From 71e65ed1162659f791de2d13a830d06580067eb4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 23 Jun 2013 09:30:04 +0200 Subject: [PATCH 0001/1509] - GZDoom differences to /wadsrc. --- wadsrc/CMakeLists.txt | 9 +- wadsrc/static/actors/doom/doomarmor.txt | 2 +- wadsrc/static/decorate.z | 102 ++++++++++ wadsrc/static/menudef.z | 246 ++++++++++++++++++++++++ wadsrc/wadsrc.vcproj | 16 +- 5 files changed, 362 insertions(+), 13 deletions(-) create mode 100644 wadsrc/static/decorate.z create mode 100644 wadsrc/static/menudef.z diff --git a/wadsrc/CMakeLists.txt b/wadsrc/CMakeLists.txt index 422052511..1f36c71a6 100644 --- a/wadsrc/CMakeLists.txt +++ b/wadsrc/CMakeLists.txt @@ -2,10 +2,11 @@ cmake_minimum_required( VERSION 2.4 ) get_target_property(ZIPDIR_EXE zipdir LOCATION) -add_custom_command( OUTPUT ${ZDOOM_OUTPUT_DIR}/zdoom.pk3 - COMMAND ${ZIPDIR_EXE} -udf ${ZDOOM_OUTPUT_DIR}/zdoom.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ZDOOM_OUTPUT_DIR}/zdoom.pk3 $ +add_custom_command( OUTPUT ${ZDOOM_OUTPUT_DIR}/gzdoom.pk3 + COMMAND ${ZIPDIR_EXE} -udf ${ZDOOM_OUTPUT_DIR}/gzdoom.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ZDOOM_OUTPUT_DIR}/gzdoom.pk3 $ DEPENDS zipdir ${CMAKE_CURRENT_SOURCE_DIR}/static ) add_custom_target( pk3 ALL - DEPENDS ${ZDOOM_OUTPUT_DIR}/zdoom.pk3 ) + DEPENDS ${ZDOOM_OUTPUT_DIR}/gzdoom.pk3 ) + diff --git a/wadsrc/static/actors/doom/doomarmor.txt b/wadsrc/static/actors/doom/doomarmor.txt index 486fc0611..c40bd1dc1 100644 --- a/wadsrc/static/actors/doom/doomarmor.txt +++ b/wadsrc/static/actors/doom/doomarmor.txt @@ -8,7 +8,7 @@ Actor ArmorBonus : BasicArmorBonus 2015 Radius 20 Height 16 Inventory.Pickupmessage "$GOTARMBONUS" - Inventory.Icon "ARM1A0" + Inventory.Icon "BON2A0" Armor.Savepercent 33.335 Armor.Saveamount 1 Armor.Maxsaveamount 200 diff --git a/wadsrc/static/decorate.z b/wadsrc/static/decorate.z new file mode 100644 index 000000000..7a14a0281 --- /dev/null +++ b/wadsrc/static/decorate.z @@ -0,0 +1,102 @@ +ACTOR DynamicLight native +{ + Height 0 + Radius 0.1 + FloatBobPhase 0 + +NOBLOCKMAP + +NOGRAVITY + +FIXMAPTHINGPOS + +INVISIBLE +} + + +ACTOR PointLight : DynamicLight 9800 +{ + DynamicLight.Type "Point" +} + +ACTOR PointLightPulse : PointLight 9801 +{ + DynamicLight.Type "Pulse" +} + +ACTOR PointLightFlicker : PointLight 9802 +{ + DynamicLight.Type "Flicker" +} + +ACTOR SectorPointLight : PointLight 9803 +{ + DynamicLight.Type "Sector" +} + +ACTOR PointLightFlickerRandom : PointLight 9804 +{ + DynamicLight.Type "RandomFlicker" +} + +// MISSILEMORE and MISSILEEVENMORE are used by the lights for additive and subtractive lights + +ACTOR PointLightAdditive : PointLight 9810 +{ + +MISSILEMORE +} + +ACTOR PointLightPulseAdditive : PointLightPulse 9811 +{ + +MISSILEMORE +} + +ACTOR PointLightFlickerAdditive : PointLightFlicker 9812 +{ + +MISSILEMORE +} + +ACTOR SectorPointLightAdditive : SectorPointLight 9813 +{ + +MISSILEMORE +} + +ACTOR PointLightFlickerRandomAdditive :PointLightFlickerRandom 9814 +{ + +MISSILEMORE +} + +ACTOR PointLightSubtractive : PointLight 9820 +{ + +MISSILEEVENMORE +} + +ACTOR PointLightPulseSubtractive : PointLightPulse 9821 +{ + +MISSILEEVENMORE +} + +ACTOR PointLightFlickerSubtractive : PointLightFlicker 9822 +{ + +MISSILEEVENMORE +} + +ACTOR SectorPointLightSubtractive : SectorPointLight 9823 +{ + +MISSILEEVENMORE +} + +ACTOR PointLightFlickerRandomSubtractive : PointLightFlickerRandom 9824 +{ + +MISSILEEVENMORE +} + + +ACTOR VavoomLight : DynamicLight 9825 native +{ +} + +ACTOR VavoomLightWhite : VavoomLight 1502 native +{ +} + +ACTOR VavoomLightColor : VavoomLight 1503 native +{ +} + diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z new file mode 100644 index 000000000..329042b74 --- /dev/null +++ b/wadsrc/static/menudef.z @@ -0,0 +1,246 @@ +OptionValue "SpriteclipModes" +{ + 0, "Never" + 1, "Smart" + 2, "Always" + 3, "Smarter" +} + +OptionValue "EnhancedStealth" +{ + 0, "Never" + 1, "Infrared only" + 2, "Infrared and torch" + 3, "Any fixed colormap" +} + +OptionValue "VBOModes" +{ + 0, "Off" + 1, "Static" + 2, "Dynamic" +} + +OptionValue "FilterModes" +{ + 0, "None" + 1, "None (nearest mipmap)" + 5, "None (linear mipmap)" + 2, "Linear" + 3, "Bilinear" + 4, "Trilinear" +} + +OptionValue "TextureFormats" +{ + 0, "RGBA8" + 1, "RGB5_A1" + 2, "RGBA4" + 3, "RGBA2" + // [BB] Added modes for texture compression. + 4, "COMPR_RGBA" + 5, "S3TC_DXT1" + 6, "S3TC_DXT3" + 7, "S3TC_DXT5" +} + +OptionValue "Anisotropy" +{ + 1, "Off" + 2, "2x" + 4, "4x" + 8, "8x" + 16, "16x" +} + +OptionValue "Colormaps" +{ + 0, "Use as palette" + 1, "Blend" +} + +OptionValue "LightingModes" +{ + 0, "Standard" + 1, "Bright" + 2, "Doom" + 3, "Dark" + 4, "Legacy" + 8, "Software" +} + +OptionValue "Precision" +{ + 0, "Speed" + 1, "Quality" +} + + +OptionValue "Hz" +{ + 0, "Optimal" + 60, "60" + 70, "70" + 72, "72" + 75, "75" + 85, "85" + 100, "100" +} + +OptionValue "BillboardModes" +{ + 0, "Y Axis" + 1, "X/Y Axis" +} + + +OptionValue "Particles" +{ + 0, "Square" + 1, "Round" + 2, "Smooth" +} + +OptionValue "HqResizeModes" +{ + 0, "Off" + 1, "Scale2x" + 2, "Scale3x" + 3, "Scale4x" + 4, "hq2x" + 5, "hq3x" + 6, "hq4x" +} + +OptionValue "HqResizeTargets" +{ + 0, "Everything" + 1, "Sprites/fonts" +} + +OptionValue "FogMode" +{ + 0, "Off" + 1, "Standard" + 2, "Radial" +} + +OptionValue "FuzzStyle" +{ + 0, "Shadow" + 1, "Pixel fuzz" + 2, "Smooth fuzz" + 3, "Swirly fuzz" + 4, "Translucent fuzz" + 6, "Noise" + 7, "Smooth Noise" + //5, "Jagged fuzz" I can't see any difference between this and 4 so it's disabled for now. +} + +OptionMenu "GLTextureGLOptions" +{ + Title "TEXTURE OPTIONS" + Option "Textures enabled", gl_texture, "YesNo" + Option "Texture Filter mode", gl_texture_filter, "FilterModes" + Option "Anisotropic filter", gl_texture_filter_anisotropic, "Anisotropy" + Option "Texture Format", gl_texture_format, "TextureFormats" + Option "Enable hires textures", gl_texture_usehires, "YesNo" + Option "High Quality Resize mode", gl_texture_hqresize, "HqResizeModes" + Option "Resize textures", gl_texture_hqresize_textures, "OnOff" + Option "Resize sprites", gl_texture_hqresize_sprites, "OnOff" + Option "Resize fonts", gl_texture_hqresize_fonts, "OnOff" + Option "Precache GL textures", gl_precache, "YesNo" + Option "Camera textures offscreen", gl_usefb, "OnOff" + Option "Trim sprite edges", gl_trimsprites, "OnOff" +} + +OptionMenu "GLLightOptions" +{ + Title "DYNAMIC LIGHTS" + Option "Dynamic Lights enabled", gl_lights, "YesNo" + Option "Enable light definitions", gl_attachedlights, "YesNo" + Option "Clip lights", gl_lights_checkside, "YesNo" + Option "Lights affect sprites", gl_light_sprites, "YesNo" + Option "Lights affect particles", gl_light_particles, "YesNo" + Option "Force additive lighting", gl_lights_additive, "YesNo" + Slider "Light intensity", gl_lights_intensity, 0.0, 1.0, 0.1 + Slider "Light size", gl_lights_size, 0.0, 2.0, 0.1 + Option "Use shaders for lights", gl_dynlight_shader, "YesNo" +} + +OptionMenu "GLPrefOptions" +{ + Title "OPENGL PREFERENCES" + Option "Sector light mode", gl_lightmode, "LightingModes" + Option "Fog mode", gl_fogmode, "FogMode" + Option "Fog forces fullbright", gl_brightfog, "YesNo" + Slider "Weapon light strength", gl_weaponlight, 0,32, 2 + Option "Environment map on mirrors",gl_mirror_envmap, "OnOff" + Option "Enhanced night vision mode",gl_enhanced_nightvision, "OnOff" + Option "ENV shows stealth monsters",gl_enhanced_nv_stealth, "EnhancedStealth" + Option "Force brightness in fog", gl_spritebrightfog, "OnOff" + Option "Adjust sprite clipping", gl_spriteclip, "SpriteclipModes" + Option "Smooth sprite edges", gl_sprite_blend, "OnOff" + Option "Fuzz Style", gl_fuzztype, "FuzzStyle" + Option "Sprite billboard", gl_billboard_mode, "BillboardModes" + Option "Particle style", gl_particles_style, "Particles" + Slider "Ambient light level", gl_light_ambient, 1.0, 255.0, 5.0 + Option "Rendering quality", gl_render_precise, "Precision" + Option "Use vertex buffer", gl_usevbo, "VBOModes" +} + +OptionMenu "GLShaderOptions" +{ + Title "SHADER OPTIONS" + Option "Enable brightness maps", gl_brightmap_shader, "OnOff" + Option "Shaders for texture warp", gl_warp_shader, "OnOff" + Option "Shaders for fog", gl_fog_shader, "OnOff" + Option "Shaders for colormaps", gl_colormap_shader, "OnOff" + Option "Shaders for glowing textures", gl_glow_shader, "OnOff" +} + +OptionMenu "OpenGLOptions" +{ + Title "OPENGL OPTIONS" + Submenu "Dynamic Light Options", "GLLightOptions" + Submenu "Texture Options", "GLTextureGLOptions" + Submenu "Shader Options", "GLShaderOptions" + Submenu "Preferences", "GLPrefOptions" +} + +OptionMenu "VideoOptions" +{ + Title "DISPLAY OPTIONS" + + Submenu "OpenGL Options", "OpenGLOptions" + Submenu "Scoreboard Options", "ScoreboardOptions" + StaticText " " + Slider "Screen size", "screenblocks", 3.0, 12.0, 1.0, 0 + + Slider "Gamma correction", "Gamma", 0.75, 3.0, 0.05, 2 + Slider "Brightness", "vid_brightness", -0.8,0.8, 0.05 + Slider "Contrast", "vid_contrast", 0.1, 3.0, 0.1 + + Option "Vertical Sync", "vid_vsync", "OnOff" + + StaticText " " + Option "Screen wipe style", "wipetype", "Wipes" + + IfOption(Windows) + { + Option "Show ENDOOM screen", "showendoom", "Endoom" + } + + Option "Stretch short skies", "r_stretchsky", "OnOff" + Option "Use fuzz effect", "r_drawfuzz", "Fuzziness" + Slider "Lost Soul translucency", "transsouls", 0.25, 1.0, 0.05, 2 + Option "Use fake contrast", "r_fakecontrast", "Contrast" + Option "Rocket Trails", "cl_rockettrails", "RocketTrailTypes" + Option "Blood Type", "cl_bloodtype", "BloodTypes" + Option "Bullet Puff Type", "cl_pufftype", "PuffTypes" + Slider "Number of particles", "r_maxparticles", 100, 10000, 100, 0 + Option "Show player sprites", "r_drawplayersprites", "OnOff" + Option "Death camera", "r_deathcamera", "OnOff" + Option "Teleporter zoom", "telezoom", "OnOff" + Option "Interpolate monster movement", "nomonsterinterpolation", "NoYes" +} diff --git a/wadsrc/wadsrc.vcproj b/wadsrc/wadsrc.vcproj index 1baa29aa5..48545734b 100644 --- a/wadsrc/wadsrc.vcproj +++ b/wadsrc/wadsrc.vcproj @@ -36,8 +36,8 @@ /> From 8c319557317673d3dc1e44fb1cb3ed671ed56b3b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 23 Jun 2013 09:32:35 +0200 Subject: [PATCH 0002/1509] - brightmap and light definitions. --- CMakeLists.txt | 6 +- wadsrc_bm/CMakeLists.txt | 9 + wadsrc_bm/brightmaps.vcproj | 120 + wadsrc_bm/static/brightmaps/doom/BON2B0.png | Bin 0 -> 99 bytes wadsrc_bm/static/brightmaps/doom/BON2C0.png | Bin 0 -> 97 bytes wadsrc_bm/static/brightmaps/doom/BON2D0.png | Bin 0 -> 98 bytes wadsrc_bm/static/brightmaps/doom/BOS2A6C4.png | Bin 0 -> 111 bytes wadsrc_bm/static/brightmaps/doom/BOS2A7C3.png | Bin 0 -> 135 bytes wadsrc_bm/static/brightmaps/doom/BOS2A8C2.png | Bin 0 -> 144 bytes wadsrc_bm/static/brightmaps/doom/BOS2B6D4.png | Bin 0 -> 107 bytes wadsrc_bm/static/brightmaps/doom/BOS2B7D3.png | Bin 0 -> 120 bytes wadsrc_bm/static/brightmaps/doom/BOS2B8D2.png | Bin 0 -> 135 bytes wadsrc_bm/static/brightmaps/doom/BOSSA1.png | Bin 0 -> 116 bytes wadsrc_bm/static/brightmaps/doom/BOSSA2A8.png | Bin 0 -> 119 bytes wadsrc_bm/static/brightmaps/doom/BOSSA3A7.png | Bin 0 -> 115 bytes wadsrc_bm/static/brightmaps/doom/BOSSA4A6.png | Bin 0 -> 137 bytes wadsrc_bm/static/brightmaps/doom/BOSSA5.png | Bin 0 -> 121 bytes wadsrc_bm/static/brightmaps/doom/BOSSB1.png | Bin 0 -> 144 bytes wadsrc_bm/static/brightmaps/doom/BOSSB2B8.png | Bin 0 -> 136 bytes wadsrc_bm/static/brightmaps/doom/BOSSB3B7.png | Bin 0 -> 118 bytes wadsrc_bm/static/brightmaps/doom/BOSSB4B6.png | Bin 0 -> 110 bytes wadsrc_bm/static/brightmaps/doom/BOSSB5.png | Bin 0 -> 140 bytes wadsrc_bm/static/brightmaps/doom/BOSSC1.png | Bin 0 -> 115 bytes wadsrc_bm/static/brightmaps/doom/BOSSC2C8.png | Bin 0 -> 143 bytes wadsrc_bm/static/brightmaps/doom/BOSSC3C7.png | Bin 0 -> 137 bytes wadsrc_bm/static/brightmaps/doom/BOSSC4C6.png | Bin 0 -> 112 bytes wadsrc_bm/static/brightmaps/doom/BOSSC5.png | Bin 0 -> 121 bytes wadsrc_bm/static/brightmaps/doom/BOSSD1.png | Bin 0 -> 139 bytes wadsrc_bm/static/brightmaps/doom/BOSSD2D8.png | Bin 0 -> 133 bytes wadsrc_bm/static/brightmaps/doom/BOSSD3D7.png | Bin 0 -> 125 bytes wadsrc_bm/static/brightmaps/doom/BOSSD4D6.png | Bin 0 -> 106 bytes wadsrc_bm/static/brightmaps/doom/BOSSD5.png | Bin 0 -> 139 bytes wadsrc_bm/static/brightmaps/doom/BOSSE1.png | Bin 0 -> 357 bytes wadsrc_bm/static/brightmaps/doom/BOSSE2.png | Bin 0 -> 196 bytes wadsrc_bm/static/brightmaps/doom/BOSSE3.png | Bin 0 -> 233 bytes wadsrc_bm/static/brightmaps/doom/BOSSE4.png | Bin 0 -> 294 bytes wadsrc_bm/static/brightmaps/doom/BOSSE5.png | Bin 0 -> 291 bytes wadsrc_bm/static/brightmaps/doom/BOSSE6.png | Bin 0 -> 267 bytes wadsrc_bm/static/brightmaps/doom/BOSSE7.png | Bin 0 -> 305 bytes wadsrc_bm/static/brightmaps/doom/BOSSE8.png | Bin 0 -> 299 bytes wadsrc_bm/static/brightmaps/doom/BOSSF1.png | Bin 0 -> 375 bytes wadsrc_bm/static/brightmaps/doom/BOSSF2.png | Bin 0 -> 398 bytes wadsrc_bm/static/brightmaps/doom/BOSSF3.png | Bin 0 -> 217 bytes wadsrc_bm/static/brightmaps/doom/BOSSF4.png | Bin 0 -> 216 bytes wadsrc_bm/static/brightmaps/doom/BOSSF5.png | Bin 0 -> 270 bytes wadsrc_bm/static/brightmaps/doom/BOSSF6.png | Bin 0 -> 268 bytes wadsrc_bm/static/brightmaps/doom/BOSSF7.png | Bin 0 -> 337 bytes wadsrc_bm/static/brightmaps/doom/BOSSF8.png | Bin 0 -> 366 bytes wadsrc_bm/static/brightmaps/doom/BOSSG1.png | Bin 0 -> 330 bytes wadsrc_bm/static/brightmaps/doom/BOSSG2.png | Bin 0 -> 312 bytes wadsrc_bm/static/brightmaps/doom/BOSSG3.png | Bin 0 -> 313 bytes wadsrc_bm/static/brightmaps/doom/BOSSG4.png | Bin 0 -> 261 bytes wadsrc_bm/static/brightmaps/doom/BOSSG5.png | Bin 0 -> 198 bytes wadsrc_bm/static/brightmaps/doom/BOSSG6.png | Bin 0 -> 203 bytes wadsrc_bm/static/brightmaps/doom/BOSSG7.png | Bin 0 -> 228 bytes wadsrc_bm/static/brightmaps/doom/BOSSG8.png | Bin 0 -> 243 bytes wadsrc_bm/static/brightmaps/doom/BOSSH1.png | Bin 0 -> 167 bytes wadsrc_bm/static/brightmaps/doom/BOSSH2.png | Bin 0 -> 194 bytes wadsrc_bm/static/brightmaps/doom/BOSSH3.png | Bin 0 -> 173 bytes wadsrc_bm/static/brightmaps/doom/BOSSH4.png | Bin 0 -> 120 bytes wadsrc_bm/static/brightmaps/doom/BOSSH5.png | Bin 0 -> 126 bytes wadsrc_bm/static/brightmaps/doom/BOSSH6.png | Bin 0 -> 125 bytes wadsrc_bm/static/brightmaps/doom/BOSSH7.png | Bin 0 -> 158 bytes wadsrc_bm/static/brightmaps/doom/BOSSH8.png | Bin 0 -> 161 bytes wadsrc_bm/static/brightmaps/doom/BOSSI0.png | Bin 0 -> 144 bytes wadsrc_bm/static/brightmaps/doom/BOSSJ0.png | Bin 0 -> 150 bytes wadsrc_bm/static/brightmaps/doom/BOSSK0.png | Bin 0 -> 137 bytes wadsrc_bm/static/brightmaps/doom/BOSSL0.png | Bin 0 -> 130 bytes wadsrc_bm/static/brightmaps/doom/BOSSM0.png | Bin 0 -> 107 bytes wadsrc_bm/static/brightmaps/doom/BSPIG1.png | Bin 0 -> 131 bytes wadsrc_bm/static/brightmaps/doom/BSPIG2G8.png | Bin 0 -> 102 bytes wadsrc_bm/static/brightmaps/doom/BSPIH1.png | Bin 0 -> 157 bytes wadsrc_bm/static/brightmaps/doom/BSPIH2H8.png | Bin 0 -> 168 bytes wadsrc_bm/static/brightmaps/doom/BSPIH3H7.png | Bin 0 -> 112 bytes wadsrc_bm/static/brightmaps/doom/BSPIH4H6.png | Bin 0 -> 118 bytes wadsrc_bm/static/brightmaps/doom/BSPIH5.png | Bin 0 -> 121 bytes wadsrc_bm/static/brightmaps/doom/CELLA0.png | Bin 0 -> 94 bytes wadsrc_bm/static/brightmaps/doom/CELPA0.png | Bin 0 -> 100 bytes wadsrc_bm/static/brightmaps/doom/CPOSE1.png | Bin 0 -> 121 bytes wadsrc_bm/static/brightmaps/doom/CPOSE2.png | Bin 0 -> 137 bytes wadsrc_bm/static/brightmaps/doom/CPOSE3.png | Bin 0 -> 146 bytes wadsrc_bm/static/brightmaps/doom/CPOSE5.png | Bin 0 -> 116 bytes wadsrc_bm/static/brightmaps/doom/CPOSE6.png | Bin 0 -> 116 bytes wadsrc_bm/static/brightmaps/doom/CPOSE7.png | Bin 0 -> 138 bytes wadsrc_bm/static/brightmaps/doom/CPOSE8.png | Bin 0 -> 143 bytes wadsrc_bm/static/brightmaps/doom/CPOSF1.png | Bin 0 -> 467 bytes wadsrc_bm/static/brightmaps/doom/CPOSF2.png | Bin 0 -> 488 bytes wadsrc_bm/static/brightmaps/doom/CPOSF3.png | Bin 0 -> 400 bytes wadsrc_bm/static/brightmaps/doom/CPOSF4.png | Bin 0 -> 178 bytes wadsrc_bm/static/brightmaps/doom/CPOSF5.png | Bin 0 -> 143 bytes wadsrc_bm/static/brightmaps/doom/CPOSF6.png | Bin 0 -> 214 bytes wadsrc_bm/static/brightmaps/doom/CPOSF7.png | Bin 0 -> 341 bytes wadsrc_bm/static/brightmaps/doom/CPOSF8.png | Bin 0 -> 352 bytes wadsrc_bm/static/brightmaps/doom/CYBRF1.png | Bin 0 -> 1895 bytes wadsrc_bm/static/brightmaps/doom/CYBRF2.png | Bin 0 -> 1976 bytes wadsrc_bm/static/brightmaps/doom/CYBRF3.png | Bin 0 -> 1830 bytes wadsrc_bm/static/brightmaps/doom/CYBRF4.png | Bin 0 -> 1540 bytes wadsrc_bm/static/brightmaps/doom/CYBRF5.png | Bin 0 -> 1014 bytes wadsrc_bm/static/brightmaps/doom/CYBRF6.png | Bin 0 -> 852 bytes wadsrc_bm/static/brightmaps/doom/CYBRF7.png | Bin 0 -> 1597 bytes wadsrc_bm/static/brightmaps/doom/CYBRF8.png | Bin 0 -> 2259 bytes wadsrc_bm/static/brightmaps/doom/CYBRJ0.png | Bin 0 -> 292 bytes wadsrc_bm/static/brightmaps/doom/CYBRK0.png | Bin 0 -> 420 bytes wadsrc_bm/static/brightmaps/doom/CYBRL0.png | Bin 0 -> 576 bytes wadsrc_bm/static/brightmaps/doom/CYBRM0.png | Bin 0 -> 1236 bytes wadsrc_bm/static/brightmaps/doom/CYBRN0.png | Bin 0 -> 1606 bytes wadsrc_bm/static/brightmaps/doom/CYBRO0.png | Bin 0 -> 1167 bytes wadsrc_bm/static/brightmaps/doom/FATTG1.png | Bin 0 -> 111 bytes wadsrc_bm/static/brightmaps/doom/FATTG2G8.png | Bin 0 -> 110 bytes wadsrc_bm/static/brightmaps/doom/FATTH1.png | Bin 0 -> 266 bytes wadsrc_bm/static/brightmaps/doom/FATTH2H8.png | Bin 0 -> 184 bytes wadsrc_bm/static/brightmaps/doom/FATTH3H7.png | Bin 0 -> 182 bytes wadsrc_bm/static/brightmaps/doom/FATTH4H6.png | Bin 0 -> 140 bytes wadsrc_bm/static/brightmaps/doom/FATTH5.png | Bin 0 -> 114 bytes wadsrc_bm/static/brightmaps/doom/FCANA0.png | Bin 0 -> 350 bytes wadsrc_bm/static/brightmaps/doom/FCANB0.png | Bin 0 -> 326 bytes wadsrc_bm/static/brightmaps/doom/FCANC0.png | Bin 0 -> 315 bytes wadsrc_bm/static/brightmaps/doom/HEADC1.png | Bin 0 -> 186 bytes wadsrc_bm/static/brightmaps/doom/HEADC2C8.png | Bin 0 -> 157 bytes wadsrc_bm/static/brightmaps/doom/HEADC3C7.png | Bin 0 -> 127 bytes wadsrc_bm/static/brightmaps/doom/HEADD1.png | Bin 0 -> 215 bytes wadsrc_bm/static/brightmaps/doom/HEADD2D8.png | Bin 0 -> 166 bytes wadsrc_bm/static/brightmaps/doom/HEADD3D7.png | Bin 0 -> 159 bytes wadsrc_bm/static/brightmaps/doom/PAINF1.png | Bin 0 -> 233 bytes wadsrc_bm/static/brightmaps/doom/PAINF2F8.png | Bin 0 -> 206 bytes wadsrc_bm/static/brightmaps/doom/PAINF3F7.png | Bin 0 -> 161 bytes wadsrc_bm/static/brightmaps/doom/PLAYF1.png | Bin 0 -> 330 bytes wadsrc_bm/static/brightmaps/doom/PLAYF2F8.png | Bin 0 -> 367 bytes wadsrc_bm/static/brightmaps/doom/PLAYF3F7.png | Bin 0 -> 355 bytes wadsrc_bm/static/brightmaps/doom/PLAYF4F6.png | Bin 0 -> 286 bytes wadsrc_bm/static/brightmaps/doom/PLAYF5.png | Bin 0 -> 275 bytes wadsrc_bm/static/brightmaps/doom/POSSE1.png | Bin 0 -> 97 bytes wadsrc_bm/static/brightmaps/doom/POSSE2E8.png | Bin 0 -> 97 bytes wadsrc_bm/static/brightmaps/doom/POSSE3E7.png | Bin 0 -> 98 bytes wadsrc_bm/static/brightmaps/doom/POSSF1.png | Bin 0 -> 215 bytes wadsrc_bm/static/brightmaps/doom/POSSF2F8.png | Bin 0 -> 232 bytes wadsrc_bm/static/brightmaps/doom/POSSF3F7.png | Bin 0 -> 202 bytes wadsrc_bm/static/brightmaps/doom/POSSF4F6.png | Bin 0 -> 165 bytes wadsrc_bm/static/brightmaps/doom/POSSF5.png | Bin 0 -> 127 bytes wadsrc_bm/static/brightmaps/doom/SKELJ1.png | Bin 0 -> 153 bytes wadsrc_bm/static/brightmaps/doom/SKELJ2.png | Bin 0 -> 141 bytes wadsrc_bm/static/brightmaps/doom/SKELJ3.png | Bin 0 -> 122 bytes wadsrc_bm/static/brightmaps/doom/SKELJ4.png | Bin 0 -> 122 bytes wadsrc_bm/static/brightmaps/doom/SKELJ5.png | Bin 0 -> 126 bytes wadsrc_bm/static/brightmaps/doom/SKELJ6.png | Bin 0 -> 122 bytes wadsrc_bm/static/brightmaps/doom/SKELJ7.png | Bin 0 -> 117 bytes wadsrc_bm/static/brightmaps/doom/SKELJ8.png | Bin 0 -> 141 bytes wadsrc_bm/static/brightmaps/doom/SMRTA0.png | Bin 0 -> 240 bytes wadsrc_bm/static/brightmaps/doom/SMRTB0.png | Bin 0 -> 248 bytes wadsrc_bm/static/brightmaps/doom/SMRTC0.png | Bin 0 -> 245 bytes wadsrc_bm/static/brightmaps/doom/SMRTD0.png | Bin 0 -> 250 bytes wadsrc_bm/static/brightmaps/doom/SPIDG1.png | Bin 0 -> 125 bytes wadsrc_bm/static/brightmaps/doom/SPIDG2G8.png | Bin 0 -> 130 bytes wadsrc_bm/static/brightmaps/doom/SPIDH1.png | Bin 0 -> 147 bytes wadsrc_bm/static/brightmaps/doom/SPIDH2H8.png | Bin 0 -> 152 bytes wadsrc_bm/static/brightmaps/doom/SPIDH3H7.png | Bin 0 -> 129 bytes wadsrc_bm/static/brightmaps/doom/SPIDL0.png | Bin 0 -> 142 bytes wadsrc_bm/static/brightmaps/doom/SPIDM0.png | Bin 0 -> 467 bytes wadsrc_bm/static/brightmaps/doom/SPIDN0.png | Bin 0 -> 535 bytes wadsrc_bm/static/brightmaps/doom/SPIDO0.png | Bin 0 -> 520 bytes wadsrc_bm/static/brightmaps/doom/SPIDP0.png | Bin 0 -> 804 bytes wadsrc_bm/static/brightmaps/doom/SPIDQ0.png | Bin 0 -> 1284 bytes wadsrc_bm/static/brightmaps/doom/SPIDR0.png | Bin 0 -> 1762 bytes wadsrc_bm/static/brightmaps/doom/SPOSE1.png | Bin 0 -> 97 bytes wadsrc_bm/static/brightmaps/doom/SPOSE2E8.png | Bin 0 -> 97 bytes wadsrc_bm/static/brightmaps/doom/SPOSE3E7.png | Bin 0 -> 97 bytes wadsrc_bm/static/brightmaps/doom/SPOSF1.png | Bin 0 -> 272 bytes wadsrc_bm/static/brightmaps/doom/SPOSF2F8.png | Bin 0 -> 257 bytes wadsrc_bm/static/brightmaps/doom/SPOSF3F7.png | Bin 0 -> 266 bytes wadsrc_bm/static/brightmaps/doom/SPOSF4F6.png | Bin 0 -> 245 bytes wadsrc_bm/static/brightmaps/doom/SPOSF5.png | Bin 0 -> 155 bytes wadsrc_bm/static/brightmaps/doom/TREDA0.png | Bin 0 -> 609 bytes wadsrc_bm/static/brightmaps/doom/TREDB0.png | Bin 0 -> 628 bytes wadsrc_bm/static/brightmaps/doom/TREDC0.png | Bin 0 -> 629 bytes wadsrc_bm/static/brightmaps/doom/TREDD0.png | Bin 0 -> 635 bytes wadsrc_bm/static/brightmaps/doom/TbluB0.png | Bin 0 -> 632 bytes wadsrc_bm/static/brightmaps/doom/TbluC0.png | Bin 0 -> 638 bytes wadsrc_bm/static/brightmaps/doom/sswvg0.png | Bin 0 -> 124 bytes wadsrc_bm/static/brightmaps/doom/vileg1.png | Bin 0 -> 301 bytes wadsrc_bm/static/brightmaps/doom/vileg2.png | Bin 0 -> 369 bytes wadsrc_bm/static/brightmaps/doom/vileg3.png | Bin 0 -> 343 bytes wadsrc_bm/static/brightmaps/doom/vileg4.png | Bin 0 -> 361 bytes wadsrc_bm/static/brightmaps/doom/vileg5.png | Bin 0 -> 313 bytes wadsrc_bm/static/brightmaps/doom/vileg6.png | Bin 0 -> 368 bytes wadsrc_bm/static/brightmaps/doom/vileg7.png | Bin 0 -> 343 bytes wadsrc_bm/static/brightmaps/doom/vileg8.png | Bin 0 -> 370 bytes wadsrc_bm/static/brightmaps/doom/vileh1.png | Bin 0 -> 859 bytes wadsrc_bm/static/brightmaps/doom/vileh2.png | Bin 0 -> 660 bytes wadsrc_bm/static/brightmaps/doom/vileh3.png | Bin 0 -> 703 bytes wadsrc_bm/static/brightmaps/doom/vileh4.png | Bin 0 -> 802 bytes wadsrc_bm/static/brightmaps/doom/vileh5.png | Bin 0 -> 787 bytes wadsrc_bm/static/brightmaps/doom/vileh6.png | Bin 0 -> 792 bytes wadsrc_bm/static/brightmaps/doom/vileh7.png | Bin 0 -> 931 bytes wadsrc_bm/static/brightmaps/doom/vileh8.png | Bin 0 -> 1142 bytes wadsrc_bm/static/brightmaps/doom/vilei1.png | Bin 0 -> 1175 bytes wadsrc_bm/static/brightmaps/doom/vilei2.png | Bin 0 -> 1185 bytes wadsrc_bm/static/brightmaps/doom/vilei3.png | Bin 0 -> 917 bytes wadsrc_bm/static/brightmaps/doom/vilei4.png | Bin 0 -> 1099 bytes wadsrc_bm/static/brightmaps/doom/vilei5.png | Bin 0 -> 1063 bytes wadsrc_bm/static/brightmaps/doom/vilei6.png | Bin 0 -> 990 bytes wadsrc_bm/static/brightmaps/doom/vilei7.png | Bin 0 -> 937 bytes wadsrc_bm/static/brightmaps/doom/vilei8.png | Bin 0 -> 1031 bytes wadsrc_bm/static/brightmaps/doom/vilej1.png | Bin 0 -> 1285 bytes wadsrc_bm/static/brightmaps/doom/vilej2.png | Bin 0 -> 1051 bytes wadsrc_bm/static/brightmaps/doom/vilej3.png | Bin 0 -> 898 bytes wadsrc_bm/static/brightmaps/doom/vilej4.png | Bin 0 -> 843 bytes wadsrc_bm/static/brightmaps/doom/vilej5.png | Bin 0 -> 1030 bytes wadsrc_bm/static/brightmaps/doom/vilej6.png | Bin 0 -> 799 bytes wadsrc_bm/static/brightmaps/doom/vilej7.png | Bin 0 -> 870 bytes wadsrc_bm/static/brightmaps/doom/vilej8.png | Bin 0 -> 1061 bytes wadsrc_bm/static/brightmaps/doom/vilek1.png | Bin 0 -> 754 bytes wadsrc_bm/static/brightmaps/doom/vilek2.png | Bin 0 -> 668 bytes wadsrc_bm/static/brightmaps/doom/vilek3.png | Bin 0 -> 589 bytes wadsrc_bm/static/brightmaps/doom/vilek4.png | Bin 0 -> 561 bytes wadsrc_bm/static/brightmaps/doom/vilek5.png | Bin 0 -> 632 bytes wadsrc_bm/static/brightmaps/doom/vilek6.png | Bin 0 -> 553 bytes wadsrc_bm/static/brightmaps/doom/vilek7.png | Bin 0 -> 674 bytes wadsrc_bm/static/brightmaps/doom/vilek8.png | Bin 0 -> 678 bytes wadsrc_bm/static/brightmaps/doom/vilel1.png | Bin 0 -> 668 bytes wadsrc_bm/static/brightmaps/doom/vilel2.png | Bin 0 -> 625 bytes wadsrc_bm/static/brightmaps/doom/vilel3.png | Bin 0 -> 577 bytes wadsrc_bm/static/brightmaps/doom/vilel4.png | Bin 0 -> 544 bytes wadsrc_bm/static/brightmaps/doom/vilel5.png | Bin 0 -> 611 bytes wadsrc_bm/static/brightmaps/doom/vilel6.png | Bin 0 -> 505 bytes wadsrc_bm/static/brightmaps/doom/vilel7.png | Bin 0 -> 629 bytes wadsrc_bm/static/brightmaps/doom/vilel8.png | Bin 0 -> 644 bytes wadsrc_bm/static/brightmaps/doom/vilem1.png | Bin 0 -> 683 bytes wadsrc_bm/static/brightmaps/doom/vilem2.png | Bin 0 -> 682 bytes wadsrc_bm/static/brightmaps/doom/vilem3.png | Bin 0 -> 583 bytes wadsrc_bm/static/brightmaps/doom/vilem4.png | Bin 0 -> 583 bytes wadsrc_bm/static/brightmaps/doom/vilem5.png | Bin 0 -> 636 bytes wadsrc_bm/static/brightmaps/doom/vilem6.png | Bin 0 -> 513 bytes wadsrc_bm/static/brightmaps/doom/vilem7.png | Bin 0 -> 621 bytes wadsrc_bm/static/brightmaps/doom/vilem8.png | Bin 0 -> 651 bytes wadsrc_bm/static/brightmaps/doom/vilen1.png | Bin 0 -> 896 bytes wadsrc_bm/static/brightmaps/doom/vilen2.png | Bin 0 -> 895 bytes wadsrc_bm/static/brightmaps/doom/vilen3.png | Bin 0 -> 829 bytes wadsrc_bm/static/brightmaps/doom/vilen4.png | Bin 0 -> 800 bytes wadsrc_bm/static/brightmaps/doom/vilen5.png | Bin 0 -> 556 bytes wadsrc_bm/static/brightmaps/doom/vilen6.png | Bin 0 -> 618 bytes wadsrc_bm/static/brightmaps/doom/vilen7.png | Bin 0 -> 799 bytes wadsrc_bm/static/brightmaps/doom/vilen8.png | Bin 0 -> 965 bytes wadsrc_bm/static/brightmaps/doom/vileo1.png | Bin 0 -> 881 bytes wadsrc_bm/static/brightmaps/doom/vileo2.png | Bin 0 -> 959 bytes wadsrc_bm/static/brightmaps/doom/vileo3.png | Bin 0 -> 890 bytes wadsrc_bm/static/brightmaps/doom/vileo4.png | Bin 0 -> 878 bytes wadsrc_bm/static/brightmaps/doom/vileo5.png | Bin 0 -> 577 bytes wadsrc_bm/static/brightmaps/doom/vileo6.png | Bin 0 -> 710 bytes wadsrc_bm/static/brightmaps/doom/vileo7.png | Bin 0 -> 901 bytes wadsrc_bm/static/brightmaps/doom/vileo8.png | Bin 0 -> 1061 bytes wadsrc_bm/static/brightmaps/doom/vilep1.png | Bin 0 -> 932 bytes wadsrc_bm/static/brightmaps/doom/vilep2.png | Bin 0 -> 903 bytes wadsrc_bm/static/brightmaps/doom/vilep3.png | Bin 0 -> 947 bytes wadsrc_bm/static/brightmaps/doom/vilep4.png | Bin 0 -> 864 bytes wadsrc_bm/static/brightmaps/doom/vilep5.png | Bin 0 -> 676 bytes wadsrc_bm/static/brightmaps/doom/vilep6.png | Bin 0 -> 678 bytes wadsrc_bm/static/brightmaps/doom/vilep7.png | Bin 0 -> 898 bytes wadsrc_bm/static/brightmaps/doom/vilep8.png | Bin 0 -> 1027 bytes .../static/brightmaps/heretic/BEASI1.png | Bin 0 -> 123 bytes .../static/brightmaps/heretic/BEASI2I8.png | Bin 0 -> 116 bytes .../static/brightmaps/heretic/BEASI3I7.png | Bin 0 -> 125 bytes .../static/brightmaps/heretic/CHDLA0.png | Bin 0 -> 150 bytes .../static/brightmaps/heretic/CHDLB0.png | Bin 0 -> 149 bytes .../static/brightmaps/heretic/CHDLC0.png | Bin 0 -> 148 bytes .../static/brightmaps/heretic/CLNKI0.png | Bin 0 -> 145 bytes .../static/brightmaps/heretic/CLNKJ0.png | Bin 0 -> 213 bytes .../static/brightmaps/heretic/CLNKK0.png | Bin 0 -> 285 bytes .../static/brightmaps/heretic/CLNKL0.png | Bin 0 -> 254 bytes .../static/brightmaps/heretic/CLNKM0.png | Bin 0 -> 446 bytes .../static/brightmaps/heretic/CLNKN0.png | Bin 0 -> 462 bytes .../static/brightmaps/heretic/IMPXD1.png | Bin 0 -> 127 bytes .../static/brightmaps/heretic/IMPXD2.png | Bin 0 -> 128 bytes .../static/brightmaps/heretic/IMPXD3.png | Bin 0 -> 119 bytes .../static/brightmaps/heretic/IMPXD4.png | Bin 0 -> 107 bytes .../static/brightmaps/heretic/IMPXD5.png | Bin 0 -> 111 bytes .../static/brightmaps/heretic/IMPXD6.png | Bin 0 -> 124 bytes .../static/brightmaps/heretic/IMPXD7.png | Bin 0 -> 130 bytes .../static/brightmaps/heretic/IMPXD8.png | Bin 0 -> 137 bytes .../static/brightmaps/heretic/IMPXE1.png | Bin 0 -> 136 bytes .../static/brightmaps/heretic/IMPXE2.png | Bin 0 -> 132 bytes .../static/brightmaps/heretic/IMPXE3.png | Bin 0 -> 125 bytes .../static/brightmaps/heretic/IMPXE4.png | Bin 0 -> 117 bytes .../static/brightmaps/heretic/IMPXE5.png | Bin 0 -> 107 bytes .../static/brightmaps/heretic/IMPXE6.png | Bin 0 -> 131 bytes .../static/brightmaps/heretic/IMPXE7.png | Bin 0 -> 131 bytes .../static/brightmaps/heretic/IMPXE8.png | Bin 0 -> 138 bytes .../static/brightmaps/heretic/IMPXF1.png | Bin 0 -> 134 bytes .../static/brightmaps/heretic/IMPXF2.png | Bin 0 -> 131 bytes .../static/brightmaps/heretic/IMPXF3.png | Bin 0 -> 117 bytes .../static/brightmaps/heretic/IMPXF4.png | Bin 0 -> 123 bytes .../static/brightmaps/heretic/IMPXF5.png | Bin 0 -> 125 bytes .../static/brightmaps/heretic/IMPXF6.png | Bin 0 -> 120 bytes .../static/brightmaps/heretic/IMPXF7.png | Bin 0 -> 118 bytes .../static/brightmaps/heretic/IMPXF8.png | Bin 0 -> 126 bytes .../static/brightmaps/heretic/LICHB1.png | Bin 0 -> 150 bytes .../static/brightmaps/heretic/LICHB2B8.png | Bin 0 -> 160 bytes .../static/brightmaps/heretic/LICHB3B7.png | Bin 0 -> 129 bytes .../static/brightmaps/heretic/LICHC0.png | Bin 0 -> 276 bytes .../static/brightmaps/heretic/LICHD0.png | Bin 0 -> 315 bytes .../static/brightmaps/heretic/LICHE0.png | Bin 0 -> 631 bytes .../static/brightmaps/heretic/LICHF0.png | Bin 0 -> 436 bytes .../static/brightmaps/heretic/LICHG0.png | Bin 0 -> 525 bytes .../static/brightmaps/heretic/LICHH0.png | Bin 0 -> 396 bytes .../static/brightmaps/heretic/PLAYF1.png | Bin 0 -> 126 bytes .../static/brightmaps/heretic/PLAYF2F8.png | Bin 0 -> 126 bytes .../static/brightmaps/heretic/PLAYF3F7.png | Bin 0 -> 139 bytes .../static/brightmaps/heretic/PLAYF4F6.png | Bin 0 -> 135 bytes .../static/brightmaps/heretic/SDTHA0.png | Bin 0 -> 291 bytes .../static/brightmaps/heretic/SDTHB0.png | Bin 0 -> 462 bytes .../static/brightmaps/heretic/SDTHC0.png | Bin 0 -> 608 bytes .../static/brightmaps/heretic/SDTHD0.png | Bin 0 -> 989 bytes .../static/brightmaps/heretic/SDTHE0.png | Bin 0 -> 1025 bytes .../static/brightmaps/heretic/SDTHF0.png | Bin 0 -> 1021 bytes .../static/brightmaps/heretic/SDTHG0.png | Bin 0 -> 728 bytes .../static/brightmaps/heretic/SDTHH0.png | Bin 0 -> 418 bytes .../static/brightmaps/heretic/SOR2R1.png | Bin 0 -> 298 bytes .../static/brightmaps/heretic/SOR2R2.png | Bin 0 -> 333 bytes .../static/brightmaps/heretic/SOR2R3.png | Bin 0 -> 256 bytes .../static/brightmaps/heretic/SOR2R4.png | Bin 0 -> 309 bytes .../static/brightmaps/heretic/SOR2R5.png | Bin 0 -> 354 bytes .../static/brightmaps/heretic/SOR2R6.png | Bin 0 -> 320 bytes .../static/brightmaps/heretic/SOR2R7.png | Bin 0 -> 232 bytes .../static/brightmaps/heretic/SOR2R8.png | Bin 0 -> 310 bytes .../static/brightmaps/heretic/SOR2S1.png | Bin 0 -> 386 bytes .../static/brightmaps/heretic/SOR2S2.png | Bin 0 -> 329 bytes .../static/brightmaps/heretic/SOR2S3.png | Bin 0 -> 234 bytes .../static/brightmaps/heretic/SOR2S4.png | Bin 0 -> 376 bytes .../static/brightmaps/heretic/SOR2S5.png | Bin 0 -> 423 bytes .../static/brightmaps/heretic/SOR2S6.png | Bin 0 -> 377 bytes .../static/brightmaps/heretic/SOR2S7.png | Bin 0 -> 228 bytes .../static/brightmaps/heretic/SOR2S8.png | Bin 0 -> 357 bytes .../static/brightmaps/heretic/SOR2T1.png | Bin 0 -> 425 bytes .../static/brightmaps/heretic/SOR2T2.png | Bin 0 -> 367 bytes .../static/brightmaps/heretic/SOR2T3.png | Bin 0 -> 279 bytes .../static/brightmaps/heretic/SOR2T4.png | Bin 0 -> 299 bytes .../static/brightmaps/heretic/SOR2T5.png | Bin 0 -> 393 bytes .../static/brightmaps/heretic/SOR2T6.png | Bin 0 -> 269 bytes .../static/brightmaps/heretic/SOR2T7.png | Bin 0 -> 282 bytes .../static/brightmaps/heretic/SOR2T8.png | Bin 0 -> 378 bytes .../static/brightmaps/heretic/VLCOE0.png | Bin 0 -> 174 bytes .../static/brightmaps/heretic/WZRDC1.png | Bin 0 -> 246 bytes .../static/brightmaps/heretic/WZRDC2C8.png | Bin 0 -> 242 bytes .../static/brightmaps/heretic/WZRDC3C7.png | Bin 0 -> 169 bytes .../static/brightmaps/heretic/WZRDC4C6.png | Bin 0 -> 245 bytes .../static/brightmaps/heretic/WZRDC5.png | Bin 0 -> 246 bytes .../static/brightmaps/heretic/WZRDD1.png | Bin 0 -> 186 bytes .../static/brightmaps/heretic/WZRDD2D8.png | Bin 0 -> 173 bytes .../static/brightmaps/heretic/WZRDD3D7.png | Bin 0 -> 167 bytes .../static/brightmaps/heretic/WZRDD4D6.png | Bin 0 -> 162 bytes .../static/brightmaps/heretic/WZRDD5.png | Bin 0 -> 148 bytes .../static/brightmaps/heretic/WZRDF0.png | Bin 0 -> 218 bytes .../static/brightmaps/heretic/WZRDG0.png | Bin 0 -> 386 bytes .../static/brightmaps/heretic/WZRDH0.png | Bin 0 -> 443 bytes .../static/brightmaps/heretic/WZRDI0.png | Bin 0 -> 501 bytes .../static/brightmaps/heretic/WZRDJ0.png | Bin 0 -> 420 bytes .../static/brightmaps/heretic/WZRDK0.png | Bin 0 -> 288 bytes wadsrc_bm/static/brightmaps/hexen/CDLRA0.png | Bin 0 -> 148 bytes wadsrc_bm/static/brightmaps/hexen/CDLRB0.png | Bin 0 -> 151 bytes wadsrc_bm/static/brightmaps/hexen/CDLRC0.png | Bin 0 -> 152 bytes wadsrc_bm/static/brightmaps/hexen/CENTF1.png | Bin 0 -> 118 bytes wadsrc_bm/static/brightmaps/hexen/CENTF2.png | Bin 0 -> 109 bytes wadsrc_bm/static/brightmaps/hexen/CENTF8.png | Bin 0 -> 108 bytes wadsrc_bm/static/brightmaps/hexen/ICEYG1.png | Bin 0 -> 341 bytes .../static/brightmaps/hexen/ICEYG2G8.png | Bin 0 -> 281 bytes .../static/brightmaps/hexen/ICEYG3G7.png | Bin 0 -> 233 bytes .../static/brightmaps/hexen/ICEYG4G6.png | Bin 0 -> 201 bytes wadsrc_bm/static/brightmaps/hexen/ICEYG5.png | Bin 0 -> 151 bytes wadsrc_bm/static/brightmaps/hexen/MAGEF1.png | Bin 0 -> 179 bytes wadsrc_bm/static/brightmaps/hexen/MAGEF2.png | Bin 0 -> 153 bytes wadsrc_bm/static/brightmaps/hexen/MAGEF3.png | Bin 0 -> 177 bytes wadsrc_bm/static/brightmaps/hexen/MAGEF4.png | Bin 0 -> 152 bytes wadsrc_bm/static/brightmaps/hexen/MAGEF5.png | Bin 0 -> 126 bytes wadsrc_bm/static/brightmaps/hexen/MAGEF6.png | Bin 0 -> 141 bytes wadsrc_bm/static/brightmaps/hexen/MAGEF7.png | Bin 0 -> 183 bytes wadsrc_bm/static/brightmaps/hexen/MAGEF8.png | Bin 0 -> 196 bytes wadsrc_bm/static/brightmaps/hexen/WRTHE1.png | Bin 0 -> 419 bytes .../static/brightmaps/hexen/WRTHE2E8.png | Bin 0 -> 347 bytes .../static/brightmaps/hexen/WRTHE3E7.png | Bin 0 -> 246 bytes .../static/brightmaps/hexen/WRTHE4E6.png | Bin 0 -> 267 bytes wadsrc_bm/static/brightmaps/hexen/WRTHE5.png | Bin 0 -> 281 bytes wadsrc_bm/static/brightmaps/hexen/WRTHF1.png | Bin 0 -> 637 bytes .../static/brightmaps/hexen/WRTHF2F8.png | Bin 0 -> 424 bytes .../static/brightmaps/hexen/WRTHF3F7.png | Bin 0 -> 395 bytes .../static/brightmaps/hexen/WRTHF4F6.png | Bin 0 -> 421 bytes wadsrc_bm/static/brightmaps/hexen/WRTHF5.png | Bin 0 -> 455 bytes wadsrc_bm/static/brightmaps/hexen/WRTHG1.png | Bin 0 -> 385 bytes .../static/brightmaps/hexen/WRTHG2G8.png | Bin 0 -> 321 bytes .../static/brightmaps/hexen/WRTHG3G7.png | Bin 0 -> 343 bytes .../static/brightmaps/hexen/WRTHG4G6.png | Bin 0 -> 322 bytes wadsrc_bm/static/brightmaps/hexen/WRTHG5.png | Bin 0 -> 316 bytes wadsrc_bm/static/brightmaps/strife/MLDRE1.png | Bin 0 -> 218 bytes wadsrc_bm/static/brightmaps/strife/MLDRE2.png | Bin 0 -> 189 bytes wadsrc_bm/static/brightmaps/strife/MLDRE3.png | Bin 0 -> 196 bytes wadsrc_bm/static/brightmaps/strife/MLDRE4.png | Bin 0 -> 201 bytes wadsrc_bm/static/brightmaps/strife/MLDRE5.png | Bin 0 -> 189 bytes wadsrc_bm/static/brightmaps/strife/MLDRE6.png | Bin 0 -> 194 bytes wadsrc_bm/static/brightmaps/strife/MLDRE7.png | Bin 0 -> 211 bytes wadsrc_bm/static/brightmaps/strife/MLDRE8.png | Bin 0 -> 227 bytes wadsrc_bm/static/brightmaps/strife/PGRDG1.png | Bin 0 -> 123 bytes wadsrc_bm/static/brightmaps/strife/PGRDG2.png | Bin 0 -> 134 bytes wadsrc_bm/static/brightmaps/strife/PGRDG3.png | Bin 0 -> 138 bytes wadsrc_bm/static/brightmaps/strife/PGRDG4.png | Bin 0 -> 148 bytes wadsrc_bm/static/brightmaps/strife/PGRDG5.png | Bin 0 -> 126 bytes wadsrc_bm/static/brightmaps/strife/PGRDG6.png | Bin 0 -> 150 bytes wadsrc_bm/static/brightmaps/strife/PGRDG7.png | Bin 0 -> 129 bytes wadsrc_bm/static/brightmaps/strife/PGRDG8.png | Bin 0 -> 132 bytes wadsrc_bm/static/brightmaps/strife/PGRDI0.png | Bin 0 -> 108 bytes wadsrc_bm/static/brightmaps/strife/PGRDJ0.png | Bin 0 -> 180 bytes wadsrc_bm/static/brightmaps/strife/PGRDK0.png | Bin 0 -> 175 bytes wadsrc_bm/static/brightmaps/strife/PGRDL0.png | Bin 0 -> 169 bytes wadsrc_bm/static/brightmaps/strife/PGRDM0.png | Bin 0 -> 157 bytes wadsrc_bm/static/brightmaps/strife/PGRDN0.png | Bin 0 -> 112 bytes wadsrc_bm/static/brightmaps/strife/PRGRO0.png | Bin 0 -> 368 bytes wadsrc_bm/static/brightmaps/strife/RBB3A0.png | Bin 0 -> 343 bytes wadsrc_bm/static/brightmaps/strife/RBB3B0.png | Bin 0 -> 336 bytes wadsrc_bm/static/brightmaps/strife/ROB1J0.png | Bin 0 -> 135 bytes wadsrc_bm/static/brightmaps/strife/ROB1K0.png | Bin 0 -> 184 bytes wadsrc_bm/static/brightmaps/strife/ROB1L0.png | Bin 0 -> 252 bytes wadsrc_bm/static/brightmaps/strife/ROB1M0.png | Bin 0 -> 211 bytes wadsrc_bm/static/brightmaps/strife/ROB1N0.png | Bin 0 -> 183 bytes wadsrc_bm/static/brightmaps/strife/ROB1O0.png | Bin 0 -> 152 bytes wadsrc_bm/static/brightmaps/strife/ROB1P0.png | Bin 0 -> 340 bytes wadsrc_bm/static/brightmaps/strife/ROB2F1.png | Bin 0 -> 181 bytes wadsrc_bm/static/brightmaps/strife/ROB2F2.png | Bin 0 -> 189 bytes wadsrc_bm/static/brightmaps/strife/ROB2F3.png | Bin 0 -> 160 bytes wadsrc_bm/static/brightmaps/strife/ROB2F4.png | Bin 0 -> 164 bytes wadsrc_bm/static/brightmaps/strife/ROB2F5.png | Bin 0 -> 163 bytes wadsrc_bm/static/brightmaps/strife/ROB2F6.png | Bin 0 -> 107 bytes wadsrc_bm/static/brightmaps/strife/ROB2F7.png | Bin 0 -> 137 bytes wadsrc_bm/static/brightmaps/strife/ROB2F8.png | Bin 0 -> 174 bytes wadsrc_bm/static/brightmaps/strife/ROB2G0.png | Bin 0 -> 187 bytes wadsrc_bm/static/brightmaps/strife/ROB2H0.png | Bin 0 -> 213 bytes wadsrc_bm/static/brightmaps/strife/ROB2I0.png | Bin 0 -> 336 bytes wadsrc_bm/static/brightmaps/strife/ROB2J0.png | Bin 0 -> 308 bytes wadsrc_bm/static/brightmaps/strife/ROB2K0.png | Bin 0 -> 491 bytes wadsrc_bm/static/brightmaps/strife/ROB2L0.png | Bin 0 -> 736 bytes wadsrc_bm/static/brightmaps/strife/ROB2M0.png | Bin 0 -> 256 bytes wadsrc_bm/static/brightmaps/strife/ROB2N0.png | Bin 0 -> 303 bytes wadsrc_bm/static/brightmaps/strife/ROB2O0.png | Bin 0 -> 157 bytes wadsrc_bm/static/brightmaps/strife/ROB3F1.png | Bin 0 -> 213 bytes wadsrc_bm/static/brightmaps/strife/ROB3F2.png | Bin 0 -> 200 bytes wadsrc_bm/static/brightmaps/strife/ROB3F3.png | Bin 0 -> 187 bytes wadsrc_bm/static/brightmaps/strife/ROB3F4.png | Bin 0 -> 199 bytes wadsrc_bm/static/brightmaps/strife/ROB3F5.png | Bin 0 -> 144 bytes wadsrc_bm/static/brightmaps/strife/ROB3F6.png | Bin 0 -> 191 bytes wadsrc_bm/static/brightmaps/strife/ROB3F7.png | Bin 0 -> 185 bytes wadsrc_bm/static/brightmaps/strife/ROB3F8.png | Bin 0 -> 230 bytes wadsrc_bm/static/brightmaps/strife/ROB3H1.png | Bin 0 -> 248 bytes wadsrc_bm/static/brightmaps/strife/ROB3H2.png | Bin 0 -> 280 bytes wadsrc_bm/static/brightmaps/strife/ROB3H3.png | Bin 0 -> 285 bytes wadsrc_bm/static/brightmaps/strife/ROB3H4.png | Bin 0 -> 333 bytes wadsrc_bm/static/brightmaps/strife/ROB3H5.png | Bin 0 -> 389 bytes wadsrc_bm/static/brightmaps/strife/ROB3H6.png | Bin 0 -> 320 bytes wadsrc_bm/static/brightmaps/strife/ROB3H7.png | Bin 0 -> 270 bytes wadsrc_bm/static/brightmaps/strife/ROB3H8.png | Bin 0 -> 302 bytes wadsrc_bm/static/brightmaps/strife/ROB3I1.png | Bin 0 -> 241 bytes wadsrc_bm/static/brightmaps/strife/ROB3I2.png | Bin 0 -> 243 bytes wadsrc_bm/static/brightmaps/strife/ROB3I3.png | Bin 0 -> 240 bytes wadsrc_bm/static/brightmaps/strife/ROB3I4.png | Bin 0 -> 306 bytes wadsrc_bm/static/brightmaps/strife/ROB3I5.png | Bin 0 -> 387 bytes wadsrc_bm/static/brightmaps/strife/ROB3I6.png | Bin 0 -> 296 bytes wadsrc_bm/static/brightmaps/strife/ROB3I7.png | Bin 0 -> 239 bytes wadsrc_bm/static/brightmaps/strife/ROB3I8.png | Bin 0 -> 247 bytes wadsrc_bm/static/brightmaps/strife/ROB3J1.png | Bin 0 -> 241 bytes wadsrc_bm/static/brightmaps/strife/ROB3J2.png | Bin 0 -> 244 bytes wadsrc_bm/static/brightmaps/strife/ROB3J3.png | Bin 0 -> 173 bytes wadsrc_bm/static/brightmaps/strife/ROB3J4.png | Bin 0 -> 192 bytes wadsrc_bm/static/brightmaps/strife/ROB3J6.png | Bin 0 -> 177 bytes wadsrc_bm/static/brightmaps/strife/ROB3J7.png | Bin 0 -> 170 bytes wadsrc_bm/static/brightmaps/strife/ROB3J8.png | Bin 0 -> 241 bytes wadsrc_bm/static/brightmaps/strife/ROB3M0.png | Bin 0 -> 240 bytes wadsrc_bm/static/brightmaps/strife/ROB3N0.png | Bin 0 -> 498 bytes wadsrc_bm/static/brightmaps/strife/ROB3O0.png | Bin 0 -> 631 bytes wadsrc_bm/static/brightmaps/strife/ROB3P0.png | Bin 0 -> 372 bytes wadsrc_bm/static/brightmaps/strife/ROB3Q0.png | Bin 0 -> 198 bytes wadsrc_bm/static/brightmaps/strife/ROB3T0.png | Bin 0 -> 164 bytes wadsrc_bm/static/brightmaps/strife/ROB3U0.png | Bin 0 -> 183 bytes wadsrc_bm/static/brightmaps/strife/ROB3V0.png | Bin 0 -> 218 bytes wadsrc_bm/static/brightmaps/strife/ROB3W0.png | Bin 0 -> 140 bytes wadsrc_bm/static/brightmaps/strife/ROB3X0.png | Bin 0 -> 122 bytes wadsrc_bm/static/brightmaps/strife/ROB3Y0.png | Bin 0 -> 153 bytes wadsrc_bm/static/brightmaps/strife/ROB3Z0.png | Bin 0 -> 196 bytes wadsrc_bm/static/brightmaps/strife/ROB3[0.png | Bin 0 -> 385 bytes wadsrc_bm/static/brightmaps/strife/ROB3]0.png | Bin 0 -> 342 bytes wadsrc_bm/static/brightmaps/strife/ROB3^0.png | Bin 0 -> 1358 bytes wadsrc_bm/static/brightmaps/strife/SEWRH0.png | Bin 0 -> 200 bytes wadsrc_bm/static/brightmaps/strife/STLKP0.png | Bin 0 -> 96 bytes wadsrc_bm/static/brightmaps/strife/STLKQ0.png | Bin 0 -> 117 bytes wadsrc_bm/static/brightmaps/strife/STLKR0.png | Bin 0 -> 113 bytes wadsrc_bm/static/brightmaps/strife/STLKS0.png | Bin 0 -> 117 bytes wadsrc_bm/static/brightmaps/strife/STLKT0.png | Bin 0 -> 149 bytes wadsrc_bm/static/brightmaps/strife/STLKU0.png | Bin 0 -> 160 bytes wadsrc_bm/static/brightmaps/strife/STLKV0.png | Bin 0 -> 174 bytes wadsrc_bm/static/brightmaps/strife/STLKW0.png | Bin 0 -> 163 bytes wadsrc_bm/static/brightmaps/strife/STLKX0.png | Bin 0 -> 122 bytes wadsrc_bm/static/brightmaps/strife/STLKY0.png | Bin 0 -> 170 bytes wadsrc_bm/static/brightmaps/strife/STLKZ0.png | Bin 0 -> 243 bytes wadsrc_bm/static/brightmaps/strife/STLK[0.png | Bin 0 -> 215 bytes wadsrc_bm/static/doomdefs.bm | 2181 +++++++++++++ wadsrc_bm/static/hexndefs.bm | 268 ++ wadsrc_bm/static/hticdefs.bm | 692 ++++ wadsrc_bm/static/strfdefs.bm | 1253 +++++++ wadsrc_lights/CMakeLists.txt | 9 + wadsrc_lights/lights.vcproj | 120 + wadsrc_lights/static/doomdefs.txt | 1258 ++++++++ wadsrc_lights/static/hexndefs.txt | 1593 +++++++++ wadsrc_lights/static/hticdefs.txt | 1854 +++++++++++ wadsrc_lights/static/strfdefs.txt | 2874 +++++++++++++++++ 508 files changed, 12235 insertions(+), 2 deletions(-) create mode 100644 wadsrc_bm/CMakeLists.txt create mode 100644 wadsrc_bm/brightmaps.vcproj create mode 100644 wadsrc_bm/static/brightmaps/doom/BON2B0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BON2C0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BON2D0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOS2A6C4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOS2A7C3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOS2A8C2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOS2B6D4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOS2B7D3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOS2B8D2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSA1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSA2A8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSA3A7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSA4A6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSA5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSB1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSB2B8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSB3B7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSB4B6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSB5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSC1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSC2C8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSC3C7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSC4C6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSC5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSD1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSD2D8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSD3D7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSD4D6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSD5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSE1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSE2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSE3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSE4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSE5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSE6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSE7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSE8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSF1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSF2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSF3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSF4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSF5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSF6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSF7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSF8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSG1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSG2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSG3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSG4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSG5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSG6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSG7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSG8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSH1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSH2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSH3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSH4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSH5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSH6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSH7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSH8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSI0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSJ0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSK0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSL0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BOSSM0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BSPIG1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BSPIG2G8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BSPIH1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BSPIH2H8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BSPIH3H7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BSPIH4H6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/BSPIH5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CELLA0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CELPA0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSE1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSE2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSE3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSE5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSE6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSE7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSE8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSF1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSF2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSF3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSF4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSF5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSF6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSF7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CPOSF8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CYBRF1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CYBRF2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CYBRF3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CYBRF4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CYBRF5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CYBRF6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CYBRF7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CYBRF8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CYBRJ0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CYBRK0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CYBRL0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CYBRM0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CYBRN0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/CYBRO0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/FATTG1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/FATTG2G8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/FATTH1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/FATTH2H8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/FATTH3H7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/FATTH4H6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/FATTH5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/FCANA0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/FCANB0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/FCANC0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/HEADC1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/HEADC2C8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/HEADC3C7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/HEADD1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/HEADD2D8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/HEADD3D7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/PAINF1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/PAINF2F8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/PAINF3F7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/PLAYF1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/PLAYF2F8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/PLAYF3F7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/PLAYF4F6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/PLAYF5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/POSSE1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/POSSE2E8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/POSSE3E7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/POSSF1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/POSSF2F8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/POSSF3F7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/POSSF4F6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/POSSF5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SKELJ1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SKELJ2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SKELJ3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SKELJ4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SKELJ5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SKELJ6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SKELJ7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SKELJ8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SMRTA0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SMRTB0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SMRTC0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SMRTD0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPIDG1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPIDG2G8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPIDH1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPIDH2H8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPIDH3H7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPIDL0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPIDM0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPIDN0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPIDO0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPIDP0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPIDQ0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPIDR0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPOSE1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPOSE2E8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPOSE3E7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPOSF1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPOSF2F8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPOSF3F7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPOSF4F6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/SPOSF5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/TREDA0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/TREDB0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/TREDC0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/TREDD0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/TbluB0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/TbluC0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/sswvg0.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileg1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileg2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileg3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileg4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileg5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileg6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileg7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileg8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileh1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileh2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileh3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileh4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileh5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileh6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileh7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileh8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilei1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilei2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilei3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilei4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilei5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilei6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilei7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilei8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilej1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilej2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilej3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilej4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilej5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilej6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilej7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilej8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilek1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilek2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilek3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilek4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilek5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilek6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilek7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilek8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilel1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilel2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilel3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilel4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilel5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilel6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilel7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilel8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilem1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilem2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilem3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilem4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilem5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilem6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilem7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilem8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilen1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilen2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilen3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilen4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilen5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilen6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilen7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilen8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileo1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileo2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileo3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileo4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileo5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileo6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileo7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vileo8.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilep1.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilep2.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilep3.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilep4.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilep5.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilep6.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilep7.png create mode 100644 wadsrc_bm/static/brightmaps/doom/vilep8.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/BEASI1.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/BEASI2I8.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/BEASI3I7.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/CHDLA0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/CHDLB0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/CHDLC0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/CLNKI0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/CLNKJ0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/CLNKK0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/CLNKL0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/CLNKM0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/CLNKN0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXD1.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXD2.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXD3.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXD4.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXD5.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXD6.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXD7.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXD8.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXE1.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXE2.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXE3.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXE4.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXE5.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXE6.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXE7.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXE8.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXF1.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXF2.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXF3.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXF4.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXF5.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXF6.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXF7.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/IMPXF8.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/LICHB1.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/LICHB2B8.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/LICHB3B7.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/LICHC0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/LICHD0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/LICHE0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/LICHF0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/LICHG0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/LICHH0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/PLAYF1.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/PLAYF2F8.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/PLAYF3F7.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/PLAYF4F6.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SDTHA0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SDTHB0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SDTHC0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SDTHD0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SDTHE0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SDTHF0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SDTHG0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SDTHH0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2R1.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2R2.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2R3.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2R4.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2R5.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2R6.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2R7.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2R8.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2S1.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2S2.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2S3.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2S4.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2S5.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2S6.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2S7.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2S8.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2T1.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2T2.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2T3.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2T4.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2T5.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2T6.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2T7.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/SOR2T8.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/VLCOE0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDC1.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDC2C8.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDC3C7.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDC4C6.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDC5.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDD1.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDD2D8.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDD3D7.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDD4D6.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDD5.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDF0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDG0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDH0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDI0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDJ0.png create mode 100644 wadsrc_bm/static/brightmaps/heretic/WZRDK0.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/CDLRA0.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/CDLRB0.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/CDLRC0.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/CENTF1.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/CENTF2.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/CENTF8.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/ICEYG1.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/ICEYG2G8.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/ICEYG3G7.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/ICEYG4G6.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/ICEYG5.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/MAGEF1.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/MAGEF2.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/MAGEF3.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/MAGEF4.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/MAGEF5.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/MAGEF6.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/MAGEF7.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/MAGEF8.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHE1.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHE2E8.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHE3E7.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHE4E6.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHE5.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHF1.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHF2F8.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHF3F7.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHF4F6.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHF5.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHG1.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHG2G8.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHG3G7.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHG4G6.png create mode 100644 wadsrc_bm/static/brightmaps/hexen/WRTHG5.png create mode 100644 wadsrc_bm/static/brightmaps/strife/MLDRE1.png create mode 100644 wadsrc_bm/static/brightmaps/strife/MLDRE2.png create mode 100644 wadsrc_bm/static/brightmaps/strife/MLDRE3.png create mode 100644 wadsrc_bm/static/brightmaps/strife/MLDRE4.png create mode 100644 wadsrc_bm/static/brightmaps/strife/MLDRE5.png create mode 100644 wadsrc_bm/static/brightmaps/strife/MLDRE6.png create mode 100644 wadsrc_bm/static/brightmaps/strife/MLDRE7.png create mode 100644 wadsrc_bm/static/brightmaps/strife/MLDRE8.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PGRDG1.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PGRDG2.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PGRDG3.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PGRDG4.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PGRDG5.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PGRDG6.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PGRDG7.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PGRDG8.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PGRDI0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PGRDJ0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PGRDK0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PGRDL0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PGRDM0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PGRDN0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/PRGRO0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/RBB3A0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/RBB3B0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB1J0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB1K0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB1L0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB1M0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB1N0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB1O0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB1P0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2F1.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2F2.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2F3.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2F4.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2F5.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2F6.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2F7.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2F8.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2G0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2H0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2I0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2J0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2K0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2L0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2M0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2N0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB2O0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3F1.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3F2.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3F3.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3F4.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3F5.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3F6.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3F7.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3F8.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3H1.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3H2.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3H3.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3H4.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3H5.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3H6.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3H7.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3H8.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3I1.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3I2.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3I3.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3I4.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3I5.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3I6.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3I7.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3I8.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3J1.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3J2.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3J3.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3J4.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3J6.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3J7.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3J8.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3M0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3N0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3O0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3P0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3Q0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3T0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3U0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3V0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3W0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3X0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3Y0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3Z0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3[0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3]0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/ROB3^0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/SEWRH0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/STLKP0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/STLKQ0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/STLKR0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/STLKS0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/STLKT0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/STLKU0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/STLKV0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/STLKW0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/STLKX0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/STLKY0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/STLKZ0.png create mode 100644 wadsrc_bm/static/brightmaps/strife/STLK[0.png create mode 100644 wadsrc_bm/static/doomdefs.bm create mode 100644 wadsrc_bm/static/hexndefs.bm create mode 100644 wadsrc_bm/static/hticdefs.bm create mode 100644 wadsrc_bm/static/strfdefs.bm create mode 100644 wadsrc_lights/CMakeLists.txt create mode 100644 wadsrc_lights/lights.vcproj create mode 100644 wadsrc_lights/static/doomdefs.txt create mode 100644 wadsrc_lights/static/hexndefs.txt create mode 100644 wadsrc_lights/static/hticdefs.txt create mode 100644 wadsrc_lights/static/strfdefs.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e5d9cc40..d19d569fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required( VERSION 2.4 ) -project(ZDoom) +project(GZDoom) IF( NOT CMAKE_BUILD_TYPE ) SET( CMAKE_BUILD_TYPE Debug CACHE STRING @@ -8,7 +8,7 @@ IF( NOT CMAKE_BUILD_TYPE ) ENDIF( NOT CMAKE_BUILD_TYPE ) set( ZDOOM_OUTPUT_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Directory where zdoom.pk3 and the executable will be created." ) -set( ZDOOM_EXE_NAME "zdoom" CACHE FILEPATH "Name of the executable to create." ) +set( ZDOOM_EXE_NAME "gzdoom" CACHE FILEPATH "Name of the executable to create" ) if( CMAKE_COMPILER_IS_GNUCXX ) set( PROFILE 0 CACHE BOOL "Enable profiling with gprof for Debug and RelWithDebInfo build types." ) @@ -109,6 +109,8 @@ add_subdirectory( game-music-emu ) add_subdirectory( dumb ) add_subdirectory( gdtoa ) add_subdirectory( wadsrc ) +add_subdirectory( wadsrc_bm ) +add_subdirectory( wadsrc_lights ) add_subdirectory( src ) if( NOT WIN32 AND NOT APPLE ) diff --git a/wadsrc_bm/CMakeLists.txt b/wadsrc_bm/CMakeLists.txt new file mode 100644 index 000000000..b79de7138 --- /dev/null +++ b/wadsrc_bm/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required( VERSION 2.4 ) + +add_custom_command( OUTPUT ${ZDOOM_OUTPUT_DIR}/brightmaps.pk3 + COMMAND ${CMAKE_BINARY_DIR}/tools/zipdir/zipdir ${ZDOOM_OUTPUT_DIR}/brightmaps.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static ${CMAKE_CURRENT_BINARY_DIR}/generated + DEPENDS zipdir ${CMAKE_CURRENT_SOURCE_DIR}/static ) + +add_custom_target( brightmaps_pk3 ALL + DEPENDS ${ZDOOM_OUTPUT_DIR}/brightmaps.pk3 ) + diff --git a/wadsrc_bm/brightmaps.vcproj b/wadsrc_bm/brightmaps.vcproj new file mode 100644 index 000000000..12581c338 --- /dev/null +++ b/wadsrc_bm/brightmaps.vcproj @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wadsrc_bm/static/brightmaps/doom/BON2B0.png b/wadsrc_bm/static/brightmaps/doom/BON2B0.png new file mode 100644 index 0000000000000000000000000000000000000000..ef16358e57574ef86907977daf6f182e489f420c GIT binary patch literal 99 zcmeAS@N?(olHy`uVBq!ia0y~yU=UznVBlwDW?*2rzV~hp0|NtFfKQ04jEoEe14G`L zm)#5u3=*C$jv*Ddl7IZ4&nUjDX4b>cm2LOGKU89v`a@QEU(b<63=9kmp00i_>zopr E0ImWag8%>k literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BON2C0.png b/wadsrc_bm/static/brightmaps/doom/BON2C0.png new file mode 100644 index 0000000000000000000000000000000000000000..f55f93bf42af47a4859ca49e005008e2aaa0a738 GIT binary patch literal 97 zcmeAS@N?(olHy`uVBq!ia0y~yU=UznVBlwDW?*2rzV~hp0|NtFfKQ04y1F_81H;Et zFD@}KFo=1&IEGZ*O8)VGKBKr*jYNyx{Pu1Jh6yGz+t2Q1yT`!5z~JfX=d#Wzp$Py& CbsE$F literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BON2D0.png b/wadsrc_bm/static/brightmaps/doom/BON2D0.png new file mode 100644 index 0000000000000000000000000000000000000000..a08679f6ee03d6962cd61f1b60ec2dcc73f78a9a GIT binary patch literal 98 zcmeAS@N?(olHy`uVBq!ia0y~yU=UznVBlwDW?*2rzV~hp0|NtFfKQ04v9U1&1B3Fk z$g2zt4C0U~pz+W?*2jKDe)wfq{W7z$e62Utgbrf#F3g z=R^hu1{F^i$B>F!$v^m+czF(YRq-#hb6W9O;FX;j*Rn(_m&5-a3bHWNPR>2LMQOb{ Q0|Nttr>mdKI;Vst0CTk-YXATM literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOS2A7C3.png b/wadsrc_bm/static/brightmaps/doom/BOS2A7C3.png new file mode 100644 index 0000000000000000000000000000000000000000..2e0c7c592898c0c99c511f125e72cc0848c8cee9 GIT binary patch literal 135 zcmeAS@N?(olHy`uVBq!ia0y~yU@&4}U~pw*2C=TGcQY_Bum$*pxa#ZcGcYi`h~=Ef zz`$VR>EaktaVz-;KO4J5o9W*Tj85|#KRvg0cq(o1^0&aR`*i}mA?%Ch@;kiv9`MUv n$X4D&K1H+40 z&WQ{R46dFojv*Ddl7H~C$xF1E?`3rQ-}sSt!53DIS_UtBhYQ~)K5hK~AUf$H1^x?q}43y`t<43=9mOu6{1-oD!M<)a5fB literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOS2B6D4.png b/wadsrc_bm/static/brightmaps/doom/BOS2B6D4.png new file mode 100644 index 0000000000000000000000000000000000000000..8c3d09be219ff64a18898f85946b352387b2a0b3 GIT binary patch literal 107 zcmeAS@N?(olHy`uVBq!ia0y~yU{GUVU~pk%W?*2re*Wqn1_lPU0G|+7eSLif28I{0 zoD&%s7!*8R978H@CI8@Osh4o$`pN84_rKZiAKT>m6oEI5Wx5Opd;(ss*r1%sz`(%Z M>FVdQ&MBb@08c9(QUCw| literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOS2B7D3.png b/wadsrc_bm/static/brightmaps/doom/BOS2B7D3.png new file mode 100644 index 0000000000000000000000000000000000000000..6d78193f526e5a7f2a1717767d53b9ba89748a98 GIT binary patch literal 120 zcmeAS@N?(olHy`uVBq!ia0y~yV9;S;VDMmMW?*30uHVYXz`(#3;1lAiudmO*!0;lL zb0Px+gRZBGV@SoV6UgN8{Pwj8!iL2WJ-U__>d*P!s a!?nH@TobJyBrz~BFnGH9xvX()V@SoVrx$jMGAM8`A9%CBWwC{b>imuruK6M{TniZH9J(G+&b-;vU=~w$ p!ND8lMnT+qV%9Ic?EW?}UwgN+YOksGG6n_)22WQ%mvv4FO#uGHDE|Ne literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSA1.png b/wadsrc_bm/static/brightmaps/doom/BOSSA1.png new file mode 100644 index 0000000000000000000000000000000000000000..a0f08cbb500de438f392848ca2862a5da16579d4 GIT binary patch literal 116 zcmeAS@N?(olHy`uVBq!ia0y~yV9;b>VDMyQW?*2L6*c!g0|NtFfKQ04zP>&K1H+40 z&WRu;o-U3d6}OUq@H6r9IM2Psv+z}*M#mld91)-U@sDzTa4r0ImB0IdQvk#MfXkfE-AF6*2UngChsAyohX literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSA2A8.png b/wadsrc_bm/static/brightmaps/doom/BOSSA2A8.png new file mode 100644 index 0000000000000000000000000000000000000000..2d07518de288ce68ddced6dc4336ebfdd2831b99 GIT binary patch literal 119 zcmeAS@N?(olHy`uVBq!ia0y~yV9;V=JDnUj?0>IF!$v^nnU~pz+W?*2jKDe)wfq{W7z$e62Utgbrf#F3g z=R^hu20c#~$B>F!$v^m+czF)b{1trvz=!Am|G(!rc;De(zQOz7YUI14Ypr%h?61yFVdQ&MBb@03z}= A`Tzg` literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSB2B8.png b/wadsrc_bm/static/brightmaps/doom/BOSSB2B8.png new file mode 100644 index 0000000000000000000000000000000000000000..bb31928df2006c991a9e86caac8b5e9c63b05a09 GIT binary patch literal 136 zcmeAS@N?(olHy`uVBq!ia0y~yV9;b>VDMmMW?*0lWb^Z4U|?Vi@Ck9%*VkuYV0aPB zIgx>Z!Pe8oF{I*F@(+F{ULNJXN$kP@&o!^K7dUwT#Fbi(uX0Yc?Lq(NGp&4o|Ns2< r0EL6s-yghk|98Tx`F|&HFfnvmwVz)pweLRz0|SGntDnm{r-UW|v6L?z literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSB3B7.png b/wadsrc_bm/static/brightmaps/doom/BOSSB3B7.png new file mode 100644 index 0000000000000000000000000000000000000000..dd8da7d8af3b4a23a4fbc4f04020bcdd34fe9fcf GIT binary patch literal 118 zcmeAS@N?(olHy`uVBq!ia0y~yV9;S;U~pq(W?*3GRee&&z`(#3;1lAiudmO*!0;lL zb0Px+gSMxOV@SoVF!$v^m+VDMyQW?*2L6*c!g0|NtFfKQ04zP>&K1H+40 z&WQ{R3>uy;jv*Ddl7H|s@$xv&u3~$7b#Xwz!M`^&I_}g4>FnZL_@=!oK{1%&_@iE@ Stg19K29TMqelF{r5}E*0N+Ku# literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSC2C8.png b/wadsrc_bm/static/brightmaps/doom/BOSSC2C8.png new file mode 100644 index 0000000000000000000000000000000000000000..c9fee8d0df7da25bff4e62a38999705172cbaa46 GIT binary patch literal 143 zcmeAS@N?(olHy`uVBq!ia0y~yU@&1|VDMsOW?*1AH}9z=0|NtFfKQ04zP>&K1H+40 z&WQ{R3@)B7jv*Ddl7H~C$xF0p*UEdEaktaVz-;KO4J5oAz9erRN=9)_xV(_0K-wC;VVYx+0(Oon=jPMJG`y6_;W~*VNLdlb;mEX$}li6FnGH9xvXU~pz+W?*2jKDe)wfq{W7z$e62Utgbrf#F3g z=R^hu231cN$B>F!$v^m+czF(Y{o-BN=e(j{;FZ1^*P@5qE{FF&KCHsQU~8YZ^2_U< RPYetU44$rjF6*2UngGF$AjALw literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSC5.png b/wadsrc_bm/static/brightmaps/doom/BOSSC5.png new file mode 100644 index 0000000000000000000000000000000000000000..0f1d3861822c705c36e2db9eb09c2d93011910cb GIT binary patch literal 121 zcmeAS@N?(olHy`uVBq!ia0y~yV9;b>U~pz+W?*2jKDe)wfq{W7z$e62Utgbrf#F3g z=R^hu20c#~$B>F!$v^m+czF&_pVS_3|NsB_{NgqIPxj^~{P-t(<~Ps6I)^9sPViUy bGc!!g&)GcbzpfPn0|SGntDnm{r-UW|Y4s*? literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSD1.png b/wadsrc_bm/static/brightmaps/doom/BOSSD1.png new file mode 100644 index 0000000000000000000000000000000000000000..8ed579c9c9b837ce1dac3142ecc342be4a34be04 GIT binary patch literal 139 zcmeAS@N?(olHy`uVBq!ia0y~yU@&B0VDMsOW?*2@*sd4Lz`(#3;1lAiudmO*!0;lL zb0Px+gM+7wV@SoVI`?>Z~N9y`MipOfq}u()z4*}Q$iB}=%q6D literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSD2D8.png b/wadsrc_bm/static/brightmaps/doom/BOSSD2D8.png new file mode 100644 index 0000000000000000000000000000000000000000..afa335e0c54f244a84015a81cdd376f07a3ac7d2 GIT binary patch literal 133 zcmeAS@N?(olHy`uVBq!ia0y~yU@%}{VDMsOW?*1AUh106z`(#3;1lAiudmO*!0;lL zb0Px+gO#U?V@SoV1_BASDU|?YIboFyt=akR{06@Ge`v3p{ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSD3D7.png b/wadsrc_bm/static/brightmaps/doom/BOSSD3D7.png new file mode 100644 index 0000000000000000000000000000000000000000..7fafce06eb27472f606a6da413d2df87ee257f70 GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0y~yV9;S;VDMmMW?*30uHVYXz`(#3;1lAiudmO*!0;lL zb0Px+gOR6;V@SoV literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSD4D6.png b/wadsrc_bm/static/brightmaps/doom/BOSSD4D6.png new file mode 100644 index 0000000000000000000000000000000000000000..296b5a80a7b547ea2579f516df29a49f01d71c20 GIT binary patch literal 106 zcmeAS@N?(olHy`uVBq!ia0y~yU{GUVU~pk%W?*2re*Wqn1_lPU0G|+7eSLif28I{0 zoD&%s800-&978H@CI8@Osh4nLisVmxe_Y|UF! zZ!hiTI~X9s{=u&CzbD4kQSird&5WNDy8qhn zC-QlJOx(_SI8V^i^VQ{8ucIfDIt`v`@}I8{KiCoyvyWTty`ot|p95pIW9M#mHa!>5 z8D@GmlRX+|R;#j9P7C?t;4;XJX_~XV z?Csu}Y&=hsg4$O!-EUvZd&}TJOWq6H7>-(xy>Ctao?Pj1w7y%sOUrJ@vr<=E1_lNO MPgg&ebxsLQ076@g#{d8T literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSE2.png b/wadsrc_bm/static/brightmaps/doom/BOSSE2.png new file mode 100644 index 0000000000000000000000000000000000000000..31837cc6cf46f1adeee16ae88230a38eef5deff7 GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0y~yU{GRUVDMmJW?*1QWV1TUz`!68;1l9HWy%yoL&KVy z8g+H`l#~=7AD@_*7zPH0>a4Q{3=9nEo-U3d6}OT#+}U{y+&rrUXL;w{O zPyJrLP|A}~l2GgKx)9s4bdId=5!P7Wh$w|s9+_Q}tXFx=wBB_x@o9^z(}wODi)XBf zi_=@vl~uiJL8U>LN7M$xS+kwplPg17JOmkfbB#Jq?&bfFVdQ&MBb@00YHB A=>Px# literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSE3.png b/wadsrc_bm/static/brightmaps/doom/BOSSE3.png new file mode 100644 index 0000000000000000000000000000000000000000..6dde651c7e2786d9149ebcb8bb93789656e7b3f5 GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0y~yV6b3dU~pn#W?*3WAjr|hz`!6E;1l9nQ&ZE^)1$7g zzGTUgn3$N7l9H5^6dxZSLqkIb28JTdZ8sPg7}`8t978H@CC}(&H<+L!X<2OKchbYg zYB^_@+oLHyCT3zslb?q)pE=+&XB}^k&oNy~)7mKYy!vGixm#XN{o%A?(w+y>Q)Mbn zW2+* literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSE4.png b/wadsrc_bm/static/brightmaps/doom/BOSSE4.png new file mode 100644 index 0000000000000000000000000000000000000000..8ffaed4bd564fedcabbe6c861fc0b5cb6790a388 GIT binary patch literal 294 zcmeAS@N?(olHy`uVBq!ia0y~yV6bLjU~pn#W?*2DR@>akz`&p$;1lA?!os4iu0CbT zl$x5FB}XX30%AQ0vi+d9U&88ck;?%e6O3D%M@$HjvoxkzS>vDg0>#NnW z8r^%J&izzx=l@jOq;9#jskC!1>xIqMd8+LmqW{$P&C+eW_xp_H7Dd5hnRl;$mE0d@ zcBX2}5A~LrMaPOBubRA`dEfSu`70k^`^)W@Ck8MS64SQG+eW0 zO-xM8k|j%ge0)kuN_u*FQc_Y_SXib^nNm|z1Jd%+ZVm$j!*)*>$B>F!$rjDBDXHhq z%rVt1e&)j_!)5k%&cEHwqo9JM-;<2((#vu;A6dG9d&U1VGefV=-61-MZP%65t6?!*hiVnRB*kzYy5>-` zn|XTEVoQZfsinq#`QI8i)^kbE;X3f($}{61B5&>$?_rmdKI;Vst052zZy#N3J literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSE6.png b/wadsrc_bm/static/brightmaps/doom/BOSSE6.png new file mode 100644 index 0000000000000000000000000000000000000000..fd6b669daf7845377dd103f72a3229fbd4405c5d GIT binary patch literal 267 zcmeAS@N?(olHy`uVBq!ia0y~yU@&B0VDMpKW?*12<8v}#U|>)Q@Ck7>G&J0^XU~)= zQ8@;?a=U-$b z98ikcTYS}Ijgjl+v`C%fT92pgtonS)NXKYuw@7*ZrKnEL&8s5=s=h0|j%A%;bj`Z_ z{g!)swHch#erFkMy~B8U-l|xKq%=)2@e1aT=ca1jh~Z_^7A`oMP{=5eGuyJ1*=(ln z#of!>6DHpjnzwCtj(M4FBICsysf%JI%g*0xIGnq={PColwpzw8_$8G=@pzbvr0Cl( Q3=9kmp00i_>zopr0Q~1>1^@s6 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSE7.png b/wadsrc_bm/static/brightmaps/doom/BOSSE7.png new file mode 100644 index 0000000000000000000000000000000000000000..4a9e0a65341102a6fb3b2c234af9c89e5c690d77 GIT binary patch literal 305 zcmeAS@N?(olHy`uVBq!ia0y~yV9;h@VDM#OW?*1Ad#_;&0|SG4fKP}k3k%DVB})tq z4b|1vdwP1-tXVT<%9NU#8Xq5@n3$N9l$4T^5(WkalFzskoJF!OYIR z>cJUi9*&2PA4Rm3ueaIA75rm|_pEB(whiZ}ZMkq^!`c^zmS1i-a#5$`q0t1(-G(j2 z4Led)cilYhcXLsVrIYuWTS2L#xbf1E3E=x)OC1djQ4 zm`$XEe;j#boL+YJz?PzG@9xgDopDIrI_>?HgU=2GPjL&KDml$e;9l9G~|ni>WMh7V_c_c1Uq9QAZ@45_&F_VQk?Lk1$O56+zv zi+9{Dwxq8q_`6a{>58{^R;83|n8dE(YwrB^e5IH3-1m2_WJUykMWewQ8JpWgY&|C{}hyz3vwTJ^aM3=9mOu6{1- HoD!MGSM%eJ<)V~*c;UaY3J`IXLHUhespf8==NgH8(ZI2yxY3@$JH2P%d&0a z`(wA~SFe8*=Y7ETnkxG?fe+W8YHr@V?fIkd$5M8w<%W#=ugA@elk++-=hp6nOC6Zz z&$513u76vo-UF})5aGw-|nUbQ0(xS=#7#J8BJYD@<);T3K0RZ#atX2R3 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSF2.png b/wadsrc_bm/static/brightmaps/doom/BOSSF2.png new file mode 100644 index 0000000000000000000000000000000000000000..1884c9cb98f55aaa2cb7163345fe26ec649849db GIT binary patch literal 398 zcmeAS@N?(olHy`uVBq!ia0y~yV6b6eU~pq$W?*1Q%6|2Xfq}swz$e6&g@r{%M#j+4 z@W_!P>gwuy_Uu`*WJyg;jgODdlqpk6N=jm4Vp394dU|@+tXadr!0>OU_(lc>MoCW> z$B>F!Z?A0hVs;c^y-?G#cgbe){|dESH~T#%-ncnK;D#Avb+_-zjD!Pj2U{|kCaMTH z8gyJ-tCX`jm?JxFlks&CMTKX3L$WsCw&gQEy02QD{oCoky!SuWoZ57x$u?Kzc-om* zyH_S2+Yb4(O-fPLU%g#m_D!bD-;ZpT_(fkiwRqctABmqLtmXyTUky9u_@TzNa8vv$ zm-I=G7WbFyTP?hyb!48{6{qEfb1q%k_jdL285Sz-?23o|Yi3N+jjW#Cnj<26{$P=M zQ(CK}$Vt9)Gp}V`+3~VAU3UAH=<|PnJxUi@eD%xC^~SQ*p0i_E*I!JPwvvA^?_n0Z z-6xgby{Z1?FMo-D`=eA_*)^Bxd&Qam&r?rXJnpG)-p}y$5QplqLn)~Y3=9mOu6{1- HoD!M literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSF3.png b/wadsrc_bm/static/brightmaps/doom/BOSSF3.png new file mode 100644 index 0000000000000000000000000000000000000000..f6b72649af2c9bba897226359b74b8a06603e501 GIT binary patch literal 217 zcmeAS@N?(olHy`uVBq!ia0y~yU@&H2U~pk!W?*2rw?ZI+fq_9iz$e6&g@q+0B}GO? zX3CT)OO`D0@$u>D=_x5Gsi~=niHR{ZG*nktXJBA3N*A5Xz`&5}>EaktaVy!PnOi17 zVyaYEkgmm2zlsM_ULDMQU?@K)$TI!JM61N++aKFsiUz2k&MxruJ-+nyjg^)byf&Se z*F|aoFeWC3fq}u->AfKX14D(Ui(^Q|t>hO6cqQ1j#~2H2cTJdj`NfNZ zZjU1i*WcYCGJU2m*PEA;k~{8P3Trz)cdfJ18Mmhys_Z_dx;vg|HFWARwa;NSP~5%k z!8Gm6qq)nZ%bX=|SzGzU6rL!ZB0k+^%i{^zo}S)E-+sU5FsCSYab{9TUI-r(Ly_sO VEG9L#5C#SY22WQ%mvv4FO#mURO*a4l literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSF5.png b/wadsrc_bm/static/brightmaps/doom/BOSSF5.png new file mode 100644 index 0000000000000000000000000000000000000000..8719121f8c9e45dcc9669e32888cc8c945c8eb50 GIT binary patch literal 270 zcmeAS@N?(olHy`uVBq!ia0y~yV6bLjU~phzW?*0ldneSyz`&pq;1lA?!oo6T$`o~V z^(9M|^z`%?8XCsL#Q6C5l$4az)YPP;q%bfrXr*kt$iTp`)YHW=q~cccjb8qo1c^nL zR{mJp%ptL^A$->q#`Rx{YA#*XzVuOQ-d2wO%iGpxbRW~T)%IPoMQZz(b9(1XY8F1b zIc=+K|Ced&LVuLx&%D_eUKM6)_i}FR?t)!4#sRx>cbn;DW-s`Xb?4;5n_1s^YE~Yt zN;j8#+1n%3v1MDf*{&~rH&1vLs{fm^t2^yxf;8jZn?IIrpI-WSYjyUQ0&Q8hrS41H cJ53mLo6?W#$3Ku@U|?YIboFyt=akR{0OU7wS^xk5 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSF6.png b/wadsrc_bm/static/brightmaps/doom/BOSSF6.png new file mode 100644 index 0000000000000000000000000000000000000000..7bc73a47e2c90c8d75af572eeff95dbcd34a0663 GIT binary patch literal 268 zcmeAS@N?(olHy`uVBq!ia0y~yV6bIiU~pn#W?*0tvp9T?fq_9Kz$e6Y&6+iahK4LG zEK{aTiHV8v@$sptsYyvmDJd!G>FHUrWC;TULv(P)90mr4#hxyXAr-fhZ}f`iBrKR% zqsjR5z+09x_k;E_&;RpHcP7i7=W$)(`_35KT1n0S`}VR|^v9X+_uNTQwfi|Y?ea3$ z$J6fbw9O84GnM;$J8W&twO;){y*sFf{E`1v@6W&4d%5#}yr0o){;&M~l{vlPb;o(6p6w6(35JzkPZ^~a X96PwO;Eo3a0|SGntDnm{r-UW|YXo+U literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSF7.png b/wadsrc_bm/static/brightmaps/doom/BOSSF7.png new file mode 100644 index 0000000000000000000000000000000000000000..71826d44008ff24d51802be68f38178ea350a459 GIT binary patch literal 337 zcmeAS@N?(olHy`uVBq!ia0y~yV9;S;U~pk!W?*38;6264z`&pz;1lA?!oqUo$dNsJ z_N-a6rlh1~%9JTFF)=kYH9b8&K0ZE%hKB0u>M1EHOO`BQU|^^#m~)+hf#JTVi(^Q| zt>lV!Q3D>Yhtr>LSiSC`R!xyy*u$IGzTTa~Qq%Q+ zZQ!y$Ecf~Rykyb1Vm{{|q8=99!C!ZkukT9~yf@QqZMx{P53g-^pGzn{`MTD6BjgTe~DWM4fRx6bg literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSF8.png b/wadsrc_bm/static/brightmaps/doom/BOSSF8.png new file mode 100644 index 0000000000000000000000000000000000000000..70af4c02bbba3b22a65eb4e2383ae6215f968cb1 GIT binary patch literal 366 zcmeAS@N?(olHy`uVBq!ia0y~yU@&7~U~pq$W?*0_^{mooU|>)W@Ck9`VtN|C+|HTpd|w}I(SP1@UQwnWW>b z6lv0>ZQ>}}6hkXV$vA*R0dFE$Em(hq-ru z@b2=+^NyEUrnH=Rd+S$>p48x^nyv@E1o<{6NXKHmhhMD^mKUBr#yG= z10FnGH9xvX)W@Ck8Uvu2HqjLeiN zQus@71>oh@q1)k%*6Y|?7@WSUiWob=VxB#E_gZn;?CU+yYGAq)h>T~=;{8KtFP<0 zPq&t2T=q@oerRyBUilY^mU*$wlGl#&?QVD(yWH?;65s6~b1aLic++HL@69Uyab}`% zy5GqMUHfHZ3bUDyq*+Eh>3iR3#Sy%&=Jgumbdz&)GTkn3PYOS~YObK%!eXoQXEr!) zUH|*bCy!~FbG_!u%F3S1c$xEk=40#Fpv7}{E!(vuamm5p^uB!G?s+@etAE85r6E^_-#dp|NTFfe$!`njxgN@xNA+J=mt literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSG2.png b/wadsrc_bm/static/brightmaps/doom/BOSSG2.png new file mode 100644 index 0000000000000000000000000000000000000000..fc735a9cb93b9f110f6b7dc70694da9e6774b2cc GIT binary patch literal 312 zcmeAS@N?(olHy`uVBq!ia0y~yV6bIiU~phzW?*25{*ZK(fq_9Wz$e62U0t1pg{7yb zXUdc*B_$<>hK4mYH9kH*F)=YIDJcvL3@hKQ>SthJxa8^L7*cU7IigiuCqZJW{M6&D zVM3SoPnz&k_{8*hKZm-bt3u^|Jkd^Dn{`w@UaIr@-_xwhmoB9}oW?Km*5}*-Svzgj zqoKDpeQ3GAhGV)$z>o8Xv~FA0UcIDI@Fyf;YX6H_tiAi63N#+oa1`FUg-f+=ZCGTa zuKNl7r%qk}MK>=B(~X`wb!upMWQfX>rNF+Dr3__l>91w{MxXEcBd)YM*Hw0({<7+*o79fW-?_w7Cx5&6$5zY!(i27jOTPHU Uy;2_;7#J8lUHx3vIVCg!01*#^X#fBK literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSG3.png b/wadsrc_bm/static/brightmaps/doom/BOSSG3.png new file mode 100644 index 0000000000000000000000000000000000000000..8d74f0cdfeee11ed36cbd68a34cdffdef5c845a1 GIT binary patch literal 313 zcmeAS@N?(olHy`uVBq!ia0y~yU@&B0V6bChW?*0_c=GNS0|SF@fKQ0)nl)=!SXg9a zWcKXYV`yl&WXTeBb@eGzru6jm#Kgpul$7}R_@tzy)YQ~4Ffa(s(0IbYz;N8t#WAGf zR&qr-!(q<&-ksGVbU{uyJZxWUZp9!6Qk6H}kPY4)}`b%$G} zI>Bi9-v>ti&*tr{{+=b{^NjD%hApO>_e}qOFjm((U-r(dH|6V}DgN19BR@&_-W%sn zE8j~={C>KteEr`EDP|#eYm52L*ctMh-s!u(ZU_6so4sO-md`p{*z$FDTCj|fzWg6JR5Fo~!MUh? WdhpCM7a15B7(8A5T-G@yGywob=!66S literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSG4.png b/wadsrc_bm/static/brightmaps/doom/BOSSG4.png new file mode 100644 index 0000000000000000000000000000000000000000..4cb2a3f96ca50716dc54f956a896af8ad78d7476 GIT binary patch literal 261 zcmeAS@N?(olHy`uVBq!ia0y~yU@&B0V6bLkW?*1Y(5&}lU|>)T@Ck8cVPR2MS2r{? z^zreTGG$6lO-)QpOi4*ePft%uN(uu5!|fmDQy3T+=6kw0hE&{2j%a1pNsySjaPgU< zIYyfcPOdqUd5g;^CGEkKlMK5ORKp}ce~OHl%YJ3^o;@{JQ#5sqvQ95s8x@w>dUkpD zmN36_hth5-DMZ@oa#we()6tyQ>a1oWQmvztUplihHchkrw9XnM@9>hf2LzWJ?Doz&`@1n zJtih5B_+kj$A^J|L0jdnBm)COj;D)bNX4yWkHg$T5^hi3choRR^X+u$u+e*IqP(Go z$#3)31D|%tOi*Flc%Rp!EipJ@1>0nQ&ZBDbEZ64?NwgiVT2SK^HLG*AgxvqxJKCg{ zaz5tVpAx)qi;L-=hqEo3F8OaNzL4=xa;m)ACkFHDJC3gZd+Iy`0|SGntDnm{r-UW| Dn&d_i literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSG6.png b/wadsrc_bm/static/brightmaps/doom/BOSSG6.png new file mode 100644 index 0000000000000000000000000000000000000000..df682c071b3eced659d57f0d421675bde38218ef GIT binary patch literal 203 zcmeAS@N?(olHy`uVBq!ia0y~yU@&1|V6b9g28qO^uV7$ckPGk$ab;m)QCC;5sj2bt z@#*R5F*GzxNlA%`i76>5VPIg;Dm@D_BE!?gF{I*F@{CSlgB~wl!9Q$&~BZ@troiR4kV(GH7jJ9+#HxMcvz1H>xTd95Hq{HYF-y2J zIAzL|nwpxFloTHypO~1Kl9Cd2b@iT}9tH*m;hlR085kJ4JY5_^DsCm;=w&zP@#^z> zG)?EQ_R3y&BhL9x&dg2OU8Zi!ocKIPBU#k!zopr0COZ;CIA2c literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSH1.png b/wadsrc_bm/static/brightmaps/doom/BOSSH1.png new file mode 100644 index 0000000000000000000000000000000000000000..bd4fbfe56d85adeba2e3d0246460fbfb16eea477 GIT binary patch literal 167 zcmeAS@N?(olHy`uVBq!ia0y~yU@&4}VDMmMW?*3G^DqfzU|?Vi@Ck9%*VkuYV0aPB zIgx>ZA;#0iF{I*F@(+GCc8NCGzcOC`-Jafm-+tlqd*>IQpDTVT)|ks9T7Q6l;eLgg zzu)UmSjT>;zQM#JwwL*co%D*m+X70r@h1E_@6YkSUo~W(gqM8VrTZ7}{4GDxYRsT^ Y=++5?H~*hAFfcH9y85}Sb4q9e0Q-$UMgRZ+ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSH2.png b/wadsrc_bm/static/brightmaps/doom/BOSSH2.png new file mode 100644 index 0000000000000000000000000000000000000000..dc93c8f70f31a7d9cdd1cda9627d07ebc568f484 GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0y~yU@&H2VDMyQW?*1gb*<+d0|NtFfKQ04zP>&K1H+40 z&WQ{R4CS6Kjv*Ddl7H~C@k_L6{T1*1FY6`WcB%HOK-IrGj=lHgyqu4|PTXSKWXC6Z zpKrDP`~?Y>yPC6*0pvtiKbLh*2~7Y*_E7== literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSH3.png b/wadsrc_bm/static/brightmaps/doom/BOSSH3.png new file mode 100644 index 0000000000000000000000000000000000000000..b94e1bb1abdc149dc530863872d2f945412aca8a GIT binary patch literal 173 zcmeAS@N?(olHy`uVBq!ia0y~yV9;k^U~p$-W?*1g>(_IGfq{W7z$e62Umqm?B9?O^ z0|P^nr;B4q#jWHY{7nBP+PJ>TwSHeK=kvEQfc<;3rYA=#f1uHS^BJ$&KfI~G(!BEa zCxumiztss$Ef>})=W~)3U%aPg-(*_?`u8`jydQn=imY=-^cBUX&+See bObj2DXQuh_z3gCMU|{fc^>bP0l+XkKciTU0 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSH4.png b/wadsrc_bm/static/brightmaps/doom/BOSSH4.png new file mode 100644 index 0000000000000000000000000000000000000000..ce03a828f99a4086fc01d8722ba226217237702f GIT binary patch literal 120 zcmeAS@N?(olHy`uVBq!ia0y~yU@&B0U~pz+W?*38-%&r6fq{W7z$e62Utgbrf#F3g z=R^hu23=1V$B>F!$v^nnczK+A_w^r}&%gBg;)`EdUi|+mP$fTQUvR(HKgIftHvU!< ahG*KVZ%e!1Z!N}9aF{I*F@(+F{9_Oil+7te>OrC%62|LGc^NyO2vO3i=F8>~~PyGMH@kx0H f=Y976euh)MZo%F+z5X&VFfe$!`njxgN@xNAT8k!b literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSH7.png b/wadsrc_bm/static/brightmaps/doom/BOSSH7.png new file mode 100644 index 0000000000000000000000000000000000000000..4061dc2e919dcc3116c9e9eccd3feabf8be4086f GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0y~yV9;S;U~pq(W?*3GRee&&z`(#3;1lAiudmO*!0;lL zb0Px+L$IfdV@SoVtK^~IyX9T} z{@cy3^5gfzT4sUJ8Y!Qtwi*mU^*8Dpru=EXRW6_PcKqQ$X>v8#1!#?pZ`gC8q!;Y;ZFGQggxtI39xR OWbkzLb6Mw<&;$Sht}~7R literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSI0.png b/wadsrc_bm/static/brightmaps/doom/BOSSI0.png new file mode 100644 index 0000000000000000000000000000000000000000..8626bba21598df883bcca38cc7e5842e7c23d853 GIT binary patch literal 144 zcmeAS@N?(olHy`uVBq!ia0y~yU@%}{VDMyQW?*1&d}w}_fq{W7z$e62Utgbrf#F3g z=R^hu23JoP$B>F!$v^nnc$_EyQs;lTw>{vqV$)XvxhY-l&urTR#Q!bUU~IatapnH| xgje!hU)i1h*6}}dT=D!R6JZ!Q0ctF{I*F@(+Ht{}ODXe`P&xGrzPi<@x`f`Q`oF68}y%XWaSq?O*$e_pPt? zGcUdWj{Va1`-U~lAOGJ;zQMU@|4qlQdy^%m{97*1%dr2>ju(H_k5(`+Ffe$!`njxg HN@xNA&8#}h literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSK0.png b/wadsrc_bm/static/brightmaps/doom/BOSSK0.png new file mode 100644 index 0000000000000000000000000000000000000000..0a4809b98d7194f8d00d0fa6303c7df1a75de526 GIT binary patch literal 137 zcmeAS@N?(olHy`uVBq!ia0y~yV6b3dU@&83W?*1g;dDZmfq{W7z$e62Utgbrf#F3g z=R^hu20Kp|$B>F!$v^lRd77u%@hq)(ez{lS)9?DW+X}z_*0EW?*3O3VYAPz`(#3;1lAiudmO*!0;lL zb0Px+gMz1vV@SoV(89*Ec>jldHTK7#J8l MUHx3vIVCg!0Kx+sxBvhE literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BSPIG1.png b/wadsrc_bm/static/brightmaps/doom/BSPIG1.png new file mode 100644 index 0000000000000000000000000000000000000000..034ec03d8b3fa9f25914b01aaf658add44441f87 GIT binary patch literal 131 zcmeAS@N?(olHy`uVBq!ia0y~yU`SwKU@&E3W?*1Ayp`=e0|NtRfKQ04zP|qd|Nj{n z7|eCQ_kdJ*x;TbZ+)9pUWj5&X>ha={?Tp-^a;UbM@gTe~DWM4f?1Lx9 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BSPIG2G8.png b/wadsrc_bm/static/brightmaps/doom/BSPIG2G8.png new file mode 100644 index 0000000000000000000000000000000000000000..937b8b1cb83ef8731b817f824755ab4bf6d2b569 GIT binary patch literal 102 zcmeAS@N?(olHy`uVBq!ia0y~yU?^i?U@&K7W?*1=oU1dNfq{W7z$e7@|Ns9C3=E-% zF4r+IFi3m4IEGZ*O8(K$^v|H@Q#<2-f7{eQ7e6c!m1mf7+Suj8v8h`b7#J8lUHx3v IIVCg!0DrY1MgRZ+ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BSPIH1.png b/wadsrc_bm/static/brightmaps/doom/BSPIH1.png new file mode 100644 index 0000000000000000000000000000000000000000..4e3625aa2dd24640d2552d5664372e065449196a GIT binary patch literal 157 zcmeAS@N?(olHy`uVBq!ia0y~yU`SwKU@&E3W?*1Ayp`=e0|NtRfKQ0)|Ns9T92^)J z7&g6I?8?Bv;P2_;7*cU7Iii)>pvSAni)Vq0NZXN98B#-vyu!ol%XR%z+cw-lT&|sDX+jNVbT0 zr>|*p;#>cPOP4NPs!IwrPUya`w!322H`C1=y9-{w-p)8}zk|1QK6`?7LUzEj<>hw0 Ycew?x%G8}=U|?YIboFyt=akR{0MKwe1^@s6 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BSPIH3H7.png b/wadsrc_bm/static/brightmaps/doom/BSPIH3H7.png new file mode 100644 index 0000000000000000000000000000000000000000..4ff61708fbd9144a01f6ba60922853fb60b48052 GIT binary patch literal 112 zcmeAS@N?(olHy`uVBq!ia0y~yV8~!#U@&K7W?*2r#WnW;0|NtFfKQ04gM$MD14HJG z&DR+i7*su7978H@CI9H>k#MUtdGL3o`?J5!&;Ggu{$y@tzicMeWb%}e;Zypt16?;} SsW31wFnGH9xvXRInmelBw@nd{_wCmlQnI#br@nd X=eq4z?iOWWU|{fc^>bP0l+XkKRCFQP literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/BSPIH5.png b/wadsrc_bm/static/brightmaps/doom/BSPIH5.png new file mode 100644 index 0000000000000000000000000000000000000000..a3c97ea8cc6957ced52f3a5c00f1dd3a4d70b22f GIT binary patch literal 121 zcmeAS@N?(olHy`uVBq!ia0y~yV8~`*U@&83W?*3WmH0J{fq{W7z$e7j!NGxnfg$t8 z=Iaa$40@g}jv*Ddl7IB`$Qkq$Wgh?Aer&D#!+(yClZ;;(_xxrK{ibhrwEts~yK<|G b9z#UuOP@{MU!@rs7#KWV{an^LB{Ts592zLC literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CELLA0.png b/wadsrc_bm/static/brightmaps/doom/CELLA0.png new file mode 100644 index 0000000000000000000000000000000000000000..f06e3d3d706b1d8c05ef4e3863f60cc40f7cb476 GIT binary patch literal 94 zcmeAS@N?(olHy`uVBq!ia0y~yU=UgTe~DWM4fZ>Jl& literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CELPA0.png b/wadsrc_bm/static/brightmaps/doom/CELPA0.png new file mode 100644 index 0000000000000000000000000000000000000000..5b6486c8b574957a11def5977781f7b82a7a79b3 GIT binary patch literal 100 zcmeAS@N?(olHy`uVBq!ia0y~yU{GLSU=U?wW?*2DWv*Mvz`(#3;1lBd|Nnmm28Pf> zm+Kf97$iMi978H@CI8@O;ZYH+KX4?S<)h5Z150@sM5BYnFI*JtWnf@n@O1TaS?83{ F1ORB28p{9x literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSE1.png b/wadsrc_bm/static/brightmaps/doom/CPOSE1.png new file mode 100644 index 0000000000000000000000000000000000000000..437c2a463ca5e6310f87c84b515d487b7b8eb44a GIT binary patch literal 121 zcmeAS@N?(olHy`uVBq!ia0y~yV9;h@V6b9hW?*0l+3AtXz`(#6;1lAyWy_ZT|Nk>E zFg!T1kPoEF)5S5Q;#P75E4#MDij#3$yt-edU7E7ji2GoiRBJ+eTavhYn0?3}i<%n@ ZzFJFOX}uS@%D}+D;OXk;vd$@?2>|0{CcXdw literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSE2.png b/wadsrc_bm/static/brightmaps/doom/CPOSE2.png new file mode 100644 index 0000000000000000000000000000000000000000..9597368cf4c1322b5fbf04341dbd1b96bc9fa16a GIT binary patch literal 137 zcmeAS@N?(olHy`uVBq!ia0y~yU@&4}V6b9hW?*3GXL{t%z`(#6;1lAyWy_ZT|Nk>E zFg!T1kdJ|Z!P?WsF{I*FazrbOn8Agf?HR0Va~G)VdvUj3Z#@z%wTq*3yHM+PEv}gd>!1;l9f!uYOs?kb2AW V;hFrmf(#4{44$rjF6*2UngCPtBY6M- literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSE6.png b/wadsrc_bm/static/brightmaps/doom/CPOSE6.png new file mode 100644 index 0000000000000000000000000000000000000000..61eda1af77bfb35340dc15189ce90b087c99fe65 GIT binary patch literal 116 zcmeAS@N?(olHy`uVBq!ia0y~yV9;P-U@&K5W?*1o7I?6Mfq{WDz$e7DqN3ve|NjgO z3^V$_U1eZkQ1f(g45_%49Kp)YbGTtA&%rreOBA@zJ(<-d5ZiW^Wm%#iUvo1jgXj6| WN&fq8&R}3*VDNPHb6Mw<&;$VVC?oj* literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSE7.png b/wadsrc_bm/static/brightmaps/doom/CPOSE7.png new file mode 100644 index 0000000000000000000000000000000000000000..587d4f62fffb7439ceb8742d64920b2ee9f4de3a GIT binary patch literal 138 zcmeAS@N?(olHy`uVBq!ia0y~yU@&1|V6b3eW?*1&m~w0}0|NtpfKQ0)mMvS{+}!^E z|6fs2!N9;EH;2D~fq}uy)5S5Q;#P9OK~4#_rBjSgCzLNCF^6xg-{z;hS%D}+D;OXk;vd$@?2>=HRFC72? literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSE8.png b/wadsrc_bm/static/brightmaps/doom/CPOSE8.png new file mode 100644 index 0000000000000000000000000000000000000000..692601735a1b5f72a64ccab291f786e995966ca5 GIT binary patch literal 143 zcmeAS@N?(olHy`uVBq!ia0y~yV9;P-V6bFj29Z*Y2N)O_cmjMvT(@l5Qc+Ry|Nnmm z1_r}LIZ+G@40fI_jv*Ddl7H~C^IS>#_cPz$_V9|+fBs3G+tZ(LZSAf81Si-3ZU5ah we*BkH>@s-s`Tu8wXYK$0G+#O1+|S7n%wc4FbanGQ1_lNOPgg&ebxsLQ04$9+=l}o! literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSF1.png b/wadsrc_bm/static/brightmaps/doom/CPOSF1.png new file mode 100644 index 0000000000000000000000000000000000000000..a445fff92f4dbfc193f76311ce079ca6561a0a36 GIT binary patch literal 467 zcmeAS@N?(olHy`uVBq!ia0y~yV9;h@V6fs~W?*2D;|w^%z`)=X;1l9%W@ct-X&Dq0 zl$n_+A|jHQn5eI>9~c;DVqzjECud`0qot*#uC5*v6B8aDo|cx@(9jSN5a8kA@&EsS zTU%QO28J__XS6XeF#349IEGZ*x_a&Qq-F&khJf#vu1QaCdGf!$l(|W?-Ky}|+jE~D zTsCY`xl*tywhTSWsVV&iZY&>#c5gXKI8UT4%d;#~Z`*zTO-UZ~mXXwtVH9 zfQ`EoXBOY_RTY=MbgMLfqjInE=I=Mtq?|sxC{Ok`xhcSBm@bveA^K15S>=t$6W{8p zFRkCbL{oifm6?rWpLc-9l3mAsT`JSr)BGiCi-~T@qOIp|?>J}Kl*FrUvoZ7BjN(1V zM19m)D!06FK4dg~M`8G7&kN7i*w<{ieN!>{*7ie{%Xj4${^qSstc~ouJO5AE|8Q@H zs@?CO1oEZ7nORf#ed_KtX)WnGFN+duSma+ aVc)Fd0j@Q_&NDDDFnGH9xvX;N~L{3glSy@?2OUuB(ATBOWQBhGrK_M|QQCnL(Gc$Ac?AZ+s4O_Ns zNlQx$2ng`-@c94#zpbq;0|P^jxhyLK17oPCi(^Q|t-I517Bw62xW1fcqPto({{R2} zYs>hyZES10^-NJ}#z$uMx8hREH$RiJcwy1B{qY@PjxP&7r2C(nn^Qc4c_Z`YMS4&2 z?`){QV<-0{DeU?4WSJQrg6S`|cg^0rG}E!>w%)nz>uUa`=hdamJNJI|yQC*;4wS{d z-SjD4RVerLjdk6k4iA>LPH>nQ&&m|Z9X#jb6`ha`-ZQ2oBxb*ia?4cp%46GX7`?1- zV!z9ioK2sP`d&W5S@ZjgnulNV^)QQH3|wUi+e$R7x`|47mz&8%* zMe}wBzgQp{@@waocLM3h92Z|dT+o02`~BiQ*ShA;iC5=!4>4xy`iB&OH0ed#6(+LJ0>PZQBg4)O9E7Dcs$s86~2?|$tK&pHOa2`^{tP;GK!U|?YIboFyt I=akR{0JBr3?*IS* literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSF4.png b/wadsrc_bm/static/brightmaps/doom/CPOSF4.png new file mode 100644 index 0000000000000000000000000000000000000000..50c3c135d98bb8250ea01db3e4ad6dadd2757f65 GIT binary patch literal 178 zcmeAS@N?(olHy`uVBq!ia0y~yU{GgZU@&80W?*30#y;1Afq{WPz$e5tEiKK)#ztLT z-PYEYfq}uJXiqu=14Epri(^Q|t>l7(EPOmB!X^jRUifTTzF!$v^m+WsUYLY;FRmI xP%pu-N@3;qmX*IXuGERFlAHaYF6J8}gS)DGxOvOP6ATOt44$rjF6*2UngCC=FQ)(i literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSF6.png b/wadsrc_bm/static/brightmaps/doom/CPOSF6.png new file mode 100644 index 0000000000000000000000000000000000000000..574378a254c55897b11b52a4b9d6b960c48a70f1 GIT binary patch literal 214 zcmeAS@N?(olHy`uVBq!ia0y~yV9;b>U@&K4W?*1Qo>ZsDz`!68;1lAisHmu|tt}xT zv1Q8^4-b$3|Nq>FMGaQgQ3;B}Kjl10L23mVJj91!5R%md#XO zxK&`=w_j(zb90DtsKw8^pOCXkrxF%KuRi}yTe+BgOtt{d%b=|2mf7fkRUq2y} VYfZ<_GB7YOc)I$ztaD0e0szqlP+9;0 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSF7.png b/wadsrc_bm/static/brightmaps/doom/CPOSF7.png new file mode 100644 index 0000000000000000000000000000000000000000..14e4c56810974b570a38916daf8e38edb6bcc7c8 GIT binary patch literal 341 zcmeAS@N?(olHy`uVBq!ia0y~yV6XsT4rT@hhWQbvbr={Jj01c^T!VswEG;e5($f6= z{0s~XGBY!soSYgP8)IT(5)%`{!@~mt0=8_~;^E=(|NnnmTU!POhIjjqMKCZh-1T&E z45_$v_i8s^vjPumz_y=E*W&*D&o-Z9H8&_ic)LcYn~z_V7qgm1yCru?-xR^bg^hiY zQ&+v;HQ`KX(+(SX*Hst7rq=E54{&~=Fk!M=!6MNI+}f*V^_+^7h_8Da;Z^$U(``Ne z%%?6p?sA;-%acyxbNt(}f7UHy<6_VCRTuWk7Zzpf_AB$ZcN7-o#umDqQJ!_{RCdgv z@*~SO>x6&Z{P)=B{IBa=TR+~Z|aWw~>X@zc74v(p(~++|>3VDNPHb6Mw<&;$UHmW?<7 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSF8.png b/wadsrc_bm/static/brightmaps/doom/CPOSF8.png new file mode 100644 index 0000000000000000000000000000000000000000..e80c306a1479e219c7d401b040fb13b898870cb6 GIT binary patch literal 352 zcmeAS@N?(olHy`uVBq!ia0y~yV9;S;V6bFiW?*30zwwF`0|SF@fKQ04nwpxvzJ7Rk zxRsTava+(DpP!+jVO(5XW@ct$VxotKM?gTp|NsAOZEYDC7))0_JI=ts@Xpi4F{I+w z(Me}{4;k>ZS~Ch8Fr^<$Vlr!Btx9YVsnTPyYJA!2eZW>xaq2DO3I7_LUM~uBn&7Nd zTUAw8_GV+np81Kro1*S7XOin*=P8}e<=@1qc$CTSsLGYb);kCFp8mU$BVjmok8WL9 z?t{;bmgNRX7kwK)FKIkI{ouhbtJn_cZJQpXcz)p%zmq*%_xb9~+xzgskJU~**Y5I4 zypVYHIN{c>k8)A>L|z!IvY8d@Hr-6Gc^zYG;7nGT*0qN+W^&9}^|0dqz4!VLf33FN zcyit=z4uj#zu2Z+&1~o7J-Ecoc~Z#1XtiT{JEug4)c+0$X3JS8bv&+iL!otGT)zwd)JZWcVr=p^A_3G8$ z-d=rueM?JAB_*ZE$Vg95Pjho~O-;>!fPl)%%KZHN!otG!>(>Vd2hW^2)6mect*tFQ zJUlKgE;csS$;l}tCB@#}K0Q4>A|k@g&CSQhConM3#KgqP%1TE^=l}oz3=9kV~$x$g6QN9ye9*YuBdN^aj?ZMUQPhh&+}oR){FaqNx^*H1os`hS>QVA(^K#iQ9j}gdnMR z)6!RSJY2pnRMEB;&d{rTdV8mIA55M3R6s+qJ)uI_OZ`gn zl+gFJL2}1Rl3scoJRRVBO!z?0@#Ir0R-CyZw1Hbu;^zhChtVxz)3mS18Cs}bn;}(s z)ad*%+x%ocg*BfJ^7XepSUthXJg|MEqrt}BUXEi2m+fcj6R!xEP|*6+yzX*H(gxiw zhlb7q70#o2Ps@%z(ysD7Z+GFU*P>rbRM%#OB`nLTNMN#3iF%}*`qgpX+>5WL>+dZ; zHba!bC-hjK#A2Bv{nH$NIo8#bm(|w({iw{^VrZCrc;%r06~@Z2Mh*st-r42S4TfgB zu53}Ra#6o!o|eHT^yTuw1cN1Ns)aYQ4IeG<$!9BS__XYIT80r%HIK65uSb{Pf2cOB z*gwgLKd|xRF~4*-6BgXRrCu!_8t!%T0z-mB_+gzzQE`r4 ze6o)-qmOWwW;8DhdEUO*%cjlnF<;u@lpBr;x#8Noyq1RW9y3TfkoWP)v-2Tkk|`;d zwpH0Qd{~}rbF^polKo+~y>}UD8RsRJ-z^nn*u2Kq`i*4J=I@ej$CWo~mh1I@UX?mM zVCu)PYSMu1iH`7iP^6XA@X?yYg+qc?zit4ip4|pH>74&G%1M&97 zI?e8Hw|rZWetF6Peo-ZkiVVNw2h#X%1)ZI$Diy`=xbpP|-+eMKwKFP3d*toTNZ*l} zl>CU%c0E&r<}|IIIR{lY|B`(+Ws~y~H{Z3}vpPL<-c@U^Epp3IxOFyFQ+A*2f_sud zCldVjmK~N9nBuqk%C+yt)%W?9-3UKZ$>p!lanb5kZ4i&5k^j8A9;c2lw}qQWyvjLI zTj9;Gd{HqBCie+9d?i}(G5jtu0E?!Ud6cz<*&oy(=n$8e0 z$tCUdJ4=lpi$Z$@c#bEo3~KYx+{!I*CrNnz+P5jM1CBJj*MB5wHd-iC&aCqgGJw_@E`)-P$a` zC`p%3GuUrEKiFJrQ)}bk_POj&Nk2b-f4txMAJseK*5|vu?dtfnuc#w#J-f&Wy>^Y~ zT5rS7P3ozizIXQQ+4pv}FRZN4$!!bzt+-Yv$!h-h-=8bbJDyS~*<7R3M2cP6)KKp{9dAoE{&Y2eSbRS|+AK={;yV7Wvvq2 z6mw?XD+9igXwNoho&B+&j!C$8`}JP0>^Zmkyu$tWj&-lEID3SO@aI&yU0y%;=$ho$ ztuk6F=C3m28K3BPSZ1r0oA=CqnPm2Bzp;Q}Y)oIy|k>Y;FJm literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRF2.png b/wadsrc_bm/static/brightmaps/doom/CYBRF2.png new file mode 100644 index 0000000000000000000000000000000000000000..886e5b20db391e7a8181106bba30231215d6c58e GIT binary patch literal 1976 zcmeAS@N?(olHy`uVBq!ia0y~yV2ER2V94WOW?*2LSr+n{{BfxNj*J1)2C0Dlaq^&kKeIl$B`pP zR8>`H&YZb+?b?=>mg3@KB_$}hjxVyWjrKLqhMJ-vfq^zv$=+UEjd3omM z=9QI|ZEbD!_4OGU84V2$l9G~|nwt9h`qtLgQ>ILDadFAc&NehOAbj;7skBEp+S65F@PftlnadUGE3=DK~a`N%F!Z)c^K-?rjut4;r&cgv*O`eWDQ zm9`pPN=yI$uh;YNytaXD>J9m-bFI~nLOSIg^&JEfZg+pn+WY_Ge%^aRZGZPxy{|uV z`tVo34`E-QJ}t`p`TKBp`VGdq*z?DCAKioGu@NsfP?7`bz2MO^hG#xs9)wWGu4udC3t68vE+$~w{1 z>{jy8lHA+6aUXpymwXSM(An85Z!c5sU-6ht+T8SyUd4TV5y>YFiXyCz33nRyO1v-F zBRjj(mj8f8uhFK}ci!vqnbqDmH%!&pc|iWqL;lC_0;+ekKmPGxPcvty!Snqb=Ubn7 zb_j^O#_W6;?(xUx9Jg?AOJGH>4S(}R4+X*fJs;Oi6J7B4hC}TWrTc9{jMJ0ks;>uQ3dw9c9=eJDqOUxOVtJ;pIh(BUE`nBuKfmR(>lbft|o-=v!cQ76^eX*`W zizmcw zR>-==8LfA-bK0ibi?zvt>Yl~-rhl;f6)=~t{jjjq;hQerTm4^&>*en2{bAsDT;|`c zeRWIMH=KXCYL_Of+aa+g2Cd#(4+ zy|8WS6>|@l&Sk3hu&i71)%)?U;4OYXb?@bWbmR$*=Ly@R6VWhVM=bUF&mDYkmMhPE znR2>bpmp=rlZT{gHmkMz^In_Ju%~X4T-~;-^PLVhvPWFVUw!q!rO)TqvwwJH6g~Ck z^~;*gIgt%tu9a~8GO*pRI;rD>ZTEJbJnMZ*`jyJZ*j7JHu$mhowzaK0hW`XpMdQwf z<>#Zr5>9K@bL=bHA9?t2&16lVpgF#KS6-N}`y$EU#D6QMQFj@~nRSh_KBvgesD1Myw& zXPm#`Tr)Z8Z;ohs@nVfz%RZ;=c(67k@7pKVwM_HxDQY~PS@Uelk(2e4A29RxJo)Hy z>aWedKe6XR8^3?DP6b8?aWF3`;)#$GVhD1 z{}r));Ajj=cS0bMJg@yY_I+-~7VGdM7@wPMiC6+w)b6Og`7e`(&+o_rpm> z|4-Ef+1cKIHsAQUKy9P^qq*K<^3$IC9i8uPSvW;^--frr^6Se!=v3&xSXpbP^56C3 zVaM+a|9{?VG}%UvN9DW-k8|LbDS2lWPG8C{+a!Lrz3eRwU4XvyXTTE_Uli7XRA6eIgYEoZq^0W z=2NN*IUaW;-RiU7-+#Z}>(rrcv&DZ_xUkjN)r(#Jy=i%c-f`iFwYx38*NE=@`O|IM zya%rJSJ&;G@ND@aiBEx|&vQ&(=T`fc6x?I4YWEU&zx(F4OWD(oh5PNkCaD!({Lf1K z%g4wsJT(`ZzTe;X_IqvWpQYNia-yEXb!NeR{q}dh9-m&{XD!dbZIgGXzBlbu`{UF1 zo=(@F`_e-uda;_#nu|9dw>Ph6KYsjv{_X>u5+O3;3&q~1_xC?uf1g`=ZOiLD-t5-} z^G?sXIkV{d@wxYV`wUGMP0UVvp1b$e->Vj1pWm@^yUNR?D4=-u-ua%72cPa|zyCY- ziDw_vCwHdOM{}CKO@CZ%Up3RTRqR9Tm4}lx6sMFOEPuov-Og8ftGKYwan8+hjO5)jmu-^uTnXNy6WI|KGl~zm;0C*U#oi1_J{FgQu&X%Q~lo FCIH{f(SQH| literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRF3.png b/wadsrc_bm/static/brightmaps/doom/CYBRF3.png new file mode 100644 index 0000000000000000000000000000000000000000..ea6ccde8e46c7e13ee5696d2fd1639a0d01a4f47 GIT binary patch literal 1830 zcmeAS@N?(olHy`uVBq!ia0y~yV5nqZV94WOW?*12`R)_Jz`(FHz$e7Dudi>?q)DZv zrKe7v3J(u2FE5XekB^LuT(@rB{{8!xELoD6m^g3VJTEV=tgI|PKECPGr>|YR*4^Db zH#fJas3;>NLq$bJUteEPP_Uq&z|hdJrKLq!SlHa$ytcNsva&KJCPq?HQcO%NKR;hx zT|FfwMM+6XPEJl*S~@m1*2l+3Q&Te{A|gFK-O0(x-rnBC#Kg+V%FWF!FfdR@N9X_l z{|pQaoQtIt85r1XJY5_^DsH{K9bPW2Ex?d)chc-fJ5F!vTKaY_-=qKkw^(n`zO8jz z=j|(1n;$aIReqWn@bDC>{fbKdmSn>sgZpIby^+XS77%T&KUBe!2bcX7_t z-u>r}u-=Nad~G0Sd$?oy(kZX6M_N_o&AxiAukNeOrg`y+;g+AKy0||2{W&mo4d*q7 z_VuoBdZjlfztp~Jz_f7k>k$7M(MX2wuc2wtUz+tTZ#ylv+23?#r<+7$&!U`=ncgRh zl^1JtxlQeyqIF#2WlhS=<})5_n|hAT&1E%lbU3`yRr9Kqv~QSGun$X(>AGc+W_>zK z1%$LtRvQPK(zI8jzKpXaw$uc&IJ z-;^d>UQITm;Myl|r>9E?vmRxRQIu%B>uPmK{?oT?N8vfzOLfkOK2G5eTjhIi*2#Ny zN7ZB$!!%!UB>8^yFU!8;cRo$gr1y8Kpt4t_0e_O+ zB<^i(3HDLRQM)G1*dO3=aa-$*71}yyH_IM-IO}MkWS$?7dPsi4Y|FHC$B>zp{ zt0W` zu=D&@z1^lI+$@iJgI@)eGZx7iJWME@aFjiCbwmFf<`>7?z8&83STnMhBax#|BvE4d z%4OVIbvwh_baGFs6?Fersa<~mP~Y+t%MVGSoS`iO8-AviE7q-TI9J4W{fAa;cII3$ zvk?1z?fK8Yuem%o#r;3WlV7se&WNs#=eCeCa`RX{=hn|{^+sQ%>tB0HPWR5~S8_RV z$aK@WC4X)#`dY%38Mfppi-+d!yN9(ZHyt`L&#>T}u=JNhypx+>1?;}0wp`olwAHEi z+`MacN39jp3!j&MYJT-0RCMpW}O%j-bT1e-N6fhzg=VZP5YC*IMUu2uUwMB=Tfi(~6a&Ez$?;kn=4 zHwe6Xs~fp4bVkLziH9v-M)h0H@%1U3P<$)w@HY3y@zItKUrnx>XFq>=?Yx5C9In1g zx$8|QCrd1gX5!Y{P<*$zU}4qW?cXousLr3J#WVTdtLLvdpUk*BWABrdh>SU=erk_uRc@BzLP6v{_eFt7nXJ1 zd@W#dJ@?bQ(pP(4Wlk5Jw%y0T_^HF^ZC*v!X5TsJy}MRl$n4^o=NZ$^S4&ziE4>{0 z=EvR7i%QmuU*|sgG|bM*UjNUs`#TQX-IqAB;M3{2`oA;9J{4a!Tv20jwfgS4r%xYL z-+k+|CFRD=qAL~Basho=O=icZONCt1zn`73^Lic6#?^j*lXVumEZVDm%EMmXZRwfy zO2z?>VkH(o_s^OT$YylsPy3|ByR?#0k{&cZ$+%^3d*`Cx*1wuQ-Q7|**Vo=YK$Y`L z$>kZztNzx!lV813?sD3W%V!t7uej&){@uHMTMs%P`San&XT=@WJ9q9Zyc;!*U(w$F z-{;RC*XLi({P0I;?yU`PC732Q!O z`d$8pZ^L1$`7d6coBuZ9vviVO?Zx$FhUUo)e`BJz&N#uE`u4qwc)O_Sx>eO8vw7H! zmH8`^OxkVs#kAJ&-drZ0`=fIbWAe7eW(U{(uy_2&Zt-sY!=j(3d>9xQ7(8A5T-G@y GGywo=9&nZb literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRF4.png b/wadsrc_bm/static/brightmaps/doom/CYBRF4.png new file mode 100644 index 0000000000000000000000000000000000000000..d53db24cd0f7ca7830b6d63d54d5639d1339a8a8 GIT binary patch literal 1540 zcmeAS@N?(olHy`uVBq!ia0y~yU?^u`V94cQW?*1gvx?7^fq|hqz$e7DrKKe}IJmsL zTw7bar>BRHk8jD6C5DEE)z#HUjvUF)&kqO)2oDeU^71k_H&0GZ*3{HYPfyp^*H=+d z5f&B}6ckiaQc_n}7ZVecl$4Z{lXG%%l9rYZ3=E8ojg5$iaC37@NlCG{x3{vgGBGjn z@$u2o(fR-XKLZ29y?_Hp85meyJY5_^DsEl9&0c)liiaU#|HY4&jzk}xw8OLG|9^2i zhe@)$yC<5ySY34e$))c7Oe&0%{LKHEo`2R~^7#6WkJ*oUou5g5yRNVB;)m0l$t_K1 z51m`BoA!OivdkAh_neK}(zor+g}=uvFVxuO+>xB0w&Q%EOqQ&y$&tbsfxJ&YgbM!V zZMUy`^L@EbQHA5(5BI7zJX6&R*6%FWvOa$`=;wxYC4Skm+x~l5de3>`wVmbnn$=r{ zIoiv%ns`09@MyYIN5MMd2EC^@TT6-=8?>&uo!rSWE&c4ptJAzTh1}U`ux?6$z;&~P z7o3m0j`5T~5U(;@9C@xsL3|DG3!`(APkM@0A7m@;+{&PKzIS?6V~6{$F5`BIU!BTDEsZY54Yg2hG;Soi8=nb}vf#srv05 z8|J-^iPdMYyUcxW-Sbng3T19zco6YorQhq5o$Kyw(y6|GEZO5(Yvv)@4I(P09KU!b zCzN;>?fzhSdK34qzE%G>Xk6d9w9TV)KFjq=z3NYv%r@T*-W8SjzOUiGuDI69ur}E# zdr`&dV|!2D6cn<_dphU&jTiZj*DiC}rC-{png{_ph^HAkw z$_{D$gPb4UG-)3%xEZ_Q@a)AZpE>4>6`VeD=wz%-+pXE!9emea|E-inme ztFO04Iv(cSa^5fE@KGP}$D-#%Skq>e^#e$+|F)Oncv4)woQL-9rvg}ErtUYnyJ{ZJNC_<27jrJ% zK)^LVM)_i!gA5<{mEI*Dmk-@CX}ZH(rr7-N{Riijhqvsys5dz@&s3D_?%Q7e825Ez z?VNcx3kz3ev_&s>4Bq#iD}Lws!?xGI+x?GYd$%Vn>y+&2W!Ks4SFVrkoGo}qMPt>4 z&yV&NzP#Nnt zQO_TlS3ZkSD|8FL=wE0Z`s;LQ_3ZG9l10o~ht6pmuGIhX(9k|dIzr3za&6bwOIgP& zS*-=MX1p#i583Jz6QD5vR+-JI&lcf{&YQXfd)&KO?@YXY$ZO-R+Fv*9ZQl2XU3|*Y zt@U8%yZ2&mnj5q$3ivnP`TO~A1MeZ9wo*>DOIo7Wz8*WtzPB>=dUR&?;Z4@nXGLRm zWUlbZzW;x8m)>5xUDLj=Zi~FRmRWk;lC6(xmpCw(AMY1^*XVv=eNp?_>nsJ5;SvVP zYHPaJoL1a(TJ&@#@9hnh$DSp;+AYrUD(S!Khbq}vf0NJuuHVvYvrbSvVD)Gf*LTS> z!SId$vf30%olh>mnHqC>{WZs!#@XNfPB6wCpK+j|a(7U#=VzI4Ym<)$3vRz((VLXM zV-{yp<@f0_2{P8lRi_mz=3B4+_Iv5-oe7ewPB?wm(-nLE|KHu(HSe0H_84l~-l<~R z^?tuySgGTwxTu5w|NJ{vzg9+nuVSuGxlMiD{f|>W^Gx;HFLR~pdF}V_d2cIDwjQjj z+spA+k!{C8Lvr*!hQ*6)A&IQ8uJ|6jKL<>kEax#t(`Ub5(+ za{ZqDX|H8>-qr8@x5#UQ+m6%vF8SBjGA^6AH_iGvS6$7X^}pt4J)T-@IrH7FU456& zd*Aik*=NH3+Uk$b%H0Q>&mRnU7O^f{Fw>Qb=l)Z+$0vPlc4jJ_JmD(rE2h+TXA4Vm zh2)9`38Ao*AVVis&6J$QC377X88-1uNqm)lLA zx2^L-rJ@Ck%Cr@O&nWfiq&{!_CCT_=_Zdgshef;2x2e~{al zM)Q7O%@@9U13H$baw^c8^ zJ)`-iq}cDW>-ne|R?C;nF5UIQ^0d0Y!|ms~|KolwjB)Ev)%?_x?EH20>D0jf6wT8* zCzVeGby=O4NP0QHS9>l`q8D4Tcev$V9m&Uz4<7m~oWQDGDG)L7cWNi=?e^YOKcmf2 zH|M4{HoZ(dzVfFA_q7Z$t10Ue`?YSIwzS!?>HfQt!=IQZt*+|a>FsvT-Kg$#UtoW# z%FJG8u}^A?)92mx%abcAoOriMZhh&LEU7rn=X{CXevyUK*La%z(yi`f&v93` zGx%HjUZc6Rr22Z!jr-r~X6BrD{_nid&4?A2x8moWZr|9H_Ve@ltvq{5vZ9UGp6Fk{ z@|oI^qqTjcfN8I&qrj=UA*{1A1e)ps9G#gL#Z|g;uJ-K|l#{PG1wtrPs z)V6z@Yebjtv}wNY_Gh)m8Ka6e8+GOb58~xsOz63!QvT+_i^oErR?eAN+i%^vaeiXO zcfAjiPNka&mI%>FM$D@osKzPEJlbIyxpMCjbBcXJBAB z#MnB6fq`j(r;B4q#jUqDGAA!q5MWFAK12Dqnv|)cl#A5A|M@Xj&iL^?&3LhD?yaSt z6hA**X`b7BHf2^(YW?(k7t->jZk_t^TSGSClm6rO2P^x2O22*Z(e|>*f|p-jFS^?3 zWzT!jzw_(e)R@`tmwTW4G{yGwr%ku#F5CJm@SWsc%iu7P-I@EJ+rE{&Ioq|0>Gz+8 z8GUa&zvlX{+&}qM<^R&xeyd;Wubgk|{dxVX9>G^@mQ=6Gw^e>K)7PVNdy!)Jv=O+i-}O`M#ze-4hQ=GdaID{0&Y!9K zH@!l3-RZ=xZOh(&Fh9k)UF`V<#nPXR(Z7Y3^M9SjaBf?9%XyiDu{9g)zIL*#KenYk zehp8>x7r%3A; zZqH@2&9mb!yku|<`LVcE&ET<5V94WOW?*1ABffn-0|UeS0G|-o1q&90hljhn zyKmmSxu>TmARyqyix*K*QQ6tq85tSp&z~0*6iiD?n=)leaB%RB9Xo`Dg=fy386O|N zcJ11uN00LH@kvTbiiwHY+uOIaw5X`4^!4@W>+35iDapynnVXxZr>Co{s~Z{`T3K1$ zx^>IM#6(k5GbJTOT3WiYveL)LCn6$Z$&w{bPEKxaZh?V;v9Yl_Iy(9J`Tzg_XJBAh zy>?0!0|RTMr;B4q#jUru+KX;m2(Tr@ch=@@T66CPtJ#E%Bfsr$zn#=06{^wc^e&I@ zq{TNMoB8z#<&l%rb8Bq>`p=7Am}$hryS&Hwvb1%0+Ib_MsYa1@US~v&gEz+IM8-)h z`@FLvXYw9@wfFC+$A#7#O*;Pl zrA=GaivLX5am&!1i^ucf=J!VgBH!t>PV+G_ce!?v#WyCc&1cd4fLXH?9aDDQ{(63o z_JlJgn$2A)J%#6bCmd8$Sv+O7-Dw;3XC9tSdtx@XPcq&q`q3jeX7fzRAfrBwlP{G$ zZydJW=wdq4@Y{^)`5MzVn8k-F1+hp!6;!#)wkFxjg>zC&2m6HeL2?a@>{DJyF6`Nz z_x(xuzVE6R9S<=3Ii$=nTDVJnervshQ+)x`$%hh}i3{!>6g_?-CH_iiqmabJ&`D(f7%#atSB3rvpCtWOC<9+PZgn+$4%NJbK=*kMR3f!c#y1`2OycPd8 zb;DI_szRI&I0P?U5WC8j&G0bm3g>?Nns;5(PZ<8Wbot}GFG~Xzf|p*Yd7fz%S+{uC z89wfR4M%?Mbnq*&xcKDx^VyC1Pj#G%tn+1$A6>&)r?&U9qJG|+-yz5Aa$bKd@jmqI zP^#~_mLSif1ihWPmbV&%KJ|6EZq|?I-*)xbb@{qA>a`!rw(*<~4VtJDc+T~#)&8@_ ziTYxRJ2vQO$K)P*SIKL1Tm7x3+vb|w$K~?#CY@QB^O<826W7<*b?Gc}vsj+1O1E7V zdtc4_X|>>`SM3R{hFhAiXUOi6eDt75mSN?Bs#WuEmbP+pYvb=TBFilge8-zoyzwU~B99jY%rC?_=gFPSNG;{g8kB>f)%Y z>%@cV-ols^7m{?c43<CV%ZCmg=BQ1D9d%wnsp3a`9G zT`${svoW&iRA07!e{-ID?W6++I_nMgd1-73*rd~?c1vZu{ssw7iR%@vR?}o3ZQ7H*VQYv6nSn+IsdSA3jmso&5SpWY~&T_kW*Q{chPZ!!y6TO$aRB8XMBa5Oec3Gs!slGnk!mV^Ci{&S; z;rDe@*2;amba#7ZV|DPEy}NgbJ-Jr$vA3#9K5|RdlDjjQe8O2iZA{ssT3`M9q?=NU?pdV0ZvVRaeu&eV+3LT0_1z7ZB?=|aQd3-(`KfsA*ZTQ? zUW-pq{+yCFFCw#7P9F2>&{aqQFa;Yc5B?${+B3m=3&B}Vl%xyKV zX5_P-JjjstR`zRg@TtZsskO$NrMs_B$w`t>e|ir?EmNO`y*}Euy$z! Ti{4iT1_lOCS3j3^P6S~jSa0>Y9G7qpZkyX${JJrT?CwJ z&is1szC*CWXVQ`-)Bgz^U?~6KlHnxslci-ZyNuF`I)S_c>_+)B)Dt)+iQL@f7ID0A zP5v{j;^RB7eb&$tFu1zadL3_*;4)U>UvK67-fyi9)||E?PWjN0!{vXvr!uweOe(&n z%yfAH^TfRlEmL>RJU{b|p}v9IHx7-}SN}XqyXT!Xi#;lz(UD7%=}_-h*Y!6A1)eo5 zSjurIBtF-C_7h_P9cKYH9ZwCxMfog@9L3oseu?!8O@HDyJ(;A!qw+>jaZ}I)-t- zww=@&uPtp)eH;`4zC6Lf}HLx?p%FM z-0zFss~v*V#4pUroTa8_vcxC#7AMoh9mWct2VWbrBrNP;P+BT*K*9PGYaYiAJ)sRf z4bC-7It4m?wncOH`w8s0TE9+o+R9padCfKZrfza>N%+4t?XLjKr<8-XK|V9j*m#I@ z+I4q1+h)})J9X`z=xWIYEJ!6aA(HXyA=$LA@_Vr)a zV{YBZ!BeU3d1>v0p3*t8YdHl}d8V9Y|E)T;w6#xgidU}MkDGQy`?g!XW?s0ea#`y# zATqRFjWTkp#}-)+1$w!Zve+S^ypU-@wh zge|_9VRd(r(!2fEyXS6R+jyh#z(UnSQMD11KZUbT4dDybyz6I@4(8f43&j~AYa za_2h1aZ9P7{LP`uZ1NBIyVGXZue57hg;*R@Gd^`*tRv`{*?QIELIrLUMC|zuB z=&;7za8BPx`EF*8&4DRAmtU^aSS9t)fqSdr*A10rg|+-&42pOUB`uyGTVDD=SYqbN zyB5oW-*Y6E`vkbH=zn#+mpgoaVPfvyrpG@d1#K43{^Y9C<1ouaP^db!ZSK8Lg(*B2 zr-Yk%Y`mDk7SI&d(0H#vM0|>-l2T^Ti_eNplXs?eE@=61qobki!n%(hC7v!7D^Brk zm~G@1BI+b2$*zA}>4-<;LJKz4H4iP#`Xs}{zWW3zdETYmd)LO-&FGdzbcjS1*TJ%Jtl>7xLmZ$vHb@ z$(SAc$dntXt-ZA_cFmrni5zlk>cyJ=9+2|ccexI^DXObz`bQIPaiRr zG$c=DxwTD!LqqP&L~}k75e>z->ctoDD%suGuu3q3w@LTJ!op2F&vq|d85Aja+~0EJ z^SgI_j~7apuQ6*dz3!@=F3yS6V7vF%;3 zx~xmd#h7VLPrZO#b%mMmL@Uhk=sUVcVU?tjDu>eLh7(4NnZ`-h$+NAT zDk?WBPTatNeNt-|>@aPza^~E%;P0$kA0-~nc4hESQB3$C!?^ciimL1RfTnc| zEE@~n)-(M0*5*m$&1(Xt7V12Pk`{hl94&$8RDx%%Tyr@5+X8>yeQRI8 zRDSyY|J5FY9yY!oi-R82PHE*@zUJo~#+Kl9eyuJGYc(~OyzO{=dj7@uD1oCZ9x+DQ z>GSh2p8F?i`&_TE^x~C{2mb%&WSn4SbiE&)wT{c{KvLuU@70ap6@D1YuZuZ&$xCOnqWyZ1H;lbghvmab;POW^A@_Jga;5nJ{zY=_Eb@w#%*q^TI`TYHF zMshjdp|?jap7#9q==Fow2VcBhTo-huMZmJ)$Ju%M?ahgwKdk3&iC+HU(b@C9lcbli zxAY_=>3lT$@^|4ouUYDOlQoRIE(rgBJ6WLZ;(6o0o*eOuc3Fn#3nqR_?%QC&;qkRG z@TSm14c)!U=JUD@Di7b+U^wJ0$`rnK){O40A4Gm`?yS2qSxdKN4}VMKliwW%Hv0^j zu5!OWDz0W+FJ`-sXLa7W6?Fm%ia#$dHeM~Y@!M4KMKk69etQvqF5nlJ7YFBZzQ*s( z44n_JXR%zq+N$`s;ebWwhoI&Kx#_vP|Kvritf9&}dw#|_3l&v zm+Kf97;bvHIEGZ*dV9r@tJy$+^@4tr9@kfndrRV0USOWF_^F1a(*o&*LeghljICOf z?ryzl+cfixztXalh(D!aVyQ}-g~M#sS-%AS;#<&t$R=u1vXr=~k7{NF%R0LgP18KD zvdml%HHmHNk3~F_Q@^^Y9shRnYm%(xO8a}ir-bRdtTgd&4^b9wjrQ0yNujf8LG7tm zEP->TxP+XT{NQx;PX8nOAFt{!nz?gsh?|x2D>XYzM{ y4%ONv?C>k^>K~zSNi%bsxS8eZo@xGp6AU;0h&l^O{$Q|E z_9kh@#&wFDJg`Qbbrsgerwu3j+@IM6L9`#;m?j5zUrhp>rbD5 zTrK>^^F8tZq4$5ksXhL=`uCTa_VdrKEK|F){<3Pq)l}Pc@9%402%GrZ;#2#JXJ`It f1VsGk|H#^;WxIHe_E$Lu1_lOCS3j3^P6}SO4}bi7x=@W z#If>=)oBy6rU?zxngr!NzifK^?w+#o|CWr0B8s1rg^RtVKttk$0{?Mc6?AY3@&T`g1@=d`7rw@A7Ik)o; z{`0u7)i&m_!o^1smu71;ZjE?Q75)3m**NT(d=pam6Cn zmIvGiOI0?rm~If5T3v9s)RzU{V~@^U0J(V8zPcs n_FTVtXsh2kxyAoH>lpqV+CTZq=H2ZK3=9mOu6{1-oD!M<`pE|C literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRM0.png b/wadsrc_bm/static/brightmaps/doom/CYBRM0.png new file mode 100644 index 0000000000000000000000000000000000000000..ffe528adb4c4f82d597fd197d1978679d9ba8675 GIT binary patch literal 1236 zcmeAS@N?(olHy`uVBq!ia0y~yVCZ0AU}$D!W?*2**?jO40|NtFfKP}k0|UeV|NocX zoPU>rfu+;a#WAGf*4e4&^QA)tjvtTPJ=iAe;c9&p0H@znm8)0*~uUzw7042 z17o0tf~ppKOV%d6kR?G*LRY*61Um)XTW$qw72Ys)+`@V#?9l~}ma4_8vNT-FX05n) zWViL1J>Sdrw$(S3Z@4c1es<;O$JYD~dY7BGEnTa;EBA=R{X-jipPcc2vE1A9%d*BB zc^NmIcudtD`EGaYnDrr@O={80-mP<#_01Et^gGr|KdqRo5Fy#$smgh;bIwwcjCZ?N zp4i;gGCgl~uEbjI@7$-huRY$<=EY0vPq-lM(L z{GaQk!-WD7hkcc1KK^W&+3{fW{p2Q=H+Qy0yNjj1^|RQYXlNL<iQqJ$=zM#|MJ3(NpV!$!#C|h{A3Z$E-t?X0->LIPA@v9`!6%HW0mLD z3L}9;9m}A!>75fCZ-sNJMzXy)8$NT#;zPUrU80{HPOw$i>9$!vVPfQM=j%Z%PTbn* zC#xb|YPc3$&`3&rE0G#CLFNGW`^h(-uUXOAQBs%jIOAMT)O+5B>n|#G@>hS$SvP@$ zEpyF+rzf1&8CP}+b%chW zyY4Tm5BDs&v|W0a`p-l=wd#iq^4}hN?CD*p_u}s?t;a{YW}P~;?!2aOYe&p)=7jH- zT2B_9C^FPI+^4U(=klpfw%qE9-svktL_T&sl&ola=5T-2tt~zOm{M|AJ-*#_=El9s zd8VarSI&}}Fs)kf+{C8M^H*B_vfkyq;kc8!^?Hwnb?i@S)M9(nZ$GX6!20NBh_-b2 zzE(b^sO~#jAFmo%U-kM@u4>^?y?)z?%g!HoTK^>(s(pTcNbkt+Q=gdC)GfJ0?*6;> zDEF6)1=C-(Q~&I5I9DJ3cl^N#gNe^Obqx4_?{9RU!L#|oPbaSXJGral!^=)7ZN4gZ zpkQ5nR(TmyK5Fbo1xCLo%z8FrSiL0U%hv} zes&~wmYMa@&<#HGpU#`}&3IyD;3FZ`rEA)cg{wS`k9@9p{NW3`XBnIJ9v8k9zd(^q z^SpgXnE6+;#Gw10>ih1${`AnLWOjPRqAhDhtUlOB{%2UM-MHbN=;3e%1_lOCS3j3^ HP6SURaSW-rwRM_*k8r8T@%!t8tyHJTateyyys)UmFxvlNm~t*%`^5hI>Dgv4bW0^Ga~q$ok=!>e z)=gHwci#q+ob^YF5|%S=zj9b2-p$@gf<>cJcXyARgOn3P*2*m{b$-rVF9eT16PmSM zQscG=C~Z?a4WqVF=xf^n^g@}%OqSg^^&w59tSH<=>PTc zboWM?_ZO79B<8ui`&^#<@I4af?#h+?I5ot(q6# zgvJGwFWMkFCE=*nVwdgmeCrn^I%)3CdllvMX4;8)&w0GoO_DA?;^x-s9nI)7tI%ui z4)vm*9{DQ0mLI8VF12z@CY!{Q7A)=$6n|Lmw68wV_)A0F$B)Zi&o-*wB65RWy}joq zfBz4Ki=y79wFP^W^9s`hYxC9_-WTUnzY)bS^OejRTTyPw%OMO^jyoUOXuK~|FDYgy z>}USS&{=ayip@=~#87Fg=_K=-l}i*aOgiv3{LSK7=Y=xk*>(9}{B_X~bnjmh<^E!6 zXZX3pv!*z4s9HI$s1-f5vbnLuU-^shuc=+f1#VpMMrp}vlUD%^ zmv-`h6E>1?Y&aKk?5oO_3DI-=*k7EhYz~%H|B~gmsBQnr6PL|Ww$yRHU9!w_t+a~j zTD`#EM=o0}&Ogi`k~N|Hva|1eruAmR6Mwx{E!k>+I&|$h;h{TQvP+F=E1k9Nq94DA+xJDZf7L!arVXo)EjHj^Eb6s&>t~(=aqC2bWZfoi{(oqZ zO3lpa73(7;+1J#IOs*`9dbH()FXKOB$;W#vrpU7{b$Gb^BSUCtUzNiOzl?3Ryc_(K z^rcQr_ewl;i=ouHW9sFDc0siXDz#gbGmiEZD+tyFMqN0}wj#vt$Qia^Nv^E=DFUZc zydtF6v%5`gnBY?R@%XbM*I#K)8rwBPeY%#FCOIj22ksR5dcEcKO4XN+3o=^%Bno?& z6w91hK7DS{f!7WBUa)q7d+z#x zRdSy4tA$@2_1wAOm66y|lh~#9TMShW&2Ex1)7IWG^=#k7qMq3nE!ARGPLA^D-IjAo z&gibbTU+G1M`HDBskivb2_-ro&nWiyw{>J$R#v>8%oSdepWnPJ_x*ak3r9|;iv6v7 zxWwU(^}i*@uNBU?aEPx_ZL8JZYpJgCDqmif9nEOikQhDt)zz6he3$L?-RX8qmGMHC z-n12QVO~dD^U^VYuIv@6)D?fSKk_tKiSpDF$1bM;%GJah974*!pCVjtPcZ$CKp?`&D?iWjbx zS_ZQicDg&i>bSEgrs`{q`?nzL-6euEJL6|RJTG|HJ(DY>qt?0T(RCHYX>;a0IB~I@ z%hz(^KmS|Pj{T~2l)JR&d!l=R_%FX{$_3jG>@P@q`ign(uUE50gTe~DWM4fT9xbf literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRO0.png b/wadsrc_bm/static/brightmaps/doom/CYBRO0.png new file mode 100644 index 0000000000000000000000000000000000000000..8b52093c38f59c37099e2a8fe080455b6ca65991 GIT binary patch literal 1167 zcmeAS@N?(olHy`uVBq!ia0y~yVCZIGU}$4xW?*2r?)f^2fq{W7z$e7@|Ns9C3=E-% zF4r+Iu()`-IEGZ*nmf%fN7+@RE#2^t-lET?(=WG5xbS*4x(GZ}n`^ybxk6Cal#`um zLX9^CmT<%-DoRZV*tTGy!=sEHP0G8c`9E*E9Ld2sL8Gj=Z;!9a?N6G!t9M)Xn{T!@ z&W>kP3VL&O`S*MK{{A=5_g(NudPR4`6mfCIc$Y}-L#`q1k)oY*luxYIn4YmtES=%` z(dkYze`K7!ADCiQ`+--gtG|Fl@^Xfj-LKoFc^CXDbQhOfCa!b(v%o)jTFR28*&nxl zWBC!9WzKsmtD5Ipe&yGY>$m3IjHqyXwbSWkenKO&gU=)P&6lIDAIx_1KC*E8b{~l& z(#{`cT-V+{Xl0qOp(;)8#9V<-6PzlZsc`jP>)_3I2i)btn6q6U<`sjPy#Gs{8ttX$% z-C>eE$$JZP`3-X+gBb>mM#t6{X)^5)5Z8EqeeZEnvz8Qz6t3JxrTD(qu;pz)z6DuA+-=|mqZMV+- zrarEwm%5!V)=i$)<6AG1@rmK#0jZmCb<_nEOnS^oWT*>XO|AK{m-T;1`) zuHWvuvHk_I#v|{0>{eWHno^c$U-0bo;g9@p~CFXK|#J;zmx_D5gz{Zi>4B`w|Dr}~I7H!I!x z`>$^6kc>}dKuAFI+(V@0XOm?Z1t-i{g%?+~|qaF8FG)&73{prTNxT(tZ0C%Tc z_{C$dU9a3&P}-y+WqNSKn#PQ8PuON`thp3%S1Geh*T{B`zH(EKk?=IxJ9m_RhOZBm zd2D!e#rpm01=OY=dT1M<&%$9h?L^(ym`h0_iyUMmev7o~UVLaE@Tg)-MJ31j{I`?Y9nCQL)5uy?m#wU}s;KY6T6SGz3u z7IVY&S!4)p)a!QZ?8bmL06xZ_gN!(QP;ce{- z6+gv@+wJX4GhI`KxBvQe^s}LA#&wOWFN8wXOzrC$f=?_evUX0moVKTBg^hM!g7(^% zpCZ(^eQ2oAE=ecxAr-fhBU*XaBuM-^l;^#vZF0F=t2-EW3bQe+_TDnjW?}YD1_lNO MPgg&ebxsLQ00)L3!TS46g*uVLn>}1N3=5QBuM-+^4`=oz1}Sq0^26?FeLv{{{Bwpn-&8D1B0il KpUXO@geCyGTpy1B literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/FATTH1.png b/wadsrc_bm/static/brightmaps/doom/FATTH1.png new file mode 100644 index 0000000000000000000000000000000000000000..e22d536f99d389c86d374e8fa12bce2a943a2d8c GIT binary patch literal 266 zcmeAS@N?(olHy`uVBq!ia0y~yUnDxVgFg|NozX zfkF9-E=bW%PZ!6Kid%0l?d5AS5McjMZ9I>OUHqF}GiU!HrGx*RA92t4!QsRAiNi<7 zYQnUlD^Ihu4Bdp;tzxS7e|cP`x$}gFVdQ&MBb@07wgQiU0rr literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/FATTH2H8.png b/wadsrc_bm/static/brightmaps/doom/FATTH2H8.png new file mode 100644 index 0000000000000000000000000000000000000000..c6a763f1ab382998f52a4b1c61542e26d054349c GIT binary patch literal 184 zcmeAS@N?(olHy`uVBq!ia0y~yU`S literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/FATTH4H6.png b/wadsrc_bm/static/brightmaps/doom/FATTH4H6.png new file mode 100644 index 0000000000000000000000000000000000000000..82fb052a1ab8bfa38d07673e2a77cfcd2b1047d8 GIT binary patch literal 140 zcmeAS@N?(olHy`uVBq!ia0y~yVDM&OU~pn$W?*1Q(m%YBfq{WDz$e7j&CTuq|NjgO z3}Wd;R~Z->>^xl@Ln>}1N3=4A8T54Zc1=_<3*~msNflVOYiZn!q~Og4N1e8A=vcdG t-Hj04M|Yaep4Hyiv38cpEWWml5)6&Itj_)ts{$Fw;OXk;vd$@?2>=yYFr@$h literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/FATTH5.png b/wadsrc_bm/static/brightmaps/doom/FATTH5.png new file mode 100644 index 0000000000000000000000000000000000000000..00ab9b9844652343245bd054efaafb647b24ad3e GIT binary patch literal 114 zcmeAS@N?(olHy`uVBq!ia0y~yUU|?YIboFyt=akR{0B?FDCIA2c literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/FCANA0.png b/wadsrc_bm/static/brightmaps/doom/FCANA0.png new file mode 100644 index 0000000000000000000000000000000000000000..3cb6b9d5b7c9c9f5d4230862aeaa2277f592636f GIT binary patch literal 350 zcmeAS@N?(olHy`uVBq!ia0y~yU{GaXU@&E2W?*12NwZ(gz`($g?&#~tz_78O`%fY( z0|SF}fKQ0);>C+QIywpq3lkF)0|ElHw6v6zl>Yz!&%nTtk^c^)?VYEKV@SoVrI!r( znhkhZ1J*h89}sr>|Wtx6T| z&*%wfq)RL_Y56dXEljeG*Em`}Olrxk6z{8x7?SocWnf@jbAx|dVr8z%1Gxjr@7Qkz zNM&`~Zd$rJ(QW3KTy*Bf5dZkDf1 zy+zFFuBx5u`PaU_V#vd>$))Pozkfd&FD-Xb%HWu!IFZNETVSPXD`yka52HgITncV$ zS{U^vFF3g9mWgOWV(+8{s_Szv@B}_=@!FJnFSg^hhQ^|ZFki=Oa1V&dS_=w)_e6mo9NX7gUn^ezmMJ iTwqda^}3Gr>hZE|q8e*!!x$JC7(8A5T-G@yGywo3L558L literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/FCANC0.png b/wadsrc_bm/static/brightmaps/doom/FCANC0.png new file mode 100644 index 0000000000000000000000000000000000000000..7b430607c4a18acf1b620af78cd0468b8b6102df GIT binary patch literal 315 zcmeAS@N?(olHy`uVBq!ia0y~yU{GOTU@&H328sOL-oe1YAQ9jb;@Z*CQCeD>nVA_A z6QiW0q@|_x|Nnmm1_rK8QM(x!818wxIEGZ*ntQ>KuUSEWHK6apu9v&Mvh8}onz5sy zMVhCY_1UjhCg!GGAI{E)KM(fv+-6)edD;O+F{a+SSmB2G0&xbD47SYIo7ij005iXld*IC?{uC zmZe_$hm%8y`KMwGx{<&e#!OX=VE-7;N*HnRC1_lNOPgg&ebxsLQ09=+!_5c6? literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/HEADC2C8.png b/wadsrc_bm/static/brightmaps/doom/HEADC2C8.png new file mode 100644 index 0000000000000000000000000000000000000000..d4fe4df87eecca5dee902b1a0b8cf60556e43fcb GIT binary patch literal 157 zcmeAS@N?(olHy`uVBq!ia0y~yV6b6eU~pw*W?*2@kr%gMU|?Vi@Ck8sc6Mf9VAvHY z;?BUp5aj9N7*cU7`3FCvyo8&iN%|gk!+!@Q>Kl7LCmehK|M~l7$@%qr*p2_q{~us4 zf9A&j19FEpq$jXz|NGzHD0%3|d4+#+hcY&_M}1^C_9M<-f|-$_#6@I-pNVY=0|Ntt Mr>mdKI;Vst0I!}kng9R* literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/HEADC3C7.png b/wadsrc_bm/static/brightmaps/doom/HEADC3C7.png new file mode 100644 index 0000000000000000000000000000000000000000..4dd996ca3f5d6eedb82cebce98758006bc806063 GIT binary patch literal 127 zcmeAS@N?(olHy`uVBq!ia0y~yV6bCgU~pw*W?*2@cy*kWfq{W7z$e7j+1Z(afnisq zh&uxVgNdh$V@SoVLtC g)gS6{l(%D;C9Ifj_<+HPfq{X+)78&qol`;+0CzzoUH||9 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/HEADD1.png b/wadsrc_bm/static/brightmaps/doom/HEADD1.png new file mode 100644 index 0000000000000000000000000000000000000000..43c2b98208bbc79388c8f174ce248a9c2f1feccc GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0y~yV6bOkU~p$-W?*3GdcbSIz`(#3;1lASoSe+Sz;K6c zqBjErLyxD6V@SoV_-1?{`r5MCFu`~QHx{Gf3s`% zZy)T+=2~*Fr{0u*NB?4@I=O`U{zE@LZ*2Uj+wt+cCG+FR4d1GHc$Oc`N|BJ5bWll* zhv#L&F*&xjB7?{LJstI<5;6Yt$qWs)D<=Sw@2 zm|)IsEN5Wwx>=H4LgM$q9)6yl&xt+16OPHV9s3{9#&Sin`pv=~`vSMW2iUn8CT$c; VmeD<~&A`CG;OXk;vd$@?2>_ksH+ld7 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/HEADD3D7.png b/wadsrc_bm/static/brightmaps/doom/HEADD3D7.png new file mode 100644 index 0000000000000000000000000000000000000000..12862b89e1e0ce584b58d9cc911347662e5d4729 GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0y~yV6bCgVDM&QW?*0lb-1&Xfq{W1z$e7j+1a_izCJlQ znSp_!P+}TL+|Sd+F{I+w+e?Og4F){U7w^qr4qNnHbLyp;UNbEDR;h2RsQL7R`%jvu z$BlzojH_6<6L{_(WZpfy;Z#9Yg!~2Oh6h0j><1a_RU91LzT5B7Jv{$*RF>Z&1_lNO MPgg&ebxsLQ0Fj0^MgRZ+ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/PAINF1.png b/wadsrc_bm/static/brightmaps/doom/PAINF1.png new file mode 100644 index 0000000000000000000000000000000000000000..26e4486c872f337b01f306935861c4bc6f393139 GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0y~yVDM#NV6b6gW?*25lf3WFz`(#6;1l91FV3BuoXo($ z@RvzJhk=1%wx^3@NX4zUmmT?96nIzz^nZH3suQ~$T*2A5K+@u=fomprPFl9gu_fn& zE(uMyS(jV+A@0Y|^xsy_a};^hu3VAL5xn~9c$cb^#_XrHi8_iE-#fO6)N6Kpa+qkc zH8E)NV|E_7%xO0h=Uo-ysqo}pr>rFPam~%I_q=9lW;$E>8~4kFSG$J?ZkzF8+RLBS o{Yx1iJ@}|0>h$dPKaTjM4`z-HtHJCf=`cJ+677ThdZdM$O+cq&UFfe$! L`njxgN@xNAfEH82 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/PAINF3F7.png b/wadsrc_bm/static/brightmaps/doom/PAINF3F7.png new file mode 100644 index 0000000000000000000000000000000000000000..044b88aa9e05908ee01da7d3853f0cc2e079cff0 GIT binary patch literal 161 zcmeAS@N?(olHy`uVBq!ia0y~yU~pn!U~ph$W?*2L5@fu9fq{W7z$e5tIXRhuf#D9@ zL~jNLhA>YT$B>F!$v^m6*(KcAUNc+wd~IhuxT<~gn?xNu3va%2o7y+OdRX=Lp-!ca zj$6*Qo5_h+lQ&sB)bZT0>($?YYy0mTT>JmNAl|O+<&XdUHwu25Z}`Z_z&oY literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/PLAYF1.png b/wadsrc_bm/static/brightmaps/doom/PLAYF1.png new file mode 100644 index 0000000000000000000000000000000000000000..f3f83fe8e0bd814c478404c398d059d419feb4c3 GIT binary patch literal 330 zcmeAS@N?(olHy`uVBq!ia0y~yV31;9V6fm|W?*2r@3us*x1-uSXkKK-@k3!wpp`grKP1UU%q_y?AibS|8Hn$U|?X7 zD0ynlz`$_E)5S5Q;?~-=_~ zu61&7S#CBrw{+2joznw8&AWfYInhV+=4wgPzQ@;E*4$J6#db5XJy9e6kB8E?4{<8b zYqrk}2)tl*bmyU^VqFUgZu+>aPhng&ab8B4_nM7;yKc-{`bMQe{ZY+~PpuQK?Jjdw zi$2D1C9r!9Ux@oMY1xI-rgAYXdA5|{#rCwv{<2AJ7t|(R=sqM+eq|Hme7CRZ)fz&N ppJ_}Kxt((NML&zdzWEiKK~);2RUGchr-zrTO^^5u<3w<48992@LT$lE|DVr@?wW(&} z>y0r_s*Xw7YHgA+c2U1B@c-3=aQ?@Zb#6h~wT}{Q&l}bqi+$bvefG7bzbn?4tmXdR zwy&0F{}$8L%cKvt)w>Ec)q7u5YdY|^Y}GWK_RGeR1$u&!7uz^q+aVZO-CetG X>w=>nerIcdf|SA2)z4*}Q$iB}F~Fi5 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/PLAYF3F7.png b/wadsrc_bm/static/brightmaps/doom/PLAYF3F7.png new file mode 100644 index 0000000000000000000000000000000000000000..8e1616cf6ba2f751fbd656ea2e7f896e5c1f23f4 GIT binary patch literal 355 zcmeAS@N?(olHy`uVBq!ia0y~yU@&1|U@+xiW?*2j{AE$Yz`)=X;1lB7*x19UdfUGLtGyN}vCMdFDD<8G z#PMUAxrYyA)ivrgiOhfM@!7S<* zZz(wbWp<5svV6Yvp@i4|z;pUf)4p^6?$LPeIrIBz=Ot>nS_aF3Grn`R9S< zYhAimw`$4oa~{fMW@#*Wmv~~`JRWDkqlK2cv$tI^&i>AS_!HmPTla4EuiH|^z`(%Z M>FVdQ&MBb@0ND|hIRF3v literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/PLAYF4F6.png b/wadsrc_bm/static/brightmaps/doom/PLAYF4F6.png new file mode 100644 index 0000000000000000000000000000000000000000..9def391d76ad309fd6bdced89a46284a968f1e79 GIT binary patch literal 286 zcmeAS@N?(olHy`uVBq!ia0y~yV9;b>U@&1}W?*1=%Er^cz`$S-;1l8+6BDy-+qSBz zDi05j#Kgo|vt|Vb1~xV}&YnFxGcz+hJiM^5u%V$LEiLW;|NjgO42)La7BDa{tn_qo z45_%a_0nn1W(R?WL~9RE&4WTZjsouw?zUB#FkAd!b{0q2h8qWkI)s#8X;`j!px@X2 zCi7=RTA5tmflABETb;goXkW~3kXjVyb!js9Ew|Skr7l~Kh7`_yZF+2;!ha1_lNOPgg&ebxsLQ02i}&;{X5v literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/PLAYF5.png b/wadsrc_bm/static/brightmaps/doom/PLAYF5.png new file mode 100644 index 0000000000000000000000000000000000000000..520a9abfa2f0e791d024d6c491ab7b02d6847279 GIT binary patch literal 275 zcmeAS@N?(olHy`uVBq!ia0y~yV31&7U@&H3W?*2bH@a%az`$S-;1lB7*x1iEiKK%!-Ii=q5QcX69WUoJWm(L zkcwM#&tK$iG7w;UaQlGy^+Fc+0ulEIlG9%>*jO+rm$az4@hE+|y?Bdl(s=>Th2Nj* zzn%JEe)#1NERW8Y$}!HZe=n%6*T?vHPo28qG2VR*Os@hYj|C-vsF=0mM1$T-er_*D zK84vAn(n3AIMhy+7UGPOGWxb@`|Kl24*lITr{OR2RIa~s>ZZ;)sC;;;d4W;k>y%qe gd(D?8U9Poz=O1cxX*Jt61_lNOPgg&ebxsLQ07T|(^Z)<= literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/POSSE1.png b/wadsrc_bm/static/brightmaps/doom/POSSE1.png new file mode 100644 index 0000000000000000000000000000000000000000..5983ef59d87d9b11f166aec595d2856a82e3ebb5 GIT binary patch literal 97 zcmeAS@N?(olHy`uVBq!ia0y~yV31;9U@&K7W?*2@*mfe7fq{W7z$e7DqN0LF!$ve7v z^b7*d*mAc#c{SDbsoH{~^(zx!=sG@K_sR9yy%zz!N0Z;Li8A=kr}drZ$k+1q%{$A_ z&1sCV6<+iGjO2_ju_`xbuU??mteXG+9{1BGpL^bW8)T2%xf^2qs%_;_fsb|!2Ss|4 VW}UBQVPIfj@O1TaS?83{1OSB{PMH7z literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/POSSF2F8.png b/wadsrc_bm/static/brightmaps/doom/POSSF2F8.png new file mode 100644 index 0000000000000000000000000000000000000000..0ecd256bca209001f7cc0bbbf2165907aa0202ae GIT binary patch literal 232 zcmeAS@N?(olHy`uVBq!ia0y~yV9;e?U@&80W?*1gsLK11fq_9Qz$e7j+1XiJTiepo z(#FQd(9lp-RaH?@QA0yRS65d?M#j|C)WN~w|Ns9C3=C6Wn8`3OFjRWFIEGZ*O5V{e z8k4YK^AB0AnZ*~UseIk;VOr1F`Dp8snf0mqvno_tKDl+wx8zRpY5ib+`0UQ&XJ_tq z-wJq_8@uDjOk)S$&EFPPiL2Sw>b6xoJiGH^4)>#y#XE#k@+D?$=HC5#{Z`(DUy|z{ nowYdPUC^<-zfIcp5yK=^}1N3;qX@GQ7;>fpnk zgSuN!aJPqCT_sWyYnrAWWm>EjaN9{+p_nslWoo3uv#!t^ zJTX$NDSEN3XC+Usc3WJ;;k9E~}sk^5|_I{Ya&fsm-=eJVhqdx-!1B0ilpUXO@ GgeCy=bVXVK literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/POSSF4F6.png b/wadsrc_bm/static/brightmaps/doom/POSSF4F6.png new file mode 100644 index 0000000000000000000000000000000000000000..bc5fb14f9797c84774009766a10c22460311683e GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0y~yV9;V268WMmW?8tUok>Ehz@|Nnmm28LCyML=4eJY5_^DsCmu=;Sr%3ApI>$W=XAbnc=~ z-x8~^+sl$V&b@ds!;;Z?3$un5@9GyNYt(!sdwsJyy^=)FF1c~%ilF>HhJLp$`_PKN Smlzlr7(8A5T-G@yGywobr!`Oj literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/POSSF5.png b/wadsrc_bm/static/brightmaps/doom/POSSF5.png new file mode 100644 index 0000000000000000000000000000000000000000..5ca4b31699f59325ef2ba799a1ae13a8db59cfe1 GIT binary patch literal 127 zcmeAS@N?(olHy`uVBq!ia0y~yV31&7U@&H3W?*2bH@a%az`!6B;1l9nSXkKD*qE4@ z7!VK;9v;rXz#zJ-Wj_N0gNCPzV@SoVWDZv*o|5MsO2thREE$)bs46H9=qXd}6EFVdQ&MBb@0KZu!$p8QV literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SKELJ1.png b/wadsrc_bm/static/brightmaps/doom/SKELJ1.png new file mode 100644 index 0000000000000000000000000000000000000000..82db405af4405bce66e6c4ccdeab868ed0bc040e GIT binary patch literal 153 zcmeAS@N?(olHy`uVBq!ia0y~yU@&B0U~p$-W?*2LqG{XAz`(#3;1lBd|Nnmm28Pf> zm+Kf982mh4978H@CI8@OV!Z literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SKELJ6.png b/wadsrc_bm/static/brightmaps/doom/SKELJ6.png new file mode 100644 index 0000000000000000000000000000000000000000..a16d9853b84a6ee1d54eccccfb378d9f86069e55 GIT binary patch literal 122 zcmeAS@N?(olHy`uVBq!ia0y~yU@&H2U~pz+W?*38_Fcb%fq{W7z$e7@|Ns9C3=E-% zF4r+IFz9=_IEGZ*O8&vm#xJqq()@*AoHc40yzD(1F35{4Fk#mE@4&R`S9`{@zw%4j cEqNLAM2{uT(<}93U|?YIboFyt=akR{0HY=(hX4Qo literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SKELJ7.png b/wadsrc_bm/static/brightmaps/doom/SKELJ7.png new file mode 100644 index 0000000000000000000000000000000000000000..9e8e4912d0c0ce5973b9b577f24d5944cfec792b GIT binary patch literal 117 zcmeAS@N?(olHy`uVBq!ia0y~yU@%}{U~pz+W?*1=P$jaOfq{W7z$e7@|Ns9C3=E-% zF4r+IFlc$YIEGZ*O8&vm#?!K*{*yqLtdpVB6Nw3$D-?Vzopr0ETZgb^rhX literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SMRTA0.png b/wadsrc_bm/static/brightmaps/doom/SMRTA0.png new file mode 100644 index 0000000000000000000000000000000000000000..49867963e05a5e642e05b16f38426e985401968d GIT binary patch literal 240 zcmeAS@N?(olHy`uVBq!ia0y~yU=U*KR@5g%PTZAG(0@q&(BX=TieRY%GA`<(b3V+(2#+F;s5{tvsa#tV_;yY_H=O! zskoK=gP&Di!Y$Hy^4E8N>$m^^e}8ZFfe-KQR)_vC7r3_D#Z+Roy67>htIWxB*EMz@ zjLcs3V2$1mojF^->&)3Ib!-=}cyzVYxu)*Bt=)I+Sd-7jawp%t!x_F^T(7&e^t+y% tZ2r4EdnnvC&tdJzAScviQ)dbEUVSO!{;!7Jml)^HjTZ8}r literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SMRTB0.png b/wadsrc_bm/static/brightmaps/doom/SMRTB0.png new file mode 100644 index 0000000000000000000000000000000000000000..e6291b8f5ae028f873b8c6d854660b93d3502771 GIT binary patch literal 248 zcmeAS@N?(olHy`uVBq!ia0y~yU=UgDAX9v<%J=clc$ZDnO;YHI4}=xAtY$iTqx|NsAwg444Y7#JEn zT^vIyZoR#@lkczr4|Blx4*kw8|Nm#dmSL5u(y$WiPMS~4ff;G)dyDc0=KX1NZn%v^AB*(d9R{J2NmaFnGH9xvXp!^1;aSvfQ`)XU2&JUrab&re%h+tk$5%F4>o(b3S*kb!~W|NsA4Sw}ZBFfi15 zx;TbZ+W6rz`QuVf4BaFv?aOOFF8}EI?S8!q7mdl22WQ%mvv4FO#mfeSaARV literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SMRTD0.png b/wadsrc_bm/static/brightmaps/doom/SMRTD0.png new file mode 100644 index 0000000000000000000000000000000000000000..f6d61149171c0d3c3af0376fad0879473dbf319e GIT binary patch literal 250 zcmeAS@N?(olHy`uVBq!ia0y~yU=Up!^1;aSvfQ`)XU2&JUrab&re%h+sewy)YR0`(b3S*kb!~W|Ns9V1*c~*FfcTE zx;TbZ+R&)}TK9kzu$Z9eZ8-ex@& zopi{S?cOiF7oW>FAO2Nc(;=?^v+(aR#TzUW-rl**D1XUYd16PdH3I_!gQu&X%Q~lo FCIFvkr%)r2KB|+vR0|NtFfKQ0)|Ns9P7#Kni zU9MwbU@-D@aSW-rmHeZhStdbZsw50@8vWNzopr0D}4^?EnA( literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDG2G8.png b/wadsrc_bm/static/brightmaps/doom/SPIDG2G8.png new file mode 100644 index 0000000000000000000000000000000000000000..0075bc06b67b7f0a2bce75fdfd314c6b2848c513 GIT binary patch literal 130 zcmeAS@N?(olHy`uVBq!ia0y~yV0g{Iz)--*%)r2KG*wiLfq{W7z$e7@|Ns9C3=E-% zF4r+IFqnI~IEGZ*O8(K$Z<8P~RSpTN>HNJjPbl-$n|t;1gkCOu{XXy|1U^*YWjNu_ Wc;(zrD**-u1_n=8KbLh*2~7aaO)a4S literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDH1.png b/wadsrc_bm/static/brightmaps/doom/SPIDH1.png new file mode 100644 index 0000000000000000000000000000000000000000..e7d0756fa8d80a6227de83e19426e794d99436d4 GIT binary patch literal 147 zcmeAS@N?(olHy`uVBq!ia0y~yU^v9Uz>vkr%)r2KB|+vR0|NtFfKQ0)|Ns9P7#Kni zU9MwbVDRvCaSW-rmHeZhStdbZsw4~s%=~PTI-~HE!GlRZj|cQSKjUw<<(nyQk!ojf wqF+Mt&ca~-sy{OFzSkEUEj9|7#K>@Fha}%i#rK;T7#J8lUHx3vIVCg!0Oi9nJ^%m! literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDH2H8.png b/wadsrc_bm/static/brightmaps/doom/SPIDH2H8.png new file mode 100644 index 0000000000000000000000000000000000000000..1a36d14bc1f8461a9bbf1058a3389e88ca1104f6 GIT binary patch literal 152 zcmeAS@N?(olHy`uVBq!ia0y~yV0g{Iz);A@%)r3FXL)Qh0|NtFfKQ0)|Ns9P7#Kni zU9MwbVDR;HaSW-r_4d+2!2=2ctQU(l89g<(xMhZOsj|4bw0X1JKa$y;JwKNFs)0mX zqJ&+`^0a)(clI%+@mHq)$ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDL0.png b/wadsrc_bm/static/brightmaps/doom/SPIDL0.png new file mode 100644 index 0000000000000000000000000000000000000000..53c899c38659709c49e9d33b73217500cce9a0d2 GIT binary patch literal 142 zcmeAS@N?(olHy`uVBq!ia0y~yVA#RHz!1sE%)r2~{b|i&1_lPU0G|-o|Ns9pFffE3 zx?IP=z~JoZ;uunKEBQyitN~Bi$N3gV?B^U;Jl7xlhtas~BlD83&6Csqv8P?S(;0kc r-j)vsRsWTD9QnQC2MjI{V`o^C{w6N}K)4eF0|SGntDnm{r-UW|s9HJX literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDM0.png b/wadsrc_bm/static/brightmaps/doom/SPIDM0.png new file mode 100644 index 0000000000000000000000000000000000000000..d9fbea53fe2cb1f17004f2fcac215a456178a758 GIT binary patch literal 467 zcmeAS@N?(olHy`uVBq!ia0y~yVA#gMz~INo%)r2~{ePV?0|NtFfKQ0)|Ns9P7#Kni zU9MwbVC?X8aSW-rwe_lX-Vp@>wg>WoJC^vm_f24SQ7S*l8nle-UD2Aa_Y(32ikO#} zcz7!`%XjB0-0Br6|7YT4e3+r*>iNf6_E&6I?6Qt5*Ul@xZ2BnjaAoq``fm##J$L() zuKe%Dhqx=h8`iyI+;fZFzDn}_fzXnr(GFLi9c0+`Ol*ynz50i?@=*4aKU#N}mh>%^ zwt0EN>%FFLcolo5IybMq{5k}SN*ix_g?CpRNu7MG1qnNVxAv9cf4rI@yyrdi@Qbkzq0?} zW-O?zALAS;dty503|prtQHi&wA6@>naeCOUxu2gLDzVL7QGM>W>$;Pg+Wqf8r^TDN z?E3j>kENZNM`Lv8NB5p~o!zSG(_TsO2bURF-uZpt#N3W&aXE9v(n~UTi%0I7__=jo zlzpYtvX6`rPbcs3-`Kj}@B7JXvMDqEY$&#!zplTxTC0A=9qEP9_a@x^S-af+Yy0<{9 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDN0.png b/wadsrc_bm/static/brightmaps/doom/SPIDN0.png new file mode 100644 index 0000000000000000000000000000000000000000..3d40b9a09d3613416d1694dbfd0eac1a63ce9a6d GIT binary patch literal 535 zcmeAS@N?(olHy`uVBq!ia0y~yVA#dLz~IHm%)r247IbGd0|NtFfKQ0)|Ns9P7#Kni zU9MwbU_9gL;uunKYwcBUzrzLs3>P>ZOT$aU*9g4ReWAD4vELzoQh{*ZrH*a^7VfeX z##P#^?UMCE^+HR$B38Nn&9XM$$o}H7n&ns1BagF=FI&j0q3-yP@#z1?9TGoMFEDL5 zy zB+I?CSbMU>>y7n#Ex(6p%bd%WFImT8o9rfQ*VfyW_8{J&LH5q~uA2oPsx>ox0;l&E zUh1i8$YJ5KS-erV)PTuOB_|={DZ`e3rgeO5U5rt`FCRNp$QGu=wp)awoFaZ3UM(?0DWmbUWCCZ2aYMDpWbdbw82rnn-~VH5O6y?xuuV~? z>$>L(*Z(tkg3I_>@2&ju_7Tq>Gr>2qdt4Io-tJz>R%cxL{dS1y{;&0iPhKguS5Ced zo|j`O6BPaMPPEODfT@Xh;(SXMPu;7?d_!XM(!H-3pJeZN6e{MFT~r%vV#Cs!E*<~$ skz<$L-{)7S#!clt^+l&*>3?x?%Snw@p96j~FfcH9y85}Sb4q9e0NsS*xc~qF literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDO0.png b/wadsrc_bm/static/brightmaps/doom/SPIDO0.png new file mode 100644 index 0000000000000000000000000000000000000000..0273fe6aaedb80ec44685a13f798090773385335 GIT binary patch literal 520 zcmeAS@N?(olHy`uVBq!ia0y~yVA#vRz~IKn%)r2~*oS>30|NtFfKP}k0|UeV|NocX zoPU>rfpM>=i(^Q|t-Vui{SG?_vT%u+6T335$EQ6z+gENQ@u&aj&Pew4X|*l4a-6bl4^F?C zVqrS5L34fk4X0+29~UMv*v#ENJ1y48qoFEpqj|s$h1I+#)^2FXn0lKbMNNJ+m&lAw zQ9k)H6N>Ggv@(0ie%oETP*uAvUM$ z3-3IvQu(7lY0JEXr&SGnyxo$Us(c>oVhx_OWkTTbvZ5&}uY8+k{4z;)FqBWR7d;^n zu=I)Y`X%0!uqs`85cbYkyhkPCu%TwIWSnV2_d46tYHw^F1e!6%U6@n4 z>s6C^<+YR5yEjh~{q#Wj595@Tya~--doTYE`&xO$=y>OP0ZzACg*VKO@)A`C)8#Yt zoD_oMJB#k9+m}XO4q(0zO$irf*eaqpYPGb*^j%T zrp;OW%sspML`7A^OwVhUn&K+94s$+orytXZl`|}8luF!P$(-Wp`h+31ocEM7{|=i6 c*`K)|E#s};;`4th0|Nttr>mdKI;Vst07U=WZU6uP literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDP0.png b/wadsrc_bm/static/brightmaps/doom/SPIDP0.png new file mode 100644 index 0000000000000000000000000000000000000000..addf1446403c53010dd5aad062ee72d3394045cc GIT binary patch literal 804 zcmeAS@N?(olHy`uVBq!ia0y~yU^u|Qz!1*J%)r2qQFvoN0|NtFfKP}k0|UeV|NocX zoPU>rf$65Fi(^Q|tl3%Cj|z8Jw@>rcEY%j7l)CX|+2+r4`hC(io!sXg_ssnBz1iQN z`7#+OYnpVQe#TI*p2OB{;J>HxK(1;3^9?sme6}S$|LetkAc6au!K&Ny@9_OCG+5_u z@@?_8)4AKi&h_MgyZS(CT7@O4eT&8sH_)*?;Sg`JLbfHOsUBAK0 zhp!wb>Q84DJ!x0>KH$vvu7=tpD${Sp^-bq|w7cw~^u(1$I!|j1ObzCw3O@vN?*`)7q%kJQ~(nqXXY#+=K4(>$4Uf6EGGhQ&S& zbKixm{jntIwCaOS{yDwxc2(UCm7F5vxMAl--MD`R{fC7n_=Yp@yJxMXtkN77-z-qG z^-(v|5s7d7OD`Rtl7D-laYG`%{fFnr*N16jxi%fjpOz`WJke@#aH6WG&H|-3Ns^h2 zD>zzue??3cSuw|QCi{-hYnbYoFBWGrNIz9CS+jj3?>o_1D+0W>^XzcV4G4QKaVIrt`I*eQ=~f-p1HhL7X?GnYma)mdBR2&+GZ3w;pe@4H}+)+EWmHM#baX zrXt1NTiA~6l1_JwVV=htW4v#D{36K@+wG~%+mVKBe_26bhlCpz_pU4#k-QT;I zBm$zMRyAEe)+!syx7zje%jn?w+z}fYw>lhW+jmu-dm8^~&k&!kQ>%aah<};5mH(m2 zRo2=V#v={lq5>Yl%z-aoFKY;kSQ%#e;Z(*$FIBDedukqJvF>>GBX(2yItR7Jc=p>T zxK`J)ynd{_TJgETp)`lMl!bTo_9tJN^JG;(;o5{dA0*ek+0M4;Sv>>iKj!O2=Y@?= TS}8CvFfe$!`njxgN@xNA{pxcs literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDQ0.png b/wadsrc_bm/static/brightmaps/doom/SPIDQ0.png new file mode 100644 index 0000000000000000000000000000000000000000..954f6061f78078bb98b2862a5b37860f7d4e315e GIT binary patch literal 1284 zcmeAS@N?(olHy`uVBq!ia0y~yV7Sb{z!1a8%)r2KPG4v`0|NtFfKP}k0|UeV|NocX zoPU>rfn}$si(^Q|t+~_uGh{*~4(z|#X|1_rrUSp4*~vBTjxVRk@T8sW=7ZD#Lh)9;${MrCDe%PS5!pA9ML!Y{av&5aei+c~p# z{`{7;^1TgR(iYc?qM0rPFEFy*g)2X)KwREb{Ygv;=CpH#YaWqXVFc)MeWvMTpbC2 z*GKHw;iR*7z4`RxGII~Exo_^)z_C7hBX#n$G^>xclGcrM>nX%X)`z3vwPO zpS!6v?R2~Jj}k7Pn_O>9Wp9{XkhjUc-Mh&?w_;kN$0C_arxvQ}3Lkm1D0jEVhoqB= zI}~U9S(+W^a6~9iM0a-5VTSn$z8g}G#ho#J7ORu0yS6bSdfu^bqE(x(m`FJP*Lc4o z_|4K+r9oeq&4TwI75wMa?pwC-hiQJM$ z3u?_bd5V`d$W7Z_BdpxbccnbBceAuto!Y4nJ=0qP8yshZd@}rUeeb{PLOn~@dI!xh zU0WIJSA6YmbdTYy9)IsOn$LZAIQeaO7`Q-9B4JC`mK+~u8Zp-rrmm*{&>kb9%^11N!t#F=@mSAcn z)4EspyJD?ow#7a<_e>=wuB!iarQ2VN5>eq>S&2g5rr$eLX#1#ill~@qk)RF#FFv-p zTJmN=?zF8}=Dz8llNqTf5uKMlRcl9V#eu$sL3+w8uNQ1JKYO9Q^_2P>7S693?AjOD zTaB#sg3AnjS}z{d+CS~)1Fxs{PJ5G|UGh37`bI;*a>0qM282|EHT5g8L)6Y(n z`K5X3dfLu@%W9$iA4`m<&ph9ED^1S2Uv*9LWdR@Sw8PGCk{9tMD6i19*Pm;^Y*M@S z*bJ{e$=QD=oV|Wi@#mzjMLXhJe#*TwbZh41j?g-@BRuzB`tryM50}WTVgIEcG|hdV zuvSd-?cVdU{OT*D>UK3PU+XTvY394x{hJgPK9`@_^EKX3DQC{~*Xs(uigB-!7Gue& z-Q^ycwqjqvuXf7|zuT6VZnBeG*!TPOZH7}JQ(Ak&jVk!3tDrj( z9=gcq*w(PnJCk)z?2Tbniuxc@cI%h^vOoT2XX^j4R^~=MdB14!Oa=x922WQ%mvv4F FO#q;oWq$ww literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDR0.png b/wadsrc_bm/static/brightmaps/doom/SPIDR0.png new file mode 100644 index 0000000000000000000000000000000000000000..02b299b155a404f1e345e49210e4899b5b783a1b GIT binary patch literal 1762 zcmeAS@N?(olHy`uVBq!ia0y~yV7Sh}z)-}<%)r3#E9u&51_lPU0G|-o|Ns9pFffE3 zx?IP=z&72}#WAGf*4t^0Inu{P9sW;Z^4z**nqSbA-i&q4EH4)FZd!Gr!!08(SoYGq zTiFwwMKrbs9PmhC>3HFFagE9Xu?e?IX36PZY@f${KSrU;GtzM;Q`QWnjD&?N%W`*y z@%8N#iOo#ud-nbOyGcdan%nQ~YGB~>|NQ*?Z2Nk)g8!=@*VhPH?SHF~CwJ_{>e{mw z2l=F*FPLN1GWErCDeD<4Rp!^fbx_-OoMrXxV~uZ)Ul!}H`qh}TEu&+WWWLRzj7_^v zYrXjQeaC?l@pop6ac^oQ4|tTE6VzHC z3SlofzEWY^(ZBD@_Wb(H>Q*(KX?<&7_)#Y1WrcnlSKcf+u5Ea~C}nd>)WOZF44H~aaEF*@}E*g{~wRPTv&bn)~Sx~+}lFG+}sx~y4lmM z?%w{LM|DLn^X+~2YmKYhs$-gJBH7hZFRu1icJ~xCC%3c4?R3rAd~vr*ajUAP=wV%s zJzPnXDpOQGJEyEr*_Pk<-ZWuyT;%c}uldm7Dpp^gRd5wESMPr=vyo2A~x!?OaK{R2@7wccCtdH!4SE@%;=l)w6G(GoEVx!BooV7u% z$y0y)oN_ZU@5OsvmQDCK!EH_N3mSm)sMsf9X9vQ~ax5_N93_#{6ty z2W9l~Z+LPX|H!oE{gIa+b{i-uoGn;D>!&2#^_R<^Wmg!OYb2ESix zEM0Ow{n|Ts(qE_BztXobJT7eDw4eTLL5qG*>Q6t-uez3BgkFRivl)nJbYH4GU*T7H z@ywJ&z3e zgnwJokvmWPUG+ZCh}+HD`cL+MT;#%^dwvAuo%(xDkn^NZ>P1&o)lGe?w}cPGx5L zn$zy-H+59z{hBT7{k{Idc7dNNhS}w(jQa2WiIeZiW->9>SUUBq591HRkAJqT{P@sj z$s3cNcWJU$&pvZm$I#UCBv^`x{k`z3kGWytt;?Ptzt6TY!aLjR!_6k*QB=JD!sUyU7k-#_6(2n!>eM9n>GvVy|`figJmtD zMobsnU6sBBadCAo@Qt18Tvt*l`|e-llS>!G!=Eg^gmnp=ZOzWHWr^0+;2Ni zpAd4r=iBf34iC@h?SB1giuaQ@Rt{YfTT`}F+gr`kQz^SR@yhy*l|f7yc?%BP6&-(b zT4hE_OHxu#gg$?SY0$$Jw&Sz63v2UM6;LrH6LM`_lQkW+KP?vv=$||82g>wwcdYt}(rwda*Xl zv{&hT#QX9Y-!2%RH11W^_ny9Iez(xJ|D2aK`Zs@gH~qth?%uNF8XMj3&6w-@Vs?c_ qcOCEL4+do)W`FztrvCIl-h&tR*`~ZcgTe~DWM4fYW)@> literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SPOSF1.png b/wadsrc_bm/static/brightmaps/doom/SPOSF1.png new file mode 100644 index 0000000000000000000000000000000000000000..ba6a74c073402b8f76171722f4c0756cb93c335d GIT binary patch literal 272 zcmeAS@N?(olHy`uVBq!ia0y~yV31~DU@&K4W?*38pQ5A9z`&pz;1lBN=H}+(Ez_3qoecx|9=JshU&+~Aq)%*^E_P~Ln>}1 zSG4oU83dfF-TVAZUdqke%ik*&pMPW7ex|ng8IS9?efQcA&DCiB z{k$$qcE;~-dM*ryYKyu2lU=X3FnpJWJgcYTC7*s%@U` d9sQn};X~ohw5=Wj#taM$44$rjF6*2UngFIvbdUf5 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SPOSF2F8.png b/wadsrc_bm/static/brightmaps/doom/SPOSF2F8.png new file mode 100644 index 0000000000000000000000000000000000000000..e42e83b012ca711a88f57f70726fec361c7cd578 GIT binary patch literal 257 zcmeAS@N?(olHy`uVBq!ia0y~yV9;h@U@&80W?*1gV_mzAfq}swz$e7j&CSin$H&RZ zDJ3Pv#Ka^bA|f_6Ha|b#%E~G*Ffctmy|S{>-rinEN9X_l{|pQaRjJEvGB7aoc)B=- zRNPAb(a&3xuwb9TZ}T^+{wIoVJDzvqd{xkzKbii#@4qC7+uiIB{qe4L&7qv1H(K_; zbDQz^y==@6ai<^mcbC6^cK_)APh3YT0B#rJ7^&r#va1uCn?49CcSyzRmynK7L?hV7t@re?otMFarYv NgQu&X%Q~loCIBM>Y|sDz literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SPOSF3F7.png b/wadsrc_bm/static/brightmaps/doom/SPOSF3F7.png new file mode 100644 index 0000000000000000000000000000000000000000..ff1e66f9f05e7de2c8f3516044b0171fe5cdc13e GIT binary patch literal 266 zcmeAS@N?(olHy`uVBq!ia0y~yU@&B0U@&E2W?*2DQkJu1U|`S<@Ck9Xx3_n4a`N)> z^6~L0C@6@DiAhOGiH(g-Pfs^7F$oL|w6e0&(b4(;|33o*!wLBX>lhdqW_Y?dhE&{2 zu4rerNm#J(On0fp*E@$*C%0eT5?;Gx_k%*&uYZc!mY1?cL??n`Z2Obs^U@&1}W?*1=%Er^cz`&p$;1lBNPZ*Om9Wu>E|^Z);U1_lO0n~%>K7#KP|T^vIyZk@e!nzO+` zz%}so2IlHbEZ!TKHnxN)yiADUsJn1+5l;vAN!6~x#A)qMR8!(M9eg#(+-gDD3gxVR ztEqwd!6DwOW^7oHwn8(DQ!Dq~>W&}PvR)5gzS{ChSSEVU+u4%GSGlg8zdGsACe|x) zTOCbjBskp-e8cy;^4SH;Kj~HXJ^vmxQ7&Ph!5(W>IQKU@0|Nttr>mdKI;Vst05~6B A<^TWy literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/SPOSF5.png b/wadsrc_bm/static/brightmaps/doom/SPOSF5.png new file mode 100644 index 0000000000000000000000000000000000000000..2fdf53286734b141a9696308bc3011b886dea42a GIT binary patch literal 155 zcmeAS@N?(olHy`uVBq!ia0y~yV31&7U@&H3W?*2bH@a%az`!6K;1lASn3xzI9&TxA z>FeujYip~oukYdEQB_sNz`(%sY|lLg1_oH!Iq*> z92GF7^1%}Y?QHjl1q#~QuFp)e6{Hgy&tx7w`BLI3j{rMEUxU+$>c7{_7#J8BJYD@< J);T3K0RZF&E~)?k literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/TREDA0.png b/wadsrc_bm/static/brightmaps/doom/TREDA0.png new file mode 100644 index 0000000000000000000000000000000000000000..d7318f94a1ab53fdaac59df5de9b978658860bd7 GIT binary patch literal 609 zcmeAS@N?(olHy`uVBq!ia0y~yV31;9U`XI#W?*12(VY~{z`zh2;1l9%YHAuB9Ng2> zGjrz5hK2@TUtecu=YW8K_V)Jj^75jhB7J@Ryu3VjcXux@uhi7ktgNi)=x9GbKMM;B zD=Vvngal(_EFlvxvCtIQ;&V z)LKYS{BL77NB1MOF8;upHl_Op|28SgE8p8ZJ;~*o=={aKZT4?OMdBSN=1Y|CT=zk- ztN6>`Q|E7r@`iLz&d-p#=5awv-)NTUl3U$(dY6exu}z$?pxxCuD~OkO@8bSfw?4KB z{TAq46S(FU|NSt_M?0LH)?B=y=CA$7M4x}v(v-6=uUxpY&TpS=l$7~~J$sL^J^P=^ zcG-Y~J6Yn2bh8Xs?fC@bv5 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/TREDB0.png b/wadsrc_bm/static/brightmaps/doom/TREDB0.png new file mode 100644 index 0000000000000000000000000000000000000000..15ba5a66575fa46100c3f21069e4a1424656f8ef GIT binary patch literal 628 zcmeAS@N?(olHy`uVBq!ia0y~yV31;9V2I{mW?*25nviPBz`&3e;1lASl#~<`6Ekz> z%z%IZUtiyzo}QAD5@%=UhK7dV;NS@pCe+r}>g((0<>eI>6&V{Fr>3T6Wo5a$yGKVy zySloXnwnZzSXfzE`T6-JBqVrwd4-3EJ32br+1dH{_}JLk{Qv)-fq@}gMzxuNf$^lL zi(^Q|t-X_P&swd(<2EZ$4p!_ruA$4vYR{PK331_ zePqFU^kYf*l-Q3~T0Sz^=ASXs{1*6RWB;R;Z!v)`AH%m4OMfgcDM^^ZA9JHpV_l%g zMZTZuS6=O9c2)|%`$^g6hOk$)5O;qqchTp}U00<=oUC6~Y;sc+JNVK1pT@san_Q2+ z+3TCqos@WQtLCzf$81~QiuI~h`mBEb{8tsPdhzwukK1pWG;p>ZXS#Oxv<}DrDT+LP z4p(@a8}_v|vRwK3&fDQ$`CO652cGUNQP}C|b0w#>mI7@lIbXwRR4Es){|X57bm@b`hf2!+XL$_o4oh%zWyJde_-d{Mq7o4 zc1_C~ZI?JSGr0uV3&gCF(p$gY@>=L;=BHwc|9_ki%iz29b5((0BIH(cSan11HB{gbJRXImO(m|b33_u#4YOBu<~$4Z~h z?vuK?!~N$%9kHkPubry7)*MyI{?Sa%<>zq?|BbChahtMS>)MW;$xOA=UVpS zRTZwSw%tzGG`4?>yls}RteCdNAiuj$v?^}8e*Vcw3mGQeGE)Y#$S&=ObBY^}@NDx` zGvKIBmiUs%W3;0GuX=ORo9c7N`oel*9C_ND9XCf^%vksI9@{xLn~i2p2To+UhP_U? zxkl?v#>U#OYo={n6L#Zu_utb}KleFZh&fna9o1HU_(b-`^$#E4Kil^A?#+gSjEBsM zymsoU%q_dbXi?dIC(yI}&ku_xt5w!ZY<7IUd|C29c|rGv*EYL$z0PvDUsBDNHG{>!hfq{X+)78&qol`;+0BB4V@c;k- literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/TREDD0.png b/wadsrc_bm/static/brightmaps/doom/TREDD0.png new file mode 100644 index 0000000000000000000000000000000000000000..f4cb483b82f09185d9ebbb1dea126504b8879310 GIT binary patch literal 635 zcmeAS@N?(olHy`uVBq!ia0y~yV31;9U`XU(W?*3WU+DOcfq@|*z$e5tGBPqgKE9`? zXYu020RaKNzP`@R&cVUK<>loK4GsGG`b9-W#>U3(?(TVcd8w(XSy@@p(b2B1uBN7@ z78Vv(R#tv~ehCQ);o;$4US5ulj&^o-K0ZD+Ha7qN|7T!eXt#WC%fP^R&C|s(q~g}z z$uB28R^Vx|br&(?e&fYk_GA>izPhQ??~`p{IPwVNBPmo>na+QIgTe~DWM4fk^&OS literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/TbluB0.png b/wadsrc_bm/static/brightmaps/doom/TbluB0.png new file mode 100644 index 0000000000000000000000000000000000000000..6d020512c560cc94b87782a7de8de373082b2e6d GIT binary patch literal 632 zcmeAS@N?(olHy`uVBq!ia0y~yV31;9U`XI#W?*12(VY~{z`&3e;1lASl#~<`6Ekz> z%z%IZUtiyzo}QAD5@%=UhK7dV;NS@pCe+r}>g((0<>eI>6&V{Fr>3T6Wo5a$yGKVy zySloXnwnZzSXfzE`T6-JBqVrwd4-3EJ32br+1dH{_}JLk{Qv)-fq@}gMzxuNf$^-T zi(^Q|t-X_P&swd(<94?=WBFGDtrZRm2fx>!sffw_7JKsSa>?p)jh3=Y9}kPQMz9=z|6}nF z?bBkSo41=ywC!rGyu56NQlIseZPg~To*1s3_x$ZwDZgjy!jDhBY1+WqcARP3-P1Z8 z|EDPO_&HqRZEmn@Z)Cah^IfpRz4EytkB>avTcWVj(aEn{&pu=2lXq!LB;q;^=P2v% z+Vg@*pgi^25!Gu~JJ&r_+a=RcDyjbO)T}4FdM-|Seg33u7w>`c7pc=Lq_6#t%Rf+D z&0OtpD4E5V+1;a&jkROJKE)j&rZI7GMQc_+lRl;E^zYw1J5F5^x{?~Hd~?+j zR?P)+((70C_j?64+xi~LX;~KLvG3SE_d4&bN+G4p!kd0nz2=nmPH9|Gu{A?@(WgWH zTb~v!Z#=-gCDl{%>%H*r*51n`9MisYXz1m7M)hTS=>l4wB@7G<44$rjF6*2UngG?T7heDX literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/TbluC0.png b/wadsrc_bm/static/brightmaps/doom/TbluC0.png new file mode 100644 index 0000000000000000000000000000000000000000..e1771d71c3e6d847c65c7639a67e66e5515477a0 GIT binary patch literal 638 zcmeAS@N?(olHy`uVBq!ia0y~yV31;9U`XI#W?*12(VY~{z`&3h;1l8+A0HnX898<8 zR9|1;o}QkPl9HsPq=0~cnKNfPJ3E(`mj?$2H#9V)rluAZ73u5i=jG)Y8yma3yGKVy zXJuu%y1JU0np#*`SXo*5`T2#1hbJT?czJm_Iy&0f+4=bR*x1(0BI1y+cE(3|9TWFYJU4Ms)()$m zRuZckZOt|8Crq6mTQIN8U99`l=B-Bazb*(n$A8AazT?wfjsA4rr#9(Vo9?u?oyknK z)7HPCACPvDE7Dmy(mtncOPq6O+z~(SU6(dEG!=1qZ`SErEU`Ls;pLr=SeJ%$r8>$N zPbr$rwD+R_=irY`T-BnjI)Qm_R&Vo-b9eH|NV_K{tNo?qyn6o0$Qy5&V#_u%m_=HN z8{BtJ>Ws{p?2{l+cFf?#ZHbfs@!k1sM{ktQ>E&H3v9n2nr@bj{>!OP>r|0s{>8(h} zZE2WzwQJ3_gPS5lZ(K)SdR}4IA6`u~!|9QaZu^luK#mdFTEGHjBzT&Ms$< z7udJ`OK5dgxy=I&1^xFCiSqo*w<{UlD)5+;ukM< zm+Kf97z{mK978H@CI9&Uzn+v-aRo`RFgV1B0ilpUXO@geCxTH;uunK z>+L0Lu0sw24G%3l-9Iut61-F)kiB}sDJ9n^!N8o}4E8B@tv6*KKCs@-?p-&o9%AYN4aVqDR`66lpbd~!y+RfLwEDTx34ECUacxQwZBXE zXvbzpPT|MroUe8tac_OHu|_ z#>&bnG&D3nKR-M?yu7?TF){Jt#fu+4d`L@63k(djv9Za_%xq|Am_2*;wr$()-o4Af zz|gx=X(j^$!v{|n$B>F!Z!dfH9Z}$64Oq3>$mr(%@B6cFwtTU=5VXF>#YOCYqpVO$ zUdY^>ZiAWaTxRKvmL=6~0;USR%u?GTFEU6>V#~g8gI7i9=33=e_Xgh5=T*!%TsfW^ zIz-uv_uXOGR{n5P-G;8uxE_dNmdK II;Vst0IkQAC;$Ke literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vileg3.png b/wadsrc_bm/static/brightmaps/doom/vileg3.png new file mode 100644 index 0000000000000000000000000000000000000000..3646c90bcfb40ed07977730962f2e129c7a25278 GIT binary patch literal 343 zcmeAS@N?(olHy`uVBq!ia0y~yVDMyMU`S(OW?*0_UA~Zqfq_9cz$e7DprD|+PkzT!$QZ*bC;LUS6c*70cRvclFVO2m22`QVO|vo7=tcQjq0Jg)3pd>e;dnUQ7`a zdiS7BUh(A8*82+^yg#3aYT0GBeBTnUkGmK{9agiP|9AXSR*P3{&_d^x0j<8P{In;bbUo{SYFd4td{vTkdzc1$`;5CXYl5v4LK7xUx$h)#`FQNdQ>}-e z&C)sJv5~9w`Nz^)=P4S2i(EQ|RK2EX1lBLSx0HXHOPBhsXAGdQbMC-zXV12= zu?Y+eOiN2^XlU5BZQI?ucNrKMo+@d4W?*3C^mK6yskrs_(#E{Q3IYrlYMiu}7ClQj zIp>;awbJ$MD`M5XS47r(n5At^{!m*s^OiTu#a`KWEi8vG7Zz-9*dJh!>2dtgcaxi9 zU9()~ZY|*Zt=+k6{e(TL7p}GaUjBYkK=$@Ys!LQCC1^#8y)S&WZsn>c$0J?l@UL!T z3;Y>i<2HF0-ybfWMeV8oG#6b@-w{YFHJdu@dtgF0yE`Ju!crJMN-qN*8E;>ry zz3^i8xgLeU>-zjm{$W;Hd-uy7vNmLznRl{;r7CQh&rGA#Q&Tj9L5#ohU)bxGY^=O! TyYdzT0|SGntDnm{r-UW|vjL=` literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vileg5.png b/wadsrc_bm/static/brightmaps/doom/vileg5.png new file mode 100644 index 0000000000000000000000000000000000000000..1f0b75a99bbb01d6473c5e403fef9512c0f356c5 GIT binary patch literal 313 zcmeAS@N?(olHy`uVBq!ia0y~yU)T@Ck9fc=2L>etvm* zc|$|Pwr$%20|RHzo_+W3-L$kc8yg!228Ms@8<#RLFkJR@aSW-r_4bk>Uz33d+k?D2 z4crz5Oujc%h17XnE{gJ=&94P?uTye3JZ+J> z!7n{gUI#M|m8}YwW{KH8G~RaItJtD?(y{g^@4W?u?>WyVorug%cU@u4?wa5gl_p^I zgZJT8R;PGj&)XtS_Uo4PXY*FnSLbw8NO3M;Zd2CmEn0Rz`i{!eP^nkn^ZZstuD$!R z{=w}oqgl*KH#ARas;tXfW7ey1vTsUvd_bd!X3!FkiAt_rV8;KJI!3XT3aL^Ze=jmH PFfe$!`njxgN@xNAhje;B literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vileg6.png b/wadsrc_bm/static/brightmaps/doom/vileg6.png new file mode 100644 index 0000000000000000000000000000000000000000..7412bf595e81f2be3ea6fac5e97db76c90bda22f GIT binary patch literal 368 zcmeAS@N?(olHy`uVBq!ia0y~yV6bLjV8~!$W?*30D>(Hg0|SFffKP~PczF25ixOD5! zTblCx$FgU)yPoMKm*(CqFgf?h=w?)&s9SPXy@Sr1)-BzcCM_ zx(ok2PT882@ci7S$exok;`2V+r0?Q<7ZFwU&(E{1{`ThP d=lTcwM!tvrXS>ulGcYhPc)I$ztaD0e0sz%-uloQ1 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vileg7.png b/wadsrc_bm/static/brightmaps/doom/vileg7.png new file mode 100644 index 0000000000000000000000000000000000000000..b98488d1f8dea7dd2f763559182546fcebfa83fb GIT binary patch literal 343 zcmeAS@N?(olHy`uVBq!ia0y~yV6bFhU`S(OW?*1wey1{pfq_9Kz$e5tCMG5^F|oY7 z{NlxnHa0eafq}DU&rVBAYiMZLwr$(pyLTBF7@n3??Pg$Lc<1Tj7*cWT?Ipv!!v;L8 z7w#-KKQYH=ZtJqSyKh)ET(0Qjw$8rj_GywrgXl%?fCby`)bBiHJ(F4Fkpf4B0OzEr zgg*8Sh0zbbGn9P%b?#LGtBrtF*hQHM(=(#t+}r2M*~W{1eClm&8PbUMkFiH9#7m#wZYu)=1B0ilpUXO@geCwE CXqqlq)&YcSk4E*rnLt0we#fulWZQIt+&@g-U?7MgGGB7Y0x-MJAz`)4h>Eakt zaqI0xL%+ig0<8~Y6sDhWv}lUnHD#Zpi+it2QG5?Pslttb%cFbYpjC?(pL+ZfB zzvmcCW>g&iB(m~C&hGjD=3eD#Fk)Nyd=KA-d8{WF-k%y7_3TCY*HhQr9;`ZZR-s_| z9b1o>ryA3Dd{q;75w-1zzC+*6BU*8lw8H+LSM)4K9`*V6VT`RBLJ z@%t$+YR$Dg^EW}_-tsGDtk#K-EE7)d=->E$M{%uovAKAe@QFJS&+aL_SsA?CZ?0A8 gt1Byim%rn_*UxKq=}DRr0|Nttr>mdKI;Vst0O8QF7ytkO literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vileh1.png b/wadsrc_bm/static/brightmaps/doom/vileh1.png new file mode 100644 index 0000000000000000000000000000000000000000..713a2204a40a3f74c99358df997ef26a44507d98 GIT binary patch literal 859 zcmeAS@N?(olHy`uVBq!ia0y~yVDM*PU`XI#W?*2*7PueIz`$S`;1lASl9EzTP%vlC zoO9>S+1S|Z-Mjb7l`ESzZSwQ;b98jPd-v|eix;365iau8_oG>c6ARbKJG-S=xl7f07&6>-aRtnQYtw})Q6 zYkYxs^Hu)#@N&kldtY7XS^nzX+luC08^6E(!<1gvve-DzeurSU{3P+rmrK^0v#pya z{^(9j;Kg+!hlSo$#hw-S@=A( z>lRKE?)`PIT~lje-87YH0*Tk%H!nHT5c*X+iN%(VN!%UBg_+IC~+A{os$ z)BZT=am7rQOAzC3NU7qBi#J>Cq7-_Yp{v`o<48jJoc@i6IzDWB`{u0v7fw~L$#)NR z^8}rWJhECuZ1=^Q?SF4-);^uHW!VwKb(KEvk3IhK**bmoCH8E~pEqok&ogfMGdD1$ zHeB|IW9N&%l_JW$zw_ml)-_IE5}aQ?{r5VzpXR!4elf)Aw>V$1i@6>z~Jv%KSY^-Bsveo%AyVbh&TkrF)XYFVE^&*>Pn2yQh&}%) zm+)O@x2nGU3I89765kkh-~BYtHg(T4$@OPnWj_$hf1JB{TKcBfng!P(rh0Cr&Yc_j#liQM9f+zuTeDo5wd4->biE%;xky$5yB1e}uAKI; z^m&}Mg2u89>$0}(ij?4;OJ}j-N&UcNZ@$?ja@8uu=KBpL+G?w+bgx&; zRXfF`XLnlgcM?l)?9^Q6>IB`e-L>UXtNR2F9(@(QNB;ifC#?U4ba>;^w^g4 zvgG~E>G!mSU#86yi#xmZ#uU!$DpQVrJ74m5cG6Uht{dWt)4m=&KBeElXZdBOY278W z_;o}rSFW0LRr7a9?y3~Uc9*ERfu{df{;2q6X4EHszN7uuj$=<6JU)EbJx47+C4cq# z8?j|PtB*9Px43ux*%01oUAOSmyRUvN$Gh&buPQnk^v6H%>287ZH$Fb9^}X-9@dvZ| XR0A2kyYW5@3=9mOu6{1-oD!M%gf8}-n~0} z_UwxnFQ%oXH8eDA+qTWd#^%F^4}pP!3=9leo05JpFffIAx;TbZ+XY> zI=(F_{o1>wUlkT|7Hxi~cdc9Sn$up+Rt9ll=1eR1h*=xeRaMV^NpjLOJ~MrD!X1~$ zxcdv;d~-N>Kb-!5*5=+94<~WXlkfh0<#1}bFLW~TSY`01PF+jxgIg~4^t@Avx8ZUS z^FMLizbH85;nvQOn<~ z%5chbdHp?Z_pbZ1S{-Kji#`7-eA;}4C*ShI#b&GK&wY9Q3J-&tX>nck(#=nfF5K6< zR$t9q?{?d*({t|>+Xgl&b57Z2d0ze0{<_l#OziB-X2dVJ!lZuW5a6!|%OTJhEu{ zwu@WlF4=qGWK`)azv(&W6)OC$Z%(Mmx?gW|nL~Tk)QbCYae&NifgS6)8SQZ`syuoaN6I8LV+c*6L?)_RR|?tQ>klT4BzN z%&2WTPI(JwrQUa0#&cVM|EP_Ku-qyQSEDOpd{_Rox-wmzu&O=LDa7zhw}HVLm^f1ZCg(?f3Jz56@1<>x$new2foWhw&$ O1B0ilpUXO@geCxN<48yV literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vileh4.png b/wadsrc_bm/static/brightmaps/doom/vileh4.png new file mode 100644 index 0000000000000000000000000000000000000000..60bd8a14b944eb532941be9bb7ae2a1fd837dcef GIT binary patch literal 802 zcmeAS@N?(olHy`uVBq!ia0y~yUEPIw1$R;*|TSF+qNw*Fwn-vhJk@WmGSch1_q}6o-U3d6}O&VwakCyAj0q<9_tE-g6ZJoDKB)24@4?sFsHKehZgCx-A9$zU+QZAeS@43Zf5+t4uO4h&&t9QX zv-ke0a}qKSHyUuSy=EJuEfM^K9OJHA*-7v<;h7h!Z%HgM+;T;`Qs?vKZPv~_a>*Y!8Yf5dyh|wHpS-#Mpd#Dh>xZS!a37no z?8uB|dk!o=z|xq^-e{i8VkRit^PIy+V6)(Pfgh`yIf`0dPMCNTTc#n+-6 znr|FDE7QoCv^$x-`S|=tZdLP?3uJ{W`wr;G|1kQ0|D#)|?9UUEf7!?O?vJ=5<*89?Af!oZQEvJW5d9}uxr_)MGOo~%ROBjLn>~)y<(ex z%Rz#@pni#0$f`rLv@A@tg*HY+EmYu&=HRr5USK+HyIR5u^SGR*<*PQWp6AXoquMSc z_m7ZA<8J8*tGc8ay5;%*SHEjzW?=6~o+id&w$< zH#bD>fMxmH&qgQf-h8#*bvSWezJT!UsrOED?2tTPuYUgQuD{Q&ZmsyrebFl6s*UyI z-?Ck7xBII)4}W!$)_Aky@!7RM3>3{JLMP2NV*lA*&L?=j`lQIC17?0+Vw#2bJnmIV z>ex+OH6e`o`R~yD-a%(~hn>yy)c=Tw+y0`OY_FdD7=+D?=oyWD- zuPUSPt=i|HimL}I|J>kJauK`m;ir*TP2s!0KHZ;pPm+jHn8@l~-*szSPNjbLi_CRW z@^gHM+hiuwt&S)=zGeF@nU)gSCE z#*@0+^`-G*&63@Yuf-(mQxbO{wV%)X|96bV>Uk6VwwFiL&oO_xOj2*H$&CD(|C-s@1xZ=Vn(gC_Zz6Jv?!Pku#ff z@&>iNZ#8-TrfxVefpN>>HMi??r`8|vYJY!Np20tXf0xdhECvP!22WQ%mvv4FO#s~j BbMycJ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vileh6.png b/wadsrc_bm/static/brightmaps/doom/vileh6.png new file mode 100644 index 0000000000000000000000000000000000000000..3c776f987b1a17b08bd6a15cc62e0154ad2a65c4 GIT binary patch literal 792 zcmeAS@N?(olHy`uVBq!ia0y~yV6bCgV8~!$W?*25wuqa{z`&pt;1l9nUS3{PQ^l?^c}`K<}ddmj8+)HCtv99#Dj z&oy}^e!koN<;QZNV!QA~q1In?T8{d^|7`dD&S}n;oi+k@<_NtIZah1A-&@N9kqwnC zo!awHzq43uR~UPvKu5pZo~i2@llR$6$1g~kr>=hfL-4k|UzQ*Lm)t2&=R52ST76UU zmx_{SatyON2X~`alfqkhwuxHh2eWV4Z}d7DDzfC#&Vs8-3|v?DPxViqe#GzS>lNH_ z3%`DzXuEUHO@5Yw8|>Yt*E$|pE^f2k>t$Im`|PsFH*qda=9Bv8&Mw#NTOfZZt@+c; znm@TZ@k>4}^mlRH;=%Fzu^vPE8WAV)Urb@Tub${?KM^?Opzy9Vt(K#+;jpJ@LvYv$ z0mrI3i!BbEPK z&zT=*UpV(_zmNsXv339F%j|Cd^(pnV`khBCl}e%>=S&vm)_uBo?a!kR-i_ZvL_%-2 z{1tSK{#?Dft8^02k+6rKZ~b@f^WErR6RYLTzS`iusmr$K|G!OLF@rrccKsTuFTpmI z`dyzFRtDs(uP{8?8C|!tV`=%OQ@b85ulSVs^Qukd#vXr1&3z}Asq6lnExRx7aM;{4 z=g+P$sm_U;)>l<^{QQH>jCU8WyZlY^>*uiLrC)BuY)QY*&-~HyY?N|0waFx7`2V=lW^K-DE!h2!33B^TEse+oNjMb;sCE{bBQu^}Sy^Z)<5zYagH|6FIpqt{f{se(!P5bc(|@q+WOPzSPyTe#`=l& z@0tZa2(Pr8S8sFkjcexfnEa^w6K3woIG2^PESBeFPk2S>+sr=ISANTG-h1Gn>k|A# z!uQ?6w?VyT#u{2P2+o@J~S-Z^o0TKOy^?xPZ&D-O**vqETfQtN?LOLCR}KRQr- zAti0q2el__c3qg%BDv{6cSqIa&MMv3@*VS4(=~SA+_r9m!R+6i1)asYv$M9^+bDh& zy)E`P!z}j4hAIig*DbG33r|>j_GnwUc+V^z*OwjLwF^FogqfO(PwwVDUr`<+^K7=y zwTMrvroDQUby7C=@Z?nmul{OOX|s6pl*trnytii8^WyYnQ~b>G%Ole1giUXle5R8n z$4QnhDTQP~BP~U>Sq|BKGm{v&^3}|xJTIzFO8Dcn$ms6rc^7UeYyJBD+IzN+WoRP1 zr&&Uey{}p2^Q<@_-%iguxlJecTCD2*lWn<9$3J4xq$t_e388;hOgzHrcFZhcjr7)S zX<}a`s>boftS@Awp6(2FTl0x0>c`EFhcC6a_3w+axO7xJ zN1{Zqb-BKdsZ*x+v-P4|A`UF_UU48+$2+5RhTbBt)@uO?+1EkJM6nyR}($K|etmMr71pR}tZiGNe5?%h?~%t5aYW$C}Oo}$GS_`2Ju_13hT zpHiN)%yoF37M-*0=s5|aPP?Ex$%j3@bX-2S)~fN<$zRJ}yY^lQj&9Pa4*aXLo!{)v ztnaoiN8UI+)xFj3exv==|F;iwrFZb{Xy51i@SM=zb@j8})js`FcU(C{Kl+ovRP8|B zfQ(?(YRc3m$Gt$fjT`c8aW1iyJ(zo`7e3Z`u<)^W}kdm_jg`|O_kiWSwD u9eVYpN5}B+aAjrXD_5=@J$f`HC1vm4z2)WQ`T6-B9UV)TF1>Z@RzX3*k|j&l ztXX4YV{`ZJ-N3-Ww6wGjA3iiRG+exRaoe_SvuDp{U|{fzczKM0f%&?pi(^Q|t+h8g z%Whlnum)_s{L<)d@{r3NqY7{8s|wytWUHun^{Dq=mZ`aU)9-9bocQjpcct}Fv&#W7^-B4XOXh~z{_)9V ze9SM>{Fy_fDyKp-hU0RIX@A;j;V>!lJx7?V>&UpYw51<3?H-Hwtf41dHsBQd;Q13 zi^a~n&I+F``TNB8)Azgg=vvHd37Y+U!Bc^QfB$`Yct2n1|DM%tQ+}76J#4tjGJWFq z{qg(%PE0)Ld*w~6b#xr3T#|H>A&6 zf4V38WBSw&*Y-w!Nlv)7Zb@ROXz8wRzvbTZy_#(CROu(jvb*jCwEM4?`MA@d^-KbwYi(mUUpxt!S*DlrbfHzQTNx9{StpKWzP`! znX~^v& zp7gwP_x#nZU&Z=wfBxC9`S`ihGppwUws_PqSb zT97L9hyCrh8`qX|KZwikj%MC&lXEP3bNM5{iZ*XtwR~Ih z(YW{A&R<2pK91CmOTExlzSB29eY4H}I*rijyQ->pPM`Mjq3Y`z`TL)4{NS0uU3b^E^5{*g-s-Z8Y3w&_H`-$&Czn}Y`jJymOzzJA&)5FT`53RbB6|Q- Po-la2`njxgN@xNAwOvBr literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilei1.png b/wadsrc_bm/static/brightmaps/doom/vilei1.png new file mode 100644 index 0000000000000000000000000000000000000000..ca8d5400115925aa4a9ede4b4dea8f4af7ec9090 GIT binary patch literal 1175 zcmeAS@N?(olHy`uVBq!ia0y~yVDM*PU`XU(W?*1g;KTEYfq@|^z$e7@)~#Ddj~-pJ zWXa{rmwS48u3Wh?XU?3&#KfAKnkP@5?A^P!qod>1t5<8+u6^*}!MSti^7HdIZQ8VE z&6=f4m)^a5H!v{J#>OTsEv=!UVfO6V7cXAiwr$&o4<8s97_8h^cQPVgsJGz27gs+vc0I=5XEr>oJ~fMZyMW{7#n4TK4et`q$z|o*umTbW zAB%(!x&C4iPGaHsxu{~c8k14XQh%q=7@N)@)85VZ1v?GrC1*O`{==H!)*+N%dSuc@ ziCtALUt~8-yQUC*Y))viZJ=(zV;&6)HjQ6RAGtO(X*^$HwS}+nP``uj`c=$}WfUZx z^{eJAy_CJDbdTBzl@kZ!Dp%=ySlV0_TXLr9$m^Ld{jY>K=GHpS9M& z{*F~~fil5f^9*L~3#cf)dtJl7@Z@a9DSsw@=UV@As>1TwHi{<>SY{qm63{xc#c+P` zyzg?iDz%w7H|FJR-4Vp=Z+o7_i_2Ly;K+-Y8-L6Xjj>W&s&(3^)iv((KKmx0Iny}! z-tTzCYL{u+R;T|~*TLqVanf70rElY|*Krw~TD|AWUEX)J3g@<-bXk3%b+RIR z|5Q2OjuP$byv2KK!xyvjty2R17Cd}Zb~v)e<4xJ8jrj1<#ncRiE?Yx2NAueJpl~I20(CddGKD>b1!$_;s6_Pi#N2NmZ?M z`uB6UPWqm`D6;IHw1Vx?>tDVcy8I^d>!&j<%l9nf-dU}B_tIPcUqAm$J^nCj{*y}o zU6tG-39tV7zOS$zAcH%6mt$omnO_XviTS7csopO4umehx6i+9_OVR?OOKe^M8ucw(fsh?U&6gL z1xM|6%_`rskKuMWcg=+FFIG=pyvIHJd0h{?`1AK!_xilKEe*Gw$A1w)69;P{gk4-#^Aw9lyB>-+1RTFfcH9y85}Sb4q9e0IJVW Ag8%>k literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilei2.png b/wadsrc_bm/static/brightmaps/doom/vilei2.png new file mode 100644 index 0000000000000000000000000000000000000000..a76359f33b37983c6bc25b06b94c7abcd2795a3b GIT binary patch literal 1185 zcmeAS@N?(olHy`uVBq!ia0y~yU~pt$U`Xa*W?*3W>^s+sfq|hkz$e62U0vPX-QCK{ zs=U0sqM{-(F)<}2rK_u}r>7?~GgDbv+1c6o+_`h+=H`u!jceDgb#!zrC@7dRWy+>a zn>so=^7Hd+YHFrVow|4L-la>I&Y3f3>(;F?F)?XrX@P-(4Gj%8Ha2(f-rcrs+w9r1 zFJ8R(;ll?828IV~4}W4{V1DlD;uunK>+STHMX$|xTCdjb_cqH{a%57t|6j10;bxbp z`ZSlX$8(o=rQ1w9>wkc;;6%yRuU^l;=Lsup6%JZ3CF_R6ibD=9sYo#NE7@|cA9QHMpA0p}by9d~dNaXE0{cZ~#Rf67@U zOKxjLE^cFP&M%CK(*y;Y($eZn6`B~9tg78sljh2CD2v-jEP|(lQ@((iN3hGABdaB6 zp|qmwq2+IQmOSb@cS7NxhqraLuEL7~Nv0l)#V%4D0dh=H?yiq)lnS)Z9c@_PyPd&N zbqSyD2d@ORHU6888%4VW0;-i2y15-?4OS;RiKnnfyxlARgK5LLUHu-{c;;}=6a901 zrL+2E&TNL5g!@+oH9Mv%9ur_YYPEWux5bo*XIYt=)(riA&F(uVgt=-z@lh0LOtoRq z)0@6ZH8D1!@viKLC(4-&JfAAWy`t(YHuu8a|3q_ z>q)DGUu)KN`QO~LS|M_olDX{dNTC%^dv^w^?pfDsSbX4Dv{Omb9#eCP`^wA8Q#fuJ z{Q4E$#Pj*Xwx4UuKP%e?SumUI5pHp^ns7pA8j*w{O@k1@*3fmw>I7MPb4szPBseZq!;9#keM1-dhzoq4m?{&rSzC0vM0Z z;*RD&9A|g((&UFT9jsa!+0v~=Z0xUZW!b6HytX^;m&A3Uwj_})tk>FiFclQ9d-qph z^Rt$}W^K2G*IF+&|6l)+kI{DNCBFq{4LRBl?Mig!VbM>>bBy7*D3IDcX=9hLm-a!1 zACGtKlUZy(gJ;Ex3vF3O&o-~QzG=6VZ>YeQUIo8~y$6=e;&{SR+MlD`@w&Y1rdyMF z*~Yoq%m*h;xO5{hS*Wy@Bbe#6SkuV>=}8vhlkccSYZ-o9GXHo~h(z@zbtm&5&4OFb zCd6&d;C*=Yt#>lV`rY-9f4!D60z+Su5nrKQcDJ$u`>Z67{-XlQ6)U|`7oa6gZMfmzej#WAGf*4pc5i)T5A zFnsvqxVQ4fjhLzpGbDGW&S5;GIM>i(?wg4c!Fx@w@$Xq07PI5h#H)*0dSt2`9B$gL znxVE$ta5_SPL9X<_io?aE??jxtluAW-{~UnBK!VHGozPJH(C^TL@{iOP5q&&eMg(l z%&)<3SEMh8ZT!!>@wvm63p4JAaB(kw=amq2uyAE*Axq4u3%Cny<8h>t5JpH$mrDWknt*@WrL#lnOI5KV@T6Ht_=BCb= z?~`VhE1OUAe!Xkw6qk$&|0&k5t#;`MuF0HXe|Ob0nZ`BO&beo0o@U*!tnRl(R>bTH zg3KFV6=e2Lowq0Dz!KHGo9fGpRhlkeGEe<2d(zsplj)4^$7wT9uXK%Os;&yn+*WLP zG)z)sR=>6HQMu>u@**2{u0HuSDQ+v*(Q2*@#}n3Ezoi${uvUH2+C_Jhg$^%HTJL;0 z!eZhqFI&?n1@X6BSxYx=4b8r9rYn}VPV?#xVZVt9Vp?Y^T?H!G(;QoW?oc?gAz|At zQGFJtj&}_``^EJaWuBg%F2LPZ`q9~6{b`|OQh2W07R$XdOIsthD~5$WcJxhL%(v?b z`;_*ZS$YfomppBYXy3Krr`9DY$(>j1E;F?4cW*zKE*Ds!G;`OsyDZBMxZ7VPuaXx@ zG4Cqg_O~?QntnFpQh#sNi9aQ>Uq@6Y>m1k-?V0|%?EIBWH`5jzyUMssc2>j3B{yft zrX{gAH?~_Gne$)j?3rW7(r+Hio!FV{WGX!QXU@?_?2;1ZkFUJdmOK-7%qMu|>_beB z*V+8EUJL&%eBTCuBhS{@cr=_KB+qNw*Fwn-vhJk_M%Hz5A3=GUKJY5_^DsD}k?wh~ZN~A4NY;%5B z)%Lx4ttPiKnaodf%I98l;5aSdlwPL1G$x^ZsbKTXP+rY%`}aOsJ>v%3D_)JtFR#8@ z9zV{`c%Azx$MYHc<65PT2F`Q8x|lzvZ+d~U8plGp5AXLM@d*25bZYm*OS{C(S4*@O z-Esc;G)iWzQgz8)_Iq86*4*N6JhY`z%HUS#zJ+~EbH&cB_I(~2!1?s-S)&iUwrx|2 zT0Xqz*vVV5lZWYkW66_eTz|qjuNw;XUi#4E5PPBTqDRTIU6pGEPE{<)oV6=q$&r{< zZTj7MGY_)AJ@`R(&d%utS$9~>?=MvsGLt`(x!}OrN0;0*`44`0|FosS__o=8)>kJM zOj*dv*8FhNm!6#4aaY)uR*f5kT*+|XoNdWNIDMw^4V@Z+tP#TOcTVxp^` zS{q4eY?>>xsms#%;97$T$5?n4XB^br-pkJB5cFR;$7SN-b-#_iv^}`wmQp;WJ5_XP z;iWB!YCd9T*Q?~pJYKfxsnN~5-yc@gzmYCT^PMqGcSBRilm+k-tF#nTJ; z|EF-CP7qC&y0>Pg<1|0ldmnhrd7ma{l*wHX-gP~dCFaqR68?=d!_|toj-}37_5AwU zm9w&n1or*UP*Lf5bmoUe**ulXQwyiOc5^y(mGAj;S*h)Z-cDb>%C~a$t^}z9&iJNa z?a6x@*{^Z_W4mVf?7+&xGY|bfspx+As=K59+|7d2UvtD(zB0eXv!AiD@uoqWL5%GE zcd7OND|SaemyvLsakhVb`O%#J73!^;sXvMgVry)3zgRv$G_|BEU{2O@d9fY5ZEf}k zH%&R?XRa*2u4YNFf~4Gs*QXbUB#G39=> zIOkzQ<~pVJ7QG+rfg9(V&C7ncg!|q~d5?QL56(R#zU)EK!O}Aya@1oIrTXlp-1#Lw z#a=LYw0ptB;3J#jwl>ZTJ=k_%{jb`w$9q%cLq5lSxMthuQ7Qk!fA&l7ihq(3d7cWa z?CCq)gSh_lSl|8d`|-`<8?mKzvFH56W3C();o6<>c%z@&t->{2^IvTE^58~G>eLfP zMYj?k&p-C$0+;w|x1USa`W}-o-`#ZkTjK-s<5ss!7*GFl6>QfnD6rIDRv3l24u^4)opG{?HNmSNX}Np0Kb zH>U5nUL~r-Q1kD9^mfMgHlBHb)j78|ToFsP@%rV?od4DTz>Rgwm*vg)^2grg_REyT^BZ z>OB$l>qpAj*1HAmP5rar?Al(XkKdvct@oa6>92CN-dxS?3lDeb+_btU7i}=sM@%zC(a(}eYCDu zaeG$o)5%xaT^P@WJmT}~UbCmHv{QJ-n+NK9nFFf-20lN!G@AECtV8*S#cvDe$=q`^ zc-#EgU8eMew#)DTntavnjOz>^r9AYV6UZK*Vt;8P&CT~dS47Trd0?Y7Cu-4)Q(G>{ z@o+B8vAz9rRiHqmU-{(@wP`2pTaLceoi8W8>!6aaqpX|elGiFxyXH^sQJ;L_>>3l+ z?fo3tAN~GMoZ`FjaQrMgk6UbY-M3j&ybsL%pk1}K-7Vzu#ZD{jkPTOM$98?({W*D6 zd*z?>wXDCF>#9($|PNy4Zzj)VOuqSGDjwQp+ zqpWW4<5d?6J^vgjKmAsL(Z!uNh2Fe)W*^KkUHQlwBTH|APft>_%c@k|#5Zo)aJ)@| z{qYX5g9arW;kOL9WA1F!);;?-xGO97-F~5%{F~powR6`Vl{w9#{C?w<^vxL^*}*|R z3(p9J$Zh)~BRc(uPR`Gn-BWnhoO(3rQCLJx*X@Ly5T%dm9>U#^HvZ(znkI9QY2Vk$ zHsAT*Z;)Q++b6X5u;})3q2Ho$pVrLhd3#lGr`Yn}F0UJtH!n8U(b=eKR=aeD+3~pa z-%B-%o*5SZYSQgX<-7U0L|=EiT{8c(^--tmnmMNFZ~ZpwZNb}3*UE0r)}PN_YE~Xo zBP`zgcJ+>xn|B_5>$qplM#ppST(=*4wqKgH@8-%a2Q}*R4`gYJe|y&%IQQ_94^zE2 zvWJ?@5WRH$#>$D?e;<07e?Q53ZGt@a@k!c=!I|9JXK%ax*nUau)Cae-r%!DZJ@vsW zajUI;Q1n^d*wC97CD*<=`S;NoE77twd{Vb>N8h^fYs*gE-EUlrvvcnyu08gx_tx3R lLFE_kta{&ZI;Ng+7VGO1+Z^ZKWnf@n@O1TaS?83{1OVK!4<7&k literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilei6.png b/wadsrc_bm/static/brightmaps/doom/vilei6.png new file mode 100644 index 0000000000000000000000000000000000000000..435fe6f31fdfea4fbb5fd3343e4719bd91ee36c8 GIT binary patch literal 990 zcmeAS@N?(olHy`uVBq!ia0y~yV6bOkV8~!$W?*30^2>BF0|SF%fKP~Pd3pJV4<9aG zytr-Kw!3%l&YnHHp`jryEiEuG(8k7wfq`L1jLuXB2IdM+7srr_TdmhlPg~?B!H^KY z@QwP1S##dF966`MSbeQ&!OOcHU4@o+V@hVbObDH?6O~~4{E0@0Z7NsEF45ESWv|Nr zd0&lJ6+KjQ>E>i@)`k9cAv5+LuQ)w>@lwNm>;)oG{>QF|Cmv_JQ68JWq;~GtWV4FL zs&{94`Y%2?SLDX*(}!ZDK0N*r$GcE5d(V|C@2^YhA8%Tc@Q^sfO2J+l9k>=Gm$jyb)ItSl=vnW!>Becy9bq_4dPj%LsQz#s_<<%Z-=()q8PfGo$AT5z{Sxp&g56 z)E<_RHf;$wyhL@w!8pgQS^n{t)MhY5hw*NewbyQxRqWHrm35uypU1c?^JC+^gN7%C z43u2NXKznp{8QO*Z~uk^mAXYABAA3Gb9(%-Ov-7nH=oXH=alfD@4)m=_fr2|G-N1n zNhr{IYIk6^(1b}P!9t0$2Lu;MygB6A%)r$7OmDithF4X)S(}}=a*1ZzYI8W|s@b() z;CjV$`LL-b^JAfaxzib$S?1n4TrN409xnIM<_!WDZ8=LBS9S1Mh_gpUWpE+^YZQu5FN3K;X`0x;N81-FJ8QumX>B?W7E*kFnjjwZQHgnFfgp-KAFY9z-;d6;uunK zYworE`L`TI*gy3AjsLa2#MMcw$5lxoESjr_!<{!)YpJPO&oqOH+uba--3%&tW4)4@ zspFV&;9#BH2F-zti(5Vdh7Ow_k>F4{5~XMs&VAY z@x_K&QaKq?3BMjLGs=n$-pVOzzQXM56W4r;+SW@`B)={*Eu9<2@AWz~HuA^igv!Ov zHcIn)W}Oa8KYHNNwg*4EmulD<7G%%TW#RVB`C4?#=!>hTz^v;Dvo2<*YH>OF&B_wJ z`JTgRr@P`cne(3l-8JkEW^3Ci+D+ope{gF`)~3|Rvg)OWqZjXcvtw(d<@5H7t*_Ul z?*2RL@ZV=XJbP~Pp2^t}QMSu>_l1VbyOhh0Ofx-RFsrXaf#cnJp)+kc`mBj}^%E@K zR%G6ub!rdGrZ{1%MOTcDw=y2_2^NSf3-gk0K00$2QrI%>(x2l0lkMizHs5etlKXFB)vRBlx1yf>p8wnLx957r4Z0U^ z#PmMbf62^gezkPl=0nT@#*yLM*IpWP?%?4!zqWsfJE=6q)K=--AJ1(K|VFP;>+T;p_0lv~ZBoHp6U zO@(hptHBvT&PfwA%Q%XC4w*!5}c+N)F`u|Abwkt zKSSTg+m*Q@9g{68qqn?roFh}Q*y-rx$C=liSLmL+sn}+_dcuqR!RQ%fJ;4HCjIh6;Th^~k#2m7KMoj1 zrl-fJ%)QjXGH0P=d#36=AJv3ECpabk_czv_`_FK9!Ce04BUz3N3=9mOu6{1-oD!M< DKmozH literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilei8.png b/wadsrc_bm/static/brightmaps/doom/vilei8.png new file mode 100644 index 0000000000000000000000000000000000000000..6dd3d603f25d0b6cb2861dfaf050c633308bb785 GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0y~yVDM*PV2Ed7W?*25KGUwpz`&pw;1l9nUS59p?%lw^ zz_he98ylMsA3iiRG|Zkod)u~c7cX99U|=|R#ej{0fq9{)i(^Q|t={Wr`xkjgus^VT zJ2xlIZQWg2pFMBSuvOb$N>l&1Yh~=s+a>-CmbvDg)9!4!>`+)NG-Xz>dzQof{YBol z{dMdtB%1x}zFv!VUHLwt`0IjKRkiFq586ssD|*+5&l6o4I`_xX-)CpoT$T9s?eOBS zAD11w5HJ4e@s@D)jf(#BB6^QRM=racwIx0CWYFW_-i1>e&e_$io1Ed7*2`X~6um8K zuXAs%lBryaU$*Jn-_DED9xRfYTAljq;f;CO!INCMZzP}H`RVl+1CxwbE@E5SHP^OC ze15sH|IMi>HjYV`gVp{WvgYIUsmAgF&*+K&HC@<0{=#;dmTj$v-p;*>!+^w z{cI$yeybhkigj8R+3~$-CEwz@=Pb7>Ibxr(ew1Ax;4+`Td&S~&tSPq`UX~>ZdOiNT zeCECe?i0$&TNs+#j-O1~rQC2p`C@@7n?*^e$ zC-7yufYbL|U0)2>)bE=*(=|||t;gFce*MMU9n7)Yj|%L%n?2b@(CPL%mo5CP6TExh zE7!erymCE$kJE_?wR>K9e{blu%=Wm-^MdW$M}aQI*Y^_lbqHSiy1#d}5XW8nmt`*m z&aSUYop4uh%gNUP>)BHUOk~^xzvv$+T+Os>$NI(Z?^&&AnC<)c^`FvTT!q;jC)g)oHqbHPd1Z^Vy$T(FYE!Yr4(0D{;Tk#V7oq zv!1Qz>%npJPrp`$^ks<+-e)$*sLcox-&Eiu{&a)y zJr}p6?L2yhy}fU(efAoym{3t(@#%!o4Yhy!^k?ikYOwLq;mkRL`&p9y-^h>=cNVo) zU#p&{XmUP`@4rUV%GYz&rUkGV|E|$a*v>G^Gq1UYwV*_92BX+vlm8yA0$dM0Kkhz$ ze5uopQ~#H3JUmfA%9Ouh%QMf3Hx4Dg5L&g4W7hNwB5G0ZSic-qUogFWrTRR!bBE6e zI=^PRmGqfvwfRwpHz0cg(iAXXPFp(0{?l zvsr=Tj;s%lvZhzbr38~r-#f#@m;Qe|?ZYqo-D@>|)PyuFVqjok@O1TaS?83{1OTxq B^`HO% literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilej1.png b/wadsrc_bm/static/brightmaps/doom/vilej1.png new file mode 100644 index 0000000000000000000000000000000000000000..3a8b234a9d32bafbb49a3b325712174083ac945d GIT binary patch literal 1285 zcmeAS@N?(olHy`uVBq!ia0y~yV6bLjUlC4{}E?v6x$&)9yZrzHBiCME|O+i6HV`Jl{O`AS{{+yqm zpO~2V>eZ{7nwsz5zkm4fAuTQK;>C;GwrvXx44gfCc0)shjg1Wh1B2jKCuRl)mIO~1 z$B>F!OJ{UeEw&J7xmo>uo(!Mv*Mqg*AnDSK#Hx1pBHN8W$ftZ+&w| zZ|I5#W&HV3|2ALywKD8?ruGxl)h>!p-wDiR$uepwIjzbydZyoNkv2UJ%&ZC2F|zY|u%uLj`v{#HQyJPqLK^n3o&& zT=vS^Yj?J+>=IZfgCDQHk$ITbYPo#!c~R!%)^!iR%{*H!nc#8h zft!-ovV}cOW$P0ni`UKcoyI!x=E_*%7suH%ic4)ob5hto#7T;UC48QK@44~rv~+v7 zKR;G43V7oGRjl@OLs0PU{a?1dG;*8rE@$oI@(uUqdq}*}ot?g|GCIQ1WbMyxZi9F8 z?>D8@W`9XFcbHrG*7K|7g&w1u`LeYq83J~_oW#!ky*Fy=&$XLbLXQ{zIM>wnTwh*a zf3E8?mBpqT3L*tf9~(ppvqT*G{wuep{(sQ%&HM%}8!Ep1Nt+VIvG=EKSw)S%^epbo z&gxvd?Dgq-43oMVK8b4=FWAK#u&!o_CtKU!hR|CP{w6ax4i%nSFh6op-vs|F0{MRC zWnMyCr@s6evnYT6)bHmX|2RIqWg^28#<$&pf|o+%eitnh z+?OY9Fsn%W{pkH&mhBt(5>k&`ck&lpa_!*#3+xfo^NL|ttp~l4ZK|377o3-1W{H^2YZaAZ{#+qJ zVx^?ifn|lc*Y&#Vn^MvgCF`tLD3v|a|36dPPP*^NbIq@U39#**|_P6)10i=F-09$w^jU}eXZp5s*8ua-mtpH zR?qJ&YPdQl@?Tk;;mxA(*7n~D>HK?jH1a=meJD`RUi&w0+N!H&C*(Ip{#%|p-Qn^b z0lB>9GlJUJa~Hhd{Dx6G?fUE;YIoM$OV_NPv|DUa!QN=!>pJC&itg75om;r+w4PH9 zv-10Do$rp>xw?rw{x=ivUQ4k)6MLWU^h>eJVl~(8+g{JQ^`9#6@1}{kTl|f^nze0) zH(qf?KVdj+w(FFg-BRZt^NxO7aH~NxYY*S#}>RRWo z4BG!r&tL6f8-DHbn(4)rHm9qskKF#8^ZNkvUiImZ{{NJDY45U7dgg-@<~j@v3=E#G KelF{r5}E)w1c)O5 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilej2.png b/wadsrc_bm/static/brightmaps/doom/vilej2.png new file mode 100644 index 0000000000000000000000000000000000000000..ed42c147dca863ba3431d3895405436c70ac65d7 GIT binary patch literal 1051 zcmeAS@N?(olHy`uVBq!ia0y~yV9;k^U}}h& z+1S`zym+ypq2a@a4-5RX)%^#GU-7R_`C9#=k6-l6gVuZOGBX%IXJm`oOKJPv zTgY!Qo$cli_myq?{oWVke@oqdPbkZaajrp)GuQPPFM+KhTYl;N=W&;9+q@q6>x%t{RXI5eHtTn%f!{OoVjMK=G* z^E!VY6|Y&f`rj?FX79e&GJ#5)4+%)~9%`RgHaGFZ&o;($Ta8boH6NJMk?tHKF+1kF z#MMu_pS>2p-PyE#n!ncE8DBQ9<@RT`=zX~Fsn&$}Y%XS-4HKOsW%Sg#cnnQzCfBU% zR-JNN>}SKnRg5-vNsgZxukp-#c_d+>l;oP3C%s~o_pLZqv-nVz99v0cWO9~}U-wa! za^5(BOHT}Y9>)CHxa_UayVokGT|CO(9oI<^vzAO-#zdoscEXj?$g(*=YM?2c(HLpLQ`yT&9PvsL+Z$93e#zxljB#-;C#lpC5CYoi}DpENtlS%RXas zU$myT@?OERdcPaoar~duDj!=Ok-xBBZ5jKI18ddJUEWh->wjH+f5U@47j9NP_`CB# zQpJM0s{hGf1=ff5f7r2EcIESm3qEmk-1j_-KJ&HxsdW3_w}zqileT|iKUpg~zx}cO Zb9Y}8j`aJ}7#J8BJYD@<);T3K0RSr`5bFQ{ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilej3.png b/wadsrc_bm/static/brightmaps/doom/vilej3.png new file mode 100644 index 0000000000000000000000000000000000000000..f9e45f1ce568258acb36039706385e0a11205ae8 GIT binary patch literal 898 zcmeAS@N?(olHy`uVBq!ia0y~yV6bLjU zKN)MlxW+1o<=4mmx8MK#c~JVE^wO)l|NdRp?;Cf@z_w?UusO2j1N|vj<_p8T0$zwDB z6o!9CY`$$he42K-?ND3-yyx`P?_ZCpaYVBnj3FlbJ*RLs&?g5_EwSk z2X{}kDqm(5^xUh-W?NCx)f0~v&Jy=ZO5eC>*6*w91ROA>Bdw&@%Vr)iK9;xq@wx>`aZ+z2{3L(d_0B$Vdi}DG#pmR9n;&Ly*Za*DYTo$J zWZNUnn)%haA+2_O>zjk+uem>7CwI7+C0;*%+bRopwFhbr>q{5)KV+|0KluIq^XH$< z=Irh}_oz_k&60mYI|>@=^;~LZ#T+=d>G075dp;h0Y`@;GPWe0Kfa2 R7#J8BJYD@<);T3K0RRBlwPpYS literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilej4.png b/wadsrc_bm/static/brightmaps/doom/vilej4.png new file mode 100644 index 0000000000000000000000000000000000000000..2c35d4aa04c36492f604a3f905ad8797cb532bfb GIT binary patch literal 843 zcmeAS@N?(olHy`uVBq!ia0y~yU~pw%Uqe_vYH0N+FB$$JE{ihN(S0fA7;mv8Xpf!s##iuk**BmY(|c=&6UV zO{8*?YMuWn^J!+TZ}n*NVmtLXF;@BCZK<$LJDfKh3J@#vP;klOU1lLNjpKON#{{P) z>7QHXiYJCfGb{7xo1c|Y)$jUxu+A}x`8tPXmubok`)!3>50>6F5Z^pIuQ^T0!2XTx zR?dca>0@^M-S?N?%4u5ER~(bRa;3qPT%`xsy-y!_ayUwx=kNiRe;a?9_ARc=+Pm_M z;2ECc)8U2e^WMC1o@pPQAo=W7V^YG6X&=L$d);rCYHW6V+J4iV;~!UL9u11OPR_Tl z)cdbsZ5fiLK6CBdGkbNMBWEpeZd*0KRCA`~quj`)Kc zuZz5TK3!7%MComt&CVC+9OreE^zS}?`f>d<+0Sd=X>8=VUb};D@dm4B0beJ{#Wh;) zT3X2IGC6%__m2tpl$GAi+?;Xkj!Z>3i;&Y(=Y?j%c8g06G9H}3BVo6;&1Itgk%fyQ z7an=S;=ZATsq(b>=c4op$2%(Q#U}c<-V%}SNGv{G@#1^Q$@#Z)90I)9Q~ul7IBWK# zaK+oDFD;(xktmX`Kd~?SrpPVhJDmO-&zEhAE^}otbRjxE&KEG=6|4XyK zmhb)OwD#w3zpcks8~04IR;%xy{ar-X?DKOo-3JRSRTF26&ET84e%I<%I~AOdRqtCS zA!G2ymy{nL{ncMKn`Sf6%CU9YU+Y1QH{ zal5y22TN>^SJONbyuV;#7K2^N$uF;ai}uOuP0~9S?Xj#{?i2S}mEdna^L`Y4y>1-O zy~1>|2FDYvSwHhn)Uu`p%9>eZH& zCv+b-K3nuQ`>9n_@ZUfliGNx5TFbM(zWQ}gzTae-uK1bGp=k+5ujA82X9VfDeq6-#`XJ+B zaBmNSI^jNes_BF)$oPPYh5QQW=zQvzf!hW?1XRXmarHVGr1E? zS)Gq|oazx1ztHFFGrjBbk6z{tG7dEn#i1EzEAL%9ze>F8nCC=u`4_(!4yayVY7;J1 zrKhUcbD!&pSzCgQ@E4x7|F|p{t7z_Ytiot{NpxxyXM<_zZvYM3u7Gq^Hi60wzlgm*%U!>*uZ4)#-P--+S?2 z#l%97B&p437TD#k^Vw+fspk83d)@z89q(PsT6F{aelsuKVpCFk{qNyV^4l}svnEbi zvFf({g-Mq*KHS~gZ1eYYX<43xikEn9-L-iN_pNu|pJ;E{_n0j%sAFEXXVQ^#`V#*; zYMxhfTFeKgn9Wm+q<7}euWVmuIqS;0ySoz?u~obN`TOqr;S09B zoZtFhs}?ob4%7fVz$2VZ|;tAEor`1!xh zax5LE)!P5bE)dQ6EOlQbVAW~nyzqpg&FaN{-=2M%AaC{CaH8t;h(}R%A^a8770#c^ zwfkjj_u%R-hjU81^B(?IlTS6*pZ!&S@3oI&`!&Zh=WYKg+rB5C+4AG_ z-io_yIk>S(b<6X}$?GgnnQL79^y|yMM;iNeZP+aKt*LB%9(aCzcJ=MEsnZqN6twH! zo!zZ+iTB>@?Tl=V!ge#ZGal)B{=NB5k8#=a?KPj+HnM-a-n988XRhp@x#xepEiG#b zFW7sg;#X$c^6wXPnfdjN^V$qwRZb2`Gwd*~tDgHg?WDc--Ur5iw}1Y_bm>dA?Wde) za+S81x9?!Ms=aT={6GHZ&U~sfzFb~ydiwQ66ML!o(_{R12JM literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilej6.png b/wadsrc_bm/static/brightmaps/doom/vilej6.png new file mode 100644 index 0000000000000000000000000000000000000000..ba3620ef6717ca0ebd7a4ab7925e36fd38d47d67 GIT binary patch literal 799 zcmeAS@N?(olHy`uVBq!ia0y~yV9;k^V2EO2W?*2r^-Sn30|SFxfKP~PO-;?VZQCwh zyf}OI?1qMhw6wGjA3g*I2HM!zFfcIe40Afpz`(S})5S5Q;#TREv-z_PL>LOzSu>qn zCigneV{h+_vfFDl6{baRy`d!ItiI%)nP`f|`iT#xWzF31|F*5&q}0y0&P@M)?oF>K zce_Pcb&pH6zHdDpdbdL=Ps-8biizz6hS{5?!^~ns?h2h?72IIj zZN+> z{IRQAYff(JT;M9O!}yEY=}nAHZh3i|w}wwxYHmJ}dBUyowmYu9BKHM!K6mu`?r111 zO@DJ}onQ^0_T>v(*D_v{?=8p>h;NGdx$N@!^p|rtN=a{ToUyg_SHl%g`JSx%7w@>P zoXop*^Ve?-n>g;|30Y>&O6_-N=-tr9#c+9T;J@D&H#O~0uDvDoma*cbrc3DuTS=*_ z{nL*07AN0v_C;EjWgGIZ{`oPZB%oh#a>2-@+=KD=p@lb2s6@%WTLUpaZQWa|&H%-YBIKS*!4a174=uq9{ zu8y)O&(z*BrK=NeTg}K^uy_B3hI&m?{*DVSyb_OHKA$g`^h)1ZDNQN)#9BE91_lOC LS3j3^P6y`P zCArg_W76XbYgE&tC&UHo&v>j9bhvQEiVx}UTUC0`s<(?>-EXr${kNs*s&CF^{om`| z*fmaYtXOr|qa~}PYa)keWrv>w*Zn)CO>g)*D#fh?p04F+@>{~XM19YTdCT;Vu44>1 zBANPetq;TIDpQdIvfnF}vNo*d@bb65)bU`~dAAv{*BfVe%wg10m_E^4{q?WA=6^*T z#iV|47;J0)&=oA)P|Ue7B(Q4=`A@COf?e3D~21GQj6n}x%W(}baVjz+DbRRD=ZK=kXCjZ1jqr3^lyISJI($?;Fe0g>A^N9~4)n~MA>C3g;BrRjBzT5BV+TD!%=c>(L zt^S!&sIuzJHCCPMe_wC$URtjoEK=SuX@AXK<)X`MmW%B7SzUR{Aoghe_x*nlEF9-)1se21-f^-5MQ zTZes}(g~~CXBh2x7J7kaL(+v5C&u3H%&h5|v$O>54zK#Zl2MxZ$~_*Y9hPDr6;1@c k&dOTD9QfZex8eUf&d1EluFpNsz`(%Z>FVdQ&MBb@0Iq+Lo&W#< literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilej8.png b/wadsrc_bm/static/brightmaps/doom/vilej8.png new file mode 100644 index 0000000000000000000000000000000000000000..1c4fc05e2bac8c67987ca20bccfa55028893469d GIT binary patch literal 1061 zcmeAS@N?(olHy`uVBq!ia0y~yU~pz&UFMGaQgN&G+TLl4 z%_P_!Xch_XY~S0wW#NMxTV|YLjnMhFZNb5tO0Ao_c~is83|!BhWKo`x#C`m@f_U_c z6v@TiT~9vp?-wpL<6qD6VsgpxRlS?aewT&+_f>V9`d_iQ)AQ>YwZtnkjhBT~=L+V@ zJT-lOCwaDp(arh6B1_dPZSoFMJ;< z)qk=n7uqD=?;Pu%IdLif0$15N0)_kEyt}RPy>aEf=^N*Fbbp$Z6Rlz_5MqByLZaqK z&7G9{N~tW0b52FDJFYRX^uGMf`Tc#@3v$19u`>0aikwlQ8>GZ=Kw##qRGUEa*-zTV zer_q493r=RRaWbjqilV*pL~DQcv4OMRnM-8y_eJ!SL?qJw-RuYJzJcz@Idy2yBTZN z$NTsSyw!9MFqcYM9`&js@m_Ll$=8NbjcSlcOP~g`ZD+ zXHGxJoVM$Q-k-N_VXLyZ1wR=4K0c|Rd7j*x*Hfn`c$oiLry%sP@j2V0$)BSC?U}SV zb29IiOLLBAPn$Ps%7b8kQKM^WjEXF?XYuhQEcct25TWeKr)KYQ$zMD4_8-@<0w)8% zntv_khtk~*$}7yDBElj{5!Er9T= zZA&|)H)T#R-wyS>$IK^G+*hyN-XUqOcWtX=pj7-UaV5T|6(?W!p1N}*v-+KvpI!W& z>GxE(EM`g(+H9mV<+awub;|oZbdP_(Z62-}=-qBEzG-?ttJzy~&wo$vYxaq^*A;Ey zlTVBMc0Squr(N&2NU48+-A;W^+4i^Ra_1#~fmsh9E>F1Y@5ONO#L2ZA=JS*+vEy01 z@uK~-*7djJQr5a9$}g;7z24(*WAU-d<6yYlMlQDtue>D{e#G&7S#dbieBsUPj*gA| zbC(>r_H*vX89OHP2=0jKSjD_gaF@%mr~j3i&dauhKmKK=8F0bz$ErGR{Y|%}_X(Ou zUEelkhik^W@c7J)bGC8LySCl@j*|C&yN})3iZLFI%w>n<>>6F9Itu%W} zH$VBZ!S9Yj-n;A5*PU;9*Lg`r^zriT&b>zQ63{x4Tq$6vc8G7#J8lUHx3vIVCg!0Ka(nMF0Q* literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilek1.png b/wadsrc_bm/static/brightmaps/doom/vilek1.png new file mode 100644 index 0000000000000000000000000000000000000000..204b6963f20b3954fd0cfed3b500060f94e90468 GIT binary patch literal 754 zcmeAS@N?(olHy`uVBq!ia0y~yU@&K3V6bOlW?*30w#-+8fq_9Kz$e6Y>C&aYfB*je z{rkm>7e9RXux;D6*|TQ{1_q|3rPFMGaQgQ3-72Bf41|kd( zVp5HFGCojBP4IW{d1%&s=uwq&-K>ylI(!U9XV0Ywblq8EG;QadQ)L`Nart{qDt`Q# z_wU|i-}=8lcl`7Z_{aU4drJF5@x4d>^=z45!f|!OEw>FnBHwyNJrkZ{8p{=8Bg_^2 zW7CwajUxJz&n{NC3)XacF>g<*R-C-ovGEY3Y}W_Tu7U})`CO#{kwCYYt-wQY~(Lr;*DfTtKPo- zc)$mi4coSF$@!~RQ}JV&)7_c3IF~HcxxM`NPs>ZQ*mbXMT)rXD`6hq)x?AlPu}_aB zItwwStz>MLaP&GWr6t_N8DK2RvFth16)$16SK5NDRxDOW|NU6o_2i}R|Dca0!dJ6G zC1M{K-mP1EkL5_lq-jo}MaMU)e2kqp+m+YQ?WN}3V`a(0R~uI?^t-8bo105^=_;9h zcIFrUU5u8P(favEao^rQ56@ncdgs*o_QLf1dv9V7>+mqo;}`y)YF(w0IN#g)d)xbr zi9*6>f2}LLwUO2O40o;c=ADfj8>j>U>b;I;vM?uryE@j)Q@Ck8Uvu4fGrAxnm z|Nh~_hrqx<8ylO87cZuzrES}`ZT9Th4Gj$p3=G@{{dY1jFd2KgIEGZ*x_ae&-fRO2 zh7We9f3dkb-9G2C=1JF9tr#^|r*pDiNq(WKX_J$evsf?p%<2%zo=!oz7CH*wQ;Kbl;V;3drCNbo%WJCxu+i$zMW1z-6)@_%BpD8 zwdzy(Ew^xvi%#KUn^idLp6ISV;OmkWJtDm|9^T&!O^H|5WV zr*=msv0r{VQ#<^^b!B6*{!iY|55Ab8dfFgy;vbog`718iE<0XqtG@LD>lM*@_U(@^ zd;FF0u;j>Ft`(Td(ap5r+=i>O4bH!L`JJy?@=nCJiklBJXY7ysW?pxCH|vsVte?M3 zo1OD1=Vrm}neUHJ*gLN&zk=)M4YfVHd1s$Ivnle{!`N*#(*70Y<$Ii-Tco}FprcZn ze>ujodCmTYsm4l4x9^|k>PXLv2>T+ItM?rycny6VsUP4wRND{V~EQ$ObHjMh7~s7~dph*@l`!^Ep6T|Vjr z9W~-JidnN)wWK@Fk*e}0Yko+R2ETiv9ljFXt;)+MUA5uI%VT01)b!``?D?hv+*?QXM;;(Zd z#rA9R4rCo;-ur$+%LcJS?Gx0__-ltBZY!Af+wjArIZ`XkO8GPy8jOCF7%;ir2;gWC z7rA-O!Bc`IS@W#j%!^Z0`r`|&Cq{d=1)XodSz~lXbt$L1d%D%frjJ>#U8WUg7>ZT2 z>ukQnB^F|4qqFyFx_7itbNl2}mhXlg;nRM;VXu}r{KO}LQNu#qFG0L|v8l&d-Z#^( z{I4|=mD<7b=IoR!A6b{2U)6bzTVZ0GEKl6&DZAe2-e2$MNcpFJr;hIbzwRH?XT!INjoXaoFfcGMc)I$ztaD0e0swu^ B6IcKM literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilek4.png b/wadsrc_bm/static/brightmaps/doom/vilek4.png new file mode 100644 index 0000000000000000000000000000000000000000..268241dd6b606c4832a223ed4138522445787994 GIT binary patch literal 561 zcmeAS@N?(olHy`uVBq!ia0y~yU~pq#V6bChW?*1QDJ+m?U|^64@Ck9fc=6)4ZQEwg zo^4}e)6mcm7#NtAmd3!qAZu)OoPmMyil>WXNX4zISI4 z9S*!cX7p^I)E@T(ufqf%e7!E;vncn@;kaYczd|pYY;no^-??v%=f7Z?w{P}&&az!> zdV8+7`ZnL+->USIvXY);J9Db*%)cjfK;k4tw{;{-8PG*^BF!NB&YgGU3}#W|QR-55G&?-!&!Y51*v_ zW#+EM$t!R5ZZ5y^;y2^m{d@m*)t5B}UD#oC?8S#~k2l*hFqxUSa>V|RX=gg10{>H9O6Z)fh;KT-GoM*R!@{nuM2_$L2;m8mv&>eaTFhXwAP z^f|PQ-&mmhy!M5XSjQIv2a;Z_*|p~7qMrHhDmR&#%@V=kpYr=zVhK&ykl0}V`MRWeV zx3hA;SiZT`n0K-(e@jvEU4vWamrl85vaKrR@w{o$&jNRTi>j!7zAZW}@5$DUe_#D) Zy4k*CM(>&3G7Jn144$rjF6*2UngIB%4YvRQ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilek5.png b/wadsrc_bm/static/brightmaps/doom/vilek5.png new file mode 100644 index 0000000000000000000000000000000000000000..a2d742dee5d55f4561300044becfc68756d70850 GIT binary patch literal 632 zcmeAS@N?(olHy`uVBq!ia0y~yU@&B0U~phzW?*1&Jk#XOz`!6E;1l9nQ&aQd!-tC( zFK*kmZT9Thfq{Vy4Gn2&X*M=C3=9lQWR6HMFffUFx;TbZ-0Hn@w(qur0Q-m9)_qRj zHhfb2rF0Y~A@bv9o=Yxrh6c|2a)Y;LOnCWn~v1z43@mW?b zPr0XypT+t(Sayc8tX<6ztk@l4Dn5mEqRRxEv>BrDW&&~Lxl?+AZ>?UczbRqs0*`OY zH!~Xvo_oW?cJjLV?YgiDkG7ouCt8tQv%T`zp&#>h%1)5|`}L`zFpsC&w7XZ5CR%yb z?%m$}XXjK!ljV19jPAKa9(*!8{aCxklCDMN(dVw~vrM><@3bJFJ=gE|tLJe`6aIc$ z^nQ^StKYM$wg&m$lTYn1mDgM1f3{a9{*39A{Ebt}jDD}+U%IILUDWOi=h-~-kDZCt z*DI;?eDXHI$>Xw1-*wHj@K1u=TlTG-%X^kx=Z^XDRueHzr~5H0dKam0;WwLNzWPh{ z=C|?HeL;QcCEISK^2cpC#jnOGs9&t5Cvs%TC1p)1ophDQ4GG(xhQv9{I`1;GWSfGN z&<0VKl_grK6S^m@ys=d8(D^hU);%Xqt*I99d;0VVb2-PImNQjq|Mowb-%&RId~D>b t`tUbq7yjDLeEXa8XQ6)aU$_5ErChmxg(unTGcYhPc)I$ztaD0e0sxgB9@+o^ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilek6.png b/wadsrc_bm/static/brightmaps/doom/vilek6.png new file mode 100644 index 0000000000000000000000000000000000000000..025d95c3ac8dfde932050b58b053c5123b57c175 GIT binary patch literal 553 zcmeAS@N?(olHy`uVBq!ia0y~yV9;S;U~phzW?*2LJf}mLfq_9fz$e7@!-o$SFJ9cX zZQJbGv(wVj0s{jZ8X9bDY#10AQlIfnXJBAF>FMGaQgLhP72ipV6-3wz&c-NgT%C4* z*0w6%Og;m}8O#m4_`IGoC>AhCT726R5~ZFQ;d6DzrTB;Q`RD6%pVa>C|1DGO+RYiZ z;DpRHSkKzTEP*rZ6wwuCmX1a~)=#EDBC?x|*11 zp}6)!_BO4JA?&*ie&?v(N~sK-wD7aB|Kz|OG3h^-1zpiwynJrhkJ7o0KQ8=Os<14I z!I^Ev-)MDVDM`KVu9}yt-ZR+)XElN55cW8;- z`?}mJDL?;VZP)r2GE;3^;{Eak4;Sda{-NHu)cDHr|9!1fiqF{n_*>nSyJO$cH?uy> zR;l2b{3iI#_v047HGY|;z4lOl^yZ(_t_o|t7lG|8v)A=YdbErDwmTUmr(AY$d*^!Q zGcOGBdT`|}mfO|lzvDs`WiHo#2%mNPyUOm%=TnSDzs!$%FQ0g0`n&Bbm1Z(9 PFfe$!`njxgN@xNALGl4u literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilek7.png b/wadsrc_bm/static/brightmaps/doom/vilek7.png new file mode 100644 index 0000000000000000000000000000000000000000..cadd45a6715615670267b9ab1dba8fcfa89e2d34 GIT binary patch literal 674 zcmeAS@N?(olHy`uVBq!ia0y~yV6bLjV6bOlW?*1gGi&WM1_lP{0G|-o4<9~Uym)cj zwrzodfi^ZaX=!P*XU}eEXkcJqD15ppiGhL1${9!-kv-9pG z$%WNDn{wPUZiev`X3I>1?q&j? zt)Dy1=zm}Etg%S8p*i#ZryD(0)|ESjLw3rYpS^v_szv9@kL!e=al5y5o^EsCg=aGg z9@sr?Vqq)Ua`bmtrqyTHV?`_EotkocF7K^#JFYYN)YL9rv2E!_0W-HvKF-5YJjHsu zPIe;q0-^2Ct-~hlY`U6t(<#vD+uNf{Gz}KsiAv`_FEYVxu4C`P$*VZG<(!kwH4bYs z+nK(N-Ke9A+mhwnU031X7s~D{n%+;5i#}0edV}raD>ue7Ek!$}ZmQl_>||O~VYsjJ z+6$qj(rtSRrj)-6dOXD_r04U+mD^aDKOYXPD?hW%`|O?=x1VpW+@7>4MkRTvX-uwh z|D0nHmfu%SJpX9^ALc*5yN)E+H2*2oIiZ-nw(jn1>3KaLK7QU?>c)JnQ|$WmHIu!T z^Pk&eH@m!7{w~k2Yo&YJ`@o`Ci-l$l0m4;u2pk zI;^&%c*ok$dhT-{2pOvI$*2s&Z?%k>G^y={HMB_WNJ9n$BJoWiW qXz(ii$>tZ^eg?+`{WzZePXB^%&goj!I$;I|1_n=8KbLh*2~7Z1+DqyH literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilek8.png b/wadsrc_bm/static/brightmaps/doom/vilek8.png new file mode 100644 index 0000000000000000000000000000000000000000..f3a79e724550e229898750a0308bf5044881c18f GIT binary patch literal 678 zcmeAS@N?(olHy`uVBq!ia0y~yU~pz&V6bIjW?*1oIdk$O0|SF}fKQ0)#fuj|eE6_! z+cp~;o7uBxr=_JeG&BST1~M=(Bo}81GcYi@dAc};RNOjy_28si3KHxEueRKN{fkZ0 z`8#Wns(X9y4+gdmZx}w_n8~Af{G35%%^RV`(#l8nPV1Jd`}th?0J}xK*}sPW^GmMP zx%DJ`vwXSZ(V_plDwVp*i!0^@i7mCX_024g`EcpK=i(#hk8Yb1`a0Iw*=pI=S6qRA zh0eO#Ogi_%=6t65hS<=^o`}<&sX6YwOBLQS~_ttNu=yl&vhY z?vS|TOn&FAQ?1FNTc+8l3kbz;TDKvO>C#6bZ;pda3XeJiANHL2nBJAjei{F z@+3NT=AGHBcZ}AqDv+%FG&hj5Q9dBss>R16TxIvI{pmYvSUo1^N=~{e*r62p?Xjri zlJCzsDh+2pbvV$Jw^>5-=X7bu68W2@rm3HfJJg)mdV{ktCO+$}^PUw-?MFO~8lDQ> z>#V*s$y@Q?;srv>FJ8VOX{WO#EOY8n{+wAx&%RGS>bCl?jOXum*>~UL#1z-I++OIG zuHvHP^iSx+*DANdxz4v*mUtYvo%`$F0wWdo4FSoaZgod`S{k+=J|4d1(2IoLTW2L6 zCHEM;DO?(D(H7&ADfivG_loVu_faoju6xaOYMJh#t4n51Fq_%-W8*pg%OWS`sxSWf zm1*bkSE4BHpk|@t2}xm7%ibR%-{Mxj>)&gvSon2`ae`dt+R4uZxnCx~iwZC~;$N+D z?#TMdVLeX_iZy$WoSU$D*Tgn;9>jewOLw rybU`iJSuSs`OEgt#pL|^m-WU?hYHi;3VInB7#KWV{an^LB{Ts5oZ~{Z literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilel1.png b/wadsrc_bm/static/brightmaps/doom/vilel1.png new file mode 100644 index 0000000000000000000000000000000000000000..fbfd4fe4491a49def851de708372cbe919af95e3 GIT binary patch literal 668 zcmeAS@N?(olHy`uVBq!ia0y~yU@&K3V6b6fW?*12FtXpqz`&pw;1lBd`}gnf-@jkH zc=5xB58JkFn>~AWU|?WcT3SOxgN=<10|UcJ>D6%z3`}O8E{-7;x6WSKTeR3ffZ>77 zq0~QY68`IYrz)8?N?*4Wc^wqbvSZgHCC*blts7o*E37hMJRHpS|L7!{U(sA?U(T)* z+qk$p&*GlmKjtaUKN=>-A7!u;im~0GxTMf4+&MLPlF-e<8MTesEzcIMC@KpP75uJH zwP@p%*Tp)qr{@(kDo1WpGy2JNKty%Qqw7AeZg9Mc?0de^X9CkYlQYhG|Eeyu3ZyL& zsd~1}ov-%#_e8Z*JNsPKoZjvHYrOc$$pfS}CfMVY@_W!%SaEdOa=^lj(AE?cagF)rq@GCRd_FFbU^QOEtKHZ7T2 z8*)tl_BzqeW#6a8pINK(JXF2d>s&$fy3XzFoPvg@ym~(7t)FHYyz#<*;b5BoD?RNw@Ar0an1eY_bTB5{%_1OzeH{`+~}!X<#OyS zxAB34jFD`` literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilel2.png b/wadsrc_bm/static/brightmaps/doom/vilel2.png new file mode 100644 index 0000000000000000000000000000000000000000..7e5b9946e09f677d8ce562bd1571bc3ed0e49a24 GIT binary patch literal 625 zcmeAS@N?(olHy`uVBq!ia0y~yV9;VIhE{QCgC1Izg~XZ_71~g@1GN z50q`rUmTiaKjlYRlz{g?E2Z?}k8eZYMt{uS7bTk@Fz4I$GmjSC*_dm=d+cmYzfx#U zysxq13C;d{SI%tFxRRZ5_|wb<;jy7x9!PFId2&a>?_Y9L1bCA7beK-=y{&1oIaEjK zR#02ZTFdW;CzzDQ@-`4&duA`+QOFpNqTRT`C9O)euAe}@y9)LD(~%I+uQY0 zmBF&Sbo;^EOI91+T(Q+SpWp8Bow-gwG~-qJHEw4k^Nd;zf6>q z!?)%dyYngwt21%Vd*9y2_V4-cegDtB|Gro2xb3b$?Qs8&{hxPNX?-lee0KYWSlgFr mVTMbKUp!$@l!?1u&!D5R{*}XTJ0AuH1_n=8KbLh*2~7ZM3@1bY literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilel3.png b/wadsrc_bm/static/brightmaps/doom/vilel3.png new file mode 100644 index 0000000000000000000000000000000000000000..f949c08121c31df700bd4d57621c39b8a178d03e GIT binary patch literal 577 zcmeAS@N?(olHy`uVBq!ia0y~yV6b3dV6bOlW?*1&Un@41fq_9Kz$e7Dyu5ts)T!UU zf48x**|u$4U|`_v*|XEq(k@=S*wE1M;ll@z35SjcGcYjT@N{tuskk-ws$u?O0}+M? zf2Q?qH!_-5tSA}WB%tkEuzAiEE16SW7Sp$yOi8o8n^3vBqj|#rn8Mp8of{`s%@de^ z@9_C=hn4LN-2V6PKFjdyWD&#T6uX9xud0?Gtd$i1zK}0b$X0xM+b)p+*NOF}r>E?g zecP<4#wbv6vw>dYZ>MRiM1T2mp12eFPybD_@UtUT57zpATr$6mbwVXJoyyV2p%U8~A z{=8@Y4VNjGO#H>Qz8tUDuM?O(N4&U6T;ws&$`8}ZJUqj+FI2zV=hGFwpS1cFWcJ#;(t_d4&{;^b>JhAoW#}r9hmi}Ay^4t$6i_NxlVUD=_Qqb#cd6;^S zukEy;!^NLPo-U~3xbM7GLZ(oA_VZcnHB%>szTgfwx+ceEx3P8amY6s1J?2~&(K9ul olyRnL_5O7dpZC{K-^)1d?urR&k8dk6FfcH9y85}Sb4q9e0OUjo0ssI2 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilel4.png b/wadsrc_bm/static/brightmaps/doom/vilel4.png new file mode 100644 index 0000000000000000000000000000000000000000..3d89128749e40274bcce292e66ab3b76032b43b8 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0y~yU~pq#V6b6fW?*2@+<8%efq_9Hz$e7@;>C;Gwr!g| zd$x^@O<-VPT3T8|LjwZ?!wgN0_Y4e-hdo^!Ln>}vy?VB&SwVmy;g-6G(d0RcgWoc% zT&({1d|ku!HpXIqmbm>ACT^`WvTZHTsh{4po8!tS)_)rX^Jiq;+tP6NB&*TV^Nm-v0|g%91R(_k7t+@-q&uQXVr7>g4CLA z-`N!SlqJ4iU){a4T;ga){As%lhbL_5t6D7MruJdemCs6@)1EWwo$sqj-sdAPck6U& zO7!{L6AM%YN@h4LulDwwE#;Fy0t~5yB&Cb$M|=`LiNKN?wY7cSTKLM86zW{)x`Mn_npi$ zP7aAZbKRb8dYAp`#^znmy#9;D{V)ESV0QB1R>Sxg{CkRKFodtaI+KBcfx*+&&t;uc GLK6Ttb^gr& literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilel5.png b/wadsrc_bm/static/brightmaps/doom/vilel5.png new file mode 100644 index 0000000000000000000000000000000000000000..93289dcb8fb2acbe70f1c8a27ccae2f1832b186c GIT binary patch literal 611 zcmeAS@N?(olHy`uVBq!ia0y~yU@&B0V6bIjW?*3WRxl@ofq_9fz$e7@!-o$SFJ9cX zZQJbGvjYPIZES4P($X3l8WsC;7-t>f*8Mo(4&4MBI`Df8SNH6mHt;cBt(6`>#R<%OX`- z%AdS-K7UXkDR&M>_&+9(gPUH>|L<~TWp3?z+bt@ByAxIv#BG~@Z@$BtZ0}Vw_*17; znx6V)x93st%g}A2X5U!~9`99ul-9CwsbxXsE_boR( ztUTu(y4AdtqeNio?{2e&o)7+eU;5ShWlNPJ|F5q>dKZfyn%rhR|D=$$^TOpbTiojz ZqnBRV#eS7PoPmLX!PC{xWt~$(69E6A9Wej^ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilel6.png b/wadsrc_bm/static/brightmaps/doom/vilel6.png new file mode 100644 index 0000000000000000000000000000000000000000..63efe375f79f1dbd1f0ce8572ffc17e1d4f9c9a0 GIT binary patch literal 505 zcmeAS@N?(olHy`uVBq!ia0y~yV9;b>V6bChW?*1&nXCVdfq_9fz$e7@!-o$SFJ7EI zd-k?%+X4dv)6&u!8X9bDY#10Ak{K$c85kI6db&7ym?tlZy(R)L@UYjK7aP@slO2P-hSex zzx&))y|#Gfksmor)gyBoPur?uR#z+TM~=Kr&lW}f+I%kbM5gb|_h)Y{y!Kq}%kzWh zLIXdysCSpXshK^=G(GW4;6}f{S`rhcZ0=aXzA^lKgr>BdTF;xFp!M$>9w=_yxc2tu z$$~uvZYK_2UDUad^Q6*?n5$DV#MVCFe0jlZ6JfI}pV_&5!&_49F1?PtC)~58zcuuH zG@sw=&41SYi?%!=Fn3nL-iTwbR$iKSOz4!yDgO1948KD%{eJrG3QmgGKCyesrMa>j z{{PA_o~N<$jIP&lu2UIqUTZE)xLTohytDoaTYSIdtoZ8LQz!qp7@t~I(i|%i)2^JwOGAsvD;!2Fq?DlwqUQrrz5`Z zov6KL(Ze4m+t*yreI>TqNaVe2b>{Syxh%&$*KP}*{aT7um}|?vKYM@gV{G}CIzKyQ S^BV>R1_n=8KbLh*2~7YPlkLj@ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilel7.png b/wadsrc_bm/static/brightmaps/doom/vilel7.png new file mode 100644 index 0000000000000000000000000000000000000000..d89739cd6201d6657090a885e5ca896a0d37e2a9 GIT binary patch literal 629 zcmeAS@N?(olHy`uVBq!ia0y~yV6bFhV6b6fW?*2@`_0eFz`&pw;1lASpPye|UjE_3 zhl>|4+Su4^+qNw*Ffc7Gt)Zb|_UzdV3=DI2_WfdDVB+_5aSW-rwe_lD|7-&hh6lHQ z*`KhtIO4FJuVYKj)Kt-L97507q_3Gg{CVw4``wkzu3G<3&3gS*DtYq4ptDTBK79Uc ze1rd&-|wFv;!Qj^rG}

SueNNDCBY%&^nZ{Ngk(MwZj?=L<)V`C*@A6`!ut-(Yd} zxUTj|R)(9?1y5N=`-XIFY?vqWLQ5*`>I#;}7So$fGV_Ps&y~GB$MdG}qWZak0;Su+ zV!UK#R%V@T6;O}9%_Pyabj5P>*QL2HcZg3>>}mIOFOJ;xjQMe5#GD%K9cn@;jA|cV ztja3BSTuP{M#kG0v$oqh3$;&7nCss7p`+bVV4-@rboIf^d|tHzi_%=1&udp|PRYC&uzOaHo=8H}!DGQE{U@lV9!+`w zH@NIa^rf82AJaB0t^VQ~+AF#H`zy<9nkyTg&-LfucrEjC)0egH|7C?qBkX^?!e4JbcBv?x=sY`_v@+xcu!##b5vY`}(fq`6?sTdDB8t zqfEndyJyaF4~;!Oqkr`>pZlj~A3An&)vw)>fzg|9uT%SSedfIq)7077QTnTl0QM(UbI`YaYsn4}MH1+t^-#>Ed9=+>dm9ynT(>zW^-*1bS9l8CqSn=}X ukM~v@ZaV+{+!WpO?_YR4obR{#{{2sak8a| zeqH}z`}6#fi8_^jG7D3`P1)h%6=|cY8S3_S-lX?eq`qoNuBLo!*?}p6&CZ3d)6})ur4sv}y!=G=6Ujv2oIPcC8`($)^{^epC7nMw}2@B_8fN zf5`=&}ABxKG*LKY6{(+bRvWQPle!bhM6nB{_*N!5d8MIcZtHuomb=a zQ=*z>A56I_xT`J2;NlymXPFNEnBvmebVtX`#sCU%w#7l6Z-UU*{MiF zg?<<pp#kADRJac^C?dCM8+w5bdX3=E#GelF{r G5}E*}|0pg1 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilem1.png b/wadsrc_bm/static/brightmaps/doom/vilem1.png new file mode 100644 index 0000000000000000000000000000000000000000..bf90c37ae4a530d9d76299fc117b02291a8737df GIT binary patch literal 683 zcmeAS@N?(olHy`uVBq!ia0y~yU@&K3V6b6fW?*12FtXpqz`&p$;1l8+8XEfh_wSgP znD5`eU%Ytn!-o&swr!g|dv-%ZLttQFT3VWojST|>gXja58U_X?drud~kcwMpuh%a7)~t{`y4Zp|>**>l=Jqk!qZxHR(f4(i_F;3y~+g`%$TH?GP~jI?q$49n!fjJh4ub5 za@e*OP81Zr`=~vA=85FlJxkB-?kRS@Dk70IC&$~;^Mx@3!_uCMs$MQ@#In6Z8(0^f zSGp`}&>fSWHbbpNpfylK%{a-{@%WR&PIXV7F}<@ff4D3|=I5-+i^qz3H$2y1$PhcU zKTs)QZ(HV3-WLb%<*;wJ2zFf0-jJ%#{%DKo%jJ8{x3e$E?BCCpe85w`xUR0T0 zw)B``a?cO_@0RkdTTT>n& z)EntYe3zZ%gz;_D)?RnHd@E_vJyAk5}8JZ+GLhm~M5Og&FKg za`R<8{rsQk#+I{IOV%z?O=`LMs%u+7K(OliFF^vO+>G{d9zs8!8Cc5 z>6zM++UAM#J#2n9OFsP3bEG^)=cQz)edoSYvmP?P`>AViYG#jVTuh(moKv?B-FEae uf7e`bv2|*)@p|h_<4>1bRS%!N9sgEi?WsPwTk;GH3=E#GelF{r5}E+L8$eC~ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilem2.png b/wadsrc_bm/static/brightmaps/doom/vilem2.png new file mode 100644 index 0000000000000000000000000000000000000000..b99e00cbec8d0be0d88ad96ccb3cf1ad7144408c GIT binary patch literal 682 zcmeAS@N?(olHy`uVBq!ia0y~yV9;VBVyLB-o96+=CrU+|IM*>>#Erjab`KOb^-xs@19v3vNh|K zUD`ykvg-w<{{2`2`6QLty)#MxZ}s~ z%nR8S42Bi|9#ptXUelbQKT}dH;@=D5t}Q!NRkV`X0L!G@>_M*W2yr>5bqzrJn4$HrAhZ>-)MEa3CdSIe)Y*L@X%V5``@K6V9r#FQoW)g$&DOEX19Ot zZME##_58r>9ghsQ`KpGfDdJ_EckzW99UF z(!XW3#O63IXDWLAqe_kc)`aa07jFL7`eQ(pKQ0qH&F2>XZpjf7 z*Lt3%GkNUqO};ld&LmlQ|IPXbnM`jB>>C|t_#_0>zu~D^<G!}r;X1l zWkp}EV`*?YXRY*%ZHdml7av&b?$t5udlAlj@6(Ml*Og*E%uUHeaAX> zZpB&e!oaN;$~5$L{OsPjZu=HLArZ5y*DlRH6)V8v`zUN$;;9P$&)?ewMV{_x`zi8m z*Y(GqTNK5+qqVy9Qr!OquDlVuW^2TY6E~**SuoQeP5VUmk21q+r*AOc++0={*Xt%U z@5hEMkKJyqZDGE5=6_Dmv3+&B#5PP=?>Q$ve3tf$I`ex9;jQFfcH9y85}Sb4q9e0HhNYg8%>k literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilem4.png b/wadsrc_bm/static/brightmaps/doom/vilem4.png new file mode 100644 index 0000000000000000000000000000000000000000..c2c5f9e4659ea45e8b06bf30e3f2ec87a3d646c7 GIT binary patch literal 583 zcmeAS@N?(olHy`uVBq!ia0y~yU~pq#V6b6fW?*2@+<8%efq_9fz$e7@!-o$SFJ9cX zZChYqppA{q?Af!^($X3l8We-^z3L*>-zVK$Hy(@`L z&yjP8zI!}yyW-+|dtG*2V~D-ZWmgtx654VjH*#f-Oda2Yb+`3)+vnWSKl6KA;@y0o zOFN@$4{p#jJO0M?$?I=hFG{_0-6`%Df7c;9ValOoqkU6buU#=bvB*$panxZC9=;VH z+AfAzUVPT{>%hU3jQewBgkJDC9oU%q``MQB_e5{ZzQ^_EYsiSzsQ_DU*YeSOJ^?6I$vxwkOxdH1Y&pPrWP?Q9w?tK;iv^33RI=&YdfAG3<` zEH2H{W=n7T`Rj1Fy8W{?{mOb}nSRr@n%`j!UJ#po`{wQX=0rz>FRd9bXZuv=elE1( vHJfohTfL6^`~RKiwr1b?uy3O9Z?^6wB6XJ|4Q?|qFfe$!`njxgN@xNALiG@K literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilem5.png b/wadsrc_bm/static/brightmaps/doom/vilem5.png new file mode 100644 index 0000000000000000000000000000000000000000..08fa83dbd498a30aa2d02d4de690aecb69aaee73 GIT binary patch literal 636 zcmeAS@N?(olHy`uVBq!ia0y~yU@&B0V6bIjW?*3WRxl@ofq_9fz$e7@!-o$SFJ9cX zZChYqppA{q?Af!^($X3l8W&5GE_M&oHm7H?*$vESXWq`Mn%EfX43ceLWj9uspGrNb zacPsD+fSvQTE6@117oCu9@nu?od4YJYLH>iN-y~*J*ht2>o)#g=fbdf>onK7ySiPT zb#V1a8nf)4oG$r*z4Vo!_p{0G8F){3mlz%0X2bbVdye0n{CSE?%9a%mL)=M|%kJrosx|+aqb8kju@3gixFi|VT=8n= zC(gSuf40>6y9Dptmh=46Jr5n*c?T0!S@MUKP7=&4S|9EKP(QfouOnKj>Nxa{ESl2Fg zwEALXy#C*;^=zHrmN7Kt>Q9$mD3Gl=ZP|n+k}0xt&e+6Vn$rB^gNM_O$hFheHr+4u z;eM5OudcafYIO9jfNeK#TK@4e+h*e7*`lCkrg-yQdVBY>5BW_~4*Xy2d5Zl~>rv*+ z!~N|=GwzBDv8_MC*}K70ra z44gfCc0)r$T3Xt+ZQE>YY#10AYQC-&WME)i=;`7ZQgLhPmA!d~3%5T;{puP)^LEO|cv^wSB|pBB_FV4b{R*_sNmuup+-koVwe{MeoHarMdetYd=xN-& zBzW(%RH{7Vv^inX*OX28Kg4JSX}5efmk!w%qWW50LY}!L?Y?1)eBpwo-*1k8$@kpx z>E`;+4F0dgH-DI;zID%!u!Yg*s1yUZt)q)lZt=kMX8$??ebnP$rg9fj^&;KkBs0h zE5H3Ae!4-+Lz$KGt9Rb#ja372zwZ*NZF+xm*&FsdTNrcdLBG YIV;lFzskpWE>fZia1|kd}3^qJg^nE@- zPI5KN!ZRz+pN#NMzwRTG2^r0+K>_#;nFsPIMXR7?iSp$2y`)Go1fgU zed}s7EhPudb8#1Q^w_UDba8Lks@117V{VLX@u{gvYYg)x^q;YZPh8N|;x+9Uho+x? zUzzAMnRb_DwdtYD*S%9#Vc@v^<&yN8i@$CZ@i5%&UHf2JppU@P6q(p!t zFgsolclUhtj@0=ZpBk*@`MbAg!s?@c1Ehc54tRK1^FEL1YW2|Dyp{Dk*UZ_R&~7#T z+VpD|??~QCbV{iWetXRHydc}d*0rx5ojqu5=g4vT(V}ffR=+G?XmI!S;_$`0->v90 lf6958{g&c4|Mgep!@enPVJg^kl7WGN!PC{xWt~$(698luC$|6q literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilem8.png b/wadsrc_bm/static/brightmaps/doom/vilem8.png new file mode 100644 index 0000000000000000000000000000000000000000..9e4b78505ec28b280dba4ec68b69203f7e8f43ec GIT binary patch literal 651 zcmeAS@N?(olHy`uVBq!ia0y~yU~pz&V6bLkW?*2rG*#;j0|SFxfKP~PW@e_1jm^c2 z7e9RX5EvMkmX~FfcHz@k-p!z`&&8>EaktaqH++!~WR@A`B0rt(6)} z*7S+w@j2(aHVI2AKRmG}Flq9}bxo1lNBcI5axQsx|JsrziXY}kpZ~o4`@FZ$pHDxX z{`&iA@yS+wcb+flo2*mil_j3Mv&QR>i}&75lP&tZj1&7Fe4T*pZoVPZnb2LRX;yu^M z(O0*rNKeBfW=-z{4UHBJ(~4csd}386cslu-bzEuLTe(c8TRuy@^057lej0?^PK&>Z>x{5YC&&y->KW*d}nt*o-#+^*5CD7 z7uU?%CgSW^H(!>eV#8ZDS+?2UCKDf*U-|UF=0%D6)f7{u%z&qhEtmdfzqH2Na#qO7 z2)hZ>#D8X7s+saLdCKHHJ|{j-tm$cv3Hs=fWizvK-i@EmkKU>;dC9*+-E`)ps#u=R zy^SktTQ)TpG>@T$FpYJpRiAEQc0afJKyb6*4+BH z@_MwS0d zK6UEUwQJWZD=Wvu#N_Aa|Ni~^`}gmGfq^zQHfd>TvuDq4XlU5BZQI3*7e9RXz`(%p zE;4ol0|PUYr;B4q#jUN=JBt<@2)Nu-o^3G8`NMzt-FKBAOEg<-%VIS=a&)nKv8UX# zda1+p2etU-ec!OFCwj(JsY3C|GjwkmcHceF)pERt**x5^RGUxrc;JQTG506z+GPumdTva8xcUhSvLe_KAA zGg+FUn=Ag*asIKkL5u$}eV?PCL0XThrCuQ6`w&Av!R50_%?NA<&25{f9#V|4^dC@S<}XP|EqdbQ&~@o+>@fHV87)-kFPJk zQsa2s!-gq4sO`dx>s*%p5Ba7EcGrlUv8d}+{;K4^<5a4Aa$?l3+&Rbed15m2&z_w1 zF8STr&zTRx`^5D9B$tCb@U+CP_wz#5Pj@)~h?PgTc;|(t z4|(w{+KWR^Ej<_NB^J4B-ej$CDY@tBIj2h4mIUlA>SAoPzUh>ZUg{XRXWLr7X}ZVf zHc5S96I;V`ThXmsLgi`Ah1D5)dw;Dme-pGuFE`GhBinn{2D@u=RY3=yvCek-Ey4WF zSNH8+)5Uql{=&JwikWhnpQlKh`PEb*7DD1N%bF0#0r16WRThtv=$Wlm48y z2_AeOV^`^F22{T>Y1=+WOIGV{(}~QRNf)Z_Z(poYJGeIN=Z2!iC9;#;(%!yJc-nF6c)*3CJ@>;zj#(e;eQ;7w?&`0;jf?!t z|KFLpFX_v|o0@97xVCR`J*Ho9|6!bh{q)&4j|yq;oVUnyu z4_sK5u=L(>35Iv?^8eK(YaQl19`W$h<|w{ECCj{3h7Uyka7P!v*1gQVT$X`>fx*+& K&t;ucLK6T!#GK>+ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilen2.png b/wadsrc_bm/static/brightmaps/doom/vilen2.png new file mode 100644 index 0000000000000000000000000000000000000000..1979d5b7670514d2e0fdf027a8d4911f12637196 GIT binary patch literal 895 zcmeAS@N?(olHy`uVBq!ia0y~yU~pw%U~pq$W?*2*Fn8I)z`$S-;1lAyckkYF=gzHN zySA~hv8JZx`}gm^fB&|zu?Y+eY-ngmOG}$Qd-k?%+b&+b_~F9`1_lNfgAcD67?`;{ zT^vIyZf(70Uwq3zgyBQYqIZAU_P%?0LTq1Caiq~Qa{cK4-#ao^{k^g-bl^11ie^c!L6Q?B}^%@xgcW~qN_dnEGgmpxUEna_Sd%zA#K!+y`qOe1^lC%-!<>6S=u zob1_t{%cC6eS`4U=d;sJXit_>T&-TLzH`wMGo_YkC%KY4ru(wxYitO)UgF+T^V^|c zt=RdL<^J^^ZF^=b^l>U$#N_iG6Zl$gQ7ac7+@-+bk@$!~_H2mD%L2E_k9&?W#<8#{ zH62Y4opr_a&!-@j$Lu0W=l9S36~`mE-Y4zy@x1Ma4HJ)wSDzBwHEH)U`2x2GdrXc^ zsC!wqew9PgIvL-y#tG|LC0DR-esZWIrR9SXPyMAX`DHDM=MA@LoqK=iLBtdB#mA0l z8%PMS>E1Pv{Tgz9YQ@GK5=$>Tvv4MPTkpM|++Ms#?7w((k;t;e+Sd>JwOP5mBmcyY9qjDB&$Ra~wmEh+Zl1|Z!Fh#! zlUAvl%oI`e-uN-Rckj~>KbNCV`m`6D&9H4#>bZXFd3wc>)2w%s+6qo?xSGe*zlmeZ ze9e6)g%@m{HP=3g+dbEGrsw=q2D)jhKdZY>om0rQbN-2Q2iMBJytMg}?3czfDU1G} zO-)~?VL4Sw_k4=l<=;V*t!rP(9$?vZMPi!re(x8%tft>L?+TnUvm|il+E3?0Q=%6b zoC-5pn!EXC^?Z}ab>SC}-R4y?+>^V$QeTfpUj1!a`p#)D=IPfnYOtISS>Pm_%)r3F N;OXk;vd$@?2>|?`s~-RW literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilen3.png b/wadsrc_bm/static/brightmaps/doom/vilen3.png new file mode 100644 index 0000000000000000000000000000000000000000..8a9e3c5d9011c769e666e620034be58c9cb7ec27 GIT binary patch literal 829 zcmeAS@N?(olHy`uVBq!ia0y~yU`S?QU~pk!W?*1Q-!n~vfq_9Wz$e7@_wV1|zkhFN zXqY{Fc3@!Owr$(e($X$oyl7)%^Wnn>1_p*1cljh47?`emx;TbZ+?qP=eEuQ_k>g+O zBl_buCOsDH?zJ_$qAH`Rz0%#)L~i;Sp>Mm^%q+;3a(;G=A;_pcH9cyP&s@fbKW6yv z%fGk2Quof6>g>Xv-?70FlPjD_Ol$0u2aHHzOj=N5QaT!{HDPBQ=QFojd(Jr7OT<37cfHdu*V5D(&Sxj8cy3Gl zIfI!s_U7!|mxe1cZ*4yi^_g}5_vy*86JEx9&9_hdX5QrTc;4;!f{7t2O>-Mhx))94 z$ozD=>DielpFBR>5(rse;Es3~Z6|sv3sZJ~p zr*f#eZE}3{-!@z6$fCGfA&c#Yvjs#OCq9vgx19GXT%nU+H7$PgDbw?%vq$_!nYK9#W$gb)#7N-G7#KWV{an^LB{Ts5%CvcW literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilen4.png b/wadsrc_bm/static/brightmaps/doom/vilen4.png new file mode 100644 index 0000000000000000000000000000000000000000..1f8dd401fc43d73973f2c30ba0994b64ca7195e5 GIT binary patch literal 800 zcmeAS@N?(olHy`uVBq!ia0y~yUx;TbZ+?smLuz0qC2*ZPv zQ*$(}x2=CJdMEj~DzBVuLHF{w**_X|(=OOQNIBcaylhUh=8N#KNxlLR0c#G>YMMV0}3= zr150M%LCTMPyCaFeyxu`e)_so%pMP|3AvlxLj9^&PkrDJeE;16okKUw_f$O#?f9-- zP|bgUC-G*RK$!6|j_I?!KFEHUzi)DC-l5NGkM?rx)?&dIvm7~AfE>4SU>$cP^!SL&mm9vlU^gG?U;Yag@vK>XU zm&(q1cxdf9QR%u{x4D>3eBbc@K@<0!mGQ6Zu3a}@!FqeeJip&o_MN*;UnFsdDXhJa zTeHov#r&M>3$cHN+m;xe5`A@C-cEaGL+HhM@6vB}_9r+w6mEKw`(%rg`G@Iidksof z|D2$9sg+;Ffb+NI-1b6ae!10`Id*ZD&;7(wn)Fn?Wbv_QI|`Ng<-7|oXtgD^|M-3M z@%d>7UrssSd^}hpMkMOM^NUBOpKaQc>t*P6G*$JzfLveyMhR)99$v$3EjOH;=2-4r zAYD{xQV_$Hm#KN|xVqr8Z;JyL^*hDHG-uyEvUA5y2SGC%|22aBiaH-;eq7e@|1Gpq zIep3N@_$pC-YD!eamv2i={;rQ|ERZpR}A~){Dkr?+6;b}@;uLJegB`~^~V>U7DWl? R85kHCJYD@<);T3K0RZ)JfqDP{ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilen5.png b/wadsrc_bm/static/brightmaps/doom/vilen5.png new file mode 100644 index 0000000000000000000000000000000000000000..616209e86b2ac2420339434eaecd25b633f9eba3 GIT binary patch literal 556 zcmeAS@N?(olHy`uVBq!ia0y~yU@&4}U~pk!W?*12%&LxKU|5`0=Jmy?Qe z{?*2wo3gHJ?w#7uWk;)LoPG9f{j_7e@7{H1WlTD8_0#0*bLBI57w$QJHM5Z^=!MEe zM}D0Go@0#vPIFjkR&mYbYSh0n*TeL(SNnnOv%S@ymI|j|PU@I9eaRC4;>k6ya-EmF znfxo^eRqzZ`qLRt^4@=&=_!8l`n-z=bA>iXXfAP6Qs|JI@;$e&V8*mbE2V1^H_N+VDNPHb6Mw<&;$UBGy6vX literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilen6.png b/wadsrc_bm/static/brightmaps/doom/vilen6.png new file mode 100644 index 0000000000000000000000000000000000000000..99418df5c72483732ee417e20fe7712bff5f8fea GIT binary patch literal 618 zcmeAS@N?(olHy`uVBq!ia0y~yV6bLjU~pk!W?*1ATOTlmfq_9Tz$e7@_wU~qFJAoc z;ls9V+h)(6-O$hw7#NtAmS$sP!@$6>EBkFV0|OJgr;B4q#jT}Reb>!45MW4{A}vtV zApV_2W8uYUH;2XB*EB4WQTU^?I!UH%>a80U*L@G}%Wa>&oWav(c9c`#r_5uIH~Q+> z%C4Q)Z-4E}>`PHo+`@$B-8%E3wR8mYR{JKeiCL{u#-Da=|BIqfrHj&! zOw#=RK20zFG&z3fLd%~gKW{j-TjSO>kEhFfcRmlVpS|Trosu$%d}h94Xn@jbbNhz>~H@0;5o~B)H2<^e>;#;>wWLC#U7;ZB)b*z&Y%3fH&I-5@df_~z9o6HD8Za#nSu zt*MmpGY|Q3wkH1b=Pwo=4=nDN>pkDI+ghyZ+`Kv&;d={Y7N7aw|5EJnzm~9jo0-q$ zbDZvzJ9}qpY?Dj5FMIfb6OTGJO^NMM$zS;C*olI*zhh=s{1AWPWz27TU1GJ+)8_}n zrxoM`KKpp_MAnWH-a~CO*X!`6))$1^{96}t`_%X8%Ys5?FP{43-^DWFVdQ&MBb@04F*%+yDRo literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilen7.png b/wadsrc_bm/static/brightmaps/doom/vilen7.png new file mode 100644 index 0000000000000000000000000000000000000000..90fd7c9d0e9231bfe315273dc5b2802da03f9646 GIT binary patch literal 799 zcmeAS@N?(olHy`uVBq!ia0y~yU`S+OU~pz(W?*2b^C?@)z`&pw;1lBd`}gnf-@kwO z@ZsXci`%wsn>~AWLqkJgU|?EWnvIPO0|UbvPHS}r2Bw{!E{-7;x7J>_@4sar!cg!| zx#0eTGoi0!UWC57F@vL2)lbqoK{)SKK%#oE_?!bFE3InIU0K=rKKR#%GU=~}vRu7Kvw?ZQ3m(b@}xdURYnE~aZwWS3Z{b5u@m zjmyL0?|Rz=_t&$%dz-dn!N^J^Y_CmqBq!nobB}HdDTR}gA?no zzj^ZYh;<34<|WgXuR3xYxziHU#Js$YEwo-MxUb|uO5F>AiE%8>+oh%-;$ukIX3FI{ z*&}FG_|K5s6!w_rlaG#{un?$FDov2^YrZb;?`^Pe7u)-N(yac4E2LWL_el00d+@E> z(PNq8Pu*5E0jDL}6O!G#wG9kA*!?#=IeKdDd%x5CEx`=Oo=U~vcKR7K@AR7OLeo61 zbKdDGm1{e5b=KYMPEVfbYw^y|=`F8)8%hpXn zX?vYEdii&pn{m!*<7c5MWj>Qvtzg>5e`rnkmAsXbH^1B~4~>~Gsbceu3z0e)bb`$e!E>A Q0|Nttr>mdKI;Vst02N7nO8@`> literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilen8.png b/wadsrc_bm/static/brightmaps/doom/vilen8.png new file mode 100644 index 0000000000000000000000000000000000000000..4ba737c78167df6c749e0aca89da5e90aa25a537 GIT binary patch literal 965 zcmeAS@N?(olHy`uVBq!ia0y~yU`S+OU~pz(W?*2b^C?@)z`&pq;1lBd`Sa)R-@pI< z{rlp@i`%ws`|#m|jg8Ih*|QrO8Uh0Y)6&uy7#MDeT)WS}z#QZ0;uunKYwdL3yxSHc z$9K+^sDeZgE`HQ~b3}ph;ix(zb*e z!G(`O0<;m+PK7+Ukvo_pKf}l`!w&Q+T+)mC@-s$670M#|_I8mDpM7?Zis9@`8Xp{cF}(Glerys_x^D1`@PBKq0|JHro_v|Dd!1l#r{mj$KyFxYo9OqbktaJ@-g%1s*Wq7 zUGtALPu}2WQ{|R&a*6i(OHN+>F2R>I<_n6Y=|8@xu&m>8-m-Z5JH-?w`B)<}pWy zX3xd4HoKOWT$b6sXwId?#kSIN}(->Zud2d_(=#1OanxiEH#@I9<9(LAq`-~gTrv!H z@(eZ8KQ74HQM~2DOUD-517OYH??f(s^6=H0A^E zg9-DS8k&RLJie|`y?SWswh0#+bXHBvSame$uxwEMjr|qwllnSaUgtcVx#BXn^{GkQ z4jtXXP-eV0_Pn^QsbIoljqsf<>0G*k!ftsdj4NA@z3nT?ExMhsP=aUabnVHvcO7#o z__EP>Wu(qZmvqJLrqgekN@py7S|a_)_k8mn8IIH&C!))?ZHRwhey~3FhQsEjg_}@lySZ8U)-TC;kASTaoBu2<+LB=IX^@v6ma|}2N?R#sS=yGP2TC(HZY;6NJj=AE zwD^R&&CULv59#~seGCf1Z!P$}?8(fHub2O4$eO1kS7P;Z`msw5hpoR)-Ryb#56Av( z^_zn{Pu@&9eD>{zzjN=dsM^-}a7OFXqmzYy=2Qh9p7g!{4cn67h&$8LT(|8_uYJn> z=8|8gz}jo3-AjtMpLrWF%S4yEHm$RKlgI2UZ!Gk5E*(#GHu-cs?_;lLTeR7VN;?-9 zqsb4s=y z*J)2Jjz7GzXM@GGr%t?1x3=ymUSRU}#D4}A_e1XvM(q5~z`(%Z>FVdQ&MBb@02dpz AUjP6A literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vileo2.png b/wadsrc_bm/static/brightmaps/doom/vileo2.png new file mode 100644 index 0000000000000000000000000000000000000000..375580791325669db6234e3827add52725a11134 GIT binary patch literal 959 zcmeAS@N?(olHy`uVBq!ia0y~yU~pkzVDMpKW?*1Y%j0>&z`&pq;1lBd`Sa)R-@pI< z{oBUICNMCtp`jryEp7Jf+1s{lyLj>9hYueZ7#NN(dOe?kfjP|6#WAGf*4}H@#j_m* z7!v-rO?kD(XswL-6sMxJ7`HudF4@dk=p&GDeTMVO5Q{r=XS+<@F-1Xzzg~~KJy&P` z(iFAH+851F-+PzYAIGY_{@dDn@{=CbPYn7c{^amYN27n$pWd1l-g&op^;$)R>37|4 zg_-kBaNz#(TXs_XUKP1dlVTV7Tl=57&~I8hT_QH9mGN7Cndc4FFrnm<`j3-D7T&78 zI44ErhT_wjZ%X3F3?^xn{hw5FD%-MW;tTJYHnV1}d6~PN+3J`@3HRJ>%hZ;4ukhYt z@!_(UEW1gy(mAEKW|^BlPF_DLxoKy<=R)0$Hx)mr?UWXswLIfXxVPFvqt{QOR|VNk zImW2ilBz4Ie!A|LOqy`)w60YGO{>?awz^HPoo0LWmDb-U3R4^=NUXPzY=0ALpM3Fg zHIq%T5D&|74)Y}qN&8+KPue<{`;iJ8(@KSo%M*f@+q1uyOum!jv8Gae-+E;YZ|_&% zdHN!zUD#sDsblIMv@+x096_7MDnBhHcz)&1;7z^%G%@sM7{eiH(<6xveF@%6^h8v? zmEPDgds4(y-%j_Rfs=U@E6f|!oNeByi&QVmS-IFxk4JsYW+Q>+8jk|iE|hqvI)7lE z(!I@Ls{7$iU2_(poL5enVmG%fRgC!9YCGvur{$COg$;KdO9e#|t=3G>xm~t*CD*K* zJj>$}TXSxn-@{P3XHVtZS;fqE<;`uIQWjj^_B$&>!JXy+qE9qMQijg`7;&GnwGKcsOibMt~HtpZ2K0i zZr|M&(S1U6kGkXhn_54QowO0^Ib*tW?q<=Qng6mLXJ2fy6O!L0_PPGCiijYybg8|i zV6_FsPkq1Z`#0VAh;NEPqMKsm6dGPVdaFM5 znCHE7!WV;VZohr{b0cT4r%?UVAL5%r+)v)`Yf7+se>&CM;M0=5Dm@>2cg@$>R>Z0K ahfQ&6pOhBgk_-k01_n=8KbLh*2~7Zs485BG literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vileo3.png b/wadsrc_bm/static/brightmaps/doom/vileo3.png new file mode 100644 index 0000000000000000000000000000000000000000..365592a37ab88323a612a733996219de8a2f2c70 GIT binary patch literal 890 zcmeAS@N?(olHy`uVBq!ia0y~yU`S?QU~pw&W?*1g^T4&2fq_9Wz$e7@`}gm^fB)XL zZCgV_!|d6!0|Nuo($X$oyl7)%^Wnn>1_p-PL56H~*1=2t$F@ zrme}>g#-_ta9?5N#C5%|{gA8V?UrW}zE?Cp#|BJUdEL3|&dMx1sh{g@+Ak#uTep2~ znfK$Q{Kos$rY-IreG==p{#Rj>jnQpUG4B(IP72;w?do&M+i1#4c7gr=ZTFTipLjLP zX4CiXjf!f?T_&@gCi$=YzsJ7p=#x56xtqT~{Vo^$Se-q|#-cpQs79^-&2sA>jgxMB z8O?S%mG^%pPpVJcDi6D<%8yPgbLL=U`!q)@scOT<+dj8G9e5&i*FwK$)2oULitBv* z*)F9%Xf&PwXVODUg)p(zhc}w_?%`^>UMlB#Qv$qN7U89FPcd=xM}pgVmA>q^IVmGXPV ztRDHw*nSc|L7pt*)dk@9yAT z2hYdfo_lq#o=U|e?J4j5%-^;rZCb)?yw~NM+n#&7yI0C`ad^3DER8l%>?~|s_G?Fs z$Ay$0BdrPCo=wXa+J|W<9W^Ow-x)2{uX3)=e^$4Lj_##Xb~C?r9e)uaWbQS+bho^o z1_lNOPgg&ebxsLQ E00|6)XJ4hsW&WGTXe0M81HD zyc5NR7GLDJd01V)d$+k;-0OrC|A~@1w-@j8-y0gj?C!)H{;>Mor3-gOH&1JO=Gn^3 zQMYBOpsV{~>HLdJlb;re+WpwI+&fi8`P8~;%aktqn{#RUIn1BFPxIurikH$4eZEio z_vZK3!zw?@8GM}lB?G&AKV8f=U-hx?XHu$w~X85TgIvVzplJD zNjE-JFLC8y{EhA-RXg8p5R<<$r+K}J0dIAL+PQ73oLinYc9+I$sBd!*DwesOy=J#) z^4?O{c8=)VADo{piBh>1&iMJ`Ws99M7v@ful4w^yx>2~a;{(flv+gSbPT>zUY;(nS zb4N85Z^)-8a(2V^aj+?I+2&x9wh=!O) t*nj(c=KJ%vi9Lt&-#%!0|KX|rgsWe}Ln_t(GB7YOc)I$ztaD0e0s!6Dp6~zw literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vileo5.png b/wadsrc_bm/static/brightmaps/doom/vileo5.png new file mode 100644 index 0000000000000000000000000000000000000000..7c0339697838cc481b7aaa5db56691c3e651ce8a GIT binary patch literal 577 zcmeAS@N?(olHy`uVBq!ia0y~yU@&4}U~pk!W?*12%&LxKU|dq+cYWYD?G zpNjQWEw?*-`qyu8j{m`h4VT%B$o@wci{ z9({2Ck#Z&I-+U9TrT!_5j{fUcl=#PAU9ayUR{cbDRa5@Oc8P`s3Cdy(pH56Icv;(} zth3%eL(Fj61L>_-nOsf31i1otF{Eebt^COz`&b)_JdFm-_4P)rAG+Um^n1ZrwTc+amwl z!#y+anAlIhJ@Zp+q}ulzQwu-OD?GWaZok{A(gObQFKv_jO100Od-tbxZQ`1j1*L8a z8n#GTt!kPV@j!y7R@3U&yHc=+AZTzI_Gz=<9SyPcsENr9{2t4LjV{PO%-pQ3Q~J)|)JAIBFCu}`q8mo=38g2XAH)n_J zRR^Qs=xmle&cBKWH!7)|KJ#}?YvGr@w?F4<34BWK+_|ma^slp=wb3cfPuxB~j%y2l nF>OtcKf@4f_)K_n9pjn*1>&bP0l+XkK%q0ta literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vileo6.png b/wadsrc_bm/static/brightmaps/doom/vileo6.png new file mode 100644 index 0000000000000000000000000000000000000000..83fb00eedb637de3c64918e6bb4843614157ae58 GIT binary patch literal 710 zcmeAS@N?(olHy`uVBq!ia0y~yV6bLjU~pk!W?*1ATOTlmfq_9Tz$e7@_wU~qFJ9cX zZQF+rA7;;<9T*tc(9n>UmS$sP!@$5WNpf8T0|QgCr;B4q#jV<_XV)z<5Mf9Vn#W-9 zE^*I{o1JI4JvjP)JEm0n9z9*8_UA;N(afM-vw0WR-qw6{b(*~p&)3tL{9os21^!$0 zCqUx==zTwPvj6IY z*X555%{|4ICq8rkyHWdVgSdXulh zwVus$_fC9!v^QBOh3~g)t=K!uF5Q#ccKz2a4Bnk9`AjFq)FgUSu6C{4WC2&pgxhzP z=)`QishT_g&L2}>rp?)MuHp8#HKSf%EB>U$oF3)4Y~6JB&U1&%H~pHm=Ue?&-D5Vp zo>e}{a5A~A{{Ac1#Mhe&y#H1#Ez{Y-`^h+VbLji6x~31JC$sdWz4c#j>z-~mOKAZ| zjMc_~l9_q2hUeL}&h7JMjpGh&oWmO5wRE$9M3ZX#iKVN%OsB5-Y38s_@zclNbPktg zFRbq$D4oCX!u`^1uSB;TID7HU#)54oKkNDe>t1Z-t}jTOakfC#DeUp1qq4I~ZBA#j z>|~Zs=HR;=vr$}IZRS=}t`{QP|1%lPdA9BIOP%)3Hgb0i(^@T03mlp3b8DG)T1C>+ zzKz`}g0! ze}DM!;o`-M+qP|+J$rUTLqlL-U|L$5jg1Wh14H@CnmG&%%rc%Xjv*DdrcU!Mx@918 zytuVRxMhxlvWNQQrM$Kdx-)#XdmMSWtXt`E;$6p0<~K!dZg{zfdE1SW@WnCfioCjV zPD|`bH2Cvn-@o^^v3utI{Ik#E+v+6`XSxWvrwjE|Kdf|l^Kjdo2llhqjS0T_Dv{$ zbLaF~iz`g$)$T5@QhI!%uHvp}$&9+!I}&XlDn4KM=EaJ|PV1F#G#&W8NzcCV-==vF zb_BeeqagO;=WQt`m5)a@?iZQsbj>$C!r4PnqP;1w8^8;(vZ6Hk!S# zljQVV>=1Bj;pfO|%T4QUt?m2$`H)3Ph02uVQ>T6?)IQ&KcOOf$xbnf|N2i50Z4@o! zt%~PuN#HtR@485UBhjvDQ)_8;sPme3&fBm3J1mQGzB=^eF6i*SU|gX(QJ~#qbL1up(lMi zo-C7_!fnx`@wp~gqjG+@+TlE=*n=A1l@cf1UKBmoZfEc+Q;qM7*Cy_}6RI}nNrucb zUGJHSBA0!9P9*&D_dU`*UG$Ja`Q?)qcep1!IF&T*jiHXP%--{LGgkzyJ9TnZ4)aO& z|K~$F=9mge7M98v9Cb@wy)-52#W$}i?b*gxo2J%8`R1ouFJ7o7zNaQvrL1O|Ok!Lf6?LMzwzyB0qd<2bpsO7++_-Fv@O ztVQ~RKAUI?Ome+->Bzrr6FpYE%XQRAb80(kr|@r8qlcIBfx{K0Q%-o@RTIwIQTLjK z+kf{H?~Uq4LUTWrZzopr0QzaDQ~&?~ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vileo8.png b/wadsrc_bm/static/brightmaps/doom/vileo8.png new file mode 100644 index 0000000000000000000000000000000000000000..e5097856a0d735b3849cbedf49177eea564237ea GIT binary patch literal 1061 zcmeAS@N?(olHy`uVBq!ia0y~yU`SwKU~p$)W?*38l8)Q@CkAK{Q2|u@85s_ z{(bS{#ckWRefaRf#>Qs$?Ad{VfoW-J4Gj$p3=HvnN4_&KFz@knaSW-rwRQUWzC|7q z2YzqTH%OC9@U3A|Q7c|*_GZ`exLud>0~#M@sB+wk^jar;^i!79sy){q{V4kFxIIWI zqgq0!llANA@5}eq+sNA2|GfJ4WjNDIeFhFie#VyEO=(NFeP=jo7PO3?;hh^>(46T{ zZ`&StTq)qn8&Jc>A;%cO+VcFV;vV)K7KU!O2eA$up7Ko3jJCgg^d|hh{(n9JJx!;h zl{@F$WAWPd_u$IJmUPb3`P&;NvAZ_vr0>aB@yTP<=@&YEtcq8j2c6zQu3c z+W z>k30R4%eV8$&wkohvXJ;Sy>o~D5!jTk;1as?dpF&h2@XAHZXFyRBgH`YJ#h zxt>243eUFfKjvz_AR=#X14q{(mMyD;e=hHw@6Pw)3g?bFvxHOFnO?c|z1n;)@$=7e z8%--lrrSE~HCxt3oNk!%`fYgZKhJ)v%em?kR9d3b zYB!vUo&DqeOk=Z;(-W5lmuKV%ZDLzw6jW*aCWL8T`{9Sz3&jKS`sbaAQ7|a$S{xOA zoACz|1K;k3y+xifyNhxkp7QCRb;B`@_0Kg;$CFdlIXdsAOlE$x;1%2cIBActj!DPe zUGJzo+;WXwx}d=Mjn8I1&e=;Ms*bF$4N<(-E?B^K?vYf&y*X>9J(2$tzn*^lDsZoY>Lx z)%^ZS%c4U&cn#!S3T4+fJ@vh~I_Kp7hMEu23=#rYX9*}=D_fzxb&K2NQ0qnqMZx-( zicL$(7QQx-_IWH8uuuETJ;9r5?%(3F6G{R+YqCVI9J)TMq;Ju&p2K+xQ4Aacv*zkO z7CAe6`|jyx6P{f3`p(_BVZ-dFzqV$G8i{f4pSn6b`yNARXiyXx`5+1oBWR}G)fR_bs$I8%8} zQs;fnjEhx_J7(Uu6>RynYNnQ`ceUFTSMvvHwaJh634i#pjom_LS6cqjr~C3>?e;i$ z`FX>1?u*I_(aIv*7>_P)`F<|-$~OJ4teiT#4K<1sFPVL~`TB44qstBa^72Q%%THYJ dYS|b2vL*Z3J6AOPWME)m@O1TaS?83{1OPZz?1lgU literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilep1.png b/wadsrc_bm/static/brightmaps/doom/vilep1.png new file mode 100644 index 0000000000000000000000000000000000000000..28162cc1d0b35f3886c0304a1b94bfc5138b2f47 GIT binary patch literal 932 zcmeAS@N?(olHy`uVBq!ia0y~yU@&7~V2EO2W?*1ojNNgbfq_9fz$e7@!-o$SFJ9cX zZJUja&FtB;0|Nsa8XD5l(ij*RET6o;z`(%l;_2cTQgN&Hnt$;k0|~Z*JBR0)`z)_k z^DcZJx$5}Tg(r4O94?(HQMFFx<1M90{d*twcT9V6F!2YcO8zIijFq$ft1P$Vy)8I? z?@ZX<8Ef~Y@4V?Z@#ehuGt;;AZa0}dd)Ato`W?x6NoLjgo3u9nl)XK3&AB&QFRr+` zis{{%XS3$J-@TK;SisL_ZE0+6<#XG5L&I;g%&ngfGac4h_qO(`#M~{{*X&$=kjqx= zed#5$==5(NR?pZX9C`Lm{Le2IJDC;C&osW;6>#_tH$!9kikT5DzwbV=jZ~3LHcE|u zBXVF)#$&CXJRb{&Gv!TBRsO!1XBqL8pW#EvgdnB=%r-K|wv{&UDsKr{s=ttVwy2y> z%CA7Jj@ged#5Pu>OuCiGlWP6mfak!Uq@@ur*&Z#i{KsN{*g#&g)=I1ID(9i|{t~Yv z`*P!C3fCBE9)16TS|)N7woGF2edE~TxhTJrH*TP!y-{(xP9%XXH{9CLF6E1ti-`)}E{MN76% zx^VaAEhZV={0+HR_J7qnmA^*o+{bMv%1&RCJMY#u%Z5GopuhdT?_r%49+Erq-tT+0 zc2cCxnkm9t--rCN&FvNWATu-dVZ~bq|G9#K4iC%Lab#v+%{Ne?f+-pExD_$@>=)zH2HOFbJj{~My)=cwGTRHz& z&z7_&NpADZ+*C}Jf1d03Fqw1Zf5w$P9?kY=PORoEF%^Vy|L)i`&#z zHsKzp=Z2fonVFJVrB+=^nbXp<^4Xp_>o|5y>y!^+KI|FCHls^p)dcVLt4$ci1zn!S zeLkjiKCftEYGq?U|A}MgPaolr-<7K6ve%TSa^Wv6xd}WxHLEA+vsP_?c)#v|gUnmL zldS@&ZHdeEOc;D@R%e-rR#@J;w~JeR57XqI{vA%C5-tZ6Hl9$OSDbs}-GmjTlbTmA zV^2Qft$ay&0tcfshhXmk_2XJ=eNNo^nD|w1nuwah<3|qO@;Wb)xP|h0cYj#_uq$>t z@2g{x`Hk<*R~^r}J?*j4JkM+2D`u-+Uq893D`U;wt=7y+d%M$}YL1&Ld`;VGs<1j| zs>B3^XxZr#t^DT{NoKlCnm28tL(WFVlcy(0PWbYpbbm}koB9vmdzP1LTRlAd*;M{* zG~W|{E4)T(^^|8>Ikj5vxgz&JFR2d?VQ*Yw> z_*uXtb76LnaQ@_Jd#_zpRM@!uwO0T4MO?35z7u|Hy`tJI>e5561aE)of+Ye^-94ih zr7C5_XHRY36BzVum8tR9JsXzHZ`{>rlzE=9d-~U>OsA)x<`92SFZuEdy8knQTxFBbSI{eAa}Y!3Nl?PnLBTk`p{>c^+56FC$$1v8^L z|D`;7qTp9l_{m0CO}kKNANS-J!BdvpSJ-H9^2}C?N)gps6(6>Hj{_!Hya=6Qv-tW< zgPGmJ-|YpC3(L(&u4|51lp@t1DKx7)Y|@#ChmyK3{SluQO8LKiVwG5Q)AZJ}MalnX zy$ShqbC-7bztZb*2OYHwr}6AGj^->>^C(TRcUUvVj?ktY#4^P=t`R%W$9oklY+(W@@`DGV3+ik{N9(ta= zEj>5R*#3C3cxKO(*!6e*E0xxpxOP^rxH7lg`fi-AVQNO|rs-Bihm~$G?0jN*`>*?? ztIL0B$eCPCExQ`M{c+UUll*TwMdz7bZ2QXcxI@t+NcTPSv*4`>QdJYLDBk0VKFKH9SteGJviVy0 zB@af!y?5B0(o&8_M&7En_KbXeaQ|=TV?ApgRV)?#S$C+!^18D2s??b!$8zSSTvuMb zV}e7bW7qjv|2BQR<$U-=a&PAxzrT{7H+AgbaX%H5ZguHHl7{7x#>W`#SKym;_2;Df zGYsPoaolx`=1kK+obn^E=A-`<=SRVlE=qTrKfC^X^_QZ_jBKwTy0db|evOVP zk1sshIrUA$ynegi=MOW>oIO?jly&hsjkPHe$6md5l|5;4cU@&}?tdm1yAFo;dMkG@ QFfcH9y85}Sb4q9e08ARmlK=n! literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilep4.png b/wadsrc_bm/static/brightmaps/doom/vilep4.png new file mode 100644 index 0000000000000000000000000000000000000000..2aaaf49a92548548f0ad091261222f7096074a0e GIT binary patch literal 864 zcmeAS@N?(olHy`uVBq!ia0y~yU#C`F)&@9|h&!<%#w6$RD@yD^e1?<(CpP`G)(?mZSbR zesTW(X?j;~-iA!OyKcWveiQjSH}CM>lxVAaC9mxg=RQs8e*V9)wCS5>Yr&aaYuCn} zz2ASvx#frRieHP1%eJlCCco9-8UNwLN;{byM_(n~Stn#?@-*3|KHTlIZP2vG*Pc|r zaOa#gk?$7o_JwU7yVbP~Qugn()p^v_x6Wrfb6M`^jjZ)o(wgkIKTZ!(JS&y$b~~=x z?sr`LEzWC~<8GU|2c64~d8Ql|w9E9`@0_cDN*6BFD?PP--wwgU?*FZ3+_<(Szl8II zp_!X*PuNBx`S-0vb%Zd}6K@zu{&4NNrSA>SnUTUzKeWS=K1_ll#^^T@F zZ*;N^)N2`Hq|8|*?@E2Vl@}H$5`SnSne_j<{o$R5x({NH-sTkB5^L+TA<(Vr!{W7P zKX0$OvZ(uLve=PWvuB6J6!vbexUj1(XQO3yu!j5wcR$_Ft8?NG{@r#h>F_c`Un&3X zZEK}sG&E=PPW^tfz_EV&mv7G&ZjO5(S3T$Gwanak+A$}$nZC0;pOO;Tsb@da`u8^B zxw`jyN~>Hm`7Y0$#eM$D{RG*@*&7pPegE+=CcXIQ>$UHKuep5tn)WJ-VJm;-6tyS! z)=B-|S7&k9ODZCSySrSwj$_X*x!CaJ?xhoLZx{()`}uhG#~X=FYj*E;JMk*jRQTqp z&G~PRrT*R%Cgk{aW$oi*>z>(FM}Bje`s&p>&5aAsnwqg37ryItNxIuPGI9EOfzF(p zviGmlS#LUI6~m!>u~&Qd%+sHm^dbd2^4+S^{p~mDY~~Z6_d_f0miTYki(XHhXW#1G z;rF2Xs&UnuwD$0qPjwxW=G=K}9zJb)ttrRt(7Ig17SH@bZw?NZ=Sx;pvZQ}Zsotbh fJL~D`kNj_14mDQHpK+amfq}u()z4*}Q$iB}@RFZ= literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilep5.png b/wadsrc_bm/static/brightmaps/doom/vilep5.png new file mode 100644 index 0000000000000000000000000000000000000000..8aac2d406b08ded1a7400522b0ba761cd7dc3801 GIT binary patch literal 676 zcmeAS@N?(olHy`uVBq!ia0y~yU@&4}ULHXYiz2yG?l9LBjlm0&x__uE>H~$~sOi`PdFw2G87A|!?65F=%#hXP! z+r1u7l2h51+HhsN_-dZ-@i~#jrU4hDpD+r)_`mk~L*XC4Psg8RnIu=X{?Ytpt5)nc ze!6j{w#d}{E=!-lH)0Q4cbeQv5Oj1db`ELt2sU~p(B|`Uva8b-NlBBFcaqCa@=WAi z<^JmM8eLvRUAf1px(m~m?$MR{Dv+$G=aG3z__1({b4hc&wNwu0rPN;)wyi6d{;M?I z`BOvVy7Ae$M(5Rwxn9S)>ZH5;(dvB~afxX!=iwVX>`GHMtP$?~>6IUKX`)tL#=IV% zoku6}N(;&*J*&A=vPii{Ic``A4@FqD|B03&t+Mpyebs&VmV~sQ8s_l33tUvhWBr_ewh7k z)g(3B1HKdE>?b{$d}XDdg6*qUmFy3BcJ@_Inm$=Y@Qu;8=k0duU+QQyUHSEXyZ?m8 zGHd-6y|#R}Q)o@LIW3y^x9YoDcBAfTt@G8*dKcKv>G<2dkE+xDDf4^n(-wzC2fj1g zvEAB=zFfcH9y85}Sb4q9e08V!Z literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilep6.png b/wadsrc_bm/static/brightmaps/doom/vilep6.png new file mode 100644 index 0000000000000000000000000000000000000000..cce3301a9419559f8d0d1395f7199cbd9e3da602 GIT binary patch literal 678 zcmeAS@N?(olHy`uVBq!ia0y~yV6bFhUN)YYFp=pMy+R#K2_=z{`>oO3xyke?>ES7d2+gX$~W7tFIT2!{q0mM<$Wc2Me5Qs z*-PAOM3;nfy=+@HLGN0_zO#4%MDSfVOnP8uC?Dxg0wx$q% zZOLnS{QUVW+Ra-YE;uE-V8`92Owoh&**Y}=wjP#CW;Ab}q`yFK?I!t5sqW0&xa5yH zbKRA7Wsf@lfAoFFhSC>*OJv1-53Q>Uw+NXpvS*)q zQu&SZrW{SYBD4AUR{Uw*62$Hv{&snzY`xM{v)fgVc>cMp rtlTa?xoY-5$$+WB4yA|GzQ`Nsz7fp2>uJisz`)??>gTe~DWM4fv{gC_ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilep7.png b/wadsrc_bm/static/brightmaps/doom/vilep7.png new file mode 100644 index 0000000000000000000000000000000000000000..e159aeac01640e2686e2d33e8ed699b75f00c4a1 GIT binary patch literal 898 zcmeAS@N?(olHy`uVBq!ia0y~yU`S+OU^LnjY5sh>dG{vEpJViAw6B+U zauL;;l~Bkd`qq0z1;4me$ec?78~MZwSNxC_U&s`mcxa!kALr@W2iI4}_;F~tJk9%A zw{f<>P6I2SfR&eyiM}u}<@fw>Q7|iN21{)@>pbPKz6m?#iKJ*e(!98g>*zW5oJ*M- zT{9Gxg?+c3_~N2yRmu6>!n*&N)8g;Q#`Zp)x^&H{`iG4Rs&sBgdwyAVZ}IwfyARJe zarIN@`g?bDEVq9>A-Tn<^HGqXZAGPo;99Rm>bw0`H%fF*)E2Rwe>+QJhm82?=L>F~ z+s*@RHwF||LLJC@{&i9V|kR8lg;8yvwObYa*&x6qtsaU^Gis&bJra01uxbZO)CscH+J23yuByR!_eEIV@H!R_e#BYzNs27mYN@0 zn0n~W?Wv6~oJ{1O&+%Nm`sFL;x8+~=OM2+e_MG@W@bY(l&%Vi~g>#R*^E`6h@Xfoh zFGue`J9THyoY%MRJzF9lqW1Odr)}5&HlN;CkP^LVw{7}C zRkQk$%FCrk<5ITB#qisBDs9wO_^DNXWS-1MF6-?)7Js$PV{2C4ekWh5U$jyxU7xS@ z`>ah3Pk)Gnt(sov;ZyawY_86w|4p-Q<<7cQZDw{~?81F}mMMki&T}i8U+wC7ba(lJ znYSh&I$o0nA(xptnrwA}Vv&;^u{kqVIQzXE&>4^QgJMHauW`9~4 Q7#J8lUHx3vIVCg!0L0#@AOHXW literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/doom/vilep8.png b/wadsrc_bm/static/brightmaps/doom/vilep8.png new file mode 100644 index 0000000000000000000000000000000000000000..71d88866b1a0a4d70c899f9ca0e7dc86d907b2be GIT binary patch literal 1027 zcmeAS@N?(olHy`uVBq!ia0y~yU`SwKUWu7jMAr-f#PWSC!Y$4Frt8`ZK^yZ(8({9E{ zTP}RxBYVz!gJrq2b-DTGKYumVC%2V67O-#;e6;XXXnt)&+w=9YKOD6ivUD%3V?C$c zShrv3$6l!o+KvCarykh9y78^ogX?A6g%qx89r(XJl5@|*BGC)`Rliy(_|H;3aQUw6 z1zmRvKv%-_cA}QVfwc5hfAr&Gl}}P(i43APtSh&xukf?zP|D| zi@TEB%47Qii{!Rmv}LF|%bmE?^YX=|`#Q}T0|Ym|y*R7Wgzdg-W1Mu%j8)~!B#xT@ z*uk17Vjl#}M26}TQr~N;2f~!@SgDG=%$c3-7 z*o$hI=TtGhnCi(X5Ww3zE2LDUA?e)Y0P8zknHAN0e>Yvo)>)%7qu|`iMy_Uk)h~@g z=^i{gW@t>wVn1IZ_2f(Aw%!TMGiI}Du!^dNweB}^|L{me@l5Q+kk4W(7ATfGu9!DB z=*zE-FI%pJg={o75oZ#N=CwP0v0wbeqNZ%Q7q=CIdAV7d!k+lQRC_8Tyi}2|OzcC? zG}X)DOHM85`{s1;v)H4CXGtNO+b&JwOl4{^bh1yWs9$n6;Nl6nkXM?*kCIr|`8jIq zU&)!Whe>Jo86kNAkDaG4vRQ2|{_{ch#pbqalcs&qKj&1@^uT#a{ccHz{nfJq1K%x+ zy7+v?kE*vzf|#;=-#jb&BKl(K>#~BFP_Jk^#si<%?P(D+`o6X783QNN?h2=+6a3yz zW9WEzRxn_V_AFKflM}zbg{f`Pymg%6%HqFY4y7A3cD)i5;PIKWVBz7ieg;OiRWFw@ zdfnQ_&v3H)_l01M?RtC;eXrLax|+Es^qc$jn(p1lVr2^2^P@hrZMpbP*Z=GHOD9gI zEVxqMFug48?y(f{*$zH)(x)ZHyip1k*|xrn&!We{Z0_X^J8$gNZ^)eR&Wv%{-8nyM z|JiYVEU`>nH#7I~&lk(Dr?BjKw<@xse|uu9v~;A||34S<)zj;4-;jP#DjI3|Z{{3J zf2R`{t~#VFKUwGJ#N+%jfA{$k>EB(Fx<4L!3tj1Na{eQ8Q@eZPq6D7>8^V|-%zPwZ zcwvsgy?bWsL=+mr7(8A5T-G@yGywoHOW{NS literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/BEASI1.png b/wadsrc_bm/static/brightmaps/heretic/BEASI1.png new file mode 100644 index 0000000000000000000000000000000000000000..0a19b43b8bcb863f4abb36259fa278bedb7a07af GIT binary patch literal 123 zcmeAS@N?(olHy`uVBq!ia0y~yU~pkzU~pq(W?*3O7hUj+fq{W7z$e7@|Ns9C3=E-% zF4r+IFc^5cIEGZ*O8&vmDlgF{^7@az#A`-lwbu;FJzpDTkNrB>-~ZKJPX2ZM-wWIe dAD(AoaIHJJ{QJJvJT_R^t(DZFXS40R=^ WW+e3<>tJADVDNPHb6Mw<&;$TNXeNaK literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/BEASI3I7.png b/wadsrc_bm/static/brightmaps/heretic/BEASI3I7.png new file mode 100644 index 0000000000000000000000000000000000000000..d3d7b8f270b4881bf2848d64453c766e17d06345 GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0y~yV2Ed6U~pw*W?*0tJHNu4fq{W7z$e7@|Ns9C3=E-% zF4r+IFc^8dIEGZ*O8(K$@L$4>?|HASkUHbc;stV@ha1i$x|lUE&ipJf^RwX0&&4Th f?={*Z_!z#{83|NBcw@l8z`)??>gTe~DWM4fh5#sT literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/CHDLA0.png b/wadsrc_bm/static/brightmaps/heretic/CHDLA0.png new file mode 100644 index 0000000000000000000000000000000000000000..41a0f6a8841e3a8d579a9ee58630a9ef0853bafe GIT binary patch literal 150 zcmeAS@N?(olHy`uVBq!ia0y~yU@&K3V6b6iW?*3WacRRb1_lPU0G|-o|Ns9pFffE3 zx?IP=z~Jra;uunKEBOaM+kXkS%%Yc{9e(sb{QLjs|M~ydCs+L2|NsBT`cj_x|NsB} z|Np$b!r#yT|C=k6+W-5%pMS}F=9hH>yjSYvJl-!~`J3U(?s?4aTgBcmFfcH9y85}S Ib4q9e0Q})Xz5oCK literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/CHDLB0.png b/wadsrc_bm/static/brightmaps/heretic/CHDLB0.png new file mode 100644 index 0000000000000000000000000000000000000000..cf551809e77064a08900460bb95e94d3abba8f53 GIT binary patch literal 149 zcmeAS@N?(olHy`uVBq!ia0y~yU@&K3V6b6iW?*3WacRRb1_lPU0G|-o|Ns9pFffE3 zx?IP=z~JTS;uunKEBOaM+kXkS%%GQl|L<>p`Sbt$=9ixnepyba`~P14@bmxs|Ns9V zeEh?YfA|0YzkkK>PyPSL|NsB~uTWw?VIRNAGn=z_IT_Ss=EXi>W@2YxU|{fc^>bP0 Hl+XkK4{JjH literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/CHDLC0.png b/wadsrc_bm/static/brightmaps/heretic/CHDLC0.png new file mode 100644 index 0000000000000000000000000000000000000000..b881e82148e1b62c36f6a5d062c3efd63c0520d7 GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0y~yU@&K3V6b6iW?*3WacRRb1_lPU0G|-o|Ns9pFffE3 zx?IP=z~JfW;uunKEBOaM+kXkS%%GRw|G#g3`TPHQ=9l;X|Nd{!e(CkDpMilP^w8xx z1_lN|7$E>+ZnF;A8^gy;Ir|ZuM&B;%Pn5p yX1?3qpYZo+%H03F$+G`>l5ORuJhbtMV3-i)-0imRzA6I)1B0ilpUXO@geCw;-Zj?% literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/CLNKJ0.png b/wadsrc_bm/static/brightmaps/heretic/CLNKJ0.png new file mode 100644 index 0000000000000000000000000000000000000000..3feb2be438356cdc3558bf9d63f64239225bdbc3 GIT binary patch literal 213 zcmeAS@N?(olHy`uVBq!ia0y~yVDMmIU~pq(W?*0l)pRIfU|?Vi@CkAK|NlQoU*qY24kz}tY?k}KpFiy``zD2?^8fN}o6h}v z{+~N>E=$nwgKOIV|Np<5eY2gy=6??e9z0i^$Bm>K7mP?^}N3!uVOW^N${XdFyh*qZLxK>^7Xat?8iIk-TSxk&4{L zDWxtkD{`Xx4@`Plv8}L?M zm+Kf97&d#lIEGZ*I(qT6V3UCW!v$93!-i!WbZ;;&oye!-XziINm)khoeaB46siyPK zE^3Oq%boviI)lTsAPWVd#EZ`2cb8aQC|cCr-&p*w=)|VuQkLlpQg2Eo2?f16tS3}IqmHw`KIoqH%UAgGt(OpaSF!t{3-uF*}N|KG>X7AYB;kXi~}ID&U$ZUG07P2OF1W$b>&TR-~?B z{iv(bI)Rh%GRL;CDpi5t4mKU5*XQHT_bj^oX8ZKH*6Gij>g5~f{n0crWnONR^Tgq- z_7?j~hZiw?zLLFajj#He+OS0K$-zy}Q#-#_DGBjte|5QkD4^h0d+#PUtrvS(#EQSJ zTTm^(viIyZ1sjc3`=rV`-wD0@Z=&20ZMy2b=-X+hzuZ`^S7Y@m>*8vq4V~AU658ME zn`$#HG+KYLEouK1Uclm$UE&{S0^;)Z2GUgMa0(j^NqMsn?jcX5V;J9^AiC zydd|UETh@7V^&Td-aT6ua;4}LzfP8|dA#q;y=y=5?&lAmJNH8AYX$}e22WQ%mvv4F FO#p{>$-4jm literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/CLNKN0.png b/wadsrc_bm/static/brightmaps/heretic/CLNKN0.png new file mode 100644 index 0000000000000000000000000000000000000000..89af9c1b5cc41b0423fb71a91ce020275df11b09 GIT binary patch literal 462 zcmeAS@N?(olHy`uVBq!ia0y~yU~p$(U~pt)W?*30sjltFz`(#3;1lBN;NZZ(z>s-k z^K}LW#%50!$B>F!r56po4?Bpke_(IoYyHK#Wv0y4gQ1ts9$nbi98gp6rw`0o|r8nk#dY^}pAAUw3t-_ov78@(mmFBbG&IyW;3@!8aYV3BFew=06$0*n1A$0Ym@YenS{@P1Zy+u|Fx!G>* zvKRW}aGL4M%eUI5>~mPfLiR_VR$)t1Re80>nw!h=+S-<9lB@4CsGoWj_29)-fA+re zlD+OX?p?U4x<-HFJ^zJ!PGo&uuqVNI{({K~JXII^ULP~%IQA&hCsbsKp3-K8|C=u4 zX^A8&Y*>(T>_F0kF3#NM%%cpY{1fM2`5iR%>Xi?zo0#<5xA5=uT+WzzTrS;dzQ^nf z?~Bd0B-A{u=Jxs(6diItW##^(?k=T8zqfO9CSFu{y6&ZX>Z1^~mHXaa2ud(6;Kyk)8inZe4c%i+H&4 Xuce#Uw6!uYFfe$!`njxgN@xNA-?-22 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXD1.png b/wadsrc_bm/static/brightmaps/heretic/IMPXD1.png new file mode 100644 index 0000000000000000000000000000000000000000..c96bc6c7dcedb67450ac42a546d36e0b6fb1a5f5 GIT binary patch literal 127 zcmeAS@N?(olHy`uVBq!ia0y~yU{GdYU@&52W?*1=GxviE0|NtFfKQ0)|Ns9P7#Kni zU9MwbU@-A?aSW-rmHdOBg%4A{8OL&r~Al1 iJ~jJ*1SwHZ29H(mCzLa@A7)@+VDNPHb6Mw<&;$TqPAd!m literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXD2.png b/wadsrc_bm/static/brightmaps/heretic/IMPXD2.png new file mode 100644 index 0000000000000000000000000000000000000000..1f2befd89b1f5e80a8d3002eb7ab1769f3a2be76 GIT binary patch literal 128 zcmeAS@N?(olHy`uVBq!ia0y~yU{GaXU@&52W?*1=*xZoJz`(#3;1lBd|Nnmm28Pf> zm+Kf97)(7~978H@CI8@Ov6uMQc7?|w8Xb18CUCY40z~JfX=d#Wzp$P!?rYT|o literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXD3.png b/wadsrc_bm/static/brightmaps/heretic/IMPXD3.png new file mode 100644 index 0000000000000000000000000000000000000000..db5360e2d67d62f6befb8c62573e0bdfe7733264 GIT binary patch literal 119 zcmeAS@N?(olHy`uVBq!ia0y~yU@&B0U@&52W?*1Ae{A7L1_lPU0G|-o|Ns9pFffE3 zx?IP=z@X#l;uunKEBOaM8!u1G%liSpY-jx_m-+MFWtO+>FKelK`zdMdmyW-D!pD`# ZAoI(~p=AT>O9lo822WQ%mvv4FO#m!FD1QI| literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXD4.png b/wadsrc_bm/static/brightmaps/heretic/IMPXD4.png new file mode 100644 index 0000000000000000000000000000000000000000..8f0c4212ee5dcd0e7fa4c0b0b7c6148ab4edddd7 GIT binary patch literal 107 zcmeAS@N?(olHy`uVBq!ia0y~yU@!tt<7&%nSCdgyW; z0|SGCr;B4q#jWHY{A}zJ8VlYFKj7E+E8Y8_-|N4_V)o8z#@YMr4O7j}2bkEOx#=yY9;OXk;vd$@?2>>mUE~5Yd literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXD8.png b/wadsrc_bm/static/brightmaps/heretic/IMPXD8.png new file mode 100644 index 0000000000000000000000000000000000000000..df216ac7ceabafb38448da50bd44081f6bfdd04f GIT binary patch literal 137 zcmeAS@N?(olHy`uVBq!ia0y~yV9;Y=U@%~0W?*0lS$%6h0|NtFfKQ0)|Ns9P7#Kni zU9MwbV6gLaaSW-rmHdOBsb1p3iuVGqfjZAj<1|bKX_-)ObN6P ssL0>&;onk+3SNO%T%l`JXEQO(yD8oH=Bw!;1_lNOPgg&ebxsLQ0OkQM`v3p{ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXE1.png b/wadsrc_bm/static/brightmaps/heretic/IMPXE1.png new file mode 100644 index 0000000000000000000000000000000000000000..6adc110cecea1e86dcf2b09f259a72f38a8eb961 GIT binary patch literal 136 zcmeAS@N?(olHy`uVBq!ia0y~yU@%}{V9;e`W?*2r)Kb;Rz`(#3;1lBd|Nnmm28Pf> zm+Kf97;HUV978H@CI8@O<8cY7-^jV|nA#6%r@QVKzwa(T|LKK85shNI45$Qdf3mvz`)??>gTe~DWM4f#wafS literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXE2.png b/wadsrc_bm/static/brightmaps/heretic/IMPXE2.png new file mode 100644 index 0000000000000000000000000000000000000000..518f9c1a7a252a4beb1447b4a5b346978c1b74e5 GIT binary patch literal 132 zcmeAS@N?(olHy`uVBq!ia0y~yU@&E1V9;Y^W?*30WO+E7fq{W7z$e7@|Ns9C3=E-% zF4r+IFj#uJIEGZ*O8&vmW-pmdKI;Vst0AUU;*#H0l literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXE3.png b/wadsrc_bm/static/brightmaps/heretic/IMPXE3.png new file mode 100644 index 0000000000000000000000000000000000000000..316c3ecc3baf8ddda247f2c1739eed5e2bed0c6d GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0y~yV9;b>V9;Y^W?*3GU%iNzfq{W7z$e7@|Ns9C3=E-% zF4r+IFc^8dIEGZ*O8&vm#LFWR^nU~AzqWw;uMb|y<;b^gvEpBNLvf0Is0`y$JLeUx fS4@QYSs8NH{dn-F?vyA40|SGntDnm{r-UW|R=y|5 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXE4.png b/wadsrc_bm/static/brightmaps/heretic/IMPXE4.png new file mode 100644 index 0000000000000000000000000000000000000000..959a5cfd22916fbb195b82e35617769aaa4541bb GIT binary patch literal 117 zcmeAS@N?(olHy`uVBq!ia0y~yU@&B0V9;S?W?*3WCUr=Pfq{W7z$e7@|Ns9C3=E-% zF4r+IFlc$YIEGZ*O8&vm#>><4a(~93=K;TLC;rNG{@-@#YsRDP3rp;$*x4DpV`d0z Xm+oVB=VoDGU|{fc^>bP0l+XkKh`S}q literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXE5.png b/wadsrc_bm/static/brightmaps/heretic/IMPXE5.png new file mode 100644 index 0000000000000000000000000000000000000000..652b426de53284bed7fa094443f72df4b673bca2 GIT binary patch literal 107 zcmeAS@N?(olHy`uVBq!ia0y~yU@&E1V9;e`W?*12S-bHl0|NtFfKQ0)|Ns9P7#Kni zU9MwbU{LUMaSW-rmHdOB&0gZe#rK6B@6{LN7hL)pP-QRW8(huE%4Y8MYQ16<0|Ntt Mr>mdKI;Vst0O&v zm+Kf97%V(p978H@CI8@OvzJ)m^xswdKBMS<#;4&9FGT}(F?$(1yr>WOH(xlQR$pSp lE4x2m;x+zG=KIFT(7W4Ng~veOih+TF!PC{xWt~$(696sTDDVIP literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXE7.png b/wadsrc_bm/static/brightmaps/heretic/IMPXE7.png new file mode 100644 index 0000000000000000000000000000000000000000..96608c7227139e616e7453e02da3718c819ca265 GIT binary patch literal 131 zcmeAS@N?(olHy`uVBq!ia0y~yU{GOTV9;k|W?*30$oWfxfq{W7z$e7@|Ns9C3=E-% zF4r+IFj#oHIEGZ*O8&vmA}>)ex!&;Td*zM$lTZ9(o%~-xi8bL8gO49Wck{{rd-BO51_lOCS3j3^P6Y{(m(B+KGMQw_@I>U{&7PNgZZa@1FnGH9xvX zm+Kf97%V(p978H@CI8@OVwYIq^;bDcpm)`AwH@+KciRK@D_pVX`1;*u#;2i3A-|b{fq}u()z4*}Q$iB}kPs!( literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXF4.png b/wadsrc_bm/static/brightmaps/heretic/IMPXF4.png new file mode 100644 index 0000000000000000000000000000000000000000..9344cf57d526c4adb9affba5fbe4676704d50faa GIT binary patch literal 123 zcmeAS@N?(olHy`uVBq!ia0y~yU@&4}U{GXaW?*1gxH;=M0|NtFfKQ0)|Ns9P7#Kni zU9MwbU@-7>aSW-rmHdOBja`CG{;yoGy}Z|L=NI)~1%C1O?Bicp@9?ue@z;-qj{<&$ d+nW7mDCW7bey7JZbp{3o22WQ%mvv4FO#ow$DWL!W literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXF5.png b/wadsrc_bm/static/brightmaps/heretic/IMPXF5.png new file mode 100644 index 0000000000000000000000000000000000000000..da598d4be197ab3741318bd4b603d93aa18cf41a GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0y~yU@&7~U{GXaW?*1g5pilS0|NtFfKQ0)|Ns9P7#Kni zU9MwbU@-D@aSW-rmHdOBtzII-@x8j|-@1^0-+$E$)cxIFB~ZIoPU#<`2GgSYKlMzZ f|0i<2V`UKKdt{p#&(^`fz`)??>gTe~DWM4f(QPQZ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXF6.png b/wadsrc_bm/static/brightmaps/heretic/IMPXF6.png new file mode 100644 index 0000000000000000000000000000000000000000..d22bf8942cb5d523fb2a866241a30e64868056bc GIT binary patch literal 120 zcmeAS@N?(olHy`uVBq!ia0y~yV9;h@U{GLWW?*307$WSzz`(#3;1lBd|Nnmm28Pf> zm+Kf97<4^d978H@CI8@O;+J^gbv0S=Pq*(o^R5T+9ACMVelR#mI%)WET;*AK?{F_0 agHgw}tB?H;D=;uHFnGH9xvX zm+Kf97_>cI978H@CI8@O;g@*fsFoo9zx~L*-h}_Z`x5@o;#Znq!!nWmfKq?pSw@C~ YjPs72d@1*Yfq{X+)78&qol`;+0Az8SbF2T*@3{U&Pt<4p+AiqxcQ2>l9sY%f6t8%3lrlKk gHU!9D)MaAOF+KQ_Cs;a@fq{X+)78&qol`;+0DP1u2mk;8 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/LICHB1.png b/wadsrc_bm/static/brightmaps/heretic/LICHB1.png new file mode 100644 index 0000000000000000000000000000000000000000..fc7d8392172f17ca61b30927f10cdbcba797a948 GIT binary patch literal 150 zcmeAS@N?(olHy`uVBq!ia0y~yV8~`*V2EU7W?*1oKJ4+5fq{W7z$e7@|Ns9C3=E-% zF4r+IFnD{qIEGZ*O8(K$BWKW4#NHSE|NsB$MX4W){@?unzkW`{JNcjg|IZe@!+z%f ze}gNBchpNtJQ6o3cs#-Ny7#2LDnC26Y>;}|SCn~*m7ytYd&H>+d;TymFfe$!`njxg HN@xNAkc&Pd literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/LICHB2B8.png b/wadsrc_bm/static/brightmaps/heretic/LICHB2B8.png new file mode 100644 index 0000000000000000000000000000000000000000..a5e3565f729351bc28f93d05bd408652dd1f34fa GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0y~yVDM*PU6z=IDj0))CeVTBaO2*z9g);NI7BxbftKH?uA_ z{&_FadVBVUo9Fe|o1Yi`SiNuE&h0BTD)x%HcCYhz%UG(Vku8*^;JZX1uycxaoa0HG z(u^(@_68m9dxtiqzMoR(QGR-fo_kiL?5XNi(vDij&t)E*`JyxX(~YGX>oTwHdgn3A zlUsAbE92iDW{Yf2?hV`hcACmF5A|2&`d-TxBy4^(TSwVcW9b#)m9_Qnw&y-G@_)7R ie#HOHM^@ea{(|#QbZPZMdmd*7kf&Y!T-G@yGywn<7k69$ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/LICHD0.png b/wadsrc_bm/static/brightmaps/heretic/LICHD0.png new file mode 100644 index 0000000000000000000000000000000000000000..76679dbd1eb8bb790b6519a1c7eb78b0fed772db GIT binary patch literal 315 zcmeAS@N?(olHy`uVBq!ia0y~yU`Sj^mw(+uoL~ntIA?A@m;8A zvExxob-%E${(Fmcgzvl5g~rS*jk;&bqVw$WZn3rBCeQw}VC~hjc~-B@E*@=Jv|jC$ z*`pNS>ob;bYT9ag<#oYX^-S%&qyI`~yPepSwb3Yh^@8s|3!Q$tJ?niEzvaTKtNXaC Y>hHb3wp?Qk0|Nttr>mdKI;Vst05tK4WB>pF literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/LICHE0.png b/wadsrc_bm/static/brightmaps/heretic/LICHE0.png new file mode 100644 index 0000000000000000000000000000000000000000..c00bf135f0059d5c53af9f2a37bf3bdecde32526 GIT binary patch literal 631 zcmeAS@N?(olHy`uVBq!ia0y~yV8~`*U`S_VW?*2j-K=NAz`(#3;1lBd|Nnmm28Pf> zm+Kf9m~=c{978H@t(~$lTf|Z1n7iK%r-xk%5guayn^>&{?=-ajZ_GVq(!{7}cy$d6 z=c0<%Ce4=3n?kiW8dPglEKOB%dUvSl`pmsD$KUPT{kg_?v+?I;JDp-~?Ed{R?b*GW z`{suk=8N1)KXXQZh0eTRSKr(Doe}6Y-fv}mIy>e>|Ba;H^$+-Vwkusz_6b*X@Z7*{ zpt^&7f}jsW8_RwtL4iB1dtN_mc;syHh~@Z0!=oxzYSKD4_bNAiRgef${hru=?k}ft zmt;=RobI)`P23wpJv`TF&OXZj>LT--*$?;x#eS`@IVdOcseAhmz0Ys#cCY2l{}{a> zH?L46^P}lJmhXX)Io^-|oYtLEm-x3MDN6r>k7$C#M+JHdTdm`fNFJ_qvSmPbV{V!~Grk>(!05 zH`?*Pj7%5(_VqzculdQ=bnR@Nu!=tCo02MPlvk@J%gj3cx!?b3(Ej5+50_|v{ThC& z)lt3ed~8KcLFmGWhZ9`2-mUUHCM|g2&I9SVq|54T@l7t(yPR_@gI@-CADuDV{hI~% z&dcAutUG&;WG_rVrL`t_PxDFT9S^N{IId%=xwiM9#_Z@->iNAFl2r7Cq*W%)JD0S* z=&-9`eUZiA(#*ock!(M|P5Cy*pT#xihwhHQVhd&&U0w8P-9+bwQ;dHsoO)u;lw-2jUc3eMlYW}7g^CME;RsY}XMg9#k;!Zo@`QSL8%fiLF05%H9#bxII>BkJV?sNvSs1cdT6&cjf0B(YXD-H6gzf8*aw#u~^#rn>9^f z@@KCZsk1Goru+-N$Mq}tY}4CS1^;?%?M)glrakn z3=E8iJY5_^DsEl9yf;tSQGor!|EDfKi4QLXx>%KO(F|7TGk+kMBz1}HqJm)N^&JIP z4>z>YMhz(z@HO=9QVtO7!Yi7VsE(dqfPjv|&WYo^MY&c^+gM)8QhSi6- zFCMO^<(7CYw7R{{C~&pN-`{my;M5|@~ zmbqcV`bNMuB0t()`~3Heit8nTmRw(04b3jRy=S6pbn*R)3qrBSz8`W9T#>AL-{q~v z{dGL+_siYn@*(*=&%+#xjnZNeb)#v|?+qKTHG(D>IeA)Iz zO<~KNt}LwB8B)LXnMT&tDf6CLygGID{(^10CwI*=GudmH)_rmA1K(X6rgo<-H9H{O zt=4+2ytwK~aDSnxbE5kbb lI;3`anPeS#VfI=+*tp@+vi%+37#J8BJYD@<);T3K0RTrr_&xvt literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/LICHH0.png b/wadsrc_bm/static/brightmaps/heretic/LICHH0.png new file mode 100644 index 0000000000000000000000000000000000000000..b2e39d506f80c3671b527efe7e02865d875bfb9d GIT binary patch literal 396 zcmeAS@N?(olHy`uVBq!ia0y~yU`S(NV2EI3W?*2jO%(XUz`(#3;1lBd|Nnmm28Pf> zm+Kf97#%%b978H@y}hLGf7n5S?E|Yb2Nw%lV5f3TQ>fo3!7M=)-!uaibv3o09HOFc zq!qLUggd%a6}+1iI4&_p^IiMRTstqjn3u81@!}HSy4riYtJhzjceJ#9`K!RG>z7Z| z-}+5zOA!0*&|6tI>hIkZ_fy-ZwxM$J(`y~K>lUx6^J%$!e8N)O(woUK`)@7j;me-M z6XfQ=sV$nPzVhPS&IRJVr?l0#yPh+OcKXb;>-n+gZ(QvhelcmezX&dzX5_l9%QCP1 zHSfaLx*_ZO7S=GY-Y;8tr{Pi)mq9_}npuUmX;&qsV;!Dd*tObn>iiN<)ex`LxjKuE zg}hj8vAn3vY}v92Csx{e?4GakC4BmsGgg)bk&Rw2k6iP!ie;bTSL2x$xZLQ=|9NHa zA3oP#IO~+=xfOwNKc+rC8-72yPC2!{TI>I>;JwU3Y_|Ff&rjE2U|?YIboFyt=akR{ E04Pzopr0QVj#PXGV_ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/PLAYF2F8.png b/wadsrc_bm/static/brightmaps/heretic/PLAYF2F8.png new file mode 100644 index 0000000000000000000000000000000000000000..e42de926695123bca653d3b331db79fe0a9d99e0 GIT binary patch literal 126 zcmeAS@N?(olHy`uVBq!ia0y~yU{GXWU@&H6W?*1YHu=1Vfq{W7z$e7@|Ns9C3=E-% zF4uviJzX3_DsCnJ;Ai3Gc`|YP!4z|$-=;JEaHvT>5quM#@X36}9p1$2%_ri&C0u@W fvYh#@C&Qnq_m8NuB@{3)Ffe$!`njxgN@xNA^gb(a literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/PLAYF3F7.png b/wadsrc_bm/static/brightmaps/heretic/PLAYF3F7.png new file mode 100644 index 0000000000000000000000000000000000000000..8aae224eee9e9f9bab8c512336f906d1e0ebf8cc GIT binary patch literal 139 zcmeAS@N?(olHy`uVBq!ia0y~yU@&B0U@&H6W?*1onN<|Rz`(#3;1lBd|Nnmm28Pf> zm+Kf97#uuZ978H@CI8@O{?APPy73k-QuDOvKXer{l3U|{fc^>bP0l+XkKiw!k) literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHA0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHA0.png new file mode 100644 index 0000000000000000000000000000000000000000..328c0363f94b3c9bd13d9cc5ffe20f07405beab0 GIT binary patch literal 291 zcmeAS@N?(olHy`uVBq!ia0y~yU;yDTMrH;EhP2|~a|{d&YymzYuK)l4XJB9mJ#@K_ zfq~(Mr;B4q#jUfK4EdT2MA#A*F)ORdH7HwDFu3zSd9R6g{w*4qK0|Nttr>mdKI;Vst0KOo93IG5A literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHB0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHB0.png new file mode 100644 index 0000000000000000000000000000000000000000..61b111e54e6d5ee7e6d72962b0173da151c528d4 GIT binary patch literal 462 zcmeAS@N?(olHy`uVBq!ia0y~yUxhF0+XEfVZGtsSXOkn&oxTy>rI2#)&^g_;CjCZ7xn9mW zbSf({%x7n$l8U17^YSz!a~H#_+nx2E|9PI%R&er-ynp=;Po1Wxm4bIpt$x5)Td=;~ z)qnr4=1+OYBF?LvPGA+&31ki4+52_#k;tS-6)v6c+Q{acOvQ=J{gf8$arT`*&MR-`E+ZRAoNf z&*$t_n`ZB1JO4M@#;g)WiMjpqT*=Z#VNcyZ$m!3NY}wiO?QivhFZZn+rWNWXZ!-3M zRBGTZ=)3aqU!Sj?w_kL6nU^OCM-=p*ddu)pPTDRylmFl@-}3WEVnuG%K2`daxSPAq zf7X%OP3o~pmwz6-`NrdIPSL*amM@s(_Lee=-;2Jmbvr|8=izr(6`uZ`_Cr=>?|g-` zCTq?c@V&G5*gj*|)YZKa*FDl|S+ZN^wSSx&b1m9dJ$Glu=cBWVs`p*#fBx+6eTJy+ WHSfj0KVe{CVDNPHb6Mw<&;$UVJJx3a literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHC0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHC0.png new file mode 100644 index 0000000000000000000000000000000000000000..9bbcffbde51ed4a88d06893313dec1800a37263d GIT binary patch literal 608 zcmeAS@N?(olHy`uVBq!ia0y~yV2EO1U zm+Kf9m_$8Y978H@gy_rT4@0-4B( zQ|?C}SK*z*vz?$v--A%>t)yhvN#r&lEhiYW0DptY^Is9Gs^5TNE;V*OD!K z(7!8KaH-7#xi1}DG5!8~uDd32^q2o}7v&V*v?2Uc&cq#FT$8o+h5V1qJ>01Ju7)gslNM78w-cBhQCO`7(0 zuV4h@dH)!<_DxS^>$usrnC{E;$jCdj?3h2R{K6W}sUI^0PDJc@r1h4i{lGiFjc=KK z9t1v?(8+f8KH>Jd`w5e@#5Ci~u9Ve&)3?lI$jSd2_PHTXc+rDp#|>RSK9oPbKQh{U TIRgs=0|SGntDnm{r-UW|cV!Y- literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHD0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHD0.png new file mode 100644 index 0000000000000000000000000000000000000000..22a51d62d49e73926c62a1f48d3a612e9cb43e0b GIT binary patch literal 989 zcmeAS@N?(olHy`uVBq!ia0y~yV8~!#V8~)*29Z*2FBupZ*aCb)T>t<7&%nSCdgyW; z0|WCUPZ!6Kid(){?7LN5CD=YlnMv@sJX4z7%=eC2V}{0>=%&VnO%rdj9%@}Zkz;ps zF^@%OjIvr+LVa)agtwCHGJ2~*K5i(VxuECGyUd-dwq?KixN_Fsqm6T)nj6P{4clAK za!K3gvi-z+>F;HH--)QLnD%MvCf!r6b*sb5DrUWo)}0#c{WRayc|!C**)7i}i=BAC zWTno@AYM~nEw;Mr$~HcyRxWa{mJ=sJAfHh||6C@mQ{qx{Gk^Lz@~)PO-o4E1 z%8M+W9M7|lXW5lkp5JijuZVYL^Sthu`RZ3$|AoFZT2#WB_rPey5-zGckBF zUHyuM!hurhEjPoPC1jsoXVZTw`83p_B5&u*o3$4|JB9o(@v;+)4a)16I-$s=?)dhe zmFrgVwN9T89F9#13`;UDzO&ikX{)Zm{eN+97Z$!`xvy>(=F*(r&k{cGcD76GUbPLg z^B&Fnv!yC_!=zd7!k#nPN{OdV=J84J`=MzX6wvD4{wkE@Iw3FhL!LgU_&()L)2bQq)3rW*wp_BLLaOXQ zdVYeO=p;Yg*LnSRCyUpL2X@?I@1Fmp!7MXj_1r7W|0V|7K6|)kXXDwF9x3hTvm?{K zI=($C_w&>~$)k4jc^v;f^-Df3`evs7o?p>3R#?c(=}nECS&?qUz&$;G^SnoIKLr#< ze6h+BwVw9f%x!C=6xW5t?_45|zgx0xao!Et5MSQpz-|idk^59Tj?|JO(MiOaB0P5Ev8(ek$Bt5-biJC}SH*ezjJ;}ZH_?p*rgJx*T_JJ#9= zt&$hqJ-^F&LzMH8AJsFWH!9tnU|x8};PPLqQ?47ibeQ{=o?7TExopbWQ?c3pA9pxQ z&1;>WbXYs-^|QhqPn~{nt}8BQu`hIgboGJX`u`03>oT?eXKdcZz`(%Z>FVdQ&MBb@ E01C*}-2eap literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHE0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHE0.png new file mode 100644 index 0000000000000000000000000000000000000000..acfa9c9a3f13e646f8ba352ef7f9adc04bd9fc80 GIT binary patch literal 1025 zcmeAS@N?(olHy`uVBq!ia0y~yU`SzLV8~@;29e5P_Zb)%*aCb)T>t<7&%nSCdgyW; z0|WCmPZ!6Kid(Kz46|jzMOx4f5}u+_`ymifY;S**7cS-zz>> z%T}YCn)UUvWNkg~_Y?PmWft;Re}5wU<;SD_@lm%Qg>0Mh^r+UnRB5hjVyQOs^G|f^ zKHIqa_Jr=BKT_7)7plIzeWOzHMZe*_-#5x;R~PoYc35R*ZR6bfcwg=mCccXg-n#A% z%9@zedf%^ldB`N2KPQ>hnMFB-%Gdwjv_v{+i$}oICH#3u^nQek?|SyGDc9xTB8hLS z&8EDXwJ5|TPVr-sH<#egTQd(hO|5#;Ydnvit81J4HOtLGQzw|&>P4r&3%R@DGKK(`TlEr;RR6a;v1;pzMO&7fZaB6&JM8nMZyL<+GA|~}v6RkRzw&fb?B?EG zC#Jko;M}`HJkojX>x!J!OIEx-V|&f#jrZKNt=_j*8ox>}oqUz?t!(C=_EV8T`!9*8 z=md!c{&EwZv^vu340mwz%w3tk6|Y;`O=}cm*42C$oT4b1!PYrHZ{-R3L&t)bI8Kgv zc0SR$V$));15cAvjD7s&U(fn?(&Z9+!H>o(t?t4zW%&#Xmi1eQothN%BIK*b+O_L` z{`D)CwL6)+wSU#8MNe|~Rm_{R@|VEv8BgA;uS~X>vDA3U&9^Cjt;UziSGa9on6z(d zo#Tz&ynP@4IqYJI`&)Ui?W47Jve(CFit8V?ZF%;*KR(OtdGsbnDuB|AI=iu5hR z1pi7|&3;|wENirM>!c&Pr4Pyvwx)5)@LB2p@Tg{Ze&Mx)o@*y#@*|-mojD!<*Sy(z z>8nG|3-zm?t7VmHzswcl)|32_a>1uFSS*MquWupq)o_~yY?m~%W!e6#Sv6*S^^iOf zzKhd%mC9QO$r<8eS4?+3Rh|DdQ#p3^>?t2+sXqLV0miLZ7C* rExb4R<;!*Q8*iWeS=syc^k44q^2!R$njKOM3=9mOu6{1-oD!M<2%qn} literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHF0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHF0.png new file mode 100644 index 0000000000000000000000000000000000000000..68c78cd7ac3e96d4ff423d507f7963e925d5620f GIT binary patch literal 1021 zcmeAS@N?(olHy`uVBq!ia0y~yV8~@)V8~)*W?*3GG4@@{z`(#3;1lBd|Nnmm28Pf> zm+Kf9m^XR4IEGZ*O1*k8?}>{5TSB|X8P*St%%@w~KC;{~3z`y_$^Toz@fP#*y{v{y zgr823{>&usnZw3$j)u0Ripc&0T{AD{JUQL;wq#4*`rCg$hg&nMJe%;u`^~#muU7dn z)g21^c`h_HeLKLlzP$Pt3&&$H;3OeW{2E-G2iY3OIYP~`+_#N-{Svurha<+ zLFVX@eJ$n{$5fSaMVlTepFMJR)p1R+g0x?&=O;E#dhPnoVWF$+Hs!yJ@;M*FlcqU6 z|M?($&piL%yPSh3t`?m8p{#$8+w+UuyIsmHgsl>JQwuY89k`KnW+v~!8ynu2J}Kfb z5WAI{(szk1W7%zePhX?-B8^xflPtZ@Pc0^{ye9VWsKukZIZ4ug4%Rq)u6ZP7_onPd z#B_^&)y;zGvRp+Gi~dbMqqXFa)YsVtd19^?n7^kg*6}~y6~m$&!)Pzlw_oY|q<d`8=M*k!4?k+m!eRZAC3M-Rz7I*> zyPP?9PWgMl z&R*}I`Om_`=0V;rwY{kkANu#VcGjGlXJA(&ctgqN;FP6jtIsegO}*b1rCj_X%Q7#0 zVxDq-V(ZV1x%1vAY|p5?Q?WJIU#fl1Os!0(+bi!$U*e9w{X%g?aL}(T;|QLJKYvbM zDRsR+Is7N*`8hhu(r3d@^nGqy_+2Wq-2Zafn!8UmZ$7_oefgTq+%z@A*Z$X^t$X%j zkFRn+_usVn#^1tDp4t`h!d@hKM|beF(8zPGH&P}T7|nhjqj6@|iKh!sS+@S09bWzE zgK5Y$6Ca=VelaO!OK%zc01U#09h&F9QnWV2KAW3-HwT>P}!KSDc1!W<^m zZ7FWaR5^L~$=>t#%`baQGvx_8Zu2=}PLU^DX0Jf=8TC!FU;eNBED(7p<$t2##SF{Z zd!{EW_CE}Gq3~H{&g{UtXZf$Dl-TgRRL+0b5`IW^cZ|7BZCQf+ZlPVOb5oRRp9d?7 zOQy*0C<;Dm8Fkt&WA&o0;*!KCr?y;O)V;^A_3qkPJN5{L^*(&F+047lrr=dd(1|m( z8rP>xw@j*toRICsZtRw2Z|?N=z2u__OaCc6G(E#3ZY1DZF(+qZa$ktj_xH!_yUgp8 q`w98Ke=DHt|4ZYo$9%YvNWC->x|p7ng0F$JpW6&Bm1t{ z3x8*69ocmxaMGf3YZ(?_sgHsig-bRrV|QWJTF5EQ;846=*;geX?^Ep(Yws_sDn1^Y zIPD3Gm!oa4-ikyf$77Sbp0KWRc$>Px-rX$*6a6yQ)m*I7%A6=(XXx*mKl$9z=bEdZpW_yp)jBCLQ{=3Z=k_bj z8OM%YbQd^#zdU`VewgvEKeDMyBVL`$5c8KkpE$ku|D!^V^yB*S zT3=spj(=4k&)3!1e08_;g5uMxZkubD`PVF4XpvZEb0on1*5{u)7F_(Ned6BAql&)a sJD1%S^}X9w$FD6_u=m=3k9tPuf-8Gpe3~f3z`(%Z>FVdQ&MBb@0QS~a`~Uy| literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHH0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHH0.png new file mode 100644 index 0000000000000000000000000000000000000000..c6393b5516bc9accef35c48392918607654d3f4a GIT binary patch literal 418 zcmeAS@N?(olHy`uVBq!ia0y~yV2EX4V8~` zm+Kf97{fhX978H@y}fkMuf;%s;ewjnmu>b7ZrX30zcg-5Cwt#-&VOy&kG)CkuWRVk z>Esj_cHo=BAe+8SgiZP5hVa=A6&ECL&D47E(By82!#+`ua;Aa_Csb#3@U6FMl56Wo zlYL(C`8#90lrevT#L`Cd8_m5pqxLtNsAbG;RH}QaUDIBX^5*60ChaJ`wubUk*>TY~ zUM_7Elh+A&#b480!Q?eJaZBe4CkL)C^0#`nww&iawtL~+=}Q-dNKRi^)MJpfyp8iN ze}yG)&k>WN&gLVlTVh)$He8-?Zi7%;)>r903xA!vAY2u}u-~=Bdq*WJZ}<#HUf&(d zMe3M0@ZNoPq-2UU+qv^fHuE;z={u0j?0R70W-)8Gs#>=j?V0@LEr~syu}}XWakFx= zU$kHK1%v;B(vJx$LdONq@5$12SUQ(GzGXwiy(-bQEV%{8+>Y(xP^r6^Q2dJX=kfR- aYz^m6*P4D=xrTv(fx*+&&t;ucLK6TcA+w+W literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2R1.png b/wadsrc_bm/static/brightmaps/heretic/SOR2R1.png new file mode 100644 index 0000000000000000000000000000000000000000..a60cc15fca352b5c46372804e1fd66c6d005bf3e GIT binary patch literal 298 zcmeAS@N?(olHy`uVBq!ia0y~yU`S?QV2ER628jq-EM;I|U<>dGasB`QKLZ0p=%LGX z3=9nSJzX3_DsH{KWXpBPK!o9e(|W~{4;+1$zOk)a7w34ySJQ8Ai$K2OCC7sYH#RqS z2bhazYw8}mFk{B_kXbPY^v-@e`1|2r@$T&RX@7(LomVd0x$wjVvDa1)eHUvTZ+Dwt z&Z;G(={8+prt74h9YMzNZbJDI1Z znGo=bcWRRRi;W!FKb^w6UV8{Eocij4vz+2r9vi_$SHhMAv~FGiIMJQ;!W^!?}Ey#cH0J-?^iH>Cd&=x=6qA?6jNPHZh!JU|?YIboFyt=akR{ E0E(Y|Pyhe` literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2R2.png b/wadsrc_bm/static/brightmaps/heretic/SOR2R2.png new file mode 100644 index 0000000000000000000000000000000000000000..e369c437ffd4a122144af7781ebde0feade7f888 GIT binary patch literal 333 zcmeAS@N?(olHy`uVBq!ia0y~yU&IikWxuK#|ydKl(Rc&yUG zQ+rSSa_NCbMydMe78GO&R)1r-k+*R&r&Haf$8l8&e{SS{o_U<(Wb~7X#~WWRy(+AJ z$#9<5Q8UxlOQ}IqrgrsLJeqKNcS_3r#PuuELabExm#91sF08q`Ax_0P`}_05zy1ZE tzE!DHw|3v$&-)9{+ZTK|c>6E=`8!wAKR#V~fPsO5!PC{xWt~$(69Ap9p!om* literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2R3.png b/wadsrc_bm/static/brightmaps/heretic/SOR2R3.png new file mode 100644 index 0000000000000000000000000000000000000000..81e042385966e6d599b9d2379736ecd7aec6df41 GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0y~yV9;V zm+Kf97`A%4IEGZ*dVAiG?~nlx>xDZ@v>!3`Jk)yAp)JxWIhA+YJO;l8k0XbIUI;Go ziEZF0-LPm2XW5|uzXMIv)vf<^one}qqWDFiP@zr2bm{g*aY}aHAJlnSuWwP>)S)%| z#5boqVXT3@Mki}7B=^Ox>$fbbD*Z9h`i7j!Yw>GRF*9$A8CGAPGU?z}+hhj04F?-` zH!pB7?Oela_}EL)TCbyzU8-uHpQg~)=Nt4x7Wq68ly7UX-~W&|@y!o$hAQJK1_lNO MPgg&ebxsLQ0D0VGBme*a literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2R4.png b/wadsrc_bm/static/brightmaps/heretic/SOR2R4.png new file mode 100644 index 0000000000000000000000000000000000000000..d54a2dbcfffed29af947ce93d60c989e2005a79b GIT binary patch literal 309 zcmeAS@N?(olHy`uVBq!ia0y~yU~pz&V2ER6W?*1&^06*uU|?Vi@CkAK|NlP&14HPc z%XJJ446i(0978H@y}e-Qci2FLE#ZEH@)YTk)Q%5=JDk=xSd}p48*D05JSVuR)S**b zvGE9lvD1}vEVC!tL};v&Kd*S+wV;_x|KF1DDgWOaO7th%KiQl!?ONpQHEmz&++Hn` zf4WGumGkA~UvrdaM(@eJbePd=@t@TSvE3W9LRZb>2(cEu5WjFw70Zj%Wty2I5IV>eicMwq0(T zW8*IAYc8{%b(CCOp%&VHbBX^eqxrjE?P2=dd?h~aT9Ef&^;*XL_h!j0KRyc-f()Ln KelF{r5}E*Bx|Z|+ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2R6.png b/wadsrc_bm/static/brightmaps/heretic/SOR2R6.png new file mode 100644 index 0000000000000000000000000000000000000000..7ad493b16f3701efe4b77210def3c9fe1dae8a87 GIT binary patch literal 320 zcmeAS@N?(olHy`uVBq!ia0y~yU;yDHMrH;EhMzOUN*Nd!*aCb)T>t<7&%nSCdgyW; z0|UcXPZ!6Kid%0l8fGy$im*Ls{Bl$Jh2o`E)r<#~pKu83nBF{e=u+50yVO?;UNp2W zRW}fhJgAhyzVU|aoWf80x4Vezyje5nRkB3e|9bx)mnS}27RGvB@6CIQ?^o8bmzU)@&)armV{wqqts^=HA9l?$pMNAM#gy-% zH*X2g=iduzW_4D&r~N;8ZXTOK`Ny*D4VVA;HuaepYR!DHIrNKtz4VGhdSBLluls)Y c`d{{ zm+Kf97+!n2IEGZ*dVA3@?~s8A+XHijuM#m$3xnF{G%|nTbD1io=(yIehlfYDxWg~j zgRfzVq>6{2bGw#e$HJ|T_FVrzbBeM9EWzj?j0`EwS+@Zt`r(k3W*wbL7Cg z&U~R2>?cFM8nqN%J(K5=^fvsa>KC4m1y0*zKXz$;Ez(;scfZ?VM%mu1-?=M3y=DCy z^RTtfx9ZxdEvw@F6Ym(!+Vbdpd90n&@|?CKx7eB9c%OSeJ^uCme_z$VGOOD=+|ZqH Sd=di#1B0ilpUXO@geCw7sfeNg literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S1.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S1.png new file mode 100644 index 0000000000000000000000000000000000000000..0365f4491aebaba6004724c53794f2e7e73ecd7c GIT binary patch literal 386 zcmeAS@N?(olHy`uVBq!ia0y~yU`S?QU`S+SW?*3WVcUC`fq{W7z$e7@|Ns9C3=E-% zF4r+IFq(V1IEGZ*dV6tiUbBG!dx1Mo&x&eQrLT&c4n8h<7ZMt17}TEgl=sl=C(aXR zEfq?3mk#V)Iw{cjhDh;sW5wLIb8{at{+ayW?0K_dQv2fxJ#tdN<28F7PG^bil@~m! zu(sPzMdj%dzRJB!UQe2Rbi(+(vh7sf#<-L(`d#wdig&yIA2%7PCzHNPwp{x4^PGdW zWXm*jUr{mDjG&wi>tH9&-Q!R8Ejx8j%D!}YNT$OqNx6@EGQ6cHJ5H2y&!v~M u*ItU6)4h7LN>BY8{fDmNv0u*rV%s&j`}wvV{00mR3=E#GelF{r5}E)G8>;^R literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S2.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S2.png new file mode 100644 index 0000000000000000000000000000000000000000..a5ab0c3a6cf35ddf3517007e269251a2400c86cb GIT binary patch literal 329 zcmeAS@N?(olHy`uVBq!ia0y~yVDM&OV2EdAW?*2Lb$o>i0|NtFfKQ0)|Ns9P7#Kni zU9MwbVEE_h;uunK>+SiCS%(b-8Xj`Xc`aXe_mcwW$JHsXZaGbNNSb?pLH~v88Z25& zt(Q*n2M9@WeO=*jU{hzw^~o`>!e307ZP#M)mnrSI5nJ|;rM_E~?ryrkDf_MS*jw3o zO6PCYS>07xbhqs1?h8Nn=+^K}w8`xh$(eTHbFlmB=sAo6;f-<&>eehgeC+oc!${uy zKi9QspTE8-C#orD$<7TicRW}=1a+L5oF^1t{Y<&RpVyM{&dMW26KhSi+=R}oo*RAi z%XXy@`7q0$7reu7G#{;gc#ZXQ)s2Xq8{RdCHAYDEttqtKka(n6DKyAn!r2oQrFVdQ&MBb@03`>N{{R30 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S3.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S3.png new file mode 100644 index 0000000000000000000000000000000000000000..c793d5712b50cf315fb93f0290f12db5bd3b5b4c GIT binary patch literal 234 zcmeAS@N?(olHy`uVBq!ia0y~yU{GdYU`S$QW?*1=ApGMp0|NtFfKQ0)|Ns9P7#Kni zU9MwbV3_ae;uunK>+M-ZzC#WItQQJ7_!{0=8iW+_yjm5=!NlvRP|fIczEMG2V5)ZD zhQ|Q`j)#`r+;n*UJf_CVnNR-zQ4}ee)LTdoO$On(>{g ze!{k$hieyQ>hRs@EIf3jY*SLz`HPFvqJ3x1@ojtYA%`cryKhep*ZFe?=1RGX{;6O- qY#b`T=;hY$DvRQ)p1$}0$$HuB!12bLf_@AP3=E#GelF{r5}E+7nqR;G literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S4.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S4.png new file mode 100644 index 0000000000000000000000000000000000000000..bfc18a04d6fadef29742ea6a58ba3a6a12ab7ed9 GIT binary patch literal 376 zcmeAS@N?(olHy`uVBq!ia0y~yVDM*PU`SzPW?*3WJMq5(0|NtFfKQ0)|Ns9P7#Kni zU9MwbVAS<=aSW-r_4dMkFJ?ypwhx?2Q7e~TeQKEVb*lF!=tAfWbhnhUqx zo$Ayx)0eMGk$P4fw{(7V&1T!Vnu`TjF)jY*2|iQTE45WCvY*J~5V?3X%9lsh_2xN=7uya6 zWxa}F;=Qn0w_#m?gy_YN&F<5plJmN^9||~K5UcF}(^WJ$cGfe7qx-J9*R`p>ta`or l+vo0A?OUEq`rj|VOJ!!mk|P&H7#J8BJYD@<);T3K0RZTPrr!Vn literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S5.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S5.png new file mode 100644 index 0000000000000000000000000000000000000000..a32e46d6b9449ca1525151169b35741a0f99553c GIT binary patch literal 423 zcmeAS@N?(olHy`uVBq!ia0y~yU`S zm+Kf97-KwL978H@y}fAdf7n2PAz?9J$4YIV)W_@_N>+UEPe@HkPF)?~x^8ae8IJ{@ z#3d#!kXWgmy;%WoihpOWdugxVIKm2kjR7y5HxPawhT;KelFB1#9{uI`qD>pRK31)ls zH;T!5kHMONwAz}wISF0PL36G=DVA$II5V;Dw5xt;oMfutnw`@g$<1dtn>gRqSL{|_ z;sKdw|Mp&7D_yp^_i$FX?O`>x)TP?L^v@ss>2dF=Z(HBip76cg>|3(7S;jt@vG?9X z#Z2wVGnq5vW1J?goi)p{F3o+;rX3m1vAaJWs57bY3t9E}%Szo9R=KgO&9+_i>u<`@ zSYO(1!XB-sTCEWK$*a}gSYVgX+?j_X{&KB6F#m-7%}>X)P6mZe+cD+uzPAf%JWot- h(O$ddQvDZJ-*eMN#Pm#M7#J8BJYD@<);T3K0RWd`x(fgR literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S6.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S6.png new file mode 100644 index 0000000000000000000000000000000000000000..b57ad71175989c6be2e719b7113f714f2e3ee526 GIT binary patch literal 377 zcmeAS@N?(olHy`uVBq!ia0y~yU#EEZpV%c< zgqBZhv$S%Vwto80oL9e(6qQ!(WXRyyY{9Isqs-<@$aE9-7C-Is!&hXUXapU71UjGG@U^L~r^o~%5*W?`sxkV%N{ l)os>0X4`)MbNmmh!Hx#=Er-j`GcYhPc)I$ztaD0e0syNxs7wF= literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S7.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S7.png new file mode 100644 index 0000000000000000000000000000000000000000..f73a05c19c9c97659028dd3ac91484dc758f5dde GIT binary patch literal 228 zcmeAS@N?(olHy`uVBq!ia0y~yU{GdYU`S$QW?*1=ApGMp0|NtFfKQ0)|Ns9P7#Kni zU9MwbV3_IY;uunK>+P9?oJ@uStqQow!ts2 zx<|+$!Q`>c>JJZ|CQH=KThw+_Q|X1ZMBj(KFOP;lU7O)?=9$*~7_lGyTKZ=#C*Ik< za>iQ+>#MKCtgZFkUNr}Iz7x-U)_!T_^OPKMtvBfzua=(pDrKh4-P?9lV4l()wI4sE lE*9h{e4F|6z5Y)|9gqE6S1*2_%fP_E;OXk;vd$@?2>=N6W3m7M literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S8.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S8.png new file mode 100644 index 0000000000000000000000000000000000000000..708f81e25a14b11d1fde2fb8001412d84bd53ec3 GIT binary patch literal 357 zcmeAS@N?(olHy`uVBq!ia0y~yU zm+Kf97^OU2978H@y}e-Qci2FL?SXpgi>4`}AyZ@)IjcWXE`1ZwVSTXaiu45S4Tgc{ zNh<`L{TyPiEEKj_+MK-e?0IDe0rP|vs;B3#QMdhTztD1;{@=v2{rNA>PRNvg^>Fju z=(BhH->zPNR{ga}&1VUY3o@Q-ewQBE9Gl{F_wBh>)#>r=NkO5l3%gb*Z@GQoLbZs_ zaM4m(JhyEje^0>&pwVxpxFxWbRh`rmS=;GrRlx_G8B2%&D(jrHYeMQ&#CK zN;#bhTBTo96}jb!!7&cQ Pz`)??>gTe~DWM4f(sG)f literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2T1.png b/wadsrc_bm/static/brightmaps/heretic/SOR2T1.png new file mode 100644 index 0000000000000000000000000000000000000000..8c980b09f43cbafacb184f7f80177b9250cdd0a2 GIT binary patch literal 425 zcmeAS@N?(olHy`uVBq!ia0y~yU`S(NVDMyQW?*3W`ugA@1_lPU0G|-o|Ns9pFffE3 zx?IP=z!>N0;uunK>+MBDzrzM1Y!B2~6SsA&b#}FInkf*}%Fed#prFKrsFfm{TNzi* zY2cAr?6mL|6St(~iYHxsH$7GZ~1Uvqxvc_n2Vk>*0D_Yn(39|jxN{5>$cPuyEz zN5J9fs%#IUQoVYOo=iV7F(7H-40QvEy>HJhxU?u__1>HBn~vOBtTQbyyW7*_cR;xK zmU-5_dJSF+9G+FZUBdaXM1RT8OCnpZ6fW+(+By5xcO! zo%vYbXyU8yd_`+x&9xuT*^)5Bxo7#iC3C#C?@e4@QdgoXCn~GkQ?!kz+W48Rz+zSH zLyY{*JA*S-w;VFySzIE$_Dsb^eQssBsINwu#Shq4&C&WccjBbq5^GwRCWqEVJcyd5 iwj)0DufV_8{;!3j%}h?jo!W7d0TdIielF{r5}E)|{=CBg literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2T2.png b/wadsrc_bm/static/brightmaps/heretic/SOR2T2.png new file mode 100644 index 0000000000000000000000000000000000000000..0eaa52c1dcc4f86fefdb4b031b02253dd609220c GIT binary patch literal 367 zcmeAS@N?(olHy`uVBq!ia0y~yU+Qvjeuo?+*gx23D*2TeB^u0IpAca%tK>sx53@>=xB8t5#$@?c z=eE9DMqw|jlFhjiQBQX4cXv$qz$o))l6T$DPj{cbt51k+jlA*cvqM#N7`xZv0h>AlpShUkG|#EwRE@o`@MfM+e#Nz%nN^)%P?)~t7nFC zXSFx|+~lLA!_$0Ii??;Y;H~0I4|-QBnr_~AJn_TinPR_xtUF%q_W1rHyG2&Ny6gXG b)-m63m=rqi)3p5z3=9mOu6{1-oD!M zm+Kf97|wXQIEGZ*O8)VG|9^WHn}i?#_y72xZ}D4S!0G1k`WuIDPCNheVb;Hs^8b0# zZ_C&5UDvMPA$#gy@csK1@~8gU?vFeqx9pj$a?{^~PD~Hm?1jDtZ2SAu-i+srz_)|x zMrNM^KFUwE{Z{bx8@s@ppS&F3EcsY=FO1u_RPNBb;6Eo0OYtYx|M=H*Twwr$?g6>C#&`Q83Hb(`z|<{>zKPTQEAzVuH|)klbHCH1~Trw znV{iCTtPbCis)E-W@L zkNINhI`xUA@!XXP+rI}CMZc9*UHkXwHmwZR|GymfGRUZ!z4E^N>jDD<1B0ilpUXO@ GgeCw?zIt*1 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2T5.png b/wadsrc_bm/static/brightmaps/heretic/SOR2T5.png new file mode 100644 index 0000000000000000000000000000000000000000..0a6d72d3ef51abd0949a616f30e4e1eabd774c6d GIT binary patch literal 393 zcmeAS@N?(olHy`uVBq!ia0y~yU`S+OVDMmMW?*2rlg%l|z`(#3;1lBd|Nnmm28Pf> zm+Kf980|b=978H@y}h{6@34UYTY~$23|@2RMPuJ7xwGMBXr?wm5!zQ*Z! z{^N?bA-TQ+L^~FUqR?$?7>T=R!xf1@pbN^Djrn zemPgU-{Y#C@x8|8nf#$10n3jhp5G~`&N0z;t!46@)+hW=q{|CRq?d#oT;wN~XglF^ z*7o9EAKX;cZtR`mxKI7ZpR%GKv0t2jT)%%s+-16{ZM0m=6b1$c22WQ%mvv4FO#pqV Btv&z% literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2T6.png b/wadsrc_bm/static/brightmaps/heretic/SOR2T6.png new file mode 100644 index 0000000000000000000000000000000000000000..3beb542fa7c91493286ca1aa86c0311cc9258df2 GIT binary patch literal 269 zcmeAS@N?(olHy`uVBq!ia0y~yU zm+Kf97!G;5IEGZ*dV9{E>yUv6+XstM!KTH*`a!QZu2D#PGb1vfT3A$M*G+B?U8@q^ zlFZDS`JT5~&MUCV{p7v>`!K@{l{`emm#7*QNWO;x3uk{2-_2T81~a?3;GU z;!=)Rl;muWnR_)&jK7{vxp>e0xaXUTFWP>tH09EpEBbx@wH-gJpLcJU_3b}-^jYWG zgjmD8yB`{oZ&cf@WOcT%vI@DZxY_&J@vo%?TGo;`?(OpR++m%q@@`wN#@xnlr+@rD c{+IF6?ENW6^%puZFfcH9y85}Sb4q9e08>eGa{vGU literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2T7.png b/wadsrc_bm/static/brightmaps/heretic/SOR2T7.png new file mode 100644 index 0000000000000000000000000000000000000000..186715a3a16dffde978328e23f2caf1ce86a5b80 GIT binary patch literal 282 zcmeAS@N?(olHy`uVBq!ia0y~yU zm+Kf97|wgTIEGZ*O8&vm`2Wp+`viu~b^rfY${+j3*TPZud4AQ5S@lNqpF7{Q|9|E4 z;VXZB2HxjSkG^vH@QwexZ{GADzHwIQ+qHsi4DvB&lb^X+{5G&Yb5EY<%-jF3q!&DT z^VUXQXu+HRxyRZQU;Q_~a^8Kz+qVzjsM*b!-T&dVd_!mZ2F|({!3`T0-=6W$uBGd? z{O0w|tNwrZ@9?)~N446G{p~ORsvrEr{?7eB^Ra?&Kc9an_)-1G*yheZn}3}N;r~{* t&)#`nF7e<0|K}&(`0sx6a4Rpvp1VPIfj@O1TaS?83{1OWQMk|qEE literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2T8.png b/wadsrc_bm/static/brightmaps/heretic/SOR2T8.png new file mode 100644 index 0000000000000000000000000000000000000000..58e7e87e273b4779b4cab1bbf55547fb2a1930ec GIT binary patch literal 378 zcmeAS@N?(olHy`uVBq!ia0y~yV2EO1VDMsOW?*1o+;H(00|NtFfKQ0)|Ns9P7#Kni zU9MwbVAS_?aSW-r_4cBz-(dq0h6MMC4U7}H7yOdqS@BTg?kTn;MGuX2SGqVgjkzto zm|RVn7nx_sxE_kGo1)nJ>PMn_?iA|-(mM6us;B+!c_1Lyvf}t(2B8lO&;RzR9I{!k zB9U8`E27x6Ldv97VG`#JDMyxr-nP?or6SF~UA%I}v-{>;@4B9)>lG49+D=S=T*!M} zOlY2Z#Pt)WJC%=QvODA&WUm%{wR2+dD#OFZDQcoyom8%@zQvL6d_^FezxDvr%Pm57 zUw9=phy0D+7?d6G?DyjR>jjR8ZeD4@xi(^H?Y$=-f4^vY=#^NkGcV%TiwAR^j;QXN zmV8*4D^j!2s_)FychS?Dr|CN7ED64HygBo=eb zXkb-1*1+0h$a3Jo5y{vC621o{6d&-2Iz)8qDfFm4IKlEzdgXzw7KeLWD)^4Ib1EEI d!SI!pp>_6rtq;M9(F_a>44$rjF6*2UngCNfG}! zm+Kf97*>0_IEGZ*dfR8s*OVa8!mg{)ss4bcEF|bgKmot5&yqjZZ*&eWe!%Lp<%5)q zaIVgQwqBcSiVHt*srh_OEh{Tuur+8dSILA0QZ~$ItFpFzxv=tDlJp+I%i3yeLR(g? zUDBkcA!*Fs*rM(C{L7*XYLS^Ox6@7)U%Pm?)-XBm=Z6WIm6yWrteJQ`{c3-7g~lJ* z`_?-hpIhCz8-GLVqv!dSlDGfE-sNAO==O{G7n9hzCtIER8k-mx7#KWV{an^LB{Ts5 DSM6tv literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDC2C8.png b/wadsrc_bm/static/brightmaps/heretic/WZRDC2C8.png new file mode 100644 index 0000000000000000000000000000000000000000..8abe02262463c41a358f39dbecc10d9f18512009 GIT binary patch literal 242 zcmeAS@N?(olHy`uVBq!ia0y~yU~pt$UA$}vmzM0mCO*4(k5l*5$Swv31_n=8KbLh*2~7Z|U}fb1 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDC3C7.png b/wadsrc_bm/static/brightmaps/heretic/WZRDC3C7.png new file mode 100644 index 0000000000000000000000000000000000000000..139467032fa3be6fbf652480141185a5003ad0af GIT binary patch literal 169 zcmeAS@N?(olHy`uVBq!ia0y~yV9;S;UuukD&O-$Pt?{B8Pq9ooWXq$J(bdo$vEv}Wx<|I^x(S><%2rON zl=rjtaBx03|5=Fh<^iqicgp4Y-!+Q<7W`ATG^9uGUF>4M-k>_+J&7lr#F~s=G@XnI zU=K^a=@z>~{dA7HMVsEuysN40Gbe5KO9=PgR5q_^#x3jZ*85p0=MTKba%y zyz zm+Kf97*>0_IEGZ*dfR8s*OVa8!mg{)ss4bcEF|bgKmot5&yqjZZ*&eWe!%Lp<%5)q zaIVgQwqBcSiVHt*srh_OEh{Tuur+8dSILA0QZ~$ItFpFzxv=tDlJp+I%i3yeLR(g? zUDBkcA!*Fs*rM(C{L7*XYLS^Ox6@7)U%Pm?)-XBm=Z6WIm6yWrteJQ`{c3-7g~lJ* z`_?-hpIhCz8-GLVqv!dSlDGfE-sNAO==O{G7n9hzCtIER8k-mx7#KWV{an^LB{Ts5 DSM6tv literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDD1.png b/wadsrc_bm/static/brightmaps/heretic/WZRDD1.png new file mode 100644 index 0000000000000000000000000000000000000000..c516516dc2d950dcb911479e20d97db1aff47373 GIT binary patch literal 186 zcmeAS@N?(olHy`uVBq!ia0y~yU@&H2U~pz+W?*38_Fcb%fq{W7z$e7@|Ns9C3=E-% zF4r+IFywo>IEGZ*O8&vm#xKFf`}h6-|9=zeYz3NreEa{#v84ZlFsH!X13W4XD>iO? z$k36NlVB0RzogoH!(E1tzvT`7GhF(AN8X@*L;Zmd+yAovZ~y7=@i6~v`KBlG8|o9- sF3R7q-_ZQR{!{%E_R0U**?Acf*RAi-Dh>5zU|?YIboFyt=akR{0Oq1e`2YX_ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDD2D8.png b/wadsrc_bm/static/brightmaps/heretic/WZRDD2D8.png new file mode 100644 index 0000000000000000000000000000000000000000..0669544912737eb3bd08c48b79b790953c1fadbd GIT binary patch literal 173 zcmeAS@N?(olHy`uVBq!ia0y~yU~pn!V6bOoW?*2*Q|sBnz`(#3;1lBd|Nnmm28Pf> zm+Kf97?M0)978H@CI8@OWtU*<`pWN_V?X8V^ZLJa9Iv1MuUT>9c=fS>jqJ8f0oNGW z*s3{JcOG0QcW6?WU*o1*@_!mP@!79v+!%M|gmc7S_Id|jy8{O~Qf((RZnV3x@d|&= e4xVH&2DSM-cR&7(TE@V@z~JfX=d#Wzp$Pzh3PEN7 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDD3D7.png b/wadsrc_bm/static/brightmaps/heretic/WZRDD3D7.png new file mode 100644 index 0000000000000000000000000000000000000000..980e7286feae67bc98170198a65fe0a2a5bba131 GIT binary patch literal 167 zcmeAS@N?(olHy`uVBq!ia0y~yVDMyMU~ph$W?*2**>obDfq{W7z$e7@|Ns9C3=E-% zF4r+IFvNJeIEGZ*O8&vm%*%5n^`Emryz-3a56;x@DR?IDX7TxWvc>1d191|c8(J)T zZl)jROO|`~tld!F?E2vu@7N!lX_tS%Wp_n+%>?%yjg061+~i2FtM^%~AekC8myl^ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDD4D6.png b/wadsrc_bm/static/brightmaps/heretic/WZRDD4D6.png new file mode 100644 index 0000000000000000000000000000000000000000..b1ba1d2025358f37b29e0ce54af47a4cc8a4a364 GIT binary patch literal 162 zcmeAS@N?(olHy`uVBq!ia0y~yU~pq#V6bOoW?*1QKdW<&fq{W7z$e7@|Ns9C3=E-% zF4r+IFob)$IEGZ*O8&vmS}(!Y^HomqoAfcO|FXws{pUS4sg@`8?_&#&)Sm_h4w3vq z5ewJw&pxwojeO~+fNS%uX2{zAI~bv#lb|yryFtzP(A`6S{{LWTKm8$QS?>ZVNz TCqo$+7#KWV{an^LB{Ts5j+{JQ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDD5.png b/wadsrc_bm/static/brightmaps/heretic/WZRDD5.png new file mode 100644 index 0000000000000000000000000000000000000000..7394eae62ccbe546758ea050afecd79d03762944 GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0y~yU@&H2U~pz+W?*38_Fcb%fq{W7z$e7@|Ns9C3=E-% zF4r+IFnD^pIEGZ*O8&vm#xKEU`}fEH|MlNIz8wDl|9``aW``)b?i%HQJMtddOqsC(q6$3?Nfo{an^LB{Ts5 DQpq~( literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDF0.png b/wadsrc_bm/static/brightmaps/heretic/WZRDF0.png new file mode 100644 index 0000000000000000000000000000000000000000..c47019cb02d47d0da0c0b12db4e9dc22d8137ce7 GIT binary patch literal 218 zcmeAS@N?(olHy`uVBq!ia0y~yU@&4}U~pw*2C=TGcQY_Bum$*pxc>kDpMilP^w8xx z1_p+HPZ!6Kid)G)_}SPc3NHVDrT9g@T0@tAVf_c^7yNHl)Xex}zv0*Y|Noo6{%4r< zf4_XfkBI;Kf7SnHY}@|(|IGjKH4P8z{>y*-zmr|!$@lXa|AX0|{I{?8Q!mSW`1gPQ zS^xiAANa8R-;d+}>m8qMtp9VLe^F!2hM#}!6~0{T7LZyYchq+OmxcdU9Dlz*a2AIY a!y5kW@3b91U1nflVDNPHb6Mw<&;$Sz2WV#i literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDG0.png b/wadsrc_bm/static/brightmaps/heretic/WZRDG0.png new file mode 100644 index 0000000000000000000000000000000000000000..92bfa5ce1b6fa04f33b2d955cf561a33ea6e34c1 GIT binary patch literal 386 zcmeAS@N?(olHy`uVBq!ia0y~yV6b3dU~p$-W?*2*uo3fQU|?Vi@CkAK|NlP&14HPc z%XJJ4jOLy$jv*DddN0~~Gdl{fJqTxAFW{3X?6~L9A+I+f0(bT+MMZS=y8N+F{Fd1& z@=-ow*(8Ndww$E(DSh@!2)*`!`SCJ9VUNrCh0B=crBv+KJ?AKyAHg(=Vqs_&~bdZ z?QIcHQf*i2r3?2Dgt#BnTWb6`clz!?3y$Ye2InKrPt{VW-Xs*G5%5}7-e>oFUWFCb z_ZuP~zj?YbtoWAlO#O*F&#tgI&$sBnZ^6*L@fRiDo4%?(o%Ld`&aplDm!JKsJzINH zZ2$DnTeKd>?E0Rys$#d{`Hxqkzm!SMxn3*7ZPzp6 wm$%P)e&UPT>^B>>9FO`p|IPg0|NHGtJZG*9DpZbPU|?YIboFyt=akR{09lN%ZvX%Q literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDH0.png b/wadsrc_bm/static/brightmaps/heretic/WZRDH0.png new file mode 100644 index 0000000000000000000000000000000000000000..e6518ce5a81607da841b09335087020970741fdb GIT binary patch literal 443 zcmeAS@N?(olHy`uVBq!ia0y~yU~phyU~pw*W?*1AkX59|z`(#3;1lBd|Nnmm28Pf> zm+Kf97z;dI978H@rC!?WbvQtT{X?)-Nr3c0)h07Lr-ce-hRysBlvjLV)Y1sqVB*x? zQ_Em)Wz}U7mXj9Q|7B!^)XeqK9J* zu1-q{I~*Rc#Vu%J7vqc@jT1i|IB@VC->WKy7jsoFe6BqZw{1hq+05rpJby*JR%lsz zc$4b+b6g7(^v@I|rbcP!a2@6f`k26Ve`@z?;}<#3arvJf3Lh4qRq+3Sibc23@h2Zw zo&VU(cJQ$D?89Cw<=X4}S$>PPhs0zG&)FvO_{Cz)>^&0qv$=Ht1TEdnbmDUSe#?y- z$7){5>|$&`U1V$M)^seR?#XExQ)|E4bGhMh&u1@+GR3S^z99t?4wmNQAvwfkX`$d2HWUEz1)rR(ZvU#Kzl zvPc$1e_guK)~iD(#{7=m%gMGZE5EMM6qu*L36B literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDJ0.png b/wadsrc_bm/static/brightmaps/heretic/WZRDJ0.png new file mode 100644 index 0000000000000000000000000000000000000000..43a84562088b717e1ed98aba8107904bf367dd60 GIT binary patch literal 420 zcmeAS@N?(olHy`uVBq!ia0y~yU~pw%V6bImW?*1AXk>Pbfq{W7z$e5tF)@*Wfx(e| z^=bwN#z;>W$B>F!y_5EOF*^zzch|{bkyrFrn6~Vb+(Gvbj5Q3+XOk2U9y)c%ODE?o zOXrdsB?pgvnY1B;gX^O8`G$8J7^$>)M4L0cm3b{=Y($X)K3eDcJ;n5vv}4r ziPo+zwO+tnwxeVR4ro9SG|Rg;X`Z)mJowDIDjsSQF_F+p4I zuy=+W(N)M$)OTIFzM$^D`rM$;vhSKF9M(FtL*;IJ{PaEIBA$lZN>n!)^iJ~&v0>Pk zJUdTxo~!R{lMkw#vRNAy1iyI&%=)i>xWVRJe}ken?}hx?Zzi9Uc5n^U_0(CzDH%6e zTCM(N&n%IHlV*!3Kl!`HJx##x;}YX@yE$}sSiHWNEL1LYDYkFbj_Jy8x4mq1f6|b= zPP9<%?lzP3H=Ap`gYC*#+g?ttz3!G*bi!_8^2rZpF1;$NoIf>ieu(pSk=f-Ryq_NU fU!nScf&A6bkF!_hzf)#lU|{fc^>bP0l+XkKs};Bb literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDK0.png b/wadsrc_bm/static/brightmaps/heretic/WZRDK0.png new file mode 100644 index 0000000000000000000000000000000000000000..d5d52c4737522f837cd1345a53ce2849ee5ffaa3 GIT binary patch literal 288 zcmeAS@N?(olHy`uVBq!ia0y~yV6bOkU@&H6W?*2D3U+$Vz`(#3;1l9%YirBEz~EN= z@jC+p!&Ofg$B>F!wHI{xm<$D2AKYW;e8O?3!IsP2LHUGNU*i+D8&y1x%CiyC4v#vn!mOEE_L6L*$1DZ~wIqMm$Bq7bJ@Km)d^UKK7}%NrQ9V z0ojNM7BiPAZ<`jaRGqizvd+Pt9h|qKyuv=QY&JamZk_%79ZJ%VX2zztSVdnG+vX&5 zqh9pPL-wjGsy4sB=ZOnE*^qr)kuu2I382l-9sq^Y|K3O;3jgC^UPI-Q^ vEu3=u^8E8M6L;LW`f|y(;vX)5j!Iwhu9<$%+I=4b0|SGntDnm{r-UW|vHx~P literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/CDLRA0.png b/wadsrc_bm/static/brightmaps/hexen/CDLRA0.png new file mode 100644 index 0000000000000000000000000000000000000000..b6dba0050e7377c8e8249d767e7fd220c0e1a90b GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0y~yU@&4}U~pt)W?*1g>7F{5fq{W7z$e7@*Z=@_uv2j=l}1QPx#U2Y0q}j-hJ8r<`?(x|F5?@ z@Zrb*`~M4msdxPQ`2YWLW}f*AO(r;8_&@Qbqof_foY$MJ9CpuQX8@V%>gTe~DWM4f D9;iB= literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/CDLRB0.png b/wadsrc_bm/static/brightmaps/hexen/CDLRB0.png new file mode 100644 index 0000000000000000000000000000000000000000..fd0a687ff65620f07300e7d82667137dcd001941 GIT binary patch literal 151 zcmeAS@N?(olHy`uVBq!ia0y~yU@&4}U~pt)W?*1g>7F{5fq{W7z$e7@|Ns9C3=E-% zF4r+IF!*@7IEGZ*O8&vm#xCK;P%GbS*YCE!{nGh`Uy=p>{{Dae`2YWM2|xb)=b!QK z-~aR9|J(B$*!=(h+`glZXOVr=i}@NR6C5u5pZL;I(vBf-@n*52W9On67#J8lUHx3v IIVCg!02{_UEdT%j literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/CDLRC0.png b/wadsrc_bm/static/brightmaps/hexen/CDLRC0.png new file mode 100644 index 0000000000000000000000000000000000000000..68710681688ff33d920a9930159c1d34f40d6767 GIT binary patch literal 152 zcmeAS@N?(olHy`uVBq!ia0y~yU@&4}U~pt)W?*1g>7F{5fq{W7z$e7@|Ns9C3=E-% zF4r+IF!*}9IEGZ*O8&vm#xCJz@K@NS{{R2~kN>|<`1Se!eT858J#{>b=Kufy^T+?^ z%skKk|F7d))Ze^?`Q>4SUym8t7N~IjmG`S}x%Ii&pq-haVdrL+tIY`q7#J8BJYD@< J);T3K0RXr2Js1E0 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/CENTF1.png b/wadsrc_bm/static/brightmaps/hexen/CENTF1.png new file mode 100644 index 0000000000000000000000000000000000000000..bce50ffe4cf102ec72538aca2bedad3ad77255dc GIT binary patch literal 118 zcmeAS@N?(olHy`uVBq!ia0y~yU~pz&VDMsOW?*2r#a;b_fq{W7z$e7@|Ns9C3=E-% zF4r+IFlc+aIEGZ*O8&vm$}iz2@cMbB#A|2kp05iekNv8U2|jLL?IX5v)8aLasf-LZ Y44rRR^{@KPz`(%Z>FVdQ&MBb@0FR_5od5s; literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/CENTF2.png b/wadsrc_bm/static/brightmaps/hexen/CENTF2.png new file mode 100644 index 0000000000000000000000000000000000000000..23ba1876cb3e95b0a1b07a8a71bd951b6468dd42 GIT binary patch literal 109 zcmeAS@N?(olHy`uVBq!ia0y~yU~pw%VDMmMW?*2Lb$8Vk1_lPU0G|-o|Ns9pFffE3 zx?IP=z@X&m;uunKEBOaMtG$Gq%(18fq{W7z$e7@|Ns9C3=E-% zF4r+IFerMuIEGZ*O8&vmY%k$9Q{zlJ$Fs#%kG9sT9FgI@uXvh;!A|^MC}+iQV+IBW N22WQ%mvv4FO#t0HAMgMG literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/ICEYG1.png b/wadsrc_bm/static/brightmaps/hexen/ICEYG1.png new file mode 100644 index 0000000000000000000000000000000000000000..6a4e2cd018b78fc38c21bdc211b118212b107452 GIT binary patch literal 341 zcmeAS@N?(olHy`uVBq!ia0y~yUfk(ZkWwCHin< zwDJo96%{4H7U4I~o^PMrsojujIe%WAd!2uS5%YzpiihS>2UU-yCf7zC{LQ(sibKxt z`Io1qA5OO~&F>G=|NFRnOI6UNd^i1jQxh)NGVV^gXb}H1K;Pl_%pSF>hcda>-$ z4e|Gz^!KUHk1@7S)-?I+Hv44SmQMEAWRH(LPriuBC2o$tzi9i8%N9$jw-m>uHYY99 zt`vM0+`dy)b8m0)>UWO~CO`Y0^Z&2=ALf;LzgJH`TyMz0z`)??>gTe~DWM4fMV**M literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/ICEYG2G8.png b/wadsrc_bm/static/brightmaps/hexen/ICEYG2G8.png new file mode 100644 index 0000000000000000000000000000000000000000..3b18f61f9ef018003b4e86309842e5458f452b7e GIT binary patch literal 281 zcmeAS@N?(olHy`uVBq!ia0y~yV2EX4VDM&SW?*2@Fpy+pU|?Vi@CkAK|NlP&14HPc z%XJJ44Cg#u978H@y}fA5*JL2UmSCp#Sg?vuyz}{?AG|z0a*Y?YEj$k$I*~9(MrO{O z0|p*%&u0to6BEmKnEveK_sP$4Su#FIDzz7}ozZ@=BJl)|ykJ4!W2-H(L9b3MHeorq z;E2#W9#@SIA97oSXK{vak?WjYQ6*C0cuTM+QvjyoU?~STA^NXurPTbAV>hycr706)bKYD}r_{@mV7B@<4~u z0+;W>4}Xg!Htnds^z!%bm<5Nwe_?g_k@F~hP2v})3Ja&676XAlvmbm(U9r_9=Aouk z@581GsXZ%H7rSI9tMjzE&SRTevf;SrYvV~ijf>Lr9M-C9tk=3|o3~`|-2Ar6l@*KK qR~^0>rP+U1vhcBY*_$8TqM{4hKRLKgy~e=6z~JfX=d#Wzp$PzV!DVOw literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/ICEYG4G6.png b/wadsrc_bm/static/brightmaps/hexen/ICEYG4G6.png new file mode 100644 index 0000000000000000000000000000000000000000..a6f727182458fb5aba430b681c6df16d82dfa850 GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0y~yU~pz&U~pw*W?*2@jy zm+Kf980tJ-978H@CI9&U*IvRV;fK9E_v`=ve+OJ^|Nm9sn*7G96>si8{&qIt+V`K< z3Ty7~fA4tp@4srkRqx*YFAvz*|Ns7N=ZO3N?He{HY^!bAoOdA7^y}}1Yw}GEs`pFZ zI(+AP-_f)0AFerHaE;F*TW-?*gf;K~8ysD5Y(ZD=Cbl`O41Z)pHYuYjCKY#9zhj1+dR!xhX0ykx(@B&pKRq{eY@R~nL#G_;q-O0&WbTGFfe$!`njxg HN@xNA12{Mv literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF1.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF1.png new file mode 100644 index 0000000000000000000000000000000000000000..fbfd6822efc8bfb11c9cc96e20bd613ccbefcb60 GIT binary patch literal 179 zcmeAS@N?(olHy`uVBq!ia0y~yU{GUVV6bImW?*3W{it&*0|NtFfKQ0)|Ns9P7#Kni zU9MwbV94-vaSW-rmHdOBrC!3|Wc~a9_t__X|NsBr;SYMh{(qBd%m4WGdX|J;;or0v{=+}*_e=aUsQLF}|H8J1k3N5P_*#GC+;rxzUjOU) l&5G?O-08o&PSBZ&L20gR?NYOj7Yqyx44$rjF6*2UngFmJPJI9X literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF2.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF2.png new file mode 100644 index 0000000000000000000000000000000000000000..b7e617a20f2ed8ad0b67605d53af9aef283dc03a GIT binary patch literal 153 zcmeAS@N?(olHy`uVBq!ia0y~yV6bIiV6bOoW?*2*ObJ@Zz`(#3;1lBd|Nnmm28Pf> zm+Kf982mh4978H@CI8@Ow3ql`xNmWHO}pX0z3rYGoh9q}uRBYemsqG|pR%CGJ}2Oq z%#26u25zh|hTJ|~@~2ibudEE_Oa0SkontT9C!ZQHpOGPd-E-}A$5mG_FfcH9y85}S Ib4q9e0C)W|bpQYW literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF3.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF3.png new file mode 100644 index 0000000000000000000000000000000000000000..3ca5f9f45fd69864eb2585a39bee9481d01710ed GIT binary patch literal 177 zcmeAS@N?(olHy`uVBq!ia0y~yU~p$(V6bOoW?*3G;CKJPz`(#3;1lBd|Nnmm28Pf> zm+Kf97}7jl978H@CI8@O{V&mx`u8up_~ZZ8Vuya!eEXly@%sG7`e|Piu9-i(EBviF z^8bwQ+ix~U8u6I*KRvjHo#*SH=ZaPm|Lxjd+&%nfzU-l22l+NXuC%_h?X$tP?>7yu j*;fa}+MkkQ(P223s<3>G1grS#taT|Nptu{;d3epDpdj>;L~b(rPaKKhB>P^1-?E zY=a@+24_iD1Gjb?pHp(Dey}Ikv`0tzFAH{;3`t^OSdevasfN0h2Ll5GgQu&X%Q~lo FCIF-oHWB~; literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF5.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF5.png new file mode 100644 index 0000000000000000000000000000000000000000..55dcaf6a4c46e621415de37316cc2f0eaf9c7fe7 GIT binary patch literal 126 zcmeAS@N?(olHy`uVBq!ia0y~yU{GaXV6bCkW?*2L=I9{7z`(#3;1lBd|Nnmm28Pf> zm+Kf97>qq#978H@CI8@Ov6t8|p4geIqmbUT9({Rs1_lNOPgg&ebxsLQ0KA+jg#Z8m literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF6.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF6.png new file mode 100644 index 0000000000000000000000000000000000000000..488808e50774fa8ba569d67072f75804fb53327c GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0y~yV6X#WMrH;E22Xw~b_NCpwg8_H*Z=?jGcYiO9=cq| zz`)?->EaktaVz-;KV!XwM&h5H%!z0G+B*KMwpU{ow7e6*7@GW(?Nmht`?Aw4r+#o6 sKR4{TXv2Q$N5EkRQSm;b6$cp@&MbTSZ^7%e77QSJT>V_uIVCg!0N2AWV*mgE literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF7.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF7.png new file mode 100644 index 0000000000000000000000000000000000000000..b70f45e94e3e879f0f99bbd148cf6d58c22c1d48 GIT binary patch literal 183 zcmeAS@N?(olHy`uVBq!ia0y~yVDMsKV6bCkW?*30wpRWr0|NtFfKQ0)|Ns9P7#Kni zU9MwbV94=waSW-rmHdOBnO&kIdEWGPWAi_4#^V3~{}w-$^5%cN%%MNof&X2E4*d!L z^PVB(ZM*!pUW45J^X6O39cCQ=Z|-pQ-~5340sM*oHvX@FU>)-1`+w%Lg6A^N+l}Rw pWPTo(J6GesrQL0&a}y`Sr4rAKNv}VhXJBAp@O1TaS?83{1ONb>Oh5nt literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF8.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF8.png new file mode 100644 index 0000000000000000000000000000000000000000..a55c5a0c71ff4d3af2edbd7ea06c26ded0a32a08 GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0y~yV6bIiV6bCkW?*1gWYNgNz`(#3;1lBd|Nnmm28Pf> zm+Kf97%Dwo978H@CI8@Ow3j%M`p23t_0QdS{=`3FEnR;eo&LXH{K$`o|Nqz9c6?0w z_y0eusKc?>mf!B*%x947m;V1hncdU2{@;K8$t)8-?tK4Wo^8S`|4;w_8#ZmV{{R2@ z9_AF*3s!6^-u{0k;UM`v@ttRz;lD}m=LWLLu`%2dzHXH$>-dX-fq}u()z4*}Q$iB} Drkhid literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHE1.png b/wadsrc_bm/static/brightmaps/hexen/WRTHE1.png new file mode 100644 index 0000000000000000000000000000000000000000..083ff7c73ea579547adbb666014b4e63d4767518 GIT binary patch literal 419 zcmeAS@N?(olHy`uVBq!ia0y~yU?^l@U~pq(W?*1Ac>ZM@0|NtFfKQ04mzNg<1H)Ut zj1mS0#t2Ur$B>F!XD{3O9X1eQco42+nskcS!2Ly6i&Wl$z*8Jdf{Xch6kKz1MAbdL zCt5w@FiYZy4k}%-Sjv8m&2%lttkwjD+tbsJzdz2HVw5O_OV66m#8~umrTxD6THdnVYSYiJH|&1?+hx7tTYub(Kkj$8{!EckZ`}_8qq0TfchR^xWN&`QN(RT5nA3zwz&H*`L{$WxqbD|N8&0 caXnL4@Cwhr^A!&>FfcH9y85}Sb4q9e09}o`iU0rr literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHE2E8.png b/wadsrc_bm/static/brightmaps/hexen/WRTHE2E8.png new file mode 100644 index 0000000000000000000000000000000000000000..c9c0e483cddf4738b58b2547f29ec94548844961 GIT binary patch literal 347 zcmeAS@N?(olHy`uVBq!ia0y~yVDMpJU~p$-W?*2LKF@eH0|NtFfKQ04mzNg<1H)Ut zj1mS0MgdP3$B>F!Z!Z{n9dQt0d!Vj)&Ci;(HO6tHK;j+Ct`2dJ^=X?zPkm)L6nEGu zMqFC^J4fV3kA)`|h%L50_r6-#Y-7X+Ccm#ApPfHHTj0^m=^L(G_->`9d-r9{h~FZae5qrh#iN$b)2=MrHKkzQ z#P`~&+;>x+6qPEhDLc`+`RPe$U~>z?m^L}b0x zOy*mg`RvlAOKZ0saX-Fn-Ov5|BTDC#9SI8a?yUcJQoc2`TtxhY_-_UV1_n=8KbLh* G2~7aMf}2$U literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHE3E7.png b/wadsrc_bm/static/brightmaps/hexen/WRTHE3E7.png new file mode 100644 index 0000000000000000000000000000000000000000..1f97728955b7602412411e84632583ec3b951dce GIT binary patch literal 246 zcmeAS@N?(olHy`uVBq!ia0y~yU~pkzU~p$-W?*1w@hpyKU|?Vi@CkAC^73L}V0i17 zQNqB$u-enbF{I+w+w&WF4;cus2DrO;%@i~`#d}ymFF2s0Wdr9#rKnAeDvO+)lmaXd zeNun&ZV#jEx_NaU-`{?a@UeEX<6|q*J`eOmlgZNbYi73D@nbuTRs9 zxEA5^DtzXo)zkOQk5kT0-fXe0GyVx~_mmdWHC3{I>+=35N6a;`Jqgv< za!k2%!`>xwzZGiow9EeGeCkmu^WyyN zCH^h1I6YtZu-wsm6OYL()0>jH=J(_Un=bCSx$>0vZN)Xb7eCeANC=B9V6Y6WkNI_X z=ce~zXM!*0KE1Ev)p=v)48v6$S*`M|@9KVDe4|)r4#)de|3lr!^hB1OU$(#gBe&W8 Xke|!0^^D zqlAHh;hd+7V@SoVqZbYNnhYdZA55R|LTw(y-56h)k|yN}mi~l0HwrFYl&;`cPxhI! zhk5GJiDo=k0)FOpA2{Uo=8}HyrSH#0L)J3IZY;=J<>-5J^-0&2?#>knw?9=qe{@V& zRr-;Fv$D>&g07`~C#Te3pCcSAv`FIk`7Je0!Iq-yi*mm9eSA{q$#&4$`=H{b`xZh? zw@zrY@rv%)Zg#>%HQ`Z&eZ#CXVY6hEMgBcoI`bHV>&~Y)P2bMgGsiD9u<~-`y;~`l ns-#MPb+yHa{Y{s(KWcDwcAGkpOJ3=9mOu6{1-oD!MQ5$B>F!cP|^}3mb|sJeWT3if~hcVw*ur%q|7P1=BQn7Op$O|A1d%E3>jk zh>q)mUjf~D4l9yxT9vspwK8gkr*ddGCvZDGiV>YUXep?T`OwR945!{$K&%{c4X|j-i(@Di^XE&9iEb$mo1)Ex7aWBcEab6cdx&(T|Q^s3hqKB zzZtxei<iu64>O)T%;RYFD11D_CS}!qrya}We4p=psIkH3`KIj* zm(PFF{v0O2t@Hk@=t2EmADJ)SFMDt-cms=_MWN67649>?OuFJ$67`;aY5EQ?J$`r? z8BdV%QghVX@yaEFr)+uKOYhDtHb-;Lx!>XG`@wFms-1OGI_AW$RfmNV6DOVD<>%t8 zFnPvvE*tH$-G1s5SM9pm&-v4@sQX5j@3m8Ury2vwkDrqBY7`Y}4E^PC>A(%+n8)RP z>tqvxFXm#Fhc6Q5_SxOom&W|@J??&m3@8uMjj7ai>Jil~lw zP?Y@gDeJk(r*`evE0CCdDl_d*J%@d#O{J5Q^#>mJ0irH>4h28JGeexx2S_E9*E&lphiA8K@l0)58!GwC7 zPbdAm&Il#0E#XL=aDw5zplQRy&L?I(%u_rkO}cln<;l^mH9NP-Z-Dm?2DUL`fh(!b#2vC(?{;F`BS#;UvYEV^tHzI hA6KRRDSwpDJQhlvdnj=Vc9rIBSl$knw=9%{DE_y z{9L>*bB6uA+@bJ9#r4~bv$f}P-fiNrYmELYk@h@!nrZ@HeH9B&xKF>6Y3#?k?rJa9 zJ+bU|;+mJ!vJYfD(|nt6&bhh6O-lc+;^m|3OywM;cub??k6R=PncfZ#^*S8NZ9aZ+c^v6@ooOnuo87ry{NSvf!ce~Nm041E zw*Ti_4sz8|DSdplKj-e!es)D7#6*OBRozk6pXS21Gz2b)cH8e{2zjt!(eI;HYgz2F xUO60{pX4cLx_V~V|AUvWy=i}?P$1P&e^P$-nXG+R)`NqT!PC{xWt~$(695CTqu>Al literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHF4F6.png b/wadsrc_bm/static/brightmaps/hexen/WRTHF4F6.png new file mode 100644 index 0000000000000000000000000000000000000000..29111a3fd1b66578cd6e776d148c2b5f6edfba3f GIT binary patch literal 421 zcmeAS@N?(olHy`uVBq!ia0y~yUke|!0^^D zqlAHhG0M}$F{I+w+e>@Bm>mV!KX7u!2=56q*kRWkdSHTfE$>04rDBY%&Egh@y%VlE zeGt6j=lD=1;Z0CO3?7OP&VagVQO zqvxut^CuYWQ)sPo>H8>}xn14$SKYhf1)CxTeExg9Zqz8gdZU+HJALZ)uvc9(6D!Zg zE;{t@QgJZ<&Mj+n%jcF)zw7b*d~tK!=2uIu)yzHhDdG3lGuz+T$TO@zTF=0?)6(w0 e!N0jb#f|>YyTbYLiyi|51B0ilpUXO@geCxcKezG# literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHF5.png b/wadsrc_bm/static/brightmaps/hexen/WRTHF5.png new file mode 100644 index 0000000000000000000000000000000000000000..91ec627ca38ff6a9cf09e655a61c8b31875701fd GIT binary patch literal 455 zcmeAS@N?(olHy`uVBq!ia0y~yUke|!0^^D zqlAHhvBuNIF{I+w)k}unhaE)NKZF~(IBuEU>}+kp#bw3O_40|zy1vo^ftW4}4!+Ee z3!XApJ?$Hs^7&wh?A;=Jo(&R_KB$7emx_p%CW7v7oB zc!!zC`1eDN&%O#q{_KZB`ikt#r?kHN?DR_6{ItFG8vFHkN^d-zy6OF!JNDY<`ssc~ z@#kf}ELAQlEnE6o#r9a*-G=Sk*4$K^9cHfdz3-x9$z8FTPd7L|zuT?I%-?2r)6!l! zyk}bDMKPTT{@>%WPKY}$|Mm6ms@{7+t#=+|t8%{%7VT}+{ZwhNdc(zp1zzL*m`G;Vik|c!i8`6s>&H+`gdD?d-Y`Jji%`j9Je)#J$L=!??v8>fO$a7fFFh)Y86nb$c@i1_xcRK!~Rd!@qtj2kC=crs0cr5;(# zHGR5o<)`Q)`l&j~-!9EEd-S`7{pH;S&y$tTzvKURE%EpJ^#9ZMGnS_xe{jk`^9Tb2 O1B0ilpUXO@geCy*y~=R_ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHG1.png b/wadsrc_bm/static/brightmaps/hexen/WRTHG1.png new file mode 100644 index 0000000000000000000000000000000000000000..e56d4fea0b968e80daa465a2dcc049dfb16a63a6 GIT binary patch literal 385 zcmeAS@N?(olHy`uVBq!ia0y~yU~pw%V6bCkW?*1&U*?j*z`(#3;1lBN<>ke|!0^^D zqlAHh(ah7uF{I+w(F+^B4m(J&fAHsDrC`?F-F;U3#>$(UcKl|0q`V_iz|*Thaq; z6`XfbtS`y$li5TuMsM!#7V5J$-udY=Q9@%^S+4)w?X8R0jq*SBZC!rC)bNtqp7}v% znglz_y-vz0x@_<+nCm5$$i(h>CjPK;ys9VfzKQA#GiU3Rv;WAsx#pm*L2lu)v%v=z z7M1U6n7e<9y4{j~rAPJ$=0u-R+W$uN@zw&b+KnMsLj#X)?FyZIVe7Pr(phUW@0>Xq u74&be^JG!!O{Tiif6t{#Z>qmw{^I&&2By0|S{N7@7(8A5T-G@yGywnF!Z!d22J8U4p_Q2jqiDxR0wbJ^Fj8~QO8T${MYS^%lx&LBg<8hBg ztCF6uPS|i_f}xva$AMFYH~fx9bc*W#E7|q=X8MIP-Ww<1ub&@%J!`SLeXqde-s3k@ z&McgiU(lg*lR>$pWa|ly{XKF;%1@lPw2MA6ocs9Mp(!V)DpgO^Sy>#scG0ob8R;t{ zMN&&*zaOnVb@O~xW@*oP0~t%f9R7mZRhu6ibLf9L=URcWXT1Hpyjn+ZzU_C)YxO!W zUswIT^sKD?GndWt?cXuHJbX856@y`i#bNUp#^b9W)LAw?7do?Z+Um!1D)0X`{har_ f{^$4jzr38@`F6qjCqft)7#KWV{an^LB{Ts5asZD- literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHG3G7.png b/wadsrc_bm/static/brightmaps/hexen/WRTHG3G7.png new file mode 100644 index 0000000000000000000000000000000000000000..58efdb75ff60a1b752cef859a93064b156761041 GIT binary patch literal 343 zcmeAS@N?(olHy`uVBq!ia0y~yV2EO1U~p$-W?*30t9OWnfq{W7z$e7j%gc*_f#I!R zMhOE0Baf$xV@SoVw-+~hF&j#-f6$jJYCg=#$JbQJBFow?T_bRpWqO{K#*zmQUMPPF zob`zL3!_Yx>xyQlU>%d|Z8d85zj}Y>YBIm`@pO6oqAVGOaj)6Iv@V&`KoeT!GwS+4T*h+ z_9a*ZJQiHc`M>8`v_tES59|JFF53A-Zsi5L775wBzrp;40*U=B*RH=%{d!=Y6wk%0 zvRylTy{DQw@GMxlspas7Nv|(odG>6POAObc5<&M;&x+p;y1X*wm2pl54aTk$G8m4; z=2!3GTM!Xab4_v8?xYr*y7Jx`_g~uoldEGaUhv^$ap2tj3=9kmp00i_>zopr0MPoA A=>Px# literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHG4G6.png b/wadsrc_bm/static/brightmaps/hexen/WRTHG4G6.png new file mode 100644 index 0000000000000000000000000000000000000000..aafc011760c2207af14879f44ecd9539635de548 GIT binary patch literal 322 zcmeAS@N?(olHy`uVBq!ia0y~yU~mFqMrH;EhMTh{t!7|gU<>dGarN@@Vqjo+>z7f& zz`*d`)5S5Q;?~`B8@*Tz1=t?!wBGSH=HRnkB4TA`O}TGsc<(!`(N){f`gCt&uYN-M z&W*dW`EKjBaC0c#Sd+ex{idw?%$v0w%#Ho_ljk!&+Wh>r;!DoZe?=!`_?T4AbX`8` zx9QlK>x;zB28rzR_X+#{rz}Brb(r6*?MJ;A++Gsv89(2$TE8>Q^RH%iR+#wCM^^i- z))lb6W;S^LYT?=4Zqw$ge0_27u8QF6fE3#n*RZq2f~Koayt>ol^Xs&3dhJYhTbcXP zSDkZ14=z}>^|p0j@*^LS({5WeZ#i8FcXSmmSh8!@yU_m0;aA`PiE;Ioa9_y3IqCg;!N9=4;OXk;vd$@?2>^CNjKTl_ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHG5.png b/wadsrc_bm/static/brightmaps/hexen/WRTHG5.png new file mode 100644 index 0000000000000000000000000000000000000000..3615bebb26699776eaee11dd00fbdeeb19748ebe GIT binary patch literal 316 zcmeAS@N?(olHy`uVBq!ia0y~yU~phyV6bLnW?*3W=p;9vfq{W7z$e7j%gc*_f#I!R zMhQs5)5S5Q;?~)7hF(V;MA#nKuMt?Y>1mUz0Ka0AVe9k_8$Ph{Wha|EUfA1KR^8q5 zmEo55ELRuDj?1dvn?8S=@3~Dlr}k{knd(1(1b#+bcVkiNUhl=4;-8+$@J>y+|N6cQMPC`myE~E?sl?p;q#~-l9JZKUMV} zNchVx4wft9zgDq>rM0EA@P2YzyRKi=oxJ)U4shj6xHyT+%k6}khLFdSq!x`>uLVl3 zEtb}00(ZE+uU4;pd73TIS5dj6PmoXWkG)^pxq{-ZZte6f*{;n_AK3OJFoiX-H|Q?r zJRu=-d<9Rf!?_2Wrp%Q!`~2xhugtgB@DRU^_P4G5kCq->u|t1@Kl@>ACRG)cKaZI2 Ym(SQMQ|0lSfq{X+)78&qol`;+0AgEFlK=n! literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/MLDRE2.png b/wadsrc_bm/static/brightmaps/strife/MLDRE2.png new file mode 100644 index 0000000000000000000000000000000000000000..0305db515bf8f502476ffa75cd9dc76723436855 GIT binary patch literal 189 zcmeAS@N?(olHy`uVBq!ia0y~yV8~!#V5neZW?*1YVNtDQU|?Vi@CkAK|NlP&14HPc z%XJJ43`L$Ujv*Dd-kvw)b8rw~y)a*6+Z`v(hg^9tIQkxO^*K2&zRdAxb;|SnL#%H~ z^gq|DF;5bm&sf=c%4v#pY--xmIlhOoM7~bkq{iWJBe!9v!GUiAr@cRg?(V3~HJuxF vT2uaF_bvX?MUh*&_yi|Unl!0yjdWAU{Vh#mw)Yqq7#KWV{an^LB{Ts5F(*fb literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/MLDRE3.png b/wadsrc_bm/static/brightmaps/strife/MLDRE3.png new file mode 100644 index 0000000000000000000000000000000000000000..ec6c34db7d7fc70718dfabe12a79e1bd4002d41d GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0y~yU?^ZL$*d2~#7KY6V!|I*U|lG;y1puos#VVt4Xr zc*LgjDravczvg*Ru2Nm_;=q-rpPo@qZ%)`M+SeWVa)t- zm+Kf980tJ-978H@y*?-ln!aFBYZym$9mZP zEnn+$zcV=;%==&OmFOqw3ii+4=^qT8mi?I5+t>H6*rWj|>K_Y^)IW*t>3B1g<2jhc03jY|A{v@&)Sv2&>I~-$XW9u;FcToC&yOF2E^8bJPHp6F=5B=az vzH?mQ;L#VG+l}mm7FJ9#JSDM@hv8Rl--jvxuDLNVFfe$!`njxgN@xNAWF_`#ZM+$e4k+X{K;#;0P;Tbo{*?2~B7BG0Qu-L0iW?dk)!997)~Bgl{--ScSNHCuCA)${&$5I3@YCr^wCnNfCpte`w^x=Czd!3=9mOu6{1-oD!M<^g~Lj literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/MLDRE7.png b/wadsrc_bm/static/brightmaps/strife/MLDRE7.png new file mode 100644 index 0000000000000000000000000000000000000000..f90672e02db4fec5f8fea033a22d238286c8af1d GIT binary patch literal 211 zcmeAS@N?(olHy`uVBq!ia0y~yU?>A&MrH;E2KCIZAOW@jpAgso|Nk>EFoYhuT*tt` z(BbLg7*cU7`3FDy`Nkjo%uV&Rc3S^y?6vm)x8eFP&u`E5pSjtF>wh}){pyr|@@!&> zBA+EBegyvDvGa~ktrcF!ANcUw*yull@v8do_AXEV*LNNJ z-*@c4{VDmU{hvIa{lD3-Cf|RozW>yJzlQ(PcmMpk_(AUJ<#v7sOQCJ&Ch7OGFfcGM Nc)I$ztaD0e0s!EKR<8g6 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/MLDRE8.png b/wadsrc_bm/static/brightmaps/strife/MLDRE8.png new file mode 100644 index 0000000000000000000000000000000000000000..94f18ca655736cc840169aadf797350f98113f9f GIT binary patch literal 227 zcmeAS@N?(olHy`uVBq!ia0y~yV2EO1V5neZW?*3OU@EU+U|?Vi@CkAK|NlP&14HPc z%XJJ43^P1k978H@CI8@O{r&pCd_qIvJLTeciiP{$Z*(uPd+#{uXF~Ilp9dAXAN)xS zaCl~*WKk?3@#f(iHa50O6=n&EhjZ$A6dJml*Yrqs9`4!jT>f#T%Ks0G3;L8Tct2ei zob&V9{)tnr{&zJxE7$q?{y%%6=k}g+>c1{|E%~&k$YIXU6Ed|b=k~unG3UL7<@JfY jC)}saw3FJiScai=iSPYz4H;Gj1_lOCS3j3^P6P literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDG3.png b/wadsrc_bm/static/brightmaps/strife/PGRDG3.png new file mode 100644 index 0000000000000000000000000000000000000000..1bf159e4b9edcedd3c85eb70a5b092593172d66b GIT binary patch literal 138 zcmeAS@N?(olHy`uVBq!ia0y~yVDMmIV6bLnW?*1=G&L@pfq{W7z$e7@|Ns9C3=E-% zF4r+IFxY##IEGZ*O8&vm%;VhgRs7tq#)PYfBjg2iswG}G*i8A_+$ev_iXq)FLGbrM thRYxKJIY;7Y00(Uu;bN#j#Nel)fk58b#kjOF)%PNc)I$ztaD0e0steU%G7D=2;KdxJkU0x9<7sD0j??A>A-R@HfNt zkL|MEC)+pfcwoD>HjY32=H%>CwHDcSVq&^6{0!-?pR#68=FMaPnd<82vd$@?2>=Zf BGG_n) literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDG5.png b/wadsrc_bm/static/brightmaps/strife/PGRDG5.png new file mode 100644 index 0000000000000000000000000000000000000000..3c437481d90f81bd18a00e98ed9c819a153e956d GIT binary patch literal 126 zcmeAS@N?(olHy`uVBq!ia0y~yU~phyV6b9j29a`Str!>>*aCb)T>t<7&%nSCdgyW; z0|SGxr;B4q#jWHY{H#3AQ#Q(<`jO6``lr#bE}cqDhK(7=w=nBpHD_R8VDNPHb6Mw<&;$Un4=M=& literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDG6.png b/wadsrc_bm/static/brightmaps/strife/PGRDG6.png new file mode 100644 index 0000000000000000000000000000000000000000..1c36855e78ba17caced8d7d39cbbb45dd8cc9c14 GIT binary patch literal 150 zcmeAS@N?(olHy`uVBq!ia0y~yU~phyV6bFlW?*30)3tvJ0|NtFfKQ0)|Ns9P7#Kni zU9MwbVDR>IaSW-rmHdOBm8W^~$MbThejMaatx0Gzk~46UY?ofh^R3z7Eq{S=Le{*) zCAJNcKN!=F%2#Loa*{jsL*2jao4vuY{;CqT(ijegD8rpIyktxcGcYhPc)I$ztaD0e F0swfi1=F|7BIo(S|yv$Wcv?+ k_uao5T-(1;T%O^O^l!^^qH&)Y7#J8lUHx3vIVCg!0EfFPlmGw# literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDG8.png b/wadsrc_bm/static/brightmaps/strife/PGRDG8.png new file mode 100644 index 0000000000000000000000000000000000000000..378feb8c6c454ed0f9f6a3989a86da0e68b55179 GIT binary patch literal 132 zcmeAS@N?(olHy`uVBq!ia0y~yVDMmIV6b9jW?*2@JlT7Wfq{W7z$e7@|Ns9C3=E-% zF4r+IFj#uJIEGZ*O8&vm%+oyUtL(Wdo^;u^&3uOlXi5ZCmJzmlW*R&bMCZrY}_yN?dL kmBxy^-Nd8&_o`-zNaNu-X23=9kmp00i_>zopr0PC1PqW}N^ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDK0.png b/wadsrc_bm/static/brightmaps/strife/PGRDK0.png new file mode 100644 index 0000000000000000000000000000000000000000..626ec400464779b6623d65deede9de5308ce32a3 GIT binary patch literal 175 zcmeAS@N?(olHy`uVBq!ia0y~yU~pz&V6b6iW?*1oFPN&rz`(#3;1lBd|Nnmm28Pf> zm+Kf97*af4978H@oxQl5x50piCBR)T$cSmNLDY?gnF8GxHa2me?wn9Gy={`xx_M95 zr>wNio9V#i+BC;#CA)}Z(J3RV1*`V`sl4wz_e$If-bo9m-V7IiEwrp9q22rCCjVY5 eEysnEYXq{i@;>Bkf$ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDM0.png b/wadsrc_bm/static/brightmaps/strife/PGRDM0.png new file mode 100644 index 0000000000000000000000000000000000000000..cbee2897f961f80987511651f4b4eb40ac25653e GIT binary patch literal 157 zcmeAS@N?(olHy`uVBq!ia0y~yU@&K3V6bImW?*12?n_Q)U|?Vi@CkAK|NlP&14HPc z%XJJ43_+eQjv*Ddl7H~C{g+tbe!uc4ZNt&5$b+@k*s z_D5`DzA$U>8VSr)yZ*O+!LR=(l9&I#>HO0mNY*77tQu2##7;iC&cMLH N;OXk;vd$@?2>^3uI%og@ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDN0.png b/wadsrc_bm/static/brightmaps/strife/PGRDN0.png new file mode 100644 index 0000000000000000000000000000000000000000..f097b1df35b1540345727cff28a5e6fe49ec4662 GIT binary patch literal 112 zcmeAS@N?(olHy`uVBq!ia0y~yU@&7~U~ph$W?*2*{vhVWz`(#3;1lBd|Nnmm28Pf> zm+Kf97*su7978H@CI8@OtCwiw`zz>W-*Son73YQjfiL+3emxiXZ0?)EAfdl&>gg(x R%?u0-44$rjF6*2UngC<9BANgI literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/PRGRO0.png b/wadsrc_bm/static/brightmaps/strife/PRGRO0.png new file mode 100644 index 0000000000000000000000000000000000000000..1267140d310aa6bd34d4ee5bcc5db339b8310805 GIT binary patch literal 368 zcmeAS@N?(olHy`uVBq!ia0y~yV3^0iz|hLb%)r1fA?k7h0|NtFfKQ0)|Ns9P7#Kni zU9MwbU{v*VaSW-r_4ew<+@lHtY!BoE1B{roQyM((>1^-}TX8$OYm~ebO@8VjOt2N7E>s+VDjYwZ2nelXe#Xb~IqAyFD-+!xxC(S#VP7f8 zyn455*45WX%Q?$Mvkp2>nVz@$yRx-`EeectYWyiR$>C9hh zoZcGrQm{K|gUgeQH0LERtQX4PaBTT4FXr)JlS<(21%KFu^C!f~M;(3p?{DPC2Kgzn zk?LCN5&Ncgy05tEko4`y+_X#a-iPO==Hz8f?=)T)a_WW5^JN_STXhBrJJ2QP8~iXb+^4xTDeZ}ugCuQ`s8?Jzr!=nl+37zJ-+z$ zEw{jnA9Lua#et*p5G9N2mHaW7xMQMhZbP^^#ZN!D!! zUXI6i9TqxvxMGv%G^Wl@rJt2=KAzw-X#aG;{({er_;kH{c42n{;yxBM`Fa;NE^OHU zpnl=Y^q5K4PdlBCIA!@s?U0kDqY>v5(WSe3;x2nQ1`6`Thd6GX)AWLU4C zu85eJ-8gOArLwG_GSTO{QYLlpc>QJFHV1#bgv&2izJK#WZ|$*&^0%+2Z)6RR`TpTh ucQ%^zK?-{fx*+&&t;ucLK6V5(Jw6k literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB1K0.png b/wadsrc_bm/static/brightmaps/strife/ROB1K0.png new file mode 100644 index 0000000000000000000000000000000000000000..61925a2d5d63b2a59a609cdf1e7ad978157e44b1 GIT binary patch literal 184 zcmeAS@N?(olHy`uVBq!ia0y~yU@!w=MrH;EhHc$H<}olZum$*pxc>kDpMilP^w8xx z1_p*)PZ!6Kid)G)_}S_uJQmb1x)|_r{{L48O?dt%t6YpxdYNo+OU`NgN#_@8bsD@6 z?Gsv7WGAd>za;RLhv$<<2{W_3*)Mr!X6q^Z%l?}fbS%CQP`SXWbVcRAgnx`HY`F@4 nD}0krXxQbP0l+XkKur);r literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB1L0.png b/wadsrc_bm/static/brightmaps/strife/ROB1L0.png new file mode 100644 index 0000000000000000000000000000000000000000..6e51ffa1ae54186f8906e6e673915a1916d4ba41 GIT binary patch literal 252 zcmeAS@N?(olHy`uVBq!ia0y~yV6bIiU@&B4W?*0l&NIHqz`(#3;1lBd|Nnmm28Pf> zm+Kf97&dykIEGZ*T6@8ek4aI0^}_y0;cW(z-qy2hTf(wm_r95?edA`Os1W!1gMu3l zcXS`v(ABv#ME?wrF*B2VdwxbF!@(IB3~W9eV~qK9Q0;L@qHVj;xos_9R^5>}W4VlJ z`faX_M@^=^^E-C%l1*PynRKG&jXoil3%R!rbb8clHdzbO!>BFSr^&3Ry8Ew(2f6*?#|Cjq7hBN#!Rn&&v9UgC+MPu+rr3Bq*- zAMF2EGMq~Jf8dW`&TV$KZ}M;cC;H4N-e6qcz~h|s?SK2tZ~c;wN){~TmryvRy P&j50_tDnm{r-UW|En`ki literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB1N0.png b/wadsrc_bm/static/brightmaps/strife/ROB1N0.png new file mode 100644 index 0000000000000000000000000000000000000000..f82245b644794fa8baa53d3ad54391f82456ecc7 GIT binary patch literal 183 zcmeAS@N?(olHy`uVBq!ia0y~yU~phyV31{GW?*1Y*#2V+0|NtFfKQ0)|Ns9P7#Kni zU9MwbV94=waSW-rmHdOBm8U}D|Eq;P@}B~Zu~%z6PPCs=*dl-GMT?=@OJ_-@e+Fzm zhR*;0+Y7MSPr1loyp#2q1;B$_|N=cG?8LZ={~z4#AQzh0|Nttr>mdKI;Vst07DN&S^xk5 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB1O0.png b/wadsrc_bm/static/brightmaps/strife/ROB1O0.png new file mode 100644 index 0000000000000000000000000000000000000000..94ac418a53069a40e62ba4525324145ca5bb2c3d GIT binary patch literal 152 zcmeAS@N?(olHy`uVBq!ia0y~yV6b6eV31>EW?*3O3VYAPz`(#3;1lBd|Nnmm28Pf> zm+Kf97<@fl978H@CI8@Ol$ZEmWOrDCH{h5(TeXC<+@T+b5A+>OICeInJ+s~TM`G9k z3H~>n);#Bag!do&@%_J@)#5t4DT(~0pX+Dn|C48!&CKv4`J$6fDbF4T1_lOCS3j3^ HP6CO3f z85kHjJzX3_DsH7--0#KgD8TmNy+v}+ksH!yCY}pg9l`Ouo8uP?m)Z5ZWs0G=8i(SNE}&k}=2yB?o8cULQ=`|c$61|KJx6zXELtxp-{+FT|MTCK(^Gb*lsD{}ep^>xF^j45)uj7D zv5d=Cu`7h%m9|-Z?_c(sU7D*lZ+En>H(GtOyz%V<7x|w$8$$D#v$@`#xfi>1&AwHC zBkK7!IQBcbJD&Aiy5jX#mRrpF@1m-o9o>6tL+G}7{7W^?J?iFP_cxZ!xKvYj-jc`a xSC+rrx?~;DyLYdfJ_7>-gQu&X%Q~loCIF5%mdpSE literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2F1.png b/wadsrc_bm/static/brightmaps/strife/ROB2F1.png new file mode 100644 index 0000000000000000000000000000000000000000..c6f85b0b2d8820579af6ba35ee0158b73f82a4c0 GIT binary patch literal 181 zcmeAS@N?(olHy`uVBq!ia0y~yU;tqUMrH;EhRuIAc`z_Aum$*pxc>kDpMilP^w8xx z1_p*KPZ!6Kid)G)_}SSdI@15Ib{CrNp7dFHa!)Zv3C`ko4c9z+r>E!j1ZR1BFB1_=SGk jGc#9yG&-d=k(Yrpv)J~k{l5 zm+Kf97>Yby978H@y}h`Rw?RRG^+LXmj_gCXL_=Yjvw<=PKXEa!3H(qoD-nx3%6;6P ziDRt@^98!{>Byt=yZtD4Ws9*mfn^xiBHWO)uV+;%o44$rjF6*2UngB>OK|25d literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2F3.png b/wadsrc_bm/static/brightmaps/strife/ROB2F3.png new file mode 100644 index 0000000000000000000000000000000000000000..ea2917b43a93f5f51ae1fb520f31e76114439af9 GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0y~yV5nkXU~pt)W?*1Y(Na3ez`(#3;1lBd|Nnmm28Pf> zm+L^3r;B4q#jWHY{akzoJPRD0ZD%nw+panwU(zW5f=QlZ)d2(MyVK;)um{|^c;LVR zg?^O}&5XVcjIj($n2%nNf5DXCd~r>w!p)@)o9YUV+*xs81%nF%1NWa3FO7Or3>X*~ O7(8A5T-G@yGywqD&oZrQIz`(#3;1lBd|Nnmm28Pf> zm+Kf97$QAg978H@y}h`R_ke-`vx9Qil%69QDzj5X+d)U0!oa}5;OXk;vd$@?2>{0MK%W2r literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2F5.png b/wadsrc_bm/static/brightmaps/strife/ROB2F5.png new file mode 100644 index 0000000000000000000000000000000000000000..ae3669a79d5a1b7341aa833532ae1703888ac556 GIT binary patch literal 163 zcmeAS@N?(olHy`uVBq!ia0y~yUi7mBr`zwsU^6EB<0UR`cgSqtET;|Llop_`mfOsIfPl zWJv$#kY<#ee5>Bg;Gy2{#)2pQET5H|ehM74=}3@sGng&tQx`K&K9$c_jbW8bDUY|= Sax(@71_n=8KbLh*2~7a!>^U(2 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2F6.png b/wadsrc_bm/static/brightmaps/strife/ROB2F6.png new file mode 100644 index 0000000000000000000000000000000000000000..5bb74e497016fd3dcb236c312278cbcb31c2d8e2 GIT binary patch literal 107 zcmeAS@N?(olHy`uVBq!ia0y~yV2EO1U~pt)W?*2*E?1OfU|?Vi@CkAK|NlP&14HPc z%XJJ43<{nujv*Ddl7I9wuuHgE9-jR9fL!Ni=9!<5*O`>8IL64}{Po-F)}FYF3=9km Mp00i_>zopr0Kpp}?f?J) literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2F7.png b/wadsrc_bm/static/brightmaps/strife/ROB2F7.png new file mode 100644 index 0000000000000000000000000000000000000000..fe11f547621e8b86aae44ea7fcf4b61f6c1c67e1 GIT binary patch literal 137 zcmeAS@N?(olHy`uVBq!ia0y~yU?^f>U~pt)W?*12|C?mXz`(#3;1lBd|Nnmm28Pf> zm+Kf980Hv*zsXVjs&nIO z8=>E}O?UtQpKp7{=iC4P&z*1DPrA+j&H1Lh{f7VT8|D8$bT?W)pQHM}!Q+I@$}8QI s{wKQ#rB86*ApPd0u=wJfNjDkfpI&_M&yHV)fq{X+)78&qol`;+0G$F+0ssI2 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2H0.png b/wadsrc_bm/static/brightmaps/strife/ROB2H0.png new file mode 100644 index 0000000000000000000000000000000000000000..cb64f9d096a21b0435798b2334d45df79ed8d47a GIT binary patch literal 213 zcmeAS@N?(olHy`uVBq!ia0y~yU`S2FKa!MF63$m*7hT;?Du7LJKHA~_Hz3NY2OZ#_%L|E3t3EpOq1)8sMT+Y!ZPKjD>?M1Dy zm+Kf97+!k1IEGZ*dVATB@2~<7YrtYY$!eB1ITd&A==DbfmA*20ygkscpuzBl;98@S zoNel?$@L6EznT7&PGCNpk|24D@yY~Cu3brNIV#~>Cgoh58ZzyvZa}GI%q*v=S)W1; zraI>uzg;1knx0iZ>+&Y!t#R|5JkK~E)Nnpe7DXZ_dl!UK|o#-^T*SoZGkH`G2brbCt zD|`{^TC^-gXz!NS{zopr063 zm+Kf97#DcDIEGZ*ntFM!7qg=P!vjurw}%EFmm3K1c=@C*yy4}yK_Kvmy1Sa^KxyK`%93I^VJ_T$FgnYU-gPN*uGT1cjF_k?NV7!zIQB4JGf!7W#Wr$KGB1>xSEe}%v4NLiI7T;QAfd<8a{u)jrRXEF$5JM4+UUf@O(gzV(PfX?(0j4d zx8-TI@h-R=F1lE#P+_UW^v(&F!&7@h#Adl45xI9`3uo(^i7)IP7itM8oG*2DnsF%L z^Q<5_ZsDwh^Cxb4m^qI@=Tx}neUrzv41cf4e_WrZ@bG1vf_csJxQ~*N!lAa(i7TFE zghk|pd)=@&Bi*Gv`_r+*deQzttHO*<)qi64{l4$lbq0=g3=9kmp00i_>zopr052)o AIRF3v literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2L0.png b/wadsrc_bm/static/brightmaps/strife/ROB2L0.png new file mode 100644 index 0000000000000000000000000000000000000000..c33e51178d0fb5d1efdce9e27baa7f4f64ffa4f2 GIT binary patch literal 736 zcmeAS@N?(olHy`uVBq!ia0y~yU?^u`UlFzskk-w%EtW54kBzH&KGv-UcAO@utXzENo%9Qg;mU=Ar``axO*1xNlJ9I z90}QQ*uimC$gv)so{n=mrJ0#xEX+)5T8o>k8nnVYv=$yaUj4qxZ_^~zf11zB%ir&l znewltu_pCG{8OVpjM^q^uQI-OGvunfFDtt6=1JQw%>>3{oDW()+-fY#%6;g=BU1a8 z`Oe&fJO#;7)o1GT({N3KD zzlqrWkTL&;V8g0cOUqi?3|ADDG+35#NG{kQAa=v2VoTGt_lKK;Yq zjmPU&$C~_;j7z`0@Qwezuc>* z9~1AUUGHD6eE;FUYkj9zuPNyKlhb>u^a%e=;X8`nY$6%;r_O%jjCwOw!Nphqz@mRE z`0Jdyr%6WD$i>IMvkp{Yo%ZxkdFH~YT+b`}@6KK7adYmpQ!*!mU#+xwsQf-?iE6yo z;vId#kyn7J|SkBOxU_j^%Kss zz1j4G_2-q^lZ`(tZRZGIKXTtPz_!fsRqc|Wa~JQcw_Q53^xW4!Q%-JV{Jt%7c~^7R z%fI)y?oPUK?f?I8XP+$kYWeu6{1-oD!M zm+Kf97`A%4IEGZ*dV9r?k4aI0^}_y19&0R^+#hDVxw!3%L`Zbx0#R1S$nH|R6!R!a z;g@kv3D5i)%AOgbqPjg39DDzZ^~TVFfDQW%$Z9UFRqLJ6&n;b zIVmdX%YB&)vm+G>e$A6>j_uy`Uhh@z!TT+~hRo*K z-E+qH^C9uGXQag|kA7lX;dnT+qi(uYiUlWgZ_bq?37seZpV-e+K7 OVDNPHb6Mw<&;$VJH)^N= literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2N0.png b/wadsrc_bm/static/brightmaps/strife/ROB2N0.png new file mode 100644 index 0000000000000000000000000000000000000000..e68aa58cc471f5bc12bb8af44956b24599bc0012 GIT binary patch literal 303 zcmeAS@N?(olHy`uVBq!ia0y~yU`S+OV2ER6W?*38eDY!j0|NtFfKQ0)|Ns9P7#Kni zU9MwbV0hx`;uunK>+K~&u0sYQY!CKZtt7k&~J6OcbpTMxBn+={ok*fs~EiOzs9)pi3T$;Ffe$! L`njxgN@xNAS1*AR literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2O0.png b/wadsrc_bm/static/brightmaps/strife/ROB2O0.png new file mode 100644 index 0000000000000000000000000000000000000000..3510ca12f6d18a0547d55ba477f1ebcce17bfe05 GIT binary patch literal 157 zcmeAS@N?(olHy`uVBq!ia0y~yV2Ed6U`S$QW?*38Nt=6=fq{W7z$e7@|Ns9C3=E-% zF4r+IFa&wJIEGZ*O8(K$@Lz&$O7Q`?&cg@#AN)y9a4-00V4!SaFDW57hyTQ!cpe^( zbLJ`Mm>*fl7fAix%y^Quo^OM4HRH*v|K)G+mvrFVdQ&MBb@0Gh`$ssI20 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3F1.png b/wadsrc_bm/static/brightmaps/strife/ROB3F1.png new file mode 100644 index 0000000000000000000000000000000000000000..8e95df7f6ad7b6592e41052168c2bebc3f960532 GIT binary patch literal 213 zcmeAS@N?(olHy`uVBq!ia0y~yU}$1sV5neZW?*1oIkMv*0|NtFfKQ0)|Ns9P7#Kni zU9MwbVCeF6aSW-r_4e{c-UbB$)(ieR8j_8oI&Wos-HS!sH>k8V+&Wo1Y4KHupF(=_ z@Ax9;@W$FHWlj{b;Y?Fxm+4fMT+tV($`s;$%8ltxilfq}u()z4*}Q$iB}JAzPl literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3F2.png b/wadsrc_bm/static/brightmaps/strife/ROB3F2.png new file mode 100644 index 0000000000000000000000000000000000000000..6a144b7b54385da6104c4b4afad88ad8e4d5bbcb GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0y~yU?^o^U?^u~W?*1oXPWzkfq{W7z$e7@|Ns9C3=E-% zF4r+IFw}awIEGZ*dV6UjXM=$N>jix=vnJ^sUT&Z7oC#FYn_$$Wa_rqd&M0lpOu0Mz z`4vx;D6Oi0-aAJo>aE41i+pm0mA;9K?UBd*kz;MK{^4lFzAs zs7{Hki0lzhxb#h*Pwjo{UcI#+9rzxd_#N}Vy!5MjEz`ox)zT$1tlly(Ffe$!`njxg HN@xNA^3GAS literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3F3.png b/wadsrc_bm/static/brightmaps/strife/ROB3F3.png new file mode 100644 index 0000000000000000000000000000000000000000..ec92b6c9822dc7501fbbe821a0700e067c7ce06d GIT binary patch literal 187 zcmeAS@N?(olHy`uVBq!ia0y~yU|7e%z);S}%)r2~;PXo_1_lPU0G|-o|Ns9pFffE3 zx?IP=z);}n;uunK>+R)@ybT6CE*G6edL{-&^jT;jyp(0fv};m8t}H9lJVg(f-9=gdrg*eRyDeVR_| z_3zKNab^ZtomV)f8ZFV8BVFWt?umW+#t0p;)9RlXSUZ}#3;$)}2=9nd4IOJ3pTb@dhY!!^zb?Ufkxoek(>=b{FgPbuT zZ4>6FrdoAVgffBSq&>Q|X~^O@@H-6x)CU5b!WO{=+{8ksWj vcK4IRmt2qWobkUGU6b$O;c+5-C*yL_<+4efi%l6A7#KWV{an^LB{Ts5;U7tt literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3F7.png b/wadsrc_bm/static/brightmaps/strife/ROB3F7.png new file mode 100644 index 0000000000000000000000000000000000000000..2b8fe006e6a2e95281d18c0f5505e20eb5a85c85 GIT binary patch literal 185 zcmeAS@N?(olHy`uVBq!ia0y~yU|7$ka~|^Dm|&!Fc8Z(k6o(fKg(4p~bp-nkt7rSK z&8wPz=9&D@lzYsT+9$Hp#MlE3)E_yo3fX?|{RysTN7i&!riA%VIHS4oUH>!gjTKFo r4#iY&GgjDsb9=Jc?6c4K>KIHPv&<~2z3t4vz`)??>gTe~DWM4f68T6u literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3F8.png b/wadsrc_bm/static/brightmaps/strife/ROB3F8.png new file mode 100644 index 0000000000000000000000000000000000000000..709de86b2dcbb264fb93d1b390be034ca8b6b540 GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0y~yVA#&Uz);S}%)r1 zm+Kf97-oCAIEGZ*dV6IfZ-asW>xF!sHzmxG2YF?D-I7Jz51eaixbZ*V$tkgLivE+n z(|;SB{M&xM|0C4bT-CIAUt;3ChKWCUdCn*^JWK!DT=C<>+#UZ5t{-gvP|oz!Tm86} z%%Svm%`5Cp&u#r2Q~156fBTL6mVNp~9-pVV+PyYjuJ(PApMYGe`oD9xc3j;1;lS@{ mC!TBFylJ1AmzQ_%w!GU%13o`9>5~i$3=E#GelF{r5}E*L|7BMI literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3H1.png b/wadsrc_bm/static/brightmaps/strife/ROB3H1.png new file mode 100644 index 0000000000000000000000000000000000000000..d1d2482bf91b98c5f9c5edd0cd23f936d56ab807 GIT binary patch literal 248 zcmeAS@N?(olHy`uVBq!ia0y~yU}#`qU?^c^W?*0_|Gc7|fq{W7z$e7@|Ns9C3=E-% zF4r+IFs$`-aSW-r_4cwOU$cS$>xIIrsr?P+FQ?uqjV#|Qc8|qBV7iKsM%khZ{!u2c z7Om7%`?P4XWWtGq&g?mie|J>;as6$^D5!MU(&b#Cd{dvpuX1mOHa*5G+)0>_N)drJJ%*E~;{n#WAGf*4xV)c@HZHuwL+w2{2+>Y~bX!X(`WyiAnj71cR1sc=LkC@4*i* zNms5Z{vRwK9B^ZkGRwK~L3!P@vnD(jjlZY}Z#%{w@VG~0)?)^iUhN4^fiBA~@Vsww zeAtt`*X{7M_pYHYPQI&NvC6n@mGDuo;+Vcyr_E=bt>3aJ)uML2%JB;ZQ}R|^G%gWU zTClpH;L|6r1@T4p;Wp3v%RUMJSRcB?t>jAt0|Nttr>mdKI;Vst0ID2%ng9R* literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3H3.png b/wadsrc_bm/static/brightmaps/strife/ROB3H3.png new file mode 100644 index 0000000000000000000000000000000000000000..dd082dddce30b151bc2356196472068042a57def GIT binary patch literal 285 zcmeAS@N?(olHy`uVBq!ia0y~yU^u|Qz);A@%)r2~v&C)-0|NtFfKQ0)|Ns9P7#Kni zU9MwbV7TPz;uunK>+Ka=zC#KUY!CVk3?4nZ)Uvo>OP0)@u>MQRS9%vNWZG!;VV|!= zPv^qdlRy1!%6T%GPu8kN@EuE&ngMs4hRiXu2>t_x8_q6}(!wfT6! zvp&bi57-ynO0aF%a+AfTDIiSlK#ZP7!fq{W7z$e7@|Ns9C3=E-% zF4r+IFj{%KIEGZ*dVAT{@34Ug`-lChE;BUP9iDK_VTf;4E=k#}%6CDzK;+PoQ-ZrT z?t10W_MqK9`FhYKv5g8>4+npl{CVEzKTNB{&K0!Pvm8*Aa5#6Ep@aDb(^(sal{`V` zrj#$^w_DhKguxReDXg2C%3}U*f$cs%%=?-A!j96zgRGZH}TBph<8jmF+Uh@<{rJiFzmoz1_lNOPgg&ebxsLQ08Oo-QUCw| literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3H6.png b/wadsrc_bm/static/brightmaps/strife/ROB3H6.png new file mode 100644 index 0000000000000000000000000000000000000000..6d0171b17d992fe5d512db209651d7b226072608 GIT binary patch literal 320 zcmeAS@N?(olHy`uVBq!ia0y~yV3^0iz)--*%)r2Kl{NYl0|NtFfKQ0)|Ns9P7#Kni zU9MwbVEF3k;uunK>+O||yoVJ8STFQzym+L>5M1-SB_ISdNiIYM! zeSWemw|>X4GMgTe~DWM4f%1(b3 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3H7.png b/wadsrc_bm/static/brightmaps/strife/ROB3H7.png new file mode 100644 index 0000000000000000000000000000000000000000..04ba80e7c8dc0435f93e2d3e907db62dd800f948 GIT binary patch literal 270 zcmeAS@N?(olHy`uVBq!ia0y~yVA#vRz)--*%)r1pG;E!&EjXR=jcv`Bn@38f=*31f=z2K6Q(|Rg zExNV*$)Ei-2Yc-$Wvxnnu+0&@p}}y2#ojtLt8rEoKT1U@xrMEx7l&ecNOvnLQ1S`vXN>8k*NK@bkYv za3tYl@Qj5TC)Qt`vCuT(`~uT!h7n&ralQ?(-ZqK5cZGoHj3$T8*Bk0zGX9DCS@7re cqdSZ%<{h~yaL?@v0|Nttr>mdKI;Vst05&0Q!~g&Q literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3H8.png b/wadsrc_bm/static/brightmaps/strife/ROB3H8.png new file mode 100644 index 0000000000000000000000000000000000000000..a728ced7af5ee66f61c20bfd598f5c92ed9de007 GIT binary patch literal 302 zcmeAS@N?(olHy`uVBq!ia0y~yU^vLYz);M{%)r1P-S=f70|NtFfKQ0)|Ns9P7#Kni zU9MwbV0i55;uunK>+NMjz9s_^wg>wSUM%a}-6Oa7quRa03uA4k=Dbkl*({uMBt&b9 zhtj|NLgj6*r|;YI{g!;3g;?Msm(EY@Nh+0Hk1Dn<{;oSUO~16DL4nU8#>=62ql4R0 z?KaV=t0uEf-7|TL7khxut+)eAIFmZ2IGRkf@i?Y(@VkR!)_;qqU;HFA4V$hQa@%*D zR#|z5=eebK(d9{NR5K?;?wczVouPF=s3gDdNY(_eDTcN?=XKO}&psh=Kkini$>JKl zlZ%*6=j$)kaAxj0Q4nO*zw65;#h@R*`6m3Ey~}HT>>1r+ef}>oM{FmxPG?|XVDNPH Kb6Mw<&;$VXU4G60 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3I1.png b/wadsrc_bm/static/brightmaps/strife/ROB3I1.png new file mode 100644 index 0000000000000000000000000000000000000000..e76aab45512046107787eaf80c7d8576df3d13f4 GIT binary patch literal 241 zcmeAS@N?(olHy`uVBq!ia0y~yU}#`qU?^c^W?*0_|Gc7|fq{W7z$e7@|Ns9C3=E-% zF4r+IFf8+QaSW-r_4bl2-ysDN_7Cnd5|&Q=i?$c(c((V&bxMEXNU~|@Q4yM#n>THaoiAzUAas(>t1&tsRKf9b_MBg{>bRb{blw<1_lNOPgg&ebxsLQ0MuSvyZ`_I literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3I2.png b/wadsrc_bm/static/brightmaps/strife/ROB3I2.png new file mode 100644 index 0000000000000000000000000000000000000000..9aab11709d2853af039bc23d2e8dcdcdfaf9d397 GIT binary patch literal 243 zcmeAS@N?(olHy`uVBq!ia0y~yV3@(cz);M{%)r19*B`0Oz`(#3;1lBd|Nnmm28Pf> zm+Kf97*=??IEGZ*dVATB?~nlx>xFo$lrskytESv(m^v}p;F@%DtA#*;@RA}1w`Eew zD;C|j=P1zcKT%foenRw$u(h}1Z;H$*UYmTwN-Wo&CAs{-jiZK4R;j`tvN{&YMx~l3 zEbaX+E%$1E{h6lZ=j(SB7wK4ClW=xg-@E8d^QOyAi&pt8;y)i`_A2$r=3P0~b+NMjuEPdAtQYcSJldQ3CUmpZnDoEB=A8P%w5p{?(kDoC)6@To z!3$12c2=m3KIZ1{Tv74k=svNBYBt6BD-N+g-1|YLCcof|Qcc3X4D(syzZbZlKP3G9 z%d_HHC!)6%fBku-wkmF)`i{c+kM{rRT_1X7e~W#KbLG?8+RB~j4_BO-T_!wl#&30o y&;7qWYRdLs-s5om&-I3Vr!POdaX9-gcg^J^e|G6hv@Wti75u>u6CaY-NPx{vpRg$?BfqO`eda9R_E$G z?az$4GNt$X)2CZ)gso$yXs9_<2;^8jSFN|=AVv|{&VhJ^Jm`xrM42br2N(2el3&j*{fSD@O`zim{~Y8 z`vQ-LTFMLNnlq`fe(i9+sknnrKw^pHE@s=7SGFA~JSCS;+Wjoq7LSB(@?`t%(0MGIp)<^HxZ!YRnSSvbz_`z`(%Z M>FVdQ&MBb@0MWyE4FCWD literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3I5.png b/wadsrc_bm/static/brightmaps/strife/ROB3I5.png new file mode 100644 index 0000000000000000000000000000000000000000..4e39617d78ddfa68fdcedbbeb810bbe27d72e9dc GIT binary patch literal 387 zcmeAS@N?(olHy`uVBq!ia0y~yU}#`qU?^r}W?*2*`ZmL!fq{W7z$e7@|Ns9C3=E-% zF4r+IFj{!JIEGZ*dV9su?}&m3+k^R6I(E-&{k`jQbb;vmhfG5J4+NiST$>v0pRlVq z`thMz1`nzOxQ>>XCHwd+>t6PgiT_8XX3f_JEb2ep8FUUZ{xXPg&|Scu!h4;22TPvU zf>|qHaYeA19(K2Fdcd>e(rabA>{TS-gkgWXfQ|LsVx_;gfj*YtG}tzr_lH?DB}daSHN)`)RmnMMQC-fGvJBP^%n z8VcAMf2j2_yzQGG)MU=-vhgd!)5vAlS=f5N$Ih6z;OT84*QBn=ddfWWQ(G1ui@BnD up`NRbr#GRv|1X31ZqN0H^Z&ox$GH8&K0|g5(G~^<1_n=8KbLh*2~7Y*+oAvf literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3I6.png b/wadsrc_bm/static/brightmaps/strife/ROB3I6.png new file mode 100644 index 0000000000000000000000000000000000000000..c8a63623b9b53c31c75748682142c53e9f52c623 GIT binary patch literal 296 zcmeAS@N?(olHy`uVBq!ia0y~yV3@(cz)--*%)r2KLt49+fq{W7z$e7@|Ns9C3=E-% zF4r+IFx>TYaSW-r_4cwM-ysDNwg>Yw7Db1fe-Yzzvz_#j=_$v(1KAd3my->wOH&lC zU0=5KK(+Jbla1zeoGf*97d|*{%eg6JtewVprzhdTGuG9to1124K2w4<-}(B^-I>o8YCJPC(&E0Uxz(s+-)3pE@F=-k>=E+? z-@9+keZGl<=Z@Uox6G^Af)`8X?NgUgk>0;TH0Q>;56RctE*`vlh5JV7{uMuNZm!H< zc_!qF(z%_cvu6menU`@X+Nw%%b<*aNl;+BB`)&U+Wj?F%`tdp0mw|zS!PC{xWt~$( F69DVxg7*Lb literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3I7.png b/wadsrc_bm/static/brightmaps/strife/ROB3I7.png new file mode 100644 index 0000000000000000000000000000000000000000..7009e2de84e31f25c06170d454b2d8058f00e1d2 GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0y~yVA#ySz)--*%)r2qzwGiV1_lPU0G|-o|Ns9pFffE3 zx?IP=z_7&A#WAGf*4rzFT!#&KSTDpE^?y@4dE@mLHq(+9TlYMbYKu9rnETkuwn+#7 z*r#YnD)sX#t0;16*K)pl_wN69*B{;0vOCfr23qJ{S^Z(p<;fp70{9Ox&Z-xVyZT>n z5x?ix-sk(--sPs-cdyuPvu>Yw`se-+kw0cvmrI%HAKEQ=U*=ACNkIRd+|re|Up?}) wnSH+_y29s(b3Id?-{IN*AKw*M%&BK|{=53R+N(3Y3=9kmp00i_>zopr0G4HGZ~y=R literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3I8.png b/wadsrc_bm/static/brightmaps/strife/ROB3I8.png new file mode 100644 index 0000000000000000000000000000000000000000..4880d6242e37ec04c1b8ff4e1cfa9e9888f6ab11 GIT binary patch literal 247 zcmeAS@N?(olHy`uVBq!ia0y~yVA#gMz);M{%)r3FFP-JUz`(#3;1lBd|Nnmm28Pf> zm+Kf97}j{YIEGZ*dV6^z?;!^s)(iDs6OEJujNE2)vN9MlXfNgVIT)zuSiI6T)IWP4_wldJJ9&}!BKHgX6%;#}nv(A&gc`612)!5empvMB|3%UF z`03v7ZlBzJ$MENb-PUSl`**IrGwsarw|;k`U!P`w@5?6tO7GKO1_lNOPgg&ebxsLQ E06)QLB>(^b literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3J1.png b/wadsrc_bm/static/brightmaps/strife/ROB3J1.png new file mode 100644 index 0000000000000000000000000000000000000000..e97f9eec6c01075c03a429f36e7ca8947c602093 GIT binary patch literal 241 zcmeAS@N?(olHy`uVBq!ia0y~yV5nzcV5neZW?*1=ShoKK0|NtFfKQ0)|Ns9P7#Kni zU9MwbU|8nq;uunK>+L05zQYPUtO?C6gU#M}(Y8N)` z8YKn$_Df$aJ#{M@c9>W!`Q_g1pgkpq-R?z0UmySg literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3J2.png b/wadsrc_bm/static/brightmaps/strife/ROB3J2.png new file mode 100644 index 0000000000000000000000000000000000000000..1e54031e582fe0ed09e0fc3c735f3524dcc115a0 GIT binary patch literal 244 zcmeAS@N?(olHy`uVBq!ia0y~yV8~}+U?^u~W?*12@9VkBz`(#3;1lBd|Nnmm28Pf> zm+Kf97*=|^IEGZ*dVA59@2~<7>x1b=DQ^TVy!x*7*owI?G*3uzD3f3MXGzeuvK1^r zB6fn-+Zy}4KZM%-h_l|9870LU-n%2zO@epB)Olb2Jo5eiC~9Z%?!_#V6&i(f1Sa`& zim4ctxE-ii@I-^75IzOk|hq+es@HRGn)92rqrU>kJGG44$rjF6*2UngII^KCS=& literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3J4.png b/wadsrc_bm/static/brightmaps/strife/ROB3J4.png new file mode 100644 index 0000000000000000000000000000000000000000..85e324869af8a3e0c54f97f95193e48dd1c728ea GIT binary patch literal 192 zcmeAS@N?(olHy`uVBq!ia0y~yV5nnYU?^u~W?*3W|0oSau?6^qxc>kDpMilP^w4FH zbg8F{V@SoVx0ek08Wea~FT8*8M9{{oKdj&FQLBU`#|#PfU)BaQUIZNz53-ZL@OIS? zKEEcmtpSQ+MrPcd4-e!qvhbR0Y3kFB$lYMmvqRA^Vb|fa8qS~8k6*G}`6+fvzV@B= tY@Z#$bGN*^_jLV#K>+~)fe%u8x% zm+Kf97}7jl978H@y}fA2*Py`D`p{kC&J(vPww}p1= zqJtwGydS7;$dbPq60v8(OrIqe+^!mK%2W;ydZ%}8-j16;-YsAK#wTUY^%-p^y+2L; hyyrhJTk}Et&y0^x`!D(&{sQDU22WQ%mvv4FO#rmmNgx0K literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3J7.png b/wadsrc_bm/static/brightmaps/strife/ROB3J7.png new file mode 100644 index 0000000000000000000000000000000000000000..08e53195824666bc975e11568073bdce4038dee5 GIT binary patch literal 170 zcmeAS@N?(olHy`uVBq!ia0y~yV2Ed6V5nqdW?*1QEzh6Jz`(#3;1lBd|Nnmm28Pf> zm+L@EJY5_^DsH{KxKQwb0SD`a^R8E>_TD;c743GCW8w<4bu}zTe0Qw%92n*w@AeI7 z;!IR{P*$SxIKiZ?fRV+GFnV&71ei?kx|{5HZr3 Y^0DYyLa}rQ0|Nttr>mdKI;Vst06JhjqyPW_ literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3J8.png b/wadsrc_bm/static/brightmaps/strife/ROB3J8.png new file mode 100644 index 0000000000000000000000000000000000000000..0aad4ac5f9dc54b28387ecf60d615566a7f99bd0 GIT binary patch literal 241 zcmeAS@N?(olHy`uVBq!ia0y~yV5ntaU?^u~W?*0txq6p@fq{W7z$e7@|Ns9C3=E-% zF4r+IFf8+QaSW-r_4d+U-opwaEDyS40v7ok(CBH~y=H2l#6eZoCK;Dw>E16Vg+w$x zy4?J|Iq-b^q4f_JZn!o}G2p@LwgQKy)&A=k1*awOF^C;9QeaNFlIx(<;t}%U&LKYO zgP(f#Hw7E8EWU8*L9)xPdm9h03=&`Z<+KasuEPoftQYioOJ52WO_A~Ke-^mMu_Z^RWyutWg>V12YTjij z`DwP;xc-Qrzw7sR@q4)Z=lx=H-^+MP`SYsUq_~#!1QEFz>TmBoV$gFdcWb};czOOQ zb{XE<&tJ9fa31H++qt~p>%HT9E_v5KORqCJzdU-z`r{Iw|C(=1|2Kcm&HO{&B6fx6 x9d~T6G^`RWy{%#M=jijawbIr1cFjNW{uiJ7>8i-m`3wvU44$rjF6*2UngA}1XW#$; literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3N0.png b/wadsrc_bm/static/brightmaps/strife/ROB3N0.png new file mode 100644 index 0000000000000000000000000000000000000000..953df2057bb09f130490a6e159750157c2a266d5 GIT binary patch literal 498 zcmeAS@N?(olHy`uVBq!ia0y~yU^vdez)-}<%)r2K_e{7m0|NtFfKQ0)|Ns9P7#Kni zU9MwbU|jC$;uunK>+MxT@52rv>>sYX*@_r$?mqiWjf+puw63|1gFRf9HIrFSY3U0+ zy{7pG4HY^j&z&ozVd2?Zvh$H?`Ye<3mv^h<7krsE>CdF=|Mx!8Q|O#{C`ionm!9Iw zi`xtUc-qB#O03y6f4>(jwUzAik6Xzw^mt>zSuw46d;i`~otVMk7b2$N?RA>mivR7N1R8Bxd0(A@fq}u()z4*} HQ$iB}L%P`Z literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3O0.png b/wadsrc_bm/static/brightmaps/strife/ROB3O0.png new file mode 100644 index 0000000000000000000000000000000000000000..dc6e981861e44454b6c7d0b509d8858c441991fe GIT binary patch literal 631 zcmeAS@N?(olHy`uVBq!ia0y~yU^vXcz>vkr%)r24y{P;=0|NtFfKQ0)|Ns9P7#Kni zU9MwbVAAn)aSW-r_4b-!{uKie_7D3#OD#Jul)P~&W|m)&-2N)2)Bj+ZaL*Eh3lCkI zB=Yun<#5Cv{qArgbtmgZ{f3a~tEVuo^vzuQOyPz~;3R8nLm}bQm4Bb!Jnw(LOo6vK zSylU|{iJ}&E$bXviaMiI+Em>?g?1YVG%}P0I|-yTo472HY1GS94Vk_}$X`6JGg~BD zJghTSWYOt)o-VS?u}+t*_V*gCSKnQnA`(7zbySC%{j?`86Z5$(XU$Cc6gSa7V)dqf zKP)4rJ#PIXU%kp^&67tzOCrx5iqo7M-@imlI@MRUaur9qUr-3c>`znlyw6x2R(i5k z-%n5Up}m&8p0MG{hEF{0^B|;_y!V?PnqW6-x27J?uLTELL^M)|{XGx-B*R zdJ$vIjI<(so#-XgGMMB4)NE_JV=-f|c6zYty99eHog^L8<|i`j>^EO3C06>0{r+gk z(198 z6{=cz@JL7HZPeY(yn{zL)bm!3v6J?D qUeL?@yUQd_Ep7cjrhl&g7_J8>1|D&A_{hM(z~JfX=d#Wzp$P!IMHAQn literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3P0.png b/wadsrc_bm/static/brightmaps/strife/ROB3P0.png new file mode 100644 index 0000000000000000000000000000000000000000..4c15cbd516a6dbe1321990c38dbde41a5fea5d64 GIT binary patch literal 372 zcmeAS@N?(olHy`uVBq!ia0y~yU|7$ zm+Kf97&Sdz978H@CI9H>{gW&qDkmx@>L&i~xYnP3$<-g^-yE`+RQytAlE}xgx74od z!*M>2wN)~%KaNkVGFV$6;rip4aj8IQ{6mwj4|9`}Cj@R5-WAw#Kk_`=r1o;vMVz=;dcWC{Ic_)40+_U`k>5Dn)=l!q#|NsBnpT}DR@7C`7XBqJ0PGMn4`TqNV1tfYt z_n%yB`Qcpqum69h)jnInnEmsf!@vHTuX9R79=7FB2dKdCF)osn}LCW!PC{xWt~$(699S_wZQ-Y literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3Q0.png b/wadsrc_bm/static/brightmaps/strife/ROB3Q0.png new file mode 100644 index 0000000000000000000000000000000000000000..c66b6d65473e1e677bb1edfdf638461a900bd4a5 GIT binary patch literal 198 zcmeAS@N?(olHy`uVBq!ia0y~yU|7$XVUkgCmVtqR!PC{xWt~$( F698)3PYeJ6 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3T0.png b/wadsrc_bm/static/brightmaps/strife/ROB3T0.png new file mode 100644 index 0000000000000000000000000000000000000000..aa2db3891c8d4857d3ed38733baaeac90381d325 GIT binary patch literal 164 zcmeAS@N?(olHy`uVBq!ia0y~yU|7Y#z~IWr%)r3#VAcC+3=9lx0X`wF|NsAIU|(K6n5C literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3U0.png b/wadsrc_bm/static/brightmaps/strife/ROB3U0.png new file mode 100644 index 0000000000000000000000000000000000000000..2faae7cc926233911f8e8dd22f95e51e094f5c78 GIT binary patch literal 183 zcmeAS@N?(olHy`uVBq!ia0y~yU|7Y#z~IKn%)r2qW;fS@fq{W7z$e7@|Ns9C3=E-% zF4r+IFywf;IEGZ*O8(K$E0Z80%GNmFMC6|%@5A|9KK_xf%;LDs+JRp8YYx>*yxGY4|A5|~Mn}2b2KHtT*?Hcma2h9@&*nO0zajc3`|c0+ pZ|?oIqd7?=CFuSvumZtM0+R2v!>5K zY0s0nE!cbd^!$65-8M0wJo1FK#KS$yVO`(LFABaFVm5cmTyme4Cv~`4%TMWoT#=TK zsVnaZ)fLK;X|-)SkG4f$a`}}Od(LxHhLiZDFH4WC**Hb)So9?~E1nY*Oa2~p-^Wn1 XxBp*g`8{z41_lOCS3j3^P6 zm+Kf97#uxa978H@CI9GWlr!i_*!Vd_Ec>|9u|6d;d7n?og3hMzZTt*F>OTl;s`YF0 u{JSBn8P>1)ZGD{yZ*Ny`*TN1)hJ0uC7c0K1#4|83FnGH9xvXk^lez literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3Y0.png b/wadsrc_bm/static/brightmaps/strife/ROB3Y0.png new file mode 100644 index 0000000000000000000000000000000000000000..c9b50001dd208b245f2e0c6f681a76a05a0a12b9 GIT binary patch literal 153 zcmeAS@N?(olHy`uVBq!ia0y~yU|7h&z~IKn%)r1f?_Sz@1_lPU0G|-o|Ns9pFffE3 zx?IP=z~JZU;uunKEBQx1tBC=R-bMRAH(cr`DEw+H3M|W6#P1<+H1Cl8??&GE>N|`0 zH_R$nFpnj$Zq1@MN4oz#P>=f}A9nHor)HDT{;s|*KCVE9=yweb?B`xEfPkl~pUXO@ GgeCwgtT~MU literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3Z0.png b/wadsrc_bm/static/brightmaps/strife/ROB3Z0.png new file mode 100644 index 0000000000000000000000000000000000000000..3bcb0324821292eff6cec52c71748e6c0db2916c GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0y~yU|7z;z~I8j%)r2Kk7Ii?0|NtFfKQ0)|Ns9P7#Kni zU9MwbV5szTaSW-r_4M*a&ISVk)(ew4G>x0IcO2|3n|WZSjOyH6HV#YWuu1YAH#mMi z&F@8M|FyD)G4jE_4N43Q3=E#GelF{r5}E+4 Cd`q?f literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3[0.png b/wadsrc_bm/static/brightmaps/strife/ROB3[0.png new file mode 100644 index 0000000000000000000000000000000000000000..7ccf983e064cd6540550fb3f5331c359e3cf2e13 GIT binary patch literal 385 zcmeAS@N?(olHy`uVBq!ia0y~yV5nhWVDMsOW?*1&{=CSSfq{W7z$e6&fq~)w|Nl#G z&cDmRz-Z>_;uunK>*y8hydw$%3;}DVPMc&Fy2C?d-6Z8F3>Odi7KwUmFFh-mqZza< zX4j4lGg5y@q$OQnI6FPiSX1BZBQ0vNO)I9#j&)ai9GNF4+aPaZ1U2P5ul;l{^q&3MB6Q+|wZUD9nxY>+mo9k6 zW1=f%UY5Mz2hUI61Dy}8zBcrKVg9wO^Zjy%2|ooBCa-@v$2p7h&881!7jMfZ>+3&? ud}JPdPoV4;!^_w|KQ%wxZgIW{dlp_%owPAykkKy~t&*9Hnpg`C|h z7}&yZcDnPgtbgb8IOQd8r~UDNxpSRN!b=w{y%HKT?d`OgyDz_QVqe0lKjT!z<#hqd zElq5z|FFgFlw{lYEnHysq=bnQw=`!r>P`5_6*%poc8H8-y78|C2mOlp1f&>0iAzs- zc%o#&Biowwl2IGhbK5LDrtx5>!UU@i+Co-en$(id#6RiKD1U5K|0#J_!)c?q>lH35 zUB0K@(VwBR;Ha38P;{T!OEtxhC0iQjeTzCR`XSFYSK|L{9rJ4$wkOuj*DT*CZBcGh zwEBfu-hnMwB}M00xd-L%Jb6E)*5-5lgBSdHulR}>QsPV*7#J8lUHx3vIVCg!06{8{ AivR!s literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3^0.png b/wadsrc_bm/static/brightmaps/strife/ROB3^0.png new file mode 100644 index 0000000000000000000000000000000000000000..f67a424b873558822d8d26bbd9b91bc9bc37cbdc GIT binary patch literal 1358 zcmeAS@N?(olHy`uVBq!ia0y~yV8~`*U~u4IW?*2@;;KB&z`$T$;u=vBoS#-wo>-L1 z;E|Y@lAD;4ssIzwQSi)5)>F_`@XSq2PgQWtNzO>ktyCy8)H5{Z`qfs|%)r3R5a1Ky z%D}+z{PE-aw{Ks+eEIz8)5i}V-oJnU_U+p@uV24<`SQi{=g*!#ee&eV-QC^I&CS)- z)#b&-`T6FM$D@!{d&{{H^%?(WX^_SV+c#>U3l+S%F@!(!otGb+}!N!?7R1G z-@JYG^3C%Xubw=6dH3Y`_1&|}nl<@x>$9tCv&$>9OUpBei!<;GGjMY=u(LDV*493)th`@d ze!aBxVsY`w!ouzR{N>!-+3f7m?Ckyw4E78R#taPV3=HB74BQM1ub(qKzszubGsE%e z4BP7&mZvjJ4`yh$XDHWaNLOYE7iVziW-w<*sQ*t0@H?}!8?!SgGcX7iX5$`LpAbyMu$Po!zs|t)unzy_J=%#l^Mx`K1{cxR39jym@u= z^4aCHyYu_&lbiFS%ai@H!`-9Zt^KWyo%OZN)s?lSrRBi^%FfQvfB16s=EK>`w@1%j z?%h4xy1rY#xL!HESUNgc*gu@x*`3|onn7EeL0+CgSeSvG{qp|xr#CM?yn6cn`Tg6c zH?QxnUfo{2xH^4yas2e`@cv}~?r8VsVCQOY>vCt~d~5x5bM<6>Uc6D|Jc?Je)uwS`B-etIaeD~@7n-6bay?_1U?aODcpFer^^zOy| z?X$bYx_SiNlk8Zdq+~UzhaRpKG#Adso`Q`>e?ktWy=3#Il`REUvk;2_H&1 z(|UEE@G0dBdyUtA7r$d)^`&)f@?r67n9YaE;9*kBnWQTTzkms{Qc^yGx7x5U-zgMi}th@D`h8V ze_QXRJn7uTU3-g?P9?9|Vp@@$sj;xB*ZXc&12@wW>zLmP+YFA^EtcBxDz2nD;bw^8 zt67N+H72jz&wUM?oK(Cn{qeI?%N9jn->2ojWYP4vNutpax3-vl+53u1=;C?vpHDAd z=#HBhd^uF!X=@=z*xi=N#@Ubf7vvqy*{L%n5!CY3$!$a@oE$z zJ`tm%vpo0qhH~Y0t!nOjK4s^_kBz3b+uD7E+ZN3@vie)u#I85Trm9*h{be$_TEYHe T(%DH23=9mOu6{1-oD!M<)Ocg0 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/SEWRH0.png b/wadsrc_bm/static/brightmaps/strife/SEWRH0.png new file mode 100644 index 0000000000000000000000000000000000000000..b439f2617401dbd03e91514ac7e968153ab904ed GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0y~yVDM#NV9;e`W?*2rXk4b)vGCL-hY;#zEtONGJs%m5{W!>%`sZQ0;RB_fmbD86nHhX| X4^Hf272U$Xz`)??>gTe~DWM4fho&YA literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/STLKR0.png b/wadsrc_bm/static/brightmaps/strife/STLKR0.png new file mode 100644 index 0000000000000000000000000000000000000000..16fa49db0a76da1cd7042ba0ca244ffd323bb252 GIT binary patch literal 113 zcmeAS@N?(olHy`uVBq!ia0y~yU~phyV31^FW?*30t+s0s0|NtFfKQ0)|Ns9P7#Kni zU9MwbU{LdPaSW-rmHdOBl}E*h?~nw)%)%b|o`7Tabu*GGXL#6Jh6S`TGKjoBbX>E7 SC5nN8fx*+&&t;ucLK6TiKOe6E literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/STLKS0.png b/wadsrc_bm/static/brightmaps/strife/STLKS0.png new file mode 100644 index 0000000000000000000000000000000000000000..5065e9c6a393cd3c6272ce6571036eac7c18be12 GIT binary patch literal 117 zcmeAS@N?(olHy`uVBq!ia0y~yV6bOkV31^FW?*30lajKXfq{W7z$e7@|Ns9C3=E-% zF4r+IFlc$YIEGZ*O8&vm_+R3K(T&8OG>ONGJs%m5{W!>%`sZQ0;RB_fmbD86nHhX| X4^Hf272U$Xz`)??>gTe~DWM4fho&YA literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/STLKT0.png b/wadsrc_bm/static/brightmaps/strife/STLKT0.png new file mode 100644 index 0000000000000000000000000000000000000000..a65e78c34d2b0e2ad6b323546a53c21fe6367b83 GIT binary patch literal 149 zcmeAS@N?(olHy`uVBq!ia0y~yU~phyV31^FW?*30t+s0s0|NtFfKQ0)|Ns9P7#Kni zU9MwbVDR#EaSW-rmHgxXM|%l_KmQMNB>!32ZuI20VvqcvfR*z17xv6Ih*c<%KlMYM zKhea%LGo+Qv4ms$fBk=cfM>?Z|Ns9SPq?DYvqXuRVPER*dlBtf=NT9n7(8A5T-G@y GGywp*IXc$> literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/STLKU0.png b/wadsrc_bm/static/brightmaps/strife/STLKU0.png new file mode 100644 index 0000000000000000000000000000000000000000..c4399848ac334a785e2103d566bca1646243b0f1 GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0y~yV6bOkV31^FW?*30lajKXfq{W7z$e7@|Ns9C3=E-% zF4uu5PZ!6Kid)G){(rXT_>=tOKl|j54swTnd~9!IJoDqje@9>2j*A>mZZ%8%pD0oP zYGIH3&wyj>5|0_HZ96`Gum8-xg5$`O|MH1F?FMelJ%s|te)uyoGyK)uBfS2xax?=2 O1B0ilpUXO@geCyV|34)F literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/STLKV0.png b/wadsrc_bm/static/brightmaps/strife/STLKV0.png new file mode 100644 index 0000000000000000000000000000000000000000..ce4ea17412502db0e4e48bafc88f73cd4e985644 GIT binary patch literal 174 zcmeAS@N?(olHy`uVBq!ia0y~yU~phyV31~HW?*3W_D*^w0|NtFfKQ0)|Ns9P7#Kni zU9MwbU`Y0KaSW-r)q7?mZ-atJ%fsmb0Y*)W4Wv}~md#E`U)kBKc0ykv#H=j-U6H!a z1BQcUD(;(18!bd+w3n|u*>RnBk(S8j9ZYi*x7(QOv^BKcnXZ15>l@#HyText>ks75 fXnRq&UT&rO!ON#+vDz{)Ffe$!`njxgN@xNA=21U; literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/STLKW0.png b/wadsrc_bm/static/brightmaps/strife/STLKW0.png new file mode 100644 index 0000000000000000000000000000000000000000..b50fcd5c8027263541b87f2609504ef4c32dbfc2 GIT binary patch literal 163 zcmeAS@N?(olHy`uVBq!ia0y~yV6bIiV31*CW?*1=5u<9!z`(#3;1lBd|Nnmm28Pf> zm+Kf97$Q7f978H@CI8@Ow3lc&5-;(Xy{GW7+?k5M-x=*YKDK|hXSVM6*vx$D$A!S- z4AXucNM@Y+C_UjHPuhw4AOEG-tp2Bdq^thx|ITy;nQwB(CbS#=FuXG1FayJ3>0`&2 U>{Xt?z`(%Z>FVdQ&MBb@0AP7QCIA2c literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/STLKX0.png b/wadsrc_bm/static/brightmaps/strife/STLKX0.png new file mode 100644 index 0000000000000000000000000000000000000000..4ae22cb0505307d120b84b04e4906fc29882843e GIT binary patch literal 122 zcmeAS@N?(olHy`uVBq!ia0y~yV6bIiV31{GW?*1YX81OTfq{W7z$e7@|Ns9C3=E-% zF4r+IFz9=_IEGZ*O8&vmXfM%`^5;Xl5#NTx5@!P3n0pEv1WzR#NZ~jv@ioBBT65dw cHb#b+2R9}@=6;dPz`(%Z>FVdQ&MBb@0Nh(A6951J literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/STLKY0.png b/wadsrc_bm/static/brightmaps/strife/STLKY0.png new file mode 100644 index 0000000000000000000000000000000000000000..417f7fed1203eecb17c926448eccd9c2f5f841db GIT binary patch literal 170 zcmeAS@N?(olHy`uVBq!ia0y~yV9;Y=U{GRYW?*2D+FHraz`(#3;1lBd|Nnmm28Pf> zm+Kf97~(x$978H@#h%~Ddq9DQ<$$|L&q0kIHt7^qw?q~%t`=c?PR_#ONl&-ubcD6@ z$apn}YB~6HiL-J@*E!Gr>0hJS{r;6?ena)khNrqNX~EB)I49L4dh9D)Qf0(6^Z!KQ ZpyVd6wMmiB85kHCJYD@<);T3K0RZ!fH|hWY literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/STLKZ0.png b/wadsrc_bm/static/brightmaps/strife/STLKZ0.png new file mode 100644 index 0000000000000000000000000000000000000000..acb6a3fa07ef11e4630b295ca59ae60a0adb687d GIT binary patch literal 243 zcmeAS@N?(olHy`uVBq!ia0y~yU{GUVV31*AW?*0_*rfW6fq{WDz$e7jo&f~@|NmbU zdf*}h1H)2J7srr_TecH63LRG9ai00RH1f@EqtcTN`_;H5jZzKEuZ4%TZ4rK-!pYs$ z5mH||aqR>FF>c=2i)wB&OkTTu<(e*aB$jbT(+fA3-_a@Y&5w zxr+J6ey-^0Q%-Jc%}UIj&$jo*F~LuoR)@|tKI~kvLqe79+|I{(LU+C>Tt2p_?o8Uc v?AhzAKF>Tc>$mmBt2riDx5RvMuItN*=Y2k*nNiQl9prXTS3j3^P6 literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/brightmaps/strife/STLK[0.png b/wadsrc_bm/static/brightmaps/strife/STLK[0.png new file mode 100644 index 0000000000000000000000000000000000000000..6b47d56e9ba448c6cdde2c83fa55e4484ce69a29 GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0y~yV322EV31*CW?*1g{N>vf1_lPU0G|-o|Ns9pFffE3 zx?IP=z|iCA;uunKOZ2Qh7n37H>&N3#Vmx|D8#=0)S4X7fKV*F~@1T9+Y%aCaT=NcT zbXeTf=9$5>EVO0r`I(=x?^hpscvRKtM?>Xv-S*&TkVZtex_C-l|w0w_Q)~_s#20UHa?-*Yo+8{xC9s X^<}?2A>lUz0|SGntDnm{r-UW|V2D?) literal 0 HcmV?d00001 diff --git a/wadsrc_bm/static/doomdefs.bm b/wadsrc_bm/static/doomdefs.bm new file mode 100644 index 000000000..78159bddd --- /dev/null +++ b/wadsrc_bm/static/doomdefs.bm @@ -0,0 +1,2181 @@ +brightmap sprite CELLA0 +{ + map "brightmaps/doom/cella0.png" + iwad +} + +brightmap sprite CELPA0 +{ + map "brightmaps/doom/celpa0.png" + iwad +} + +brightmap sprite PLAYF1 +{ + map "brightmaps/doom/PLAYf1.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF2F8 +{ + map "brightmaps/doom/PLAYf2f8.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF3F7 +{ + map "brightmaps/doom/PLAYf3f7.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF4F6 +{ + map "brightmaps/doom/PLAYf4f6.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF5 +{ + map "brightmaps/doom/PLAYf5.png" + iwad + disablefullbright +} + +brightmap sprite POSSF1 +{ + map "brightmaps/doom/possf1.png" + iwad + disablefullbright +} + +brightmap sprite POSSF2F8 +{ + map "brightmaps/doom/possf2f8.png" + iwad + disablefullbright +} + +brightmap sprite POSSF3F7 +{ + map "brightmaps/doom/possf3f7.png" + iwad + disablefullbright +} + +brightmap sprite POSSF4F6 +{ + map "brightmaps/doom/possf4f6.png" + iwad + disablefullbright +} + +brightmap sprite POSSF5 +{ + map "brightmaps/doom/possf5.png" + iwad + disablefullbright +} + +brightmap sprite SPOSF1 +{ + map "brightmaps/doom/SPOSf1.png" + iwad + disablefullbright +} + +brightmap sprite SPOSF2F8 +{ + map "brightmaps/doom/SPOSf2f8.png" + iwad + disablefullbright +} + +brightmap sprite SPOSF3F7 +{ + map "brightmaps/doom/SPOSf3f7.png" + iwad + disablefullbright +} + +brightmap sprite SPOSF4F6 +{ + map "brightmaps/doom/SPOSf4f6.png" + iwad + disablefullbright +} + +brightmap sprite SPOSF5 +{ + iwad + map "brightmaps/doom/SPOSf5.png" + disablefullbright +} + +brightmap sprite CPOSE1 +{ + map "brightmaps/doom/CPOSE1.png" + iwad + disablefullbright +} + +brightmap sprite CPOSE2 +{ + map "brightmaps/doom/CPOSE2.png" + iwad + disablefullbright +} + +brightmap sprite CPOSE3 +{ + map "brightmaps/doom/CPOSE3.png" + iwad + disablefullbright +} + +brightmap sprite CPOSE4 +{ + iwad + disablefullbright +} + +brightmap sprite CPOSE5 +{ + map "brightmaps/doom/CPOSE5.png" + iwad + disablefullbright +} + +brightmap sprite CPOSE6 +{ + map "brightmaps/doom/CPOSE6.png" + iwad + disablefullbright +} + +brightmap sprite CPOSE7 +{ + map "brightmaps/doom/CPOSE7.png" + iwad + disablefullbright +} + +brightmap sprite CPOSE8 +{ + map "brightmaps/doom/CPOSE8.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF1 +{ + map "brightmaps/doom/CPOSF1.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF2 +{ + map "brightmaps/doom/CPOSF2.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF3 +{ + map "brightmaps/doom/CPOSF3.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF4 +{ + map "brightmaps/doom/CPOSF4.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF5 +{ + map "brightmaps/doom/CPOSF5.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF6 +{ + map "brightmaps/doom/CPOSF6.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF7 +{ + map "brightmaps/doom/CPOSF7.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF8 +{ + map "brightmaps/doom/CPOSF8.png" + iwad + disablefullbright +} + +brightmap sprite SSWVG0 +{ + map "brightmaps/doom/sswvg0.png" + iwad + disablefullbright +} + +brightmap sprite BSPIA1D1 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIA2a8 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIA3A7 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIA4A6 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIA5D5 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIG1 +{ + map "brightmaps/doom/bspig1.png" + iwad + disablefullbright +} + +brightmap sprite BSPIG2G8 +{ + map "brightmaps/doom/bspig2g8.png" + iwad + disablefullbright +} + +brightmap sprite BSPIG3G7 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIG4G6 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIG5 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIH1 +{ + map "brightmaps/doom/bspih1.png" + iwad + disablefullbright +} + +brightmap sprite BSPIH2H8 +{ + map "brightmaps/doom/bspih2h8.png" + iwad + disablefullbright +} + +brightmap sprite BSPIH3H7 +{ + map "brightmaps/doom/bspih3h7.png" + iwad + disablefullbright +} + +brightmap sprite BSPIH4H6 +{ + map "brightmaps/doom/bspih4h6.png" + iwad + disablefullbright +} + +brightmap sprite BSPIH5 +{ + map "brightmaps/doom/bspih5.png" + iwad + disablefullbright +} + +brightmap sprite BOSSA1 +{ + map "brightmaps/doom/bossa1.png" + iwad +} + +brightmap sprite BOSSA2A8 +{ + map "brightmaps/doom/bossa2a8.png" + iwad +} + +brightmap sprite BOSSA3A7 +{ + map "brightmaps/doom/bossa3a7.png" + iwad +} + +brightmap sprite BOSSA4A6 +{ + map "brightmaps/doom/bossa4a6.png" + iwad +} + +brightmap sprite BOSSA5 +{ + map "brightmaps/doom/bossa5.png" + iwad +} + +brightmap sprite BOSSb1 +{ + map "brightmaps/doom/bossb1.png" + iwad +} + +brightmap sprite BOSSB2B8 +{ + map "brightmaps/doom/bossb2b8.png" + iwad +} + +brightmap sprite BOSSB3B7 +{ + map "brightmaps/doom/bossb3b7.png" + iwad +} + +brightmap sprite BOSSB4B6 +{ + map "brightmaps/doom/bossb4b6.png" + iwad +} + +brightmap sprite BOSSB5 +{ + map "brightmaps/doom/bossb5.png" + iwad +} + +brightmap sprite BOSSC1 +{ + map "brightmaps/doom/bossc1.png" + iwad +} + +brightmap sprite BOSSC2C8 +{ + map "brightmaps/doom/bossc2c8.png" + iwad +} + +brightmap sprite BOSSC3C7 +{ + map "brightmaps/doom/bossc3c7.png" + iwad +} + +brightmap sprite BOSSC4C6 +{ + map "brightmaps/doom/bossc4c6.png" + iwad +} + +brightmap sprite BOSSC5 +{ + map "brightmaps/doom/bossc5.png" + iwad +} + +brightmap sprite BOSSD1 +{ + map "brightmaps/doom/bossd1.png" + iwad +} + +brightmap sprite BOSSD2D8 +{ + map "brightmaps/doom/bossd2d8.png" + iwad +} + +brightmap sprite BOSSD3D7 +{ + map "brightmaps/doom/bossd3d7.png" + iwad +} + +brightmap sprite BOSSD4D6 +{ + map "brightmaps/doom/bossd4d6.png" + iwad +} + +brightmap sprite BOSSD5 +{ + map "brightmaps/doom/bossd5.png" + iwad +} + +brightmap sprite BOSSE1 +{ + map "brightmaps/doom/bosse1.png" + iwad +} + +brightmap sprite BOSSE2 +{ + map "brightmaps/doom/bosse2.png" + iwad +} + +brightmap sprite BOSSE3 +{ + map "brightmaps/doom/bosse3.png" + iwad +} + +brightmap sprite BOSSE4 +{ + map "brightmaps/doom/bosse4.png" + iwad +} + +brightmap sprite BOSSE5 +{ + map "brightmaps/doom/bosse5.png" + iwad +} + +brightmap sprite BOSSE6 +{ + map "brightmaps/doom/bosse6.png" + iwad +} + +brightmap sprite BOSSE7 +{ + map "brightmaps/doom/bosse7.png" + iwad +} + +brightmap sprite BOSSE8 +{ + map "brightmaps/doom/bosse8.png" + iwad +} + +brightmap sprite BOSSF1 +{ + map "brightmaps/doom/BOSSF1.png" + iwad +} + +brightmap sprite BOSSF2 +{ + map "brightmaps/doom/BOSSF2.png" + iwad +} + +brightmap sprite BOSSF3 +{ + map "brightmaps/doom/BOSSF3.png" + iwad +} + +brightmap sprite BOSSF4 +{ + map "brightmaps/doom/BOSSF4.png" + iwad +} + +brightmap sprite BOSSF5 +{ + map "brightmaps/doom/BOSSF5.png" + iwad +} + +brightmap sprite BOSSF6 +{ + map "brightmaps/doom/BOSSF6.png" + iwad +} + +brightmap sprite BOSSF7 +{ + map "brightmaps/doom/BOSSF7.png" + iwad +} + +brightmap sprite BOSSF8 +{ + map "brightmaps/doom/BOSSF8.png" + iwad +} + +brightmap sprite BOSSG1 +{ + map "brightmaps/doom/BOSSG1.png" + iwad +} + +brightmap sprite BOSSG2 +{ + map "brightmaps/doom/BOSSG2.png" + iwad +} + +brightmap sprite BOSSG3 +{ + map "brightmaps/doom/BOSSG3.png" + iwad +} + +brightmap sprite BOSSG4 +{ + map "brightmaps/doom/BOSSG4.png" + iwad +} + +brightmap sprite BOSSG5 +{ + map "brightmaps/doom/BOSSG5.png" + iwad +} + +brightmap sprite BOSSG6 +{ + map "brightmaps/doom/BOSSG6.png" + iwad +} + +brightmap sprite BOSSG7 +{ + map "brightmaps/doom/BOSSG7.png" + iwad +} + +brightmap sprite BOSSG8 +{ + map "brightmaps/doom/BOSSG8.png" + iwad +} + +brightmap sprite BOSSH1 +{ + map "brightmaps/doom/BOSSH1.png" + iwad +} + +brightmap sprite BOSSH2 +{ + map "brightmaps/doom/BOSSH2.png" + iwad +} + +brightmap sprite BOSSH3 +{ + map "brightmaps/doom/BOSSH3.png" + iwad +} + +brightmap sprite BOSSH4 +{ + map "brightmaps/doom/BOSSH4.png" + iwad +} + +brightmap sprite BOSSH5 +{ + map "brightmaps/doom/BOSSH5.png" + iwad +} + +brightmap sprite BOSSH6 +{ + map "brightmaps/doom/BOSSH6.png" + iwad +} + +brightmap sprite BOSSH7 +{ + map "brightmaps/doom/BOSSH7.png" + iwad +} + +brightmap sprite BOSSH8 +{ + map "brightmaps/doom/BOSSH8.png" + iwad +} + +brightmap sprite BOSSI0 +{ + map "brightmaps/doom/BOSSI0.png" + iwad +} + +brightmap sprite BOSSJ0 +{ + map "brightmaps/doom/BOSSJ0.png" + iwad +} + +brightmap sprite BOSSK0 +{ + map "brightmaps/doom/BOSSK0.png" + iwad +} + +brightmap sprite BOSSL0 +{ + map "brightmaps/doom/BOSSL0.png" + iwad +} + +brightmap sprite BOSSM0 +{ + map "brightmaps/doom/BOSSM0.png" + iwad +} + +brightmap sprite BOS2A1C1 +{ + map "brightmaps/doom/bossa1.png" + iwad +} + +brightmap sprite BOS2A2C8 +{ + map "brightmaps/doom/bossa2a8.png" + iwad +} + +brightmap sprite BOS2A3C7 +{ + map "brightmaps/doom/bossa3a7.png" + iwad +} + +brightmap sprite BOS2A4C6 +{ + map "brightmaps/doom/bossa4a6.png" + iwad +} + +brightmap sprite BOS2A5C5 +{ + map "brightmaps/doom/bossa5.png" + iwad +} + +brightmap sprite BOS2b1D1 +{ + map "brightmaps/doom/bossb1.png" + iwad +} + +brightmap sprite BOS2B2D8 +{ + map "brightmaps/doom/bossb2b8.png" + iwad +} + +brightmap sprite BOS2B3D7 +{ + map "brightmaps/doom/bossb3b7.png" + iwad +} + +brightmap sprite BOS2B4D6 +{ + map "brightmaps/doom/bossb4b6.png" + iwad +} + +brightmap sprite BOS2B5D5 +{ + map "brightmaps/doom/bossb5.png" + iwad +} + +brightmap sprite BOS2E1 +{ + map "brightmaps/doom/bosse1.png" + iwad +} + +brightmap sprite BOS2E2 +{ + map "brightmaps/doom/bosse2.png" + iwad +} + +brightmap sprite BOS2E3 +{ + map "brightmaps/doom/bosse3.png" + iwad +} + +brightmap sprite BOS2E4 +{ + map "brightmaps/doom/bosse4.png" + iwad +} + +brightmap sprite BOS2E5 +{ + map "brightmaps/doom/bosse5.png" + iwad +} + +brightmap sprite BOS2E6 +{ + map "brightmaps/doom/bosse6.png" + iwad +} + +brightmap sprite BOS2E7 +{ + map "brightmaps/doom/bosse7.png" + iwad +} + +brightmap sprite BOS2E8 +{ + map "brightmaps/doom/bosse8.png" + iwad +} + +brightmap sprite BOS2F1 +{ + map "brightmaps/doom/BOSSF1.png" + iwad +} + +brightmap sprite BOS2F2 +{ + map "brightmaps/doom/BOSSF2.png" + iwad +} + +brightmap sprite BOS2F3 +{ + map "brightmaps/doom/BOSSF3.png" + iwad +} + +brightmap sprite BOS2F4 +{ + map "brightmaps/doom/BOSSF4.png" + iwad +} + +brightmap sprite BOS2F5 +{ + map "brightmaps/doom/BOSSF5.png" + iwad +} + +brightmap sprite BOS2F6 +{ + map "brightmaps/doom/BOSSF6.png" + iwad +} + +brightmap sprite BOS2F7 +{ + map "brightmaps/doom/BOSSF7.png" + iwad +} + +brightmap sprite BOS2F8 +{ + map "brightmaps/doom/BOSSF8.png" + iwad +} + +brightmap sprite BOS2G1 +{ + map "brightmaps/doom/BOSSG1.png" + iwad +} + +brightmap sprite BOS2G2 +{ + map "brightmaps/doom/BOSSG2.png" + iwad +} + +brightmap sprite BOS2G3 +{ + map "brightmaps/doom/BOSSG3.png" + iwad +} + +brightmap sprite BOS2G4 +{ + map "brightmaps/doom/BOSSG4.png" + iwad +} + +brightmap sprite BOS2G5 +{ + map "brightmaps/doom/BOSSG5.png" + iwad +} + +brightmap sprite BOS2G6 +{ + map "brightmaps/doom/BOSSG6.png" + iwad +} + +brightmap sprite BOS2G7 +{ + map "brightmaps/doom/BOSSG7.png" + iwad +} + +brightmap sprite BOS2G8 +{ + map "brightmaps/doom/BOSSG8.png" + iwad +} + +brightmap sprite BOS2H1 +{ + map "brightmaps/doom/BOSSH1.png" + iwad +} + +brightmap sprite BOS2H2 +{ + map "brightmaps/doom/BOSSH2.png" + iwad +} + +brightmap sprite BOS2H3 +{ + map "brightmaps/doom/BOSSH3.png" + iwad +} + +brightmap sprite BOS2H4 +{ + map "brightmaps/doom/BOSSH4.png" + iwad +} + +brightmap sprite BOS2H5 +{ + map "brightmaps/doom/BOSSH5.png" + iwad +} + +brightmap sprite BOS2H6 +{ + map "brightmaps/doom/BOSSH6.png" + iwad +} + +brightmap sprite BOS2H7 +{ + map "brightmaps/doom/BOSSH7.png" + iwad +} + +brightmap sprite BOS2H8 +{ + map "brightmaps/doom/BOSSH8.png" + iwad +} + +brightmap sprite BOS2I0 +{ + map "brightmaps/doom/BOSSI0.png" + iwad +} + +brightmap sprite BOS2J0 +{ + map "brightmaps/doom/BOSSJ0.png" + iwad +} + +brightmap sprite BOS2K0 +{ + map "brightmaps/doom/BOSSK0.png" + iwad +} + +brightmap sprite BOS2L0 +{ + map "brightmaps/doom/BOSSL0.png" + iwad +} + +brightmap sprite BOS2M0 +{ + map "brightmaps/doom/BOSSM0.png" + iwad +} + +brightmap sprite BOS2A6C4 +{ + map "brightmaps/doom/BOS2A6C4.png" + iwad +} + +brightmap sprite BOS2A7C3 +{ + map "brightmaps/doom/BOS2A7C3.png" + iwad +} + +brightmap sprite BOS2A8C2 +{ + map "brightmaps/doom/BOS2A8C2.png" + iwad +} + +brightmap sprite BOS2B6D4 +{ + map "brightmaps/doom/BOS2B6D4.png" + iwad +} + +brightmap sprite BOS2B7D3 +{ + map "brightmaps/doom/BOS2B7D3.png" + iwad +} + +brightmap sprite BOS2B8D2 +{ + map "brightmaps/doom/BOS2B8D2.png" + iwad +} + +brightmap sprite SKELJ1 +{ + map "brightmaps/doom/SKELJ1.png" + iwad + disablefullbright +} + +brightmap sprite SKELJ2 +{ + map "brightmaps/doom/SKELJ2.png" + iwad + disablefullbright +} + +brightmap sprite SKELJ3 +{ + map "brightmaps/doom/SKELJ3.png" + iwad + disablefullbright +} + +brightmap sprite SKELJ4 +{ + map "brightmaps/doom/SKELJ4.png" + iwad + disablefullbright +} + +brightmap sprite SKELJ5 +{ + map "brightmaps/doom/SKELJ5.png" + iwad + disablefullbright +} + +brightmap sprite SKELJ6 +{ + map "brightmaps/doom/SKELJ6.png" + iwad + disablefullbright +} + +brightmap sprite SKELJ7 +{ + map "brightmaps/doom/SKELJ7.png" + iwad + disablefullbright +} + +brightmap sprite SKELJ8 +{ + map "brightmaps/doom/SKELJ8.png" + iwad + disablefullbright +} + +brightmap sprite FATTH1 +{ + map "brightmaps/doom/FATTH1.png" + iwad + disablefullbright +} + +brightmap sprite FATTH2H8 +{ + map "brightmaps/doom/FATTH2H8.png" + iwad + disablefullbright +} + +brightmap sprite FATTH3H7 +{ + map "brightmaps/doom/FATTH3H7.png" + iwad + disablefullbright +} + +brightmap sprite FATTH4H6 +{ + map "brightmaps/doom/FATTH4H6.png" + iwad + disablefullbright +} + +brightmap sprite FATTH5 +{ + map "brightmaps/doom/FATTH5.png" + iwad + disablefullbright +} + +brightmap sprite HEADC1 +{ + map "brightmaps/doom/HEADC1.png" + iwad + disablefullbright +} + +brightmap sprite HEADC2C8 +{ + map "brightmaps/doom/HEADC2C8.png" + iwad + disablefullbright +} + +brightmap sprite HEADC3C7 +{ + map "brightmaps/doom/HEADC3C7.png" + iwad + disablefullbright +} + +brightmap sprite HEADD1 +{ + map "brightmaps/doom/HEADD1.png" + iwad + disablefullbright +} + +brightmap sprite HEADD2D8 +{ + map "brightmaps/doom/HEADD2D8.png" + iwad + disablefullbright +} + +brightmap sprite HEADD3D7 +{ + map "brightmaps/doom/HEADD3D7.png" + iwad + disablefullbright +} + +brightmap sprite HEADD4D6 +{ + iwad + disablefullbright +} + +brightmap sprite HEADD5 +{ + iwad + disablefullbright +} + +brightmap sprite PAINF1 +{ + map "brightmaps/doom/PAINf1.png" + iwad + disablefullbright +} + +brightmap sprite PAINF2F8 +{ + map "brightmaps/doom/PAINf2f8.png" + iwad + disablefullbright +} + +brightmap sprite PAINF3F7 +{ + map "brightmaps/doom/PAINf3f7.png" + iwad + disablefullbright +} + +brightmap sprite PAINF4F6 +{ + iwad + disablefullbright +} + +brightmap sprite PAINF5 +{ + iwad + disablefullbright +} + +brightmap sprite CYBRF1 +{ + map "brightmaps/doom/CYBRF1.png" + iwad + disablefullbright +} + +brightmap sprite CYBRF2 +{ + map "brightmaps/doom/CYBRF2.png" + iwad + disablefullbright +} + +brightmap sprite CYBRF3 +{ + map "brightmaps/doom/CYBRF3.png" + iwad + disablefullbright +} + +brightmap sprite CYBRF4 +{ + map "brightmaps/doom/CYBRF4.png" + iwad + disablefullbright +} + +brightmap sprite CYBRF5 +{ + map "brightmaps/doom/CYBRF5.png" + iwad + disablefullbright +} + +brightmap sprite CYBRF6 +{ + map "brightmaps/doom/CYBRF6.png" + iwad + disablefullbright +} + +brightmap sprite CYBRF7 +{ + map "brightmaps/doom/CYBRF7.png" + iwad + disablefullbright +} + +brightmap sprite CYBRF8 +{ + map "brightmaps/doom/CYBRF8.png" + iwad + disablefullbright +} + +brightmap sprite CYBRJ0 +{ + map "brightmaps/doom/CYBRJ0.png" + iwad + disablefullbright +} + +brightmap sprite CYBRK0 +{ + map "brightmaps/doom/CYBRK0.png" + iwad + disablefullbright +} + +brightmap sprite CYBRL0 +{ + map "brightmaps/doom/CYBRL0.png" + iwad + disablefullbright +} + +brightmap sprite CYBRM0 +{ + map "brightmaps/doom/CYBRM0.png" + iwad + disablefullbright +} + +brightmap sprite CYBRN0 +{ + map "brightmaps/doom/CYBRN0.png" + iwad + disablefullbright +} + +brightmap sprite SPIDA1D1 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDA2D8 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDA3D7 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDA4D6 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDA5D5 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDG1 +{ + map "brightmaps/doom/SPIDG1.png" + iwad + disablefullbright +} + +brightmap sprite SPIDG2G8 +{ + map "brightmaps/doom/SPIDG2G8.png" + iwad + disablefullbright +} + +brightmap sprite SPIDG3G7 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDG4G6 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDG5 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDH1 +{ + map "brightmaps/doom/SPIDH1.png" + iwad + disablefullbright +} + +brightmap sprite SPIDG2G8 +{ + map "brightmaps/doom/SPIDH2H8.png" + iwad + disablefullbright +} + +brightmap sprite SPIDH3H7 +{ + map "brightmaps/doom/SPIDH3H7.png" + iwad + disablefullbright +} + +brightmap sprite SPIDH4H6 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDH5 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDH1 +{ + map "brightmaps/doom/SPIDH1.png" + iwad + disablefullbright +} + +brightmap sprite SPIDL0 +{ + map "brightmaps/doom/SPIDL0.png" + iwad + disablefullbright +} + +brightmap sprite SPIDM0 +{ + map "brightmaps/doom/SPIDM0.png" + iwad + disablefullbright +} + +brightmap sprite SPIDN0 +{ + map "brightmaps/doom/SPIDN0.png" + iwad + disablefullbright +} + +brightmap sprite SPIDO0 +{ + map "brightmaps/doom/SPIDO0.png" + iwad + disablefullbright +} + +brightmap sprite SPIDP0 +{ + map "brightmaps/doom/SPIDP0.png" + iwad + disablefullbright +} + +brightmap sprite SPIDQ0 +{ + map "brightmaps/doom/SPIDQ0.png" + iwad + disablefullbright +} + +brightmap sprite SPIDR0 +{ + map "brightmaps/doom/SPIDR0.png" + iwad + disablefullbright +} + +brightmap sprite BON2B0 +{ + map "brightmaps/doom/BON2B0.png" + iwad + disablefullbright +} + +brightmap sprite BON2c0 +{ + map "brightmaps/doom/BON2c0.png" + iwad + disablefullbright +} + +brightmap sprite BON2d0 +{ + map "brightmaps/doom/BON2d0.png" + iwad + disablefullbright +} + +brightmap sprite FCANA0 +{ + map "brightmaps/doom/FCANA0.png" + iwad + disablefullbright +} + +brightmap sprite FCANb0 +{ + map "brightmaps/doom/FCANb0.png" + iwad + disablefullbright +} + +brightmap sprite FCANc0 +{ + map "brightmaps/doom/FCANc0.png" + iwad + disablefullbright +} + +brightmap sprite treda0 +{ + map "brightmaps/doom/treda0.png" + iwad + disablefullbright +} + +brightmap sprite tredb0 +{ + map "brightmaps/doom/tredb0.png" + iwad + disablefullbright +} + +brightmap sprite tredc0 +{ + map "brightmaps/doom/tredc0.png" + iwad + disablefullbright +} + +brightmap sprite tredd0 +{ + map "brightmaps/doom/tredd0.png" + iwad + disablefullbright +} + +brightmap sprite TBLUA0 +{ + map "brightmaps/doom/treda0.png" + iwad + disablefullbright +} + +brightmap sprite TBLUb0 +{ + map "brightmaps/doom/TBLUb0.png" + iwad + disablefullbright +} + +brightmap sprite TBLUc0 +{ + map "brightmaps/doom/TBLUc0.png" + iwad + disablefullbright +} + +brightmap sprite TBLUd0 +{ + map "brightmaps/doom/tredd0.png" + iwad + disablefullbright +} + +brightmap sprite TGRNA0 +{ + map "brightmaps/doom/treda0.png" + iwad + disablefullbright +} + +brightmap sprite TGRNb0 +{ + map "brightmaps/doom/tredb0.png" + iwad + disablefullbright +} + +brightmap sprite TGRNc0 +{ + map "brightmaps/doom/tredc0.png" + iwad + disablefullbright +} + +brightmap sprite TGRNd0 +{ + map "brightmaps/doom/tredd0.png" + iwad + disablefullbright +} + +brightmap sprite SMRTA0 +{ + map "brightmaps/doom/SMRTA0.png" + iwad + disablefullbright +} + +brightmap sprite SMRTb0 +{ + map "brightmaps/doom/SMRTb0.png" + iwad + disablefullbright +} + +brightmap sprite SMRTc0 +{ + map "brightmaps/doom/SMRTc0.png" + iwad + disablefullbright +} + +brightmap sprite SMRTd0 +{ + map "brightmaps/doom/SMRTd0.png" + iwad + disablefullbright +} + +brightmap sprite SMbTA0 +{ + map "brightmaps/doom/SMRTA0.png" + iwad + disablefullbright +} + +brightmap sprite SMbTb0 +{ + map "brightmaps/doom/SMRTb0.png" + iwad + disablefullbright +} + +brightmap sprite SMbTc0 +{ + map "brightmaps/doom/SMRTc0.png" + iwad + disablefullbright +} + +brightmap sprite SMbTd0 +{ + map "brightmaps/doom/SMRTd0.png" + iwad + disablefullbright +} + +brightmap sprite SMgTA0 +{ + map "brightmaps/doom/SMRTA0.png" + iwad + disablefullbright +} + +brightmap sprite SMgTb0 +{ + map "brightmaps/doom/SMRTb0.png" + iwad + disablefullbright +} + +brightmap sprite SMgTc0 +{ + map "brightmaps/doom/SMRTc0.png" + iwad + disablefullbright +} + +brightmap sprite SMgTd0 +{ + map "brightmaps/doom/SMRTd0.png" + iwad + disablefullbright +} + +brightmap sprite vileg1 +{ + map "brightmaps/doom/vileg1.png" + iwad + disablefullbright +} + +brightmap sprite vileg2 +{ + map "brightmaps/doom/vileg2.png" + iwad + disablefullbright +} + +brightmap sprite vileg3 +{ + map "brightmaps/doom/vileg3.png" + iwad + disablefullbright +} + +brightmap sprite vileg4 +{ + map "brightmaps/doom/vileg4.png" + iwad + disablefullbright +} + +brightmap sprite vileg5 +{ + map "brightmaps/doom/vileg5.png" + iwad + disablefullbright +} + +brightmap sprite vileg6 +{ + map "brightmaps/doom/vileg6.png" + iwad + disablefullbright +} + +brightmap sprite vileg7 +{ + map "brightmaps/doom/vileg7.png" + iwad + disablefullbright +} + +brightmap sprite vileg8 +{ + map "brightmaps/doom/vileg8.png" + iwad + disablefullbright +} + +brightmap sprite vileh1 +{ + map "brightmaps/doom/vileh1.png" + iwad + disablefullbright +} + +brightmap sprite vileh2 +{ + map "brightmaps/doom/vileh2.png" + iwad + disablefullbright +} + +brightmap sprite vileh3 +{ + map "brightmaps/doom/vileh3.png" + iwad + disablefullbright +} + +brightmap sprite vileh4 +{ + map "brightmaps/doom/vileh4.png" + iwad + disablefullbright +} + +brightmap sprite vileh5 +{ + map "brightmaps/doom/vileh5.png" + iwad + disablefullbright +} + +brightmap sprite vileh6 +{ + map "brightmaps/doom/vileh6.png" + iwad + disablefullbright +} + +brightmap sprite vileh7 +{ + map "brightmaps/doom/vileh7.png" + iwad + disablefullbright +} + +brightmap sprite vileh8 +{ + map "brightmaps/doom/vileh8.png" + iwad + disablefullbright +} + +brightmap sprite vilei1 +{ + map "brightmaps/doom/vilei1.png" + iwad + disablefullbright +} + +brightmap sprite vilei2 +{ + map "brightmaps/doom/vilei2.png" + iwad + disablefullbright +} + +brightmap sprite vilei3 +{ + map "brightmaps/doom/vilei3.png" + iwad + disablefullbright +} + +brightmap sprite vilei4 +{ + map "brightmaps/doom/vilei4.png" + iwad + disablefullbright +} + +brightmap sprite vilei5 +{ + map "brightmaps/doom/vilei5.png" + iwad + disablefullbright +} + +brightmap sprite vilei6 +{ + map "brightmaps/doom/vilei6.png" + iwad + disablefullbright +} + +brightmap sprite vilei7 +{ + map "brightmaps/doom/vilei7.png" + iwad + disablefullbright +} + +brightmap sprite vilei8 +{ + map "brightmaps/doom/vilei8.png" + iwad + disablefullbright +} + +brightmap sprite vilej1 +{ + map "brightmaps/doom/vilej1.png" + iwad + disablefullbright +} + +brightmap sprite vilej2 +{ + map "brightmaps/doom/vilej2.png" + iwad + disablefullbright +} + +brightmap sprite vilej3 +{ + map "brightmaps/doom/vilej3.png" + iwad + disablefullbright +} + +brightmap sprite vilej4 +{ + map "brightmaps/doom/vilej4.png" + iwad + disablefullbright +} + +brightmap sprite vilej5 +{ + map "brightmaps/doom/vilej5.png" + iwad + disablefullbright +} + +brightmap sprite vilej6 +{ + map "brightmaps/doom/vilej6.png" + iwad + disablefullbright +} + +brightmap sprite vilej7 +{ + map "brightmaps/doom/vilej7.png" + iwad + disablefullbright +} + +brightmap sprite vilej8 +{ + map "brightmaps/doom/vilej8.png" + iwad + disablefullbright +} + +brightmap sprite vilek1 +{ + map "brightmaps/doom/vilek1.png" + iwad + disablefullbright +} + +brightmap sprite vilek2 +{ + map "brightmaps/doom/vilek2.png" + iwad + disablefullbright +} + +brightmap sprite vilek3 +{ + map "brightmaps/doom/vilek3.png" + iwad + disablefullbright +} + +brightmap sprite vilek4 +{ + map "brightmaps/doom/vilek4.png" + iwad + disablefullbright +} + +brightmap sprite vilek5 +{ + map "brightmaps/doom/vilek5.png" + iwad + disablefullbright +} + +brightmap sprite vilek6 +{ + map "brightmaps/doom/vilek6.png" + iwad + disablefullbright +} + +brightmap sprite vilek7 +{ + map "brightmaps/doom/vilek7.png" + iwad + disablefullbright +} + +brightmap sprite vilek8 +{ + map "brightmaps/doom/vilek8.png" + iwad + disablefullbright +} + +brightmap sprite vilel1 +{ + map "brightmaps/doom/vilel1.png" + iwad + disablefullbright +} + +brightmap sprite vilel2 +{ + map "brightmaps/doom/vilel2.png" + iwad + disablefullbright +} + +brightmap sprite vilel3 +{ + map "brightmaps/doom/vilel3.png" + iwad + disablefullbright +} + +brightmap sprite vilel4 +{ + map "brightmaps/doom/vilel4.png" + iwad + disablefullbright +} + +brightmap sprite vilel5 +{ + map "brightmaps/doom/vilel5.png" + iwad + disablefullbright +} + +brightmap sprite vilel6 +{ + map "brightmaps/doom/vilel6.png" + iwad + disablefullbright +} + +brightmap sprite vilel7 +{ + map "brightmaps/doom/vilel7.png" + iwad + disablefullbright +} + +brightmap sprite vilel8 +{ + map "brightmaps/doom/vilel8.png" + iwad + disablefullbright +} + +brightmap sprite vilem1 +{ + map "brightmaps/doom/vilem1.png" + iwad + disablefullbright +} + +brightmap sprite vilem2 +{ + map "brightmaps/doom/vilem2.png" + iwad + disablefullbright +} + +brightmap sprite vilem3 +{ + map "brightmaps/doom/vilem3.png" + iwad + disablefullbright +} + +brightmap sprite vilem4 +{ + map "brightmaps/doom/vilem4.png" + iwad + disablefullbright +} + +brightmap sprite vilem5 +{ + map "brightmaps/doom/vilem5.png" + iwad + disablefullbright +} + +brightmap sprite vilem6 +{ + map "brightmaps/doom/vilem6.png" + iwad + disablefullbright +} + +brightmap sprite vilem7 +{ + map "brightmaps/doom/vilem7.png" + iwad + disablefullbright +} + +brightmap sprite vilem8 +{ + map "brightmaps/doom/vilem8.png" + iwad + disablefullbright +} + +brightmap sprite vilen1 +{ + map "brightmaps/doom/vilen1.png" + iwad + disablefullbright +} + +brightmap sprite vilen2 +{ + map "brightmaps/doom/vilen2.png" + iwad + disablefullbright +} + +brightmap sprite vilen3 +{ + map "brightmaps/doom/vilen3.png" + iwad + disablefullbright +} + +brightmap sprite vilen4 +{ + map "brightmaps/doom/vilen4.png" + iwad + disablefullbright +} + +brightmap sprite vilen5 +{ + map "brightmaps/doom/vilen5.png" + iwad + disablefullbright +} + +brightmap sprite vilen6 +{ + map "brightmaps/doom/vilen6.png" + iwad + disablefullbright +} + +brightmap sprite vilen7 +{ + map "brightmaps/doom/vilen7.png" + iwad + disablefullbright +} + +brightmap sprite vilen8 +{ + map "brightmaps/doom/vilen8.png" + iwad + disablefullbright +} + +brightmap sprite vileo1 +{ + map "brightmaps/doom/vileo1.png" + iwad + disablefullbright +} + +brightmap sprite vileo2 +{ + map "brightmaps/doom/vileo2.png" + iwad + disablefullbright +} + +brightmap sprite vileo3 +{ + map "brightmaps/doom/vileo3.png" + iwad + disablefullbright +} + +brightmap sprite vileo4 +{ + map "brightmaps/doom/vileo4.png" + iwad + disablefullbright +} + +brightmap sprite vileo5 +{ + map "brightmaps/doom/vileo5.png" + iwad + disablefullbright +} + +brightmap sprite vileo6 +{ + map "brightmaps/doom/vileo6.png" + iwad + disablefullbright +} + +brightmap sprite vileo7 +{ + map "brightmaps/doom/vileo7.png" + iwad + disablefullbright +} + +brightmap sprite vileo8 +{ + map "brightmaps/doom/vileo8.png" + iwad + disablefullbright +} + +brightmap sprite vilep1 +{ + map "brightmaps/doom/vilep1.png" + iwad + disablefullbright +} + +brightmap sprite vilep2 +{ + map "brightmaps/doom/vilep2.png" + iwad + disablefullbright +} + +brightmap sprite vilep3 +{ + map "brightmaps/doom/vilep3.png" + iwad + disablefullbright +} + +brightmap sprite vilep4 +{ + map "brightmaps/doom/vilep4.png" + iwad + disablefullbright +} + +brightmap sprite vilep5 +{ + map "brightmaps/doom/vilep5.png" + iwad + disablefullbright +} + +brightmap sprite vilep6 +{ + map "brightmaps/doom/vilep6.png" + iwad + disablefullbright +} + +brightmap sprite vilep7 +{ + map "brightmaps/doom/vilep7.png" + iwad + disablefullbright +} + +brightmap sprite vilep8 +{ + map "brightmaps/doom/vilep8.png" + iwad + disablefullbright +} diff --git a/wadsrc_bm/static/hexndefs.bm b/wadsrc_bm/static/hexndefs.bm new file mode 100644 index 000000000..180f6b15c --- /dev/null +++ b/wadsrc_bm/static/hexndefs.bm @@ -0,0 +1,268 @@ + +brightmap sprite CDLRA0 +{ + map "brightmaps/hexen/CDLRA0.png" + iwad + disablefullbright +} + +brightmap sprite CDLRB0 +{ + map "brightmaps/hexen/CDLRB0.png" + iwad + disablefullbright +} + +brightmap sprite CDLRC0 +{ + map "brightmaps/hexen/CDLRC0.png" + iwad + disablefullbright +} + +brightmap sprite CENTF1 +{ + map "brightmaps/hexen/CENTF1.png" + iwad + disablefullbright +} + +brightmap sprite CENTF2 +{ + map "brightmaps/hexen/CENTF2.png" + iwad + disablefullbright +} + +brightmap sprite CENTF3 +{ + iwad + disablefullbright +} + +brightmap sprite CENTF4 +{ + iwad + disablefullbright +} + +brightmap sprite CENTF5 +{ + iwad + disablefullbright +} + +brightmap sprite CENTF6 +{ + iwad + disablefullbright +} + +brightmap sprite CENTF7 +{ + iwad + disablefullbright +} + +brightmap sprite CENTF8 +{ + map "brightmaps/hexen/CENTF8.png" + iwad + disablefullbright +} + +brightmap sprite ICEYG1 +{ + map "brightmaps/hexen/ICEYG1.png" + iwad + disablefullbright +} + +brightmap sprite ICEYG2G8 +{ + map "brightmaps/hexen/ICEYG2G8.png" + iwad + disablefullbright +} + +brightmap sprite ICEYG3G7 +{ + map "brightmaps/hexen/ICEYG3G7.png" + iwad + disablefullbright +} + +brightmap sprite ICEYG4G6 +{ + map "brightmaps/hexen/ICEYG4G6.png" + iwad + disablefullbright +} + +brightmap sprite ICEYG5 +{ + map "brightmaps/hexen/ICEYG5.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF1 +{ + map "brightmaps/hexen/MAGEF1.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF2 +{ + map "brightmaps/hexen/MAGEF2.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF3 +{ + map "brightmaps/hexen/MAGEF3.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF4 +{ + map "brightmaps/hexen/MAGEF4.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF5 +{ + map "brightmaps/hexen/MAGEF5.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF6 +{ + map "brightmaps/hexen/MAGEF6.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF7 +{ + map "brightmaps/hexen/MAGEF7.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF8 +{ + map "brightmaps/hexen/MAGEF8.png" + iwad + disablefullbright +} + +brightmap sprite WRTHE1 +{ + map "brightmaps/hexen/WRTHE1.png" + iwad + disablefullbright +} + +brightmap sprite WRTHE2E8 +{ + map "brightmaps/hexen/WRTHE2E8.png" + iwad + disablefullbright +} + +brightmap sprite WRTHE3E7 +{ + map "brightmaps/hexen/WRTHE3E7.png" + iwad + disablefullbright +} + +brightmap sprite WRTHE4E6 +{ + map "brightmaps/hexen/WRTHE4E6.png" + iwad + disablefullbright +} + +brightmap sprite WRTHE5 +{ + map "brightmaps/hexen/WRTHE5.png" + iwad + disablefullbright +} + +brightmap sprite WRTHF1 +{ + map "brightmaps/hexen/WRTHF1.png" + iwad + disablefullbright +} + +brightmap sprite WRTHF2F8 +{ + map "brightmaps/hexen/WRTHF2F8.png" + iwad + disablefullbright +} + +brightmap sprite WRTHF3F7 +{ + map "brightmaps/hexen/WRTHF3F7.png" + iwad + disablefullbright +} + +brightmap sprite WRTHF4F6 +{ + map "brightmaps/hexen/WRTHF4F6.png" + iwad + disablefullbright +} + +brightmap sprite WRTHF5 +{ + map "brightmaps/hexen/WRTHF5.png" + iwad + disablefullbright +} + +brightmap sprite WRTHG1 +{ + map "brightmaps/hexen/WRTHG1.png" + iwad + disablefullbright +} + +brightmap sprite WRTHG2G8 +{ + map "brightmaps/hexen/WRTHG2G8.png" + iwad + disablefullbright +} + +brightmap sprite WRTHG3G7 +{ + map "brightmaps/hexen/WRTHG3G7.png" + iwad + disablefullbright +} + +brightmap sprite WRTHG4G6 +{ + map "brightmaps/hexen/WRTHG4G6.png" + iwad + disablefullbright +} + +brightmap sprite WRTHG5 +{ + map "brightmaps/hexen/WRTHG5.png" + iwad + disablefullbright +} diff --git a/wadsrc_bm/static/hticdefs.bm b/wadsrc_bm/static/hticdefs.bm new file mode 100644 index 000000000..a61afcf62 --- /dev/null +++ b/wadsrc_bm/static/hticdefs.bm @@ -0,0 +1,692 @@ +brightmap sprite BEASI1 +{ + map "brightmaps/heretic/BEASI1.png" + iwad + disablefullbright +} + +brightmap sprite BEASI2I8 +{ + map "brightmaps/heretic/BEASI2I8.png" + iwad + disablefullbright +} + +brightmap sprite BEASI3I7 +{ + map "brightmaps/heretic/BEASI3I7.png" + iwad + disablefullbright +} + +brightmap sprite CHDLA0 +{ + map "brightmaps/heretic/CHDLA0.png" + iwad + disablefullbright +} + +brightmap sprite CHDLB0 +{ + map "brightmaps/heretic/CHDLB0.png" + iwad + disablefullbright +} + +brightmap sprite CHDLC0 +{ + map "brightmaps/heretic/CHDLC0.png" + iwad + disablefullbright +} + +brightmap sprite CLNKI0 +{ + map "brightmaps/heretic/CLNKI0.png" + iwad + disablefullbright +} + +brightmap sprite CLNKJ0 +{ + map "brightmaps/heretic/CLNKJ0.png" + iwad + disablefullbright +} + +brightmap sprite CLNKK0 +{ + map "brightmaps/heretic/CLNKK0.png" + iwad + disablefullbright +} + +brightmap sprite CLNKL0 +{ + map "brightmaps/heretic/CLNKL0.png" + iwad + disablefullbright +} + +brightmap sprite CLNKM0 +{ + map "brightmaps/heretic/CLNKM0.png" + iwad + disablefullbright +} + +brightmap sprite CLNKN0 +{ + map "brightmaps/heretic/CLNKN0.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD1 +{ + map "brightmaps/heretic/IMPXD1.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD2 +{ + map "brightmaps/heretic/IMPXD2.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD3 +{ + map "brightmaps/heretic/IMPXD3.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD4 +{ + map "brightmaps/heretic/IMPXD4.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD5 +{ + map "brightmaps/heretic/IMPXD5.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD6 +{ + map "brightmaps/heretic/IMPXD6.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD7 +{ + map "brightmaps/heretic/IMPXD7.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD8 +{ + map "brightmaps/heretic/IMPXD8.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE1 +{ + map "brightmaps/heretic/IMPXE1.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE2 +{ + map "brightmaps/heretic/IMPXE2.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE3 +{ + map "brightmaps/heretic/IMPXE3.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE4 +{ + map "brightmaps/heretic/IMPXE4.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE5 +{ + map "brightmaps/heretic/IMPXE5.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE6 +{ + map "brightmaps/heretic/IMPXE6.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE7 +{ + map "brightmaps/heretic/IMPXE7.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE8 +{ + map "brightmaps/heretic/IMPXE8.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF1 +{ + map "brightmaps/heretic/IMPXF1.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF2 +{ + map "brightmaps/heretic/IMPXF2.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF3 +{ + map "brightmaps/heretic/IMPXF3.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF4 +{ + map "brightmaps/heretic/IMPXF4.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF5 +{ + map "brightmaps/heretic/IMPXF5.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF6 +{ + map "brightmaps/heretic/IMPXF6.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF7 +{ + map "brightmaps/heretic/IMPXF7.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF8 +{ + map "brightmaps/heretic/IMPXF8.png" + iwad + disablefullbright +} + +brightmap sprite LICHB1 +{ + map "brightmaps/heretic/LICHB1.png" + iwad + disablefullbright +} + +brightmap sprite LICHB2B8 +{ + map "brightmaps/heretic/LICHB2B8.png" + iwad + disablefullbright +} + +brightmap sprite LICHB3M7 +{ + map "brightmaps/heretic/LICHB3B7.png" + iwad + disablefullbright +} + +brightmap sprite LICHC0 +{ + map "brightmaps/heretic/LICHC0.png" + iwad + disablefullbright +} + +brightmap sprite LICHD0 +{ + map "brightmaps/heretic/LICHD0.png" + iwad + disablefullbright +} + +brightmap sprite LICHE0 +{ + map "brightmaps/heretic/LICHE0.png" + iwad + disablefullbright +} + +brightmap sprite LICHF0 +{ + map "brightmaps/heretic/LICHF0.png" + iwad + disablefullbright +} + +brightmap sprite LICHG0 +{ + map "brightmaps/heretic/LICHG0.png" + iwad + disablefullbright +} + +brightmap sprite LICHH0 +{ + map "brightmaps/heretic/LICHH0.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF1 +{ + map "brightmaps/heretic/PLAYf1.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF2F8 +{ + map "brightmaps/heretic/PLAYf2f8.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF3F7 +{ + map "brightmaps/heretic/PLAYf3f7.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF4F6 +{ + map "brightmaps/heretic/PLAYf4f6.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF5 +{ + iwad + disablefullbright +} + +brightmap sprite SDTHA0 +{ + map "brightmaps/heretic/SDTHA0.png" + iwad + disablefullbright +} + +brightmap sprite SDTHB0 +{ + map "brightmaps/heretic/SDTHB0.png" + iwad + disablefullbright +} + +brightmap sprite SDTHC0 +{ + map "brightmaps/heretic/SDTHC0.png" + iwad + disablefullbright +} + +brightmap sprite SDTHD0 +{ + map "brightmaps/heretic/SDTHD0.png" + iwad + disablefullbright +} + +brightmap sprite SDTHE0 +{ + map "brightmaps/heretic/SDTHE0.png" + iwad + disablefullbright +} + +brightmap sprite SDTHF0 +{ + map "brightmaps/heretic/SDTHF0.png" + iwad + disablefullbright +} + +brightmap sprite SDTHG0 +{ + map "brightmaps/heretic/SDTHG0.png" + iwad + disablefullbright +} + +brightmap sprite SDTHH0 +{ + map "brightmaps/heretic/SDTHH0.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R1 +{ + map "brightmaps/heretic/SOR2R1.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R2 +{ + map "brightmaps/heretic/SOR2R2.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R3 +{ + map "brightmaps/heretic/SOR2R3.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R4 +{ + map "brightmaps/heretic/SOR2R4.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R5 +{ + map "brightmaps/heretic/SOR2R5.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R6 +{ + map "brightmaps/heretic/SOR2R6.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R7 +{ + map "brightmaps/heretic/SOR2R7.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R8 +{ + map "brightmaps/heretic/SOR2R8.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S1 +{ + map "brightmaps/heretic/SOR2S1.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S2 +{ + map "brightmaps/heretic/SOR2S2.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S3 +{ + map "brightmaps/heretic/SOR2S3.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S4 +{ + map "brightmaps/heretic/SOR2S4.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S5 +{ + map "brightmaps/heretic/SOR2S5.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S6 +{ + map "brightmaps/heretic/SOR2S6.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S7 +{ + map "brightmaps/heretic/SOR2S7.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S8 +{ + map "brightmaps/heretic/SOR2S8.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T1 +{ + map "brightmaps/heretic/SOR2T1.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T2 +{ + map "brightmaps/heretic/SOR2T2.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T3 +{ + map "brightmaps/heretic/SOR2T3.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T4 +{ + map "brightmaps/heretic/SOR2T4.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T5 +{ + map "brightmaps/heretic/SOR2T5.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T6 +{ + map "brightmaps/heretic/SOR2T6.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T7 +{ + map "brightmaps/heretic/SOR2T7.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T8 +{ + map "brightmaps/heretic/SOR2T8.png" + iwad + disablefullbright +} + +brightmap sprite VLCOE0 +{ + map "brightmaps/heretic/VLCOE0.png" + iwad + disablefullbright +} + +brightmap sprite WZRDC1 +{ + map "brightmaps/heretic/WZRDC1.png" + iwad + disablefullbright +} + +brightmap sprite WZRDC2C8 +{ + map "brightmaps/heretic/WZRDC2C8.png" + iwad + disablefullbright +} + +brightmap sprite WZRDC3C7 +{ + map "brightmaps/heretic/WZRDC3C7.png" + iwad + disablefullbright +} + +brightmap sprite WZRDC4C6 +{ + map "brightmaps/heretic/WZRDC4C6.png" + iwad + disablefullbright +} + +brightmap sprite WZRDC5 +{ + map "brightmaps/heretic/WZRDC5.png" + iwad + disablefullbright +} + +brightmap sprite WZRDD1 +{ + map "brightmaps/heretic/WZRDD1.png" + iwad + disablefullbright +} + +brightmap sprite WZRDD2D8 +{ + map "brightmaps/heretic/WZRDD2D8.png" + iwad + disablefullbright +} + +brightmap sprite WZRDD3D7 +{ + map "brightmaps/heretic/WZRDD3D7.png" + iwad + disablefullbright +} + +brightmap sprite WZRDD4D6 +{ + map "brightmaps/heretic/WZRDD4D6.png" + iwad + disablefullbright +} + +brightmap sprite WZRDD5 +{ + map "brightmaps/heretic/WZRDD5.png" + iwad + disablefullbright +} + +brightmap sprite WZRDF0 +{ + map "brightmaps/heretic/WZRDF0.png" + iwad + disablefullbright +} + +brightmap sprite WZRDG0 +{ + map "brightmaps/heretic/WZRDG0.png" + iwad + disablefullbright +} + +brightmap sprite WZRDH0 +{ + map "brightmaps/heretic/WZRDH0.png" + iwad + disablefullbright +} + +brightmap sprite WZRDI0 +{ + map "brightmaps/heretic/WZRDI0.png" + iwad + disablefullbright +} + +brightmap sprite WZRDJ0 +{ + map "brightmaps/heretic/WZRDJ0.png" + iwad + disablefullbright +} + +brightmap sprite WZRDK0 +{ + map "brightmaps/heretic/WZRDK0.png" + iwad + disablefullbright +} + diff --git a/wadsrc_bm/static/strfdefs.bm b/wadsrc_bm/static/strfdefs.bm new file mode 100644 index 000000000..75c2fd9c2 --- /dev/null +++ b/wadsrc_bm/static/strfdefs.bm @@ -0,0 +1,1253 @@ +brightmap sprite HMN1F1 +{ + iwad + disablefullbright +} + +brightmap sprite HMN1F2 +{ + iwad + disablefullbright +} + +brightmap sprite HMN1F3 +{ + iwad + disablefullbright +} + +brightmap sprite HMN1F4 +{ + iwad + disablefullbright +} + +brightmap sprite HMN1F5 +{ + iwad + disablefullbright +} + +brightmap sprite HMN1F6 +{ + iwad + disablefullbright +} + +brightmap sprite HMN1F7 +{ + iwad + disablefullbright +} + +brightmap sprite HMN1F8 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF1 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF2 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF3 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF4 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF5 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF6 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF7 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF8 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRE1 +{ + map "brightmaps/strife/MLDRE1.png" + disablefullbright + iwad +} + +brightmap sprite MLDRE2 +{ + map "brightmaps/strife/MLDRE2.png" + disablefullbright + iwad +} + +brightmap sprite MLDRE3 +{ + map "brightmaps/strife/MLDRE3.png" + disablefullbright + iwad +} + +brightmap sprite MLDRE4 +{ + map "brightmaps/strife/MLDRE4.png" + disablefullbright + iwad +} + +brightmap sprite MLDRE5 +{ + map "brightmaps/strife/MLDRE5.png" + disablefullbright + iwad +} + +brightmap sprite MLDRE6 +{ + map "brightmaps/strife/MLDRE6.png" + disablefullbright + iwad +} + +brightmap sprite MLDRE7 +{ + map "brightmaps/strife/MLDRE7.png" + disablefullbright + iwad +} + +brightmap sprite MLDRE8 +{ + map "brightmaps/strife/MLDRE8.png" + disablefullbright + iwad +} + +brightmap sprite MLDRF1 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRF2 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRF3 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRF4 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRF5 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRF6 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRF7 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRF8 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDG1 +{ + map "brightmaps/strife/PGRDG1.png" + disablefullbright + iwad +} + +brightmap sprite PGRDG2 +{ + map "brightmaps/strife/PGRDG2.png" + disablefullbright + iwad +} + +brightmap sprite PGRDG3 +{ + map "brightmaps/strife/PGRDG3.png" + disablefullbright + iwad +} + +brightmap sprite PGRDG4 +{ + map "brightmaps/strife/PGRDG4.png" + disablefullbright + iwad +} + +brightmap sprite PGRDG5 +{ + map "brightmaps/strife/PGRDG5.png" + disablefullbright + iwad +} + +brightmap sprite PGRDG6 +{ + map "brightmaps/strife/PGRDG6.png" + disablefullbright + iwad +} + +brightmap sprite PGRDG7 +{ + map "brightmaps/strife/PGRDG7.png" + disablefullbright + iwad +} + +brightmap sprite PGRDG8 +{ + map "brightmaps/strife/PGRDG8.png" + disablefullbright + iwad +} + +brightmap sprite PGRDH1 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDH2 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDH3 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDH4 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDH5 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDH6 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDH7 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDH8 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDI0 +{ + map "brightmaps/strife/PGRDI0.png" + disablefullbright + iwad +} + +brightmap sprite PGRDJ0 +{ + map "brightmaps/strife/PGRDJ0.png" + disablefullbright + iwad +} + +brightmap sprite PGRDK0 +{ + map "brightmaps/strife/PGRDK0.png" + disablefullbright + iwad +} + +brightmap sprite PGRDL0 +{ + map "brightmaps/strife/PGRDL0.png" + disablefullbright + iwad +} + +brightmap sprite PGRDM0 +{ + map "brightmaps/strife/PGRDM0.png" + disablefullbright + iwad +} + +brightmap sprite PGRDN0 +{ + map "brightmaps/strife/PGRDN0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1G1 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1G2 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1G3 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1G4 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1G5 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1G6 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1G7 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1G8 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1j0 +{ + map "brightmaps/strife/ROB1J0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1K0 +{ + map "brightmaps/strife/ROB1K0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1L0 +{ + map "brightmaps/strife/ROB1L0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1M0 +{ + map "brightmaps/strife/ROB1M0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1N0 +{ + map "brightmaps/strife/ROB1N0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1O0 +{ + map "brightmaps/strife/ROB1O0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1P0 +{ + map "brightmaps/strife/ROB1P0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1Q0 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E1 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E2 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E3 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E4 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E5 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E6 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E7 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E8 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2F1 +{ + map "brightmaps/strife/ROB2F1.png" + disablefullbright + iwad +} + +brightmap sprite ROB2F2 +{ + map "brightmaps/strife/ROB2F2.png" + disablefullbright + iwad +} + +brightmap sprite ROB2F3 +{ + map "brightmaps/strife/ROB2F3.png" + disablefullbright + iwad +} + +brightmap sprite ROB2F4 +{ + map "brightmaps/strife/ROB2F4.png" + disablefullbright + iwad +} + +brightmap sprite ROB2F5 +{ + map "brightmaps/strife/ROB2F5.png" + disablefullbright + iwad +} + +brightmap sprite ROB2F6 +{ + map "brightmaps/strife/ROB2F6.png" + disablefullbright + iwad +} + +brightmap sprite ROB2F7 +{ + map "brightmaps/strife/ROB2F7.png" + disablefullbright + iwad +} + +brightmap sprite ROB2F8 +{ + map "brightmaps/strife/ROB2F8.png" + disablefullbright + iwad +} + +brightmap sprite ROB2G0 +{ + map "brightmaps/strife/ROB2G0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2H0 +{ + map "brightmaps/strife/ROB2H0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2I0 +{ + map "brightmaps/strife/ROB2I0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2J0 +{ + map "brightmaps/strife/ROB2J0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2K0 +{ + map "brightmaps/strife/ROB2K0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2L0 +{ + map "brightmaps/strife/ROB2L0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2M0 +{ + map "brightmaps/strife/ROB2M0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2N0 +{ + map "brightmaps/strife/ROB2N0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2O0 +{ + map "brightmaps/strife/ROB2O0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F1 +{ + map "brightmaps/strife/ROB3F1.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F2 +{ + map "brightmaps/strife/ROB3F2.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F3 +{ + map "brightmaps/strife/ROB3F3.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F4 +{ + map "brightmaps/strife/ROB3F4.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F5 +{ + map "brightmaps/strife/ROB3F5.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F6 +{ + map "brightmaps/strife/ROB3F6.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F7 +{ + map "brightmaps/strife/ROB3F7.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F8 +{ + map "brightmaps/strife/ROB3F8.png" + disablefullbright + iwad +} + +brightmap sprite ROB3G1 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3G2 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3G3 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3G4 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3G5 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3G6 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3G7 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3G8 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3H1 +{ + map "brightmaps/strife/ROB3H1.png" + disablefullbright + iwad +} + +brightmap sprite ROB3H2 +{ + map "brightmaps/strife/ROB3H2.png" + disablefullbright + iwad +} + +brightmap sprite ROB3H3 +{ + map "brightmaps/strife/ROB3H3.png" + disablefullbright + iwad +} + +brightmap sprite ROB3H4 +{ + map "brightmaps/strife/ROB3H4.png" + disablefullbright + iwad +} + +brightmap sprite ROB3H5 +{ + map "brightmaps/strife/ROB3H5.png" + disablefullbright + iwad +} + +brightmap sprite ROB3H6 +{ + map "brightmaps/strife/ROB3H6.png" + disablefullbright + iwad +} + +brightmap sprite ROB3H7 +{ + map "brightmaps/strife/ROB3H7.png" + disablefullbright + iwad +} + +brightmap sprite ROB3H8 +{ + map "brightmaps/strife/ROB3H8.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I1 +{ + map "brightmaps/strife/ROB3I1.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I2 +{ + map "brightmaps/strife/ROB3I2.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I3 +{ + map "brightmaps/strife/ROB3I3.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I4 +{ + map "brightmaps/strife/ROB3I4.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I5 +{ + map "brightmaps/strife/ROB3I5.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I6 +{ + map "brightmaps/strife/ROB3I6.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I7 +{ + map "brightmaps/strife/ROB3I7.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I8 +{ + map "brightmaps/strife/ROB3I8.png" + disablefullbright + iwad +} + +brightmap sprite ROB3J1 +{ + map "brightmaps/strife/ROB3J1.png" + disablefullbright + iwad +} + +brightmap sprite ROB3J2 +{ + map "brightmaps/strife/ROB3J2.png" + disablefullbright + iwad +} + +brightmap sprite ROB3J3 +{ + map "brightmaps/strife/ROB3J3.png" + disablefullbright + iwad +} + +brightmap sprite ROB3J4 +{ + map "brightmaps/strife/ROB3J4.png" + disablefullbright + iwad +} + +brightmap sprite ROB3J5 +{ + disablefullbright + iwad +} + +brightmap sprite ROB3J6 +{ + map "brightmaps/strife/ROB3J6.png" + disablefullbright + iwad +} + +brightmap sprite ROB3J7 +{ + map "brightmaps/strife/ROB3J7.png" + disablefullbright + iwad +} + +brightmap sprite ROB3J8 +{ + map "brightmaps/strife/ROB3J8.png" + disablefullbright + iwad +} + +brightmap sprite ROB3M0 +{ + map "brightmaps/strife/ROB3M0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3N0 +{ + map "brightmaps/strife/ROB3N0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3O0 +{ + map "brightmaps/strife/ROB3O0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3P0 +{ + map "brightmaps/strife/ROB3P0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3Q0 +{ + map "brightmaps/strife/ROB3Q0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3R0 +{ + disablefullbright + iwad +} + +brightmap sprite ROB3S0 +{ + disablefullbright + iwad +} + +brightmap sprite ROB3T0 +{ + map "brightmaps/strife/ROB3T0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3U0 +{ + map "brightmaps/strife/ROB3U0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3V0 +{ + map "brightmaps/strife/ROB3V0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3W0 +{ + map "brightmaps/strife/ROB3W0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3X0 +{ + map "brightmaps/strife/ROB3X0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3Y0 +{ + map "brightmaps/strife/ROB3Y0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3Z0 +{ + map "brightmaps/strife/ROB3Z0.png" + disablefullbright + iwad +} + +brightmap sprite "ROB3[0" +{ + map "brightmaps/strife/ROB3[0.png" + disablefullbright + iwad +} + +brightmap sprite "ROB3\0" +{ + map "brightmaps/strife/ROB3^0.png" + disablefullbright + iwad +} + +brightmap sprite "ROB3]0" +{ + map "brightmaps/strife/ROB3]0.png" + disablefullbright + iwad +} + +brightmap sprite RBB3A0 +{ + map "brightmaps/strife/RBB3A0.png" + disablefullbright + iwad +} + +brightmap sprite RBB3B0 +{ + map "brightmaps/strife/RBB3B0.png" + disablefullbright + iwad +} + +brightmap sprite PRGRH0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRI0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRJ0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRK0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRL0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRM0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRO0 +{ + map "brightmaps/strife/prgro0.png" + iwad + disablefullbright +} + +brightmap sprite PRGRP0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRQ0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRR0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRS0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRT0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRU0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRV0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRW0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRX0 +{ + iwad + disablefullbright +} + +brightmap sprite SEWRC1 +{ + iwad + disablefullbright +} + +brightmap sprite SEWRC8C2 +{ + iwad + disablefullbright +} + +brightmap sprite SEWRC7C3 +{ + iwad + disablefullbright +} + +brightmap sprite SEWRC6C4 +{ + iwad + disablefullbright +} + +brightmap sprite SEWRC5 +{ + disablefullbright +} + +brightmap sprite SEWRE0 +{ + iwad + disablefullbright +} + +brightmap sprite SEWRF0 +{ + iwad + disablefullbright +} + +brightmap sprite SEWRG0 +{ + iwad + disablefullbright +} + +brightmap sprite sewrh0 +{ + map "brightmaps/strife/SEWRH0.png" + disablefullbright + iwad +} + +brightmap sprite STLKP0 +{ + map "brightmaps/strife/STLKP0.png" + disablefullbright + iwad +} + +brightmap sprite STLKQ0 +{ + map "brightmaps/strife/STLKQ0.png" + disablefullbright + iwad +} + +brightmap sprite STLKR0 +{ + map "brightmaps/strife/STLKR0.png" + disablefullbright + iwad +} + +brightmap sprite STLKS0 +{ + map "brightmaps/strife/STLKS0.png" + disablefullbright + iwad +} + +brightmap sprite STLKT0 +{ + map "brightmaps/strife/STLKT0.png" + disablefullbright + iwad +} + +brightmap sprite STLKU0 +{ + map "brightmaps/strife/STLKU0.png" + disablefullbright + iwad +} + +brightmap sprite STLKV0 +{ + map "brightmaps/strife/STLKV0.png" + disablefullbright + iwad +} + +brightmap sprite STLKW0 +{ + map "brightmaps/strife/STLKW0.png" + disablefullbright + iwad +} + +brightmap sprite STLKX0 +{ + map "brightmaps/strife/STLKX0.png" + disablefullbright + iwad +} + +brightmap sprite STLKY0 +{ + map "brightmaps/strife/STLKY0.png" + disablefullbright + iwad +} + +brightmap sprite STLKZ0 +{ + map "brightmaps/strife/STLKZ0.png" + disablefullbright + iwad +} + +brightmap sprite "STLK[0" +{ + map "brightmaps/strife/STLK[0.png" + disablefullbright + iwad +} + diff --git a/wadsrc_lights/CMakeLists.txt b/wadsrc_lights/CMakeLists.txt new file mode 100644 index 000000000..6bdb11e92 --- /dev/null +++ b/wadsrc_lights/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required( VERSION 2.4 ) + +add_custom_command( OUTPUT ${ZDOOM_OUTPUT_DIR}/lights.pk3 + COMMAND ${CMAKE_BINARY_DIR}/tools/zipdir/zipdir ${ZDOOM_OUTPUT_DIR}/lights.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static ${CMAKE_CURRENT_BINARY_DIR}/generated + DEPENDS zipdir ${CMAKE_CURRENT_SOURCE_DIR}/static ) + +add_custom_target( lights_pk3 ALL + DEPENDS ${ZDOOM_OUTPUT_DIR}/lights.pk3 ) + diff --git a/wadsrc_lights/lights.vcproj b/wadsrc_lights/lights.vcproj new file mode 100644 index 000000000..6f5a0e641 --- /dev/null +++ b/wadsrc_lights/lights.vcproj @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wadsrc_lights/static/doomdefs.txt b/wadsrc_lights/static/doomdefs.txt new file mode 100644 index 000000000..4e9f1e760 --- /dev/null +++ b/wadsrc_lights/static/doomdefs.txt @@ -0,0 +1,1258 @@ +// ------------------------------------------------------ +// ------------------ DOOM GAME LIGHTS ------------------ +// ------------------------------------------------------ + +// ------------------ +// -- Doom Weapons -- +// ------------------ + +// Bullet puff +flickerlight BPUFF1 +{ + color 0.5 0.5 0.0 + size 6 + secondarySize 8 + chance 0.8 +} + +flickerlight BPUFF2 +{ + color 0.5 0.5 0.0 + size 3 + secondarySize 4 + chance 0.8 +} + +object BulletPuff +{ + frame PUFFA { light BPUFF1 } + frame PUFFB { light BPUFF2 } +} + +// Rocket +pointlight ROCKET +{ + color 1.0 0.7 0.0 + size 56 +} + +flickerlight ROCKET_X1 +{ + color 1.0 0.7 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight ROCKET_X2 +{ + color 0.5 0.1 0.0 + size 80 + secondarySize 88 + chance 0.3 +} + +flickerlight ROCKET_X3 +{ + color 0.3 0.0 0.0 + size 96 + secondarySize 104 + chance 0.3 +} + +object Rocket +{ + frame MISLA { light ROCKET } + + frame MISLB { light ROCKET_X1 } + frame MISLC { light ROCKET_X2 } + frame MISLD { light ROCKET_X3 } +} + +// Plasma +pointlight PLASMABALL +{ + color 0.0 0.1 1.0 + size 56 +} + +flickerlight PLASMA_X1 +{ + color 0.2 0.2 1.0 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight PLASMA_X2 +{ + color 0.2 0.2 0.8 + size 80 + secondarySize 88 + chance 0.4 +} + +flickerlight PLASMA_X3 +{ + color 0.1 0.1 0.5 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight PLASMA_X4 +{ + color 0.0 0.0 0.2 + size 8 + secondarySize 16 + chance 0.4 +} + +object PlasmaBall +{ + frame PLSSA { light PLASMABALL } + frame PLSSB { light PLASMABALL } + + frame PLSEA { light PLASMA_X1 } + frame PLSEB { light PLASMA_X2 } + frame PLSEC { light PLASMA_X2 } + frame PLSED { light PLASMA_X3 } + frame PLSEE { light PLASMA_X4 } +} + +// Beta Plasma 1 +pointlight PLASMABALL1 +{ + color 0.1 1.0 0.0 + size 56 +} + +flickerlight PLASMA1_X1 +{ + color 0.2 1.0 0.2 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight PLASMA1_X2 +{ + color 0.2 0.8 0.2 + size 80 + secondarySize 88 + chance 0.4 +} + +flickerlight PLASMA1_X3 +{ + color 0.1 0.5 0.1 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight PLASMA1_X4 +{ + color 0.0 0.2 0.0 + size 8 + secondarySize 16 + chance 0.4 +} + +object PlasmaBall1 +{ + frame PLS1A { light PLASMABALL1 } + frame PLS1B { light PLASMABALL1 } + + frame PLS1C { light PLASMA1_X1 } + frame PLS1D { light PLASMA1_X2 } + frame PLS1E { light PLASMA1_X2 } + frame PLS1F { light PLASMA1_X3 } + frame PLS1G { light PLASMA1_X4 } +} + +// Beta Plasma 2 +pointlight PLASMABALL2 +{ + color 1.0 0.1 0.0 + size 56 +} + +flickerlight PLASMA1_X1 +{ + color 0.9 0.2 0.2 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight PLASMA1_X2 +{ + color 0.6 0.2 0.2 + size 80 + secondarySize 88 + chance 0.4 +} + +flickerlight PLASMA1_X3 +{ + color 0.2 0.0 0.0 + size 8 + secondarySize 16 + chance 0.4 +} + +object PlasmaBall2 +{ + frame PLS2A { light PLASMABALL2 } + frame PLS2B { light PLASMABALL2 } + + frame PLS2C { light PLASMA2_X1 } + frame PLS2D { light PLASMA2_X2 } + frame PLS2E { light PLASMA2_X3 } +} + +// BFG +pointlight BFGBALL +{ + color 0.0 1.0 0.0 + size 80 +} + +flickerlight BFGBALL_X1 +{ + color 0.2 1.0 0.2 + size 80 + secondarySize 88 + chance 0.3 +} + +flickerlight BFGBALL_X2 +{ + color 0.3 1.0 0.3 + size 104 + secondarySize 112 + chance 0.3 +} + +flickerlight BFGBALL_X3 +{ + color 0.5 1.0 0.5 + size 120 + secondarySize 128 + chance 0.3 +} + +flickerlight BFGBALL_X4 +{ + color 0.2 0.7 0.2 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight BFGBALL_X5 +{ + color 0.1 0.3 0.1 + size 48 + secondarySize 56 + chance 0.3 +} + +object BFGBall +{ + frame BFS1A { light BFGBALL } + frame BFS1B { light BFGBALL } + + frame BFE1A { light BFGBALL_X1 } + frame BFE1B { light BFGBALL_X2 } + frame BFE1C { light BFGBALL_X3 } + frame BFE1D { light BFGBALL_X1 } + frame BFE1E { light BFGBALL_X4 } + frame BFE1F { light BFGBALL_X5 } +} + + +object BFGExtra +{ + frame BFE2A { light BFGBALL } + frame BFE2B { light BFGBALL_X1 } + frame BFE2C { light BFGBALL_X4 } + frame BFE2D { light BFGBALL_X5 } +} + + + +// ---------------------- +// -- Doom Decorations -- +// ---------------------- + +// Barrel +pulselight BARREL +{ + color 0.0 0.5 0.0 + size 20 + secondarySize 21 + interval 0.5 + offset 0 36 0 + dontlightself 1 +} + +object ExplosiveBarrel +{ + frame BAR1 { light BARREL } + + frame BEXPC { light ROCKET_X1 } + frame BEXPD { light ROCKET_X2 } + frame BEXPE { light ROCKET_X3 } +} + +// Floor lamp +pointlight LAMP +{ + color 1.0 1.0 0.8 + size 56 + offset 0 44 0 +} + +object Column +{ + frame COLU { light LAMP } +} + +// Short tech lamp +pulselight SMALLLAMP +{ + color 0.8 0.8 1.0 + size 56 + secondarySize 58 + interval 0.4 + offset 0 44 0 +} + +object TechLamp2 +{ + frame TLP2 { light SMALLLAMP } +} + +// Tall tech lamp +pulselight BIGLAMP +{ + color 0.8 0.8 1.0 + size 64 + secondarySize 66 + interval 0.4 + offset 0 72 0 +} + +object TechLamp +{ + frame TLMP { light BIGLAMP } +} + +// Tall red torch +flickerlight2 BIGREDTORCH +{ + color 1.0 0.3 0.0 + size 64 + secondarySize 72 + interval 0.1 + offset 0 60 0 +} + +object RedTorch +{ + frame TRED { light BIGREDTORCH } +} + +// Tall green torch +flickerlight2 BIGGREENTORCH +{ + color 0.0 1.0 0.0 + size 64 + secondarySize 72 + interval 0.1 + offset 0 60 0 +} + +object GreenTorch +{ + frame TGRN { light BIGGREENTORCH } +} + +// Tall blue torch +flickerlight2 BIGBLUETORCH +{ + color 0.0 0.0 1.0 + size 64 + secondarySize 72 + interval 0.1 + offset 0 60 0 +} + +object BlueTorch +{ + frame TBLU { light BIGBLUETORCH } +} + +// Small red torch +flickerlight2 SMALLREDTORCH +{ + color 1.0 0.3 0.0 + size 48 + secondarySize 54 + interval 0.1 + offset 0 35 0 +} + +object ShortRedTorch +{ + frame SMRT { light SMALLREDTORCH } +} + +// Small green torch +flickerlight2 SMALLGREENTORCH +{ + color 0.0 1.0 0.0 + size 48 + secondarySize 54 + interval 0.1 + offset 0 35 0 +} + +object ShortGreenTorch +{ + frame SMGT { light SMALLGREENTORCH } +} + +// Small blue torch +flickerlight2 SMALLBLUETORCH +{ + color 0.0 0.0 1.0 + size 48 + secondarySize 54 + interval 0.1 + offset 0 35 0 +} + +object ShortBlueTorch +{ + frame SMBT { light SMALLBLUETORCH } +} + +// Burning barrel +flickerlight2 FIREBARREL +{ + color 1.0 0.9 0.0 + size 48 + secondarySize 54 + interval 0.1 + offset 0 32 0 +} + +object BurningBarrel +{ + frame FCAN { light FIREBARREL } +} + +// Skulls w/candles +flickerlight2 SKULLCANDLES +{ + color 1.0 1.0 0.0 + size 32 + secondarySize 34 + interval 0.1 + offset 0 24 0 +} + +object HeadCandles +{ + frame POL3 { light SKULLCANDLES } +} + +// Candle +pointlight CANDLE +{ + color 1.0 1.0 0.0 + size 16 + offset 0 16 0 +} + +object Candlestick +{ + frame CAND { light CANDLE } +} + +// Candelabra +pointlight CANDELABRA +{ + color 1.0 1.0 0.0 + size 48 + offset 0 52 0 +} + +object Candelabra +{ + frame CBRA { light CANDELABRA } +} + + + +// ---------------- +// -- Doom Items -- +// ---------------- + +// Soul Sphere +pulselight SOULSPHERE +{ + color 0.0 0.0 1.0 + size 40 + secondarySize 42 + interval 2.0 + offset 0 16 0 +} + +object SoulSphere +{ + frame SOUL { light SOULSPHERE } +} + +// Invulnerability Sphere +pulselight INVULN +{ + color 0.0 1.0 0.0 + size 40 + secondarySize 42 + interval 2.0 + offset 0 16 0 +} + +object InvulnerabilitySphere +{ + frame PINV { light INVULN } +} + +// Blur Sphere +pointlight BLURSPHERE1 +{ + color 1.0 0.0 0.0 + size 40 + offset 0 16 0 +} + +pointlight BLURSPHERE2 +{ + color 0.0 0.0 1.0 + size 32 + offset 0 16 0 +} + +pointlight BLURSPHERE3 +{ + color 0.0 0.0 1.0 + size 24 + offset 0 16 0 +} + +pointlight BLURSPHERE4 +{ + color 0.0 0.0 1.0 + size 16 + offset 0 16 0 +} + +pointlight BLURSPHERE5 +{ + color 0.0 0.0 1.0 + size 8 + offset 0 16 0 +} + +object BlurSphere +{ + frame PINS { light BLURSPHERE1 } + + frame PINSA { light BLURSPHERE2 } + frame PINSB { light BLURSPHERE3 } + frame PINSC { light BLURSPHERE4 } + frame PINSD { light BLURSPHERE5 } +} + +// Health Potion +pulselight HEALTHPOTION +{ + color 0.0 0.0 0.6 + size 16 + secondarySize 18 + interval 2.0 +} + +object HealthBonus +{ + frame BON1 { light HEALTHPOTION } +} + +// Armour Helmet +pulselight ARMORBONUS +{ + color 0.0 0.6 0.0 + size 16 + secondarySize 14 + interval 1.0 + dontlightself 1 +} + +object ArmorBonus +{ + frame BON2 { light ARMORBONUS } +} + +// Blue Keys +object BlueCard +{ + frame BKEY { light HEALTHPOTION } +} + +object BlueSkull +{ + frame BSKU { light HEALTHPOTION } +} + +// Yellow Keys +pulselight YELLOWKEY +{ + color 0.6 0.6 0.0 + size 16 + secondarySize 18 + interval 2.0 +} + +object YellowCard +{ + frame YKEY { light YELLOWKEY } +} + +object YellowSkull +{ + frame YSKU { light YELLOWKEY } +} + +// Red Keys +pulselight REDKEY +{ + color 0.6 0.0 0.0 + size 16 + secondarySize 18 + interval 2.0 +} + +object RedCard +{ + frame RKEY { light REDKEY } +} + +object RedSkull +{ + frame RSKU { light REDKEY } +} + +// Green armour +pointlight GREENARMOR1 +{ + color 0.0 0.6 0.0 + size 48 +} + +pointlight GREENARMOR2 +{ + color 0.0 0.6 0.0 + size 32 +} + +object GreenArmor +{ + frame ARM1A { light GREENARMOR1 } + frame ARM1B { light GREENARMOR2 } +} + +// Blue armour +pointlight BLUEARMOR1 +{ + color 0.0 0.0 0.6 + size 48 +} + +pointlight BLUEARMOR2 +{ + color 0.0 0.0 0.6 + size 32 +} + +object BlueArmor +{ + frame ARM2A { light BLUEARMOR1 } + frame ARM2B { light BLUEARMOR2 } +} + + + +// ------------------ +// -- Doom Enemies -- +// ------------------ + +// Zombies +flickerlight2 ZOMBIEATK +{ + color 1.0 0.8 0.2 + size 48 + secondarySize 56 + interval 1 + offset 0 40 0 +} + +object ZombieMan +{ + frame POSSF { light ZOMBIEATK } +} + +object ShotgunGuy +{ + frame SPOSF { light ZOMBIEATK } +} + +object ChaingunGuy +{ + frame CPOSE { light ZOMBIEATK } + frame CPOSF { light ZOMBIEATK } +} + +object DoomPlayer +{ + frame PLAYF { light ZOMBIEATK } +} + + +// Doom Imp Fireball +pointlight IMPBALL +{ + color 1.0 0.5 0.0 + size 64 +} + +// Doom imp fireball explosion +flickerlight IMPBALL_X1 +{ + color 0.7 0.2 0.0 + size 80 + secondarySize 88 + chance 0.25 +} + +flickerlight IMPBALL_X2 +{ + color 0.4 0.0 0.0 + size 96 + secondarySize 104 + chance 0.25 +} + +flickerlight IMPBALL_X3 +{ + color 0.2 0.0 0.0 + size 112 + secondarySize 120 + chance 0.25 +} + +object DoomImpBall +{ + frame BAL1A { light IMPBALL } + frame BAL1B { light IMPBALL } + + frame BAL1C { light IMPBALL_X1 } + frame BAL1D { light IMPBALL_X2 } + frame BAL1E { light IMPBALL_X3 } +} + +pointlight SPECTRE +{ + color 0.5 0.5 0.5 + size 48 + offset 0 24 0 + subtractive 1 +} + +/* +object Spectre +{ + frame SARG { light SPECTRE } +} +*/ + +// Cacodemon fireball +flickerlight CACOBALL +{ + color 1.0 0.2 0.6 + size 56 + secondarySize 64 + chance 0.5 +} + +flickerlight CACOBALL_X1 +{ + color 0.9 0.1 0.4 + size 72 + secondarySize 80 + chance 0.25 +} + +flickerlight CACOBALL_X2 +{ + color 0.6 0.0 0.1 + size 88 + secondarySize 96 + chance 0.25 +} + +flickerlight CACOBALL_X3 +{ + color 0.3 0.0 0.0 + size 104 + secondarySize 112 + chance 0.25 +} + +object CacodemonBall +{ + frame BAL2A { light CACOBALL } + frame BAL2B { light CACOBALL } + + frame BAL2C { light CACOBALL_X1 } + frame BAL2D { light CACOBALL_X2 } + frame BAL2E { light CACOBALL_X3 } +} + +// Baron / Hell Knight fireball +pointlight BARONBALL +{ + color 0.0 1.0 0.0 + size 64 +} + +flickerlight BARONBALL_X1 +{ + color 0.0 0.7 0.0 + size 80 + secondarySize 88 + chance 0.25 +} + +flickerlight BARONBALL_X2 +{ + color 0.0 0.4 0.0 + size 96 + secondarySize 104 + chance 0.25 +} + +flickerlight BARONBALL_X3 +{ + color 0.0 0.2 0.0 + size 112 + secondarySize 120 + chance 0.25 +} + +object BaronBall +{ + frame BAL7A { light BARONBALL } + frame BAL7B { light BARONBALL } + + frame BAL7C { light BARONBALL_X1 } + frame BAL7D { light BARONBALL_X2 } + frame BAL7E { light BARONBALL_X3 } +} + +// Lost Soul +flickerlight LOSTSOUL +{ + color 1.0 0.3 0.0 + size 56 + secondarysize 64 + chance 0.1 +} + +flickerlight LOSTSOUL_X1 +{ + color 0.8 0.3 0.0 + size 72 + secondarySize 80 + chance 0.25 +} + +flickerlight LOSTSOUL_X2 +{ + color 0.6 0.2 0.0 + size 88 + secondarySize 96 + chance 0.25 +} + +flickerlight LOSTSOUL_X3 +{ + color 0.4 0.1 0.0 + size 104 + secondarySize 112 + chance 0.25 +} + +flickerlight LOSTSOUL_X4 +{ + color 0.2 0.0 0.0 + size 112 + secondarySize 120 + chance 0.25 +} + +object LostSoul +{ + frame SKULA { light LOSTSOUL } + frame SKULB { light LOSTSOUL } + frame SKULC { light LOSTSOUL } + frame SKULD { light LOSTSOUL } + frame SKULE { light LOSTSOUL } + frame SKULF { light LOSTSOUL } + frame SKULG { light LOSTSOUL } + + frame SKULH { light LOSTSOUL_X1 } + frame SKULI { light LOSTSOUL_X2 } + frame SKULJ { light LOSTSOUL_X3 } + frame SKULK { light LOSTSOUL_X4 } +} + +// Mancubus Fireball +object FatShot +{ + frame MANFA { light IMPBALL } + frame MANFB { light IMPBALL } + + frame MISLB { light ROCKET_X1 } + frame MISLC { light ROCKET_X2 } + frame MISLD { light ROCKET_X3 } +} + +// Arachnotron Fireball +pointlight ARACHPLAS +{ + color 0.6 1.0 0.0 + size 56 +} + +flickerlight ARACHPLAS_X1 +{ + color 0.4 0.8 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight ARACHPLAS_X2 +{ + color 0.6 0.6 0.0 + size 88 + secondarySize 96 + chance 0.3 +} + +flickerlight ARACHPLAS_X3 +{ + color 0.4 0.4 0.0 + size 48 + secondarySize 32 + chance 0.3 +} + +flickerlight ARACHPLAS_X4 +{ + color 0.2 0.2 0.0 + size 24 + secondarySize 16 + chance 0.3 +} + +object ArachnotronPlasma +{ + frame APLSA { light ARACHPLAS } + frame APLSB { light ARACHPLAS } + + frame APBXA { light ARACHPLAS_X1 } + frame APBXB { light ARACHPLAS_X2 } + frame APBXC { light ARACHPLAS_X2 } + frame APBXD { light ARACHPLAS_X3 } + frame APBXE { light ARACHPLAS_X4 } +} + +// Revenant tracer +pointlight TRACER +{ + color 1.0 0.3 0.0 + size 48 +} + +flickerlight TRACER_X1 +{ + color 1.0 0.2 0.0 + size 64 + secondarySize 72 + chance 0.25 +} + +flickerlight TRACER_X2 +{ + color 0.6 0.0 0.0 + size 80 + secondarySize 88 + chance 0.25 +} + +flickerlight TRACER_X3 +{ + color 0.3 0.0 0.0 + size 96 + secondarySize 104 + chance 0.25 +} + +object RevenantTracer +{ + frame FATBA { light TRACER } + frame FATBB { light TRACER } + + frame FBXPA { light TRACER_X1 } + frame FBXPB { light TRACER_X2 } + frame FBXPC { light TRACER_X3 } +} + +// Arch Vile Fire +flickerlight ARCHFIRE1 +{ + color 1.0 1.0 0.0 + size 24 + secondarySize 32 + chance 0.3 + offset 0 8 0 +} + +flickerlight ARCHFIRE2 +{ + color 1.0 1.0 0.0 + size 40 + secondarySize 48 + chance 0.3 + offset 0 24 0 +} + +flickerlight ARCHFIRE3 +{ + color 1.0 1.0 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 32 0 +} + +flickerlight ARCHFIRE4 +{ + color 0.8 0.8 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 40 0 +} + +flickerlight ARCHFIRE5 +{ + color 0.8 0.8 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 48 0 +} + +flickerlight ARCHFIRE6 +{ + color 0.6 0.6 0.0 + size 48 + secondarySize 56 + chance 0.3 + offset 0 64 0 +} + +flickerlight ARCHFIRE7 +{ + color 0.4 0.4 0.0 + size 32 + secondarySize 40 + chance 0.3 + offset 0 72 0 +} + +flickerlight ARCHFIRE8 +{ + color 0.2 0.2 0.0 + size 16 + secondarySize 24 + chance 0.3 + offset 0 80 0 +} + +object ArchvileFire +{ + frame FIREA { light ARCHFIRE1 } + frame FIREB { light ARCHFIRE2 } + frame FIREC { light ARCHFIRE3 } + frame FIRED { light ARCHFIRE4 } + frame FIREE { light ARCHFIRE5 } + frame FIREF { light ARCHFIRE6 } + frame FIREG { light ARCHFIRE7 } + frame FIREH { light ARCHFIRE8 } +} + +// Arch-vile +flickerlight ARCHATK1 +{ + color 1.0 1.0 0.0 + size 32 + secondarySize 48 + chance 0.3 + offset 0 80 0 +} + +flickerlight ARCHATK2 +{ + color 1.0 1.0 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 80 0 +} + +flickerlight ARCHATK3 +{ + color 1.0 1.0 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 64 0 +} + +flickerlight ARCHATK4 +{ + color 1.0 1.0 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 48 0 +} + +flickerlight ARCHATK5 +{ + color 1.0 1.0 0.0 + size 80 + secondarySize 88 + chance 0.3 + offset 0 40 0 +} + +flickerlight ARCHATK6 +{ + color 0.7 0.7 0.0 + size 96 + secondarySize 104 + chance 0.3 + offset 0 40 0 +} + +flickerlight ARCHATK7 +{ + color 0.3 0.3 0.0 + size 104 + secondarySize 112 + chance 0.3 + offset 0 40 0 +} + +pulselight ARCHRES +{ + color 0.6 0.0 0.0 + size 64 + secondarySize 70 + interval 0.5 + offset 0 36 0 +} + +object Archvile +{ + frame VILEH { light ARCHATK1 } + frame VILEI { light ARCHATK2 } + frame VILEJ { light ARCHATK3 } + frame VILEK { light ARCHATK4 } + frame VILEL { light ARCHATK4 } + frame VILEM { light ARCHATK4 } + frame VILEN { light ARCHATK5 } + frame VILEO { light ARCHATK6 } + frame VILEP { light ARCHATK7 } + + frame VILE[ { light ARCHRES } + frame VILE\ { light ARCHRES } + frame VILE] { light ARCHRES } +} + +// ------------------ +// -- Doom Effects -- +// ------------------ + +// Doom Teleport fog +flickerlight DTFOG1 +{ + color 0.4 1.0 0.4 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight DTFOG2 +{ + color 0.4 1.0 0.4 + size 40 + secondarySize 48 + chance 0.4 +} + +flickerlight DTFOG3 +{ + color 0.4 1.0 0.4 + size 24 + secondarySize 32 + chance 0.4 +} + +flickerlight DTFOG4 +{ + color 0.4 1.0 0.4 + size 10 + secondarySize 16 + chance 0.4 +} + +object TeleportFog +{ + frame TFOGA { light DTFOG1 } + frame TFOGB { light DTFOG2 } + frame TFOGC { light DTFOG2 } + frame TFOGD { light DTFOG2 } + frame TFOGE { light DTFOG3 } + frame TFOGF { light DTFOG4 } + frame TFOGI { light DTFOG4 } + frame TFOGJ { light DTFOG3 } +} diff --git a/wadsrc_lights/static/hexndefs.txt b/wadsrc_lights/static/hexndefs.txt new file mode 100644 index 000000000..e7f53e74c --- /dev/null +++ b/wadsrc_lights/static/hexndefs.txt @@ -0,0 +1,1593 @@ +// ------------------------------------------------------ +// ----------------- HEXEN GAME LIGHTS ------------------ +// ------------------------------------------------------ + +// ------------------- +// -- Hexen Weapons -- +// ------------------- + +// Charged Axe Puff +flickerlight CAXEPUFF1 +{ + color 0.4 0.4 1.0 + size 40 + secondarySize 44 + chance 0.5 +} + +flickerlight CAXEPUFF2 +{ + color 0.2 0.2 0.8 + size 48 + secondarySize 52 + chance 0.5 +} + +flickerlight CAXEPUFF3 +{ + color 0.0 0.0 0.5 + size 44 + secondarySize 48 + chance 0.5 +} + +object AxePuffGlow +{ + frame FAXER { light CAXEPUFF1 } + frame FAXES { light CAXEPUFF1 } + frame FAXET { light CAXEPUFF2 } + frame FAXEU { light CAXEPUFF2 } + frame FAXEV { light CAXEPUFF3 } + frame FAXEW { light CAXEPUFF3 } + frame FAXEX { light CAXEPUFF3 } +} + +// Flying Hammer +flickerlight THROWHAMMER +{ + color 1.0 0.2 0.0 + size 48 + secondarySize 52 + chance 0.4 +} + +flickerlight THROWHAMMER_X1 +{ + color 1.0 0.7 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +flickerlight THROWHAMMER_X2 +{ + color 1.0 0.7 0.0 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight THROWHAMMER_X3 +{ + color 1.0 0.7 0.0 + size 72 + secondarySize 80 + chance 0.4 +} + +flickerlight THROWHAMMER_X4 +{ + color 0.8 0.8 0.0 + size 80 + secondarySize 84 + chance 0.4 +} + +flickerlight THROWHAMMER_X5 +{ + color 0.5 0.5 0.0 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight THROWHAMMER_X6 +{ + color 0.2 0.2 0.0 + size 40 + secondarySize 48 + chance 0.4 +} + +object HammerMissile +{ + frame FHFXA { light THROWHAMMER } + frame FHFXB { light THROWHAMMER } + frame FHFXC { light THROWHAMMER } + frame FHFXD { light THROWHAMMER } + frame FHFXE { light THROWHAMMER } + frame FHFXF { light THROWHAMMER } + frame FHFXG { light THROWHAMMER } + frame FHFXH { light THROWHAMMER } + + frame FHFXI { light THROWHAMMER_X1 } + frame FHFXJ { light THROWHAMMER_X2 } + frame FHFXK { light THROWHAMMER_X3 } + frame FHFXL { light THROWHAMMER_X4 } + frame FHFXM { light THROWHAMMER_X4 } + frame FHFXN { light THROWHAMMER_X4 } + frame FHFXO { light THROWHAMMER_X4 } + frame FHFXP { light THROWHAMMER_X4 } + frame FHFXQ { light THROWHAMMER_X5 } + frame FHFXR { light THROWHAMMER_X6 } +} + +// Fighter sword shot +flickerlight SWORDSHOT +{ + color 0.0 1.0 0.0 + size 48 + secondarySize 44 + chance 0.4 +} + +flickerlight SWORDSHOT_X1 +{ + color 0.0 1.0 0.0 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight SWORDSHOT_X2 +{ + color 0.0 1.0 0.0 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight SWORDSHOT_X3 +{ + color 0.0 0.7 0.0 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight SWORDSHOT_X4 +{ + color 0.0 0.4 0.0 + size 40 + secondarySize 48 + chance 0.4 +} + +flickerlight SWORDSHOT_X5 +{ + color 0.0 0.2 0.0 + size 32 + secondarySize 40 + chance 0.4 +} + +object FSwordMissile +{ + frame FSFXA { light SWORDSHOT } + frame FSFXB { light SWORDSHOT } + frame FSFXC { light SWORDSHOT } + + frame FSFXD { light SWORDSHOT_X1 } + frame FSFXE { light SWORDSHOT_X2 } + frame FSFXF { light SWORDSHOT_X2 } + frame FSFXG { light SWORDSHOT_X2 } + frame FSFXH { light SWORDSHOT_X3 } + frame FSFXI { light SWORDSHOT_X3 } + frame FSFXJ { light SWORDSHOT_X4 } + frame FSFXK { light SWORDSHOT_X5 } + frame FSFXL { light SWORDSHOT_X5 } +} + +// Cleric Serpent Staff ball +pointlight CSTAFFBALL +{ + color 0.0 1.0 0.0 + size 40 +} + +flickerlight CSTAFFBALL_X1 +{ + color 0.0 1.0 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight CSTAFFBALL_X2 +{ + color 0.0 0.7 0.0 + size 60 + secondarySize 68 + chance 0.3 +} + +flickerlight CSTAFFBALL_X3 +{ + color 0.0 0.5 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight CSTAFFBALL_X4 +{ + color 0.0 0.3 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +object CStaffMissile +{ + frame CSSFD { light CSTAFFBALL } + frame CSSFE { light CSTAFFBALL } + + frame CSSFF { light CSTAFFBALL_X1 } + frame CSSFG { light CSTAFFBALL_X2 } + frame CSSFH { light CSTAFFBALL_X3 } + frame CSSFI { light CSTAFFBALL_X4 } +} + +// Cleric fire hands +flickerlight CFLAMETRAIL +{ + color 1.0 0.8 0.0 + size 40 + secondarySize 44 + chance 0.5 +} + +flickerlight CFLAME1 +{ + color 1.0 0.8 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +flickerlight CFLAME2 +{ + color 1.0 0.8 0.0 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight CFLAME3 +{ + color 0.7 0.4 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +flickerlight CFLAME4 +{ + color 0.5 0.2 0.0 + size 32 + secondarySize 40 + chance 0.4 +} + +flickerlight CFLAME5 +{ + color 0.2 0.2 0.0 + size 24 + secondarySize 32 + chance 0.4 +} + +object FlamePuff2 +{ + frame CFFXB { light CFLAME1 } + frame CFFXC { light CFLAME2 } + frame CFFXD { light CFLAME2 } + frame CFFXE { light CFLAME2 } + frame CFFXF { light CFLAME2 } + frame CFFXG { light CFLAME2 } + frame CFFXH { light CFLAME2 } + frame CFFXI { light CFLAME2 } + frame CFFXJ { light CFLAME3 } + frame CFFXK { light CFLAME4 } + frame CFFXL { light CFLAME5 } +} + +object CFlameFloor +{ + frame CFFX { light CFLAMETRAIL } +} + +// Wraithverge +flickerlight GHOST +{ + color 1.0 1.0 1.0 + size 56 + secondarySize 52 + chance 0.7 + subtractive 1 +} + +object HolyMissile +{ + frame SPIRP { light GHOST } +} + +object HolySpirit +{ + frame SPIRA { light GHOST } + frame SPIRB { light GHOST } +} + +// Mage wand +pointlight MWAND_X1 +{ + color 0.3 0.3 1.0 + size 32 +} + +pointlight MWAND_X2 +{ + color 0.2 0.2 0.8 + size 40 +} + +pointlight MWAND_X3 +{ + color 0.1 0.1 0.6 + size 48 +} + +pointlight MWAND_X4 +{ + color 0.0 0.0 0.4 + size 56 +} + +object MageWandMissile +{ + frame MWNDE { light MWAND_X1 } + frame MWNDF { light MWAND_X2 } + frame MWNDG { light MWAND_X3 } + frame MWNDH { light MWAND_X4 } +} + +// Frost shards +flickerlight MFROSTSHARD +{ + color 0.3 0.3 1.0 + size 32 + secondarySize 40 + chance 0.3 +} + +flickerlight MFROSTSHARD_X1 +{ + color 0.3 0.3 1.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight MFROSTSHARD_X2 +{ + color 0.2 0.2 0.8 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight MFROSTSHARD_X3 +{ + color 0.1 0.1 0.5 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight MFROSTSHARD_X4 +{ + color 0.0 0.0 0.2 + size 64 + secondarySize 68 + chance 0.3 +} + +object FrostMissile +{ + frame SHRD { light MFROSTSHARD } + + frame SHEXA { light MFROSTSHARD_X1 } + frame SHEXB { light MFROSTSHARD_X2 } + frame SHEXC { light MFROSTSHARD_X3 } + frame SHEXD { light MFROSTSHARD_X4 } +} + +// Mage lightning +flickerlight MAGELIGHT +{ + color 0.4 0.4 1.0 + size 48 + secondarySize 52 + chance 0.7 +} + +object LightningCeiling +{ + frame MLFX { light MAGELIGHT } + frame MLF2 { light MAGELIGHT } +} + +object LightningFloor +{ + frame MLFX { light MAGELIGHT } + frame MLF2 { light MAGELIGHT } +} + +object LightningZap +{ + frame MLFX { light MAGELIGHT } + frame MLF2 { light MAGELIGHT } +} + +// BloodScourge +flickerlight BSBALL +{ + color 1.0 0.2 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight BSBALL_X1 +{ + color 1.0 0.4 0.0 + size 24 + secondarySize 28 + chance 0.3 +} + +flickerlight BSBALL_X2 +{ + color 0.7 0.3 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight BSBALL_X3 +{ + color 0.5 0.2 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight BSBALL_X4 +{ + color 0.3 0.1 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +object MageStaffFX2 +{ + frame MSP2A { light BSBALL } + frame MSP2B { light BSBALL } + frame MSP2C { light BSBALL } + frame MSP2D { light BSBALL } + + frame MSP2E { light BSBALL_X1 } + frame MSP2F { light BSBALL_X2 } + frame MSP2G { light BSBALL_X3 } + frame MSP2H { light BSBALL_X4 } +} + +// ------------------- +// -- Hexen Weapons -- +// ------------------- + +// Stalker slimeball +pointlight STALKERSLIME +{ + color 0.0 1.0 0.0 + size 40 +} + +flickerlight STALKERSLIME_X1 +{ + color 0.0 1.0 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +flickerlight STALKERSLIME_X2 +{ + color 0.0 0.7 0.0 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight STALKERSLIME_X3 +{ + color 0.0 0.5 0.0 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight STALKERSLIME_X4 +{ + color 0.0 0.2 0.0 + size 68 + secondarySize 76 + chance 0.4 +} + +object SerpentFX +{ + frame SSFXA { light STALKERSLIME } + frame SSFXB { light STALKERSLIME } + + frame SSFXC { light STALKERSLIME_X1 } + frame SSFXD { light STALKERSLIME_X2 } + frame SSFXE { light STALKERSLIME_X3 } + frame SSFXF { light STALKERSLIME_X3 } + frame SSFXG { light STALKERSLIME_X4 } + frame SSFXH { light STALKERSLIME_X4 } +} + +// Centaur fireball +pointlight TAURBALL +{ + color 0.2 0.2 1.0 + size 48 +} + +flickerlight TAURBALL_X1 +{ + color 0.2 0.2 1.0 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight TAURBALL_X2 +{ + color 0.2 0.2 0.7 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight TAURBALL_X3 +{ + color 0.1 0.1 0.5 + size 72 + secondarySize 80 + chance 0.4 +} + +flickerlight TAURBALL_X4 +{ + color 0.0 0.0 0.3 + size 80 + secondarySize 88 + chance 0.4 +} + +object CentaurFX +{ + frame CTFXA { light TAURBALL } + + frame CTFXB { light TAURBALL_X1 } + frame CTFXC { light TAURBALL_X2 } + frame CTFXD { light TAURBALL_X3 } + frame CTFXE { light TAURBALL_X4 } + frame CTFXF { light TAURBALL_X4 } +} + +// Green Chaos Serpent fireball +flickerlight SERPENTBALL +{ + color 1.0 0.95 0.0 + size 56 + secondarySize 64 + chance 0.5 +} + +flickerlight SERPENTBALL_X1 +{ + color 1.0 0.95 0.0 + size 64 + secondarySize 72 + chance 0.5 +} + +flickerlight SERPENTBALL_X2 +{ + color 0.8 0.8 0.0 + size 72 + secondarySize 80 + chance 0.5 +} + +flickerlight SERPENTBALL_X3 +{ + color 0.5 0.5 0.0 + size 88 + secondarySize 96 + chance 0.5 +} + +flickerlight SERPENTBALL_X4 +{ + color 0.2 0.2 0.0 + size 96 + secondarySize 104 + chance 0.5 +} + +object Demon1FX1 +{ + frame DMFXA { light SERPENTBALL } + frame DMFXB { light SERPENTBALL } + frame DMFXC { light SERPENTBALL } + + frame DMFXD { light SERPENTBALL_X1 } + frame DMFXE { light SERPENTBALL_X2 } + frame DMFXF { light SERPENTBALL_X3 } + frame DMFXG { light SERPENTBALL_X4 } + frame DMFXH { light SERPENTBALL_X4 } +} + +// Brown Chaos Serpent gasball +pointlight CSGASBALL +{ + color 0.0 1.0 0.0 + size 48 +} + +flickerlight CSGASBALL_X1 +{ + color 0.0 1.0 0.0 + size 64 + secondarySize 72 + chance 0.5 +} + +flickerlight CSGASBALL_X2 +{ + color 0.0 0.8 0.0 + size 72 + secondarySize 80 + chance 0.5 +} + +flickerlight CSGASBALL_X3 +{ + color 0.0 0.5 0.0 + size 88 + secondarySize 96 + chance 0.5 +} + +flickerlight CSGASBALL_X4 +{ + color 0.0 0.2 0.0 + size 96 + secondarySize 104 + chance 0.5 +} + +object Demon2FX1 +{ + frame D2FXA { light CSGASBALL } + frame D2FXB { light CSGASBALL } + frame D2FXC { light CSGASBALL } + frame D2FXD { light CSGASBALL } + frame D2FXE { light CSGASBALL } + frame D2FXF { light CSGASBALL } + + frame D2FXG { light CSGASBALL_X1 } + frame D2FXH { light CSGASBALL_X2 } + frame D2FXI { light CSGASBALL_X2 } + frame D2FXJ { light CSGASBALL_X3 } + frame D2FXK { light CSGASBALL_X4 } + frame D2FXL { light CSGASBALL_X4 } +} + +// Reaver fireball +pointlight REAVERBALL +{ + color 1.0 0.5 0.0 + size 48 +} + +flickerlight REAVERBALL_X1 +{ + color 1.0 0.7 0.0 + size 64 + secondarySize 72 +} + +flickerlight REAVERBALL_X2 +{ + color 0.6 0.2 0.0 + size 60 + secondarySize 68 +} + +flickerlight REAVERBALL_X3 +{ + color 0.2 0.0 0.0 + size 56 + secondarySize 64 +} + +object WraithFX1 +{ + frame WRBLA { light REAVERBALL } + frame WRBLB { light REAVERBALL } + frame WRBLC { light REAVERBALL } + + frame WRBLD { light REAVERBALL_X1 } + frame WRBLE { light REAVERBALL_X2 } + frame WRBLF { light REAVERBALL_X3 } +} + +// Dragon Fireball +flickerlight DRAGONBALL +{ + color 1.0 1.0 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +object DragonFireball +{ + frame DRFXA { light DRAGONBALL } + frame DRFXB { light DRAGONBALL } + frame DRFXC { light DRAGONBALL } + frame DRFXD { light DRAGONBALL } + frame DRFXE { light DRAGONBALL } + frame DRFXF { light DRAGONBALL } + + frame DRFXG { light DRAGONBALL_X1 } + frame DRFXH { light DRAGONBALL_X2 } + frame DRFXI { light DRAGONBALL_X2 } + frame DRFXJ { light DRAGONBALL_X3 } + frame DRFXK { light DRAGONBALL_X4 } +} + +flickerlight DRAGONBALL_X1 +{ + color 0.8 0.8 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight DRAGONBALL_X2 +{ + color 0.6 0.6 0.0 + size 96 + secondarySize 104 + chance 0.3 +} + +flickerlight DRAGONBALL_X3 +{ + color 0.4 0.4 0.0 + size 88 + secondarySize 96 + chance 0.3 +} + +flickerlight DRAGONBALL_X4 +{ + color 0.2 0.2 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +object DragonExplosion +{ + frame CFCFQ { light DRAGONBALL_X1 } + frame CFCFR { light DRAGONBALL_X2 } + frame CFCFS { light DRAGONBALL_X2 } + frame CFCFT { light DRAGONBALL_X2 } + frame CFCFU { light DRAGONBALL_X3 } + frame CFCFV { light DRAGONBALL_X3 } + frame CFCFW { light DRAGONBALL_X4 } +} + +// Bishop fireball +pointlight BISHOPBALL +{ + color 0.6 1.0 0.0 + size 48 +} + +flickerlight BISHOPBALL_X1 +{ + color 0.6 1.0 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight BISHOPBALL_X2 +{ + color 0.2 0.8 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight BISHOPBALL_X3 +{ + color 0.1 0.5 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight BISHOPBALL_X4 +{ + color 0.0 0.3 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +object BishopFX +{ + frame BPFXA { light BISHOPBALL } + frame BPFXB { light BISHOPBALL } + + frame BPFXC { light BISHOPBALL_X1 } + frame BPFXD { light BISHOPBALL_X2 } + frame BPFXE { light BISHOPBALL_X2 } + frame BPFXF { light BISHOPBALL_X3 } + frame BPFXG { light BISHOPBALL_X3 } + frame BPFXH { light BISHOPBALL_X4 } +} + +// Fire gargoyle +flickerlight FGARG +{ + color 1.0 1.0 0.0 + size 40 + secondarySize 48 + chance 0.4 +} + +flickerlight FGARGATK +{ + color 1.0 1.0 0.0 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight FGARGBALL_X1 +{ + color 0.8 0.8 0.0 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight FGARGBALL_X2 +{ + color 0.5 0.5 0.0 + size 50 + secondarySize 54 + chance 0.4 +} + +flickerlight FGARGBALL_X3 +{ + color 0.2 0.2 0.0 + size 44 + secondarySize 48 + chance 0.4 +} + +object FireDemon +{ + frame FDMNA { light FGARG } + frame FDMNB { light FGARG } + frame FDMNC { light FGARG } + frame FDMND { light FGARG } + frame FDMNH { light FGARG } + frame FDMNI { light FGARG } + frame FDMNJ { light FGARG } + + frame FDMNK { light FGARGATK } +} + +object FireDemonMissile +{ + frame FDMBA { light FGARG } + + frame FDMBB { light FGARGBALL_X1 } + frame FDMBC { light FGARGBALL_X2 } + frame FDMBD { light FGARGBALL_X3 } +} + +// Wendigo +pointlight ICEGUYATK +{ + color 0.3 0.3 1.0 + size 64 +} + +pointlight ICEBALL +{ + color 0.3 0.3 1.0 + size 56 +} + +flickerlight ICEBALL_X1 +{ + color 0.3 0.3 1.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight ICEBALL_X2 +{ + color 0.3 0.3 0.7 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight ICEBALL_X3 +{ + color 0.2 0.2 0.4 + size 72 + secondarySize 74 + chance 0.3 +} + +flickerlight ICEBALL_X4 +{ + color 0.0 0.0 0.2 + size 74 + secondarySize 80 + chance 0.3 +} + +pointlight ICESHARD +{ + color 0.3 0.3 1.0 + size 40 +} + +object IceGuyFX +{ + frame ICPRA { light ICEBALL } + frame ICPRB { light ICEBALL } + frame ICPRC { light ICEBALL } + + frame ICPRD { light ICEBALL_X1 } + frame ICPRE { light ICEBALL_X2 } + frame ICPRF { light ICEBALL_X3 } + frame ICPRG { light ICEBALL_X4 } +} + +object IceGuyFX2 +{ + frame ICPRN { light ICESHARD } + frame ICPRO { light ICESHARD } + frame ICPRP { light ICESHARD } +} + +object IceGuy +{ + frame ICEYG { light ICEGUYATK } +} + +// Heresiarch +flickerlight HARCHATK +{ + color 1.0 0.0 1.0 + size 64 + secondarySize 72 + chance 0.4 +} + +pointlight HARCHBLUCUBE +{ + color 0.0 0.0 1.0 + size 32 +} + +pointlight HARCHGRNCUBE +{ + color 0.0 1.0 0.0 + size 32 +} + +pointlight HARCHPURCUBE +{ + color 1.0 0.0 1.0 + size 32 +} + +flickerlight HARCHBALL_X1 +{ + color 0.8 0.0 0.8 + size 48 + secondarySize 56 + chance 0.4 +} + +flickerlight HARCHBALL_X2 +{ + color 0.5 0.0 0.5 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight HARCHBALL_X3 +{ + color 0.2 0.0 0.2 + size 72 + secondarySize 76 + chance 0.4 +} + +flickerlight HARCHBALL2_X1 +{ + color 0.0 0.8 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +flickerlight HARCHBALL2_X2 +{ + color 0.0 0.5 0.0 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight HARCHBALL2_X3 +{ + color 0.0 0.2 0.0 + size 72 + secondarySize 76 + chance 0.4 +} + +flickerlight HARCHHEAD +{ + color 1.0 0.5 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +object SorcFX1 +{ + frame SBS1 { light HARCHHEAD } +} + +object SorcFX2 +{ + frame SBS2 { light HARCHPURCUBE } +} + +object SorcFX3 +{ + frame SBS3A { light HARCHGRNCUBE } + frame SBS3B { light HARCHGRNCUBE } + + frame SBS3C { light HARCHBALL2_X1 } + frame SBS3D { light HARCHBALL2_X2 } + frame SBS3E { light HARCHBALL2_X3 } +} + +object SorcFX4 +{ + frame SBS4A { light HARCHPURCUBE } + frame SBS4B { light HARCHPURCUBE } + + frame SBS4C { light HARCHBALL_X1 } + frame SBS4D { light HARCHBALL_X2 } + frame SBS4E { light HARCHBALL_X3 } +} + +object SorcBall1 +{ + frame SBMP { light HARCHPURCUBE } +} + +object SorcBall2 +{ + frame SBMB { light HARCHBLUCUBE } +} + +object SorcBall3 +{ + frame SBMG { light HARCHGRNCUBE } +} + +object Heresiarch +{ + frame SORCE { light HARCHATK } + frame SORCF { light HARCHATK } +} + +// Korax +object Korax +{ + frame KORXF { light HARCHATK } + frame KORXG { light HARCHATK } +} + +// ----------------------- +// -- Hexen Decorations -- +// ----------------------- + +// Candles +flickerlight2 HCANDLES +{ + color 1.0 1.0 0.0 + size 16 + secondarySize 20 + interval 0.1 +} + +object ZCandle +{ + frame CNDL { light HCANDLES } +} + +// Twined torch +flickerlight2 TWINETORCH +{ + color 1.0 0.7 0.0 + size 46 + secondarySize 52 + interval 0.1 + offset 0 64 0 +} + +object ZTwinedTorch +{ + frame TWTRA { light TWINETORCH } + frame TWTRB { light TWINETORCH } + frame TWTRC { light TWINETORCH } + frame TWTRD { light TWINETORCH } + frame TWTRE { light TWINETORCH } + frame TWTRF { light TWINETORCH } + frame TWTRG { light TWINETORCH } + frame TWTRH { light TWINETORCH } +} + +object ZTwinedTorchUnlit +{ + frame TWTRA { light TWINETORCH } + frame TWTRB { light TWINETORCH } + frame TWTRC { light TWINETORCH } + frame TWTRD { light TWINETORCH } + frame TWTRE { light TWINETORCH } + frame TWTRF { light TWINETORCH } + frame TWTRG { light TWINETORCH } + frame TWTRH { light TWINETORCH } +} + + +// Wall torch +flickerlight2 WALLTORCH2 +{ + color 1.0 0.7 0.0 + size 24 + secondarySize 28 + interval 0.1 + offset 0 24 0 +} + +object ZWallTorch +{ + frame WLTRA { light WALLTORCH2 } + frame WLTRB { light WALLTORCH2 } + frame WLTRC { light WALLTORCH2 } + frame WLTRD { light WALLTORCH2 } + frame WLTRE { light WALLTORCH2 } + frame WLTRF { light WALLTORCH2 } + frame WLTRG { light WALLTORCH2 } + frame WLTRH { light WALLTORCH2 } +} + + +object ZWallTorchUnlit +{ + frame WLTRA { light WALLTORCH2 } + frame WLTRB { light WALLTORCH2 } + frame WLTRC { light WALLTORCH2 } + frame WLTRD { light WALLTORCH2 } + frame WLTRE { light WALLTORCH2 } + frame WLTRF { light WALLTORCH2 } + frame WLTRG { light WALLTORCH2 } + frame WLTRH { light WALLTORCH2 } +} + + +// Fire bull +flickerlight2 FIREBULL +{ + color 1.0 0.7 0.0 + size 64 + secondarySize 70 + interval 0.1 + offset 0 40 0 +} + +object ZFireBull +{ + frame FBULA { light FIREBULL } + frame FBULB { light FIREBULL } + frame FBULC { light FIREBULL } + frame FBULD { light FIREBULL } + frame FBULE { light FIREBULL } + frame FBULF { light FIREBULL } + frame FBULG { light FIREBULL } + frame FBULH { light FIREBULL } +} + +object ZFireBullUnlit +{ + frame FBULA { light FIREBULL } + frame FBULB { light FIREBULL } + frame FBULC { light FIREBULL } + frame FBULD { light FIREBULL } + frame FBULE { light FIREBULL } + frame FBULF { light FIREBULL } + frame FBULG { light FIREBULL } + frame FBULH { light FIREBULL } +} + + +// Cauldron +flickerlight2 CAULFLAME +{ + color 1.0 0.9 0.0 + size 24 + secondarySize 26 + interval 0.1 +} + +object ZCauldron +{ + frame CDRNB { light CAULFLAME } + frame CDRNC { light CAULFLAME } + frame CDRND { light CAULFLAME } + frame CDRNE { light CAULFLAME } + frame CDRNF { light CAULFLAME } + frame CDRNG { light CAULFLAME } + frame CDRNH { light CAULFLAME } +} + +object ZCauldronUnlit +{ + frame CDRNB { light CAULFLAME } + frame CDRNC { light CAULFLAME } + frame CDRND { light CAULFLAME } + frame CDRNE { light CAULFLAME } + frame CDRNF { light CAULFLAME } + frame CDRNG { light CAULFLAME } + frame CDRNH { light CAULFLAME } +} + +// Blue candle +flickerlight2 BCANDLE +{ + color 0.3 0.3 1.0 + size 14 + secondarySize 16 + interval 0.1 +} + +object ZBlueCandle +{ + frame CAND { light BCANDLE } +} + +// Small flame +object FlameSmall +{ + frame FFSM { light HCANDLES } +} + +object FlameSmallTemp +{ + frame FFSM { light HCANDLES } +} + +// Large flame +flickerlight2 LARGEFLAME +{ + color 1.0 0.7 0.0 + size 40 + secondarySize 48 + interval 0.1 +} + +object FlameLarge +{ + frame FFLG { light LARGEFLAME } +} + +object FlameLargeTemp +{ + frame FFLG { light LARGEFLAME } +} + +// Chandelier +flickerlight2 CHANDELIER +{ + color 1.0 1.0 0.0 + size 64 + secondarySize 68 + interval 0.1 +} + +object ZChandelier +{ + frame CDLR { light CHANDELIER } +} + +// Brass torch +flickerlight2 BRASSTORCH +{ + color 1.0 0.7 0.0 + size 40 + secondarySize 48 + interval 0.1 + offset 0 32 0 +} + +object BrassTorch +{ + frame BRTR { light BRASSTORCH } +} + +// Skull flame +object FireThing +{ + frame FSKL { light BRASSTORCH } +} + +// Teleport smoke +flickerlight2 TELESMOKE +{ + color 1.0 0.0 0.0 + size 64 + secondarySize 72 + interval 0.1 + offset 0 44 0 +} + +object TeleSmoke +{ + frame TSMK { light TELESMOKE } +} + +// Fireball +pointlight HFIREBALL +{ + color 1.0 0.4 0.0 + size 48 +} + +object FireBall +{ + frame FBL1A { light HFIREBALL } + frame FBL1B { light HFIREBALL } +} + +// ----------------- +// -- Hexen Items -- +// ----------------- + +// Blue mana +pointlight MANA1 +{ + color 0.0 0.0 0.7 + size 24 + offset 0 36 0 +} + +object Mana1 +{ + frame MAN1 { light MANA1 } +} + +// Green mana +pointlight MANA2 +{ + color 0.0 0.6 0.0 + size 24 + offset 0 36 0 +} + +object Mana2 +{ + frame MAN2 { light MANA2 } +} + +// Combined mana +pointlight MANA3 +{ + color 0.7 0.0 0.0 + size 24 + offset 0 36 0 +} + +object Mana3 +{ + frame MAN3 { light MANA3 } +} + +// ZXmasTree +flickerlight2 XMASFIRE1 +{ + color 1.0 0.7 0.0 + size 16 + secondarySize 24 + interval 0.1 + offset 0 48 0 +} + + +flickerlight2 XMASFIRE2 +{ + color 1.0 0.8 0.0 + size 32 + secondarySize 48 + interval 0.1 + offset 0 48 0 +} + + +flickerlight2 XMASFIRE3 +{ + color 1.0 0.9 0.0 + size 48 + secondarySize 64 + interval 0.1 + offset 0 32 0 +} + + +flickerlight2 XMASFIRE4 +{ + color 1.0 0.8 0.0 + size 32 + secondarySize 40 + interval 0.1 + offset 0 120 0 +} + + +flickerlight2 XMASFIRE5 +{ + color 1.0 0.7 0.0 + size 12 + secondarySize 20 + interval 0.1 + offset 0 140 0 +} + + +flickerlight2 XMASFIRE6 +{ + color 1.0 0.8 0.0 + size 10 + secondarySize 14 + interval 0.1 + offset 0 148 0 +} + + +object ZXmasTree +{ + frame XMASB { light XMASFIRE1 } + frame XMASC { light XMASFIRE2 } + frame XMASD { light XMASFIRE3 } + frame XMASE { light XMASFIRE3 } + frame XMASF { light XMASFIRE4 } + frame XMASG { light XMASFIRE5 } + frame XMASH { light XMASFIRE6 } +} + + + + +// TreeDestructible +flickerlight2 TDESTRUCT1 +{ + color 1.0 0.8 0.0 + size 48 + secondarySize 56 + interval 0.1 + offset 0 32 0 +} + + +flickerlight2 TDESTRUCT2 +{ + color 1.0 0.9 0.0 + size 56 + secondarySize 72 + interval 0.1 + offset 0 32 0 +} + + +flickerlight2 TDESTRUCT3 +{ + color 1.0 0.8 0.0 + size 40 + secondarySize 48 + interval 0.1 + offset 0 20 0 +} + + +flickerlight2 TDESTRUCT4 +{ + color 1.0 0.7 0.0 + size 16 + secondarySize 24 + interval 0.1 + offset 0 12 0 +} + +flickerlight2 TDESTRUCT5 +{ + color 1.0 0.7 0.0 + size 8 + secondarySize 12 + interval 0.1 + offset 0 4 0 +} + + + + +object TreeDestructible +{ + frame TRDTH { light TDESTRUCT1 } + frame TRDTI { light TDESTRUCT2 } + frame TRDTJ { light TDESTRUCT2 } + frame TRDTK { light TDESTRUCT2 } + frame TRDTL { light TDESTRUCT2 } + frame TRDTM { light TDESTRUCT3 } + frame TRDTN { light TDESTRUCT4 } + frame TRDTO { light TDESTRUCT4 } + frame TRDTP { light TDESTRUCT5 } +} diff --git a/wadsrc_lights/static/hticdefs.txt b/wadsrc_lights/static/hticdefs.txt new file mode 100644 index 000000000..92fa2852d --- /dev/null +++ b/wadsrc_lights/static/hticdefs.txt @@ -0,0 +1,1854 @@ +// ------------------------------------------------------ +// ---------------- HERETIC GAME LIGHTS ----------------- +// ------------------------------------------------------ + +// --------------------- +// -- Heretic Weapons -- +// --------------------- + +// Wand puffs +pointlight WANDPUFF1 +{ + color 1.0 1.0 0.0 + size 32 +} + +pointlight WANDPUFF2 +{ + color 0.7 0.7 0.0 + size 24 +} + +pointlight WANDPUFF3 +{ + color 0.4 0.4 0.0 + size 16 +} + +pointlight WANDPUFF4 +{ + color 0.2 0.2 0.0 + size 8 +} + +object GoldWandPuff1 +{ + frame PUF2A { light WANDPUFF1 } + frame PUF2B { light WANDPUFF2 } + frame PUF2C { light WANDPUFF3 } + frame PUF2D { light WANDPUFF4 } +} + +object GoldWandPuff2 +{ + frame PUF2C { light WANDPUFF3 } + frame PUF2D { light WANDPUFF4 } +} + +// Tomed wand projectile +pointlight WANDBALL +{ + color 1.0 1.0 0.0 + size 24 +} + +pointlight WANDBALL_X1 +{ + color 0.8 0.8 0.0 + size 32 +} + +pointlight WANDBALL_X2 +{ + color 0.6 0.6 0.0 + size 34 +} + +pointlight WANDBALL_X3 +{ + color 0.4 0.4 0.0 + size 36 +} + +pointlight WANDBALL_X4 +{ + color 0.2 0.2 0.0 + size 38 +} + +object GoldWandFX2 +{ + frame FX01C { light WANDBALL } + frame FX01D { light WANDBALL } + + frame FX01E { light WANDBALL_X1 } + frame FX01F { light WANDBALL_X2 } + frame FX01G { light WANDBALL_X3 } + frame FX01H { light WANDBALL_X4 } +} + +// Crossbow secondary projectile +pointlight SMALLBOWBOLT +{ + color 0.0 1.0 0.0 + size 40 +} + +flickerlight SMALLBOWBOLT_X1 +{ + color 0.0 0.7 0.0 + size 48 + secondarySize 52 + chance 0.3 +} + +flickerlight SMALLBOWBOLT_X2 +{ + color 0.0 0.4 0.0 + size 40 + secondarySize 44 + chance 0.3 +} + +flickerlight SMALLBOWBOLT_X3 +{ + color 0.0 0.2 0.0 + size 32 + secondarySize 36 + chance 0.3 +} + +object CrossbowFX3 +{ + frame FX03A { light SMALLBOWBOLT } + + frame FX03C { light SMALLBOWBOLT_X1 } + frame FX03D { light SMALLBOWBOLT_X2 } + frame FX03E { light SMALLBOWBOLT_X3 } +} + +// Crossbow primary proectile +pointlight BIGBOWBOLT +{ + color 0.7 1.0 0.0 + size 64 +} + +flickerlight BIGBOWBOLT_X1 +{ + color 0.4 0.8 0.0 + size 72 + secondarySize 74 + chance 0.3 +} + +flickerlight BIGBOWBOLT_X2 +{ + color 0.4 0.6 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight BIGBOWBOLT_X3 +{ + color 0.2 0.4 0.0 + size 32 + secondarySize 40 + chance 0.3 +} + +object CrossbowFX1 +{ + frame FX03B { light BIGBOWBOLT } + + frame FX03H { light BIGBOWBOLT_X1 } + frame FX03I { light BIGBOWBOLT_X2 } + frame FX03J { light BIGBOWBOLT_X3 } +} + +// Tomed crossbow projectile +object CrossbowFX2 +{ + frame FX03B { light BIGBOWBOLT } + + frame FX03H { light BIGBOWBOLT_X1 } + frame FX03I { light BIGBOWBOLT_X2 } + frame FX03J { light BIGBOWBOLT_X3 } +} + +// Tomed crossbow trail (slows down too much :P) +pointlight BOWTRAIL1 +{ + color 0.0 1.0 0.0 + size 24 +} + +pointlight BOWTRAIL2 +{ + color 0.0 0.7 0.0 + size 16 +} + +//object CrossbowFX4 +//{ + //frame FX03F { light BOWTRAIL1 } + //frame FX03G { light BOWTRAIL2 } +//} + +// Claw puff +pointlight CLAWPUFF1 +{ + color 0.4 0.4 1.0 + size 32 +} + +pointlight CLAWPUFF2 +{ + color 0.3 0.3 0.8 + size 24 +} + +pointlight CLAWPUFF3 +{ + color 0.2 0.2 0.6 + size 16 +} + +pointlight CLAWPUFF4 +{ + color 0.1 0.1 0.4 + size 8 +} + +object BlasterPuff +{ + frame FX17A { light CLAWPUFF1 } + frame FX17B { light CLAWPUFF2 } + frame FX17C { light CLAWPUFF3 } + frame FX17D { light CLAWPUFF4 } + frame FX17F { light CLAWPUFF1 } + frame FX17G { light CLAWPUFF2 } + frame FX17H { light CLAWPUFF3 } + frame FX17I { light CLAWPUFF4 } +} + +// Tomed claw puff +pointlight BIGCLAWPUFF1 +{ + color 0.4 0.4 1.0 + size 56 +} + +pointlight BIGCLAWPUFF2 +{ + color 0.3 0.3 0.8 + size 48 +} + +pointlight BIGCLAWPUFF3 +{ + color 0.2 0.2 0.6 + size 40 +} + +pointlight BIGCLAWPUFF4 +{ + color 0.1 0.1 0.4 + size 32 +} + +pointlight BIGCLAWPUFF5 +{ + color 0.0 0.0 0.2 + size 24 +} + +object BlasterFX1 +{ + frame FX18C { light BIGCLAWPUFF1 } + frame FX18D { light BIGCLAWPUFF2 } + frame FX18E { light BIGCLAWPUFF3 } + frame FX18F { light BIGCLAWPUFF4 } + frame FX18G { light BIGCLAWPUFF5 } +} + +// Hellstaff bolt +pointlight HELLSTAFFBALL +{ + color 1.0 0.2 0.2 + size 56 +} + +flickerlight HELLSTAFFBALL_X1 +{ + color 1.0 0.4 0.4 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight HELLSTAFFBALL_X2 +{ + color 0.8 0.3 0.3 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight HELLSTAFFBALL_X3 +{ + color 0.6 0.2 0.2 + size 80 + secondarySize 88 + chance 0.3 +} + +flickerlight HELLSTAFFBALL_X4 +{ + color 0.4 0.1 0.1 + size 88 + secondarySize 96 + chance 0.3 +} + +flickerlight HELLSTAFFBALL_X5 +{ + color 0.2 0.0 0.0 + size 96 + secondarySize 104 + chance 0.3 +} + +object HornRodFX1 +{ + frame FX00A { light HELLSTAFFBALL } + frame FX00B { light HELLSTAFFBALL } + + frame FX00H { light HELLSTAFFBALL_X1 } + frame FX00I { light HELLSTAFFBALL_X2 } + frame FX00J { light HELLSTAFFBALL_X3 } + frame FX00K { light HELLSTAFFBALL_X4 } + frame FX00L { light HELLSTAFFBALL_X5 } +} + +object HornRodFX2 +{ + frame FX00C { light HELLSTAFFBALL } + frame FX00D { light HELLSTAFFBALL } + frame FX00E { light HELLSTAFFBALL } + frame FX00F { light HELLSTAFFBALL } + + frame FX00H { light HELLSTAFFBALL_X1 } + frame FX00I { light HELLSTAFFBALL_X2 } + frame FX00J { light HELLSTAFFBALL_X3 } + frame FX00K { light HELLSTAFFBALL_X4 } + frame FX00L { light HELLSTAFFBALL_X5 } +} + +// Tomed hellstaff rain +pointlight REDRAIN +{ + color 1.0 0.0 0.0 + size 32 +} + +pointlight REDRAIN_X1 +{ + color 1.0 0.4 0.4 + size 48 +} + +pointlight REDRAIN_X2 +{ + color 0.8 0.3 0.3 + size 40 +} + +pointlight REDRAIN_X3 +{ + color 0.5 0.1 0.1 + size 32 +} + +pointlight REDRAIN_X4 +{ + color 0.3 0.0 0.0 + size 24 +} + +object RainPillar +{ + frame FX22A { light REDRAIN } + frame FX22B { light REDRAIN } + + frame FX22C { light REDRAIN_X1 } + frame FX22D { light REDRAIN_X2 } + frame FX22E { light REDRAIN_X3 } + frame FX22F { light REDRAIN_X4 } +} + +// Phoenix rod shot +pointlight PHOENIXSHOT +{ + color 1.0 0.6 0.0 + size 64 +} + +flickerlight PHOENIX_X1 +{ + color 1.0 0.8 0.4 + size 104 + secondarySize 112 + chance 0.3 +} + +flickerlight PHOENIX_X2 +{ + color 1.0 0.6 0.0 + size 88 + secondarySize 96 + chance 0.3 +} + +flickerlight PHOENIX_X3 +{ + color 0.8 0.6 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight PHOENIX_X4 +{ + color 0.6 0.4 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight PHOENIX_X5 +{ + color 0.4 0.2 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight PHOENIX_X6 +{ + color 0.2 0.0 0.0 + size 24 + secondarySize 32 + chance 0.3 +} + +object PhoenixFX1 +{ + frame FX04A { light PHOENIXSHOT } + + frame FX08A { light PHOENIX_X1 } + frame FX08B { light PHOENIX_X2 } + frame FX08C { light PHOENIX_X3 } + frame FX08D { light PHOENIX_X4 } + frame FX08E { light PHOENIX_X5 } + frame FX08F { light PHOENIX_X6 } + frame FX08G { light PHOENIX_X6 } + frame FX08H { light PHOENIX_X6 } +} + +// Phoenix rod flamethrower +flickerlight PHOENIXFLAME +{ + color 0.7 0.4 0.0 + size 48 + secondarySize 56 + chance 0.5 +} + +flickerlight PHOENIXFLAME2 +{ + color 0.5 0.2 0.0 + size 24 + secondarySize 32 + chance 0.5 +} + +flickerlight PHOENIXFLAME3 +{ + color 0.3 0.1 0.0 + size 16 + secondarySize 24 + chance 0.5 +} + +object PhoenixFX2 +{ + frame FX09A { light PHOENIXFLAME } + frame FX09B { light PHOENIXFLAME } + + frame FX09C { light PHOENIXFLAME2 } + frame FX09D { light PHOENIXFLAME3 } +} + +// Mace ball explosion +flickerlight MACEBALL_X1 +{ + color 0.8 0.8 0.2 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight MACEBALL_X2 +{ + color 0.6 0.6 0.1 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight MACEBALL_X3 +{ + color 0.4 0.4 0.0 + size 32 + secondarySize 40 + chance 0.3 +} + +flickerlight MACEBALL_X4 +{ + color 0.2 0.2 0.0 + size 16 + secondarySize 24 + chance 0.3 +} + +object MaceFX1 +{ + frame FX02G { light MACEBALL_X1 } + frame FX02H { light MACEBALL_X2 } + frame FX02I { light MACEBALL_X3 } + frame FX02J { light MACEBALL_X4 } +} + +object MaceFX2 +{ + frame FX02G { light MACEBALL_X1 } + frame FX02H { light MACEBALL_X2 } + frame FX02I { light MACEBALL_X3 } + frame FX02J { light MACEBALL_X4 } +} + +object MaceFX3 +{ + frame FX02G { light MACEBALL_X1 } + frame FX02H { light MACEBALL_X2 } + frame FX02I { light MACEBALL_X3 } + frame FX02J { light MACEBALL_X4 } +} + +object MaceFX4 +{ + frame FX02G { light MACEBALL_X1 } + frame FX02H { light MACEBALL_X2 } + frame FX02I { light MACEBALL_X3 } + frame FX02J { light MACEBALL_X4 } +} + +// --------------------- +// -- Heretic Enemies -- +// --------------------- + +// Heretic imp fireball +pointlight HIMPBALL +{ + color 1.0 0.8 0.0 + size 32 +} + +flickerlight HIMPBALL_X1 +{ + color 0.8 0.5 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight HIMPBALL_X2 +{ + color 0.6 0.3 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight HIMPBALL_X3 +{ + color 0.3 0.1 0.0 + size 32 + secondarySize 40 + chance 0.3 +} + +object HereticImpBall +{ + frame FX10A { light HIMPBALL } + frame FX10B { light HIMPBALL } + frame FX10C { light HIMPBALL } + + frame FX10D { light HIMPBALL } + frame FX10E { light HIMPBALL_X1 } + frame FX10F { light HIMPBALL_X2 } + frame FX10G { light HIMPBALL_X3 } +} + +// Mummy +flickerlight MUMMYATK +{ + color 1.0 1.0 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +object MummyLeader +{ + frame MUMMY { light MUMMYATK } +} + +object MummyLeaderGhost +{ + frame MUMMY { light MUMMYATK } +} + +// Mummy fireball +flickerlight MUMMYBALL +{ + color 1.0 1.0 0.0 + size 40 + secondarySize 48 + chance 0.4 +} + +flickerlight MUMMYBALL_X1 +{ + color 0.7 0.7 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +flickerlight MUMMYBALL_X2 +{ + color 0.4 0.4 0.0 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight MUMMYBALL_X3 +{ + color 0.2 0.2 0.0 + size 64 + secondarySize 72 + chance 0.4 +} + +object MummyFX1 +{ + frame FX15A { light MUMMYBALL } + frame FX15B { light MUMMYBALL } + frame FX15C { light MUMMYBALL } + + frame FX15D { light MUMMYBALL_X1 } + frame FX15E { light MUMMYBALL_X2 } + frame FX15F { light MUMMYBALL_X3 } +} + +// Green flying axe +pointlight GREENAXE +{ + color 0.0 1.0 0.0 + size 32 +} + +flickerlight GREENAXE_X1 +{ + color 0.0 0.7 0.0 + size 32 + secondarySize 48 + chance 0.3 +} + +flickerlight GREENAXE_X2 +{ + color 0.0 0.4 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight GREENAXE_X3 +{ + color 0.0 0.2 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +object KnightAxe +{ + frame SPAXA { light GREENAXE } + frame SPAXB { light GREENAXE } + frame SPAXC { light GREENAXE } + + frame SPAXD { light GREENAXE_X1 } + frame SPAXE { light GREENAXE_X2 } + frame SPAXF { light GREENAXE_X3 } +} + +// Red flying axe +pointlight REDAXE +{ + color 1.0 0.0 0.0 + size 32 +} + +flickerlight REDAXE_X1 +{ + color 0.7 0.0 0.0 + size 32 + secondarySize 48 + chance 0.3 +} + +flickerlight REDAXE_X2 +{ + color 0.4 0.0 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight REDAXE_X3 +{ + color 0.2 0.0 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +object RedAxe +{ + frame RAXEA { light REDAXE } + frame RAXEB { light REDAXE } + + frame RAXEC { light REDAXE_X1 } + frame RAXED { light REDAXE_X2 } + frame RAXEE { light REDAXE_X3 } +} + +// Disciple fireball +flickerlight DISCIPLEBALL +{ + color 1.0 0.0 1.0 + size 32 + secondarySize 40 + chance 0.3 +} + +flickerlight DISCIPLEBALL_X1 +{ + color 0.7 0.0 0.7 + size 16 + secondarySize 24 + chance 0.3 +} + +flickerlight DISCIPLEBALL_X2 +{ + color 0.3 0.0 0.3 + size 8 + secondarySize 16 + chance 0.3 +} + +object WizardFX1 +{ + frame FX11A { light DISCIPLEBALL } + frame FX11B { light DISCIPLEBALL } + frame FX11C { light DISCIPLEBALL } + + frame FX11D { light DISCIPLEBALL } + frame FX11E { light DISCIPLEBALL } + frame FX11F { light DISCIPLEBALL_X1 } + frame FX11G { light DISCIPLEBALL_X2 } +} + +// Iron lich death explosion +flickerlight IRONLICH1 +{ + color 1.0 0.4 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 40 0 +} + +flickerlight IRONLICH2 +{ + color 1.0 0.7 0.0 + size 80 + secondarySize 88 + chance 0.3 + offset 0 44 0 +} + +flickerlight IRONLICH3 +{ + color 0.8 0.4 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 48 0 +} + +flickerlight IRONLICH4 +{ + color 0.4 0.0 0.0 + size 48 + secondarySize 56 + chance 0.3 + offset 0 40 0 +} + +object Ironlich +{ + frame LICHD { light IRONLICH1 } + frame LICHE { light IRONLICH2 } + frame LICHF { light IRONLICH3 } + frame LICHG { light IRONLICH4 } +} + +// IronLich frost ball +pointlight FROSTBALL +{ + color 0.4 0.4 1.0 + size 48 +} + +pointlight FROSTBALL_X1 +{ + color 0.4 0.4 1.0 + size 64 +} + +pointlight FROSTBALL_X2 +{ + color 0.2 0.2 0.7 + size 56 +} + +pointlight FROSTBALL_X3 +{ + color 0.0 0.0 0.4 + size 48 +} + +pointlight FROSTBALL_X4 +{ + color 0.0 0.0 0.2 + size 40 +} + +object HeadFX1 +{ + frame FX05A { light FROSTBALL } + frame FX05B { light FROSTBALL } + frame FX05C { light FROSTBALL } + + frame FX05D { light FROSTBALL_X1 } + frame FX05E { light FROSTBALL_X2 } + frame FX05F { light FROSTBALL_X3 } + frame FX05G { light FROSTBALL_X4 } +} + +// Frost shard (spawned by frost ball) +pointlight FROSTSHARD +{ + color 0.0 0.0 0.5 + size 32 +} + +object HeadFX2 +{ + frame FX05H { light FROSTSHARD } + frame FX05I { light FROSTSHARD } + frame FX05J { light FROSTSHARD } +} + +// Ironlich fire wall +flickerlight LICHFIRE +{ + color 1.0 0.7 0.0 + size 48 + secondarySize 56 + chance 0.5 +} + +flickerlight LICHFIRE_X1 +{ + color 0.9 0.4 0.0 + size 56 + secondarySize 64 + chance 0.5 +} + +flickerlight LICHFIRE_X2 +{ + color 0.7 0.1 0.0 + size 48 + secondarySize 56 + chance 0.5 +} + +flickerlight LICHFIRE_X3 +{ + color 0.4 0.0 0.0 + size 40 + secondarySize 48 + chance 0.5 +} + +flickerlight LICHFIRE_X4 +{ + color 0.2 0.0 0.0 + size 32 + secondarySize 40 + chance 0.5 +} + +object HeadFX3 +{ + frame FX06A { light LICHFIRE } + frame FX06B { light LICHFIRE } + frame FX06C { light LICHFIRE } + + frame FX06D { light LICHFIRE_X1 } + frame FX06E { light LICHFIRE_X2 } + frame FX06F { light LICHFIRE_X3 } + frame FX06G { light LICHFIRE_X4 } +} + +// Clinker death explosion +flickerlight CLINK_X1 +{ + color 1.0 0.8 0.0 + size 40 + secondarySize 48 + chance 0.5 +} + +flickerlight CLINK_X2 +{ + color 1.0 0.6 0.0 + size 64 + secondarySize 72 + chance 0.5 +} + +flickerlight CLINK_X3 +{ + color 0.6 0.3 0.0 + size 56 + secondarySize 64 + chance 0.5 +} + +flickerlight CLINK_X4 +{ + color 0.3 0.0 0.0 + size 48 + secondarySize 56 + chance 0.5 +} + +object Clink +{ + frame CLNKK { light CLINK_X1 } + frame CLNKL { light CLINK_X2 } + frame CLNKM { light CLINK_X3 } + frame CLNKN { light CLINK_X4 } +} + +// Weredragon +flickerlight BEASTATK +{ + color 1.0 0.7 0.0 + size 56 + secondarySize 64 + chance 0.5 + offset 0 48 0 +} + +object Beast +{ + frame BEASI { light BEASTATK } +} + +// Weredragon fireball +flickerlight BEASTBALL +{ + color 1.0 0.4 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight BEASTBALL_X1 +{ + color 0.8 0.2 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight BEASTBALL_X2 +{ + color 0.6 0.0 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight BEASTBALL_X3 +{ + color 0.4 0.0 0.0 + size 32 + secondarySize 40 + chance 0.3 +} + +flickerlight BEASTBALL_X4 +{ + color 0.2 0.0 0.0 + size 28 + secondarySize 32 + chance 0.3 +} + +object BeastBall +{ + frame FRB1A { light BEASTBALL } + frame FRB1B { light BEASTBALL } + frame FRB1C { light BEASTBALL } + + frame FRB1D { light BEASTBALL_X1 } + frame FRB1E { light BEASTBALL_X2 } + frame FRB1F { light BEASTBALL_X3 } + frame FRB1G { light BEASTBALL_X4 } +} + +// Small ophidian shot +pointlight SNAKESHOT1 +{ + color 0.5 0.3 1.0 + size 24 +} + +flickerlight SNAKESHOT1_X1 +{ + color 0.5 0.3 1.0 + size 24 + secondarySize 26 + chance 0.3 +} + +flickerlight SNAKESHOT1_X2 +{ + color 0.4 0.1 0.7 + size 24 + secondarySize 26 + chance 0.3 +} + +flickerlight SNAKESHOT1_X3 +{ + color 0.3 0.0 0.5 + size 28 + secondarySize 30 + chance 0.3 +} + +flickerlight SNAKESHOT1_X4 +{ + color 0.3 0.0 0.3 + size 26 + secondarySize 28 + chance 0.3 +} + +object SnakeProjA +{ + frame SNFXA { light SNAKESHOT1 } + frame SNFXB { light SNAKESHOT1 } + frame SNFXC { light SNAKESHOT1 } + frame SNFXD { light SNAKESHOT1 } + + frame SNFXE { light SNAKESHOT1_X1 } + frame SNFXF { light SNAKESHOT1_X2 } + frame SNFXG { light SNAKESHOT1_X3 } + frame SNFXH { light SNAKESHOT1_X4 } +} + +// Large ophidian shot +pointlight SNAKESHOT2 +{ + color 1.0 0.6 0.0 + size 32 +} + +flickerlight SNAKESHOT2_X1 +{ + color 1.0 0.6 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight SNAKESHOT2_X2 +{ + color 0.6 0.3 0.0 + size 48 + secondarySize 52 + chance 0.3 +} + +flickerlight SNAKESHOT2_X3 +{ + color 0.3 0.0 0.0 + size 44 + secondarySize 48 + chance 0.3 +} + +object SnakeProjB +{ + frame SNFXJ { light SNAKESHOT2 } + frame SNFXK { light SNAKESHOT2 } + + frame SNFXL { light SNAKESHOT2_X1 } + frame SNFXM { light SNAKESHOT2_X2 } + frame SNFXN { light SNAKESHOT2_X3 } +} + +// Maulotaur fireball +flickerlight MAULBALL +{ + color 1.0 0.7 0.0 + size 40 + secondarySize 48 + chance 0.5 +} + +flickerlight MAULBALL_X1 +{ + color 0.8 0.6 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight MAULBALL_X2 +{ + color 0.8 0.4 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight MAULBALL_X3 +{ + color 0.6 0.2 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight MAULBALL_X4 +{ + color 0.4 0.1 0.0 + size 32 + secondarySize 40 + chance 0.3 +} + +object MinotaurFX1 +{ + frame FX12A { light MAULBALL } + frame FX12B { light MAULBALL } + + frame FX12C { light MAULBALL_X1 } + frame FX12D { light MAULBALL_X2 } + frame FX12E { light MAULBALL_X3 } + frame FX12F { light MAULBALL_X3 } + frame FX12G { light MAULBALL_X4 } + frame FX12H { light MAULBALL_X4 } +} + +// Maulotaur ground flame +pulselight MAULFLAME +{ + color 1.0 0.7 0.0 + size 1 + secondarySize 64 + interval 6.0 +} + +flickerlight MAULFLAME_X1 +{ + color 1.0 0.7 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight MAULFLAME_X2 +{ + color 1.0 0.7 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight MAULFLAME_X3 +{ + color 0.7 0.4 0.0 + size 64 + secondarySize 68 + chance 0.3 +} + +flickerlight MAULFLAME_X4 +{ + color 0.5 0.1 0.0 + size 68 + secondarySize 72 + chance 0.3 +} + +flickerlight MAULFLAME_X5 +{ + color 0.2 0.0 0.0 + size 72 + secondarySize 76 + chance 0.3 +} + +object MinotaurFX3 +{ + frame FX13B { light MAULFLAME } + frame FX13C { light MAULFLAME } + frame FX13D { light MAULFLAME } + frame FX13E { light MAULFLAME } + frame FX13F { light MAULFLAME } + frame FX13G { light MAULFLAME } + frame FX13H { light MAULFLAME } + + frame FX13I { light MAULFLAME_X1 } + frame FX13J { light MAULFLAME_X2 } + frame FX13K { light MAULFLAME_X3 } + frame FX13L { light MAULFLAME_X4 } + frame FX13M { light MAULFLAME_X5 } +} + +// D'Sparil serpent fireball +flickerlight SERPENTBALL +{ + color 1.0 0.95 0.0 + size 56 + secondarySize 64 + chance 0.5 +} + +flickerlight SERPENTBALL_X1 +{ + color 1.0 0.95 0.0 + size 64 + secondarySize 72 + chance 0.5 +} + +flickerlight SERPENTBALL_X2 +{ + color 0.8 0.8 0.0 + size 72 + secondarySize 80 + chance 0.5 +} + +flickerlight SERPENTBALL_X3 +{ + color 0.5 0.5 0.0 + size 88 + secondarySize 96 + chance 0.5 +} + +flickerlight SERPENTBALL_X4 +{ + color 0.2 0.2 0.0 + size 96 + secondarySize 104 + chance 0.5 +} + +object SorcererFX1 +{ + frame FX14A { light SERPENTBALL } + frame FX14B { light SERPENTBALL } + frame FX14C { light SERPENTBALL } + + frame FX14D { light SERPENTBALL_X1 } + frame FX14E { light SERPENTBALL_X2 } + frame FX14F { light SERPENTBALL_X3 } + frame FX14G { light SERPENTBALL_X4 } + frame FX14H { light SERPENTBALL_X4 } +} + +// D'Sparil blue bolt +flickerlight DSPARILBALL +{ + color 0.3 0.3 1.0 + size 56 + secondarySize 64 + chance 0.5 +} + +flickerlight DSPARILBALL_X1 +{ + color 0.3 0.3 1.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight DSPARILBALL_X2 +{ + color 0.2 0.2 0.8 + size 80 + secondarySize 88 + chance 0.3 +} + +flickerlight DSPARILBALL_X3 +{ + color 0.1 0.1 0.6 + size 88 + secondarySize 92 + chance 0.3 +} + +flickerlight DSPARILBALL_X4 +{ + color 0.0 0.0 0.4 + size 82 + secondarySize 86 + chance 0.3 +} + +flickerlight DSPARILBALL_X5 +{ + color 0.0 0.0 0.2 + size 82 + secondarySize 86 + chance 0.3 +} + +object Sorcerer2FX1 +{ + frame FX16A { light DSPARILBALL } + frame FX16B { light DSPARILBALL } + frame FX16C { light DSPARILBALL } + + frame FX16G { light DSPARILBALL_X1 } + frame FX16H { light DSPARILBALL_X2 } + frame FX16I { light DSPARILBALL_X3 } + frame FX16J { light DSPARILBALL_X4 } + frame FX16K { light DSPARILBALL_X5 } + frame FX16L { light DSPARILBALL_X5 } +} + +// D'Sparil +flickerlight DSPARILATK +{ + color 0.3 0.3 1.0 + size 64 + secondarySize 72 + chance 0.5 +} + +object Sorcerer2 +{ + frame SOR2R { light DSPARILATK } + frame SOR2S { light DSPARILATK } + frame SOR2T { light DSPARILATK } +} + +// ------------------------- +// -- Heretic Decorations -- +// ------------------------- + +// Wall Torch +flickerlight2 WALLTORCH +{ + color 1.0 0.8 0.0 + size 32 + secondarySize 36 + interval 0.1 + offset 0 70 0 +} + +object WallTorch +{ + frame WTRH { light WALLTORCH } +} + +// Fire Brazier +flickerlight2 FIREBRAZ +{ + color 1.0 0.8 0.0 + size 68 + secondarySize 76 + interval 0.1 + offset 0 48 0 +} + +object FireBrazier +{ + frame KFR1 { light FIREBRAZ } +} + +// Serpent torch +flickerlight2 SERPTORCH +{ + color 1.0 0.8 0.0 + size 48 + secondarySize 56 + interval 0.1 + offset 0 48 0 +} + +object SerpentTorch +{ + frame SRTC { light SERPTORCH } +} + +// Chandelier +flickerlight2 CHANDELIER +{ + color 1.0 1.0 0.0 + size 64 + secondarySize 68 + interval 0.1 +} + +object Chandelier +{ + frame CHDL { light CHANDELIER } +} + +// Pod +flickerlight POD_X1 +{ + color 0.0 1.0 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight POD_X2 +{ + color 0.0 0.7 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight POD_X3 +{ + color 0.0 0.4 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight POD_X4 +{ + color 0.0 0.2 0.0 + size 80 + secondarySize 88 + chance 0.3 +} + +object Pod +{ + frame PPODC { light POD_X1 } + frame PPODD { light POD_X2 } + frame PPODE { light POD_X3 } + frame PPODF { light POD_X4 } +} + +// Big volcano fireball +flickerlight VOLCANOBALL1 +{ + color 1.0 0.5 0.0 + size 56 + secondarySize 64 + chance 0.5 +} + +object VolcanoBlast +{ + frame VFBL { light VOLCANOBALL1 } +} + +// Small volcano fireball +flickerlight VOLCANOBALL1 +{ + color 1.0 0.5 0.0 + size 40 + secondarySize 48 + chance 0.5 +} + +object VolcanoTBlast +{ + frame VTFB { light VOLCANOBALL1 } +} + +// Blue Key Statue +pointlight BLUESTATUE +{ + color 0.0 0.0 1.0 + size 32 + offset 0 64 0 +} + +object KeyGizmoBlue +{ + frame KGZ1 { light BLUESTATUE } +} + +// Yellow Key Statue +pointlight YELLOWSTATUE +{ + color 1.0 1.0 0.0 + size 32 + offset 0 64 0 +} + +object KeyGizmoYellow +{ + frame KGZ1 { light YELLOWSTATUE } +} + +// Green Key Statue +pointlight GREENSTATUE +{ + color 0.0 1.0 0.0 + size 32 + offset 0 64 0 +} + +object KeyGizmoGreen +{ + frame KGZ1 { light GREENSTATUE } +} + +// ------------------- +// -- Heretic Items -- +// ------------------- + +// Time bomb explosion +flickerlight TIMEBOMB_X1 +{ + color 1.0 0.6 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight TIMEBOMB_X1 +{ + color 0.8 0.4 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight TIMEBOMB_X1 +{ + color 0.6 0.2 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight TIMEBOMB_X1 +{ + color 0.4 0.0 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight TIMEBOMB_X1 +{ + color 0.2 0.0 0.0 + size 80 + secondarySize 88 + chance 0.3 +} + +object ActivatedTimeBomb +{ + frame XPL1A { light TIMEBOMB_X1 } + frame XPL1B { light TIMEBOMB_X2 } + frame XPL1C { light TIMEBOMB_X3 } + frame XPL1D { light TIMEBOMB_X4 } + frame XPL1E { light TIMEBOMB_X5 } + frame XPL1F { light TIMEBOMB_X5 } +} + +// Small wand ammo +pointlight SWANDAMMO +{ + color 1.0 1.0 0.0 + size 8 +} + +object GoldWandAmmo +{ + frame AMG1 { light SWANDAMMO } +} + +// Large wand ammo +pulselight LWANDAMMO +{ + color 1.0 1.0 0.0 + size 16 + secondarySize 18 + interval 2.0 +} + +object GoldWandHefty +{ + frame AMG2 { light LWANDAMMO } +} + +// Ethereal arrows +pointlight ETHARROWS +{ + color 0.0 1.0 0.0 + size 12 + offset 0 8 0 +} + +object CrossbowAmmo +{ + frame AMC1 { light ETHARROWS } +} + +// Quiver of ethereal arrows +pulselight ETHQUIVER +{ + color 0.0 1.0 0.0 + size 16 + secondarySize 18 + interval 2.0 + offset 0 16 0 +} + +object CrossbowHefty +{ + frame AMC2 { light ETHQUIVER } +} + +// Small claw ammo +pulselight SCLAWAMMO +{ + color 0.0 0.0 1.0 + size 8 + secondarySize 10 + interval 2.0 +} + +object BlasterAmmo +{ + frame AMB1 { light SCLAWAMMO } +} + +// Large claw ammo +pulselight LCLAWAMMO +{ + color 0.0 0.0 1.0 + size 16 + secondarySize 18 + interval 2.0 + offset 0 6 0 +} + +object BlasterHefty +{ + frame AMB2 { light LCLAWAMMO } +} + +// Small hellstaff ammo +pulselight SSTAFFAMMO +{ + color 1.0 0.0 0.0 + size 8 + secondarySize 10 + interval 2.0 +} + +object SkullRodAmmo +{ + frame AMS1 { light SSTAFFAMMO } +} + +// Large hellstaff ammo +pulselight LSTAFFAMMO +{ + color 1.0 0.0 0.0 + size 16 + secondarySize 18 + interval 2.0 +} + +object SkullRodHefty +{ + frame AMS2 { light LSTAFFAMMO } +} + +// Small phoenix rod ammo +pulselight SRODAMMO +{ + color 1.0 0.6 0.0 + size 8 + secondarySize 10 + interval 2.0 +} + +object PhoenixRodAmmo +{ + frame AMP1 { light SRODAMMO } +} + +// Large phoenix rod ammo +pulselight LRODAMMO +{ + color 1.0 0.6 0.0 + size 16 + secondarySize 18 + interval 2.0 +} + +object PhoenixRodHefty +{ + frame AMP2 { light LRODAMMO } +} + +// Yellow Key +pulselight HYELLOWKEY +{ + color 1.0 1.0 0.0 + size 24 + secondarySize 26 + interval 2.0 +} +object KeyYellow +{ + frame CKYY { light HYELLOWKEY } +} + +// Blue Key +pulselight HBLUEKEY +{ + color 0.0 0.0 1.0 + size 24 + secondarySize 26 + interval 2.0 +} + +object KeyBlue +{ + frame BKYY { light HBLUEKEY } +} + +// Green Key +pulselight HGREENKEY +{ + color 0.0 1.0 0.0 + size 24 + secondarySize 26 + interval 2.0 +} + +object KeyGreen +{ + frame AKYY { light HGREENKEY } +} + +// --------------------- +// -- Heretic Effects -- +// --------------------- + +// Heretic Teleport fog +pointlight HTFOG1 +{ + color 0.4 0.4 1.0 + size 64 +} + +pointlight HTFOG2 +{ + color 0.4 0.4 1.0 + size 40 +} + +pointlight HTFOG3 +{ + color 0.4 0.4 1.0 + size 16 +} + +flickerlight HTFOG4 +{ + color 0.5 0.5 1.0 + size 40 + secondarySize 48 + chance 0.4 +} + +flickerlight HTFOG5 +{ + color 0.5 0.5 1.0 + size 56 + secondarySize 64 + chance 0.4 +} + +object TeleportFog +{ + frame TELEA { light HTFOG1 } + frame TELEB { light HTFOG2 } + frame TELEC { light HTFOG3 } + frame TELED { light HTFOG4 } + frame TELEE { light HTFOG4 } + frame TELEF { light HTFOG4 } + frame TELEG { light HTFOG5 } + frame TELEH { light HTFOG5 } +} \ No newline at end of file diff --git a/wadsrc_lights/static/strfdefs.txt b/wadsrc_lights/static/strfdefs.txt new file mode 100644 index 000000000..8a2bdcc5d --- /dev/null +++ b/wadsrc_lights/static/strfdefs.txt @@ -0,0 +1,2874 @@ +// ------------------------------------------------------ +// ---------------- STRIFE GAME LIGHTS ------------------ +// ------------------------------------------------------ +// -------------------- +// -- Strife Weapons -- +// -------------------- + +// Bullet puff +flickerlight SPUFF1 +{ + color 1.0 1.0 0.0 + size 6 + secondarySize 8 + chance 0.8 +} + +flickerlight SPUFF2 +{ + color 1.0 0.8 0.0 + size 5 + secondarySize 6 + chance 0.8 +} + +flickerlight SPUFF3 +{ + color 1.0 0.6 0.0 + size 8 + secondarySize 10 + chance 0.8 +} + +flickerlight SPUFF4 +{ + color 0.8 0.8 1.0 + size 2 + secondarySize 4 + chance 0.8 +} + +flickerlight SPUFF5 +{ + color 0.8 0.8 1.0 + size 4 + secondarySize 6 + chance 0.8 +} + +flickerlight SPUFF6 +{ + color 0.6 0.6 1.0 + size 6 + secondarySize 8 + chance 0.8 +} + +flickerlight SPUFF7 +{ + color 0.4 0.4 0.8 + size 7 + secondarySize 9 + chance 0.8 +} + +flickerlight SPUFF8 +{ + color 1.0 1.0 0.0 + size 2 + secondarySize 4 + chance 0.8 +} + +flickerlight SPUFF9 +{ + color 1.0 0.8 0.0 + size 3 + secondarySize 4 + chance 0.8 +} + +flickerlight SPUFF10 +{ + color 1.0 0.6 0.0 + size 5 + secondarySize 6 + chance 0.8 +} + +flickerlight SPUFF11 +{ + color 1.0 0.4 0.0 + size 7 + secondarySize 8 + chance 0.8 +} + +object StrifePuff +{ + frame PUFYA { light SPUFF1 } + frame PUFYB { light SPUFF2 } + frame PUFYC { light SPUFF3 } + + frame POW3A { light SPUFF4 } + frame POW3B { light SPUFF5 } + frame POW3C { light SPUFF6 } + frame POW3D { light SPUFF7 } + frame POW3E { light SPUFF8 } + frame POW3F { light SPUFF9 } + frame POW3G { light SPUFF10 } + frame POW3H { light SPUFF11 } +} + +flickerlight SSPARK1 +{ + color 0.5 0.5 1.0 + size 4 + secondarySize 6 + chance 0.8 +} + +flickerlight SSPARK2 +{ + color 0.5 0.5 1.0 + size 6 + secondarySize 8 + chance 0.8 +} + +flickerlight SSPARK3 +{ + color 0.4 0.4 1.0 + size 8 + secondarySize 10 + chance 0.8 +} + +flickerlight SSPARK4 +{ + color 0.3 0.3 1.0 + size 6 + secondarySize 8 + chance 0.8 +} + +flickerlight SSPARK5 +{ + color 0.2 0.2 1.0 + size 4 + secondarySize 6 + chance 0.8 +} + +object StrifeSpark +{ + frame POW3A { light SPUFF4 } + frame POW3B { light SPUFF5 } + frame POW3C { light SPUFF6 } + frame POW3D { light SPUFF7 } + frame POW3E { light SPUFF8 } + frame POW3F { light SPUFF9 } + frame POW3G { light SPUFF10 } + frame POW3H { light SPUFF11 } + + frame POW2A { light SSPARK5 } + frame POW2B { light SSPARK5 } + frame POW2C { light SSPARK5 } + frame POW2D { light SSPARK5 } + frame POW2E { light SSPARK5 } +} + +// Arrow +flickerlight ARROWZAP1 +{ + color 0.4 0.4 1.0 + size 8 + secondarySize 16 + chance 0.4 +} + +flickerlight ARROWZAP2 +{ + color 0.45 0.45 1.0 + size 16 + secondarySize 24 + chance 0.4 +} + +flickerlight ARROWZAP3 +{ + color 0.5 0.5 1.0 + size 24 + secondarySize 30 + chance 0.4 +} + +flickerlight ARROWZAP4 +{ + color 0.6 0.6 1.0 + size 30 + secondarySize 36 + chance 0.4 +} + +flickerlight ARROWZAP5 +{ + color 0.7 0.7 1.0 + size 36 + secondarySize 40 + chance 0.4 +} + +flickerlight ARROWZAP6 +{ + color 0.8 0.8 1.0 + size 40 + secondarySize 42 + chance 0.4 +} + +object ElectricBolt +{ + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +// Missile +pointlight MISSILE +{ + color 1.0 0.7 0.0 + size 56 + offset -40 0 0 +} + +flickerlight MISSILE_X1 +{ + color 1.0 0.7 0.0 + size 56 + secondarySize 60 + chance 0.3 +} + +flickerlight MISSILE_X2 +{ + color 1.0 0.65 0.0 + size 60 + secondarySize 64 + chance 0.3 +} + +flickerlight MISSILE_X3 +{ + color 1.0 0.6 0.0 + size 64 + secondarySize 68 + chance 0.3 +} + +flickerlight MISSILE_X4 +{ + color 1.0 0.6 0.0 + size 68 + secondarySize 72 + chance 0.3 +} + +flickerlight MISSILE_X5 +{ + color 1.0 0.6 0.0 + size 72 + secondarySize 76 + chance 0.3 +} + +flickerlight MISSILE_X6 +{ + color 1.0 0.6 0.0 + size 76 + secondarySize 80 + chance 0.3 +} + +flickerlight MISSILE_X7 +{ + color 1.0 0.6 0.0 + size 80 + secondarySize 88 + chance 0.3 +} + +object MiniMissile +{ + frame MICRA { light MISSILE } + + frame SMISA { light MISSILE_X1 } + frame SMISB { light MISSILE_X2 } + frame SMISC { light MISSILE_X3 } + frame SMISD { light MISSILE_X4 } + frame SMISE { light MISSILE_X5 } + frame SMISF { light MISSILE_X6 } + frame SMISG { light MISSILE_X7 } +} + +// Flame +pointlight FLMMISSILE +{ + color 1.0 0.7 0.0 + size 56 +} + +pointlight FLMMSL_X1 +{ + color 1.0 0.7 0.0 + size 52 +} + +pointlight FLMMSL_X2 +{ + color 0.8 0.56 0.0 + size 46 +} + +pointlight FLMMSL_X3 +{ + color 0.6 0.42 0.0 + size 38 +} + +pointlight FLMMSL_X4 +{ + color 0.4 0.28 0.0 + size 24 +} + +pointlight FLMMSL_X5 +{ + color 0.2 0.14 0.0 + size 16 +} + +object FlameMissile +{ + frame FRBLA { light FLMMISSILE } + frame FRBLB { light FLMMISSILE } + frame FRBLC { light FLMMISSILE } + + frame FRBLD { light FLMMSL_X1 } + frame FRBLE { light FLMMSL_X2 } + frame FRBLF { light FLMMSL_X3 } + frame FRBLG { light FLMMSL_X4 } + frame FRBLH { light FLMMSL_X5 } +} + +// Mauler +flickerlight MPUFFG +{ + color 0.0 1.0 0.0 + size 6 + secondarySize 8 + chance 0.8 +} + +flickerlight MPUFF1 +{ + color 1.0 1.0 1.0 + size 6 + secondarySize 8 + chance 0.8 +} + +flickerlight MPUFF2 +{ + color 1.0 1.0 1.0 + size 8 + secondarySize 10 + chance 0.8 +} + +flickerlight MPUFF3 +{ + color 1.0 1.0 1.0 + size 10 + secondarySize 12 + chance 0.8 +} + +flickerlight MPUFF4 +{ + color 1.0 1.0 1.0 + size 12 + secondarySize 14 + chance 0.8 +} + +flickerlight MPUFF5 +{ + color 1.0 1.0 1.0 + size 14 + secondarySize 16 + chance 0.8 +} + +object MaulerPuff +{ + frame MPUFA { light MPUFFG } + frame MPUFB { light MPUFFG } + frame POW1A { light MPUFF1 } + frame POW1B { light MPUFF2 } + frame POW1C { light MPUFF3 } + frame POW1D { light MPUFF4 } + frame POW1E { light MPUFF5 } +} + +pointlight MTORPEDO +{ + color 0.0 1.0 0.0 + size 80 +} + +flickerlight MTORP_X1 +{ + color 0.5 1.0 0.5 + size 80 + secondarySize 84 + chance 0.3 +} + +flickerlight MTORP_X2 +{ + color 0.4 1.0 0.4 + size 84 + secondarySize 88 + chance 0.3 +} + +flickerlight MTORP_X3 +{ + color 0.2 1.0 0.2 + size 88 + secondarySize 92 + chance 0.3 +} + +flickerlight MTORP_X4 +{ + color 0.125 0.5 0.125 + size 92 + secondarySize 96 + chance 0.3 +} + +flickerlight MTORP_X5 +{ + color 0.0 0.25 0.0 + size 96 + secondarySize 100 + chance 0.3 +} + +object MaulerTorpedo +{ + frame TORP { light MTORPEDO } + + frame THITA { light MTORP_X1 } + frame THITB { light MTORP_X2 } + frame THITC { light MTORP_X3 } + frame THITD { light MTORP_X4 } + frame THITE { light MTORP_X5 } +} + +flickerlight MWAVE_X1 +{ + color 0.0 1.0 0.0 + size 112 + secondarySize 128 + chance 0.3 +} + +flickerlight MWAVE_X2 +{ + color 0.0 0.75 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight MWAVE_X3 +{ + color 0.0 0.5 0.0 + size 24 + secondarySize 32 + chance 0.3 +} + +object MaulerTorpedoWave +{ + frame TWAVA { light MWAVE_X1 } + frame TWAVB { light MWAVE_X2 } + frame TWAVC { light MWAVE_X3 } +} + +// High Explosive Grenade +flickerlight HEGRENADE_X1 +{ + color 1.0 0.30 0.10 + size 80 + secondarySize 84 + chance 0.3 +} + +flickerlight HEGRENADE_X2 +{ + color 1.0 0.28 0.08 + size 72 + secondarySize 76 + chance 0.3 + offset 0 28 0 +} + +flickerlight HEGRENADE_X3 +{ + color 1.0 0.26 0.10 + size 57 + secondarySize 62 + chance 0.3 + offset 0 40 0 +} + +flickerlight HEGRENADE_X4 +{ + color 1.0 0.24 0.08 + size 28 + secondarySize 32 + chance 0.3 + offset 0 64 0 +} + +object HEGrenade +{ + frame BNG4A { light POWCRYS_X1 } + frame BNG4B { light POWCRYS_X2 } + frame BNG4C { light POWCRYS_X3 } + frame BNG4D { light POWCRYS_X4 } + frame BNG4E { light POWCRYS_X5 } + frame BNG4F { light POWCRYS_X6 } + frame BNG4G { light POWCRYS_X7 } + frame BNG4H { light POWCRYS_X8 } + frame BNG4I { light POWCRYS_X9 } + frame BNG4J { light POWCRYS_X10 } + + frame BNG4K { light HEGRENADE_X1 } + frame BNG4L { light HEGRENADE_X2 } + frame BNG4M { light HEGRENADE_X3 } + frame BNG4N { light HEGRENADE_X4 } +} + +// Phosphorous Fire Grenade +flickerlight PHFIRE_FX1 +{ + color 1.0 0.75 0.0 + size 28 + secondarySize 32 + chance 0.3 +} + +flickerlight PHFIRE_FX2 +{ + color 1.0 0.7 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight PHFIRE_FX3 +{ + color 1.0 0.65 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight PHFIRE_FX4 +{ + color 1.0 0.55 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight PHFIRE_FX5 +{ + color 1.0 0.5 0.0 + size 66 + secondarySize 72 + chance 0.3 +} + +flickerlight PHFIRE_FX6 +{ + color 1.0 0.55 0.0 + size 66 + secondarySize 72 + chance 0.3 +} + +flickerlight PHFIRE_FX7 +{ + color 1.0 0.6 0.0 + size 66 + secondarySize 72 + chance 0.3 +} + +flickerlight PHFIRE_FX8 +{ + color 1.0 0.5 0.0 + size 60 + secondarySize 68 + chance 0.3 +} + +flickerlight PHFIRE_FX9 +{ + color 1.0 0.4 0.0 + size 48 + secondarySize 52 + chance 0.3 +} + +flickerlight PHFIRE_FX10 +{ + color 1.0 0.45 0.0 + size 44 + secondarySize 48 + chance 0.3 +} + +flickerlight PHFIRE_FX11 +{ + color 1.0 0.3 0.0 + size 36 + secondarySize 40 + chance 0.3 +} + +object PhosphorousFire +{ + frame FLBEA { light PHFIRE_FX1 } + frame FLBEB { light PHFIRE_FX2 } + frame FLBEC { light PHFIRE_FX3 } + frame FLBED { light PHFIRE_FX4 } + frame FLBEE { light PHFIRE_FX5 } + frame FLBEF { light PHFIRE_FX6 } + frame FLBEG { light PHFIRE_FX7 } + + frame FLBEH { light PHFIRE_FX8 } + frame FLBEI { light PHFIRE_FX9 } + frame FLBEJ { light PHFIRE_FX10 } + frame FLBEK { light PHFIRE_FX11 } +} + +// ------------------ +// -- Strife Items -- +// ------------------ + +// Degnin Ore +flickerlight DEGORE_X1 +{ + color 1.0 0.6 0.0 + size 32 + secondarySize 40 + chance 0.3 +} + +flickerlight DEGORE_X2 +{ + color 1.0 0.8 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight DEGORE_X3 +{ + color 1.0 0.8 0.0 + size 44 + secondarySize 52 + chance 0.3 +} + +flickerlight DEGORE_X4 +{ + color 1.0 0.75 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight DEGORE_X5 +{ + color 1.0 0.7 0.0 + size 52 + secondarySize 60 + chance 0.3 +} + +flickerlight DEGORE_X6 +{ + color 1.0 0.5 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight DEGORE_X7 +{ + color 0.5 0.125 0.0 + size 60 + secondarySize 68 + chance 0.3 +} + +flickerlight DEGORE_X8 +{ + color 0.25 0.05 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +object DegninOre +{ + frame BNG3A { light DEGORE_X1 } + frame BNG3B { light DEGORE_X2 } + frame BNG3C { light DEGORE_X3 } + frame BNG3D { light DEGORE_X4 } + frame BNG3E { light DEGORE_X5 } + frame BNG3F { light DEGORE_X6 } + frame BNG3G { light DEGORE_X7 } + frame BNG3H { light DEGORE_X8 } +} + +// Power Coupling +pointlight POWCOUP1 +{ + color 0.5 0.5 1.0 + size 24 +} + +pointlight POWCOUP2 +{ + color 0.7 0.7 1.0 + size 32 +} + +object PowerCoupling +{ + frame COUPA { light POWCOUP1 } + frame COUPB { light POWCOUP2 } +} + +// Energy Ammo +pointlight ENERGY1 +{ + color 0.4 1.0 0.4 + size 16 +} + +pointlight ENERGY2 +{ + color 0.4 1.0 0.4 + size 32 +} + +object EnergyPod +{ + frame BRY1B { light ENERGY1 } +} + +object EnergyPack +{ + frame CPACB { light ENERGY2 } +} + +// ----------------------- +// -- Strife Characters -- +// ----------------------- + +// Humanoids +flickerlight2 HUMNDATK +{ + color 1.0 0.8 0.2 + size 48 + secondarySize 56 + interval 1 + offset 0 40 0 +} + +object Acolyte +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteTan +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteRed +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteRust +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteGray +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteDGreen +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteGold +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteLGreen +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteBlue +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteShadow +{ + frame AGRDF { light HUMNDATK } +} + +object Rebel +{ + frame HMN1F { light HUMNDATK } +} + +object Rebel1 +{ + frame HMN1F { light HUMNDATK } +} + +object Rebel2 +{ + frame HMN1F { light HUMNDATK } +} + +object Rebel3 +{ + frame HMN1F { light HUMNDATK } +} + +object Rebel4 +{ + frame HMN1F { light HUMNDATK } +} + +object Rebel5 +{ + frame HMN1F { light HUMNDATK } +} + +object Rebel6 +{ + frame HMN1F { light HUMNDATK } +} + +object Macil1 +{ + frame LEADF { light HUMNDATK } +} + +object Macil2 +{ + frame LEADF { light HUMNDATK } +} + +object StrifePlayer +{ + //frame PLAYF { light HUMNDATK } + + frame BURNA { light PHFIRE_FX1 } + frame BURNB { light PHFIRE_FX2 } + frame BURNC { light PHFIRE_FX3 } + frame BURND { light PHFIRE_FX4 } + frame BURNE { light PHFIRE_FX5 } + frame BURNF { light PHFIRE_FX6 } + frame BURNG { light PHFIRE_FX7 } + frame BURNH { light PHFIRE_FX6 } + frame BURNI { light PHFIRE_FX5 } + frame BURNJ { light PHFIRE_FX4 } + frame BURNK { light PHFIRE_FX3 } + frame BURNL { light PHFIRE_FX2 } + frame BURNM { light PHFIRE_FX1 } + frame BURNN { light PHFIRE_FX2 } + frame BURNO { light PHFIRE_FX3 } + frame BURNP { light PHFIRE_FX4 } + frame BURNQ { light PHFIRE_FX5 } + + frame BURNR { light PHFIRE_FX8 } + frame BURNS { light PHFIRE_FX9 } + frame BURNT { light PHFIRE_FX10 } + frame BURNU { light PHFIRE_FX11 } +} + +// Turret +flickerlight2 CTURRETATK1 +{ + color 1.0 0.8 0.2 + size 40 + secondarySize 48 + interval 1 + offset 0 0 0 +} + +flickerlight2 CTURRETATK2 +{ + color 1.0 0.8 0.2 + size 48 + secondarySize 56 + interval 1 + offset 0 0 0 +} + +flickerlight2 CTURRETDTH1 +{ + color 1.0 1.0 1.0 + size 32 + secondarySize 36 + interval 1 + offset 0 0 0 +} + +flickerlight2 CTURRETDTH2 +{ + color 0.9 0.9 0.9 + size 36 + secondarySize 40 + interval 1 + offset 0 0 0 +} + +flickerlight2 CTURRETDTH3 +{ + color 0.7 0.7 0.7 + size 42 + secondarySize 46 + interval 1 + offset 0 0 0 +} + +flickerlight2 CTURRETDTH4 +{ + color 0.5 0.5 0.5 + size 48 + secondarySize 52 + interval 1 + offset 0 0 0 +} + +flickerlight2 CTURRETDTH5 +{ + color 0.3 0.3 0.3 + size 52 + secondarySize 56 + interval 1 + offset 0 0 0 +} + +object CeilingTurret +{ + frame TURTB { light CTURRETATK1 } + frame TURTD { light CTURRETATK2 } + + frame BALLA { light CTURRETDTH1 } + frame BALLB { light CTURRETDTH2 } + frame BALLC { light CTURRETDTH3 } + frame BALLD { light CTURRETDTH4 } + frame BALLE { light CTURRETDTH5 } +} + +// Stalker +flickerlight2 STLKATK +{ + color 1.0 0.8 0.2 + size 48 + secondarySize 56 + interval 1 + offset 0 10 0 +} + +flickerlight STLKDTH1 +{ + color 0.2 1.0 0.2 + size 32 + secondarySize 36 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH2 +{ + color 0.3 1.0 0.3 + size 36 + secondarySize 40 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH3 +{ + color 0.2 1.0 0.2 + size 40 + secondarySize 48 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH4 +{ + color 0.35 1.0 0.35 + size 44 + secondarySize 52 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH5 +{ + color 0.5 1.0 0.2 + size 40 + secondarySize 44 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH6 +{ + color 1.0 0.2 0.0 + size 32 + secondarySize 40 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH7 +{ + color 0.7 0.3 0.0 + size 40 + secondarySize 48 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH8 +{ + color 0.5 0.15 0.0 + size 36 + secondarySize 44 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH9 +{ + color 0.35 0.05 0.0 + size 32 + secondarySize 36 + chance 0.3 + offset 0 15 0 +} + +object Stalker +{ + frame STLKM { light STLKATK } // Not used in Strife + + frame STLKQ { light STLKDTH1 } + frame STLKR { light STLKDTH1 } + frame STLKS { light STLKDTH1 } + frame STLKT { light STLKDTH2 } + frame STLKU { light STLKDTH3 } + frame STLKV { light STLKDTH4 } + frame STLKW { light STLKDTH5 } + frame STLKX { light STLKDTH6 } + frame STLKY { light STLKDTH7 } + frame STLKZ { light STLKDTH8 } + frame STLK[ { light STLKDTH9 } +} + +// Sentinel +flickerlight SNTNLDTH1 +{ + color 1.0 0.4 0.0 + size 24 + secondarySize 36 + chance 0.3 + offset 0 12 0 +} + +flickerlight SNTNLDTH2 +{ + color 1.0 0.6 0.0 + size 48 + secondarySize 56 + chance 0.3 + offset 0 12 0 +} + +object Sentinel +{ + frame SEWRG { light SNTNLDTH1 } + frame SEWRH { light SNTNLDTH2 } +} + +pointlight SNTNL_FX1 +{ + color 1.0 0.0 0.0 + size 16 +} + +pointlight SNTNL_FX2 +{ + color 0.5 0.0 0.0 + size 16 +} + +pointlight SNTNL_FX3 +{ + color 1.0 0.0 0.0 + size 18 +} + +pointlight SNTNL_FX4 +{ + color 0.8 0.0 0.0 + size 20 +} + +pointlight SNTNL_FX5 +{ + color 0.6 0.0 0.0 + size 22 +} + +pointlight SNTNL_FX6 +{ + color 0.4 0.0 0.0 + size 24 +} + +pointlight SNTNL_FX7 +{ + color 0.2 0.0 0.0 + size 28 +} + +object SentinelFX1 +{ + frame SHT1A { light SNTNL_FX1 } + frame SHT1B { light SNTNL_FX2 } + + frame POW1F { light SNTNL_FX3 } + frame POW1G { light SNTNL_FX4 } + frame POW1H { light SNTNL_FX5 } + frame POW1I { light SNTNL_FX6 } + frame POW1J { light SNTNL_FX7 } +} + +object SentinelFX2 +{ + frame SHT1A { light SNTNL_FX1 } + frame SHT1B { light SNTNL_FX2 } + + frame POW1F { light SNTNL_FX3 } + frame POW1G { light SNTNL_FX4 } + frame POW1H { light SNTNL_FX5 } + frame POW1I { light SNTNL_FX6 } + frame POW1J { light SNTNL_FX7 } +} + +// Crusader +flickerlight CRSDRDTH1 +{ + color 1.0 0.5 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 80 0 +} + +flickerlight CRSDRDTH2 +{ + color 1.0 0.8 0.0 + size 68 + secondarySize 74 + chance 0.3 + offset 0 40 0 +} + +flickerlight CRSDRDTH3 +{ + color 1.0 0.8 0.0 + size 72 + secondarySize 76 + chance 0.3 + offset 0 40 0 +} + +flickerlight CRSDRDTH4 +{ + color 1.0 0.9 0.0 + size 76 + secondarySize 80 + chance 0.3 + offset 0 40 0 +} + +flickerlight CRSDRDTH5 +{ + color 1.0 0.6 0.0 + size 80 + secondarySize 84 + chance 0.3 + offset 0 40 0 +} + +object Crusader +{ + frame ROB2H { light CRSDRDTH1 } + frame ROB2I { light CRSDRDTH2 } + frame ROB2J { light CRSDRDTH3 } + frame ROB2K { light CRSDRDTH4 } + frame ROB2L { light CRSDRDTH5 } + frame ROB2M { light CRSDRDTH4 } + frame ROB2N { light CRSDRDTH3 } + frame ROB2O { light CRSDRDTH2 } +} + +object FastFlameMissile +{ + frame FRBLA { light FLMMISSILE } + frame FRBLB { light FLMMISSILE } + frame FRBLC { light FLMMISSILE } + + frame FRBLD { light FLMMSL_X1 } + frame FRBLE { light FLMMSL_X2 } + frame FRBLF { light FLMMSL_X3 } + frame FRBLG { light FLMMSL_X4 } + frame FRBLH { light FLMMSL_X5 } +} + +object CrusaderMissile +{ + frame MICRA { light MISSILE } + + frame SMISA { light MISSILE_X1 } + frame SMISB { light MISSILE_X2 } + frame SMISC { light MISSILE_X3 } + frame SMISD { light MISSILE_X4 } + frame SMISE { light MISSILE_X5 } + frame SMISF { light MISSILE_X6 } + frame SMISG { light MISSILE_X7 } +} + +// Reaver +flickerlight REAV_X1 +{ + color 1.0 0.3 0.0 + size 16 + secondarySize 20 + chance 0.3 + offset 0 16 16 +} + +flickerlight REAV_X2 +{ + color 1.0 0.2 0.0 + size 32 + secondarySize 40 + chance 0.3 + offset 0 32 -16 +} + +flickerlight REAV_X3 +{ + color 1.0 0.6 0.0 + size 40 + secondarySize 44 + chance 0.3 + offset 0 12 16 +} + +flickerlight REAV_X4 +{ + color 1.0 0.5 0.0 + size 20 + secondarySize 24 + chance 0.3 + offset 0 10 0 +} + +flickerlight REAV_X5 +{ + color 1.0 0.8 0.0 + size 28 + secondarySize 32 + chance 0.3 + offset 0 18 0 +} + +flickerlight REAV_X6 +{ + color 1.0 0.7 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 20 0 +} + +flickerlight REAV_X7 +{ + color 0.5 0.05 0.0 + size 52 + secondarySize 56 + chance 0.3 + offset 0 20 0 +} + +object Reaver +{ + frame ROB1F { light HUMNDATK } + + frame ROB1K { light REAV_X1 } + frame ROB1L { light REAV_X2 } + frame ROB1M { light REAV_X3 } + frame ROB1N { light REAV_X4 } + frame ROB1O { light REAV_X5 } + frame ROB1P { light REAV_X6 } + frame ROB1Q { light REAV_X7 } +} + +// Templar +flickerlight2 TEMPATK +{ + color 0.2 1.0 0.2 + size 48 + secondarySize 56 + interval 1 + offset 20 40 0 +} + +flickerlight TEMP_X1 +{ + color 1.0 0.8 0.2 + size 8 + secondarySize 12 + chance 0.3 + offset 0 20 32 +} + +flickerlight TEMP_X2 +{ + color 1.0 0.5 0.0 + size 32 + secondarySize 36 + chance 0.3 + offset 0 20 24 +} + +flickerlight TEMP_X3 +{ + color 1.0 0.75 0.1 + size 24 + secondarySize 28 + chance 0.3 + offset 0 20 24 +} + +flickerlight TEMP_X4 +{ + color 1.0 0.65 0.1 + size 28 + secondarySize 32 + chance 0.3 + offset 0 20 16 +} + +flickerlight TEMP_X5 +{ + color 1.0 0.6 0.0 + size 30 + secondarySize 34 + chance 0.3 + offset 0 20 8 +} + +flickerlight TEMP_X6 +{ + color 1.0 0.5 0.0 + size 32 + secondarySize 36 + chance 0.3 + offset 0 20 0 +} + +object Templar +{ + frame PGRDG { light TEMPATK } + + frame PGRDI { light TEMP_X1 } + frame PGRDJ { light TEMP_X2 } + frame PGRDK { light TEMP_X3 } + frame PGRDL { light TEMP_X4 } + frame PGRDM { light TEMP_X5 } + frame PGRDN { light TEMP_X6 } +} + +// Inquisitor +flickerlight2 INQATK1 +{ + color 1.0 0.6 0.0 + size 88 + secondarySize 96 + interval 1 + offset 20 72 -40 +} + +flickerlight2 INQATK2 +{ + color 1.0 0.6 0.0 + size 88 + secondarySize 96 + interval 1 + offset 20 96 0 +} + +flickerlight2 INQFLY1 +{ + color 0.5 0.5 1.0 + size 80 + secondarySize 84 + interval 1 + offset -40 36 0 +} + +flickerlight2 INQFLY2 +{ + color 0.33 0.33 1.0 + size 64 + secondarySize 72 + interval 1 + offset -40 36 0 +} + +flickerlight INQDTH1 +{ + color 1.0 0.4 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 72 0 +} + +flickerlight INQDTH2 +{ + color 1.0 0.7 0.0 + size 84 + secondarySize 96 + chance 0.3 + offset 0 64 0 +} + +flickerlight INQDTH3 +{ + color 1.0 0.6 0.0 + size 92 + secondarySize 100 + chance 0.3 + offset 0 56 0 +} + +flickerlight INQDTH4 +{ + color 0.7 0.07 0.0 + size 72 + secondarySize 80 + chance 0.3 + offset 0 40 0 +} + +flickerlight INQDTH5 +{ + color 0.3 0.0 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 40 0 +} + +flickerlight INQDTH6 +{ + color 0.5 0.3 0.0 + size 32 + secondarySize 40 + chance 0.3 + offset 0 32 0 +} + +flickerlight INQDTH7 +{ + color 1.0 0.6 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 32 0 +} + +flickerlight INQDTH8 +{ + color 1.0 0.7 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 32 0 +} + +flickerlight INQDTH9 +{ + color 1.0 0.7 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 56 0 +} + +flickerlight INQDTH10 +{ + color 1.0 0.6 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 56 0 +} + +flickerlight INQDTH11 +{ + color 1.0 0.5 0.0 + size 100 + secondarySize 128 + chance 0.3 + offset 0 32 0 +} + +flickerlight INQDTH12 +{ + color 1.0 0.4 0.0 + size 80 + secondarySize 96 + chance 0.3 + offset 0 32 0 +} + +flickerlight INQDTH13 +{ + color 1.0 0.3 0.0 + size 60 + secondarySize 72 + chance 0.3 + offset 0 24 0 +} + +flickerlight INQDTH14 +{ + color 0.5 0.15 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 18 0 +} + +object Inquisitor +{ + frame ROB3F { light INQATK1 } + frame ROB3J { light INQATK2 } + + frame ROB3H { light INQFLY1 } + frame ROB3I { light INQFLY2 } + + frame ROB3M { light INQDTH1 } + frame ROB3N { light INQDTH2 } + frame ROB3O { light INQDTH3 } + frame ROB3P { light INQDTH4 } + frame ROB3Q { light INQDTH5 } + frame ROB3R { light INQDTH6 } + frame ROB3S { light INQDTH6 } + frame ROB3T { light INQDTH6 } + frame ROB3U { light INQDTH7 } + frame ROB3V { light INQDTH8 } + frame ROB3W { light INQDTH6 } + frame ROB3X { light INQDTH6 } + frame ROB3Y { light INQDTH9 } + frame ROB3Z { light INQDTH10 } + frame ROB3[ { light INQDTH11 } + frame ROB3\ { light INQDTH12 } + frame RBB3] { light INQDTH13 } + frame RBB3A { light INQDTH12 } + frame RBB3B { light INQDTH13 } + frame RBB3C { light INQDTH14 } +} + +flickerlight INQSHOT_X1 +{ + color 1.0 0.8 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight INQSHOT_X2 +{ + color 1.0 0.7 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight INQSHOT_X3 +{ + color 0.8 0.45 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight INQSHOT_X4 +{ + color 0.5 0.3 0.0 + size 80 + secondarySize 84 + chance 0.3 +} + +flickerlight INQSHOT_X5 +{ + color 1.0 0.6 0.0 + size 56 + secondarySize 60 + chance 0.3 +} + +flickerlight INQSHOT_X6 +{ + color 1.0 0.7 0.0 + size 60 + secondarySize 64 + chance 0.3 +} + +flickerlight INQSHOT_X7 +{ + color 1.0 0.7 0.0 + size 64 + secondarySize 68 + chance 0.3 +} + +flickerlight INQSHOT_X8 +{ + color 1.0 0.6 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight INQSHOT_X9 +{ + color 1.0 0.4 0.0 + size 24 + secondarySize 32 + chance 0.3 +} + +object InquisitorShot +{ + frame BNG2A { light INQSHOT_X1 } + frame BNG2B { light INQSHOT_X2 } + frame BNG2C { light INQSHOT_X3 } + frame BNG2D { light INQSHOT_X4 } + frame BNG2E { light INQSHOT_X5 } + frame BNG2F { light INQSHOT_X6 } + frame BNG2G { light INQSHOT_X7 } + frame BNG2H { light INQSHOT_X8 } + frame BNG2I { light INQSHOT_X9 } +} + +// Programmer +flickerlight PROGATK1 +{ + color 0.5 0.5 1.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 60 0 +} + +flickerlight PROGATK2 +{ + color 0.6 0.6 1.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 60 0 +} + +flickerlight PROGATK3 +{ + color 0.8 0.8 1.0 + size 80 + secondarySize 96 + chance 0.3 + offset 0 60 0 +} + +flickerlight PROGDTH1 +{ + color 1.0 0.4 0.0 + size 112 + secondarySize 128 + chance 0.3 + offset 0 40 0 +} + +flickerlight PROGDTH2 +{ + color 1.0 0.6 0.0 + size 128 + secondarySize 140 + chance 0.3 + offset 0 40 0 +} + +object Programmer +{ + frame PRGRH { light PROGATK1 } + frame PRGRI { light PROGATK2 } + frame PRGRJ { light PROGATK3 } + + frame PRGRN { light PROGDTH1 } + frame PRGRO { light PROGDTH2 } +} + +flickerlight BASE_X1 +{ + color 1.0 0.55 0.0 + size 96 + secondarySize 112 + chance 0.3 + offset 0 40 0 +} + +flickerlight BASE_X2 +{ + color 1.0 0.50 0.0 + size 80 + secondarySize 96 + chance 0.3 + offset 0 40 0 +} + +flickerlight BASE_X3 +{ + color 0.5 0.2 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 32 0 +} + +object ProgrammerBase +{ + frame BASEA { light BASE_X1 } + frame BASEB { light BASE_X2 } + frame BASEC { light BASE_X3 } +} + +// Bishop +flickerlight BISHOP +{ + color 1.0 1.0 1.0 + size 96 + secondarySize 108 + chance 0.3 + offset 0 120 0 +} + +object StrifeBishop +{ + frame MLDRE { light BISHOP } +} + +object BishopMissile +{ + frame MISS { light MISSILE } + + frame SMISA { light MISSILE_X1} + frame SMISB { light MISSILE_X2} + frame SMISC { light MISSILE_X3} + frame SMISD { light MISSILE_X4} + frame SMISE { light MISSILE_X5} + frame SMISF { light MISSILE_X6} + frame SMISG { light MISSILE_X7} +} + +// ------------------ +// - Strife Objects - +// ------------------ + +// Lights +pointlight LIGHT1 +{ + color 1.0 1.0 1.0 + size 56 + offset 0 30 0 +} + +pointlight LIGHT2 +{ + color 1.0 1.0 1.0 + size 40 + offset 0 72 0 +} + +pointlight LIGHT3 +{ + color 1.0 1.0 1.0 + size 64 +} + +pointlight LIGHT4 +{ + color 1.0 1.0 1.0 + size 64 + offset 0 80 0 +} + +pointlight LIGHT5 +{ + color 1.0 1.0 1.0 + size 56 + offset 0 72 0 +} + +pointlight CLIGHT1 +{ + color 1.0 1.0 0.0 + size 24 + offset 0 12 0 +} + +pulselight CLIGHT2 +{ + color 1.0 1.0 0.0 + size 48 + secondarySize 50 + interval 8.0 + offset 0 64 0 +} + +pulselight LLIGHT +{ + color 1.0 0.5 0.0 + size 24 + secondarySize 32 + interval 12.0 + offset 0 76 0 +} + +pulselight TLLIGHT1 +{ + color 0.9 0.9 1.0 + size 56 + secondarySize 64 + interval 3.0 + offset 0 48 0 +} + +pointlight TLLIGHT2 +{ + color 1.0 1.0 0.5 + size 80 + offset 0 56 0 +} + +flickerlight HTECH +{ + color 0.3 1.0 0.3 + size 96 + secondarySize 104 + chance 0.5 + offset 0 80 0 +} + +pulselight BCOLUMN +{ + color 0.5 1.0 0.5 + size 120 + secondarySize 128 + interval 10.0 + offset 0 64 0 +} + +pulselight FBUBBLE +{ + color 0.5 1.0 0.5 + size 60 + secondarySize 64 + interval 10.0 + offset 0 32 0 +} + +pulselight CBUBBLE +{ + color 0.5 1.0 0.5 + size 60 + secondarySize 64 + interval 10.0 +} + +pointlight SPIDLGHT1 +{ + color 0.5 1.0 0.5 + size 64 + offset 0 10 0 +} + +pointlight SPIDLGHT2 +{ + color 0.2 0.75 0.2 + size 56 + offset 0 10 0 +} + +pointlight SPIDLGHT3 +{ + color 0.0 0.25 0.0 + size 48 + offset 0 10 0 +} + +object LightSilverFluorescent +{ + frame LITS { light LIGHT1 } +} + +object LightBrownFluorescent +{ + frame LITB { light LIGHT1 } +} + +object LightGoldFluorescent +{ + frame LITG { light LIGHT1 } +} + +object LightGlobe +{ + frame LITE { light LIGHT5 } +} + +object PillarHugeTech +{ + frame HUGE { light HTECH } +} + +object Candle +{ + frame KNDL { light CLIGHT1 } +} + +object StrifeCandelabra +{ + frame CLBR { light CLIGHT2 } +} + +object CageLight +{ + frame CAGE { light LIGHT3 } +} + +object OutsideLamp +{ + frame LAMP { light LIGHT4 } +} + +object PoleLantern +{ + frame LANT { light LLIGHT } +} + +object TechLampSilver +{ + frame TECHA { light TLLIGHT1 } +} + +object TechLampBrass +{ + frame TECHB { light TLLIGHT2 } +} + +object AlienBubbleColumn +{ + frame BUBB { light BCOLUMN } +} + +object AlienFloorBubble +{ + frame BUBF { light FBUBBLE } +} + +object AlienCeilingBubble +{ + frame BUBC { light CBUBBLE } +} + +object AlienSpiderLight +{ + frame SPDLA { light SPIDLGHT1 } + frame SPDLB { light SPIDLGHT2 } + frame SPDLC { light SPIDLGHT3 } +} + +// Burning Things +flickerlight BBARREL +{ + color 1.0 0.6 0.0 + size 32 + secondarySize 40 + chance 0.8 + offset 0 32 0 +} + +flickerlight BBOWL +{ + color 1.0 0.7 0.0 + size 24 + secondarySize 32 + chance 0.5 + offset 0 10 0 +} + +flickerlight BBRAZIER +{ + color 1.0 0.8 0.0 + size 40 + secondarySize 48 + chance 0.2 + offset 0 32 0 +} + +pulselight STORCH +{ + color 1.0 0.6 0.0 + size 28 + secondarySize 32 + interval 5.0 + offset 0 56 0 +} + +pulselight MTORCH +{ + color 1.0 0.6 0.0 + size 56 + secondarySize 64 + interval 5.0 + offset 0 64 0 +} + +pulselight LTORCH +{ + color 1.0 0.8 0.0 + size 64 + secondarySize 72 + interval 2.0 + offset 0 64 0 +} + +pulselight HTORCH +{ + color 1.0 0.6 0.0 + size 72 + secondarySize 76 + interval 3.0 + offset 0 72 0 +} + +object StrifeBurningBarrel +{ + frame BBAR { light BBARREL } +} + +object BurningBowl +{ + frame BOWL { light BBOWL } +} + +object BurningBrazier +{ + frame BRAZ { light BBRAZIER } +} + +object SmallTorchLit +{ + frame TRHL { light STORCH } +} + +object MediumTorch +{ + frame LTRH { light MTORCH } +} + +object LargeTorch +{ + frame LMPC { light LTORCH } +} + +object HugeTorch +{ + frame LOGS { light HTORCH } +} + +// Power Crystal +pointlight PCRYSTAL +{ + color 1.0 1.0 0.0 + size 40 + offset 0 16 0 +} + +pointlight PCRYSTAL1 +{ + color 0.4 0.4 1.0 + size 24 + offset 0 12 0 +} + +pointlight PCRYSTAL2 +{ + color 0.5 0.5 1.0 + size 30 + offset 0 18 0 +} + +pointlight PCRYSTAL3 +{ + color 0.45 0.45 1.0 + size 32 + offset 0 24 0 +} + +pointlight PCRYSTAL4 +{ + color 0.35 0.35 1.0 + size 28 + offset 0 32 0 +} + +pointlight PCRYSTAL5 +{ + color 0.1 0.1 1.0 + size 18 + offset 0 40 0 +} + +flickerlight POWCRYS_X1 +{ + color 1.0 0.7 0.1 + size 108 + secondarySize 112 + chance 0.3 +} + +flickerlight POWCRYS_X2 +{ + color 1.0 0.75 0.2 + size 112 + secondarySize 116 + chance 0.3 +} + +flickerlight POWCRYS_X3 +{ + color 1.0 0.8 0.4 + size 116 + secondarySize 120 + chance 0.3 +} + +flickerlight POWCRYS_X4 +{ + color 1.0 0.75 0.3 + size 115 + secondarySize 117 + chance 0.3 +} + +flickerlight POWCRYS_X5 +{ + color 1.0 0.7 0.27 + size 114 + secondarySize 113 + chance 0.3 +} + +flickerlight POWCRYS_X6 +{ + color 1.0 0.65 0.24 + size 113 + secondarySize 115 + chance 0.3 +} + +flickerlight POWCRYS_X6 +{ + color 1.0 0.62 0.22 + size 112 + secondarySize 114 + chance 0.3 +} + +flickerlight POWCRYS_X7 +{ + color 1.0 0.6 0.20 + size 111 + secondarySize 113 + chance 0.3 +} + +flickerlight POWCRYS_X8 +{ + color 1.0 0.58 0.18 + size 110 + secondarySize 112 + chance 0.3 +} + +flickerlight POWCRYS_X9 +{ + color 1.0 0.56 0.16 + size 109 + secondarySize 111 + chance 0.3 +} + +flickerlight POWCRYS_X10 +{ + color 1.0 0.54 0.14 + size 108 + secondarySize 110 + chance 0.3 +} + +flickerlight POWCRYS_X11 +{ + color 1.0 0.52 0.12 + size 107 + secondarySize 109 + chance 0.3 +} + +flickerlight POWCRYS_X12 +{ + color 1.0 0.5 0.10 + size 106 + secondarySize 108 + chance 0.3 +} + +flickerlight POWCRYS_X13 +{ + color 1.0 0.48 0.10 + size 105 + secondarySize 106 + chance 0.3 +} + +flickerlight POWCRYS_X14 +{ + color 1.0 0.46 0.08 + size 103 + secondarySize 104 + chance 0.3 +} + +flickerlight POWCRYS_X15 +{ + color 1.0 0.44 0.06 + size 102 + secondarySize 104 + chance 0.3 +} + +flickerlight POWCRYS_X16 +{ + color 1.0 0.42 0.04 + size 101 + secondarySize 103 + chance 0.3 +} + +flickerlight POWCRYS_X15 +{ + color 1.0 0.4 0.02 + size 100 + secondarySize 102 + chance 0.3 +} + +flickerlight POWCRYS_X16 +{ + color 1.0 0.38 0.0 + size 99 + secondarySize 101 + chance 0.3 +} + +flickerlight POWCRYS_X17 +{ + color 1.0 0.36 0.02 + size 98 + secondarySize 100 + chance 0.3 +} + +flickerlight POWCRYS_X18 +{ + color 1.0 0.34 0.0 + size 97 + secondarySize 100 + chance 0.3 +} + +flickerlight POWCRYS_X19 +{ + color 1.0 0.32 0.0 + size 96 + secondarySize 99 + chance 0.3 +} + +flickerlight POWCRYS_X20 +{ + color 1.0 0.3 0.0 + size 95 + secondarySize 98 + chance 0.3 +} + +flickerlight POWCRYS_X21 +{ + color 1.0 0.28 0.0 + size 94 + secondarySize 93 + chance 0.3 +} + +flickerlight POWCRYS_X22 +{ + color 1.0 0.26 0.0 + size 93 + secondarySize 92 + chance 0.3 +} + +flickerlight POWCRYS_X23 +{ + color 1.0 0.24 0.0 + size 92 + secondarySize 91 + chance 0.3 +} + +flickerlight POWCRYS_X24 +{ + color 1.0 0.22 0.0 + size 90 + secondarySize 92 + chance 0.3 +} + +flickerlight POWCRYS_X25 +{ + color 1.0 0.2 0.0 + size 86 + secondarySize 90 + chance 0.3 +} + +object PowerCrystal +{ + frame CRYS { light PCRYSTAL } + + frame CRYSB { light PCRYSTAL1 } + frame CRYSC { light PCRYSTAL2 } + frame CRYSD { light PCRYSTAL3 } + frame CRYSE { light PCRYSTAL4 } + frame CRYSF { light PCRYSTAL5 } + + frame BOOMA { light POWCRYS_X1 } + frame BOOMB { light POWCRYS_X2 } + frame BOOMC { light POWCRYS_X3 } + frame BOOMD { light POWCRYS_X4 } + frame BOOME { light POWCRYS_X5 } + frame BOOMF { light POWCRYS_X6 } + frame BOOMG { light POWCRYS_X7 } + frame BOOMH { light POWCRYS_X8 } + frame BOOMI { light POWCRYS_X9 } + frame BOOMJ { light POWCRYS_X10 } + frame BOOMK { light POWCRYS_X11 } + frame BOOML { light POWCRYS_X12 } + frame BOOMM { light POWCRYS_X13 } + frame BOOMN { light POWCRYS_X14 } + frame BOOMO { light POWCRYS_X15 } + frame BOOMP { light POWCRYS_X16 } + frame BOOMQ { light POWCRYS_X17 } + frame BOOMR { light POWCRYS_X18 } + frame BOOMS { light POWCRYS_X19 } + frame BOOMT { light POWCRYS_X20 } + frame BOOMU { light POWCRYS_X21 } + frame BOOMV { light POWCRYS_X22 } + frame BOOMW { light POWCRYS_X23 } + frame BOOMX { light POWCRYS_X24 } + frame BOOMY { light POWCRYS_X25 } +} + +// Computer +pulselight COMPUTER +{ + color 0.25 1.0 0.25 + size 112 + secondarySize 128 + interval 0.25 + offset 0 64 0 +} + +object Computer +{ + frame SECRA { light COMPUTER } + frame SECRB { light COMPUTER } + frame SECRC { light COMPUTER } + frame SECRD { light COMPUTER } +} + +// Strife Explosive Barrel +flickerlight BARREL_X1 +{ + color 1.0 0.6 0.1 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight BARREL_X2 +{ + color 1.0 0.8 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight BARREL_X3 +{ + color 1.0 0.7 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight BARREL_X4 +{ + color 1.0 0.6 0.0 + size 80 + secondarySize 88 + chance 0.3 +} + +flickerlight BARREL_X5 +{ + color 1.0 0.5 0.0 + size 72 + secondarySize 76 + chance 0.3 +} + +flickerlight BARREL_X6 +{ + color 1.0 0.45 0.0 + size 56 + secondarySize 60 + chance 0.3 +} + +flickerlight BARREL_X7 +{ + color 1.0 0.4 0.0 + size 52 + secondarySize 56 + chance 0.3 + offset 0 24 0 +} + +flickerlight BARREL_X8 +{ + color 1.0 0.35 0.0 + size 36 + secondarySize 40 + chance 0.3 + offset 0 40 0 +} + +flickerlight BARREL_X9 +{ + color 1.0 0.3 0.0 + size 16 + secondarySize 24 + chance 0.3 + offset 0 56 0 +} + +object ExplosiveBarrel2 +{ + frame BARTC { light BARREL_X1 } + frame BARTD { light BARREL_X2 } + frame BARTE { light BARREL_X3 } + frame BARTF { light BARREL_X4 } + frame BARTG { light BARREL_X5 } + frame BARTH { light BARREL_X6 } + frame BARTI { light BARREL_X7 } + frame BARTJ { light BARREL_X8 } + frame BARTK { light BARREL_X9 } +} + +// Alarm +pointlight KLAXON +{ + color 1.0 0.0 0.0 + size 24 +} + +object KlaxonWarningLight +{ + frame KLAXC { light KLAXON } +} + +// ------------------ +// - Strife Effects - +// ------------------ + +// Bang Cloud +object Bang4Cloud +{ + frame BNG4B { light POWCRYS_X2 } + frame BNG4C { light POWCRYS_X3 } + frame BNG4D { light POWCRYS_X4 } + frame BNG4E { light POWCRYS_X5 } + frame BNG4F { light POWCRYS_X6 } + frame BNG4G { light POWCRYS_X7 } + frame BNG4H { light POWCRYS_X8 } + frame BNG4I { light POWCRYS_X9 } + frame BNG4J { light POWCRYS_X10 } + + frame BNG4K { light HEGRENADE_X1 } + frame BNG4L { light HEGRENADE_X2 } + frame BNG4M { light HEGRENADE_X3 } + frame BNG4N { light HEGRENADE_X4 } +} + +// Fire Droplet +object FireDroplet +{ + frame FFOTA { light PHFIRE_FX8 } + frame FFOTB { light PHFIRE_FX9 } + frame FFOTC { light PHFIRE_FX10 } + frame FFOTD { light PHFIRE_FX11 } +} + +// Lighning +flickerlight ZAPBALL1 +{ + color 0.8 0.8 1.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight ZAPBALL2 +{ + color 0.8 0.8 1.0 + size 128 + secondarySize 144 + chance 0.5 +} + +flickerlight LIGHTNING1 +{ + color 0.8 0.8 1.0 + size 72 + secondarySize 80 + chance 0.8 +} + +flickerlight LIGHTNING2 +{ + color 0.8 0.8 1.0 + size 80 + secondarySize 96 + chance 0.8 +} + +flickerlight LIGHT_SPT +{ + color 0.8 0.8 1.0 + size 24 + secondarySize 32 + chance 0.8 +} + +flickerlight LGNTAIL +{ + color 0.4 0.4 0.5 + size 72 + secondarySize 80 + chance 0.8 +} + +object StrifeZap1 +{ + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningBase +{ + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningBall1 +{ + frame ZOT3 { light ZAPBALL1 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningBall2 +{ + frame ZOT3 { light ZAPBALL1 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningBigBall1 +{ + frame ZOT7 { light ZAPBALL2 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningBigBall2 +{ + frame ZOT7 { light ZAPBALL2 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningH1 +{ + frame ZAP6 { light LIGHTNING1 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningH2 +{ + frame ZAP6 { light LIGHTNING1 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningH3 +{ + frame ZAP6 { light LIGHTNING1 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningHTail +{ + frame ZAP6 { light LGNTAIL } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningV1 +{ + frame ZOT1 { light LIGHTNING1 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningV2 +{ + frame ZOT1 { light LIGHTNING1 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningSpot +{ + frame ZAP5 { light LIGHT_SPT } +} + +object SpectralLightningBigV1 +{ + frame ZOT2 { light LIGHTNING2 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningBigV2 +{ + frame ZOT2 { light LIGHTNING2 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +// Teleport +pointlight TFOG1 +{ + color 0.5 0.5 0.25 + size 32 + offset 0 40 0 +} + +pointlight TFOG2 +{ + color 0.5 0.5 0.25 + size 40 + offset 0 40 0 +} + +pointlight TFOG3 +{ + color 0.5 0.5 0.25 + size 48 + offset 0 40 0 +} + +pointlight TFOG4 +{ + color 0.5 0.5 0.25 + size 56 + offset 0 40 0 +} + +pointlight TFOG5 +{ + color 0.5 0.5 0.25 + size 64 + offset 0 40 0 +} + +pointlight TFOG6 +{ + color 0.5 0.5 0.25 + size 72 + offset 0 40 0 +} + +object TeleportFog +{ + frame TFOGA { light TFOG1 } + frame TFOGB { light TFOG2 } + frame TFOGC { light TFOG3 } + frame TFOGD { light TFOG4 } + frame TFOGE { light TFOG5 } + frame TFOGF { light TFOG6 } +} \ No newline at end of file From 399d0974abb54cb53fa7b643bd1b27cc39523d28 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 23 Jun 2013 09:49:34 +0200 Subject: [PATCH 0003/1509] - added GL render as of SVN revision 1600. --- src/gl/data/gl_data.cpp | 524 +++ src/gl/data/gl_data.h | 61 + src/gl/data/gl_portaldata.cpp | 473 +++ src/gl/data/gl_sections.cpp | 847 ++++ src/gl/data/gl_sections.h | 56 + src/gl/data/gl_setup.cpp | 736 ++++ src/gl/data/gl_vertexbuffer.cpp | 420 ++ src/gl/data/gl_vertexbuffer.h | 62 + src/gl/dynlights/a_dynlight.cpp | 742 ++++ src/gl/dynlights/gl_dynlight.cpp | 1365 +++++++ src/gl/dynlights/gl_dynlight.h | 191 + src/gl/dynlights/gl_dynlight1.cpp | 261 ++ src/gl/dynlights/gl_glow.cpp | 139 + src/gl/dynlights/gl_glow.h | 10 + src/gl/dynlights/gl_lightbuffer.cpp | 243 ++ src/gl/dynlights/gl_lightbuffer.h | 66 + src/gl/gl_builddraw.cpp | 594 +++ src/gl/gl_functions.h | 13 + src/gl/hqnx/Image.cpp | 1174 ++++++ src/gl/hqnx/Image.h | 145 + src/gl/hqnx/gl_hqresize.cpp | 280 ++ src/gl/hqnx/hq2x.cpp | 2987 ++++++++++++++ src/gl/hqnx/hq3x.cpp | 3868 ++++++++++++++++++ src/gl/hqnx/hq4x.cpp | 5469 ++++++++++++++++++++++++++ src/gl/hqnx/hqnx.h | 35 + src/gl/models/gl_models.cpp | 922 +++++ src/gl/models/gl_models.h | 365 ++ src/gl/models/gl_models_md2.cpp | 509 +++ src/gl/models/gl_models_md3.cpp | 313 ++ src/gl/models/gl_voxels.cpp | 504 +++ src/gl/models/tab_anorms.h | 489 +++ src/gl/renderer/gl_colormap.h | 79 + src/gl/renderer/gl_lightdata.cpp | 654 +++ src/gl/renderer/gl_lightdata.h | 66 + src/gl/renderer/gl_renderer.cpp | 634 +++ src/gl/renderer/gl_renderer.h | 178 + src/gl/renderer/gl_renderstate.cpp | 352 ++ src/gl/renderer/gl_renderstate.h | 278 ++ src/gl/scene/gl_bsp.cpp | 563 +++ src/gl/scene/gl_clipper.cpp | 458 +++ src/gl/scene/gl_clipper.h | 152 + src/gl/scene/gl_decal.cpp | 428 ++ src/gl/scene/gl_drawinfo.cpp | 1221 ++++++ src/gl/scene/gl_drawinfo.h | 279 ++ src/gl/scene/gl_fakeflat.cpp | 397 ++ src/gl/scene/gl_flats.cpp | 809 ++++ src/gl/scene/gl_portal.cpp | 1081 +++++ src/gl/scene/gl_portal.h | 300 ++ src/gl/scene/gl_renderhacks.cpp | 1247 ++++++ src/gl/scene/gl_scene.cpp | 1270 ++++++ src/gl/scene/gl_sky.cpp | 353 ++ src/gl/scene/gl_skydome.cpp | 613 +++ src/gl/scene/gl_sprite.cpp | 991 +++++ src/gl/scene/gl_spritelight.cpp | 300 ++ src/gl/scene/gl_vertex.cpp | 195 + src/gl/scene/gl_wall.h | 365 ++ src/gl/scene/gl_walls.cpp | 1793 +++++++++ src/gl/scene/gl_walls_draw.cpp | 592 +++ src/gl/scene/gl_weapon.cpp | 407 ++ src/gl/shaders/gl_shader.cpp | 679 ++++ src/gl/shaders/gl_shader.h | 160 + src/gl/shaders/gl_texshader.cpp | 698 ++++ src/gl/shaders/gl_texshader.h | 96 + src/gl/system/gl_cvars.h | 59 + src/gl/system/gl_framebuffer.cpp | 559 +++ src/gl/system/gl_framebuffer.h | 117 + src/gl/system/gl_interface.cpp | 1084 +++++ src/gl/system/gl_interface.h | 249 ++ src/gl/system/gl_menu.cpp | 137 + src/gl/system/gl_system.h | 124 + src/gl/system/gl_threads.cpp | 0 src/gl/system/gl_threads.h | 247 ++ src/gl/system/gl_wipe.cpp | 551 +++ src/gl/textures/gl_bitmap.cpp | 286 ++ src/gl/textures/gl_bitmap.h | 34 + src/gl/textures/gl_hirestex.cpp | 373 ++ src/gl/textures/gl_hqresize.cpp | 291 ++ src/gl/textures/gl_hwtexture.cpp | 420 ++ src/gl/textures/gl_hwtexture.h | 77 + src/gl/textures/gl_material.cpp | 1123 ++++++ src/gl/textures/gl_material.h | 254 ++ src/gl/textures/gl_skyboxtexture.cpp | 229 ++ src/gl/textures/gl_skyboxtexture.h | 45 + src/gl/textures/gl_texture.cpp | 857 ++++ src/gl/textures/gl_texture.h | 88 + src/gl/textures/gl_translate.cpp | 88 + src/gl/textures/gl_translate.h | 42 + src/gl/utility/gl_clock.cpp | 222 ++ src/gl/utility/gl_clock.h | 122 + src/gl/utility/gl_convert.h | 9 + src/gl/utility/gl_cycler.cpp | 155 + src/gl/utility/gl_cycler.h | 52 + src/gl/utility/gl_geometric.cpp | 258 ++ src/gl/utility/gl_geometric.h | 251 ++ src/gl/utility/gl_templates.h | 82 + src/sdl/hardware.cpp | 44 +- src/sdl/sdlglvideo.cpp | 417 ++ src/sdl/sdlglvideo.h | 78 + src/textures/textures.h | 72 +- src/win32/hardware.cpp | 59 +- src/win32/win32gliface.cpp | 564 +++ src/win32/win32gliface.h | 147 + src/win32/zdoom.rc | 20 +- 103 files changed, 51414 insertions(+), 23 deletions(-) create mode 100644 src/gl/data/gl_data.cpp create mode 100644 src/gl/data/gl_data.h create mode 100644 src/gl/data/gl_portaldata.cpp create mode 100644 src/gl/data/gl_sections.cpp create mode 100644 src/gl/data/gl_sections.h create mode 100644 src/gl/data/gl_setup.cpp create mode 100644 src/gl/data/gl_vertexbuffer.cpp create mode 100644 src/gl/data/gl_vertexbuffer.h create mode 100644 src/gl/dynlights/a_dynlight.cpp create mode 100644 src/gl/dynlights/gl_dynlight.cpp create mode 100644 src/gl/dynlights/gl_dynlight.h create mode 100644 src/gl/dynlights/gl_dynlight1.cpp create mode 100644 src/gl/dynlights/gl_glow.cpp create mode 100644 src/gl/dynlights/gl_glow.h create mode 100644 src/gl/dynlights/gl_lightbuffer.cpp create mode 100644 src/gl/dynlights/gl_lightbuffer.h create mode 100644 src/gl/gl_builddraw.cpp create mode 100644 src/gl/gl_functions.h create mode 100644 src/gl/hqnx/Image.cpp create mode 100644 src/gl/hqnx/Image.h create mode 100644 src/gl/hqnx/gl_hqresize.cpp create mode 100644 src/gl/hqnx/hq2x.cpp create mode 100644 src/gl/hqnx/hq3x.cpp create mode 100644 src/gl/hqnx/hq4x.cpp create mode 100644 src/gl/hqnx/hqnx.h create mode 100644 src/gl/models/gl_models.cpp create mode 100644 src/gl/models/gl_models.h create mode 100644 src/gl/models/gl_models_md2.cpp create mode 100644 src/gl/models/gl_models_md3.cpp create mode 100644 src/gl/models/gl_voxels.cpp create mode 100644 src/gl/models/tab_anorms.h create mode 100644 src/gl/renderer/gl_colormap.h create mode 100644 src/gl/renderer/gl_lightdata.cpp create mode 100644 src/gl/renderer/gl_lightdata.h create mode 100644 src/gl/renderer/gl_renderer.cpp create mode 100644 src/gl/renderer/gl_renderer.h create mode 100644 src/gl/renderer/gl_renderstate.cpp create mode 100644 src/gl/renderer/gl_renderstate.h create mode 100644 src/gl/scene/gl_bsp.cpp create mode 100644 src/gl/scene/gl_clipper.cpp create mode 100644 src/gl/scene/gl_clipper.h create mode 100644 src/gl/scene/gl_decal.cpp create mode 100644 src/gl/scene/gl_drawinfo.cpp create mode 100644 src/gl/scene/gl_drawinfo.h create mode 100644 src/gl/scene/gl_fakeflat.cpp create mode 100644 src/gl/scene/gl_flats.cpp create mode 100644 src/gl/scene/gl_portal.cpp create mode 100644 src/gl/scene/gl_portal.h create mode 100644 src/gl/scene/gl_renderhacks.cpp create mode 100644 src/gl/scene/gl_scene.cpp create mode 100644 src/gl/scene/gl_sky.cpp create mode 100644 src/gl/scene/gl_skydome.cpp create mode 100644 src/gl/scene/gl_sprite.cpp create mode 100644 src/gl/scene/gl_spritelight.cpp create mode 100644 src/gl/scene/gl_vertex.cpp create mode 100644 src/gl/scene/gl_wall.h create mode 100644 src/gl/scene/gl_walls.cpp create mode 100644 src/gl/scene/gl_walls_draw.cpp create mode 100644 src/gl/scene/gl_weapon.cpp create mode 100644 src/gl/shaders/gl_shader.cpp create mode 100644 src/gl/shaders/gl_shader.h create mode 100644 src/gl/shaders/gl_texshader.cpp create mode 100644 src/gl/shaders/gl_texshader.h create mode 100644 src/gl/system/gl_cvars.h create mode 100644 src/gl/system/gl_framebuffer.cpp create mode 100644 src/gl/system/gl_framebuffer.h create mode 100644 src/gl/system/gl_interface.cpp create mode 100644 src/gl/system/gl_interface.h create mode 100644 src/gl/system/gl_menu.cpp create mode 100644 src/gl/system/gl_system.h create mode 100644 src/gl/system/gl_threads.cpp create mode 100644 src/gl/system/gl_threads.h create mode 100644 src/gl/system/gl_wipe.cpp create mode 100644 src/gl/textures/gl_bitmap.cpp create mode 100644 src/gl/textures/gl_bitmap.h create mode 100644 src/gl/textures/gl_hirestex.cpp create mode 100644 src/gl/textures/gl_hqresize.cpp create mode 100644 src/gl/textures/gl_hwtexture.cpp create mode 100644 src/gl/textures/gl_hwtexture.h create mode 100644 src/gl/textures/gl_material.cpp create mode 100644 src/gl/textures/gl_material.h create mode 100644 src/gl/textures/gl_skyboxtexture.cpp create mode 100644 src/gl/textures/gl_skyboxtexture.h create mode 100644 src/gl/textures/gl_texture.cpp create mode 100644 src/gl/textures/gl_texture.h create mode 100644 src/gl/textures/gl_translate.cpp create mode 100644 src/gl/textures/gl_translate.h create mode 100644 src/gl/utility/gl_clock.cpp create mode 100644 src/gl/utility/gl_clock.h create mode 100644 src/gl/utility/gl_convert.h create mode 100644 src/gl/utility/gl_cycler.cpp create mode 100644 src/gl/utility/gl_cycler.h create mode 100644 src/gl/utility/gl_geometric.cpp create mode 100644 src/gl/utility/gl_geometric.h create mode 100644 src/gl/utility/gl_templates.h create mode 100644 src/sdl/sdlglvideo.cpp create mode 100644 src/sdl/sdlglvideo.h create mode 100644 src/win32/win32gliface.cpp create mode 100644 src/win32/win32gliface.h diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp new file mode 100644 index 000000000..5a2508968 --- /dev/null +++ b/src/gl/data/gl_data.cpp @@ -0,0 +1,524 @@ +/* +** gl_data.cpp +** Maintenance data for GL renderer (mostly to handle rendering hacks) +** +**--------------------------------------------------------------------------- +** Copyright 2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" + +#include "doomtype.h" +#include "colormatcher.h" +#include "i_system.h" +#include "p_local.h" +#include "p_lnspec.h" +#include "c_dispatch.h" +#include "r_sky.h" +#include "sc_man.h" +#include "w_wad.h" +#include "gi.h" +#include "g_level.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/models/gl_models.h" +#include "gl/utility/gl_clock.h" +#include "gl/shaders/gl_shader.h" +#include "gl/gl_functions.h" + +GLRenderSettings glset; +long gl_frameMS; +long gl_frameCount; + +EXTERN_CVAR(Int, gl_lightmode) +EXTERN_CVAR(Bool, gl_brightfog) + +CUSTOM_CVAR(Float, maxviewpitch, 90.f, CVAR_ARCHIVE|CVAR_SERVERINFO) +{ + if (self>90.f) self=90.f; + else if (self<-90.f) self=-90.f; +} + +CUSTOM_CVAR(Bool, gl_notexturefill, false, 0) +{ + glset.notexturefill = self; +} + + +CUSTOM_CVAR(Bool, gl_nocoloredspritelighting, false, 0) +{ + glset.nocoloredspritelighting = self; +} + +void gl_CreateSections(); + +//----------------------------------------------------------------------------- +// +// Adjust sprite offsets for GL rendering (IWAD resources only) +// +//----------------------------------------------------------------------------- + +void AdjustSpriteOffsets() +{ + static bool done=false; + char name[30]; + + if (done) return; + done=true; + + mysnprintf(name, countof(name), "sprofs/%s.sprofs", GameNames[gameinfo.gametype]); + int lump = Wads.CheckNumForFullName(name); + if (lump>=0) + { + FScanner sc; + sc.OpenLumpNum(lump); + GLRenderer->FlushTextures(); + while (sc.GetString()) + { + int x,y; + FTextureID texno = TexMan.CheckForTexture(sc.String, FTexture::TEX_Sprite); + sc.GetNumber(); + x=sc.Number; + sc.GetNumber(); + y=sc.Number; + + if (texno.isValid()) + { + FTexture * tex = TexMan[texno]; + + int lumpnum = tex->GetSourceLump(); + // We only want to change texture offsets for sprites in the IWAD! + if (lumpnum >= 0 && lumpnum < Wads.GetNumLumps()) + { + int wadno = Wads.GetLumpFile(lumpnum); + if (wadno==FWadCollection::IWAD_FILENUM) + { + tex->LeftOffset=x; + tex->TopOffset=y; + tex->KillNative(); + } + } + } + } + } +} + + + +// Normally this would be better placed in p_lnspec.cpp. +// But I have accidentally overwritten that file several times +// so I'd rather place it here. +static int LS_Sector_SetPlaneReflection (line_t *ln, AActor *it, bool backSide, + int arg0, int arg1, int arg2, int arg3, int arg4) +{ +// Sector_SetPlaneReflection (tag, floor, ceiling) + int secnum = -1; + + while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) + { + sector_t * s = §ors[secnum]; + if (s->floorplane.a==0 && s->floorplane.b==0) s->reflect[sector_t::floor] = arg1/255.f; + if (s->ceilingplane.a==0 && s->ceilingplane.b==0) sectors[secnum].reflect[sector_t::ceiling] = arg2/255.f; + } + + return true; +} + +static int LS_SetGlobalFogParameter (line_t *ln, AActor *it, bool backSide, + int arg0, int arg1, int arg2, int arg3, int arg4) +{ +// SetGlobalFogParameter (type, value) + switch(arg0) + { + case 0: + fogdensity = arg1>>1; + return true; + + case 1: + outsidefogdensity = arg1>>1; + return true; + + case 2: + skyfog = arg1; + return true; + + default: + return false; + } +} + + +//========================================================================== +// +// Portal identifier lists +// +//========================================================================== + + +//========================================================================== +// +// MAPINFO stuff +// +//========================================================================== + +struct FGLROptions : public FOptionalMapinfoData +{ + FGLROptions() + { + identifier = "gl_renderer"; + fogdensity = 0; + outsidefogdensity = 0; + skyfog = 0; + lightmode = -1; + nocoloredspritelighting = -1; + notexturefill = -1; + skyrotatevector = FVector3(0,0,1); + skyrotatevector2 = FVector3(0,0,1); + } + virtual FOptionalMapinfoData *Clone() const + { + FGLROptions *newopt = new FGLROptions; + newopt->identifier = identifier; + newopt->fogdensity = fogdensity; + newopt->outsidefogdensity = outsidefogdensity; + newopt->skyfog = skyfog; + newopt->lightmode = lightmode; + newopt->nocoloredspritelighting = nocoloredspritelighting; + newopt->notexturefill = notexturefill; + newopt->skyrotatevector = skyrotatevector; + newopt->skyrotatevector2 = skyrotatevector2; + return newopt; + } + int fogdensity; + int outsidefogdensity; + int skyfog; + int lightmode; + int brightfog; + SBYTE nocoloredspritelighting; + SBYTE notexturefill; + FVector3 skyrotatevector; + FVector3 skyrotatevector2; +}; + +DEFINE_MAP_OPTION(fogdensity, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + parse.ParseAssign(); + parse.sc.MustGetNumber(); + opt->fogdensity = parse.sc.Number; +} + +DEFINE_MAP_OPTION(brightfog, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + parse.ParseAssign(); + parse.sc.MustGetNumber(); + opt->brightfog = parse.sc.Number; +} + +DEFINE_MAP_OPTION(outsidefogdensity, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + parse.ParseAssign(); + parse.sc.MustGetNumber(); + opt->outsidefogdensity = parse.sc.Number; +} + +DEFINE_MAP_OPTION(skyfog, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + parse.ParseAssign(); + parse.sc.MustGetNumber(); + opt->skyfog = parse.sc.Number; +} + +DEFINE_MAP_OPTION(lightmode, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + parse.ParseAssign(); + parse.sc.MustGetNumber(); + opt->lightmode = BYTE(parse.sc.Number); +} + +DEFINE_MAP_OPTION(nocoloredspritelighting, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + if (parse.CheckAssign()) + { + parse.sc.MustGetNumber(); + opt->nocoloredspritelighting = !!parse.sc.Number; + } + else + { + opt->nocoloredspritelighting = true; + } +} + +DEFINE_MAP_OPTION(notexturefill, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + if (parse.CheckAssign()) + { + parse.sc.MustGetNumber(); + opt->notexturefill = !!parse.sc.Number; + } + else + { + opt->notexturefill = true; + } +} + +DEFINE_MAP_OPTION(skyrotate, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + + parse.ParseAssign(); + parse.sc.MustGetFloat(); + opt->skyrotatevector.X = (float)parse.sc.Float; + if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(","); + parse.sc.MustGetFloat(); + opt->skyrotatevector.Y = (float)parse.sc.Float; + if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(","); + parse.sc.MustGetFloat(); + opt->skyrotatevector.Z = (float)parse.sc.Float; + opt->skyrotatevector.MakeUnit(); +} + +DEFINE_MAP_OPTION(skyrotate2, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + + parse.ParseAssign(); + parse.sc.MustGetFloat(); + opt->skyrotatevector2.X = (float)parse.sc.Float; + if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(","); + parse.sc.MustGetFloat(); + opt->skyrotatevector2.Y = (float)parse.sc.Float; + if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(","); + parse.sc.MustGetFloat(); + opt->skyrotatevector2.Z = (float)parse.sc.Float; + opt->skyrotatevector2.MakeUnit(); +} + +bool IsLightmodeValid() +{ + return (glset.map_lightmode >= 0 && glset.map_lightmode <= 4) || glset.map_lightmode == 8; +} + +void InitGLRMapinfoData() +{ + FGLROptions *opt = level.info->GetOptData("gl_renderer", false); + + if (opt != NULL) + { + gl_SetFogParams(opt->fogdensity, level.info->outsidefog, opt->outsidefogdensity, opt->skyfog); + glset.map_lightmode = opt->lightmode; + glset.map_brightfog = opt->brightfog; + glset.map_nocoloredspritelighting = opt->nocoloredspritelighting; + glset.map_notexturefill = opt->notexturefill; + glset.skyrotatevector = opt->skyrotatevector; + glset.skyrotatevector2 = opt->skyrotatevector2; + if (gl.shadermodel == 2 && glset.map_lightmode ==2) glset.map_lightmode = 3; + } + else + { + gl_SetFogParams(0, level.info->outsidefog, 0, 0); + glset.map_lightmode = -1; + glset.map_brightfog = -1; + glset.map_nocoloredspritelighting = -1; + glset.map_notexturefill = -1; + glset.skyrotatevector = FVector3(0,0,1); + glset.skyrotatevector2 = FVector3(0,0,1); + } + + if (!IsLightmodeValid()) glset.lightmode = gl_lightmode; + else glset.lightmode = glset.map_lightmode; + if (glset.map_nocoloredspritelighting == -1) glset.nocoloredspritelighting = gl_nocoloredspritelighting; + else glset.nocoloredspritelighting = !!glset.map_nocoloredspritelighting; + if (glset.map_notexturefill == -1) glset.notexturefill = gl_notexturefill; + else glset.notexturefill = !!glset.map_notexturefill; + if (glset.map_brightfog == -1) glset.brightfog = gl_brightfog; + else glset.brightfog = !!glset.map_brightfog; +} + +CCMD(gl_resetmap) +{ + if (!IsLightmodeValid()) glset.lightmode = gl_lightmode; + else glset.lightmode = glset.map_lightmode; + if (glset.map_nocoloredspritelighting == -1) glset.nocoloredspritelighting = gl_nocoloredspritelighting; + else glset.nocoloredspritelighting = !!glset.map_nocoloredspritelighting; + if (glset.map_notexturefill == -1) glset.notexturefill = gl_notexturefill; + else glset.notexturefill = !!glset.map_notexturefill; + if (glset.map_brightfog == -1) glset.brightfog = gl_brightfog; + else glset.brightfog = !!glset.map_brightfog; +} + + +//=========================================================================== +// +// Gets the texture index for a sprite frame +// +//=========================================================================== + +FTextureID gl_GetSpriteFrame(unsigned sprite, int frame, int rot, angle_t ang, bool *mirror) +{ + spritedef_t *sprdef = &sprites[sprite]; + if (frame >= sprdef->numframes) + { + // If there are no frames at all for this sprite, don't draw it. + return FNullTextureID(); + } + else + { + //picnum = SpriteFrames[sprdef->spriteframes + thing->frame].Texture[0]; + // choose a different rotation based on player view + spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + frame]; + if (rot==-1) + { + if (sprframe->Texture[0] == sprframe->Texture[1]) + { + rot = (ang + (angle_t)(ANGLE_45/2)*9) >> 28; + } + else + { + rot = (ang + (angle_t)(ANGLE_45/2)*9-(angle_t)(ANGLE_180/16)) >> 28; + } + } + if (mirror) *mirror = !!(sprframe->Flip&(1<Texture[rot]; + } +} + + +//========================================================================== +// +// Recalculate all heights affectting this vertex. +// +//========================================================================== +void gl_RecalcVertexHeights(vertex_t * v) +{ + int i,j,k; + float height; + + //@sync-vertexheights + v->numheights=0; + for(i=0;inumsectors;i++) + { + for(j=0;j<2;j++) + { + if (j==0) height=FIXED2FLOAT(v->sectors[i]->ceilingplane.ZatPoint(v)); + else height=FIXED2FLOAT(v->sectors[i]->floorplane.ZatPoint(v)); + + for(k=0;knumheights;k++) + { + if (height == v->heightlist[k]) break; + if (height < v->heightlist[k]) + { + memmove(&v->heightlist[k+1], &v->heightlist[k], sizeof(float) * (v->numheights-k)); + v->heightlist[k]=height; + v->numheights++; + break; + } + } + if (k==v->numheights) v->heightlist[v->numheights++]=height; + } + } + if (v->numheights<=2) v->numheights=0; // is not in need of any special attention + v->dirty = false; +} + + + + +void gl_InitData() +{ + LineSpecials[157]=LS_SetGlobalFogParameter; + LineSpecials[159]=LS_Sector_SetPlaneReflection; + gl_InitModels(); + AdjustSpriteOffsets(); +} + +//========================================================================== +// +// dumpgeometry +// +//========================================================================== + +CCMD(dumpgeometry) +{ + for(int i=0;isubsectorcount;j++) + { + subsector_t * sub = sector->subsectors[j]; + + Printf(PRINT_LOG, " Subsector %d - real sector = %d - %s\n", int(sub-subsectors), sub->sector->sectornum, sub->hacked&1? "hacked":""); + for(DWORD k=0;knumlines;k++) + { + seg_t * seg = sub->firstline + k; + if (seg->linedef) + { + Printf(PRINT_LOG, " (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, linedef %d, side %d", + FIXED2FLOAT(seg->v1->x), FIXED2FLOAT(seg->v1->y), FIXED2FLOAT(seg->v2->x), FIXED2FLOAT(seg->v2->y), + int(seg-segs), int(seg->linedef-lines), seg->sidedef != seg->linedef->sidedef[0]); + } + else + { + Printf(PRINT_LOG, " (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, miniseg", + FIXED2FLOAT(seg->v1->x), FIXED2FLOAT(seg->v1->y), FIXED2FLOAT(seg->v2->x), FIXED2FLOAT(seg->v2->y), + int(seg-segs)); + } + if (seg->PartnerSeg) + { + subsector_t * sub2 = seg->PartnerSeg->Subsector; + Printf(PRINT_LOG, ", back sector = %d, real back sector = %d", sub2->render_sector->sectornum, seg->PartnerSeg->frontsector->sectornum); + } + else if (seg->backsector) + { + Printf(PRINT_LOG, ", back sector = %d (no partnerseg)", seg->backsector->sectornum); + } + + Printf(PRINT_LOG, "\n"); + } + } + } +} diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h new file mode 100644 index 000000000..6a71dd1ac --- /dev/null +++ b/src/gl/data/gl_data.h @@ -0,0 +1,61 @@ + +#ifndef __GLC_DATA_H +#define __GLC_DATA_H + +#include "doomtype.h" + +struct GLRenderSettings +{ + + SBYTE lightmode; + bool nocoloredspritelighting; + bool notexturefill; + bool brightfog; + + SBYTE map_lightmode; + SBYTE map_nocoloredspritelighting; + SBYTE map_notexturefill; + SBYTE map_brightfog; + + FVector3 skyrotatevector; + FVector3 skyrotatevector2; + +}; + +extern GLRenderSettings glset; + +#include "r_defs.h" +#include "a_sharedglobal.h" +#include "c_cvars.h" + +extern int extralight; +EXTERN_CVAR(Int, gl_weaponlight); + +inline int getExtraLight() +{ + return extralight * gl_weaponlight; // ((glset.lightmode == 8)? 16:8); +} + +void gl_RecalcVertexHeights(vertex_t * v); +FTextureID gl_GetSpriteFrame(unsigned sprite, int frame, int rot, angle_t ang, bool *mirror); + +class AStackPoint; +struct GLSectorStackPortal; + +struct FPortal +{ + fixed_t xDisplacement; + fixed_t yDisplacement; + int plane; + GLSectorStackPortal *glportal; // for quick access to the render data. This is only valid during BSP traversal! + + GLSectorStackPortal *GetGLPortal(); +}; + +extern TArray portals; +extern TArray currentmapsection; + +void gl_InitPortals(); +void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, FPortal *portal); + +#endif diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp new file mode 100644 index 000000000..11989b4a7 --- /dev/null +++ b/src/gl/data/gl_portaldata.cpp @@ -0,0 +1,473 @@ +/* +** gl_setup.cpp +** Initializes the data structures required by the GL renderer to handle +** a level +** +**--------------------------------------------------------------------------- +** Copyright 2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "doomtype.h" +#include "colormatcher.h" +#include "i_system.h" +#include "p_local.h" +#include "p_lnspec.h" +#include "c_dispatch.h" +#include "r_sky.h" +#include "sc_man.h" +#include "w_wad.h" +#include "gi.h" +#include "g_level.h" +#include "a_sharedglobal.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/scene/gl_clipper.h" +#include "gl/scene/gl_portal.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/utility/gl_clock.h" +#include "gl/gl_functions.h" + +struct FPortalID +{ + fixed_t mXDisplacement; + fixed_t mYDisplacement; + + // for the hash code + operator intptr_t() const { return (mXDisplacement >> 8) + (mYDisplacement << 8); } + bool operator != (const FPortalID &other) const + { + return mXDisplacement != other.mXDisplacement || + mYDisplacement != other.mYDisplacement; + } +}; + +struct FPortalSector +{ + sector_t *mSub; + int mPlane; +}; + +typedef TArray FPortalSectors; + +typedef TMap FPortalMap; + +TArray portals; + +//========================================================================== +// +// +// +//========================================================================== + +GLSectorStackPortal *FPortal::GetGLPortal() +{ + if (glportal == NULL) glportal = new GLSectorStackPortal(this); + return glportal; +} + +//========================================================================== +// +// +// +//========================================================================== + +struct FCoverageVertex +{ + fixed_t x, y; + + bool operator !=(FCoverageVertex &other) + { + return x != other.x || y != other.y; + } +}; + +struct FCoverageLine +{ + FCoverageVertex v[2]; +}; + +struct FCoverageBuilder +{ + subsector_t *target; + FPortal *portal; + TArray collect; + FCoverageVertex center; + + //========================================================================== + // + // + // + //========================================================================== + + FCoverageBuilder(subsector_t *sub, FPortal *port) + { + target = sub; + portal = port; + } + + //========================================================================== + // + // GetIntersection + // + // adapted from P_InterceptVector + // + //========================================================================== + + bool GetIntersection(FCoverageVertex *v1, FCoverageVertex *v2, node_t *bsp, FCoverageVertex *v) + { + double frac; + double num; + double den; + + double v2x = (double)v1->x; + double v2y = (double)v1->y; + double v2dx = (double)(v2->x - v1->x); + double v2dy = (double)(v2->y - v1->y); + double v1x = (double)bsp->x; + double v1y = (double)bsp->y; + double v1dx = (double)bsp->dx; + double v1dy = (double)bsp->dy; + + den = v1dy*v2dx - v1dx*v2dy; + + if (den == 0) + return false; // parallel + + num = (v1x - v2x)*v1dy + (v2y - v1y)*v1dx; + frac = num / den; + + if (frac < 0. || frac > 1.) return false; + + v->x = xs_RoundToInt(v2x + frac * v2dx); + v->y = xs_RoundToInt(v2y + frac * v2dy); + return true; + } + + //========================================================================== + // + // + // + //========================================================================== + + double PartitionDistance(FCoverageVertex *vt, node_t *node) + { + return fabs(double(-node->dy) * (vt->x - node->x) + double(node->dx) * (vt->y - node->y)) / node->len; + } + + //========================================================================== + // + // + // + //========================================================================== + + int PointOnSide(FCoverageVertex *vt, node_t *node) + { + return R_PointOnSide(vt->x, vt->y, node); + } + + //========================================================================== + // + // adapted from polyobject splitter + // + //========================================================================== + + void CollectNode(void *node, TArray &shape) + { + static TArray lists[2]; + const double COVERAGE_EPSILON = 6.; // same epsilon as the node builder + + if (!((size_t)node & 1)) // Keep going until found a subsector + { + node_t *bsp = (node_t *)node; + + int centerside = R_PointOnSide(center.x, center.y, bsp); + + lists[0].Clear(); + lists[1].Clear(); + for(unsigned i=0;ichildren[0], shape); + } + else if (lists[0].Size() == 0) + { + CollectNode(bsp->children[1], shape); + } + else + { + // copy the static arrays into local ones + TArray locallists[2]; + + for(int l=0;l<2;l++) + { + for (unsigned i=0;ichildren[0], locallists[0]); + CollectNode(bsp->children[1], locallists[1]); + } + } + else + { + // we reached a subsector so we can link the node with this subsector + subsector_t *sub = (subsector_t *)((BYTE *)node - 1); + collect.Push(int(sub-subsectors)); + } + } +}; + +//========================================================================== +// +// Calculate portal coverage for a single subsector +// +//========================================================================== + +void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, FPortal *portal) +{ + TArray shape; + double centerx=0, centery=0; + + shape.Resize(subsector->numlines); + for(unsigned i=0; inumlines; i++) + { + centerx += (shape[i].x = subsector->firstline[i].v1->x + portal->xDisplacement); + centery += (shape[i].y = subsector->firstline[i].v1->y + portal->yDisplacement); + } + + FCoverageBuilder build(subsector, portal); + build.center.x = xs_CRoundToInt(centerx / subsector->numlines); + build.center.y = xs_CRoundToInt(centery / subsector->numlines); + + build.CollectNode(nodes + numnodes - 1, shape); + coverage->subsectors = new DWORD[build.collect.Size()]; + coverage->sscount = build.collect.Size(); + memcpy(coverage->subsectors, &build.collect[0], build.collect.Size() * sizeof(DWORD)); +} + +//========================================================================== +// +// portal initialization +// +//========================================================================== + +static void CollectPortalSectors(FPortalMap &collection) +{ + for (int i=0;iCeilingSkyBox != NULL && sec->CeilingSkyBox->bAlways && sec->CeilingSkyBox->Mate != NULL) + { + FPortalID id = { sec->CeilingSkyBox->x - sec->CeilingSkyBox->Mate->x, + sec->CeilingSkyBox->y - sec->CeilingSkyBox->Mate->y}; + + FPortalSectors &sss = collection[id]; + FPortalSector ss = { sec, sector_t::ceiling }; + sss.Push(ss); + } + + if (sec->FloorSkyBox != NULL && sec->FloorSkyBox->bAlways && sec->FloorSkyBox->Mate != NULL) + { + FPortalID id = { sec->FloorSkyBox->x - sec->FloorSkyBox->Mate->x, + sec->FloorSkyBox->y - sec->FloorSkyBox->Mate->y }; + + FPortalSectors &sss = collection[id]; + FPortalSector ss = { sec, sector_t::floor }; + sss.Push(ss); + } + } +} + +void gl_InitPortals() +{ + FPortalMap collection; + + if (numnodes == 0) return; + + for(int i=0;idx; + double fdy = (double)no->dy; + no->len = (float)sqrt(fdx * fdx + fdy * fdy); + } + + CollectPortalSectors(collection); + portals.Clear(); + + FPortalMap::Iterator it(collection); + FPortalMap::Pair *pair; + int c = 0; + int planeflags = 0; + while (it.NextPair(pair)) + { + for(unsigned i=0;iValue.Size(); i++) + { + if (pair->Value[i].mPlane == sector_t::floor) planeflags |= 1; + else if (pair->Value[i].mPlane == sector_t::ceiling) planeflags |= 2; + } + for (int i=1;i<=2;i<<=1) + { + // For now, add separate portals for floor and ceiling. They can be merged once + // proper plane clipping is in. + if (planeflags & i) + { + FPortal *portal = new FPortal; + portal->xDisplacement = pair->Key.mXDisplacement; + portal->yDisplacement = pair->Key.mYDisplacement; + portal->plane = (i==1? sector_t::floor : sector_t::ceiling); /**/ + portal->glportal = NULL; + portals.Push(portal); + for(unsigned j=0;jValue.Size(); j++) + { + sector_t *sec = pair->Value[j].mSub; + int plane = pair->Value[j].mPlane; + if (portal->plane == plane) + { + for(int k=0;ksubsectorcount; k++) + { + subsector_t *sub = sec->subsectors[k]; + gl_BuildPortalCoverage(&sub->portalcoverage[plane], sub, portal); + } + sec->portals[plane] = portal; + } + } + } + } + } +} + +CCMD(dumpportals) +{ + for(unsigned i=0;ixDisplacement/65536.; + double ydisp = portals[i]->yDisplacement/65536.; + Printf(PRINT_LOG, "Portal #%d, %s, displacement = (%f,%f)\n", i, portals[i]->plane==0? "floor":"ceiling", + xdisp, ydisp); + Printf(PRINT_LOG, "Coverage:\n"); + for(int j=0;jrender_sector->portals[portals[i]->plane]; + if (port == portals[i]) + { + Printf(PRINT_LOG, "\tSubsector %d (%d):\n\t\t", j, sub->render_sector->sectornum); + for(unsigned k = 0;k< sub->numlines; k++) + { + Printf(PRINT_LOG, "(%.3f,%.3f), ", sub->firstline[k].v1->x/65536. + xdisp, sub->firstline[k].v1->y/65536. + ydisp); + } + Printf(PRINT_LOG, "\n\t\tCovered by subsectors:\n"); + FPortalCoverage *cov = &sub->portalcoverage[portals[i]->plane]; + for(int l = 0;l< cov->sscount; l++) + { + subsector_t *csub = &subsectors[cov->subsectors[l]]; + Printf(PRINT_LOG, "\t\t\t%5d (%4d): ", cov->subsectors[l], csub->render_sector->sectornum); + for(unsigned m = 0;m< csub->numlines; m++) + { + Printf(PRINT_LOG, "(%.3f,%.3f), ", csub->firstline[m].v1->x/65536., csub->firstline[m].v1->y/65536.); + } + Printf(PRINT_LOG, "\n"); + } + } + } + } +} diff --git a/src/gl/data/gl_sections.cpp b/src/gl/data/gl_sections.cpp new file mode 100644 index 000000000..34dbabd1d --- /dev/null +++ b/src/gl/data/gl_sections.cpp @@ -0,0 +1,847 @@ +/* +** gl_sections.cpp +** Splits sectors into continuous separate parts +** +**--------------------------------------------------------------------------- +** Copyright 2008 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ +#if 0 + +#include "gl/system/gl_system.h" +#include "i_system.h" +#include "p_local.h" +#include "c_dispatch.h" +#include "gl/data/gl_sections.h" + +typedef void (CALLBACK *tessFunc)(); + +TArray SectionLines; +TArray SectionLoops; +TArray Sections; +TArray SectionForSubsector; + +CVAR (Bool, dumpsections, false, 0) + +#define ISDONE(no, p) (p[(no)>>3] & (1 << ((no)&7))) +#define SETDONE(no, p) p[(no)>>3] |= (1 << ((no)&7)) + +inline vertex_t *V1(side_t *s) +{ + line_t *ln = s->linedef; + return s == ln->sidedef[0]? ln->v1: ln->v2; +} + +inline vertex_t *V2(side_t *s) +{ + line_t *ln = s->linedef; + return s == ln->sidedef[0]? ln->v2: ln->v1; +} + +//========================================================================== +// +// +// +//========================================================================== + +class FSectionCreator +{ + static FSectionCreator *creator; + + BYTE *processed_segs; + BYTE *processed_subsectors; + int *section_for_segs; + + vertex_t *v1_l1, *v2_l1; + + FGLSectionLoop *loop; + FGLSection *section; // current working section + +public: + //========================================================================== + // + // + // + //========================================================================== + + FSectionCreator() + { + processed_segs = new BYTE[(numsegs+7)/8]; + processed_subsectors = new BYTE[(numsubsectors+7)/8]; + + memset(processed_segs, 0, (numsegs+7)/8); + memset(processed_subsectors, 0, (numsubsectors+7)/8); + + section_for_segs = new int[numsegs]; + memset(section_for_segs, -1, numsegs * sizeof(int)); + } + + //========================================================================== + // + // + // + //========================================================================== + + ~FSectionCreator() + { + delete [] processed_segs; + delete [] processed_subsectors; + delete [] section_for_segs; + } + + //========================================================================== + // + // + // + //========================================================================== + + void NewLoop() + { + section->numloops++; + loop = &SectionLoops[SectionLoops.Reserve(1)]; + loop->startline = SectionLines.Size(); + loop->numlines = 0 ; + } + + void NewSection(sector_t *sec) + { + section = &Sections[Sections.Reserve(1)]; + section->sector = sec; + section->subsectors.Clear(); + section->numloops = 0; + section->startloop = SectionLoops.Size(); + section->validcount = -1; + NewLoop(); + } + + void FinalizeSection() + { + } + + //========================================================================== + // + // + // + //========================================================================== + + bool AddSeg(seg_t *seg) + { + FGLSectionLine &line = SectionLines[SectionLines.Reserve(1)]; + + + bool firstline = loop->numlines == 0; + + if (ISDONE(seg-segs, processed_segs)) + { + // should never happen! + DPrintf("Tried to add seg %d to Sections twice. Cannot create Sections.\n", seg-segs); + return false; + } + + SETDONE(seg-segs, processed_segs); + section_for_segs[seg-segs] = Sections.Size()-1; + + line.start = seg->v1; + line.end = seg->v2; + line.sidedef = seg->sidedef; + line.linedef = seg->linedef; + line.refseg = seg; + line.polysub = NULL; + line.otherside = -1; + + if (loop->numlines == 0) + { + v1_l1 = seg->v1; + v2_l1 = seg->v2; + } + loop->numlines++; + return true; + } + + //========================================================================== + // + // Utility stuff + // + //========================================================================== + + sector_t *FrontRenderSector(seg_t *seg) + { + return seg->Subsector->render_sector; + } + + sector_t *BackRenderSector(seg_t *seg) + { + if (seg->PartnerSeg == NULL) return NULL; + return seg->PartnerSeg->Subsector->render_sector; + } + + bool IntraSectorSeg(seg_t *seg) + { + return FrontRenderSector(seg) == BackRenderSector(seg); + } + + + //========================================================================== + // + // returns the seg whose partner seg determines where this + // section continues + // + //========================================================================== + bool AddSubSector(subsector_t *subsec, vertex_t *startpt, seg_t **pNextSeg) + { + unsigned i = 0; + if (startpt != NULL) + { + // find the seg in this subsector that starts at the given vertex + for(i = 0; i < subsec->numlines; i++) + { + if (subsec->firstline[i].v1 == startpt) break; + } + if (i == subsec->numlines) + { + DPrintf("Vertex not found in subsector %d. Cannot create Sections.\n", subsec-subsectors); + return false; // Nodes are bad + } + } + else + { + // Find the first unprocessed non-miniseg + for(i = 0; i < subsec->numlines; i++) + { + seg_t *seg = subsec->firstline + i; + + if (seg->sidedef == NULL) continue; + if (IntraSectorSeg(seg)) continue; + if (ISDONE(seg-segs, processed_segs)) continue; + break; + } + if (i == subsec->numlines) + { + DPrintf("Unable to find a start seg. Cannot create Sections.\n"); + return false; // Nodes are bad + } + + startpt = subsec->firstline[i].v1; + } + + seg_t *thisseg = subsec->firstline + i; + if (IntraSectorSeg(thisseg)) + { + SETDONE(thisseg-segs, processed_segs); + // continue with the loop in the adjoining subsector + *pNextSeg = thisseg; + return true; + } + + while(1) + { + if (loop->numlines > 0 && thisseg->v1 == v1_l1 && thisseg->v2 == v2_l1) + { + // This loop is complete + *pNextSeg = NULL; + return true; + } + + if (!AddSeg(thisseg)) return NULL; + + i = (i+1) % subsec->numlines; + seg_t *nextseg = subsec->firstline + i; + + if (thisseg->v2 != nextseg->v1) + { + DPrintf("Segs in subsector %d are not continuous. Cannot create Sections.\n", subsec-subsectors); + return false; // Nodes are bad + } + + if (IntraSectorSeg(nextseg)) + { + SETDONE(nextseg-segs, processed_segs); + // continue with the loop in the adjoining subsector + *pNextSeg = nextseg; + return true; + } + thisseg = nextseg; + } + } + + //============================================================================= + // + // + // + //============================================================================= + + bool FindNextSeg(seg_t **pSeg) + { + // find an unprocessed non-miniseg or a miniseg with an unprocessed + // partner subsector that belongs to the same rendersector + for (unsigned i = 0; i < section->subsectors.Size(); i++) + { + for(unsigned j = 0; j < section->subsectors[i]->numlines; j++) + { + seg_t *seg = section->subsectors[i]->firstline + j; + bool intra = IntraSectorSeg(seg); + + if (!intra && !ISDONE(seg-segs, processed_segs)) + { + *pSeg = seg; + return true; + } + else if (intra && + !ISDONE(seg->PartnerSeg->Subsector-subsectors, processed_subsectors)) + { + *pSeg = seg->PartnerSeg; + return true; + } + } + } + *pSeg = NULL; + return true; + } + + //============================================================================= + // + // all segs and subsectors must be grouped into Sections + // + //============================================================================= + bool CheckSections() + { + bool res = true; + for (int i = 0; i < numsegs; i++) + { + if (segs[i].sidedef != NULL && !ISDONE(i, processed_segs) && !IntraSectorSeg(&segs[i])) + { + Printf("Seg %d (Linedef %d) not processed during section creation\n", i, segs[i].linedef-lines); + res = false; + } + } + for (int i = 0; i < numsubsectors; i++) + { + if (!ISDONE(i, processed_subsectors)) + { + Printf("Subsector %d (Sector %d) not processed during section creation\n", i, subsectors[i].sector-sectors); + res = false; + } + } + return res; + } + + //============================================================================= + // + // + // + //============================================================================= + void DeleteLine(int i) + { + SectionLines.Delete(i); + for(int i = SectionLoops.Size() - 1; i >= 0; i--) + { + FGLSectionLoop *loop = &SectionLoops[i]; + if (loop->startline > i) loop->startline--; + } + } + + //============================================================================= + // + // + // + //============================================================================= + void MergeLines(FGLSectionLoop *loop) + { + int i; + int deleted = 0; + FGLSectionLine *ln1; + FGLSectionLine *ln2; + // Merge identical lines in the list + for(i = loop->numlines - 1; i > 0; i--) + { + ln1 = loop->GetLine(i); + ln2 = loop->GetLine(i-1); + + if (ln1->sidedef == ln2->sidedef && ln1->otherside == ln2->otherside) + { + // identical references. These 2 lines can be merged. + ln2->end = ln1->end; + SectionLines.Delete(loop->startline + i); + loop->numlines--; + deleted++; + } + } + + // If we started in the middle of a sidedef the first and last lines + // may reference the same sidedef. check that, too. + + int loopstart = 0; + + ln1 = loop->GetLine(0); + for(i = loop->numlines - 1; i > 0; i--) + { + ln2 = loop->GetLine(i); + if (ln1->sidedef != ln2->sidedef || ln1->otherside != ln2->otherside) + break; + } + if (i < loop->numlines-1) + { + i++; + ln2 = loop->GetLine(i); + ln1->start = ln2->start; + SectionLines.Delete(loop->startline + i, loop->numlines - i); + deleted += loop->numlines - i; + loop->numlines = i; + } + + // Adjust all following loops + for(unsigned ii = unsigned(loop - &SectionLoops[0]) + 1; ii < SectionLoops.Size(); ii++) + { + SectionLoops[ii].startline -= deleted; + } + } + + //============================================================================= + // + // + // + //============================================================================= + void SetReferences() + { + for(unsigned i = 0; i < SectionLines.Size(); i++) + { + FGLSectionLine *ln = &SectionLines[i]; + seg_t *seg = ln->refseg; + + if (seg != NULL) + { + seg_t *partner = seg->PartnerSeg; + + if (seg->PartnerSeg == NULL) + { + ln->otherside = -1; + } + else + { + ln->otherside = section_for_segs[partner-segs]; + } + } + else + { + ln->otherside = -1; + } + } + + for(unsigned i = 0; i < SectionLoops.Size(); i++) + { + MergeLines(&SectionLoops[i]); + } + } + + //============================================================================= + // + // cbTessBegin + // + // called when the tesselation of a new loop starts + // + //============================================================================= + + static void CALLBACK cbTessBegin(GLenum type, void *section) + { + FGLSection *sect = (FGLSection*)section; + sect->vertices.Push(-int(type)); + } + + //============================================================================= + // + // cbTessError + // + // called when the tesselation failed + // + //============================================================================= + + static void CALLBACK cbTessError(GLenum error, void *section) + { + } + + //============================================================================= + // + // cbTessCombine + // + // called when the two or more vertexes are on the same coordinate + // + //============================================================================= + + static void CALLBACK cbTessCombine( GLdouble coords[3], void *vert[4], GLfloat w[4], void **dataOut ) + { + *dataOut = vert[0]; + } + + //============================================================================= + // + // cbTessVertex + // + // called when a vertex is found + // + //============================================================================= + + static void CALLBACK cbTessVertex( void *vert, void *section ) + { + FGLSection *sect = (FGLSection*)section; + sect->vertices.Push(int(intptr_t(vert))); + } + + //============================================================================= + // + // cbTessEnd + // + // called when the tesselation of a the current loop ends + // + //============================================================================= + + static void CALLBACK cbTessEnd(void *section) + { + } + + //============================================================================= + // + // + // + //============================================================================= + void tesselateSections() + { + // init tesselator + GLUtesselator *tess = gluNewTess(); + if (!tess) + { + return; + } + // set callbacks + gluTessCallback(tess, GLU_TESS_BEGIN_DATA, (tessFunc)cbTessBegin); + gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (tessFunc)cbTessVertex); + gluTessCallback(tess, GLU_TESS_ERROR_DATA, (tessFunc)cbTessError); + gluTessCallback(tess, GLU_TESS_COMBINE, (tessFunc)cbTessCombine); + gluTessCallback(tess, GLU_TESS_END_DATA, (tessFunc)cbTessEnd); + + for(unsigned int i=0;inumloops; j++) + { + gluTessBeginContour(tess); + FGLSectionLoop *loop = sect->GetLoop(j); + for(int k=0; knumlines; k++) + { + FGLSectionLine *line = loop->GetLine(k); + vertex_t *vert = line->start; + GLdouble v[3] = { + -(double)vert->x/(double)FRACUNIT, // negate to get proper winding + 0.0, + (double)vert->y/(double)FRACUNIT + }; + gluTessVertex(tess, v, (void*)(vert - vertexes)); + } + gluTessEndContour(tess); + } + gluTessEndPolygon(tess); + sect->vertices.Push(-1337); + sect->vertices.ShrinkToFit(); + } + gluDeleteTess(tess); + } + + + //============================================================================= + // + // First mark all subsectors that have no outside boundaries as processed + // No line in such a subsector will ever be part of a section's border + // + //============================================================================= + + void MarkInternalSubsectors() + { + for(int i=0; i < numsubsectors; i++) + { + subsector_t *sub = &subsectors[i]; + int j; + + for(j=0; j < sub->numlines; j++) + { + seg_t *seg = sub->firstline + j; + if (!IntraSectorSeg(seg)) break; + } + if (j==sub->numlines) + { + // All lines are intra-sector so mark this as processed + SETDONE(i, processed_subsectors); + for(j=0; j < sub->numlines; j++) + { + seg_t *seg = sub->firstline + j; + SETDONE((sub->firstline-segs)+j, processed_segs); + if (seg->PartnerSeg != NULL) + { + SETDONE(int(seg->PartnerSeg - segs), processed_segs); + } + } + } + } + } + + //============================================================================= + // + // + // + //============================================================================= + bool CreateSections() + { + int pick = 0; + + MarkInternalSubsectors(); + while (pick < numsubsectors) + { + if (ISDONE(pick, processed_subsectors)) + { + pick++; + continue; + } + + + subsector_t *subsector = &subsectors[pick]; + + seg_t *workseg = NULL; + vertex_t *startpt = NULL; + + NewSection(subsector->render_sector); + while (1) + { + if (!ISDONE(subsector-subsectors, processed_subsectors)) + { + SETDONE(subsector-subsectors, processed_subsectors); + section->subsectors.Push(subsector); + SectionForSubsector[subsector - subsectors] = int(section - &Sections[0]); + } + + bool result = AddSubSector(subsector, startpt, &workseg); + + if (!result) + { + return false; // couldn't create Sections + } + else if (workseg != NULL) + { + // crossing into another subsector + seg_t *partner = workseg->PartnerSeg; + if (workseg->v2 != partner->v1) + { + DPrintf("Inconsistent subsector references in seg %d. Cannot create Sections.\n", workseg-segs); + return false; + } + subsector = partner->Subsector; + startpt = workseg->v1; + } + else + { + // loop complete. Check adjoining subsectors for other loops to + // be added to this section + if (!FindNextSeg(&workseg)) + { + return false; + } + else if (workseg == NULL) + { + // No more subsectors found. This section is complete! + FinalizeSection(); + break; + } + else + { + subsector = workseg->Subsector; + // If this is a regular seg, start there, otherwise start + // at the subsector's first seg + startpt = workseg->sidedef == NULL? NULL : workseg->v1; + + NewLoop(); + } + } + } + } + + if (!CheckSections()) return false; + SetReferences(); + + Sections.ShrinkToFit(); + SectionLoops.ShrinkToFit(); + SectionLines.ShrinkToFit(); + + tesselateSections(); + + return true; + } +}; + +FSectionCreator *FSectionCreator::creator; + + +//============================================================================= +// +// +// +//============================================================================= + +void DumpSection(int no, FGLSection *sect) +{ + Printf(PRINT_LOG, "Section %d, sector %d\n{\n", no, sect->sector->sectornum); + + for(int i = 0; i < sect->numloops; i++) + { + Printf(PRINT_LOG, "\tLoop %d\n\t{\n", i); + + FGLSectionLoop *loop = sect->GetLoop(i); + + for(int i = 0; i < loop->numlines; i++) + { + FGLSectionLine *ln = loop->GetLine(i); + if (ln->sidedef != NULL) + { + vertex_t *v1 = V1(ln->sidedef); + vertex_t *v2 = V2(ln->sidedef); + double dx = FIXED2FLOAT(v2->x-v1->x); + double dy = FIXED2FLOAT(v2->y-v1->y); + double dx1 = FIXED2FLOAT(ln->start->x-v1->x); + double dy1 = FIXED2FLOAT(ln->start->y-v1->y); + double dx2 = FIXED2FLOAT(ln->end->x-v1->x); + double dy2 = FIXED2FLOAT(ln->end->y-v1->y); + double d = sqrt(dx*dx+dy*dy); + double d1 = sqrt(dx1*dx1+dy1*dy1); + double d2 = sqrt(dx2*dx2+dy2*dy2); + + Printf(PRINT_LOG, "\t\tLinedef %d, %s: Start (%1.2f, %1.2f), End (%1.2f, %1.2f)", + ln->linedef - lines, ln->sidedef == ln->linedef->sidedef[0]? "front":"back", + ln->start->x/65536.f, ln->start->y/65536.f, + ln->end->x/65536.f, ln->end->y/65536.f); + + if (ln->otherside != -1) + { + Printf (PRINT_LOG, ", other side = %d", ln->otherside); + } + if (d1 > 0.005 || d2 < 0.995) + { + Printf(PRINT_LOG, ", Range = %1.3f, %1.3f", d1/d, d2/d); + } + } + else + { + Printf(PRINT_LOG, "\t\tMiniseg: Start (%1.3f, %1.3f), End (%1.3f, %1.3f)\n", + ln->start->x/65536.f, ln->start->y/65536.f, ln->end->x/65536.f, ln->end->y/65536.f); + + if (ln->otherside != -1) + { + Printf (PRINT_LOG, ", other side = %d", ln->otherside); + } + } + Printf(PRINT_LOG, "\n"); + } + Printf(PRINT_LOG, "\t}\n"); + } + int prim = 1; + for(unsigned i = 0; i < sect->vertices.Size(); i++) + { + int v = sect->vertices[i]; + if (v < 0) + { + if (i > 0) + { + Printf(PRINT_LOG, "\t}\n"); + } + switch (v) + { + case -GL_TRIANGLE_FAN: + Printf(PRINT_LOG, "\t%d: Triangle fan\n\t{\n", prim); + break; + + case -GL_TRIANGLE_STRIP: + Printf(PRINT_LOG, "\t%d: Triangle strip\n\t{\n", prim); + break; + + case -GL_TRIANGLES: + Printf(PRINT_LOG, "\t%d: Triangles\n\t{\n", prim); + break; + + default: + break; + } + prim++; + } + else + { + Printf(PRINT_LOG, "\t\tVertex %d: (%1.2f, %1.2f)\n", + v, vertexes[v].x/65536.f, vertexes[v].y/65536.f); + } + } + Printf(PRINT_LOG, "}\n\n"); +} + +//============================================================================= +// +// +// +//============================================================================= + +void DumpSections() +{ + for(unsigned i = 0; i < Sections.Size(); i++) + { + DumpSection(i, &Sections[i]); + } +} + +//============================================================================= +// +// +// +//============================================================================= + +void gl_CreateSections() +{ + SectionLines.Clear(); + SectionLoops.Clear(); + Sections.Clear(); + SectionForSubsector.Resize(numsubsectors); + memset(&SectionForSubsector[0], -1, numsubsectors * sizeof(SectionForSubsector[0])); + FSectionCreator creat; + creat.CreateSections(); + if (dumpsections) DumpSections(); +} + + + +#endif diff --git a/src/gl/data/gl_sections.h b/src/gl/data/gl_sections.h new file mode 100644 index 000000000..b64886791 --- /dev/null +++ b/src/gl/data/gl_sections.h @@ -0,0 +1,56 @@ + +#ifndef __GL_SECTIONS_H +#define __GL_SECTIONS_H + +#include "tarray.h" +#include "r_defs.h" + +struct FGLSectionLine +{ + vertex_t *start; + vertex_t *end; + side_t *sidedef; + line_t *linedef; + seg_t *refseg; // we need to reference at least one seg for each line. + subsector_t *polysub; // If this is part of a polyobject we need a reference to the containing subsector + int otherside; +}; + +struct FGLSectionLoop +{ + int startline; + int numlines; + + FGLSectionLine *GetLine(int no); +}; + +struct FGLSection +{ + sector_t *sector; + TArray subsectors; + TArray vertices; + int startloop; + int numloops; + int validcount; + + FGLSectionLoop *GetLoop(int no); +}; + +extern TArray SectionLines; +extern TArray SectionLoops; +extern TArray Sections; +extern TArray SectionForSubsector; + +inline FGLSectionLine *FGLSectionLoop::GetLine(int no) +{ + return &SectionLines[startline + no]; +} + +inline FGLSectionLoop *FGLSection::GetLoop(int no) +{ + return &SectionLoops[startloop + no]; +} + +void gl_CreateSections(); + +#endif \ No newline at end of file diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp new file mode 100644 index 000000000..d822ac440 --- /dev/null +++ b/src/gl/data/gl_setup.cpp @@ -0,0 +1,736 @@ +/* +** gl_setup.cpp +** Initializes the data structures required by the GL renderer to handle +** a level +** +**--------------------------------------------------------------------------- +** Copyright 2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "doomtype.h" +#include "colormatcher.h" +#include "i_system.h" +#include "p_local.h" +#include "p_lnspec.h" +#include "c_dispatch.h" +#include "r_sky.h" +#include "sc_man.h" +#include "w_wad.h" +#include "gi.h" +#include "p_setup.h" +#include "g_level.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/utility/gl_clock.h" +#include "gl/gl_functions.h" + +void InitGLRMapinfoData(); +void gl_InitData(); + +//========================================================================== +// +// +// +//========================================================================== + +static void DoSetMapSection(subsector_t *sub, int num) +{ + sub->mapsection = num; + + for(DWORD i=0;inumlines;i++) + { + seg_t * seg = sub->firstline + i; + + if (seg->PartnerSeg) + { + subsector_t * sub2 = seg->PartnerSeg->Subsector; + + if (sub2->mapsection != num) + { + assert(sub2->mapsection == 0); + DoSetMapSection(sub2, num); + } + } + } +} + +//========================================================================== +// +// Merge sections. This is needed in case the map contains errors +// like overlapping lines resulting in abnormal subsectors. +// +// This function ensures that any vertex position can only be in one section. +// +//========================================================================== + +struct cvertex_t +{ + fixed_t x, y; + + operator int () const { return ((x>>16)&0xffff) | y; } + bool operator!= (const cvertex_t &other) const { return x != other.x || y != other.y; } + cvertex_t& operator =(const vertex_t *v) { x = v->x; y = v->y; return *this; } +}; + +typedef TMap FSectionVertexMap; + +static int MergeMapSections(int num) +{ + FSectionVertexMap vmap; + FSectionVertexMap::Pair *pair; + TArray sectmap; + TArray sectvalid; + sectmap.Resize(num); + sectvalid.Resize(num); + for(int i=0;iSubsector->mapsection; + for(int j=0;j<2;j++) + { + vt = j==0? seg->v1:seg->v2; + vmap[vt] = section; + } + } + + // second step: Check if any seg references more than one mapsection, either by subsector or by vertex + for(DWORD i=0;iSubsector->mapsection; + for(int j=0;j<2;j++) + { + vt = j==0? seg->v1:seg->v2; + int vsection = vmap[vt]; + + if (vsection != section) + { + // These 2 sections should be merged + for(int k=0;kValue == vsection) pair->Value = section; + } + sectvalid[vsection-1] = false; + } + } + } + for(int i=0;inumlines;i++) + { + seg_t * seg = sub->firstline + i; + + if (seg->PartnerSeg) + { + subsector_t * sub2 = seg->PartnerSeg->Subsector; + + if (!(sub2->hacked&1) && sub2->render_sector == sub->render_sector) + { + sub2->hacked|=1; + SpreadHackedFlag (sub2); + } + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +static void PrepareSectorData() +{ + int i; + TArray undetermined; + subsector_t * ss; + + // now group the subsectors by sector + subsector_t ** subsectorbuffer = new subsector_t * [numsubsectors]; + + for(i=0, ss=subsectors; irender_sector->subsectorcount++; + } + + for (i=0; irender_sector->subsectors[ss->render_sector->subsectorcount++]=ss; + } + + // marks all malformed subsectors so rendering tricks using them can be handled more easily + for (i = 0; i < numsubsectors; i++) + { + if (subsectors[i].sector == subsectors[i].render_sector) + { + seg_t * seg = subsectors[i].firstline; + for(DWORD j=0;jSubsector->render_sector) + { + DPrintf("Found hack: (%d,%d) (%d,%d)\n", seg[j].v1->x>>16, seg[j].v1->y>>16, seg[j].v2->x>>16, seg[j].v2->y>>16); + subsectors[i].hacked|=1; + SpreadHackedFlag(&subsectors[i]); + } + if (seg[j].PartnerSeg==NULL) subsectors[i].hacked|=2; // used for quick termination checks + } + } + } + SetMapSections(); +} + +//========================================================================== +// +// Some processing for transparent door hacks using a floor raised by 1 map unit +// - This will be used to lower the floor of such sectors by one map unit +// +//========================================================================== + +static void PrepareTransparentDoors(sector_t * sector) +{ + bool solidwall=false; + int notextures=0; + int nobtextures=0; + int selfref=0; + int i; + sector_t * nextsec=NULL; + +#ifdef _MSC_VER +#ifdef _DEBUG + if (sector-sectors==2) + { + __asm nop + } +#endif +#endif + + P_Recalculate3DFloors(sector); + if (sector->subsectorcount==0) return; + + sector->transdoorheight=sector->GetPlaneTexZ(sector_t::floor); + sector->transdoor= !(sector->e->XFloor.ffloors.Size() || sector->heightsec || sector->floorplane.a || sector->floorplane.b); + + if (sector->transdoor) + { + for (i=0; ilinecount; i++) + { + if (sector->lines[i]->frontsector==sector->lines[i]->backsector) + { + selfref++; + continue; + } + + sector_t * sec=getNextSector(sector->lines[i], sector); + if (sec==NULL) + { + solidwall=true; + continue; + } + else + { + nextsec=sec; + + int side = sector->lines[i]->sidedef[0]->sector == sec; + + if (sector->GetPlaneTexZ(sector_t::floor)!=sec->GetPlaneTexZ(sector_t::floor)+FRACUNIT) + { + sector->transdoor=false; + return; + } + if (!sector->lines[i]->sidedef[1-side]->GetTexture(side_t::top).isValid()) notextures++; + if (!sector->lines[i]->sidedef[1-side]->GetTexture(side_t::bottom).isValid()) nobtextures++; + } + } + if (sector->GetTexture(sector_t::ceiling)==skyflatnum) + { + sector->transdoor=false; + return; + } + + if (selfref+nobtextures!=sector->linecount) + { + sector->transdoor=false; + } + + if (selfref+notextures!=sector->linecount) + { + // This is a crude attempt to fix an incorrect transparent door effect I found in some + // WolfenDoom maps but considering the amount of code required to handle it I left it in. + // Do this only if the sector only contains one-sided walls or ones with no lower texture. + if (solidwall) + { + if (solidwall+nobtextures+selfref==sector->linecount && nextsec) + { + sector->heightsec=nextsec; + sector->heightsec->MoreFlags=0; + } + sector->transdoor=false; + } + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +static void AddToVertex(const sector_t * sec, TArray & list) +{ + int secno = int(sec-sectors); + + for(unsigned i=0;i * vt_sectorlists; + + int i,j,k; + unsigned int l; + + vt_sectorlists = new TArray[numvertexes]; + + + for(i=0;iv1 : line->v2; + + for(k=0;k<2;k++) + { + sector_t * sec = k==0? line->frontsector : line->backsector; + + if (sec) + { + extsector_t::xfloor &x = sec->e->XFloor; + + AddToVertex(sec, vt_sectorlists[v-vertexes]); + if (sec->heightsec) AddToVertex(sec->heightsec, vt_sectorlists[v-vertexes]); + + for(l=0;lflags & FF_EXISTS)) continue; + if (rover->flags&FF_NOSHADE) continue; // FF_NOSHADE doesn't create any wall splits + + AddToVertex(rover->model, vt_sectorlists[v-vertexes]); + } + } + } + } + } + + for(i=0;i1) + { + vertexes[i].numsectors= cnt; + vertexes[i].sectors=new sector_t*[cnt]; + vertexes[i].heightlist = new float[cnt*2]; + for(int j=0;jsidedef[0] == &sides[sdnum]) + { + v1->X = ln->v1->fx; + v1->Y = ln->v1->fy; + v2->X = ln->v2->fx; + v2->Y = ln->v2->fy; + } + else + { + v2->X = ln->v1->fx; + v2->Y = ln->v1->fy; + v1->X = ln->v2->fx; + v1->Y = ln->v2->fy; + } +} + +static int STACK_ARGS segcmp(const void *a, const void *b) +{ + seg_t *A = *(seg_t**)a; + seg_t *B = *(seg_t**)b; + return xs_RoundToInt(FRACUNIT*(A->sidefrac - B->sidefrac)); +} + +//========================================================================== +// +// Group segs to sidedefs +// +//========================================================================== + +static void PrepareSegs() +{ + int *segcount = new int[numsides]; + int realsegs = 0; + + // Get floatng point coordinates of vertices + for(int i = 0; i < numvertexes; i++) + { + vertexes[i].fx = FIXED2FLOAT(vertexes[i].x); + vertexes[i].fy = FIXED2FLOAT(vertexes[i].y); + vertexes[i].dirty = true; + } + + // count the segs + memset(segcount, 0, numsides * sizeof(int)); + + // set up the extra data in case the map was loaded with regular nodes that might pass as GL nodes. + if (glsegextras == NULL) + { + for(int i=0;iPartnerSeg = &segs[partner]; + else seg->PartnerSeg = NULL; + seg->Subsector = glsegextras[i].Subsector; + } + } + + for(int i=0;isidedef == NULL) continue; // miniseg + int sidenum = int(seg->sidedef - sides); + + realsegs++; + segcount[sidenum]++; + FVector2 sidestart, sideend, segend(seg->v2->fx, seg->v2->fy); + GetSideVertices(sidenum, &sidestart, &sideend); + + sideend -=sidestart; + segend -= sidestart; + + seg->sidefrac = float(segend.Length() / sideend.Length()); + } + + // allocate memory + sides[0].segs = new seg_t*[realsegs]; + sides[0].numsegs = 0; + + for(int i = 1; i < numsides; i++) + { + sides[i].segs = sides[i-1].segs + segcount[i-1]; + sides[i].numsegs = 0; + } + delete [] segcount; + + // assign the segs + for(int i=0;isidedef != NULL) seg->sidedef->segs[seg->sidedef->numsegs++] = seg; + } + + // sort the segs + for(int i = 0; i < numsides; i++) + { + if (sides[i].numsegs > 1) qsort(sides[i].segs, sides[i].numsegs, sizeof(seg_t*), segcmp); + } +} + +//========================================================================== +// +// Initialize the level data for the GL renderer +// +//========================================================================== +extern int restart; + +void gl_PreprocessLevel() +{ + int i; + + static int datadone=-1; + + + if (datadone != restart) + { + datadone = restart; + gl_InitData(); + } + + PrepareSegs(); + PrepareSectorData(); + InitVertexData(); + for(i=0;iSetupLevel(); + } + +#if 0 + gl_CreateSections(); +#endif + + InitGLRMapinfoData(); +} + + + +//========================================================================== +// +// Cleans up all the GL data for the last level +// +//========================================================================== + +void gl_CleanLevelData() +{ + // Dynamic lights must be destroyed before the sector information here is deleted. + TThinkerIterator it(STAT_DLIGHT); + AActor * mo=it.Next(); + while (mo) + { + AActor * next = it.Next(); + mo->Destroy(); + mo=next; + } + + if (vertexes != NULL) + { + for(int i = 0; i < numvertexes; i++) if (vertexes[i].numsectors > 0) + { + if (vertexes[i].sectors != NULL) + { + delete [] vertexes[i].sectors; + vertexes[i].sectors = NULL; + } + if (vertexes[i].heightlist != NULL) + { + delete [] vertexes[i].heightlist; + vertexes[i].heightlist = NULL; + } + } + } + + if (sides && sides[0].segs) + { + delete [] sides[0].segs; + sides[0].segs = NULL; + } + if (sectors && sectors[0].subsectors) + { + delete [] sectors[0].subsectors; + sectors[0].subsectors = NULL; + } + for (int i=0;isectornum, int(subsectors[j].firstline->linedef-lines)); + break; + } + } + } +} \ No newline at end of file diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp new file mode 100644 index 000000000..036224338 --- /dev/null +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -0,0 +1,420 @@ +/* +** glc_vertexbuffer.cpp +** Vertex buffer handling. +** +**--------------------------------------------------------------------------- +** Copyright 2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "doomtype.h" +#include "p_local.h" +#include "m_argv.h" +#include "c_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" + + +CUSTOM_CVAR(Int, gl_usevbo, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (self < -1 || self > 2 || !(gl.flags&RFL_VBO)) + { + self = 0; + } + else if (self == -1) + { + if (!(gl.flags & RFL_NVIDIA)) self = 0; + else self = 2; + } + else if (GLRenderer != NULL && GLRenderer->mVBO != NULL && GLRenderer->mVBO->vbo_arg != self) + { + Printf("Vertex buffer use will be changed for the next level.\n"); + } +} + +//========================================================================== +// +// Create / destroy the VBO +// +//========================================================================== + +FVertexBuffer::FVertexBuffer() +{ + vbo_id = 0; + if (gl.flags&RFL_VBO) + { + if (gl_usevbo == -1) gl_usevbo.Callback(); + gl.GenBuffers(1, &vbo_id); + } +} + +FVertexBuffer::~FVertexBuffer() +{ + if (vbo_id != 0) + { + gl.DeleteBuffers(1, &vbo_id); + } +} + +//========================================================================== +// +// +// +//========================================================================== + +FFlatVertexBuffer::FFlatVertexBuffer() +: FVertexBuffer() +{ + if (!(gl.flags&RFL_VBO)) + { + vbo_arg = 0; + } + else + { + vbo_arg = gl_usevbo; + } + map = NULL; +} + +FFlatVertexBuffer::~FFlatVertexBuffer() +{ + UnmapVBO(); +} + +//========================================================================== +// +// Initialize a single vertex +// +//========================================================================== + +void FFlatVertex::SetFlatVertex(vertex_t *vt, const secplane_t & plane) +{ + x = vt->fx; + y = vt->fy; + z = plane.ZatPoint(vt->fx, vt->fy); + u = vt->fx/64.f; + v = -vt->fy/64.f; + w = dc = df = 0; +} + +//========================================================================== +// +// Find a 3D floor +// +//========================================================================== + +static F3DFloor *Find3DFloor(sector_t *target, sector_t *model) +{ + for(unsigned i=0; ie->XFloor.ffloors.Size(); i++) + { + F3DFloor *ffloor = target->e->XFloor.ffloors[i]; + if (ffloor->model == model) return ffloor; + } + return NULL; +} + +//========================================================================== +// +// Creates the vertices for one plane in one subsector +// +//========================================================================== + +int FFlatVertexBuffer::CreateSubsectorVertices(subsector_t *sub, const secplane_t &plane, int floor) +{ + int idx = vbo_shadowdata.Reserve(sub->numlines); + for(unsigned int k=0; knumlines; k++, idx++) + { + vbo_shadowdata[idx].SetFlatVertex(sub->firstline[k].v1, plane); + if (sub->sector->transdoor && floor) vbo_shadowdata[idx].z -= 1.f; + } + return idx; +} + +//========================================================================== +// +// Creates the vertices for one plane in one subsector +// +//========================================================================== + +int FFlatVertexBuffer::CreateSectorVertices(sector_t *sec, const secplane_t &plane, int floor) +{ + int rt = vbo_shadowdata.Size(); + // First calculate the vertices for the sector itself + for(int j=0; jsubsectorcount; j++) + { + subsector_t *sub = sec->subsectors[j]; + CreateSubsectorVertices(sub, plane, floor); + } + return rt; +} + +//========================================================================== +// +// +// +//========================================================================== + +int FFlatVertexBuffer::CreateVertices(int h, sector_t *sec, const secplane_t &plane, int floor) +{ + // First calculate the vertices for the sector itself + sec->vboheight[h] = sec->GetPlaneTexZ(h); + sec->vboindex[h] = CreateSectorVertices(sec, plane, floor); + + // Next are all sectors using this one as heightsec + TArray &fakes = sec->e->FakeFloor.Sectors; + for (unsigned g=0; gvboindex[2+h] = CreateSectorVertices(fsec, plane, false); + } + + // and finally all attached 3D floors + TArray &xf = sec->e->XFloor.attached; + for (unsigned g=0; gflags & FF_RENDERPLANES) + { + bool dotop = (ffloor->top.model == sec) && (ffloor->top.isceiling == h); + bool dobottom = (ffloor->bottom.model == sec) && (ffloor->bottom.isceiling == h); + + if (dotop || dobottom) + { + if (dotop) ffloor->top.vindex = vbo_shadowdata.Size(); + if (dobottom) ffloor->bottom.vindex = vbo_shadowdata.Size(); + + CreateSectorVertices(fsec, plane, false); + } + } + } + sec->vbocount[h] = vbo_shadowdata.Size() - sec->vboindex[h]; + return sec->vboindex[h]; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void FFlatVertexBuffer::CreateFlatVBO() +{ + for (int h = sector_t::floor; h <= sector_t::ceiling; h++) + { + for(int i=0; iXFloor.ffloors.Size(); j++) + { + F3DFloor *ff = sectors[i].e->XFloor.ffloors[j]; + + if (ff->top.model == §ors[i]) + { + ff->top.vindex = sectors[i].vboindex[ff->top.isceiling]; + } + if (ff->bottom.model == §ors[i]) + { + ff->bottom.vindex = sectors[i].vboindex[ff->top.isceiling]; + } + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FFlatVertexBuffer::MapVBO() +{ + if (map == NULL) + { + gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); + map = (FFlatVertex*)gl.MapBufferRange(GL_ARRAY_BUFFER, 0, vbo_shadowdata.Size() * sizeof(FFlatVertex), + GL_MAP_WRITE_BIT|GL_MAP_FLUSH_EXPLICIT_BIT|GL_MAP_UNSYNCHRONIZED_BIT); + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FFlatVertexBuffer::UnmapVBO() +{ + if (map != NULL) + { + gl.UnmapBuffer(GL_ARRAY_BUFFER); + map = NULL; + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) +{ + int startvt = sec->vboindex[plane]; + int countvt = sec->vbocount[plane]; + secplane_t &splane = sec->GetSecPlane(plane); + FFlatVertex *vt = &vbo_shadowdata[startvt]; + for(int i=0; iz = splane.ZatPoint(vt->x, vt->y); + if (plane == sector_t::floor && sec->transdoor) vt->z -= 1; + } + if (gl.flags & RFL_MAP_BUFFER_RANGE) + { + MapVBO(); + if (map == NULL) return; // Error + memcpy(&map[startvt], &vbo_shadowdata[startvt], countvt * sizeof(FFlatVertex)); + gl.FlushMappedBufferRange(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex)); + } + else + { + gl.BufferSubData(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex), &vbo_shadowdata[startvt]); + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FFlatVertexBuffer::CreateVBO() +{ + vbo_shadowdata.Clear(); + if (vbo_arg > 0) + { + CreateFlatVBO(); + gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); + gl.BufferData(GL_ARRAY_BUFFER, vbo_shadowdata.Size() * sizeof(FFlatVertex), &vbo_shadowdata[0], GL_DYNAMIC_DRAW); + } + else if (sectors) + { + // set all VBO info to invalid values so that we can save some checks in the rendering code + for(int i=0;i 0) + { + UnmapVBO(); + gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); + gl.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glVertexPointer(3,GL_FLOAT, sizeof(FFlatVertex), &VTO->x); + glTexCoordPointer(2,GL_FLOAT, sizeof(FFlatVertex), &VTO->u); + gl.EnableClientState(GL_VERTEX_ARRAY); + gl.EnableClientState(GL_TEXTURE_COORD_ARRAY); + gl.DisableClientState(GL_INDEX_ARRAY); + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FFlatVertexBuffer::CheckPlanes(sector_t *sector) +{ + if (sector->GetPlaneTexZ(sector_t::ceiling) != sector->vboheight[sector_t::ceiling]) + { + if (sector->ceilingdata == NULL) // only update if there's no thinker attached + { + UpdatePlaneVertices(sector, sector_t::ceiling); + sector->vboheight[sector_t::ceiling] = sector->GetPlaneTexZ(sector_t::ceiling); + } + } + if (sector->GetPlaneTexZ(sector_t::floor) != sector->vboheight[sector_t::floor]) + { + if (sector->floordata == NULL) // only update if there's no thinker attached + { + UpdatePlaneVertices(sector, sector_t::floor); + sector->vboheight[sector_t::floor] = sector->GetPlaneTexZ(sector_t::floor); + } + } +} + +//========================================================================== +// +// checks the validity of all planes attached to this sector +// and updates them if possible. Anything moving will not be +// updated unless it stops. This is to ensure that we never +// have to synchronize with the rendering process. +// +//========================================================================== + +void FFlatVertexBuffer::CheckUpdate(sector_t *sector) +{ + if (vbo_arg == 2) + { + CheckPlanes(sector); + sector_t *hs = sector->GetHeightSec(); + if (hs != NULL) CheckPlanes(hs); + for(unsigned i = 0; i < sector->e->XFloor.ffloors.Size(); i++) + CheckPlanes(sector->e->XFloor.ffloors[i]->model); + } +} \ No newline at end of file diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h new file mode 100644 index 000000000..6c2b83a15 --- /dev/null +++ b/src/gl/data/gl_vertexbuffer.h @@ -0,0 +1,62 @@ +#ifndef __VERTEXBUFFER_H +#define __VERTEXBUFFER_H + +#include "tarray.h" + +struct vertex_t; +struct secplane_t; +struct subsector_t; +struct sector_t; + + +class FVertexBuffer +{ +protected: + unsigned int vbo_id; + +public: + FVertexBuffer(); + virtual ~FVertexBuffer(); + virtual void BindVBO() = 0; +}; + +struct FFlatVertex // exactly 32 bytes large +{ + float x,z,y,w; // w only for padding to make one vertex 32 bytes - maybe it will find some use later + float u,v; // texture coordinates + float dc, df; // distance to floor and ceiling on walls - used for glowing + + void SetFlatVertex(vertex_t *vt, const secplane_t &plane); +}; + +#define VTO ((FFlatVertex*)NULL) + + +class FFlatVertexBuffer : public FVertexBuffer +{ + FFlatVertex *map; + + void MapVBO(); + void CheckPlanes(sector_t *sector); + +public: + int vbo_arg; + TArray vbo_shadowdata; // this is kept around for non-VBO rendering + +public: + FFlatVertexBuffer(); + ~FFlatVertexBuffer(); + + int CreateSubsectorVertices(subsector_t *sub, const secplane_t &plane, int floor); + int CreateSectorVertices(sector_t *sec, const secplane_t &plane, int floor); + int CreateVertices(int h, sector_t *sec, const secplane_t &plane, int floor); + void CreateFlatVBO(); + void CreateVBO(); + void UpdatePlaneVertices(sector_t *sec, int plane); + void BindVBO(); + void CheckUpdate(sector_t *sector); + void UnmapVBO(); + +}; + +#endif \ No newline at end of file diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp new file mode 100644 index 000000000..731b4dfd2 --- /dev/null +++ b/src/gl/dynlights/a_dynlight.cpp @@ -0,0 +1,742 @@ +/* +** a_dynlight.cpp +** Implements actors representing dynamic lights (hardware independent) +** +**--------------------------------------------------------------------------- +** Copyright 2003 Timothy Stump +** Copyright 2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "templates.h" +#include "m_random.h" +#include "p_local.h" +#include "c_dispatch.h" +#include "g_level.h" +#include "thingdef/thingdef.h" +#include "i_system.h" + + +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/utility/gl_convert.h" +#include "gl/utility/gl_templates.h" + +EXTERN_CVAR (Float, gl_lights_size); +EXTERN_CVAR (Bool, gl_lights_additive); + + +//========================================================================== +// +//========================================================================== +DEFINE_CLASS_PROPERTY(type, S, DynamicLight) +{ + PROP_STRING_PARM(str, 0); + static const char * ltype_names[]={ + "Point","Pulse","Flicker","Sector","RandomFlicker", "ColorPulse", "ColorFlicker", "RandomColorFlicker", NULL}; + + static const int ltype_values[]={ + PointLight, PulseLight, FlickerLight, SectorLight, RandomFlickerLight, ColorPulseLight, ColorFlickerLight, RandomColorFlickerLight }; + + int style = MatchString(str, ltype_names); + if (style < 0) I_Error("Unknown light type '%s'", str); + defaults->lighttype = ltype_values[style]; +} + +//========================================================================== +// +// Actor classes +// +// For flexibility all functionality has been packed into a single class +// which is controlled by flags +// +//========================================================================== +IMPLEMENT_CLASS (ADynamicLight) +IMPLEMENT_CLASS (AVavoomLight) +IMPLEMENT_CLASS (AVavoomLightWhite) +IMPLEMENT_CLASS (AVavoomLightColor) + +void AVavoomLight::BeginPlay () +{ + // This must not call Super::BeginPlay! + ChangeStatNum(STAT_DLIGHT); + if (Sector) z -= Sector->floorplane.ZatPoint(x, y); + lighttype = PointLight; +} + +void AVavoomLightWhite::BeginPlay () +{ + m_intensity[0] = args[0] * 4; + args[LIGHT_RED] = 128; + args[LIGHT_GREEN] = 128; + args[LIGHT_BLUE] = 128; + + Super::BeginPlay(); +} + +void AVavoomLightColor::BeginPlay () +{ + int l_args[5]; + memcpy(l_args, args, sizeof(l_args)); + memset(args, 0, 5); + m_intensity[0] = l_args[0] * 4; + args[LIGHT_RED] = l_args[1] >> 1; + args[LIGHT_GREEN] = l_args[2] >> 1; + args[LIGHT_BLUE] = l_args[3] >> 1; + + Super::BeginPlay(); +} + +static FRandom randLight; + +//========================================================================== +// +// Base class +// +//========================================================================== + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::Serialize(FArchive &arc) +{ + Super::Serialize (arc); + arc << lightflags << lighttype; + arc << m_tickCount << m_currentIntensity; + arc << m_intensity[0] << m_intensity[1]; + + if (lighttype == PulseLight) arc << m_lastUpdate << m_cycler; + if (arc.IsLoading()) LinkLight(); + +} + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::BeginPlay() +{ + //Super::BeginPlay(); + ChangeStatNum(STAT_DLIGHT); + + m_intensity[0] = args[LIGHT_INTENSITY]; + m_intensity[1] = args[LIGHT_SECONDARY_INTENSITY]; +} + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::PostBeginPlay() +{ + Super::PostBeginPlay(); + + if (!(SpawnFlags & MTF_DORMANT)) + { + Activate (NULL); + } + + subsector = R_PointInSubsector(x,y); +} + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::Activate(AActor *activator) +{ + //Super::Activate(activator); + flags2&=~MF2_DORMANT; + + m_currentIntensity = float(m_intensity[0]); + m_tickCount = 0; + + if (lighttype == PulseLight) + { + float pulseTime = ANGLE_TO_FLOAT(this->angle) / TICRATE; + + m_lastUpdate = level.maptime; + m_cycler.SetParams(float(m_intensity[1]), float(m_intensity[0]), pulseTime); + m_cycler.ShouldCycle(true); + m_cycler.SetCycleType(CYCLE_Sin); + m_currentIntensity = (BYTE)m_cycler.GetVal(); + } +} + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::Deactivate(AActor *activator) +{ + //Super::Deactivate(activator); + flags2|=MF2_DORMANT; +} + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::Tick() +{ + + if (IsOwned()) + { + if (!target || !target->state) + { + this->Destroy(); + return; + } + if (target->flags & MF_UNMORPHED) return; + } + + // Don't bother if the light won't be shown + if (!IsActive()) return; + + // I am doing this with a type field so that I can dynamically alter the type of light + // without having to create or maintain multiple objects. + switch(lighttype) + { + case PulseLight: + { + float diff = (level.maptime - m_lastUpdate) / (float)TICRATE; + + m_lastUpdate = level.maptime; + m_cycler.Update(diff); + m_currentIntensity = m_cycler.GetVal(); + break; + } + + case FlickerLight: + { + BYTE rnd = randLight(); + float pct = ANGLE_TO_FLOAT(angle)/360.f; + + m_currentIntensity = float(m_intensity[rnd >= pct * 255]); + break; + } + + case RandomFlickerLight: + { + int flickerRange = m_intensity[1] - m_intensity[0]; + float amt = randLight() / 255.f; + + m_tickCount++; + + if (m_tickCount > ANGLE_TO_FLOAT(angle)) + { + m_currentIntensity = float(m_intensity[0] + (amt * flickerRange)); + m_tickCount = 0; + } + break; + } + +#if 0 + // These need some more work elsewhere + case ColorFlickerLight: + { + BYTE rnd = randLight(); + float pct = ANGLE_TO_FLOAT(angle)/360.f; + + m_currentIntensity = m_intensity[rnd >= pct * 255]; + break; + } + + case RandomColorFlickerLight: + { + int flickerRange = m_intensity[1] - m_intensity[0]; + float amt = randLight() / 255.f; + + m_tickCount++; + + if (m_tickCount > ANGLE_TO_FLOAT(angle)) + { + m_currentIntensity = m_intensity[0] + (amt * flickerRange); + m_tickCount = 0; + } + break; + } +#endif + + case SectorLight: + { + float intensity; + float scale = args[LIGHT_SCALE] / 8.f; + + if (scale == 0.f) scale = 1.f; + + intensity = Sector->lightlevel * scale; + intensity = clamp(intensity, 0.f, 255.f); + + m_currentIntensity = intensity; + break; + } + + case PointLight: + m_currentIntensity = float(m_intensity[0]); + break; + } + + UpdateLocation(); +} + + + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::UpdateLocation() +{ + fixed_t oldx=x; + fixed_t oldy=y; + fixed_t oldradius=radius; + float intensity; + + if (IsActive()) + { + if (target) + { + angle_t angle = target->angle>>ANGLETOFINESHIFT; + PrevX = x = target->x + FixedMul(m_offX, finecosine[angle]) + FixedMul(m_offZ, finesine[angle]); + PrevY = y = target->y + FixedMul(m_offX, finesine[angle]) - FixedMul(m_offZ, finecosine[angle]); + PrevZ = z = target->z + m_offY + target->GetBobOffset(); + subsector = R_PointInSubsector(x, y); + Sector = subsector->sector; + } + + + // The radius being used here is always the maximum possible with the + // current settings. This avoids constant relinking of flickering lights + + if (lighttype == FlickerLight || lighttype == RandomFlickerLight) + { + intensity = float(m_intensity[1]); + } + else + { + intensity = m_currentIntensity; + } + radius = FLOAT2FIXED(intensity * 2.0f * gl_lights_size); + + if (x!=oldx || y!=oldy || radius!=oldradius) + { + //Update the light lists + LinkLight(); + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::SetOffset(fixed_t x, fixed_t y, fixed_t z) +{ + m_offX = x; + m_offY = y; + m_offZ = z; + UpdateLocation(); +} + + +//========================================================================== +// +// The target pointer in dynamic lights should never be substituted unless +// notOld is NULL (which indicates that the object was destroyed by force.) +// +//========================================================================== +size_t ADynamicLight::PointerSubstitution (DObject *old, DObject *notOld) +{ + AActor *saved_target = target; + size_t ret = Super::PointerSubstitution(old, notOld); + if (notOld != NULL) target = saved_target; + return ret; +} + +//============================================================================= +// +// These have been copied from the secnode code and modified for the light links +// +// P_AddSecnode() searches the current list to see if this sector is +// already there. If not, it adds a sector node at the head of the list of +// sectors this object appears in. This is called when creating a list of +// nodes that will get linked in later. Returns a pointer to the new node. +// +//============================================================================= +static FreeList freelist; + +FLightNode * AddLightNode(FLightNode ** thread, void * linkto, ADynamicLight * light, FLightNode *& nextnode) +{ + FLightNode * node; + + node = nextnode; + while (node) + { + if (node->targ==linkto) // Already have a node for this sector? + { + node->lightsource = light; // Yes. Setting m_thing says 'keep it'. + return(nextnode); + } + node = node->nextTarget; + } + + // Couldn't find an existing node for this sector. Add one at the head + // of the list. + + node = freelist.GetNew(); + + node->targ = linkto; + node->lightsource = light; + + node->prevTarget = &nextnode; + node->nextTarget = nextnode; + + if (nextnode) nextnode->prevTarget = &node->nextTarget; + + // Add new node at head of sector thread starting at s->touching_thinglist + + node->prevLight = thread; + node->nextLight = *thread; + if (node->nextLight) node->nextLight->prevLight=&node->nextLight; + *thread = node; + return(node); +} + + +//============================================================================= +// +// P_DelSecnode() deletes a sector node from the list of +// sectors this object appears in. Returns a pointer to the next node +// on the linked list, or NULL. +// +//============================================================================= + +static FLightNode * DeleteLightNode(FLightNode * node) +{ + FLightNode * tn; // next node on thing thread + + if (node) + { + + *node->prevTarget = node->nextTarget; + if (node->nextTarget) node->nextTarget->prevTarget=node->prevTarget; + + *node->prevLight = node->nextLight; + if (node->nextLight) node->nextLight->prevLight=node->prevLight; + + // Return this node to the freelist + tn=node->nextTarget; + freelist.Release(node); + return(tn); + } + return(NULL); +} // phares 3/13/98 + + + +//========================================================================== +// +// Gets the light's distance to a line +// +//========================================================================== + +float ADynamicLight::DistToSeg(seg_t *seg) +{ + float u, px, py; + + float seg_dx = FIXED2FLOAT(seg->v2->x - seg->v1->x); + float seg_dy = FIXED2FLOAT(seg->v2->y - seg->v1->y); + float seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy; + + u = ( FIXED2FLOAT(x - seg->v1->x) * seg_dx + FIXED2FLOAT(y - seg->v1->y) * seg_dy) / seg_length_sq; + if (u < 0.f) u = 0.f; // clamp the test point to the line segment + if (u > 1.f) u = 1.f; + + px = FIXED2FLOAT(seg->v1->x) + (u * seg_dx); + py = FIXED2FLOAT(seg->v1->y) + (u * seg_dy); + + px -= FIXED2FLOAT(x); + py -= FIXED2FLOAT(y); + + return (px*px) + (py*py); +} + + +//========================================================================== +// +// Collect all touched sidedefs and subsectors +// to sidedefs and sector parts. +// +//========================================================================== + +void ADynamicLight::CollectWithinRadius(subsector_t *subSec, float radius) +{ + if (!subSec) return; + + bool additive = (flags4&MF4_ADDITIVE) || gl_lights_additive; + + subSec->validcount = ::validcount; + + touching_subsectors = AddLightNode(&subSec->lighthead[additive], subSec, this, touching_subsectors); + + for (unsigned int i = 0; i < subSec->numlines; i++) + { + seg_t * seg = subSec->firstline + i; + + if (seg->sidedef && seg->linedef && seg->linedef->validcount!=::validcount) + { + // light is in front of the seg + if (DMulScale32 (y-seg->v1->y, seg->v2->x-seg->v1->x, seg->v1->x-x, seg->v2->y-seg->v1->y) <=0) + { + seg->linedef->validcount=validcount; + touching_sides = AddLightNode(&seg->sidedef->lighthead[additive], + seg->sidedef, this, touching_sides); + } + } + + seg_t *partner = seg->PartnerSeg; + if (partner) + { + subsector_t *sub = partner->Subsector; + if (sub != NULL && sub->validcount!=::validcount) + { + // check distance from x/y to seg and if within radius add opposing subsector (lather/rinse/repeat) + if (DistToSeg(seg) <= radius) + { + CollectWithinRadius(sub, radius); + } + } + } + } +} + +//========================================================================== +// +// Link the light into the world +// +//========================================================================== + +void ADynamicLight::LinkLight() +{ + // mark the old light nodes + FLightNode * node; + + node = touching_sides; + while (node) + { + node->lightsource = NULL; + node = node->nextTarget; + } + node = touching_subsectors; + while (node) + { + node->lightsource = NULL; + node = node->nextTarget; + } + + if (radius>0) + { + // passing in radius*radius allows us to do a distance check without any calls to sqrtf + ::validcount++; + subsector_t * subSec = R_PointInSubsector(x, y); + if (subSec) + { + float fradius = FIXED2FLOAT(radius); + CollectWithinRadius(subSec, fradius*fradius); + } + } + + // Now delete any nodes that won't be used. These are the ones where + // m_thing is still NULL. + + node = touching_sides; + while (node) + { + if (node->lightsource == NULL) + { + node = DeleteLightNode(node); + } + else + node = node->nextTarget; + } + + node = touching_subsectors; + while (node) + { + if (node->lightsource == NULL) + { + node = DeleteLightNode(node); + } + else + node = node->nextTarget; + } +} + + +//========================================================================== +// +// Deletes the link lists +// +//========================================================================== +void ADynamicLight::UnlinkLight () +{ + if (owned && target != NULL) + { + // Delete reference in owning actor + for(int c=target->dynamiclights.Size()-1; c>=0; c--) + { + if (target->dynamiclights[c] == this) + { + target->dynamiclights.Delete(c); + break; + } + } + } + while (touching_sides) touching_sides = DeleteLightNode(touching_sides); + while (touching_subsectors) touching_subsectors = DeleteLightNode(touching_subsectors); +} + +void ADynamicLight::Destroy() +{ + UnlinkLight(); + Super::Destroy(); +} + + +//========================================================================== +// +// Needed for garbage collection +// +//========================================================================== + +size_t AActor::PropagateMark() +{ + for (unsigned i=0; i it; + + while ((dl=it.Next())) + { + walls=0; + sectors=0; + Printf("%s at (%f, %f, %f), color = 0x%02x%02x%02x, radius = %f ", + dl->target? dl->target->GetClass()->TypeName.GetChars() : dl->GetClass()->TypeName.GetChars(), + FIXED2FLOAT(dl->x), FIXED2FLOAT(dl->y), FIXED2FLOAT(dl->z), dl->args[LIGHT_RED], + dl->args[LIGHT_GREEN], dl->args[LIGHT_BLUE], FIXED2FLOAT(dl->radius)); + i++; + + if (dl->target) + { + FTextureID spr = gl_GetSpriteFrame(dl->target->sprite, dl->target->frame, 0, 0, NULL); + Printf(", frame = %s ", TexMan[spr]->Name); + } + + + FLightNode * node; + + node=dl->touching_sides; + + while (node) + { + walls++; + allwalls++; + node = node->nextTarget; + } + + node=dl->touching_subsectors; + + while (node) + { + allsectors++; + sectors++; + node = node->nextTarget; + } + + Printf("- %d walls, %d subsectors\n", walls, sectors); + + } + Printf("%i dynamic lights, %d walls, %d subsectors\n\n\n", i, allwalls, allsectors); +} + +CCMD(listsublights) +{ + for(int i=0;ilighthead[0]; + while (node != NULL) + { + lights++; + node = node->nextLight; + } + + node = sub->lighthead[1]; + while (node != NULL) + { + addlights++; + node = node->nextLight; + } + Printf(PRINT_LOG, "Subsector %d - %d lights, %d additive lights\n", i, lights, addlights); + } +} + diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp new file mode 100644 index 000000000..6c6209664 --- /dev/null +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -0,0 +1,1365 @@ +/* +** gl_dynlight.cpp +** Light definitions for actors. +** +**--------------------------------------------------------------------------- +** Copyright 2003 Timothy Stump +** Copyright 2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + + +#include +#include "i_system.h" +#include "doomtype.h" +#include "c_cvars.h" +#include "c_dispatch.h" +#include "m_random.h" +#include "sc_man.h" +#include "templates.h" +#include "w_wad.h" +#include "gi.h" +#include "r_state.h" +#include "stats.h" +#include "zstring.h" +#include "d_dehacked.h" + + +#include "gl/dynlights/gl_dynlight.h" +#include "gl/textures/gl_skyboxtexture.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_convert.h" + +EXTERN_CVAR (Float, gl_lights_intensity); +EXTERN_CVAR (Float, gl_lights_size); +int ScriptDepth; +void gl_InitGlow(FScanner &sc); +void gl_ParseBrightmap(FScanner &sc, int); +void gl_DestroyUserShaders(); +void gl_ParseHardwareShader(FScanner &sc, int deflump); +void gl_ParseSkybox(FScanner &sc); +void gl_ParseDetailTexture(FScanner &sc); +void gl_ParseVavoomSkybox(); + +//========================================================================== +// +// Dehacked aliasing +// +//========================================================================== + +inline const PClass * GetRealType(const PClass * ti) +{ + FActorInfo *rep = ti->ActorInfo->GetReplacement(false); + if (rep != ti->ActorInfo && rep != NULL && rep->Class->IsDescendantOf(RUNTIME_CLASS(ADehackedPickup))) + { + return rep->Class; + } + return ti; +} + + + +//========================================================================== +// +// Light associations +// +//========================================================================== +class FLightAssociation +{ +public: + //FLightAssociation(); + FLightAssociation(FName actorName, const char *frameName, FName lightName) + : m_ActorName(actorName), m_AssocLight(lightName) + { + mysnprintf(m_FrameName, 8, "%s", frameName); + } + + FName ActorName() { return m_ActorName; } + const char *FrameName() { return m_FrameName; } + FName Light() { return m_AssocLight; } + void ReplaceLightName(FName newName) { m_AssocLight = newName; } +protected: + char m_FrameName[8]; + FName m_ActorName, m_AssocLight; +}; + +TArray LightAssociations; + + +//========================================================================== +// +// Light definitions +// +//========================================================================== +class FLightDefaults +{ +public: + FLightDefaults(FName name, ELightType type); + + void ApplyProperties(ADynamicLight * light) const; + FName GetName() const { return m_Name; } + void SetAngle(angle_t angle) { m_Angle = angle; } + void SetArg(int arg, BYTE val) { m_Args[arg] = val; } + BYTE GetArg(int arg) { return m_Args[arg]; } + void SetOffset(float* ft) { m_X = FLOAT2FIXED(ft[0]); m_Y = FLOAT2FIXED(ft[1]); m_Z = FLOAT2FIXED(ft[2]); } + void SetSubtractive(bool subtract) { m_subtractive = subtract; } + void SetAdditive(bool add) { m_additive = add; } + void SetDontLightSelf(bool add) { m_dontlightself = add; } + void SetHalo(bool halo) { m_halo = halo; } +protected: + FName m_Name; + unsigned char m_Args[5]; + angle_t m_Angle; + fixed_t m_X, m_Y, m_Z; + ELightType m_type; + bool m_subtractive, m_additive, m_halo, m_dontlightself; +}; + +TArray LightDefaults; + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +FLightDefaults::FLightDefaults(FName name, ELightType type) +{ + m_Name = name; + m_type = type; + + m_X = m_Y = m_Z = 0; + memset(m_Args, 0, 5); + + m_subtractive = false; + m_additive = false; + m_halo = false; + m_dontlightself = false; +} + +void FLightDefaults::ApplyProperties(ADynamicLight * light) const +{ + light->lighttype = m_type; + light->angle = m_Angle; + light->SetOffset(m_X, m_Y, m_Z); + light->halo = m_halo; + for (int a = 0; a < 3; a++) light->args[a] = clamp((int)(m_Args[a] * gl_lights_intensity), 0, 255); + light->m_intensity[0] = int(m_Args[LIGHT_INTENSITY]); + light->m_intensity[1] = int(m_Args[LIGHT_SECONDARY_INTENSITY]); + light->flags4&=~(MF4_ADDITIVE|MF4_SUBTRACTIVE|MF4_DONTLIGHTSELF); + if (m_subtractive) light->flags4|=MF4_SUBTRACTIVE; + if (m_additive) light->flags4|=MF4_ADDITIVE; + if (m_dontlightself) light->flags4|=MF4_DONTLIGHTSELF; +} + + +//========================================================================== +// +// light definition file parser +// +//========================================================================== + + +static const char *LightTags[]= +{ + "color", + "size", + "secondarySize", + "offset", + "chance", + "interval", + "scale", + "frame", + "light", + "{", + "}", + "subtractive", + "additive", + "halo", + "dontlightself", + NULL +}; + + +enum { + LIGHTTAG_COLOR, + LIGHTTAG_SIZE, + LIGHTTAG_SECSIZE, + LIGHTTAG_OFFSET, + LIGHTTAG_CHANCE, + LIGHTTAG_INTERVAL, + LIGHTTAG_SCALE, + LIGHTTAG_FRAME, + LIGHTTAG_LIGHT, + LIGHTTAG_OPENBRACE, + LIGHTTAG_CLOSEBRACE, + LIGHTTAG_SUBTRACTIVE, + LIGHTTAG_ADDITIVE, + LIGHTTAG_HALO, + LIGHTTAG_DONTLIGHTSELF, +}; + + +extern int ScriptDepth; + + +//========================================================================== +// +// +// +//========================================================================== + +inline float gl_ParseFloat(FScanner &sc) +{ + sc.GetFloat(); + + return float(sc.Float); +} + + +inline int gl_ParseInt(FScanner &sc) +{ + sc.GetNumber(); + + return sc.Number; +} + + +inline char *gl_ParseString(FScanner &sc) +{ + sc.GetString(); + + return sc.String; +} + + +void gl_ParseTriple(FScanner &sc, float floatVal[3]) +{ + for (int i = 0; i < 3; i++) + { + floatVal[i] = gl_ParseFloat(sc); + } +} + + +void gl_AddLightDefaults(FLightDefaults *defaults) +{ + FLightDefaults *temp; + unsigned int i; + + // remove duplicates + for (i = 0; i < LightDefaults.Size(); i++) + { + temp = LightDefaults[i]; + if (temp->GetName() == defaults->GetName()) + { + delete temp; + LightDefaults.Delete(i); + break; + } + } + + LightDefaults.Push(defaults); +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParsePointLight(FScanner &sc) +{ + int type; + float floatTriple[3]; + int intVal; + FLightDefaults *defaults; + + // get name + sc.GetString(); + FName name = sc.String; + + // check for opening brace + sc.GetString(); + if (sc.Compare("{")) + { + defaults = new FLightDefaults(name, PointLight); + ScriptDepth++; + while (ScriptDepth) + { + sc.GetString(); + type = sc.MatchString(LightTags); + switch (type) + { + case LIGHTTAG_OPENBRACE: + ScriptDepth++; + break; + case LIGHTTAG_CLOSEBRACE: + ScriptDepth--; + break; + case LIGHTTAG_COLOR: + gl_ParseTriple(sc, floatTriple); + defaults->SetArg(LIGHT_RED, clamp((int)(floatTriple[0] * 255), 0, 255)); + defaults->SetArg(LIGHT_GREEN, clamp((int)(floatTriple[1] * 255), 0, 255)); + defaults->SetArg(LIGHT_BLUE, clamp((int)(floatTriple[2] * 255), 0, 255)); + break; + case LIGHTTAG_OFFSET: + gl_ParseTriple(sc, floatTriple); + defaults->SetOffset(floatTriple); + break; + case LIGHTTAG_SIZE: + intVal = clamp(gl_ParseInt(sc), 0, 255); + defaults->SetArg(LIGHT_INTENSITY, intVal); + break; + case LIGHTTAG_SUBTRACTIVE: + defaults->SetSubtractive(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_ADDITIVE: + defaults->SetAdditive(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_HALO: + defaults->SetHalo(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_DONTLIGHTSELF: + defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); + break; + default: + sc.ScriptError("Unknown tag: %s\n", sc.String); + } + } + gl_AddLightDefaults(defaults); + } + else + { + sc.ScriptError("Expected '{'.\n"); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParsePulseLight(FScanner &sc) +{ + int type; + float floatVal, floatTriple[3]; + int intVal; + FLightDefaults *defaults; + + // get name + sc.GetString(); + FName name = sc.String; + + // check for opening brace + sc.GetString(); + if (sc.Compare("{")) + { + defaults = new FLightDefaults(name, PulseLight); + ScriptDepth++; + while (ScriptDepth) + { + sc.GetString(); + type = sc.MatchString(LightTags); + switch (type) + { + case LIGHTTAG_OPENBRACE: + ScriptDepth++; + break; + case LIGHTTAG_CLOSEBRACE: + ScriptDepth--; + break; + case LIGHTTAG_COLOR: + gl_ParseTriple(sc, floatTriple); + defaults->SetArg(LIGHT_RED, clamp((int)(floatTriple[0] * 255), 0, 255)); + defaults->SetArg(LIGHT_GREEN, clamp((int)(floatTriple[1] * 255), 0, 255)); + defaults->SetArg(LIGHT_BLUE, clamp((int)(floatTriple[2] * 255), 0, 255)); + break; + case LIGHTTAG_OFFSET: + gl_ParseTriple(sc, floatTriple); + defaults->SetOffset(floatTriple); + break; + case LIGHTTAG_SIZE: + intVal = clamp(gl_ParseInt(sc), 0, 255); + defaults->SetArg(LIGHT_INTENSITY, intVal); + break; + case LIGHTTAG_SECSIZE: + intVal = clamp(gl_ParseInt(sc), 0, 255); + defaults->SetArg(LIGHT_SECONDARY_INTENSITY, intVal); + break; + case LIGHTTAG_INTERVAL: + floatVal = gl_ParseFloat(sc); + defaults->SetAngle(FLOAT_TO_ANGLE(floatVal * TICRATE)); + break; + case LIGHTTAG_SUBTRACTIVE: + defaults->SetSubtractive(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_HALO: + defaults->SetHalo(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_DONTLIGHTSELF: + defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); + break; + default: + sc.ScriptError("Unknown tag: %s\n", sc.String); + } + } + gl_AddLightDefaults(defaults); + } + else + { + sc.ScriptError("Expected '{'.\n"); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParseFlickerLight(FScanner &sc) +{ + int type; + float floatVal, floatTriple[3]; + int intVal; + FLightDefaults *defaults; + + // get name + sc.GetString(); + FName name = sc.String; + + // check for opening brace + sc.GetString(); + if (sc.Compare("{")) + { + defaults = new FLightDefaults(name, FlickerLight); + ScriptDepth++; + while (ScriptDepth) + { + sc.GetString(); + type = sc.MatchString(LightTags); + switch (type) + { + case LIGHTTAG_OPENBRACE: + ScriptDepth++; + break; + case LIGHTTAG_CLOSEBRACE: + ScriptDepth--; + break; + case LIGHTTAG_COLOR: + gl_ParseTriple(sc, floatTriple); + defaults->SetArg(LIGHT_RED, clamp((int)(floatTriple[0] * 255), 0, 255)); + defaults->SetArg(LIGHT_GREEN, clamp((int)(floatTriple[1] * 255), 0, 255)); + defaults->SetArg(LIGHT_BLUE, clamp((int)(floatTriple[2] * 255), 0, 255)); + break; + case LIGHTTAG_OFFSET: + gl_ParseTriple(sc, floatTriple); + defaults->SetOffset(floatTriple); + break; + case LIGHTTAG_SIZE: + intVal = clamp(gl_ParseInt(sc), 0, 255); + defaults->SetArg(LIGHT_INTENSITY, intVal); + break; + case LIGHTTAG_SECSIZE: + intVal = clamp(gl_ParseInt(sc), 0, 255); + defaults->SetArg(LIGHT_SECONDARY_INTENSITY, intVal); + break; + case LIGHTTAG_CHANCE: + floatVal = gl_ParseFloat(sc); + defaults->SetAngle((angle_t)(floatVal * ANGLE_MAX)); + break; + case LIGHTTAG_SUBTRACTIVE: + defaults->SetSubtractive(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_HALO: + defaults->SetHalo(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_DONTLIGHTSELF: + defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); + break; + default: + sc.ScriptError("Unknown tag: %s\n", sc.String); + } + } + gl_AddLightDefaults(defaults); + } + else + { + sc.ScriptError("Expected '{'.\n"); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParseFlickerLight2(FScanner &sc) +{ + int type; + float floatVal, floatTriple[3]; + int intVal; + FLightDefaults *defaults; + + // get name + sc.GetString(); + FName name = sc.String; + + // check for opening brace + sc.GetString(); + if (sc.Compare("{")) + { + defaults = new FLightDefaults(name, RandomFlickerLight); + ScriptDepth++; + while (ScriptDepth) + { + sc.GetString(); + type = sc.MatchString(LightTags); + switch (type) + { + case LIGHTTAG_OPENBRACE: + ScriptDepth++; + break; + case LIGHTTAG_CLOSEBRACE: + ScriptDepth--; + break; + case LIGHTTAG_COLOR: + gl_ParseTriple(sc, floatTriple); + defaults->SetArg(LIGHT_RED, clamp((int)(floatTriple[0] * 255), 0, 255)); + defaults->SetArg(LIGHT_GREEN, clamp((int)(floatTriple[1] * 255), 0, 255)); + defaults->SetArg(LIGHT_BLUE, clamp((int)(floatTriple[2] * 255), 0, 255)); + break; + case LIGHTTAG_OFFSET: + gl_ParseTriple(sc, floatTriple); + defaults->SetOffset(floatTriple); + break; + case LIGHTTAG_SIZE: + intVal = clamp(gl_ParseInt(sc), 0, 255); + defaults->SetArg(LIGHT_INTENSITY, intVal); + break; + case LIGHTTAG_SECSIZE: + intVal = clamp(gl_ParseInt(sc), 0, 255); + defaults->SetArg(LIGHT_SECONDARY_INTENSITY, intVal); + break; + case LIGHTTAG_INTERVAL: + floatVal = gl_ParseFloat(sc); + defaults->SetAngle((angle_t)(floatVal * ANGLE_MAX)); + break; + case LIGHTTAG_SUBTRACTIVE: + defaults->SetSubtractive(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_HALO: + defaults->SetHalo(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_DONTLIGHTSELF: + defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); + break; + default: + sc.ScriptError("Unknown tag: %s\n", sc.String); + } + } + if (defaults->GetArg(LIGHT_SECONDARY_INTENSITY) < defaults->GetArg(LIGHT_INTENSITY)) + { + BYTE v = defaults->GetArg(LIGHT_SECONDARY_INTENSITY); + defaults->SetArg(LIGHT_SECONDARY_INTENSITY, defaults->GetArg(LIGHT_INTENSITY)); + defaults->SetArg(LIGHT_INTENSITY, v); + } + gl_AddLightDefaults(defaults); + } + else + { + sc.ScriptError("Expected '{'.\n"); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParseSectorLight(FScanner &sc) +{ + int type; + float floatVal; + float floatTriple[3]; + FLightDefaults *defaults; + + // get name + sc.GetString(); + FName name = sc.String; + + // check for opening brace + sc.GetString(); + if (sc.Compare("{")) + { + defaults = new FLightDefaults(name, SectorLight); + ScriptDepth++; + while (ScriptDepth) + { + sc.GetString(); + type = sc.MatchString(LightTags); + switch (type) + { + case LIGHTTAG_OPENBRACE: + ScriptDepth++; + break; + case LIGHTTAG_CLOSEBRACE: + ScriptDepth--; + break; + case LIGHTTAG_COLOR: + gl_ParseTriple(sc, floatTriple); + defaults->SetArg(LIGHT_RED, clamp((int)(floatTriple[0] * 255), 0, 255)); + defaults->SetArg(LIGHT_GREEN, clamp((int)(floatTriple[1] * 255), 0, 255)); + defaults->SetArg(LIGHT_BLUE, clamp((int)(floatTriple[2] * 255), 0, 255)); + break; + case LIGHTTAG_OFFSET: + gl_ParseTriple(sc, floatTriple); + defaults->SetOffset(floatTriple); + break; + case LIGHTTAG_SCALE: + floatVal = gl_ParseFloat(sc); + defaults->SetArg(LIGHT_SCALE, (BYTE)(floatVal * 255)); + break; + case LIGHTTAG_SUBTRACTIVE: + defaults->SetSubtractive(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_HALO: + defaults->SetHalo(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_DONTLIGHTSELF: + defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); + break; + default: + sc.ScriptError("Unknown tag: %s\n", sc.String); + } + } + gl_AddLightDefaults(defaults); + } + else + { + sc.ScriptError("Expected '{'.\n"); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_AddLightAssociation(const char *actor, const char *frame, const char *light) +{ + FLightAssociation *temp; + unsigned int i; + FLightAssociation assoc(actor, frame, light); + + for (i = 0; i < LightAssociations.Size(); i++) + { + temp = &LightAssociations[i]; + if (temp->ActorName() == assoc.ActorName()) + { + if (strcmp(temp->FrameName(), assoc.FrameName()) == 0) + { + temp->ReplaceLightName(assoc.Light()); + return; + } + } + } + + LightAssociations.Push(assoc); +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParseFrame(FScanner &sc, FString name) +{ + int type, startDepth; + FString frameName; + + // get name + sc.GetString(); + if (strlen(sc.String) > 8) + { + sc.ScriptError("Name longer than 8 characters: %s\n", sc.String); + } + frameName = sc.String; + + startDepth = ScriptDepth; + + // check for opening brace + sc.GetString(); + if (sc.Compare("{")) + { + ScriptDepth++; + while (ScriptDepth > startDepth) + { + sc.GetString(); + type = sc.MatchString(LightTags); + switch (type) + { + case LIGHTTAG_OPENBRACE: + ScriptDepth++; + break; + case LIGHTTAG_CLOSEBRACE: + ScriptDepth--; + break; + case LIGHTTAG_LIGHT: + gl_ParseString(sc); + gl_AddLightAssociation(name, frameName, sc.String); + break; + default: + sc.ScriptError("Unknown tag: %s\n", sc.String); + } + } + } + else + { + sc.ScriptError("Expected '{'.\n"); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParseObject(FScanner &sc) +{ + int type; + FString name; + + // get name + sc.GetString(); + name = sc.String; + if (!PClass::FindClass(name)) + sc.ScriptMessage("Warning: dynamic lights attached to non-existent actor %s\n", name.GetChars()); + + // check for opening brace + sc.GetString(); + if (sc.Compare("{")) + { + ScriptDepth++; + while (ScriptDepth) + { + sc.GetString(); + type = sc.MatchString(LightTags); + switch (type) + { + case LIGHTTAG_OPENBRACE: + ScriptDepth++; + break; + case LIGHTTAG_CLOSEBRACE: + ScriptDepth--; + break; + case LIGHTTAG_FRAME: + gl_ParseFrame(sc, name); + break; + default: + sc.ScriptError("Unknown tag: %s\n", sc.String); + } + } + } + else + { + sc.ScriptError("Expected '{'.\n"); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ReleaseLights() +{ + unsigned int i; + + for (i = 0; i < LightDefaults.Size(); i++) + { + delete LightDefaults[i]; + } + + LightAssociations.Clear(); + LightDefaults.Clear(); +} + +//========================================================================== +// +// +// +//========================================================================== + +// these are the core types available in the *DEFS lump +static const char *CoreKeywords[]= +{ + "pointlight", + "pulselight", + "flickerlight", + "flickerlight2", + "sectorlight", + "object", + "clearlights", + "shader", + "clearshaders", + "skybox", + "glow", + "brightmap", + "disable_fullbright", + "hardwareshader", + "detail", + "#include", + NULL +}; + + +enum +{ + LIGHT_POINT, + LIGHT_PULSE, + LIGHT_FLICKER, + LIGHT_FLICKER2, + LIGHT_SECTOR, + LIGHT_OBJECT, + LIGHT_CLEAR, + TAG_SHADER, + TAG_CLEARSHADERS, + TAG_SKYBOX, + TAG_GLOW, + TAG_BRIGHTMAP, + TAG_DISABLE_FB, + TAG_HARDWARESHADER, + TAG_DETAIL, + TAG_INCLUDE, +}; + + +//========================================================================== +// +// This is only here so any shader definition for ZDoomGL can be skipped +// There is no functionality for this stuff! +// +//========================================================================== +bool gl_ParseShader(FScanner &sc) +{ + int ShaderDepth = 0; + + if (sc.GetString()) + { + char *tmp; + + tmp = strstr(sc.String, "{"); + while (tmp) + { + ShaderDepth++; + tmp++; + tmp = strstr(tmp, "{"); + } + + tmp = strstr(sc.String, "}"); + while (tmp) + { + ShaderDepth--; + tmp++; + tmp = strstr(tmp, "}"); + } + + if (ShaderDepth == 0) return true; + } + return false; +} + +//========================================================================== +// +// Light associations per actor class +// +// Turn this inefficient mess into something that can be used at run time. +// +//========================================================================== + +class FInternalLightAssociation +{ +public: + FInternalLightAssociation(FLightAssociation * asso); + int Sprite() const { return m_sprite; } + int Frame() const { return m_frame; } + const FLightDefaults *Light() const { return m_AssocLight; } +protected: + int m_sprite; + int m_frame; + FLightDefaults * m_AssocLight; +}; + +//========================================================================== +// +// +// +//========================================================================== + +FInternalLightAssociation::FInternalLightAssociation(FLightAssociation * asso) +{ + + m_AssocLight=NULL; + for(unsigned int i=0;iGetName() == asso->Light()) + { + m_AssocLight = LightDefaults[i]; + break; + } + } + + m_sprite=-1; + m_frame = -1; + for (unsigned i = 0; i < sprites.Size (); ++i) + { + if (strncmp (sprites[i].name, asso->FrameName(), 4) == 0) + { + m_sprite = (int)i; + break; + } + } + + // Only handle lights for full frames. + // I won't bother with special lights for single rotations + // because there is no decent use for them! + if (strlen(asso->FrameName())==5 || asso->FrameName()[5]=='0') + { + m_frame = toupper(asso->FrameName()[4])-'A'; + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +inline TDeletingArray * gl_GetActorLights(AActor * actor) +{ + return (TDeletingArray*)actor->lightassociations; +} + +TDeletingArray< TDeletingArray * > AssoDeleter; + +//========================================================================== +// +// State lights +// +//========================================================================== +TArray ParsedStateLights; +TArray StateLights; + + + +//========================================================================== +// +// +// +//========================================================================== + +void gl_InitializeActorLights() +{ + for(unsigned int i=0;ilightassociations) + { + TDeletingArray *p =new TDeletingArray; + defaults->lightassociations = p; + AssoDeleter.Push(p); + } + TDeletingArray * lights = gl_GetActorLights(defaults); + if (iasso->Light()==NULL) + { + // The definition was not valid. + delete iasso; + } + else + { + lights->Push(iasso); + } + } + } + } + // we don't need the parser data for the light associations anymore + LightAssociations.Clear(); + LightAssociations.ShrinkToFit(); + + StateLights.Resize(ParsedStateLights.Size()+1); + for(unsigned i=0; iGetName() == ParsedStateLights[i]) + { + StateLights[i] = LightDefaults[j]; + break; + } + } + } + else StateLights[i] = NULL; + } + StateLights[StateLights.Size()-1] = NULL; // terminator + ParsedStateLights.Clear(); + ParsedStateLights.ShrinkToFit(); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void gl_AttachLight(AActor *actor, unsigned int count, const FLightDefaults *lightdef) +{ + ADynamicLight *light; + + // I'm skipping the single rotations because that really doesn't make sense! + if (count < actor->dynamiclights.Size()) + { + light = barrier_cast(actor->dynamiclights[count]); + assert(light != NULL); + } + else + { + light = Spawn(actor->x, actor->y, actor->z, NO_REPLACE); + light->target = actor; + light->owned = true; + actor->dynamiclights.Push(light); + } + light->flags2&=~MF2_DORMANT; + lightdef->ApplyProperties(light); +} + +//========================================================================== +// +// per-state light adjustment +// +//========================================================================== + +void gl_SetActorLights(AActor *actor) +{ + TArray * l = gl_GetActorLights(actor); + unsigned int count = 0; + + All.Clock(); + if (actor->state == NULL) return; + if (l) + { + TArray & LightAssociations=*l; + ADynamicLight *lights, *tmpLight; + unsigned int i; + + int sprite = actor->state->sprite; + int frame = actor->state->GetFrame(); + + lights = tmpLight = NULL; + + + for (i = 0; i < LightAssociations.Size(); i++) + { + if (LightAssociations[i]->Sprite() == sprite && + (LightAssociations[i]->Frame()==frame || LightAssociations[i]->Frame()==-1)) + { + gl_AttachLight(actor, count++, LightAssociations[i]->Light()); + } + } + } + if (count == 0 && actor->state->Light > 0) + { + for(int i= actor->state->Light; StateLights[i] != NULL; i++) + { + if (StateLights[i] != (FLightDefaults*)-1) + { + gl_AttachLight(actor, count++, StateLights[i]); + } + } + } + + for(;countdynamiclights.Size();count++) + { + actor->dynamiclights[count]->flags2|=MF2_DORMANT; + memset(actor->dynamiclights[count]->args, 0, sizeof(actor->args)); + } + All.Unclock(); +} + +//========================================================================== +// +// This is called before saving the game +// +//========================================================================== + +void gl_DeleteAllAttachedLights() +{ + TThinkerIterator it; + AActor * a; + ADynamicLight * l; + + while ((a=it.Next())) + { + a->dynamiclights.Clear(); + } + + TThinkerIterator it2; + + l=it2.Next(); + while (l) + { + ADynamicLight * ll = it2.Next(); + if (l->owned) l->Destroy(); + l=ll; + } + + +} + +//========================================================================== +// +// +// +//========================================================================== + +void gl_RecreateAllAttachedLights() +{ + TThinkerIterator it; + AActor * a; + + while ((a=it.Next())) + { + gl_SetActorLights(a); + } +} + + +//========================================================================== +// The actual light def parsing code is there. +// DoParseDefs is no longer called directly by ParseDefs, now it's called +// by LoadDynLightDefs, which wasn't simply integrated into ParseDefs +// because of the way the code needs to load two out of five lumps. +//========================================================================== +void gl_DoParseDefs(FScanner &sc, int workingLump) +{ + int recursion=0; + int lump, type; + + // Get actor class name. + while (true) + { + sc.SavePos(); + if (!sc.GetToken ()) + { + return; + } + type = sc.MatchString(CoreKeywords); + switch (type) + { + case TAG_INCLUDE: + { + sc.MustGetString(); + // This is not using sc.Open because it can print a more useful error message when done here + lump = Wads.CheckNumForFullName(sc.String, true); + if (lump==-1) + sc.ScriptError("Lump '%s' not found", sc.String); + + FScanner newscanner(lump); + gl_DoParseDefs(newscanner, lump); + break; + } + case LIGHT_POINT: + gl_ParsePointLight(sc); + break; + case LIGHT_PULSE: + gl_ParsePulseLight(sc); + break; + case LIGHT_FLICKER: + gl_ParseFlickerLight(sc); + break; + case LIGHT_FLICKER2: + gl_ParseFlickerLight2(sc); + break; + case LIGHT_SECTOR: + gl_ParseSectorLight(sc); + break; + case LIGHT_OBJECT: + gl_ParseObject(sc); + break; + case LIGHT_CLEAR: + gl_ReleaseLights(); + break; + case TAG_SHADER: + gl_ParseShader(sc); + break; + case TAG_CLEARSHADERS: + break; + case TAG_SKYBOX: + gl_ParseSkybox(sc); + break; + case TAG_GLOW: + gl_InitGlow(sc); + break; + case TAG_BRIGHTMAP: + gl_ParseBrightmap(sc, workingLump); + break; + case TAG_HARDWARESHADER: + gl_ParseHardwareShader(sc, workingLump); + break; + case TAG_DETAIL: + gl_ParseDetailTexture(sc); + break; + case TAG_DISABLE_FB: + { + /* not implemented. + sc.MustGetString(); + const PClass *cls = PClass::FindClass(sc.String); + if (cls) GetDefaultByType(cls)->renderflags |= RF_NEVERFULLBRIGHT; + */ + } + break; + default: + sc.ScriptError("Error parsing defs. Unknown tag: %s.\n", sc.String); + break; + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void gl_LoadGLDefs(const char * defsLump) +{ + int workingLump, lastLump; + + lastLump = 0; + while ((workingLump = Wads.FindLump(defsLump, &lastLump)) != -1) + { + FScanner sc(workingLump); + gl_DoParseDefs(sc, workingLump); + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +void gl_ParseDefs() +{ + const char *defsLump = NULL; + + atterm( gl_ReleaseLights ); + gl_ReleaseLights(); + gl_DestroyUserShaders(); + switch (gameinfo.gametype) + { + case GAME_Heretic: + defsLump = "HTICDEFS"; + break; + case GAME_Hexen: + defsLump = "HEXNDEFS"; + break; + case GAME_Strife: + defsLump = "STRFDEFS"; + break; + case GAME_Doom: + defsLump = "DOOMDEFS"; + break; + case GAME_Chex: + defsLump = "CHEXDEFS"; + break; + default: // silence GCC + break; + } + gl_ParseVavoomSkybox(); + if (defsLump != NULL) gl_LoadGLDefs(defsLump); + gl_LoadGLDefs("GLDEFS"); + gl_InitializeActorLights(); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void AddStateLight(FState *State, const char *lname) +{ + if (State->Light == 0) + { + ParsedStateLights.Push(NAME_None); + State->Light = ParsedStateLights.Push(FName(lname)); + } + else + { + ParsedStateLights.Push(FName(lname)); + } +} diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h new file mode 100644 index 000000000..e4242d8f9 --- /dev/null +++ b/src/gl/dynlights/gl_dynlight.h @@ -0,0 +1,191 @@ +#ifndef __GLC_DYNLIGHT_H +#define __GLC_DYNLIGHT_H + +#include "c_cvars.h" +#include "gl/utility/gl_geometric.h" +#include "gl/utility/gl_cycler.h" + + +EXTERN_CVAR(Bool, gl_lights) +EXTERN_CVAR(Bool, gl_attachedlights) + +class ADynamicLight; +class FArchive; + + + +enum +{ + LIGHT_RED = 0, + LIGHT_GREEN = 1, + LIGHT_BLUE = 2, + LIGHT_INTENSITY = 3, + LIGHT_SECONDARY_INTENSITY = 4, + LIGHT_SCALE = 3, +}; + +// This is as good as something new - and it can be set directly in the ActorInfo! +#define MF4_SUBTRACTIVE MF4_MISSILEEVENMORE +#define MF4_ADDITIVE MF4_MISSILEMORE +#define MF4_DONTLIGHTSELF MF4_SEESDAGGERS + +enum ELightType +{ + PointLight, + PulseLight, + FlickerLight, + RandomFlickerLight, + SectorLight, + SpotLight, + ColorPulseLight, + ColorFlickerLight, + RandomColorFlickerLight +}; + + +struct FLightNode +{ + FLightNode ** prevTarget; + FLightNode * nextTarget; + FLightNode ** prevLight; + FLightNode * nextLight; + ADynamicLight * lightsource; + union + { + side_t * targLine; + subsector_t * targSubsector; + void * targ; + }; +}; + + +// +// Base class +// +// [CO] I merged everything together in this one class so that I don't have +// to create and re-create an excessive amount of objects +// + +class ADynamicLight : public AActor +{ + DECLARE_CLASS (ADynamicLight, AActor) +public: + virtual void Tick(); + void Serialize(FArchive &arc); + BYTE GetRed() const { return args[LIGHT_RED]; } + BYTE GetGreen() const { return args[LIGHT_GREEN]; } + BYTE GetBlue() const { return args[LIGHT_BLUE]; } + float GetIntensity() const { return m_currentIntensity; } + float GetRadius() const { return (IsActive() ? GetIntensity() * 2.f : 0.f); } + void LinkLight(); + void UnlinkLight(); + size_t PointerSubstitution (DObject *old, DObject *notOld); + + virtual void BeginPlay(); + void PostBeginPlay(); + void Destroy(); + void Activate(AActor *activator); + void Deactivate(AActor *activator); + void SetOffset(fixed_t x, fixed_t y, fixed_t z); + void UpdateLocation(); + bool IsOwned() const { return owned; } + bool IsActive() const { return !(flags2&MF2_DORMANT); } + bool IsSubtractive() { return !!(flags4&MF4_SUBTRACTIVE); } + bool IsAdditive() { return !!(flags4&MF4_ADDITIVE); } + FState *targetState; + FLightNode * touching_sides; + FLightNode * touching_subsectors; + +private: + float DistToSeg(seg_t *seg); + void CollectWithinRadius(subsector_t *subSec, float radius); + +protected: + fixed_t m_offX, m_offY, m_offZ; + float m_currentIntensity; + int m_tickCount; + unsigned int m_lastUpdate; + FCycler m_cycler; + subsector_t * subsector; + +public: + int m_intensity[2]; + BYTE lightflags; + BYTE lighttype; + bool owned; + bool halo; + BYTE color2[3]; + int bufferindex; + + // intermediate texture coordinate data + // this is stored in the light object to avoid recalculating it + // several times during rendering of a flat + Vector nearPt, up, right; + float scale; + +}; + +class AVavoomLight : public ADynamicLight +{ + DECLARE_CLASS (AVavoomLight, ADynamicLight) +public: + virtual void BeginPlay(); +}; + +class AVavoomLightWhite : public AVavoomLight +{ + DECLARE_CLASS (AVavoomLightWhite, AVavoomLight) +public: + virtual void BeginPlay(); +}; + +class AVavoomLightColor : public AVavoomLight +{ + DECLARE_CLASS (AVavoomLightColor, AVavoomLight) +public: + void BeginPlay(); +}; + + +enum +{ + STAT_DLIGHT=64 +}; + +struct FDynLightData +{ + TArray arrays[3]; + + void Clear() + { + arrays[0].Clear(); + arrays[1].Clear(); + arrays[2].Clear(); + } + + void Combine(int *siz, int max) + { + siz[0] = arrays[0].Size(); + siz[1] = siz[0] + arrays[1].Size(); + siz[2] = siz[1] + arrays[2].Size(); + arrays[0].Resize(arrays[0].Size() + arrays[1].Size() + arrays[2].Size()); + memcpy(&arrays[0][siz[0]], &arrays[1][0], arrays[1].Size() * sizeof(float)); + memcpy(&arrays[0][siz[1]], &arrays[2][0], arrays[2].Size() * sizeof(float)); + siz[0]>>=2; + siz[1]>>=2; + siz[2]>>=2; + max<<=1; + if (siz[0] > max) siz[0] = max; + if (siz[1] > max) siz[1] = max; + if (siz[2] > max) siz[2] = max; + } +}; + + + +bool gl_GetLight(Plane & p, ADynamicLight * light, int desaturation, bool checkside, bool forceadditive, FDynLightData &data); +bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, float & scale, int desaturation, bool checkside=true, bool forceadditive=true); +bool gl_SetupLightTexture(); + + +#endif diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp new file mode 100644 index 000000000..4c9f929f4 --- /dev/null +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -0,0 +1,261 @@ +/* +** gl_dynlight1.cpp +** dynamic light application +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "c_dispatch.h" +#include "p_local.h" +#include "vectors.h" +#include "gl/gl_functions.h" +#include "g_level.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" + + +//========================================================================== +// +// Light related CVARs +// +//========================================================================== + +CUSTOM_CVAR (Bool, gl_lights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (self) gl_RecreateAllAttachedLights(); + else gl_DeleteAllAttachedLights(); +} + +CUSTOM_CVAR (Bool, gl_dynlight_shader, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (self && (gl.maxuniforms < 1024 || gl.shadermodel < 4)) self = false; +} + +CVAR (Bool, gl_attachedlights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR (Bool, gl_lights_checkside, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR (Float, gl_lights_intensity, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR (Float, gl_lights_size, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR (Bool, gl_light_sprites, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR (Bool, gl_light_particles, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CUSTOM_CVAR (Bool, gl_lights_additive, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + gl_DeleteAllAttachedLights(); + gl_RecreateAllAttachedLights(); +} + +//========================================================================== +// +// Sets up the parameters to render one dynamic light onto one plane +// +//========================================================================== +bool gl_GetLight(Plane & p, ADynamicLight * light, + int desaturation, bool checkside, bool forceadditive, FDynLightData &ldata) +{ + Vector fn, pos; + int i = 0; + + float x = FIXED2FLOAT(light->x); + float y = FIXED2FLOAT(light->y); + float z = FIXED2FLOAT(light->z); + + float dist = fabsf(p.DistToPoint(x, z, y)); + float radius = (light->GetRadius() * gl_lights_size); + + if (radius <= 0.f) return false; + if (dist > radius) return false; + if (checkside && gl_lights_checkside && p.PointOnSide(x, z, y)) + { + return false; + } + + + float cs; + if (gl_lights_additive || light->flags4&MF4_ADDITIVE || forceadditive) + { + cs = 0.2f; + i = 2; + } + else + { + cs = 1.0f; + } + + float r = light->GetRed() / 255.0f * cs * gl_lights_intensity; + float g = light->GetGreen() / 255.0f * cs * gl_lights_intensity; + float b = light->GetBlue() / 255.0f * cs * gl_lights_intensity; + + if (light->IsSubtractive()) + { + Vector v; + + v.Set(r, g, b); + r = v.Length() - r; + g = v.Length() - g; + b = v.Length() - b; + i = 1; + } + + if (desaturation>0) + { + float gray=(r*77 + g*143 + b*37)/257; + + r= (r*(32-desaturation)+ gray*desaturation)/32; + g= (g*(32-desaturation)+ gray*desaturation)/32; + b= (b*(32-desaturation)+ gray*desaturation)/32; + } + float *data = &ldata.arrays[i][ldata.arrays[i].Reserve(8)]; + data[0] = x; + data[1] = z; + data[2] = y; + data[3] = radius; + data[4] = r; + data[5] = g; + data[6] = b; + data[7] = 0; + return true; +} + + + + +//========================================================================== +// +// Sets up the parameters to render one dynamic light onto one plane +// +//========================================================================== +bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, + float & scale, int desaturation, bool checkside, bool forceadditive) +{ + Vector fn, pos; + + float x = FIXED2FLOAT(light->x); + float y = FIXED2FLOAT(light->y); + float z = FIXED2FLOAT(light->z); + + float dist = fabsf(p.DistToPoint(x, z, y)); + float radius = (light->GetRadius() * gl_lights_size); + + if (radius <= 0.f) return false; + if (dist > radius) return false; + if (checkside && gl_lights_checkside && p.PointOnSide(x, z, y)) + { + return false; + } + + scale = 1.0f / ((2.f * radius) - dist); + + // project light position onto plane (find closest point on plane) + + + pos.Set(x,z,y); + fn=p.Normal(); + fn.GetRightUp(right, up); + +#ifdef _MSC_VER + nearPt = pos + fn * dist; +#else + Vector tmpVec = fn * dist; + nearPt = pos + tmpVec; +#endif + + float cs = 1.0f - (dist / radius); + if (gl_lights_additive || light->flags4&MF4_ADDITIVE || forceadditive) cs*=0.2f; // otherwise the light gets too strong. + float r = light->GetRed() / 255.0f * cs * gl_lights_intensity; + float g = light->GetGreen() / 255.0f * cs * gl_lights_intensity; + float b = light->GetBlue() / 255.0f * cs * gl_lights_intensity; + + if (light->IsSubtractive()) + { + Vector v; + + gl_RenderState.BlendEquation(GL_FUNC_REVERSE_SUBTRACT); + v.Set(r, g, b); + r = v.Length() - r; + g = v.Length() - g; + b = v.Length() - b; + } + else + { + gl_RenderState.BlendEquation(GL_FUNC_ADD); + } + if (desaturation>0) + { + float gray=(r*77 + g*143 + b*37)/257; + + r= (r*(32-desaturation)+ gray*desaturation)/32; + g= (g*(32-desaturation)+ gray*desaturation)/32; + b= (b*(32-desaturation)+ gray*desaturation)/32; + } + gl.Color3f(r,g,b); + return true; +} + + +//========================================================================== +// +// +// +//========================================================================== + +bool gl_SetupLightTexture() +{ + + if (GLRenderer->gllight == NULL) return false; + FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight); + pat->BindPatch(CM_DEFAULT, 0); + return true; +} + + +//========================================================================== +// +// +// +//========================================================================== + +inline fixed_t P_AproxDistance3(fixed_t dx, fixed_t dy, fixed_t dz) +{ + return P_AproxDistance(P_AproxDistance(dx,dy),dz); +} + diff --git a/src/gl/dynlights/gl_glow.cpp b/src/gl/dynlights/gl_glow.cpp new file mode 100644 index 000000000..ce763109d --- /dev/null +++ b/src/gl/dynlights/gl_glow.cpp @@ -0,0 +1,139 @@ +/* +** gl_glow.cpp +** Glowing flats like Doomsday +** +**--------------------------------------------------------------------------- +** Copyright 2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "w_wad.h" +#include "sc_man.h" +#include "v_video.h" +#include "r_defs.h" +#include "textures/textures.h" + +#include "gl/dynlights/gl_glow.h" + +//=========================================================================== +// +// Reads glow definitions from GLDEFS +// +//=========================================================================== +void gl_InitGlow(FScanner &sc) +{ + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + sc.MustGetString(); + if (sc.Compare("FLATS")) + { + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + sc.MustGetString(); + FTextureID flump=TexMan.CheckForTexture(sc.String, FTexture::TEX_Flat,FTextureManager::TEXMAN_TryAny); + FTexture *tex = TexMan[flump]; + if (tex) tex->gl_info.bGlowing = tex->gl_info.bFullbright = true; + } + } + else if (sc.Compare("WALLS")) + { + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + sc.MustGetString(); + FTextureID flump=TexMan.CheckForTexture(sc.String, FTexture::TEX_Wall,FTextureManager::TEXMAN_TryAny); + FTexture *tex = TexMan[flump]; + if (tex) tex->gl_info.bGlowing = tex->gl_info.bFullbright = true; + } + } + else if (sc.Compare("TEXTURE")) + { + sc.SetCMode(true); + sc.MustGetString(); + FTextureID flump=TexMan.CheckForTexture(sc.String, FTexture::TEX_Flat,FTextureManager::TEXMAN_TryAny); + FTexture *tex = TexMan[flump]; + sc.MustGetStringName(","); + sc.MustGetString(); + PalEntry color = V_GetColor(NULL, sc.String); + //sc.MustGetStringName(","); + //sc.MustGetNumber(); + if (sc.CheckString(",")) + { + if (sc.CheckNumber()) + { + if (tex) tex->gl_info.GlowHeight = sc.Number; + if (!sc.CheckString(",")) goto skip_fb; + } + + sc.MustGetStringName("fullbright"); + if (tex) tex->gl_info.bFullbright = true; + } + skip_fb: + sc.SetCMode(false); + + if (tex && color != 0) + { + tex->gl_info.bGlowing = true; + tex->gl_info.GlowColor = color; + } + } + } +} + + +//========================================================================== +// +// Checks whether a sprite should be affected by a glow +// +//========================================================================== +int gl_CheckSpriteGlow(sector_t *sec, int lightlevel, int x, int y, int z) +{ + FTextureID floorpic = sec->GetTexture(sector_t::floor); + FTexture *tex = TexMan[floorpic]; + if (tex != NULL && tex->isGlowing()) + { + fixed_t floordiff = z - sec->floorplane.ZatPoint(x, y); + if (floordiff < tex->gl_info.GlowHeight*FRACUNIT && tex->gl_info.GlowHeight != 0) + { + int maxlight = (255+lightlevel)>>1; + fixed_t lightfrac = floordiff / tex->gl_info.GlowHeight; + if (lightfrac<0) lightfrac=0; + lightlevel= (lightfrac*lightlevel + maxlight*(FRACUNIT-lightfrac))>>FRACBITS; + } + } + return lightlevel; +} + diff --git a/src/gl/dynlights/gl_glow.h b/src/gl/dynlights/gl_glow.h new file mode 100644 index 000000000..bc3235685 --- /dev/null +++ b/src/gl/dynlights/gl_glow.h @@ -0,0 +1,10 @@ + +#ifndef __GL_GLOW +#define __GL_GLOW + +struct sector_t; + +void gl_InitGlow(const char * lumpnm); +int gl_CheckSpriteGlow(sector_t *sec, int lightlevel, int x, int y, int z); + +#endif diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp new file mode 100644 index 000000000..d3a62a718 --- /dev/null +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -0,0 +1,243 @@ +/* +** gl_dynlight1.cpp +** dynamic light buffer for shader rendering +** +**--------------------------------------------------------------------------- +** Copyright 2009 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#if 0 // unused for now. Code doesn't work + +#include "gl/system/gl_system.h" +#include "c_dispatch.h" +#include "p_local.h" +#include "vectors.h" +#include "g_level.h" + +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/dynlights/gl_lightbuffer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" + + +//========================================================================== +// +// +// +//========================================================================== + +FLightBuffer::FLightBuffer() +{ + gl.GenBuffers(1, &mIDbuf_RGB); + gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB); + + gl.GenBuffers(1, &mIDbuf_Position); + gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); + + gl.GenTextures(1, &mIDtex_RGB); + gl.BindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB); + gl.TexBufferARB(GL_TEXTURE_BUFFER, GL_RGBA8, mIDbuf_RGB); + + gl.GenTextures(1, &mIDtex_Position); + gl.BindTexture(GL_TEXTURE_BUFFER, mIDtex_Position); + gl.TexBufferARB(GL_TEXTURE_BUFFER, GL_RGBA32F, mIDbuf_Position); +} + + +//========================================================================== +// +// +// +//========================================================================== + +FLightBuffer::~FLightBuffer() +{ + gl.BindBuffer(GL_TEXTURE_BUFFER, 0); + gl.DeleteBuffers(1, &mIDbuf_RGB); + gl.DeleteBuffers(1, &mIDbuf_Position); + + gl.BindTexture(GL_TEXTURE_BUFFER, 0); + gl.DeleteTextures(1, &mIDtex_RGB); + gl.DeleteTextures(1, &mIDtex_Position); + +} + +//========================================================================== +// +// +// +//========================================================================== + +void FLightBuffer::BindTextures(int texunit1, int texunit2) +{ + gl.ActiveTexture(texunit1); + gl.BindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB); + gl.ActiveTexture(texunit2); + gl.BindTexture(GL_TEXTURE_BUFFER, mIDtex_Position); + gl.ActiveTexture(GL_TEXTURE0); +} + + +//========================================================================== +// +// This collects all currently actove +// +//========================================================================== + +void FLightBuffer::CollectLightSources() +{ + if (gl_dynlight_shader && gl_lights && GLRenderer->mLightCount && gl_fixedcolormap == CM_DEFAULT) + { + TArray pLights(100); + TArray pPos(100); + TThinkerIterator it(STAT_DLIGHT); + + ADynamicLight *light; + + while ((light = it.Next()) != NULL) + { + if (!(light->flags2 & MF2_DORMANT)) + { + FLightRGB rgb; + FLightPosition pos; + + rgb.R = light->GetRed(); + rgb.G = light->GetGreen(); + rgb.B = light->GetBlue(); + rgb.Type = (light->flags4 & MF4_SUBTRACTIVE)? 128 : (light->flags4 & MF4_ADDITIVE || foggy)? 255:0; + pos.X = FIXED2FLOAT(light->x); + pos.Y = FIXED2FLOAT(light->y); + pos.Z = FIXED2FLOAT(light->z); + pos.Distance = (light->GetRadius() * gl_lights_size); + light->bufferindex = pPos.Size(); + pLights.Push(rgb); + pPos.Push(pos); + } + else light->bufferindex = -1; + } + GLRenderer->mLightCount = pPos.Size(); + + gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB); + gl.BufferData(GL_TEXTURE_BUFFER, pLights.Size() * sizeof (FLightRGB), &pLights[0], GL_STREAM_DRAW); + + gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); + gl.BufferData(GL_TEXTURE_BUFFER, pPos.Size() * sizeof (FLightPosition), &pPos[0], GL_STREAM_DRAW); + + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +FLightIndexBuffer::FLightIndexBuffer() +{ + gl.GenBuffers(1, &mIDBuffer); + gl.BindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); + + gl.GenTextures(1, &mIDTexture); + gl.BindTexture(GL_TEXTURE_BUFFER, mIDTexture); + gl.TexBufferARB(GL_TEXTURE_BUFFER, GL_R16UI, mIDBuffer); +} + +//========================================================================== +// +// +// +//========================================================================== + +FLightIndexBuffer::~FLightIndexBuffer() +{ + gl.BindBuffer(GL_TEXTURE_BUFFER, 0); + gl.DeleteBuffers(1, &mIDBuffer); + + gl.BindTexture(GL_TEXTURE_BUFFER, 0); + gl.DeleteTextures(1, &mIDTexture); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void FLightIndexBuffer::AddLight(ADynamicLight *light) +{ + if (light->bufferindex >= 0) + { + mBuffer.Push(light->bufferindex); + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FLightIndexBuffer::SendBuffer() +{ + gl.BindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); + gl.BufferData(GL_TEXTURE_BUFFER, mBuffer.Size() * sizeof (short), &mBuffer[0], GL_STREAM_DRAW); + gl.BindBuffer(GL_TEXTURE_BUFFER, 0); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void FLightIndexBuffer::BindTexture(int texunit1) +{ + gl.ActiveTexture(texunit1); + gl.BindTexture(GL_TEXTURE_BUFFER, mIDTexture); + gl.ActiveTexture(GL_TEXTURE0); +} + + + +#endif \ No newline at end of file diff --git a/src/gl/dynlights/gl_lightbuffer.h b/src/gl/dynlights/gl_lightbuffer.h new file mode 100644 index 000000000..d0da46b98 --- /dev/null +++ b/src/gl/dynlights/gl_lightbuffer.h @@ -0,0 +1,66 @@ +#ifndef __GL_LIGHTBUFFER_H +#define __GL_LIGHTBUFFER_H + +#if 0 +class ADynamicLight; + +const int MAX_DYNLIGHTS = 40000; // should hopefully be enough + +struct FLightRGB +{ + unsigned char R,G,B,Type; // Type is 0 for normal, 1 for additive and 2 for subtractive +}; + +struct FLightPosition +{ + float X,Z,Y,Distance; +}; + +class FLightBuffer +{ + unsigned int mIDbuf_RGB; + unsigned int mIDbuf_Position; + + unsigned int mIDtex_RGB; + unsigned int mIDtex_Position; + +public: + FLightBuffer(); + ~FLightBuffer(); + //void MapBuffer(); + //void UnmapBuffer(); + void BindTextures(int uniloc1, int uniloc2); + //void AddLight(ADynamicLight *light, bool foggy); + void CollectLightSources(); +}; + +class FLightIndexBuffer +{ + unsigned int mIDBuffer; + unsigned int mIDTexture; + + TArray mBuffer; + +public: + + FLightIndexBuffer(); + ~FLightIndexBuffer(); + void AddLight(ADynamicLight *light); + void SendBuffer(); + void BindTexture(int loc1); + + void ClearBuffer() + { + mBuffer.Clear(); + } + + int GetLightIndex() + { + return mBuffer.Size(); + } + +}; + +#endif + +#endif \ No newline at end of file diff --git a/src/gl/gl_builddraw.cpp b/src/gl/gl_builddraw.cpp new file mode 100644 index 000000000..60b94b984 --- /dev/null +++ b/src/gl/gl_builddraw.cpp @@ -0,0 +1,594 @@ +/* +** gl_builddraw.cpp +** a build-like rendering algorithm +** Uses the sections created in gl_sections.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2008 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "i_system.h" +#include "p_local.h" +#include "c_dispatch.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/scene/gl_clipper.h" +#include "gl/utility/gl_clock.h" +#include "gl/data/gl_sections.h" +#include "gl/scene/gl_wall.h" + +#ifdef BUILD_TEST +#define D(x) x +#else +#define D(x) do{}while(0) +#endif + +EXTERN_CVAR (Bool, dumpsections) + +struct FBunch +{ + int startline; + int endline; + angle_t startangle; + angle_t endangle; + fixed_t minviewdist; + fixed_t maxviewdist; +}; + +void DoSubsector(subsector_t * sub, bool handlelines); + +EXTERN_CVAR(Bool, gl_render_walls) + +//========================================================================== +// +// From Build but changed to use doubles to prevent overflows +// +//========================================================================== + +static int WallInFront(FGLSectionLine *wal1, FGLSectionLine *wal2) +{ + double x11, y11, x21, y21, x12, y12, x22, y22, dx, dy, t1, t2; + + x11 = wal1->start->x; + y11 = wal1->start->y; + x21 = wal1->end->x; + y21 = wal1->end->y; + x12 = wal2->start->x; + y12 = wal2->start->y; + x22 = wal2->end->x; + y22 = wal2->end->y; + + dx = x21-x11; dy = y21-y11; + + t1 = (x12-x11)*dy - (y12-y11)*dx; + t2 = (x22-x11)*dy - (y22-y11)*dx; + if (t1 == 0) + { + t1 = t2; + if (t1 == 0) return(-1); + } + if (t2 == 0) t2 = t1; + + if ((t1*t2) >= 0) + { + t2 = (double(viewx)-x11) * dy - (double(viewy)-y11)*dx; + return((t2*t1) < 0); + } + + dx = x22-x12; dy = y22-y12; + t1 = (x11-x12)*dy - (y11-y12)*dx; + t2 = (x21-x12)*dy - (y21-y12)*dx; + if (t1 == 0) + { + t1 = t2; + if (t1 == 0) return(-1); + } + if (t2 == 0) t2 = t1; + if ((t1*t2) >= 0) + { + t2 = (double(viewx)-x12) * dy - (double(viewy)-y12)*dx; + return((t2*t1) >= 0); + } + return(-2); +} + +//========================================================================== +// +// This is a bit more complicated than it looks because angles can wrap +// around so we can only compare angle differences. +// +// Rules: +// 1. Any bunch can span at most 180°. +// 2. 2 bunches can never overlap at both ends +// 3. if there is an overlap one of the 2 starting points must be in the +// overlapping area. +// +//========================================================================== + +static int BunchInFront(FBunch *b1, FBunch *b2) +{ + angle_t anglecheck, endang; + + if (b2->startangle - b1->startangle < b1->endangle - b1->startangle) + { + // we have an overlap at b2->startangle + anglecheck = b2->startangle - b1->startangle; + + // Find the wall in b1 that overlaps b2->startangle + for(int i = b1->startline; i <= b1->endline; i++) + { + #ifdef _DEBUG + angle_t startang = SectionLines[i].start->GetClipAngleInverse() - b1->startangle; + #endif + endang = SectionLines[i].end->GetClipAngleInverse() - b1->startangle; + if (endang > anglecheck) + { + assert (startang <= anglecheck); + + // found a line + int ret = WallInFront(&SectionLines[b2->startline], &SectionLines[i]); + + D(Printf (PRINT_LOG, "Line %d <-> line %d: Result = %d.\n", + SectionLines[b2->startline].linedef-lines, + SectionLines[i].linedef-lines, ret)); + + return ret; + } + } + } + else if (b1->startangle - b2->startangle < b2->endangle - b2->startangle) + { + // we have an overlap at b1->startangle + anglecheck = b1->startangle - b2->startangle; + + // Find the wall in b2 that overlaps b1->startangle + for(int i = b2->startline; i <= b2->endline; i++) + { + #ifdef _DEBUG + angle_t startang = SectionLines[i].start->GetClipAngleInverse() - b2->startangle; + #endif + endang = SectionLines[i].end->GetClipAngleInverse() - b2->startangle; + if (endang > anglecheck) + { + assert (startang <= anglecheck); + + // found a line + int ret = WallInFront(&SectionLines[i], &SectionLines[b1->startline]); + + D(Printf (PRINT_LOG, "Line %d <-> line %d: Result = %d,\n", + SectionLines[i].linedef-lines, + SectionLines[b1->endline].linedef-lines, ret)); + + return ret; + } + } + } + // we have no overlap + return -1; +} + + +// ---------------------------------------------------------------------------- +// +// Bunches are groups of continuous lines +// This array stores the amount of points per bunch, +// the view angles for each point and the line index for the starting line +// +// ---------------------------------------------------------------------------- + +class BunchDrawer +{ + int LastBunch; + int StartTime; + TArray Bunches; + TArray CompareData; + sector_t fakebacksec; + + //========================================================================== + // + // + // + //========================================================================== +public: + BunchDrawer() + { + StartScene(); + } + + //========================================================================== + // + // + // + //========================================================================== +private: + void StartScene() + { + LastBunch = 0; + StartTime = I_MSTime(); + Bunches.Clear(); + } + + //========================================================================== + // + // + // + //========================================================================== + + void StartBunch(int linenum, angle_t startan, angle_t endan, vertex_t *startpt, vertex_t *endpt) + { + FBunch *bunch = &Bunches[LastBunch = Bunches.Reserve(1)]; + + bunch->startline = bunch->endline = linenum; + bunch->startangle = startan; + bunch->endangle = endan; + } + + //========================================================================== + // + // + // + //========================================================================== + + void AddLineToBunch(int newan) + { + Bunches[LastBunch].endline++; + Bunches[LastBunch].endangle = newan; + } + + //========================================================================== + // + // + // + //========================================================================== + + void DeleteBunch(int index) + { + Bunches.Delete(index); + } + + //========================================================================== + // + // ClipLine + // Clips the given segment + // + //========================================================================== + + enum + { + CL_Skip = 0, + CL_Draw = 1, + CL_Pass = 2, + }; + + + int ClipLine (FGLSectionLine *line, sector_t * sector, sector_t **pbacksector) + { + angle_t startAngle, endAngle; + sector_t * backsector = NULL; + bool blocking; + + startAngle = line->end->GetClipAngle(); + endAngle = line->start->GetClipAngle(); + *pbacksector = NULL; + + // Back side, i.e. backface culling - read: endAngle >= startAngle! + if (startAngle-endAngleotherside == -1) + { + // one-sided + clipper.SafeAddClipRange(startAngle, endAngle); + return CL_Draw; + } + else if (line->polysub == NULL) + { + // two sided and not a polyobject + if (line->linedef == NULL) + { + // Miniseg + return CL_Pass; + } + if (sector->sectornum == line->refseg->backsector->sectornum) + { + FTexture *tex = TexMan(line->sidedef->GetTexture(side_t::mid)); + if (!tex || tex->UseType==FTexture::TEX_Null) + { + // no mid texture: nothing to do here + return CL_Pass; + } + *pbacksector = sector; + return CL_Draw|CL_Pass; + } + else + { + // clipping checks are only needed when the backsector is not the same as the front sector + gl_CheckViewArea(line->start, line->end, line->refseg->frontsector, line->refseg->backsector); + + *pbacksector = backsector = gl_FakeFlat(line->refseg->backsector, &fakebacksec, true); + + blocking = gl_CheckClip(line->sidedef, sector, backsector); + if (blocking) + { + clipper.SafeAddClipRange(startAngle, endAngle); + return CL_Draw; + } + return CL_Draw|CL_Pass; + } + } + else + { + *pbacksector = sector; + return CL_Draw; + } + } + + //========================================================================== + // + // + // + //========================================================================== + + void ProcessBunch(int bnch) + { + FBunch *bunch = &Bunches[bnch]; + + sector_t fake; + sector_t *sec; + sector_t *backsector; + + D(Printf(PRINT_LOG, "------------------------------\nProcessing bunch %d (Startline %d)\n",bnch,SectionLines[bunch->startline].linedef-lines)); + ClipWall.Clock(); + for(int i=bunch->startline; i <= bunch->endline; i++) + { + FGLSectionLine *ln = &SectionLines[i]; + + + // Draw this line. todo: optimize + sec = gl_FakeFlat(ln->refseg->frontsector, &fake, false); + + int clipped = ClipLine(ln, sec, &backsector); + + D(Printf(PRINT_LOG, "line %d clip result is %d\n", ln->linedef - lines, clipped)); + + if (clipped & CL_Draw) + { + ln->linedef->flags |= ML_MAPPED; + + if (ln->linedef->validcount!=validcount) + { + ln->linedef->validcount=validcount; + + #ifndef BUILD_TEST + if (gl_render_walls) + { + SetupWall.Clock(); + + GLWall wall; + wall.Process(ln->refseg, sec, backsector, ln->polysub); + rendered_lines++; + + SetupWall.Unclock(); + } + #endif + } + } + + if (clipped & CL_Pass) + { + ClipWall.Unclock(); + ProcessSection(ln->otherside); + ClipWall.Clock(); + } + } + D(Printf(PRINT_LOG, "Bunch %d done\n------------------------------\n",bnch)); + ClipWall.Unclock(); + } + + //========================================================================== + // + // + // + //========================================================================== + + int FindClosestBunch() + { + int closest = 0; //Almost works, but not quite :( + + CompareData.Clear(); + for(unsigned i = 1; i < Bunches.Size(); i++) + { + switch (BunchInFront(&Bunches[i], &Bunches[closest])) + { + case 0: // i is in front + closest = i; + continue; + + case 1: // i is behind + continue; + + default: // can't determine + CompareData.Push(i); // mark for later comparison + continue; + } + } + + // we need to do a second pass to see how the marked bunches relate to the currently closest one. + for(unsigned i = 0; i < CompareData.Size(); i++) + { + switch (BunchInFront(&Bunches[CompareData[i]], &Bunches[closest])) + { + case 0: // is in front + closest = i; + CompareData.Delete(i); + i = 0; // we need to recheck everything that's still marked. + continue; + + case 1: // is behind + CompareData.Delete(i); + i--; + continue; + + default: + continue; + + } + } + return closest; + } + + //========================================================================== + // + // + // + //========================================================================== + + void ProcessSection(int sectnum) + { + FGLSection *sect = &Sections[sectnum]; + bool inbunch; + angle_t startangle; + + if (sect->validcount == StartTime) return; + sect->validcount = StartTime; + D(Printf(PRINT_LOG, "------------------------------\nProcessing section %d (sector %d)\n",sectnum, sect->sector->sectornum)); + + #ifndef BUILD_TEST + for(unsigned i = 0; i < sect->subsectors.Size(); i++) + { + DoSubsector(sect->subsectors[i], false); + if (sect->subsectors[i]->poly != NULL) + { + // ProcessPolyobject() + } + } + #endif + + //Todo: process subsectors + for(int i=0; inumloops; i++) + { + FGLSectionLoop *loop = sect->GetLoop(i); + inbunch = false; + + for(int j=0; jnumlines; j++) + { + FGLSectionLine *ln = loop->GetLine(j); + + angle_t ang1 = ln->start->GetClipAngle(); + angle_t ang2 = ln->end->GetClipAngle(); + + if (ang2 - ang1 < ANGLE_180) + { + // Backside + D(Printf(PRINT_LOG, "line %d facing backwards\n", ln->linedef - lines)); + inbunch = false; + } + else if (!clipper.SafeCheckRange(ang2, ang1)) + { + // is it visible? + D(Printf(PRINT_LOG, "line %d not in view\n", ln->linedef - lines)); + inbunch = false; + } + else if (!inbunch || startangle - ang2 >= ANGLE_180) + { + // don't let a bunch span more than 180° to avoid problems. + // This limitation ensures that the combined range of 2 + // bunches will always be less than 360° which simplifies + // the distance comparison code because it prevents a + // situation where 2 bunches may overlap at both ends. + D(Printf(PRINT_LOG, "Starting bunch %d at line %d\n",Bunches.Size(), ln->linedef - lines)); + + startangle = ang2; + // Clipping angles are backward which makes this code very hard to read so let's use the inverse + StartBunch(loop->startline + j, 0 - ang1, 0 - ang2); + inbunch = true; + } + else + { + D(Printf(PRINT_LOG, " Adding line %d\n", ln->linedef - lines)); + AddLineToBunch(0 - ang2); + } + } + } + D(Printf(PRINT_LOG, "Section %d done\n------------------------------\n",sectnum)); + } + + //========================================================================== + // + // + // + //========================================================================== + +public: + void RenderScene(int viewsection) + { + ProcessSection(viewsection); + while (Bunches.Size() > 0) + { + int closest = FindClosestBunch(); + ProcessBunch(closest); + DeleteBunch(closest); + } + } +}; + + +void gl_RenderBuild() +{ + subsector_t *sub = R_PointInSubsector(viewx, viewy); + + clipper.Clear(); + angle_t a1 = GLRenderer->FrustumAngle(); + clipper.SafeAddClipRangeRealAngles(viewangle+a1, viewangle-a1); + if (Sections.Size() == 0) gl_CreateSections(); + + int startsection = SectionForSubsector[sub-subsectors]; + + BunchDrawer bd; + bd.RenderScene(startsection); +} + +#ifdef BUILD_TEST +CCMD(testrender) +{ + gl_RenderBuild(); +} +#endif diff --git a/src/gl/gl_functions.h b/src/gl/gl_functions.h new file mode 100644 index 000000000..aa08d19be --- /dev/null +++ b/src/gl/gl_functions.h @@ -0,0 +1,13 @@ +#ifndef __GL_FUNCT +#define __GL_FUNCT + +#include "v_palette.h" + +class AActor; + +void gl_PreprocessLevel(); +void gl_CleanLevelData(); +void gl_LinkLights(); +void gl_SetActorLights(AActor *); + +#endif diff --git a/src/gl/hqnx/Image.cpp b/src/gl/hqnx/Image.cpp new file mode 100644 index 000000000..089036365 --- /dev/null +++ b/src/gl/hqnx/Image.cpp @@ -0,0 +1,1174 @@ +//CImage class - loading and saving BMP and TGA files +//---------------------------------------------------------- +//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +// +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU Lesser General Public +//License as published by the Free Software Foundation; either +//version 2.1 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public +//License along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#include +#include +#include "Image.h" + +DLL CImage::CImage() +{ + m_Xres = m_Yres = m_NumPixel = 0; + m_pBitmap = NULL; +} + +DLL CImage::~CImage() +{ + Destroy(); +} + +int DLL CImage::Init( int X, int Y, unsigned short BitPerPixel ) +{ + if (m_pBitmap != NULL) + free(m_pBitmap); + + m_Xres = X; + m_Yres = Y; + m_BitPerPixel = BitPerPixel<=8 ? 8 : BitPerPixel<=16 ? 16 : BitPerPixel<=24 ? 24 : 32; + m_BytePerPixel = m_BitPerPixel >> 3; + m_NumPixel = m_Xres*m_Yres; + int size = m_NumPixel*((m_BitPerPixel+7)/8); + m_pBitmap=(unsigned char *)malloc(size); + return (m_pBitmap != NULL) ? 0 : 1; +} + +int DLL CImage::SetImage(unsigned char *img, int width, int height, int bpp) +{ + Init(width, height, bpp); + + memcpy(m_pBitmap, img, m_NumPixel * m_BytePerPixel); + + return 0; +} + +int DLL CImage::Destroy() +{ + if (m_pBitmap) + { + free(m_pBitmap); + m_pBitmap = NULL; + } + m_Xres = 0; + m_Yres = 0; + m_NumPixel = 0; + m_BitPerPixel = 0; + return 0; +} + +int DLL CImage::Convert32To17( void ) +{ + int nRes = eConvUnknownFormat; + + if ( m_BitPerPixel == 32 ) + { + if ( m_pBitmap != NULL ) + { + unsigned char * pTemp8 = m_pBitmap; + unsigned int * pTemp32 = (unsigned int *)m_pBitmap; + unsigned int a, r, g, b; + for ( int i=0; i> 3; + g = (*(pTemp8++)) >> 2; + r = (*(pTemp8++)) >> 3; + a = *(pTemp8++); + *pTemp32 = (r << 11) + (g << 5) + b + (a > 127 ? 0x10000 : 0); + pTemp32++; + } + } + else + nRes = eConvSourceMemory; + + nRes = 0; + } + + return nRes; +} + +int DLL CImage::ConvertTo32( void ) +{ + int nRes = eConvUnknownFormat; + + if ( m_pBitmap == NULL ) + return eConvSourceMemory; + + switch ( m_BitPerPixel ) + { + case 8: + { + nRes = 0; + m_BitPerPixel = 32; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*4); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp8 = m_pBitmap; + unsigned char * pTemp32 = pNewBitmap; + unsigned char c; + for ( int i=0; i> 3); + *(pTemp24++) = ((rgb & 0xF800) >> 8); + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + break; + } + case 32: + { + nRes = 0; + m_BitPerPixel = 24; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*3); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp32 = m_pBitmap; + unsigned char * pTemp24 = pNewBitmap; + for ( int i=0; i> 3; + g = m_Pal[c].g >> 2; + b = m_Pal[c].b >> 3; + *(pTemp16++) = (r << 11) + (g << 5) + b; + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + break; + } + case 24: + { + nRes = 0; + m_BitPerPixel = 16; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*2); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp24 = m_pBitmap; + unsigned short * pTemp16 = (unsigned short *)pNewBitmap; + unsigned short r, g, b; + for ( int i=0; i> 3; + g = (*(pTemp24++)) >> 2; + r = (*(pTemp24++)) >> 3; + *(pTemp16++) = (r << 11) + (g << 5) + b; + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + break; + } + case 32: + { + nRes = 0; + m_BitPerPixel = 16; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*2); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp32 = m_pBitmap; + unsigned short * pTemp16 = (unsigned short *)pNewBitmap; + unsigned short r, g, b; + for ( int i=0; i> 3; + g = (*(pTemp32++)) >> 2; + r = (*(pTemp32++)) >> 3; + pTemp32++; + *(pTemp16++) = (r << 11) + (g << 5) + b; + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + break; + } + } + + return nRes; +} + +int CImage::Convert8To17( int transindex ) +{ + int nRes = eConvUnknownFormat; + + if ( m_BitPerPixel == 8 ) + { + m_BitPerPixel = 32; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*4); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp8 = m_pBitmap; + unsigned int * pTemp32 = (unsigned int *)pNewBitmap; + unsigned int r, g, b; + unsigned char c; + for ( int i=0; i> 3; + g = m_Pal[c].g >> 2; + b = m_Pal[c].b >> 3; + *(pTemp32++) = (r << 11) + (g << 5) + b + (transindex != c ? 0x10000 : 0); + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + nRes = 0; + } + + return nRes; +} + +int CImage::SaveBmp(char *szFilename) +{ + _BMPFILEHEADER fh; + _BMPIMAGEHEADER ih; + unsigned char BmpPal[256][4]; + long int SuffLen; + long int Dummy = 0; + unsigned char * pBuf; + short i; + + if (!(f = fopen(szFilename, "wb"))) return eSaveBmpFileOpen; + if ( m_pBitmap == NULL ) return eSaveBmpSourceMemory; + + fh.bfType=0x4D42; + if (m_BitPerPixel==8) + { + SuffLen=((m_Xres+3)/4)*4-m_Xres; + ih.biSize=0x28; + ih.biWidth=m_Xres; + ih.biHeight=m_Yres; + ih.biPlanes=1; + ih.biBitCount=8; + ih.biCompression=0; + ih.biSizeImage=(m_Xres+SuffLen)*m_Yres; + ih.biXPelsPerMeter=ih.biYPelsPerMeter=0x2E23; // 300dpi (pixels per meter) + ih.biClrUsed=ih.biClrImportant=0; + fh.bfSize=(ih.biSizeImage)+0x0436; + fh.bfRes1=0; + fh.bfOffBits=0x0436; + if (fwrite(&fh, 14, 1, f) != 1) return eSaveBmpFileWrite; + if (fwrite(&ih, 40, 1, f) != 1) return eSaveBmpFileWrite; + for (i=0; i<256; i++) + { + BmpPal[i][0]=m_Pal[i].b; + BmpPal[i][1]=m_Pal[i].g; + BmpPal[i][2]=m_Pal[i].r; + BmpPal[i][3]=0; + } + if (fwrite(&BmpPal, 1024, 1, f) != 1) return eSaveBmpFileWrite; + pBuf=m_pBitmap; + pBuf+=m_NumPixel; + for (i=0; i0) + { + if (fwrite(&Dummy, SuffLen, 1, f) != 1) return eSaveBmpFileWrite; + } + } + } + else + if (m_BitPerPixel==24) + { + SuffLen=((m_Xres*3+3)/4)*4-m_Xres*3; + ih.biSize=0x28; + ih.biWidth=m_Xres; + ih.biHeight=m_Yres; + ih.biPlanes=1; + ih.biBitCount=24; + ih.biCompression=0; + ih.biSizeImage=(m_Xres*3+SuffLen)*m_Yres; + ih.biXPelsPerMeter=ih.biYPelsPerMeter=0x2E23; // 300dpi (pixels per meter) + ih.biClrUsed=ih.biClrImportant=0; + fh.bfSize=(ih.biSizeImage)+0x0036; + fh.bfRes1=0; + fh.bfOffBits=0x0036; + if (fwrite(&fh, 14, 1, f) != 1) return eSaveBmpFileWrite; + if (fwrite(&ih, 40, 1, f) != 1) return eSaveBmpFileWrite; + pBuf=m_pBitmap; + pBuf+=m_NumPixel*3; + for (i=0; i0) + { + if (fwrite(&Dummy, SuffLen, 1, f) != 1) return eSaveBmpFileWrite; + } + } + } + else + return eSaveBmpColorDepth; + + fclose(f); + + return 0; +} + +int CImage::LoadBmp(char *szFilename) +{ + _BMPFILEHEADER fh; + _BMPIMAGEHEADEROLD ih_old; + _BMPIMAGEHEADER ih; + unsigned char BmpPal[256][4]; + long int biSize; + long int SuffLen; + long int Dummy = 0; + unsigned char * pBuf; + short i; + long int xres, yres; + unsigned short bits; + + if (!(f = fopen(szFilename, "rb"))) return eLoadBmpFileOpen; + if (fread(&fh, 14, 1, f) != 1) return eLoadBmpFileRead; + if (fh.bfType != 0x4D42) return eLoadBmpBadFormat; + if (fread(&biSize, 4, 1, f) != 1) return eLoadBmpFileRead; + if (biSize > 12) + { + fseek( f, -4, SEEK_CUR ); + if (fread(&ih, biSize, 1, f) != 1) return eLoadBmpFileRead; + xres = ih.biWidth; + yres = ih.biHeight; + bits = ih.biBitCount; + } + else + { + fseek( f, -4, SEEK_CUR ); + if (fread(&ih_old, biSize, 1, f) != 1) return eLoadBmpFileRead; + xres = ih_old.biWidth; + yres = ih_old.biHeight; + bits = ih_old.biBitCount; + } + + if ( Init( xres, yres, bits ) != 0 ) return eLoadBmpInit; + if (m_BitPerPixel==8) + { + SuffLen=((m_Xres+3)/4)*4-m_Xres; + if (fread(&BmpPal, 1024, 1, f) != 1) return eLoadBmpFileRead; + for (i=0; i<256; i++) + { + m_Pal[i].b=BmpPal[i][0]; + m_Pal[i].g=BmpPal[i][1]; + m_Pal[i].r=BmpPal[i][2]; + } + pBuf=m_pBitmap; + pBuf+=m_NumPixel; + for (i=0; i0) + { + if (fread(&Dummy, SuffLen, 1, f) != 1) return eLoadBmpFileRead; + } + } + } + else + if (m_BitPerPixel==24) + { + SuffLen=((m_Xres*3+3)/4)*4-(m_Xres*3); + pBuf=m_pBitmap; + pBuf+=m_NumPixel*3; + for (i=0; i0) + { + if (fread(&Dummy, SuffLen, 1, f) != 1) return eLoadBmpFileRead; + } + } + } + else + return eLoadBmpColorDepth; + + fclose(f); + + return 0; +} + +void CImage::Output( void ) +{ + fwrite(m_cBuf, m_nCount, 1, f); + m_nCount=0; +} + +void CImage::Output( char c ) +{ + if ( m_nCount == sizeof(m_cBuf) ) + { + fwrite(m_cBuf, m_nCount, 1, f); + m_nCount=0; + } + m_cBuf[m_nCount++] = c; +} + +void CImage::Output( char * pcData, int nSize ) +{ + for ( int i=0; i 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+i-nDif-nRep), nDif ); + } + nDif = 1; + } + } + else + { + if ( bEqual && (nRep<127) ) + nRep++; + else + { + Output( nRep+128 ); + Output( (char*)&colOld, 1 ); + nRep = 0; + nDif = 1; + } + } + } + + if ( nRep == 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+m_Xres-nDif), nDif ); + } + else + { + Output( nRep+128 ); + Output( (char*)&colOld, 1 ); + } + Output(); + } + } + } + else + if (m_BitPerPixel==24) + { + fh.tiImageType = bCompressed ? 10 : 2; + if (fwrite(&fh, sizeof(fh), 1, f) != 1) return eSaveTgaFileWrite; + + _BGR * pcolBuf = (_BGR *)m_pBitmap; + pcolBuf += m_NumPixel; + + if ( !bCompressed ) + { + for (j=0; j 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+i-nDif-nRep), sizeof(_BGR)*nDif ); + } + nDif = 1; + } + } + else + { + if ( bEqual && (nRep<127) ) + nRep++; + else + { + Output( nRep+128 ); + Output( (char*)&colOld, sizeof(_BGR) ); + nRep = 0; + nDif = 1; + } + } + } + + if ( nRep == 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+m_Xres-nDif), sizeof(_BGR)*nDif ); + } + else + { + Output( nRep+128 ); + Output( (char*)&colOld, sizeof(_BGR) ); + } + Output(); + } + } + } + else + if (m_BitPerPixel==32) + { + fh.tiImageType = bCompressed ? 10 : 2; + fh.tiAttrBits = 8; + if (fwrite(&fh, sizeof(fh), 1, f) != 1) return eSaveTgaFileWrite; + + _BGRA * pcolBuf = (_BGRA *)m_pBitmap; + pcolBuf += m_NumPixel; + + if ( !bCompressed ) + { + for (j=0; j 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+i-nDif-nRep), sizeof(_BGRA)*nDif ); + } + nDif = 1; + } + } + else + { + if ( bEqual && (nRep<127) ) + nRep++; + else + { + Output( nRep+128 ); + Output( (char*)&colOld, sizeof(_BGRA) ); + nRep = 0; + nDif = 1; + } + } + } + + if ( nRep == 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+m_Xres-nDif), sizeof(_BGRA)*nDif ); + } + else + { + Output( nRep+128 ); + Output( (char*)&colOld, sizeof(_BGRA) ); + } + Output(); + } + } + } + else + return eSaveTgaColorDepth; + + fclose(f); + + return 0; +} + +int CImage::LoadTga(char *szFilename) +{ + _TGAHEADER fh; + int i, j, k; + unsigned char nCount; + + if (!(f = fopen(szFilename, "rb"))) return eLoadTgaFileOpen; + if (fread(&fh, sizeof(fh), 1, f) != 1) return eLoadTgaFileRead; + bool bCompressed = (( fh.tiImageType & 8 ) != 0); + if ((fh.tiBitPerPixel<=0) || (fh.tiBitPerPixel>32)) + return eLoadTgaBadFormat; + + if ( Init( fh.tiXres, fh.tiYres, fh.tiBitPerPixel ) != 0 ) + return eLoadTgaInit; + + if ( m_BitPerPixel == 8 ) + { + if ( fh.tiPaletteIncluded == 1 ) + { + if ( fh.tiPaletteBpp == 24) + { + if (fread(&m_Pal, 3, fh.tiPaletteSize, f) != fh.tiPaletteSize) + return eLoadTgaFileRead; + } + else + if ( fh.tiPaletteBpp == 32) + { + unsigned char BmpPal[256][4]; + + if (fread(&BmpPal, 4, fh.tiPaletteSize, f) != fh.tiPaletteSize) + return eLoadTgaFileRead; + + for (i=0; i= m_pBitmap ) + { + nCount = Input(); + if ((nCount & 128)==0) + { + for (k=0; k<=nCount; k++) + { + colCur = Input(); + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + else + { + colCur = Input(); + for (k=0; k<=nCount-128; k++) + { + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + } + } + } + else + if ( m_BitPerPixel == 24 ) + { + _BGR * pcolBuf = (_BGR *)m_pBitmap; + pcolBuf += m_NumPixel; + + if ( !bCompressed ) + { + for (j=0; j= (_BGR *)m_pBitmap ) + { + nCount = Input(); + if ((nCount & 128)==0) + { + for (k=0; k<=nCount; k++) + { + colCur.b = Input(); + colCur.g = Input(); + colCur.r = Input(); + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + else + { + colCur.b = Input(); + colCur.g = Input(); + colCur.r = Input(); + for (k=0; k<=nCount-128; k++) + { + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + } + } + } + else + if ( m_BitPerPixel == 32 ) + { + _BGRA * pcolBuf = (_BGRA *)m_pBitmap; + pcolBuf += m_NumPixel; + + if ( !bCompressed ) + { + for (j=0; j= (_BGRA *)m_pBitmap ) + { + nCount = Input(); + if ((nCount & 128)==0) + { + for (k=0; k<=nCount; k++) + { + colCur.b = Input(); + colCur.g = Input(); + colCur.r = Input(); + colCur.a = Input(); + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + else + { + colCur.b = Input(); + colCur.g = Input(); + colCur.r = Input(); + colCur.a = Input(); + for (k=0; k<=nCount-128; k++) + { + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + } + } + } + else + return eLoadTgaColorDepth; + + fclose(f); + + return 0; +} + +int DLL CImage::Load(char *szFilename) +{ + int nRes = 0; + + if ( szFilename != NULL ) + { + char * szExt = strrchr( szFilename, '.' ); + int nNotTGA = 1; + + if ( szExt != NULL ) + nNotTGA = _stricmp( szExt, ".tga" ); + + if ( nNotTGA != 0 ) + nRes = LoadBmp( szFilename ); + else + nRes = LoadTga( szFilename ); + } + else + nRes = eLoadFilename; + + return nRes; +} + +int DLL CImage::Save(char *szFilename) +{ + int nRes = 0; + int nNotTGA = 1; + + if ( szFilename != NULL ) + { + char * szExt = strrchr( szFilename, '.' ); + + if ( szExt != NULL ) + nNotTGA = _stricmp( szExt, ".tga" ); + + if ( nNotTGA != 0 ) + { + if (( m_BitPerPixel == 16 ) || ( m_BitPerPixel == 32 )) + nRes = ConvertTo24(); + + if (nRes == 0) + nRes = SaveBmp( szFilename ); + } + else + { + if ( m_BitPerPixel == 16 ) + nRes = ConvertTo24(); + + if (nRes == 0) + nRes = SaveTga( szFilename, true ); + } + } + else + nRes = eSaveFilename; + + return nRes; +} diff --git a/src/gl/hqnx/Image.h b/src/gl/hqnx/Image.h new file mode 100644 index 000000000..684aba164 --- /dev/null +++ b/src/gl/hqnx/Image.h @@ -0,0 +1,145 @@ +//CImage class - loading and saving BMP and TGA files +//---------------------------------------------------------- +//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +// +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU Lesser General Public +//License as published by the Free Software Foundation; either +//version 2.1 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public +//License along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +//#ifdef WIN32 +//#define DLL __declspec(dllexport) +//#else +#define DLL +//#endif + +#include +#pragma once +#pragma warning(disable: 4103) +#pragma pack(1) + +typedef struct { unsigned char b, g, r; } _BGR; +typedef struct { unsigned char b, g, r, a; } _BGRA; + +class CImage +{ + public: + DLL CImage(); + DLL ~CImage(); + + enum CImageErrors + { + eConvUnknownFormat = 10, + eConvSourceMemory = 11, + eConvDestMemory = 12, + + eSaveBmpFileOpen = 20, + eSaveBmpFileWrite = 21, + eSaveBmpSourceMemory = 22, + eSaveBmpColorDepth = 23, + + eLoadBmpFileOpen = 30, + eLoadBmpFileRead = 31, + eLoadBmpBadFormat = 32, + eLoadBmpInit = 33, + eLoadBmpColorDepth = 34, + + eSaveTgaFileOpen = 40, + eSaveTgaFileWrite = 41, + eSaveTgaSourceMemory = 42, + eSaveTgaColorDepth = 43, + + eLoadTgaFileOpen = 50, + eLoadTgaFileRead = 51, + eLoadTgaBadFormat = 52, + eLoadTgaInit = 53, + eLoadTgaColorDepth = 54, + + eLoadFilename = 60, + eSaveFilename = 61, + }; + + struct _BMPFILEHEADER + { + unsigned short bfType; + long int bfSize, bfRes1, bfOffBits; + }; + + struct _BMPIMAGEHEADEROLD + { + long int biSize; + unsigned short biWidth, biHeight; + unsigned short biPlanes, biBitCount; + }; + + struct _BMPIMAGEHEADER + { + long int biSize, biWidth, biHeight; + unsigned short biPlanes, biBitCount; + long int biCompression, biSizeImage; + long int biXPelsPerMeter, biYPelsPerMeter; + long int biClrUsed, biClrImportant; + }; + + struct _TGAHEADER + { + unsigned char tiIdentSize; + unsigned char tiPaletteIncluded; + unsigned char tiImageType; + unsigned short tiPaletteStart; + unsigned short tiPaletteSize; + unsigned char tiPaletteBpp; + unsigned short tiX0; + unsigned short tiY0; + unsigned short tiXres; + unsigned short tiYres; + unsigned char tiBitPerPixel; + unsigned char tiAttrBits; + }; + + public: + int DLL Init( int Xres, int Yres, unsigned short BitPerPixel ); + int DLL SetImage(unsigned char *img, int width, int height, int bpp); + int DLL Destroy(); + int DLL ConvertTo32( void ); + int DLL ConvertTo24( void ); + int DLL ConvertTo16( void ); + int DLL Convert8To17( int transindex ); + int DLL Convert32To17( void ); + int SaveBmp(char *szFilename); + int LoadBmp(char *szFilename); + int SaveTga(char *szFilename, bool bCompressed ); + int LoadTga(char *szFilename); + int DLL Load(char *szFilename); + int DLL Save(char *szFilename); + + private: + void Output( char * pcData, int nSize ); + void Output( char c ); + void Output( void ); + unsigned char Input( void ); + + public: + int m_Xres, m_Yres; + unsigned short m_BitPerPixel; + unsigned short m_BytePerPixel; + unsigned char * m_pBitmap; + _BGR m_Pal[256]; + + private: + int m_NumPixel; + FILE * f; + int m_nCount; + char m_cBuf[32768]; +}; + +#pragma pack(8) diff --git a/src/gl/hqnx/gl_hqresize.cpp b/src/gl/hqnx/gl_hqresize.cpp new file mode 100644 index 000000000..2aa8f2085 --- /dev/null +++ b/src/gl/hqnx/gl_hqresize.cpp @@ -0,0 +1,280 @@ +/* +** gl_hqresize.cpp +** Contains high quality upsampling functions. +** So far supports Scale2x/3x/4x as described in http://scale2x.sourceforge.net/ +** and Maxim Stepin's hq2x/3x/4x. +** +**--------------------------------------------------------------------------- +** Copyright 2008-2009 Benjamin Berkels +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl_pch.h" +#include "gl_hqresize.h" +#include "gl_intern.h" +#include "c_cvars.h" +// [BB] hqnx scaling is only supported with the MS compiler. +#ifdef _MSC_VER +#include "../hqnx/hqnx.h" +#endif + +CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ +#ifdef _MSC_VER + if (self < 0 || self > 6) +#else + if (self < 0 || self > 3) +#endif + self = 0; + FGLTexture::FlushAll(); +} + +CUSTOM_CVAR(Int, gl_texture_hqresize_maxinputsize, 512, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (self > 1024) self = 1024; + FGLTexture::FlushAll(); +} + +CUSTOM_CVAR(Int, gl_texture_hqresize_targets, 7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + FGLTexture::FlushAll(); +} + +CVAR (Flag, gl_texture_hqresize_textures, gl_texture_hqresize_targets, 1); +CVAR (Flag, gl_texture_hqresize_sprites, gl_texture_hqresize_targets, 2); +CVAR (Flag, gl_texture_hqresize_fonts, gl_texture_hqresize_targets, 4); + + +static void scale2x ( uint32* inputBuffer, uint32* outputBuffer, int inWidth, int inHeight ) +{ + const int width = 2* inWidth; + const int height = 2 * inHeight; + + for ( int i = 0; i < inWidth; ++i ) + { + const int iMinus = (i > 0) ? (i-1) : 0; + const int iPlus = (i < inWidth - 1 ) ? (i+1) : i; + for ( int j = 0; j < inHeight; ++j ) + { + const int jMinus = (j > 0) ? (j-1) : 0; + const int jPlus = (j < inHeight - 1 ) ? (j+1) : j; + const uint32 A = inputBuffer[ iMinus +inWidth*jMinus]; + const uint32 B = inputBuffer[ iMinus +inWidth*j ]; + const uint32 C = inputBuffer[ iMinus +inWidth*jPlus]; + const uint32 D = inputBuffer[ i +inWidth*jMinus]; + const uint32 E = inputBuffer[ i +inWidth*j ]; + const uint32 F = inputBuffer[ i +inWidth*jPlus]; + const uint32 G = inputBuffer[ iPlus +inWidth*jMinus]; + const uint32 H = inputBuffer[ iPlus +inWidth*j ]; + const uint32 I = inputBuffer[ iPlus +inWidth*jPlus]; + if (B != H && D != F) { + outputBuffer[2*i + width*2*j ] = D == B ? D : E; + outputBuffer[2*i + width*(2*j+1)] = B == F ? F : E; + outputBuffer[2*i+1 + width*2*j ] = D == H ? D : E; + outputBuffer[2*i+1 + width*(2*j+1)] = H == F ? F : E; + } else { + outputBuffer[2*i + width*2*j ] = E; + outputBuffer[2*i + width*(2*j+1)] = E; + outputBuffer[2*i+1 + width*2*j ] = E; + outputBuffer[2*i+1 + width*(2*j+1)] = E; + } + } + } +} + +static void scale3x ( uint32* inputBuffer, uint32* outputBuffer, int inWidth, int inHeight ) +{ + const int width = 3* inWidth; + const int height = 3 * inHeight; + + for ( int i = 0; i < inWidth; ++i ) + { + const int iMinus = (i > 0) ? (i-1) : 0; + const int iPlus = (i < inWidth - 1 ) ? (i+1) : i; + for ( int j = 0; j < inHeight; ++j ) + { + const int jMinus = (j > 0) ? (j-1) : 0; + const int jPlus = (j < inHeight - 1 ) ? (j+1) : j; + const uint32 A = inputBuffer[ iMinus +inWidth*jMinus]; + const uint32 B = inputBuffer[ iMinus +inWidth*j ]; + const uint32 C = inputBuffer[ iMinus +inWidth*jPlus]; + const uint32 D = inputBuffer[ i +inWidth*jMinus]; + const uint32 E = inputBuffer[ i +inWidth*j ]; + const uint32 F = inputBuffer[ i +inWidth*jPlus]; + const uint32 G = inputBuffer[ iPlus +inWidth*jMinus]; + const uint32 H = inputBuffer[ iPlus +inWidth*j ]; + const uint32 I = inputBuffer[ iPlus +inWidth*jPlus]; + if (B != H && D != F) { + outputBuffer[3*i + width*3*j ] = D == B ? D : E; + outputBuffer[3*i + width*(3*j+1)] = (D == B && E != C) || (B == F && E != A) ? B : E; + outputBuffer[3*i + width*(3*j+2)] = B == F ? F : E; + outputBuffer[3*i+1 + width*3*j ] = (D == B && E != G) || (D == H && E != A) ? D : E; + outputBuffer[3*i+1 + width*(3*j+1)] = E; + outputBuffer[3*i+1 + width*(3*j+2)] = (B == F && E != I) || (H == F && E != C) ? F : E; + outputBuffer[3*i+2 + width*3*j ] = D == H ? D : E; + outputBuffer[3*i+2 + width*(3*j+1)] = (D == H && E != I) || (H == F && E != G) ? H : E; + outputBuffer[3*i+2 + width*(3*j+2)] = H == F ? F : E; + } else { + outputBuffer[3*i + width*3*j ] = E; + outputBuffer[3*i + width*(3*j+1)] = E; + outputBuffer[3*i + width*(3*j+2)] = E; + outputBuffer[3*i+1 + width*3*j ] = E; + outputBuffer[3*i+1 + width*(3*j+1)] = E; + outputBuffer[3*i+1 + width*(3*j+2)] = E; + outputBuffer[3*i+2 + width*3*j ] = E; + outputBuffer[3*i+2 + width*(3*j+1)] = E; + outputBuffer[3*i+2 + width*(3*j+2)] = E; + } + } + } +} + +static void scale4x ( uint32* inputBuffer, uint32* outputBuffer, int inWidth, int inHeight ) +{ + int width = 2* inWidth; + int height = 2 * inHeight; + uint32 * buffer2x = new uint32[width*height]; + + scale2x ( reinterpret_cast ( inputBuffer ), reinterpret_cast ( buffer2x ), inWidth, inHeight ); + width *= 2; + height *= 2; + scale2x ( reinterpret_cast ( buffer2x ), reinterpret_cast ( outputBuffer ), 2*inWidth, 2*inHeight ); + delete[] buffer2x; +} + + +static unsigned char *scaleNxHelper( void (*scaleNxFunction) ( uint32* , uint32* , int , int), + const int N, + unsigned char *inputBuffer, + const int inWidth, + const int inHeight, + int &outWidth, + int &outHeight ) +{ + outWidth = N * inWidth; + outHeight = N *inHeight; + unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; + + scaleNxFunction ( reinterpret_cast ( inputBuffer ), reinterpret_cast ( newBuffer ), inWidth, inHeight ); + delete[] inputBuffer; + return newBuffer; +} + +// [BB] hqnx scaling is only supported with the MS compiler. +#ifdef _MSC_VER +static unsigned char *hqNxHelper( void (*hqNxFunction) ( int*, unsigned char*, int, int, int ), + const int N, + unsigned char *inputBuffer, + const int inWidth, + const int inHeight, + int &outWidth, + int &outHeight ) +{ + outWidth = N * inWidth; + outHeight = N *inHeight; + + CImage cImageIn; + cImageIn.SetImage(inputBuffer, inWidth, inHeight, 32); + cImageIn.Convert32To17(); + + unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; + hqNxFunction( reinterpret_cast(cImageIn.m_pBitmap), newBuffer, cImageIn.m_Xres, cImageIn.m_Yres, outWidth*4 ); + delete[] inputBuffer; + return newBuffer; +} +#endif + +//=========================================================================== +// +// [BB] Upsamples the texture in inputBuffer, frees inputBuffer and returns +// the upsampled buffer. +// +//=========================================================================== +unsigned char *gl_CreateUpsampledTextureBuffer ( const FGLTexture *inputGLTexture, unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight ) +{ + // [BB] Make sure that outWidth and outHeight denote the size of + // the returned buffer even if we don't upsample the input buffer. + outWidth = inWidth; + outHeight = inHeight; + + // [BB] Don't resample if the width or height of the input texture is bigger than gl_texture_hqresize_maxinputsize. + if ( ( inWidth > gl_texture_hqresize_maxinputsize ) || ( inHeight > gl_texture_hqresize_maxinputsize ) ) + return inputBuffer; + + // [BB] The hqnx upsampling (not the scaleN one) destroys partial transparency, don't upsamle textures using it. + if ( inputGLTexture->bIsTransparent == 1 ) + return inputBuffer; + + // [BB] Don't try to upsample textures based off FCanvasTexture. + if ( inputGLTexture->tex->bHasCanvas ) + return inputBuffer; + + // [BB] Don't upsample non-shader handled warped textures. Needs too much memory. + if ( (!(gl.flags & RFL_GLSL) || !gl_warp_shader) && inputGLTexture->tex->bWarped ) + return inputBuffer; + + switch (inputGLTexture->tex->UseType) + { + case FTexture::TEX_Sprite: + case FTexture::TEX_SkinSprite: + if (!(gl_texture_hqresize_targets & 2)) return inputBuffer; + break; + + case FTexture::TEX_FontChar: + if (!(gl_texture_hqresize_targets & 4)) return inputBuffer; + break; + + default: + if (!(gl_texture_hqresize_targets & 1)) return inputBuffer; + break; + } + + if (inputBuffer) + { + int type = gl_texture_hqresize; + switch (type) + { + case 1: + return scaleNxHelper( &scale2x, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 2: + return scaleNxHelper( &scale3x, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 3: + return scaleNxHelper( &scale4x, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); +// [BB] hqnx scaling is only supported with the MS compiler. +#ifdef _MSC_VER + case 4: + return hqNxHelper( &hq2x_32, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 5: + return hqNxHelper( &hq3x_32, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 6: + return hqNxHelper( &hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); +#endif + } + } + return inputBuffer; +} diff --git a/src/gl/hqnx/hq2x.cpp b/src/gl/hqnx/hq2x.cpp new file mode 100644 index 000000000..073fe06b2 --- /dev/null +++ b/src/gl/hqnx/hq2x.cpp @@ -0,0 +1,2987 @@ +//hq2x filter demo program +//---------------------------------------------------------- +//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +// +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU Lesser General Public +//License as published by the Free Software Foundation; either +//version 2.1 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public +//License along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#include "hqnx.h" + +extern int LUT16to32[65536*2]; +extern int RGBtoYUV[65536*2]; + +static const __int64 reg_blank = 0; +static const __int64 const3 = 0x0003000300030003; +static const __int64 const5 = 0x0005000500050005; +static const __int64 const6 = 0x0006000600060006; +static const __int64 const14 = 0x000E000E000E000E; +static const __int64 treshold = 0x0000000000300706; + +inline void Interp1(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1*3+c2)/4; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + pmullw mm1, const3 + paddw mm1, mm2 + psrlw mm1, 2 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp2(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*2+c2+c3) >> 2; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + psllw mm1, 1 + paddw mm1, mm2 + paddw mm1, mm3 + psrlw mm1, 2 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp5(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1+c2)/2; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + paddw mm1, mm2 + psrlw mm1, 1 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp6(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*5+c2*2+c3)/8; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + pmullw mm1, const5 + psllw mm2, 1 + paddw mm1, mm3 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp7(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*6+c2+c3)/8; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + pmullw mm1, const6 + paddw mm2, mm3 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp9(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*2+(c2+c3)*3)/8; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + psllw mm1, 1 + paddw mm2, mm3 + pmullw mm2, const3 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp10(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*14+c2+c3)/16; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + pmullw mm1, const14 + paddw mm2, mm3 + paddw mm1, mm2 + psrlw mm1, 4 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +#define PIXEL00_0 *((int*)(pOut)) = c[5]; +#define PIXEL00_10 Interp1(pOut, c[5], c[1]); +#define PIXEL00_11 Interp1(pOut, c[5], c[4]); +#define PIXEL00_12 Interp1(pOut, c[5], c[2]); +#define PIXEL00_20 Interp2(pOut, c[5], c[4], c[2]); +#define PIXEL00_21 Interp2(pOut, c[5], c[1], c[2]); +#define PIXEL00_22 Interp2(pOut, c[5], c[1], c[4]); +#define PIXEL00_60 Interp6(pOut, c[5], c[2], c[4]); +#define PIXEL00_61 Interp6(pOut, c[5], c[4], c[2]); +#define PIXEL00_70 Interp7(pOut, c[5], c[4], c[2]); +#define PIXEL00_90 Interp9(pOut, c[5], c[4], c[2]); +#define PIXEL00_100 Interp10(pOut, c[5], c[4], c[2]); +#define PIXEL01_0 *((int*)(pOut+4)) = c[5]; +#define PIXEL01_10 Interp1(pOut+4, c[5], c[3]); +#define PIXEL01_11 Interp1(pOut+4, c[5], c[2]); +#define PIXEL01_12 Interp1(pOut+4, c[5], c[6]); +#define PIXEL01_20 Interp2(pOut+4, c[5], c[2], c[6]); +#define PIXEL01_21 Interp2(pOut+4, c[5], c[3], c[6]); +#define PIXEL01_22 Interp2(pOut+4, c[5], c[3], c[2]); +#define PIXEL01_60 Interp6(pOut+4, c[5], c[6], c[2]); +#define PIXEL01_61 Interp6(pOut+4, c[5], c[2], c[6]); +#define PIXEL01_70 Interp7(pOut+4, c[5], c[2], c[6]); +#define PIXEL01_90 Interp9(pOut+4, c[5], c[2], c[6]); +#define PIXEL01_100 Interp10(pOut+4, c[5], c[2], c[6]); +#define PIXEL10_0 *((int*)(pOut+BpL)) = c[5]; +#define PIXEL10_10 Interp1(pOut+BpL, c[5], c[7]); +#define PIXEL10_11 Interp1(pOut+BpL, c[5], c[8]); +#define PIXEL10_12 Interp1(pOut+BpL, c[5], c[4]); +#define PIXEL10_20 Interp2(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL10_21 Interp2(pOut+BpL, c[5], c[7], c[4]); +#define PIXEL10_22 Interp2(pOut+BpL, c[5], c[7], c[8]); +#define PIXEL10_60 Interp6(pOut+BpL, c[5], c[4], c[8]); +#define PIXEL10_61 Interp6(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL10_70 Interp7(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL10_90 Interp9(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL10_100 Interp10(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL11_0 *((int*)(pOut+BpL+4)) = c[5]; +#define PIXEL11_10 Interp1(pOut+BpL+4, c[5], c[9]); +#define PIXEL11_11 Interp1(pOut+BpL+4, c[5], c[6]); +#define PIXEL11_12 Interp1(pOut+BpL+4, c[5], c[8]); +#define PIXEL11_20 Interp2(pOut+BpL+4, c[5], c[6], c[8]); +#define PIXEL11_21 Interp2(pOut+BpL+4, c[5], c[9], c[8]); +#define PIXEL11_22 Interp2(pOut+BpL+4, c[5], c[9], c[6]); +#define PIXEL11_60 Interp6(pOut+BpL+4, c[5], c[8], c[6]); +#define PIXEL11_61 Interp6(pOut+BpL+4, c[5], c[6], c[8]); +#define PIXEL11_70 Interp7(pOut+BpL+4, c[5], c[6], c[8]); +#define PIXEL11_90 Interp9(pOut+BpL+4, c[5], c[6], c[8]); +#define PIXEL11_100 Interp10(pOut+BpL+4, c[5], c[6], c[8]); + + +int Diff(unsigned int w5, unsigned int w1); + +void DLL hq2x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) +{ + int i, j, k; + int w[10]; + unsigned int c[10]; + + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ + + for (j=0; j0) + { + w[1] = *(pIn - Xres - 1); + } + else + { + w[1] = 0; + } + + w[2] = *(pIn - Xres); + + if (i0) + { + w[4] = *(pIn - 1); + } + else + { + w[4] = 0; + } + + w[5] = *(pIn); + if (i0) + { + w[7] = *(pIn + Xres - 1); + } + else + { + w[7] = 0; + } + + w[8] = *(pIn + Xres); + if (i0) w[1] = *(pIn - Xres - 1); else w[1] = 0; + w[2] = *(pIn - Xres); + if (i0) w[4] = *(pIn - 1); else w[4] = 0; + w[5] = *(pIn); + if (i0) w[7] = *(pIn + Xres - 1); else w[7] = 0; + w[8] = *(pIn + Xres); + if (i +#include +#include +#include +#include "hqnx.h" + +int LUT16to32[65536*2]; +int RGBtoYUV[65536*2]; + +static const __int64 reg_blank = 0; +static const __int64 const3 = 0x0003000300030003; +static const __int64 const5 = 0x0005000500050005; +static const __int64 const6 = 0x0006000600060006; +static const __int64 const7 = 0x0007000700070007; +static const __int64 treshold = 0x0000000000300706; + + +inline void Interp1(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1*3+c2)/4; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + pmullw mm1, const3 + paddw mm1, mm2 + psrlw mm1, 2 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp2(unsigned char * pc, int c1, int c2, int c3) +{ +// *((int*)pc) = (c1*2+c2+c3)/4; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + psllw mm1, 1 + paddw mm1, mm2 + paddw mm1, mm3 + psrlw mm1, 2 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp3(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1*7+c2)/8; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + pmullw mm1, const7 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp5(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1+c2)/2; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + paddw mm1, mm2 + psrlw mm1, 1 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp6(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*5+c2*2+c3)/8; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + pmullw mm1, const5 + psllw mm2, 1 + paddw mm1, mm3 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp7(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*6+c2+c3)/8; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + pmullw mm1, const6 + paddw mm2, mm3 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp8(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1*5+c2*3)/8; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + pmullw mm1, const5 + pmullw mm2, const3 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +#define PIXEL00_0 *((int*)(pOut)) = c[5]; +#define PIXEL00_11 Interp1(pOut, c[5], c[4]); +#define PIXEL00_12 Interp1(pOut, c[5], c[2]); +#define PIXEL00_20 Interp2(pOut, c[5], c[2], c[4]); +#define PIXEL00_50 Interp5(pOut, c[2], c[4]); +#define PIXEL00_80 Interp8(pOut, c[5], c[1]); +#define PIXEL00_81 Interp8(pOut, c[5], c[4]); +#define PIXEL00_82 Interp8(pOut, c[5], c[2]); +#define PIXEL01_0 *((int*)(pOut+4)) = c[5]; +#define PIXEL01_10 Interp1(pOut+4, c[5], c[1]); +#define PIXEL01_12 Interp1(pOut+4, c[5], c[2]); +#define PIXEL01_14 Interp1(pOut+4, c[2], c[5]); +#define PIXEL01_21 Interp2(pOut+4, c[2], c[5], c[4]); +#define PIXEL01_31 Interp3(pOut+4, c[5], c[4]); +#define PIXEL01_50 Interp5(pOut+4, c[2], c[5]); +#define PIXEL01_60 Interp6(pOut+4, c[5], c[2], c[4]); +#define PIXEL01_61 Interp6(pOut+4, c[5], c[2], c[1]); +#define PIXEL01_82 Interp8(pOut+4, c[5], c[2]); +#define PIXEL01_83 Interp8(pOut+4, c[2], c[4]); +#define PIXEL02_0 *((int*)(pOut+8)) = c[5]; +#define PIXEL02_10 Interp1(pOut+8, c[5], c[3]); +#define PIXEL02_11 Interp1(pOut+8, c[5], c[2]); +#define PIXEL02_13 Interp1(pOut+8, c[2], c[5]); +#define PIXEL02_21 Interp2(pOut+8, c[2], c[5], c[6]); +#define PIXEL02_32 Interp3(pOut+8, c[5], c[6]); +#define PIXEL02_50 Interp5(pOut+8, c[2], c[5]); +#define PIXEL02_60 Interp6(pOut+8, c[5], c[2], c[6]); +#define PIXEL02_61 Interp6(pOut+8, c[5], c[2], c[3]); +#define PIXEL02_81 Interp8(pOut+8, c[5], c[2]); +#define PIXEL02_83 Interp8(pOut+8, c[2], c[6]); +#define PIXEL03_0 *((int*)(pOut+12)) = c[5]; +#define PIXEL03_11 Interp1(pOut+12, c[5], c[2]); +#define PIXEL03_12 Interp1(pOut+12, c[5], c[6]); +#define PIXEL03_20 Interp2(pOut+12, c[5], c[2], c[6]); +#define PIXEL03_50 Interp5(pOut+12, c[2], c[6]); +#define PIXEL03_80 Interp8(pOut+12, c[5], c[3]); +#define PIXEL03_81 Interp8(pOut+12, c[5], c[2]); +#define PIXEL03_82 Interp8(pOut+12, c[5], c[6]); +#define PIXEL10_0 *((int*)(pOut+BpL)) = c[5]; +#define PIXEL10_10 Interp1(pOut+BpL, c[5], c[1]); +#define PIXEL10_11 Interp1(pOut+BpL, c[5], c[4]); +#define PIXEL10_13 Interp1(pOut+BpL, c[4], c[5]); +#define PIXEL10_21 Interp2(pOut+BpL, c[4], c[5], c[2]); +#define PIXEL10_32 Interp3(pOut+BpL, c[5], c[2]); +#define PIXEL10_50 Interp5(pOut+BpL, c[4], c[5]); +#define PIXEL10_60 Interp6(pOut+BpL, c[5], c[4], c[2]); +#define PIXEL10_61 Interp6(pOut+BpL, c[5], c[4], c[1]); +#define PIXEL10_81 Interp8(pOut+BpL, c[5], c[4]); +#define PIXEL10_83 Interp8(pOut+BpL, c[4], c[2]); +#define PIXEL11_0 *((int*)(pOut+BpL+4)) = c[5]; +#define PIXEL11_30 Interp3(pOut+BpL+4, c[5], c[1]); +#define PIXEL11_31 Interp3(pOut+BpL+4, c[5], c[4]); +#define PIXEL11_32 Interp3(pOut+BpL+4, c[5], c[2]); +#define PIXEL11_70 Interp7(pOut+BpL+4, c[5], c[4], c[2]); +#define PIXEL12_0 *((int*)(pOut+BpL+8)) = c[5]; +#define PIXEL12_30 Interp3(pOut+BpL+8, c[5], c[3]); +#define PIXEL12_31 Interp3(pOut+BpL+8, c[5], c[2]); +#define PIXEL12_32 Interp3(pOut+BpL+8, c[5], c[6]); +#define PIXEL12_70 Interp7(pOut+BpL+8, c[5], c[6], c[2]); +#define PIXEL13_0 *((int*)(pOut+BpL+12)) = c[5]; +#define PIXEL13_10 Interp1(pOut+BpL+12, c[5], c[3]); +#define PIXEL13_12 Interp1(pOut+BpL+12, c[5], c[6]); +#define PIXEL13_14 Interp1(pOut+BpL+12, c[6], c[5]); +#define PIXEL13_21 Interp2(pOut+BpL+12, c[6], c[5], c[2]); +#define PIXEL13_31 Interp3(pOut+BpL+12, c[5], c[2]); +#define PIXEL13_50 Interp5(pOut+BpL+12, c[6], c[5]); +#define PIXEL13_60 Interp6(pOut+BpL+12, c[5], c[6], c[2]); +#define PIXEL13_61 Interp6(pOut+BpL+12, c[5], c[6], c[3]); +#define PIXEL13_82 Interp8(pOut+BpL+12, c[5], c[6]); +#define PIXEL13_83 Interp8(pOut+BpL+12, c[6], c[2]); +#define PIXEL20_0 *((int*)(pOut+BpL+BpL)) = c[5]; +#define PIXEL20_10 Interp1(pOut+BpL+BpL, c[5], c[7]); +#define PIXEL20_12 Interp1(pOut+BpL+BpL, c[5], c[4]); +#define PIXEL20_14 Interp1(pOut+BpL+BpL, c[4], c[5]); +#define PIXEL20_21 Interp2(pOut+BpL+BpL, c[4], c[5], c[8]); +#define PIXEL20_31 Interp3(pOut+BpL+BpL, c[5], c[8]); +#define PIXEL20_50 Interp5(pOut+BpL+BpL, c[4], c[5]); +#define PIXEL20_60 Interp6(pOut+BpL+BpL, c[5], c[4], c[8]); +#define PIXEL20_61 Interp6(pOut+BpL+BpL, c[5], c[4], c[7]); +#define PIXEL20_82 Interp8(pOut+BpL+BpL, c[5], c[4]); +#define PIXEL20_83 Interp8(pOut+BpL+BpL, c[4], c[8]); +#define PIXEL21_0 *((int*)(pOut+BpL+BpL+4)) = c[5]; +#define PIXEL21_30 Interp3(pOut+BpL+BpL+4, c[5], c[7]); +#define PIXEL21_31 Interp3(pOut+BpL+BpL+4, c[5], c[8]); +#define PIXEL21_32 Interp3(pOut+BpL+BpL+4, c[5], c[4]); +#define PIXEL21_70 Interp7(pOut+BpL+BpL+4, c[5], c[4], c[8]); +#define PIXEL22_0 *((int*)(pOut+BpL+BpL+8)) = c[5]; +#define PIXEL22_30 Interp3(pOut+BpL+BpL+8, c[5], c[9]); +#define PIXEL22_31 Interp3(pOut+BpL+BpL+8, c[5], c[6]); +#define PIXEL22_32 Interp3(pOut+BpL+BpL+8, c[5], c[8]); +#define PIXEL22_70 Interp7(pOut+BpL+BpL+8, c[5], c[6], c[8]); +#define PIXEL23_0 *((int*)(pOut+BpL+BpL+12)) = c[5]; +#define PIXEL23_10 Interp1(pOut+BpL+BpL+12, c[5], c[9]); +#define PIXEL23_11 Interp1(pOut+BpL+BpL+12, c[5], c[6]); +#define PIXEL23_13 Interp1(pOut+BpL+BpL+12, c[6], c[5]); +#define PIXEL23_21 Interp2(pOut+BpL+BpL+12, c[6], c[5], c[8]); +#define PIXEL23_32 Interp3(pOut+BpL+BpL+12, c[5], c[8]); +#define PIXEL23_50 Interp5(pOut+BpL+BpL+12, c[6], c[5]); +#define PIXEL23_60 Interp6(pOut+BpL+BpL+12, c[5], c[6], c[8]); +#define PIXEL23_61 Interp6(pOut+BpL+BpL+12, c[5], c[6], c[9]); +#define PIXEL23_81 Interp8(pOut+BpL+BpL+12, c[5], c[6]); +#define PIXEL23_83 Interp8(pOut+BpL+BpL+12, c[6], c[8]); +#define PIXEL30_0 *((int*)(pOut+BpL+BpL+BpL)) = c[5]; +#define PIXEL30_11 Interp1(pOut+BpL+BpL+BpL, c[5], c[8]); +#define PIXEL30_12 Interp1(pOut+BpL+BpL+BpL, c[5], c[4]); +#define PIXEL30_20 Interp2(pOut+BpL+BpL+BpL, c[5], c[8], c[4]); +#define PIXEL30_50 Interp5(pOut+BpL+BpL+BpL, c[8], c[4]); +#define PIXEL30_80 Interp8(pOut+BpL+BpL+BpL, c[5], c[7]); +#define PIXEL30_81 Interp8(pOut+BpL+BpL+BpL, c[5], c[8]); +#define PIXEL30_82 Interp8(pOut+BpL+BpL+BpL, c[5], c[4]); +#define PIXEL31_0 *((int*)(pOut+BpL+BpL+BpL+4)) = c[5]; +#define PIXEL31_10 Interp1(pOut+BpL+BpL+BpL+4, c[5], c[7]); +#define PIXEL31_11 Interp1(pOut+BpL+BpL+BpL+4, c[5], c[8]); +#define PIXEL31_13 Interp1(pOut+BpL+BpL+BpL+4, c[8], c[5]); +#define PIXEL31_21 Interp2(pOut+BpL+BpL+BpL+4, c[8], c[5], c[4]); +#define PIXEL31_32 Interp3(pOut+BpL+BpL+BpL+4, c[5], c[4]); +#define PIXEL31_50 Interp5(pOut+BpL+BpL+BpL+4, c[8], c[5]); +#define PIXEL31_60 Interp6(pOut+BpL+BpL+BpL+4, c[5], c[8], c[4]); +#define PIXEL31_61 Interp6(pOut+BpL+BpL+BpL+4, c[5], c[8], c[7]); +#define PIXEL31_81 Interp8(pOut+BpL+BpL+BpL+4, c[5], c[8]); +#define PIXEL31_83 Interp8(pOut+BpL+BpL+BpL+4, c[8], c[4]); +#define PIXEL32_0 *((int*)(pOut+BpL+BpL+BpL+8)) = c[5]; +#define PIXEL32_10 Interp1(pOut+BpL+BpL+BpL+8, c[5], c[9]); +#define PIXEL32_12 Interp1(pOut+BpL+BpL+BpL+8, c[5], c[8]); +#define PIXEL32_14 Interp1(pOut+BpL+BpL+BpL+8, c[8], c[5]); +#define PIXEL32_21 Interp2(pOut+BpL+BpL+BpL+8, c[8], c[5], c[6]); +#define PIXEL32_31 Interp3(pOut+BpL+BpL+BpL+8, c[5], c[6]); +#define PIXEL32_50 Interp5(pOut+BpL+BpL+BpL+8, c[8], c[5]); +#define PIXEL32_60 Interp6(pOut+BpL+BpL+BpL+8, c[5], c[8], c[6]); +#define PIXEL32_61 Interp6(pOut+BpL+BpL+BpL+8, c[5], c[8], c[9]); +#define PIXEL32_82 Interp8(pOut+BpL+BpL+BpL+8, c[5], c[8]); +#define PIXEL32_83 Interp8(pOut+BpL+BpL+BpL+8, c[8], c[6]); +#define PIXEL33_0 *((int*)(pOut+BpL+BpL+BpL+12)) = c[5]; +#define PIXEL33_11 Interp1(pOut+BpL+BpL+BpL+12, c[5], c[6]); +#define PIXEL33_12 Interp1(pOut+BpL+BpL+BpL+12, c[5], c[8]); +#define PIXEL33_20 Interp2(pOut+BpL+BpL+BpL+12, c[5], c[8], c[6]); +#define PIXEL33_50 Interp5(pOut+BpL+BpL+BpL+12, c[8], c[6]); +#define PIXEL33_80 Interp8(pOut+BpL+BpL+BpL+12, c[5], c[9]); +#define PIXEL33_81 Interp8(pOut+BpL+BpL+BpL+12, c[5], c[6]); +#define PIXEL33_82 Interp8(pOut+BpL+BpL+BpL+12, c[5], c[8]); + + +#pragma warning(disable: 4035) + +int Diff(unsigned int w5, unsigned int w1) +{ + __asm + { + xor eax,eax + mov ebx,w5 + mov edx,w1 + cmp ebx,edx + je FIN + mov ecx,offset RGBtoYUV + movd mm1,[ecx + ebx*4] + movq mm5,mm1 + movd mm2,[ecx + edx*4] + psubusb mm1,mm2 + psubusb mm2,mm5 + por mm1,mm2 + psubusb mm1,treshold + movd eax,mm1 +FIN: + } +} +// returns result in eax register + +#pragma warning(default: 4035) + +void DLL hq4x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) +{ + int i, j, k; + int w[10]; + int c[10]; + + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ + + for (j = 0; j < Yres; j++) + { + for (i = 0; i < Xres; i++) + { + if (j == 0) + { + w[1] = 0; + w[2] = 0; + w[3] = 0; + } + else + { + if (i > 0) + w[1] = *(pIn - Xres - 1); + else + w[1] = 0; + + w[2] = *(pIn - Xres); + + if (i < Xres - 1) + w[3] = *(pIn - Xres + 1); + else + w[3] = 0; + } + + if (i > 0) + w[4] = *(pIn - 1); + else + w[4] = 0; + + w[5] = *(pIn); + + if (i < Xres - 1) + w[6] = *(pIn + 1); + else + w[6] = 0; + + if (j == Yres - 1) + { + w[7] = 0; + w[8] = 0; + w[9] = 0; + } + else + { + if (i > 0) + w[7] = *(pIn + Xres - 1); + else + w[7] = 0; + + w[8] = *(pIn + Xres); + + if (i < Xres-1) + w[9] = *(pIn + Xres + 1); + else + w[9] = 0; + } + + int pattern = 0; + + if ( Diff(w[5],w[1]) ) pattern |= 0x0001; + if ( Diff(w[5],w[2]) ) pattern |= 0x0002; + if ( Diff(w[5],w[3]) ) pattern |= 0x0004; + if ( Diff(w[5],w[4]) ) pattern |= 0x0008; + if ( Diff(w[5],w[6]) ) pattern |= 0x0010; + if ( Diff(w[5],w[7]) ) pattern |= 0x0020; + if ( Diff(w[5],w[8]) ) pattern |= 0x0040; + if ( Diff(w[5],w[9]) ) pattern |= 0x0080; + + for (k=1; k<=9; k++) + c[k] = LUT16to32[w[k]]; + + switch (pattern) + { + case 0: + case 1: + case 4: + case 32: + case 128: + case 5: + case 132: + case 160: + case 33: + case 129: + case 36: + case 133: + case 164: + case 161: + case 37: + case 165: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 2: + case 34: + case 130: + case 162: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 16: + case 17: + case 48: + case 49: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 64: + case 65: + case 68: + case 69: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 8: + case 12: + case 136: + case 140: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 3: + case 35: + case 131: + case 163: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 6: + case 38: + case 134: + case 166: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 20: + case 21: + case 52: + case 53: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 144: + case 145: + case 176: + case 177: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 192: + case 193: + case 196: + case 197: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 96: + case 97: + case 100: + case 101: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 40: + case 44: + case 168: + case 172: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 9: + case 13: + case 137: + case 141: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 18: + case 50: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL12_0 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 80: + case 81: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 72: + case 76: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_50 + PIXEL21_0 + PIXEL30_50 + PIXEL31_50 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 10: + case 138: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 66: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 24: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 7: + case 39: + case 135: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 148: + case 149: + case 180: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 224: + case 228: + case 225: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 41: + case 169: + case 45: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 22: + case 54: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 208: + case 209: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 104: + case 108: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 11: + case 139: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 19: + case 51: + { + if (Diff(w[2], w[6])) + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 146: + case 178: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + PIXEL23_32 + PIXEL33_82 + } + else + { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + break; + } + case 84: + case 85: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + if (Diff(w[6], w[8])) + { + PIXEL03_81 + PIXEL13_31 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL20_61 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; + } + case 112: + case 113: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; + } + case 200: + case 204: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + } + else + { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; + } + case 73: + case 77: + { + if (Diff(w[8], w[4])) + { + PIXEL00_82 + PIXEL10_32 + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 42: + case 170: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + PIXEL20_31 + PIXEL30_81 + } + else + { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 14: + case 142: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 67: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 70: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 28: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 152: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 194: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 98: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 56: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 25: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 26: + case 31: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL11_0 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 82: + case 214: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 88: + case 248: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 74: + case 107: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 27: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 86: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 216: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 106: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 30: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 210: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 120: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 75: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 29: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 198: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 184: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 99: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 57: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 71: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 156: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 226: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 60: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 195: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 102: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 153: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 58: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 83: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 92: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 202: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 78: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 154: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 114: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 89: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 90: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 55: + case 23: + { + if (Diff(w[2], w[6])) + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + } + else + { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 182: + case 150: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + PIXEL23_32 + PIXEL33_82 + } + else + { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + break; + } + case 213: + case 212: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + if (Diff(w[6], w[8])) + { + PIXEL03_81 + PIXEL13_31 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL20_61 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; + } + case 241: + case 240: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; + } + case 236: + case 232: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + } + else + { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; + } + case 109: + case 105: + { + if (Diff(w[8], w[4])) + { + PIXEL00_82 + PIXEL10_32 + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 171: + case 43: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + PIXEL11_0 + PIXEL20_31 + PIXEL30_81 + } + else + { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 143: + case 15: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + } + else + { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 124: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 203: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 62: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 211: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 118: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 217: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 110: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 155: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 188: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 185: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 61: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 157: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 103: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 227: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 230: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 199: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 220: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 158: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 234: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 242: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 59: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL11_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 121: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 87: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 79: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_32 + PIXEL03_82 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 122: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 94: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 218: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 91: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL11_0 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 229: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 167: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 173: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 181: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 186: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 115: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 93: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 206: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 205: + case 201: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 174: + case 46: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 179: + case 147: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 117: + case 116: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 189: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 231: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 126: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 219: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 125: + { + if (Diff(w[8], w[4])) + { + PIXEL00_82 + PIXEL10_32 + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 221: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + if (Diff(w[6], w[8])) + { + PIXEL03_81 + PIXEL13_31 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; + } + case 207: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + } + else + { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 238: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + } + else + { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; + } + case 190: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + PIXEL23_32 + PIXEL33_82 + } + else + { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_10 + PIXEL11_30 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + break; + } + case 187: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + PIXEL11_0 + PIXEL20_31 + PIXEL30_81 + } + else + { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 243: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; + } + case 119: + { + if (Diff(w[2], w[6])) + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + } + else + { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 237: + case 233: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; + } + case 175: + case 47: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 183: + case 151: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 245: + case 244: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 250: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 123: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 95: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL11_0 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 222: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 252: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 249: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + break; + } + case 235: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; + } + case 111: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 63: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 159: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 215: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 246: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 254: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 253: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 251: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + break; + } + case 239: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; + } + case 127: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 191: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 223: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 247: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 255: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + } + pIn++; // next source pixel (just increment since it's an int*) + pOut += 16; // skip 4 pixels (4 bytes * 4 pixels) + } + pOut += BpL; // skip next 3 rows + pOut += BpL; + pOut += BpL; + } + __asm emms +} + +void DLL InitLUTs() +{ + int i, j, k, r, g, b, Y, u, v; + +#if 0 // colorOutlines() after hqresize + for (i=0; i<65536; i++) + LUT16to32[i] = 0x00404040; + for (i=0; i<65536; i++) + LUT16to32[i+65536] = 0xFF000000 + ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3); +#else // colorOutlines() before hqresize + for (i=0; i<65536; i++) + LUT16to32[i] = ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3); + for (i=0; i<65536; i++) + LUT16to32[i+65536] = 0xFF000000 + LUT16to32[i]; +#endif + + for (i=0; i<65536; i++) + RGBtoYUV[i] = 0xFF000000; + + for (i=0; i<32; i++) + for (j=0; j<64; j++) + for (k=0; k<32; k++) + { + r = i << 3; + g = j << 2; + b = k << 3; + Y = (r + g + b) >> 2; + u = 128 + ((r - b) >> 2); + v = 128 + ((-r + 2*g -b)>>3); + RGBtoYUV[ 65536 + (i << 11) + (j << 5) + k ] = (Y<<16) + (u<<8) + v; + } +} + +/* +int DLL hq4x_32 ( CImage &ImageIn, CImage &ImageOut ) +{ + if ( ImageIn.Convert32To17() != 0 ) + { + printf( "ERROR: conversion to 17 bit failed\n" ); + return 1; + } + + if ( ImageOut.Init( ImageIn.m_Xres*4, ImageIn.m_Yres*4, 32 ) != 0 ) + { + printf( "ERROR: ImageOut.Init()\n" ); + return 1; + }; + + InitLUTs(); + hq4x_32( (int*)ImageIn.m_pBitmap, ImageOut.m_pBitmap, ImageIn.m_Xres, ImageIn.m_Yres, ImageOut.m_Xres*4 ); + + printf( "\nOK\n" ); + return 0; +} +*/ \ No newline at end of file diff --git a/src/gl/hqnx/hqnx.h b/src/gl/hqnx/hqnx.h new file mode 100644 index 000000000..ce0aeced4 --- /dev/null +++ b/src/gl/hqnx/hqnx.h @@ -0,0 +1,35 @@ +//hqnx filter library +//---------------------------------------------------------- +//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +//Copyright (C) 2009 Benjamin Berkels +// +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU Lesser General Public +//License as published by the Free Software Foundation; either +//version 2.1 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public +//License along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef __HQNX_H__ +#define __HQNX_H__ + +#pragma warning(disable:4799) + +#include "Image.h" + +void DLL hq2x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ); +void DLL hq3x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ); +void DLL hq4x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ); +int DLL hq4x_32 ( CImage &ImageIn, CImage &ImageOut ); + +void DLL InitLUTs(); + + +#endif //__HQNX_H__ \ No newline at end of file diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp new file mode 100644 index 000000000..9f13bee7d --- /dev/null +++ b/src/gl/models/gl_models.cpp @@ -0,0 +1,922 @@ +/* +** gl_models.cpp +** +** General model handling code +** +**--------------------------------------------------------------------------- +** Copyright 2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "w_wad.h" +#include "cmdlib.h" +#include "sc_man.h" +#include "m_crc32.h" +#include "c_console.h" +#include "g_game.h" +#include "doomstat.h" +#include "g_level.h" +#include "r_state.h" +#include "d_player.h" +//#include "resources/voxels.h" +//#include "gl/gl_intern.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/models/gl_models.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_geometric.h" +#include "gl/utility/gl_convert.h" +#include "gl/renderer/gl_renderstate.h" + +static inline float GetTimeFloat() +{ + return (float)I_MSTime() * (float)TICRATE / 1000.0f; +} + +CVAR(Bool, gl_interpolate_model_frames, true, CVAR_ARCHIVE) +CVAR(Bool, gl_light_models, true, CVAR_ARCHIVE) +EXTERN_CVAR(Int, gl_fogmode) +EXTERN_CVAR(Bool, gl_dynlight_shader) + +extern TDeletingArray Voxels; +extern TDeletingArray VoxelDefs; + + +class DeletingModelArray : public TArray +{ +public: + +#if 0 + ~DeletingModelArray() + { + for(unsigned i=0;i SpriteModelFrames; +static int * SpriteModelHash; +//TArray StateModelFrames; + +static void DeleteModelHash() +{ + if (SpriteModelHash != NULL) delete [] SpriteModelHash; + SpriteModelHash = NULL; +} + +//=========================================================================== +// +// FindGFXFile +// +//=========================================================================== + +static int FindGFXFile(FString & fn) +{ + int best = -1; + int dot = fn.LastIndexOf('.'); + int slash = fn.LastIndexOf('/'); + if (dot > slash) fn.Truncate(dot); + + static const char * extensions[] = { ".png", ".jpg", ".tga", ".pcx", NULL }; + + for (const char ** extp=extensions; *extp; extp++) + { + int lump = Wads.CheckNumForFullName(fn + *extp); + if (lump >= best) best = lump; + } + return best; +} + + +//=========================================================================== +// +// LoadSkin +// +//=========================================================================== + +FTexture * LoadSkin(const char * path, const char * fn) +{ + FString buffer; + + buffer.Format("%s%s", path, fn); + + int texlump = FindGFXFile(buffer); + if (texlump>=0) + { + FTextureID texno = TexMan.FindTextureByLumpNum(texlump); + if (!texno.isValid()) + { + FTexture *tex = FTexture::CreateTexture("", texlump, FTexture::TEX_Override); + TexMan.AddTexture(tex); + return tex; + } + return TexMan[texno]; + } + else + { + return NULL; + } +} + +//=========================================================================== +// +// ModelFrameHash +// +//=========================================================================== + +static int ModelFrameHash(FSpriteModelFrame * smf) +{ + const DWORD *table = GetCRCTable (); + DWORD hash = 0xffffffff; + + const char * s = (const char *)(&smf->type); // this uses type, sprite and frame for hashing + const char * se= (const char *)(&smf->hashnext); + + for (; smFileName.CompareNoCase(fullname)) return Models[i]; + } + + int len = Wads.LumpLength(lump); + FMemLump lumpd = Wads.ReadLump(lump); + char * buffer = (char*)lumpd.GetMem(); + + if (!memcmp(buffer, "DMDM", 4)) + { + model = new FDMDModel; + } + else if (!memcmp(buffer, "IDP2", 4)) + { + model = new FMD2Model; + } + else if (!memcmp(buffer, "IDP3", 4)) + { + model = new FMD3Model; + } + + if (model != NULL) + { + if (!model->Load(path, lump, buffer, len)) + { + delete model; + return NULL; + } + } + else + { + // try loading as a voxel + FVoxel *voxel = R_LoadKVX(lump); + if (voxel != NULL) + { + model = new FVoxelModel(voxel, true); + } + else + { + Printf("LoadModel: Unknown model format in '%s'\n", fullname.GetChars()); + return NULL; + } + } + + model->mFileName = fullname; + Models.Push(model); + return model; +} + +//=========================================================================== +// +// gl_InitModels +// +//=========================================================================== + +void gl_InitModels() +{ + int Lump, lastLump; + FString path; + int index; + int i; + + FSpriteModelFrame smf; + + lastLump = 0; + + for(unsigned i=0;iVoxelIndex = Models.Push(md); + } + // now create GL model frames for the voxeldefs + for (unsigned i = 0; i < VoxelDefs.Size(); i++) + { + FVoxelModel *md = (FVoxelModel*)Models[VoxelDefs[i]->Voxel->VoxelIndex]; + memset(&smf, 0, sizeof(smf)); + smf.models[0] = md; + smf.skins[0] = md->GetPaletteTexture(); + smf.xscale = smf.yscale = smf.zscale = FIXED2FLOAT(VoxelDefs[i]->Scale); + smf.angleoffset = VoxelDefs[i]->AngleOffset; + if (VoxelDefs[i]->PlacedSpin != 0) + { + smf.yrotate = 1.f; + smf.rotationSpeed = VoxelDefs[i]->PlacedSpin / 55.55f; + smf.flags |= MDL_ROTATING; + } + VoxelDefs[i]->VoxeldefIndex = SpriteModelFrames.Push(smf); + if (VoxelDefs[i]->PlacedSpin != VoxelDefs[i]->DroppedSpin) + { + if (VoxelDefs[i]->DroppedSpin != 0) + { + smf.yrotate = 1.f; + smf.rotationSpeed = VoxelDefs[i]->DroppedSpin / 55.55f; + smf.flags |= MDL_ROTATING; + } + else + { + smf.yrotate = 0; + smf.rotationSpeed = 0; + smf.flags &= ~MDL_ROTATING; + } + SpriteModelFrames.Push(smf); + } + } + + memset(&smf, 0, sizeof(smf)); + while ((Lump = Wads.FindLump("MODELDEF", &lastLump)) != -1) + { + FScanner sc(Lump); + while (sc.GetString()) + { + if (sc.Compare("model")) + { + sc.MustGetString(); + memset(&smf, 0, sizeof(smf)); + smf.xscale=smf.yscale=smf.zscale=1.f; + + smf.type = PClass::FindClass(sc.String); + if (!smf.type || smf.type->Defaults == NULL) + { + sc.ScriptError("MODELDEF: Unknown actor type '%s'\n", sc.String); + } + GetDefaultByType(smf.type)->hasmodel=true; + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + sc.MustGetString(); + if (sc.Compare("path")) + { + sc.MustGetString(); + FixPathSeperator(sc.String); + path = sc.String; + if (path[(int)path.Len()-1]!='/') path+='/'; + } + else if (sc.Compare("model")) + { + sc.MustGetNumber(); + index=sc.Number; + if (index<0 || index>=MAX_MODELS_PER_FRAME) + { + sc.ScriptError("Too many models in %s", smf.type->TypeName.GetChars()); + } + sc.MustGetString(); + FixPathSeperator(sc.String); + smf.models[index] = FindModel(path.GetChars(), sc.String); + if (!smf.models[index]) + { + Printf("%s: model not found in %s\n", sc.String, path.GetChars()); + } + } + else if (sc.Compare("scale")) + { + sc.MustGetFloat(); + smf.xscale=sc.Float; + sc.MustGetFloat(); + smf.yscale=sc.Float; + sc.MustGetFloat(); + smf.zscale=sc.Float; + } + // [BB] Added zoffset reading. + // Now it must be considered deprecated. + else if (sc.Compare("zoffset")) + { + sc.MustGetFloat(); + smf.zoffset=sc.Float; + } + // Offset reading. + else if (sc.Compare("offset")) + { + sc.MustGetFloat(); + smf.xoffset = sc.Float; + sc.MustGetFloat(); + smf.yoffset = sc.Float; + sc.MustGetFloat(); + smf.zoffset = sc.Float; + } + // angleoffset, pitchoffset and rolloffset reading. + else if (sc.Compare("angleoffset")) + { + sc.MustGetFloat(); + smf.angleoffset = FLOAT_TO_ANGLE(sc.Float); + } + else if (sc.Compare("pitchoffset")) + { + sc.MustGetFloat(); + smf.pitchoffset = sc.Float; + } + else if (sc.Compare("rolloffset")) + { + sc.MustGetFloat(); + smf.rolloffset = sc.Float; + } + // [BB] Added model flags reading. + else if (sc.Compare("ignoretranslation")) + { + smf.flags |= MDL_IGNORETRANSLATION; + } + else if (sc.Compare("pitchfrommomentum")) + { + smf.flags |= MDL_PITCHFROMMOMENTUM; + } + else if (sc.Compare("inheritactorpitch")) + { + smf.flags |= MDL_INHERITACTORPITCH; + } + else if (sc.Compare("inheritactorroll")) + { + smf.flags |= MDL_INHERITACTORROLL; + } + else if (sc.Compare("rotating")) + { + smf.flags |= MDL_ROTATING; + smf.xrotate = 0.; + smf.yrotate = 1.; + smf.zrotate = 0.; + smf.rotationCenterX = 0.; + smf.rotationCenterY = 0.; + smf.rotationCenterZ = 0.; + smf.rotationSpeed = 1.; + } + else if (sc.Compare("rotation-speed")) + { + sc.MustGetFloat(); + smf.rotationSpeed = sc.Float; + } + else if (sc.Compare("rotation-vector")) + { + sc.MustGetFloat(); + smf.xrotate = sc.Float; + sc.MustGetFloat(); + smf.yrotate = sc.Float; + sc.MustGetFloat(); + smf.zrotate = sc.Float; + } + else if (sc.Compare("rotation-center")) + { + sc.MustGetFloat(); + smf.rotationCenterX = sc.Float; + sc.MustGetFloat(); + smf.rotationCenterY = sc.Float; + sc.MustGetFloat(); + smf.rotationCenterZ = sc.Float; + } + else if (sc.Compare("interpolatedoubledframes")) + { + smf.flags |= MDL_INTERPOLATEDOUBLEDFRAMES; + } + else if (sc.Compare("nointerpolation")) + { + smf.flags |= MDL_NOINTERPOLATION; + } + else if (sc.Compare("skin")) + { + sc.MustGetNumber(); + index=sc.Number; + if (index<0 || index>=MAX_MODELS_PER_FRAME) + { + sc.ScriptError("Too many models in %s", smf.type->TypeName.GetChars()); + } + sc.MustGetString(); + FixPathSeperator(sc.String); + if (sc.Compare("")) + { + smf.skins[index]=NULL; + } + else + { + smf.skins[index]=LoadSkin(path.GetChars(), sc.String); + if (smf.skins[index] == NULL) + { + Printf("Skin '%s' not found in '%s'\n", + sc.String, smf.type->TypeName.GetChars()); + } + } + } + else if (sc.Compare("frameindex") || sc.Compare("frame")) + { + bool isframe=!!sc.Compare("frame"); + + sc.MustGetString(); + smf.sprite = -1; + for (i = 0; i < (int)sprites.Size (); ++i) + { + if (strncmp (sprites[i].name, sc.String, 4) == 0) + { + if (sprites[i].numframes==0) + { + //sc.ScriptError("Sprite %s has no frames", sc.String); + } + smf.sprite = i; + break; + } + } + if (smf.sprite==-1) + { + sc.ScriptError("Unknown sprite %s in model definition for %s", sc.String, smf.type->TypeName.GetChars()); + } + + sc.MustGetString(); + FString framechars = sc.String; + + sc.MustGetNumber(); + index=sc.Number; + if (index<0 || index>=MAX_MODELS_PER_FRAME) + { + sc.ScriptError("Too many models in %s", smf.type->TypeName.GetChars()); + } + if (isframe) + { + sc.MustGetString(); + if (smf.models[index]!=NULL) + { + smf.modelframes[index] = smf.models[index]->FindFrame(sc.String); + if (smf.modelframes[index]==-1) sc.ScriptError("Unknown frame '%s' in %s", sc.String, smf.type->TypeName.GetChars()); + } + else smf.modelframes[index] = -1; + } + else + { + sc.MustGetNumber(); + smf.modelframes[index] = sc.Number; + } + + for(i=0; framechars[i]>0; i++) + { + char map[29]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + int c = toupper(framechars[i])-'A'; + + if (c<0 || c>=29) + { + sc.ScriptError("Invalid frame character %c found", c+'A'); + } + if (map[c]) continue; + smf.frame=c; + SpriteModelFrames.Push(smf); + map[c]=1; + } + } + else + { + sc.ScriptMessage("Unrecognized string \"%s\"", sc.String); + } + } + } + } + } + + // create a hash table for quick access + SpriteModelHash = new int[SpriteModelFrames.Size ()]; + atterm(DeleteModelHash); + memset(SpriteModelHash, 0xff, SpriteModelFrames.Size () * sizeof(int)); + + for (i = 0; i < (int)SpriteModelFrames.Size (); i++) + { + int j = ModelFrameHash(&SpriteModelFrames[i]) % SpriteModelFrames.Size (); + + SpriteModelFrames[i].hashnext = SpriteModelHash[j]; + SpriteModelHash[j]=i; + } +} + + +//=========================================================================== +// +// gl_FindModelFrame +// +//=========================================================================== +EXTERN_CVAR (Bool, r_drawvoxels) + +FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped) +{ + if (GetDefaultByType(ti)->hasmodel) + { + FSpriteModelFrame smf; + + memset(&smf, 0, sizeof(smf)); + smf.type=ti; + smf.sprite=sprite; + smf.frame=frame; + + int hash = SpriteModelHash[ModelFrameHash(&smf) % SpriteModelFrames.Size()]; + + while (hash>=0) + { + FSpriteModelFrame * smff = &SpriteModelFrames[hash]; + if (smff->type==ti && smff->sprite==sprite && smff->frame==frame) return smff; + hash=smff->hashnext; + } + } + + // Check for voxel replacements + if (r_drawvoxels) + { + spritedef_t *sprdef = &sprites[sprite]; + if (frame < sprdef->numframes) + { + spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + frame]; + if (sprframe->Voxel != NULL) + { + int index = sprframe->Voxel->VoxeldefIndex; + if (dropped && sprframe->Voxel->DroppedSpin !=sprframe->Voxel->PlacedSpin) index++; + return &SpriteModelFrames[index]; + } + } + } + return NULL; +} + + +//=========================================================================== +// +// gl_RenderModel +// +//=========================================================================== + +void gl_RenderFrameModels( const FSpriteModelFrame *smf, + const FState *curState, + const int curTics, + const PClass *ti, + int cm, + Matrix3x4 *normaltransform, + int translation) +{ + // [BB] Frame interpolation: Find the FSpriteModelFrame smfNext which follows after smf in the animation + // and the scalar value inter ( element of [0,1) ), both necessary to determine the interpolated frame. + FSpriteModelFrame * smfNext = NULL; + double inter = 0.; + if( gl_interpolate_model_frames && !(smf->flags & MDL_NOINTERPOLATION) ) + { + FState *nextState = curState->GetNextState( ); + if( curState != nextState && nextState ) + { + // [BB] To interpolate at more than 35 fps we take tic fractions into account. + float ticFraction = 0.; + // [BB] In case the tic counter is frozen we have to leave ticFraction at zero. + if ( ConsoleState == c_up && menuactive != MENU_On && !(level.flags2 & LEVEL2_FROZEN) ) + { + float time = GetTimeFloat(); + ticFraction = (time - static_cast(time)); + } + inter = static_cast(curState->Tics - curTics - ticFraction)/static_cast(curState->Tics); + + // [BB] For some actors (e.g. ZPoisonShroom) spr->actor->tics can be bigger than curState->Tics. + // In this case inter is negative and we need to set it to zero. + if ( inter < 0. ) + inter = 0.; + else + { + // [BB] Workaround for actors that use the same frame twice in a row. + // Most of the standard Doom monsters do this in their see state. + if ( (smf->flags & MDL_INTERPOLATEDOUBLEDFRAMES) ) + { + const FState *prevState = curState - 1; + if ( (curState->sprite == prevState->sprite) && ( curState->Frame == prevState->Frame) ) + { + inter /= 2.; + inter += 0.5; + } + if ( (curState->sprite == nextState->sprite) && ( curState->Frame == nextState->Frame) ) + { + inter /= 2.; + nextState = nextState->GetNextState( ); + } + } + if ( inter != 0.0 ) + smfNext = gl_FindModelFrame(ti, nextState->sprite, nextState->Frame, false); + } + } + } + + for(int i=0; imodels[i]; + + if (mdl!=NULL) + { + if ( smfNext && smf->modelframes[i] != smfNext->modelframes[i] ) + mdl->RenderFrameInterpolated(smf->skins[i], smf->modelframes[i], smfNext->modelframes[i], inter, cm, translation); + else + mdl->RenderFrame(smf->skins[i], smf->modelframes[i], cm, translation); + } + } +} + +void gl_RenderModel(GLSprite * spr, int cm) +{ + FSpriteModelFrame * smf = spr->modelframe; + + + // Setup transformation. + gl.DepthFunc(GL_LEQUAL); + gl_RenderState.SetTextureMode(TM_MODULATE); + gl_RenderState.EnableTexture(true); + // [BB] In case the model should be rendered translucent, do back face culling. + // This solves a few of the problems caused by the lack of depth sorting. + // TO-DO: Implement proper depth sorting. + if (!( spr->actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) + { + gl.Enable(GL_CULL_FACE); + glFrontFace(GL_CW); + } + + int translation = 0; + if ( !(smf->flags & MDL_IGNORETRANSLATION) ) + translation = spr->actor->Translation; + + + // y scale for a sprite means height, i.e. z in the world! + float scaleFactorX = FIXED2FLOAT(spr->actor->scaleX) * smf->xscale; + float scaleFactorY = FIXED2FLOAT(spr->actor->scaleX) * smf->yscale; + float scaleFactorZ = FIXED2FLOAT(spr->actor->scaleY) * smf->zscale; + float pitch = 0; + float roll = 0; + float rotateOffset = 0; + float angle = ANGLE_TO_FLOAT(spr->actor->angle); + + // [BB] Workaround for the missing pitch information. + if ( (smf->flags & MDL_PITCHFROMMOMENTUM) ) + { + const double x = static_cast(spr->actor->velx); + const double y = static_cast(spr->actor->vely); + const double z = static_cast(spr->actor->velz); + + // [BB] Calculate the pitch using spherical coordinates. + if(z || x || y) pitch = float(atan( z/sqrt(x*x+y*y) ) / M_PI * 180); + + // Correcting pitch if model is moving backwards + if(x || y) + { + if((x * cos(angle * M_PI / 180) + y * sin(angle * M_PI / 180)) / sqrt(x * x + y * y) < 0) pitch *= -1; + } + else pitch = abs(pitch); + } + + if( smf->flags & MDL_ROTATING ) + { + const float time = smf->rotationSpeed*GetTimeFloat()/200.f; + rotateOffset = float((time - xs_FloorToInt(time)) *360.f ); + } + + // Added MDL_INHERITACTORPITCH and MDL_INHERITACTORROLL flags processing. + // If both flags MDL_INHERITACTORPITCH and MDL_PITCHFROMMOMENTUM are set, the pitch sums up the actor pitch and the momentum vector pitch. + // This is rather crappy way to transfer fixet_t type into angle in degrees, but its works! + if(smf->flags & MDL_INHERITACTORPITCH) pitch += float(static_cast(spr->actor->pitch >> 16) / (1 << 13) * 45 + static_cast(spr->actor->pitch & 0x0000FFFF) / (1 << 29) * 45); + if(smf->flags & MDL_INHERITACTORROLL) roll += float(static_cast(spr->actor->roll >> 16) / (1 << 13) * 45 + static_cast(spr->actor->roll & 0x0000FFFF) / (1 << 29) * 45); + + if (gl.shadermodel < 4) + { + gl.MatrixMode(GL_MODELVIEW); + gl.PushMatrix(); + } + else + { + gl.ActiveTexture(GL_TEXTURE7); // Hijack the otherwise unused seventh texture matrix for the model to world transformation. + gl.MatrixMode(GL_TEXTURE); + gl.LoadIdentity(); + } + + // Model space => World space + gl.Translatef(spr->x, spr->z, spr->y ); + + // Applying model transformations: + // 1) Applying actor angle, pitch and roll to the model + gl.Rotatef(-angle, 0, 1, 0); + gl.Rotatef(pitch, 0, 0, 1); + gl.Rotatef(-roll, 1, 0, 0); + + // 2) Applying Doomsday like rotation of the weapon pickup models + // The rotation angle is based on the elapsed time. + + if( smf->flags & MDL_ROTATING ) + { + gl.Translatef(smf->rotationCenterX, smf->rotationCenterY, smf->rotationCenterZ); + gl.Rotatef(rotateOffset, smf->xrotate, smf->yrotate, smf->zrotate); + gl.Translatef(-smf->rotationCenterX, -smf->rotationCenterY, -smf->rotationCenterZ); + } + + // 3) Scaling model. + gl.Scalef(scaleFactorX, scaleFactorZ, scaleFactorY); + + // 4) Aplying model offsets (model offsets do not depend on model scalings). + gl.Translatef(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); + + // 5) Applying model rotations. + gl.Rotatef(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); + gl.Rotatef(smf->pitchoffset, 0, 0, 1); + gl.Rotatef(-smf->rolloffset, 1, 0, 0); + + if (gl.shadermodel >= 4) gl.ActiveTexture(GL_TEXTURE0); + +#if 0 + if (gl_light_models) + { + // The normal transform matrix only contains the inverse rotations and scalings but not the translations + NormalTransform.MakeIdentity(); + + NormalTransform.Scale(1.f/scaleFactorX, 1.f/scaleFactorZ, 1.f/scaleFactorY); + if( smf->flags & MDL_ROTATING ) NormalTransform.Rotate(smf->xrotate, smf->yrotate, smf->zrotate, -rotateOffset); + if (pitch != 0) NormalTransform.Rotate(0,0,1,-pitch); + if (angle != 0) NormalTransform.Rotate(0,1,0, angle); + + gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), cm, &ModelToWorld, &NormalTransform, translation ); + } +#endif + + gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), cm, NULL, translation ); + + if (gl.shadermodel < 4) + { + gl.MatrixMode(GL_MODELVIEW); + gl.PopMatrix(); + } + else + { + gl.ActiveTexture(GL_TEXTURE7); + gl.MatrixMode(GL_TEXTURE); + gl.LoadIdentity(); + gl.ActiveTexture(GL_TEXTURE0); + gl.MatrixMode(GL_MODELVIEW); + } + + gl.DepthFunc(GL_LESS); + if (!( spr->actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) + gl.Disable(GL_CULL_FACE); +} + + +//=========================================================================== +// +// gl_RenderHUDModel +// +//=========================================================================== + +void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy, int cm) +{ + AActor * playermo=players[consoleplayer].camera; + FSpriteModelFrame *smf = gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->state->sprite, psp->state->GetFrame(), false); + + // [BB] No model found for this sprite, so we can't render anything. + if ( smf == NULL ) + return; + + // [BB] The model has to be drawn independtly from the position of the player, + // so we have to reset the GL_MODELVIEW matrix. + gl.MatrixMode(GL_MODELVIEW); + gl.PushMatrix(); + gl.LoadIdentity(); + gl.DepthFunc(GL_LEQUAL); + + // [BB] In case the model should be rendered translucent, do back face culling. + // This solves a few of the problems caused by the lack of depth sorting. + // TO-DO: Implement proper depth sorting. + if (!( playermo->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) + { + gl.Enable(GL_CULL_FACE); + glFrontFace(GL_CCW); + } + + // Scaling model (y scale for a sprite means height, i.e. z in the world!). + gl.Scalef(smf->xscale, smf->zscale, smf->yscale); + + // Aplying model offsets (model offsets do not depend on model scalings). + gl.Translatef(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); + + // [BB] Weapon bob, very similar to the normal Doom weapon bob. + gl.Rotatef(FIXED2FLOAT(ofsx)/4, 0, 1, 0); + gl.Rotatef(-FIXED2FLOAT(ofsy-WEAPONTOP)/4, 1, 0, 0); + + // [BB] For some reason the jDoom models need to be rotated. + gl.Rotatef(90., 0, 1, 0); + + // Applying angleoffset, pitchoffset, rolloffset. + gl.Rotatef(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); + gl.Rotatef(smf->pitchoffset, 0, 0, 1); + gl.Rotatef(-smf->rolloffset, 1, 0, 0); + + gl_RenderFrameModels( smf, psp->state, psp->tics, playermo->player->ReadyWeapon->GetClass(), cm, NULL, 0 ); + + gl.MatrixMode(GL_MODELVIEW); + gl.PopMatrix(); + gl.DepthFunc(GL_LESS); + if (!( playermo->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) + gl.Disable(GL_CULL_FACE); +} + +//=========================================================================== +// +// gl_IsHUDModelForPlayerAvailable +// +//=========================================================================== + +bool gl_IsHUDModelForPlayerAvailable (player_t * player) +{ + if ( (player == NULL) || (player->ReadyWeapon == NULL) || (player->psprites[0].state == NULL) ) + return false; + + FState* state = player->psprites[0].state; + FSpriteModelFrame *smf = gl_FindModelFrame(player->ReadyWeapon->GetClass(), state->sprite, state->GetFrame(), false); + return ( smf != NULL ); +} + +//=========================================================================== +// +// gl_CleanModelData +// +//=========================================================================== + +void gl_CleanModelData() +{ + for (unsigned i=0;iCleanGLData(); + } +} diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h new file mode 100644 index 000000000..c3d564f9d --- /dev/null +++ b/src/gl/models/gl_models.h @@ -0,0 +1,365 @@ +#ifndef __GL_MODELS_H_ +#define __GL_MODELS_H_ + +#include "gl/utility/gl_geometric.h" +#include "p_pspr.h" +#include "r_data/voxels.h" + +#define MAX_LODS 4 + +enum { VX, VZ, VY }; + +static const float rModelAspectMod = 1 / 1.2f; //.833334f; + +#define MD2_MAGIC 0x32504449 +#define DMD_MAGIC 0x4D444D44 +#define MD3_MAGIC 0x33504449 +#define NUMVERTEXNORMALS 162 + +FTexture * LoadSkin(const char * path, const char * fn); + + +class FModel +{ +public: + FModel() { } + virtual ~FModel() { } + + virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0; + virtual int FindFrame(const char * name) = 0; + virtual void RenderFrame(FTexture * skin, int frame, int cm, int translation=0) = 0; + // [BB] Added RenderFrameInterpolated + virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int cm, int translation=0) = 0; + virtual void MakeGLData() {} + virtual void CleanGLData() {} + + + + FString mFileName; +}; + +class FDMDModel : public FModel +{ +protected: + + struct FTriangle + { + short vertexIndices[3]; + short textureIndices[3]; + }; + + + struct DMDHeader + { + int magic; + int version; + int flags; + }; + + struct FModelVertex + { + float xyz[3]; + }; + + struct FTexCoord + { + short s, t; + }; + + struct FGLCommandVertex + { + float s, t; + int index; + }; + + struct DMDInfo + { + int skinWidth; + int skinHeight; + int frameSize; + int numSkins; + int numVertices; + int numTexCoords; + int numFrames; + int numLODs; + int offsetSkins; + int offsetTexCoords; + int offsetFrames; + int offsetLODs; + int offsetEnd; + }; + + struct ModelFrame + { + char name[16]; + FModelVertex *vertices; + FModelVertex *normals; + + ModelFrame() + { + vertices = normals = NULL; + } + + ~ModelFrame() + { + if (vertices) delete [] vertices; + if (normals) delete [] normals; + } + }; + + struct DMDLoDInfo + { + int numTriangles; + int numGlCommands; + int offsetTriangles; + int offsetGlCommands; + }; + + struct DMDLoD + { + FTriangle * triangles; + int * glCommands; + }; + + + bool loaded; + DMDHeader header; + DMDInfo info; + FTexture ** skins; + FTexCoord * texCoords; + + ModelFrame * frames; + DMDLoDInfo lodInfo[MAX_LODS]; + DMDLoD lods[MAX_LODS]; + char *vertexUsage; // Bitfield for each vertex. + bool allowTexComp; // Allow texture compression with this. + + static void RenderGLCommands(void *glCommands, unsigned int numVertices,FModelVertex * vertices); + +public: + FDMDModel() + { + loaded = false; + frames = NULL; + skins = NULL; + lods[0].glCommands = NULL; + info.numLODs = 0; + } + virtual ~FDMDModel(); + + virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); + virtual int FindFrame(const char * name); + virtual void RenderFrame(FTexture * skin, int frame, int cm, int translation=0); + virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int cm, int translation=0); + +}; + +// This uses the same internal representation as DMD +class FMD2Model : public FDMDModel +{ +public: + FMD2Model() {} + virtual ~FMD2Model(); + + virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); + +}; + + +class FMD3Model : public FModel +{ + struct MD3Tag + { + // Currently I have no use for this + }; + + struct MD3TexCoord + { + float s,t; + }; + + struct MD3Vertex + { + float x,y,z; + float nx,ny,nz; + }; + + struct MD3Triangle + { + int VertIndex[3]; + }; + + struct MD3Surface + { + int numVertices; + int numTriangles; + int numSkins; + + FTexture ** skins; + MD3Triangle * tris; + MD3TexCoord * texcoords; + MD3Vertex * vertices; + + MD3Surface() + { + tris=NULL; + vertices=NULL; + texcoords=NULL; + } + + ~MD3Surface() + { + if (tris) delete [] tris; + if (vertices) delete [] vertices; + if (texcoords) delete [] texcoords; + for (int i=0;i FVoxelMap; + + +class FVoxelModel : public FModel +{ +protected: + FVoxel *mVoxel; + bool mOwningVoxel; // if created through MODELDEF deleting this object must also delete the voxel object + TArray mVertices; + TArray mIndices; + FVoxelVertexBuffer *mVBO; + FTexture *mPalette; + + void MakeSlabPolys(int x, int y, kvxslab_t *voxptr, FVoxelMap &check); + void AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3, int x4, int y4, int z4, BYTE color, FVoxelMap &check); + void AddVertex(FVoxelVertex &vert, FVoxelMap &check); + +public: + FVoxelModel(FVoxel *voxel, bool owned); + ~FVoxelModel(); + bool Load(const char * fn, int lumpnum, const char * buffer, int length); + void Initialize(); + void MakeGLData(); + void CleanGLData(); + virtual int FindFrame(const char * name); + virtual void RenderFrame(FTexture * skin, int frame, int cm, int translation=0); + virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int cm, int translation=0); + FTexture *GetPaletteTexture() const { return mPalette; } +}; + + + +#define MAX_MODELS_PER_FRAME 4 + +// +// [BB] Model rendering flags. +// +enum +{ + // [BB] Color translations for the model skin are ignored. This is + // useful if the skin texture is not using the game palette. + MDL_IGNORETRANSLATION = 1, + MDL_PITCHFROMMOMENTUM = 2, + MDL_ROTATING = 4, + MDL_INTERPOLATEDOUBLEDFRAMES = 8, + MDL_NOINTERPOLATION = 16, + MDL_INHERITACTORPITCH = 32, + MDL_INHERITACTORROLL = 64, // useless for now +}; + +struct FSpriteModelFrame +{ + FModel * models[MAX_MODELS_PER_FRAME]; + FTexture * skins[MAX_MODELS_PER_FRAME]; + int modelframes[MAX_MODELS_PER_FRAME]; + float xscale, yscale, zscale; + // [BB] Added zoffset, rotation parameters and flags. + // Added xoffset, yoffset + float xoffset, yoffset, zoffset; + float xrotate, yrotate, zrotate; + float rotationCenterX, rotationCenterY, rotationCenterZ; + float rotationSpeed; + unsigned int flags; + const PClass * type; + short sprite; + short frame; + FState * state; // for later! + int hashnext; + angle_t angleoffset; + // added pithoffset, rolloffset. + float pitchoffset, rolloffset; // I don't want to bother with type transformations, so I made this variables float. +}; + +class GLSprite; + +void gl_InitModels(); +FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped); + +void gl_RenderModel(GLSprite * spr, int cm); +// [BB] HUD weapon model rendering functions. +void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy, int cm); +bool gl_IsHUDModelForPlayerAvailable (player_t * player); +void gl_CleanModelData(); + +#endif diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp new file mode 100644 index 000000000..95a344c6e --- /dev/null +++ b/src/gl/models/gl_models_md2.cpp @@ -0,0 +1,509 @@ +/* +** gl_models.cpp +** +** MD2/DMD model format code +** +**--------------------------------------------------------------------------- +** Copyright 2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "w_wad.h" +#include "cmdlib.h" +#include "sc_man.h" +#include "m_crc32.h" + +#include "gl/renderer/gl_renderstate.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/models/gl_models.h" +#include "gl/textures/gl_material.h" +#include "gl/shaders/gl_shader.h" + +static float avertexnormals[NUMVERTEXNORMALS][3] = { +#include "tab_anorms.h" +}; + +//=========================================================================== +// +// UnpackVector +// Packed: pppppppy yyyyyyyy. Yaw is on the XY plane. +// +//=========================================================================== + +static void UnpackVector(unsigned short packed, float vec[3]) +{ + float yaw = (packed & 511) / 512.0f * 2 * PI; + float pitch = ((packed >> 9) / 127.0f - 0.5f) * PI; + float cosp = (float) cos(pitch); + + vec[VX] = (float) cos(yaw) * cosp; + vec[VY] = (float) sin(yaw) * cosp; + vec[VZ] = (float) sin(pitch); +} + + +//=========================================================================== +// +// FDMDModel::Load +// +//=========================================================================== + +bool FDMDModel::Load(const char * path, int, const char * buffer, int length) +{ + struct dmd_chunk_t + { + int type; + int length; // Next chunk follows... + }; + +#pragma pack(1) + struct dmd_packedVertex_t + { + byte vertex[3]; + unsigned short normal; // Yaw and pitch. + }; + + struct dmd_packedFrame_t + { + float scale[3]; + float translate[3]; + char name[16]; + dmd_packedVertex_t vertices[1]; + } ; +#pragma pack() + + // Chunk types. + enum + { + DMC_END, // Must be the last chunk. + DMC_INFO // Required; will be expected to exist. + }; + + dmd_chunk_t * chunk = (dmd_chunk_t*)(buffer+12); + char *temp; + ModelFrame *frame; + int i, k, c; + FTriangle *triangles[MAX_LODS]; + int axis[3] = { VX, VY, VZ }; + + int fileoffset=12+sizeof(dmd_chunk_t); + + chunk->type = LittleLong(chunk->type); + while(chunk->type != DMC_END) + { + switch (chunk->type) + { + case DMC_INFO: // Standard DMD information chunk. + memcpy(&info, buffer + fileoffset, LittleLong(chunk->length)); + info.skinWidth = LittleLong(info.skinWidth); + info.skinHeight = LittleLong(info.skinHeight); + info.frameSize = LittleLong(info.frameSize); + info.numSkins = LittleLong(info.numSkins); + info.numVertices = LittleLong(info.numVertices); + info.numTexCoords = LittleLong(info.numTexCoords); + info.numFrames = LittleLong(info.numFrames); + info.numLODs = LittleLong(info.numLODs); + info.offsetSkins = LittleLong(info.offsetSkins); + info.offsetTexCoords = LittleLong(info.offsetTexCoords); + info.offsetFrames = LittleLong(info.offsetFrames); + info.offsetLODs = LittleLong(info.offsetLODs); + info.offsetEnd = LittleLong(info.offsetEnd); + fileoffset += chunk->length; + break; + + default: + // Just skip all unknown chunks. + fileoffset += chunk->length; + break; + } + // Read the next chunk header. + chunk = (dmd_chunk_t*)(buffer+fileoffset); + chunk->type = LittleLong(chunk->type); + fileoffset += sizeof(dmd_chunk_t); + } + + // Allocate and load in the data. + skins = new FTexture *[info.numSkins]; + + for(i = 0; i < info.numSkins; i++) + { + skins[i] = LoadSkin(path, buffer + info.offsetSkins + i*64); + } + + + temp = (char*)buffer + info.offsetFrames; + frames = new ModelFrame[info.numFrames]; + + for(i = 0, frame = frames; i < info.numFrames; i++, frame++) + { + dmd_packedFrame_t *pfr = (dmd_packedFrame_t *) (temp + info.frameSize * i); + dmd_packedVertex_t *pVtx; + + memcpy(frame->name, pfr->name, sizeof(pfr->name)); + frame->vertices = new FModelVertex[info.numVertices]; + frame->normals = new FModelVertex[info.numVertices]; + + // Translate each vertex. + for(k = 0, pVtx = pfr->vertices; k < info.numVertices; k++, pVtx++) + { + UnpackVector(USHORT(pVtx->normal), frame->normals[k].xyz); + for(c = 0; c < 3; c++) + { + frame->vertices[k].xyz[axis[c]] = + (pVtx->vertex[c] * FLOAT(pfr->scale[c]) + FLOAT(pfr->translate[c])); + } + // Aspect undo. + frame->vertices[k].xyz[VZ] *= rModelAspectMod; + } + } + + memcpy(lodInfo, buffer+info.offsetLODs, info.numLODs * sizeof(DMDLoDInfo)); + for(i = 0; i < info.numLODs; i++) + { + lodInfo[i].numTriangles = LittleLong(lodInfo[i].numTriangles); + lodInfo[i].numGlCommands = LittleLong(lodInfo[i].numGlCommands); + lodInfo[i].offsetTriangles = LittleLong(lodInfo[i].offsetTriangles); + lodInfo[i].offsetGlCommands = LittleLong(lodInfo[i].offsetGlCommands); + + triangles[i] = (FTriangle*)(buffer + lodInfo[i].offsetTriangles); + + lods[i].glCommands = new int[lodInfo[i].numGlCommands]; + memcpy(lods[i].glCommands, buffer + lodInfo[i].offsetGlCommands, sizeof(int) * lodInfo[i].numGlCommands); + } + + // Determine vertex usage at each LOD level. + vertexUsage = new char[info.numVertices]; + memset(vertexUsage, 0, info.numVertices); + + for(i = 0; i < info.numLODs; i++) + for(k = 0; k < lodInfo[i].numTriangles; k++) + for(c = 0; c < 3; c++) + vertexUsage[SHORT(triangles[i][k].vertexIndices[c])] |= 1 << i; + + loaded=true; + return true; +} + + +FDMDModel::~FDMDModel() +{ + int i; + + // clean up + if (skins != NULL) + { + for (i=0;i 0 ? GL_TRIANGLE_STRIP : GL_TRIANGLE_FAN); + count = abs(count); + + while(count--) + { + v = (FGLCommandVertex *) pos; + pos += sizeof(FGLCommandVertex); + + gl.TexCoord2fv(&v->s); + gl.Vertex3fv((float*)&vertices[v->index]); + } + + gl.End(); + } +} + + +void FDMDModel::RenderFrame(FTexture * skin, int frameno, int cm, int translation) +{ + int activeLod; + + if (frameno>=info.numFrames) return; + + ModelFrame * frame = &frames[frameno]; + //int mainFlags = mf->flags; + + if (!skin) + { + if (info.numSkins==0) return; + skin = skins[0]; + if (!skin) return; + } + + FMaterial * tex = FMaterial::ValidateTexture(skin); + + tex->Bind(cm, 0, translation); + + int numVerts = info.numVertices; + + // Determine the suitable LOD. + /* + if(info.numLODs > 1 && rend_model_lod != 0) + { + float lodFactor = rend_model_lod * screen->Width() / 640.0f / (GLRenderer->mCurrentFoV / 90.0f); + if(lodFactor) lodFactor = 1 / lodFactor; + + // Determine the LOD we will be using. + activeLod = (int) (lodFactor * spr->distance); + if(activeLod < 0) activeLod = 0; + if(activeLod >= mdl->info.numLODs) activeLod = mdl->info.numLODs - 1; + vertexUsage = mdl->vertexUsage; + } + else + */ + { + activeLod = 0; + } + + RenderGLCommands(lods[activeLod].glCommands, numVerts, frame->vertices/*, modelColors, NULL*/); +} + +void FDMDModel::RenderFrameInterpolated(FTexture * skin, int frameno, int frameno2, double inter, int cm, int translation) +{ + int activeLod = 0; + + if (frameno>=info.numFrames || frameno2>=info.numFrames) return; + + FModelVertex *vertices1 = frames[frameno].vertices; + FModelVertex *vertices2 = frames[frameno2].vertices; + + if (!skin) + { + if (info.numSkins==0) return; + skin = skins[0]; + if (!skin) return; + } + + FMaterial * tex = FMaterial::ValidateTexture(skin); + + tex->Bind(cm, 0, translation); + + int numVerts = info.numVertices; + + // [BB] Calculate the interpolated vertices by linear interpolation. + FModelVertex *verticesInterpolated = new FModelVertex[numVerts]; + for( int k = 0; k < numVerts; k++ ) + { + for ( int i = 0; i < 3; i++ ) + verticesInterpolated[k].xyz[i] = (1-inter)*vertices1[k].xyz[i]+ (inter)*vertices2[k].xyz[i]; + } + + RenderGLCommands(lods[activeLod].glCommands, numVerts, verticesInterpolated/*, modelColors, NULL*/); + delete[] verticesInterpolated; +} + + +//=========================================================================== +// +// FMD2Model::Load +// +//=========================================================================== + +bool FMD2Model::Load(const char * path, int, const char * buffer, int length) +{ + // Internal data structures of MD2 files - only used during loading! + struct md2_header_t + { + int magic; + int version; + int skinWidth; + int skinHeight; + int frameSize; + int numSkins; + int numVertices; + int numTexCoords; + int numTriangles; + int numGlCommands; + int numFrames; + int offsetSkins; + int offsetTexCoords; + int offsetTriangles; + int offsetFrames; + int offsetGlCommands; + int offsetEnd; + } ; + + struct md2_triangleVertex_t + { + byte vertex[3]; + byte lightNormalIndex; + }; + + struct md2_packedFrame_t + { + float scale[3]; + float translate[3]; + char name[16]; + md2_triangleVertex_t vertices[1]; + }; + + md2_header_t * md2header = (md2_header_t *)buffer; + ModelFrame *frame; + byte *md2_frames; + int i, k, c; + int axis[3] = { VX, VY, VZ }; + + // Convert it to DMD. + header.magic = MD2_MAGIC; + header.version = 8; + header.flags = 0; + vertexUsage = NULL; + info.skinWidth = LittleLong(md2header->skinWidth); + info.skinHeight = LittleLong(md2header->skinHeight); + info.frameSize = LittleLong(md2header->frameSize); + info.numLODs = 1; + info.numSkins = LittleLong(md2header->numSkins); + info.numTexCoords = LittleLong(md2header->numTexCoords); + info.numVertices = LittleLong(md2header->numVertices); + info.numFrames = LittleLong(md2header->numFrames); + info.offsetSkins = LittleLong(md2header->offsetSkins); + info.offsetTexCoords = LittleLong(md2header->offsetTexCoords); + info.offsetFrames = LittleLong(md2header->offsetFrames); + info.offsetLODs = LittleLong(md2header->offsetEnd); // Doesn't exist. + lodInfo[0].numTriangles = LittleLong(md2header->numTriangles); + lodInfo[0].numGlCommands = LittleLong(md2header->numGlCommands); + lodInfo[0].offsetTriangles = LittleLong(md2header->offsetTriangles); + lodInfo[0].offsetGlCommands = LittleLong(md2header->offsetGlCommands); + info.offsetEnd = LittleLong(md2header->offsetEnd); + + if (info.offsetFrames + info.frameSize * info.numFrames > length) + { + Printf("LoadModel: Model '%s' file too short\n", path); + return false; + } + if (lodInfo[0].numGlCommands <= 0) + { + Printf("LoadModel: Model '%s' invalid NumGLCommands\n", path); + return false; + } + + // The frames need to be unpacked. + md2_frames = (byte*)buffer + info.offsetFrames; + + frames = new ModelFrame[info.numFrames]; + + for(i = 0, frame = frames; i < info.numFrames; i++, frame++) + { + md2_packedFrame_t *pfr = (md2_packedFrame_t *) (md2_frames + info.frameSize * i); + md2_triangleVertex_t *pVtx; + + memcpy(frame->name, pfr->name, sizeof(pfr->name)); + frame->vertices = new FModelVertex[info.numVertices]; + frame->normals = new FModelVertex[info.numVertices]; + + // Translate each vertex. + for(k = 0, pVtx = pfr->vertices; k < info.numVertices; k++, pVtx++) + { + memcpy(frame->normals[k].xyz, + avertexnormals[pVtx->lightNormalIndex], sizeof(float) * 3); + + for(c = 0; c < 3; c++) + { + frame->vertices[k].xyz[axis[c]] = + (pVtx->vertex[c] * pfr->scale[c] + pfr->translate[c]); + } + // Aspect ratio adjustment (1.33 -> 1.6.) + frame->vertices[k].xyz[VZ] *= rModelAspectMod; + } + } + + + lods[0].glCommands = new int[lodInfo[0].numGlCommands]; + memcpy(lods[0].glCommands, buffer + lodInfo[0].offsetGlCommands, sizeof(int) * lodInfo[0].numGlCommands); + + skins = new FTexture *[info.numSkins]; + + for(i = 0; i < info.numSkins; i++) + { + skins[i] = LoadSkin(path, buffer + info.offsetSkins + i*64); + } + loaded=true; + return true; +} + +FMD2Model::~FMD2Model() +{ +} + diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp new file mode 100644 index 000000000..72bf6d655 --- /dev/null +++ b/src/gl/models/gl_models_md3.cpp @@ -0,0 +1,313 @@ +/* +** gl_models_md3.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2006 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "w_wad.h" +#include "cmdlib.h" +#include "sc_man.h" +#include "m_crc32.h" + +#include "gl/renderer/gl_renderstate.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/models/gl_models.h" +#include "gl/textures/gl_material.h" +#include "gl/shaders/gl_shader.h" + +#define MAX_QPATH 64 + +static void UnpackVector(unsigned short packed, float & nx, float & ny, float & nz) +{ + // decode the lat/lng normal to a 3 float normal + double lat = ( packed >> 8 ) & 0xff; + double lng = ( packed & 0xff ); + lat *= PI/128; + lng *= PI/128; + + nx = cos(lat) * sin(lng); + ny = sin(lat) * sin(lng); + nz = cos(lng); +} + + + +bool FMD3Model::Load(const char * path, int, const char * buffer, int length) +{ + #pragma pack(4) + struct md3_header_t + { + DWORD Magic; + DWORD Version; + char Name[MAX_QPATH]; + DWORD Flags; + DWORD Num_Frames; + DWORD Num_Tags; + DWORD Num_Surfaces; + DWORD Num_Skins; + DWORD Ofs_Frames; + DWORD Ofs_Tags; + DWORD Ofs_Surfaces; + DWORD Ofs_Eof; + }; + + struct md3_surface_t + { + DWORD Magic; + char Name[MAX_QPATH]; + DWORD Flags; + DWORD Num_Frames; + DWORD Num_Shaders; + DWORD Num_Verts; + DWORD Num_Triangles; + DWORD Ofs_Triangles; + DWORD Ofs_Shaders; + DWORD Ofs_Texcoord; + DWORD Ofs_XYZNormal; + DWORD Ofs_End; + }; + + struct md3_triangle_t + { + DWORD vt_index[3]; + }; + + struct md3_shader_t + { + char Name[MAX_QPATH]; + DWORD index; + }; + + struct md3_texcoord_t + { + float s,t; + }; + + struct md3_vertex_t + { + short x,y,z,n; + }; + + struct md3_frame_t + { + float min_Bounds[3]; + float max_Bounds[3]; + float localorigin[3]; + float radius; + char Name[16]; + }; + #pragma pack() + + md3_header_t * hdr=(md3_header_t *)buffer; + + numFrames = LittleLong(hdr->Num_Frames); + numTags = LittleLong(hdr->Num_Tags); + numSurfaces = LittleLong(hdr->Num_Surfaces); + + md3_frame_t * frm = (md3_frame_t*)(buffer + LittleLong(hdr->Ofs_Frames)); + + frames = new MD3Frame[numFrames]; + for(int i=0;iOfs_Surfaces)); + + surfaces = new MD3Surface[numSurfaces]; + for(int i=0;iOfs_End)); + + s->numSkins = LittleLong(ss->Num_Shaders); + s->numTriangles = LittleLong(ss->Num_Triangles); + s->numVertices = LittleLong(ss->Num_Verts); + + // copy triangle indices + md3_triangle_t * tris = (md3_triangle_t*)(((char*)ss)+LittleLong(ss->Ofs_Triangles)); + s->tris = new MD3Triangle[s->numTriangles]; + + for(int i=0;inumTriangles;i++) for (int j=0;j<3;j++) + { + s->tris[i].VertIndex[j]=LittleLong(tris[i].vt_index[j]); + } + + // copy shaders (skins) + md3_shader_t * shader = (md3_shader_t*)(((char*)ss)+LittleLong(ss->Ofs_Shaders)); + s->skins = new FTexture *[s->numSkins]; + + for(int i=0;inumSkins;i++) + { + // [BB] According to the MD3 spec, Name is supposed to include the full path. + s->skins[i] = LoadSkin("", shader[i].Name); + // [BB] Fall back and check if Name is relative. + if ( s->skins[i] == NULL ) + s->skins[i] = LoadSkin(path, shader[i].Name); + } + + // Load texture coordinates + md3_texcoord_t * tc = (md3_texcoord_t*)(((char*)ss)+LittleLong(ss->Ofs_Texcoord)); + s->texcoords = new MD3TexCoord[s->numVertices]; + + for(int i=0;inumVertices;i++) + { + s->texcoords[i].s = tc[i].s; + s->texcoords[i].t = tc[i].t; + } + + // Load vertices and texture coordinates + md3_vertex_t * vt = (md3_vertex_t*)(((char*)ss)+LittleLong(ss->Ofs_XYZNormal)); + s->vertices = new MD3Vertex[s->numVertices * numFrames]; + + for(int i=0;inumVertices * numFrames;i++) + { + s->vertices[i].x = LittleShort(vt[i].x)/64.f; + s->vertices[i].y = LittleShort(vt[i].y)/64.f; + s->vertices[i].z = LittleShort(vt[i].z)/64.f * rModelAspectMod; + UnpackVector( LittleShort(vt[i].n), s->vertices[i].nx, s->vertices[i].ny, s->vertices[i].nz); + } + } + return true; +} + +int FMD3Model::FindFrame(const char * name) +{ + for (int i=0;inumTriangles;i++) + { + for(int j=0;j<3;j++) + { + int x = surf->tris[i].VertIndex[j]; + + gl.TexCoord2fv(&surf->texcoords[x].s); + gl.Vertex3f(vert[x].x, vert[x].z, vert[x].y); + } + } + gl.End(); +} + +void FMD3Model::RenderFrame(FTexture * skin, int frameno, int cm, int translation) +{ + if (frameno>=numFrames) return; + + MD3Frame * frame = &frames[frameno]; + + // I can't confirm correctness of this because no model I have tested uses this information + // gl.MatrixMode(GL_MODELVIEW); + // gl.Translatef(frame->origin[0], frame->origin[1], frame->origin[2]); + + for(int i=0;inumSkins==0) return; + surfaceSkin = surf->skins[0]; + if (!surfaceSkin) return; + } + + FMaterial * tex = FMaterial::ValidateTexture(surfaceSkin); + + tex->Bind(cm, 0, translation); + RenderTriangles(surf, surf->vertices + frameno * surf->numVertices); + } +} + +void FMD3Model::RenderFrameInterpolated(FTexture * skin, int frameno, int frameno2, double inter, int cm, int translation) +{ + if (frameno>=numFrames || frameno2>=numFrames) return; + + for(int i=0;inumSkins==0) return; + surfaceSkin = surf->skins[0]; + if (!surfaceSkin) return; + } + + FMaterial * tex = FMaterial::ValidateTexture(surfaceSkin); + + tex->Bind(cm, 0, translation); + + MD3Vertex* verticesInterpolated = new MD3Vertex[surfaces[i].numVertices]; + MD3Vertex* vertices1 = surf->vertices + frameno * surf->numVertices; + MD3Vertex* vertices2 = surf->vertices + frameno2 * surf->numVertices; + + // [BB] Calculate the interpolated vertices by linear interpolation. + for( int k = 0; k < surf->numVertices; k++ ) + { + verticesInterpolated[k].x = (1-inter)*vertices1[k].x+ (inter)*vertices2[k].x; + verticesInterpolated[k].y = (1-inter)*vertices1[k].y+ (inter)*vertices2[k].y; + verticesInterpolated[k].z = (1-inter)*vertices1[k].z+ (inter)*vertices2[k].z; + // [BB] Apparently RenderTriangles doesn't use nx, ny, nz, so don't interpolate them. + } + + RenderTriangles(surf, verticesInterpolated); + + delete[] verticesInterpolated; + } +} + +FMD3Model::~FMD3Model() +{ + if (frames) delete [] frames; + if (surfaces) delete [] surfaces; + frames = NULL; + surfaces = NULL; +} diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp new file mode 100644 index 000000000..450c19d64 --- /dev/null +++ b/src/gl/models/gl_voxels.cpp @@ -0,0 +1,504 @@ +/* +** gl_voxels.cpp +** +** Voxel management +** +**--------------------------------------------------------------------------- +** Copyright 2010 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "w_wad.h" +#include "cmdlib.h" +#include "sc_man.h" +#include "m_crc32.h" +#include "c_console.h" +#include "g_game.h" +#include "doomstat.h" +#include "g_level.h" +#include "textures/bitmap.h" +//#include "gl/gl_intern.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/models/gl_models.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_geometric.h" +#include "gl/utility/gl_convert.h" +#include "gl/renderer/gl_renderstate.h" + + +//=========================================================================== +// +// Creates a 16x16 texture from the palette so that we can +// use the existing palette manipulation code to render the voxel +// Otherwise all shaders had to be duplicated and the non-shader code +// would be a lot less efficient. +// +//=========================================================================== + +class FVoxelTexture : public FTexture +{ +public: + + FVoxelTexture(FVoxel *voxel); + ~FVoxelTexture(); + const BYTE *GetColumn (unsigned int column, const Span **spans_out); + const BYTE *GetPixels (); + void Unload (); + + int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf); + bool UseBasePalette() { return false; } + +protected: + FVoxel *SourceVox; + +}; + +//=========================================================================== +// +// +// +//=========================================================================== + +FVoxelTexture::FVoxelTexture(FVoxel *vox) +{ + SourceVox = vox; + Width = 16; + Height = 16; + WidthBits = 4; + HeightBits = 4; + WidthMask = 15; + gl_info.bNoFilter = true; + gl_info.bNoCompress = true; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +FVoxelTexture::~FVoxelTexture() +{ +} + +const BYTE *FVoxelTexture::GetColumn (unsigned int column, const Span **spans_out) +{ + // not needed + return NULL; +} + +const BYTE *FVoxelTexture::GetPixels () +{ + // not needed + return NULL; +} + +void FVoxelTexture::Unload () +{ +} + +//=========================================================================== +// +// FVoxelTexture::CopyTrueColorPixels +// +// This creates a dummy 16x16 paletted bitmap and converts that using the +// voxel palette +// +//=========================================================================== + +int FVoxelTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +{ + PalEntry pe[256]; + BYTE bitmap[256]; + BYTE *pp = SourceVox->Palette; + + for(int i=0;i<256;i++, pp+=3) + { + bitmap[i] = (BYTE)i; + pe[i].r = (pp[0] << 2) | (pp[0] >> 4); + pe[i].g = (pp[1] << 2) | (pp[1] >> 4); + pe[i].b = (pp[2] << 2) | (pp[2] >> 4); + pe[i].a = 255; + } + + bmp->CopyPixelData(x, y, bitmap, Width, Height, 1, 16, rotate, pe, inf); + return 0; +} + +//=========================================================================== +// +// +// +//=========================================================================== + + +class FVoxelVertexBuffer : public FVertexBuffer +{ + unsigned int ibo_id; + bool isint; + +public: + FVoxelVertexBuffer(TArray &verts, TArray &indices); + ~FVoxelVertexBuffer(); + void BindVBO(); + bool IsInt() const { return isint; } +}; + + +//=========================================================================== +// +// +// +//=========================================================================== + +FVoxelVertexBuffer::FVoxelVertexBuffer(TArray &verts, TArray &indices) +{ + ibo_id = 0; + if (gl.flags&RFL_VBO) + { + gl.GenBuffers(1, &ibo_id); + + gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); + gl.BufferData(GL_ARRAY_BUFFER, verts.Size() * sizeof(FVoxelVertex), &verts[0], GL_STATIC_DRAW); + gl.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); + if (verts.Size() > 65535) + { + gl.BufferData(GL_ELEMENT_ARRAY_BUFFER, indices.Size() * sizeof(unsigned int), &indices[0], GL_STATIC_DRAW); + isint = true; + } + else + { + unsigned short *sbuffer = new unsigned short[indices.Size()]; + for(unsigned i=0;ix); + glTexCoordPointer(2,GL_FLOAT, sizeof(FVoxelVertex), &VVO->u); + gl.EnableClientState(GL_VERTEX_ARRAY); + gl.EnableClientState(GL_TEXTURE_COORD_ARRAY); + gl.EnableClientState(GL_INDEX_ARRAY); +} + + + +//=========================================================================== +// +// +// +//=========================================================================== + +FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned) +{ + mVoxel = voxel; + mOwningVoxel = owned; + mVBO = NULL; + mPalette = new FVoxelTexture(voxel); + Initialize(); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +FVoxelModel::~FVoxelModel() +{ + CleanGLData(); + delete mPalette; + if (mOwningVoxel) delete mVoxel; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FVoxelModel::AddVertex(FVoxelVertex &vert, FVoxelMap &check) +{ + unsigned int index = check[vert]; + if (index == 0xffffffff) + { + index = check[vert] =mVertices.Push(vert); + } + mIndices.Push(index); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FVoxelModel::AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3, int x4, int y4, int z4, BYTE col, FVoxelMap &check) +{ + float PivotX = mVoxel->Mips[0].PivotX / 256.f; + float PivotY = mVoxel->Mips[0].PivotY / 256.f; + float PivotZ = mVoxel->Mips[0].PivotZ / 256.f; + int h = mVoxel->Mips[0].SizeZ; + FVoxelVertex vert; + + + vert.u = (((col & 15) * 255 / 16) + 7) / 255.f; + vert.v = (((col / 16) * 255 / 16) + 7) / 255.f; + + vert.x = x1 - PivotX; + vert.z = -y1 + PivotY; + vert.y = -z1 + PivotZ; + AddVertex(vert, check); + + vert.x = x2 - PivotX; + vert.z = -y2 + PivotY; + vert.y = -z2 + PivotZ; + AddVertex(vert, check); + + vert.x = x4 - PivotX; + vert.z = -y4 + PivotY; + vert.y = -z4 + PivotZ; + AddVertex(vert, check); + + vert.x = x3 - PivotX; + vert.z = -y3 + PivotY; + vert.y = -z3 + PivotZ; + AddVertex(vert, check); + +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FVoxelModel::MakeSlabPolys(int x, int y, kvxslab_t *voxptr, FVoxelMap &check) +{ + const BYTE *col = voxptr->col; + int zleng = voxptr->zleng; + int ztop = voxptr->ztop; + int cull = voxptr->backfacecull; + + if (cull & 16) + { + AddFace(x, y, ztop, x+1, y, ztop, x, y+1, ztop, x+1, y+1, ztop, *col, check); + } + int z = ztop; + while (z < ztop+zleng) + { + int c = 0; + while (z+c < ztop+zleng && col[c] == col[0]) c++; + + if (cull & 1) + { + AddFace(x, y, z, x, y+1, z, x, y, z+c, x, y+1, z+c, *col, check); + } + if (cull & 2) + { + AddFace(x+1, y+1, z, x+1, y, z, x+1, y+1, z+c, x+1, y, z+c, *col, check); + } + if (cull & 4) + { + AddFace(x, y, z, x+1, y, z, x, y, z+c, x+1, y, z+c, *col, check); + } + if (cull & 8) + { + AddFace(x+1, y+1, z, x, y+1, z, x+1, y+1, z+c, x, y+1, z+c, *col, check); + } + z+=c; + col+=c; + } + if (cull & 32) + { + int z = ztop+zleng-1; + AddFace(x+1, y, z+1, x, y, z+1, x+1, y+1, z+1, x, y+1, z+1, voxptr->col[zleng-1], check); + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FVoxelModel::Initialize() +{ + FVoxelMap check; + FVoxelMipLevel *mip = &mVoxel->Mips[0]; + for (int x = 0; x < mip->SizeX; x++) + { + BYTE *slabxoffs = &mip->SlabData[mip->OffsetX[x]]; + short *xyoffs = &mip->OffsetXY[x * (mip->SizeY + 1)]; + for (int y = 0; y < mip->SizeY; y++) + { + kvxslab_t *voxptr = (kvxslab_t *)(slabxoffs + xyoffs[y]); + kvxslab_t *voxend = (kvxslab_t *)(slabxoffs + xyoffs[y+1]); + for (; voxptr < voxend; voxptr = (kvxslab_t *)((BYTE *)voxptr + voxptr->zleng + 3)) + { + MakeSlabPolys(x, y, voxptr, check); + } + } + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +bool FVoxelModel::Load(const char * fn, int lumpnum, const char * buffer, int length) +{ + return false; // not needed +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FVoxelModel::MakeGLData() +{ + if (gl.flags&RFL_VBO) + { + mVBO = new FVoxelVertexBuffer(mVertices, mIndices); + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FVoxelModel::CleanGLData() +{ + if (mVBO != NULL) + { + delete mVBO; + mVBO = NULL; + } +} + +//=========================================================================== +// +// Voxels don't have frames so always return 0 +// +//=========================================================================== + +int FVoxelModel::FindFrame(const char * name) +{ + return 0; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FVoxelModel::RenderFrame(FTexture * skin, int frame, int cm, int translation) +{ + FMaterial * tex = FMaterial::ValidateTexture(skin); + tex->Bind(cm, 0, translation); + gl_RenderState.Apply(); + + if (gl.flags&RFL_VBO) + { + if (mVBO == NULL) MakeGLData(); + if (mVBO != NULL) + { + mVBO->BindVBO(); + glDrawElements(GL_QUADS, mIndices.Size(), mVBO->IsInt()? GL_UNSIGNED_INT:GL_UNSIGNED_SHORT, 0); + GLRenderer->mVBO->BindVBO(); + return; + } + } + + gl.Begin(GL_QUADS); + for(unsigned i=0;i < mIndices.Size(); i++) + { + FVoxelVertex *vert = &mVertices[mIndices[i]]; + gl.TexCoord2fv(&vert->u); + gl.Vertex3fv(&vert->x); + } + gl.End(); +} + +//=========================================================================== +// +// Voxels never interpolate between frames +// +//=========================================================================== + +void FVoxelModel::RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int cm, int translation) +{ + RenderFrame(skin, frame, cm, translation); +} + diff --git a/src/gl/models/tab_anorms.h b/src/gl/models/tab_anorms.h new file mode 100644 index 000000000..46467b460 --- /dev/null +++ b/src/gl/models/tab_anorms.h @@ -0,0 +1,489 @@ +#ifdef WIN32 +#pragma warning(disable:4305) +#endif + +{ +-0.525731, 0.000000, 0.850651}, + +{ +-0.442863, 0.238856, 0.864188}, + +{ +-0.295242, 0.000000, 0.955423}, + +{ +-0.309017, 0.500000, 0.809017}, + +{ +-0.162460, 0.262866, 0.951056}, + +{ +0.000000, 0.000000, 1.000000}, + +{ +0.000000, 0.850651, 0.525731}, + +{ +-0.147621, 0.716567, 0.681718}, + +{ +0.147621, 0.716567, 0.681718}, + +{ +0.000000, 0.525731, 0.850651}, + +{ +0.309017, 0.500000, 0.809017}, + +{ +0.525731, 0.000000, 0.850651}, + +{ +0.295242, 0.000000, 0.955423}, + +{ +0.442863, 0.238856, 0.864188}, + +{ +0.162460, 0.262866, 0.951056}, + +{ +-0.681718, 0.147621, 0.716567}, + +{ +-0.809017, 0.309017, 0.500000}, + +{ +-0.587785, 0.425325, 0.688191}, + +{ +-0.850651, 0.525731, 0.000000}, + +{ +-0.864188, 0.442863, 0.238856}, + +{ +-0.716567, 0.681718, 0.147621}, + +{ +-0.688191, 0.587785, 0.425325}, + +{ +-0.500000, 0.809017, 0.309017}, + +{ +-0.238856, 0.864188, 0.442863}, + +{ +-0.425325, 0.688191, 0.587785}, + +{ +-0.716567, 0.681718, -0.147621}, + +{ +-0.500000, 0.809017, -0.309017}, + +{ +-0.525731, 0.850651, 0.000000}, + +{ +0.000000, 0.850651, -0.525731}, + +{ +-0.238856, 0.864188, -0.442863}, + +{ +0.000000, 0.955423, -0.295242}, + +{ +-0.262866, 0.951056, -0.162460}, + +{ +0.000000, 1.000000, 0.000000}, + +{ +0.000000, 0.955423, 0.295242}, + +{ +-0.262866, 0.951056, 0.162460}, + +{ +0.238856, 0.864188, 0.442863}, + +{ +0.262866, 0.951056, 0.162460}, + +{ +0.500000, 0.809017, 0.309017}, + +{ +0.238856, 0.864188, -0.442863}, + +{ +0.262866, 0.951056, -0.162460}, + +{ +0.500000, 0.809017, -0.309017}, + +{ +0.850651, 0.525731, 0.000000}, + +{ +0.716567, 0.681718, 0.147621}, + +{ +0.716567, 0.681718, -0.147621}, + +{ +0.525731, 0.850651, 0.000000}, + +{ +0.425325, 0.688191, 0.587785}, + +{ +0.864188, 0.442863, 0.238856}, + +{ +0.688191, 0.587785, 0.425325}, + +{ +0.809017, 0.309017, 0.500000}, + +{ +0.681718, 0.147621, 0.716567}, + +{ +0.587785, 0.425325, 0.688191}, + +{ +0.955423, 0.295242, 0.000000}, + +{ +1.000000, 0.000000, 0.000000}, + +{ +0.951056, 0.162460, 0.262866}, + +{ +0.850651, -0.525731, 0.000000}, + +{ +0.955423, -0.295242, 0.000000}, + +{ +0.864188, -0.442863, 0.238856}, + +{ +0.951056, -0.162460, 0.262866}, + +{ +0.809017, -0.309017, 0.500000}, + +{ +0.681718, -0.147621, 0.716567}, + +{ +0.850651, 0.000000, 0.525731}, + +{ +0.864188, 0.442863, -0.238856}, + +{ +0.809017, 0.309017, -0.500000}, + +{ +0.951056, 0.162460, -0.262866}, + +{ +0.525731, 0.000000, -0.850651}, + +{ +0.681718, 0.147621, -0.716567}, + +{ +0.681718, -0.147621, -0.716567}, + +{ +0.850651, 0.000000, -0.525731}, + +{ +0.809017, -0.309017, -0.500000}, + +{ +0.864188, -0.442863, -0.238856}, + +{ +0.951056, -0.162460, -0.262866}, + +{ +0.147621, 0.716567, -0.681718}, + +{ +0.309017, 0.500000, -0.809017}, + +{ +0.425325, 0.688191, -0.587785}, + +{ +0.442863, 0.238856, -0.864188}, + +{ +0.587785, 0.425325, -0.688191}, + +{ +0.688191, 0.587785, -0.425325}, + +{ +-0.147621, 0.716567, -0.681718}, + +{ +-0.309017, 0.500000, -0.809017}, + +{ +0.000000, 0.525731, -0.850651}, + +{ +-0.525731, 0.000000, -0.850651}, + +{ +-0.442863, 0.238856, -0.864188}, + +{ +-0.295242, 0.000000, -0.955423}, + +{ +-0.162460, 0.262866, -0.951056}, + +{ +0.000000, 0.000000, -1.000000}, + +{ +0.295242, 0.000000, -0.955423}, + +{ +0.162460, 0.262866, -0.951056}, + +{ +-0.442863, -0.238856, -0.864188}, + +{ +-0.309017, -0.500000, -0.809017}, + +{ +-0.162460, -0.262866, -0.951056}, + +{ +0.000000, -0.850651, -0.525731}, + +{ +-0.147621, -0.716567, -0.681718}, + +{ +0.147621, -0.716567, -0.681718}, + +{ +0.000000, -0.525731, -0.850651}, + +{ +0.309017, -0.500000, -0.809017}, + +{ +0.442863, -0.238856, -0.864188}, + +{ +0.162460, -0.262866, -0.951056}, + +{ +0.238856, -0.864188, -0.442863}, + +{ +0.500000, -0.809017, -0.309017}, + +{ +0.425325, -0.688191, -0.587785}, + +{ +0.716567, -0.681718, -0.147621}, + +{ +0.688191, -0.587785, -0.425325}, + +{ +0.587785, -0.425325, -0.688191}, + +{ +0.000000, -0.955423, -0.295242}, + +{ +0.000000, -1.000000, 0.000000}, + +{ +0.262866, -0.951056, -0.162460}, + +{ +0.000000, -0.850651, 0.525731}, + +{ +0.000000, -0.955423, 0.295242}, + +{ +0.238856, -0.864188, 0.442863}, + +{ +0.262866, -0.951056, 0.162460}, + +{ +0.500000, -0.809017, 0.309017}, + +{ +0.716567, -0.681718, 0.147621}, + +{ +0.525731, -0.850651, 0.000000}, + +{ +-0.238856, -0.864188, -0.442863}, + +{ +-0.500000, -0.809017, -0.309017}, + +{ +-0.262866, -0.951056, -0.162460}, + +{ +-0.850651, -0.525731, 0.000000}, + +{ +-0.716567, -0.681718, -0.147621}, + +{ +-0.716567, -0.681718, 0.147621}, + +{ +-0.525731, -0.850651, 0.000000}, + +{ +-0.500000, -0.809017, 0.309017}, + +{ +-0.238856, -0.864188, 0.442863}, + +{ +-0.262866, -0.951056, 0.162460}, + +{ +-0.864188, -0.442863, 0.238856}, + +{ +-0.809017, -0.309017, 0.500000}, + +{ +-0.688191, -0.587785, 0.425325}, + +{ +-0.681718, -0.147621, 0.716567}, + +{ +-0.442863, -0.238856, 0.864188}, + +{ +-0.587785, -0.425325, 0.688191}, + +{ +-0.309017, -0.500000, 0.809017}, + +{ +-0.147621, -0.716567, 0.681718}, + +{ +-0.425325, -0.688191, 0.587785}, + +{ +-0.162460, -0.262866, 0.951056}, + +{ +0.442863, -0.238856, 0.864188}, + +{ +0.162460, -0.262866, 0.951056}, + +{ +0.309017, -0.500000, 0.809017}, + +{ +0.147621, -0.716567, 0.681718}, + +{ +0.000000, -0.525731, 0.850651}, + +{ +0.425325, -0.688191, 0.587785}, + +{ +0.587785, -0.425325, 0.688191}, + +{ +0.688191, -0.587785, 0.425325}, + +{ +-0.955423, 0.295242, 0.000000}, + +{ +-0.951056, 0.162460, 0.262866}, + +{ +-1.000000, 0.000000, 0.000000}, + +{ +-0.850651, 0.000000, 0.525731}, + +{ +-0.955423, -0.295242, 0.000000}, + +{ +-0.951056, -0.162460, 0.262866}, + +{ +-0.864188, 0.442863, -0.238856}, + +{ +-0.951056, 0.162460, -0.262866}, + +{ +-0.809017, 0.309017, -0.500000}, + +{ +-0.864188, -0.442863, -0.238856}, + +{ +-0.951056, -0.162460, -0.262866}, + +{ +-0.809017, -0.309017, -0.500000}, + +{ +-0.681718, 0.147621, -0.716567}, + +{ +-0.681718, -0.147621, -0.716567}, + +{ +-0.850651, 0.000000, -0.525731}, + +{ +-0.688191, 0.587785, -0.425325}, + +{ +-0.587785, 0.425325, -0.688191}, + +{ +-0.425325, 0.688191, -0.587785}, + +{ +-0.425325, -0.688191, -0.587785}, + +{ +-0.587785, -0.425325, -0.688191}, + +{ +-0.688191, -0.587785, -0.425325}, diff --git a/src/gl/renderer/gl_colormap.h b/src/gl/renderer/gl_colormap.h new file mode 100644 index 000000000..a3f4cf83b --- /dev/null +++ b/src/gl/renderer/gl_colormap.h @@ -0,0 +1,79 @@ +#ifndef __GL_COLORMAP +#define __GL_COLORMAP + +#include "doomtype.h" +#include "v_palette.h" +#include "r_data/colormaps.h" + +extern DWORD gl_fixedcolormap; + + +enum EColorManipulation +{ + + CM_INVALID=-1, + CM_DEFAULT=0, // untranslated + CM_DESAT0=CM_DEFAULT, + CM_DESAT1, // minimum desaturation + CM_DESAT31=CM_DESAT1+30, // maximum desaturation = grayscale + CM_FIRSTSPECIALCOLORMAP, // first special fixed colormap + + // special internal values for texture creation + CM_SHADE= 0x10000002, // alpha channel texture + + // These are not to be passed to the texture manager + CM_LITE = 0x20000000, // special values to handle these items without excessive hacking + CM_TORCH= 0x20000010, // These are not real color manipulations +}; + +#define CM_MAXCOLORMAP int(CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size()) + + // for internal use +struct FColormap +{ + PalEntry LightColor; // a is saturation (0 full, 31=b/w, other=custom colormap) + PalEntry FadeColor; // a is fadedensity>>1 + int colormap; + int blendfactor; + + void Clear() + { + LightColor=0xffffff; + FadeColor=0; + colormap = CM_DEFAULT; + blendfactor=0; + } + + void ClearColor() + { + LightColor.r=LightColor.g=LightColor.b=0xff; + blendfactor=0; + } + + + void GetFixedColormap() + { + Clear(); + colormap = gl_fixedcolormap >= CM_LITE? CM_DEFAULT : gl_fixedcolormap; + } + + FColormap & operator=(FDynamicColormap * from) + { + LightColor = from->Color; + colormap = from->Desaturate>>3; + FadeColor = from->Fade; + blendfactor = from->Color.a; + return * this; + } + + void CopyLightColor(FDynamicColormap * from) + { + LightColor = from->Color; + colormap = from->Desaturate>>3; + blendfactor = from->Color.a; + } +}; + + + +#endif diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp new file mode 100644 index 000000000..9c77803fc --- /dev/null +++ b/src/gl/renderer/gl_lightdata.cpp @@ -0,0 +1,654 @@ +/* +** gl_light.cpp +** Light level / fog management / dynamic lights +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + + +#include "gl/system/gl_system.h" +#include "gl/system/gl_cvars.h" +#include "gl/data/gl_data.h" +#include "gl/renderer/gl_colormap.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/shaders/gl_shader.h" +#include "gl/scene/gl_portal.h" +#include "c_dispatch.h" +#include "p_local.h" +#include "g_level.h" +#include "r_sky.h" + +// externally settable lighting properties +static float distfogtable[2][256]; // light to fog conversion table for black fog +static PalEntry outsidefogcolor; +int fogdensity; +int outsidefogdensity; +int skyfog; + +CUSTOM_CVAR (Int, gl_light_ambient, 20, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + // ambient of 0 does not work correctly because light level 0 is special. + if (self < 1) self = 1; +} + +CVAR(Int, gl_weaponlight, 8, CVAR_ARCHIVE); +CVAR(Bool,gl_enhanced_nightvision,true,CVAR_ARCHIVE) +CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE); + + + +//========================================================================== +// +// +// +//========================================================================== + +bool gl_BrightmapsActive() +{ + return gl.shadermodel == 4 || (gl.shadermodel == 3 && gl_brightmap_shader); +} + +bool gl_GlowActive() +{ + return gl.shadermodel == 4 || (gl.shadermodel == 3 && gl_glow_shader); +} + +//========================================================================== +// +// Sets up the fog tables +// +//========================================================================== + +CUSTOM_CVAR (Int, gl_distfog, 70, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + for (int i=0;i<256;i++) + { + + if (i<164) + { + distfogtable[0][i]= (gl_distfog>>1) + (gl_distfog)*(164-i)/164; + } + else if (i<230) + { + distfogtable[0][i]= (gl_distfog>>1) - (gl_distfog>>1)*(i-164)/(230-164); + } + else distfogtable[0][i]=0; + + if (i<128) + { + distfogtable[1][i]= 6.f + (gl_distfog>>1) + (gl_distfog)*(128-i)/48; + } + else if (i<216) + { + distfogtable[1][i]= (216.f-i) / ((216.f-128.f)) * gl_distfog / 10; + } + else distfogtable[1][i]=0; + } +} + +CUSTOM_CVAR(Int,gl_fogmode,1,CVAR_ARCHIVE|CVAR_NOINITCALL) +{ + if (self>2) self=2; + if (self<0) self=0; + if (self == 2 && gl.shadermodel < 4) self = 1; +} + +CUSTOM_CVAR(Int, gl_lightmode, 3 ,CVAR_ARCHIVE|CVAR_NOINITCALL) +{ + int newself = self; + if (newself > 4) newself=8; // use 8 for software lighting to avoid conflicts with the bit mask + if (newself < 0) newself=0; + if ((newself == 2 || newself == 8) && gl.shadermodel < 4) newself = 3; + if (self != newself) self = newself; + glset.lightmode = newself; +} + + + + +//========================================================================== +// +// Sets render state to draw the given render style +// includes: Texture mode, blend equation and blend mode +// +//========================================================================== + +void gl_GetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending, + int *tm, int *sb, int *db, int *be) +{ + static int blendstyles[] = { GL_ZERO, GL_ONE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }; + static int renderops[] = { 0, GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1 }; + + int srcblend = blendstyles[style.SrcAlpha&3]; + int dstblend = blendstyles[style.DestAlpha&3]; + int blendequation = renderops[style.BlendOp&15]; + int texturemode = drawopaque? TM_OPAQUE : TM_MODULATE; + + if (style.Flags & STYLEF_ColorIsFixed) + { + texturemode = TM_MASK; + } + else if (style.Flags & STYLEF_InvertSource) + { + texturemode = drawopaque? TM_INVERTOPAQUE : TM_INVERT; + } + + if (blendequation == -1) + { + srcblend = GL_DST_COLOR; + dstblend = GL_ONE_MINUS_SRC_ALPHA; + blendequation = GL_FUNC_ADD; + } + + if (allowcolorblending && srcblend == GL_SRC_ALPHA && dstblend == GL_ONE && blendequation == GL_FUNC_ADD) + { + srcblend = GL_SRC_COLOR; + } + + *tm = texturemode; + *be = blendequation; + *sb = srcblend; + *db = dstblend; +} + + +//========================================================================== +// +// Set fog parameters for the level +// +//========================================================================== +void gl_SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog) +{ + fogdensity=_fogdensity; + outsidefogcolor=_outsidefogcolor; + outsidefogdensity=_outsidefogdensity; + skyfog=_skyfog; + + outsidefogdensity>>=1; + fogdensity>>=1; +} + + +//========================================================================== +// +// Get current light level +// +//========================================================================== + +int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon) +{ + int light; + + if (lightlevel == 0) return 0; + + if ((glset.lightmode & 2) && lightlevel < 192 && !weapon) + { + light = xs_CRoundToInt(192.f - (192-lightlevel)* 1.95f); + } + else + { + light=lightlevel; + } + + if (light>=1; + } + return clamp(light+rellight, 0, 255); +} + +//========================================================================== +// +// Get current light color +// +//========================================================================== + +PalEntry gl_CalcLightColor(int light, PalEntry pe, int blendfactor, bool force) +{ + int r,g,b; + + if (glset.lightmode == 8 && !force) + { + return pe; + } + else if (blendfactor == 0) + { + r = pe.r * light / 255; + g = pe.g * light / 255; + b = pe.b * light / 255; + } + else + { + int mixlight = light * (255 - blendfactor); + + r = (mixlight + pe.r * blendfactor) / 255; + g = (mixlight + pe.g * blendfactor) / 255; + b = (mixlight + pe.b * blendfactor) / 255; + } + return PalEntry(BYTE(r), BYTE(g), BYTE(b)); +} + +//========================================================================== +// +// Get current light color +// +//========================================================================== +void gl_GetLightColor(int lightlevel, int rellight, const FColormap * cm, float * pred, float * pgreen, float * pblue, bool weapon) +{ + float & r=*pred,& g=*pgreen,& b=*pblue; + int torch=0; + + if (gl_fixedcolormap) + { + if (gl_fixedcolormap==CM_LITE) + { + if (gl_enhanced_nightvision) r=0.375f, g=1.0f, b=0.375f; + else r=g=b=1.0f; + } + else if (gl_fixedcolormap>=CM_TORCH) + { + int flicker=gl_fixedcolormap-CM_TORCH; + r=(0.8f+(7-flicker)/70.0f); + if (r>1.0f) r=1.0f; + b=g=r; + if (gl_enhanced_nightvision) b*=0.75f; + } + else r=g=b=1.0f; + return; + } + + PalEntry lightcolor = cm? cm->LightColor : PalEntry(255,255,255); + int blendfactor = cm? cm->blendfactor : 0; + + lightlevel = gl_CalcLightLevel(lightlevel, rellight, weapon); + PalEntry pe = gl_CalcLightColor(lightlevel, lightcolor, blendfactor); + r = pe.r/255.f; + g = pe.g/255.f; + b = pe.b/255.f; +} + +//========================================================================== +// +// set current light color +// +//========================================================================== +void gl_SetColor(int light, int rellight, const FColormap * cm, float *red, float *green, float *blue, PalEntry ThingColor, bool weapon) +{ + float r,g,b; + gl_GetLightColor(light, rellight, cm, &r, &g, &b, weapon); + + *red = r * ThingColor.r/255.0f; + *green = g * ThingColor.g/255.0f; + *blue = b * ThingColor.b/255.0f; +} + +//========================================================================== +// +// set current light color +// +//========================================================================== +void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, PalEntry ThingColor, bool weapon) +{ + float r,g,b; + + gl_GetLightColor(light, rellight, cm, &r, &g, &b, weapon); + + if (glset.lightmode != 8) + { + gl.Color4f(r * ThingColor.r/255.0f, g * ThingColor.g/255.0f, b * ThingColor.b/255.0f, alpha); + } + else + { + gl.Color4f(r, g, b, alpha); + + if (gl_fixedcolormap) + { + gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); + } + else + { + float lightlevel = gl_CalcLightLevel(light, rellight, weapon) / 255.0f; + gl.VertexAttrib1f(VATTR_LIGHTLEVEL, lightlevel); + } + } +} + +//========================================================================== +// +// calculates the current fog density +// +// Rules for fog: +// +// 1. If bit 4 of gl_lightmode is set always use the level's fog density. +// This is what Legacy's GL render does. +// 2. black fog means no fog and always uses the distfogtable based on the level's fog density setting +// 3. If outside fog is defined and the current fog color is the same as the outside fog +// the engine always uses the outside fog density to make the fog uniform across the level. +// If the outside fog's density is undefined it uses the level's fog density and if that is +// not defined it uses a default of 70. +// 4. If a global fog density is specified it is being used for all fog on the level +// 5. If none of the above apply fog density is based on the light level as for the software renderer. +// +//========================================================================== + +float gl_GetFogDensity(int lightlevel, PalEntry fogcolor) +{ + float density; + + if (glset.lightmode&4) + { + // uses approximations of Legacy's default settings. + density = fogdensity? fogdensity : 18; + } + else if ((fogcolor.d & 0xffffff) == 0) + { + // case 1: black fog + if (glset.lightmode != 8) + { + density=distfogtable[glset.lightmode!=0][lightlevel]; + } + else + { + density = 0; + } + } + else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff)) + { + // case 2. outsidefogdensity has already been set as needed + density=outsidefogdensity; + } + else if (fogdensity!=0) + { + // case 3: level has fog density set + density=fogdensity; + } + else if (lightlevel < 248) + { + // case 4: use light level + density=clamp(255-lightlevel,30,255); + } + else + { + density = 0.f; + } + return density; +} + + +//========================================================================== +// +// Check fog by current lighting info +// +//========================================================================== + +bool gl_CheckFog(FColormap *cm, int lightlevel) +{ + // Check for fog boundaries. This needs a few more checks for the sectors + bool frontfog; + + PalEntry fogcolor = cm->FadeColor; + + if ((fogcolor.d & 0xffffff) == 0) + { + frontfog = false; + } + else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff)) + { + frontfog = true; + } + else if (fogdensity!=0 || (glset.lightmode & 4)) + { + // case 3: level has fog density set + frontfog = true; + } + else + { + // case 4: use light level + frontfog = lightlevel < 248; + } + return frontfog; +} + +//========================================================================== +// +// Check if the current linedef is a candidate for a fog boundary +// +//========================================================================== + +bool gl_CheckFog(sector_t *frontsector, sector_t *backsector) +{ + // Check for fog boundaries. This needs a few more checks for the sectors + bool frontfog, backfog; + + PalEntry fogcolor = frontsector->ColorMap->Fade; + + if ((fogcolor.d & 0xffffff) == 0) + { + frontfog = false; + } + else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff)) + { + frontfog = true; + } + else if (fogdensity!=0 || (glset.lightmode & 4)) + { + // case 3: level has fog density set + frontfog = true; + } + else + { + // case 4: use light level + frontfog = frontsector->lightlevel < 248; + } + + if (backsector == NULL) return frontfog; + + fogcolor = backsector->ColorMap->Fade; + + if ((fogcolor.d & 0xffffff) == 0) + { + backfog = false; + } + else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff)) + { + backfog = true; + } + else if (fogdensity!=0 || (glset.lightmode & 4)) + { + // case 3: level has fog density set + backfog = true; + } + else + { + // case 4: use light level + backfog = backsector->lightlevel < 248; + } + + // in all other cases this might create more problems than it solves. + return (frontfog && !backfog && !gl_fixedcolormap && + (frontsector->GetTexture(sector_t::ceiling)!=skyflatnum || + backsector->GetTexture(sector_t::ceiling)!=skyflatnum)); +} + +//========================================================================== +// +// Lighting stuff +// +//========================================================================== + +void gl_SetShaderLight(float level, float olight) +{ +#if 1 //ndef _DEBUG + const float MAXDIST = 256.f; + const float THRESHOLD = 96.f; + const float FACTOR = 0.75f; +#else + const float MAXDIST = 256.f; + const float THRESHOLD = 96.f; + const float FACTOR = 2.75f; +#endif + + if (level > 0) + { + float lightdist, lightfactor; + + if (olight < THRESHOLD) + { + lightdist = (MAXDIST/2) + (olight * MAXDIST / THRESHOLD / 2); + olight = THRESHOLD; + } + else lightdist = MAXDIST; + + lightfactor = 1.f + ((olight/level) - 1.f) * FACTOR; + if (lightfactor == 1.f) lightdist = 0.f; // save some code in the shader + gl_RenderState.SetLightParms(lightfactor, lightdist); + } + else + { + gl_RenderState.SetLightParms(1.f, 0.f); + } +} + + +//========================================================================== +// +// Sets the fog for the current polygon +// +//========================================================================== + +void gl_SetFog(int lightlevel, int rellight, const FColormap *cmap, bool isadditive) +{ + PalEntry fogcolor; + float fogdensity; + + if (level.flags&LEVEL_HASFADETABLE) + { + fogdensity=70; + fogcolor=0x808080; + } + else if (cmap != NULL && gl_fixedcolormap == 0) + { + fogcolor = cmap->FadeColor; + fogdensity = gl_GetFogDensity(lightlevel, fogcolor); + fogcolor.a=0; + } + else + { + fogcolor = 0; + fogdensity = 0; + } + + // Make fog a little denser when inside a skybox + if (GLPortal::inskybox) fogdensity+=fogdensity/2; + + + // no fog in enhanced vision modes! + if (fogdensity==0 || gl_fogmode == 0) + { + gl_RenderState.EnableFog(false); + gl_RenderState.SetFog(0,0); + } + else + { + if (glset.lightmode == 2 && fogcolor == 0) + { + float light = gl_CalcLightLevel(lightlevel, rellight, false); + gl_SetShaderLight(light, lightlevel); + } + else + { + gl_RenderState.SetLightParms(1.f, 0.f); + } + + // For additive rendering using the regular fog color here would mean applying it twice + // so always use black + if (isadditive) + { + fogcolor=0; + } + // Handle desaturation + if (cmap->colormap != CM_DEFAULT) + gl_ModifyColor(fogcolor.r, fogcolor.g, fogcolor.b, cmap->colormap); + + gl_RenderState.EnableFog(true); + gl_RenderState.SetFog(fogcolor, fogdensity); + + // Korshun: fullbright fog like in software renderer. + if (glset.brightfog && fogdensity != 0 && fogcolor != 0) + gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); + } +} + +//========================================================================== +// +// Modifies a color according to a specified colormap +// +//========================================================================== + +void gl_ModifyColor(BYTE & red, BYTE & green, BYTE & blue, int cm) +{ + int gray = (red*77 + green*143 + blue*36)>>8; + if (cm >= CM_FIRSTSPECIALCOLORMAP && cm < CM_MAXCOLORMAP) + { + PalEntry pe = SpecialColormaps[cm - CM_FIRSTSPECIALCOLORMAP].GrayscaleToColor[gray]; + red = pe.r; + green = pe.g; + blue = pe.b; + } + else if (cm >= CM_DESAT1 && cm <= CM_DESAT31) + { + gl_Desaturate(gray, red, green, blue, red, green, blue, cm - CM_DESAT0); + } +} + + + +//========================================================================== +// +// For testing sky fog sheets +// +//========================================================================== +CCMD(skyfog) +{ + if (argv.argc()>1) + { + skyfog=strtol(argv[1],NULL,0); + } +} + diff --git a/src/gl/renderer/gl_lightdata.h b/src/gl/renderer/gl_lightdata.h new file mode 100644 index 000000000..33d179b27 --- /dev/null +++ b/src/gl/renderer/gl_lightdata.h @@ -0,0 +1,66 @@ +#ifndef __GL_LIGHTDATA +#define __GL_LIGHTDATA + +#include "v_palette.h" +#include "r_data/renderstyle.h" +#include "gl/renderer/gl_colormap.h" + +bool gl_BrightmapsActive(); +bool gl_GlowActive(); + +inline int gl_ClampLight(int lightlevel) +{ + return clamp(lightlevel, 0, 255); +} + +void gl_GetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending, + int *tm, int *sb, int *db, int *be); +void gl_SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog); + +int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon); +PalEntry gl_CalcLightColor(int light, PalEntry pe, int blendfactor, bool force = false); +void gl_GetLightColor(int lightlevel, int rellight, const FColormap * cm, float * pred, float * pgreen, float * pblue, bool weapon=false); +void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, PalEntry ThingColor = 0xffffff, bool weapon=false); +void gl_SetColor(int light, int rellight, const FColormap * cm, float *red, float *green, float *blue, PalEntry ThingColor=0xffffff, bool weapon=false); + +float gl_GetFogDensity(int lightlevel, PalEntry fogcolor); +struct sector_t; +bool gl_CheckFog(FColormap *cm, int lightlevel); +bool gl_CheckFog(sector_t *frontsector, sector_t *backsector); + +void gl_SetFog(int lightlevel, int rellight, const FColormap *cm, bool isadditive); + +inline bool gl_isBlack(PalEntry color) +{ + return color.r + color.g + color.b == 0; +} + +inline bool gl_isWhite(PalEntry color) +{ + return color.r + color.g + color.b == 3*0xff; +} + +extern DWORD gl_fixedcolormap; + +inline bool gl_isFullbright(PalEntry color, int lightlevel) +{ + return gl_fixedcolormap || (gl_isWhite(color) && lightlevel==255); +} + +__forceinline void gl_Desaturate(int gray, int ired, int igreen, int iblue, BYTE & red, BYTE & green, BYTE & blue, int fac) +{ + red = (ired*(31-fac) + gray*fac)/31; + green = (igreen*(31-fac) + gray*fac)/31; + blue = (iblue*(31-fac) + gray*fac)/31; +} + +void gl_ModifyColor(BYTE & red, BYTE & green, BYTE & blue, int cm); +void gl_DeleteAllAttachedLights(); +void gl_RecreateAllAttachedLights(); + +extern int fogdensity; +extern int outsidefogdensity; +extern int skyfog; + + +#endif \ No newline at end of file diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp new file mode 100644 index 000000000..62983f213 --- /dev/null +++ b/src/gl/renderer/gl_renderer.cpp @@ -0,0 +1,634 @@ +/* +** gl1_renderer.cpp +** Renderer interface +** +**--------------------------------------------------------------------------- +** Copyright 2008 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "r_data/r_translate.h" +#include "m_png.h" +#include "m_crc32.h" +#include "w_wad.h" +//#include "gl/gl_intern.h" +#include "gl/gl_functions.h" +#include "vectors.h" + +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_threads.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/dynlights/gl_lightbuffer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_texture.h" +#include "gl/textures/gl_translate.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_templates.h" +#include "gl/models/gl_models.h" + +//=========================================================================== +// +// Renderer interface +// +//=========================================================================== + +EXTERN_CVAR(Bool, gl_render_segs) + +//----------------------------------------------------------------------------- +// +// Initialize +// +//----------------------------------------------------------------------------- + +void FGLRenderer::Initialize() +{ + glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch); + glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch); + mirrortexture = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/mirror.png"), FTexture::TEX_MiscPatch); + gllight = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/gllight.png"), FTexture::TEX_MiscPatch); + + mVBO = new FFlatVertexBuffer; + mFBID = 0; + SetupLevel(); + mShaderManager = new FShaderManager; + //mThreadManager = new FGLThreadManager; +} + +FGLRenderer::~FGLRenderer() +{ + gl_CleanModelData(); + gl_DeleteAllAttachedLights(); + FMaterial::FlushAll(); + //if (mThreadManager != NULL) delete mThreadManager; + if (mShaderManager != NULL) delete mShaderManager; + if (mVBO != NULL) delete mVBO; + if (glpart2) delete glpart2; + if (glpart) delete glpart; + if (mirrortexture) delete mirrortexture; + if (gllight) delete gllight; + if (mFBID != 0) gl.DeleteFramebuffers(1, &mFBID); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::SetupLevel() +{ + mVBO->CreateVBO(); +} + +void FGLRenderer::Begin2D() +{ + gl_RenderState.EnableFog(false); + gl_RenderState.Set2DMode(true); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector) +{ + GLWall wall; + wall.ProcessLowerMiniseg(seg, frontsector, backsector); + rendered_lines++; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::ProcessSprite(AActor *thing, sector_t *sector) +{ + GLSprite glsprite; + glsprite.Process(thing, sector); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::ProcessParticle(particle_t *part, sector_t *sector) +{ + GLSprite glsprite; + glsprite.ProcessParticle(part, sector);//, 0, 0); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::ProcessSector(sector_t *fakesector) +{ + GLFlat glflat; + glflat.ProcessSector(fakesector); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::FlushTextures() +{ + FMaterial::FlushAll(); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +bool FGLRenderer::StartOffscreen() +{ + if (gl.flags & RFL_FRAMEBUFFER) + { + if (mFBID == 0) gl.GenFramebuffers(1, &mFBID); + gl.BindFramebuffer(GL_FRAMEBUFFER, mFBID); + return true; + } + return false; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::EndOffscreen() +{ + if (gl.flags & RFL_FRAMEBUFFER) + { + gl.BindFramebuffer(GL_FRAMEBUFFER, 0); + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +unsigned char *FGLRenderer::GetTextureBuffer(FTexture *tex, int &w, int &h) +{ + FMaterial * gltex = FMaterial::ValidateTexture(tex); + if (gltex) + { + return gltex->CreateTexBuffer(CM_DEFAULT, 0, w, h); + } + return NULL; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::ClearBorders() +{ + OpenGLFrameBuffer *glscreen = static_cast(screen); + + // Letterbox time! Draw black top and bottom borders. + int width = glscreen->GetWidth(); + int height = glscreen->GetHeight(); + int trueHeight = glscreen->GetTrueHeight(); + + int borderHeight = (trueHeight - height) / 2; + + gl.Viewport(0, 0, width, trueHeight); + gl.MatrixMode(GL_PROJECTION); + gl.LoadIdentity(); + gl.Ortho(0.0, width * 1.0, 0.0, trueHeight, -1.0, 1.0); + gl.MatrixMode(GL_MODELVIEW); + gl.Color3f(0.f, 0.f, 0.f); + gl_RenderState.Set2DMode(true); + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(true); + + gl.Begin(GL_QUADS); + // upper quad + gl.Vertex2i(0, borderHeight); + gl.Vertex2i(0, 0); + gl.Vertex2i(width, 0); + gl.Vertex2i(width, borderHeight); + + // lower quad + gl.Vertex2i(0, trueHeight); + gl.Vertex2i(0, trueHeight - borderHeight); + gl.Vertex2i(width, trueHeight - borderHeight); + gl.Vertex2i(width, trueHeight); + gl.End(); + + gl_RenderState.EnableTexture(true); + + gl.Viewport(0, (trueHeight - height) / 2, width, height); +} + +//========================================================================== +// +// Draws a texture +// +//========================================================================== + +void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) +{ + double xscale = parms.destwidth / parms.texwidth; + double yscale = parms.destheight / parms.texheight; + double x = parms.x - parms.left * xscale; + double y = parms.y - parms.top * yscale; + double w = parms.destwidth; + double h = parms.destheight; + float u1, v1, u2, v2, r, g, b; + float light = 1.f; + + FMaterial * gltex = FMaterial::ValidateTexture(img); + + if (parms.colorOverlay && (parms.colorOverlay & 0xffffff) == 0) + { + // Right now there's only black. Should be implemented properly later + light = 1.f - APART(parms.colorOverlay)/255.f; + parms.colorOverlay = 0; + } + + if (!img->bHasCanvas) + { + if (!parms.alphaChannel) + { + int translation = 0; + if (parms.remap != NULL && !parms.remap->Inactive) + { + GLTranslationPalette * pal = static_cast(parms.remap->GetNative()); + if (pal) translation = -pal->GetIndex(); + } + gltex->BindPatch(CM_DEFAULT, translation); + } + else + { + // This is an alpha texture + gltex->BindPatch(CM_SHADE, 0); + } + + u1 = gltex->GetUL(); + v1 = gltex->GetVT(); + u2 = gltex->GetUR(); + v2 = gltex->GetVB(); + } + else + { + gltex->Bind(CM_DEFAULT, 0, 0); + u2=1.f; + v2=-1.f; + u1 = v1 = 0.f; + gl_RenderState.SetTextureMode(TM_OPAQUE); + } + + if (parms.flipX) + { + float temp = u1; + u1 = u2; + u2 = temp; + } + + + if (parms.windowleft > 0 || parms.windowright < parms.texwidth) + { + x += parms.windowleft * xscale; + w -= (parms.texwidth - parms.windowright + parms.windowleft) * xscale; + + u1 = float(u1 + parms.windowleft / parms.texwidth); + u2 = float(u2 - (parms.texwidth - parms.windowright) / parms.texwidth); + } + + if (parms.style.Flags & STYLEF_ColorIsFixed) + { + r = RPART(parms.fillcolor)/255.0f; + g = GPART(parms.fillcolor)/255.0f; + b = BPART(parms.fillcolor)/255.0f; + } + else + { + r = g = b = light; + } + + // scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates + int btm = (SCREENHEIGHT - screen->GetHeight()) / 2; + btm = SCREENHEIGHT - btm; + + gl.Enable(GL_SCISSOR_TEST); + int space = (static_cast(screen)->GetTrueHeight()-screen->GetHeight())/2; + gl.Scissor(parms.lclip, btm - parms.dclip + space, parms.rclip - parms.lclip, parms.dclip - parms.uclip); + + gl_SetRenderStyle(parms.style, !parms.masked, false); + if (img->bHasCanvas) + { + gl_RenderState.SetTextureMode(TM_OPAQUE); + } + + gl.Color4f(r, g, b, FIXED2FLOAT(parms.alpha)); + + gl_RenderState.EnableAlphaTest(false); + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_STRIP); + gl.TexCoord2f(u1, v1); + glVertex2d(x, y); + gl.TexCoord2f(u1, v2); + glVertex2d(x, y + h); + gl.TexCoord2f(u2, v1); + glVertex2d(x + w, y); + gl.TexCoord2f(u2, v2); + glVertex2d(x + w, y + h); + gl.End(); + + if (parms.colorOverlay) + { + gl_RenderState.SetTextureMode(TM_MASK); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.Apply(); + gl.Color4ub(RPART(parms.colorOverlay),GPART(parms.colorOverlay),BPART(parms.colorOverlay),APART(parms.colorOverlay)); + gl.Begin(GL_TRIANGLE_STRIP); + gl.TexCoord2f(u1, v1); + glVertex2d(x, y); + gl.TexCoord2f(u1, v2); + glVertex2d(x, y + h); + gl.TexCoord2f(u2, v1); + glVertex2d(x + w, y); + gl.TexCoord2f(u2, v2); + glVertex2d(x + w, y + h); + gl.End(); + } + + gl_RenderState.EnableAlphaTest(true); + + gl.Scissor(0, 0, screen->GetWidth(), screen->GetHeight()); + gl.Disable(GL_SCISSOR_TEST); + gl_RenderState.SetTextureMode(TM_MODULATE); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.BlendEquation(GL_FUNC_ADD); +} + +//========================================================================== +// +// +// +//========================================================================== +void FGLRenderer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color) +{ + PalEntry p = color? (PalEntry)color : GPalette.BaseColors[palcolor]; + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(true); + gl.Color3ub(p.r, p.g, p.b); + gl.Begin(GL_LINES); + gl.Vertex2i(x1, y1); + gl.Vertex2i(x2, y2); + gl.End(); + gl_RenderState.EnableTexture(true); +} + +//========================================================================== +// +// +// +//========================================================================== +void FGLRenderer::DrawPixel(int x1, int y1, int palcolor, uint32 color) +{ + PalEntry p = color? (PalEntry)color : GPalette.BaseColors[palcolor]; + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(true); + gl.Color3ub(p.r, p.g, p.b); + gl.Begin(GL_POINTS); + gl.Vertex2i(x1, y1); + gl.End(); + gl_RenderState.EnableTexture(true); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::Dim(PalEntry color, float damount, int x1, int y1, int w, int h) +{ + float r, g, b; + + gl_RenderState.EnableTexture(false); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.AlphaFunc(GL_GREATER,0); + gl_RenderState.Apply(true); + + r = color.r/255.0f; + g = color.g/255.0f; + b = color.b/255.0f; + + gl.Begin(GL_TRIANGLE_FAN); + gl.Color4f(r, g, b, damount); + gl.Vertex2i(x1, y1); + gl.Vertex2i(x1, y1 + h); + gl.Vertex2i(x1 + w, y1 + h); + gl.Vertex2i(x1 + w, y1); + gl.End(); + + gl_RenderState.EnableTexture(true); +} + +//========================================================================== +// +// +// +//========================================================================== +void FGLRenderer::FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin) +{ + float fU1,fU2,fV1,fV2; + + FMaterial *gltexture=FMaterial::ValidateTexture(src); + + if (!gltexture) return; + + gltexture->Bind(CM_DEFAULT, 0, 0); + + // scaling is not used here. + if (!local_origin) + { + fU1 = float(left) / src->GetWidth(); + fV1 = float(top) / src->GetHeight(); + fU2 = float(right) / src->GetWidth(); + fV2 = float(bottom) / src->GetHeight(); + } + else + { + fU1 = 0; + fV1 = 0; + fU2 = float(right-left) / src->GetWidth(); + fV2 = float(bottom-top) / src->GetHeight(); + } + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_STRIP); + gl.Color4f(1, 1, 1, 1); + gl.TexCoord2f(fU1, fV1); gl.Vertex2f(left, top); + gl.TexCoord2f(fU1, fV2); gl.Vertex2f(left, bottom); + gl.TexCoord2f(fU2, fV1); gl.Vertex2f(right, top); + gl.TexCoord2f(fU2, fV2); gl.Vertex2f(right, bottom); + gl.End(); +} + +//========================================================================== +// +// +// +//========================================================================== +void FGLRenderer::Clear(int left, int top, int right, int bottom, int palcolor, uint32 color) +{ + int rt; + int offY = 0; + PalEntry p = palcolor==-1 || color != 0? (PalEntry)color : GPalette.BaseColors[palcolor]; + int width = right-left; + int height= bottom-top; + + + rt = screen->GetHeight() - top; + + int space = (static_cast(screen)->GetTrueHeight()-screen->GetHeight())/2; // ugh... + rt += space; + /* + if (!m_windowed && (m_trueHeight != m_height)) + { + offY = (m_trueHeight - m_height) / 2; + rt += offY; + } + */ + + gl.Enable(GL_SCISSOR_TEST); + gl.Scissor(left, rt - height, width, height); + + gl.ClearColor(p.r/255.0f, p.g/255.0f, p.b/255.0f, 0.f); + gl.Clear(GL_COLOR_BUFFER_BIT); + gl.ClearColor(0.f, 0.f, 0.f, 0.f); + + gl.Disable(GL_SCISSOR_TEST); +} + +//========================================================================== +// +// D3DFB :: FillSimplePoly +// +// Here, "simple" means that a simple triangle fan can draw it. +// +//========================================================================== + +void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, + double originx, double originy, double scalex, double scaley, + angle_t rotation, FDynamicColormap *colormap, int lightlevel) +{ + if (npoints < 3) + { // This is no polygon. + return; + } + + FMaterial *gltexture = FMaterial::ValidateTexture(texture); + + if (gltexture == NULL) + { + return; + } + + FColormap cm; + cm = colormap; + + lightlevel = gl_CalcLightLevel(lightlevel, 0, true); + PalEntry pe = gl_CalcLightColor(lightlevel, cm.LightColor, cm.blendfactor, true); + gl.Color3ub(pe.r, pe.g, pe.b); + + gltexture->Bind(cm.colormap); + + int i; + float rot = float(rotation * M_PI / float(1u << 31)); + bool dorotate = rot != 0; + + float cosrot = cos(rot); + float sinrot = sin(rot); + + //float yoffs = GatheringWipeScreen ? 0 : LBOffset; + float uscale = float(1.f / (texture->GetScaledWidth() * scalex)); + float vscale = float(1.f / (texture->GetScaledHeight() * scaley)); + if (gltexture->tex->bHasCanvas) + { + vscale = 0 - vscale; + } + float ox = float(originx); + float oy = float(originy); + + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_FAN); + for (i = 0; i < npoints; ++i) + { + float u = points[i].X - 0.5f - ox; + float v = points[i].Y - 0.5f - oy; + if (dorotate) + { + float t = u; + u = t * cosrot - v * sinrot; + v = v * cosrot + t * sinrot; + } + gl.TexCoord2f(u * uscale, v * vscale); + gl.Vertex3f(points[i].X, points[i].Y /* + yoffs */, 0); + } + gl.End(); +} + diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h new file mode 100644 index 000000000..f1b39fc46 --- /dev/null +++ b/src/gl/renderer/gl_renderer.h @@ -0,0 +1,178 @@ +#ifndef __GL_RENDERER_H +#define __GL_RENDERER_H + +#include "r_defs.h" +#include "v_video.h" +#include "vectors.h" +#include "r_renderer.h" + +struct particle_t; +class FCanvasTexture; +class FFlatVertexBuffer; +class OpenGLFrameBuffer; +struct FDrawInfo; +struct pspdef_t; +class FShaderManager; +class GLPortal; +class FGLThreadManager; + +enum SectorRenderFlags +{ + // This is used to avoid creating too many drawinfos + SSRF_RENDERFLOOR = 1, + SSRF_RENDERCEILING = 2, + SSRF_RENDER3DPLANES = 4, + SSRF_RENDERALL = 7, + SSRF_PROCESSED = 8, + SSRF_SEEN = 16, +}; + +struct GL_IRECT +{ + int left,top; + int width,height; + + + void Offset(int xofs,int yofs) + { + left+=xofs; + top+=yofs; + } +}; + + +class FGLRenderer +{ +public: + + OpenGLFrameBuffer *framebuffer; + GLPortal *mCurrentPortal; + int mMirrorCount; + int mPlaneMirrorCount; + int mLightCount; + float mCurrentFoV; + AActor *mViewActor; + FShaderManager *mShaderManager; + FGLThreadManager *mThreadManager; + int gl_spriteindex; + unsigned int mFBID; + + FTexture *glpart2; + FTexture *glpart; + FTexture *mirrortexture; + FTexture *gllight; + + float mSky1Pos, mSky2Pos; + + FRotator mAngles; + FVector2 mViewVector; + FVector3 mCameraPos; + + FFlatVertexBuffer *mVBO; + + + FGLRenderer(OpenGLFrameBuffer *fb) + { + framebuffer = fb; + mCurrentPortal = NULL; + mMirrorCount = 0; + mPlaneMirrorCount = 0; + mLightCount = 0; + mAngles = FRotator(0,0,0); + mViewVector = FVector2(0,0); + mCameraPos = FVector3(0,0,0); + mVBO = NULL; + gl_spriteindex = 0; + mShaderManager = NULL; + glpart2 = glpart = gllight = mirrortexture = NULL; + } + ~FGLRenderer() ; + + angle_t FrustumAngle(); + void SetViewArea(); + void ResetViewport(); + void SetViewport(GL_IRECT *bounds); + sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen); + void RenderView(player_t *player); + void SetCameraPos(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle); + void SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror); + + void Initialize(); + + void CreateScene(); + void RenderScene(int recursion); + void RenderTranslucent(); + void DrawScene(bool toscreen = false); + void DrawBlend(sector_t * viewsector); + + void DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, int cm_index, bool hudModelStep, int OverrideShader); + void DrawPlayerSprites(sector_t * viewsector, bool hudModelStep); + void DrawTargeterSprites(); + + void Begin2D(); + void ClearBorders(); + void DrawTexture(FTexture *img, DCanvas::DrawParms &parms); + void DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color); + void DrawPixel(int x1, int y1, int palcolor, uint32 color); + void Dim(PalEntry color, float damount, int x1, int y1, int w, int h); + void FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin); + void Clear(int left, int top, int right, int bottom, int palcolor, uint32 color); + + void ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector); + void ProcessSprite(AActor *thing, sector_t *sector); + void ProcessParticle(particle_t *part, sector_t *sector); + void ProcessSector(sector_t *fakesector); + void FlushTextures(); + unsigned char *GetTextureBuffer(FTexture *tex, int &w, int &h); + void SetupLevel(); + + void SetFixedColormap (player_t *player); + void WriteSavePic (player_t *player, FILE *file, int width, int height); + void EndDrawScene(sector_t * viewsector); + void Flush() {} + + void SetProjection(float fov, float ratio, float fovratio); + void SetViewMatrix(bool mirror, bool planemirror); + void ProcessScene(bool toscreen = false); + + bool StartOffscreen(); + void EndOffscreen(); + + void FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, + double originx, double originy, double scalex, double scaley, + angle_t rotation, FDynamicColormap *colormap, int lightlevel); +}; + +// Global functions. Make them members of GLRenderer later? +void gl_RenderBSPNode (void *node); +bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsector); +void gl_CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector); + +typedef enum +{ + area_normal, + area_below, + area_above, + area_default +} area_t; + +extern area_t in_area; + + +sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back); +inline sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, bool back) +{ + return gl_FakeFlat(sec, dest, in_area, back); +} + +struct TexFilter_s +{ + int minfilter; + int magfilter; + bool mipmapping; +} ; + + +extern FGLRenderer *GLRenderer; + +#endif \ No newline at end of file diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp new file mode 100644 index 000000000..31c46bc8a --- /dev/null +++ b/src/gl/renderer/gl_renderstate.cpp @@ -0,0 +1,352 @@ +/* +** gl_renderstate.cpp +** Render state maintenance +** +**--------------------------------------------------------------------------- +** Copyright 2009 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "gl/data/gl_data.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_shader.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_colormap.h" + +FRenderState gl_RenderState; +int FStateAttr::ChangeCounter; + +CVAR(Bool, gl_direct_state_change, true, 0) + + +//========================================================================== +// +// +// +//========================================================================== + +void FRenderState::Reset() +{ + mTextureEnabled = true; + mBrightmapEnabled = mFogEnabled = mGlowEnabled = mLightEnabled = false; + ffTextureEnabled = ffFogEnabled = false; + mSpecialEffect = ffSpecialEffect = EFF_NONE; + mFogColor.d = ffFogColor.d = -1; + mFogDensity = ffFogDensity = 0; + mTextureMode = ffTextureMode = -1; + mSrcBlend = GL_SRC_ALPHA; + mDstBlend = GL_ONE_MINUS_SRC_ALPHA; + glSrcBlend = glDstBlend = -1; + glAlphaFunc = -1; + mAlphaFunc = GL_GEQUAL; + mAlphaThreshold = 0.5f; + mBlendEquation = GL_FUNC_ADD; + glBlendEquation = -1; + m2D = true; +} + + +//========================================================================== +// +// Set texture shader info +// +//========================================================================== + +int FRenderState::SetupShader(bool cameratexture, int &shaderindex, int &cm, float warptime) +{ + bool usecmshader; + int softwarewarp = 0; + + if (shaderindex == 3) + { + // Brightmap should not be used. + if (!mBrightmapEnabled || cm >= CM_FIRSTSPECIALCOLORMAP) + { + shaderindex = 0; + } + } + + if (gl.shadermodel == 4) + { + usecmshader = cm > CM_DEFAULT && cm < CM_MAXCOLORMAP && mTextureMode != TM_MASK; + } + else if (gl.shadermodel == 3) + { + usecmshader = (cameratexture || gl_colormap_shader) && + cm > CM_DEFAULT && cm < CM_MAXCOLORMAP && mTextureMode != TM_MASK; + + if (!gl_brightmap_shader && shaderindex == 3) + { + shaderindex = 0; + } + else if (!gl_warp_shader && shaderindex !=3) + { + if (shaderindex <= 2) softwarewarp = shaderindex; + shaderindex = 0; + } + } + else + { + usecmshader = cameratexture; + softwarewarp = shaderindex > 0 && shaderindex < 3? shaderindex : 0; + shaderindex = 0; + } + + mEffectState = shaderindex; + mColormapState = usecmshader? cm : CM_DEFAULT; + if (usecmshader) cm = CM_DEFAULT; + mWarpTime = warptime; + return softwarewarp; +} + + +//========================================================================== +// +// Apply shader settings +// +//========================================================================== + +bool FRenderState::ApplyShader() +{ + bool useshaders = false; + FShader *activeShader = NULL; + + if (mSpecialEffect > 0 && gl.shadermodel > 2) + { + activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect); + } + else + { + switch (gl.shadermodel) + { + case 2: + useshaders = (mTextureEnabled && mColormapState != CM_DEFAULT); + break; + + case 3: + useshaders = ( + mEffectState != 0 || // special shaders + (mFogEnabled && (gl_fogmode == 2 || gl_fog_shader) && gl_fogmode != 0) || // fog requires a shader + (mTextureEnabled && (mEffectState != 0 || mColormapState)) || // colormap + mGlowEnabled // glow requires a shader + ); + break; + + case 4: + useshaders = (!m2D || mEffectState != 0 || mColormapState); // all 3D rendering and 2D with texture effects. + break; + + default: + break; + } + + if (useshaders) + { + FShaderContainer *shd = GLRenderer->mShaderManager->Get(mTextureEnabled? mEffectState : 4); + + if (shd != NULL) + { + activeShader = shd->Bind(mColormapState, mGlowEnabled, mWarpTime, mLightEnabled); + } + } + } + + if (activeShader) + { + int fogset = 0; + if (mFogEnabled) + { + if ((mFogColor & 0xffffff) == 0) + { + fogset = gl_fogmode; + } + else + { + fogset = -gl_fogmode; + } + } + + if (fogset != activeShader->currentfogenabled) + { + gl.Uniform1i(activeShader->fogenabled_index, (activeShader->currentfogenabled = fogset)); + } + if (mTextureMode != activeShader->currenttexturemode) + { + gl.Uniform1i(activeShader->texturemode_index, (activeShader->currenttexturemode = mTextureMode)); + } + if (activeShader->currentcamerapos.Update(&mCameraPos)) + { + gl.Uniform3fv(activeShader->camerapos_index, 1, mCameraPos.vec); + } + /*if (mLightParms[0] != activeShader->currentlightfactor || + mLightParms[1] != activeShader->currentlightdist || + mFogDensity != activeShader->currentfogdensity)*/ + { + const float LOG2E = 1.442692f; // = 1/log(2) + //activeShader->currentlightdist = mLightParms[1]; + //activeShader->currentlightfactor = mLightParms[0]; + //activeShader->currentfogdensity = mFogDensity; + // premultiply the density with as much as possible here to reduce shader + // execution time. + gl.VertexAttrib4f(VATTR_FOGPARAMS, mLightParms[0], mLightParms[1], mFogDensity * (-LOG2E / 64000.f), 0); + } + if (mFogColor != activeShader->currentfogcolor) + { + activeShader->currentfogcolor = mFogColor; + + gl.Uniform4f (activeShader->fogcolor_index, mFogColor.r/255.f, mFogColor.g/255.f, + mFogColor.b/255.f, 0); + } + if (mGlowEnabled) + { + gl.Uniform4fv(activeShader->glowtopcolor_index, 1, mGlowTop.vec); + gl.Uniform4fv(activeShader->glowbottomcolor_index, 1, mGlowBottom.vec); + } + if (mLightEnabled) + { + gl.Uniform3iv(activeShader->lightrange_index, 1, mNumLights); + gl.Uniform4fv(activeShader->lights_index, mNumLights[2], mLightData); + } + if (glset.lightmode == 8) + { + gl.Uniform3fv(activeShader->dlightcolor_index, 1, mDynLight); + } + + return true; + } + return false; +} + + +//========================================================================== +// +// Apply State +// +//========================================================================== + +void FRenderState::Apply(bool forcenoshader) +{ + if (!gl_direct_state_change) + { + if (mSrcBlend != glSrcBlend || mDstBlend != glDstBlend) + { + glSrcBlend = mSrcBlend; + glDstBlend = mDstBlend; + glBlendFunc(mSrcBlend, mDstBlend); + } + if (mAlphaFunc != glAlphaFunc || mAlphaThreshold != glAlphaThreshold) + { + glAlphaFunc = mAlphaFunc; + glAlphaThreshold = mAlphaThreshold; + ::glBlendFunc(mAlphaFunc, mAlphaThreshold); + } + if (mAlphaTest != glAlphaTest) + { + glAlphaTest = mAlphaTest; + if (mAlphaTest) glEnable(GL_ALPHA_TEST); + else glDisable(GL_ALPHA_TEST); + } + if (mBlendEquation != glBlendEquation) + { + glBlendEquation = mBlendEquation; + gl.BlendEquation(mBlendEquation); + } + } + + if (forcenoshader || !ApplyShader()) + { + GLRenderer->mShaderManager->SetActiveShader(NULL); + if (mTextureMode != ffTextureMode) + { + gl.SetTextureMode((ffTextureMode = mTextureMode)); + } + if (mTextureEnabled != ffTextureEnabled) + { + if ((ffTextureEnabled = mTextureEnabled)) gl.Enable(GL_TEXTURE_2D); + else gl.Disable(GL_TEXTURE_2D); + } + if (mFogEnabled != ffFogEnabled) + { + if ((ffFogEnabled = mFogEnabled)) + { + gl.Enable(GL_FOG); + } + else gl.Disable(GL_FOG); + } + if (mFogEnabled) + { + if (ffFogColor != mFogColor) + { + ffFogColor = mFogColor; + GLfloat FogColor[4]={mFogColor.r/255.0f,mFogColor.g/255.0f,mFogColor.b/255.0f,0.0f}; + gl.Fogfv(GL_FOG_COLOR, FogColor); + } + if (ffFogDensity != mFogDensity) + { + gl.Fogf(GL_FOG_DENSITY, mFogDensity/64000.f); + ffFogDensity=mFogDensity; + } + } + if (mSpecialEffect != ffSpecialEffect) + { + switch (ffSpecialEffect) + { + case EFF_SPHEREMAP: + gl.Disable(GL_TEXTURE_GEN_T); + gl.Disable(GL_TEXTURE_GEN_S); + + default: + break; + } + switch (mSpecialEffect) + { + case EFF_SPHEREMAP: + // Use sphere mapping for this + gl.Enable(GL_TEXTURE_GEN_T); + gl.Enable(GL_TEXTURE_GEN_S); + gl.TexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP); + gl.TexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP); + break; + + default: + break; + } + ffSpecialEffect = mSpecialEffect; + } + } + +} + diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h new file mode 100644 index 000000000..e8a4d1940 --- /dev/null +++ b/src/gl/renderer/gl_renderstate.h @@ -0,0 +1,278 @@ +#ifndef __GL_RENDERSTATE_H +#define __GL_RENDERSTATE_H + +#include +#include "c_cvars.h" + +EXTERN_CVAR(Bool, gl_direct_state_change) + +struct FStateAttr +{ + static int ChangeCounter; + int mLastChange; + + FStateAttr() + { + mLastChange = -1; + } + + bool operator == (const FStateAttr &other) + { + return mLastChange == other.mLastChange; + } + + bool operator != (const FStateAttr &other) + { + return mLastChange != other.mLastChange; + } + +}; + +struct FStateVec3 : public FStateAttr +{ + float vec[3]; + + bool Update(FStateVec3 *other) + { + if (mLastChange != other->mLastChange) + { + *this = *other; + return true; + } + return false; + } + + void Set(float x, float y, float z) + { + vec[0] = x; + vec[1] = z; + vec[2] = y; + mLastChange = ++ChangeCounter; + } +}; + +struct FStateVec4 : public FStateAttr +{ + float vec[4]; + + bool Update(FStateVec4 *other) + { + if (mLastChange != other->mLastChange) + { + *this = *other; + return true; + } + return false; + } + + void Set(float r, float g, float b, float a) + { + vec[0] = r; + vec[1] = g; + vec[2] = b; + vec[3] = a; + mLastChange = ++ChangeCounter; + } +}; + + +enum EEffect +{ + EFF_NONE, + EFF_FOGBOUNDARY, + EFF_SPHEREMAP, +}; + +class FRenderState +{ + bool mTextureEnabled; + bool mFogEnabled; + bool mGlowEnabled; + bool mLightEnabled; + bool mBrightmapEnabled; + int mSpecialEffect; + int mTextureMode; + float mDynLight[3]; + float mLightParms[2]; + int mNumLights[3]; + float *mLightData; + int mSrcBlend, mDstBlend; + int mAlphaFunc; + float mAlphaThreshold; + bool mAlphaTest; + int mBlendEquation; + bool m2D; + + FStateVec3 mCameraPos; + FStateVec4 mGlowTop, mGlowBottom; + PalEntry mFogColor; + float mFogDensity; + + int mEffectState; + int mColormapState; + float mWarpTime; + + int glSrcBlend, glDstBlend; + int glAlphaFunc; + float glAlphaThreshold; + bool glAlphaTest; + int glBlendEquation; + + bool ffTextureEnabled; + bool ffFogEnabled; + int ffTextureMode; + int ffSpecialEffect; + PalEntry ffFogColor; + float ffFogDensity; + + bool ApplyShader(); + +public: + FRenderState() + { + Reset(); + } + + void Reset(); + + int SetupShader(bool cameratexture, int &shaderindex, int &cm, float warptime); + void Apply(bool forcenoshader = false); + + void SetTextureMode(int mode) + { + mTextureMode = mode; + } + + void EnableTexture(bool on) + { + mTextureEnabled = on; + } + + void EnableFog(bool on) + { + mFogEnabled = on; + } + + void SetEffect(int eff) + { + mSpecialEffect = eff; + } + + void EnableGlow(bool on) + { + mGlowEnabled = on; + } + + void EnableLight(bool on) + { + mLightEnabled = on; + } + + void EnableBrightmap(bool on) + { + mBrightmapEnabled = on; + } + + void SetCameraPos(float x, float y, float z) + { + mCameraPos.Set(x,y,z); + } + + void SetGlowParams(float *t, float *b) + { + mGlowTop.Set(t[0], t[1], t[2], t[3]); + mGlowBottom.Set(b[0], b[1], b[2], b[3]); + } + + void SetDynLight(float r,float g, float b) + { + mDynLight[0] = r; + mDynLight[1] = g; + mDynLight[2] = b; + } + + void SetFog(PalEntry c, float d) + { + mFogColor = c; + if (d >= 0.0f) mFogDensity = d; + } + + void SetLightParms(float f, float d) + { + mLightParms[0] = f; + mLightParms[1] = d; + } + + void SetLights(int *numlights, float *lightdata) + { + mNumLights[0] = numlights[0]; + mNumLights[1] = numlights[1]; + mNumLights[2] = numlights[2]; + mLightData = lightdata; // caution: the data must be preserved by the caller until the 'apply' call! + } + + PalEntry GetFogColor() const + { + return mFogColor; + } + + void BlendFunc(int src, int dst) + { + if (!gl_direct_state_change) + { + mSrcBlend = src; + mDstBlend = dst; + } + else + { + glBlendFunc(src, dst); + } + } + + void AlphaFunc(int func, float thresh) + { + if (!gl_direct_state_change) + { + mAlphaFunc = func; + mAlphaThreshold = thresh; + } + else + { + ::glAlphaFunc(func, thresh); + } + } + + void EnableAlphaTest(bool on) + { + if (!gl_direct_state_change) + { + mAlphaTest = on; + } + else + { + if (on) glEnable(GL_ALPHA_TEST); + else glDisable(GL_ALPHA_TEST); + } + } + + void BlendEquation(int eq) + { + if (!gl_direct_state_change) + { + mBlendEquation = eq; + } + else + { + gl.BlendEquation(eq); + } + } + + void Set2DMode(bool on) + { + m2D = on; + } +}; + +extern FRenderState gl_RenderState; + +#endif diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp new file mode 100644 index 000000000..b8a1eeec0 --- /dev/null +++ b/src/gl/scene/gl_bsp.cpp @@ -0,0 +1,563 @@ +/* +** gl_bsp.cpp +** Main rendering loop / BSP traversal / visibility clipping +** +**--------------------------------------------------------------------------- +** Copyright 2000-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "p_lnspec.h" +#include "p_local.h" +#include "a_sharedglobal.h" +#include "r_sky.h" +#include "p_effect.h" +#include "po_man.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/scene/gl_clipper.h" +#include "gl/scene/gl_portal.h" +#include "gl/scene/gl_wall.h" +#include "gl/utility/gl_clock.h" + +EXTERN_CVAR(Bool, gl_render_segs) + +Clipper clipper; + + +CVAR(Bool, gl_render_things, true, 0) +CVAR(Bool, gl_render_walls, true, 0) +CVAR(Bool, gl_render_flats, true, 0) + + +static void UnclipSubsector(subsector_t *sub) +{ + int count = sub->numlines; + seg_t * seg = sub->firstline; + + while (count--) + { + angle_t startAngle = seg->v2->GetClipAngle(); + angle_t endAngle = seg->v1->GetClipAngle(); + + // Back side, i.e. backface culling - read: endAngle >= startAngle! + if (startAngle-endAngle >= ANGLE_180) + { + clipper.SafeRemoveClipRange(startAngle, endAngle); + } + seg++; + } +} + +//========================================================================== +// +// R_AddLine +// Clips the given segment +// and adds any visible pieces to the line list. +// +//========================================================================== + +// making these 2 variables global instead of passing them as function parameters is faster. +static subsector_t *currentsubsector; +static sector_t *currentsector; + +static void AddLine (seg_t *seg) +{ +#ifdef _MSC_VER +#ifdef _DEBUG + if (seg->linedef-lines==38) + __asm nop +#endif +#endif + + angle_t startAngle, endAngle; + sector_t * backsector = NULL; + sector_t bs; + + if (GLRenderer->mCurrentPortal) + { + int clipres = GLRenderer->mCurrentPortal->ClipSeg(seg); + if (clipres == GLPortal::PClip_InFront) return; + } + + startAngle = seg->v2->GetClipAngle(); + endAngle = seg->v1->GetClipAngle(); + + // Back side, i.e. backface culling - read: endAngle >= startAngle! + if (startAngle-endAnglesidedef == NULL) + { + if (!(currentsubsector->flags & SSECF_DRAWN)) + { + if (clipper.SafeCheckRange(startAngle, endAngle)) + { + currentsubsector->flags |= SSECF_DRAWN; + } + } + return; + } + + if (!clipper.SafeCheckRange(startAngle, endAngle)) + { + return; + } + currentsubsector->flags |= SSECF_DRAWN; + + if (!seg->backsector) + { + clipper.SafeAddClipRange(startAngle, endAngle); + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) // Two-sided polyobjects never obstruct the view + { + if (currentsector->sectornum == seg->backsector->sectornum) + { + FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::mid)); + if (!tex || tex->UseType==FTexture::TEX_Null) + { + // nothing to do here! + seg->linedef->validcount=validcount; + return; + } + backsector=currentsector; + } + else + { + // clipping checks are only needed when the backsector is not the same as the front sector + gl_CheckViewArea(seg->v1, seg->v2, seg->frontsector, seg->backsector); + + backsector = gl_FakeFlat(seg->backsector, &bs, true); + + if (gl_CheckClip(seg->sidedef, currentsector, backsector)) + { + clipper.SafeAddClipRange(startAngle, endAngle); + } + } + } + else + { + // Backsector for polyobj segs is always the containing sector itself + backsector = currentsector; + } + + seg->linedef->flags |= ML_MAPPED; + + if ((seg->sidedef->Flags & WALLF_POLYOBJ) || seg->linedef->validcount!=validcount) + { + if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) seg->linedef->validcount=validcount; + + if (gl_render_walls) + { + SetupWall.Clock(); + + //if (!gl_multithreading) + { + GLWall wall; + wall.sub = currentsubsector; + wall.Process(seg, currentsector, backsector); + } + /* + else + { + FJob *job = new FGLJobProcessWall(currentsubsector, seg, + currentsector->sectornum, backsector != NULL? backsector->sectornum : -1); + GLRenderer->mThreadManager->AddJob(job); + } + */ + rendered_lines++; + + SetupWall.Unclock(); + } + } +} + +//========================================================================== +// +// R_Subsector +// Determine floor/ceiling planes. +// Add sprites of things in sector. +// Draw one or more line segments. +// +//========================================================================== + +static void PolySubsector(subsector_t * sub) +{ + int count = sub->numlines; + seg_t * line = sub->firstline; + + while (count--) + { + if (line->linedef) + { + AddLine (line); + } + line++; + } +} + +//========================================================================== +// +// RenderBSPNode +// Renders all subsectors below a given node, +// traversing subtree recursively. +// Just call with BSP root. +// +//========================================================================== + +static void RenderPolyBSPNode (void *node) +{ + while (!((size_t)node & 1)) // Keep going until found a subsector + { + node_t *bsp = (node_t *)node; + + // Decide which side the view point is on. + int side = R_PointOnSide(viewx, viewy, bsp); + + // Recursively divide front space (toward the viewer). + RenderPolyBSPNode (bsp->children[side]); + + // Possibly divide back space (away from the viewer). + side ^= 1; + + // It is not necessary to use the slower precise version here + if (!clipper.CheckBox(bsp->bbox[side])) + { + return; + } + + node = bsp->children[side]; + } + PolySubsector ((subsector_t *)((BYTE *)node - 1)); +} + +//========================================================================== +// +// Unlilke the software renderer this function will only draw the walls, +// not the flats. Those are handled as a whole by the parent subsector. +// +//========================================================================== + +static void AddPolyobjs(subsector_t *sub) +{ + if (sub->BSP == NULL || sub->BSP->bDirty) + { + sub->BuildPolyBSP(); + } + if (sub->BSP->Nodes.Size() == 0) + { + PolySubsector(&sub->BSP->Subsectors[0]); + } + else + { + RenderPolyBSPNode(&sub->BSP->Nodes.Last()); + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +static inline void AddLines(subsector_t * sub, sector_t * sector) +{ + currentsector = sector; + currentsubsector = sub; + + ClipWall.Clock(); + if (sub->polys != NULL) + { + AddPolyobjs(sub); + } + else + { + int count = sub->numlines; + seg_t * seg = sub->firstline; + + while (count--) + { + if (seg->linedef == NULL) + { + if (!(sub->flags & SSECF_DRAWN)) AddLine (seg); + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + AddLine (seg); + } + seg++; + } + } + ClipWall.Unclock(); +} + + +//========================================================================== +// +// R_RenderThings +// +//========================================================================== + +static inline void RenderThings(subsector_t * sub, sector_t * sector) +{ + + SetupSprite.Clock(); + sector_t * sec=sub->sector; + if (sec->thinglist != NULL) + { + //if (!gl_multithreading) + { + // Handle all things in sector. + for (AActor * thing = sec->thinglist; thing; thing = thing->snext) + { + GLRenderer->ProcessSprite(thing, sector); + } + } + /* + else if (sec->thinglist != NULL) + { + FJob *job = new FGLJobProcessSprites(sector); + GLRenderer->mThreadManager->AddJob(job); + } + */ + } + SetupSprite.Unclock(); +} + + +//========================================================================== +// +// R_Subsector +// Determine floor/ceiling planes. +// Add sprites of things in sector. +// Draw one or more line segments. +// +//========================================================================== + +static void DoSubsector(subsector_t * sub) +{ + unsigned int i; + sector_t * sector; + sector_t * fakesector; + sector_t fake; + + // check for visibility of this entire subsector. This requires GL nodes. + // (disabled because it costs more time than it saves.) + //if (!clipper.CheckBox(sub->bbox)) return; + + +#ifdef _MSC_VER +#ifdef _DEBUG + if (sub->sector-sectors==931) + { + __asm nop + } +#endif +#endif + + sector=sub->sector; + if (!sector) return; + + // If the mapsections differ this subsector can't possibly be visible from the current view point + if (!(currentmapsection[sub->mapsection>>3] & (1 << (sub->mapsection & 7)))) return; + + if (gl_drawinfo->ss_renderflags[sub-subsectors] & SSRF_SEEN) + { + // This means that we have reached a subsector in a portal that has been marked 'seen' + // from the other side of the portal. This means we must clear the clipper for the + // range this subsector spans before going on. + UnclipSubsector(sub); + } + + fakesector=gl_FakeFlat(sector, &fake, false); + + if (sector->validcount != validcount) + { + GLRenderer->mVBO->CheckUpdate(sector); + } + + // [RH] Add particles + //int shade = LIGHT2SHADE((floorlightlevel + ceilinglightlevel)/2 + r_actualextralight); + if (gl_render_things) + { + SetupSprite.Clock(); + + //if (!gl_multithreading) + { + for (i = ParticlesInSubsec[DWORD(sub-subsectors)]; i != NO_PARTICLE; i = Particles[i].snext) + { + GLRenderer->ProcessParticle(&Particles[i], fakesector); + } + } + /* + else if (ParticlesInSubsec[DWORD(sub-subsectors)] != NO_PARTICLE) + { + FJob job = new FGLJobProcessParticles(sub); + GLRenderer->mThreadManager->AddJob(job); + } + */ + SetupSprite.Unclock(); + } + + AddLines(sub, fakesector); + + // BSP is traversed by subsector. + // A sector might have been split into several + // subsectors during BSP building. + // Thus we check whether it was already added. + if (sector->validcount != validcount) + { + // Well, now it will be done. + sector->validcount = validcount; + + if (gl_render_things) + { + RenderThings(sub, fakesector); + } + sector->MoreFlags |= SECF_DRAWN; + } + + if (gl_render_flats) + { + // Subsectors with only 2 lines cannot have any area! + if (sub->numlines>2 || (sub->hacked&1)) + { + // Exclude the case when it tries to render a sector with a heightsec + // but undetermined heightsec state. This can only happen if the + // subsector is obstructed but not excluded due to a large bounding box. + // Due to the way a BSP works such a subsector can never be visible + if (!sector->heightsec || sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC || in_area!=area_default) + { + if (sector != sub->render_sector) + { + sector = sub->render_sector; + // the planes of this subsector are faked to belong to another sector + // This means we need the heightsec parts and light info of the render sector, not the actual one. + fakesector = gl_FakeFlat(sector, &fake, false); + } + + BYTE &srf = gl_drawinfo->sectorrenderflags[sub->render_sector->sectornum]; + if (!(srf & SSRF_PROCESSED)) + { + srf |= SSRF_PROCESSED; + + SetupFlat.Clock(); + //if (!gl_multithreading) + { + GLRenderer->ProcessSector(fakesector); + } + /* + else + { + FJob *job = new FGLJobProcessFlats(sub); + GLRenderer->mThreadManager->AddJob(job); + } + */ + SetupFlat.Unclock(); + } + // mark subsector as processed - but mark for rendering only if it has an actual area. + gl_drawinfo->ss_renderflags[sub-subsectors] = + (sub->numlines > 2) ? SSRF_PROCESSED|SSRF_RENDERALL : SSRF_PROCESSED; + if (sub->hacked & 1) gl_drawinfo->AddHackedSubsector(sub); + + FPortal *portal; + + portal = fakesector->portals[sector_t::ceiling]; + if (portal != NULL) + { + GLSectorStackPortal *glportal = portal->GetGLPortal(); + glportal->AddSubsector(sub); + } + + portal = fakesector->portals[sector_t::floor]; + if (portal != NULL) + { + GLSectorStackPortal *glportal = portal->GetGLPortal(); + glportal->AddSubsector(sub); + } + } + } + } +} + + + + +//========================================================================== +// +// RenderBSPNode +// Renders all subsectors below a given node, +// traversing subtree recursively. +// Just call with BSP root. +// +//========================================================================== + +void gl_RenderBSPNode (void *node) +{ + if (numnodes == 0) + { + DoSubsector (subsectors); + return; + } + while (!((size_t)node & 1)) // Keep going until found a subsector + { + node_t *bsp = (node_t *)node; + + // Decide which side the view point is on. + int side = R_PointOnSide(viewx, viewy, bsp); + + // Recursively divide front space (toward the viewer). + gl_RenderBSPNode (bsp->children[side]); + + // Possibly divide back space (away from the viewer). + side ^= 1; + + // It is not necessary to use the slower precise version here + if (!clipper.CheckBox(bsp->bbox[side])) + { + if (!(gl_drawinfo->no_renderflags[bsp-nodes] & SSRF_SEEN)) + return; + } + + node = bsp->children[side]; + } + DoSubsector ((subsector_t *)((BYTE *)node - 1)); +} + + diff --git a/src/gl/scene/gl_clipper.cpp b/src/gl/scene/gl_clipper.cpp new file mode 100644 index 000000000..c6f8d9019 --- /dev/null +++ b/src/gl/scene/gl_clipper.cpp @@ -0,0 +1,458 @@ +/* +* +** gl_clipper.cpp +** +** Handles visibility checks. +** Loosely based on the JDoom clipper. +** +**--------------------------------------------------------------------------- +** Copyright 2003 Tim Stump +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/scene/gl_clipper.h" + + + +ClipNode * ClipNode::freelist; +int Clipper::anglecache; + + +//----------------------------------------------------------------------------- +// +// Destructor +// +//----------------------------------------------------------------------------- + +Clipper::~Clipper() +{ + Clear(); + while (ClipNode::freelist != NULL) + { + ClipNode * node = ClipNode::freelist; + ClipNode::freelist = node->next; + delete node; + } +} + +//----------------------------------------------------------------------------- +// +// RemoveRange +// +//----------------------------------------------------------------------------- + +void Clipper::RemoveRange(ClipNode * range) +{ + if (range == cliphead) + { + cliphead = cliphead->next; + } + else + { + if (range->prev) range->prev->next = range->next; + if (range->next) range->next->prev = range->prev; + } + + range->Free(); +} + +//----------------------------------------------------------------------------- +// +// Clear +// +//----------------------------------------------------------------------------- + +void Clipper::Clear() +{ + ClipNode *node = cliphead; + ClipNode *temp; + + while (node != NULL) + { + temp = node; + node = node->next; + temp->Free(); + } + node = silhouette; + + while (node != NULL) + { + temp = node; + node = node->next; + temp->Free(); + } + + cliphead = NULL; + silhouette = NULL; + anglecache++; +} + +//----------------------------------------------------------------------------- +// +// SetSilhouette +// +//----------------------------------------------------------------------------- + +void Clipper::SetSilhouette() +{ + ClipNode *node = cliphead; + ClipNode *last = NULL; + + while (node != NULL) + { + ClipNode *snode = ClipNode::NewRange(node->start, node->end); + if (silhouette == NULL) silhouette = snode; + snode->prev = last; + if (last != NULL) last->next = snode; + last = snode; + node = node->next; + } +} + + +//----------------------------------------------------------------------------- +// +// IsRangeVisible +// +//----------------------------------------------------------------------------- + +bool Clipper::IsRangeVisible(angle_t startAngle, angle_t endAngle) +{ + ClipNode *ci; + ci = cliphead; + + if (endAngle==0 && ci && ci->start==0) return false; + + while (ci != NULL && ci->start < endAngle) + { + if (startAngle >= ci->start && endAngle <= ci->end) + { + return false; + } + ci = ci->next; + } + + return true; +} + +//----------------------------------------------------------------------------- +// +// AddClipRange +// +//----------------------------------------------------------------------------- + +void Clipper::AddClipRange(angle_t start, angle_t end) +{ + ClipNode *node, *temp, *prevNode; + + if (cliphead) + { + //check to see if range contains any old ranges + node = cliphead; + while (node != NULL && node->start < end) + { + if (node->start >= start && node->end <= end) + { + temp = node; + node = node->next; + RemoveRange(temp); + } + else if (node->start<=start && node->end>=end) + { + return; + } + else + { + node = node->next; + } + } + + //check to see if range overlaps a range (or possibly 2) + node = cliphead; + while (node != NULL && node->start <= end) + { + if (node->end >= start) + { + // we found the first overlapping node + if (node->start > start) + { + // the new range overlaps with this node's start point + node->start = start; + } + + if (node->end < end) + { + node->end = end; + } + + ClipNode *node2 = node->next; + while (node2 && node2->start <= node->end) + { + if (node2->end > node->end) node->end = node2->end; + ClipNode *delnode = node2; + node2 = node2->next; + RemoveRange(delnode); + } + return; + } + node = node->next; + } + + //just add range + node = cliphead; + prevNode = NULL; + temp = ClipNode::NewRange(start, end); + + while (node != NULL && node->start < end) + { + prevNode = node; + node = node->next; + } + + temp->next = node; + if (node == NULL) + { + temp->prev = prevNode; + if (prevNode) prevNode->next = temp; + if (!cliphead) cliphead = temp; + } + else + { + if (node == cliphead) + { + cliphead->prev = temp; + cliphead = temp; + } + else + { + temp->prev = prevNode; + prevNode->next = temp; + node->prev = temp; + } + } + } + else + { + temp = ClipNode::NewRange(start, end); + cliphead = temp; + return; + } +} + + +//----------------------------------------------------------------------------- +// +// RemoveClipRange +// +//----------------------------------------------------------------------------- + +void Clipper::RemoveClipRange(angle_t start, angle_t end) +{ + ClipNode *node; + + if (silhouette) + { + node = silhouette; + while (node != NULL && node->end <= start) + { + node = node->next; + } + if (node != NULL && node->start <= start) + { + if (node->end >= end) return; + start = node->end; + node = node->next; + } + while (node != NULL && node->start < end) + { + DoRemoveClipRange(start, node->start); + start = node->end; + node = node->next; + } + if (start >= end) return; + } + DoRemoveClipRange(start, end); +} + +//----------------------------------------------------------------------------- +// +// RemoveClipRange worker function +// +//----------------------------------------------------------------------------- + +void Clipper::DoRemoveClipRange(angle_t start, angle_t end) +{ + ClipNode *node, *temp; + + if (cliphead) + { + //check to see if range contains any old ranges + node = cliphead; + while (node != NULL && node->start < end) + { + if (node->start >= start && node->end <= end) + { + temp = node; + node = node->next; + RemoveRange(temp); + } + else + { + node = node->next; + } + } + + //check to see if range overlaps a range (or possibly 2) + node = cliphead; + while (node != NULL) + { + if (node->start >= start && node->start <= end) + { + node->start = end; + break; + } + else if (node->end >= start && node->end <= end) + { + node->end=start; + } + else if (node->start < start && node->end > end) + { + temp=ClipNode::NewRange(end, node->end); + node->end=start; + temp->next=node->next; + temp->prev=node; + node->next=temp; + if (temp->next) temp->next->prev=temp; + break; + } + node = node->next; + } + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +angle_t Clipper::AngleToPseudo(angle_t ang) +{ + double vecx = cos(ang * M_PI / ANGLE_180); + double vecy = sin(ang * M_PI / ANGLE_180); + + double result = vecy / (fabs(vecx) + fabs(vecy)); + if (vecx < 0) + { + result = 2.f - result; + } + return xs_Fix<30>::ToFix(result); +} + +//----------------------------------------------------------------------------- +// +// ! Returns the pseudoangle between the line p1 to (infinity, p1.y) and the +// line from p1 to p2. The pseudoangle has the property that the ordering of +// points by true angle anround p1 and ordering of points by pseudoangle are the +// same. +// +// For clipping exact angles are not needed. Only the ordering matters. +// This is about as fast as the fixed point R_PointToAngle2 but without +// the precision issues associated with that function. +// +//----------------------------------------------------------------------------- + +angle_t R_PointToPseudoAngle (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y) +{ + // Note: float won't work here as it's less precise than the BAM values being passed as parameters + double vecx = double(x-viewx); + double vecy = double(y-viewy); + + if (vecx == 0 && vecy == 0) + { + return 0; + } + else + { + double result = vecy / (fabs(vecx) + fabs(vecy)); + if (vecx < 0) + { + result = 2.f - result; + } + return xs_Fix<30>::ToFix(result); + } +} + + + + +//----------------------------------------------------------------------------- +// +// R_CheckBBox +// Checks BSP node/subtree bounding box. +// Returns true +// if some part of the bbox might be visible. +// +//----------------------------------------------------------------------------- + static const int checkcoord[12][4] = // killough -- static const + { + {3,0,2,1}, + {3,0,2,0}, + {3,1,2,0}, + {0}, + {2,0,2,1}, + {0,0,0,0}, + {3,1,3,0}, + {0}, + {2,0,3,1}, + {2,1,3,1}, + {2,1,3,0} + }; + +bool Clipper::CheckBox(const fixed_t *bspcoord) +{ + angle_t angle1, angle2; + + int boxpos; + const int* check; + + // Find the corners of the box + // that define the edges from current viewpoint. + boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT ] ? 1 : 2) + + (viewy >= bspcoord[BOXTOP ] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); + + if (boxpos == 5) return true; + + check = checkcoord[boxpos]; + angle1 = R_PointToPseudoAngle (viewx, viewy, bspcoord[check[0]], bspcoord[check[1]]); + angle2 = R_PointToPseudoAngle (viewx, viewy, bspcoord[check[2]], bspcoord[check[3]]); + + return SafeCheckRange(angle2, angle1); +} + diff --git a/src/gl/scene/gl_clipper.h b/src/gl/scene/gl_clipper.h new file mode 100644 index 000000000..637839f4f --- /dev/null +++ b/src/gl/scene/gl_clipper.h @@ -0,0 +1,152 @@ +#ifndef __GL_CLIPPER +#define __GL_CLIPPER + +#include "doomtype.h" +#include "tables.h" +#include "xs_Float.h" +#include "r_utility.h" + +class ClipNode +{ + friend class Clipper; + friend class ClipNodesFreer; + + ClipNode *prev, *next; + angle_t start, end; + static ClipNode * freelist; + + bool operator== (const ClipNode &other) + { + return other.start == start && other.end == end; + } + + void Free() + { + next=freelist; + freelist=this; + } + + static ClipNode * GetNew() + { + if (freelist) + { + ClipNode * p=freelist; + freelist=p->next; + return p; + } + else return new ClipNode; + } + + static ClipNode * NewRange(angle_t start, angle_t end) + { + ClipNode * c=GetNew(); + + c->start=start; + c->end=end; + c->next=c->prev=NULL; + return c; + } + +}; + + +class Clipper +{ + ClipNode * clipnodes; + ClipNode * cliphead; + ClipNode * silhouette; // will be preserved even when RemoveClipRange is called + + static angle_t AngleToPseudo(angle_t ang); + bool IsRangeVisible(angle_t startangle, angle_t endangle); + void RemoveRange(ClipNode * cn); + void AddClipRange(angle_t startangle, angle_t endangle); + void RemoveClipRange(angle_t startangle, angle_t endangle); + void DoRemoveClipRange(angle_t start, angle_t end); + +public: + + static int anglecache; + + Clipper() + { + clipnodes=cliphead=NULL; + } + + ~Clipper(); + + void Clear(); + + + void SetSilhouette(); + + bool SafeCheckRange(angle_t startAngle, angle_t endAngle) + { + if(startAngle > endAngle) + { + return (IsRangeVisible(startAngle, ANGLE_MAX) || IsRangeVisible(0, endAngle)); + } + + return IsRangeVisible(startAngle, endAngle); + } + + void SafeAddClipRange(angle_t startangle, angle_t endangle) + { + if(startangle > endangle) + { + // The range has to added in two parts. + AddClipRange(startangle, ANGLE_MAX); + AddClipRange(0, endangle); + } + else + { + // Add the range as usual. + AddClipRange(startangle, endangle); + } + } + + void SafeAddClipRangeRealAngles(angle_t startangle, angle_t endangle) + { + SafeAddClipRange(AngleToPseudo(startangle), AngleToPseudo(endangle)); + } + + + void SafeRemoveClipRange(angle_t startangle, angle_t endangle) + { + if(startangle > endangle) + { + // The range has to added in two parts. + RemoveClipRange(startangle, ANGLE_MAX); + RemoveClipRange(0, endangle); + } + else + { + // Add the range as usual. + RemoveClipRange(startangle, endangle); + } + } + + void SafeRemoveClipRangeRealAngles(angle_t startangle, angle_t endangle) + { + SafeRemoveClipRange(AngleToPseudo(startangle), AngleToPseudo(endangle)); + } + + bool CheckBox(const fixed_t *bspcoord); +}; + + +extern Clipper clipper; + +angle_t R_PointToPseudoAngle (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y); + +inline angle_t R_PointToAnglePrecise (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y) +{ + return xs_RoundToUInt(atan2(double(y-viewy), double(x-viewx)) * (ANGLE_180/M_PI)); +} + +// Used to speed up angle calculations during clipping +inline angle_t vertex_t::GetClipAngle() +{ + return angletime == Clipper::anglecache? viewangle : (angletime = Clipper::anglecache, viewangle = R_PointToPseudoAngle(viewx, viewy, x,y)); +} + +#endif \ No newline at end of file diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp new file mode 100644 index 000000000..b6478dd22 --- /dev/null +++ b/src/gl/scene/gl_decal.cpp @@ -0,0 +1,428 @@ +/* +** gl_decal.cpp +** OpenGL decal rendering code +** +**--------------------------------------------------------------------------- +** Copyright 2003-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "doomdata.h" +#include "gl/system/gl_system.h" +#include "a_sharedglobal.h" +#include "r_utility.h" + +#include "gl/system/gl_cvars.h" +#include "gl/data/gl_data.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_texture.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" + +struct DecalVertex +{ + float x,y,z; + float u,v; +}; + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::DrawDecal(DBaseDecal *decal) +{ + line_t * line=seg->linedef; + side_t * side=seg->sidedef; + int i; + fixed_t zpos; + int light; + int rel; + float a; + bool flipx, flipy, loadAlpha; + DecalVertex dv[4]; + FTextureID decalTile; + + + if (decal->RenderFlags & RF_INVISIBLE) return; + if (type==RENDERWALL_FFBLOCK && gltexture->isMasked()) return; // No decals on 3D floors with transparent textures. + + //if (decal->sprite != 0xffff) + { + decalTile = decal->PicNum; + flipx = !!(decal->RenderFlags & RF_XFLIP); + flipy = !!(decal->RenderFlags & RF_YFLIP); + } + /* + else + { + decalTile = SpriteFrames[sprites[decal->sprite].spriteframes + decal->frame].lump[0]; + flipx = SpriteFrames[sprites[decal->sprite].spriteframes + decal->frame].flip & 1; + } + */ + + FTexture *texture = TexMan[decalTile]; + if (texture == NULL) return; + + FMaterial *tex; + + + if (texture->UseType == FTexture::TEX_MiscPatch) + { + // We need to create a clone of this texture where we can force the + // texture filtering offset in. + if (texture->gl_info.DecalTexture == NULL) + { + texture->gl_info.DecalTexture = new FCloneTexture(texture, FTexture::TEX_Decal); + } + tex = FMaterial::ValidateTexture(texture->gl_info.DecalTexture); + } + else tex = FMaterial::ValidateTexture(texture); + + + // the sectors are only used for their texture origin coordinates + // so we don't need the fake sectors for deep water etc. + // As this is a completely split wall fragment no further splits are + // necessary for the decal. + sector_t *frontsector; + + // for 3d-floor segments use the model sector as reference + if ((decal->RenderFlags&RF_CLIPMASK)==RF_CLIPMID) frontsector=decal->Sector; + else frontsector=seg->frontsector; + + switch (decal->RenderFlags & RF_RELMASK) + { + default: + // No valid decal can have this type. If one is encountered anyway + // it is in some way invalid so skip it. + return; + //zpos = decal->z; + //break; + + case RF_RELUPPER: + if (type!=RENDERWALL_TOP) return; + if (line->flags & ML_DONTPEGTOP) + { + zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling); + } + else + { + zpos = decal->Z + seg->backsector->GetPlaneTexZ(sector_t::ceiling); + } + break; + case RF_RELLOWER: + if (type!=RENDERWALL_BOTTOM) return; + if (line->flags & ML_DONTPEGBOTTOM) + { + zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling); + } + else + { + zpos = decal->Z + seg->backsector->GetPlaneTexZ(sector_t::floor); + } + break; + case RF_RELMID: + if (type==RENDERWALL_TOP || type==RENDERWALL_BOTTOM) return; + if (line->flags & ML_DONTPEGBOTTOM) + { + zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::floor); + } + else + { + zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling); + } + } + + if (decal->RenderFlags & RF_FULLBRIGHT) + { + light = 255; + rel = 0; + } + else + { + light = lightlevel; + rel = rellight + getExtraLight(); + } + + int r = RPART(decal->AlphaColor); + int g = GPART(decal->AlphaColor); + int b = BPART(decal->AlphaColor); + FColormap p = Colormap; + + if (glset.nocoloredspritelighting) + { + int v = (Colormap.LightColor.r * 77 + Colormap.LightColor.g*143 + Colormap.LightColor.b*35)/255; + p.LightColor = PalEntry(p.colormap, v, v, v); + } + + float red, green, blue; + + if (decal->RenderStyle.Flags & STYLEF_RedIsAlpha) + { + loadAlpha = true; + p.colormap=CM_SHADE; + + if (glset.lightmode != 8) + { + gl_GetLightColor(light, rel, &p, &red, &green, &blue); + } + else + { + gl_GetLightColor(lightlevel, rellight, &p, &red, &green, &blue); + } + + if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap && gl_light_sprites) + { + float result[3]; + fixed_t x, y; + decal->GetXY(seg->sidedef, x, y); + gl_GetSpriteLight(NULL, x, y, zpos, sub, Colormap.colormap-CM_DESAT0, result, line, side == line->sidedef[0]? 0:1); + if (glset.lightmode != 8) + { + red = clamp(result[0]+red, 0, 1.0f); + green = clamp(result[1]+green, 0, 1.0f); + blue = clamp(result[2]+blue, 0, 1.0f); + } + else + { + gl_RenderState.SetDynLight(result[0], result[1], result[2]); + } + } + + BYTE R = xs_RoundToInt(r * red); + BYTE G = xs_RoundToInt(g * green); + BYTE B = xs_RoundToInt(b * blue); + + gl_ModifyColor(R,G,B, Colormap.colormap); + + red = R/255.f; + green = G/255.f; + blue = B/255.f; + } + else + { + loadAlpha = false; + + red = 1.f; + green = 1.f; + blue = 1.f; + } + + + a = FIXED2FLOAT(decal->Alpha); + + // now clip the decal to the actual polygon + float decalwidth = tex->TextureWidth(GLUSE_PATCH) * FIXED2FLOAT(decal->ScaleX); + float decalheight= tex->TextureHeight(GLUSE_PATCH) * FIXED2FLOAT(decal->ScaleY); + float decallefto = tex->GetLeftOffset(GLUSE_PATCH) * FIXED2FLOAT(decal->ScaleX); + float decaltopo = tex->GetTopOffset(GLUSE_PATCH) * FIXED2FLOAT(decal->ScaleY); + + + float leftedge = glseg.fracleft * side->TexelLength; + float linelength = glseg.fracright * side->TexelLength - leftedge; + + // texel index of the decal's left edge + float decalpixpos = (float)side->TexelLength * decal->LeftDistance / (1<<30) - (flipx? decalwidth-decallefto : decallefto) - leftedge; + + float left,right; + float lefttex,righttex; + + // decal is off the left edge + if (decalpixpos < 0) + { + left = 0; + lefttex = -decalpixpos; + } + else + { + left = decalpixpos; + lefttex = 0; + } + + // decal is off the right edge + if (decalpixpos + decalwidth > linelength) + { + right = linelength; + righttex = right - decalpixpos; + } + else + { + right = decalpixpos + decalwidth; + righttex = decalwidth; + } + if (right<=left) return; // nothing to draw + + // one texture unit on the wall as vector + float vx=(glseg.x2-glseg.x1)/linelength; + float vy=(glseg.y2-glseg.y1)/linelength; + + dv[1].x=dv[0].x=glseg.x1+vx*left; + dv[1].y=dv[0].y=glseg.y1+vy*left; + + dv[3].x=dv[2].x=glseg.x1+vx*right; + dv[3].y=dv[2].y=glseg.y1+vy*right; + + zpos+= FRACUNIT*(flipy? decalheight-decaltopo : decaltopo); + + tex->BindPatch(p.colormap, decal->Translation); + + dv[1].z=dv[2].z = FIXED2FLOAT(zpos); + dv[0].z=dv[3].z = dv[1].z - decalheight; + dv[1].v=dv[2].v = tex->GetVT(); + + dv[1].u=dv[0].u = tex->GetU(lefttex / FIXED2FLOAT(decal->ScaleX)); + dv[3].u=dv[2].u = tex->GetU(righttex / FIXED2FLOAT(decal->ScaleX)); + dv[0].v=dv[3].v = tex->GetVB(); + + + // now clip to the top plane + float vzt=(ztop[1]-ztop[0])/linelength; + float topleft=this->ztop[0]+vzt*left; + float topright=this->ztop[0]+vzt*right; + + // completely below the wall + if (topleftzbottom[0]+vzb*left; + float bottomright=this->zbottom[0]+vzb*right; + + // completely above the wall + if (bottomleft>dv[1].z && bottomright>dv[2].z) + return; + + if (bottomleft>dv[0].z || bottomright>dv[3].z) + { + // decal has to be clipped at the bottom + // let texture clamping handle all extreme cases + dv[0].v=(dv[1].z-bottomleft)/(dv[1].z-dv[0].z)*(dv[0].v-dv[1].v) + dv[1].v; + dv[3].v=(dv[2].z-bottomright)/(dv[2].z-dv[3].z)*(dv[3].v-dv[2].v) + dv[2].v; + dv[0].z=bottomleft; + dv[3].z=bottomright; + } + + + if (flipx) + { + float ur = tex->GetUR(); + for(i=0;i<4;i++) dv[i].u=ur-dv[i].u; + } + if (flipy) + { + float vb = tex->GetVB(); + for(i=0;i<4;i++) dv[i].v=vb-dv[i].v; + } + // fog is set once per wall in the calling function and not per decal! + + if (loadAlpha) + { + gl.Color4f(red, green, blue, a); + + if (glset.lightmode == 8) + { + if (gl_fixedcolormap) + gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); + else + gl.VertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(light, rel, false) / 255.0); + } + } + else + { + if (glset.lightmode == 8) + { + gl_SetColor(light, rel, &p, a, extralight); // Korshun. + } + else + { + gl_SetColor(light, rel, &p, a); + } + } + + PalEntry fc = gl_RenderState.GetFogColor(); + if (decal->RenderStyle.BlendOp == STYLEOP_Add && decal->RenderStyle.DestAlpha == STYLEALPHA_One) + { + gl_RenderState.SetFog(0,-1); + } + + + gl_SetRenderStyle(decal->RenderStyle, false, false); + + // If srcalpha is one it looks better with a higher alpha threshold + if (decal->RenderStyle.SrcAlpha == STYLEALPHA_One) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); + else gl_RenderState.AlphaFunc(GL_GREATER, 0.f); + + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_FAN); + for(i=0;i<4;i++) + { + gl.TexCoord2f(dv[i].u,dv[i].v); + gl.Vertex3f(dv[i].x,dv[i].z,dv[i].y); + } + gl.End(); + rendered_decals++; + gl_RenderState.SetFog(fc,-1); + gl_RenderState.SetDynLight(0,0,0); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::DoDrawDecals() +{ + DBaseDecal *decal = seg->sidedef->AttachedDecals; + while (decal) + { + DrawDecal(decal); + decal = decal->WallNext; + } +} + diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp new file mode 100644 index 000000000..a03cb01e2 --- /dev/null +++ b/src/gl/scene/gl_drawinfo.cpp @@ -0,0 +1,1221 @@ +/* +** gl_drawinfo.cpp +** Implements the draw info structure which contains most of the +** data in a scene and the draw lists - including a very thorough BSP +** style sorting algorithm for translucent objects. +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ +#include "gl/system/gl_system.h" +#include "r_sky.h" +#include "r_utility.h" +#include "r_state.h" +#include "doomstat.h" + +#include "gl/system/gl_cvars.h" +#include "gl/data/gl_data.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/dynlights/gl_lightbuffer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_templates.h" +#include "gl/shaders/gl_shader.h" + +FDrawInfo * gl_drawinfo; + +CVAR(Bool, gl_sort_textures, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) + +//========================================================================== +// +// +// +//========================================================================== +class StaticSortNodeArray : public TDeletingArray +{ + unsigned usecount; +public: + unsigned Size() { return usecount; } + void Clear() { usecount=0; } + void Release(int start) { usecount=start; } + SortNode * GetNew(); +}; + + +SortNode * StaticSortNodeArray::GetNew() +{ + if (usecount==TArray::Size()) + { + Push(new SortNode); + } + return operator[](usecount++); +} + + +static StaticSortNodeArray SortNodes; + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::Reset() +{ + if (sorted) SortNodes.Release(SortNodeStart); + sorted=NULL; + walls.Clear(); + flats.Clear(); + sprites.Clear(); + drawitems.Clear(); +} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +// Translucent polygon sorting - uses a BSP algorithm with an additional 'equal' branch + +inline double GLSprite::CalcIntersectionVertex(GLWall * w2) +{ + float ax = x1, ay=y1; + float bx = x2, by=y2; + float cx = w2->glseg.x1, cy=w2->glseg.y1; + float dx = w2->glseg.x2, dy=w2->glseg.y2; + return ((ay-cy)*(dx-cx)-(ax-cx)*(dy-cy)) / ((bx-ax)*(dy-cy)-(by-ay)*(dx-cx)); +} + + + +//========================================================================== +// +// +// +//========================================================================== +inline void SortNode::UnlinkFromChain() +{ + if (parent) parent->next=next; + if (next) next->parent=parent; + parent=next=NULL; +} + +//========================================================================== +// +// +// +//========================================================================== +inline void SortNode::Link(SortNode * hook) +{ + if (hook) + { + parent=hook->parent; + hook->parent=this; + } + next=hook; + if (parent) parent->next=this; +} + +//========================================================================== +// +// +// +//========================================================================== +inline void SortNode::AddToEqual(SortNode *child) +{ + child->UnlinkFromChain(); + child->equal=equal; + equal=child; +} + +//========================================================================== +// +// +// +//========================================================================== +inline void SortNode::AddToLeft(SortNode * child) +{ + child->UnlinkFromChain(); + child->Link(left); + left=child; +} + +//========================================================================== +// +// +// +//========================================================================== +inline void SortNode::AddToRight(SortNode * child) +{ + child->UnlinkFromChain(); + child->Link(right); + right=child; +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::MakeSortList() +{ + SortNode * p, * n, * c; + unsigned i; + + SortNodeStart=SortNodes.Size(); + p=NULL; + n=SortNodes.GetNew(); + for(i=0;iitemindex=(int)i; + n->left=n->equal=n->right=NULL; + n->parent=p; + p=n; + if (i!=drawitems.Size()-1) + { + c=SortNodes.GetNew(); + n->next=c; + n=c; + } + else + { + n->next=NULL; + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== +SortNode * GLDrawList::FindSortPlane(SortNode * head) +{ + while (head->next && drawitems[head->itemindex].rendertype!=GLDIT_FLAT) + head=head->next; + if (drawitems[head->itemindex].rendertype==GLDIT_FLAT) return head; + return NULL; +} + + +//========================================================================== +// +// +// +//========================================================================== +SortNode * GLDrawList::FindSortWall(SortNode * head) +{ + fixed_t farthest=INT_MIN; + fixed_t nearest=INT_MAX; + SortNode * best=NULL; + SortNode * node=head; + fixed_t bestdist=INT_MAX; + + while (node) + { + GLDrawItem * it=&drawitems[node->itemindex]; + if (it->rendertype==GLDIT_WALL) + { + fixed_t d=walls[it->index].viewdistance; + if (d>farthest) farthest=d; + if (dnext; + } + if (farthest==INT_MIN) return NULL; + node=head; + farthest=(farthest+nearest)>>1; + while (node) + { + GLDrawItem * it=&drawitems[node->itemindex]; + if (it->rendertype==GLDIT_WALL) + { + fixed_t di=abs(walls[it->index].viewdistance-farthest); + if (!best || dinext; + } + return best; +} + +//========================================================================== +// +// Note: sloped planes are a huge problem... +// +//========================================================================== +void GLDrawList::SortPlaneIntoPlane(SortNode * head,SortNode * sort) +{ + GLFlat * fh=&flats[drawitems[head->itemindex].index]; + GLFlat * fs=&flats[drawitems[sort->itemindex].index]; + + if (fh->z==fs->z) + head->AddToEqual(sort); + else if ( (fh->zz && fh->ceiling) || (fh->z>fs->z && !fh->ceiling)) + head->AddToLeft(sort); + else + head->AddToRight(sort); +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::SortWallIntoPlane(SortNode * head,SortNode * sort) +{ + GLFlat * fh=&flats[drawitems[head->itemindex].index]; + GLWall * ws=&walls[drawitems[sort->itemindex].index]; + GLWall * ws1; + + bool ceiling = fh->z > FIXED2FLOAT(viewz); + + + if (ws->ztop[0]>fh->z && ws->zbottom[0]z) + { + // We have to split this wall! + + // WARNING: NEVER EVER push a member of an array onto the array itself. + // Bad things will happen if the memory must be reallocated! + GLWall w=*ws; + AddWall(&w); + + ws1=&walls[walls.Size()-1]; + ws=&walls[drawitems[sort->itemindex].index]; // may have been reallocated! + float newtexv = ws->uplft.v + ((ws->lolft.v - ws->uplft.v) / (ws->zbottom[0] - ws->ztop[0])) * (fh->z - ws->ztop[0]); + + // I make the very big assumption here that translucent walls in sloped sectors + // and 3D-floors never coexist in the same level. If that were the case this + // code would become extremely more complicated. + if (!ceiling) + { + ws->ztop[1] = ws1->zbottom[1] = ws->ztop[0] = ws1->zbottom[0] = fh->z; + ws->uprgt.v = ws1->lorgt.v = ws->uplft.v = ws1->lolft.v = newtexv; + } + else + { + ws1->ztop[1] = ws->zbottom[1] = ws1->ztop[0] = ws->zbottom[0] = fh->z; + ws1->uplft.v = ws->lolft.v = ws1->uprgt.v = ws->lorgt.v=newtexv; + } + + SortNode * sort2=SortNodes.GetNew(); + memset(sort2,0,sizeof(SortNode)); + sort2->itemindex=drawitems.Size()-1; + + head->AddToLeft(sort); + head->AddToRight(sort2); + } + else if ((ws->zbottom[0]z && !ceiling) || (ws->ztop[0]>fh->z && ceiling)) // completely on the left side + { + head->AddToLeft(sort); + } + else + { + head->AddToRight(sort); + } + +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::SortSpriteIntoPlane(SortNode * head,SortNode * sort) +{ + GLFlat * fh=&flats[drawitems[head->itemindex].index]; + GLSprite * ss=&sprites[drawitems[sort->itemindex].index]; + GLSprite * ss1; + + bool ceiling = fh->z > FIXED2FLOAT(viewz); + + if (ss->z1>fh->z && ss->z2z) + { + // We have to split this sprite! + GLSprite s=*ss; + AddSprite(&s); + ss1=&sprites[sprites.Size()-1]; + ss=&sprites[drawitems[sort->itemindex].index]; // may have been reallocated! + float newtexv=ss->vt + ((ss->vb-ss->vt)/(ss->z2-ss->z1))*(fh->z-ss->z1); + + if (!ceiling) + { + ss->z1=ss1->z2=fh->z; + ss->vt=ss1->vb=newtexv; + } + else + { + ss1->z1=ss->z2=fh->z; + ss1->vt=ss->vb=newtexv; + } + + SortNode * sort2=SortNodes.GetNew(); + memset(sort2,0,sizeof(SortNode)); + sort2->itemindex=drawitems.Size()-1; + + head->AddToLeft(sort); + head->AddToRight(sort2); + } + else if ((ss->z2z && !ceiling) || (ss->z1>fh->z && ceiling)) // completely on the left side + { + head->AddToLeft(sort); + } + else + { + head->AddToRight(sort); + } + +} + + +//========================================================================== +// +// +// +//========================================================================== +#define MIN_EQ (0.0005f) + +void GLDrawList::SortWallIntoWall(SortNode * head,SortNode * sort) +{ + GLWall * wh=&walls[drawitems[head->itemindex].index]; + GLWall * ws=&walls[drawitems[sort->itemindex].index]; + GLWall * ws1; + float v1=wh->PointOnSide(ws->glseg.x1,ws->glseg.y1); + float v2=wh->PointOnSide(ws->glseg.x2,ws->glseg.y2); + + if (fabs(v1)type==RENDERWALL_FOGBOUNDARY && wh->type!=RENDERWALL_FOGBOUNDARY) + { + head->AddToRight(sort); + } + else if (ws->type!=RENDERWALL_FOGBOUNDARY && wh->type==RENDERWALL_FOGBOUNDARY) + { + head->AddToLeft(sort); + } + else + { + head->AddToEqual(sort); + } + } + else if (v1AddToLeft(sort); + } + else if (v1>-MIN_EQ && v2>-MIN_EQ) + { + head->AddToRight(sort); + } + else + { + double r=ws->CalcIntersectionVertex(wh); + + float ix=(float)(ws->glseg.x1+r*(ws->glseg.x2-ws->glseg.x1)); + float iy=(float)(ws->glseg.y1+r*(ws->glseg.y2-ws->glseg.y1)); + float iu=(float)(ws->uplft.u + r * (ws->uprgt.u - ws->uplft.u)); + float izt=(float)(ws->ztop[0]+r*(ws->ztop[1]-ws->ztop[0])); + float izb=(float)(ws->zbottom[0]+r*(ws->zbottom[1]-ws->zbottom[0])); + + GLWall w=*ws; + AddWall(&w); + ws1=&walls[walls.Size()-1]; + ws=&walls[drawitems[sort->itemindex].index]; // may have been reallocated! + + ws1->glseg.x1=ws->glseg.x2=ix; + ws1->glseg.y1=ws->glseg.y2=iy; + ws1->ztop[0]=ws->ztop[1]=izt; + ws1->zbottom[0]=ws->zbottom[1]=izb; + ws1->lolft.u = ws1->uplft.u = ws->lorgt.u = ws->uprgt.u = iu; + + SortNode * sort2=SortNodes.GetNew(); + memset(sort2,0,sizeof(SortNode)); + sort2->itemindex=drawitems.Size()-1; + + if (v1>0) + { + head->AddToLeft(sort2); + head->AddToRight(sort); + } + else + { + head->AddToLeft(sort); + head->AddToRight(sort2); + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::SortSpriteIntoWall(SortNode * head,SortNode * sort) +{ + GLWall * wh=&walls[drawitems[head->itemindex].index]; + GLSprite * ss=&sprites[drawitems[sort->itemindex].index]; + GLSprite * ss1; + + float v1 = wh->PointOnSide(ss->x1, ss->y1); + float v2 = wh->PointOnSide(ss->x2, ss->y2); + + if (fabs(v1)type==RENDERWALL_FOGBOUNDARY) + { + head->AddToLeft(sort); + } + else + { + head->AddToEqual(sort); + } + } + else if (v1AddToLeft(sort); + } + else if (v1>-MIN_EQ && v2>-MIN_EQ) + { + head->AddToRight(sort); + } + else + { + double r=ss->CalcIntersectionVertex(wh); + + float ix=(float)(ss->x1 + r * (ss->x2-ss->x1)); + float iy=(float)(ss->y1 + r * (ss->y2-ss->y1)); + float iu=(float)(ss->ul + r * (ss->ur-ss->ul)); + + GLSprite s=*ss; + AddSprite(&s); + ss1=&sprites[sprites.Size()-1]; + ss=&sprites[drawitems[sort->itemindex].index]; // may have been reallocated! + + ss1->x1=ss->x2=ix; + ss1->y1=ss->y2=iy; + ss1->ul=ss->ur=iu; + + SortNode * sort2=SortNodes.GetNew(); + memset(sort2,0,sizeof(SortNode)); + sort2->itemindex=drawitems.Size()-1; + + if (v1>0) + { + head->AddToLeft(sort2); + head->AddToRight(sort); + } + else + { + head->AddToLeft(sort); + head->AddToRight(sort2); + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +inline int GLDrawList::CompareSprites(SortNode * a,SortNode * b) +{ + GLSprite * s1=&sprites[drawitems[a->itemindex].index]; + GLSprite * s2=&sprites[drawitems[b->itemindex].index]; + + int res = s1->depth - s2->depth; + + if (res != 0) return -res; + else return (i_compatflags & COMPATF_SPRITESORT)? s1->index-s2->index : s2->index-s1->index; +} + +//========================================================================== +// +// +// +//========================================================================== +static GLDrawList * gd; +int __cdecl CompareSprite(const void * a,const void * b) +{ + return gd->CompareSprites(*(SortNode**)a,*(SortNode**)b); +} + +//========================================================================== +// +// +// +//========================================================================== +SortNode * GLDrawList::SortSpriteList(SortNode * head) +{ + SortNode * n; + int count; + unsigned i; + + static TArray sortspritelist; + + SortNode * parent=head->parent; + + sortspritelist.Clear(); + for(count=0,n=head;n;n=n->next) sortspritelist.Push(n); + gd=this; + qsort(&sortspritelist[0],sortspritelist.Size(),sizeof(SortNode *),CompareSprite); + for(i=0;inext=NULL; + if (parent) parent->equal=sortspritelist[i]; + parent=sortspritelist[i]; + } + return sortspritelist[0]; +} + +//========================================================================== +// +// +// +//========================================================================== +SortNode * GLDrawList::DoSort(SortNode * head) +{ + SortNode * node, * sn, * next; + + sn=FindSortPlane(head); + if (sn) + { + if (sn==head) head=head->next; + sn->UnlinkFromChain(); + node=head; + head=sn; + while (node) + { + next=node->next; + switch(drawitems[node->itemindex].rendertype) + { + case GLDIT_FLAT: + SortPlaneIntoPlane(head,node); + break; + + case GLDIT_WALL: + SortWallIntoPlane(head,node); + break; + + case GLDIT_SPRITE: + SortSpriteIntoPlane(head,node); + break; + case GLDIT_POLY: break; + } + node=next; + } + } + else + { + sn=FindSortWall(head); + if (sn) + { + if (sn==head) head=head->next; + sn->UnlinkFromChain(); + node=head; + head=sn; + while (node) + { + next=node->next; + switch(drawitems[node->itemindex].rendertype) + { + case GLDIT_WALL: + SortWallIntoWall(head,node); + break; + + case GLDIT_SPRITE: + SortSpriteIntoWall(head,node); + break; + case GLDIT_POLY: break; + case GLDIT_FLAT: break; + } + node=next; + } + } + else + { + return SortSpriteList(head); + } + } + if (head->left) head->left=DoSort(head->left); + if (head->right) head->right=DoSort(head->right); + return sn; +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::DoDraw(int pass, int i) +{ + switch(drawitems[i].rendertype) + { + case GLDIT_FLAT: + { + GLFlat * f=&flats[drawitems[i].index]; + RenderFlat.Clock(); + f->Draw(pass); + RenderFlat.Unclock(); + } + break; + + case GLDIT_WALL: + { + GLWall * w=&walls[drawitems[i].index]; + RenderWall.Clock(); + w->Draw(pass); + RenderWall.Unclock(); + } + break; + + case GLDIT_SPRITE: + { + GLSprite * s=&sprites[drawitems[i].index]; + RenderSprite.Clock(); + s->Draw(pass); + RenderSprite.Unclock(); + } + break; + case GLDIT_POLY: break; + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::DoDrawSorted(SortNode * head) +{ + do + { + if (head->left) + { + DoDrawSorted(head->left); + } + DoDraw(GLPASS_TRANSLUCENT, head->itemindex); + if (head->equal) + { + SortNode * ehead=head->equal; + while (ehead) + { + DoDraw(GLPASS_TRANSLUCENT, ehead->itemindex); + ehead=ehead->equal; + } + } + } + while ((head=head->right)); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::DrawSorted() +{ + if (drawitems.Size()==0) return; + + if (!sorted) + { + MakeSortList(); + sorted=DoSort(SortNodes[SortNodeStart]); + } + DoDrawSorted(sorted); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::Draw(int pass) +{ + for(unsigned i=0;irendertype) + { + case GLDIT_FLAT: + { + GLFlat * f=&sortinfo->flats[di[i]->index]; + tx[i]=f->gltexture; + lights[i]=f->lightlevel; + clamp[i] = 0; + } + break; + + case GLDIT_WALL: + { + GLWall * w=&sortinfo->walls[di[i]->index]; + tx[i]=w->gltexture; + lights[i]=w->lightlevel; + clamp[i] = w->flags & 3; + } + break; + + case GLDIT_SPRITE: + { + GLSprite * s=&sortinfo->sprites[di[i]->index]; + tx[i]=s->gltexture; + lights[i]=s->lightlevel; + clamp[i] = 4; + } + break; + case GLDIT_POLY: break; + } + } + if (tx[0]!=tx[1]) return tx[0]-tx[1]; + if (clamp[0]!=clamp[1]) return clamp[0]-clamp[1]; // clamping forces different textures. + return lights[0]-lights[1]; +} + + +void GLDrawList::Sort() +{ + if (drawitems.Size()!=0 && gl_sort_textures) + { + sortinfo=this; + qsort(&drawitems[0], drawitems.Size(), sizeof(drawitems[0]), dicmp); + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::AddWall(GLWall * wall) +{ + //@sync-drawinfo + drawitems.Push(GLDrawItem(GLDIT_WALL,walls.Push(*wall))); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::AddFlat(GLFlat * flat) +{ + //@sync-drawinfo + drawitems.Push(GLDrawItem(GLDIT_FLAT,flats.Push(*flat))); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::AddSprite(GLSprite * sprite) +{ + //@sync-drawinfo + drawitems.Push(GLDrawItem(GLDIT_SPRITE,sprites.Push(*sprite))); +} + + +//========================================================================== +// +// Try to reuse the lists as often as possible as they contain resources that +// are expensive to create and delete. +// +//========================================================================== + +FDrawInfo *FDrawInfoList::GetNew() +{ + if (mList.Size() > 0) + { + FDrawInfo *di; + mList.Pop(di); + return di; + } + return new FDrawInfo; +} + +void FDrawInfoList::Release(FDrawInfo * di) +{ + di->ClearBuffers(); + mList.Push(di); +} + +static FDrawInfoList di_list; + +//========================================================================== +// +// +// +//========================================================================== + +FDrawInfo::FDrawInfo() +{ + next = NULL; +} + +FDrawInfo::~FDrawInfo() +{ + ClearBuffers(); +} + + +//========================================================================== +// +// Sets up a new drawinfo struct +// +//========================================================================== +void FDrawInfo::StartDrawInfo() +{ + FDrawInfo *di=di_list.GetNew(); + di->StartScene(); +} + +void FDrawInfo::StartScene() +{ + ClearBuffers(); + + sectorrenderflags.Resize(numsectors); + ss_renderflags.Resize(numsubsectors); + no_renderflags.Resize(numsubsectors); + + memset(§orrenderflags[0], 0, numsectors*sizeof(sectorrenderflags[0])); + memset(&ss_renderflags[0], 0, numsubsectors*sizeof(ss_renderflags[0])); + memset(&no_renderflags[0], 0, numnodes*sizeof(no_renderflags[0])); + + next=gl_drawinfo; + gl_drawinfo=this; + for(int i=0;idrawlists[i].Reset(); + gl_drawinfo=di->next; + di_list.Release(di); +} + + +//========================================================================== +// +// Flood gaps with the back side's ceiling/floor texture +// This requires a stencil because the projected plane interferes with +// the depth buffer +// +//========================================================================== + +void FDrawInfo::SetupFloodStencil(wallseg * ws) +{ + int recursion = GLPortal::GetRecursion(); + + // Create stencil + gl.StencilFunc(GL_EQUAL,recursion,~0); // create stencil + gl.StencilOp(GL_KEEP,GL_KEEP,GL_INCR); // increment stencil of valid pixels + gl.ColorMask(0,0,0,0); // don't write to the graphics buffer + gl_RenderState.EnableTexture(false); + gl.Color3f(1,1,1); + gl.Enable(GL_DEPTH_TEST); + gl.DepthMask(true); + + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_FAN); + gl.Vertex3f(ws->x1, ws->z1, ws->y1); + gl.Vertex3f(ws->x1, ws->z2, ws->y1); + gl.Vertex3f(ws->x2, ws->z2, ws->y2); + gl.Vertex3f(ws->x2, ws->z1, ws->y2); + gl.End(); + + gl.StencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil + gl.StencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil + + gl.ColorMask(1,1,1,1); // don't write to the graphics buffer + gl_RenderState.EnableTexture(true); + gl.Disable(GL_DEPTH_TEST); + gl.DepthMask(false); +} + +void FDrawInfo::ClearFloodStencil(wallseg * ws) +{ + int recursion = GLPortal::GetRecursion(); + + gl.StencilOp(GL_KEEP,GL_KEEP,GL_DECR); + gl_RenderState.EnableTexture(false); + gl.ColorMask(0,0,0,0); // don't write to the graphics buffer + gl.Color3f(1,1,1); + + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_FAN); + gl.Vertex3f(ws->x1, ws->z1, ws->y1); + gl.Vertex3f(ws->x1, ws->z2, ws->y1); + gl.Vertex3f(ws->x2, ws->z2, ws->y2); + gl.Vertex3f(ws->x2, ws->z1, ws->y2); + gl.End(); + + // restore old stencil op. + gl.StencilOp(GL_KEEP,GL_KEEP,GL_KEEP); + gl.StencilFunc(GL_EQUAL,recursion,~0); + gl_RenderState.EnableTexture(true); + gl.ColorMask(1,1,1,1); + gl.Enable(GL_DEPTH_TEST); + gl.DepthMask(true); +} + +//========================================================================== +// +// Draw the plane segment into the gap +// +//========================================================================== +void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, bool ceiling) +{ + GLSectorPlane plane; + int lightlevel; + FColormap Colormap; + FMaterial * gltexture; + + plane.GetFromSector(sec, ceiling); + + gltexture=FMaterial::ValidateTexture(plane.texture, true); + if (!gltexture) return; + + if (gl_fixedcolormap) + { + Colormap.GetFixedColormap(); + lightlevel=255; + } + else + { + Colormap=sec->ColorMap; + if (gltexture->tex->isFullbright()) + { + Colormap.LightColor.r = Colormap.LightColor.g = Colormap.LightColor.b = 0xff; + lightlevel=255; + } + else lightlevel=abs(ceiling? sec->GetCeilingLight() : sec->GetFloorLight()); + } + + int rel = getExtraLight(); + gl_SetColor(lightlevel, rel, &Colormap, 1.0f); + gl_SetFog(lightlevel, rel, &Colormap, false); + gltexture->Bind(Colormap.colormap); + + float fviewx = FIXED2FLOAT(viewx); + float fviewy = FIXED2FLOAT(viewy); + float fviewz = FIXED2FLOAT(viewz); + + gl_RenderState.Apply(); + + bool pushed = gl_SetPlaneTextureRotation(&plane, gltexture); + + gl.Begin(GL_TRIANGLE_FAN); + float prj_fac1 = (planez-fviewz)/(ws->z1-fviewz); + float prj_fac2 = (planez-fviewz)/(ws->z2-fviewz); + + float px1 = fviewx + prj_fac1 * (ws->x1-fviewx); + float py1 = fviewy + prj_fac1 * (ws->y1-fviewy); + + float px2 = fviewx + prj_fac2 * (ws->x1-fviewx); + float py2 = fviewy + prj_fac2 * (ws->y1-fviewy); + + float px3 = fviewx + prj_fac2 * (ws->x2-fviewx); + float py3 = fviewy + prj_fac2 * (ws->y2-fviewy); + + float px4 = fviewx + prj_fac1 * (ws->x2-fviewx); + float py4 = fviewy + prj_fac1 * (ws->y2-fviewy); + + gl.TexCoord2f(px1 / 64, -py1 / 64); + gl.Vertex3f(px1, planez, py1); + + gl.TexCoord2f(px2 / 64, -py2 / 64); + gl.Vertex3f(px2, planez, py2); + + gl.TexCoord2f(px3 / 64, -py3 / 64); + gl.Vertex3f(px3, planez, py3); + + gl.TexCoord2f(px4 / 64, -py4 / 64); + gl.Vertex3f(px4, planez, py4); + + gl.End(); + + if (pushed) + { + gl.PopMatrix(); + gl.MatrixMode(GL_MODELVIEW); + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FDrawInfo::FloodUpperGap(seg_t * seg) +{ + wallseg ws; + sector_t ffake, bfake; + sector_t * fakefsector = gl_FakeFlat(seg->frontsector, &ffake, true); + sector_t * fakebsector = gl_FakeFlat(seg->backsector, &bfake, false); + + vertex_t * v1, * v2; + + // Although the plane can be sloped this code will only be called + // when the edge itself is not. + fixed_t backz = fakebsector->ceilingplane.ZatPoint(seg->v1); + fixed_t frontz = fakefsector->ceilingplane.ZatPoint(seg->v1); + + if (fakebsector->GetTexture(sector_t::ceiling)==skyflatnum) return; + if (backz < viewz) return; + + if (seg->sidedef == seg->linedef->sidedef[0]) + { + v1=seg->linedef->v1; + v2=seg->linedef->v2; + } + else + { + v1=seg->linedef->v2; + v2=seg->linedef->v1; + } + + ws.x1= FIXED2FLOAT(v1->x); + ws.y1= FIXED2FLOAT(v1->y); + ws.x2= FIXED2FLOAT(v2->x); + ws.y2= FIXED2FLOAT(v2->y); + + ws.z1= FIXED2FLOAT(frontz); + ws.z2= FIXED2FLOAT(backz); + + // Step1: Draw a stencil into the gap + SetupFloodStencil(&ws); + + // Step2: Project the ceiling plane into the gap + DrawFloodedPlane(&ws, ws.z2, fakebsector, true); + + // Step3: Delete the stencil + ClearFloodStencil(&ws); +} + +//========================================================================== +// +// +// +//========================================================================== + +void FDrawInfo::FloodLowerGap(seg_t * seg) +{ + wallseg ws; + sector_t ffake, bfake; + sector_t * fakefsector = gl_FakeFlat(seg->frontsector, &ffake, true); + sector_t * fakebsector = gl_FakeFlat(seg->backsector, &bfake, false); + + vertex_t * v1, * v2; + + // Although the plane can be sloped this code will only be called + // when the edge itself is not. + fixed_t backz = fakebsector->floorplane.ZatPoint(seg->v1); + fixed_t frontz = fakefsector->floorplane.ZatPoint(seg->v1); + + + if (fakebsector->GetTexture(sector_t::floor) == skyflatnum) return; + if (fakebsector->GetPlaneTexZ(sector_t::floor) > viewz) return; + + if (seg->sidedef == seg->linedef->sidedef[0]) + { + v1=seg->linedef->v1; + v2=seg->linedef->v2; + } + else + { + v1=seg->linedef->v2; + v2=seg->linedef->v1; + } + + ws.x1= FIXED2FLOAT(v1->x); + ws.y1= FIXED2FLOAT(v1->y); + ws.x2= FIXED2FLOAT(v2->x); + ws.y2= FIXED2FLOAT(v2->y); + + ws.z2= FIXED2FLOAT(frontz); + ws.z1= FIXED2FLOAT(backz); + + // Step1: Draw a stencil into the gap + SetupFloodStencil(&ws); + + // Step2: Project the ceiling plane into the gap + DrawFloodedPlane(&ws, ws.z1, fakebsector, false); + + // Step3: Delete the stencil + ClearFloodStencil(&ws); +} diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h new file mode 100644 index 000000000..07735eb3f --- /dev/null +++ b/src/gl/scene/gl_drawinfo.h @@ -0,0 +1,279 @@ +#ifndef __GL_DRAWINFO_H +#define __GL_DRAWINFO_H + +#include "gl/scene/gl_wall.h" + +enum GLDrawItemType +{ + GLDIT_WALL, + GLDIT_FLAT, + GLDIT_SPRITE, + GLDIT_POLY, +}; + +enum DrawListType +{ + // These are organized so that the various multipass rendering modes + // have to be set as few times as possible + GLDL_LIGHT, + GLDL_LIGHTBRIGHT, + GLDL_LIGHTMASKED, + GLDL_LIGHTFOG, + GLDL_LIGHTFOGMASKED, + + GLDL_PLAIN, + GLDL_MASKED, + GLDL_FOG, + GLDL_FOGMASKED, + + GLDL_TRANSLUCENT, + GLDL_TRANSLUCENTBORDER, + + GLDL_TYPES, + + GLDL_FIRSTLIGHT = GLDL_LIGHT, + GLDL_LASTLIGHT = GLDL_LIGHTFOGMASKED, + GLDL_FIRSTNOLIGHT = GLDL_PLAIN, + GLDL_LASTNOLIGHT = GLDL_FOGMASKED, +}; + +enum Drawpasses +{ + GLPASS_BASE, // Draws the untextured surface only + GLPASS_BASE_MASKED, // Draws an untextured surface that is masked by the texture + GLPASS_PLAIN, // Draws a texture that isn't affected by dynamic lights with sector light settings + GLPASS_LIGHT, // Draws dynamic lights + GLPASS_LIGHT_ADDITIVE, // Draws additive dynamic lights + GLPASS_TEXTURE, // Draws the texture to be modulated with the light information on the base surface + GLPASS_DECALS, // Draws a decal + GLPASS_DECALS_NOFOG,// Draws a decal without setting the fog (used for passes that need a fog layer) + GLPASS_TRANSLUCENT, // Draws translucent objects + GLPASS_ALL // Everything at once, using shaders for dynamic lights +}; + +//========================================================================== +// +// Intermediate struct to link one draw item into a draw list +// +// unfortunately this struct must not contain pointers because +// the arrays may be reallocated! +// +//========================================================================== + +struct GLDrawItem +{ + GLDrawItemType rendertype; + int index; + + GLDrawItem(GLDrawItemType _rendertype,int _index) : rendertype(_rendertype),index(_index) {} +}; + +struct SortNode +{ + int itemindex; + SortNode * parent; + SortNode * next; // unsorted successor + SortNode * left; // left side of this node + SortNode * equal; // equal to this node + SortNode * right; // right side of this node + + + void UnlinkFromChain(); + void Link(SortNode * hook); + void AddToEqual(SortNode * newnode); + void AddToLeft (SortNode * newnode); + void AddToRight(SortNode * newnode); +}; + +//========================================================================== +// +// One draw list. This contains all info for one type of rendering data +// +//========================================================================== + +struct GLDrawList +{ +//private: + TArray walls; + TArray flats; + TArray sprites; + TArray drawitems; + int SortNodeStart; + SortNode * sorted; + +public: + GLDrawList() + { + next=NULL; + SortNodeStart=-1; + sorted=NULL; + } + + ~GLDrawList() + { + Reset(); + } + + void AddWall(GLWall * wall); + void AddFlat(GLFlat * flat); + void AddSprite(GLSprite * sprite); + void Reset(); + void Sort(); + + + void MakeSortList(); + SortNode * FindSortPlane(SortNode * head); + SortNode * FindSortWall(SortNode * head); + void SortPlaneIntoPlane(SortNode * head,SortNode * sort); + void SortWallIntoPlane(SortNode * head,SortNode * sort); + void SortSpriteIntoPlane(SortNode * head,SortNode * sort); + void SortWallIntoWall(SortNode * head,SortNode * sort); + void SortSpriteIntoWall(SortNode * head,SortNode * sort); + int CompareSprites(SortNode * a,SortNode * b); + SortNode * SortSpriteList(SortNode * head); + SortNode * DoSort(SortNode * head); + + void DoDraw(int pass, int index); + void DoDrawSorted(SortNode * node); + void DrawSorted(); + void Draw(int pass); + + GLDrawList * next; +} ; + + +//========================================================================== +// +// these are used to link faked planes due to missing textures to a sector +// +//========================================================================== +struct gl_subsectorrendernode +{ + gl_subsectorrendernode * next; + subsector_t * sub; +}; + + +struct FDrawInfo +{ + struct wallseg + { + float x1, y1, z1, x2, y2, z2; + }; + + bool temporary; + + + + struct MissingTextureInfo + { + seg_t * seg; + subsector_t * sub; + fixed_t planez; + fixed_t planezfront; + }; + + struct MissingSegInfo + { + seg_t * seg; + int MTI_Index; // tells us which MissingTextureInfo represents this seg. + }; + + struct SubsectorHackInfo + { + subsector_t * sub; + BYTE flags; + }; + + TArray sectorrenderflags; + TArray ss_renderflags; + TArray no_renderflags; + + TArray MissingUpperTextures; + TArray MissingLowerTextures; + + TArray MissingUpperSegs; + TArray MissingLowerSegs; + + TArray SubsectorHacks; + + TArray otherfloorplanes; + TArray otherceilingplanes; + + TArray CeilingStacks; + TArray FloorStacks; + + TArray HandledSubsectors; + + FDrawInfo * next; + GLDrawList drawlists[GLDL_TYPES]; + + FDrawInfo(); + ~FDrawInfo(); + void ClearBuffers(); + + bool DoOneSectorUpper(subsector_t * subsec, fixed_t planez); + bool DoOneSectorLower(subsector_t * subsec, fixed_t planez); + bool DoFakeBridge(subsector_t * subsec, fixed_t planez); + bool DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez); + + bool CheckAnchorFloor(subsector_t * sub); + bool CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor); + bool CheckAnchorCeiling(subsector_t * sub); + bool CollectSubsectorsCeiling(subsector_t * sub, sector_t * anchor); + void CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor); + void CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor); + + void AddUpperMissingTexture(side_t * side, subsector_t *sub, fixed_t backheight); + void AddLowerMissingTexture(side_t * side, subsector_t *sub, fixed_t backheight); + void HandleMissingTextures(); + void DrawUnhandledMissingTextures(); + void AddHackedSubsector(subsector_t * sub); + void HandleHackedSubsectors(); + void AddFloorStack(sector_t * sec); + void AddCeilingStack(sector_t * sec); + void ProcessSectorStacks(); + + void AddOtherFloorPlane(int sector, gl_subsectorrendernode * node); + void AddOtherCeilingPlane(int sector, gl_subsectorrendernode * node); + + void StartScene(); + void SetupFloodStencil(wallseg * ws); + void ClearFloodStencil(wallseg * ws); + void DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, bool ceiling); + void FloodUpperGap(seg_t * seg); + void FloodLowerGap(seg_t * seg); + + static void StartDrawInfo(); + static void EndDrawInfo(); + + gl_subsectorrendernode * GetOtherFloorPlanes(unsigned int sector) + { + if (sector mList; + +public: + + FDrawInfo *GetNew(); + void Release(FDrawInfo *); +}; + + +extern FDrawInfo * gl_drawinfo; + +bool gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * gltexture); +void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending); + +#endif \ No newline at end of file diff --git a/src/gl/scene/gl_fakeflat.cpp b/src/gl/scene/gl_fakeflat.cpp new file mode 100644 index 000000000..122bae0e6 --- /dev/null +++ b/src/gl/scene/gl_fakeflat.cpp @@ -0,0 +1,397 @@ +/* +** gl_fakeflat.cpp +** Fake flat functions to render stacked sectors +** +**--------------------------------------------------------------------------- +** Copyright 2001-2011 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "p_lnspec.h" +#include "p_local.h" +#include "a_sharedglobal.h" +#include "r_sky.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/scene/gl_clipper.h" +#include "gl/data/gl_data.h" + + +//========================================================================== +// +// Check whether the player can look beyond this line +// +//========================================================================== +CVAR(Bool, gltest_slopeopt, false, 0) + +bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsector) +{ + line_t *linedef = sidedef->linedef; + fixed_t bs_floorheight1; + fixed_t bs_floorheight2; + fixed_t bs_ceilingheight1; + fixed_t bs_ceilingheight2; + fixed_t fs_floorheight1; + fixed_t fs_floorheight2; + fixed_t fs_ceilingheight1; + fixed_t fs_ceilingheight2; + + // Mirrors and horizons always block the view + //if (linedef->special==Line_Mirror || linedef->special==Line_Horizon) return true; + + // Lines with stacked sectors must never block! + + if (backsector->portals[sector_t::ceiling] != NULL || backsector->portals[sector_t::floor] != NULL || + frontsector->portals[sector_t::ceiling] != NULL || frontsector->portals[sector_t::floor] != NULL) + { + return false; + } + + // on large levels this distinction can save some time + // That's a lot of avoided multiplications if there's a lot to see! + + if (frontsector->ceilingplane.a | frontsector->ceilingplane.b) + { + fs_ceilingheight1=frontsector->ceilingplane.ZatPoint(linedef->v1); + fs_ceilingheight2=frontsector->ceilingplane.ZatPoint(linedef->v2); + } + else + { + fs_ceilingheight2=fs_ceilingheight1=frontsector->ceilingplane.d; + } + + if (frontsector->floorplane.a | frontsector->floorplane.b) + { + fs_floorheight1=frontsector->floorplane.ZatPoint(linedef->v1); + fs_floorheight2=frontsector->floorplane.ZatPoint(linedef->v2); + } + else + { + fs_floorheight2=fs_floorheight1=-frontsector->floorplane.d; + } + + if (backsector->ceilingplane.a | backsector->ceilingplane.b) + { + bs_ceilingheight1=backsector->ceilingplane.ZatPoint(linedef->v1); + bs_ceilingheight2=backsector->ceilingplane.ZatPoint(linedef->v2); + } + else + { + bs_ceilingheight2=bs_ceilingheight1=backsector->ceilingplane.d; + } + + if (backsector->floorplane.a | backsector->floorplane.b) + { + bs_floorheight1=backsector->floorplane.ZatPoint(linedef->v1); + bs_floorheight2=backsector->floorplane.ZatPoint(linedef->v2); + } + else + { + bs_floorheight2=bs_floorheight1=-backsector->floorplane.d; + } + + // now check for closed sectors! + if (bs_ceilingheight1<=fs_floorheight1 && bs_ceilingheight2<=fs_floorheight2) + { + FTexture * tex = TexMan(sidedef->GetTexture(side_t::top)); + if (!tex || tex->UseType==FTexture::TEX_Null) return false; + if (backsector->GetTexture(sector_t::ceiling)==skyflatnum && + frontsector->GetTexture(sector_t::ceiling)==skyflatnum) return false; + return true; + } + + if (fs_ceilingheight1<=bs_floorheight1 && fs_ceilingheight2<=bs_floorheight2) + { + FTexture * tex = TexMan(sidedef->GetTexture(side_t::bottom)); + if (!tex || tex->UseType==FTexture::TEX_Null) return false; + + // properly render skies (consider door "open" if both floors are sky): + if (backsector->GetTexture(sector_t::ceiling)==skyflatnum && + frontsector->GetTexture(sector_t::ceiling)==skyflatnum) return false; + return true; + } + + if (bs_ceilingheight1<=bs_floorheight1 && bs_ceilingheight2<=bs_floorheight2) + { + // preserve a kind of transparent door/lift special effect: + if (bs_ceilingheight1 < fs_ceilingheight1 || bs_ceilingheight2 < fs_ceilingheight2) + { + FTexture * tex = TexMan(sidedef->GetTexture(side_t::top)); + if (!tex || tex->UseType==FTexture::TEX_Null) return false; + } + if (bs_floorheight1 > fs_floorheight1 || bs_floorheight2 > fs_floorheight2) + { + FTexture * tex = TexMan(sidedef->GetTexture(side_t::bottom)); + if (!tex || tex->UseType==FTexture::TEX_Null) return false; + } + if (backsector->GetTexture(sector_t::ceiling)==skyflatnum && + frontsector->GetTexture(sector_t::ceiling)==skyflatnum) return false; + if (backsector->GetTexture(sector_t::floor)==skyflatnum && frontsector->GetTexture(sector_t::floor) + ==skyflatnum) return false; + return true; + } + + return false; +} + +//========================================================================== +// +// check for levels with exposed lower areas +// +//========================================================================== + +void gl_CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector) +{ + if (in_area==area_default && + (backsector->heightsec && !(backsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) && + (!frontsector->heightsec || frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) + { + sector_t * s = backsector->heightsec; + + fixed_t cz1 = frontsector->ceilingplane.ZatPoint(v1); + fixed_t cz2 = frontsector->ceilingplane.ZatPoint(v2); + fixed_t fz1 = s->floorplane.ZatPoint(v1); + fixed_t fz2 = s->floorplane.ZatPoint(v2); + + // allow some tolerance in case slopes are involved + if (cz1 <= fz1 + FRACUNIT/100 && cz2<=fz2 + FRACUNIT/100) + in_area=area_below; + else + in_area=area_normal; + } +} + + +//========================================================================== +// +// This is mostly like R_FakeFlat but with a few alterations necessitated +// by hardware rendering +// +//========================================================================== +sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back) +{ + if (!sec->heightsec || sec->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC || sec->heightsec==sec) + { + // check for backsectors with the ceiling lower than the floor. These will create + // visual glitches because upper amd lower textures overlap. + if (back && sec->planes[sector_t::floor].TexZ > sec->planes[sector_t::ceiling].TexZ) + { + if (!(sec->floorplane.a | sec->floorplane.b | sec->ceilingplane.a | sec->ceilingplane.b)) + { + *dest = *sec; + dest->ceilingplane=sec->floorplane; + dest->ceilingplane.FlipVert(); + dest->planes[sector_t::ceiling].TexZ = dest->planes[sector_t::floor].TexZ; + return dest; + } + } + return sec; + } + +#ifdef _MSC_VER +#ifdef _DEBUG + if (sec-sectors==560) + { + __asm nop + } +#endif +#endif + + if (in_area==area_above) + { + if (sec->heightsec->MoreFlags&SECF_FAKEFLOORONLY || sec->GetTexture(sector_t::ceiling)==skyflatnum) in_area=area_normal; + } + + int diffTex = (sec->heightsec->MoreFlags & SECF_CLIPFAKEPLANES); + sector_t * s = sec->heightsec; + +#if 0 + *dest=*sec; // This will invoke the copy operator which isn't really needed here. Memcpy is faster. +#else + memcpy(dest, sec, sizeof(sector_t)); +#endif + + // Replace floor and ceiling height with control sector's heights. + if (diffTex) + { + if (s->floorplane.CopyPlaneIfValid (&dest->floorplane, &sec->ceilingplane)) + { + dest->SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false); + dest->SetPlaneTexZ(sector_t::floor, s->GetPlaneTexZ(sector_t::floor)); + dest->vboindex[sector_t::floor] = sec->vboindex[sector_t::vbo_fakefloor]; + dest->vboheight[sector_t::floor] = s->vboheight[sector_t::floor]; + } + else if (s->MoreFlags & SECF_FAKEFLOORONLY) + { + if (in_area==area_below) + { + dest->ColorMap=s->ColorMap; + if (!(s->MoreFlags & SECF_NOFAKELIGHT)) + { + dest->lightlevel = s->lightlevel; + dest->SetPlaneLight(sector_t::floor, s->GetPlaneLight(sector_t::floor)); + dest->SetPlaneLight(sector_t::ceiling, s->GetPlaneLight(sector_t::ceiling)); + dest->ChangeFlags(sector_t::floor, -1, s->GetFlags(sector_t::floor)); + dest->ChangeFlags(sector_t::ceiling, -1, s->GetFlags(sector_t::ceiling)); + } + return dest; + } + return sec; + } + } + else + { + dest->SetPlaneTexZ(sector_t::floor, s->GetPlaneTexZ(sector_t::floor)); + dest->floorplane = s->floorplane; + + dest->vboindex[sector_t::floor] = sec->vboindex[sector_t::vbo_fakefloor]; + dest->vboheight[sector_t::floor] = s->vboheight[sector_t::floor]; + } + + if (!(s->MoreFlags&SECF_FAKEFLOORONLY)) + { + if (diffTex) + { + if (s->ceilingplane.CopyPlaneIfValid (&dest->ceilingplane, &sec->floorplane)) + { + dest->SetTexture(sector_t::ceiling, s->GetTexture(sector_t::ceiling), false); + dest->SetPlaneTexZ(sector_t::ceiling, s->GetPlaneTexZ(sector_t::ceiling)); + dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::vbo_fakeceiling]; + dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::ceiling]; + } + } + else + { + dest->ceilingplane = s->ceilingplane; + dest->SetPlaneTexZ(sector_t::ceiling, s->GetPlaneTexZ(sector_t::ceiling)); + dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::vbo_fakeceiling]; + dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::ceiling]; + } + } + + if (in_area==area_below) + { + dest->ColorMap=s->ColorMap; + dest->SetPlaneTexZ(sector_t::floor, sec->GetPlaneTexZ(sector_t::floor)); + dest->SetPlaneTexZ(sector_t::ceiling, s->GetPlaneTexZ(sector_t::floor)); + dest->floorplane=sec->floorplane; + dest->ceilingplane=s->floorplane; + dest->ceilingplane.FlipVert(); + + dest->vboindex[sector_t::floor] = sec->vboindex[sector_t::floor]; + dest->vboheight[sector_t::floor] = sec->vboheight[sector_t::floor]; + + dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::vbo_fakefloor]; + dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::floor]; + if (!(s->MoreFlags & SECF_NOFAKELIGHT)) + { + dest->lightlevel = s->lightlevel; + } + + if (!back) + { + dest->SetTexture(sector_t::floor, diffTex ? sec->GetTexture(sector_t::floor) : s->GetTexture(sector_t::floor), false); + dest->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform; + + //dest->ceilingplane = s->floorplane; + + if (s->GetTexture(sector_t::ceiling) == skyflatnum) + { + dest->SetTexture(sector_t::ceiling, dest->GetTexture(sector_t::floor), false); + //dest->floorplane = dest->ceilingplane; + //dest->floorplane.FlipVert (); + //dest->floorplane.ChangeHeight (+1); + dest->planes[sector_t::ceiling].xform = dest->planes[sector_t::floor].xform; + + } + else + { + dest->SetTexture(sector_t::ceiling, diffTex ? s->GetTexture(sector_t::floor) : s->GetTexture(sector_t::ceiling), false); + dest->planes[sector_t::ceiling].xform = s->planes[sector_t::ceiling].xform; + } + + if (!(s->MoreFlags & SECF_NOFAKELIGHT)) + { + dest->SetPlaneLight(sector_t::floor, s->GetPlaneLight(sector_t::floor)); + dest->SetPlaneLight(sector_t::ceiling, s->GetPlaneLight(sector_t::ceiling)); + dest->ChangeFlags(sector_t::floor, -1, s->GetFlags(sector_t::floor)); + dest->ChangeFlags(sector_t::ceiling, -1, s->GetFlags(sector_t::ceiling)); + } + } + } + else if (in_area==area_above) + { + dest->ColorMap=s->ColorMap; + dest->SetPlaneTexZ(sector_t::ceiling, sec->GetPlaneTexZ(sector_t::ceiling)); + dest->SetPlaneTexZ(sector_t::floor, s->GetPlaneTexZ(sector_t::ceiling)); + dest->ceilingplane= sec->ceilingplane; + dest->floorplane = s->ceilingplane; + dest->floorplane.FlipVert(); + + dest->vboindex[sector_t::floor] = sec->vboindex[sector_t::vbo_fakeceiling]; + dest->vboheight[sector_t::floor] = s->vboheight[sector_t::ceiling]; + + dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::ceiling]; + dest->vboheight[sector_t::ceiling] = sec->vboheight[sector_t::ceiling]; + + if (!(s->MoreFlags & SECF_NOFAKELIGHT)) + { + dest->lightlevel = s->lightlevel; + } + + if (!back) + { + dest->SetTexture(sector_t::ceiling, diffTex ? sec->GetTexture(sector_t::ceiling) : s->GetTexture(sector_t::ceiling), false); + dest->SetTexture(sector_t::floor, s->GetTexture(sector_t::ceiling), false); + dest->planes[sector_t::ceiling].xform = dest->planes[sector_t::floor].xform = s->planes[sector_t::ceiling].xform; + + if (s->GetTexture(sector_t::floor) != skyflatnum) + { + dest->SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false); + dest->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform; + } + + if (!(s->MoreFlags & SECF_NOFAKELIGHT)) + { + dest->lightlevel = s->lightlevel; + dest->SetPlaneLight(sector_t::floor, s->GetPlaneLight(sector_t::floor)); + dest->SetPlaneLight(sector_t::ceiling, s->GetPlaneLight(sector_t::ceiling)); + dest->ChangeFlags(sector_t::floor, -1, s->GetFlags(sector_t::floor)); + dest->ChangeFlags(sector_t::ceiling, -1, s->GetFlags(sector_t::ceiling)); + } + } + } + return dest; +} + + diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp new file mode 100644 index 000000000..71f2bb6c9 --- /dev/null +++ b/src/gl/scene/gl_flats.cpp @@ -0,0 +1,809 @@ +/* +** gl_flat.cpp +** Flat rendering +** +**--------------------------------------------------------------------------- +** Copyright 2000-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "a_sharedglobal.h" +#include "r_defs.h" +#include "r_sky.h" +#include "r_utility.h" +#include "g_level.h" +#include "doomstat.h" +#include "d_player.h" + +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/dynlights/gl_lightbuffer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_convert.h" +#include "gl/utility/gl_templates.h" + +//========================================================================== +// +// Sets the texture matrix according to the plane's texture positioning +// information +// +//========================================================================== + +bool gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * gltexture) +{ + // only manipulate the texture matrix if needed. + if (secplane->xoffs != 0 || secplane->yoffs != 0 || + secplane->xscale != FRACUNIT || secplane->yscale != FRACUNIT || + secplane->angle != 0 || + gltexture->TextureWidth(GLUSE_TEXTURE) != 64 || + gltexture->TextureHeight(GLUSE_TEXTURE) != 64) + { + float uoffs=FIXED2FLOAT(secplane->xoffs)/gltexture->TextureWidth(GLUSE_TEXTURE); + float voffs=FIXED2FLOAT(secplane->yoffs)/gltexture->TextureHeight(GLUSE_TEXTURE); + + float xscale1=FIXED2FLOAT(secplane->xscale); + float yscale1=FIXED2FLOAT(secplane->yscale); + if (gltexture->tex->bHasCanvas) + { + yscale1 = 0 - yscale1; + } + float angle=-ANGLE_TO_FLOAT(secplane->angle); + + float xscale2=64.f/gltexture->TextureWidth(GLUSE_TEXTURE); + float yscale2=64.f/gltexture->TextureHeight(GLUSE_TEXTURE); + + gl.MatrixMode(GL_TEXTURE); + gl.PushMatrix(); + gl.Scalef(xscale1 ,yscale1,1.0f); + gl.Translatef(uoffs,voffs,0.0f); + gl.Scalef(xscale2 ,yscale2,1.0f); + gl.Rotatef(angle,0.0f,0.0f,1.0f); + return true; + } + return false; +} + + +//========================================================================== +// +// Flats +// +//========================================================================== + +void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) +{ + Plane p; + Vector nearPt, up, right, t1; + float scale; + unsigned int k; + seg_t *v; + + FLightNode * node = sub->lighthead[pass==GLPASS_LIGHT_ADDITIVE]; + gl_RenderState.Apply(); + while (node) + { + ADynamicLight * light = node->lightsource; + + if (light->flags2&MF2_DORMANT) + { + node=node->nextLight; + continue; + } + iter_dlightf++; + + // we must do the side check here because gl_SetupLight needs the correct plane orientation + // which we don't have for Legacy-style 3D-floors + fixed_t planeh = plane.plane.ZatPoint(light->x, light->y); + if (gl_lights_checkside && ((planehz && ceiling) || (planeh>light->z && !ceiling))) + { + node=node->nextLight; + continue; + } + + p.Set(plane.plane); + if (!gl_SetupLight(p, light, nearPt, up, right, scale, Colormap.colormap, false, foggy)) + { + node=node->nextLight; + continue; + } + draw_dlightf++; + + // Render the light + gl.Begin(GL_TRIANGLE_FAN); + for(k = 0, v = sub->firstline; k < sub->numlines; k++, v++) + { + vertex_t *vt = v->v1; + float zc = plane.plane.ZatPoint(vt->fx, vt->fy) + dz; + + t1.Set(vt->fx, zc, vt->fy); + Vector nearToVert = t1 - nearPt; + gl.TexCoord2f( (nearToVert.Dot(right) * scale) + 0.5f, (nearToVert.Dot(up) * scale) + 0.5f); + + gl.Vertex3f(vt->fx, zc, vt->fy); + } + + gl.End(); + node = node->nextLight; + } +} + + +//========================================================================== +// +// Flats +// +//========================================================================== +extern FDynLightData lightdata; + +bool GLFlat::SetupSubsectorLights(bool lightsapplied, subsector_t * sub) +{ + Plane p; + + lightdata.Clear(); + for(int i=0;i<2;i++) + { + FLightNode * node = sub->lighthead[i]; + while (node) + { + ADynamicLight * light = node->lightsource; + + if (light->flags2&MF2_DORMANT) + { + node=node->nextLight; + continue; + } + iter_dlightf++; + + // we must do the side check here because gl_SetupLight needs the correct plane orientation + // which we don't have for Legacy-style 3D-floors + fixed_t planeh = plane.plane.ZatPoint(light->x, light->y); + if (gl_lights_checkside && ((planehz && ceiling) || (planeh>light->z && !ceiling))) + { + node=node->nextLight; + continue; + } + + p.Set(plane.plane); + gl_GetLight(p, light, Colormap.colormap, false, false, lightdata); + node = node->nextLight; + } + } + + int numlights[3]; + + lightdata.Combine(numlights, gl.MaxLights()); + if (numlights[2] > 0) + { + draw_dlightf+=numlights[2]/2; + gl_RenderState.EnableLight(true); + gl_RenderState.SetLights(numlights, &lightdata.arrays[0][0]); + gl_RenderState.Apply(); + return true; + } + if (lightsapplied) + { + gl_RenderState.EnableLight(false); + gl_RenderState.Apply(); + } + return false; +} + +//========================================================================== +// +// +// +//========================================================================== + +void GLFlat::DrawSubsector(subsector_t * sub) +{ + gl.Begin(GL_TRIANGLE_FAN); + + for(unsigned int k=0; knumlines; k++) + { + vertex_t *vt = sub->firstline[k].v1; + gl.TexCoord2f(vt->fx/64.f, -vt->fy/64.f); + float zc = plane.plane.ZatPoint(vt->fx, vt->fy) + dz; + gl.Vertex3f(vt->fx, zc, vt->fy); + } + gl.End(); + + flatvertices += sub->numlines; + flatprimitives++; +} + +//========================================================================== +// +// +// +//========================================================================== + +void GLFlat::DrawSubsectors(int pass, bool istrans) +{ + bool lightsapplied = false; + + gl_RenderState.Apply(); + if (sub) + { + // This represents a single subsector + if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub); + DrawSubsector(sub); + } + else + { + if (vboindex >= 0) + { + //gl.Color3f( 1.f,.5f,.5f); + int index = vboindex; + for (int i=0; isubsectorcount; i++) + { + subsector_t * sub = sector->subsectors[i]; + // This is just a quick hack to make translucent 3D floors and portals work. + if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) + { + if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub); + gl.DrawArrays(GL_TRIANGLE_FAN, index, sub->numlines); + flatvertices += sub->numlines; + flatprimitives++; + } + index += sub->numlines; + } + } + else + { + //gl.Color3f( .5f,1.f,.5f); // these are for testing the VBO stuff. + // Draw the subsectors belonging to this sector + for (int i=0; isubsectorcount; i++) + { + subsector_t * sub = sector->subsectors[i]; + if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) + { + if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub); + DrawSubsector(sub); + } + } + } + + // Draw the subsectors assigned to it due to missing textures + if (!(renderflags&SSRF_RENDER3DPLANES)) + { + gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR)? + gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) : + gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum); + + while (node) + { + if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, node->sub); + DrawSubsector(node->sub); + node = node->next; + } + } + } + gl_RenderState.EnableLight(false); +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLFlat::Draw(int pass) +{ + int i; + int rel = getExtraLight(); + +#ifdef _MSC_VER +#ifdef _DEBUG + if (sector->sectornum == 2) + __asm nop +#endif +#endif + + + switch (pass) + { + case GLPASS_BASE: + gl_SetColor(lightlevel, rel, &Colormap,1.0f); + if (!foggy) gl_SetFog(lightlevel, rel, &Colormap, false); + DrawSubsectors(pass, false); + break; + + case GLPASS_PLAIN: // Single-pass rendering + case GLPASS_ALL: + case GLPASS_BASE_MASKED: + gl_SetColor(lightlevel, rel, &Colormap,1.0f); + if (!foggy || pass != GLPASS_BASE_MASKED) gl_SetFog(lightlevel, rel, &Colormap, false); + // fall through + case GLPASS_TEXTURE: + { + gltexture->Bind(Colormap.colormap); + bool pushed = gl_SetPlaneTextureRotation(&plane, gltexture); + DrawSubsectors(pass, false); + if (pushed) + { + gl.PopMatrix(); + gl.MatrixMode(GL_MODELVIEW); + } + break; + } + + case GLPASS_LIGHT: + case GLPASS_LIGHT_ADDITIVE: + + if (!foggy) gl_SetFog((255+lightlevel)>>1, 0, &Colormap, false); + else gl_SetFog(lightlevel, 0, &Colormap, true); + + if (sub) + { + DrawSubsectorLights(sub, pass); + } + else + { + // Draw the subsectors belonging to this sector + for (i=0; isubsectorcount; i++) + { + subsector_t * sub = sector->subsectors[i]; + + if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags) + { + DrawSubsectorLights(sub, pass); + } + } + + // Draw the subsectors assigned to it due to missing textures + if (!(renderflags&SSRF_RENDER3DPLANES)) + { + gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR)? + gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) : + gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum); + + while (node) + { + DrawSubsectorLights(node->sub, pass); + node = node->next; + } + } + } + break; + + case GLPASS_TRANSLUCENT: + if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE); + gl_SetColor(lightlevel, rel, &Colormap, alpha); + gl_SetFog(lightlevel, rel, &Colormap, false); + gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_threshold*(alpha)); + if (!gltexture) + { + gl_RenderState.EnableTexture(false); + DrawSubsectors(pass, true); + gl_RenderState.EnableTexture(true); + } + else + { + if (foggy) gl_RenderState.EnableBrightmap(false); + gltexture->Bind(Colormap.colormap); + bool pushed = gl_SetPlaneTextureRotation(&plane, gltexture); + DrawSubsectors(pass, true); + gl_RenderState.EnableBrightmap(true); + if (pushed) + { + gl.PopMatrix(); + gl.MatrixMode(GL_MODELVIEW); + } + } + if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + break; + } +} + + +//========================================================================== +// +// GLFlat::PutFlat +// +// Checks texture, lighting and translucency settings and puts this +// plane in the appropriate render list. +// +//========================================================================== +inline void GLFlat::PutFlat(bool fog) +{ + int list; + + if (gl_fixedcolormap) + { + Colormap.GetFixedColormap(); + } + if (renderstyle!=STYLE_Translucent || alpha < 1.f - FLT_EPSILON || fog) + { + int list = (renderflags&SSRF_RENDER3DPLANES) ? GLDL_TRANSLUCENT : GLDL_TRANSLUCENTBORDER; + gl_drawinfo->drawlists[list].AddFlat (this); + } + else if (gltexture != NULL) + { + static DrawListType list_indices[2][2][2]={ + { { GLDL_PLAIN, GLDL_FOG }, { GLDL_MASKED, GLDL_FOGMASKED } }, + { { GLDL_LIGHT, GLDL_LIGHTFOG }, { GLDL_LIGHTMASKED, GLDL_LIGHTFOGMASKED } } + }; + + bool light = gl_forcemultipass; + bool masked = gltexture->isMasked() && ((renderflags&SSRF_RENDER3DPLANES) || stack); + + if (!gl_fixedcolormap) + { + foggy = gl_CheckFog(&Colormap, lightlevel) || level.flags&LEVEL_HASFADETABLE; + + if (gl_lights && !gl_dynlight_shader && GLRenderer->mLightCount) // Are lights touching this sector? + { + for(int i=0;isubsectorcount;i++) if (sector->subsectors[i]->lighthead[0] != NULL) + { + light=true; + } + } + } + else foggy = false; + + list = list_indices[light][masked][foggy]; + if (list == GLDL_LIGHT && gltexture->tex->gl_info.Brightmap && gl_BrightmapsActive()) list = GLDL_LIGHTBRIGHT; + + gl_drawinfo->drawlists[list].AddFlat (this); + } +} + +//========================================================================== +// +// This draws one flat +// The passed sector does not indicate the area which is rendered. +// It is only used as source for the plane data. +// The whichplane boolean indicates if the flat is a floor(false) or a ceiling(true) +// +//========================================================================== + +void GLFlat::Process(sector_t * model, int whichplane, bool fog) +{ + plane.GetFromSector(model, whichplane); + + if (!fog) + { + if (plane.texture==skyflatnum) return; + + gltexture=FMaterial::ValidateTexture(plane.texture, true); + if (!gltexture) return; + if (gltexture->tex->isFullbright()) + { + Colormap.LightColor.r = Colormap.LightColor.g = Colormap.LightColor.b = 0xff; + lightlevel=255; + } + } + else + { + gltexture = NULL; + lightlevel = abs(lightlevel); + } + + // get height from vplane + if (whichplane == sector_t::floor && sector->transdoor) dz = -1; + else dz = 0; + + z = plane.plane.ZatPoint(0.f, 0.f); + + PutFlat(fog); + rendered_flats++; +} + +//========================================================================== +// +// Sets 3D floor info. Common code for all 4 cases +// +//========================================================================== + +void GLFlat::SetFrom3DFloor(F3DFloor *rover, bool top, bool underside) +{ + F3DFloor::planeref & plane = top? rover->top : rover->bottom; + + // FF_FOG requires an inverted logic where to get the light from + lightlist_t *light = P_GetPlaneLight(sector, plane.plane, underside); + lightlevel = *light->p_lightlevel; + + if (rover->flags & FF_FOG) Colormap.LightColor = (light->extra_colormap)->Fade; + else Colormap.CopyLightColor(light->extra_colormap); + + alpha = rover->alpha/255.0f; + renderstyle = rover->flags&FF_ADDITIVETRANS? STYLE_Add : STYLE_Translucent; + if (plane.model->VBOHeightcheck(plane.isceiling)) + { + vboindex = plane.vindex; + } + else + { + vboindex = -1; + } +} + +//========================================================================== +// +// Process a sector's flats for rendering +// This function is only called once per sector. +// Subsequent subsectors are just quickly added to the ss_renderflags array +// +//========================================================================== + +void GLFlat::ProcessSector(sector_t * frontsector) +{ + lightlist_t * light; + +#ifdef _MSC_VER +#ifdef _DEBUG + if (frontsector==NULL) + { + __asm int 3 + } + if (frontsector->sectornum==0) + { + __asm nop + } +#endif +#endif + + // Get the real sector for this one. + sector=§ors[frontsector->sectornum]; + extsector_t::xfloor &x = sector->e->XFloor; + this->sub=NULL; + + byte &srf = gl_drawinfo->sectorrenderflags[sector->sectornum]; + + // + // + // + // do floors + // + // + // + if (frontsector->floorplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) <= FIXED2FLOAT(viewz)) + { + // process the original floor first. + + srf |= SSRF_RENDERFLOOR; + + lightlevel = gl_ClampLight(frontsector->GetFloorLight()); + Colormap=frontsector->ColorMap; + if ((stack = (frontsector->portals[sector_t::floor] != NULL))) + { + gl_drawinfo->AddFloorStack(sector); + alpha = frontsector->GetAlpha(sector_t::floor)/65536.0f; + } + else + { + alpha = 1.0f-frontsector->GetReflect(sector_t::floor); + } + if (frontsector->VBOHeightcheck(sector_t::floor)) + { + vboindex = frontsector->vboindex[sector_t::floor]; + } + else + { + vboindex = -1; + } + + ceiling=false; + renderflags=SSRF_RENDERFLOOR; + + if (x.ffloors.Size()) + { + light = P_GetPlaneLight(sector, &frontsector->floorplane, false); + if ((!(sector->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING) || light!=&x.lightlist[0]) + && (light->p_lightlevel != &frontsector->lightlevel)) + { + lightlevel = *light->p_lightlevel; + } + + Colormap.CopyLightColor(light->extra_colormap); + } + renderstyle = STYLE_Translucent; + if (alpha!=0.0f) Process(frontsector, false, false); + } + + // + // + // + // do ceilings + // + // + // + if (frontsector->ceilingplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) >= FIXED2FLOAT(viewz)) + { + // process the original ceiling first. + + srf |= SSRF_RENDERCEILING; + + lightlevel = gl_ClampLight(frontsector->GetCeilingLight()); + Colormap=frontsector->ColorMap; + if ((stack = (frontsector->portals[sector_t::ceiling] != NULL))) + { + gl_drawinfo->AddCeilingStack(sector); + alpha = frontsector->GetAlpha(sector_t::ceiling)/65536.0f; + } + else + { + alpha = 1.0f-frontsector->GetReflect(sector_t::ceiling); + } + + if (frontsector->VBOHeightcheck(sector_t::ceiling)) + { + vboindex = frontsector->vboindex[sector_t::ceiling]; + } + else + { + vboindex = -1; + } + + ceiling=true; + renderflags=SSRF_RENDERCEILING; + + if (x.ffloors.Size()) + { + light = P_GetPlaneLight(sector, §or->ceilingplane, true); + + if ((!(sector->GetFlags(sector_t::ceiling)&PLANEF_ABSLIGHTING)) + && (light->p_lightlevel != &frontsector->lightlevel)) + { + lightlevel = *light->p_lightlevel; + } + Colormap.CopyLightColor(light->extra_colormap); + } + renderstyle = STYLE_Translucent; + if (alpha!=0.0f) Process(frontsector, true, false); + } + + // + // + // + // do 3D floors + // + // + // + + stack=false; + if (x.ffloors.Size()) + { + player_t * player=players[consoleplayer].camera->player; + + renderflags=SSRF_RENDER3DPLANES; + srf |= SSRF_RENDER3DPLANES; + // 3d-floors must not overlap! + fixed_t lastceilingheight=sector->CenterCeiling(); // render only in the range of the + fixed_t lastfloorheight=sector->CenterFloor(); // current sector part (if applicable) + F3DFloor * rover; + int k; + + // floors are ordered now top to bottom so scanning the list for the best match + // is no longer necessary. + + ceiling=true; + for(k=0;k<(int)x.ffloors.Size();k++) + { + rover=x.ffloors[k]; + + if ((rover->flags&(FF_EXISTS|FF_RENDERPLANES|FF_THISINSIDE))==(FF_EXISTS|FF_RENDERPLANES)) + { + if (rover->flags&FF_FOG && gl_fixedcolormap) continue; + if (rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) + { + fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector)); + if (ff_toptop.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) + { + SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG)); + Colormap.FadeColor=frontsector->ColorMap->Fade; + Process(rover->top.model, rover->top.isceiling, !!(rover->flags&FF_FOG)); + } + lastceilingheight=ff_top; + } + } + if (!(rover->flags&FF_INVERTPLANES)) + { + fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector)); + if (ff_bottombottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) + { + SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG)); + Colormap.FadeColor=frontsector->ColorMap->Fade; + Process(rover->bottom.model, rover->bottom.isceiling, !!(rover->flags&FF_FOG)); + } + lastceilingheight=ff_bottom; + if (rover->alpha<255) lastceilingheight++; + } + } + } + } + + ceiling=false; + for(k=x.ffloors.Size()-1;k>=0;k--) + { + rover=x.ffloors[k]; + + if ((rover->flags&(FF_EXISTS|FF_RENDERPLANES|FF_THISINSIDE))==(FF_EXISTS|FF_RENDERPLANES)) + { + if (rover->flags&FF_FOG && gl_fixedcolormap) continue; + if (rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) + { + fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector)); + if (ff_bottom>lastfloorheight || (rover->flags&FF_FIX)) + { + if (FIXED2FLOAT(viewz) >= rover->bottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) + { + SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG)); + Colormap.FadeColor=frontsector->ColorMap->Fade; + + if (rover->flags&FF_FIX) + { + lightlevel = gl_ClampLight(rover->model->lightlevel); + Colormap = rover->GetColormap(); + } + + Process(rover->bottom.model, rover->bottom.isceiling, !!(rover->flags&FF_FOG)); + } + lastfloorheight=ff_bottom; + } + } + if (!(rover->flags&FF_INVERTPLANES)) + { + fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector)); + if (ff_top>lastfloorheight) + { + if (FIXED2FLOAT(viewz) >= rover->top.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) + { + SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG)); + Colormap.FadeColor=frontsector->ColorMap->Fade; + Process(rover->top.model, rover->top.isceiling, !!(rover->flags&FF_FOG)); + } + lastfloorheight=ff_top; + if (rover->alpha<255) lastfloorheight--; + } + } + } + } + } +} + diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp new file mode 100644 index 000000000..6c72c2219 --- /dev/null +++ b/src/gl/scene/gl_portal.cpp @@ -0,0 +1,1081 @@ +/* +** gl_portal.cpp +** Generalized portal maintenance classes for skyboxes, horizons etc. +** Requires a stencil buffer! +** +**--------------------------------------------------------------------------- +** Copyright 2004-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "p_local.h" +#include "vectors.h" +#include "c_dispatch.h" +#include "doomstat.h" +#include "a_sharedglobal.h" + +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/data/gl_data.h" +#include "gl/scene/gl_clipper.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_templates.h" +#include "gl/utility/gl_geometric.h" + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// General portal handling code +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +EXTERN_CVAR(Bool, gl_portals) +EXTERN_CVAR(Bool, gl_noquery) +EXTERN_CVAR(Int, r_mirror_recursions) + +TArray GLPortal::portals; +int GLPortal::recursion; +int GLPortal::MirrorFlag; +int GLPortal::PlaneMirrorFlag; +int GLPortal::renderdepth; +int GLPortal::PlaneMirrorMode; +GLuint GLPortal::QueryObject; + +int GLPortal::instack[2]; +bool GLPortal::inskybox; + +UniqueList UniqueSkies; +UniqueList UniqueHorizons; +UniqueList UniquePlaneMirrors; + + + +//========================================================================== +// +// +// +//========================================================================== + +void GLPortal::BeginScene() +{ + UniqueSkies.Clear(); + UniqueHorizons.Clear(); + UniquePlaneMirrors.Clear(); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLPortal::ClearScreen() +{ + bool multi = !!gl.IsEnabled(GL_MULTISAMPLE); + gl.MatrixMode(GL_MODELVIEW); + gl.PushMatrix(); + gl.MatrixMode(GL_PROJECTION); + gl.PushMatrix(); + screen->Begin2D(false); + screen->Dim(0, 1.f, 0, 0, SCREENWIDTH, SCREENHEIGHT); + gl.Enable(GL_DEPTH_TEST); + gl.MatrixMode(GL_PROJECTION); + gl.PopMatrix(); + gl.MatrixMode(GL_MODELVIEW); + gl.PopMatrix(); + if (multi) gl.Enable(GL_MULTISAMPLE); + gl_RenderState.Set2DMode(false); +} + + +//----------------------------------------------------------------------------- +// +// DrawPortalStencil +// +//----------------------------------------------------------------------------- +void GLPortal::DrawPortalStencil() +{ + for(unsigned int i=0;i 1) + { + // Cap the stencil at the top and bottom + // (cheap ass version) + gl.Begin(GL_TRIANGLE_FAN); + gl.Vertex3f(-32767.0f,32767.0f,-32767.0f); + gl.Vertex3f(-32767.0f,32767.0f, 32767.0f); + gl.Vertex3f( 32767.0f,32767.0f, 32767.0f); + gl.Vertex3f( 32767.0f,32767.0f,-32767.0f); + gl.End(); + gl.Begin(GL_TRIANGLE_FAN); + gl.Vertex3f(-32767.0f,-32767.0f,-32767.0f); + gl.Vertex3f(-32767.0f,-32767.0f, 32767.0f); + gl.Vertex3f( 32767.0f,-32767.0f, 32767.0f); + gl.Vertex3f( 32767.0f,-32767.0f,-32767.0f); + gl.End(); + } +} + + + +//----------------------------------------------------------------------------- +// +// Start +// +//----------------------------------------------------------------------------- + +bool GLPortal::Start(bool usestencil, bool doquery) +{ + rendered_portals++; + PortalAll.Clock(); + if (usestencil) + { + if (!gl_portals) + { + PortalAll.Unclock(); + return false; + } + + // Create stencil + gl.StencilFunc(GL_EQUAL,recursion,~0); // create stencil + gl.StencilOp(GL_KEEP,GL_KEEP,GL_INCR); // increment stencil of valid pixels + gl.ColorMask(0,0,0,0); // don't write to the graphics buffer + gl_RenderState.EnableTexture(false); + gl.Color3f(1,1,1); + gl.DepthFunc(GL_LESS); + gl_RenderState.Apply(); + + if (NeedDepthBuffer()) + { + gl.DepthMask(false); // don't write to Z-buffer! + if (!NeedDepthBuffer()) doquery = false; // too much overhead and nothing to gain. + else if (gl_noquery) doquery = false; + + // If occlusion query is supported let's use it to avoid rendering portals that aren't visible + if (doquery && gl.flags&RFL_OCCLUSION_QUERY) + { + if (!QueryObject) gl.GenQueries(1, &QueryObject); + if (QueryObject) + { + gl.BeginQuery(GL_SAMPLES_PASSED_ARB, QueryObject); + } + else doquery = false; // some kind of error happened + + } + + DrawPortalStencil(); + + if (doquery && gl.flags&RFL_OCCLUSION_QUERY) + { + gl.EndQuery(GL_SAMPLES_PASSED_ARB); + } + + // Clear Z-buffer + gl.StencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil + gl.StencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil + gl.DepthMask(true); // enable z-buffer again + gl.DepthRange(1,1); + gl.DepthFunc(GL_ALWAYS); + DrawPortalStencil(); + + // set normal drawing mode + gl_RenderState.EnableTexture(true); + gl.DepthFunc(GL_LESS); + gl.ColorMask(1,1,1,1); + gl.DepthRange(0,1); + + if (doquery && gl.flags&RFL_OCCLUSION_QUERY) + { + GLuint sampleCount; + + gl.GetQueryObjectuiv(QueryObject, GL_QUERY_RESULT_ARB, &sampleCount); + + if (sampleCount==0) // not visible + { + // restore default stencil op. + gl.StencilOp(GL_KEEP,GL_KEEP,GL_KEEP); + gl.StencilFunc(GL_EQUAL,recursion,~0); // draw sky into stencil + PortalAll.Unclock(); + return false; + } + } + FDrawInfo::StartDrawInfo(); + } + else + { + // No z-buffer is needed therefore we can skip all the complicated stuff that is involved + // No occlusion queries will be done here. For these portals the overhead is far greater + // than the benefit. + // Note: We must draw the stencil with z-write enabled here because there is no second pass! + + gl.DepthMask(true); + DrawPortalStencil(); + gl.StencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil + gl.StencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil + gl_RenderState.EnableTexture(true); + gl.ColorMask(1,1,1,1); + gl.Disable(GL_DEPTH_TEST); + gl.DepthMask(false); // don't write to Z-buffer! + } + recursion++; + + + } + else + { + if (NeedDepthBuffer()) + { + FDrawInfo::StartDrawInfo(); + } + else + { + gl.DepthMask(false); + gl.Disable(GL_DEPTH_TEST); + } + } + // The clip plane from the previous portal must be deactivated for this one. + clipsave = gl.IsEnabled(GL_CLIP_PLANE0+renderdepth-1); + if (clipsave) gl.Disable(GL_CLIP_PLANE0+renderdepth-1); + + // save viewpoint + savedviewx=viewx; + savedviewy=viewy; + savedviewz=viewz; + savedviewactor=GLRenderer->mViewActor; + savedviewangle=viewangle; + savedviewarea=in_area; + + NextPortal = GLRenderer->mCurrentPortal; + GLRenderer->mCurrentPortal = NULL; // Portals which need this have to set it themselves + PortalAll.Unclock(); + return true; +} + + +inline void GLPortal::ClearClipper() +{ + fixed_t angleOffset = viewangle - savedviewangle; + + clipper.Clear(); + + static int call=0; + + // Set the clipper to the minimal visible area + clipper.SafeAddClipRange(0,0xffffffff); + for(unsigned int i=0;i0) + { + clipper.SafeRemoveClipRangeRealAngles(startAngle + angleOffset, endAngle + angleOffset); + } + } + + // and finally clip it to the visible area + angle_t a1 = GLRenderer->FrustumAngle(); + if (a1mCurrentPortal = NextPortal; + if (clipsave) gl.Enable (GL_CLIP_PLANE0+renderdepth-1); + if (usestencil) + { + if (needdepth) FDrawInfo::EndDrawInfo(); + + // Restore the old view + viewx=savedviewx; + viewy=savedviewy; + viewz=savedviewz; + viewangle=savedviewangle; + GLRenderer->mViewActor=savedviewactor; + in_area=savedviewarea; + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + + gl.Color4f(1,1,1,1); + gl.ColorMask(0,0,0,0); // no graphics + gl.Color3f(1,1,1); + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(); + + if (needdepth) + { + // first step: reset the depth buffer to max. depth + gl.DepthRange(1,1); // always + gl.DepthFunc(GL_ALWAYS); // write the farthest depth value + DrawPortalStencil(); + } + else + { + gl.Enable(GL_DEPTH_TEST); + } + + // second step: restore the depth buffer to the previous values and reset the stencil + gl.DepthFunc(GL_LEQUAL); + gl.DepthRange(0,1); + gl.StencilOp(GL_KEEP,GL_KEEP,GL_DECR); + gl.StencilFunc(GL_EQUAL,recursion,~0); // draw sky into stencil + DrawPortalStencil(); + gl.DepthFunc(GL_LESS); + + + gl_RenderState.EnableTexture(true); + gl.ColorMask(1,1,1,1); + recursion--; + + // restore old stencil op. + gl.StencilOp(GL_KEEP,GL_KEEP,GL_KEEP); + gl.StencilFunc(GL_EQUAL,recursion,~0); // draw sky into stencil + } + else + { + if (needdepth) + { + FDrawInfo::EndDrawInfo(); + gl.Clear(GL_DEPTH_BUFFER_BIT); + } + else + { + gl.Enable(GL_DEPTH_TEST); + gl.DepthMask(true); + } + // Restore the old view + viewx=savedviewx; + viewy=savedviewy; + viewz=savedviewz; + viewangle=savedviewangle; + GLRenderer->mViewActor=savedviewactor; + in_area=savedviewarea; + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + + // This draws a valid z-buffer into the stencil's contents to ensure it + // doesn't get overwritten by the level's geometry. + + gl.Color4f(1,1,1,1); + gl.DepthFunc(GL_LEQUAL); + gl.DepthRange(0,1); + gl.ColorMask(0,0,0,0); // no graphics + gl_RenderState.EnableTexture(false); + DrawPortalStencil(); + gl_RenderState.EnableTexture(true); + gl.ColorMask(1,1,1,1); + gl.DepthFunc(GL_LESS); + } + PortalAll.Unclock(); +} + + +//----------------------------------------------------------------------------- +// +// StartFrame +// +//----------------------------------------------------------------------------- +void GLPortal::StartFrame() +{ + GLPortal * p=NULL; + portals.Push(p); + if (renderdepth==0) + { + inskybox=false; + instack[sector_t::floor]=instack[sector_t::ceiling]=0; + } + renderdepth++; +} + + +//----------------------------------------------------------------------------- +// +// Portal info +// +//----------------------------------------------------------------------------- + +static bool gl_portalinfo; + +CCMD(gl_portalinfo) +{ + gl_portalinfo = true; +} + +FString indent; + +//----------------------------------------------------------------------------- +// +// EndFrame +// +//----------------------------------------------------------------------------- + +void GLPortal::EndFrame() +{ + GLPortal * p; + + if (gl.flags & RFL_NOSTENCIL) + { + while (portals.Pop(p) && p) + { + delete p; + } + return; + } + + if (gl_portalinfo) + { + Printf("%s%d portals, depth = %d\n%s{\n", indent.GetChars(), portals.Size(), renderdepth, indent.GetChars()); + indent += " "; + } + + // Only use occlusion query if there are more than 2 portals. + // Otherwise there's too much overhead. + // (And don't forget to consider the separating NULL pointers!) + bool usequery = portals.Size() > 2 + (unsigned)renderdepth; + + while (portals.Pop(p) && p) + { + if (gl_portalinfo) + { + Printf("%sProcessing %s, depth = %d, query = %d\n", indent.GetChars(), p->GetName(), renderdepth, usequery); + } + if (p->lines.Size() > 0) + { + p->RenderPortal(true, usequery); + } + delete p; + } + renderdepth--; + + if (gl_portalinfo) + { + indent.Truncate(long(indent.Len()-2)); + Printf("%s}\n", indent.GetChars()); + if (portals.Size() == 0) gl_portalinfo = false; + } +} + + +//----------------------------------------------------------------------------- +// +// Renders one sky portal without a stencil. +// In more complex scenes using a stencil for skies can severly stall +// the GPU and there's rarely more than one sky visible at a time. +// +//----------------------------------------------------------------------------- +bool GLPortal::RenderFirstSkyPortal(int recursion) +{ + GLPortal * p; + GLPortal * best = NULL; + unsigned bestindex=0; + + // Find the one with the highest amount of lines. + // Normally this is also the one that saves the largest amount + // of time by drawing it before the scene itself. + for(int i = portals.Size()-1; i >= 0 && portals[i] != NULL; --i) + { + p=portals[i]; + if (p->lines.Size() > 0 && p->IsSky()) + { + // Cannot clear the depth buffer inside a portal recursion + if (recursion && p->NeedDepthBuffer()) continue; + + if (!best || p->lines.Size()>best->lines.Size()) + { + best=p; + bestindex=i; + } + } + } + + if (best) + { + portals.Delete(bestindex); + best->RenderPortal(false, false); + delete best; + return true; + } + return false; +} + + +//----------------------------------------------------------------------------- +// +// FindPortal +// +//----------------------------------------------------------------------------- + +GLPortal * GLPortal::FindPortal(const void * src) +{ + int i=portals.Size()-1; + + while (i>=0 && portals[i] && portals[i]->GetSource()!=src) i--; + return i>=0? portals[i]:NULL; +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void GLPortal::SaveMapSection() +{ + savedmapsection.Resize(currentmapsection.Size()); + memcpy(&savedmapsection[0], ¤tmapsection[0], currentmapsection.Size()); + memset(¤tmapsection[0], 0, currentmapsection.Size()); +} + +void GLPortal::RestoreMapSection() +{ + memcpy(¤tmapsection[0], &savedmapsection[0], currentmapsection.Size()); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Skybox Portal +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// +// GLSkyboxPortal::DrawContents +// +//----------------------------------------------------------------------------- +static int skyboxrecursion=0; +void GLSkyboxPortal::DrawContents() +{ + int old_pm=PlaneMirrorMode; + int saved_extralight = extralight; + + if (skyboxrecursion>=3) + { + ClearScreen(); + return; + } + + skyboxrecursion++; + origin->flags|=MF_JUSTHIT; + extralight = 0; + + PlaneMirrorMode=0; + + gl.Disable(GL_DEPTH_CLAMP_NV); + + viewx = origin->PrevX + FixedMul(r_TicFrac, origin->x - origin->PrevX); + viewy = origin->PrevY + FixedMul(r_TicFrac, origin->y - origin->PrevY); + viewz = origin->PrevZ + FixedMul(r_TicFrac, origin->z - origin->PrevZ); + viewangle += origin->PrevAngle + FixedMul(r_TicFrac, origin->angle - origin->PrevAngle); + + // Don't let the viewpoint be too close to a floor or ceiling! + fixed_t floorh = origin->Sector->floorplane.ZatPoint(origin->x, origin->y); + fixed_t ceilh = origin->Sector->ceilingplane.ZatPoint(origin->x, origin->y); + if (viewzceilh-4*FRACUNIT) viewz=ceilh-4*FRACUNIT; + + + GLRenderer->mViewActor = origin; + + validcount++; + inskybox=true; + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + GLRenderer->SetViewArea(); + ClearClipper(); + + int mapsection = R_PointInSubsector(viewx, viewy)->mapsection; + + SaveMapSection(); + currentmapsection[mapsection>>3] |= 1 << (mapsection & 7); + + GLRenderer->DrawScene(); + origin->flags&=~MF_JUSTHIT; + inskybox=false; + gl.Enable(GL_DEPTH_CLAMP_NV); + skyboxrecursion--; + + PlaneMirrorMode=old_pm; + extralight = saved_extralight; + + RestoreMapSection(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Sector stack Portal +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +GLSectorStackPortal::~GLSectorStackPortal() +{ + if (origin != NULL && origin->glportal == this) + { + origin->glportal = NULL; + } +} + +//----------------------------------------------------------------------------- +// +// GLSectorStackPortal::SetupCoverage +// +//----------------------------------------------------------------------------- + +static BYTE SetCoverage(void *node) +{ + if (numnodes == 0) + { + return 0; + } + if (!((size_t)node & 1)) // Keep going until found a subsector + { + node_t *bsp = (node_t *)node; + BYTE coverage = SetCoverage(bsp->children[0]) | SetCoverage(bsp->children[1]); + gl_drawinfo->no_renderflags[bsp-nodes] = coverage; + return coverage; + } + else + { + subsector_t *sub = (subsector_t *)((BYTE *)node - 1); + return gl_drawinfo->ss_renderflags[sub-subsectors] & SSRF_SEEN; + } +} + +void GLSectorStackPortal::SetupCoverage() +{ + for(unsigned i=0; iplane; + for(int j=0;jportalcoverage[plane].sscount; j++) + { + subsector_t *dsub = &::subsectors[sub->portalcoverage[plane].subsectors[j]]; + currentmapsection[dsub->mapsection>>3] |= 1 << (dsub->mapsection&7); + gl_drawinfo->ss_renderflags[dsub-::subsectors] |= SSRF_SEEN; + } + } + SetCoverage(&nodes[numnodes-1]); +} + +//----------------------------------------------------------------------------- +// +// GLSectorStackPortal::DrawContents +// +//----------------------------------------------------------------------------- +void GLSectorStackPortal::DrawContents() +{ + FPortal *portal = origin; + + viewx += origin->xDisplacement; + viewy += origin->yDisplacement; + GLRenderer->mViewActor = NULL; + GLRenderer->mCurrentPortal = this; + + + validcount++; + + // avoid recursions! + if (origin->plane != -1) instack[origin->plane]++; + + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + SaveMapSection(); + SetupCoverage(); + ClearClipper(); + GLRenderer->DrawScene(); + RestoreMapSection(); + + if (origin->plane != -1) instack[origin->plane]--; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Plane Mirror Portal +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// +// GLPlaneMirrorPortal::DrawContents +// +//----------------------------------------------------------------------------- + +void GLPlaneMirrorPortal::DrawContents() +{ + if (renderdepth>r_mirror_recursions) + { + ClearScreen(); + return; + } + + int old_pm=PlaneMirrorMode; + + fixed_t planez = origin->ZatPoint(viewx, viewy); + viewz = 2*planez - viewz; + GLRenderer->mViewActor = NULL; + PlaneMirrorMode = ksgn(origin->c); + + validcount++; + + PlaneMirrorFlag++; + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + ClearClipper(); + + gl.Enable(GL_CLIP_PLANE0+renderdepth); + // This only works properly for non-sloped planes so don't bother with the math. + //double d[4]={origin->a/65536., origin->c/65536., origin->b/65536., FIXED2FLOAT(origin->d)}; + double d[4]={0, PlaneMirrorMode, 0, FIXED2FLOAT(origin->d)}; + gl.ClipPlane(GL_CLIP_PLANE0+renderdepth, d); + + GLRenderer->DrawScene(); + gl.Disable(GL_CLIP_PLANE0+renderdepth); + PlaneMirrorFlag--; + PlaneMirrorMode=old_pm; +} + +//----------------------------------------------------------------------------- +// +// GLPlaneMirrorPortal::DrawContents +// +//----------------------------------------------------------------------------- + + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Mirror Portal +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// +// R_EnterMirror +// +//----------------------------------------------------------------------------- +void GLMirrorPortal::DrawContents() +{ + if (renderdepth>r_mirror_recursions) + { + ClearScreen(); + return; + } + + GLRenderer->mCurrentPortal = this; + angle_t startang = viewangle; + fixed_t startx = viewx; + fixed_t starty = viewy; + + vertex_t *v1 = linedef->v1; + vertex_t *v2 = linedef->v2; + + // Reflect the current view behind the mirror. + if (linedef->dx == 0) + { + // vertical mirror + viewx = v1->x - startx + v1->x; + + // Compensation for reendering inaccuracies + if (startxx) viewx -= FRACUNIT/2; + else viewx += FRACUNIT/2; + } + else if (linedef->dy == 0) + { + // horizontal mirror + viewy = v1->y - starty + v1->y; + + // Compensation for reendering inaccuracies + if (startyy) viewy -= FRACUNIT/2; + else viewy += FRACUNIT/2; + } + else + { + // any mirror--use floats to avoid integer overflow. + // Use doubles to avoid losing precision which is very important here. + + double dx = FIXED2FLOAT(v2->x - v1->x); + double dy = FIXED2FLOAT(v2->y - v1->y); + double x1 = FIXED2FLOAT(v1->x); + double y1 = FIXED2FLOAT(v1->y); + double x = FIXED2FLOAT(startx); + double y = FIXED2FLOAT(starty); + + // the above two cases catch len == 0 + double r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy); + + viewx = FLOAT2FIXED((x1 + r * dx)*2 - x); + viewy = FLOAT2FIXED((y1 + r * dy)*2 - y); + + // Compensation for reendering inaccuracies + FVector2 v(-dx, dy); + v.MakeUnit(); + + viewx+= FLOAT2FIXED(v[1] * renderdepth / 2); + viewy+= FLOAT2FIXED(v[0] * renderdepth / 2); + } + // we cannot afford any imprecisions caused by R_PointToAngle2 here. They'd be visible as seams around the mirror. + viewangle = 2*R_PointToAnglePrecise (linedef->v1->x, linedef->v1->y, + linedef->v2->x, linedef->v2->y) - startang; + + GLRenderer->mViewActor = NULL; + + validcount++; + + MirrorFlag++; + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + + clipper.Clear(); + + angle_t af = GLRenderer->FrustumAngle(); + if (afv1->GetClipAngle(); + angle_t a1 = linedef->v2->GetClipAngle(); + clipper.SafeAddClipRange(a1,a2); + + GLRenderer->DrawScene(); + + MirrorFlag--; +} + + +int GLMirrorPortal::ClipSeg(seg_t *seg) +{ + // this seg is completely behind the mirror! + if (P_PointOnLineSide(seg->v1->x, seg->v1->y, linedef) && + P_PointOnLineSide(seg->v2->x, seg->v2->y, linedef)) + { + return PClip_InFront; + } + return PClip_Inside; +} + +int GLMirrorPortal::ClipPoint(fixed_t x, fixed_t y) +{ + if (P_PointOnLineSide(x, y, linedef)) + { + return PClip_InFront; + } + return PClip_Inside; +} + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Horizon Portal +// +// This simply draws the area in medium sized squares. Drawing it as a whole +// polygon creates visible inaccuracies. +// +// Originally I tried to minimize the amount of data to be drawn but there +// are 2 problems with it: +// +// 1. Setting this up completely negates any performance gains. +// 2. It doesn't work with a 360° field of view (as when you are looking up.) +// +// +// So the brute force mechanism is just as good. +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// GLHorizonPortal::DrawContents +// +//----------------------------------------------------------------------------- +void GLHorizonPortal::DrawContents() +{ + PortalAll.Clock(); + + GLSectorPlane * sp=&origin->plane; + FMaterial * gltexture; + PalEntry color; + float z; + player_t * player=&players[consoleplayer]; + + gltexture=FMaterial::ValidateTexture(sp->texture, true); + if (!gltexture) + { + ClearScreen(); + PortalAll.Unclock(); + return; + } + + + z=FIXED2FLOAT(sp->texheight); + + + if (gltexture && gltexture->tex->isFullbright()) + { + // glowing textures are always drawn full bright without color + gl_SetColor(255, 0, NULL, 1.f); + gl_SetFog(255, 0, &origin->colormap, false); + } + else + { + int rel = getExtraLight(); + gl_SetColor(origin->lightlevel, rel, &origin->colormap, 1.0f); + gl_SetFog(origin->lightlevel, rel, &origin->colormap, false); + } + + + gltexture->Bind(origin->colormap.colormap); + + gl_RenderState.EnableAlphaTest(false); + gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); + gl_RenderState.Apply(); + + + bool pushed = gl_SetPlaneTextureRotation(sp, gltexture); + + float vx=FIXED2FLOAT(viewx); + float vy=FIXED2FLOAT(viewy); + + // Draw to some far away boundary + for(float x=-32768+vx; x<32768+vx; x+=4096) + { + for(float y=-32768+vy; y<32768+vy;y+=4096) + { + gl.Begin(GL_TRIANGLE_FAN); + + gl.TexCoord2f(x/64, -y/64); + gl.Vertex3f(x, z, y); + + gl.TexCoord2f(x/64 + 64, -y/64); + gl.Vertex3f(x + 4096, z, y); + + gl.TexCoord2f(x/64 + 64, -y/64 - 64); + gl.Vertex3f(x + 4096, z, y + 4096); + + gl.TexCoord2f(x/64, -y/64 - 64); + gl.Vertex3f(x, z, y + 4096); + + gl.End(); + + } + } + + float vz=FIXED2FLOAT(viewz); + float tz=(z-vz);///64.0f; + + // fill the gap between the polygon and the true horizon + // Since I can't draw into infinity there can always be a + // small gap + + gl.Begin(GL_TRIANGLE_STRIP); + + gl.TexCoord2f(512.f, 0); + gl.Vertex3f(-32768+vx, z, -32768+vy); + gl.TexCoord2f(512.f, tz); + gl.Vertex3f(-32768+vx, vz, -32768+vy); + + gl.TexCoord2f(-512.f, 0); + gl.Vertex3f(-32768+vx, z, 32768+vy); + gl.TexCoord2f(-512.f, tz); + gl.Vertex3f(-32768+vx, vz, 32768+vy); + + gl.TexCoord2f(512.f, 0); + gl.Vertex3f( 32768+vx, z, 32768+vy); + gl.TexCoord2f(512.f, tz); + gl.Vertex3f( 32768+vx, vz, 32768+vy); + + gl.TexCoord2f(-512.f, 0); + gl.Vertex3f( 32768+vx, z, -32768+vy); + gl.TexCoord2f(-512.f, tz); + gl.Vertex3f( 32768+vx, vz, -32768+vy); + + gl.TexCoord2f(512.f, 0); + gl.Vertex3f(-32768+vx, z, -32768+vy); + gl.TexCoord2f(512.f, tz); + gl.Vertex3f(-32768+vx, vz, -32768+vy); + + gl.End(); + + if (pushed) + { + gl.PopMatrix(); + gl.MatrixMode(GL_MODELVIEW); + } + + PortalAll.Unclock(); + +} + +const char *GLSkyPortal::GetName() { return "Sky"; } +const char *GLSkyboxPortal::GetName() { return "Skybox"; } +const char *GLSectorStackPortal::GetName() { return "Sectorstack"; } +const char *GLPlaneMirrorPortal::GetName() { return "Planemirror"; } +const char *GLMirrorPortal::GetName() { return "Mirror"; } +const char *GLHorizonPortal::GetName() { return "Horizon"; } diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h new file mode 100644 index 000000000..b04873ec8 --- /dev/null +++ b/src/gl/scene/gl_portal.h @@ -0,0 +1,300 @@ +/* +** gl_renderstruct.h +** Generalized portal maintenance classes to make rendering special effects easier +** and help add future extensions +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#ifndef __GL_PORTAL_H +#define __GL_PORTAL_H + +#include "tarray.h" +//#include "gl/gl_intern.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/utility/gl_templates.h" + +class ASkyViewpoint; + +struct GLHorizonInfo +{ + GLSectorPlane plane; + int lightlevel; + FColormap colormap; +}; + +struct GLSkyInfo +{ + float x_offset[2]; + float y_offset; // doubleskies don't have a y-offset + FMaterial * texture[2]; + FTextureID skytexno1; + bool mirrored; + bool doublesky; + bool sky2; + PalEntry fadecolor; // if this isn't made part of the dome things will become more complicated when sky fog is used. + + bool operator==(const GLSkyInfo & inf) + { + return !memcmp(this, &inf, sizeof(*this)); + } + bool operator!=(const GLSkyInfo & inf) + { + return !!memcmp(this, &inf, sizeof(*this)); + } +}; + +extern UniqueList UniqueSkies; +extern UniqueList UniqueHorizons; +extern UniqueList UniquePlaneMirrors; + +class GLPortal +{ + static TArray portals; + static int recursion; + static unsigned int QueryObject; +protected: + static int MirrorFlag; + static int PlaneMirrorFlag; + static int renderdepth; + +public: + static int PlaneMirrorMode; + static int inupperstack; + static int instack[2]; + static bool inskybox; + +private: + void DrawPortalStencil(); + + fixed_t savedviewx; + fixed_t savedviewy; + fixed_t savedviewz; + angle_t savedviewangle; + AActor * savedviewactor; + area_t savedviewarea; + unsigned char clipsave; + GLPortal *NextPortal; + TArray savedmapsection; + +protected: + TArray lines; + int level; + + GLPortal() { portals.Push(this); } + virtual ~GLPortal() { } + + bool Start(bool usestencil, bool doquery); + void End(bool usestencil); + virtual void DrawContents()=0; + virtual void * GetSource() const =0; // GetSource MUST be implemented! + void ClearClipper(); + virtual bool IsSky() { return false; } + virtual bool NeedCap() { return true; } + virtual bool NeedDepthBuffer() { return true; } + void ClearScreen(); + virtual const char *GetName() = 0; + void SaveMapSection(); + void RestoreMapSection(); + +public: + + enum + { + PClip_InFront, + PClip_Inside, + PClip_Behind + }; + + void RenderPortal(bool usestencil, bool doquery) + { + // Start may perform an occlusion query. If that returns 0 there + // is no need to draw the stencil's contents and there's also no + // need to restore the affected area becasue there is none! + if (Start(usestencil, doquery)) + { + DrawContents(); + End(usestencil); + } + } + + void AddLine(GLWall * l) + { + lines.Push(*l); + } + + static int GetRecursion() + { + return recursion; + } + + virtual int ClipSeg(seg_t *seg) { return PClip_Inside; } + virtual int ClipPoint(fixed_t x, fixed_t y) { return PClip_Inside; } + + static void BeginScene(); + static void StartFrame(); + static bool RenderFirstSkyPortal(int recursion); + static void EndFrame(); + static GLPortal * FindPortal(const void * src); +}; + + +struct GLMirrorPortal : public GLPortal +{ + // mirror portals always consist of single linedefs! + line_t * linedef; + +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return linedef; } + virtual const char *GetName(); + +public: + + GLMirrorPortal(line_t * line) + { + linedef=line; + } + + virtual bool NeedCap() { return false; } + virtual int ClipSeg(seg_t *seg); + virtual int ClipPoint(fixed_t x, fixed_t y); +}; + + +struct GLSkyboxPortal : public GLPortal +{ + AActor * origin; + +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return origin; } + virtual bool IsSky() { return true; } // later! + virtual const char *GetName(); + +public: + + + GLSkyboxPortal(AActor * pt) + { + origin=pt; + } + +}; + + +struct GLSkyPortal : public GLPortal +{ + GLSkyInfo * origin; + +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return origin; } + virtual bool IsSky() { return true; } + virtual bool NeedDepthBuffer() { return false; } + virtual const char *GetName(); + +public: + + + GLSkyPortal(GLSkyInfo * pt) + { + origin=pt; + } + +}; + + + +struct GLSectorStackPortal : public GLPortal +{ + TArray subsectors; +protected: + virtual ~GLSectorStackPortal(); + virtual void DrawContents(); + virtual void * GetSource() const { return origin; } + virtual bool IsSky() { return true; } // although this isn't a real sky it can be handled as one. + virtual const char *GetName(); + FPortal *origin; + +public: + + GLSectorStackPortal(FPortal *pt) + { + origin=pt; + } + void SetupCoverage(); + void AddSubsector(subsector_t *sub) + { + subsectors.Push(sub); + } + +}; + +struct GLPlaneMirrorPortal : public GLPortal +{ +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return origin; } + virtual const char *GetName(); + secplane_t * origin; + +public: + + GLPlaneMirrorPortal(secplane_t * pt) + { + origin=pt; + } + +}; + + +struct GLHorizonPortal : public GLPortal +{ + GLHorizonInfo * origin; + +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return origin; } + virtual bool NeedDepthBuffer() { return false; } + virtual bool NeedCap() { return false; } + virtual const char *GetName(); + +public: + + GLHorizonPortal(GLHorizonInfo * pt) + { + origin=pt; + } + +}; + +#endif diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp new file mode 100644 index 000000000..a6452a01f --- /dev/null +++ b/src/gl/scene/gl_renderhacks.cpp @@ -0,0 +1,1247 @@ +/* +** gl_missingtexture.cpp +** Handles missing upper and lower textures and self referencing sector hacks +** +**--------------------------------------------------------------------------- +** Copyright 2000-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "a_sharedglobal.h" +#include "r_utility.h" +#include "r_defs.h" +#include "r_sky.h" +#include "g_level.h" + + +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/dynlights/gl_lightbuffer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_templates.h" + + +// This is for debugging maps. + +FreeList SSR_List; + +// profiling data +static int totalupper, totallower; +static int lowershcount, uppershcount; +static glcycle_t totalms, showtotalms; +static glcycle_t totalssms; +static sector_t fakesec; + +void FDrawInfo::ClearBuffers() +{ + for(unsigned int i=0;i< otherfloorplanes.Size();i++) + { + gl_subsectorrendernode * node = otherfloorplanes[i]; + while (node) + { + gl_subsectorrendernode * n = node; + node = node->next; + SSR_List.Release(n); + } + } + otherfloorplanes.Clear(); + + for(unsigned int i=0;i< otherceilingplanes.Size();i++) + { + gl_subsectorrendernode * node = otherceilingplanes[i]; + while (node) + { + gl_subsectorrendernode * n = node; + node = node->next; + SSR_List.Release(n); + } + } + otherceilingplanes.Clear(); + + // clear all the lists that might not have been cleared already + MissingUpperTextures.Clear(); + MissingLowerTextures.Clear(); + MissingUpperSegs.Clear(); + MissingLowerSegs.Clear(); + SubsectorHacks.Clear(); + CeilingStacks.Clear(); + FloorStacks.Clear(); + HandledSubsectors.Clear(); + +} +//========================================================================== +// +// Adds a subsector plane to a sector's render list +// +//========================================================================== + +void FDrawInfo::AddOtherFloorPlane(int sector, gl_subsectorrendernode * node) +{ + int oldcnt = otherfloorplanes.Size(); + + if (oldcnt<=sector) + { + otherfloorplanes.Resize(sector+1); + for(int i=oldcnt;i<=sector;i++) otherfloorplanes[i]=NULL; + } + node->next = otherfloorplanes[sector]; + otherfloorplanes[sector] = node; +} + +void FDrawInfo::AddOtherCeilingPlane(int sector, gl_subsectorrendernode * node) +{ + int oldcnt = otherceilingplanes.Size(); + + if (oldcnt<=sector) + { + otherceilingplanes.Resize(sector+1); + for(int i=oldcnt;i<=sector;i++) otherceilingplanes[i]=NULL; + } + node->next = otherceilingplanes[sector]; + otherceilingplanes[sector] = node; +} + + +//========================================================================== +// +// Collects all sectors that might need a fake ceiling +// +//========================================================================== +void FDrawInfo::AddUpperMissingTexture(side_t * side, subsector_t *sub, fixed_t backheight) +{ + if (!side->segs[0]->backsector) return; + + totalms.Clock(); + for(int i=0; inumsegs; i++) + { + seg_t *seg = side->segs[i]; + + // we need find the seg belonging to the passed subsector + if (seg->Subsector == sub) + { + MissingTextureInfo mti = {}; + MissingSegInfo msi; + + + if (sub->render_sector != sub->sector || seg->frontsector != sub->sector) + { + totalms.Unclock(); + return; + } + + //@sync-hack + for(unsigned int i=0;isegs[0]->backsector; + if (!backsec) return; + if (backsec->transdoor) + { + // Transparent door hacks alter the backsector's floor height so we should not + // process the missing texture for them. + if (backsec->transdoorheight == backsec->GetPlaneTexZ(sector_t::floor)) return; + } + + totalms.Clock(); + // we need to check all segs of this sidedef + for(int i=0; inumsegs; i++) + { + seg_t *seg = side->segs[i]; + + // we need find the seg belonging to the passed subsector + if (seg->Subsector == sub) + { + MissingTextureInfo mti = {}; + MissingSegInfo msi; + + subsector_t * sub = seg->Subsector; + + if (sub->render_sector != sub->sector || seg->frontsector != sub->sector) + { + totalms.Unclock(); + return; + } + + // Ignore FF_FIX's because they are designed to abuse missing textures + if (seg->backsector->e->XFloor.ffloors.Size() && seg->backsector->e->XFloor.ffloors[0]->flags&FF_FIX) + { + totalms.Unclock(); + return; + } + + //@sync-hack + for(unsigned int i=0;i MissingLowerTextures[i].planez) + { + MissingLowerTextures[i].planez = backheight; + MissingLowerTextures[i].seg = seg; + } + + msi.MTI_Index = i; + msi.seg=seg; + MissingLowerSegs.Push(msi); + totalms.Unclock(); + return; + } + } + mti.seg=seg; + mti.sub = sub; + mti.planez=backheight; + msi.MTI_Index = MissingLowerTextures.Push(mti); + msi.seg=seg; + MissingLowerSegs.Push(msi); + } + } + totalms.Unclock(); +} + + +//========================================================================== +// +// +// +//========================================================================== +bool FDrawInfo::DoOneSectorUpper(subsector_t * subsec, fixed_t planez) +{ + // Is there a one-sided wall in this sector? + // Do this first to avoid unnecessary recursion + for(DWORD i=0; i< subsec->numlines; i++) + { + if (subsec->firstline[i].backsector == NULL) return false; + if (subsec->firstline[i].PartnerSeg == NULL) return false; + } + + for(DWORD i=0; i< subsec->numlines; i++) + { + seg_t * seg = subsec->firstline +i; + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // already checked? + if (backsub->validcount == validcount) continue; + backsub->validcount=validcount; + + if (seg->frontsector != seg->backsector && seg->linedef) + { + // Note: if this is a real line between sectors + // we can be sure that render_sector is the real sector! + + sector_t * sec = gl_FakeFlat(seg->backsector, &fakesec, true); + + // Don't bother with slopes + if (sec->ceilingplane.a!=0 || sec->ceilingplane.b!=0) return false; + + // Is the neighboring ceiling lower than the desired height? + if (sec->GetPlaneTexZ(sector_t::ceiling)GetPlaneTexZ(sector_t::ceiling)==planez) + { + // If there's a texture abort + FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::top)]; + if (!tex || tex->UseType==FTexture::TEX_Null) continue; + else return false; + } + } + if (!DoOneSectorUpper(backsub, planez)) return false; + } + // all checked ok. This subsector is part of the current fake plane + + HandledSubsectors.Push(subsec); + return 1; +} + +//========================================================================== +// +// +// +//========================================================================== +bool FDrawInfo::DoOneSectorLower(subsector_t * subsec, fixed_t planez) +{ + // Is there a one-sided wall in this subsector? + // Do this first to avoid unnecessary recursion + for(DWORD i=0; i< subsec->numlines; i++) + { + if (subsec->firstline[i].backsector == NULL) return false; + if (subsec->firstline[i].PartnerSeg == NULL) return false; + } + + for(DWORD i=0; i< subsec->numlines; i++) + { + seg_t * seg = subsec->firstline + i; + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // already checked? + if (backsub->validcount == validcount) continue; + backsub->validcount=validcount; + + if (seg->frontsector != seg->backsector && seg->linedef) + { + // Note: if this is a real line between sectors + // we can be sure that render_sector is the real sector! + + sector_t * sec = gl_FakeFlat(seg->backsector, &fakesec, true); + + // Don't bother with slopes + if (sec->floorplane.a!=0 || sec->floorplane.b!=0) return false; + + // Is the neighboring floor higher than the desired height? + if (sec->GetPlaneTexZ(sector_t::floor)>planez) + { + // todo: check for missing textures. + return false; + } + + // This is an exact height match which means we don't have to do any further checks for this sector + if (sec->GetPlaneTexZ(sector_t::floor)==planez) + { + // If there's a texture abort + FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::bottom)]; + if (!tex || tex->UseType==FTexture::TEX_Null) continue; + else return false; + } + } + if (!DoOneSectorLower(backsub, planez)) return false; + } + // all checked ok. This sector is part of the current fake plane + + HandledSubsectors.Push(subsec); + return 1; +} + + +//========================================================================== +// +// +// +//========================================================================== +bool FDrawInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez) +{ + // Is there a one-sided wall in this sector? + // Do this first to avoid unnecessary recursion + for(DWORD i=0; i< subsec->numlines; i++) + { + if (subsec->firstline[i].backsector == NULL) return false; + if (subsec->firstline[i].PartnerSeg == NULL) return false; + } + + for(DWORD i=0; i< subsec->numlines; i++) + { + seg_t * seg = subsec->firstline + i; + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // already checked? + if (backsub->validcount == validcount) continue; + backsub->validcount=validcount; + + if (seg->frontsector != seg->backsector && seg->linedef) + { + // Note: if this is a real line between sectors + // we can be sure that render_sector is the real sector! + + sector_t * sec = gl_FakeFlat(seg->backsector, &fakesec, true); + + // Don't bother with slopes + if (sec->floorplane.a!=0 || sec->floorplane.b!=0) return false; + + // Is the neighboring floor higher than the desired height? + if (sec->GetPlaneTexZ(sector_t::floor)GetPlaneTexZ(sector_t::floor)==planez) continue; + } + if (!DoFakeBridge(backsub, planez)) return false; + } + // all checked ok. This sector is part of the current fake plane + + HandledSubsectors.Push(subsec); + return 1; +} + +//========================================================================== +// +// +// +//========================================================================== +bool FDrawInfo::DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez) +{ + // Is there a one-sided wall in this sector? + // Do this first to avoid unnecessary recursion + for(DWORD i=0; i< subsec->numlines; i++) + { + if (subsec->firstline[i].backsector == NULL) return false; + if (subsec->firstline[i].PartnerSeg == NULL) return false; + } + + for(DWORD i=0; i< subsec->numlines; i++) + { + seg_t * seg = subsec->firstline + i; + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // already checked? + if (backsub->validcount == validcount) continue; + backsub->validcount=validcount; + + if (seg->frontsector != seg->backsector && seg->linedef) + { + // Note: if this is a real line between sectors + // we can be sure that render_sector is the real sector! + + sector_t * sec = gl_FakeFlat(seg->backsector, &fakesec, true); + + // Don't bother with slopes + if (sec->ceilingplane.a!=0 || sec->ceilingplane.b!=0) return false; + + // Is the neighboring ceiling higher than the desired height? + if (sec->GetPlaneTexZ(sector_t::ceiling)>planez) + { + // todo: check for missing textures. + return false; + } + + // This is an exact height match which means we don't have to do any further checks for this sector + // No texture checks though! + if (sec->GetPlaneTexZ(sector_t::ceiling)==planez) continue; + } + if (!DoFakeCeilingBridge(backsub, planez)) return false; + } + // all checked ok. This sector is part of the current fake plane + + HandledSubsectors.Push(subsec); + return 1; +} + + +//========================================================================== +// +// Draws the fake planes +// +//========================================================================== +void FDrawInfo::HandleMissingTextures() +{ + sector_t fake; + totalms.Clock(); + totalupper=MissingUpperTextures.Size(); + totallower=MissingLowerTextures.Size(); + + for(unsigned int i=0;i viewz) + { + // close the hole only if all neighboring sectors are an exact height match + // Otherwise just fill in the missing textures. + MissingUpperTextures[i].sub->validcount=validcount; + if (DoOneSectorUpper(MissingUpperTextures[i].sub, MissingUpperTextures[i].planez)) + { + sector_t * sec = MissingUpperTextures[i].seg->backsector; + // The mere fact that this seg has been added to the list means that the back sector + // will be rendered so we can safely assume that it is already in the render list + + for(unsigned int j=0;jsub = HandledSubsectors[j]; + + AddOtherCeilingPlane(sec->sectornum, node); + } + + if (HandledSubsectors.Size()!=1) + { + // mark all subsectors in the missing list that got processed by this + for(unsigned int j=0;jPartnerSeg) continue; + subsector_t *backsub = MissingUpperTextures[i].seg->PartnerSeg->Subsector; + if (!backsub) continue; + validcount++; + HandledSubsectors.Clear(); + + { + // It isn't a hole. Now check whether it might be a fake bridge + sector_t * fakesector = gl_FakeFlat(MissingUpperTextures[i].seg->frontsector, &fake, false); + fixed_t planez = fakesector->GetPlaneTexZ(sector_t::ceiling); + + backsub->validcount=validcount; + if (DoFakeCeilingBridge(backsub, planez)) + { + // The mere fact that this seg has been added to the list means that the back sector + // will be rendered so we can safely assume that it is already in the render list + + for(unsigned int j=0;jsub = HandledSubsectors[j]; + AddOtherCeilingPlane(fakesector->sectornum, node); + } + } + continue; + } + } + + for(unsigned int i=0;ivalidcount=validcount; + if (DoOneSectorLower(MissingLowerTextures[i].sub, MissingLowerTextures[i].planez)) + { + sector_t * sec = MissingLowerTextures[i].seg->backsector; + // The mere fact that this seg has been added to the list means that the back sector + // will be rendered so we can safely assume that it is already in the render list + + for(unsigned int j=0;jsub = HandledSubsectors[j]; + AddOtherFloorPlane(sec->sectornum, node); + } + + if (HandledSubsectors.Size()!=1) + { + // mark all subsectors in the missing list that got processed by this + for(unsigned int j=0;jPartnerSeg) continue; + subsector_t *backsub = MissingLowerTextures[i].seg->PartnerSeg->Subsector; + if (!backsub) continue; + validcount++; + HandledSubsectors.Clear(); + + { + // It isn't a hole. Now check whether it might be a fake bridge + sector_t * fakesector = gl_FakeFlat(MissingLowerTextures[i].seg->frontsector, &fake, false); + fixed_t planez = fakesector->GetPlaneTexZ(sector_t::floor); + + backsub->validcount=validcount; + if (DoFakeBridge(backsub, planez)) + { + // The mere fact that this seg has been added to the list means that the back sector + // will be rendered so we can safely assume that it is already in the render list + + for(unsigned int j=0;jsub = HandledSubsectors[j]; + AddOtherFloorPlane(fakesector->sectornum, node); + } + } + continue; + } + } + + totalms.Unclock(); + showtotalms=totalms; + totalms.Reset(); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void FDrawInfo::DrawUnhandledMissingTextures() +{ + validcount++; + for(int i=MissingUpperSegs.Size()-1; i>=0; i--) + { + int index = MissingUpperSegs[i].MTI_Index; + if (index>=0 && MissingUpperTextures[index].seg==NULL) continue; + + seg_t * seg = MissingUpperSegs[i].seg; + + // already done! + if (seg->linedef->validcount==validcount) continue; // already done + seg->linedef->validcount=validcount; + if (seg->frontsector->GetPlaneTexZ(sector_t::ceiling) < viewz) continue; // out of sight + //if (seg->frontsector->ceilingpic==skyflatnum) continue; + + // FIXME: The check for degenerate subsectors should be more precise + if (seg->PartnerSeg && (seg->PartnerSeg->Subsector->flags & SSECF_DEGENERATE)) continue; + if (seg->backsector->transdoor) continue; + if (seg->backsector->GetTexture(sector_t::ceiling)==skyflatnum) continue; + if (seg->backsector->portals[sector_t::ceiling] != NULL) continue; + + if (!glset.notexturefill) FloodUpperGap(seg); + } + + validcount++; + for(int i=MissingLowerSegs.Size()-1; i>=0; i--) + { + int index = MissingLowerSegs[i].MTI_Index; + if (index>=0 && MissingLowerTextures[index].seg==NULL) continue; + + seg_t * seg = MissingLowerSegs[i].seg; + + // already done! + if (seg->linedef->validcount==validcount) continue; // already done + seg->linedef->validcount=validcount; + if (!(sectorrenderflags[seg->backsector->sectornum] & SSRF_RENDERFLOOR)) continue; + if (seg->frontsector->GetPlaneTexZ(sector_t::floor) > viewz) continue; // out of sight + if (seg->backsector->transdoor) continue; + if (seg->backsector->GetTexture(sector_t::floor)==skyflatnum) continue; + if (seg->backsector->portals[sector_t::floor] != NULL) continue; + + if (!glset.notexturefill) FloodLowerGap(seg); + } + MissingUpperTextures.Clear(); + MissingLowerTextures.Clear(); + MissingUpperSegs.Clear(); + MissingLowerSegs.Clear(); + +} + +void AppendMissingTextureStats(FString &out) +{ + out.AppendFormat("Missing textures: %d upper, %d lower, %.3f ms\n", + totalupper, totallower, showtotalms.TimeMS()); +} + +ADD_STAT(missingtextures) +{ + FString out; + AppendMissingTextureStats(out); + return out; +} + + +//========================================================================== +// +// Multi-sector deep water hacks +// +//========================================================================== + +void FDrawInfo::AddHackedSubsector(subsector_t * sub) +{ + if (!(level.maptype == MAPTYPE_HEXEN)) + { + //@sync-hack (probably not, this is only called from the main thread) + SubsectorHackInfo sh={sub, 0}; + SubsectorHacks.Push (sh); + } +} + +//========================================================================== +// +// Finds a subsector whose plane can be used for rendering +// +//========================================================================== + +bool FDrawInfo::CheckAnchorFloor(subsector_t * sub) +{ + // This subsector has a one sided wall and can be used. + if (sub->hacked==3) return true; + if (sub->flags & SSECF_DEGENERATE) return false; + + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (!seg->PartnerSeg) return true; + + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // Find a linedef with a different visplane on the other side. + if (!(backsub->flags & SSECF_DEGENERATE) && seg->linedef && + (sub->render_sector != backsub->render_sector && sub->sector != backsub->sector)) + { + // I'm ignoring slopes, scaling and rotation here. The likelihood of ZDoom maps + // using such crap hacks is simply too small + if (sub->render_sector->GetTexture(sector_t::floor)==backsub->render_sector->GetTexture(sector_t::floor) && + sub->render_sector->GetPlaneTexZ(sector_t::floor)==backsub->render_sector->GetPlaneTexZ(sector_t::floor) && + sub->render_sector->GetFloorLight() == backsub->render_sector->GetFloorLight()) + { + continue; + } + // This means we found an adjoining subsector that clearly would go into another + // visplane. That means that this subsector can be used as an anchor. + return true; + } + } + return false; +} + +//========================================================================== +// +// Collect connected subsectors that have to be rendered with the same plane +// +//========================================================================== +static bool inview; +static subsector_t * viewsubsector; +static TArray lowersegs; + +bool FDrawInfo::CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor) +{ + + // mark it checked + sub->validcount=validcount; + + + // We must collect any subsector that either is connected to this one with a miniseg + // or has the same visplane. + // We must not collect any subsector that has the anchor's visplane! + if (!(sub->flags & SSECF_DEGENERATE)) + { + // Is not being rendered so don't bother. + if (!(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return true; + + if (sub->render_sector->GetTexture(sector_t::floor) != anchor->GetTexture(sector_t::floor) || + sub->render_sector->GetPlaneTexZ(sector_t::floor)!=anchor->GetPlaneTexZ(sector_t::floor) || + sub->render_sector->GetFloorLight() != anchor->GetFloorLight()) + { + if (sub==viewsubsector && viewzGetPlaneTexZ(sector_t::floor)) inview=true; + HandledSubsectors.Push (sub); + } + } + + // We can assume that all segs in this subsector are connected to a subsector that has + // to be checked as well + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (seg->PartnerSeg) + { + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // could be an anchor itself. + if (!CheckAnchorFloor (backsub)) // must not be an anchor itself! + { + if (backsub->validcount!=validcount) + { + if (!CollectSubsectorsFloor (backsub, anchor)) return false; + } + } + else if (sub->render_sector == backsub->render_sector) + { + // Any anchor not within the original anchor's visplane terminates the processing. + if (sub->render_sector->GetTexture(sector_t::floor)!=anchor->GetTexture(sector_t::floor) || + sub->render_sector->GetPlaneTexZ(sector_t::floor)!=anchor->GetPlaneTexZ(sector_t::floor) || + sub->render_sector->GetFloorLight() != anchor->GetFloorLight()) + { + return false; + } + } + if (!seg->linedef || (seg->frontsector==seg->backsector && sub->render_sector!=backsub->render_sector)) + lowersegs.Push(seg); + } + } + return true; +} + +//========================================================================== +// +// Finds a subsector whose plane can be used for rendering +// +//========================================================================== + +bool FDrawInfo::CheckAnchorCeiling(subsector_t * sub) +{ + // This subsector has a one sided wall and can be used. + if (sub->hacked==3) return true; + if (sub->flags & SSECF_DEGENERATE) return false; + + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (!seg->PartnerSeg) return true; + + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // Find a linedef with a different visplane on the other side. + if (!(backsub->flags & SSECF_DEGENERATE) && seg->linedef && + (sub->render_sector != backsub->render_sector && sub->sector != backsub->sector)) + { + // I'm ignoring slopes, scaling and rotation here. The likelihood of ZDoom maps + // using such crap hacks is simply too small + if (sub->render_sector->GetTexture(sector_t::ceiling)==backsub->render_sector->GetTexture(sector_t::ceiling) && + sub->render_sector->GetPlaneTexZ(sector_t::ceiling)==backsub->render_sector->GetPlaneTexZ(sector_t::ceiling) && + sub->render_sector->GetCeilingLight() == backsub->render_sector->GetCeilingLight()) + { + continue; + } + // This means we found an adjoining subsector that clearly would go into another + // visplane. That means that this subsector can be used as an anchor. + return true; + } + } + return false; +} + +//========================================================================== +// +// Collect connected subsectors that have to be rendered with the same plane +// +//========================================================================== + +bool FDrawInfo::CollectSubsectorsCeiling(subsector_t * sub, sector_t * anchor) +{ + // mark it checked + sub->validcount=validcount; + + + // We must collect any subsector that either is connected to this one with a miniseg + // or has the same visplane. + // We must not collect any subsector that has the anchor's visplane! + if (!(sub->flags & SSECF_DEGENERATE)) + { + // Is not being rendererd so don't bother. + if (!(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return true; + + if (sub->render_sector->GetTexture(sector_t::ceiling)!=anchor->GetTexture(sector_t::ceiling) || + sub->render_sector->GetPlaneTexZ(sector_t::ceiling)!=anchor->GetPlaneTexZ(sector_t::ceiling) || + sub->render_sector->GetCeilingLight() != anchor->GetCeilingLight()) + { + HandledSubsectors.Push (sub); + } + } + + // We can assume that all segs in this subsector are connected to a subsector that has + // to be checked as well + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (seg->PartnerSeg) + { + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // could be an anchor itself. + if (!CheckAnchorCeiling (backsub)) // must not be an anchor itself! + { + if (backsub->validcount!=validcount) + { + if (!CollectSubsectorsCeiling (backsub, anchor)) return false; + } + } + else if (sub->render_sector == backsub->render_sector) + { + // Any anchor not within the original anchor's visplane terminates the processing. + if (sub->render_sector->GetTexture(sector_t::ceiling)!=anchor->GetTexture(sector_t::ceiling) || + sub->render_sector->GetPlaneTexZ(sector_t::ceiling)!=anchor->GetPlaneTexZ(sector_t::ceiling) || + sub->render_sector->GetCeilingLight() != anchor->GetCeilingLight()) + { + return false; + } + } + } + } + return true; +} + +//========================================================================== +// +// Process the subsectors that have been marked as hacked +// +//========================================================================== + +void FDrawInfo::HandleHackedSubsectors() +{ + lowershcount=uppershcount=0; + totalssms.Reset(); + totalssms.Clock(); + + viewsubsector = R_PointInSubsector(viewx, viewy); + + // Each subsector may only be processed once in this loop! + validcount++; + for(unsigned int i=0;ivalidcount!=validcount && CheckAnchorFloor(sub)) + { + // Now collect everything that is connected with this subsector. + HandledSubsectors.Clear(); + inview=false; + lowersegs.Clear(); + if (CollectSubsectorsFloor(sub, sub->render_sector)) + { + for(unsigned int j=0;jsub = HandledSubsectors[j]; + AddOtherFloorPlane(sub->render_sector->sectornum, node); + } + if (inview) for(unsigned int j=0;jProcessLowerMiniseg (seg, seg->Subsector->render_sector, seg->PartnerSeg->Subsector->render_sector); + } + lowershcount+=HandledSubsectors.Size(); + } + } + } + + // Each subsector may only be processed once in this loop! + validcount++; + for(unsigned int i=0;ivalidcount!=validcount && CheckAnchorCeiling(sub)) + { + // Now collect everything that is connected with this subsector. + HandledSubsectors.Clear(); + if (CollectSubsectorsCeiling(sub, sub->render_sector)) + { + for(unsigned int j=0;jsub = HandledSubsectors[j]; + AddOtherCeilingPlane(sub->render_sector->sectornum, node); + } + uppershcount+=HandledSubsectors.Size(); + } + } + } + + + SubsectorHacks.Clear(); + totalssms.Unclock(); +} + +ADD_STAT(sectorhacks) +{ + FString out; + out.Format("sectorhacks = %.3f ms, %d upper, %d lower\n", totalssms.TimeMS(), uppershcount, lowershcount); + return out; +} + + +//========================================================================== +// +// This merges visplanes that lie inside a sector stack together +// to avoid rendering these unneeded flats +// +//========================================================================== + +void FDrawInfo::AddFloorStack(sector_t * sec) +{ + //@sync-hack + FloorStacks.Push(sec); +} + +void FDrawInfo::AddCeilingStack(sector_t * sec) +{ + //@sync-hack + CeilingStacks.Push(sec); +} + +//========================================================================== +// +// +// +//========================================================================== + +void FDrawInfo::CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor) +{ + sector_t fake; + + // mark it checked + sub->validcount=validcount; + + // Has a sector stack or skybox itself! + if (sub->render_sector->portals[sector_t::ceiling] != NULL) return; + + // Don't bother processing unrendered subsectors + if (sub->numlines>2 && !(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return; + + // Must be the exact same visplane + sector_t * me = gl_FakeFlat(sub->render_sector, &fake, false); + if (me->GetTexture(sector_t::ceiling) != anchor->GetTexture(sector_t::ceiling) || + me->ceilingplane != anchor->ceilingplane || + me->GetCeilingLight() != anchor->GetCeilingLight() || + me->ColorMap != anchor->ColorMap || + me->GetXOffset(sector_t::ceiling) != anchor->GetXOffset(sector_t::ceiling) || + me->GetYOffset(sector_t::ceiling) != anchor->GetYOffset(sector_t::ceiling) || + me->GetXScale(sector_t::ceiling) != anchor->GetXScale(sector_t::ceiling) || + me->GetYScale(sector_t::ceiling) != anchor->GetYScale(sector_t::ceiling) || + me->GetAngle(sector_t::ceiling) != anchor->GetAngle(sector_t::ceiling)) + { + // different visplane so it can't belong to this stack + return; + } + + HandledSubsectors.Push (sub); + + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (seg->PartnerSeg) + { + subsector_t * backsub = seg->PartnerSeg->Subsector; + + if (backsub->validcount!=validcount) CollectSectorStacksCeiling (backsub, anchor); + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FDrawInfo::CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor) +{ + sector_t fake; + // mark it checked + sub->validcount=validcount; + + // Has a sector stack or skybox itself! + if (sub->render_sector->portals[sector_t::floor] != NULL) return; + + // Don't bother processing unrendered subsectors + if (sub->numlines>2 && !(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return; + + // Must be the exact same visplane + sector_t * me = gl_FakeFlat(sub->render_sector, &fake, false); + if (me->GetTexture(sector_t::floor) != anchor->GetTexture(sector_t::floor) || + me->floorplane != anchor->floorplane || + me->GetFloorLight() != anchor->GetFloorLight() || + me->ColorMap != anchor->ColorMap || + me->GetXOffset(sector_t::floor) != anchor->GetXOffset(sector_t::floor) || + me->GetYOffset(sector_t::floor) != anchor->GetYOffset(sector_t::floor) || + me->GetXScale(sector_t::floor) != anchor->GetXScale(sector_t::floor) || + me->GetYScale(sector_t::floor) != anchor->GetYScale(sector_t::floor) || + me->GetAngle(sector_t::floor) != anchor->GetAngle(sector_t::floor)) + { + // different visplane so it can't belong to this stack + return; + } + + HandledSubsectors.Push (sub); + + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (seg->PartnerSeg) + { + subsector_t * backsub = seg->PartnerSeg->Subsector; + + if (backsub->validcount!=validcount) CollectSectorStacksFloor (backsub, anchor); + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FDrawInfo::ProcessSectorStacks() +{ + unsigned int i; + sector_t fake; + + validcount++; + for (i=0;iportals[sector_t::ceiling]; + if (portal != NULL) for(int k=0;ksubsectorcount;k++) + { + subsector_t * sub = sec->subsectors[k]; + if (ss_renderflags[sub-subsectors] & SSRF_PROCESSED) + { + HandledSubsectors.Clear(); + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (seg->PartnerSeg) + { + subsector_t * backsub = seg->PartnerSeg->Subsector; + + if (backsub->validcount!=validcount) CollectSectorStacksCeiling (backsub, sec); + } + } + for(unsigned int j=0;jportalcoverage[sector_t::ceiling].subsectors == NULL) + { + gl_BuildPortalCoverage(&sub->portalcoverage[sector_t::ceiling], sub, portal); + } + + portal->GetGLPortal()->AddSubsector(sub); + + if (sec->GetAlpha(sector_t::ceiling) != 0 && sec->GetTexture(sector_t::ceiling) != skyflatnum) + { + gl_subsectorrendernode * node = SSR_List.GetNew(); + node->sub = sub; + AddOtherCeilingPlane(sec->sectornum, node); + } + } + } + } + } + + validcount++; + for (i=0;iportals[sector_t::floor]; + if (portal != NULL) for(int k=0;ksubsectorcount;k++) + { + subsector_t * sub = sec->subsectors[k]; + if (ss_renderflags[sub-subsectors] & SSRF_PROCESSED) + { + HandledSubsectors.Clear(); + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (seg->PartnerSeg) + { + subsector_t * backsub = seg->PartnerSeg->Subsector; + + if (backsub->validcount!=validcount) CollectSectorStacksFloor (backsub, sec); + } + } + + for(unsigned int j=0;jportalcoverage[sector_t::floor].subsectors == NULL) + { + gl_BuildPortalCoverage(&sub->portalcoverage[sector_t::floor], sub, portal); + } + + GLSectorStackPortal *glportal = portal->GetGLPortal(); + glportal->AddSubsector(sub); + + if (sec->GetAlpha(sector_t::floor) != 0 && sec->GetTexture(sector_t::floor) != skyflatnum) + { + gl_subsectorrendernode * node = SSR_List.GetNew(); + node->sub = sub; + AddOtherFloorPlane(sec->sectornum, node); + } + } + } + } + } + + FloorStacks.Clear(); + CeilingStacks.Clear(); +} + diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp new file mode 100644 index 000000000..99660267c --- /dev/null +++ b/src/gl/scene/gl_scene.cpp @@ -0,0 +1,1270 @@ +/* +** gl_scene.cpp +** manages the rendering of the player's view +** +**--------------------------------------------------------------------------- +** Copyright 2004-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "gi.h" +#include "m_png.h" +#include "m_random.h" +#include "st_stuff.h" +#include "dobject.h" +#include "doomstat.h" +#include "g_level.h" +#include "r_data/r_interpolate.h" +#include "r_utility.h" +#include "d_player.h" +#include "p_effect.h" +#include "sbar.h" +#include "po_man.h" +#include "r_utility.h" +#include "a_hexenglobal.h" +#include "p_local.h" +#include "gl/gl_functions.h" + +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/dynlights/gl_lightbuffer.h" +#include "gl/models/gl_models.h" +#include "gl/scene/gl_clipper.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_convert.h" +#include "gl/utility/gl_templates.h" + +//========================================================================== +// +// CVARs +// +//========================================================================== +CVAR(Bool, gl_texture, true, 0) +CVAR(Bool, gl_no_skyclear, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Float, gl_mask_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Float, gl_mask_sprite_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Bool, gl_forcemultipass, false, 0) + +EXTERN_CVAR (Int, screenblocks) +EXTERN_CVAR (Bool, cl_capfps) +EXTERN_CVAR (Bool, r_deathcamera) + + +extern int viewpitch; + +DWORD gl_fixedcolormap; +area_t in_area; +TArray currentmapsection; + +void gl_ParseDefs(); + +//----------------------------------------------------------------------------- +// +// R_FrustumAngle +// +//----------------------------------------------------------------------------- +angle_t FGLRenderer::FrustumAngle() +{ + float tilt= fabs(mAngles.Pitch); + + // If the pitch is larger than this you can look all around at a FOV of 90° + if (tilt>46.0f) return 0xffffffff; + + // ok, this is a gross hack that barely works... + // but at least it doesn't overestimate too much... + double floatangle=2.0+(45.0+((tilt/1.9)))*mCurrentFoV*48.0/BaseRatioSizes[WidescreenRatio][3]/90.0; + angle_t a1 = FLOAT_TO_ANGLE(floatangle); + if (a1>=ANGLE_180) return 0xffffffff; + return a1; +} + +//----------------------------------------------------------------------------- +// +// Sets the area the camera is in +// +//----------------------------------------------------------------------------- +void FGLRenderer::SetViewArea() +{ + // The render_sector is better suited to represent the current position in GL + viewsector = R_PointInSubsector(viewx, viewy)->render_sector; + + // keep the view within the render sector's floor and ceiling + fixed_t theZ = viewsector->ceilingplane.ZatPoint (viewx, viewy) - 4*FRACUNIT; + if (viewz > theZ) + { + viewz = theZ; + } + + theZ = viewsector->floorplane.ZatPoint (viewx, viewy) + 4*FRACUNIT; + if (viewz < theZ) + { + viewz = theZ; + } + + // Get the heightsec state from the render sector, not the current one! + if (viewsector->heightsec && !(viewsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) + { + in_area = viewz<=viewsector->heightsec->floorplane.ZatPoint(viewx,viewy) ? area_below : + (viewz>viewsector->heightsec->ceilingplane.ZatPoint(viewx,viewy) && + !(viewsector->heightsec->MoreFlags&SECF_FAKEFLOORONLY)) ? area_above:area_normal; + } + else + { + in_area=area_default; // depends on exposed lower sectors + } +} + +//----------------------------------------------------------------------------- +// +// resets the 3D viewport +// +//----------------------------------------------------------------------------- + +void FGLRenderer::ResetViewport() +{ + int trueheight = static_cast(screen)->GetTrueHeight(); // ugh... + gl.Viewport(0, (trueheight-screen->GetHeight())/2, screen->GetWidth(), screen->GetHeight()); +} + +//----------------------------------------------------------------------------- +// +// sets 3D viewport and initial state +// +//----------------------------------------------------------------------------- + +void FGLRenderer::SetViewport(GL_IRECT *bounds) +{ + if (!bounds) + { + int height, width; + + // Special handling so the view with a visible status bar displays properly + + if (screenblocks >= 10) + { + height = SCREENHEIGHT; + width = SCREENWIDTH; + } + else + { + height = (screenblocks*SCREENHEIGHT/10) & ~7; + width = (screenblocks*SCREENWIDTH/10); + } + + int trueheight = static_cast(screen)->GetTrueHeight(); // ugh... + int bars = (trueheight-screen->GetHeight())/2; + + int vw = viewwidth; + int vh = viewheight; + gl.Viewport(viewwindowx, trueheight-bars-(height+viewwindowy-((height-vh)/2)), vw, height); + gl.Scissor(viewwindowx, trueheight-bars-(vh+viewwindowy), vw, vh); + } + else + { + gl.Viewport(bounds->left, bounds->top, bounds->width, bounds->height); + gl.Scissor(bounds->left, bounds->top, bounds->width, bounds->height); + } + gl.Enable(GL_SCISSOR_TEST); + + #ifdef _DEBUG + gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + #else + gl.Clear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + #endif + + gl.Enable(GL_MULTISAMPLE); + gl.Enable(GL_DEPTH_TEST); + gl.Enable(GL_STENCIL_TEST); + gl.StencilFunc(GL_ALWAYS,0,~0); // default stencil + gl.StencilOp(GL_KEEP,GL_KEEP,GL_REPLACE); +} + +//----------------------------------------------------------------------------- +// +// Setup the camera position +// +//----------------------------------------------------------------------------- + +void FGLRenderer::SetCameraPos(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle) +{ + float fviewangle=(float)(viewangle>>ANGLETOFINESHIFT)*360.0f/FINEANGLES; + + mAngles.Yaw = 270.0f-fviewangle; + mViewVector = FVector2(cos(DEG2RAD(fviewangle)), sin(DEG2RAD(fviewangle))); + mCameraPos = FVector3(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); + + R_SetViewAngle(); +} + + +//----------------------------------------------------------------------------- +// +// SetProjection +// sets projection matrix +// +//----------------------------------------------------------------------------- + +void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) +{ + gl.MatrixMode(GL_PROJECTION); + gl.LoadIdentity(); + + float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovratio)); + gluPerspective(fovy, ratio, 5.f, 65536.f); + gl_RenderState.Set2DMode(false); +} + +//----------------------------------------------------------------------------- +// +// Setup the modelview matrix +// +//----------------------------------------------------------------------------- + +void FGLRenderer::SetViewMatrix(bool mirror, bool planemirror) +{ + if (gl.shadermodel >= 4) + { + gl.ActiveTexture(GL_TEXTURE7); + gl.MatrixMode(GL_TEXTURE); + gl.LoadIdentity(); + } + gl.ActiveTexture(GL_TEXTURE0); + gl.MatrixMode(GL_TEXTURE); + gl.LoadIdentity(); + + gl.MatrixMode(GL_MODELVIEW); + gl.LoadIdentity(); + + float mult = mirror? -1:1; + float planemult = planemirror? -1:1; + + gl.Rotatef(GLRenderer->mAngles.Roll, 0.0f, 0.0f, 1.0f); + gl.Rotatef(GLRenderer->mAngles.Pitch, 1.0f, 0.0f, 0.0f); + gl.Rotatef(GLRenderer->mAngles.Yaw, 0.0f, mult, 0.0f); + gl.Translatef( GLRenderer->mCameraPos.X * mult, -GLRenderer->mCameraPos.Z*planemult, -GLRenderer->mCameraPos.Y); + gl.Scalef(-mult, planemult, 1); +} + + +//----------------------------------------------------------------------------- +// +// SetupView +// Setup the view rotation matrix for the given viewpoint +// +//----------------------------------------------------------------------------- +void FGLRenderer::SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror) +{ + SetCameraPos(viewx, viewy, viewz, viewangle); + SetViewMatrix(mirror, planemirror); +} + +//----------------------------------------------------------------------------- +// +// CreateScene +// +// creates the draw lists for the current scene +// +//----------------------------------------------------------------------------- + +void FGLRenderer::CreateScene() +{ + // reset the portal manager + GLPortal::StartFrame(); + PO_LinkToSubsectors(); + + ProcessAll.Clock(); + + // clip the scene and fill the drawlists + for(unsigned i=0;iglportal = NULL; + gl_spriteindex=0; + Bsp.Clock(); + gl_RenderBSPNode (nodes + numnodes - 1); + Bsp.Unclock(); + + // And now the crappy hacks that have to be done to avoid rendering anomalies: + + gl_drawinfo->HandleMissingTextures(); // Missing upper/lower textures + gl_drawinfo->HandleHackedSubsectors(); // open sector hacks for deep water + gl_drawinfo->ProcessSectorStacks(); // merge visplanes of sector stacks + + GLRenderer->mVBO->UnmapVBO (); + ProcessAll.Unclock(); + +} + +//----------------------------------------------------------------------------- +// +// RenderScene +// +// Draws the current draw lists for the non GLSL renderer +// +//----------------------------------------------------------------------------- + +void FGLRenderer::RenderScene(int recursion) +{ + RenderAll.Clock(); + + gl.DepthMask(true); + if (!gl_no_skyclear) GLPortal::RenderFirstSkyPortal(recursion); + + gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); + + gl_RenderState.EnableFog(true); + gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); + + // First draw all single-pass stuff + + // Part 1: solid geometry. This is set up so that there are no transparent parts + gl.DepthFunc(GL_LESS); + + + gl_RenderState.EnableAlphaTest(false); + + gl.Disable(GL_POLYGON_OFFSET_FILL); // just in case + + int pass; + + if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && gl_dynlight_shader) + { + pass = GLPASS_ALL; + } + else if (gl_texture) + { + pass = GLPASS_PLAIN; + } + else + { + pass = GLPASS_BASE; + } + + gl_RenderState.EnableTexture(gl_texture); + gl_RenderState.EnableBrightmap(gl_fixedcolormap == CM_DEFAULT); + gl_drawinfo->drawlists[GLDL_PLAIN].Sort(); + gl_drawinfo->drawlists[GLDL_PLAIN].Draw(pass); + gl_RenderState.EnableBrightmap(false); + gl_drawinfo->drawlists[GLDL_FOG].Sort(); + gl_drawinfo->drawlists[GLDL_FOG].Draw(pass); + gl_drawinfo->drawlists[GLDL_LIGHTFOG].Sort(); + gl_drawinfo->drawlists[GLDL_LIGHTFOG].Draw(pass); + + + gl_RenderState.EnableAlphaTest(true); + + // Part 2: masked geometry. This is set up so that only pixels with alpha>0.5 will show + if (!gl_texture) + { + gl_RenderState.EnableTexture(true); + gl_RenderState.SetTextureMode(TM_MASK); + } + if (pass == GLPASS_BASE) pass = GLPASS_BASE_MASKED; + gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_threshold); + gl_RenderState.EnableBrightmap(true); + gl_drawinfo->drawlists[GLDL_MASKED].Sort(); + gl_drawinfo->drawlists[GLDL_MASKED].Draw(pass); + gl_RenderState.EnableBrightmap(false); + gl_drawinfo->drawlists[GLDL_FOGMASKED].Sort(); + gl_drawinfo->drawlists[GLDL_FOGMASKED].Draw(pass); + gl_drawinfo->drawlists[GLDL_LIGHTFOGMASKED].Sort(); + gl_drawinfo->drawlists[GLDL_LIGHTFOGMASKED].Draw(pass); + + // And now the multipass stuff + if (!gl_dynlight_shader && gl_lights) + { + // First pass: empty background with sector light only + + // Part 1: solid geometry. This is set up so that there are no transparent parts + + // remove any remaining texture bindings and shaders whick may get in the way. + gl_RenderState.EnableTexture(false); + gl_RenderState.EnableBrightmap(false); + gl_RenderState.Apply(); + gl_drawinfo->drawlists[GLDL_LIGHT].Draw(GLPASS_BASE); + gl_RenderState.EnableTexture(true); + + // Part 2: masked geometry. This is set up so that only pixels with alpha>0.5 will show + // This creates a blank surface that only fills the nontransparent parts of the texture + gl_RenderState.SetTextureMode(TM_MASK); + gl_RenderState.EnableBrightmap(true); + gl_drawinfo->drawlists[GLDL_LIGHTBRIGHT].Draw(GLPASS_BASE_MASKED); + gl_drawinfo->drawlists[GLDL_LIGHTMASKED].Draw(GLPASS_BASE_MASKED); + gl_RenderState.EnableBrightmap(false); + gl_RenderState.SetTextureMode(TM_MODULATE); + + + // second pass: draw lights (on fogged surfaces they are added to the textures!) + gl.DepthMask(false); + if (mLightCount && !gl_fixedcolormap) + { + if (gl_SetupLightTexture()) + { + gl_RenderState.BlendFunc(GL_ONE, GL_ONE); + gl.DepthFunc(GL_EQUAL); + if (glset.lightmode == 8) gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0f); // Korshun. + for(int i=GLDL_FIRSTLIGHT; i<=GLDL_LASTLIGHT; i++) + { + gl_drawinfo->drawlists[i].Draw(GLPASS_LIGHT); + } + gl_RenderState.BlendEquation(GL_FUNC_ADD); + } + else gl_lights=false; + } + + // third pass: modulated texture + gl.Color3f(1.0f, 1.0f, 1.0f); + gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); + gl_RenderState.EnableFog(false); + gl.DepthFunc(GL_LEQUAL); + if (gl_texture) + { + gl_RenderState.EnableAlphaTest(false); + gl_drawinfo->drawlists[GLDL_LIGHT].Sort(); + gl_drawinfo->drawlists[GLDL_LIGHT].Draw(GLPASS_TEXTURE); + gl_RenderState.EnableAlphaTest(true); + gl_drawinfo->drawlists[GLDL_LIGHTBRIGHT].Sort(); + gl_drawinfo->drawlists[GLDL_LIGHTBRIGHT].Draw(GLPASS_TEXTURE); + gl_drawinfo->drawlists[GLDL_LIGHTMASKED].Sort(); + gl_drawinfo->drawlists[GLDL_LIGHTMASKED].Draw(GLPASS_TEXTURE); + } + + // fourth pass: additive lights + gl_RenderState.EnableFog(true); + if (gl_lights && mLightCount && !gl_fixedcolormap) + { + gl_RenderState.BlendFunc(GL_ONE, GL_ONE); + gl.DepthFunc(GL_EQUAL); + if (gl_SetupLightTexture()) + { + for(int i=0; idrawlists[i].Draw(GLPASS_LIGHT_ADDITIVE); + } + gl_RenderState.BlendEquation(GL_FUNC_ADD); + } + else gl_lights=false; + } + } + + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // Draw decals (not a real pass) + gl.DepthFunc(GL_LEQUAL); + gl.Enable(GL_POLYGON_OFFSET_FILL); + gl.PolygonOffset(-1.0f, -128.0f); + gl.DepthMask(false); + + for(int i=0; idrawlists[i].Draw(GLPASS_DECALS); + } + + gl_RenderState.SetTextureMode(TM_MODULATE); + + gl.DepthMask(true); + + + // Push bleeding floor/ceiling textures back a little in the z-buffer + // so they don't interfere with overlapping mid textures. + gl.PolygonOffset(1.0f, 128.0f); + + // flood all the gaps with the back sector's flat texture + // This will always be drawn like GLDL_PLAIN or GLDL_FOG, depending on the fog settings + + if (!(gl.flags&RFL_NOSTENCIL)) // needs a stencil to work! + { + gl.DepthMask(false); // don't write to Z-buffer! + gl_RenderState.EnableFog(true); + gl_RenderState.EnableAlphaTest(false); + gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); + gl_drawinfo->DrawUnhandledMissingTextures(); + gl_RenderState.EnableAlphaTest(true); + } + gl.DepthMask(true); + + gl.PolygonOffset(0.0f, 0.0f); + gl.Disable(GL_POLYGON_OFFSET_FILL); + + RenderAll.Unclock(); +} + +//----------------------------------------------------------------------------- +// +// RenderTranslucent +// +// Draws the current draw lists for the non GLSL renderer +// +//----------------------------------------------------------------------------- + +void FGLRenderer::RenderTranslucent() +{ + RenderAll.Clock(); + + gl.DepthMask(false); + gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); + + // final pass: translucent stuff + gl_RenderState.EnableAlphaTest(true); + gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_sprite_threshold); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + gl_RenderState.EnableBrightmap(true); + gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(GLPASS_TRANSLUCENT); + gl_drawinfo->drawlists[GLDL_TRANSLUCENT].DrawSorted(); + gl_RenderState.EnableBrightmap(false); + + gl.DepthMask(true); + + gl_RenderState.AlphaFunc(GL_GEQUAL,0.5f); + RenderAll.Unclock(); +} + + +//----------------------------------------------------------------------------- +// +// gl_drawscene - this function renders the scene from the current +// viewpoint, including mirrors and skyboxes and other portals +// It is assumed that the GLPortal::EndFrame returns with the +// stencil, z-buffer and the projection matrix intact! +// +//----------------------------------------------------------------------------- +EXTERN_CVAR(Bool, gl_draw_sync) + +void FGLRenderer::DrawScene(bool toscreen) +{ + static int recursion=0; + + CreateScene(); + GLRenderer->mCurrentPortal = NULL; // this must be reset before any portal recursion takes place. + + // Up to this point in the main draw call no rendering is performed so we can wait + // with swapping the render buffer until now. + if (!gl_draw_sync && toscreen) + { + All.Unclock(); + static_cast(screen)->Swap(); + All.Clock(); + } + RenderScene(recursion); + + // Handle all portals after rendering the opaque objects but before + // doing all translucent stuff + recursion++; + GLPortal::EndFrame(); + recursion--; + RenderTranslucent(); +} + + +//========================================================================== +// +// Draws a blend over the entire view +// +//========================================================================== +void FGLRenderer::DrawBlend(sector_t * viewsector) +{ + float blend[4]={0,0,0,0}; + PalEntry blendv=0; + float extra_red; + float extra_green; + float extra_blue; + player_t *player = NULL; + + if (players[consoleplayer].camera != NULL) + { + player=players[consoleplayer].camera->player; + } + + // don't draw sector based blends when an invulnerability colormap is active + if (!gl_fixedcolormap) + { + if (!viewsector->e->XFloor.ffloors.Size()) + { + if (viewsector->heightsec && !(viewsector->MoreFlags&SECF_IGNOREHEIGHTSEC)) + { + switch(in_area) + { + default: + case area_normal: blendv=viewsector->heightsec->midmap; break; + case area_above: blendv=viewsector->heightsec->topmap; break; + case area_below: blendv=viewsector->heightsec->bottommap; break; + } + } + } + else + { + TArray & lightlist = viewsector->e->XFloor.lightlist; + + for(unsigned int i=0;ifloorplane.ZatPoint(viewx,viewy); + + if (lightbottomflags&FF_FADEWALLS))) + { + // 3d floor 'fog' is rendered as a blending value + blendv=lightlist[i].blend; + // If this is the same as the sector's it doesn't apply! + if (blendv == viewsector->ColorMap->Fade) blendv=0; + // a little hack to make this work for Legacy maps. + if (blendv.a==0 && blendv!=0) blendv.a=128; + break; + } + } + } + } + + if (blendv.a==0) + { + blendv = R_BlendForColormap(blendv); + if (blendv.a==255) + { + // The calculated average is too dark so brighten it according to the palettes's overall brightness + int maxcol = MAX(MAX(framebuffer->palette_brightness, blendv.r), MAX(blendv.g, blendv.b)); + blendv.r = blendv.r * 255 / maxcol; + blendv.g = blendv.g * 255 / maxcol; + blendv.b = blendv.b * 255 / maxcol; + } + } + + if (blendv.a==255) + { + + extra_red = blendv.r / 255.0f; + extra_green = blendv.g / 255.0f; + extra_blue = blendv.b / 255.0f; + + // If this is a multiplicative blend do it separately and add the additive ones on top of it! + blendv=0; + + // black multiplicative blends are ignored + if (extra_red || extra_green || extra_blue) + { + gl_RenderState.EnableAlphaTest(false); + gl_RenderState.EnableTexture(false); + gl_RenderState.BlendFunc(GL_DST_COLOR,GL_ZERO); + gl.Color4f(extra_red, extra_green, extra_blue, 1.0f); + gl_RenderState.Apply(true); + gl.Begin(GL_TRIANGLE_STRIP); + gl.Vertex2f( 0.0f, 0.0f); + gl.Vertex2f( 0.0f, (float)SCREENHEIGHT); + gl.Vertex2f( (float)SCREENWIDTH, 0.0f); + gl.Vertex2f( (float)SCREENWIDTH, (float)SCREENHEIGHT); + gl.End(); + } + } + else if (blendv.a) + { + V_AddBlend (blendv.r / 255.f, blendv.g / 255.f, blendv.b / 255.f, blendv.a/255.0f,blend); + } + + // This mostly duplicates the code in shared_sbar.cpp + // When I was writing this the original was called too late so that I + // couldn't get the blend in time. However, since then I made some changes + // here that would get lost if I switched back so I won't do it. + + if (player) + { + V_AddPlayerBlend(player, blend, 0.5, 175); + } + + if (players[consoleplayer].camera != NULL) + { + // except for fadeto effects + player_t *player = (players[consoleplayer].camera->player != NULL) ? players[consoleplayer].camera->player : &players[consoleplayer]; + V_AddBlend (player->BlendR, player->BlendG, player->BlendB, player->BlendA, blend); + } + + if (blend[3]>0.0f) + { + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.EnableAlphaTest(false); + gl_RenderState.EnableTexture(false); + gl.Color4fv(blend); + gl_RenderState.Apply(true); + gl.Begin(GL_TRIANGLE_STRIP); + gl.Vertex2f( 0.0f, 0.0f); + gl.Vertex2f( 0.0f, (float)SCREENHEIGHT); + gl.Vertex2f( (float)SCREENWIDTH, 0.0f); + gl.Vertex2f( (float)SCREENWIDTH, (float)SCREENHEIGHT); + gl.End(); + } +} + + +//----------------------------------------------------------------------------- +// +// Draws player sprites and color blend +// +//----------------------------------------------------------------------------- + + +void FGLRenderer::EndDrawScene(sector_t * viewsector) +{ + // [BB] HUD models need to be rendered here. Make sure that + // DrawPlayerSprites is only called once. Either to draw + // HUD models or to draw the weapon sprites. + const bool renderHUDModel = gl_IsHUDModelForPlayerAvailable( players[consoleplayer].camera->player ); + if ( renderHUDModel ) + { + // [BB] The HUD model should be drawn over everything else already drawn. + gl.Clear(GL_DEPTH_BUFFER_BIT); + DrawPlayerSprites (viewsector, true); + } + + gl.Disable(GL_STENCIL_TEST); + gl.Disable(GL_POLYGON_SMOOTH); + + gl_RenderState.EnableFog(false); + framebuffer->Begin2D(false); + + ResetViewport(); + // [BB] Only draw the sprites if we didn't render a HUD model before. + if ( renderHUDModel == false ) + { + DrawPlayerSprites (viewsector, false); + } + DrawTargeterSprites(); + DrawBlend(viewsector); + + // Restore standard rendering state + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl.Color3f(1.0f,1.0f,1.0f); + gl_RenderState.EnableTexture(true); + gl_RenderState.EnableAlphaTest(true); + gl.Disable(GL_SCISSOR_TEST); +} + + +//----------------------------------------------------------------------------- +// +// R_RenderView - renders one view - either the screen or a camera texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::ProcessScene(bool toscreen) +{ + FDrawInfo::StartDrawInfo(); + iter_dlightf = iter_dlight = draw_dlight = draw_dlightf = 0; + GLPortal::BeginScene(); + + int mapsection = R_PointInSubsector(viewx, viewy)->mapsection; + memset(¤tmapsection[0], 0, currentmapsection.Size()); + currentmapsection[mapsection>>3] |= 1 << (mapsection & 7); + DrawScene(toscreen); + FDrawInfo::EndDrawInfo(); + +} + +//----------------------------------------------------------------------------- +// +// gl_SetFixedColormap +// +//----------------------------------------------------------------------------- + +void FGLRenderer::SetFixedColormap (player_t *player) +{ + gl_fixedcolormap=CM_DEFAULT; + + // check for special colormaps + player_t * cplayer = player->camera->player; + if (cplayer) + { + if (cplayer->extralight<0) + { + gl_fixedcolormap=CM_FIRSTSPECIALCOLORMAP + INVERSECOLORMAP; + extralight=0; + } + else if (cplayer->fixedcolormap != NOFIXEDCOLORMAP) + { + gl_fixedcolormap = CM_FIRSTSPECIALCOLORMAP + cplayer->fixedcolormap; + } + else if (cplayer->fixedlightlevel != -1) + { + for(AInventory * in = cplayer->mo->Inventory; in; in = in->Inventory) + { + PalEntry color = in->GetBlend (); + + // Need special handling for light amplifiers + if (in->IsKindOf(RUNTIME_CLASS(APowerTorch))) + { + gl_fixedcolormap = cplayer->fixedlightlevel + CM_TORCH; + } + else if (in->IsKindOf(RUNTIME_CLASS(APowerLightAmp))) + { + gl_fixedcolormap = CM_LITE; + } + } + } + } +} + +//----------------------------------------------------------------------------- +// +// Renders one viewpoint in a scene +// +//----------------------------------------------------------------------------- + +sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen) +{ + sector_t * retval; + R_SetupFrame (camera); + SetViewArea(); + mAngles.Pitch = clamp((float)((double)(int)(viewpitch))/ANGLE_1, -90, 90); + + // Scroll the sky + mSky1Pos = (float)fmod(gl_frameMS * level.skyspeed1, 1024.f) * 90.f/256.f; + mSky2Pos = (float)fmod(gl_frameMS * level.skyspeed2, 1024.f) * 90.f/256.f; + + + + if (camera->player && camera->player-players==consoleplayer && + ((camera->player->cheats & CF_CHASECAM) || (r_deathcamera && camera->health <= 0)) && camera==camera->player->mo) + { + mViewActor=NULL; + } + else + { + mViewActor=camera; + } + + retval = viewsector; + + SetViewport(bounds); + mCurrentFoV = fov; + SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper + SetCameraPos(viewx, viewy, viewz, viewangle); + SetViewMatrix(false, false); + + clipper.Clear(); + angle_t a1 = FrustumAngle(); + clipper.SafeAddClipRangeRealAngles(viewangle+a1, viewangle-a1); + + ProcessScene(toscreen); + + gl_frameCount++; // This counter must be increased right before the interpolations are restored. + interpolator.RestoreInterpolations (); + return retval; +} + + +//----------------------------------------------------------------------------- +// +// renders the view +// +//----------------------------------------------------------------------------- + +void FGLRenderer::RenderView (player_t* player) +{ + OpenGLFrameBuffer* GLTarget = static_cast(screen); + AActor *&LastCamera = GLTarget->LastCamera; + + if (player->camera != LastCamera) + { + // If the camera changed don't interpolate + // Otherwise there will be some not so nice effects. + R_ResetViewInterpolation(); + LastCamera=player->camera; + } + + mVBO->BindVBO(); + + // reset statistics counters + ResetProfilingData(); + + // Get this before everything else + if (cl_capfps || r_NoInterpolate) r_TicFrac = FRACUNIT; + else r_TicFrac = I_GetTimeFrac (&r_FrameTime); + gl_frameMS = I_MSTime(); + + P_FindParticleSubsectors (); + + // prepare all camera textures that have been used in the last frame + FCanvasTextureInfo::UpdateAll(); + + + // I stopped using BaseRatioSizes here because the information there wasn't well presented. + #define RMUL (1.6f/1.333333f) + // 4:3 16:9 16:10 17:10 5:4 + static float ratios[]={RMUL*1.333333f, RMUL*1.777777f, RMUL*1.6f, RMUL*1.7f, RMUL*1.25f}; + + // now render the main view + float fovratio; + float ratio = ratios[WidescreenRatio]; + if (!(WidescreenRatio&4)) + { + fovratio = 1.6f; + } + else + { + fovratio = ratio; + } + + SetFixedColormap (player); + + // Check if there's some lights. If not some code can be skipped. + TThinkerIterator it(STAT_DLIGHT); + GLRenderer->mLightCount = ((it.Next()) != NULL); + + sector_t * viewsector = RenderViewpoint(player->camera, NULL, FieldOfView * 360.0f / FINEANGLES, ratio, fovratio, true, true); + EndDrawScene(viewsector); + + All.Unclock(); +} + +//=========================================================================== +// +// Render the view to a savegame picture +// +//=========================================================================== + +void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int height) +{ + GL_IRECT bounds; + + bounds.left=0; + bounds.top=0; + bounds.width=width; + bounds.height=height; + gl.Flush(); + SetFixedColormap(player); + + // Check if there's some lights. If not some code can be skipped. + TThinkerIterator it(STAT_DLIGHT); + GLRenderer->mLightCount = ((it.Next()) != NULL); + + sector_t *viewsector = RenderViewpoint(players[consoleplayer].camera, &bounds, + FieldOfView * 360.0f / FINEANGLES, 1.6f, 1.6f, true, false); + gl.Disable(GL_STENCIL_TEST); + screen->Begin2D(false); + DrawBlend(viewsector); + gl.Flush(); + + byte * scr = (byte *)M_Malloc(width * height * 3); + gl.ReadPixels(0,0,width, height,GL_RGB,GL_UNSIGNED_BYTE,scr); + M_CreatePNG (file, scr + ((height-1) * width * 3), NULL, SS_RGB, width, height, -width*3); + M_Free(scr); +} + + +//=========================================================================== +// +// +// +//=========================================================================== + +struct FGLInterface : public FRenderer +{ + bool UsesColormap() const; + void PrecacheTexture(FTexture *tex, int cache); + void RenderView(player_t *player); + void WriteSavePic (player_t *player, FILE *file, int width, int height); + void StateChanged(AActor *actor); + void StartSerialize(FArchive &arc); + void EndSerialize(FArchive &arc); + void RenderTextureView (FCanvasTexture *self, AActor *viewpoint, int fov); + sector_t *FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel, bool back); + void SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog); + void PreprocessLevel(); + void CleanLevelData(); + bool RequireGLNodes(); + + int GetMaxViewPitch(bool down); + void ClearBuffer(int color); + void Init(); +}; + +//=========================================================================== +// +// The GL renderer has no use for colormaps so let's +// not create them and save us some time. +// +//=========================================================================== + +bool FGLInterface::UsesColormap() const +{ + return false; +} + +//========================================================================== +// +// DFrameBuffer :: PrecacheTexture +// +//========================================================================== + +void FGLInterface::PrecacheTexture(FTexture *tex, int cache) +{ + if (tex != NULL) + { + if (cache) + { + tex->PrecacheGL(); + } + else + { + tex->UncacheGL(); + } + } +} + +//========================================================================== +// +// DFrameBuffer :: StateChanged +// +//========================================================================== + +void FGLInterface::StateChanged(AActor *actor) +{ + gl_SetActorLights(actor); +} + +//=========================================================================== +// +// notify the renderer that serialization of the curent level is about to start/end +// +//=========================================================================== + +void FGLInterface::StartSerialize(FArchive &arc) +{ + gl_DeleteAllAttachedLights(); + arc << fogdensity << outsidefogdensity << skyfog; +} + +void FGLInterface::EndSerialize(FArchive &arc) +{ + gl_RecreateAllAttachedLights(); + if (arc.IsLoading()) gl_InitPortals(); +} + +//=========================================================================== +// +// Get max. view angle (renderer specific information so it goes here now) +// +//=========================================================================== + +EXTERN_CVAR(Float, maxviewpitch) + +int FGLInterface::GetMaxViewPitch(bool down) +{ + return int(maxviewpitch); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLInterface::ClearBuffer(int color) +{ + PalEntry pe = GPalette.BaseColors[color]; + gl.ClearColor(pe.r/255.f, pe.g/255.f, pe.b/255.f, 1.f); + gl.Clear(GL_COLOR_BUFFER_BIT); +} + +//=========================================================================== +// +// Render the view to a savegame picture +// +//=========================================================================== + +void FGLInterface::WriteSavePic (player_t *player, FILE *file, int width, int height) +{ + GLRenderer->WriteSavePic(player, file, width, height); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLInterface::RenderView(player_t *player) +{ + GLRenderer->RenderView(player); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLInterface::Init() +{ + gl_ParseDefs(); +} + +//=========================================================================== +// +// Camera texture rendering +// +//=========================================================================== +CVAR(Bool, gl_usefb, false , CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +extern TexFilter_s TexFilter[]; + +void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, int FOV) +{ + FMaterial * gltex = FMaterial::ValidateTexture(tex); + + int width = gltex->TextureWidth(GLUSE_TEXTURE); + int height = gltex->TextureHeight(GLUSE_TEXTURE); + + gl_fixedcolormap=CM_DEFAULT; + + bool usefb; + + if (gl.flags & RFL_FRAMEBUFFER) + { + usefb = gl_usefb || width > screen->GetWidth() || height > screen->GetHeight(); + } + else usefb = false; + + + if (!usefb) + { + gl.Flush(); + } + else + { +#if defined(_WIN32) && (defined(_MSC_VER) || defined(__INTEL_COMPILER)) + __try +#endif + { + GLRenderer->StartOffscreen(); + gltex->BindToFrameBuffer(); + } +#if defined(_WIN32) && (defined(_MSC_VER) || defined(__INTEL_COMPILER)) + __except(1) + { + usefb = false; + gl_usefb = false; + GLRenderer->EndOffscreen(); + gl.Flush(); + } +#endif + } + + GL_IRECT bounds; + bounds.left=bounds.top=0; + bounds.width=FHardwareTexture::GetTexDimension(gltex->GetWidth(GLUSE_TEXTURE)); + bounds.height=FHardwareTexture::GetTexDimension(gltex->GetHeight(GLUSE_TEXTURE)); + + GLRenderer->RenderViewpoint(Viewpoint, &bounds, FOV, (float)width/height, (float)width/height, false, false); + + if (!usefb) + { + gl.Flush(); + gltex->Bind(CM_DEFAULT, 0, 0); + gl.CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, bounds.width, bounds.height); + } + else + { + GLRenderer->EndOffscreen(); + } + + gltex->Bind(CM_DEFAULT, 0, 0); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + tex->SetUpdated(); +} + +//========================================================================== +// +// +// +//========================================================================== + +sector_t *FGLInterface::FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel, bool back) +{ + if (floorlightlevel != NULL) + { + *floorlightlevel = sec->GetFloorLight (); + } + if (ceilinglightlevel != NULL) + { + *ceilinglightlevel = sec->GetCeilingLight (); + } + return gl_FakeFlat(sec, tempsec, back); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLInterface::SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog) +{ + gl_SetFogParams(_fogdensity, _outsidefogcolor, _outsidefogdensity, _skyfog); +} + +void FGLInterface::PreprocessLevel() +{ + gl_PreprocessLevel(); +} + +void FGLInterface::CleanLevelData() +{ + gl_CleanLevelData(); +} + +bool FGLInterface::RequireGLNodes() +{ + return true; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +FRenderer *gl_CreateInterface() +{ + return new FGLInterface; +} + + diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp new file mode 100644 index 000000000..b236f45d8 --- /dev/null +++ b/src/gl/scene/gl_sky.cpp @@ -0,0 +1,353 @@ +/* +** gl_sky.cpp +** Sky preparation code. +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "a_sharedglobal.h" +#include "g_level.h" +#include "r_sky.h" +#include "r_state.h" +#include "r_utility.h" +#include "doomdata.h" +#include "gl/gl_functions.h" + +#include "gl/data/gl_data.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_convert.h" + +CVAR(Bool,gl_noskyboxes, false, 0) +extern int skyfog; + +enum +{ + NoSkyDraw = 89 +}; + + +//========================================================================== +// +// Calculate sky texture +// +//========================================================================== +void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) +{ + FPortal *portal = sector->portals[plane]; + if (portal != NULL) + { + if (GLPortal::instack[1-plane]) return; + type=RENDERWALL_SECTORSTACK; + this->portal = portal; + } + else if (sector->GetTexture(plane)==skyflatnum) + { + GLSkyInfo skyinfo; + ASkyViewpoint * skyboxx = plane == sector_t::floor? sector->FloorSkyBox : sector->CeilingSkyBox; + if (skyboxx == NULL) skyboxx = level.DefaultSkybox; + + // JUSTHIT is used as an indicator that a skybox is in use. + // This is to avoid recursion + + if (!gl_noskyboxes && skyboxx && GLRenderer->mViewActor!=skyboxx && !(skyboxx->flags&MF_JUSTHIT)) + { + type=RENDERWALL_SKYBOX; + skybox=skyboxx; + } + else + { + int sky1 = sector->sky; + memset(&skyinfo, 0, sizeof(skyinfo)); + if ((sky1 & PL_SKYFLAT) && (sky1 & (PL_SKYFLAT-1))) + { + const line_t *l = &lines[(sky1&(PL_SKYFLAT-1))-1]; + const side_t *s = l->sidedef[0]; + int pos; + + if (level.flags & LEVEL_SWAPSKIES && s->GetTexture(side_t::bottom).isValid()) + { + pos = side_t::bottom; + } + else + { + pos = side_t::top; + } + + FTextureID texno = s->GetTexture(pos); + skyinfo.texture[0] = FMaterial::ValidateTexture(texno, true); + if (!skyinfo.texture[0] || skyinfo.texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky; + skyinfo.skytexno1 = texno; + skyinfo.x_offset[0] = ANGLE_TO_FLOAT(s->GetTextureXOffset(pos)); + skyinfo.y_offset = FIXED2FLOAT(s->GetTextureYOffset(pos)); + skyinfo.mirrored = !l->args[2]; + } + else + { + normalsky: + if (level.flags&LEVEL_DOUBLESKY) + { + skyinfo.texture[1]=FMaterial::ValidateTexture(sky1texture, true); + skyinfo.x_offset[1] = GLRenderer->mSky1Pos; + skyinfo.doublesky = true; + } + + if ((level.flags&LEVEL_SWAPSKIES || (sky1==PL_SKYFLAT) || (level.flags&LEVEL_DOUBLESKY)) && + sky2texture!=sky1texture) // If both skies are equal use the scroll offset of the first! + { + skyinfo.texture[0]=FMaterial::ValidateTexture(sky2texture, true); + skyinfo.skytexno1=sky2texture; + skyinfo.sky2 = true; + skyinfo.x_offset[0] = GLRenderer->mSky2Pos; + } + else + { + skyinfo.texture[0]=FMaterial::ValidateTexture(sky1texture, true); + skyinfo.skytexno1=sky1texture; + skyinfo.x_offset[0] = GLRenderer->mSky1Pos; + } + } + if (skyfog>0) + { + skyinfo.fadecolor=Colormap.FadeColor; + skyinfo.fadecolor.a=0; + } + else skyinfo.fadecolor=0; + + type=RENDERWALL_SKY; + sky=UniqueSkies.Get(&skyinfo); + } + } + else if (allowreflect && sector->GetReflect(plane) > 0) + { + if ((plane == sector_t::ceiling && viewz > sector->ceilingplane.d) || + (plane == sector_t::floor && viewz < -sector->floorplane.d)) return; + type=RENDERWALL_PLANEMIRROR; + planemirror = plane == sector_t::ceiling? §or->ceilingplane : §or->floorplane; + } + else return; + PutWall(0); +} + + +//========================================================================== +// +// Skies on one sided walls +// +//========================================================================== + +void GLWall::SkyNormal(sector_t * fs,vertex_t * v1,vertex_t * v2) +{ + ztop[0]=ztop[1]=32768.0f; + zbottom[0]=zceil[0]; + zbottom[1]=zceil[1]; + SkyPlane(fs, sector_t::ceiling, true); + + ztop[0]=zfloor[0]; + ztop[1]=zfloor[1]; + zbottom[0]=zbottom[1]=-32768.0f; + SkyPlane(fs, sector_t::floor, true); +} + +//========================================================================== +// +// Upper Skies on two sided walls +// +//========================================================================== + +void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2) +{ + if (fs->GetTexture(sector_t::ceiling)==skyflatnum) + { + if ((bs->special&0xff) == NoSkyDraw) return; + if (bs->GetTexture(sector_t::ceiling)==skyflatnum) + { + // if the back sector is closed the sky must be drawn! + if (bs->ceilingplane.ZatPoint(v1) > bs->floorplane.ZatPoint(v1) || + bs->ceilingplane.ZatPoint(v2) > bs->floorplane.ZatPoint(v2) || bs->transdoor) + return; + + // one more check for some ugly transparent door hacks + if (bs->floorplane.a==0 && bs->floorplane.b==0 && fs->floorplane.a==0 && fs->floorplane.b==0) + { + if (bs->GetPlaneTexZ(sector_t::floor)==fs->GetPlaneTexZ(sector_t::floor)+FRACUNIT) + { + FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::bottom)); + if (!tex || tex->UseType==FTexture::TEX_Null) return; + + // very, very, very ugly special case (See Icarus MAP14) + // It is VERY important that this is only done for a floor height difference of 1 + // or it will cause glitches elsewhere. + tex = TexMan(seg->sidedef->GetTexture(side_t::mid)); + if (tex != NULL && !(seg->linedef->flags & ML_DONTPEGTOP) && + seg->sidedef->GetTextureYOffset(side_t::mid) > 0) + { + ztop[0]=ztop[1]=32768.0f; + zbottom[0]=zbottom[1]= + FIXED2FLOAT(bs->ceilingplane.ZatPoint(v2) + seg->sidedef->GetTextureYOffset(side_t::mid)); + SkyPlane(fs, sector_t::ceiling, false); + return; + } + } + } + } + + ztop[0]=ztop[1]=32768.0f; + + FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::top)); + if (bs->GetTexture(sector_t::ceiling) != skyflatnum) + + { + zbottom[0]=zceil[0]; + zbottom[1]=zceil[1]; + } + else + { + zbottom[0]=FIXED2FLOAT(bs->ceilingplane.ZatPoint(v1)); + zbottom[1]=FIXED2FLOAT(bs->ceilingplane.ZatPoint(v2)); + flags|=GLWF_SKYHACK; // mid textures on such lines need special treatment! + } + } + else + { + FPortal *pfront = fs->portals[sector_t::ceiling]; + FPortal *pback = bs->portals[sector_t::ceiling]; + float frontreflect = fs->GetReflect(sector_t::ceiling); + if (frontreflect > 0) + { + float backreflect = bs->GetReflect(sector_t::ceiling); + if (backreflect > 0 && bs->ceilingplane.d == fs->ceilingplane.d) + { + // Don't add intra-portal line to the portal. + return; + } + } + else if (pfront == NULL || pfront == pback) + { + return; + } + + // stacked sectors + fixed_t fsc1=fs->ceilingplane.ZatPoint(v1); + fixed_t fsc2=fs->ceilingplane.ZatPoint(v2); + + ztop[0]=ztop[1]=32768.0f; + zbottom[0]=FIXED2FLOAT(fsc1); + zbottom[1]=FIXED2FLOAT(fsc2); + } + + SkyPlane(fs, sector_t::ceiling, true); +} + + +//========================================================================== +// +// Lower Skies on two sided walls +// +//========================================================================== + +void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2) +{ + if (fs->GetTexture(sector_t::floor)==skyflatnum) + { + if ((bs->special&0xff) == NoSkyDraw) return; + FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::bottom)); + + // For lower skies the normal logic only applies to walls with no lower texture! + if (tex->UseType==FTexture::TEX_Null) + { + if (bs->GetTexture(sector_t::floor)==skyflatnum) + { + // if the back sector is closed the sky must be drawn! + if (bs->ceilingplane.ZatPoint(v1) > bs->floorplane.ZatPoint(v1) || + bs->ceilingplane.ZatPoint(v2) > bs->floorplane.ZatPoint(v2)) + return; + + } + else + { + // Special hack for Vrack2b + if (bs->floorplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) > FIXED2FLOAT(viewz)) return; + } + } + zbottom[0]=zbottom[1]=-32768.0f; + + if ((tex && tex->UseType!=FTexture::TEX_Null) || bs->GetTexture(sector_t::floor)!=skyflatnum) + { + ztop[0]=zfloor[0]; + ztop[1]=zfloor[1]; + } + else + { + ztop[0]=FIXED2FLOAT(bs->floorplane.ZatPoint(v1)); + ztop[1]=FIXED2FLOAT(bs->floorplane.ZatPoint(v2)); + flags|=GLWF_SKYHACK; // mid textures on such lines need special treatment! + } + } + else + { + FPortal *pfront = fs->portals[sector_t::floor]; + FPortal *pback = bs->portals[sector_t::floor]; + float frontreflect = fs->GetReflect(sector_t::floor); + if (frontreflect > 0) + { + float backreflect = bs->GetReflect(sector_t::floor); + if (backreflect > 0 && bs->floorplane.d == fs->floorplane.d) + { + // Don't add intra-portal line to the portal. + return; + } + } + else if (pfront == NULL || pfront == pback) + { + return; + } + + // stacked sectors + fixed_t fsc1=fs->floorplane.ZatPoint(v1); + fixed_t fsc2=fs->floorplane.ZatPoint(v2); + + zbottom[0]=zbottom[1]=-32768.0f; + ztop[0]=FIXED2FLOAT(fsc1); + ztop[1]=FIXED2FLOAT(fsc2); + } + + SkyPlane(fs, sector_t::floor, true); +} + diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp new file mode 100644 index 000000000..8bed575b3 --- /dev/null +++ b/src/gl/scene/gl_skydome.cpp @@ -0,0 +1,613 @@ +/* +** gl_sky.cpp +** +** Draws the sky. Loosely based on the JDoom sky and the ZDoomGL 0.66.2 sky. +** +**--------------------------------------------------------------------------- +** Copyright 2003 Tim Stump +** Copyright 2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ +#include "gl/system/gl_system.h" +#include "doomtype.h" +#include "g_level.h" +#include "sc_man.h" +#include "w_wad.h" +#include "r_state.h" +//#include "gl/gl_intern.h" + +#include "gl/data/gl_data.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_bitmap.h" +#include "gl/textures/gl_texture.h" +#include "gl/textures/gl_skyboxtexture.h" +#include "gl/textures/gl_material.h" + + +//----------------------------------------------------------------------------- +// +// Shamelessly lifted from Doomsday (written by Jaakko Keränen) +// also shamelessly lifted from ZDoomGL! ;) +// +//----------------------------------------------------------------------------- + +CVAR (Int, gl_sky_detail, 16, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +EXTERN_CVAR (Bool, r_stretchsky) + +extern int skyfog; + +// The texture offset to be applied to the texture coordinates in SkyVertex(). + +static angle_t maxSideAngle = ANGLE_180 / 3; +static int rows, columns; +static fixed_t scale = 10000 << FRACBITS; +static bool yflip; +static int texw; +static float yAdd; +static bool foglayer; +static bool secondlayer; +static float R,G,B; +static bool skymirror; + +#define SKYHEMI_UPPER 0x1 +#define SKYHEMI_LOWER 0x2 +#define SKYHEMI_JUST_CAP 0x4 // Just draw the top or bottom cap. + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +static void SkyVertex(int r, int c) +{ + angle_t topAngle= (angle_t)(c / (float)columns * ANGLE_MAX); + angle_t sideAngle = maxSideAngle * (rows - r) / rows; + fixed_t height = finesine[sideAngle>>ANGLETOFINESHIFT]; + fixed_t realRadius = FixedMul(scale, finecosine[sideAngle>>ANGLETOFINESHIFT]); + fixed_t x = FixedMul(realRadius, finecosine[topAngle>>ANGLETOFINESHIFT]); + fixed_t y = (!yflip) ? FixedMul(scale, height) : FixedMul(scale, height) * -1; + fixed_t z = FixedMul(realRadius, finesine[topAngle>>ANGLETOFINESHIFT]); + float fx, fy, fz; + float color = r * 1.f / rows; + float u, v; + float timesRepeat; + + timesRepeat = (short)(4 * (256.f / texw)); + if (timesRepeat == 0.f) timesRepeat = 1.f; + + if (!foglayer) + { + gl_SetColor(255, 0, NULL, r==0? 0.0f : 1.0f); + + // And the texture coordinates. + if(!yflip) // Flipped Y is for the lower hemisphere. + { + u = (-timesRepeat * c / (float)columns) ; + v = (r / (float)rows) + yAdd; + } + else + { + u = (-timesRepeat * c / (float)columns) ; + v = 1.0f + ((rows-r)/(float)rows) + yAdd; + } + + + gl.TexCoord2f(skymirror? -u:u, v); + } + if (r != 4) y+=FRACUNIT*300; + // And finally the vertex. + fx =-FIXED2FLOAT(x); // Doom mirrors the sky vertically! + fy = FIXED2FLOAT(y); + fz = FIXED2FLOAT(z); + gl.Vertex3f(fx, fy - 1.f, fz); +} + + +//----------------------------------------------------------------------------- +// +// Hemi is Upper or Lower. Zero is not acceptable. +// The current texture is used. SKYHEMI_NO_TOPCAP can be used. +// +//----------------------------------------------------------------------------- + +static void RenderSkyHemisphere(int hemi, bool mirror) +{ + int r, c; + + if (hemi & SKYHEMI_LOWER) + { + yflip = true; + } + else + { + yflip = false; + } + + skymirror = mirror; + + // The top row (row 0) is the one that's faded out. + // There must be at least 4 columns. The preferable number + // is 4n, where n is 1, 2, 3... There should be at least + // two rows because the first one is always faded. + rows = 4; + + if (hemi & SKYHEMI_JUST_CAP) + { + return; + } + + + // Draw the cap as one solid color polygon + if (!foglayer) + { + columns = 4 * (gl_sky_detail > 0 ? gl_sky_detail : 1); + foglayer=true; + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(true); + + + if (!secondlayer) + { + gl.Color3f(R, G ,B); + gl.Begin(GL_TRIANGLE_FAN); + for(c = 0; c < columns; c++) + { + SkyVertex(1, c); + } + gl.End(); + } + + gl_RenderState.EnableTexture(true); + foglayer=false; + gl_RenderState.Apply(); + } + else + { + gl_RenderState.Apply(true); + columns=4; // no need to do more! + gl.Begin(GL_TRIANGLE_FAN); + for(c = 0; c < columns; c++) + { + SkyVertex(0, c); + } + gl.End(); + } + + // The total number of triangles per hemisphere can be calculated + // as follows: rows * columns * 2 + 2 (for the top cap). + for(r = 0; r < rows; r++) + { + if (yflip) + { + gl.Begin(GL_TRIANGLE_STRIP); + SkyVertex(r + 1, 0); + SkyVertex(r, 0); + for(c = 1; c <= columns; c++) + { + SkyVertex(r + 1, c); + SkyVertex(r, c); + } + gl.End(); + } + else + { + gl.Begin(GL_TRIANGLE_STRIP); + SkyVertex(r, 0); + SkyVertex(r + 1, 0); + for(c = 1; c <= columns; c++) + { + SkyVertex(r, c); + SkyVertex(r + 1, c); + } + gl.End(); + } + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- +CVAR(Float, skyoffset, 0, 0) // for testing + +static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float y_offset, bool mirror, int CM_Index) +{ + int texh = 0; + bool texscale = false; + + // 57 worls units roughly represent one sky texel for the glTranslate call. + const float skyoffsetfactor = 57; + + if (tex) + { + gl.PushMatrix(); + tex->Bind(CM_Index, 0, 0); + texw = tex->TextureWidth(GLUSE_TEXTURE); + texh = tex->TextureHeight(GLUSE_TEXTURE); + + gl.Rotatef(-180.0f+x_offset, 0.f, 1.f, 0.f); + yAdd = y_offset/texh; + + if (texh < 200) + { + gl.Translatef(0.f, -1250.f, 0.f); + gl.Scalef(1.f, texh/230.f, 1.f); + } + else if (texh <= 240) + { + gl.Translatef(0.f, (200 - texh + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); + gl.Scalef(1.f, 1.f + ((texh-200.f)/200.f) * 1.17f, 1.f); + } + else + { + gl.Translatef(0.f, (-40 + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); + gl.Scalef(1.f, 1.2f * 1.17f, 1.f); + gl.MatrixMode(GL_TEXTURE); + gl.PushMatrix(); + gl.LoadIdentity(); + gl.Scalef(1.f, 240.f / texh, 1.f); + gl.MatrixMode(GL_MODELVIEW); + texscale = true; + } + } + + if (tex && !secondlayer) + { + PalEntry pe = tex->tex->GetSkyCapColor(false); + if (CM_Index!=CM_DEFAULT) ModifyPalette(&pe, &pe, CM_Index, 1); + + R=pe.r/255.0f; + G=pe.g/255.0f; + B=pe.b/255.0f; + + if (gl_fixedcolormap) + { + float rr, gg, bb; + + gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb); + R*=rr; + G*=gg; + B*=bb; + } + } + + RenderSkyHemisphere(SKYHEMI_UPPER, mirror); + + if (tex && !secondlayer) + { + PalEntry pe = tex->tex->GetSkyCapColor(true); + if (CM_Index!=CM_DEFAULT) ModifyPalette(&pe, &pe, CM_Index, 1); + R=pe.r/255.0f; + G=pe.g/255.0f; + B=pe.b/255.0f; + + if (gl_fixedcolormap != CM_DEFAULT) + { + float rr,gg,bb; + + gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb); + R*=rr; + G*=gg; + B*=bb; + } + } + + RenderSkyHemisphere(SKYHEMI_LOWER, mirror); + if (texscale) + { + gl.MatrixMode(GL_TEXTURE); + gl.PopMatrix(); + gl.MatrixMode(GL_MODELVIEW); + } + if (tex) gl.PopMatrix(); + +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int CM_Index, bool sky2) +{ + FSkyBox * sb = static_cast(gltex->tex); + int faces; + FMaterial * tex; + + if (!sky2) + gl.Rotatef(-180.0f+x_offset, glset.skyrotatevector.X, glset.skyrotatevector.Z, glset.skyrotatevector.Y); + else + gl.Rotatef(-180.0f+x_offset, glset.skyrotatevector2.X, glset.skyrotatevector2.Z, glset.skyrotatevector2.Y); + + gl.Color3f(R, G ,B); + + if (sb->faces[5]) + { + faces=4; + + // north + tex = FMaterial::ValidateTexture(sb->faces[0]); + tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_FAN); + gl.TexCoord2f(0, 0); + gl.Vertex3f(128.f, 128.f, -128.f); + gl.TexCoord2f(1, 0); + gl.Vertex3f(-128.f, 128.f, -128.f); + gl.TexCoord2f(1, 1); + gl.Vertex3f(-128.f, -128.f, -128.f); + gl.TexCoord2f(0, 1); + gl.Vertex3f(128.f, -128.f, -128.f); + gl.End(); + + // east + tex = FMaterial::ValidateTexture(sb->faces[1]); + tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_FAN); + gl.TexCoord2f(0, 0); + gl.Vertex3f(-128.f, 128.f, -128.f); + gl.TexCoord2f(1, 0); + gl.Vertex3f(-128.f, 128.f, 128.f); + gl.TexCoord2f(1, 1); + gl.Vertex3f(-128.f, -128.f, 128.f); + gl.TexCoord2f(0, 1); + gl.Vertex3f(-128.f, -128.f, -128.f); + gl.End(); + + // south + tex = FMaterial::ValidateTexture(sb->faces[2]); + tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_FAN); + gl.TexCoord2f(0, 0); + gl.Vertex3f(-128.f, 128.f, 128.f); + gl.TexCoord2f(1, 0); + gl.Vertex3f(128.f, 128.f, 128.f); + gl.TexCoord2f(1, 1); + gl.Vertex3f(128.f, -128.f, 128.f); + gl.TexCoord2f(0, 1); + gl.Vertex3f(-128.f, -128.f, 128.f); + gl.End(); + + // west + tex = FMaterial::ValidateTexture(sb->faces[3]); + tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_FAN); + gl.TexCoord2f(0, 0); + gl.Vertex3f(128.f, 128.f, 128.f); + gl.TexCoord2f(1, 0); + gl.Vertex3f(128.f, 128.f, -128.f); + gl.TexCoord2f(1, 1); + gl.Vertex3f(128.f, -128.f, -128.f); + gl.TexCoord2f(0, 1); + gl.Vertex3f(128.f, -128.f, 128.f); + gl.End(); + } + else + { + faces=1; + // all 4 sides + tex = FMaterial::ValidateTexture(sb->faces[0]); + tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); + + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_FAN); + gl.TexCoord2f(0, 0); + gl.Vertex3f(128.f, 128.f, -128.f); + gl.TexCoord2f(.25f, 0); + gl.Vertex3f(-128.f, 128.f, -128.f); + gl.TexCoord2f(.25f, 1); + gl.Vertex3f(-128.f, -128.f, -128.f); + gl.TexCoord2f(0, 1); + gl.Vertex3f(128.f, -128.f, -128.f); + gl.End(); + + // east + gl.Begin(GL_TRIANGLE_FAN); + gl.TexCoord2f(.25f, 0); + gl.Vertex3f(-128.f, 128.f, -128.f); + gl.TexCoord2f(.5f, 0); + gl.Vertex3f(-128.f, 128.f, 128.f); + gl.TexCoord2f(.5f, 1); + gl.Vertex3f(-128.f, -128.f, 128.f); + gl.TexCoord2f(.25f, 1); + gl.Vertex3f(-128.f, -128.f, -128.f); + gl.End(); + + // south + gl.Begin(GL_TRIANGLE_FAN); + gl.TexCoord2f(.5f, 0); + gl.Vertex3f(-128.f, 128.f, 128.f); + gl.TexCoord2f(.75f, 0); + gl.Vertex3f(128.f, 128.f, 128.f); + gl.TexCoord2f(.75f, 1); + gl.Vertex3f(128.f, -128.f, 128.f); + gl.TexCoord2f(.5f, 1); + gl.Vertex3f(-128.f, -128.f, 128.f); + gl.End(); + + // west + gl.Begin(GL_TRIANGLE_FAN); + gl.TexCoord2f(.75f, 0); + gl.Vertex3f(128.f, 128.f, 128.f); + gl.TexCoord2f(1, 0); + gl.Vertex3f(128.f, 128.f, -128.f); + gl.TexCoord2f(1, 1); + gl.Vertex3f(128.f, -128.f, -128.f); + gl.TexCoord2f(.75f, 1); + gl.Vertex3f(128.f, -128.f, 128.f); + gl.End(); + } + + // top + tex = FMaterial::ValidateTexture(sb->faces[faces]); + tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_FAN); + if (!sb->fliptop) + { + gl.TexCoord2f(0, 0); + gl.Vertex3f(128.f, 128.f, -128.f); + gl.TexCoord2f(1, 0); + gl.Vertex3f(-128.f, 128.f, -128.f); + gl.TexCoord2f(1, 1); + gl.Vertex3f(-128.f, 128.f, 128.f); + gl.TexCoord2f(0, 1); + gl.Vertex3f(128.f, 128.f, 128.f); + } + else + { + gl.TexCoord2f(0, 0); + gl.Vertex3f(128.f, 128.f, 128.f); + gl.TexCoord2f(1, 0); + gl.Vertex3f(-128.f, 128.f, 128.f); + gl.TexCoord2f(1, 1); + gl.Vertex3f(-128.f, 128.f, -128.f); + gl.TexCoord2f(0, 1); + gl.Vertex3f(128.f, 128.f, -128.f); + } + gl.End(); + + + // bottom + tex = FMaterial::ValidateTexture(sb->faces[faces+1]); + tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_FAN); + gl.TexCoord2f(0, 0); + gl.Vertex3f(128.f, -128.f, -128.f); + gl.TexCoord2f(1, 0); + gl.Vertex3f(-128.f, -128.f, -128.f); + gl.TexCoord2f(1, 1); + gl.Vertex3f(-128.f, -128.f, 128.f); + gl.TexCoord2f(0, 1); + gl.Vertex3f(128.f, -128.f, 128.f); + gl.End(); + + +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- +void GLSkyPortal::DrawContents() +{ + bool drawBoth = false; + int CM_Index; + PalEntry FadeColor(0,0,0,0); + + // We have no use for Doom lighting special handling here, so disable it for this function. + int oldlightmode = glset.lightmode; + if (glset.lightmode == 8) glset.lightmode = 2; + + + if (gl_fixedcolormap) + { + CM_Index=gl_fixedcolormapfadecolor; + } + + gl_RenderState.EnableFog(false); + gl_RenderState.EnableAlphaTest(false); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + gl.MatrixMode(GL_MODELVIEW); + gl.PushMatrix(); + GLRenderer->SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + + if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox) + { + if (gl_fixedcolormap != CM_DEFAULT) + { + float rr,gg,bb; + + gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb); + R=rr; + G=gg; + B=bb; + } + else R=G=B=1.f; + + RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], CM_Index, origin->sky2); + gl_RenderState.EnableAlphaTest(true); + } + else + { + if (origin->texture[0]==origin->texture[1] && origin->doublesky) origin->doublesky=false; + + if (origin->texture[0]) + { + gl_RenderState.SetTextureMode(TM_OPAQUE); + RenderDome(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->y_offset, origin->mirrored, CM_Index); + gl_RenderState.SetTextureMode(TM_MODULATE); + } + + gl_RenderState.EnableAlphaTest(true); + gl_RenderState.AlphaFunc(GL_GEQUAL,0.05f); + + if (origin->doublesky && origin->texture[1]) + { + secondlayer=true; + RenderDome(FNullTextureID(), origin->texture[1], origin->x_offset[1], origin->y_offset, false, CM_Index); + secondlayer=false; + } + + if (skyfog>0 && (FadeColor.r ||FadeColor.g || FadeColor.b)) + { + gl_RenderState.EnableTexture(false); + foglayer=true; + gl.Color4f(FadeColor.r/255.0f,FadeColor.g/255.0f,FadeColor.b/255.0f,skyfog/255.0f); + RenderDome(FNullTextureID(), NULL, 0, 0, false, CM_DEFAULT); + gl_RenderState.EnableTexture(true); + foglayer=false; + } + } + gl.PopMatrix(); + glset.lightmode = oldlightmode; +} + diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp new file mode 100644 index 000000000..2fd250f93 --- /dev/null +++ b/src/gl/scene/gl_sprite.cpp @@ -0,0 +1,991 @@ +/* +** gl_sprite.cpp +** Sprite/Particle rendering +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ +#include "gl/system/gl_system.h" +#include "p_local.h" +#include "p_effect.h" +#include "g_level.h" +#include "doomstat.h" +#include "gl/gl_functions.h" +#include "r_defs.h" +#include "r_sky.h" +#include "r_utility.h" + +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/models/gl_models.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" + +CVAR(Bool, gl_usecolorblending, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Bool, gl_spritebrightfog, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +CVAR(Bool, gl_sprite_blend, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +CVAR(Int, gl_spriteclip, 1, CVAR_ARCHIVE) +CVAR(Float, gl_sclipthreshold, 10.0, CVAR_ARCHIVE) +CVAR(Float, gl_sclipfactor, 1.8, CVAR_ARCHIVE) +CVAR(Int, gl_particles_style, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // 0 = square, 1 = round, 2 = smooth +CVAR(Int, gl_billboard_mode, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, gl_billboard_particles, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Int, gl_enhanced_nv_stealth, 3, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CUSTOM_CVAR(Int, gl_fuzztype, 0, CVAR_ARCHIVE) +{ + if (self < 0 || self > 7) self = 0; +} + +extern bool r_showviewer; +EXTERN_CVAR (Float, transsouls) + +extern TArray sprites; +extern TArray SpriteFrames; +extern TArray BloodTranslationColors; + +enum HWRenderStyle +{ + STYLEHW_Normal, // default + STYLEHW_Solid, // drawn solid (needs special treatment for sprites) + STYLEHW_NoAlphaTest, // disable alpha test +}; + + +void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending) +{ + int tm, sb, db, be; + + gl_GetRenderStyle(style, drawopaque, allowcolorblending, &tm, &sb, &db, &be); + gl_RenderState.BlendEquation(be); + gl_RenderState.BlendFunc(sb, db); + gl_RenderState.SetTextureMode(tm); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLSprite::Draw(int pass) +{ + if (pass!=GLPASS_PLAIN && pass != GLPASS_ALL && pass!=GLPASS_TRANSLUCENT) return; + + // Hack to enable bright sprites in faded maps + uint32 backupfade = Colormap.FadeColor.d; + if (gl_spritebrightfog && fullbright) + Colormap.FadeColor = 0; + + + bool additivefog = false; + int rel = getExtraLight(); + + if (pass==GLPASS_TRANSLUCENT) + { + // The translucent pass requires special setup for the various modes. + + // Brightmaps will only be used when doing regular drawing ops and having no fog + if (!gl_spritebrightfog && (!gl_isBlack(Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE || + RenderStyle.BlendOp != STYLEOP_Add)) + { + gl_RenderState.EnableBrightmap(false); + } + + gl_SetRenderStyle(RenderStyle, false, + // The rest of the needed checks are done inside gl_SetRenderStyle + trans > 1.f - FLT_EPSILON && gl_usecolorblending && gl_fixedcolormap < CM_FIRSTSPECIALCOLORMAP && actor && + fullbright && gltexture && !gltexture->GetTransparent()); + + if (hw_styleflags == STYLEHW_NoAlphaTest) + { + gl_RenderState.EnableAlphaTest(false); + } + else + { + gl_RenderState.AlphaFunc(GL_GEQUAL,trans*gl_mask_sprite_threshold); + } + + if (RenderStyle.BlendOp == STYLEOP_Shadow) + { + float fuzzalpha=0.44f; + float minalpha=0.1f; + + // fog + fuzz don't work well without some fiddling with the alpha value! + if (!gl_isBlack(Colormap.FadeColor)) + { + float xcamera=FIXED2FLOAT(viewx); + float ycamera=FIXED2FLOAT(viewy); + + float dist=Dist2(xcamera,ycamera, x,y); + + if (!Colormap.FadeColor.a) Colormap.FadeColor.a=clamp(255-lightlevel,60,255); + + // this value was determined by trial and error and is scale dependent! + float factor=0.05f+exp(-Colormap.FadeColor.a*dist/62500.f); + fuzzalpha*=factor; + minalpha*=factor; + } + + gl_RenderState.AlphaFunc(GL_GEQUAL,minalpha*gl_mask_sprite_threshold); + gl.Color4f(0.2f,0.2f,0.2f,fuzzalpha); + additivefog = true; + } + else if (RenderStyle.BlendOp == STYLEOP_Add && RenderStyle.DestAlpha == STYLEALPHA_One) + { + additivefog = true; + } + } + if (RenderStyle.BlendOp!=STYLEOP_Shadow) + { + if (actor) + { + lightlevel = gl_SetSpriteLighting(RenderStyle, actor, lightlevel, rel, &Colormap, ThingColor, trans, + fullbright || gl_fixedcolormap >= CM_FIRSTSPECIALCOLORMAP, false); + } + else if (particle) + { + if (gl_light_particles) + { + lightlevel = gl_SetSpriteLight(particle, lightlevel, rel, &Colormap, trans, ThingColor); + } + else + { + gl_SetColor(lightlevel, rel, &Colormap, trans, ThingColor); + } + } + else return; + } + + if (gl_isBlack(Colormap.FadeColor)) foglevel=lightlevel; + + if (RenderStyle.Flags & STYLEF_FadeToBlack) + { + Colormap.FadeColor=0; + additivefog = true; + } + + if (RenderStyle.Flags & STYLEF_InvertOverlay) + { + Colormap.FadeColor = Colormap.FadeColor.InverseColor(); + additivefog=false; + } + + gl_SetFog(foglevel, rel, &Colormap, additivefog); + + if (gltexture) gltexture->BindPatch(Colormap.colormap, translation, OverrideShader); + else if (!modelframe) gl_RenderState.EnableTexture(false); + + if (!modelframe) + { + // [BB] Billboard stuff + const bool drawWithXYBillboard = ( (particle && gl_billboard_particles) || (!(actor && actor->renderflags & RF_FORCEYBILLBOARD) + //&& GLRenderer->mViewActor != NULL + && (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD ))) ); + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_STRIP); + if ( drawWithXYBillboard ) + { + // Rotate the sprite about the vector starting at the center of the sprite + // triangle strip and with direction orthogonal to where the player is looking + // in the x/y plane. + float xcenter = (x1+x2)*0.5; + float ycenter = (y1+y2)*0.5; + float zcenter = (z1+z2)*0.5; + float angleRad = DEG2RAD(270. - float(GLRenderer->mAngles.Yaw)); + + Matrix3x4 mat; + mat.MakeIdentity(); + mat.Translate( xcenter, zcenter, ycenter); + mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch); + mat.Translate( -xcenter, -zcenter, -ycenter); + Vector v1 = mat * Vector(x1,z1,y1); + Vector v2 = mat * Vector(x2,z1,y2); + Vector v3 = mat * Vector(x1,z2,y1); + Vector v4 = mat * Vector(x2,z2,y2); + + if (gltexture) + { + gl.TexCoord2f(ul, vt); gl.Vertex3fv(&v1[0]); + gl.TexCoord2f(ur, vt); gl.Vertex3fv(&v2[0]); + gl.TexCoord2f(ul, vb); gl.Vertex3fv(&v3[0]); + gl.TexCoord2f(ur, vb); gl.Vertex3fv(&v4[0]); + } + else // Particle + { + gl.Vertex3fv(&v1[0]); + gl.Vertex3fv(&v2[0]); + gl.Vertex3fv(&v3[0]); + gl.Vertex3fv(&v4[0]); + } + + } + else + { + if (gltexture) + { + gl.TexCoord2f(ul, vt); gl.Vertex3f(x1, z1, y1); + gl.TexCoord2f(ur, vt); gl.Vertex3f(x2, z1, y2); + gl.TexCoord2f(ul, vb); gl.Vertex3f(x1, z2, y1); + gl.TexCoord2f(ur, vb); gl.Vertex3f(x2, z2, y2); + } + else // Particle + { + gl.Vertex3f(x1, z1, y1); + gl.Vertex3f(x2, z1, y2); + gl.Vertex3f(x1, z2, y1); + gl.Vertex3f(x2, z2, y2); + } + } + gl.End(); + } + else + { + gl_RenderModel(this, Colormap.colormap); + } + + if (pass==GLPASS_TRANSLUCENT) + { + gl_RenderState.EnableBrightmap(true); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.SetTextureMode(TM_MODULATE); + + // [BB] Restore the alpha test after drawing a smooth particle. + if (hw_styleflags == STYLEHW_NoAlphaTest) + { + gl_RenderState.EnableAlphaTest(true); + } + else + { + gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_sprite_threshold); + } + } + + // End of gl_sprite_brightfog hack: restore FadeColor to normalcy + if (backupfade != Colormap.FadeColor.d) + Colormap.FadeColor = backupfade; + + gl_RenderState.EnableTexture(true); + gl_RenderState.SetDynLight(0,0,0); +} + + +//========================================================================== +// +// +// +//========================================================================== +inline void GLSprite::PutSprite(bool translucent) +{ + int list; + // [BB] Allow models to be drawn in the GLDL_TRANSLUCENT pass. + if (translucent || !modelframe) + { + list = GLDL_TRANSLUCENT; + } + else if ((!gl_isBlack (Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE)) + { + list = GLDL_FOGMASKED; + } + else + { + list = GLDL_MASKED; + } + gl_drawinfo->drawlists[list].AddSprite(this); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLSprite::SplitSprite(sector_t * frontsector, bool translucent) +{ + GLSprite copySprite; + fixed_t lightbottom; + float maplightbottom; + unsigned int i; + bool put=false; + TArray & lightlist=frontsector->e->XFloor.lightlist; + + //y1+=y; + //y2+=y; + //y=0; + for(i=0;ix,actor->y); + else lightbottom=frontsector->floorplane.ZatPoint(actor->x,actor->y); + + //maplighttop=FIXED2FLOAT(lightlist[i].height); + maplightbottom=FIXED2FLOAT(lightbottom); + if (maplightbottom>8; + copySprite.Colormap.LightColor.g=(copySprite.Colormap.LightColor.g*ThingColor.g)>>8; + copySprite.Colormap.LightColor.b=(copySprite.Colormap.LightColor.b*ThingColor.b)>>8; + } + + z1=copySprite.z2=maplightbottom; + vt=copySprite.vb=copySprite.vt+ + (maplightbottom-copySprite.z1)*(copySprite.vb-copySprite.vt)/(z2-copySprite.z1); + copySprite.PutSprite(translucent); + put=true; + } + } + //if (y1 & lightlist=actor->Sector->e->XFloor.lightlist; + + for(i=0;ix,actor->y); + else lightbottom=sector->floorplane.ZatPoint(actor->x,actor->y); + + //maplighttop=FIXED2FLOAT(lightlist[i].height); + maplightbottom=FIXED2FLOAT(lightbottom); + if (maplightbottom>8; + Colormap.LightColor.g=(Colormap.LightColor.g*ThingColor.g)>>8; + Colormap.LightColor.b=(Colormap.LightColor.b*ThingColor.b)>>8; + } + return; + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void GLSprite::Process(AActor* thing,sector_t * sector) +{ + sector_t rs; + sector_t * rendersector; + // don't draw the thing that's used as camera (for viewshifts during quakes!) + if (thing==GLRenderer->mViewActor) return; + + // Don't waste time projecting sprites that are definitely not visible. + if (thing == NULL || thing->sprite == 0 || !thing->IsVisibleToPlayer()) + { + return; + } + + int spritenum = thing->sprite; + fixed_t spritescaleX = thing->scaleX; + fixed_t spritescaleY = thing->scaleY; + if (thing->player != NULL) + { + P_CheckPlayerSprite(thing, spritenum, spritescaleX, spritescaleY); + } + + if (thing->renderflags & RF_INVISIBLE || !thing->RenderStyle.IsVisible(thing->alpha)) + { + if (!(thing->flags & MF_STEALTH) || !gl_fixedcolormap || !gl_enhanced_nightvision) + return; + } + + // If this thing is in a map section that's not in view it can't possibly be visible + if (!(currentmapsection[thing->subsector->mapsection>>3] & (1 << (thing->subsector->mapsection & 7)))) return; + + // [RH] Interpolate the sprite's position to make it look smooth + fixed_t thingx = thing->PrevX + FixedMul (r_TicFrac, thing->x - thing->PrevX); + fixed_t thingy = thing->PrevY + FixedMul (r_TicFrac, thing->y - thing->PrevY); + fixed_t thingz = thing->PrevZ + FixedMul (r_TicFrac, thing->z - thing->PrevZ); + + // Too close to the camera. This doesn't look good if it is a sprite. + if (P_AproxDistance(thingx-viewx, thingy-viewy)<2*FRACUNIT) + { + // exclude vertically moving objects from this check. + if (!(thing->velx==0 && thing->vely==0 && thing->velz!=0)) + { + if (!gl_FindModelFrame(RUNTIME_TYPE(thing), spritenum, thing->frame, false)) + { + return; + } + } + } + + // don't draw first frame of a player missile + if (thing->flags&MF_MISSILE && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) + { + if (P_AproxDistance(thingx-viewx, thingy-viewy) < thing->Speed ) return; + } + + if (GLRenderer->mCurrentPortal) + { + int clipres = GLRenderer->mCurrentPortal->ClipPoint(thingx, thingy); + if (clipres == GLPortal::PClip_InFront) return; + } + + player_t *player=&players[consoleplayer]; + FloatRect r; + + if (sector->sectornum!=thing->Sector->sectornum) + { + rendersector=gl_FakeFlat(thing->Sector, &rs, false); + } + else + { + rendersector=sector; + } + + + x = FIXED2FLOAT(thingx); + z = FIXED2FLOAT(thingz-thing->floorclip); + y = FIXED2FLOAT(thingy); + + // [RH] Make floatbobbing a renderer-only effect. + if (thing->flags2 & MF2_FLOATBOB) + { + float fz = FIXED2FLOAT(thing->GetBobOffset(r_TicFrac)); + z += fz; + } + + modelframe = gl_FindModelFrame(RUNTIME_TYPE(thing), spritenum, thing->frame, !!(thing->flags & MF_DROPPED)); + if (!modelframe) + { + angle_t ang = R_PointToAngle(thingx, thingy); + + bool mirror; + FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, ang - thing->angle, &mirror); + if (!patch.isValid()) return; + gltexture=FMaterial::ValidateTexture(patch, false); + if (!gltexture) return; + + if (gl.flags & RFL_NPOT_TEXTURE) // trimming only works if non-power-of-2 textures are supported + { + vt = gltexture->GetSpriteVT(); + vb = gltexture->GetSpriteVB(); + gltexture->GetRect(&r, GLUSE_SPRITE); + if (mirror) + { + r.left=-r.width-r.left; // mirror the sprite's x-offset + ul = gltexture->GetSpriteUL(); + ur = gltexture->GetSpriteUR(); + } + else + { + ul = gltexture->GetSpriteUR(); + ur = gltexture->GetSpriteUL(); + } + } + else + { + vt = gltexture->GetVT(); + vb = gltexture->GetVB(); + gltexture->GetRect(&r, GLUSE_PATCH); + if (mirror) + { + r.left=-r.width-r.left; // mirror the sprite's x-offset + ul = gltexture->GetUL(); + ur = gltexture->GetUR(); + } + else + { + ul = gltexture->GetUR(); + ur = gltexture->GetUL(); + } + } + + r.Scale(FIXED2FLOAT(spritescaleX),FIXED2FLOAT(spritescaleY)); + + float rightfac=-r.left; + float leftfac=rightfac-r.width; + + z1=z-r.top; + z2=z1-r.height; + + float spriteheight = FIXED2FLOAT(spritescaleY) * gltexture->GetScaledHeightFloat(GLUSE_SPRITE); + + // Tests show that this doesn't look good for many decorations and corpses + if (spriteheight>0 && gl_spriteclip>0) + { + bool smarterclip = false; // Set to true if one condition triggers the test below + if (((thing->player || thing->flags3&MF3_ISMONSTER || + thing->IsKindOf(RUNTIME_CLASS(AInventory))) && (thing->flags&MF_ICECORPSE || + !(thing->flags&MF_CORPSE))) || (gl_spriteclip==3 && (smarterclip = true)) || gl_spriteclip > 1) + { + float btm= 1000000.0f; + float top=-1000000.0f; + extsector_t::xfloor &x = thing->Sector->e->XFloor; + + if (x.ffloors.Size()) + { + for(unsigned int i=0;itop.plane->ZatPoint(thingx, thingy); + fixed_t ceilingh=ff->bottom.plane->ZatPoint(thingx, thingy); + if (floorh==thing->floorz) + { + btm=FIXED2FLOAT(floorh); + } + if (ceilingh==thing->ceilingz) + { + top=FIXED2FLOAT(ceilingh); + } + if (btm != 1000000.0f && top != -1000000.0f) + { + break; + } + } + } + else if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) + { + if (thing->flags2&MF2_ONMOBJ && thing->floorz== + thing->Sector->heightsec->floorplane.ZatPoint(thingx, thingy)) + { + btm=FIXED2FLOAT(thing->floorz); + top=FIXED2FLOAT(thing->ceilingz); + } + } + if (btm==1000000.0f) + btm= FIXED2FLOAT(thing->Sector->floorplane.ZatPoint(thingx, thingy)-thing->floorclip); + if (top==-1000000.0f) + top= FIXED2FLOAT(thing->Sector->ceilingplane.ZatPoint(thingx, thingy)); + + float diffb = z2 - btm; + float difft = z1 - top; + if (diffb >= 0 /*|| !gl_sprite_clip_to_floor*/) diffb = 0; + // Adjust sprites clipping into ceiling and adjust clipping adjustment for tall graphics + if (smarterclip) + { + // Reduce slightly clipping adjustment of corpses + if (thing->flags & MF_CORPSE || spriteheight > abs(diffb)) + { + float ratio = clamp((abs(diffb) * (float)gl_sclipfactor/(spriteheight+1)), 0.5, 1.0); + diffb*=ratio; + } + if (!diffb) + { + if (difft <= 0) difft = 0; + if (difft >= (float)gl_sclipthreshold) + { + // dumb copy of the above. + if (!(thing->flags3&MF3_ISMONSTER) || (thing->flags&MF_NOGRAVITY) || (thing->flags&MF_CORPSE) || difft > (float)gl_sclipthreshold) + { + difft=0; + } + } + if (spriteheight > abs(difft)) + { + float ratio = clamp((abs(difft) * (float)gl_sclipfactor/(spriteheight+1)), 0.5, 1.0); + difft*=ratio; + } + z2-=difft; + z1-=difft; + } + } + if (diffb <= (0 - (float)gl_sclipthreshold)) // such a large displacement can't be correct! + { + // for living monsters standing on the floor allow a little more. + if (!(thing->flags3&MF3_ISMONSTER) || (thing->flags&MF_NOGRAVITY) || (thing->flags&MF_CORPSE) || diffb<(-1.8*(float)gl_sclipthreshold)) + { + diffb=0; + } + } + z2-=diffb; + z1-=diffb; + } + } + float viewvecX = GLRenderer->mViewVector.X; + float viewvecY = GLRenderer->mViewVector.Y; + + x1=x-viewvecY*leftfac; + x2=x-viewvecY*rightfac; + y1=y+viewvecX*leftfac; + y2=y+viewvecX*rightfac; + } + else + { + x1 = x2 = x; + y1 = y2 = y; + z1 = z2 = z; + gltexture=NULL; + } + + depth = DMulScale20 (thing->x-viewx, viewtancos, thing->y-viewy, viewtansin); + + // light calculation + + bool enhancedvision=false; + + // allow disabling of the fullbright flag by a brightmap definition + // (e.g. to do the gun flashes of Doom's zombies correctly. + fullbright = (thing->flags5 & MF5_BRIGHT) || + ((thing->renderflags & RF_FULLBRIGHT) && (!gl_BrightmapsActive() || !gltexture || !gltexture->tex->gl_info.bBrightmapDisablesFullbright)); + + lightlevel=fullbright? 255 : + gl_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ? + rendersector->GetCeilingLight() : rendersector->GetFloorLight()); + foglevel = (BYTE)clamp(rendersector->lightlevel, 0, 255); + + lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, thingx, thingy, thingz); + + // colormap stuff is a little more complicated here... + if (gl_fixedcolormap) + { + if ((gl_enhanced_nv_stealth > 0 && gl_fixedcolormap == CM_LITE) // Infrared powerup only + || (gl_enhanced_nv_stealth == 2 && gl_fixedcolormap >= CM_TORCH)// Also torches + || (gl_enhanced_nv_stealth == 3)) // Any fixed colormap + enhancedvision=true; + + Colormap.GetFixedColormap(); + + if (gl_fixedcolormap==CM_LITE) + { + if (gl_enhanced_nightvision && + (thing->IsKindOf(RUNTIME_CLASS(AInventory)) || thing->flags3&MF3_ISMONSTER || thing->flags&MF_MISSILE || thing->flags&MF_CORPSE)) + { + Colormap.colormap = CM_FIRSTSPECIALCOLORMAP + INVERSECOLORMAP; + } + } + } + else + { + Colormap=rendersector->ColorMap; + if (fullbright) + { + if (rendersector == §ors[rendersector->sectornum] || in_area != area_below) + // under water areas keep their color for fullbright objects + { + // Only make the light white but keep everything else (fog, desaturation and Boom colormap.) + Colormap.LightColor.r= + Colormap.LightColor.g= + Colormap.LightColor.b=0xff; + } + else + { + Colormap.LightColor.r = (3*Colormap.LightColor.r + 0xff)/4; + Colormap.LightColor.g = (3*Colormap.LightColor.g + 0xff)/4; + Colormap.LightColor.b = (3*Colormap.LightColor.b + 0xff)/4; + } + } + else if (glset.nocoloredspritelighting) + { + int v = (Colormap.LightColor.r /* * 77 */ + Colormap.LightColor.g /**143 */ + Colormap.LightColor.b /**35*/)/3;//255; + Colormap.LightColor.r= + Colormap.LightColor.g= + Colormap.LightColor.b=(255+v+v)/3; + } + } + + translation=thing->Translation; + + ThingColor=0xffffff; + RenderStyle = thing->RenderStyle; + OverrideShader = 0; + trans = FIXED2FLOAT(thing->alpha); + hw_styleflags = STYLEHW_Normal; + + if (RenderStyle.BlendOp >= STYLEOP_Fuzz && RenderStyle.BlendOp <= STYLEOP_FuzzOrRevSub) + { + RenderStyle.CheckFuzz(); + if (RenderStyle.BlendOp == STYLEOP_Fuzz) + { + if (gl.shadermodel >= 4 && gl_fuzztype != 0) + { + // Todo: implement shader selection here + RenderStyle = LegacyRenderStyles[STYLE_Translucent]; + OverrideShader = gl_fuzztype + 4; + trans = 0.99f; // trans may not be 1 here + hw_styleflags |= STYLEHW_NoAlphaTest; + } + else + { + RenderStyle.BlendOp = STYLEOP_Shadow; + } + } + } + + if (RenderStyle.Flags & STYLEF_TransSoulsAlpha) + { + trans = transsouls; + } + else if (RenderStyle.Flags & STYLEF_Alpha1) + { + trans = 1.f; + } + + if (trans >= 1.f-FLT_EPSILON && RenderStyle.BlendOp != STYLEOP_Shadow && ( + (RenderStyle.SrcAlpha == STYLEALPHA_One && RenderStyle.DestAlpha == STYLEALPHA_Zero) || + (RenderStyle.SrcAlpha == STYLEALPHA_Src && RenderStyle.DestAlpha == STYLEALPHA_InvSrc) + )) + { + // This is a non-translucent sprite (i.e. STYLE_Normal or equivalent) + trans=1.f; + + + if (!gl_sprite_blend || modelframe) + { + RenderStyle.SrcAlpha = STYLEALPHA_One; + RenderStyle.DestAlpha = STYLEALPHA_Zero; + hw_styleflags = STYLEHW_Solid; + } + else + { + RenderStyle.SrcAlpha = STYLEALPHA_Src; + RenderStyle.DestAlpha = STYLEALPHA_InvSrc; + } + + + } + if ((gltexture && gltexture->GetTransparent()) || (RenderStyle.Flags & STYLEF_RedIsAlpha)) + { + if (hw_styleflags == STYLEHW_Solid) + { + RenderStyle.SrcAlpha = STYLEALPHA_Src; + RenderStyle.DestAlpha = STYLEALPHA_InvSrc; + } + hw_styleflags = STYLEHW_NoAlphaTest; + } + + if (enhancedvision && gl_enhanced_nightvision) + { + if (RenderStyle.BlendOp == STYLEOP_Shadow) + { + // enhanced vision makes them more visible! + trans=0.5f; + RenderStyle = STYLE_Translucent; + } + else if (thing->flags & MF_STEALTH) + { + // enhanced vision overcomes stealth! + if (trans < 0.5f) trans = 0.5f; + } + } + + if (trans==0.0f) return; + + // end of light calculation + + actor=thing; + index = GLRenderer->gl_spriteindex++; + particle=NULL; + + const bool drawWithXYBillboard = ( !(actor->renderflags & RF_FORCEYBILLBOARD) + && players[consoleplayer].camera + && (gl_billboard_mode == 1 || actor->renderflags & RF_FORCEXYBILLBOARD ) ); + + + if (drawWithXYBillboard || modelframe) + { + if (!gl_fixedcolormap && !fullbright) SetSpriteColor(actor->Sector, actor->y + (actor->height>>1)); + PutSprite(hw_styleflags != STYLEHW_Solid); + } + else if (thing->Sector->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap || fullbright) + { + PutSprite(hw_styleflags != STYLEHW_Solid); + } + else + { + SplitSprite(thing->Sector, hw_styleflags != STYLEHW_Solid); + } + rendered_sprites++; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int shade, int fakeside) +{ + if (GLRenderer->mCurrentPortal) + { + int clipres = GLRenderer->mCurrentPortal->ClipPoint(particle->x, particle->y); + if (clipres == GLPortal::PClip_InFront) return; + } + + player_t *player=&players[consoleplayer]; + + if (particle->trans==0) return; + + lightlevel = gl_ClampLight(sector->GetTexture(sector_t::ceiling) == skyflatnum ? + sector->GetCeilingLight() : sector->GetFloorLight()); + foglevel = sector->lightlevel; + + if (gl_fixedcolormap) + { + Colormap.GetFixedColormap(); + } + else if (!particle->bright) + { + TArray & lightlist=sector->e->XFloor.lightlist; + int lightbottom; + + Colormap = sector->ColorMap; + for(unsigned int i=0;ix,particle->y); + else lightbottom = sector->floorplane.ZatPoint(particle->x,particle->y); + + if (lightbottom < particle->y) + { + lightlevel = *lightlist[i].p_lightlevel; + Colormap.LightColor = (lightlist[i].extra_colormap)->Color; + break; + } + } + } + else + { + lightlevel = 255; + Colormap = sector->ColorMap; + Colormap.ClearColor(); + } + + trans=particle->trans/255.0f; + RenderStyle = STYLE_Translucent; + OverrideShader = 0; + + ThingColor = particle->color; //GPalette.BaseColors[particle->color]; + ThingColor.a=0; + + modelframe=NULL; + gltexture=NULL; + + // [BB] Load the texture for round or smooth particles + if (gl_particles_style) + { + FTexture *lump = NULL; + if (gl_particles_style == 1) + { + lump = GLRenderer->glpart2; + } + else if (gl_particles_style == 2) + { + lump = GLRenderer->glpart; + } + + if (lump != NULL) + { + gltexture=FMaterial::ValidateTexture(lump); + translation = 0; + + ul = gltexture->GetUL(); + ur = gltexture->GetUR(); + vt = gltexture->GetVT(); + vb = gltexture->GetVB(); + FloatRect r; + gltexture->GetRect(&r, GLUSE_PATCH); + } + } + + x= FIXED2FLOAT(particle->x); + y= FIXED2FLOAT(particle->y); + z= FIXED2FLOAT(particle->z); + + float scalefac=particle->size/4.0f; + // [BB] The smooth particles are smaller than the other ones. Compensate for this here. + if (gl_particles_style==2) + scalefac *= 1.7; + + float viewvecX = GLRenderer->mViewVector.X; + float viewvecY = GLRenderer->mViewVector.Y; + + x1=x+viewvecY*scalefac; + x2=x-viewvecY*scalefac; + y1=y-viewvecX*scalefac; + y2=y+viewvecX*scalefac; + z1=z-scalefac; + z2=z+scalefac; + + depth = DMulScale20 (particle->x-viewx, viewtancos, particle->y-viewy, viewtansin); + + actor=NULL; + this->particle=particle; + + // [BB] Translucent particles have to be rendered without the alpha test. + if (gl_particles_style != 2 && trans>=1.0f-FLT_EPSILON) hw_styleflags = STYLEHW_Solid; + else hw_styleflags = STYLEHW_NoAlphaTest; + + PutSprite(hw_styleflags != STYLEHW_Solid); + rendered_sprites++; +} + + + diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp new file mode 100644 index 000000000..56ab7030c --- /dev/null +++ b/src/gl/scene/gl_spritelight.cpp @@ -0,0 +1,300 @@ +/* +** gl_light.cpp +** Light level / fog management / dynamic lights +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "c_dispatch.h" +#include "p_local.h" +#include "p_effect.h" +#include "vectors.h" +#include "gl/gl_functions.h" +#include "g_level.h" + +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" + + +//========================================================================== +// +// Gets the light for a sprite - takes dynamic lights into account +// +//========================================================================== + +bool gl_GetSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsector_t * subsec, int desaturation, float * out, line_t *line, int side) +{ + ADynamicLight *light; + float frac, lr, lg, lb; + float radius; + bool changed = false; + + out[0]=out[1]=out[2]=0; + + for(int j=0;j<2;j++) + { + // Go through both light lists + FLightNode * node = subsec->lighthead[j]; + while (node) + { + light=node->lightsource; + if (!(light->flags2&MF2_DORMANT) && + (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) + { + float dist = FVector3( FIXED2FLOAT(x - light->x), FIXED2FLOAT(y - light->y), FIXED2FLOAT(z - light->z) ).Length(); + radius = light->GetRadius() * gl_lights_size; + + if (dist < radius) + { + frac = 1.0f - (dist / radius); + + if (frac > 0) + { + if (line != NULL) + { + if (P_PointOnLineSide(light->x, light->y, line) != side) + { + node = node->nextLight; + continue; + } + } + lr = light->GetRed() / 255.0f * gl_lights_intensity; + lg = light->GetGreen() / 255.0f * gl_lights_intensity; + lb = light->GetBlue() / 255.0f * gl_lights_intensity; + if (light->IsSubtractive()) + { + float bright = FVector3(lr, lg, lb).Length(); + FVector3 lightColor(lr, lg, lb); + lr = (bright - lr) * -1; + lg = (bright - lg) * -1; + lb = (bright - lb) * -1; + } + + out[0] += lr * frac; + out[1] += lg * frac; + out[2] += lb * frac; + changed = true; + } + } + } + node = node->nextLight; + } + } + + // Desaturate dynamic lighting if applicable + if (desaturation>0 && desaturation<=CM_DESAT31) + { + float gray=(out[0]*77 + out[1]*143 + out[2]*37)/257; + + out[0]= (out[0]*(31-desaturation)+ gray*desaturation)/31; + out[1]= (out[1]*(31-desaturation)+ gray*desaturation)/31; + out[2]= (out[2]*(31-desaturation)+ gray*desaturation)/31; + } + return changed; +} + + + +//========================================================================== +// +// Sets the light for a sprite - takes dynamic lights into account +// +//========================================================================== + +static int gl_SetSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsector_t * subsec, + int lightlevel, int rellight, FColormap * cm, float alpha, + PalEntry ThingColor, bool weapon) +{ + float r,g,b; + float result[4]; // Korshun. + + gl_GetLightColor(lightlevel, rellight, cm, &r, &g, &b, weapon); + bool res = gl_GetSpriteLight(self, x, y, z, subsec, cm? cm->colormap : 0, result); + if (!res || glset.lightmode == 8) + { + r *= ThingColor.r/255.f; + g *= ThingColor.g/255.f; + b *= ThingColor.b/255.f; + gl.Color4f(r, g, b, alpha); + if (glset.lightmode == 8) + { + gl.VertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(lightlevel, rellight, weapon) / 255.0f); // Korshun. + gl_RenderState.SetDynLight(result[0], result[1], result[2]); + } + return lightlevel; + } + else + { + // Note: Due to subtractive lights the values can easily become negative so we have to clamp both + // at the low and top end of the range! + r = clamp(result[0]+r, 0, 1.0f); + g = clamp(result[1]+g, 0, 1.0f); + b = clamp(result[2]+b, 0, 1.0f); + + float dlightlevel = r*77 + g*143 + b*35; + + r *= ThingColor.r/255.f; + g *= ThingColor.g/255.f; + b *= ThingColor.b/255.f; + + gl.Color4f(r, g, b, alpha); + + if (dlightlevel == 0) return 0; + + if (glset.lightmode&2 && dlightlevel<192.f) + { + return xs_CRoundToInt(192.f - (192.f - dlightlevel) / 1.95f); + } + else + { + return xs_CRoundToInt(dlightlevel); + } + } +} + +int gl_SetSpriteLight(AActor * thing, int lightlevel, int rellight, FColormap * cm, + float alpha, PalEntry ThingColor, bool weapon) +{ + subsector_t * subsec = thing->subsector; + return gl_SetSpriteLight(thing, thing->x, thing->y, thing->z+(thing->height>>1), subsec, + lightlevel, rellight, cm, alpha, ThingColor, weapon); +} + +int gl_SetSpriteLight(particle_t * thing, int lightlevel, int rellight, FColormap *cm, float alpha, PalEntry ThingColor) +{ + return gl_SetSpriteLight(NULL, thing->x, thing->y, thing->z, thing->subsector, lightlevel, rellight, + cm, alpha, ThingColor, false); +} + +//========================================================================== +// +// Modifies the color values depending on the render style +// +//========================================================================== + +void gl_GetSpriteLighting(FRenderStyle style, AActor *thing, FColormap *cm, PalEntry &ThingColor) +{ + if (style.Flags & STYLEF_RedIsAlpha) + { + cm->colormap = CM_SHADE; + } + if (style.Flags & STYLEF_ColorIsFixed) + { + if (style.Flags & STYLEF_InvertSource) + { + ThingColor = PalEntry(thing->fillcolor).InverseColor(); + } + else + { + ThingColor = thing->fillcolor; + } + } + + // This doesn't work like in the software renderer. + if (style.Flags & STYLEF_InvertSource) + { + int gray = (cm->LightColor.r*77 + cm->LightColor.r*143 + cm->LightColor.r*36)>>8; + cm->LightColor.r = cm->LightColor.g = cm->LightColor.b = gray; + } +} + + +//========================================================================== +// +// Sets render state to draw the given render style +// +//========================================================================== + +int gl_SetSpriteLighting(FRenderStyle style, AActor *thing, int lightlevel, int rellight, FColormap *cm, + PalEntry ThingColor, float alpha, bool fullbright, bool weapon) +{ + FColormap internal_cm; + + if (style.Flags & STYLEF_RedIsAlpha) + { + cm->colormap = CM_SHADE; + } + if (style.Flags & STYLEF_ColorIsFixed) + { + if (style.Flags & STYLEF_InvertSource) + { + ThingColor = PalEntry(thing->fillcolor).InverseColor(); + } + else + { + ThingColor = thing->fillcolor; + } + gl_ModifyColor(ThingColor.r, ThingColor.g, ThingColor.b, cm->colormap); + } + + // This doesn't work like in the software renderer. + if (style.Flags & STYLEF_InvertSource) + { + internal_cm = *cm; + cm = &internal_cm; + + int gray = (internal_cm.LightColor.r*77 + internal_cm.LightColor.r*143 + internal_cm.LightColor.r*36)>>8; + cm->LightColor.r = cm->LightColor.g = cm->LightColor.b = gray; + } + + if (style.BlendOp == STYLEOP_Shadow) + { + gl.Color4f(0.2f * ThingColor.r / 255.f, 0.2f * ThingColor.g / 255.f, + 0.2f * ThingColor.b / 255.f, (alpha = 0.33f)); + } + else + { + if (gl_light_sprites && gl_lights && GLRenderer->mLightCount && !fullbright) + { + lightlevel = gl_SetSpriteLight(thing, lightlevel, rellight, cm, alpha, ThingColor, weapon); + } + else + { + gl_SetColor(lightlevel, rellight, cm, alpha, ThingColor, weapon); + } + } + gl_RenderState.AlphaFunc(GL_GEQUAL,alpha*gl_mask_sprite_threshold); + return lightlevel; +} + diff --git a/src/gl/scene/gl_vertex.cpp b/src/gl/scene/gl_vertex.cpp new file mode 100644 index 000000000..0e70b4077 --- /dev/null +++ b/src/gl/scene/gl_vertex.cpp @@ -0,0 +1,195 @@ +/* +** gl_vertex.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2006 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + + + +#include "gl/system/gl_system.h" +#include "gl/gl_functions.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_templates.h" + +EXTERN_CVAR(Bool, gl_seamless) +extern int vertexcount; + +//========================================================================== +// +// Split upper edge of wall +// +//========================================================================== + +void GLWall::SplitUpperEdge(texcoord * tcs, bool glow) +{ + if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; + + side_t *sidedef = seg->sidedef; + float polyw = glseg.fracright - glseg.fracleft; + float facu = (tcs[2].u - tcs[1].u) / polyw; + float facv = (tcs[2].v - tcs[1].v) / polyw; + float fact = (ztop[1] - ztop[0]) / polyw; + float facc = (zceil[1] - zceil[0]) / polyw; + float facf = (zfloor[1] - zfloor[0]) / polyw; + + for (int i=0; i < sidedef->numsegs - 1; i++) + { + seg_t *cseg = sidedef->segs[i]; + float sidefrac = cseg->sidefrac; + if (sidefrac <= glseg.fracleft) continue; + if (sidefrac >= glseg.fracright) return; + + float fracfac = sidefrac - glseg.fracleft; + + if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - ztop[0] + (facc - fact) * fracfac, + ztop[0] - zfloor[0] + (fact - facf) * fracfac); + + gl.TexCoord2f(tcs[1].u + facu * fracfac, tcs[1].v + facv * fracfac); + gl.Vertex3f(cseg->v2->fx, ztop[0] + fact * fracfac, cseg->v2->fy); + } + vertexcount += sidedef->numsegs-1; +} + +//========================================================================== +// +// Split upper edge of wall +// +//========================================================================== + +void GLWall::SplitLowerEdge(texcoord * tcs, bool glow) +{ + if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; + + side_t *sidedef = seg->sidedef; + float polyw = glseg.fracright - glseg.fracleft; + float facu = (tcs[3].u - tcs[0].u) / polyw; + float facv = (tcs[3].v - tcs[0].v) / polyw; + float facb = (zbottom[1] - zbottom[0]) / polyw; + float facc = (zceil[1] - zceil[0]) / polyw; + float facf = (zfloor[1] - zfloor[0]) / polyw; + + for (int i = sidedef->numsegs-2; i >= 0; i--) + { + seg_t *cseg = sidedef->segs[i]; + float sidefrac = cseg->sidefrac; + if (sidefrac >= glseg.fracright) continue; + if (sidefrac <= glseg.fracleft) return; + + float fracfac = sidefrac - glseg.fracleft; + + if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - zbottom[0] + (facc - facb) * fracfac, + zbottom[0] - zfloor[0] + (facb - facf) * fracfac); + + gl.TexCoord2f(tcs[0].u + facu * fracfac, tcs[0].v + facv * fracfac); + gl.Vertex3f(cseg->v2->fx, zbottom[0] + facb * fracfac, cseg->v2->fy); + } + vertexcount += sidedef->numsegs-1; +} + +//========================================================================== +// +// Split left edge of wall +// +//========================================================================== + +void GLWall::SplitLeftEdge(texcoord * tcs, bool glow) +{ + if (vertexes[0]==NULL) return; + + vertex_t * vi=vertexes[0]; + + if (vi->numheights) + { + int i=0; + + float polyh1=ztop[0] - zbottom[0]; + float factv1=polyh1? (tcs[1].v - tcs[0].v) / polyh1:0; + float factu1=polyh1? (tcs[1].u - tcs[0].u) / polyh1:0; + + while (inumheights && vi->heightlist[i] <= zbottom[0] ) i++; + while (inumheights && vi->heightlist[i] < ztop[0]) + { + if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - vi->heightlist[i], vi->heightlist[i] - zfloor[0]); + gl.TexCoord2f(factu1*(vi->heightlist[i] - ztop[0]) + tcs[1].u, + factv1*(vi->heightlist[i] - ztop[0]) + tcs[1].v); + gl.Vertex3f(glseg.x1, vi->heightlist[i], glseg.y1); + i++; + } + vertexcount+=i; + } +} + +//========================================================================== +// +// Split right edge of wall +// +//========================================================================== + +void GLWall::SplitRightEdge(texcoord * tcs, bool glow) +{ + if (vertexes[1]==NULL) return; + + vertex_t * vi=vertexes[1]; + + if (vi->numheights) + { + int i=vi->numheights-1; + + float polyh2 = ztop[1] - zbottom[1]; + float factv2 = polyh2? (tcs[2].v - tcs[3].v) / polyh2:0; + float factu2 = polyh2? (tcs[2].u - tcs[3].u) / polyh2:0; + + while (i>0 && vi->heightlist[i] >= ztop[1]) i--; + while (i>0 && vi->heightlist[i] > zbottom[1]) + { + if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - vi->heightlist[i], vi->heightlist[i] - zfloor[1]); + gl.TexCoord2f(factu2 * (vi->heightlist[i] - ztop[1]) + tcs[2].u, + factv2 * (vi->heightlist[i] - ztop[1]) + tcs[2].v); + gl.Vertex3f(glseg.x2, vi->heightlist[i], glseg.y2); + i--; + } + vertexcount+=i; + } +} + diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h new file mode 100644 index 000000000..e44155aa6 --- /dev/null +++ b/src/gl/scene/gl_wall.h @@ -0,0 +1,365 @@ +#ifndef __GL_WALL_H +#define __GL_WALL_H +//========================================================================== +// +// One wall segment in the draw list +// +//========================================================================== +#include "r_defs.h" +#include "textures/textures.h" +#include "gl/renderer/gl_colormap.h" + +struct GLHorizonInfo; +struct F3DFloor; +struct model_t; +struct FSpriteModelFrame; +struct particle_t; +class ADynamicLight; +class FMaterial; +struct GLDrawList; +struct GLSkyInfo; +struct FTexCoordInfo; +struct FPortal; + + +enum WallTypes +{ + RENDERWALL_NONE, + RENDERWALL_TOP, + RENDERWALL_M1S, + RENDERWALL_M2S, + RENDERWALL_BOTTOM, + RENDERWALL_SKY, + RENDERWALL_FOGBOUNDARY, + RENDERWALL_HORIZON, + RENDERWALL_SKYBOX, + RENDERWALL_SECTORSTACK, + RENDERWALL_PLANEMIRROR, + RENDERWALL_MIRROR, + RENDERWALL_MIRRORSURFACE, + RENDERWALL_M2SNF, + RENDERWALL_M2SFOG, + RENDERWALL_COLOR, + RENDERWALL_FFBLOCK, + RENDERWALL_COLORLAYER, + // Insert new types at the end! +}; + +struct GLSeg +{ + float x1,x2; + float y1,y2; + float fracleft, fracright; // fractional offset of the 2 vertices on the linedef +}; + +struct texcoord +{ + float u,v; +}; + +//========================================================================== +// +// One sector plane, still in fixed point +// +//========================================================================== + +struct GLSectorPlane +{ + FTextureID texture; + secplane_t plane; + fixed_t texheight; + fixed_t xoffs, yoffs; + fixed_t xscale, yscale; + angle_t angle; + + void GetFromSector(sector_t * sec, int ceiling) + { + xoffs = sec->GetXOffset(ceiling); + yoffs = sec->GetYOffset(ceiling); + xscale = sec->GetXScale(ceiling); + yscale = sec->GetYScale(ceiling); + angle = sec->GetAngle(ceiling); + texture = sec->GetTexture(ceiling); + plane = sec->GetSecPlane(ceiling); + texheight = (ceiling == sector_t::ceiling)? plane.d : -plane.d; + } +}; + + + +class GLWall +{ +public: + + enum + { + //GLWF_CLAMPX=1, use GLT_* for these! + //GLWF_CLAMPY=2, + GLWF_SKYHACK=4, + GLWF_FOGGY=8, + GLWF_GLOW=16, // illuminated by glowing flats + GLWF_NOSHADER=32, // cannot be drawn with shaders. + GLWF_NOSPLITUPPER=64, + GLWF_NOSPLITLOWER=128, + }; + + friend struct GLDrawList; + friend class GLPortal; + + GLSeg glseg; + vertex_t * vertexes[2]; // required for polygon splitting + float ztop[2],zbottom[2]; + texcoord uplft, uprgt, lolft, lorgt; + float alpha; + FMaterial *gltexture; + + FColormap Colormap; + ERenderStyle RenderStyle; + + fixed_t viewdistance; + + BYTE lightlevel; + BYTE type; + BYTE flags; + short rellight; + + float topglowcolor[4]; + float bottomglowcolor[4]; + + int firstdynlight, lastdynlight; + int firstwall, numwalls; // splitting info. + + union + { + // it's either one of them but never more! + AActor * skybox; // for skyboxes + GLSkyInfo * sky; // for normal sky + GLHorizonInfo * horizon; // for horizon information + FPortal * portal; // stacked sector portals + secplane_t * planemirror; // for plane mirrors + }; + + + FTextureID topflat,bottomflat; + + // these are not the same as ytop and ybottom!!! + float zceil[2]; + float zfloor[2]; + +public: + seg_t * seg; // this gives the easiest access to all other structs involved + subsector_t * sub; // For polyobjects +private: + + void CheckGlowing(); + void PutWall(bool translucent); + void CheckTexturePosition(); + + void SetupLights(); + bool PrepareLight(texcoord * tcs, ADynamicLight * light); + void RenderWall(int textured, float * color2, ADynamicLight * light=NULL); + void RenderGlowingPoly(int textured, ADynamicLight * light=NULL); + int Intersection(FloatRect * rc,GLWall * result); + + void FloodPlane(int pass); + + void SkyPlane(sector_t *sector, int plane, bool allowmirror); + void SkyNormal(sector_t * fs,vertex_t * v1,vertex_t * v2); + void SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2); + void SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2); + + void Put3DWall(lightlist_t * lightlist, bool translucent); + void SplitWall(sector_t * frontsector, bool translucent); + void LightPass(); + void SetHorizon(vertex_t * ul, vertex_t * ur, vertex_t * ll, vertex_t * lr); + bool DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2); + + bool SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float ceilingrefheight, + int topleft,int topright, int bottomleft,int bottomright, int texoffset); + + void DoTexture(int type,seg_t * seg,int peg, + int ceilingrefheight,int floorrefheight, + int CeilingHeightstart,int CeilingHeightend, + int FloorHeightstart,int FloorHeightend, + int v_offset); + + void DoMidTexture(seg_t * seg, bool drawfogboundary, + sector_t * front, sector_t * back, + sector_t * realfront, sector_t * realback, + fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, + fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2); + + void GetPlanePos(F3DFloor::planeref *planeref, int &left, int &right); + + void BuildFFBlock(seg_t * seg, F3DFloor * rover, + fixed_t ff_topleft, fixed_t ff_topright, + fixed_t ff_bottomleft, fixed_t ff_bottomright); + void InverseFloors(seg_t * seg, sector_t * frontsector, + fixed_t topleft, fixed_t topright, + fixed_t bottomleft, fixed_t bottomright); + void ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector, + fixed_t topleft, fixed_t topright, + fixed_t bottomleft, fixed_t bottomright); + void DoFFloorBlocks(seg_t * seg, sector_t * frontsector, sector_t * backsector, + fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, + fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2); + + void DrawDecal(DBaseDecal *actor); + void DoDrawDecals(); + + void RenderFogBoundary(); + void RenderMirrorSurface(); + void RenderTranslucentWall(); + + void SplitLeftEdge(texcoord * tcs, bool glow); + void SplitRightEdge(texcoord * tcs, bool glow); + void SplitUpperEdge(texcoord * tcs, bool glow); + void SplitLowerEdge(texcoord * tcs, bool glow); + +public: + + void Process(seg_t *seg, sector_t *frontsector, sector_t *backsector); + void ProcessLowerMiniseg(seg_t *seg, sector_t *frontsector, sector_t *backsector); + void Draw(int pass); + + float PointOnSide(float x,float y) + { + return -((y-glseg.y1)*(glseg.x2-glseg.x1)-(x-glseg.x1)*(glseg.y2-glseg.y1)); + } + + // Lines start-end and fdiv must intersect. + double CalcIntersectionVertex(GLWall * w2) + { + float ax = glseg.x1, ay=glseg.y1; + float bx = glseg.x2, by=glseg.y2; + float cx = w2->glseg.x1, cy=w2->glseg.y1; + float dx = w2->glseg.x2, dy=w2->glseg.y2; + return ((ay-cy)*(dx-cx)-(ax-cx)*(dy-cy)) / ((bx-ax)*(dy-cy)-(by-ay)*(dx-cx)); + } + +}; + +//========================================================================== +// +// One flat plane in the draw list +// +//========================================================================== + +class GLFlat +{ +public: + friend struct GLDrawList; + + sector_t * sector; + subsector_t * sub; // only used for translucent planes + float dz; // z offset for rendering hacks + float z; // the z position of the flat (only valid for non-sloped planes) + FMaterial *gltexture; + + FColormap Colormap; // light and fog + ERenderStyle renderstyle; + + float alpha; + GLSectorPlane plane; + int lightlevel; + bool stack; + bool foggy; + bool ceiling; + BYTE renderflags; + int vboindex; + int vboheight; + + int dynlightindex; + + bool SetupSubsectorLights(bool lightsapplied, subsector_t * sub); + void DrawSubsector(subsector_t * sub); + void DrawSubsectorLights(subsector_t * sub, int pass); + void DrawSubsectors(int pass, bool istrans); + + void PutFlat(bool fog = false); + void Process(sector_t * model, int whichplane, bool notexture); + void SetFrom3DFloor(F3DFloor *rover, bool top, bool underside); + void ProcessSector(sector_t * frontsector); + void Draw(int pass); +}; + + +//========================================================================== +// +// One sprite in the draw list +// +//========================================================================== + + +class GLSprite +{ +public: + friend struct GLDrawList; + friend void Mod_RenderModel(GLSprite * spr, model_t * mdl, int framenumber); + + BYTE lightlevel; + BYTE foglevel; + BYTE hw_styleflags; + bool fullbright; + PalEntry ThingColor; // thing's own color + FColormap Colormap; + FSpriteModelFrame * modelframe; + FRenderStyle RenderStyle; + int OverrideShader; + + int translation; + int index; + int depth; + + float x,y,z; // needed for sorting! + + float ul,ur; + float vt,vb; + float x1,y1,z1; + float x2,y2,z2; + + FMaterial *gltexture; + float trans; + AActor * actor; + particle_t * particle; + + void SplitSprite(sector_t * frontsector, bool translucent); + void SetLowerParam(); + +public: + + void Draw(int pass); + void PutSprite(bool translucent); + void Process(AActor* thing,sector_t * sector); + void ProcessParticle (particle_t *particle, sector_t *sector);//, int shade, int fakeside) + void SetThingColor(PalEntry); + void SetSpriteColor(sector_t *sector, fixed_t y); + + // Lines start-end and fdiv must intersect. + double CalcIntersectionVertex(GLWall * w2); +}; + +inline float Dist2(float x1,float y1,float x2,float y2) +{ + return sqrtf((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); +} + +// Light + color + +bool gl_GetSpriteLight(AActor *Self, fixed_t x, fixed_t y, fixed_t z, subsector_t * subsec, int desaturation, float * out, line_t *line = NULL, int side = 0); +int gl_SetSpriteLight(AActor * thing, int lightlevel, int rellight, FColormap * cm, float alpha, PalEntry ThingColor = 0xffffff, bool weapon=false); + +void gl_GetSpriteLight(AActor * thing, int lightlevel, int rellight, FColormap * cm, + float *red, float *green, float *blue, + PalEntry ThingColor, bool weapon); + +int gl_SetSpriteLighting(FRenderStyle style, AActor *thing, int lightlevel, int rellight, FColormap *cm, + PalEntry ThingColor, float alpha, bool fullbright, bool weapon); + +int gl_SetSpriteLight(particle_t * thing, int lightlevel, int rellight, FColormap *cm, float alpha, PalEntry ThingColor = 0xffffff); +void gl_GetLightForThing(AActor * thing, float upper, float lower, float & r, float & g, float & b); + + + + +#endif diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp new file mode 100644 index 000000000..40c18baa9 --- /dev/null +++ b/src/gl/scene/gl_walls.cpp @@ -0,0 +1,1793 @@ +/* +** gl_wall.cpp +** Wall rendering preparation +** +**--------------------------------------------------------------------------- +** Copyright 2000-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "p_local.h" +#include "p_lnspec.h" +#include "a_sharedglobal.h" +#include "g_level.h" +#include "templates.h" +#include "vectors.h" +#include "r_defs.h" +#include "r_sky.h" + +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/dynlights/gl_lightbuffer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_geometric.h" +#include "gl/utility/gl_templates.h" +#include "gl/shaders/gl_shader.h" + + +//========================================================================== +// +// Checks whether a wall should glow +// +//========================================================================== +void GLWall::CheckGlowing() +{ + bottomglowcolor[3] = topglowcolor[3] = 0; + if (!gl_isFullbright(Colormap.LightColor, lightlevel) && gl_GlowActive()) + { + FTexture *tex = TexMan[topflat]; + if (tex != NULL && tex->isGlowing()) + { + flags |= GLWall::GLWF_GLOW; + tex->GetGlowColor(topglowcolor); + topglowcolor[3] = tex->gl_info.GlowHeight; + } + + tex = TexMan[bottomflat]; + if (tex != NULL && tex->isGlowing()) + { + flags |= GLWall::GLWF_GLOW; + tex->GetGlowColor(bottomglowcolor); + bottomglowcolor[3] = tex->gl_info.GlowHeight; + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::PutWall(bool translucent) +{ + GLPortal * portal; + int list; + + static char passflag[]={ + 0, //RENDERWALL_NONE, + 1, //RENDERWALL_TOP, // unmasked + 1, //RENDERWALL_M1S, // unmasked + 2, //RENDERWALL_M2S, // depends on render and texture settings + 1, //RENDERWALL_BOTTOM, // unmasked + 4, //RENDERWALL_SKYDOME, // special + 3, //RENDERWALL_FOGBOUNDARY, // translucent + 4, //RENDERWALL_HORIZON, // special + 4, //RENDERWALL_SKYBOX, // special + 4, //RENDERWALL_SECTORSTACK, // special + 4, //RENDERWALL_PLANEMIRROR, // special + 4, //RENDERWALL_MIRROR, // special + 1, //RENDERWALL_MIRRORSURFACE, // needs special handling + 2, //RENDERWALL_M2SNF, // depends on render and texture settings, no fog + 2, //RENDERWALL_M2SFOG, // depends on render and texture settings, no fog + 3, //RENDERWALL_COLOR, // translucent + 2, //RENDERWALL_FFBLOCK // depends on render and texture settings + 4, //RENDERWALL_COLORLAYER // color layer needs special handling + }; + + if (gltexture && gltexture->GetTransparent() && passflag[type] == 2) + { + translucent = true; + } + + if (gl_fixedcolormap) + { + // light planes don't get drawn with fullbright rendering + if (!gltexture && passflag[type]!=4) return; + + Colormap.GetFixedColormap(); + } + + CheckGlowing(); + + if (translucent) // translucent walls + { + viewdistance = P_AproxDistance( ((seg->linedef->v1->x+seg->linedef->v2->x)>>1) - viewx, + ((seg->linedef->v1->y+seg->linedef->v2->y)>>1) - viewy); + gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this); + } + else if (passflag[type]!=4) // non-translucent walls + { + static DrawListType list_indices[2][2][2]={ + { { GLDL_PLAIN, GLDL_FOG }, { GLDL_MASKED, GLDL_FOGMASKED } }, + { { GLDL_LIGHT, GLDL_LIGHTFOG }, { GLDL_LIGHTMASKED, GLDL_LIGHTFOGMASKED } } + }; + + bool masked; + bool light = gl_forcemultipass; + + if (!gl_fixedcolormap) + { + if (gl_lights && !gl_dynlight_shader) + { + if (seg->sidedef == NULL) + { + light = false; + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + light = seg->sidedef->lighthead[0] != NULL; + } + else if (sub) + { + // for polyobjects we cannot use the side's light list. + // We must use the subsector's. + light = sub->lighthead[0] != NULL; + } + } + } + else + { + flags&=~GLWF_FOGGY; + } + + masked = passflag[type]==1? false : (light && type!=RENDERWALL_FFBLOCK) || (gltexture && gltexture->isMasked()); + + list = list_indices[light][masked][!!(flags&GLWF_FOGGY)]; + if (list == GLDL_LIGHT) + { + if (gltexture->tex->gl_info.Brightmap && gl_BrightmapsActive()) list = GLDL_LIGHTBRIGHT; + if (flags & GLWF_GLOW) list = GLDL_LIGHTBRIGHT; + } + gl_drawinfo->drawlists[list].AddWall(this); + + } + else switch (type) + { + case RENDERWALL_COLORLAYER: + gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this); + break; + + // portals don't go into the draw list. + // Instead they are added to the portal manager + case RENDERWALL_HORIZON: + //@sync-portal + horizon=UniqueHorizons.Get(horizon); + portal=GLPortal::FindPortal(horizon); + if (!portal) portal=new GLHorizonPortal(horizon); + portal->AddLine(this); + break; + + case RENDERWALL_SKYBOX: + //@sync-portal + portal=GLPortal::FindPortal(skybox); + if (!portal) portal=new GLSkyboxPortal(skybox); + portal->AddLine(this); + break; + + case RENDERWALL_SECTORSTACK: + //@sync-portal + portal = this->portal->GetGLPortal(); + portal->AddLine(this); + break; + + case RENDERWALL_PLANEMIRROR: + if (GLPortal::PlaneMirrorMode * planemirror->c <=0) + { + //@sync-portal + planemirror=UniquePlaneMirrors.Get(planemirror); + portal=GLPortal::FindPortal(planemirror); + if (!portal) portal=new GLPlaneMirrorPortal(planemirror); + portal->AddLine(this); + } + break; + + case RENDERWALL_MIRROR: + //@sync-portal + portal=GLPortal::FindPortal(seg->linedef); + if (!portal) portal=new GLMirrorPortal(seg->linedef); + portal->AddLine(this); + if (gl_mirror_envmap) + { + // draw a reflective layer over the mirror + type=RENDERWALL_MIRRORSURFACE; + gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].AddWall(this); + } + break; + + case RENDERWALL_SKY: + //@sync-portal + portal=GLPortal::FindPortal(sky); + if (!portal) portal=new GLSkyPortal(sky); + portal->AddLine(this); + break; + } +} + +//========================================================================== +// +// Sets 3D-floor lighting info +// +//========================================================================== + +void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent) +{ + bool fadewall = (!translucent && lightlist->caster && (lightlist->caster->flags&FF_FADEWALLS) && + !gl_isBlack((lightlist->extra_colormap)->Fade)) && gl_isBlack(Colormap.FadeColor); + + // only modify the light level if it doesn't originate from the seg's frontsector. This is to account for light transferring effects + if (lightlist->p_lightlevel != &seg->sidedef->sector->lightlevel) + { + lightlevel = gl_ClampLight(*lightlist->p_lightlevel); + } + // relative light won't get changed here. It is constant across the entire wall. + + Colormap.CopyLightColor(lightlist->extra_colormap); + if (fadewall) lightlevel=255; + PutWall(translucent); + + if (fadewall) + { + FMaterial *tex = gltexture; + type = RENDERWALL_COLORLAYER; + gltexture = NULL; + Colormap.LightColor = (lightlist->extra_colormap)->Fade; + alpha = (255-(*lightlist->p_lightlevel))/255.f*1.f; + if (alpha>0.f) PutWall(true); + + type = RENDERWALL_FFBLOCK; + alpha = 1.0; + gltexture = tex; + } +} + +//========================================================================== +// +// Splits a wall vertically if a 3D-floor +// creates different lighting across the wall +// +//========================================================================== + +void GLWall::SplitWall(sector_t * frontsector, bool translucent) +{ + GLWall copyWall1,copyWall2; + float maplightbottomleft; + float maplightbottomright; + unsigned int i; + int origlight = lightlevel; + TArray & lightlist=frontsector->e->XFloor.lightlist; + + if (glseg.x1==glseg.x2 && glseg.y1==glseg.y2) + { + return; + } + ::SplitWall.Clock(); + +#ifdef _MSC_VER +#ifdef _DEBUG + if (seg->linedef-lines==1) + __asm nop +#endif +#endif + + if (lightlist.Size()>1) + { + for(i=0;i=ztop[0] && maplightbottomright>=ztop[1]) + { + continue; + } + + // check for an intersection with the upper plane + if ((maplightbottomleftztop[1]) || + (maplightbottomleft>ztop[0] && maplightbottomright(fabsf(glseg.x2-glseg.x1), fabsf(glseg.y2-glseg.y2)); + + float dch=ztop[1]-ztop[0]; + float dfh=maplightbottomright-maplightbottomleft; + float coeff= (ztop[0]-maplightbottomleft)/(dfh-dch); + + // check for inaccuracies - let's be a little generous here! + if (coeff*clen<.1f) + { + maplightbottomleft=ztop[0]; + } + else if (coeff*clen>clen-.1f) + { + maplightbottomright=ztop[1]; + } + else + { + // split the wall in 2 at the intersection and recursively split both halves + copyWall1=copyWall2=*this; + + copyWall1.glseg.x2 = copyWall2.glseg.x1 = glseg.x1 + coeff * (glseg.x2-glseg.x1); + copyWall1.glseg.y2 = copyWall2.glseg.y1 = glseg.y1 + coeff * (glseg.y2-glseg.y1); + copyWall1.ztop[1] = copyWall2.ztop[0] = ztop[0] + coeff * (ztop[1]-ztop[0]); + copyWall1.zbottom[1] = copyWall2.zbottom[0] = zbottom[0] + coeff * (zbottom[1]-zbottom[0]); + copyWall1.glseg.fracright = copyWall2.glseg.fracleft = glseg.fracleft + coeff * (glseg.fracright-glseg.fracleft); + copyWall1.uprgt.u = copyWall2.uplft.u = uplft.u + coeff * (uprgt.u-uplft.u); + copyWall1.uprgt.v = copyWall2.uplft.v = uplft.v + coeff * (uprgt.v-uplft.v); + copyWall1.lorgt.u = copyWall2.lolft.u = lolft.u + coeff * (lorgt.u-lolft.u); + copyWall1.lorgt.v = copyWall2.lolft.v = lolft.v + coeff * (lorgt.v-lolft.v); + + ::SplitWall.Unclock(); + + copyWall1.SplitWall(frontsector, translucent); + copyWall2.SplitWall(frontsector, translucent); + return; + } + } + + // check for an intersection with the lower plane + if ((maplightbottomleftzbottom[1]) || + (maplightbottomleft>zbottom[0] && maplightbottomright(fabsf(glseg.x2-glseg.x1), fabsf(glseg.y2-glseg.y2)); + + float dch=zbottom[1]-zbottom[0]; + float dfh=maplightbottomright-maplightbottomleft; + float coeff= (zbottom[0]-maplightbottomleft)/(dfh-dch); + + // check for inaccuracies - let's be a little generous here because there's + // some conversions between floats and fixed_t's involved + if (coeff*clen<.1f) + { + maplightbottomleft=zbottom[0]; + } + else if (coeff*clen>clen-.1f) + { + maplightbottomright=zbottom[1]; + } + else + { + // split the wall in 2 at the intersection and recursively split both halves + copyWall1=copyWall2=*this; + + copyWall1.glseg.x2 = copyWall2.glseg.x1 = glseg.x1 + coeff * (glseg.x2-glseg.x1); + copyWall1.glseg.y2 = copyWall2.glseg.y1 = glseg.y1 + coeff * (glseg.y2-glseg.y1); + copyWall1.ztop[1] = copyWall2.ztop[0] = ztop[0] + coeff * (ztop[1]-ztop[0]); + copyWall1.zbottom[1] = copyWall2.zbottom[0] = zbottom[0] + coeff * (zbottom[1]-zbottom[0]); + copyWall1.glseg.fracright = copyWall2.glseg.fracleft = glseg.fracleft + coeff * (glseg.fracright-glseg.fracleft); + copyWall1.uprgt.u = copyWall2.uplft.u = uplft.u + coeff * (uprgt.u-uplft.u); + copyWall1.uprgt.v = copyWall2.uplft.v = uplft.v + coeff * (uprgt.v-uplft.v); + copyWall1.lorgt.u = copyWall2.lolft.u = lolft.u + coeff * (lorgt.u-lolft.u); + copyWall1.lorgt.v = copyWall2.lolft.v = lolft.v + coeff * (lorgt.v-lolft.v); + + ::SplitWall.Unclock(); + + copyWall1.SplitWall(frontsector, translucent); + copyWall2.SplitWall(frontsector, translucent); + return; + } + } + + // 3D floor is completely within this light + if (maplightbottomleft<=zbottom[0] && maplightbottomright<=zbottom[1]) + { + // These values must not be destroyed! + int ll=lightlevel; + FColormap lc=Colormap; + + if (i > 0) Put3DWall(&lightlist[i], translucent); + else PutWall(translucent); // uppermost section does not alter light at all. + + lightlevel=ll; + Colormap=lc; + + ::SplitWall.Unclock(); + + return; + } + + if (maplightbottomleft<=ztop[0] && maplightbottomright<=ztop[1] && + (maplightbottomleft!=ztop[0] || maplightbottomright!=ztop[1])) + { + copyWall1=*this; + + copyWall1.flags |= GLWF_NOSPLITLOWER; + flags |= GLWF_NOSPLITUPPER; + ztop[0]=copyWall1.zbottom[0]=maplightbottomleft; + ztop[1]=copyWall1.zbottom[1]=maplightbottomright; + uplft.v=copyWall1.lolft.v=copyWall1.uplft.v+ + (maplightbottomleft-copyWall1.ztop[0])*(copyWall1.lolft.v-copyWall1.uplft.v)/(zbottom[0]-copyWall1.ztop[0]); + uprgt.v=copyWall1.lorgt.v=copyWall1.uprgt.v+ + (maplightbottomright-copyWall1.ztop[1])*(copyWall1.lorgt.v-copyWall1.uprgt.v)/(zbottom[1]-copyWall1.ztop[1]); + copyWall1.Put3DWall(&lightlist[i], translucent); + } + if (ztop[0]==zbottom[0] && ztop[1]==zbottom[1]) + { + ::SplitWall.Unclock(); + return; + } + } + } + + // These values must not be destroyed! + int ll=lightlevel; + FColormap lc=Colormap; + + Put3DWall(&lightlist[lightlist.Size()-1], translucent); + + lightlevel=ll; + Colormap=lc; + flags &= ~GLWF_NOSPLITUPPER; + ::SplitWall.Unclock(); +} + + +//========================================================================== +// +// +// +//========================================================================== +bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) +{ + GLHorizonInfo hi; + lightlist_t * light; + + // ZDoom doesn't support slopes in a horizon sector so I won't either! + ztop[1] = ztop[0] = FIXED2FLOAT(fs->GetPlaneTexZ(sector_t::ceiling)); + zbottom[1] = zbottom[0] = FIXED2FLOAT(fs->GetPlaneTexZ(sector_t::floor)); + + if (viewz < fs->GetPlaneTexZ(sector_t::ceiling)) + { + if (viewz > fs->GetPlaneTexZ(sector_t::floor)) + zbottom[1] = zbottom[0] = FIXED2FLOAT(viewz); + + if (fs->GetTexture(sector_t::ceiling) == skyflatnum) + { + SkyPlane(fs, sector_t::ceiling, false); + } + else + { + type = RENDERWALL_HORIZON; + hi.plane.GetFromSector(fs, true); + hi.lightlevel = gl_ClampLight(fs->GetCeilingLight()); + hi.colormap = fs->ColorMap; + + if (fs->e->XFloor.ffloors.Size()) + { + light = P_GetPlaneLight(fs, &fs->ceilingplane, true); + + if(!(fs->GetFlags(sector_t::ceiling)&PLANEF_ABSLIGHTING)) hi.lightlevel = gl_ClampLight(*light->p_lightlevel); + hi.colormap.LightColor = (light->extra_colormap)->Color; + } + + if (gl_fixedcolormap) hi.colormap.GetFixedColormap(); + horizon = &hi; + PutWall(0); + } + ztop[1] = ztop[0] = zbottom[0]; + } + + if (viewz > fs->GetPlaneTexZ(sector_t::floor)) + { + zbottom[1] = zbottom[0] = FIXED2FLOAT(fs->GetPlaneTexZ(sector_t::floor)); + if (fs->GetTexture(sector_t::floor) == skyflatnum) + { + SkyPlane(fs, sector_t::floor, false); + } + else + { + type = RENDERWALL_HORIZON; + hi.plane.GetFromSector(fs, false); + hi.lightlevel = gl_ClampLight(fs->GetFloorLight()); + hi.colormap = fs->ColorMap; + + if (fs->e->XFloor.ffloors.Size()) + { + light = P_GetPlaneLight(fs, &fs->floorplane, false); + + if(!(fs->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING)) hi.lightlevel = gl_ClampLight(*light->p_lightlevel); + hi.colormap.LightColor = (light->extra_colormap)->Color; + } + + if (gl_fixedcolormap) hi.colormap.GetFixedColormap(); + horizon=&hi; + PutWall(0); + } + } + return true; +} + +//========================================================================== +// +// +// +//========================================================================== +bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float texturetop, + int topleft,int topright, int bottomleft,int bottomright, int t_ofs) +{ + // + // + // set up texture coordinate stuff + // + // + float l_ul; + float texlength; + + if (gltexture) + { + float length = seg->sidedef? seg->sidedef->TexelLength: Dist2(glseg.x1, glseg.y1, glseg.x2, glseg.y2); + + l_ul=tci->FloatToTexU(FIXED2FLOAT(tci->TextureOffset(t_ofs))); + texlength = tci->FloatToTexU(length); + } + else + { + tci=NULL; + l_ul=0; + texlength=0; + } + + + // + // + // set up coordinates for the left side of the polygon + // + // check left side for intersections + if (topleft>=bottomleft) + { + // normal case + ztop[0]=FIXED2FLOAT(topleft); + zbottom[0]=FIXED2FLOAT(bottomleft); + + if (tci) + { + uplft.v=tci->FloatToTexV(-ztop[0] + texturetop); + lolft.v=tci->FloatToTexV(-zbottom[0] + texturetop); + } + } + else + { + // ceiling below floor - clip to the visible part of the wall + fixed_t dch=topright-topleft; + fixed_t dfh=bottomright-bottomleft; + fixed_t coeff=FixedDiv(bottomleft-topleft, dch-dfh); + + fixed_t inter_y=topleft+FixedMul(coeff,dch); + + float inter_x= FIXED2FLOAT(coeff); + + glseg.x1 = glseg.x1 + inter_x * (glseg.x2 - glseg.x1); + glseg.y1 = glseg.y1 + inter_x * (glseg.y2 - glseg.y1); + glseg.fracleft = inter_x; + + zbottom[0]=ztop[0]=FIXED2FLOAT(inter_y); + + if (tci) + { + lolft.v=uplft.v=tci->FloatToTexV(-ztop[0] + texturetop); + } + } + + // + // + // set up coordinates for the right side of the polygon + // + // check left side for intersections + if (topright >= bottomright) + { + // normal case + ztop[1]=FIXED2FLOAT(topright) ; + zbottom[1]=FIXED2FLOAT(bottomright) ; + + if (tci) + { + uprgt.v=tci->FloatToTexV(-ztop[1] + texturetop); + lorgt.v=tci->FloatToTexV(-zbottom[1] + texturetop); + } + } + else + { + // ceiling below floor - clip to the visible part of the wall + fixed_t dch=topright-topleft; + fixed_t dfh=bottomright-bottomleft; + fixed_t coeff=FixedDiv(bottomleft-topleft, dch-dfh); + + fixed_t inter_y=topleft+FixedMul(coeff,dch); + + float inter_x= FIXED2FLOAT(coeff); + + glseg.x2 = glseg.x1 + inter_x * (glseg.x2 - glseg.x1); + glseg.y2 = glseg.y1 + inter_x * (glseg.y2 - glseg.y1); + glseg.fracright = inter_x; + + zbottom[1]=ztop[1]=FIXED2FLOAT(inter_y); + if (tci) + { + lorgt.v=uprgt.v=tci->FloatToTexV(-ztop[1] + texturetop); + } + } + + uplft.u = lolft.u = l_ul + texlength * glseg.fracleft; + uprgt.u = lorgt.u = l_ul + texlength * glseg.fracright; + + + if (gltexture && gltexture->tex->bHasCanvas && flags&GLT_CLAMPY) + { + // Camera textures are upside down so we have to shift the y-coordinate + // from [-1..0] to [0..1] when using texture clamping + + uplft.v+=1.f; + uprgt.v+=1.f; + lolft.v+=1.f; + lorgt.v+=1.f; + } + return true; +} + +//========================================================================== +// +// Do some tweaks with the texture coordinates to reduce visual glitches +// +//========================================================================== + +void GLWall::CheckTexturePosition() +{ + float sub; + + if (gltexture->tex->bHasCanvas) return; + + // clamp texture coordinates to a reasonable range. + // Extremely large values can cause visual problems + if (uplft.v < uprgt.v) + { + sub = float(xs_FloorToInt(uplft.v)); + } + else + { + sub = float(xs_FloorToInt(uprgt.v)); + } + uplft.v -= sub; + uprgt.v -= sub; + lolft.v -= sub; + lorgt.v -= sub; + + if ((uplft.v == 0.f && uprgt.v == 0.f && lolft.v <= 1.f && lorgt.v <= 1.f) || + (uplft.v >= 0.f && uprgt.v >= 0.f && lolft.v == 1.f && lorgt.v == 1.f)) + { + flags|=GLT_CLAMPY; + } +} + +//========================================================================== +// +// Handle one sided walls, upper and lower texture +// +//========================================================================== +void GLWall::DoTexture(int _type,seg_t * seg, int peg, + int ceilingrefheight,int floorrefheight, + int topleft,int topright, + int bottomleft,int bottomright, + int v_offset) +{ + if (topleft<=bottomleft && topright<=bottomright) return; + + // The Vertex values can be destroyed in this function and must be restored aferward! + GLSeg glsave=glseg; + int lh=ceilingrefheight-floorrefheight; + int texpos; + + switch (_type) + { + case RENDERWALL_TOP: + texpos = side_t::top; + break; + case RENDERWALL_BOTTOM: + texpos = side_t::bottom; + break; + default: + texpos = side_t::mid; + break; + } + + FTexCoordInfo tci; + + gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(texpos), seg->sidedef->GetTextureYScale(texpos)); + + type = (seg->linedef->special == Line_Mirror && _type == RENDERWALL_M1S && gl_mirrors) ? RENDERWALL_MIRROR : _type; + + float floatceilingref = FIXED2FLOAT(ceilingrefheight) + + FIXED2FLOAT(tci.RowOffset(seg->sidedef->GetTextureYOffset(texpos))) + + FIXED2FLOAT((peg ? (gltexture->TextureHeight(GLUSE_TEXTURE)<sidedef->GetTextureXOffset(texpos))) return; + + CheckTexturePosition(); + + // Add this wall to the render list + sector_t * sec = sub? sub->sector : seg->frontsector; + + if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(false); + else SplitWall(sec, false); + + glseg=glsave; + flags&=~GLT_CLAMPY; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, + sector_t * front, sector_t * back, + sector_t * realfront, sector_t * realback, + fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, + fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2) + +{ + FTexCoordInfo tci; + fixed_t topleft,bottomleft,topright,bottomright; + GLSeg glsave=glseg; + fixed_t texturetop, texturebottom; + bool wrap = (seg->linedef->flags&ML_WRAP_MIDTEX) || (seg->sidedef->Flags&WALLF_WRAP_MIDTEX); + + // + // + // Get the base coordinates for the texture + // + // + if (gltexture) + { + // Align the texture to the ORIGINAL sector's height!! + // At this point slopes don't matter because they don't affect the texture's z-position + + gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::mid), seg->sidedef->GetTextureYScale(side_t::mid)); + fixed_t rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); + if ( (seg->linedef->flags & ML_DONTPEGBOTTOM) >0) + { + texturebottom = MAX(realfront->GetPlaneTexZ(sector_t::floor),realback->GetPlaneTexZ(sector_t::floor))+rowoffset; + texturetop=texturebottom+(gltexture->TextureHeight(GLUSE_TEXTURE)<GetPlaneTexZ(sector_t::ceiling),realback->GetPlaneTexZ(sector_t::ceiling))+rowoffset; + texturebottom=texturetop-(gltexture->TextureHeight(GLUSE_TEXTURE)<GetHeightSec()) + { + // + // + // Set up the top + // + // + FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::top)); + if (!tex || tex->UseType==FTexture::TEX_Null) + { + if (front->GetTexture(sector_t::ceiling) == skyflatnum && + back->GetTexture(sector_t::ceiling) == skyflatnum) + { + // intra-sky lines do not clip the texture at all if there's no upper texture + topleft = topright = texturetop; + } + else + { + // texture is missing - use the higher plane + topleft = MAX(bch1,fch1); + topright = MAX(bch2,fch2); + } + } + else if ((bch1>fch1 || bch2>fch2) && + (seg->frontsector->GetTexture(sector_t::ceiling)!=skyflatnum || seg->backsector->GetTexture(sector_t::ceiling)==skyflatnum)) + // (!((bch1<=fch1 && bch2<=fch2) || (bch1>=fch1 && bch2>=fch2))) + { + // Use the higher plane and let the geometry clip the extruding part + topleft = bch1; + topright = bch2; + } + else + { + // But not if there can be visual artifacts. + topleft = MIN(bch1,fch1); + topright = MIN(bch2,fch2); + } + + // + // + // Set up the bottom + // + // + tex = TexMan(seg->sidedef->GetTexture(side_t::bottom)); + if (!tex || tex->UseType==FTexture::TEX_Null) + { + // texture is missing - use the lower plane + bottomleft = MIN(bfh1,ffh1); + bottomright = MIN(bfh2,ffh2); + } + else if (bfh1=ffh1 && bfh2>=ffh2))) + { + // the floor planes intersect. Use the backsector's floor for drawing so that + // drawing the front sector's plane clips the polygon automatically. + bottomleft = bfh1; + bottomright = bfh2; + } + else + { + // normal case - use the higher plane + bottomleft = MAX(bfh1,ffh1); + bottomright = MAX(bfh2,ffh2); + } + + // + // + // if we don't need a fog sheet let's clip away some unnecessary parts of the polygon + // + // + if (!drawfogboundary && !wrap) + { + if (texturetopbottomleft && texturebottom>bottomright) bottomleft=bottomright=texturebottom; + } + } + else + { + // + // + // if both sides of the line are in the same sector and the sector + // doesn't have a Transfer_Heights special don't clip to the planes + // Clipping to the planes is not necessary and can even produce + // unwanted side effects. + // + // + topleft=topright=texturetop; + bottomleft=bottomright=texturebottom; + } + + // nothing visible - skip the rest + if (topleft<=bottomleft && topright<=bottomright) return; + + + // + // + // set up texture coordinate stuff + // + // + fixed_t t_ofs = seg->sidedef->GetTextureXOffset(side_t::mid); + + if (gltexture) + { + // First adjust the texture offset so that the left edge of the linedef is inside the range [0..1]. + fixed_t texwidth = tci.TextureAdjustWidth()<>FRACBITS)+seg->sidedef->TexelLength; + + if ((textureoffset==0 && righttex<=gltexture->TextureWidth(GLUSE_TEXTURE)) || + (textureoffset>=0 && righttex==gltexture->TextureWidth(GLUSE_TEXTURE))) + { + flags|=GLT_CLAMPX; + } + else + { + flags&=~GLT_CLAMPX; + } + if (!wrap) + { + flags|=GLT_CLAMPY; + } + } + SetWallCoordinates(seg, &tci, FIXED2FLOAT(texturetop), topleft, topright, bottomleft, bottomright, t_ofs); + + // + // + // draw fog sheet if required + // + // + if (drawfogboundary) + { + flags |= GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER; + type=RENDERWALL_FOGBOUNDARY; + PutWall(true); + if (!gltexture) + { + flags &= ~(GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER); + return; + } + type=RENDERWALL_M2SNF; + } + else type=RENDERWALL_M2S; + + // + // + // set up alpha blending + // + // + if (seg->linedef->Alpha)// && seg->linedef->special!=Line_Fogsheet) + { + bool translucent = false; + + switch (seg->linedef->flags& ML_ADDTRANS)//TRANSBITS) + { + case 0: + RenderStyle=STYLE_Translucent; + alpha=FIXED2FLOAT(seg->linedef->Alpha); + translucent = seg->linedef->Alpha < FRACUNIT || (gltexture && gltexture->GetTransparent()); + break; + + case ML_ADDTRANS: + RenderStyle=STYLE_Add; + alpha=FIXED2FLOAT(seg->linedef->Alpha); + translucent=true; + break; + } + + // + // + // for textures with large empty areas only the visible parts are drawn. + // If these textures come too close to the camera they severely affect performance + // if stacked closely together + // Recognizing vertical gaps is rather simple and well worth the effort. + // + // + FloatRect *splitrect; + int v = gltexture->GetAreas(&splitrect); + if (v>0 && !drawfogboundary && !(seg->linedef->flags&ML_WRAP_MIDTEX)) + { + // split the poly! + GLWall split; + int i,t=0; + float v_factor=(zbottom[0]-ztop[0])/(lolft.v-uplft.v); + // only split the vertical area of the polygon that does not contain slopes. + float splittopv = MAX(uplft.v, uprgt.v); + float splitbotv = MIN(lolft.v, lorgt.v); + + // this is split vertically into sections. + for(i=0;i=splitbotv) break; + + float splitbot=splitrect[i].top+splitrect[i].height; + + // the current segment is above the top line of the splittable area + if (splitbot<=splittopv) continue; + + split=*this; + + // the top line of the current segment is inside the splittable area + // use the splitrect's top as top of this segment + // if not use the top of the remaining polygon + if (splitrect[i].top>splittopv) + { + split.ztop[0]=split.ztop[1]= ztop[0]+v_factor*(splitrect[i].top-uplft.v); + split.uplft.v=split.uprgt.v=splitrect[i].top; + } + // the bottom line of the current segment is inside the splittable area + // use the splitrect's bottom as bottom of this segment + // if not use the bottom of the remaining polygon + if (splitbot<=splitbotv) + { + split.zbottom[0]=split.zbottom[1]=ztop[0]+v_factor*(splitbot-uplft.v); + split.lolft.v=split.lorgt.v=splitbot; + } + // + // + // Draw the stuff + // + // + if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) split.PutWall(translucent); + else split.SplitWall(realfront, translucent); + + t=1; + } + render_texsplit+=t; + } + else + { + // + // + // Draw the stuff without splitting + // + // + if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(translucent); + else SplitWall(realfront, translucent); + } + alpha=1.0f; + } + // restore some values that have been altered in this function + glseg=glsave; + flags&=~(GLT_CLAMPX|GLT_CLAMPY|GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER); +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, + fixed_t ff_topleft, fixed_t ff_topright, + fixed_t ff_bottomleft, fixed_t ff_bottomright) +{ + side_t * mastersd = rover->master->sidedef[0]; + float to; + lightlist_t * light; + bool translucent; + byte savelight=lightlevel; + FColormap savecolor=Colormap; + float ul; + float texlength; + FTexCoordInfo tci; + + if (rover->flags&FF_FOG) + { + if (!gl_fixedcolormap) + { + // this may not yet be done! + light=P_GetPlaneLight(rover->target, rover->top.plane,true); + Colormap.Clear(); + Colormap.LightColor=(light->extra_colormap)->Fade; + // the fog plane defines the light level, not the front sector! + lightlevel=*light->p_lightlevel; + gltexture=NULL; + type=RENDERWALL_FFBLOCK; + } + else return; + } + else + { + + if (rover->flags&FF_UPPERTEXTURE) + { + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), true); + if (!gltexture) return; + gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::top), seg->sidedef->GetTextureYScale(side_t::top)); + } + else if (rover->flags&FF_LOWERTEXTURE) + { + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), true); + if (!gltexture) return; + gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::bottom), seg->sidedef->GetTextureYScale(side_t::bottom)); + } + else + { + gltexture = FMaterial::ValidateTexture(mastersd->GetTexture(side_t::mid), true); + if (!gltexture) return; + gltexture->GetTexCoordInfo(&tci, mastersd->GetTextureXScale(side_t::mid), mastersd->GetTextureYScale(side_t::mid)); + } + + to=FIXED2FLOAT((rover->flags&(FF_UPPERTEXTURE|FF_LOWERTEXTURE))? + 0 : tci.TextureOffset(mastersd->GetTextureXOffset(side_t::mid))); + + ul=tci.FloatToTexU(to + FIXED2FLOAT(tci.TextureOffset(seg->sidedef->GetTextureXOffset(side_t::mid)))); + + texlength = tci.FloatToTexU(seg->sidedef->TexelLength); + + uplft.u = lolft.u = ul + texlength * glseg.fracleft; + uprgt.u = lorgt.u = ul + texlength * glseg.fracright; + + fixed_t rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); + to= (rover->flags&(FF_UPPERTEXTURE|FF_LOWERTEXTURE))? + 0.f : FIXED2FLOAT(tci.RowOffset(mastersd->GetTextureYOffset(side_t::mid))); + + to += FIXED2FLOAT(rowoffset); + + uplft.v=tci.FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_topleft)); + uprgt.v=tci.FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_topright)); + lolft.v=tci.FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_bottomleft)); + lorgt.v=tci.FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_bottomright)); + type=RENDERWALL_FFBLOCK; + CheckTexturePosition(); + } + + ztop[0]=FIXED2FLOAT(ff_topleft); + ztop[1]=FIXED2FLOAT(ff_topright); + zbottom[0]=FIXED2FLOAT(ff_bottomleft);//-0.001f; + zbottom[1]=FIXED2FLOAT(ff_bottomright); + + if (rover->flags&(FF_TRANSLUCENT|FF_ADDITIVETRANS|FF_FOG)) + { + alpha=rover->alpha/255.0f; + RenderStyle = (rover->flags&FF_ADDITIVETRANS)? STYLE_Add : STYLE_Translucent; + translucent=true; + type=gltexture? RENDERWALL_M2S:RENDERWALL_COLOR; + } + else + { + alpha=1.0f; + RenderStyle=STYLE_Normal; + translucent=false; + } + + sector_t * sec = sub? sub->sector : seg->frontsector; + + if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(translucent); + else SplitWall(sec, translucent); + + alpha=1.0f; + lightlevel = savelight; + Colormap = savecolor; + flags&=~GLT_CLAMPY; +} + + +//========================================================================== +// +// +// +//========================================================================== + +__forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, int &left, int &right) +{ + if (planeref->plane->a | planeref->plane->b) + { + left=planeref->plane->ZatPoint(vertexes[0]); + right=planeref->plane->ZatPoint(vertexes[1]); + } + else if(planeref->isceiling == sector_t::ceiling) + { + left = right = planeref->plane->d; + } + else + { + left = right = -planeref->plane->d; + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::InverseFloors(seg_t * seg, sector_t * frontsector, + fixed_t topleft, fixed_t topright, + fixed_t bottomleft, fixed_t bottomright) +{ + TArray & frontffloors=frontsector->e->XFloor.ffloors; + + for(unsigned int i=0;iflags&FF_EXISTS)) continue; + if (!(rover->flags&FF_RENDERSIDES)) continue; + if (!(rover->flags&(FF_INVERTSIDES|FF_ALLSIDES))) continue; + + fixed_t ff_topleft; + fixed_t ff_topright; + fixed_t ff_bottomleft; + fixed_t ff_bottomright; + + GetPlanePos(&rover->top, ff_topleft, ff_topright); + GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright); + + // above ceiling + if (ff_bottomleft>topleft && ff_bottomright>topright) continue; + + if (ff_topleft>topleft && ff_topright>topright) + { + // the new section overlaps with the previous one - clip it! + ff_topleft=topleft; + ff_topright=topright; + } + if (ff_bottomleft & frontffloors=frontsector->e->XFloor.ffloors; + + int flags = ffloor->flags & (FF_SWIMMABLE|FF_TRANSLUCENT); + + for(unsigned int i=0;iflags&FF_EXISTS)) continue; + if (!(rover->flags&FF_RENDERSIDES)) continue; + if ((rover->flags&flags)!=flags) continue; + + fixed_t ff_topleft; + fixed_t ff_topright; + fixed_t ff_bottomleft; + fixed_t ff_bottomright; + + GetPlanePos(&rover->top, ff_topleft, ff_topright); + + // we are completely below the bottom so unless there are some + // (unsupported) intersections there won't be any more floors that + // could clip this one. + if (ff_topleftbottom, ff_bottomleft, ff_bottomright); + // above top line? + if (ff_bottomleft>topleft && ff_bottomright>topright) continue; + + // overlapping the top line + if (ff_topleft>=topleft && ff_topright>=topright) + { + // overlapping with the entire range + if (ff_bottomleft<=bottomleft && ff_bottomright<=bottomright) return; + else if (ff_bottomleft>bottomleft && ff_bottomright>bottomright) + { + topleft=ff_bottomleft; + topright=ff_bottomright; + } + else + { + // an intersecting case. + // proper handling requires splitting but + // I don't need this right now. + } + } + else if (ff_topleft<=topleft && ff_topright<=topright) + { + BuildFFBlock(seg, ffloor, topleft, topright, ff_topleft, ff_topright); + if (ff_bottomleft<=bottomleft && ff_bottomright<=bottomright) return; + topleft=ff_bottomleft; + topright=ff_bottomright; + } + else + { + // an intersecting case. + // proper handling requires splitting but + // I don't need this right now. + } + } + +done: + // if the program reaches here there is one block left to draw + BuildFFBlock(seg, ffloor, topleft, topright, bottomleft, bottomright); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::DoFFloorBlocks(seg_t * seg,sector_t * frontsector,sector_t * backsector, + fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, + fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2) + +{ + TArray & backffloors=backsector->e->XFloor.ffloors; + fixed_t topleft, topright, bottomleft, bottomright; + bool renderedsomething=false; + + // if the ceilings intersect use the backsector's height because this sector's ceiling will + // obstruct the redundant parts. + + if (fch1bfh1 && ffh2>bfh2) + { + bottomleft=ffh1; + bottomright=ffh2; + } + else + { + bottomleft=bfh1; + bottomright=bfh2; + } + + for(unsigned int i=0;iflags&FF_EXISTS)) continue; + if (!(rover->flags&FF_RENDERSIDES) || (rover->flags&FF_INVERTSIDES)) continue; + + fixed_t ff_topleft; + fixed_t ff_topright; + fixed_t ff_bottomleft; + fixed_t ff_bottomright; + + GetPlanePos(&rover->top, ff_topleft, ff_topright); + GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright); + + // completely above ceiling + if (ff_bottomleft>topleft && ff_bottomright>topright && !renderedsomething) continue; + + if (ff_topleft>topleft && ff_topright>topright) + { + // the new section overlaps with the previous one - clip it! + ff_topleft=topleft; + ff_topright=topright; + } + + // do all inverse floors above the current one it there is a gap between the + // last 3D floor and this one. + if (topleft>ff_topleft && topright>ff_topright) + InverseFloors(seg, frontsector, topleft, topright, ff_topleft, ff_topright); + + // if translucent or liquid clip away adjoining parts of the same type of FFloors on the other side + if (rover->flags&(FF_SWIMMABLE|FF_TRANSLUCENT)) + ClipFFloors(seg, rover, frontsector, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright); + else + BuildFFBlock(seg, rover, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright); + + topleft=ff_bottomleft; + topright=ff_bottomright; + renderedsomething=true; + if (topleft<=bottomleft && topright<=bottomright) return; + } + + // draw all inverse floors below the lowest one + if (frontsector->e->XFloor.ffloors.Size() > 0) + { + if (topleft>bottomleft || topright>bottomright) + InverseFloors(seg, frontsector, topleft, topright, bottomleft, bottomright); + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) +{ + vertex_t * v1, * v2; + fixed_t fch1; + fixed_t ffh1; + fixed_t fch2; + fixed_t ffh2; + sector_t * realfront; + sector_t * realback; + +#ifdef _MSC_VER +#ifdef _DEBUG + if (seg->linedef-lines==2570) + __asm nop +#endif +#endif + + // note: we always have a valid sidedef and linedef reference when getting here. + + this->seg = seg; + + if ((seg->sidedef->Flags & WALLF_POLYOBJ) && seg->backsector) + { + // Textures on 2-sided polyobjects are aligned to the actual seg's sectors + realfront = seg->frontsector; + realback = seg->backsector; + } + else + { + // Need these for aligning the textures + realfront = §ors[frontsector->sectornum]; + realback = backsector? §ors[backsector->sectornum] : NULL; + } + + if (seg->sidedef == seg->linedef->sidedef[0]) + { + v1=seg->linedef->v1; + v2=seg->linedef->v2; + } + else + { + v1=seg->linedef->v2; + v2=seg->linedef->v1; + } + + if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + glseg.fracleft=0; + glseg.fracright=1; + if (gl_seamless) + { + if (v1->dirty) gl_RecalcVertexHeights(v1); + if (v2->dirty) gl_RecalcVertexHeights(v2); + } + } + else // polyobjects must be rendered per seg. + { + if (abs(v1->x-v2->x) > abs(v1->y-v2->y)) + { + glseg.fracleft = float(seg->v1->x - v1->x)/float(v2->x-v1->x); + glseg.fracright = float(seg->v2->x - v1->x)/float(v2->x-v1->x); + } + else + { + glseg.fracleft = float(seg->v1->y - v1->y)/float(v2->y-v1->y); + glseg.fracright = float(seg->v2->y - v1->y)/float(v2->y-v1->y); + } + v1=seg->v1; + v2=seg->v2; + } + + + vertexes[0]=v1; + vertexes[1]=v2; + + glseg.x1= FIXED2FLOAT(v1->x); + glseg.y1= FIXED2FLOAT(v1->y); + glseg.x2= FIXED2FLOAT(v2->x); + glseg.y2= FIXED2FLOAT(v2->y); + Colormap=frontsector->ColorMap; + flags = (!gl_isBlack(Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE)? GLWF_FOGGY : 0; + + int rel = 0; + int orglightlevel = gl_ClampLight(frontsector->lightlevel); + lightlevel = seg->sidedef->GetLightLevel(!!(flags&GLWF_FOGGY), orglightlevel, false, &rel); + if (orglightlevel >= 253) // with the software renderer fake contrast won't be visible above this. + { + rellight = 0; + } + else if (lightlevel - rel > 256) // the brighter part of fake contrast will be clamped so also clamp the darker part by the same amount for better looks + { + rellight = 256 - lightlevel + rel; + } + else + { + rellight = rel; + } + + alpha=1.0f; + RenderStyle=STYLE_Normal; + gltexture=NULL; + + topflat=frontsector->GetTexture(sector_t::ceiling); // for glowing textures. These must be saved because + bottomflat=frontsector->GetTexture(sector_t::floor); // the sector passed here might be a temporary copy. + + // Save a little time (up to 0.3 ms per frame ;) ) + if (frontsector->floorplane.a | frontsector->floorplane.b) + { + ffh1=frontsector->floorplane.ZatPoint(v1); + ffh2=frontsector->floorplane.ZatPoint(v2); + zfloor[0]=FIXED2FLOAT(ffh1); + zfloor[1]=FIXED2FLOAT(ffh2); + } + else + { + ffh1 = ffh2 = -frontsector->floorplane.d; + zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh2); + } + + if (frontsector->ceilingplane.a | frontsector->ceilingplane.b) + { + fch1=frontsector->ceilingplane.ZatPoint(v1); + fch2=frontsector->ceilingplane.ZatPoint(v2); + zceil[0]= FIXED2FLOAT(fch1); + zceil[1]= FIXED2FLOAT(fch2); + } + else + { + fch1 = fch2 = frontsector->ceilingplane.d; + zceil[0] = zceil[1] = FIXED2FLOAT(fch2); + } + + + if (seg->linedef->special==Line_Horizon) + { + SkyNormal(frontsector,v1,v2); + DoHorizon(seg,frontsector, v1,v2); + return; + } + + //return; + // [GZ] 3D middle textures are necessarily two-sided, even if they lack the explicit two-sided flag + if (!backsector || !(seg->linedef->flags&(ML_TWOSIDED|ML_3DMIDTEX))) // one sided + { + // sector's sky + SkyNormal(frontsector,v1,v2); + + // normal texture + gltexture=FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::mid), true); + if (gltexture) + { + DoTexture(RENDERWALL_M1S,seg,(seg->linedef->flags & ML_DONTPEGBOTTOM)>0, + realfront->GetPlaneTexZ(sector_t::ceiling),realfront->GetPlaneTexZ(sector_t::floor), // must come from the original! + fch1,fch2,ffh1,ffh2,0); + } + } + else // two sided + { + + fixed_t bch1; + fixed_t bch2; + fixed_t bfh1; + fixed_t bfh2; + + if (backsector->floorplane.a | backsector->floorplane.b) + { + bfh1=backsector->floorplane.ZatPoint(v1); + bfh2=backsector->floorplane.ZatPoint(v2); + } + else + { + bfh1 = bfh2 = -backsector->floorplane.d; + } + + if (backsector->ceilingplane.a | backsector->ceilingplane.b) + { + bch1=backsector->ceilingplane.ZatPoint(v1); + bch2=backsector->ceilingplane.ZatPoint(v2); + } + else + { + bch1 = bch2 = backsector->ceilingplane.d; + } + + SkyTop(seg,frontsector,backsector,v1,v2); + SkyBottom(seg,frontsector,backsector,v1,v2); + + // upper texture + if (frontsector->GetTexture(sector_t::ceiling)!=skyflatnum || backsector->GetTexture(sector_t::ceiling)!=skyflatnum) + { + fixed_t bch1a=bch1, bch2a=bch2; + if (frontsector->GetTexture(sector_t::floor)!=skyflatnum || backsector->GetTexture(sector_t::floor)!=skyflatnum) + { + // the back sector's floor obstructs part of this wall + if (ffh1>bch1 && ffh2>bch2) + { + bch2a=ffh2; + bch1a=ffh1; + } + } + + if (bch1asidedef->GetTexture(side_t::top), true); + if (gltexture) + { + DoTexture(RENDERWALL_TOP,seg,(seg->linedef->flags & (ML_DONTPEGTOP))==0, + realfront->GetPlaneTexZ(sector_t::ceiling),realback->GetPlaneTexZ(sector_t::ceiling), + fch1,fch2,bch1a,bch2a,0); + } + else if ((frontsector->ceilingplane.a | frontsector->ceilingplane.b | + backsector->ceilingplane.a | backsector->ceilingplane.b) && + frontsector->GetTexture(sector_t::ceiling)!=skyflatnum && + backsector->GetTexture(sector_t::ceiling)!=skyflatnum) + { + gltexture=FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::ceiling), true); + if (gltexture) + { + DoTexture(RENDERWALL_TOP,seg,(seg->linedef->flags & (ML_DONTPEGTOP))==0, + realfront->GetPlaneTexZ(sector_t::ceiling),realback->GetPlaneTexZ(sector_t::ceiling), + fch1,fch2,bch1a,bch2a,0); + } + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a); + } + } + } + + + /* mid texture */ + bool drawfogboundary = gl_CheckFog(frontsector, backsector); + FTexture *tex = TexMan(seg->sidedef->GetTexture(side_t::mid)); + if (tex != NULL) + { + if (i_compatflags & COMPATF_MASKEDMIDTEX) + { + tex = tex->GetRawTexture(); + } + gltexture=FMaterial::ValidateTexture(tex); + } + else gltexture = NULL; + + if (gltexture || drawfogboundary) + { + DoMidTexture(seg, drawfogboundary, frontsector, backsector, realfront, realback, + fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); + } + + if (backsector->e->XFloor.ffloors.Size() || frontsector->e->XFloor.ffloors.Size()) + { + DoFFloorBlocks(seg,frontsector,backsector, fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); + } + + /* bottom texture */ + // the back sector's ceiling obstructs part of this wall (specially important for sky sectors) + if (fch1ffh1 || bfh2>ffh2) + { + gltexture=FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), true); + if (gltexture) + { + DoTexture(RENDERWALL_BOTTOM,seg,(seg->linedef->flags & ML_DONTPEGBOTTOM)>0, + realback->GetPlaneTexZ(sector_t::floor),realfront->GetPlaneTexZ(sector_t::floor), + bfh1,bfh2,ffh1,ffh2, + frontsector->GetTexture(sector_t::ceiling)==skyflatnum && backsector->GetTexture(sector_t::ceiling)==skyflatnum ? + realfront->GetPlaneTexZ(sector_t::floor)-realback->GetPlaneTexZ(sector_t::ceiling) : + realfront->GetPlaneTexZ(sector_t::floor)-realfront->GetPlaneTexZ(sector_t::ceiling)); + } + else if ((frontsector->floorplane.a | frontsector->floorplane.b | + backsector->floorplane.a | backsector->floorplane.b) && + frontsector->GetTexture(sector_t::floor)!=skyflatnum && + backsector->GetTexture(sector_t::floor)!=skyflatnum) + { + // render it anyway with the sector's floor texture. With a background sky + // there are ugly holes otherwise and slopes are simply not precise enough + // to mach in any case. + gltexture=FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), true); + if (gltexture) + { + DoTexture(RENDERWALL_BOTTOM,seg,(seg->linedef->flags & ML_DONTPEGBOTTOM)>0, + realback->GetPlaneTexZ(sector_t::floor),realfront->GetPlaneTexZ(sector_t::floor), + bfh1,bfh2,ffh1,ffh2, realfront->GetPlaneTexZ(sector_t::floor)-realfront->GetPlaneTexZ(sector_t::ceiling)); + } + } + else if (backsector->GetTexture(sector_t::floor)!=skyflatnum && + !(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1); + } + } + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector) +{ + if (frontsector->GetTexture(sector_t::floor)==skyflatnum) return; + + fixed_t ffh = frontsector->GetPlaneTexZ(sector_t::floor); + fixed_t bfh = backsector->GetPlaneTexZ(sector_t::floor); + if (bfh>ffh) + { + this->seg = seg; + this->sub = NULL; + + vertex_t * v1=seg->v1; + vertex_t * v2=seg->v2; + vertexes[0]=v1; + vertexes[1]=v2; + + glseg.x1 = FIXED2FLOAT(v1->x); + glseg.y1 = FIXED2FLOAT(v1->y); + glseg.x2 = FIXED2FLOAT(v2->x); + glseg.y2 = FIXED2FLOAT(v2->y); + glseg.fracleft = 0; + glseg.fracright = 1; + + flags = (!gl_isBlack(Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE)? GLWF_FOGGY : 0; + + // can't do fake contrast without a sidedef + lightlevel = gl_ClampLight(frontsector->lightlevel); + rellight = 0; + + alpha = 1.0f; + RenderStyle = STYLE_Normal; + Colormap = frontsector->ColorMap; + + topflat = frontsector->GetTexture(sector_t::ceiling); // for glowing textures + bottomflat = frontsector->GetTexture(sector_t::floor); + + zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh); + + gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), true); + + if (gltexture) + { + FTexCoordInfo tci; + type=RENDERWALL_BOTTOM; + gltexture->GetTexCoordInfo(&tci, FRACUNIT, FRACUNIT); + SetWallCoordinates(seg, &tci, FIXED2FLOAT(bfh), bfh, bfh, ffh, ffh, 0); + PutWall(false); + } + } +} diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp new file mode 100644 index 000000000..1689909fc --- /dev/null +++ b/src/gl/scene/gl_walls_draw.cpp @@ -0,0 +1,592 @@ +/* +** gl_walls_draw.cpp +** Wall rendering +** +**--------------------------------------------------------------------------- +** Copyright 2000-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "p_local.h" +#include "p_lnspec.h" +#include "a_sharedglobal.h" +#include "gl/gl_functions.h" + +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_templates.h" + +EXTERN_CVAR(Bool, gl_seamless) + +//========================================================================== +// +// Sets up the texture coordinates for one light to be rendered +// +//========================================================================== +bool GLWall::PrepareLight(texcoord * tcs, ADynamicLight * light) +{ + float vtx[]={glseg.x1,zbottom[0],glseg.y1, glseg.x1,ztop[0],glseg.y1, glseg.x2,ztop[1],glseg.y2, glseg.x2,zbottom[1],glseg.y2}; + Plane p; + Vector nearPt, up, right; + float scale; + + p.Init(vtx,4); + + if (!p.ValidNormal()) + { + return false; + } + + if (!gl_SetupLight(p, light, nearPt, up, right, scale, Colormap.colormap, true, !!(flags&GLWF_FOGGY))) + { + return false; + } + + if (tcs != NULL) + { + Vector t1; + int outcnt[4]={0,0,0,0}; + + for(int i=0;i<4;i++) + { + t1.Set(&vtx[i*3]); + Vector nearToVert = t1 - nearPt; + tcs[i].u = (nearToVert.Dot(right) * scale) + 0.5f; + tcs[i].v = (nearToVert.Dot(up) * scale) + 0.5f; + + // quick check whether the light touches this polygon + if (tcs[i].u<0) outcnt[0]++; + if (tcs[i].u>1) outcnt[1]++; + if (tcs[i].v<0) outcnt[2]++; + if (tcs[i].v>1) outcnt[3]++; + + } + // The light doesn't touch this polygon + if (outcnt[0]==4 || outcnt[1]==4 || outcnt[2]==4 || outcnt[3]==4) return false; + } + + draw_dlight++; + return true; +} + +//========================================================================== +// +// Collect lights for shader +// +//========================================================================== +FDynLightData lightdata; + +void GLWall::SetupLights() +{ + float vtx[]={glseg.x1,zbottom[0],glseg.y1, glseg.x1,ztop[0],glseg.y1, glseg.x2,ztop[1],glseg.y2, glseg.x2,zbottom[1],glseg.y2}; + Plane p; + + lightdata.Clear(); + p.Init(vtx,4); + + if (!p.ValidNormal()) + { + return; + } + for(int i=0;i<2;i++) + { + FLightNode *node; + if (seg->sidedef == NULL) + { + node = NULL; + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + node = seg->sidedef->lighthead[i]; + } + else if (sub) + { + // Polobject segs cannot be checked per sidedef so use the subsector instead. + node = sub->lighthead[i]; + } + else node = NULL; + + // Iterate through all dynamic lights which touch this wall and render them + while (node) + { + if (!(node->lightsource->flags2&MF2_DORMANT)) + { + iter_dlight++; + + Vector fn, pos; + + float x = FIXED2FLOAT(node->lightsource->x); + float y = FIXED2FLOAT(node->lightsource->y); + float z = FIXED2FLOAT(node->lightsource->z); + float dist = fabsf(p.DistToPoint(x, z, y)); + float radius = (node->lightsource->GetRadius() * gl_lights_size); + float scale = 1.0f / ((2.f * radius) - dist); + + if (radius > 0.f && dist < radius) + { + Vector nearPt, up, right; + + pos.Set(x,z,y); + fn=p.Normal(); + fn.GetRightUp(right, up); + + Vector tmpVec = fn * dist; + nearPt = pos + tmpVec; + + Vector t1; + int outcnt[4]={0,0,0,0}; + texcoord tcs[4]; + + // do a quick check whether the light touches this polygon + for(int i=0;i<4;i++) + { + t1.Set(&vtx[i*3]); + Vector nearToVert = t1 - nearPt; + tcs[i].u = (nearToVert.Dot(right) * scale) + 0.5f; + tcs[i].v = (nearToVert.Dot(up) * scale) + 0.5f; + + if (tcs[i].u<0) outcnt[0]++; + if (tcs[i].u>1) outcnt[1]++; + if (tcs[i].v<0) outcnt[2]++; + if (tcs[i].v>1) outcnt[3]++; + + } + if (outcnt[0]!=4 && outcnt[1]!=4 && outcnt[2]!=4 && outcnt[3]!=4) + { + gl_GetLight(p, node->lightsource, Colormap.colormap, true, false, lightdata); + } + } + } + node = node->nextLight; + } + } + int numlights[3]; + + lightdata.Combine(numlights, gl.MaxLights()); + if (numlights[2] > 0) + { + draw_dlight+=numlights[2]/2; + gl_RenderState.EnableLight(true); + gl_RenderState.SetLights(numlights, &lightdata.arrays[0][0]); + } +} + +//========================================================================== +// +// General purpose wall rendering function +// everything goes through here +// +//========================================================================== + +void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) +{ + texcoord tcs[4]; + bool glowing; + bool split = (gl_seamless && !(textured&4) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ)); + + if (!light) + { + tcs[0]=lolft; + tcs[1]=uplft; + tcs[2]=uprgt; + tcs[3]=lorgt; + glowing = !!(flags&GLWF_GLOW) && (textured & 2); + } + else + { + if (!PrepareLight(tcs, light)) return; + glowing = false; + } + + if (glowing) gl_RenderState.SetGlowParams(topglowcolor, bottomglowcolor); + + gl_RenderState.Apply(); + + // the rest of the code is identical for textured rendering and lights + + gl.Begin(GL_TRIANGLE_FAN); + + // lower left corner + if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - zbottom[0], zbottom[0] - zfloor[0]); + if (textured&1) gl.TexCoord2f(tcs[0].u,tcs[0].v); + gl.Vertex3f(glseg.x1,zbottom[0],glseg.y1); + + if (split && glseg.fracleft==0) SplitLeftEdge(tcs, glowing); + + // upper left corner + if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - ztop[0], ztop[0] - zfloor[0]); + if (textured&1) gl.TexCoord2f(tcs[1].u,tcs[1].v); + gl.Vertex3f(glseg.x1,ztop[0],glseg.y1); + + if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs, glowing); + + // color for right side + if (color2) gl.Color4fv(color2); + + // upper right corner + if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - ztop[1], ztop[1] - zfloor[1]); + if (textured&1) gl.TexCoord2f(tcs[2].u,tcs[2].v); + gl.Vertex3f(glseg.x2,ztop[1],glseg.y2); + + if (split && glseg.fracright==1) SplitRightEdge(tcs, glowing); + + // lower right corner + if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - zbottom[1], zbottom[1] - zfloor[1]); + if (textured&1) gl.TexCoord2f(tcs[3].u,tcs[3].v); + gl.Vertex3f(glseg.x2,zbottom[1],glseg.y2); + + if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, glowing); + + gl.End(); + + vertexcount+=4; + +} + +//========================================================================== +// +// +// +//========================================================================== + +void GLWall::RenderFogBoundary() +{ + if (gl_fogmode && gl_fixedcolormap == 0) + { + // with shaders this can be done properly + if (gl.shadermodel == 4 || (gl.shadermodel == 3 && gl_fog_shader)) + { + int rel = rellight + getExtraLight(); + gl_SetFog(lightlevel, rel, &Colormap, false); + gl_RenderState.SetEffect(EFF_FOGBOUNDARY); + gl_RenderState.EnableAlphaTest(false); + RenderWall(0, NULL); + gl_RenderState.EnableAlphaTest(true); + gl_RenderState.SetEffect(EFF_NONE); + } + else + { + // otherwise some approximation is needed. This won't look as good + // as the shader version but it's an acceptable compromise. + float fogdensity=gl_GetFogDensity(lightlevel, Colormap.FadeColor); + + float xcamera=FIXED2FLOAT(viewx); + float ycamera=FIXED2FLOAT(viewy); + + float dist1=Dist2(xcamera,ycamera, glseg.x1,glseg.y1); + float dist2=Dist2(xcamera,ycamera, glseg.x2,glseg.y2); + + + // these values were determined by trial and error and are scale dependent! + float fogd1=(0.95f-exp(-fogdensity*dist1/62500.f)) * 1.05f; + float fogd2=(0.95f-exp(-fogdensity*dist2/62500.f)) * 1.05f; + + gl_ModifyColor(Colormap.FadeColor.r, Colormap.FadeColor.g, Colormap.FadeColor.b, Colormap.colormap); + float fc[4]={Colormap.FadeColor.r/255.0f,Colormap.FadeColor.g/255.0f,Colormap.FadeColor.b/255.0f,fogd2}; + + gl_RenderState.EnableTexture(false); + gl_RenderState.EnableFog(false); + gl_RenderState.AlphaFunc(GL_GREATER,0); + gl.DepthFunc(GL_LEQUAL); + gl.Color4f(fc[0],fc[1],fc[2], fogd1); + if (glset.lightmode == 8) gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); // Korshun. + + flags &= ~GLWF_GLOW; + RenderWall(4,fc); + + gl.DepthFunc(GL_LESS); + gl_RenderState.EnableFog(true); + gl_RenderState.AlphaFunc(GL_GEQUAL,0.5f); + gl_RenderState.EnableTexture(true); + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::RenderMirrorSurface() +{ + if (GLRenderer->mirrortexture == NULL) return; + + // For the sphere map effect we need a normal of the mirror surface, + Vector v(glseg.y2-glseg.y1, 0 ,-glseg.x2+glseg.x1); + v.Normalize(); + glNormal3fv(&v[0]); + + // Use sphere mapping for this + gl_RenderState.SetEffect(EFF_SPHEREMAP); + + gl_SetColor(lightlevel, 0, &Colormap ,0.1f); + gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE); + gl_RenderState.AlphaFunc(GL_GREATER,0); + gl.DepthFunc(GL_LEQUAL); + gl_SetFog(lightlevel, getExtraLight(), &Colormap, true); + + FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrortexture); + pat->BindPatch(Colormap.colormap, 0); + + flags &= ~GLWF_GLOW; + //flags |= GLWF_NOSHADER; + RenderWall(0,NULL); + + gl_RenderState.SetEffect(EFF_NONE); + + // Restore the defaults for the translucent pass + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.AlphaFunc(GL_GEQUAL,0.5f*gl_mask_sprite_threshold); + gl.DepthFunc(GL_LESS); + + // This is drawn in the translucent pass which is done after the decal pass + // As a result the decals have to be drawn here. + if (seg->sidedef->AttachedDecals) + { + gl.Enable(GL_POLYGON_OFFSET_FILL); + gl.PolygonOffset(-1.0f, -128.0f); + gl.DepthMask(false); + DoDrawDecals(); + gl.DepthMask(true); + gl.PolygonOffset(0.0f, 0.0f); + gl.Disable(GL_POLYGON_OFFSET_FILL); + gl_RenderState.SetTextureMode(TM_MODULATE); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +void GLWall::RenderTranslucentWall() +{ + bool transparent = gltexture? gltexture->GetTransparent() : false; + + // currently the only modes possible are solid, additive or translucent + // and until that changes I won't fix this code for the new blending modes! + bool isadditive = RenderStyle == STYLE_Add; + + if (!transparent) gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_threshold*fabs(alpha)); + else gl_RenderState.EnableAlphaTest(false); + if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE); + + int extra; + if (gltexture) + { + if (flags&GLWF_FOGGY) gl_RenderState.EnableBrightmap(false); + gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); + gltexture->Bind(Colormap.colormap, flags, 0); + extra = getExtraLight(); + } + else + { + gl_RenderState.EnableTexture(false); + extra = 0; + } + + gl_SetColor(lightlevel, extra, &Colormap, fabsf(alpha)); + if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, extra, &Colormap, isadditive); + else gl_SetFog(255, 0, NULL, false); + + RenderWall(5,NULL); + + // restore default settings + if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + if (transparent) gl_RenderState.EnableAlphaTest(true); + + if (!gltexture) + { + gl_RenderState.EnableTexture(true); + } + gl_RenderState.EnableBrightmap(true); + gl_RenderState.EnableGlow(false); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::Draw(int pass) +{ + FLightNode * node; + int rel; + +#ifdef _MSC_VER +#ifdef _DEBUG + if (seg->linedef-lines==879) + __asm nop +#endif +#endif + + + // This allows mid textures to be drawn on lines that might overlap a sky wall + if ((flags&GLWF_SKYHACK && type==RENDERWALL_M2S) || type == RENDERWALL_COLORLAYER) + { + if (pass != GLPASS_DECALS) + { + gl.Enable(GL_POLYGON_OFFSET_FILL); + gl.PolygonOffset(-1.0f, -128.0f); + } + } + + switch (pass) + { + case GLPASS_ALL: // Single-pass rendering + SetupLights(); + // fall through + case GLPASS_PLAIN: // Single-pass rendering + rel = rellight + getExtraLight(); + gl_SetColor(lightlevel, rel, &Colormap,1.0f); + if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, false); + else gl_SetFog(255, 0, NULL, false); + + gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); + gltexture->Bind(Colormap.colormap, flags, 0); + RenderWall(3, NULL); + gl_RenderState.EnableGlow(false); + gl_RenderState.EnableLight(false); + break; + + case GLPASS_BASE: // Base pass for non-masked polygons (all opaque geometry) + case GLPASS_BASE_MASKED: // Base pass for masked polygons (2sided mid-textures and transparent 3D floors) + rel = rellight + getExtraLight(); + gl_SetColor(lightlevel, rel, &Colormap,1.0f); + if (!(flags&GLWF_FOGGY)) + { + if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, false); + else gl_SetFog(255, 0, NULL, false); + } + gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); + // fall through + + if (pass != GLPASS_BASE) + { + gltexture->Bind(Colormap.colormap, flags, 0); + } + RenderWall(pass == GLPASS_BASE? 2:3, NULL); + gl_RenderState.EnableGlow(false); + gl_RenderState.EnableLight(false); + break; + + case GLPASS_TEXTURE: // modulated texture + gltexture->Bind(Colormap.colormap, flags, 0); + RenderWall(1, NULL); + break; + + case GLPASS_LIGHT: + case GLPASS_LIGHT_ADDITIVE: + // black fog is diminishing light and should affect lights less than the rest! + if (!(flags&GLWF_FOGGY)) gl_SetFog((255+lightlevel)>>1, 0, NULL, false); + else gl_SetFog(lightlevel, 0, &Colormap, true); + + if (seg->sidedef == NULL) + { + node = NULL; + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + // Iterate through all dynamic lights which touch this wall and render them + node = seg->sidedef->lighthead[pass==GLPASS_LIGHT_ADDITIVE]; + } + else if (sub) + { + // To avoid constant rechecking for polyobjects use the subsector's lightlist instead + node = sub->lighthead[pass==GLPASS_LIGHT_ADDITIVE]; + } + else node = NULL; + while (node) + { + if (!(node->lightsource->flags2&MF2_DORMANT)) + { + iter_dlight++; + RenderWall(1, NULL, node->lightsource); + } + node = node->nextLight; + } + break; + + case GLPASS_DECALS: + case GLPASS_DECALS_NOFOG: + if (seg->sidedef && seg->sidedef->AttachedDecals) + { + if (pass==GLPASS_DECALS) + { + gl_SetFog(lightlevel, rellight + getExtraLight(), &Colormap, false); + } + DoDrawDecals(); + } + break; + + case GLPASS_TRANSLUCENT: + switch (type) + { + case RENDERWALL_MIRRORSURFACE: + RenderMirrorSurface(); + break; + + case RENDERWALL_FOGBOUNDARY: + RenderFogBoundary(); + break; + + default: + RenderTranslucentWall(); + break; + } + } + + if ((flags&GLWF_SKYHACK && type==RENDERWALL_M2S) || type == RENDERWALL_COLORLAYER) + { + if (pass!=GLPASS_DECALS) + { + gl.Disable(GL_POLYGON_OFFSET_FILL); + gl.PolygonOffset(0, 0); + } + } +} diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp new file mode 100644 index 000000000..f9f1a823b --- /dev/null +++ b/src/gl/scene/gl_weapon.cpp @@ -0,0 +1,407 @@ +/* +** gl_weapon.cpp +** Weapon sprite drawing +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ +#include "gl/system/gl_system.h" +#include "sbar.h" +#include "r_utility.h" +#include "v_video.h" +#include "doomstat.h" +#include "d_player.h" +#include "g_level.h" + +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/models/gl_models.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" + +EXTERN_CVAR (Bool, r_drawplayersprites) +EXTERN_CVAR(Float, transsouls) +EXTERN_CVAR (Bool, st_scale) +EXTERN_CVAR(Int, gl_fuzztype) + + +//========================================================================== +// +// R_DrawPSprite +// +//========================================================================== + +void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, int cm_index, bool hudModelStep, int OverrideShader) +{ + float fU1,fV1; + float fU2,fV2; + fixed_t tx; + int x1,y1,x2,y2; + float scale; + fixed_t scalex; + fixed_t texturemid;// 4:3 16:9 16:10 17:10 5:4 + static fixed_t xratio[] = {FRACUNIT, FRACUNIT*3/4, FRACUNIT*5/6, FRACUNIT*40/51, FRACUNIT}; + + // [BB] In the HUD model step we just render the model and break out. + if ( hudModelStep ) + { + gl_RenderHUDModel( psp, sx, sy, cm_index ); + return; + } + + // decide which patch to use + bool mirror; + FTextureID lump = gl_GetSpriteFrame(psp->sprite, psp->frame, 0, 0, &mirror); + if (!lump.isValid()) return; + + FMaterial * tex = FMaterial::ValidateTexture(lump, false); + if (!tex) return; + + tex->BindPatch(cm_index, 0, OverrideShader); + + int vw = viewwidth; + int vh = viewheight; + + // calculate edges of the shape + scalex = xratio[WidescreenRatio] * vw / 320; + + tx = sx - ((160 + tex->GetScaledLeftOffset(GLUSE_PATCH))<>FRACBITS) + (vw>>1); + if (x1 > vw) return; // off the right side + x1+=viewwindowx; + + tx += tex->TextureWidth(GLUSE_PATCH) << FRACBITS; + x2 = (FixedMul(tx, scalex)>>FRACBITS) + (vw>>1); + if (x2 < 0) return; // off the left side + x2+=viewwindowx; + + // killough 12/98: fix psprite positioning problem + texturemid = (100<GetScaledTopOffset(GLUSE_PATCH)<ReadyWeapon; + if (wi && wi->YAdjust) + { + if (screenblocks>=11) + { + texturemid -= wi->YAdjust; + } + else if (!st_scale) + { + texturemid -= FixedMul (StatusBar->GetDisplacement (), wi->YAdjust); + } + } + + scale = ((SCREENHEIGHT*vw)/SCREENWIDTH) / 200.0f; + y1 = viewwindowy + (vh >> 1) - (int)(((float)texturemid / (float)FRACUNIT) * scale); + y2 = y1 + (int)((float)tex->TextureHeight(GLUSE_PATCH) * scale) + 1; + + if (!mirror) + { + fU1=tex->GetUL(); + fV1=tex->GetVT(); + fU2=tex->GetUR(); + fV2=tex->GetVB(); + } + else + { + fU2=tex->GetUL(); + fV1=tex->GetVT(); + fU1=tex->GetUR(); + fV2=tex->GetVB(); + } + + if (tex->GetTransparent() || OverrideShader != 0) + { + gl_RenderState.EnableAlphaTest(false); + } + gl_RenderState.Apply(); + gl.Begin(GL_TRIANGLE_STRIP); + gl.TexCoord2f(fU1, fV1); gl.Vertex2f(x1,y1); + gl.TexCoord2f(fU1, fV2); gl.Vertex2f(x1,y2); + gl.TexCoord2f(fU2, fV1); gl.Vertex2f(x2,y1); + gl.TexCoord2f(fU2, fV2); gl.Vertex2f(x2,y2); + gl.End(); + if (tex->GetTransparent() || OverrideShader != 0) + { + gl_RenderState.EnableAlphaTest(true); + } +} + +//========================================================================== +// +// R_DrawPlayerSprites +// +//========================================================================== + +EXTERN_CVAR(Bool, gl_brightfog) + +void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) +{ + bool statebright[2] = {false, false}; + unsigned int i; + pspdef_t *psp; + int lightlevel=0; + fixed_t ofsx, ofsy; + FColormap cm; + sector_t * fakesec, fs; + AActor * playermo=players[consoleplayer].camera; + player_t * player=playermo->player; + + if(!player || playermo->renderflags&RF_INVISIBLE || !r_drawplayersprites || + mViewActor!=playermo || playermo->RenderStyle.BlendOp == STYLEOP_None) return; + + P_BobWeapon (player, &player->psprites[ps_weapon], &ofsx, &ofsy); + + // check for fullbright + if (player->fixedcolormap==NOFIXEDCOLORMAP) + { + for (i=0, psp=player->psprites; i<=ps_flash; i++,psp++) + if (psp->state != NULL) + { + bool disablefullbright = false; + FTextureID lump = gl_GetSpriteFrame(psp->sprite, psp->frame, 0, 0, NULL); + if (lump.isValid() && gl_BrightmapsActive()) + { + FMaterial * tex=FMaterial::ValidateTexture(lump, false); + if (tex) + disablefullbright = tex->tex->gl_info.bBrightmapDisablesFullbright; + } + statebright[i] = !!psp->state->GetFullbright() && !disablefullbright; + } + + } + + if (gl_fixedcolormap) + { + lightlevel=255; + cm.GetFixedColormap(); + statebright[0] = statebright[1] = true; + fakesec = viewsector; + } + else + { + fakesec = gl_FakeFlat(viewsector, &fs, false); + + // calculate light level for weapon sprites + lightlevel = gl_ClampLight(fakesec->lightlevel); + if (glset.lightmode == 8) + { + lightlevel = gl_CalcLightLevel(lightlevel, getExtraLight(), true); + + // Korshun: the way based on max possible light level for sector like in software renderer. + float min_L = 36.0/31.0 - ((lightlevel/255.0) * (63.0/31.0)); // Lightlevel in range 0-63 + if (min_L < 0) + min_L = 0; + else if (min_L > 1.0) + min_L = 1.0; + + lightlevel = (1.0 - min_L) * 255; + } + lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->x, playermo->y, playermo->z); + + // calculate colormap for weapon sprites + if (viewsector->e->XFloor.ffloors.Size() && !glset.nocoloredspritelighting) + { + TArray & lightlist = viewsector->e->XFloor.lightlist; + for(i=0;ifloorplane.ZatPoint(viewx,viewy); + } + + if (lightbottomviewz) + { + cm = lightlist[i].extra_colormap; + lightlevel = *lightlist[i].p_lightlevel; + break; + } + } + } + else + { + cm=fakesec->ColorMap; + if (glset.nocoloredspritelighting) cm.ClearColor(); + } + } + + + // Korshun: fullbright fog in opengl, render weapon sprites fullbright. + if (glset.brightfog && ((level.flags&LEVEL_HASFADETABLE) || cm.FadeColor != 0)) + { + lightlevel = 255; + statebright[0] = statebright[1] = true; + } + + PalEntry ThingColor = playermo->fillcolor; + visstyle_t vis; + + vis.RenderStyle=playermo->RenderStyle; + vis.alpha=playermo->alpha; + vis.colormap = NULL; + if (playermo->Inventory) + { + playermo->Inventory->AlterWeaponSprite(&vis); + if (vis.colormap >= SpecialColormaps[0].Colormap && + vis.colormap < SpecialColormaps[SpecialColormaps.Size()].Colormap && + cm.colormap == CM_DEFAULT) + { + ptrdiff_t specialmap = (vis.colormap - SpecialColormaps[0].Colormap) / sizeof(FSpecialColormap); + cm.colormap = int(CM_FIRSTSPECIALCOLORMAP + specialmap); + } + } + + // Set the render parameters + + int OverrideShader = 0; + float trans = 0.f; + if (vis.RenderStyle.BlendOp >= STYLEOP_Fuzz && vis.RenderStyle.BlendOp <= STYLEOP_FuzzOrRevSub) + { + vis.RenderStyle.CheckFuzz(); + if (vis.RenderStyle.BlendOp == STYLEOP_Fuzz) + { + if (gl.shadermodel >= 4 && gl_fuzztype != 0) + { + // Todo: implement shader selection here + vis.RenderStyle = LegacyRenderStyles[STYLE_Translucent]; + OverrideShader = gl_fuzztype + 4; + trans = 0.99f; // trans may not be 1 here + } + else + { + vis.RenderStyle.BlendOp = STYLEOP_Shadow; + } + } + statebright[0] = statebright[1] = false; + } + + gl_SetRenderStyle(vis.RenderStyle, false, false); + + if (vis.RenderStyle.Flags & STYLEF_TransSoulsAlpha) + { + trans = transsouls; + } + else if (vis.RenderStyle.Flags & STYLEF_Alpha1) + { + trans = 1.f; + } + else if (trans == 0.f) + { + trans = FIXED2FLOAT(vis.alpha); + } + + // now draw the different layers of the weapon + gl_RenderState.EnableBrightmap(true); + if (statebright[0] || statebright[1]) + { + // brighten the weapon to reduce the difference between + // normal sprite and fullbright flash. + if (glset.lightmode != 8) lightlevel = (2*lightlevel+255)/3; + } + + // hack alert! Rather than changing everything in the underlying lighting code let's just temporarily change + // light mode here to draw the weapon sprite. + int oldlightmode = glset.lightmode; + if (glset.lightmode == 8) glset.lightmode = 2; + + for (i=0, psp=player->psprites; i<=ps_flash; i++,psp++) + { + if (psp->state) + { + FColormap cmc = cm; + if (statebright[i]) + { + if (fakesec == viewsector || in_area != area_below) + // under water areas keep most of their color for fullbright objects + { + cmc.LightColor.r= + cmc.LightColor.g= + cmc.LightColor.b=0xff; + } + else + { + cmc.LightColor.r = (3*cmc.LightColor.r + 0xff)/4; + cmc.LightColor.g = (3*cmc.LightColor.g + 0xff)/4; + cmc.LightColor.b = (3*cmc.LightColor.b + 0xff)/4; + } + } + // set the lighting parameters (only calls glColor and glAlphaFunc) + gl_SetSpriteLighting(vis.RenderStyle, playermo, statebright[i]? 255 : lightlevel, + 0, &cmc, 0xffffff, trans, statebright[i], true); + DrawPSprite (player,psp,psp->sx+ofsx, psp->sy+ofsy, cm.colormap, hudModelStep, OverrideShader); + } + } + gl_RenderState.EnableBrightmap(false); + glset.lightmode = oldlightmode; +} + +//========================================================================== +// +// R_DrawPlayerSprites +// +//========================================================================== + +void FGLRenderer::DrawTargeterSprites() +{ + int i; + pspdef_t *psp; + AActor * playermo=players[consoleplayer].camera; + player_t * player=playermo->player; + + if(!player || playermo->renderflags&RF_INVISIBLE || !r_drawplayersprites || + mViewActor!=playermo) return; + + gl_RenderState.EnableBrightmap(false); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_sprite_threshold); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl.Color3f(1.0f,1.0f,1.0f); + gl_RenderState.SetTextureMode(TM_MODULATE); + + // The Targeter's sprites are always drawn normally. + for (i=ps_targetcenter, psp = &player->psprites[ps_targetcenter]; istate) DrawPSprite (player,psp,psp->sx, psp->sy, CM_DEFAULT, false, 0); +} \ No newline at end of file diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp new file mode 100644 index 000000000..4a3c7ca94 --- /dev/null +++ b/src/gl/shaders/gl_shader.cpp @@ -0,0 +1,679 @@ +/* +** gl_shader.cpp +** +** GLSL shader handling +** +**--------------------------------------------------------------------------- +** Copyright 2004-2009 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ +#include "gl/system/gl_system.h" +#include "c_cvars.h" +#include "v_video.h" +#include "name.h" +#include "w_wad.h" +#include "i_system.h" +#include "doomerrors.h" +#include "v_palette.h" +#include "sc_man.h" +#include "cmdlib.h" + +#include "gl/data/gl_data.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" + +// these will only have an effect on SM3 cards. +// For SM4 they are always on and for SM2 always off +CVAR(Bool, gl_warp_shader, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +CVAR(Bool, gl_fog_shader, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +CVAR(Bool, gl_colormap_shader, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +CVAR(Bool, gl_brightmap_shader, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +CVAR(Bool, gl_glow_shader, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) + + +extern long gl_frameMS; + +//========================================================================== +// +// +// +//========================================================================== + +bool FShader::Load(const char * name, const char * vert_prog_lump, const char * frag_prog_lump, const char * proc_prog_lump, const char * defines) +{ + static char buffer[10000]; + FString error; + + if (gl.shadermodel > 0) + { + int vp_lump = Wads.CheckNumForFullName(vert_prog_lump); + if (vp_lump == -1) I_Error("Unable to load '%s'", vert_prog_lump); + FMemLump vp_data = Wads.ReadLump(vp_lump); + + int fp_lump = Wads.CheckNumForFullName(frag_prog_lump); + if (fp_lump == -1) I_Error("Unable to load '%s'", frag_prog_lump); + FMemLump fp_data = Wads.ReadLump(fp_lump); + + + FString vp_comb; + FString fp_comb; + vp_comb = defines; + if (gl.shadermodel < 4) + { + vp_comb << "#define NO_SM4\n"; + } + + fp_comb = vp_comb; + // This uses GetChars on the strings to get rid of terminating 0 characters. + vp_comb << vp_data.GetString().GetChars() << "\n"; + fp_comb << fp_data.GetString().GetChars() << "\n"; + + if (proc_prog_lump != NULL) + { + if (*proc_prog_lump != '#') + { + int pp_lump = Wads.CheckNumForFullName(proc_prog_lump); + if (pp_lump == -1) I_Error("Unable to load '%s'", proc_prog_lump); + FMemLump pp_data = Wads.ReadLump(pp_lump); + + fp_comb << pp_data.GetString().GetChars(); + } + else + { + // Proc_prog_lump is not a lump name but the source itself (from generated shaders) + fp_comb << proc_prog_lump+1; + } + } + + hVertProg = gl.CreateShader(GL_VERTEX_SHADER); + hFragProg = gl.CreateShader(GL_FRAGMENT_SHADER); + + + int vp_size = (int)vp_comb.Len(); + int fp_size = (int)fp_comb.Len(); + + const char *vp_ptr = vp_comb.GetChars(); + const char *fp_ptr = fp_comb.GetChars(); + + gl.ShaderSource(hVertProg, 1, &vp_ptr, &vp_size); + gl.ShaderSource(hFragProg, 1, &fp_ptr, &fp_size); + + gl.CompileShader(hVertProg); + gl.CompileShader(hFragProg); + + hShader = gl.CreateProgram(); + + gl.AttachShader(hShader, hVertProg); + gl.AttachShader(hShader, hFragProg); + + gl.BindAttribLocation(hShader, VATTR_GLOWDISTANCE, "glowdistance"); + gl.BindAttribLocation(hShader, VATTR_FOGPARAMS, "fogparams"); + gl.BindAttribLocation(hShader, VATTR_LIGHTLEVEL, "lightlevel_in"); // Korshun. + + gl.LinkProgram(hShader); + + gl.GetShaderInfoLog(hVertProg, 10000, NULL, buffer); + if (*buffer) + { + error << "Vertex shader:\n" << buffer << "\n"; + } + gl.GetShaderInfoLog(hFragProg, 10000, NULL, buffer); + if (*buffer) + { + error << "Vertex shader:\n" << buffer << "\n"; + } + + gl.GetProgramInfoLog(hShader, 10000, NULL, buffer); + if (*buffer) + { + error << "Linking:\n" << buffer << "\n"; + } + int linked; + gl.GetObjectParameteriv(hShader, GL_LINK_STATUS, &linked); + if (linked == 0) + { + // only print message if there's an error. + Printf("Init Shader '%s':\n%s\n", name, error.GetChars()); + } + timer_index = gl.GetUniformLocation(hShader, "timer"); + desaturation_index = gl.GetUniformLocation(hShader, "desaturation_factor"); + fogenabled_index = gl.GetUniformLocation(hShader, "fogenabled"); + texturemode_index = gl.GetUniformLocation(hShader, "texturemode"); + camerapos_index = gl.GetUniformLocation(hShader, "camerapos"); + lightparms_index = gl.GetUniformLocation(hShader, "lightparms"); + colormapstart_index = gl.GetUniformLocation(hShader, "colormapstart"); + colormaprange_index = gl.GetUniformLocation(hShader, "colormaprange"); + lightrange_index = gl.GetUniformLocation(hShader, "lightrange"); + fogcolor_index = gl.GetUniformLocation(hShader, "fogcolor"); + lights_index = gl.GetUniformLocation(hShader, "lights"); + dlightcolor_index = gl.GetUniformLocation(hShader, "dlightcolor"); + + glowbottomcolor_index = gl.GetUniformLocation(hShader, "bottomglowcolor"); + glowtopcolor_index = gl.GetUniformLocation(hShader, "topglowcolor"); + + gl.UseProgram(hShader); + + int texture_index = gl.GetUniformLocation(hShader, "texture2"); + if (texture_index > 0) gl.Uniform1i(texture_index, 1); + + gl.UseProgram(0); + return !!linked; + } + return false; +} + +//========================================================================== +// +// +// +//========================================================================== + +FShader::~FShader() +{ + gl.DeleteProgram(hShader); + gl.DeleteShader(hVertProg); + gl.DeleteShader(hFragProg); +} + + +//========================================================================== +// +// +// +//========================================================================== + +bool FShader::Bind(float Speed) +{ + GLRenderer->mShaderManager->SetActiveShader(this); + if (timer_index >=0 && Speed > 0.f) gl.Uniform1f(timer_index, gl_frameMS*Speed/1000.f); + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + +FShaderContainer::FShaderContainer(const char *ShaderName, const char *ShaderPath) +{ + const char * shaderdefines[] = { + "#define NO_GLOW\n#define NO_DESATURATE\n", + "#define NO_DESATURATE\n", + "#define NO_GLOW\n", + "\n", + "#define NO_GLOW\n#define NO_DESATURATE\n#define DYNLIGHT\n", + "#define NO_DESATURATE\n#define DYNLIGHT\n", + "#define NO_GLOW\n#define DYNLIGHT\n", + "\n#define DYNLIGHT\n", + "#define NO_GLOW\n#define NO_DESATURATE\n#define SOFTLIGHT\n", + "#define NO_DESATURATE\n#define SOFTLIGHT\n", + "#define NO_GLOW\n#define SOFTLIGHT\n", + "\n#define SOFTLIGHT\n", + "#define NO_GLOW\n#define NO_DESATURATE\n#define DYNLIGHT\n#define SOFTLIGHT\n", + "#define NO_DESATURATE\n#define DYNLIGHT\n#define SOFTLIGHT\n", + "#define NO_GLOW\n#define DYNLIGHT\n#define SOFTLIGHT\n", + "\n#define DYNLIGHT\n#define SOFTLIGHT\n" + }; + + const char * shaderdesc[] = { + "::default", + "::glow", + "::desaturate", + "::glow+desaturate", + "::default+dynlight", + "::glow+dynlight", + "::desaturate+dynlight", + "::glow+desaturate+dynlight", + "::softlight", + "::glow+softlight", + "::desaturate+softlight", + "::glow+desaturate+softlight", + "::default+dynlight+softlight", + "::glow+dynlight+softlight", + "::desaturate+dynlight+softlight", + "::glow+desaturate+dynlight+softlight", + }; + + FString name; + + name << ShaderName << "::colormap"; + + try + { + shader_cm = new FShader; + if (!shader_cm->Load(name, "shaders/glsl/main.vp", "shaders/glsl/main_colormap.fp", ShaderPath, "#define NO_FOG\n#define NO_GLOW\n")) + { + delete shader_cm; + shader_cm = NULL; + } + } + catch(CRecoverableError &err) + { + shader_cm = NULL; + I_Error("Unable to load shader %s:\n%s\n", name.GetChars(), err.GetMessage()); + } + + if (gl.shadermodel > 2) + { + for(int i = 0;i < NUM_SHADERS; i++) + { + FString name; + + name << ShaderName << shaderdesc[i]; + + try + { + FString str; + if ((i&4) != 0) + { + if (gl.maxuniforms < 1024 || gl.shadermodel != 4) + { + shader[i] = NULL; + continue; + } + // this can't be in the shader code due to ATI strangeness. + str = "#version 120\n#extension GL_EXT_gpu_shader4 : enable\n"; + if (gl.MaxLights() == 128) str += "#define MAXLIGHTS128\n"; + } + if ((i&8) == 0) + { + if (gl.shadermodel != 4) + { + shader[i] = NULL; + continue; + } + } + str += shaderdefines[i]; + shader[i] = new FShader; + if (!shader[i]->Load(name, "shaders/glsl/main.vp", "shaders/glsl/main.fp", ShaderPath, str.GetChars())) + { + delete shader[i]; + shader[i] = NULL; + } + } + catch(CRecoverableError &err) + { + shader[i] = NULL; + I_Error("Unable to load shader %s:\n%s\n", name.GetChars(), err.GetMessage()); + } + } + } + else memset(shader, 0, sizeof(shader)); +} + +//========================================================================== +// +// +// +//========================================================================== +FShaderContainer::~FShaderContainer() +{ + delete shader_cm; + for(int i = 0;i < NUM_SHADERS; i++) + { + if (shader[i] != NULL) + { + delete shader[i]; + shader[i] = NULL; + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +FShader *FShaderContainer::Bind(int cm, bool glowing, float Speed, bool lights) +{ + FShader *sh=NULL; + + if (cm >= CM_FIRSTSPECIALCOLORMAP && cm < CM_MAXCOLORMAP) + { + // these are never used with any kind of lighting or fog + sh = shader_cm; + // [BB] If there was a problem when loading the shader, sh is NULL here. + if( sh ) + { + FSpecialColormap *map = &SpecialColormaps[cm - CM_FIRSTSPECIALCOLORMAP]; + sh->Bind(Speed); + float m[3]= {map->ColorizeEnd[0] - map->ColorizeStart[0], + map->ColorizeEnd[1] - map->ColorizeStart[1], map->ColorizeEnd[2] - map->ColorizeStart[2]}; + + gl.Uniform3fv(sh->colormapstart_index, 1, map->ColorizeStart); + gl.Uniform3fv(sh->colormaprange_index, 1, m); + } + } + else + { + bool desat = cm>=CM_DESAT1 && cm<=CM_DESAT31; + sh = shader[glowing + 2*desat + 4*lights + (glset.lightmode & 8)]; + // [BB] If there was a problem when loading the shader, sh is NULL here. + if( sh ) + { + sh->Bind(Speed); + if (desat) + { + gl.Uniform1f(sh->desaturation_index, 1.f-float(cm-CM_DESAT0)/(CM_DESAT31-CM_DESAT0)); + } + } + } + return sh; +} + + +//========================================================================== +// +// +// +//========================================================================== +struct FDefaultShader +{ + const char * ShaderName; + const char * gettexelfunc; +}; + +// Note: the FIRST_USER_SHADER constant in gl_shader.h needs +// to be updated whenever the size of this array is modified. +static const FDefaultShader defaultshaders[]= +{ + {"Default", "shaders/glsl/func_normal.fp"}, + {"Warp 1", "shaders/glsl/func_warp1.fp"}, + {"Warp 2", "shaders/glsl/func_warp2.fp"}, + {"Brightmap","shaders/glsl/func_brightmap.fp"}, + {"No Texture", "shaders/glsl/func_notexture.fp"}, + {"Basic Fuzz", "shaders/glsl/fuzz_standard.fp"}, + {"Smooth Fuzz", "shaders/glsl/fuzz_smooth.fp"}, + {"Swirly Fuzz", "shaders/glsl/fuzz_swirly.fp"}, + {"Translucent Fuzz", "shaders/glsl/fuzz_smoothtranslucent.fp"}, + {"Jagged Fuzz", "shaders/glsl/fuzz_jagged.fp"}, + {"Noise Fuzz", "shaders/glsl/fuzz_noise.fp"}, + {"Smooth Noise Fuzz", "shaders/glsl/fuzz_smoothnoise.fp"}, + {NULL,NULL} +}; + +static TArray usershaders; + +struct FEffectShader +{ + const char *ShaderName; + const char *vp; + const char *fp1; + const char *fp2; + const char *defines; +}; + +static const FEffectShader effectshaders[]= +{ + {"fogboundary", "shaders/glsl/main.vp", "shaders/glsl/fogboundary.fp", NULL, "#define NO_GLOW\n"}, + {"spheremap", "shaders/glsl/main.vp", "shaders/glsl/main.fp", "shaders/glsl/func_normal.fp", "#define NO_GLOW\n#define NO_DESATURATE\n#define SPHEREMAP\n#define SPHEREMAP_0\n"} +}; + + +//========================================================================== +// +// +// +//========================================================================== + +FShaderManager::FShaderManager() +{ + CompileShaders(); +} + +//========================================================================== +// +// +// +//========================================================================== + +FShaderManager::~FShaderManager() +{ + Clean(); +} + +//========================================================================== +// +// +// +//========================================================================== + +void FShaderManager::Recompile() +{ + Clean(); + CompileShaders(); +} + +//========================================================================== +// +// +// +//========================================================================== + +void FShaderManager::CompileShaders() +{ + mActiveShader = mEffectShaders[0] = mEffectShaders[1] = NULL; + if (gl.shadermodel > 0) + { + for(int i=0;defaultshaders[i].ShaderName != NULL;i++) + { + FShaderContainer * shc = new FShaderContainer(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc); + mTextureEffects.Push(shc); + if (gl.shadermodel <= 2) return; // SM2 will only initialize the default shader + } + + for(unsigned i = 0; i < usershaders.Size(); i++) + { + FString name = ExtractFileBase(usershaders[i]); + FName sfn = name; + + if (gl.shadermodel > 2) + { + FShaderContainer * shc = new FShaderContainer(sfn, usershaders[i]); + mTextureEffects.Push(shc); + } + } + + if (gl.shadermodel > 2) + { + for(int i=0;iLoad(effectshaders[i].ShaderName, effectshaders[i].vp, effectshaders[i].fp1, + effectshaders[i].fp2, effectshaders[i].defines)) + { + delete eff; + } + else mEffectShaders[i] = eff; + } + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FShaderManager::Clean() +{ + SetActiveShader(NULL); + for(unsigned int i=0;iName == sfn) + { + return i; + } + } + return -1; +} + +//========================================================================== +// +// +// +//========================================================================== + +void FShaderManager::SetActiveShader(FShader *sh) +{ + // shadermodel needs to be tested here because without it UseProgram will be NULL. + if (gl.shadermodel > 0 && mActiveShader != sh) + { + gl.UseProgram(sh == NULL? 0 : sh->GetHandle()); + mActiveShader = sh; + } +} + +//========================================================================== +// +// +// +//========================================================================== + +FShader *FShaderManager::BindEffect(int effect) +{ + if (effect > 0 && effect <= NUM_EFFECTS && mEffectShaders[effect-1] != NULL) + { + mEffectShaders[effect-1]->Bind(0); + return mEffectShaders[effect-1]; + } + return NULL; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void gl_DestroyUserShaders() +{ + // todo +} + +//========================================================================== +// +// Parses a shader definition +// +//========================================================================== + +void gl_ParseHardwareShader(FScanner &sc, int deflump) +{ + int type = FTexture::TEX_Any; + bool disable_fullbright=false; + bool thiswad = false; + bool iwad = false; + int maplump = -1; + FString maplumpname; + float speed = 1.f; + + sc.MustGetString(); + if (sc.Compare("texture")) type = FTexture::TEX_Wall; + else if (sc.Compare("flat")) type = FTexture::TEX_Flat; + else if (sc.Compare("sprite")) type = FTexture::TEX_Sprite; + else sc.UnGet(); + + sc.MustGetString(); + FTextureID no = TexMan.CheckForTexture(sc.String, type); + FTexture *tex = TexMan[no]; + + sc.MustGetToken('{'); + while (!sc.CheckToken('}')) + { + sc.MustGetString(); + if (sc.Compare("shader")) + { + sc.MustGetString(); + maplumpname = sc.String; + } + else if (sc.Compare("speed")) + { + sc.MustGetFloat(); + speed = float(sc.Float); + } + } + if (!tex) + { + return; + } + + if (maplumpname.IsNotEmpty()) + { + if (tex->bWarped != 0) + { + Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name); + return; + } + tex->gl_info.shaderspeed = speed; + for(unsigned i=0;igl_info.shaderindex = i + FIRST_USER_SHADER; + return; + } + } + tex->gl_info.shaderindex = usershaders.Push(maplumpname) + FIRST_USER_SHADER; + } +} + diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h new file mode 100644 index 000000000..b43e0aec4 --- /dev/null +++ b/src/gl/shaders/gl_shader.h @@ -0,0 +1,160 @@ + +#ifndef __GL_SHADERS_H__ +#define __GL_SHADERS_H__ + +#include "gl/renderer/gl_renderstate.h" +#include "name.h" + +extern bool gl_shaderactive; + +const int VATTR_GLOWDISTANCE = 15; +const int VATTR_FOGPARAMS = 14; +const int VATTR_LIGHTLEVEL = 13; // Korshun. + +//========================================================================== +// +// +//========================================================================== + +class FShader +{ + friend class FShaderContainer; + friend class FRenderState; + + unsigned int hShader; + unsigned int hVertProg; + unsigned int hFragProg; + + int timer_index; + int desaturation_index; + int fogenabled_index; + int texturemode_index; + int camerapos_index; + int lightparms_index; + int colormapstart_index; + int colormaprange_index; + int lightrange_index; + int fogcolor_index; + int lights_index; + int dlightcolor_index; + + int glowbottomcolor_index; + int glowtopcolor_index; + + int currentfogenabled; + int currenttexturemode; + float currentlightfactor; + float currentlightdist; + + PalEntry currentfogcolor; + float currentfogdensity; + + FStateVec3 currentcamerapos; + +public: + FShader() + { + hShader = hVertProg = hFragProg = 0; + currentfogenabled = currenttexturemode = 0; + currentlightfactor = currentlightdist = 0.0f; + currentfogdensity = -1; + currentfogcolor = 0; + + timer_index = -1; + desaturation_index = -1; + fogenabled_index = -1; + texturemode_index = -1; + camerapos_index = -1; + lightparms_index = -1; + colormapstart_index = -1; + colormaprange_index = -1; + lightrange_index = -1; + fogcolor_index = -1; + lights_index = -1; + dlightcolor_index = -1; + + } + + ~FShader(); + + bool Load(const char * name, const char * vert_prog_lump, const char * fragprog, const char * fragprog2, const char *defines); + + void SetColormapColor(float r, float g, float b, float r1, float g1, float b1); + void SetGlowParams(float *topcolors, float topheight, float *bottomcolors, float bottomheight); + void SetLightRange(int start, int end, int forceadd); + + bool Bind(float Speed); + unsigned int GetHandle() const { return hShader; } + +}; + +//========================================================================== +// +// This class contains the shaders for the different lighting modes +// that are required (e.g. special colormaps etc.) +// +//========================================================================== + +class FShaderContainer +{ + friend class FShaderManager; + + FName Name; + + enum { NUM_SHADERS = 16 }; + + FShader *shader[NUM_SHADERS]; + FShader *shader_cm; // the shader for fullscreen colormaps + +public: + FShaderContainer(const char *ShaderName, const char *ShaderPath); + ~FShaderContainer(); + FShader *Bind(int cm, bool glowing, float Speed, bool lights); + +}; + + +//========================================================================== +// +// The global shader manager +// +//========================================================================== +class FShaderManager +{ + enum + { + NUM_EFFECTS = 2 + }; + + TArray mTextureEffects; + FShader *mActiveShader; + FShader *mEffectShaders[NUM_EFFECTS]; + + void Clean(); + void CompileShaders(); + +public: + FShaderManager(); + ~FShaderManager(); + int Find(const char *mame); + FShader *BindEffect(int effect); + void SetActiveShader(FShader *sh); + + FShaderContainer *Get(unsigned int eff) + { + // indices 0-2 match the warping modes, 3 is brightmap, 4 no texture, the following are custom + if (eff < mTextureEffects.Size()) + { + return mTextureEffects[eff]; + } + return NULL; + } + + void Recompile(); +}; + +#define FIRST_USER_SHADER 12 + + +#endif + diff --git a/src/gl/shaders/gl_texshader.cpp b/src/gl/shaders/gl_texshader.cpp new file mode 100644 index 000000000..f91529909 --- /dev/null +++ b/src/gl/shaders/gl_texshader.cpp @@ -0,0 +1,698 @@ +/* +** gl_shaders.cpp +** Routines parsing/managing texture shaders. +** +**--------------------------------------------------------------------------- +** Copyright 2003 Timothy Stump +** Copyright 2009 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "doomtype.h" +#include "c_cvars.h" +#include "sc_man.h" +#include "textures/textures.h" +#include "gl/shaders/gl_texshader.h" + +CVAR(Bool, gl_texture_useshaders, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) + + +//========================================================================== +// +// +// +//========================================================================== + +FShaderLayer::FShaderLayer() +{ + animate = false; + emissive = false; + blendFuncSrc = GL_SRC_ALPHA; + blendFuncDst = GL_ONE_MINUS_SRC_ALPHA; + offsetX = 0.f; + offsetY = 0.f; + centerX = 0.0f; + centerY = 0.0f; + rotate = 0.f; + rotation = 0.f; + adjustX.SetParams(0.f, 0.f, 0.f); + adjustY.SetParams(0.f, 0.f, 0.f); + scaleX.SetParams(1.f, 1.f, 0.f); + scaleY.SetParams(1.f, 1.f, 0.f); + alpha.SetParams(1.f, 1.f, 0.f); + r.SetParams(1.f, 1.f, 0.f); + g.SetParams(1.f, 1.f, 0.f); + b.SetParams(1.f, 1.f, 0.f); + flags = 0; + layerMask = NULL; + texgen = SHADER_TexGen_None; + warp = false; + warpspeed = 0; +} + +//========================================================================== +// +// +// +//========================================================================== + +FShaderLayer::FShaderLayer(const FShaderLayer &layer) +{ + texture = layer.texture; + animate = layer.animate; + emissive = layer.emissive; + adjustX = layer.adjustX; + adjustY = layer.adjustY; + blendFuncSrc = layer.blendFuncSrc; + blendFuncDst = layer.blendFuncDst; + offsetX = layer.offsetX; + offsetY = layer.offsetY; + centerX = layer.centerX; + centerY = layer.centerX; + rotate = layer.rotate; + rotation = layer.rotation; + scaleX = layer.scaleX; + scaleY = layer.scaleY; + vectorX = layer.vectorX; + vectorY = layer.vectorY; + alpha = layer.alpha; + r = layer.r; + g = layer.g; + b = layer.b; + flags = layer.flags; + if (layer.layerMask) + { + layerMask = new FShaderLayer(*(layer.layerMask)); + } + else + { + layerMask = NULL; + } + texgen = layer.texgen; + warp = layer.warp; + warpspeed = layer.warpspeed; +} + +//========================================================================== +// +// +// +//========================================================================== + +FShaderLayer::~FShaderLayer() +{ + if (layerMask) + { + delete layerMask; + layerMask = NULL; + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FShaderLayer::Update(float diff) +{ + r.Update(diff); + g.Update(diff); + b.Update(diff); + alpha.Update(diff); + vectorY.Update(diff); + vectorX.Update(diff); + scaleX.Update(diff); + scaleY.Update(diff); + adjustX.Update(diff); + adjustY.Update(diff); + srcFactor.Update(diff); + dstFactor.Update(diff); + + offsetX += vectorX * diff; + if (offsetX >= 1.f) offsetX -= 1.f; + if (offsetX < 0.f) offsetX += 1.f; + + offsetY += vectorY * diff; + if (offsetY >= 1.f) offsetY -= 1.f; + if (offsetY < 0.f) offsetY += 1.f; + + rotation += rotate * diff; + if (rotation > 360.f) rotation -= 360.f; + if (rotation < 0.f) rotation += 360.f; + + if (layerMask != NULL) layerMask->Update(diff); +} + +//========================================================================== +// +// +// +//========================================================================== + +struct FParseKey +{ + const char *name; + int value; +}; + +static const FParseKey CycleTags[]= +{ + {"linear", CYCLE_Linear}, + {"sin", CYCLE_Sin}, + {"cos", CYCLE_Cos}, + {"sawtooth", CYCLE_SawTooth}, + {"square", CYCLE_Square}, + {NULL} +}; + +static const FParseKey BlendTags[]= +{ + {"GL_ZERO", GL_ZERO}, + {"GL_ONE", GL_ONE}, + + {"GL_DST_COLOR", GL_DST_COLOR}, + {"GL_ONE_MINUS_DST_COLOR", GL_ONE_MINUS_DST_COLOR}, + {"GL_DST_ALPHA", GL_DST_ALPHA}, + {"GL_ONE_MINUS_DST_ALPHA", GL_ONE_MINUS_DST_ALPHA}, + + {"GL_SRC_COLOR", GL_SRC_COLOR}, + {"GL_ONE_MINUS_SRC_COLOR", GL_ONE_MINUS_SRC_COLOR}, + {"GL_SRC_ALPHA", GL_SRC_ALPHA}, + {"GL_ONE_MINUS_SRC_ALPHA", GL_ONE_MINUS_SRC_ALPHA}, + + {"GL_SRC_ALPHA_SATURATE", GL_SRC_ALPHA_SATURATE}, + {NULL} +}; + + +//========================================================================== +// +// +// +//========================================================================== + +CycleType FShaderLayer::ParseCycleType(FScanner &sc) +{ + if (sc.GetString()) + { + int t = sc.MatchString(&CycleTags[0].name, sizeof(CycleTags[0])); + if (t > -1) return CycleType(CycleTags[t].value); + sc.UnGet(); + } + return CYCLE_Linear; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool FShaderLayer::ParseLayer(FScanner &sc) +{ + bool retval = true; + float start, end, cycle, r1, r2, g1, g2, b1, b2; + int type; + + if (sc.GetString()) + { + texture = TexMan.CheckForTexture(sc.String, FTexture::TEX_Wall); + if (!texture.isValid()) + { + sc.ScriptMessage("Unknown texture '%s'", sc.String); + retval = false; + } + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + if (sc.End) + { + sc.ScriptError("Unexpected end of file encountered"); + return false; + } + + if (sc.Compare("alpha")) + { + if (sc.CheckString("cycle")) + { + alpha.ShouldCycle(true); + alpha.SetCycleType(ParseCycleType(sc)); + + sc.GetFloat(); + start = sc.Float; + sc.GetFloat(); + end = sc.Float; + sc.GetFloat(); + cycle = sc.Float; + + alpha.SetParams(start, end, cycle); + } + else + { + sc.MustGetFloat(); + alpha.SetParams(float(sc.Float), float(sc.Float), 0.f); + } + } + else if (sc.Compare("srcfactor")) + { + if (sc.CheckString("cycle")) + { + srcFactor.ShouldCycle(true); + srcFactor.SetCycleType(ParseCycleType(sc)); + + sc.GetFloat(); + start = sc.Float; + sc.GetFloat(); + end = sc.Float; + sc.GetFloat(); + cycle = sc.Float; + + srcFactor.SetParams(start, end, cycle); + } + else + { + sc.MustGetFloat(); + srcFactor.SetParams(float(sc.Float), float(sc.Float), 0.f); + } + } + if (sc.Compare("destfactor")) + { + if (sc.CheckString("cycle")) + { + dstFactor.ShouldCycle(true); + dstFactor.SetCycleType(ParseCycleType(sc)); + + sc.GetFloat(); + start = sc.Float; + sc.GetFloat(); + end = sc.Float; + sc.GetFloat(); + cycle = sc.Float; + + dstFactor.SetParams(start, end, cycle); + } + else + { + sc.MustGetFloat(); + dstFactor.SetParams(float(sc.Float), float(sc.Float), 0.f); + } + } + else if (sc.Compare("animate")) + { + sc.GetString(); + animate = sc.Compare("true"); + } + else if (sc.Compare("blendfunc")) + { + sc.GetString(); + type = sc.MustMatchString(&BlendTags[0].name, sizeof(BlendTags[0])); + blendFuncSrc = type;// BlendTags[type].value; + + sc.GetString(); + type = sc.MustMatchString(&BlendTags[0].name, sizeof(BlendTags[0])); + blendFuncDst = type; //BlendTags[type].value; + } + else if (sc.Compare("color")) + { + if (sc.CheckString("cycle")) + { + CycleType type = ParseCycleType(sc); + r.ShouldCycle(true); + g.ShouldCycle(true); + b.ShouldCycle(true); + r.SetCycleType(type); + g.SetCycleType(type); + b.SetCycleType(type); + + sc.GetFloat(); + r1 = float(sc.Float); + sc.GetFloat(); + g1 = float(sc.Float); + sc.GetFloat(); + b1 = float(sc.Float); + + // get color2 + sc.GetFloat(); + r2 = float(sc.Float); + sc.GetFloat(); + g2 = float(sc.Float); + sc.GetFloat(); + b2 = float(sc.Float); + + // get cycle time + sc.GetFloat(); + cycle = sc.Float; + + r.SetParams(r1, r2, cycle); + g.SetParams(g1, g2, cycle); + b.SetParams(b1, b2, cycle); + } + else + { + sc.GetFloat(); + r1 = float(sc.Float); + sc.GetFloat(); + g1 = sc.Float; + sc.GetFloat(); + b1 = sc.Float; + + r.SetParams(r1, r1, 0.f); + g.SetParams(g1, g1, 0.f); + b.SetParams(b1, b1, 0.f); + } + } + else if (sc.Compare("center")) + { + sc.GetFloat(); + centerX = sc.Float; + sc.GetFloat(); + centerY = sc.Float; + } + else if (sc.Compare("emissive")) + { + sc.GetString(); + emissive = sc.Compare("true"); + } + else if (sc.Compare("offset")) + { + if (sc.CheckString("cycle")) + { + adjustX.ShouldCycle(true); + adjustY.ShouldCycle(true); + + sc.GetFloat(); + r1 = sc.Float; + sc.GetFloat(); + r2 = sc.Float; + + sc.GetFloat(); + g1 = sc.Float; + sc.GetFloat(); + g2 = sc.Float; + + sc.GetFloat(); + cycle = sc.Float; + + offsetX = r1; + offsetY = r2; + + adjustX.SetParams(0.f, g1 - r1, cycle); + adjustY.SetParams(0.f, g2 - r2, cycle); + } + else + { + sc.GetFloat(); + offsetX = sc.Float; + sc.GetFloat(); + offsetY = sc.Float; + } + } + else if (sc.Compare("offsetfunc")) + { + adjustX.SetCycleType(ParseCycleType(sc)); + adjustY.SetCycleType(ParseCycleType(sc)); + } + else if (sc.Compare("mask")) + { + if (layerMask != NULL) delete layerMask; + layerMask = new FShaderLayer; + layerMask->ParseLayer(sc); + } + else if (sc.Compare("rotate")) + { + sc.GetFloat(); + rotate = sc.Float; + } + else if (sc.Compare("rotation")) + { + sc.GetFloat(); + rotation = sc.Float; + } + else if (sc.Compare("scale")) + { + if (sc.CheckString("cycle")) + { + scaleX.ShouldCycle(true); + scaleY.ShouldCycle(true); + + sc.GetFloat(); + r1 = sc.Float; + sc.GetFloat(); + r2 = sc.Float; + + sc.GetFloat(); + g1 = sc.Float; + sc.GetFloat(); + g2 = sc.Float; + + sc.GetFloat(); + cycle = sc.Float; + + scaleX.SetParams(r1, g1, cycle); + scaleY.SetParams(r2, g2, cycle); + } + else + { + sc.GetFloat(); + scaleX.SetParams(sc.Float, sc.Float, 0.f); + sc.GetFloat(); + scaleY.SetParams(sc.Float, sc.Float, 0.f); + } + } + else if (sc.Compare("scalefunc")) + { + scaleX.SetCycleType(ParseCycleType(sc)); + scaleY.SetCycleType(ParseCycleType(sc)); + } + else if (sc.Compare("texgen")) + { + sc.MustGetString(); + if (sc.Compare("sphere")) + { + texgen = SHADER_TexGen_Sphere; + } + else + { + texgen = SHADER_TexGen_None; + } + } + else if (sc.Compare("vector")) + { + if (sc.CheckString("cycle")) + { + vectorX.ShouldCycle(true); + vectorY.ShouldCycle(true); + + sc.GetFloat(); + r1 = sc.Float; + sc.GetFloat(); + g1 = sc.Float; + sc.GetFloat(); + r2 = sc.Float; + sc.GetFloat(); + g2 = sc.Float; + sc.GetFloat(); + cycle = sc.Float; + + vectorX.SetParams(r1, r2, cycle); + vectorY.SetParams(g1, g2, cycle); + } + else + { + sc.GetFloat(); + vectorX.SetParams(sc.Float, sc.Float, 0.f); + sc.GetFloat(); + vectorY.SetParams(sc.Float, sc.Float, 0.f); + } + } + else if (sc.Compare("vectorfunc")) + { + vectorX.SetCycleType(ParseCycleType(sc)); + vectorY.SetCycleType(ParseCycleType(sc)); + } + else if (sc.Compare("warp")) + { + if (sc.CheckNumber()) + { + warp = sc.Number >= 0 && sc.Number <= 2? sc.Number : 0; + } + else + { + // compatibility with ZDoomGL + sc.MustGetString(); + warp = sc.Compare("true"); + } + } + else + { + sc.ScriptError("Unknown keyword '%s' in shader layer", sc.String); + } + } + } + return retval; +} + +//========================================================================== +// +// +// +//========================================================================== + +FTextureShader::FTextureShader() +{ + layers.Clear(); + lastUpdate = 0; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool FTextureShader::ParseShader(FScanner &sc, TArray &names) +{ + bool retval = true; + + if (sc.GetString()) + { + name = sc.String; + + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + if (sc.End) + { + sc.ScriptError("Unexpected end of file encountered"); + return false; + } + else if (sc.Compare("layer")) + { + FShaderLayer *lay = new FShaderLayer; + if (lay->ParseLayer(sc)) + { + if (layers.Size() < 8) + { + layers.Push(lay); + } + else + { + delete lay; + sc.ScriptMessage("Only 8 layers per texture allowed."); + } + } + else + { + delete lay; + retval = false; + } + } + else + { + sc.ScriptError("Unknown keyword '%s' in shader", sc.String); + } + } + } + return retval; +} + +//========================================================================== +// +// +// +//========================================================================== + +void FTextureShader::Update(int framems) +{ + float diff = (framems - lastUpdate) / 1000.f; + + if (lastUpdate != 0) // && !paused && !bglobal.freeze) + { + for (unsigned int i = 0; i < layers.Size(); i++) + { + layers[i]->Update(diff); + } + } + lastUpdate = framems; +} + +//========================================================================== +// +// +// +//========================================================================== + +void FTextureShader::FakeUpdate(int framems) +{ + lastUpdate = framems; +} + +//========================================================================== +// +// +// +//========================================================================== + +FString FTextureShader::CreateName() +{ + FString compose = "custom"; + for(unsigned i=0; iemissive, + layers[i]->blendFuncSrc, layers[i]->blendFuncDst, layers[i]->texgen, layers[i]->warp); + } + return compose; +} + +//========================================================================== +// +// +// +//========================================================================== + +FString FTextureShader::GenerateCode() +{ + static const char *funcnames[] = {"gettexel", "getwarp1", "getwarp2" }; + static const char *srcblend[] = { "vec4(0.0)", "src", "src*dest", "1.0-src*dest", "src*dest.a", "1.0-src*dest.a", + "src*src", "1.0-src*src", "src*src.a", "1.0-src*src", "vec4(src.rgb*src.a, 1)" }; + static const char *dstblend[] = { "vec4(0.0)", "dest", "dest*dest", "1.0-dest*dest", "dest*dest.a", "1.0-dest*dest.a", + "dest*src", "1.0-dest*src", "dest*src.a", "1.0-dest*src", "vec4(dest.rgb*src.a, 1)" }; + FString compose; + for(unsigned i=0; iwarp], i+1, i, i); + if (!layers[i]->emissive) compose.AppendFormat("src.rgb *= gl_Color.rgb;\n"); + compose.AppendFormat("dest = (%s)*srcfactor + (%s)*dstfactor;\n", + srcblend[layers[i]->blendFuncSrc], dstblend[layers[i]->blendFuncDst]); + } + return compose; +} + diff --git a/src/gl/shaders/gl_texshader.h b/src/gl/shaders/gl_texshader.h new file mode 100644 index 000000000..b3e90bf56 --- /dev/null +++ b/src/gl/shaders/gl_texshader.h @@ -0,0 +1,96 @@ + +#ifndef __GL_TEXSHADERS_H__ +#define __GL_TEXSHADERS_H__ + + +#include "tarray.h" +#include "zstring.h" +#include "gl/utility/gl_cycler.h" + + +enum +{ + SHADER_TexGen_None = 0, + SHADER_TexGen_Sphere, + NUM_TexGenTypes +}; + + +//========================================================================== +// +// +// +//========================================================================== + +class FShaderLayer +{ +public: + FShaderLayer(); + FShaderLayer(const FShaderLayer &layer); + ~FShaderLayer(); + void Update(float diff); + CycleType ParseCycleType(FScanner &sc); + bool ParseLayer(FScanner &sc); + + FTextureID texture; + int warpspeed; + unsigned char warp; + bool animate; + bool emissive; + unsigned char texgen; + float centerX, centerY; + float rotation; + float rotate; + float offsetX, offsetY; + FCycler adjustX, adjustY; + FCycler vectorX, vectorY; + FCycler scaleX, scaleY; + FCycler alpha; + FCycler r, g, b; + FCycler srcFactor, dstFactor; + unsigned int flags; + unsigned int blendFuncSrc, blendFuncDst; + FShaderLayer *layerMask; +}; + +//========================================================================== +// +// +// +//========================================================================== + +class FTextureShader +{ +public: + FTextureShader(); + bool ParseShader(FScanner &sc, TArray &names); + bool Available(); + bool Setup(float time); + void Update(int framems); + void FakeUpdate(int framems); + FString CreateName(); + FString GenerateCode(); + + FName name; + TDeletingArray layers; // layers for shader + unsigned int lastUpdate; +}; + + +/* +//extern TArray Shaders[NUM_ShaderClasses]; +//extern TArray ShaderLookup[NUM_ShaderClasses]; + +void GL_InitShaders(); +void GL_ReleaseShaders(); +void GL_UpdateShaders(); +void GL_FakeUpdateShaders(); +//void GL_UpdateShader(FShader *shader); +void GL_DrawShaders(); +//FShader *GL_ShaderForTexture(FTexture *tex); + +bool GL_ParseShader(); +*/ + + +#endif // __GL_TEXSHADERS_H__ diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h new file mode 100644 index 000000000..4e8aa85fd --- /dev/null +++ b/src/gl/system/gl_cvars.h @@ -0,0 +1,59 @@ + + +#ifndef _GL_INTERN_H +#define _GL_INTERN_H + +#include "r_defs.h" +#include "c_cvars.h" + +#ifdef _MSC_VER +#pragma warning(disable:4244) +#endif + +EXTERN_CVAR(Bool, gl_warp_shader) +EXTERN_CVAR(Bool, gl_fog_shader) +EXTERN_CVAR(Bool, gl_colormap_shader) +EXTERN_CVAR(Bool, gl_brightmap_shader) +EXTERN_CVAR(Bool, gl_glow_shader) + +EXTERN_CVAR(Bool, gl_vid_compatibility) +EXTERN_CVAR(Bool,gl_enhanced_nightvision) +EXTERN_CVAR(Int, screenblocks); +EXTERN_CVAR(Bool, gl_texture) +EXTERN_CVAR(Int, gl_texture_filter) +EXTERN_CVAR(Float, gl_texture_filter_anisotropic) +EXTERN_CVAR(Int, gl_texture_format) +EXTERN_CVAR(Bool, gl_texture_usehires) +EXTERN_CVAR(Bool, gl_usefb) + +EXTERN_CVAR(Int, gl_weaponlight) + +EXTERN_CVAR(Bool, gl_forcemultipass) + +EXTERN_CVAR (Bool, gl_lights); +EXTERN_CVAR (Bool, gl_attachedlights); +EXTERN_CVAR (Bool, gl_lights_checkside); +EXTERN_CVAR (Float, gl_lights_intensity); +EXTERN_CVAR (Float, gl_lights_size); +EXTERN_CVAR (Bool, gl_lights_additive); +EXTERN_CVAR (Bool, gl_light_sprites); +EXTERN_CVAR (Bool, gl_light_particles); + +EXTERN_CVAR(Int, gl_fogmode) +EXTERN_CVAR(Int, gl_lightmode) +EXTERN_CVAR(Bool,gl_mirror_envmap) + +EXTERN_CVAR(Bool,gl_mirrors) +EXTERN_CVAR(Bool,gl_mirror_envmap) +EXTERN_CVAR(Bool, gl_render_segs) +EXTERN_CVAR(Bool, gl_seamless) +EXTERN_CVAR(Bool, gl_dynlight_shader) + +EXTERN_CVAR(Float, gl_mask_threshold) +EXTERN_CVAR(Float, gl_mask_sprite_threshold) + +EXTERN_CVAR(Int, gl_usevbo) + + + +#endif // _GL_INTERN_H diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp new file mode 100644 index 000000000..0409151a9 --- /dev/null +++ b/src/gl/system/gl_framebuffer.cpp @@ -0,0 +1,559 @@ +/* +** gl_framebuffer.cpp +** Implementation of the non-hardware specific parts of the +** OpenGL frame buffer +** +**--------------------------------------------------------------------------- +** Copyright 2000-2007 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "doomstat.h" +#include "m_png.h" +#include "m_crc32.h" +#include "vectors.h" +#include "v_palette.h" +#include "templates.h" +#include "farchive.h" + +#include "gl/system/gl_framebuffer.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/data/gl_data.h" +#include "gl/textures/gl_hwtexture.h" +#include "gl/textures/gl_texture.h" +#include "gl/textures/gl_translate.h" +#include "gl/textures/gl_skyboxtexture.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_templates.h" +#include "gl/gl_functions.h" + +IMPLEMENT_CLASS(OpenGLFrameBuffer) +EXTERN_CVAR (Float, vid_brightness) +EXTERN_CVAR (Float, vid_contrast) +EXTERN_CVAR (Bool, vid_vsync) + +CVAR(Bool, gl_aalines, false, CVAR_ARCHIVE) + +FGLRenderer *GLRenderer; + +void gl_SetupMenu(); + +//========================================================================== +// +// +// +//========================================================================== + +OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : + Super(hMonitor, width, height, bits, refreshHz, fullscreen) +{ + GLRenderer = new FGLRenderer(this); + memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256); + UpdatePalette (); + ScreenshotBuffer = NULL; + LastCamera = NULL; + + InitializeState(); + gl_SetupMenu(); + gl_GenerateGlobalBrightmapFromColormap(); + DoSetGamma(); + needsetgamma = true; + swapped = false; + Accel2D = true; + if (gl.SetVSync!=NULL) gl.SetVSync(vid_vsync); +} + +OpenGLFrameBuffer::~OpenGLFrameBuffer() +{ + delete GLRenderer; + GLRenderer = NULL; +} + +//========================================================================== +// +// Initializes the GL renderer +// +//========================================================================== + +void OpenGLFrameBuffer::InitializeState() +{ + static bool first=true; + + gl.LoadExtensions(); + Super::InitializeState(); + if (first) + { + first=false; + // [BB] For some reason this crashes, if compiled with MinGW and optimization. Has to be investigated. +#ifdef _MSC_VER + gl.PrintStartupLog(); +#endif + + if (gl.flags&RFL_NPOT_TEXTURE) + { + Printf("Support for non power 2 textures enabled.\n"); + } + if (gl.flags&RFL_OCCLUSION_QUERY) + { + Printf("Occlusion query enabled.\n"); + } + } + gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.ClearDepth(1.0f); + gl.DepthFunc(GL_LESS); + gl.ShadeModel(GL_SMOOTH); + + gl.Enable(GL_DITHER); + gl.Enable(GL_ALPHA_TEST); + gl.Disable(GL_CULL_FACE); + gl.Disable(GL_POLYGON_OFFSET_FILL); + gl.Enable(GL_POLYGON_OFFSET_LINE); + gl.Enable(GL_BLEND); + gl.Enable(GL_DEPTH_CLAMP_NV); + gl.Disable(GL_DEPTH_TEST); + gl.Enable(GL_TEXTURE_2D); + gl.Disable(GL_LINE_SMOOTH); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glAlphaFunc(GL_GEQUAL,0.5f); + gl.Hint(GL_LINE_SMOOTH_HINT, GL_NICEST); + gl.Hint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); + gl.Hint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + + // This was to work around a bug in some older driver. Probably doesn't make sense anymore. + gl.Enable(GL_FOG); + gl.Disable(GL_FOG); + + gl.Hint(GL_FOG_HINT, GL_FASTEST); + gl.Fogi(GL_FOG_MODE, GL_EXP); + + + gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + int trueH = GetTrueHeight(); + int h = GetHeight(); + gl.Viewport(0, (trueH - h)/2, GetWidth(), GetHeight()); + + Begin2D(false); + GLRenderer->Initialize(); +} + +//========================================================================== +// +// Updates the screen +// +//========================================================================== + +// Testing only for now. +CVAR(Bool, gl_draw_sync, true, 0) //false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) + +void OpenGLFrameBuffer::Update() +{ + if (!CanUpdate()) + { + GLRenderer->Flush(); + return; + } + + Begin2D(false); + + DrawRateStuff(); + GLRenderer->Flush(); + + if (GetTrueHeight() != GetHeight()) + { + if (GLRenderer != NULL) + GLRenderer->ClearBorders(); + + Begin2D(false); + } + if (gl_draw_sync || !swapped) + { + Swap(); + } + swapped = false; + Unlock(); + CheckBench(); +} + + +//========================================================================== +// +// Swap the buffers +// +//========================================================================== + +void OpenGLFrameBuffer::Swap() +{ + Finish.Reset(); + Finish.Clock(); + gl.Finish(); + if (needsetgamma) + { + //DoSetGamma(); + needsetgamma = false; + } + gl.SwapBuffers(); + Finish.Unclock(); + swapped = true; + FHardwareTexture::UnbindAll(); +} + +//=========================================================================== +// +// DoSetGamma +// +// (Unfortunately Windows has some safety precautions that block gamma ramps +// that are considered too extreme. As a result this doesn't work flawlessly) +// +//=========================================================================== + +void OpenGLFrameBuffer::DoSetGamma() +{ + WORD gammaTable[768]; + + if (m_supportsGamma) + { + // This formula is taken from Doomsday + float gamma = clamp(Gamma, 0.1f, 4.f); + float contrast = clamp(vid_contrast, 0.1f, 3.f); + float bright = clamp(vid_brightness, -0.8f, 0.8f); + + double invgamma = 1 / gamma; + double norm = pow(255., invgamma - 1); + + for (int i = 0; i < 256; i++) + { + double val = i * contrast - (contrast - 1) * 127; + if(gamma != 1) val = pow(val, invgamma) / norm; + val += bright * 128; + + gammaTable[i] = gammaTable[i + 256] = gammaTable[i + 512] = (WORD)clamp(val*256, 0, 0xffff); + } + SetGammaTable(gammaTable); + } +} + +bool OpenGLFrameBuffer::SetGamma(float gamma) +{ + DoSetGamma(); + return true; +} + +bool OpenGLFrameBuffer::SetBrightness(float bright) +{ + DoSetGamma(); + return true; +} + +bool OpenGLFrameBuffer::SetContrast(float contrast) +{ + DoSetGamma(); + return true; +} + +//=========================================================================== +// +// +//=========================================================================== + +void OpenGLFrameBuffer::UpdatePalette() +{ + int rr=0,gg=0,bb=0; + for(int x=0;x<256;x++) + { + rr+=GPalette.BaseColors[x].r; + gg+=GPalette.BaseColors[x].g; + bb+=GPalette.BaseColors[x].b; + } + rr>>=8; + gg>>=8; + bb>>=8; + + palette_brightness = (rr*77 + gg*143 + bb*35)/255; +} + +void OpenGLFrameBuffer::GetFlashedPalette (PalEntry pal[256]) +{ + memcpy(pal, SourcePalette, 256*sizeof(PalEntry)); +} + +PalEntry *OpenGLFrameBuffer::GetPalette () +{ + return SourcePalette; +} + +bool OpenGLFrameBuffer::SetFlash(PalEntry rgb, int amount) +{ + Flash = PalEntry(amount, rgb.r, rgb.g, rgb.b); + return true; +} + +void OpenGLFrameBuffer::GetFlash(PalEntry &rgb, int &amount) +{ + rgb = Flash; + rgb.a = 0; + amount = Flash.a; +} + +int OpenGLFrameBuffer::GetPageCount() +{ + return 1; +} + + +void OpenGLFrameBuffer::GetHitlist(BYTE *hitlist) +{ + Super::GetHitlist(hitlist); + + // check skybox textures and mark the separate faces as used + for(int i=0;igl_info.bSkybox) + { + FSkyBox *sb = static_cast(tex); + for(int i=0;i<6;i++) + { + if (sb->faces[i]) + { + int index = sb->faces[i]->id.GetIndex(); + hitlist[index] |= 1; + } + } + } + } + } + + + // check model skins +} + +//========================================================================== +// +// DFrameBuffer :: CreatePalette +// +// Creates a native palette from a remap table, if supported. +// +//========================================================================== + +FNativePalette *OpenGLFrameBuffer::CreatePalette(FRemapTable *remap) +{ + return GLTranslationPalette::CreatePalette(remap); +} + +//========================================================================== +// +// +// +//========================================================================== +bool OpenGLFrameBuffer::Begin2D(bool) +{ + gl.MatrixMode(GL_MODELVIEW); + gl.LoadIdentity(); + gl.MatrixMode(GL_PROJECTION); + gl.LoadIdentity(); + gl.Ortho( + (GLdouble) 0, + (GLdouble) GetWidth(), + (GLdouble) GetHeight(), + (GLdouble) 0, + (GLdouble) -1.0, + (GLdouble) 1.0 + ); + gl.Disable(GL_DEPTH_TEST); + + // Korshun: ENABLE AUTOMAP ANTIALIASING!!! + if (gl_aalines) + gl.Enable(GL_LINE_SMOOTH); + else + { + gl.Disable(GL_MULTISAMPLE); + gl.Disable(GL_LINE_SMOOTH); + glLineWidth(1.0); + } + + if (GLRenderer != NULL) + GLRenderer->Begin2D(); + return true; +} + +//========================================================================== +// +// Draws a texture +// +//========================================================================== + +void STACK_ARGS OpenGLFrameBuffer::DrawTextureV(FTexture *img, double x0, double y0, uint32 tag, va_list tags) +{ + DrawParms parms; + + if (ParseDrawTextureTags(img, x0, y0, tag, tags, &parms, true)) + { + if (GLRenderer != NULL) GLRenderer->DrawTexture(img, parms); + } +} + +//========================================================================== +// +// +// +//========================================================================== +void OpenGLFrameBuffer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color) +{ + if (GLRenderer != NULL) + GLRenderer->DrawLine(x1, y1, x2, y2, palcolor, color); +} + +//========================================================================== +// +// +// +//========================================================================== +void OpenGLFrameBuffer::DrawPixel(int x1, int y1, int palcolor, uint32 color) +{ + if (GLRenderer != NULL) + GLRenderer->DrawPixel(x1, y1, palcolor, color); +} + +//========================================================================== +// +// +// +//========================================================================== +void OpenGLFrameBuffer::Dim(PalEntry) +{ + // Unlike in the software renderer the color is being ignored here because + // view blending only affects the actual view with the GL renderer. + Super::Dim(0); +} + +void OpenGLFrameBuffer::Dim(PalEntry color, float damount, int x1, int y1, int w, int h) +{ + if (GLRenderer != NULL) + GLRenderer->Dim(color, damount, x1, y1, w, h); +} + +//========================================================================== +// +// +// +//========================================================================== +void OpenGLFrameBuffer::FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin) +{ + + if (GLRenderer != NULL) + GLRenderer->FlatFill(left, top, right, bottom, src, local_origin); +} + +//========================================================================== +// +// +// +//========================================================================== +void OpenGLFrameBuffer::Clear(int left, int top, int right, int bottom, int palcolor, uint32 color) +{ + if (GLRenderer != NULL) + GLRenderer->Clear(left, top, right, bottom, palcolor, color); +} + +//========================================================================== +// +// D3DFB :: FillSimplePoly +// +// Here, "simple" means that a simple triangle fan can draw it. +// +//========================================================================== + +void OpenGLFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, + double originx, double originy, double scalex, double scaley, + angle_t rotation, FDynamicColormap *colormap, int lightlevel) +{ + if (GLRenderer != NULL) + { + GLRenderer->FillSimplePoly(texture, points, npoints, originx, originy, scalex, scaley, + rotation, colormap, lightlevel); + } +} + + +//=========================================================================== +// +// Takes a screenshot +// +//=========================================================================== + +void OpenGLFrameBuffer::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type) +{ + int w = SCREENWIDTH; + int h = SCREENHEIGHT; + + ReleaseScreenshotBuffer(); + ScreenshotBuffer = new BYTE[w * h * 3]; + + glPixelStorei(GL_PACK_ALIGNMENT, 1); + gl.ReadPixels(0,(GetTrueHeight() - GetHeight()) / 2,w,h,GL_RGB,GL_UNSIGNED_BYTE,ScreenshotBuffer); + glPixelStorei(GL_PACK_ALIGNMENT, 4); + pitch = -w*3; + color_type = SS_RGB; + buffer = ScreenshotBuffer + w * 3 * (h - 1); +} + +//=========================================================================== +// +// Releases the screenshot buffer. +// +//=========================================================================== + +void OpenGLFrameBuffer::ReleaseScreenshotBuffer() +{ + if (ScreenshotBuffer != NULL) delete [] ScreenshotBuffer; + ScreenshotBuffer = NULL; +} + + +void OpenGLFrameBuffer::GameRestart() +{ + memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256); + UpdatePalette (); + ScreenshotBuffer = NULL; + LastCamera = NULL; + gl_GenerateGlobalBrightmapFromColormap(); +} \ No newline at end of file diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h new file mode 100644 index 000000000..c2a4fc277 --- /dev/null +++ b/src/gl/system/gl_framebuffer.h @@ -0,0 +1,117 @@ +#ifndef __GL_FRAMEBUFFER +#define __GL_FRAMEBUFFER + +#ifdef _WIN32 +#include "win32iface.h" +#include "win32gliface.h" +#endif + +class FHardwareTexture; + +extern long gl_frameMS; +extern long gl_frameCount; +#ifdef _WIN32 +class OpenGLFrameBuffer : public Win32GLFrameBuffer +{ + typedef Win32GLFrameBuffer Super; + DECLARE_CLASS(OpenGLFrameBuffer, Win32GLFrameBuffer) +#else +#include "sdlglvideo.h" +class OpenGLFrameBuffer : public SDLGLFB +{ +// typedef SDLGLFB Super; //[C]commented, DECLARE_CLASS defines this in linux + DECLARE_CLASS(OpenGLFrameBuffer, SDLGLFB) +#endif + + +public: + + explicit OpenGLFrameBuffer() {} + OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) ; + ~OpenGLFrameBuffer(); + + void InitializeState(); + void Update(); + + // Color correction + bool SetGamma (float gamma); + bool SetBrightness(float bright); + bool SetContrast(float contrast); + void DoSetGamma(); + + void UpdatePalette(); + void GetFlashedPalette (PalEntry pal[256]); + PalEntry *GetPalette (); + bool SetFlash(PalEntry rgb, int amount); + void GetFlash(PalEntry &rgb, int &amount); + int GetPageCount(); + bool Begin2D(bool copy3d); + void GetHitlist(BYTE *hitlist); + void GameRestart(); + + // Retrieves a buffer containing image data for a screenshot. + // Hint: Pitch can be negative for upside-down images, in which case buffer + // points to the last row in the buffer, which will be the first row output. + virtual void GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type); + + // Releases the screenshot buffer. + virtual void ReleaseScreenshotBuffer(); + + // 2D drawing + void STACK_ARGS DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags); + void DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color); + void DrawPixel(int x1, int y1, int palcolor, uint32 color); + void Clear(int left, int top, int right, int bottom, int palcolor, uint32 color); + void Dim(PalEntry color=0); + void Dim (PalEntry color, float damount, int x1, int y1, int w, int h); + void FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin=false); + + void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, + double originx, double originy, double scalex, double scaley, + angle_t rotation, FDynamicColormap *colormap, int lightlevel); + + FNativePalette *CreatePalette(FRemapTable *remap); + + bool WipeStartScreen(int type); + void WipeEndScreen(); + bool WipeDo(int ticks); + void WipeCleanup(); + void Swap(); + bool Is8BitMode() { return false; } + + +private: + PalEntry Flash; + + // Texture creation info + int cm; + int translation; + bool iscomplex; + bool needsetgamma; + bool swapped; + + PalEntry SourcePalette[256]; + BYTE *ScreenshotBuffer; + + class Wiper + { + public: + virtual ~Wiper(); + virtual bool Run(int ticks, OpenGLFrameBuffer *fb) = 0; + }; + + class Wiper_Melt; friend class Wiper_Melt; + class Wiper_Burn; friend class Wiper_Burn; + class Wiper_Crossfade; friend class Wiper_Crossfade; + + Wiper *ScreenWipe; + FHardwareTexture *wipestartscreen; + FHardwareTexture *wipeendscreen; + +public: + AActor * LastCamera; + int palette_brightness; +}; + + +#endif //__GL_FRAMEBUFFER diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp new file mode 100644 index 000000000..e3234e947 --- /dev/null +++ b/src/gl/system/gl_interface.cpp @@ -0,0 +1,1084 @@ +/* +** r_opengl.cpp +** +** OpenGL system interface +** +**--------------------------------------------------------------------------- +** Copyright 2005 Tim Stump +** Copyright 2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ +#include "gl/system/gl_system.h" +#include "tarray.h" +#include "doomtype.h" +#include "m_argv.h" +#include "zstring.h" +#include "version.h" +#include "i_system.h" +#include "gl/system/gl_cvars.h" + +#if defined (unix) || defined (__APPLE__) +#include +#define wglGetProcAddress(x) (*SDL_GL_GetProcAddress)(x) +#endif +static void APIENTRY glBlendEquationDummy (GLenum mode); + + +#if !defined (unix) && !defined (__APPLE__) +PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB; // = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); +PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; +#endif + +static TArray m_Extensions; + +#if !defined (unix) && !defined (__APPLE__) +HWND m_Window; +HDC m_hDC; +HGLRC m_hRC; +#endif + +#define gl pgl + +RenderContext * gl; + +int occlusion_type=0; + + +//========================================================================== +// +// +// +//========================================================================== + +#if !defined (unix) && !defined (__APPLE__) +static HWND InitDummy() +{ + HMODULE g_hInst = GetModuleHandle(NULL); + HWND dummy; + //Create a rect structure for the size/position of the window + RECT windowRect; + windowRect.left = 0; + windowRect.right = 64; + windowRect.top = 0; + windowRect.bottom = 64; + + //Window class structure + WNDCLASS wc; + + //Fill in window class struct + wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wc.lpfnWndProc = (WNDPROC) DefWindowProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = g_hInst; + wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = "GZDoomOpenGLDummyWindow"; + + //Register window class + if(!RegisterClass(&wc)) + { + return 0; + } + + //Set window style & extended style + DWORD style, exStyle; + exStyle = WS_EX_CLIENTEDGE; + style = WS_SYSMENU | WS_BORDER | WS_CAPTION;// | WS_VISIBLE; + + //Adjust the window size so that client area is the size requested + AdjustWindowRectEx(&windowRect, style, false, exStyle); + + //Create Window + if(!(dummy = CreateWindowEx(exStyle, + "GZDoomOpenGLDummyWindow", + "GZDOOM", + WS_CLIPSIBLINGS | WS_CLIPCHILDREN | style, + 0, 0, + windowRect.right-windowRect.left, + windowRect.bottom-windowRect.top, + NULL, NULL, + g_hInst, + NULL))) + { + UnregisterClass("GZDoomOpenGLDummyWindow", g_hInst); + return 0; + } + ShowWindow(dummy, SW_HIDE); + + return dummy; +} + +//========================================================================== +// +// +// +//========================================================================== + +static void ShutdownDummy(HWND dummy) +{ + DestroyWindow(dummy); + UnregisterClass("GZDoomOpenGLDummyWindow", GetModuleHandle(NULL)); +} + + +//========================================================================== +// +// +// +//========================================================================== + +static bool ReadInitExtensions() +{ + HDC hDC; + HGLRC hRC; + HWND dummy; + + PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), + 1, + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, + PFD_TYPE_RGBA, + 32, // color depth + 0, 0, 0, 0, 0, 0, + 0, + 0, + 0, + 0, 0, 0, 0, + 16, // z depth + 0, // stencil buffer + 0, + PFD_MAIN_PLANE, + 0, + 0, 0, 0 + }; + + int pixelFormat; + + // we have to create a dummy window to init stuff from or the full init stuff fails + dummy = InitDummy(); + + hDC = GetDC(dummy); + pixelFormat = ChoosePixelFormat(hDC, &pfd); + DescribePixelFormat(hDC, pixelFormat, sizeof(pfd), &pfd); + + SetPixelFormat(hDC, pixelFormat, &pfd); + + hRC = wglCreateContext(hDC); + wglMakeCurrent(hDC, hRC); + + wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); + wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); + // any extra stuff here? + + wglMakeCurrent(NULL, NULL); + wglDeleteContext(hRC); + ReleaseDC(dummy, hDC); + ShutdownDummy(dummy); + + return true; +} +#endif + +//========================================================================== +// +// +// +//========================================================================== +const char *wgl_extensions; + +static void CollectExtensions() +{ + const char *supported = NULL; + char *extensions, *extension; + + supported = (char *)glGetString(GL_EXTENSIONS); + + if (supported) + { + extensions = new char[strlen(supported) + 1]; + strcpy(extensions, supported); + + extension = strtok(extensions, " "); + while(extension) + { + m_Extensions.Push(FString(extension)); + extension = strtok(NULL, " "); + } + + delete [] extensions; + } +} + +//========================================================================== +// +// +// +//========================================================================== + +static bool CheckExtension(const char *ext) +{ + for (unsigned int i = 0; i < m_Extensions.Size(); ++i) + { + if (m_Extensions[i].CompareNoCase(ext) == 0) return true; + } + + return false; +} + + +//========================================================================== +// +// +// +//========================================================================== + +static void APIENTRY LoadExtensions() +{ + CollectExtensions(); + + const char *version = (const char*)glGetString(GL_VERSION); + + // Don't even start if it's lower than 1.2 + if (strcmp(version, "1.2") < 0) + { + I_FatalError("Unsupported OpenGL version.\nAt least GL 1.2 is required to run "GAMENAME".\n"); + } + + // This loads any function pointers and flags that require a vaild render context to + // initialize properly + + gl->shadermodel = 0; // assume no shader support + gl->vendorstring=(char*)glGetString(GL_VENDOR); + + // First try the regular function + gl->BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation"); + // If that fails try the EXT version + if (!gl->BlendEquation) gl->BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquationEXT"); + // If that fails use a no-op dummy + if (!gl->BlendEquation) gl->BlendEquation = glBlendEquationDummy; + + if (CheckExtension("GL_ARB_texture_non_power_of_two")) gl->flags|=RFL_NPOT_TEXTURE; + if (CheckExtension("GL_ARB_texture_compression")) gl->flags|=RFL_TEXTURE_COMPRESSION; + if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl->flags|=RFL_TEXTURE_COMPRESSION_S3TC; + if (strstr(gl->vendorstring, "NVIDIA")) gl->flags|=RFL_NVIDIA; + else if (strstr(gl->vendorstring, "ATI Technologies")) gl->flags|=RFL_ATI; + + if (strcmp(version, "2.0") >= 0) gl->flags|=RFL_GL_20; + if (strcmp(version, "2.1") >= 0) gl->flags|=RFL_GL_21; + if (strcmp(version, "3.0") >= 0) gl->flags|=RFL_GL_30; + + +#if !defined (unix) && !defined (__APPLE__) + PFNWGLSWAPINTERVALEXTPROC vs = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); + if (vs) gl->SetVSync = vs; +#endif + + glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl->max_texturesize); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + if (gl->flags & RFL_GL_20) + { + gl->DeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader"); + gl->DeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram"); + gl->DetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader"); + gl->CreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader"); + gl->ShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource"); + gl->CompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader"); + gl->CreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram"); + gl->AttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader"); + gl->LinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram"); + gl->UseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"); + gl->ValidateProgram = (PFNGLVALIDATEPROGRAMPROC)wglGetProcAddress("glValidateProgram"); + + gl->VertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)wglGetProcAddress("glVertexAttrib1f"); + gl->VertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)wglGetProcAddress("glVertexAttrib2f"); + gl->VertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)wglGetProcAddress("glVertexAttrib4f"); + gl->VertexAttrib2fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib2fv"); + gl->VertexAttrib3fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib3fv"); + gl->VertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv"); + gl->VertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)wglGetProcAddress("glVertexAttrib4ubv"); + gl->GetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation"); + gl->BindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation"); + + + gl->Uniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f"); + gl->Uniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f"); + gl->Uniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f"); + gl->Uniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f"); + gl->Uniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i"); + gl->Uniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i"); + gl->Uniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i"); + gl->Uniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i"); + gl->Uniform1fv = (PFNGLUNIFORM1FVPROC)wglGetProcAddress("glUniform1fv"); + gl->Uniform2fv = (PFNGLUNIFORM2FVPROC)wglGetProcAddress("glUniform2fv"); + gl->Uniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv"); + gl->Uniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv"); + gl->Uniform1iv = (PFNGLUNIFORM1IVPROC)wglGetProcAddress("glUniform1iv"); + gl->Uniform2iv = (PFNGLUNIFORM2IVPROC)wglGetProcAddress("glUniform2iv"); + gl->Uniform3iv = (PFNGLUNIFORM3IVPROC)wglGetProcAddress("glUniform3iv"); + gl->Uniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv"); + + gl->UniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)wglGetProcAddress("glUniformMatrix2fv"); + gl->UniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)wglGetProcAddress("glUniformMatrix3fv"); + gl->UniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv"); + + gl->GetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog"); + gl->GetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog"); + gl->GetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation"); + gl->GetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)wglGetProcAddress("glGetActiveUniform"); + gl->GetUniformfv = (PFNGLGETUNIFORMFVPROC)wglGetProcAddress("glGetUniformfv"); + gl->GetUniformiv = (PFNGLGETUNIFORMIVPROC)wglGetProcAddress("glGetUniformiv"); + gl->GetShaderSource = (PFNGLGETSHADERSOURCEPROC)wglGetProcAddress("glGetShaderSource"); + + gl->EnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray"); + gl->DisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray"); + gl->VertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer"); + + // what'S the equivalent of this in GL 2.0??? + gl->GetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB"); + + // Rules: + // SM4 will always use shaders. No option to switch them off is needed here. + // SM3 has shaders optional but they are off by default (they will have a performance impact + // SM2 only uses shaders for colormaps on camera textures and has no option to use them in general. + // On SM2 cards the shaders will be too slow and show visual bugs (at least on GF 6800.) + if (strcmp((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION), "1.3") >= 0) gl->shadermodel = 4; + else if (CheckExtension("GL_NV_GPU_shader4")) gl->shadermodel = 4; // for pre-3.0 drivers that support GF8xxx. + else if (CheckExtension("GL_EXT_GPU_shader4")) gl->shadermodel = 4; // for pre-3.0 drivers that support GF8xxx. + else if (CheckExtension("GL_NV_vertex_program3")) gl->shadermodel = 3; + else if (!strstr(gl->vendorstring, "NVIDIA")) gl->shadermodel = 3; + else gl->shadermodel = 2; // Only for older NVidia cards which had notoriously bad shader support. + + // Command line overrides for testing and problem cases. + if (Args->CheckParm("-sm2") && gl->shadermodel > 2) gl->shadermodel = 2; + else if (Args->CheckParm("-sm3") && gl->shadermodel > 3) gl->shadermodel = 3; + } + + if (CheckExtension("GL_ARB_occlusion_query")) + { + gl->GenQueries = (PFNGLGENQUERIESARBPROC)wglGetProcAddress("glGenQueriesARB"); + gl->DeleteQueries = (PFNGLDELETEQUERIESARBPROC)wglGetProcAddress("glDeleteQueriesARB"); + gl->GetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVARBPROC)wglGetProcAddress("glGetQueryObjectuivARB"); + gl->BeginQuery = (PFNGLBEGINQUERYARBPROC)wglGetProcAddress("glBeginQueryARB"); + gl->EndQuery = (PFNGLENDQUERYPROC)wglGetProcAddress("glEndQueryARB"); + gl->flags|=RFL_OCCLUSION_QUERY; + } + + if (gl->flags & RFL_GL_21) + { + gl->BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer"); + gl->DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers"); + gl->GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers"); + gl->BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData"); + gl->BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubData"); + gl->MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer"); + gl->UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer"); + gl->flags |= RFL_VBO; + } + else if (CheckExtension("GL_ARB_vertex_buffer_object")) + { + gl->BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBufferARB"); + gl->DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB"); + gl->GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffersARB"); + gl->BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferDataARB"); + gl->BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB"); + gl->MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBufferARB"); + gl->UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBufferARB"); + gl->flags |= RFL_VBO; + } + + if (CheckExtension("GL_ARB_map_buffer_range")) + { + gl->MapBufferRange = (PFNGLMAPBUFFERRANGEPROC)wglGetProcAddress("glMapBufferRange"); + gl->FlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)wglGetProcAddress("glFlushMappedBufferRange"); + gl->flags|=RFL_MAP_BUFFER_RANGE; + } + + if (CheckExtension("GL_ARB_framebuffer_object")) + { + gl->GenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers"); + gl->DeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers"); + gl->BindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer"); + gl->FramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D"); + gl->GenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers"); + gl->DeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress("glDeleteRenderbuffers"); + gl->BindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer"); + gl->RenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorage"); + gl->FramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbuffer"); + + gl->flags|=RFL_FRAMEBUFFER; + } +#if 0 + else if (CheckExtension("GL_EXT_framebuffer_object") && + CheckExtension("GL_EXT_packed_depth_stencil")) + { + gl->GenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffersEXT"); + gl->BindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebufferEXT"); + gl->FramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2DEXT"); + gl->GenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffersEXT"); + gl->BindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbufferEXT"); + gl->RenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorageEXT"); + gl->FramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbufferEXT"); + + gl->flags|=RFL_FRAMEBUFFER; + } +#endif + +#if 0 + if (CheckExtension("GL_ARB_texture_buffer_object") && + CheckExtension("GL_ARB_texture_float") && + CheckExtension("GL_EXT_GPU_Shader4") && + CheckExtension("GL_ARB_texture_rg") && + gl->shadermodel == 4) + { + gl->TexBufferARB = (PFNGLTEXBUFFERARBPROC)wglGetProcAddress("glTexBufferARB"); + gl->flags|=RFL_TEXTUREBUFFER; + } +#endif + + + + gl->ActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTextureARB"); + gl->MultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2fARB"); + gl->MultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) wglGetProcAddress("glMultiTexCoord2fvARB"); +} + +//========================================================================== +// +// +// +//========================================================================== + +static void APIENTRY PrintStartupLog() +{ + Printf ("GL_VENDOR: %s\n", glGetString(GL_VENDOR)); + Printf ("GL_RENDERER: %s\n", glGetString(GL_RENDERER)); + Printf ("GL_VERSION: %s\n", glGetString(GL_VERSION)); + Printf ("GL_SHADING_LANGUAGE_VERSION: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); + Printf ("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS)); + int v; + + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &v); + Printf ("Max. texture units: %d\n", v); + glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); + Printf ("Max. fragment uniforms: %d\n", v); + if (gl->shadermodel == 4) gl->maxuniforms = v; + glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &v); + Printf ("Max. vertex uniforms: %d\n", v); + glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); + Printf ("Max. varying: %d\n", v); + glGetIntegerv(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, &v); + Printf ("Max. combined uniforms: %d\n", v); + glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &v); + Printf ("Max. combined uniform blocks: %d\n", v); + +} + +//========================================================================== +// +// +// +//========================================================================== + +#if !defined (unix) && !defined (__APPLE__) +static bool SetupPixelFormat(HDC hDC, bool allowsoftware, bool nostencil, int multisample) +{ + int colorDepth; + HDC deskDC; + int attributes[26]; + int pixelFormat; + unsigned int numFormats; + float attribsFloat[] = {0.0f, 0.0f}; + int stencil; + + deskDC = GetDC(GetDesktopWindow()); + colorDepth = GetDeviceCaps(deskDC, BITSPIXEL); + ReleaseDC(GetDesktopWindow(), deskDC); + + /* + if (!nostencil && colorDepth < 32) + { + Printf("R_OPENGL: Desktop not in 32 bit mode!\n"); + return false; + } + */ + + if (!nostencil) + { + for (stencil=1;stencil>=0;stencil--) + { + if (wglChoosePixelFormatARB && stencil) + { + attributes[0] = WGL_RED_BITS_ARB; //bits + attributes[1] = 8; + attributes[2] = WGL_GREEN_BITS_ARB; //bits + attributes[3] = 8; + attributes[4] = WGL_BLUE_BITS_ARB; //bits + attributes[5] = 8; + attributes[6] = WGL_ALPHA_BITS_ARB; + attributes[7] = 8; + attributes[8] = WGL_DEPTH_BITS_ARB; + attributes[9] = 24; + attributes[10] = WGL_STENCIL_BITS_ARB; + attributes[11] = 8; + + attributes[12] = WGL_DRAW_TO_WINDOW_ARB; //required to be true + attributes[13] = true; + attributes[14] = WGL_SUPPORT_OPENGL_ARB; + attributes[15] = true; + attributes[16] = WGL_DOUBLE_BUFFER_ARB; + attributes[17] = true; + + attributes[18] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB + if (allowsoftware) + { + attributes[19] = WGL_NO_ACCELERATION_ARB; + } + else + { + attributes[19] = WGL_FULL_ACCELERATION_ARB; + } + + if (multisample > 0) + { + attributes[20] = WGL_SAMPLE_BUFFERS_ARB; + attributes[21] = true; + attributes[22] = WGL_SAMPLES_ARB; + attributes[23] = multisample; + } + else + { + attributes[20] = 0; + attributes[21] = 0; + attributes[22] = 0; + attributes[23] = 0; + } + + attributes[24] = 0; + attributes[25] = 0; + + if (!wglChoosePixelFormatARB(hDC, attributes, attribsFloat, 1, &pixelFormat, &numFormats)) + { + Printf("R_OPENGL: Couldn't choose pixel format. Retrying in compatibility mode\n"); + goto oldmethod; + } + + if (numFormats == 0) + { + Printf("R_OPENGL: No valid pixel formats found. Retrying in compatibility mode\n"); + goto oldmethod; + } + + break; + } + else + { + oldmethod: + // If wglChoosePixelFormatARB is not found we have to do it the old fashioned way. + static PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), + 1, + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, + PFD_TYPE_RGBA, + 32, // color depth + 0, 0, 0, 0, 0, 0, + 0, + 0, + 0, + 0, 0, 0, 0, + 32, // z depth + stencil*8, // stencil buffer + 0, + PFD_MAIN_PLANE, + 0, + 0, 0, 0 + }; + + pixelFormat = ChoosePixelFormat(hDC, &pfd); + DescribePixelFormat(hDC, pixelFormat, sizeof(pfd), &pfd); + + if (pfd.dwFlags & PFD_GENERIC_FORMAT) + { + if (!allowsoftware) + { + if (stencil==0) + { + // not accelerated! + Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n"); + return false; + } + else + { + Printf("R_OPENGL: OpenGL driver not accelerated! Retrying in compatibility mode\n"); + continue; + } + } + } + break; + } + } + } + else + { + // Use the cheapest mode available and let's hope the driver can handle this... + stencil=0; + + // If wglChoosePixelFormatARB is not found we have to do it the old fashioned way. + static PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), + 1, + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, + PFD_TYPE_RGBA, + 16, // color depth + 0, 0, 0, 0, 0, 0, + 0, + 0, + 0, + 0, 0, 0, 0, + 16, // z depth + 0, // stencil buffer + 0, + PFD_MAIN_PLANE, + 0, + 0, 0, 0 + }; + + pixelFormat = ChoosePixelFormat(hDC, &pfd); + DescribePixelFormat(hDC, pixelFormat, sizeof(pfd), &pfd); + + if (pfd.dwFlags & PFD_GENERIC_FORMAT) + { + if (!allowsoftware) + { + Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n"); + return false; + } + } + } + if (stencil==0) + { + gl->flags|=RFL_NOSTENCIL; + } + + if (!SetPixelFormat(hDC, pixelFormat, NULL)) + { + Printf("R_OPENGL: Couldn't set pixel format.\n"); + return false; + } + return true; +} +#else + +static bool SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample) +{ + int stencil; + + if (!nostencil) + { + stencil=1; + SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); + SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); +// SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + if (multisample > 0) { + SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); + SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample ); + } + } + else + { + // Use the cheapest mode available and let's hope the driver can handle this... + stencil=0; + + SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4 ); + SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4 ); + SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4 ); + SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 4 ); + SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); + //SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 )*/ + } + if (stencil==0) + { + gl->flags|=RFL_NOSTENCIL; + } + return true; +} +#endif + + +//========================================================================== +// +// +// +//========================================================================== + +#if !defined (unix) && !defined (__APPLE__) +CVAR(Bool, gl_debug, false, 0) + +static bool APIENTRY InitHardware (HWND Window, bool allowsoftware, bool nostencil, int multisample) +{ + m_Window=Window; + m_hDC = GetDC(Window); + + if (!SetupPixelFormat(m_hDC, allowsoftware, nostencil, multisample)) + { + Printf ("R_OPENGL: Reverting to software mode...\n"); + return false; + } + + m_hRC = 0; + if (wglCreateContextAttribsARB != NULL) + { + int ctxAttribs[] = { + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, + WGL_CONTEXT_MINOR_VERSION_ARB, 3, + WGL_CONTEXT_FLAGS_ARB, gl_debug? WGL_CONTEXT_DEBUG_BIT_ARB : 0, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + 0 + }; + + m_hRC = wglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); + } + if (m_hRC == 0) + { + m_hRC = wglCreateContext(m_hDC); + } + + if (m_hRC == NULL) + { + Printf ("R_OPENGL: Couldn't create render context. Reverting to software mode...\n"); + return false; + } + + wglMakeCurrent(m_hDC, m_hRC); + return true; +} + +#else +static bool APIENTRY InitHardware (bool allowsoftware, bool nostencil, int multisample) +{ + if (!SetupPixelFormat(allowsoftware, nostencil, multisample)) + { + Printf ("R_OPENGL: Reverting to software mode...\n"); + return false; + } + return true; +} +#endif + + +//========================================================================== +// +// +// +//========================================================================== + +#if !defined (unix) && !defined (__APPLE__) +static void APIENTRY Shutdown() +{ + if (m_hRC) + { + wglMakeCurrent(0, 0); + wglDeleteContext(m_hRC); + } + if (m_hDC) ReleaseDC(m_Window, m_hDC); +} + + +static bool APIENTRY SetFullscreen(const char *devicename, int w, int h, int bits, int hz) +{ + DEVMODE dm; + + if (w==0) + { + ChangeDisplaySettingsEx(devicename, 0, 0, 0, 0); + } + else + { + dm.dmSize = sizeof(DEVMODE); + dm.dmSpecVersion = DM_SPECVERSION;//Somebody owes me... + dm.dmDriverExtra = 0;//...1 hour of my life back + dm.dmPelsWidth = w; + dm.dmPelsHeight = h; + dm.dmBitsPerPel = bits; + dm.dmDisplayFrequency = hz; + dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; + if (DISP_CHANGE_SUCCESSFUL != ChangeDisplaySettingsEx(devicename, &dm, 0, CDS_FULLSCREEN, 0)) + { + dm.dmFields &= ~DM_DISPLAYFREQUENCY; + return DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettingsEx(devicename, &dm, 0, CDS_FULLSCREEN, 0); + } + } + return true; +} +#endif +//========================================================================== +// +// +// +//========================================================================== + +static void APIENTRY iSwapBuffers() +{ +#if !defined (unix) && !defined (__APPLE__) + SwapBuffers(m_hDC); +#else + SDL_GL_SwapBuffers (); +#endif +} + +static BOOL APIENTRY SetVSync( int vsync ) +{ +#if defined (__APPLE__) + return kCGLNoError == CGLSetParameter( CGLGetCurrentContext(), kCGLCPSwapInterval, &vsync ); +#else // !__APPLE__ + // empty placeholder + return false; +#endif // __APPLE__ +} + +//========================================================================== +// +// +// +//========================================================================== + +static void APIENTRY glBlendEquationDummy (GLenum mode) +{ + // If this is not supported all non-existent modes are + // made to draw nothing. + if (mode == GL_FUNC_ADD) + { + glColorMask(true, true, true, true); + } + else + { + glColorMask(false, false, false, false); + } +} + +//========================================================================== +// +// +// +//========================================================================== + +static void APIENTRY SetTextureMode(int type) +{ + static float white[] = {1.f,1.f,1.f,1.f}; + + if (gl_vid_compatibility) + { + type = TM_MODULATE; + } + if (type == TM_MASK) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); + } + else if (type == TM_OPAQUE) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + } + else if (type == TM_INVERT) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); + } + else if (type == TM_INVERTOPAQUE) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + } + else // if (type == TM_MODULATE) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } +} + +//========================================================================== +// +// +// +//========================================================================== + +/* +extern "C" +{ + +__declspec(dllexport) +*/ +void APIENTRY GetContext(RenderContext & gl) +{ + ::gl=≷ + + gl.flags=0; + + gl.LoadExtensions = LoadExtensions; + gl.SetTextureMode = SetTextureMode; + gl.PrintStartupLog = PrintStartupLog; + gl.InitHardware = InitHardware; +#if !defined (unix) && !defined (__APPLE__) + gl.Shutdown = Shutdown; +#endif + gl.SwapBuffers = iSwapBuffers; +#if !defined (unix) && !defined (__APPLE__) + gl.SetFullscreen = SetFullscreen; +#endif + + gl.Begin = glBegin; + gl.End = glEnd; + gl.DrawArrays = glDrawArrays; + + gl.TexCoord2f = glTexCoord2f; + gl.TexCoord2fv = glTexCoord2fv; + + gl.Vertex2f = glVertex2f; + gl.Vertex2i = glVertex2i; + gl.Vertex3f = glVertex3f; + gl.Vertex3fv = glVertex3fv; + gl.Vertex3d = glVertex3d; + + gl.Color4f = glColor4f; + gl.Color4fv = glColor4fv; + gl.Color3f = glColor3f; + gl.Color3ub = glColor3ub; + gl.Color4ub = glColor4ub; + + gl.ColorMask = glColorMask; + + gl.DepthFunc = glDepthFunc; + gl.DepthMask = glDepthMask; + gl.DepthRange = glDepthRange; + + gl.StencilFunc = glStencilFunc; + gl.StencilMask = glStencilMask; + gl.StencilOp = glStencilOp; + + gl.MatrixMode = glMatrixMode; + gl.PushMatrix = glPushMatrix; + gl.PopMatrix = glPopMatrix; + gl.LoadIdentity = glLoadIdentity; + gl.MultMatrixd = glMultMatrixd; + gl.Translatef = glTranslatef; + gl.Ortho = glOrtho; + gl.Scalef = glScalef; + gl.Rotatef = glRotatef; + + gl.Viewport = glViewport; + gl.Scissor = glScissor; + + gl.Clear = glClear; + gl.ClearColor = glClearColor; + gl.ClearDepth = glClearDepth; + gl.ShadeModel = glShadeModel; + gl.Hint = glHint; + + gl.DisableClientState = glDisableClientState; + gl.EnableClientState = glEnableClientState; + + gl.Fogf = glFogf; + gl.Fogi = glFogi; + gl.Fogfv = glFogfv; + + gl.Enable = glEnable; + gl.IsEnabled = glIsEnabled; + gl.Disable = glDisable; + + gl.TexGeni = glTexGeni; + gl.DeleteTextures = glDeleteTextures; + gl.GenTextures = glGenTextures; + gl.BindTexture = glBindTexture; + gl.TexImage2D = glTexImage2D; + gl.TexParameterf = glTexParameterf; + gl.TexParameteri = glTexParameteri; + gl.CopyTexSubImage2D = glCopyTexSubImage2D; + + gl.ReadPixels = glReadPixels; + gl.PolygonOffset = glPolygonOffset; + gl.ClipPlane = glClipPlane; + + gl.Finish = glFinish; + gl.Flush = glFlush; + + gl.BlendEquation = glBlendEquationDummy; + gl.SetVSync = SetVSync; + +#if !defined (unix) && !defined (__APPLE__) + ReadInitExtensions(); + //GL is not yet inited in UNIX version, read them later in LoadExtensions +#endif + +} + + + +//} // extern "C" diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h new file mode 100644 index 000000000..8766ebcfa --- /dev/null +++ b/src/gl/system/gl_interface.h @@ -0,0 +1,249 @@ +#ifndef R_RENDER +#define R_RENDER + +#if defined(__APPLE__) +#define APIENTRY +#endif // __APPLE__ + +#ifndef PFNGLMULTITEXCOORD2FPROC +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +#endif +#ifndef PFNGLMULTITEXCOORD2FVPROC +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +#endif + +enum RenderFlags +{ + RFL_NPOT_TEXTURE=1, + RFL_NOSTENCIL=2, + RFL_OCCLUSION_QUERY=4, + // [BB] Added texture compression flags. + RFL_TEXTURE_COMPRESSION=8, + RFL_TEXTURE_COMPRESSION_S3TC=16, + + RFL_VBO = 32, + RFL_MAP_BUFFER_RANGE = 64, + RFL_FRAMEBUFFER = 128, + RFL_TEXTUREBUFFER = 256, + RFL_NVIDIA = 512, + RFL_ATI = 1024, + + + RFL_GL_20 = 0x10000000, + RFL_GL_21 = 0x20000000, + RFL_GL_30 = 0x40000000, +}; + +enum TexMode +{ + TMF_MASKBIT = 1, + TMF_OPAQUEBIT = 2, + TMF_INVERTBIT = 4, + + TM_MODULATE = 0, + TM_MASK = TMF_MASKBIT, + TM_OPAQUE = TMF_OPAQUEBIT, + TM_INVERT = TMF_INVERTBIT, + //TM_INVERTMASK = TMF_MASKBIT | TMF_INVERTBIT + TM_INVERTOPAQUE = TMF_INVERTBIT | TMF_OPAQUEBIT, +}; + +struct RenderContext +{ + unsigned int flags; + unsigned int shadermodel; + unsigned int maxuniforms; + int max_texturesize; + char * vendorstring; + + int MaxLights() const + { + return maxuniforms>=2048? 128:64; + } + + void (APIENTRY * LoadExtensions) (); + void (APIENTRY * SetTextureMode) (int type); + void (APIENTRY * PrintStartupLog) (); + BOOL (APIENTRY * SetVSync) (int on); +#if !defined (unix) && !defined (__APPLE__) + bool (APIENTRY * InitHardware) (HWND, bool allowsoftware, bool nostencil, int multisample); + void (APIENTRY * Shutdown) (); +#else + bool (APIENTRY * InitHardware) (bool allowsoftware, bool nostencil, int multisample); +#endif + void (APIENTRY * SwapBuffers) (); + bool (APIENTRY * SetFullscreen) (const char *devicename, int w, int h, int bits, int hz); + + + void (APIENTRY * Begin) (GLenum mode); + void (APIENTRY * End) (void); + void (APIENTRY * DrawArrays) (GLenum mode, GLint first, GLsizei count); + + void (APIENTRY * TexCoord2f) (GLfloat s, GLfloat t); + void (APIENTRY * TexCoord2fv) (const GLfloat *v); + + void (APIENTRY * Vertex2f) (GLfloat x, GLfloat y); + void (APIENTRY * Vertex2i) (GLint x, GLint y); + void (APIENTRY * Vertex3f) (GLfloat x, GLfloat y, GLfloat z); + void (APIENTRY * Vertex3d) (GLdouble x, GLdouble y, GLdouble z); + void (APIENTRY * Vertex3fv) (const GLfloat *v); + + void (APIENTRY * Color4f) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + void (APIENTRY * Color4fv) (const GLfloat *v); + void (APIENTRY * Color3f) (GLfloat red, GLfloat green, GLfloat blue); + void (APIENTRY * Color3ub) (GLubyte red, GLubyte green, GLubyte blue); + void (APIENTRY * Color4ub) (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); + + void (APIENTRY * BlendEquation) (GLenum); + void (APIENTRY * ColorMask) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); + + void (APIENTRY * DepthFunc) (GLenum func); + void (APIENTRY * DepthMask) (GLboolean flag); + void (APIENTRY * DepthRange) (GLclampd zNear, GLclampd zFar); + + void (APIENTRY * StencilFunc) (GLenum func, GLint ref, GLuint mask); + void (APIENTRY * StencilMask) (GLuint mask); + void (APIENTRY * StencilOp) (GLenum fail, GLenum zfail, GLenum zpass); + + void (APIENTRY * MatrixMode) (GLenum mode); + void (APIENTRY * PushMatrix) (void); + void (APIENTRY * PopMatrix) (void); + void (APIENTRY * LoadIdentity) (void); + void (APIENTRY * MultMatrixd) (const GLdouble *m); + void (APIENTRY * Translatef) (GLfloat x, GLfloat y, GLfloat z); + void (APIENTRY * Ortho) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); + void (APIENTRY * Scalef) (GLfloat x, GLfloat y, GLfloat z); + void (APIENTRY * Rotatef) (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); + + void (APIENTRY * Viewport) (GLint x, GLint y, GLsizei width, GLsizei height); + void (APIENTRY * Scissor) (GLint x, GLint y, GLsizei width, GLsizei height); + + void (APIENTRY * Clear) (GLbitfield mask); + void (APIENTRY * ClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + void (APIENTRY * ClearDepth) (GLclampd depth); + void (APIENTRY * ShadeModel) (GLenum mode); + void (APIENTRY * Hint) (GLenum target, GLenum mode); + + void (APIENTRY * DisableClientState) (GLenum array); + void (APIENTRY * EnableClientState) (GLenum array); + + void (APIENTRY * Fogf) (GLenum pname, GLfloat param); + void (APIENTRY * Fogi) (GLenum pname, GLint param); + void (APIENTRY * Fogfv) (GLenum pname, const GLfloat *params); + + void (APIENTRY * Enable) (GLenum cap); + GLboolean (APIENTRY * IsEnabled) (GLenum cap); + void (APIENTRY * Disable) (GLenum cap); + + void (APIENTRY * TexGeni) (GLenum coord, GLenum pname, GLint param); + void (APIENTRY * DeleteTextures) (GLsizei n, const GLuint *textures); + void (APIENTRY * GenTextures) (GLsizei n, GLuint *textures); + void (APIENTRY * BindTexture) (GLenum target, GLuint texture); + void (APIENTRY * TexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + void (APIENTRY * TexParameterf) (GLenum target, GLenum pname, GLfloat param); + void (APIENTRY * TexParameteri) (GLenum target, GLenum pname, GLint param); + void (APIENTRY * CopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + + void (APIENTRY * ReadPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); + void (APIENTRY * PolygonOffset) (GLfloat factor, GLfloat units); + void (APIENTRY * ClipPlane) (GLenum which, const GLdouble *); + + void (APIENTRY * Finish) (void); + void (APIENTRY * Flush) (void); + + // ARB_SHADER_OBJECTS + PFNGLDELETESHADERPROC DeleteShader; + PFNGLDELETEPROGRAMPROC DeleteProgram; + PFNGLDETACHSHADERPROC DetachShader; + PFNGLCREATESHADERPROC CreateShader; + PFNGLSHADERSOURCEPROC ShaderSource; + PFNGLCOMPILESHADERPROC CompileShader; + PFNGLCREATEPROGRAMPROC CreateProgram; + PFNGLATTACHSHADERPROC AttachShader; + PFNGLLINKPROGRAMPROC LinkProgram; + PFNGLUSEPROGRAMPROC UseProgram; + PFNGLVALIDATEPROGRAMPROC ValidateProgram; + PFNGLVERTEXATTRIB1FPROC VertexAttrib1f; + PFNGLVERTEXATTRIB2FPROC VertexAttrib2f; + PFNGLVERTEXATTRIB4FPROC VertexAttrib4f; + PFNGLVERTEXATTRIB2FVPROC VertexAttrib2fv; + PFNGLVERTEXATTRIB3FVPROC VertexAttrib3fv; + PFNGLVERTEXATTRIB4FVPROC VertexAttrib4fv; + PFNGLVERTEXATTRIB4UBVPROC VertexAttrib4ubv; + PFNGLGETATTRIBLOCATIONPROC GetAttribLocation; + PFNGLBINDATTRIBLOCATIONPROC BindAttribLocation; + + PFNGLUNIFORM1FPROC Uniform1f; + PFNGLUNIFORM2FPROC Uniform2f; + PFNGLUNIFORM3FPROC Uniform3f; + PFNGLUNIFORM4FPROC Uniform4f; + PFNGLUNIFORM1IPROC Uniform1i; + PFNGLUNIFORM2IPROC Uniform2i; + PFNGLUNIFORM3IPROC Uniform3i; + PFNGLUNIFORM4IPROC Uniform4i; + PFNGLUNIFORM1FVPROC Uniform1fv; + PFNGLUNIFORM2FVPROC Uniform2fv; + PFNGLUNIFORM3FVPROC Uniform3fv; + PFNGLUNIFORM4FVPROC Uniform4fv; + PFNGLUNIFORM1IVPROC Uniform1iv; + PFNGLUNIFORM2IVPROC Uniform2iv; + PFNGLUNIFORM3IVPROC Uniform3iv; + PFNGLUNIFORM4IVPROC Uniform4iv; + + PFNGLUNIFORMMATRIX2FVPROC UniformMatrix2fv; + PFNGLUNIFORMMATRIX3FVPROC UniformMatrix3fv; + PFNGLUNIFORMMATRIX4FVPROC UniformMatrix4fv; + + PFNGLGETSHADERINFOLOGPROC GetShaderInfoLog; + PFNGLGETPROGRAMINFOLOGPROC GetProgramInfoLog; + PFNGLGETUNIFORMLOCATIONPROC GetUniformLocation; + PFNGLGETACTIVEUNIFORMPROC GetActiveUniform; + PFNGLGETUNIFORMFVPROC GetUniformfv; + PFNGLGETUNIFORMIVPROC GetUniformiv; + PFNGLGETSHADERSOURCEPROC GetShaderSource; + PFNGLGETOBJECTPARAMETERIVARBPROC GetObjectParameteriv; + + PFNGLGENQUERIESARBPROC GenQueries; + PFNGLDELETEQUERIESARBPROC DeleteQueries; + PFNGLBEGINQUERYARBPROC BeginQuery; + PFNGLENDQUERYARBPROC EndQuery; + PFNGLGETQUERYOBJECTUIVARBPROC GetQueryObjectuiv; + + PFNGLACTIVETEXTUREPROC ActiveTexture; + PFNGLMULTITEXCOORD2FPROC MultiTexCoord2f; + PFNGLMULTITEXCOORD2FVPROC MultiTexCoord2fv; + + PFNGLBINDBUFFERPROC BindBuffer; + PFNGLDELETEBUFFERSPROC DeleteBuffers; + PFNGLGENBUFFERSPROC GenBuffers; + PFNGLBUFFERDATAPROC BufferData; + PFNGLBUFFERSUBDATAPROC BufferSubData; + PFNGLMAPBUFFERPROC MapBuffer; + PFNGLUNMAPBUFFERPROC UnmapBuffer; + PFNGLENABLEVERTEXATTRIBARRAYPROC EnableVertexAttribArray; + PFNGLDISABLEVERTEXATTRIBARRAYPROC DisableVertexAttribArray; + PFNGLVERTEXATTRIBPOINTERPROC VertexAttribPointer; + + PFNGLMAPBUFFERRANGEPROC MapBufferRange; + PFNGLFLUSHMAPPEDBUFFERRANGEPROC FlushMappedBufferRange; + + PFNGLGENFRAMEBUFFERSPROC GenFramebuffers; + PFNGLDELETEFRAMEBUFFERSPROC DeleteFramebuffers; + PFNGLBINDFRAMEBUFFERPROC BindFramebuffer; + PFNGLFRAMEBUFFERTEXTURE2DPROC FramebufferTexture2D; + PFNGLGENRENDERBUFFERSPROC GenRenderbuffers; + PFNGLDELETERENDERBUFFERSPROC DeleteRenderbuffers; + PFNGLBINDRENDERBUFFERPROC BindRenderbuffer; + PFNGLRENDERBUFFERSTORAGEPROC RenderbufferStorage; + PFNGLFRAMEBUFFERRENDERBUFFERPROC FramebufferRenderbuffer; + + PFNGLTEXBUFFERARBPROC TexBufferARB; +}; + + +typedef void (APIENTRY * GetContextProc)(RenderContext & gl); + +void APIENTRY GetContext(RenderContext & gl); + +#endif + diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp new file mode 100644 index 000000000..5429da9c7 --- /dev/null +++ b/src/gl/system/gl_menu.cpp @@ -0,0 +1,137 @@ + + +#include "gl/system/gl_system.h" +#include "c_cvars.h" +#include "c_dispatch.h" +#include "v_video.h" +#include "version.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "menu/menu.h" + + + +// OpenGL stuff moved here +// GL related CVARs +CVAR(Bool, gl_portals, true, 0) +CVAR(Bool, gl_noquery, false, 0) +CVAR(Bool,gl_mirrors,true,0) // This is for debugging only! +CVAR(Bool,gl_mirror_envmap, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) +CVAR(Bool, gl_render_segs, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Bool, gl_seamless, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Bool, gl_vid_compatibility, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); + +CUSTOM_CVAR(Int, r_mirror_recursions,4,CVAR_GLOBALCONFIG|CVAR_ARCHIVE) +{ + if (self<0) self=0; + if (self>10) self=10; +} +bool gl_plane_reflection_i; // This is needed in a header that cannot include the CVAR stuff... +CUSTOM_CVAR(Bool, gl_plane_reflection, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) +{ + gl_plane_reflection_i = self; +} + +CUSTOM_CVAR(Bool, gl_render_precise, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + //gl_render_segs=self; + gl_seamless=self; +} + +CUSTOM_CVAR (Float, vid_brightness, 0.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + if (screen != NULL) + { + screen->SetGamma(Gamma); //Brightness (self); + } +} + +CUSTOM_CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + if (screen != NULL) + { + screen->SetGamma(Gamma); //SetContrast (self); + } +} + + +// Do some tinkering with the menus so that certain options only appear +// when they are actually valid. +void gl_SetupMenu() +{ +#ifndef _MSC_VER + FOptionValues **opt = OptionValues.CheckKey("HqResizeModes"); + if (opt != NULL) + { + for(int i = (*opt)->mValues.Size()-1; i>=0; i--) + { + // Delete HQnX resize modes for non MSVC targets + if ((*opt)->mValues[i].Value >= 4.0) + { + (*opt)->mValues.Delete(i); + } + } + } +#endif + + if (gl.shadermodel < 4) + { + // Radial fog and Doom lighting are not available in SM < 4 cards + // The way they are implemented does not work well on older hardware. + + FOptionValues **opt = OptionValues.CheckKey("LightingModes"); + if (opt != NULL) + { + for(int i = (*opt)->mValues.Size()-1; i>=0; i--) + { + // Delete 'Doom' lighting mode + if ((*opt)->mValues[i].Value == 2.0 || (*opt)->mValues[i].Value == 8.0) + { + (*opt)->mValues.Delete(i); + } + } + } + + opt = OptionValues.CheckKey("FogMode"); + if (opt != NULL) + { + for(int i = (*opt)->mValues.Size()-1; i>=0; i--) + { + // Delete 'Radial' fog mode + if ((*opt)->mValues[i].Value == 2.0) + { + (*opt)->mValues.Delete(i); + } + } + } + + // disable features that don't work without shaders. + if (gl_lightmode == 2 || gl_lightmode == 8) gl_lightmode = 3; + if (gl_fogmode == 2) gl_fogmode = 1; + if (gl_dynlight_shader) gl_dynlight_shader = false; + } + + if (gl.shadermodel != 3) + { + // The shader menu will only be visible on SM3. + // SM2 won't use shaders unless unavoidable (and then it's automatic) and SM4 will always use shaders. + // Find the OpenGLOptions menu and remove the item named GLShaderOptions. + + FMenuDescriptor **desc = MenuDescriptors.CheckKey("OpenGLOptions"); + if (desc != NULL && (*desc)->mType == MDESC_OptionsMenu) + { + FOptionMenuDescriptor *opt = (FOptionMenuDescriptor *)*desc; + + FName shader = "GLShaderOptions"; + for(unsigned i=0;imItems.Size();i++) + { + FName nm = opt->mItems[i]->GetAction(NULL); + if (nm == shader) + { + delete opt->mItems[i]; + opt->mItems.Delete(i); + } + } + } + } +} diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h new file mode 100644 index 000000000..d48b55976 --- /dev/null +++ b/src/gl/system/gl_system.h @@ -0,0 +1,124 @@ +#ifndef __GL_PCH_H +#define __GL_PCH_H +#ifdef _WIN32 +//#define __RPCNDR_H__ // this header causes problems! +//#define __wtypes_h__ +#define WIN32_LEAN_AND_MEAN +#define _WIN32_WINDOWS 0x410 +#define _WIN32_WINNT 0x0501 // Support the mouse wheel and session notification. +#define _WIN32_IE 0x0500 +#define DIRECTINPUT_VERSION 0x800 +#define DIRECTDRAW_VERSION 0x0300 + +#define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code! + +#ifdef _MSC_VER +#pragma warning(disable : 4995) // MIPS +#endif + +#include +#include +#include +#ifndef __WINE__ +#include +#endif +#include +//#include +//#include +//#include +//#include +#endif + +#undef DWORD +#ifndef CALLBACK +#define CALLBACK +#endif +#include +#include +#include +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#if !defined(__APPLE__) +#include +#endif +#include + +#ifdef _MSC_VER +#define F_OK 0 /* Check for file existence */ +#define W_OK 2 /* Check for write permission */ +#define R_OK 4 /* Check for read permission */ +#include +#else +#include +#endif +#include +#include +#include + +#if defined(__APPLE__) +#include +#include +#else // !__APPLE__ +#include +#include +#include +#endif // __APPLE__ + +#ifdef _WIN32 +#define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code! +#include +#ifndef __WINE__ +#undef DWORD +#endif +#else +typedef unsigned char byte; +typedef float FLOAT; +template +inline T max( T a, T b) { return (((a)>(b)) ? (a) : (b)); } +#define __cdecl +#define _access(a,b) access(a,b) +#endif +#ifndef _WIN32 +#include "platform.h" +#include +#endif +#include "gl/system/gl_interface.h" + +extern RenderContext gl; + +#ifdef LoadMenu +#undef LoadMenu +#endif +#ifdef DrawText +#undef DrawText +#endif +#ifdef GetCharWidth +#undef GetCharWidth +#endif + +#undef S_NORMAL +#undef OPAQUE + + +#ifdef _MSC_VER +#pragma warning(disable : 4244) // MIPS +#pragma warning(disable : 4136) // X86 +#pragma warning(disable : 4051) // ALPHA + +#pragma warning(disable : 4018) // signed/unsigned mismatch +#pragma warning(disable : 4305) // truncate from double to float +#endif + +#ifdef WIN32 +#undef WIN32 +#endif +#endif //__GL_PCH_H diff --git a/src/gl/system/gl_threads.cpp b/src/gl/system/gl_threads.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/src/gl/system/gl_threads.h b/src/gl/system/gl_threads.h new file mode 100644 index 000000000..68919776c --- /dev/null +++ b/src/gl/system/gl_threads.h @@ -0,0 +1,247 @@ +#if 0 //ndef __GL_THREADS_H +#define __GL_THREADS_H + +#ifdef WIN32 +#include +#endif + +#include "critsec.h" + +// system specific Base classes - should be externalized to a separate header later. +#ifdef WIN32 +class FEvent +{ + HANDLE mEvent; + +public: + + FEvent(bool manual = true, bool initial = false) + { + mEvent = CreateEvent(NULL, manual, initial, NULL); + } + + ~FEvent() + { + CloseHandle(mEvent); + } + + void Set() + { + SetEvent(mEvent); + } + + void Reset() + { + ResetEvent(mEvent); + } +}; + +class FThread +{ +protected: + uintptr_t hThread; + bool mTerminateRequest; +public: + + FThread(int stacksize) + { + hThread = _beginthreadex(NULL, stacksize, StaticRun, this, 0, NULL); + } + + virtual ~FThread() + { + CloseHandle((HANDLE)hThread); + } + + void SignalTerminate() + { + mTerminateRequest = true; + } + + virtual void Run() = 0; + +private: + static unsigned __stdcall StaticRun(void *param) + { + FThread *thread = (FThread*)param; + thread->Run(); + return 0; + } + +}; + +#else +class FEvent +{ +public: + + FEvent(bool manual = true, bool initial = false) + { + } + + ~FEvent() + { + } + + void Set() + { + } + + void Reset() + { + } +}; + +class FThread +{ +protected: + bool mTerminateRequest; +public: + + FThread(int stacksize) + { + } + + virtual ~FThread() + { + } + + void SignalTerminate() + { + mTerminateRequest = true; + } + + virtual void Run() = 0; +}; + +#endif + + + +enum +{ + CS_ValidateTexture, + CS_Hacks, + CS_Drawlist, + CS_Portals, + + MAX_GL_CRITICAL_SECTIONS +}; + +class FJob +{ + friend class FJobQueue; + FJob *pNext; + FJob *pPrev; + +public: + FJob() { pNext = pPrev = NULL; } + virtual ~FJob(); + virtual void Run() = 0; +}; + +class FJobQueue +{ + FCriticalSection mCritSec; // for limiting access + FEvent mEvent; // signals that the queue is emoty or not + FJob *pFirst; + FJob *pLast; + +public: + FJobQueue(); + ~FJobQueue(); + + void AddJob(FJob *job); + FJob *GetJob(); +}; + +class FJobThread : public FThread +{ + FJobQueue *mQueue; + +public: + FJobThread(FJobQueue *queue); + ~FJobThread(); + void Run(); +}; + +class FGLJobProcessWall : public FJob +{ + seg_t *mSeg; + subsector_t *mSub; + int mFrontsector, mBacksector; +public: + FGLJobProcessWall(seg_t *seg, subsector_t *sub, int frontsector, int backsector) + { + mSeg = seg; + mSub = sub; + mFrontsector = frontsector; + mBacksector = backsector; + } + + void Run(); +}; + +class FGLJobProcessSprites : public FJob +{ + sector_t *mSector; +public: + FGLJobProcessSprites(sector_t *sector); + void Run(); +}; + +class FGLJobProcessParticles : public FJob +{ + subsector_t *mSubsector; +public: + FGLJobProcessParticles(subsector_t *subsector); + void Run(); +}; + +class FGLJobProcessFlats : public FJob +{ + subsector_t *mSubsector; +public: + FGLJobProcessFlats(subsector_t *subsector); + void Run(); +}; + + +class FGLThreadManager +{ +#if 0 + FCriticalSection mCritSecs[MAX_GL_CRITICAL_SECTIONS]; + FJobQueue mJobs; + FJobThread *mThreads[2]; + +public: + FGLThreadManager() {} + ~FGLThreadManager() {} + + void StartJobs(); + + void PauseJobs(); + + void EnterCS(int index) + { + mCritSecs[index].Enter(); + } + + void LeaveCS(int index) + { + mCritSecs[index].Leave(); + } + + void AddJob(FJob *job) + { + mJobs.AddJob(job); + } + + FJob *GetJob() + { + return mJobs.GetJob(); + } +#endif +}; + +#endif \ No newline at end of file diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp new file mode 100644 index 000000000..f9f73a4ea --- /dev/null +++ b/src/gl/system/gl_wipe.cpp @@ -0,0 +1,551 @@ +/* +** gl_wipe.cpp +** Screen wipe stuff +** (This uses immediate mode and the fixed function pipeline +** even if the new renderer is active) +** +**--------------------------------------------------------------------------- +** Copyright 2008 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "f_wipe.h" +#include "m_random.h" +#include "w_wad.h" +#include "v_palette.h" +#include "templates.h" +#include "vectors.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/textures/gl_translate.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_templates.h" + +EXTERN_CVAR(Bool, gl_vid_compatibility) + +//=========================================================================== +// +// Screen wipes +// +//=========================================================================== + +// TYPES ------------------------------------------------------------------- + +class OpenGLFrameBuffer::Wiper_Crossfade : public OpenGLFrameBuffer::Wiper +{ +public: + Wiper_Crossfade(); + bool Run(int ticks, OpenGLFrameBuffer *fb); + +private: + int Clock; +}; + +class OpenGLFrameBuffer::Wiper_Melt : public OpenGLFrameBuffer::Wiper +{ +public: + Wiper_Melt(); + bool Run(int ticks, OpenGLFrameBuffer *fb); + +private: + static const int WIDTH = 320, HEIGHT = 200; + int y[WIDTH]; +}; + +class OpenGLFrameBuffer::Wiper_Burn : public OpenGLFrameBuffer::Wiper +{ +public: + Wiper_Burn(); + ~Wiper_Burn(); + bool Run(int ticks, OpenGLFrameBuffer *fb); + +private: + static const int WIDTH = 64, HEIGHT = 64; + BYTE BurnArray[WIDTH * (HEIGHT + 5)]; + FHardwareTexture *BurnTexture; + int Density; + int BurnTime; +}; + +//========================================================================== +// +// OpenGLFrameBuffer :: WipeStartScreen +// +// Called before the current screen has started rendering. This needs to +// save what was drawn the previous frame so that it can be animated into +// what gets drawn this frame. +// +//========================================================================== + +bool OpenGLFrameBuffer::WipeStartScreen(int type) +{ + if (gl_vid_compatibility) + { + return false; // not all required features present. + } + switch (type) + { + case wipe_Burn: + ScreenWipe = new Wiper_Burn; + break; + + case wipe_Fade: + ScreenWipe = new Wiper_Crossfade; + break; + + case wipe_Melt: + ScreenWipe = new Wiper_Melt; + break; + + default: + return false; + } + + wipestartscreen = new FHardwareTexture(Width, Height, false, false, false, true); + wipestartscreen->CreateTexture(NULL, Width, Height, false, 0, CM_DEFAULT); + gl.Finish(); + wipestartscreen->Bind(0, CM_DEFAULT); + gl.CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + return true; +} + +//========================================================================== +// +// OpenGLFrameBuffer :: WipeEndScreen +// +// The screen we want to animate to has just been drawn. +// +//========================================================================== + +void OpenGLFrameBuffer::WipeEndScreen() +{ + wipeendscreen = new FHardwareTexture(Width, Height, false, false, false, true); + wipeendscreen->CreateTexture(NULL, Width, Height, false, 0, CM_DEFAULT); + gl.Flush(); + wipeendscreen->Bind(0, CM_DEFAULT); + gl.CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + Unlock(); +} + +//========================================================================== +// +// OpenGLFrameBuffer :: WipeDo +// +// Perform the actual wipe animation. The number of tics since the last +// time this function was called is passed in. Returns true when the wipe +// is over. The first time this function has been called, the screen is +// still locked from before and EndScene() still has not been called. +// Successive times need to call BeginScene(). +// +//========================================================================== + +bool OpenGLFrameBuffer::WipeDo(int ticks) +{ + // Sanity checks. + if (wipestartscreen == NULL || wipeendscreen == NULL) + { + return true; + } + + Lock(true); + + gl_RenderState.EnableTexture(true); + gl_RenderState.EnableFog(false); + gl.Disable(GL_DEPTH_TEST); + gl.DepthMask(false); + + bool done = ScreenWipe->Run(ticks, this); + gl.DepthMask(true); + //DrawLetterbox(); + return done; +} + +//========================================================================== +// +// OpenGLFrameBuffer :: WipeCleanup +// +// Release any resources that were specifically created for the wipe. +// +//========================================================================== + +void OpenGLFrameBuffer::WipeCleanup() +{ + if (ScreenWipe != NULL) + { + delete ScreenWipe; + ScreenWipe = NULL; + } + if (wipestartscreen != NULL) + { + delete wipestartscreen; + wipestartscreen = NULL; + } + if (wipeendscreen != NULL) + { + delete wipeendscreen; + wipeendscreen = NULL; + } +} + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper Constructor +// +//========================================================================== + +OpenGLFrameBuffer::Wiper::~Wiper() +{ +} + +// WIPE: CROSSFADE --------------------------------------------------------- + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper_Crossfade Constructor +// +//========================================================================== + +OpenGLFrameBuffer::Wiper_Crossfade::Wiper_Crossfade() +: Clock(0) +{ +} + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper_Crossfade :: Run +// +// Fades the old screen into the new one over 32 ticks. +// +//========================================================================== + +bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) +{ + Clock += ticks; + + float ur = fb->GetWidth() / FHardwareTexture::GetTexDimension(fb->GetWidth()); + float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight()); + + gl_RenderState.SetTextureMode(TM_OPAQUE); + gl_RenderState.EnableAlphaTest(false); + gl_RenderState.Apply(); + fb->wipestartscreen->Bind(0, CM_DEFAULT); + gl.Color4f(1.f, 1.f, 1.f, 1.f); + gl.Begin(GL_TRIANGLE_STRIP); + gl.TexCoord2f(0, vb); + gl.Vertex2i(0, 0); + gl.TexCoord2f(0, 0); + gl.Vertex2i(0, fb->Height); + gl.TexCoord2f(ur, vb); + gl.Vertex2i(fb->Width, 0); + gl.TexCoord2f(ur, 0); + gl.Vertex2i(fb->Width, fb->Height); + gl.End(); + + fb->wipeendscreen->Bind(0, CM_DEFAULT); + gl.Color4f(1.f, 1.f, 1.f, clamp(Clock/32.f, 0.f, 1.f)); + gl.Begin(GL_TRIANGLE_STRIP); + gl.TexCoord2f(0, vb); + gl.Vertex2i(0, 0); + gl.TexCoord2f(0, 0); + gl.Vertex2i(0, fb->Height); + gl.TexCoord2f(ur, vb); + gl.Vertex2i(fb->Width, 0); + gl.TexCoord2f(ur, 0); + gl.Vertex2i(fb->Width, fb->Height); + gl.End(); + gl_RenderState.EnableAlphaTest(true); + gl_RenderState.SetTextureMode(TM_MODULATE); + + return Clock >= 32; +} + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper_Melt Constructor +// +//========================================================================== + +OpenGLFrameBuffer::Wiper_Melt::Wiper_Melt() +{ + int i, r; + + // setup initial column positions + // (y<0 => not ready to scroll yet) + y[0] = -(M_Random() & 15); + for (i = 1; i < WIDTH; ++i) + { + r = (M_Random()%3) - 1; + y[i] = clamp(y[i-1] + r, -15, 0); + } +} + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper_Melt :: Run +// +// Fades the old screen into the new one over 32 ticks. +// +//========================================================================== + +bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) +{ + float ur = fb->GetWidth() / FHardwareTexture::GetTexDimension(fb->GetWidth()); + float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight()); + + // Draw the new screen on the bottom. + gl_RenderState.SetTextureMode(TM_OPAQUE); + gl_RenderState.Apply(); + fb->wipeendscreen->Bind(0, CM_DEFAULT); + gl.Color4f(1.f, 1.f, 1.f, 1.f); + gl.Begin(GL_TRIANGLE_STRIP); + gl.TexCoord2f(0, vb); + gl.Vertex2i(0, 0); + gl.TexCoord2f(0, 0); + gl.Vertex2i(0, fb->Height); + gl.TexCoord2f(ur, vb); + gl.Vertex2i(fb->Width, 0); + gl.TexCoord2f(ur, 0); + gl.Vertex2i(fb->Width, fb->Height); + gl.End(); + + int i, dy; + bool done = false; + + fb->wipestartscreen->Bind(0, CM_DEFAULT); + // Copy the old screen in vertical strips on top of the new one. + while (ticks--) + { + done = true; + for (i = 0; i < WIDTH; i++) + { + if (y[i] < 0) + { + y[i]++; + done = false; + } + else if (y[i] < HEIGHT) + { + dy = (y[i] < 16) ? y[i]+1 : 8; + y[i] = MIN(y[i] + dy, HEIGHT); + done = false; + } + if (ticks == 0) + { // Only draw for the final tick. + RECT rect; + POINT dpt; + + dpt.x = i * fb->Width / WIDTH; + dpt.y = MAX(0, y[i] * fb->Height / HEIGHT); + rect.left = dpt.x; + rect.top = 0; + rect.right = (i + 1) * fb->Width / WIDTH; + rect.bottom = fb->Height - dpt.y; + if (rect.bottom > rect.top) + { + float tw = (float)FHardwareTexture::GetTexDimension(fb->Width); + float th = (float)FHardwareTexture::GetTexDimension(fb->Height); + rect.bottom = fb->Height - rect.bottom; + rect.top = fb->Height - rect.top; + gl.Color4f(1.f, 1.f, 1.f, 1.f); + gl.Begin(GL_TRIANGLE_STRIP); + gl.TexCoord2f(rect.left / tw, rect.top / th); + gl.Vertex2i(rect.left, rect.bottom); + gl.TexCoord2f(rect.left / tw, rect.bottom / th); + gl.Vertex2i(rect.left, rect.top); + gl.TexCoord2f(rect.right / tw, rect.top / th); + gl.Vertex2i(rect.right, rect.bottom); + gl.TexCoord2f(rect.right / tw, rect.bottom / th); + gl.Vertex2i(rect.right, rect.top); + gl.End(); + } + } + } + } + gl_RenderState.SetTextureMode(TM_MODULATE); + return done; +} + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper_Burn Constructor +// +//========================================================================== + +OpenGLFrameBuffer::Wiper_Burn::Wiper_Burn() +{ + Density = 4; + BurnTime = 0; + memset(BurnArray, 0, sizeof(BurnArray)); + BurnTexture = NULL; +} + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper_Burn Destructor +// +//========================================================================== + +OpenGLFrameBuffer::Wiper_Burn::~Wiper_Burn() +{ + if (BurnTexture != NULL) + { + delete BurnTexture; + BurnTexture = NULL; + } +} + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper_Burn :: Run +// +//========================================================================== + +bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) +{ + bool done; + + BurnTime += ticks; + ticks *= 2; + + // Make the fire burn + done = false; + while (!done && ticks--) + { + Density = wipe_CalcBurn(BurnArray, WIDTH, HEIGHT, Density); + done = (Density < 0); + } + + if (BurnTexture != NULL) delete BurnTexture; + BurnTexture = new FHardwareTexture(WIDTH, HEIGHT, false, false, false, true); + + // Update the burn texture with the new burn data + BYTE rgb_buffer[WIDTH*HEIGHT*4]; + + const BYTE *src = BurnArray; + DWORD *dest = (DWORD *)rgb_buffer; + for (int y = HEIGHT; y != 0; --y) + { + for (int x = WIDTH; x != 0; --x) + { + BYTE s = clamp((*src++)*2, 0, 255); + *dest++ = MAKEARGB(s,255,255,255); + } + } + + float ur = fb->GetWidth() / FHardwareTexture::GetTexDimension(fb->GetWidth()); + float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight()); + + + // Put the initial screen back to the buffer. + gl_RenderState.SetTextureMode(TM_OPAQUE); + gl_RenderState.EnableAlphaTest(false); + gl_RenderState.Apply(); + fb->wipestartscreen->Bind(0, CM_DEFAULT); + gl.Color4f(1.f, 1.f, 1.f, 1.f); + gl.Begin(GL_TRIANGLE_STRIP); + gl.TexCoord2f(0, vb); + gl.Vertex2i(0, 0); + gl.TexCoord2f(0, 0); + gl.Vertex2i(0, fb->Height); + gl.TexCoord2f(ur, vb); + gl.Vertex2i(fb->Width, 0); + gl.TexCoord2f(ur, 0); + gl.Vertex2i(fb->Width, fb->Height); + gl.End(); + + gl_RenderState.SetTextureMode(TM_MODULATE); + gl_RenderState.Apply(true); + gl.ActiveTexture(GL_TEXTURE1); + gl.Enable(GL_TEXTURE_2D); + + // mask out the alpha channel of the wipeendscreen. + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE1); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + + gl.ActiveTexture(GL_TEXTURE0); + + // Burn the new screen on top of it. + gl.Color4f(1.f, 1.f, 1.f, 1.f); + fb->wipeendscreen->Bind(1, CM_DEFAULT); + //BurnTexture->Bind(0, CM_DEFAULT); + + BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, false, 0, CM_DEFAULT); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + + gl.Begin(GL_TRIANGLE_STRIP); + gl.MultiTexCoord2f(GL_TEXTURE0, 0, 0); + gl.MultiTexCoord2f(GL_TEXTURE1, 0, vb); + gl.Vertex2i(0, 0); + gl.MultiTexCoord2f(GL_TEXTURE0, 0, 1); + gl.MultiTexCoord2f(GL_TEXTURE1, 0, 0); + gl.Vertex2i(0, fb->Height); + gl.MultiTexCoord2f(GL_TEXTURE0, 1, 0); + gl.MultiTexCoord2f(GL_TEXTURE1, ur, vb); + gl.Vertex2i(fb->Width, 0); + gl.MultiTexCoord2f(GL_TEXTURE0, 1, 1); + gl.MultiTexCoord2f(GL_TEXTURE1, ur, 0); + gl.Vertex2i(fb->Width, fb->Height); + gl.End(); + + gl.ActiveTexture(GL_TEXTURE1); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + gl.Disable(GL_TEXTURE_2D); + gl.ActiveTexture(GL_TEXTURE0); + + // The fire may not always stabilize, so the wipe is forced to end + // after an arbitrary maximum time. + return done || (BurnTime > 40); +} diff --git a/src/gl/textures/gl_bitmap.cpp b/src/gl/textures/gl_bitmap.cpp new file mode 100644 index 000000000..d90fd36b7 --- /dev/null +++ b/src/gl/textures/gl_bitmap.cpp @@ -0,0 +1,286 @@ +/* +** gl_bitmap.cpp +** Bitmap class for texture composition +** +**--------------------------------------------------------------------------- +** Copyright 2004-2009 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + + +#include "v_palette.h" +#include "templates.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/textures/gl_translate.h" +#include "gl/textures/gl_bitmap.h" + +//=========================================================================== +// +// multi-format pixel copy with colormap application +// requires one of the previously defined conversion classes to work +// +//=========================================================================== +template +void iCopyColors(unsigned char * pout, const unsigned char * pin, int cm, int count, int step) +{ + int i; + int fac; + + if (cm == CM_DEFAULT) + { + for(i=0;i= CM_FIRSTSPECIALCOLORMAP && cm < CM_FIRSTSPECIALCOLORMAP + int(SpecialColormaps.Size())) + { + for(i=0;i, + iCopyColors, + iCopyColors, + iCopyColors, + iCopyColors, + iCopyColors, + iCopyColors, + iCopyColors, + iCopyColors +}; + +//=========================================================================== +// +// True Color texture copy function +// This excludes all the cases that force downconversion to the +// base palette because they wouldn't be used anyway. +// +//=========================================================================== +void FGLBitmap::CopyPixelDataRGB(int originx, int originy, + const BYTE * patch, int srcwidth, int srcheight, int step_x, int step_y, + int rotate, int ct, FCopyInfo *inf) +{ + if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate)) + { + BYTE *buffer = GetPixels() + 4*originx + Pitch*originy; + for (int y=0;y= CM_FIRSTSPECIALCOLORMAP && cm < CM_FIRSTSPECIALCOLORMAP + int(SpecialColormaps.Size())) + { + for(i=0;i> 8; + // This can be done in place so we cannot copy the color directly. + PalEntry pe = SpecialColormaps[cm - CM_FIRSTSPECIALCOLORMAP].GrayscaleToColor[gray]; + pout[i].r = pe.r; + pout[i].g = pe.g; + pout[i].b = pe.b; + pout[i].a = pin[i].a; + } + } + else if (cm<=CM_DESAT31) + { + // Desaturated light settings. + fac=cm-CM_DESAT0; + for(i=0;i>8; + gl_Desaturate(gray, pin[i].r, pin[i].g, pin[i].b, pout[i].r, pout[i].g, pout[i].b, fac); + pout[i].a = pin[i].a; + } + } + else if (pin!=pout) + { + memcpy(pout, pin, count * sizeof(PalEntry)); + } +} + + +//=========================================================================== +// +// Paletted to True Color texture copy function +// +//=========================================================================== +void FGLBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int srcwidth, int srcheight, + int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf) +{ + PalEntry penew[256]; + + int x,y,pos,i; + + if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate)) + { + BYTE *buffer = GetPixels() + 4*originx + Pitch*originy; + + // CM_SHADE is an alpha map with 0==transparent and 1==opaque + if (cm == CM_SHADE) + { + for(int i=0;i<256;i++) + { + if (palette[i].a != 0) + penew[i]=PalEntry(i, 255,255,255); + else + penew[i]=PalEntry(0,255,255,255); // If the palette contains transparent colors keep them. + } + } + else + { + // apply any translation. + // The ice and blood color translations are done directly + // because that yields better results. + switch(translation) + { + default: + { + PalEntry *ptrans = GLTranslationPalette::GetPalette(translation); + if (ptrans) + { + for(i = 0; i < 256; i++) + { + penew[i] = (ptrans[i]&0xffffff) | (palette[i]&0xff000000); + } + break; + } + } + + case 0: + memcpy(penew, palette, 256*sizeof(PalEntry)); + break; + } + if (cm!=0) + { + // Apply color modifications like invulnerability, desaturation and Boom colormaps + ModifyPalette(penew, penew, cm, 256); + } + } + // Now penew contains the actual palette that is to be used for creating the image. + + // convert the image according to the translated palette. + for (y=0;y(buffer[pos+3] + (( 255-buffer[pos+3]) * (255-penew[v].a))/255, 0, 255); + } + */ + } + } + } +} diff --git a/src/gl/textures/gl_bitmap.h b/src/gl/textures/gl_bitmap.h new file mode 100644 index 000000000..db3722a6e --- /dev/null +++ b/src/gl/textures/gl_bitmap.h @@ -0,0 +1,34 @@ +#ifndef __GL_BITMAP_H +#define __GL_BITMAP_H + +#include "textures/bitmap.h" +#include "gl/textures/gl_material.h" + + +void ModifyPalette(PalEntry * pout, PalEntry * pin, int cm, int count); + +class FGLBitmap : public FBitmap +{ + int cm; + int translation; +public: + + FGLBitmap() { cm = CM_DEFAULT; translation = 0; } + FGLBitmap(BYTE *buffer, int pitch, int width, int height) + : FBitmap(buffer, pitch, width, height) + { cm = CM_DEFAULT; translation = 0; } + + void SetTranslationInfo(int _cm, int _trans=-1337) + { + if (_cm != -1) cm = _cm; + if (_trans != -1337) translation = _trans; + + } + + virtual void CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int srcwidth, + int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf = NULL); + virtual void CopyPixelData(int originx, int originy, const BYTE * patch, int srcwidth, int srcheight, + int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf = NULL); +}; + +#endif diff --git a/src/gl/textures/gl_hirestex.cpp b/src/gl/textures/gl_hirestex.cpp new file mode 100644 index 000000000..423a783fb --- /dev/null +++ b/src/gl/textures/gl_hirestex.cpp @@ -0,0 +1,373 @@ +/* +** Hires texture management +** +**--------------------------------------------------------------------------- +** Copyright 2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#ifdef _MSC_VER +#define F_OK 0 /* Check for file existence */ +#define W_OK 2 /* Check for write permission */ +#define R_OK 4 /* Check for read permission */ +#include +#else +#include +#endif + +#include "w_wad.h" +#include "m_png.h" +#include "sbar.h" +#include "gi.h" +#include "cmdlib.h" +#include "sc_man.h" +#include "doomstat.h" +#include "d_main.h" +#include "zstring.h" + +#ifdef __GNUC__ +#include "Linux/platform.h" /* Without this it would fail on _access on line 374 (378 now) */ +#endif + +static int Doom2Wad = -1; + +// quick'n dirty hack. Should be enough here... +static void SetDoom2Wad() +{ + if (Doom2Wad == -1) + { + FString iwad = Wads.GetWadFullName(1); + iwad.ToLower(); + if (iwad.IndexOf("plutonia") >= 0) Doom2Wad = 1; + else if (iwad.IndexOf("tnt") >= 0) Doom2Wad = 2; + else Doom2Wad = 0; + } +} +//========================================================================== +// +// Checks for the presence of a hires texture replacement in a Doomsday style PK3 +// +//========================================================================== +int CheckDDPK3(FTexture *tex) +{ + static const char * doom1texpath[]= { + "data/jdoom/textures/doom/%s.%s", "data/jdoom/textures/doom-ult/%s.%s", "data/jdoom/textures/doom1/%s.%s", "data/jdoom/textures/%s.%s", NULL }; + + static const char * doom2texpath[]= { + "data/jdoom/textures/doom2/%s.%s", "data/jdoom/textures/%s.%s", NULL }; + + static const char * pluttexpath[]= { + "data/jdoom/textures/doom2-plut/%s.%s", "data/jdoom/textures/plutonia/%s.%s", "data/jdoom/textures/%s.%s", NULL }; + + static const char * tnttexpath[]= { + "data/jdoom/textures/doom2-tnt/%s.%s", "data/jdoom/textures/tnt/%s.%s", "data/jdoom/textures/%s.%s", NULL }; + + static const char * heretictexpath[]= { + "data/jheretic/textures/%s.%s", NULL }; + + static const char * hexentexpath[]= { + "data/jhexen/textures/%s.%s", NULL }; + + static const char * strifetexpath[]= { + "data/jstrife/textures/%s.%s", NULL }; + + static const char * chextexpath[]= { + "data/jchex/textures/%s.%s", NULL }; + + static const char * doomflatpath[]= { + "data/jdoom/flats/%s.%s", NULL }; + + static const char * hereticflatpath[]= { + "data/jheretic/flats/%s.%s", NULL }; + + static const char * hexenflatpath[]= { + "data/jhexen/flats/%s.%s", NULL }; + + static const char * strifeflatpath[]= { + "data/jstrife/flats/%s.%s", NULL }; + + static const char * chexflatpath[]= { + "data/jchex/flats/%s.%s", NULL }; + + + FString checkName; + const char ** checklist; + BYTE useType=tex->UseType; + + if (useType==FTexture::TEX_SkinSprite || useType==FTexture::TEX_Decal || useType==FTexture::TEX_FontChar) + { + return -3; + } + + bool ispatch = (useType==FTexture::TEX_MiscPatch || useType==FTexture::TEX_Sprite) ; + + // for patches this doesn't work yet + if (ispatch) return -3; + + if (!gameinfo.ConfigName.CompareNoCase("Doom")) + { + if (!(gameinfo.flags & GI_MAPxx)) + { + checklist = useType==FTexture::TEX_Flat? doomflatpath : doom1texpath; + } + else + { + SetDoom2Wad(); + if (Doom2Wad == 1) + checklist = useType==FTexture::TEX_Flat? doomflatpath : pluttexpath; + else if (Doom2Wad == 2) + checklist = useType==FTexture::TEX_Flat? doomflatpath : tnttexpath; + else + checklist = useType==FTexture::TEX_Flat? doomflatpath : doom2texpath; + } + } + else if (!gameinfo.ConfigName.CompareNoCase("Heretic")) + { + checklist = useType==FTexture::TEX_Flat? hereticflatpath : heretictexpath; + } + else if (!gameinfo.ConfigName.CompareNoCase("Hexen")) + { + checklist = useType==FTexture::TEX_Flat? hexenflatpath : hexentexpath; + } + else if (!gameinfo.ConfigName.CompareNoCase("Strife")) + { + checklist = useType==FTexture::TEX_Flat? strifeflatpath : strifetexpath; + } + else if (!gameinfo.ConfigName.CompareNoCase("Chex")) + { + checklist = useType==FTexture::TEX_Flat? chexflatpath : chextexpath; + } + else + return -3; + + while (*checklist) + { + static const char * extensions[] = { "PNG", "JPG", "TGA", "PCX", NULL }; + + for (const char ** extp=extensions; *extp; extp++) + { + checkName.Format(*checklist, tex->Name, *extp); + int lumpnum = Wads.CheckNumForFullName(checkName); + if (lumpnum >= 0) return lumpnum; + } + checklist++; + } + return -3; +} + + +//========================================================================== +// +// Checks for the presence of a hires texture replacement +// +//========================================================================== +int CheckExternalFile(FTexture *tex, bool & hascolorkey) +{ + static const char * doom1texpath[]= { + "%stextures/doom/doom1/%s.%s", "%stextures/doom/doom1/%s-ck.%s", + "%stextures/doom/%s.%s", "%stextures/doom/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * doom2texpath[]= { + "%stextures/doom/doom2/%s.%s", "%stextures/doom/doom2/%s-ck.%s", + "%stextures/doom/%s.%s", "%stextures/doom/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * pluttexpath[]= { + "%stextures/doom/plut/%s.%s", "%stextures/doom/plut/%s-ck.%s", + "%stextures/doom/doom2-plut/%s.%s", "%stextures/doom/doom2-plut/%s-ck.%s", + "%stextures/doom/%s.%s", "%stextures/doom/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * tnttexpath[]= { + "%stextures/doom/tnt/%s.%s", "%stextures/doom/tnt/%s-ck.%s", + "%stextures/doom/doom2-tnt/%s.%s", "%stextures/doom/doom2-tnt/%s-ck.%s", + "%stextures/doom/%s.%s", "%stextures/doom/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * heretictexpath[]= { + "%stextures/heretic/%s.%s", "%stextures/heretic/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * hexentexpath[]= { + "%stextures/hexen/%s.%s", "%stextures/hexen/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * strifetexpath[]= { + "%stextures/strife/%s.%s", "%stextures/strife/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * chextexpath[]= { + "%stextures/chex/%s.%s", "%stextures/chex/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * doom1flatpath[]= { + "%sflats/doom/doom1/%s.%s", "%stextures/doom/doom1/flat-%s.%s", + "%sflats/doom/%s.%s", "%stextures/doom/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * doom2flatpath[]= { + "%sflats/doom/doom2/%s.%s", "%stextures/doom/doom2/flat-%s.%s", + "%sflats/doom/%s.%s", "%stextures/doom/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * plutflatpath[]= { + "%sflats/doom/plut/%s.%s", "%stextures/doom/plut/flat-%s.%s", + "%sflats/doom/doom2-plut/%s.%s", "%stextures/doom/doom2-plut/flat-%s.%s", + "%sflats/doom/%s.%s", "%stextures/doom/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * tntflatpath[]= { + "%sflats/doom/tnt/%s.%s", "%stextures/doom/tnt/flat-%s.%s", + "%sflats/doom/doom2-tnt/%s.%s", "%stextures/doom/doom2-tnt/flat-%s.%s", + "%sflats/doom/%s.%s", "%stextures/doom/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * hereticflatpath[]= { + "%sflats/heretic/%s.%s", "%stextures/heretic/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * hexenflatpath[]= { + "%sflats/hexen/%s.%s", "%stextures/hexen/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * strifeflatpath[]= { + "%sflats/strife/%s.%s", "%stextures/strife/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * chexflatpath[]= { + "%sflats/chex/%s.%s", "%stextures/chex/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * doom1patchpath[]= { + "%spatches/doom/doom1/%s.%s", "%spatches/doom/%s.%s", "%spatches/%s.%s", NULL + }; + + static const char * doom2patchpath[]= { + "%spatches/doom/doom2/%s.%s", "%spatches/doom/%s.%s", "%spatches/%s.%s", NULL + }; + + static const char * plutpatchpath[]= { + "%spatches/doom/plut/%s.%s", "%spatches/doom/%s.%s", "%spatches/%s.%s", NULL + }; + + static const char * tntpatchpath[]= { + "%spatches/doom/tnt/%s.%s", "%spatches/doom/%s.%s", "%spatches/%s.%s", NULL + }; + + static const char * hereticpatchpath[]= { + "%spatches/heretic/%s.%s", "%spatches/%s.%s", NULL + }; + + static const char * hexenpatchpath[]= { + "%spatches/hexen/%s.%s", "%spatches/%s.%s", NULL + }; + + static const char * strifepatchpath[]= { + "%spatches/strife/%s.%s", "%spatches/%s.%s", NULL + }; + + static const char * chexpatchpath[]= { + "%spatches/chex/%s.%s", "%spatches/%s.%s", NULL + }; + + FString checkName; + const char ** checklist; + BYTE useType=tex->UseType; + + if (useType==FTexture::TEX_SkinSprite || useType==FTexture::TEX_Decal || useType==FTexture::TEX_FontChar) + { + return -3; + } + + bool ispatch = (useType==FTexture::TEX_MiscPatch || useType==FTexture::TEX_Sprite) ; + + // for patches this doesn't work yet + if (ispatch) return -3; + + if (!gameinfo.ConfigName.CompareNoCase("Doom")) + { + if (!(gameinfo.flags & GI_MAPxx)) + { + checklist = ispatch ? doom1patchpath : useType==FTexture::TEX_Flat? doom1flatpath : doom1texpath; + } + else + { + SetDoom2Wad(); + if (Doom2Wad == 1) + checklist = ispatch ? plutpatchpath : useType==FTexture::TEX_Flat? plutflatpath : pluttexpath; + else if (Doom2Wad == 2) + checklist = ispatch ? tntpatchpath : useType==FTexture::TEX_Flat? tntflatpath : tnttexpath; + else + checklist = ispatch ? doom2patchpath : useType==FTexture::TEX_Flat? doom2flatpath : doom2texpath; + } + } + else if (!gameinfo.ConfigName.CompareNoCase("Heretic")) + { + checklist = ispatch ? hereticpatchpath : useType==FTexture::TEX_Flat? hereticflatpath : heretictexpath; + } + else if (!gameinfo.ConfigName.CompareNoCase("Hexen")) + { + checklist = ispatch ? hexenpatchpath : useType==FTexture::TEX_Flat? hexenflatpath : hexentexpath; + } + else if (!gameinfo.ConfigName.CompareNoCase("Strife")) + { + checklist = ispatch ?strifepatchpath : useType==FTexture::TEX_Flat? strifeflatpath : strifetexpath; + } + else if (!gameinfo.ConfigName.CompareNoCase("Chex")) + { + checklist = ispatch ?chexpatchpath : useType==FTexture::TEX_Flat? chexflatpath : chextexpath; + } + else + return -3; + + while (*checklist) + { + static const char * extensions[] = { "PNG", "JPG", "TGA", "PCX", NULL }; + + for (const char ** extp=extensions; *extp; extp++) + { + checkName.Format(*checklist, progdir.GetChars(), tex->Name, *extp); + if (_access(checkName, 0) == 0) + { + hascolorkey = !!strstr(checkName, "-ck."); + return Wads.AddExternalFile(checkName); + } + } + checklist++; + } + return -3; +} + + diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp new file mode 100644 index 000000000..36861f713 --- /dev/null +++ b/src/gl/textures/gl_hqresize.cpp @@ -0,0 +1,291 @@ +/* +** gl_hqresize.cpp +** Contains high quality upsampling functions. +** So far Scale2x/3x/4x as described in http://scale2x.sourceforge.net/ +** are implemented. +** +**--------------------------------------------------------------------------- +** Copyright 2008 Benjamin Berkels +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/textures/gl_texture.h" +#include "c_cvars.h" +// [BB] hqnx scaling is only supported with the MS compiler. +#if (defined _MSC_VER) && (!defined _WIN64) +#include "gl/hqnx/hqnx.h" +#endif + +CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ +#ifdef _MSC_VER + if (self < 0 || self > 6) +#else + if (self < 0 || self > 3) +#endif + self = 0; + GLRenderer->FlushTextures(); +} + +CUSTOM_CVAR(Int, gl_texture_hqresize_maxinputsize, 512, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (self > 1024) self = 1024; + GLRenderer->FlushTextures(); +} + +CUSTOM_CVAR(Int, gl_texture_hqresize_targets, 7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + GLRenderer->FlushTextures(); +} + +CVAR (Flag, gl_texture_hqresize_textures, gl_texture_hqresize_targets, 1); +CVAR (Flag, gl_texture_hqresize_sprites, gl_texture_hqresize_targets, 2); +CVAR (Flag, gl_texture_hqresize_fonts, gl_texture_hqresize_targets, 4); + + +static void scale2x ( uint32* inputBuffer, uint32* outputBuffer, int inWidth, int inHeight ) +{ + const int width = 2* inWidth; + const int height = 2 * inHeight; + + for ( int i = 0; i < inWidth; ++i ) + { + const int iMinus = (i > 0) ? (i-1) : 0; + const int iPlus = (i < inWidth - 1 ) ? (i+1) : i; + for ( int j = 0; j < inHeight; ++j ) + { + const int jMinus = (j > 0) ? (j-1) : 0; + const int jPlus = (j < inHeight - 1 ) ? (j+1) : j; + const uint32 A = inputBuffer[ iMinus +inWidth*jMinus]; + const uint32 B = inputBuffer[ iMinus +inWidth*j ]; + const uint32 C = inputBuffer[ iMinus +inWidth*jPlus]; + const uint32 D = inputBuffer[ i +inWidth*jMinus]; + const uint32 E = inputBuffer[ i +inWidth*j ]; + const uint32 F = inputBuffer[ i +inWidth*jPlus]; + const uint32 G = inputBuffer[ iPlus +inWidth*jMinus]; + const uint32 H = inputBuffer[ iPlus +inWidth*j ]; + const uint32 I = inputBuffer[ iPlus +inWidth*jPlus]; + if (B != H && D != F) { + outputBuffer[2*i + width*2*j ] = D == B ? D : E; + outputBuffer[2*i + width*(2*j+1)] = B == F ? F : E; + outputBuffer[2*i+1 + width*2*j ] = D == H ? D : E; + outputBuffer[2*i+1 + width*(2*j+1)] = H == F ? F : E; + } else { + outputBuffer[2*i + width*2*j ] = E; + outputBuffer[2*i + width*(2*j+1)] = E; + outputBuffer[2*i+1 + width*2*j ] = E; + outputBuffer[2*i+1 + width*(2*j+1)] = E; + } + } + } +} + +static void scale3x ( uint32* inputBuffer, uint32* outputBuffer, int inWidth, int inHeight ) +{ + const int width = 3* inWidth; + const int height = 3 * inHeight; + + for ( int i = 0; i < inWidth; ++i ) + { + const int iMinus = (i > 0) ? (i-1) : 0; + const int iPlus = (i < inWidth - 1 ) ? (i+1) : i; + for ( int j = 0; j < inHeight; ++j ) + { + const int jMinus = (j > 0) ? (j-1) : 0; + const int jPlus = (j < inHeight - 1 ) ? (j+1) : j; + const uint32 A = inputBuffer[ iMinus +inWidth*jMinus]; + const uint32 B = inputBuffer[ iMinus +inWidth*j ]; + const uint32 C = inputBuffer[ iMinus +inWidth*jPlus]; + const uint32 D = inputBuffer[ i +inWidth*jMinus]; + const uint32 E = inputBuffer[ i +inWidth*j ]; + const uint32 F = inputBuffer[ i +inWidth*jPlus]; + const uint32 G = inputBuffer[ iPlus +inWidth*jMinus]; + const uint32 H = inputBuffer[ iPlus +inWidth*j ]; + const uint32 I = inputBuffer[ iPlus +inWidth*jPlus]; + if (B != H && D != F) { + outputBuffer[3*i + width*3*j ] = D == B ? D : E; + outputBuffer[3*i + width*(3*j+1)] = (D == B && E != C) || (B == F && E != A) ? B : E; + outputBuffer[3*i + width*(3*j+2)] = B == F ? F : E; + outputBuffer[3*i+1 + width*3*j ] = (D == B && E != G) || (D == H && E != A) ? D : E; + outputBuffer[3*i+1 + width*(3*j+1)] = E; + outputBuffer[3*i+1 + width*(3*j+2)] = (B == F && E != I) || (H == F && E != C) ? F : E; + outputBuffer[3*i+2 + width*3*j ] = D == H ? D : E; + outputBuffer[3*i+2 + width*(3*j+1)] = (D == H && E != I) || (H == F && E != G) ? H : E; + outputBuffer[3*i+2 + width*(3*j+2)] = H == F ? F : E; + } else { + outputBuffer[3*i + width*3*j ] = E; + outputBuffer[3*i + width*(3*j+1)] = E; + outputBuffer[3*i + width*(3*j+2)] = E; + outputBuffer[3*i+1 + width*3*j ] = E; + outputBuffer[3*i+1 + width*(3*j+1)] = E; + outputBuffer[3*i+1 + width*(3*j+2)] = E; + outputBuffer[3*i+2 + width*3*j ] = E; + outputBuffer[3*i+2 + width*(3*j+1)] = E; + outputBuffer[3*i+2 + width*(3*j+2)] = E; + } + } + } +} + +static void scale4x ( uint32* inputBuffer, uint32* outputBuffer, int inWidth, int inHeight ) +{ + int width = 2* inWidth; + int height = 2 * inHeight; + uint32 * buffer2x = new uint32[width*height]; + + scale2x ( reinterpret_cast ( inputBuffer ), reinterpret_cast ( buffer2x ), inWidth, inHeight ); + width *= 2; + height *= 2; + scale2x ( reinterpret_cast ( buffer2x ), reinterpret_cast ( outputBuffer ), 2*inWidth, 2*inHeight ); + delete[] buffer2x; +} + + +static unsigned char *scaleNxHelper( void (*scaleNxFunction) ( uint32* , uint32* , int , int), + const int N, + unsigned char *inputBuffer, + const int inWidth, + const int inHeight, + int &outWidth, + int &outHeight ) +{ + outWidth = N * inWidth; + outHeight = N *inHeight; + unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; + + scaleNxFunction ( reinterpret_cast ( inputBuffer ), reinterpret_cast ( newBuffer ), inWidth, inHeight ); + delete[] inputBuffer; + return newBuffer; +} + +// [BB] hqnx scaling is only supported with the MS compiler. +#if (defined _MSC_VER) && (!defined _WIN64) +static unsigned char *hqNxHelper( void (*hqNxFunction) ( int*, unsigned char*, int, int, int ), + const int N, + unsigned char *inputBuffer, + const int inWidth, + const int inHeight, + int &outWidth, + int &outHeight ) +{ + static int initdone = false; + + if (!initdone) + { + InitLUTs(); + initdone = true; + } + outWidth = N * inWidth; + outHeight = N *inHeight; + + CImage cImageIn; + cImageIn.SetImage(inputBuffer, inWidth, inHeight, 32); + cImageIn.Convert32To17(); + + unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; + hqNxFunction( reinterpret_cast(cImageIn.m_pBitmap), newBuffer, cImageIn.m_Xres, cImageIn.m_Yres, outWidth*4 ); + delete[] inputBuffer; + return newBuffer; +} +#endif + +//=========================================================================== +// +// [BB] Upsamples the texture in inputBuffer, frees inputBuffer and returns +// the upsampled buffer. +// +//=========================================================================== +unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight, bool hasAlpha ) +{ + // [BB] Make sure that outWidth and outHeight denote the size of + // the returned buffer even if we don't upsample the input buffer. + outWidth = inWidth; + outHeight = inHeight; + + // [BB] Don't resample if the width or height of the input texture is bigger than gl_texture_hqresize_maxinputsize. + if ( ( inWidth > gl_texture_hqresize_maxinputsize ) || ( inHeight > gl_texture_hqresize_maxinputsize ) ) + return inputBuffer; + + // [BB] Don't try to upsample textures based off FCanvasTexture. + if ( inputTexture->bHasCanvas ) + return inputBuffer; + + // [BB] Don't upsample non-shader handled warped textures. Needs too much memory and time + if (gl.shadermodel == 2 || (gl.shadermodel == 3 && inputTexture->bWarped)) + return inputBuffer; + + switch (inputTexture->UseType) + { + case FTexture::TEX_Sprite: + case FTexture::TEX_SkinSprite: + if (!(gl_texture_hqresize_targets & 2)) return inputBuffer; + break; + + case FTexture::TEX_FontChar: + if (!(gl_texture_hqresize_targets & 4)) return inputBuffer; + break; + + default: + if (!(gl_texture_hqresize_targets & 1)) return inputBuffer; + break; + } + + if (inputBuffer) + { + outWidth = inWidth; + outHeight = inHeight; + int type = gl_texture_hqresize; + // hqNx does not preserve the alpha channel so fall back to ScaleNx for such textures + if (hasAlpha && type > 3) + { + type -= 3; + } + + switch (type) + { + case 1: + return scaleNxHelper( &scale2x, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 2: + return scaleNxHelper( &scale3x, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 3: + return scaleNxHelper( &scale4x, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); +// [BB] hqnx scaling is only supported with the MS compiler. +#if (defined _MSC_VER) && (!defined _WIN64) + case 4: + return hqNxHelper( &hq2x_32, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 5: + return hqNxHelper( &hq3x_32, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 6: + return hqNxHelper( &hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); +#endif + } + } + return inputBuffer; +} diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp new file mode 100644 index 000000000..f81d003d4 --- /dev/null +++ b/src/gl/textures/gl_hwtexture.cpp @@ -0,0 +1,420 @@ +/* +** gltexture.cpp +** Low level OpenGL texture handling. These classes are also +** containers for the various translations a texture can have. +** +**--------------------------------------------------------------------------- +** Copyright 2004-2005 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "templates.h" +#include "m_crc32.h" +#include "c_cvars.h" +#include "c_dispatch.h" +#include "v_palette.h" + +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/textures/gl_material.h" + + +extern TexFilter_s TexFilter[]; +extern int TexFormat[]; +EXTERN_CVAR(Bool, gl_clamp_per_texture) + + +//=========================================================================== +// +// Static texture data +// +//=========================================================================== +unsigned int FHardwareTexture::lastbound[FHardwareTexture::MAX_TEXTURES]; + +//=========================================================================== +// +// STATIC - Gets the maximum size of hardware textures +// +//=========================================================================== +int FHardwareTexture::GetTexDimension(int value) +{ + if (value > gl.max_texturesize) return gl.max_texturesize; + if (gl.flags&RFL_NPOT_TEXTURE) return value; + + int i=1; + while (iw) + memcpy( scaledbuffer + rw * y * 4 + w * 4, + scaledbuffer + rw * y * 4 + w * 4 -4, 4); + } + // also duplicate the last line for the same reason! + memcpy( scaledbuffer + rw * h * 4, scaledbuffer + rw * (h-1) * 4, w*4 + 4); + + deletebuffer=true; + buffer=scaledbuffer; + } + } + } + gl.TexImage2D(GL_TEXTURE_2D, 0, texformat, rw, rh, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + + if (deletebuffer) free(buffer); + + // When using separate samplers the stuff below is not needed. + // if (gl.flags & RFL_SAMPLER_OBJECTS) return; + + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); + clampmode = wrapparam==GL_CLAMP? GLT_CLAMPX|GLT_CLAMPY : 0; + + if (forcenofiltering) + { + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + gl.TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + } + else + { + if (mipmap && use_mipmapping) + { + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + if (gl_texture_filter_anisotropic) + { + gl.TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + } + } + else + { + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + } + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + } +} + + +//=========================================================================== +// +// Creates a texture +// +//=========================================================================== +FHardwareTexture::FHardwareTexture(int _width, int _height, bool _mipmap, bool wrap, bool nofilter, bool nocompression) +{ + forcenocompression = nocompression; + mipmap=_mipmap; + texwidth=_width; + texheight=_height; + + int cm_arraysize = CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size(); + glTexID = new unsigned[cm_arraysize]; + memset(glTexID,0,sizeof(unsigned int)*cm_arraysize); + clampmode=0; + glDepthID = 0; + forcenofiltering = nofilter; +} + + +//=========================================================================== +// +// Deletes a texture id and unbinds it from the texture units +// +//=========================================================================== +void FHardwareTexture::DeleteTexture(unsigned int texid) +{ + if (texid != 0) + { + for(int i = 0; i < MAX_TEXTURES; i++) + { + if (lastbound[i] == texid) + { + lastbound[i] = 0; + } + } + gl.DeleteTextures(1, &texid); + } +} + +//=========================================================================== +// +// Frees all associated resources +// +//=========================================================================== +void FHardwareTexture::Clean(bool all) +{ + int cm_arraysize = CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size(); + + if (all) + { + for (int i=0;i= CM_MAXCOLORMAP) cm=CM_DEFAULT; + + if (translation==0) + { + return &glTexID[cm]; + } + + // normally there aren't more than very few different + // translations here so this isn't performance critical. + for(unsigned int i=0;i= CM_MAXCOLORMAP) cm=CM_DEFAULT; + + unsigned int * pTexID=GetTexID(cm, translation); + + if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0+texunit); + LoadImage(buffer, w, h, *pTexID, wrap? GL_REPEAT:GL_CLAMP, cm==CM_SHADE, texunit); + if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0); + return *pTexID; +} + + diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h new file mode 100644 index 000000000..da093df4e --- /dev/null +++ b/src/gl/textures/gl_hwtexture.h @@ -0,0 +1,77 @@ + +#ifndef __GLTEXTURE_H +#define __GLTEXTURE_H + +#define SHADED_TEXTURE -1 +#define DIRECT_PALETTE -2 + +#include "tarray.h" + +class FCanvasTexture; +class AActor; + +enum +{ + GLT_CLAMPX=1, + GLT_CLAMPY=2 +}; + +class FHardwareTexture +{ + enum + { + MAX_TEXTURES = 16 + }; + + struct TranslatedTexture + { + unsigned int glTexID; + int translation; + int cm; + }; + +public: + + static unsigned int lastbound[MAX_TEXTURES]; + static int lastactivetexture; + static bool supportsNonPower2; + static int max_texturesize; + + static int GetTexDimension(int value); + +private: + + short texwidth, texheight; + //float scalexfac, scaleyfac; + bool mipmap; + BYTE clampmode; + bool forcenofiltering; + bool forcenocompression; + + unsigned int * glTexID; + TArray glTexID_Translated; + unsigned int glDepthID; // only used by camera textures + + void LoadImage(unsigned char * buffer,int w, int h, unsigned int & glTexID,int wrapparam, bool alphatexture, int texunit); + unsigned * GetTexID(int cm, int translation); + + int GetDepthBuffer(); + void DeleteTexture(unsigned int texid); + +public: + FHardwareTexture(int w, int h, bool mip, bool wrap, bool nofilter, bool nocompress); + ~FHardwareTexture(); + + static void Unbind(int texunit); + static void UnbindAll(); + + void BindToFrameBuffer(); + + unsigned int Bind(int texunit, int cm, int translation=0); + unsigned int CreateTexture(unsigned char * buffer, int w, int h,bool wrap, int texunit, int cm, int translation=0); + void Resize(int _width, int _height) ; + + void Clean(bool all); +}; + +#endif diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp new file mode 100644 index 000000000..53d01a3b9 --- /dev/null +++ b/src/gl/textures/gl_material.cpp @@ -0,0 +1,1123 @@ +/* +** gl_material.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2004-2009 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "w_wad.h" +#include "m_png.h" +#include "sbar.h" +#include "gi.h" +#include "cmdlib.h" +#include "c_dispatch.h" +#include "stats.h" +#include "r_utility.h" +#include "templates.h" +#include "sc_man.h" +#include "colormatcher.h" + +//#include "gl/gl_intern.h" + +#include "gl/system/gl_framebuffer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/data/gl_data.h" +#include "gl/textures/gl_texture.h" +#include "gl/textures/gl_translate.h" +#include "gl/textures/gl_bitmap.h" +#include "gl/textures/gl_material.h" +#include "gl/shaders/gl_shader.h" + +EXTERN_CVAR(Bool, gl_render_precise) +EXTERN_CVAR(Int, gl_lightmode) +EXTERN_CVAR(Bool, gl_precache) +EXTERN_CVAR(Bool, gl_texture_usehires) + +//=========================================================================== +// +// The GL texture maintenance class +// +//=========================================================================== + +//=========================================================================== +// +// Constructor +// +//=========================================================================== +FGLTexture::FGLTexture(FTexture * tx, bool expandpatches) +{ + assert(tx->gl_info.SystemTexture == NULL); + tex = tx; + + glpatch=NULL; + for(int i=0;i<5;i++) gltexture[i]=NULL; + HiresLump=-1; + hirestexture = NULL; + currentwarp = 0; + bHasColorkey = false; + bIsTransparent = -1; + bExpand = expandpatches; + tex->gl_info.SystemTexture = this; +} + +//=========================================================================== +// +// Destructor +// +//=========================================================================== + +FGLTexture::~FGLTexture() +{ + Clean(true); + if (hirestexture) delete hirestexture; +} + +//========================================================================== +// +// Checks for the presence of a hires texture replacement and loads it +// +//========================================================================== +unsigned char *FGLTexture::LoadHiresTexture(FTexture *tex, int *width, int *height, int cm) +{ + if (HiresLump==-1) + { + bHasColorkey = false; + HiresLump = CheckDDPK3(tex); + if (HiresLump < 0) HiresLump = CheckExternalFile(tex, bHasColorkey); + + if (HiresLump >=0) + { + hirestexture = FTexture::CreateTexture(HiresLump, FTexture::TEX_Any); + } + } + if (hirestexture != NULL) + { + int w=hirestexture->GetWidth(); + int h=hirestexture->GetHeight(); + + unsigned char * buffer=new unsigned char[w*(h+1)*4]; + memset(buffer, 0, w * (h+1) * 4); + + FGLBitmap bmp(buffer, w*4, w, h); + bmp.SetTranslationInfo(cm); + + + int trans = hirestexture->CopyTrueColorPixels(&bmp, 0, 0); + hirestexture->CheckTrans(buffer, w*h, trans); + bIsTransparent = hirestexture->gl_info.mIsTransparent; + + if (bHasColorkey) + { + // This is a crappy Doomsday color keyed image + // We have to remove the key manually. :( + DWORD * dwdata=(DWORD*)buffer; + for (int i=(w*h);i>0;i--) + { + if (dwdata[i]==0xffffff00 || dwdata[i]==0xffff00ff) dwdata[i]=0; + } + } + *width = w; + *height = h; + return buffer; + } + return NULL; +} + +//=========================================================================== +// +// Deletes all allocated resources +// +//=========================================================================== + +void FGLTexture::Clean(bool all) +{ + for(int i=0;i<5;i++) + { + if (gltexture[i]) + { + if (!all) gltexture[i]->Clean(false); + else + { + delete gltexture[i]; + gltexture[i]=NULL; + } + } + } + if (glpatch) + { + if (!all) glpatch->Clean(false); + else + { + delete glpatch; + glpatch=NULL; + } + } +} + +//=========================================================================== +// +// FGLTex::WarpBuffer +// +//=========================================================================== + +BYTE *FGLTexture::WarpBuffer(BYTE *buffer, int Width, int Height, int warp) +{ + if (Width > 256 || Height > 256) return buffer; + + DWORD *in = (DWORD*)buffer; + DWORD *out = (DWORD*)new BYTE[4*Width*Height]; + float Speed = static_cast(tex)->GetSpeed(); + + static_cast(tex)->GenTime = r_FrameTime; + + static DWORD linebuffer[256]; // anything larger will bring down performance so it is excluded above. + DWORD timebase = DWORD(r_FrameTime*Speed*23/28); + int xsize = Width; + int ysize = Height; + int xmask = xsize - 1; + int ymask = ysize - 1; + int ds_xbits; + int i,x; + + if (warp == 1) + { + for(ds_xbits=-1,i=Width; i; i>>=1, ds_xbits++); + + for (x = xsize-1; x >= 0; x--) + { + int yt, yf = (finesine[(timebase+(x+17)*128)&FINEMASK]>>13) & ymask; + const DWORD *source = in + x; + DWORD *dest = out + x; + for (yt = ysize; yt; yt--, yf = (yf+1)&ymask, dest += xsize) + { + *dest = *(source+(yf<= 0; y--) + { + int xt, xf = (finesine[(timebase+y*128)&FINEMASK]>>13) & xmask; + DWORD *source = out + (y<>=1, ybits++); + + DWORD timebase = (r_FrameTime * Speed * 40 / 28); + for (x = xsize-1; x >= 0; x--) + { + for (int y = ysize-1; y >= 0; y--) + { + int xt = (x + 128 + + ((finesine[(y*128 + timebase*5 + 900) & 8191]*2)>>FRACBITS) + + ((finesine[(x*256 + timebase*4 + 300) & 8191]*2)>>FRACBITS)) & xmask; + int yt = (y + 128 + + ((finesine[(y*128 + timebase*3 + 700) & 8191]*2)>>FRACBITS) + + ((finesine[(x*256 + timebase*4 + 1200) & 8191]*2)>>FRACBITS)) & ymask; + const DWORD *source = in + (xt << ybits) + yt; + DWORD *dest = out + (x << ybits) + y; + *dest = *source; + } + } + } + delete [] buffer; + return (BYTE*)out; +} + +//=========================================================================== +// +// Initializes the buffer for the texture data +// +//=========================================================================== + +unsigned char * FGLTexture::CreateTexBuffer(int cm, int translation, int & w, int & h, bool expand, FTexture *hirescheck, int warp) +{ + unsigned char * buffer; + int W, H; + + + // Textures that are already scaled in the texture lump will not get replaced + // by hires textures + if (gl_texture_usehires && hirescheck != NULL) + { + buffer = LoadHiresTexture (hirescheck, &w, &h, cm); + if (buffer) + { + return buffer; + } + } + + W = w = tex->GetWidth() + expand*2; + H = h = tex->GetHeight() + expand*2; + + + buffer=new unsigned char[W*(H+1)*4]; + memset(buffer, 0, W * (H+1) * 4); + + FGLBitmap bmp(buffer, W*4, W, H); + bmp.SetTranslationInfo(cm, translation); + + if (tex->bComplex) + { + FBitmap imgCreate; + + // The texture contains special processing so it must be composited using the + // base bitmap class and then be converted as a whole. + if (imgCreate.Create(W, H)) + { + memset(imgCreate.GetPixels(), 0, W * H * 4); + int trans = tex->CopyTrueColorPixels(&imgCreate, expand, expand); + bmp.CopyPixelDataRGB(0, 0, imgCreate.GetPixels(), W, H, 4, W * 4, 0, CF_BGRA); + tex->CheckTrans(buffer, W*H, trans); + bIsTransparent = tex->gl_info.mIsTransparent; + } + } + else if (translation<=0) + { + int trans = tex->CopyTrueColorPixels(&bmp, expand, expand); + tex->CheckTrans(buffer, W*H, trans); + bIsTransparent = tex->gl_info.mIsTransparent; + } + else + { + // When using translations everything must be mapped to the base palette. + // Since FTexture's method is doing exactly that by calling GetPixels let's use that here + // to do all the dirty work for us. ;) + tex->FTexture::CopyTrueColorPixels(&bmp, expand, expand); + bIsTransparent = 0; + } + + if (warp != 0) + { + buffer = WarpBuffer(buffer, W, H, warp); + } + // [BB] The hqnx upsampling (not the scaleN one) destroys partial transparency, don't upsamle textures using it. + // Also don't upsample warped textures. + else //if (bIsTransparent != 1) + { + // [BB] Potentially upsample the buffer. + buffer = gl_CreateUpsampledTextureBuffer ( tex, buffer, W, H, w, h, bIsTransparent || cm == CM_SHADE ); + } + currentwarp = warp; + currentwarptime = gl_frameMS; + + return buffer; +} + + +//=========================================================================== +// +// Create hardware texture for world use +// +//=========================================================================== + +FHardwareTexture *FGLTexture::CreateTexture(int clampmode) +{ + if (tex->UseType==FTexture::TEX_Null) return NULL; // Cannot register a NULL texture + if (!gltexture[clampmode]) + { + gltexture[clampmode] = new FHardwareTexture(tex->GetWidth(), tex->GetHeight(), true, true, false, tex->gl_info.bNoCompress); + } + return gltexture[clampmode]; +} + +//=========================================================================== +// +// Create Hardware texture for patch use +// +//=========================================================================== + +bool FGLTexture::CreatePatch() +{ + if (tex->UseType==FTexture::TEX_Null) return false; // Cannot register a NULL texture + if (!glpatch) + { + glpatch=new FHardwareTexture(tex->GetWidth() + bExpand, tex->GetHeight() + bExpand, false, false, tex->gl_info.bNoFilter, tex->gl_info.bNoCompress); + } + if (glpatch) return true; + return false; +} + + +//=========================================================================== +// +// Binds a texture to the renderer +// +//=========================================================================== + +const FHardwareTexture *FGLTexture::Bind(int texunit, int cm, int clampmode, int translation, FTexture *hirescheck, int warp) +{ + int usebright = false; + + if (translation <= 0) translation = -translation; + else translation = GLTranslationPalette::GetInternalTranslation(translation); + + FHardwareTexture *hwtex; + + if (gltexture[4] != NULL && clampmode < 4 && gltexture[clampmode] == NULL) + { + hwtex = gltexture[clampmode] = gltexture[4]; + gltexture[4] = NULL; + + if (hwtex->Bind(texunit, cm, translation)) + { + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (clampmode & GLT_CLAMPX)? GL_CLAMP_TO_EDGE : GL_REPEAT); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (clampmode & GLT_CLAMPY)? GL_CLAMP_TO_EDGE : GL_REPEAT); + } + } + else + { + hwtex = CreateTexture(clampmode); + } + + if (hwtex) + { + if ((warp != 0 || currentwarp != warp) && currentwarptime != gl_frameMS) + { + // must recreate the texture + Clean(true); + hwtex = CreateTexture(clampmode); + } + + // Texture has become invalid + else if ((warp == 0 && !tex->bHasCanvas) && tex->CheckModified()) + { + Clean(true); + hwtex = CreateTexture(clampmode); + } + + // Bind it to the system. + if (!hwtex->Bind(texunit, cm, translation)) + { + + int w, h; + + // Create this texture + unsigned char * buffer = NULL; + + if (!tex->bHasCanvas) + { + buffer = CreateTexBuffer(cm, translation, w, h, false, hirescheck, warp); + tex->ProcessData(buffer, w, h, false); + } + if (!hwtex->CreateTexture(buffer, w, h, true, texunit, cm, translation)) + { + // could not create texture + delete[] buffer; + return NULL; + } + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (clampmode & GLT_CLAMPX)? GL_CLAMP_TO_EDGE : GL_REPEAT); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (clampmode & GLT_CLAMPY)? GL_CLAMP_TO_EDGE : GL_REPEAT); + delete[] buffer; + } + + if (tex->bHasCanvas) static_cast(tex)->NeedUpdate(); + return hwtex; + } + return NULL; +} + +//=========================================================================== +// +// Binds a sprite to the renderer +// +//=========================================================================== +const FHardwareTexture * FGLTexture::BindPatch(int texunit, int cm, int translation, int warp) +{ + bool usebright = false; + int transparm = translation; + + if (translation <= 0) translation = -translation; + else translation = GLTranslationPalette::GetInternalTranslation(translation); + + if (CreatePatch()) + { + if (warp != 0 || currentwarp != warp) + { + // must recreate the texture + Clean(true); + CreatePatch(); + } + + // Texture has become invalid + else if ((warp == 0 && !tex->bHasCanvas) && tex->CheckModified()) + { + Clean(true); + CreatePatch(); + } + + + // Bind it to the system. + if (!glpatch->Bind(texunit, cm, translation)) + { + int w, h; + + // Create this texture + unsigned char * buffer = CreateTexBuffer(cm, translation, w, h, bExpand, NULL, warp); + tex->ProcessData(buffer, w, h, true); + if (!glpatch->CreateTexture(buffer, w, h, false, texunit, cm, translation)) + { + // could not create texture + delete[] buffer; + return NULL; + } + delete[] buffer; + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } + return glpatch; + } + return NULL; +} + + +//=========================================================================== +// +// +// +//=========================================================================== + +fixed_t FTexCoordInfo::RowOffset(fixed_t rowoffset) const +{ + if (mTempScaleY == FRACUNIT) + { + if (mScaleY==FRACUNIT || mWorldPanning) return rowoffset; + else return FixedDiv(rowoffset, mScaleY); + } + else + { + if (mWorldPanning) return FixedDiv(rowoffset, mTempScaleY); + else return FixedDiv(rowoffset, mScaleY); + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +fixed_t FTexCoordInfo::TextureOffset(fixed_t textureoffset) const +{ + if (mTempScaleX == FRACUNIT) + { + if (mScaleX==FRACUNIT || mWorldPanning) return textureoffset; + else return FixedDiv(textureoffset, mScaleX); + } + else + { + if (mWorldPanning) return FixedDiv(textureoffset, mTempScaleX); + else return FixedDiv(textureoffset, mScaleX); + } +} + +//=========================================================================== +// +// Returns the size for which texture offset coordinates are used. +// +//=========================================================================== + +fixed_t FTexCoordInfo::TextureAdjustWidth() const +{ + if (mWorldPanning) + { + if (mTempScaleX == FRACUNIT) return mRenderWidth; + else return FixedDiv(mWidth, mTempScaleX); + } + else return mWidth; +} + + + +//=========================================================================== +// +// +// +//=========================================================================== +FGLTexture * FMaterial::ValidateSysTexture(FTexture * tex, bool expand) +{ + if (tex && tex->UseType!=FTexture::TEX_Null) + { + FGLTexture *gltex = tex->gl_info.SystemTexture; + if (gltex == NULL) + { + gltex = new FGLTexture(tex, expand); + } + return gltex; + } + return NULL; +} + +//=========================================================================== +// +// Constructor +// +//=========================================================================== +TArray FMaterial::mMaterials; +int FMaterial::mMaxBound; + +FMaterial::FMaterial(FTexture * tx, bool forceexpand) +{ + assert(tx->gl_info.Material == NULL); + + bool expanded = tx->UseType == FTexture::TEX_Sprite || + tx->UseType == FTexture::TEX_SkinSprite || + tx->UseType == FTexture::TEX_Decal || + forceexpand; + + mShaderIndex = 0; + + // TODO: apply custom shader object here + /* if (tx->CustomShaderDefinition) + { + } + else + */ + if (tx->bWarped) + { + mShaderIndex = tx->bWarped; + expanded = false; + tx->gl_info.shaderspeed = static_cast(tx)->GetSpeed(); + } + else if (tx->bHasCanvas) + { + expanded = false; + } + else if (gl.shadermodel > 2) + { + if (tx->gl_info.shaderindex >= FIRST_USER_SHADER) + { + mShaderIndex = tx->gl_info.shaderindex; + expanded = false; + } + else + { + tx->CreateDefaultBrightmap(); + if (tx->gl_info.Brightmap != NULL) + { + ValidateSysTexture(tx->gl_info.Brightmap, expanded); + FTextureLayer layer = {tx->gl_info.Brightmap, false}; + mTextureLayers.Push(layer); + mShaderIndex = 3; + } + } + } + + + for (int i=GLUSE_PATCH; i<=GLUSE_TEXTURE; i++) + { + Width[i] = tx->GetWidth(); + Height[i] = tx->GetHeight(); + LeftOffset[i] = tx->LeftOffset; + TopOffset[i] = tx->TopOffset; + RenderWidth[i] = tx->GetScaledWidth(); + RenderHeight[i] = tx->GetScaledHeight(); + } + Width[GLUSE_SPRITE] = Width[GLUSE_PATCH]; + Height[GLUSE_SPRITE] = Height[GLUSE_PATCH]; + LeftOffset[GLUSE_SPRITE] = LeftOffset[GLUSE_PATCH]; + TopOffset[GLUSE_SPRITE] = TopOffset[GLUSE_PATCH]; + SpriteU[0] = SpriteV[0] = 0; + spriteright = SpriteU[1] = Width[GLUSE_PATCH] / (float)FHardwareTexture::GetTexDimension(Width[GLUSE_PATCH]); + spritebottom = SpriteV[1] = Height[GLUSE_PATCH] / (float)FHardwareTexture::GetTexDimension(Height[GLUSE_PATCH]); + + mTextureLayers.ShrinkToFit(); + mMaxBound = -1; + mMaterials.Push(this); + tx->gl_info.Material = this; + if (tx->bHasCanvas) tx->gl_info.mIsTransparent = 0; + tex = tx; + + tx->gl_info.mExpanded = expanded; + FTexture *basetex = tx->GetRedirect(gl.shadermodel < 4); + if (!expanded && !basetex->gl_info.mExpanded) + { + // check if the texture is just a simple redirect to a patch + // If so we should use the patch for texture creation to + // avoid eventual redundancies. + // This may only be done if both textures use the same expansion mode + mBaseLayer = ValidateSysTexture(basetex, false); + } + else if (!expanded) + { + // if we got a non-expanded texture that redirects to an expanded one + mBaseLayer = ValidateSysTexture(tx, false); + } + else + { + // a little adjustment to make sprites look better with texture filtering: + // create a 1 pixel wide empty frame around them. + RenderWidth[GLUSE_PATCH]+=2; + RenderHeight[GLUSE_PATCH]+=2; + Width[GLUSE_PATCH]+=2; + Height[GLUSE_PATCH]+=2; + LeftOffset[GLUSE_PATCH]+=1; + TopOffset[GLUSE_PATCH]+=1; + Width[GLUSE_SPRITE] += 2; + Height[GLUSE_SPRITE] += 2; + LeftOffset[GLUSE_SPRITE] += 1; + TopOffset[GLUSE_SPRITE] += 1; + spriteright = SpriteU[1] = Width[GLUSE_PATCH] / (float)FHardwareTexture::GetTexDimension(Width[GLUSE_PATCH]); + spritebottom = SpriteV[1] = Height[GLUSE_PATCH] / (float)FHardwareTexture::GetTexDimension(Height[GLUSE_PATCH]); + + mBaseLayer = ValidateSysTexture(tx, true); + + if (gl.flags & RFL_NPOT_TEXTURE) // trimming only works if non-power-of-2 textures are supported + { + int trim[4]; + + if (TrimBorders(trim)) + { + Width[GLUSE_SPRITE] = trim[2] + 2; + Height[GLUSE_SPRITE] = trim[3] + 2; + LeftOffset[GLUSE_SPRITE] -= trim[0]; + TopOffset[GLUSE_SPRITE] -= trim[1]; + + SpriteU[0] = SpriteU[1] * (trim[0] / (float)Width[GLUSE_PATCH]); + SpriteV[0] = SpriteV[1] * (trim[1] / (float)Height[GLUSE_PATCH]); + SpriteU[1] *= (trim[0]+trim[2]+2) / (float)Width[GLUSE_PATCH]; + SpriteV[1] *= (trim[1]+trim[3]+2) / (float)Height[GLUSE_PATCH]; + } + } + } +} + +//=========================================================================== +// +// Destructor +// +//=========================================================================== + +FMaterial::~FMaterial() +{ + for(unsigned i=0;i= size) + { + rect[0] = 0; + rect[1] = 0; + rect[2] = 1; + rect[3] = 1; + delete [] buffer; + return true; + } + + for(last = size-1; last >= first; last--) + { + if (buffer[last*4+3] != 0) break; + } + + rect[1] = first / w; + rect[3] = 1 + last/w - rect[1]; + + rect[0] = 0; + rect[2] = w; + + unsigned char *bufferoff = buffer + (rect[1] * w * 4); + h = rect[3]; + + for(int x = 0; x < w; x++) + { + for(int y = 0; y < h; y++) + { + if (bufferoff[(x+y*w)*4+3] != 0) goto outl; + } + rect[0]++; + } +outl: + rect[2] -= rect[0]; + + for(int x = w-1; rect[2] > 1; x--) + { + for(int y = 0; y < h; y++) + { + if (bufferoff[(x+y*w)*4+3] != 0) + { + delete [] buffer; + return true; + } + } + rect[2]--; + } + delete [] buffer; + return true; +} + + +//=========================================================================== +// +// Binds a texture to the renderer +// +//=========================================================================== + +void FMaterial::Bind(int cm, int clampmode, int translation, int overrideshader) +{ + int usebright = false; + int shaderindex = overrideshader > 0? overrideshader : mShaderIndex; + int maxbound = 0; + bool allowhires = tex->xScale == FRACUNIT && tex->yScale == FRACUNIT; + + int softwarewarp = gl_RenderState.SetupShader(tex->bHasCanvas, shaderindex, cm, tex->gl_info.shaderspeed); + + if (tex->bHasCanvas || tex->bWarped) clampmode = 0; + else if (clampmode != -1) clampmode &= 3; + else clampmode = 4; + + const FHardwareTexture *gltexture = mBaseLayer->Bind(0, cm, clampmode, translation, allowhires? tex:NULL, softwarewarp); + if (gltexture != NULL && shaderindex > 0 && overrideshader == 0) + { + for(unsigned i=0;iGetID(); + layer = TexMan(id); + ValidateSysTexture(layer, false); + } + else + { + layer = mTextureLayers[i].texture; + } + layer->gl_info.SystemTexture->Bind(i+1, CM_DEFAULT, clampmode, 0, NULL, false); + maxbound = i+1; + } + } + // unbind everything from the last texture that's still active + for(int i=maxbound+1; i<=mMaxBound;i++) + { + FHardwareTexture::Unbind(i); + mMaxBound = maxbound; + } +} + + +//=========================================================================== +// +// Binds a texture to the renderer +// +//=========================================================================== + +void FMaterial::BindPatch(int cm, int translation, int overrideshader) +{ + int usebright = false; + int shaderindex = overrideshader > 0? overrideshader : mShaderIndex; + int maxbound = 0; + + int softwarewarp = gl_RenderState.SetupShader(tex->bHasCanvas, shaderindex, cm, tex->gl_info.shaderspeed); + + const FHardwareTexture *glpatch = mBaseLayer->BindPatch(0, cm, translation, softwarewarp); + // The only multitexture effect usable on sprites is the brightmap. + if (glpatch != NULL && shaderindex == 3) + { + mTextureLayers[0].texture->gl_info.SystemTexture->BindPatch(1, CM_DEFAULT, 0, 0); + maxbound = 1; + } + // unbind everything from the last texture that's still active + for(int i=maxbound+1; i<=mMaxBound;i++) + { + FHardwareTexture::Unbind(i); + mMaxBound = maxbound; + } +} + + +//=========================================================================== +// +// +// +//=========================================================================== +void FMaterial::Precache() +{ + if (tex->UseType==FTexture::TEX_Sprite) + { + BindPatch(CM_DEFAULT, 0); + } + else + { + int cached = 0; + for(int i=0;i<4;i++) + { + if (mBaseLayer->gltexture[i] != 0) + { + Bind (CM_DEFAULT, i, 0); + cached++; + } + if (cached == 0) Bind(CM_DEFAULT, -1, 0); + } + } +} + +//=========================================================================== +// +// This function is needed here to temporarily manipulate the texture +// for per-wall scaling so that the coordinate functions return proper +// results. Doing this here is much easier than having the calling code +// make these calculations. +// +//=========================================================================== + +void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const +{ + if (x == FRACUNIT) + { + tci->mRenderWidth = RenderWidth[GLUSE_TEXTURE]; + tci->mScaleX = tex->xScale; + tci->mTempScaleX = FRACUNIT; + } + else + { + fixed_t scale_x = FixedMul(x, tex->xScale); + int foo = (Width[GLUSE_TEXTURE] << 17) / scale_x; + tci->mRenderWidth = (foo >> 1) + (foo & 1); + tci->mScaleX = scale_x; + tci->mTempScaleX = x; + } + + if (y == FRACUNIT) + { + tci->mRenderHeight = RenderHeight[GLUSE_TEXTURE]; + tci->mScaleY = tex->yScale; + tci->mTempScaleY = FRACUNIT; + } + else + { + fixed_t scale_y = FixedMul(y, tex->yScale); + int foo = (Height[GLUSE_TEXTURE] << 17) / scale_y; + tci->mRenderHeight = (foo >> 1) + (foo & 1); + tci->mScaleY = scale_y; + tci->mTempScaleY = y; + } + if (tex->bHasCanvas) + { + tci->mScaleY = -tci->mScaleY; + tci->mRenderHeight = -tci->mRenderHeight; + } + tci->mWorldPanning = tex->bWorldPanning; + tci->mWidth = Width[GLUSE_TEXTURE]; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +int FMaterial::GetAreas(FloatRect **pAreas) const +{ + if (mShaderIndex == 0) // texture splitting can only be done if there's no attached effects + { + FTexture *tex = mBaseLayer->tex; + *pAreas = tex->gl_info.areas; + return tex->gl_info.areacount; + } + else + { + return 0; + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FMaterial::BindToFrameBuffer() +{ + if (mBaseLayer->gltexture == NULL) + { + // must create the hardware texture first + mBaseLayer->Bind(0, CM_DEFAULT, 0, 0, NULL, 0); + FHardwareTexture::Unbind(0); + } + mBaseLayer->gltexture[0]->BindToFrameBuffer(); +} + +//=========================================================================== +// +// GetRect +// +//=========================================================================== + +void FMaterial::GetRect(FloatRect * r, ETexUse i) const +{ + r->left = -GetScaledLeftOffsetFloat(i); + r->top = -GetScaledTopOffsetFloat(i); + r->width = GetScaledWidthFloat(i); + r->height = GetScaledHeightFloat(i); +} + + +//========================================================================== +// +// Gets a texture from the texture manager and checks its validity for +// GL rendering. +// +//========================================================================== + +FMaterial * FMaterial::ValidateTexture(FTexture * tex) +{ + if (tex && tex->UseType!=FTexture::TEX_Null) + { + FMaterial *gltex = tex->gl_info.Material; + if (gltex == NULL) + { + //@sync-tex + gltex = new FMaterial(tex, false); + } + return gltex; + } + return NULL; +} + +FMaterial * FMaterial::ValidateTexture(FTextureID no, bool translate) +{ + return ValidateTexture(translate? TexMan(no) : TexMan[no]); +} + + +//========================================================================== +// +// Flushes all hardware dependent data +// +//========================================================================== + +void FMaterial::FlushAll() +{ + for(int i=mMaterials.Size()-1;i>=0;i--) + { + mMaterials[i]->Clean(true); + } + // This is for shader layers. All shader layers must be managed by the texture manager + // so this will catch everything. + for(int i=TexMan.NumTextures()-1;i>=0;i--) + { + FGLTexture *gltex = TexMan.ByIndex(i)->gl_info.SystemTexture; + if (gltex != NULL) gltex->Clean(true); + } +} + +//========================================================================== +// +// Prints some texture info +// +//========================================================================== + +int FGLTexture::Dump(int i) +{ + int cnt = 0; + int lump = tex->GetSourceLump(); + Printf(PRINT_LOG, "Texture '%s' (Index %d, Lump %d, Name '%s'):\n", tex->Name, i, lump, Wads.GetLumpFullName(lump)); + if (hirestexture) Printf(PRINT_LOG, "\tHirestexture\n"); + if (glpatch) Printf(PRINT_LOG, "\tPatch\n"),cnt++; + if (gltexture[0]) Printf(PRINT_LOG, "\tTexture (x:no, y:no )\n"),cnt++; + if (gltexture[1]) Printf(PRINT_LOG, "\tTexture (x:yes, y:no )\n"),cnt++; + if (gltexture[2]) Printf(PRINT_LOG, "\tTexture (x:no, y:yes)\n"),cnt++; + if (gltexture[3]) Printf(PRINT_LOG, "\tTexture (x:yes, y:yes)\n"),cnt++; + if (gltexture[4]) Printf(PRINT_LOG, "\tTexture precache\n"),cnt++; + return cnt; +} + +CCMD(textureinfo) +{ + int cnth = 0, cntt = 0, pix = 0; + for(int i=0; igl_info.SystemTexture; + if (systex != NULL) + { + int cnt = systex->Dump(i); + cnth+=cnt; + cntt++; + pix += cnt * tex->GetWidth() * tex->GetHeight(); + } + } + Printf(PRINT_LOG, "%d system textures, %d hardware textures, %d pixels\n", cntt, cnth, pix); +} + diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h new file mode 100644 index 000000000..3754e9337 --- /dev/null +++ b/src/gl/textures/gl_material.h @@ -0,0 +1,254 @@ + +#ifndef __GL_TEXTURE_H +#define __GL_TEXTURE_H + +#include "m_fixed.h" +#include "textures/textures.h" +#include "gl/textures/gl_hwtexture.h" +#include "gl/renderer/gl_colormap.h" +#include "i_system.h" + +EXTERN_CVAR(Bool, gl_precache) + +struct FRemapTable; +class FTextureShader; + + + +struct FTexCoordInfo +{ + int mRenderWidth; + int mRenderHeight; + int mWidth; + fixed_t mScaleX; + fixed_t mScaleY; + fixed_t mTempScaleX; + fixed_t mTempScaleY; + bool mWorldPanning; + + float FloatToTexU(float v) const { return v / mRenderWidth; } + float FloatToTexV(float v) const { return v / mRenderHeight; } + fixed_t RowOffset(fixed_t ofs) const; + fixed_t TextureOffset(fixed_t ofs) const; + fixed_t TextureAdjustWidth() const; +}; + +//=========================================================================== +// +// this is the texture maintenance class for OpenGL. +// +//=========================================================================== +class FMaterial; + +enum ETexUse +{ + GLUSE_PATCH, + GLUSE_TEXTURE, + GLUSE_SPRITE, +}; + + +class FGLTexture //: protected WorldTextureInfo, protected PatchTextureInfo +{ + friend class FMaterial; +public: + FTexture * tex; + FTexture * hirestexture; + char bIsTransparent; + int HiresLump; + +private: + FHardwareTexture *gltexture[5]; + FHardwareTexture *glpatch; + + int currentwarp; + int currentwarptime; + + bool bHasColorkey; // only for hires + bool bExpand; + float AlphaThreshold; + + unsigned char * LoadHiresTexture(FTexture *hirescheck, int *width, int *height, int cm); + BYTE *WarpBuffer(BYTE *buffer, int Width, int Height, int warp); + + FHardwareTexture *CreateTexture(int clampmode); + //bool CreateTexture(); + bool CreatePatch(); + + const FHardwareTexture *Bind(int texunit, int cm, int clamp, int translation, FTexture *hirescheck, int warp); + const FHardwareTexture *BindPatch(int texunit, int cm, int translation, int warp); + +public: + FGLTexture(FTexture * tx, bool expandpatches); + ~FGLTexture(); + + unsigned char * CreateTexBuffer(int cm, int translation, int & w, int & h, bool expand, FTexture *hirescheck, int warp); + + void Clean(bool all); + int Dump(int i); + +}; + +//=========================================================================== +// +// this is the material class for OpenGL. +// +//=========================================================================== + +class FMaterial +{ + struct FTextureLayer + { + FTexture *texture; + bool animated; + }; + + static TArray mMaterials; + static int mMaxBound; + + FGLTexture *mBaseLayer; + TArray mTextureLayers; + int mShaderIndex; + + short LeftOffset[3]; + short TopOffset[3]; + short Width[3]; + short Height[3]; + short RenderWidth[2]; + short RenderHeight[2]; + + float SpriteU[2], SpriteV[2]; + float spriteright, spritebottom; + + void SetupShader(int shaderindex, int &cm); + FGLTexture * ValidateSysTexture(FTexture * tex, bool expand); + bool TrimBorders(int *rect); + +public: + FTexture *tex; + + FMaterial(FTexture *tex, bool forceexpand); + ~FMaterial(); + void Precache(); + bool isMasked() const + { + return !!mBaseLayer->tex->bMasked; + } + + void Bind(int cm, int clamp = 0, int translation = 0, int overrideshader = 0); + void BindPatch(int cm, int translation = 0, int overrideshader = 0); + + unsigned char * CreateTexBuffer(int cm, int translation, int & w, int & h, bool expand = false, bool allowhires=true) const + { + return mBaseLayer->CreateTexBuffer(cm, translation, w, h, expand, allowhires? tex:NULL, 0); + } + + void Clean(bool f) + { + mBaseLayer->Clean(f); + } + + void BindToFrameBuffer(); + // Patch drawing utilities + + void GetRect(FloatRect *r, ETexUse i) const; + void GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const; + + // This is scaled size in integer units as needed by walls and flats + int TextureHeight(ETexUse i) const { return RenderHeight[i]; } + int TextureWidth(ETexUse i) const { return RenderWidth[i]; } + + int GetAreas(FloatRect **pAreas) const; + + int GetWidth(ETexUse i) const + { + return Width[i]; + } + + int GetHeight(ETexUse i) const + { + return Height[i]; + } + + int GetLeftOffset(ETexUse i) const + { + return LeftOffset[i]; + } + + int GetTopOffset(ETexUse i) const + { + return TopOffset[i]; + } + + int GetScaledLeftOffset(ETexUse i) const + { + return DivScale16(LeftOffset[i], tex->xScale); + } + + int GetScaledTopOffset(ETexUse i) const + { + return DivScale16(TopOffset[i], tex->yScale); + } + + float GetScaledLeftOffsetFloat(ETexUse i) const + { + return LeftOffset[i] / FIXED2FLOAT(tex->xScale); + } + + float GetScaledTopOffsetFloat(ETexUse i) const + { + return TopOffset[i] / FIXED2FLOAT(tex->yScale); + } + + // This is scaled size in floating point as needed by sprites + float GetScaledWidthFloat(ETexUse i) const + { + return Width[i] / FIXED2FLOAT(tex->xScale); + } + + float GetScaledHeightFloat(ETexUse i) const + { + return Height[i] / FIXED2FLOAT(tex->yScale); + } + + // Get right/bottom UV coordinates for patch drawing + float GetUL() const { return 0; } + float GetVT() const { return 0; } + float GetUR() const { return spriteright; } + float GetVB() const { return spritebottom; } + float GetU(float upix) const { return upix/(float)Width[GLUSE_PATCH] * spriteright; } + float GetV(float vpix) const { return vpix/(float)Height[GLUSE_PATCH] * spritebottom; } + + float GetSpriteUL() const { return SpriteU[0]; } + float GetSpriteVT() const { return SpriteV[0]; } + float GetSpriteUR() const { return SpriteU[1]; } + float GetSpriteVB() const { return SpriteV[1]; } + + + + bool GetTransparent() const + { + if (mBaseLayer->bIsTransparent == -1) + { + if (!mBaseLayer->tex->bHasCanvas) + { + int w, h; + unsigned char *buffer = CreateTexBuffer(CM_DEFAULT, 0, w, h); + delete [] buffer; + } + else + { + mBaseLayer->bIsTransparent = 0; + } + } + return !!mBaseLayer->bIsTransparent; + } + + static void DeleteAll(); + static void FlushAll(); + static FMaterial *ValidateTexture(FTexture * tex); + static FMaterial *ValidateTexture(FTextureID no, bool trans); + +}; + +#endif diff --git a/src/gl/textures/gl_skyboxtexture.cpp b/src/gl/textures/gl_skyboxtexture.cpp new file mode 100644 index 000000000..f9918dff2 --- /dev/null +++ b/src/gl/textures/gl_skyboxtexture.cpp @@ -0,0 +1,229 @@ +/* +** gl_skyboxtexture.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2004-2009 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "doomtype.h" +#include "sc_man.h" +#include "w_wad.h" +#include "textures/textures.h" +#include "gl/textures/gl_skyboxtexture.h" + + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +FSkyBox::FSkyBox() +{ + faces[0]=faces[1]=faces[2]=faces[3]=faces[4]=faces[5]=NULL; + UseType=TEX_Override; + gl_info.bSkybox = true; + fliptop = false; +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +FSkyBox::~FSkyBox() +{ + // The faces are only referenced but not owned so don't delete them. +} + +//----------------------------------------------------------------------------- +// +// If something attempts to use this as a texture just pass the information of the first face. +// +//----------------------------------------------------------------------------- + +const BYTE *FSkyBox::GetColumn (unsigned int column, const Span **spans_out) +{ + if (faces[0]) return faces[0]->GetColumn(column, spans_out); + return NULL; +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +const BYTE *FSkyBox::GetPixels () +{ + if (faces[0]) return faces[0]->GetPixels(); + return NULL; +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +int FSkyBox::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +{ + if (faces[0]) return faces[0]->CopyTrueColorPixels(bmp, x, y, rotate, inf); + return 0; +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +bool FSkyBox::UseBasePalette() +{ + return false; // not really but here it's not important. +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void FSkyBox::Unload () +{ + //for(int i=0;i<6;i++) if (faces[i]) faces[i]->Unload(); +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void FSkyBox::PrecacheGL() +{ + //for(int i=0;i<6;i++) if (faces[i]) faces[i]->PrecacheGL(); +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParseSkybox(FScanner &sc) +{ + int facecount=0; + + sc.MustGetString(); + + FSkyBox * sb = new FSkyBox; + uppercopy(sb->Name, sc.String); + sb->Name[8]=0; + if (sc.CheckString("fliptop")) + { + sb->fliptop = true; + } + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + sc.MustGetString(); + if (facecount<6) + { + sb->faces[facecount] = TexMan[TexMan.GetTexture(sc.String, FTexture::TEX_Wall, FTextureManager::TEXMAN_TryAny|FTextureManager::TEXMAN_Overridable)]; + } + facecount++; + } + if (facecount != 3 && facecount != 6) + { + sc.ScriptError("%s: Skybox definition requires either 3 or 6 faces", sb->Name); + } + sb->SetSize(); + TexMan.AddTexture(sb); +} + +//----------------------------------------------------------------------------- +// +// gl_ParseVavoomSkybox +// +//----------------------------------------------------------------------------- + +void gl_ParseVavoomSkybox() +{ + int lump = Wads.CheckNumForName("SKYBOXES"); + + if (lump < 0) return; + + FScanner sc(lump); + while (sc.GetString()) + { + int facecount=0; + int maplump = -1; + FSkyBox * sb = new FSkyBox; + uppercopy(sb->Name, sc.String); + sb->Name[8]=0; + sb->fliptop = true; + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + if (facecount<6) + { + sc.MustGetStringName("{"); + sc.MustGetStringName("map"); + sc.MustGetString(); + + maplump = Wads.CheckNumForFullName(sc.String, true); + if (maplump==-1) + Printf("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->Name); + + FTextureID tex = TexMan.FindTextureByLumpNum(maplump); + if (!tex.isValid()) + { + tex = TexMan.CreateTexture(maplump, FTexture::TEX_MiscPatch); + } + sb->faces[facecount] = TexMan[tex]; + sc.MustGetStringName("}"); + } + facecount++; + } + if (facecount != 6) + { + sc.ScriptError("%s: Skybox definition requires 6 faces", sb->Name); + } + sb->SetSize(); + TexMan.AddTexture(sb); + } +} + diff --git a/src/gl/textures/gl_skyboxtexture.h b/src/gl/textures/gl_skyboxtexture.h new file mode 100644 index 000000000..a85e14190 --- /dev/null +++ b/src/gl/textures/gl_skyboxtexture.h @@ -0,0 +1,45 @@ + + +//----------------------------------------------------------------------------- +// +// This is not a real texture but will be added to the texture manager +// so that it can be handled like any other sky. +// +//----------------------------------------------------------------------------- + +class FSkyBox : public FTexture +{ +public: + + FTexture * faces[6]; + bool fliptop; + + FSkyBox(); + ~FSkyBox(); + const BYTE *GetColumn (unsigned int column, const Span **spans_out); + const BYTE *GetPixels (); + int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf); + bool UseBasePalette(); + void Unload (); + void PrecacheGL(); + + void SetSize() + { + if (faces[0]) + { + Width=faces[0]->GetWidth(); + Height=faces[0]->GetHeight(); + CalcBitSize(); + } + } + + bool Is3Face() const + { + return faces[5]==NULL; + } + + bool IsFlipped() const + { + return fliptop; + } +}; diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp new file mode 100644 index 000000000..6222c4b1c --- /dev/null +++ b/src/gl/textures/gl_texture.cpp @@ -0,0 +1,857 @@ +/* +** Global texture data +** +**--------------------------------------------------------------------------- +** Copyright 2004-2009 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "c_cvars.h" +#include "w_wad.h" +#include "templates.h" +#include "colormatcher.h" +#include "r_data/r_translate.h" +#include "c_dispatch.h" +#ifdef _WIN32 +#include "win32gliface.h" +#endif +#include "v_palette.h" +#include "sc_man.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/textures/gl_texture.h" +#include "gl/textures/gl_material.h" + +//========================================================================== +// +// Texture CVARs +// +//========================================================================== +CUSTOM_CVAR(Float,gl_texture_filter_anisotropic,8.0f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +{ + if (GLRenderer != NULL) GLRenderer->FlushTextures(); +} + +CCMD(gl_flush) +{ + if (GLRenderer != NULL) GLRenderer->FlushTextures(); +} + +CUSTOM_CVAR(Int, gl_texture_filter, 4, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +{ + if (self < 0 || self > 5) self=4; + if (GLRenderer != NULL) GLRenderer->FlushTextures(); +} + +CUSTOM_CVAR(Int, gl_texture_format, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +{ + // [BB] The number of available texture modes depends on the GPU capabilities. + // RFL_TEXTURE_COMPRESSION gives us one additional mode and RFL_TEXTURE_COMPRESSION_S3TC + // another three. + int numOfAvailableTextureFormat = 4; + if ( gl.flags & RFL_TEXTURE_COMPRESSION && gl.flags & RFL_TEXTURE_COMPRESSION_S3TC ) + numOfAvailableTextureFormat = 8; + else if ( gl.flags & RFL_TEXTURE_COMPRESSION ) + numOfAvailableTextureFormat = 5; + if (self < 0 || self > numOfAvailableTextureFormat-1) self=0; + GLRenderer->FlushTextures(); +} + +CUSTOM_CVAR(Bool, gl_texture_usehires, true, CVAR_ARCHIVE|CVAR_NOINITCALL) +{ + if (GLRenderer != NULL) GLRenderer->FlushTextures(); +} + +CVAR(Bool, gl_precache, false, CVAR_ARCHIVE) +CVAR(Bool, gl_clamp_per_texture, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) + +CVAR(Bool, gl_trimsprites, true, CVAR_ARCHIVE); + +TexFilter_s TexFilter[]={ + {GL_NEAREST, GL_NEAREST, false}, + {GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST, true}, + {GL_LINEAR, GL_LINEAR, false}, + {GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR, true}, + {GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, true}, + {GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST, true}, +}; + +int TexFormat[]={ + GL_RGBA8, + GL_RGB5_A1, + GL_RGBA4, + GL_RGBA2, + // [BB] Added compressed texture formats. + GL_COMPRESSED_RGBA_ARB, + GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, + GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, + GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, +}; + + + +bool HasGlobalBrightmap; +FRemapTable GlobalBrightmap; + +//=========================================================================== +// +// Examines the colormap to see if some of the colors have to be +// considered fullbright all the time. +// +//=========================================================================== + +void gl_GenerateGlobalBrightmapFromColormap() +{ + HasGlobalBrightmap = false; + int lump = Wads.CheckNumForName("COLORMAP"); + if (lump == -1) lump = Wads.CheckNumForName("COLORMAP", ns_colormaps); + if (lump == -1) return; + FMemLump cmap = Wads.ReadLump(lump); + FMemLump palette = Wads.ReadLump("PLAYPAL"); + const unsigned char *cmapdata = (const unsigned char *)cmap.GetMem(); + const unsigned char *paldata = (const unsigned char *)palette.GetMem(); + + const int black = 0; + const int white = ColorMatcher.Pick(255,255,255); + + + GlobalBrightmap.MakeIdentity(); + memset(GlobalBrightmap.Remap, white, 256); + for(int i=0;i<256;i++) GlobalBrightmap.Palette[i]=PalEntry(255,255,255,255); + for(int j=0;j<32;j++) + { + for(int i=0;i<256;i++) + { + // the palette comparison should be for ==0 but that gives false positives with Heretic + // and Hexen. + if (cmapdata[i+j*256]!=i || (paldata[3*i]<10 && paldata[3*i+1]<10 && paldata[3*i+2]<10)) + { + GlobalBrightmap.Remap[i]=black; + GlobalBrightmap.Palette[i]=PalEntry(0,0,0); + } + } + } + for(int i=0;i<256;i++) + { + HasGlobalBrightmap |= GlobalBrightmap.Remap[i] == white; + if (GlobalBrightmap.Remap[i] == white) DPrintf("Marked color %d as fullbright\n",i); + } +} + +//=========================================================================== +// +// averageColor +// input is RGBA8 pixel format. +// The resulting RGB color can be scaled uniformly so that the highest +// component becomes one. +// +//=========================================================================== +PalEntry averageColor(const DWORD *data, int size, fixed_t maxout_factor) +{ + int i; + unsigned int r, g, b; + + + + // First clear them. + r = g = b = 0; + if (size==0) + { + return PalEntry(255,255,255); + } + for(i = 0; i < size; i++) + { + r += BPART(data[i]); + g += GPART(data[i]); + b += RPART(data[i]); + } + + r = r/size; + g = g/size; + b = b/size; + + int maxv=MAX(MAX(r,g),b); + + if(maxv && maxout_factor) + { + maxout_factor = FixedMul(maxout_factor, 255); + r = Scale(r, maxout_factor, maxv); + g = Scale(g, maxout_factor, maxv); + b = Scale(b, maxout_factor, maxv); + } + return PalEntry(r,g,b); +} + + + +//========================================================================== +// +// GL status data for a texture +// +//========================================================================== + +FTexture::MiscGLInfo::MiscGLInfo() throw() +{ + bGlowing = false; + GlowColor = 0; + GlowHeight = 128; + bSkybox = false; + FloorSkyColor = 0; + CeilingSkyColor = 0; + bFullbright = false; + bSkyColorDone = false; + bBrightmapChecked = false; + bBrightmap = false; + bBrightmapDisablesFullbright = false; + bNoFilter = false; + bNoCompress = false; + mExpanded = false; + areas = NULL; + areacount = 0; + mIsTransparent = -1; + shaderspeed = 1.f; + shaderindex = 0; + + Material = NULL; + SystemTexture = NULL; + Brightmap = NULL; + DecalTexture = NULL; +} + +FTexture::MiscGLInfo::~MiscGLInfo() +{ + if (Material != NULL) delete Material; + Material = NULL; + + if (SystemTexture != NULL) delete SystemTexture; + SystemTexture = NULL; + + // this is managed by the texture manager so it may not be deleted here. + //if (Brightmap != NULL) delete Brightmap; + Brightmap = NULL; + + if (areas != NULL) delete [] areas; + areas = NULL; + + if (DecalTexture != NULL) delete DecalTexture; + DecalTexture = NULL; + +} + +//=========================================================================== +// +// Checks if the texture has a default brightmap and creates it if so +// +//=========================================================================== +void FTexture::CreateDefaultBrightmap() +{ + if (!gl_info.bBrightmapChecked) + { + // Check for brightmaps + if (UseBasePalette() && HasGlobalBrightmap && + UseType != TEX_Decal && UseType != TEX_MiscPatch && UseType != TEX_FontChar && + gl_info.Brightmap == NULL && bWarped == 0 + ) + { + // May have one - let's check when we use this texture + const BYTE *texbuf = GetPixels(); + const int white = ColorMatcher.Pick(255,255,255); + + int size = GetWidth() * GetHeight(); + for(int i=0;iPrecache(); + } +} + +//========================================================================== +// +// Precaches a GL texture +// +//========================================================================== + +void FTexture::UncacheGL() +{ + if (gl_info.Material) gl_info.Material->Clean(true); +} + +//========================================================================== +// +// Calculates glow color for a texture +// +//========================================================================== + +void FTexture::GetGlowColor(float *data) +{ + if (gl_info.bGlowing && gl_info.GlowColor == 0) + { + int w, h; + unsigned char *buffer = GLRenderer->GetTextureBuffer(this, w, h); + + if (buffer) + { + gl_info.GlowColor = averageColor((DWORD *) buffer, w*h, 6*FRACUNIT/10); + delete[] buffer; + } + + // Black glow equals nothing so switch glowing off + if (gl_info.GlowColor == 0) gl_info.bGlowing = false; + } + data[0]=gl_info.GlowColor.r/255.0f; + data[1]=gl_info.GlowColor.g/255.0f; + data[2]=gl_info.GlowColor.b/255.0f; +} + +//=========================================================================== +// +// Gets the average color of a texture for use as a sky cap color +// +//=========================================================================== + +PalEntry FTexture::GetSkyCapColor(bool bottom) +{ + PalEntry col; + int w; + int h; + + if (!gl_info.bSkyColorDone) + { + gl_info.bSkyColorDone = true; + + unsigned char *buffer = GLRenderer->GetTextureBuffer(this, w, h); + + if (buffer) + { + gl_info.CeilingSkyColor = averageColor((DWORD *) buffer, w * MIN(30, h), 0); + if (h>30) + { + gl_info.FloorSkyColor = averageColor(((DWORD *) buffer)+(h-30)*w, w * 30, 0); + } + else gl_info.FloorSkyColor = gl_info.CeilingSkyColor; + delete[] buffer; + } + } + return bottom? gl_info.FloorSkyColor : gl_info.CeilingSkyColor; +} + +//=========================================================================== +// +// Finds gaps in the texture which can be skipped by the renderer +// This was mainly added to speed up one area in E4M6 of 007LTSD +// +//=========================================================================== + +bool FTexture::FindHoles(const unsigned char * buffer, int w, int h) +{ + const unsigned char * li; + int y,x; + int startdraw,lendraw; + int gaps[5][2]; + int gapc=0; + + + // already done! + if (gl_info.areacount) return false; + if (UseType == TEX_Flat) return false; // flats don't have transparent parts + gl_info.areacount=-1; //whatever happens next, it shouldn't be done twice! + + // large textures are excluded for performance reasons + if (h>512) return false; + + startdraw=-1; + lendraw=0; + for(y=0;y>24; + + if (alpha != 0xff && alpha != 0) + { + gl_info.mIsTransparent = 1; + return; + } + } + } + gl_info.mIsTransparent = 0; + } +} + + +//=========================================================================== +// +// smooth the edges of transparent fields in the texture +// +//=========================================================================== + +#ifdef WORDS_BIGENDIAN +#define MSB 0 +#define SOME_MASK 0xffffff00 +#else +#define MSB 3 +#define SOME_MASK 0x00ffffff +#endif + +#define CHKPIX(ofs) (l1[(ofs)*4+MSB]==255 ? (( ((DWORD*)l1)[0] = ((DWORD*)l1)[ofs]&SOME_MASK), trans=true ) : false) + +bool FTexture::SmoothEdges(unsigned char * buffer,int w, int h) +{ + int x,y; + bool trans=buffer[MSB]==0; // If I set this to false here the code won't detect textures + // that only contain transparent pixels. + unsigned char * l1; + + if (h<=1 || w<=1) return false; // makes (a) no sense and (b) doesn't work with this code! + + l1=buffer; + + + if (l1[MSB]==0 && !CHKPIX(1)) CHKPIX(w); + l1+=4; + for(x=1;xbNoDecals; + Rotations = source->Rotations; + UseType = source->UseType; + gl_info.bBrightmap = true; + id.SetInvalid(); + SourceLump = -1; +} + +FBrightmapTexture::~FBrightmapTexture () +{ +} + +const BYTE *FBrightmapTexture::GetColumn (unsigned int column, const Span **spans_out) +{ + // not needed + return NULL; +} + +const BYTE *FBrightmapTexture::GetPixels () +{ + // not needed + return NULL; +} + +void FBrightmapTexture::Unload () +{ +} + +int FBrightmapTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +{ + SourcePic->CopyTrueColorTranslated(bmp, x, y, rotate, &GlobalBrightmap); + return 0; +} + + +//=========================================================================== +// +// A cloned texture. This is needed by the decal code which needs to assign +// a different texture type to some of its graphics. +// +//=========================================================================== + +FCloneTexture::FCloneTexture (FTexture *source, int usetype) +{ + memset(Name, 0, sizeof(Name)); + SourcePic = source; + CopySize(source); + bNoDecals = source->bNoDecals; + Rotations = source->Rotations; + UseType = usetype; + gl_info.bBrightmap = false; + id.SetInvalid(); + SourceLump = -1; +} + +FCloneTexture::~FCloneTexture () +{ +} + +const BYTE *FCloneTexture::GetColumn (unsigned int column, const Span **spans_out) +{ + return NULL; +} + +const BYTE *FCloneTexture::GetPixels () +{ + return NULL; +} + +void FCloneTexture::Unload () +{ +} + +int FCloneTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +{ + return SourcePic->CopyTrueColorPixels(bmp, x, y, rotate, inf); +} + +//========================================================================== +// +// Parses a brightmap definition +// +//========================================================================== + +void gl_ParseBrightmap(FScanner &sc, int deflump) +{ + int type = FTexture::TEX_Any; + bool disable_fullbright=false; + bool thiswad = false; + bool iwad = false; + int maplump = -1; + FString maplumpname; + + sc.MustGetString(); + if (sc.Compare("texture")) type = FTexture::TEX_Wall; + else if (sc.Compare("flat")) type = FTexture::TEX_Flat; + else if (sc.Compare("sprite")) type = FTexture::TEX_Sprite; + else sc.UnGet(); + + sc.MustGetString(); + FTextureID no = TexMan.CheckForTexture(sc.String, type); + FTexture *tex = TexMan[no]; + + sc.MustGetToken('{'); + while (!sc.CheckToken('}')) + { + sc.MustGetString(); + if (sc.Compare("disablefullbright")) + { + // This can also be used without a brightness map to disable + // fullbright in rotations that only use brightness maps on + // other angles. + disable_fullbright = true; + } + else if (sc.Compare("thiswad")) + { + // only affects textures defined in the WAD containing the definition file. + thiswad = true; + } + else if (sc.Compare ("iwad")) + { + // only affects textures defined in the IWAD. + iwad = true; + } + else if (sc.Compare ("map")) + { + sc.MustGetString(); + + if (maplump >= 0) + { + Printf("Multiple brightmap definitions in texture %s\n", tex? tex->Name : "(null)"); + } + + maplump = Wads.CheckNumForFullName(sc.String, true); + + if (maplump==-1) + Printf("Brightmap '%s' not found in texture '%s'\n", sc.String, tex? tex->Name : "(null)"); + + maplumpname = sc.String; + } + } + if (!tex) + { + return; + } + if (thiswad || iwad) + { + bool useme = false; + int lumpnum = tex->GetSourceLump(); + + if (lumpnum != -1) + { + if (iwad && Wads.GetLumpFile(lumpnum) <= FWadCollection::IWAD_FILENUM) useme = true; + if (thiswad && Wads.GetLumpFile(lumpnum) == deflump) useme = true; + } + if (!useme) return; + } + + if (maplump != -1) + { + if (tex->bWarped != 0) + { + Printf("Cannot combine warping with brightmap on texture '%s'\n", tex->Name); + return; + } + + // Brightmap textures are stored in the texture manager so that multiple + // instances of the same textures can be avoided. + FTexture *brightmap; + FTextureID brightmapId = TexMan.FindTextureByLumpNum(maplump); + + if (!brightmapId.isValid()) + { + // a texture for this lump has not been created yet. + brightmap = FTexture::CreateTexture(maplump, tex->UseType); + if (!brightmap) + { + Printf("Unable to create texture from '%s' in brightmap definition for '%s'\n", + maplumpname.GetChars(), tex->Name); + return; + } + brightmap->gl_info.bBrightmap = true; + brightmap->Name[0] = 0; // brightmaps don't have names + TexMan.AddTexture(brightmap); + } + else + { + brightmap = TexMan[brightmapId]; + } + + tex->gl_info.Brightmap = brightmap; + } + tex->gl_info.bBrightmapDisablesFullbright = disable_fullbright; +} + +//========================================================================== +// +// Parses a GLBoom+ detail texture definition +// +// Syntax is this: +// detail +// { +// (walls | flats) [default_detail_name [width [height [offset_x [offset_y]]]]] +// { +// texture_name [detail_name [width [height [offset_x [offset_y]]]]] +// } +// } +// This merely parses the block and returns no error if valid. The feature +// is not actually implemented, so nothing else happens. +//========================================================================== + +void gl_ParseDetailTexture(FScanner &sc) +{ + while (!sc.CheckToken('}')) + { + sc.MustGetString(); + if (sc.Compare("walls") || sc.Compare("flats")) + { + if (!sc.CheckToken('{')) + { + sc.MustGetString(); // Default detail texture + if (sc.CheckFloat()) // Width + if (sc.CheckFloat()) // Height + if (sc.CheckFloat()) // OffsX + if (sc.CheckFloat()) // OffsY + { + // Nothing + } + } + else sc.UnGet(); + sc.MustGetToken('{'); + while (!sc.CheckToken('}')) + { + sc.MustGetString(); // Texture + if (sc.GetString()) // Detail texture + { + if (sc.CheckFloat()) // Width + if (sc.CheckFloat()) // Height + if (sc.CheckFloat()) // OffsX + if (sc.CheckFloat()) // OffsY + { + // Nothing + } + } + else sc.UnGet(); + } + } + } +} + diff --git a/src/gl/textures/gl_texture.h b/src/gl/textures/gl_texture.h new file mode 100644 index 000000000..afb812ff0 --- /dev/null +++ b/src/gl/textures/gl_texture.h @@ -0,0 +1,88 @@ +/* +** gl_hqresize.h +** Contains high quality upsampling functions. +** +**--------------------------------------------------------------------------- +** Copyright 2008 Benjamin Berkels +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#ifndef __GL_HQRESIZE_H__ +#define __GL_HQRESIZE_H__ + +#include "r_defs.h" + +class FBrightmapTexture : public FTexture +{ +public: + FBrightmapTexture (FTexture *source); + ~FBrightmapTexture (); + + const BYTE *GetColumn (unsigned int column, const Span **spans_out); + const BYTE *GetPixels (); + void Unload (); + + int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf); + bool UseBasePalette() { return false; } + +protected: + FTexture *SourcePic; + //BYTE *Pixels; + //Span **Spans; +}; + +class FCloneTexture : public FTexture +{ +public: + FCloneTexture (FTexture *source, int usetype); + ~FCloneTexture (); + + const BYTE *GetColumn (unsigned int column, const Span **spans_out); + const BYTE *GetPixels (); + void Unload (); + + int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf); + bool UseBasePalette() { return false; } + +protected: + FTexture *SourcePic; +}; + + +void gl_GenerateGlobalBrightmapFromColormap(); +PalEntry averageColor(const DWORD *data, int size, fixed_t maxout); + + + +unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight, bool hasAlpha ); +int CheckDDPK3(FTexture *tex); +int CheckExternalFile(FTexture *tex, bool & hascolorkey); +PalEntry averageColor(const DWORD *data, int size, fixed_t maxout); + +#endif // __GL_HQRESIZE_H__ + diff --git a/src/gl/textures/gl_translate.cpp b/src/gl/textures/gl_translate.cpp new file mode 100644 index 000000000..f9a46dba8 --- /dev/null +++ b/src/gl/textures/gl_translate.cpp @@ -0,0 +1,88 @@ +/* +** gl_translate.cpp +** GL-related translation stuff +** +**--------------------------------------------------------------------------- +** Copyright 2007 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "doomtype.h" +#include "r_data/r_translate.h" +#include "gl/textures/gl_translate.h" +#include "m_crc32.h" + +TArray GLTranslationPalette::AllPalettes; + + +GLTranslationPalette *GLTranslationPalette::CreatePalette(FRemapTable *remap) +{ + GLTranslationPalette *p = new GLTranslationPalette(remap); + p->Update(); + return p; +} + +bool GLTranslationPalette::Update() +{ + PalData pd; + + memset(pd.pe, 0, sizeof(pd.pe)); + memcpy(pd.pe, remap->Palette, remap->NumEntries * sizeof(*remap->Palette)); + pd.crc32 = CalcCRC32((BYTE*)pd.pe, sizeof(pd.pe)); + for(unsigned int i=0;i< AllPalettes.Size(); i++) + { + if (pd.crc32 == AllPalettes[i].crc32) + { + if (!memcmp(pd.pe, AllPalettes[i].pe, sizeof(pd.pe))) + { + Index = 1+i; + return true; + } + } + } + Index = 1+AllPalettes.Push(pd); + return true; +} + +int GLTranslationPalette::GetInternalTranslation(int trans) +{ + if (trans <= 0) return 0; + + FRemapTable *remap = TranslationToTable(trans); + if (remap == NULL || remap->Inactive) return 0; + + GLTranslationPalette *tpal = static_cast(remap->GetNative()); + if (tpal == NULL) return 0; + return tpal->GetIndex(); +} diff --git a/src/gl/textures/gl_translate.h b/src/gl/textures/gl_translate.h new file mode 100644 index 000000000..07ede1a22 --- /dev/null +++ b/src/gl/textures/gl_translate.h @@ -0,0 +1,42 @@ +#ifndef __GL_TRANSLATE__ +#define __GL_TRANSLATE__ + +#include "doomtype.h" +#include "v_video.h" + +enum +{ + TRANSLATION_ICE = -1, + TRANSLATION_INTENSITY = -2, + TRANSLATION_SHADE = -3, +}; + + +class GLTranslationPalette : public FNativePalette +{ + struct PalData + { + int crc32; + PalEntry pe[256]; + }; + static TArray AllPalettes; + + int Index; + FRemapTable *remap; + + GLTranslationPalette(FRemapTable *r) { remap=r; Index=-1; } + +public: + + static GLTranslationPalette *CreatePalette(FRemapTable *remap); + static int GetInternalTranslation(int trans); + static PalEntry *GetPalette(unsigned int index) + { + return index > 0 && index <= AllPalettes.Size()? AllPalettes[index-1].pe : NULL; + } + bool Update(); + int GetIndex() const { return Index; } +}; + + +#endif diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp new file mode 100644 index 000000000..7ad32f8ee --- /dev/null +++ b/src/gl/utility/gl_clock.cpp @@ -0,0 +1,222 @@ +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include + +#define USE_WINDOWS_DWORD +#endif + +#include "i_system.h" +#include "g_level.h" +#include "c_console.h" +#include "c_dispatch.h" +#include "r_utility.h" +#include "v_video.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_convert.h" + + +glcycle_t RenderWall,SetupWall,ClipWall,SplitWall; +glcycle_t RenderFlat,SetupFlat; +glcycle_t RenderSprite,SetupSprite; +glcycle_t All, Finish, PortalAll, Bsp; +glcycle_t ProcessAll; +glcycle_t RenderAll; +glcycle_t Dirty; +int vertexcount, flatvertices, flatprimitives; + +int rendered_lines,rendered_flats,rendered_sprites,render_vertexsplit,render_texsplit,rendered_decals, rendered_portals; +int iter_dlightf, iter_dlight, draw_dlight, draw_dlightf; + +double gl_SecondsPerCycle = 1e-8; +double gl_MillisecPerCycle = 1e-5; // 100 MHz + +// For GL timing the performance counter is far too costly so we still need RDTSC +// even though it may not be perfect. + +void gl_CalculateCPUSpeed () +{ + #ifdef WIN32 + LARGE_INTEGER freq; + + QueryPerformanceFrequency (&freq); + + if (freq.QuadPart != 0) + { + LARGE_INTEGER count1, count2; + unsigned minDiff; + long long ClockCalibration = 0; + + // Count cycles for at least 55 milliseconds. + // The performance counter is very low resolution compared to CPU + // speeds today, so the longer we count, the more accurate our estimate. + // On the other hand, we don't want to count too long, because we don't + // want the user to notice us spend time here, since most users will + // probably never use the performance statistics. + minDiff = freq.LowPart * 11 / 200; + + // Minimize the chance of task switching during the testing by going very + // high priority. This is another reason to avoid timing for too long. + SetPriorityClass (GetCurrentProcess (), REALTIME_PRIORITY_CLASS); + SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL); + ClockCalibration = __rdtsc(); + QueryPerformanceCounter (&count1); + do + { + QueryPerformanceCounter (&count2); + } while ((DWORD)((unsigned __int64)count2.QuadPart - (unsigned __int64)count1.QuadPart) < minDiff); + ClockCalibration = __rdtsc() - ClockCalibration; + QueryPerformanceCounter (&count2); + SetPriorityClass (GetCurrentProcess (), NORMAL_PRIORITY_CLASS); + SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_NORMAL); + + double CyclesPerSecond = (double)ClockCalibration * + (double)freq.QuadPart / + (double)((__int64)count2.QuadPart - (__int64)count1.QuadPart); + gl_SecondsPerCycle = 1.0 / CyclesPerSecond; + gl_MillisecPerCycle = 1000.0 / CyclesPerSecond; + } + #endif +} + + +void ResetProfilingData() +{ + All.Reset(); + All.Clock(); + Bsp.Reset(); + PortalAll.Reset(); + RenderAll.Reset(); + ProcessAll.Reset(); + RenderWall.Reset(); + SetupWall.Reset(); + SplitWall.Reset(); + ClipWall.Reset(); + RenderFlat.Reset(); + SetupFlat.Reset(); + RenderSprite.Reset(); + SetupSprite.Reset(); + + flatvertices=flatprimitives=vertexcount=0; + render_texsplit=render_vertexsplit=rendered_lines=rendered_flats=rendered_sprites=rendered_decals=rendered_portals = 0; +} + +//----------------------------------------------------------------------------- +// +// Rendering statistics +// +//----------------------------------------------------------------------------- + +static void AppendRenderTimes(FString &str) +{ + double setupwall = SetupWall.TimeMS() - SplitWall.TimeMS(); + double clipwall = ClipWall.TimeMS() - SetupWall.TimeMS(); + double bsp = Bsp.TimeMS() - ClipWall.TimeMS() - SetupFlat.TimeMS() - SetupSprite.TimeMS(); + + str.AppendFormat("W: Render=%2.3f, Split = %2.3f, Setup=%2.3f, Clip=%2.3f\n" + "F: Render=%2.3f, Setup=%2.3f\n" + "S: Render=%2.3f, Setup=%2.3f\n" + "All=%2.3f, Render=%2.3f, Setup=%2.3f, BSP = %2.3f, Portal=%2.3f, Finish=%2.3f\n", + RenderWall.TimeMS(), SplitWall.TimeMS(), setupwall, clipwall, RenderFlat.TimeMS(), SetupFlat.TimeMS(), + RenderSprite.TimeMS(), SetupSprite.TimeMS(), All.TimeMS() + Finish.TimeMS(), RenderAll.TimeMS(), + ProcessAll.TimeMS(), bsp, PortalAll.TimeMS(), Finish.TimeMS()); +} + +static void AppendRenderStats(FString &out) +{ + out.AppendFormat("Walls: %d (%d splits, %d t-splits, %d vertices)\n" + "Flats: %d (%d primitives, %d vertices)\n" + "Sprites: %d, Decals=%d, Portals: %d\n", + rendered_lines, render_vertexsplit, render_texsplit, vertexcount, rendered_flats, flatprimitives, flatvertices, rendered_sprites,rendered_decals, rendered_portals ); +} + +static void AppendLightStats(FString &out) +{ + out.AppendFormat("DLight - Walls: %d processed, %d rendered - Flats: %d processed, %d rendered\n", + iter_dlight, draw_dlight, iter_dlightf, draw_dlightf ); +} + +ADD_STAT(rendertimes) +{ + static FString buff; + static int lasttime=0; + int t=I_FPSTime(); + if (t-lasttime>1000) + { + buff.Truncate(0); + AppendRenderTimes(buff); + lasttime=t; + } + return buff; +} + +ADD_STAT(renderstats) +{ + FString out; + AppendRenderStats(out); + return out; +} + +ADD_STAT(lightstats) +{ + FString out; + AppendLightStats(out); + return out; +} + +void AppendMissingTextureStats(FString &out); + + +static int printstats; +static bool switchfps; +static unsigned int waitstart; +EXTERN_CVAR(Bool, vid_fps) + +void CheckBench() +{ + if (printstats && ConsoleState == c_up) + { + // if we started the FPS counter ourselves or ran from the console + // we need to wait for it to stabilize before using it. + if (waitstart > 0 && I_MSTime() < waitstart + 5000) return; + + FString compose; + + compose.Format("Map %s: \"%s\",\nx = %1.4f, y = %1.4f, z = %1.4f, angle = %1.4f, pitch = %1.4f\n", + level.mapname, level.LevelName.GetChars(), FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz), + ANGLE_TO_FLOAT(viewangle), ANGLE_TO_FLOAT(viewpitch)); + + AppendRenderStats(compose); + AppendRenderTimes(compose); + AppendLightStats(compose); + AppendMissingTextureStats(compose); + compose.AppendFormat("%d fps\n\n", screen->GetLastFPS()); + + FILE *f = fopen("benchmarks.txt", "at"); + if (f != NULL) + { + fputs(compose.GetChars(), f); + fclose(f); + } + Printf("Benchmark info saved\n"); + if (switchfps) vid_fps = false; + printstats = false; + } +} + +CCMD(bench) +{ + printstats = true; + if (vid_fps == 0) + { + vid_fps = 1; + waitstart = I_MSTime(); + switchfps = true; + } + else + { + if (ConsoleState == c_up) waitstart = I_MSTime(); + switchfps = false; + } + C_HideConsole (); +} \ No newline at end of file diff --git a/src/gl/utility/gl_clock.h b/src/gl/utility/gl_clock.h new file mode 100644 index 000000000..cb9d0173e --- /dev/null +++ b/src/gl/utility/gl_clock.h @@ -0,0 +1,122 @@ +#ifndef __GL_CLOCK_H +#define __GL_CLOCK_H + +#include "stats.h" +#include "x86.h" +#include "m_fixed.h" + +#ifdef _MSC_VER + +extern double gl_SecondsPerCycle; +extern double gl_MillisecPerCycle; + + +__forceinline long long GetClockCycle () +{ +#if _M_X64 + return __rdtsc(); +#else + return CPU.bRDTSC ? __rdtsc() : 0; +#endif +} + +#elif defined(__GNUG__) && defined(__i386__) + +extern double gl_SecondsPerCycle; +extern double gl_MillisecPerCycle; + +inline long long GetClockCycle() +{ + if (CPU.bRDTSC) + { + long long res; + asm volatile ("rdtsc" : "=A" (res)); + return res; + } + else + { + return 0; + } +} + +#else + +extern double gl_SecondsPerCycle; +extern double gl_MillisecPerCycle; + +inline long long GetClockCycle () +{ + return 0; +} +#endif + +#if defined (__APPLE__) + +typedef cycle_t glcycle_t; + +#else // !__APPLE__ + +class glcycle_t +{ +public: + glcycle_t &operator= (const glcycle_t &o) + { + Counter = o.Counter; + return *this; + } + + void Reset() + { + Counter = 0; + } + + __forceinline void Clock() + { + // Not using QueryPerformanceCounter directly, so we don't need + // to pull in the Windows headers for every single file that + // wants to do some profiling. + long long time = GetClockCycle(); + Counter -= time; + } + + __forceinline void Unclock() + { + long long time = GetClockCycle(); + Counter += time; + } + + double Time() + { + return double(Counter) * gl_SecondsPerCycle; + } + + double TimeMS() + { + return double(Counter) * gl_MillisecPerCycle; + } + +private: + long long Counter; +}; + +#endif // __APPLE__ + +extern glcycle_t RenderWall,SetupWall,ClipWall,SplitWall; +extern glcycle_t RenderFlat,SetupFlat; +extern glcycle_t RenderSprite,SetupSprite; +extern glcycle_t All, Finish, PortalAll, Bsp; +extern glcycle_t ProcessAll; +extern glcycle_t RenderAll; +extern glcycle_t Dirty; + +extern int iter_dlightf, iter_dlight, draw_dlight, draw_dlightf; +extern int rendered_lines,rendered_flats,rendered_sprites,rendered_decals,render_vertexsplit,render_texsplit; +extern int rendered_portals; + +extern int vertexcount, flatvertices, flatprimitives; + +void ResetProfilingData(); +void CheckBench(); + + +#endif \ No newline at end of file diff --git a/src/gl/utility/gl_convert.h b/src/gl/utility/gl_convert.h new file mode 100644 index 000000000..7f99412fa --- /dev/null +++ b/src/gl/utility/gl_convert.h @@ -0,0 +1,9 @@ + +#ifndef __GLC_CONVERT +#define __GLC_CONVERT + +#include "m_fixed.h" +#define ANGLE_TO_FLOAT(ang) ((float)((ang) * 180. / ANGLE_180)) +#define FLOAT_TO_ANGLE(ang) xs_RoundToUInt((ang) / 180. * ANGLE_180) + +#endif \ No newline at end of file diff --git a/src/gl/utility/gl_cycler.cpp b/src/gl/utility/gl_cycler.cpp new file mode 100644 index 000000000..a12cb4851 --- /dev/null +++ b/src/gl/utility/gl_cycler.cpp @@ -0,0 +1,155 @@ +/* +** gl_cycler.cpp +** Implements the cycler for dynamic lights and texture shaders. +** +**--------------------------------------------------------------------------- +** Copyright 2003 Timothy Stump +** Copyright 2006 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include +#include "gl/utility/gl_cycler.h" + +//========================================================================== +// +// +// +//========================================================================== + +void FCycler::Serialize(FArchive & arc) +{ + arc << m_start << m_end << m_current + << m_time << m_cycle << m_increment << m_shouldCycle + << m_cycleType; +} + +//========================================================================== +// +// +// +//========================================================================== + +FCycler::FCycler() +{ + m_cycle = 0.f; + m_cycleType = CYCLE_Linear; + m_shouldCycle = false; + m_start = m_current = 0.f; + m_end = 0.f; + m_increment = true; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void FCycler::SetParams(float start, float end, float cycle) +{ + m_cycle = cycle; + m_time = 0.f; + m_start = m_current = start; + m_end = end; + m_increment = true; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void FCycler::Update(float diff) +{ + float mult, angle; + float step = m_end - m_start; + + if (!m_shouldCycle) + { + return; + } + + m_time += diff; + if (m_time >= m_cycle) + { + m_time = m_cycle; + } + + mult = m_time / m_cycle; + + switch (m_cycleType) + { + case CYCLE_Linear: + if (m_increment) + { + m_current = m_start + (step * mult); + } + else + { + m_current = m_end - (step * mult); + } + break; + case CYCLE_Sin: + angle = float(M_PI * 2.f * mult); + mult = sinf(angle); + mult = (mult + 1.f) / 2.f; + m_current = m_start + (step * mult); + break; + case CYCLE_Cos: + angle = float(M_PI * 2.f * mult); + mult = cosf(angle); + mult = (mult + 1.f) / 2.f; + m_current = m_start + (step * mult); + break; + case CYCLE_SawTooth: + m_current = m_start + (step * mult); + break; + case CYCLE_Square: + if (m_increment) + { + m_current = m_start; + } + else + { + m_current = m_end; + } + break; + } + + if (m_time == m_cycle) + { + m_time = 0.f; + m_increment = !m_increment; + } +} + + diff --git a/src/gl/utility/gl_cycler.h b/src/gl/utility/gl_cycler.h new file mode 100644 index 000000000..8a6b55581 --- /dev/null +++ b/src/gl/utility/gl_cycler.h @@ -0,0 +1,52 @@ +#ifndef __GL_CYCLER_H +#define __GL_CYCLER_H + +#include "farchive.h" + +typedef enum +{ + CYCLE_Linear, + CYCLE_Sin, + CYCLE_Cos, + CYCLE_SawTooth, + CYCLE_Square +} CycleType; + +inline FArchive &operator<< (FArchive &arc, CycleType &type) +{ + BYTE val = (BYTE)type; + arc << val; + type = (CycleType)val; + return arc; +} + + +class FCycler +{ +public: + FCycler(); + void Update(float diff); + void SetParams(float start, float end, float cycle); + void ShouldCycle(bool sc) { m_shouldCycle = sc; } + void SetCycleType(CycleType ct) { m_cycleType = ct; } + float GetVal() { return m_current; } + + inline operator float () const { return m_current; } + + void Serialize(FArchive & arc); +protected: + float m_start, m_end, m_current; + float m_time, m_cycle; + bool m_increment, m_shouldCycle; + + CycleType m_cycleType; +}; + +inline FArchive &operator<< (FArchive &arc, FCycler &type) +{ + type.Serialize(arc); + return arc; +} + + +#endif diff --git a/src/gl/utility/gl_geometric.cpp b/src/gl/utility/gl_geometric.cpp new file mode 100644 index 000000000..5e3f93ba8 --- /dev/null +++ b/src/gl/utility/gl_geometric.cpp @@ -0,0 +1,258 @@ + + +#include +#include +#include "gl/utility/gl_geometric.h" + +static Vector axis[3] = +{ + Vector(1.0f, 0.0f, 0.0f), + Vector(0.0f, 1.0f, 0.0f), + Vector(0.0f, 0.0f, 1.0f) +}; + + + +Vector Vector::Cross(Vector &v) +{ + float x, y, z; + Vector cp; + + x = Y() * v.Z() - Z() * v.Y(); + y = Z() * v.X() - X() * v.Z(); + z = X() * v.Y() - Y() * v.X(); + + cp.Set(x, y, z); + + return cp; +} + + +Vector Vector::operator- (Vector &v) +{ + float x, y, z; + Vector vec; + + x = X() - v.X(); + y = Y() - v.Y(); + z = Z() - v.Z(); + + vec.Set(x, y, z); + + return vec; +} + + +Vector Vector::operator+ (Vector &v) +{ + float x, y, z; + Vector vec; + + x = X() + v.X(); + y = Y() + v.Y(); + z = Z() + v.Z(); + + vec.Set(x, y, z); + + return vec; +} + + +Vector Vector::operator* (float f) +{ + Vector vec(X(), Y(), Z()); + + vec.Scale(f); + + return vec; +} + + +Vector Vector::operator/ (float f) +{ + Vector vec(X(), Y(), Z()); + + vec.Scale(1.f / f); + + return vec; +} + + +bool Vector::operator== (Vector &v) +{ + return X() == v.X() && Y() == v.Y() && Z() == v.Z(); +} + + +void Vector::GetRightUp(Vector &right, Vector &up) +{ + Vector n(X(), Y(), Z()); + Vector fn(fabsf(n.X()), fabsf(n.Y()), fabsf(n.Z())); + int major = 0; + + if (fn[1] > fn[major]) major = 1; + if (fn[2] > fn[major]) major = 2; + + // build right vector by hand + if (fabsf(fn[0]-1.0f) < FLT_EPSILON || fabsf(fn[1]-1.0f) < FLT_EPSILON || fabsf(fn[2]-1.0f) < FLT_EPSILON) + { + if (major == 0 && n[0] > 0.f) + { + right.Set(0.f, 0.f, -1.f); + } + else if (major == 0) + { + right.Set(0.f, 0.f, 1.f); + } + + if (major == 1 || (major == 2 && n[2] > 0.f)) + { + right.Set(1.f, 0.f, 0.f); + } + + if (major == 2 && n[2] < 0.0f) + { + right.Set(-1.f, 0.f, 0.f); + } + } + else + { + right = axis[major].Cross(n); + } + + up = n.Cross(right); + right.Normalize(); + up.Normalize(); +} + + +void Vector::Scale(float scale) +{ + float x, y, z; + + x = X() * scale; + y = Y() * scale; + z = Z() * scale; + + Set(x, y, z); +} + + +Vector Vector::ProjectVector(Vector &a) +{ + Vector res, b; + + b.Set(X(), Y(), Z()); + res.Set(a.X(), a.Y(), a.Z()); + + res.Scale(a.Dot(b) / a.Dot(a)); + + return res; +} + + +Vector Vector::ProjectPlane(Vector &right, Vector &up) +{ + Vector src(X(), Y(), Z()); + Vector t1, t2; + + t1 = src.ProjectVector(right); + t2 = src.ProjectVector(up); + + return t1 + t2; +} + + + + + + +void Plane::Init(float *v1, float *v2, float *v3) +{ + Vector vec1, vec2, vec3; + + vec1.Set(v1); + vec2.Set(v2); + vec3.Set(v3); + +#ifdef _MSC_VER + m_normal = (vec2 - vec1).Cross(vec3 - vec1); +#else + Vector tmpVec = vec3 - vec1; + m_normal = (vec2 - vec1).Cross(tmpVec); +#endif + m_normal.Normalize(); + m_d = vec3.Dot(m_normal) * -1.f; +} + + +#define FNOTEQUAL(a, b) (fabsf(a - b) > 0.001f) +void Plane::Init(float *verts, int numVerts) +{ + float *v[3], *t; + int i, curVert; + + if (numVerts < 3) return; + + curVert = 1; + v[0] = verts + 0; + for (i = 1; i < numVerts; i++) + { + t = verts + (i * 3); + if (FNOTEQUAL(t[0], v[curVert - 1][0]) || FNOTEQUAL(t[1], v[curVert - 1][1]) || FNOTEQUAL(t[2], v[curVert - 1][2])) + { + v[curVert] = t; + curVert++; + } + if (curVert == 3) break; + } + + if (curVert != 3) + { + // degenerate triangle, no valid normal + return; + } + + Init(v[0], v[1], v[2]); +} + + +void Plane::Init(float a, float b, float c, float d) +{ + m_normal.Set(a, b, c); + m_d = d / m_normal.Length(); + m_normal.Normalize(); +} + + +void Plane::Set(secplane_t &plane) +{ + float a, b, c, d; + + a = FIXED2FLOAT(plane.a); + b = FIXED2FLOAT(plane.b); + c = FIXED2FLOAT(plane.c); + d = FIXED2FLOAT(plane.d); + + m_normal.Set(a, c, b); + //m_normal.Normalize(); the vector is already normalized + m_d = d; +} + + +float Plane::DistToPoint(float x, float y, float z) +{ + Vector p; + + p.Set(x, y, z); + + return m_normal.Dot(p) + m_d; +} + + +bool Plane::PointOnSide(float x, float y, float z) +{ + return DistToPoint(x, y, z) < 0.f; +} + + diff --git a/src/gl/utility/gl_geometric.h b/src/gl/utility/gl_geometric.h new file mode 100644 index 000000000..6868dab21 --- /dev/null +++ b/src/gl/utility/gl_geometric.h @@ -0,0 +1,251 @@ +#ifndef __GL_GEOM +#define __GL_GEOM + +#include "math.h" +#include "r_defs.h" + +class Vector +{ +public: + Vector() + { + SetX(0.f); + SetY(1.f); + SetZ(0.f); + m_length = 1.f; + } + + Vector(float x, float y, float z) + { + SetX(x); + SetY(y); + SetZ(z); + m_length=-1.0f; + } + + Vector(float *v) + { + SetX(v[0]); + SetY(v[1]); + SetZ(v[2]); + m_length=-1.0f; + } + + Vector(vertex_t * v) + { + SetX(v->fx); + SetY(v->fy); + SetZ(0); + } + + void Normalize() + { + float l = 1.f / Length(); + + SetX(X() * l); + SetY(Y() * l); + SetZ(Z() * l); + m_length=1.0f; + } + + void UpdateLength() + { + m_length = sqrtf((X() * X()) + (Y() * Y()) + (Z() * Z())); + } + + void Set(float *v) + { + SetX(v[0]); + SetY(v[1]); + SetZ(v[2]); + m_length=-1.0f; + } + + void Set(float x, float y, float z) + { + SetX(x); + SetY(y); + SetZ(z); + m_length=-1.0f; + } + + float Length() + { + if (m_length<0.0f) UpdateLength(); + return m_length; + } + + float Dist(Vector &v) + { + Vector t(X() - v.X(), Y() - v.Y(), Z() - v.Z()); + + return t.Length(); + } + + float Dot(Vector &v) + { + return (X() * v.X()) + (Y() * v.Y()) + (Z() * v.Z()); + } + + Vector Cross(Vector &v); + Vector operator- (Vector &v); + Vector operator+ (Vector &v); + Vector operator* (float f); + Vector operator/ (float f); + bool operator== (Vector &v); + bool operator!= (Vector &v) { return !((*this) == v); } + + void GetRightUp(Vector &up, Vector &right); + float operator[] (int index) const { return m_vec[index]; } + float &operator[] (int index) { return m_vec[index]; } + float X() const { return m_vec[0]; } + float Y() const { return m_vec[1]; } + float Z() const { return m_vec[2]; } + void SetX(float x) { m_vec[0] = x; } + void SetY(float y) { m_vec[1] = y; } + void SetZ(float z) { m_vec[2] = z; } + void Scale(float scale); + + Vector ProjectVector(Vector &a); + Vector ProjectPlane(Vector &right, Vector &up); +protected: + float m_vec[3]; + float m_length; +}; + + +class Plane +{ +public: + Plane() + { + m_normal.Set(0.f, 1.f, 0.f); + m_d = 0.f; + } + void Init(float *v1, float *v2, float *v3); + void Init(float a, float b, float c, float d); + void Init(float *verts, int numVerts); + void Set(secplane_t &plane); + float DistToPoint(float x, float y, float z); + bool PointOnSide(float x, float y, float z); + bool PointOnSide(Vector &v) { return PointOnSide(v.X(), v.Y(), v.Z()); } + bool ValidNormal() { return m_normal.Length() == 1.f; } + + float A() { return m_normal.X(); } + float B() { return m_normal.Y(); } + float C() { return m_normal.Z(); } + float D() { return m_d; } + + const Vector &Normal() const { return m_normal; } +protected: + Vector m_normal; + float m_d; +}; + +class Matrix3x4 // used like a 4x4 matrix with the last row always being (0,0,0,1) +{ + float m[3][4]; + +public: + + void MakeIdentity() + { + memset(m, 0, sizeof(m)); + m[0][0] = m[1][1] = m[2][2] = 1.f; + } + + void Translate(float x, float y, float z) + { + m[0][3] = m[0][0]*x + m[0][1]*y + m[0][2]*z + m[0][3]; + m[1][3] = m[1][0]*x + m[1][1]*y + m[1][2]*z + m[1][3]; + m[2][3] = m[2][0]*x + m[2][1]*y + m[2][2]*z + m[2][3]; + } + + void Scale(float x, float y, float z) + { + m[0][0] *=x; + m[1][0] *=x; + m[2][0] *=x; + + m[0][1] *=y; + m[1][1] *=y; + m[2][1] *=y; + + m[0][2] *=z; + m[1][2] *=z; + m[2][2] *=z; + } + + void Rotate(float ax, float ay, float az, float angle) + { + Matrix3x4 m1; + + Vector axis(ax, ay, az); + axis.Normalize(); + double c = cos(angle * M_PI/180.), s = sin(angle * M_PI/180.), t = 1 - c; + double sx = s*axis.X(), sy = s*axis.Y(), sz = s*axis.Z(); + double tx, ty, txx, tyy, u, v; + + tx = t*axis.X(); + m1.m[0][0] = float( (txx=tx*axis.X()) + c ); + m1.m[0][1] = float( (u=tx*axis.Y()) - sz); + m1.m[0][2] = float( (v=tx*axis.Z()) + sy); + + ty = t*axis.Y(); + m1.m[1][0] = float( u + sz); + m1.m[1][1] = float( (tyy=ty*axis.Y()) + c ); + m1.m[1][2] = float( (u=ty*axis.Z()) - sx); + + m1.m[2][0] = float( v - sy); + m1.m[2][1] = float( u + sx); + m1.m[2][2] = float( (t-txx-tyy) + c ); + + m1.m[0][3] = 0.f; + m1.m[1][3] = 0.f; + m1.m[2][3] = 0.f; + + *this = (*this) * m1; + } + + Matrix3x4 operator *(const Matrix3x4 &other) + { + Matrix3x4 result; + + result.m[0][0] = m[0][0]*other.m[0][0] + m[0][1]*other.m[1][0] + m[0][2]*other.m[2][0]; + result.m[0][1] = m[0][0]*other.m[0][1] + m[0][1]*other.m[1][1] + m[0][2]*other.m[2][1]; + result.m[0][2] = m[0][0]*other.m[0][2] + m[0][1]*other.m[1][2] + m[0][2]*other.m[2][2]; + result.m[0][3] = m[0][0]*other.m[0][3] + m[0][1]*other.m[1][3] + m[0][2]*other.m[2][3] + m[0][3]; + + result.m[1][0] = m[1][0]*other.m[0][0] + m[1][1]*other.m[1][0] + m[1][2]*other.m[2][0]; + result.m[1][1] = m[1][0]*other.m[0][1] + m[1][1]*other.m[1][1] + m[1][2]*other.m[2][1]; + result.m[1][2] = m[1][0]*other.m[0][2] + m[1][1]*other.m[1][2] + m[1][2]*other.m[2][2]; + result.m[1][3] = m[1][0]*other.m[0][3] + m[1][1]*other.m[1][3] + m[1][2]*other.m[2][3] + m[1][3]; + + result.m[2][0] = m[2][0]*other.m[0][0] + m[2][1]*other.m[1][0] + m[2][2]*other.m[2][0]; + result.m[2][1] = m[2][0]*other.m[0][1] + m[2][1]*other.m[1][1] + m[2][2]*other.m[2][1]; + result.m[2][2] = m[2][0]*other.m[0][2] + m[2][1]*other.m[1][2] + m[2][2]*other.m[2][2]; + result.m[2][3] = m[2][0]*other.m[0][3] + m[2][1]*other.m[1][3] + m[2][2]*other.m[2][3] + m[2][3]; + + return result; + } + + Vector operator *(const Vector &vec) + { + Vector result; + + result.SetX(vec.X()*m[0][0] + vec.Y()*m[0][1] + vec.Z()*m[0][2] + m[0][3]); + result.SetY(vec.X()*m[1][0] + vec.Y()*m[1][1] + vec.Z()*m[1][2] + m[1][3]); + result.SetZ(vec.X()*m[2][0] + vec.Y()*m[2][1] + vec.Z()*m[2][2] + m[2][3]); + return result; + } + + void MultiplyVector(float *f3 , float *f3o) + { + float x = f3[0] * m[0][0] + f3[1] * m[0][1] + f3[2] * m[0][2] + m[0][3]; + float y = f3[0] * m[1][0] + f3[1] * m[1][1] + f3[2] * m[1][2] + m[1][3]; + float z = f3[0] * m[2][0] + f3[1] * m[2][1] + f3[2] * m[2][2] + m[2][3]; + f3o[2] = z; f3o[1] = y; f3o[0] = x; + } +}; + +#endif diff --git a/src/gl/utility/gl_templates.h b/src/gl/utility/gl_templates.h new file mode 100644 index 000000000..1ebef1f48 --- /dev/null +++ b/src/gl/utility/gl_templates.h @@ -0,0 +1,82 @@ +#ifndef __GL_BASIC +#define __GL_BASIC + +#include +#include "stats.h" + + +// Disabled because it doesn't work and only accumulates large portions of blocked heap +// without providing any relevant performance boost. +template struct FreeList +{ + //T * freelist; + + T * GetNew() + { + /* + if (freelist) + { + T * n=freelist; + freelist=*((T**)n); + return new ((void*)n) T; + } + */ + return new T; + } + + void Release(T * node) + { + /* + node->~T(); + *((T**)node) = freelist; + freelist=node; + */ + delete node; + } + + ~FreeList() + { + /* + while (freelist!=NULL) + { + T * n = freelist; + freelist=*((T**)n); + delete n; + } + */ + } +}; + +template class UniqueList +{ + TArray Array; + FreeList TheFreeList; + +public: + + T * Get(T * t) + { + for(unsigned i=0;i #include +#include "version.h" #include "hardware.h" #include "i_video.h" #include "i_system.h" @@ -46,6 +47,7 @@ #include "v_text.h" #include "doomstat.h" #include "m_argv.h" +#include "sdlglvideo.h" #include "r_renderer.h" #include "r_swrenderer.h" @@ -55,6 +57,37 @@ EXTERN_CVAR (Float, vid_winscale) IVideo *Video; +extern int NewWidth, NewHeight, NewBits, DisplayBits; +bool V_DoModeSetup (int width, int height, int bits); +void I_RestartRenderer(); + +int currentrenderer; + +// [ZDoomGL] +CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + // 0: Software renderer + // 1: OpenGL renderer + + if (self != currentrenderer) + { + switch (self) + { + case 0: + Printf("Switching to software renderer...\n"); + break; + case 1: + Printf("Switching to OpenGL renderer...\n"); + break; + default: + Printf("Unknown renderer (%d). Falling back to software renderer...\n", (int) vid_renderer); + self = 0; // make sure to actually switch to the software renderer + break; + } + Printf("You must restart " GAMENAME " to switch the renderer\n"); + } +} + void I_ShutdownGraphics () { if (screen) @@ -74,8 +107,11 @@ void I_InitGraphics () val.Bool = !!Args->CheckParm ("-devparm"); ticker.SetGenericRepDefault (val, CVAR_Bool); - - Video = new SDLVideo (0); + + //currentrenderer = vid_renderer; + if (currentrenderer==1) Video = new SDLGLVideo(0); + else Video = new SDLVideo (0); + if (Video == NULL) I_FatalError ("Failed to initialize display"); @@ -91,9 +127,11 @@ static void I_DeleteRenderer() void I_CreateRenderer() { + currentrenderer = vid_renderer; if (Renderer == NULL) { - Renderer = new FSoftwareRenderer; + if (currentrenderer==1) Renderer = gl_CreateInterface(); + else Renderer = new FSoftwareRenderer; atterm(I_DeleteRenderer); } } diff --git a/src/sdl/sdlglvideo.cpp b/src/sdl/sdlglvideo.cpp new file mode 100644 index 000000000..6378381e4 --- /dev/null +++ b/src/sdl/sdlglvideo.cpp @@ -0,0 +1,417 @@ + +// HEADER FILES ------------------------------------------------------------ + +#include + +#include "doomtype.h" + +#include "templates.h" +#include "i_system.h" +#include "i_video.h" +#include "v_video.h" +#include "v_pfx.h" +#include "stats.h" +#include "version.h" +#include "c_console.h" + +#include "sdlglvideo.h" +#include "gl/system/gl_system.h" +#include "r_defs.h" +#include "gl/gl_functions.h" +//#include "gl/gl_intern.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/shaders/gl_shader.h" +#include "gl/utility/gl_templates.h" +#include "gl/textures/gl_material.h" +#include "gl/system/gl_cvars.h" + +// MACROS ------------------------------------------------------------------ + +// TYPES ------------------------------------------------------------------- + +IMPLEMENT_ABSTRACT_CLASS(SDLGLFB) + +struct MiniModeInfo +{ + WORD Width, Height; +}; + +// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- + +// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- + +// EXTERNAL DATA DECLARATIONS ---------------------------------------------- + +extern IVideo *Video; +// extern int vid_renderer; + +EXTERN_CVAR (Float, Gamma) +EXTERN_CVAR (Int, vid_displaybits) +EXTERN_CVAR (Int, vid_renderer) + + +// PUBLIC DATA DEFINITIONS ------------------------------------------------- + +CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL ) +{ + Printf("This won't take effect until "GAMENAME" is restarted.\n"); +} + +RenderContext gl; + +// PRIVATE DATA DEFINITIONS ------------------------------------------------ + +// Dummy screen sizes to pass when windowed +static MiniModeInfo WinModes[] = +{ + { 320, 200 }, + { 320, 240 }, + { 400, 225 }, // 16:9 + { 400, 300 }, + { 480, 270 }, // 16:9 + { 480, 360 }, + { 512, 288 }, // 16:9 + { 512, 384 }, + { 640, 360 }, // 16:9 + { 640, 400 }, + { 640, 480 }, + { 720, 480 }, // 16:10 + { 720, 540 }, + { 800, 450 }, // 16:9 + { 800, 500 }, // 16:10 + { 800, 600 }, + { 848, 480 }, // 16:9 + { 960, 600 }, // 16:10 + { 960, 720 }, + { 1024, 576 }, // 16:9 + { 1024, 600 }, // 17:10 + { 1024, 640 }, // 16:10 + { 1024, 768 }, + { 1088, 612 }, // 16:9 + { 1152, 648 }, // 16:9 + { 1152, 720 }, // 16:10 + { 1152, 864 }, + { 1280, 720 }, // 16:9 + { 1280, 800 }, // 16:10 + { 1280, 960 }, + { 1344, 756 }, // 16:9 + { 1360, 768 }, // 16:9 + { 1400, 787 }, // 16:9 + { 1400, 875 }, // 16:10 + { 1440, 900 }, + { 1400, 1050 }, + { 1600, 900 }, // 16:9 + { 1600, 1000 }, // 16:10 + { 1600, 1200 }, + { 1680, 1050 }, // 16:10 + { 1920, 1080 }, // 16:9 + { 1920, 1200 }, // 16:10 + { 2054, 1536 }, + { 2560, 1440 }, // 16:9 + { 2880, 1800 } // 16:10 +}; + +// CODE -------------------------------------------------------------------- + +SDLGLVideo::SDLGLVideo (int parm) +{ + IteratorBits = 0; + IteratorFS = false; + if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { + fprintf( stderr, "Video initialization failed: %s\n", + SDL_GetError( ) ); + } + GetContext(gl); +#ifndef _WIN32 + // mouse cursor is visible by default on linux systems, we disable it by default + SDL_ShowCursor (0); +#endif +} + +SDLGLVideo::~SDLGLVideo () +{ + if (GLRenderer != NULL) GLRenderer->FlushTextures(); +} + +void SDLGLVideo::StartModeIterator (int bits, bool fs) +{ + IteratorMode = 0; + IteratorBits = bits; + IteratorFS = fs; +} + +bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox) +{ + if (IteratorBits != 8) + return false; + + if (!IteratorFS) + { + if ((unsigned)IteratorMode < sizeof(WinModes)/sizeof(WinModes[0])) + { + *width = WinModes[IteratorMode].Width; + *height = WinModes[IteratorMode].Height; + ++IteratorMode; + return true; + } + } + else + { + SDL_Rect **modes = SDL_ListModes (NULL, SDL_FULLSCREEN|SDL_HWSURFACE); + if (modes != NULL && modes[IteratorMode] != NULL) + { + *width = modes[IteratorMode]->w; + *height = modes[IteratorMode]->h; + ++IteratorMode; + return true; + } + } + return false; +} + +DFrameBuffer *SDLGLVideo::CreateFrameBuffer (int width, int height, bool fullscreen, DFrameBuffer *old) +{ + static int retry = 0; + static int owidth, oheight; + + PalEntry flashColor; +// int flashAmount; + + if (old != NULL) + { // Reuse the old framebuffer if its attributes are the same + SDLGLFB *fb = static_cast (old); + if (fb->Width == width && + fb->Height == height) + { + bool fsnow = (fb->Screen->flags & SDL_FULLSCREEN) != 0; + + if (fsnow != fullscreen) + { + SDL_WM_ToggleFullScreen (fb->Screen); + } + return old; + } +// old->GetFlash (flashColor, flashAmount); + delete old; + } + else + { + flashColor = 0; +// flashAmount = 0; + } + + SDLGLFB *fb = new OpenGLFrameBuffer (0, width, height, 32, 60, fullscreen); + retry = 0; + + // If we could not create the framebuffer, try again with slightly + // different parameters in this order: + // 1. Try with the closest size + // 2. Try in the opposite screen mode with the original size + // 3. Try in the opposite screen mode with the closest size + // This is a somewhat confusing mass of recursion here. + + while (fb == NULL || !fb->IsValid ()) + { + if (fb != NULL) + { + delete fb; + } + + switch (retry) + { + case 0: + owidth = width; + oheight = height; + case 2: + // Try a different resolution. Hopefully that will work. + I_ClosestResolution (&width, &height, 8); + break; + + case 1: + // Try changing fullscreen mode. Maybe that will work. + width = owidth; + height = oheight; + fullscreen = !fullscreen; + break; + + default: + // I give up! + I_FatalError ("Could not create new screen (%d x %d)", owidth, oheight); + + fprintf( stderr, "!!! [SDLGLVideo::CreateFrameBuffer] Got beyond I_FatalError !!!" ); + return NULL; //[C] actually this shouldn't be reached; probably should be replaced with an ASSERT + } + + ++retry; + fb = static_cast(CreateFrameBuffer (width, height, fullscreen, NULL)); + } + +// fb->SetFlash (flashColor, flashAmount); + return fb; +} + +void SDLGLVideo::SetWindowedScale (float scale) +{ +} + +bool SDLGLVideo::SetResolution (int width, int height, int bits) +{ + // FIXME: Is it possible to do this without completely destroying the old + // interface? +#ifndef NO_GL + + if (GLRenderer != NULL) GLRenderer->FlushTextures(); + I_ShutdownGraphics(); + + Video = new SDLGLVideo(0); + if (Video == NULL) I_FatalError ("Failed to initialize display"); + +#if (defined(WINDOWS)) || defined(WIN32) + bits=32; +#else + bits=24; +#endif + + V_DoModeSetup(width, height, bits); +#endif + return true; // We must return true because the old video context no longer exists. +} + +// FrameBuffer implementation ----------------------------------------------- + +SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen) + : DFrameBuffer (width, height) +{ + static int localmultisample=-1; + + if (localmultisample<0) localmultisample=gl_vid_multisample; + + int i; + + m_Lock=0; + + UpdatePending = false; + + if (!gl.InitHardware(false, gl_vid_compatibility, localmultisample)) + { + vid_renderer = 0; + return; + } + + // Mac OS X version will crash when entering fullscreen mode with BPP <= 8 + // Also it may crash with BPP == 16 on some configurations + // It seems 24 and 32 bits are safe values + // So value of vid_displaybits is ignored and hardcoded constant is used instead + + Screen = SDL_SetVideoMode (width, height, +#if defined(__APPLE__) + 32, +#else // ! __APPLE__ + vid_displaybits, +#endif // __APPLE__ + SDL_HWSURFACE|SDL_HWPALETTE|SDL_OPENGL | SDL_GL_DOUBLEBUFFER|SDL_ANYFORMAT| + (fullscreen ? SDL_FULLSCREEN : 0)); + + if (Screen == NULL) + return; + + m_supportsGamma = -1 != SDL_GetGammaRamp(m_origGamma[0], m_origGamma[1], m_origGamma[2]); + +#if defined(__APPLE__) + // Need to set title here because a window is not created yet when calling the same function from main() + SDL_WM_SetCaption( GAMESIG " " DOTVERSIONSTR " (" __DATE__ ")", NULL ); +#endif // __APPLE__ +} + +SDLGLFB::~SDLGLFB () +{ + if (m_supportsGamma) + { + SDL_SetGammaRamp(m_origGamma[0], m_origGamma[1], m_origGamma[2]); + } +} + +void SDLGLFB::InitializeState() +{ + int value = 0; + SDL_GL_GetAttribute( SDL_GL_STENCIL_SIZE, &value ); + if (!value) + { + Printf("Failed to use stencil buffer!\n"); //[C] is it needed to recreate buffer in "cheapest mode"? + gl.flags|=RFL_NOSTENCIL; + } +} + +bool SDLGLFB::CanUpdate () +{ + if (m_Lock != 1) + { + if (m_Lock > 0) + { + UpdatePending = true; + --m_Lock; + } + return false; + } + return true; +} + +void SDLGLFB::SetGammaTable(WORD *tbl) +{ + SDL_SetGammaRamp(&tbl[0], &tbl[256], &tbl[512]); +} + +bool SDLGLFB::Lock(bool buffered) +{ + m_Lock++; + Buffer = MemBuffer; + return true; +} + +bool SDLGLFB::Lock () +{ + return Lock(false); +} + +void SDLGLFB::Unlock () +{ + if (UpdatePending && m_Lock == 1) + { + Update (); + } + else if (--m_Lock <= 0) + { + m_Lock = 0; + } +} + +bool SDLGLFB::IsLocked () +{ + return m_Lock>0;// true; +} + +bool SDLGLFB::IsFullscreen () +{ + return (Screen->flags & SDL_FULLSCREEN) != 0; +} + + +bool SDLGLFB::IsValid () +{ + return DFrameBuffer::IsValid() && Screen != NULL; +} + +void SDLGLFB::SetVSync( bool vsync ) +{ +#if defined (__APPLE__) + const GLint value = vsync ? 1 : 0; + CGLSetParameter( CGLGetCurrentContext(), kCGLCPSwapInterval, &value ); +#endif +} + +void SDLGLFB::NewRefreshRate () +{ +} + diff --git a/src/sdl/sdlglvideo.h b/src/sdl/sdlglvideo.h new file mode 100644 index 000000000..35175e421 --- /dev/null +++ b/src/sdl/sdlglvideo.h @@ -0,0 +1,78 @@ +#ifndef __SDLGLVIDEO_H__ +#define __SDLGLVIDEO_H__ + +#include "hardware.h" +#include "v_video.h" +#include +#include "gl/system/gl_system.h" + +EXTERN_CVAR (Float, dimamount) +EXTERN_CVAR (Color, dimcolor) + +struct FRenderer; +FRenderer *gl_CreateInterface(); + +class SDLGLVideo : public IVideo +{ + public: + SDLGLVideo (int parm); + ~SDLGLVideo (); + + EDisplayType GetDisplayType () { return DISPLAY_Both; } + void SetWindowedScale (float scale); + + DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old); + + void StartModeIterator (int bits, bool fs); + bool NextMode (int *width, int *height, bool *letterbox); + bool SetResolution (int width, int height, int bits); + +private: + int IteratorMode; + int IteratorBits; + bool IteratorFS; +}; +class SDLGLFB : public DFrameBuffer +{ + DECLARE_CLASS(SDLGLFB, DFrameBuffer) +public: + // this must have the same parameters as the Windows version, even if they are not used! + SDLGLFB (void *hMonitor, int width, int height, int, int, bool fullscreen); + ~SDLGLFB (); + + void ForceBuffering (bool force); + bool Lock(bool buffered); + bool Lock (); + void Unlock(); + bool IsLocked (); + + bool IsValid (); + bool IsFullscreen (); + + virtual void SetVSync( bool vsync ); + + void NewRefreshRate (); + + friend class SDLGLVideo; + +//[C] + int GetTrueHeight() { return GetHeight();} + +protected: + bool CanUpdate(); + void SetGammaTable(WORD *tbl); + void InitializeState(); + + SDLGLFB () {} + BYTE GammaTable[3][256]; + bool UpdatePending; + + SDL_Surface *Screen; + + void UpdateColors (); + + int m_Lock; + Uint16 m_origGamma[3][256]; + bool m_supportsGamma; +}; +#endif diff --git a/src/textures/textures.h b/src/textures/textures.h index 100ba31e9..e4e3dc92d 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -3,6 +3,27 @@ #include "doomtype.h" +struct FloatRect +{ + float left,top; + float width,height; + + + void Offset(float xofs,float yofs) + { + left+=xofs; + top+=yofs; + } + void Scale(float xfac,float yfac) + { + left*=xfac; + width*=xfac; + top*=yfac; + height*=yfac; + } +}; + + class FBitmap; struct FRemapTable; struct FCopyInfo; @@ -13,6 +34,8 @@ class FArchive; // Texture IDs class FTextureManager; class FTerrainTypeArray; +class FGLTexture; +class FMaterial; class FTextureID { @@ -295,6 +318,9 @@ protected: CopySize(other); bNoDecals = other->bNoDecals; Rotations = other->Rotations; + gl_info = other->gl_info; + gl_info.Brightmap = NULL; + gl_info.areas = NULL; } public: @@ -304,8 +330,52 @@ public: static void FlipNonSquareBlockRemap (BYTE *blockto, const BYTE *blockfrom, int x, int y, int srcpitch, const BYTE *remap); friend class D3DTex; -}; +public: + + struct MiscGLInfo + { + FMaterial *Material; + FGLTexture *SystemTexture; + FTexture *Brightmap; + FTexture *DecalTexture; // This is needed for decals of UseType TEX_MiscPatch- + PalEntry GlowColor; + PalEntry FloorSkyColor; + PalEntry CeilingSkyColor; + int GlowHeight; + FloatRect *areas; + int areacount; + int shaderindex; + float shaderspeed; + int mIsTransparent:2; + bool bGlowing:1; // Texture glows + bool bFullbright:1; // always draw fullbright + bool bSkybox:1; // This is a skybox + bool bSkyColorDone:1; // Fill color for sky + char bBrightmapChecked:1; // Set to 1 if brightmap has been checked + bool bBrightmap:1; // This is a brightmap + bool bBrightmapDisablesFullbright:1; // This disables fullbright display + bool bNoFilter:1; + bool bNoCompress:1; + bool mExpanded:1; + + MiscGLInfo() throw (); + ~MiscGLInfo(); + }; + MiscGLInfo gl_info; + + virtual void PrecacheGL(); + virtual void UncacheGL(); + void GetGlowColor(float *data); + PalEntry GetSkyCapColor(bool bottom); + bool isGlowing() { return gl_info.bGlowing; } + bool isFullbright() { return gl_info.bFullbright; } + void CreateDefaultBrightmap(); + bool FindHoles(const unsigned char * buffer, int w, int h); + static bool SmoothEdges(unsigned char * buffer,int w, int h); + void CheckTrans(unsigned char * buffer, int size, int trans); + bool ProcessData(unsigned char * buffer, int w, int h, bool ispatch); +}; // Texture manager class FTextureManager diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 6b3f40f1c..cd009c206 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -56,12 +56,48 @@ EXTERN_CVAR (Float, vid_winscale) CVAR(Int, win_x, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Int, win_y, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -extern HWND Window; +#include "win32gliface.h" bool ForceWindowed; IVideo *Video; + +void I_RestartRenderer(); +int currentrenderer = -1; +bool changerenderer; + +// [ZDoomGL] +CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + // 0: Software renderer + // 1: OpenGL renderer + + if (self != currentrenderer) + { + switch (self) + { + case 0: + Printf("Switching to software renderer...\n"); + break; + case 1: + Printf("Switching to OpenGL renderer...\n"); + break; + default: + Printf("Unknown renderer (%d). Falling back to software renderer...\n", *vid_renderer); + self = 0; // make sure to actually switch to the software renderer + break; + } + //changerenderer = true; + Printf("You must restart "GAMENAME" to switch the renderer\n"); + } +} + +CCMD (vid_restart) +{ +} + + void I_ShutdownGraphics () { if (screen) @@ -94,15 +130,18 @@ void I_InitGraphics () // not receive a WM_ACTIVATEAPP message, so both games think they // are the active app. Huh? } - val.Bool = !!Args->CheckParm ("-devparm"); ticker.SetGenericRepDefault (val, CVAR_Bool); - Video = new Win32Video (0); + + //currentrenderer = vid_renderer; + if (currentrenderer==1) Video = new Win32GLVideo(0); + else Video = new Win32Video (0); + if (Video == NULL) I_FatalError ("Failed to initialize display"); - + atterm (I_ShutdownGraphics); - + Video->SetWindowedScale (vid_winscale); } @@ -113,9 +152,11 @@ static void I_DeleteRenderer() void I_CreateRenderer() { + currentrenderer = vid_renderer; if (Renderer == NULL) { - Renderer = new FSoftwareRenderer; + if (currentrenderer==1) Renderer = gl_CreateInterface(); + else Renderer = new FSoftwareRenderer; atterm(I_DeleteRenderer); } } @@ -148,12 +189,12 @@ DFrameBuffer *I_SetMode (int &width, int &height, DFrameBuffer *old) } DFrameBuffer *res = Video->CreateFrameBuffer (width, height, fs, old); - /* Right now, CreateFrameBuffer cannot return NULL + //* Right now, CreateFrameBuffer cannot return NULL if (res == NULL) { I_FatalError ("Mode %dx%d is unavailable\n", width, height); } - */ + //*/ return res; } @@ -332,7 +373,7 @@ CUSTOM_CVAR (Float, vid_winscale, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) NewWidth = screen->GetWidth(); NewHeight = screen->GetHeight(); NewBits = DisplayBits; - setmodeneeded = true; + //setmodeneeded = true; // This CVAR doesn't do anything and only causes problems! } } diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp new file mode 100644 index 000000000..ebe9e10c6 --- /dev/null +++ b/src/win32/win32gliface.cpp @@ -0,0 +1,564 @@ +#include "gl/system/gl_system.h" + +#include "win32iface.h" +#include "win32gliface.h" +//#include "gl/gl_intern.h" +#include "templates.h" +#include "version.h" +#include "c_console.h" +#include "hardware.h" +#include "v_video.h" +#include "i_input.h" +#include "i_system.h" +#include "doomstat.h" +#include "v_text.h" +//#include "gl_defs.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/shaders/gl_shader.h" +#include "gl/utility/gl_templates.h" + +void gl_CalculateCPUSpeed(); +extern int NewWidth, NewHeight, NewBits, DisplayBits; + +CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL ) +{ + Printf("This won't take effect until "GAMENAME" is restarted.\n"); +} + +RenderContext gl; + + +EXTERN_CVAR(Bool, gl_vid_compatibility) +EXTERN_CVAR(Int, vid_refreshrate) + +Win32GLVideo::Win32GLVideo(int parm) : m_Modes(NULL), m_IsFullscreen(false) +{ + #ifdef _WIN32 + if (CPU.bRDTSC) gl_CalculateCPUSpeed(); + #endif + I_SetWndProc(); + m_DisplayWidth = vid_defwidth; + m_DisplayHeight = vid_defheight; + m_DisplayBits = gl_vid_compatibility? 16:32; + m_DisplayHz = 60; + + GetDisplayDeviceName(); + MakeModesList(); + GetContext(gl); + +} + +Win32GLVideo::~Win32GLVideo() +{ + FreeModes(); + if (GLRenderer != NULL) GLRenderer->FlushTextures(); +} + +void Win32GLVideo::SetWindowedScale(float scale) +{ +} + +struct MonitorEnumState +{ + int curIdx; + HMONITOR hFoundMonitor; +}; + +static BOOL CALLBACK GetDisplayDeviceNameMonitorEnumProc(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData) +{ + MonitorEnumState *state = reinterpret_cast(dwData); + + MONITORINFOEX mi; + mi.cbSize = sizeof mi; + GetMonitorInfo(hMonitor, &mi); + + // This assumes the monitors are returned by EnumDisplayMonitors in the + // order they're found in the Direct3D9 adapters list. Fingers crossed... + if (state->curIdx == vid_adapter) + { + state->hFoundMonitor = hMonitor; + + // Don't stop enumeration; this makes EnumDisplayMonitors fail. I like + // proper fails. + } + + ++state->curIdx; + + return TRUE; +} + +void Win32GLVideo::GetDisplayDeviceName() +{ + // If anything goes wrong, anything at all, everything uses the primary + // monitor. + m_DisplayDeviceName = 0; + m_hMonitor = 0; + + MonitorEnumState mes; + + mes.curIdx = 1; + mes.hFoundMonitor = 0; + + // Could also use EnumDisplayDevices, I guess. That might work. + if (EnumDisplayMonitors(0, 0, &GetDisplayDeviceNameMonitorEnumProc, LPARAM(&mes))) + { + if (mes.hFoundMonitor) + { + MONITORINFOEX mi; + + mi.cbSize = sizeof mi; + + if (GetMonitorInfo(mes.hFoundMonitor, &mi)) + { + strcpy(m_DisplayDeviceBuffer, mi.szDevice); + m_DisplayDeviceName = m_DisplayDeviceBuffer; + + m_hMonitor = mes.hFoundMonitor; + } + } + } +} + +void Win32GLVideo::MakeModesList() +{ + ModeInfo *pMode, *nextmode; + DEVMODE dm; + int mode = 0; + + memset(&dm, 0, sizeof(DEVMODE)); + dm.dmSize = sizeof(DEVMODE); + + while (EnumDisplaySettings(m_DisplayDeviceName, mode, &dm)) + { + this->AddMode(dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel, dm.dmPelsHeight, dm.dmDisplayFrequency); + ++mode; + } + + for (pMode = m_Modes; pMode != NULL; pMode = nextmode) + { + nextmode = pMode->next; + if (pMode->realheight == pMode->height && pMode->height * 4/3 == pMode->width) + { + if (pMode->width >= 360) + { + AddMode (pMode->width, pMode->width * 9/16, pMode->bits, pMode->height, pMode->refreshHz); + } + if (pMode->width > 640) + { + AddMode (pMode->width, pMode->width * 10/16, pMode->bits, pMode->height, pMode->refreshHz); + } + } + } +} + +void Win32GLVideo::StartModeIterator(int bits, bool fs) +{ + m_IteratorMode = m_Modes; + // I think it's better to ignore the game-side settings of bit depth. + // The GL renderer will always default to 32 bits, except in compatibility mode + m_IteratorBits = gl_vid_compatibility? 16:32; + m_IteratorFS = fs; +} + +bool Win32GLVideo::NextMode(int *width, int *height, bool *letterbox) +{ + if (m_IteratorMode) + { + while (m_IteratorMode && m_IteratorMode->bits != m_IteratorBits) + { + m_IteratorMode = m_IteratorMode->next; + } + + if (m_IteratorMode) + { + *width = m_IteratorMode->width; + *height = m_IteratorMode->height; + if (letterbox != NULL) *letterbox = m_IteratorMode->realheight != m_IteratorMode->height; + m_IteratorMode = m_IteratorMode->next; + return true; + } + } + + return false; +} + +void Win32GLVideo::AddMode(int x, int y, int bits, int baseHeight, int refreshHz) +{ + ModeInfo **probep = &m_Modes; + ModeInfo *probe = m_Modes; + + // This mode may have been already added to the list because it is + // enumerated multiple times at different refresh rates. If it's + // not present, add it to the right spot in the list; otherwise, do nothing. + // Modes are sorted first by width, then by height, then by depth. In each + // case the order is ascending. + for (; probe != 0; probep = &probe->next, probe = probe->next) + { + if (probe->width != x) continue; + // Width is equal + if (probe->height != y) continue; + // Width is equal + if (probe->realheight != baseHeight) continue; + // Height is equal + if (probe->bits != bits) continue; + // Bits is equal + if (probe->refreshHz > refreshHz) continue; + probe->refreshHz = refreshHz; + return; + } + + *probep = new ModeInfo (x, y, bits, baseHeight, refreshHz); + (*probep)->next = probe; +} + +void Win32GLVideo::FreeModes() +{ + ModeInfo *mode = m_Modes; + + while (mode) + { + ModeInfo *tempmode = mode; + mode = mode->next; + delete tempmode; + } + + m_Modes = NULL; +} + +bool Win32GLVideo::GoFullscreen(bool yes) +{ + m_IsFullscreen = yes; + + m_trueHeight = m_DisplayHeight; + + if (yes) + { + // If in windowed mode, any height is good. + for (ModeInfo *mode = m_Modes; mode != NULL; mode = mode->next) + { + if (mode->width == m_DisplayWidth && mode->height == m_DisplayHeight) + { + m_trueHeight = mode->realheight; + break; + } + } + } + + if (yes) + { + gl.SetFullscreen(m_DisplayDeviceName, m_DisplayWidth, m_trueHeight, m_DisplayBits, m_DisplayHz); + } + else + { + gl.SetFullscreen(m_DisplayDeviceName, 0,0,0,0); + } + return yes; +} + + +DFrameBuffer *Win32GLVideo::CreateFrameBuffer(int width, int height, bool fs, DFrameBuffer *old) +{ + Win32GLFrameBuffer *fb; + + m_DisplayWidth = width; + m_DisplayHeight = height; + m_DisplayBits = gl_vid_compatibility? 16:32; + m_DisplayHz = 60; + + if (vid_refreshrate == 0) + { + for (ModeInfo *mode = m_Modes; mode != NULL; mode = mode->next) + { + if (mode->width == m_DisplayWidth && mode->height == m_DisplayHeight && mode->bits == m_DisplayBits) + { + m_DisplayHz = MAX(m_DisplayHz, mode->refreshHz); + } + } + } + else + { + m_DisplayHz = vid_refreshrate; + } + + if (old != NULL) + { // Reuse the old framebuffer if its attributes are the same + fb = static_cast (old); + if (fb->m_Width == m_DisplayWidth && + fb->m_Height == m_DisplayHeight && + fb->m_Bits == m_DisplayBits && + fb->m_RefreshHz == m_DisplayHz && + fb->m_Fullscreen == fs) + { + return old; + } + //old->GetFlash(flashColor, flashAmount); + delete old; + } + + fb = new OpenGLFrameBuffer(m_hMonitor, m_DisplayWidth, m_DisplayHeight, m_DisplayBits, m_DisplayHz, fs); + + return fb; +} + +bool Win32GLVideo::SetResolution (int width, int height, int bits) +{ + if (GLRenderer != NULL) GLRenderer->FlushTextures(); + I_ShutdownGraphics(); + + Video = new Win32GLVideo(0); + if (Video == NULL) I_FatalError ("Failed to initialize display"); + + bits=32; + + V_DoModeSetup(width, height, bits); + return true; // We must return true because the old video context no longer exists. +} + +struct DumpAdaptersState +{ + unsigned index; + char *displayDeviceName; +}; + +static BOOL CALLBACK DumpAdaptersMonitorEnumProc(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData) +{ + DumpAdaptersState *state = reinterpret_cast(dwData); + + MONITORINFOEX mi; + mi.cbSize=sizeof mi; + + char moreinfo[64] = ""; + + bool active = true; + + if (GetMonitorInfo(hMonitor, &mi)) + { + bool primary = !!(mi.dwFlags & MONITORINFOF_PRIMARY); + + mysnprintf(moreinfo, countof(moreinfo), " [%ldx%ld @ (%ld,%ld)]%s", + mi.rcMonitor.right - mi.rcMonitor.left, + mi.rcMonitor.bottom - mi.rcMonitor.top, + mi.rcMonitor.left, mi.rcMonitor.top, + primary ? " (Primary)" : ""); + + if (!state->displayDeviceName && !primary) + active = false;//primary selected, but this ain't primary + else if (state->displayDeviceName && strcmp(state->displayDeviceName, mi.szDevice) != 0) + active = false;//this isn't the selected one + } + + Printf("%s%u. %s\n", + active ? TEXTCOLOR_BOLD : "", + state->index, + moreinfo); + + ++state->index; + + return TRUE; +} + +void Win32GLVideo::DumpAdapters() +{ + DumpAdaptersState das; + + das.index = 1; + das.displayDeviceName = m_DisplayDeviceName; + + EnumDisplayMonitors(0, 0, DumpAdaptersMonitorEnumProc, LPARAM(&das)); +} + +IMPLEMENT_ABSTRACT_CLASS(Win32GLFrameBuffer) + +Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : BaseWinFB(width, height) +{ + static int localmultisample=-1; + + if (localmultisample<0) localmultisample=gl_vid_multisample; + + m_Width = width; + m_Height = height; + m_Bits = bits; + m_RefreshHz = refreshHz; + m_Fullscreen = fullscreen; + m_Lock=0; + + RECT r; + LONG style, exStyle; + + static_cast(Video)->GoFullscreen(fullscreen); + + m_displayDeviceName = 0; + int monX = 0, monY = 0; + + if (hMonitor) + { + MONITORINFOEX mi; + mi.cbSize = sizeof mi; + + if (GetMonitorInfo(HMONITOR(hMonitor), &mi)) + { + strcpy(m_displayDeviceNameBuffer, mi.szDevice); + m_displayDeviceName = m_displayDeviceNameBuffer; + + monX = int(mi.rcMonitor.left); + monY = int(mi.rcMonitor.top); + } + } + + ShowWindow (Window, SW_SHOW); + GetWindowRect(Window, &r); + style = WS_VISIBLE | WS_CLIPSIBLINGS; + exStyle = 0; + + if (fullscreen) + style |= WS_POPUP; + else + { + style |= WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX; + exStyle |= WS_EX_WINDOWEDGE; + } + + SetWindowLong(Window, GWL_STYLE, style); + SetWindowLong(Window, GWL_EXSTYLE, exStyle); + SetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + + if (fullscreen) + { + MoveWindow(Window, monX, monY, width, static_cast(Video)->GetTrueHeight(), FALSE); + + // And now, seriously, it IS in the right place. Promise. + } + else + { + MoveWindow(Window, r.left, r.top, width + (GetSystemMetrics(SM_CXSIZEFRAME) * 2), height + (GetSystemMetrics(SM_CYSIZEFRAME) * 2) + GetSystemMetrics(SM_CYCAPTION), FALSE); + + I_RestoreWindowedPos(); + } + + if (!gl.InitHardware(Window, false, gl_vid_compatibility, localmultisample)) + { + vid_renderer = 0; + return; + } + + HDC hDC = GetDC(Window); + m_supportsGamma = !!GetDeviceGammaRamp(hDC, (void *)m_origGamma); + ReleaseDC(Window, hDC); +} + +Win32GLFrameBuffer::~Win32GLFrameBuffer() +{ + if (m_supportsGamma) + { + HDC hDC = GetDC(Window); + SetDeviceGammaRamp(hDC, (void *)m_origGamma); + ReleaseDC(Window, hDC); + } + I_SaveWindowedPos(); + + gl.SetFullscreen(m_displayDeviceName, 0,0,0,0); + + ShowWindow (Window, SW_SHOW); + SetWindowLong(Window, GWL_STYLE, WS_VISIBLE | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW); + SetWindowLong(Window, GWL_EXSTYLE, WS_EX_WINDOWEDGE); + SetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + I_GetEvent(); + + gl.Shutdown(); +} + + +void Win32GLFrameBuffer::InitializeState() +{ +} + +bool Win32GLFrameBuffer::CanUpdate() +{ + if (!AppActive) return false; + return true; +} + +void Win32GLFrameBuffer::SetGammaTable(WORD *tbl) +{ + HDC hDC = GetDC(Window); + SetDeviceGammaRamp(hDC, (void *)tbl); + ReleaseDC(Window, hDC); +} + +bool Win32GLFrameBuffer::Lock(bool buffered) +{ + m_Lock++; + Buffer = MemBuffer; + return true; +} + +bool Win32GLFrameBuffer::Lock () +{ + return Lock(false); +} + +void Win32GLFrameBuffer::Unlock () +{ + m_Lock--; +} + +bool Win32GLFrameBuffer::IsLocked () +{ + return m_Lock>0;// true; +} + +bool Win32GLFrameBuffer::IsFullscreen() +{ + return m_Fullscreen; +} + +void Win32GLFrameBuffer::PaletteChanged() +{ +} + +int Win32GLFrameBuffer::QueryNewPalette() +{ + return 0; +} + +HRESULT Win32GLFrameBuffer::GetHR() +{ + return 0; +} + +void Win32GLFrameBuffer::Blank () +{ +} + +bool Win32GLFrameBuffer::PaintToWindow () +{ + return false; +} + +bool Win32GLFrameBuffer::CreateResources () +{ + return false; +} + +void Win32GLFrameBuffer::ReleaseResources () +{ +} + +void Win32GLFrameBuffer::SetVSync (bool vsync) +{ + if (gl.SetVSync!=NULL) gl.SetVSync(vsync); +} + +void Win32GLFrameBuffer::NewRefreshRate () +{ + if (m_Fullscreen) + { + setmodeneeded = true; + NewWidth = screen->GetWidth(); + NewHeight = screen->GetHeight(); + NewBits = DisplayBits; + } +} + diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h new file mode 100644 index 000000000..ba4ea001d --- /dev/null +++ b/src/win32/win32gliface.h @@ -0,0 +1,147 @@ +#ifndef __WIN32GLIFACE_H__ +#define __WIN32GLIFACE_H__ + +/* +#define WIN32_LEAN_AND_MEAN +#include +#include + +#include "gl/glext.h" +#include "gl/wglext.h" +*/ + +#include "win32iface.h" +#include "hardware.h" +#include "v_video.h" +#include "tarray.h" + +extern IVideo *Video; + + +extern BOOL AppActive; + +EXTERN_CVAR (Float, dimamount) +EXTERN_CVAR (Color, dimcolor) + +EXTERN_CVAR(Int, vid_defwidth); +EXTERN_CVAR(Int, vid_defheight); +EXTERN_CVAR(Int, vid_renderer); +EXTERN_CVAR(Int, vid_adapter); + +extern HINSTANCE g_hInst; +extern HWND Window; +extern IVideo *Video; + +struct FRenderer; +FRenderer *gl_CreateInterface(); + + +class Win32GLVideo : public IVideo +{ +public: + Win32GLVideo(int parm); + virtual ~Win32GLVideo(); + + EDisplayType GetDisplayType () { return DISPLAY_Both; } + void SetWindowedScale (float scale); + void StartModeIterator (int bits, bool fs); + bool NextMode (int *width, int *height, bool *letterbox); + bool GoFullscreen(bool yes); + DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old); + virtual bool SetResolution (int width, int height, int bits); + void DumpAdapters(); + +protected: + struct ModeInfo + { + ModeInfo (int inX, int inY, int inBits, int inRealY, int inRefresh) + : next (NULL), + width (inX), + height (inY), + bits (inBits), + refreshHz (inRefresh), + realheight (inRealY) + {} + ModeInfo *next; + int width, height, bits, refreshHz, realheight; + } *m_Modes; + + ModeInfo *m_IteratorMode; + int m_IteratorBits; + bool m_IteratorFS; + bool m_IsFullscreen; + int m_trueHeight; + int m_DisplayWidth, m_DisplayHeight, m_DisplayBits, m_DisplayHz; + HMODULE hmRender; + + char m_DisplayDeviceBuffer[CCHDEVICENAME]; + char *m_DisplayDeviceName; + HMONITOR m_hMonitor; + + void GetDisplayDeviceName(); + void MakeModesList(); + void AddMode(int x, int y, int bits, int baseHeight, int refreshHz); + void FreeModes(); +public: + int GetTrueHeight() { return m_trueHeight; } + +}; + + + +class Win32GLFrameBuffer : public BaseWinFB +{ + DECLARE_CLASS(Win32GLFrameBuffer, BaseWinFB) + +public: + Win32GLFrameBuffer() {} + // Actually, hMonitor is a HMONITOR, but it's passed as a void * as there + // look to be some cross-platform bits in the way. + Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen); + virtual ~Win32GLFrameBuffer(); + + // unused but must be defined + virtual void Blank (); + virtual bool PaintToWindow (); + virtual HRESULT GetHR(); + + virtual bool CreateResources (); + virtual void ReleaseResources (); + + void SetVSync (bool vsync); + void NewRefreshRate (); + + + int GetTrueHeight() { return static_cast(Video)->GetTrueHeight(); } + + bool Lock(bool buffered); + bool Lock (); + void Unlock(); + bool IsLocked (); + + + bool IsFullscreen(); + void PaletteChanged(); + int QueryNewPalette(); + + void InitializeState(); + +protected: + + bool CanUpdate(); + void SetGammaTable(WORD * tbl); + + float m_Gamma, m_Brightness, m_Contrast; + WORD m_origGamma[768]; + BOOL m_supportsGamma; + bool m_Fullscreen; + int m_Width, m_Height, m_Bits, m_RefreshHz; + int m_Lock; + char m_displayDeviceNameBuffer[CCHDEVICENAME]; + char *m_displayDeviceName; + + friend class Win32GLVideo; + +}; + +#endif //__WIN32GLIFACE_H__ diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index e28277e3a..5e2226c6d 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -72,13 +72,13 @@ BEGIN " BEGIN\r\n" " VALUE ""Comments"", ""Thanks to id Software for creating DOOM and then releasing the source code. Thanks also to TeamTNT for creating BOOM, which ZDoom is partially based on. Includes code based on the Cajun Bot 0.97 by Martin Collberg.""\r\n" " VALUE ""CompanyName"", "" ""\r\n" - " VALUE ""FileDescription"", ""ZDoom""\r\n" + " VALUE ""FileDescription"", ""GZDoom""\r\n" " VALUE ""FileVersion"", RC_FILEVERSION2\r\n" - " VALUE ""InternalName"", ""ZDoom""\r\n" + " VALUE ""InternalName"", ""GZDoom""\r\n" " VALUE ""LegalCopyright"", ""Copyright \\u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al.""\r\n" " VALUE ""LegalTrademarks"", ""DoomR is a Registered Trademark of id Software, Inc.""\r\n" - " VALUE ""OriginalFilename"", ""zdoom.exe""\r\n" - " VALUE ""ProductName"", ""ZDoom""\r\n" + " VALUE ""OriginalFilename"", ""gzdoom.exe""\r\n" + " VALUE ""ProductName"", ""GZDoom""\r\n" " VALUE ""ProductVersion"", RC_PRODUCTVERSION2\r\n" " END\r\n" " END\r\n" @@ -86,7 +86,7 @@ BEGIN " BEGIN\r\n" " VALUE ""Translation"", 0x409, 1200\r\n" " END\r\n" - "EN\0" + "END\r\n" END #endif // APSTUDIO_INVOKED @@ -464,7 +464,7 @@ IDB_DEADGUY BITMAP "deadguy.bmp" // Generated from the TEXTINCLUDE 3 resource. // #ifndef NO_MANIFEST - CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "zdoom.exe.manifest" +// CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "zdoom.exe.manifest" #endif ///////////////////////////////////////////////////////////////////////////// @@ -492,13 +492,13 @@ BEGIN BEGIN VALUE "Comments", "Thanks to id Software for creating DOOM and then releasing the source code. Thanks also to TeamTNT for creating BOOM, which ZDoom is partially based on. Includes code based on the Cajun Bot 0.97 by Martin Collberg." VALUE "CompanyName", " " - VALUE "FileDescription", "ZDoom" + VALUE "FileDescription", "GZDoom" VALUE "FileVersion", RC_FILEVERSION2 - VALUE "InternalName", "ZDoom" + VALUE "InternalName", "GZDoom" VALUE "LegalCopyright", "Copyright \u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al." VALUE "LegalTrademarks", "DoomR is a Registered Trademark of id Software, Inc." - VALUE "OriginalFilename", "zdoom.exe" - VALUE "ProductName", "ZDoom" + VALUE "OriginalFilename", "gzdoom.exe" + VALUE "ProductName", "GZDoom" VALUE "ProductVersion", RC_PRODUCTVERSION2 END END From a73d1b792c9e968cff9d5865e2fb4a837996ec9d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 23 Jun 2013 10:17:58 +0200 Subject: [PATCH 0004/1509] - fixed: Assignment of GetLightLevel to GLWall::lightlevel must be clamped. This was done incorrectly in the last SVN version which clamped the result of GetLightLevel, causing problems elsewhere. --- src/gl/scene/gl_wall.h | 2 +- src/gl/scene/gl_walls.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index e44155aa6..00459644c 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -118,7 +118,7 @@ public: fixed_t viewdistance; - BYTE lightlevel; + int lightlevel; BYTE type; BYTE flags; short rellight; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 40c18baa9..e7265c1a1 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1098,7 +1098,7 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, float to; lightlist_t * light; bool translucent; - byte savelight=lightlevel; + int savelight=lightlevel; FColormap savecolor=Colormap; float ul; float texlength; @@ -1108,12 +1108,12 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, { if (!gl_fixedcolormap) { - // this may not yet be done! + // this may not yet be done light=P_GetPlaneLight(rover->target, rover->top.plane,true); Colormap.Clear(); Colormap.LightColor=(light->extra_colormap)->Fade; - // the fog plane defines the light level, not the front sector! - lightlevel=*light->p_lightlevel; + // the fog plane defines the light level, not the front sector + lightlevel = gl_ClampLight(*light->p_lightlevel); gltexture=NULL; type=RENDERWALL_FFBLOCK; } @@ -1520,7 +1520,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) int rel = 0; int orglightlevel = gl_ClampLight(frontsector->lightlevel); - lightlevel = seg->sidedef->GetLightLevel(!!(flags&GLWF_FOGGY), orglightlevel, false, &rel); + lightlevel = gl_ClampLight(seg->sidedef->GetLightLevel(!!(flags&GLWF_FOGGY), orglightlevel, false, &rel)); if (orglightlevel >= 253) // with the software renderer fake contrast won't be visible above this. { rellight = 0; From b2bb24ea0a4afabf5c947c21768e00b65bfc6387 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 23 Jun 2013 10:46:31 +0200 Subject: [PATCH 0005/1509] - GZDoom project files and GZDoom related changes to main ZDoom code --- gzdoom.vcproj | 7159 ++++++++++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 70 + src/actor.h | 8 + src/p_3dfloors.cpp | 3 +- src/p_saveg.cpp | 3 + src/r_defs.h | 100 + src/version.h | 24 +- 7 files changed, 7355 insertions(+), 12 deletions(-) create mode 100644 gzdoom.vcproj diff --git a/gzdoom.vcproj b/gzdoom.vcproj new file mode 100644 index 000000000..46e600254 --- /dev/null +++ b/gzdoom.vcproj @@ -0,0 +1,7159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9436154bb..1b6dcb019 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,6 +8,7 @@ include( CheckCXXSourceCompiles ) include( CheckFunctionExists ) include( CheckCXXCompilerFlag ) include( FindPkgConfig ) +include( FindOpenGL ) option( NO_ASM "Disable assembly code" ) if( CMAKE_COMPILER_IS_GNUCXX ) @@ -201,6 +202,22 @@ else( WIN32 ) endif( FPU_CONTROL_DIR ) endif( WIN32 ) +if( X64 ) + set( NO_ASM ON ) +endif( X64 ) + +# Check if we have OpenGL + +if( NOT OPENGL_FOUND ) + message( FATAL_ERROR "OpenGL is required for building." ) +endif( NOT OPENGL_FOUND ) +if( NOT OPENGL_GLU_FOUND ) + message( FATAL_ERROR "OpenGL GLU is required for building." ) +endif( NOT OPENGL_GLU_FOUND ) + +set( ZDOOM_LIBS ${ZDOOM_LIBS} ${OPENGL_LIBRARIES} ) +include_directories( ${OPENGL_INCLUDE_DIR} ) + # Decide on the name of the FMOD library we want to use. if( NOT FMOD_LIB_NAME AND MSVC ) @@ -528,6 +545,7 @@ if( WIN32 ) win32/i_movie.cpp win32/i_system.cpp win32/st_start.cpp + win32/win32gliface.cpp win32/win32video.cpp ) if( CMAKE_COMPILER_IS_GNUCXX ) # CMake is not set up to compile and link rc files with GCC. :( @@ -549,6 +567,7 @@ else( WIN32 ) sdl/i_main.cpp sdl/i_movie.cpp sdl/i_system.cpp + sdl/sdlglvideo.cpp sdl/sdlvideo.cpp sdl/st_start.cpp ) if( APPLE ) @@ -841,6 +860,57 @@ add_executable( zdoom WIN32 menu/playermenu.cpp menu/readthis.cpp menu/videomenu.cpp + gl/data/gl_sections.cpp + gl/data/gl_data.cpp + gl/data/gl_portaldata.cpp + gl/data/gl_setup.cpp + gl/data/gl_vertexbuffer.cpp + gl/dynlights/a_dynlight.cpp + gl/utility/gl_clock.cpp + gl/utility/gl_cycler.cpp + gl/utility/gl_geometric.cpp + gl/renderer/gl_renderer.cpp + gl/renderer/gl_renderstate.cpp + gl/renderer/gl_lightdata.cpp + gl/textures/gl_hwtexture.cpp + gl/textures/gl_texture.cpp + gl/textures/gl_material.cpp + gl/textures/gl_hirestex.cpp + gl/textures/gl_bitmap.cpp + gl/textures/gl_translate.cpp + gl/textures/gl_hqresize.cpp + gl/textures/gl_skyboxtexture.cpp + gl/scene/gl_bsp.cpp + gl/scene/gl_fakeflat.cpp + gl/scene/gl_clipper.cpp + gl/scene/gl_decal.cpp + gl/scene/gl_drawinfo.cpp + gl/scene/gl_flats.cpp + gl/scene/gl_walls.cpp + gl/scene/gl_sprite.cpp + gl/scene/gl_skydome.cpp + gl/scene/gl_renderhacks.cpp + gl/scene/gl_weapon.cpp + gl/scene/gl_scene.cpp + gl/scene/gl_sky.cpp + gl/scene/gl_portal.cpp + gl/scene/gl_walls_draw.cpp + gl/scene/gl_vertex.cpp + gl/scene/gl_spritelight.cpp + gl/dynlights/gl_dynlight.cpp + gl/dynlights/gl_glow.cpp + gl/dynlights/gl_dynlight1.cpp + gl/dynlights/gl_lightbuffer.cpp + gl/shaders/gl_shader.cpp + gl/shaders/gl_texshader.cpp + gl/system/gl_interface.cpp + gl/system/gl_framebuffer.cpp + gl/system/gl_menu.cpp + gl/system/gl_wipe.cpp + gl/models/gl_models_md3.cpp + gl/models/gl_models_md2.cpp + gl/models/gl_models.cpp + gl/models/gl_voxels.cpp oplsynth/fmopl.cpp oplsynth/mlopl.cpp oplsynth/mlopl_io.cpp diff --git a/src/actor.h b/src/actor.h index ab04b176d..6571b3f44 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1013,6 +1013,14 @@ public: } bool HasSpecialDeathStates () const; + + // begin of GZDoom specific additions + TArray > dynamiclights; + void * lightassociations; + bool hasmodel; + // end of GZDoom specific additions + + size_t PropagateMark(); }; class FActorIterator diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index 56b34ca0f..7012248f0 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -44,6 +44,7 @@ #include "r_data/colormaps.h" #ifdef _3DFLOORS +EXTERN_CVAR(Int, vid_renderer) //========================================================================== // @@ -200,7 +201,7 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag // kg3D - software renderer only hack // this is really required because of ceilingclip and floorclip - if(flags & FF_BOTHPLANES) + if((vid_renderer == 0) && (flags & FF_BOTHPLANES)) { P_Add3DFloor(sec, sec2, master, FF_EXISTS | FF_THISINSIDE | FF_RENDERPLANES | FF_NOSHADE | FF_SEETHROUGH | FF_SHOOTTHROUGH | (flags & (FF_INVERTSECTOR | FF_TRANSLUCENT | FF_ADDITIVETRANS)), alpha); diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index a045c5098..069c9bac6 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -389,6 +389,9 @@ void P_SerializeWorld (FArchive &arc) << desaturate; sec->ColorMap = GetSpecialLights (color, fade, desaturate); } + // begin of GZDoom additions + arc << sec->reflect[sector_t::ceiling] << sec->reflect[sector_t::floor]; + // end of GZDoom additions } // do lines diff --git a/src/r_defs.h b/src/r_defs.h index c2f3e5b34..c7cdd8a3c 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -35,6 +35,9 @@ // to handle sound origins in sectors. // SECTORS do store MObjs anyway. #include "actor.h" +struct FLightNode; +struct FGLSection; +struct seg_t; #include "dthinker.h" @@ -81,15 +84,43 @@ struct vertex_t { fixed_t x, y; + float fx, fy; // Floating point coordinates of this vertex (excluding polyoblect translation!) + angle_t viewangle; // precalculated angle for clipping + int angletime; // recalculation time for view angle + bool dirty; // something has changed and needs to be recalculated + int numheights; + int numsectors; + sector_t ** sectors; + float * heightlist; + + vertex_t() + { + x = y = 0; + fx = fy = 0; + angletime = 0; + viewangle = 0; + dirty = true; + numheights = numsectors = 0; + sectors = NULL; + heightlist = NULL; + } + bool operator== (const vertex_t &other) { return x == other.x && y == other.y; } + bool operator!= (const vertex_t &other) + { + return x != other.x || y != other.y; + } + void clear() { x = y = 0; } + + angle_t GetClipAngle(); }; // Forward of LineDefs, for Sectors. @@ -319,6 +350,12 @@ FArchive &operator<< (FArchive &arc, secplane_t &plane); #include "p_3dfloors.h" +struct subsector_t; +struct sector_t; +struct side_t; +extern bool gl_plane_reflection_i; +struct FPortal; + // Ceiling/floor flags enum { @@ -723,6 +760,41 @@ struct sector_t int sectornum; // for comparing sector copies extsector_t * e; // This stores data that requires construction/destruction. Such data must not be copied by R_FakeFlat. + + // GL only stuff starts here + float reflect[2]; + + int dirtyframe[3]; // last frame this sector was marked dirty + bool dirty; // marked for recalculation + bool transdoor; // For transparent door hacks + fixed_t transdoorheight; // for transparent door hacks + int subsectorcount; // list of subsectors + subsector_t ** subsectors; + FPortal * portals[2]; // floor and ceiling portals + + enum + { + vbo_fakefloor = floor+2, + vbo_fakeceiling = ceiling+2, + }; + + int vboindex[4]; // VBO indices of the 4 planes this sector uses during rendering + fixed_t vboheight[2]; // Last calculated height for the 2 planes of this actual sector + int vbocount[2]; // Total count of vertices belonging to this sector's planes +#ifdef IBO_TEST + int iboindex[4]; // VBO indices of the 4 planes this sector uses during rendering + int ibocount; +#endif + + float GetReflect(int pos) { return gl_plane_reflection_i? reflect[pos] : 0; } + bool VBOHeightcheck(int pos) const { return vboheight[pos] == GetPlaneTexZ(pos); } + + enum + { + INVALIDATE_PLANES = 1, + INVALIDATE_OTHER = 2 + }; + }; FArchive &operator<< (FArchive &arc, sector_t::splane &p); @@ -877,6 +949,13 @@ struct side_t vertex_t *V1() const; vertex_t *V2() const; + + //For GL + FLightNode * lighthead[2]; // all blended lights that may affect this wall + + seg_t **segs; // all segs belonging to this sidedef in ascending order. Used for precise rendering + int numsegs; + }; FArchive &operator<< (FArchive &arc, side_t::part &p); @@ -957,6 +1036,11 @@ struct seg_t // Sector references. Could be retrieved from linedef, too. sector_t* frontsector; sector_t* backsector; // NULL for one-sided lines + + seg_t* PartnerSeg; + subsector_t* Subsector; + + float sidefrac; // relative position of seg's ending vertex on owning sidedef }; struct glsegextra_t @@ -965,6 +1049,9 @@ struct glsegextra_t subsector_t *Subsector; }; +extern seg_t *segs; + + // // A SubSector. // References a Sector. @@ -979,6 +1066,12 @@ enum SSECF_POLYORG = 4, }; +struct FPortalCoverage +{ + DWORD * subsectors; + int sscount; +}; + struct subsector_t { sector_t *sector; @@ -990,6 +1083,13 @@ struct subsector_t int flags; void BuildPolyBSP(); + // subsector related GL data + FLightNode * lighthead[2]; // Light nodes (blended and additive) + int validcount; + short mapsection; + char hacked; // 1: is part of a render hack + // 2: has one-sided walls + FPortalCoverage portalcoverage[2]; }; diff --git a/src/version.h b/src/version.h index fa8a1d937..8f3c8e8a0 100644 --- a/src/version.h +++ b/src/version.h @@ -41,12 +41,12 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "2.8pre" +#define VERSIONSTR "1.9pre" // The version as seen in the Windows resource -#define RC_FILEVERSION 2,7,9999,0 -#define RC_PRODUCTVERSION 2,7,9999,0 -#define RC_PRODUCTVERSION2 "2.8pre" +#define RC_FILEVERSION 1,8,9999,0 +#define RC_PRODUCTVERSION 1,8,9999,0 +#define RC_PRODUCTVERSION2 "1.9pre" // Version identifier for network games. // Bump it every time you do a release unless you're certain you @@ -82,21 +82,23 @@ const char *GetVersionString(); #define SAVEVERSTRINGIFY(x) #x #define SAVESIG "ZDOOMSAVE" SAVEVERSTRINGIFY(SAVEVER) +#define DYNLIGHT + // This is so that derivates can use the same savegame versions without worrying about engine compatibility -#define GAMESIG "ZDOOM" -#define BASEWAD "zdoom.pk3" +#define GAMESIG "GZDOOM" +#define BASEWAD "gzdoom.pk3" // More stuff that needs to be different for derivatives. -#define GAMENAME "ZDoom" -#define FORUM_URL "http://forum.zdoom.org" -#define BUGS_FORUM_URL "http://forum.zdoom.org/index.php?c=3" +#define GAMENAME "GZDoom" +#define FORUM_URL "http://forum.drdteam.org" +#define BUGS_FORUM_URL "http://forum.drdteam.org/viewforum.php?f=24" #ifdef unix -#define GAME_DIR ".config/zdoom" +#define GAME_DIR ".config/gzdoom" #elif defined(__APPLE__) #define GAME_DIR GAMENAME #else -#define CDROM_DIR "C:\\ZDOOMDAT" +#define CDROM_DIR "C:\\GZDOOMDAT" #endif From e00847f64b49fb58a822e682d7ed130ef93cb531 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 23 Jun 2013 11:13:01 +0200 Subject: [PATCH 0006/1509] - GZDoom solution file - missing GL resources for gzdoom.pk3. --- gzdoom.sln | 177 ++++++++++++ wadsrc/static/glstuff/gllight.png | Bin 0 -> 13073 bytes wadsrc/static/glstuff/glpart.png | Bin 0 -> 13343 bytes wadsrc/static/glstuff/glpart2.png | Bin 0 -> 358 bytes wadsrc/static/glstuff/mirror.png | Bin 0 -> 26089 bytes wadsrc/static/shaders/glsl/fogboundary.fp | 36 +++ wadsrc/static/shaders/glsl/func_brightmap.fp | 9 + wadsrc/static/shaders/glsl/func_normal.fp | 7 + wadsrc/static/shaders/glsl/func_notexture.fp | 6 + wadsrc/static/shaders/glsl/func_warp1.fp | 17 ++ wadsrc/static/shaders/glsl/func_warp2.fp | 18 ++ wadsrc/static/shaders/glsl/func_wavex.fp | 13 + wadsrc/static/shaders/glsl/fuzz_jagged.fp | 25 ++ wadsrc/static/shaders/glsl/fuzz_noise.fp | 21 ++ wadsrc/static/shaders/glsl/fuzz_smooth.fp | 19 ++ .../static/shaders/glsl/fuzz_smoothnoise.fp | 20 ++ .../shaders/glsl/fuzz_smoothtranslucent.fp | 19 ++ wadsrc/static/shaders/glsl/fuzz_standard.fp | 22 ++ wadsrc/static/shaders/glsl/fuzz_swirly.fp | 19 ++ wadsrc/static/shaders/glsl/main.fp | 262 ++++++++++++++++++ wadsrc/static/shaders/glsl/main.vp | 75 +++++ wadsrc/static/shaders/glsl/main_colormap.fp | 46 +++ 22 files changed, 811 insertions(+) create mode 100644 gzdoom.sln create mode 100644 wadsrc/static/glstuff/gllight.png create mode 100644 wadsrc/static/glstuff/glpart.png create mode 100644 wadsrc/static/glstuff/glpart2.png create mode 100644 wadsrc/static/glstuff/mirror.png create mode 100644 wadsrc/static/shaders/glsl/fogboundary.fp create mode 100644 wadsrc/static/shaders/glsl/func_brightmap.fp create mode 100644 wadsrc/static/shaders/glsl/func_normal.fp create mode 100644 wadsrc/static/shaders/glsl/func_notexture.fp create mode 100644 wadsrc/static/shaders/glsl/func_warp1.fp create mode 100644 wadsrc/static/shaders/glsl/func_warp2.fp create mode 100644 wadsrc/static/shaders/glsl/func_wavex.fp create mode 100644 wadsrc/static/shaders/glsl/fuzz_jagged.fp create mode 100644 wadsrc/static/shaders/glsl/fuzz_noise.fp create mode 100644 wadsrc/static/shaders/glsl/fuzz_smooth.fp create mode 100644 wadsrc/static/shaders/glsl/fuzz_smoothnoise.fp create mode 100644 wadsrc/static/shaders/glsl/fuzz_smoothtranslucent.fp create mode 100644 wadsrc/static/shaders/glsl/fuzz_standard.fp create mode 100644 wadsrc/static/shaders/glsl/fuzz_swirly.fp create mode 100644 wadsrc/static/shaders/glsl/main.fp create mode 100644 wadsrc/static/shaders/glsl/main.vp create mode 100644 wadsrc/static/shaders/glsl/main_colormap.fp diff --git a/gzdoom.sln b/gzdoom.sln new file mode 100644 index 000000000..16d1acc3d --- /dev/null +++ b/gzdoom.sln @@ -0,0 +1,177 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gzdoom", "gzdoom.vcproj", "{8049475B-5C87-46F9-9358-635218A4EF18}" + ProjectSection(ProjectDependencies) = postProject + {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96} = {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96} + {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} + {6077B7D6-349F-4077-B552-3BC302EF5859} = {6077B7D6-349F-4077-B552-3BC302EF5859} + {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E} = {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E} + {0F80ACBF-460E-44F0-B28E-B3272D1774A7} = {0F80ACBF-460E-44F0-B28E-B3272D1774A7} + {DA47396F-60C1-4BDE-A977-7F7DE461CF77} = {DA47396F-60C1-4BDE-A977-7F7DE461CF77} + {1D179D4B-F008-431B-8C72-111F8372584F} = {1D179D4B-F008-431B-8C72-111F8372584F} + {B68E0ABF-B627-48A3-A92F-D8F827A75054} = {B68E0ABF-B627-48A3-A92F-D8F827A75054} + {8997289F-10BF-4678-8BAA-3BB509C84953} = {8997289F-10BF-4678-8BAA-3BB509C84953} + {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466} = {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466} + {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4} = {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4} + {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F} = {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib\zlib.vcproj", "{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lemon", "tools\lemon\lemon.vcproj", "{0F80ACBF-460E-44F0-B28E-B3272D1774A7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "re2c", "tools\re2c\re2c.vcproj", "{667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wadsrc", "wadsrc\wadsrc.vcproj", "{1D179D4B-F008-431B-8C72-111F8372584F}" + ProjectSection(ProjectDependencies) = postProject + {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} = {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "updaterevision", "tools\updaterevision\updaterevision.vcproj", "{6077B7D6-349F-4077-B552-3BC302EF5859}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jpeg-6b", "jpeg-6b\jpeg-6b.vcproj", "{AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fixrtext", "tools\fixrtext\fixrtext.vcproj", "{DA47396F-60C1-4BDE-A977-7F7DE461CF77}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dumb_static", "dumb\vc6\dumb_static\dumb_static.vcproj", "{8997289F-10BF-4678-8BAA-3BB509C84953}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gdtoa", "gdtoa\gdtoa.vcproj", "{B68E0ABF-B627-48A3-A92F-D8F827A75054}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zipdir", "tools\zipdir\zipdir.vcproj", "{24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}" + ProjectSection(ProjectDependencies) = postProject + {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4} = {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4} + {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} + {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F} = {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lzmalib", "lzma\lzmalib.vcproj", "{6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bzip2", "bzip2\bzip2.vcproj", "{A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "game-music-emu", "game-music-emu\game-music-emu.vcproj", "{9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8049475B-5C87-46F9-9358-635218A4EF18}.Debug|Win32.ActiveCfg = Debug|Win32 + {8049475B-5C87-46F9-9358-635218A4EF18}.Debug|Win32.Build.0 = Debug|Win32 + {8049475B-5C87-46F9-9358-635218A4EF18}.Debug|x64.ActiveCfg = Debug|x64 + {8049475B-5C87-46F9-9358-635218A4EF18}.Debug|x64.Build.0 = Debug|x64 + {8049475B-5C87-46F9-9358-635218A4EF18}.Release|Win32.ActiveCfg = Release|Win32 + {8049475B-5C87-46F9-9358-635218A4EF18}.Release|Win32.Build.0 = Release|Win32 + {8049475B-5C87-46F9-9358-635218A4EF18}.Release|x64.ActiveCfg = Release|x64 + {8049475B-5C87-46F9-9358-635218A4EF18}.Release|x64.Build.0 = Release|x64 + {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Debug|Win32.ActiveCfg = Debug|Win32 + {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Debug|Win32.Build.0 = Debug|Win32 + {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Debug|x64.ActiveCfg = Debug|x64 + {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Debug|x64.Build.0 = Debug|x64 + {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Release|Win32.ActiveCfg = Release|Win32 + {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Release|Win32.Build.0 = Release|Win32 + {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Release|x64.ActiveCfg = Release|x64 + {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Release|x64.Build.0 = Release|x64 + {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Debug|Win32.ActiveCfg = Debug|Win32 + {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Debug|Win32.Build.0 = Debug|Win32 + {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Debug|x64.ActiveCfg = Release|Win32 + {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Debug|x64.Build.0 = Release|Win32 + {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Release|Win32.ActiveCfg = Release|Win32 + {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Release|Win32.Build.0 = Release|Win32 + {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Release|x64.ActiveCfg = Release|Win32 + {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Release|x64.Build.0 = Release|Win32 + {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Debug|Win32.ActiveCfg = Debug|Win32 + {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Debug|Win32.Build.0 = Debug|Win32 + {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Debug|x64.ActiveCfg = Release|Win32 + {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Debug|x64.Build.0 = Release|Win32 + {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Release|Win32.ActiveCfg = Release|Win32 + {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Release|Win32.Build.0 = Release|Win32 + {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Release|x64.ActiveCfg = Release|Win32 + {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Release|x64.Build.0 = Release|Win32 + {1D179D4B-F008-431B-8C72-111F8372584F}.Debug|Win32.ActiveCfg = Debug|Win32 + {1D179D4B-F008-431B-8C72-111F8372584F}.Debug|Win32.Build.0 = Debug|Win32 + {1D179D4B-F008-431B-8C72-111F8372584F}.Debug|x64.ActiveCfg = Release|Win32 + {1D179D4B-F008-431B-8C72-111F8372584F}.Debug|x64.Build.0 = Release|Win32 + {1D179D4B-F008-431B-8C72-111F8372584F}.Release|Win32.ActiveCfg = Release|Win32 + {1D179D4B-F008-431B-8C72-111F8372584F}.Release|Win32.Build.0 = Release|Win32 + {1D179D4B-F008-431B-8C72-111F8372584F}.Release|x64.ActiveCfg = Release|Win32 + {1D179D4B-F008-431B-8C72-111F8372584F}.Release|x64.Build.0 = Release|Win32 + {6077B7D6-349F-4077-B552-3BC302EF5859}.Debug|Win32.ActiveCfg = Debug|Win32 + {6077B7D6-349F-4077-B552-3BC302EF5859}.Debug|Win32.Build.0 = Debug|Win32 + {6077B7D6-349F-4077-B552-3BC302EF5859}.Debug|x64.ActiveCfg = Debug|x64 + {6077B7D6-349F-4077-B552-3BC302EF5859}.Debug|x64.Build.0 = Debug|x64 + {6077B7D6-349F-4077-B552-3BC302EF5859}.Release|Win32.ActiveCfg = Release|Win32 + {6077B7D6-349F-4077-B552-3BC302EF5859}.Release|Win32.Build.0 = Release|Win32 + {6077B7D6-349F-4077-B552-3BC302EF5859}.Release|x64.ActiveCfg = Release|x64 + {6077B7D6-349F-4077-B552-3BC302EF5859}.Release|x64.Build.0 = Release|x64 + {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Debug|Win32.ActiveCfg = Debug|Win32 + {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Debug|Win32.Build.0 = Debug|Win32 + {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Debug|x64.ActiveCfg = Debug|x64 + {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Debug|x64.Build.0 = Debug|x64 + {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Release|Win32.ActiveCfg = Release|Win32 + {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Release|Win32.Build.0 = Release|Win32 + {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Release|x64.ActiveCfg = Release|x64 + {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Release|x64.Build.0 = Release|x64 + {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Debug|Win32.Build.0 = Debug|Win32 + {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Debug|x64.ActiveCfg = Debug|Win32 + {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Debug|x64.Build.0 = Debug|Win32 + {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Release|Win32.ActiveCfg = Release|Win32 + {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Release|Win32.Build.0 = Release|Win32 + {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Release|x64.ActiveCfg = Release|Win32 + {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Release|x64.Build.0 = Release|Win32 + {8997289F-10BF-4678-8BAA-3BB509C84953}.Debug|Win32.ActiveCfg = Debug|Win32 + {8997289F-10BF-4678-8BAA-3BB509C84953}.Debug|Win32.Build.0 = Debug|Win32 + {8997289F-10BF-4678-8BAA-3BB509C84953}.Debug|x64.ActiveCfg = Debug|x64 + {8997289F-10BF-4678-8BAA-3BB509C84953}.Debug|x64.Build.0 = Debug|x64 + {8997289F-10BF-4678-8BAA-3BB509C84953}.Release|Win32.ActiveCfg = Release|Win32 + {8997289F-10BF-4678-8BAA-3BB509C84953}.Release|Win32.Build.0 = Release|Win32 + {8997289F-10BF-4678-8BAA-3BB509C84953}.Release|x64.ActiveCfg = Release|x64 + {8997289F-10BF-4678-8BAA-3BB509C84953}.Release|x64.Build.0 = Release|x64 + {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Debug|Win32.ActiveCfg = Debug|Win32 + {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Debug|Win32.Build.0 = Debug|Win32 + {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Debug|x64.ActiveCfg = Debug|x64 + {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Debug|x64.Build.0 = Debug|x64 + {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Release|Win32.ActiveCfg = Release|Win32 + {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Release|Win32.Build.0 = Release|Win32 + {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Release|x64.ActiveCfg = Release|x64 + {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Release|x64.Build.0 = Release|x64 + {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Debug|Win32.ActiveCfg = Debug|Win32 + {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Debug|Win32.Build.0 = Debug|Win32 + {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Debug|x64.ActiveCfg = Debug|x64 + {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Debug|x64.Build.0 = Debug|x64 + {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Release|Win32.ActiveCfg = Release|Win32 + {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Release|Win32.Build.0 = Release|Win32 + {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Release|x64.ActiveCfg = Release|x64 + {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Release|x64.Build.0 = Release|x64 + {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Debug|Win32.ActiveCfg = Debug|Win32 + {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Debug|Win32.Build.0 = Debug|Win32 + {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Debug|x64.ActiveCfg = Debug|x64 + {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Debug|x64.Build.0 = Debug|x64 + {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Release|Win32.ActiveCfg = Release|Win32 + {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Release|Win32.Build.0 = Release|Win32 + {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Release|x64.ActiveCfg = Release|x64 + {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Release|x64.Build.0 = Release|x64 + {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Debug|Win32.ActiveCfg = Debug|Win32 + {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Debug|Win32.Build.0 = Debug|Win32 + {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Debug|x64.ActiveCfg = Debug|x64 + {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Debug|x64.Build.0 = Debug|x64 + {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|Win32.ActiveCfg = Release|Win32 + {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|Win32.Build.0 = Release|Win32 + {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|x64.ActiveCfg = Release|x64 + {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|x64.Build.0 = Release|x64 + {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|Win32.ActiveCfg = Release|Win32 + {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|Win32.Build.0 = Release|Win32 + {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|x64.ActiveCfg = Release|x64 + {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|x64.Build.0 = Release|x64 + {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Release|Win32.ActiveCfg = Release|Win32 + {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Release|Win32.Build.0 = Release|Win32 + {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Release|x64.ActiveCfg = Release|x64 + {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/wadsrc/static/glstuff/gllight.png b/wadsrc/static/glstuff/gllight.png new file mode 100644 index 0000000000000000000000000000000000000000..a3a296b9f856f4654aae244e3400a4f33fd95902 GIT binary patch literal 13073 zcmeAS@N?(olHy`uVBq!ia0y~yU}OMc4h9AWhDyoryBHXZZg{#lhE&{o8v8P7uH~wf zpZETEMnC!|AkuoS@R3THe(~kWN6KvO3OebyGV1+5U;o4YqkL#+sOi*Su5W65ztl%F zloo^rpFJPqb3}yc!hcW3IiF|Fidk+hbn54#2haa^F`WD8bLCv-=WtQs)t|LZ8tMeE z{@=rJZtLn*ow9}zdl@b3m9nbrwoGCbae0$}f#v@*@%*3ObMKvdI$K6CWA5(`$55XT z*Q4h)PyF@PUcJF)YNYJ85XPXu)4|hg4SdrtoOk>n^DmjnW3HK1*4=%Zw66GD=QDQ& zMJcHEyf5ber~7`N|GKoltyWt$TKfp!WK+0*?B^rFwwn3LAM!2tPYH^i=@`T)Y~0-Q ziT`Eh6x9_69@w;03I5Mxlu0$;`|qUjG>#xW)z-=%iKfvitE9fkPMlQ#^5xbmw*I*l zf5Y-7$kj!%H_Cj-7bxOi`A1f@b|udr@3(d(H(z}Fyz28cZ^chp$^97ve z-JJTxvGA{e*H0(q=LtJX-fj@!3pCw#LhhHi?EIMhQ`@fRulvJV%5kjCQfFi64}&Cj z+f3s)=NsZH56$ffs9s#MplbHfGeyhFqE5~B~%z4`O^^a2Coh!9I>iSm4ZORQT1rhOwf-V1onO0o) zTy7p*Ty2@36}dK5K*C=_h3l_Bh$vF z6DPPj=9UZ8Z)SL~^x^Z@?f2!k`sxI~sH%Vcfsun-(%|w;o$K%CD$7p(Q_k72rf}!( zkXm{7^5Ax}9jn4?9_SiA{t?mZ*gUOa#;O@9f1fDiv`)Md{3Evi#s2iaukKVye%+I% zoE#s&z~W_%XS%`*9yNg)6;8RV`@dVI=D9DZpUn2+=k9s?_sv-OY^68nmZ`U|p1M;h zeX_VLzuoW;vn{g=^KtPhY%|2NPRy9NB>YbvV@hZ9r+Gc;w*QysK7M_)x^92@nu34l z@3|F5HMaTh&Z`i)|Kiii8PjH*%=b7@|M%x?&PA0m3A0U3b6;2PO=k7-G+8?3m{Y%< zW%|V_463v8SSP4t&2wco^y3Y2a;?8B|6_f1{Z;G7g~fAjM@tBt+W5zA?Y?5a92xof zIUW}J(*jLhp7Q83R$ly`8AZd^{p6H}ZaXFeB`UlUXx^2$$8rX0?uv zCI9{h<$d60+93GflBr?xqaS~TF7Z7x-=*EGa)S5c%5Wc^BN7u0vzD@5)t|FtmHVZc zjVJU|-RFxlEVZ3^cnZfJ|G5(je%gQKX}KC*i;aaa@>_hjA~P zVCSkuN5i=pw(2aY+`y36C;mW`H~q(BWow5A3sQww_?7%qw|cegmgy!=&MizAgf(P4 z;yF0}eExR-)%v-1y*e|Z=kNcM5ZP$-*>9(C%>GxcZ2@K(2M&b>*d1GXm^r{;#S|2%9LMtufAjzN5F@L3Tk<5M`Pu*TM8nWe{Owp z!Cvy;%2l1$@9$c$zSybde?iNMR)(Jz50}K62(8vQ-t*T!!gSHGQ}GAooey8SBv8dT z-;{a2kVBI3v;*z0d2&v2p3%ReTv$}Mg59i-f&Ii+CpQK^s~js4hKu%d_hqwwEHz_T zuzZ^8`}B8NaqLUk6T%uBC$2o8tnS*_{l>u~^1HuK#4LpeA%?313V+_Z^&!*x!TeAE zWi}qzS}O74_&sY|j{T1uPG@i$6@BFnPBV)Ei~sn~ikB>?n{_>J(WjRY2kevo z?M`y^G5YHXgNg@nJO=1827rM+B za4@d6`t$V0^E-QI-)t`468q-B!Mk!tc$K3T?b=y7bB9pU59fyx5ldD&Gq?%z&3)f( zf1M#jYxjoR7SpZWt^P_qVA`aYlJ@P1`SLAu-ZU(eY`mId;}OK(;ieTLAv0}#yzK$Q zzg&zr9-25Z|LLoln={Y+Q~bt$?YZAKhOiiyJMqt5<;5PZT`Q2Q5Ypke`quIEggv3k z{sQ$%4V~57#RKFS^;{+#W6+qn?AGk+)&CApX$+K_B{tcsS%$OV#rjo=rT;EyHYRh{ z&yxDZzg}LTf$3V))$e|+qW+EVM9t%$e>W0+X?rrRY+-@g*^>)>EJ8R0mjy&{2~1wd zvXt%PZz%(bxX>4i*dJ{8Z_yWQb|ZdC$x4?*8P9WFyR<|*&RD$+f3?b>t1WrKLMf?P z@!cVl?+Y`$nSal{-m~E${}$bvNSpPat2`4E+zV!@Ygql4eEG$(J5;ZXZ*d6Eq;1Sr z&E<|&GWKCi|2dhK9eGn}TfJ)U`I-+M3-#`u_5IsuuuP%D{lF)ivVM;vbN!0Ue@q!C56=T>q!=JNxzb zIVLl#AM{L8v|jU|ztga#;c2|tBn!!++fKEHeDj4EF8$|YsGU{2uBE)tqW^tC-@h5N z?LRa=VU^VPnGpE?&4U?JKeGh!1qKStUuhC+{42Od=;Pyr1NO%nIuCrTD%vmW#C3AM zNp|qtx%Zro_uOM`I=FD5QDtMZy6%~90p5-m-Y2A+9cF4y{5Ok%Yl61jeC;jwazpB0 z9y)d5_T&DWk5j*C%lVi#Y&2=%^$~8o7r9LF)XxBOp~6kvJ{loz{;m#!c6@Aq*yS3M z?A?R-A6SRZRFeJ^@Lm10{rBZ}?p1PC{$t}!>saZjvT&O6g%%-kQSaw@G0d6u^0j4x z7dzyQy#5}RkTBq=tdc*u^F@$oE;ubB4N? zt*s@wEc+EayZGNW)X!lSn7wp;6g!98f%3RrvzG~1oD#QMqoC>{@>QgoqwT#0%ey!! zUa!82)`L(AFcw|t%4(>(j&&56P_9)DNXOu5h= zypm%sYp>YpvjVGgEUeV8Rh(>oWq3e5BVf*tOkM>x6~X;AYz~|c1*}iq{cE|&BHfkk6<;tuAYc+^cV@8J4mI(6Ti z|C4up*dV#!LVP=K;NnvjFC5D|d!$|pFtfh-&-rK3G*O6NSNC*%Onb>~GT+JW!M|5`&U-R*7`a}FxhI;twc@*(PQ0m-p@L3`Xf@~i z#ZF1zS^||i&r3R9z4$$XEg=2lZE2=OH~v@p-TFLdvHet$O?N+kD|d@sZ2T=WH*ZIQ zer~6N5f8_w{E5#+`&gZvoK?@gRE~Sd_%Z89&#j%aSM<*JAHn<$SJZep z6%Tyr=_>JfX16$gv4)4{mrV5!g5pZ|r2d+pyKq0PF_gb`qY__--7A+Kykpfb+$S}O58~nux&A3fe#zQsytRM!`D6IM?0-Dz3#U4(zH{De>UW1x zkSDGqi$CP0*NF|8lI+^8`*(cxl?%n3Z7S;OczU}@;zuZ<_$ z=dI(_Bq3>uFWOhWTUs?3EjW9iQ<|x}s_K?Q7jw|_{NRAF{XgYyt&+c`Ht+EQg-V%> z1eZqntOGCoH#oL`U(%$>T5^oo{3IycNHzbA#)b|FQoi4koADGh}8bZ#w3))lfxc z3;S`8Z=EfC$`@Yd-rOJCQL(yqHB()`*`)PM0aE`McU=1|xg`8Wv2Ezbnw%$fKewt) z4ijhKKXh^RIdvudvkStKxAY`A|XnN3Z`Ag|nNQ>ZJ6UJdBL|9SV{@?FwJ-v+#lF zx3G7=C6pT8sVK+U--+IKP~&{_igN+a4hd<#k`g%>#&FZ$WsXOLAp0S%Lvjj6@9Jms ztDJCmzoT#{PSIc~BY&2XsLH|oo_%dMKY5ndI89)(ZE8C{)tVzz=|Iu4`{CX#3yw6r zs#m%yhx9@iy}*1t~?XTdFyeqyN2nYW~1FXkOX@ zEyjO2EUzxUpCJ49+2T|I5s@j0HMLB4j~)nFz+~?xoFTQlo!jv#JhW$4 zPwLUHZtQvy_)w{QV;}g1VD`S=^F5moSrc!6KVG4Zr73dUkXs!_~j? zla6N0bUHk_B&j@uZ|0qzXW_G28NTrsCq9`fcx~Rg;C*WY8YXbu{QF5#sd6!+%`?Fz z5wn;sgw9=Zz*h8`-CWLsO%0hDO&2SU_0&HVAmox79ck}Rf)}PHC z0yhn14qEdXNU<)z@@lEW|Bn`{o~8c_VZ5P{ZlkcPugY(coXe~0|JEyMKRZ^jthsb{ zK<55aXFmO|TF-y}ZGI=mS{=_VNy$PC1sug8Zqgj#`yxWTd{xF>Mpug6-DH7SF@t&qoy+&bRvQ z88M~XA?wcl*4N9Y_a8iXFqL2A-!lUi-z(o)_Dd}}p7SQ^{l}*hYAsuWTD+N6c1L8| z2+aC-_cou2`LT=4g^I3aYR5YHnl>A3PY>Ap(!b+bZS?*}uH|=&D;&8Pmaetu+rRWP z)7t!WMu}tf&F_5nHn@oD$!<90*b`BBcIM(A{8!J)HC$3Zek0>uch;f$0{aNnU6RL_ zTHjZSc1lv_bx10>S2v-2$`1{`1(s$n@??3^dKgzm#jD!$3qSSdNn(DG1ATY&F` zjwM-NC%sP;4|!5oS|9S;?VETkQ^30S0eUmoTg?}QE9S7K$lup>eO<6x{$}yh~KgQ_o3z-B3H{SfRyy=Zu z|85TvXNGCDr_ToOxsa&TJj1q2{6ImV&8Z{5BNzTt}BZ6@W;X^?SGYqRDDw$fJt zfol3@TOPdF%cFc@VnL6(!R?TDYRk(0KfA*C<;ITsCcYOd?>D@cV45JK1>5%>t$CUj0X`(l@{Mc8?WP z8-xyNGMwJ&>l5LweL3N~h2#8Ct}`#(SHI?NJ{aG2H}G-$wzrSvI3iBZi1BdgJjke^ zS6snp)A%#g^JIt1n=8vQls%mPT=;V8@i`6^hR)SoG8hF+T*{9SEMcQXFj)3BOb2!iW%a?dI%=2x^T5=@E@At%uAI~Z#rZN@9F#F{jU8~)vlcuDA8U*oC&xf(q8+NX$T zWSyJS@_vd~qS`af`g0Nq7ydp`efG4&fkP-EfJen)62snKGx<3;e7Ldly}+Sm`nrTf)x3raIQd$K!H&N@{>a9zts=^2p=)0_(qS~_K{ zzoL9&)AxJTr~7L4YP?-NqffX8?0dl)Zg4R`qXUuI`z5u4Th(AmHU@J$xcpvugf6b z*v~m<_aU}J&5OT7L~CB<+l@1W!N3rFM>{LxyNTs*az-&)K@Ez8r6D1jX7Czva)OC+Jz=}7^CWi5)t26_P^H-*C zKJAU2M?9wZTRpj|c5U`P8RzCKAqBzbhHhJY7bG{{V{z8JuI^=0>+An|wU$)RcxQ)n0?Z&jB#3md6kS(W6p&sY_`9=@2^O* zI8(uJFZkf!(x08@TDD)ZzO~${BzETS)y#YL|DI>@rBV0 zGtz0ct_8~)MWd>-6SU+Kt_!e#^dFzdDT1+l3UM#QT76i}Tuv6bZ~1&chom6ILCqtZ%#*2c{|zW37?X?qbJ);;a_uQRXMc_A^; z=%jq;ud5gDiRXMx5Oz{y>&m{beT>^dNkYcx+vF1#3dP2YFLv(a%QaHT2zjvAp<(&l z0@pJw>Hp8TCUR6e3$V7Hk)A$JU_rx?sizXBGQO`hV$^VGZBqBL5ZC`vwY1|n+lz<- z_s6>KsZ*rxTRXDFP57_AbIyXE%oX1yUgR-^Evvg2_HfrxTRiV^Np`~9K1asN^UBBL{UBvUvK)Z?IKj&|1{4-&hYFh`- zpL}J37+Ddo>l{rE&Wg_s_ArFSoc-$GwY0*{ZB-TT-lAKRF6{|>8K>^o)RT4i>Mu@v z`N=#I2kKUcglsg7ZrsvTeKcK1_35H4xz`jq~AQOwEE_J?bMEIz3p~k=TJluz{+KjDez{$AXyP|<#5`4e-g1N!H_+w!VAAAbDr zf}-t(4INX%_j?JS5(=xC5Ws17P+7w#pfxG+X|MPd=R?k-*}1ngmR{hqke#yPp6dD4 z3`L)Ur`CSiI@fu*E@jbQ-+z(QI%==dE=!iF3w>(2Sx;VGf7kB8 zio*;Y-}do3W;*n*Tj2Ts#RAWkBh{P2dMAWW-{>eB`tDn$Fvl`=hm&iC>a7_%1BFV| z8d;)JoF@D^-p#S-p2O`%t~o~4DK0s?4jP`g_$5_5N!)YmcI_3b(o6!EoqMvVYQMtc zsXUARI`2Gdt={}h-6}Wf=s|b3*K_Jv=hi*FJ%Nwio12SUpOafVMYU+OW0Azjo+L! z6W#}#SO*q%Guw(hQgVw6sNA5O&-Tv6ac9_rt-ltlDV)w`R*7Ord$WA`c!*DGHcyeJ>a!i@BY{~^XK1| zZ?7f(pK3Ln@^hE0L54=m8Mhk;mPmZ@N@<(jZr}OgR`q(5Hg3zLc1}^&x18)UE+;me z3)(up{-y0p@ASJf4n8sbrrC0O?_Son?}-|7tk1-parF3nIbnXlDLHk{EbR?VSx27o zGIq~5Vw&C1bR?^9$2nVlo8$b&qEmKvOkI|^GH$V5+z-Dhk=e%+ddzM-h}&Svrfd;= z&x7&z^DJ+PYENdC+4m1TlM2jc5aV3QS1{%H-TR#fSy?5|){F7(RM0=Wi~r_z(VrbCqVK`S|`tjzPncC;A)E~S_ z)wDYM`&!_~hYlU>`x*b7UAKWD!0-97CtE&$T0FIWt16FCvxu;;-UJ8D(*BU+9{vSu zqQ$#DHe2!$@UL06+ocW%QA#3>A5}U?lo?Z8J z85EjR1Y~sEvsF@Fo}Sa+dbwZb#gYBbf243;_FKa@^^$>(WW$M!xo172wC-3RaShI$ z=IY5*Rg;N2Rml*1isAN;Zn)+YH_mBh0`zm zrGy>Sb<{T`tzFE+J%MA6!*m~psp+*Do7p&~v$MLNYIP6!F3r7B+Uep=F|EzN)E#XD zT3F=*A{L)^GE$3a>3McPSfER^;$ipV`CGroWl!zy*{dCG;kG$j^Q2@~bsLAEn)ZX0 z-P2wlFjY|3O**$g&~zs6`D6#Ki1Y4jhGvN`Bsy)`T3DYt6#CSE+4%W+eD&ME;cwRT zs}-*36xN-hG&Sb#l8Sm2!TVwcOS-7dpxvz8BE;p{5x!^ccmbKH`lODzNnIk&~n19|&ibd@px@HGo$an{qHP%FH?!l5`mm}gnpe)h@tT20wlPn=eW zIdkmzl z;*~hIW`6x5$LzN!jt5N3+o<+tfz!)-v(w(5jZCsSR`+Smf4TOc_j?z)&71b&*6Xsf zj&|Ag&!iS~a)(*%$c*DNTEO?R;7{ny4?jbmeP2+U5IQkOegC7oHU}@iD42UILTg7# zj_rbdzXiX2h$`6mYkueVzE}Fp&5Uza-S)u67uBQh?K2;b8ZGJQ(`RC4`8=D)N=XmJWZ7h60O;YvypX4u(S=;um zb39YIpz?XIu-fjgAL`shMP`18YdFRp`XR-q*=TdC^qKg(3R3_4HYqzRKPz@vpzwXp zit0~u`<|{a^ga~x>!Rf=zJ!Q*^3Uo686q4Lx*WwGHE4Ct31Ns~G`X~Qw$|;%vDGK} zOC6*(D)?6X+a7l&eOB$NJMR|<8g+bQf6hKpi%Y7!O} z8BCGs<~4cs`2}m^Er|tg_0|4|*1ullHldZ}$NEVQQAdsz7Wt_3#2yek*K(hOq4tf$ zr^M?y+w)qVDs{x2wbv5={y+6!`3X@j_k~O*vdWzPyYDbC%`ahO7ER%OVYaDsqtYgm zUl+T2CHYU@C~XiA+Isi&+mE|mUvIO2c+JAB^DOTYM$Obe?lJe<-8C};Q#?K;v(y z|E!RR2>9P~)0d~|gM!!T<7NwL56-D_J)(cn@Xz94h6II=L9cz*+b@?Aw_ou5@YLC- zPK6gJhuqqKmE#3t)AcCs_UFGoyzA3?#v1!Xdb+rFM)}q$v+JvvQV!P~t)Kjmqq*|j zZ1;Obf`5GWs46+^{I_+tfW^IfHm22q9~pdW7UvXMd|uqVjGg;m##OQ7Oqs89zZ~v& zW#7ZZ{obzPiy_;77G2vWxp#p~6Wesc>~4pu9B^eg(8TQFo53ege*V+f_mTX+FK)9G zYl`J9FnzZs=kSRVuCM1p7nppXdd$v1WxMSa;w2ki@+Uqa-G=IDEce}eWgRJF!N6*9yjn`MS9qnL!vX^O3+QMh`;KpOE52N0S#b5|`$mSaNat5#J&$?= zFFPDzW&Lx71!kLf2D1wc|Y#`8y##UjacMh*a?mgdcGkqUCzN7V`PQq9(22Jg>Yx|DBe zKBtG@=ET+R6CE1P&iGJoTo?8@UY(&SRAtZd7fFKNry3@Ozlr!gnMq=?Lav_W&N6%V z@Be!e(=$Fi%C*o>_Mf$R!h`!y|0FB^PY%inJiIbh;Ks{avsWHkTpVSm%dqH&^s|4a zx796Vd%~wF>s$8<%=#{2lv5Y5xcwhit8*>F+TA!pX z+{7{^kn>fd{GNt>mIB=d%}L5UEbLuP(;%ED3J>2;+aZiio_f(@>k-Vqo>OZO9Y}l}V zzrLOCsYPp6eEIKw{C@<4?Vo);^LoFpzb^N9#@#wa+ed$*nj9i>+ikyF$9)VJVB5D- z>)Ni(RSg#wed(`KHFSF7%vrOBaq^qUEBbnGpZ=b|blQa5%3qeemwCNy@`s)756y4f zS-RQ!C7)_zEQ8h3^`&ym4vinToU@qwEC2s4hIN7)rpwwGHpG2?zi39jEYIZ!kGoD@ ze^cF~^?^;y!VuwpLYmWOuKx4&ci%*@ z72L0Gm~pJzHH(_@BOolHj2AE zf3VaenW;d%?&^=bZ}TTc9#p#TuDU4EKG}7%I|FZzV)CcoOb2dXll$=J+pp(h8moTx z>|FNd-*LuID>jQO?f5hGtX{Rj{hbo~(z>6#v-GyN{NF#H;Y0mg=?|xF2_6j16t7~B zJ6p`~FmlH|*QouoE^pS5NSbxJ%X7vnjTt3bfpxNq_LU6tH!zwXUpuj(L88yQ=i(!V zqtiFCG~M2wDU?@`uqR9F&?~Ko zICOfQ5T~Hg)5izSHZ1$HjQLo{?guB6r({g=GI5fLuB-cZo}*!stX>~$u}vj^iMhiC zuN^u~vit7IUF2y!e3!4?C6iTnzvhL-Z5u@Y{4n(U{haMVILm>@{`Nm4?>tdETe`Gy z-`(5w1_xcI+pe%H5SziX-*Kj`*hbSNK@pGFVc*iv{nupl2ydw5b=k|H*LjIeV&T^~ zC+md;O*f3UtkyR^sXsxV{VHRg(*wC+*Oh$VIycvPF-+&@NHaew%dwqTV)lh{{liZ( zD^m7meQGzE<9{td@Xp?s-*&o-1iZd^Kv^hWjp5AS)j!j3+16dTb@1l>n4eKK9Fp}G z2GM&ScowGY3ct)I{d@XR+p7{ACuLXcd%?NF&%#Ijyymep)17}gI{$fgRISoF*7CrU z&%GP_E&o;i_$qX6QtfU5w`mfo|IU1^k7D-QznrzaapCVq?}JgZ>b2~JuKYI^U-0cn z@V!aLPWcBLTVJn#_g5 zZ+bm06&SUxWN%S85W9Bk$7GfV=D7|hwlaCGw=;KY;NYGzqas24_5@CFkqU(Abn?5Z?QzKDVJmSl(yY)b$M44v%)0DNy3jfj;{DEB5*HfLm#*1o=LBG z{`~n_@5sQc8zxod|1w_n{$J^7wQqNr+G}1+w)YD7{ohJ4ZVTg_zw%eaVt)9CK6qNq zvfxt^=X!QQOO=V@`@$j)%)P*Q<*l~Ff!p`4Y6u3tF?{xKZ{*6L)646>{@K5V@nZ5t zrFEe@1e3KM&1lq1zVZF%?RVW8QpH>m=3FL%bC~KDK6<}_aev9b`xQ)vxeooi*4)?; zsNr=YLfouO;oU(Ig+uuQ*A;h!YIs;FOkv~i{Jr(_|2DQen;lB{tQ7M?RG(}%(=&ba zZ^ePY-!o;8aJ&;YF;%sf2_PykMyT( zOYmoRNs_33<-K|SH&d~P(ySM1PH2R7boLZqpIuTqN%OUd)I9a4#r^O19lGmSwQ#y} z2=mY0&;Q#PDqc@#TbOh!Cc>iCuc}GxXxoKt(|I>=yp#XXaNt{fhJg63vYHc3f7BRz zp2n{VkKLpAFhTOdz4N!K6;9mlx@;PCcUSzJiSJ~^|MK77T=)FPe$57LmKT35toGRM z2&($Y};s{;CS&x($+ImJACHe zHkZ1z!Ql5^xvBq{`5tWNdf=}aZmKRY%t}sS=+wEmzn>{EV3GV3ojbA%Zp{3~&-vh~?THsc3)lo_#?@b9 zJ=L4~{c%Rw67|4_|NEw$J3e3Le?P0hck3M|l8Vh9ypVa3^ipo(g~UBxXYTZex!igA zW&Yd)`=7nrDEc=`q~oN-Ja2pU@@aKtcg(e3Dc@hY=fD5?|EB&5pFUKbb(cNF;97Tl z&zT#^#&;atKE5fAk71s_JF&e!is2x$;?i@6wf=Q&C&t&i=`s=xbke+2Wf;sv#7;$BXBOCr@D+FrCU z5o_{TJNf;o*ZU(FOxU;ocCU6TI@uVo=&rVbroo}CfQNm-oj+c^{>8?t;Kjnr_Nqux zqxdl|$6MyQ*eQOmum59aTHyNV>qW83*nj(4qpYmWvzm%OJm~$=cDa5s!xKK1CBn)= z2i|qfG}tx!^wG>`N2lBWc`we8di=bjALol7Xz+hpt@~$xG{gT% b^8eXyONlr0HB~$X?RD{V^>bP0l+XkK3f!mG literal 0 HcmV?d00001 diff --git a/wadsrc/static/glstuff/glpart.png b/wadsrc/static/glstuff/glpart.png new file mode 100644 index 0000000000000000000000000000000000000000..ddb0aea8ea8a74843fa0709b41264552043bede0 GIT binary patch literal 13343 zcmeAS@N?(olHy`uVBq!ia0y~yU}ykg4mJh`hQoG=rx_R+SkfJR9T^xl_SO6joXo($ zppfhl9;uumf zC+Wxk|MrJ97VEig=TIqZ`$ zL$X`K$nBc-g}Q~DY#a+1%NeFBOW7vPTsVW3J*_nnAE=`meZZb=cVdi21#h*`&Q!E~MtT1f%h#2G*yYEb<&^I!7$w8FSIshC6-^c{+R^G7Kyi9Ng`69$oCNdXgl!)34oi z&y9MQC5Ma5bq-BbmK53P<*%adUax6vRLVFi_T>rtqv7oW1=F20wy(`+U zzJ0MXmd$<1Y9&`Q9iy!aBBVP?7et76eJ$8fI`K-D^H*hcp|Af}sIsj)(h%diK%FI` zlVP>kgle7*S&e#yOacwxi*_W+?>K?l9?*D*=fTn{T*N#v?IW{*!a`;v0+W#Go zWW`<{`!8rIZMi8?Fo*kSSwIf|Q9g?ewv(c)S4eJXX_})kL74f3?1oiLVXhCnIZnJ~ z{^F+ez22o)M}IMVRx2-BEsCG53GRE}5`B%}NJlq%=2x z$_jUlGNz<-g)+xO>nt{KhpaUYnJ;{WC*skDzx}fm5|%O-tz7V3K2S*^oOi>qMQ`fw zEM@$(gE8k!Ls}<;Lc7AYu^lqCMJ=c9qpoTH_YMdE?{5c(d@cO zT3|QxMs|^Er;Xx5-&__Y-jMCO`){!t&+`8>IuE|G&oXVCBaooVwB~!m9lM69Yzqn; z)(c$_X7pXf+`zCX^ojEIpEru^bUsboUAp1j94V7WiKTn~)nC~q8+PPyS82o&Wp@jm zMUE3+@gA`Yc*A|9&f|uBXWPcatc0pP|CNQIl zJJ}N+-&lTP`Qz*x$@h|fI@U!z{Pp_kyO|%)e4ljWdQDBvT={h^_nmTHSFm3DsOob~ zt$LozXGK1ija`j~fuC!RrYlYmd=zKGw&~#0#hMv<3$!i?m>hHD-n|N1i&yqpiaf3aUw*m1|# z<(+JRDkybqRgyPb$A9|g4kh`@0QQ{=*|k3OJA1(Z}>CL!poHQG|*WpV#8Y5-WbK_}{_8{>F{TZF6935u zN*%bxcA}HvnqGq{(-S$SHNFjZT$gxxG6*z$HS%DTU`cwgb^VLvUxK;+|FiGr=CkIw zXTx%^dBI7wk5d?Y{+Vih{(H9hPj%e1dRy22HR-Q%zt5`>?%%q8$?P{OJ6Wq9@YY0y zZ@901OJm}bN)9H&2Rvo0)`yI>#9pvZaZze)n(=;PF_ZY=#Y#U|1x$wzxYevx~hvAvllch^E6FuA`X& zbNZMMKM7t?s`9dl!7HsG0~usEfSXM&mV5~fLiquFEsv;Tes+hnkA|`IIjH=XS~d)6!GYHuFX?+IYyVvckc79 zI``KIu6TS=y5@({eK9GI4Ke&&HWBOiTi6WN2)4_7yrCp3c5?y8Io3xu3g_Gpu|^nd zs?ifUEX1J`sG!dFBuG)}m0pB3<2APrjlT}RwO^FWuv+NMe_=nCp#OrM43$SFXxW0Y z>XsMod0z_uyUX4a{oQ}-YP0E&3Ci+jE10=>BIe6oTig7!Dj<(Zbp68rg08kYj}l#N zs+K6bS15{zGZq>OOlK(6l=UYe-9o2TP+;|``S?Trt(Ok&uMZfIfj7WnyJ zuv781{i3dhsT_p?=&))@2r92RBG(rs&X|?8V&AI&9W0DS;yX(m{5UqSr5IhAyWyMTk$RWg47P$6 z4uAXSaU?LiZCIH6^M8j+gI$zIU?{`|H}=?7UF?s0e>m#Tf`9A2)gNKtU(=u8t@5-M78*gX7w%x}ke*l|EG6G2z2H?M zC(ASit%c7Hd$lR8_^VKUU{%|f|0}LCt?^>`$sVrMFqP%SUgiiT2YKa&P}V>H19!Kn zOlM+Xbjf?yzV+9|?z$UK_&z!CudriwwJWlhkAHGF>gNInXT48}JLSTTAMW}!>3_$g zy|3)EmK;{vBiR+bV25be?F|pYR!B{#ieO@#**r&Lf;a1v76vWBgsVs<`_yMI`10R_IbNI65Hx?ApsG zW$61qPryC3o3=?PlPE@Wtu~UBM)&4tAo%McQ zjQ+F0QE>bJj&*X|=J2n6@93&k6w815>w*q;(UZKOf==w^UJpTQ#twDIk0~lPtew1* z=W`qtUhu1W!Lx%x%qQfY2rU$QB{yMrLMOvDGlre=wt@$4u{8b<+}&~Rzo2s4hHnja zCNdM-yHo!wSFzskV!Za>Wf~|vyxz6*{!%#qezEzVC;yeZ>LRA|?|jjI_4m5}g3h}c z{|COVc`~P8=H~__`6;)v{wcruk(SYNpzC|y5|8;EA}50zE2ISc*&j)IRH#YSTZP=c z^1q|S@T2{rDKGx@uTV36m_q}~So9eUv?|m-*XGz^! zdC}y**J?xFwe(wAxLy1w;(y!x=cT<3=I(ocY(KJI_n}JFc?+X+V(T{UPu1W!=jgJ7 zdEEvVPDi&3yj7k7ELM$5Gd}G*$Jw@`bK%^^|7?4;1vm;BBODaA=>B=bG@W5elp|k* z0?+T+{vX8W)i&sV$m;1-sw=s4BaPcpnBR7yKtgIZdwtgadq3~z*+)q3t_|3@smAN? zs^6b}+44Jv`Dg7Ht>N5T@p|gJ^v@#w4!S(|#F*+tmNZR1!5ZFrW~0lSXDtzy`6^8% zO~Fem ztzrUi9{0xep1+rPe^BZuzNob9Qk$zB*G8sYO$)y?UI=Z_d2m=UW^1 zT9RI<+BWT;U4HQ*=Mifq-(QdTC%w3EbcRGm{onl`+!+>M>EB}?Rxk5=MV)C~%!`hz z`mfcWKHhI%UA)E9yY}|Kj+!@etMB`WERk0WKC-OsPJz_X9X*ep-+Zscail@u3D@rZ z?a~)Cl$u_!2pxR&H6vCkm9sm^-r(x<4;p@~OIr4FPY^g3x4>Ta&l%P{MhVkq*@gy% zwz^gIA2iohi#$B^snvP$S+k@`wmy#(lC~PxcE|nryuD81|E=%VKhy8>i(CIV`1C|= zkKK;?4s&tWKMiUZ_c7m}|D)o^t6xry3L?8|7k13%tljV`SpD^;$ER*p?&I0`sjApS zc}m9Rghzi<)C45@V&?lalxlMcw92u@E1X%z5aD3opW%Mt@4^>i4oAfPpE$k8VI|Mr z`}|t}3a|eC_Fr(P{Iyr?OUrUx?N`iW;a%3SD`>+yxuUuKx}Po<{}sw;X;jKH4Qgpt zsuC8+XM3dUut&6OyW+;}4u&4QI*x0aXE7V`hbif_+%jj+veywjaEtXt=YnVUi@GCz z$Zxe}Sk0C2nE3>+Q^a$_;15l-5fsWK~EgFf0!1V^-ifJnzuu3NCGH`-F6+ z&ew&@!jg}!vNCX)x?%Vm`9C-7uU-D=1f90;4fOYJmH?#jK z7uo1MDtAz>Y{+sm|~ISsZD9-PiK%TKF!n z@fUM+D1)?$*RTG)A`M$v6P7Z3+QINkhVj<{fxx|t4GdFe?d57P;AxSMEtfxX^5jw1 zKeg*$9jrBBv$9}uTqAn!PVA(A3;)}E>CBD4D7d`p<*&f+?r+1tz1BZ}Q$E)I%KfRU zeqZ?^v5&)UihjV9uS|7j1t~wX8orzR9T$D{E%ZCT{r1Ya*YxY;FBw$szxdl-?ZWp& zp7x-n3-s^jC9dHzX!*jnNqm7)Ldu;~FH4v%6gWI{j^@{LBZpAAg)7x4LuYbCDw(_6kVwrr&cH)DSxIo9{P|@(+eQ#Z?Oy zH54(5FiIbO#plHKT4Key1*;mTvF~9L$YRxGIArkVzy1e}AIt}5E8KILoBvA6V?mxM z|IXaxEzy(8eqa9I^KbEQ_P;MSAD{lSd1hy6eaXL@Z^JjM2iZ4qzH)!5y4~LJ$EDvh zPae!|U6=pO&qk=mD$l*phL@|b@Xo=?8T*U(PJOLEO}=U3Z|ODPnI|!oa$Qvw;Xc8= z!m_2p)wrW#(UNQ1i}s3aGg6SBU@K5sxenwkONJ(cH=g@0wO4%PpXbvfuFqAMap^`| z?&EizmoAoi|XX~vtAEEeYveD>t}63}8%b?oag zrXrR}jk_e*q%PPT#P;XSg8vGWWOKeTPG@MDd62ikfQPv}S?O4k=#ggjDWy(+t6HU7 zDxQRXoqD9~js3spi_geE|G(s@&?phnWg5|OG_sNPhv=Jx|4mJ+ zkM>wkP<$s;%OXE-LWHVLj{ZDA^6ImNm!qamrl!I$|IOVyQy0qp#(O0oja82cGoX6@!Zpupqeep>6M zGIPp&o(X!wOI%Y#+STuJaw`VzaFM9*`<(8|Q2h6OY`w6<_kW*nh#zgJf6%pZ+V6ks z{x<%<^Mmo9&9k|N_5Uu+`Rkx#YH>6FMf=>@A0EzeKgaa$iB&enbYpt**}&l^9#oM)_g8O(n8KZnDQ z`JdK*`ak{G_b>fFR-f8Gtyb@kNa>QgkNa5WThw<7{xq7mNbd0I6K@aAvk^qK4)Bn)-Ccal*wO+yB;@`fCRZKY9Fa{@cT~0%i$yes*PL z6PL_4T_@Fl@g-bMNZ@%@Gcb^O$CG_lWIl@NzoTu!`|h!@(x@FZ=rD zZjE)+ZFs}}N9bTUgWK7=Yz`6~3l|#;RVxGrDM@kJIm>KJ;(jio(xvU;T)017yFzdzAO?#D z1qW}&1cqLY2Tz#4{j#5Df2=>jY$F{fy&m7r~1(@qOIp!>VVr<-5A9X;EA^vau-`DY+3%=~% zRX^*eHp2mT-#-WHKWv^>e@f?R*qQliyf@z8^xx+6*Z0}&YZBhWy42?FKr2r>hIVx2K-PeXPsEh^y$Ch?xq*F zj|bdhU|{@V(Ja#7D8aGs4*wU{zdrJpXJ3!Y$-mgj(-vaW5wJpJPTFR}9n1>z8IN?! zF(^bi$T+YyEIS{|xZ(!OgAJSxI{z3LTIFBv|6;CI&-I_{a>o9Dajiu!t!MxL(YD?2 zo}u0R+4kZrlUPnVe*K;w&!63)?7*h?U+#{>IcC3T=72Z+44n#dokCcY8MgGMYkRPC zxF5d4G_7}0EW@F*H`p8`*qSaI@EdR7vo>(dVmm2x#l*zKP5g7G1^#>lt127!#uRU1V=enCx&vh~d*K`3P}=CxJKi*?rMd z&|y^g&fvhvna!Z2-thMVN5j?s8(0{!|0s(8Ul7B4`tSXP6aTSy{C9d8AMjB>p!EGe z}iEM>je-ZJqyO93z2LUo3w#f=P% z7UqkE8yqFL^e#nO2dBSe;=Ay^Zd$mL?Wc~80QU>V`f`O=nLqrztekLJf|0?2E zkI{jZp&@o<3uA(6vlhb%1@?qx&FwE2fXW~V_5^{pM*FwfznAj)tkg+-nH6-TYev&Y z%f`zBGyXID;PGKu!cfGuLz?NYVguiTLz`Gb9%?dJH&`<$H}EZBzUC|cwY0(T`uv^! zjs?#d%D*xRFj+BHh+W`p;MkGn%D_57@&LyJ3k&B5j~Lc7C@mB0n8&bTE8~Udj31^l zED-72!`2WW>fk5MAQD*qU-{Sn7r6`pvHf@0e*Bcb$oAup{6#i~m(8jTyZ;;BX4oLa zu#=Zzw#1=pYz}d%Ex9HWZkRRjPGf1f$Dxvy$l<`?_Vxi=ftUwfhE zRu{n;wqQ+z&WV|Kcp9&&1(>q@V|{RNRl^>ZN9GO20gMxvDlP;uNSX<#PLOgitB7Q* zVapR;VCTT~L!fto_5;_o4SfL(cCCI~Cm02oV;OC(w^ec6(L5lzgC&8>VTbGu28M$U zBC=<*j%{kr^a$UUFZaZ&sPK05Bfr3Ox4a6uh^b3$doszHgKpiL~tJXFaO&u;6@C? zC$R#jZpRDPnH2b0534mNI3GMw%($Ud;Y6%sz{c)7d=7FvO;edRxO@3oJ9J%-xd5;@BSw%Ibd z@Ut?rJhv4eH8v9jc0OVRp^l1Ev2Rm~E9FP*|5%o}5RctIyySKi7^rBWUI z47v&8&0oSMI9=GvP{Z8Q{ME*pS=1z8L(@v>+E?B!`?mbQ;>&!I^#J1}wFbiiEr#-^ zdc7}qqW>mGQT;Qe6F@;r{GTP_Mzt-8y?DaNuqg6=&Hq@IBBqMZ415i9**zGRur;tRklpj!^2v|VGeQn6 zLJYqq8GL#Bpe2k&_!VbDv>;11$D~b49AR7s(pV=hZ=D#<(zvVW`+w)Cul*AYazZaK zulRHKe@BwM*#~CrUyhwTVc!?8=WvP>=ZF?$(f*hCnyGLt2h-L6FBUiKIL2@xoMq*| z<1tcwxr;T9i5WI9OqqRvgJ@>@9=pb=CDJE;a3gAuPFvq;R2Oj5_=UnZi_VSla&eMRano} zw3f>)PTV6S)F4M)AScvdMTS~gr~%JmrN3$>kJkTH-=kG=zWz}dYw~Q?mR^Qwe~<6e zlDNX)VrS2>m$74?b;pgB2|b|)85mo%84p}zU8K&C^o=zkn>}H+$f0mvh3{+|-f}ne zavlg{SA5USAbR#hC&M;zq7{t?%%2Z;8gvYTE^x7h3|3pd7bOl%j{h&Zve zn&C-pzV~v|lQ~ixS7QN_`X8!z2 z{f{B{jz_uw=lri_j`;iEs9AzTcBZ2{gV(tSEDQo|jlbVN3lMtY$g%Rl?e)IFmp?ye zdcZ6tHE*WFrpAAA4$>EPJU$o@%y|4zsP8_-H)|VoANKN2ky4SKQS)G?v6fuGmW_>l zt%l!na}@U4uUw$gqWb^cKWXU`Y8R$4nlS(PqxFnSA%>G-r))!ZrbJG;!3o9_j~O>y zJ$NFW`N3_uwmsGo;hGFt+y_=MJrQ(%$3K$l5}CkuFk_d+V~&yw!K`; z==rfwSmf5SfGOujf@-$DpLfC=ey1^k4pKk3xhggVs8Sr3~wGAD#HklCYHF7mHv~Xv3a(hU)7u~Y7M3iM$=1powvWR9yZ3xa?EZ7|zo4{3LOM(1op}DQ z{J+8szO0k~^-^KOMf=(RR~)r3dMzLJ|8W#^!)8W~Lkx^9`iugr*f_qjT}Wr&IF)Hb z>!J;Ej5*r{szMv?$Q=k1I&h0+L72q~?QL)D7tP-B&HiEVp>2QNU4Epk*v0!lu)nAI zX;nma{lEG<>@JG$S=e^&|7D+bnE#3YjWhB&57;fgA3pYP;&;Xc=Km(N*H0{GKG;=% z?!U_%AvS@A3C715CD;-l{I?G*eL2f+;;A6Ntv-|aawL@;J9ua8XSnf|bzd5bCfCvs z9q+>lj8ZN=U8)Kpr%G%Z@(h|C=0v}U7I`y=Z`Z3>@#EJGR=wve+5ML1^nyDd_xxJ? zYo5aoy9NH=MPHR`RxsJS|LbsAP#5?6{4@V=|I44=PyIFBmdT)q&79$o0gp^?;Ekrt zABrCvWqWlBR|$tUxzGE%#WQPr-+wg+@y9+nI9=bdroHIH3 z7<0g38M&`%%sdM_p4~5Dwm+Wct{^EBeq`-Kk*clE_V>TGxBWi8?v+T^mibfdt^fFb zy{O*1FyP;Ue`j~s2X5_a|E>OGcJ2SVMfHya8zxvE15Lj({P@4L{>7#IWl0tf-5g~F zq`luH_@_>!IA#cnL~h;u`me^i5QPFg@5>!Kuu8OM$;Q;Seoz|Av}iADC|y3cDK z+?jvNC%mL5{<-RF(f_ORZ=Ziu{VDLTQvBNaA5Pzy|MBwV{hfbf|NP{x=&Ao*#hUQs zP9OtIl0ucZ{wvirEUbH9cyzVmUAK1SUlv+cvi*bVUELc0a<2O&`=4!@IRCQmqLsg@d*IL$ zu4vtef^x-&Yz*i3y$E4dXf9)W$Yj>Gf=T(;B#kqQ)y$$SGaVZk{2E-IczZmvef)nP z1C!r{`#-+13REns{v5j`uIW|33Ov`RV$u|0;hK>bKRc{Tuyz`#jZ# z4qpbJ|Axm|HcVwYVaxR7Vd9gkPA@_kKXEAL%wq_#Px59t!Fzbu{}peW`u=xpV_f6H z;3}~qq(QYU^8!b!Dp$mz8I3K=|GM9iFnVhLh-)V2|G@V`S^xW2yiZ(QW9s5!SG2d^ z=5c%6m&4~k9i>lu?2F#HzyBq8_eXPL1H+WLfm{a^c%0AgJlrFjz`@KfqxmC4=g>C( z{eL}jE{mKDXL4W)JCYx|AdhpeXo8@z=ngrHEz4RBB`d5sOl6ft?G7$I!_&mUcwud* zvW=IMLzkW7vl8Yz@zud;Y@rVx{|la}-Er&trv69w8{c!w>;L`pr|^3I@;~*K^(_c3nlhgU+$ZUHg@)OLZ?sm2$PQ3R` zzA!)Gas8Q&^*{P=-8lWbzsi_n%{ljTKVMAjk9mJM>hA_$`3-I00r9K+p9~FDp4SPm zaVP`{Gpu`<7@^4^E$fmma7e80&?=_W|942YZkWedq||U$vVlo7Otqm%a*c_DKgWi9 zOjSt@56w*ObRB6^m5T6dcdhzcf5^PO=??4b=ZB+yfBbK#EPw4j`%h`J>-?*~gC-%Qd4Z}XIoI6Z&GE_sl5=dd)a)os{U%d=C<;hpG#F#f~0m^Zj77AZNb=W|$_8Ze#n zO1@j3OcRsUd;4d14=(6n4CTH0KX7$Bo5~%I-k6j-9U?b3aIhyvEIItD;z@`5xvw|> z8@}i3``uqzZcy}O_aFB)UmWG$wO;-G!qwi8*M3nksOl70$;l9|*|4Xa;irn=&;L{I z%JFfT+&Cgww3}h4Nkb_22~Nfk@#+7M@3EDcrjhmWfz%R?^-kSiF8!ZT&iee%@jdzy zVfPQKRV47*J(*~i0}9l|+kZ{$u8Y{tZ~I+1_WNN22Zl@U5?CE1+8AGauM!EguU~xO zcvHnC=k>D6v9s0MYc&~S9{9?5E!KGZNTg#$OVd%o z_vG-epLzcci|vY@98UXnVR_ZW=)X6*>K3upZb)okm@|7L?*Rn?X7>|GQz8{ZGB?#b zrgRD~*VoXPpz-3(_uss8gcfXLiWiSh{;Q~otF`|`Kx zN9$>I*Yq1SJQ+5uVyMhv*csk%$Fyawbb~3^MpdSW_Xob&C(U7)#*q-pR1_{~t9azU z`xe23rA!)|95|JPIn$LN$}Hh%ON=kDR=Cn`)|^puJo3xEQ- z<&Fc-ul@}A1|^1TZVrAt8?>0jDp&pw6lUXDu6WVF^o8KO29cMB;I%Kun^&!D_}}r* zwrE|u=+6b;_*Ts4mwM#dR}-<3|Mbt2&Kgh_^%7>_Ijq(_LA)=)o8`n^=ZM1sJIfio zST>X~t|{bLC6wTNe8Wr^`3#3=|L;qsORu=fr|`(4#2Gd|{!i*%1o^v5B2LR)JMg)27rWTU7dz#`o*Z`j@uk4UuIOC* z)*p!z`DZ^rzVm#)439vAsPQ&N2A0MLTG#p#9$tw=vN z`NQj9`5TQtZ9Y1&earf}>tD+~dcW{J=ie(L4p)2_Zg?@>P!Rkj!MMhk!JB2nL8XY@ z3{$KpJm)|2Pg#g*g+=RDe$bMG>xZPeHymNmmSp;utk#vV#KU!Y^TJn57nNkfjvQ9H z%bcZO)VIBT7yq=^zWOtY|0iEMfqn0dx%%@g@Nn`M*yl0vWxtzpa>T}Wyhr2y3tGxf zyPY`k9YZPmntALy`S-4CmwmF}qx|L*?O#DFTx_2o?y6noX2$`FHDQJ-rG~FO6IL@v zcrr-qF!dH3lxp9g#b{Q~kS)DHo#pfYj+O-8UWVWQS9BhHYOmzjpmdg*vsy9HUqz}d z@ztIG%0)Z5qn6xuR+inlf?YM>hLB$K{}rXSpyewy5l;@Ql_&hI`SLP$){`0uHV%a- z6^0m9#x;o?(mF!F`e!(@urjSNnee|qO6owG@J3aZfP`kD=BM>8){J3BH=LEZL=rc+ zFnUXDIKp^XFCt?`RfPAwfA(2|{I4%HzA^vZf8yf_LH^aRC$g76`M;R&L&snDo)3!r zACpf16fysG!O(%>q88%;gDRzlUf~1R1QS*ZP4H%3`hSNoQ&B(TGzka6B+jD?IGR*B zp136P_XgxhsO5i`4_tHG!SIBQ_KKSu?&N)vH=M+-{c5A@o=f#tV)&(RxvqPks9f_R z)^?UFH~`lQGw28&sA4~%+;$?AsVbAw=gb@k^935A9iQyCm2%qm;%IXldA zank3#Al&q)-ovS(S4C+$*NINXFy8~KxR_OPIC_0zB&Jm)yh?Pn);Y9wql=Z!cI|)e zXFn>GD{ucWQM&4ctKF{;dZBEU9S0d0UCy&Gc(dG)YCo}*aZPT+903Q$jSXZdII*NXTV*62!Q(t6?h73r?nK8VM59EJXe-o+fu> z!6Dh3X9G*4Zs3Hb#EHE!4^K?w%RYPf4wLlJ=BE`m8qO`~u8?2@Z@A#=iBnQgXNg!3 za=R+WlS_=2fd@96sK3I}vSQ&zKwIA;@1WuXBlgPoH`V zWFLu2Td({9A*QNm#^{#}($NmbHnbe{8{LwwNk{Z^}*(qvXe_wBUaH5X!#>cqB)s-y8Z5;_`CkPx!k3H_kdWdt`0k{4G z?KhYlf*z;@w>Bg{3>N3hZava9C-vN4!MOMbnOCFA_bC+J_^|oe*2^)X*SLjFm#Q?& zSx9Yh5j9BU(4ArEGHVZGG`AQ}HFp@#OR*bz4%`d)-*LWR{2^};z`WzD@eR8b?jIg# z%hca`{94iB&d!zG53hxa-)*$npIs(#vDsz1(cEL(wpK5EF>TTOu0HMRO)qY>J##93 zy#1!avi2lbDPfN@8iq$r<`*AV%n*{Y(>`i)R^Lj~tl)3_KgJ41sjrf2yqgu?FfcGM Nc)I$ztaD0e0suvml*j-8 literal 0 HcmV?d00001 diff --git a/wadsrc/static/glstuff/mirror.png b/wadsrc/static/glstuff/mirror.png new file mode 100644 index 0000000000000000000000000000000000000000..08a6abcbe6705e5c76aeb85608df8784f69904f6 GIT binary patch literal 26089 zcmeAS@N?(olHy`uVBq!ia0y~yU}OMc4rT@hhU_&FAq)%*Q2{<7u0cUT-@biYvu4fS zy?f7|J-c_y-m6!yo;`YY%9JV1&CN@eEZMSUOHxwO(W6J7J$n`v6;)kb{p{YeIdkR| z7Z)Ghd-UGDd-ty1%gV~yvS!P>ckjBpyWc%~clGSm|Ns9>ChD>>Fr<2Ux;TbZ+}c{( z-n96{rZpe@6l^#w{{Nq?ue6D4p_%dB&F{aN?zUbQ%@Ufatek)F^Us`RR`RzJBioWB zw%PS;Quf`vt-h~zcW(68H>dV-E?TJDmYQ)}sfz9LHTS~-KADBb*Y}>Sxsn|#e%rw1 z@;{zg88=SZ&1qWs>a)S^`H}X=ZcjK;7^9wgPw#C&Pw+hX%8ThgxX(X7_y7CH?EBxB zecazzU;BGg{PX>#KeCo-@@~)KJ*2q)@ygea%<99UCq92WZOYqUJii#vcl7Vy@^r?# zZ?el@mN6z6FnBQ{_k7B7G1^@p9KRR9KUlrwPTj%>eW_ST}ykd zYKoaIOivVFlDO|{^5>q@hT2h#0a`a;X? zi}!!q?%}U3e7{`n>?X_O`T1KJJlc}FSN)ZIe)`fQts~hX58ugXGDPq;Xx;wDb>R5n zg1?XI<2JmsVn6VRL4(DCpP}K$ubM}KA8&Fx*)Qw058nQqyP@^}^=~!|7EZqR+Y&h$ zetrDe6CU$?4#S7pExsSteAb9MwQT?Pr)BpaY5MM-a(-$$(}F|tJ(HdrYrpGnWl+iH zEZ{g0F}0Op1>=FRDTUwv9AAI>rveL`LnecX`$TiThE4gaAIy9_SAwB3h2g_`O9msx z3$NH*m|@N%0k%L07{Cq;&BYd1v4 z$BVM#hA;m`8_ac{2{YI@9M+C`%EHighjD^1 zgUxfP)1OU(t6~^5KG>fY>ofeA{Y~v{VcKUcuEN!`f8A(4!o1;X&9R!hm(z>lx5>;~ zV82UhKdZFGYMw_E1_n-v0Ng{!rCU4H}FeN zHT>gV7k}$_a)acV>AdS><7$t;jNFt}_3o+c@jRYcR&C!E7!3a`-Rbz}5_iMj-Rd>} zpU*$gu=(D#S2sVi`25&X8NK#r*tF=z#qk$8@_t@>#rHsiiNU6R{{0so^J2q3UDdN; zU`S|+UDiGGvS!b#C2g(VuU}dk@=TCEk^b-9u4U)>(&V<=te>wuuk)BgqC=DYEZ5iz zU$_}oFgoZm@a;HQsLJ3Sn9kRbzt`cz>dOiYVayEoH@$9`^RH)JaO1(rXr&X+G|b@XZ8KYglT%*Q!XZ1w(ae7IIG z`pA4;>4=nM;WM`4hMIB?ugxyj-1&7EQ1efi$?`*wX|S+H=i+$|fOLq_5Z z2RC1N_%yU#+Tw+&(v0`Bk4|=Pb&z0p5Sy^RVAi85-ObDT9_{iw&ZT(g^UR1P4YMyS z|I_F>^X=qT#hY#M`}CLk9QfSu{r;;e{(=vQEte9QZsbbuW6+qUTO9r%k`?_4DnJC59cD{$>fsQr`6g0hiw z-8$waw>p_jVeV(JzrN+sSJ`Bl@V#|kFRt65_v23K#yg)mmTk(ry)ReL`AP@JZPPRj z8!iTkgMkb!9jEr~dZc&Ywxm0352O#I zntTxdzUkCFYbGZbiCBZ{PuUoZYK)l_qItgGls{qeOkdwRU%~Fld0Q5~+RhidnHfGF z`EOV7^0i&eX`A=O3}v|ZKX;{tW!p(O0sX4=AbP6mcxkLU4AceHcMZO)Kkm^!y%)g7_6rnf=M zIJPX;kNW#$_@1OYgElap0Pd7&%k$HAACs4)jK*Q`q`Ew4f zsFg@fUNfqq8u z?G>GeBns0$fBW_Ei)Qk~bw69VISM{`-Kp5Kc&c6A@#BY$AH}Zo$e+9_v!Je$h0Usc zmj0^l>u*^ebo|=0W}>TdCg((cx!B9020v^WEiTnXdfi*IVykyc{uOzbdaln=m7f+F zOycVh6Xi4P<~VTa`*)dp33ntM9&HR-=6q60>7>@-O8LpnmVZybd;NC#e)b2M3{xcI zqO$6XyPn&6y<*vThNHc=sm--0I$l%cnW|>qyZq&)H`+U%FWzv3eRW4b@aJRlJ@+o9 zREiV`Sh%IJ6|!tgQ7S9#n}74vnuBaghhABwgfV~U`lg^eO~~`JaYuGy({eBV8wahr z-?rE%$ISXHqW$f{<PF9M}Cnfm-J%}{1a!e zVz?0QZEYmv*1IZayJp`bol^;wA8zhG>!oCQ|9#$bI~&H1)kVFG4)diM7!1!&FOvQk zDIoo=pFJ)?_`vB8yA3|-3e8xb5XCL?-XL9OhWbaFvplQYRo59O*zu&+=?j{qeXvkX z%CUKH=i(Vz&;1WCJ?_Usqqk9@C=FkfKoG0ncmFeBmcb_3f2&Dk&N_OJiaA{n>-&&vY^1{}Lq ztoWpR==(AK1yd$1)Ao1nW?&M0*pPM5mgk#}+mbzxB9{L-cEV23>Y=rmU{3D#=&{f3pRe`fq{RB# z-Rl_`Rx&;EkIRu-&N1;oZKHn5p&ixf>pm@$QK((u{6MGS?_D{D1{OB1i3U7|d&=wF zoq~+N9hkd_v;Qf3C41k=$bCl`FIX@L@IR@HTeo7RPeFPI?=7BsQPC#3`P;n;Io0Nt zu{!_w!Lu{bY}qM>6~=Q~84Uw(D)Lnw>t?)gL__b3>E$zjEf3yP3W@tw5HZPLaDv}K z&I8M(KEyLR%$wwUo^Khe`3{K!<_Yx&-pFV=FLWwr_}VaK!J`}N%}>`9eA=|C>sflw z1xxpIg?Z2T?my}~q@eG!=XlMbj+u|9d}evk_|bRvtklDOjb^7hldr5!36gPdx!)6* znAOg5(_oEujrQjrWv$9T4~a>08Wssq^KR zO|r&H>(&%_9t~r6oGh9eX*O}yT2Ud59iA3@)YxV@_HuD2C^MLP_u7;yE6B@!&*_we4LYDI>!Jpwh(6{|#I8LupzQmG`~Ijbf0%k|xNYh|A7PfO=t zzwrO-kMZgX3*65M?%H4|7|y^@$fI@5n6W|haCz>FY15BJDgT%kJ4->JOKX{C^h^Z@ z-py&}!-|>NWun?`mb*xqD6X1O=E8a=W4RuOTUE%OPZJ{5yY!xJ4r^&#r2HGdf80@^=?Ac6ToLxpBd-o{EKsQgijf7i_eMaQ}2+dUvPZ&hvGdJ$q}H zdeluwk^3#8cqRK=vh=Fn9H7Lu-Za zi@EtO+|7FX<`chyq*mK)hUzofjSPl5!i(IMHz-vdx;gveS87%0U)y|@DWcAJY-<(nz zBxR1x{BIw(SH6KMh47jE@`cy;^Kr)&`}F5eZM6=l9LGpu1*5c=8F z{fxu%<`0eP>)07g864Id_7&chVaQm~TDs}(>Ad_Y|5oihYN45S_DH=T6T=15^WVS! z_f?7bmbr21dCL}g_N?Go5yeMN^A@Ua4v9H+W=%s)k<})JMM~EX-B@{7!!zh%2phTi2YJdF$$@ z?Od+Tp#0e4`tjhGkNFu53t~?1^a{A+m}YcC-)jnLvp$+7us{1-IfFg>@UIgA zd=h!l4{trv==`cW=lhf|&p0}5vmCu=e&%>n)Ve|Lq1hVQ?BzX*%t!h-S{5lBD|KSz z^x^!allHem&ZtC6P-KB~+bXGjn%)fJ4A&mbTh4ai2}1`f!#sPZ$UcJyEN9NX{`+51 z(IIr9)^m;9>C?<^Jb1f|>)|!FZk7h-IJt=R>7fQ6k(t|{-!v47 z43tQ@(p9I+7_e}I07HRq=pOTptj(hR43mFX?|51)v*4JCv7FAwXA^Ed@_l{$Tx#IL zosApBe2aG2Pwfn1X7JnMGF8DjsGvpH+mLBNEQ^CH1K;UWaSSh*T>h=L%Xj$DtmfI< zBCQ$ISy!-vPoC>=_RYgurF+)s2whm*Ui0v0R6ob%+tNzYm3)epR{UsK(RFs>t5EHJ zhOEOc-i1aVS!8if=U4M#t92iEc_L=sNaxr;CE4(9xUJmUz-j-MEpU_w-4xrggyHLP z>qujZSRNK}rU0=6XWHxI=P=A++{04N(6n9Y!*zE>xA}$k0j22|m#4`@Dt^wsxH}`H zDRJkz%76JNm6JzrlYa|B3Jk z#Q>|g(;BJK4F7EpUgUbtqbi{=?a@p zr`EmqM+4(OZC2UtEpisgEk!I0irJwd)`#pEHf#=X>As|Td)bk*3=$J2ue#u@J!3(* zH7BDCqf$fG%elJSlvCddtrKzW<7j_wM8&v?l5#&NHR_NtX~ z4eYYH{?b2~8uUJ8vCI*d;bfdQzxUQNZMP$NCm$TI*|93{s3gnRSuegWRA{$eV8N`* z-!f&D_`5TI+)7raGMlyNRckPaaI$y_SEsW+k`R@fvT-7-;+*05PYSdfWu{DDw`(55B+mq<7c3RG zSq@~(onX!&!uj!IHtXDcU1l}5F9*&p@9}thfTivKJ{!5UmPJc;9i8;W)?O^jDZu#lur~-TJi~f8UyQ+g!|ac@4PO5Ktj&l?n-)dc@LGjs1nriC9ax?F4#V2?X+N8Z{yGgQb$ zVZy?#=k1F7SS(*eNKH6s7_eGcgT}IJ|&MSZZF)@VQek65HENog!xLl*M)&$|_C(b|2 z6gVTRu+dj6N-?F)e1~qdap=i8TXWt$3*&XVVzAMGNuW|F@LAL;j;Yg{HES8(oe@52 z6y$Zdz*U;_+k=bm-B}mkd|UA^FKz99=TNEelpW6>a4z|Hs`>t+z}P(uH{Ru5itzpB z(jXwgb|!J1n1H#c?z&T2-tmkFq6&Cl-JHe${b=8TiD`cquis{vu&}lB`NBneLXS@T zma~1~ef2AcI2b%#R$OJaxUoCXGqE*dN!poPN~J!_B79FgZ`{&w^!=RJEvuMjf4HYy zli>WZLHgwjrhulS%LN!7%bhWlkf_MJ*{#hm^{c%t!{@D1CjQ~?IEtjV=w27?H~nq> zL6AYFFhD=tW%nP>qGZz?vpW{+)MoQqFzc|HrMV>pKZ}-rw8K4tO}w0O!^ii&4=h?( zn9rLpntAe?!XeoowQ8a}6e>6)*Bv;>c;VQY%)m6aw~aAeZ6^xcZC}l|oYj&Me4|*n z!Fpl=L(AN+YUh95|MROVzkl(pj!C|qW%}=5OlNqL!#>SGYH{b71OgNml!FHX{A35dBL$VAE(z}=Jm~FyzV(-uM)!7UUA+8Kf+zi*(Z-1vT zOVek0;p;_@wHdy|J?u0pC=vb>(OPOC(Q&DLQ_9kSbcWob&>4l3Z?c`qw-ma;(SDo3 zfm?Q_2-m|JhFj)xMKLz}-tz3^&G`6PZ*}WBLyKqJ@1s1mEA(gh9&YxL{I!?2d-b2A zf4CY%CeXE=gD{q*zw_VvF?Ra4Oic?d$ zcT~MO?W=U)q2z&FhunmnQz_IhSv z+)M?2b%vX63^NK1N*eyUsLbGIC@#FbRQ#DoRm%gG1y)#8$TfVgIq)w#?d3X# z!>cQFHl=U;^pB~rUh)tB$wd(fHLa0-9WU!vCz%PAyOftieF)-f*b?-SLm)!3`DI?q z`ydscvXio{ry12npYg6UI2f61ZrJUy<=DrDgO6kd$_3&W%#Sfd@H9MPQ7~ng^{a5&hxbiu1R=q?JWO^C3fmuW#)|iI{ZP32fjIJT)%f(BR{a=vH3D?hma1J z`3zUsb=ha!nBq;c=D921`FNq&YMtV}|7SjFSCk39XYhK*vED(1fgwSnhGhZ!Y=bi0#&SOi zMvK1-=9#!MO;1@Q;mY)2_aT9O!X0;*Pw_tE6e`J?c#9$X2IG|HQt@Y+8JlDGz5Udq z(5UBH$(kT_^`JP51q)ANr-s+eomPK)lRtG_X}CS%LB^u#3`|O^Z!<8YERMOa=`zgY`6Tj2N2y@C{u*Pq z%{vYyMt2-n3+KyInKbiuUhmA7&?%-R3l$z6?K{pk|A*r2rN^u;Nrp)Yxg2}o`(o$E zDXOPqcBpuWXUcdSa$CLgnqUI=lY7g1r27gsE`M$~L0p7kHk*&m-ra7tITL?MCom}R z$we+onq~06Q(f^|te?9_@wNXZIOz)MS$_YMCplwSMM0zI=w+XFG16KFi#oRA~C5+IAn~ zgTG$g+U~0*EEohT7C0?(lfSh2r~lT#rcVCg72&TZF{PU5##q+e4m-alpSA6PZnx{Z zHO0H9uG4H1=j;>I;y#yi|L2_UK7Apnh?batIfB){9E-F#Ch%OaQZrlW?BJeo@PmxM z!y>j828N0i?Fyv1ZS2gB>^C7M6c|tvLI@o{8}* z+8J&ny;hbBJzg#D3eUFrFqh1G!m7;3u;|6}xaWC`8}b=sawf}I zF&)3paNxe@&1 z8g42cGt7vz)(}gM1@1eve$jK|E+!DJHvvThsp|9Lr_|4@OOcI;Sw=L)HZD4qOurw|C z>w$ueJ0#NFs;)&{I4Izsv+dpa+YDDSg>4x;iW?3b%v@IcpR;q$&O)h$&yr0w{`sf` zsWw&B6x484r5}l3!F9Riu*`-}i8g`E3T`tlY00uM%~mWZ_dgpp%bJs64 zY8O12A<(@_&`f~A=hLiD+!o<13)mw0(goi}u!h{<;AG42Lyl=dcAc5uktw2{)|I#C zv=wbwZF%~9!>*OS*_8~JGR_#yVffm@;jlPH{OHG0)3A1DhqWai-$hFwV0gK%*kt}` z&3mG!FJ?}j+nO-@@mY^E0p4{xgd1+o7r4l7nY~G^EW?l2HzQU5a56CR9&eE| z+56+~JDG^gaH+kTygzS=&iFQk^+Ct^s7oB@=FCpnJi$CY)c!TgffWWR_l#{`oxbIo zbMWR7GZ~ZfH4&eBbf(x9IW6*Qi+INnV8!w1j)ed3`wR)b7LR=%=c}FkCds>K>Y6={ z*U}e!Ow*iR@_nN1B?=P1xVLLlO-jgtK#?5D@2zXt3_P`-@W^kft17BB%uA8p zcJVd8-5HavPs==`mOlJ3YwC*atIYZ`&MuhL@hGgs zuZ$BO`3lV7-mQK3s=NM4mD~9haVZ6xXE|u?5@ZnBy6gx;z}fS%(&8dwUwUV=GjLu| zH!tJOklM%ICRH<8W8U*_u2UvW+Kd(q2O|D6Fvu`|s{L2P^6h#11};PUsHras^u${2 z{z%`cDB1l??Stc#)G56mY*RRS)P))k9`H#LW%$Be)N17-#+rLgm}5VCgIihN9o`4~ zjeSA{S2oObOi^NZ^qi5oCZg2h2Q!2JvNZ+*ETbAoEl&9 zFh z_WCydxH zD0?vp2sKD8ZEvyv$lkokWcBCk3@^(jXM*#sJlO0MW-ziPjxowO)8N-vOn0#mc`QFAWuJ%8K9+>->=I7{zIpp!tPPL#Y&o9d`FQ@u-Ck@A>_X2X zu87n~?A?%6Ezod}@8Gdy?Of69hmHIPUQL|k-kHI3w_Qv3UG^C_HSQOh#|^V3!s{%u zL|0UHCsivlNb&N0eE(-6>+`jL%sU;#ttB`M|yH z&pYB$V}8!;*}I>WA(rWnUVod*5MbiCIHPCN7o(?1p^nw}rl_$0h>X$yvijtKh4Kj< zOLsQfEUMkY`081Cank!|j7c1CH2Tv5%612xZ9k~&ZuW)maAwC0#=x1g`_KR4$W+w0 z_xze@f@x>+#WxXe{>)q9-X8q!~8)=-AbsnPtQ( zUgXA95%{*MWcniIi2JL`4A<|nugP2UcvILh!_siqPPuvYPi(X-U+{KM`3+@9RR=XEq7?qP#yx`g$c^)i>47X;UT-pKZr>8?nF=Rt*-H80rh z{q2-Fw%@Jed-bSHc)`)8Q`gknuDM=V*r>f$_UO`$4|UoiSQ4(CG2%Yc>cm}=SLuAF zvQ|Fm-(8DEAz62sw$ut2ESb~8BWZ9z+rg%mviDmy*Z*Q z7=I={&72>j@~Ez5;ZhHgh1oY>tcYB@;ip}CTIGt9uLI2%S~2rW-uk#FDJ;f$pX%bb zKNsEo*L}S1@9imp3Vr#4nYvT2tkTMRQ#>JR%EjHXePv09CA027{QL7{pj-2Yx{M{S z3ZgeTGhASo>U^S^aoL6S^3EXk`Ra|zX|iu^U)eA2ykPQgn`X)f28Cl!ET3!;>zbT1 z(dLF)-ODIn`*{-lb_@omnM_^<8m>B&lQhZ5xa6U~@1>Wm)x~}*eDtLmKFn@5l@bxC z4t4UJuBrKX!|n5%W4NzGPQ7_Uh+RGU{=TGx4ts?in!ESe`)@UyW@w>z-ej^$-OrXK z`>(VMcQ-}YZpcgcpv@{9=dJd452Kdj!d;!OoS9f^!a6kK7qh?7nxpJF>(08@;tW$l z4)ApD67%|hLz4Y`Kl_15-@1x#;Zc*~3r-8z^?T{DO?A)xpdkOW)%J4pQp2ty1sI}PPtedYZ$rxbh++xD4lQS(#@ay&pxOY5t06#8}xrp2-g|w))n8) z)8|C2ee~z0#EM+ii|xV;tS8umOGA0NJ^7yID1TK-dsM$GYR)8H<@a0nI-Crgvf41q zvW7e0g35!E6~>FYx=vi3weC%S1YY+vCtlfnP$gcRjjS2ZW`iRi@o z8947g#$+X9+d&5}*_~V*0n6F$+c4%zf3n>8 z@t4EHZOW38%rD#C{VZGYLNxW`0cGRstGNCN&A5N1X~CQ+a`878&o1&i zd7}A}hwrw;Z2$N7jru!-SX>iJc*3$n_wBv*Z%JH+;(kM>$xjnby^@~4<~yfby``hY z$-2Yey`+;;53>7i`(@0~*k$VW#Hnd9Q-H^ze2$OmlkUhVoHqN=otvo4Y4EzH#=AMO z@#L{vD|A$=W_BFk`CjR>NCr!mUvHFP;JW2o{I1L}+xOu&zq`Yhvo{aDh;489@yI>g zig~qXS(Zqa@LPQ)1`Ebkh8@>JJbJ2Z{M5MBR!eZ)Tg%TT=CJE9&z4zxQxa!8`oC)B z`;fI#R^Y8fq~YVVHEy9IrN7Q_oMfCo?S@lIl;d@#w>FVlKYo5*d?!QrQtwf@HShas z?!Wf27C4sD8xZ0)Pd9y;(!czV2iYc=7Jq6IV{EYZ5>1iiy6|^d(DJmv{L{W-T_+Yy zl6rXBP$EELV~@StWc@W;R^2*Nw7UCLs&UF%76wU8Gr>Pj52iC5Ny{wPmXV8eIwq|$ z^_5WX`sL4?FMQr`^PvCNlN@Z1`n9*ovpp_r);E1*E!ZqKi{od)`}zX)lZ**+dCU4d zOd6XXRn33(^t@Zv$IS(+EGsuRwr#ws{*p~+Vll^`Wd=?CwJ9rqD8KAvSi{q#tHHIL zx8=bBCqv&d>>11fM(@@zzVxbQP&<>P ze|yd$$4MqJtG8U4b1t*ULc=C#*MlEZm=rD_vCUR*Jl$1a%qFF>sqm=a@{*$B7ardo zx|!rxEHOBj^-_#~hx36~b82R9=WjiF>Suc4p`3HQGJ!oU(-pQCa{n?Z2- z!-YvsabaaOKG}0>uVw7%EW5?Q(C^?{+iLlZwPo3FTLy`b4_8`WT2~nP!*J0HuB6v< z+V+aPF5tA#S@UD^`Oq3hh9rw^O`@E;-6ZmBEN^}^U)y@LmV54}&s+z7ZI=jrztnBw z()eFSM^|ZG@X7NzkmNRHgG$niS@-X2vD9!MaNKHTu3}u7&Bapi^56x_QCA|vp)?!v^EZhl8r zO_?0?yBgE_nIyuhpd>t)y$R(>5Io{;aI{w4A}Hhdo21^A`WcnTOh*M(k=5EYj>@ z^WZu1;QNJrPeSb(A85O-o8OSN`q$6d)ivzR_DnB0cJ5Qy@^+yHleI_W#r;d(mq{3G zF_By2WaOW!a%9ph_Xpt&2_B2Q4I5nfjwH!zm-ez*Io~-Y@yx$XpnjW);LoSZ3cJ^Fh(>yfS>PdKdeG&&UYuDHMV zdH4SJUf%aM%ilyC-7@ct%h{U~mwbqCJydb7Z`Hx28!ty5SI9kFnwfo4V!A<#K-jCxGJNnW`eZTvs`U5jS? z!*h!tTYP@y{pey_Zp2~#-SLbYm>W2&WNSi{7b}aE{=H@?<}T&6I^cTXOp(&R3%5Q$ zp18Bt(`m+$S0T+Gs{Zbk-=Lge#k+N?WF+^2JMV5E;<5jJ`HlSf=B}O<+!udzUROB3 z)Qu^)&EoG-*$Yo}>t1x(X&<`XF56goWfo6lqZel`i}MX*T`q%wA+dTZ|BkuX<&R+Em4NR@qd|ZE|uAI%Xu0ej?v}e-&1@ikCA5_n0pJV*E?)~4t zkE_4G>~F~K&r>tD4k_-OD|oK^wP(_6uUn1V)_f?E`S6ZE)lp}S@7dC*SKC_yw=}5v z9A3l6;LG(=?qTwgNt=&1%FZ@jzl8nD>~l8BJN@Gl(zSbM&9C`)`seq4eHK4=g@_P` z1OG#<_pW7jxDxj&p`vN?vVpmZLViQ$*@^6ORTYaS~?`I#m!0M>yv|5)TgRTE$ zwUb!=0*2X4t6n$iRagE0_2=RR^;yMHF*X+FeaUBUahL{e zd)&ZdQupmj_p`Grdv70in6a|q%=|_FFTdFTN#Q=bRF9xy=QU5`xF40pla4GpxB2(N zq#31dchox{2TPoi@Sgnh|C!0#;zFjy*RvYidEK}2+QRC*`)>s2ug9*5TU1Y39&+g{ z=$opzcz^Aw>vunk`#ImS|G#MubHb}j(f(^y)8^W+3%u<1+;UB4X@+28hHm0hhgn;{ zTuNvYI%}?f_jJ&o*WzgLIJZZE%nJbv2467B-+)!nT>m~`Y_5|iWHZ$MU;rM@>lXgY@3_+DZ z;musDzRxtg6r{|Trda(UdtHfxw0_Q?cz*|hC8yg`uJ^iXsE3rW3Jc%dAQFFTMxJUM ze+^sry}**)TDQ)LneIJW|Moby1B02$Rl#N5pQkn&Tzzs=!*hoP9|$H2$i%d*$!->l_t5>-{ zObeT{BJ9uqQ#JN63{oAfuQqwC@0*!)TZ1{EvF&YJmsIP;6n)8)B_||ZPU!J69Ig8$s&FW8rEdCcZXI8P z#=j-MT)NNCu#|aY`|4{P+>5eHr;74C@NsngnjymPv@bp`z+B;*&CDfbb8MLy;wRS5 z{PXTV1H+Wf8!w-Ci|#$T_S9qs4%2__7!s4Ew}yZTY;o?k;@xruh3vtikv_usc` zH)L!+&Nj_-X~m|f=fa#1m>(|;ef8+Zk_lE(PATRMVh7kJ9Z?CLw`ukTo14scz1{xp zmuRd?u%FNWfsrA?k+0@5j}u!f_ok-WH{JZMfh~I3_jV=ze7ok)ob&nrH!?i>wBk3* zqr~>&w7JJ}O#K}9pWmu=>?>onulU3%99s`}IwZv?uIEzNZ4sY(N;c+c9@8ZJ-i*Lz<7Yc;={Ab;c;gGQ}Y3PZ@!yNyX6 z2UdoNuDsmw{wUi5i%>B$k^5dMKa2jh7e|#;KDiMT?yG#&Qu;Cfq`35Y|0k7KSfiw; zAD+CL)!^tc(JhQErbXI%OP;A5YP&p9CieA*_(M!=VznFdb{#hHnD}<$f;+tL=dZYF z@Ry@>+5beHO`E>qu=J`vGBa}!W;7P=0)8| zzp$ll*)3-mDHHyNwjP`CMN(@EPE;oBEu6hAJyp?A@npo2uklO*4je4S5o_3Unj&2n zs`buY)cNF&QG}kvI?I=;nO_Tb9}_XI`gQMa#)t2dnb)-~n%lr`=9f^iXx{GAHRdnA zwz4-|*Kce*$kVC4ZWa43sqg11l(U~O&Uk)~UuyX@TQ#}n?&o;>6{qDx_@58rfPr=}SjJzKN&ez-Q&c4K#d-vekDN#$8vh?#gXYFFN zE@d#S%bDkTdD*djckO)+t`d8j$+FSyX??i7|3Y5d8Lt|*sarE7Ezi8X?yhie$T~Lv zoV{t&?q0cNZ*tpPc|v^jg43&+!X!%9w6jR-T)Av|q-JwB&!OKBxLn`(h6uiLzQQ-N zN96gu`&>GftJU<_Iqy7sGg>9E^YhoyykiM$JbW{7xcN=rQ2R9Qka>Rl%ChcvMMC4dhRW@s8wu6#j!rAU)yaun^A!)_)QRFu_4Fdq!$(%R*m7S zd>^sJ9mr@+$uiYSUYk_#>tlg?$rks+)8=k?vq0MFrpV^N+b8#PrB;4f?vuWV4G7`zVGD!NVCBU-&BY2(te;Q#V7 zcQ+{&cf934kufuKy-c%leXV4r6tCHduxxE(P5&tNv`sMy7xiWtp4w{b{LJ|HHvbh9 z?KL+pb-r5l+KXXMi%byXtL?{UMTjt{Exl#BKW69a9ES~yH9~CKx`hp#*n&TD*zEk7 zvbbx}G0pbqv-M&jmyWEFWVccFa+Bx`<^A!y`AUupp_mBHyjSHH|O2Q)M#76u;)=OKf{a17f*O~ zJPZ1udYdQo<_SNh)y#9OUTV}#3RyUNX4&DxbM$TrFn-B!F`w)EOva4+fQQB58E>DZ zY?i$)7IcR7qu=$-rA48!g;!#F&m`sNPMzT~Y2~V450@!$)NwncGGy4jyuc{hEa$Fs z+nvYqjbnLGbg)?0r`eiyol?+4r<(-sUUjxBb@G$8?~^=}99ozxr(G3zvEsYy^P;;9t~GARYw2;wWC%!eU-f5B;%(iU zGk=zGHwdgNy(}KkTfeEe=~Moag9*#iE>4;9cn{NowYwf<3&{2P2XuX4W!UOlT6n10 zxI@Bg(v-QY1?R+UdUk#DlM{QA)>vI16 ziw#51!@1{VmnN0h^KvkF_^{8)RQ9tGbGxV$c2$%iXR*$yS1bz*7>d{(Ug|vHbePz& zx9@iU*0V7mLJ})KiZ)yq>%8yA>}wNn@53R#pj=H8`{NoJv*^XZGZBe_Cz`R zZC<*5e}9BoGvow#oUJS8PTT*1+1h#5r#1zT!;{u+$c*{er}HLr_j3vP&Cd=iiQd~& zA>uht@#~{0Cm$VkVP&W)_PKM)=Jvr4M^~-qRoo`OAopASjz8;#1$eJ$%WoFfO@FlR zIos^S32!G(YM0u=#oK4K@!k#I{oahXmMC!DW#V0ARb_uhcHhCd3ss-x{kk(n$%bLa zGGVFrQ?E!w>)$*!dxk@}{C-I*@fUdvOCpojwl9gk)OKr|gDoRN$u)yJ-=EFD&D_DF z_%wE|TjD z)AYX{oF^rAy-QKkS^7j{`$HB6uSU=FZ#i$gF0o~pv-eWj%Bt7tn!lA^9y{znt2(HmA?&8oB?Nbbq6Jzwq35M@`e7P55>927fKHgR$x3!ex_w+}c;XfSL$q;HGM+J#(%5~mTsZ(o0K-sYPr7B^Of0|wYldlH#dFCi{M_)>VE$D zei25!M2E}wRlh$}zw7G#h&O}1uEyiu=JKg0IV2cP>Yi1Y@}`Z|*EP(&A$uEh@uEzr zo__0TdP&`FX{Y|Wyx~0XfH6Tv!}OatL&o7chK9rgecwv%pS7vg5LhyqIU)bw-yhj` zG7e|xbDR*LDsiVF`S`DRojY@~m31cE%?f_Y!mzL5$gHD`3BqT^yDs`nR0-I)(ZbDJ zJgT3eRNb|xO3u6cebnAP3di5KTbqd8Xzt!KVXi-`(=o?b$Neo@I{*9%OBBL)uH~Hm zoWJS*HD)!D<%fSx(fhEwy6Nk+!#Yd0*`4YMe|+p$ehz1_X;Q%=2O+7~=S!lhwX-Zt z87>s0-STaXW9;BOka2c-Im3pj>?u=z&sNgiCi*D$;o@(?o+=xdqVK3ai_?0RiMSTpGa6i#*i*f}Yl(PHmwuYJgI4rA)jb?)c~Q!J zxn^eN0t`B(5nV2+*T1ne+)gdvU#8En;DV8t|C$Z&bPj%1h%!~yia0y_z>j=wCmlH! z<=5BNuUf?@P;L+u6B9bBefm2h3$ylA<^Bi7cP&n|crT;=5c_f(*zU-9LR zb&t0mlr5|2pT@M)(2cF6e6PHKvJ^v!aH-u&rFTY_&tIhIZkb=%I(Lzme~eXC#zQN9 znP~?;t(0QjFme4SVTL(->X{q%Zk>2`%dd60Tf+V}@B}5jJ>)O;!Q7(Z&o_;Tq>8m` z!p_#}SKj@$bCOP1c)c~_fjFMUVwMasiW_uPtD9#%<*2ir-e+%Vle%bAU&De;FRt|5 zcwy%Dj8)ZP=|&fwm)VMuy{_By)gN5EmU7JH!~f9Ypg$|t+^$_>|Nob^vrF5{)mOfS zNjjgJI-FuwvhkQ2Vbs3z!cjJNS%#Zu z<|!>JUfA`6i#d*Ajc)q)2dz$hC?rIFF5n>wU0)?iN@R)yf1%$ zW^G{0liE}#tf}}a?)HxP>ekaYa z?Ugq}SC4M?8^fbV4_-0f#N84r^)JtE&GdhzdK^W5UXD|_8TK&VtUa*qq9lt&dD+&8 znpb|(1uC;||wq9`q_EUMkF4>M_?aZNXc{iVB7u`8%2(FfD3% z^f5@4{R9I8*L;H$XKoAYy*)hV?8IZo|7=T1y0IvDbE z8616JXEj~x{G~k!G7MW8A4|Mu*~6@0S>*DI_2&F5Gj`UqFnrq+xu0!;0E5E2JNjk; z>I|~RE6y#pn)Usem15YmI@MYKwHY4d@A&>b;AmAHBZKq|W;S>3;3fIa`>#ZH;cmJ~8I6i-#=$tu%pzx?-U`tm%DMi5*Xb&OIU;6K zzB#vKj=y9PNJ%+8>1>YFPyhVt6h3x`s-9zp;i)mRCBjTu?r1VFNUuAfD7sUh!GqP| zFE7JKZif9c89(+jKQJu#|0b-}+px6m;HQ&TKbJ~7yj*$U(I%763_Grtp53Q3`S7L- zm-4*=Z}u}C44CY%rQ)o7IZ<71iEzWFPE*$<#mr0(x?#7DO((HXpF1q(l%bN3Q=CYds z`sIG-((j4Z{}n#{quQ0^M`hhgFDPhB^G_1Y{ih~Z?Nd2w1?-R zeH}+X-#;+po%Y)h$Mh2|bq5vGat|>ISaPZeu`)Q!NZx|33`cu>x4|cz;dB|nAjPqA?@TQ{Vz+Y8$-_z50 zJd4aDudaIc+)`@iktsK1T0z7&&Y_PE-cye2t57d41x> zMurAw*8lJH8FK_$!Az#TEuvu$ydZ>mX6k>p!@u@o?0xqnRiQn?)5x- z#*Aek=jV~unc8+cUB-LuiEE!jmb6aG@IJ)LeK>jD&4!b0 z_9{CMtQ8Po>G;4dW&CE&vvX&<#bey{rnm6eZ>!C}D$cOr`FFMk+yBn0hHsYVX@A(s z(@-k$YWd~HZCY_}LhkM6W_tJJwBw%L?QTBS?=s)(-R?T-GIxRC&F4Iiy;$eHOWsjh z&cxu~c7@@%q^7*8tLo(N*-zxA`$;ocILk9IJdS3#Vtgy`>JLtaC32zX3cqSI@G~=r zr{`>xpOtCk67DoZvwWs*y`{_S$qv5Xh2~FW*m>_8JA+lxIsVzc)}cFmPMWlZIm|Tf zX}0^q&2ZGZr`Ta4=OvYgO@e1;w-m9nF+A?bW>DD0V6fcHsfwLpnqyeghnVF(8j6cJna?iUyG=iXTjR)* z3tJAd^fNx-+%NWN^}_l06DI8BUVJKrbal>um0=-Wg(`B=w6L}Wo3Ct0)o~LcI|3uInC!3su zD_tJk-`aL!+u@tGHL>-> z5-n?ah7-BFdl)C^cW~7+GH8A8XgO6DV|kIMz2}n0l}d&=f)*;FFRrRuJ`_pqeSW## zfQg0See^89SaoSGadlaDkETVw=d}Zb8ZL|9z7@^9U{zXRnL*)YWsAl;)k#c8k|LNI z_GAgBly%(w%XTf>*TS`UPtU9MISh<1WEi@YPcqo)D%iX-Tg0L3%2UMfptaOmJ7t;P z+|MC~Is%RNBzkJH<}BA{U}S7i>;G2cvD|3olrzppjovthD>L*kPy3zi8kbl+Paxdg z+i8xf%)G2*);SDEmQ6XGKTWtn>S)@M_4*7h*}@FM$0kgS%usm9vfw+zk;|M1?lL$0 zEcFRH{~$Q{nb)DUT5`W`zy9$#pGikzy|SmQJkRvMcey@U9G$|b^K}2>6WvzXo>Lec z^twGhJlwCt7ogJ8&RY7!NY^tqNad{H+-z)Nlpx@JDN6gA z0JK=raI>YcB_)8e|6KgR9u|Mw@8lRT907($FN&Mf}0sE)-kNn^(woZ#So$5W3|sj z`NFlsR`)kv^EvmIWx@OX>Do6 zdOYZCpSRK##)homt#!LSB#qaLGt~AvI_AdNm zI?e|qi;B;durlN}lonJ!SyMarx!RJsQ{))3Vt;i;eBHnEh{PJpfRwB`4StjF)HWVc zm&o6`dez3HIr@)k%Zn=`H6G7l`0eY<>6Tz}ip`24=g5N8YKgsu?^)y28M?xDhN> zdBy&p^ZH-fe4cZhh2fv5v%ZY#t3ydCyPK>!-!u5gGZxGZY`A}s+wDoLHLG+v1Bb(V zhJxVfX>}LUm_p0eFWeL6y2gI-lOPp!hO?}V=a>r~%(y1wms`B*%A5CxLnIzDGk8CA zb(ovChJj;x;v3;@rC}$tHlIljezS$KL(ITXi9w_8va5w2U&9w=hL`CK0{svD6(=sU zf4TkO(Z*}hq6|7q&dl~dY{Q^4*(TX!t~YObz*aM_`<<84Sgf{BlfHf9z#_$qEK{$2 z(U#Plb2#iW*S1$~u9D0N5sM~S8yz?!D;jf7O!-&Ib2lYjRnDh=W_Kjl4D)zA*XE29ZpYt=1E@pG?$U z7;gK4<-l);j>0Rl#fEZ?rhhl7$!%J-U9|6IDi0r1L!BDSwltLm$xgjiljXNBly9vv ze-_B%FwOG$#7f478B>xDrr4IV-#ZW){{Af6BemtCN=H>LUTBOC&N;_nzB@$qUg9Cr&R7{=Cql?X3EXqge-=fAmXv#b@{)-AZ`K1(7!D{N^>}nKp5a1W*#_rjg=tGp z9E{n1Z)b^bYXHN7Nmq`rIaC)FY>P|u_nGA4mnQ1UszElu}doV6ZeCo zrfd8=f~0mt9<9y19j@BMaOKaR;}=7imOl7*`MT7e{!6!Z?3DFoP&2;GZW6FT%aLiL zzT+y+sW+GQs!Uz9=>CH~hH%zLysehA^a`d;oX;7j@&C+DMlFw$8@;j#EB^g-W{8nt zsp47T_xS|tDia1)(WPscLUg>a-ShGx;yZb^;VQXuk)ZC*C=NkJqJt~Uc`}X^} zecl}fPhVY|GgFaiUif^9AI$h`Jxj$!%voV8q!e z^Zv)@!kN}57n=tj|GrFo&A&6IbESI~wBByk{Jdi?+nUpgVsf`qri7gOuquYT@$E!+ z%V^~jYUc4`hj(5LUdGOlU?#D6Z9~yzbA~VC3?_fihPTPfT#v24uX29U>hLN(h2sw$ z4(CYB)@OVn`73#woVbd!_$_V6`s-g0i(6N3QD$0jS?IXm+4v*92l(W-%7(qZ$p7Ab zflE&JN|Om?g(lVNLRJQ^)jc0|JO*9G(7>iH3rG4eSqoFfiy8ma!&G1QUH?o;p+`In=2mMpdUt;a=$Ml^TkUKi;L|D-F^_B8ezBeHdGOxr7t;YprRtAiPYJdZLuJhrsR>UzD#k|F1f)!e!*aRM`cr3LgNIxTba`(oxgWOO&(^Ihb^ZEZYhf?f-#(8uxWAj5oY!Y)=(rLf z#IT!LoF!oPLF0owej#sXnl5+K-eJkGWLCpAXB~#BI(bHe`3x#-2g>ZVPsOpMNjaWg z;8a&DslMgft0_v)TsJfrF1BYlkQMgX+;7F9!&@%ZIUkuFS)8lrGx;~4X^ zvTon-i6#BVh7yg?KRp~*7ad$XMRd&VuGcgD^&r`i|YgxiBxe0e( zI^R|Lc1Pes+gho^&vY4HY$$)mdf@P^W}&}ZFRcGqo%WxN;h60fO&_^0IpVtyHD*j| zy~Ds7t)sd}KfO`RHr~gme@?=pWuG1~FB~@O1 zJovCw=;7s-J>K?OC)ZxT+_A;z*_NZ*Vvg*zV{#}uettzlrqYCX?U=ZU6T;FLB(>PB z?m2Lc@4NWgyIfm3*tUo83LIhb>R@q@x-Y@8`SFQO9#J70ol{q{C+uQSShU8@ZmSzp z>5~ckK5=!~A5v#bEy|GKh+lB$_*v1cr*W7>bqeul2!8<-pzvKQwDYfNpQ$nCP3!NP)3V*APYi~&~9sMq- zMtq4e%&k?py>i>PMJLmRQZovA*T_#0)#csXM6o${== z@mzrn3*K#u?ysmY``b~h-K=RApZn7|W7+(!^sMivIj^xZ%qmTc{`^?5V7kI`Wrxxg zL1&c?@HtK0`hwN#mE{LrmjB&tDkgJ}TG>S>OW*!uvEDZ{Li510RU17YWH>F~zi;Ma z%im6kTutw0JWQI)-IaUm!uPz>8hLs;`+v4iZ#et;Z;)0sGef5)Pjw1Iz>cSNJ6SBP zr(1HhsF*+Mb+*|YBK%{=(>W=3ReQpn7;=7cF-SMwgCN6%#%RU|M^3jrTqc=}k}$yudhN*S&<5f;Sin_qXxg{Wfh))}};*l}8s9Fx=qR zzRav9uwHcO#eEjvMRL-s!@SMDdtWvG`!s8%KEsX8hqfKrcjflIGY;p(RL(dY%}jqc z@miKRL&H(&8o7o5UD4}Zb?gTMpZ(o=ns3g^t({k{U)ZH6UJ^X|XUPKeqs_w(v|{(rIzZB5M9#{W2WSnU!2eYb?uq1wmF_ql?9FYAHil|G^c zdEJ4hubamHxwWkKO~H!bQwJrCyY`7FmP(lJy?tw0^MihdH!e0?&99wMxt15SNRDA; z_xd>=zHgUzJvd-^{N46hj`?mAKKlC23@JRY^}VGNfm47WXxsz8L%dpb0^~m5A_+d?rDF$ z%{XD#uCN91(>}eN{AZ292X%%C<)1fu^L*IDvc5q;KIP$>w0X)OZmi|x+;^3Co=!@q zqI0aI*!zoC3>7wfdGAw;H`++p^~41s=MM`>8!Slc}c0N zRadUeGG*w|CowWEINT6w_rNx2y@Qi) zYJKbhy-Q8IawTi&-v7|-53Jm_r^GO>KxbLMgM zinT>TQ&dj7GN>$eXJBaf&~ec7QpOFN;`h9@DId-)QPE)$;SK6rGgq;1qRf)1h070U z#rl2!^Nt~9qx|b)83}fW@7W9<>Q;;ipO36bc*6GY)1Hj`Ldmll+0PuHSiAlMO?|w$0LsQqgyAhCjF>VVb0PYKfWNw60d2pEtVF-pZM1Genj0bFUEX z5m_mi{aHli0po;<7i;+6`RlK){=8mQ#g<|2^GOqr1ZOCaW@-9&J4& z%#=I5<6P_0bld!L29y5`4&{sqN!)wIh2LbcwXK%Ck-=tW(BV8i^qqNUXWS=t#s#3_9Qo$0F47UmZ$uWwDfbS|xPceEBu_hou4d0ED`RBgbp|aA?xIm5dosdXKD0?@*wMFR7-Jx|Wn}T;I zpUU4FD=p*f{V>i+!SurFazF8)g3P!Le*#*SIPZV`6KnI}r{%sfE~8tmR}{=rCETqU z=B|8ZDHm}0@8Qq!{SCio-x9dDS?6~h+ZoXvM`B;yH)zpqxwNzW`?1`b%7?qYKicqQ zQB`E^{TqHKgt(u)m3kezhfUK$s5>+NW}ozyrThE?x@FaALj#9yq^UvJ=)~{OqT+u~=k4&w`eQ+_%fJx$9mp&B=OKcJ|AkWzTaaP01@{dtUhSj~U;| zBj2`8+Gj1E%evp1W&QE%NrhWJY;`kQ8MpnxT8Ff%pC7)tb_Pm(vE6n1^4nx>^Xo@* zWsjcY707PB)y8_~#ixz{w`ysztEUPB67vu4lkUA=r}ii(^c|Ai2h zGm8(MuyuHwf4FUrf#jVX?z^{otT=qGbn~6KoqjJgABH7bqza{~+J0wCspHvf=J;vl z&;3jb68Yszv(*^`V-GR9tCs%`ismv`sElep_EysA(Y5YO9mSc#jNDp*DlY^D{dP}c z6!B2ho*~-mmbYc%;-hKV8g5sLeT>BZIT+u*b6(LZPp5s=4yD?&rTaMo-B$m6&+ul+ zmDd~{s?l?&eYmRi(R;}WQ^&k3ZZFTq&bNFu_totARYE-`_qTk?4b7iW^>9`~*n;g^ z&V{?rti8AW=$*)>mo_UB-}<#)xRxftcKo)~%6Fe%-~0cYu|RoBR8^YIL-YI}Z4IYB ztHdr$jhM^uK=k*srHjK_p6xZ^WN`h#^=f_fnKJn)8y-iUKiB6FH<{UBLdA{9i|aOS zod4x(s=^M_sQ=*%9&$+D;r-sJ`3y7WOq=@scd-A8bVE)d zMvoI+#zt)QjeEwp_|MwD8Zk)*O`uhJpSG6aG zr5;b^K7ZsyP;xz+PNDOiDb@@Zet%||b2WGUk}KVuoJtWpb7tLaI`t|pFh=CF_Jl>+ z2NKwLxL(J5p8EQ_CFz$v+XGL#w%tel_>M1SU9Pz2_t8wbh6hXs4woLdFL2=zM_a$( z8FPiK12uB8RH3>H1mWb}Afcj3B};deLXhL0;1J_yURHOy@~cVdn_ z!;cSZe%t2?|A>mV_RabJ>C!xB;m*~<(d(Z)6rEcT@F8Gt{4TCVbEXIH+7kR{%2l=F zopC{`GUD6&`l^Me6+L6*`*Y;9wu|`lzkkB}k7O^u@_DV=jlbWO6Vxs5uq_w8{A_zUS`KesnPUfnHvWr&y&$^RaJNPo2_jzK|E& zvSp&TaG03T{;u=!nYV7&&y9R))yea=xw9^fB&D8VrJkA=;4w&}gl8)iS z9mk~^Ui=T=X7Kjt`pVMJW{d}lX08_XNKJ3`^Rld;yx`6A&-4F3z4zaJp-Z$E-_-N} zYglq#)*gH7xX$VO2FJ=MrgF|d4C?>xA9yq&cg~cr0`t$B9l3LU!A0|usSY#pwrTBt zvwwl`WchlJOM1clmnz?#b6mjB{@_B{-YviXGcu@t3D-Wd%eub&<;AL%f>9?<-@3rb zkdbi9I3VVi=JaW04{x1a?!;z!;(OAc!tm`c_eCz*HQ)Q@|NT1}V|Qtl*v~Z!_9zqx`RH@9iSZYITwNct=Vy>W&r}XEzRg$si_QKg-kulfIQjCY%!oCz zN_$w}3EjA*?Pe%*P>G?hhF5!shxo5jpO_mNZ`K`M%EiYbaDDNY?~#9&G9`$9jF>uU z%SXY7`|}poGaCF}b9$HljwBDkKpoqi%3(~)=cPxhtrt#sIU(#w%-y3!f=tz-{Wra} zkAGo5JE#A;RmIiK^XuAMqj@dQMm2xUw-(!@u{t{B+TJ9=8Am6bzMwL<^j)2dMQ2RQ z*SE9Wb7U^O|6R_q&gA;o5OCKXD{b# zD<5pHJ1IRWcFN?R8?9co+^+97OB9VS>p#DTS!a0#%b9of_fEVEXIS**y7tF1^%=*n zs=MF1nW>(bKCSK9oxjDg3O}ysS6;p8`6}B|E5mB1Tw`nU@9nR7%8puZ*eN@E_V=1| zulDP51#;{D)Lf}pu>Stk)4sbEHiyRMJv{r+oVVWE{Hrm;Jvn=e+{5eE2~G`-+26BH zHl@vQZ)`=m(2daKBkeqgi+1f>&23^nEBxbm1`GN5k^R}bH@`GVTQ>cwuUx}VV}{@M zWjyzlQi^tKs!faTJibZ#+r?KunGT#&-e4igv72RWzVtrD1cQWE8viWUrY;Z4corsl z?Ui)5&NRvBglQ^2!lj?rXNr7#7Oa!_=XAV zERa61Bj@|${?_CDH&oZoc`((q$90B5T-CIny2}pkXI{|p`EtA<_quK##_u^PXB~h3 zVr?j7*A5SRXX}+0{YjeX8$TOU@#n>>Pfl_-n{{mZdDZhvQw6unmaN(;7r!PpZ8dX zXO@8Vd$tC)wLTNwtLMLvuw!NN{hrJ)ubxFA;b6(e(vDSy0sAuY^4`xk>C;i)V*jXY zLcD9CK7)be4^DL>I@(LUO(mfmce67MCYn~=IReu1mwwZ4XmHEjey7JkaqsNjySpBWJH9POu)YW@e1=Ri1h|)+= zUYfM++fC7i1Ak{8d8_cZ=fKyWH)U_ETKv27e>-b{n3BB1JcH7=`V0Yq%teVY;``%u zZrwEcnHlkd@rRMa_M(}$)Vi-$Y?!W-trvd4rAKY1 0) + { + #if (!defined(NO_SM4) || defined(DOOMLIGHT)) && !defined SOFTLIGHT + // special lighting mode 'Doom' not available on older cards for performance reasons. + if (fogdist < fogparm.y) + { + color.rgb *= fogparm.x - (fogdist / fogparm.y) * (fogparm.x - 1.0); + } + #endif + + //color = vec4(color.rgb * (1.0 - fogfactor), color.a); + color.rgb = mix(vec3(0.0, 0.0, 0.0), color.rgb, fogfactor); + } + #endif + + #ifndef NO_GLOW + // + // handle glowing walls + // + if (topglowcolor.a > 0.0 && glowdist.x < topglowcolor.a) + { + color.rgb += desaturate(topglowcolor * (1.0 - glowdist.x / topglowcolor.a)).rgb; + } + if (bottomglowcolor.a > 0.0 && glowdist.y < bottomglowcolor.a) + { + color.rgb += desaturate(bottomglowcolor * (1.0 - glowdist.y / bottomglowcolor.a)).rgb; + } + color = min(color, 1.0); + #endif + + // calculation of actual light color is complete. + return color; +} + +//=========================================================================== +// +// Gets a texel and performs common manipulations +// +//=========================================================================== + +vec4 getTexel(vec2 st) +{ + vec4 texel = texture2D(tex, st); + + #ifndef NO_TEXTUREMODE + // + // Apply texture modes + // + if (texturemode == 2) + { + texel.a = 1.0; + } + else if (texturemode == 1) + { + texel.rgb = vec3(1.0,1.0,1.0); + } + #endif + + return desaturate(texel); +} + +//=========================================================================== +// +// Applies colored fog +// +//=========================================================================== + +#ifndef NO_FOG +vec4 applyFog(vec4 frag, float fogfactor) +{ + return vec4(mix(fogcolor.rgb, frag.rgb, fogfactor), frag.a); +} +#endif + + +//=========================================================================== +// +// Main shader routine +// +//=========================================================================== + +void main() +{ + float fogdist = 0.0; + float fogfactor = 0.0; + + #ifdef DYNLIGHT + vec4 dynlight = vec4(0.0,0.0,0.0,0.0); + vec4 addlight = vec4(0.0,0.0,0.0,0.0); + #endif + + #ifndef NO_FOG + // + // calculate fog factor + // + if (fogenabled != 0) + { + #ifndef NO_SM4 + if (fogenabled == 1 || fogenabled == -1) + { + fogdist = pixelpos.w; + } + else + { + fogdist = max(16.0, distance(pixelpos.xyz, camerapos)); + } + #elif !defined(FOG_RADIAL) + fogdist = pixelpos.w; + #else + fogdist = max(16.0, distance(pixelpos.xyz, camerapos)); + #endif + fogfactor = exp2 (fogparm.z * fogdist); + } + #endif + + vec4 frag = getLightColor(fogdist, fogfactor); + + + #ifdef DYNLIGHT + for(int i=0; i Date: Sun, 23 Jun 2013 13:35:00 +0200 Subject: [PATCH 0007/1509] - remove d_dehackedactions.h from .prj file. --- gzdoom.vcproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gzdoom.vcproj b/gzdoom.vcproj index 46e600254..9a19b1636 100644 --- a/gzdoom.vcproj +++ b/gzdoom.vcproj @@ -1168,10 +1168,6 @@ RelativePath=".\src\d_dehacked.h" > - - From 4500145ef9ad622ec2705ecb18e70464671aeb39 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 23 Jun 2013 14:36:26 +0200 Subject: [PATCH 0008/1509] - forgot to add wadsrc_lights and wadsrc_bm projects to solution. --- .gitignore | 2 +- gzdoom.sln | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 822d07fb2..a388a5ae8 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,4 @@ /tools/*/*.exe /tools/lemon/build /tools/re2c/build -/wadsrc/*.pk3 +/wadsrc*/*.pk3 diff --git a/gzdoom.sln b/gzdoom.sln index 16d1acc3d..c87c648e9 100644 --- a/gzdoom.sln +++ b/gzdoom.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gzdoom", "gzdoom.vcproj", "{8049475B-5C87-46F9-9358-635218A4EF18}" +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zdoom", "gzdoom.vcproj", "{8049475B-5C87-46F9-9358-635218A4EF18}" ProjectSection(ProjectDependencies) = postProject {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96} = {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96} {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} @@ -27,6 +27,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wadsrc", "wadsrc\wadsrc.vcp {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} = {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wadsrc-brightmaps", "wadsrc_bm\brightmaps.vcproj", "{087B206F-F49E-4EFB-92CB-E1F6E32D1278}" + ProjectSection(ProjectDependencies) = postProject + {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} = {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wadsrc-lights", "wadsrc_lights\lights.vcproj", "{31090871-A623-4BBC-A167-DE821CD1240C}" + ProjectSection(ProjectDependencies) = postProject + {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} = {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "updaterevision", "tools\updaterevision\updaterevision.vcproj", "{6077B7D6-349F-4077-B552-3BC302EF5859}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jpeg-6b", "jpeg-6b\jpeg-6b.vcproj", "{AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}" @@ -98,6 +108,18 @@ Global {1D179D4B-F008-431B-8C72-111F8372584F}.Release|Win32.Build.0 = Release|Win32 {1D179D4B-F008-431B-8C72-111F8372584F}.Release|x64.ActiveCfg = Release|Win32 {1D179D4B-F008-431B-8C72-111F8372584F}.Release|x64.Build.0 = Release|Win32 + {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Debug|Win32.ActiveCfg = Debug|Win32 + {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Debug|Win32.Build.0 = Debug|Win32 + {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Debug|x64.ActiveCfg = Debug|Win32 + {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Release|Win32.ActiveCfg = Release|Win32 + {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Release|Win32.Build.0 = Release|Win32 + {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Release|x64.ActiveCfg = Release|Win32 + {31090871-A623-4BBC-A167-DE821CD1240C}.Debug|Win32.ActiveCfg = Debug|Win32 + {31090871-A623-4BBC-A167-DE821CD1240C}.Debug|Win32.Build.0 = Debug|Win32 + {31090871-A623-4BBC-A167-DE821CD1240C}.Debug|x64.ActiveCfg = Debug|Win32 + {31090871-A623-4BBC-A167-DE821CD1240C}.Release|Win32.ActiveCfg = Release|Win32 + {31090871-A623-4BBC-A167-DE821CD1240C}.Release|Win32.Build.0 = Release|Win32 + {31090871-A623-4BBC-A167-DE821CD1240C}.Release|x64.ActiveCfg = Release|Win32 {6077B7D6-349F-4077-B552-3BC302EF5859}.Debug|Win32.ActiveCfg = Debug|Win32 {6077B7D6-349F-4077-B552-3BC302EF5859}.Debug|Win32.Build.0 = Debug|Win32 {6077B7D6-349F-4077-B552-3BC302EF5859}.Debug|x64.ActiveCfg = Debug|x64 From 3da7dcea035efe43cd9086fcddf11f5ed2d7a34e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 23 Jun 2013 14:52:21 +0200 Subject: [PATCH 0009/1509] - this is version 1.8.1. --- src/version.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/version.h b/src/version.h index 8f3c8e8a0..a8975bd98 100644 --- a/src/version.h +++ b/src/version.h @@ -41,12 +41,12 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "1.9pre" +#define VERSIONSTR "1.8.1" // The version as seen in the Windows resource -#define RC_FILEVERSION 1,8,9999,0 -#define RC_PRODUCTVERSION 1,8,9999,0 -#define RC_PRODUCTVERSION2 "1.9pre" +#define RC_FILEVERSION 1,8,1,0 +#define RC_PRODUCTVERSION 1,8,1,0 +#define RC_PRODUCTVERSION2 "1.8.1" // Version identifier for network games. // Bump it every time you do a release unless you're certain you From 46d203a9298b35288b979d76eedea8798a661a04 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 24 Jun 2013 00:59:57 +0200 Subject: [PATCH 0010/1509] - removed unused variable wgl_extensions. --- src/gl/system/gl_interface.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index e3234e947..41e09ebd5 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -214,7 +214,6 @@ static bool ReadInitExtensions() // // //========================================================================== -const char *wgl_extensions; static void CollectExtensions() { From d65af4b5bbee8cbe774d0e767a80c058887fa28f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 26 Jun 2013 20:22:52 +0200 Subject: [PATCH 0011/1509] - fixed updaterevision calls in VC project. - put back a clean version file into the maintenance branch. --- gzdoom.vcproj | 8 ++++---- src/version.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gzdoom.vcproj b/gzdoom.vcproj index 9a19b1636..e24992960 100644 --- a/gzdoom.vcproj +++ b/gzdoom.vcproj @@ -29,7 +29,7 @@ Date: Wed, 26 Jun 2013 19:01:00 -0400 Subject: [PATCH 0012/1509] - Fixed compilation on non-Windows systems by removing dependency on src/Linux/platform.h --- src/gl/models/gl_models_md2.cpp | 4 ++-- src/gl/system/gl_interface.h | 5 +++++ src/gl/system/gl_system.h | 1 - src/gl/system/gl_wipe.cpp | 13 +++++++++++++ src/gl/textures/gl_hirestex.cpp | 4 ++-- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index 95a344c6e..1ff98629d 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -176,7 +176,7 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length) // Translate each vertex. for(k = 0, pVtx = pfr->vertices; k < info.numVertices; k++, pVtx++) { - UnpackVector(USHORT(pVtx->normal), frame->normals[k].xyz); + UnpackVector((unsigned short)(pVtx->normal), frame->normals[k].xyz); for(c = 0; c < 3; c++) { frame->vertices[k].xyz[axis[c]] = @@ -208,7 +208,7 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length) for(i = 0; i < info.numLODs; i++) for(k = 0; k < lodInfo[i].numTriangles; k++) for(c = 0; c < 3; c++) - vertexUsage[SHORT(triangles[i][k].vertexIndices[c])] |= 1 << i; + vertexUsage[short(triangles[i][k].vertexIndices[c])] |= 1 << i; loaded=true; return true; diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 8766ebcfa..3d54bf8f6 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -5,6 +5,11 @@ #define APIENTRY #endif // __APPLE__ +#include "basictypes.h" +#ifndef _WIN32 +typedef bool BOOL; +#endif + #ifndef PFNGLMULTITEXCOORD2FPROC typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); #endif diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h index d48b55976..5dc6cf5b5 100644 --- a/src/gl/system/gl_system.h +++ b/src/gl/system/gl_system.h @@ -88,7 +88,6 @@ inline T max( T a, T b) { return (((a)>(b)) ? (a) : (b)); } #define _access(a,b) access(a,b) #endif #ifndef _WIN32 -#include "platform.h" #include #endif #include "gl/system/gl_interface.h" diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index f9f73a4ea..83f5abd82 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -56,6 +56,19 @@ #include "gl/textures/gl_material.h" #include "gl/utility/gl_templates.h" +#ifndef _WIN32 +struct POINT { + SDWORD x; + SDWORD y; +}; +struct RECT { + SDWORD left; + SDWORD top; + SDWORD right; + SDWORD bottom; +}; +#endif + EXTERN_CVAR(Bool, gl_vid_compatibility) //=========================================================================== diff --git a/src/gl/textures/gl_hirestex.cpp b/src/gl/textures/gl_hirestex.cpp index 423a783fb..b7824bf11 100644 --- a/src/gl/textures/gl_hirestex.cpp +++ b/src/gl/textures/gl_hirestex.cpp @@ -56,8 +56,8 @@ #include "d_main.h" #include "zstring.h" -#ifdef __GNUC__ -#include "Linux/platform.h" /* Without this it would fail on _access on line 374 (378 now) */ +#ifndef _WIN32 +#define _access(a,b) access(a,b) #endif static int Doom2Wad = -1; From b35422376eb38fa508c6c7a18c3c9ddf50f254b3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 27 Jun 2013 20:03:05 +0200 Subject: [PATCH 0013/1509] - add brightmaps.pk3 and lights.pk3 to VC++ 64bit confguration. --- gzdoom.sln | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gzdoom.sln b/gzdoom.sln index c87c648e9..181f28c08 100644 --- a/gzdoom.sln +++ b/gzdoom.sln @@ -111,15 +111,19 @@ Global {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Debug|Win32.ActiveCfg = Debug|Win32 {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Debug|Win32.Build.0 = Debug|Win32 {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Debug|x64.ActiveCfg = Debug|Win32 + {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Debug|x64.Build.0 = Debug|Win32 {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Release|Win32.ActiveCfg = Release|Win32 {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Release|Win32.Build.0 = Release|Win32 {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Release|x64.ActiveCfg = Release|Win32 + {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Release|x64.Build.0 = Release|Win32 {31090871-A623-4BBC-A167-DE821CD1240C}.Debug|Win32.ActiveCfg = Debug|Win32 {31090871-A623-4BBC-A167-DE821CD1240C}.Debug|Win32.Build.0 = Debug|Win32 {31090871-A623-4BBC-A167-DE821CD1240C}.Debug|x64.ActiveCfg = Debug|Win32 + {31090871-A623-4BBC-A167-DE821CD1240C}.Debug|x64.Build.0 = Debug|Win32 {31090871-A623-4BBC-A167-DE821CD1240C}.Release|Win32.ActiveCfg = Release|Win32 {31090871-A623-4BBC-A167-DE821CD1240C}.Release|Win32.Build.0 = Release|Win32 {31090871-A623-4BBC-A167-DE821CD1240C}.Release|x64.ActiveCfg = Release|Win32 + {31090871-A623-4BBC-A167-DE821CD1240C}.Release|x64.Build.0 = Release|Win32 {6077B7D6-349F-4077-B552-3BC302EF5859}.Debug|Win32.ActiveCfg = Debug|Win32 {6077B7D6-349F-4077-B552-3BC302EF5859}.Debug|Win32.Build.0 = Debug|Win32 {6077B7D6-349F-4077-B552-3BC302EF5859}.Debug|x64.ActiveCfg = Debug|x64 From 28fd035b22aa9df0436e86766c93beb83ba4a7ed Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 28 Jun 2013 11:02:55 +0300 Subject: [PATCH 0014/1509] * fix build on OS X via CMake --- src/CMakeLists.txt | 20 ++++++++++++++++++++ src/gl/system/gl_interface.h | 1 + src/sdl/iwadpicker_cocoa.mm | 4 ++-- src/sdl/sdlglvideo.cpp | 4 +++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 50c5f5b22..dbca574b1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -371,6 +371,20 @@ if( NOT NO_ASM ) ENDMACRO( ADD_ASM_FILE ) endif( NOT NO_ASM ) +# OpenGL on OS X: Search for GLEW include files + +if( APPLE ) + find_path( GLEW_INCLUDE_DIR GL/glew.h + PATHS "/usr/include" + "/usr/local/include" ) + + if( GLEW_INCLUDE_DIR ) + message( STATUS "GLEW include files found at ${GLEW_INCLUDE_DIR}" ) + else( GLEW_INCLUDE_DIR ) + message( SEND_ERROR "Could not find GLEW include files" ) + endif( GLEW_INCLUDE_DIR ) +endif( APPLE ) + # Decide on SSE setup set( SSE_MATTERS NO ) @@ -522,6 +536,12 @@ if( FLUIDSYNTH_FOUND ) endif( NOT DYN_FLUIDSYNTH ) endif( FLUIDSYNTH_FOUND ) +# OpenGL on OS X: GLEW include directory + +if( APPLE ) + include_directories( "${GLEW_INCLUDE_DIR}" ) +endif( APPLE ) + # Start defining source files for ZDoom if( WIN32 ) diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 3d54bf8f6..a6c583343 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -3,6 +3,7 @@ #if defined(__APPLE__) #define APIENTRY +#define APIENTRYP * #endif // __APPLE__ #include "basictypes.h" diff --git a/src/sdl/iwadpicker_cocoa.mm b/src/sdl/iwadpicker_cocoa.mm index 1a1fa8b8c..45f0d1a8f 100644 --- a/src/sdl/iwadpicker_cocoa.mm +++ b/src/sdl/iwadpicker_cocoa.mm @@ -156,14 +156,14 @@ static const char* const tableHeaders[NUM_COLUMNS] = { "IWAD", "Game" }; cancelled = false; app = [NSApplication sharedApplication]; - id windowTitle = [NSString stringWithUTF8String:GAMESIG " " DOTVERSIONSTR ": Select an IWAD to use"]; + id windowTitle = [NSString stringWithFormat:@"%s %s", GAMESIG, GetVersionString()]; NSRect frame = NSMakeRect(0, 0, 440, 450); window = [[NSWindow alloc] initWithContentRect:frame styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO]; [window setTitle:windowTitle]; NSTextField *description = [[NSTextField alloc] initWithFrame:NSMakeRect(22, 379, 412, 50)]; - [self makeLabel:description:"ZDoom found more than one IWAD\nSelect from the list below to determine which one to use:"]; + [self makeLabel:description:"GZDoom found more than one IWAD\nSelect from the list below to determine which one to use:"]; [[window contentView] addSubview:description]; [description release]; diff --git a/src/sdl/sdlglvideo.cpp b/src/sdl/sdlglvideo.cpp index 6378381e4..9ee54b4e8 100644 --- a/src/sdl/sdlglvideo.cpp +++ b/src/sdl/sdlglvideo.cpp @@ -321,7 +321,9 @@ SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen) #if defined(__APPLE__) // Need to set title here because a window is not created yet when calling the same function from main() - SDL_WM_SetCaption( GAMESIG " " DOTVERSIONSTR " (" __DATE__ ")", NULL ); + char caption[100]; + mysnprintf(caption, countof(caption), GAMESIG " %s (%s)", GetVersionString(), GetGitTime()); + SDL_WM_SetCaption(caption, NULL); #endif // __APPLE__ } From 97bccb5239b96aad185ab85b296afe1ffbdb0441 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 2 Jul 2013 10:02:38 +0200 Subject: [PATCH 0015/1509] - adjusted CMakeLists.txt for brightmaps.pk3 and lights.pk3 to same style as for gzdoom.pk3 --- wadsrc_bm/CMakeLists.txt | 8 +------- wadsrc_lights/CMakeLists.txt | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/wadsrc_bm/CMakeLists.txt b/wadsrc_bm/CMakeLists.txt index b79de7138..a76c5dc36 100644 --- a/wadsrc_bm/CMakeLists.txt +++ b/wadsrc_bm/CMakeLists.txt @@ -1,9 +1,3 @@ cmake_minimum_required( VERSION 2.4 ) -add_custom_command( OUTPUT ${ZDOOM_OUTPUT_DIR}/brightmaps.pk3 - COMMAND ${CMAKE_BINARY_DIR}/tools/zipdir/zipdir ${ZDOOM_OUTPUT_DIR}/brightmaps.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static ${CMAKE_CURRENT_BINARY_DIR}/generated - DEPENDS zipdir ${CMAKE_CURRENT_SOURCE_DIR}/static ) - -add_custom_target( brightmaps_pk3 ALL - DEPENDS ${ZDOOM_OUTPUT_DIR}/brightmaps.pk3 ) - +add_pk3(brightmaps.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static) diff --git a/wadsrc_lights/CMakeLists.txt b/wadsrc_lights/CMakeLists.txt index 6bdb11e92..92f89314a 100644 --- a/wadsrc_lights/CMakeLists.txt +++ b/wadsrc_lights/CMakeLists.txt @@ -1,9 +1,3 @@ cmake_minimum_required( VERSION 2.4 ) -add_custom_command( OUTPUT ${ZDOOM_OUTPUT_DIR}/lights.pk3 - COMMAND ${CMAKE_BINARY_DIR}/tools/zipdir/zipdir ${ZDOOM_OUTPUT_DIR}/lights.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static ${CMAKE_CURRENT_BINARY_DIR}/generated - DEPENDS zipdir ${CMAKE_CURRENT_SOURCE_DIR}/static ) - -add_custom_target( lights_pk3 ALL - DEPENDS ${ZDOOM_OUTPUT_DIR}/lights.pk3 ) - +add_pk3(lights.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static) From 4e4eb7189a1c076e04e2e1928a8ac7b75e923277 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 22 Jul 2013 17:30:08 +0200 Subject: [PATCH 0016/1509] - fixed: negative extra light levels should not be treated like inverse flashes, that's only the case for INT_MIN. --- src/gl/scene/gl_scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 99660267c..072d3408c 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -813,7 +813,7 @@ void FGLRenderer::SetFixedColormap (player_t *player) player_t * cplayer = player->camera->player; if (cplayer) { - if (cplayer->extralight<0) + if (cplayer->extralight == INT_MIN) { gl_fixedcolormap=CM_FIRSTSPECIALCOLORMAP + INVERSECOLORMAP; extralight=0; From 62fd6c8e7456bb0152881b8b35ba3f76e7ff11fd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Aug 2013 23:12:21 +0200 Subject: [PATCH 0017/1509] - fixed: light values read from 3D floor light lists for lighting sprites were not clamped to [0..255]. --- src/gl/scene/gl_sprite.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 2fd250f93..8150bf17d 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -346,23 +346,19 @@ void GLSprite::SplitSprite(sector_t * frontsector, bool translucent) bool put=false; TArray & lightlist=frontsector->e->XFloor.lightlist; - //y1+=y; - //y2+=y; - //y=0; for(i=0;ix,actor->y); else lightbottom=frontsector->floorplane.ZatPoint(actor->x,actor->y); - //maplighttop=FIXED2FLOAT(lightlist[i].height); maplightbottom=FIXED2FLOAT(lightbottom); if (maplightbottom Date: Fri, 9 Aug 2013 23:38:30 +0200 Subject: [PATCH 0018/1509] - fixed: Dynamic lights may not execute their tick() function when the software renderer is active. --- src/gl/dynlights/a_dynlight.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 731b4dfd2..80dc4e543 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -52,6 +52,7 @@ EXTERN_CVAR (Float, gl_lights_size); EXTERN_CVAR (Bool, gl_lights_additive); +EXTERN_CVAR(Int, vid_renderer) //========================================================================== @@ -218,7 +219,10 @@ void ADynamicLight::Deactivate(AActor *activator) //========================================================================== void ADynamicLight::Tick() { - + if (vid_renderer == 0) + { + return; + } if (IsOwned()) { if (!target || !target->state) From b59d82ad5b6b2807240ae318d9085da9cf97448d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 18 Aug 2013 12:38:38 +0200 Subject: [PATCH 0019/1509] - made win32gliface.cpp more readable. --- src/win32/win32gliface.cpp | 150 +++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index ebe9e10c6..af6bf42cd 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -33,6 +33,12 @@ RenderContext gl; EXTERN_CVAR(Bool, gl_vid_compatibility) EXTERN_CVAR(Int, vid_refreshrate) +//========================================================================== +// +// +// +//========================================================================== + Win32GLVideo::Win32GLVideo(int parm) : m_Modes(NULL), m_IsFullscreen(false) { #ifdef _WIN32 @@ -50,16 +56,34 @@ Win32GLVideo::Win32GLVideo(int parm) : m_Modes(NULL), m_IsFullscreen(false) } +//========================================================================== +// +// +// +//========================================================================== + Win32GLVideo::~Win32GLVideo() { FreeModes(); if (GLRenderer != NULL) GLRenderer->FlushTextures(); } +//========================================================================== +// +// +// +//========================================================================== + void Win32GLVideo::SetWindowedScale(float scale) { } +//========================================================================== +// +// +// +//========================================================================== + struct MonitorEnumState { int curIdx; @@ -89,6 +113,12 @@ static BOOL CALLBACK GetDisplayDeviceNameMonitorEnumProc(HMONITOR hMonitor, HDC, return TRUE; } +//========================================================================== +// +// +// +//========================================================================== + void Win32GLVideo::GetDisplayDeviceName() { // If anything goes wrong, anything at all, everything uses the primary @@ -121,6 +151,12 @@ void Win32GLVideo::GetDisplayDeviceName() } } +//========================================================================== +// +// +// +//========================================================================== + void Win32GLVideo::MakeModesList() { ModeInfo *pMode, *nextmode; @@ -153,6 +189,12 @@ void Win32GLVideo::MakeModesList() } } +//========================================================================== +// +// +// +//========================================================================== + void Win32GLVideo::StartModeIterator(int bits, bool fs) { m_IteratorMode = m_Modes; @@ -162,6 +204,12 @@ void Win32GLVideo::StartModeIterator(int bits, bool fs) m_IteratorFS = fs; } +//========================================================================== +// +// +// +//========================================================================== + bool Win32GLVideo::NextMode(int *width, int *height, bool *letterbox) { if (m_IteratorMode) @@ -184,6 +232,12 @@ bool Win32GLVideo::NextMode(int *width, int *height, bool *letterbox) return false; } +//========================================================================== +// +// +// +//========================================================================== + void Win32GLVideo::AddMode(int x, int y, int bits, int baseHeight, int refreshHz) { ModeInfo **probep = &m_Modes; @@ -213,6 +267,12 @@ void Win32GLVideo::AddMode(int x, int y, int bits, int baseHeight, int refreshHz (*probep)->next = probe; } +//========================================================================== +// +// +// +//========================================================================== + void Win32GLVideo::FreeModes() { ModeInfo *mode = m_Modes; @@ -227,6 +287,12 @@ void Win32GLVideo::FreeModes() m_Modes = NULL; } +//========================================================================== +// +// +// +//========================================================================== + bool Win32GLVideo::GoFullscreen(bool yes) { m_IsFullscreen = yes; @@ -258,6 +324,12 @@ bool Win32GLVideo::GoFullscreen(bool yes) } +//========================================================================== +// +// +// +//========================================================================== + DFrameBuffer *Win32GLVideo::CreateFrameBuffer(int width, int height, bool fs, DFrameBuffer *old) { Win32GLFrameBuffer *fb; @@ -302,6 +374,12 @@ DFrameBuffer *Win32GLVideo::CreateFrameBuffer(int width, int height, bool fs, DF return fb; } +//========================================================================== +// +// +// +//========================================================================== + bool Win32GLVideo::SetResolution (int width, int height, int bits) { if (GLRenderer != NULL) GLRenderer->FlushTextures(); @@ -316,6 +394,12 @@ bool Win32GLVideo::SetResolution (int width, int height, int bits) return true; // We must return true because the old video context no longer exists. } +//========================================================================== +// +// +// +//========================================================================== + struct DumpAdaptersState { unsigned index; @@ -359,6 +443,12 @@ static BOOL CALLBACK DumpAdaptersMonitorEnumProc(HMONITOR hMonitor, HDC, LPRECT, return TRUE; } +//========================================================================== +// +// +// +//========================================================================== + void Win32GLVideo::DumpAdapters() { DumpAdaptersState das; @@ -369,8 +459,20 @@ void Win32GLVideo::DumpAdapters() EnumDisplayMonitors(0, 0, DumpAdaptersMonitorEnumProc, LPARAM(&das)); } +//========================================================================== +// +// +// +//========================================================================== + IMPLEMENT_ABSTRACT_CLASS(Win32GLFrameBuffer) +//========================================================================== +// +// +// +//========================================================================== + Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : BaseWinFB(width, height) { static int localmultisample=-1; @@ -448,6 +550,12 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in ReleaseDC(Window, hDC); } +//========================================================================== +// +// +// +//========================================================================== + Win32GLFrameBuffer::~Win32GLFrameBuffer() { if (m_supportsGamma) @@ -470,16 +578,34 @@ Win32GLFrameBuffer::~Win32GLFrameBuffer() } +//========================================================================== +// +// +// +//========================================================================== + void Win32GLFrameBuffer::InitializeState() { } +//========================================================================== +// +// +// +//========================================================================== + bool Win32GLFrameBuffer::CanUpdate() { if (!AppActive) return false; return true; } +//========================================================================== +// +// +// +//========================================================================== + void Win32GLFrameBuffer::SetGammaTable(WORD *tbl) { HDC hDC = GetDC(Window); @@ -487,6 +613,12 @@ void Win32GLFrameBuffer::SetGammaTable(WORD *tbl) ReleaseDC(Window, hDC); } +//========================================================================== +// +// +// +//========================================================================== + bool Win32GLFrameBuffer::Lock(bool buffered) { m_Lock++; @@ -509,6 +641,12 @@ bool Win32GLFrameBuffer::IsLocked () return m_Lock>0;// true; } +//========================================================================== +// +// +// +//========================================================================== + bool Win32GLFrameBuffer::IsFullscreen() { return m_Fullscreen; @@ -546,11 +684,23 @@ void Win32GLFrameBuffer::ReleaseResources () { } +//========================================================================== +// +// +// +//========================================================================== + void Win32GLFrameBuffer::SetVSync (bool vsync) { if (gl.SetVSync!=NULL) gl.SetVSync(vsync); } +//========================================================================== +// +// +// +//========================================================================== + void Win32GLFrameBuffer::NewRefreshRate () { if (m_Fullscreen) From 761ab4ab78cae79715a17c1cd0958735556ac2fb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 18 Aug 2013 14:16:33 +0200 Subject: [PATCH 0020/1509] - moved all system specific code out of gl_interface.cpp into the respective Video classes (Win32GLVideo andSDLGLVideo.) (SDL side not tested yet!) --- gzdoom.vcproj | 782 ++++++++++++++++--------------- src/gl/system/gl_framebuffer.cpp | 4 +- src/gl/system/gl_interface.cpp | 558 +--------------------- src/gl/system/gl_interface.h | 12 - src/gl/system/gl_system.h | 2 + src/sdl/sdlglvideo.cpp | 71 ++- src/sdl/sdlglvideo.h | 4 + src/win32/hardware.cpp | 7 +- src/win32/win32gliface.cpp | 452 +++++++++++++++++- src/win32/win32gliface.h | 32 +- 10 files changed, 961 insertions(+), 963 deletions(-) diff --git a/gzdoom.vcproj b/gzdoom.vcproj index e24992960..b7e52df62 100644 --- a/gzdoom.vcproj +++ b/gzdoom.vcproj @@ -1,7 +1,7 @@ + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + @@ -1847,14 +1855,6 @@ Outputs="$(IntDir)/$(InputName).obj" /> - - - @@ -2231,7 +2231,7 @@ /> - - - @@ -2460,6 +2452,14 @@ AdditionalIncludeDirectories="src\win32;$(NoInherit)" /> + + + @@ -2774,7 +2774,7 @@ /> - - - + + + + + + + + + + + + + + + + + + + @@ -3234,7 +3274,7 @@ /> - - - + + + m_Extensions; -#if !defined (unix) && !defined (__APPLE__) -HWND m_Window; -HDC m_hDC; -HGLRC m_hRC; -#endif - #define gl pgl RenderContext * gl; @@ -71,143 +60,6 @@ RenderContext * gl; int occlusion_type=0; -//========================================================================== -// -// -// -//========================================================================== - -#if !defined (unix) && !defined (__APPLE__) -static HWND InitDummy() -{ - HMODULE g_hInst = GetModuleHandle(NULL); - HWND dummy; - //Create a rect structure for the size/position of the window - RECT windowRect; - windowRect.left = 0; - windowRect.right = 64; - windowRect.top = 0; - windowRect.bottom = 64; - - //Window class structure - WNDCLASS wc; - - //Fill in window class struct - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wc.lpfnWndProc = (WNDPROC) DefWindowProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = g_hInst; - wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = "GZDoomOpenGLDummyWindow"; - - //Register window class - if(!RegisterClass(&wc)) - { - return 0; - } - - //Set window style & extended style - DWORD style, exStyle; - exStyle = WS_EX_CLIENTEDGE; - style = WS_SYSMENU | WS_BORDER | WS_CAPTION;// | WS_VISIBLE; - - //Adjust the window size so that client area is the size requested - AdjustWindowRectEx(&windowRect, style, false, exStyle); - - //Create Window - if(!(dummy = CreateWindowEx(exStyle, - "GZDoomOpenGLDummyWindow", - "GZDOOM", - WS_CLIPSIBLINGS | WS_CLIPCHILDREN | style, - 0, 0, - windowRect.right-windowRect.left, - windowRect.bottom-windowRect.top, - NULL, NULL, - g_hInst, - NULL))) - { - UnregisterClass("GZDoomOpenGLDummyWindow", g_hInst); - return 0; - } - ShowWindow(dummy, SW_HIDE); - - return dummy; -} - -//========================================================================== -// -// -// -//========================================================================== - -static void ShutdownDummy(HWND dummy) -{ - DestroyWindow(dummy); - UnregisterClass("GZDoomOpenGLDummyWindow", GetModuleHandle(NULL)); -} - - -//========================================================================== -// -// -// -//========================================================================== - -static bool ReadInitExtensions() -{ - HDC hDC; - HGLRC hRC; - HWND dummy; - - PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 32, // color depth - 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, - 0, 0, 0, 0, - 16, // z depth - 0, // stencil buffer - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - int pixelFormat; - - // we have to create a dummy window to init stuff from or the full init stuff fails - dummy = InitDummy(); - - hDC = GetDC(dummy); - pixelFormat = ChoosePixelFormat(hDC, &pfd); - DescribePixelFormat(hDC, pixelFormat, sizeof(pfd), &pfd); - - SetPixelFormat(hDC, pixelFormat, &pfd); - - hRC = wglCreateContext(hDC); - wglMakeCurrent(hDC, hRC); - - wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); - wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); - // any extra stuff here? - - wglMakeCurrent(NULL, NULL); - wglDeleteContext(hRC); - ReleaseDC(dummy, hDC); - ShutdownDummy(dummy); - - return true; -} -#endif //========================================================================== // @@ -296,12 +148,6 @@ static void APIENTRY LoadExtensions() if (strcmp(version, "2.1") >= 0) gl->flags|=RFL_GL_21; if (strcmp(version, "3.0") >= 0) gl->flags|=RFL_GL_30; - -#if !defined (unix) && !defined (__APPLE__) - PFNWGLSWAPINTERVALEXTPROC vs = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); - if (vs) gl->SetVSync = vs; -#endif - glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl->max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -437,21 +283,6 @@ static void APIENTRY LoadExtensions() gl->flags|=RFL_FRAMEBUFFER; } -#if 0 - else if (CheckExtension("GL_EXT_framebuffer_object") && - CheckExtension("GL_EXT_packed_depth_stencil")) - { - gl->GenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffersEXT"); - gl->BindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebufferEXT"); - gl->FramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2DEXT"); - gl->GenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffersEXT"); - gl->BindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbufferEXT"); - gl->RenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorageEXT"); - gl->FramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbufferEXT"); - - gl->flags|=RFL_FRAMEBUFFER; - } -#endif #if 0 if (CheckExtension("GL_ARB_texture_buffer_object") && @@ -509,372 +340,6 @@ static void APIENTRY PrintStartupLog() // //========================================================================== -#if !defined (unix) && !defined (__APPLE__) -static bool SetupPixelFormat(HDC hDC, bool allowsoftware, bool nostencil, int multisample) -{ - int colorDepth; - HDC deskDC; - int attributes[26]; - int pixelFormat; - unsigned int numFormats; - float attribsFloat[] = {0.0f, 0.0f}; - int stencil; - - deskDC = GetDC(GetDesktopWindow()); - colorDepth = GetDeviceCaps(deskDC, BITSPIXEL); - ReleaseDC(GetDesktopWindow(), deskDC); - - /* - if (!nostencil && colorDepth < 32) - { - Printf("R_OPENGL: Desktop not in 32 bit mode!\n"); - return false; - } - */ - - if (!nostencil) - { - for (stencil=1;stencil>=0;stencil--) - { - if (wglChoosePixelFormatARB && stencil) - { - attributes[0] = WGL_RED_BITS_ARB; //bits - attributes[1] = 8; - attributes[2] = WGL_GREEN_BITS_ARB; //bits - attributes[3] = 8; - attributes[4] = WGL_BLUE_BITS_ARB; //bits - attributes[5] = 8; - attributes[6] = WGL_ALPHA_BITS_ARB; - attributes[7] = 8; - attributes[8] = WGL_DEPTH_BITS_ARB; - attributes[9] = 24; - attributes[10] = WGL_STENCIL_BITS_ARB; - attributes[11] = 8; - - attributes[12] = WGL_DRAW_TO_WINDOW_ARB; //required to be true - attributes[13] = true; - attributes[14] = WGL_SUPPORT_OPENGL_ARB; - attributes[15] = true; - attributes[16] = WGL_DOUBLE_BUFFER_ARB; - attributes[17] = true; - - attributes[18] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB - if (allowsoftware) - { - attributes[19] = WGL_NO_ACCELERATION_ARB; - } - else - { - attributes[19] = WGL_FULL_ACCELERATION_ARB; - } - - if (multisample > 0) - { - attributes[20] = WGL_SAMPLE_BUFFERS_ARB; - attributes[21] = true; - attributes[22] = WGL_SAMPLES_ARB; - attributes[23] = multisample; - } - else - { - attributes[20] = 0; - attributes[21] = 0; - attributes[22] = 0; - attributes[23] = 0; - } - - attributes[24] = 0; - attributes[25] = 0; - - if (!wglChoosePixelFormatARB(hDC, attributes, attribsFloat, 1, &pixelFormat, &numFormats)) - { - Printf("R_OPENGL: Couldn't choose pixel format. Retrying in compatibility mode\n"); - goto oldmethod; - } - - if (numFormats == 0) - { - Printf("R_OPENGL: No valid pixel formats found. Retrying in compatibility mode\n"); - goto oldmethod; - } - - break; - } - else - { - oldmethod: - // If wglChoosePixelFormatARB is not found we have to do it the old fashioned way. - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 32, // color depth - 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, - 0, 0, 0, 0, - 32, // z depth - stencil*8, // stencil buffer - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - pixelFormat = ChoosePixelFormat(hDC, &pfd); - DescribePixelFormat(hDC, pixelFormat, sizeof(pfd), &pfd); - - if (pfd.dwFlags & PFD_GENERIC_FORMAT) - { - if (!allowsoftware) - { - if (stencil==0) - { - // not accelerated! - Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n"); - return false; - } - else - { - Printf("R_OPENGL: OpenGL driver not accelerated! Retrying in compatibility mode\n"); - continue; - } - } - } - break; - } - } - } - else - { - // Use the cheapest mode available and let's hope the driver can handle this... - stencil=0; - - // If wglChoosePixelFormatARB is not found we have to do it the old fashioned way. - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 16, // color depth - 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, - 0, 0, 0, 0, - 16, // z depth - 0, // stencil buffer - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - pixelFormat = ChoosePixelFormat(hDC, &pfd); - DescribePixelFormat(hDC, pixelFormat, sizeof(pfd), &pfd); - - if (pfd.dwFlags & PFD_GENERIC_FORMAT) - { - if (!allowsoftware) - { - Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n"); - return false; - } - } - } - if (stencil==0) - { - gl->flags|=RFL_NOSTENCIL; - } - - if (!SetPixelFormat(hDC, pixelFormat, NULL)) - { - Printf("R_OPENGL: Couldn't set pixel format.\n"); - return false; - } - return true; -} -#else - -static bool SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample) -{ - int stencil; - - if (!nostencil) - { - stencil=1; - SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); - SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); -// SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); - if (multisample > 0) { - SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); - SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample ); - } - } - else - { - // Use the cheapest mode available and let's hope the driver can handle this... - stencil=0; - - SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4 ); - SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4 ); - SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4 ); - SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 4 ); - SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); - //SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 )*/ - } - if (stencil==0) - { - gl->flags|=RFL_NOSTENCIL; - } - return true; -} -#endif - - -//========================================================================== -// -// -// -//========================================================================== - -#if !defined (unix) && !defined (__APPLE__) -CVAR(Bool, gl_debug, false, 0) - -static bool APIENTRY InitHardware (HWND Window, bool allowsoftware, bool nostencil, int multisample) -{ - m_Window=Window; - m_hDC = GetDC(Window); - - if (!SetupPixelFormat(m_hDC, allowsoftware, nostencil, multisample)) - { - Printf ("R_OPENGL: Reverting to software mode...\n"); - return false; - } - - m_hRC = 0; - if (wglCreateContextAttribsARB != NULL) - { - int ctxAttribs[] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3, - WGL_CONTEXT_MINOR_VERSION_ARB, 3, - WGL_CONTEXT_FLAGS_ARB, gl_debug? WGL_CONTEXT_DEBUG_BIT_ARB : 0, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, - 0 - }; - - m_hRC = wglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); - } - if (m_hRC == 0) - { - m_hRC = wglCreateContext(m_hDC); - } - - if (m_hRC == NULL) - { - Printf ("R_OPENGL: Couldn't create render context. Reverting to software mode...\n"); - return false; - } - - wglMakeCurrent(m_hDC, m_hRC); - return true; -} - -#else -static bool APIENTRY InitHardware (bool allowsoftware, bool nostencil, int multisample) -{ - if (!SetupPixelFormat(allowsoftware, nostencil, multisample)) - { - Printf ("R_OPENGL: Reverting to software mode...\n"); - return false; - } - return true; -} -#endif - - -//========================================================================== -// -// -// -//========================================================================== - -#if !defined (unix) && !defined (__APPLE__) -static void APIENTRY Shutdown() -{ - if (m_hRC) - { - wglMakeCurrent(0, 0); - wglDeleteContext(m_hRC); - } - if (m_hDC) ReleaseDC(m_Window, m_hDC); -} - - -static bool APIENTRY SetFullscreen(const char *devicename, int w, int h, int bits, int hz) -{ - DEVMODE dm; - - if (w==0) - { - ChangeDisplaySettingsEx(devicename, 0, 0, 0, 0); - } - else - { - dm.dmSize = sizeof(DEVMODE); - dm.dmSpecVersion = DM_SPECVERSION;//Somebody owes me... - dm.dmDriverExtra = 0;//...1 hour of my life back - dm.dmPelsWidth = w; - dm.dmPelsHeight = h; - dm.dmBitsPerPel = bits; - dm.dmDisplayFrequency = hz; - dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; - if (DISP_CHANGE_SUCCESSFUL != ChangeDisplaySettingsEx(devicename, &dm, 0, CDS_FULLSCREEN, 0)) - { - dm.dmFields &= ~DM_DISPLAYFREQUENCY; - return DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettingsEx(devicename, &dm, 0, CDS_FULLSCREEN, 0); - } - } - return true; -} -#endif -//========================================================================== -// -// -// -//========================================================================== - -static void APIENTRY iSwapBuffers() -{ -#if !defined (unix) && !defined (__APPLE__) - SwapBuffers(m_hDC); -#else - SDL_GL_SwapBuffers (); -#endif -} - -static BOOL APIENTRY SetVSync( int vsync ) -{ -#if defined (__APPLE__) - return kCGLNoError == CGLSetParameter( CGLGetCurrentContext(), kCGLCPSwapInterval, &vsync ); -#else // !__APPLE__ - // empty placeholder - return false; -#endif // __APPLE__ -} - -//========================================================================== -// -// -// -//========================================================================== - static void APIENTRY glBlendEquationDummy (GLenum mode) { // If this is not supported all non-existent modes are @@ -969,12 +434,6 @@ static void APIENTRY SetTextureMode(int type) // //========================================================================== -/* -extern "C" -{ - -__declspec(dllexport) -*/ void APIENTRY GetContext(RenderContext & gl) { ::gl=≷ @@ -984,14 +443,6 @@ void APIENTRY GetContext(RenderContext & gl) gl.LoadExtensions = LoadExtensions; gl.SetTextureMode = SetTextureMode; gl.PrintStartupLog = PrintStartupLog; - gl.InitHardware = InitHardware; -#if !defined (unix) && !defined (__APPLE__) - gl.Shutdown = Shutdown; -#endif - gl.SwapBuffers = iSwapBuffers; -#if !defined (unix) && !defined (__APPLE__) - gl.SetFullscreen = SetFullscreen; -#endif gl.Begin = glBegin; gl.End = glEnd; @@ -1069,13 +520,6 @@ void APIENTRY GetContext(RenderContext & gl) gl.Flush = glFlush; gl.BlendEquation = glBlendEquationDummy; - gl.SetVSync = SetVSync; - -#if !defined (unix) && !defined (__APPLE__) - ReadInitExtensions(); - //GL is not yet inited in UNIX version, read them later in LoadExtensions -#endif - } diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index a6c583343..5473f3e03 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -70,16 +70,6 @@ struct RenderContext void (APIENTRY * LoadExtensions) (); void (APIENTRY * SetTextureMode) (int type); void (APIENTRY * PrintStartupLog) (); - BOOL (APIENTRY * SetVSync) (int on); -#if !defined (unix) && !defined (__APPLE__) - bool (APIENTRY * InitHardware) (HWND, bool allowsoftware, bool nostencil, int multisample); - void (APIENTRY * Shutdown) (); -#else - bool (APIENTRY * InitHardware) (bool allowsoftware, bool nostencil, int multisample); -#endif - void (APIENTRY * SwapBuffers) (); - bool (APIENTRY * SetFullscreen) (const char *devicename, int w, int h, int bits, int hz); - void (APIENTRY * Begin) (GLenum mode); void (APIENTRY * End) (void); @@ -247,8 +237,6 @@ struct RenderContext }; -typedef void (APIENTRY * GetContextProc)(RenderContext & gl); - void APIENTRY GetContext(RenderContext & gl); #endif diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h index 5dc6cf5b5..d2430bd63 100644 --- a/src/gl/system/gl_system.h +++ b/src/gl/system/gl_system.h @@ -5,8 +5,10 @@ //#define __wtypes_h__ #define WIN32_LEAN_AND_MEAN #define _WIN32_WINDOWS 0x410 +#ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0501 // Support the mouse wheel and session notification. #define _WIN32_IE 0x0500 +#endif #define DIRECTINPUT_VERSION 0x800 #define DIRECTDRAW_VERSION 0x0300 diff --git a/src/sdl/sdlglvideo.cpp b/src/sdl/sdlglvideo.cpp index 9ee54b4e8..3285b8ed5 100644 --- a/src/sdl/sdlglvideo.cpp +++ b/src/sdl/sdlglvideo.cpp @@ -279,6 +279,67 @@ bool SDLGLVideo::SetResolution (int width, int height, int bits) return true; // We must return true because the old video context no longer exists. } +//========================================================================== +// +// +// +//========================================================================== + +bool SDLGLVideo::SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample) +{ + int stencil; + + if (!nostencil) + { + stencil=1; + SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); + SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); +// SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + if (multisample > 0) { + SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); + SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample ); + } + } + else + { + // Use the cheapest mode available and let's hope the driver can handle this... + stencil=0; + + SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4 ); + SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4 ); + SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4 ); + SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 4 ); + SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); + //SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 )*/ + } + if (stencil==0) + { + gl.flags|=RFL_NOSTENCIL; + } + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool SDLGLVideo::InitHardware (bool allowsoftware, bool nostencil, int multisample) +{ + if (!SetupPixelFormat(allowsoftware, nostencil, multisample)) + { + Printf ("R_OPENGL: Reverting to software mode...\n"); + return false; + } + return true; +} + + // FrameBuffer implementation ----------------------------------------------- SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen) @@ -294,7 +355,7 @@ SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen) UpdatePending = false; - if (!gl.InitHardware(false, gl_vid_compatibility, localmultisample)) + if (!static_cast(Video)->InitHardware(false, gl_vid_compatibility, localmultisample)) { vid_renderer = 0; return; @@ -335,6 +396,9 @@ SDLGLFB::~SDLGLFB () } } + + + void SDLGLFB::InitializeState() { int value = 0; @@ -417,3 +481,8 @@ void SDLGLFB::NewRefreshRate () { } +void SDLGLFB::SwapBuffers() +{ + SDL_GL_SwapBuffers (); +} + diff --git a/src/sdl/sdlglvideo.h b/src/sdl/sdlglvideo.h index 35175e421..4fbdf3e9a 100644 --- a/src/sdl/sdlglvideo.h +++ b/src/sdl/sdlglvideo.h @@ -27,6 +27,9 @@ class SDLGLVideo : public IVideo bool NextMode (int *width, int *height, bool *letterbox); bool SetResolution (int width, int height, int bits); + bool SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample); + bool InitHardware (bool allowsoftware, bool nostencil, int multisample); + private: int IteratorMode; int IteratorBits; @@ -50,6 +53,7 @@ public: bool IsFullscreen (); virtual void SetVSync( bool vsync ); + void SwapBuffers(); void NewRefreshRate (); diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index cd009c206..e9d1bc5e6 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -56,12 +56,15 @@ EXTERN_CVAR (Float, vid_winscale) CVAR(Int, win_x, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Int, win_y, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -#include "win32gliface.h" +extern HWND Window; bool ForceWindowed; IVideo *Video; +// do not include GL headers here, only declare the necessary functions. +IVideo *gl_CreateVideo(); +FRenderer *gl_CreateInterface(); void I_RestartRenderer(); int currentrenderer = -1; @@ -134,7 +137,7 @@ void I_InitGraphics () ticker.SetGenericRepDefault (val, CVAR_Bool); //currentrenderer = vid_renderer; - if (currentrenderer==1) Video = new Win32GLVideo(0); + if (currentrenderer==1) Video = gl_CreateVideo(); else Video = new Win32Video (0); if (Video == NULL) diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index af6bf42cd..e13dce63d 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -27,6 +27,8 @@ CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ Printf("This won't take effect until "GAMENAME" is restarted.\n"); } +CVAR(Bool, gl_debug, false, 0) + RenderContext gl; @@ -53,6 +55,7 @@ Win32GLVideo::Win32GLVideo(int parm) : m_Modes(NULL), m_IsFullscreen(false) GetDisplayDeviceName(); MakeModesList(); GetContext(gl); + SetPixelFormat(); } @@ -314,11 +317,11 @@ bool Win32GLVideo::GoFullscreen(bool yes) if (yes) { - gl.SetFullscreen(m_DisplayDeviceName, m_DisplayWidth, m_trueHeight, m_DisplayBits, m_DisplayHz); + SetFullscreen(m_DisplayDeviceName, m_DisplayWidth, m_trueHeight, m_DisplayBits, m_DisplayHz); } else { - gl.SetFullscreen(m_DisplayDeviceName, 0,0,0,0); + SetFullscreen(m_DisplayDeviceName, 0,0,0,0); } return yes; } @@ -465,6 +468,429 @@ void Win32GLVideo::DumpAdapters() // //========================================================================== +HWND Win32GLVideo::InitDummy() +{ + HMODULE g_hInst = GetModuleHandle(NULL); + HWND dummy; + //Create a rect structure for the size/position of the window + RECT windowRect; + windowRect.left = 0; + windowRect.right = 64; + windowRect.top = 0; + windowRect.bottom = 64; + + //Window class structure + WNDCLASS wc; + + //Fill in window class struct + wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wc.lpfnWndProc = (WNDPROC) DefWindowProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = g_hInst; + wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = "GZDoomOpenGLDummyWindow"; + + //Register window class + if(!RegisterClass(&wc)) + { + return 0; + } + + //Set window style & extended style + DWORD style, exStyle; + exStyle = WS_EX_CLIENTEDGE; + style = WS_SYSMENU | WS_BORDER | WS_CAPTION;// | WS_VISIBLE; + + //Adjust the window size so that client area is the size requested + AdjustWindowRectEx(&windowRect, style, false, exStyle); + + //Create Window + if(!(dummy = CreateWindowEx(exStyle, + "GZDoomOpenGLDummyWindow", + "GZDOOM", + WS_CLIPSIBLINGS | WS_CLIPCHILDREN | style, + 0, 0, + windowRect.right-windowRect.left, + windowRect.bottom-windowRect.top, + NULL, NULL, + g_hInst, + NULL))) + { + UnregisterClass("GZDoomOpenGLDummyWindow", g_hInst); + return 0; + } + ShowWindow(dummy, SW_HIDE); + + return dummy; +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLVideo::ShutdownDummy(HWND dummy) +{ + DestroyWindow(dummy); + UnregisterClass("GZDoomOpenGLDummyWindow", GetModuleHandle(NULL)); +} + + +//========================================================================== +// +// +// +//========================================================================== + +bool Win32GLVideo::SetPixelFormat() +{ + HDC hDC; + HGLRC hRC; + HWND dummy; + + PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), + 1, + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, + PFD_TYPE_RGBA, + 32, // color depth + 0, 0, 0, 0, 0, 0, + 0, + 0, + 0, + 0, 0, 0, 0, + 16, // z depth + 0, // stencil buffer + 0, + PFD_MAIN_PLANE, + 0, + 0, 0, 0 + }; + + int pixelFormat; + + // we have to create a dummy window to init stuff from or the full init stuff fails + dummy = InitDummy(); + + hDC = GetDC(dummy); + pixelFormat = ChoosePixelFormat(hDC, &pfd); + DescribePixelFormat(hDC, pixelFormat, sizeof(pfd), &pfd); + + ::SetPixelFormat(hDC, pixelFormat, &pfd); + + hRC = wglCreateContext(hDC); + wglMakeCurrent(hDC, hRC); + + wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); + wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); + // any extra stuff here? + + wglMakeCurrent(NULL, NULL); + wglDeleteContext(hRC); + ReleaseDC(dummy, hDC); + ShutdownDummy(dummy); + + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample) +{ + int colorDepth; + HDC deskDC; + int attributes[26]; + int pixelFormat; + unsigned int numFormats; + float attribsFloat[] = {0.0f, 0.0f}; + int stencil; + + deskDC = GetDC(GetDesktopWindow()); + colorDepth = GetDeviceCaps(deskDC, BITSPIXEL); + ReleaseDC(GetDesktopWindow(), deskDC); + + /* + if (!nostencil && colorDepth < 32) + { + Printf("R_OPENGL: Desktop not in 32 bit mode!\n"); + return false; + } + */ + + if (!nostencil) + { + for (stencil=1;stencil>=0;stencil--) + { + if (wglChoosePixelFormatARB && stencil) + { + attributes[0] = WGL_RED_BITS_ARB; //bits + attributes[1] = 8; + attributes[2] = WGL_GREEN_BITS_ARB; //bits + attributes[3] = 8; + attributes[4] = WGL_BLUE_BITS_ARB; //bits + attributes[5] = 8; + attributes[6] = WGL_ALPHA_BITS_ARB; + attributes[7] = 8; + attributes[8] = WGL_DEPTH_BITS_ARB; + attributes[9] = 24; + attributes[10] = WGL_STENCIL_BITS_ARB; + attributes[11] = 8; + + attributes[12] = WGL_DRAW_TO_WINDOW_ARB; //required to be true + attributes[13] = true; + attributes[14] = WGL_SUPPORT_OPENGL_ARB; + attributes[15] = true; + attributes[16] = WGL_DOUBLE_BUFFER_ARB; + attributes[17] = true; + + attributes[18] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB + if (allowsoftware) + { + attributes[19] = WGL_NO_ACCELERATION_ARB; + } + else + { + attributes[19] = WGL_FULL_ACCELERATION_ARB; + } + + if (multisample > 0) + { + attributes[20] = WGL_SAMPLE_BUFFERS_ARB; + attributes[21] = true; + attributes[22] = WGL_SAMPLES_ARB; + attributes[23] = multisample; + } + else + { + attributes[20] = 0; + attributes[21] = 0; + attributes[22] = 0; + attributes[23] = 0; + } + + attributes[24] = 0; + attributes[25] = 0; + + if (!wglChoosePixelFormatARB(m_hDC, attributes, attribsFloat, 1, &pixelFormat, &numFormats)) + { + Printf("R_OPENGL: Couldn't choose pixel format. Retrying in compatibility mode\n"); + goto oldmethod; + } + + if (numFormats == 0) + { + Printf("R_OPENGL: No valid pixel formats found. Retrying in compatibility mode\n"); + goto oldmethod; + } + + break; + } + else + { + oldmethod: + // If wglChoosePixelFormatARB is not found we have to do it the old fashioned way. + static PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), + 1, + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, + PFD_TYPE_RGBA, + 32, // color depth + 0, 0, 0, 0, 0, 0, + 0, + 0, + 0, + 0, 0, 0, 0, + 32, // z depth + stencil*8, // stencil buffer + 0, + PFD_MAIN_PLANE, + 0, + 0, 0, 0 + }; + + pixelFormat = ChoosePixelFormat(m_hDC, &pfd); + DescribePixelFormat(m_hDC, pixelFormat, sizeof(pfd), &pfd); + + if (pfd.dwFlags & PFD_GENERIC_FORMAT) + { + if (!allowsoftware) + { + if (stencil==0) + { + // not accelerated! + Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n"); + return false; + } + else + { + Printf("R_OPENGL: OpenGL driver not accelerated! Retrying in compatibility mode\n"); + continue; + } + } + } + break; + } + } + } + else + { + // Use the cheapest mode available and let's hope the driver can handle this... + stencil=0; + + // If wglChoosePixelFormatARB is not found we have to do it the old fashioned way. + static PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), + 1, + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, + PFD_TYPE_RGBA, + 16, // color depth + 0, 0, 0, 0, 0, 0, + 0, + 0, + 0, + 0, 0, 0, 0, + 16, // z depth + 0, // stencil buffer + 0, + PFD_MAIN_PLANE, + 0, + 0, 0, 0 + }; + + pixelFormat = ChoosePixelFormat(m_hDC, &pfd); + DescribePixelFormat(m_hDC, pixelFormat, sizeof(pfd), &pfd); + + if (pfd.dwFlags & PFD_GENERIC_FORMAT) + { + if (!allowsoftware) + { + Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n"); + return false; + } + } + } + if (stencil==0) + { + gl.flags|=RFL_NOSTENCIL; + } + + if (!::SetPixelFormat(m_hDC, pixelFormat, NULL)) + { + Printf("R_OPENGL: Couldn't set pixel format.\n"); + return false; + } + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool Win32GLVideo::InitHardware (HWND Window, bool allowsoftware, bool nostencil, int multisample) +{ + m_Window=Window; + m_hDC = GetDC(Window); + + if (!SetupPixelFormat(allowsoftware, nostencil, multisample)) + { + Printf ("R_OPENGL: Reverting to software mode...\n"); + return false; + } + + m_hRC = 0; + if (wglCreateContextAttribsARB != NULL) + { + int ctxAttribs[] = { + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, + WGL_CONTEXT_MINOR_VERSION_ARB, 3, + WGL_CONTEXT_FLAGS_ARB, gl_debug? WGL_CONTEXT_DEBUG_BIT_ARB : 0, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + 0 + }; + + m_hRC = wglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); + } + if (m_hRC == 0) + { + m_hRC = wglCreateContext(m_hDC); + } + + if (m_hRC == NULL) + { + Printf ("R_OPENGL: Couldn't create render context. Reverting to software mode...\n"); + return false; + } + + wglMakeCurrent(m_hDC, m_hRC); + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLVideo::Shutdown() +{ + if (m_hRC) + { + wglMakeCurrent(0, 0); + wglDeleteContext(m_hRC); + } + if (m_hDC) ReleaseDC(m_Window, m_hDC); +} + +//========================================================================== +// +// +// +//========================================================================== + +bool Win32GLVideo::SetFullscreen(const char *devicename, int w, int h, int bits, int hz) +{ + DEVMODE dm; + + if (w==0) + { + ChangeDisplaySettingsEx(devicename, 0, 0, 0, 0); + } + else + { + dm.dmSize = sizeof(DEVMODE); + dm.dmSpecVersion = DM_SPECVERSION;//Somebody owes me... + dm.dmDriverExtra = 0;//...1 hour of my life back + dm.dmPelsWidth = w; + dm.dmPelsHeight = h; + dm.dmBitsPerPel = bits; + dm.dmDisplayFrequency = hz; + dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; + if (DISP_CHANGE_SUCCESSFUL != ChangeDisplaySettingsEx(devicename, &dm, 0, CDS_FULLSCREEN, 0)) + { + dm.dmFields &= ~DM_DISPLAYFREQUENCY; + return DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettingsEx(devicename, &dm, 0, CDS_FULLSCREEN, 0); + } + } + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + IMPLEMENT_ABSTRACT_CLASS(Win32GLFrameBuffer) //========================================================================== @@ -528,7 +954,7 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in if (fullscreen) { - MoveWindow(Window, monX, monY, width, static_cast(Video)->GetTrueHeight(), FALSE); + MoveWindow(Window, monX, monY, width, GetTrueHeight(), FALSE); // And now, seriously, it IS in the right place. Promise. } @@ -539,12 +965,14 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in I_RestoreWindowedPos(); } - if (!gl.InitHardware(Window, false, gl_vid_compatibility, localmultisample)) + if (!static_cast(Video)->InitHardware(Window, false, gl_vid_compatibility, localmultisample)) { vid_renderer = 0; return; } + vsyncfunc = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); + HDC hDC = GetDC(Window); m_supportsGamma = !!GetDeviceGammaRamp(hDC, (void *)m_origGamma); ReleaseDC(Window, hDC); @@ -566,7 +994,7 @@ Win32GLFrameBuffer::~Win32GLFrameBuffer() } I_SaveWindowedPos(); - gl.SetFullscreen(m_displayDeviceName, 0,0,0,0); + static_cast(Video)->SetFullscreen(m_displayDeviceName, 0,0,0,0); ShowWindow (Window, SW_SHOW); SetWindowLong(Window, GWL_STYLE, WS_VISIBLE | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW); @@ -574,7 +1002,7 @@ Win32GLFrameBuffer::~Win32GLFrameBuffer() SetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); I_GetEvent(); - gl.Shutdown(); + static_cast(Video)->Shutdown(); } @@ -692,7 +1120,12 @@ void Win32GLFrameBuffer::ReleaseResources () void Win32GLFrameBuffer::SetVSync (bool vsync) { - if (gl.SetVSync!=NULL) gl.SetVSync(vsync); + if (vsyncfunc != NULL) vsyncfunc(vsync); +} + +void Win32GLFrameBuffer::SwapBuffers() +{ + ::SwapBuffers(static_cast(Video)->m_hDC); } //========================================================================== @@ -712,3 +1145,8 @@ void Win32GLFrameBuffer::NewRefreshRate () } } + +IVideo *gl_CreateVideo() +{ + return new Win32GLVideo(0); +} \ No newline at end of file diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index ba4ea001d..e4d70ba43 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -1,17 +1,9 @@ #ifndef __WIN32GLIFACE_H__ #define __WIN32GLIFACE_H__ -/* -#define WIN32_LEAN_AND_MEAN -#include -#include - -#include "gl/glext.h" -#include "gl/wglext.h" -*/ - -#include "win32iface.h" +#include "gl/system/gl_system.h" #include "hardware.h" +#include "win32iface.h" #include "v_video.h" #include "tarray.h" @@ -50,6 +42,13 @@ public: DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old); virtual bool SetResolution (int width, int height, int bits); void DumpAdapters(); + bool InitHardware (HWND Window, bool allowsoftware, bool nostencil, int multisample); + void Shutdown(); + bool SetFullscreen(const char *devicename, int w, int h, int bits, int hz); + + PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB; // = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; + HDC m_hDC; protected: struct ModeInfo @@ -78,6 +77,14 @@ protected: char *m_DisplayDeviceName; HMONITOR m_hMonitor; + HWND m_Window; + HGLRC m_hRC; + + HWND InitDummy(); + void ShutdownDummy(HWND dummy); + bool SetPixelFormat(); + bool SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample); + void GetDisplayDeviceName(); void MakeModesList(); void AddMode(int x, int y, int bits, int baseHeight, int refreshHz); @@ -100,6 +107,8 @@ public: Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen); virtual ~Win32GLFrameBuffer(); + PFNWGLSWAPINTERVALEXTPROC vsyncfunc; + // unused but must be defined virtual void Blank (); virtual bool PaintToWindow (); @@ -109,10 +118,11 @@ public: virtual void ReleaseResources (); void SetVSync (bool vsync); + void SwapBuffers(); void NewRefreshRate (); - int GetTrueHeight() { return static_cast(Video)->GetTrueHeight(); } + int GetTrueHeight() { return static_cast(Video)->GetTrueHeight(); } bool Lock(bool buffered); bool Lock (); From b61ef3a107d4779742579bcb29e51ef0f2b1b546 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 18 Aug 2013 15:41:52 +0200 Subject: [PATCH 0021/1509] - bumped minimum supported OpenGL version to 1.4. The engine was already using several 1.3 and 1.4 features which would have caused problems on 1.2. - removed gl_vid_compatibility. With the bump to 1.4 no hardware requiring this flag is supported anymore. - disabled 16 bit framebuffers for the same reason. As a conseqence all code for rendering without stencil could also be removed. --- src/gl/renderer/gl_renderer.cpp | 16 + src/gl/renderer/gl_renderer.h | 16 +- src/gl/renderer/gl_renderstate.cpp | 4 +- src/gl/scene/gl_portal.cpp | 9 - src/gl/scene/gl_scene.cpp | 15 +- src/gl/system/gl_cvars.h | 1 - src/gl/system/gl_framebuffer.cpp | 6 +- src/gl/system/gl_interface.cpp | 648 ++++++++++++++--------------- src/gl/system/gl_interface.h | 7 - src/gl/system/gl_menu.cpp | 1 - src/gl/system/gl_wipe.cpp | 6 - src/gl/textures/gl_hwtexture.cpp | 4 - src/sdl/sdlglvideo.cpp | 73 +--- src/sdl/sdlglvideo.h | 4 +- src/win32/win32gliface.cpp | 215 ++++------ src/win32/win32gliface.h | 4 +- 16 files changed, 443 insertions(+), 586 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 62983f213..e398a04c2 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -81,6 +81,22 @@ EXTERN_CVAR(Bool, gl_render_segs) // //----------------------------------------------------------------------------- +FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) +{ + framebuffer = fb; + mCurrentPortal = NULL; + mMirrorCount = 0; + mPlaneMirrorCount = 0; + mLightCount = 0; + mAngles = FRotator(0,0,0); + mViewVector = FVector2(0,0); + mCameraPos = FVector3(0,0,0); + mVBO = NULL; + gl_spriteindex = 0; + mShaderManager = NULL; + glpart2 = glpart = gllight = mirrortexture = NULL; +} + void FGLRenderer::Initialize() { glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch); diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index f1b39fc46..8db9cb195 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -71,21 +71,7 @@ public: FFlatVertexBuffer *mVBO; - FGLRenderer(OpenGLFrameBuffer *fb) - { - framebuffer = fb; - mCurrentPortal = NULL; - mMirrorCount = 0; - mPlaneMirrorCount = 0; - mLightCount = 0; - mAngles = FRotator(0,0,0); - mViewVector = FVector2(0,0); - mCameraPos = FVector3(0,0,0); - mVBO = NULL; - gl_spriteindex = 0; - mShaderManager = NULL; - glpart2 = glpart = gllight = mirrortexture = NULL; - } + FGLRenderer(OpenGLFrameBuffer *fb); ~FGLRenderer() ; angle_t FrustumAngle(); diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 31c46bc8a..f986d7afc 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -46,6 +46,8 @@ #include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_colormap.h" +void gl_SetTextureMode(int type); + FRenderState gl_RenderState; int FStateAttr::ChangeCounter; @@ -291,7 +293,7 @@ void FRenderState::Apply(bool forcenoshader) GLRenderer->mShaderManager->SetActiveShader(NULL); if (mTextureMode != ffTextureMode) { - gl.SetTextureMode((ffTextureMode = mTextureMode)); + gl_SetTextureMode((ffTextureMode = mTextureMode)); } if (mTextureEnabled != ffTextureEnabled) { diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 6c72c2219..95ab7b567 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -470,15 +470,6 @@ void GLPortal::EndFrame() { GLPortal * p; - if (gl.flags & RFL_NOSTENCIL) - { - while (portals.Pop(p) && p) - { - delete p; - } - return; - } - if (gl_portalinfo) { Printf("%s%d portals, depth = %d\n%s{\n", indent.GetChars(), portals.Size(), renderdepth, indent.GetChars()); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 072d3408c..51454ed1a 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -511,15 +511,12 @@ void FGLRenderer::RenderScene(int recursion) // flood all the gaps with the back sector's flat texture // This will always be drawn like GLDL_PLAIN or GLDL_FOG, depending on the fog settings - if (!(gl.flags&RFL_NOSTENCIL)) // needs a stencil to work! - { - gl.DepthMask(false); // don't write to Z-buffer! - gl_RenderState.EnableFog(true); - gl_RenderState.EnableAlphaTest(false); - gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); - gl_drawinfo->DrawUnhandledMissingTextures(); - gl_RenderState.EnableAlphaTest(true); - } + gl.DepthMask(false); // don't write to Z-buffer! + gl_RenderState.EnableFog(true); + gl_RenderState.EnableAlphaTest(false); + gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); + gl_drawinfo->DrawUnhandledMissingTextures(); + gl_RenderState.EnableAlphaTest(true); gl.DepthMask(true); gl.PolygonOffset(0.0f, 0.0f); diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index 4e8aa85fd..f748f9b52 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -16,7 +16,6 @@ EXTERN_CVAR(Bool, gl_colormap_shader) EXTERN_CVAR(Bool, gl_brightmap_shader) EXTERN_CVAR(Bool, gl_glow_shader) -EXTERN_CVAR(Bool, gl_vid_compatibility) EXTERN_CVAR(Bool,gl_enhanced_nightvision) EXTERN_CVAR(Int, screenblocks); EXTERN_CVAR(Bool, gl_texture) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 6ba5032bb..c486cb374 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -73,6 +73,8 @@ CVAR(Bool, gl_aalines, false, CVAR_ARCHIVE) FGLRenderer *GLRenderer; void gl_SetupMenu(); +void gl_LoadExtensions(); +void gl_PrintStartupLog(); //========================================================================== // @@ -115,14 +117,14 @@ void OpenGLFrameBuffer::InitializeState() { static bool first=true; - gl.LoadExtensions(); + gl_LoadExtensions(); Super::InitializeState(); if (first) { first=false; // [BB] For some reason this crashes, if compiled with MinGW and optimization. Has to be investigated. #ifdef _MSC_VER - gl.PrintStartupLog(); + gl_PrintStartupLog(); #endif if (gl.flags&RFL_NPOT_TEXTURE) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 1576b5c49..6789c2c20 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -53,9 +53,7 @@ static void APIENTRY glBlendEquationDummy (GLenum mode); static TArray m_Extensions; -#define gl pgl - -RenderContext * gl; +RenderContext gl; int occlusion_type=0; @@ -107,201 +105,6 @@ static bool CheckExtension(const char *ext) } -//========================================================================== -// -// -// -//========================================================================== - -static void APIENTRY LoadExtensions() -{ - CollectExtensions(); - - const char *version = (const char*)glGetString(GL_VERSION); - - // Don't even start if it's lower than 1.2 - if (strcmp(version, "1.2") < 0) - { - I_FatalError("Unsupported OpenGL version.\nAt least GL 1.2 is required to run "GAMENAME".\n"); - } - - // This loads any function pointers and flags that require a vaild render context to - // initialize properly - - gl->shadermodel = 0; // assume no shader support - gl->vendorstring=(char*)glGetString(GL_VENDOR); - - // First try the regular function - gl->BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation"); - // If that fails try the EXT version - if (!gl->BlendEquation) gl->BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquationEXT"); - // If that fails use a no-op dummy - if (!gl->BlendEquation) gl->BlendEquation = glBlendEquationDummy; - - if (CheckExtension("GL_ARB_texture_non_power_of_two")) gl->flags|=RFL_NPOT_TEXTURE; - if (CheckExtension("GL_ARB_texture_compression")) gl->flags|=RFL_TEXTURE_COMPRESSION; - if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl->flags|=RFL_TEXTURE_COMPRESSION_S3TC; - if (strstr(gl->vendorstring, "NVIDIA")) gl->flags|=RFL_NVIDIA; - else if (strstr(gl->vendorstring, "ATI Technologies")) gl->flags|=RFL_ATI; - - if (strcmp(version, "2.0") >= 0) gl->flags|=RFL_GL_20; - if (strcmp(version, "2.1") >= 0) gl->flags|=RFL_GL_21; - if (strcmp(version, "3.0") >= 0) gl->flags|=RFL_GL_30; - - glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl->max_texturesize); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - if (gl->flags & RFL_GL_20) - { - gl->DeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader"); - gl->DeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram"); - gl->DetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader"); - gl->CreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader"); - gl->ShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource"); - gl->CompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader"); - gl->CreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram"); - gl->AttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader"); - gl->LinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram"); - gl->UseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"); - gl->ValidateProgram = (PFNGLVALIDATEPROGRAMPROC)wglGetProcAddress("glValidateProgram"); - - gl->VertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)wglGetProcAddress("glVertexAttrib1f"); - gl->VertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)wglGetProcAddress("glVertexAttrib2f"); - gl->VertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)wglGetProcAddress("glVertexAttrib4f"); - gl->VertexAttrib2fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib2fv"); - gl->VertexAttrib3fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib3fv"); - gl->VertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv"); - gl->VertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)wglGetProcAddress("glVertexAttrib4ubv"); - gl->GetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation"); - gl->BindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation"); - - - gl->Uniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f"); - gl->Uniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f"); - gl->Uniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f"); - gl->Uniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f"); - gl->Uniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i"); - gl->Uniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i"); - gl->Uniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i"); - gl->Uniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i"); - gl->Uniform1fv = (PFNGLUNIFORM1FVPROC)wglGetProcAddress("glUniform1fv"); - gl->Uniform2fv = (PFNGLUNIFORM2FVPROC)wglGetProcAddress("glUniform2fv"); - gl->Uniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv"); - gl->Uniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv"); - gl->Uniform1iv = (PFNGLUNIFORM1IVPROC)wglGetProcAddress("glUniform1iv"); - gl->Uniform2iv = (PFNGLUNIFORM2IVPROC)wglGetProcAddress("glUniform2iv"); - gl->Uniform3iv = (PFNGLUNIFORM3IVPROC)wglGetProcAddress("glUniform3iv"); - gl->Uniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv"); - - gl->UniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)wglGetProcAddress("glUniformMatrix2fv"); - gl->UniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)wglGetProcAddress("glUniformMatrix3fv"); - gl->UniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv"); - - gl->GetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog"); - gl->GetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog"); - gl->GetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation"); - gl->GetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)wglGetProcAddress("glGetActiveUniform"); - gl->GetUniformfv = (PFNGLGETUNIFORMFVPROC)wglGetProcAddress("glGetUniformfv"); - gl->GetUniformiv = (PFNGLGETUNIFORMIVPROC)wglGetProcAddress("glGetUniformiv"); - gl->GetShaderSource = (PFNGLGETSHADERSOURCEPROC)wglGetProcAddress("glGetShaderSource"); - - gl->EnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray"); - gl->DisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray"); - gl->VertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer"); - - // what'S the equivalent of this in GL 2.0??? - gl->GetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB"); - - // Rules: - // SM4 will always use shaders. No option to switch them off is needed here. - // SM3 has shaders optional but they are off by default (they will have a performance impact - // SM2 only uses shaders for colormaps on camera textures and has no option to use them in general. - // On SM2 cards the shaders will be too slow and show visual bugs (at least on GF 6800.) - if (strcmp((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION), "1.3") >= 0) gl->shadermodel = 4; - else if (CheckExtension("GL_NV_GPU_shader4")) gl->shadermodel = 4; // for pre-3.0 drivers that support GF8xxx. - else if (CheckExtension("GL_EXT_GPU_shader4")) gl->shadermodel = 4; // for pre-3.0 drivers that support GF8xxx. - else if (CheckExtension("GL_NV_vertex_program3")) gl->shadermodel = 3; - else if (!strstr(gl->vendorstring, "NVIDIA")) gl->shadermodel = 3; - else gl->shadermodel = 2; // Only for older NVidia cards which had notoriously bad shader support. - - // Command line overrides for testing and problem cases. - if (Args->CheckParm("-sm2") && gl->shadermodel > 2) gl->shadermodel = 2; - else if (Args->CheckParm("-sm3") && gl->shadermodel > 3) gl->shadermodel = 3; - } - - if (CheckExtension("GL_ARB_occlusion_query")) - { - gl->GenQueries = (PFNGLGENQUERIESARBPROC)wglGetProcAddress("glGenQueriesARB"); - gl->DeleteQueries = (PFNGLDELETEQUERIESARBPROC)wglGetProcAddress("glDeleteQueriesARB"); - gl->GetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVARBPROC)wglGetProcAddress("glGetQueryObjectuivARB"); - gl->BeginQuery = (PFNGLBEGINQUERYARBPROC)wglGetProcAddress("glBeginQueryARB"); - gl->EndQuery = (PFNGLENDQUERYPROC)wglGetProcAddress("glEndQueryARB"); - gl->flags|=RFL_OCCLUSION_QUERY; - } - - if (gl->flags & RFL_GL_21) - { - gl->BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer"); - gl->DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers"); - gl->GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers"); - gl->BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData"); - gl->BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubData"); - gl->MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer"); - gl->UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer"); - gl->flags |= RFL_VBO; - } - else if (CheckExtension("GL_ARB_vertex_buffer_object")) - { - gl->BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBufferARB"); - gl->DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB"); - gl->GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffersARB"); - gl->BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferDataARB"); - gl->BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB"); - gl->MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBufferARB"); - gl->UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBufferARB"); - gl->flags |= RFL_VBO; - } - - if (CheckExtension("GL_ARB_map_buffer_range")) - { - gl->MapBufferRange = (PFNGLMAPBUFFERRANGEPROC)wglGetProcAddress("glMapBufferRange"); - gl->FlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)wglGetProcAddress("glFlushMappedBufferRange"); - gl->flags|=RFL_MAP_BUFFER_RANGE; - } - - if (CheckExtension("GL_ARB_framebuffer_object")) - { - gl->GenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers"); - gl->DeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers"); - gl->BindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer"); - gl->FramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D"); - gl->GenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers"); - gl->DeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress("glDeleteRenderbuffers"); - gl->BindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer"); - gl->RenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorage"); - gl->FramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbuffer"); - - gl->flags|=RFL_FRAMEBUFFER; - } - -#if 0 - if (CheckExtension("GL_ARB_texture_buffer_object") && - CheckExtension("GL_ARB_texture_float") && - CheckExtension("GL_EXT_GPU_Shader4") && - CheckExtension("GL_ARB_texture_rg") && - gl->shadermodel == 4) - { - gl->TexBufferARB = (PFNGLTEXBUFFERARBPROC)wglGetProcAddress("glTexBufferARB"); - gl->flags|=RFL_TEXTUREBUFFER; - } -#endif - - - - gl->ActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTextureARB"); - gl->MultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2fARB"); - gl->MultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) wglGetProcAddress("glMultiTexCoord2fvARB"); -} //========================================================================== // @@ -309,141 +112,10 @@ static void APIENTRY LoadExtensions() // //========================================================================== -static void APIENTRY PrintStartupLog() +static void InitContext() { - Printf ("GL_VENDOR: %s\n", glGetString(GL_VENDOR)); - Printf ("GL_RENDERER: %s\n", glGetString(GL_RENDERER)); - Printf ("GL_VERSION: %s\n", glGetString(GL_VERSION)); - Printf ("GL_SHADING_LANGUAGE_VERSION: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); - Printf ("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS)); - int v; - - glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &v); - Printf ("Max. texture units: %d\n", v); - glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); - Printf ("Max. fragment uniforms: %d\n", v); - if (gl->shadermodel == 4) gl->maxuniforms = v; - glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &v); - Printf ("Max. vertex uniforms: %d\n", v); - glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); - Printf ("Max. varying: %d\n", v); - glGetIntegerv(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, &v); - Printf ("Max. combined uniforms: %d\n", v); - glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &v); - Printf ("Max. combined uniform blocks: %d\n", v); - -} - -//========================================================================== -// -// -// -//========================================================================== - -static void APIENTRY glBlendEquationDummy (GLenum mode) -{ - // If this is not supported all non-existent modes are - // made to draw nothing. - if (mode == GL_FUNC_ADD) - { - glColorMask(true, true, true, true); - } - else - { - glColorMask(false, false, false, false); - } -} - -//========================================================================== -// -// -// -//========================================================================== - -static void APIENTRY SetTextureMode(int type) -{ - static float white[] = {1.f,1.f,1.f,1.f}; - - if (gl_vid_compatibility) - { - type = TM_MODULATE; - } - if (type == TM_MASK) - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); - } - else if (type == TM_OPAQUE) - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - } - else if (type == TM_INVERT) - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); - } - else if (type == TM_INVERTOPAQUE) - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - } - else // if (type == TM_MODULATE) - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } -} - -//========================================================================== -// -// -// -//========================================================================== - -void APIENTRY GetContext(RenderContext & gl) -{ - ::gl=≷ - gl.flags=0; - gl.LoadExtensions = LoadExtensions; - gl.SetTextureMode = SetTextureMode; - gl.PrintStartupLog = PrintStartupLog; - gl.Begin = glBegin; gl.End = glEnd; gl.DrawArrays = glDrawArrays; @@ -522,6 +194,322 @@ void APIENTRY GetContext(RenderContext & gl) gl.BlendEquation = glBlendEquationDummy; } +//========================================================================== +// +// +// +//========================================================================== +void gl_LoadExtensions() +{ + InitContext(); + CollectExtensions(); + + const char *version = (const char*)glGetString(GL_VERSION); + + // Don't even start if it's lower than 1.4 + if (strcmp(version, "1.4") < 0) + { + I_FatalError("Unsupported OpenGL version.\nAt least GL 1.4 is required to run "GAMENAME".\n"); + } + + // This loads any function pointers and flags that require a vaild render context to + // initialize properly + + gl.shadermodel = 0; // assume no shader support + gl.vendorstring=(char*)glGetString(GL_VENDOR); + + // First try the regular function + gl.BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation"); + // If that fails try the EXT version + if (!gl.BlendEquation) gl.BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquationEXT"); + // If that fails use a no-op dummy + if (!gl.BlendEquation) gl.BlendEquation = glBlendEquationDummy; + + if (CheckExtension("GL_ARB_texture_non_power_of_two")) gl.flags|=RFL_NPOT_TEXTURE; + if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; + if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; + if (strstr(gl.vendorstring, "NVIDIA")) gl.flags|=RFL_NVIDIA; + else if (strstr(gl.vendorstring, "ATI Technologies")) gl.flags|=RFL_ATI; + + if (strcmp(version, "2.0") >= 0) gl.flags|=RFL_GL_20; + if (strcmp(version, "2.1") >= 0) gl.flags|=RFL_GL_21; + if (strcmp(version, "3.0") >= 0) gl.flags|=RFL_GL_30; + + glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + if (gl.flags & RFL_GL_20) + { + gl.DeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader"); + gl.DeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram"); + gl.DetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader"); + gl.CreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader"); + gl.ShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource"); + gl.CompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader"); + gl.CreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram"); + gl.AttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader"); + gl.LinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram"); + gl.UseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"); + gl.ValidateProgram = (PFNGLVALIDATEPROGRAMPROC)wglGetProcAddress("glValidateProgram"); + + gl.VertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)wglGetProcAddress("glVertexAttrib1f"); + gl.VertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)wglGetProcAddress("glVertexAttrib2f"); + gl.VertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)wglGetProcAddress("glVertexAttrib4f"); + gl.VertexAttrib2fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib2fv"); + gl.VertexAttrib3fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib3fv"); + gl.VertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv"); + gl.VertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)wglGetProcAddress("glVertexAttrib4ubv"); + gl.GetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation"); + gl.BindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation"); + + + gl.Uniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f"); + gl.Uniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f"); + gl.Uniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f"); + gl.Uniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f"); + gl.Uniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i"); + gl.Uniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i"); + gl.Uniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i"); + gl.Uniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i"); + gl.Uniform1fv = (PFNGLUNIFORM1FVPROC)wglGetProcAddress("glUniform1fv"); + gl.Uniform2fv = (PFNGLUNIFORM2FVPROC)wglGetProcAddress("glUniform2fv"); + gl.Uniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv"); + gl.Uniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv"); + gl.Uniform1iv = (PFNGLUNIFORM1IVPROC)wglGetProcAddress("glUniform1iv"); + gl.Uniform2iv = (PFNGLUNIFORM2IVPROC)wglGetProcAddress("glUniform2iv"); + gl.Uniform3iv = (PFNGLUNIFORM3IVPROC)wglGetProcAddress("glUniform3iv"); + gl.Uniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv"); + + gl.UniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)wglGetProcAddress("glUniformMatrix2fv"); + gl.UniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)wglGetProcAddress("glUniformMatrix3fv"); + gl.UniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv"); + + gl.GetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog"); + gl.GetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog"); + gl.GetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation"); + gl.GetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)wglGetProcAddress("glGetActiveUniform"); + gl.GetUniformfv = (PFNGLGETUNIFORMFVPROC)wglGetProcAddress("glGetUniformfv"); + gl.GetUniformiv = (PFNGLGETUNIFORMIVPROC)wglGetProcAddress("glGetUniformiv"); + gl.GetShaderSource = (PFNGLGETSHADERSOURCEPROC)wglGetProcAddress("glGetShaderSource"); + + gl.EnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray"); + gl.DisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray"); + gl.VertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer"); + + // what'S the equivalent of this in GL 2.0??? + gl.GetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB"); + + // Rules: + // SM4 will always use shaders. No option to switch them off is needed here. + // SM3 has shaders optional but they are off by default (they will have a performance impact + // SM2 only uses shaders for colormaps on camera textures and has no option to use them in general. + // On SM2 cards the shaders will be too slow and show visual bugs (at least on GF 6800.) + if (strcmp((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION), "1.3") >= 0) gl.shadermodel = 4; + else if (CheckExtension("GL_NV_GPU_shader4")) gl.shadermodel = 4; // for pre-3.0 drivers that support GF8xxx. + else if (CheckExtension("GL_EXT_GPU_shader4")) gl.shadermodel = 4; // for pre-3.0 drivers that support GF8xxx. + else if (CheckExtension("GL_NV_vertex_program3")) gl.shadermodel = 3; + else if (!strstr(gl.vendorstring, "NVIDIA")) gl.shadermodel = 3; + else gl.shadermodel = 2; // Only for older NVidia cards which had notoriously bad shader support. + + // Command line overrides for testing and problem cases. + if (Args->CheckParm("-sm2") && gl.shadermodel > 2) gl.shadermodel = 2; + else if (Args->CheckParm("-sm3") && gl.shadermodel > 3) gl.shadermodel = 3; + } + + if (CheckExtension("GL_ARB_occlusion_query")) + { + gl.GenQueries = (PFNGLGENQUERIESARBPROC)wglGetProcAddress("glGenQueriesARB"); + gl.DeleteQueries = (PFNGLDELETEQUERIESARBPROC)wglGetProcAddress("glDeleteQueriesARB"); + gl.GetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVARBPROC)wglGetProcAddress("glGetQueryObjectuivARB"); + gl.BeginQuery = (PFNGLBEGINQUERYARBPROC)wglGetProcAddress("glBeginQueryARB"); + gl.EndQuery = (PFNGLENDQUERYPROC)wglGetProcAddress("glEndQueryARB"); + gl.flags|=RFL_OCCLUSION_QUERY; + } + + if (gl.flags & RFL_GL_21) + { + gl.BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer"); + gl.DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers"); + gl.GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers"); + gl.BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData"); + gl.BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubData"); + gl.MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer"); + gl.UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer"); + gl.flags |= RFL_VBO; + } + else if (CheckExtension("GL_ARB_vertex_buffer_object")) + { + gl.BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBufferARB"); + gl.DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB"); + gl.GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffersARB"); + gl.BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferDataARB"); + gl.BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB"); + gl.MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBufferARB"); + gl.UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBufferARB"); + gl.flags |= RFL_VBO; + } + + if (CheckExtension("GL_ARB_map_buffer_range")) + { + gl.MapBufferRange = (PFNGLMAPBUFFERRANGEPROC)wglGetProcAddress("glMapBufferRange"); + gl.FlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)wglGetProcAddress("glFlushMappedBufferRange"); + gl.flags|=RFL_MAP_BUFFER_RANGE; + } + + if (CheckExtension("GL_ARB_framebuffer_object")) + { + gl.GenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers"); + gl.DeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers"); + gl.BindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer"); + gl.FramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D"); + gl.GenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers"); + gl.DeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress("glDeleteRenderbuffers"); + gl.BindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer"); + gl.RenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorage"); + gl.FramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbuffer"); + + gl.flags|=RFL_FRAMEBUFFER; + } + +#if 0 + if (CheckExtension("GL_ARB_texture_buffer_object") && + CheckExtension("GL_ARB_texture_float") && + CheckExtension("GL_EXT_GPU_Shader4") && + CheckExtension("GL_ARB_texture_rg") && + gl.shadermodel == 4) + { + gl.TexBufferARB = (PFNGLTEXBUFFERARBPROC)wglGetProcAddress("glTexBufferARB"); + gl.flags|=RFL_TEXTUREBUFFER; + } +#endif + + + + gl.ActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTextureARB"); + gl.MultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2fARB"); + gl.MultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) wglGetProcAddress("glMultiTexCoord2fvARB"); +} + +//========================================================================== +// +// +// +//========================================================================== + +void gl_PrintStartupLog() +{ + Printf ("GL_VENDOR: %s\n", glGetString(GL_VENDOR)); + Printf ("GL_RENDERER: %s\n", glGetString(GL_RENDERER)); + Printf ("GL_VERSION: %s\n", glGetString(GL_VERSION)); + Printf ("GL_SHADING_LANGUAGE_VERSION: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); + Printf ("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS)); + int v; + + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &v); + Printf ("Max. texture units: %d\n", v); + glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); + Printf ("Max. fragment uniforms: %d\n", v); + if (gl.shadermodel == 4) gl.maxuniforms = v; + glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &v); + Printf ("Max. vertex uniforms: %d\n", v); + glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); + Printf ("Max. varying: %d\n", v); + glGetIntegerv(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, &v); + Printf ("Max. combined uniforms: %d\n", v); + glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &v); + Printf ("Max. combined uniform blocks: %d\n", v); + +} + +//========================================================================== +// +// +// +//========================================================================== + +static void APIENTRY glBlendEquationDummy (GLenum mode) +{ + // If this is not supported all non-existent modes are + // made to draw nothing. + if (mode == GL_FUNC_ADD) + { + glColorMask(true, true, true, true); + } + else + { + glColorMask(false, false, false, false); + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void gl_SetTextureMode(int type) +{ + static float white[] = {1.f,1.f,1.f,1.f}; + + if (type == TM_MASK) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); + } + else if (type == TM_OPAQUE) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + } + else if (type == TM_INVERT) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); + } + else if (type == TM_INVERTOPAQUE) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + } + else // if (type == TM_MODULATE) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } +} //} // extern "C" diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 5473f3e03..2cd554111 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -21,7 +21,6 @@ typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat enum RenderFlags { RFL_NPOT_TEXTURE=1, - RFL_NOSTENCIL=2, RFL_OCCLUSION_QUERY=4, // [BB] Added texture compression flags. RFL_TEXTURE_COMPRESSION=8, @@ -67,10 +66,6 @@ struct RenderContext return maxuniforms>=2048? 128:64; } - void (APIENTRY * LoadExtensions) (); - void (APIENTRY * SetTextureMode) (int type); - void (APIENTRY * PrintStartupLog) (); - void (APIENTRY * Begin) (GLenum mode); void (APIENTRY * End) (void); void (APIENTRY * DrawArrays) (GLenum mode, GLint first, GLsizei count); @@ -237,7 +232,5 @@ struct RenderContext }; -void APIENTRY GetContext(RenderContext & gl); - #endif diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index 5429da9c7..ba70431da 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -19,7 +19,6 @@ CVAR(Bool,gl_mirrors,true,0) // This is for debugging only! CVAR(Bool,gl_mirror_envmap, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) CVAR(Bool, gl_render_segs, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, gl_seamless, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -CVAR(Bool, gl_vid_compatibility, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CUSTOM_CVAR(Int, r_mirror_recursions,4,CVAR_GLOBALCONFIG|CVAR_ARCHIVE) { diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 83f5abd82..63ec45b43 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -69,8 +69,6 @@ struct RECT { }; #endif -EXTERN_CVAR(Bool, gl_vid_compatibility) - //=========================================================================== // // Screen wipes @@ -127,10 +125,6 @@ private: bool OpenGLFrameBuffer::WipeStartScreen(int type) { - if (gl_vid_compatibility) - { - return false; // not all required features present. - } switch (type) { case wipe_Burn: diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index f81d003d4..0093729b2 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -119,10 +119,6 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i rw = GetTexDimension (w); rh = GetTexDimension (h); - if (gl_vid_compatibility) - { - mipmap=false; - } gl.TexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, (mipmap && use_mipmapping && !forcenofiltering)); if (rw == w && rh == h) diff --git a/src/sdl/sdlglvideo.cpp b/src/sdl/sdlglvideo.cpp index 3285b8ed5..0241a4f39 100644 --- a/src/sdl/sdlglvideo.cpp +++ b/src/sdl/sdlglvideo.cpp @@ -59,8 +59,6 @@ CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ Printf("This won't take effect until "GAMENAME" is restarted.\n"); } -RenderContext gl; - // PRIVATE DATA DEFINITIONS ------------------------------------------------ // Dummy screen sizes to pass when windowed @@ -123,7 +121,6 @@ SDLGLVideo::SDLGLVideo (int parm) fprintf( stderr, "Video initialization failed: %s\n", SDL_GetError( ) ); } - GetContext(gl); #ifndef _WIN32 // mouse cursor is visible by default on linux systems, we disable it by default SDL_ShowCursor (0); @@ -285,40 +282,18 @@ bool SDLGLVideo::SetResolution (int width, int height, int bits) // //========================================================================== -bool SDLGLVideo::SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample) +bool SDLGLVideo::SetupPixelFormat(bool allowsoftware, int multisample) { - int stencil; - - if (!nostencil) - { - stencil=1; - SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); - SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); + SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); // SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); - if (multisample > 0) { - SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); - SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample ); - } - } - else - { - // Use the cheapest mode available and let's hope the driver can handle this... - stencil=0; - - SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4 ); - SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4 ); - SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4 ); - SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 4 ); - SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); - //SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 )*/ - } - if (stencil==0) - { - gl.flags|=RFL_NOSTENCIL; + if (multisample > 0) { + SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); + SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample ); } return true; } @@ -329,13 +304,20 @@ bool SDLGLVideo::SetupPixelFormat(bool allowsoftware, bool nostencil, int multis // //========================================================================== -bool SDLGLVideo::InitHardware (bool allowsoftware, bool nostencil, int multisample) +bool SDLGLVideo::InitHardware (bool allowsoftware, int multisample) { - if (!SetupPixelFormat(allowsoftware, nostencil, multisample)) + if (!SetupPixelFormat(allowsoftware, multisample)) { Printf ("R_OPENGL: Reverting to software mode...\n"); return false; } + int value = 0; + SDL_GL_GetAttribute( SDL_GL_STENCIL_SIZE, &value ); + if (!value) + { + Printf("R_OPENGL: Failed to initialize stencil buffer! Reverting to software mode...\n"); + } + return true; } @@ -355,23 +337,15 @@ SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen) UpdatePending = false; - if (!static_cast(Video)->InitHardware(false, gl_vid_compatibility, localmultisample)) + if (!static_cast(Video)->InitHardware(false, localmultisample)) { vid_renderer = 0; return; } - // Mac OS X version will crash when entering fullscreen mode with BPP <= 8 - // Also it may crash with BPP == 16 on some configurations - // It seems 24 and 32 bits are safe values - // So value of vid_displaybits is ignored and hardcoded constant is used instead Screen = SDL_SetVideoMode (width, height, -#if defined(__APPLE__) 32, -#else // ! __APPLE__ - vid_displaybits, -#endif // __APPLE__ SDL_HWSURFACE|SDL_HWPALETTE|SDL_OPENGL | SDL_GL_DOUBLEBUFFER|SDL_ANYFORMAT| (fullscreen ? SDL_FULLSCREEN : 0)); @@ -401,13 +375,6 @@ SDLGLFB::~SDLGLFB () void SDLGLFB::InitializeState() { - int value = 0; - SDL_GL_GetAttribute( SDL_GL_STENCIL_SIZE, &value ); - if (!value) - { - Printf("Failed to use stencil buffer!\n"); //[C] is it needed to recreate buffer in "cheapest mode"? - gl.flags|=RFL_NOSTENCIL; - } } bool SDLGLFB::CanUpdate () diff --git a/src/sdl/sdlglvideo.h b/src/sdl/sdlglvideo.h index 4fbdf3e9a..205e416c0 100644 --- a/src/sdl/sdlglvideo.h +++ b/src/sdl/sdlglvideo.h @@ -27,8 +27,8 @@ class SDLGLVideo : public IVideo bool NextMode (int *width, int *height, bool *letterbox); bool SetResolution (int width, int height, int bits); - bool SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample); - bool InitHardware (bool allowsoftware, bool nostencil, int multisample); + bool SetupPixelFormat(bool allowsoftware, int multisample); + bool InitHardware (bool allowsoftware, int multisample); private: int IteratorMode; diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index e13dce63d..5623b7062 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -29,10 +29,6 @@ CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ CVAR(Bool, gl_debug, false, 0) -RenderContext gl; - - -EXTERN_CVAR(Bool, gl_vid_compatibility) EXTERN_CVAR(Int, vid_refreshrate) //========================================================================== @@ -49,12 +45,11 @@ Win32GLVideo::Win32GLVideo(int parm) : m_Modes(NULL), m_IsFullscreen(false) I_SetWndProc(); m_DisplayWidth = vid_defwidth; m_DisplayHeight = vid_defheight; - m_DisplayBits = gl_vid_compatibility? 16:32; + m_DisplayBits = 32; m_DisplayHz = 60; GetDisplayDeviceName(); MakeModesList(); - GetContext(gl); SetPixelFormat(); } @@ -202,8 +197,8 @@ void Win32GLVideo::StartModeIterator(int bits, bool fs) { m_IteratorMode = m_Modes; // I think it's better to ignore the game-side settings of bit depth. - // The GL renderer will always default to 32 bits, except in compatibility mode - m_IteratorBits = gl_vid_compatibility? 16:32; + // The GL renderer will always default to 32 bits because 16 bit modes cannot have a stencil buffer. + m_IteratorBits = 32; m_IteratorFS = fs; } @@ -339,7 +334,7 @@ DFrameBuffer *Win32GLVideo::CreateFrameBuffer(int width, int height, bool fs, DF m_DisplayWidth = width; m_DisplayHeight = height; - m_DisplayBits = gl_vid_compatibility? 16:32; + m_DisplayBits = 32; m_DisplayHz = 60; if (vid_refreshrate == 0) @@ -604,7 +599,7 @@ bool Win32GLVideo::SetPixelFormat() // //========================================================================== -bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample) +bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, int multisample) { int colorDepth; HDC deskDC; @@ -612,154 +607,90 @@ bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, bool nostencil, int mult int pixelFormat; unsigned int numFormats; float attribsFloat[] = {0.0f, 0.0f}; - int stencil; deskDC = GetDC(GetDesktopWindow()); colorDepth = GetDeviceCaps(deskDC, BITSPIXEL); ReleaseDC(GetDesktopWindow(), deskDC); - /* - if (!nostencil && colorDepth < 32) + if (wglChoosePixelFormatARB) { - Printf("R_OPENGL: Desktop not in 32 bit mode!\n"); - return false; - } - */ - - if (!nostencil) - { - for (stencil=1;stencil>=0;stencil--) + attributes[0] = WGL_RED_BITS_ARB; //bits + attributes[1] = 8; + attributes[2] = WGL_GREEN_BITS_ARB; //bits + attributes[3] = 8; + attributes[4] = WGL_BLUE_BITS_ARB; //bits + attributes[5] = 8; + attributes[6] = WGL_ALPHA_BITS_ARB; + attributes[7] = 8; + attributes[8] = WGL_DEPTH_BITS_ARB; + attributes[9] = 24; + attributes[10] = WGL_STENCIL_BITS_ARB; + attributes[11] = 8; + + attributes[12] = WGL_DRAW_TO_WINDOW_ARB; //required to be true + attributes[13] = true; + attributes[14] = WGL_SUPPORT_OPENGL_ARB; + attributes[15] = true; + attributes[16] = WGL_DOUBLE_BUFFER_ARB; + attributes[17] = true; + + attributes[18] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB + if (allowsoftware) { - if (wglChoosePixelFormatARB && stencil) - { - attributes[0] = WGL_RED_BITS_ARB; //bits - attributes[1] = 8; - attributes[2] = WGL_GREEN_BITS_ARB; //bits - attributes[3] = 8; - attributes[4] = WGL_BLUE_BITS_ARB; //bits - attributes[5] = 8; - attributes[6] = WGL_ALPHA_BITS_ARB; - attributes[7] = 8; - attributes[8] = WGL_DEPTH_BITS_ARB; - attributes[9] = 24; - attributes[10] = WGL_STENCIL_BITS_ARB; - attributes[11] = 8; - - attributes[12] = WGL_DRAW_TO_WINDOW_ARB; //required to be true - attributes[13] = true; - attributes[14] = WGL_SUPPORT_OPENGL_ARB; - attributes[15] = true; - attributes[16] = WGL_DOUBLE_BUFFER_ARB; - attributes[17] = true; - - attributes[18] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB - if (allowsoftware) - { - attributes[19] = WGL_NO_ACCELERATION_ARB; - } - else - { - attributes[19] = WGL_FULL_ACCELERATION_ARB; - } - - if (multisample > 0) - { - attributes[20] = WGL_SAMPLE_BUFFERS_ARB; - attributes[21] = true; - attributes[22] = WGL_SAMPLES_ARB; - attributes[23] = multisample; - } - else - { - attributes[20] = 0; - attributes[21] = 0; - attributes[22] = 0; - attributes[23] = 0; - } - - attributes[24] = 0; - attributes[25] = 0; - - if (!wglChoosePixelFormatARB(m_hDC, attributes, attribsFloat, 1, &pixelFormat, &numFormats)) - { - Printf("R_OPENGL: Couldn't choose pixel format. Retrying in compatibility mode\n"); - goto oldmethod; - } - - if (numFormats == 0) - { - Printf("R_OPENGL: No valid pixel formats found. Retrying in compatibility mode\n"); - goto oldmethod; - } - - break; - } - else - { - oldmethod: - // If wglChoosePixelFormatARB is not found we have to do it the old fashioned way. - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 32, // color depth - 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, - 0, 0, 0, 0, - 32, // z depth - stencil*8, // stencil buffer - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - pixelFormat = ChoosePixelFormat(m_hDC, &pfd); - DescribePixelFormat(m_hDC, pixelFormat, sizeof(pfd), &pfd); - - if (pfd.dwFlags & PFD_GENERIC_FORMAT) - { - if (!allowsoftware) - { - if (stencil==0) - { - // not accelerated! - Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n"); - return false; - } - else - { - Printf("R_OPENGL: OpenGL driver not accelerated! Retrying in compatibility mode\n"); - continue; - } - } - } - break; - } + attributes[19] = WGL_NO_ACCELERATION_ARB; + } + else + { + attributes[19] = WGL_FULL_ACCELERATION_ARB; + } + + if (multisample > 0) + { + attributes[20] = WGL_SAMPLE_BUFFERS_ARB; + attributes[21] = true; + attributes[22] = WGL_SAMPLES_ARB; + attributes[23] = multisample; + } + else + { + attributes[20] = 0; + attributes[21] = 0; + attributes[22] = 0; + attributes[23] = 0; + } + + attributes[24] = 0; + attributes[25] = 0; + + if (!wglChoosePixelFormatARB(m_hDC, attributes, attribsFloat, 1, &pixelFormat, &numFormats)) + { + Printf("R_OPENGL: Couldn't choose pixel format. Retrying in compatibility mode\n"); + goto oldmethod; + } + + if (numFormats == 0) + { + Printf("R_OPENGL: No valid pixel formats found. Retrying in compatibility mode\n"); + goto oldmethod; } } else { - // Use the cheapest mode available and let's hope the driver can handle this... - stencil=0; - + oldmethod: // If wglChoosePixelFormatARB is not found we have to do it the old fashioned way. static PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, - 16, // color depth + 32, // color depth 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 16, // z depth - 0, // stencil buffer + 32, // z depth + 8, // stencil buffer 0, PFD_MAIN_PLANE, 0, @@ -773,15 +704,11 @@ bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, bool nostencil, int mult { if (!allowsoftware) { - Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n"); + Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n"); return false; } } } - if (stencil==0) - { - gl.flags|=RFL_NOSTENCIL; - } if (!::SetPixelFormat(m_hDC, pixelFormat, NULL)) { @@ -797,12 +724,12 @@ bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, bool nostencil, int mult // //========================================================================== -bool Win32GLVideo::InitHardware (HWND Window, bool allowsoftware, bool nostencil, int multisample) +bool Win32GLVideo::InitHardware (HWND Window, bool allowsoftware, int multisample) { m_Window=Window; m_hDC = GetDC(Window); - if (!SetupPixelFormat(allowsoftware, nostencil, multisample)) + if (!SetupPixelFormat(allowsoftware, multisample)) { Printf ("R_OPENGL: Reverting to software mode...\n"); return false; @@ -965,7 +892,7 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in I_RestoreWindowedPos(); } - if (!static_cast(Video)->InitHardware(Window, false, gl_vid_compatibility, localmultisample)) + if (!static_cast(Video)->InitHardware(Window, false, localmultisample)) { vid_renderer = 0; return; diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index e4d70ba43..4457c5372 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -42,7 +42,7 @@ public: DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old); virtual bool SetResolution (int width, int height, int bits); void DumpAdapters(); - bool InitHardware (HWND Window, bool allowsoftware, bool nostencil, int multisample); + bool InitHardware (HWND Window, bool allowsoftware, int multisample); void Shutdown(); bool SetFullscreen(const char *devicename, int w, int h, int bits, int hz); @@ -83,7 +83,7 @@ protected: HWND InitDummy(); void ShutdownDummy(HWND dummy); bool SetPixelFormat(); - bool SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample); + bool SetupPixelFormat(bool allowsoftware, int multisample); void GetDisplayDeviceName(); void MakeModesList(); From 9f12e5928c3ab1b5fbf125fd7010cde02c24be01 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 19 Aug 2013 08:04:31 +0200 Subject: [PATCH 0022/1509] - removed stencil buffer check from SDL init code because it caused a crash. --- src/sdl/sdlglvideo.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/sdl/sdlglvideo.cpp b/src/sdl/sdlglvideo.cpp index 0241a4f39..868cf0afc 100644 --- a/src/sdl/sdlglvideo.cpp +++ b/src/sdl/sdlglvideo.cpp @@ -311,13 +311,6 @@ bool SDLGLVideo::InitHardware (bool allowsoftware, int multisample) Printf ("R_OPENGL: Reverting to software mode...\n"); return false; } - int value = 0; - SDL_GL_GetAttribute( SDL_GL_STENCIL_SIZE, &value ); - if (!value) - { - Printf("R_OPENGL: Failed to initialize stencil buffer! Reverting to software mode...\n"); - } - return true; } From e6f571729f56c6dbe3686c0aa2eca3627b4b72d0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 27 Aug 2013 23:31:23 +0200 Subject: [PATCH 0023/1509] - fixed: When calculating an y-texture offset the scale was multiplied with instead of divided by. --- src/gl/scene/gl_walls.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index e7265c1a1..64d3d02d5 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -760,9 +760,21 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg, type = (seg->linedef->special == Line_Mirror && _type == RENDERWALL_M1S && gl_mirrors) ? RENDERWALL_MIRROR : _type; - float floatceilingref = FIXED2FLOAT(ceilingrefheight) + - FIXED2FLOAT(tci.RowOffset(seg->sidedef->GetTextureYOffset(texpos))) + - FIXED2FLOAT((peg ? (gltexture->TextureHeight(GLUSE_TEXTURE)<sidedef->GetTextureYOffset(texpos))); + float f3 = 0; + + if (peg) + { + int foo = (gltexture->TextureHeight(GLUSE_TEXTURE) << 17) / tci.mTempScaleY; + fixed_t of = (foo >> 1) + (foo & 1); + f3 = of - FIXED2FLOAT(lh - v_offset); + + float f3a = FIXED2FLOAT((peg ? (gltexture->TextureHeight(GLUSE_TEXTURE)<sidedef->GetTextureXOffset(texpos))) return; @@ -1448,7 +1460,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) #ifdef _MSC_VER #ifdef _DEBUG - if (seg->linedef-lines==2570) + if (seg->linedef-lines==636) __asm nop #endif #endif From 61af682be9863f69b4135f7fb42990782d2a730a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 27 Aug 2013 23:53:14 +0200 Subject: [PATCH 0024/1509] - made some alterations to last commit after reviewing how the broken code managed to get into GZDoom. --- src/gl/scene/gl_walls.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 64d3d02d5..6c8b32766 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -760,21 +760,8 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg, type = (seg->linedef->special == Line_Mirror && _type == RENDERWALL_M1S && gl_mirrors) ? RENDERWALL_MIRROR : _type; - float f1 = FIXED2FLOAT(ceilingrefheight); - float f2 = FIXED2FLOAT(tci.RowOffset(seg->sidedef->GetTextureYOffset(texpos))); - float f3 = 0; - - if (peg) - { - int foo = (gltexture->TextureHeight(GLUSE_TEXTURE) << 17) / tci.mTempScaleY; - fixed_t of = (foo >> 1) + (foo & 1); - f3 = of - FIXED2FLOAT(lh - v_offset); - - float f3a = FIXED2FLOAT((peg ? (gltexture->TextureHeight(GLUSE_TEXTURE)<sidedef->GetTextureYOffset(texpos))); + if (peg) floatceilingref += tci.mRenderHeight - FIXED2FLOAT(lh + v_offset); if (!SetWallCoordinates(seg, &tci, floatceilingref, topleft, topright, bottomleft, bottomright, seg->sidedef->GetTextureXOffset(texpos))) return; From 737708b63529cee012f9b3de27ed6e2494b8d1bc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 28 Aug 2013 08:33:11 +0200 Subject: [PATCH 0025/1509] - fix c++11's compile problems. --- src/cmdlib.cpp | 2 +- src/gl/data/gl_portaldata.cpp | 2 +- src/gl/data/gl_setup.cpp | 6 +++--- src/gl/scene/gl_portal.cpp | 2 +- src/gl/system/gl_interface.cpp | 4 ++-- src/gl/textures/gl_material.cpp | 2 +- src/sdl/sdlglvideo.cpp | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cmdlib.cpp b/src/cmdlib.cpp index 557c80cf8..b3c406ee0 100644 --- a/src/cmdlib.cpp +++ b/src/cmdlib.cpp @@ -957,7 +957,7 @@ void ScanDirectory(TArray &list, const char *dirpath) } } -#elif defined(__sun) || defined(linux) +#elif defined(__sun) || defined(__linux__) //========================================================================== // diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 11989b4a7..676f6a630 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -223,7 +223,7 @@ struct FCoverageBuilder { FCoverageVertex *v1 = &shape[i]; FCoverageVertex *v2 = &shape[(i+1) % shape.Size()]; - FCoverageLine vl = { *v1, *v2 }; + FCoverageLine vl = {{*v1, *v2}}; double dist_v1 = PartitionDistance(v1, bsp); double dist_v2 = PartitionDistance(v2, bsp); diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index d822ac440..342f58fa1 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -130,7 +130,7 @@ static int MergeMapSections(int num) cvertex_t vt; // first step: Set mapsection for all vertex positions. - for(DWORD i=0;iSubsector->mapsection; @@ -142,7 +142,7 @@ static int MergeMapSections(int num) } // second step: Check if any seg references more than one mapsection, either by subsector or by vertex - for(DWORD i=0;iSubsector->mapsection; @@ -733,4 +733,4 @@ CCMD(listmapsections) } } } -} \ No newline at end of file +} diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 95ab7b567..3d9c8627d 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -781,7 +781,7 @@ void GLPlaneMirrorPortal::DrawContents() gl.Enable(GL_CLIP_PLANE0+renderdepth); // This only works properly for non-sloped planes so don't bother with the math. //double d[4]={origin->a/65536., origin->c/65536., origin->b/65536., FIXED2FLOAT(origin->d)}; - double d[4]={0, PlaneMirrorMode, 0, FIXED2FLOAT(origin->d)}; + double d[4]={0, static_cast(PlaneMirrorMode), 0, FIXED2FLOAT(origin->d)}; gl.ClipPlane(GL_CLIP_PLANE0+renderdepth, d); GLRenderer->DrawScene(); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 6789c2c20..964f623d7 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -44,7 +44,7 @@ #include "i_system.h" #include "gl/system/gl_cvars.h" -#if defined (unix) || defined (__APPLE__) +#if defined (__unix__) || defined (__APPLE__) #include #define wglGetProcAddress(x) (*SDL_GL_GetProcAddress)(x) #endif @@ -210,7 +210,7 @@ void gl_LoadExtensions() // Don't even start if it's lower than 1.4 if (strcmp(version, "1.4") < 0) { - I_FatalError("Unsupported OpenGL version.\nAt least GL 1.4 is required to run "GAMENAME".\n"); + I_FatalError("Unsupported OpenGL version.\nAt least GL 1.4 is required to run " GAMENAME ".\n"); } // This loads any function pointers and flags that require a vaild render context to diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 53d01a3b9..f2d31ee0c 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -430,7 +430,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int cm, int clampmode, int if (!hwtex->Bind(texunit, cm, translation)) { - int w, h; + int w=0, h=0; // Create this texture unsigned char * buffer = NULL; diff --git a/src/sdl/sdlglvideo.cpp b/src/sdl/sdlglvideo.cpp index 868cf0afc..649989e6d 100644 --- a/src/sdl/sdlglvideo.cpp +++ b/src/sdl/sdlglvideo.cpp @@ -56,7 +56,7 @@ EXTERN_CVAR (Int, vid_renderer) CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL ) { - Printf("This won't take effect until "GAMENAME" is restarted.\n"); + Printf("This won't take effect until " GAMENAME " is restarted.\n"); } // PRIVATE DATA DEFINITIONS ------------------------------------------------ From 4dc06cca704b15cb5133a3518557e5a097c1fd48 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 2 Sep 2013 08:43:56 +0200 Subject: [PATCH 0026/1509] - changed minimum required GL version to 1.3. The only 1.4 feature that's required is mipmap generation which on many older cards is available as an extension. The worst thing that can happen with relaxing the version requirement is that on a few ancient graphics cards the mipmapped texture filtering modes produce garbage. --- src/gl/system/gl_interface.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 964f623d7..299ea7878 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -42,6 +42,7 @@ #include "zstring.h" #include "version.h" #include "i_system.h" +#include "v_text.h" #include "gl/system/gl_cvars.h" #if defined (__unix__) || defined (__APPLE__) @@ -207,10 +208,16 @@ void gl_LoadExtensions() const char *version = (const char*)glGetString(GL_VERSION); - // Don't even start if it's lower than 1.4 - if (strcmp(version, "1.4") < 0) + // Don't even start if it's lower than 1.3 + if (strcmp(version, "1.3") < 0) { - I_FatalError("Unsupported OpenGL version.\nAt least GL 1.4 is required to run " GAMENAME ".\n"); + I_FatalError("Unsupported OpenGL version.\nAt least GL 1.3 is required to run " GAMENAME ".\n"); + } + else if (strcmp(version, "1.4") < 0) + { + // The engine will still assume 1.4 but the only 1.4 feature being used is GL_GENERATE_MIPMAP which should be supported as an extension + // on most 1.3 cards this is present but let's print a warning that not everything may work as intended. + Printf(TEXTCOLOR_RED "The current graphics driver implements a OpenGL version lower than 1.4 and may not support all features " GAMENAME " requires.\n"); } // This loads any function pointers and flags that require a vaild render context to From 26943fe3fd45301ac0e97c38ef81eda69242e72c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 Sep 2013 14:05:41 +0200 Subject: [PATCH 0027/1509] - removed gl interface function pointers for all OpenGL32.dll entry points. --- src/gl/data/gl_vertexbuffer.cpp | 6 +- src/gl/dynlights/gl_dynlight1.cpp | 2 +- src/gl/dynlights/gl_lightbuffer.cpp | 28 +-- src/gl/models/gl_models.cpp | 84 ++++---- src/gl/models/gl_models_md2.cpp | 8 +- src/gl/models/gl_models_md3.cpp | 12 +- src/gl/models/gl_voxels.cpp | 14 +- src/gl/renderer/gl_lightdata.cpp | 4 +- src/gl/renderer/gl_renderer.cpp | 138 +++++++------- src/gl/renderer/gl_renderstate.cpp | 24 +-- src/gl/scene/gl_decal.cpp | 10 +- src/gl/scene/gl_drawinfo.cpp | 86 ++++----- src/gl/scene/gl_flats.cpp | 42 ++-- src/gl/scene/gl_portal.cpp | 224 +++++++++++----------- src/gl/scene/gl_scene.cpp | 154 +++++++-------- src/gl/scene/gl_skydome.cpp | 286 ++++++++++++++-------------- src/gl/scene/gl_sprite.cpp | 38 ++-- src/gl/scene/gl_spritelight.cpp | 6 +- src/gl/scene/gl_vertex.cpp | 16 +- src/gl/scene/gl_walls_draw.cpp | 52 ++--- src/gl/scene/gl_weapon.cpp | 14 +- src/gl/system/gl_framebuffer.cpp | Bin 14716 -> 30486 bytes src/gl/system/gl_interface.cpp | 76 -------- src/gl/system/gl_interface.h | 74 ------- src/gl/system/gl_wipe.cpp | 166 ++++++++-------- src/gl/textures/gl_hwtexture.cpp | 38 ++-- src/gl/textures/gl_material.cpp | 12 +- 27 files changed, 732 insertions(+), 882 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 036224338..5c43c256c 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -366,9 +366,9 @@ void FFlatVertexBuffer::BindVBO() gl.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glVertexPointer(3,GL_FLOAT, sizeof(FFlatVertex), &VTO->x); glTexCoordPointer(2,GL_FLOAT, sizeof(FFlatVertex), &VTO->u); - gl.EnableClientState(GL_VERTEX_ARRAY); - gl.EnableClientState(GL_TEXTURE_COORD_ARRAY); - gl.DisableClientState(GL_INDEX_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_INDEX_ARRAY); } } diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index 4c9f929f4..386590f61 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -227,7 +227,7 @@ bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & u g= (g*(32-desaturation)+ gray*desaturation)/32; b= (b*(32-desaturation)+ gray*desaturation)/32; } - gl.Color3f(r,g,b); + glColor3f(r,g,b); return true; } diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index d3a62a718..6280f650b 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -72,12 +72,12 @@ FLightBuffer::FLightBuffer() gl.GenBuffers(1, &mIDbuf_Position); gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); - gl.GenTextures(1, &mIDtex_RGB); - gl.BindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB); + glGenTextures(1, &mIDtex_RGB); + glBindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB); gl.TexBufferARB(GL_TEXTURE_BUFFER, GL_RGBA8, mIDbuf_RGB); - gl.GenTextures(1, &mIDtex_Position); - gl.BindTexture(GL_TEXTURE_BUFFER, mIDtex_Position); + glGenTextures(1, &mIDtex_Position); + glBindTexture(GL_TEXTURE_BUFFER, mIDtex_Position); gl.TexBufferARB(GL_TEXTURE_BUFFER, GL_RGBA32F, mIDbuf_Position); } @@ -94,9 +94,9 @@ FLightBuffer::~FLightBuffer() gl.DeleteBuffers(1, &mIDbuf_RGB); gl.DeleteBuffers(1, &mIDbuf_Position); - gl.BindTexture(GL_TEXTURE_BUFFER, 0); - gl.DeleteTextures(1, &mIDtex_RGB); - gl.DeleteTextures(1, &mIDtex_Position); + glBindTexture(GL_TEXTURE_BUFFER, 0); + glDeleteTextures(1, &mIDtex_RGB); + glDeleteTextures(1, &mIDtex_Position); } @@ -109,9 +109,9 @@ FLightBuffer::~FLightBuffer() void FLightBuffer::BindTextures(int texunit1, int texunit2) { gl.ActiveTexture(texunit1); - gl.BindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB); + glBindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB); gl.ActiveTexture(texunit2); - gl.BindTexture(GL_TEXTURE_BUFFER, mIDtex_Position); + glBindTexture(GL_TEXTURE_BUFFER, mIDtex_Position); gl.ActiveTexture(GL_TEXTURE0); } @@ -176,8 +176,8 @@ FLightIndexBuffer::FLightIndexBuffer() gl.GenBuffers(1, &mIDBuffer); gl.BindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); - gl.GenTextures(1, &mIDTexture); - gl.BindTexture(GL_TEXTURE_BUFFER, mIDTexture); + glGenTextures(1, &mIDTexture); + glBindTexture(GL_TEXTURE_BUFFER, mIDTexture); gl.TexBufferARB(GL_TEXTURE_BUFFER, GL_R16UI, mIDBuffer); } @@ -192,8 +192,8 @@ FLightIndexBuffer::~FLightIndexBuffer() gl.BindBuffer(GL_TEXTURE_BUFFER, 0); gl.DeleteBuffers(1, &mIDBuffer); - gl.BindTexture(GL_TEXTURE_BUFFER, 0); - gl.DeleteTextures(1, &mIDTexture); + glBindTexture(GL_TEXTURE_BUFFER, 0); + glDeleteTextures(1, &mIDTexture); } @@ -234,7 +234,7 @@ void FLightIndexBuffer::SendBuffer() void FLightIndexBuffer::BindTexture(int texunit1) { gl.ActiveTexture(texunit1); - gl.BindTexture(GL_TEXTURE_BUFFER, mIDTexture); + glBindTexture(GL_TEXTURE_BUFFER, mIDTexture); gl.ActiveTexture(GL_TEXTURE0); } diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 9f13bee7d..3a89bcbbc 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -696,7 +696,7 @@ void gl_RenderModel(GLSprite * spr, int cm) // Setup transformation. - gl.DepthFunc(GL_LEQUAL); + glDepthFunc(GL_LEQUAL); gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.EnableTexture(true); // [BB] In case the model should be rendered translucent, do back face culling. @@ -704,7 +704,7 @@ void gl_RenderModel(GLSprite * spr, int cm) // TO-DO: Implement proper depth sorting. if (!( spr->actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) { - gl.Enable(GL_CULL_FACE); + glEnable(GL_CULL_FACE); glFrontFace(GL_CW); } @@ -754,45 +754,45 @@ void gl_RenderModel(GLSprite * spr, int cm) if (gl.shadermodel < 4) { - gl.MatrixMode(GL_MODELVIEW); - gl.PushMatrix(); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); } else { gl.ActiveTexture(GL_TEXTURE7); // Hijack the otherwise unused seventh texture matrix for the model to world transformation. - gl.MatrixMode(GL_TEXTURE); - gl.LoadIdentity(); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); } // Model space => World space - gl.Translatef(spr->x, spr->z, spr->y ); + glTranslatef(spr->x, spr->z, spr->y ); // Applying model transformations: // 1) Applying actor angle, pitch and roll to the model - gl.Rotatef(-angle, 0, 1, 0); - gl.Rotatef(pitch, 0, 0, 1); - gl.Rotatef(-roll, 1, 0, 0); + glRotatef(-angle, 0, 1, 0); + glRotatef(pitch, 0, 0, 1); + glRotatef(-roll, 1, 0, 0); // 2) Applying Doomsday like rotation of the weapon pickup models // The rotation angle is based on the elapsed time. if( smf->flags & MDL_ROTATING ) { - gl.Translatef(smf->rotationCenterX, smf->rotationCenterY, smf->rotationCenterZ); - gl.Rotatef(rotateOffset, smf->xrotate, smf->yrotate, smf->zrotate); - gl.Translatef(-smf->rotationCenterX, -smf->rotationCenterY, -smf->rotationCenterZ); + glTranslatef(smf->rotationCenterX, smf->rotationCenterY, smf->rotationCenterZ); + glRotatef(rotateOffset, smf->xrotate, smf->yrotate, smf->zrotate); + glTranslatef(-smf->rotationCenterX, -smf->rotationCenterY, -smf->rotationCenterZ); } // 3) Scaling model. - gl.Scalef(scaleFactorX, scaleFactorZ, scaleFactorY); + glScalef(scaleFactorX, scaleFactorZ, scaleFactorY); // 4) Aplying model offsets (model offsets do not depend on model scalings). - gl.Translatef(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); + glTranslatef(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); // 5) Applying model rotations. - gl.Rotatef(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); - gl.Rotatef(smf->pitchoffset, 0, 0, 1); - gl.Rotatef(-smf->rolloffset, 1, 0, 0); + glRotatef(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); + glRotatef(smf->pitchoffset, 0, 0, 1); + glRotatef(-smf->rolloffset, 1, 0, 0); if (gl.shadermodel >= 4) gl.ActiveTexture(GL_TEXTURE0); @@ -815,21 +815,21 @@ void gl_RenderModel(GLSprite * spr, int cm) if (gl.shadermodel < 4) { - gl.MatrixMode(GL_MODELVIEW); - gl.PopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); } else { gl.ActiveTexture(GL_TEXTURE7); - gl.MatrixMode(GL_TEXTURE); - gl.LoadIdentity(); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); gl.ActiveTexture(GL_TEXTURE0); - gl.MatrixMode(GL_MODELVIEW); + glMatrixMode(GL_MODELVIEW); } - gl.DepthFunc(GL_LESS); + glDepthFunc(GL_LESS); if (!( spr->actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) - gl.Disable(GL_CULL_FACE); + glDisable(GL_CULL_FACE); } @@ -850,45 +850,45 @@ void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy, int cm) // [BB] The model has to be drawn independtly from the position of the player, // so we have to reset the GL_MODELVIEW matrix. - gl.MatrixMode(GL_MODELVIEW); - gl.PushMatrix(); - gl.LoadIdentity(); - gl.DepthFunc(GL_LEQUAL); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glDepthFunc(GL_LEQUAL); // [BB] In case the model should be rendered translucent, do back face culling. // This solves a few of the problems caused by the lack of depth sorting. // TO-DO: Implement proper depth sorting. if (!( playermo->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) { - gl.Enable(GL_CULL_FACE); + glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); } // Scaling model (y scale for a sprite means height, i.e. z in the world!). - gl.Scalef(smf->xscale, smf->zscale, smf->yscale); + glScalef(smf->xscale, smf->zscale, smf->yscale); // Aplying model offsets (model offsets do not depend on model scalings). - gl.Translatef(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); + glTranslatef(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); // [BB] Weapon bob, very similar to the normal Doom weapon bob. - gl.Rotatef(FIXED2FLOAT(ofsx)/4, 0, 1, 0); - gl.Rotatef(-FIXED2FLOAT(ofsy-WEAPONTOP)/4, 1, 0, 0); + glRotatef(FIXED2FLOAT(ofsx)/4, 0, 1, 0); + glRotatef(-FIXED2FLOAT(ofsy-WEAPONTOP)/4, 1, 0, 0); // [BB] For some reason the jDoom models need to be rotated. - gl.Rotatef(90., 0, 1, 0); + glRotatef(90., 0, 1, 0); // Applying angleoffset, pitchoffset, rolloffset. - gl.Rotatef(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); - gl.Rotatef(smf->pitchoffset, 0, 0, 1); - gl.Rotatef(-smf->rolloffset, 1, 0, 0); + glRotatef(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); + glRotatef(smf->pitchoffset, 0, 0, 1); + glRotatef(-smf->rolloffset, 1, 0, 0); gl_RenderFrameModels( smf, psp->state, psp->tics, playermo->player->ReadyWeapon->GetClass(), cm, NULL, 0 ); - gl.MatrixMode(GL_MODELVIEW); - gl.PopMatrix(); - gl.DepthFunc(GL_LESS); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glDepthFunc(GL_LESS); if (!( playermo->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) - gl.Disable(GL_CULL_FACE); + glDisable(GL_CULL_FACE); } //=========================================================================== diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index 1ff98629d..f5ac5d2bf 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -279,7 +279,7 @@ void FDMDModel::RenderGLCommands(void *glCommands, unsigned int numVertices,FMod pos += 4; // The type of primitive depends on the sign. - gl.Begin(count > 0 ? GL_TRIANGLE_STRIP : GL_TRIANGLE_FAN); + glBegin(count > 0 ? GL_TRIANGLE_STRIP : GL_TRIANGLE_FAN); count = abs(count); while(count--) @@ -287,11 +287,11 @@ void FDMDModel::RenderGLCommands(void *glCommands, unsigned int numVertices,FMod v = (FGLCommandVertex *) pos; pos += sizeof(FGLCommandVertex); - gl.TexCoord2fv(&v->s); - gl.Vertex3fv((float*)&vertices[v->index]); + glTexCoord2fv(&v->s); + glVertex3fv((float*)&vertices[v->index]); } - gl.End(); + glEnd(); } } diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index 72bf6d655..12509b769 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -218,18 +218,18 @@ int FMD3Model::FindFrame(const char * name) void FMD3Model::RenderTriangles(MD3Surface * surf, MD3Vertex * vert) { gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLES); + glBegin(GL_TRIANGLES); for(int i=0; inumTriangles;i++) { for(int j=0;j<3;j++) { int x = surf->tris[i].VertIndex[j]; - gl.TexCoord2fv(&surf->texcoords[x].s); - gl.Vertex3f(vert[x].x, vert[x].z, vert[x].y); + glTexCoord2fv(&surf->texcoords[x].s); + glVertex3f(vert[x].x, vert[x].z, vert[x].y); } } - gl.End(); + glEnd(); } void FMD3Model::RenderFrame(FTexture * skin, int frameno, int cm, int translation) @@ -239,8 +239,8 @@ void FMD3Model::RenderFrame(FTexture * skin, int frameno, int cm, int translatio MD3Frame * frame = &frames[frameno]; // I can't confirm correctness of this because no model I have tested uses this information - // gl.MatrixMode(GL_MODELVIEW); - // gl.Translatef(frame->origin[0], frame->origin[1], frame->origin[2]); + // glMatrixMode(GL_MODELVIEW); + // glTranslatef(frame->origin[0], frame->origin[1], frame->origin[2]); for(int i=0;ix); glTexCoordPointer(2,GL_FLOAT, sizeof(FVoxelVertex), &VVO->u); - gl.EnableClientState(GL_VERTEX_ARRAY); - gl.EnableClientState(GL_TEXTURE_COORD_ARRAY); - gl.EnableClientState(GL_INDEX_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableClientState(GL_INDEX_ARRAY); } @@ -481,14 +481,14 @@ void FVoxelModel::RenderFrame(FTexture * skin, int frame, int cm, int translatio } } - gl.Begin(GL_QUADS); + glBegin(GL_QUADS); for(unsigned i=0;i < mIndices.Size(); i++) { FVoxelVertex *vert = &mVertices[mIndices[i]]; - gl.TexCoord2fv(&vert->u); - gl.Vertex3fv(&vert->x); + glTexCoord2fv(&vert->u); + glVertex3fv(&vert->x); } - gl.End(); + glEnd(); } //=========================================================================== diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 9c77803fc..5be90d3cf 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -331,11 +331,11 @@ void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, Pal if (glset.lightmode != 8) { - gl.Color4f(r * ThingColor.r/255.0f, g * ThingColor.g/255.0f, b * ThingColor.b/255.0f, alpha); + glColor4f(r * ThingColor.r/255.0f, g * ThingColor.g/255.0f, b * ThingColor.b/255.0f, alpha); } else { - gl.Color4f(r, g, b, alpha); + glColor4f(r, g, b, alpha); if (gl_fixedcolormap) { diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index e398a04c2..b1ef3244f 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -267,33 +267,33 @@ void FGLRenderer::ClearBorders() int borderHeight = (trueHeight - height) / 2; - gl.Viewport(0, 0, width, trueHeight); - gl.MatrixMode(GL_PROJECTION); - gl.LoadIdentity(); - gl.Ortho(0.0, width * 1.0, 0.0, trueHeight, -1.0, 1.0); - gl.MatrixMode(GL_MODELVIEW); - gl.Color3f(0.f, 0.f, 0.f); + glViewport(0, 0, width, trueHeight); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0.0, width * 1.0, 0.0, trueHeight, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glColor3f(0.f, 0.f, 0.f); gl_RenderState.Set2DMode(true); gl_RenderState.EnableTexture(false); gl_RenderState.Apply(true); - gl.Begin(GL_QUADS); + glBegin(GL_QUADS); // upper quad - gl.Vertex2i(0, borderHeight); - gl.Vertex2i(0, 0); - gl.Vertex2i(width, 0); - gl.Vertex2i(width, borderHeight); + glVertex2i(0, borderHeight); + glVertex2i(0, 0); + glVertex2i(width, 0); + glVertex2i(width, borderHeight); // lower quad - gl.Vertex2i(0, trueHeight); - gl.Vertex2i(0, trueHeight - borderHeight); - gl.Vertex2i(width, trueHeight - borderHeight); - gl.Vertex2i(width, trueHeight); - gl.End(); + glVertex2i(0, trueHeight); + glVertex2i(0, trueHeight - borderHeight); + glVertex2i(width, trueHeight - borderHeight); + glVertex2i(width, trueHeight); + glEnd(); gl_RenderState.EnableTexture(true); - gl.Viewport(0, (trueHeight - height) / 2, width, height); + glViewport(0, (trueHeight - height) / 2, width, height); } //========================================================================== @@ -386,9 +386,9 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) int btm = (SCREENHEIGHT - screen->GetHeight()) / 2; btm = SCREENHEIGHT - btm; - gl.Enable(GL_SCISSOR_TEST); + glEnable(GL_SCISSOR_TEST); int space = (static_cast(screen)->GetTrueHeight()-screen->GetHeight())/2; - gl.Scissor(parms.lclip, btm - parms.dclip + space, parms.rclip - parms.lclip, parms.dclip - parms.uclip); + glScissor(parms.lclip, btm - parms.dclip + space, parms.rclip - parms.lclip, parms.dclip - parms.uclip); gl_SetRenderStyle(parms.style, !parms.masked, false); if (img->bHasCanvas) @@ -396,20 +396,20 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) gl_RenderState.SetTextureMode(TM_OPAQUE); } - gl.Color4f(r, g, b, FIXED2FLOAT(parms.alpha)); + glColor4f(r, g, b, FIXED2FLOAT(parms.alpha)); gl_RenderState.EnableAlphaTest(false); gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_STRIP); - gl.TexCoord2f(u1, v1); + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(u1, v1); glVertex2d(x, y); - gl.TexCoord2f(u1, v2); + glTexCoord2f(u1, v2); glVertex2d(x, y + h); - gl.TexCoord2f(u2, v1); + glTexCoord2f(u2, v1); glVertex2d(x + w, y); - gl.TexCoord2f(u2, v2); + glTexCoord2f(u2, v2); glVertex2d(x + w, y + h); - gl.End(); + glEnd(); if (parms.colorOverlay) { @@ -417,23 +417,23 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.BlendEquation(GL_FUNC_ADD); gl_RenderState.Apply(); - gl.Color4ub(RPART(parms.colorOverlay),GPART(parms.colorOverlay),BPART(parms.colorOverlay),APART(parms.colorOverlay)); - gl.Begin(GL_TRIANGLE_STRIP); - gl.TexCoord2f(u1, v1); + glColor4ub(RPART(parms.colorOverlay),GPART(parms.colorOverlay),BPART(parms.colorOverlay),APART(parms.colorOverlay)); + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(u1, v1); glVertex2d(x, y); - gl.TexCoord2f(u1, v2); + glTexCoord2f(u1, v2); glVertex2d(x, y + h); - gl.TexCoord2f(u2, v1); + glTexCoord2f(u2, v1); glVertex2d(x + w, y); - gl.TexCoord2f(u2, v2); + glTexCoord2f(u2, v2); glVertex2d(x + w, y + h); - gl.End(); + glEnd(); } gl_RenderState.EnableAlphaTest(true); - gl.Scissor(0, 0, screen->GetWidth(), screen->GetHeight()); - gl.Disable(GL_SCISSOR_TEST); + glScissor(0, 0, screen->GetWidth(), screen->GetHeight()); + glDisable(GL_SCISSOR_TEST); gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.BlendEquation(GL_FUNC_ADD); @@ -449,11 +449,11 @@ void FGLRenderer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 PalEntry p = color? (PalEntry)color : GPalette.BaseColors[palcolor]; gl_RenderState.EnableTexture(false); gl_RenderState.Apply(true); - gl.Color3ub(p.r, p.g, p.b); - gl.Begin(GL_LINES); - gl.Vertex2i(x1, y1); - gl.Vertex2i(x2, y2); - gl.End(); + glColor3ub(p.r, p.g, p.b); + glBegin(GL_LINES); + glVertex2i(x1, y1); + glVertex2i(x2, y2); + glEnd(); gl_RenderState.EnableTexture(true); } @@ -467,10 +467,10 @@ void FGLRenderer::DrawPixel(int x1, int y1, int palcolor, uint32 color) PalEntry p = color? (PalEntry)color : GPalette.BaseColors[palcolor]; gl_RenderState.EnableTexture(false); gl_RenderState.Apply(true); - gl.Color3ub(p.r, p.g, p.b); - gl.Begin(GL_POINTS); - gl.Vertex2i(x1, y1); - gl.End(); + glColor3ub(p.r, p.g, p.b); + glBegin(GL_POINTS); + glVertex2i(x1, y1); + glEnd(); gl_RenderState.EnableTexture(true); } @@ -493,13 +493,13 @@ void FGLRenderer::Dim(PalEntry color, float damount, int x1, int y1, int w, int g = color.g/255.0f; b = color.b/255.0f; - gl.Begin(GL_TRIANGLE_FAN); - gl.Color4f(r, g, b, damount); - gl.Vertex2i(x1, y1); - gl.Vertex2i(x1, y1 + h); - gl.Vertex2i(x1 + w, y1 + h); - gl.Vertex2i(x1 + w, y1); - gl.End(); + glBegin(GL_TRIANGLE_FAN); + glColor4f(r, g, b, damount); + glVertex2i(x1, y1); + glVertex2i(x1, y1 + h); + glVertex2i(x1 + w, y1 + h); + glVertex2i(x1 + w, y1); + glEnd(); gl_RenderState.EnableTexture(true); } @@ -535,13 +535,13 @@ void FGLRenderer::FlatFill (int left, int top, int right, int bottom, FTexture * fV2 = float(bottom-top) / src->GetHeight(); } gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_STRIP); - gl.Color4f(1, 1, 1, 1); - gl.TexCoord2f(fU1, fV1); gl.Vertex2f(left, top); - gl.TexCoord2f(fU1, fV2); gl.Vertex2f(left, bottom); - gl.TexCoord2f(fU2, fV1); gl.Vertex2f(right, top); - gl.TexCoord2f(fU2, fV2); gl.Vertex2f(right, bottom); - gl.End(); + glBegin(GL_TRIANGLE_STRIP); + glColor4f(1, 1, 1, 1); + glTexCoord2f(fU1, fV1); glVertex2f(left, top); + glTexCoord2f(fU1, fV2); glVertex2f(left, bottom); + glTexCoord2f(fU2, fV1); glVertex2f(right, top); + glTexCoord2f(fU2, fV2); glVertex2f(right, bottom); + glEnd(); } //========================================================================== @@ -570,14 +570,14 @@ void FGLRenderer::Clear(int left, int top, int right, int bottom, int palcolor, } */ - gl.Enable(GL_SCISSOR_TEST); - gl.Scissor(left, rt - height, width, height); + glEnable(GL_SCISSOR_TEST); + glScissor(left, rt - height, width, height); - gl.ClearColor(p.r/255.0f, p.g/255.0f, p.b/255.0f, 0.f); - gl.Clear(GL_COLOR_BUFFER_BIT); - gl.ClearColor(0.f, 0.f, 0.f, 0.f); + glClearColor(p.r/255.0f, p.g/255.0f, p.b/255.0f, 0.f); + glClear(GL_COLOR_BUFFER_BIT); + glClearColor(0.f, 0.f, 0.f, 0.f); - gl.Disable(GL_SCISSOR_TEST); + glDisable(GL_SCISSOR_TEST); } //========================================================================== @@ -609,7 +609,7 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint lightlevel = gl_CalcLightLevel(lightlevel, 0, true); PalEntry pe = gl_CalcLightColor(lightlevel, cm.LightColor, cm.blendfactor, true); - gl.Color3ub(pe.r, pe.g, pe.b); + glColor3ub(pe.r, pe.g, pe.b); gltexture->Bind(cm.colormap); @@ -631,7 +631,7 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint float oy = float(originy); gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_FAN); + glBegin(GL_TRIANGLE_FAN); for (i = 0; i < npoints; ++i) { float u = points[i].X - 0.5f - ox; @@ -642,9 +642,9 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint u = t * cosrot - v * sinrot; v = v * cosrot + t * sinrot; } - gl.TexCoord2f(u * uscale, v * vscale); - gl.Vertex3f(points[i].X, points[i].Y /* + yoffs */, 0); + glTexCoord2f(u * uscale, v * vscale); + glVertex3f(points[i].X, points[i].Y /* + yoffs */, 0); } - gl.End(); + glEnd(); } diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index f986d7afc..7f7a2df67 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -297,16 +297,16 @@ void FRenderState::Apply(bool forcenoshader) } if (mTextureEnabled != ffTextureEnabled) { - if ((ffTextureEnabled = mTextureEnabled)) gl.Enable(GL_TEXTURE_2D); - else gl.Disable(GL_TEXTURE_2D); + if ((ffTextureEnabled = mTextureEnabled)) glEnable(GL_TEXTURE_2D); + else glDisable(GL_TEXTURE_2D); } if (mFogEnabled != ffFogEnabled) { if ((ffFogEnabled = mFogEnabled)) { - gl.Enable(GL_FOG); + glEnable(GL_FOG); } - else gl.Disable(GL_FOG); + else glDisable(GL_FOG); } if (mFogEnabled) { @@ -314,11 +314,11 @@ void FRenderState::Apply(bool forcenoshader) { ffFogColor = mFogColor; GLfloat FogColor[4]={mFogColor.r/255.0f,mFogColor.g/255.0f,mFogColor.b/255.0f,0.0f}; - gl.Fogfv(GL_FOG_COLOR, FogColor); + glFogfv(GL_FOG_COLOR, FogColor); } if (ffFogDensity != mFogDensity) { - gl.Fogf(GL_FOG_DENSITY, mFogDensity/64000.f); + glFogf(GL_FOG_DENSITY, mFogDensity/64000.f); ffFogDensity=mFogDensity; } } @@ -327,8 +327,8 @@ void FRenderState::Apply(bool forcenoshader) switch (ffSpecialEffect) { case EFF_SPHEREMAP: - gl.Disable(GL_TEXTURE_GEN_T); - gl.Disable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + glDisable(GL_TEXTURE_GEN_S); default: break; @@ -337,10 +337,10 @@ void FRenderState::Apply(bool forcenoshader) { case EFF_SPHEREMAP: // Use sphere mapping for this - gl.Enable(GL_TEXTURE_GEN_T); - gl.Enable(GL_TEXTURE_GEN_S); - gl.TexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP); - gl.TexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP); + glEnable(GL_TEXTURE_GEN_T); + glEnable(GL_TEXTURE_GEN_S); + glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP); + glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP); break; default: diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index b6478dd22..6bb109fa4 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -363,7 +363,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) if (loadAlpha) { - gl.Color4f(red, green, blue, a); + glColor4f(red, green, blue, a); if (glset.lightmode == 8) { @@ -399,13 +399,13 @@ void GLWall::DrawDecal(DBaseDecal *decal) else gl_RenderState.AlphaFunc(GL_GREATER, 0.f); gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_FAN); + glBegin(GL_TRIANGLE_FAN); for(i=0;i<4;i++) { - gl.TexCoord2f(dv[i].u,dv[i].v); - gl.Vertex3f(dv[i].x,dv[i].z,dv[i].y); + glTexCoord2f(dv[i].u,dv[i].v); + glVertex3f(dv[i].x,dv[i].z,dv[i].y); } - gl.End(); + glEnd(); rendered_decals++; gl_RenderState.SetFog(fc,-1); gl_RenderState.SetDynLight(0,0,0); diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index a03cb01e2..62e604aca 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -981,55 +981,55 @@ void FDrawInfo::SetupFloodStencil(wallseg * ws) int recursion = GLPortal::GetRecursion(); // Create stencil - gl.StencilFunc(GL_EQUAL,recursion,~0); // create stencil - gl.StencilOp(GL_KEEP,GL_KEEP,GL_INCR); // increment stencil of valid pixels - gl.ColorMask(0,0,0,0); // don't write to the graphics buffer + glStencilFunc(GL_EQUAL,recursion,~0); // create stencil + glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); // increment stencil of valid pixels + glColorMask(0,0,0,0); // don't write to the graphics buffer gl_RenderState.EnableTexture(false); - gl.Color3f(1,1,1); - gl.Enable(GL_DEPTH_TEST); - gl.DepthMask(true); + glColor3f(1,1,1); + glEnable(GL_DEPTH_TEST); + glDepthMask(true); gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_FAN); - gl.Vertex3f(ws->x1, ws->z1, ws->y1); - gl.Vertex3f(ws->x1, ws->z2, ws->y1); - gl.Vertex3f(ws->x2, ws->z2, ws->y2); - gl.Vertex3f(ws->x2, ws->z1, ws->y2); - gl.End(); + glBegin(GL_TRIANGLE_FAN); + glVertex3f(ws->x1, ws->z1, ws->y1); + glVertex3f(ws->x1, ws->z2, ws->y1); + glVertex3f(ws->x2, ws->z2, ws->y2); + glVertex3f(ws->x2, ws->z1, ws->y2); + glEnd(); - gl.StencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil - gl.StencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil + glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil + glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil - gl.ColorMask(1,1,1,1); // don't write to the graphics buffer + glColorMask(1,1,1,1); // don't write to the graphics buffer gl_RenderState.EnableTexture(true); - gl.Disable(GL_DEPTH_TEST); - gl.DepthMask(false); + glDisable(GL_DEPTH_TEST); + glDepthMask(false); } void FDrawInfo::ClearFloodStencil(wallseg * ws) { int recursion = GLPortal::GetRecursion(); - gl.StencilOp(GL_KEEP,GL_KEEP,GL_DECR); + glStencilOp(GL_KEEP,GL_KEEP,GL_DECR); gl_RenderState.EnableTexture(false); - gl.ColorMask(0,0,0,0); // don't write to the graphics buffer - gl.Color3f(1,1,1); + glColorMask(0,0,0,0); // don't write to the graphics buffer + glColor3f(1,1,1); gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_FAN); - gl.Vertex3f(ws->x1, ws->z1, ws->y1); - gl.Vertex3f(ws->x1, ws->z2, ws->y1); - gl.Vertex3f(ws->x2, ws->z2, ws->y2); - gl.Vertex3f(ws->x2, ws->z1, ws->y2); - gl.End(); + glBegin(GL_TRIANGLE_FAN); + glVertex3f(ws->x1, ws->z1, ws->y1); + glVertex3f(ws->x1, ws->z2, ws->y1); + glVertex3f(ws->x2, ws->z2, ws->y2); + glVertex3f(ws->x2, ws->z1, ws->y2); + glEnd(); // restore old stencil op. - gl.StencilOp(GL_KEEP,GL_KEEP,GL_KEEP); - gl.StencilFunc(GL_EQUAL,recursion,~0); + glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); + glStencilFunc(GL_EQUAL,recursion,~0); gl_RenderState.EnableTexture(true); - gl.ColorMask(1,1,1,1); - gl.Enable(GL_DEPTH_TEST); - gl.DepthMask(true); + glColorMask(1,1,1,1); + glEnable(GL_DEPTH_TEST); + glDepthMask(true); } //========================================================================== @@ -1078,7 +1078,7 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo bool pushed = gl_SetPlaneTextureRotation(&plane, gltexture); - gl.Begin(GL_TRIANGLE_FAN); + glBegin(GL_TRIANGLE_FAN); float prj_fac1 = (planez-fviewz)/(ws->z1-fviewz); float prj_fac2 = (planez-fviewz)/(ws->z2-fviewz); @@ -1094,24 +1094,24 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo float px4 = fviewx + prj_fac1 * (ws->x2-fviewx); float py4 = fviewy + prj_fac1 * (ws->y2-fviewy); - gl.TexCoord2f(px1 / 64, -py1 / 64); - gl.Vertex3f(px1, planez, py1); + glTexCoord2f(px1 / 64, -py1 / 64); + glVertex3f(px1, planez, py1); - gl.TexCoord2f(px2 / 64, -py2 / 64); - gl.Vertex3f(px2, planez, py2); + glTexCoord2f(px2 / 64, -py2 / 64); + glVertex3f(px2, planez, py2); - gl.TexCoord2f(px3 / 64, -py3 / 64); - gl.Vertex3f(px3, planez, py3); + glTexCoord2f(px3 / 64, -py3 / 64); + glVertex3f(px3, planez, py3); - gl.TexCoord2f(px4 / 64, -py4 / 64); - gl.Vertex3f(px4, planez, py4); + glTexCoord2f(px4 / 64, -py4 / 64); + glVertex3f(px4, planez, py4); - gl.End(); + glEnd(); if (pushed) { - gl.PopMatrix(); - gl.MatrixMode(GL_MODELVIEW); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); } } diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 71f2bb6c9..309d5cdfb 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -93,12 +93,12 @@ bool gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * glte float xscale2=64.f/gltexture->TextureWidth(GLUSE_TEXTURE); float yscale2=64.f/gltexture->TextureHeight(GLUSE_TEXTURE); - gl.MatrixMode(GL_TEXTURE); - gl.PushMatrix(); - gl.Scalef(xscale1 ,yscale1,1.0f); - gl.Translatef(uoffs,voffs,0.0f); - gl.Scalef(xscale2 ,yscale2,1.0f); - gl.Rotatef(angle,0.0f,0.0f,1.0f); + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glScalef(xscale1 ,yscale1,1.0f); + glTranslatef(uoffs,voffs,0.0f); + glScalef(xscale2 ,yscale2,1.0f); + glRotatef(angle,0.0f,0.0f,1.0f); return true; } return false; @@ -150,7 +150,7 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) draw_dlightf++; // Render the light - gl.Begin(GL_TRIANGLE_FAN); + glBegin(GL_TRIANGLE_FAN); for(k = 0, v = sub->firstline; k < sub->numlines; k++, v++) { vertex_t *vt = v->v1; @@ -158,12 +158,12 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) t1.Set(vt->fx, zc, vt->fy); Vector nearToVert = t1 - nearPt; - gl.TexCoord2f( (nearToVert.Dot(right) * scale) + 0.5f, (nearToVert.Dot(up) * scale) + 0.5f); + glTexCoord2f( (nearToVert.Dot(right) * scale) + 0.5f, (nearToVert.Dot(up) * scale) + 0.5f); - gl.Vertex3f(vt->fx, zc, vt->fy); + glVertex3f(vt->fx, zc, vt->fy); } - gl.End(); + glEnd(); node = node->nextLight; } } @@ -237,16 +237,16 @@ bool GLFlat::SetupSubsectorLights(bool lightsapplied, subsector_t * sub) void GLFlat::DrawSubsector(subsector_t * sub) { - gl.Begin(GL_TRIANGLE_FAN); + glBegin(GL_TRIANGLE_FAN); for(unsigned int k=0; knumlines; k++) { vertex_t *vt = sub->firstline[k].v1; - gl.TexCoord2f(vt->fx/64.f, -vt->fy/64.f); + glTexCoord2f(vt->fx/64.f, -vt->fy/64.f); float zc = plane.plane.ZatPoint(vt->fx, vt->fy) + dz; - gl.Vertex3f(vt->fx, zc, vt->fy); + glVertex3f(vt->fx, zc, vt->fy); } - gl.End(); + glEnd(); flatvertices += sub->numlines; flatprimitives++; @@ -273,7 +273,7 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) { if (vboindex >= 0) { - //gl.Color3f( 1.f,.5f,.5f); + //glColor3f( 1.f,.5f,.5f); int index = vboindex; for (int i=0; isubsectorcount; i++) { @@ -282,7 +282,7 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) { if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub); - gl.DrawArrays(GL_TRIANGLE_FAN, index, sub->numlines); + glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines); flatvertices += sub->numlines; flatprimitives++; } @@ -291,7 +291,7 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) } else { - //gl.Color3f( .5f,1.f,.5f); // these are for testing the VBO stuff. + //glColor3f( .5f,1.f,.5f); // these are for testing the VBO stuff. // Draw the subsectors belonging to this sector for (int i=0; isubsectorcount; i++) { @@ -362,8 +362,8 @@ void GLFlat::Draw(int pass) DrawSubsectors(pass, false); if (pushed) { - gl.PopMatrix(); - gl.MatrixMode(GL_MODELVIEW); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); } break; } @@ -427,8 +427,8 @@ void GLFlat::Draw(int pass) gl_RenderState.EnableBrightmap(true); if (pushed) { - gl.PopMatrix(); - gl.MatrixMode(GL_MODELVIEW); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); } } if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 3d9c8627d..b0ee96d88 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -112,19 +112,19 @@ void GLPortal::BeginScene() //========================================================================== void GLPortal::ClearScreen() { - bool multi = !!gl.IsEnabled(GL_MULTISAMPLE); - gl.MatrixMode(GL_MODELVIEW); - gl.PushMatrix(); - gl.MatrixMode(GL_PROJECTION); - gl.PushMatrix(); + bool multi = !!glIsEnabled(GL_MULTISAMPLE); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); screen->Begin2D(false); screen->Dim(0, 1.f, 0, 0, SCREENWIDTH, SCREENHEIGHT); - gl.Enable(GL_DEPTH_TEST); - gl.MatrixMode(GL_PROJECTION); - gl.PopMatrix(); - gl.MatrixMode(GL_MODELVIEW); - gl.PopMatrix(); - if (multi) gl.Enable(GL_MULTISAMPLE); + glEnable(GL_DEPTH_TEST); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + if (multi) glEnable(GL_MULTISAMPLE); gl_RenderState.Set2DMode(false); } @@ -146,18 +146,18 @@ void GLPortal::DrawPortalStencil() { // Cap the stencil at the top and bottom // (cheap ass version) - gl.Begin(GL_TRIANGLE_FAN); - gl.Vertex3f(-32767.0f,32767.0f,-32767.0f); - gl.Vertex3f(-32767.0f,32767.0f, 32767.0f); - gl.Vertex3f( 32767.0f,32767.0f, 32767.0f); - gl.Vertex3f( 32767.0f,32767.0f,-32767.0f); - gl.End(); - gl.Begin(GL_TRIANGLE_FAN); - gl.Vertex3f(-32767.0f,-32767.0f,-32767.0f); - gl.Vertex3f(-32767.0f,-32767.0f, 32767.0f); - gl.Vertex3f( 32767.0f,-32767.0f, 32767.0f); - gl.Vertex3f( 32767.0f,-32767.0f,-32767.0f); - gl.End(); + glBegin(GL_TRIANGLE_FAN); + glVertex3f(-32767.0f,32767.0f,-32767.0f); + glVertex3f(-32767.0f,32767.0f, 32767.0f); + glVertex3f( 32767.0f,32767.0f, 32767.0f); + glVertex3f( 32767.0f,32767.0f,-32767.0f); + glEnd(); + glBegin(GL_TRIANGLE_FAN); + glVertex3f(-32767.0f,-32767.0f,-32767.0f); + glVertex3f(-32767.0f,-32767.0f, 32767.0f); + glVertex3f( 32767.0f,-32767.0f, 32767.0f); + glVertex3f( 32767.0f,-32767.0f,-32767.0f); + glEnd(); } } @@ -182,17 +182,17 @@ bool GLPortal::Start(bool usestencil, bool doquery) } // Create stencil - gl.StencilFunc(GL_EQUAL,recursion,~0); // create stencil - gl.StencilOp(GL_KEEP,GL_KEEP,GL_INCR); // increment stencil of valid pixels - gl.ColorMask(0,0,0,0); // don't write to the graphics buffer + glStencilFunc(GL_EQUAL,recursion,~0); // create stencil + glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); // increment stencil of valid pixels + glColorMask(0,0,0,0); // don't write to the graphics buffer gl_RenderState.EnableTexture(false); - gl.Color3f(1,1,1); - gl.DepthFunc(GL_LESS); + glColor3f(1,1,1); + glDepthFunc(GL_LESS); gl_RenderState.Apply(); if (NeedDepthBuffer()) { - gl.DepthMask(false); // don't write to Z-buffer! + glDepthMask(false); // don't write to Z-buffer! if (!NeedDepthBuffer()) doquery = false; // too much overhead and nothing to gain. else if (gl_noquery) doquery = false; @@ -216,18 +216,18 @@ bool GLPortal::Start(bool usestencil, bool doquery) } // Clear Z-buffer - gl.StencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil - gl.StencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil - gl.DepthMask(true); // enable z-buffer again - gl.DepthRange(1,1); - gl.DepthFunc(GL_ALWAYS); + glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil + glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil + glDepthMask(true); // enable z-buffer again + glDepthRange(1,1); + glDepthFunc(GL_ALWAYS); DrawPortalStencil(); // set normal drawing mode gl_RenderState.EnableTexture(true); - gl.DepthFunc(GL_LESS); - gl.ColorMask(1,1,1,1); - gl.DepthRange(0,1); + glDepthFunc(GL_LESS); + glColorMask(1,1,1,1); + glDepthRange(0,1); if (doquery && gl.flags&RFL_OCCLUSION_QUERY) { @@ -238,8 +238,8 @@ bool GLPortal::Start(bool usestencil, bool doquery) if (sampleCount==0) // not visible { // restore default stencil op. - gl.StencilOp(GL_KEEP,GL_KEEP,GL_KEEP); - gl.StencilFunc(GL_EQUAL,recursion,~0); // draw sky into stencil + glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); + glStencilFunc(GL_EQUAL,recursion,~0); // draw sky into stencil PortalAll.Unclock(); return false; } @@ -253,14 +253,14 @@ bool GLPortal::Start(bool usestencil, bool doquery) // than the benefit. // Note: We must draw the stencil with z-write enabled here because there is no second pass! - gl.DepthMask(true); + glDepthMask(true); DrawPortalStencil(); - gl.StencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil - gl.StencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil + glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil + glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil gl_RenderState.EnableTexture(true); - gl.ColorMask(1,1,1,1); - gl.Disable(GL_DEPTH_TEST); - gl.DepthMask(false); // don't write to Z-buffer! + glColorMask(1,1,1,1); + glDisable(GL_DEPTH_TEST); + glDepthMask(false); // don't write to Z-buffer! } recursion++; @@ -274,13 +274,13 @@ bool GLPortal::Start(bool usestencil, bool doquery) } else { - gl.DepthMask(false); - gl.Disable(GL_DEPTH_TEST); + glDepthMask(false); + glDisable(GL_DEPTH_TEST); } } // The clip plane from the previous portal must be deactivated for this one. - clipsave = gl.IsEnabled(GL_CLIP_PLANE0+renderdepth-1); - if (clipsave) gl.Disable(GL_CLIP_PLANE0+renderdepth-1); + clipsave = glIsEnabled(GL_CLIP_PLANE0+renderdepth-1); + if (clipsave) glDisable(GL_CLIP_PLANE0+renderdepth-1); // save viewpoint savedviewx=viewx; @@ -340,7 +340,7 @@ void GLPortal::End(bool usestencil) PortalAll.Clock(); GLRenderer->mCurrentPortal = NextPortal; - if (clipsave) gl.Enable (GL_CLIP_PLANE0+renderdepth-1); + if (clipsave) glEnable (GL_CLIP_PLANE0+renderdepth-1); if (usestencil) { if (needdepth) FDrawInfo::EndDrawInfo(); @@ -354,52 +354,52 @@ void GLPortal::End(bool usestencil) in_area=savedviewarea; GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); - gl.Color4f(1,1,1,1); - gl.ColorMask(0,0,0,0); // no graphics - gl.Color3f(1,1,1); + glColor4f(1,1,1,1); + glColorMask(0,0,0,0); // no graphics + glColor3f(1,1,1); gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); if (needdepth) { // first step: reset the depth buffer to max. depth - gl.DepthRange(1,1); // always - gl.DepthFunc(GL_ALWAYS); // write the farthest depth value + glDepthRange(1,1); // always + glDepthFunc(GL_ALWAYS); // write the farthest depth value DrawPortalStencil(); } else { - gl.Enable(GL_DEPTH_TEST); + glEnable(GL_DEPTH_TEST); } // second step: restore the depth buffer to the previous values and reset the stencil - gl.DepthFunc(GL_LEQUAL); - gl.DepthRange(0,1); - gl.StencilOp(GL_KEEP,GL_KEEP,GL_DECR); - gl.StencilFunc(GL_EQUAL,recursion,~0); // draw sky into stencil + glDepthFunc(GL_LEQUAL); + glDepthRange(0,1); + glStencilOp(GL_KEEP,GL_KEEP,GL_DECR); + glStencilFunc(GL_EQUAL,recursion,~0); // draw sky into stencil DrawPortalStencil(); - gl.DepthFunc(GL_LESS); + glDepthFunc(GL_LESS); gl_RenderState.EnableTexture(true); - gl.ColorMask(1,1,1,1); + glColorMask(1,1,1,1); recursion--; // restore old stencil op. - gl.StencilOp(GL_KEEP,GL_KEEP,GL_KEEP); - gl.StencilFunc(GL_EQUAL,recursion,~0); // draw sky into stencil + glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); + glStencilFunc(GL_EQUAL,recursion,~0); // draw sky into stencil } else { if (needdepth) { FDrawInfo::EndDrawInfo(); - gl.Clear(GL_DEPTH_BUFFER_BIT); + glClear(GL_DEPTH_BUFFER_BIT); } else { - gl.Enable(GL_DEPTH_TEST); - gl.DepthMask(true); + glEnable(GL_DEPTH_TEST); + glDepthMask(true); } // Restore the old view viewx=savedviewx; @@ -413,15 +413,15 @@ void GLPortal::End(bool usestencil) // This draws a valid z-buffer into the stencil's contents to ensure it // doesn't get overwritten by the level's geometry. - gl.Color4f(1,1,1,1); - gl.DepthFunc(GL_LEQUAL); - gl.DepthRange(0,1); - gl.ColorMask(0,0,0,0); // no graphics + glColor4f(1,1,1,1); + glDepthFunc(GL_LEQUAL); + glDepthRange(0,1); + glColorMask(0,0,0,0); // no graphics gl_RenderState.EnableTexture(false); DrawPortalStencil(); gl_RenderState.EnableTexture(true); - gl.ColorMask(1,1,1,1); - gl.DepthFunc(GL_LESS); + glColorMask(1,1,1,1); + glDepthFunc(GL_LESS); } PortalAll.Unclock(); } @@ -613,7 +613,7 @@ void GLSkyboxPortal::DrawContents() PlaneMirrorMode=0; - gl.Disable(GL_DEPTH_CLAMP_NV); + glDisable(GL_DEPTH_CLAMP_NV); viewx = origin->PrevX + FixedMul(r_TicFrac, origin->x - origin->PrevX); viewy = origin->PrevY + FixedMul(r_TicFrac, origin->y - origin->PrevY); @@ -643,7 +643,7 @@ void GLSkyboxPortal::DrawContents() GLRenderer->DrawScene(); origin->flags&=~MF_JUSTHIT; inskybox=false; - gl.Enable(GL_DEPTH_CLAMP_NV); + glEnable(GL_DEPTH_CLAMP_NV); skyboxrecursion--; PlaneMirrorMode=old_pm; @@ -778,14 +778,14 @@ void GLPlaneMirrorPortal::DrawContents() GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); ClearClipper(); - gl.Enable(GL_CLIP_PLANE0+renderdepth); + glEnable(GL_CLIP_PLANE0+renderdepth); // This only works properly for non-sloped planes so don't bother with the math. //double d[4]={origin->a/65536., origin->c/65536., origin->b/65536., FIXED2FLOAT(origin->d)}; double d[4]={0, static_cast(PlaneMirrorMode), 0, FIXED2FLOAT(origin->d)}; - gl.ClipPlane(GL_CLIP_PLANE0+renderdepth, d); + glClipPlane(GL_CLIP_PLANE0+renderdepth, d); GLRenderer->DrawScene(); - gl.Disable(GL_CLIP_PLANE0+renderdepth); + glDisable(GL_CLIP_PLANE0+renderdepth); PlaneMirrorFlag--; PlaneMirrorMode=old_pm; } @@ -999,21 +999,21 @@ void GLHorizonPortal::DrawContents() { for(float y=-32768+vy; y<32768+vy;y+=4096) { - gl.Begin(GL_TRIANGLE_FAN); + glBegin(GL_TRIANGLE_FAN); - gl.TexCoord2f(x/64, -y/64); - gl.Vertex3f(x, z, y); + glTexCoord2f(x/64, -y/64); + glVertex3f(x, z, y); - gl.TexCoord2f(x/64 + 64, -y/64); - gl.Vertex3f(x + 4096, z, y); + glTexCoord2f(x/64 + 64, -y/64); + glVertex3f(x + 4096, z, y); - gl.TexCoord2f(x/64 + 64, -y/64 - 64); - gl.Vertex3f(x + 4096, z, y + 4096); + glTexCoord2f(x/64 + 64, -y/64 - 64); + glVertex3f(x + 4096, z, y + 4096); - gl.TexCoord2f(x/64, -y/64 - 64); - gl.Vertex3f(x, z, y + 4096); + glTexCoord2f(x/64, -y/64 - 64); + glVertex3f(x, z, y + 4096); - gl.End(); + glEnd(); } } @@ -1025,39 +1025,39 @@ void GLHorizonPortal::DrawContents() // Since I can't draw into infinity there can always be a // small gap - gl.Begin(GL_TRIANGLE_STRIP); + glBegin(GL_TRIANGLE_STRIP); - gl.TexCoord2f(512.f, 0); - gl.Vertex3f(-32768+vx, z, -32768+vy); - gl.TexCoord2f(512.f, tz); - gl.Vertex3f(-32768+vx, vz, -32768+vy); + glTexCoord2f(512.f, 0); + glVertex3f(-32768+vx, z, -32768+vy); + glTexCoord2f(512.f, tz); + glVertex3f(-32768+vx, vz, -32768+vy); - gl.TexCoord2f(-512.f, 0); - gl.Vertex3f(-32768+vx, z, 32768+vy); - gl.TexCoord2f(-512.f, tz); - gl.Vertex3f(-32768+vx, vz, 32768+vy); + glTexCoord2f(-512.f, 0); + glVertex3f(-32768+vx, z, 32768+vy); + glTexCoord2f(-512.f, tz); + glVertex3f(-32768+vx, vz, 32768+vy); - gl.TexCoord2f(512.f, 0); - gl.Vertex3f( 32768+vx, z, 32768+vy); - gl.TexCoord2f(512.f, tz); - gl.Vertex3f( 32768+vx, vz, 32768+vy); + glTexCoord2f(512.f, 0); + glVertex3f( 32768+vx, z, 32768+vy); + glTexCoord2f(512.f, tz); + glVertex3f( 32768+vx, vz, 32768+vy); - gl.TexCoord2f(-512.f, 0); - gl.Vertex3f( 32768+vx, z, -32768+vy); - gl.TexCoord2f(-512.f, tz); - gl.Vertex3f( 32768+vx, vz, -32768+vy); + glTexCoord2f(-512.f, 0); + glVertex3f( 32768+vx, z, -32768+vy); + glTexCoord2f(-512.f, tz); + glVertex3f( 32768+vx, vz, -32768+vy); - gl.TexCoord2f(512.f, 0); - gl.Vertex3f(-32768+vx, z, -32768+vy); - gl.TexCoord2f(512.f, tz); - gl.Vertex3f(-32768+vx, vz, -32768+vy); + glTexCoord2f(512.f, 0); + glVertex3f(-32768+vx, z, -32768+vy); + glTexCoord2f(512.f, tz); + glVertex3f(-32768+vx, vz, -32768+vy); - gl.End(); + glEnd(); if (pushed) { - gl.PopMatrix(); - gl.MatrixMode(GL_MODELVIEW); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); } PortalAll.Unclock(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 51454ed1a..93c8dbbf8 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -164,7 +164,7 @@ void FGLRenderer::SetViewArea() void FGLRenderer::ResetViewport() { int trueheight = static_cast(screen)->GetTrueHeight(); // ugh... - gl.Viewport(0, (trueheight-screen->GetHeight())/2, screen->GetWidth(), screen->GetHeight()); + glViewport(0, (trueheight-screen->GetHeight())/2, screen->GetWidth(), screen->GetHeight()); } //----------------------------------------------------------------------------- @@ -197,28 +197,28 @@ void FGLRenderer::SetViewport(GL_IRECT *bounds) int vw = viewwidth; int vh = viewheight; - gl.Viewport(viewwindowx, trueheight-bars-(height+viewwindowy-((height-vh)/2)), vw, height); - gl.Scissor(viewwindowx, trueheight-bars-(vh+viewwindowy), vw, vh); + glViewport(viewwindowx, trueheight-bars-(height+viewwindowy-((height-vh)/2)), vw, height); + glScissor(viewwindowx, trueheight-bars-(vh+viewwindowy), vw, vh); } else { - gl.Viewport(bounds->left, bounds->top, bounds->width, bounds->height); - gl.Scissor(bounds->left, bounds->top, bounds->width, bounds->height); + glViewport(bounds->left, bounds->top, bounds->width, bounds->height); + glScissor(bounds->left, bounds->top, bounds->width, bounds->height); } - gl.Enable(GL_SCISSOR_TEST); + glEnable(GL_SCISSOR_TEST); #ifdef _DEBUG - gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f); - gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); #else - gl.Clear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); #endif - gl.Enable(GL_MULTISAMPLE); - gl.Enable(GL_DEPTH_TEST); - gl.Enable(GL_STENCIL_TEST); - gl.StencilFunc(GL_ALWAYS,0,~0); // default stencil - gl.StencilOp(GL_KEEP,GL_KEEP,GL_REPLACE); + glEnable(GL_MULTISAMPLE); + glEnable(GL_DEPTH_TEST); + glEnable(GL_STENCIL_TEST); + glStencilFunc(GL_ALWAYS,0,~0); // default stencil + glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE); } //----------------------------------------------------------------------------- @@ -248,8 +248,8 @@ void FGLRenderer::SetCameraPos(fixed_t viewx, fixed_t viewy, fixed_t viewz, angl void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) { - gl.MatrixMode(GL_PROJECTION); - gl.LoadIdentity(); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovratio)); gluPerspective(fovy, ratio, 5.f, 65536.f); @@ -267,24 +267,24 @@ void FGLRenderer::SetViewMatrix(bool mirror, bool planemirror) if (gl.shadermodel >= 4) { gl.ActiveTexture(GL_TEXTURE7); - gl.MatrixMode(GL_TEXTURE); - gl.LoadIdentity(); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); } gl.ActiveTexture(GL_TEXTURE0); - gl.MatrixMode(GL_TEXTURE); - gl.LoadIdentity(); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); - gl.MatrixMode(GL_MODELVIEW); - gl.LoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); float mult = mirror? -1:1; float planemult = planemirror? -1:1; - gl.Rotatef(GLRenderer->mAngles.Roll, 0.0f, 0.0f, 1.0f); - gl.Rotatef(GLRenderer->mAngles.Pitch, 1.0f, 0.0f, 0.0f); - gl.Rotatef(GLRenderer->mAngles.Yaw, 0.0f, mult, 0.0f); - gl.Translatef( GLRenderer->mCameraPos.X * mult, -GLRenderer->mCameraPos.Z*planemult, -GLRenderer->mCameraPos.Y); - gl.Scalef(-mult, planemult, 1); + glRotatef(GLRenderer->mAngles.Roll, 0.0f, 0.0f, 1.0f); + glRotatef(GLRenderer->mAngles.Pitch, 1.0f, 0.0f, 0.0f); + glRotatef(GLRenderer->mAngles.Yaw, 0.0f, mult, 0.0f); + glTranslatef( GLRenderer->mCameraPos.X * mult, -GLRenderer->mCameraPos.Z*planemult, -GLRenderer->mCameraPos.Y); + glScalef(-mult, planemult, 1); } @@ -346,7 +346,7 @@ void FGLRenderer::RenderScene(int recursion) { RenderAll.Clock(); - gl.DepthMask(true); + glDepthMask(true); if (!gl_no_skyclear) GLPortal::RenderFirstSkyPortal(recursion); gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); @@ -357,12 +357,12 @@ void FGLRenderer::RenderScene(int recursion) // First draw all single-pass stuff // Part 1: solid geometry. This is set up so that there are no transparent parts - gl.DepthFunc(GL_LESS); + glDepthFunc(GL_LESS); gl_RenderState.EnableAlphaTest(false); - gl.Disable(GL_POLYGON_OFFSET_FILL); // just in case + glDisable(GL_POLYGON_OFFSET_FILL); // just in case int pass; @@ -434,13 +434,13 @@ void FGLRenderer::RenderScene(int recursion) // second pass: draw lights (on fogged surfaces they are added to the textures!) - gl.DepthMask(false); + glDepthMask(false); if (mLightCount && !gl_fixedcolormap) { if (gl_SetupLightTexture()) { gl_RenderState.BlendFunc(GL_ONE, GL_ONE); - gl.DepthFunc(GL_EQUAL); + glDepthFunc(GL_EQUAL); if (glset.lightmode == 8) gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0f); // Korshun. for(int i=GLDL_FIRSTLIGHT; i<=GLDL_LASTLIGHT; i++) { @@ -452,10 +452,10 @@ void FGLRenderer::RenderScene(int recursion) } // third pass: modulated texture - gl.Color3f(1.0f, 1.0f, 1.0f); + glColor3f(1.0f, 1.0f, 1.0f); gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); gl_RenderState.EnableFog(false); - gl.DepthFunc(GL_LEQUAL); + glDepthFunc(GL_LEQUAL); if (gl_texture) { gl_RenderState.EnableAlphaTest(false); @@ -473,7 +473,7 @@ void FGLRenderer::RenderScene(int recursion) if (gl_lights && mLightCount && !gl_fixedcolormap) { gl_RenderState.BlendFunc(GL_ONE, GL_ONE); - gl.DepthFunc(GL_EQUAL); + glDepthFunc(GL_EQUAL); if (gl_SetupLightTexture()) { for(int i=0; iDrawUnhandledMissingTextures(); gl_RenderState.EnableAlphaTest(true); - gl.DepthMask(true); + glDepthMask(true); - gl.PolygonOffset(0.0f, 0.0f); - gl.Disable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(0.0f, 0.0f); + glDisable(GL_POLYGON_OFFSET_FILL); RenderAll.Unclock(); } @@ -537,7 +537,7 @@ void FGLRenderer::RenderTranslucent() { RenderAll.Clock(); - gl.DepthMask(false); + glDepthMask(false); gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); // final pass: translucent stuff @@ -550,7 +550,7 @@ void FGLRenderer::RenderTranslucent() gl_drawinfo->drawlists[GLDL_TRANSLUCENT].DrawSorted(); gl_RenderState.EnableBrightmap(false); - gl.DepthMask(true); + glDepthMask(true); gl_RenderState.AlphaFunc(GL_GEQUAL,0.5f); RenderAll.Unclock(); @@ -683,14 +683,14 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) gl_RenderState.EnableAlphaTest(false); gl_RenderState.EnableTexture(false); gl_RenderState.BlendFunc(GL_DST_COLOR,GL_ZERO); - gl.Color4f(extra_red, extra_green, extra_blue, 1.0f); + glColor4f(extra_red, extra_green, extra_blue, 1.0f); gl_RenderState.Apply(true); - gl.Begin(GL_TRIANGLE_STRIP); - gl.Vertex2f( 0.0f, 0.0f); - gl.Vertex2f( 0.0f, (float)SCREENHEIGHT); - gl.Vertex2f( (float)SCREENWIDTH, 0.0f); - gl.Vertex2f( (float)SCREENWIDTH, (float)SCREENHEIGHT); - gl.End(); + glBegin(GL_TRIANGLE_STRIP); + glVertex2f( 0.0f, 0.0f); + glVertex2f( 0.0f, (float)SCREENHEIGHT); + glVertex2f( (float)SCREENWIDTH, 0.0f); + glVertex2f( (float)SCREENWIDTH, (float)SCREENHEIGHT); + glEnd(); } } else if (blendv.a) @@ -720,14 +720,14 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.EnableAlphaTest(false); gl_RenderState.EnableTexture(false); - gl.Color4fv(blend); + glColor4fv(blend); gl_RenderState.Apply(true); - gl.Begin(GL_TRIANGLE_STRIP); - gl.Vertex2f( 0.0f, 0.0f); - gl.Vertex2f( 0.0f, (float)SCREENHEIGHT); - gl.Vertex2f( (float)SCREENWIDTH, 0.0f); - gl.Vertex2f( (float)SCREENWIDTH, (float)SCREENHEIGHT); - gl.End(); + glBegin(GL_TRIANGLE_STRIP); + glVertex2f( 0.0f, 0.0f); + glVertex2f( 0.0f, (float)SCREENHEIGHT); + glVertex2f( (float)SCREENWIDTH, 0.0f); + glVertex2f( (float)SCREENWIDTH, (float)SCREENHEIGHT); + glEnd(); } } @@ -748,12 +748,12 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) if ( renderHUDModel ) { // [BB] The HUD model should be drawn over everything else already drawn. - gl.Clear(GL_DEPTH_BUFFER_BIT); + glClear(GL_DEPTH_BUFFER_BIT); DrawPlayerSprites (viewsector, true); } - gl.Disable(GL_STENCIL_TEST); - gl.Disable(GL_POLYGON_SMOOTH); + glDisable(GL_STENCIL_TEST); + glDisable(GL_POLYGON_SMOOTH); gl_RenderState.EnableFog(false); framebuffer->Begin2D(false); @@ -769,10 +769,10 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) // Restore standard rendering state gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl.Color3f(1.0f,1.0f,1.0f); + glColor3f(1.0f,1.0f,1.0f); gl_RenderState.EnableTexture(true); gl_RenderState.EnableAlphaTest(true); - gl.Disable(GL_SCISSOR_TEST); + glDisable(GL_SCISSOR_TEST); } @@ -966,7 +966,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei bounds.top=0; bounds.width=width; bounds.height=height; - gl.Flush(); + glFlush(); SetFixedColormap(player); // Check if there's some lights. If not some code can be skipped. @@ -975,13 +975,13 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei sector_t *viewsector = RenderViewpoint(players[consoleplayer].camera, &bounds, FieldOfView * 360.0f / FINEANGLES, 1.6f, 1.6f, true, false); - gl.Disable(GL_STENCIL_TEST); + glDisable(GL_STENCIL_TEST); screen->Begin2D(false); DrawBlend(viewsector); - gl.Flush(); + glFlush(); byte * scr = (byte *)M_Malloc(width * height * 3); - gl.ReadPixels(0,0,width, height,GL_RGB,GL_UNSIGNED_BYTE,scr); + glReadPixels(0,0,width, height,GL_RGB,GL_UNSIGNED_BYTE,scr); M_CreatePNG (file, scr + ((height-1) * width * 3), NULL, SS_RGB, width, height, -width*3); M_Free(scr); } @@ -1098,8 +1098,8 @@ int FGLInterface::GetMaxViewPitch(bool down) void FGLInterface::ClearBuffer(int color) { PalEntry pe = GPalette.BaseColors[color]; - gl.ClearColor(pe.r/255.f, pe.g/255.f, pe.b/255.f, 1.f); - gl.Clear(GL_COLOR_BUFFER_BIT); + glClearColor(pe.r/255.f, pe.g/255.f, pe.b/255.f, 1.f); + glClear(GL_COLOR_BUFFER_BIT); } //=========================================================================== @@ -1163,7 +1163,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in if (!usefb) { - gl.Flush(); + glFlush(); } else { @@ -1180,7 +1180,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in usefb = false; gl_usefb = false; GLRenderer->EndOffscreen(); - gl.Flush(); + glFlush(); } #endif } @@ -1194,9 +1194,9 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in if (!usefb) { - gl.Flush(); + glFlush(); gltex->Bind(CM_DEFAULT, 0, 0); - gl.CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, bounds.width, bounds.height); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, bounds.width, bounds.height); } else { @@ -1204,7 +1204,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in } gltex->Bind(CM_DEFAULT, 0, 0); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); tex->SetUpdated(); } diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 8bed575b3..41182cfb4 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -125,14 +125,14 @@ static void SkyVertex(int r, int c) } - gl.TexCoord2f(skymirror? -u:u, v); + glTexCoord2f(skymirror? -u:u, v); } if (r != 4) y+=FRACUNIT*300; // And finally the vertex. fx =-FIXED2FLOAT(x); // Doom mirrors the sky vertically! fy = FIXED2FLOAT(y); fz = FIXED2FLOAT(z); - gl.Vertex3f(fx, fy - 1.f, fz); + glVertex3f(fx, fy - 1.f, fz); } @@ -181,13 +181,13 @@ static void RenderSkyHemisphere(int hemi, bool mirror) if (!secondlayer) { - gl.Color3f(R, G ,B); - gl.Begin(GL_TRIANGLE_FAN); + glColor3f(R, G ,B); + glBegin(GL_TRIANGLE_FAN); for(c = 0; c < columns; c++) { SkyVertex(1, c); } - gl.End(); + glEnd(); } gl_RenderState.EnableTexture(true); @@ -198,12 +198,12 @@ static void RenderSkyHemisphere(int hemi, bool mirror) { gl_RenderState.Apply(true); columns=4; // no need to do more! - gl.Begin(GL_TRIANGLE_FAN); + glBegin(GL_TRIANGLE_FAN); for(c = 0; c < columns; c++) { SkyVertex(0, c); } - gl.End(); + glEnd(); } // The total number of triangles per hemisphere can be calculated @@ -212,7 +212,7 @@ static void RenderSkyHemisphere(int hemi, bool mirror) { if (yflip) { - gl.Begin(GL_TRIANGLE_STRIP); + glBegin(GL_TRIANGLE_STRIP); SkyVertex(r + 1, 0); SkyVertex(r, 0); for(c = 1; c <= columns; c++) @@ -220,11 +220,11 @@ static void RenderSkyHemisphere(int hemi, bool mirror) SkyVertex(r + 1, c); SkyVertex(r, c); } - gl.End(); + glEnd(); } else { - gl.Begin(GL_TRIANGLE_STRIP); + glBegin(GL_TRIANGLE_STRIP); SkyVertex(r, 0); SkyVertex(r + 1, 0); for(c = 1; c <= columns; c++) @@ -232,7 +232,7 @@ static void RenderSkyHemisphere(int hemi, bool mirror) SkyVertex(r, c); SkyVertex(r + 1, c); } - gl.End(); + glEnd(); } } } @@ -255,33 +255,33 @@ static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float if (tex) { - gl.PushMatrix(); + glPushMatrix(); tex->Bind(CM_Index, 0, 0); texw = tex->TextureWidth(GLUSE_TEXTURE); texh = tex->TextureHeight(GLUSE_TEXTURE); - gl.Rotatef(-180.0f+x_offset, 0.f, 1.f, 0.f); + glRotatef(-180.0f+x_offset, 0.f, 1.f, 0.f); yAdd = y_offset/texh; if (texh < 200) { - gl.Translatef(0.f, -1250.f, 0.f); - gl.Scalef(1.f, texh/230.f, 1.f); + glTranslatef(0.f, -1250.f, 0.f); + glScalef(1.f, texh/230.f, 1.f); } else if (texh <= 240) { - gl.Translatef(0.f, (200 - texh + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); - gl.Scalef(1.f, 1.f + ((texh-200.f)/200.f) * 1.17f, 1.f); + glTranslatef(0.f, (200 - texh + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); + glScalef(1.f, 1.f + ((texh-200.f)/200.f) * 1.17f, 1.f); } else { - gl.Translatef(0.f, (-40 + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); - gl.Scalef(1.f, 1.2f * 1.17f, 1.f); - gl.MatrixMode(GL_TEXTURE); - gl.PushMatrix(); - gl.LoadIdentity(); - gl.Scalef(1.f, 240.f / texh, 1.f); - gl.MatrixMode(GL_MODELVIEW); + glTranslatef(0.f, (-40 + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); + glScalef(1.f, 1.2f * 1.17f, 1.f); + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glLoadIdentity(); + glScalef(1.f, 240.f / texh, 1.f); + glMatrixMode(GL_MODELVIEW); texscale = true; } } @@ -330,11 +330,11 @@ static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float RenderSkyHemisphere(SKYHEMI_LOWER, mirror); if (texscale) { - gl.MatrixMode(GL_TEXTURE); - gl.PopMatrix(); - gl.MatrixMode(GL_MODELVIEW); + glMatrixMode(GL_TEXTURE); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); } - if (tex) gl.PopMatrix(); + if (tex) glPopMatrix(); } @@ -352,11 +352,11 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int C FMaterial * tex; if (!sky2) - gl.Rotatef(-180.0f+x_offset, glset.skyrotatevector.X, glset.skyrotatevector.Z, glset.skyrotatevector.Y); + glRotatef(-180.0f+x_offset, glset.skyrotatevector.X, glset.skyrotatevector.Z, glset.skyrotatevector.Y); else - gl.Rotatef(-180.0f+x_offset, glset.skyrotatevector2.X, glset.skyrotatevector2.Z, glset.skyrotatevector2.Y); + glRotatef(-180.0f+x_offset, glset.skyrotatevector2.X, glset.skyrotatevector2.Z, glset.skyrotatevector2.Y); - gl.Color3f(R, G ,B); + glColor3f(R, G ,B); if (sb->faces[5]) { @@ -366,61 +366,61 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int C tex = FMaterial::ValidateTexture(sb->faces[0]); tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_FAN); - gl.TexCoord2f(0, 0); - gl.Vertex3f(128.f, 128.f, -128.f); - gl.TexCoord2f(1, 0); - gl.Vertex3f(-128.f, 128.f, -128.f); - gl.TexCoord2f(1, 1); - gl.Vertex3f(-128.f, -128.f, -128.f); - gl.TexCoord2f(0, 1); - gl.Vertex3f(128.f, -128.f, -128.f); - gl.End(); + glBegin(GL_TRIANGLE_FAN); + glTexCoord2f(0, 0); + glVertex3f(128.f, 128.f, -128.f); + glTexCoord2f(1, 0); + glVertex3f(-128.f, 128.f, -128.f); + glTexCoord2f(1, 1); + glVertex3f(-128.f, -128.f, -128.f); + glTexCoord2f(0, 1); + glVertex3f(128.f, -128.f, -128.f); + glEnd(); // east tex = FMaterial::ValidateTexture(sb->faces[1]); tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_FAN); - gl.TexCoord2f(0, 0); - gl.Vertex3f(-128.f, 128.f, -128.f); - gl.TexCoord2f(1, 0); - gl.Vertex3f(-128.f, 128.f, 128.f); - gl.TexCoord2f(1, 1); - gl.Vertex3f(-128.f, -128.f, 128.f); - gl.TexCoord2f(0, 1); - gl.Vertex3f(-128.f, -128.f, -128.f); - gl.End(); + glBegin(GL_TRIANGLE_FAN); + glTexCoord2f(0, 0); + glVertex3f(-128.f, 128.f, -128.f); + glTexCoord2f(1, 0); + glVertex3f(-128.f, 128.f, 128.f); + glTexCoord2f(1, 1); + glVertex3f(-128.f, -128.f, 128.f); + glTexCoord2f(0, 1); + glVertex3f(-128.f, -128.f, -128.f); + glEnd(); // south tex = FMaterial::ValidateTexture(sb->faces[2]); tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_FAN); - gl.TexCoord2f(0, 0); - gl.Vertex3f(-128.f, 128.f, 128.f); - gl.TexCoord2f(1, 0); - gl.Vertex3f(128.f, 128.f, 128.f); - gl.TexCoord2f(1, 1); - gl.Vertex3f(128.f, -128.f, 128.f); - gl.TexCoord2f(0, 1); - gl.Vertex3f(-128.f, -128.f, 128.f); - gl.End(); + glBegin(GL_TRIANGLE_FAN); + glTexCoord2f(0, 0); + glVertex3f(-128.f, 128.f, 128.f); + glTexCoord2f(1, 0); + glVertex3f(128.f, 128.f, 128.f); + glTexCoord2f(1, 1); + glVertex3f(128.f, -128.f, 128.f); + glTexCoord2f(0, 1); + glVertex3f(-128.f, -128.f, 128.f); + glEnd(); // west tex = FMaterial::ValidateTexture(sb->faces[3]); tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_FAN); - gl.TexCoord2f(0, 0); - gl.Vertex3f(128.f, 128.f, 128.f); - gl.TexCoord2f(1, 0); - gl.Vertex3f(128.f, 128.f, -128.f); - gl.TexCoord2f(1, 1); - gl.Vertex3f(128.f, -128.f, -128.f); - gl.TexCoord2f(0, 1); - gl.Vertex3f(128.f, -128.f, 128.f); - gl.End(); + glBegin(GL_TRIANGLE_FAN); + glTexCoord2f(0, 0); + glVertex3f(128.f, 128.f, 128.f); + glTexCoord2f(1, 0); + glVertex3f(128.f, 128.f, -128.f); + glTexCoord2f(1, 1); + glVertex3f(128.f, -128.f, -128.f); + glTexCoord2f(0, 1); + glVertex3f(128.f, -128.f, 128.f); + glEnd(); } else { @@ -430,98 +430,98 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int C tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_FAN); - gl.TexCoord2f(0, 0); - gl.Vertex3f(128.f, 128.f, -128.f); - gl.TexCoord2f(.25f, 0); - gl.Vertex3f(-128.f, 128.f, -128.f); - gl.TexCoord2f(.25f, 1); - gl.Vertex3f(-128.f, -128.f, -128.f); - gl.TexCoord2f(0, 1); - gl.Vertex3f(128.f, -128.f, -128.f); - gl.End(); + glBegin(GL_TRIANGLE_FAN); + glTexCoord2f(0, 0); + glVertex3f(128.f, 128.f, -128.f); + glTexCoord2f(.25f, 0); + glVertex3f(-128.f, 128.f, -128.f); + glTexCoord2f(.25f, 1); + glVertex3f(-128.f, -128.f, -128.f); + glTexCoord2f(0, 1); + glVertex3f(128.f, -128.f, -128.f); + glEnd(); // east - gl.Begin(GL_TRIANGLE_FAN); - gl.TexCoord2f(.25f, 0); - gl.Vertex3f(-128.f, 128.f, -128.f); - gl.TexCoord2f(.5f, 0); - gl.Vertex3f(-128.f, 128.f, 128.f); - gl.TexCoord2f(.5f, 1); - gl.Vertex3f(-128.f, -128.f, 128.f); - gl.TexCoord2f(.25f, 1); - gl.Vertex3f(-128.f, -128.f, -128.f); - gl.End(); + glBegin(GL_TRIANGLE_FAN); + glTexCoord2f(.25f, 0); + glVertex3f(-128.f, 128.f, -128.f); + glTexCoord2f(.5f, 0); + glVertex3f(-128.f, 128.f, 128.f); + glTexCoord2f(.5f, 1); + glVertex3f(-128.f, -128.f, 128.f); + glTexCoord2f(.25f, 1); + glVertex3f(-128.f, -128.f, -128.f); + glEnd(); // south - gl.Begin(GL_TRIANGLE_FAN); - gl.TexCoord2f(.5f, 0); - gl.Vertex3f(-128.f, 128.f, 128.f); - gl.TexCoord2f(.75f, 0); - gl.Vertex3f(128.f, 128.f, 128.f); - gl.TexCoord2f(.75f, 1); - gl.Vertex3f(128.f, -128.f, 128.f); - gl.TexCoord2f(.5f, 1); - gl.Vertex3f(-128.f, -128.f, 128.f); - gl.End(); + glBegin(GL_TRIANGLE_FAN); + glTexCoord2f(.5f, 0); + glVertex3f(-128.f, 128.f, 128.f); + glTexCoord2f(.75f, 0); + glVertex3f(128.f, 128.f, 128.f); + glTexCoord2f(.75f, 1); + glVertex3f(128.f, -128.f, 128.f); + glTexCoord2f(.5f, 1); + glVertex3f(-128.f, -128.f, 128.f); + glEnd(); // west - gl.Begin(GL_TRIANGLE_FAN); - gl.TexCoord2f(.75f, 0); - gl.Vertex3f(128.f, 128.f, 128.f); - gl.TexCoord2f(1, 0); - gl.Vertex3f(128.f, 128.f, -128.f); - gl.TexCoord2f(1, 1); - gl.Vertex3f(128.f, -128.f, -128.f); - gl.TexCoord2f(.75f, 1); - gl.Vertex3f(128.f, -128.f, 128.f); - gl.End(); + glBegin(GL_TRIANGLE_FAN); + glTexCoord2f(.75f, 0); + glVertex3f(128.f, 128.f, 128.f); + glTexCoord2f(1, 0); + glVertex3f(128.f, 128.f, -128.f); + glTexCoord2f(1, 1); + glVertex3f(128.f, -128.f, -128.f); + glTexCoord2f(.75f, 1); + glVertex3f(128.f, -128.f, 128.f); + glEnd(); } // top tex = FMaterial::ValidateTexture(sb->faces[faces]); tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_FAN); + glBegin(GL_TRIANGLE_FAN); if (!sb->fliptop) { - gl.TexCoord2f(0, 0); - gl.Vertex3f(128.f, 128.f, -128.f); - gl.TexCoord2f(1, 0); - gl.Vertex3f(-128.f, 128.f, -128.f); - gl.TexCoord2f(1, 1); - gl.Vertex3f(-128.f, 128.f, 128.f); - gl.TexCoord2f(0, 1); - gl.Vertex3f(128.f, 128.f, 128.f); + glTexCoord2f(0, 0); + glVertex3f(128.f, 128.f, -128.f); + glTexCoord2f(1, 0); + glVertex3f(-128.f, 128.f, -128.f); + glTexCoord2f(1, 1); + glVertex3f(-128.f, 128.f, 128.f); + glTexCoord2f(0, 1); + glVertex3f(128.f, 128.f, 128.f); } else { - gl.TexCoord2f(0, 0); - gl.Vertex3f(128.f, 128.f, 128.f); - gl.TexCoord2f(1, 0); - gl.Vertex3f(-128.f, 128.f, 128.f); - gl.TexCoord2f(1, 1); - gl.Vertex3f(-128.f, 128.f, -128.f); - gl.TexCoord2f(0, 1); - gl.Vertex3f(128.f, 128.f, -128.f); + glTexCoord2f(0, 0); + glVertex3f(128.f, 128.f, 128.f); + glTexCoord2f(1, 0); + glVertex3f(-128.f, 128.f, 128.f); + glTexCoord2f(1, 1); + glVertex3f(-128.f, 128.f, -128.f); + glTexCoord2f(0, 1); + glVertex3f(128.f, 128.f, -128.f); } - gl.End(); + glEnd(); // bottom tex = FMaterial::ValidateTexture(sb->faces[faces+1]); tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_FAN); - gl.TexCoord2f(0, 0); - gl.Vertex3f(128.f, -128.f, -128.f); - gl.TexCoord2f(1, 0); - gl.Vertex3f(-128.f, -128.f, -128.f); - gl.TexCoord2f(1, 1); - gl.Vertex3f(-128.f, -128.f, 128.f); - gl.TexCoord2f(0, 1); - gl.Vertex3f(128.f, -128.f, 128.f); - gl.End(); + glBegin(GL_TRIANGLE_FAN); + glTexCoord2f(0, 0); + glVertex3f(128.f, -128.f, -128.f); + glTexCoord2f(1, 0); + glVertex3f(-128.f, -128.f, -128.f); + glTexCoord2f(1, 1); + glVertex3f(-128.f, -128.f, 128.f); + glTexCoord2f(0, 1); + glVertex3f(128.f, -128.f, 128.f); + glEnd(); } @@ -556,8 +556,8 @@ void GLSkyPortal::DrawContents() gl_RenderState.EnableAlphaTest(false); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl.MatrixMode(GL_MODELVIEW); - gl.PushMatrix(); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); GLRenderer->SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox) @@ -601,13 +601,13 @@ void GLSkyPortal::DrawContents() { gl_RenderState.EnableTexture(false); foglayer=true; - gl.Color4f(FadeColor.r/255.0f,FadeColor.g/255.0f,FadeColor.b/255.0f,skyfog/255.0f); + glColor4f(FadeColor.r/255.0f,FadeColor.g/255.0f,FadeColor.b/255.0f,skyfog/255.0f); RenderDome(FNullTextureID(), NULL, 0, 0, false, CM_DEFAULT); gl_RenderState.EnableTexture(true); foglayer=false; } } - gl.PopMatrix(); + glPopMatrix(); glset.lightmode = oldlightmode; } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 8150bf17d..40b55dfef 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -165,7 +165,7 @@ void GLSprite::Draw(int pass) } gl_RenderState.AlphaFunc(GL_GEQUAL,minalpha*gl_mask_sprite_threshold); - gl.Color4f(0.2f,0.2f,0.2f,fuzzalpha); + glColor4f(0.2f,0.2f,0.2f,fuzzalpha); additivefog = true; } else if (RenderStyle.BlendOp == STYLEOP_Add && RenderStyle.DestAlpha == STYLEALPHA_One) @@ -220,7 +220,7 @@ void GLSprite::Draw(int pass) //&& GLRenderer->mViewActor != NULL && (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD ))) ); gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_STRIP); + glBegin(GL_TRIANGLE_STRIP); if ( drawWithXYBillboard ) { // Rotate the sprite about the vector starting at the center of the sprite @@ -243,17 +243,17 @@ void GLSprite::Draw(int pass) if (gltexture) { - gl.TexCoord2f(ul, vt); gl.Vertex3fv(&v1[0]); - gl.TexCoord2f(ur, vt); gl.Vertex3fv(&v2[0]); - gl.TexCoord2f(ul, vb); gl.Vertex3fv(&v3[0]); - gl.TexCoord2f(ur, vb); gl.Vertex3fv(&v4[0]); + glTexCoord2f(ul, vt); glVertex3fv(&v1[0]); + glTexCoord2f(ur, vt); glVertex3fv(&v2[0]); + glTexCoord2f(ul, vb); glVertex3fv(&v3[0]); + glTexCoord2f(ur, vb); glVertex3fv(&v4[0]); } else // Particle { - gl.Vertex3fv(&v1[0]); - gl.Vertex3fv(&v2[0]); - gl.Vertex3fv(&v3[0]); - gl.Vertex3fv(&v4[0]); + glVertex3fv(&v1[0]); + glVertex3fv(&v2[0]); + glVertex3fv(&v3[0]); + glVertex3fv(&v4[0]); } } @@ -261,20 +261,20 @@ void GLSprite::Draw(int pass) { if (gltexture) { - gl.TexCoord2f(ul, vt); gl.Vertex3f(x1, z1, y1); - gl.TexCoord2f(ur, vt); gl.Vertex3f(x2, z1, y2); - gl.TexCoord2f(ul, vb); gl.Vertex3f(x1, z2, y1); - gl.TexCoord2f(ur, vb); gl.Vertex3f(x2, z2, y2); + glTexCoord2f(ul, vt); glVertex3f(x1, z1, y1); + glTexCoord2f(ur, vt); glVertex3f(x2, z1, y2); + glTexCoord2f(ul, vb); glVertex3f(x1, z2, y1); + glTexCoord2f(ur, vb); glVertex3f(x2, z2, y2); } else // Particle { - gl.Vertex3f(x1, z1, y1); - gl.Vertex3f(x2, z1, y2); - gl.Vertex3f(x1, z2, y1); - gl.Vertex3f(x2, z2, y2); + glVertex3f(x1, z1, y1); + glVertex3f(x2, z1, y2); + glVertex3f(x1, z2, y1); + glVertex3f(x2, z2, y2); } } - gl.End(); + glEnd(); } else { diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index 56ab7030c..cdbf1950c 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -156,7 +156,7 @@ static int gl_SetSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subs r *= ThingColor.r/255.f; g *= ThingColor.g/255.f; b *= ThingColor.b/255.f; - gl.Color4f(r, g, b, alpha); + glColor4f(r, g, b, alpha); if (glset.lightmode == 8) { gl.VertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(lightlevel, rellight, weapon) / 255.0f); // Korshun. @@ -178,7 +178,7 @@ static int gl_SetSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subs g *= ThingColor.g/255.f; b *= ThingColor.b/255.f; - gl.Color4f(r, g, b, alpha); + glColor4f(r, g, b, alpha); if (dlightlevel == 0) return 0; @@ -280,7 +280,7 @@ int gl_SetSpriteLighting(FRenderStyle style, AActor *thing, int lightlevel, int if (style.BlendOp == STYLEOP_Shadow) { - gl.Color4f(0.2f * ThingColor.r / 255.f, 0.2f * ThingColor.g / 255.f, + glColor4f(0.2f * ThingColor.r / 255.f, 0.2f * ThingColor.g / 255.f, 0.2f * ThingColor.b / 255.f, (alpha = 0.33f)); } else diff --git a/src/gl/scene/gl_vertex.cpp b/src/gl/scene/gl_vertex.cpp index 0e70b4077..a11b06fde 100644 --- a/src/gl/scene/gl_vertex.cpp +++ b/src/gl/scene/gl_vertex.cpp @@ -85,8 +85,8 @@ void GLWall::SplitUpperEdge(texcoord * tcs, bool glow) if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - ztop[0] + (facc - fact) * fracfac, ztop[0] - zfloor[0] + (fact - facf) * fracfac); - gl.TexCoord2f(tcs[1].u + facu * fracfac, tcs[1].v + facv * fracfac); - gl.Vertex3f(cseg->v2->fx, ztop[0] + fact * fracfac, cseg->v2->fy); + glTexCoord2f(tcs[1].u + facu * fracfac, tcs[1].v + facv * fracfac); + glVertex3f(cseg->v2->fx, ztop[0] + fact * fracfac, cseg->v2->fy); } vertexcount += sidedef->numsegs-1; } @@ -121,8 +121,8 @@ void GLWall::SplitLowerEdge(texcoord * tcs, bool glow) if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - zbottom[0] + (facc - facb) * fracfac, zbottom[0] - zfloor[0] + (facb - facf) * fracfac); - gl.TexCoord2f(tcs[0].u + facu * fracfac, tcs[0].v + facv * fracfac); - gl.Vertex3f(cseg->v2->fx, zbottom[0] + facb * fracfac, cseg->v2->fy); + glTexCoord2f(tcs[0].u + facu * fracfac, tcs[0].v + facv * fracfac); + glVertex3f(cseg->v2->fx, zbottom[0] + facb * fracfac, cseg->v2->fy); } vertexcount += sidedef->numsegs-1; } @@ -151,9 +151,9 @@ void GLWall::SplitLeftEdge(texcoord * tcs, bool glow) while (inumheights && vi->heightlist[i] < ztop[0]) { if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - vi->heightlist[i], vi->heightlist[i] - zfloor[0]); - gl.TexCoord2f(factu1*(vi->heightlist[i] - ztop[0]) + tcs[1].u, + glTexCoord2f(factu1*(vi->heightlist[i] - ztop[0]) + tcs[1].u, factv1*(vi->heightlist[i] - ztop[0]) + tcs[1].v); - gl.Vertex3f(glseg.x1, vi->heightlist[i], glseg.y1); + glVertex3f(glseg.x1, vi->heightlist[i], glseg.y1); i++; } vertexcount+=i; @@ -184,9 +184,9 @@ void GLWall::SplitRightEdge(texcoord * tcs, bool glow) while (i>0 && vi->heightlist[i] > zbottom[1]) { if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - vi->heightlist[i], vi->heightlist[i] - zfloor[1]); - gl.TexCoord2f(factu2 * (vi->heightlist[i] - ztop[1]) + tcs[2].u, + glTexCoord2f(factu2 * (vi->heightlist[i] - ztop[1]) + tcs[2].u, factv2 * (vi->heightlist[i] - ztop[1]) + tcs[2].v); - gl.Vertex3f(glseg.x2, vi->heightlist[i], glseg.y2); + glVertex3f(glseg.x2, vi->heightlist[i], glseg.y2); i--; } vertexcount+=i; diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 1689909fc..fbd881982 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -245,40 +245,40 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) // the rest of the code is identical for textured rendering and lights - gl.Begin(GL_TRIANGLE_FAN); + glBegin(GL_TRIANGLE_FAN); // lower left corner if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - zbottom[0], zbottom[0] - zfloor[0]); - if (textured&1) gl.TexCoord2f(tcs[0].u,tcs[0].v); - gl.Vertex3f(glseg.x1,zbottom[0],glseg.y1); + if (textured&1) glTexCoord2f(tcs[0].u,tcs[0].v); + glVertex3f(glseg.x1,zbottom[0],glseg.y1); if (split && glseg.fracleft==0) SplitLeftEdge(tcs, glowing); // upper left corner if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - ztop[0], ztop[0] - zfloor[0]); - if (textured&1) gl.TexCoord2f(tcs[1].u,tcs[1].v); - gl.Vertex3f(glseg.x1,ztop[0],glseg.y1); + if (textured&1) glTexCoord2f(tcs[1].u,tcs[1].v); + glVertex3f(glseg.x1,ztop[0],glseg.y1); if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs, glowing); // color for right side - if (color2) gl.Color4fv(color2); + if (color2) glColor4fv(color2); // upper right corner if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - ztop[1], ztop[1] - zfloor[1]); - if (textured&1) gl.TexCoord2f(tcs[2].u,tcs[2].v); - gl.Vertex3f(glseg.x2,ztop[1],glseg.y2); + if (textured&1) glTexCoord2f(tcs[2].u,tcs[2].v); + glVertex3f(glseg.x2,ztop[1],glseg.y2); if (split && glseg.fracright==1) SplitRightEdge(tcs, glowing); // lower right corner if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - zbottom[1], zbottom[1] - zfloor[1]); - if (textured&1) gl.TexCoord2f(tcs[3].u,tcs[3].v); - gl.Vertex3f(glseg.x2,zbottom[1],glseg.y2); + if (textured&1) glTexCoord2f(tcs[3].u,tcs[3].v); + glVertex3f(glseg.x2,zbottom[1],glseg.y2); if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, glowing); - gl.End(); + glEnd(); vertexcount+=4; @@ -328,14 +328,14 @@ void GLWall::RenderFogBoundary() gl_RenderState.EnableTexture(false); gl_RenderState.EnableFog(false); gl_RenderState.AlphaFunc(GL_GREATER,0); - gl.DepthFunc(GL_LEQUAL); - gl.Color4f(fc[0],fc[1],fc[2], fogd1); + glDepthFunc(GL_LEQUAL); + glColor4f(fc[0],fc[1],fc[2], fogd1); if (glset.lightmode == 8) gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); // Korshun. flags &= ~GLWF_GLOW; RenderWall(4,fc); - gl.DepthFunc(GL_LESS); + glDepthFunc(GL_LESS); gl_RenderState.EnableFog(true); gl_RenderState.AlphaFunc(GL_GEQUAL,0.5f); gl_RenderState.EnableTexture(true); @@ -364,7 +364,7 @@ void GLWall::RenderMirrorSurface() gl_SetColor(lightlevel, 0, &Colormap ,0.1f); gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE); gl_RenderState.AlphaFunc(GL_GREATER,0); - gl.DepthFunc(GL_LEQUAL); + glDepthFunc(GL_LEQUAL); gl_SetFog(lightlevel, getExtraLight(), &Colormap, true); FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrortexture); @@ -379,19 +379,19 @@ void GLWall::RenderMirrorSurface() // Restore the defaults for the translucent pass gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.AlphaFunc(GL_GEQUAL,0.5f*gl_mask_sprite_threshold); - gl.DepthFunc(GL_LESS); + glDepthFunc(GL_LESS); // This is drawn in the translucent pass which is done after the decal pass // As a result the decals have to be drawn here. if (seg->sidedef->AttachedDecals) { - gl.Enable(GL_POLYGON_OFFSET_FILL); - gl.PolygonOffset(-1.0f, -128.0f); - gl.DepthMask(false); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); + glDepthMask(false); DoDrawDecals(); - gl.DepthMask(true); - gl.PolygonOffset(0.0f, 0.0f); - gl.Disable(GL_POLYGON_OFFSET_FILL); + glDepthMask(true); + glPolygonOffset(0.0f, 0.0f); + glDisable(GL_POLYGON_OFFSET_FILL); gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } @@ -471,8 +471,8 @@ void GLWall::Draw(int pass) { if (pass != GLPASS_DECALS) { - gl.Enable(GL_POLYGON_OFFSET_FILL); - gl.PolygonOffset(-1.0f, -128.0f); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); } } @@ -585,8 +585,8 @@ void GLWall::Draw(int pass) { if (pass!=GLPASS_DECALS) { - gl.Disable(GL_POLYGON_OFFSET_FILL); - gl.PolygonOffset(0, 0); + glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(0, 0); } } } diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index f9f1a823b..83cdf67f6 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -152,12 +152,12 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed gl_RenderState.EnableAlphaTest(false); } gl_RenderState.Apply(); - gl.Begin(GL_TRIANGLE_STRIP); - gl.TexCoord2f(fU1, fV1); gl.Vertex2f(x1,y1); - gl.TexCoord2f(fU1, fV2); gl.Vertex2f(x1,y2); - gl.TexCoord2f(fU2, fV1); gl.Vertex2f(x2,y1); - gl.TexCoord2f(fU2, fV2); gl.Vertex2f(x2,y2); - gl.End(); + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(fU1, fV1); glVertex2f(x1,y1); + glTexCoord2f(fU1, fV2); glVertex2f(x1,y2); + glTexCoord2f(fU2, fV1); glVertex2f(x2,y1); + glTexCoord2f(fU2, fV2); glVertex2f(x2,y2); + glEnd(); if (tex->GetTransparent() || OverrideShader != 0) { gl_RenderState.EnableAlphaTest(true); @@ -398,7 +398,7 @@ void FGLRenderer::DrawTargeterSprites() gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_sprite_threshold); gl_RenderState.BlendEquation(GL_FUNC_ADD); - gl.Color3f(1.0f,1.0f,1.0f); + glColor3f(1.0f,1.0f,1.0f); gl_RenderState.SetTextureMode(TM_MODULATE); // The Targeter's sprites are always drawn normally. diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index c486cb374389d7c4a2f238539351c00825608592..ec717934c0668b702489bbd117d475ee2044c1fd 100644 GIT binary patch literal 30486 zcmezWPoF`HftP`cL5o3)L4hHiA%`KJA&sGkA(0`MA(bJCp_CzwA&nuGp@>0`A(^3o zp#Vv>Cqphn0YeT$Dp+kELkUA7LkUABLq0@sAl&H>)|1EJ&fvqKfaG2U z6c@wP!)RTG!3bflQ($mr$Y&^EsAMQ&$Ye-o$Y3a8P+%}(FaSecD9fAyq%H%jrkJ4w ztRsU#fx(|4l_7^AnIRh-SH(!Nk zNGSo6acA&j2xU-U@B!B;px6V&oI5y1L9qc!g9;1*45bW7;F1PZ$NPZmdQhB$)GIK+ zLI9?w7#vzD@NyNBA3*L#c9RCTKxqY(`(d#F3bjhGuQV9^82lMR7+e{w7!(*llhEN6{aF~Nc zLm7e?0vP-mf}vpxi3yMogTcOaWB~aG6c5PdCdmH~KPxb}GK4X>GWaosfa4V8Mjvq7 zALe7!_;Lc<0}5@BFMPl}gggDf{sGwza)&cR2srFOwxNn4LI@=13{5K_H#jo*fb|43 z1TeTVfMj4Ipj6-rjcZU?M1s{pLdcoHpTQ3t27wHrP~UhmfOIM_xG*>}_%b*$xP!x0 zfk6Wt`?yj9!ex+LggZrmQlvivC^kTT1;sJQ{h0#0L~)Z@1jRNYyddcXWGg7oLR=0@Cy3MzDh?U4OBLPTCvm6;*z@;fH7C<^c{so00s00AzeNYUemMIWb!3?3`atD%PV7UNM5)8&( zyDmHqAt9y@=7ZSE;Jz-X9xDa+I29O_z~d_V48;tU;J!3yyhI-?7LOvP$B@CG1U3ho z8KBV-P>om2fL~oM1ISd+_(}l*m1PX^@P2VV0kxo>2&f$j8VdlmrwF^DfC1ExCaf+Q zJX&DP0O}dy^FOGimJA;80JWCzn+x(8sC5DgFGxEbzj{zx3^JAl@*Al2f?s_ac!VmM zA%g+Z-bSb3k3!(tm4+-nhE5pGKPHcXew;J zAebQ)oL>tVe8GMGQU(nMO$La1bhSR3fkp;E zX&98AK_g(G5xErb7$UMLXw(LlW0A!{BgLT6Kx8pcEeNVxLAfJ?!Goa+oGU=%<@w zgGzc(IJz^Sis>;pfk)|5!Sht0@)Xn#1E~a!o>eiVf=A#qpt@WcK)JPup^`z9L5snN z!IZ%aUM6rdgfbK`K-vVUQ1vjIK|NoDi-Q>uaRV9=1daV5m-~>A0F6F^Mgt%v4kv>T z*qtQ|&d^y*P^pYfB`BOZ89W*Cz%x*gvGPm?kWV0`3@9WJWfCW}#g4DEgQ-Ct`vjTd z4z7Qaz+vnJF3TWoD$v+i0RyN`%V)?%3Rj3YvfZF@V2I7`U|)e$Aj^a5uT+K<@LXI8 zLpody#NQ@gh8Xlpb!I1Dp&n_j7{RQovk_nX@?=K=G@<5Y6Dk;KUFM zu0=pKFlgorR1$&G2q;Z}W@SKg7oa&hP+u36hCn4UNE}q(L1yqF?g6!dK|KUe{{vF0 zfa*t3iUW-;gX(p6hH&T{2xxW*HaC*X04j4Kp$)PNG;8hwF2O;zf@TJjz-tLWCV<8O zKyd?V1AugZ?179EfqJ%S;PDpFJY+nBF9T>~IUd~N4FacZP6k-~5Zjtm2Db@7vo2|1 z6CiQS30{K$3V%>LT#q3Q-0w?gC}vP&2x4$!@L`B&@M8dtc84&;gGcBi7(ipIpz&8& zJR!#vCj-JgX$%?+O3-#k0eEH?)E0ux#6adjK(jiabqb&!KWM%R6iUebL{J=o@-=LR z1hlpzh9QqZ390_&WPp@vpfG{No(8yf!|of<_%UQ88Z?3j8vl%EfQ(=VF+@V=UqB`y zQXi(D{K0ie4tTW)q`j}ePzbJ*Ky3ub>@RUHhPfOR`p)3hN1$0#(ApVDn?!@bfI*MJ zfFTXs-Xp|Dv^7x8b74qj0L_DCFlaD=FRXubi|b467j z3|{*LDs4fnUJ#wb0Mil7;0qpe2aU+WbU{)Z$W@@W6fA6DIzTfOAl0C8d6*7J`o^Xj zG{+DCp4owukN{)5a!H3^%m@tXr0wFk{Y5jMvO93!CFI>Kr}vw@)51`qHE0%!&cG?NC( z(P2pW2NWyVLkw9zXe8!Qas8L*`wNP2Jr=Mhj3A3dE0 zgXjA|;{!enkkkQc&4b!Z@!**%R|Zfy3Yt*>%@Ba>0L>2~t4DPsXr);JIF+N@1e(L-Fm{y}}{JO*{}x&Tnm1GLHzWFn}Zfvw*Ft!x0T(*d;`Aayb%{b5V*pt)Fgw79~a z!ckR1LIjli&{GRU9k!4Km0X})h%J49)`+AtWWv)N%oI>*49dxfGzJ=541l{B9Rd0W`Pi#^45?T?g?%v*!v7HQ;qTptb_Y9$1NkO)V^sLF@y? zC8$jRYkhh!KzeVW9%l(d2(+K)!H^1HLyFu>gy{yY7zOp_Ai8j=28DANLnZ@goB`Gv z0oAUcPyvlEK>Cy*7w9r5Fk~=jGUziHfoolex#8eZLQo43pVbiHDYjK&|pBcUqLD%;Q%V7(0g{e40c$1^B~(HZD&Z^0b~LwR}I$w4ajXUH-cto z5o0Bgd=F}QgK{6JB@P+4f~khlgVkp+_km`HL1hYPr4neC5VYDak0A%VHVV15TMk|; z1kwc?&Bito4l2VE8Op))o{&)pP+EiK5D?n{JVy=+S43I@iNj0<)oGx*4YXC2BIj^|=M5pVN_p@RAw>)KrV&kIPBvrpqz@$br5r5VE`#DaFuBa42s}!P>3qbG6iB5EL;)2Hf*5< zGYdBIg9v3%zXqEQkPi^$K4^9Zw5tKsCo4vqj{uoKI7AUWGMMi{rEfd~X4(eT9iZAn z5p5I?*0)6XI2bz0ha4M_cqVoPFq8q5DiZz4F^CNyuphq#u@w+`z4J z&^$s0gC2M{1E{?RYNaDe6jU{!T!EQlK&cs79dc@drFdLp*ofQ+a}{L#iqM!iCwRqZ zD$Y@HL|p(Ys~{;CG%^QC3CME|$oZO+0ogBl44{01m}N)y8@7>lSj_~p)r|o(-UTW@ zK(>O~&mj!RBRZhbL68lg86{9Z4%E*AjUB*Z0OD#;tbtPJU`&;^;MN_;bud?g)_UbL zKxPjRGa4{i7!4X_1Nj`%CIHo0dC`tjX=B0Ks0ELGiYZHsFjom z-oI7?Zd-tM6M*)bLG~v=#-Tv!L2Xpfcp_-57c`0lD%n7@+n|*Op#BbMtQ^EHU_g`t zpcUx|eV{QYP>BH=1%=FMLwZ=C)CU@&1C1bqM!7(<-k=x;xehea=?Gqv4eG6dL_w>% zbHKeUkjbE22ild94_;Rf>wlGl#|1$>KFG*pIkhYE0RHLK@sy{Aq=pwt!M^w1~Uc=hFECZ2c#3xI)JR61I_!wdOXDpi1Y~w zUF5bGD5OEHS=i_}B&Ftp*X)C06%vP_om-$jGidh*Xige5#tz8=AXYJWF0>MyM?kFw zP`pA`tDvSqP>&5%%0N=04S3`kqRtN7g9V9$QY)xs3mW${gpPrN_Mae+wt!{_K&c#( z;vp#(R3?E&^+A10{Pw`stDx&cw-vNg2)C`sYi}SuSlm8?*@&zMR9Aq~JjhmE@Q9KH z)VCm?gV?ar5fZ`f|>j#a+gLcC}+zv`B z4N=ArAh8V^!2y+YARVCa&xH2r4Ztg;K|CAqPEgPsI%v&w zCWAJEHjZ(3&}a?9m!LgCpm{4$jDpMo?eRsAHw6ZeyELHt9g))kNF3x|(25`h215oT z26Jeh0l6EJXF&4?u&{!)q9J;a?S_R9L=0Q#fa-Wq$iu=F5$>D}5M2rk+Tiv+awG1C zjhvnakGnzhS&$VpkWv}d&FFcU7VZYsY=gJ$0CF8D1tZgg*R>#*lG@Ti9wkCui3RFk zfJ}ttFIc@%#8AXw%K$1x(izgBtR#jcFbkH~Ang+kaIX$j*Hl1dD;R9RwU-%#HA4kT z{Q|QEG;UM`E`y0%85Ye@!4S)!$4~?(v4w*g1H^S8cfvwK4ZNZedsskJL&5mIJk_K`DR}#YA-7dJKseIS}R+Qqx~L17yuCBrecPZ`2fMh+!+pt>lF= zXpXc5yyG6UW(qWO5(!?91j<98{whKaHEki*J%dJ`Ao&R0EOh;l&<42`GByV~KLu3g zKt@uKceQ{~IctIsC=tPG^@TydZ zJ`f3-;{c7bKx{{^;WD8$Tqc7J17uvymjPs-9)lnFWDSTIr2Pq+lLEyLW-kj?UO;+1 zpxzp42t+f0dKQpy1l4p1^`NmrR69W75AsU|w4Vo&g}KU!p%Ofc2^v4DU;x$Bi1s_k zWY}ma#01bh1ZZqE9$ce?{I184#1M?MiwNN+oi z0~#Lyt$>VYNCvORD`Bu=#Ukh?SsPqEu}At zJ)kwrdJK@X4_cWCiw$&Ng3QNE2{3y=eZm@WuN9WBLFyqGQkOv3h}j=%G6q@`532oA8IZ@|6&OGz z5@;7TsMG|dPxSo*Ff(8@s#;KK0jdWeqsWlGo1pcSpc6_!wH+uWgGw0C8W_--F(9=d zn?R##ka;24C?ce80h)Gh|E zwk?64vV-bcLhb;W3ULK27Z1I>0g5r?yfRo*7OCxH&^$6|B~~7I?V|>G2P|lv8fv-# z)pVeG64V;aWT*h|9|M(ouyt3kbz45*vj|)n!jamuAic1a`JUjF;-FdqwD+tMX~rJZ z3(R4_X9wgA3or1wAE0%9p!LwO^aRmOtS$ZwpnZ%P4EYQi44`-gmHiN(AdljLMn*w> zdi*LNH5F(+46QN-v%UpqlqA7S_CLRU=_HVd-48c~a*h9&k@fyis-Kx=0~ z>-%8(AU+1=5d{Ws@LU;a=NPE%4cgfU+FuMhoddK+8+1Ad=#(FS@X0Fy(DO1taSB?e z3ObnuwBFs1!JR=73?U}NS|p(KguV+Gl3GFW2$BW$#$fdYBwj&l!$Iq5K`U#K*Pg=M z&Ivxn5!B{|*aa&OA?XTxSonfZ+5x#b7<`5dWG6MkM0|R&udzkf3p%R{GCo>5iMj;xeY4$A*~@$=?hwM3R$&-SZM?CDJaaasRy;i(8~sdtspZI^#rI?z}80v zrG>#-PJ-M93IPxeYWINpIpy#9Wggn2^B2`_nb-?KqruZ`lg8t5HmpYGx6}=Gfbu!Z9EL-LQqQtG#?0RVM6+= zpz}?Ud&RJF1ELa?$6SjdlBW|n;7K^Zw9u$9|))6T07=lL#LH$Y4d_g4xD!&4{;u|3kSpg2? zgJK_aE-|Pr2kIe#(j{t+1I=ZD<`9d}au%s66cji3Y7tC7RzUp%^ApT3l~6xnb33wY zA-Q`r71JUYfMS!}R2;wn>KlO0!zMl*V~gv7O{d7dKu@XITsxXFX^{>w%_J{ng4!mS za~+WW0<4t}s%b#`JwR)&Gr=dhgGNn3BOr*;aL~*d@+r5V7BF(13~Hx<#@#{V@31l# zWD2NV0@_CnDwiR9!qUNK@`Ln)_KSh^fY_k9NZ1NVP#Xp0TiAFbXdM=4FAzu#Xzmka zFU&m9&TY{8L(mzwpp`2iGe9S@Alw5QwFkA}Kx1v7Q*R;ria#lrzeBvOh9=TloLTctzz(* zjUZW&YEU@?xK~N5j3kd;l>r1S%KM`zoM52zp3pfLBDr z{EzTAs((Q)NA@SePoUN)XvPb47YeA&itx#39>7ey)Di)u4N~&}Xs<~s_$*FDOOKjq zAC!JUWjVI?*1)t5k$sHpQ({v&HlHBs1XvG!==EtpV`s(;E(~rAP7JVFLeL%^P{|k! zzKH~KQ&9l;rWeRsd*oU|fdMoM4l3V3rJ53Wr4ne}E+~wZ7(go%KeCZL)XVme3;RLX#6sz4*apcM?D8Ea4*4pgFmXxNTEP^+v2+Nwcz3AOSQHO&F# zO%NtEf8vV)>|=PSBc7nRaAOFA-d_MJi;WmS^$%!0IV5jFM!q0y&@EG_G9WjjuiOWj z0xQugz-=(p(L!YTN-XlA+igI#9H>qNxerx0LKdVKVm~4^#Dn+tfM%CL<94uFOpqyV z3@+dk)If9Ipfwku^}nEc2sE0P$N-vq)&j54M-~I=gZUhBPA@3Mg3fcup=dk>;&NDP z6yGjh(0NZe4A}A*=!^hRD8X6|Aorri4`z&kc7lU)5M(Y85Y%Y8 zY$1&(?I3f(AXi}zJxFa2TbqF>6G34E%CXeUVbn7V<~m5b3FJ;r2GE!?X#WwY7YJI@ z017WqSqJK2fo8`*=PJVV!D#Bah?*vWTnECWmPC;GQ9|cQ!gj%cRzE>*1Od%1f=V1U zl$+&1X$F?_K%?%U9xUiIaF96YoDtBRMfxf3VYD0R4(9?Um)u(br=YRA*|g6nX5&(pPW!JL0a=r06y6ilrkZ)q{~na zUS|#qHAGp6NSP3op!3V(86ZA{sYc!n4^xFd9YI#NgVF^g1%PrAsGkZ-6R_Q75YrK* zE2zYxW{E*Pvp_isbaGg zCV^ZB!lahDp!|pk8$x*iln+6+z}g(J5immfV7m?xD+)j}y`a&5P>u(+z@x!?{s@@^ zNr#~EMM7yBROZ5LgXlt}UXTw+4JXL{;#6=M4XSxSYoH+~EPzadg$MG^3s4@yy;lKL jHWIhP2BdPRp56>8E91dybV0QbXypW`_dw}c%e4#u^2A2~ literal 14716 zcmdPb;?mMmNY9B+D@x2wO)5=GOD)n%E+_zrdgd17q~@mPl_ZvA=I1HorzwCPDizZ5i*k!~ z6v{J8G8FQQz;u3T3CM!n{1i}7fCEcM0Tem~sYSV&B_*jT3I#>^Wtl0dDGDVSi6!7* zOv}&7$uG~$OIJwF&r8V!Sqye2NMCMhi51johI(kO0|zqHS;_e+sS3HJ#U%MRlk&?_6_R1$0&@-Df!8zhyx{d zky@mXn^=-sl$n@Qj0k&hoPj)v9NS>e8S5#8fRc7%ZYn5TKxz_8OEU67##DmBP9Z53 zlq6CVO7ay_^HTDQic>+cUr>~vn_rR&vLdB4xda@63JMA-sYRJ(sVNF+Mftgq5HHS8 zD*OK?x}gHMTt2I0i{VfnaK)1naQbn#i?NXK_bN&sVUGnfEwghl$xp# z4D+U2era9`I44*uq-KI6q%5@vb=9y%?5*K_Q`| zkXn(PT2KPY!=Pv>f_VW{cvULoWF{3Q7GEjs^3AWYEGsF*Mqnm$_f}=u!V^D~vbEuDFkU~IcP=J51s{+UiE}p^8 zK8~Kgt}ft^_w-Zn^H*>UbM*^R2=;LF@c~;4^^}vVf{&-8laH$c*hs%f1sBgCSLYCr z)1fSob3FZ=JzZS=LL7Z`6oLa>ojpMe*9ceN03XMoNF4?LAO&ZCzhKwEP*=YYPe&gG z7e`-5ch_JA4b%_-nS~w*0YU!Gp+T;`AouyZDFlZ)1&4Tsgod~(xcmFNfI?Rx*fl83 z)7drHTEWL36y9zMp~0>?Aj4c7Lma`@2L$=Md4>dAgPh_N8te%UCQrW**Px)#fDliA zKTQP>|8UnZ*B}LF$IxI`Pz<^#`1^q(5@b+_hpT^3q=LU2I6S~1uA>m{;Tq!M8l>Rq z2l8G>kRvEyfcOwxyc`7P`GEXtEPfu zkY})`pF7A@P$~*{j8yOs4FOpVN^PORt_uEcAhS>srVcm;6+GP(99_aZLGJf=14m?l ze{irTG>L$N&)EYS`k>gSUe&D&&Mx{~T*{ew$vLGdsR~NzIr_zw#U-h^`sq3G5SCts z5|VRH5AX;_}1-RI##nP)(bUDwvX=pIcm#Sb{2=8()x@jxLm3lx%E-Dp;19 zT#{deW_MY9L1Ip7Nl7ZI+LF}V0#Jd4raCRLC^;ju46GQ*Pbi)SH7pTMp z7Z>r)K90e`8jyyo8>ltx1a1v$a=Au?xCZ&fJBK+2DQLLmoX@GX>O~4^Ay9E$~gvE7j1nh70=SC#JYo zl%(c?D&k^fnSi3qyprIO#G;bY0-yYJkQA4`zAe=Nm%ct6QO!_WE-sANva-Su(g25v zR)%kWUS>&tk&Z%UUWr0^W=cs0gqe{F$|?|cQf5gpgjJN9R+L(t;Zdcdkd&XFqmWjb zlT(~rl$x5SsbHnR#Ti^$kXodHFcfMa%rJ;SNQNNm=c?x7M8ukctwLUExdKw0YJghl zn$}#Lxv9Cy1(gaK!QgI40HnOpQE-Q{^qdllQ=Rj3@{5Xf6pAyeQuEU^0upmv^Gb>; zHMNXP%|K>^7NjJWq(XHlfMS+280?SYjQkQv5?8QQ@C)_vvF76RNh~gLPRva$N`#AX zaeC%umSiU8WLBjHmn4>?f{jSeiAPCdoas67kTzpUs(Vg;Qeuu1ICtbG7PuAV=Yk!X zn^*wW>yjUwTH>CVo0|yc=B1{l6sMM?g9H?86-tUqQ?0o;K?Qq3YKnp_Bnwz`aXKa^ zr{);BAe02BmV^aY<|S)@G9x4(S##B5O%!#QsX`MJ3n{5NsU@ijh{&);iy26`)N;`v zHz**&wHVwMclS|%744ABLd~24&IA~tU}c4H1T=C%!2+r(Gn1hSKeMQ~#1;}OT%c&i zEJYxh0gGAIT%4I{3L0r3BQ&`d9snDG%RDW~S8WTtU(af02Q zo}-tRlbBwt7Ubp=?-$@75+C9k5fU2Ys>#I(_6#T3h%^nQ;L?JE{31xtA}>Erp&-9J zwMfB80a}?AE2QRux(O+IF?mX$Ovzb`%?f{KXP?kuPk+Doz);tqNDN#2laq5wL1ni> zVQFenB{oBAK~bdVoRgYZ1kQ6B26_f*Itu6{$PMW^5Opr81tl38hI$5RP*JdeTWMah zhPzL^k85x+R6IB%F(uVEKP5E>BoXZE?;ql!Y0U+;(G~1JkhqH{sBsF_f)IA}3Gi@? z4{;3+fl9e#7K4HWq{TVZ$0y#+(b*MKD!|_-(%s)L-rvnF*fk{H&C|yRst92;ni?NZ zKbS!XHBLURel8d~U0ee~JU|t{Z$P|X7*ra`VGwyFM**I791j{XfTH}Q#H5@` zg_Qi%;ym>dh1|sKRE1*5FhgEtZhld!9$M0J^LK}YjUG~9Lj=JpVLo;9cSm^7%`q4$ z0^Rb{GeN-yQsV3H;tCEf*N6a6ItH5o&N?6!&i+3BLGezZZf>qY@lKv03N@hUf}{w9 zC`cbCs6hcLAUzap72H!xLW)XLJ;03$aQz07&49=tiKgf1g=MCegGvnz104koh<;s# z3{8C_9gr#EpcaaTCYTM=r)jOg#l`8Anx2_wnntS3h=yih5Wo6@VKi&UVgcr0$NKsr6{pH9@K``0k<4<6bv*K^!33( zgW7Da0k@&uef*sqeVqOM+&tYiq0MD1wIala8sIhps0LGXPRxUeX(~W!GUQNq%PB3+ z00lTFXHjZNX;Gdv7iTS&sN&*uDM~C4N-RkYE-6h*1M9$Q4y58lOH2xi;PeGg4G?#L z+=nm&qz2Sz0lAVBsgIl35I|a=>*}T25klPHJ&+PNgQqdDLrm+u|-^5McsILE-*EE)buEfSN_o=4KYL zptcn#rR2sJL)w?c;9e6n7lKMi(3mu6MyfO?5j1LDl9-*E2bp#NO%4>NBvyi&+@K)~ zh}jCZ3duQ%xdk?9ATc`)uz8^7p<$Yif{7lualr|e15HbTM=sE{fI3^SQ4N?*V-%f` zaS?3#ATpp46CDLz13e3H%hUp7D;FncN`7fl4!GeCiC|j=Lj`?^vq3!tsB~U_QLch5 zsDZ6vWNNAh>a3SR)axo3f@@>WwEQ9k4N$F{sbH&MV6Bj;V54AUYG$pFsjUrfQ$vj_ zOUzNQRmfD(Likr#K?CML1(2BvS_+0n<{&3{7HK3Mh4K}&K@P?uYHDZ%64d~u7EMS@ zLOfyzassH!ucKg~qhL^xmX-zzR!(q71J>OJn-1{-m{{JnhA?PVoasxFc-AIqv~J* zo-zc|B7qL=K#CDivM(yKHPA^8j7O0qSu<^p91aDJ$;HL$L*0cC{>a83Z#I7LO; zwphlKqAOzcia-fCJsqcfI!Hb#38#D#xDmuzRAgsoYhlgBnVt@1Bqc!@T%6D$bflqF z1zQD;q9QGGa|LaM^mHvl6JrH!g`^}cV^d9iBU4jw^1@XgyQh}8<$#6^QlMd?03Qxh zC`inSHZnDf1t$r}xSB=*DA%Hmtr?k`X`v6LX@YHqjjSnXVaX}(sU>hb!B#+;feI+5 zgN?zHH^7cZIJqc22~?<*C?w|Qm*$m#jRh-FuvLILMgtBduj_js*skLoLUT;?gmY}BXUrtt$}r>O-O2m zZ(^RFUuiD183k&9L2DOKo&wd`P`jfuW8qbf8&tJ|R!M4wf~^A77^h0lyp+@mjZ9E{ zK?a^mQY&=r(sSZ7^V0J5l7hkWA|PWRgHD`o!P%8g`4tLU#h}Q54A#XbCl;63KxMS- zG)ht{Am+hyKg8{3)}UHYfs2z9I)nwWu{cTB4(w-;gCVj|%Q(T^+f0xX6>Jrd)#=)0 zrs%n+mOz{jwT+V#?sJfqScMu}1w&9l!3n90pd@Jgs}|fx0uLZSq9zwKwxm#;otak* zs+Fi&GDBK+3NA=&ctQr=RvhtS)rN$(FD$i)Qqkl|L46@k3>^VM{$8%m;OT!*ZH8Toe^E(Bz6KX3 zr-r)^q-mz9V4#D_cTX*WkM3Z|z1RGd+oXQklk2VSw^7#ia5>lmN_T5RIzB({&UesZgQ90M4v5&`~JO%quZAQYcAG*HI`-j0e@JAWktj zvw(~XNCd46D*%z8`V$oP0f|M$sUSJ1RUwJ##TsBcK!$@%1shkAm|m=-pa#|o8I{w7 zc3DA&AYuwJRD}@JwL>x=Vm8_b2Y$0prZgc8)PoX%yJ!tj3J-1+;S32+(65R!8t1@HLU~^ zN+tOP5C(XS2ZWiFUs95vtD}IZeTs{cp^Im7@{<#D;`56#(=+ox0SswXAWD5iO@LO0 z!5p9gu^VhJ)J~XvU|Ucu7%FX7T=fKaqK1SJ2PI!bi3F|K!RZnd*5H*4Lob4{G3WiEv?{@T9m4zpi~SNS5nALP0Rz8A&Dgl zi3$)wg_5Go#JuzzP#-=|AvrNm0W_7RkXfP!F@lPn4@k=lOLGj>=|~MSXd6*S!7U8D zrqoD5s~|r!54Pwm56atSRpvC^6VxUq-0qoieC=GHoCnv(a2-hLG3_PGn?P)~NpsfOzzCLG2Vm4^ZM*%XW z4O$*Y?G%G&EZ04?1btZ^Xd0rpL;*6=r3RVZgp{>v1(_wu89EBC!NDPw1*r;Z;LwUM zsVqo^#2#pcqk^qMuyc^Bt6#XMONa+(DOO&I0%#!uMAXC8)7>Kk)U*#u%}GrxPQ|bu z)aFJPgf3PDxhc9_K}#V+K}*3HJW-XN18yS)m*f|vf|pnXfIBQcp6-62)%ZH#*%?s3 zFDNxJ1+27K!$3y^eTrKbwDtkk2L{cg80nPjWazm2#0R-Mfv8ZwU{7~HSC@E@8+6d! z2XZq(mzaQ5frC)NRzbI1%h;NW6A^--a0>?6X3fP333QMM`jSa)1(5fR6|@vIGQiVB zR4)%<=~4k2KcI3h6)AB-x7AU-Si_S@p)NrWbjT1csL_NjgQ(b{D=njA70}gKbKzc) k3d-xas!8|6+|;1dV$h;xhyx&_`UAUK7PPLA$aS!_02t9OuK)l5 diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 299ea7878..536dc194b 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -116,82 +116,6 @@ static bool CheckExtension(const char *ext) static void InitContext() { gl.flags=0; - - gl.Begin = glBegin; - gl.End = glEnd; - gl.DrawArrays = glDrawArrays; - - gl.TexCoord2f = glTexCoord2f; - gl.TexCoord2fv = glTexCoord2fv; - - gl.Vertex2f = glVertex2f; - gl.Vertex2i = glVertex2i; - gl.Vertex3f = glVertex3f; - gl.Vertex3fv = glVertex3fv; - gl.Vertex3d = glVertex3d; - - gl.Color4f = glColor4f; - gl.Color4fv = glColor4fv; - gl.Color3f = glColor3f; - gl.Color3ub = glColor3ub; - gl.Color4ub = glColor4ub; - - gl.ColorMask = glColorMask; - - gl.DepthFunc = glDepthFunc; - gl.DepthMask = glDepthMask; - gl.DepthRange = glDepthRange; - - gl.StencilFunc = glStencilFunc; - gl.StencilMask = glStencilMask; - gl.StencilOp = glStencilOp; - - gl.MatrixMode = glMatrixMode; - gl.PushMatrix = glPushMatrix; - gl.PopMatrix = glPopMatrix; - gl.LoadIdentity = glLoadIdentity; - gl.MultMatrixd = glMultMatrixd; - gl.Translatef = glTranslatef; - gl.Ortho = glOrtho; - gl.Scalef = glScalef; - gl.Rotatef = glRotatef; - - gl.Viewport = glViewport; - gl.Scissor = glScissor; - - gl.Clear = glClear; - gl.ClearColor = glClearColor; - gl.ClearDepth = glClearDepth; - gl.ShadeModel = glShadeModel; - gl.Hint = glHint; - - gl.DisableClientState = glDisableClientState; - gl.EnableClientState = glEnableClientState; - - gl.Fogf = glFogf; - gl.Fogi = glFogi; - gl.Fogfv = glFogfv; - - gl.Enable = glEnable; - gl.IsEnabled = glIsEnabled; - gl.Disable = glDisable; - - gl.TexGeni = glTexGeni; - gl.DeleteTextures = glDeleteTextures; - gl.GenTextures = glGenTextures; - gl.BindTexture = glBindTexture; - gl.TexImage2D = glTexImage2D; - gl.TexParameterf = glTexParameterf; - gl.TexParameteri = glTexParameteri; - gl.CopyTexSubImage2D = glCopyTexSubImage2D; - - gl.ReadPixels = glReadPixels; - gl.PolygonOffset = glPolygonOffset; - gl.ClipPlane = glClipPlane; - - gl.Finish = glFinish; - gl.Flush = glFlush; - gl.BlendEquation = glBlendEquationDummy; } diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 2cd554111..7e937dcbf 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -66,81 +66,7 @@ struct RenderContext return maxuniforms>=2048? 128:64; } - void (APIENTRY * Begin) (GLenum mode); - void (APIENTRY * End) (void); - void (APIENTRY * DrawArrays) (GLenum mode, GLint first, GLsizei count); - - void (APIENTRY * TexCoord2f) (GLfloat s, GLfloat t); - void (APIENTRY * TexCoord2fv) (const GLfloat *v); - - void (APIENTRY * Vertex2f) (GLfloat x, GLfloat y); - void (APIENTRY * Vertex2i) (GLint x, GLint y); - void (APIENTRY * Vertex3f) (GLfloat x, GLfloat y, GLfloat z); - void (APIENTRY * Vertex3d) (GLdouble x, GLdouble y, GLdouble z); - void (APIENTRY * Vertex3fv) (const GLfloat *v); - - void (APIENTRY * Color4f) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); - void (APIENTRY * Color4fv) (const GLfloat *v); - void (APIENTRY * Color3f) (GLfloat red, GLfloat green, GLfloat blue); - void (APIENTRY * Color3ub) (GLubyte red, GLubyte green, GLubyte blue); - void (APIENTRY * Color4ub) (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); - void (APIENTRY * BlendEquation) (GLenum); - void (APIENTRY * ColorMask) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); - - void (APIENTRY * DepthFunc) (GLenum func); - void (APIENTRY * DepthMask) (GLboolean flag); - void (APIENTRY * DepthRange) (GLclampd zNear, GLclampd zFar); - - void (APIENTRY * StencilFunc) (GLenum func, GLint ref, GLuint mask); - void (APIENTRY * StencilMask) (GLuint mask); - void (APIENTRY * StencilOp) (GLenum fail, GLenum zfail, GLenum zpass); - - void (APIENTRY * MatrixMode) (GLenum mode); - void (APIENTRY * PushMatrix) (void); - void (APIENTRY * PopMatrix) (void); - void (APIENTRY * LoadIdentity) (void); - void (APIENTRY * MultMatrixd) (const GLdouble *m); - void (APIENTRY * Translatef) (GLfloat x, GLfloat y, GLfloat z); - void (APIENTRY * Ortho) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); - void (APIENTRY * Scalef) (GLfloat x, GLfloat y, GLfloat z); - void (APIENTRY * Rotatef) (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); - - void (APIENTRY * Viewport) (GLint x, GLint y, GLsizei width, GLsizei height); - void (APIENTRY * Scissor) (GLint x, GLint y, GLsizei width, GLsizei height); - - void (APIENTRY * Clear) (GLbitfield mask); - void (APIENTRY * ClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - void (APIENTRY * ClearDepth) (GLclampd depth); - void (APIENTRY * ShadeModel) (GLenum mode); - void (APIENTRY * Hint) (GLenum target, GLenum mode); - - void (APIENTRY * DisableClientState) (GLenum array); - void (APIENTRY * EnableClientState) (GLenum array); - - void (APIENTRY * Fogf) (GLenum pname, GLfloat param); - void (APIENTRY * Fogi) (GLenum pname, GLint param); - void (APIENTRY * Fogfv) (GLenum pname, const GLfloat *params); - - void (APIENTRY * Enable) (GLenum cap); - GLboolean (APIENTRY * IsEnabled) (GLenum cap); - void (APIENTRY * Disable) (GLenum cap); - - void (APIENTRY * TexGeni) (GLenum coord, GLenum pname, GLint param); - void (APIENTRY * DeleteTextures) (GLsizei n, const GLuint *textures); - void (APIENTRY * GenTextures) (GLsizei n, GLuint *textures); - void (APIENTRY * BindTexture) (GLenum target, GLuint texture); - void (APIENTRY * TexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); - void (APIENTRY * TexParameterf) (GLenum target, GLenum pname, GLfloat param); - void (APIENTRY * TexParameteri) (GLenum target, GLenum pname, GLint param); - void (APIENTRY * CopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); - - void (APIENTRY * ReadPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); - void (APIENTRY * PolygonOffset) (GLfloat factor, GLfloat units); - void (APIENTRY * ClipPlane) (GLenum which, const GLdouble *); - - void (APIENTRY * Finish) (void); - void (APIENTRY * Flush) (void); // ARB_SHADER_OBJECTS PFNGLDELETESHADERPROC DeleteShader; diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 63ec45b43..d290fcc30 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -145,13 +145,13 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) wipestartscreen = new FHardwareTexture(Width, Height, false, false, false, true); wipestartscreen->CreateTexture(NULL, Width, Height, false, 0, CM_DEFAULT); - gl.Finish(); + glFinish(); wipestartscreen->Bind(0, CM_DEFAULT); - gl.CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); return true; } @@ -168,13 +168,13 @@ void OpenGLFrameBuffer::WipeEndScreen() { wipeendscreen = new FHardwareTexture(Width, Height, false, false, false, true); wipeendscreen->CreateTexture(NULL, Width, Height, false, 0, CM_DEFAULT); - gl.Flush(); + glFlush(); wipeendscreen->Bind(0, CM_DEFAULT); - gl.CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); Unlock(); } @@ -202,11 +202,11 @@ bool OpenGLFrameBuffer::WipeDo(int ticks) gl_RenderState.EnableTexture(true); gl_RenderState.EnableFog(false); - gl.Disable(GL_DEPTH_TEST); - gl.DepthMask(false); + glDisable(GL_DEPTH_TEST); + glDepthMask(false); bool done = ScreenWipe->Run(ticks, this); - gl.DepthMask(true); + glDepthMask(true); //DrawLetterbox(); return done; } @@ -280,30 +280,30 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.EnableAlphaTest(false); gl_RenderState.Apply(); fb->wipestartscreen->Bind(0, CM_DEFAULT); - gl.Color4f(1.f, 1.f, 1.f, 1.f); - gl.Begin(GL_TRIANGLE_STRIP); - gl.TexCoord2f(0, vb); - gl.Vertex2i(0, 0); - gl.TexCoord2f(0, 0); - gl.Vertex2i(0, fb->Height); - gl.TexCoord2f(ur, vb); - gl.Vertex2i(fb->Width, 0); - gl.TexCoord2f(ur, 0); - gl.Vertex2i(fb->Width, fb->Height); - gl.End(); + glColor4f(1.f, 1.f, 1.f, 1.f); + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(0, vb); + glVertex2i(0, 0); + glTexCoord2f(0, 0); + glVertex2i(0, fb->Height); + glTexCoord2f(ur, vb); + glVertex2i(fb->Width, 0); + glTexCoord2f(ur, 0); + glVertex2i(fb->Width, fb->Height); + glEnd(); fb->wipeendscreen->Bind(0, CM_DEFAULT); - gl.Color4f(1.f, 1.f, 1.f, clamp(Clock/32.f, 0.f, 1.f)); - gl.Begin(GL_TRIANGLE_STRIP); - gl.TexCoord2f(0, vb); - gl.Vertex2i(0, 0); - gl.TexCoord2f(0, 0); - gl.Vertex2i(0, fb->Height); - gl.TexCoord2f(ur, vb); - gl.Vertex2i(fb->Width, 0); - gl.TexCoord2f(ur, 0); - gl.Vertex2i(fb->Width, fb->Height); - gl.End(); + glColor4f(1.f, 1.f, 1.f, clamp(Clock/32.f, 0.f, 1.f)); + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(0, vb); + glVertex2i(0, 0); + glTexCoord2f(0, 0); + glVertex2i(0, fb->Height); + glTexCoord2f(ur, vb); + glVertex2i(fb->Width, 0); + glTexCoord2f(ur, 0); + glVertex2i(fb->Width, fb->Height); + glEnd(); gl_RenderState.EnableAlphaTest(true); gl_RenderState.SetTextureMode(TM_MODULATE); @@ -347,17 +347,17 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.SetTextureMode(TM_OPAQUE); gl_RenderState.Apply(); fb->wipeendscreen->Bind(0, CM_DEFAULT); - gl.Color4f(1.f, 1.f, 1.f, 1.f); - gl.Begin(GL_TRIANGLE_STRIP); - gl.TexCoord2f(0, vb); - gl.Vertex2i(0, 0); - gl.TexCoord2f(0, 0); - gl.Vertex2i(0, fb->Height); - gl.TexCoord2f(ur, vb); - gl.Vertex2i(fb->Width, 0); - gl.TexCoord2f(ur, 0); - gl.Vertex2i(fb->Width, fb->Height); - gl.End(); + glColor4f(1.f, 1.f, 1.f, 1.f); + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(0, vb); + glVertex2i(0, 0); + glTexCoord2f(0, 0); + glVertex2i(0, fb->Height); + glTexCoord2f(ur, vb); + glVertex2i(fb->Width, 0); + glTexCoord2f(ur, 0); + glVertex2i(fb->Width, fb->Height); + glEnd(); int i, dy; bool done = false; @@ -397,17 +397,17 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) float th = (float)FHardwareTexture::GetTexDimension(fb->Height); rect.bottom = fb->Height - rect.bottom; rect.top = fb->Height - rect.top; - gl.Color4f(1.f, 1.f, 1.f, 1.f); - gl.Begin(GL_TRIANGLE_STRIP); - gl.TexCoord2f(rect.left / tw, rect.top / th); - gl.Vertex2i(rect.left, rect.bottom); - gl.TexCoord2f(rect.left / tw, rect.bottom / th); - gl.Vertex2i(rect.left, rect.top); - gl.TexCoord2f(rect.right / tw, rect.top / th); - gl.Vertex2i(rect.right, rect.bottom); - gl.TexCoord2f(rect.right / tw, rect.bottom / th); - gl.Vertex2i(rect.right, rect.top); - gl.End(); + glColor4f(1.f, 1.f, 1.f, 1.f); + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(rect.left / tw, rect.top / th); + glVertex2i(rect.left, rect.bottom); + glTexCoord2f(rect.left / tw, rect.bottom / th); + glVertex2i(rect.left, rect.top); + glTexCoord2f(rect.right / tw, rect.top / th); + glVertex2i(rect.right, rect.bottom); + glTexCoord2f(rect.right / tw, rect.bottom / th); + glVertex2i(rect.right, rect.top); + glEnd(); } } } @@ -492,22 +492,22 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.EnableAlphaTest(false); gl_RenderState.Apply(); fb->wipestartscreen->Bind(0, CM_DEFAULT); - gl.Color4f(1.f, 1.f, 1.f, 1.f); - gl.Begin(GL_TRIANGLE_STRIP); - gl.TexCoord2f(0, vb); - gl.Vertex2i(0, 0); - gl.TexCoord2f(0, 0); - gl.Vertex2i(0, fb->Height); - gl.TexCoord2f(ur, vb); - gl.Vertex2i(fb->Width, 0); - gl.TexCoord2f(ur, 0); - gl.Vertex2i(fb->Width, fb->Height); - gl.End(); + glColor4f(1.f, 1.f, 1.f, 1.f); + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(0, vb); + glVertex2i(0, 0); + glTexCoord2f(0, 0); + glVertex2i(0, fb->Height); + glTexCoord2f(ur, vb); + glVertex2i(fb->Width, 0); + glTexCoord2f(ur, 0); + glVertex2i(fb->Width, fb->Height); + glEnd(); gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.Apply(true); gl.ActiveTexture(GL_TEXTURE1); - gl.Enable(GL_TEXTURE_2D); + glEnable(GL_TEXTURE_2D); // mask out the alpha channel of the wipeendscreen. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); @@ -521,35 +521,35 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) gl.ActiveTexture(GL_TEXTURE0); // Burn the new screen on top of it. - gl.Color4f(1.f, 1.f, 1.f, 1.f); + glColor4f(1.f, 1.f, 1.f, 1.f); fb->wipeendscreen->Bind(1, CM_DEFAULT); //BurnTexture->Bind(0, CM_DEFAULT); BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, false, 0, CM_DEFAULT); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - gl.Begin(GL_TRIANGLE_STRIP); + glBegin(GL_TRIANGLE_STRIP); gl.MultiTexCoord2f(GL_TEXTURE0, 0, 0); gl.MultiTexCoord2f(GL_TEXTURE1, 0, vb); - gl.Vertex2i(0, 0); + glVertex2i(0, 0); gl.MultiTexCoord2f(GL_TEXTURE0, 0, 1); gl.MultiTexCoord2f(GL_TEXTURE1, 0, 0); - gl.Vertex2i(0, fb->Height); + glVertex2i(0, fb->Height); gl.MultiTexCoord2f(GL_TEXTURE0, 1, 0); gl.MultiTexCoord2f(GL_TEXTURE1, ur, vb); - gl.Vertex2i(fb->Width, 0); + glVertex2i(fb->Width, 0); gl.MultiTexCoord2f(GL_TEXTURE0, 1, 1); gl.MultiTexCoord2f(GL_TEXTURE1, ur, 0); - gl.Vertex2i(fb->Width, fb->Height); - gl.End(); + glVertex2i(fb->Width, fb->Height); + glEnd(); gl.ActiveTexture(GL_TEXTURE1); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - gl.Disable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_2D); gl.ActiveTexture(GL_TEXTURE0); // The fire may not always stabilize, so the wipe is forced to end diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 0093729b2..eaf581be4 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -96,8 +96,8 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i if (alphatexture) texformat=GL_ALPHA8; else if (forcenocompression) texformat = GL_RGBA8; - if (glTexID==0) gl.GenTextures(1,&glTexID); - gl.BindTexture(GL_TEXTURE_2D, glTexID); + if (glTexID==0) glGenTextures(1,&glTexID); + glBindTexture(GL_TEXTURE_2D, glTexID); lastbound[texunit]=glTexID; if (!buffer) @@ -109,7 +109,7 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i // The texture must at least be initialized if no data is present. mipmap=false; - gl.TexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, false); + glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, false); buffer=(unsigned char *)calloc(4,rw * (rh+1)); deletebuffer=true; //texheight=-h; @@ -119,7 +119,7 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i rw = GetTexDimension (w); rh = GetTexDimension (h); - gl.TexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, (mipmap && use_mipmapping && !forcenofiltering)); + glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, (mipmap && use_mipmapping && !forcenofiltering)); if (rw == w && rh == h) { @@ -157,38 +157,38 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i } } } - gl.TexImage2D(GL_TEXTURE_2D, 0, texformat, rw, rh, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + glTexImage2D(GL_TEXTURE_2D, 0, texformat, rw, rh, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); if (deletebuffer) free(buffer); // When using separate samplers the stuff below is not needed. // if (gl.flags & RFL_SAMPLER_OBJECTS) return; - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); clampmode = wrapparam==GL_CLAMP? GLT_CLAMPX|GLT_CLAMPY : 0; if (forcenofiltering) { - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - gl.TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); } else { if (mipmap && use_mipmapping) { - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); if (gl_texture_filter_anisotropic) { - gl.TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); } } else { - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); } - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); } } @@ -230,7 +230,7 @@ void FHardwareTexture::DeleteTexture(unsigned int texid) lastbound[i] = 0; } } - gl.DeleteTextures(1, &texid); + glDeleteTextures(1, &texid); } } @@ -249,7 +249,7 @@ void FHardwareTexture::Clean(bool all) { DeleteTexture(glTexID[i]); } - //gl.DeleteTextures(cm_arraysize,glTexID); + //glDeleteTextures(cm_arraysize,glTexID); memset(glTexID,0,sizeof(unsigned int)*cm_arraysize); } else @@ -258,7 +258,7 @@ void FHardwareTexture::Clean(bool all) { DeleteTexture(glTexID[i]); } - //gl.DeleteTextures(cm_arraysize-1,glTexID+1); + //glDeleteTextures(cm_arraysize-1,glTexID+1); memset(glTexID+1,0,sizeof(unsigned int)*(cm_arraysize-1)); } for(unsigned int i=0;iBind(texunit, cm, translation)) { - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (clampmode & GLT_CLAMPX)? GL_CLAMP_TO_EDGE : GL_REPEAT); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (clampmode & GLT_CLAMPY)? GL_CLAMP_TO_EDGE : GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (clampmode & GLT_CLAMPX)? GL_CLAMP_TO_EDGE : GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (clampmode & GLT_CLAMPY)? GL_CLAMP_TO_EDGE : GL_REPEAT); } } else @@ -446,8 +446,8 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int cm, int clampmode, int delete[] buffer; return NULL; } - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (clampmode & GLT_CLAMPX)? GL_CLAMP_TO_EDGE : GL_REPEAT); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (clampmode & GLT_CLAMPY)? GL_CLAMP_TO_EDGE : GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (clampmode & GLT_CLAMPX)? GL_CLAMP_TO_EDGE : GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (clampmode & GLT_CLAMPY)? GL_CLAMP_TO_EDGE : GL_REPEAT); delete[] buffer; } @@ -502,8 +502,8 @@ const FHardwareTexture * FGLTexture::BindPatch(int texunit, int cm, int translat return NULL; } delete[] buffer; - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } return glpatch; } From 2885056f46eefd70fd3f67455249dff37bee8f50 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 Sep 2013 18:29:39 +0200 Subject: [PATCH 0028/1509] - moved GLEXT API out of RenderContext struct. --- gzdoom.vcproj | 8 ++ src/CMakeLists.txt | 1 + src/gl/api/gl_api.cpp | 4 + src/gl/api/gl_api.h | 100 ++++++++++++++++ src/gl/data/gl_data.cpp | 1 + src/gl/data/gl_vertexbuffer.cpp | 23 ++-- src/gl/dynlights/gl_dynlight1.cpp | 1 + src/gl/dynlights/gl_lightbuffer.cpp | 46 ++++---- src/gl/models/gl_models.cpp | 9 +- src/gl/models/gl_voxels.cpp | 19 +-- src/gl/renderer/gl_lightdata.cpp | 7 +- src/gl/renderer/gl_renderer.cpp | 9 +- src/gl/renderer/gl_renderstate.cpp | 23 ++-- src/gl/renderer/gl_renderstate.h | 2 +- src/gl/scene/gl_decal.cpp | 4 +- src/gl/scene/gl_flats.cpp | 1 + src/gl/scene/gl_portal.cpp | 9 +- src/gl/scene/gl_scene.cpp | 7 +- src/gl/scene/gl_skydome.cpp | 1 + src/gl/scene/gl_sprite.cpp | 1 + src/gl/scene/gl_spritelight.cpp | 2 +- src/gl/scene/gl_vertex.cpp | 8 +- src/gl/scene/gl_walls_draw.cpp | 11 +- src/gl/scene/gl_weapon.cpp | 1 + src/gl/shaders/gl_shader.cpp | 87 +++++++------- src/gl/system/gl_framebuffer.cpp | Bin 30486 -> 30560 bytes src/gl/system/gl_interface.cpp | 177 ++++++++++++++-------------- src/gl/system/gl_interface.h | 106 +---------------- src/gl/system/gl_menu.cpp | 1 + src/gl/system/gl_system.h | 3 +- src/gl/system/gl_wipe.cpp | 25 ++-- src/gl/textures/gl_hqresize.cpp | 1 + src/gl/textures/gl_hwtexture.cpp | 27 +++-- src/gl/textures/gl_material.cpp | 1 + src/gl/textures/gl_texture.cpp | 1 + 35 files changed, 379 insertions(+), 348 deletions(-) create mode 100644 src/gl/api/gl_api.cpp create mode 100644 src/gl/api/gl_api.h diff --git a/gzdoom.vcproj b/gzdoom.vcproj index b7e52df62..b24dfce18 100644 --- a/gzdoom.vcproj +++ b/gzdoom.vcproj @@ -3601,6 +3601,14 @@ + + + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e89d1f75f..1189b96c3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -886,6 +886,7 @@ add_executable( zdoom WIN32 menu/playermenu.cpp menu/readthis.cpp menu/videomenu.cpp + gl/api/gl_api.cpp gl/data/gl_sections.cpp gl/data/gl_data.cpp gl/data/gl_portaldata.cpp diff --git a/src/gl/api/gl_api.cpp b/src/gl/api/gl_api.cpp new file mode 100644 index 000000000..67a3fb3e5 --- /dev/null +++ b/src/gl/api/gl_api.cpp @@ -0,0 +1,4 @@ +#include "gl/system/gl_system.h" + +#define __EXTERN +#include "gl_api.h" diff --git a/src/gl/api/gl_api.h b/src/gl/api/gl_api.h new file mode 100644 index 000000000..bcb03c416 --- /dev/null +++ b/src/gl/api/gl_api.h @@ -0,0 +1,100 @@ +#if defined(__APPLE__) +#define APIENTRY +#define APIENTRYP * +#endif // __APPLE__ + +#ifndef __EXTERN +#define __EXTERN extern +#endif + +__EXTERN PFNGLBLENDEQUATIONPROC glBlendEquation; + +// ARB_SHADER_OBJECTS +__EXTERN PFNGLDELETESHADERPROC glDeleteShader; +__EXTERN PFNGLDELETEPROGRAMPROC glDeleteProgram; +__EXTERN PFNGLDETACHSHADERPROC glDetachShader; +__EXTERN PFNGLCREATESHADERPROC glCreateShader; +__EXTERN PFNGLSHADERSOURCEPROC glShaderSource; +__EXTERN PFNGLCOMPILESHADERPROC glCompileShader; +__EXTERN PFNGLCREATEPROGRAMPROC glCreateProgram; +__EXTERN PFNGLATTACHSHADERPROC glAttachShader; +__EXTERN PFNGLLINKPROGRAMPROC glLinkProgram; +__EXTERN PFNGLUSEPROGRAMPROC glUseProgram; +__EXTERN PFNGLVALIDATEPROGRAMPROC glValidateProgram; +__EXTERN PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f; +__EXTERN PFNGLVERTEXATTRIB2FPROC glVertexAttrib2f; +__EXTERN PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f; +__EXTERN PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv; +__EXTERN PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv; +__EXTERN PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv; +__EXTERN PFNGLVERTEXATTRIB4UBVPROC glVertexAttrib4ubv; +__EXTERN PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; +__EXTERN PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation; + +__EXTERN PFNGLUNIFORM1FPROC glUniform1f; +__EXTERN PFNGLUNIFORM2FPROC glUniform2f; +__EXTERN PFNGLUNIFORM3FPROC glUniform3f; +__EXTERN PFNGLUNIFORM4FPROC glUniform4f; +__EXTERN PFNGLUNIFORM1IPROC glUniform1i; +__EXTERN PFNGLUNIFORM2IPROC glUniform2i; +__EXTERN PFNGLUNIFORM3IPROC glUniform3i; +__EXTERN PFNGLUNIFORM4IPROC glUniform4i; +__EXTERN PFNGLUNIFORM1FVPROC glUniform1fv; +__EXTERN PFNGLUNIFORM2FVPROC glUniform2fv; +__EXTERN PFNGLUNIFORM3FVPROC glUniform3fv; +__EXTERN PFNGLUNIFORM4FVPROC glUniform4fv; +__EXTERN PFNGLUNIFORM1IVPROC glUniform1iv; +__EXTERN PFNGLUNIFORM2IVPROC glUniform2iv; +__EXTERN PFNGLUNIFORM3IVPROC glUniform3iv; +__EXTERN PFNGLUNIFORM4IVPROC glUniform4iv; + +__EXTERN PFNGLUNIFORMMATRIX2FVPROC glUniformMatrix2fv; +__EXTERN PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv; +__EXTERN PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; + +__EXTERN PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; +__EXTERN PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; +__EXTERN PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; +__EXTERN PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform; +__EXTERN PFNGLGETUNIFORMFVPROC glGetUniformfv; +__EXTERN PFNGLGETUNIFORMIVPROC glGetUniformiv; +__EXTERN PFNGLGETSHADERSOURCEPROC glGetShaderSource; +__EXTERN PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameteriv; + +__EXTERN PFNGLGENQUERIESARBPROC glGenQueries; +__EXTERN PFNGLDELETEQUERIESARBPROC glDeleteQueries; +__EXTERN PFNGLBEGINQUERYARBPROC glBeginQuery; +__EXTERN PFNGLENDQUERYARBPROC glEndQuery; +__EXTERN PFNGLGETQUERYOBJECTUIVARBPROC glGetQueryObjectuiv; + +__EXTERN PFNGLACTIVETEXTUREPROC glActiveTexture; +__EXTERN PFNGLMULTITEXCOORD2FPROC glMultiTexCoord2f; +__EXTERN PFNGLMULTITEXCOORD2FVPROC glMultiTexCoord2fv; + +__EXTERN PFNGLBINDBUFFERPROC glBindBuffer; +__EXTERN PFNGLDELETEBUFFERSPROC glDeleteBuffers; +__EXTERN PFNGLGENBUFFERSPROC glGenBuffers; +__EXTERN PFNGLBUFFERDATAPROC glBufferData; +__EXTERN PFNGLBUFFERSUBDATAPROC glBufferSubData; +__EXTERN PFNGLMAPBUFFERPROC glMapBuffer; +__EXTERN PFNGLUNMAPBUFFERPROC glUnmapBuffer; +__EXTERN PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; +__EXTERN PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; +__EXTERN PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; + +__EXTERN PFNGLMAPBUFFERRANGEPROC glMapBufferRange; +__EXTERN PFNGLFLUSHMAPPEDBUFFERRANGEPROC glFlushMappedBufferRange; + +__EXTERN PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; +__EXTERN PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; +__EXTERN PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; +__EXTERN PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; +__EXTERN PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; +__EXTERN PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; +__EXTERN PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; +__EXTERN PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; +__EXTERN PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; + +__EXTERN PFNGLTEXBUFFERARBPROC glTexBufferARB; + +#undef __EXTERN diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 5a2508968..20ec8a3a7 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -52,6 +52,7 @@ #include "gi.h" #include "g_level.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" #include "gl/data/gl_data.h" diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 5c43c256c..cda619ce1 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -43,6 +43,7 @@ #include "p_local.h" #include "m_argv.h" #include "c_cvars.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" @@ -77,7 +78,7 @@ FVertexBuffer::FVertexBuffer() if (gl.flags&RFL_VBO) { if (gl_usevbo == -1) gl_usevbo.Callback(); - gl.GenBuffers(1, &vbo_id); + glGenBuffers(1, &vbo_id); } } @@ -85,7 +86,7 @@ FVertexBuffer::~FVertexBuffer() { if (vbo_id != 0) { - gl.DeleteBuffers(1, &vbo_id); + glDeleteBuffers(1, &vbo_id); } } @@ -273,8 +274,8 @@ void FFlatVertexBuffer::MapVBO() { if (map == NULL) { - gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); - map = (FFlatVertex*)gl.MapBufferRange(GL_ARRAY_BUFFER, 0, vbo_shadowdata.Size() * sizeof(FFlatVertex), + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, vbo_shadowdata.Size() * sizeof(FFlatVertex), GL_MAP_WRITE_BIT|GL_MAP_FLUSH_EXPLICIT_BIT|GL_MAP_UNSYNCHRONIZED_BIT); } } @@ -289,7 +290,7 @@ void FFlatVertexBuffer::UnmapVBO() { if (map != NULL) { - gl.UnmapBuffer(GL_ARRAY_BUFFER); + glUnmapBuffer(GL_ARRAY_BUFFER); map = NULL; } } @@ -316,11 +317,11 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) MapVBO(); if (map == NULL) return; // Error memcpy(&map[startvt], &vbo_shadowdata[startvt], countvt * sizeof(FFlatVertex)); - gl.FlushMappedBufferRange(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex)); + glFlushMappedBufferRange(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex)); } else { - gl.BufferSubData(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex), &vbo_shadowdata[startvt]); + glBufferSubData(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex), &vbo_shadowdata[startvt]); } } @@ -336,8 +337,8 @@ void FFlatVertexBuffer::CreateVBO() if (vbo_arg > 0) { CreateFlatVBO(); - gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); - gl.BufferData(GL_ARRAY_BUFFER, vbo_shadowdata.Size() * sizeof(FFlatVertex), &vbo_shadowdata[0], GL_DYNAMIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferData(GL_ARRAY_BUFFER, vbo_shadowdata.Size() * sizeof(FFlatVertex), &vbo_shadowdata[0], GL_DYNAMIC_DRAW); } else if (sectors) { @@ -362,8 +363,8 @@ void FFlatVertexBuffer::BindVBO() if (vbo_arg > 0) { UnmapVBO(); - gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); - gl.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glVertexPointer(3,GL_FLOAT, sizeof(FFlatVertex), &VTO->x); glTexCoordPointer(2,GL_FLOAT, sizeof(FFlatVertex), &VTO->u); glEnableClientState(GL_VERTEX_ARRAY); diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index 386590f61..af2a9f7c6 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -45,6 +45,7 @@ #include "gl/gl_functions.h" #include "g_level.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" #include "gl/data/gl_data.h" diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index 6280f650b..9f141e6af 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -66,11 +66,11 @@ FLightBuffer::FLightBuffer() { - gl.GenBuffers(1, &mIDbuf_RGB); - gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB); + glGenBuffers(1, &mIDbuf_RGB); + glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB); - gl.GenBuffers(1, &mIDbuf_Position); - gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); + glGenBuffers(1, &mIDbuf_Position); + glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); glGenTextures(1, &mIDtex_RGB); glBindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB); @@ -90,9 +90,9 @@ FLightBuffer::FLightBuffer() FLightBuffer::~FLightBuffer() { - gl.BindBuffer(GL_TEXTURE_BUFFER, 0); - gl.DeleteBuffers(1, &mIDbuf_RGB); - gl.DeleteBuffers(1, &mIDbuf_Position); + glBindBuffer(GL_TEXTURE_BUFFER, 0); + glDeleteBuffers(1, &mIDbuf_RGB); + glDeleteBuffers(1, &mIDbuf_Position); glBindTexture(GL_TEXTURE_BUFFER, 0); glDeleteTextures(1, &mIDtex_RGB); @@ -108,11 +108,11 @@ FLightBuffer::~FLightBuffer() void FLightBuffer::BindTextures(int texunit1, int texunit2) { - gl.ActiveTexture(texunit1); + glActiveTexture(texunit1); glBindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB); - gl.ActiveTexture(texunit2); + glActiveTexture(texunit2); glBindTexture(GL_TEXTURE_BUFFER, mIDtex_Position); - gl.ActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); } @@ -155,11 +155,11 @@ void FLightBuffer::CollectLightSources() } GLRenderer->mLightCount = pPos.Size(); - gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB); - gl.BufferData(GL_TEXTURE_BUFFER, pLights.Size() * sizeof (FLightRGB), &pLights[0], GL_STREAM_DRAW); + glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB); + glBufferData(GL_TEXTURE_BUFFER, pLights.Size() * sizeof (FLightRGB), &pLights[0], GL_STREAM_DRAW); - gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); - gl.BufferData(GL_TEXTURE_BUFFER, pPos.Size() * sizeof (FLightPosition), &pPos[0], GL_STREAM_DRAW); + glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); + glBufferData(GL_TEXTURE_BUFFER, pPos.Size() * sizeof (FLightPosition), &pPos[0], GL_STREAM_DRAW); } } @@ -173,8 +173,8 @@ void FLightBuffer::CollectLightSources() FLightIndexBuffer::FLightIndexBuffer() { - gl.GenBuffers(1, &mIDBuffer); - gl.BindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); + glGenBuffers(1, &mIDBuffer); + glBindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); glGenTextures(1, &mIDTexture); glBindTexture(GL_TEXTURE_BUFFER, mIDTexture); @@ -189,8 +189,8 @@ FLightIndexBuffer::FLightIndexBuffer() FLightIndexBuffer::~FLightIndexBuffer() { - gl.BindBuffer(GL_TEXTURE_BUFFER, 0); - gl.DeleteBuffers(1, &mIDBuffer); + glBindBuffer(GL_TEXTURE_BUFFER, 0); + glDeleteBuffers(1, &mIDBuffer); glBindTexture(GL_TEXTURE_BUFFER, 0); glDeleteTextures(1, &mIDTexture); @@ -219,9 +219,9 @@ void FLightIndexBuffer::AddLight(ADynamicLight *light) void FLightIndexBuffer::SendBuffer() { - gl.BindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); - gl.BufferData(GL_TEXTURE_BUFFER, mBuffer.Size() * sizeof (short), &mBuffer[0], GL_STREAM_DRAW); - gl.BindBuffer(GL_TEXTURE_BUFFER, 0); + glBindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); + glBufferData(GL_TEXTURE_BUFFER, mBuffer.Size() * sizeof (short), &mBuffer[0], GL_STREAM_DRAW); + glBindBuffer(GL_TEXTURE_BUFFER, 0); } @@ -233,9 +233,9 @@ void FLightIndexBuffer::SendBuffer() void FLightIndexBuffer::BindTexture(int texunit1) { - gl.ActiveTexture(texunit1); + glActiveTexture(texunit1); glBindTexture(GL_TEXTURE_BUFFER, mIDTexture); - gl.ActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); } diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 3a89bcbbc..a59666d04 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -51,6 +51,7 @@ //#include "resources/voxels.h" //#include "gl/gl_intern.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/models/gl_models.h" @@ -759,7 +760,7 @@ void gl_RenderModel(GLSprite * spr, int cm) } else { - gl.ActiveTexture(GL_TEXTURE7); // Hijack the otherwise unused seventh texture matrix for the model to world transformation. + glActiveTexture(GL_TEXTURE7); // Hijack the otherwise unused seventh texture matrix for the model to world transformation. glMatrixMode(GL_TEXTURE); glLoadIdentity(); } @@ -794,7 +795,7 @@ void gl_RenderModel(GLSprite * spr, int cm) glRotatef(smf->pitchoffset, 0, 0, 1); glRotatef(-smf->rolloffset, 1, 0, 0); - if (gl.shadermodel >= 4) gl.ActiveTexture(GL_TEXTURE0); + if (gl.shadermodel >= 4) glActiveTexture(GL_TEXTURE0); #if 0 if (gl_light_models) @@ -820,10 +821,10 @@ void gl_RenderModel(GLSprite * spr, int cm) } else { - gl.ActiveTexture(GL_TEXTURE7); + glActiveTexture(GL_TEXTURE7); glMatrixMode(GL_TEXTURE); glLoadIdentity(); - gl.ActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); glMatrixMode(GL_MODELVIEW); } diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index c13ddda5f..e81c6531c 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -49,6 +49,7 @@ #include "textures/bitmap.h" //#include "gl/gl_intern.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_drawinfo.h" @@ -189,14 +190,14 @@ FVoxelVertexBuffer::FVoxelVertexBuffer(TArray &verts, TArray 65535) { - gl.BufferData(GL_ELEMENT_ARRAY_BUFFER, indices.Size() * sizeof(unsigned int), &indices[0], GL_STATIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.Size() * sizeof(unsigned int), &indices[0], GL_STATIC_DRAW); isint = true; } else @@ -206,7 +207,7 @@ FVoxelVertexBuffer::FVoxelVertexBuffer(TArray &verts, TArrayx); glTexCoordPointer(2,GL_FLOAT, sizeof(FVoxelVertex), &VVO->u); glEnableClientState(GL_VERTEX_ARRAY); diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 5be90d3cf..88d24cc02 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -40,6 +40,7 @@ #include "gl/system/gl_system.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #include "gl/data/gl_data.h" #include "gl/renderer/gl_colormap.h" @@ -339,12 +340,12 @@ void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, Pal if (gl_fixedcolormap) { - gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); + glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); } else { float lightlevel = gl_CalcLightLevel(light, rellight, weapon) / 255.0f; - gl.VertexAttrib1f(VATTR_LIGHTLEVEL, lightlevel); + glVertexAttrib1f(VATTR_LIGHTLEVEL, lightlevel); } } } @@ -611,7 +612,7 @@ void gl_SetFog(int lightlevel, int rellight, const FColormap *cmap, bool isaddit // Korshun: fullbright fog like in software renderer. if (glset.brightfog && fogdensity != 0 && fogcolor != 0) - gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); + glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); } } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index b1ef3244f..3ce805351 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -50,6 +50,7 @@ #include "gl/gl_functions.h" #include "vectors.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_threads.h" #include "gl/renderer/gl_renderer.h" @@ -123,7 +124,7 @@ FGLRenderer::~FGLRenderer() if (glpart) delete glpart; if (mirrortexture) delete mirrortexture; if (gllight) delete gllight; - if (mFBID != 0) gl.DeleteFramebuffers(1, &mFBID); + if (mFBID != 0) glDeleteFramebuffers(1, &mFBID); } //=========================================================================== @@ -213,8 +214,8 @@ bool FGLRenderer::StartOffscreen() { if (gl.flags & RFL_FRAMEBUFFER) { - if (mFBID == 0) gl.GenFramebuffers(1, &mFBID); - gl.BindFramebuffer(GL_FRAMEBUFFER, mFBID); + if (mFBID == 0) glGenFramebuffers(1, &mFBID); + glBindFramebuffer(GL_FRAMEBUFFER, mFBID); return true; } return false; @@ -230,7 +231,7 @@ void FGLRenderer::EndOffscreen() { if (gl.flags & RFL_FRAMEBUFFER) { - gl.BindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); } } diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 7f7a2df67..19af11168 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -39,6 +39,7 @@ */ #include "gl/system/gl_system.h" +#include "gl/system/gl_interface.h" #include "gl/data/gl_data.h" #include "gl/system/gl_cvars.h" #include "gl/shaders/gl_shader.h" @@ -203,15 +204,15 @@ bool FRenderState::ApplyShader() if (fogset != activeShader->currentfogenabled) { - gl.Uniform1i(activeShader->fogenabled_index, (activeShader->currentfogenabled = fogset)); + glUniform1i(activeShader->fogenabled_index, (activeShader->currentfogenabled = fogset)); } if (mTextureMode != activeShader->currenttexturemode) { - gl.Uniform1i(activeShader->texturemode_index, (activeShader->currenttexturemode = mTextureMode)); + glUniform1i(activeShader->texturemode_index, (activeShader->currenttexturemode = mTextureMode)); } if (activeShader->currentcamerapos.Update(&mCameraPos)) { - gl.Uniform3fv(activeShader->camerapos_index, 1, mCameraPos.vec); + glUniform3fv(activeShader->camerapos_index, 1, mCameraPos.vec); } /*if (mLightParms[0] != activeShader->currentlightfactor || mLightParms[1] != activeShader->currentlightdist || @@ -223,28 +224,28 @@ bool FRenderState::ApplyShader() //activeShader->currentfogdensity = mFogDensity; // premultiply the density with as much as possible here to reduce shader // execution time. - gl.VertexAttrib4f(VATTR_FOGPARAMS, mLightParms[0], mLightParms[1], mFogDensity * (-LOG2E / 64000.f), 0); + glVertexAttrib4f(VATTR_FOGPARAMS, mLightParms[0], mLightParms[1], mFogDensity * (-LOG2E / 64000.f), 0); } if (mFogColor != activeShader->currentfogcolor) { activeShader->currentfogcolor = mFogColor; - gl.Uniform4f (activeShader->fogcolor_index, mFogColor.r/255.f, mFogColor.g/255.f, + glUniform4f (activeShader->fogcolor_index, mFogColor.r/255.f, mFogColor.g/255.f, mFogColor.b/255.f, 0); } if (mGlowEnabled) { - gl.Uniform4fv(activeShader->glowtopcolor_index, 1, mGlowTop.vec); - gl.Uniform4fv(activeShader->glowbottomcolor_index, 1, mGlowBottom.vec); + glUniform4fv(activeShader->glowtopcolor_index, 1, mGlowTop.vec); + glUniform4fv(activeShader->glowbottomcolor_index, 1, mGlowBottom.vec); } if (mLightEnabled) { - gl.Uniform3iv(activeShader->lightrange_index, 1, mNumLights); - gl.Uniform4fv(activeShader->lights_index, mNumLights[2], mLightData); + glUniform3iv(activeShader->lightrange_index, 1, mNumLights); + glUniform4fv(activeShader->lights_index, mNumLights[2], mLightData); } if (glset.lightmode == 8) { - gl.Uniform3fv(activeShader->dlightcolor_index, 1, mDynLight); + glUniform3fv(activeShader->dlightcolor_index, 1, mDynLight); } return true; @@ -284,7 +285,7 @@ void FRenderState::Apply(bool forcenoshader) if (mBlendEquation != glBlendEquation) { glBlendEquation = mBlendEquation; - gl.BlendEquation(mBlendEquation); + ::glBlendEquation(mBlendEquation); } } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index e8a4d1940..dd348ad8c 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -263,7 +263,7 @@ public: } else { - gl.BlendEquation(eq); + ::glBlendEquation(eq); } } diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 6bb109fa4..bd39f8008 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -368,9 +368,9 @@ void GLWall::DrawDecal(DBaseDecal *decal) if (glset.lightmode == 8) { if (gl_fixedcolormap) - gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); + glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); else - gl.VertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(light, rel, false) / 255.0); + glVertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(light, rel, false) / 255.0); } } else diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 309d5cdfb..441c8b73f 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -47,6 +47,7 @@ #include "doomstat.h" #include "d_player.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index b0ee96d88..31b6149d2 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -46,6 +46,7 @@ #include "doomstat.h" #include "a_sharedglobal.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" @@ -199,10 +200,10 @@ bool GLPortal::Start(bool usestencil, bool doquery) // If occlusion query is supported let's use it to avoid rendering portals that aren't visible if (doquery && gl.flags&RFL_OCCLUSION_QUERY) { - if (!QueryObject) gl.GenQueries(1, &QueryObject); + if (!QueryObject) glGenQueries(1, &QueryObject); if (QueryObject) { - gl.BeginQuery(GL_SAMPLES_PASSED_ARB, QueryObject); + glBeginQuery(GL_SAMPLES_PASSED_ARB, QueryObject); } else doquery = false; // some kind of error happened @@ -212,7 +213,7 @@ bool GLPortal::Start(bool usestencil, bool doquery) if (doquery && gl.flags&RFL_OCCLUSION_QUERY) { - gl.EndQuery(GL_SAMPLES_PASSED_ARB); + glEndQuery(GL_SAMPLES_PASSED_ARB); } // Clear Z-buffer @@ -233,7 +234,7 @@ bool GLPortal::Start(bool usestencil, bool doquery) { GLuint sampleCount; - gl.GetQueryObjectuiv(QueryObject, GL_QUERY_RESULT_ARB, &sampleCount); + glGetQueryObjectuiv(QueryObject, GL_QUERY_RESULT_ARB, &sampleCount); if (sampleCount==0) // not visible { diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 93c8dbbf8..6434e848a 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -57,6 +57,7 @@ #include "p_local.h" #include "gl/gl_functions.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" @@ -266,11 +267,11 @@ void FGLRenderer::SetViewMatrix(bool mirror, bool planemirror) { if (gl.shadermodel >= 4) { - gl.ActiveTexture(GL_TEXTURE7); + glActiveTexture(GL_TEXTURE7); glMatrixMode(GL_TEXTURE); glLoadIdentity(); } - gl.ActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); glMatrixMode(GL_TEXTURE); glLoadIdentity(); @@ -441,7 +442,7 @@ void FGLRenderer::RenderScene(int recursion) { gl_RenderState.BlendFunc(GL_ONE, GL_ONE); glDepthFunc(GL_EQUAL); - if (glset.lightmode == 8) gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0f); // Korshun. + if (glset.lightmode == 8) glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0f); // Korshun. for(int i=GLDL_FIRSTLIGHT; i<=GLDL_LASTLIGHT; i++) { gl_drawinfo->drawlists[i].Draw(GLPASS_LIGHT); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 41182cfb4..dee3ea4e3 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -43,6 +43,7 @@ #include "r_state.h" //#include "gl/gl_intern.h" +#include "gl/system/gl_interface.h" #include "gl/data/gl_data.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 40b55dfef..208507c84 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -47,6 +47,7 @@ #include "r_sky.h" #include "r_utility.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index cdbf1950c..d630ddbc2 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -159,7 +159,7 @@ static int gl_SetSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subs glColor4f(r, g, b, alpha); if (glset.lightmode == 8) { - gl.VertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(lightlevel, rellight, weapon) / 255.0f); // Korshun. + glVertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(lightlevel, rellight, weapon) / 255.0f); // Korshun. gl_RenderState.SetDynLight(result[0], result[1], result[2]); } return lightlevel; diff --git a/src/gl/scene/gl_vertex.cpp b/src/gl/scene/gl_vertex.cpp index a11b06fde..4df381311 100644 --- a/src/gl/scene/gl_vertex.cpp +++ b/src/gl/scene/gl_vertex.cpp @@ -82,7 +82,7 @@ void GLWall::SplitUpperEdge(texcoord * tcs, bool glow) float fracfac = sidefrac - glseg.fracleft; - if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - ztop[0] + (facc - fact) * fracfac, + if (glow) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - ztop[0] + (facc - fact) * fracfac, ztop[0] - zfloor[0] + (fact - facf) * fracfac); glTexCoord2f(tcs[1].u + facu * fracfac, tcs[1].v + facv * fracfac); @@ -118,7 +118,7 @@ void GLWall::SplitLowerEdge(texcoord * tcs, bool glow) float fracfac = sidefrac - glseg.fracleft; - if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - zbottom[0] + (facc - facb) * fracfac, + if (glow) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - zbottom[0] + (facc - facb) * fracfac, zbottom[0] - zfloor[0] + (facb - facf) * fracfac); glTexCoord2f(tcs[0].u + facu * fracfac, tcs[0].v + facv * fracfac); @@ -150,7 +150,7 @@ void GLWall::SplitLeftEdge(texcoord * tcs, bool glow) while (inumheights && vi->heightlist[i] <= zbottom[0] ) i++; while (inumheights && vi->heightlist[i] < ztop[0]) { - if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - vi->heightlist[i], vi->heightlist[i] - zfloor[0]); + if (glow) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - vi->heightlist[i], vi->heightlist[i] - zfloor[0]); glTexCoord2f(factu1*(vi->heightlist[i] - ztop[0]) + tcs[1].u, factv1*(vi->heightlist[i] - ztop[0]) + tcs[1].v); glVertex3f(glseg.x1, vi->heightlist[i], glseg.y1); @@ -183,7 +183,7 @@ void GLWall::SplitRightEdge(texcoord * tcs, bool glow) while (i>0 && vi->heightlist[i] >= ztop[1]) i--; while (i>0 && vi->heightlist[i] > zbottom[1]) { - if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - vi->heightlist[i], vi->heightlist[i] - zfloor[1]); + if (glow) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - vi->heightlist[i], vi->heightlist[i] - zfloor[1]); glTexCoord2f(factu2 * (vi->heightlist[i] - ztop[1]) + tcs[2].u, factv2 * (vi->heightlist[i] - ztop[1]) + tcs[2].v); glVertex3f(glseg.x2, vi->heightlist[i], glseg.y2); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index fbd881982..d97475029 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -44,6 +44,7 @@ #include "a_sharedglobal.h" #include "gl/gl_functions.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" @@ -248,14 +249,14 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) glBegin(GL_TRIANGLE_FAN); // lower left corner - if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - zbottom[0], zbottom[0] - zfloor[0]); + if (glowing) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - zbottom[0], zbottom[0] - zfloor[0]); if (textured&1) glTexCoord2f(tcs[0].u,tcs[0].v); glVertex3f(glseg.x1,zbottom[0],glseg.y1); if (split && glseg.fracleft==0) SplitLeftEdge(tcs, glowing); // upper left corner - if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - ztop[0], ztop[0] - zfloor[0]); + if (glowing) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - ztop[0], ztop[0] - zfloor[0]); if (textured&1) glTexCoord2f(tcs[1].u,tcs[1].v); glVertex3f(glseg.x1,ztop[0],glseg.y1); @@ -265,14 +266,14 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) if (color2) glColor4fv(color2); // upper right corner - if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - ztop[1], ztop[1] - zfloor[1]); + if (glowing) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - ztop[1], ztop[1] - zfloor[1]); if (textured&1) glTexCoord2f(tcs[2].u,tcs[2].v); glVertex3f(glseg.x2,ztop[1],glseg.y2); if (split && glseg.fracright==1) SplitRightEdge(tcs, glowing); // lower right corner - if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - zbottom[1], zbottom[1] - zfloor[1]); + if (glowing) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - zbottom[1], zbottom[1] - zfloor[1]); if (textured&1) glTexCoord2f(tcs[3].u,tcs[3].v); glVertex3f(glseg.x2,zbottom[1],glseg.y2); @@ -330,7 +331,7 @@ void GLWall::RenderFogBoundary() gl_RenderState.AlphaFunc(GL_GREATER,0); glDepthFunc(GL_LEQUAL); glColor4f(fc[0],fc[1],fc[2], fogd1); - if (glset.lightmode == 8) gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); // Korshun. + if (glset.lightmode == 8) glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); // Korshun. flags &= ~GLWF_GLOW; RenderWall(4,fc); diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 83cdf67f6..61289f48b 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -45,6 +45,7 @@ #include "d_player.h" #include "g_level.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 4a3c7ca94..30e3318f3 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -49,6 +49,7 @@ #include "sc_man.h" #include "cmdlib.h" +#include "gl/system/gl_interface.h" #include "gl/data/gl_data.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderstate.h" @@ -119,8 +120,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * } } - hVertProg = gl.CreateShader(GL_VERTEX_SHADER); - hFragProg = gl.CreateShader(GL_FRAGMENT_SHADER); + hVertProg = glCreateShader(GL_VERTEX_SHADER); + hFragProg = glCreateShader(GL_FRAGMENT_SHADER); int vp_size = (int)vp_comb.Len(); @@ -129,68 +130,68 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * const char *vp_ptr = vp_comb.GetChars(); const char *fp_ptr = fp_comb.GetChars(); - gl.ShaderSource(hVertProg, 1, &vp_ptr, &vp_size); - gl.ShaderSource(hFragProg, 1, &fp_ptr, &fp_size); + glShaderSource(hVertProg, 1, &vp_ptr, &vp_size); + glShaderSource(hFragProg, 1, &fp_ptr, &fp_size); - gl.CompileShader(hVertProg); - gl.CompileShader(hFragProg); + glCompileShader(hVertProg); + glCompileShader(hFragProg); - hShader = gl.CreateProgram(); + hShader = glCreateProgram(); - gl.AttachShader(hShader, hVertProg); - gl.AttachShader(hShader, hFragProg); + glAttachShader(hShader, hVertProg); + glAttachShader(hShader, hFragProg); - gl.BindAttribLocation(hShader, VATTR_GLOWDISTANCE, "glowdistance"); - gl.BindAttribLocation(hShader, VATTR_FOGPARAMS, "fogparams"); - gl.BindAttribLocation(hShader, VATTR_LIGHTLEVEL, "lightlevel_in"); // Korshun. + glBindAttribLocation(hShader, VATTR_GLOWDISTANCE, "glowdistance"); + glBindAttribLocation(hShader, VATTR_FOGPARAMS, "fogparams"); + glBindAttribLocation(hShader, VATTR_LIGHTLEVEL, "lightlevel_in"); // Korshun. - gl.LinkProgram(hShader); + glLinkProgram(hShader); - gl.GetShaderInfoLog(hVertProg, 10000, NULL, buffer); + glGetShaderInfoLog(hVertProg, 10000, NULL, buffer); if (*buffer) { error << "Vertex shader:\n" << buffer << "\n"; } - gl.GetShaderInfoLog(hFragProg, 10000, NULL, buffer); + glGetShaderInfoLog(hFragProg, 10000, NULL, buffer); if (*buffer) { error << "Vertex shader:\n" << buffer << "\n"; } - gl.GetProgramInfoLog(hShader, 10000, NULL, buffer); + glGetProgramInfoLog(hShader, 10000, NULL, buffer); if (*buffer) { error << "Linking:\n" << buffer << "\n"; } int linked; - gl.GetObjectParameteriv(hShader, GL_LINK_STATUS, &linked); + glGetObjectParameteriv(hShader, GL_LINK_STATUS, &linked); if (linked == 0) { // only print message if there's an error. Printf("Init Shader '%s':\n%s\n", name, error.GetChars()); } - timer_index = gl.GetUniformLocation(hShader, "timer"); - desaturation_index = gl.GetUniformLocation(hShader, "desaturation_factor"); - fogenabled_index = gl.GetUniformLocation(hShader, "fogenabled"); - texturemode_index = gl.GetUniformLocation(hShader, "texturemode"); - camerapos_index = gl.GetUniformLocation(hShader, "camerapos"); - lightparms_index = gl.GetUniformLocation(hShader, "lightparms"); - colormapstart_index = gl.GetUniformLocation(hShader, "colormapstart"); - colormaprange_index = gl.GetUniformLocation(hShader, "colormaprange"); - lightrange_index = gl.GetUniformLocation(hShader, "lightrange"); - fogcolor_index = gl.GetUniformLocation(hShader, "fogcolor"); - lights_index = gl.GetUniformLocation(hShader, "lights"); - dlightcolor_index = gl.GetUniformLocation(hShader, "dlightcolor"); + timer_index = glGetUniformLocation(hShader, "timer"); + desaturation_index = glGetUniformLocation(hShader, "desaturation_factor"); + fogenabled_index = glGetUniformLocation(hShader, "fogenabled"); + texturemode_index = glGetUniformLocation(hShader, "texturemode"); + camerapos_index = glGetUniformLocation(hShader, "camerapos"); + lightparms_index = glGetUniformLocation(hShader, "lightparms"); + colormapstart_index = glGetUniformLocation(hShader, "colormapstart"); + colormaprange_index = glGetUniformLocation(hShader, "colormaprange"); + lightrange_index = glGetUniformLocation(hShader, "lightrange"); + fogcolor_index = glGetUniformLocation(hShader, "fogcolor"); + lights_index = glGetUniformLocation(hShader, "lights"); + dlightcolor_index = glGetUniformLocation(hShader, "dlightcolor"); - glowbottomcolor_index = gl.GetUniformLocation(hShader, "bottomglowcolor"); - glowtopcolor_index = gl.GetUniformLocation(hShader, "topglowcolor"); + glowbottomcolor_index = glGetUniformLocation(hShader, "bottomglowcolor"); + glowtopcolor_index = glGetUniformLocation(hShader, "topglowcolor"); - gl.UseProgram(hShader); + glUseProgram(hShader); - int texture_index = gl.GetUniformLocation(hShader, "texture2"); - if (texture_index > 0) gl.Uniform1i(texture_index, 1); + int texture_index = glGetUniformLocation(hShader, "texture2"); + if (texture_index > 0) glUniform1i(texture_index, 1); - gl.UseProgram(0); + glUseProgram(0); return !!linked; } return false; @@ -204,9 +205,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * FShader::~FShader() { - gl.DeleteProgram(hShader); - gl.DeleteShader(hVertProg); - gl.DeleteShader(hFragProg); + glDeleteProgram(hShader); + glDeleteShader(hVertProg); + glDeleteShader(hFragProg); } @@ -219,7 +220,7 @@ FShader::~FShader() bool FShader::Bind(float Speed) { GLRenderer->mShaderManager->SetActiveShader(this); - if (timer_index >=0 && Speed > 0.f) gl.Uniform1f(timer_index, gl_frameMS*Speed/1000.f); + if (timer_index >=0 && Speed > 0.f) glUniform1f(timer_index, gl_frameMS*Speed/1000.f); return true; } @@ -376,8 +377,8 @@ FShader *FShaderContainer::Bind(int cm, bool glowing, float Speed, bool lights) float m[3]= {map->ColorizeEnd[0] - map->ColorizeStart[0], map->ColorizeEnd[1] - map->ColorizeStart[1], map->ColorizeEnd[2] - map->ColorizeStart[2]}; - gl.Uniform3fv(sh->colormapstart_index, 1, map->ColorizeStart); - gl.Uniform3fv(sh->colormaprange_index, 1, m); + glUniform3fv(sh->colormapstart_index, 1, map->ColorizeStart); + glUniform3fv(sh->colormaprange_index, 1, m); } } else @@ -390,7 +391,7 @@ FShader *FShaderContainer::Bind(int cm, bool glowing, float Speed, bool lights) sh->Bind(Speed); if (desat) { - gl.Uniform1f(sh->desaturation_index, 1.f-float(cm-CM_DESAT0)/(CM_DESAT31-CM_DESAT0)); + glUniform1f(sh->desaturation_index, 1.f-float(cm-CM_DESAT0)/(CM_DESAT31-CM_DESAT0)); } } } @@ -578,7 +579,7 @@ void FShaderManager::SetActiveShader(FShader *sh) // shadermodel needs to be tested here because without it UseProgram will be NULL. if (gl.shadermodel > 0 && mActiveShader != sh) { - gl.UseProgram(sh == NULL? 0 : sh->GetHandle()); + glUseProgram(sh == NULL? 0 : sh->GetHandle()); mActiveShader = sh; } } diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index ec717934c0668b702489bbd117d475ee2044c1fd..22f53864d03bdc6b5af20427d05a871aab2c5445 100644 GIT binary patch delta 40 wcmbRCj`6`e#tkjPf|(3?3?&Sy3`GoS42cZM45^b7h2$sqiLh-h5MGuH030w3{Qv*} delta 14 WcmaFxj&a&M#tkjPo6iYPN(KNrJO?EJ diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 536dc194b..cadab5af9 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -43,6 +43,7 @@ #include "version.h" #include "i_system.h" #include "v_text.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #if defined (__unix__) || defined (__APPLE__) @@ -116,7 +117,7 @@ static bool CheckExtension(const char *ext) static void InitContext() { gl.flags=0; - gl.BlendEquation = glBlendEquationDummy; + glBlendEquation = glBlendEquationDummy; } //========================================================================== @@ -151,11 +152,11 @@ void gl_LoadExtensions() gl.vendorstring=(char*)glGetString(GL_VENDOR); // First try the regular function - gl.BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation"); + glBlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation"); // If that fails try the EXT version - if (!gl.BlendEquation) gl.BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquationEXT"); + if (!glBlendEquation) glBlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquationEXT"); // If that fails use a no-op dummy - if (!gl.BlendEquation) gl.BlendEquation = glBlendEquationDummy; + if (!glBlendEquation) glBlendEquation = glBlendEquationDummy; if (CheckExtension("GL_ARB_texture_non_power_of_two")) gl.flags|=RFL_NPOT_TEXTURE; if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; @@ -172,64 +173,64 @@ void gl_LoadExtensions() if (gl.flags & RFL_GL_20) { - gl.DeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader"); - gl.DeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram"); - gl.DetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader"); - gl.CreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader"); - gl.ShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource"); - gl.CompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader"); - gl.CreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram"); - gl.AttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader"); - gl.LinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram"); - gl.UseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"); - gl.ValidateProgram = (PFNGLVALIDATEPROGRAMPROC)wglGetProcAddress("glValidateProgram"); + glDeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader"); + glDeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram"); + glDetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader"); + glCreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader"); + glShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource"); + glCompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader"); + glCreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram"); + glAttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader"); + glLinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram"); + glUseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"); + glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)wglGetProcAddress("glValidateProgram"); - gl.VertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)wglGetProcAddress("glVertexAttrib1f"); - gl.VertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)wglGetProcAddress("glVertexAttrib2f"); - gl.VertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)wglGetProcAddress("glVertexAttrib4f"); - gl.VertexAttrib2fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib2fv"); - gl.VertexAttrib3fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib3fv"); - gl.VertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv"); - gl.VertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)wglGetProcAddress("glVertexAttrib4ubv"); - gl.GetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation"); - gl.BindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation"); + glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)wglGetProcAddress("glVertexAttrib1f"); + glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)wglGetProcAddress("glVertexAttrib2f"); + glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)wglGetProcAddress("glVertexAttrib4f"); + glVertexAttrib2fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib2fv"); + glVertexAttrib3fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib3fv"); + glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv"); + glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)wglGetProcAddress("glVertexAttrib4ubv"); + glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation"); + glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation"); - gl.Uniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f"); - gl.Uniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f"); - gl.Uniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f"); - gl.Uniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f"); - gl.Uniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i"); - gl.Uniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i"); - gl.Uniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i"); - gl.Uniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i"); - gl.Uniform1fv = (PFNGLUNIFORM1FVPROC)wglGetProcAddress("glUniform1fv"); - gl.Uniform2fv = (PFNGLUNIFORM2FVPROC)wglGetProcAddress("glUniform2fv"); - gl.Uniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv"); - gl.Uniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv"); - gl.Uniform1iv = (PFNGLUNIFORM1IVPROC)wglGetProcAddress("glUniform1iv"); - gl.Uniform2iv = (PFNGLUNIFORM2IVPROC)wglGetProcAddress("glUniform2iv"); - gl.Uniform3iv = (PFNGLUNIFORM3IVPROC)wglGetProcAddress("glUniform3iv"); - gl.Uniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv"); + glUniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f"); + glUniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f"); + glUniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f"); + glUniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f"); + glUniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i"); + glUniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i"); + glUniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i"); + glUniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i"); + glUniform1fv = (PFNGLUNIFORM1FVPROC)wglGetProcAddress("glUniform1fv"); + glUniform2fv = (PFNGLUNIFORM2FVPROC)wglGetProcAddress("glUniform2fv"); + glUniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv"); + glUniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv"); + glUniform1iv = (PFNGLUNIFORM1IVPROC)wglGetProcAddress("glUniform1iv"); + glUniform2iv = (PFNGLUNIFORM2IVPROC)wglGetProcAddress("glUniform2iv"); + glUniform3iv = (PFNGLUNIFORM3IVPROC)wglGetProcAddress("glUniform3iv"); + glUniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv"); - gl.UniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)wglGetProcAddress("glUniformMatrix2fv"); - gl.UniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)wglGetProcAddress("glUniformMatrix3fv"); - gl.UniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv"); + glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)wglGetProcAddress("glUniformMatrix2fv"); + glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)wglGetProcAddress("glUniformMatrix3fv"); + glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv"); - gl.GetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog"); - gl.GetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog"); - gl.GetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation"); - gl.GetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)wglGetProcAddress("glGetActiveUniform"); - gl.GetUniformfv = (PFNGLGETUNIFORMFVPROC)wglGetProcAddress("glGetUniformfv"); - gl.GetUniformiv = (PFNGLGETUNIFORMIVPROC)wglGetProcAddress("glGetUniformiv"); - gl.GetShaderSource = (PFNGLGETSHADERSOURCEPROC)wglGetProcAddress("glGetShaderSource"); + glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog"); + glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog"); + glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation"); + glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)wglGetProcAddress("glGetActiveUniform"); + glGetUniformfv = (PFNGLGETUNIFORMFVPROC)wglGetProcAddress("glGetUniformfv"); + glGetUniformiv = (PFNGLGETUNIFORMIVPROC)wglGetProcAddress("glGetUniformiv"); + glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)wglGetProcAddress("glGetShaderSource"); - gl.EnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray"); - gl.DisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray"); - gl.VertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer"); + glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray"); + glDisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray"); + glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer"); // what'S the equivalent of this in GL 2.0??? - gl.GetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB"); + glGetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB"); // Rules: // SM4 will always use shaders. No option to switch them off is needed here. @@ -250,55 +251,55 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_occlusion_query")) { - gl.GenQueries = (PFNGLGENQUERIESARBPROC)wglGetProcAddress("glGenQueriesARB"); - gl.DeleteQueries = (PFNGLDELETEQUERIESARBPROC)wglGetProcAddress("glDeleteQueriesARB"); - gl.GetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVARBPROC)wglGetProcAddress("glGetQueryObjectuivARB"); - gl.BeginQuery = (PFNGLBEGINQUERYARBPROC)wglGetProcAddress("glBeginQueryARB"); - gl.EndQuery = (PFNGLENDQUERYPROC)wglGetProcAddress("glEndQueryARB"); + glGenQueries = (PFNGLGENQUERIESARBPROC)wglGetProcAddress("glGenQueriesARB"); + glDeleteQueries = (PFNGLDELETEQUERIESARBPROC)wglGetProcAddress("glDeleteQueriesARB"); + glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVARBPROC)wglGetProcAddress("glGetQueryObjectuivARB"); + glBeginQuery = (PFNGLBEGINQUERYARBPROC)wglGetProcAddress("glBeginQueryARB"); + glEndQuery = (PFNGLENDQUERYPROC)wglGetProcAddress("glEndQueryARB"); gl.flags|=RFL_OCCLUSION_QUERY; } if (gl.flags & RFL_GL_21) { - gl.BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer"); - gl.DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers"); - gl.GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers"); - gl.BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData"); - gl.BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubData"); - gl.MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer"); - gl.UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer"); + glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer"); + glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers"); + glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers"); + glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData"); + glBufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubData"); + glMapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer"); + glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer"); gl.flags |= RFL_VBO; } else if (CheckExtension("GL_ARB_vertex_buffer_object")) { - gl.BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBufferARB"); - gl.DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB"); - gl.GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffersARB"); - gl.BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferDataARB"); - gl.BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB"); - gl.MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBufferARB"); - gl.UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBufferARB"); + glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBufferARB"); + glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB"); + glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffersARB"); + glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferDataARB"); + glBufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB"); + glMapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBufferARB"); + glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBufferARB"); gl.flags |= RFL_VBO; } if (CheckExtension("GL_ARB_map_buffer_range")) { - gl.MapBufferRange = (PFNGLMAPBUFFERRANGEPROC)wglGetProcAddress("glMapBufferRange"); - gl.FlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)wglGetProcAddress("glFlushMappedBufferRange"); + glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)wglGetProcAddress("glMapBufferRange"); + glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)wglGetProcAddress("glFlushMappedBufferRange"); gl.flags|=RFL_MAP_BUFFER_RANGE; } if (CheckExtension("GL_ARB_framebuffer_object")) { - gl.GenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers"); - gl.DeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers"); - gl.BindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer"); - gl.FramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D"); - gl.GenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers"); - gl.DeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress("glDeleteRenderbuffers"); - gl.BindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer"); - gl.RenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorage"); - gl.FramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbuffer"); + glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers"); + glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers"); + glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer"); + glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D"); + glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers"); + glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress("glDeleteRenderbuffers"); + glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer"); + glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorage"); + glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbuffer"); gl.flags|=RFL_FRAMEBUFFER; } @@ -310,16 +311,16 @@ void gl_LoadExtensions() CheckExtension("GL_ARB_texture_rg") && gl.shadermodel == 4) { - gl.TexBufferARB = (PFNGLTEXBUFFERARBPROC)wglGetProcAddress("glTexBufferARB"); + glTexBufferARB = (PFNGLTEXBUFFERARBPROC)wglGetProcAddress("glTexBufferARB"); gl.flags|=RFL_TEXTUREBUFFER; } #endif - gl.ActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTextureARB"); - gl.MultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2fARB"); - gl.MultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) wglGetProcAddress("glMultiTexCoord2fvARB"); + glActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTextureARB"); + glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2fARB"); + glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) wglGetProcAddress("glMultiTexCoord2fvARB"); } //========================================================================== diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 7e937dcbf..babbec8fd 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -1,22 +1,7 @@ #ifndef R_RENDER #define R_RENDER -#if defined(__APPLE__) -#define APIENTRY -#define APIENTRYP * -#endif // __APPLE__ - #include "basictypes.h" -#ifndef _WIN32 -typedef bool BOOL; -#endif - -#ifndef PFNGLMULTITEXCOORD2FPROC -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -#endif -#ifndef PFNGLMULTITEXCOORD2FVPROC -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -#endif enum RenderFlags { @@ -65,98 +50,9 @@ struct RenderContext { return maxuniforms>=2048? 128:64; } - - void (APIENTRY * BlendEquation) (GLenum); - - // ARB_SHADER_OBJECTS - PFNGLDELETESHADERPROC DeleteShader; - PFNGLDELETEPROGRAMPROC DeleteProgram; - PFNGLDETACHSHADERPROC DetachShader; - PFNGLCREATESHADERPROC CreateShader; - PFNGLSHADERSOURCEPROC ShaderSource; - PFNGLCOMPILESHADERPROC CompileShader; - PFNGLCREATEPROGRAMPROC CreateProgram; - PFNGLATTACHSHADERPROC AttachShader; - PFNGLLINKPROGRAMPROC LinkProgram; - PFNGLUSEPROGRAMPROC UseProgram; - PFNGLVALIDATEPROGRAMPROC ValidateProgram; - PFNGLVERTEXATTRIB1FPROC VertexAttrib1f; - PFNGLVERTEXATTRIB2FPROC VertexAttrib2f; - PFNGLVERTEXATTRIB4FPROC VertexAttrib4f; - PFNGLVERTEXATTRIB2FVPROC VertexAttrib2fv; - PFNGLVERTEXATTRIB3FVPROC VertexAttrib3fv; - PFNGLVERTEXATTRIB4FVPROC VertexAttrib4fv; - PFNGLVERTEXATTRIB4UBVPROC VertexAttrib4ubv; - PFNGLGETATTRIBLOCATIONPROC GetAttribLocation; - PFNGLBINDATTRIBLOCATIONPROC BindAttribLocation; - - PFNGLUNIFORM1FPROC Uniform1f; - PFNGLUNIFORM2FPROC Uniform2f; - PFNGLUNIFORM3FPROC Uniform3f; - PFNGLUNIFORM4FPROC Uniform4f; - PFNGLUNIFORM1IPROC Uniform1i; - PFNGLUNIFORM2IPROC Uniform2i; - PFNGLUNIFORM3IPROC Uniform3i; - PFNGLUNIFORM4IPROC Uniform4i; - PFNGLUNIFORM1FVPROC Uniform1fv; - PFNGLUNIFORM2FVPROC Uniform2fv; - PFNGLUNIFORM3FVPROC Uniform3fv; - PFNGLUNIFORM4FVPROC Uniform4fv; - PFNGLUNIFORM1IVPROC Uniform1iv; - PFNGLUNIFORM2IVPROC Uniform2iv; - PFNGLUNIFORM3IVPROC Uniform3iv; - PFNGLUNIFORM4IVPROC Uniform4iv; - - PFNGLUNIFORMMATRIX2FVPROC UniformMatrix2fv; - PFNGLUNIFORMMATRIX3FVPROC UniformMatrix3fv; - PFNGLUNIFORMMATRIX4FVPROC UniformMatrix4fv; - - PFNGLGETSHADERINFOLOGPROC GetShaderInfoLog; - PFNGLGETPROGRAMINFOLOGPROC GetProgramInfoLog; - PFNGLGETUNIFORMLOCATIONPROC GetUniformLocation; - PFNGLGETACTIVEUNIFORMPROC GetActiveUniform; - PFNGLGETUNIFORMFVPROC GetUniformfv; - PFNGLGETUNIFORMIVPROC GetUniformiv; - PFNGLGETSHADERSOURCEPROC GetShaderSource; - PFNGLGETOBJECTPARAMETERIVARBPROC GetObjectParameteriv; - - PFNGLGENQUERIESARBPROC GenQueries; - PFNGLDELETEQUERIESARBPROC DeleteQueries; - PFNGLBEGINQUERYARBPROC BeginQuery; - PFNGLENDQUERYARBPROC EndQuery; - PFNGLGETQUERYOBJECTUIVARBPROC GetQueryObjectuiv; - - PFNGLACTIVETEXTUREPROC ActiveTexture; - PFNGLMULTITEXCOORD2FPROC MultiTexCoord2f; - PFNGLMULTITEXCOORD2FVPROC MultiTexCoord2fv; - - PFNGLBINDBUFFERPROC BindBuffer; - PFNGLDELETEBUFFERSPROC DeleteBuffers; - PFNGLGENBUFFERSPROC GenBuffers; - PFNGLBUFFERDATAPROC BufferData; - PFNGLBUFFERSUBDATAPROC BufferSubData; - PFNGLMAPBUFFERPROC MapBuffer; - PFNGLUNMAPBUFFERPROC UnmapBuffer; - PFNGLENABLEVERTEXATTRIBARRAYPROC EnableVertexAttribArray; - PFNGLDISABLEVERTEXATTRIBARRAYPROC DisableVertexAttribArray; - PFNGLVERTEXATTRIBPOINTERPROC VertexAttribPointer; - - PFNGLMAPBUFFERRANGEPROC MapBufferRange; - PFNGLFLUSHMAPPEDBUFFERRANGEPROC FlushMappedBufferRange; - - PFNGLGENFRAMEBUFFERSPROC GenFramebuffers; - PFNGLDELETEFRAMEBUFFERSPROC DeleteFramebuffers; - PFNGLBINDFRAMEBUFFERPROC BindFramebuffer; - PFNGLFRAMEBUFFERTEXTURE2DPROC FramebufferTexture2D; - PFNGLGENRENDERBUFFERSPROC GenRenderbuffers; - PFNGLDELETERENDERBUFFERSPROC DeleteRenderbuffers; - PFNGLBINDRENDERBUFFERPROC BindRenderbuffer; - PFNGLRENDERBUFFERSTORAGEPROC RenderbufferStorage; - PFNGLFRAMEBUFFERRENDERBUFFERPROC FramebufferRenderbuffer; - - PFNGLTEXBUFFERARBPROC TexBufferARB; }; +extern RenderContext gl; #endif diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index ba70431da..eae5d7a7e 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -5,6 +5,7 @@ #include "c_dispatch.h" #include "v_video.h" #include "version.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_renderer.h" #include "menu/menu.h" diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h index d2430bd63..0a0fc7017 100644 --- a/src/gl/system/gl_system.h +++ b/src/gl/system/gl_system.h @@ -74,6 +74,7 @@ #include #include #endif // __APPLE__ +#include "gl/api/gl_api.h" #ifdef _WIN32 #define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code! @@ -92,9 +93,7 @@ inline T max( T a, T b) { return (((a)>(b)) ? (a) : (b)); } #ifndef _WIN32 #include #endif -#include "gl/system/gl_interface.h" -extern RenderContext gl; #ifdef LoadMenu #undef LoadMenu diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index d290fcc30..c41a1fb24 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -49,6 +49,7 @@ #include "templates.h" #include "vectors.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderstate.h" #include "gl/system/gl_framebuffer.h" @@ -506,7 +507,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.Apply(true); - gl.ActiveTexture(GL_TEXTURE1); + glActiveTexture(GL_TEXTURE1); glEnable(GL_TEXTURE_2D); // mask out the alpha channel of the wipeendscreen. @@ -518,7 +519,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - gl.ActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); // Burn the new screen on top of it. glColor4f(1.f, 1.f, 1.f, 1.f); @@ -533,24 +534,24 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) glBegin(GL_TRIANGLE_STRIP); - gl.MultiTexCoord2f(GL_TEXTURE0, 0, 0); - gl.MultiTexCoord2f(GL_TEXTURE1, 0, vb); + glMultiTexCoord2f(GL_TEXTURE0, 0, 0); + glMultiTexCoord2f(GL_TEXTURE1, 0, vb); glVertex2i(0, 0); - gl.MultiTexCoord2f(GL_TEXTURE0, 0, 1); - gl.MultiTexCoord2f(GL_TEXTURE1, 0, 0); + glMultiTexCoord2f(GL_TEXTURE0, 0, 1); + glMultiTexCoord2f(GL_TEXTURE1, 0, 0); glVertex2i(0, fb->Height); - gl.MultiTexCoord2f(GL_TEXTURE0, 1, 0); - gl.MultiTexCoord2f(GL_TEXTURE1, ur, vb); + glMultiTexCoord2f(GL_TEXTURE0, 1, 0); + glMultiTexCoord2f(GL_TEXTURE1, ur, vb); glVertex2i(fb->Width, 0); - gl.MultiTexCoord2f(GL_TEXTURE0, 1, 1); - gl.MultiTexCoord2f(GL_TEXTURE1, ur, 0); + glMultiTexCoord2f(GL_TEXTURE0, 1, 1); + glMultiTexCoord2f(GL_TEXTURE1, ur, 0); glVertex2i(fb->Width, fb->Height); glEnd(); - gl.ActiveTexture(GL_TEXTURE1); + glActiveTexture(GL_TEXTURE1); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glDisable(GL_TEXTURE_2D); - gl.ActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); // The fire may not always stabilize, so the wipe is forced to end // after an arbitrary maximum time. diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 36861f713..9145ac3f1 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -35,6 +35,7 @@ */ #include "gl/system/gl_system.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/textures/gl_texture.h" #include "c_cvars.h" diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index eaf581be4..4737f7717 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -46,6 +46,7 @@ #include "c_dispatch.h" #include "v_palette.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_renderer.h" #include "gl/textures/gl_material.h" @@ -266,7 +267,7 @@ void FHardwareTexture::Clean(bool all) DeleteTexture(glTexID_Translated[i].glTexID); } glTexID_Translated.Clear(); - if (glDepthID != 0) gl.DeleteRenderbuffers(1, &glDepthID); + if (glDepthID != 0) glDeleteRenderbuffers(1, &glDepthID); } //=========================================================================== @@ -327,9 +328,9 @@ unsigned int FHardwareTexture::Bind(int texunit, int cm,int translation) { if (lastbound[texunit]==*pTexID) return *pTexID; lastbound[texunit]=*pTexID; - if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0+texunit); + if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); glBindTexture(GL_TEXTURE_2D, *pTexID); - if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0); + if (texunit != 0) glActiveTexture(GL_TEXTURE0); return *pTexID; } return 0; @@ -340,9 +341,9 @@ void FHardwareTexture::Unbind(int texunit) { if (lastbound[texunit] != 0) { - if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0+texunit); + if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); glBindTexture(GL_TEXTURE_2D, 0); - if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0); + if (texunit != 0) glActiveTexture(GL_TEXTURE0); lastbound[texunit] = 0; } } @@ -367,11 +368,11 @@ int FHardwareTexture::GetDepthBuffer() { if (glDepthID == 0) { - gl.GenRenderbuffers(1, &glDepthID); - gl.BindRenderbuffer(GL_RENDERBUFFER, glDepthID); - gl.RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, + glGenRenderbuffers(1, &glDepthID); + glBindRenderbuffer(GL_RENDERBUFFER, glDepthID); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, GetTexDimension(texwidth), GetTexDimension(texheight)); - gl.BindRenderbuffer(GL_RENDERBUFFER, 0); + glBindRenderbuffer(GL_RENDERBUFFER, 0); } return glDepthID; } @@ -389,8 +390,8 @@ void FHardwareTexture::BindToFrameBuffer() { if (gl.flags & RFL_FRAMEBUFFER) { - gl.FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glTexID[0], 0); - gl.FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glTexID[0], 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); } } @@ -407,9 +408,9 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int unsigned int * pTexID=GetTexID(cm, translation); - if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0+texunit); + if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); LoadImage(buffer, w, h, *pTexID, wrap? GL_REPEAT:GL_CLAMP, cm==CM_SHADE, texunit); - if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0); + if (texunit != 0) glActiveTexture(GL_TEXTURE0); return *pTexID; } diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index e124e18ee..b77920d57 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -50,6 +50,7 @@ //#include "gl/gl_intern.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/renderer/gl_lightdata.h" #include "gl/data/gl_data.h" diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 6222c4b1c..68c33f125 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -48,6 +48,7 @@ #include "v_palette.h" #include "sc_man.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/textures/gl_texture.h" #include "gl/textures/gl_material.h" From fef0782a43231cdf8262981083f8f1868d379b13 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 12 Sep 2013 10:27:32 +0200 Subject: [PATCH 0029/1509] - added glext headers to the project because they seem to be broken in newer versions, causing compile errors on Linux. --- src/gl/api/glext.h | 11813 ++++++++++++++++++++++++++++++++++++ src/gl/api/wglext.h | 943 +++ src/gl/system/gl_system.h | 4 +- 3 files changed, 12758 insertions(+), 2 deletions(-) create mode 100644 src/gl/api/glext.h create mode 100644 src/gl/api/wglext.h diff --git a/src/gl/api/glext.h b/src/gl/api/glext.h new file mode 100644 index 000000000..8fce0f6f0 --- /dev/null +++ b/src/gl/api/glext.h @@ -0,0 +1,11813 @@ +#ifndef __glext_h_ +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2007-2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated $Date: 2012-04-26 00:59:42 -0700 (Thu, 26 Apr 2012) $ */ +/* Current version at http://www.opengl.org/registry/ */ +#define GL_GLEXT_VERSION 81 +/* Function declaration macros - to move into glplatform.h */ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_VERSION_1_2_DEPRECATED +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#endif + +#ifndef GL_ARB_imaging_DEPRECATED +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#endif + +#ifndef GL_VERSION_1_3_DEPRECATED +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#endif + +#ifndef GL_VERSION_1_4_DEPRECATED +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#endif + +#ifndef GL_VERSION_1_5_DEPRECATED +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC1_ALPHA 0x8589 +#define GL_SRC2_ALPHA 0x858A +#endif + +#ifndef GL_VERSION_2_0 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#endif + +#ifndef GL_VERSION_2_0_DEPRECATED +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +#endif + +#ifndef GL_VERSION_2_1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#endif + +#ifndef GL_VERSION_2_1_DEPRECATED +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +#endif + +#ifndef GL_VERSION_3_0 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +/* Reuse tokens from ARB_depth_buffer_float */ +/* reuse GL_DEPTH_COMPONENT32F */ +/* reuse GL_DEPTH32F_STENCIL8 */ +/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ +/* Reuse tokens from ARB_framebuffer_object */ +/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ +/* reuse GL_FRAMEBUFFER_DEFAULT */ +/* reuse GL_FRAMEBUFFER_UNDEFINED */ +/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ +/* reuse GL_INDEX */ +/* reuse GL_MAX_RENDERBUFFER_SIZE */ +/* reuse GL_DEPTH_STENCIL */ +/* reuse GL_UNSIGNED_INT_24_8 */ +/* reuse GL_DEPTH24_STENCIL8 */ +/* reuse GL_TEXTURE_STENCIL_SIZE */ +/* reuse GL_TEXTURE_RED_TYPE */ +/* reuse GL_TEXTURE_GREEN_TYPE */ +/* reuse GL_TEXTURE_BLUE_TYPE */ +/* reuse GL_TEXTURE_ALPHA_TYPE */ +/* reuse GL_TEXTURE_DEPTH_TYPE */ +/* reuse GL_UNSIGNED_NORMALIZED */ +/* reuse GL_FRAMEBUFFER_BINDING */ +/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ +/* reuse GL_RENDERBUFFER_BINDING */ +/* reuse GL_READ_FRAMEBUFFER */ +/* reuse GL_DRAW_FRAMEBUFFER */ +/* reuse GL_READ_FRAMEBUFFER_BINDING */ +/* reuse GL_RENDERBUFFER_SAMPLES */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +/* reuse GL_FRAMEBUFFER_COMPLETE */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ +/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ +/* reuse GL_MAX_COLOR_ATTACHMENTS */ +/* reuse GL_COLOR_ATTACHMENT0 */ +/* reuse GL_COLOR_ATTACHMENT1 */ +/* reuse GL_COLOR_ATTACHMENT2 */ +/* reuse GL_COLOR_ATTACHMENT3 */ +/* reuse GL_COLOR_ATTACHMENT4 */ +/* reuse GL_COLOR_ATTACHMENT5 */ +/* reuse GL_COLOR_ATTACHMENT6 */ +/* reuse GL_COLOR_ATTACHMENT7 */ +/* reuse GL_COLOR_ATTACHMENT8 */ +/* reuse GL_COLOR_ATTACHMENT9 */ +/* reuse GL_COLOR_ATTACHMENT10 */ +/* reuse GL_COLOR_ATTACHMENT11 */ +/* reuse GL_COLOR_ATTACHMENT12 */ +/* reuse GL_COLOR_ATTACHMENT13 */ +/* reuse GL_COLOR_ATTACHMENT14 */ +/* reuse GL_COLOR_ATTACHMENT15 */ +/* reuse GL_DEPTH_ATTACHMENT */ +/* reuse GL_STENCIL_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER */ +/* reuse GL_RENDERBUFFER */ +/* reuse GL_RENDERBUFFER_WIDTH */ +/* reuse GL_RENDERBUFFER_HEIGHT */ +/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ +/* reuse GL_STENCIL_INDEX1 */ +/* reuse GL_STENCIL_INDEX4 */ +/* reuse GL_STENCIL_INDEX8 */ +/* reuse GL_STENCIL_INDEX16 */ +/* reuse GL_RENDERBUFFER_RED_SIZE */ +/* reuse GL_RENDERBUFFER_GREEN_SIZE */ +/* reuse GL_RENDERBUFFER_BLUE_SIZE */ +/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ +/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ +/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ +/* reuse GL_MAX_SAMPLES */ +/* Reuse tokens from ARB_framebuffer_sRGB */ +/* reuse GL_FRAMEBUFFER_SRGB */ +/* Reuse tokens from ARB_half_float_vertex */ +/* reuse GL_HALF_FLOAT */ +/* Reuse tokens from ARB_map_buffer_range */ +/* reuse GL_MAP_READ_BIT */ +/* reuse GL_MAP_WRITE_BIT */ +/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ +/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ +/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ +/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ +/* Reuse tokens from ARB_texture_compression_rgtc */ +/* reuse GL_COMPRESSED_RED_RGTC1 */ +/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ +/* reuse GL_COMPRESSED_RG_RGTC2 */ +/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ +/* Reuse tokens from ARB_texture_rg */ +/* reuse GL_RG */ +/* reuse GL_RG_INTEGER */ +/* reuse GL_R8 */ +/* reuse GL_R16 */ +/* reuse GL_RG8 */ +/* reuse GL_RG16 */ +/* reuse GL_R16F */ +/* reuse GL_R32F */ +/* reuse GL_RG16F */ +/* reuse GL_RG32F */ +/* reuse GL_R8I */ +/* reuse GL_R8UI */ +/* reuse GL_R16I */ +/* reuse GL_R16UI */ +/* reuse GL_R32I */ +/* reuse GL_R32UI */ +/* reuse GL_RG8I */ +/* reuse GL_RG8UI */ +/* reuse GL_RG16I */ +/* reuse GL_RG16UI */ +/* reuse GL_RG32I */ +/* reuse GL_RG32UI */ +/* Reuse tokens from ARB_vertex_array_object */ +/* reuse GL_VERTEX_ARRAY_BINDING */ +#endif + +#ifndef GL_VERSION_3_0_DEPRECATED +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +/* Reuse tokens from ARB_framebuffer_object */ +/* reuse GL_TEXTURE_LUMINANCE_TYPE */ +/* reuse GL_TEXTURE_INTENSITY_TYPE */ +#endif + +#ifndef GL_VERSION_3_1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT 0x8C2E +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +/* Reuse tokens from ARB_copy_buffer */ +/* reuse GL_COPY_READ_BUFFER */ +/* reuse GL_COPY_WRITE_BUFFER */ +/* Reuse tokens from ARB_draw_instanced (none) */ +/* Reuse tokens from ARB_uniform_buffer_object */ +/* reuse GL_UNIFORM_BUFFER */ +/* reuse GL_UNIFORM_BUFFER_BINDING */ +/* reuse GL_UNIFORM_BUFFER_START */ +/* reuse GL_UNIFORM_BUFFER_SIZE */ +/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */ +/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */ +/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */ +/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */ +/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */ +/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */ +/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */ +/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */ +/* reuse GL_ACTIVE_UNIFORM_BLOCKS */ +/* reuse GL_UNIFORM_TYPE */ +/* reuse GL_UNIFORM_SIZE */ +/* reuse GL_UNIFORM_NAME_LENGTH */ +/* reuse GL_UNIFORM_BLOCK_INDEX */ +/* reuse GL_UNIFORM_OFFSET */ +/* reuse GL_UNIFORM_ARRAY_STRIDE */ +/* reuse GL_UNIFORM_MATRIX_STRIDE */ +/* reuse GL_UNIFORM_IS_ROW_MAJOR */ +/* reuse GL_UNIFORM_BLOCK_BINDING */ +/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */ +/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */ +/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */ +/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_INVALID_INDEX */ +#endif + +#ifndef GL_VERSION_3_2 +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +/* reuse GL_MAX_VARYING_COMPONENTS */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +/* Reuse tokens from ARB_depth_clamp */ +/* reuse GL_DEPTH_CLAMP */ +/* Reuse tokens from ARB_draw_elements_base_vertex (none) */ +/* Reuse tokens from ARB_fragment_coord_conventions (none) */ +/* Reuse tokens from ARB_provoking_vertex */ +/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ +/* reuse GL_FIRST_VERTEX_CONVENTION */ +/* reuse GL_LAST_VERTEX_CONVENTION */ +/* reuse GL_PROVOKING_VERTEX */ +/* Reuse tokens from ARB_seamless_cube_map */ +/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ +/* Reuse tokens from ARB_sync */ +/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */ +/* reuse GL_OBJECT_TYPE */ +/* reuse GL_SYNC_CONDITION */ +/* reuse GL_SYNC_STATUS */ +/* reuse GL_SYNC_FLAGS */ +/* reuse GL_SYNC_FENCE */ +/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */ +/* reuse GL_UNSIGNALED */ +/* reuse GL_SIGNALED */ +/* reuse GL_ALREADY_SIGNALED */ +/* reuse GL_TIMEOUT_EXPIRED */ +/* reuse GL_CONDITION_SATISFIED */ +/* reuse GL_WAIT_FAILED */ +/* reuse GL_TIMEOUT_IGNORED */ +/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */ +/* reuse GL_TIMEOUT_IGNORED */ +/* Reuse tokens from ARB_texture_multisample */ +/* reuse GL_SAMPLE_POSITION */ +/* reuse GL_SAMPLE_MASK */ +/* reuse GL_SAMPLE_MASK_VALUE */ +/* reuse GL_MAX_SAMPLE_MASK_WORDS */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_SAMPLES */ +/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */ +/* reuse GL_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */ +/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */ +/* reuse GL_MAX_INTEGER_SAMPLES */ +/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */ +#endif + +#ifndef GL_VERSION_3_3 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +/* Reuse tokens from ARB_blend_func_extended */ +/* reuse GL_SRC1_COLOR */ +/* reuse GL_ONE_MINUS_SRC1_COLOR */ +/* reuse GL_ONE_MINUS_SRC1_ALPHA */ +/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */ +/* Reuse tokens from ARB_explicit_attrib_location (none) */ +/* Reuse tokens from ARB_occlusion_query2 */ +/* reuse GL_ANY_SAMPLES_PASSED */ +/* Reuse tokens from ARB_sampler_objects */ +/* reuse GL_SAMPLER_BINDING */ +/* Reuse tokens from ARB_shader_bit_encoding (none) */ +/* Reuse tokens from ARB_texture_rgb10_a2ui */ +/* reuse GL_RGB10_A2UI */ +/* Reuse tokens from ARB_texture_swizzle */ +/* reuse GL_TEXTURE_SWIZZLE_R */ +/* reuse GL_TEXTURE_SWIZZLE_G */ +/* reuse GL_TEXTURE_SWIZZLE_B */ +/* reuse GL_TEXTURE_SWIZZLE_A */ +/* reuse GL_TEXTURE_SWIZZLE_RGBA */ +/* Reuse tokens from ARB_timer_query */ +/* reuse GL_TIME_ELAPSED */ +/* reuse GL_TIMESTAMP */ +/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */ +/* reuse GL_INT_2_10_10_10_REV */ +#endif + +#ifndef GL_VERSION_4_0 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +/* Reuse tokens from ARB_texture_query_lod (none) */ +/* Reuse tokens from ARB_draw_buffers_blend (none) */ +/* Reuse tokens from ARB_draw_indirect */ +/* reuse GL_DRAW_INDIRECT_BUFFER */ +/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */ +/* Reuse tokens from ARB_gpu_shader5 */ +/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */ +/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */ +/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */ +/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */ +/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */ +/* reuse GL_MAX_VERTEX_STREAMS */ +/* Reuse tokens from ARB_gpu_shader_fp64 */ +/* reuse GL_DOUBLE_VEC2 */ +/* reuse GL_DOUBLE_VEC3 */ +/* reuse GL_DOUBLE_VEC4 */ +/* reuse GL_DOUBLE_MAT2 */ +/* reuse GL_DOUBLE_MAT3 */ +/* reuse GL_DOUBLE_MAT4 */ +/* reuse GL_DOUBLE_MAT2x3 */ +/* reuse GL_DOUBLE_MAT2x4 */ +/* reuse GL_DOUBLE_MAT3x2 */ +/* reuse GL_DOUBLE_MAT3x4 */ +/* reuse GL_DOUBLE_MAT4x2 */ +/* reuse GL_DOUBLE_MAT4x3 */ +/* Reuse tokens from ARB_shader_subroutine */ +/* reuse GL_ACTIVE_SUBROUTINES */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */ +/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */ +/* reuse GL_MAX_SUBROUTINES */ +/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */ +/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_COMPATIBLE_SUBROUTINES */ +/* Reuse tokens from ARB_tessellation_shader */ +/* reuse GL_PATCHES */ +/* reuse GL_PATCH_VERTICES */ +/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */ +/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */ +/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */ +/* reuse GL_TESS_GEN_MODE */ +/* reuse GL_TESS_GEN_SPACING */ +/* reuse GL_TESS_GEN_VERTEX_ORDER */ +/* reuse GL_TESS_GEN_POINT_MODE */ +/* reuse GL_ISOLINES */ +/* reuse GL_FRACTIONAL_ODD */ +/* reuse GL_FRACTIONAL_EVEN */ +/* reuse GL_MAX_PATCH_VERTICES */ +/* reuse GL_MAX_TESS_GEN_LEVEL */ +/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_PATCH_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */ +/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */ +/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */ +/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_TESS_EVALUATION_SHADER */ +/* reuse GL_TESS_CONTROL_SHADER */ +/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */ +/* Reuse tokens from ARB_transform_feedback2 */ +/* reuse GL_TRANSFORM_FEEDBACK */ +/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ +/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ +/* reuse GL_TRANSFORM_FEEDBACK_BINDING */ +/* Reuse tokens from ARB_transform_feedback3 */ +/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */ +/* reuse GL_MAX_VERTEX_STREAMS */ +#endif + +#ifndef GL_VERSION_4_1 +/* Reuse tokens from ARB_ES2_compatibility */ +/* reuse GL_FIXED */ +/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */ +/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */ +/* reuse GL_LOW_FLOAT */ +/* reuse GL_MEDIUM_FLOAT */ +/* reuse GL_HIGH_FLOAT */ +/* reuse GL_LOW_INT */ +/* reuse GL_MEDIUM_INT */ +/* reuse GL_HIGH_INT */ +/* reuse GL_SHADER_COMPILER */ +/* reuse GL_NUM_SHADER_BINARY_FORMATS */ +/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */ +/* reuse GL_MAX_VARYING_VECTORS */ +/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */ +/* reuse GL_RGB565 */ +/* Reuse tokens from ARB_get_program_binary */ +/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ +/* reuse GL_PROGRAM_BINARY_LENGTH */ +/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */ +/* reuse GL_PROGRAM_BINARY_FORMATS */ +/* Reuse tokens from ARB_separate_shader_objects */ +/* reuse GL_VERTEX_SHADER_BIT */ +/* reuse GL_FRAGMENT_SHADER_BIT */ +/* reuse GL_GEOMETRY_SHADER_BIT */ +/* reuse GL_TESS_CONTROL_SHADER_BIT */ +/* reuse GL_TESS_EVALUATION_SHADER_BIT */ +/* reuse GL_ALL_SHADER_BITS */ +/* reuse GL_PROGRAM_SEPARABLE */ +/* reuse GL_ACTIVE_PROGRAM */ +/* reuse GL_PROGRAM_PIPELINE_BINDING */ +/* Reuse tokens from ARB_shader_precision (none) */ +/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */ +/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */ +/* reuse GL_MAX_VIEWPORTS */ +/* reuse GL_VIEWPORT_SUBPIXEL_BITS */ +/* reuse GL_VIEWPORT_BOUNDS_RANGE */ +/* reuse GL_LAYER_PROVOKING_VERTEX */ +/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */ +/* reuse GL_UNDEFINED_VERTEX */ +#endif + +#ifndef GL_VERSION_4_2 +/* Reuse tokens from ARB_base_instance (none) */ +/* Reuse tokens from ARB_shading_language_420pack (none) */ +/* Reuse tokens from ARB_transform_feedback_instanced (none) */ +/* Reuse tokens from ARB_compressed_texture_pixel_storage */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */ +/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */ +/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */ +/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */ +/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */ +/* Reuse tokens from ARB_conservative_depth (none) */ +/* Reuse tokens from ARB_internalformat_query */ +/* reuse GL_NUM_SAMPLE_COUNTS */ +/* Reuse tokens from ARB_map_buffer_alignment */ +/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */ +/* Reuse tokens from ARB_shader_atomic_counters */ +/* reuse GL_ATOMIC_COUNTER_BUFFER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_START */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */ +/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */ +/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */ +/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */ +/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */ +/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */ +/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */ +/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */ +/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */ +/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */ +/* Reuse tokens from ARB_shader_image_load_store */ +/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */ +/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */ +/* reuse GL_UNIFORM_BARRIER_BIT */ +/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */ +/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */ +/* reuse GL_COMMAND_BARRIER_BIT */ +/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */ +/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */ +/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */ +/* reuse GL_FRAMEBUFFER_BARRIER_BIT */ +/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */ +/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */ +/* reuse GL_ALL_BARRIER_BITS */ +/* reuse GL_MAX_IMAGE_UNITS */ +/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ +/* reuse GL_IMAGE_BINDING_NAME */ +/* reuse GL_IMAGE_BINDING_LEVEL */ +/* reuse GL_IMAGE_BINDING_LAYERED */ +/* reuse GL_IMAGE_BINDING_LAYER */ +/* reuse GL_IMAGE_BINDING_ACCESS */ +/* reuse GL_IMAGE_1D */ +/* reuse GL_IMAGE_2D */ +/* reuse GL_IMAGE_3D */ +/* reuse GL_IMAGE_2D_RECT */ +/* reuse GL_IMAGE_CUBE */ +/* reuse GL_IMAGE_BUFFER */ +/* reuse GL_IMAGE_1D_ARRAY */ +/* reuse GL_IMAGE_2D_ARRAY */ +/* reuse GL_IMAGE_CUBE_MAP_ARRAY */ +/* reuse GL_IMAGE_2D_MULTISAMPLE */ +/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_INT_IMAGE_1D */ +/* reuse GL_INT_IMAGE_2D */ +/* reuse GL_INT_IMAGE_3D */ +/* reuse GL_INT_IMAGE_2D_RECT */ +/* reuse GL_INT_IMAGE_CUBE */ +/* reuse GL_INT_IMAGE_BUFFER */ +/* reuse GL_INT_IMAGE_1D_ARRAY */ +/* reuse GL_INT_IMAGE_2D_ARRAY */ +/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */ +/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */ +/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_1D */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D */ +/* reuse GL_UNSIGNED_INT_IMAGE_3D */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */ +/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */ +/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */ +/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_MAX_IMAGE_SAMPLES */ +/* reuse GL_IMAGE_BINDING_FORMAT */ +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */ +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */ +/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */ +/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */ +/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */ +/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */ +/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */ +/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */ +/* Reuse tokens from ARB_shading_language_packing (none) */ +/* Reuse tokens from ARB_texture_storage */ +/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */ +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +#ifndef GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#endif + +#ifndef GL_ARB_draw_instanced +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#endif + +#ifndef GL_ARB_framebuffer_object_DEPRECATED +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +/* reuse GL_MAX_VARYING_COMPONENTS */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_HALF_FLOAT 0x140B +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#endif + +#ifndef GL_ARB_texture_rg +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#endif + +#ifndef GL_ARB_uniform_buffer_object +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#endif + +#ifndef GL_ARB_compatibility +/* ARB_compatibility just defines tokens from core 3.0 */ +#endif + +#ifndef GL_ARB_copy_buffer +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_READ_BUFFER GL_COPY_READ_BUFFER_BINDING +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_COPY_WRITE_BUFFER GL_COPY_WRITE_BUFFER_BINDING +#endif + +#ifndef GL_ARB_shader_texture_lod +#endif + +#ifndef GL_ARB_depth_clamp +#define GL_DEPTH_CLAMP 0x864F +#endif + +#ifndef GL_ARB_draw_elements_base_vertex +#endif + +#ifndef GL_ARB_fragment_coord_conventions +#endif + +#ifndef GL_ARB_provoking_vertex +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#endif + +#ifndef GL_ARB_seamless_cube_map +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#endif + +#ifndef GL_ARB_sync +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#endif + +#ifndef GL_ARB_texture_multisample +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +#endif + +#ifndef GL_ARB_vertex_array_bgra +/* reuse GL_BGRA */ +#endif + +#ifndef GL_ARB_draw_buffers_blend +#endif + +#ifndef GL_ARB_sample_shading +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +#endif + +#ifndef GL_ARB_texture_cube_map_array +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif + +#ifndef GL_ARB_texture_gather +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#endif + +#ifndef GL_ARB_texture_query_lod +#endif + +#ifndef GL_ARB_shading_language_include +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +#endif + +#ifndef GL_ARB_texture_compression_bptc +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif + +#ifndef GL_ARB_blend_func_extended +#define GL_SRC1_COLOR 0x88F9 +/* reuse GL_SRC1_ALPHA */ +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#endif + +#ifndef GL_ARB_explicit_attrib_location +#endif + +#ifndef GL_ARB_occlusion_query2 +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#endif + +#ifndef GL_ARB_sampler_objects +#define GL_SAMPLER_BINDING 0x8919 +#endif + +#ifndef GL_ARB_shader_bit_encoding +#endif + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_RGB10_A2UI 0x906F +#endif + +#ifndef GL_ARB_texture_swizzle +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#endif + +#ifndef GL_ARB_timer_query +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#endif + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */ +#define GL_INT_2_10_10_10_REV 0x8D9F +#endif + +#ifndef GL_ARB_draw_indirect +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#endif + +#ifndef GL_ARB_gpu_shader5 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +/* reuse GL_MAX_VERTEX_STREAMS */ +#endif + +#ifndef GL_ARB_gpu_shader_fp64 +/* reuse GL_DOUBLE */ +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#endif + +#ifndef GL_ARB_shader_subroutine +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +/* reuse GL_UNIFORM_SIZE */ +/* reuse GL_UNIFORM_NAME_LENGTH */ +#endif + +#ifndef GL_ARB_tessellation_shader +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +/* reuse GL_TRIANGLES */ +/* reuse GL_QUADS */ +#define GL_ISOLINES 0x8E7A +/* reuse GL_EQUAL */ +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +/* reuse GL_CCW */ +/* reuse GL_CW */ +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#endif + +#ifndef GL_ARB_texture_buffer_object_rgb32 +/* reuse GL_RGB32F */ +/* reuse GL_RGB32UI */ +/* reuse GL_RGB32I */ +#endif + +#ifndef GL_ARB_transform_feedback2 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED GL_TRANSFORM_FEEDBACK_PAUSED +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE GL_TRANSFORM_FEEDBACK_ACTIVE +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#endif + +#ifndef GL_ARB_transform_feedback3 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#endif + +#ifndef GL_ARB_ES2_compatibility +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#endif + +#ifndef GL_ARB_get_program_binary +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#endif + +#ifndef GL_ARB_separate_shader_objects +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#endif + +#ifndef GL_ARB_shader_precision +#endif + +#ifndef GL_ARB_vertex_attrib_64bit +/* reuse GL_RGB32I */ +/* reuse GL_DOUBLE_VEC2 */ +/* reuse GL_DOUBLE_VEC3 */ +/* reuse GL_DOUBLE_VEC4 */ +/* reuse GL_DOUBLE_MAT2 */ +/* reuse GL_DOUBLE_MAT3 */ +/* reuse GL_DOUBLE_MAT4 */ +/* reuse GL_DOUBLE_MAT2x3 */ +/* reuse GL_DOUBLE_MAT2x4 */ +/* reuse GL_DOUBLE_MAT3x2 */ +/* reuse GL_DOUBLE_MAT3x4 */ +/* reuse GL_DOUBLE_MAT4x2 */ +/* reuse GL_DOUBLE_MAT4x3 */ +#endif + +#ifndef GL_ARB_viewport_array +/* reuse GL_SCISSOR_BOX */ +/* reuse GL_VIEWPORT */ +/* reuse GL_DEPTH_RANGE */ +/* reuse GL_SCISSOR_TEST */ +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +/* reuse GL_FIRST_VERTEX_CONVENTION */ +/* reuse GL_LAST_VERTEX_CONVENTION */ +/* reuse GL_PROVOKING_VERTEX */ +#endif + +#ifndef GL_ARB_cl_event +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +#endif + +#ifndef GL_ARB_debug_output +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +#endif + +#ifndef GL_ARB_robustness +/* reuse GL_NO_ERROR */ +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif + +#ifndef GL_ARB_shader_stencil_export +#endif + +#ifndef GL_ARB_base_instance +#endif + +#ifndef GL_ARB_shading_language_420pack +#endif + +#ifndef GL_ARB_transform_feedback_instanced +#endif + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#endif + +#ifndef GL_ARB_conservative_depth +#endif + +#ifndef GL_ARB_internalformat_query +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#endif + +#ifndef GL_ARB_map_buffer_alignment +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#endif + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#endif + +#ifndef GL_ARB_shader_image_load_store +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#endif + +#ifndef GL_ARB_shading_language_packing +#endif + +#ifndef GL_ARB_texture_storage +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_FfdMaskSGIX +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_FOG_SCALE_SGIX 0x81FC +#define GL_FOG_SCALE_VALUE_SGIX 0x81FD +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_SGI_depth_pass_instrument +#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 +#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 +#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif + +#ifndef GL_NV_fragment_program_option +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif + +#ifndef GL_NV_vertex_program2_option +/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ +/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ +#endif + +#ifndef GL_NV_vertex_program3 +/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#endif + +#ifndef GL_GREMEDY_string_marker +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif + +#ifndef GL_EXT_timer_query +#define GL_TIME_ELAPSED_EXT 0x88BF +#endif + +#ifndef GL_EXT_gpu_program_parameters +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */ +/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */ +/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */ +/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */ +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +/* reuse GL_LINES_ADJACENCY_EXT */ +/* reuse GL_LINE_STRIP_ADJACENCY_EXT */ +/* reuse GL_TRIANGLES_ADJACENCY_EXT */ +/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +/* reuse GL_PROGRAM_POINT_SIZE_EXT */ +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#endif + +#ifndef GL_EXT_draw_instanced +#endif + +#ifndef GL_EXT_packed_float +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif + +#ifndef GL_EXT_texture_array +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +#endif + +#ifndef GL_NV_fragment_program4 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif + +#ifndef GL_NV_geometry_shader4 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +#endif + +#ifndef GL_EXT_draw_buffers2 +#endif + +#ifndef GL_NV_transform_feedback +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +#endif + +#ifndef GL_EXT_texture_integer +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +#endif + +#ifndef GL_GREMEDY_frame_terminator +#endif + +#ifndef GL_NV_conditional_render +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +#endif + +#ifndef GL_NV_present_video +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +#endif + +#ifndef GL_EXT_direct_state_access +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +#endif + +#ifndef GL_EXT_vertex_array_bgra +/* reuse GL_BGRA */ +#endif + +#ifndef GL_EXT_texture_swizzle +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif + +#ifndef GL_NV_explicit_multisample +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +#endif + +#ifndef GL_NV_transform_feedback2 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +#endif + +#ifndef GL_ATI_meminfo +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif + +#ifndef GL_AMD_performance_monitor +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +#endif + +#ifndef GL_AMD_texture_texture4 +#endif + +#ifndef GL_AMD_vertex_shader_tesselator +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +#endif + +#ifndef GL_EXT_provoking_vertex +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +#endif + +#ifndef GL_EXT_texture_snorm +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +/* reuse GL_RED_SNORM */ +/* reuse GL_RG_SNORM */ +/* reuse GL_RGB_SNORM */ +/* reuse GL_RGBA_SNORM */ +/* reuse GL_R8_SNORM */ +/* reuse GL_RG8_SNORM */ +/* reuse GL_RGB8_SNORM */ +/* reuse GL_RGBA8_SNORM */ +/* reuse GL_R16_SNORM */ +/* reuse GL_RG16_SNORM */ +/* reuse GL_RGB16_SNORM */ +/* reuse GL_RGBA16_SNORM */ +/* reuse GL_SIGNED_NORMALIZED */ +#endif + +#ifndef GL_AMD_draw_buffers_blend +#endif + +#ifndef GL_APPLE_texture_range +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +/* reuse GL_STORAGE_CACHED_APPLE */ +/* reuse GL_STORAGE_SHARED_APPLE */ +#endif + +#ifndef GL_APPLE_float_pixels +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +#endif + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif + +#ifndef GL_APPLE_object_purgeable +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +#endif + +#ifndef GL_APPLE_row_bytes +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif + +#ifndef GL_APPLE_rgb_422 +#define GL_RGB_422_APPLE 0x8A1F +/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */ +/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */ +#endif + +#ifndef GL_NV_video_capture +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +#endif + +#ifndef GL_NV_copy_image +#endif + +#ifndef GL_EXT_separate_shader_objects +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +#endif + +#ifndef GL_NV_parameter_buffer_object2 +#endif + +#ifndef GL_NV_shader_buffer_load +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +#endif + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +#endif + +#ifndef GL_NV_texture_barrier +#endif + +#ifndef GL_AMD_shader_stencil_export +#endif + +#ifndef GL_AMD_seamless_cubemap_per_texture +/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ +#endif + +#ifndef GL_AMD_conservative_depth +#endif + +#ifndef GL_EXT_shader_image_load_store +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +#endif + +#ifndef GL_EXT_vertex_attrib_64bit +/* reuse GL_DOUBLE */ +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +#endif + +#ifndef GL_NV_gpu_program5 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +#endif + +#ifndef GL_NV_gpu_shader5 +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +/* reuse GL_PATCHES */ +#endif + +#ifndef GL_NV_shader_buffer_store +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +/* reuse GL_READ_WRITE */ +/* reuse GL_WRITE_ONLY */ +#endif + +#ifndef GL_NV_tessellation_program5 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif + +#ifndef GL_NV_vertex_attrib_integer_64bit +/* reuse GL_INT64_NV */ +/* reuse GL_UNSIGNED_INT64_NV */ +#endif + +#ifndef GL_NV_multisample_coverage +#define GL_COVERAGE_SAMPLES_NV 0x80A9 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#endif + +#ifndef GL_AMD_name_gen_delete +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +#endif + +#ifndef GL_AMD_debug_output +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +#endif + +#ifndef GL_NV_vdpau_interop +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +#endif + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#endif + +#ifndef GL_AMD_depth_clamp_separate +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif + +#ifndef GL_NV_texture_multisample +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +#endif + +#ifndef GL_AMD_blend_minmax_factor +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif + +#ifndef GL_AMD_sample_positions +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +#endif + +#ifndef GL_EXT_x11_sync_object +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +#endif + +#ifndef GL_AMD_multi_draw_indirect +#endif + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif + +#ifndef GL_NV_path_rendering +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_PATH_SAMPLE_QUALITY_NV 0x9085 +#define GL_PATH_STROKE_BOUND_NV 0x9086 +#define GL_PATH_STROKE_OVERSAMPLE_COUNT_NV 0x9087 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_MULTI_HULLS_NV 0x908C +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_PROJECTIVE_2D_NV 0x9093 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_PROJECTIVE_3D_NV 0x9095 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_PROJECTIVE_2D_NV 0x9097 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_TRANSPOSE_PROJECTIVE_3D_NV 0x9099 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_NV 0x00100000 +#define GL_FONT_ASCENDER_NV 0x00200000 +#define GL_FONT_DESCENDER_NV 0x00400000 +#define GL_FONT_HEIGHT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_NV 0x08000000 +#define GL_FONT_HAS_KERNING_NV 0x10000000 +#endif + +#ifndef GL_AMD_pinned_memory +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif + +#ifndef GL_AMD_stencil_operation_extended +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +#endif + +#ifndef GL_AMD_vertex_shader_viewport_index +#endif + +#ifndef GL_AMD_vertex_shader_layer +#endif + +#ifndef GL_NV_bindless_texture +#endif + +#ifndef GL_NV_shader_atomic_float +#endif + + +/*************************************************************/ + +#include +#ifndef GL_VERSION_2_0 +/* GL type for program/shader text */ +typedef char GLchar; +#endif + +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for program/shader text and shader object handles */ +typedef char GLcharARB; +typedef unsigned int GLhandleARB; +#endif + +/* GL type for "half" precision (s10e5) float data in host memory */ +#ifndef GL_ARB_half_float_pixel +typedef unsigned short GLhalfARB; +#endif + +#ifndef GL_NV_half_float +typedef unsigned short GLhalfNV; +#endif + +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif + +#ifndef GL_EXT_timer_query +typedef int64_t GLint64EXT; +typedef uint64_t GLuint64EXT; +#endif + +#ifndef GL_ARB_sync +typedef int64_t GLint64; +typedef uint64_t GLuint64; +typedef struct __GLsync *GLsync; +#endif + +#ifndef GL_ARB_cl_event +/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */ +struct _cl_context; +struct _cl_event; +#endif + +#ifndef GL_ARB_debug_output +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + +#ifndef GL_AMD_debug_output +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + +#ifndef GL_NV_vdpau_interop +typedef GLintptr GLvdpauSurfaceNV; +#endif + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_2_DEPRECATED +#define GL_VERSION_1_2_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_3_DEPRECATED +#define GL_VERSION_1_3_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_VERSION_1_4_DEPRECATED +#define GL_VERSION_1_4_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +/* OpenGL 3.0 also reuses entry points from these extensions: */ +/* ARB_framebuffer_object */ +/* ARB_map_buffer_range */ +/* ARB_vertex_array_object */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +#endif + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +/* OpenGL 3.1 also reuses entry points from these extensions: */ +/* ARB_copy_buffer */ +/* ARB_uniform_buffer_object */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +#endif + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +/* OpenGL 3.2 also reuses entry points from these extensions: */ +/* ARB_draw_elements_base_vertex */ +/* ARB_provoking_vertex */ +/* ARB_sync */ +/* ARB_texture_multisample */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +/* OpenGL 3.3 also reuses entry points from these extensions: */ +/* ARB_blend_func_extended */ +/* ARB_sampler_objects */ +/* ARB_explicit_attrib_location, but it has none */ +/* ARB_occlusion_query2 (no entry points) */ +/* ARB_shader_bit_encoding (no entry points) */ +/* ARB_texture_rgb10_a2ui (no entry points) */ +/* ARB_texture_swizzle (no entry points) */ +/* ARB_timer_query */ +/* ARB_vertex_type_2_10_10_10_rev */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +#endif + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +/* OpenGL 4.0 also reuses entry points from these extensions: */ +/* ARB_texture_query_lod (no entry points) */ +/* ARB_draw_indirect */ +/* ARB_gpu_shader5 (no entry points) */ +/* ARB_gpu_shader_fp64 */ +/* ARB_shader_subroutine */ +/* ARB_tessellation_shader */ +/* ARB_texture_buffer_object_rgb32 (no entry points) */ +/* ARB_texture_cube_map_array (no entry points) */ +/* ARB_texture_gather (no entry points) */ +/* ARB_transform_feedback2 */ +/* ARB_transform_feedback3 */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +/* OpenGL 4.1 reuses entry points from these extensions: */ +/* ARB_ES2_compatibility */ +/* ARB_get_program_binary */ +/* ARB_separate_shader_objects */ +/* ARB_shader_precision (no entry points) */ +/* ARB_vertex_attrib_64bit */ +/* ARB_viewport_array */ +#endif + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +/* OpenGL 4.2 reuses entry points from these extensions: */ +/* ARB_base_instance */ +/* ARB_shading_language_420pack (no entry points) */ +/* ARB_transform_feedback_instanced */ +/* ARB_compressed_texture_pixel_storage (no entry points) */ +/* ARB_conservative_depth (no entry points) */ +/* ARB_internalformat_query */ +/* ARB_map_buffer_alignment (no entry points) */ +/* ARB_shader_atomic_counters */ +/* ARB_shader_image_load_store */ +/* ARB_shading_language_packing (no entry points) */ +/* ARB_texture_storage */ +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#endif + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#endif + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif + +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, const GLint *basevertex); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, const GLint *basevertex); +#endif + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +#endif + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); +#endif + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#endif + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#endif + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#endif + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#endif + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +#endif + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +#endif + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); +#endif + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +#endif + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +#endif + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +#endif + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +#endif + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GLAPI void APIENTRY glClearDepthf (GLfloat d); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +#endif + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +#endif + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* const *strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* const *strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +#endif + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#endif + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); +#endif + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); +#endif + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei primcount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); +#endif + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#endif + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +#endif + +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid* *params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIX_texture_select +#define GL_SGIX_texture_select 1 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean* *pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid* *data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +/* This is really a WGL extension, but defines some associated GL enums. + * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. + */ +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#endif + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#endif + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#endif + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#endif + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#endif + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#endif + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#endif + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +#endif + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +#endif + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#endif + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#endif + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#endif + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid* *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI GLvoid* APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid* *params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#endif + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#endif + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#endif + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#endif + +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#endif + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif + +#ifndef GL_AMD_vertex_shader_tesselator +#define GL_AMD_vertex_shader_tesselator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#endif + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#endif + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#endif + +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif + +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#endif + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#endif + +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#endif + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#endif + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#endif + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#endif + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#endif + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#endif + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#endif + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#endif + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#endif + +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +#endif + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif + +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#endif + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#endif + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif + +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#endif + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#endif + +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif + +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +#endif + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#endif + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#endif + +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#endif + +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +#endif + +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif + +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#endif + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/gl/api/wglext.h b/src/gl/api/wglext.h new file mode 100644 index 000000000..b5dc7bf7f --- /dev/null +++ b/src/gl/api/wglext.h @@ -0,0 +1,943 @@ +#ifndef __wglext_h_ +#define __wglext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2007-2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Function declaration macros - to move into glplatform.h */ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +/* Header file version number */ +/* wglext.h last updated 2012/01/04 */ +/* Current version at http://www.opengl.org/registry/ */ +#define WGL_WGLEXT_VERSION 24 + +#ifndef WGL_ARB_buffer_region +#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 +#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 +#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 +#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 +#endif + +#ifndef WGL_ARB_multisample +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 +#endif + +#ifndef WGL_ARB_extensions_string +#endif + +#ifndef WGL_ARB_pixel_format +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C +#endif + +#ifndef WGL_ARB_make_current_read +#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 +#endif + +#ifndef WGL_ARB_pbuffer +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 +#endif + +#ifndef WGL_ARB_render_texture +#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 +#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 +#define WGL_TEXTURE_FORMAT_ARB 0x2072 +#define WGL_TEXTURE_TARGET_ARB 0x2073 +#define WGL_MIPMAP_TEXTURE_ARB 0x2074 +#define WGL_TEXTURE_RGB_ARB 0x2075 +#define WGL_TEXTURE_RGBA_ARB 0x2076 +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 +#define WGL_TEXTURE_1D_ARB 0x2079 +#define WGL_TEXTURE_2D_ARB 0x207A +#define WGL_MIPMAP_LEVEL_ARB 0x207B +#define WGL_CUBE_MAP_FACE_ARB 0x207C +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 +#define WGL_FRONT_LEFT_ARB 0x2083 +#define WGL_FRONT_RIGHT_ARB 0x2084 +#define WGL_BACK_LEFT_ARB 0x2085 +#define WGL_BACK_RIGHT_ARB 0x2086 +#define WGL_AUX0_ARB 0x2087 +#define WGL_AUX1_ARB 0x2088 +#define WGL_AUX2_ARB 0x2089 +#define WGL_AUX3_ARB 0x208A +#define WGL_AUX4_ARB 0x208B +#define WGL_AUX5_ARB 0x208C +#define WGL_AUX6_ARB 0x208D +#define WGL_AUX7_ARB 0x208E +#define WGL_AUX8_ARB 0x208F +#define WGL_AUX9_ARB 0x2090 +#endif + +#ifndef WGL_ARB_pixel_format_float +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#endif + +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 +#endif + +#ifndef WGL_ARB_create_context +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define ERROR_INVALID_VERSION_ARB 0x2095 +#endif + +#ifndef WGL_ARB_create_context_profile +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define ERROR_INVALID_PROFILE_ARB 0x2096 +#endif + +#ifndef WGL_ARB_create_context_robustness +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif + +#ifndef WGL_EXT_make_current_read +#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 +#endif + +#ifndef WGL_EXT_pixel_format +#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 +#define WGL_DRAW_TO_WINDOW_EXT 0x2001 +#define WGL_DRAW_TO_BITMAP_EXT 0x2002 +#define WGL_ACCELERATION_EXT 0x2003 +#define WGL_NEED_PALETTE_EXT 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 +#define WGL_SWAP_METHOD_EXT 0x2007 +#define WGL_NUMBER_OVERLAYS_EXT 0x2008 +#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 +#define WGL_TRANSPARENT_EXT 0x200A +#define WGL_TRANSPARENT_VALUE_EXT 0x200B +#define WGL_SHARE_DEPTH_EXT 0x200C +#define WGL_SHARE_STENCIL_EXT 0x200D +#define WGL_SHARE_ACCUM_EXT 0x200E +#define WGL_SUPPORT_GDI_EXT 0x200F +#define WGL_SUPPORT_OPENGL_EXT 0x2010 +#define WGL_DOUBLE_BUFFER_EXT 0x2011 +#define WGL_STEREO_EXT 0x2012 +#define WGL_PIXEL_TYPE_EXT 0x2013 +#define WGL_COLOR_BITS_EXT 0x2014 +#define WGL_RED_BITS_EXT 0x2015 +#define WGL_RED_SHIFT_EXT 0x2016 +#define WGL_GREEN_BITS_EXT 0x2017 +#define WGL_GREEN_SHIFT_EXT 0x2018 +#define WGL_BLUE_BITS_EXT 0x2019 +#define WGL_BLUE_SHIFT_EXT 0x201A +#define WGL_ALPHA_BITS_EXT 0x201B +#define WGL_ALPHA_SHIFT_EXT 0x201C +#define WGL_ACCUM_BITS_EXT 0x201D +#define WGL_ACCUM_RED_BITS_EXT 0x201E +#define WGL_ACCUM_GREEN_BITS_EXT 0x201F +#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 +#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 +#define WGL_DEPTH_BITS_EXT 0x2022 +#define WGL_STENCIL_BITS_EXT 0x2023 +#define WGL_AUX_BUFFERS_EXT 0x2024 +#define WGL_NO_ACCELERATION_EXT 0x2025 +#define WGL_GENERIC_ACCELERATION_EXT 0x2026 +#define WGL_FULL_ACCELERATION_EXT 0x2027 +#define WGL_SWAP_EXCHANGE_EXT 0x2028 +#define WGL_SWAP_COPY_EXT 0x2029 +#define WGL_SWAP_UNDEFINED_EXT 0x202A +#define WGL_TYPE_RGBA_EXT 0x202B +#define WGL_TYPE_COLORINDEX_EXT 0x202C +#endif + +#ifndef WGL_EXT_pbuffer +#define WGL_DRAW_TO_PBUFFER_EXT 0x202D +#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E +#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 +#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 +#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 +#define WGL_PBUFFER_LARGEST_EXT 0x2033 +#define WGL_PBUFFER_WIDTH_EXT 0x2034 +#define WGL_PBUFFER_HEIGHT_EXT 0x2035 +#endif + +#ifndef WGL_EXT_depth_float +#define WGL_DEPTH_FLOAT_EXT 0x2040 +#endif + +#ifndef WGL_3DFX_multisample +#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 +#define WGL_SAMPLES_3DFX 0x2061 +#endif + +#ifndef WGL_EXT_multisample +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#define WGL_SAMPLES_EXT 0x2042 +#endif + +#ifndef WGL_I3D_digital_video_control +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 +#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 +#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 +#endif + +#ifndef WGL_I3D_gamma +#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E +#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F +#endif + +#ifndef WGL_I3D_genlock +#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 +#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045 +#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046 +#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047 +#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 +#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 +#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A +#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B +#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C +#endif + +#ifndef WGL_I3D_image_buffer +#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 +#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 +#endif + +#ifndef WGL_I3D_swap_frame_lock +#endif + +#ifndef WGL_NV_render_depth_texture +#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 +#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 +#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 +#define WGL_DEPTH_COMPONENT_NV 0x20A7 +#endif + +#ifndef WGL_NV_render_texture_rectangle +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 +#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 +#endif + +#ifndef WGL_ATI_pixel_format_float +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 +#endif + +#ifndef WGL_NV_float_buffer +#define WGL_FLOAT_COMPONENTS_NV 0x20B0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 +#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 +#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 +#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 +#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 +#endif + +#ifndef WGL_3DL_stereo_control +#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 +#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 +#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 +#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 +#endif + +#ifndef WGL_EXT_pixel_format_packed_float +#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 +#endif + +#ifndef WGL_EXT_framebuffer_sRGB +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 +#endif + +#ifndef WGL_NV_present_video +#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 +#endif + +#ifndef WGL_NV_video_out +#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 +#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 +#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 +#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 +#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 +#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 +#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define WGL_VIDEO_OUT_FRAME 0x20C8 +#define WGL_VIDEO_OUT_FIELD_1 0x20C9 +#define WGL_VIDEO_OUT_FIELD_2 0x20CA +#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB +#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC +#endif + +#ifndef WGL_NV_swap_group +#endif + +#ifndef WGL_NV_gpu_affinity +#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 +#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 +#endif + +#ifndef WGL_AMD_gpu_association +#define WGL_GPU_VENDOR_AMD 0x1F00 +#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 +#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define WGL_GPU_RAM_AMD 0x21A3 +#define WGL_GPU_CLOCK_AMD 0x21A4 +#define WGL_GPU_NUM_PIPES_AMD 0x21A5 +#define WGL_GPU_NUM_SIMD_AMD 0x21A6 +#define WGL_GPU_NUM_RB_AMD 0x21A7 +#define WGL_GPU_NUM_SPI_AMD 0x21A8 +#endif + +#ifndef WGL_NV_video_capture +#define WGL_UNIQUE_ID_NV 0x20CE +#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF +#endif + +#ifndef WGL_NV_copy_image +#endif + +#ifndef WGL_NV_multisample_coverage +#define WGL_COVERAGE_SAMPLES_NV 0x2042 +#define WGL_COLOR_SAMPLES_NV 0x20B9 +#endif + +#ifndef WGL_EXT_create_context_es2_profile +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#endif + +#ifndef WGL_NV_DX_interop +#define WGL_ACCESS_READ_ONLY_NV 0x00000000 +#define WGL_ACCESS_READ_WRITE_NV 0x00000001 +#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 +#endif + +#ifndef WGL_NV_DX_interop2 +#endif + +#ifndef WGL_EXT_swap_control_tear +#endif + + +/*************************************************************/ + +#ifndef WGL_ARB_pbuffer +DECLARE_HANDLE(HPBUFFERARB); +#endif +#ifndef WGL_EXT_pbuffer +DECLARE_HANDLE(HPBUFFEREXT); +#endif +#ifndef WGL_NV_present_video +DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); +#endif +#ifndef WGL_NV_video_output +DECLARE_HANDLE(HPVIDEODEV); +#endif +#ifndef WGL_NV_gpu_affinity +DECLARE_HANDLE(HPGPUNV); +DECLARE_HANDLE(HGPUNV); + +typedef struct _GPU_DEVICE { + DWORD cb; + CHAR DeviceName[32]; + CHAR DeviceString[128]; + DWORD Flags; + RECT rcVirtualScreen; +} GPU_DEVICE, *PGPU_DEVICE; +#endif +#ifndef WGL_NV_video_capture +DECLARE_HANDLE(HVIDEOINPUTDEVICENV); +#endif + +#ifndef WGL_ARB_buffer_region +#define WGL_ARB_buffer_region 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); +extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); +extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); +extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); +typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); +typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); +typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#endif + +#ifndef WGL_ARB_multisample +#define WGL_ARB_multisample 1 +#endif + +#ifndef WGL_ARB_extensions_string +#define WGL_ARB_extensions_string 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern const char * WINAPI wglGetExtensionsStringARB (HDC hdc); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +#endif + +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +extern BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif + +#ifndef WGL_ARB_make_current_read +#define WGL_ARB_make_current_read 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +extern HDC WINAPI wglGetCurrentReadDCARB (void); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); +#endif + +#ifndef WGL_ARB_pbuffer +#define WGL_ARB_pbuffer 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); +extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); +extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); +extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#endif + +#ifndef WGL_ARB_render_texture +#define WGL_ARB_render_texture 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); +#endif + +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float 1 +#endif + +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_ARB_framebuffer_sRGB 1 +#endif + +#ifndef WGL_ARB_create_context +#define WGL_ARB_create_context 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); +#endif + +#ifndef WGL_ARB_create_context_profile +#define WGL_ARB_create_context_profile 1 +#endif + +#ifndef WGL_ARB_create_context_robustness +#define WGL_ARB_create_context_robustness 1 +#endif + +#ifndef WGL_EXT_display_color_table +#define WGL_EXT_display_color_table 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); +extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); +extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); +extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); +typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); +#endif + +#ifndef WGL_EXT_extensions_string +#define WGL_EXT_extensions_string 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern const char * WINAPI wglGetExtensionsStringEXT (void); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); +#endif + +#ifndef WGL_EXT_make_current_read +#define WGL_EXT_make_current_read 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +extern HDC WINAPI wglGetCurrentReadDCEXT (void); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); +#endif + +#ifndef WGL_EXT_pbuffer +#define WGL_EXT_pbuffer 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); +extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); +extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); +extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#endif + +#ifndef WGL_EXT_pixel_format +#define WGL_EXT_pixel_format 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +extern BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif + +#ifndef WGL_EXT_swap_control +#define WGL_EXT_swap_control 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglSwapIntervalEXT (int interval); +extern int WINAPI wglGetSwapIntervalEXT (void); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); +typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); +#endif + +#ifndef WGL_EXT_depth_float +#define WGL_EXT_depth_float 1 +#endif + +#ifndef WGL_NV_vertex_array_range +#define WGL_NV_vertex_array_range 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern void* WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +extern void WINAPI wglFreeMemoryNV (void *pointer); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); +#endif + +#ifndef WGL_3DFX_multisample +#define WGL_3DFX_multisample 1 +#endif + +#ifndef WGL_EXT_multisample +#define WGL_EXT_multisample 1 +#endif + +#ifndef WGL_OML_sync_control +#define WGL_OML_sync_control 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +extern BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); +extern INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +extern BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +extern BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); +typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#endif + +#ifndef WGL_I3D_digital_video_control +#define WGL_I3D_digital_video_control 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); +extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +#endif + +#ifndef WGL_I3D_gamma +#define WGL_I3D_gamma 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); +extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); +extern BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +extern BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#endif + +#ifndef WGL_I3D_genlock +#define WGL_I3D_genlock 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglEnableGenlockI3D (HDC hDC); +extern BOOL WINAPI wglDisableGenlockI3D (HDC hDC); +extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); +extern BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); +extern BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); +extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); +extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); +extern BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); +extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); +extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); +extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); +extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); +typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); +typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#endif + +#ifndef WGL_I3D_image_buffer +#define WGL_I3D_image_buffer 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); +extern BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); +extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); +typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); +typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); +#endif + +#ifndef WGL_I3D_swap_frame_lock +#define WGL_I3D_swap_frame_lock 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglEnableFrameLockI3D (void); +extern BOOL WINAPI wglDisableFrameLockI3D (void); +extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); +extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); +#endif + +#ifndef WGL_I3D_swap_frame_usage +#define WGL_I3D_swap_frame_usage 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); +extern BOOL WINAPI wglBeginFrameTrackingI3D (void); +extern BOOL WINAPI wglEndFrameTrackingI3D (void); +extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); +typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#endif + +#ifndef WGL_ATI_pixel_format_float +#define WGL_ATI_pixel_format_float 1 +#endif + +#ifndef WGL_NV_float_buffer +#define WGL_NV_float_buffer 1 +#endif + +#ifndef WGL_3DL_stereo_control +#define WGL_3DL_stereo_control 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); +#endif + +#ifndef WGL_EXT_pixel_format_packed_float +#define WGL_EXT_pixel_format_packed_float 1 +#endif + +#ifndef WGL_EXT_framebuffer_sRGB +#define WGL_EXT_framebuffer_sRGB 1 +#endif + +#ifndef WGL_NV_present_video +#define WGL_NV_present_video 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +extern BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +extern BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); +#endif + +#ifndef WGL_NV_video_output +#define WGL_NV_video_output 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); +extern BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +extern BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); +extern BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +extern BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); +typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#endif + +#ifndef WGL_NV_swap_group +#define WGL_NV_swap_group 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); +extern BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); +extern BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); +extern BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +extern BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); +extern BOOL WINAPI wglResetFrameCountNV (HDC hDC); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); +typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); +typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); +typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); +typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); +#endif + +#ifndef WGL_NV_gpu_affinity +#define WGL_NV_gpu_affinity 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); +extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); +extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +extern BOOL WINAPI wglDeleteDCNV (HDC hdc); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); +typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); +typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); +#endif + +#ifndef WGL_AMD_gpu_association +#define WGL_AMD_gpu_association 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); +extern INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data); +extern UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); +extern HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); +extern HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); +extern BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); +extern BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); +extern HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); +extern VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); +typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data); +typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); +typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); +typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); +typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +#ifndef WGL_NV_video_capture +#define WGL_NV_video_capture 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +extern UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +extern BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +extern BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +extern BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#endif + +#ifndef WGL_NV_copy_image +#define WGL_NV_copy_image 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif + +#ifndef WGL_NV_multisample_coverage +#define WGL_NV_multisample_coverage 1 +#endif + +#ifndef WGL_NV_DX_interop +#define WGL_NV_DX_interop 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle); +extern HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice); +extern BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice); +extern HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +extern BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject); +extern BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access); +extern BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +extern BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle); +typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice); +typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); +typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); +typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +#endif + +#ifndef WGL_NV_DX_interop2 +#define WGL_NV_DX_interop2 1 +#endif + +#ifndef WGL_EXT_swap_control_tear +#define WGL_EXT_swap_control_tear 1 +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h index 0a0fc7017..8a0c307fc 100644 --- a/src/gl/system/gl_system.h +++ b/src/gl/system/gl_system.h @@ -72,13 +72,13 @@ #else // !__APPLE__ #include #include -#include +#include "gl/api/glext.h" // use the local copy #endif // __APPLE__ #include "gl/api/gl_api.h" #ifdef _WIN32 #define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code! -#include +#include "gl/api/wglext.h" #ifndef __WINE__ #undef DWORD #endif From 0ff21c3af7678c44c9947d8714a85d4980f8d90b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Sep 2013 10:28:12 +0200 Subject: [PATCH 0030/1509] - fixed: Sprites may never be used as a base of a texture redirect Due to autoexpansion to remove filtering artifacts their dimensions are not the same as for patches. But if the sprite hadn't been used yet this information won't have been set yet. --- src/gl/textures/gl_material.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index b77920d57..ebfcbc002 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -671,12 +671,14 @@ FMaterial::FMaterial(FTexture * tx, bool forceexpand) tx->gl_info.mExpanded = expanded; FTexture *basetex = tx->GetRedirect(gl.shadermodel < 4); - if (!expanded && !basetex->gl_info.mExpanded) + if (!expanded && !basetex->gl_info.mExpanded && basetex->UseType != FTexture::TEX_Sprite) { // check if the texture is just a simple redirect to a patch // If so we should use the patch for texture creation to // avoid eventual redundancies. // This may only be done if both textures use the same expansion mode + // Redirects to sprites are not permitted because sprites get expanded, however, this won't have been set + // if the sprite hadn't been used yet. mBaseLayer = ValidateSysTexture(basetex, false); } else if (!expanded) From 841572d0ec6d4a9dcd1a2762e109ea313724f7ff Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Sep 2013 10:32:47 +0200 Subject: [PATCH 0031/1509] - fixed: The dynamic light definition for Hexen's FireBull was incorrect. --- wadsrc_lights/static/hexndefs.txt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/wadsrc_lights/static/hexndefs.txt b/wadsrc_lights/static/hexndefs.txt index e7f53e74c..ae062bd85 100644 --- a/wadsrc_lights/static/hexndefs.txt +++ b/wadsrc_lights/static/hexndefs.txt @@ -1246,6 +1246,15 @@ flickerlight2 FIREBULL offset 0 40 0 } +flickerlight2 FIREBULL2 +{ + color 1.0 0.7 0.0 + size 48 + secondarySize 60 + interval 0.1 + offset 0 40 0 +} + object ZFireBull { frame FBULA { light FIREBULL } @@ -1255,7 +1264,8 @@ object ZFireBull frame FBULE { light FIREBULL } frame FBULF { light FIREBULL } frame FBULG { light FIREBULL } - frame FBULH { light FIREBULL } + frame FBULI { light FIREBULL2 } + frame FBULJ { light FIREBULL } } object ZFireBullUnlit @@ -1267,7 +1277,8 @@ object ZFireBullUnlit frame FBULE { light FIREBULL } frame FBULF { light FIREBULL } frame FBULG { light FIREBULL } - frame FBULH { light FIREBULL } + frame FBULI { light FIREBULL2 } + frame FBULJ { light FIREBULL } } From 5f08111a34242c4917f5682a4290b92273964160 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 28 Sep 2013 23:33:55 +0200 Subject: [PATCH 0032/1509] - fixed: The GL voxel palette loader needs to handle the case when the voxel has no own palette and used the game's base palette instead. Also added an implementation for GetPixels because this is used when a voxel needs a translated palette. --- src/gl/models/gl_voxels.cpp | 64 +++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index e81c6531c..85b46185b 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -46,6 +46,7 @@ #include "g_game.h" #include "doomstat.h" #include "g_level.h" +#include "colormatcher.h" #include "textures/bitmap.h" //#include "gl/gl_intern.h" @@ -84,6 +85,7 @@ public: protected: FVoxel *SourceVox; + BYTE *Pixels; }; @@ -101,6 +103,7 @@ FVoxelTexture::FVoxelTexture(FVoxel *vox) WidthBits = 4; HeightBits = 4; WidthMask = 15; + Pixels = NULL; gl_info.bNoFilter = true; gl_info.bNoCompress = true; } @@ -123,12 +126,42 @@ const BYTE *FVoxelTexture::GetColumn (unsigned int column, const Span **spans_ou const BYTE *FVoxelTexture::GetPixels () { - // not needed - return NULL; + // GetPixels gets called when a translated palette is used so we still need to implement it here. + if (Pixels == NULL) + { + Pixels = new BYTE[256]; + + BYTE *pp = SourceVox->Palette; + + if(pp != NULL) + { + for(int i=0;i<256;i++, pp+=3) + { + PalEntry pe; + pe.r = (pp[0] << 2) | (pp[0] >> 4); + pe.g = (pp[1] << 2) | (pp[1] >> 4); + pe.b = (pp[2] << 2) | (pp[2] >> 4); + Pixels[i] = ColorMatcher.Pick(pe); + } + } + else + { + for(int i=0;i<256;i++, pp+=3) + { + Pixels[i] = (BYTE)i; + } + } + } + return Pixels; } void FVoxelTexture::Unload () { + if (Pixels != NULL) + { + delete[] Pixels; + Pixels = NULL; + } } //=========================================================================== @@ -146,15 +179,26 @@ int FVoxelTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, F BYTE bitmap[256]; BYTE *pp = SourceVox->Palette; - for(int i=0;i<256;i++, pp+=3) + if(pp != NULL) { - bitmap[i] = (BYTE)i; - pe[i].r = (pp[0] << 2) | (pp[0] >> 4); - pe[i].g = (pp[1] << 2) | (pp[1] >> 4); - pe[i].b = (pp[2] << 2) | (pp[2] >> 4); - pe[i].a = 255; - } - + for(int i=0;i<256;i++, pp+=3) + { + bitmap[i] = (BYTE)i; + pe[i].r = (pp[0] << 2) | (pp[0] >> 4); + pe[i].g = (pp[1] << 2) | (pp[1] >> 4); + pe[i].b = (pp[2] << 2) | (pp[2] >> 4); + pe[i].a = 255; + } + } + else + { + for(int i=0;i<256;i++, pp+=3) + { + bitmap[i] = (BYTE)i; + pe[i] = GPalette.BaseColors[i]; + pe[i].a = 255; + } + } bmp->CopyPixelData(x, y, bitmap, Width, Height, 1, 16, rotate, pe, inf); return 0; } From 834678af2f64929bdb96c176daa23bdc3efa049b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 29 Sep 2013 09:51:01 +0200 Subject: [PATCH 0033/1509] - changes to project file for last ZDoom update. --- gzdoom.vcproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gzdoom.vcproj b/gzdoom.vcproj index b24dfce18..9bc3aa271 100644 --- a/gzdoom.vcproj +++ b/gzdoom.vcproj @@ -711,6 +711,10 @@ RelativePath=".\src\m_random.cpp" > + + From a338248e3eac546e3a5993f6cbddcef706db4f19 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 3 Oct 2013 12:08:57 +0200 Subject: [PATCH 0034/1509] - converted project to Visual Studio 2008 format. I own a full professional version of 2008 and 2005 is having some stability issues with Windows 7 so it makes no sense to stick to the old compiler. --- bzip2/bzip2.vcproj | 3 +- dumb/vc6/dumb_static/dumb_static.vcproj | 3 +- game-music-emu/game-music-emu.vcproj | 183 +++-- gdtoa/gdtoa.vcproj | 3 +- gzdoom.sln | 4 +- gzdoom.vcproj | 775 +++++++++++---------- jpeg-6b/jpeg-6b.vcproj | 3 +- lzma/lzmalib.vcproj | 3 +- tools/fixrtext/fixrtext.vcproj | 13 +- tools/lemon/lemon.vcproj | 23 +- tools/re2c/re2c.vcproj | 23 +- tools/updaterevision/updaterevision.vcproj | 171 +++-- tools/zipdir/zipdir.vcproj | 23 +- wadsrc/wadsrc.vcproj | 11 +- wadsrc_bm/brightmaps.vcproj | 49 +- wadsrc_lights/lights.vcproj | 49 +- zlib/zlib.vcproj | 17 +- 17 files changed, 676 insertions(+), 680 deletions(-) diff --git a/bzip2/bzip2.vcproj b/bzip2/bzip2.vcproj index 72510949d..4b8aef564 100644 --- a/bzip2/bzip2.vcproj +++ b/bzip2/bzip2.vcproj @@ -1,11 +1,12 @@ @@ -174,8 +172,8 @@ EnableIntrinsicFunctions="true" FavorSizeOrSpeed="1" OmitFramePointers="true" - WholeProgramOptimization="true" - PreprocessorDefinitions="WIN32;NDEBUG;GME_DLL" + WholeProgramOptimization="false" + PreprocessorDefinitions="WIN32;NDEBUG;_LIB" StringPooling="true" ExceptionHandling="0" RuntimeLibrary="0" @@ -193,78 +191,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -351,6 +277,80 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + + + - diff --git a/gdtoa/gdtoa.vcproj b/gdtoa/gdtoa.vcproj index 7195c1457..b179daaf0 100644 --- a/gdtoa/gdtoa.vcproj +++ b/gdtoa/gdtoa.vcproj @@ -1,11 +1,12 @@ + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - @@ -440,6 +440,8 @@ StackReserveSize="0" TerminalServerAware="2" SetChecksum="false" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="17" /> - @@ -977,7 +976,7 @@ /> - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - @@ -1859,6 +1850,14 @@ Outputs="$(IntDir)/$(InputName).obj" /> + + + @@ -2235,7 +2234,7 @@ /> + + + @@ -2456,14 +2463,6 @@ AdditionalIncludeDirectories="src\win32;$(NoInherit)" /> - - - @@ -2778,7 +2777,7 @@ /> + + + + + + + + + - - - - @@ -138,6 +138,8 @@ SubSystem="1" OptimizeReferences="2" EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="1" /> - diff --git a/tools/lemon/lemon.vcproj b/tools/lemon/lemon.vcproj index 9f46d4df9..d3205b967 100644 --- a/tools/lemon/lemon.vcproj +++ b/tools/lemon/lemon.vcproj @@ -1,11 +1,12 @@ - @@ -159,6 +159,8 @@ OptimizeReferences="2" EnableCOMDATFolding="2" OptimizeForWindows98="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="17" /> - @@ -241,6 +240,8 @@ OptimizeReferences="2" EnableCOMDATFolding="2" OptimizeForWindows98="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="1" /> - @@ -325,6 +323,8 @@ OptimizeReferences="2" EnableCOMDATFolding="2" OptimizeForWindows98="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="17" /> - diff --git a/tools/re2c/re2c.vcproj b/tools/re2c/re2c.vcproj index c10906185..5d82bd460 100644 --- a/tools/re2c/re2c.vcproj +++ b/tools/re2c/re2c.vcproj @@ -1,11 +1,12 @@ - @@ -156,6 +156,8 @@ OptimizeReferences="2" EnableCOMDATFolding="2" OptimizeForWindows98="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="17" /> - @@ -237,6 +236,8 @@ OptimizeReferences="2" EnableCOMDATFolding="2" OptimizeForWindows98="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="1" /> - @@ -320,6 +318,8 @@ OptimizeReferences="2" EnableCOMDATFolding="2" OptimizeForWindows98="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="17" /> - diff --git a/tools/updaterevision/updaterevision.vcproj b/tools/updaterevision/updaterevision.vcproj index 0421cbb65..17675b681 100644 --- a/tools/updaterevision/updaterevision.vcproj +++ b/tools/updaterevision/updaterevision.vcproj @@ -1,11 +1,12 @@ - - - - - - - - - - - - - - - - - - - - - @@ -221,6 +144,8 @@ LinkIncremental="2" GenerateDebugInformation="true" SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="17" /> + + + + + + + + + + + + + + + + + + - @@ -349,7 +346,7 @@ /> - - - - diff --git a/wadsrc_bm/brightmaps.vcproj b/wadsrc_bm/brightmaps.vcproj index 12581c338..eaf6a4729 100644 --- a/wadsrc_bm/brightmaps.vcproj +++ b/wadsrc_bm/brightmaps.vcproj @@ -1,11 +1,12 @@ + + + + + + - - - - - - diff --git a/wadsrc_lights/lights.vcproj b/wadsrc_lights/lights.vcproj index 6f5a0e641..b3b2cc5d4 100644 --- a/wadsrc_lights/lights.vcproj +++ b/wadsrc_lights/lights.vcproj @@ -1,11 +1,12 @@ + + + + + + - - - - - - diff --git a/zlib/zlib.vcproj b/zlib/zlib.vcproj index 3e0ba5ff7..06d9ed48c 100644 --- a/zlib/zlib.vcproj +++ b/zlib/zlib.vcproj @@ -1,10 +1,11 @@ - - - - - - Date: Thu, 3 Oct 2013 12:12:19 +0200 Subject: [PATCH 0035/1509] - fixed: Warped textures were recreated each time they were bound. - fixed: Models were never freed. --- src/gl/models/gl_models.cpp | 2 +- src/gl/textures/gl_material.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index a59666d04..39668cd02 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -78,7 +78,7 @@ class DeletingModelArray : public TArray { public: -#if 0 +#if 1 ~DeletingModelArray() { for(unsigned i=0;ibHasCanvas) && tex->CheckModified()) + // Texture has become invalid - this is only for special textures, not the regular warping, which is handled above + else if ((warp == 0 && !tex->bHasCanvas && !tex->bWarped) && tex->CheckModified()) { Clean(true); hwtex = CreateTexture(clampmode); @@ -480,8 +480,8 @@ const FHardwareTexture * FGLTexture::BindPatch(int texunit, int cm, int translat CreatePatch(); } - // Texture has become invalid - else if ((warp == 0 && !tex->bHasCanvas) && tex->CheckModified()) + // Texture has become invalid - this is only for special textures, not the regular warping, which is handled above + else if ((warp == 0 && !tex->bHasCanvas && !tex->bWarped) && tex->CheckModified()) { Clean(true); CreatePatch(); From 759139e6f331c202cfae836f7391856abb8a9922 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Sat, 5 Oct 2013 14:48:26 -0400 Subject: [PATCH 0036/1509] - Fixed compilation with Visual Studio using CMake project by using slightly modified version of the code in Zandronum's changeset 597309d. --- src/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cbfaa3fa0..2aa27a4ce 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -581,6 +581,17 @@ if( WIN32 ) else( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) set( SYSTEM_SOURCES ${SYSTEM_SOURCES} win32/zdoom.rc ) endif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + + # [BB] Maxim Stepin's hq2x/3x/4x pixel upsampling algorithm as library. Currently only used with VC++. + if( MSVC ) + set( SYSTEM_SOURCES + ${SYSTEM_SOURCES} + gl/hqnx/Image.cpp + gl/hqnx/hq2x.cpp + gl/hqnx/hq3x.cpp + gl/hqnx/hq4x.cpp + ) + endif( MSVC ) else( WIN32 ) set( SYSTEM_SOURCES_DIR sdl ) set( SYSTEM_SOURCES From f239a40caaf2677a746f65f22c3079b4f03441aa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 9 Oct 2013 12:16:08 +0200 Subject: [PATCH 0037/1509] - fixed CMakeLists to generate working VC++ projects. --- src/CMakeLists.txt | 17 +++ src/gl/hqnx/gl_hqresize.cpp | 280 ------------------------------------ 2 files changed, 17 insertions(+), 280 deletions(-) delete mode 100644 src/gl/hqnx/gl_hqresize.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d4841d856..f161a068f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -78,6 +78,7 @@ if( WIN32 ) "C:/Program Files/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" "C:/Program Files (x86)/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" # This next one is for me. + "D:/portable/FMOD SoundSystem 4.26/FMOD Programmers API WIN32/api" "E:/Software/Dev/FMOD/${WIN_TYPE}/api" ) set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES inc ) set( FMOD_LIB_PATH_SUFFIXES PATH_SUFFIXES lib ) @@ -549,6 +550,10 @@ endif( APPLE ) # Start defining source files for ZDoom set( PLAT_WIN32_SOURCES + gl/hqnx/hq2x.cpp + gl/hqnx/hq3x.cpp + gl/hqnx/hq4x.cpp + gl/hqnx/Image.cpp win32/eaxedit.cpp win32/fb_d3d9.cpp win32/fb_d3d9_wipe.cpp @@ -685,6 +690,18 @@ file( GLOB HEADER_FILES textures/*.h thingdef/*.h xlat/*.h + gl/*.h + gl/api/*.h + gl/data/*.h + gl/dynlights/*.h + gl/hqnx/*.h + gl/models/*.h + gl/renderer/*.h + gl/scene/*.h + gl/shaders/*.h + gl/system/*.h + gl/textures/*.h + gl/utility/*.h *.h ) diff --git a/src/gl/hqnx/gl_hqresize.cpp b/src/gl/hqnx/gl_hqresize.cpp deleted file mode 100644 index 2aa8f2085..000000000 --- a/src/gl/hqnx/gl_hqresize.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/* -** gl_hqresize.cpp -** Contains high quality upsampling functions. -** So far supports Scale2x/3x/4x as described in http://scale2x.sourceforge.net/ -** and Maxim Stepin's hq2x/3x/4x. -** -**--------------------------------------------------------------------------- -** Copyright 2008-2009 Benjamin Berkels -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ - -#include "gl_pch.h" -#include "gl_hqresize.h" -#include "gl_intern.h" -#include "c_cvars.h" -// [BB] hqnx scaling is only supported with the MS compiler. -#ifdef _MSC_VER -#include "../hqnx/hqnx.h" -#endif - -CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ -#ifdef _MSC_VER - if (self < 0 || self > 6) -#else - if (self < 0 || self > 3) -#endif - self = 0; - FGLTexture::FlushAll(); -} - -CUSTOM_CVAR(Int, gl_texture_hqresize_maxinputsize, 512, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ - if (self > 1024) self = 1024; - FGLTexture::FlushAll(); -} - -CUSTOM_CVAR(Int, gl_texture_hqresize_targets, 7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ - FGLTexture::FlushAll(); -} - -CVAR (Flag, gl_texture_hqresize_textures, gl_texture_hqresize_targets, 1); -CVAR (Flag, gl_texture_hqresize_sprites, gl_texture_hqresize_targets, 2); -CVAR (Flag, gl_texture_hqresize_fonts, gl_texture_hqresize_targets, 4); - - -static void scale2x ( uint32* inputBuffer, uint32* outputBuffer, int inWidth, int inHeight ) -{ - const int width = 2* inWidth; - const int height = 2 * inHeight; - - for ( int i = 0; i < inWidth; ++i ) - { - const int iMinus = (i > 0) ? (i-1) : 0; - const int iPlus = (i < inWidth - 1 ) ? (i+1) : i; - for ( int j = 0; j < inHeight; ++j ) - { - const int jMinus = (j > 0) ? (j-1) : 0; - const int jPlus = (j < inHeight - 1 ) ? (j+1) : j; - const uint32 A = inputBuffer[ iMinus +inWidth*jMinus]; - const uint32 B = inputBuffer[ iMinus +inWidth*j ]; - const uint32 C = inputBuffer[ iMinus +inWidth*jPlus]; - const uint32 D = inputBuffer[ i +inWidth*jMinus]; - const uint32 E = inputBuffer[ i +inWidth*j ]; - const uint32 F = inputBuffer[ i +inWidth*jPlus]; - const uint32 G = inputBuffer[ iPlus +inWidth*jMinus]; - const uint32 H = inputBuffer[ iPlus +inWidth*j ]; - const uint32 I = inputBuffer[ iPlus +inWidth*jPlus]; - if (B != H && D != F) { - outputBuffer[2*i + width*2*j ] = D == B ? D : E; - outputBuffer[2*i + width*(2*j+1)] = B == F ? F : E; - outputBuffer[2*i+1 + width*2*j ] = D == H ? D : E; - outputBuffer[2*i+1 + width*(2*j+1)] = H == F ? F : E; - } else { - outputBuffer[2*i + width*2*j ] = E; - outputBuffer[2*i + width*(2*j+1)] = E; - outputBuffer[2*i+1 + width*2*j ] = E; - outputBuffer[2*i+1 + width*(2*j+1)] = E; - } - } - } -} - -static void scale3x ( uint32* inputBuffer, uint32* outputBuffer, int inWidth, int inHeight ) -{ - const int width = 3* inWidth; - const int height = 3 * inHeight; - - for ( int i = 0; i < inWidth; ++i ) - { - const int iMinus = (i > 0) ? (i-1) : 0; - const int iPlus = (i < inWidth - 1 ) ? (i+1) : i; - for ( int j = 0; j < inHeight; ++j ) - { - const int jMinus = (j > 0) ? (j-1) : 0; - const int jPlus = (j < inHeight - 1 ) ? (j+1) : j; - const uint32 A = inputBuffer[ iMinus +inWidth*jMinus]; - const uint32 B = inputBuffer[ iMinus +inWidth*j ]; - const uint32 C = inputBuffer[ iMinus +inWidth*jPlus]; - const uint32 D = inputBuffer[ i +inWidth*jMinus]; - const uint32 E = inputBuffer[ i +inWidth*j ]; - const uint32 F = inputBuffer[ i +inWidth*jPlus]; - const uint32 G = inputBuffer[ iPlus +inWidth*jMinus]; - const uint32 H = inputBuffer[ iPlus +inWidth*j ]; - const uint32 I = inputBuffer[ iPlus +inWidth*jPlus]; - if (B != H && D != F) { - outputBuffer[3*i + width*3*j ] = D == B ? D : E; - outputBuffer[3*i + width*(3*j+1)] = (D == B && E != C) || (B == F && E != A) ? B : E; - outputBuffer[3*i + width*(3*j+2)] = B == F ? F : E; - outputBuffer[3*i+1 + width*3*j ] = (D == B && E != G) || (D == H && E != A) ? D : E; - outputBuffer[3*i+1 + width*(3*j+1)] = E; - outputBuffer[3*i+1 + width*(3*j+2)] = (B == F && E != I) || (H == F && E != C) ? F : E; - outputBuffer[3*i+2 + width*3*j ] = D == H ? D : E; - outputBuffer[3*i+2 + width*(3*j+1)] = (D == H && E != I) || (H == F && E != G) ? H : E; - outputBuffer[3*i+2 + width*(3*j+2)] = H == F ? F : E; - } else { - outputBuffer[3*i + width*3*j ] = E; - outputBuffer[3*i + width*(3*j+1)] = E; - outputBuffer[3*i + width*(3*j+2)] = E; - outputBuffer[3*i+1 + width*3*j ] = E; - outputBuffer[3*i+1 + width*(3*j+1)] = E; - outputBuffer[3*i+1 + width*(3*j+2)] = E; - outputBuffer[3*i+2 + width*3*j ] = E; - outputBuffer[3*i+2 + width*(3*j+1)] = E; - outputBuffer[3*i+2 + width*(3*j+2)] = E; - } - } - } -} - -static void scale4x ( uint32* inputBuffer, uint32* outputBuffer, int inWidth, int inHeight ) -{ - int width = 2* inWidth; - int height = 2 * inHeight; - uint32 * buffer2x = new uint32[width*height]; - - scale2x ( reinterpret_cast ( inputBuffer ), reinterpret_cast ( buffer2x ), inWidth, inHeight ); - width *= 2; - height *= 2; - scale2x ( reinterpret_cast ( buffer2x ), reinterpret_cast ( outputBuffer ), 2*inWidth, 2*inHeight ); - delete[] buffer2x; -} - - -static unsigned char *scaleNxHelper( void (*scaleNxFunction) ( uint32* , uint32* , int , int), - const int N, - unsigned char *inputBuffer, - const int inWidth, - const int inHeight, - int &outWidth, - int &outHeight ) -{ - outWidth = N * inWidth; - outHeight = N *inHeight; - unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; - - scaleNxFunction ( reinterpret_cast ( inputBuffer ), reinterpret_cast ( newBuffer ), inWidth, inHeight ); - delete[] inputBuffer; - return newBuffer; -} - -// [BB] hqnx scaling is only supported with the MS compiler. -#ifdef _MSC_VER -static unsigned char *hqNxHelper( void (*hqNxFunction) ( int*, unsigned char*, int, int, int ), - const int N, - unsigned char *inputBuffer, - const int inWidth, - const int inHeight, - int &outWidth, - int &outHeight ) -{ - outWidth = N * inWidth; - outHeight = N *inHeight; - - CImage cImageIn; - cImageIn.SetImage(inputBuffer, inWidth, inHeight, 32); - cImageIn.Convert32To17(); - - unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; - hqNxFunction( reinterpret_cast(cImageIn.m_pBitmap), newBuffer, cImageIn.m_Xres, cImageIn.m_Yres, outWidth*4 ); - delete[] inputBuffer; - return newBuffer; -} -#endif - -//=========================================================================== -// -// [BB] Upsamples the texture in inputBuffer, frees inputBuffer and returns -// the upsampled buffer. -// -//=========================================================================== -unsigned char *gl_CreateUpsampledTextureBuffer ( const FGLTexture *inputGLTexture, unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight ) -{ - // [BB] Make sure that outWidth and outHeight denote the size of - // the returned buffer even if we don't upsample the input buffer. - outWidth = inWidth; - outHeight = inHeight; - - // [BB] Don't resample if the width or height of the input texture is bigger than gl_texture_hqresize_maxinputsize. - if ( ( inWidth > gl_texture_hqresize_maxinputsize ) || ( inHeight > gl_texture_hqresize_maxinputsize ) ) - return inputBuffer; - - // [BB] The hqnx upsampling (not the scaleN one) destroys partial transparency, don't upsamle textures using it. - if ( inputGLTexture->bIsTransparent == 1 ) - return inputBuffer; - - // [BB] Don't try to upsample textures based off FCanvasTexture. - if ( inputGLTexture->tex->bHasCanvas ) - return inputBuffer; - - // [BB] Don't upsample non-shader handled warped textures. Needs too much memory. - if ( (!(gl.flags & RFL_GLSL) || !gl_warp_shader) && inputGLTexture->tex->bWarped ) - return inputBuffer; - - switch (inputGLTexture->tex->UseType) - { - case FTexture::TEX_Sprite: - case FTexture::TEX_SkinSprite: - if (!(gl_texture_hqresize_targets & 2)) return inputBuffer; - break; - - case FTexture::TEX_FontChar: - if (!(gl_texture_hqresize_targets & 4)) return inputBuffer; - break; - - default: - if (!(gl_texture_hqresize_targets & 1)) return inputBuffer; - break; - } - - if (inputBuffer) - { - int type = gl_texture_hqresize; - switch (type) - { - case 1: - return scaleNxHelper( &scale2x, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight ); - case 2: - return scaleNxHelper( &scale3x, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); - case 3: - return scaleNxHelper( &scale4x, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); -// [BB] hqnx scaling is only supported with the MS compiler. -#ifdef _MSC_VER - case 4: - return hqNxHelper( &hq2x_32, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight ); - case 5: - return hqNxHelper( &hq3x_32, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); - case 6: - return hqNxHelper( &hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); -#endif - } - } - return inputBuffer; -} From 41856905be8b1ab73909dabecf29e7273750ece7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 9 Oct 2013 13:06:18 +0200 Subject: [PATCH 0038/1509] - CMake: The GL renderer requires fast Floating point math or performance will go down the drain. - added CMake 'build' directory to .gitignore. --- .gitignore | 1 + CMakeLists.txt | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 05a759c8b..d1304b75b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ /Release /wadsrc_wad *.user +/build /debug /release */debug diff --git a/CMakeLists.txt b/CMakeLists.txt index a7bae2b4c..fb335c1f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,8 @@ if( MSVC ) # String pooling # Function-level linking # Disable run-time type information - set( ALL_C_FLAGS "/GF /Gy /GR-" ) + # Set floating point model to fast or the GL render will suffer for it. + set( ALL_C_FLAGS "/GF /Gy /GR- /fp:fast" ) # Avoid CRT DLL dependancies in release builds set( REL_C_FLAGS "/MT" ) From d89ece580272ae6abb3f8c0de45333f9afdcf47a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 9 Oct 2013 13:08:49 +0200 Subject: [PATCH 0039/1509] - removed duplicate HQNX entries in CMakeLists.txt --- src/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3dd61c128..e4bbcb8ca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -550,10 +550,6 @@ endif( APPLE ) # Start defining source files for ZDoom set( PLAT_WIN32_SOURCES - gl/hqnx/hq2x.cpp - gl/hqnx/hq3x.cpp - gl/hqnx/hq4x.cpp - gl/hqnx/Image.cpp win32/eaxedit.cpp win32/fb_d3d9.cpp win32/fb_d3d9_wipe.cpp From cb74dd99efd69c0a1dae9be31edef35436146982 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 9 Oct 2013 15:54:56 +0200 Subject: [PATCH 0040/1509] - MSVC Release also needs the /Oi option for best performance. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb335c1f1..f929ee11d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ if( MSVC ) set( ALL_C_FLAGS "/GF /Gy /GR- /fp:fast" ) # Avoid CRT DLL dependancies in release builds - set( REL_C_FLAGS "/MT" ) + set( REL_C_FLAGS "/MT /Oi" ) # Debug allocations in debug builds set( DEB_C_FLAGS "/D _CRTDBG_MAP_ALLOC" ) From b6dab83d2b3a40fa1b414ff60d7fffd34b7d57d1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 10 Oct 2013 23:13:56 +0200 Subject: [PATCH 0041/1509] - removed constructor and destructor from FDMDModel::ModelFrame because they were redundant and only caused double deletion of its contents. --- src/gl/models/gl_models.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index c3d564f9d..9535b16ae 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -94,17 +94,6 @@ protected: char name[16]; FModelVertex *vertices; FModelVertex *normals; - - ModelFrame() - { - vertices = normals = NULL; - } - - ~ModelFrame() - { - if (vertices) delete [] vertices; - if (normals) delete [] normals; - } }; struct DMDLoDInfo From 0f8ed0123fe33324a028217708f404cc3e53f527 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 11 Oct 2013 01:04:54 +0200 Subject: [PATCH 0042/1509] - fixed: Models must not delete their skin textures because they are stored in the texture manager which will be responsible for doing this. --- src/gl/models/gl_models.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 9535b16ae..5d474dd8d 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -201,7 +201,6 @@ class FMD3Model : public FModel if (tris) delete [] tris; if (vertices) delete [] vertices; if (texcoords) delete [] texcoords; - for (int i=0;i Date: Fri, 11 Oct 2013 12:57:46 +0200 Subject: [PATCH 0043/1509] - fixed: Since model skins are managed by the texture manager, the model code may not delete them itself. --- src/gl/models/gl_models_md2.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index f5ac5d2bf..244ec064d 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -222,10 +222,7 @@ FDMDModel::~FDMDModel() // clean up if (skins != NULL) { - for (i=0;i Date: Wed, 20 Nov 2013 23:12:13 +0100 Subject: [PATCH 0044/1509] - deleted obsolete VC++2008 solution. Please use CMake to generate VC++ projects from now on. --- gzdoom.vcproj | 7222 ------------------------------------------------- 1 file changed, 7222 deletions(-) delete mode 100644 gzdoom.vcproj diff --git a/gzdoom.vcproj b/gzdoom.vcproj deleted file mode 100644 index ec5c998db..000000000 --- a/gzdoom.vcproj +++ /dev/null @@ -1,7222 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From cdd0aef1ce51fd76ac936d63442aa90dea811913 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Nov 2013 10:20:24 +0100 Subject: [PATCH 0045/1509] - fixed: HQnX must be excluded on Win64 builds. --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c5fada0c4..c8e3fcf60 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -610,7 +610,7 @@ if( WIN32 ) endif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) # [BB] Maxim Stepin's hq2x/3x/4x pixel upsampling algorithm as library. Currently only used with VC++. - if( MSVC ) + if( MSVC AND NOT X64 ) set( SYSTEM_SOURCES ${SYSTEM_SOURCES} gl/hqnx/Image.cpp @@ -618,7 +618,7 @@ if( WIN32 ) gl/hqnx/hq3x.cpp gl/hqnx/hq4x.cpp ) - endif( MSVC ) + endif( MSVC AND NOT X64) else( WIN32 ) set( SYSTEM_SOURCES_DIR sdl ) set( SYSTEM_SOURCES ${PLAT_SDL_SOURCES} ) From e4282d3554f79a0d9baf616a35a6f5f0e904ef67 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Nov 2013 12:34:55 +0100 Subject: [PATCH 0046/1509] - added error check to GL getProcAddress calls to spot driver errors. --- src/gl/system/gl_interface.cpp | 174 +++++++++++++++++---------------- 1 file changed, 90 insertions(+), 84 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index cadab5af9..b70a103f3 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -59,6 +59,12 @@ RenderContext gl; int occlusion_type=0; +PROC myGetProcAddress(LPCSTR proc) +{ + PROC p = wglGetProcAddress(proc); + if (p == NULL) I_Error("Fatal: GL function '%s' not found."); + return p; +} //========================================================================== @@ -173,64 +179,64 @@ void gl_LoadExtensions() if (gl.flags & RFL_GL_20) { - glDeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader"); - glDeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram"); - glDetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader"); - glCreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader"); - glShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource"); - glCompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader"); - glCreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram"); - glAttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader"); - glLinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram"); - glUseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"); - glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)wglGetProcAddress("glValidateProgram"); + glDeleteShader = (PFNGLDELETESHADERPROC)myGetProcAddress("glDeleteShader"); + glDeleteProgram = (PFNGLDELETEPROGRAMPROC)myGetProcAddress("glDeleteProgram"); + glDetachShader = (PFNGLDETACHSHADERPROC)myGetProcAddress("glDetachShader"); + glCreateShader = (PFNGLCREATESHADERPROC)myGetProcAddress("glCreateShader"); + glShaderSource = (PFNGLSHADERSOURCEPROC)myGetProcAddress("glShaderSource"); + glCompileShader = (PFNGLCOMPILESHADERPROC)myGetProcAddress("glCompileShader"); + glCreateProgram = (PFNGLCREATEPROGRAMPROC)myGetProcAddress("glCreateProgram"); + glAttachShader = (PFNGLATTACHSHADERPROC)myGetProcAddress("glAttachShader"); + glLinkProgram = (PFNGLLINKPROGRAMPROC)myGetProcAddress("glLinkProgram"); + glUseProgram = (PFNGLUSEPROGRAMPROC)myGetProcAddress("glUseProgram"); + glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)myGetProcAddress("glValidateProgram"); - glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)wglGetProcAddress("glVertexAttrib1f"); - glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)wglGetProcAddress("glVertexAttrib2f"); - glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)wglGetProcAddress("glVertexAttrib4f"); - glVertexAttrib2fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib2fv"); - glVertexAttrib3fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib3fv"); - glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv"); - glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)wglGetProcAddress("glVertexAttrib4ubv"); - glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation"); - glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation"); + glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)myGetProcAddress("glVertexAttrib1f"); + glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)myGetProcAddress("glVertexAttrib2f"); + glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)myGetProcAddress("glVertexAttrib4f"); + glVertexAttrib2fv = (PFNGLVERTEXATTRIB4FVPROC)myGetProcAddress("glVertexAttrib2fv"); + glVertexAttrib3fv = (PFNGLVERTEXATTRIB4FVPROC)myGetProcAddress("glVertexAttrib3fv"); + glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)myGetProcAddress("glVertexAttrib4fv"); + glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)myGetProcAddress("glVertexAttrib4ubv"); + glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)myGetProcAddress("glGetAttribLocation"); + glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)myGetProcAddress("glBindAttribLocation"); - glUniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f"); - glUniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f"); - glUniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f"); - glUniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f"); - glUniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i"); - glUniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i"); - glUniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i"); - glUniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i"); - glUniform1fv = (PFNGLUNIFORM1FVPROC)wglGetProcAddress("glUniform1fv"); - glUniform2fv = (PFNGLUNIFORM2FVPROC)wglGetProcAddress("glUniform2fv"); - glUniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv"); - glUniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv"); - glUniform1iv = (PFNGLUNIFORM1IVPROC)wglGetProcAddress("glUniform1iv"); - glUniform2iv = (PFNGLUNIFORM2IVPROC)wglGetProcAddress("glUniform2iv"); - glUniform3iv = (PFNGLUNIFORM3IVPROC)wglGetProcAddress("glUniform3iv"); - glUniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv"); + glUniform1f = (PFNGLUNIFORM1FPROC)myGetProcAddress("glUniform1f"); + glUniform2f = (PFNGLUNIFORM2FPROC)myGetProcAddress("glUniform2f"); + glUniform3f = (PFNGLUNIFORM3FPROC)myGetProcAddress("glUniform3f"); + glUniform4f = (PFNGLUNIFORM4FPROC)myGetProcAddress("glUniform4f"); + glUniform1i = (PFNGLUNIFORM1IPROC)myGetProcAddress("glUniform1i"); + glUniform2i = (PFNGLUNIFORM2IPROC)myGetProcAddress("glUniform2i"); + glUniform3i = (PFNGLUNIFORM3IPROC)myGetProcAddress("glUniform3i"); + glUniform4i = (PFNGLUNIFORM4IPROC)myGetProcAddress("glUniform4i"); + glUniform1fv = (PFNGLUNIFORM1FVPROC)myGetProcAddress("glUniform1fv"); + glUniform2fv = (PFNGLUNIFORM2FVPROC)myGetProcAddress("glUniform2fv"); + glUniform3fv = (PFNGLUNIFORM3FVPROC)myGetProcAddress("glUniform3fv"); + glUniform4fv = (PFNGLUNIFORM4FVPROC)myGetProcAddress("glUniform4fv"); + glUniform1iv = (PFNGLUNIFORM1IVPROC)myGetProcAddress("glUniform1iv"); + glUniform2iv = (PFNGLUNIFORM2IVPROC)myGetProcAddress("glUniform2iv"); + glUniform3iv = (PFNGLUNIFORM3IVPROC)myGetProcAddress("glUniform3iv"); + glUniform4iv = (PFNGLUNIFORM4IVPROC)myGetProcAddress("glUniform4iv"); - glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)wglGetProcAddress("glUniformMatrix2fv"); - glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)wglGetProcAddress("glUniformMatrix3fv"); - glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv"); + glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)myGetProcAddress("glUniformMatrix2fv"); + glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)myGetProcAddress("glUniformMatrix3fv"); + glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)myGetProcAddress("glUniformMatrix4fv"); - glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog"); - glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog"); - glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation"); - glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)wglGetProcAddress("glGetActiveUniform"); - glGetUniformfv = (PFNGLGETUNIFORMFVPROC)wglGetProcAddress("glGetUniformfv"); - glGetUniformiv = (PFNGLGETUNIFORMIVPROC)wglGetProcAddress("glGetUniformiv"); - glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)wglGetProcAddress("glGetShaderSource"); + glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)myGetProcAddress("glGetProgramInfoLog"); + glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)myGetProcAddress("glGetShaderInfoLog"); + glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)myGetProcAddress("glGetUniformLocation"); + glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)myGetProcAddress("glGetActiveUniform"); + glGetUniformfv = (PFNGLGETUNIFORMFVPROC)myGetProcAddress("glGetUniformfv"); + glGetUniformiv = (PFNGLGETUNIFORMIVPROC)myGetProcAddress("glGetUniformiv"); + glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)myGetProcAddress("glGetShaderSource"); - glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray"); - glDisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray"); - glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer"); + glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)myGetProcAddress("glEnableVertexAttribArray"); + glDisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)myGetProcAddress("glDisableVertexAttribArray"); + glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)myGetProcAddress("glVertexAttribPointer"); // what'S the equivalent of this in GL 2.0??? - glGetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB"); + glGetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)myGetProcAddress("glGetObjectParameterivARB"); // Rules: // SM4 will always use shaders. No option to switch them off is needed here. @@ -251,55 +257,55 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_occlusion_query")) { - glGenQueries = (PFNGLGENQUERIESARBPROC)wglGetProcAddress("glGenQueriesARB"); - glDeleteQueries = (PFNGLDELETEQUERIESARBPROC)wglGetProcAddress("glDeleteQueriesARB"); - glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVARBPROC)wglGetProcAddress("glGetQueryObjectuivARB"); - glBeginQuery = (PFNGLBEGINQUERYARBPROC)wglGetProcAddress("glBeginQueryARB"); - glEndQuery = (PFNGLENDQUERYPROC)wglGetProcAddress("glEndQueryARB"); + glGenQueries = (PFNGLGENQUERIESARBPROC)myGetProcAddress("glGenQueriesARB"); + glDeleteQueries = (PFNGLDELETEQUERIESARBPROC)myGetProcAddress("glDeleteQueriesARB"); + glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVARBPROC)myGetProcAddress("glGetQueryObjectuivARB"); + glBeginQuery = (PFNGLBEGINQUERYARBPROC)myGetProcAddress("glBeginQueryARB"); + glEndQuery = (PFNGLENDQUERYPROC)myGetProcAddress("glEndQueryARB"); gl.flags|=RFL_OCCLUSION_QUERY; } if (gl.flags & RFL_GL_21) { - glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer"); - glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers"); - glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers"); - glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData"); - glBufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubData"); - glMapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer"); - glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer"); + glBindBuffer = (PFNGLBINDBUFFERPROC)myGetProcAddress("glBindBuffer"); + glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)myGetProcAddress("glDeleteBuffers"); + glGenBuffers = (PFNGLGENBUFFERSPROC)myGetProcAddress("glGenBuffers"); + glBufferData = (PFNGLBUFFERDATAPROC)myGetProcAddress("glBufferData"); + glBufferSubData = (PFNGLBUFFERSUBDATAPROC)myGetProcAddress("glBufferSubData"); + glMapBuffer = (PFNGLMAPBUFFERPROC)myGetProcAddress("glMapBuffer"); + glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)myGetProcAddress("glUnmapBuffer"); gl.flags |= RFL_VBO; } else if (CheckExtension("GL_ARB_vertex_buffer_object")) { - glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBufferARB"); - glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB"); - glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffersARB"); - glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferDataARB"); - glBufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB"); - glMapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBufferARB"); - glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBufferARB"); + glBindBuffer = (PFNGLBINDBUFFERPROC)myGetProcAddress("glBindBufferARB"); + glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)myGetProcAddress("glDeleteBuffersARB"); + glGenBuffers = (PFNGLGENBUFFERSPROC)myGetProcAddress("glGenBuffersARB"); + glBufferData = (PFNGLBUFFERDATAPROC)myGetProcAddress("glBufferDataARB"); + glBufferSubData = (PFNGLBUFFERSUBDATAPROC)myGetProcAddress("glBufferSubDataARB"); + glMapBuffer = (PFNGLMAPBUFFERPROC)myGetProcAddress("glMapBufferARB"); + glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)myGetProcAddress("glUnmapBufferARB"); gl.flags |= RFL_VBO; } if (CheckExtension("GL_ARB_map_buffer_range")) { - glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)wglGetProcAddress("glMapBufferRange"); - glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)wglGetProcAddress("glFlushMappedBufferRange"); + glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)myGetProcAddress("glMapBufferRange"); + glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)myGetProcAddress("glFlushMappedBufferRange"); gl.flags|=RFL_MAP_BUFFER_RANGE; } if (CheckExtension("GL_ARB_framebuffer_object")) { - glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers"); - glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers"); - glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer"); - glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D"); - glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers"); - glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress("glDeleteRenderbuffers"); - glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer"); - glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorage"); - glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbuffer"); + glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)myGetProcAddress("glGenFramebuffers"); + glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)myGetProcAddress("glDeleteFramebuffers"); + glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)myGetProcAddress("glBindFramebuffer"); + glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)myGetProcAddress("glFramebufferTexture2D"); + glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)myGetProcAddress("glGenRenderbuffers"); + glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)myGetProcAddress("glDeleteRenderbuffers"); + glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)myGetProcAddress("glBindRenderbuffer"); + glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)myGetProcAddress("glRenderbufferStorage"); + glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)myGetProcAddress("glFramebufferRenderbuffer"); gl.flags|=RFL_FRAMEBUFFER; } @@ -311,16 +317,16 @@ void gl_LoadExtensions() CheckExtension("GL_ARB_texture_rg") && gl.shadermodel == 4) { - glTexBufferARB = (PFNGLTEXBUFFERARBPROC)wglGetProcAddress("glTexBufferARB"); + glTexBufferARB = (PFNGLTEXBUFFERARBPROC)myGetProcAddress("glTexBufferARB"); gl.flags|=RFL_TEXTUREBUFFER; } #endif - glActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTextureARB"); - glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2fARB"); - glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) wglGetProcAddress("glMultiTexCoord2fvARB"); + glActiveTexture = (PFNGLACTIVETEXTUREPROC)myGetProcAddress("glActiveTextureARB"); + glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) myGetProcAddress("glMultiTexCoord2fARB"); + glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) myGetProcAddress("glMultiTexCoord2fvARB"); } //========================================================================== From 12985cf635259009531f71132e6426f3b1fda879 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Nov 2013 12:35:38 +0100 Subject: [PATCH 0047/1509] - fixed: Particle drawing needs to apply the current fixed colormap to the particle's color. --- src/gl/scene/gl_sprite.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 208507c84..f46acefb4 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -918,7 +918,8 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s RenderStyle = STYLE_Translucent; OverrideShader = 0; - ThingColor = particle->color; //GPalette.BaseColors[particle->color]; + ThingColor = particle->color; + gl_ModifyColor(ThingColor.r, ThingColor.g, ThingColor.b, Colormap.colormap); ThingColor.a=0; modelframe=NULL; From 228c6f976f5fbeb9217a7f826f35004632049764 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Nov 2013 12:53:34 +0100 Subject: [PATCH 0048/1509] - fixed: the size limit for dynamic light uniforms was not checked properly, causing artifacts when there were too many dynamic lights. --- src/gl/dynlights/gl_dynlight.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index e4242d8f9..ca3b2ec90 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -174,7 +174,6 @@ struct FDynLightData siz[0]>>=2; siz[1]>>=2; siz[2]>>=2; - max<<=1; if (siz[0] > max) siz[0] = max; if (siz[1] > max) siz[1] = max; if (siz[2] > max) siz[2] = max; From 992994239bb97e5dde40f44ae2f712e7ed2f493c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Nov 2013 13:01:48 +0100 Subject: [PATCH 0049/1509] - changed rules for drawing HUD sprites to match the software renderer. --- src/gl/scene/gl_weapon.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 61289f48b..aa991c0a0 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -185,8 +185,17 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) AActor * playermo=players[consoleplayer].camera; player_t * player=playermo->player; + // this is the same as the software renderer + if (!player || + !r_drawplayersprites || + !camera->player || + (players[consoleplayer].cheats & CF_CHASECAM)) + return; + + /* if(!player || playermo->renderflags&RF_INVISIBLE || !r_drawplayersprites || mViewActor!=playermo || playermo->RenderStyle.BlendOp == STYLEOP_None) return; + */ P_BobWeapon (player, &player->psprites[ps_weapon], &ofsx, &ofsy); From 9ac3b6aa1b298f7cfa69a862fabe1bf77612a7d8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Nov 2013 13:15:22 +0100 Subject: [PATCH 0050/1509] - fixed: IsVisibleToPlayer needs to be checked for the owner of owned dynamic lights. --- src/gl/dynlights/gl_dynlight1.cpp | 4 ++ src/gl/scene/gl_spritelight.cpp | 61 ++++++++++++++++--------------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index af2a9f7c6..0b2ffa43d 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -183,6 +183,10 @@ bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & u { return false; } + if (light->owned && light->target != NULL && !light->target->IsVisibleToPlayer()) + { + return false; + } scale = 1.0f / ((2.f * radius) - dist); diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index d630ddbc2..b1216d86b 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -79,42 +79,45 @@ bool gl_GetSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsector_ while (node) { light=node->lightsource; - if (!(light->flags2&MF2_DORMANT) && - (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) + if (!light->owned || light->target == NULL || light->target->IsVisibleToPlayer()) { - float dist = FVector3( FIXED2FLOAT(x - light->x), FIXED2FLOAT(y - light->y), FIXED2FLOAT(z - light->z) ).Length(); - radius = light->GetRadius() * gl_lights_size; - - if (dist < radius) + if (!(light->flags2&MF2_DORMANT) && + (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) { - frac = 1.0f - (dist / radius); - - if (frac > 0) + float dist = FVector3(FIXED2FLOAT(x - light->x), FIXED2FLOAT(y - light->y), FIXED2FLOAT(z - light->z)).Length(); + radius = light->GetRadius() * gl_lights_size; + + if (dist < radius) { - if (line != NULL) + frac = 1.0f - (dist / radius); + + if (frac > 0) { - if (P_PointOnLineSide(light->x, light->y, line) != side) + if (line != NULL) { - node = node->nextLight; - continue; + if (P_PointOnLineSide(light->x, light->y, line) != side) + { + node = node->nextLight; + continue; + } } + lr = light->GetRed() / 255.0f * gl_lights_intensity; + lg = light->GetGreen() / 255.0f * gl_lights_intensity; + lb = light->GetBlue() / 255.0f * gl_lights_intensity; + if (light->IsSubtractive()) + { + float bright = FVector3(lr, lg, lb).Length(); + FVector3 lightColor(lr, lg, lb); + lr = (bright - lr) * -1; + lg = (bright - lg) * -1; + lb = (bright - lb) * -1; + } + + out[0] += lr * frac; + out[1] += lg * frac; + out[2] += lb * frac; + changed = true; } - lr = light->GetRed() / 255.0f * gl_lights_intensity; - lg = light->GetGreen() / 255.0f * gl_lights_intensity; - lb = light->GetBlue() / 255.0f * gl_lights_intensity; - if (light->IsSubtractive()) - { - float bright = FVector3(lr, lg, lb).Length(); - FVector3 lightColor(lr, lg, lb); - lr = (bright - lr) * -1; - lg = (bright - lg) * -1; - lb = (bright - lb) * -1; - } - - out[0] += lr * frac; - out[1] += lg * frac; - out[2] += lb * frac; - changed = true; } } } From 058f06544680d7114657364c893862a4dee8f012 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 5 Dec 2013 10:23:01 +0100 Subject: [PATCH 0051/1509] - fixed: FFlatVertex contained two unused members. - fixed: Clearing the args in the VavoomLightColor constructor only cleared 5 bytes, still assuming byte args. --- src/gl/data/gl_vertexbuffer.cpp | 2 +- src/gl/data/gl_vertexbuffer.h | 2 +- src/gl/dynlights/a_dynlight.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index cda619ce1..93802f74b 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -128,7 +128,7 @@ void FFlatVertex::SetFlatVertex(vertex_t *vt, const secplane_t & plane) z = plane.ZatPoint(vt->fx, vt->fy); u = vt->fx/64.f; v = -vt->fy/64.f; - w = dc = df = 0; + w = /*dc = df =*/ 0; } //========================================================================== diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 6c2b83a15..49db1c7db 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -24,7 +24,7 @@ struct FFlatVertex // exactly 32 bytes large { float x,z,y,w; // w only for padding to make one vertex 32 bytes - maybe it will find some use later float u,v; // texture coordinates - float dc, df; // distance to floor and ceiling on walls - used for glowing + //float dc, df; // distance to floor and ceiling on walls - used for glowing void SetFlatVertex(vertex_t *vt, const secplane_t &plane); }; diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 80dc4e543..bc12288cd 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -107,7 +107,7 @@ void AVavoomLightColor::BeginPlay () { int l_args[5]; memcpy(l_args, args, sizeof(l_args)); - memset(args, 0, 5); + memset(args, 0, sizeof(args)); m_intensity[0] = l_args[0] * 4; args[LIGHT_RED] = l_args[1] >> 1; args[LIGHT_GREEN] = l_args[2] >> 1; From 2f60ca338b4c55c4585eac6cb7514c67f8123b0a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 5 Dec 2013 12:19:44 +0100 Subject: [PATCH 0052/1509] - removed unused members from sector_t --- src/r_defs.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/r_defs.h b/src/r_defs.h index c7cdd8a3c..bb2401684 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -781,10 +781,6 @@ struct sector_t int vboindex[4]; // VBO indices of the 4 planes this sector uses during rendering fixed_t vboheight[2]; // Last calculated height for the 2 planes of this actual sector int vbocount[2]; // Total count of vertices belonging to this sector's planes -#ifdef IBO_TEST - int iboindex[4]; // VBO indices of the 4 planes this sector uses during rendering - int ibocount; -#endif float GetReflect(int pos) { return gl_plane_reflection_i? reflect[pos] : 0; } bool VBOHeightcheck(int pos) const { return vboheight[pos] == GetPlaneTexZ(pos); } From d48d3378838a7d2ad24323fd8e85eca75b9979a5 Mon Sep 17 00:00:00 2001 From: Mike Swanson Date: Thu, 5 Dec 2013 04:43:29 -0800 Subject: [PATCH 0053/1509] convert file from UTF-16LE to UTF-8 This one file gave issues with parsing in certain programs, including the GitHub UI. No need for English text to waste so much space. --- src/gl/system/gl_framebuffer.cpp | Bin 30560 -> 14718 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 22f53864d03bdc6b5af20427d05a871aab2c5445..b68f5eeb22329219e1bb8bd3869fa0795620559a 100644 GIT binary patch literal 14718 zcmdPb;?mMmNY9B+D@x2wO)5=GOD)n%E+_zrdgd17q~@mPl_ZvA=I1HorzwCPDizZ5i*k!~ z6v{J8G8FQQz;u3T3CM!n{1i}7fCEcM0Tem~sYSV&B_*jT3I#>^Wtl0dDGDVSi6!7* zOv}&7$uG~$OIJwF&r8V!Sqye2NMCMhi51johI(kO0|zqHS;_e+sS3HJ#U%MRlk&?_6_R1$0&@-Df!8zhyx{d zky@mXn^=-sl$n@Qj0k&hoPj)v9NS>e8S5#8fRc7%ZYn5TKxz_8OEU67##DmBP9Z53 zlq6CVO7ay_^HTDQic>+cUr>~vn_rR&vLdB4xda@63JMA-sYRJ(sVNF+Mftgq5HHS8 zD*OK?x}gHMTt2I0i{VfnaK)1naQbn#i?NXK_bN&sVUGnfEwghl$xp# z4D+U2era9`I44*uq-KI6q%5@vb=9y%?5*K_Q`| zkXn(PT2KPY!=Pv>f_VW{cvULoWF{3Q7GEjs^3AWYEGsF*Mqnm$_f}=u!V^D~vbEuDFkU~IcP=J51s{+UiE}p^8 zK8~Kgt}ft^_w-Zn^H*>UbM*^R2=;LF@c~;4^^}vVf{&-8laH$c*hs%f1sBgCSLYCr z)1fSob3FZ=JzZS=LL7Z`6oLa>ojpMe*9ceN03XMoNF4?LAO&ZCzhKwEP*=YYPe&gG z7e`-5ch_JA4b%_-nS~w*0YU!Gp+T;`AouyZDFlZ)1&4Tsgod~(xcmFNfI?Rx*fl83 z)7drHTEWL36y9zMp~0>?Aj4c7Lma`@2L$=Md4>dAgPh_N8te%UCQrW**Px)#fDliA zKTQP>|8UnZ*B}LF$IxI`Pz<^#`1^q(5@b+_hpT^3q=LU2I6S~1uA>m{;Tq!M8l>Rq z2l8G>kRvEyfcOwxyc`7P`GEXtEPfu zkY})`pF7A@P$~*{j8yOs4FOpVN^PORt_uEcAhS>srVcm;6+GP(99_aZLGJf=14m?l ze{irTG>L$N&)EYS`k>gSUe&D&&Mx{~T*{ew$vLGdsR~NzIr_zw#U-h^`sq3G5SCts z5|VRH5AX;_}1-RI##nP)(bUDwvX=pIcm#Sb{2=8()x@jxLm3lx%E-Dp;19 zT#{deW_MY9L1Ip7Nl7ZI+LF}V0#Jd4raCRLC^;ju46GQ*Pbi+w%qvMPN=r-zE5Z>l z;06_>J%ws-dX9ckYFfuYHARVe#h{SGYf^D`Wm0|xF7rxDGIKIZDnSlQ&dE>C#xM#=0gi}D&jIO9 zE6qy=RY2fa1xEQyZyFVa!S%qvkS&rB)FfG{&sL0JXDPRcAPhOmlK(~44y zGd!wv6q54ua}?4_b8?E4i&9hbG!?8AxHyAL3sQ?T5Qahxgc$}g2+0s+{an>toQPOc zuvN%QEmuH_Qw>l{UelV3GdDFixu8-(BN*IO34oMIItuPkmY!2$ajJ8EPJU6bjzV!} zRcd~kMnGbYYhFoFrKXmVsTs(O(1Mi2l2oV;1yIa#27~=koRMDwN#Y8&3VxwJKGs~E zK8eL8&WX9HMTu}RE>6$9%#zH+oXo1!;F83WRIm~0Iq@h-j59qa9@4HXNp;W3PfE;j z0_Tq0!~(aX{9Ldja}x`|dR_8^Q%l?vb8{2H+`QD(l;YHqbdZ38twKprX{t3BC#di* zNKH|&g=7J1E>6ef+U`Zu%aE3S*V#)z?lFe6s)Wej(|okC|E$%X=XAs z;b#^Vm)JsLg$oqTn576LGhi{xnu{|tO+h0KWP~OcXEhfmCzx#uF4nBMI63w86{4M- zVinx-ixi6Ub5j+HQWJ~wLA~9~Vuj?Q#NrH4DVUk2ker`ekeQR30`8S7_-5w0hl4w| zpw2{YW)-+UqNm`ISPbgMC4oBlWvRs_ndylops@hu%(Rr$G=+HIVCVQS*B~xVkVmi- zddjJJDVb?pT%2Hcr|0OUdT2K@@=cFbUfwP>3fu2E{jsiLfazc6zSeZ*|K}m*& zp`Jk+L=en(E6q#RaQBJ#aSaZJ2nS~*rlk7jr=;e9#DjhP{X;x7t+_z9xq`h05_a(f zwOt_^5TcGg0UnO=A+Et85E+-uVo+FsG&qO)_{6(8I=f=X1o-zv#L36i&jnqdi)%oL2dK994T$#(gUBMe2_lVfF2Xcu&2*;d)j6|3o zch|sBM;{#nJyU4Jcx2|4fWi#Ps(24izYwsQexObdG<;zSVc`RD76G-cL7?7Rh-a8< zyt980sAC68hM4AafpRRkyIc;*YUTMw*$Rn8pfLf3M1`c%bkHacI49@lq@)%pq=1G? ziu4o$it>{ZlX5B*Qu0%a^VCZeauc&t6^bDv4|$cj`9-OEsHw@#-yISzNZ||-1F3`g z(#_u;;WanMU_`{Z<)>$Y0t}?W*Wbkz98j(i0ia|HG69_YK?iDz0Z>(?=$x1b6Vp_H zR9VQO?v_(poB;}OPR^p#lG36)Yc9@OEK$Y9=~9$f9+X&;8eCGEmIl^=)f`9-iI$cW z6v4?0o*E$T0J#rg21pI4bpmoFCsK1#*AASpo$`xPQj3Z~7ISf8rleYkz3Dme@NiYA zsZmgbHoKseb#OVf$yST4K^B?^>W6`B;B?MNP0n^o%}WM{O)VEq+DjnUfE!AXK5{Yj z(;}`$63Avq8ga|a%Ph{&3ra0cEdl!+D&Pzciu4?a5LgxzWytMYP-KBxLHhb=jbKh> zRY;BAS}snI<&btdI5s&U#_NUVfxE$AYoM`)Xd1hDKxc76ApLnOtI)ip%)AuGoE(q_ zDwh_vkeEmspaTQ>hT1nU|7ZUaXLj2pYT1O;spPOiL}PR46D) zO-=;Q&wz@W#1e%hP-rSZdIUv@xdou8R)EZ}faXw=^Ye-`LBk=SG5dUl)QXa#)ZA1( z1;=8AM9>6KX%1)}CbJk`*MKXjw4B89oYdmtoJviI^QhOnw#8k*Ai@NafWrNQTp&IR z0kwjn&CM)gLG36|O395chO{G#!M!7BCIl6bpz&$Y>{Mw^B4`A=Br!WR4>AP-nkXnv zNvs4ltwBQ*5VI9*6_Rrja|>+JKw@?pVDmujK*Ka01rt4RlY$d02b!V+k5Hg%0d=Zi zqZcrp#wa==;~&`cL1aK9BRUGY26`6YCa49-RxVD?l>E}99B>0262Z0#h6?%+XM=hK zQ0ctQEt-&+gm}abszI~iOhBBx$!E@+hpu7ANjZ9L{dy8oag05ud6G8CHX3>{8`nhA?PVoasx za2B+{qw1glo-zc|Ab}3yK#CDivM(yKHPA^8j7O0qSu<^p91aDJ$;HL$L*0cC{> za83Z#I7LO;wphlEqAOzcia-fCJsqcfI!Hb#38#D#xDCWvRAgsoYhlgBnVt@1Bqc!@ zT%6G1bfh6u1zQD;q9QGGa|LaM^mHvl6JrH!g`^}cV^d9iBU4jw^1@XeyQh}8<$#6; zQlMd?03Y^JC`inSHZnDf1t$r}_?bolDA%Hmp&6N)X`v69X@YHqji4!LVaX}(sU>hb z!B#+8feI+5gN?zHH^7cZIJqc22~?<*C?w|Qm*$m#jRh-FuvLILMgt_jssNgjDF#h_gQnmSIVjWC zz&g_=B(=gfF;CC0G#A>80yV&(wF@Xuf$D6i-O-t`@G8d*s#-y-B(*}pRsm{^Q>ABK zN@|5hCMdoj1572U6}oomIq{i!Y596d!QlB1kTH`JHn3I(lVP-H*`<>HeQ zi%V>vGFo;TC8-q<^WeE3;&wA@P%Wsy#mNaBs)E>9oTO_9_A|)A5Lu{YoZ!xFCdi2j zwhGAVbnP-z^xRWRAkK%{#>olyIY>*aLXEA0A*i6>gw#b)5;V?L3+^I;M-CuSlM5P0 zQYg;O%qs@fO4KZwAuT%v7o-Us1uH8B=b}`^AUISFL=4nq%mc5h02LjeIX_6d3e=Fy zO)O9-0kzU}6f)BkplvhIa3Xj%gL=(JE-p7euoGZK3$~I6;#{Z-4Y#1w+{6NK?XI9z z1Y(2p1~hxQ`-DJe+%og?pjxb~P)&en0_Q{OM*t*kVn2}m9s0_i!vi6upu z6`-+7(BKYe(={BFZqsu>gV&xZpp_&gm7tywC%XE8Ab&4cXYe`zP*sLagMU#; zM!p6YC#QzH52RJ5sbHXk%6CsKfsgB8$iVvbI-m@Q#}HjZJp*(#hI$4dT@c?Ojf_Et ztDvJ_;JoIYUsRk?nrEfp>IYu8;TRg?@9P+#09tb5=;P@KT3Vo}s0bejfX+FB%AfQc z#Hgo_r=Kg*&}M2*aVlguB0UGmdf!l=5YJ#o-vA%*AS@?}B$^SN={Y``d8v@_G1M~v z`2{qF0xC|ijBkL7FodwK9W2U0+MwwjUhPpoB`bi&aX^IxbSR(dDH~D=28TF0d&fHl zxd$s?sSiPJfL1DD8i?v8GdEpF0g?h0Dh%MvN&_8*(#*UPVQFl(FxQ9ah2&8(1;c8ledT%pK?I?4yPuEJ190b~uxib^9LP&EcNOh*AsK^nC~JX`}Z zD^hc?1}t>~5@J3qBoSr~lMu|zg}3*?Nlaf~Av7;1GaEDt18EP#7IzlGmX(0kaDsgg z8gEKU1ubUIOwY>)EicVTElO2L0u9-Lssep|g|f`la)l(&j2B25coaV|EiE;<1T>tN zs*spmQks|pQ3YBf3$_tyvRegpoCMQ2RF(*F1C^J1X4-~+VCIzC@N7Mvp zWf;r>8W6j|_CoE1*$1`-#e$*IWW`lafTw3j2ysyIMU+U;iXEITL17JEs6a$eLu|zz z&IlVIM$;&i6gw)as9;rpCItog~U~wgd+|%&;`aP@Rs{AcM9Mbrjsf zz{^UF6toKRGxK0;%JQHbF4!12B+FF5TW%13C7fTJoS2h}kOp%rb+|ae0T5rJP?QhZ zzoVnz=2DrLn46glUiAU$w`zf-F*gyKlflbDb5hGvbMPe^NW&hHnsn{ZybAXq)F%os zFDXErUIAL~4=M&Kbris^t$@-XS95YA+>3A>lFPv3h}51u1dY`yaOvxFh9qXEf*SIW ziEPm7H)^LCJVUtdsU_&E?m)8-#U%=m0WLMjoF=5KRV&CWNzTwwa19O)sVqoUPy>fn zd`V?NDkSzm3m6q_6@s0ETwVRbJzYXPKr5~CN)$k=4l z^`JI4x*&8dBFIhA^c-*-DYzuRC>6Y{A^_ZB@$q!`11-qc0Z+Q@7Hb&jXrRw)>w*?Mz`DPn`4c0Za-9qvcc1tmcP9`P>KE+k?&s0okScHpD%dLMmTMVXb8#X95EN{|Alt0DI3ZyU5j2bmp literal 30560 zcmezWPoF`HftP`cL5o3)L4hHiA%`KJA&sGkA(0`MA(bJCp_CzwA&nuGp@>0`A(^3o zp#Vv>Cqphn0YeT$Dp+kELkUA7LkUABLq0@sAl&H>)|1EJ&fvqKfaG2U z6c@wP!)RTG!3bflQ($mr$Y&^EsAMQ&$Ye-o$Y3a8P+%}(FaSecD9fAyq%H%jrkJ4w ztRsU#fx(|4l_7^AnIRh-SH(!Nk zNGSo6acA&j2xU-U@B!B;px6V&oI5y1L9qc!g9;1*45bW7;F1PZ$NPZmdQhB$)GIK+ zLI9?w7#vzD@NyNBA3*L#c9RCTKxqY(`(d#F3bjhGuQV9^82lMR7+e{w7!(*llhEN6{aF~Nc zLm7e?0vP-mf}vpxi3yMogTcOaWB~aG6c5PdCdmH~KPxb}GK4X>GWaosfa4V8Mjvq7 zALe7!_;Lc<0}5@BFMPl}gggDf{sGwza)&cR2srFOwxNn4LI@=13{5K_H#jo*fb|43 z1TeTVfMj4Ipj6-rjcZU?M1s{pLdcoHpTQ3t27wHrP~UhmfOIM_xG*>}_%b*$xP!x0 zfk6Wt`?yj9!ex+LggZrmQlvivC^kTT1;sJQ{h0#0L~)Z@1jRNYyddcXWGg7oLR=0@Cy3MzDh?U4OBLPTCvm6;*z@;fH7C<^c{so00s00AzeNYUemMIWb!3?3`atD%PV7UNM5)8&( zyDmHqAt9y@=7ZSE;Jz-X9xDa+I29O_z~d_V48;tU;J!3yyhI-?7LOvP$B@CG1U3ho z8KBV-P>om2fL~oM1ISd+_(}l*m1PX^@P2VV0kxo>2&f$j8VdlmrwF^DfC1ExCaf+Q zJX&DP0O}dy^FOGimJA;80JWCzn+x(8sC5DgFGxEbzj{zx3^JAl@*Al2f?s_ac!VmM zA%g+Z-bSbmss$nADe(-T zo)2uy7Su}tjRTNp5~x208tDP01W;K^$P_2=_&^T0jRkW}8Msyfg%d>8vN;%+hR#00e6`XQGZF11a2FTBx48aVg;2EnT1`Vuk zMRg;(+mPLa-7UCW0J6OroZC3D=0pVsTkzamDnmJg0t5D3tN{)?(C7>-Cvt+vqjSOY zfuOM;4F=HY8*EG|09=}Y@-e8S2Zf_M1FD!FgA;hXFBLrF1u9QLEjo}&&^TNbLn?SI zPXnsUl>wAnix?^yG#RuQj2KKA%;04LCqpPh0RyB>kP1}~vl-NfMz}bb0TDN#u|?1* z5^}i@2?@|RCTLs%QsQtj_<-G6!r%;@4+WLV*i?eTnUlejArCy41sQeEWB~aDQp$ir z0#PP$LfiiMN;{Yua=`@T%>S?h$Gt#8c~MW z><;!7NCmPysQyZ2NCD64l`y2k)j<4R!cfFe%8&{zlQ|iR!K3J)d0~(qh#Exg0SiY* zhGg)_Vh)25c+3ox>d;MsxG9Vwn4uC}$AfY>XwDAQM*;PmAoUr<#9DBg28B9tts7HuPON4Vd$k(t`1Zu;9`jnvg1JLXRXf_8l8xQKu zgG#*;23rQyoB+}d%l)8MNg@NGHV$(A0;)X;yAYOgL2E8R zrIAvEW(+R0D(N&_E>-D2;&91ZaK-Gz$Wn?F03iL1_q7B7?+1 z^&Mm_0K`3@HZZ7%0P250N)=H32ug9FQEE`V?#>VnolODFQ^96gav4BnE+n);c7f*K zJ-{V6$X3uCV-k2(0>}i=XaXp1Ky3h!4v;;N5hqZeI}JQ?1Der{XYgeJjZw#gTf9Nw zl+DQiiyvZJlgi*W0cidv4Qv7=jyb`r89?C=YKQAFq=EZ==?ujTY79XPZVWyQ@eF

z)Z+)ue1SpiCF&HqUf!lk8*od|Us(CI9sSKbQwG0Lg2GE)ika?(T5h_4) zeV}?y1Ke7RX8_GyfO@W|>Vv_ns6eGHsMQOia~NPcf*E|lqxYb(U6?LNY6H0n)RuyU z4NM1U&I6E=bkQ50T`$pB}0$xjkZVPAz0@SjKXK-V1WB|<~ z5Tgr}_I(&489*}j#ZRV1_g{pMq2(N{M)IdkfXA*lmM_ zK|BMt6a+~RPT)KO>fxiO(_rw-A!vNShXIm0K&^RDn<*YV=jF-(Dn~(c6QH>UkR70z zMr8GZ7C|#}pqWq5C=_V^2UPZh=9xUf;YzGckP-k=QzPcu zL30G4G9I*w5VSS~RBva4>s8Q-D$qz9sCEUdI03Ev1FeYz)ttyRJE;E)Dt|!h1X94g z5m3DfTJZ&%^8uLx>ZyQMeSrFjpg9CkA3Bdg9lXK-)bjwXR|J^|s%Ky;K|pIHKr4Pg z?FLAl3`u|3(mQBY*Bvdcu%~cTm5>ktLT&AE4DH=?t0hGzT*U zR2qYFG9rzE#ufwME(W;+gdsje)IzY*88l}MnrRJUh-U!JlDaXtf#>N#JkUJ60z(aW zMG&a10I~;G;$Tw?%VQAxKye9b6Tn)Z9t@D)8>q)w!Vm)O=Xo%s!dIgr_Yz^cL2FMz zy*Y?3T&h9g9LA8z02*h2wMIa-D=1Vz;|q{JCCCN33$1C-909kXwxyTo^RKGc1sCO^`}RIDkqi^q!qAgB{l1JjixP z+Zob!0GR;FRfDyE19BV8ji7m6#8?R=--BA-pxg&)i9^P%V5(vCVD%ZyeV{pJP?-W+ z^8}i21g#s)W5@xovO;d{mV;Lvfpoz}v$2hYgUYZ(hH~%>Dr6J_l-6K51jIG~&$ffY z710+0iNj0<)oGx*4Yd9URBqQWAY?!(&7Z*uyy63tul*Q6Ef`Sg1#%Y%liC+W9{mEP zO^_L|wll0Xt_U8z%0n3`1E~d#P=eGW_aHzn#FiI8vmT%|S)ev7BIj^|SKmQqmGa;t zLWrEf$v`;&L0sShUO86I5CooCNo4?ynn89RfLsd6aoERMKsgng>mcUB!T?fQ;40G; z7!<+dpb%A>j<@l5OpU?>A9S3>3vkxg+1 zuk!@$TLAeC)b~M7V-Pz);Sa)~TsK(DBaqu*ZUn8E0ky3PpsS8SV<4aw6l^CAWFG;t zj=}0HkdH_$laSL2NIxtUxq(~dpm~H020ie;2vBcxdJoAfKoHEI^@&@ zOYykIuo1Zt<|@ee6`?V4PVm~(RGg#Yh`In)RzXrOXk-qO5|HN_kn=Ss1F~QA7(n?1 zG0TqZH*6#Au$l>Gs~ZDoybDx*fNTY|pFtL<~ts2W`fXp5sW;9^3Fd8(<2J$(iO#rI1@}PAMq^$sIVS+*g zG#&Z!iSUHGYzJjdFoz zy+JVyavf--(-FM78`N6^iGtRL=YV@zAd^A44z#}`AG|^z*8eI8j|+l&e2|gHa&Z41 zv~~d$CXiYHIiv?~dH}^TspS-|JP$GpRyu@(*EWMzl_KWBLKt9UThR>W3}y@#46)F* z4@f7XbpTn12b%YV^>~UI5a|;Vy2x!WP)LJXv#`-|NJ`BGul@(cDkKg;d%!?_X3#zo z(3~`Aj2)5#K&)c$TxcaYkAPYWpm>F>RzXdJpdK5jl!2r~8}P_8M4cVD2MZDhrB+bO z7Buc@2pt0j?PNh7Z2`>=fKoXm#Y0jos7wNl>Vx{0`0atMS3%c@ZYyZd5pG+N*WN&S zu(*8&vk_SjsICB|d62ET;1MMYsBb|&2eDzLBP4z~!Mm~``&2;r6x6#c!H;amHGiYoEQIa4+6jDyY%41w*HY|=oH6N&M zF9PpH2Bkp6S_MkoioDtaR%W2O8aX`;9(RN0vmh&IAf+;@o6++yE!+*N*#>Xh0pvPR z3Pz>}uWLarCAFo4JW7PR5)0J70GSBOU$ATm}=jGAx>*f+3bckD&-!GJ{Gkkh?&o zIB6!NBbfm559uZ(!A*daClJ5bG1xKKGQesMP>qq!fG!5I4^<2l@|@t)E+FfSKZ-TwMk6KSV$3>OxRx!u*3; z_u%#gB>y1XMPAK`hz-njlAu0jIztk;4FJp0pcV{hcRQ#iKrQ1DCP7je#GiC~`^g7y#uEP^f{{hk|-7pwxk_R;DynVhaZ~28ioG z?u3Pe8hAw`_OO7chJ*tmTp%$9@(0AU$Ac<(-F%@k zLGls0S?Ky9p$&2?WNZ#}5(}uzfsCXe?`i>!h9Hk_fyQ4Tr(%H42my_wfW|gJ;~$`Y z8fdf;R3d@a@PbNO(Af});8m#*eIODv#{n8=f!K~-!(~EixJ(8c2FSRYF9XOvJqADU z866NYNc$5sCk2Wh%w86(ynyt2K)p585Qt^~^(-La2&(B2>Oo_LsCIzDALN$`Xg?1k z3v-ndLnU|?6EuEQ!2qhM5$$)7$*|E%~H5enIX5VdQWF@nOC#W=LWH`4u!~3)*d0%m52< zRQ>3FgqQ(y0cflcl=dLG9haFPdq8WL^%x*&AG9(P78~fk1euSS5@7a#`h+#$UMnnL zgVaMXq%MK55wkxaK0*e@g3zG!4Z_%R7^tiVxe?Uc2jw9#s3KG9Zt^D=>gcB+!0tP^k$@pXmDsU}nH*RJEYe0#pw`Mv)=AKtby% zL1&$SYCBL$29+?NH87ylXFzH}Hi1UfAoD`7QA9}H1X^nf8nXqhqz9#Tkbcm5OPK92 zda#B%$bD`Me&8{6NN7OX5s0wRB4Q0bC{CQgv&z_F1ho4OG&>CmL&T^As1!tmEu@r! z<$jPjq(la_JwWrXpjlv0sa*_SZCe68uLsq&gxmo#72*n5E*^S$0~BM(d1bJsEK=LY zpm}7_N~}Ea+D8rW4p`7SHPmzgs_8)WB&ao-$xs2_KL#rGVC$}6>$ZHrry962gd??Q zL3&{;^F6^U#X+?KXzy7i(u_T*7ns9<&ko3G7+&BLL_q8OKHXo z81fl37(np~D*GWmK_0~gjf{f&^!QakYAVot7-ZKRs1*Y$qlnRkzIKAJKEm$Ng|3<= zY!+m7HKG_zw7(d1&If3X zHt3uY(0M`r;4@qTpeJvD;uN$_6?Dc6XuZ21gFAyF7(z^jwMane34IqXB(;L#5hM%h zjlt>*NW6m9hJ)7Af>zcduRVpiofCW>B&f{`u?tonLedrXuIqP(fUS=TN(+OvoCLWI6apX`)b0WGbIRd!!l3p9XvP@S3r_`? z5g>Ii^@G(?m3k(fX*@j^-U8QAZCE(XX4?# zXP8Ve+ISeug`k!QXg(0s!i4l!K_{gm_ljZV21F$&kHhq$`UKQM0_`RO^_+5{Zh`p# z=4Q}*GQ^b-7Gxim8hAVo;tEi?3(F6naWzn!Aoq=6t^tKV;XDdDz0e1|`Ug2LgYqVJ zKOnmu5gLem3n?uiB*o_ z-0kJ`Ik+2n# zpf(D~x3KX>&^j#8ULcSf(A+1;UYL2Ho!g-GhoIAPK`U24W`Is)LAVDrY7c6`fyUZE z=jTH96@hlJf%@Q}9Z4`>g4!gY*)Y)VGEnax!g*7ZKP`~zr_zl%3n68Jp8s=JvD?zS94_#1d#mpT8F9HfhklS$41Mfmi z7l7PKYHEedbe4cuqJz#c0?kRm(iSLpg3d}uPLCzvTPKi3KxaNf&Y?jT1&!Q+PG1DA zOa+O9&S3`4nSk;xC?|q?TE*bgA3?Gp)u3_)bQ=L^)jueA$Ad>*KxZ_7+=E=kf&5A8 z_yA&L2vjbh_fHp|&|Z^N@Ts1NmL4_JJ}CWy%5rS&t$}GBBKsKGr^KdmY(7EM39uge(CgEH z#?FixTo~LKoETuUgrGe-ppr2de5VQI&Z7YEoiUKL_QMA z(XbtTpjKH4v{i%b5^CiqYMKMen;=YT{=^pp*vIftM?67s;l>aKy$JzS78@~u>L1X0 za!B5UjC?`Zp!=#&Wk7C5U%3x51y-V0fZJfGqlL)wm009K_vC^T!7+k<7sDb9ZL2E8R>wiJ@5NI?nkpVRKtOZ`7k1Ph# z2lF}NoL*3h1)b-RL(zB&#O1KoD8601p!1$`7_j9r&=~=sP=d7_K<-72AIum7?F0wq zAjn)GBz`bs1QE&*6$m~e)InoG*g_gn+Ck=mL9W6cdXU;4wl)J%CW68Slw+xx!>DH# z%yp1<6Ud#M44^S((EcM(FA%h*0Tf=KvJTY40?m$r&Q*lzgVEG;5j9N$xekO$Er}rW zqlC_rgzbU>t$u>sEdrWd1eG{yD0kF>(hMx;fkxdyJy_7W;vjL*IU}Gsk4kVaRe?bb zDc^$fKSUh4RSaqogL;pkzA$8E66owQ(3vry*-FrT0WRQMO!)zlIW)K&H<_AHik%I1H z0fkvK_-s-U~{Db;4`Nn^G2YVO3;l(u)8oo zAr0DR1al?GG*I6FbnYI))M5t6c_kndL2Ft-t4KgIgrK?}R0n`=>jU`}vIh#1M$qLz z^Y5UYNuY6UP;WScK?i!yR}h0cgA<$=3ce)-6!xG~sa(J(zd+Vo>M#%rLs+{DGFOXm zKRKadg0$wL0DQ73C}l!oNtdA?J`B42^ZSJ)^PwlWqp za#jl7-32-+0&+?c$V8aQ)N?B}O#-p(Z=z?k=(8>u=?}5^@mTMUR D?lx1= From 95163e378e85c905ee0c6fc11b6bfa2fda114e0d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 5 Dec 2013 15:06:10 +0100 Subject: [PATCH 0054/1509] - added a fog layer when drawing sprites with render style reverse subtract. --- src/gl/renderer/gl_colormap.h | 1 + src/gl/renderer/gl_renderstate.h | 5 + src/gl/scene/gl_sprite.cpp | 116 ++++++++++++++------ src/gl/shaders/gl_shader.cpp | 34 +++++- src/gl/shaders/gl_shader.h | 2 +- wadsrc/static/shaders/glsl/main_foglayer.fp | 59 ++++++++++ 6 files changed, 181 insertions(+), 36 deletions(-) create mode 100644 wadsrc/static/shaders/glsl/main_foglayer.fp diff --git a/src/gl/renderer/gl_colormap.h b/src/gl/renderer/gl_colormap.h index a3f4cf83b..d04e1edda 100644 --- a/src/gl/renderer/gl_colormap.h +++ b/src/gl/renderer/gl_colormap.h @@ -24,6 +24,7 @@ enum EColorManipulation // These are not to be passed to the texture manager CM_LITE = 0x20000000, // special values to handle these items without excessive hacking CM_TORCH= 0x20000010, // These are not real color manipulations + CM_FOGLAYER= 0x20000020, // Sprite shaped fog layer - this is only used as a parameter to FMaterial::BindPatch }; #define CM_MAXCOLORMAP int(CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size()) diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index dd348ad8c..6fea56707 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -211,6 +211,11 @@ public: mLightData = lightdata; // caution: the data must be preserved by the caller until the 'apply' call! } + void SetFixedColormap(int cm) + { + mColormapState = cm; + } + PalEntry GetFogColor() const { return mFogColor; diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index f46acefb4..0a672737e 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -101,6 +101,8 @@ void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblend gl_RenderState.SetTextureMode(tm); } +CVAR(Bool, gl_nolayer, false, 0) + //========================================================================== // // @@ -117,6 +119,7 @@ void GLSprite::Draw(int pass) bool additivefog = false; + bool foglayer = false; int rel = getExtraLight(); if (pass==GLPASS_TRANSLUCENT) @@ -208,8 +211,36 @@ void GLSprite::Draw(int pass) Colormap.FadeColor = Colormap.FadeColor.InverseColor(); additivefog=false; } + if (RenderStyle.BlendOp == STYLEOP_RevSub || RenderStyle.BlendOp == STYLEOP_Sub) + { + if (!modelframe) + { + // non-black fog with subtractive style needs special treatment + if (!gl_isBlack(Colormap.FadeColor)) + { + if (gl.shadermodel >= 4 && !gl_nolayer) + { + // fog layer only works on modern hardware. + foglayer = true; + // Due to the two-layer approach we need to force an alpha test that lets everything pass + gl_RenderState.AlphaFunc(GL_GREATER, 0); + } + else + { + // this at least partially handles the fog issue + Colormap.FadeColor = Colormap.FadeColor.InverseColor(); + } + } + } + else RenderStyle.BlendOp = STYLEOP_Fuzz; // subtractive with models is not going to work. + } - gl_SetFog(foglevel, rel, &Colormap, additivefog); + if (!foglayer) gl_SetFog(foglevel, rel, &Colormap, additivefog); + else + { + gl_RenderState.EnableFog(false); + gl_RenderState.SetFog(0, 0); + } if (gltexture) gltexture->BindPatch(Colormap.colormap, translation, OverrideShader); else if (!modelframe) gl_RenderState.EnableTexture(false); @@ -221,27 +252,67 @@ void GLSprite::Draw(int pass) //&& GLRenderer->mViewActor != NULL && (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD ))) ); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_STRIP); - if ( drawWithXYBillboard ) + + Vector v1; + Vector v2; + Vector v3; + Vector v4; + + if (drawWithXYBillboard) { // Rotate the sprite about the vector starting at the center of the sprite // triangle strip and with direction orthogonal to where the player is looking // in the x/y plane. - float xcenter = (x1+x2)*0.5; - float ycenter = (y1+y2)*0.5; - float zcenter = (z1+z2)*0.5; + float xcenter = (x1 + x2)*0.5; + float ycenter = (y1 + y2)*0.5; + float zcenter = (z1 + z2)*0.5; float angleRad = DEG2RAD(270. - float(GLRenderer->mAngles.Yaw)); - + Matrix3x4 mat; mat.MakeIdentity(); - mat.Translate( xcenter, zcenter, ycenter); + mat.Translate(xcenter, zcenter, ycenter); mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch); - mat.Translate( -xcenter, -zcenter, -ycenter); - Vector v1 = mat * Vector(x1,z1,y1); - Vector v2 = mat * Vector(x2,z1,y2); - Vector v3 = mat * Vector(x1,z2,y1); - Vector v4 = mat * Vector(x2,z2,y2); + mat.Translate(-xcenter, -zcenter, -ycenter); + v1 = mat * Vector(x1, z1, y1); + v2 = mat * Vector(x2, z1, y2); + v3 = mat * Vector(x1, z2, y1); + v4 = mat * Vector(x2, z2, y2); + } + else + { + v1 = Vector(x1, z1, y1); + v2 = Vector(x2, z1, y2); + v3 = Vector(x1, z2, y1); + v4 = Vector(x2, z2, y2); + } + glBegin(GL_TRIANGLE_STRIP); + if (gltexture) + { + glTexCoord2f(ul, vt); glVertex3fv(&v1[0]); + glTexCoord2f(ur, vt); glVertex3fv(&v2[0]); + glTexCoord2f(ul, vb); glVertex3fv(&v3[0]); + glTexCoord2f(ur, vb); glVertex3fv(&v4[0]); + } + else // Particle + { + glVertex3fv(&v1[0]); + glVertex3fv(&v2[0]); + glVertex3fv(&v3[0]); + glVertex3fv(&v4[0]); + } + + glEnd(); + + if (foglayer) + { + // If we get here we know that we have colored fog and no fixed colormap. + gl_SetFog(foglevel, rel, &Colormap, additivefog); + gl_RenderState.SetFixedColormap(CM_FOGLAYER); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.Apply(); + + glBegin(GL_TRIANGLE_STRIP); if (gltexture) { glTexCoord2f(ul, vt); glVertex3fv(&v1[0]); @@ -256,26 +327,9 @@ void GLSprite::Draw(int pass) glVertex3fv(&v3[0]); glVertex3fv(&v4[0]); } + glEnd(); } - else - { - if (gltexture) - { - glTexCoord2f(ul, vt); glVertex3f(x1, z1, y1); - glTexCoord2f(ur, vt); glVertex3f(x2, z1, y2); - glTexCoord2f(ul, vb); glVertex3f(x1, z2, y1); - glTexCoord2f(ur, vb); glVertex3f(x2, z2, y2); - } - else // Particle - { - glVertex3f(x1, z1, y1); - glVertex3f(x2, z1, y2); - glVertex3f(x1, z2, y1); - glVertex3f(x2, z2, y2); - } - } - glEnd(); } else { diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 30e3318f3..23474fc7d 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -155,7 +155,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * glGetShaderInfoLog(hFragProg, 10000, NULL, buffer); if (*buffer) { - error << "Vertex shader:\n" << buffer << "\n"; + error << "Fragment shader:\n" << buffer << "\n"; } glGetProgramInfoLog(hShader, 10000, NULL, buffer); @@ -289,6 +289,23 @@ FShaderContainer::FShaderContainer(const char *ShaderName, const char *ShaderPat I_Error("Unable to load shader %s:\n%s\n", name.GetChars(), err.GetMessage()); } + name << ShaderName << "::foglayer"; + + try + { + shader_fl = new FShader; + if (!shader_fl->Load(name, "shaders/glsl/main.vp", "shaders/glsl/main_foglayer.fp", ShaderPath, "#define NO_GLOW\n")) + { + delete shader_fl; + shader_fl = NULL; + } + } + catch (CRecoverableError &err) + { + shader_fl = NULL; + I_Error("Unable to load shader %s:\n%s\n", name.GetChars(), err.GetMessage()); + } + if (gl.shadermodel > 2) { for(int i = 0;i < NUM_SHADERS; i++) @@ -344,8 +361,9 @@ FShaderContainer::FShaderContainer(const char *ShaderName, const char *ShaderPat //========================================================================== FShaderContainer::~FShaderContainer() { - delete shader_cm; - for(int i = 0;i < NUM_SHADERS; i++) + if (shader_cm != NULL) delete shader_cm; + if (shader_fl != NULL) delete shader_fl; + for (int i = 0; i < NUM_SHADERS; i++) { if (shader[i] != NULL) { @@ -365,7 +383,15 @@ FShader *FShaderContainer::Bind(int cm, bool glowing, float Speed, bool lights) { FShader *sh=NULL; - if (cm >= CM_FIRSTSPECIALCOLORMAP && cm < CM_MAXCOLORMAP) + if (cm == CM_FOGLAYER) + { + if (shader_fl) + { + shader_fl->Bind(Speed); + } + return shader_fl; + } + else if (cm >= CM_FIRSTSPECIALCOLORMAP && cm < CM_MAXCOLORMAP) { // these are never used with any kind of lighting or fog sh = shader_cm; diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index b43e0aec4..0211eeac0 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -105,12 +105,12 @@ class FShaderContainer FShader *shader[NUM_SHADERS]; FShader *shader_cm; // the shader for fullscreen colormaps + FShader *shader_fl; // the shader for the fog layer public: FShaderContainer(const char *ShaderName, const char *ShaderPath); ~FShaderContainer(); FShader *Bind(int cm, bool glowing, float Speed, bool lights); - }; diff --git a/wadsrc/static/shaders/glsl/main_foglayer.fp b/wadsrc/static/shaders/glsl/main_foglayer.fp new file mode 100644 index 000000000..5d18eeee5 --- /dev/null +++ b/wadsrc/static/shaders/glsl/main_foglayer.fp @@ -0,0 +1,59 @@ +uniform int fogenabled; +uniform vec4 fogcolor; +uniform vec3 camerapos; +varying vec4 pixelpos; +varying vec4 fogparm; + +uniform sampler2D tex; + +vec4 Process(vec4 color); + +//=========================================================================== +// +// Gets a texel and performs common manipulations +// +//=========================================================================== + +vec4 desaturate(vec4 texel) +{ + return texel; +} + +vec4 getTexel(vec2 st) +{ + vec4 texel = texture2D(tex, st); + return texel; +} + +//=========================================================================== +// +// Main shader routine +// +//=========================================================================== + +void main() +{ + float fogdist; + float fogfactor; + + // + // calculate fog factor + // + #ifndef NO_SM4 + if (fogenabled == -1) + { + fogdist = pixelpos.w; + } + else + { + fogdist = max(16.0, distance(pixelpos.xyz, camerapos)); + } + #else + fogdist = pixelpos.w; + #endif + fogfactor = exp2 (fogparm.z * fogdist); + + vec4 frag = Process(vec4(1.0,1.0,1.0,1.0)); + gl_FragColor = vec4(fogcolor.rgb, (1.0 - fogfactor) * frag.a * 0.75); +} + From d46315c44b99f07be7244da4ae01bc010b380795 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 5 Dec 2013 15:39:46 +0100 Subject: [PATCH 0055/1509] - some finetuning of subtractive effect. --- src/gl/scene/gl_sprite.cpp | 1 + wadsrc/static/shaders/glsl/main_foglayer.fp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 0a672737e..b7a48852c 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -310,6 +310,7 @@ void GLSprite::Draw(int pass) gl_SetFog(foglevel, rel, &Colormap, additivefog); gl_RenderState.SetFixedColormap(CM_FOGLAYER); gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.Apply(); glBegin(GL_TRIANGLE_STRIP); diff --git a/wadsrc/static/shaders/glsl/main_foglayer.fp b/wadsrc/static/shaders/glsl/main_foglayer.fp index 5d18eeee5..4b1bdf418 100644 --- a/wadsrc/static/shaders/glsl/main_foglayer.fp +++ b/wadsrc/static/shaders/glsl/main_foglayer.fp @@ -54,6 +54,6 @@ void main() fogfactor = exp2 (fogparm.z * fogdist); vec4 frag = Process(vec4(1.0,1.0,1.0,1.0)); - gl_FragColor = vec4(fogcolor.rgb, (1.0 - fogfactor) * frag.a * 0.75); + gl_FragColor = vec4(fogcolor.rgb, (1.0 - fogfactor) * frag.a * 0.75 * glColor.a); } From 4b24489393a39038bb6904b512f9923832b7dfdb Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 7 Dec 2013 12:19:35 +0200 Subject: [PATCH 0056/1509] * fix compilation on non-Windows systems --- src/gl/system/gl_interface.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index b70a103f3..a9fea02aa 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -47,6 +47,9 @@ #include "gl/system/gl_cvars.h" #if defined (__unix__) || defined (__APPLE__) +#define PROC void* +#define LPCSTR const char* + #include #define wglGetProcAddress(x) (*SDL_GL_GetProcAddress)(x) #endif @@ -62,7 +65,7 @@ int occlusion_type=0; PROC myGetProcAddress(LPCSTR proc) { PROC p = wglGetProcAddress(proc); - if (p == NULL) I_Error("Fatal: GL function '%s' not found."); + if (p == NULL) I_Error("Fatal: GL function '%s' not found.", proc); return p; } From fd767233aa968d546da7c91e3f91b242f8a31175 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 8 Dec 2013 10:01:03 +0100 Subject: [PATCH 0057/1509] - fixed typo: glColor must be gl_Color in shader. --- wadsrc/static/shaders/glsl/main_foglayer.fp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/shaders/glsl/main_foglayer.fp b/wadsrc/static/shaders/glsl/main_foglayer.fp index 4b1bdf418..bfe08d327 100644 --- a/wadsrc/static/shaders/glsl/main_foglayer.fp +++ b/wadsrc/static/shaders/glsl/main_foglayer.fp @@ -54,6 +54,6 @@ void main() fogfactor = exp2 (fogparm.z * fogdist); vec4 frag = Process(vec4(1.0,1.0,1.0,1.0)); - gl_FragColor = vec4(fogcolor.rgb, (1.0 - fogfactor) * frag.a * 0.75 * glColor.a); + gl_FragColor = vec4(fogcolor.rgb, (1.0 - fogfactor) * frag.a * 0.75 * gl_Color.a); } From 3b5d379fa4bb89f4992d4e140dce67bf92ec8992 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 9 Dec 2013 11:34:26 +0100 Subject: [PATCH 0058/1509] - Linux compile fix. --- src/gl/api/gl_api.h | 4 ++-- src/gl/data/gl_data.cpp | 5 +++-- src/gl/system/gl_system.h | 10 +++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/gl/api/gl_api.h b/src/gl/api/gl_api.h index bcb03c416..3ed1a2efd 100644 --- a/src/gl/api/gl_api.h +++ b/src/gl/api/gl_api.h @@ -1,7 +1,7 @@ -#if defined(__APPLE__) +#if defined(__unix__) || defined(__APPLE__) #define APIENTRY #define APIENTRYP * -#endif // __APPLE__ +#endif // __unix__ || __APPLE__ #ifndef __EXTERN #define __EXTERN extern diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 20ec8a3a7..e0bb5ee6b 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -110,6 +110,7 @@ void AdjustSpriteOffsets() FScanner sc; sc.OpenLumpNum(lump); GLRenderer->FlushTextures(); + int ofslumpno = Wads.GetLumpFile(lump); while (sc.GetString()) { int x,y; @@ -124,11 +125,11 @@ void AdjustSpriteOffsets() FTexture * tex = TexMan[texno]; int lumpnum = tex->GetSourceLump(); - // We only want to change texture offsets for sprites in the IWAD! + // We only want to change texture offsets for sprites in the IWAD or the file this lump originated from. if (lumpnum >= 0 && lumpnum < Wads.GetNumLumps()) { int wadno = Wads.GetLumpFile(lumpnum); - if (wadno==FWadCollection::IWAD_FILENUM) + if (wadno==FWadCollection::IWAD_FILENUM || wadno == ofslumpno) { tex->LeftOffset=x; tex->TopOffset=y; diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h index 8a0c307fc..222fb44f1 100644 --- a/src/gl/system/gl_system.h +++ b/src/gl/system/gl_system.h @@ -66,14 +66,18 @@ #include #include +//GL headers #if defined(__APPLE__) #include #include -#else // !__APPLE__ +#elif defined(__unix__) +#include +#include "gl/api/glext.h" +#else // !__APPLE__ && !__unix__ #include #include -#include "gl/api/glext.h" // use the local copy -#endif // __APPLE__ +#include "gl/api/glext.h" +#endif #include "gl/api/gl_api.h" #ifdef _WIN32 From 917a869a54b75866eb8deeaca6474294ce625519 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 23 Dec 2013 09:56:16 +0100 Subject: [PATCH 0059/1509] - fixed: gl_SetFog set the vertex attribute for software lighting mode without checking if the mode is actually on. --- src/gl/renderer/gl_lightdata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 88d24cc02..9292c765e 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -611,7 +611,7 @@ void gl_SetFog(int lightlevel, int rellight, const FColormap *cmap, bool isaddit gl_RenderState.SetFog(fogcolor, fogdensity); // Korshun: fullbright fog like in software renderer. - if (glset.brightfog && fogdensity != 0 && fogcolor != 0) + if (glset.lightmode == 8 && glset.brightfog && fogdensity != 0 && fogcolor != 0) glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); } } From 4909aa750fa44853e88647509dac2049522182a1 Mon Sep 17 00:00:00 2001 From: galtgendo Date: Sun, 2 Mar 2014 11:32:45 +0100 Subject: [PATCH 0060/1509] Use more portable hqx code from googlecode hqx Conflicts: src/CMakeLists.txt --- src/CMakeLists.txt | 2634 ++++---- src/gl/hqnx/Image.cpp | 1174 ---- src/gl/hqnx/Image.h | 145 - src/gl/hqnx/common.h | 141 + src/gl/hqnx/hq2x.cpp | 5768 ++++++++-------- src/gl/hqnx/hq3x.cpp | 7623 +++++++++++---------- src/gl/hqnx/hq4x.cpp | 10690 +++++++++++++++--------------- src/gl/hqnx/hqnx.h | 35 - src/gl/hqnx/hqx.h | 55 + src/gl/hqnx/init.cpp | 38 + src/gl/system/gl_menu.cpp | 15 - src/gl/textures/gl_hqresize.cpp | 27 +- 12 files changed, 13347 insertions(+), 14998 deletions(-) delete mode 100644 src/gl/hqnx/Image.cpp delete mode 100644 src/gl/hqnx/Image.h create mode 100644 src/gl/hqnx/common.h delete mode 100644 src/gl/hqnx/hqnx.h create mode 100644 src/gl/hqnx/hqx.h create mode 100644 src/gl/hqnx/init.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5d6719fba..29ade3566 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,1320 +1,1314 @@ -cmake_minimum_required( VERSION 2.4 ) - -if( COMMAND cmake_policy ) - cmake_policy( SET CMP0003 NEW ) -endif( COMMAND cmake_policy ) - -include( CheckCXXSourceCompiles ) -include( CheckFunctionExists ) -include( CheckCXXCompilerFlag ) -include( FindPkgConfig ) -include( FindOpenGL ) - -if( NOT APPLE ) - option( NO_ASM "Disable assembly code" OFF ) -else( NOT APPLE ) - # At the moment asm code doesn't work with OS X, so disable by default - option( NO_ASM "Disable assembly code" ON ) -endif( NOT APPLE ) -if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) - option( NO_STRIP "Do not strip Release or MinSizeRel builds" ) - # At least some versions of Xcode fail if you strip with the linker - # instead of the separate strip utility. - if( APPLE ) - set( NO_STRIP ON ) - endif( APPLE ) -endif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) - -option( DYN_FLUIDSYNTH "Dynamically load fluidsynth" ON ) - -if( CMAKE_SIZEOF_VOID_P MATCHES "8" ) - set( X64 64 ) -endif( CMAKE_SIZEOF_VOID_P MATCHES "8" ) - -# You can either use "make install" on the FMOD distribution to put it -# in standard system locations, or you can unpack the FMOD distribution -# in the root of the zdoom tree. e.g.: -# zdoom -# docs -# fmodapilinux[64] -or simply- fmod -# jpeg-6b -# ... -# The recommended method is to put it in the zdoom tree, since its -# headers are unversioned. Especially now that we can't work properly -# with anything newer than 4.26.xx, you probably don't want to use -# a system-wide version. - -# Construct version numbers for searching for the FMOD library on Linux. -set( MINOR_VERSIONS "50" "49" "48" "47" "46" "45" "44" "43" "42" "41" - "40" "39" "38" "37" "36" "35" "34" "33" "32" "31" "30" "29" "28" - "27" "26" "25" "24" "23" "22" "21" "20" "21" "19" "18" "17" "16" - "15" "14" "13" "12" "11" "10" "09" "08" "07" "06" "05" "04" "03" - "02" "01" "00" ) -set( MAJOR_VERSIONS "44" "34" "28" "26" "24" "22" "20" ) - -if( NOT FMOD_DIR_VERSIONS ) - set( FMOD_DIR_VERSIONS "" ) -endif( NOT FMOD_DIR_VERSIONS ) -if( NOT FMOD_VERSIONS ) - set( FMOD_VERSIONS "" ) -endif( NOT FMOD_VERSIONS ) -if( NOT FMOD_LOCAL_INC_DIRS ) - set( FMOD_LOCAL_INC_DIRS "" ) -endif( NOT FMOD_LOCAL_INC_DIRS ) -if( NOT FMOD_LOCAL_LIB_DIRS ) - set( FMOD_LOCAL_LIB_DIRS "" ) -endif( NOT FMOD_LOCAL_LIB_DIRS ) - -set( FMOD_DIR_VERSIONS ${FMOD_DIR_VERSIONS} "../fmod" ) -foreach( majver ${MAJOR_VERSIONS} ) - foreach( minver ${MINOR_VERSIONS} ) - set( FMOD_VERSIONS ${FMOD_VERSIONS} "fmodex${X64}-4.${majver}.${minver}" ) - set( FMOD_DIR_VERSIONS ${FMOD_DIR_VERSIONS} "${CMAKE_HOME_DIRECTORY}/fmodapi4${majver}${minver}linux${X64}" ) - endforeach( minver ${MINOR_VERSIONS} ) - foreach( dir ${FMOD_DIR_VERSIONS} ) - set( FMOD_LOCAL_INC_DIRS ${FMOD_LOCAL_INC_DIRS} "${dir}/api/inc" ) - set( FMOD_LOCAL_LIB_DIRS ${FMOD_LOCAL_LIB_DIRS} "${dir}/api/lib" ) - endforeach( dir ${FMOD_DIR_VERSIONS} ) -endforeach( majver ${MAJOR_VERSIONS} ) - -if( NOT ZDOOM_LIBS ) - set( ZDOOM_LIBS "" ) -endif( NOT ZDOOM_LIBS ) - -if( WIN32 ) - if( X64 ) - set( WIN_TYPE Win64 ) - set( XBITS x64 ) - else( X64 ) - set( WIN_TYPE Win32 ) - set( XBITS x86 ) - endif( X64 ) - - add_definitions( -D_WIN32 ) - - set( FMOD_SEARCH_PATHS - "C:/Program Files/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" - "C:/Program Files (x86)/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" - # This next one is for Randy. - "E:/Software/Dev/FMOD/${WIN_TYPE}/api" - # .. and this one for Graf Zahl - "D:/portable/FMOD SoundSystem 4.26/FMOD Programmers API WIN32/api" - ) - set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES inc ) - set( FMOD_LIB_PATH_SUFFIXES PATH_SUFFIXES lib ) - set( NASM_NAMES nasmw nasm ) - - find_path( D3D_INCLUDE_DIR d3d9.h - PATHS ENV DXSDK_DIR - PATH_SUFFIXES Include ) - if( NOT D3D_INCLUDE_DIR ) - message( SEND_ERROR "Could not find DirectX 9 header files" ) - else( NOT D3D_INCLUDE_DIR ) - include_directories( ${D3D_INCLUDE_DIR} ) - endif( NOT D3D_INCLUDE_DIR ) - - find_path( XINPUT_INCLUDE_DIR xinput.h - PATHS ENV DXSDK_DIR - PATH_SUFFIXES Include ) - if( NOT XINPUT_INCLUDE_DIR ) - message( SEND_ERROR "Could not find xinput.h. XInput will be disabled." ) - add_definitions( -DNO_XINPUT ) - else( NOT XINPUT_INCLUDE_DIR ) - include_directories( ${XINPUT_INCLUDE_DIR} ) - endif( NOT XINPUT_INCLUDE_DIR ) - - find_library( DX_dxguid_LIBRARY dxguid - PATHS ENV DXSDK_DIR - PATH_SUFFIXES Lib Lib/${XBITS} ) - find_library( DX_dinput8_LIBRARY dinput8 - PATHS ENV DXSDK_DIR - PATH_SUFFIXES Lib Lib/${XBITS} ) - - set( DX_LIBS_FOUND YES ) - if( NOT DX_dxguid_LIBRARY ) - set( DX_LIBS_FOUND NO ) - endif( NOT DX_dxguid_LIBRARY ) - if( NOT DX_dinput8_LIBRARY ) - set( DX_LIBS_FOUND NO ) - endif( NOT DX_dinput8_LIBRARY ) - - if( NOT DX_LIBS_FOUND ) - message( FATAL_ERROR "Could not find DirectX 9 libraries" ) - endif( NOT DX_LIBS_FOUND ) - - set( ZDOOM_LIBS - wsock32 - winmm - "${DX_dxguid_LIBRARY}" - "${DX_dinput8_LIBRARY}" - ole32 - user32 - gdi32 - comctl32 - comdlg32 - ws2_32 - setupapi - oleaut32 - DelayImp ) -else( WIN32 ) - if( APPLE ) - set( FMOD_SEARCH_PATHS "/Developer/FMOD Programmers API Mac/api" ) - set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES inc ) - set( FMOD_LIB_PATH_SUFFIXES PATH_SUFFIXES lib ) - set( NO_GTK ON ) - else( APPLE ) - option( NO_GTK "Disable GTK+ dialogs (Not applicable to Windows)" ) - option( VALGRIND "Add special Valgrind sequences to self-modifying code" ) - - set( FMOD_SEARCH_PATHS - /usr/local/include - /usr/local/include/fmodex - /usr/include - /usr/include/fmodex - /opt/local/include - /opt/local/include/fmodex - /opt/include - /opt/include/fmodex ) - set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES fmodex ) - - # Use GTK+ for the IWAD picker, if available. - if( NOT NO_GTK ) - pkg_check_modules( GTK2 gtk+-2.0 ) - if( GTK2_FOUND ) - set( ZDOOM_LIBS ${ZDOOM_LIBS} ${GTK2_LIBRARIES} ) - include_directories( ${GTK2_INCLUDE_DIRS} ) - else( GTK2_FOUND ) - set( NO_GTK ON ) - endif( GTK2_FOUND ) - endif( NOT NO_GTK ) - - # Check for Xcursor library and header files - find_library( XCURSOR_LIB Xcursor ) - if( XCURSOR_LIB ) - find_file( XCURSOR_HEADER "X11/Xcursor/Xcursor.h" ) - if( XCURSOR_HEADER ) - add_definitions( -DUSE_XCURSOR=1 ) - message( STATUS "Found Xcursor at ${XCURSOR_LIB}" ) - set( ZDOOM_LIBS ${ZDOOM_LIBS} ${XCURSOR_LIB} ) - else( XCURSOR_HEADER ) - unset( XCURSOR_LIB ) - endif( XCURSOR_HEADER ) - endif( XCURSOR_LIB ) - endif( APPLE ) - set( NASM_NAMES nasm ) - - if( NO_GTK ) - add_definitions( -DNO_GTK=1 ) - endif( NO_GTK ) - - # Non-Windows version also needs SDL - find_package( SDL ) - if( NOT SDL_FOUND ) - message( SEND_ERROR "SDL is required for building." ) - endif( NOT SDL_FOUND ) - set( ZDOOM_LIBS ${ZDOOM_LIBS} "${SDL_LIBRARY}" ) - include_directories( "${SDL_INCLUDE_DIR}" ) - - find_path( FPU_CONTROL_DIR fpu_control.h ) - if( FPU_CONTROL_DIR ) - include_directories( ${FPU_CONTROL_DIR} ) - add_definitions( -DHAVE_FPU_CONTROL ) - endif( FPU_CONTROL_DIR ) -endif( WIN32 ) - -if( X64 ) - set( NO_ASM ON ) -endif( X64 ) - -# Check if we have OpenGL - -if( NOT OPENGL_FOUND ) - message( FATAL_ERROR "OpenGL is required for building." ) -endif( NOT OPENGL_FOUND ) -if( NOT OPENGL_GLU_FOUND ) - message( FATAL_ERROR "OpenGL GLU is required for building." ) -endif( NOT OPENGL_GLU_FOUND ) - -set( ZDOOM_LIBS ${ZDOOM_LIBS} ${OPENGL_LIBRARIES} ) -include_directories( ${OPENGL_INCLUDE_DIR} ) - -# Decide on the name of the FMOD library we want to use. - -if( NOT FMOD_LIB_NAME AND MSVC ) - set( FMOD_LIB_NAME fmodex${X64}_vc ) -endif( NOT FMOD_LIB_NAME AND MSVC ) - -if( NOT FMOD_LIB_NAME AND BORLAND ) - set( FMOD_LIB_NAME fmodex${X64}_bc ) -endif( NOT FMOD_LIB_NAME AND BORLAND ) - -if( NOT FMOD_LIB_NAME ) - set( FMOD_LIB_NAME fmodex${X64} ) -endif( NOT FMOD_LIB_NAME ) - - -# Search for FMOD include files - -if( NOT WIN32 ) - find_path( FMOD_INCLUDE_DIR fmod.hpp - PATHS ${FMOD_LOCAL_INC_DIRS} ) -endif( NOT WIN32 ) - -if( NOT FMOD_INCLUDE_DIR ) - find_path( FMOD_INCLUDE_DIR fmod.hpp - PATHS ${FMOD_SEARCH_PATHS} - ${FMOD_INC_PATH_SUFFIXES} ) -endif( NOT FMOD_INCLUDE_DIR ) - -if( FMOD_INCLUDE_DIR ) - message( STATUS "FMOD include files found at ${FMOD_INCLUDE_DIR}" ) -else( FMOD_INCLUDE_DIR ) - message( SEND_ERROR "Could not find FMOD include files" ) -endif( FMOD_INCLUDE_DIR ) - - -# Search for FMOD library - -if( WIN32 OR APPLE ) - find_library( FMOD_LIBRARY ${FMOD_LIB_NAME} - PATHS ${FMOD_SEARCH_PATHS} - ${FMOD_LIB_PATH_SUFFIXES} ) -else( WIN32 OR APPLE ) - find_library( FMOD_LIBRARY - NAMES ${FMOD_VERSIONS} - PATHS ${FMOD_LOCAL_LIB_DIRS} ) -endif( WIN32 OR APPLE ) - -if( FMOD_LIBRARY ) - message( STATUS "FMOD library found at ${FMOD_LIBRARY}" ) -else( FMOD_LIBRARY ) - message( SEND_ERROR "Could not find FMOD library" ) -endif( FMOD_LIBRARY ) - - -# Search for FluidSynth - -find_package( FluidSynth ) - -# Search for NASM - -if( NOT NO_ASM ) - if( UNIX AND X64 ) - find_program( GAS_PATH as ) - - if( GAS_PATH ) - set( ASSEMBLER ${GAS_PATH} ) - else( GAS_PATH ) - message( STATUS "Could not find as. Disabling assembly code." ) - set( NO_ASM ON ) - endif( GAS_PATH ) - else( UNIX AND X64 ) - find_program( NASM_PATH NAMES ${NASM_NAMES} ) - find_program( YASM_PATH yasm ) - - if( X64 ) - if( YASM_PATH ) - set( ASSEMBLER ${YASM_PATH} ) - else( YASM_PATH ) - message( STATUS "Could not find YASM. Disabling assembly code." ) - set( NO_ASM ON ) - endif( YASM_PATH ) - else( X64 ) - if( NASM_PATH ) - set( ASSEMBLER ${NASM_PATH} ) - else( NASM_PATH ) - message( STATUS "Could not find NASM. Disabling assembly code." ) - set( NO_ASM ON ) - endif( NASM_PATH ) - endif( X64 ) - endif( UNIX AND X64 ) - - # I think the only reason there was a version requirement was because the - # executable name for Windows changed from 0.x to 2.0, right? This is - # how to do it in case I need to do something similar later. - - # execute_process( COMMAND ${NASM_PATH} -v - # OUTPUT_VARIABLE NASM_VER_STRING ) - # string( REGEX REPLACE ".*version ([0-9]+[.][0-9]+).*" "\\1" NASM_VER "${NASM_VER_STRING}" ) - # if( NOT NASM_VER LESS 2 ) - # message( SEND_ERROR "NASM version should be 2 or later. (Installed version is ${NASM_VER}.)" ) - # endif( NOT NASM_VER LESS 2 ) -endif( NOT NO_ASM ) - -if( NOT NO_ASM ) - # Valgrind support is meaningless without assembly code. - if( VALGRIND ) - add_definitions( -DVALGRIND_AWARE=1 ) - # If you're Valgrinding, you probably want to keep symbols around. - set( NO_STRIP ON ) - endif( VALGRIND ) - - # Tell CMake how to assemble our files - if( UNIX ) - set( ASM_OUTPUT_EXTENSION .o ) - if( X64 ) - set( ASM_FLAGS ) - set( ASM_SOURCE_EXTENSION .s ) - else( X64 ) - if( APPLE ) - set( ASM_FLAGS -fmacho -DM_TARGET_MACHO ) - else( APPLE ) - set( ASM_FLAGS -felf -DM_TARGET_LINUX ) - endif( APPLE ) - set( ASM_FLAGS "${ASM_FLAGS}" -i${CMAKE_CURRENT_SOURCE_DIR}/ ) - set( ASM_SOURCE_EXTENSION .asm ) - endif( X64 ) - else( UNIX ) - set( ASM_OUTPUT_EXTENSION .obj ) - set( ASM_SOURCE_EXTENSION .asm ) - if( X64 ) - set( ASM_FLAGS -f win64 -DWIN32 -DWIN64 ) - else( X64 ) - set( ASM_FLAGS -f win32 -DWIN32 -i${CMAKE_CURRENT_SOURCE_DIR}/ ) - endif( X64 ) - endif( UNIX ) - if( WIN32 ) - set( FIXRTEXT fixrtext ) - else( WIN32 ) - set( FIXRTEXT "" ) - endif( WIN32 ) - message( STATUS "Selected assembler: ${ASSEMBLER}" ) - MACRO( ADD_ASM_FILE indir infile ) - set( ASM_OUTPUT_${infile} "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/zdoom.dir/${indir}/${infile}${ASM_OUTPUT_EXTENSION}" ) - if( WIN32 ) - set( FIXRTEXT_${infile} COMMAND ${FIXRTEXT} "${ASM_OUTPUT_${infile}}" ) - else( WIN32 ) - set( FIXRTEXT_${infile} COMMAND "" ) - endif( WIN32 ) - add_custom_command( OUTPUT ${ASM_OUTPUT_${infile}} - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/zdoom.dir/${indir} - COMMAND ${ASSEMBLER} ${ASM_FLAGS} -o"${ASM_OUTPUT_${infile}}" "${CMAKE_CURRENT_SOURCE_DIR}/${indir}/${infile}${ASM_SOURCE_EXTENSION}" - ${FIXRTEXT_${infile}} - DEPENDS ${indir}/${infile}.asm ${FIXRTEXT} ) - set( ASM_SOURCES ${ASM_SOURCES} "${ASM_OUTPUT_${infile}}" ) - ENDMACRO( ADD_ASM_FILE ) -endif( NOT NO_ASM ) - -# OpenGL on OS X: Search for GLEW include files - -if( APPLE ) - find_path( GLEW_INCLUDE_DIR GL/glew.h - PATHS "/usr/include" - "/usr/local/include" ) - - if( GLEW_INCLUDE_DIR ) - message( STATUS "GLEW include files found at ${GLEW_INCLUDE_DIR}" ) - else( GLEW_INCLUDE_DIR ) - message( SEND_ERROR "Could not find GLEW include files" ) - endif( GLEW_INCLUDE_DIR ) -endif( APPLE ) - -# Decide on SSE setup - -set( SSE_MATTERS NO ) - -# with global use of SSE 2 we do not need special handling for selected files -if (NOT ZDOOM_USE_SSE2) - # SSE only matters on 32-bit targets. We check compiler flags to know if we can do it. - if( CMAKE_SIZEOF_VOID_P MATCHES "4" AND NOT CMAKE_OSX_ARCHITECTURES MATCHES ppc ) - CHECK_CXX_COMPILER_FLAG( "-msse2 -mfpmath=sse" CAN_DO_MFPMATH ) - CHECK_CXX_COMPILER_FLAG( -arch:SSE2 CAN_DO_ARCHSSE2 ) - if( CAN_DO_MFPMATH ) - set( SSE1_ENABLE "-msse -mfpmath=sse" ) - set( SSE2_ENABLE "-msse2 -mfpmath=sse" ) - set( SSE_MATTERS YES ) - elseif( CAN_DO_ARCHSSE2 ) - set( SSE1_ENABLE -arch:SSE ) - set( SSE2_ENABLE -arch:SSE2 ) - set( SSE_MATTERS YES ) - endif( CAN_DO_MFPMATH ) - endif( CMAKE_SIZEOF_VOID_P MATCHES "4" AND NOT CMAKE_OSX_ARCHITECTURES MATCHES ppc ) -endif (NOT ZDOOM_USE_SSE2) - -if( SSE_MATTERS ) - if( WIN32 ) - set( BACKPATCH 1 CACHE BOOL "Enable backpatching." ) - else( WIN32 ) - CHECK_FUNCTION_EXISTS(mprotect HAVE_MPROTECT) - if( HAVE_MPROTECT ) - set( BACKPATCH 1 CACHE BOOL "Enable backpatching." ) - else( HAVE_MPROTECT ) - set( BACKPATCH 0 ) - endif( HAVE_MPROTECT ) - endif( WIN32 ) - set( SSE 1 CACHE BOOL "Build SSE and SSE2 versions of key code." ) -else( SSE_MATTERS ) - set( BACKPATCH 0 ) -endif( SSE_MATTERS ) - -# Set up flags for GCC - -if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) - if( PROFILE ) - set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -pg" ) - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg" ) - set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -pg" ) - set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -pg" ) - endif( PROFILE ) - - set( REL_CXX_FLAGS "-fno-rtti" ) - if( NOT PROFILE ) - set( REL_CXX_FLAGS "${REL_CXX_FLAGS} -fomit-frame-pointer" ) - endif( NOT PROFILE ) - set( CMAKE_CXX_FLAGS_RELEASE "${REL_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}" ) - set( CMAKE_CXX_FLAGS_MINSIZEREL "${REL_CXX_FLAGS} ${CMAKE_CXX_FLAGS_MINSIZEREL}" ) - set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${REL_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" ) - - set( CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers ${CMAKE_CXX_FLAGS}" ) - - # Remove extra warnings when using the official DirectX headers. - # Also, TDM-GCC 4.4.0 no longer accepts glibc-style printf formats as valid, - # which is a royal pain. The previous version I had been using was fine with them. - if( WIN32 ) - set( CMAKE_CXX_FLAGS "-Wno-unknown-pragmas -Wno-comment -Wno-format ${CMAKE_CXX_FLAGS}" ) - endif( WIN32 ) - - if( NOT NO_STRIP ) - set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s" ) - set (CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} -s" ) - endif( NOT NO_STRIP ) -endif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) - -# Check for functions that may or may not exist. - -CHECK_FUNCTION_EXISTS( filelength FILELENGTH_EXISTS ) -if( FILELENGTH_EXISTS ) - add_definitions( -DHAVE_FILELENGTH=1 ) -endif( FILELENGTH_EXISTS ) - -CHECK_FUNCTION_EXISTS( strupr STRUPR_EXISTS ) -if( NOT STRUPR_EXISTS ) - add_definitions( -DNEED_STRUPR=1 ) -endif( NOT STRUPR_EXISTS ) - -CHECK_FUNCTION_EXISTS( stricmp STRICMP_EXISTS ) -if( NOT STRICMP_EXISTS ) - add_definitions( -Dstricmp=strcasecmp ) -endif( NOT STRICMP_EXISTS ) - -CHECK_FUNCTION_EXISTS( strnicmp STRNICMP_EXISTS ) -if( NOT STRNICMP_EXISTS ) - add_definitions( -Dstrnicmp=strncasecmp ) -endif( NOT STRNICMP_EXISTS ) - -if( NOT MSVC ) - add_definitions( -D__forceinline=inline ) -endif( NOT MSVC ) - -if( UNIX ) - CHECK_LIBRARY_EXISTS( rt clock_gettime "" CLOCK_GETTIME_IN_RT ) - if( NOT CLOCK_GETTIME_IN_RT ) - CHECK_FUNCTION_EXISTS( clock_gettime CLOCK_GETTIME_EXISTS ) - if( NOT CLOCK_GETTIME_EXISTS ) - message( STATUS "Could not find clock_gettime. Timing statistics will not be available." ) - add_definitions( -DNO_CLOCK_GETTIME ) - endif( NOT CLOCK_GETTIME_EXISTS ) - else( NOT CLOCK_GETTIME_IN_RT ) - set( ZDOOM_LIBS ${ZDOOM_LIBS} rt ) - endif( NOT CLOCK_GETTIME_IN_RT ) -endif( UNIX ) - -CHECK_CXX_SOURCE_COMPILES( - "#include - int main() { va_list list1, list2; va_copy(list1, list2); return 0; }" - HAS_VA_COPY ) -if( NOT HAS_VA_COPY ) - CHECK_CXX_SOURCE_COMPILES( - "#include - int main() { va_list list1, list2; __va_copy(list1, list2); return 0; }" - HAS___VA_COPY ) - if( HAS___VA_COPY ) - add_definitions( -Dva_copy=__va_copy ) - else( HAS___VA_COPY ) - add_definitions( -DNO_VA_COPY ) - endif( HAS___VA_COPY ) -endif( NOT HAS_VA_COPY ) - -# Flags - -if( BACKPATCH ) - add_definitions( -DBACKPATCH ) -endif( BACKPATCH ) - -# Update gitinfo.h - -get_target_property( UPDATEREVISION_EXE updaterevision LOCATION ) - -add_custom_target( revision_check ALL - COMMAND ${UPDATEREVISION_EXE} src/gitinfo.h - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - DEPENDS updaterevision ) - -# Libraries ZDoom needs - -message( STATUS "Fluid synth libs: ${FLUIDSYNTH_LIBRARIES}" ) -set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${GME_LIBRARIES}" "${FMOD_LIBRARY}" ) -include_directories( "${ZLIB_INCLUDE_DIR}" "${FMOD_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GME_INCLUDE_DIR}" ) - -if( NOT DYN_FLUIDSYNTH) - if( FLUIDSYNTH_FOUND ) - set( ZDOOM_LIBS ${ZDOOM_LIBS} "${FLUIDSYNTH_LIBRARIES}" ) - include_directories( "${FLUIDSYNTH_INCLUDE_DIR}" ) - endif( FLUIDSYNTH_FOUND ) -else( NOT DYN_FLUIDSYNTH ) - set( ZDOOM_LIBS ${ZDOOM_LIBS} ${CMAKE_DL_LIBS} ) -endif( NOT DYN_FLUIDSYNTH ) - -# OpenGL on OS X: GLEW include directory - -if( APPLE ) - include_directories( "${GLEW_INCLUDE_DIR}" ) -endif( APPLE ) - -# Start defining source files for ZDoom -set( PLAT_WIN32_SOURCES - win32/eaxedit.cpp - win32/fb_d3d9.cpp - win32/fb_d3d9_wipe.cpp - win32/fb_ddraw.cpp - win32/hardware.cpp - win32/helperthread.cpp - win32/i_cd.cpp - win32/i_crash.cpp - win32/i_input.cpp - win32/i_keyboard.cpp - win32/i_mouse.cpp - win32/i_dijoy.cpp - win32/i_rawps2.cpp - win32/i_xinput.cpp - win32/i_main.cpp - win32/i_movie.cpp - win32/i_system.cpp - win32/st_start.cpp - win32/win32gliface.cpp - win32/win32video.cpp ) -set( PLAT_SDL_SOURCES - sdl/crashcatcher.c - sdl/hardware.cpp - sdl/i_cd.cpp - sdl/i_input.cpp - sdl/i_joystick.cpp - sdl/i_main.cpp - sdl/i_movie.cpp - sdl/i_system.cpp - sdl/sdlvideo.cpp - sdl/sdlglvideo.cpp - sdl/st_start.cpp ) -set( PLAT_MAC_SOURCES - sdl/SDLMain.m - sdl/iwadpicker_cocoa.mm - sdl/i_system_cocoa.mm ) -if( WIN32 ) - set( SYSTEM_SOURCES_DIR win32 ) - set( SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ) - set( OTHER_SYSTEM_SOURCES ${PLAT_SDL_SOURCES} ${PLAT_MAC_SOURCES} ) - - if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) - # CMake is not set up to compile and link rc files with GCC. :( - add_custom_command( OUTPUT zdoom-rc.o - COMMAND windres -o zdoom-rc.o -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zdoom.rc - DEPENDS win32/zdoom.rc ) - set( SYSTEM_SOURCES ${SYSTEM_SOURCES} zdoom-rc.o ) - else( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) - set( SYSTEM_SOURCES ${SYSTEM_SOURCES} win32/zdoom.rc ) - endif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) - - # [BB] Maxim Stepin's hq2x/3x/4x pixel upsampling algorithm as library. Currently only used with VC++. - if( MSVC AND NOT X64 ) - set( SYSTEM_SOURCES - ${SYSTEM_SOURCES} - gl/hqnx/Image.cpp - gl/hqnx/hq2x.cpp - gl/hqnx/hq3x.cpp - gl/hqnx/hq4x.cpp - ) - endif( MSVC AND NOT X64) -else( WIN32 ) - set( SYSTEM_SOURCES_DIR sdl ) - set( SYSTEM_SOURCES ${PLAT_SDL_SOURCES} ) - if( APPLE ) - set( SYSTEM_SOURCES ${SYSTEM_SOURCES} ${PLAT_MAC_SOURCES} ) - set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ) - else( APPLE ) - set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_MAC_SOURCES} ) - endif( APPLE ) -endif( WIN32 ) - -if( NO_ASM ) - add_definitions( -DNOASM ) -else( NO_ASM ) - if( NOT ASM_SOURCES ) - set( ASM_SOURCES "" ) - endif( NOT ASM_SOURCES ) - if( X64 ) - ADD_ASM_FILE( asm_x86_64 tmap3 ) - else( X64 ) - ADD_ASM_FILE( asm_ia32 a ) - ADD_ASM_FILE( asm_ia32 misc ) - ADD_ASM_FILE( asm_ia32 tmap ) - ADD_ASM_FILE( asm_ia32 tmap2 ) - ADD_ASM_FILE( asm_ia32 tmap3 ) - endif( X64 ) -endif( NO_ASM ) - -get_target_property( LEMON_EXE lemon LOCATION ) -get_target_property( RE2C_EXE re2c LOCATION ) - -add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.h - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/xlat/xlat_parser.y . - COMMAND ${LEMON_EXE} xlat_parser.y - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS lemon ${CMAKE_CURRENT_SOURCE_DIR}/xlat/xlat_parser.y ) - -add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h - COMMAND ${RE2C_EXE} --no-generation-date -s -o ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h ${CMAKE_CURRENT_SOURCE_DIR}/sc_man_scanner.re - DEPENDS re2c ${CMAKE_CURRENT_SOURCE_DIR}/sc_man_scanner.re ) - -include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) - -if( SSE_MATTERS ) - if( SSE ) - set( X86_SOURCES nodebuild_classify_sse2.cpp ) - set_source_files_properties( nodebuild_classify_sse2.cpp PROPERTIES COMPILE_FLAGS "${SSE2_ENABLE}" ) - else( SSE ) - add_definitions( -DDISABLE_SSE ) - endif( SSE ) -else( SSE_MATTERS ) - add_definitions( -DDISABLE_SSE ) - set( X86_SOURCES ) -endif( SSE_MATTERS ) - -if( DYN_FLUIDSYNTH ) - add_definitions( -DHAVE_FLUIDSYNTH -DDYN_FLUIDSYNTH ) -elseif( FLUIDSYNTH_FOUND ) - add_definitions( -DHAVE_FLUIDSYNTH ) -endif( DYN_FLUIDSYNTH ) - -# Project files should be aware of the header files. We can GLOB these since -# there's generally a new cpp for every header so this file will get changed -if( WIN32 ) - set( EXTRA_HEADER_DIRS win32/*.h ) -else( WIN32 ) - set( EXTRA_HEADER_DIRS sdl/*.h ) -endif( WIN32 ) -file( GLOB HEADER_FILES - ${EXTRA_HEADER_DIRS} - fragglescript/*.h - g_doom/*.h - g_heretic/*.h - g_hexen/*.h - g_raven/*.h - g_shared/*.h - g_strife/*.h - intermission/*.h - menu/*.h - oplsynth/*.h - oplsynth/dosbox/*.h - r_data/*.h - resourcefiles/*.h - sdl/*.h - sfmt/*.h - sound/*.h - textures/*.h - thingdef/*.h - xlat/*.h - gl/*.h - gl/api/*.h - gl/data/*.h - gl/dynlights/*.h - gl/hqnx/*.h - gl/models/*.h - gl/renderer/*.h - gl/scene/*.h - gl/shaders/*.h - gl/system/*.h - gl/textures/*.h - gl/utility/*.h - *.h -) - -# These files will be flagged as "headers" so that they appear in project files -# without being compiled. -set( NOT_COMPILED_SOURCE_FILES - ${OTHER_SYSTEM_SOURCES} - sc_man_scanner.h - sc_man_scanner.re - g_doom/a_arachnotron.cpp - g_doom/a_archvile.cpp - g_doom/a_bossbrain.cpp - g_doom/a_bruiser.cpp - g_doom/a_cacodemon.cpp - g_doom/a_cyberdemon.cpp - g_doom/a_demon.cpp - g_doom/a_doomimp.cpp - g_doom/a_doomweaps.cpp - g_doom/a_fatso.cpp - g_doom/a_keen.cpp - g_doom/a_lostsoul.cpp - g_doom/a_painelemental.cpp - g_doom/a_possessed.cpp - g_doom/a_revenant.cpp - g_doom/a_scriptedmarine.cpp - g_doom/a_spidermaster.cpp - g_heretic/a_chicken.cpp - g_heretic/a_dsparil.cpp - g_heretic/a_hereticartifacts.cpp - g_heretic/a_hereticimp.cpp - g_heretic/a_hereticweaps.cpp - g_heretic/a_ironlich.cpp - g_heretic/a_knight.cpp - g_heretic/a_wizard.cpp - g_hexen/a_bats.cpp - g_hexen/a_bishop.cpp - g_hexen/a_blastradius.cpp - g_hexen/a_boostarmor.cpp - g_hexen/a_centaur.cpp - g_hexen/a_clericflame.cpp - g_hexen/a_clericholy.cpp - g_hexen/a_clericmace.cpp - g_hexen/a_clericstaff.cpp - g_hexen/a_dragon.cpp - g_hexen/a_fighteraxe.cpp - g_hexen/a_fighterhammer.cpp - g_hexen/a_fighterplayer.cpp - g_hexen/a_fighterquietus.cpp - g_hexen/a_firedemon.cpp - g_hexen/a_flechette.cpp - g_hexen/a_fog.cpp - g_hexen/a_healingradius.cpp - g_hexen/a_heresiarch.cpp - g_hexen/a_hexenspecialdecs.cpp - g_hexen/a_iceguy.cpp - g_hexen/a_korax.cpp - g_hexen/a_magecone.cpp - g_hexen/a_magelightning.cpp - g_hexen/a_magestaff.cpp - g_hexen/a_pig.cpp - g_hexen/a_serpent.cpp - g_hexen/a_spike.cpp - g_hexen/a_summon.cpp - g_hexen/a_teleportother.cpp - g_hexen/a_wraith.cpp - g_strife/a_acolyte.cpp - g_strife/a_alienspectres.cpp - g_strife/a_coin.cpp - g_strife/a_crusader.cpp - g_strife/a_entityboss.cpp - g_strife/a_inquisitor.cpp - g_strife/a_oracle.cpp - g_strife/a_programmer.cpp - g_strife/a_reaver.cpp - g_strife/a_rebels.cpp - g_strife/a_sentinel.cpp - g_strife/a_stalker.cpp - g_strife/a_strifeitems.cpp - g_strife/a_strifeweapons.cpp - g_strife/a_templar.cpp - g_strife/a_thingstoblowup.cpp - g_shared/sbarinfo_commands.cpp - xlat/xlat_parser.y - xlat_parser.c - xlat_parser.h - - # We could have the ASM macro add these files, but it wouldn't add all - # platforms. - asm_ia32/a.asm - asm_ia32/misc.asm - asm_ia32/tmap.asm - asm_ia32/tmap2.asm - asm_ia32/tmap3.asm - asm_x86_64/tmap3.asm - asm_x86_64/tmap3.s -) - -add_executable( zdoom WIN32 - ${HEADER_FILES} - ${NOT_COMPILED_SOURCE_FILES} - __autostart.cpp - ${ASM_SOURCES} - ${SYSTEM_SOURCES} - ${X86_SOURCES} - x86.cpp - actorptrselect.cpp - am_map.cpp - b_bot.cpp - b_func.cpp - b_game.cpp - b_move.cpp - b_think.cpp - bbannouncer.cpp - c_bind.cpp - c_cmds.cpp - c_console.cpp - c_cvars.cpp - c_dispatch.cpp - c_expr.cpp - cmdlib.cpp - colormatcher.cpp - compatibility.cpp - configfile.cpp - ct_chat.cpp - d_dehacked.cpp - d_iwad.cpp - d_main.cpp - d_net.cpp - d_netinfo.cpp - d_protocol.cpp - decallib.cpp - dobject.cpp - dobjgc.cpp - dobjtype.cpp - doomdef.cpp - doomstat.cpp - dsectoreffect.cpp - dthinker.cpp - f_wipe.cpp - farchive.cpp - files.cpp - g_game.cpp - g_hub.cpp - g_level.cpp - g_mapinfo.cpp - g_skill.cpp - gameconfigfile.cpp - gi.cpp - gitinfo.cpp - hu_scores.cpp - i_net.cpp - info.cpp - keysections.cpp - lumpconfigfile.cpp - m_alloc.cpp - m_argv.cpp - m_bbox.cpp - m_cheat.cpp - m_joy.cpp - m_misc.cpp - m_png.cpp - m_random.cpp - m_specialpaths.cpp - memarena.cpp - md5.cpp - name.cpp - nodebuild.cpp - nodebuild_classify_nosse2.cpp - nodebuild_events.cpp - nodebuild_extract.cpp - nodebuild_gl.cpp - nodebuild_utility.cpp - p_3dfloors.cpp - p_3dmidtex.cpp - p_acs.cpp - p_buildmap.cpp - p_ceiling.cpp - p_conversation.cpp - p_doors.cpp - p_effect.cpp - p_enemy.cpp - p_floor.cpp - p_glnodes.cpp - p_interaction.cpp - p_lights.cpp - p_linkedsectors.cpp - p_lnspec.cpp - p_map.cpp - p_maputl.cpp - p_mobj.cpp - p_pillar.cpp - p_plats.cpp - p_pspr.cpp - p_saveg.cpp - p_sectors.cpp - p_setup.cpp - p_sight.cpp - p_slopes.cpp - p_spec.cpp - p_states.cpp - p_switch.cpp - p_teleport.cpp - p_terrain.cpp - p_things.cpp - p_tick.cpp - p_trace.cpp - p_udmf.cpp - p_usdf.cpp - p_user.cpp - p_writemap.cpp - p_xlat.cpp - parsecontext.cpp - po_man.cpp - r_swrenderer.cpp - r_utility.cpp - r_3dfloors.cpp - r_bsp.cpp - r_draw.cpp - r_drawt.cpp - r_main.cpp - r_plane.cpp - r_polymost.cpp - r_segs.cpp - r_sky.cpp - r_things.cpp - s_advsound.cpp - s_environment.cpp - s_playlist.cpp - s_sndseq.cpp - s_sound.cpp - sc_man.cpp - st_stuff.cpp - statistics.cpp - stats.cpp - stringtable.cpp - strnatcmp.c - tables.cpp - teaminfo.cpp - tempfiles.cpp - v_blend.cpp - v_collection.cpp - v_draw.cpp - v_font.cpp - v_palette.cpp - v_pfx.cpp - v_text.cpp - v_video.cpp - w_wad.cpp - wi_stuff.cpp - zstrformat.cpp - zstring.cpp - g_doom/a_doommisc.cpp - g_heretic/a_hereticmisc.cpp - g_hexen/a_hexenmisc.cpp - g_raven/a_artitele.cpp - g_raven/a_minotaur.cpp - g_strife/a_strifestuff.cpp - g_strife/strife_sbar.cpp - g_shared/a_action.cpp - g_shared/a_armor.cpp - g_shared/a_artifacts.cpp - g_shared/a_bridge.cpp - g_shared/a_camera.cpp - g_shared/a_debris.cpp - g_shared/a_decals.cpp - g_shared/a_fastprojectile.cpp - g_shared/a_flashfader.cpp - g_shared/a_fountain.cpp - g_shared/a_hatetarget.cpp - g_shared/a_keys.cpp - g_shared/a_lightning.cpp - g_shared/a_mapmarker.cpp - g_shared/a_morph.cpp - g_shared/a_movingcamera.cpp - g_shared/a_pickups.cpp - g_shared/a_puzzleitems.cpp - g_shared/a_quake.cpp - g_shared/a_randomspawner.cpp - g_shared/a_secrettrigger.cpp - g_shared/a_sectoraction.cpp - g_shared/a_setcolor.cpp - g_shared/a_skies.cpp - g_shared/a_soundenvironment.cpp - g_shared/a_soundsequence.cpp - g_shared/a_spark.cpp - g_shared/a_specialspot.cpp - g_shared/a_waterzone.cpp - g_shared/a_weaponpiece.cpp - g_shared/a_weapons.cpp - g_shared/hudmessages.cpp - g_shared/sbarinfo.cpp - g_shared/sbar_mugshot.cpp - g_shared/shared_hud.cpp - g_shared/shared_sbar.cpp - intermission/intermission.cpp - intermission/intermission_parse.cpp - menu/colorpickermenu.cpp - menu/joystickmenu.cpp - menu/listmenu.cpp - menu/loadsavemenu.cpp - menu/menu.cpp - menu/menudef.cpp - menu/menuinput.cpp - menu/messagebox.cpp - menu/optionmenu.cpp - menu/playerdisplay.cpp - menu/playermenu.cpp - menu/readthis.cpp - menu/videomenu.cpp - gl/api/gl_api.cpp - gl/data/gl_sections.cpp - gl/data/gl_data.cpp - gl/data/gl_portaldata.cpp - gl/data/gl_setup.cpp - gl/data/gl_vertexbuffer.cpp - gl/dynlights/a_dynlight.cpp - gl/utility/gl_clock.cpp - gl/utility/gl_cycler.cpp - gl/utility/gl_geometric.cpp - gl/renderer/gl_renderer.cpp - gl/renderer/gl_renderstate.cpp - gl/renderer/gl_lightdata.cpp - gl/textures/gl_hwtexture.cpp - gl/textures/gl_texture.cpp - gl/textures/gl_material.cpp - gl/textures/gl_hirestex.cpp - gl/textures/gl_bitmap.cpp - gl/textures/gl_translate.cpp - gl/textures/gl_hqresize.cpp - gl/textures/gl_skyboxtexture.cpp - gl/scene/gl_bsp.cpp - gl/scene/gl_fakeflat.cpp - gl/scene/gl_clipper.cpp - gl/scene/gl_decal.cpp - gl/scene/gl_drawinfo.cpp - gl/scene/gl_flats.cpp - gl/scene/gl_walls.cpp - gl/scene/gl_sprite.cpp - gl/scene/gl_skydome.cpp - gl/scene/gl_renderhacks.cpp - gl/scene/gl_weapon.cpp - gl/scene/gl_scene.cpp - gl/scene/gl_sky.cpp - gl/scene/gl_portal.cpp - gl/scene/gl_walls_draw.cpp - gl/scene/gl_vertex.cpp - gl/scene/gl_spritelight.cpp - gl/dynlights/gl_dynlight.cpp - gl/dynlights/gl_glow.cpp - gl/dynlights/gl_dynlight1.cpp - gl/dynlights/gl_lightbuffer.cpp - gl/shaders/gl_shader.cpp - gl/shaders/gl_texshader.cpp - gl/system/gl_interface.cpp - gl/system/gl_framebuffer.cpp - gl/system/gl_menu.cpp - gl/system/gl_wipe.cpp - gl/models/gl_models_md3.cpp - gl/models/gl_models_md2.cpp - gl/models/gl_models.cpp - gl/models/gl_voxels.cpp - oplsynth/fmopl.cpp - oplsynth/mlopl.cpp - oplsynth/mlopl_io.cpp - oplsynth/music_opldumper_mididevice.cpp - oplsynth/music_opl_mididevice.cpp - oplsynth/opl_mus_player.cpp - oplsynth/dosbox/opl.cpp - oplsynth/OPL3.cpp - resourcefiles/ancientzip.cpp - resourcefiles/file_7z.cpp - resourcefiles/file_grp.cpp - resourcefiles/file_lump.cpp - resourcefiles/file_rff.cpp - resourcefiles/file_wad.cpp - resourcefiles/file_zip.cpp - resourcefiles/file_pak.cpp - resourcefiles/file_directory.cpp - resourcefiles/resourcefile.cpp - sfmt/SFMT.cpp - sound/fmodsound.cpp - sound/i_music.cpp - sound/i_sound.cpp - sound/music_cd.cpp - sound/music_dumb.cpp - sound/music_gme.cpp - sound/music_mus_midiout.cpp - sound/music_smf_midiout.cpp - sound/music_hmi_midiout.cpp - sound/music_xmi_midiout.cpp - sound/music_midistream.cpp - sound/music_midi_base.cpp - sound/music_midi_timidity.cpp - sound/music_mus_opl.cpp - sound/music_stream.cpp - sound/music_fluidsynth_mididevice.cpp - sound/music_softsynth_mididevice.cpp - sound/music_timidity_mididevice.cpp - sound/music_win_mididevice.cpp - sound/music_pseudo_mididevice.cpp - textures/animations.cpp - textures/anim_switches.cpp - textures/automaptexture.cpp - textures/bitmap.cpp - textures/buildtexture.cpp - textures/canvastexture.cpp - textures/ddstexture.cpp - textures/flattexture.cpp - textures/imgztexture.cpp - textures/jpegtexture.cpp - textures/multipatchtexture.cpp - textures/patchtexture.cpp - textures/pcxtexture.cpp - textures/pngtexture.cpp - textures/rawpagetexture.cpp - textures/emptytexture.cpp - textures/texture.cpp - textures/texturemanager.cpp - textures/tgatexture.cpp - textures/warptexture.cpp - thingdef/olddecorations.cpp - thingdef/thingdef.cpp - thingdef/thingdef_codeptr.cpp - thingdef/thingdef_data.cpp - thingdef/thingdef_exp.cpp - thingdef/thingdef_expression.cpp - thingdef/thingdef_function.cpp - thingdef/thingdef_parse.cpp - thingdef/thingdef_properties.cpp - thingdef/thingdef_states.cpp - timidity/common.cpp - timidity/instrum.cpp - timidity/instrum_dls.cpp - timidity/instrum_font.cpp - timidity/instrum_sf2.cpp - timidity/mix.cpp - timidity/playmidi.cpp - timidity/resample.cpp - timidity/timidity.cpp - xlat/parse_xlat.cpp - fragglescript/t_fspic.cpp - fragglescript/t_func.cpp - fragglescript/t_load.cpp - fragglescript/t_oper.cpp - fragglescript/t_parse.cpp - fragglescript/t_prepro.cpp - fragglescript/t_script.cpp - fragglescript/t_spec.cpp - fragglescript/t_variable.cpp - fragglescript/t_cmd.cpp - r_data/colormaps.cpp - r_data/sprites.cpp - r_data/voxels.cpp - r_data/renderstyle.cpp - r_data/r_interpolate.cpp - r_data/r_translate.cpp - zzautozend.cpp -) - -set_source_files_properties( xlat/parse_xlat.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c" ) -set_source_files_properties( sc_man.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h" ) -set_source_files_properties( ${NOT_COMPILED_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE ) - -if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS") - # [BL] Solaris requires these to be explicitly linked. - set( ZDOOM_LIBS ${ZDOOM_LIBS} nsl socket) -endif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS") - -target_link_libraries( zdoom ${ZDOOM_LIBS} gdtoa dumb lzma ) -include_directories( . - g_doom - g_heretic - g_hexen - g_raven - g_strife - g_shared - oplsynth - sound - textures - thingdef - timidity - xlat - ../gdtoa - ../dumb/include - ${CMAKE_BINARY_DIR}/gdtoa - ${SYSTEM_SOURCES_DIR} ) - -add_dependencies( zdoom revision_check ) - -# Due to some quirks, we need to do this in this order -if( NOT ZDOOM_OUTPUT_OLDSTYLE OR NO_GENERATOR_EXPRESSIONS ) - # RUNTIME_OUTPUT_DIRECTORY does not exist in CMake 2.4. - # Linux distributions are slow to adopt 2.6. :( - set_target_properties( zdoom PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ZDOOM_OUTPUT_DIR} ) - set_target_properties( zdoom PROPERTIES OUTPUT_NAME ${ZDOOM_EXE_NAME} ) -else( NOT ZDOOM_OUTPUT_OLDSTYLE OR NO_GENERATOR_EXPRESSIONS ) - set_target_properties( zdoom PROPERTIES - RUNTIME_OUTPUT_NAME ${ZDOOM_EXE_NAME} - RUNTIME_OUTPUT_DIRECTORY_RELEASE ${ZDOOM_OUTPUT_DIR} - RUNTIME_OUTPUT_NAME_DEBUG ${ZDOOM_EXE_NAME}d - RUNTIME_OUTPUT_DIRECTORY_DEBUG ${ZDOOM_OUTPUT_DIR} - RUNTIME_OUTPUT_NAME_MINSIZEREL ${ZDOOM_EXE_NAME}msr - RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${ZDOOM_OUTPUT_DIR} - RUNTIME_OUTPUT_NAME_RELWITHDEBINFO ${ZDOOM_EXE_NAME}rd - RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${ZDOOM_OUTPUT_DIR} - ) -endif( NOT ZDOOM_OUTPUT_OLDSTYLE OR NO_GENERATOR_EXPRESSIONS ) - -if( MSVC ) - option( ZDOOM_GENERATE_MAPFILE "Generate .map file for debugging." OFF ) - if( ZDOOM_GENERATE_MAPFILE ) - set_target_properties(zdoom PROPERTIES LINK_FLAGS "/MANIFEST:NO /DELAYLOAD:\"fmodex${X64}.dll\" /MAP") - else( ZDOOM_GENERATE_MAPFILE ) - set_target_properties(zdoom PROPERTIES LINK_FLAGS "/MANIFEST:NO /DELAYLOAD:\"fmodex${X64}.dll\"") - endif( ZDOOM_GENERATE_MAPFILE ) - - add_custom_command(TARGET zdoom POST_BUILD - COMMAND "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\win32\\zdoom.exe.manifest\" -outputresource:\"$(TargetDir)$(TargetFileName)\"\;\#1 - COMMENT "Adding manifest..." - ) - - create_default_target_launcher( zdoom WORKING_DIRECTORY ${ZDOOM_OUTPUT_DIR} ) -endif( MSVC ) - -if( NOT WIN32 ) - FILE( WRITE ${CMAKE_CURRENT_BINARY_DIR}/link-make "if [ ! -e ${ZDOOM_OUTPUT_DIR}/${ZDOOM_EXE_NAME} ]; then ln -sf ${CMAKE_CURRENT_BINARY_DIR}/${ZDOOM_EXE_NAME} ${ZDOOM_OUTPUT_DIR}/${ZDOOM_EXE_NAME}; fi" ) - add_custom_command( TARGET zdoom POST_BUILD - COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/link-make - COMMAND /bin/sh -c ${CMAKE_CURRENT_BINARY_DIR}/link-make ) -endif( NOT WIN32 ) -if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) - # GCC misoptimizes this file - set_source_files_properties( oplsynth/fmopl.cpp PROPERTIES COMPILE_FLAGS "-fno-tree-dominator-opts -fno-tree-fre" ) -endif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) -if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) - # Need to enable intrinsics for this file. - if( SSE_MATTERS ) - set_source_files_properties( x86.cpp PROPERTIES COMPILE_FLAGS "-msse2 -mmmx" ) - endif( SSE_MATTERS ) -endif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) - -source_group("Assembly Files\\ia32" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/asm_ia32/.+") -source_group("Assembly Files\\x86_64" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/asm_x86_64/.+") -source_group("Audio Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sound/.+") -source_group("Audio Files\\OPL Synth" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/oplsynth/.+") -source_group("Audio Files\\OPL Synth\\DOSBox" FILES oplsynth/dosbox/opl.cpp oplsynth/dosbox/opl.h) -source_group("Audio Files\\Timidity\\Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/timidity/.+\\.h$") -source_group("Audio Files\\Timidity\\Source" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/timidity/.+\\.cpp$") -source_group("Decorate++" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/thingdef/.+") -source_group("FraggleScript" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/fragglescript/.+") -source_group("Games\\Doom Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_doom/.+") -source_group("Games\\Heretic Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_heretic/.+") -source_group("Games\\Hexen Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_hexen/.+") -source_group("Games\\Raven Shared" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_raven/.+") -source_group("Games\\Strife Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_strife/.+") -source_group("Intermission" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/intermission/.+") -source_group("Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/menu/.+") -source_group("OpenGL Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/.+") -source_group("OpenGL Renderer\\API" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/api/.+") -source_group("OpenGL Renderer\\Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/data/.+") -source_group("OpenGL Renderer\\Dynamic Lights" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/dynlights/.+") -source_group("OpenGL Renderer\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx/.+") -source_group("OpenGL Renderer\\Models" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/models/.+") -source_group("OpenGL Renderer\\Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/renderer/.+") -source_group("OpenGL Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/scene/.+") -source_group("OpenGL Renderer\\Shaders" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/shaders/.+") -source_group("OpenGL Renderer\\System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/system/.+") -source_group("OpenGL Renderer\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/textures/.+") -source_group("OpenGL Renderer\\Utilities" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/utility/.+") -source_group("Render Core\\Render Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_.+\\.h$") -source_group("Render Core\\Render Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_.+\\.cpp$") -source_group("Render Data\\Resource Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_data/.+\\.h$") -source_group("Render Data\\Resource Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_data/.+\\.cpp$") -source_group("Render Data\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/textures/.+") -source_group("Render Interface" FILES r_defs.h r_renderer.h r_sky.cpp r_sky.h r_state.h r_utility.cpp r_utility.h) -source_group("Resource Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/resourcefiles/.+") -source_group("SDL Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sdl/.+") -source_group("SFMT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sfmt/.+") -source_group("Shared Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_shared/.+") -source_group("Versioning" FILES version.h win32/zdoom.rc) -source_group("Win32 Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/win32/.+") -source_group("Xlat" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/xlat/.+" FILES ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.h) -source_group("Source Files" FILES ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h sc_man_scanner.re) +cmake_minimum_required( VERSION 2.4 ) + +if( COMMAND cmake_policy ) + cmake_policy( SET CMP0003 NEW ) +endif( COMMAND cmake_policy ) + +include( CheckCXXSourceCompiles ) +include( CheckFunctionExists ) +include( CheckCXXCompilerFlag ) +include( FindPkgConfig ) +include( FindOpenGL ) + +if( NOT APPLE ) + option( NO_ASM "Disable assembly code" OFF ) +else( NOT APPLE ) + # At the moment asm code doesn't work with OS X, so disable by default + option( NO_ASM "Disable assembly code" ON ) +endif( NOT APPLE ) +if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + option( NO_STRIP "Do not strip Release or MinSizeRel builds" ) + # At least some versions of Xcode fail if you strip with the linker + # instead of the separate strip utility. + if( APPLE ) + set( NO_STRIP ON ) + endif( APPLE ) +endif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + +option( DYN_FLUIDSYNTH "Dynamically load fluidsynth" ON ) + +if( CMAKE_SIZEOF_VOID_P MATCHES "8" ) + set( X64 64 ) +endif( CMAKE_SIZEOF_VOID_P MATCHES "8" ) + +# You can either use "make install" on the FMOD distribution to put it +# in standard system locations, or you can unpack the FMOD distribution +# in the root of the zdoom tree. e.g.: +# zdoom +# docs +# fmodapilinux[64] -or simply- fmod +# jpeg-6b +# ... +# The recommended method is to put it in the zdoom tree, since its +# headers are unversioned. Especially now that we can't work properly +# with anything newer than 4.26.xx, you probably don't want to use +# a system-wide version. + +# Construct version numbers for searching for the FMOD library on Linux. +set( MINOR_VERSIONS "50" "49" "48" "47" "46" "45" "44" "43" "42" "41" + "40" "39" "38" "37" "36" "35" "34" "33" "32" "31" "30" "29" "28" + "27" "26" "25" "24" "23" "22" "21" "20" "21" "19" "18" "17" "16" + "15" "14" "13" "12" "11" "10" "09" "08" "07" "06" "05" "04" "03" + "02" "01" "00" ) +set( MAJOR_VERSIONS "44" "34" "28" "26" "24" "22" "20" ) + +if( NOT FMOD_DIR_VERSIONS ) + set( FMOD_DIR_VERSIONS "" ) +endif( NOT FMOD_DIR_VERSIONS ) +if( NOT FMOD_VERSIONS ) + set( FMOD_VERSIONS "" ) +endif( NOT FMOD_VERSIONS ) +if( NOT FMOD_LOCAL_INC_DIRS ) + set( FMOD_LOCAL_INC_DIRS "" ) +endif( NOT FMOD_LOCAL_INC_DIRS ) +if( NOT FMOD_LOCAL_LIB_DIRS ) + set( FMOD_LOCAL_LIB_DIRS "" ) +endif( NOT FMOD_LOCAL_LIB_DIRS ) + +set( FMOD_DIR_VERSIONS ${FMOD_DIR_VERSIONS} "../fmod" ) +foreach( majver ${MAJOR_VERSIONS} ) + foreach( minver ${MINOR_VERSIONS} ) + set( FMOD_VERSIONS ${FMOD_VERSIONS} "fmodex${X64}-4.${majver}.${minver}" ) + set( FMOD_DIR_VERSIONS ${FMOD_DIR_VERSIONS} "${CMAKE_HOME_DIRECTORY}/fmodapi4${majver}${minver}linux${X64}" ) + endforeach( minver ${MINOR_VERSIONS} ) + foreach( dir ${FMOD_DIR_VERSIONS} ) + set( FMOD_LOCAL_INC_DIRS ${FMOD_LOCAL_INC_DIRS} "${dir}/api/inc" ) + set( FMOD_LOCAL_LIB_DIRS ${FMOD_LOCAL_LIB_DIRS} "${dir}/api/lib" ) + endforeach( dir ${FMOD_DIR_VERSIONS} ) +endforeach( majver ${MAJOR_VERSIONS} ) + +if( NOT ZDOOM_LIBS ) + set( ZDOOM_LIBS "" ) +endif( NOT ZDOOM_LIBS ) + +if( WIN32 ) + if( X64 ) + set( WIN_TYPE Win64 ) + set( XBITS x64 ) + else( X64 ) + set( WIN_TYPE Win32 ) + set( XBITS x86 ) + endif( X64 ) + + add_definitions( -D_WIN32 ) + + set( FMOD_SEARCH_PATHS + "C:/Program Files/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" + "C:/Program Files (x86)/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" + # This next one is for Randy. + "E:/Software/Dev/FMOD/${WIN_TYPE}/api" + # .. and this one for Graf Zahl + "D:/portable/FMOD SoundSystem 4.26/FMOD Programmers API WIN32/api" + ) + set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES inc ) + set( FMOD_LIB_PATH_SUFFIXES PATH_SUFFIXES lib ) + set( NASM_NAMES nasmw nasm ) + + find_path( D3D_INCLUDE_DIR d3d9.h + PATHS ENV DXSDK_DIR + PATH_SUFFIXES Include ) + if( NOT D3D_INCLUDE_DIR ) + message( SEND_ERROR "Could not find DirectX 9 header files" ) + else( NOT D3D_INCLUDE_DIR ) + include_directories( ${D3D_INCLUDE_DIR} ) + endif( NOT D3D_INCLUDE_DIR ) + + find_path( XINPUT_INCLUDE_DIR xinput.h + PATHS ENV DXSDK_DIR + PATH_SUFFIXES Include ) + if( NOT XINPUT_INCLUDE_DIR ) + message( SEND_ERROR "Could not find xinput.h. XInput will be disabled." ) + add_definitions( -DNO_XINPUT ) + else( NOT XINPUT_INCLUDE_DIR ) + include_directories( ${XINPUT_INCLUDE_DIR} ) + endif( NOT XINPUT_INCLUDE_DIR ) + + find_library( DX_dxguid_LIBRARY dxguid + PATHS ENV DXSDK_DIR + PATH_SUFFIXES Lib Lib/${XBITS} ) + find_library( DX_dinput8_LIBRARY dinput8 + PATHS ENV DXSDK_DIR + PATH_SUFFIXES Lib Lib/${XBITS} ) + + set( DX_LIBS_FOUND YES ) + if( NOT DX_dxguid_LIBRARY ) + set( DX_LIBS_FOUND NO ) + endif( NOT DX_dxguid_LIBRARY ) + if( NOT DX_dinput8_LIBRARY ) + set( DX_LIBS_FOUND NO ) + endif( NOT DX_dinput8_LIBRARY ) + + if( NOT DX_LIBS_FOUND ) + message( FATAL_ERROR "Could not find DirectX 9 libraries" ) + endif( NOT DX_LIBS_FOUND ) + + set( ZDOOM_LIBS + wsock32 + winmm + "${DX_dxguid_LIBRARY}" + "${DX_dinput8_LIBRARY}" + ole32 + user32 + gdi32 + comctl32 + comdlg32 + ws2_32 + setupapi + oleaut32 + DelayImp ) +else( WIN32 ) + if( APPLE ) + set( FMOD_SEARCH_PATHS "/Developer/FMOD Programmers API Mac/api" ) + set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES inc ) + set( FMOD_LIB_PATH_SUFFIXES PATH_SUFFIXES lib ) + set( NO_GTK ON ) + else( APPLE ) + option( NO_GTK "Disable GTK+ dialogs (Not applicable to Windows)" ) + option( VALGRIND "Add special Valgrind sequences to self-modifying code" ) + + set( FMOD_SEARCH_PATHS + /usr/local/include + /usr/local/include/fmodex + /usr/include + /usr/include/fmodex + /opt/local/include + /opt/local/include/fmodex + /opt/include + /opt/include/fmodex ) + set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES fmodex ) + + # Use GTK+ for the IWAD picker, if available. + if( NOT NO_GTK ) + pkg_check_modules( GTK2 gtk+-2.0 ) + if( GTK2_FOUND ) + set( ZDOOM_LIBS ${ZDOOM_LIBS} ${GTK2_LIBRARIES} ) + include_directories( ${GTK2_INCLUDE_DIRS} ) + else( GTK2_FOUND ) + set( NO_GTK ON ) + endif( GTK2_FOUND ) + endif( NOT NO_GTK ) + + # Check for Xcursor library and header files + find_library( XCURSOR_LIB Xcursor ) + if( XCURSOR_LIB ) + find_file( XCURSOR_HEADER "X11/Xcursor/Xcursor.h" ) + if( XCURSOR_HEADER ) + add_definitions( -DUSE_XCURSOR=1 ) + message( STATUS "Found Xcursor at ${XCURSOR_LIB}" ) + set( ZDOOM_LIBS ${ZDOOM_LIBS} ${XCURSOR_LIB} ) + else( XCURSOR_HEADER ) + unset( XCURSOR_LIB ) + endif( XCURSOR_HEADER ) + endif( XCURSOR_LIB ) + endif( APPLE ) + set( NASM_NAMES nasm ) + + if( NO_GTK ) + add_definitions( -DNO_GTK=1 ) + endif( NO_GTK ) + + # Non-Windows version also needs SDL + find_package( SDL ) + if( NOT SDL_FOUND ) + message( SEND_ERROR "SDL is required for building." ) + endif( NOT SDL_FOUND ) + set( ZDOOM_LIBS ${ZDOOM_LIBS} "${SDL_LIBRARY}" ) + include_directories( "${SDL_INCLUDE_DIR}" ) + + find_path( FPU_CONTROL_DIR fpu_control.h ) + if( FPU_CONTROL_DIR ) + include_directories( ${FPU_CONTROL_DIR} ) + add_definitions( -DHAVE_FPU_CONTROL ) + endif( FPU_CONTROL_DIR ) +endif( WIN32 ) + +if( X64 ) + set( NO_ASM ON ) +endif( X64 ) + +# Check if we have OpenGL + +if( NOT OPENGL_FOUND ) + message( FATAL_ERROR "OpenGL is required for building." ) +endif( NOT OPENGL_FOUND ) +if( NOT OPENGL_GLU_FOUND ) + message( FATAL_ERROR "OpenGL GLU is required for building." ) +endif( NOT OPENGL_GLU_FOUND ) + +set( ZDOOM_LIBS ${ZDOOM_LIBS} ${OPENGL_LIBRARIES} ) +include_directories( ${OPENGL_INCLUDE_DIR} ) + +# Decide on the name of the FMOD library we want to use. + +if( NOT FMOD_LIB_NAME AND MSVC ) + set( FMOD_LIB_NAME fmodex${X64}_vc ) +endif( NOT FMOD_LIB_NAME AND MSVC ) + +if( NOT FMOD_LIB_NAME AND BORLAND ) + set( FMOD_LIB_NAME fmodex${X64}_bc ) +endif( NOT FMOD_LIB_NAME AND BORLAND ) + +if( NOT FMOD_LIB_NAME ) + set( FMOD_LIB_NAME fmodex${X64} ) +endif( NOT FMOD_LIB_NAME ) + + +# Search for FMOD include files + +if( NOT WIN32 ) + find_path( FMOD_INCLUDE_DIR fmod.hpp + PATHS ${FMOD_LOCAL_INC_DIRS} ) +endif( NOT WIN32 ) + +if( NOT FMOD_INCLUDE_DIR ) + find_path( FMOD_INCLUDE_DIR fmod.hpp + PATHS ${FMOD_SEARCH_PATHS} + ${FMOD_INC_PATH_SUFFIXES} ) +endif( NOT FMOD_INCLUDE_DIR ) + +if( FMOD_INCLUDE_DIR ) + message( STATUS "FMOD include files found at ${FMOD_INCLUDE_DIR}" ) +else( FMOD_INCLUDE_DIR ) + message( SEND_ERROR "Could not find FMOD include files" ) +endif( FMOD_INCLUDE_DIR ) + + +# Search for FMOD library + +if( WIN32 OR APPLE ) + find_library( FMOD_LIBRARY ${FMOD_LIB_NAME} + PATHS ${FMOD_SEARCH_PATHS} + ${FMOD_LIB_PATH_SUFFIXES} ) +else( WIN32 OR APPLE ) + find_library( FMOD_LIBRARY + NAMES ${FMOD_VERSIONS} + PATHS ${FMOD_LOCAL_LIB_DIRS} ) +endif( WIN32 OR APPLE ) + +if( FMOD_LIBRARY ) + message( STATUS "FMOD library found at ${FMOD_LIBRARY}" ) +else( FMOD_LIBRARY ) + message( SEND_ERROR "Could not find FMOD library" ) +endif( FMOD_LIBRARY ) + + +# Search for FluidSynth + +find_package( FluidSynth ) + +# Search for NASM + +if( NOT NO_ASM ) + if( UNIX AND X64 ) + find_program( GAS_PATH as ) + + if( GAS_PATH ) + set( ASSEMBLER ${GAS_PATH} ) + else( GAS_PATH ) + message( STATUS "Could not find as. Disabling assembly code." ) + set( NO_ASM ON ) + endif( GAS_PATH ) + else( UNIX AND X64 ) + find_program( NASM_PATH NAMES ${NASM_NAMES} ) + find_program( YASM_PATH yasm ) + + if( X64 ) + if( YASM_PATH ) + set( ASSEMBLER ${YASM_PATH} ) + else( YASM_PATH ) + message( STATUS "Could not find YASM. Disabling assembly code." ) + set( NO_ASM ON ) + endif( YASM_PATH ) + else( X64 ) + if( NASM_PATH ) + set( ASSEMBLER ${NASM_PATH} ) + else( NASM_PATH ) + message( STATUS "Could not find NASM. Disabling assembly code." ) + set( NO_ASM ON ) + endif( NASM_PATH ) + endif( X64 ) + endif( UNIX AND X64 ) + + # I think the only reason there was a version requirement was because the + # executable name for Windows changed from 0.x to 2.0, right? This is + # how to do it in case I need to do something similar later. + + # execute_process( COMMAND ${NASM_PATH} -v + # OUTPUT_VARIABLE NASM_VER_STRING ) + # string( REGEX REPLACE ".*version ([0-9]+[.][0-9]+).*" "\\1" NASM_VER "${NASM_VER_STRING}" ) + # if( NOT NASM_VER LESS 2 ) + # message( SEND_ERROR "NASM version should be 2 or later. (Installed version is ${NASM_VER}.)" ) + # endif( NOT NASM_VER LESS 2 ) +endif( NOT NO_ASM ) + +if( NOT NO_ASM ) + # Valgrind support is meaningless without assembly code. + if( VALGRIND ) + add_definitions( -DVALGRIND_AWARE=1 ) + # If you're Valgrinding, you probably want to keep symbols around. + set( NO_STRIP ON ) + endif( VALGRIND ) + + # Tell CMake how to assemble our files + if( UNIX ) + set( ASM_OUTPUT_EXTENSION .o ) + if( X64 ) + set( ASM_FLAGS ) + set( ASM_SOURCE_EXTENSION .s ) + else( X64 ) + if( APPLE ) + set( ASM_FLAGS -fmacho -DM_TARGET_MACHO ) + else( APPLE ) + set( ASM_FLAGS -felf -DM_TARGET_LINUX ) + endif( APPLE ) + set( ASM_FLAGS "${ASM_FLAGS}" -i${CMAKE_CURRENT_SOURCE_DIR}/ ) + set( ASM_SOURCE_EXTENSION .asm ) + endif( X64 ) + else( UNIX ) + set( ASM_OUTPUT_EXTENSION .obj ) + set( ASM_SOURCE_EXTENSION .asm ) + if( X64 ) + set( ASM_FLAGS -f win64 -DWIN32 -DWIN64 ) + else( X64 ) + set( ASM_FLAGS -f win32 -DWIN32 -i${CMAKE_CURRENT_SOURCE_DIR}/ ) + endif( X64 ) + endif( UNIX ) + if( WIN32 ) + set( FIXRTEXT fixrtext ) + else( WIN32 ) + set( FIXRTEXT "" ) + endif( WIN32 ) + message( STATUS "Selected assembler: ${ASSEMBLER}" ) + MACRO( ADD_ASM_FILE indir infile ) + set( ASM_OUTPUT_${infile} "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/zdoom.dir/${indir}/${infile}${ASM_OUTPUT_EXTENSION}" ) + if( WIN32 ) + set( FIXRTEXT_${infile} COMMAND ${FIXRTEXT} "${ASM_OUTPUT_${infile}}" ) + else( WIN32 ) + set( FIXRTEXT_${infile} COMMAND "" ) + endif( WIN32 ) + add_custom_command( OUTPUT ${ASM_OUTPUT_${infile}} + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/zdoom.dir/${indir} + COMMAND ${ASSEMBLER} ${ASM_FLAGS} -o"${ASM_OUTPUT_${infile}}" "${CMAKE_CURRENT_SOURCE_DIR}/${indir}/${infile}${ASM_SOURCE_EXTENSION}" + ${FIXRTEXT_${infile}} + DEPENDS ${indir}/${infile}.asm ${FIXRTEXT} ) + set( ASM_SOURCES ${ASM_SOURCES} "${ASM_OUTPUT_${infile}}" ) + ENDMACRO( ADD_ASM_FILE ) +endif( NOT NO_ASM ) + +# OpenGL on OS X: Search for GLEW include files + +if( APPLE ) + find_path( GLEW_INCLUDE_DIR GL/glew.h + PATHS "/usr/include" + "/usr/local/include" ) + + if( GLEW_INCLUDE_DIR ) + message( STATUS "GLEW include files found at ${GLEW_INCLUDE_DIR}" ) + else( GLEW_INCLUDE_DIR ) + message( SEND_ERROR "Could not find GLEW include files" ) + endif( GLEW_INCLUDE_DIR ) +endif( APPLE ) + +# Decide on SSE setup + +set( SSE_MATTERS NO ) + +# with global use of SSE 2 we do not need special handling for selected files +if (NOT ZDOOM_USE_SSE2) + # SSE only matters on 32-bit targets. We check compiler flags to know if we can do it. + if( CMAKE_SIZEOF_VOID_P MATCHES "4" AND NOT CMAKE_OSX_ARCHITECTURES MATCHES ppc ) + CHECK_CXX_COMPILER_FLAG( "-msse2 -mfpmath=sse" CAN_DO_MFPMATH ) + CHECK_CXX_COMPILER_FLAG( -arch:SSE2 CAN_DO_ARCHSSE2 ) + if( CAN_DO_MFPMATH ) + set( SSE1_ENABLE "-msse -mfpmath=sse" ) + set( SSE2_ENABLE "-msse2 -mfpmath=sse" ) + set( SSE_MATTERS YES ) + elseif( CAN_DO_ARCHSSE2 ) + set( SSE1_ENABLE -arch:SSE ) + set( SSE2_ENABLE -arch:SSE2 ) + set( SSE_MATTERS YES ) + endif( CAN_DO_MFPMATH ) + endif( CMAKE_SIZEOF_VOID_P MATCHES "4" AND NOT CMAKE_OSX_ARCHITECTURES MATCHES ppc ) +endif (NOT ZDOOM_USE_SSE2) + +if( SSE_MATTERS ) + if( WIN32 ) + set( BACKPATCH 1 CACHE BOOL "Enable backpatching." ) + else( WIN32 ) + CHECK_FUNCTION_EXISTS(mprotect HAVE_MPROTECT) + if( HAVE_MPROTECT ) + set( BACKPATCH 1 CACHE BOOL "Enable backpatching." ) + else( HAVE_MPROTECT ) + set( BACKPATCH 0 ) + endif( HAVE_MPROTECT ) + endif( WIN32 ) + set( SSE 1 CACHE BOOL "Build SSE and SSE2 versions of key code." ) +else( SSE_MATTERS ) + set( BACKPATCH 0 ) +endif( SSE_MATTERS ) + +# Set up flags for GCC + +if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + if( PROFILE ) + set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -pg" ) + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg" ) + set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -pg" ) + set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -pg" ) + endif( PROFILE ) + + set( REL_CXX_FLAGS "-fno-rtti" ) + if( NOT PROFILE ) + set( REL_CXX_FLAGS "${REL_CXX_FLAGS} -fomit-frame-pointer" ) + endif( NOT PROFILE ) + set( CMAKE_CXX_FLAGS_RELEASE "${REL_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}" ) + set( CMAKE_CXX_FLAGS_MINSIZEREL "${REL_CXX_FLAGS} ${CMAKE_CXX_FLAGS_MINSIZEREL}" ) + set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${REL_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" ) + + set( CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers ${CMAKE_CXX_FLAGS}" ) + + # Remove extra warnings when using the official DirectX headers. + # Also, TDM-GCC 4.4.0 no longer accepts glibc-style printf formats as valid, + # which is a royal pain. The previous version I had been using was fine with them. + if( WIN32 ) + set( CMAKE_CXX_FLAGS "-Wno-unknown-pragmas -Wno-comment -Wno-format ${CMAKE_CXX_FLAGS}" ) + endif( WIN32 ) + + if( NOT NO_STRIP ) + set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s" ) + set (CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} -s" ) + endif( NOT NO_STRIP ) +endif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + +# Check for functions that may or may not exist. + +CHECK_FUNCTION_EXISTS( filelength FILELENGTH_EXISTS ) +if( FILELENGTH_EXISTS ) + add_definitions( -DHAVE_FILELENGTH=1 ) +endif( FILELENGTH_EXISTS ) + +CHECK_FUNCTION_EXISTS( strupr STRUPR_EXISTS ) +if( NOT STRUPR_EXISTS ) + add_definitions( -DNEED_STRUPR=1 ) +endif( NOT STRUPR_EXISTS ) + +CHECK_FUNCTION_EXISTS( stricmp STRICMP_EXISTS ) +if( NOT STRICMP_EXISTS ) + add_definitions( -Dstricmp=strcasecmp ) +endif( NOT STRICMP_EXISTS ) + +CHECK_FUNCTION_EXISTS( strnicmp STRNICMP_EXISTS ) +if( NOT STRNICMP_EXISTS ) + add_definitions( -Dstrnicmp=strncasecmp ) +endif( NOT STRNICMP_EXISTS ) + +if( NOT MSVC ) + add_definitions( -D__forceinline=inline ) +endif( NOT MSVC ) + +if( UNIX ) + CHECK_LIBRARY_EXISTS( rt clock_gettime "" CLOCK_GETTIME_IN_RT ) + if( NOT CLOCK_GETTIME_IN_RT ) + CHECK_FUNCTION_EXISTS( clock_gettime CLOCK_GETTIME_EXISTS ) + if( NOT CLOCK_GETTIME_EXISTS ) + message( STATUS "Could not find clock_gettime. Timing statistics will not be available." ) + add_definitions( -DNO_CLOCK_GETTIME ) + endif( NOT CLOCK_GETTIME_EXISTS ) + else( NOT CLOCK_GETTIME_IN_RT ) + set( ZDOOM_LIBS ${ZDOOM_LIBS} rt ) + endif( NOT CLOCK_GETTIME_IN_RT ) +endif( UNIX ) + +CHECK_CXX_SOURCE_COMPILES( + "#include + int main() { va_list list1, list2; va_copy(list1, list2); return 0; }" + HAS_VA_COPY ) +if( NOT HAS_VA_COPY ) + CHECK_CXX_SOURCE_COMPILES( + "#include + int main() { va_list list1, list2; __va_copy(list1, list2); return 0; }" + HAS___VA_COPY ) + if( HAS___VA_COPY ) + add_definitions( -Dva_copy=__va_copy ) + else( HAS___VA_COPY ) + add_definitions( -DNO_VA_COPY ) + endif( HAS___VA_COPY ) +endif( NOT HAS_VA_COPY ) + +# Flags + +if( BACKPATCH ) + add_definitions( -DBACKPATCH ) +endif( BACKPATCH ) + +# Update gitinfo.h + +get_target_property( UPDATEREVISION_EXE updaterevision LOCATION ) + +add_custom_target( revision_check ALL + COMMAND ${UPDATEREVISION_EXE} src/gitinfo.h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS updaterevision ) + +# Libraries ZDoom needs + +message( STATUS "Fluid synth libs: ${FLUIDSYNTH_LIBRARIES}" ) +set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${GME_LIBRARIES}" "${FMOD_LIBRARY}" ) +include_directories( "${ZLIB_INCLUDE_DIR}" "${FMOD_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GME_INCLUDE_DIR}" ) + +if( NOT DYN_FLUIDSYNTH) + if( FLUIDSYNTH_FOUND ) + set( ZDOOM_LIBS ${ZDOOM_LIBS} "${FLUIDSYNTH_LIBRARIES}" ) + include_directories( "${FLUIDSYNTH_INCLUDE_DIR}" ) + endif( FLUIDSYNTH_FOUND ) +else( NOT DYN_FLUIDSYNTH ) + set( ZDOOM_LIBS ${ZDOOM_LIBS} ${CMAKE_DL_LIBS} ) +endif( NOT DYN_FLUIDSYNTH ) + +# OpenGL on OS X: GLEW include directory + +if( APPLE ) + include_directories( "${GLEW_INCLUDE_DIR}" ) +endif( APPLE ) + +# Start defining source files for ZDoom +set( PLAT_WIN32_SOURCES + win32/eaxedit.cpp + win32/fb_d3d9.cpp + win32/fb_d3d9_wipe.cpp + win32/fb_ddraw.cpp + win32/hardware.cpp + win32/helperthread.cpp + win32/i_cd.cpp + win32/i_crash.cpp + win32/i_input.cpp + win32/i_keyboard.cpp + win32/i_mouse.cpp + win32/i_dijoy.cpp + win32/i_rawps2.cpp + win32/i_xinput.cpp + win32/i_main.cpp + win32/i_movie.cpp + win32/i_system.cpp + win32/st_start.cpp + win32/win32gliface.cpp + win32/win32video.cpp ) +set( PLAT_SDL_SOURCES + sdl/crashcatcher.c + sdl/hardware.cpp + sdl/i_cd.cpp + sdl/i_input.cpp + sdl/i_joystick.cpp + sdl/i_main.cpp + sdl/i_movie.cpp + sdl/i_system.cpp + sdl/sdlvideo.cpp + sdl/sdlglvideo.cpp + sdl/st_start.cpp ) +set( PLAT_MAC_SOURCES + sdl/SDLMain.m + sdl/iwadpicker_cocoa.mm + sdl/i_system_cocoa.mm ) +if( WIN32 ) + set( SYSTEM_SOURCES_DIR win32 ) + set( SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ) + set( OTHER_SYSTEM_SOURCES ${PLAT_SDL_SOURCES} ${PLAT_MAC_SOURCES} ) + + if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + # CMake is not set up to compile and link rc files with GCC. :( + add_custom_command( OUTPUT zdoom-rc.o + COMMAND windres -o zdoom-rc.o -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zdoom.rc + DEPENDS win32/zdoom.rc ) + set( SYSTEM_SOURCES ${SYSTEM_SOURCES} zdoom-rc.o ) + else( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + set( SYSTEM_SOURCES ${SYSTEM_SOURCES} win32/zdoom.rc ) + endif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + +else( WIN32 ) + set( SYSTEM_SOURCES_DIR sdl ) + set( SYSTEM_SOURCES ${PLAT_SDL_SOURCES} ) + if( APPLE ) + set( SYSTEM_SOURCES ${SYSTEM_SOURCES} ${PLAT_MAC_SOURCES} ) + set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ) + else( APPLE ) + set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_MAC_SOURCES} ) + endif( APPLE ) +endif( WIN32 ) + +if( NO_ASM ) + add_definitions( -DNOASM ) +else( NO_ASM ) + if( NOT ASM_SOURCES ) + set( ASM_SOURCES "" ) + endif( NOT ASM_SOURCES ) + if( X64 ) + ADD_ASM_FILE( asm_x86_64 tmap3 ) + else( X64 ) + ADD_ASM_FILE( asm_ia32 a ) + ADD_ASM_FILE( asm_ia32 misc ) + ADD_ASM_FILE( asm_ia32 tmap ) + ADD_ASM_FILE( asm_ia32 tmap2 ) + ADD_ASM_FILE( asm_ia32 tmap3 ) + endif( X64 ) +endif( NO_ASM ) + +get_target_property( LEMON_EXE lemon LOCATION ) +get_target_property( RE2C_EXE re2c LOCATION ) + +add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.h + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/xlat/xlat_parser.y . + COMMAND ${LEMON_EXE} xlat_parser.y + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS lemon ${CMAKE_CURRENT_SOURCE_DIR}/xlat/xlat_parser.y ) + +add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h + COMMAND ${RE2C_EXE} --no-generation-date -s -o ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h ${CMAKE_CURRENT_SOURCE_DIR}/sc_man_scanner.re + DEPENDS re2c ${CMAKE_CURRENT_SOURCE_DIR}/sc_man_scanner.re ) + +include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) + +if( SSE_MATTERS ) + if( SSE ) + set( X86_SOURCES nodebuild_classify_sse2.cpp ) + set_source_files_properties( nodebuild_classify_sse2.cpp PROPERTIES COMPILE_FLAGS "${SSE2_ENABLE}" ) + else( SSE ) + add_definitions( -DDISABLE_SSE ) + endif( SSE ) +else( SSE_MATTERS ) + add_definitions( -DDISABLE_SSE ) + set( X86_SOURCES ) +endif( SSE_MATTERS ) + +if( DYN_FLUIDSYNTH ) + add_definitions( -DHAVE_FLUIDSYNTH -DDYN_FLUIDSYNTH ) +elseif( FLUIDSYNTH_FOUND ) + add_definitions( -DHAVE_FLUIDSYNTH ) +endif( DYN_FLUIDSYNTH ) + +# Project files should be aware of the header files. We can GLOB these since +# there's generally a new cpp for every header so this file will get changed +if( WIN32 ) + set( EXTRA_HEADER_DIRS win32/*.h ) +else( WIN32 ) + set( EXTRA_HEADER_DIRS sdl/*.h ) +endif( WIN32 ) +file( GLOB HEADER_FILES + ${EXTRA_HEADER_DIRS} + fragglescript/*.h + g_doom/*.h + g_heretic/*.h + g_hexen/*.h + g_raven/*.h + g_shared/*.h + g_strife/*.h + intermission/*.h + menu/*.h + oplsynth/*.h + oplsynth/dosbox/*.h + r_data/*.h + resourcefiles/*.h + sdl/*.h + sfmt/*.h + sound/*.h + textures/*.h + thingdef/*.h + xlat/*.h + gl/*.h + gl/api/*.h + gl/data/*.h + gl/dynlights/*.h + gl/hqnx/*.h + gl/models/*.h + gl/renderer/*.h + gl/scene/*.h + gl/shaders/*.h + gl/system/*.h + gl/textures/*.h + gl/utility/*.h + *.h +) + +# These files will be flagged as "headers" so that they appear in project files +# without being compiled. +set( NOT_COMPILED_SOURCE_FILES + ${OTHER_SYSTEM_SOURCES} + sc_man_scanner.h + sc_man_scanner.re + g_doom/a_arachnotron.cpp + g_doom/a_archvile.cpp + g_doom/a_bossbrain.cpp + g_doom/a_bruiser.cpp + g_doom/a_cacodemon.cpp + g_doom/a_cyberdemon.cpp + g_doom/a_demon.cpp + g_doom/a_doomimp.cpp + g_doom/a_doomweaps.cpp + g_doom/a_fatso.cpp + g_doom/a_keen.cpp + g_doom/a_lostsoul.cpp + g_doom/a_painelemental.cpp + g_doom/a_possessed.cpp + g_doom/a_revenant.cpp + g_doom/a_scriptedmarine.cpp + g_doom/a_spidermaster.cpp + g_heretic/a_chicken.cpp + g_heretic/a_dsparil.cpp + g_heretic/a_hereticartifacts.cpp + g_heretic/a_hereticimp.cpp + g_heretic/a_hereticweaps.cpp + g_heretic/a_ironlich.cpp + g_heretic/a_knight.cpp + g_heretic/a_wizard.cpp + g_hexen/a_bats.cpp + g_hexen/a_bishop.cpp + g_hexen/a_blastradius.cpp + g_hexen/a_boostarmor.cpp + g_hexen/a_centaur.cpp + g_hexen/a_clericflame.cpp + g_hexen/a_clericholy.cpp + g_hexen/a_clericmace.cpp + g_hexen/a_clericstaff.cpp + g_hexen/a_dragon.cpp + g_hexen/a_fighteraxe.cpp + g_hexen/a_fighterhammer.cpp + g_hexen/a_fighterplayer.cpp + g_hexen/a_fighterquietus.cpp + g_hexen/a_firedemon.cpp + g_hexen/a_flechette.cpp + g_hexen/a_fog.cpp + g_hexen/a_healingradius.cpp + g_hexen/a_heresiarch.cpp + g_hexen/a_hexenspecialdecs.cpp + g_hexen/a_iceguy.cpp + g_hexen/a_korax.cpp + g_hexen/a_magecone.cpp + g_hexen/a_magelightning.cpp + g_hexen/a_magestaff.cpp + g_hexen/a_pig.cpp + g_hexen/a_serpent.cpp + g_hexen/a_spike.cpp + g_hexen/a_summon.cpp + g_hexen/a_teleportother.cpp + g_hexen/a_wraith.cpp + g_strife/a_acolyte.cpp + g_strife/a_alienspectres.cpp + g_strife/a_coin.cpp + g_strife/a_crusader.cpp + g_strife/a_entityboss.cpp + g_strife/a_inquisitor.cpp + g_strife/a_oracle.cpp + g_strife/a_programmer.cpp + g_strife/a_reaver.cpp + g_strife/a_rebels.cpp + g_strife/a_sentinel.cpp + g_strife/a_stalker.cpp + g_strife/a_strifeitems.cpp + g_strife/a_strifeweapons.cpp + g_strife/a_templar.cpp + g_strife/a_thingstoblowup.cpp + g_shared/sbarinfo_commands.cpp + xlat/xlat_parser.y + xlat_parser.c + xlat_parser.h + + # We could have the ASM macro add these files, but it wouldn't add all + # platforms. + asm_ia32/a.asm + asm_ia32/misc.asm + asm_ia32/tmap.asm + asm_ia32/tmap2.asm + asm_ia32/tmap3.asm + asm_x86_64/tmap3.asm + asm_x86_64/tmap3.s +) + +add_executable( zdoom WIN32 + ${HEADER_FILES} + ${NOT_COMPILED_SOURCE_FILES} + __autostart.cpp + ${ASM_SOURCES} + ${SYSTEM_SOURCES} + ${X86_SOURCES} + x86.cpp + actorptrselect.cpp + am_map.cpp + b_bot.cpp + b_func.cpp + b_game.cpp + b_move.cpp + b_think.cpp + bbannouncer.cpp + c_bind.cpp + c_cmds.cpp + c_console.cpp + c_cvars.cpp + c_dispatch.cpp + c_expr.cpp + cmdlib.cpp + colormatcher.cpp + compatibility.cpp + configfile.cpp + ct_chat.cpp + d_dehacked.cpp + d_iwad.cpp + d_main.cpp + d_net.cpp + d_netinfo.cpp + d_protocol.cpp + decallib.cpp + dobject.cpp + dobjgc.cpp + dobjtype.cpp + doomdef.cpp + doomstat.cpp + dsectoreffect.cpp + dthinker.cpp + f_wipe.cpp + farchive.cpp + files.cpp + g_game.cpp + g_hub.cpp + g_level.cpp + g_mapinfo.cpp + g_skill.cpp + gameconfigfile.cpp + gi.cpp + gitinfo.cpp + hu_scores.cpp + i_net.cpp + info.cpp + keysections.cpp + lumpconfigfile.cpp + m_alloc.cpp + m_argv.cpp + m_bbox.cpp + m_cheat.cpp + m_joy.cpp + m_misc.cpp + m_png.cpp + m_random.cpp + m_specialpaths.cpp + memarena.cpp + md5.cpp + name.cpp + nodebuild.cpp + nodebuild_classify_nosse2.cpp + nodebuild_events.cpp + nodebuild_extract.cpp + nodebuild_gl.cpp + nodebuild_utility.cpp + p_3dfloors.cpp + p_3dmidtex.cpp + p_acs.cpp + p_buildmap.cpp + p_ceiling.cpp + p_conversation.cpp + p_doors.cpp + p_effect.cpp + p_enemy.cpp + p_floor.cpp + p_glnodes.cpp + p_interaction.cpp + p_lights.cpp + p_linkedsectors.cpp + p_lnspec.cpp + p_map.cpp + p_maputl.cpp + p_mobj.cpp + p_pillar.cpp + p_plats.cpp + p_pspr.cpp + p_saveg.cpp + p_sectors.cpp + p_setup.cpp + p_sight.cpp + p_slopes.cpp + p_spec.cpp + p_states.cpp + p_switch.cpp + p_teleport.cpp + p_terrain.cpp + p_things.cpp + p_tick.cpp + p_trace.cpp + p_udmf.cpp + p_usdf.cpp + p_user.cpp + p_writemap.cpp + p_xlat.cpp + parsecontext.cpp + po_man.cpp + r_swrenderer.cpp + r_utility.cpp + r_3dfloors.cpp + r_bsp.cpp + r_draw.cpp + r_drawt.cpp + r_main.cpp + r_plane.cpp + r_polymost.cpp + r_segs.cpp + r_sky.cpp + r_things.cpp + s_advsound.cpp + s_environment.cpp + s_playlist.cpp + s_sndseq.cpp + s_sound.cpp + sc_man.cpp + st_stuff.cpp + statistics.cpp + stats.cpp + stringtable.cpp + strnatcmp.c + tables.cpp + teaminfo.cpp + tempfiles.cpp + v_blend.cpp + v_collection.cpp + v_draw.cpp + v_font.cpp + v_palette.cpp + v_pfx.cpp + v_text.cpp + v_video.cpp + w_wad.cpp + wi_stuff.cpp + zstrformat.cpp + zstring.cpp + g_doom/a_doommisc.cpp + g_heretic/a_hereticmisc.cpp + g_hexen/a_hexenmisc.cpp + g_raven/a_artitele.cpp + g_raven/a_minotaur.cpp + g_strife/a_strifestuff.cpp + g_strife/strife_sbar.cpp + g_shared/a_action.cpp + g_shared/a_armor.cpp + g_shared/a_artifacts.cpp + g_shared/a_bridge.cpp + g_shared/a_camera.cpp + g_shared/a_debris.cpp + g_shared/a_decals.cpp + g_shared/a_fastprojectile.cpp + g_shared/a_flashfader.cpp + g_shared/a_fountain.cpp + g_shared/a_hatetarget.cpp + g_shared/a_keys.cpp + g_shared/a_lightning.cpp + g_shared/a_mapmarker.cpp + g_shared/a_morph.cpp + g_shared/a_movingcamera.cpp + g_shared/a_pickups.cpp + g_shared/a_puzzleitems.cpp + g_shared/a_quake.cpp + g_shared/a_randomspawner.cpp + g_shared/a_secrettrigger.cpp + g_shared/a_sectoraction.cpp + g_shared/a_setcolor.cpp + g_shared/a_skies.cpp + g_shared/a_soundenvironment.cpp + g_shared/a_soundsequence.cpp + g_shared/a_spark.cpp + g_shared/a_specialspot.cpp + g_shared/a_waterzone.cpp + g_shared/a_weaponpiece.cpp + g_shared/a_weapons.cpp + g_shared/hudmessages.cpp + g_shared/sbarinfo.cpp + g_shared/sbar_mugshot.cpp + g_shared/shared_hud.cpp + g_shared/shared_sbar.cpp + intermission/intermission.cpp + intermission/intermission_parse.cpp + menu/colorpickermenu.cpp + menu/joystickmenu.cpp + menu/listmenu.cpp + menu/loadsavemenu.cpp + menu/menu.cpp + menu/menudef.cpp + menu/menuinput.cpp + menu/messagebox.cpp + menu/optionmenu.cpp + menu/playerdisplay.cpp + menu/playermenu.cpp + menu/readthis.cpp + menu/videomenu.cpp + gl/api/gl_api.cpp + gl/data/gl_sections.cpp + gl/data/gl_data.cpp + gl/data/gl_portaldata.cpp + gl/data/gl_setup.cpp + gl/data/gl_vertexbuffer.cpp + gl/dynlights/a_dynlight.cpp + gl/utility/gl_clock.cpp + gl/utility/gl_cycler.cpp + gl/utility/gl_geometric.cpp + gl/renderer/gl_renderer.cpp + gl/renderer/gl_renderstate.cpp + gl/renderer/gl_lightdata.cpp + gl/hqnx/init.cpp + gl/hqnx/hq2x.cpp + gl/hqnx/hq3x.cpp + gl/hqnx/hq4x.cpp + gl/textures/gl_hwtexture.cpp + gl/textures/gl_texture.cpp + gl/textures/gl_material.cpp + gl/textures/gl_hirestex.cpp + gl/textures/gl_bitmap.cpp + gl/textures/gl_translate.cpp + gl/textures/gl_hqresize.cpp + gl/textures/gl_skyboxtexture.cpp + gl/scene/gl_bsp.cpp + gl/scene/gl_fakeflat.cpp + gl/scene/gl_clipper.cpp + gl/scene/gl_decal.cpp + gl/scene/gl_drawinfo.cpp + gl/scene/gl_flats.cpp + gl/scene/gl_walls.cpp + gl/scene/gl_sprite.cpp + gl/scene/gl_skydome.cpp + gl/scene/gl_renderhacks.cpp + gl/scene/gl_weapon.cpp + gl/scene/gl_scene.cpp + gl/scene/gl_sky.cpp + gl/scene/gl_portal.cpp + gl/scene/gl_walls_draw.cpp + gl/scene/gl_vertex.cpp + gl/scene/gl_spritelight.cpp + gl/dynlights/gl_dynlight.cpp + gl/dynlights/gl_glow.cpp + gl/dynlights/gl_dynlight1.cpp + gl/dynlights/gl_lightbuffer.cpp + gl/shaders/gl_shader.cpp + gl/shaders/gl_texshader.cpp + gl/system/gl_interface.cpp + gl/system/gl_framebuffer.cpp + gl/system/gl_menu.cpp + gl/system/gl_wipe.cpp + gl/models/gl_models_md3.cpp + gl/models/gl_models_md2.cpp + gl/models/gl_models.cpp + gl/models/gl_voxels.cpp + oplsynth/fmopl.cpp + oplsynth/mlopl.cpp + oplsynth/mlopl_io.cpp + oplsynth/music_opldumper_mididevice.cpp + oplsynth/music_opl_mididevice.cpp + oplsynth/opl_mus_player.cpp + oplsynth/dosbox/opl.cpp + oplsynth/OPL3.cpp + resourcefiles/ancientzip.cpp + resourcefiles/file_7z.cpp + resourcefiles/file_grp.cpp + resourcefiles/file_lump.cpp + resourcefiles/file_rff.cpp + resourcefiles/file_wad.cpp + resourcefiles/file_zip.cpp + resourcefiles/file_pak.cpp + resourcefiles/file_directory.cpp + resourcefiles/resourcefile.cpp + sfmt/SFMT.cpp + sound/fmodsound.cpp + sound/i_music.cpp + sound/i_sound.cpp + sound/music_cd.cpp + sound/music_dumb.cpp + sound/music_gme.cpp + sound/music_mus_midiout.cpp + sound/music_smf_midiout.cpp + sound/music_hmi_midiout.cpp + sound/music_xmi_midiout.cpp + sound/music_midistream.cpp + sound/music_midi_base.cpp + sound/music_midi_timidity.cpp + sound/music_mus_opl.cpp + sound/music_stream.cpp + sound/music_fluidsynth_mididevice.cpp + sound/music_softsynth_mididevice.cpp + sound/music_timidity_mididevice.cpp + sound/music_win_mididevice.cpp + sound/music_pseudo_mididevice.cpp + textures/animations.cpp + textures/anim_switches.cpp + textures/automaptexture.cpp + textures/bitmap.cpp + textures/buildtexture.cpp + textures/canvastexture.cpp + textures/ddstexture.cpp + textures/flattexture.cpp + textures/imgztexture.cpp + textures/jpegtexture.cpp + textures/multipatchtexture.cpp + textures/patchtexture.cpp + textures/pcxtexture.cpp + textures/pngtexture.cpp + textures/rawpagetexture.cpp + textures/emptytexture.cpp + textures/texture.cpp + textures/texturemanager.cpp + textures/tgatexture.cpp + textures/warptexture.cpp + thingdef/olddecorations.cpp + thingdef/thingdef.cpp + thingdef/thingdef_codeptr.cpp + thingdef/thingdef_data.cpp + thingdef/thingdef_exp.cpp + thingdef/thingdef_expression.cpp + thingdef/thingdef_function.cpp + thingdef/thingdef_parse.cpp + thingdef/thingdef_properties.cpp + thingdef/thingdef_states.cpp + timidity/common.cpp + timidity/instrum.cpp + timidity/instrum_dls.cpp + timidity/instrum_font.cpp + timidity/instrum_sf2.cpp + timidity/mix.cpp + timidity/playmidi.cpp + timidity/resample.cpp + timidity/timidity.cpp + xlat/parse_xlat.cpp + fragglescript/t_fspic.cpp + fragglescript/t_func.cpp + fragglescript/t_load.cpp + fragglescript/t_oper.cpp + fragglescript/t_parse.cpp + fragglescript/t_prepro.cpp + fragglescript/t_script.cpp + fragglescript/t_spec.cpp + fragglescript/t_variable.cpp + fragglescript/t_cmd.cpp + r_data/colormaps.cpp + r_data/sprites.cpp + r_data/voxels.cpp + r_data/renderstyle.cpp + r_data/r_interpolate.cpp + r_data/r_translate.cpp + zzautozend.cpp +) + +set_source_files_properties( xlat/parse_xlat.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c" ) +set_source_files_properties( sc_man.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h" ) +set_source_files_properties( ${NOT_COMPILED_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE ) + +if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS") + # [BL] Solaris requires these to be explicitly linked. + set( ZDOOM_LIBS ${ZDOOM_LIBS} nsl socket) +endif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS") + +target_link_libraries( zdoom ${ZDOOM_LIBS} gdtoa dumb lzma ) +include_directories( . + g_doom + g_heretic + g_hexen + g_raven + g_strife + g_shared + oplsynth + sound + textures + thingdef + timidity + xlat + ../gdtoa + ../dumb/include + ${CMAKE_BINARY_DIR}/gdtoa + ${SYSTEM_SOURCES_DIR} ) + +add_dependencies( zdoom revision_check ) + +# Due to some quirks, we need to do this in this order +if( NOT ZDOOM_OUTPUT_OLDSTYLE OR NO_GENERATOR_EXPRESSIONS ) + # RUNTIME_OUTPUT_DIRECTORY does not exist in CMake 2.4. + # Linux distributions are slow to adopt 2.6. :( + set_target_properties( zdoom PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ZDOOM_OUTPUT_DIR} ) + set_target_properties( zdoom PROPERTIES OUTPUT_NAME ${ZDOOM_EXE_NAME} ) +else( NOT ZDOOM_OUTPUT_OLDSTYLE OR NO_GENERATOR_EXPRESSIONS ) + set_target_properties( zdoom PROPERTIES + RUNTIME_OUTPUT_NAME ${ZDOOM_EXE_NAME} + RUNTIME_OUTPUT_DIRECTORY_RELEASE ${ZDOOM_OUTPUT_DIR} + RUNTIME_OUTPUT_NAME_DEBUG ${ZDOOM_EXE_NAME}d + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${ZDOOM_OUTPUT_DIR} + RUNTIME_OUTPUT_NAME_MINSIZEREL ${ZDOOM_EXE_NAME}msr + RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${ZDOOM_OUTPUT_DIR} + RUNTIME_OUTPUT_NAME_RELWITHDEBINFO ${ZDOOM_EXE_NAME}rd + RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${ZDOOM_OUTPUT_DIR} + ) +endif( NOT ZDOOM_OUTPUT_OLDSTYLE OR NO_GENERATOR_EXPRESSIONS ) + +if( MSVC ) + option( ZDOOM_GENERATE_MAPFILE "Generate .map file for debugging." OFF ) + if( ZDOOM_GENERATE_MAPFILE ) + set_target_properties(zdoom PROPERTIES LINK_FLAGS "/MANIFEST:NO /DELAYLOAD:\"fmodex${X64}.dll\" /MAP") + else( ZDOOM_GENERATE_MAPFILE ) + set_target_properties(zdoom PROPERTIES LINK_FLAGS "/MANIFEST:NO /DELAYLOAD:\"fmodex${X64}.dll\"") + endif( ZDOOM_GENERATE_MAPFILE ) + + add_custom_command(TARGET zdoom POST_BUILD + COMMAND "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\win32\\zdoom.exe.manifest\" -outputresource:\"$(TargetDir)$(TargetFileName)\"\;\#1 + COMMENT "Adding manifest..." + ) + + create_default_target_launcher( zdoom WORKING_DIRECTORY ${ZDOOM_OUTPUT_DIR} ) +endif( MSVC ) + +if( NOT WIN32 ) + FILE( WRITE ${CMAKE_CURRENT_BINARY_DIR}/link-make "if [ ! -e ${ZDOOM_OUTPUT_DIR}/${ZDOOM_EXE_NAME} ]; then ln -sf ${CMAKE_CURRENT_BINARY_DIR}/${ZDOOM_EXE_NAME} ${ZDOOM_OUTPUT_DIR}/${ZDOOM_EXE_NAME}; fi" ) + add_custom_command( TARGET zdoom POST_BUILD + COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/link-make + COMMAND /bin/sh -c ${CMAKE_CURRENT_BINARY_DIR}/link-make ) +endif( NOT WIN32 ) +if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) + # GCC misoptimizes this file + set_source_files_properties( oplsynth/fmopl.cpp PROPERTIES COMPILE_FLAGS "-fno-tree-dominator-opts -fno-tree-fre" ) +endif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) +if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + # Need to enable intrinsics for this file. + if( SSE_MATTERS ) + set_source_files_properties( x86.cpp PROPERTIES COMPILE_FLAGS "-msse2 -mmmx" ) + endif( SSE_MATTERS ) +endif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + +source_group("Assembly Files\\ia32" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/asm_ia32/.+") +source_group("Assembly Files\\x86_64" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/asm_x86_64/.+") +source_group("Audio Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sound/.+") +source_group("Audio Files\\OPL Synth" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/oplsynth/.+") +source_group("Audio Files\\OPL Synth\\DOSBox" FILES oplsynth/dosbox/opl.cpp oplsynth/dosbox/opl.h) +source_group("Audio Files\\Timidity\\Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/timidity/.+\\.h$") +source_group("Audio Files\\Timidity\\Source" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/timidity/.+\\.cpp$") +source_group("Decorate++" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/thingdef/.+") +source_group("FraggleScript" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/fragglescript/.+") +source_group("Games\\Doom Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_doom/.+") +source_group("Games\\Heretic Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_heretic/.+") +source_group("Games\\Hexen Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_hexen/.+") +source_group("Games\\Raven Shared" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_raven/.+") +source_group("Games\\Strife Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_strife/.+") +source_group("Intermission" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/intermission/.+") +source_group("Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/menu/.+") +source_group("OpenGL Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/.+") +source_group("OpenGL Renderer\\API" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/api/.+") +source_group("OpenGL Renderer\\Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/data/.+") +source_group("OpenGL Renderer\\Dynamic Lights" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/dynlights/.+") +source_group("OpenGL Renderer\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx/.+") +source_group("OpenGL Renderer\\Models" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/models/.+") +source_group("OpenGL Renderer\\Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/renderer/.+") +source_group("OpenGL Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/scene/.+") +source_group("OpenGL Renderer\\Shaders" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/shaders/.+") +source_group("OpenGL Renderer\\System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/system/.+") +source_group("OpenGL Renderer\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/textures/.+") +source_group("OpenGL Renderer\\Utilities" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/utility/.+") +source_group("Render Core\\Render Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_.+\\.h$") +source_group("Render Core\\Render Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_.+\\.cpp$") +source_group("Render Data\\Resource Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_data/.+\\.h$") +source_group("Render Data\\Resource Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_data/.+\\.cpp$") +source_group("Render Data\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/textures/.+") +source_group("Render Interface" FILES r_defs.h r_renderer.h r_sky.cpp r_sky.h r_state.h r_utility.cpp r_utility.h) +source_group("Resource Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/resourcefiles/.+") +source_group("SDL Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sdl/.+") +source_group("SFMT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sfmt/.+") +source_group("Shared Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_shared/.+") +source_group("Versioning" FILES version.h win32/zdoom.rc) +source_group("Win32 Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/win32/.+") +source_group("Xlat" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/xlat/.+" FILES ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.h) +source_group("Source Files" FILES ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h sc_man_scanner.re) diff --git a/src/gl/hqnx/Image.cpp b/src/gl/hqnx/Image.cpp deleted file mode 100644 index 089036365..000000000 --- a/src/gl/hqnx/Image.cpp +++ /dev/null @@ -1,1174 +0,0 @@ -//CImage class - loading and saving BMP and TGA files -//---------------------------------------------------------- -//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) -// -//This program is free software; you can redistribute it and/or -//modify it under the terms of the GNU Lesser General Public -//License as published by the Free Software Foundation; either -//version 2.1 of the License, or (at your option) any later version. -// -//This program is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -//Lesser General Public License for more details. -// -//You should have received a copy of the GNU Lesser General Public -//License along with this program; if not, write to the Free Software -//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -#include -#include -#include "Image.h" - -DLL CImage::CImage() -{ - m_Xres = m_Yres = m_NumPixel = 0; - m_pBitmap = NULL; -} - -DLL CImage::~CImage() -{ - Destroy(); -} - -int DLL CImage::Init( int X, int Y, unsigned short BitPerPixel ) -{ - if (m_pBitmap != NULL) - free(m_pBitmap); - - m_Xres = X; - m_Yres = Y; - m_BitPerPixel = BitPerPixel<=8 ? 8 : BitPerPixel<=16 ? 16 : BitPerPixel<=24 ? 24 : 32; - m_BytePerPixel = m_BitPerPixel >> 3; - m_NumPixel = m_Xres*m_Yres; - int size = m_NumPixel*((m_BitPerPixel+7)/8); - m_pBitmap=(unsigned char *)malloc(size); - return (m_pBitmap != NULL) ? 0 : 1; -} - -int DLL CImage::SetImage(unsigned char *img, int width, int height, int bpp) -{ - Init(width, height, bpp); - - memcpy(m_pBitmap, img, m_NumPixel * m_BytePerPixel); - - return 0; -} - -int DLL CImage::Destroy() -{ - if (m_pBitmap) - { - free(m_pBitmap); - m_pBitmap = NULL; - } - m_Xres = 0; - m_Yres = 0; - m_NumPixel = 0; - m_BitPerPixel = 0; - return 0; -} - -int DLL CImage::Convert32To17( void ) -{ - int nRes = eConvUnknownFormat; - - if ( m_BitPerPixel == 32 ) - { - if ( m_pBitmap != NULL ) - { - unsigned char * pTemp8 = m_pBitmap; - unsigned int * pTemp32 = (unsigned int *)m_pBitmap; - unsigned int a, r, g, b; - for ( int i=0; i> 3; - g = (*(pTemp8++)) >> 2; - r = (*(pTemp8++)) >> 3; - a = *(pTemp8++); - *pTemp32 = (r << 11) + (g << 5) + b + (a > 127 ? 0x10000 : 0); - pTemp32++; - } - } - else - nRes = eConvSourceMemory; - - nRes = 0; - } - - return nRes; -} - -int DLL CImage::ConvertTo32( void ) -{ - int nRes = eConvUnknownFormat; - - if ( m_pBitmap == NULL ) - return eConvSourceMemory; - - switch ( m_BitPerPixel ) - { - case 8: - { - nRes = 0; - m_BitPerPixel = 32; - unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*4); - if ( pNewBitmap != NULL ) - { - unsigned char * pTemp8 = m_pBitmap; - unsigned char * pTemp32 = pNewBitmap; - unsigned char c; - for ( int i=0; i> 3); - *(pTemp24++) = ((rgb & 0xF800) >> 8); - } - free(m_pBitmap); - m_pBitmap = pNewBitmap; - } - else - nRes = eConvDestMemory; - - break; - } - case 32: - { - nRes = 0; - m_BitPerPixel = 24; - unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*3); - if ( pNewBitmap != NULL ) - { - unsigned char * pTemp32 = m_pBitmap; - unsigned char * pTemp24 = pNewBitmap; - for ( int i=0; i> 3; - g = m_Pal[c].g >> 2; - b = m_Pal[c].b >> 3; - *(pTemp16++) = (r << 11) + (g << 5) + b; - } - free(m_pBitmap); - m_pBitmap = pNewBitmap; - } - else - nRes = eConvDestMemory; - - break; - } - case 24: - { - nRes = 0; - m_BitPerPixel = 16; - unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*2); - if ( pNewBitmap != NULL ) - { - unsigned char * pTemp24 = m_pBitmap; - unsigned short * pTemp16 = (unsigned short *)pNewBitmap; - unsigned short r, g, b; - for ( int i=0; i> 3; - g = (*(pTemp24++)) >> 2; - r = (*(pTemp24++)) >> 3; - *(pTemp16++) = (r << 11) + (g << 5) + b; - } - free(m_pBitmap); - m_pBitmap = pNewBitmap; - } - else - nRes = eConvDestMemory; - - break; - } - case 32: - { - nRes = 0; - m_BitPerPixel = 16; - unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*2); - if ( pNewBitmap != NULL ) - { - unsigned char * pTemp32 = m_pBitmap; - unsigned short * pTemp16 = (unsigned short *)pNewBitmap; - unsigned short r, g, b; - for ( int i=0; i> 3; - g = (*(pTemp32++)) >> 2; - r = (*(pTemp32++)) >> 3; - pTemp32++; - *(pTemp16++) = (r << 11) + (g << 5) + b; - } - free(m_pBitmap); - m_pBitmap = pNewBitmap; - } - else - nRes = eConvDestMemory; - - break; - } - } - - return nRes; -} - -int CImage::Convert8To17( int transindex ) -{ - int nRes = eConvUnknownFormat; - - if ( m_BitPerPixel == 8 ) - { - m_BitPerPixel = 32; - unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*4); - if ( pNewBitmap != NULL ) - { - unsigned char * pTemp8 = m_pBitmap; - unsigned int * pTemp32 = (unsigned int *)pNewBitmap; - unsigned int r, g, b; - unsigned char c; - for ( int i=0; i> 3; - g = m_Pal[c].g >> 2; - b = m_Pal[c].b >> 3; - *(pTemp32++) = (r << 11) + (g << 5) + b + (transindex != c ? 0x10000 : 0); - } - free(m_pBitmap); - m_pBitmap = pNewBitmap; - } - else - nRes = eConvDestMemory; - - nRes = 0; - } - - return nRes; -} - -int CImage::SaveBmp(char *szFilename) -{ - _BMPFILEHEADER fh; - _BMPIMAGEHEADER ih; - unsigned char BmpPal[256][4]; - long int SuffLen; - long int Dummy = 0; - unsigned char * pBuf; - short i; - - if (!(f = fopen(szFilename, "wb"))) return eSaveBmpFileOpen; - if ( m_pBitmap == NULL ) return eSaveBmpSourceMemory; - - fh.bfType=0x4D42; - if (m_BitPerPixel==8) - { - SuffLen=((m_Xres+3)/4)*4-m_Xres; - ih.biSize=0x28; - ih.biWidth=m_Xres; - ih.biHeight=m_Yres; - ih.biPlanes=1; - ih.biBitCount=8; - ih.biCompression=0; - ih.biSizeImage=(m_Xres+SuffLen)*m_Yres; - ih.biXPelsPerMeter=ih.biYPelsPerMeter=0x2E23; // 300dpi (pixels per meter) - ih.biClrUsed=ih.biClrImportant=0; - fh.bfSize=(ih.biSizeImage)+0x0436; - fh.bfRes1=0; - fh.bfOffBits=0x0436; - if (fwrite(&fh, 14, 1, f) != 1) return eSaveBmpFileWrite; - if (fwrite(&ih, 40, 1, f) != 1) return eSaveBmpFileWrite; - for (i=0; i<256; i++) - { - BmpPal[i][0]=m_Pal[i].b; - BmpPal[i][1]=m_Pal[i].g; - BmpPal[i][2]=m_Pal[i].r; - BmpPal[i][3]=0; - } - if (fwrite(&BmpPal, 1024, 1, f) != 1) return eSaveBmpFileWrite; - pBuf=m_pBitmap; - pBuf+=m_NumPixel; - for (i=0; i0) - { - if (fwrite(&Dummy, SuffLen, 1, f) != 1) return eSaveBmpFileWrite; - } - } - } - else - if (m_BitPerPixel==24) - { - SuffLen=((m_Xres*3+3)/4)*4-m_Xres*3; - ih.biSize=0x28; - ih.biWidth=m_Xres; - ih.biHeight=m_Yres; - ih.biPlanes=1; - ih.biBitCount=24; - ih.biCompression=0; - ih.biSizeImage=(m_Xres*3+SuffLen)*m_Yres; - ih.biXPelsPerMeter=ih.biYPelsPerMeter=0x2E23; // 300dpi (pixels per meter) - ih.biClrUsed=ih.biClrImportant=0; - fh.bfSize=(ih.biSizeImage)+0x0036; - fh.bfRes1=0; - fh.bfOffBits=0x0036; - if (fwrite(&fh, 14, 1, f) != 1) return eSaveBmpFileWrite; - if (fwrite(&ih, 40, 1, f) != 1) return eSaveBmpFileWrite; - pBuf=m_pBitmap; - pBuf+=m_NumPixel*3; - for (i=0; i0) - { - if (fwrite(&Dummy, SuffLen, 1, f) != 1) return eSaveBmpFileWrite; - } - } - } - else - return eSaveBmpColorDepth; - - fclose(f); - - return 0; -} - -int CImage::LoadBmp(char *szFilename) -{ - _BMPFILEHEADER fh; - _BMPIMAGEHEADEROLD ih_old; - _BMPIMAGEHEADER ih; - unsigned char BmpPal[256][4]; - long int biSize; - long int SuffLen; - long int Dummy = 0; - unsigned char * pBuf; - short i; - long int xres, yres; - unsigned short bits; - - if (!(f = fopen(szFilename, "rb"))) return eLoadBmpFileOpen; - if (fread(&fh, 14, 1, f) != 1) return eLoadBmpFileRead; - if (fh.bfType != 0x4D42) return eLoadBmpBadFormat; - if (fread(&biSize, 4, 1, f) != 1) return eLoadBmpFileRead; - if (biSize > 12) - { - fseek( f, -4, SEEK_CUR ); - if (fread(&ih, biSize, 1, f) != 1) return eLoadBmpFileRead; - xres = ih.biWidth; - yres = ih.biHeight; - bits = ih.biBitCount; - } - else - { - fseek( f, -4, SEEK_CUR ); - if (fread(&ih_old, biSize, 1, f) != 1) return eLoadBmpFileRead; - xres = ih_old.biWidth; - yres = ih_old.biHeight; - bits = ih_old.biBitCount; - } - - if ( Init( xres, yres, bits ) != 0 ) return eLoadBmpInit; - if (m_BitPerPixel==8) - { - SuffLen=((m_Xres+3)/4)*4-m_Xres; - if (fread(&BmpPal, 1024, 1, f) != 1) return eLoadBmpFileRead; - for (i=0; i<256; i++) - { - m_Pal[i].b=BmpPal[i][0]; - m_Pal[i].g=BmpPal[i][1]; - m_Pal[i].r=BmpPal[i][2]; - } - pBuf=m_pBitmap; - pBuf+=m_NumPixel; - for (i=0; i0) - { - if (fread(&Dummy, SuffLen, 1, f) != 1) return eLoadBmpFileRead; - } - } - } - else - if (m_BitPerPixel==24) - { - SuffLen=((m_Xres*3+3)/4)*4-(m_Xres*3); - pBuf=m_pBitmap; - pBuf+=m_NumPixel*3; - for (i=0; i0) - { - if (fread(&Dummy, SuffLen, 1, f) != 1) return eLoadBmpFileRead; - } - } - } - else - return eLoadBmpColorDepth; - - fclose(f); - - return 0; -} - -void CImage::Output( void ) -{ - fwrite(m_cBuf, m_nCount, 1, f); - m_nCount=0; -} - -void CImage::Output( char c ) -{ - if ( m_nCount == sizeof(m_cBuf) ) - { - fwrite(m_cBuf, m_nCount, 1, f); - m_nCount=0; - } - m_cBuf[m_nCount++] = c; -} - -void CImage::Output( char * pcData, int nSize ) -{ - for ( int i=0; i 0 ) - { - Output( nDif-1 ); - Output( (char*)(pcolBuf+i-nDif-nRep), nDif ); - } - nDif = 1; - } - } - else - { - if ( bEqual && (nRep<127) ) - nRep++; - else - { - Output( nRep+128 ); - Output( (char*)&colOld, 1 ); - nRep = 0; - nDif = 1; - } - } - } - - if ( nRep == 0 ) - { - Output( nDif-1 ); - Output( (char*)(pcolBuf+m_Xres-nDif), nDif ); - } - else - { - Output( nRep+128 ); - Output( (char*)&colOld, 1 ); - } - Output(); - } - } - } - else - if (m_BitPerPixel==24) - { - fh.tiImageType = bCompressed ? 10 : 2; - if (fwrite(&fh, sizeof(fh), 1, f) != 1) return eSaveTgaFileWrite; - - _BGR * pcolBuf = (_BGR *)m_pBitmap; - pcolBuf += m_NumPixel; - - if ( !bCompressed ) - { - for (j=0; j 0 ) - { - Output( nDif-1 ); - Output( (char*)(pcolBuf+i-nDif-nRep), sizeof(_BGR)*nDif ); - } - nDif = 1; - } - } - else - { - if ( bEqual && (nRep<127) ) - nRep++; - else - { - Output( nRep+128 ); - Output( (char*)&colOld, sizeof(_BGR) ); - nRep = 0; - nDif = 1; - } - } - } - - if ( nRep == 0 ) - { - Output( nDif-1 ); - Output( (char*)(pcolBuf+m_Xres-nDif), sizeof(_BGR)*nDif ); - } - else - { - Output( nRep+128 ); - Output( (char*)&colOld, sizeof(_BGR) ); - } - Output(); - } - } - } - else - if (m_BitPerPixel==32) - { - fh.tiImageType = bCompressed ? 10 : 2; - fh.tiAttrBits = 8; - if (fwrite(&fh, sizeof(fh), 1, f) != 1) return eSaveTgaFileWrite; - - _BGRA * pcolBuf = (_BGRA *)m_pBitmap; - pcolBuf += m_NumPixel; - - if ( !bCompressed ) - { - for (j=0; j 0 ) - { - Output( nDif-1 ); - Output( (char*)(pcolBuf+i-nDif-nRep), sizeof(_BGRA)*nDif ); - } - nDif = 1; - } - } - else - { - if ( bEqual && (nRep<127) ) - nRep++; - else - { - Output( nRep+128 ); - Output( (char*)&colOld, sizeof(_BGRA) ); - nRep = 0; - nDif = 1; - } - } - } - - if ( nRep == 0 ) - { - Output( nDif-1 ); - Output( (char*)(pcolBuf+m_Xres-nDif), sizeof(_BGRA)*nDif ); - } - else - { - Output( nRep+128 ); - Output( (char*)&colOld, sizeof(_BGRA) ); - } - Output(); - } - } - } - else - return eSaveTgaColorDepth; - - fclose(f); - - return 0; -} - -int CImage::LoadTga(char *szFilename) -{ - _TGAHEADER fh; - int i, j, k; - unsigned char nCount; - - if (!(f = fopen(szFilename, "rb"))) return eLoadTgaFileOpen; - if (fread(&fh, sizeof(fh), 1, f) != 1) return eLoadTgaFileRead; - bool bCompressed = (( fh.tiImageType & 8 ) != 0); - if ((fh.tiBitPerPixel<=0) || (fh.tiBitPerPixel>32)) - return eLoadTgaBadFormat; - - if ( Init( fh.tiXres, fh.tiYres, fh.tiBitPerPixel ) != 0 ) - return eLoadTgaInit; - - if ( m_BitPerPixel == 8 ) - { - if ( fh.tiPaletteIncluded == 1 ) - { - if ( fh.tiPaletteBpp == 24) - { - if (fread(&m_Pal, 3, fh.tiPaletteSize, f) != fh.tiPaletteSize) - return eLoadTgaFileRead; - } - else - if ( fh.tiPaletteBpp == 32) - { - unsigned char BmpPal[256][4]; - - if (fread(&BmpPal, 4, fh.tiPaletteSize, f) != fh.tiPaletteSize) - return eLoadTgaFileRead; - - for (i=0; i= m_pBitmap ) - { - nCount = Input(); - if ((nCount & 128)==0) - { - for (k=0; k<=nCount; k++) - { - colCur = Input(); - *(pcolBuf+i) = colCur; - if ( (++i) == m_Xres ) - { - i=0; - pcolBuf -= m_Xres; - break; - } - } - } - else - { - colCur = Input(); - for (k=0; k<=nCount-128; k++) - { - *(pcolBuf+i) = colCur; - if ( (++i) == m_Xres ) - { - i=0; - pcolBuf -= m_Xres; - break; - } - } - } - } - } - } - else - if ( m_BitPerPixel == 24 ) - { - _BGR * pcolBuf = (_BGR *)m_pBitmap; - pcolBuf += m_NumPixel; - - if ( !bCompressed ) - { - for (j=0; j= (_BGR *)m_pBitmap ) - { - nCount = Input(); - if ((nCount & 128)==0) - { - for (k=0; k<=nCount; k++) - { - colCur.b = Input(); - colCur.g = Input(); - colCur.r = Input(); - *(pcolBuf+i) = colCur; - if ( (++i) == m_Xres ) - { - i=0; - pcolBuf -= m_Xres; - break; - } - } - } - else - { - colCur.b = Input(); - colCur.g = Input(); - colCur.r = Input(); - for (k=0; k<=nCount-128; k++) - { - *(pcolBuf+i) = colCur; - if ( (++i) == m_Xres ) - { - i=0; - pcolBuf -= m_Xres; - break; - } - } - } - } - } - } - else - if ( m_BitPerPixel == 32 ) - { - _BGRA * pcolBuf = (_BGRA *)m_pBitmap; - pcolBuf += m_NumPixel; - - if ( !bCompressed ) - { - for (j=0; j= (_BGRA *)m_pBitmap ) - { - nCount = Input(); - if ((nCount & 128)==0) - { - for (k=0; k<=nCount; k++) - { - colCur.b = Input(); - colCur.g = Input(); - colCur.r = Input(); - colCur.a = Input(); - *(pcolBuf+i) = colCur; - if ( (++i) == m_Xres ) - { - i=0; - pcolBuf -= m_Xres; - break; - } - } - } - else - { - colCur.b = Input(); - colCur.g = Input(); - colCur.r = Input(); - colCur.a = Input(); - for (k=0; k<=nCount-128; k++) - { - *(pcolBuf+i) = colCur; - if ( (++i) == m_Xres ) - { - i=0; - pcolBuf -= m_Xres; - break; - } - } - } - } - } - } - else - return eLoadTgaColorDepth; - - fclose(f); - - return 0; -} - -int DLL CImage::Load(char *szFilename) -{ - int nRes = 0; - - if ( szFilename != NULL ) - { - char * szExt = strrchr( szFilename, '.' ); - int nNotTGA = 1; - - if ( szExt != NULL ) - nNotTGA = _stricmp( szExt, ".tga" ); - - if ( nNotTGA != 0 ) - nRes = LoadBmp( szFilename ); - else - nRes = LoadTga( szFilename ); - } - else - nRes = eLoadFilename; - - return nRes; -} - -int DLL CImage::Save(char *szFilename) -{ - int nRes = 0; - int nNotTGA = 1; - - if ( szFilename != NULL ) - { - char * szExt = strrchr( szFilename, '.' ); - - if ( szExt != NULL ) - nNotTGA = _stricmp( szExt, ".tga" ); - - if ( nNotTGA != 0 ) - { - if (( m_BitPerPixel == 16 ) || ( m_BitPerPixel == 32 )) - nRes = ConvertTo24(); - - if (nRes == 0) - nRes = SaveBmp( szFilename ); - } - else - { - if ( m_BitPerPixel == 16 ) - nRes = ConvertTo24(); - - if (nRes == 0) - nRes = SaveTga( szFilename, true ); - } - } - else - nRes = eSaveFilename; - - return nRes; -} diff --git a/src/gl/hqnx/Image.h b/src/gl/hqnx/Image.h deleted file mode 100644 index 684aba164..000000000 --- a/src/gl/hqnx/Image.h +++ /dev/null @@ -1,145 +0,0 @@ -//CImage class - loading and saving BMP and TGA files -//---------------------------------------------------------- -//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) -// -//This program is free software; you can redistribute it and/or -//modify it under the terms of the GNU Lesser General Public -//License as published by the Free Software Foundation; either -//version 2.1 of the License, or (at your option) any later version. -// -//This program is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -//Lesser General Public License for more details. -// -//You should have received a copy of the GNU Lesser General Public -//License along with this program; if not, write to the Free Software -//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -//#ifdef WIN32 -//#define DLL __declspec(dllexport) -//#else -#define DLL -//#endif - -#include -#pragma once -#pragma warning(disable: 4103) -#pragma pack(1) - -typedef struct { unsigned char b, g, r; } _BGR; -typedef struct { unsigned char b, g, r, a; } _BGRA; - -class CImage -{ - public: - DLL CImage(); - DLL ~CImage(); - - enum CImageErrors - { - eConvUnknownFormat = 10, - eConvSourceMemory = 11, - eConvDestMemory = 12, - - eSaveBmpFileOpen = 20, - eSaveBmpFileWrite = 21, - eSaveBmpSourceMemory = 22, - eSaveBmpColorDepth = 23, - - eLoadBmpFileOpen = 30, - eLoadBmpFileRead = 31, - eLoadBmpBadFormat = 32, - eLoadBmpInit = 33, - eLoadBmpColorDepth = 34, - - eSaveTgaFileOpen = 40, - eSaveTgaFileWrite = 41, - eSaveTgaSourceMemory = 42, - eSaveTgaColorDepth = 43, - - eLoadTgaFileOpen = 50, - eLoadTgaFileRead = 51, - eLoadTgaBadFormat = 52, - eLoadTgaInit = 53, - eLoadTgaColorDepth = 54, - - eLoadFilename = 60, - eSaveFilename = 61, - }; - - struct _BMPFILEHEADER - { - unsigned short bfType; - long int bfSize, bfRes1, bfOffBits; - }; - - struct _BMPIMAGEHEADEROLD - { - long int biSize; - unsigned short biWidth, biHeight; - unsigned short biPlanes, biBitCount; - }; - - struct _BMPIMAGEHEADER - { - long int biSize, biWidth, biHeight; - unsigned short biPlanes, biBitCount; - long int biCompression, biSizeImage; - long int biXPelsPerMeter, biYPelsPerMeter; - long int biClrUsed, biClrImportant; - }; - - struct _TGAHEADER - { - unsigned char tiIdentSize; - unsigned char tiPaletteIncluded; - unsigned char tiImageType; - unsigned short tiPaletteStart; - unsigned short tiPaletteSize; - unsigned char tiPaletteBpp; - unsigned short tiX0; - unsigned short tiY0; - unsigned short tiXres; - unsigned short tiYres; - unsigned char tiBitPerPixel; - unsigned char tiAttrBits; - }; - - public: - int DLL Init( int Xres, int Yres, unsigned short BitPerPixel ); - int DLL SetImage(unsigned char *img, int width, int height, int bpp); - int DLL Destroy(); - int DLL ConvertTo32( void ); - int DLL ConvertTo24( void ); - int DLL ConvertTo16( void ); - int DLL Convert8To17( int transindex ); - int DLL Convert32To17( void ); - int SaveBmp(char *szFilename); - int LoadBmp(char *szFilename); - int SaveTga(char *szFilename, bool bCompressed ); - int LoadTga(char *szFilename); - int DLL Load(char *szFilename); - int DLL Save(char *szFilename); - - private: - void Output( char * pcData, int nSize ); - void Output( char c ); - void Output( void ); - unsigned char Input( void ); - - public: - int m_Xres, m_Yres; - unsigned short m_BitPerPixel; - unsigned short m_BytePerPixel; - unsigned char * m_pBitmap; - _BGR m_Pal[256]; - - private: - int m_NumPixel; - FILE * f; - int m_nCount; - char m_cBuf[32768]; -}; - -#pragma pack(8) diff --git a/src/gl/hqnx/common.h b/src/gl/hqnx/common.h new file mode 100644 index 000000000..c2a957713 --- /dev/null +++ b/src/gl/hqnx/common.h @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com ) + * + * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net) + * Copyright (C) 2011 Francois Gannaz + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __HQX_COMMON_H_ +#define __HQX_COMMON_H_ + +#include +#include + +#define MASK_2 0x0000FF00 +#define MASK_13 0x00FF00FF +#define MASK_RGB 0x00FFFFFF +#define MASK_ALPHA 0xFF000000 + +#define Ymask 0x00FF0000 +#define Umask 0x0000FF00 +#define Vmask 0x000000FF +#define trY 0x00300000 +#define trU 0x00000700 +#define trV 0x00000006 + +/* RGB to YUV lookup table */ +extern uint32_t RGBtoYUV[16777216]; + +static inline uint32_t rgb_to_yuv(uint32_t c) +{ + // Mask against MASK_RGB to discard the alpha channel + return RGBtoYUV[MASK_RGB & c]; +} + +/* Test if there is difference in color */ +static inline int yuv_diff(uint32_t yuv1, uint32_t yuv2) { + return (( abs((yuv1 & Ymask) - (yuv2 & Ymask)) > trY ) || + ( abs((yuv1 & Umask) - (yuv2 & Umask)) > trU ) || + ( abs((yuv1 & Vmask) - (yuv2 & Vmask)) > trV ) ); +} + +static inline int Diff(uint32_t c1, uint32_t c2) +{ + return yuv_diff(rgb_to_yuv(c1), rgb_to_yuv(c2)); +} + +/* Interpolate functions */ +static inline uint32_t Interpolate_2(uint32_t c1, int w1, uint32_t c2, int w2, int s) +{ + if (c1 == c2) { + return c1; + } + return + (((((c1 & MASK_ALPHA) >> 24) * w1 + ((c2 & MASK_ALPHA) >> 24) * w2) << (24-s)) & MASK_ALPHA) + + ((((c1 & MASK_2) * w1 + (c2 & MASK_2) * w2) >> s) & MASK_2) + + ((((c1 & MASK_13) * w1 + (c2 & MASK_13) * w2) >> s) & MASK_13); +} + +static inline uint32_t Interpolate_3(uint32_t c1, int w1, uint32_t c2, int w2, uint32_t c3, int w3, int s) +{ + return + (((((c1 & MASK_ALPHA) >> 24) * w1 + ((c2 & MASK_ALPHA) >> 24) * w2 + ((c3 & MASK_ALPHA) >> 24) * w3) << (24-s)) & MASK_ALPHA) + + ((((c1 & MASK_2) * w1 + (c2 & MASK_2) * w2 + (c3 & MASK_2) * w3) >> s) & MASK_2) + + ((((c1 & MASK_13) * w1 + (c2 & MASK_13) * w2 + (c3 & MASK_13) * w3) >> s) & MASK_13); +} + +static inline uint32_t Interp1(uint32_t c1, uint32_t c2) +{ + //(c1*3+c2) >> 2; + return Interpolate_2(c1, 3, c2, 1, 2); +} + +static inline uint32_t Interp2(uint32_t c1, uint32_t c2, uint32_t c3) +{ + //(c1*2+c2+c3) >> 2; + return Interpolate_3(c1, 2, c2, 1, c3, 1, 2); +} + +static inline uint32_t Interp3(uint32_t c1, uint32_t c2) +{ + //(c1*7+c2)/8; + return Interpolate_2(c1, 7, c2, 1, 3); +} + +static inline uint32_t Interp4(uint32_t c1, uint32_t c2, uint32_t c3) +{ + //(c1*2+(c2+c3)*7)/16; + return Interpolate_3(c1, 2, c2, 7, c3, 7, 4); +} + +static inline uint32_t Interp5(uint32_t c1, uint32_t c2) +{ + //(c1+c2) >> 1; + return Interpolate_2(c1, 1, c2, 1, 1); +} + +static inline uint32_t Interp6(uint32_t c1, uint32_t c2, uint32_t c3) +{ + //(c1*5+c2*2+c3)/8; + return Interpolate_3(c1, 5, c2, 2, c3, 1, 3); +} + +static inline uint32_t Interp7(uint32_t c1, uint32_t c2, uint32_t c3) +{ + //(c1*6+c2+c3)/8; + return Interpolate_3(c1, 6, c2, 1, c3, 1, 3); +} + +static inline uint32_t Interp8(uint32_t c1, uint32_t c2) +{ + //(c1*5+c2*3)/8; + return Interpolate_2(c1, 5, c2, 3, 3); +} + +static inline uint32_t Interp9(uint32_t c1, uint32_t c2, uint32_t c3) +{ + //(c1*2+(c2+c3)*3)/8; + return Interpolate_3(c1, 2, c2, 3, c3, 3, 3); +} + +static inline uint32_t Interp10(uint32_t c1, uint32_t c2, uint32_t c3) +{ + //(c1*14+c2+c3)/16; + return Interpolate_3(c1, 14, c2, 1, c3, 1, 4); +} + +#endif diff --git a/src/gl/hqnx/hq2x.cpp b/src/gl/hqnx/hq2x.cpp index 073fe06b2..94c1dfb5a 100644 --- a/src/gl/hqnx/hq2x.cpp +++ b/src/gl/hqnx/hq2x.cpp @@ -1,2987 +1,2809 @@ -//hq2x filter demo program -//---------------------------------------------------------- -//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) -// -//This program is free software; you can redistribute it and/or -//modify it under the terms of the GNU Lesser General Public -//License as published by the Free Software Foundation; either -//version 2.1 of the License, or (at your option) any later version. -// -//This program is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -//Lesser General Public License for more details. -// -//You should have received a copy of the GNU Lesser General Public -//License along with this program; if not, write to the Free Software -//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/* + * Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com ) + * + * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ -#include "hqnx.h" +#include +#include "common.h" +#include "hqx.h" -extern int LUT16to32[65536*2]; -extern int RGBtoYUV[65536*2]; +#define PIXEL00_0 *dp = w[5]; +#define PIXEL00_10 *dp = Interp1(w[5], w[1]); +#define PIXEL00_11 *dp = Interp1(w[5], w[4]); +#define PIXEL00_12 *dp = Interp1(w[5], w[2]); +#define PIXEL00_20 *dp = Interp2(w[5], w[4], w[2]); +#define PIXEL00_21 *dp = Interp2(w[5], w[1], w[2]); +#define PIXEL00_22 *dp = Interp2(w[5], w[1], w[4]); +#define PIXEL00_60 *dp = Interp6(w[5], w[2], w[4]); +#define PIXEL00_61 *dp = Interp6(w[5], w[4], w[2]); +#define PIXEL00_70 *dp = Interp7(w[5], w[4], w[2]); +#define PIXEL00_90 *dp = Interp9(w[5], w[4], w[2]); +#define PIXEL00_100 *dp = Interp10(w[5], w[4], w[2]); +#define PIXEL01_0 *(dp+1) = w[5]; +#define PIXEL01_10 *(dp+1) = Interp1(w[5], w[3]); +#define PIXEL01_11 *(dp+1) = Interp1(w[5], w[2]); +#define PIXEL01_12 *(dp+1) = Interp1(w[5], w[6]); +#define PIXEL01_20 *(dp+1) = Interp2(w[5], w[2], w[6]); +#define PIXEL01_21 *(dp+1) = Interp2(w[5], w[3], w[6]); +#define PIXEL01_22 *(dp+1) = Interp2(w[5], w[3], w[2]); +#define PIXEL01_60 *(dp+1) = Interp6(w[5], w[6], w[2]); +#define PIXEL01_61 *(dp+1) = Interp6(w[5], w[2], w[6]); +#define PIXEL01_70 *(dp+1) = Interp7(w[5], w[2], w[6]); +#define PIXEL01_90 *(dp+1) = Interp9(w[5], w[2], w[6]); +#define PIXEL01_100 *(dp+1) = Interp10(w[5], w[2], w[6]); +#define PIXEL10_0 *(dp+dpL) = w[5]; +#define PIXEL10_10 *(dp+dpL) = Interp1(w[5], w[7]); +#define PIXEL10_11 *(dp+dpL) = Interp1(w[5], w[8]); +#define PIXEL10_12 *(dp+dpL) = Interp1(w[5], w[4]); +#define PIXEL10_20 *(dp+dpL) = Interp2(w[5], w[8], w[4]); +#define PIXEL10_21 *(dp+dpL) = Interp2(w[5], w[7], w[4]); +#define PIXEL10_22 *(dp+dpL) = Interp2(w[5], w[7], w[8]); +#define PIXEL10_60 *(dp+dpL) = Interp6(w[5], w[4], w[8]); +#define PIXEL10_61 *(dp+dpL) = Interp6(w[5], w[8], w[4]); +#define PIXEL10_70 *(dp+dpL) = Interp7(w[5], w[8], w[4]); +#define PIXEL10_90 *(dp+dpL) = Interp9(w[5], w[8], w[4]); +#define PIXEL10_100 *(dp+dpL) = Interp10(w[5], w[8], w[4]); +#define PIXEL11_0 *(dp+dpL+1) = w[5]; +#define PIXEL11_10 *(dp+dpL+1) = Interp1(w[5], w[9]); +#define PIXEL11_11 *(dp+dpL+1) = Interp1(w[5], w[6]); +#define PIXEL11_12 *(dp+dpL+1) = Interp1(w[5], w[8]); +#define PIXEL11_20 *(dp+dpL+1) = Interp2(w[5], w[6], w[8]); +#define PIXEL11_21 *(dp+dpL+1) = Interp2(w[5], w[9], w[8]); +#define PIXEL11_22 *(dp+dpL+1) = Interp2(w[5], w[9], w[6]); +#define PIXEL11_60 *(dp+dpL+1) = Interp6(w[5], w[8], w[6]); +#define PIXEL11_61 *(dp+dpL+1) = Interp6(w[5], w[6], w[8]); +#define PIXEL11_70 *(dp+dpL+1) = Interp7(w[5], w[6], w[8]); +#define PIXEL11_90 *(dp+dpL+1) = Interp9(w[5], w[6], w[8]); +#define PIXEL11_100 *(dp+dpL+1) = Interp10(w[5], w[6], w[8]); -static const __int64 reg_blank = 0; -static const __int64 const3 = 0x0003000300030003; -static const __int64 const5 = 0x0005000500050005; -static const __int64 const6 = 0x0006000600060006; -static const __int64 const14 = 0x000E000E000E000E; -static const __int64 treshold = 0x0000000000300706; - -inline void Interp1(unsigned char * pc, int c1, int c2) +HQX_API void HQX_CALLCONV hq2x_32_rb( uint32_t * sp, uint32_t srb, uint32_t * dp, uint32_t drb, int Xres, int Yres ) { - //*((int*)pc) = (c1*3+c2)/4; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - pmullw mm1, const3 - paddw mm1, mm2 - psrlw mm1, 2 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} + int i, j, k; + int prevline, nextline; + uint32_t w[10]; + int dpL = (drb >> 2); + int spL = (srb >> 2); + uint8_t *sRowP = (uint8_t *) sp; + uint8_t *dRowP = (uint8_t *) dp; + uint32_t yuv1, yuv2; -inline void Interp2(unsigned char * pc, int c1, int c2, int c3) -{ - //*((int*)pc) = (c1*2+c2+c3) >> 2; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - psllw mm1, 1 - paddw mm1, mm2 - paddw mm1, mm3 - psrlw mm1, 2 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ -inline void Interp5(unsigned char * pc, int c1, int c2) -{ - //*((int*)pc) = (c1+c2)/2; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - paddw mm1, mm2 - psrlw mm1, 1 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -inline void Interp6(unsigned char * pc, int c1, int c2, int c3) -{ - //*((int*)pc) = (c1*5+c2*2+c3)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - pmullw mm1, const5 - psllw mm2, 1 - paddw mm1, mm3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -inline void Interp7(unsigned char * pc, int c1, int c2, int c3) -{ - //*((int*)pc) = (c1*6+c2+c3)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - pmullw mm1, const6 - paddw mm2, mm3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -inline void Interp9(unsigned char * pc, int c1, int c2, int c3) -{ - //*((int*)pc) = (c1*2+(c2+c3)*3)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - psllw mm1, 1 - paddw mm2, mm3 - pmullw mm2, const3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -inline void Interp10(unsigned char * pc, int c1, int c2, int c3) -{ - //*((int*)pc) = (c1*14+c2+c3)/16; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - pmullw mm1, const14 - paddw mm2, mm3 - paddw mm1, mm2 - psrlw mm1, 4 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -#define PIXEL00_0 *((int*)(pOut)) = c[5]; -#define PIXEL00_10 Interp1(pOut, c[5], c[1]); -#define PIXEL00_11 Interp1(pOut, c[5], c[4]); -#define PIXEL00_12 Interp1(pOut, c[5], c[2]); -#define PIXEL00_20 Interp2(pOut, c[5], c[4], c[2]); -#define PIXEL00_21 Interp2(pOut, c[5], c[1], c[2]); -#define PIXEL00_22 Interp2(pOut, c[5], c[1], c[4]); -#define PIXEL00_60 Interp6(pOut, c[5], c[2], c[4]); -#define PIXEL00_61 Interp6(pOut, c[5], c[4], c[2]); -#define PIXEL00_70 Interp7(pOut, c[5], c[4], c[2]); -#define PIXEL00_90 Interp9(pOut, c[5], c[4], c[2]); -#define PIXEL00_100 Interp10(pOut, c[5], c[4], c[2]); -#define PIXEL01_0 *((int*)(pOut+4)) = c[5]; -#define PIXEL01_10 Interp1(pOut+4, c[5], c[3]); -#define PIXEL01_11 Interp1(pOut+4, c[5], c[2]); -#define PIXEL01_12 Interp1(pOut+4, c[5], c[6]); -#define PIXEL01_20 Interp2(pOut+4, c[5], c[2], c[6]); -#define PIXEL01_21 Interp2(pOut+4, c[5], c[3], c[6]); -#define PIXEL01_22 Interp2(pOut+4, c[5], c[3], c[2]); -#define PIXEL01_60 Interp6(pOut+4, c[5], c[6], c[2]); -#define PIXEL01_61 Interp6(pOut+4, c[5], c[2], c[6]); -#define PIXEL01_70 Interp7(pOut+4, c[5], c[2], c[6]); -#define PIXEL01_90 Interp9(pOut+4, c[5], c[2], c[6]); -#define PIXEL01_100 Interp10(pOut+4, c[5], c[2], c[6]); -#define PIXEL10_0 *((int*)(pOut+BpL)) = c[5]; -#define PIXEL10_10 Interp1(pOut+BpL, c[5], c[7]); -#define PIXEL10_11 Interp1(pOut+BpL, c[5], c[8]); -#define PIXEL10_12 Interp1(pOut+BpL, c[5], c[4]); -#define PIXEL10_20 Interp2(pOut+BpL, c[5], c[8], c[4]); -#define PIXEL10_21 Interp2(pOut+BpL, c[5], c[7], c[4]); -#define PIXEL10_22 Interp2(pOut+BpL, c[5], c[7], c[8]); -#define PIXEL10_60 Interp6(pOut+BpL, c[5], c[4], c[8]); -#define PIXEL10_61 Interp6(pOut+BpL, c[5], c[8], c[4]); -#define PIXEL10_70 Interp7(pOut+BpL, c[5], c[8], c[4]); -#define PIXEL10_90 Interp9(pOut+BpL, c[5], c[8], c[4]); -#define PIXEL10_100 Interp10(pOut+BpL, c[5], c[8], c[4]); -#define PIXEL11_0 *((int*)(pOut+BpL+4)) = c[5]; -#define PIXEL11_10 Interp1(pOut+BpL+4, c[5], c[9]); -#define PIXEL11_11 Interp1(pOut+BpL+4, c[5], c[6]); -#define PIXEL11_12 Interp1(pOut+BpL+4, c[5], c[8]); -#define PIXEL11_20 Interp2(pOut+BpL+4, c[5], c[6], c[8]); -#define PIXEL11_21 Interp2(pOut+BpL+4, c[5], c[9], c[8]); -#define PIXEL11_22 Interp2(pOut+BpL+4, c[5], c[9], c[6]); -#define PIXEL11_60 Interp6(pOut+BpL+4, c[5], c[8], c[6]); -#define PIXEL11_61 Interp6(pOut+BpL+4, c[5], c[6], c[8]); -#define PIXEL11_70 Interp7(pOut+BpL+4, c[5], c[6], c[8]); -#define PIXEL11_90 Interp9(pOut+BpL+4, c[5], c[6], c[8]); -#define PIXEL11_100 Interp10(pOut+BpL+4, c[5], c[6], c[8]); - - -int Diff(unsigned int w5, unsigned int w1); - -void DLL hq2x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) -{ - int i, j, k; - int w[10]; - unsigned int c[10]; - - // +----+----+----+ - // | | | | - // | w1 | w2 | w3 | - // +----+----+----+ - // | | | | - // | w4 | w5 | w6 | - // +----+----+----+ - // | | | | - // | w7 | w8 | w9 | - // +----+----+----+ - - for (j=0; j0) + if (j>0) prevline = -spL; else prevline = 0; + if (j0) + { + w[1] = *(sp + prevline - 1); + w[4] = *(sp - 1); + w[7] = *(sp + nextline - 1); + } + else + { + w[1] = w[2]; + w[4] = w[5]; + w[7] = w[8]; + } + + if (i0) - { - w[4] = *(pIn - 1); - } - else - { - w[4] = 0; - } - - w[5] = *(pIn); - if (i0) - { - w[7] = *(pIn + Xres - 1); - } - else - { - w[7] = 0; - } - - w[8] = *(pIn + Xres); - if (i +#include "common.h" +#include "hqx.h" -extern int LUT16to32[65536*2]; -extern int RGBtoYUV[65536*2]; +#define PIXEL00_1M *dp = Interp1(w[5], w[1]); +#define PIXEL00_1U *dp = Interp1(w[5], w[2]); +#define PIXEL00_1L *dp = Interp1(w[5], w[4]); +#define PIXEL00_2 *dp = Interp2(w[5], w[4], w[2]); +#define PIXEL00_4 *dp = Interp4(w[5], w[4], w[2]); +#define PIXEL00_5 *dp = Interp5(w[4], w[2]); +#define PIXEL00_C *dp = w[5]; -static const __int64 reg_blank = 0; -static const __int64 const3 = 0x0003000300030003; -static const __int64 const7 = 0x0007000700070007; -static const __int64 treshold = 0x0000000000300706; +#define PIXEL01_1 *(dp+1) = Interp1(w[5], w[2]); +#define PIXEL01_3 *(dp+1) = Interp3(w[5], w[2]); +#define PIXEL01_6 *(dp+1) = Interp1(w[2], w[5]); +#define PIXEL01_C *(dp+1) = w[5]; -inline void Interp1(unsigned char * pc, int c1, int c2) +#define PIXEL02_1M *(dp+2) = Interp1(w[5], w[3]); +#define PIXEL02_1U *(dp+2) = Interp1(w[5], w[2]); +#define PIXEL02_1R *(dp+2) = Interp1(w[5], w[6]); +#define PIXEL02_2 *(dp+2) = Interp2(w[5], w[2], w[6]); +#define PIXEL02_4 *(dp+2) = Interp4(w[5], w[2], w[6]); +#define PIXEL02_5 *(dp+2) = Interp5(w[2], w[6]); +#define PIXEL02_C *(dp+2) = w[5]; + +#define PIXEL10_1 *(dp+dpL) = Interp1(w[5], w[4]); +#define PIXEL10_3 *(dp+dpL) = Interp3(w[5], w[4]); +#define PIXEL10_6 *(dp+dpL) = Interp1(w[4], w[5]); +#define PIXEL10_C *(dp+dpL) = w[5]; + +#define PIXEL11 *(dp+dpL+1) = w[5]; + +#define PIXEL12_1 *(dp+dpL+2) = Interp1(w[5], w[6]); +#define PIXEL12_3 *(dp+dpL+2) = Interp3(w[5], w[6]); +#define PIXEL12_6 *(dp+dpL+2) = Interp1(w[6], w[5]); +#define PIXEL12_C *(dp+dpL+2) = w[5]; + +#define PIXEL20_1M *(dp+dpL+dpL) = Interp1(w[5], w[7]); +#define PIXEL20_1D *(dp+dpL+dpL) = Interp1(w[5], w[8]); +#define PIXEL20_1L *(dp+dpL+dpL) = Interp1(w[5], w[4]); +#define PIXEL20_2 *(dp+dpL+dpL) = Interp2(w[5], w[8], w[4]); +#define PIXEL20_4 *(dp+dpL+dpL) = Interp4(w[5], w[8], w[4]); +#define PIXEL20_5 *(dp+dpL+dpL) = Interp5(w[8], w[4]); +#define PIXEL20_C *(dp+dpL+dpL) = w[5]; + +#define PIXEL21_1 *(dp+dpL+dpL+1) = Interp1(w[5], w[8]); +#define PIXEL21_3 *(dp+dpL+dpL+1) = Interp3(w[5], w[8]); +#define PIXEL21_6 *(dp+dpL+dpL+1) = Interp1(w[8], w[5]); +#define PIXEL21_C *(dp+dpL+dpL+1) = w[5]; + +#define PIXEL22_1M *(dp+dpL+dpL+2) = Interp1(w[5], w[9]); +#define PIXEL22_1D *(dp+dpL+dpL+2) = Interp1(w[5], w[8]); +#define PIXEL22_1R *(dp+dpL+dpL+2) = Interp1(w[5], w[6]); +#define PIXEL22_2 *(dp+dpL+dpL+2) = Interp2(w[5], w[6], w[8]); +#define PIXEL22_4 *(dp+dpL+dpL+2) = Interp4(w[5], w[6], w[8]); +#define PIXEL22_5 *(dp+dpL+dpL+2) = Interp5(w[6], w[8]); +#define PIXEL22_C *(dp+dpL+dpL+2) = w[5]; + +HQX_API void HQX_CALLCONV hq3x_32_rb( uint32_t * sp, uint32_t srb, uint32_t * dp, uint32_t drb, int Xres, int Yres ) { - //*((int*)pc) = (c1*3+c2)/4; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - pmullw mm1, const3 - paddw mm1, mm2 - psrlw mm1, 2 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} + int i, j, k; + int prevline, nextline; + uint32_t w[10]; + int dpL = (drb >> 2); + int spL = (srb >> 2); + uint8_t *sRowP = (uint8_t *) sp; + uint8_t *dRowP = (uint8_t *) dp; + uint32_t yuv1, yuv2; -inline void Interp2(unsigned char * pc, int c1, int c2, int c3) -{ -// *((int*)pc) = (c1*2+c2+c3)/4; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - psllw mm1, 1 - paddw mm1, mm2 - paddw mm1, mm3 - psrlw mm1, 2 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ -inline void Interp3(unsigned char * pc, int c1, int c2) -{ - //*((int*)pc) = (c1*7+c2)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - pmullw mm1, const7 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -inline void Interp4(unsigned char * pc, int c1, int c2, int c3) -{ - //*((int*)pc) = (c1*2+(c2+c3)*7)/16; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - psllw mm1, 1 - paddw mm2, mm3 - pmullw mm2, const7 - paddw mm1, mm2 - psrlw mm1, 4 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -inline void Interp5(unsigned char * pc, int c1, int c2) -{ - //*((int*)pc) = (c1+c2)/2; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - paddw mm1, mm2 - psrlw mm1, 1 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -#define PIXEL00_1M Interp1(pOut, c[5], c[1]); -#define PIXEL00_1U Interp1(pOut, c[5], c[2]); -#define PIXEL00_1L Interp1(pOut, c[5], c[4]); -#define PIXEL00_2 Interp2(pOut, c[5], c[4], c[2]); -#define PIXEL00_4 Interp4(pOut, c[5], c[4], c[2]); -#define PIXEL00_5 Interp5(pOut, c[4], c[2]); -#define PIXEL00_C *((int*)(pOut)) = c[5]; - -#define PIXEL01_1 Interp1(pOut+4, c[5], c[2]); -#define PIXEL01_3 Interp3(pOut+4, c[5], c[2]); -#define PIXEL01_6 Interp1(pOut+4, c[2], c[5]); -#define PIXEL01_C *((int*)(pOut+4)) = c[5]; - -#define PIXEL02_1M Interp1(pOut+8, c[5], c[3]); -#define PIXEL02_1U Interp1(pOut+8, c[5], c[2]); -#define PIXEL02_1R Interp1(pOut+8, c[5], c[6]); -#define PIXEL02_2 Interp2(pOut+8, c[5], c[2], c[6]); -#define PIXEL02_4 Interp4(pOut+8, c[5], c[2], c[6]); -#define PIXEL02_5 Interp5(pOut+8, c[2], c[6]); -#define PIXEL02_C *((int*)(pOut+8)) = c[5]; - -#define PIXEL10_1 Interp1(pOut+BpL, c[5], c[4]); -#define PIXEL10_3 Interp3(pOut+BpL, c[5], c[4]); -#define PIXEL10_6 Interp1(pOut+BpL, c[4], c[5]); -#define PIXEL10_C *((int*)(pOut+BpL)) = c[5]; - -#define PIXEL11 *((int*)(pOut+BpL+4)) = c[5]; - -#define PIXEL12_1 Interp1(pOut+BpL+8, c[5], c[6]); -#define PIXEL12_3 Interp3(pOut+BpL+8, c[5], c[6]); -#define PIXEL12_6 Interp1(pOut+BpL+8, c[6], c[5]); -#define PIXEL12_C *((int*)(pOut+BpL+8)) = c[5]; - -#define PIXEL20_1M Interp1(pOut+BpL+BpL, c[5], c[7]); -#define PIXEL20_1D Interp1(pOut+BpL+BpL, c[5], c[8]); -#define PIXEL20_1L Interp1(pOut+BpL+BpL, c[5], c[4]); -#define PIXEL20_2 Interp2(pOut+BpL+BpL, c[5], c[8], c[4]); -#define PIXEL20_4 Interp4(pOut+BpL+BpL, c[5], c[8], c[4]); -#define PIXEL20_5 Interp5(pOut+BpL+BpL, c[8], c[4]); -#define PIXEL20_C *((int*)(pOut+BpL+BpL)) = c[5]; - -#define PIXEL21_1 Interp1(pOut+BpL+BpL+4, c[5], c[8]); -#define PIXEL21_3 Interp3(pOut+BpL+BpL+4, c[5], c[8]); -#define PIXEL21_6 Interp1(pOut+BpL+BpL+4, c[8], c[5]); -#define PIXEL21_C *((int*)(pOut+BpL+BpL+4)) = c[5]; - -#define PIXEL22_1M Interp1(pOut+BpL+BpL+8, c[5], c[9]); -#define PIXEL22_1D Interp1(pOut+BpL+BpL+8, c[5], c[8]); -#define PIXEL22_1R Interp1(pOut+BpL+BpL+8, c[5], c[6]); -#define PIXEL22_2 Interp2(pOut+BpL+BpL+8, c[5], c[6], c[8]); -#define PIXEL22_4 Interp4(pOut+BpL+BpL+8, c[5], c[6], c[8]); -#define PIXEL22_5 Interp5(pOut+BpL+BpL+8, c[6], c[8]); -#define PIXEL22_C *((int*)(pOut+BpL+BpL+8)) = c[5]; - -int Diff(unsigned int w5, unsigned int w1); - -void DLL hq3x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) -{ - int i, j, k; - int w[10]; - unsigned int c[10]; - - // +----+----+----+ - // | | | | - // | w1 | w2 | w3 | - // +----+----+----+ - // | | | | - // | w4 | w5 | w6 | - // +----+----+----+ - // | | | | - // | w7 | w8 | w9 | - // +----+----+----+ - - for (j=0; j0) w[1] = *(pIn - Xres - 1); else w[1] = 0; - w[2] = *(pIn - Xres); - if (i0) prevline = -spL; else prevline = 0; + if (j0) w[4] = *(pIn - 1); else w[4] = 0; - w[5] = *(pIn); - if (i0) w[7] = *(pIn + Xres - 1); else w[7] = 0; - w[8] = *(pIn + Xres); - if (i0) + { + w[1] = *(sp + prevline - 1); + w[4] = *(sp - 1); + w[7] = *(sp + nextline - 1); + } + else + { + w[1] = w[2]; + w[4] = w[5]; + w[7] = w[8]; + } - int pattern = 0; + if (i -#include -#include -#include -#include "hqnx.h" - -int LUT16to32[65536*2]; -int RGBtoYUV[65536*2]; - -static const __int64 reg_blank = 0; -static const __int64 const3 = 0x0003000300030003; -static const __int64 const5 = 0x0005000500050005; -static const __int64 const6 = 0x0006000600060006; -static const __int64 const7 = 0x0007000700070007; -static const __int64 treshold = 0x0000000000300706; - - -inline void Interp1(unsigned char * pc, int c1, int c2) -{ - //*((int*)pc) = (c1*3+c2)/4; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - pmullw mm1, const3 - paddw mm1, mm2 - psrlw mm1, 2 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -inline void Interp2(unsigned char * pc, int c1, int c2, int c3) -{ -// *((int*)pc) = (c1*2+c2+c3)/4; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - psllw mm1, 1 - paddw mm1, mm2 - paddw mm1, mm3 - psrlw mm1, 2 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -inline void Interp3(unsigned char * pc, int c1, int c2) -{ - //*((int*)pc) = (c1*7+c2)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - pmullw mm1, const7 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -inline void Interp5(unsigned char * pc, int c1, int c2) -{ - //*((int*)pc) = (c1+c2)/2; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - paddw mm1, mm2 - psrlw mm1, 1 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -inline void Interp6(unsigned char * pc, int c1, int c2, int c3) -{ - //*((int*)pc) = (c1*5+c2*2+c3)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - pmullw mm1, const5 - psllw mm2, 1 - paddw mm1, mm3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -inline void Interp7(unsigned char * pc, int c1, int c2, int c3) -{ - //*((int*)pc) = (c1*6+c2+c3)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - pmullw mm1, const6 - paddw mm2, mm3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -inline void Interp8(unsigned char * pc, int c1, int c2) -{ - //*((int*)pc) = (c1*5+c2*3)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - pmullw mm1, const5 - pmullw mm2, const3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } -} - -#define PIXEL00_0 *((int*)(pOut)) = c[5]; -#define PIXEL00_11 Interp1(pOut, c[5], c[4]); -#define PIXEL00_12 Interp1(pOut, c[5], c[2]); -#define PIXEL00_20 Interp2(pOut, c[5], c[2], c[4]); -#define PIXEL00_50 Interp5(pOut, c[2], c[4]); -#define PIXEL00_80 Interp8(pOut, c[5], c[1]); -#define PIXEL00_81 Interp8(pOut, c[5], c[4]); -#define PIXEL00_82 Interp8(pOut, c[5], c[2]); -#define PIXEL01_0 *((int*)(pOut+4)) = c[5]; -#define PIXEL01_10 Interp1(pOut+4, c[5], c[1]); -#define PIXEL01_12 Interp1(pOut+4, c[5], c[2]); -#define PIXEL01_14 Interp1(pOut+4, c[2], c[5]); -#define PIXEL01_21 Interp2(pOut+4, c[2], c[5], c[4]); -#define PIXEL01_31 Interp3(pOut+4, c[5], c[4]); -#define PIXEL01_50 Interp5(pOut+4, c[2], c[5]); -#define PIXEL01_60 Interp6(pOut+4, c[5], c[2], c[4]); -#define PIXEL01_61 Interp6(pOut+4, c[5], c[2], c[1]); -#define PIXEL01_82 Interp8(pOut+4, c[5], c[2]); -#define PIXEL01_83 Interp8(pOut+4, c[2], c[4]); -#define PIXEL02_0 *((int*)(pOut+8)) = c[5]; -#define PIXEL02_10 Interp1(pOut+8, c[5], c[3]); -#define PIXEL02_11 Interp1(pOut+8, c[5], c[2]); -#define PIXEL02_13 Interp1(pOut+8, c[2], c[5]); -#define PIXEL02_21 Interp2(pOut+8, c[2], c[5], c[6]); -#define PIXEL02_32 Interp3(pOut+8, c[5], c[6]); -#define PIXEL02_50 Interp5(pOut+8, c[2], c[5]); -#define PIXEL02_60 Interp6(pOut+8, c[5], c[2], c[6]); -#define PIXEL02_61 Interp6(pOut+8, c[5], c[2], c[3]); -#define PIXEL02_81 Interp8(pOut+8, c[5], c[2]); -#define PIXEL02_83 Interp8(pOut+8, c[2], c[6]); -#define PIXEL03_0 *((int*)(pOut+12)) = c[5]; -#define PIXEL03_11 Interp1(pOut+12, c[5], c[2]); -#define PIXEL03_12 Interp1(pOut+12, c[5], c[6]); -#define PIXEL03_20 Interp2(pOut+12, c[5], c[2], c[6]); -#define PIXEL03_50 Interp5(pOut+12, c[2], c[6]); -#define PIXEL03_80 Interp8(pOut+12, c[5], c[3]); -#define PIXEL03_81 Interp8(pOut+12, c[5], c[2]); -#define PIXEL03_82 Interp8(pOut+12, c[5], c[6]); -#define PIXEL10_0 *((int*)(pOut+BpL)) = c[5]; -#define PIXEL10_10 Interp1(pOut+BpL, c[5], c[1]); -#define PIXEL10_11 Interp1(pOut+BpL, c[5], c[4]); -#define PIXEL10_13 Interp1(pOut+BpL, c[4], c[5]); -#define PIXEL10_21 Interp2(pOut+BpL, c[4], c[5], c[2]); -#define PIXEL10_32 Interp3(pOut+BpL, c[5], c[2]); -#define PIXEL10_50 Interp5(pOut+BpL, c[4], c[5]); -#define PIXEL10_60 Interp6(pOut+BpL, c[5], c[4], c[2]); -#define PIXEL10_61 Interp6(pOut+BpL, c[5], c[4], c[1]); -#define PIXEL10_81 Interp8(pOut+BpL, c[5], c[4]); -#define PIXEL10_83 Interp8(pOut+BpL, c[4], c[2]); -#define PIXEL11_0 *((int*)(pOut+BpL+4)) = c[5]; -#define PIXEL11_30 Interp3(pOut+BpL+4, c[5], c[1]); -#define PIXEL11_31 Interp3(pOut+BpL+4, c[5], c[4]); -#define PIXEL11_32 Interp3(pOut+BpL+4, c[5], c[2]); -#define PIXEL11_70 Interp7(pOut+BpL+4, c[5], c[4], c[2]); -#define PIXEL12_0 *((int*)(pOut+BpL+8)) = c[5]; -#define PIXEL12_30 Interp3(pOut+BpL+8, c[5], c[3]); -#define PIXEL12_31 Interp3(pOut+BpL+8, c[5], c[2]); -#define PIXEL12_32 Interp3(pOut+BpL+8, c[5], c[6]); -#define PIXEL12_70 Interp7(pOut+BpL+8, c[5], c[6], c[2]); -#define PIXEL13_0 *((int*)(pOut+BpL+12)) = c[5]; -#define PIXEL13_10 Interp1(pOut+BpL+12, c[5], c[3]); -#define PIXEL13_12 Interp1(pOut+BpL+12, c[5], c[6]); -#define PIXEL13_14 Interp1(pOut+BpL+12, c[6], c[5]); -#define PIXEL13_21 Interp2(pOut+BpL+12, c[6], c[5], c[2]); -#define PIXEL13_31 Interp3(pOut+BpL+12, c[5], c[2]); -#define PIXEL13_50 Interp5(pOut+BpL+12, c[6], c[5]); -#define PIXEL13_60 Interp6(pOut+BpL+12, c[5], c[6], c[2]); -#define PIXEL13_61 Interp6(pOut+BpL+12, c[5], c[6], c[3]); -#define PIXEL13_82 Interp8(pOut+BpL+12, c[5], c[6]); -#define PIXEL13_83 Interp8(pOut+BpL+12, c[6], c[2]); -#define PIXEL20_0 *((int*)(pOut+BpL+BpL)) = c[5]; -#define PIXEL20_10 Interp1(pOut+BpL+BpL, c[5], c[7]); -#define PIXEL20_12 Interp1(pOut+BpL+BpL, c[5], c[4]); -#define PIXEL20_14 Interp1(pOut+BpL+BpL, c[4], c[5]); -#define PIXEL20_21 Interp2(pOut+BpL+BpL, c[4], c[5], c[8]); -#define PIXEL20_31 Interp3(pOut+BpL+BpL, c[5], c[8]); -#define PIXEL20_50 Interp5(pOut+BpL+BpL, c[4], c[5]); -#define PIXEL20_60 Interp6(pOut+BpL+BpL, c[5], c[4], c[8]); -#define PIXEL20_61 Interp6(pOut+BpL+BpL, c[5], c[4], c[7]); -#define PIXEL20_82 Interp8(pOut+BpL+BpL, c[5], c[4]); -#define PIXEL20_83 Interp8(pOut+BpL+BpL, c[4], c[8]); -#define PIXEL21_0 *((int*)(pOut+BpL+BpL+4)) = c[5]; -#define PIXEL21_30 Interp3(pOut+BpL+BpL+4, c[5], c[7]); -#define PIXEL21_31 Interp3(pOut+BpL+BpL+4, c[5], c[8]); -#define PIXEL21_32 Interp3(pOut+BpL+BpL+4, c[5], c[4]); -#define PIXEL21_70 Interp7(pOut+BpL+BpL+4, c[5], c[4], c[8]); -#define PIXEL22_0 *((int*)(pOut+BpL+BpL+8)) = c[5]; -#define PIXEL22_30 Interp3(pOut+BpL+BpL+8, c[5], c[9]); -#define PIXEL22_31 Interp3(pOut+BpL+BpL+8, c[5], c[6]); -#define PIXEL22_32 Interp3(pOut+BpL+BpL+8, c[5], c[8]); -#define PIXEL22_70 Interp7(pOut+BpL+BpL+8, c[5], c[6], c[8]); -#define PIXEL23_0 *((int*)(pOut+BpL+BpL+12)) = c[5]; -#define PIXEL23_10 Interp1(pOut+BpL+BpL+12, c[5], c[9]); -#define PIXEL23_11 Interp1(pOut+BpL+BpL+12, c[5], c[6]); -#define PIXEL23_13 Interp1(pOut+BpL+BpL+12, c[6], c[5]); -#define PIXEL23_21 Interp2(pOut+BpL+BpL+12, c[6], c[5], c[8]); -#define PIXEL23_32 Interp3(pOut+BpL+BpL+12, c[5], c[8]); -#define PIXEL23_50 Interp5(pOut+BpL+BpL+12, c[6], c[5]); -#define PIXEL23_60 Interp6(pOut+BpL+BpL+12, c[5], c[6], c[8]); -#define PIXEL23_61 Interp6(pOut+BpL+BpL+12, c[5], c[6], c[9]); -#define PIXEL23_81 Interp8(pOut+BpL+BpL+12, c[5], c[6]); -#define PIXEL23_83 Interp8(pOut+BpL+BpL+12, c[6], c[8]); -#define PIXEL30_0 *((int*)(pOut+BpL+BpL+BpL)) = c[5]; -#define PIXEL30_11 Interp1(pOut+BpL+BpL+BpL, c[5], c[8]); -#define PIXEL30_12 Interp1(pOut+BpL+BpL+BpL, c[5], c[4]); -#define PIXEL30_20 Interp2(pOut+BpL+BpL+BpL, c[5], c[8], c[4]); -#define PIXEL30_50 Interp5(pOut+BpL+BpL+BpL, c[8], c[4]); -#define PIXEL30_80 Interp8(pOut+BpL+BpL+BpL, c[5], c[7]); -#define PIXEL30_81 Interp8(pOut+BpL+BpL+BpL, c[5], c[8]); -#define PIXEL30_82 Interp8(pOut+BpL+BpL+BpL, c[5], c[4]); -#define PIXEL31_0 *((int*)(pOut+BpL+BpL+BpL+4)) = c[5]; -#define PIXEL31_10 Interp1(pOut+BpL+BpL+BpL+4, c[5], c[7]); -#define PIXEL31_11 Interp1(pOut+BpL+BpL+BpL+4, c[5], c[8]); -#define PIXEL31_13 Interp1(pOut+BpL+BpL+BpL+4, c[8], c[5]); -#define PIXEL31_21 Interp2(pOut+BpL+BpL+BpL+4, c[8], c[5], c[4]); -#define PIXEL31_32 Interp3(pOut+BpL+BpL+BpL+4, c[5], c[4]); -#define PIXEL31_50 Interp5(pOut+BpL+BpL+BpL+4, c[8], c[5]); -#define PIXEL31_60 Interp6(pOut+BpL+BpL+BpL+4, c[5], c[8], c[4]); -#define PIXEL31_61 Interp6(pOut+BpL+BpL+BpL+4, c[5], c[8], c[7]); -#define PIXEL31_81 Interp8(pOut+BpL+BpL+BpL+4, c[5], c[8]); -#define PIXEL31_83 Interp8(pOut+BpL+BpL+BpL+4, c[8], c[4]); -#define PIXEL32_0 *((int*)(pOut+BpL+BpL+BpL+8)) = c[5]; -#define PIXEL32_10 Interp1(pOut+BpL+BpL+BpL+8, c[5], c[9]); -#define PIXEL32_12 Interp1(pOut+BpL+BpL+BpL+8, c[5], c[8]); -#define PIXEL32_14 Interp1(pOut+BpL+BpL+BpL+8, c[8], c[5]); -#define PIXEL32_21 Interp2(pOut+BpL+BpL+BpL+8, c[8], c[5], c[6]); -#define PIXEL32_31 Interp3(pOut+BpL+BpL+BpL+8, c[5], c[6]); -#define PIXEL32_50 Interp5(pOut+BpL+BpL+BpL+8, c[8], c[5]); -#define PIXEL32_60 Interp6(pOut+BpL+BpL+BpL+8, c[5], c[8], c[6]); -#define PIXEL32_61 Interp6(pOut+BpL+BpL+BpL+8, c[5], c[8], c[9]); -#define PIXEL32_82 Interp8(pOut+BpL+BpL+BpL+8, c[5], c[8]); -#define PIXEL32_83 Interp8(pOut+BpL+BpL+BpL+8, c[8], c[6]); -#define PIXEL33_0 *((int*)(pOut+BpL+BpL+BpL+12)) = c[5]; -#define PIXEL33_11 Interp1(pOut+BpL+BpL+BpL+12, c[5], c[6]); -#define PIXEL33_12 Interp1(pOut+BpL+BpL+BpL+12, c[5], c[8]); -#define PIXEL33_20 Interp2(pOut+BpL+BpL+BpL+12, c[5], c[8], c[6]); -#define PIXEL33_50 Interp5(pOut+BpL+BpL+BpL+12, c[8], c[6]); -#define PIXEL33_80 Interp8(pOut+BpL+BpL+BpL+12, c[5], c[9]); -#define PIXEL33_81 Interp8(pOut+BpL+BpL+BpL+12, c[5], c[6]); -#define PIXEL33_82 Interp8(pOut+BpL+BpL+BpL+12, c[5], c[8]); - - -#pragma warning(disable: 4035) - -int Diff(unsigned int w5, unsigned int w1) -{ - __asm - { - xor eax,eax - mov ebx,w5 - mov edx,w1 - cmp ebx,edx - je FIN - mov ecx,offset RGBtoYUV - movd mm1,[ecx + ebx*4] - movq mm5,mm1 - movd mm2,[ecx + edx*4] - psubusb mm1,mm2 - psubusb mm2,mm5 - por mm1,mm2 - psubusb mm1,treshold - movd eax,mm1 -FIN: - } -} -// returns result in eax register - -#pragma warning(default: 4035) - -void DLL hq4x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) -{ - int i, j, k; - int w[10]; - int c[10]; - - // +----+----+----+ - // | | | | - // | w1 | w2 | w3 | - // +----+----+----+ - // | | | | - // | w4 | w5 | w6 | - // +----+----+----+ - // | | | | - // | w7 | w8 | w9 | - // +----+----+----+ - - for (j = 0; j < Yres; j++) - { - for (i = 0; i < Xres; i++) - { - if (j == 0) - { - w[1] = 0; - w[2] = 0; - w[3] = 0; - } - else - { - if (i > 0) - w[1] = *(pIn - Xres - 1); - else - w[1] = 0; - - w[2] = *(pIn - Xres); - - if (i < Xres - 1) - w[3] = *(pIn - Xres + 1); - else - w[3] = 0; - } - - if (i > 0) - w[4] = *(pIn - 1); - else - w[4] = 0; - - w[5] = *(pIn); - - if (i < Xres - 1) - w[6] = *(pIn + 1); - else - w[6] = 0; - - if (j == Yres - 1) - { - w[7] = 0; - w[8] = 0; - w[9] = 0; - } - else - { - if (i > 0) - w[7] = *(pIn + Xres - 1); - else - w[7] = 0; - - w[8] = *(pIn + Xres); - - if (i < Xres-1) - w[9] = *(pIn + Xres + 1); - else - w[9] = 0; - } - - int pattern = 0; - - if ( Diff(w[5],w[1]) ) pattern |= 0x0001; - if ( Diff(w[5],w[2]) ) pattern |= 0x0002; - if ( Diff(w[5],w[3]) ) pattern |= 0x0004; - if ( Diff(w[5],w[4]) ) pattern |= 0x0008; - if ( Diff(w[5],w[6]) ) pattern |= 0x0010; - if ( Diff(w[5],w[7]) ) pattern |= 0x0020; - if ( Diff(w[5],w[8]) ) pattern |= 0x0040; - if ( Diff(w[5],w[9]) ) pattern |= 0x0080; - - for (k=1; k<=9; k++) - c[k] = LUT16to32[w[k]]; - - switch (pattern) - { - case 0: - case 1: - case 4: - case 32: - case 128: - case 5: - case 132: - case 160: - case 33: - case 129: - case 36: - case 133: - case 164: - case 161: - case 37: - case 165: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } - case 2: - case 34: - case 130: - case 162: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } - case 16: - case 17: - case 48: - case 49: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } - case 64: - case 65: - case 68: - case 69: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 8: - case 12: - case 136: - case 140: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } - case 3: - case 35: - case 131: - case 163: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } - case 6: - case 38: - case 134: - case 166: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } - case 20: - case 21: - case 52: - case 53: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } - case 144: - case 145: - case 176: - case 177: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; - } - case 192: - case 193: - case 196: - case 197: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } - case 96: - case 97: - case 100: - case 101: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } - case 40: - case 44: - case 168: - case 172: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } - case 9: - case 13: - case 137: - case 141: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } - case 18: - case 50: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL12_0 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } - case 80: - case 81: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_61 - PIXEL21_30 - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 72: - case 76: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_50 - PIXEL21_0 - PIXEL30_50 - PIXEL31_50 - } - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 10: - case 138: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - PIXEL11_0 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } - case 66: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 24: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } - case 7: - case 39: - case 135: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } - case 148: - case 149: - case 180: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; - } - case 224: - case 228: - case 225: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } - case 41: - case 169: - case 45: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } - case 22: - case 54: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } - case 208: - case 209: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 104: - case 108: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 11: - case 139: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } - case 19: - case 51: - { - if (Diff(w[2], w[6])) - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL00_12 - PIXEL01_14 - PIXEL02_83 - PIXEL03_50 - PIXEL12_70 - PIXEL13_21 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } - case 146: - case 178: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - PIXEL23_32 - PIXEL33_82 - } - else - { - PIXEL02_21 - PIXEL03_50 - PIXEL12_70 - PIXEL13_83 - PIXEL23_13 - PIXEL33_11 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - break; - } - case 84: - case 85: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - if (Diff(w[6], w[8])) - { - PIXEL03_81 - PIXEL13_31 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL03_12 - PIXEL13_14 - PIXEL22_70 - PIXEL23_83 - PIXEL32_21 - PIXEL33_50 - } - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL20_61 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - break; - } - case 112: - case 113: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_82 - PIXEL21_32 - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_70 - PIXEL23_21 - PIXEL30_11 - PIXEL31_13 - PIXEL32_83 - PIXEL33_50 - } - break; - } - case 200: - case 204: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - } - else - { - PIXEL20_21 - PIXEL21_70 - PIXEL30_50 - PIXEL31_83 - PIXEL32_14 - PIXEL33_12 - } - PIXEL22_31 - PIXEL23_81 - break; - } - case 73: - case 77: - { - if (Diff(w[8], w[4])) - { - PIXEL00_82 - PIXEL10_32 - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL00_11 - PIXEL10_13 - PIXEL20_83 - PIXEL21_70 - PIXEL30_50 - PIXEL31_21 - } - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 42: - case 170: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - PIXEL20_31 - PIXEL30_81 - } - else - { - PIXEL00_50 - PIXEL01_21 - PIXEL10_83 - PIXEL11_70 - PIXEL20_14 - PIXEL30_12 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } - case 14: - case 142: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_50 - PIXEL01_83 - PIXEL02_13 - PIXEL03_11 - PIXEL10_21 - PIXEL11_70 - } - PIXEL12_32 - PIXEL13_82 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } - case 67: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 70: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 28: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } - case 152: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 194: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } - case 98: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } - case 56: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } - case 25: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } - case 26: - case 31: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL11_0 - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } - case 82: - case 214: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 88: - case 248: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - break; - } - case 74: - case 107: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 27: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } - case 86: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 216: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 106: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 30: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } - case 210: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 120: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 75: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 29: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } - case 198: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } - case 184: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } - case 99: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } - case 57: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } - case 71: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 156: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 226: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } - case 60: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } - case 195: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } - case 102: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } - case 153: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 58: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } - case 83: - { - PIXEL00_81 - PIXEL01_31 - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_61 - PIXEL21_30 - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 92: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } - case 202: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_31 - PIXEL23_81 - PIXEL32_31 - PIXEL33_81 - break; - } - case 78: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - PIXEL02_32 - PIXEL03_82 - PIXEL12_32 - PIXEL13_82 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 154: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 114: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_82 - PIXEL21_32 - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - PIXEL30_82 - PIXEL31_32 - break; - } - case 89: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } - case 90: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } - case 55: - case 23: - { - if (Diff(w[2], w[6])) - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_0 - PIXEL03_0 - PIXEL12_0 - PIXEL13_0 - } - else - { - PIXEL00_12 - PIXEL01_14 - PIXEL02_83 - PIXEL03_50 - PIXEL12_70 - PIXEL13_21 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } - case 182: - case 150: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL12_0 - PIXEL13_0 - PIXEL23_32 - PIXEL33_82 - } - else - { - PIXEL02_21 - PIXEL03_50 - PIXEL12_70 - PIXEL13_83 - PIXEL23_13 - PIXEL33_11 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - break; - } - case 213: - case 212: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - if (Diff(w[6], w[8])) - { - PIXEL03_81 - PIXEL13_31 - PIXEL22_0 - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL03_12 - PIXEL13_14 - PIXEL22_70 - PIXEL23_83 - PIXEL32_21 - PIXEL33_50 - } - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL20_61 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - break; - } - case 241: - case 240: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_82 - PIXEL21_32 - if (Diff(w[6], w[8])) - { - PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL22_70 - PIXEL23_21 - PIXEL30_11 - PIXEL31_13 - PIXEL32_83 - PIXEL33_50 - } - break; - } - case 236: - case 232: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL21_0 - PIXEL30_0 - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - } - else - { - PIXEL20_21 - PIXEL21_70 - PIXEL30_50 - PIXEL31_83 - PIXEL32_14 - PIXEL33_12 - } - PIXEL22_31 - PIXEL23_81 - break; - } - case 109: - case 105: - { - if (Diff(w[8], w[4])) - { - PIXEL00_82 - PIXEL10_32 - PIXEL20_0 - PIXEL21_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL00_11 - PIXEL10_13 - PIXEL20_83 - PIXEL21_70 - PIXEL30_50 - PIXEL31_21 - } - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 171: - case 43: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - PIXEL11_0 - PIXEL20_31 - PIXEL30_81 - } - else - { - PIXEL00_50 - PIXEL01_21 - PIXEL10_83 - PIXEL11_70 - PIXEL20_14 - PIXEL30_12 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } - case 143: - case 15: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL02_32 - PIXEL03_82 - PIXEL10_0 - PIXEL11_0 - } - else - { - PIXEL00_50 - PIXEL01_83 - PIXEL02_13 - PIXEL03_11 - PIXEL10_21 - PIXEL11_70 - } - PIXEL12_32 - PIXEL13_82 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } - case 124: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 203: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - PIXEL20_10 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } - case 62: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } - case 211: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_10 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 118: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_10 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } - case 217: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 110: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_10 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 155: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 188: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } - case 185: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } - case 61: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } - case 157: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 103: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } - case 227: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } - case 230: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } - case 199: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } - case 220: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - break; - } - case 158: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 234: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_31 - PIXEL23_81 - PIXEL32_31 - PIXEL33_81 - break; - } - case 242: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_82 - PIXEL21_32 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_82 - PIXEL31_32 - break; - } - case 59: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL11_0 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } - case 121: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } - case 87: - { - PIXEL00_81 - PIXEL01_31 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_81 - PIXEL11_31 - PIXEL12_0 - PIXEL20_61 - PIXEL21_30 - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 79: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_32 - PIXEL03_82 - PIXEL11_0 - PIXEL12_32 - PIXEL13_82 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 122: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } - case 94: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL12_0 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } - case 218: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - break; - } - case 91: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL11_0 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } - case 229: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } - case 167: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } - case 173: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } - case 181: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; - } - case 186: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } - case 115: - { - PIXEL00_81 - PIXEL01_31 - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_82 - PIXEL21_32 - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - PIXEL30_82 - PIXEL31_32 - break; - } - case 93: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } - case 206: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - PIXEL02_32 - PIXEL03_82 - PIXEL12_32 - PIXEL13_82 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_31 - PIXEL23_81 - PIXEL32_31 - PIXEL33_81 - break; - } - case 205: - case 201: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_31 - PIXEL23_81 - PIXEL32_31 - PIXEL33_81 - break; - } - case 174: - case 46: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - PIXEL02_32 - PIXEL03_82 - PIXEL12_32 - PIXEL13_82 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } - case 179: - case 147: - { - PIXEL00_81 - PIXEL01_31 - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; - } - case 117: - case 116: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_82 - PIXEL21_32 - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - PIXEL30_82 - PIXEL31_32 - break; - } - case 189: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } - case 231: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } - case 126: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 219: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 125: - { - if (Diff(w[8], w[4])) - { - PIXEL00_82 - PIXEL10_32 - PIXEL20_0 - PIXEL21_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL00_11 - PIXEL10_13 - PIXEL20_83 - PIXEL21_70 - PIXEL30_50 - PIXEL31_21 - } - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 221: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - if (Diff(w[6], w[8])) - { - PIXEL03_81 - PIXEL13_31 - PIXEL22_0 - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL03_12 - PIXEL13_14 - PIXEL22_70 - PIXEL23_83 - PIXEL32_21 - PIXEL33_50 - } - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - break; - } - case 207: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL02_32 - PIXEL03_82 - PIXEL10_0 - PIXEL11_0 - } - else - { - PIXEL00_50 - PIXEL01_83 - PIXEL02_13 - PIXEL03_11 - PIXEL10_21 - PIXEL11_70 - } - PIXEL12_32 - PIXEL13_82 - PIXEL20_10 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } - case 238: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_10 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL21_0 - PIXEL30_0 - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - } - else - { - PIXEL20_21 - PIXEL21_70 - PIXEL30_50 - PIXEL31_83 - PIXEL32_14 - PIXEL33_12 - } - PIXEL22_31 - PIXEL23_81 - break; - } - case 190: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL12_0 - PIXEL13_0 - PIXEL23_32 - PIXEL33_82 - } - else - { - PIXEL02_21 - PIXEL03_50 - PIXEL12_70 - PIXEL13_83 - PIXEL23_13 - PIXEL33_11 - } - PIXEL10_10 - PIXEL11_30 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - break; - } - case 187: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - PIXEL11_0 - PIXEL20_31 - PIXEL30_81 - } - else - { - PIXEL00_50 - PIXEL01_21 - PIXEL10_83 - PIXEL11_70 - PIXEL20_14 - PIXEL30_12 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } - case 243: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_10 - PIXEL20_82 - PIXEL21_32 - if (Diff(w[6], w[8])) - { - PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL22_70 - PIXEL23_21 - PIXEL30_11 - PIXEL31_13 - PIXEL32_83 - PIXEL33_50 - } - break; - } - case 119: - { - if (Diff(w[2], w[6])) - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_0 - PIXEL03_0 - PIXEL12_0 - PIXEL13_0 - } - else - { - PIXEL00_12 - PIXEL01_14 - PIXEL02_83 - PIXEL03_50 - PIXEL12_70 - PIXEL13_21 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_10 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } - case 237: - case 233: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL20_0 - PIXEL21_0 - PIXEL22_31 - PIXEL23_81 - if (Diff(w[8], w[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - break; - } - case 175: - case 47: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_32 - PIXEL03_82 - PIXEL10_0 - PIXEL11_0 - PIXEL12_32 - PIXEL13_82 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } - case 183: - case 151: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_0 - if (Diff(w[2], w[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL10_81 - PIXEL11_31 - PIXEL12_0 - PIXEL13_0 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; - } - case 245: - case 244: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_82 - PIXEL21_32 - PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - if (Diff(w[6], w[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; - } - case 250: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - break; - } - case 123: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 95: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL11_0 - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 222: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 252: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_0 - PIXEL23_0 - PIXEL32_0 - if (Diff(w[6], w[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; - } - case 249: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_0 - PIXEL21_0 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - if (Diff(w[8], w[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - break; - } - case 235: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - PIXEL20_0 - PIXEL21_0 - PIXEL22_31 - PIXEL23_81 - if (Diff(w[8], w[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - break; - } - case 111: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_32 - PIXEL03_82 - PIXEL10_0 - PIXEL11_0 - PIXEL12_32 - PIXEL13_82 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 63: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_0 - PIXEL11_0 - PIXEL12_0 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } - case 159: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_0 - if (Diff(w[2], w[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL11_0 - PIXEL12_0 - PIXEL13_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 215: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_0 - if (Diff(w[2], w[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL10_81 - PIXEL11_31 - PIXEL12_0 - PIXEL13_0 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 246: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_82 - PIXEL21_32 - PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - if (Diff(w[6], w[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; - } - case 254: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_0 - PIXEL23_0 - PIXEL32_0 - if (Diff(w[6], w[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; - } - case 253: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_0 - PIXEL21_0 - PIXEL22_0 - PIXEL23_0 - if (Diff(w[8], w[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - PIXEL32_0 - if (Diff(w[6], w[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; - } - case 251: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - PIXEL20_0 - PIXEL21_0 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - if (Diff(w[8], w[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - break; - } - case 239: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_32 - PIXEL03_82 - PIXEL10_0 - PIXEL11_0 - PIXEL12_32 - PIXEL13_82 - PIXEL20_0 - PIXEL21_0 - PIXEL22_31 - PIXEL23_81 - if (Diff(w[8], w[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - break; - } - case 127: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_0 - PIXEL11_0 - PIXEL12_0 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 191: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_0 - if (Diff(w[2], w[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL10_0 - PIXEL11_0 - PIXEL12_0 - PIXEL13_0 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } - case 223: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_0 - if (Diff(w[2], w[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL11_0 - PIXEL12_0 - PIXEL13_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 247: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_0 - if (Diff(w[2], w[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL10_81 - PIXEL11_31 - PIXEL12_0 - PIXEL13_0 - PIXEL20_82 - PIXEL21_32 - PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - if (Diff(w[6], w[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; - } - case 255: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_0 - if (Diff(w[2], w[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL10_0 - PIXEL11_0 - PIXEL12_0 - PIXEL13_0 - PIXEL20_0 - PIXEL21_0 - PIXEL22_0 - PIXEL23_0 - if (Diff(w[8], w[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - PIXEL32_0 - if (Diff(w[6], w[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; - } - } - pIn++; // next source pixel (just increment since it's an int*) - pOut += 16; // skip 4 pixels (4 bytes * 4 pixels) - } - pOut += BpL; // skip next 3 rows - pOut += BpL; - pOut += BpL; - } - __asm emms -} - -void DLL InitLUTs() -{ - int i, j, k, r, g, b, Y, u, v; - -#if 0 // colorOutlines() after hqresize - for (i=0; i<65536; i++) - LUT16to32[i] = 0x00404040; - for (i=0; i<65536; i++) - LUT16to32[i+65536] = 0xFF000000 + ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3); -#else // colorOutlines() before hqresize - for (i=0; i<65536; i++) - LUT16to32[i] = ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3); - for (i=0; i<65536; i++) - LUT16to32[i+65536] = 0xFF000000 + LUT16to32[i]; -#endif - - for (i=0; i<65536; i++) - RGBtoYUV[i] = 0xFF000000; - - for (i=0; i<32; i++) - for (j=0; j<64; j++) - for (k=0; k<32; k++) - { - r = i << 3; - g = j << 2; - b = k << 3; - Y = (r + g + b) >> 2; - u = 128 + ((r - b) >> 2); - v = 128 + ((-r + 2*g -b)>>3); - RGBtoYUV[ 65536 + (i << 11) + (j << 5) + k ] = (Y<<16) + (u<<8) + v; - } -} - /* -int DLL hq4x_32 ( CImage &ImageIn, CImage &ImageOut ) + * Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com ) + * + * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include "common.h" +#include "hqx.h" + +#define PIXEL00_0 *dp = w[5]; +#define PIXEL00_11 *dp = Interp1(w[5], w[4]); +#define PIXEL00_12 *dp = Interp1(w[5], w[2]); +#define PIXEL00_20 *dp = Interp2(w[5], w[2], w[4]); +#define PIXEL00_50 *dp = Interp5(w[2], w[4]); +#define PIXEL00_80 *dp = Interp8(w[5], w[1]); +#define PIXEL00_81 *dp = Interp8(w[5], w[4]); +#define PIXEL00_82 *dp = Interp8(w[5], w[2]); +#define PIXEL01_0 *(dp+1) = w[5]; +#define PIXEL01_10 *(dp+1) = Interp1(w[5], w[1]); +#define PIXEL01_12 *(dp+1) = Interp1(w[5], w[2]); +#define PIXEL01_14 *(dp+1) = Interp1(w[2], w[5]); +#define PIXEL01_21 *(dp+1) = Interp2(w[2], w[5], w[4]); +#define PIXEL01_31 *(dp+1) = Interp3(w[5], w[4]); +#define PIXEL01_50 *(dp+1) = Interp5(w[2], w[5]); +#define PIXEL01_60 *(dp+1) = Interp6(w[5], w[2], w[4]); +#define PIXEL01_61 *(dp+1) = Interp6(w[5], w[2], w[1]); +#define PIXEL01_82 *(dp+1) = Interp8(w[5], w[2]); +#define PIXEL01_83 *(dp+1) = Interp8(w[2], w[4]); +#define PIXEL02_0 *(dp+2) = w[5]; +#define PIXEL02_10 *(dp+2) = Interp1(w[5], w[3]); +#define PIXEL02_11 *(dp+2) = Interp1(w[5], w[2]); +#define PIXEL02_13 *(dp+2) = Interp1(w[2], w[5]); +#define PIXEL02_21 *(dp+2) = Interp2(w[2], w[5], w[6]); +#define PIXEL02_32 *(dp+2) = Interp3(w[5], w[6]); +#define PIXEL02_50 *(dp+2) = Interp5(w[2], w[5]); +#define PIXEL02_60 *(dp+2) = Interp6(w[5], w[2], w[6]); +#define PIXEL02_61 *(dp+2) = Interp6(w[5], w[2], w[3]); +#define PIXEL02_81 *(dp+2) = Interp8(w[5], w[2]); +#define PIXEL02_83 *(dp+2) = Interp8(w[2], w[6]); +#define PIXEL03_0 *(dp+3) = w[5]; +#define PIXEL03_11 *(dp+3) = Interp1(w[5], w[2]); +#define PIXEL03_12 *(dp+3) = Interp1(w[5], w[6]); +#define PIXEL03_20 *(dp+3) = Interp2(w[5], w[2], w[6]); +#define PIXEL03_50 *(dp+3) = Interp5(w[2], w[6]); +#define PIXEL03_80 *(dp+3) = Interp8(w[5], w[3]); +#define PIXEL03_81 *(dp+3) = Interp8(w[5], w[2]); +#define PIXEL03_82 *(dp+3) = Interp8(w[5], w[6]); +#define PIXEL10_0 *(dp+dpL) = w[5]; +#define PIXEL10_10 *(dp+dpL) = Interp1(w[5], w[1]); +#define PIXEL10_11 *(dp+dpL) = Interp1(w[5], w[4]); +#define PIXEL10_13 *(dp+dpL) = Interp1(w[4], w[5]); +#define PIXEL10_21 *(dp+dpL) = Interp2(w[4], w[5], w[2]); +#define PIXEL10_32 *(dp+dpL) = Interp3(w[5], w[2]); +#define PIXEL10_50 *(dp+dpL) = Interp5(w[4], w[5]); +#define PIXEL10_60 *(dp+dpL) = Interp6(w[5], w[4], w[2]); +#define PIXEL10_61 *(dp+dpL) = Interp6(w[5], w[4], w[1]); +#define PIXEL10_81 *(dp+dpL) = Interp8(w[5], w[4]); +#define PIXEL10_83 *(dp+dpL) = Interp8(w[4], w[2]); +#define PIXEL11_0 *(dp+dpL+1) = w[5]; +#define PIXEL11_30 *(dp+dpL+1) = Interp3(w[5], w[1]); +#define PIXEL11_31 *(dp+dpL+1) = Interp3(w[5], w[4]); +#define PIXEL11_32 *(dp+dpL+1) = Interp3(w[5], w[2]); +#define PIXEL11_70 *(dp+dpL+1) = Interp7(w[5], w[4], w[2]); +#define PIXEL12_0 *(dp+dpL+2) = w[5]; +#define PIXEL12_30 *(dp+dpL+2) = Interp3(w[5], w[3]); +#define PIXEL12_31 *(dp+dpL+2) = Interp3(w[5], w[2]); +#define PIXEL12_32 *(dp+dpL+2) = Interp3(w[5], w[6]); +#define PIXEL12_70 *(dp+dpL+2) = Interp7(w[5], w[6], w[2]); +#define PIXEL13_0 *(dp+dpL+3) = w[5]; +#define PIXEL13_10 *(dp+dpL+3) = Interp1(w[5], w[3]); +#define PIXEL13_12 *(dp+dpL+3) = Interp1(w[5], w[6]); +#define PIXEL13_14 *(dp+dpL+3) = Interp1(w[6], w[5]); +#define PIXEL13_21 *(dp+dpL+3) = Interp2(w[6], w[5], w[2]); +#define PIXEL13_31 *(dp+dpL+3) = Interp3(w[5], w[2]); +#define PIXEL13_50 *(dp+dpL+3) = Interp5(w[6], w[5]); +#define PIXEL13_60 *(dp+dpL+3) = Interp6(w[5], w[6], w[2]); +#define PIXEL13_61 *(dp+dpL+3) = Interp6(w[5], w[6], w[3]); +#define PIXEL13_82 *(dp+dpL+3) = Interp8(w[5], w[6]); +#define PIXEL13_83 *(dp+dpL+3) = Interp8(w[6], w[2]); +#define PIXEL20_0 *(dp+dpL+dpL) = w[5]; +#define PIXEL20_10 *(dp+dpL+dpL) = Interp1(w[5], w[7]); +#define PIXEL20_12 *(dp+dpL+dpL) = Interp1(w[5], w[4]); +#define PIXEL20_14 *(dp+dpL+dpL) = Interp1(w[4], w[5]); +#define PIXEL20_21 *(dp+dpL+dpL) = Interp2(w[4], w[5], w[8]); +#define PIXEL20_31 *(dp+dpL+dpL) = Interp3(w[5], w[8]); +#define PIXEL20_50 *(dp+dpL+dpL) = Interp5(w[4], w[5]); +#define PIXEL20_60 *(dp+dpL+dpL) = Interp6(w[5], w[4], w[8]); +#define PIXEL20_61 *(dp+dpL+dpL) = Interp6(w[5], w[4], w[7]); +#define PIXEL20_82 *(dp+dpL+dpL) = Interp8(w[5], w[4]); +#define PIXEL20_83 *(dp+dpL+dpL) = Interp8(w[4], w[8]); +#define PIXEL21_0 *(dp+dpL+dpL+1) = w[5]; +#define PIXEL21_30 *(dp+dpL+dpL+1) = Interp3(w[5], w[7]); +#define PIXEL21_31 *(dp+dpL+dpL+1) = Interp3(w[5], w[8]); +#define PIXEL21_32 *(dp+dpL+dpL+1) = Interp3(w[5], w[4]); +#define PIXEL21_70 *(dp+dpL+dpL+1) = Interp7(w[5], w[4], w[8]); +#define PIXEL22_0 *(dp+dpL+dpL+2) = w[5]; +#define PIXEL22_30 *(dp+dpL+dpL+2) = Interp3(w[5], w[9]); +#define PIXEL22_31 *(dp+dpL+dpL+2) = Interp3(w[5], w[6]); +#define PIXEL22_32 *(dp+dpL+dpL+2) = Interp3(w[5], w[8]); +#define PIXEL22_70 *(dp+dpL+dpL+2) = Interp7(w[5], w[6], w[8]); +#define PIXEL23_0 *(dp+dpL+dpL+3) = w[5]; +#define PIXEL23_10 *(dp+dpL+dpL+3) = Interp1(w[5], w[9]); +#define PIXEL23_11 *(dp+dpL+dpL+3) = Interp1(w[5], w[6]); +#define PIXEL23_13 *(dp+dpL+dpL+3) = Interp1(w[6], w[5]); +#define PIXEL23_21 *(dp+dpL+dpL+3) = Interp2(w[6], w[5], w[8]); +#define PIXEL23_32 *(dp+dpL+dpL+3) = Interp3(w[5], w[8]); +#define PIXEL23_50 *(dp+dpL+dpL+3) = Interp5(w[6], w[5]); +#define PIXEL23_60 *(dp+dpL+dpL+3) = Interp6(w[5], w[6], w[8]); +#define PIXEL23_61 *(dp+dpL+dpL+3) = Interp6(w[5], w[6], w[9]); +#define PIXEL23_81 *(dp+dpL+dpL+3) = Interp8(w[5], w[6]); +#define PIXEL23_83 *(dp+dpL+dpL+3) = Interp8(w[6], w[8]); +#define PIXEL30_0 *(dp+dpL+dpL+dpL) = w[5]; +#define PIXEL30_11 *(dp+dpL+dpL+dpL) = Interp1(w[5], w[8]); +#define PIXEL30_12 *(dp+dpL+dpL+dpL) = Interp1(w[5], w[4]); +#define PIXEL30_20 *(dp+dpL+dpL+dpL) = Interp2(w[5], w[8], w[4]); +#define PIXEL30_50 *(dp+dpL+dpL+dpL) = Interp5(w[8], w[4]); +#define PIXEL30_80 *(dp+dpL+dpL+dpL) = Interp8(w[5], w[7]); +#define PIXEL30_81 *(dp+dpL+dpL+dpL) = Interp8(w[5], w[8]); +#define PIXEL30_82 *(dp+dpL+dpL+dpL) = Interp8(w[5], w[4]); +#define PIXEL31_0 *(dp+dpL+dpL+dpL+1) = w[5]; +#define PIXEL31_10 *(dp+dpL+dpL+dpL+1) = Interp1(w[5], w[7]); +#define PIXEL31_11 *(dp+dpL+dpL+dpL+1) = Interp1(w[5], w[8]); +#define PIXEL31_13 *(dp+dpL+dpL+dpL+1) = Interp1(w[8], w[5]); +#define PIXEL31_21 *(dp+dpL+dpL+dpL+1) = Interp2(w[8], w[5], w[4]); +#define PIXEL31_32 *(dp+dpL+dpL+dpL+1) = Interp3(w[5], w[4]); +#define PIXEL31_50 *(dp+dpL+dpL+dpL+1) = Interp5(w[8], w[5]); +#define PIXEL31_60 *(dp+dpL+dpL+dpL+1) = Interp6(w[5], w[8], w[4]); +#define PIXEL31_61 *(dp+dpL+dpL+dpL+1) = Interp6(w[5], w[8], w[7]); +#define PIXEL31_81 *(dp+dpL+dpL+dpL+1) = Interp8(w[5], w[8]); +#define PIXEL31_83 *(dp+dpL+dpL+dpL+1) = Interp8(w[8], w[4]); +#define PIXEL32_0 *(dp+dpL+dpL+dpL+2) = w[5]; +#define PIXEL32_10 *(dp+dpL+dpL+dpL+2) = Interp1(w[5], w[9]); +#define PIXEL32_12 *(dp+dpL+dpL+dpL+2) = Interp1(w[5], w[8]); +#define PIXEL32_14 *(dp+dpL+dpL+dpL+2) = Interp1(w[8], w[5]); +#define PIXEL32_21 *(dp+dpL+dpL+dpL+2) = Interp2(w[8], w[5], w[6]); +#define PIXEL32_31 *(dp+dpL+dpL+dpL+2) = Interp3(w[5], w[6]); +#define PIXEL32_50 *(dp+dpL+dpL+dpL+2) = Interp5(w[8], w[5]); +#define PIXEL32_60 *(dp+dpL+dpL+dpL+2) = Interp6(w[5], w[8], w[6]); +#define PIXEL32_61 *(dp+dpL+dpL+dpL+2) = Interp6(w[5], w[8], w[9]); +#define PIXEL32_82 *(dp+dpL+dpL+dpL+2) = Interp8(w[5], w[8]); +#define PIXEL32_83 *(dp+dpL+dpL+dpL+2) = Interp8(w[8], w[6]); +#define PIXEL33_0 *(dp+dpL+dpL+dpL+3) = w[5]; +#define PIXEL33_11 *(dp+dpL+dpL+dpL+3) = Interp1(w[5], w[6]); +#define PIXEL33_12 *(dp+dpL+dpL+dpL+3) = Interp1(w[5], w[8]); +#define PIXEL33_20 *(dp+dpL+dpL+dpL+3) = Interp2(w[5], w[8], w[6]); +#define PIXEL33_50 *(dp+dpL+dpL+dpL+3) = Interp5(w[8], w[6]); +#define PIXEL33_80 *(dp+dpL+dpL+dpL+3) = Interp8(w[5], w[9]); +#define PIXEL33_81 *(dp+dpL+dpL+dpL+3) = Interp8(w[5], w[6]); +#define PIXEL33_82 *(dp+dpL+dpL+dpL+3) = Interp8(w[5], w[8]); + +HQX_API void HQX_CALLCONV hq4x_32_rb( uint32_t * sp, uint32_t srb, uint32_t * dp, uint32_t drb, int Xres, int Yres ) { - if ( ImageIn.Convert32To17() != 0 ) - { - printf( "ERROR: conversion to 17 bit failed\n" ); - return 1; - } + int i, j, k; + int prevline, nextline; + uint32_t w[10]; + int dpL = (drb >> 2); + int spL = (srb >> 2); + uint8_t *sRowP = (uint8_t *) sp; + uint8_t *dRowP = (uint8_t *) dp; + uint32_t yuv1, yuv2; - if ( ImageOut.Init( ImageIn.m_Xres*4, ImageIn.m_Yres*4, 32 ) != 0 ) - { - printf( "ERROR: ImageOut.Init()\n" ); - return 1; - }; + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ - InitLUTs(); - hq4x_32( (int*)ImageIn.m_pBitmap, ImageOut.m_pBitmap, ImageIn.m_Xres, ImageIn.m_Yres, ImageOut.m_Xres*4 ); + for (j=0; j0) prevline = -spL; else prevline = 0; + if (j0) + { + w[1] = *(sp + prevline - 1); + w[4] = *(sp - 1); + w[7] = *(sp + nextline - 1); + } + else + { + w[1] = w[2]; + w[4] = w[5]; + w[7] = w[8]; + } + + if (i + +#if defined( __GNUC__ ) + #ifdef __MINGW32__ + #define HQX_CALLCONV __stdcall + #else + #define HQX_CALLCONV + #endif +#else + #define HQX_CALLCONV +#endif + +#if defined(_WIN32) + #ifdef DLL_EXPORT + #define HQX_API __declspec(dllexport) + #else + #define HQX_API __declspec(dllimport) + #endif +#else + #define HQX_API +#endif + +HQX_API void HQX_CALLCONV hqxInit(void); +HQX_API void HQX_CALLCONV hq2x_32( uint32_t * src, uint32_t * dest, int width, int height ); +HQX_API void HQX_CALLCONV hq3x_32( uint32_t * src, uint32_t * dest, int width, int height ); +HQX_API void HQX_CALLCONV hq4x_32( uint32_t * src, uint32_t * dest, int width, int height ); + +HQX_API void HQX_CALLCONV hq2x_32_rb( uint32_t * src, uint32_t src_rowBytes, uint32_t * dest, uint32_t dest_rowBytes, int width, int height ); +HQX_API void HQX_CALLCONV hq3x_32_rb( uint32_t * src, uint32_t src_rowBytes, uint32_t * dest, uint32_t dest_rowBytes, int width, int height ); +HQX_API void HQX_CALLCONV hq4x_32_rb( uint32_t * src, uint32_t src_rowBytes, uint32_t * dest, uint32_t dest_rowBytes, int width, int height ); + +#endif diff --git a/src/gl/hqnx/init.cpp b/src/gl/hqnx/init.cpp new file mode 100644 index 000000000..217358165 --- /dev/null +++ b/src/gl/hqnx/init.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include "hqx.h" + +uint32_t RGBtoYUV[16777216]; +uint32_t YUV1, YUV2; + +HQX_API void HQX_CALLCONV hqxInit(void) +{ + /* Initalize RGB to YUV lookup table */ + uint32_t c, r, g, b, y, u, v; + for (c = 0; c < 16777215; c++) { + r = (c & 0xFF0000) >> 16; + g = (c & 0x00FF00) >> 8; + b = c & 0x0000FF; + y = (uint32_t)(0.299*r + 0.587*g + 0.114*b); + u = (uint32_t)(-0.169*r - 0.331*g + 0.5*b) + 128; + v = (uint32_t)(0.5*r - 0.419*g - 0.081*b) + 128; + RGBtoYUV[c] = (y << 16) + (u << 8) + v; + } +} diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index eae5d7a7e..75436209c 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -59,21 +59,6 @@ CUSTOM_CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // when they are actually valid. void gl_SetupMenu() { -#ifndef _MSC_VER - FOptionValues **opt = OptionValues.CheckKey("HqResizeModes"); - if (opt != NULL) - { - for(int i = (*opt)->mValues.Size()-1; i>=0; i--) - { - // Delete HQnX resize modes for non MSVC targets - if ((*opt)->mValues[i].Value >= 4.0) - { - (*opt)->mValues.Delete(i); - } - } - } -#endif - if (gl.shadermodel < 4) { // Radial fog and Doom lighting are not available in SM < 4 cards diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 9145ac3f1..2c5f831f1 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -39,18 +39,11 @@ #include "gl/renderer/gl_renderer.h" #include "gl/textures/gl_texture.h" #include "c_cvars.h" -// [BB] hqnx scaling is only supported with the MS compiler. -#if (defined _MSC_VER) && (!defined _WIN64) -#include "gl/hqnx/hqnx.h" -#endif +#include "gl/hqnx/hqx.h" CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { -#ifdef _MSC_VER if (self < 0 || self > 6) -#else - if (self < 0 || self > 3) -#endif self = 0; GLRenderer->FlushTextures(); } @@ -186,9 +179,7 @@ static unsigned char *scaleNxHelper( void (*scaleNxFunction) ( uint32* , uint32* return newBuffer; } -// [BB] hqnx scaling is only supported with the MS compiler. -#if (defined _MSC_VER) && (!defined _WIN64) -static unsigned char *hqNxHelper( void (*hqNxFunction) ( int*, unsigned char*, int, int, int ), +static unsigned char *hqNxHelper( void (*hqNxFunction) ( unsigned*, unsigned*, int, int ), const int N, unsigned char *inputBuffer, const int inWidth, @@ -200,22 +191,17 @@ static unsigned char *hqNxHelper( void (*hqNxFunction) ( int*, unsigned char*, i if (!initdone) { - InitLUTs(); + hqxInit(); initdone = true; } outWidth = N * inWidth; outHeight = N *inHeight; - CImage cImageIn; - cImageIn.SetImage(inputBuffer, inWidth, inHeight, 32); - cImageIn.Convert32To17(); - unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; - hqNxFunction( reinterpret_cast(cImageIn.m_pBitmap), newBuffer, cImageIn.m_Xres, cImageIn.m_Yres, outWidth*4 ); + hqNxFunction( reinterpret_cast(inputBuffer), reinterpret_cast(newBuffer), inWidth, inHeight ); delete[] inputBuffer; return newBuffer; } -#endif //=========================================================================== // @@ -263,11 +249,13 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u outWidth = inWidth; outHeight = inHeight; int type = gl_texture_hqresize; +#if 0 // hqNx does not preserve the alpha channel so fall back to ScaleNx for such textures if (hasAlpha && type > 3) { type -= 3; } +#endif switch (type) { @@ -277,15 +265,12 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u return scaleNxHelper( &scale3x, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); case 3: return scaleNxHelper( &scale4x, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); -// [BB] hqnx scaling is only supported with the MS compiler. -#if (defined _MSC_VER) && (!defined _WIN64) case 4: return hqNxHelper( &hq2x_32, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight ); case 5: return hqNxHelper( &hq3x_32, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); case 6: return hqNxHelper( &hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); -#endif } } return inputBuffer; From bf0b85008835451507d71e4d3e83270fff9cd4e7 Mon Sep 17 00:00:00 2001 From: galtgendo Date: Sun, 2 Mar 2014 12:10:34 +0100 Subject: [PATCH 0061/1509] look for gme header in the proper location --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 582e47c69..68c65e70b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,7 +88,7 @@ find_package( BZip2 ) find_package( JPEG ) find_package( ZLIB ) # GME -find_path( GME_INCLUDE_DIR gme.h ) +find_path( GME_INCLUDE_DIR gme/gme.h ) find_library( GME_LIBRARIES gme ) mark_as_advanced( GME_INCLUDE_DIR GME_LIBRARIES ) FIND_PACKAGE_HANDLE_STANDARD_ARGS( GME From 8f97e96af187d44ae095f35511b6b94491668ddf Mon Sep 17 00:00:00 2001 From: galtgendo Date: Sun, 2 Mar 2014 12:11:23 +0100 Subject: [PATCH 0062/1509] silence a noisy warning --- src/gl/renderer/gl_colormap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_colormap.h b/src/gl/renderer/gl_colormap.h index d04e1edda..7c9921108 100644 --- a/src/gl/renderer/gl_colormap.h +++ b/src/gl/renderer/gl_colormap.h @@ -55,7 +55,7 @@ struct FColormap void GetFixedColormap() { Clear(); - colormap = gl_fixedcolormap >= CM_LITE? CM_DEFAULT : gl_fixedcolormap; + colormap = gl_fixedcolormap >= (int)CM_LITE? (int)CM_DEFAULT : gl_fixedcolormap; } FColormap & operator=(FDynamicColormap * from) From 7261af1d9ff3de3d600e8e1815bb19f7e99608e1 Mon Sep 17 00:00:00 2001 From: Gaerzi Date: Wed, 2 Apr 2014 20:23:17 +0200 Subject: [PATCH 0063/1509] Don't define HQX_API to anything on Windows --- src/gl/hqnx/hqx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/hqnx/hqx.h b/src/gl/hqnx/hqx.h index 2eed971e9..089b5a0bc 100644 --- a/src/gl/hqnx/hqx.h +++ b/src/gl/hqnx/hqx.h @@ -33,7 +33,7 @@ #define HQX_CALLCONV #endif -#if defined(_WIN32) +#if 0 //defined(_WIN32) #ifdef DLL_EXPORT #define HQX_API __declspec(dllexport) #else From 0aba6e09f3c53b012e0da38552e42253935aed52 Mon Sep 17 00:00:00 2001 From: Gaerzi Date: Thu, 3 Apr 2014 20:14:38 +0200 Subject: [PATCH 0064/1509] Disambiguate which abs type we want. --- src/gl/hqnx/common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/hqnx/common.h b/src/gl/hqnx/common.h index c2a957713..930604e64 100644 --- a/src/gl/hqnx/common.h +++ b/src/gl/hqnx/common.h @@ -48,9 +48,9 @@ static inline uint32_t rgb_to_yuv(uint32_t c) /* Test if there is difference in color */ static inline int yuv_diff(uint32_t yuv1, uint32_t yuv2) { - return (( abs((yuv1 & Ymask) - (yuv2 & Ymask)) > trY ) || - ( abs((yuv1 & Umask) - (yuv2 & Umask)) > trU ) || - ( abs((yuv1 & Vmask) - (yuv2 & Vmask)) > trV ) ); + return (( abs((int64_t)(yuv1 & Ymask) - (int64_t)(yuv2 & Ymask)) > trY ) || + ( abs((int64_t)(yuv1 & Umask) - (int64_t)(yuv2 & Umask)) > trU ) || + ( abs((int64_t)(yuv1 & Vmask) - (int64_t)(yuv2 & Vmask)) > trV ) ); } static inline int Diff(uint32_t c1, uint32_t c2) From 47406a3406b0048e976edb9d92d69592112ec014 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 3 Apr 2014 23:02:43 +0200 Subject: [PATCH 0065/1509] - I don't think it's a good idea to put a 64 MB lookup table into the static data segment, if it's for a piece of code most people will never use... --- src/gl/hqnx/common.h | 2 +- src/gl/hqnx/init.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gl/hqnx/common.h b/src/gl/hqnx/common.h index 930604e64..c3e700571 100644 --- a/src/gl/hqnx/common.h +++ b/src/gl/hqnx/common.h @@ -38,7 +38,7 @@ #define trV 0x00000006 /* RGB to YUV lookup table */ -extern uint32_t RGBtoYUV[16777216]; +extern uint32_t *RGBtoYUV; static inline uint32_t rgb_to_yuv(uint32_t c) { diff --git a/src/gl/hqnx/init.cpp b/src/gl/hqnx/init.cpp index 217358165..a3d97ba88 100644 --- a/src/gl/hqnx/init.cpp +++ b/src/gl/hqnx/init.cpp @@ -19,13 +19,14 @@ #include #include "hqx.h" -uint32_t RGBtoYUV[16777216]; +uint32_t *RGBtoYUV; uint32_t YUV1, YUV2; HQX_API void HQX_CALLCONV hqxInit(void) { /* Initalize RGB to YUV lookup table */ uint32_t c, r, g, b, y, u, v; + RGBtoYUV = new uint32_t[16777216]; for (c = 0; c < 16777215; c++) { r = (c & 0xFF0000) >> 16; g = (c & 0x00FF00) >> 8; From 69af73d9b98b1f8b8f0a4b81a0c5f3dcad448f40 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 6 Apr 2014 14:35:44 +0200 Subject: [PATCH 0066/1509] - alternative configuration using GLEW to get extension functions. This requires GL 2.0, though so it won't be promoted to the mainline for the time being. - removed all pre GL 2.0 support. --- src/CMakeLists.txt | 44 +++++----- src/gl/api/gl_api.h | 3 + src/gl/data/gl_vertexbuffer.cpp | 18 +--- src/gl/models/gl_voxels.cpp | 57 ++++++------ src/gl/scene/gl_portal.cpp | 40 ++++----- src/gl/scene/gl_scene.cpp | 27 +++++- src/gl/scene/gl_sprite.cpp | 38 ++------ src/gl/shaders/gl_shader.cpp | 2 +- src/gl/system/gl_framebuffer.cpp | 13 ++- src/gl/system/gl_interface.cpp | 144 ++----------------------------- src/gl/system/gl_interface.h | 3 - src/gl/system/gl_system.h | 17 ++-- src/gl/textures/gl_hwtexture.cpp | 34 +------- src/gl/textures/gl_material.cpp | 25 +++--- 14 files changed, 137 insertions(+), 328 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 29ade3566..d9fa878e9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -238,6 +238,30 @@ endif( NOT OPENGL_GLU_FOUND ) set( ZDOOM_LIBS ${ZDOOM_LIBS} ${OPENGL_LIBRARIES} ) include_directories( ${OPENGL_INCLUDE_DIR} ) + +# check for GLEW +find_path( GLEW_INCLUDE_DIR GL/glew.h + PATHS "/usr/include" + "/usr/local/include" ) + +if( GLEW_INCLUDE_DIR ) + message( STATUS "GLEW include files found at ${GLEW_INCLUDE_DIR}" ) +else( GLEW_INCLUDE_DIR ) + message( SEND_ERROR "Could not find GLEW include files" ) +endif( GLEW_INCLUDE_DIR ) + +# GLEW include directory +include_directories( "${GLEW_INCLUDE_DIR}" ) + +find_library( GLEW_LIBRARY glew32 ) + +if( NOT GLEW_LIBRARY ) + message( SEND_ERROR "Could not find GLEW library files" ) +endif( NOT GLEW_LIBRARY ) + +set( ZDOOM_LIBS ${ZDOOM_LIBS} ${GLEW_LIBRARY} ) + + # Decide on the name of the FMOD library we want to use. if( NOT FMOD_LIB_NAME AND MSVC ) @@ -395,20 +419,6 @@ if( NOT NO_ASM ) ENDMACRO( ADD_ASM_FILE ) endif( NOT NO_ASM ) -# OpenGL on OS X: Search for GLEW include files - -if( APPLE ) - find_path( GLEW_INCLUDE_DIR GL/glew.h - PATHS "/usr/include" - "/usr/local/include" ) - - if( GLEW_INCLUDE_DIR ) - message( STATUS "GLEW include files found at ${GLEW_INCLUDE_DIR}" ) - else( GLEW_INCLUDE_DIR ) - message( SEND_ERROR "Could not find GLEW include files" ) - endif( GLEW_INCLUDE_DIR ) -endif( APPLE ) - # Decide on SSE setup set( SSE_MATTERS NO ) @@ -565,12 +575,6 @@ else( NOT DYN_FLUIDSYNTH ) set( ZDOOM_LIBS ${ZDOOM_LIBS} ${CMAKE_DL_LIBS} ) endif( NOT DYN_FLUIDSYNTH ) -# OpenGL on OS X: GLEW include directory - -if( APPLE ) - include_directories( "${GLEW_INCLUDE_DIR}" ) -endif( APPLE ) - # Start defining source files for ZDoom set( PLAT_WIN32_SOURCES win32/eaxedit.cpp diff --git a/src/gl/api/gl_api.h b/src/gl/api/gl_api.h index 3ed1a2efd..6c5b96887 100644 --- a/src/gl/api/gl_api.h +++ b/src/gl/api/gl_api.h @@ -7,6 +7,7 @@ #define __EXTERN extern #endif +#if 0 __EXTERN PFNGLBLENDEQUATIONPROC glBlendEquation; // ARB_SHADER_OBJECTS @@ -98,3 +99,5 @@ __EXTERN PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; __EXTERN PFNGLTEXBUFFERARBPROC glTexBufferARB; #undef __EXTERN + +#endif diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 93802f74b..c07b6cea3 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -51,7 +51,7 @@ CUSTOM_CVAR(Int, gl_usevbo, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { - if (self < -1 || self > 2 || !(gl.flags&RFL_VBO)) + if (self < -1 || self > 2) { self = 0; } @@ -75,11 +75,8 @@ CUSTOM_CVAR(Int, gl_usevbo, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCA FVertexBuffer::FVertexBuffer() { vbo_id = 0; - if (gl.flags&RFL_VBO) - { - if (gl_usevbo == -1) gl_usevbo.Callback(); - glGenBuffers(1, &vbo_id); - } + if (gl_usevbo == -1) gl_usevbo.Callback(); + glGenBuffers(1, &vbo_id); } FVertexBuffer::~FVertexBuffer() @@ -99,14 +96,7 @@ FVertexBuffer::~FVertexBuffer() FFlatVertexBuffer::FFlatVertexBuffer() : FVertexBuffer() { - if (!(gl.flags&RFL_VBO)) - { - vbo_arg = 0; - } - else - { - vbo_arg = gl_usevbo; - } + vbo_arg = gl_usevbo; map = NULL; } diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 85b46185b..f47685216 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -232,29 +232,26 @@ public: FVoxelVertexBuffer::FVoxelVertexBuffer(TArray &verts, TArray &indices) { ibo_id = 0; - if (gl.flags&RFL_VBO) - { - glGenBuffers(1, &ibo_id); + glGenBuffers(1, &ibo_id); - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBufferData(GL_ARRAY_BUFFER, verts.Size() * sizeof(FVoxelVertex), &verts[0], GL_STATIC_DRAW); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); - if (verts.Size() > 65535) + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferData(GL_ARRAY_BUFFER, verts.Size() * sizeof(FVoxelVertex), &verts[0], GL_STATIC_DRAW); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); + if (verts.Size() > 65535) + { + glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.Size() * sizeof(unsigned int), &indices[0], GL_STATIC_DRAW); + isint = true; + } + else + { + unsigned short *sbuffer = new unsigned short[indices.Size()]; + for(unsigned i=0;iBind(cm, 0, translation); gl_RenderState.Apply(); - if (gl.flags&RFL_VBO) + if (mVBO == NULL) MakeGLData(); + if (mVBO != NULL) { - if (mVBO == NULL) MakeGLData(); - if (mVBO != NULL) - { - mVBO->BindVBO(); - glDrawElements(GL_QUADS, mIndices.Size(), mVBO->IsInt()? GL_UNSIGNED_INT:GL_UNSIGNED_SHORT, 0); - GLRenderer->mVBO->BindVBO(); - return; - } + mVBO->BindVBO(); + glDrawElements(GL_QUADS, mIndices.Size(), mVBO->IsInt()? GL_UNSIGNED_INT:GL_UNSIGNED_SHORT, 0); + GLRenderer->mVBO->BindVBO(); + return; } glBegin(GL_QUADS); diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 31b6149d2..ee0d494a4 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -198,23 +198,16 @@ bool GLPortal::Start(bool usestencil, bool doquery) else if (gl_noquery) doquery = false; // If occlusion query is supported let's use it to avoid rendering portals that aren't visible - if (doquery && gl.flags&RFL_OCCLUSION_QUERY) + if (!QueryObject) glGenQueries(1, &QueryObject); + if (QueryObject) { - if (!QueryObject) glGenQueries(1, &QueryObject); - if (QueryObject) - { - glBeginQuery(GL_SAMPLES_PASSED_ARB, QueryObject); - } - else doquery = false; // some kind of error happened - + glBeginQuery(GL_SAMPLES_PASSED_ARB, QueryObject); } + else doquery = false; // some kind of error happened DrawPortalStencil(); - if (doquery && gl.flags&RFL_OCCLUSION_QUERY) - { - glEndQuery(GL_SAMPLES_PASSED_ARB); - } + glEndQuery(GL_SAMPLES_PASSED_ARB); // Clear Z-buffer glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil @@ -230,20 +223,17 @@ bool GLPortal::Start(bool usestencil, bool doquery) glColorMask(1,1,1,1); glDepthRange(0,1); - if (doquery && gl.flags&RFL_OCCLUSION_QUERY) + GLuint sampleCount; + + glGetQueryObjectuiv(QueryObject, GL_QUERY_RESULT_ARB, &sampleCount); + + if (sampleCount==0) // not visible { - GLuint sampleCount; - - glGetQueryObjectuiv(QueryObject, GL_QUERY_RESULT_ARB, &sampleCount); - - if (sampleCount==0) // not visible - { - // restore default stencil op. - glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); - glStencilFunc(GL_EQUAL,recursion,~0); // draw sky into stencil - PortalAll.Unclock(); - return false; - } + // restore default stencil op. + glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); + glStencilFunc(GL_EQUAL,recursion,~0); // draw sky into stencil + PortalAll.Unclock(); + return false; } FDrawInfo::StartDrawInfo(); } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 6434e848a..513abaa57 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -247,13 +247,36 @@ void FGLRenderer::SetCameraPos(fixed_t viewx, fixed_t viewy, fixed_t viewz, angl // //----------------------------------------------------------------------------- +static void setPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar) +{ + GLdouble m[4][4]; + double sine, cotangent, deltaZ; + double radians = fovy / 2 * M_PI / 180; + + deltaZ = zFar - zNear; + sine = sin(radians); + if ((deltaZ == 0) || (sine == 0) || (aspect == 0)) { + return; + } + cotangent = cos(radians) / sine; + + memset(m, 0, sizeof(m)); + m[0][0] = cotangent / aspect; + m[1][1] = cotangent; + m[2][2] = -(zFar + zNear) / deltaZ; + m[2][3] = -1; + m[3][2] = -2 * zNear * zFar / deltaZ; + m[3][3] = 0; + glLoadMatrixd(&m[0][0]); +} + + void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) { glMatrixMode(GL_PROJECTION); - glLoadIdentity(); float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovratio)); - gluPerspective(fovy, ratio, 5.f, 65536.f); + setPerspective(fovy, ratio, 5.f, 65536.f); gl_RenderState.Set2DMode(false); } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index b7a48852c..63efb978e 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -584,39 +584,19 @@ void GLSprite::Process(AActor* thing,sector_t * sector) gltexture=FMaterial::ValidateTexture(patch, false); if (!gltexture) return; - if (gl.flags & RFL_NPOT_TEXTURE) // trimming only works if non-power-of-2 textures are supported + vt = gltexture->GetSpriteVT(); + vb = gltexture->GetSpriteVB(); + gltexture->GetRect(&r, GLUSE_SPRITE); + if (mirror) { - vt = gltexture->GetSpriteVT(); - vb = gltexture->GetSpriteVB(); - gltexture->GetRect(&r, GLUSE_SPRITE); - if (mirror) - { - r.left=-r.width-r.left; // mirror the sprite's x-offset - ul = gltexture->GetSpriteUL(); - ur = gltexture->GetSpriteUR(); - } - else - { - ul = gltexture->GetSpriteUR(); - ur = gltexture->GetSpriteUL(); - } + r.left=-r.width-r.left; // mirror the sprite's x-offset + ul = gltexture->GetSpriteUL(); + ur = gltexture->GetSpriteUR(); } else { - vt = gltexture->GetVT(); - vb = gltexture->GetVB(); - gltexture->GetRect(&r, GLUSE_PATCH); - if (mirror) - { - r.left=-r.width-r.left; // mirror the sprite's x-offset - ul = gltexture->GetUL(); - ur = gltexture->GetUR(); - } - else - { - ul = gltexture->GetUR(); - ur = gltexture->GetUL(); - } + ul = gltexture->GetSpriteUR(); + ur = gltexture->GetSpriteUL(); } r.Scale(FIXED2FLOAT(spritescaleX),FIXED2FLOAT(spritescaleY)); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 23474fc7d..241c5097f 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -164,7 +164,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * error << "Linking:\n" << buffer << "\n"; } int linked; - glGetObjectParameteriv(hShader, GL_LINK_STATUS, &linked); + glGetShaderiv(hShader, GL_LINK_STATUS, &linked); if (linked == 0) { // only print message if there's an error. diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index b68f5eeb2..99e9bd9a4 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -118,6 +118,11 @@ void OpenGLFrameBuffer::InitializeState() { static bool first=true; + if (first) + { + glewInit(); + } + gl_LoadExtensions(); Super::InitializeState(); if (first) @@ -128,14 +133,6 @@ void OpenGLFrameBuffer::InitializeState() gl_PrintStartupLog(); #endif - if (gl.flags&RFL_NPOT_TEXTURE) - { - Printf("Support for non power 2 textures enabled.\n"); - } - if (gl.flags&RFL_OCCLUSION_QUERY) - { - Printf("Occlusion query enabled.\n"); - } } glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index a9fea02aa..2d311f0bb 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -126,7 +126,6 @@ static bool CheckExtension(const char *ext) static void InitContext() { gl.flags=0; - glBlendEquation = glBlendEquationDummy; } //========================================================================== @@ -143,15 +142,9 @@ void gl_LoadExtensions() const char *version = (const char*)glGetString(GL_VERSION); // Don't even start if it's lower than 1.3 - if (strcmp(version, "1.3") < 0) + if (strcmp(version, "2.0") < 0) { - I_FatalError("Unsupported OpenGL version.\nAt least GL 1.3 is required to run " GAMENAME ".\n"); - } - else if (strcmp(version, "1.4") < 0) - { - // The engine will still assume 1.4 but the only 1.4 feature being used is GL_GENERATE_MIPMAP which should be supported as an extension - // on most 1.3 cards this is present but let's print a warning that not everything may work as intended. - Printf(TEXTCOLOR_RED "The current graphics driver implements a OpenGL version lower than 1.4 and may not support all features " GAMENAME " requires.\n"); + I_FatalError("Unsupported OpenGL version.\nAt least GL 2.0 is required to run " GAMENAME ".\n"); } // This loads any function pointers and flags that require a vaild render context to @@ -160,14 +153,6 @@ void gl_LoadExtensions() gl.shadermodel = 0; // assume no shader support gl.vendorstring=(char*)glGetString(GL_VENDOR); - // First try the regular function - glBlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation"); - // If that fails try the EXT version - if (!glBlendEquation) glBlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquationEXT"); - // If that fails use a no-op dummy - if (!glBlendEquation) glBlendEquation = glBlendEquationDummy; - - if (CheckExtension("GL_ARB_texture_non_power_of_two")) gl.flags|=RFL_NPOT_TEXTURE; if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; if (strstr(gl.vendorstring, "NVIDIA")) gl.flags|=RFL_NVIDIA; @@ -182,65 +167,6 @@ void gl_LoadExtensions() if (gl.flags & RFL_GL_20) { - glDeleteShader = (PFNGLDELETESHADERPROC)myGetProcAddress("glDeleteShader"); - glDeleteProgram = (PFNGLDELETEPROGRAMPROC)myGetProcAddress("glDeleteProgram"); - glDetachShader = (PFNGLDETACHSHADERPROC)myGetProcAddress("glDetachShader"); - glCreateShader = (PFNGLCREATESHADERPROC)myGetProcAddress("glCreateShader"); - glShaderSource = (PFNGLSHADERSOURCEPROC)myGetProcAddress("glShaderSource"); - glCompileShader = (PFNGLCOMPILESHADERPROC)myGetProcAddress("glCompileShader"); - glCreateProgram = (PFNGLCREATEPROGRAMPROC)myGetProcAddress("glCreateProgram"); - glAttachShader = (PFNGLATTACHSHADERPROC)myGetProcAddress("glAttachShader"); - glLinkProgram = (PFNGLLINKPROGRAMPROC)myGetProcAddress("glLinkProgram"); - glUseProgram = (PFNGLUSEPROGRAMPROC)myGetProcAddress("glUseProgram"); - glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)myGetProcAddress("glValidateProgram"); - - glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)myGetProcAddress("glVertexAttrib1f"); - glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)myGetProcAddress("glVertexAttrib2f"); - glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)myGetProcAddress("glVertexAttrib4f"); - glVertexAttrib2fv = (PFNGLVERTEXATTRIB4FVPROC)myGetProcAddress("glVertexAttrib2fv"); - glVertexAttrib3fv = (PFNGLVERTEXATTRIB4FVPROC)myGetProcAddress("glVertexAttrib3fv"); - glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)myGetProcAddress("glVertexAttrib4fv"); - glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)myGetProcAddress("glVertexAttrib4ubv"); - glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)myGetProcAddress("glGetAttribLocation"); - glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)myGetProcAddress("glBindAttribLocation"); - - - glUniform1f = (PFNGLUNIFORM1FPROC)myGetProcAddress("glUniform1f"); - glUniform2f = (PFNGLUNIFORM2FPROC)myGetProcAddress("glUniform2f"); - glUniform3f = (PFNGLUNIFORM3FPROC)myGetProcAddress("glUniform3f"); - glUniform4f = (PFNGLUNIFORM4FPROC)myGetProcAddress("glUniform4f"); - glUniform1i = (PFNGLUNIFORM1IPROC)myGetProcAddress("glUniform1i"); - glUniform2i = (PFNGLUNIFORM2IPROC)myGetProcAddress("glUniform2i"); - glUniform3i = (PFNGLUNIFORM3IPROC)myGetProcAddress("glUniform3i"); - glUniform4i = (PFNGLUNIFORM4IPROC)myGetProcAddress("glUniform4i"); - glUniform1fv = (PFNGLUNIFORM1FVPROC)myGetProcAddress("glUniform1fv"); - glUniform2fv = (PFNGLUNIFORM2FVPROC)myGetProcAddress("glUniform2fv"); - glUniform3fv = (PFNGLUNIFORM3FVPROC)myGetProcAddress("glUniform3fv"); - glUniform4fv = (PFNGLUNIFORM4FVPROC)myGetProcAddress("glUniform4fv"); - glUniform1iv = (PFNGLUNIFORM1IVPROC)myGetProcAddress("glUniform1iv"); - glUniform2iv = (PFNGLUNIFORM2IVPROC)myGetProcAddress("glUniform2iv"); - glUniform3iv = (PFNGLUNIFORM3IVPROC)myGetProcAddress("glUniform3iv"); - glUniform4iv = (PFNGLUNIFORM4IVPROC)myGetProcAddress("glUniform4iv"); - - glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)myGetProcAddress("glUniformMatrix2fv"); - glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)myGetProcAddress("glUniformMatrix3fv"); - glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)myGetProcAddress("glUniformMatrix4fv"); - - glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)myGetProcAddress("glGetProgramInfoLog"); - glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)myGetProcAddress("glGetShaderInfoLog"); - glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)myGetProcAddress("glGetUniformLocation"); - glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)myGetProcAddress("glGetActiveUniform"); - glGetUniformfv = (PFNGLGETUNIFORMFVPROC)myGetProcAddress("glGetUniformfv"); - glGetUniformiv = (PFNGLGETUNIFORMIVPROC)myGetProcAddress("glGetUniformiv"); - glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)myGetProcAddress("glGetShaderSource"); - - glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)myGetProcAddress("glEnableVertexAttribArray"); - glDisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)myGetProcAddress("glDisableVertexAttribArray"); - glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)myGetProcAddress("glVertexAttribPointer"); - - // what'S the equivalent of this in GL 2.0??? - glGetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)myGetProcAddress("glGetObjectParameterivARB"); - // Rules: // SM4 will always use shaders. No option to switch them off is needed here. // SM3 has shaders optional but they are off by default (they will have a performance impact @@ -258,78 +184,16 @@ void gl_LoadExtensions() else if (Args->CheckParm("-sm3") && gl.shadermodel > 3) gl.shadermodel = 3; } - if (CheckExtension("GL_ARB_occlusion_query")) - { - glGenQueries = (PFNGLGENQUERIESARBPROC)myGetProcAddress("glGenQueriesARB"); - glDeleteQueries = (PFNGLDELETEQUERIESARBPROC)myGetProcAddress("glDeleteQueriesARB"); - glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVARBPROC)myGetProcAddress("glGetQueryObjectuivARB"); - glBeginQuery = (PFNGLBEGINQUERYARBPROC)myGetProcAddress("glBeginQueryARB"); - glEndQuery = (PFNGLENDQUERYPROC)myGetProcAddress("glEndQueryARB"); - gl.flags|=RFL_OCCLUSION_QUERY; - } - - if (gl.flags & RFL_GL_21) - { - glBindBuffer = (PFNGLBINDBUFFERPROC)myGetProcAddress("glBindBuffer"); - glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)myGetProcAddress("glDeleteBuffers"); - glGenBuffers = (PFNGLGENBUFFERSPROC)myGetProcAddress("glGenBuffers"); - glBufferData = (PFNGLBUFFERDATAPROC)myGetProcAddress("glBufferData"); - glBufferSubData = (PFNGLBUFFERSUBDATAPROC)myGetProcAddress("glBufferSubData"); - glMapBuffer = (PFNGLMAPBUFFERPROC)myGetProcAddress("glMapBuffer"); - glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)myGetProcAddress("glUnmapBuffer"); - gl.flags |= RFL_VBO; - } - else if (CheckExtension("GL_ARB_vertex_buffer_object")) - { - glBindBuffer = (PFNGLBINDBUFFERPROC)myGetProcAddress("glBindBufferARB"); - glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)myGetProcAddress("glDeleteBuffersARB"); - glGenBuffers = (PFNGLGENBUFFERSPROC)myGetProcAddress("glGenBuffersARB"); - glBufferData = (PFNGLBUFFERDATAPROC)myGetProcAddress("glBufferDataARB"); - glBufferSubData = (PFNGLBUFFERSUBDATAPROC)myGetProcAddress("glBufferSubDataARB"); - glMapBuffer = (PFNGLMAPBUFFERPROC)myGetProcAddress("glMapBufferARB"); - glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)myGetProcAddress("glUnmapBufferARB"); - gl.flags |= RFL_VBO; - } - if (CheckExtension("GL_ARB_map_buffer_range")) { - glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)myGetProcAddress("glMapBufferRange"); - glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)myGetProcAddress("glFlushMappedBufferRange"); gl.flags|=RFL_MAP_BUFFER_RANGE; } - if (CheckExtension("GL_ARB_framebuffer_object")) + if (gl.flags & RFL_GL_30) { - glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)myGetProcAddress("glGenFramebuffers"); - glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)myGetProcAddress("glDeleteFramebuffers"); - glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)myGetProcAddress("glBindFramebuffer"); - glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)myGetProcAddress("glFramebufferTexture2D"); - glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)myGetProcAddress("glGenRenderbuffers"); - glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)myGetProcAddress("glDeleteRenderbuffers"); - glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)myGetProcAddress("glBindRenderbuffer"); - glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)myGetProcAddress("glRenderbufferStorage"); - glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)myGetProcAddress("glFramebufferRenderbuffer"); - gl.flags|=RFL_FRAMEBUFFER; } -#if 0 - if (CheckExtension("GL_ARB_texture_buffer_object") && - CheckExtension("GL_ARB_texture_float") && - CheckExtension("GL_EXT_GPU_Shader4") && - CheckExtension("GL_ARB_texture_rg") && - gl.shadermodel == 4) - { - glTexBufferARB = (PFNGLTEXBUFFERARBPROC)myGetProcAddress("glTexBufferARB"); - gl.flags|=RFL_TEXTUREBUFFER; - } -#endif - - - - glActiveTexture = (PFNGLACTIVETEXTUREPROC)myGetProcAddress("glActiveTextureARB"); - glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) myGetProcAddress("glMultiTexCoord2fARB"); - glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) myGetProcAddress("glMultiTexCoord2fvARB"); } //========================================================================== @@ -347,6 +211,8 @@ void gl_PrintStartupLog() Printf ("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS)); int v; + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &v); + Printf("Max. texture size: %d\n", v); glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &v); Printf ("Max. texture units: %d\n", v); glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index babbec8fd..79623c07f 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -5,13 +5,10 @@ enum RenderFlags { - RFL_NPOT_TEXTURE=1, - RFL_OCCLUSION_QUERY=4, // [BB] Added texture compression flags. RFL_TEXTURE_COMPRESSION=8, RFL_TEXTURE_COMPRESSION_S3TC=16, - RFL_VBO = 32, RFL_MAP_BUFFER_RANGE = 64, RFL_FRAMEBUFFER = 128, RFL_TEXTUREBUFFER = 256, diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h index 222fb44f1..cb98d572e 100644 --- a/src/gl/system/gl_system.h +++ b/src/gl/system/gl_system.h @@ -67,22 +67,21 @@ #include //GL headers +#include + #if defined(__APPLE__) -#include -#include + #include #elif defined(__unix__) -#include -#include "gl/api/glext.h" + #include #else // !__APPLE__ && !__unix__ -#include -#include -#include "gl/api/glext.h" + #define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code! + #include + #undef DWORD #endif -#include "gl/api/gl_api.h" #ifdef _WIN32 #define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code! -#include "gl/api/wglext.h" +//#include "gl/api/wglext.h" #ifndef __WINE__ #undef DWORD #endif diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 4737f7717..be6c6415f 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -72,11 +72,7 @@ unsigned int FHardwareTexture::lastbound[FHardwareTexture::MAX_TEXTURES]; int FHardwareTexture::GetTexDimension(int value) { if (value > gl.max_texturesize) return gl.max_texturesize; - if (gl.flags&RFL_NPOT_TEXTURE) return value; - - int i=1; - while (iw) - memcpy( scaledbuffer + rw * y * 4 + w * 4, - scaledbuffer + rw * y * 4 + w * 4 -4, 4); - } - // also duplicate the last line for the same reason! - memcpy( scaledbuffer + rw * h * 4, scaledbuffer + rw * (h-1) * 4, w*4 + 4); - - deletebuffer=true; - buffer=scaledbuffer; - } - } } glTexImage2D(GL_TEXTURE_2D, 0, texformat, rw, rh, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 62c860705..9cb3ef523 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -705,22 +705,19 @@ FMaterial::FMaterial(FTexture * tx, bool forceexpand) mBaseLayer = ValidateSysTexture(tx, true); - if (gl.flags & RFL_NPOT_TEXTURE) // trimming only works if non-power-of-2 textures are supported + int trim[4]; + + if (TrimBorders(trim)) { - int trim[4]; + Width[GLUSE_SPRITE] = trim[2] + 2; + Height[GLUSE_SPRITE] = trim[3] + 2; + LeftOffset[GLUSE_SPRITE] -= trim[0]; + TopOffset[GLUSE_SPRITE] -= trim[1]; - if (TrimBorders(trim)) - { - Width[GLUSE_SPRITE] = trim[2] + 2; - Height[GLUSE_SPRITE] = trim[3] + 2; - LeftOffset[GLUSE_SPRITE] -= trim[0]; - TopOffset[GLUSE_SPRITE] -= trim[1]; - - SpriteU[0] = SpriteU[1] * (trim[0] / (float)Width[GLUSE_PATCH]); - SpriteV[0] = SpriteV[1] * (trim[1] / (float)Height[GLUSE_PATCH]); - SpriteU[1] *= (trim[0]+trim[2]+2) / (float)Width[GLUSE_PATCH]; - SpriteV[1] *= (trim[1]+trim[3]+2) / (float)Height[GLUSE_PATCH]; - } + SpriteU[0] = SpriteU[1] * (trim[0] / (float)Width[GLUSE_PATCH]); + SpriteV[0] = SpriteV[1] * (trim[1] / (float)Height[GLUSE_PATCH]); + SpriteU[1] *= (trim[0]+trim[2]+2) / (float)Width[GLUSE_PATCH]; + SpriteV[1] *= (trim[1]+trim[3]+2) / (float)Height[GLUSE_PATCH]; } } } From 94b06900cbcef33f5404ae007190aaba6f246af6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Apr 2014 11:59:41 +0200 Subject: [PATCH 0067/1509] - got rid of a lot of stuff that's no longer required with GLEW. - replaced GLUs texture scaling with our own function. This is only used to scale down textures larger than what the hardware can handle so we do not need a dependency to an essentially deprecated library for it. --- src/CMakeLists.txt | 3 - src/gl/api/gl_api.cpp | 4 - src/gl/api/gl_api.h | 103 - src/gl/api/glext.h | 11813 ----------------------------- src/gl/api/wglext.h | 943 --- src/gl/data/gl_sections.cpp | 847 --- src/gl/data/gl_sections.h | 56 - src/gl/textures/gl_hwtexture.cpp | 101 +- src/gl/textures/gl_hwtexture.h | 1 + 9 files changed, 101 insertions(+), 13770 deletions(-) delete mode 100644 src/gl/api/gl_api.cpp delete mode 100644 src/gl/api/gl_api.h delete mode 100644 src/gl/api/glext.h delete mode 100644 src/gl/api/wglext.h delete mode 100644 src/gl/data/gl_sections.cpp delete mode 100644 src/gl/data/gl_sections.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d9fa878e9..9e72e4375 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1038,8 +1038,6 @@ add_executable( zdoom WIN32 menu/playermenu.cpp menu/readthis.cpp menu/videomenu.cpp - gl/api/gl_api.cpp - gl/data/gl_sections.cpp gl/data/gl_data.cpp gl/data/gl_portaldata.cpp gl/data/gl_setup.cpp @@ -1291,7 +1289,6 @@ source_group("Games\\Strife Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DI source_group("Intermission" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/intermission/.+") source_group("Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/menu/.+") source_group("OpenGL Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/.+") -source_group("OpenGL Renderer\\API" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/api/.+") source_group("OpenGL Renderer\\Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/data/.+") source_group("OpenGL Renderer\\Dynamic Lights" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/dynlights/.+") source_group("OpenGL Renderer\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx/.+") diff --git a/src/gl/api/gl_api.cpp b/src/gl/api/gl_api.cpp deleted file mode 100644 index 67a3fb3e5..000000000 --- a/src/gl/api/gl_api.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "gl/system/gl_system.h" - -#define __EXTERN -#include "gl_api.h" diff --git a/src/gl/api/gl_api.h b/src/gl/api/gl_api.h deleted file mode 100644 index 6c5b96887..000000000 --- a/src/gl/api/gl_api.h +++ /dev/null @@ -1,103 +0,0 @@ -#if defined(__unix__) || defined(__APPLE__) -#define APIENTRY -#define APIENTRYP * -#endif // __unix__ || __APPLE__ - -#ifndef __EXTERN -#define __EXTERN extern -#endif - -#if 0 -__EXTERN PFNGLBLENDEQUATIONPROC glBlendEquation; - -// ARB_SHADER_OBJECTS -__EXTERN PFNGLDELETESHADERPROC glDeleteShader; -__EXTERN PFNGLDELETEPROGRAMPROC glDeleteProgram; -__EXTERN PFNGLDETACHSHADERPROC glDetachShader; -__EXTERN PFNGLCREATESHADERPROC glCreateShader; -__EXTERN PFNGLSHADERSOURCEPROC glShaderSource; -__EXTERN PFNGLCOMPILESHADERPROC glCompileShader; -__EXTERN PFNGLCREATEPROGRAMPROC glCreateProgram; -__EXTERN PFNGLATTACHSHADERPROC glAttachShader; -__EXTERN PFNGLLINKPROGRAMPROC glLinkProgram; -__EXTERN PFNGLUSEPROGRAMPROC glUseProgram; -__EXTERN PFNGLVALIDATEPROGRAMPROC glValidateProgram; -__EXTERN PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f; -__EXTERN PFNGLVERTEXATTRIB2FPROC glVertexAttrib2f; -__EXTERN PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f; -__EXTERN PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv; -__EXTERN PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv; -__EXTERN PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv; -__EXTERN PFNGLVERTEXATTRIB4UBVPROC glVertexAttrib4ubv; -__EXTERN PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; -__EXTERN PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation; - -__EXTERN PFNGLUNIFORM1FPROC glUniform1f; -__EXTERN PFNGLUNIFORM2FPROC glUniform2f; -__EXTERN PFNGLUNIFORM3FPROC glUniform3f; -__EXTERN PFNGLUNIFORM4FPROC glUniform4f; -__EXTERN PFNGLUNIFORM1IPROC glUniform1i; -__EXTERN PFNGLUNIFORM2IPROC glUniform2i; -__EXTERN PFNGLUNIFORM3IPROC glUniform3i; -__EXTERN PFNGLUNIFORM4IPROC glUniform4i; -__EXTERN PFNGLUNIFORM1FVPROC glUniform1fv; -__EXTERN PFNGLUNIFORM2FVPROC glUniform2fv; -__EXTERN PFNGLUNIFORM3FVPROC glUniform3fv; -__EXTERN PFNGLUNIFORM4FVPROC glUniform4fv; -__EXTERN PFNGLUNIFORM1IVPROC glUniform1iv; -__EXTERN PFNGLUNIFORM2IVPROC glUniform2iv; -__EXTERN PFNGLUNIFORM3IVPROC glUniform3iv; -__EXTERN PFNGLUNIFORM4IVPROC glUniform4iv; - -__EXTERN PFNGLUNIFORMMATRIX2FVPROC glUniformMatrix2fv; -__EXTERN PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv; -__EXTERN PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; - -__EXTERN PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; -__EXTERN PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; -__EXTERN PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; -__EXTERN PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform; -__EXTERN PFNGLGETUNIFORMFVPROC glGetUniformfv; -__EXTERN PFNGLGETUNIFORMIVPROC glGetUniformiv; -__EXTERN PFNGLGETSHADERSOURCEPROC glGetShaderSource; -__EXTERN PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameteriv; - -__EXTERN PFNGLGENQUERIESARBPROC glGenQueries; -__EXTERN PFNGLDELETEQUERIESARBPROC glDeleteQueries; -__EXTERN PFNGLBEGINQUERYARBPROC glBeginQuery; -__EXTERN PFNGLENDQUERYARBPROC glEndQuery; -__EXTERN PFNGLGETQUERYOBJECTUIVARBPROC glGetQueryObjectuiv; - -__EXTERN PFNGLACTIVETEXTUREPROC glActiveTexture; -__EXTERN PFNGLMULTITEXCOORD2FPROC glMultiTexCoord2f; -__EXTERN PFNGLMULTITEXCOORD2FVPROC glMultiTexCoord2fv; - -__EXTERN PFNGLBINDBUFFERPROC glBindBuffer; -__EXTERN PFNGLDELETEBUFFERSPROC glDeleteBuffers; -__EXTERN PFNGLGENBUFFERSPROC glGenBuffers; -__EXTERN PFNGLBUFFERDATAPROC glBufferData; -__EXTERN PFNGLBUFFERSUBDATAPROC glBufferSubData; -__EXTERN PFNGLMAPBUFFERPROC glMapBuffer; -__EXTERN PFNGLUNMAPBUFFERPROC glUnmapBuffer; -__EXTERN PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; -__EXTERN PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; -__EXTERN PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; - -__EXTERN PFNGLMAPBUFFERRANGEPROC glMapBufferRange; -__EXTERN PFNGLFLUSHMAPPEDBUFFERRANGEPROC glFlushMappedBufferRange; - -__EXTERN PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; -__EXTERN PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; -__EXTERN PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; -__EXTERN PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; -__EXTERN PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; -__EXTERN PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; -__EXTERN PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; -__EXTERN PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; -__EXTERN PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; - -__EXTERN PFNGLTEXBUFFERARBPROC glTexBufferARB; - -#undef __EXTERN - -#endif diff --git a/src/gl/api/glext.h b/src/gl/api/glext.h deleted file mode 100644 index 8fce0f6f0..000000000 --- a/src/gl/api/glext.h +++ /dev/null @@ -1,11813 +0,0 @@ -#ifndef __glext_h_ -#define __glext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2007-2012 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated $Date: 2012-04-26 00:59:42 -0700 (Thu, 26 Apr 2012) $ */ -/* Current version at http://www.opengl.org/registry/ */ -#define GL_GLEXT_VERSION 81 -/* Function declaration macros - to move into glplatform.h */ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -#ifndef GL_VERSION_1_2 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#endif - -#ifndef GL_VERSION_1_2_DEPRECATED -#define GL_RESCALE_NORMAL 0x803A -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#endif - -#ifndef GL_ARB_imaging -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#endif - -#ifndef GL_ARB_imaging_DEPRECATED -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 -#endif - -#ifndef GL_VERSION_1_3 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_CLAMP_TO_BORDER 0x812D -#endif - -#ifndef GL_VERSION_1_3_DEPRECATED -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define GL_MULTISAMPLE_BIT 0x20000000 -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_SUBTRACT 0x84E7 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -#endif - -#ifndef GL_VERSION_1_4 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#endif - -#ifndef GL_VERSION_1_4_DEPRECATED -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_COMPARE_R_TO_TEXTURE 0x884E -#endif - -#ifndef GL_VERSION_1_5 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#endif - -#ifndef GL_VERSION_1_5_DEPRECATED -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define GL_FOG_COORD_SRC 0x8450 -#define GL_FOG_COORD 0x8451 -#define GL_CURRENT_FOG_COORD 0x8453 -#define GL_FOG_COORD_ARRAY_TYPE 0x8454 -#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORD_ARRAY_POINTER 0x8456 -#define GL_FOG_COORD_ARRAY 0x8457 -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D -#define GL_SRC0_RGB 0x8580 -#define GL_SRC1_RGB 0x8581 -#define GL_SRC2_RGB 0x8582 -#define GL_SRC0_ALPHA 0x8588 -#define GL_SRC1_ALPHA 0x8589 -#define GL_SRC2_ALPHA 0x858A -#endif - -#ifndef GL_VERSION_2_0 -#define GL_BLEND_EQUATION_RGB 0x8009 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#endif - -#ifndef GL_VERSION_2_0_DEPRECATED -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_TEXTURE_COORDS 0x8871 -#endif - -#ifndef GL_VERSION_2_1 -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB_ALPHA 0x8C42 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#endif - -#ifndef GL_VERSION_2_1_DEPRECATED -#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F -#define GL_SLUMINANCE_ALPHA 0x8C44 -#define GL_SLUMINANCE8_ALPHA8 0x8C45 -#define GL_SLUMINANCE 0x8C46 -#define GL_SLUMINANCE8 0x8C47 -#define GL_COMPRESSED_SLUMINANCE 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B -#endif - -#ifndef GL_VERSION_3_0 -#define GL_COMPARE_REF_TO_TEXTURE 0x884E -#define GL_CLIP_DISTANCE0 0x3000 -#define GL_CLIP_DISTANCE1 0x3001 -#define GL_CLIP_DISTANCE2 0x3002 -#define GL_CLIP_DISTANCE3 0x3003 -#define GL_CLIP_DISTANCE4 0x3004 -#define GL_CLIP_DISTANCE5 0x3005 -#define GL_CLIP_DISTANCE6 0x3006 -#define GL_CLIP_DISTANCE7 0x3007 -#define GL_MAX_CLIP_DISTANCES 0x0D32 -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#define GL_CONTEXT_FLAGS 0x821E -#define GL_COMPRESSED_RED 0x8225 -#define GL_COMPRESSED_RG 0x8226 -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 -#define GL_RGBA32F 0x8814 -#define GL_RGB32F 0x8815 -#define GL_RGBA16F 0x881A -#define GL_RGB16F 0x881B -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD -#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF -#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 -#define GL_CLAMP_READ_COLOR 0x891C -#define GL_FIXED_ONLY 0x891D -#define GL_MAX_VARYING_COMPONENTS 0x8B4B -#define GL_TEXTURE_1D_ARRAY 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D -#define GL_R11F_G11F_B10F 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B -#define GL_RGB9_E5 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E -#define GL_TEXTURE_SHARED_SIZE 0x8C3F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 -#define GL_PRIMITIVES_GENERATED 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 -#define GL_RASTERIZER_DISCARD 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B -#define GL_INTERLEAVED_ATTRIBS 0x8C8C -#define GL_SEPARATE_ATTRIBS 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F -#define GL_RGBA32UI 0x8D70 -#define GL_RGB32UI 0x8D71 -#define GL_RGBA16UI 0x8D76 -#define GL_RGB16UI 0x8D77 -#define GL_RGBA8UI 0x8D7C -#define GL_RGB8UI 0x8D7D -#define GL_RGBA32I 0x8D82 -#define GL_RGB32I 0x8D83 -#define GL_RGBA16I 0x8D88 -#define GL_RGB16I 0x8D89 -#define GL_RGBA8I 0x8D8E -#define GL_RGB8I 0x8D8F -#define GL_RED_INTEGER 0x8D94 -#define GL_GREEN_INTEGER 0x8D95 -#define GL_BLUE_INTEGER 0x8D96 -#define GL_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_BGR_INTEGER 0x8D9A -#define GL_BGRA_INTEGER 0x8D9B -#define GL_SAMPLER_1D_ARRAY 0x8DC0 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 -#define GL_UNSIGNED_INT_VEC2 0x8DC6 -#define GL_UNSIGNED_INT_VEC3 0x8DC7 -#define GL_UNSIGNED_INT_VEC4 0x8DC8 -#define GL_INT_SAMPLER_1D 0x8DC9 -#define GL_INT_SAMPLER_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 -#define GL_QUERY_WAIT 0x8E13 -#define GL_QUERY_NO_WAIT 0x8E14 -#define GL_QUERY_BY_REGION_WAIT 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 -#define GL_BUFFER_ACCESS_FLAGS 0x911F -#define GL_BUFFER_MAP_LENGTH 0x9120 -#define GL_BUFFER_MAP_OFFSET 0x9121 -/* Reuse tokens from ARB_depth_buffer_float */ -/* reuse GL_DEPTH_COMPONENT32F */ -/* reuse GL_DEPTH32F_STENCIL8 */ -/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ -/* Reuse tokens from ARB_framebuffer_object */ -/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_DEFAULT */ -/* reuse GL_FRAMEBUFFER_UNDEFINED */ -/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ -/* reuse GL_INDEX */ -/* reuse GL_MAX_RENDERBUFFER_SIZE */ -/* reuse GL_DEPTH_STENCIL */ -/* reuse GL_UNSIGNED_INT_24_8 */ -/* reuse GL_DEPTH24_STENCIL8 */ -/* reuse GL_TEXTURE_STENCIL_SIZE */ -/* reuse GL_TEXTURE_RED_TYPE */ -/* reuse GL_TEXTURE_GREEN_TYPE */ -/* reuse GL_TEXTURE_BLUE_TYPE */ -/* reuse GL_TEXTURE_ALPHA_TYPE */ -/* reuse GL_TEXTURE_DEPTH_TYPE */ -/* reuse GL_UNSIGNED_NORMALIZED */ -/* reuse GL_FRAMEBUFFER_BINDING */ -/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_BINDING */ -/* reuse GL_READ_FRAMEBUFFER */ -/* reuse GL_DRAW_FRAMEBUFFER */ -/* reuse GL_READ_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_SAMPLES */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* reuse GL_FRAMEBUFFER_COMPLETE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ -/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ -/* reuse GL_MAX_COLOR_ATTACHMENTS */ -/* reuse GL_COLOR_ATTACHMENT0 */ -/* reuse GL_COLOR_ATTACHMENT1 */ -/* reuse GL_COLOR_ATTACHMENT2 */ -/* reuse GL_COLOR_ATTACHMENT3 */ -/* reuse GL_COLOR_ATTACHMENT4 */ -/* reuse GL_COLOR_ATTACHMENT5 */ -/* reuse GL_COLOR_ATTACHMENT6 */ -/* reuse GL_COLOR_ATTACHMENT7 */ -/* reuse GL_COLOR_ATTACHMENT8 */ -/* reuse GL_COLOR_ATTACHMENT9 */ -/* reuse GL_COLOR_ATTACHMENT10 */ -/* reuse GL_COLOR_ATTACHMENT11 */ -/* reuse GL_COLOR_ATTACHMENT12 */ -/* reuse GL_COLOR_ATTACHMENT13 */ -/* reuse GL_COLOR_ATTACHMENT14 */ -/* reuse GL_COLOR_ATTACHMENT15 */ -/* reuse GL_DEPTH_ATTACHMENT */ -/* reuse GL_STENCIL_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER */ -/* reuse GL_RENDERBUFFER */ -/* reuse GL_RENDERBUFFER_WIDTH */ -/* reuse GL_RENDERBUFFER_HEIGHT */ -/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ -/* reuse GL_STENCIL_INDEX1 */ -/* reuse GL_STENCIL_INDEX4 */ -/* reuse GL_STENCIL_INDEX8 */ -/* reuse GL_STENCIL_INDEX16 */ -/* reuse GL_RENDERBUFFER_RED_SIZE */ -/* reuse GL_RENDERBUFFER_GREEN_SIZE */ -/* reuse GL_RENDERBUFFER_BLUE_SIZE */ -/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ -/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ -/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ -/* reuse GL_MAX_SAMPLES */ -/* Reuse tokens from ARB_framebuffer_sRGB */ -/* reuse GL_FRAMEBUFFER_SRGB */ -/* Reuse tokens from ARB_half_float_vertex */ -/* reuse GL_HALF_FLOAT */ -/* Reuse tokens from ARB_map_buffer_range */ -/* reuse GL_MAP_READ_BIT */ -/* reuse GL_MAP_WRITE_BIT */ -/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ -/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ -/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ -/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ -/* Reuse tokens from ARB_texture_compression_rgtc */ -/* reuse GL_COMPRESSED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_RG_RGTC2 */ -/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ -/* Reuse tokens from ARB_texture_rg */ -/* reuse GL_RG */ -/* reuse GL_RG_INTEGER */ -/* reuse GL_R8 */ -/* reuse GL_R16 */ -/* reuse GL_RG8 */ -/* reuse GL_RG16 */ -/* reuse GL_R16F */ -/* reuse GL_R32F */ -/* reuse GL_RG16F */ -/* reuse GL_RG32F */ -/* reuse GL_R8I */ -/* reuse GL_R8UI */ -/* reuse GL_R16I */ -/* reuse GL_R16UI */ -/* reuse GL_R32I */ -/* reuse GL_R32UI */ -/* reuse GL_RG8I */ -/* reuse GL_RG8UI */ -/* reuse GL_RG16I */ -/* reuse GL_RG16UI */ -/* reuse GL_RG32I */ -/* reuse GL_RG32UI */ -/* Reuse tokens from ARB_vertex_array_object */ -/* reuse GL_VERTEX_ARRAY_BINDING */ -#endif - -#ifndef GL_VERSION_3_0_DEPRECATED -#define GL_CLAMP_VERTEX_COLOR 0x891A -#define GL_CLAMP_FRAGMENT_COLOR 0x891B -#define GL_ALPHA_INTEGER 0x8D97 -/* Reuse tokens from ARB_framebuffer_object */ -/* reuse GL_TEXTURE_LUMINANCE_TYPE */ -/* reuse GL_TEXTURE_INTENSITY_TYPE */ -#endif - -#ifndef GL_VERSION_3_1 -#define GL_SAMPLER_2D_RECT 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 -#define GL_SAMPLER_BUFFER 0x8DC2 -#define GL_INT_SAMPLER_2D_RECT 0x8DCD -#define GL_INT_SAMPLER_BUFFER 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -#define GL_TEXTURE_BUFFER 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT 0x8C2E -#define GL_TEXTURE_RECTANGLE 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 -#define GL_RED_SNORM 0x8F90 -#define GL_RG_SNORM 0x8F91 -#define GL_RGB_SNORM 0x8F92 -#define GL_RGBA_SNORM 0x8F93 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM 0x8F98 -#define GL_RG16_SNORM 0x8F99 -#define GL_RGB16_SNORM 0x8F9A -#define GL_RGBA16_SNORM 0x8F9B -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_PRIMITIVE_RESTART 0x8F9D -#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E -/* Reuse tokens from ARB_copy_buffer */ -/* reuse GL_COPY_READ_BUFFER */ -/* reuse GL_COPY_WRITE_BUFFER */ -/* Reuse tokens from ARB_draw_instanced (none) */ -/* Reuse tokens from ARB_uniform_buffer_object */ -/* reuse GL_UNIFORM_BUFFER */ -/* reuse GL_UNIFORM_BUFFER_BINDING */ -/* reuse GL_UNIFORM_BUFFER_START */ -/* reuse GL_UNIFORM_BUFFER_SIZE */ -/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */ -/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */ -/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */ -/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */ -/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */ -/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */ -/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */ -/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */ -/* reuse GL_ACTIVE_UNIFORM_BLOCKS */ -/* reuse GL_UNIFORM_TYPE */ -/* reuse GL_UNIFORM_SIZE */ -/* reuse GL_UNIFORM_NAME_LENGTH */ -/* reuse GL_UNIFORM_BLOCK_INDEX */ -/* reuse GL_UNIFORM_OFFSET */ -/* reuse GL_UNIFORM_ARRAY_STRIDE */ -/* reuse GL_UNIFORM_MATRIX_STRIDE */ -/* reuse GL_UNIFORM_IS_ROW_MAJOR */ -/* reuse GL_UNIFORM_BLOCK_BINDING */ -/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */ -/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */ -/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */ -/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */ -/* reuse GL_INVALID_INDEX */ -#endif - -#ifndef GL_VERSION_3_2 -#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 -#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define GL_LINES_ADJACENCY 0x000A -#define GL_LINE_STRIP_ADJACENCY 0x000B -#define GL_TRIANGLES_ADJACENCY 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D -#define GL_PROGRAM_POINT_SIZE 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#define GL_GEOMETRY_SHADER 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT 0x8916 -#define GL_GEOMETRY_INPUT_TYPE 0x8917 -#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#define GL_CONTEXT_PROFILE_MASK 0x9126 -/* reuse GL_MAX_VARYING_COMPONENTS */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* Reuse tokens from ARB_depth_clamp */ -/* reuse GL_DEPTH_CLAMP */ -/* Reuse tokens from ARB_draw_elements_base_vertex (none) */ -/* Reuse tokens from ARB_fragment_coord_conventions (none) */ -/* Reuse tokens from ARB_provoking_vertex */ -/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ -/* reuse GL_FIRST_VERTEX_CONVENTION */ -/* reuse GL_LAST_VERTEX_CONVENTION */ -/* reuse GL_PROVOKING_VERTEX */ -/* Reuse tokens from ARB_seamless_cube_map */ -/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ -/* Reuse tokens from ARB_sync */ -/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */ -/* reuse GL_OBJECT_TYPE */ -/* reuse GL_SYNC_CONDITION */ -/* reuse GL_SYNC_STATUS */ -/* reuse GL_SYNC_FLAGS */ -/* reuse GL_SYNC_FENCE */ -/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */ -/* reuse GL_UNSIGNALED */ -/* reuse GL_SIGNALED */ -/* reuse GL_ALREADY_SIGNALED */ -/* reuse GL_TIMEOUT_EXPIRED */ -/* reuse GL_CONDITION_SATISFIED */ -/* reuse GL_WAIT_FAILED */ -/* reuse GL_TIMEOUT_IGNORED */ -/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */ -/* reuse GL_TIMEOUT_IGNORED */ -/* Reuse tokens from ARB_texture_multisample */ -/* reuse GL_SAMPLE_POSITION */ -/* reuse GL_SAMPLE_MASK */ -/* reuse GL_SAMPLE_MASK_VALUE */ -/* reuse GL_MAX_SAMPLE_MASK_WORDS */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_SAMPLES */ -/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */ -/* reuse GL_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */ -/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */ -/* reuse GL_MAX_INTEGER_SAMPLES */ -/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */ -#endif - -#ifndef GL_VERSION_3_3 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -/* Reuse tokens from ARB_blend_func_extended */ -/* reuse GL_SRC1_COLOR */ -/* reuse GL_ONE_MINUS_SRC1_COLOR */ -/* reuse GL_ONE_MINUS_SRC1_ALPHA */ -/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */ -/* Reuse tokens from ARB_explicit_attrib_location (none) */ -/* Reuse tokens from ARB_occlusion_query2 */ -/* reuse GL_ANY_SAMPLES_PASSED */ -/* Reuse tokens from ARB_sampler_objects */ -/* reuse GL_SAMPLER_BINDING */ -/* Reuse tokens from ARB_shader_bit_encoding (none) */ -/* Reuse tokens from ARB_texture_rgb10_a2ui */ -/* reuse GL_RGB10_A2UI */ -/* Reuse tokens from ARB_texture_swizzle */ -/* reuse GL_TEXTURE_SWIZZLE_R */ -/* reuse GL_TEXTURE_SWIZZLE_G */ -/* reuse GL_TEXTURE_SWIZZLE_B */ -/* reuse GL_TEXTURE_SWIZZLE_A */ -/* reuse GL_TEXTURE_SWIZZLE_RGBA */ -/* Reuse tokens from ARB_timer_query */ -/* reuse GL_TIME_ELAPSED */ -/* reuse GL_TIMESTAMP */ -/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */ -/* reuse GL_INT_2_10_10_10_REV */ -#endif - -#ifndef GL_VERSION_4_0 -#define GL_SAMPLE_SHADING 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F -#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F -/* Reuse tokens from ARB_texture_query_lod (none) */ -/* Reuse tokens from ARB_draw_buffers_blend (none) */ -/* Reuse tokens from ARB_draw_indirect */ -/* reuse GL_DRAW_INDIRECT_BUFFER */ -/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */ -/* Reuse tokens from ARB_gpu_shader5 */ -/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */ -/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */ -/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */ -/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */ -/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */ -/* reuse GL_MAX_VERTEX_STREAMS */ -/* Reuse tokens from ARB_gpu_shader_fp64 */ -/* reuse GL_DOUBLE_VEC2 */ -/* reuse GL_DOUBLE_VEC3 */ -/* reuse GL_DOUBLE_VEC4 */ -/* reuse GL_DOUBLE_MAT2 */ -/* reuse GL_DOUBLE_MAT3 */ -/* reuse GL_DOUBLE_MAT4 */ -/* reuse GL_DOUBLE_MAT2x3 */ -/* reuse GL_DOUBLE_MAT2x4 */ -/* reuse GL_DOUBLE_MAT3x2 */ -/* reuse GL_DOUBLE_MAT3x4 */ -/* reuse GL_DOUBLE_MAT4x2 */ -/* reuse GL_DOUBLE_MAT4x3 */ -/* Reuse tokens from ARB_shader_subroutine */ -/* reuse GL_ACTIVE_SUBROUTINES */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */ -/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */ -/* reuse GL_MAX_SUBROUTINES */ -/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */ -/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ -/* reuse GL_COMPATIBLE_SUBROUTINES */ -/* Reuse tokens from ARB_tessellation_shader */ -/* reuse GL_PATCHES */ -/* reuse GL_PATCH_VERTICES */ -/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */ -/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */ -/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */ -/* reuse GL_TESS_GEN_MODE */ -/* reuse GL_TESS_GEN_SPACING */ -/* reuse GL_TESS_GEN_VERTEX_ORDER */ -/* reuse GL_TESS_GEN_POINT_MODE */ -/* reuse GL_ISOLINES */ -/* reuse GL_FRACTIONAL_ODD */ -/* reuse GL_FRACTIONAL_EVEN */ -/* reuse GL_MAX_PATCH_VERTICES */ -/* reuse GL_MAX_TESS_GEN_LEVEL */ -/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */ -/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */ -/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_PATCH_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */ -/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */ -/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */ -/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */ -/* reuse GL_TESS_EVALUATION_SHADER */ -/* reuse GL_TESS_CONTROL_SHADER */ -/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */ -/* Reuse tokens from ARB_transform_feedback2 */ -/* reuse GL_TRANSFORM_FEEDBACK */ -/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ -/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ -/* reuse GL_TRANSFORM_FEEDBACK_BINDING */ -/* Reuse tokens from ARB_transform_feedback3 */ -/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */ -/* reuse GL_MAX_VERTEX_STREAMS */ -#endif - -#ifndef GL_VERSION_4_1 -/* Reuse tokens from ARB_ES2_compatibility */ -/* reuse GL_FIXED */ -/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */ -/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */ -/* reuse GL_LOW_FLOAT */ -/* reuse GL_MEDIUM_FLOAT */ -/* reuse GL_HIGH_FLOAT */ -/* reuse GL_LOW_INT */ -/* reuse GL_MEDIUM_INT */ -/* reuse GL_HIGH_INT */ -/* reuse GL_SHADER_COMPILER */ -/* reuse GL_NUM_SHADER_BINARY_FORMATS */ -/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */ -/* reuse GL_MAX_VARYING_VECTORS */ -/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */ -/* reuse GL_RGB565 */ -/* Reuse tokens from ARB_get_program_binary */ -/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ -/* reuse GL_PROGRAM_BINARY_LENGTH */ -/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */ -/* reuse GL_PROGRAM_BINARY_FORMATS */ -/* Reuse tokens from ARB_separate_shader_objects */ -/* reuse GL_VERTEX_SHADER_BIT */ -/* reuse GL_FRAGMENT_SHADER_BIT */ -/* reuse GL_GEOMETRY_SHADER_BIT */ -/* reuse GL_TESS_CONTROL_SHADER_BIT */ -/* reuse GL_TESS_EVALUATION_SHADER_BIT */ -/* reuse GL_ALL_SHADER_BITS */ -/* reuse GL_PROGRAM_SEPARABLE */ -/* reuse GL_ACTIVE_PROGRAM */ -/* reuse GL_PROGRAM_PIPELINE_BINDING */ -/* Reuse tokens from ARB_shader_precision (none) */ -/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */ -/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */ -/* reuse GL_MAX_VIEWPORTS */ -/* reuse GL_VIEWPORT_SUBPIXEL_BITS */ -/* reuse GL_VIEWPORT_BOUNDS_RANGE */ -/* reuse GL_LAYER_PROVOKING_VERTEX */ -/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */ -/* reuse GL_UNDEFINED_VERTEX */ -#endif - -#ifndef GL_VERSION_4_2 -/* Reuse tokens from ARB_base_instance (none) */ -/* Reuse tokens from ARB_shading_language_420pack (none) */ -/* Reuse tokens from ARB_transform_feedback_instanced (none) */ -/* Reuse tokens from ARB_compressed_texture_pixel_storage */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */ -/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */ -/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */ -/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */ -/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */ -/* Reuse tokens from ARB_conservative_depth (none) */ -/* Reuse tokens from ARB_internalformat_query */ -/* reuse GL_NUM_SAMPLE_COUNTS */ -/* Reuse tokens from ARB_map_buffer_alignment */ -/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */ -/* Reuse tokens from ARB_shader_atomic_counters */ -/* reuse GL_ATOMIC_COUNTER_BUFFER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_START */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */ -/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */ -/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */ -/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */ -/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */ -/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */ -/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */ -/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */ -/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */ -/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */ -/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */ -/* Reuse tokens from ARB_shader_image_load_store */ -/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */ -/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */ -/* reuse GL_UNIFORM_BARRIER_BIT */ -/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */ -/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */ -/* reuse GL_COMMAND_BARRIER_BIT */ -/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */ -/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */ -/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */ -/* reuse GL_FRAMEBUFFER_BARRIER_BIT */ -/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */ -/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */ -/* reuse GL_ALL_BARRIER_BITS */ -/* reuse GL_MAX_IMAGE_UNITS */ -/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ -/* reuse GL_IMAGE_BINDING_NAME */ -/* reuse GL_IMAGE_BINDING_LEVEL */ -/* reuse GL_IMAGE_BINDING_LAYERED */ -/* reuse GL_IMAGE_BINDING_LAYER */ -/* reuse GL_IMAGE_BINDING_ACCESS */ -/* reuse GL_IMAGE_1D */ -/* reuse GL_IMAGE_2D */ -/* reuse GL_IMAGE_3D */ -/* reuse GL_IMAGE_2D_RECT */ -/* reuse GL_IMAGE_CUBE */ -/* reuse GL_IMAGE_BUFFER */ -/* reuse GL_IMAGE_1D_ARRAY */ -/* reuse GL_IMAGE_2D_ARRAY */ -/* reuse GL_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_INT_IMAGE_1D */ -/* reuse GL_INT_IMAGE_2D */ -/* reuse GL_INT_IMAGE_3D */ -/* reuse GL_INT_IMAGE_2D_RECT */ -/* reuse GL_INT_IMAGE_CUBE */ -/* reuse GL_INT_IMAGE_BUFFER */ -/* reuse GL_INT_IMAGE_1D_ARRAY */ -/* reuse GL_INT_IMAGE_2D_ARRAY */ -/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_1D */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D */ -/* reuse GL_UNSIGNED_INT_IMAGE_3D */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */ -/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */ -/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */ -/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_MAX_IMAGE_SAMPLES */ -/* reuse GL_IMAGE_BINDING_FORMAT */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */ -/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */ -/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */ -/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */ -/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */ -/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */ -/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */ -/* Reuse tokens from ARB_shading_language_packing (none) */ -/* Reuse tokens from ARB_texture_storage */ -/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */ -#endif - -#ifndef GL_ARB_multitexture -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -#endif - -#ifndef GL_ARB_multisample -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -#endif - -#ifndef GL_ARB_texture_env_add -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif - -#ifndef GL_ARB_texture_compression -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif - -#ifndef GL_ARB_point_parameters -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif - -#ifndef GL_ARB_shadow -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#endif - -#ifndef GL_ARB_window_pos -#endif - -#ifndef GL_ARB_vertex_program -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -#endif - -#ifndef GL_ARB_fragment_program -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -#endif - -#ifndef GL_ARB_shader_objects -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#endif - -#ifndef GL_ARB_point_sprite -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif - -#ifndef GL_ARB_texture_float -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD -#endif - -#ifndef GL_ARB_draw_instanced -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_STENCIL_INDEX1 0x8D46 -#define GL_STENCIL_INDEX4 0x8D47 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_STENCIL_INDEX16 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#endif - -#ifndef GL_ARB_framebuffer_object_DEPRECATED -#define GL_INDEX 0x8222 -#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB 0x8DB9 -#endif - -#ifndef GL_ARB_geometry_shader4 -#define GL_LINES_ADJACENCY_ARB 0x000A -#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B -#define GL_TRIANGLES_ADJACENCY_ARB 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 -/* reuse GL_MAX_VARYING_COMPONENTS */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_HALF_FLOAT 0x140B -#endif - -#ifndef GL_ARB_instanced_arrays -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#endif - -#ifndef GL_ARB_texture_buffer_object -#define GL_TEXTURE_BUFFER_ARB 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#endif - -#ifndef GL_ARB_texture_rg -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING 0x85B5 -#endif - -#ifndef GL_ARB_uniform_buffer_object -#define GL_UNIFORM_BUFFER 0x8A11 -#define GL_UNIFORM_BUFFER_BINDING 0x8A28 -#define GL_UNIFORM_BUFFER_START 0x8A29 -#define GL_UNIFORM_BUFFER_SIZE 0x8A2A -#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D -#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E -#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F -#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 -#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 -#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 -#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 -#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 -#define GL_UNIFORM_TYPE 0x8A37 -#define GL_UNIFORM_SIZE 0x8A38 -#define GL_UNIFORM_NAME_LENGTH 0x8A39 -#define GL_UNIFORM_BLOCK_INDEX 0x8A3A -#define GL_UNIFORM_OFFSET 0x8A3B -#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C -#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D -#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E -#define GL_UNIFORM_BLOCK_BINDING 0x8A3F -#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 -#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 -#define GL_INVALID_INDEX 0xFFFFFFFFu -#endif - -#ifndef GL_ARB_compatibility -/* ARB_compatibility just defines tokens from core 3.0 */ -#endif - -#ifndef GL_ARB_copy_buffer -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_READ_BUFFER GL_COPY_READ_BUFFER_BINDING -#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 -#define GL_COPY_WRITE_BUFFER GL_COPY_WRITE_BUFFER_BINDING -#endif - -#ifndef GL_ARB_shader_texture_lod -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_DEPTH_CLAMP 0x864F -#endif - -#ifndef GL_ARB_draw_elements_base_vertex -#endif - -#ifndef GL_ARB_fragment_coord_conventions -#endif - -#ifndef GL_ARB_provoking_vertex -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define GL_LAST_VERTEX_CONVENTION 0x8E4E -#define GL_PROVOKING_VERTEX 0x8E4F -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F -#endif - -#ifndef GL_ARB_sync -#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 -#define GL_OBJECT_TYPE 0x9112 -#define GL_SYNC_CONDITION 0x9113 -#define GL_SYNC_STATUS 0x9114 -#define GL_SYNC_FLAGS 0x9115 -#define GL_SYNC_FENCE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 -#define GL_UNSIGNALED 0x9118 -#define GL_SIGNALED 0x9119 -#define GL_ALREADY_SIGNALED 0x911A -#define GL_TIMEOUT_EXPIRED 0x911B -#define GL_CONDITION_SATISFIED 0x911C -#define GL_WAIT_FAILED 0x911D -#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull -#endif - -#ifndef GL_ARB_texture_multisample -#define GL_SAMPLE_POSITION 0x8E50 -#define GL_SAMPLE_MASK 0x8E51 -#define GL_SAMPLE_MASK_VALUE 0x8E52 -#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#define GL_TEXTURE_SAMPLES 0x9106 -#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define GL_MAX_INTEGER_SAMPLES 0x9110 -#endif - -#ifndef GL_ARB_vertex_array_bgra -/* reuse GL_BGRA */ -#endif - -#ifndef GL_ARB_draw_buffers_blend -#endif - -#ifndef GL_ARB_sample_shading -#define GL_SAMPLE_SHADING_ARB 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 -#endif - -#ifndef GL_ARB_texture_cube_map_array -#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F -#endif - -#ifndef GL_ARB_texture_gather -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F -#endif - -#ifndef GL_ARB_texture_query_lod -#endif - -#ifndef GL_ARB_shading_language_include -#define GL_SHADER_INCLUDE_ARB 0x8DAE -#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 -#define GL_NAMED_STRING_TYPE_ARB 0x8DEA -#endif - -#ifndef GL_ARB_texture_compression_bptc -#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F -#endif - -#ifndef GL_ARB_blend_func_extended -#define GL_SRC1_COLOR 0x88F9 -/* reuse GL_SRC1_ALPHA */ -#define GL_ONE_MINUS_SRC1_COLOR 0x88FA -#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB -#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC -#endif - -#ifndef GL_ARB_explicit_attrib_location -#endif - -#ifndef GL_ARB_occlusion_query2 -#define GL_ANY_SAMPLES_PASSED 0x8C2F -#endif - -#ifndef GL_ARB_sampler_objects -#define GL_SAMPLER_BINDING 0x8919 -#endif - -#ifndef GL_ARB_shader_bit_encoding -#endif - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_RGB10_A2UI 0x906F -#endif - -#ifndef GL_ARB_texture_swizzle -#define GL_TEXTURE_SWIZZLE_R 0x8E42 -#define GL_TEXTURE_SWIZZLE_G 0x8E43 -#define GL_TEXTURE_SWIZZLE_B 0x8E44 -#define GL_TEXTURE_SWIZZLE_A 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 -#endif - -#ifndef GL_ARB_timer_query -#define GL_TIME_ELAPSED 0x88BF -#define GL_TIMESTAMP 0x8E28 -#endif - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */ -#define GL_INT_2_10_10_10_REV 0x8D9F -#endif - -#ifndef GL_ARB_draw_indirect -#define GL_DRAW_INDIRECT_BUFFER 0x8F3F -#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 -#endif - -#ifndef GL_ARB_gpu_shader5 -#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F -#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C -#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D -/* reuse GL_MAX_VERTEX_STREAMS */ -#endif - -#ifndef GL_ARB_gpu_shader_fp64 -/* reuse GL_DOUBLE */ -#define GL_DOUBLE_VEC2 0x8FFC -#define GL_DOUBLE_VEC3 0x8FFD -#define GL_DOUBLE_VEC4 0x8FFE -#define GL_DOUBLE_MAT2 0x8F46 -#define GL_DOUBLE_MAT3 0x8F47 -#define GL_DOUBLE_MAT4 0x8F48 -#define GL_DOUBLE_MAT2x3 0x8F49 -#define GL_DOUBLE_MAT2x4 0x8F4A -#define GL_DOUBLE_MAT3x2 0x8F4B -#define GL_DOUBLE_MAT3x4 0x8F4C -#define GL_DOUBLE_MAT4x2 0x8F4D -#define GL_DOUBLE_MAT4x3 0x8F4E -#endif - -#ifndef GL_ARB_shader_subroutine -#define GL_ACTIVE_SUBROUTINES 0x8DE5 -#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 -#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 -#define GL_MAX_SUBROUTINES 0x8DE7 -#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 -#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A -#define GL_COMPATIBLE_SUBROUTINES 0x8E4B -/* reuse GL_UNIFORM_SIZE */ -/* reuse GL_UNIFORM_NAME_LENGTH */ -#endif - -#ifndef GL_ARB_tessellation_shader -#define GL_PATCHES 0x000E -#define GL_PATCH_VERTICES 0x8E72 -#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 -#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 -#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 -#define GL_TESS_GEN_MODE 0x8E76 -#define GL_TESS_GEN_SPACING 0x8E77 -#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 -#define GL_TESS_GEN_POINT_MODE 0x8E79 -/* reuse GL_TRIANGLES */ -/* reuse GL_QUADS */ -#define GL_ISOLINES 0x8E7A -/* reuse GL_EQUAL */ -#define GL_FRACTIONAL_ODD 0x8E7B -#define GL_FRACTIONAL_EVEN 0x8E7C -/* reuse GL_CCW */ -/* reuse GL_CW */ -#define GL_MAX_PATCH_VERTICES 0x8E7D -#define GL_MAX_TESS_GEN_LEVEL 0x8E7E -#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F -#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 -#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 -#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 -#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 -#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 -#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 -#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 -#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 -#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A -#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C -#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D -#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E -#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 -#define GL_TESS_EVALUATION_SHADER 0x8E87 -#define GL_TESS_CONTROL_SHADER 0x8E88 -#endif - -#ifndef GL_ARB_texture_buffer_object_rgb32 -/* reuse GL_RGB32F */ -/* reuse GL_RGB32UI */ -/* reuse GL_RGB32I */ -#endif - -#ifndef GL_ARB_transform_feedback2 -#define GL_TRANSFORM_FEEDBACK 0x8E22 -#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED GL_TRANSFORM_FEEDBACK_PAUSED -#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE GL_TRANSFORM_FEEDBACK_ACTIVE -#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 -#endif - -#ifndef GL_ARB_transform_feedback3 -#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 -#define GL_MAX_VERTEX_STREAMS 0x8E71 -#endif - -#ifndef GL_ARB_ES2_compatibility -#define GL_FIXED 0x140C -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_RGB565 0x8D62 -#endif - -#ifndef GL_ARB_get_program_binary -#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 -#define GL_PROGRAM_BINARY_LENGTH 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE -#define GL_PROGRAM_BINARY_FORMATS 0x87FF -#endif - -#ifndef GL_ARB_separate_shader_objects -#define GL_VERTEX_SHADER_BIT 0x00000001 -#define GL_FRAGMENT_SHADER_BIT 0x00000002 -#define GL_GEOMETRY_SHADER_BIT 0x00000004 -#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 -#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 -#define GL_ALL_SHADER_BITS 0xFFFFFFFF -#define GL_PROGRAM_SEPARABLE 0x8258 -#define GL_ACTIVE_PROGRAM 0x8259 -#define GL_PROGRAM_PIPELINE_BINDING 0x825A -#endif - -#ifndef GL_ARB_shader_precision -#endif - -#ifndef GL_ARB_vertex_attrib_64bit -/* reuse GL_RGB32I */ -/* reuse GL_DOUBLE_VEC2 */ -/* reuse GL_DOUBLE_VEC3 */ -/* reuse GL_DOUBLE_VEC4 */ -/* reuse GL_DOUBLE_MAT2 */ -/* reuse GL_DOUBLE_MAT3 */ -/* reuse GL_DOUBLE_MAT4 */ -/* reuse GL_DOUBLE_MAT2x3 */ -/* reuse GL_DOUBLE_MAT2x4 */ -/* reuse GL_DOUBLE_MAT3x2 */ -/* reuse GL_DOUBLE_MAT3x4 */ -/* reuse GL_DOUBLE_MAT4x2 */ -/* reuse GL_DOUBLE_MAT4x3 */ -#endif - -#ifndef GL_ARB_viewport_array -/* reuse GL_SCISSOR_BOX */ -/* reuse GL_VIEWPORT */ -/* reuse GL_DEPTH_RANGE */ -/* reuse GL_SCISSOR_TEST */ -#define GL_MAX_VIEWPORTS 0x825B -#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C -#define GL_VIEWPORT_BOUNDS_RANGE 0x825D -#define GL_LAYER_PROVOKING_VERTEX 0x825E -#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F -#define GL_UNDEFINED_VERTEX 0x8260 -/* reuse GL_FIRST_VERTEX_CONVENTION */ -/* reuse GL_LAST_VERTEX_CONVENTION */ -/* reuse GL_PROVOKING_VERTEX */ -#endif - -#ifndef GL_ARB_cl_event -#define GL_SYNC_CL_EVENT_ARB 0x8240 -#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 -#endif - -#ifndef GL_ARB_debug_output -#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 -#define GL_DEBUG_SOURCE_API_ARB 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A -#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B -#define GL_DEBUG_TYPE_ERROR_ARB 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E -#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 -#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 -#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 -#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 -#endif - -#ifndef GL_ARB_robustness -/* reuse GL_NO_ERROR */ -#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 -#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 -#endif - -#ifndef GL_ARB_shader_stencil_export -#endif - -#ifndef GL_ARB_base_instance -#endif - -#ifndef GL_ARB_shading_language_420pack -#endif - -#ifndef GL_ARB_transform_feedback_instanced -#endif - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 -#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 -#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 -#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A -#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B -#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C -#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D -#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E -#endif - -#ifndef GL_ARB_conservative_depth -#endif - -#ifndef GL_ARB_internalformat_query -#define GL_NUM_SAMPLE_COUNTS 0x9380 -#endif - -#ifndef GL_ARB_map_buffer_alignment -#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC -#endif - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 -#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 -#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 -#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 -#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB -#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE -#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF -#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 -#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 -#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 -#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 -#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 -#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC -#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 -#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA -#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB -#endif - -#ifndef GL_ARB_shader_image_load_store -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 -#define GL_COMMAND_BARRIER_BIT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 -#define GL_ALL_BARRIER_BITS 0xFFFFFFFF -#define GL_MAX_IMAGE_UNITS 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 -#define GL_IMAGE_BINDING_NAME 0x8F3A -#define GL_IMAGE_BINDING_LEVEL 0x8F3B -#define GL_IMAGE_BINDING_LAYERED 0x8F3C -#define GL_IMAGE_BINDING_LAYER 0x8F3D -#define GL_IMAGE_BINDING_ACCESS 0x8F3E -#define GL_IMAGE_1D 0x904C -#define GL_IMAGE_2D 0x904D -#define GL_IMAGE_3D 0x904E -#define GL_IMAGE_2D_RECT 0x904F -#define GL_IMAGE_CUBE 0x9050 -#define GL_IMAGE_BUFFER 0x9051 -#define GL_IMAGE_1D_ARRAY 0x9052 -#define GL_IMAGE_2D_ARRAY 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 -#define GL_INT_IMAGE_1D 0x9057 -#define GL_INT_IMAGE_2D 0x9058 -#define GL_INT_IMAGE_3D 0x9059 -#define GL_INT_IMAGE_2D_RECT 0x905A -#define GL_INT_IMAGE_CUBE 0x905B -#define GL_INT_IMAGE_BUFFER 0x905C -#define GL_INT_IMAGE_1D_ARRAY 0x905D -#define GL_INT_IMAGE_2D_ARRAY 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C -#define GL_MAX_IMAGE_SAMPLES 0x906D -#define GL_IMAGE_BINDING_FORMAT 0x906E -#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 -#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA -#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB -#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC -#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD -#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE -#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF -#endif - -#ifndef GL_ARB_shading_language_packing -#endif - -#ifndef GL_ARB_texture_storage -#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F -#endif - -#ifndef GL_EXT_abgr -#define GL_ABGR_EXT 0x8000 -#endif - -#ifndef GL_EXT_blend_color -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -#endif - -#ifndef GL_EXT_texture -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif - -#ifndef GL_EXT_texture3D -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -#endif - -#ifndef GL_EXT_subtexture -#endif - -#ifndef GL_EXT_copy_texture -#endif - -#ifndef GL_EXT_histogram -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -#endif - -#ifndef GL_EXT_convolution -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -#endif - -#ifndef GL_SGI_color_matrix -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif - -#ifndef GL_SGI_color_table -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -#endif - -#ifndef GL_SGIS_texture4D -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif - -#ifndef GL_EXT_cmyka -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif - -#ifndef GL_EXT_texture_object -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif - -#ifndef GL_SGIS_multisample -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif - -#ifndef GL_EXT_vertex_array -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#endif - -#ifndef GL_EXT_misc_attribute -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif - -#ifndef GL_SGIX_shadow -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif - -#ifndef GL_EXT_blend_logic_op -#endif - -#ifndef GL_SGIX_interlace -#define GL_INTERLACE_SGIX 0x8094 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif - -#ifndef GL_SGIS_texture_select -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif - -#ifndef GL_EXT_point_parameters -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -#endif - -#ifndef GL_SGIX_instruments -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif - -#ifndef GL_SGIX_framezoom -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#endif - -#ifndef GL_FfdMaskSGIX -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -#endif - -#ifndef GL_SGIX_flush_raster -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif - -#ifndef GL_HP_image_transform -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif - -#ifndef GL_INGR_palette_buffer -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif - -#ifndef GL_EXT_color_subtable -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_LIST_PRIORITY_SGIX 0x8182 -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif - -#ifndef GL_EXT_index_texture -#endif - -#ifndef GL_EXT_index_material -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -#endif - -#ifndef GL_EXT_index_func -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -#endif - -#ifndef GL_WIN_phong_shading -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif - -#ifndef GL_WIN_specular_fog -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif - -#ifndef GL_EXT_light_texture -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -/* reuse GL_FRAGMENT_DEPTH_EXT */ -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif - -#ifndef GL_SGIX_impact_pixel_texture -#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 -#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 -#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 -#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 -#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 -#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 -#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A -#endif - -#ifndef GL_EXT_bgra -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif - -#ifndef GL_SGIX_async -#define GL_ASYNC_MARKER_SGIX 0x8329 -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif - -#ifndef GL_INTEL_texture_scissor -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -#endif - -#ifndef GL_HP_occlusion_test -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif - -#ifndef GL_EXT_secondary_color -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -#endif - -#ifndef GL_EXT_multi_draw_arrays -#endif - -#ifndef GL_EXT_fog_coord -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_FOG_SCALE_SGIX 0x81FC -#define GL_FOG_SCALE_VALUE_SGIX 0x81FD -#endif - -#ifndef GL_SUNX_constant_data -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -#endif - -#ifndef GL_SUN_global_alpha -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -#endif - -#ifndef GL_SUN_triangle_list -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -#endif - -#ifndef GL_SUN_vertex -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -#endif - -#ifndef GL_INGR_color_clamp -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INTERLACE_READ_INGR 0x8568 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif - -#ifndef GL_EXT_texture_cube_map -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif - -#ifndef GL_EXT_texture_env_add -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT GL_MODELVIEW -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -#endif - -#ifndef GL_NV_register_combiners -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -/* reuse GL_TEXTURE0_ARB */ -/* reuse GL_TEXTURE1_ARB */ -/* reuse GL_ZERO */ -/* reuse GL_NONE */ -/* reuse GL_FOG */ -#endif - -#ifndef GL_NV_fog_distance -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -/* reuse GL_EYE_PLANE */ -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif - -#ifndef GL_NV_blend_square -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif - -#ifndef GL_MESA_resize_buffers -#endif - -#ifndef GL_MESA_window_pos -#endif - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_CULL_VERTEX_IBM 103050 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -#endif - -#ifndef GL_SGIX_subsample -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif - -#ifndef GL_SGI_depth_pass_instrument -#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 -#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 -#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif - -#ifndef GL_3DFX_tbuffer -#endif - -#ifndef GL_EXT_multisample -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif - -#ifndef GL_SGIX_resample -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif - -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif - -#ifndef GL_NV_evaluators -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -#endif - -#ifndef GL_NV_texture_compression_vtc -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif - -#ifndef GL_NV_texture_shader -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV -#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV -#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif - -#ifndef GL_NV_vertex_program -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif - -#ifndef GL_OML_interlace -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif - -#ifndef GL_OML_subsample -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif - -#ifndef GL_OML_resample -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -#endif - -#ifndef GL_ATI_element_array -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -#endif - -#ifndef GL_SUN_mesh_array -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_DEPTH_CLAMP_NV 0x864F -#endif - -#ifndef GL_NV_occlusion_query -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#endif - -#ifndef GL_NV_point_sprite -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif - -#ifndef GL_NV_vertex_program1_1 -#endif - -#ifndef GL_EXT_shadow_funcs -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif - -#ifndef GL_APPLE_element_array -#define GL_ELEMENT_ARRAY_APPLE 0x8A0C -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E -#endif - -#ifndef GL_APPLE_fence -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CLIENT_APPLE 0x85B4 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -#ifndef GL_S3_s3tc -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif - -#ifndef GL_ATI_texture_float -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif - -#ifndef GL_NV_float_buffer -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif - -#ifndef GL_NV_fragment_program -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -#endif - -#ifndef GL_NV_half_float -#define GL_HALF_FLOAT_NV 0x140B -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -#endif - -#ifndef GL_NV_primitive_restart -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif - -#ifndef GL_NV_vertex_program2 -#endif - -#ifndef GL_ATI_map_object_buffer -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#endif - -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_BLEND_EQUATION_RGB_EXT 0x8009 -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -#endif - -#ifndef GL_MESA_pack_invert -#define GL_PACK_INVERT_MESA 0x8758 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif - -#ifndef GL_NV_fragment_program_option -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif - -#ifndef GL_NV_vertex_program2_option -/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ -/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ -#endif - -#ifndef GL_NV_vertex_program3 -/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#endif - -#ifndef GL_GREMEDY_string_marker -#endif - -#ifndef GL_EXT_packed_depth_stencil -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 -#endif - -#ifndef GL_EXT_stencil_clear_tag -#define GL_STENCIL_TAG_BITS_EXT 0x88F2 -#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 -#endif - -#ifndef GL_EXT_texture_sRGB -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif - -#ifndef GL_EXT_framebuffer_blit -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA -#endif - -#ifndef GL_EXT_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -#endif - -#ifndef GL_MESAX_texture_stack -#define GL_TEXTURE_1D_STACK_MESAX 0x8759 -#define GL_TEXTURE_2D_STACK_MESAX 0x875A -#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B -#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C -#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D -#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E -#endif - -#ifndef GL_EXT_timer_query -#define GL_TIME_ELAPSED_EXT 0x88BF -#endif - -#ifndef GL_EXT_gpu_program_parameters -#endif - -#ifndef GL_APPLE_flush_buffer_range -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 -#endif - -#ifndef GL_NV_gpu_program4 -#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 -#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 -#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 -#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 -#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 -#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 -#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 -#endif - -#ifndef GL_NV_geometry_program4 -#define GL_LINES_ADJACENCY_EXT 0x000A -#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B -#define GL_TRIANGLES_ADJACENCY_EXT 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D -#define GL_GEOMETRY_PROGRAM_NV 0x8C26 -#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 -#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 -#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 -#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 -#endif - -#ifndef GL_EXT_geometry_shader4 -#define GL_GEOMETRY_SHADER_EXT 0x8DD9 -/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */ -/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */ -/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */ -/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */ -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE -#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 -/* reuse GL_LINES_ADJACENCY_EXT */ -/* reuse GL_LINE_STRIP_ADJACENCY_EXT */ -/* reuse GL_TRIANGLES_ADJACENCY_EXT */ -/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ -/* reuse GL_PROGRAM_POINT_SIZE_EXT */ -#endif - -#ifndef GL_NV_vertex_program4 -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD -#endif - -#ifndef GL_EXT_gpu_shader4 -#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 -#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 -#define GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 -#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 -#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 -#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 -#define GL_INT_SAMPLER_1D_EXT 0x8DC9 -#define GL_INT_SAMPLER_2D_EXT 0x8DCA -#define GL_INT_SAMPLER_3D_EXT 0x8DCB -#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC -#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD -#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF -#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 -#endif - -#ifndef GL_EXT_draw_instanced -#endif - -#ifndef GL_EXT_packed_float -#define GL_R11F_G11F_B10F_EXT 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B -#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C -#endif - -#ifndef GL_EXT_texture_array -#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D -#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF -#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ -#endif - -#ifndef GL_EXT_texture_buffer_object -#define GL_TEXTURE_BUFFER_EXT 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E -#endif - -#ifndef GL_EXT_texture_compression_latc -#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 -#endif - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE -#endif - -#ifndef GL_EXT_texture_shared_exponent -#define GL_RGB9_E5_EXT 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E -#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F -#endif - -#ifndef GL_NV_depth_buffer_float -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB -#define GL_DEPTH32F_STENCIL8_NV 0x8DAC -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD -#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF -#endif - -#ifndef GL_NV_fragment_program4 -#endif - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB -#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 -#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 -#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA -#endif - -#ifndef GL_NV_geometry_shader4 -#endif - -#ifndef GL_NV_parameter_buffer_object -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 -#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 -#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 -#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 -#endif - -#ifndef GL_EXT_draw_buffers2 -#endif - -#ifndef GL_NV_transform_feedback -#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 -#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 -#define GL_TEXTURE_COORD_NV 0x8C79 -#define GL_CLIP_DISTANCE_NV 0x8C7A -#define GL_VERTEX_ID_NV 0x8C7B -#define GL_PRIMITIVE_ID_NV 0x8C7C -#define GL_GENERIC_ATTRIB_NV 0x8C7D -#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 -#define GL_ACTIVE_VARYINGS_NV 0x8C81 -#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 -#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 -#define GL_PRIMITIVES_GENERATED_NV 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 -#define GL_RASTERIZER_DISCARD_NV 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C -#define GL_SEPARATE_ATTRIBS_NV 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F -#define GL_LAYER_NV 0x8DAA -#define GL_NEXT_BUFFER_NV -2 -#define GL_SKIP_COMPONENTS4_NV -3 -#define GL_SKIP_COMPONENTS3_NV -4 -#define GL_SKIP_COMPONENTS2_NV -5 -#define GL_SKIP_COMPONENTS1_NV -6 -#endif - -#ifndef GL_EXT_bindable_uniform -#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 -#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 -#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 -#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED -#define GL_UNIFORM_BUFFER_EXT 0x8DEE -#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF -#endif - -#ifndef GL_EXT_texture_integer -#define GL_RGBA32UI_EXT 0x8D70 -#define GL_RGB32UI_EXT 0x8D71 -#define GL_ALPHA32UI_EXT 0x8D72 -#define GL_INTENSITY32UI_EXT 0x8D73 -#define GL_LUMINANCE32UI_EXT 0x8D74 -#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 -#define GL_RGBA16UI_EXT 0x8D76 -#define GL_RGB16UI_EXT 0x8D77 -#define GL_ALPHA16UI_EXT 0x8D78 -#define GL_INTENSITY16UI_EXT 0x8D79 -#define GL_LUMINANCE16UI_EXT 0x8D7A -#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B -#define GL_RGBA8UI_EXT 0x8D7C -#define GL_RGB8UI_EXT 0x8D7D -#define GL_ALPHA8UI_EXT 0x8D7E -#define GL_INTENSITY8UI_EXT 0x8D7F -#define GL_LUMINANCE8UI_EXT 0x8D80 -#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 -#define GL_RGBA32I_EXT 0x8D82 -#define GL_RGB32I_EXT 0x8D83 -#define GL_ALPHA32I_EXT 0x8D84 -#define GL_INTENSITY32I_EXT 0x8D85 -#define GL_LUMINANCE32I_EXT 0x8D86 -#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 -#define GL_RGBA16I_EXT 0x8D88 -#define GL_RGB16I_EXT 0x8D89 -#define GL_ALPHA16I_EXT 0x8D8A -#define GL_INTENSITY16I_EXT 0x8D8B -#define GL_LUMINANCE16I_EXT 0x8D8C -#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D -#define GL_RGBA8I_EXT 0x8D8E -#define GL_RGB8I_EXT 0x8D8F -#define GL_ALPHA8I_EXT 0x8D90 -#define GL_INTENSITY8I_EXT 0x8D91 -#define GL_LUMINANCE8I_EXT 0x8D92 -#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 -#define GL_RED_INTEGER_EXT 0x8D94 -#define GL_GREEN_INTEGER_EXT 0x8D95 -#define GL_BLUE_INTEGER_EXT 0x8D96 -#define GL_ALPHA_INTEGER_EXT 0x8D97 -#define GL_RGB_INTEGER_EXT 0x8D98 -#define GL_RGBA_INTEGER_EXT 0x8D99 -#define GL_BGR_INTEGER_EXT 0x8D9A -#define GL_BGRA_INTEGER_EXT 0x8D9B -#define GL_LUMINANCE_INTEGER_EXT 0x8D9C -#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D -#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E -#endif - -#ifndef GL_GREMEDY_frame_terminator -#endif - -#ifndef GL_NV_conditional_render -#define GL_QUERY_WAIT_NV 0x8E13 -#define GL_QUERY_NO_WAIT_NV 0x8E14 -#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 -#endif - -#ifndef GL_NV_present_video -#define GL_FRAME_NV 0x8E26 -#define GL_FIELDS_NV 0x8E27 -#define GL_CURRENT_TIME_NV 0x8E28 -#define GL_NUM_FILL_STREAMS_NV 0x8E29 -#define GL_PRESENT_TIME_NV 0x8E2A -#define GL_PRESENT_DURATION_NV 0x8E2B -#endif - -#ifndef GL_EXT_transform_feedback -#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F -#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C -#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D -#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 -#define GL_RASTERIZER_DISCARD_EXT 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 -#endif - -#ifndef GL_EXT_direct_state_access -#define GL_PROGRAM_MATRIX_EXT 0x8E2D -#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E -#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F -#endif - -#ifndef GL_EXT_vertex_array_bgra -/* reuse GL_BGRA */ -#endif - -#ifndef GL_EXT_texture_swizzle -#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 -#endif - -#ifndef GL_NV_explicit_multisample -#define GL_SAMPLE_POSITION_NV 0x8E50 -#define GL_SAMPLE_MASK_NV 0x8E51 -#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 -#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 -#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 -#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 -#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 -#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 -#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 -#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 -#endif - -#ifndef GL_NV_transform_feedback2 -#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 -#endif - -#ifndef GL_ATI_meminfo -#define GL_VBO_FREE_MEMORY_ATI 0x87FB -#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC -#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD -#endif - -#ifndef GL_AMD_performance_monitor -#define GL_COUNTER_TYPE_AMD 0x8BC0 -#define GL_COUNTER_RANGE_AMD 0x8BC1 -#define GL_UNSIGNED_INT64_AMD 0x8BC2 -#define GL_PERCENTAGE_AMD 0x8BC3 -#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define GL_PERFMON_RESULT_AMD 0x8BC6 -#endif - -#ifndef GL_AMD_texture_texture4 -#endif - -#ifndef GL_AMD_vertex_shader_tesselator -#define GL_SAMPLER_BUFFER_AMD 0x9001 -#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 -#define GL_TESSELLATION_MODE_AMD 0x9004 -#define GL_TESSELLATION_FACTOR_AMD 0x9005 -#define GL_DISCRETE_AMD 0x9006 -#define GL_CONTINUOUS_AMD 0x9007 -#endif - -#ifndef GL_EXT_provoking_vertex -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D -#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E -#define GL_PROVOKING_VERTEX_EXT 0x8E4F -#endif - -#ifndef GL_EXT_texture_snorm -#define GL_ALPHA_SNORM 0x9010 -#define GL_LUMINANCE_SNORM 0x9011 -#define GL_LUMINANCE_ALPHA_SNORM 0x9012 -#define GL_INTENSITY_SNORM 0x9013 -#define GL_ALPHA8_SNORM 0x9014 -#define GL_LUMINANCE8_SNORM 0x9015 -#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 -#define GL_INTENSITY8_SNORM 0x9017 -#define GL_ALPHA16_SNORM 0x9018 -#define GL_LUMINANCE16_SNORM 0x9019 -#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A -#define GL_INTENSITY16_SNORM 0x901B -/* reuse GL_RED_SNORM */ -/* reuse GL_RG_SNORM */ -/* reuse GL_RGB_SNORM */ -/* reuse GL_RGBA_SNORM */ -/* reuse GL_R8_SNORM */ -/* reuse GL_RG8_SNORM */ -/* reuse GL_RGB8_SNORM */ -/* reuse GL_RGBA8_SNORM */ -/* reuse GL_R16_SNORM */ -/* reuse GL_RG16_SNORM */ -/* reuse GL_RGB16_SNORM */ -/* reuse GL_RGBA16_SNORM */ -/* reuse GL_SIGNED_NORMALIZED */ -#endif - -#ifndef GL_AMD_draw_buffers_blend -#endif - -#ifndef GL_APPLE_texture_range -#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 -#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 -#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC -#define GL_STORAGE_PRIVATE_APPLE 0x85BD -/* reuse GL_STORAGE_CACHED_APPLE */ -/* reuse GL_STORAGE_SHARED_APPLE */ -#endif - -#ifndef GL_APPLE_float_pixels -#define GL_HALF_APPLE 0x140B -#define GL_RGBA_FLOAT32_APPLE 0x8814 -#define GL_RGB_FLOAT32_APPLE 0x8815 -#define GL_ALPHA_FLOAT32_APPLE 0x8816 -#define GL_INTENSITY_FLOAT32_APPLE 0x8817 -#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 -#define GL_RGBA_FLOAT16_APPLE 0x881A -#define GL_RGB_FLOAT16_APPLE 0x881B -#define GL_ALPHA_FLOAT16_APPLE 0x881C -#define GL_INTENSITY_FLOAT16_APPLE 0x881D -#define GL_LUMINANCE_FLOAT16_APPLE 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F -#define GL_COLOR_FLOAT_APPLE 0x8A0F -#endif - -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 -#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 -#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 -#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 -#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 -#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 -#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 -#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 -#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 -#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 -#endif - -#ifndef GL_APPLE_aux_depth_stencil -#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 -#endif - -#ifndef GL_APPLE_object_purgeable -#define GL_BUFFER_OBJECT_APPLE 0x85B3 -#define GL_RELEASED_APPLE 0x8A19 -#define GL_VOLATILE_APPLE 0x8A1A -#define GL_RETAINED_APPLE 0x8A1B -#define GL_UNDEFINED_APPLE 0x8A1C -#define GL_PURGEABLE_APPLE 0x8A1D -#endif - -#ifndef GL_APPLE_row_bytes -#define GL_PACK_ROW_BYTES_APPLE 0x8A15 -#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 -#endif - -#ifndef GL_APPLE_rgb_422 -#define GL_RGB_422_APPLE 0x8A1F -/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */ -/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */ -#endif - -#ifndef GL_NV_video_capture -#define GL_VIDEO_BUFFER_NV 0x9020 -#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 -#define GL_FIELD_UPPER_NV 0x9022 -#define GL_FIELD_LOWER_NV 0x9023 -#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 -#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 -#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 -#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 -#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 -#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 -#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A -#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B -#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C -#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D -#define GL_PARTIAL_SUCCESS_NV 0x902E -#define GL_SUCCESS_NV 0x902F -#define GL_FAILURE_NV 0x9030 -#define GL_YCBYCR8_422_NV 0x9031 -#define GL_YCBAYCR8A_4224_NV 0x9032 -#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 -#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 -#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 -#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 -#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 -#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 -#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 -#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A -#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B -#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C -#endif - -#ifndef GL_NV_copy_image -#endif - -#ifndef GL_EXT_separate_shader_objects -#define GL_ACTIVE_PROGRAM_EXT 0x8B8D -#endif - -#ifndef GL_NV_parameter_buffer_object2 -#endif - -#ifndef GL_NV_shader_buffer_load -#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D -#define GL_GPU_ADDRESS_NV 0x8F34 -#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 -#endif - -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E -#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F -#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 -#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 -#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 -#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 -#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 -#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 -#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 -#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 -#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 -#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 -#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A -#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B -#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C -#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D -#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E -#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F -#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 -#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 -#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 -#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 -#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 -#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 -#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 -#endif - -#ifndef GL_NV_texture_barrier -#endif - -#ifndef GL_AMD_shader_stencil_export -#endif - -#ifndef GL_AMD_seamless_cubemap_per_texture -/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ -#endif - -#ifndef GL_AMD_conservative_depth -#endif - -#ifndef GL_EXT_shader_image_load_store -#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 -#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A -#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B -#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C -#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D -#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E -#define GL_IMAGE_1D_EXT 0x904C -#define GL_IMAGE_2D_EXT 0x904D -#define GL_IMAGE_3D_EXT 0x904E -#define GL_IMAGE_2D_RECT_EXT 0x904F -#define GL_IMAGE_CUBE_EXT 0x9050 -#define GL_IMAGE_BUFFER_EXT 0x9051 -#define GL_IMAGE_1D_ARRAY_EXT 0x9052 -#define GL_IMAGE_2D_ARRAY_EXT 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 -#define GL_INT_IMAGE_1D_EXT 0x9057 -#define GL_INT_IMAGE_2D_EXT 0x9058 -#define GL_INT_IMAGE_3D_EXT 0x9059 -#define GL_INT_IMAGE_2D_RECT_EXT 0x905A -#define GL_INT_IMAGE_CUBE_EXT 0x905B -#define GL_INT_IMAGE_BUFFER_EXT 0x905C -#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D -#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C -#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D -#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 -#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 -#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF -#endif - -#ifndef GL_EXT_vertex_attrib_64bit -/* reuse GL_DOUBLE */ -#define GL_DOUBLE_VEC2_EXT 0x8FFC -#define GL_DOUBLE_VEC3_EXT 0x8FFD -#define GL_DOUBLE_VEC4_EXT 0x8FFE -#define GL_DOUBLE_MAT2_EXT 0x8F46 -#define GL_DOUBLE_MAT3_EXT 0x8F47 -#define GL_DOUBLE_MAT4_EXT 0x8F48 -#define GL_DOUBLE_MAT2x3_EXT 0x8F49 -#define GL_DOUBLE_MAT2x4_EXT 0x8F4A -#define GL_DOUBLE_MAT3x2_EXT 0x8F4B -#define GL_DOUBLE_MAT3x4_EXT 0x8F4C -#define GL_DOUBLE_MAT4x2_EXT 0x8F4D -#define GL_DOUBLE_MAT4x3_EXT 0x8F4E -#endif - -#ifndef GL_NV_gpu_program5 -#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C -#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F -#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 -#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 -#endif - -#ifndef GL_NV_gpu_shader5 -#define GL_INT64_NV 0x140E -#define GL_UNSIGNED_INT64_NV 0x140F -#define GL_INT8_NV 0x8FE0 -#define GL_INT8_VEC2_NV 0x8FE1 -#define GL_INT8_VEC3_NV 0x8FE2 -#define GL_INT8_VEC4_NV 0x8FE3 -#define GL_INT16_NV 0x8FE4 -#define GL_INT16_VEC2_NV 0x8FE5 -#define GL_INT16_VEC3_NV 0x8FE6 -#define GL_INT16_VEC4_NV 0x8FE7 -#define GL_INT64_VEC2_NV 0x8FE9 -#define GL_INT64_VEC3_NV 0x8FEA -#define GL_INT64_VEC4_NV 0x8FEB -#define GL_UNSIGNED_INT8_NV 0x8FEC -#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED -#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE -#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF -#define GL_UNSIGNED_INT16_NV 0x8FF0 -#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 -#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 -#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 -#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 -#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 -#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 -#define GL_FLOAT16_NV 0x8FF8 -#define GL_FLOAT16_VEC2_NV 0x8FF9 -#define GL_FLOAT16_VEC3_NV 0x8FFA -#define GL_FLOAT16_VEC4_NV 0x8FFB -/* reuse GL_PATCHES */ -#endif - -#ifndef GL_NV_shader_buffer_store -#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 -/* reuse GL_READ_WRITE */ -/* reuse GL_WRITE_ONLY */ -#endif - -#ifndef GL_NV_tessellation_program5 -#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 -#define GL_TESS_CONTROL_PROGRAM_NV 0x891E -#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F -#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 -#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 -#endif - -#ifndef GL_NV_vertex_attrib_integer_64bit -/* reuse GL_INT64_NV */ -/* reuse GL_UNSIGNED_INT64_NV */ -#endif - -#ifndef GL_NV_multisample_coverage -#define GL_COVERAGE_SAMPLES_NV 0x80A9 -#define GL_COLOR_SAMPLES_NV 0x8E20 -#endif - -#ifndef GL_AMD_name_gen_delete -#define GL_DATA_BUFFER_AMD 0x9151 -#define GL_PERFORMANCE_MONITOR_AMD 0x9152 -#define GL_QUERY_OBJECT_AMD 0x9153 -#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 -#define GL_SAMPLER_OBJECT_AMD 0x9155 -#endif - -#ifndef GL_AMD_debug_output -#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 -#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 -#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 -#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A -#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B -#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C -#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D -#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E -#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F -#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 -#endif - -#ifndef GL_NV_vdpau_interop -#define GL_SURFACE_STATE_NV 0x86EB -#define GL_SURFACE_REGISTERED_NV 0x86FD -#define GL_SURFACE_MAPPED_NV 0x8700 -#define GL_WRITE_DISCARD_NV 0x88BE -#endif - -#ifndef GL_AMD_transform_feedback3_lines_triangles -#endif - -#ifndef GL_AMD_depth_clamp_separate -#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E -#define GL_DEPTH_CLAMP_FAR_AMD 0x901F -#endif - -#ifndef GL_EXT_texture_sRGB_decode -#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 -#define GL_DECODE_EXT 0x8A49 -#define GL_SKIP_DECODE_EXT 0x8A4A -#endif - -#ifndef GL_NV_texture_multisample -#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 -#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 -#endif - -#ifndef GL_AMD_blend_minmax_factor -#define GL_FACTOR_MIN_AMD 0x901C -#define GL_FACTOR_MAX_AMD 0x901D -#endif - -#ifndef GL_AMD_sample_positions -#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F -#endif - -#ifndef GL_EXT_x11_sync_object -#define GL_SYNC_X11_FENCE_EXT 0x90E1 -#endif - -#ifndef GL_AMD_multi_draw_indirect -#endif - -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA -#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB -#endif - -#ifndef GL_NV_path_rendering -#define GL_PATH_FORMAT_SVG_NV 0x9070 -#define GL_PATH_FORMAT_PS_NV 0x9071 -#define GL_STANDARD_FONT_NAME_NV 0x9072 -#define GL_SYSTEM_FONT_NAME_NV 0x9073 -#define GL_FILE_NAME_NV 0x9074 -#define GL_PATH_STROKE_WIDTH_NV 0x9075 -#define GL_PATH_END_CAPS_NV 0x9076 -#define GL_PATH_INITIAL_END_CAP_NV 0x9077 -#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 -#define GL_PATH_JOIN_STYLE_NV 0x9079 -#define GL_PATH_MITER_LIMIT_NV 0x907A -#define GL_PATH_DASH_CAPS_NV 0x907B -#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C -#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D -#define GL_PATH_DASH_OFFSET_NV 0x907E -#define GL_PATH_CLIENT_LENGTH_NV 0x907F -#define GL_PATH_FILL_MODE_NV 0x9080 -#define GL_PATH_FILL_MASK_NV 0x9081 -#define GL_PATH_FILL_COVER_MODE_NV 0x9082 -#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 -#define GL_PATH_STROKE_MASK_NV 0x9084 -#define GL_PATH_SAMPLE_QUALITY_NV 0x9085 -#define GL_PATH_STROKE_BOUND_NV 0x9086 -#define GL_PATH_STROKE_OVERSAMPLE_COUNT_NV 0x9087 -#define GL_COUNT_UP_NV 0x9088 -#define GL_COUNT_DOWN_NV 0x9089 -#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A -#define GL_CONVEX_HULL_NV 0x908B -#define GL_MULTI_HULLS_NV 0x908C -#define GL_BOUNDING_BOX_NV 0x908D -#define GL_TRANSLATE_X_NV 0x908E -#define GL_TRANSLATE_Y_NV 0x908F -#define GL_TRANSLATE_2D_NV 0x9090 -#define GL_TRANSLATE_3D_NV 0x9091 -#define GL_AFFINE_2D_NV 0x9092 -#define GL_PROJECTIVE_2D_NV 0x9093 -#define GL_AFFINE_3D_NV 0x9094 -#define GL_PROJECTIVE_3D_NV 0x9095 -#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 -#define GL_TRANSPOSE_PROJECTIVE_2D_NV 0x9097 -#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 -#define GL_TRANSPOSE_PROJECTIVE_3D_NV 0x9099 -#define GL_UTF8_NV 0x909A -#define GL_UTF16_NV 0x909B -#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C -#define GL_PATH_COMMAND_COUNT_NV 0x909D -#define GL_PATH_COORD_COUNT_NV 0x909E -#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F -#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 -#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 -#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 -#define GL_SQUARE_NV 0x90A3 -#define GL_ROUND_NV 0x90A4 -#define GL_TRIANGULAR_NV 0x90A5 -#define GL_BEVEL_NV 0x90A6 -#define GL_MITER_REVERT_NV 0x90A7 -#define GL_MITER_TRUNCATE_NV 0x90A8 -#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 -#define GL_USE_MISSING_GLYPH_NV 0x90AA -#define GL_PATH_ERROR_POSITION_NV 0x90AB -#define GL_PATH_FOG_GEN_MODE_NV 0x90AC -#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD -#define GL_ADJACENT_PAIRS_NV 0x90AE -#define GL_FIRST_TO_REST_NV 0x90AF -#define GL_PATH_GEN_MODE_NV 0x90B0 -#define GL_PATH_GEN_COEFF_NV 0x90B1 -#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 -#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 -#define GL_PATH_STENCIL_FUNC_NV 0x90B7 -#define GL_PATH_STENCIL_REF_NV 0x90B8 -#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 -#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD -#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE -#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF -#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 -#define GL_MOVE_TO_RESETS_NV 0x90B5 -#define GL_MOVE_TO_CONTINUES_NV 0x90B6 -#define GL_CLOSE_PATH_NV 0x00 -#define GL_MOVE_TO_NV 0x02 -#define GL_RELATIVE_MOVE_TO_NV 0x03 -#define GL_LINE_TO_NV 0x04 -#define GL_RELATIVE_LINE_TO_NV 0x05 -#define GL_HORIZONTAL_LINE_TO_NV 0x06 -#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 -#define GL_VERTICAL_LINE_TO_NV 0x08 -#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 -#define GL_QUADRATIC_CURVE_TO_NV 0x0A -#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B -#define GL_CUBIC_CURVE_TO_NV 0x0C -#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D -#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E -#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F -#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 -#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 -#define GL_SMALL_CCW_ARC_TO_NV 0x12 -#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 -#define GL_SMALL_CW_ARC_TO_NV 0x14 -#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 -#define GL_LARGE_CCW_ARC_TO_NV 0x16 -#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 -#define GL_LARGE_CW_ARC_TO_NV 0x18 -#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 -#define GL_RESTART_PATH_NV 0xF0 -#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 -#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 -#define GL_RECT_NV 0xF6 -#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 -#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA -#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC -#define GL_ARC_TO_NV 0xFE -#define GL_RELATIVE_ARC_TO_NV 0xFF -#define GL_BOLD_BIT_NV 0x01 -#define GL_ITALIC_BIT_NV 0x02 -#define GL_GLYPH_WIDTH_BIT_NV 0x01 -#define GL_GLYPH_HEIGHT_BIT_NV 0x02 -#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 -#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 -#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 -#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 -#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 -#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 -#define GL_GLYPH_HAS_KERNING_NV 0x100 -#define GL_FONT_X_MIN_BOUNDS_NV 0x00010000 -#define GL_FONT_Y_MIN_BOUNDS_NV 0x00020000 -#define GL_FONT_X_MAX_BOUNDS_NV 0x00040000 -#define GL_FONT_Y_MAX_BOUNDS_NV 0x00080000 -#define GL_FONT_UNITS_PER_EM_NV 0x00100000 -#define GL_FONT_ASCENDER_NV 0x00200000 -#define GL_FONT_DESCENDER_NV 0x00400000 -#define GL_FONT_HEIGHT_NV 0x00800000 -#define GL_FONT_MAX_ADVANCE_WIDTH_NV 0x01000000 -#define GL_FONT_MAX_ADVANCE_HEIGHT_NV 0x02000000 -#define GL_FONT_UNDERLINE_POSITION_NV 0x04000000 -#define GL_FONT_UNDERLINE_THICKNESS_NV 0x08000000 -#define GL_FONT_HAS_KERNING_NV 0x10000000 -#endif - -#ifndef GL_AMD_pinned_memory -#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 -#endif - -#ifndef GL_AMD_stencil_operation_extended -#define GL_SET_AMD 0x874A -#define GL_REPLACE_VALUE_AMD 0x874B -#define GL_STENCIL_OP_VALUE_AMD 0x874C -#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D -#endif - -#ifndef GL_AMD_vertex_shader_viewport_index -#endif - -#ifndef GL_AMD_vertex_shader_layer -#endif - -#ifndef GL_NV_bindless_texture -#endif - -#ifndef GL_NV_shader_atomic_float -#endif - - -/*************************************************************/ - -#include -#ifndef GL_VERSION_2_0 -/* GL type for program/shader text */ -typedef char GLchar; -#endif - -#ifndef GL_VERSION_1_5 -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -#endif - -#ifndef GL_ARB_vertex_buffer_object -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for program/shader text and shader object handles */ -typedef char GLcharARB; -typedef unsigned int GLhandleARB; -#endif - -/* GL type for "half" precision (s10e5) float data in host memory */ -#ifndef GL_ARB_half_float_pixel -typedef unsigned short GLhalfARB; -#endif - -#ifndef GL_NV_half_float -typedef unsigned short GLhalfNV; -#endif - -#ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glxext.h, so must be protected */ -#define GLEXT_64_TYPES_DEFINED -/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ -/* (as used in the GL_EXT_timer_query extension). */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include -#elif defined(__sun__) || defined(__digital__) -#include -#if defined(__STDC__) -#if defined(__arch64__) || defined(_LP64) -typedef long int int64_t; -typedef unsigned long int uint64_t; -#else -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#endif /* __arch64__ */ -#endif /* __STDC__ */ -#elif defined( __VMS ) || defined(__sgi) -#include -#elif defined(__SCO__) || defined(__USLC__) -#include -#elif defined(__UNIXOS2__) || defined(__SOL64__) -typedef long int int32_t; -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#elif defined(_WIN32) && defined(__GNUC__) -#include -#elif defined(_WIN32) -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -/* Fallback if nothing above works */ -#include -#endif -#endif - -#ifndef GL_EXT_timer_query -typedef int64_t GLint64EXT; -typedef uint64_t GLuint64EXT; -#endif - -#ifndef GL_ARB_sync -typedef int64_t GLint64; -typedef uint64_t GLuint64; -typedef struct __GLsync *GLsync; -#endif - -#ifndef GL_ARB_cl_event -/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */ -struct _cl_context; -struct _cl_event; -#endif - -#ifndef GL_ARB_debug_output -typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -#endif - -#ifndef GL_AMD_debug_output -typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -#endif - -#ifndef GL_NV_vdpau_interop -typedef GLintptr GLvdpauSurfaceNV; -#endif - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -GLAPI void APIENTRY glBlendEquation (GLenum mode); -GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_2_DEPRECATED -#define GL_VERSION_1_2_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table); -GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); -GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); -GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image); -GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glResetHistogram (GLenum target); -GLAPI void APIENTRY glResetMinmax (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -#endif - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum texture); -GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_VERSION_1_3_DEPRECATED -#define GL_VERSION_1_3_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClientActiveTexture (GLenum texture); -GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); -GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); -GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); -GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); -GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); -GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); -GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); -GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); -GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); -GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); -GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); -GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); -GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -#endif - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount); -GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_VERSION_1_4_DEPRECATED -#define GL_VERSION_1_4_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordf (GLfloat coord); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); -GLAPI void APIENTRY glFogCoordd (GLdouble coord); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); -GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); -GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); -GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); -GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); -GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); -GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); -GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); -GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); -GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); -GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); -GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); -GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); -GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2iv (const GLint *v); -GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); -GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3iv (const GLint *v); -GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -#endif - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQuery (GLuint id); -GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQuery (GLenum target); -GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); -GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); -GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); -GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); -GLAPI void APIENTRY glCompileShader (GLuint shader); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum type); -GLAPI void APIENTRY glDeleteProgram (GLuint program); -GLAPI void APIENTRY glDeleteShader (GLuint shader); -GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer); -GLAPI GLboolean APIENTRY glIsProgram (GLuint program); -GLAPI GLboolean APIENTRY glIsShader (GLuint shader); -GLAPI void APIENTRY glLinkProgram (GLuint program); -GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length); -GLAPI void APIENTRY glUseProgram (GLuint program); -GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glValidateProgram (GLuint program); -GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif - -#ifndef GL_VERSION_3_0 -#define GL_VERSION_3_0 1 -/* OpenGL 3.0 also reuses entry points from these extensions: */ -/* ARB_framebuffer_object */ -/* ARB_map_buffer_range */ -/* ARB_vertex_array_object */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); -GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); -GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedback (void); -GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); -GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRender (void); -GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); -GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); -GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); -GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); -GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); -#endif - -#ifndef GL_VERSION_3_1 -#define GL_VERSION_3_1 1 -/* OpenGL 3.1 also reuses entry points from these extensions: */ -/* ARB_copy_buffer */ -/* ARB_uniform_buffer_object */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); -#endif - -#ifndef GL_VERSION_3_2 -#define GL_VERSION_3_2 1 -/* OpenGL 3.2 also reuses entry points from these extensions: */ -/* ARB_draw_elements_base_vertex */ -/* ARB_provoking_vertex */ -/* ARB_sync */ -/* ARB_texture_multisample */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); -GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -#endif - -#ifndef GL_VERSION_3_3 -#define GL_VERSION_3_3 1 -/* OpenGL 3.3 also reuses entry points from these extensions: */ -/* ARB_blend_func_extended */ -/* ARB_sampler_objects */ -/* ARB_explicit_attrib_location, but it has none */ -/* ARB_occlusion_query2 (no entry points) */ -/* ARB_shader_bit_encoding (no entry points) */ -/* ARB_texture_rgb10_a2ui (no entry points) */ -/* ARB_texture_swizzle (no entry points) */ -/* ARB_timer_query */ -/* ARB_vertex_type_2_10_10_10_rev */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); -#endif - -#ifndef GL_VERSION_4_0 -#define GL_VERSION_4_0 1 -/* OpenGL 4.0 also reuses entry points from these extensions: */ -/* ARB_texture_query_lod (no entry points) */ -/* ARB_draw_indirect */ -/* ARB_gpu_shader5 (no entry points) */ -/* ARB_gpu_shader_fp64 */ -/* ARB_shader_subroutine */ -/* ARB_tessellation_shader */ -/* ARB_texture_buffer_object_rgb32 (no entry points) */ -/* ARB_texture_cube_map_array (no entry points) */ -/* ARB_texture_gather (no entry points) */ -/* ARB_transform_feedback2 */ -/* ARB_transform_feedback3 */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShading (GLfloat value); -GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); -typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif - -#ifndef GL_VERSION_4_1 -#define GL_VERSION_4_1 1 -/* OpenGL 4.1 reuses entry points from these extensions: */ -/* ARB_ES2_compatibility */ -/* ARB_get_program_binary */ -/* ARB_separate_shader_objects */ -/* ARB_shader_precision (no entry points) */ -/* ARB_vertex_attrib_64bit */ -/* ARB_viewport_array */ -#endif - -#ifndef GL_VERSION_4_2 -#define GL_VERSION_4_2 1 -/* OpenGL 4.2 reuses entry points from these extensions: */ -/* ARB_base_instance */ -/* ARB_shading_language_420pack (no entry points) */ -/* ARB_transform_feedback_instanced */ -/* ARB_compressed_texture_pixel_storage (no entry points) */ -/* ARB_conservative_depth (no entry points) */ -/* ARB_internalformat_query */ -/* ARB_map_buffer_alignment (no entry points) */ -/* ARB_shader_atomic_counters */ -/* ARB_shader_image_load_store */ -/* ARB_shading_language_packing (no entry points) */ -/* ARB_texture_storage */ -#endif - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTextureARB (GLenum texture); -GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); -GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); -GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); -GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); -GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); -GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); -GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); -GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); -GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); -GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); -GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); -GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); -GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); -GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -#endif - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); -#endif - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#endif - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#endif - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); -GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); -GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); -GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); -GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); -GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); -GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); -GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); -GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glVertexBlendARB (GLint count); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); -typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); -typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); -typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); -typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); -typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); -GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); -GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); -GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); -GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#endif - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#endif - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); -GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); -GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); -GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#endif - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); -GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); -GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); -GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); -GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string); -GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid* *pointer); -GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); -#endif - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); -GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); -GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); -GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQueryARB (GLenum target); -GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); -GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); -GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); -GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); -GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); -GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); -GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); -GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); -GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); -GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); -GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); -GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); -GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); -GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 -#endif - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 -#endif - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_ARB_depth_buffer_float 1 -#endif - -#ifndef GL_ARB_draw_instanced -#define GL_ARB_draw_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_ARB_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmap (GLenum target); -GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_ARB_framebuffer_sRGB 1 -#endif - -#ifndef GL_ARB_geometry_shader4 -#define GL_ARB_geometry_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); -GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex 1 -#endif - -#ifndef GL_ARB_instanced_arrays -#define GL_ARB_instanced_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_ARB_map_buffer_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -#endif - -#ifndef GL_ARB_texture_buffer_object -#define GL_ARB_texture_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc 1 -#endif - -#ifndef GL_ARB_texture_rg -#define GL_ARB_texture_rg 1 -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_ARB_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArray (GLuint array); -GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); -#endif - -#ifndef GL_ARB_uniform_buffer_object -#define GL_ARB_uniform_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices); -GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); -GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif - -#ifndef GL_ARB_compatibility -#define GL_ARB_compatibility 1 -#endif - -#ifndef GL_ARB_copy_buffer -#define GL_ARB_copy_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -#endif - -#ifndef GL_ARB_shader_texture_lod -#define GL_ARB_shader_texture_lod 1 -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_ARB_depth_clamp 1 -#endif - -#ifndef GL_ARB_draw_elements_base_vertex -#define GL_ARB_draw_elements_base_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, const GLint *basevertex); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, const GLint *basevertex); -#endif - -#ifndef GL_ARB_fragment_coord_conventions -#define GL_ARB_fragment_coord_conventions 1 -#endif - -#ifndef GL_ARB_provoking_vertex -#define GL_ARB_provoking_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProvokingVertex (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_ARB_seamless_cube_map 1 -#endif - -#ifndef GL_ARB_sync -#define GL_ARB_sync 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); -GLAPI GLboolean APIENTRY glIsSync (GLsync sync); -GLAPI void APIENTRY glDeleteSync (GLsync sync); -GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); -typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); -typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); -typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif - -#ifndef GL_ARB_texture_multisample -#define GL_ARB_texture_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); -#endif - -#ifndef GL_ARB_vertex_array_bgra -#define GL_ARB_vertex_array_bgra 1 -#endif - -#ifndef GL_ARB_draw_buffers_blend -#define GL_ARB_draw_buffers_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif - -#ifndef GL_ARB_sample_shading -#define GL_ARB_sample_shading 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); -#endif - -#ifndef GL_ARB_texture_cube_map_array -#define GL_ARB_texture_cube_map_array 1 -#endif - -#ifndef GL_ARB_texture_gather -#define GL_ARB_texture_gather 1 -#endif - -#ifndef GL_ARB_texture_query_lod -#define GL_ARB_texture_query_lod 1 -#endif - -#ifndef GL_ARB_shading_language_include -#define GL_ARB_shading_language_include 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); -GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); -typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_texture_compression_bptc -#define GL_ARB_texture_compression_bptc 1 -#endif - -#ifndef GL_ARB_blend_func_extended -#define GL_ARB_blend_func_extended 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); -#endif - -#ifndef GL_ARB_explicit_attrib_location -#define GL_ARB_explicit_attrib_location 1 -#endif - -#ifndef GL_ARB_occlusion_query2 -#define GL_ARB_occlusion_query2 1 -#endif - -#ifndef GL_ARB_sampler_objects -#define GL_ARB_sampler_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); -GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); -GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); -GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); -GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); -GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); -GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); -GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); -typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); -typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); -typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_bit_encoding -#define GL_ARB_shader_bit_encoding 1 -#endif - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_ARB_texture_rgb10_a2ui 1 -#endif - -#ifndef GL_ARB_texture_swizzle -#define GL_ARB_texture_swizzle 1 -#endif - -#ifndef GL_ARB_timer_query -#define GL_ARB_timer_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); -GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); -#endif - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -#define GL_ARB_vertex_type_2_10_10_10_rev 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -#endif - -#ifndef GL_ARB_draw_indirect -#define GL_ARB_draw_indirect 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); -GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); -#endif - -#ifndef GL_ARB_gpu_shader5 -#define GL_ARB_gpu_shader5 1 -#endif - -#ifndef GL_ARB_gpu_shader_fp64 -#define GL_ARB_gpu_shader_fp64 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); -GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); -#endif - -#ifndef GL_ARB_shader_subroutine -#define GL_ARB_shader_subroutine 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); -GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); -GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); -typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -#endif - -#ifndef GL_ARB_tessellation_shader -#define GL_ARB_tessellation_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); -GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); -#endif - -#ifndef GL_ARB_texture_buffer_object_rgb32 -#define GL_ARB_texture_buffer_object_rgb32 1 -#endif - -#ifndef GL_ARB_transform_feedback2 -#define GL_ARB_transform_feedback2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedback (void); -GLAPI void APIENTRY glResumeTransformFeedback (void); -GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); -#endif - -#ifndef GL_ARB_transform_feedback3 -#define GL_ARB_transform_feedback3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); -GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); -GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); -GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); -typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_ES2_compatibility -#define GL_ARB_ES2_compatibility 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReleaseShaderCompiler (void); -GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); -GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); -GLAPI void APIENTRY glClearDepthf (GLfloat d); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); -typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); -typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); -typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); -#endif - -#ifndef GL_ARB_get_program_binary -#define GL_ARB_get_program_binary 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); -GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); -#endif - -#ifndef GL_ARB_separate_shader_objects -#define GL_ARB_separate_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); -GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* const *strings); -GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); -GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); -GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); -GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); -GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); -GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); -typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* const *strings); -typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); -typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif - -#ifndef GL_ARB_vertex_attrib_64bit -#define GL_ARB_vertex_attrib_64bit 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); -#endif - -#ifndef GL_ARB_viewport_array -#define GL_ARB_viewport_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); -GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); -GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); -GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); -typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); -#endif - -#ifndef GL_ARB_cl_event -#define GL_ARB_cl_event 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); -#endif - -#ifndef GL_ARB_debug_output -#define GL_ARB_debug_output 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif - -#ifndef GL_ARB_robustness -#define GL_ARB_robustness 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); -GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); -GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); -GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); -GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); -GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); -GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); -GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); -GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); -GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); -GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); -GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); -typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); -typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); -typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); -typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); -typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); -typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); -typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -#endif - -#ifndef GL_ARB_shader_stencil_export -#define GL_ARB_shader_stencil_export 1 -#endif - -#ifndef GL_ARB_base_instance -#define GL_ARB_base_instance 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); -#endif - -#ifndef GL_ARB_shading_language_420pack -#define GL_ARB_shading_language_420pack 1 -#endif - -#ifndef GL_ARB_transform_feedback_instanced -#define GL_ARB_transform_feedback_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei primcount); -GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); -#endif - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_ARB_compressed_texture_pixel_storage 1 -#endif - -#ifndef GL_ARB_conservative_depth -#define GL_ARB_conservative_depth 1 -#endif - -#ifndef GL_ARB_internalformat_query -#define GL_ARB_internalformat_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -#endif - -#ifndef GL_ARB_map_buffer_alignment -#define GL_ARB_map_buffer_alignment 1 -#endif - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ARB_shader_atomic_counters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_shader_image_load_store -#define GL_ARB_shader_image_load_store 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); -#endif - -#ifndef GL_ARB_shading_language_packing -#define GL_ARB_shading_language_packing 1 -#endif - -#ifndef GL_ARB_texture_storage -#define GL_ARB_texture_storage 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 -#endif - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); -#endif - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#endif - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); -GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glResetHistogramEXT (GLenum target); -GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); -#endif - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); -GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); -GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image); -GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif - -#ifndef GL_SGI_color_matrix -#define GL_SGI_color_matrix 1 -#endif - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table); -GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); -GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); -GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); -GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 -#endif - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 -#endif - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); -GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); -GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); -GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); -GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); -GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#endif - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#endif - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glArrayElementEXT (GLint i); -GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); -GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid* *params); -GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#endif - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 -#endif - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 -#endif - -#ifndef GL_SGIX_texture_select -#define GL_SGIX_texture_select 1 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); -GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); -GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#endif - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); -GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); -GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); -GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); -GLAPI void APIENTRY glStartInstrumentsSGIX (void); -GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#endif - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTagSampleBufferSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); -GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#endif - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRasterSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#endif - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#endif - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data); -GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); -GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); -GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); -GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#endif - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); -GLAPI void APIENTRY glUnlockArraysEXT (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); -GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); -GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); -GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); -GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); -GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); -GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#endif - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#endif - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); -GLAPI void APIENTRY glTextureLightEXT (GLenum pname); -GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 -#endif - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#endif - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); -GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); -GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); -GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); -GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); -GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); -GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid* *pointer); -GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); -GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -#endif - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#endif - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); -GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); -GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); -GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); -GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); -GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); -GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); -GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); -GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); -GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif - -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); -GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); -GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); -GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); -GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); -GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); -GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); -GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); -GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); -GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); -GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); -GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); -GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); -GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); -GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); -GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); -GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); -GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); -GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_SGIX_fog_scale 1 -#endif - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFinishTextureSUNX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); -#endif - -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); -GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); -GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); -GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); -GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); -GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); -GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); -GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -#endif - -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); -GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); -GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); -GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); -GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); -GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); -GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif - -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_blend_func_separate -#define GL_INGR_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#endif - -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); -GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); -GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); -#endif - -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); -GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); -GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); -GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); -#endif - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#endif - -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#endif - -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glResizeBuffersMESA (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); -#endif - -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); -GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); -GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean* *pointer, GLint ptrstride); -GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -#endif - -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 -#endif - -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#endif - -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); -#endif - -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#endif - -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif - -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#endif - -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); -GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); -GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); -GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); -GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); -GLAPI void APIENTRY glFinishFenceNV (GLuint fence); -GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif - -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 -#endif - -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 -#endif - -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); -GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); -GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); -GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); -GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid* *pointer); -GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); -GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); -GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); -GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); -typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); -typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 -#endif - -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 -#endif - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#endif - -#ifndef GL_OML_resample -#define GL_OML_resample 1 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); -GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); -GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); -GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); -GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); -GLAPI void APIENTRY glBeginFragmentShaderATI (void); -GLAPI void APIENTRY glEndFragmentShaderATI (void); -GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); -GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); -GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); -GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage); -GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); -GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVertexShaderEXT (void); -GLAPI void APIENTRY glEndVertexShaderEXT (void); -GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); -GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); -GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); -GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); -GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); -GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); -GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr); -GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr); -GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); -GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); -GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); -GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); -GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); -GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); -GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); -GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); -GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); -GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); -GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); -GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); -GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); -GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); -GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); -GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); -GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid* *data); -GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); -GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); -GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); -GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); -GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); -GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); -GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); -GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); -GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); -GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer); -GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); -GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif - -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 -#endif - -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); -GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); -GLAPI void APIENTRY glEndOcclusionQueryNV (void); -GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#endif - -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 -#endif - -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#endif - -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer); -GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif - -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); -GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); -GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); -GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); -GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); -GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); -GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); -GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#endif - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -/* This is really a WGL extension, but defines some associated GL enums. - * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. - */ -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#endif - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 -#endif - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 -#endif - -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif - -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); -GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); -GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); -GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); -GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); -GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); -GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); -GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); -GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); -GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); -GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); -GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); -GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); -GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, GLvoid *pointer); -GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -#endif - -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartNV (void); -GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#endif - -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif - -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#endif - -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -#endif - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 -#endif - -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 -#endif - -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 -#endif - -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -#endif - -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); -#endif - -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil 1 -#endif - -#ifndef GL_EXT_stencil_clear_tag -#define GL_EXT_stencil_clear_tag 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); -#endif - -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 -#endif - -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif - -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_MESAX_texture_stack -#define GL_MESAX_texture_stack 1 -#endif - -#ifndef GL_EXT_timer_query -#define GL_EXT_timer_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); -#endif - -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#endif - -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); -#endif - -#ifndef GL_NV_gpu_program4 -#define GL_NV_gpu_program4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); -GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -#endif - -#ifndef GL_NV_geometry_program4 -#define GL_NV_geometry_program4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); -GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif - -#ifndef GL_EXT_geometry_shader4 -#define GL_EXT_geometry_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); -#endif - -#ifndef GL_NV_vertex_program4 -#define GL_NV_vertex_program4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); -#endif - -#ifndef GL_EXT_gpu_shader4 -#define GL_EXT_gpu_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -#endif - -#ifndef GL_EXT_draw_instanced -#define GL_EXT_draw_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -#ifndef GL_EXT_packed_float -#define GL_EXT_packed_float 1 -#endif - -#ifndef GL_EXT_texture_array -#define GL_EXT_texture_array 1 -#endif - -#ifndef GL_EXT_texture_buffer_object -#define GL_EXT_texture_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#endif - -#ifndef GL_EXT_texture_compression_latc -#define GL_EXT_texture_compression_latc 1 -#endif - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc 1 -#endif - -#ifndef GL_EXT_texture_shared_exponent -#define GL_EXT_texture_shared_exponent 1 -#endif - -#ifndef GL_NV_depth_buffer_float -#define GL_NV_depth_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); -GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); -typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); -#endif - -#ifndef GL_NV_fragment_program4 -#define GL_NV_fragment_program4 1 -#endif - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_NV_framebuffer_multisample_coverage 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_EXT_framebuffer_sRGB 1 -#endif - -#ifndef GL_NV_geometry_shader4 -#define GL_NV_geometry_shader4 1 -#endif - -#ifndef GL_NV_parameter_buffer_object -#define GL_NV_parameter_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); -#endif - -#ifndef GL_EXT_draw_buffers2 -#define GL_EXT_draw_buffers2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); -GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); -#endif - -#ifndef GL_NV_transform_feedback -#define GL_NV_transform_feedback 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedbackNV (void); -GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); -GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); -GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); -GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); -#endif - -#ifndef GL_EXT_bindable_uniform -#define GL_EXT_bindable_uniform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); -GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); -GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); -typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); -typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); -#endif - -#ifndef GL_EXT_texture_integer -#define GL_EXT_texture_integer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); -GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); -typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#endif - -#ifndef GL_GREMEDY_frame_terminator -#define GL_GREMEDY_frame_terminator 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); -#endif - -#ifndef GL_NV_conditional_render -#define GL_NV_conditional_render 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRenderNV (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); -#endif - -#ifndef GL_NV_present_video -#define GL_NV_present_video 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); -GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); -#endif - -#ifndef GL_EXT_transform_feedback -#define GL_EXT_transform_feedback 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedbackEXT (void); -GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -#endif - -#ifndef GL_EXT_direct_state_access -#define GL_EXT_direct_state_access 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); -GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); -GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); -GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); -GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); -GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); -GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); -GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); -GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); -GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid* *data); -GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img); -GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img); -GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); -GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string); -GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); -GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); -GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); -GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); -GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); -GLAPI GLvoid* APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid* *params); -GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); -GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); -GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); -GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); -GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); -GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); -GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); -GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); -GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); -typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); -typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); -typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); -typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); -typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -#endif - -#ifndef GL_EXT_vertex_array_bgra -#define GL_EXT_vertex_array_bgra 1 -#endif - -#ifndef GL_EXT_texture_swizzle -#define GL_EXT_texture_swizzle 1 -#endif - -#ifndef GL_NV_explicit_multisample -#define GL_NV_explicit_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); -GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); -typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); -#endif - -#ifndef GL_NV_transform_feedback2 -#define GL_NV_transform_feedback2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedbackNV (void); -GLAPI void APIENTRY glResumeTransformFeedbackNV (void); -GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); -#endif - -#ifndef GL_ATI_meminfo -#define GL_ATI_meminfo 1 -#endif - -#ifndef GL_AMD_performance_monitor -#define GL_AMD_performance_monitor 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); -GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); -GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); -GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); -GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif - -#ifndef GL_AMD_texture_texture4 -#define GL_AMD_texture_texture4 1 -#endif - -#ifndef GL_AMD_vertex_shader_tesselator -#define GL_AMD_vertex_shader_tesselator 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); -GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_provoking_vertex -#define GL_EXT_provoking_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_texture_snorm -#define GL_EXT_texture_snorm 1 -#endif - -#ifndef GL_AMD_draw_buffers_blend -#define GL_AMD_draw_buffers_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -#endif - -#ifndef GL_APPLE_texture_range -#define GL_APPLE_texture_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer); -GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_APPLE_float_pixels -#define GL_APPLE_float_pixels 1 -#endif - -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_APPLE_vertex_program_evaluators 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); -GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); -GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); -GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -#endif - -#ifndef GL_APPLE_aux_depth_stencil -#define GL_APPLE_aux_depth_stencil 1 -#endif - -#ifndef GL_APPLE_object_purgeable -#define GL_APPLE_object_purgeable 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); -GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); -GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); -#endif - -#ifndef GL_APPLE_row_bytes -#define GL_APPLE_row_bytes 1 -#endif - -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 -#endif - -#ifndef GL_NV_video_capture -#define GL_NV_video_capture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); -GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); -GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); -GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); -GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); -GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); -GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); -GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); -typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); -#endif - -#ifndef GL_NV_copy_image -#define GL_NV_copy_image 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif - -#ifndef GL_EXT_separate_shader_objects -#define GL_EXT_separate_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); -GLAPI void APIENTRY glActiveProgramEXT (GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); -typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); -#endif - -#ifndef GL_NV_parameter_buffer_object2 -#define GL_NV_parameter_buffer_object2 1 -#endif - -#ifndef GL_NV_shader_buffer_load -#define GL_NV_shader_buffer_load 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); -GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); -GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); -GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); -GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); -GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); -GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); -GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); -GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); -GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); -GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); -typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); -typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); -typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); -typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); -typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); -typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); -typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif - -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_NV_vertex_buffer_unified_memory 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); -GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); -#endif - -#ifndef GL_NV_texture_barrier -#define GL_NV_texture_barrier 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureBarrierNV (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); -#endif - -#ifndef GL_AMD_shader_stencil_export -#define GL_AMD_shader_stencil_export 1 -#endif - -#ifndef GL_AMD_seamless_cubemap_per_texture -#define GL_AMD_seamless_cubemap_per_texture 1 -#endif - -#ifndef GL_AMD_conservative_depth -#define GL_AMD_conservative_depth 1 -#endif - -#ifndef GL_EXT_shader_image_load_store -#define GL_EXT_shader_image_load_store 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); -#endif - -#ifndef GL_EXT_vertex_attrib_64bit -#define GL_EXT_vertex_attrib_64bit 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -#endif - -#ifndef GL_NV_gpu_program5 -#define GL_NV_gpu_program5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); -#endif - -#ifndef GL_NV_gpu_shader5 -#define GL_NV_gpu_shader5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); -GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); -GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); -GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); -GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); -GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); -typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); -typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif - -#ifndef GL_NV_shader_buffer_store -#define GL_NV_shader_buffer_store 1 -#endif - -#ifndef GL_NV_tessellation_program5 -#define GL_NV_tessellation_program5 1 -#endif - -#ifndef GL_NV_vertex_attrib_integer_64bit -#define GL_NV_vertex_attrib_integer_64bit 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); -GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); -GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); -#endif - -#ifndef GL_NV_multisample_coverage -#define GL_NV_multisample_coverage 1 -#endif - -#ifndef GL_AMD_name_gen_delete -#define GL_AMD_name_gen_delete 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); -GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); -GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); -typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); -typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); -#endif - -#ifndef GL_AMD_debug_output -#define GL_AMD_debug_output 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#endif - -#ifndef GL_NV_vdpau_interop -#define GL_NV_vdpau_interop 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress); -GLAPI void APIENTRY glVDPAUFiniNV (void); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); -GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); -GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress); -typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); -typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); -typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); -#endif - -#ifndef GL_AMD_transform_feedback3_lines_triangles -#define GL_AMD_transform_feedback3_lines_triangles 1 -#endif - -#ifndef GL_AMD_depth_clamp_separate -#define GL_AMD_depth_clamp_separate 1 -#endif - -#ifndef GL_EXT_texture_sRGB_decode -#define GL_EXT_texture_sRGB_decode 1 -#endif - -#ifndef GL_NV_texture_multisample -#define GL_NV_texture_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -#endif - -#ifndef GL_AMD_blend_minmax_factor -#define GL_AMD_blend_minmax_factor 1 -#endif - -#ifndef GL_AMD_sample_positions -#define GL_AMD_sample_positions 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); -#endif - -#ifndef GL_EXT_x11_sync_object -#define GL_EXT_x11_sync_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); -#endif - -#ifndef GL_AMD_multi_draw_indirect -#define GL_AMD_multi_draw_indirect 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -#endif - -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_EXT_framebuffer_multisample_blit_scaled 1 -#endif - -#ifndef GL_NV_path_rendering -#define GL_NV_path_rendering 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); -GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); -GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); -GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); -GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); -GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); -GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); -GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); -GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); -GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); -GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); -GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); -GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); -GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); -GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); -GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); -GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); -GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); -GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); -GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); -GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); -GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); -GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); -GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); -GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); -GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); -GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); -GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); -GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); -GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); -GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); -GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); -GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); -GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); -typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); -typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); -typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); -typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); -typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); -typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); -typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); -typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); -typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); -typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); -typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); -typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); -typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); -typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); -typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); -typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); -typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); -typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); -typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); -typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); -typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); -typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); -typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); -typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); -typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); -typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); -typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); -typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); -#endif - -#ifndef GL_AMD_pinned_memory -#define GL_AMD_pinned_memory 1 -#endif - -#ifndef GL_AMD_stencil_operation_extended -#define GL_AMD_stencil_operation_extended 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); -#endif - -#ifndef GL_AMD_vertex_shader_viewport_index -#define GL_AMD_vertex_shader_viewport_index 1 -#endif - -#ifndef GL_AMD_vertex_shader_layer -#define GL_AMD_vertex_shader_layer 1 -#endif - -#ifndef GL_NV_bindless_texture -#define GL_NV_bindless_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); -GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); -GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); -GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); -GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); -GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); -GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); -GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); -GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); -GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); -typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); -typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); -#endif - -#ifndef GL_NV_shader_atomic_float -#define GL_NV_shader_atomic_float 1 -#endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/gl/api/wglext.h b/src/gl/api/wglext.h deleted file mode 100644 index b5dc7bf7f..000000000 --- a/src/gl/api/wglext.h +++ /dev/null @@ -1,943 +0,0 @@ -#ifndef __wglext_h_ -#define __wglext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2007-2012 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Function declaration macros - to move into glplatform.h */ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number */ -/* wglext.h last updated 2012/01/04 */ -/* Current version at http://www.opengl.org/registry/ */ -#define WGL_WGLEXT_VERSION 24 - -#ifndef WGL_ARB_buffer_region -#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 -#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 -#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 -#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 -#endif - -#ifndef WGL_ARB_multisample -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 -#endif - -#ifndef WGL_ARB_extensions_string -#endif - -#ifndef WGL_ARB_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NEED_PALETTE_ARB 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define WGL_TRANSPARENT_ARB 0x200A -#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 -#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 -#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A -#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B -#define WGL_SHARE_DEPTH_ARB 0x200C -#define WGL_SHARE_STENCIL_ARB 0x200D -#define WGL_SHARE_ACCUM_ARB 0x200E -#define WGL_SUPPORT_GDI_ARB 0x200F -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_STEREO_ARB 0x2012 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201A -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_ALPHA_SHIFT_ARB 0x201C -#define WGL_ACCUM_BITS_ARB 0x201D -#define WGL_ACCUM_RED_BITS_ARB 0x201E -#define WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_SWAP_COPY_ARB 0x2029 -#define WGL_SWAP_UNDEFINED_ARB 0x202A -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_TYPE_COLORINDEX_ARB 0x202C -#endif - -#ifndef WGL_ARB_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 -#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 -#endif - -#ifndef WGL_ARB_pbuffer -#define WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E -#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 -#define WGL_PBUFFER_LARGEST_ARB 0x2033 -#define WGL_PBUFFER_WIDTH_ARB 0x2034 -#define WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define WGL_PBUFFER_LOST_ARB 0x2036 -#endif - -#ifndef WGL_ARB_render_texture -#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 -#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 -#define WGL_TEXTURE_FORMAT_ARB 0x2072 -#define WGL_TEXTURE_TARGET_ARB 0x2073 -#define WGL_MIPMAP_TEXTURE_ARB 0x2074 -#define WGL_TEXTURE_RGB_ARB 0x2075 -#define WGL_TEXTURE_RGBA_ARB 0x2076 -#define WGL_NO_TEXTURE_ARB 0x2077 -#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 -#define WGL_TEXTURE_1D_ARB 0x2079 -#define WGL_TEXTURE_2D_ARB 0x207A -#define WGL_MIPMAP_LEVEL_ARB 0x207B -#define WGL_CUBE_MAP_FACE_ARB 0x207C -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 -#define WGL_FRONT_LEFT_ARB 0x2083 -#define WGL_FRONT_RIGHT_ARB 0x2084 -#define WGL_BACK_LEFT_ARB 0x2085 -#define WGL_BACK_RIGHT_ARB 0x2086 -#define WGL_AUX0_ARB 0x2087 -#define WGL_AUX1_ARB 0x2088 -#define WGL_AUX2_ARB 0x2089 -#define WGL_AUX3_ARB 0x208A -#define WGL_AUX4_ARB 0x208B -#define WGL_AUX5_ARB 0x208C -#define WGL_AUX6_ARB 0x208D -#define WGL_AUX7_ARB 0x208E -#define WGL_AUX8_ARB 0x208F -#define WGL_AUX9_ARB 0x2090 -#endif - -#ifndef WGL_ARB_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 -#endif - -#ifndef WGL_ARB_framebuffer_sRGB -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 -#endif - -#ifndef WGL_ARB_create_context -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define ERROR_INVALID_VERSION_ARB 0x2095 -#endif - -#ifndef WGL_ARB_create_context_profile -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define ERROR_INVALID_PROFILE_ARB 0x2096 -#endif - -#ifndef WGL_ARB_create_context_robustness -#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 -#endif - -#ifndef WGL_EXT_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 -#endif - -#ifndef WGL_EXT_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 -#define WGL_DRAW_TO_WINDOW_EXT 0x2001 -#define WGL_DRAW_TO_BITMAP_EXT 0x2002 -#define WGL_ACCELERATION_EXT 0x2003 -#define WGL_NEED_PALETTE_EXT 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 -#define WGL_SWAP_METHOD_EXT 0x2007 -#define WGL_NUMBER_OVERLAYS_EXT 0x2008 -#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 -#define WGL_TRANSPARENT_EXT 0x200A -#define WGL_TRANSPARENT_VALUE_EXT 0x200B -#define WGL_SHARE_DEPTH_EXT 0x200C -#define WGL_SHARE_STENCIL_EXT 0x200D -#define WGL_SHARE_ACCUM_EXT 0x200E -#define WGL_SUPPORT_GDI_EXT 0x200F -#define WGL_SUPPORT_OPENGL_EXT 0x2010 -#define WGL_DOUBLE_BUFFER_EXT 0x2011 -#define WGL_STEREO_EXT 0x2012 -#define WGL_PIXEL_TYPE_EXT 0x2013 -#define WGL_COLOR_BITS_EXT 0x2014 -#define WGL_RED_BITS_EXT 0x2015 -#define WGL_RED_SHIFT_EXT 0x2016 -#define WGL_GREEN_BITS_EXT 0x2017 -#define WGL_GREEN_SHIFT_EXT 0x2018 -#define WGL_BLUE_BITS_EXT 0x2019 -#define WGL_BLUE_SHIFT_EXT 0x201A -#define WGL_ALPHA_BITS_EXT 0x201B -#define WGL_ALPHA_SHIFT_EXT 0x201C -#define WGL_ACCUM_BITS_EXT 0x201D -#define WGL_ACCUM_RED_BITS_EXT 0x201E -#define WGL_ACCUM_GREEN_BITS_EXT 0x201F -#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 -#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 -#define WGL_DEPTH_BITS_EXT 0x2022 -#define WGL_STENCIL_BITS_EXT 0x2023 -#define WGL_AUX_BUFFERS_EXT 0x2024 -#define WGL_NO_ACCELERATION_EXT 0x2025 -#define WGL_GENERIC_ACCELERATION_EXT 0x2026 -#define WGL_FULL_ACCELERATION_EXT 0x2027 -#define WGL_SWAP_EXCHANGE_EXT 0x2028 -#define WGL_SWAP_COPY_EXT 0x2029 -#define WGL_SWAP_UNDEFINED_EXT 0x202A -#define WGL_TYPE_RGBA_EXT 0x202B -#define WGL_TYPE_COLORINDEX_EXT 0x202C -#endif - -#ifndef WGL_EXT_pbuffer -#define WGL_DRAW_TO_PBUFFER_EXT 0x202D -#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E -#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 -#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 -#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 -#define WGL_PBUFFER_LARGEST_EXT 0x2033 -#define WGL_PBUFFER_WIDTH_EXT 0x2034 -#define WGL_PBUFFER_HEIGHT_EXT 0x2035 -#endif - -#ifndef WGL_EXT_depth_float -#define WGL_DEPTH_FLOAT_EXT 0x2040 -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 -#define WGL_SAMPLES_3DFX 0x2061 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_SAMPLE_BUFFERS_EXT 0x2041 -#define WGL_SAMPLES_EXT 0x2042 -#endif - -#ifndef WGL_I3D_digital_video_control -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 -#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 -#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 -#endif - -#ifndef WGL_I3D_gamma -#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E -#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F -#endif - -#ifndef WGL_I3D_genlock -#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 -#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045 -#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046 -#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047 -#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 -#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 -#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A -#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B -#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C -#endif - -#ifndef WGL_I3D_image_buffer -#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 -#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 -#endif - -#ifndef WGL_I3D_swap_frame_lock -#endif - -#ifndef WGL_NV_render_depth_texture -#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 -#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 -#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 -#define WGL_DEPTH_COMPONENT_NV 0x20A7 -#endif - -#ifndef WGL_NV_render_texture_rectangle -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 -#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 -#endif - -#ifndef WGL_ATI_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 -#endif - -#ifndef WGL_NV_float_buffer -#define WGL_FLOAT_COMPONENTS_NV 0x20B0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 -#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 -#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 -#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 -#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 -#endif - -#ifndef WGL_3DL_stereo_control -#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 -#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 -#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 -#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 -#endif - -#ifndef WGL_EXT_pixel_format_packed_float -#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 -#endif - -#ifndef WGL_EXT_framebuffer_sRGB -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 -#endif - -#ifndef WGL_NV_present_video -#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 -#endif - -#ifndef WGL_NV_video_out -#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 -#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 -#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 -#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 -#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 -#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 -#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 -#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 -#define WGL_VIDEO_OUT_FRAME 0x20C8 -#define WGL_VIDEO_OUT_FIELD_1 0x20C9 -#define WGL_VIDEO_OUT_FIELD_2 0x20CA -#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB -#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC -#endif - -#ifndef WGL_NV_swap_group -#endif - -#ifndef WGL_NV_gpu_affinity -#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 -#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 -#endif - -#ifndef WGL_AMD_gpu_association -#define WGL_GPU_VENDOR_AMD 0x1F00 -#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 -#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 -#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 -#define WGL_GPU_RAM_AMD 0x21A3 -#define WGL_GPU_CLOCK_AMD 0x21A4 -#define WGL_GPU_NUM_PIPES_AMD 0x21A5 -#define WGL_GPU_NUM_SIMD_AMD 0x21A6 -#define WGL_GPU_NUM_RB_AMD 0x21A7 -#define WGL_GPU_NUM_SPI_AMD 0x21A8 -#endif - -#ifndef WGL_NV_video_capture -#define WGL_UNIQUE_ID_NV 0x20CE -#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF -#endif - -#ifndef WGL_NV_copy_image -#endif - -#ifndef WGL_NV_multisample_coverage -#define WGL_COVERAGE_SAMPLES_NV 0x2042 -#define WGL_COLOR_SAMPLES_NV 0x20B9 -#endif - -#ifndef WGL_EXT_create_context_es2_profile -#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 -#endif - -#ifndef WGL_NV_DX_interop -#define WGL_ACCESS_READ_ONLY_NV 0x00000000 -#define WGL_ACCESS_READ_WRITE_NV 0x00000001 -#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 -#endif - -#ifndef WGL_NV_DX_interop2 -#endif - -#ifndef WGL_EXT_swap_control_tear -#endif - - -/*************************************************************/ - -#ifndef WGL_ARB_pbuffer -DECLARE_HANDLE(HPBUFFERARB); -#endif -#ifndef WGL_EXT_pbuffer -DECLARE_HANDLE(HPBUFFEREXT); -#endif -#ifndef WGL_NV_present_video -DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); -#endif -#ifndef WGL_NV_video_output -DECLARE_HANDLE(HPVIDEODEV); -#endif -#ifndef WGL_NV_gpu_affinity -DECLARE_HANDLE(HPGPUNV); -DECLARE_HANDLE(HGPUNV); - -typedef struct _GPU_DEVICE { - DWORD cb; - CHAR DeviceName[32]; - CHAR DeviceString[128]; - DWORD Flags; - RECT rcVirtualScreen; -} GPU_DEVICE, *PGPU_DEVICE; -#endif -#ifndef WGL_NV_video_capture -DECLARE_HANDLE(HVIDEOINPUTDEVICENV); -#endif - -#ifndef WGL_ARB_buffer_region -#define WGL_ARB_buffer_region 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); -extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); -extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); -extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); -typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); -typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); -typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); -#endif - -#ifndef WGL_ARB_multisample -#define WGL_ARB_multisample 1 -#endif - -#ifndef WGL_ARB_extensions_string -#define WGL_ARB_extensions_string 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringARB (HDC hdc); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); -#endif - -#ifndef WGL_ARB_pixel_format -#define WGL_ARB_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); -extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); -extern BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif - -#ifndef WGL_ARB_make_current_read -#define WGL_ARB_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -extern HDC WINAPI wglGetCurrentReadDCARB (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); -#endif - -#ifndef WGL_ARB_pbuffer -#define WGL_ARB_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); -extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); -extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); -extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); -#endif - -#ifndef WGL_ARB_render_texture -#define WGL_ARB_render_texture 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); -extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); -extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); -#endif - -#ifndef WGL_ARB_pixel_format_float -#define WGL_ARB_pixel_format_float 1 -#endif - -#ifndef WGL_ARB_framebuffer_sRGB -#define WGL_ARB_framebuffer_sRGB 1 -#endif - -#ifndef WGL_ARB_create_context -#define WGL_ARB_create_context 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); -#endif - -#ifndef WGL_ARB_create_context_profile -#define WGL_ARB_create_context_profile 1 -#endif - -#ifndef WGL_ARB_create_context_robustness -#define WGL_ARB_create_context_robustness 1 -#endif - -#ifndef WGL_EXT_display_color_table -#define WGL_EXT_display_color_table 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); -extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); -extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); -extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); -typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); -#endif - -#ifndef WGL_EXT_extensions_string -#define WGL_EXT_extensions_string 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); -#endif - -#ifndef WGL_EXT_make_current_read -#define WGL_EXT_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -extern HDC WINAPI wglGetCurrentReadDCEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); -#endif - -#ifndef WGL_EXT_pbuffer -#define WGL_EXT_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); -extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); -extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); -extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); -#endif - -#ifndef WGL_EXT_pixel_format -#define WGL_EXT_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); -extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); -extern BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif - -#ifndef WGL_EXT_swap_control -#define WGL_EXT_swap_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglSwapIntervalEXT (int interval); -extern int WINAPI wglGetSwapIntervalEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); -typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); -#endif - -#ifndef WGL_EXT_depth_float -#define WGL_EXT_depth_float 1 -#endif - -#ifndef WGL_NV_vertex_array_range -#define WGL_NV_vertex_array_range 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern void* WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -extern void WINAPI wglFreeMemoryNV (void *pointer); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_3DFX_multisample 1 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_EXT_multisample 1 -#endif - -#ifndef WGL_OML_sync_control -#define WGL_OML_sync_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); -extern BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); -extern INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); -extern BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); -extern BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); -typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); -#endif - -#ifndef WGL_I3D_digital_video_control -#define WGL_I3D_digital_video_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); -extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); -typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); -#endif - -#ifndef WGL_I3D_gamma -#define WGL_I3D_gamma 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); -extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); -extern BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); -extern BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); -#endif - -#ifndef WGL_I3D_genlock -#define WGL_I3D_genlock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableGenlockI3D (HDC hDC); -extern BOOL WINAPI wglDisableGenlockI3D (HDC hDC); -extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); -extern BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); -extern BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); -extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); -extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); -extern BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); -extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); -extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); -extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); -extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); -typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); -typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); -#endif - -#ifndef WGL_I3D_image_buffer -#define WGL_I3D_image_buffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); -extern BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); -extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); -extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); -typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); -typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); -typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); -#endif - -#ifndef WGL_I3D_swap_frame_lock -#define WGL_I3D_swap_frame_lock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableFrameLockI3D (void); -extern BOOL WINAPI wglDisableFrameLockI3D (void); -extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); -extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); -#endif - -#ifndef WGL_I3D_swap_frame_usage -#define WGL_I3D_swap_frame_usage 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); -extern BOOL WINAPI wglBeginFrameTrackingI3D (void); -extern BOOL WINAPI wglEndFrameTrackingI3D (void); -extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); -typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); -#endif - -#ifndef WGL_ATI_pixel_format_float -#define WGL_ATI_pixel_format_float 1 -#endif - -#ifndef WGL_NV_float_buffer -#define WGL_NV_float_buffer 1 -#endif - -#ifndef WGL_3DL_stereo_control -#define WGL_3DL_stereo_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); -#endif - -#ifndef WGL_EXT_pixel_format_packed_float -#define WGL_EXT_pixel_format_packed_float 1 -#endif - -#ifndef WGL_EXT_framebuffer_sRGB -#define WGL_EXT_framebuffer_sRGB 1 -#endif - -#ifndef WGL_NV_present_video -#define WGL_NV_present_video 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); -extern BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); -extern BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); -typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); -typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); -#endif - -#ifndef WGL_NV_video_output -#define WGL_NV_video_output 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); -extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); -extern BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); -extern BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); -extern BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); -extern BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); -typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); -typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); -typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); -#endif - -#ifndef WGL_NV_swap_group -#define WGL_NV_swap_group 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); -extern BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); -extern BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); -extern BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); -extern BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); -extern BOOL WINAPI wglResetFrameCountNV (HDC hDC); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); -typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); -typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); -typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); -typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); -#endif - -#ifndef WGL_NV_gpu_affinity -#define WGL_NV_gpu_affinity 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); -extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); -extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); -extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); -extern BOOL WINAPI wglDeleteDCNV (HDC hdc); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); -typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); -typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); -typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); -typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); -#endif - -#ifndef WGL_AMD_gpu_association -#define WGL_AMD_gpu_association 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); -extern INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data); -extern UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); -extern HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); -extern HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); -extern BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); -extern BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); -extern HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); -extern VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); -typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data); -typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); -typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); -typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); -typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); -typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); -typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); -typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif - -#ifndef WGL_NV_video_capture -#define WGL_NV_video_capture 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); -extern UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); -extern BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); -extern BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); -extern BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); -typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); -typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); -typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); -#endif - -#ifndef WGL_NV_copy_image -#define WGL_NV_copy_image 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif - -#ifndef WGL_NV_multisample_coverage -#define WGL_NV_multisample_coverage 1 -#endif - -#ifndef WGL_NV_DX_interop -#define WGL_NV_DX_interop 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle); -extern HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice); -extern BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice); -extern HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); -extern BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject); -extern BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access); -extern BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); -extern BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle); -typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice); -typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); -typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); -typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); -typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); -typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); -typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); -#endif - -#ifndef WGL_NV_DX_interop2 -#define WGL_NV_DX_interop2 1 -#endif - -#ifndef WGL_EXT_swap_control_tear -#define WGL_EXT_swap_control_tear 1 -#endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/gl/data/gl_sections.cpp b/src/gl/data/gl_sections.cpp deleted file mode 100644 index 34dbabd1d..000000000 --- a/src/gl/data/gl_sections.cpp +++ /dev/null @@ -1,847 +0,0 @@ -/* -** gl_sections.cpp -** Splits sectors into continuous separate parts -** -**--------------------------------------------------------------------------- -** Copyright 2008 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ -#if 0 - -#include "gl/system/gl_system.h" -#include "i_system.h" -#include "p_local.h" -#include "c_dispatch.h" -#include "gl/data/gl_sections.h" - -typedef void (CALLBACK *tessFunc)(); - -TArray SectionLines; -TArray SectionLoops; -TArray Sections; -TArray SectionForSubsector; - -CVAR (Bool, dumpsections, false, 0) - -#define ISDONE(no, p) (p[(no)>>3] & (1 << ((no)&7))) -#define SETDONE(no, p) p[(no)>>3] |= (1 << ((no)&7)) - -inline vertex_t *V1(side_t *s) -{ - line_t *ln = s->linedef; - return s == ln->sidedef[0]? ln->v1: ln->v2; -} - -inline vertex_t *V2(side_t *s) -{ - line_t *ln = s->linedef; - return s == ln->sidedef[0]? ln->v2: ln->v1; -} - -//========================================================================== -// -// -// -//========================================================================== - -class FSectionCreator -{ - static FSectionCreator *creator; - - BYTE *processed_segs; - BYTE *processed_subsectors; - int *section_for_segs; - - vertex_t *v1_l1, *v2_l1; - - FGLSectionLoop *loop; - FGLSection *section; // current working section - -public: - //========================================================================== - // - // - // - //========================================================================== - - FSectionCreator() - { - processed_segs = new BYTE[(numsegs+7)/8]; - processed_subsectors = new BYTE[(numsubsectors+7)/8]; - - memset(processed_segs, 0, (numsegs+7)/8); - memset(processed_subsectors, 0, (numsubsectors+7)/8); - - section_for_segs = new int[numsegs]; - memset(section_for_segs, -1, numsegs * sizeof(int)); - } - - //========================================================================== - // - // - // - //========================================================================== - - ~FSectionCreator() - { - delete [] processed_segs; - delete [] processed_subsectors; - delete [] section_for_segs; - } - - //========================================================================== - // - // - // - //========================================================================== - - void NewLoop() - { - section->numloops++; - loop = &SectionLoops[SectionLoops.Reserve(1)]; - loop->startline = SectionLines.Size(); - loop->numlines = 0 ; - } - - void NewSection(sector_t *sec) - { - section = &Sections[Sections.Reserve(1)]; - section->sector = sec; - section->subsectors.Clear(); - section->numloops = 0; - section->startloop = SectionLoops.Size(); - section->validcount = -1; - NewLoop(); - } - - void FinalizeSection() - { - } - - //========================================================================== - // - // - // - //========================================================================== - - bool AddSeg(seg_t *seg) - { - FGLSectionLine &line = SectionLines[SectionLines.Reserve(1)]; - - - bool firstline = loop->numlines == 0; - - if (ISDONE(seg-segs, processed_segs)) - { - // should never happen! - DPrintf("Tried to add seg %d to Sections twice. Cannot create Sections.\n", seg-segs); - return false; - } - - SETDONE(seg-segs, processed_segs); - section_for_segs[seg-segs] = Sections.Size()-1; - - line.start = seg->v1; - line.end = seg->v2; - line.sidedef = seg->sidedef; - line.linedef = seg->linedef; - line.refseg = seg; - line.polysub = NULL; - line.otherside = -1; - - if (loop->numlines == 0) - { - v1_l1 = seg->v1; - v2_l1 = seg->v2; - } - loop->numlines++; - return true; - } - - //========================================================================== - // - // Utility stuff - // - //========================================================================== - - sector_t *FrontRenderSector(seg_t *seg) - { - return seg->Subsector->render_sector; - } - - sector_t *BackRenderSector(seg_t *seg) - { - if (seg->PartnerSeg == NULL) return NULL; - return seg->PartnerSeg->Subsector->render_sector; - } - - bool IntraSectorSeg(seg_t *seg) - { - return FrontRenderSector(seg) == BackRenderSector(seg); - } - - - //========================================================================== - // - // returns the seg whose partner seg determines where this - // section continues - // - //========================================================================== - bool AddSubSector(subsector_t *subsec, vertex_t *startpt, seg_t **pNextSeg) - { - unsigned i = 0; - if (startpt != NULL) - { - // find the seg in this subsector that starts at the given vertex - for(i = 0; i < subsec->numlines; i++) - { - if (subsec->firstline[i].v1 == startpt) break; - } - if (i == subsec->numlines) - { - DPrintf("Vertex not found in subsector %d. Cannot create Sections.\n", subsec-subsectors); - return false; // Nodes are bad - } - } - else - { - // Find the first unprocessed non-miniseg - for(i = 0; i < subsec->numlines; i++) - { - seg_t *seg = subsec->firstline + i; - - if (seg->sidedef == NULL) continue; - if (IntraSectorSeg(seg)) continue; - if (ISDONE(seg-segs, processed_segs)) continue; - break; - } - if (i == subsec->numlines) - { - DPrintf("Unable to find a start seg. Cannot create Sections.\n"); - return false; // Nodes are bad - } - - startpt = subsec->firstline[i].v1; - } - - seg_t *thisseg = subsec->firstline + i; - if (IntraSectorSeg(thisseg)) - { - SETDONE(thisseg-segs, processed_segs); - // continue with the loop in the adjoining subsector - *pNextSeg = thisseg; - return true; - } - - while(1) - { - if (loop->numlines > 0 && thisseg->v1 == v1_l1 && thisseg->v2 == v2_l1) - { - // This loop is complete - *pNextSeg = NULL; - return true; - } - - if (!AddSeg(thisseg)) return NULL; - - i = (i+1) % subsec->numlines; - seg_t *nextseg = subsec->firstline + i; - - if (thisseg->v2 != nextseg->v1) - { - DPrintf("Segs in subsector %d are not continuous. Cannot create Sections.\n", subsec-subsectors); - return false; // Nodes are bad - } - - if (IntraSectorSeg(nextseg)) - { - SETDONE(nextseg-segs, processed_segs); - // continue with the loop in the adjoining subsector - *pNextSeg = nextseg; - return true; - } - thisseg = nextseg; - } - } - - //============================================================================= - // - // - // - //============================================================================= - - bool FindNextSeg(seg_t **pSeg) - { - // find an unprocessed non-miniseg or a miniseg with an unprocessed - // partner subsector that belongs to the same rendersector - for (unsigned i = 0; i < section->subsectors.Size(); i++) - { - for(unsigned j = 0; j < section->subsectors[i]->numlines; j++) - { - seg_t *seg = section->subsectors[i]->firstline + j; - bool intra = IntraSectorSeg(seg); - - if (!intra && !ISDONE(seg-segs, processed_segs)) - { - *pSeg = seg; - return true; - } - else if (intra && - !ISDONE(seg->PartnerSeg->Subsector-subsectors, processed_subsectors)) - { - *pSeg = seg->PartnerSeg; - return true; - } - } - } - *pSeg = NULL; - return true; - } - - //============================================================================= - // - // all segs and subsectors must be grouped into Sections - // - //============================================================================= - bool CheckSections() - { - bool res = true; - for (int i = 0; i < numsegs; i++) - { - if (segs[i].sidedef != NULL && !ISDONE(i, processed_segs) && !IntraSectorSeg(&segs[i])) - { - Printf("Seg %d (Linedef %d) not processed during section creation\n", i, segs[i].linedef-lines); - res = false; - } - } - for (int i = 0; i < numsubsectors; i++) - { - if (!ISDONE(i, processed_subsectors)) - { - Printf("Subsector %d (Sector %d) not processed during section creation\n", i, subsectors[i].sector-sectors); - res = false; - } - } - return res; - } - - //============================================================================= - // - // - // - //============================================================================= - void DeleteLine(int i) - { - SectionLines.Delete(i); - for(int i = SectionLoops.Size() - 1; i >= 0; i--) - { - FGLSectionLoop *loop = &SectionLoops[i]; - if (loop->startline > i) loop->startline--; - } - } - - //============================================================================= - // - // - // - //============================================================================= - void MergeLines(FGLSectionLoop *loop) - { - int i; - int deleted = 0; - FGLSectionLine *ln1; - FGLSectionLine *ln2; - // Merge identical lines in the list - for(i = loop->numlines - 1; i > 0; i--) - { - ln1 = loop->GetLine(i); - ln2 = loop->GetLine(i-1); - - if (ln1->sidedef == ln2->sidedef && ln1->otherside == ln2->otherside) - { - // identical references. These 2 lines can be merged. - ln2->end = ln1->end; - SectionLines.Delete(loop->startline + i); - loop->numlines--; - deleted++; - } - } - - // If we started in the middle of a sidedef the first and last lines - // may reference the same sidedef. check that, too. - - int loopstart = 0; - - ln1 = loop->GetLine(0); - for(i = loop->numlines - 1; i > 0; i--) - { - ln2 = loop->GetLine(i); - if (ln1->sidedef != ln2->sidedef || ln1->otherside != ln2->otherside) - break; - } - if (i < loop->numlines-1) - { - i++; - ln2 = loop->GetLine(i); - ln1->start = ln2->start; - SectionLines.Delete(loop->startline + i, loop->numlines - i); - deleted += loop->numlines - i; - loop->numlines = i; - } - - // Adjust all following loops - for(unsigned ii = unsigned(loop - &SectionLoops[0]) + 1; ii < SectionLoops.Size(); ii++) - { - SectionLoops[ii].startline -= deleted; - } - } - - //============================================================================= - // - // - // - //============================================================================= - void SetReferences() - { - for(unsigned i = 0; i < SectionLines.Size(); i++) - { - FGLSectionLine *ln = &SectionLines[i]; - seg_t *seg = ln->refseg; - - if (seg != NULL) - { - seg_t *partner = seg->PartnerSeg; - - if (seg->PartnerSeg == NULL) - { - ln->otherside = -1; - } - else - { - ln->otherside = section_for_segs[partner-segs]; - } - } - else - { - ln->otherside = -1; - } - } - - for(unsigned i = 0; i < SectionLoops.Size(); i++) - { - MergeLines(&SectionLoops[i]); - } - } - - //============================================================================= - // - // cbTessBegin - // - // called when the tesselation of a new loop starts - // - //============================================================================= - - static void CALLBACK cbTessBegin(GLenum type, void *section) - { - FGLSection *sect = (FGLSection*)section; - sect->vertices.Push(-int(type)); - } - - //============================================================================= - // - // cbTessError - // - // called when the tesselation failed - // - //============================================================================= - - static void CALLBACK cbTessError(GLenum error, void *section) - { - } - - //============================================================================= - // - // cbTessCombine - // - // called when the two or more vertexes are on the same coordinate - // - //============================================================================= - - static void CALLBACK cbTessCombine( GLdouble coords[3], void *vert[4], GLfloat w[4], void **dataOut ) - { - *dataOut = vert[0]; - } - - //============================================================================= - // - // cbTessVertex - // - // called when a vertex is found - // - //============================================================================= - - static void CALLBACK cbTessVertex( void *vert, void *section ) - { - FGLSection *sect = (FGLSection*)section; - sect->vertices.Push(int(intptr_t(vert))); - } - - //============================================================================= - // - // cbTessEnd - // - // called when the tesselation of a the current loop ends - // - //============================================================================= - - static void CALLBACK cbTessEnd(void *section) - { - } - - //============================================================================= - // - // - // - //============================================================================= - void tesselateSections() - { - // init tesselator - GLUtesselator *tess = gluNewTess(); - if (!tess) - { - return; - } - // set callbacks - gluTessCallback(tess, GLU_TESS_BEGIN_DATA, (tessFunc)cbTessBegin); - gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (tessFunc)cbTessVertex); - gluTessCallback(tess, GLU_TESS_ERROR_DATA, (tessFunc)cbTessError); - gluTessCallback(tess, GLU_TESS_COMBINE, (tessFunc)cbTessCombine); - gluTessCallback(tess, GLU_TESS_END_DATA, (tessFunc)cbTessEnd); - - for(unsigned int i=0;inumloops; j++) - { - gluTessBeginContour(tess); - FGLSectionLoop *loop = sect->GetLoop(j); - for(int k=0; knumlines; k++) - { - FGLSectionLine *line = loop->GetLine(k); - vertex_t *vert = line->start; - GLdouble v[3] = { - -(double)vert->x/(double)FRACUNIT, // negate to get proper winding - 0.0, - (double)vert->y/(double)FRACUNIT - }; - gluTessVertex(tess, v, (void*)(vert - vertexes)); - } - gluTessEndContour(tess); - } - gluTessEndPolygon(tess); - sect->vertices.Push(-1337); - sect->vertices.ShrinkToFit(); - } - gluDeleteTess(tess); - } - - - //============================================================================= - // - // First mark all subsectors that have no outside boundaries as processed - // No line in such a subsector will ever be part of a section's border - // - //============================================================================= - - void MarkInternalSubsectors() - { - for(int i=0; i < numsubsectors; i++) - { - subsector_t *sub = &subsectors[i]; - int j; - - for(j=0; j < sub->numlines; j++) - { - seg_t *seg = sub->firstline + j; - if (!IntraSectorSeg(seg)) break; - } - if (j==sub->numlines) - { - // All lines are intra-sector so mark this as processed - SETDONE(i, processed_subsectors); - for(j=0; j < sub->numlines; j++) - { - seg_t *seg = sub->firstline + j; - SETDONE((sub->firstline-segs)+j, processed_segs); - if (seg->PartnerSeg != NULL) - { - SETDONE(int(seg->PartnerSeg - segs), processed_segs); - } - } - } - } - } - - //============================================================================= - // - // - // - //============================================================================= - bool CreateSections() - { - int pick = 0; - - MarkInternalSubsectors(); - while (pick < numsubsectors) - { - if (ISDONE(pick, processed_subsectors)) - { - pick++; - continue; - } - - - subsector_t *subsector = &subsectors[pick]; - - seg_t *workseg = NULL; - vertex_t *startpt = NULL; - - NewSection(subsector->render_sector); - while (1) - { - if (!ISDONE(subsector-subsectors, processed_subsectors)) - { - SETDONE(subsector-subsectors, processed_subsectors); - section->subsectors.Push(subsector); - SectionForSubsector[subsector - subsectors] = int(section - &Sections[0]); - } - - bool result = AddSubSector(subsector, startpt, &workseg); - - if (!result) - { - return false; // couldn't create Sections - } - else if (workseg != NULL) - { - // crossing into another subsector - seg_t *partner = workseg->PartnerSeg; - if (workseg->v2 != partner->v1) - { - DPrintf("Inconsistent subsector references in seg %d. Cannot create Sections.\n", workseg-segs); - return false; - } - subsector = partner->Subsector; - startpt = workseg->v1; - } - else - { - // loop complete. Check adjoining subsectors for other loops to - // be added to this section - if (!FindNextSeg(&workseg)) - { - return false; - } - else if (workseg == NULL) - { - // No more subsectors found. This section is complete! - FinalizeSection(); - break; - } - else - { - subsector = workseg->Subsector; - // If this is a regular seg, start there, otherwise start - // at the subsector's first seg - startpt = workseg->sidedef == NULL? NULL : workseg->v1; - - NewLoop(); - } - } - } - } - - if (!CheckSections()) return false; - SetReferences(); - - Sections.ShrinkToFit(); - SectionLoops.ShrinkToFit(); - SectionLines.ShrinkToFit(); - - tesselateSections(); - - return true; - } -}; - -FSectionCreator *FSectionCreator::creator; - - -//============================================================================= -// -// -// -//============================================================================= - -void DumpSection(int no, FGLSection *sect) -{ - Printf(PRINT_LOG, "Section %d, sector %d\n{\n", no, sect->sector->sectornum); - - for(int i = 0; i < sect->numloops; i++) - { - Printf(PRINT_LOG, "\tLoop %d\n\t{\n", i); - - FGLSectionLoop *loop = sect->GetLoop(i); - - for(int i = 0; i < loop->numlines; i++) - { - FGLSectionLine *ln = loop->GetLine(i); - if (ln->sidedef != NULL) - { - vertex_t *v1 = V1(ln->sidedef); - vertex_t *v2 = V2(ln->sidedef); - double dx = FIXED2FLOAT(v2->x-v1->x); - double dy = FIXED2FLOAT(v2->y-v1->y); - double dx1 = FIXED2FLOAT(ln->start->x-v1->x); - double dy1 = FIXED2FLOAT(ln->start->y-v1->y); - double dx2 = FIXED2FLOAT(ln->end->x-v1->x); - double dy2 = FIXED2FLOAT(ln->end->y-v1->y); - double d = sqrt(dx*dx+dy*dy); - double d1 = sqrt(dx1*dx1+dy1*dy1); - double d2 = sqrt(dx2*dx2+dy2*dy2); - - Printf(PRINT_LOG, "\t\tLinedef %d, %s: Start (%1.2f, %1.2f), End (%1.2f, %1.2f)", - ln->linedef - lines, ln->sidedef == ln->linedef->sidedef[0]? "front":"back", - ln->start->x/65536.f, ln->start->y/65536.f, - ln->end->x/65536.f, ln->end->y/65536.f); - - if (ln->otherside != -1) - { - Printf (PRINT_LOG, ", other side = %d", ln->otherside); - } - if (d1 > 0.005 || d2 < 0.995) - { - Printf(PRINT_LOG, ", Range = %1.3f, %1.3f", d1/d, d2/d); - } - } - else - { - Printf(PRINT_LOG, "\t\tMiniseg: Start (%1.3f, %1.3f), End (%1.3f, %1.3f)\n", - ln->start->x/65536.f, ln->start->y/65536.f, ln->end->x/65536.f, ln->end->y/65536.f); - - if (ln->otherside != -1) - { - Printf (PRINT_LOG, ", other side = %d", ln->otherside); - } - } - Printf(PRINT_LOG, "\n"); - } - Printf(PRINT_LOG, "\t}\n"); - } - int prim = 1; - for(unsigned i = 0; i < sect->vertices.Size(); i++) - { - int v = sect->vertices[i]; - if (v < 0) - { - if (i > 0) - { - Printf(PRINT_LOG, "\t}\n"); - } - switch (v) - { - case -GL_TRIANGLE_FAN: - Printf(PRINT_LOG, "\t%d: Triangle fan\n\t{\n", prim); - break; - - case -GL_TRIANGLE_STRIP: - Printf(PRINT_LOG, "\t%d: Triangle strip\n\t{\n", prim); - break; - - case -GL_TRIANGLES: - Printf(PRINT_LOG, "\t%d: Triangles\n\t{\n", prim); - break; - - default: - break; - } - prim++; - } - else - { - Printf(PRINT_LOG, "\t\tVertex %d: (%1.2f, %1.2f)\n", - v, vertexes[v].x/65536.f, vertexes[v].y/65536.f); - } - } - Printf(PRINT_LOG, "}\n\n"); -} - -//============================================================================= -// -// -// -//============================================================================= - -void DumpSections() -{ - for(unsigned i = 0; i < Sections.Size(); i++) - { - DumpSection(i, &Sections[i]); - } -} - -//============================================================================= -// -// -// -//============================================================================= - -void gl_CreateSections() -{ - SectionLines.Clear(); - SectionLoops.Clear(); - Sections.Clear(); - SectionForSubsector.Resize(numsubsectors); - memset(&SectionForSubsector[0], -1, numsubsectors * sizeof(SectionForSubsector[0])); - FSectionCreator creat; - creat.CreateSections(); - if (dumpsections) DumpSections(); -} - - - -#endif diff --git a/src/gl/data/gl_sections.h b/src/gl/data/gl_sections.h deleted file mode 100644 index b64886791..000000000 --- a/src/gl/data/gl_sections.h +++ /dev/null @@ -1,56 +0,0 @@ - -#ifndef __GL_SECTIONS_H -#define __GL_SECTIONS_H - -#include "tarray.h" -#include "r_defs.h" - -struct FGLSectionLine -{ - vertex_t *start; - vertex_t *end; - side_t *sidedef; - line_t *linedef; - seg_t *refseg; // we need to reference at least one seg for each line. - subsector_t *polysub; // If this is part of a polyobject we need a reference to the containing subsector - int otherside; -}; - -struct FGLSectionLoop -{ - int startline; - int numlines; - - FGLSectionLine *GetLine(int no); -}; - -struct FGLSection -{ - sector_t *sector; - TArray subsectors; - TArray vertices; - int startloop; - int numloops; - int validcount; - - FGLSectionLoop *GetLoop(int no); -}; - -extern TArray SectionLines; -extern TArray SectionLoops; -extern TArray Sections; -extern TArray SectionForSubsector; - -inline FGLSectionLine *FGLSectionLoop::GetLine(int no) -{ - return &SectionLines[startline + no]; -} - -inline FGLSectionLoop *FGLSection::GetLoop(int no) -{ - return &SectionLoops[startloop + no]; -} - -void gl_CreateSections(); - -#endif \ No newline at end of file diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index be6c6415f..648bac770 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -75,6 +75,105 @@ int FHardwareTexture::GetTexDimension(int value) return value; } + +//=========================================================================== +// +// Quick'n dirty image rescaling. +// +// This will only be used when the source texture is larger than +// what the hardware can manage (extremely rare in Doom) +// +// Code taken from wxWidgets +// +//=========================================================================== + +struct BoxPrecalc +{ + int boxStart; + int boxEnd; +}; + +static void ResampleBoxPrecalc(TArray& boxes, int oldDim) +{ + int newDim = boxes.Size(); + const double scale_factor_1 = double(oldDim) / newDim; + const int scale_factor_2 = (int)(scale_factor_1 / 2); + + for (int dst = 0; dst < newDim; ++dst) + { + // Source pixel in the Y direction + const int src_p = int(dst * scale_factor_1); + + BoxPrecalc& precalc = boxes[dst]; + precalc.boxStart = clamp(int(src_p - scale_factor_1 / 2.0 + 1), 0, oldDim - 1); + precalc.boxEnd = clamp(MAX(precalc.boxStart + 1, int(src_p + scale_factor_2)), 0, oldDim - 1); + } +} + +void FHardwareTexture::Resize(int width, int height, unsigned char *src_data, unsigned char *dst_data) +{ + + // This function implements a simple pre-blur/box averaging method for + // downsampling that gives reasonably smooth results To scale the image + // down we will need to gather a grid of pixels of the size of the scale + // factor in each direction and then do an averaging of the pixels. + + TArray vPrecalcs(height); + TArray hPrecalcs(width); + + ResampleBoxPrecalc(vPrecalcs, texheight); + ResampleBoxPrecalc(hPrecalcs, texwidth); + + int averaged_pixels, averaged_alpha, src_pixel_index; + double sum_r, sum_g, sum_b, sum_a; + + for (int y = 0; y < height; y++) // Destination image - Y direction + { + // Source pixel in the Y direction + const BoxPrecalc& vPrecalc = vPrecalcs[y]; + + for (int x = 0; x < width; x++) // Destination image - X direction + { + // Source pixel in the X direction + const BoxPrecalc& hPrecalc = hPrecalcs[x]; + + // Box of pixels to average + averaged_pixels = 0; + averaged_alpha = 0; + sum_r = sum_g = sum_b = sum_a = 0.0; + + for (int j = vPrecalc.boxStart; j <= vPrecalc.boxEnd; ++j) + { + for (int i = hPrecalc.boxStart; i <= hPrecalc.boxEnd; ++i) + { + // Calculate the actual index in our source pixels + src_pixel_index = j * texwidth + i; + + int a = src_data[src_pixel_index * 4 + 3]; + if (a > 0) // do not use color from fully transparent pixels + { + sum_r += src_data[src_pixel_index * 4 + 0]; + sum_g += src_data[src_pixel_index * 4 + 1]; + sum_b += src_data[src_pixel_index * 4 + 2]; + sum_a += a; + averaged_pixels++; + } + averaged_alpha++; + + } + } + + // Calculate the average from the sum and number of averaged pixels + dst_data[0] = (unsigned char)xs_CRoundToInt(sum_r / averaged_pixels); + dst_data[1] = (unsigned char)xs_CRoundToInt(sum_g / averaged_pixels); + dst_data[2] = (unsigned char)xs_CRoundToInt(sum_b / averaged_pixels); + dst_data[3] = (unsigned char)xs_CRoundToInt(sum_a / averaged_alpha); + dst_data += 4; + } + } +} + + //=========================================================================== // // Loads the texture image into the hardware @@ -124,7 +223,7 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i unsigned char * scaledbuffer=(unsigned char *)calloc(4,rw * (rh+1)); if (scaledbuffer) { - gluScaleImage(GL_RGBA,w, h,GL_UNSIGNED_BYTE,buffer, rw, rh, GL_UNSIGNED_BYTE,scaledbuffer); + Resize(rw, rh, buffer, scaledbuffer); deletebuffer=true; buffer=scaledbuffer; } diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h index da093df4e..5b5e55ac5 100644 --- a/src/gl/textures/gl_hwtexture.h +++ b/src/gl/textures/gl_hwtexture.h @@ -57,6 +57,7 @@ private: int GetDepthBuffer(); void DeleteTexture(unsigned int texid); + void Resize(int width, int height, unsigned char *src_data, unsigned char *dst_data); public: FHardwareTexture(int w, int h, bool mip, bool wrap, bool nofilter, bool nocompress); From 314225f1b0b8f95433d4099f35b90dabd4368e62 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 1 May 2014 12:30:56 +0200 Subject: [PATCH 0068/1509] - don't depend on stdint.h because older MSVC versions do not have it. --- src/gl/hqnx/common.h | 2 +- src/gl/hqnx/hq2x.cpp | 2 +- src/gl/hqnx/hq3x.cpp | 2 +- src/gl/hqnx/hq4x.cpp | 2 +- src/gl/hqnx/hqx.h | 2 +- src/gl/hqnx/init.cpp | 2 +- src/gl/hqnx/mystdint.h | 19 +++++++++++++++++++ 7 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 src/gl/hqnx/mystdint.h diff --git a/src/gl/hqnx/common.h b/src/gl/hqnx/common.h index c3e700571..3388651bf 100644 --- a/src/gl/hqnx/common.h +++ b/src/gl/hqnx/common.h @@ -23,7 +23,7 @@ #define __HQX_COMMON_H_ #include -#include +#include "mystdint.h" #define MASK_2 0x0000FF00 #define MASK_13 0x00FF00FF diff --git a/src/gl/hqnx/hq2x.cpp b/src/gl/hqnx/hq2x.cpp index 94c1dfb5a..679a8c2b6 100644 --- a/src/gl/hqnx/hq2x.cpp +++ b/src/gl/hqnx/hq2x.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include "mystdint.h" #include "common.h" #include "hqx.h" diff --git a/src/gl/hqnx/hq3x.cpp b/src/gl/hqnx/hq3x.cpp index 6ffa6228d..cbc7fab39 100644 --- a/src/gl/hqnx/hq3x.cpp +++ b/src/gl/hqnx/hq3x.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include "mystdint.h" #include "common.h" #include "hqx.h" diff --git a/src/gl/hqnx/hq4x.cpp b/src/gl/hqnx/hq4x.cpp index 0a7b7512d..7ad6e06c3 100644 --- a/src/gl/hqnx/hq4x.cpp +++ b/src/gl/hqnx/hq4x.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include "mystdint.h" #include "common.h" #include "hqx.h" diff --git a/src/gl/hqnx/hqx.h b/src/gl/hqnx/hqx.h index 089b5a0bc..ee968a561 100644 --- a/src/gl/hqnx/hqx.h +++ b/src/gl/hqnx/hqx.h @@ -21,7 +21,7 @@ #ifndef __HQX_H_ #define __HQX_H_ -#include +#include "mystdint.h" #if defined( __GNUC__ ) #ifdef __MINGW32__ diff --git a/src/gl/hqnx/init.cpp b/src/gl/hqnx/init.cpp index a3d97ba88..f27d45a65 100644 --- a/src/gl/hqnx/init.cpp +++ b/src/gl/hqnx/init.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include "mystdint.h" #include "hqx.h" uint32_t *RGBtoYUV; diff --git a/src/gl/hqnx/mystdint.h b/src/gl/hqnx/mystdint.h new file mode 100644 index 000000000..b2da9df8c --- /dev/null +++ b/src/gl/hqnx/mystdint.h @@ -0,0 +1,19 @@ +#ifndef __MYSTDINT_H +#define __MYSTDINT_H + +#ifndef _MSC_VER +#include +#else +typedef unsigned __int64 uint64_t; +typedef signed __int64 int64_t; +typedef unsigned __int32 uint32_t; +typedef signed __int32 int32_t; +typedef unsigned __int16 uint16_t; +typedef signed __int16 int16_t; +typedef unsigned __int8 uint8_t; +typedef signed __int8 int8_t; +#endif + + + +#endif \ No newline at end of file From 1d4ea9f16286c600514982e6d22f2ebc36b6192f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 May 2014 09:48:39 +0200 Subject: [PATCH 0069/1509] - removed the __asm nop breakpoints for debugging. They not only do not work on non-MSVC but also not on 64 bit. --- src/gl/data/gl_setup.cpp | 4 +--- src/gl/scene/gl_bsp.cpp | 12 +++++------- src/gl/scene/gl_fakeflat.cpp | 4 +--- src/gl/scene/gl_flats.cpp | 14 ++++---------- src/gl/scene/gl_walls.cpp | 12 ++++++------ src/gl/scene/gl_walls_draw.cpp | 6 +++--- 6 files changed, 20 insertions(+), 32 deletions(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index 342f58fa1..a76e618d9 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -312,13 +312,11 @@ static void PrepareTransparentDoors(sector_t * sector) int i; sector_t * nextsec=NULL; -#ifdef _MSC_VER #ifdef _DEBUG if (sector-sectors==2) { - __asm nop + int a = 0; } -#endif #endif P_Recalculate3DFloors(sector); diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index b8a1eeec0..5bdb99b88 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -96,11 +96,11 @@ static sector_t *currentsector; static void AddLine (seg_t *seg) { -#ifdef _MSC_VER #ifdef _DEBUG - if (seg->linedef-lines==38) - __asm nop -#endif + if (seg->linedef - lines == 38) + { + int a = 0; + } #endif angle_t startAngle, endAngle; @@ -382,13 +382,11 @@ static void DoSubsector(subsector_t * sub) //if (!clipper.CheckBox(sub->bbox)) return; -#ifdef _MSC_VER #ifdef _DEBUG if (sub->sector-sectors==931) { - __asm nop + int a = 0; } -#endif #endif sector=sub->sector; diff --git a/src/gl/scene/gl_fakeflat.cpp b/src/gl/scene/gl_fakeflat.cpp index 122bae0e6..d46449ddb 100644 --- a/src/gl/scene/gl_fakeflat.cpp +++ b/src/gl/scene/gl_fakeflat.cpp @@ -218,13 +218,11 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac return sec; } -#ifdef _MSC_VER #ifdef _DEBUG if (sec-sectors==560) { - __asm nop + int a = 0; } -#endif #endif if (in_area==area_above) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 441c8b73f..3efdcba8b 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -334,11 +334,11 @@ void GLFlat::Draw(int pass) int i; int rel = getExtraLight(); -#ifdef _MSC_VER #ifdef _DEBUG if (sector->sectornum == 2) - __asm nop -#endif + { + int a = 0; + } #endif @@ -572,17 +572,11 @@ void GLFlat::ProcessSector(sector_t * frontsector) { lightlist_t * light; -#ifdef _MSC_VER #ifdef _DEBUG - if (frontsector==NULL) - { - __asm int 3 - } if (frontsector->sectornum==0) { - __asm nop + int a = 0; } -#endif #endif // Get the real sector for this one. diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 6c8b32766..c65e1aa3b 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -311,11 +311,11 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) } ::SplitWall.Clock(); -#ifdef _MSC_VER #ifdef _DEBUG if (seg->linedef-lines==1) - __asm nop -#endif + { + int a = 0; + } #endif if (lightlist.Size()>1) @@ -1445,11 +1445,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) sector_t * realfront; sector_t * realback; -#ifdef _MSC_VER #ifdef _DEBUG if (seg->linedef-lines==636) - __asm nop -#endif + { + int a = 0; + } #endif // note: we always have a valid sidedef and linedef reference when getting here. diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index d97475029..c71e23a20 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -459,11 +459,11 @@ void GLWall::Draw(int pass) FLightNode * node; int rel; -#ifdef _MSC_VER #ifdef _DEBUG if (seg->linedef-lines==879) - __asm nop -#endif + { + int a = 0; + } #endif From b09405a8bd2f3cb5918114d903d24abf00a34fd0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 10 May 2014 17:09:43 +0200 Subject: [PATCH 0070/1509] - changed rendering of glowing walls so that it doesn't require an additional vertex attribute, just pass the floor and ceiling planes as uniforms. --- src/gl/renderer/gl_renderstate.cpp | 11 +++++++++++ src/gl/renderer/gl_renderstate.h | 10 +++++++++- src/gl/scene/gl_vertex.cpp | 16 ++++------------ src/gl/scene/gl_wall.h | 11 +++++------ src/gl/scene/gl_walls.cpp | 4 ++++ src/gl/scene/gl_walls_draw.cpp | 22 ++++++++++------------ src/gl/shaders/gl_shader.cpp | 5 +++-- src/gl/shaders/gl_shader.h | 12 ++++++++---- wadsrc/static/shaders/glsl/main.vp | 15 +++------------ 9 files changed, 57 insertions(+), 49 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 19af11168..73cc5ec90 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -237,7 +237,18 @@ bool FRenderState::ApplyShader() { glUniform4fv(activeShader->glowtopcolor_index, 1, mGlowTop.vec); glUniform4fv(activeShader->glowbottomcolor_index, 1, mGlowBottom.vec); + glUniform4fv(activeShader->glowtopplane_index, 1, mGlowTopPlane.vec); + glUniform4fv(activeShader->glowbottomplane_index, 1, mGlowBottomPlane.vec); + activeShader->currentglowstate = 1; } + else if (activeShader->currentglowstate) + { + // if glowing is on, disable it. + glUniform4f(activeShader->glowtopcolor_index, 0.f, 0.f, 0.f, 0.f); + glUniform4f(activeShader->glowbottomcolor_index, 0.f, 0.f, 0.f, 0.f); + activeShader->currentglowstate = 0; + } + if (mLightEnabled) { glUniform3iv(activeShader->lightrange_index, 1, mNumLights); diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 6fea56707..061f5c2df 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -3,6 +3,7 @@ #include #include "c_cvars.h" +#include "r_defs.h" EXTERN_CVAR(Bool, gl_direct_state_change) @@ -105,6 +106,7 @@ class FRenderState FStateVec3 mCameraPos; FStateVec4 mGlowTop, mGlowBottom; + FStateVec4 mGlowTopPlane, mGlowBottomPlane; PalEntry mFogColor; float mFogDensity; @@ -184,7 +186,13 @@ public: mGlowBottom.Set(b[0], b[1], b[2], b[3]); } - void SetDynLight(float r,float g, float b) + void SetGlowPlanes(const secplane_t &top, const secplane_t &bottom) + { + mGlowTopPlane.Set(FIXED2FLOAT(top.a), FIXED2FLOAT(top.b), FIXED2FLOAT(top.ic), FIXED2FLOAT(top.d)); + mGlowBottomPlane.Set(FIXED2FLOAT(bottom.a), FIXED2FLOAT(bottom.b), FIXED2FLOAT(bottom.ic), FIXED2FLOAT(bottom.d)); + } + + void SetDynLight(float r, float g, float b) { mDynLight[0] = r; mDynLight[1] = g; diff --git a/src/gl/scene/gl_vertex.cpp b/src/gl/scene/gl_vertex.cpp index 4df381311..3aff28d1f 100644 --- a/src/gl/scene/gl_vertex.cpp +++ b/src/gl/scene/gl_vertex.cpp @@ -61,7 +61,7 @@ extern int vertexcount; // //========================================================================== -void GLWall::SplitUpperEdge(texcoord * tcs, bool glow) +void GLWall::SplitUpperEdge(texcoord * tcs) { if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; @@ -82,9 +82,6 @@ void GLWall::SplitUpperEdge(texcoord * tcs, bool glow) float fracfac = sidefrac - glseg.fracleft; - if (glow) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - ztop[0] + (facc - fact) * fracfac, - ztop[0] - zfloor[0] + (fact - facf) * fracfac); - glTexCoord2f(tcs[1].u + facu * fracfac, tcs[1].v + facv * fracfac); glVertex3f(cseg->v2->fx, ztop[0] + fact * fracfac, cseg->v2->fy); } @@ -97,7 +94,7 @@ void GLWall::SplitUpperEdge(texcoord * tcs, bool glow) // //========================================================================== -void GLWall::SplitLowerEdge(texcoord * tcs, bool glow) +void GLWall::SplitLowerEdge(texcoord * tcs) { if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; @@ -118,9 +115,6 @@ void GLWall::SplitLowerEdge(texcoord * tcs, bool glow) float fracfac = sidefrac - glseg.fracleft; - if (glow) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - zbottom[0] + (facc - facb) * fracfac, - zbottom[0] - zfloor[0] + (facb - facf) * fracfac); - glTexCoord2f(tcs[0].u + facu * fracfac, tcs[0].v + facv * fracfac); glVertex3f(cseg->v2->fx, zbottom[0] + facb * fracfac, cseg->v2->fy); } @@ -133,7 +127,7 @@ void GLWall::SplitLowerEdge(texcoord * tcs, bool glow) // //========================================================================== -void GLWall::SplitLeftEdge(texcoord * tcs, bool glow) +void GLWall::SplitLeftEdge(texcoord * tcs) { if (vertexes[0]==NULL) return; @@ -150,7 +144,6 @@ void GLWall::SplitLeftEdge(texcoord * tcs, bool glow) while (inumheights && vi->heightlist[i] <= zbottom[0] ) i++; while (inumheights && vi->heightlist[i] < ztop[0]) { - if (glow) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - vi->heightlist[i], vi->heightlist[i] - zfloor[0]); glTexCoord2f(factu1*(vi->heightlist[i] - ztop[0]) + tcs[1].u, factv1*(vi->heightlist[i] - ztop[0]) + tcs[1].v); glVertex3f(glseg.x1, vi->heightlist[i], glseg.y1); @@ -166,7 +159,7 @@ void GLWall::SplitLeftEdge(texcoord * tcs, bool glow) // //========================================================================== -void GLWall::SplitRightEdge(texcoord * tcs, bool glow) +void GLWall::SplitRightEdge(texcoord * tcs) { if (vertexes[1]==NULL) return; @@ -183,7 +176,6 @@ void GLWall::SplitRightEdge(texcoord * tcs, bool glow) while (i>0 && vi->heightlist[i] >= ztop[1]) i--; while (i>0 && vi->heightlist[i] > zbottom[1]) { - if (glow) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - vi->heightlist[i], vi->heightlist[i] - zfloor[1]); glTexCoord2f(factu2 * (vi->heightlist[i] - ztop[1]) + tcs[2].u, factv2 * (vi->heightlist[i] - ztop[1]) + tcs[2].v); glVertex3f(glseg.x2, vi->heightlist[i], glseg.y2); diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 00459644c..e53513167 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -141,6 +141,7 @@ public: FTextureID topflat,bottomflat; + secplane_t topplane, bottomplane; // we need to save these to pass them to the shader for calculating glows. // these are not the same as ytop and ybottom!!! float zceil[2]; @@ -158,8 +159,6 @@ private: void SetupLights(); bool PrepareLight(texcoord * tcs, ADynamicLight * light); void RenderWall(int textured, float * color2, ADynamicLight * light=NULL); - void RenderGlowingPoly(int textured, ADynamicLight * light=NULL); - int Intersection(FloatRect * rc,GLWall * result); void FloodPlane(int pass); @@ -211,10 +210,10 @@ private: void RenderMirrorSurface(); void RenderTranslucentWall(); - void SplitLeftEdge(texcoord * tcs, bool glow); - void SplitRightEdge(texcoord * tcs, bool glow); - void SplitUpperEdge(texcoord * tcs, bool glow); - void SplitLowerEdge(texcoord * tcs, bool glow); + void SplitLeftEdge(texcoord * tcs); + void SplitRightEdge(texcoord * tcs); + void SplitUpperEdge(texcoord * tcs); + void SplitLowerEdge(texcoord * tcs); public: diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index c65e1aa3b..2d14e0949 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1539,6 +1539,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) topflat=frontsector->GetTexture(sector_t::ceiling); // for glowing textures. These must be saved because bottomflat=frontsector->GetTexture(sector_t::floor); // the sector passed here might be a temporary copy. + topplane = frontsector->ceilingplane; + bottomplane = frontsector->floorplane; // Save a little time (up to 0.3 ms per frame ;) ) if (frontsector->floorplane.a | frontsector->floorplane.b) @@ -1775,6 +1777,8 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * topflat = frontsector->GetTexture(sector_t::ceiling); // for glowing textures bottomflat = frontsector->GetTexture(sector_t::floor); + topplane = frontsector->ceilingplane; + bottomplane = frontsector->floorplane; zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index c71e23a20..d7edc6ef7 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -223,7 +223,6 @@ void GLWall::SetupLights() void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) { texcoord tcs[4]; - bool glowing; bool split = (gl_seamless && !(textured&4) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ)); if (!light) @@ -232,15 +231,18 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) tcs[1]=uplft; tcs[2]=uprgt; tcs[3]=lorgt; - glowing = !!(flags&GLWF_GLOW) && (textured & 2); + if (!!(flags&GLWF_GLOW) && (textured & 2)) + { + gl_RenderState.SetGlowPlanes(topplane, bottomplane); + gl_RenderState.SetGlowParams(topglowcolor, bottomglowcolor); + } + } else { if (!PrepareLight(tcs, light)) return; - glowing = false; } - if (glowing) gl_RenderState.SetGlowParams(topglowcolor, bottomglowcolor); gl_RenderState.Apply(); @@ -249,35 +251,31 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) glBegin(GL_TRIANGLE_FAN); // lower left corner - if (glowing) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - zbottom[0], zbottom[0] - zfloor[0]); if (textured&1) glTexCoord2f(tcs[0].u,tcs[0].v); glVertex3f(glseg.x1,zbottom[0],glseg.y1); - if (split && glseg.fracleft==0) SplitLeftEdge(tcs, glowing); + if (split && glseg.fracleft==0) SplitLeftEdge(tcs); // upper left corner - if (glowing) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - ztop[0], ztop[0] - zfloor[0]); if (textured&1) glTexCoord2f(tcs[1].u,tcs[1].v); glVertex3f(glseg.x1,ztop[0],glseg.y1); - if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs, glowing); + if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs); // color for right side if (color2) glColor4fv(color2); // upper right corner - if (glowing) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - ztop[1], ztop[1] - zfloor[1]); if (textured&1) glTexCoord2f(tcs[2].u,tcs[2].v); glVertex3f(glseg.x2,ztop[1],glseg.y2); - if (split && glseg.fracright==1) SplitRightEdge(tcs, glowing); + if (split && glseg.fracright==1) SplitRightEdge(tcs); // lower right corner - if (glowing) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - zbottom[1], zbottom[1] - zfloor[1]); if (textured&1) glTexCoord2f(tcs[3].u,tcs[3].v); glVertex3f(glseg.x2,zbottom[1],glseg.y2); - if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, glowing); + if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs); glEnd(); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 241c5097f..ca1921bd4 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -141,7 +141,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * glAttachShader(hShader, hVertProg); glAttachShader(hShader, hFragProg); - glBindAttribLocation(hShader, VATTR_GLOWDISTANCE, "glowdistance"); glBindAttribLocation(hShader, VATTR_FOGPARAMS, "fogparams"); glBindAttribLocation(hShader, VATTR_LIGHTLEVEL, "lightlevel_in"); // Korshun. @@ -185,7 +184,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * glowbottomcolor_index = glGetUniformLocation(hShader, "bottomglowcolor"); glowtopcolor_index = glGetUniformLocation(hShader, "topglowcolor"); - + glowbottomplane_index = glGetUniformLocation(hShader, "glowbottomplane"); + glowtopplane_index = glGetUniformLocation(hShader, "glowtopplane"); + glUseProgram(hShader); int texture_index = glGetUniformLocation(hShader, "texture2"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 0211eeac0..61053287c 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -7,7 +7,6 @@ extern bool gl_shaderactive; -const int VATTR_GLOWDISTANCE = 15; const int VATTR_FOGPARAMS = 14; const int VATTR_LIGHTLEVEL = 13; // Korshun. @@ -37,10 +36,12 @@ class FShader int fogcolor_index; int lights_index; int dlightcolor_index; - int glowbottomcolor_index; int glowtopcolor_index; + int glowbottomplane_index; + int glowtopplane_index; + int currentglowstate; int currentfogenabled; int currenttexturemode; float currentlightfactor; @@ -55,7 +56,7 @@ public: FShader() { hShader = hVertProg = hFragProg = 0; - currentfogenabled = currenttexturemode = 0; + currentglowstate = currentfogenabled = currenttexturemode = 0; currentlightfactor = currentlightdist = 0.0f; currentfogdensity = -1; currentfogcolor = 0; @@ -72,7 +73,10 @@ public: fogcolor_index = -1; lights_index = -1; dlightcolor_index = -1; - + glowtopplane_index = -1; + glowbottomplane_index = -1; + glowtopcolor_index = -1; + glowbottomcolor_index = -1; } ~FShader(); diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 87402bed0..7aebb8171 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -5,7 +5,7 @@ #endif #ifndef NO_GLOW varying vec2 glowdist; - attribute vec2 glowdistance; + uniform vec4 glowbottomplane, glowtopplane; #endif #ifdef SOFTLIGHT @@ -36,7 +36,8 @@ void main() #endif #ifndef NO_GLOW - glowdist = glowdistance; + glowdist.x = -((glowtopplane.w + glowtopplane.x * worldcoord.x + glowtopplane.y * worldcoord.z) * glowtopplane.z) - worldcoord.y; + glowdist.y = worldcoord.y + ((glowbottomplane.w + glowbottomplane.x * worldcoord.x + glowbottomplane.y * worldcoord.z) * glowbottomplane.z); #endif #ifdef SPHEREMAP @@ -54,16 +55,6 @@ void main() gl_TexCoord[0].xy = sst; #endif - /* only for reference purposes. I don't think this will ever get used. - #ifdef NUM_LAYERS - #ifndef SPHEREMAP_1 - gl_TexCoord[1] = gl_TextureMatrix[1] * gl_MultiTexCoord0; - #else - gl_TexCoord[1].xy = sst; - #endif - #endif - */ - #ifndef NO_SM4 gl_Position = gl_ModelViewProjectionMatrix * worldcoord; #else From 7d3beb665b7a3e802ef57091ff423dffc7bf29b5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 10 May 2014 21:47:07 +0200 Subject: [PATCH 0071/1509] - rewrote vertex buffer code to require GL_ARB_BUFFER_STORAGE extension. This means it won't work anymore on anything that doesn't support OpenGL 4.0, but I don't think this is a problem. On older NVidia cards performance gains could not be seen and on older AMDs using the vertex buffer was even worse as long as it got mixed with immediate mode rendering. --- src/gl/data/gl_vertexbuffer.cpp | 106 ++++++++++------------------- src/gl/data/gl_vertexbuffer.h | 19 +++--- src/gl/models/gl_voxels.cpp | 26 +++---- src/gl/renderer/gl_renderstate.cpp | 8 +++ src/gl/renderer/gl_renderstate.h | 9 +++ src/gl/scene/gl_flats.cpp | 2 +- src/gl/scene/gl_scene.cpp | 3 +- src/gl/system/gl_interface.cpp | 43 ++++-------- src/gl/system/gl_interface.h | 13 +--- 9 files changed, 97 insertions(+), 132 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index c07b6cea3..c5703a8ef 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -49,20 +49,18 @@ #include "gl/data/gl_vertexbuffer.h" +const int BUFFER_SIZE = 2000000; + CUSTOM_CVAR(Int, gl_usevbo, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { - if (self < -1 || self > 2) + if (self < -1 || self > 1 || !(gl.flags & RFL_BUFFER_STORAGE)) { self = 0; } else if (self == -1) { - if (!(gl.flags & RFL_NVIDIA)) self = 0; - else self = 2; - } - else if (GLRenderer != NULL && GLRenderer->mVBO != NULL && GLRenderer->mVBO->vbo_arg != self) - { - Printf("Vertex buffer use will be changed for the next level.\n"); + if (!(gl.flags & RFL_BUFFER_STORAGE)) self = 0; + else self = 1; } } @@ -96,13 +94,24 @@ FVertexBuffer::~FVertexBuffer() FFlatVertexBuffer::FFlatVertexBuffer() : FVertexBuffer() { - vbo_arg = gl_usevbo; - map = NULL; + if (gl.flags & RFL_BUFFER_STORAGE) + { + unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + } + else + { + map = NULL; + } } FFlatVertexBuffer::~FFlatVertexBuffer() { - UnmapVBO(); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glUnmapBuffer(GL_ARRAY_BUFFER); + glBindBuffer(GL_ARRAY_BUFFER, 0); } //========================================================================== @@ -118,7 +127,6 @@ void FFlatVertex::SetFlatVertex(vertex_t *vt, const secplane_t & plane) z = plane.ZatPoint(vt->fx, vt->fy); u = vt->fx/64.f; v = -vt->fy/64.f; - w = /*dc = df =*/ 0; } //========================================================================== @@ -260,58 +268,18 @@ void FFlatVertexBuffer::CreateFlatVBO() // //========================================================================== -void FFlatVertexBuffer::MapVBO() -{ - if (map == NULL) - { - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, vbo_shadowdata.Size() * sizeof(FFlatVertex), - GL_MAP_WRITE_BIT|GL_MAP_FLUSH_EXPLICIT_BIT|GL_MAP_UNSYNCHRONIZED_BIT); - } -} - -//========================================================================== -// -// -// -//========================================================================== - -void FFlatVertexBuffer::UnmapVBO() -{ - if (map != NULL) - { - glUnmapBuffer(GL_ARRAY_BUFFER); - map = NULL; - } -} - -//========================================================================== -// -// -// -//========================================================================== - void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) { int startvt = sec->vboindex[plane]; int countvt = sec->vbocount[plane]; secplane_t &splane = sec->GetSecPlane(plane); FFlatVertex *vt = &vbo_shadowdata[startvt]; + FFlatVertex *mapvt = &map[startvt]; for(int i=0; iz = splane.ZatPoint(vt->x, vt->y); if (plane == sector_t::floor && sec->transdoor) vt->z -= 1; - } - if (gl.flags & RFL_MAP_BUFFER_RANGE) - { - MapVBO(); - if (map == NULL) return; // Error - memcpy(&map[startvt], &vbo_shadowdata[startvt], countvt * sizeof(FFlatVertex)); - glFlushMappedBufferRange(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex)); - } - else - { - glBufferSubData(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex), &vbo_shadowdata[startvt]); + mapvt->z = vt->z; } } @@ -324,11 +292,10 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) void FFlatVertexBuffer::CreateVBO() { vbo_shadowdata.Clear(); - if (vbo_arg > 0) + if (gl.flags & RFL_BUFFER_STORAGE) { CreateFlatVBO(); - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBufferData(GL_ARRAY_BUFFER, vbo_shadowdata.Size() * sizeof(FFlatVertex), &vbo_shadowdata[0], GL_DYNAMIC_DRAW); + memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); } else if (sectors) { @@ -350,16 +317,14 @@ void FFlatVertexBuffer::CreateVBO() void FFlatVertexBuffer::BindVBO() { - if (vbo_arg > 0) + if (gl.flags & RFL_BUFFER_STORAGE) { - UnmapVBO(); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glVertexPointer(3,GL_FLOAT, sizeof(FFlatVertex), &VTO->x); glTexCoordPointer(2,GL_FLOAT, sizeof(FFlatVertex), &VTO->u); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_INDEX_ARRAY); } } @@ -371,20 +336,23 @@ void FFlatVertexBuffer::BindVBO() void FFlatVertexBuffer::CheckPlanes(sector_t *sector) { - if (sector->GetPlaneTexZ(sector_t::ceiling) != sector->vboheight[sector_t::ceiling]) + if (gl.flags & RFL_BUFFER_STORAGE) { - if (sector->ceilingdata == NULL) // only update if there's no thinker attached + if (sector->GetPlaneTexZ(sector_t::ceiling) != sector->vboheight[sector_t::ceiling]) { - UpdatePlaneVertices(sector, sector_t::ceiling); - sector->vboheight[sector_t::ceiling] = sector->GetPlaneTexZ(sector_t::ceiling); + //if (sector->ceilingdata == NULL) // only update if there's no thinker attached + { + UpdatePlaneVertices(sector, sector_t::ceiling); + sector->vboheight[sector_t::ceiling] = sector->GetPlaneTexZ(sector_t::ceiling); + } } - } - if (sector->GetPlaneTexZ(sector_t::floor) != sector->vboheight[sector_t::floor]) - { - if (sector->floordata == NULL) // only update if there's no thinker attached + if (sector->GetPlaneTexZ(sector_t::floor) != sector->vboheight[sector_t::floor]) { - UpdatePlaneVertices(sector, sector_t::floor); - sector->vboheight[sector_t::floor] = sector->GetPlaneTexZ(sector_t::floor); + //if (sector->floordata == NULL) // only update if there's no thinker attached + { + UpdatePlaneVertices(sector, sector_t::floor); + sector->vboheight[sector_t::floor] = sector->GetPlaneTexZ(sector_t::floor); + } } } } diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 49db1c7db..2755b6494 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -20,11 +20,10 @@ public: virtual void BindVBO() = 0; }; -struct FFlatVertex // exactly 32 bytes large +struct FFlatVertex { - float x,z,y,w; // w only for padding to make one vertex 32 bytes - maybe it will find some use later + float x,z,y; // world position float u,v; // texture coordinates - //float dc, df; // distance to floor and ceiling on walls - used for glowing void SetFlatVertex(vertex_t *vt, const secplane_t &plane); }; @@ -35,27 +34,27 @@ struct FFlatVertex // exactly 32 bytes large class FFlatVertexBuffer : public FVertexBuffer { FFlatVertex *map; + unsigned int mIndex; - void MapVBO(); void CheckPlanes(sector_t *sector); public: int vbo_arg; - TArray vbo_shadowdata; // this is kept around for non-VBO rendering + TArray vbo_shadowdata; // this is kept around for updating the actual (non-readable) buffer -public: FFlatVertexBuffer(); ~FFlatVertexBuffer(); + void CreateVBO(); + void BindVBO(); + void CheckUpdate(sector_t *sector); + +private: int CreateSubsectorVertices(subsector_t *sub, const secplane_t &plane, int floor); int CreateSectorVertices(sector_t *sec, const secplane_t &plane, int floor); int CreateVertices(int h, sector_t *sec, const secplane_t &plane, int floor); void CreateFlatVBO(); - void CreateVBO(); void UpdatePlaneVertices(sector_t *sec, int plane); - void BindVBO(); - void CheckUpdate(sector_t *sector); - void UnmapVBO(); }; diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index f47685216..14ed5985c 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -506,25 +506,27 @@ void FVoxelModel::RenderFrame(FTexture * skin, int frame, int cm, int translatio { FMaterial * tex = FMaterial::ValidateTexture(skin); tex->Bind(cm, 0, translation); - gl_RenderState.Apply(); if (mVBO == NULL) MakeGLData(); if (mVBO != NULL) { - mVBO->BindVBO(); - glDrawElements(GL_QUADS, mIndices.Size(), mVBO->IsInt()? GL_UNSIGNED_INT:GL_UNSIGNED_SHORT, 0); - GLRenderer->mVBO->BindVBO(); - return; + gl_RenderState.SetVertexBuffer(mVBO); + gl_RenderState.Apply(); + glDrawElements(GL_QUADS, mIndices.Size(), mVBO->IsInt() ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, 0); + gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); } - - glBegin(GL_QUADS); - for(unsigned i=0;i < mIndices.Size(); i++) + else { - FVoxelVertex *vert = &mVertices[mIndices[i]]; - glTexCoord2fv(&vert->u); - glVertex3fv(&vert->x); + gl_RenderState.Apply(); + glBegin(GL_QUADS); + for (unsigned i = 0; i < mIndices.Size(); i++) + { + FVoxelVertex *vert = &mVertices[mIndices[i]]; + glTexCoord2fv(&vert->u); + glVertex3fv(&vert->x); + } + glEnd(); } - glEnd(); } //=========================================================================== diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 73cc5ec90..f0ceb40fa 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -41,6 +41,7 @@ #include "gl/system/gl_system.h" #include "gl/system/gl_interface.h" #include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" #include "gl/system/gl_cvars.h" #include "gl/shaders/gl_shader.h" #include "gl/renderer/gl_renderer.h" @@ -79,6 +80,7 @@ void FRenderState::Reset() mBlendEquation = GL_FUNC_ADD; glBlendEquation = -1; m2D = true; + mVertexBuffer = mCurrentVertexBuffer = NULL; } @@ -300,6 +302,12 @@ void FRenderState::Apply(bool forcenoshader) } } + if (mVertexBuffer != mCurrentVertexBuffer) + { + if (mVertexBuffer == NULL) glBindBuffer(GL_ARRAY_BUFFER, 0); + else mVertexBuffer->BindVBO(); + mCurrentVertexBuffer = mVertexBuffer; + } if (forcenoshader || !ApplyShader()) { GLRenderer->mShaderManager->SetActiveShader(NULL); diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 061f5c2df..7e611f7a5 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -5,6 +5,8 @@ #include "c_cvars.h" #include "r_defs.h" +class FVertexBuffer; + EXTERN_CVAR(Bool, gl_direct_state_change) struct FStateAttr @@ -104,6 +106,8 @@ class FRenderState int mBlendEquation; bool m2D; + FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; + FStateVec3 mCameraPos; FStateVec4 mGlowTop, mGlowBottom; FStateVec4 mGlowTopPlane, mGlowBottomPlane; @@ -140,6 +144,11 @@ public: int SetupShader(bool cameratexture, int &shaderindex, int &cm, float warptime); void Apply(bool forcenoshader = false); + void SetVertexBuffer(FVertexBuffer *vb) + { + mVertexBuffer = vb; + } + void SetTextureMode(int mode) { mTextureMode = mode; diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 3efdcba8b..7ff3d7110 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -272,7 +272,7 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) } else { - if (vboindex >= 0) + if (gl_usevbo && vboindex >= 0) { //glColor3f( 1.f,.5f,.5f); int index = vboindex; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 513abaa57..47f990796 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -353,7 +353,6 @@ void FGLRenderer::CreateScene() gl_drawinfo->HandleHackedSubsectors(); // open sector hacks for deep water gl_drawinfo->ProcessSectorStacks(); // merge visplanes of sector stacks - GLRenderer->mVBO->UnmapVBO (); ProcessAll.Unclock(); } @@ -931,7 +930,7 @@ void FGLRenderer::RenderView (player_t* player) LastCamera=player->camera; } - mVBO->BindVBO(); + gl_RenderState.SetVertexBuffer(mVBO); // reset statistics counters ResetProfilingData(); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 2d311f0bb..25797e4fa 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -155,41 +155,28 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; - if (strstr(gl.vendorstring, "NVIDIA")) gl.flags|=RFL_NVIDIA; - else if (strstr(gl.vendorstring, "ATI Technologies")) gl.flags|=RFL_ATI; + if (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; - if (strcmp(version, "2.0") >= 0) gl.flags|=RFL_GL_20; - if (strcmp(version, "2.1") >= 0) gl.flags|=RFL_GL_21; - if (strcmp(version, "3.0") >= 0) gl.flags|=RFL_GL_30; + gl.version = strtod((char*)glGetString(GL_VERSION), NULL); glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - if (gl.flags & RFL_GL_20) - { - // Rules: - // SM4 will always use shaders. No option to switch them off is needed here. - // SM3 has shaders optional but they are off by default (they will have a performance impact - // SM2 only uses shaders for colormaps on camera textures and has no option to use them in general. - // On SM2 cards the shaders will be too slow and show visual bugs (at least on GF 6800.) - if (strcmp((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION), "1.3") >= 0) gl.shadermodel = 4; - else if (CheckExtension("GL_NV_GPU_shader4")) gl.shadermodel = 4; // for pre-3.0 drivers that support GF8xxx. - else if (CheckExtension("GL_EXT_GPU_shader4")) gl.shadermodel = 4; // for pre-3.0 drivers that support GF8xxx. - else if (CheckExtension("GL_NV_vertex_program3")) gl.shadermodel = 3; - else if (!strstr(gl.vendorstring, "NVIDIA")) gl.shadermodel = 3; - else gl.shadermodel = 2; // Only for older NVidia cards which had notoriously bad shader support. + // Rules: + // SM4 will always use shaders. No option to switch them off is needed here. + // SM3 has shaders optional but they are off by default (they will have a performance impact + // SM2 only uses shaders for colormaps on camera textures and has no option to use them in general. + // On SM2 cards the shaders will be too slow and show visual bugs (at least on GF 6800.) + if (strcmp((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION), "1.3") >= 0) gl.shadermodel = 4; + else if (CheckExtension("GL_NV_vertex_program3")) gl.shadermodel = 3; + else if (!strstr(gl.vendorstring, "NVIDIA")) gl.shadermodel = 3; + else gl.shadermodel = 2; // Only for older NVidia cards which had notoriously bad shader support. - // Command line overrides for testing and problem cases. - if (Args->CheckParm("-sm2") && gl.shadermodel > 2) gl.shadermodel = 2; - else if (Args->CheckParm("-sm3") && gl.shadermodel > 3) gl.shadermodel = 3; - } + // Command line overrides for testing and problem cases. + if (Args->CheckParm("-sm2") && gl.shadermodel > 2) gl.shadermodel = 2; + else if (Args->CheckParm("-sm3") && gl.shadermodel > 3) gl.shadermodel = 3; - if (CheckExtension("GL_ARB_map_buffer_range")) - { - gl.flags|=RFL_MAP_BUFFER_RANGE; - } - - if (gl.flags & RFL_GL_30) + if (gl.version >= 3.f) { gl.flags|=RFL_FRAMEBUFFER; } diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 79623c07f..fdadd67d9 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -9,16 +9,8 @@ enum RenderFlags RFL_TEXTURE_COMPRESSION=8, RFL_TEXTURE_COMPRESSION_S3TC=16, - RFL_MAP_BUFFER_RANGE = 64, - RFL_FRAMEBUFFER = 128, - RFL_TEXTUREBUFFER = 256, - RFL_NVIDIA = 512, - RFL_ATI = 1024, - - - RFL_GL_20 = 0x10000000, - RFL_GL_21 = 0x20000000, - RFL_GL_30 = 0x40000000, + RFL_FRAMEBUFFER = 32, + RFL_BUFFER_STORAGE = 64, }; enum TexMode @@ -40,6 +32,7 @@ struct RenderContext unsigned int flags; unsigned int shadermodel; unsigned int maxuniforms; + float version; int max_texturesize; char * vendorstring; From f7404d20fb77b6a2fdcee179e54828e1618c27fd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 May 2014 01:23:27 +0200 Subject: [PATCH 0072/1509] - add vertex buffer based drawing for all walls and flats. --- src/gl/data/gl_vertexbuffer.cpp | 1 + src/gl/data/gl_vertexbuffer.h | 18 +++++ src/gl/scene/gl_flats.cpp | 68 +++++++++++++++--- src/gl/scene/gl_scene.cpp | 3 + src/gl/scene/gl_vertex.cpp | 121 ++++++++++++++++++++++++++++++++ src/gl/scene/gl_wall.h | 6 ++ src/gl/scene/gl_walls_draw.cpp | 86 +++++++++++++++++------ 7 files changed, 273 insertions(+), 30 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index c5703a8ef..a0f9aa849 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -296,6 +296,7 @@ void FFlatVertexBuffer::CreateVBO() { CreateFlatVBO(); memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); + mIndex = vbo_shadowdata.Size(); } else if (sectors) { diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 2755b6494..24fe5b4d5 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -35,6 +35,7 @@ class FFlatVertexBuffer : public FVertexBuffer { FFlatVertex *map; unsigned int mIndex; + unsigned int mCurIndex; void CheckPlanes(sector_t *sector); @@ -49,6 +50,23 @@ public: void BindVBO(); void CheckUpdate(sector_t *sector); + FFlatVertex *GetBuffer() + { + return &map[mCurIndex]; + } + unsigned int GetCount(FFlatVertex *newptr, unsigned int *poffset) + { + unsigned int newofs = unsigned int(newptr - map); + unsigned int diff = newofs - mCurIndex; + *poffset = mCurIndex; + mCurIndex = newofs; + return diff; + } + void Reset() + { + mCurIndex = mIndex; + } + private: int CreateSubsectorVertices(subsector_t *sub, const secplane_t &plane, int floor); int CreateSectorVertices(sector_t *sec, const secplane_t &plane, int floor); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 7ff3d7110..c32011998 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -238,21 +238,72 @@ bool GLFlat::SetupSubsectorLights(bool lightsapplied, subsector_t * sub) void GLFlat::DrawSubsector(subsector_t * sub) { - glBegin(GL_TRIANGLE_FAN); - - for(unsigned int k=0; knumlines; k++) + if (!gl_usevbo) { - vertex_t *vt = sub->firstline[k].v1; - glTexCoord2f(vt->fx/64.f, -vt->fy/64.f); - float zc = plane.plane.ZatPoint(vt->fx, vt->fy) + dz; - glVertex3f(vt->fx, zc, vt->fy); + glBegin(GL_TRIANGLE_FAN); + + if (plane.plane.a | plane.plane.b) + { + for (unsigned int k = 0; k < sub->numlines; k++) + { + vertex_t *vt = sub->firstline[k].v1; + glTexCoord2f(vt->fx / 64.f, -vt->fy / 64.f); + float zc = plane.plane.ZatPoint(vt->fx, vt->fy) + dz; + glVertex3f(vt->fx, zc, vt->fy); + } + } + else + { + float zc = FIXED2FLOAT(plane.plane.Zat0()) + dz; + for (unsigned int k = 0; k < sub->numlines; k++) + { + vertex_t *vt = sub->firstline[k].v1; + glTexCoord2f(vt->fx / 64.f, -vt->fy / 64.f); + glVertex3f(vt->fx, zc, vt->fy); + } + } + glEnd(); + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + if (plane.plane.a | plane.plane.b) + { + for (unsigned int k = 0; k < sub->numlines; k++) + { + vertex_t *vt = sub->firstline[k].v1; + ptr->x = vt->fx; + ptr->y = vt->fy; + ptr->z = plane.plane.ZatPoint(vt->fx, vt->fy) + dz; + ptr->u = vt->fx / 64.f; + ptr->v = -vt->fy / 64.f; + ptr++; + } + } + else + { + float zc = FIXED2FLOAT(plane.plane.Zat0()) + dz; + for (unsigned int k = 0; k < sub->numlines; k++) + { + vertex_t *vt = sub->firstline[k].v1; + ptr->x = vt->fx; + ptr->y = vt->fy; + ptr->z = zc; + ptr->u = vt->fx / 64.f; + ptr->v = -vt->fy / 64.f; + ptr++; + } + } + unsigned int offset; + unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); + glDrawArrays(GL_TRIANGLE_FAN, offset, count); } - glEnd(); flatvertices += sub->numlines; flatprimitives++; } + //========================================================================== // // @@ -292,7 +343,6 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) } else { - //glColor3f( .5f,1.f,.5f); // these are for testing the VBO stuff. // Draw the subsectors belonging to this sector for (int i=0; isubsectorcount; i++) { diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 47f990796..1aa3c2b3f 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -931,6 +931,7 @@ void FGLRenderer::RenderView (player_t* player) } gl_RenderState.SetVertexBuffer(mVBO); + GLRenderer->mVBO->Reset(); // reset statistics counters ResetProfilingData(); @@ -991,6 +992,8 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei bounds.height=height; glFlush(); SetFixedColormap(player); + gl_RenderState.SetVertexBuffer(mVBO); + GLRenderer->mVBO->Reset(); // Check if there's some lights. If not some code can be skipped. TThinkerIterator it(STAT_DLIGHT); diff --git a/src/gl/scene/gl_vertex.cpp b/src/gl/scene/gl_vertex.cpp index 3aff28d1f..03f7df520 100644 --- a/src/gl/scene/gl_vertex.cpp +++ b/src/gl/scene/gl_vertex.cpp @@ -45,6 +45,7 @@ #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" #include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" #include "gl/dynlights/gl_glow.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" @@ -88,6 +89,37 @@ void GLWall::SplitUpperEdge(texcoord * tcs) vertexcount += sidedef->numsegs-1; } +void GLWall::SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr) +{ + if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; + + side_t *sidedef = seg->sidedef; + float polyw = glseg.fracright - glseg.fracleft; + float facu = (tcs[2].u - tcs[1].u) / polyw; + float facv = (tcs[2].v - tcs[1].v) / polyw; + float fact = (ztop[1] - ztop[0]) / polyw; + float facc = (zceil[1] - zceil[0]) / polyw; + float facf = (zfloor[1] - zfloor[0]) / polyw; + + for (int i = 0; i < sidedef->numsegs - 1; i++) + { + seg_t *cseg = sidedef->segs[i]; + float sidefrac = cseg->sidefrac; + if (sidefrac <= glseg.fracleft) continue; + if (sidefrac >= glseg.fracright) return; + + float fracfac = sidefrac - glseg.fracleft; + + ptr->x = cseg->v2->fx; + ptr->y = cseg->v2->fy; + ptr->z = ztop[0] + fact * fracfac; + ptr->u = tcs[1].u + facu * fracfac; + ptr->v = tcs[1].v + facv * fracfac; + ptr++; + } + vertexcount += sidedef->numsegs - 1; +} + //========================================================================== // // Split upper edge of wall @@ -121,6 +153,37 @@ void GLWall::SplitLowerEdge(texcoord * tcs) vertexcount += sidedef->numsegs-1; } +void GLWall::SplitLowerEdge(texcoord * tcs, FFlatVertex *&ptr) +{ + if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; + + side_t *sidedef = seg->sidedef; + float polyw = glseg.fracright - glseg.fracleft; + float facu = (tcs[3].u - tcs[0].u) / polyw; + float facv = (tcs[3].v - tcs[0].v) / polyw; + float facb = (zbottom[1] - zbottom[0]) / polyw; + float facc = (zceil[1] - zceil[0]) / polyw; + float facf = (zfloor[1] - zfloor[0]) / polyw; + + for (int i = sidedef->numsegs - 2; i >= 0; i--) + { + seg_t *cseg = sidedef->segs[i]; + float sidefrac = cseg->sidefrac; + if (sidefrac >= glseg.fracright) continue; + if (sidefrac <= glseg.fracleft) return; + + float fracfac = sidefrac - glseg.fracleft; + + ptr->x = cseg->v2->fx; + ptr->y = cseg->v2->fy; + ptr->z = zbottom[0] + facb * fracfac; + ptr->u = tcs[0].u + facu * fracfac; + ptr->v = tcs[0].v + facv * fracfac; + ptr++; + } + vertexcount += sidedef->numsegs - 1; +} + //========================================================================== // // Split left edge of wall @@ -153,6 +216,35 @@ void GLWall::SplitLeftEdge(texcoord * tcs) } } +void GLWall::SplitLeftEdge(texcoord * tcs, FFlatVertex *&ptr) +{ + if (vertexes[0] == NULL) return; + + vertex_t * vi = vertexes[0]; + + if (vi->numheights) + { + int i = 0; + + float polyh1 = ztop[0] - zbottom[0]; + float factv1 = polyh1 ? (tcs[1].v - tcs[0].v) / polyh1 : 0; + float factu1 = polyh1 ? (tcs[1].u - tcs[0].u) / polyh1 : 0; + + while (inumheights && vi->heightlist[i] <= zbottom[0]) i++; + while (inumheights && vi->heightlist[i] < ztop[0]) + { + ptr->x = glseg.x1; + ptr->y = glseg.y1; + ptr->z = vi->heightlist[i]; + ptr->u = factu1*(vi->heightlist[i] - ztop[0]) + tcs[1].u; + ptr->v = factv1*(vi->heightlist[i] - ztop[0]) + tcs[1].v; + ptr++; + i++; + } + vertexcount += i; + } +} + //========================================================================== // // Split right edge of wall @@ -185,3 +277,32 @@ void GLWall::SplitRightEdge(texcoord * tcs) } } +void GLWall::SplitRightEdge(texcoord * tcs, FFlatVertex *&ptr) +{ + if (vertexes[1] == NULL) return; + + vertex_t * vi = vertexes[1]; + + if (vi->numheights) + { + int i = vi->numheights - 1; + + float polyh2 = ztop[1] - zbottom[1]; + float factv2 = polyh2 ? (tcs[2].v - tcs[3].v) / polyh2 : 0; + float factu2 = polyh2 ? (tcs[2].u - tcs[3].u) / polyh2 : 0; + + while (i>0 && vi->heightlist[i] >= ztop[1]) i--; + while (i>0 && vi->heightlist[i] > zbottom[1]) + { + ptr->x = glseg.x2; + ptr->y = glseg.y2; + ptr->z = vi->heightlist[i]; + ptr->u = factu2*(vi->heightlist[i] - ztop[1]) + tcs[2].u; + ptr->v = factv2*(vi->heightlist[i] - ztop[1]) + tcs[2].v; + ptr++; + i--; + } + vertexcount += i; + } +} + diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index e53513167..207b7bdbf 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -20,6 +20,7 @@ struct GLDrawList; struct GLSkyInfo; struct FTexCoordInfo; struct FPortal; +struct FFlatVertex; enum WallTypes @@ -215,6 +216,11 @@ private: void SplitUpperEdge(texcoord * tcs); void SplitLowerEdge(texcoord * tcs); + void SplitLeftEdge(texcoord * tcs, FFlatVertex *&ptr); + void SplitRightEdge(texcoord * tcs, FFlatVertex *&ptr); + void SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr); + void SplitLowerEdge(texcoord * tcs, FFlatVertex *&ptr); + public: void Process(seg_t *seg, sector_t *frontsector, sector_t *backsector); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index d7edc6ef7..63e5086a7 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -48,7 +48,9 @@ #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_renderer.h" #include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" #include "gl/dynlights/gl_dynlight.h" #include "gl/dynlights/gl_glow.h" #include "gl/scene/gl_drawinfo.h" @@ -248,38 +250,80 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) // the rest of the code is identical for textured rendering and lights - glBegin(GL_TRIANGLE_FAN); - // lower left corner - if (textured&1) glTexCoord2f(tcs[0].u,tcs[0].v); - glVertex3f(glseg.x1,zbottom[0],glseg.y1); + if (!gl_usevbo) + { + glBegin(GL_TRIANGLE_FAN); - if (split && glseg.fracleft==0) SplitLeftEdge(tcs); + // lower left corner + if (textured & 1) glTexCoord2f(tcs[0].u, tcs[0].v); + glVertex3f(glseg.x1, zbottom[0], glseg.y1); - // upper left corner - if (textured&1) glTexCoord2f(tcs[1].u,tcs[1].v); - glVertex3f(glseg.x1,ztop[0],glseg.y1); + if (split && glseg.fracleft == 0) SplitLeftEdge(tcs); - if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs); + // upper left corner + if (textured & 1) glTexCoord2f(tcs[1].u, tcs[1].v); + glVertex3f(glseg.x1, ztop[0], glseg.y1); - // color for right side - if (color2) glColor4fv(color2); + if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs); - // upper right corner - if (textured&1) glTexCoord2f(tcs[2].u,tcs[2].v); - glVertex3f(glseg.x2,ztop[1],glseg.y2); + // color for right side + if (color2) glColor4fv(color2); - if (split && glseg.fracright==1) SplitRightEdge(tcs); + // upper right corner + if (textured & 1) glTexCoord2f(tcs[2].u, tcs[2].v); + glVertex3f(glseg.x2, ztop[1], glseg.y2); - // lower right corner - if (textured&1) glTexCoord2f(tcs[3].u,tcs[3].v); - glVertex3f(glseg.x2,zbottom[1],glseg.y2); + if (split && glseg.fracright == 1) SplitRightEdge(tcs); - if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs); + // lower right corner + if (textured & 1) glTexCoord2f(tcs[3].u, tcs[3].v); + glVertex3f(glseg.x2, zbottom[1], glseg.y2); - glEnd(); + if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs); + + glEnd(); + + vertexcount += 4; + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + + ptr->x = glseg.x1; + ptr->y = glseg.y1; + ptr->z = zbottom[0]; + ptr->u = tcs[0].u; + ptr->v = tcs[0].v; + ptr++; + if (split && glseg.fracleft == 0) SplitLeftEdge(tcs, ptr); + ptr->x = glseg.x1; + ptr->y = glseg.y1; + ptr->z = ztop[0]; + ptr->u = tcs[1].u; + ptr->v = tcs[1].v; + ptr++; + if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs, ptr); + ptr->x = glseg.x2; + ptr->y = glseg.y2; + ptr->z = ztop[1]; + ptr->u = tcs[2].u; + ptr->v = tcs[2].v; + ptr++; + if (split && glseg.fracright == 1) SplitRightEdge(tcs, ptr); + ptr->x = glseg.x2; + ptr->y = glseg.y2; + ptr->z = zbottom[1]; + ptr->u = tcs[3].u; + ptr->v = tcs[3].v; + ptr++; + if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, ptr); + unsigned int offset; + unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); + glDrawArrays(GL_TRIANGLE_FAN, offset, count); + vertexcount += 4; + } - vertexcount+=4; } From a42cde0837598afee01ea0cc6df6d1027e194362 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 May 2014 09:17:18 +0200 Subject: [PATCH 0073/1509] - removed #include of glxew.h because it's not used. - removed some unused functions from gl_interface.cpp which were causing problems when compiling on Linux. --- src/gl/system/gl_interface.cpp | 37 ---------------------------------- src/gl/system/gl_system.h | 2 +- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 2d311f0bb..214702566 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -46,29 +46,12 @@ #include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" -#if defined (__unix__) || defined (__APPLE__) -#define PROC void* -#define LPCSTR const char* - -#include -#define wglGetProcAddress(x) (*SDL_GL_GetProcAddress)(x) -#endif -static void APIENTRY glBlendEquationDummy (GLenum mode); - - static TArray m_Extensions; RenderContext gl; int occlusion_type=0; -PROC myGetProcAddress(LPCSTR proc) -{ - PROC p = wglGetProcAddress(proc); - if (p == NULL) I_Error("Fatal: GL function '%s' not found.", proc); - return p; -} - //========================================================================== // @@ -235,26 +218,6 @@ void gl_PrintStartupLog() // //========================================================================== -static void APIENTRY glBlendEquationDummy (GLenum mode) -{ - // If this is not supported all non-existent modes are - // made to draw nothing. - if (mode == GL_FUNC_ADD) - { - glColorMask(true, true, true, true); - } - else - { - glColorMask(false, false, false, false); - } -} - -//========================================================================== -// -// -// -//========================================================================== - void gl_SetTextureMode(int type) { static float white[] = {1.f,1.f,1.f,1.f}; diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h index cb98d572e..8140904a2 100644 --- a/src/gl/system/gl_system.h +++ b/src/gl/system/gl_system.h @@ -72,7 +72,7 @@ #if defined(__APPLE__) #include #elif defined(__unix__) - #include + //#include #else // !__APPLE__ && !__unix__ #define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code! #include From 09f407143649616bba8c35755dced5711481504e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 May 2014 13:27:51 +0200 Subject: [PATCH 0074/1509] Ok, it had to be done: Removed shader support for pre GLSL 1.3/GL 3.0 hardware. The compromises needed to accomodate these are just too bad and would block any attempt at streamlining the code. --- src/gl/data/gl_data.cpp | 9 +- src/gl/dynlights/gl_dynlight1.cpp | 12 ++- src/gl/models/gl_models.cpp | 6 +- src/gl/renderer/gl_lightdata.cpp | 8 +- src/gl/renderer/gl_renderstate.cpp | 62 +++--------- src/gl/scene/gl_scene.cpp | 2 +- src/gl/scene/gl_sprite.cpp | 4 +- src/gl/scene/gl_walls_draw.cpp | 2 +- src/gl/scene/gl_weapon.cpp | 2 +- src/gl/shaders/gl_shader.cpp | 101 +++++++------------- src/gl/shaders/gl_shader.h | 2 - src/gl/system/gl_framebuffer.cpp | 2 +- src/gl/system/gl_interface.cpp | 19 +--- src/gl/system/gl_interface.h | 16 +++- src/gl/system/gl_menu.cpp | 26 +---- src/gl/textures/gl_hqresize.cpp | 2 +- src/gl/textures/gl_material.cpp | 4 +- wadsrc/static/menudef.z | 20 +--- wadsrc/static/shaders/glsl/fogboundary.fp | 18 ++-- wadsrc/static/shaders/glsl/main.fp | 20 ++-- wadsrc/static/shaders/glsl/main.vp | 14 +-- wadsrc/static/shaders/glsl/main_colormap.fp | 24 +++-- wadsrc/static/shaders/glsl/main_foglayer.fp | 18 ++-- 23 files changed, 132 insertions(+), 261 deletions(-) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index e0bb5ee6b..da72f6313 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -356,7 +356,14 @@ void InitGLRMapinfoData() glset.map_notexturefill = opt->notexturefill; glset.skyrotatevector = opt->skyrotatevector; glset.skyrotatevector2 = opt->skyrotatevector2; - if (gl.shadermodel == 2 && glset.map_lightmode ==2) glset.map_lightmode = 3; + if (!gl.hasGLSL()) + { + // light modes 2 and 8 require shaders + if (glset.map_lightmode == 2 || glset.map_lightmode == 8) + { + glset.map_lightmode = 3; + } + } } else { diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index 0b2ffa43d..e09207411 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -70,7 +70,17 @@ CUSTOM_CVAR (Bool, gl_lights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOIN CUSTOM_CVAR (Bool, gl_dynlight_shader, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { - if (self && (gl.maxuniforms < 1024 || gl.shadermodel < 4)) self = false; + if (self) + { + if (!gl.hasGLSL()) + { + self = false; + } + else if (gl.maxuniforms < 1024 && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + { + self = false; + } + } } CVAR (Bool, gl_attachedlights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 39668cd02..4b8a8e44b 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -753,7 +753,7 @@ void gl_RenderModel(GLSprite * spr, int cm) if(smf->flags & MDL_INHERITACTORPITCH) pitch += float(static_cast(spr->actor->pitch >> 16) / (1 << 13) * 45 + static_cast(spr->actor->pitch & 0x0000FFFF) / (1 << 29) * 45); if(smf->flags & MDL_INHERITACTORROLL) roll += float(static_cast(spr->actor->roll >> 16) / (1 << 13) * 45 + static_cast(spr->actor->roll & 0x0000FFFF) / (1 << 29) * 45); - if (gl.shadermodel < 4) + if (!gl.hasGLSL()) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); @@ -795,7 +795,7 @@ void gl_RenderModel(GLSprite * spr, int cm) glRotatef(smf->pitchoffset, 0, 0, 1); glRotatef(-smf->rolloffset, 1, 0, 0); - if (gl.shadermodel >= 4) glActiveTexture(GL_TEXTURE0); + if (gl.hasGLSL()) glActiveTexture(GL_TEXTURE0); #if 0 if (gl_light_models) @@ -814,7 +814,7 @@ void gl_RenderModel(GLSprite * spr, int cm) gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), cm, NULL, translation ); - if (gl.shadermodel < 4) + if (!gl.hasGLSL()) { glMatrixMode(GL_MODELVIEW); glPopMatrix(); diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 9292c765e..1523443c8 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -80,12 +80,12 @@ CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE); bool gl_BrightmapsActive() { - return gl.shadermodel == 4 || (gl.shadermodel == 3 && gl_brightmap_shader); + return gl.hasGLSL(); } bool gl_GlowActive() { - return gl.shadermodel == 4 || (gl.shadermodel == 3 && gl_glow_shader); + return gl.hasGLSL(); } //========================================================================== @@ -125,7 +125,7 @@ CUSTOM_CVAR(Int,gl_fogmode,1,CVAR_ARCHIVE|CVAR_NOINITCALL) { if (self>2) self=2; if (self<0) self=0; - if (self == 2 && gl.shadermodel < 4) self = 1; + if (self == 2 && !gl.hasGLSL()) self = 1; } CUSTOM_CVAR(Int, gl_lightmode, 3 ,CVAR_ARCHIVE|CVAR_NOINITCALL) @@ -133,7 +133,7 @@ CUSTOM_CVAR(Int, gl_lightmode, 3 ,CVAR_ARCHIVE|CVAR_NOINITCALL) int newself = self; if (newself > 4) newself=8; // use 8 for software lighting to avoid conflicts with the bit mask if (newself < 0) newself=0; - if ((newself == 2 || newself == 8) && gl.shadermodel < 4) newself = 3; + if ((newself == 2 || newself == 8) && !gl.hasGLSL()) newself = 3; if (self != newself) self = newself; glset.lightmode = newself; } diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index f0ceb40fa..8d3423423 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -104,28 +104,13 @@ int FRenderState::SetupShader(bool cameratexture, int &shaderindex, int &cm, flo } } - if (gl.shadermodel == 4) + if (gl.hasGLSL()) { usecmshader = cm > CM_DEFAULT && cm < CM_MAXCOLORMAP && mTextureMode != TM_MASK; } - else if (gl.shadermodel == 3) - { - usecmshader = (cameratexture || gl_colormap_shader) && - cm > CM_DEFAULT && cm < CM_MAXCOLORMAP && mTextureMode != TM_MASK; - - if (!gl_brightmap_shader && shaderindex == 3) - { - shaderindex = 0; - } - else if (!gl_warp_shader && shaderindex !=3) - { - if (shaderindex <= 2) softwarewarp = shaderindex; - shaderindex = 0; - } - } else { - usecmshader = cameratexture; + usecmshader = false; softwarewarp = shaderindex > 0 && shaderindex < 3? shaderindex : 0; shaderindex = 0; } @@ -149,43 +134,22 @@ bool FRenderState::ApplyShader() bool useshaders = false; FShader *activeShader = NULL; - if (mSpecialEffect > 0 && gl.shadermodel > 2) + if (mSpecialEffect > 0 && gl.hasGLSL()) { activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect); } - else + else if (gl.hasGLSL()) { - switch (gl.shadermodel) + useshaders = (!m2D || mEffectState != 0 || mColormapState); // all 3D rendering and 2D with texture effects. + } + + if (useshaders) + { + FShaderContainer *shd = GLRenderer->mShaderManager->Get(mTextureEnabled? mEffectState : 4); + + if (shd != NULL) { - case 2: - useshaders = (mTextureEnabled && mColormapState != CM_DEFAULT); - break; - - case 3: - useshaders = ( - mEffectState != 0 || // special shaders - (mFogEnabled && (gl_fogmode == 2 || gl_fog_shader) && gl_fogmode != 0) || // fog requires a shader - (mTextureEnabled && (mEffectState != 0 || mColormapState)) || // colormap - mGlowEnabled // glow requires a shader - ); - break; - - case 4: - useshaders = (!m2D || mEffectState != 0 || mColormapState); // all 3D rendering and 2D with texture effects. - break; - - default: - break; - } - - if (useshaders) - { - FShaderContainer *shd = GLRenderer->mShaderManager->Get(mTextureEnabled? mEffectState : 4); - - if (shd != NULL) - { - activeShader = shd->Bind(mColormapState, mGlowEnabled, mWarpTime, mLightEnabled); - } + activeShader = shd->Bind(mColormapState, mGlowEnabled, mWarpTime, mLightEnabled); } } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 1aa3c2b3f..8fe1f180a 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -288,7 +288,7 @@ void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) void FGLRenderer::SetViewMatrix(bool mirror, bool planemirror) { - if (gl.shadermodel >= 4) + if (gl.hasGLSL()) { glActiveTexture(GL_TEXTURE7); glMatrixMode(GL_TEXTURE); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 63efb978e..d018d2eea 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -218,7 +218,7 @@ void GLSprite::Draw(int pass) // non-black fog with subtractive style needs special treatment if (!gl_isBlack(Colormap.FadeColor)) { - if (gl.shadermodel >= 4 && !gl_nolayer) + if (gl.hasGLSL() && !gl_nolayer) { // fog layer only works on modern hardware. foglayer = true; @@ -795,7 +795,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) RenderStyle.CheckFuzz(); if (RenderStyle.BlendOp == STYLEOP_Fuzz) { - if (gl.shadermodel >= 4 && gl_fuzztype != 0) + if (gl.hasGLSL() && gl_fuzztype != 0) { // Todo: implement shader selection here RenderStyle = LegacyRenderStyles[STYLE_Translucent]; diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 63e5086a7..f060978e4 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -338,7 +338,7 @@ void GLWall::RenderFogBoundary() if (gl_fogmode && gl_fixedcolormap == 0) { // with shaders this can be done properly - if (gl.shadermodel == 4 || (gl.shadermodel == 3 && gl_fog_shader)) + if (gl.hasGLSL()) { int rel = rellight + getExtraLight(); gl_SetFog(lightlevel, rel, &Colormap, false); diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index aa991c0a0..fe3aee0ff 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -313,7 +313,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) vis.RenderStyle.CheckFuzz(); if (vis.RenderStyle.BlendOp == STYLEOP_Fuzz) { - if (gl.shadermodel >= 4 && gl_fuzztype != 0) + if (gl.hasGLSL() && gl_fuzztype != 0) { // Todo: implement shader selection here vis.RenderStyle = LegacyRenderStyles[STYLE_Translucent]; diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index ca1921bd4..2065768fa 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -79,7 +79,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * static char buffer[10000]; FString error; - if (gl.shadermodel > 0) + if (gl.hasGLSL()) { int vp_lump = Wads.CheckNumForFullName(vert_prog_lump); if (vp_lump == -1) I_Error("Unable to load '%s'", vert_prog_lump); @@ -93,10 +93,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * FString vp_comb; FString fp_comb; vp_comb = defines; - if (gl.shadermodel < 4) - { - vp_comb << "#define NO_SM4\n"; - } fp_comb = vp_comb; // This uses GetChars on the strings to get rid of terminating 0 characters. @@ -307,52 +303,40 @@ FShaderContainer::FShaderContainer(const char *ShaderName, const char *ShaderPat I_Error("Unable to load shader %s:\n%s\n", name.GetChars(), err.GetMessage()); } - if (gl.shadermodel > 2) + for(int i = 0;i < NUM_SHADERS; i++) { - for(int i = 0;i < NUM_SHADERS; i++) + FString name; + + name << ShaderName << shaderdesc[i]; + + try { - FString name; - - name << ShaderName << shaderdesc[i]; - - try + FString str; + if ((i&4) != 0) { - FString str; - if ((i&4) != 0) + if (gl.maxuniforms < 1024) { - if (gl.maxuniforms < 1024 || gl.shadermodel != 4) - { - shader[i] = NULL; - continue; - } - // this can't be in the shader code due to ATI strangeness. - str = "#version 120\n#extension GL_EXT_gpu_shader4 : enable\n"; - if (gl.MaxLights() == 128) str += "#define MAXLIGHTS128\n"; - } - if ((i&8) == 0) - { - if (gl.shadermodel != 4) - { - shader[i] = NULL; - continue; - } - } - str += shaderdefines[i]; - shader[i] = new FShader; - if (!shader[i]->Load(name, "shaders/glsl/main.vp", "shaders/glsl/main.fp", ShaderPath, str.GetChars())) - { - delete shader[i]; shader[i] = NULL; + continue; } + // this can't be in the shader code due to ATI strangeness. + str = "#version 120\n#extension GL_EXT_gpu_shader4 : enable\n"; + if (gl.MaxLights() == 128) str += "#define MAXLIGHTS128\n"; } - catch(CRecoverableError &err) + str += shaderdefines[i]; + shader[i] = new FShader; + if (!shader[i]->Load(name, "shaders/glsl/main.vp", "shaders/glsl/main.fp", ShaderPath, str.GetChars())) { + delete shader[i]; shader[i] = NULL; - I_Error("Unable to load shader %s:\n%s\n", name.GetChars(), err.GetMessage()); } } + catch(CRecoverableError &err) + { + shader[i] = NULL; + I_Error("Unable to load shader %s:\n%s\n", name.GetChars(), err.GetMessage()); + } } - else memset(shader, 0, sizeof(shader)); } //========================================================================== @@ -502,28 +486,15 @@ FShaderManager::~FShaderManager() // //========================================================================== -void FShaderManager::Recompile() -{ - Clean(); - CompileShaders(); -} - -//========================================================================== -// -// -// -//========================================================================== - void FShaderManager::CompileShaders() { mActiveShader = mEffectShaders[0] = mEffectShaders[1] = NULL; - if (gl.shadermodel > 0) + if (gl.hasGLSL()) { for(int i=0;defaultshaders[i].ShaderName != NULL;i++) { FShaderContainer * shc = new FShaderContainer(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc); mTextureEffects.Push(shc); - if (gl.shadermodel <= 2) return; // SM2 will only initialize the default shader } for(unsigned i = 0; i < usershaders.Size(); i++) @@ -531,25 +502,19 @@ void FShaderManager::CompileShaders() FString name = ExtractFileBase(usershaders[i]); FName sfn = name; - if (gl.shadermodel > 2) - { - FShaderContainer * shc = new FShaderContainer(sfn, usershaders[i]); - mTextureEffects.Push(shc); - } + FShaderContainer * shc = new FShaderContainer(sfn, usershaders[i]); + mTextureEffects.Push(shc); } - if (gl.shadermodel > 2) + for(int i=0;iLoad(effectshaders[i].ShaderName, effectshaders[i].vp, effectshaders[i].fp1, + effectshaders[i].fp2, effectshaders[i].defines)) { - FShader *eff = new FShader(); - if (!eff->Load(effectshaders[i].ShaderName, effectshaders[i].vp, effectshaders[i].fp1, - effectshaders[i].fp2, effectshaders[i].defines)) - { - delete eff; - } - else mEffectShaders[i] = eff; + delete eff; } + else mEffectShaders[i] = eff; } } } @@ -604,7 +569,7 @@ int FShaderManager::Find(const char * shn) void FShaderManager::SetActiveShader(FShader *sh) { // shadermodel needs to be tested here because without it UseProgram will be NULL. - if (gl.shadermodel > 0 && mActiveShader != sh) + if (gl.hasGLSL() && mActiveShader != sh) { glUseProgram(sh == NULL? 0 : sh->GetHandle()); mActiveShader = sh; diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 61053287c..bd3aa0f30 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -153,8 +153,6 @@ public: } return NULL; } - - void Recompile(); }; #define FIRST_USER_SHADER 12 diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 99e9bd9a4..d22c6a5ed 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -73,9 +73,9 @@ CVAR(Bool, gl_aalines, false, CVAR_ARCHIVE) FGLRenderer *GLRenderer; -void gl_SetupMenu(); void gl_LoadExtensions(); void gl_PrintStartupLog(); +void gl_SetupMenu(); //========================================================================== // diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 31176d220..434659a7c 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -133,7 +133,6 @@ void gl_LoadExtensions() // This loads any function pointers and flags that require a vaild render context to // initialize properly - gl.shadermodel = 0; // assume no shader support gl.vendorstring=(char*)glGetString(GL_VENDOR); if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; @@ -141,23 +140,11 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; gl.version = strtod((char*)glGetString(GL_VERSION), NULL); + gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL); + if (Args->CheckParm("-noshader")) gl.glslversion = 0.0f; glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - // Rules: - // SM4 will always use shaders. No option to switch them off is needed here. - // SM3 has shaders optional but they are off by default (they will have a performance impact - // SM2 only uses shaders for colormaps on camera textures and has no option to use them in general. - // On SM2 cards the shaders will be too slow and show visual bugs (at least on GF 6800.) - if (strcmp((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION), "1.3") >= 0) gl.shadermodel = 4; - else if (CheckExtension("GL_NV_vertex_program3")) gl.shadermodel = 3; - else if (!strstr(gl.vendorstring, "NVIDIA")) gl.shadermodel = 3; - else gl.shadermodel = 2; // Only for older NVidia cards which had notoriously bad shader support. - - // Command line overrides for testing and problem cases. - if (Args->CheckParm("-sm2") && gl.shadermodel > 2) gl.shadermodel = 2; - else if (Args->CheckParm("-sm3") && gl.shadermodel > 3) gl.shadermodel = 3; if (gl.version >= 3.f) { @@ -187,7 +174,7 @@ void gl_PrintStartupLog() Printf ("Max. texture units: %d\n", v); glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); Printf ("Max. fragment uniforms: %d\n", v); - if (gl.shadermodel == 4) gl.maxuniforms = v; + if (gl.hasGLSL()) gl.maxuniforms = v; glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &v); Printf ("Max. vertex uniforms: %d\n", v); glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index fdadd67d9..66f96be00 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -6,11 +6,12 @@ enum RenderFlags { // [BB] Added texture compression flags. - RFL_TEXTURE_COMPRESSION=8, - RFL_TEXTURE_COMPRESSION_S3TC=16, + RFL_TEXTURE_COMPRESSION=1, + RFL_TEXTURE_COMPRESSION_S3TC=2, - RFL_FRAMEBUFFER = 32, - RFL_BUFFER_STORAGE = 64, + RFL_FRAMEBUFFER = 4, + RFL_BUFFER_STORAGE = 8, + RFL_SHADER_STORAGE_BUFFER = 16, }; enum TexMode @@ -30,9 +31,9 @@ enum TexMode struct RenderContext { unsigned int flags; - unsigned int shadermodel; unsigned int maxuniforms; float version; + float glslversion; int max_texturesize; char * vendorstring; @@ -40,6 +41,11 @@ struct RenderContext { return maxuniforms>=2048? 128:64; } + + bool hasGLSL() const + { + return glslversion >= 1.3f; + } }; extern RenderContext gl; diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index 75436209c..0518606b9 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -59,7 +59,7 @@ CUSTOM_CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // when they are actually valid. void gl_SetupMenu() { - if (gl.shadermodel < 4) + if (!gl.hasGLSL()) { // Radial fog and Doom lighting are not available in SM < 4 cards // The way they are implemented does not work well on older hardware. @@ -95,28 +95,4 @@ void gl_SetupMenu() if (gl_fogmode == 2) gl_fogmode = 1; if (gl_dynlight_shader) gl_dynlight_shader = false; } - - if (gl.shadermodel != 3) - { - // The shader menu will only be visible on SM3. - // SM2 won't use shaders unless unavoidable (and then it's automatic) and SM4 will always use shaders. - // Find the OpenGLOptions menu and remove the item named GLShaderOptions. - - FMenuDescriptor **desc = MenuDescriptors.CheckKey("OpenGLOptions"); - if (desc != NULL && (*desc)->mType == MDESC_OptionsMenu) - { - FOptionMenuDescriptor *opt = (FOptionMenuDescriptor *)*desc; - - FName shader = "GLShaderOptions"; - for(unsigned i=0;imItems.Size();i++) - { - FName nm = opt->mItems[i]->GetAction(NULL); - if (nm == shader) - { - delete opt->mItems[i]; - opt->mItems.Delete(i); - } - } - } - } } diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 2c5f831f1..837977145 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -225,7 +225,7 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u return inputBuffer; // [BB] Don't upsample non-shader handled warped textures. Needs too much memory and time - if (gl.shadermodel == 2 || (gl.shadermodel == 3 && inputTexture->bWarped)) + if (inputTexture->bWarped && !gl.hasGLSL()) return inputBuffer; switch (inputTexture->UseType) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 9cb3ef523..5d471fc81 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -624,7 +624,7 @@ FMaterial::FMaterial(FTexture * tx, bool forceexpand) { expanded = false; } - else if (gl.shadermodel > 2) + else if (gl.hasGLSL()) { if (tx->gl_info.shaderindex >= FIRST_USER_SHADER) { @@ -670,7 +670,7 @@ FMaterial::FMaterial(FTexture * tx, bool forceexpand) tex = tx; tx->gl_info.mExpanded = expanded; - FTexture *basetex = tx->GetRedirect(gl.shadermodel < 4); + FTexture *basetex = tx->GetRedirect(!gl.hasGLSL()); if (!expanded && !basetex->gl_info.mExpanded && basetex->UseType != FTexture::TEX_Sprite) { // check if the texture is just a simple redirect to a patch diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 329042b74..0db780620 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -14,13 +14,6 @@ OptionValue "EnhancedStealth" 3, "Any fixed colormap" } -OptionValue "VBOModes" -{ - 0, "Off" - 1, "Static" - 2, "Dynamic" -} - OptionValue "FilterModes" { 0, "None" @@ -186,17 +179,7 @@ OptionMenu "GLPrefOptions" Option "Particle style", gl_particles_style, "Particles" Slider "Ambient light level", gl_light_ambient, 1.0, 255.0, 5.0 Option "Rendering quality", gl_render_precise, "Precision" - Option "Use vertex buffer", gl_usevbo, "VBOModes" -} - -OptionMenu "GLShaderOptions" -{ - Title "SHADER OPTIONS" - Option "Enable brightness maps", gl_brightmap_shader, "OnOff" - Option "Shaders for texture warp", gl_warp_shader, "OnOff" - Option "Shaders for fog", gl_fog_shader, "OnOff" - Option "Shaders for colormaps", gl_colormap_shader, "OnOff" - Option "Shaders for glowing textures", gl_glow_shader, "OnOff" + Option "Use vertex buffer", gl_usevbo, "OnOff" } OptionMenu "OpenGLOptions" @@ -204,7 +187,6 @@ OptionMenu "OpenGLOptions" Title "OPENGL OPTIONS" Submenu "Dynamic Light Options", "GLLightOptions" Submenu "Texture Options", "GLTextureGLOptions" - Submenu "Shader Options", "GLShaderOptions" Submenu "Preferences", "GLPrefOptions" } diff --git a/wadsrc/static/shaders/glsl/fogboundary.fp b/wadsrc/static/shaders/glsl/fogboundary.fp index 5b43dfd95..5ab8ac717 100644 --- a/wadsrc/static/shaders/glsl/fogboundary.fp +++ b/wadsrc/static/shaders/glsl/fogboundary.fp @@ -18,18 +18,14 @@ void main() // // calculate fog factor // - #ifndef NO_SM4 - if (fogenabled == -1) - { - fogdist = pixelpos.w; - } - else - { - fogdist = max(16.0, distance(pixelpos.xyz, camerapos)); - } - #else + if (fogenabled == -1) + { fogdist = pixelpos.w; - #endif + } + else + { + fogdist = max(16.0, distance(pixelpos.xyz, camerapos)); + } fogfactor = exp2 (fogparm.z * fogdist); gl_FragColor = vec4(fogcolor.rgb, 1.0 - fogfactor); } diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index aa2c33238..6bb17a2ad 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -102,7 +102,7 @@ vec4 getLightColor(float fogdist, float fogfactor) // if (fogenabled > 0) { - #if (!defined(NO_SM4) || defined(DOOMLIGHT)) && !defined SOFTLIGHT + #if (defined(DOOMLIGHT)) && !defined SOFTLIGHT // special lighting mode 'Doom' not available on older cards for performance reasons. if (fogdist < fogparm.y) { @@ -197,20 +197,14 @@ void main() // if (fogenabled != 0) { - #ifndef NO_SM4 - if (fogenabled == 1 || fogenabled == -1) - { - fogdist = pixelpos.w; - } - else - { - fogdist = max(16.0, distance(pixelpos.xyz, camerapos)); - } - #elif !defined(FOG_RADIAL) + if (fogenabled == 1 || fogenabled == -1) + { fogdist = pixelpos.w; - #else + } + else + { fogdist = max(16.0, distance(pixelpos.xyz, camerapos)); - #endif + } fogfactor = exp2 (fogparm.z * fogdist); } #endif diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 7aebb8171..fc905b753 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -19,12 +19,8 @@ void main() lightlevel = lightlevel_in; #endif - #ifndef NO_SM4 - // Yes, I know... But using a texture matrix here saves me from the hassle of tracking its state across shaders. ;) - vec4 worldcoord = gl_TextureMatrix[7] * gl_Vertex; - #else - vec4 worldcoord = gl_Vertex; - #endif + // We use texture matrix 7 as the model matrix and the modelview matrix as the view matrix. + vec4 worldcoord = gl_TextureMatrix[7] * gl_Vertex; vec4 eyeCoordPos = gl_ModelViewMatrix * worldcoord; gl_FrontColor = gl_Color; @@ -55,11 +51,7 @@ void main() gl_TexCoord[0].xy = sst; #endif - #ifndef NO_SM4 - gl_Position = gl_ModelViewProjectionMatrix * worldcoord; - #else - gl_Position = ftransform(); - #endif + gl_Position = gl_ModelViewProjectionMatrix * worldcoord; #ifdef __GLSL_CG_DATA_TYPES gl_ClipVertex = eyeCoordPos; #endif diff --git a/wadsrc/static/shaders/glsl/main_colormap.fp b/wadsrc/static/shaders/glsl/main_colormap.fp index a64f67bc2..fa0f28f25 100644 --- a/wadsrc/static/shaders/glsl/main_colormap.fp +++ b/wadsrc/static/shaders/glsl/main_colormap.fp @@ -16,19 +16,17 @@ vec4 getTexel(vec2 st) { vec4 texel = texture2D(tex, st); - #ifndef NO_TEXTUREMODE - // - // Apply texture modes - // - if (texturemode == 2) - { - texel.a = 1.0; - } - else if (texturemode == 1) - { - texel.rgb = vec3(1.0,1.0,1.0); - } - #endif + // + // Apply texture modes + // + if (texturemode == 2) + { + texel.a = 1.0; + } + else if (texturemode == 1) + { + texel.rgb = vec3(1.0,1.0,1.0); + } return texel; } diff --git a/wadsrc/static/shaders/glsl/main_foglayer.fp b/wadsrc/static/shaders/glsl/main_foglayer.fp index bfe08d327..3802e3d85 100644 --- a/wadsrc/static/shaders/glsl/main_foglayer.fp +++ b/wadsrc/static/shaders/glsl/main_foglayer.fp @@ -39,18 +39,14 @@ void main() // // calculate fog factor // - #ifndef NO_SM4 - if (fogenabled == -1) - { - fogdist = pixelpos.w; - } - else - { - fogdist = max(16.0, distance(pixelpos.xyz, camerapos)); - } - #else + if (fogenabled == -1) + { fogdist = pixelpos.w; - #endif + } + else + { + fogdist = max(16.0, distance(pixelpos.xyz, camerapos)); + } fogfactor = exp2 (fogparm.z * fogdist); vec4 frag = Process(vec4(1.0,1.0,1.0,1.0)); From cd6d653b59e8821f376e8aca6929f8091ff032cd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 May 2014 13:29:06 +0200 Subject: [PATCH 0075/1509] - fixed: the delayed state changer for the alpha function called glBlendFunc instead of glAlphaFunc. --- src/gl/renderer/gl_renderstate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 73cc5ec90..8c31e191d 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -285,7 +285,7 @@ void FRenderState::Apply(bool forcenoshader) { glAlphaFunc = mAlphaFunc; glAlphaThreshold = mAlphaThreshold; - ::glBlendFunc(mAlphaFunc, mAlphaThreshold); + ::glAlphaFunc(mAlphaFunc, mAlphaThreshold); } if (mAlphaTest != glAlphaTest) { From f3a9cb0cfa7a9ade4878f2fed84ef1a9f20d8552 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 May 2014 14:46:37 +0200 Subject: [PATCH 0076/1509] remove special texture creation for fullscreen colormaps. On GL 3.x+ this isn't needed at all and on older hardware it causes performance issues, in particular with hires textures due to impossibility of precaching. In addition it forces some really awkward handling of lighting for things that have their own color, like stenciled sprites or particles. With this special case gone it will be possible to handle this case in a saner manner than it is right now. As compensation for older hardware a fullscreen blend will be drawn over the entire screen. This won't be 100% accurate but it's preferable to keeping the current method. --- src/gl/renderer/gl_lightdata.cpp | 27 +++-- src/gl/renderer/gl_renderstate.cpp | 48 ++++---- src/gl/scene/gl_scene.cpp | 182 +++++++++++++++++++---------- 3 files changed, 161 insertions(+), 96 deletions(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 1523443c8..0660f04c2 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -275,22 +275,27 @@ void gl_GetLightColor(int lightlevel, int rellight, const FColormap * cm, float float & r=*pred,& g=*pgreen,& b=*pblue; int torch=0; - if (gl_fixedcolormap) + if (gl_fixedcolormap) { - if (gl_fixedcolormap==CM_LITE) + if (!gl_enhanced_nightvision || !gl.hasGLSL()) { - if (gl_enhanced_nightvision) r=0.375f, g=1.0f, b=0.375f; - else r=g=b=1.0f; + // we cannot multiply the light in here without causing major problems with the ThingColor so for older hardware + // these maps are done as a postprocessing overlay. + r = g = b = 1.0f; } - else if (gl_fixedcolormap>=CM_TORCH) + else if (gl_fixedcolormap == CM_LITE) { - int flicker=gl_fixedcolormap-CM_TORCH; - r=(0.8f+(7-flicker)/70.0f); - if (r>1.0f) r=1.0f; - b=g=r; - if (gl_enhanced_nightvision) b*=0.75f; + r = 0.375f, g = 1.0f, b = 0.375f; } - else r=g=b=1.0f; + else if (gl_fixedcolormap >= CM_TORCH) + { + int flicker = gl_fixedcolormap - CM_TORCH; + r = (0.8f + (7 - flicker) / 70.0f); + if (r > 1.0f) r = 1.0f; + g = r; + b = g * 0.75f; + } + else r = g = b = 1.0f; return; } diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index d0d5c34b3..67a53bf19 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -92,33 +92,35 @@ void FRenderState::Reset() int FRenderState::SetupShader(bool cameratexture, int &shaderindex, int &cm, float warptime) { - bool usecmshader; int softwarewarp = 0; - if (shaderindex == 3) - { - // Brightmap should not be used. - if (!mBrightmapEnabled || cm >= CM_FIRSTSPECIALCOLORMAP) - { - shaderindex = 0; - } - } if (gl.hasGLSL()) { - usecmshader = cm > CM_DEFAULT && cm < CM_MAXCOLORMAP && mTextureMode != TM_MASK; + if (shaderindex == 3) + { + // Brightmap should not be used. + if (!mBrightmapEnabled || cm >= CM_FIRSTSPECIALCOLORMAP) + { + shaderindex = 0; + } + } + + mColormapState = cm; + if (cm > CM_DEFAULT && cm < CM_MAXCOLORMAP && mTextureMode != TM_MASK) + { + cm = CM_DEFAULT; + } + mEffectState = shaderindex; + mWarpTime = warptime; } else { - usecmshader = false; + if (cm != CM_SHADE) cm = CM_DEFAULT; softwarewarp = shaderindex > 0 && shaderindex < 3? shaderindex : 0; shaderindex = 0; } - mEffectState = shaderindex; - mColormapState = usecmshader? cm : CM_DEFAULT; - if (usecmshader) cm = CM_DEFAULT; - mWarpTime = warptime; return softwarewarp; } @@ -141,18 +143,18 @@ bool FRenderState::ApplyShader() else if (gl.hasGLSL()) { useshaders = (!m2D || mEffectState != 0 || mColormapState); // all 3D rendering and 2D with texture effects. - } - - if (useshaders) - { - FShaderContainer *shd = GLRenderer->mShaderManager->Get(mTextureEnabled? mEffectState : 4); - - if (shd != NULL) + if (useshaders) { - activeShader = shd->Bind(mColormapState, mGlowEnabled, mWarpTime, mLightEnabled); + FShaderContainer *shd = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4); + + if (shd != NULL) + { + activeShader = shd->Bind(mColormapState, mGlowEnabled, mWarpTime, mLightEnabled); + } } } + if (activeShader) { int fogset = 0; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 8fe1f180a..d3758c0a4 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -616,6 +616,19 @@ void FGLRenderer::DrawScene(bool toscreen) } +static void FillScreen() +{ + gl_RenderState.EnableAlphaTest(false); + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(true); + glBegin(GL_TRIANGLE_STRIP); + glVertex2f(0.0f, 0.0f); + glVertex2f(0.0f, (float)SCREENHEIGHT); + glVertex2f((float)SCREENWIDTH, 0.0f); + glVertex2f((float)SCREENWIDTH, (float)SCREENHEIGHT); + glEnd(); +} + //========================================================================== // // Draws a blend over the entire view @@ -642,12 +655,12 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) { if (viewsector->heightsec && !(viewsector->MoreFlags&SECF_IGNOREHEIGHTSEC)) { - switch(in_area) + switch (in_area) { default: - case area_normal: blendv=viewsector->heightsec->midmap; break; - case area_above: blendv=viewsector->heightsec->topmap; break; - case area_below: blendv=viewsector->heightsec->bottommap; break; + case area_normal: blendv = viewsector->heightsec->midmap; break; + case area_above: blendv = viewsector->heightsec->topmap; break; + case area_below: blendv = viewsector->heightsec->bottommap; break; } } } @@ -655,71 +668,124 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) { TArray & lightlist = viewsector->e->XFloor.lightlist; - for(unsigned int i=0;ifloorplane.ZatPoint(viewx,viewy); + if (i < lightlist.Size() - 1) + lightbottom = lightlist[i + 1].plane.ZatPoint(viewx, viewy); + else + lightbottom = viewsector->floorplane.ZatPoint(viewx, viewy); - if (lightbottomflags&FF_FADEWALLS))) + if (lightbottom < viewz && (!lightlist[i].caster || !(lightlist[i].caster->flags&FF_FADEWALLS))) { // 3d floor 'fog' is rendered as a blending value - blendv=lightlist[i].blend; + blendv = lightlist[i].blend; // If this is the same as the sector's it doesn't apply! - if (blendv == viewsector->ColorMap->Fade) blendv=0; + if (blendv == viewsector->ColorMap->Fade) blendv = 0; // a little hack to make this work for Legacy maps. - if (blendv.a==0 && blendv!=0) blendv.a=128; + if (blendv.a == 0 && blendv != 0) blendv.a = 128; break; } } } - } - if (blendv.a==0) - { - blendv = R_BlendForColormap(blendv); - if (blendv.a==255) + if (blendv.a == 0) { - // The calculated average is too dark so brighten it according to the palettes's overall brightness - int maxcol = MAX(MAX(framebuffer->palette_brightness, blendv.r), MAX(blendv.g, blendv.b)); - blendv.r = blendv.r * 255 / maxcol; - blendv.g = blendv.g * 255 / maxcol; - blendv.b = blendv.b * 255 / maxcol; + blendv = R_BlendForColormap(blendv); + if (blendv.a == 255) + { + // The calculated average is too dark so brighten it according to the palettes's overall brightness + int maxcol = MAX(MAX(framebuffer->palette_brightness, blendv.r), MAX(blendv.g, blendv.b)); + blendv.r = blendv.r * 255 / maxcol; + blendv.g = blendv.g * 255 / maxcol; + blendv.b = blendv.b * 255 / maxcol; + } + } + + if (blendv.a == 255) + { + + extra_red = blendv.r / 255.0f; + extra_green = blendv.g / 255.0f; + extra_blue = blendv.b / 255.0f; + + // If this is a multiplicative blend do it separately and add the additive ones on top of it. + blendv = 0; + + // black multiplicative blends are ignored + if (extra_red || extra_green || extra_blue) + { + gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); + glColor4f(extra_red, extra_green, extra_blue, 1.0f); + FillScreen(); + } + } + else if (blendv.a) + { + V_AddBlend(blendv.r / 255.f, blendv.g / 255.f, blendv.b / 255.f, blendv.a / 255.0f, blend); + } + } + else if (!gl.hasGLSL()) + { + float r, g, b; + bool inverse = false; + const float BLACK_THRESH = 0.05f; + const float WHITE_THRESH = 0.95f; + + // for various reasons (performance and keeping the lighting code clean) + // we no longer do colormapped textures on pre GL 3.0 hardware and instead do + // just a fullscreen overlay to emulate the inverse invulnerability effect or similar fullscreen blends. + if (gl_fixedcolormap >= CM_FIRSTSPECIALCOLORMAP && gl_fixedcolormap < CM_MAXCOLORMAP) + { + FSpecialColormap *scm = &SpecialColormaps[gl_fixedcolormap - CM_FIRSTSPECIALCOLORMAP]; + + if (scm->ColorizeEnd[0] < BLACK_THRESH && scm->ColorizeEnd[1] < BLACK_THRESH && scm->ColorizeEnd[2] < BLACK_THRESH) + { + r = scm->ColorizeStart[0]; + g = scm->ColorizeStart[1]; + b = scm->ColorizeStart[2]; + inverse = true; + } + else + { + r = scm->ColorizeEnd[0]; + g = scm->ColorizeEnd[1]; + b = scm->ColorizeEnd[2]; + } + + } + else if (gl_enhanced_nightvision) + { + if (gl_fixedcolormap == CM_LITE) + { + r = 0.375f, g = 1.0f, b = 0.375f; + } + else if (gl_fixedcolormap >= CM_TORCH) + { + int flicker = gl_fixedcolormap - CM_TORCH; + r = (0.8f + (7 - flicker) / 70.0f); + if (r > 1.0f) r = 1.0f; + g = r; + b = g * 0.75f; + } + else r = g = b = 1.f; + } + + if (inverse) + { + gl_RenderState.BlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); + glColor4f(1.f, 1.f, 1.f, 1.f); + FillScreen(); + } + + if (r < WHITE_THRESH || g < WHITE_THRESH || b < WHITE_THRESH) + { + gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); + glColor4f(r, g, b, 1.0f); + FillScreen(); } } - if (blendv.a==255) - { - - extra_red = blendv.r / 255.0f; - extra_green = blendv.g / 255.0f; - extra_blue = blendv.b / 255.0f; - - // If this is a multiplicative blend do it separately and add the additive ones on top of it! - blendv=0; - - // black multiplicative blends are ignored - if (extra_red || extra_green || extra_blue) - { - gl_RenderState.EnableAlphaTest(false); - gl_RenderState.EnableTexture(false); - gl_RenderState.BlendFunc(GL_DST_COLOR,GL_ZERO); - glColor4f(extra_red, extra_green, extra_blue, 1.0f); - gl_RenderState.Apply(true); - glBegin(GL_TRIANGLE_STRIP); - glVertex2f( 0.0f, 0.0f); - glVertex2f( 0.0f, (float)SCREENHEIGHT); - glVertex2f( (float)SCREENWIDTH, 0.0f); - glVertex2f( (float)SCREENWIDTH, (float)SCREENHEIGHT); - glEnd(); - } - } - else if (blendv.a) - { - V_AddBlend (blendv.r / 255.f, blendv.g / 255.f, blendv.b / 255.f, blendv.a/255.0f,blend); - } // This mostly duplicates the code in shared_sbar.cpp // When I was writing this the original was called too late so that I @@ -741,16 +807,8 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) if (blend[3]>0.0f) { gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl_RenderState.EnableAlphaTest(false); - gl_RenderState.EnableTexture(false); glColor4fv(blend); - gl_RenderState.Apply(true); - glBegin(GL_TRIANGLE_STRIP); - glVertex2f( 0.0f, 0.0f); - glVertex2f( 0.0f, (float)SCREENHEIGHT); - glVertex2f( (float)SCREENWIDTH, 0.0f); - glVertex2f( (float)SCREENWIDTH, (float)SCREENHEIGHT); - glEnd(); + FillScreen(); } } From 53f4cd010837e3bbdd4c897daa97d44a7ee8a911 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 May 2014 16:06:25 +0200 Subject: [PATCH 0077/1509] - added objectcolor uniform. This will be used to hold the thingcolor for shader based rendering. --- src/gl/dynlights/gl_dynlight1.cpp | 8 ------- src/gl/renderer/gl_renderstate.cpp | 9 ++++++++ src/gl/renderer/gl_renderstate.h | 23 +++++++++++++++++++- src/gl/scene/gl_flats.cpp | 1 - src/gl/scene/gl_sprite.cpp | 3 ++- src/gl/scene/gl_walls_draw.cpp | 1 + src/gl/shaders/gl_shader.h | 5 ++++- wadsrc/static/shaders/glsl/func_notexture.fp | 2 +- wadsrc/static/shaders/glsl/main.fp | 3 ++- wadsrc/static/shaders/glsl/main_colormap.fp | 3 ++- 10 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index e09207411..57da56b40 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -234,14 +234,6 @@ bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & u { gl_RenderState.BlendEquation(GL_FUNC_ADD); } - if (desaturation>0) - { - float gray=(r*77 + g*143 + b*37)/257; - - r= (r*(32-desaturation)+ gray*desaturation)/32; - g= (g*(32-desaturation)+ gray*desaturation)/32; - b= (b*(32-desaturation)+ gray*desaturation)/32; - } glColor3f(r,g,b); return true; } diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 67a53bf19..84f270e06 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -78,6 +78,7 @@ void FRenderState::Reset() mAlphaFunc = GL_GEQUAL; mAlphaThreshold = 0.5f; mBlendEquation = GL_FUNC_ADD; + mObjectColor = 0xffffffff; glBlendEquation = -1; m2D = true; mVertexBuffer = mCurrentVertexBuffer = NULL; @@ -158,6 +159,7 @@ bool FRenderState::ApplyShader() if (activeShader) { int fogset = 0; + //glColor4fv(mColor.vec); if (mFogEnabled) { if ((mFogColor & 0xffffff) == 0) @@ -226,6 +228,11 @@ bool FRenderState::ApplyShader() { glUniform3fv(activeShader->dlightcolor_index, 1, mDynLight); } + if (mObjectColor != activeShader->currentobjectcolor) + { + activeShader->currentobjectcolor = mObjectColor; + glUniform4f(activeShader->objectcolor_index, mObjectColor.r / 255.f, mObjectColor.g / 255.f, mObjectColor.b / 255.f, mObjectColor.a / 255.f); + } return true; } @@ -276,6 +283,8 @@ void FRenderState::Apply(bool forcenoshader) } if (forcenoshader || !ApplyShader()) { + //if (mColor.vec[0] >= 0.f) glColor4fv(mColor.vec); + GLRenderer->mShaderManager->SetActiveShader(NULL); if (mTextureMode != ffTextureMode) { diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 7e611f7a5..35f5795a2 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -107,11 +107,12 @@ class FRenderState bool m2D; FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; - + FStateVec4 mColor; FStateVec3 mCameraPos; FStateVec4 mGlowTop, mGlowBottom; FStateVec4 mGlowTopPlane, mGlowBottomPlane; PalEntry mFogColor; + PalEntry mObjectColor; float mFogDensity; int mEffectState; @@ -149,6 +150,26 @@ public: mVertexBuffer = vb; } + void SetColor(float r, float g, float b, float a = 1.f, int desat = 0) + { + mColor.Set(r, g, b, a); + } + + void SetColor(PalEntry pe, int desat = 0) + { + mColor.Set(pe.r/255.f, pe.g/255.f, pe.b/255.f, pe.a/255.f); + } + + void SetColorAlpha(PalEntry pe, float alpha = 1.f, int desat = 0) + { + mColor.Set(pe.r/255.f, pe.g/255.f, pe.b/255.f, alpha); + } + + void ResetColor() + { + mColor.Set(1,1,1,1); + } + void SetTextureMode(int mode) { mTextureMode = mode; diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index c32011998..f24db1fdd 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -325,7 +325,6 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) { if (gl_usevbo && vboindex >= 0) { - //glColor3f( 1.f,.5f,.5f); int index = vboindex; for (int i=0; isubsectorcount; i++) { diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index d018d2eea..46541fc27 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -749,7 +749,8 @@ void GLSprite::Process(AActor* thing,sector_t * sector) if (gl_enhanced_nightvision && (thing->IsKindOf(RUNTIME_CLASS(AInventory)) || thing->flags3&MF3_ISMONSTER || thing->flags&MF_MISSILE || thing->flags&MF_CORPSE)) { - Colormap.colormap = CM_FIRSTSPECIALCOLORMAP + INVERSECOLORMAP; + // needs to be fixed later + //Colormap.colormap = CM_FIRSTSPECIALCOLORMAP + INVERSECOLORMAP; } } } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index f060978e4..7f7538dc4 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -373,6 +373,7 @@ void GLWall::RenderFogBoundary() gl_RenderState.AlphaFunc(GL_GREATER,0); glDepthFunc(GL_LEQUAL); glColor4f(fc[0],fc[1],fc[2], fogd1); + gl_RenderState.SetColor(-1, 0, 0, 0); // we do not want the render state to control the color. if (glset.lightmode == 8) glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); // Korshun. flags &= ~GLWF_GLOW; diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index bd3aa0f30..4b0c37e1e 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -40,7 +40,9 @@ class FShader int glowtopcolor_index; int glowbottomplane_index; int glowtopplane_index; + int objectcolor_index; + PalEntry currentobjectcolor; int currentglowstate; int currentfogenabled; int currenttexturemode; @@ -59,7 +61,7 @@ public: currentglowstate = currentfogenabled = currenttexturemode = 0; currentlightfactor = currentlightdist = 0.0f; currentfogdensity = -1; - currentfogcolor = 0; + currentobjectcolor = currentfogcolor = 0; timer_index = -1; desaturation_index = -1; @@ -73,6 +75,7 @@ public: fogcolor_index = -1; lights_index = -1; dlightcolor_index = -1; + objectcolor_index = -1; glowtopplane_index = -1; glowbottomplane_index = -1; glowtopcolor_index = -1; diff --git a/wadsrc/static/shaders/glsl/func_notexture.fp b/wadsrc/static/shaders/glsl/func_notexture.fp index 99ef44f68..904d4a6cd 100644 --- a/wadsrc/static/shaders/glsl/func_notexture.fp +++ b/wadsrc/static/shaders/glsl/func_notexture.fp @@ -1,6 +1,6 @@ vec4 Process(vec4 color) { - return color; + return color*objectcolor; } diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 6bb17a2ad..a99ffa330 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -23,6 +23,7 @@ uniform vec4 lights[128]; uniform int fogenabled; uniform vec4 fogcolor; +uniform vec4 objectcolor; uniform vec3 dlightcolor; uniform vec3 camerapos; varying vec4 pixelpos; @@ -158,7 +159,7 @@ vec4 getTexel(vec2 st) } #endif - return desaturate(texel); + return desaturate(texel * objectcolor); } //=========================================================================== diff --git a/wadsrc/static/shaders/glsl/main_colormap.fp b/wadsrc/static/shaders/glsl/main_colormap.fp index fa0f28f25..d4c079cdd 100644 --- a/wadsrc/static/shaders/glsl/main_colormap.fp +++ b/wadsrc/static/shaders/glsl/main_colormap.fp @@ -1,6 +1,7 @@ uniform int texturemode; uniform sampler2D tex; +uniform vec4 objectcolor; uniform vec3 colormapstart; uniform vec3 colormaprange; @@ -28,7 +29,7 @@ vec4 getTexel(vec2 st) texel.rgb = vec3(1.0,1.0,1.0); } - return texel; + return texel*objectcolor; } From 52056a05bda71b47740ebc5567fe367df8d2f5fc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 May 2014 16:49:17 +0200 Subject: [PATCH 0078/1509] - changed handling of DynLight in shader to serve as a global dynamic light color for all lighting modes. --- src/gl/dynlights/gl_dynlight.h | 4 +- src/gl/dynlights/gl_dynlight1.cpp | 13 +----- src/gl/renderer/gl_lightdata.cpp | 67 ++++++++---------------------- src/gl/renderer/gl_renderstate.cpp | 9 ++-- src/gl/renderer/gl_renderstate.h | 15 +++++-- src/gl/scene/gl_flats.cpp | 4 +- src/gl/scene/gl_skydome.cpp | 2 +- src/gl/scene/gl_walls_draw.cpp | 4 +- src/gl/scene/gl_weapon.cpp | 12 ++++-- src/gl/shaders/gl_shader.cpp | 1 + src/gl/shaders/gl_shader.h | 3 +- wadsrc/static/shaders/glsl/main.fp | 16 ++++--- 12 files changed, 61 insertions(+), 89 deletions(-) diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index ca3b2ec90..dbf89324b 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -182,8 +182,8 @@ struct FDynLightData -bool gl_GetLight(Plane & p, ADynamicLight * light, int desaturation, bool checkside, bool forceadditive, FDynLightData &data); -bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, float & scale, int desaturation, bool checkside=true, bool forceadditive=true); +bool gl_GetLight(Plane & p, ADynamicLight * light, bool checkside, bool forceadditive, FDynLightData &data); +bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, float & scale, bool checkside=true, bool forceadditive=true); bool gl_SetupLightTexture(); diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index 57da56b40..90d65559c 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -100,8 +100,7 @@ CUSTOM_CVAR (Bool, gl_lights_additive, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG // Sets up the parameters to render one dynamic light onto one plane // //========================================================================== -bool gl_GetLight(Plane & p, ADynamicLight * light, - int desaturation, bool checkside, bool forceadditive, FDynLightData &ldata) +bool gl_GetLight(Plane & p, ADynamicLight * light, bool checkside, bool forceadditive, FDynLightData &ldata) { Vector fn, pos; int i = 0; @@ -147,14 +146,6 @@ bool gl_GetLight(Plane & p, ADynamicLight * light, i = 1; } - if (desaturation>0) - { - float gray=(r*77 + g*143 + b*37)/257; - - r= (r*(32-desaturation)+ gray*desaturation)/32; - g= (g*(32-desaturation)+ gray*desaturation)/32; - b= (b*(32-desaturation)+ gray*desaturation)/32; - } float *data = &ldata.arrays[i][ldata.arrays[i].Reserve(8)]; data[0] = x; data[1] = z; @@ -176,7 +167,7 @@ bool gl_GetLight(Plane & p, ADynamicLight * light, // //========================================================================== bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, - float & scale, int desaturation, bool checkside, bool forceadditive) + float & scale, bool checkside, bool forceadditive) { Vector fn, pos; diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 0660f04c2..1ceb609c8 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -256,13 +256,15 @@ PalEntry gl_CalcLightColor(int light, PalEntry pe, int blendfactor, bool force) } else { + // This is what Legacy does with colored light in 3D volumes. No, it doesn't really make sense... + // It also doesn't translate well to software style lighting. int mixlight = light * (255 - blendfactor); r = (mixlight + pe.r * blendfactor) / 255; g = (mixlight + pe.g * blendfactor) / 255; b = (mixlight + pe.b * blendfactor) / 255; } - return PalEntry(BYTE(r), BYTE(g), BYTE(b)); + return PalEntry(255, BYTE(r), BYTE(g), BYTE(b)); } //========================================================================== @@ -373,7 +375,7 @@ void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, Pal // //========================================================================== -float gl_GetFogDensity(int lightlevel, PalEntry fogcolor) +static float gl_GetFogDensity(int lightlevel, PalEntry fogcolor) { float density; @@ -417,98 +419,65 @@ float gl_GetFogDensity(int lightlevel, PalEntry fogcolor) } -//========================================================================== -// -// Check fog by current lighting info -// -//========================================================================== - -bool gl_CheckFog(FColormap *cm, int lightlevel) -{ - // Check for fog boundaries. This needs a few more checks for the sectors - bool frontfog; - - PalEntry fogcolor = cm->FadeColor; - - if ((fogcolor.d & 0xffffff) == 0) - { - frontfog = false; - } - else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff)) - { - frontfog = true; - } - else if (fogdensity!=0 || (glset.lightmode & 4)) - { - // case 3: level has fog density set - frontfog = true; - } - else - { - // case 4: use light level - frontfog = lightlevel < 248; - } - return frontfog; -} - //========================================================================== // // Check if the current linedef is a candidate for a fog boundary // +// Requirements for a fog boundary: +// - front sector has no fog +// - back sector has fog +// - at least one of both does not have a sky ceiling. +// //========================================================================== bool gl_CheckFog(sector_t *frontsector, sector_t *backsector) { + if (gl_fixedcolormap) return false; + if (frontsector == backsector) return false; // there can't be a boundary if both sides are in the same sector. + // Check for fog boundaries. This needs a few more checks for the sectors - bool frontfog, backfog; PalEntry fogcolor = frontsector->ColorMap->Fade; if ((fogcolor.d & 0xffffff) == 0) { - frontfog = false; + return false; } else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff)) { - frontfog = true; } else if (fogdensity!=0 || (glset.lightmode & 4)) { // case 3: level has fog density set - frontfog = true; } else { // case 4: use light level - frontfog = frontsector->lightlevel < 248; + if (frontsector->lightlevel >= 248) return false; } - if (backsector == NULL) return frontfog; - fogcolor = backsector->ColorMap->Fade; if ((fogcolor.d & 0xffffff) == 0) { - backfog = false; } else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff)) { - backfog = true; + return false; } else if (fogdensity!=0 || (glset.lightmode & 4)) { // case 3: level has fog density set - backfog = true; + return false; } else { // case 4: use light level - backfog = backsector->lightlevel < 248; + if (backsector->lightlevel < 248) return false; } // in all other cases this might create more problems than it solves. - return (frontfog && !backfog && !gl_fixedcolormap && - (frontsector->GetTexture(sector_t::ceiling)!=skyflatnum || + return ((frontsector->GetTexture(sector_t::ceiling)!=skyflatnum || backsector->GetTexture(sector_t::ceiling)!=skyflatnum)); } diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 84f270e06..96b782771 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -224,15 +224,16 @@ bool FRenderState::ApplyShader() glUniform3iv(activeShader->lightrange_index, 1, mNumLights); glUniform4fv(activeShader->lights_index, mNumLights[2], mLightData); } - if (glset.lightmode == 8) - { - glUniform3fv(activeShader->dlightcolor_index, 1, mDynLight); - } if (mObjectColor != activeShader->currentobjectcolor) { activeShader->currentobjectcolor = mObjectColor; glUniform4f(activeShader->objectcolor_index, mObjectColor.r / 255.f, mObjectColor.g / 255.f, mObjectColor.b / 255.f, mObjectColor.a / 255.f); } + if (mDynColor != activeShader->currentdlightcolor) + { + activeShader->currentobjectcolor = mObjectColor; + glUniform4f(activeShader->dlightcolor_index, mDynColor.r / 255.f, mDynColor.g / 255.f, mDynColor.b / 255.f, 0); + } return true; } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 35f5795a2..2c2c43605 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -95,7 +95,6 @@ class FRenderState bool mBrightmapEnabled; int mSpecialEffect; int mTextureMode; - float mDynLight[3]; float mLightParms[2]; int mNumLights[3]; float *mLightData; @@ -113,6 +112,7 @@ class FRenderState FStateVec4 mGlowTopPlane, mGlowBottomPlane; PalEntry mFogColor; PalEntry mObjectColor; + PalEntry mDynColor; float mFogDensity; int mEffectState; @@ -153,21 +153,25 @@ public: void SetColor(float r, float g, float b, float a = 1.f, int desat = 0) { mColor.Set(r, g, b, a); + glColor4fv(mColor.vec); } void SetColor(PalEntry pe, int desat = 0) { mColor.Set(pe.r/255.f, pe.g/255.f, pe.b/255.f, pe.a/255.f); + glColor4fv(mColor.vec); } void SetColorAlpha(PalEntry pe, float alpha = 1.f, int desat = 0) { mColor.Set(pe.r/255.f, pe.g/255.f, pe.b/255.f, alpha); + glColor4fv(mColor.vec); } void ResetColor() { mColor.Set(1,1,1,1); + glColor4fv(mColor.vec); } void SetTextureMode(int mode) @@ -224,9 +228,12 @@ public: void SetDynLight(float r, float g, float b) { - mDynLight[0] = r; - mDynLight[1] = g; - mDynLight[2] = b; + mDynColor = PalEntry(xs_CRoundToInt(r*255), xs_CRoundToInt(g*255), xs_CRoundToInt(b*255)); + } + + void SetDynLight(PalEntry pe) + { + mDynColor = pe; } void SetFog(PalEntry c, float d) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index f24db1fdd..4a4c0d715 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -143,7 +143,7 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) } p.Set(plane.plane); - if (!gl_SetupLight(p, light, nearPt, up, right, scale, Colormap.colormap, false, foggy)) + if (!gl_SetupLight(p, light, nearPt, up, right, scale, false, foggy)) { node=node->nextLight; continue; @@ -206,7 +206,7 @@ bool GLFlat::SetupSubsectorLights(bool lightsapplied, subsector_t * sub) } p.Set(plane.plane); - gl_GetLight(p, light, Colormap.colormap, false, false, lightdata); + gl_GetLight(p, light, false, false, lightdata); node = node->nextLight; } } diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index dee3ea4e3..7dbf5e573 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -602,7 +602,7 @@ void GLSkyPortal::DrawContents() { gl_RenderState.EnableTexture(false); foglayer=true; - glColor4f(FadeColor.r/255.0f,FadeColor.g/255.0f,FadeColor.b/255.0f,skyfog/255.0f); + gl_RenderState.SetColorAlpha(FadeColor, skyfog / 255.0f); RenderDome(FNullTextureID(), NULL, 0, 0, false, CM_DEFAULT); gl_RenderState.EnableTexture(true); foglayer=false; diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 7f7538dc4..b4af1e28d 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -81,7 +81,7 @@ bool GLWall::PrepareLight(texcoord * tcs, ADynamicLight * light) return false; } - if (!gl_SetupLight(p, light, nearPt, up, right, scale, Colormap.colormap, true, !!(flags&GLWF_FOGGY))) + if (!gl_SetupLight(p, light, nearPt, up, right, scale, true, !!(flags&GLWF_FOGGY))) { return false; } @@ -197,7 +197,7 @@ void GLWall::SetupLights() } if (outcnt[0]!=4 && outcnt[1]!=4 && outcnt[2]!=4 && outcnt[3]!=4) { - gl_GetLight(p, node->lightsource, Colormap.colormap, true, false, lightdata); + gl_GetLight(p, node->lightsource, true, false, lightdata); } } } diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index fe3aee0ff..c9f8434c4 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -286,7 +286,8 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) statebright[0] = statebright[1] = true; } - PalEntry ThingColor = playermo->fillcolor; + PalEntry ThingColor = (playermo->RenderStyle.Flags & STYLEF_ColorIsFixed) ? playermo->fillcolor : 0xffffff; + visstyle_t vis; vis.RenderStyle=playermo->RenderStyle; @@ -345,6 +346,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) // now draw the different layers of the weapon gl_RenderState.EnableBrightmap(true); + gl_RenderState.SetObjectColor(ThingColor); if (statebright[0] || statebright[1]) { // brighten the weapon to reduce the difference between @@ -365,7 +367,6 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) if (statebright[i]) { if (fakesec == viewsector || in_area != area_below) - // under water areas keep most of their color for fullbright objects { cmc.LightColor.r= cmc.LightColor.g= @@ -373,7 +374,8 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) } else { - cmc.LightColor.r = (3*cmc.LightColor.r + 0xff)/4; + // under water areas keep most of their color for fullbright objects + cmc.LightColor.r = (3 * cmc.LightColor.r + 0xff) / 4; cmc.LightColor.g = (3*cmc.LightColor.g + 0xff)/4; cmc.LightColor.b = (3*cmc.LightColor.b + 0xff)/4; } @@ -384,6 +386,8 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) DrawPSprite (player,psp,psp->sx+ofsx, psp->sy+ofsy, cm.colormap, hudModelStep, OverrideShader); } } + gl_RenderState.SetObjectColor(0xffffffff); + gl_RenderState.SetDynLight(0, 0, 0); gl_RenderState.EnableBrightmap(false); glset.lightmode = oldlightmode; } @@ -408,7 +412,7 @@ void FGLRenderer::DrawTargeterSprites() gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_sprite_threshold); gl_RenderState.BlendEquation(GL_FUNC_ADD); - glColor3f(1.0f,1.0f,1.0f); + gl_RenderState.ResetColor(); gl_RenderState.SetTextureMode(TM_MODULATE); // The Targeter's sprites are always drawn normally. diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 2065768fa..8f993b857 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -177,6 +177,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * fogcolor_index = glGetUniformLocation(hShader, "fogcolor"); lights_index = glGetUniformLocation(hShader, "lights"); dlightcolor_index = glGetUniformLocation(hShader, "dlightcolor"); + objectcolor_index = glGetUniformLocation(hShader, "objectcolor"); glowbottomcolor_index = glGetUniformLocation(hShader, "bottomglowcolor"); glowtopcolor_index = glGetUniformLocation(hShader, "topglowcolor"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 4b0c37e1e..62c87c1f9 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -42,6 +42,7 @@ class FShader int glowtopplane_index; int objectcolor_index; + PalEntry currentdlightcolor; PalEntry currentobjectcolor; int currentglowstate; int currentfogenabled; @@ -61,7 +62,7 @@ public: currentglowstate = currentfogenabled = currenttexturemode = 0; currentlightfactor = currentlightdist = 0.0f; currentfogdensity = -1; - currentobjectcolor = currentfogcolor = 0; + currentdlightcolor = currentobjectcolor = currentfogcolor = 0; timer_index = -1; desaturation_index = -1; diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index a99ffa330..8587b5ac3 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -24,7 +24,7 @@ uniform vec4 lights[128]; uniform int fogenabled; uniform vec4 fogcolor; uniform vec4 objectcolor; -uniform vec3 dlightcolor; +uniform vec4 dlightcolor; uniform vec3 camerapos; varying vec4 pixelpos; varying vec4 fogparm; @@ -95,7 +95,7 @@ vec4 getLightColor(float fogdist, float fogfactor) vec4 color = gl_Color; #ifdef SOFTLIGHT float newlightlevel = 1.0 - R_DoomLightingEquation(lightlevel, gl_FragCoord.z); - color.rgb *= clamp(vec3(newlightlevel) + dlightcolor, 0.0, 1.0); + color.rgb *= clamp(vec3(newlightlevel), 0.0, 1.0); #endif #ifndef NO_FOG // @@ -187,11 +187,6 @@ void main() float fogdist = 0.0; float fogfactor = 0.0; - #ifdef DYNLIGHT - vec4 dynlight = vec4(0.0,0.0,0.0,0.0); - vec4 addlight = vec4(0.0,0.0,0.0,0.0); - #endif - #ifndef NO_FOG // // calculate fog factor @@ -214,6 +209,9 @@ void main() #ifdef DYNLIGHT + vec4 dynlight = dlightcolor; + vec4 addlight = vec4(0.0,0.0,0.0,0.0); + for(int i=0; i Date: Sun, 11 May 2014 16:51:33 +0200 Subject: [PATCH 0079/1509] -looks like we still need this... --- src/gl/renderer/gl_lightdata.cpp | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 1ceb609c8..3caa5cbc5 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -419,6 +419,40 @@ static float gl_GetFogDensity(int lightlevel, PalEntry fogcolor) } +//========================================================================== +// +// Check fog by current lighting info +// +//========================================================================== + +bool gl_CheckFog(FColormap *cm, int lightlevel) +{ + // Check for fog boundaries. This needs a few more checks for the sectors + bool frontfog; + + PalEntry fogcolor = cm->FadeColor; + + if ((fogcolor.d & 0xffffff) == 0) + { + frontfog = false; + } + else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff)) + { + frontfog = true; + } + else if (fogdensity!=0 || (glset.lightmode & 4)) + { + // case 3: level has fog density set + frontfog = true; + } + else + { + // case 4: use light level + frontfog = lightlevel < 248; + } + return frontfog; +} + //========================================================================== // // Check if the current linedef is a candidate for a fog boundary From 607be91c4858244ad49ed4cb3c384f2b97a9eb47 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 May 2014 16:54:11 +0200 Subject: [PATCH 0080/1509] - bad copy. --- src/gl/renderer/gl_lightdata.cpp | 2 +- src/gl/renderer/gl_renderstate.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 3caa5cbc5..afd5cdbcf 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -375,7 +375,7 @@ void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, Pal // //========================================================================== -static float gl_GetFogDensity(int lightlevel, PalEntry fogcolor) +float gl_GetFogDensity(int lightlevel, PalEntry fogcolor) { float density; diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 2c2c43605..e037fb637 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -236,6 +236,11 @@ public: mDynColor = pe; } + void SetObjectColor(PalEntry pe) + { + mObjectColor = pe; + } + void SetFog(PalEntry c, float d) { mFogColor = c; From 7793bbbcc978d766c1ac0621e543005ed96a9b84 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 May 2014 17:56:38 +0200 Subject: [PATCH 0081/1509] Further cleanup of lighting code. - remove thing color from lighting calculations. - implement alpha textures and inverse sprites for infrared as texture modes. This still requires some handling for the alpha texture mode for non-shader rendering because there is no way in the fixed pipeline to do it. The inverted texture effect can be done with a texture combiner. - fixed: ThingColor for sprites was set in the wrong place. It must be in the Process function, not in the lighting calculation. - added functions for isolated calculation of sprites' dynlight color. --- src/gl/renderer/gl_lightdata.cpp | 28 ++++---- src/gl/renderer/gl_lightdata.h | 3 +- src/gl/renderer/gl_renderer.cpp | 1 + src/gl/scene/gl_decal.cpp | 2 +- src/gl/scene/gl_sprite.cpp | 35 ++++------ src/gl/scene/gl_spritelight.cpp | 73 ++++++++++++++++++++- src/gl/scene/gl_wall.h | 4 ++ src/gl/system/gl_interface.cpp | 19 +----- src/gl/system/gl_interface.h | 16 ++--- wadsrc/static/shaders/glsl/main.fp | 12 +++- wadsrc/static/shaders/glsl/main_colormap.fp | 12 +++- 11 files changed, 133 insertions(+), 72 deletions(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index afd5cdbcf..102d1d43e 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -160,13 +160,17 @@ void gl_GetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblend int blendequation = renderops[style.BlendOp&15]; int texturemode = drawopaque? TM_OPAQUE : TM_MODULATE; - if (style.Flags & STYLEF_ColorIsFixed) + if (style.Flags & STYLEF_RedIsAlpha) + { + texturemode = TM_REDTOALPHA; + } + else if (style.Flags & STYLEF_ColorIsFixed) { texturemode = TM_MASK; } else if (style.Flags & STYLEF_InvertSource) { - texturemode = drawopaque? TM_INVERTOPAQUE : TM_INVERT; + texturemode = TM_INVERSE; } if (blendequation == -1) @@ -316,14 +320,9 @@ void gl_GetLightColor(int lightlevel, int rellight, const FColormap * cm, float // set current light color // //========================================================================== -void gl_SetColor(int light, int rellight, const FColormap * cm, float *red, float *green, float *blue, PalEntry ThingColor, bool weapon) +void gl_SetColor(int light, int rellight, const FColormap * cm, float *red, float *green, float *blue, bool weapon) { - float r,g,b; - gl_GetLightColor(light, rellight, cm, &r, &g, &b, weapon); - - *red = r * ThingColor.r/255.0f; - *green = g * ThingColor.g/255.0f; - *blue = b * ThingColor.b/255.0f; + gl_GetLightColor(light, rellight, cm, red, green, blue, weapon); } //========================================================================== @@ -331,20 +330,15 @@ void gl_SetColor(int light, int rellight, const FColormap * cm, float *red, floa // set current light color // //========================================================================== -void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, PalEntry ThingColor, bool weapon) +void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, bool weapon) { float r,g,b; gl_GetLightColor(light, rellight, cm, &r, &g, &b, weapon); - if (glset.lightmode != 8) - { - glColor4f(r * ThingColor.r/255.0f, g * ThingColor.g/255.0f, b * ThingColor.b/255.0f, alpha); - } - else + gl_RenderState.SetColor(r, g, b, alpha); + if (glset.lightmode == 8) { - glColor4f(r, g, b, alpha); - if (gl_fixedcolormap) { glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); diff --git a/src/gl/renderer/gl_lightdata.h b/src/gl/renderer/gl_lightdata.h index 33d179b27..8eb70bbb9 100644 --- a/src/gl/renderer/gl_lightdata.h +++ b/src/gl/renderer/gl_lightdata.h @@ -20,8 +20,7 @@ void gl_SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefog int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon); PalEntry gl_CalcLightColor(int light, PalEntry pe, int blendfactor, bool force = false); void gl_GetLightColor(int lightlevel, int rellight, const FColormap * cm, float * pred, float * pgreen, float * pblue, bool weapon=false); -void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, PalEntry ThingColor = 0xffffff, bool weapon=false); -void gl_SetColor(int light, int rellight, const FColormap * cm, float *red, float *green, float *blue, PalEntry ThingColor=0xffffff, bool weapon=false); +void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, bool weapon=false); float gl_GetFogDensity(int lightlevel, PalEntry fogcolor); struct sector_t; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 3ce805351..5120c00ea 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -338,6 +338,7 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) else { // This is an alpha texture + gl_RenderState.SetTextureMode(TM_REDTOALPHA); gltex->BindPatch(CM_SHADE, 0); } diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index bd39f8008..959641076 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -377,7 +377,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) { if (glset.lightmode == 8) { - gl_SetColor(light, rel, &p, a, extralight); // Korshun. + gl_SetColor(light, rel, &p, a, !!extralight); // Korshun. } else { diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 46541fc27..d64f62b71 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -169,7 +169,7 @@ void GLSprite::Draw(int pass) } gl_RenderState.AlphaFunc(GL_GEQUAL,minalpha*gl_mask_sprite_threshold); - glColor4f(0.2f,0.2f,0.2f,fuzzalpha); + gl_RenderState.SetColor(0.2f,0.2f,0.2f,fuzzalpha); additivefog = true; } else if (RenderStyle.BlendOp == STYLEOP_Add && RenderStyle.DestAlpha == STYLEALPHA_One) @@ -181,22 +181,23 @@ void GLSprite::Draw(int pass) { if (actor) { - lightlevel = gl_SetSpriteLighting(RenderStyle, actor, lightlevel, rel, &Colormap, ThingColor, trans, + lightlevel = gl_SetSpriteLighting(RenderStyle, actor, lightlevel, rel, &Colormap, 0xffffffff, trans, fullbright || gl_fixedcolormap >= CM_FIRSTSPECIALCOLORMAP, false); } else if (particle) { if (gl_light_particles) { - lightlevel = gl_SetSpriteLight(particle, lightlevel, rel, &Colormap, trans, ThingColor); + lightlevel = gl_SetSpriteLight(particle, lightlevel, rel, &Colormap, trans, 0xffffffff); } else { - gl_SetColor(lightlevel, rel, &Colormap, trans, ThingColor); + gl_SetColor(lightlevel, rel, &Colormap, trans); } } else return; } + gl_RenderState.SetObjectColor(ThingColor); if (gl_isBlack(Colormap.FadeColor)) foglevel=lightlevel; @@ -425,13 +426,6 @@ void GLSprite::SplitSprite(sector_t * frontsector, bool translucent) copySprite.Colormap.LightColor.b=(255+v+v)/3; } - if (!gl_isWhite(ThingColor)) - { - copySprite.Colormap.LightColor.r=(copySprite.Colormap.LightColor.r*ThingColor.r)>>8; - copySprite.Colormap.LightColor.g=(copySprite.Colormap.LightColor.g*ThingColor.g)>>8; - copySprite.Colormap.LightColor.b=(copySprite.Colormap.LightColor.b*ThingColor.b)>>8; - } - z1=copySprite.z2=maplightbottom; vt=copySprite.vb=copySprite.vt+ (maplightbottom-copySprite.z1)*(copySprite.vb-copySprite.vt)/(z2-copySprite.z1); @@ -471,13 +465,6 @@ void GLSprite::SetSpriteColor(sector_t *sector, fixed_t center_y) Colormap.LightColor.g= Colormap.LightColor.b=(255+v+v)/3; } - - if (!gl_isWhite(ThingColor)) - { - Colormap.LightColor.r=(Colormap.LightColor.r*ThingColor.r)>>8; - Colormap.LightColor.g=(Colormap.LightColor.g*ThingColor.g)>>8; - Colormap.LightColor.b=(Colormap.LightColor.b*ThingColor.b)>>8; - } return; } } @@ -734,6 +721,10 @@ void GLSprite::Process(AActor* thing,sector_t * sector) lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, thingx, thingy, thingz); + ThingColor = (thing->RenderStyle.Flags & STYLEF_ColorIsFixed) ? thing->fillcolor : 0xffffff; + ThingColor.a = 255; + RenderStyle = thing->RenderStyle; + // colormap stuff is a little more complicated here... if (gl_fixedcolormap) { @@ -749,8 +740,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) if (gl_enhanced_nightvision && (thing->IsKindOf(RUNTIME_CLASS(AInventory)) || thing->flags3&MF3_ISMONSTER || thing->flags&MF_MISSILE || thing->flags&MF_CORPSE)) { - // needs to be fixed later - //Colormap.colormap = CM_FIRSTSPECIALCOLORMAP + INVERSECOLORMAP; + RenderStyle.Flags |= STYLEF_InvertSource; } } } @@ -785,8 +775,6 @@ void GLSprite::Process(AActor* thing,sector_t * sector) translation=thing->Translation; - ThingColor=0xffffff; - RenderStyle = thing->RenderStyle; OverrideShader = 0; trans = FIXED2FLOAT(thing->alpha); hw_styleflags = STYLEHW_Normal; @@ -955,8 +943,7 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s OverrideShader = 0; ThingColor = particle->color; - gl_ModifyColor(ThingColor.r, ThingColor.g, ThingColor.b, Colormap.colormap); - ThingColor.a=0; + ThingColor.a = 255; modelframe=NULL; gltexture=NULL; diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index b1216d86b..66a2b6c7f 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -57,6 +57,77 @@ #include "gl/textures/gl_material.h" +//========================================================================== +// +// Sets a single light value from all dynamic lights affecting the specified location +// +//========================================================================== + +void gl_SetDynSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsector_t * subsec) +{ + ADynamicLight *light; + float frac, lr, lg, lb; + float radius; + float out[3] = { 0.0f, 0.0f, 0.0f }; + + // Go through both light lists + for (int i = 0; i < 2; i++) + { + FLightNode * node = subsec->lighthead[i]; + while (node) + { + light = node->lightsource; + if (!light->owned || light->target == NULL || light->target->IsVisibleToPlayer()) + { + if (!(light->flags2&MF2_DORMANT) && + (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) + { + float dist = FVector3(FIXED2FLOAT(x - light->x), FIXED2FLOAT(y - light->y), FIXED2FLOAT(z - light->z)).Length(); + radius = light->GetRadius() * gl_lights_size; + + if (dist < radius) + { + frac = 1.0f - (dist / radius); + + if (frac > 0) + { + lr = light->GetRed() / 255.0f * gl_lights_intensity; + lg = light->GetGreen() / 255.0f * gl_lights_intensity; + lb = light->GetBlue() / 255.0f * gl_lights_intensity; + if (light->IsSubtractive()) + { + float bright = FVector3(lr, lg, lb).Length(); + FVector3 lightColor(lr, lg, lb); + lr = (bright - lr) * -1; + lg = (bright - lg) * -1; + lb = (bright - lb) * -1; + } + + out[0] += lr * frac; + out[1] += lg * frac; + out[2] += lb * frac; + } + } + } + } + node = node->nextLight; + } + } + gl_RenderState.SetDynLight(out[0], out[1], out[2]); +} + +void gl_SetDynSpriteLight(AActor *thing, particle_t *particle) +{ + if (thing != NULL) + { + gl_SetDynSpriteLight(thing, thing->x, thing->y, thing->z + (thing->height >> 1), thing->subsector); + } + else if (particle != NULL) + { + gl_SetDynSpriteLight(NULL, particle->x, particle->y, particle->z, particle->subsector); + } +} + //========================================================================== // // Gets the light for a sprite - takes dynamic lights into account @@ -294,7 +365,7 @@ int gl_SetSpriteLighting(FRenderStyle style, AActor *thing, int lightlevel, int } else { - gl_SetColor(lightlevel, rellight, cm, alpha, ThingColor, weapon); + gl_SetColor(lightlevel, rellight, cm, alpha, weapon); } } gl_RenderState.AlphaFunc(GL_GEQUAL,alpha*gl_mask_sprite_threshold); diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 207b7bdbf..ba050c1b6 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -351,6 +351,10 @@ inline float Dist2(float x1,float y1,float x2,float y2) // Light + color +void gl_SetDynSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsector_t *subsec); +void gl_SetDynSpriteLight(AActor *actor, particle_t *particle); + + bool gl_GetSpriteLight(AActor *Self, fixed_t x, fixed_t y, fixed_t z, subsector_t * subsec, int desaturation, float * out, line_t *line = NULL, int side = 0); int gl_SetSpriteLight(AActor * thing, int lightlevel, int rellight, FColormap * cm, float alpha, PalEntry ThingColor = 0xffffff, bool weapon=false); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 434659a7c..7615373c5 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -194,8 +194,7 @@ void gl_PrintStartupLog() void gl_SetTextureMode(int type) { - static float white[] = {1.f,1.f,1.f,1.f}; - + gl.needAlphaTexture = false; if (type == TM_MASK) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); @@ -222,7 +221,7 @@ void gl_SetTextureMode(int type) glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); } - else if (type == TM_INVERT) + else if (type == TM_INVERSE) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); @@ -237,22 +236,10 @@ void gl_SetTextureMode(int type) glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); } - else if (type == TM_INVERTOPAQUE) - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - } else // if (type == TM_MODULATE) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + gl.needAlphaTexture = (type == TM_REDTOALPHA); } } diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 66f96be00..13913f621 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -16,16 +16,13 @@ enum RenderFlags enum TexMode { - TMF_MASKBIT = 1, - TMF_OPAQUEBIT = 2, - TMF_INVERTBIT = 4, + TM_MODULATE = 0, // (r, g, b, a) + TM_MASK = 1, // (1, 1, 1, a) + TM_OPAQUE = 2, // (r, g, b, 1) + TM_INVERSE = 3, // (1-r, 1-g, 1-b, a) + TM_REDTOALPHA = 4, // (1, 1, 1, r) - TM_MODULATE = 0, - TM_MASK = TMF_MASKBIT, - TM_OPAQUE = TMF_OPAQUEBIT, - TM_INVERT = TMF_INVERTBIT, - //TM_INVERTMASK = TMF_MASKBIT | TMF_INVERTBIT - TM_INVERTOPAQUE = TMF_INVERTBIT | TMF_OPAQUEBIT, + // 4 cannot be done natively without shaders and requires special textures. }; struct RenderContext @@ -36,6 +33,7 @@ struct RenderContext float glslversion; int max_texturesize; char * vendorstring; + bool needAlphaTexture; int MaxLights() const { diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 8587b5ac3..d4334251b 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -149,7 +149,17 @@ vec4 getTexel(vec2 st) // // Apply texture modes // - if (texturemode == 2) + if (texturemode == 3) + { + texel *=objectcolor; + texel = vec4(1.0-texel.r, 1.0-texel.g, 1.0-texel.b, texel.a); + return texel; + } + else if (texturemode == 4) + { + texel = vec4(1.0, 1.0, 1.0, texel.r); + } + else if (texturemode == 2) { texel.a = 1.0; } diff --git a/wadsrc/static/shaders/glsl/main_colormap.fp b/wadsrc/static/shaders/glsl/main_colormap.fp index d4c079cdd..d78a21f5f 100644 --- a/wadsrc/static/shaders/glsl/main_colormap.fp +++ b/wadsrc/static/shaders/glsl/main_colormap.fp @@ -20,7 +20,17 @@ vec4 getTexel(vec2 st) // // Apply texture modes // - if (texturemode == 2) + if (texturemode == 3) + { + texel *=objectcolor; + texel = vec4(1.0-texel.r, 1.0-texel.g, 1.0-texel.b, texel.a); + return texel; + } + else if (texturemode == 4) + { + texel = vec4(1.0, 1.0, 1.0, texel.r); + } + else if (texturemode == 2) { texel.a = 1.0; } From 887d35d559820d9ffac14f17e09b9c1557a2c09f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 May 2014 19:44:19 +0200 Subject: [PATCH 0082/1509] - remove colormap from texture generation parameters. The one remaining special case, alpha texture on old hardware is now handled by the currently set texture mode at the time of use. - use the cleaned up decal lighting code from the first GLEW branch. --- src/gl/renderer/gl_lightdata.cpp | 1 + src/gl/renderer/gl_renderer.cpp | 2 +- src/gl/renderer/gl_renderstate.h | 2 + src/gl/scene/gl_decal.cpp | 100 +++++------------------ src/gl/scene/gl_skydome.cpp | 2 - src/gl/system/gl_interface.cpp | 2 - src/gl/system/gl_interface.h | 5 ++ src/gl/system/gl_wipe.cpp | 22 ++--- src/gl/textures/gl_bitmap.cpp | 133 ++++--------------------------- src/gl/textures/gl_bitmap.h | 28 ++++--- src/gl/textures/gl_hwtexture.cpp | 49 ++++-------- src/gl/textures/gl_hwtexture.h | 21 +++-- src/gl/textures/gl_material.cpp | 43 +++++----- src/gl/textures/gl_material.h | 16 ++-- 14 files changed, 134 insertions(+), 292 deletions(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 102d1d43e..7d69ababd 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -170,6 +170,7 @@ void gl_GetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblend } else if (style.Flags & STYLEF_InvertSource) { + // The only place where InvertSource is used is for inverted sprites with the infrared powerup. texturemode = TM_INVERSE; } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 5120c00ea..d7d2466f0 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -246,7 +246,7 @@ unsigned char *FGLRenderer::GetTextureBuffer(FTexture *tex, int &w, int &h) FMaterial * gltex = FMaterial::ValidateTexture(tex); if (gltex) { - return gltex->CreateTexBuffer(CM_DEFAULT, 0, w, h); + return gltex->CreateTexBuffer(0, w, h); } return NULL; } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index e037fb637..cd37705af 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -2,6 +2,7 @@ #define __GL_RENDERSTATE_H #include +#include "gl/system/gl_interface.h" #include "c_cvars.h" #include "r_defs.h" @@ -177,6 +178,7 @@ public: void SetTextureMode(int mode) { mTextureMode = mode; + gl.checkTextureMode(mode); } void EnableTexture(bool on) diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 959641076..7c2dda05f 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -74,7 +74,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) int light; int rel; float a; - bool flipx, flipy, loadAlpha; + bool flipx, flipy; DecalVertex dv[4]; FTextureID decalTile; @@ -179,9 +179,6 @@ void GLWall::DrawDecal(DBaseDecal *decal) rel = rellight + getExtraLight(); } - int r = RPART(decal->AlphaColor); - int g = GPART(decal->AlphaColor); - int b = BPART(decal->AlphaColor); FColormap p = Colormap; if (glset.nocoloredspritelighting) @@ -190,58 +187,6 @@ void GLWall::DrawDecal(DBaseDecal *decal) p.LightColor = PalEntry(p.colormap, v, v, v); } - float red, green, blue; - - if (decal->RenderStyle.Flags & STYLEF_RedIsAlpha) - { - loadAlpha = true; - p.colormap=CM_SHADE; - - if (glset.lightmode != 8) - { - gl_GetLightColor(light, rel, &p, &red, &green, &blue); - } - else - { - gl_GetLightColor(lightlevel, rellight, &p, &red, &green, &blue); - } - - if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap && gl_light_sprites) - { - float result[3]; - fixed_t x, y; - decal->GetXY(seg->sidedef, x, y); - gl_GetSpriteLight(NULL, x, y, zpos, sub, Colormap.colormap-CM_DESAT0, result, line, side == line->sidedef[0]? 0:1); - if (glset.lightmode != 8) - { - red = clamp(result[0]+red, 0, 1.0f); - green = clamp(result[1]+green, 0, 1.0f); - blue = clamp(result[2]+blue, 0, 1.0f); - } - else - { - gl_RenderState.SetDynLight(result[0], result[1], result[2]); - } - } - - BYTE R = xs_RoundToInt(r * red); - BYTE G = xs_RoundToInt(g * green); - BYTE B = xs_RoundToInt(b * blue); - - gl_ModifyColor(R,G,B, Colormap.colormap); - - red = R/255.f; - green = G/255.f; - blue = B/255.f; - } - else - { - loadAlpha = false; - - red = 1.f; - green = 1.f; - blue = 1.f; - } a = FIXED2FLOAT(decal->Alpha); @@ -299,8 +244,6 @@ void GLWall::DrawDecal(DBaseDecal *decal) zpos+= FRACUNIT*(flipy? decalheight-decaltopo : decaltopo); - tex->BindPatch(p.colormap, decal->Translation); - dv[1].z=dv[2].z = FIXED2FLOAT(zpos); dv[0].z=dv[3].z = dv[1].z - decalheight; dv[1].v=dv[2].v = tex->GetVT(); @@ -359,32 +302,25 @@ void GLWall::DrawDecal(DBaseDecal *decal) float vb = tex->GetVB(); for(i=0;i<4;i++) dv[i].v=vb-dv[i].v; } - // fog is set once per wall in the calling function and not per decal! - if (loadAlpha) + // calculate dynamic light effect. + if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap && gl_light_sprites) { - glColor4f(red, green, blue, a); - - if (glset.lightmode == 8) - { - if (gl_fixedcolormap) - glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); - else - glVertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(light, rel, false) / 255.0); - } - } - else - { - if (glset.lightmode == 8) - { - gl_SetColor(light, rel, &p, a, !!extralight); // Korshun. - } - else - { - gl_SetColor(light, rel, &p, a); - } + // Note: This should be replaced with proper shader based lighting. + fixed_t x, y; + decal->GetXY(seg->sidedef, x, y); + gl_SetDynSpriteLight(NULL, x, y, zpos, sub); } + // alpha color only has an effect when using an alpha texture. + if (decal->RenderStyle.Flags & STYLEF_RedIsAlpha) + { + gl_RenderState.SetObjectColor(decal->AlphaColor); + } + + gl_SetColor(light, rel, &p, a); + + // for additively drawn decals we must temporarily set the fog color to black. PalEntry fc = gl_RenderState.GetFogColor(); if (decal->RenderStyle.BlendOp == STYLEOP_Add && decal->RenderStyle.DestAlpha == STYLEALPHA_One) { @@ -393,6 +329,8 @@ void GLWall::DrawDecal(DBaseDecal *decal) gl_SetRenderStyle(decal->RenderStyle, false, false); + tex->BindPatch(p.colormap, decal->Translation); + // If srcalpha is one it looks better with a higher alpha threshold if (decal->RenderStyle.SrcAlpha == STYLEALPHA_One) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); @@ -407,6 +345,8 @@ void GLWall::DrawDecal(DBaseDecal *decal) } glEnd(); rendered_decals++; + gl_RenderState.SetTextureMode(TM_MODULATE); + gl_RenderState.SetObjectColor(0xffffffff); gl_RenderState.SetFog(fc,-1); gl_RenderState.SetDynLight(0,0,0); } diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 7dbf5e573..b5f3b1333 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -290,7 +290,6 @@ static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float if (tex && !secondlayer) { PalEntry pe = tex->tex->GetSkyCapColor(false); - if (CM_Index!=CM_DEFAULT) ModifyPalette(&pe, &pe, CM_Index, 1); R=pe.r/255.0f; G=pe.g/255.0f; @@ -312,7 +311,6 @@ static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float if (tex && !secondlayer) { PalEntry pe = tex->tex->GetSkyCapColor(true); - if (CM_Index!=CM_DEFAULT) ModifyPalette(&pe, &pe, CM_Index, 1); R=pe.r/255.0f; G=pe.g/255.0f; B=pe.b/255.0f; diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 7615373c5..2299ddabb 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -194,7 +194,6 @@ void gl_PrintStartupLog() void gl_SetTextureMode(int type) { - gl.needAlphaTexture = false; if (type == TM_MASK) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); @@ -239,7 +238,6 @@ void gl_SetTextureMode(int type) else // if (type == TM_MODULATE) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - gl.needAlphaTexture = (type == TM_REDTOALPHA); } } diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 13913f621..8618c246a 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -44,6 +44,11 @@ struct RenderContext { return glslversion >= 1.3f; } + + void checkTextureMode(int mode) + { + if (!hasGLSL()) needAlphaTexture = (mode == TM_REDTOALPHA); + } }; extern RenderContext gl; diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index c41a1fb24..b7751b7ec 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -145,9 +145,9 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) } wipestartscreen = new FHardwareTexture(Width, Height, false, false, false, true); - wipestartscreen->CreateTexture(NULL, Width, Height, false, 0, CM_DEFAULT); + wipestartscreen->CreateTexture(NULL, Width, Height, false, 0); glFinish(); - wipestartscreen->Bind(0, CM_DEFAULT); + wipestartscreen->Bind(0); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -168,9 +168,9 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) void OpenGLFrameBuffer::WipeEndScreen() { wipeendscreen = new FHardwareTexture(Width, Height, false, false, false, true); - wipeendscreen->CreateTexture(NULL, Width, Height, false, 0, CM_DEFAULT); + wipeendscreen->CreateTexture(NULL, Width, Height, false, 0); glFlush(); - wipeendscreen->Bind(0, CM_DEFAULT); + wipeendscreen->Bind(0); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -280,7 +280,7 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.SetTextureMode(TM_OPAQUE); gl_RenderState.EnableAlphaTest(false); gl_RenderState.Apply(); - fb->wipestartscreen->Bind(0, CM_DEFAULT); + fb->wipestartscreen->Bind(0); glColor4f(1.f, 1.f, 1.f, 1.f); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, vb); @@ -293,7 +293,7 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) glVertex2i(fb->Width, fb->Height); glEnd(); - fb->wipeendscreen->Bind(0, CM_DEFAULT); + fb->wipeendscreen->Bind(0); glColor4f(1.f, 1.f, 1.f, clamp(Clock/32.f, 0.f, 1.f)); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, vb); @@ -347,7 +347,7 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) // Draw the new screen on the bottom. gl_RenderState.SetTextureMode(TM_OPAQUE); gl_RenderState.Apply(); - fb->wipeendscreen->Bind(0, CM_DEFAULT); + fb->wipeendscreen->Bind(0); glColor4f(1.f, 1.f, 1.f, 1.f); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, vb); @@ -363,7 +363,7 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) int i, dy; bool done = false; - fb->wipestartscreen->Bind(0, CM_DEFAULT); + fb->wipestartscreen->Bind(0); // Copy the old screen in vertical strips on top of the new one. while (ticks--) { @@ -492,7 +492,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.SetTextureMode(TM_OPAQUE); gl_RenderState.EnableAlphaTest(false); gl_RenderState.Apply(); - fb->wipestartscreen->Bind(0, CM_DEFAULT); + fb->wipestartscreen->Bind(0); glColor4f(1.f, 1.f, 1.f, 1.f); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, vb); @@ -523,10 +523,10 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) // Burn the new screen on top of it. glColor4f(1.f, 1.f, 1.f, 1.f); - fb->wipeendscreen->Bind(1, CM_DEFAULT); + fb->wipeendscreen->Bind(1); //BurnTexture->Bind(0, CM_DEFAULT); - BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, false, 0, CM_DEFAULT); + BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, false, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); diff --git a/src/gl/textures/gl_bitmap.cpp b/src/gl/textures/gl_bitmap.cpp index d90fd36b7..51e03aa98 100644 --- a/src/gl/textures/gl_bitmap.cpp +++ b/src/gl/textures/gl_bitmap.cpp @@ -50,12 +50,11 @@ // //=========================================================================== template -void iCopyColors(unsigned char * pout, const unsigned char * pin, int cm, int count, int step) +void iCopyColors(unsigned char * pout, const unsigned char * pin, bool alphatex, int count, int step) { int i; - int fac; - if (cm == CM_DEFAULT) + if (!alphatex) { for(i=0;i= CM_FIRSTSPECIALCOLORMAP && cm < CM_FIRSTSPECIALCOLORMAP + int(SpecialColormaps.Size())) - { - for(i=0;i, @@ -147,57 +115,11 @@ void FGLBitmap::CopyPixelDataRGB(int originx, int originy, BYTE *buffer = GetPixels() + 4*originx + Pitch*originy; for (int y=0;y= CM_FIRSTSPECIALCOLORMAP && cm < CM_FIRSTSPECIALCOLORMAP + int(SpecialColormaps.Size())) - { - for(i=0;i> 8; - // This can be done in place so we cannot copy the color directly. - PalEntry pe = SpecialColormaps[cm - CM_FIRSTSPECIALCOLORMAP].GrayscaleToColor[gray]; - pout[i].r = pe.r; - pout[i].g = pe.g; - pout[i].b = pe.b; - pout[i].a = pin[i].a; - } - } - else if (cm<=CM_DESAT31) - { - // Desaturated light settings. - fac=cm-CM_DESAT0; - for(i=0;i>8; - gl_Desaturate(gray, pin[i].r, pin[i].g, pin[i].b, pout[i].r, pout[i].g, pout[i].b, fac); - pout[i].a = pin[i].a; - } - } - else if (pin!=pout) - { - memcpy(pout, pin, count * sizeof(PalEntry)); - } -} - - //=========================================================================== // // Paletted to True Color texture copy function @@ -215,7 +137,7 @@ void FGLBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int BYTE *buffer = GetPixels() + 4*originx + Pitch*originy; // CM_SHADE is an alpha map with 0==transparent and 1==opaque - if (cm == CM_SHADE) + if (alphatex) { for(int i=0;i<256;i++) { @@ -225,37 +147,21 @@ void FGLBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int penew[i]=PalEntry(0,255,255,255); // If the palette contains transparent colors keep them. } } - else + else if (translation > 0) { - // apply any translation. - // The ice and blood color translations are done directly - // because that yields better results. - switch(translation) + PalEntry *ptrans = GLTranslationPalette::GetPalette(translation); + if (ptrans) { - default: - { - PalEntry *ptrans = GLTranslationPalette::GetPalette(translation); - if (ptrans) + for (i = 0; i < 256; i++) { - for(i = 0; i < 256; i++) - { - penew[i] = (ptrans[i]&0xffffff) | (palette[i]&0xff000000); - } - break; + penew[i] = (ptrans[i] & 0xffffff) | (palette[i] & 0xff000000); } } - - case 0: - memcpy(penew, palette, 256*sizeof(PalEntry)); - break; - } - if (cm!=0) - { - // Apply color modifications like invulnerability, desaturation and Boom colormaps - ModifyPalette(penew, penew, cm, 256); - } } - // Now penew contains the actual palette that is to be used for creating the image. + else + { + memcpy(penew, palette, 256*sizeof(PalEntry)); + } // convert the image according to the translated palette. for (y=0;y(buffer[pos+3] + (( 255-buffer[pos+3]) * (255-penew[v].a))/255, 0, 255); - } - */ } } } diff --git a/src/gl/textures/gl_bitmap.h b/src/gl/textures/gl_bitmap.h index db3722a6e..98addb51d 100644 --- a/src/gl/textures/gl_bitmap.h +++ b/src/gl/textures/gl_bitmap.h @@ -5,24 +5,34 @@ #include "gl/textures/gl_material.h" -void ModifyPalette(PalEntry * pout, PalEntry * pin, int cm, int count); - class FGLBitmap : public FBitmap { - int cm; + bool alphatex; int translation; public: - FGLBitmap() { cm = CM_DEFAULT; translation = 0; } + FGLBitmap() + { + alphatex = false; + translation = 0; + } FGLBitmap(BYTE *buffer, int pitch, int width, int height) : FBitmap(buffer, pitch, width, height) - { cm = CM_DEFAULT; translation = 0; } - - void SetTranslationInfo(int _cm, int _trans=-1337) { - if (_cm != -1) cm = _cm; - if (_trans != -1337) translation = _trans; + alphatex = false; + translation = 0; + } + void SetTranslationInfo(int _trans) + { + if (_trans == -1) alphatex = true; + else if (_trans != -1337) translation = _trans; + + } + + void SetAlphaTex() + { + alphatex = true; } virtual void CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int srcwidth, diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 648bac770..7aa8b610c 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -277,9 +277,7 @@ FHardwareTexture::FHardwareTexture(int _width, int _height, bool _mipmap, bool w texwidth=_width; texheight=_height; - int cm_arraysize = CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size(); - glTexID = new unsigned[cm_arraysize]; - memset(glTexID,0,sizeof(unsigned int)*cm_arraysize); + glDefTexID = 0; clampmode=0; glDepthID = 0; forcenofiltering = nofilter; @@ -317,21 +315,8 @@ void FHardwareTexture::Clean(bool all) if (all) { - for (int i=0;i= CM_MAXCOLORMAP) cm=CM_DEFAULT; - if (translation==0) { - return &glTexID[cm]; + return &glDefTexID; } // normally there aren't more than very few different // translations here so this isn't performance critical. for(unsigned int i=0;i= CM_MAXCOLORMAP) cm=CM_DEFAULT; - - unsigned int * pTexID=GetTexID(cm, translation); + if (alphatexture) translation = TRANS_Alpha; + unsigned int * pTexID=GetTexID(translation); if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); - LoadImage(buffer, w, h, *pTexID, wrap? GL_REPEAT:GL_CLAMP, cm==CM_SHADE, texunit); + LoadImage(buffer, w, h, *pTexID, wrap? GL_REPEAT:GL_CLAMP, alphatexture, texunit); if (texunit != 0) glActiveTexture(GL_TEXTURE0); return *pTexID; } diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h index 5b5e55ac5..fc962f3ea 100644 --- a/src/gl/textures/gl_hwtexture.h +++ b/src/gl/textures/gl_hwtexture.h @@ -10,6 +10,17 @@ class FCanvasTexture; class AActor; +// For error catching while changing parameters. +enum EInvalid +{ + Invalid = 0 +}; + +enum ETranslation +{ + TRANS_Alpha = INT_MAX +}; + enum { GLT_CLAMPX=1, @@ -27,7 +38,7 @@ class FHardwareTexture { unsigned int glTexID; int translation; - int cm; + //int cm; }; public: @@ -48,12 +59,12 @@ private: bool forcenofiltering; bool forcenocompression; - unsigned int * glTexID; + unsigned glDefTexID; TArray glTexID_Translated; unsigned int glDepthID; // only used by camera textures void LoadImage(unsigned char * buffer,int w, int h, unsigned int & glTexID,int wrapparam, bool alphatexture, int texunit); - unsigned * GetTexID(int cm, int translation); + unsigned * GetTexID(int translation); int GetDepthBuffer(); void DeleteTexture(unsigned int texid); @@ -68,8 +79,8 @@ public: void BindToFrameBuffer(); - unsigned int Bind(int texunit, int cm, int translation=0); - unsigned int CreateTexture(unsigned char * buffer, int w, int h,bool wrap, int texunit, int cm, int translation=0); + unsigned int Bind(int texunit, int translation=0, bool alphatexture = false); + unsigned int CreateTexture(unsigned char * buffer, int w, int h,bool wrap, int texunit, int translation=0, bool alphatexture = false); void Resize(int _width, int _height) ; void Clean(bool all); diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 5d471fc81..8253c3262 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -109,7 +109,7 @@ FGLTexture::~FGLTexture() // Checks for the presence of a hires texture replacement and loads it // //========================================================================== -unsigned char *FGLTexture::LoadHiresTexture(FTexture *tex, int *width, int *height, int cm) +unsigned char *FGLTexture::LoadHiresTexture(FTexture *tex, int *width, int *height, bool alphatexture) { if (HiresLump==-1) { @@ -131,7 +131,7 @@ unsigned char *FGLTexture::LoadHiresTexture(FTexture *tex, int *width, int *heig memset(buffer, 0, w * (h+1) * 4); FGLBitmap bmp(buffer, w*4, w, h); - bmp.SetTranslationInfo(cm); + if (alphatexture) bmp.SetAlphaTex(); int trans = hirestexture->CopyTrueColorPixels(&bmp, 0, 0); @@ -271,7 +271,7 @@ BYTE *FGLTexture::WarpBuffer(BYTE *buffer, int Width, int Height, int warp) // //=========================================================================== -unsigned char * FGLTexture::CreateTexBuffer(int cm, int translation, int & w, int & h, bool expand, FTexture *hirescheck, int warp) +unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, bool expand, FTexture *hirescheck, int warp, bool alphatexture) { unsigned char * buffer; int W, H; @@ -281,7 +281,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int cm, int translation, int & w, in // by hires textures if (gl_texture_usehires && hirescheck != NULL) { - buffer = LoadHiresTexture (hirescheck, &w, &h, cm); + buffer = LoadHiresTexture (hirescheck, &w, &h, alphatexture); if (buffer) { return buffer; @@ -296,7 +296,8 @@ unsigned char * FGLTexture::CreateTexBuffer(int cm, int translation, int & w, in memset(buffer, 0, W * (H+1) * 4); FGLBitmap bmp(buffer, W*4, W, H); - bmp.SetTranslationInfo(cm, translation); + bmp.SetTranslationInfo(translation); + if (alphatexture) bmp.SetAlphaTex(); if (tex->bComplex) { @@ -337,7 +338,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int cm, int translation, int & w, in else //if (bIsTransparent != 1) { // [BB] Potentially upsample the buffer. - buffer = gl_CreateUpsampledTextureBuffer ( tex, buffer, W, H, w, h, bIsTransparent || cm == CM_SHADE ); + buffer = gl_CreateUpsampledTextureBuffer ( tex, buffer, W, H, w, h, bIsTransparent || alphatexture); } currentwarp = warp; currentwarptime = gl_frameMS; @@ -386,7 +387,7 @@ bool FGLTexture::CreatePatch() // //=========================================================================== -const FHardwareTexture *FGLTexture::Bind(int texunit, int cm, int clampmode, int translation, FTexture *hirescheck, int warp) +const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int translation, FTexture *hirescheck, int warp) { int usebright = false; @@ -400,7 +401,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int cm, int clampmode, int hwtex = gltexture[clampmode] = gltexture[4]; gltexture[4] = NULL; - if (hwtex->Bind(texunit, cm, translation)) + if (hwtex->Bind(texunit, translation)) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (clampmode & GLT_CLAMPX)? GL_CLAMP_TO_EDGE : GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (clampmode & GLT_CLAMPY)? GL_CLAMP_TO_EDGE : GL_REPEAT); @@ -428,7 +429,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int cm, int clampmode, int } // Bind it to the system. - if (!hwtex->Bind(texunit, cm, translation)) + if (!hwtex->Bind(texunit, translation)) { int w=0, h=0; @@ -438,10 +439,10 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int cm, int clampmode, int if (!tex->bHasCanvas) { - buffer = CreateTexBuffer(cm, translation, w, h, false, hirescheck, warp); + buffer = CreateTexBuffer(translation, w, h, false, hirescheck, warp); tex->ProcessData(buffer, w, h, false); } - if (!hwtex->CreateTexture(buffer, w, h, true, texunit, cm, translation)) + if (!hwtex->CreateTexture(buffer, w, h, true, texunit, translation)) { // could not create texture delete[] buffer; @@ -463,7 +464,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int cm, int clampmode, int // Binds a sprite to the renderer // //=========================================================================== -const FHardwareTexture * FGLTexture::BindPatch(int texunit, int cm, int translation, int warp) +const FHardwareTexture * FGLTexture::BindPatch(int texunit, int translation, int warp, bool alphatexture) { bool usebright = false; int transparm = translation; @@ -489,14 +490,14 @@ const FHardwareTexture * FGLTexture::BindPatch(int texunit, int cm, int translat // Bind it to the system. - if (!glpatch->Bind(texunit, cm, translation)) + if (!glpatch->Bind(texunit, translation, alphatexture)) { int w, h; // Create this texture - unsigned char * buffer = CreateTexBuffer(cm, translation, w, h, bExpand, NULL, warp); + unsigned char * buffer = CreateTexBuffer(translation, w, h, bExpand, NULL, warp, alphatexture); tex->ProcessData(buffer, w, h, true); - if (!glpatch->CreateTexture(buffer, w, h, false, texunit, cm, translation)) + if (!glpatch->CreateTexture(buffer, w, h, false, texunit, translation, alphatexture)) { // could not create texture delete[] buffer; @@ -755,7 +756,7 @@ bool FMaterial::TrimBorders(int *rect) int w; int h; - unsigned char *buffer = CreateTexBuffer(CM_DEFAULT, 0, w, h); + unsigned char *buffer = CreateTexBuffer(0, w, h); if (buffer == NULL) { @@ -847,7 +848,7 @@ void FMaterial::Bind(int cm, int clampmode, int translation, int overrideshader) else if (clampmode != -1) clampmode &= 3; else clampmode = 4; - const FHardwareTexture *gltexture = mBaseLayer->Bind(0, cm, clampmode, translation, allowhires? tex:NULL, softwarewarp); + const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, allowhires? tex:NULL, softwarewarp); if (gltexture != NULL && shaderindex > 0 && overrideshader == 0) { for(unsigned i=0;igl_info.SystemTexture->Bind(i+1, CM_DEFAULT, clampmode, 0, NULL, false); + layer->gl_info.SystemTexture->Bind(i+1, clampmode, 0, NULL, false); maxbound = i+1; } } @@ -890,11 +891,11 @@ void FMaterial::BindPatch(int cm, int translation, int overrideshader) int softwarewarp = gl_RenderState.SetupShader(tex->bHasCanvas, shaderindex, cm, tex->gl_info.shaderspeed); - const FHardwareTexture *glpatch = mBaseLayer->BindPatch(0, cm, translation, softwarewarp); + const FHardwareTexture *glpatch = mBaseLayer->BindPatch(0, translation, softwarewarp, gl.needAlphaTexture); // The only multitexture effect usable on sprites is the brightmap. if (glpatch != NULL && shaderindex == 3) { - mTextureLayers[0].texture->gl_info.SystemTexture->BindPatch(1, CM_DEFAULT, 0, 0); + mTextureLayers[0].texture->gl_info.SystemTexture->BindPatch(1, 0, 0, false); maxbound = 1; } // unbind everything from the last texture that's still active @@ -1012,7 +1013,7 @@ void FMaterial::BindToFrameBuffer() if (mBaseLayer->gltexture == NULL) { // must create the hardware texture first - mBaseLayer->Bind(0, CM_DEFAULT, 0, 0, NULL, 0); + mBaseLayer->Bind(0, 0, 0, NULL, 0); FHardwareTexture::Unbind(0); } mBaseLayer->gltexture[0]->BindToFrameBuffer(); diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 3754e9337..16f1ed451 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -48,7 +48,7 @@ enum ETexUse }; -class FGLTexture //: protected WorldTextureInfo, protected PatchTextureInfo +class FGLTexture { friend class FMaterial; public: @@ -68,21 +68,21 @@ private: bool bExpand; float AlphaThreshold; - unsigned char * LoadHiresTexture(FTexture *hirescheck, int *width, int *height, int cm); + unsigned char * LoadHiresTexture(FTexture *hirescheck, int *width, int *height, bool alphatexture); BYTE *WarpBuffer(BYTE *buffer, int Width, int Height, int warp); FHardwareTexture *CreateTexture(int clampmode); //bool CreateTexture(); bool CreatePatch(); - const FHardwareTexture *Bind(int texunit, int cm, int clamp, int translation, FTexture *hirescheck, int warp); - const FHardwareTexture *BindPatch(int texunit, int cm, int translation, int warp); + const FHardwareTexture *Bind(int texunit, int clamp, int translation, FTexture *hirescheck, int warp); + const FHardwareTexture *BindPatch(int texunit, int translation, int warp, bool alphatexture); public: FGLTexture(FTexture * tx, bool expandpatches); ~FGLTexture(); - unsigned char * CreateTexBuffer(int cm, int translation, int & w, int & h, bool expand, FTexture *hirescheck, int warp); + unsigned char * CreateTexBuffer(int translation, int & w, int & h, bool expand, FTexture *hirescheck, int warp, bool alphatexture = false); void Clean(bool all); int Dump(int i); @@ -138,9 +138,9 @@ public: void Bind(int cm, int clamp = 0, int translation = 0, int overrideshader = 0); void BindPatch(int cm, int translation = 0, int overrideshader = 0); - unsigned char * CreateTexBuffer(int cm, int translation, int & w, int & h, bool expand = false, bool allowhires=true) const + unsigned char * CreateTexBuffer(int translation, int & w, int & h, bool expand = false, bool allowhires=true) const { - return mBaseLayer->CreateTexBuffer(cm, translation, w, h, expand, allowhires? tex:NULL, 0); + return mBaseLayer->CreateTexBuffer(translation, w, h, expand, allowhires? tex:NULL, 0); } void Clean(bool f) @@ -233,7 +233,7 @@ public: if (!mBaseLayer->tex->bHasCanvas) { int w, h; - unsigned char *buffer = CreateTexBuffer(CM_DEFAULT, 0, w, h); + unsigned char *buffer = CreateTexBuffer(0, w, h); delete [] buffer; } else From 978ace241c43562fb805530a9f8fc271d4b78a21 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 May 2014 21:47:54 +0200 Subject: [PATCH 0083/1509] - removed all code that mixes together the different lighting methods. Now everything goes through the 3 different light parameters in the render state. - removed cm parameter from many functions. --- src/gl/dynlights/gl_dynlight1.cpp | 2 +- src/gl/models/gl_models.cpp | 15 +- src/gl/models/gl_models.h | 20 +-- src/gl/models/gl_models_md2.cpp | 8 +- src/gl/models/gl_models_md3.cpp | 8 +- src/gl/models/gl_voxels.cpp | 8 +- src/gl/renderer/gl_colormap.h | 2 +- src/gl/renderer/gl_renderer.cpp | 10 +- src/gl/renderer/gl_renderer.h | 2 +- src/gl/renderer/gl_renderstate.cpp | 45 ++---- src/gl/renderer/gl_renderstate.h | 2 +- src/gl/scene/gl_decal.cpp | 2 +- src/gl/scene/gl_drawinfo.cpp | 2 +- src/gl/scene/gl_flats.cpp | 6 +- src/gl/scene/gl_portal.cpp | 28 ++-- src/gl/scene/gl_renderhacks.cpp | 1 - src/gl/scene/gl_scene.cpp | 9 +- src/gl/scene/gl_skydome.cpp | 98 +++--------- src/gl/scene/gl_sprite.cpp | 30 +--- src/gl/scene/gl_spritelight.cpp | 245 ----------------------------- src/gl/scene/gl_wall.h | 17 -- src/gl/scene/gl_walls.cpp | 2 +- src/gl/scene/gl_walls_draw.cpp | 10 +- src/gl/scene/gl_weapon.cpp | 37 +++-- src/gl/system/gl_cvars.h | 8 - src/gl/system/gl_interface.cpp | 8 +- src/gl/system/gl_wipe.cpp | 11 +- src/gl/textures/gl_hwtexture.h | 4 + src/gl/textures/gl_material.cpp | 14 +- src/gl/textures/gl_material.h | 5 +- src/gl/textures/gl_texture.cpp | 2 +- 31 files changed, 154 insertions(+), 507 deletions(-) diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index 90d65559c..c1bb9dbbf 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -241,7 +241,7 @@ bool gl_SetupLightTexture() if (GLRenderer->gllight == NULL) return false; FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight); - pat->BindPatch(CM_DEFAULT, 0); + pat->BindPatch(0); return true; } diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 4b8a8e44b..1efcefd08 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -626,7 +626,6 @@ void gl_RenderFrameModels( const FSpriteModelFrame *smf, const FState *curState, const int curTics, const PClass *ti, - int cm, Matrix3x4 *normaltransform, int translation) { @@ -684,14 +683,14 @@ void gl_RenderFrameModels( const FSpriteModelFrame *smf, if (mdl!=NULL) { if ( smfNext && smf->modelframes[i] != smfNext->modelframes[i] ) - mdl->RenderFrameInterpolated(smf->skins[i], smf->modelframes[i], smfNext->modelframes[i], inter, cm, translation); + mdl->RenderFrameInterpolated(smf->skins[i], smf->modelframes[i], smfNext->modelframes[i], inter, translation); else - mdl->RenderFrame(smf->skins[i], smf->modelframes[i], cm, translation); + mdl->RenderFrame(smf->skins[i], smf->modelframes[i], translation); } } } -void gl_RenderModel(GLSprite * spr, int cm) +void gl_RenderModel(GLSprite * spr) { FSpriteModelFrame * smf = spr->modelframe; @@ -808,11 +807,11 @@ void gl_RenderModel(GLSprite * spr, int cm) if (pitch != 0) NormalTransform.Rotate(0,0,1,-pitch); if (angle != 0) NormalTransform.Rotate(0,1,0, angle); - gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), cm, &ModelToWorld, &NormalTransform, translation ); + gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), &ModelToWorld, &NormalTransform, translation ); } #endif - gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), cm, NULL, translation ); + gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), NULL, translation ); if (!gl.hasGLSL()) { @@ -840,7 +839,7 @@ void gl_RenderModel(GLSprite * spr, int cm) // //=========================================================================== -void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy, int cm) +void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy) { AActor * playermo=players[consoleplayer].camera; FSpriteModelFrame *smf = gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->state->sprite, psp->state->GetFrame(), false); @@ -883,7 +882,7 @@ void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy, int cm) glRotatef(smf->pitchoffset, 0, 0, 1); glRotatef(-smf->rolloffset, 1, 0, 0); - gl_RenderFrameModels( smf, psp->state, psp->tics, playermo->player->ReadyWeapon->GetClass(), cm, NULL, 0 ); + gl_RenderFrameModels( smf, psp->state, psp->tics, playermo->player->ReadyWeapon->GetClass(), NULL, 0 ); glMatrixMode(GL_MODELVIEW); glPopMatrix(); diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 5d474dd8d..ebfb8b8c5 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -27,9 +27,9 @@ public: virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0; virtual int FindFrame(const char * name) = 0; - virtual void RenderFrame(FTexture * skin, int frame, int cm, int translation=0) = 0; + virtual void RenderFrame(FTexture * skin, int frame, int translation=0) = 0; // [BB] Added RenderFrameInterpolated - virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int cm, int translation=0) = 0; + virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0; virtual void MakeGLData() {} virtual void CleanGLData() {} @@ -138,8 +138,8 @@ public: virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); virtual int FindFrame(const char * name); - virtual void RenderFrame(FTexture * skin, int frame, int cm, int translation=0); - virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int cm, int translation=0); + virtual void RenderFrame(FTexture * skin, int frame, int translation=0); + virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int translation=0); }; @@ -228,8 +228,8 @@ public: virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); virtual int FindFrame(const char * name); - virtual void RenderFrame(FTexture * skin, int frame, int cm, int translation=0); - virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int cm, int translation=0); + virtual void RenderFrame(FTexture * skin, int frame, int translation=0); + virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int translation=0); }; class FVoxelVertexBuffer; @@ -291,8 +291,8 @@ public: void MakeGLData(); void CleanGLData(); virtual int FindFrame(const char * name); - virtual void RenderFrame(FTexture * skin, int frame, int cm, int translation=0); - virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int cm, int translation=0); + virtual void RenderFrame(FTexture * skin, int frame, int translation=0); + virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int translation=0); FTexture *GetPaletteTexture() const { return mPalette; } }; @@ -344,9 +344,9 @@ class GLSprite; void gl_InitModels(); FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped); -void gl_RenderModel(GLSprite * spr, int cm); +void gl_RenderModel(GLSprite * spr); // [BB] HUD weapon model rendering functions. -void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy, int cm); +void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy); bool gl_IsHUDModelForPlayerAvailable (player_t * player); void gl_CleanModelData(); diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index 244ec064d..12c8bebe7 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -293,7 +293,7 @@ void FDMDModel::RenderGLCommands(void *glCommands, unsigned int numVertices,FMod } -void FDMDModel::RenderFrame(FTexture * skin, int frameno, int cm, int translation) +void FDMDModel::RenderFrame(FTexture * skin, int frameno, int translation) { int activeLod; @@ -311,7 +311,7 @@ void FDMDModel::RenderFrame(FTexture * skin, int frameno, int cm, int translatio FMaterial * tex = FMaterial::ValidateTexture(skin); - tex->Bind(cm, 0, translation); + tex->Bind(0, translation); int numVerts = info.numVertices; @@ -337,7 +337,7 @@ void FDMDModel::RenderFrame(FTexture * skin, int frameno, int cm, int translatio RenderGLCommands(lods[activeLod].glCommands, numVerts, frame->vertices/*, modelColors, NULL*/); } -void FDMDModel::RenderFrameInterpolated(FTexture * skin, int frameno, int frameno2, double inter, int cm, int translation) +void FDMDModel::RenderFrameInterpolated(FTexture * skin, int frameno, int frameno2, double inter, int translation) { int activeLod = 0; @@ -355,7 +355,7 @@ void FDMDModel::RenderFrameInterpolated(FTexture * skin, int frameno, int framen FMaterial * tex = FMaterial::ValidateTexture(skin); - tex->Bind(cm, 0, translation); + tex->Bind(0, translation); int numVerts = info.numVertices; diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index 12509b769..bd1b4e972 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -232,7 +232,7 @@ void FMD3Model::RenderTriangles(MD3Surface * surf, MD3Vertex * vert) glEnd(); } -void FMD3Model::RenderFrame(FTexture * skin, int frameno, int cm, int translation) +void FMD3Model::RenderFrame(FTexture * skin, int frameno, int translation) { if (frameno>=numFrames) return; @@ -258,12 +258,12 @@ void FMD3Model::RenderFrame(FTexture * skin, int frameno, int cm, int translatio FMaterial * tex = FMaterial::ValidateTexture(surfaceSkin); - tex->Bind(cm, 0, translation); + tex->Bind(0, translation); RenderTriangles(surf, surf->vertices + frameno * surf->numVertices); } } -void FMD3Model::RenderFrameInterpolated(FTexture * skin, int frameno, int frameno2, double inter, int cm, int translation) +void FMD3Model::RenderFrameInterpolated(FTexture * skin, int frameno, int frameno2, double inter, int translation) { if (frameno>=numFrames || frameno2>=numFrames) return; @@ -283,7 +283,7 @@ void FMD3Model::RenderFrameInterpolated(FTexture * skin, int frameno, int framen FMaterial * tex = FMaterial::ValidateTexture(surfaceSkin); - tex->Bind(cm, 0, translation); + tex->Bind(0, translation); MD3Vertex* verticesInterpolated = new MD3Vertex[surfaces[i].numVertices]; MD3Vertex* vertices1 = surf->vertices + frameno * surf->numVertices; diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 14ed5985c..99b565fc5 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -502,10 +502,10 @@ int FVoxelModel::FindFrame(const char * name) // //=========================================================================== -void FVoxelModel::RenderFrame(FTexture * skin, int frame, int cm, int translation) +void FVoxelModel::RenderFrame(FTexture * skin, int frame, int translation) { FMaterial * tex = FMaterial::ValidateTexture(skin); - tex->Bind(cm, 0, translation); + tex->Bind(0, translation); if (mVBO == NULL) MakeGLData(); if (mVBO != NULL) @@ -535,8 +535,8 @@ void FVoxelModel::RenderFrame(FTexture * skin, int frame, int cm, int translatio // //=========================================================================== -void FVoxelModel::RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int cm, int translation) +void FVoxelModel::RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int translation) { - RenderFrame(skin, frame, cm, translation); + RenderFrame(skin, frame, translation); } diff --git a/src/gl/renderer/gl_colormap.h b/src/gl/renderer/gl_colormap.h index 7c9921108..59ccf9961 100644 --- a/src/gl/renderer/gl_colormap.h +++ b/src/gl/renderer/gl_colormap.h @@ -24,7 +24,7 @@ enum EColorManipulation // These are not to be passed to the texture manager CM_LITE = 0x20000000, // special values to handle these items without excessive hacking CM_TORCH= 0x20000010, // These are not real color manipulations - CM_FOGLAYER= 0x20000020, // Sprite shaped fog layer - this is only used as a parameter to FMaterial::BindPatch + CM_FOGLAYER= 0x20000020, // Sprite shaped fog layer }; #define CM_MAXCOLORMAP int(CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size()) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index d7d2466f0..3e88ebceb 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -333,13 +333,13 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) GLTranslationPalette * pal = static_cast(parms.remap->GetNative()); if (pal) translation = -pal->GetIndex(); } - gltex->BindPatch(CM_DEFAULT, translation); + gltex->BindPatch(translation); } else { // This is an alpha texture gl_RenderState.SetTextureMode(TM_REDTOALPHA); - gltex->BindPatch(CM_SHADE, 0); + gltex->BindPatch(0); } u1 = gltex->GetUL(); @@ -349,7 +349,7 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) } else { - gltex->Bind(CM_DEFAULT, 0, 0); + gltex->Bind(0, 0); u2=1.f; v2=-1.f; u1 = v1 = 0.f; @@ -519,7 +519,7 @@ void FGLRenderer::FlatFill (int left, int top, int right, int bottom, FTexture * if (!gltexture) return; - gltexture->Bind(CM_DEFAULT, 0, 0); + gltexture->Bind(0, 0); // scaling is not used here. if (!local_origin) @@ -613,7 +613,7 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint PalEntry pe = gl_CalcLightColor(lightlevel, cm.LightColor, cm.blendfactor, true); glColor3ub(pe.r, pe.g, pe.b); - gltexture->Bind(cm.colormap); + gltexture->Bind(); int i; float rot = float(rotation * M_PI / float(1u << 31)); diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 8db9cb195..4a4e31c10 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -91,7 +91,7 @@ public: void DrawScene(bool toscreen = false); void DrawBlend(sector_t * viewsector); - void DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, int cm_index, bool hudModelStep, int OverrideShader); + void DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, bool hudModelStep, int OverrideShader); void DrawPlayerSprites(sector_t * viewsector, bool hudModelStep); void DrawTargeterSprites(); diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 96b782771..d6cf1804e 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -82,6 +82,7 @@ void FRenderState::Reset() glBlendEquation = -1; m2D = true; mVertexBuffer = mCurrentVertexBuffer = NULL; + mColormapState = CM_DEFAULT; } @@ -91,33 +92,18 @@ void FRenderState::Reset() // //========================================================================== -int FRenderState::SetupShader(bool cameratexture, int &shaderindex, int &cm, float warptime) +int FRenderState::SetupShader(bool cameratexture, int &shaderindex, float warptime) { int softwarewarp = 0; if (gl.hasGLSL()) { - if (shaderindex == 3) - { - // Brightmap should not be used. - if (!mBrightmapEnabled || cm >= CM_FIRSTSPECIALCOLORMAP) - { - shaderindex = 0; - } - } - - mColormapState = cm; - if (cm > CM_DEFAULT && cm < CM_MAXCOLORMAP && mTextureMode != TM_MASK) - { - cm = CM_DEFAULT; - } mEffectState = shaderindex; mWarpTime = warptime; } else { - if (cm != CM_SHADE) cm = CM_DEFAULT; softwarewarp = shaderindex > 0 && shaderindex < 3? shaderindex : 0; shaderindex = 0; } @@ -134,30 +120,21 @@ int FRenderState::SetupShader(bool cameratexture, int &shaderindex, int &cm, flo bool FRenderState::ApplyShader() { - bool useshaders = false; - FShader *activeShader = NULL; - if (mSpecialEffect > 0 && gl.hasGLSL()) + if (gl.hasGLSL()) { - activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect); - } - else if (gl.hasGLSL()) - { - useshaders = (!m2D || mEffectState != 0 || mColormapState); // all 3D rendering and 2D with texture effects. - if (useshaders) + FShader *activeShader; + if (mSpecialEffect > 0) { - FShaderContainer *shd = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4); - - if (shd != NULL) - { - activeShader = shd->Bind(mColormapState, mGlowEnabled, mWarpTime, mLightEnabled); - } + activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect); } - } + FShaderContainer *shd = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4); + if (shd != NULL) + { + activeShader = shd->Bind(mColormapState, mGlowEnabled, mWarpTime, mLightEnabled); + } - if (activeShader) - { int fogset = 0; //glColor4fv(mColor.vec); if (mFogEnabled) diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index cd37705af..d01cc53cf 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -143,7 +143,7 @@ public: void Reset(); - int SetupShader(bool cameratexture, int &shaderindex, int &cm, float warptime); + int SetupShader(bool cameratexture, int &shaderindex, float warptime); void Apply(bool forcenoshader = false); void SetVertexBuffer(FVertexBuffer *vb) diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 7c2dda05f..ed54e9e32 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -329,7 +329,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) gl_SetRenderStyle(decal->RenderStyle, false, false); - tex->BindPatch(p.colormap, decal->Translation); + tex->BindPatch(decal->Translation); // If srcalpha is one it looks better with a higher alpha threshold diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 62e604aca..52177cbe2 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -1068,7 +1068,7 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo int rel = getExtraLight(); gl_SetColor(lightlevel, rel, &Colormap, 1.0f); gl_SetFog(lightlevel, rel, &Colormap, false); - gltexture->Bind(Colormap.colormap); + gltexture->Bind(); float fviewx = FIXED2FLOAT(viewx); float fviewy = FIXED2FLOAT(viewy); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 4a4c0d715..179c087d1 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -407,7 +407,7 @@ void GLFlat::Draw(int pass) // fall through case GLPASS_TEXTURE: { - gltexture->Bind(Colormap.colormap); + gltexture->Bind(); bool pushed = gl_SetPlaneTextureRotation(&plane, gltexture); DrawSubsectors(pass, false); if (pushed) @@ -471,7 +471,7 @@ void GLFlat::Draw(int pass) else { if (foggy) gl_RenderState.EnableBrightmap(false); - gltexture->Bind(Colormap.colormap); + gltexture->Bind(); bool pushed = gl_SetPlaneTextureRotation(&plane, gltexture); DrawSubsectors(pass, true); gl_RenderState.EnableBrightmap(true); @@ -515,7 +515,7 @@ inline void GLFlat::PutFlat(bool fog) { { GLDL_LIGHT, GLDL_LIGHTFOG }, { GLDL_LIGHTMASKED, GLDL_LIGHTFOGMASKED } } }; - bool light = gl_forcemultipass; + bool light = false; bool masked = gltexture->isMasked() && ((renderflags&SSRF_RENDER3DPLANES) || stack); if (!gl_fixedcolormap) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index ee0d494a4..020a37b4e 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -50,6 +50,7 @@ #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderstate.h" #include "gl/dynlights/gl_glow.h" #include "gl/data/gl_data.h" @@ -187,7 +188,7 @@ bool GLPortal::Start(bool usestencil, bool doquery) glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); // increment stencil of valid pixels glColorMask(0,0,0,0); // don't write to the graphics buffer gl_RenderState.EnableTexture(false); - glColor3f(1,1,1); + gl_RenderState.ResetColor(); glDepthFunc(GL_LESS); gl_RenderState.Apply(); @@ -345,9 +346,8 @@ void GLPortal::End(bool usestencil) in_area=savedviewarea; GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); - glColor4f(1,1,1,1); glColorMask(0,0,0,0); // no graphics - glColor3f(1,1,1); + gl_RenderState.ResetColor(); gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); @@ -404,7 +404,7 @@ void GLPortal::End(bool usestencil) // This draws a valid z-buffer into the stencil's contents to ensure it // doesn't get overwritten by the level's geometry. - glColor4f(1,1,1,1); + gl_RenderState.ResetColor(); glDepthFunc(GL_LEQUAL); glDepthRange(0,1); glColorMask(0,0,0,0); // no graphics @@ -604,7 +604,7 @@ void GLSkyboxPortal::DrawContents() PlaneMirrorMode=0; - glDisable(GL_DEPTH_CLAMP_NV); + glDisable(GL_DEPTH_CLAMP); viewx = origin->PrevX + FixedMul(r_TicFrac, origin->x - origin->PrevX); viewy = origin->PrevY + FixedMul(r_TicFrac, origin->y - origin->PrevY); @@ -634,7 +634,7 @@ void GLSkyboxPortal::DrawContents() GLRenderer->DrawScene(); origin->flags&=~MF_JUSTHIT; inskybox=false; - glEnable(GL_DEPTH_CLAMP_NV); + glEnable(GL_DEPTH_CLAMP); skyboxrecursion--; PlaneMirrorMode=old_pm; @@ -844,12 +844,12 @@ void GLMirrorPortal::DrawContents() // any mirror--use floats to avoid integer overflow. // Use doubles to avoid losing precision which is very important here. - double dx = FIXED2FLOAT(v2->x - v1->x); - double dy = FIXED2FLOAT(v2->y - v1->y); - double x1 = FIXED2FLOAT(v1->x); - double y1 = FIXED2FLOAT(v1->y); - double x = FIXED2FLOAT(startx); - double y = FIXED2FLOAT(starty); + double dx = FIXED2DBL(v2->x - v1->x); + double dy = FIXED2DBL(v2->y - v1->y); + double x1 = FIXED2DBL(v1->x); + double y1 = FIXED2DBL(v1->y); + double x = FIXED2DBL(startx); + double y = FIXED2DBL(starty); // the above two cases catch len == 0 double r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy); @@ -962,7 +962,7 @@ void GLHorizonPortal::DrawContents() if (gltexture && gltexture->tex->isFullbright()) { // glowing textures are always drawn full bright without color - gl_SetColor(255, 0, NULL, 1.f); + gl_SetColor(255, 0, &origin->colormap, 1.f); gl_SetFog(255, 0, &origin->colormap, false); } else @@ -973,7 +973,7 @@ void GLHorizonPortal::DrawContents() } - gltexture->Bind(origin->colormap.colormap); + gltexture->Bind(); gl_RenderState.EnableAlphaTest(false); gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index a6452a01f..20d6ac7bc 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -48,7 +48,6 @@ #include "gl/renderer/gl_renderer.h" #include "gl/data/gl_data.h" #include "gl/dynlights/gl_glow.h" -#include "gl/dynlights/gl_lightbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" #include "gl/utility/gl_clock.h" diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index d3758c0a4..0c4439bc6 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -85,7 +85,6 @@ CVAR(Bool, gl_texture, true, 0) CVAR(Bool, gl_no_skyclear, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_sprite_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -CVAR(Bool, gl_forcemultipass, false, 0) EXTERN_CVAR (Int, screenblocks) EXTERN_CVAR (Bool, cl_capfps) @@ -845,6 +844,7 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) { DrawPlayerSprites (viewsector, false); } + gl_RenderState.SetFixedColormap(CM_DEFAULT); DrawTargeterSprites(); DrawBlend(viewsector); @@ -918,6 +918,7 @@ void FGLRenderer::SetFixedColormap (player_t *player) } } } + gl_RenderState.SetFixedColormap(gl_fixedcolormap); } //----------------------------------------------------------------------------- @@ -1060,6 +1061,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei sector_t *viewsector = RenderViewpoint(players[consoleplayer].camera, &bounds, FieldOfView * 360.0f / FINEANGLES, 1.6f, 1.6f, true, false); glDisable(GL_STENCIL_TEST); + gl_RenderState.SetFixedColormap(CM_DEFAULT); screen->Begin2D(false); DrawBlend(viewsector); glFlush(); @@ -1235,6 +1237,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in int height = gltex->TextureHeight(GLUSE_TEXTURE); gl_fixedcolormap=CM_DEFAULT; + gl_RenderState.SetFixedColormap(CM_DEFAULT); bool usefb; @@ -1279,7 +1282,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in if (!usefb) { glFlush(); - gltex->Bind(CM_DEFAULT, 0, 0); + gltex->Bind(0, 0); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, bounds.width, bounds.height); } else @@ -1287,7 +1290,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in GLRenderer->EndOffscreen(); } - gltex->Bind(CM_DEFAULT, 0, 0); + gltex->Bind(0, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); tex->SetUpdated(); } diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index b5f3b1333..f56076ef6 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -78,12 +78,10 @@ static int texw; static float yAdd; static bool foglayer; static bool secondlayer; -static float R,G,B; static bool skymirror; #define SKYHEMI_UPPER 0x1 #define SKYHEMI_LOWER 0x2 -#define SKYHEMI_JUST_CAP 0x4 // Just draw the top or bottom cap. //----------------------------------------------------------------------------- @@ -111,7 +109,8 @@ static void SkyVertex(int r, int c) if (!foglayer) { - gl_SetColor(255, 0, NULL, r==0? 0.0f : 1.0f); + // this cannot use the renderstate because it's inside a primitive. + glColor4f(1.f, 1.f, 1.f, r==0? 0.0f : 1.0f); // And the texture coordinates. if(!yflip) // Flipped Y is for the lower hemisphere. @@ -165,30 +164,24 @@ static void RenderSkyHemisphere(int hemi, bool mirror) // two rows because the first one is always faded. rows = 4; - if (hemi & SKYHEMI_JUST_CAP) - { - return; - } - - // Draw the cap as one solid color polygon if (!foglayer) { columns = 4 * (gl_sky_detail > 0 ? gl_sky_detail : 1); foglayer=true; gl_RenderState.EnableTexture(false); - gl_RenderState.Apply(true); + gl_RenderState.Apply(); if (!secondlayer) { - glColor3f(R, G ,B); glBegin(GL_TRIANGLE_FAN); for(c = 0; c < columns; c++) { SkyVertex(1, c); } glEnd(); + gl_RenderState.SetObjectColor(0xffffffff); // unset the cap's color } gl_RenderState.EnableTexture(true); @@ -197,7 +190,7 @@ static void RenderSkyHemisphere(int hemi, bool mirror) } else { - gl_RenderState.Apply(true); + gl_RenderState.Apply(); columns=4; // no need to do more! glBegin(GL_TRIANGLE_FAN); for(c = 0; c < columns; c++) @@ -246,7 +239,7 @@ static void RenderSkyHemisphere(int hemi, bool mirror) //----------------------------------------------------------------------------- CVAR(Float, skyoffset, 0, 0) // for testing -static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float y_offset, bool mirror, int CM_Index) +static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float y_offset, bool mirror) { int texh = 0; bool texscale = false; @@ -257,7 +250,7 @@ static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float if (tex) { glPushMatrix(); - tex->Bind(CM_Index, 0, 0); + tex->Bind(0, 0); texw = tex->TextureWidth(GLUSE_TEXTURE); texh = tex->TextureHeight(GLUSE_TEXTURE); @@ -290,20 +283,7 @@ static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float if (tex && !secondlayer) { PalEntry pe = tex->tex->GetSkyCapColor(false); - - R=pe.r/255.0f; - G=pe.g/255.0f; - B=pe.b/255.0f; - - if (gl_fixedcolormap) - { - float rr, gg, bb; - - gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb); - R*=rr; - G*=gg; - B*=bb; - } + gl_RenderState.SetObjectColor(pe); } RenderSkyHemisphere(SKYHEMI_UPPER, mirror); @@ -311,19 +291,7 @@ static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float if (tex && !secondlayer) { PalEntry pe = tex->tex->GetSkyCapColor(true); - R=pe.r/255.0f; - G=pe.g/255.0f; - B=pe.b/255.0f; - - if (gl_fixedcolormap != CM_DEFAULT) - { - float rr,gg,bb; - - gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb); - R*=rr; - G*=gg; - B*=bb; - } + gl_RenderState.SetObjectColor(pe); } RenderSkyHemisphere(SKYHEMI_LOWER, mirror); @@ -344,7 +312,7 @@ static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float // //----------------------------------------------------------------------------- -static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int CM_Index, bool sky2) +static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool sky2) { FSkyBox * sb = static_cast(gltex->tex); int faces; @@ -355,15 +323,13 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int C else glRotatef(-180.0f+x_offset, glset.skyrotatevector2.X, glset.skyrotatevector2.Z, glset.skyrotatevector2.Y); - glColor3f(R, G ,B); - if (sb->faces[5]) { faces=4; // north tex = FMaterial::ValidateTexture(sb->faces[0]); - tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); + tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0, 0); @@ -378,7 +344,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int C // east tex = FMaterial::ValidateTexture(sb->faces[1]); - tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); + tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0, 0); @@ -393,7 +359,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int C // south tex = FMaterial::ValidateTexture(sb->faces[2]); - tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); + tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0, 0); @@ -408,7 +374,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int C // west tex = FMaterial::ValidateTexture(sb->faces[3]); - tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); + tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0, 0); @@ -426,7 +392,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int C faces=1; // all 4 sides tex = FMaterial::ValidateTexture(sb->faces[0]); - tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); + tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); glBegin(GL_TRIANGLE_FAN); @@ -479,7 +445,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int C // top tex = FMaterial::ValidateTexture(sb->faces[faces]); - tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); + tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); glBegin(GL_TRIANGLE_FAN); if (!sb->fliptop) @@ -509,7 +475,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int C // bottom tex = FMaterial::ValidateTexture(sb->faces[faces+1]); - tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0); + tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0, 0); @@ -533,7 +499,6 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int C void GLSkyPortal::DrawContents() { bool drawBoth = false; - int CM_Index; PalEntry FadeColor(0,0,0,0); // We have no use for Doom lighting special handling here, so disable it for this function. @@ -541,16 +506,12 @@ void GLSkyPortal::DrawContents() if (glset.lightmode == 8) glset.lightmode = 2; - if (gl_fixedcolormap) + if (!gl_fixedcolormap) { - CM_Index=gl_fixedcolormapfadecolor; + FadeColor = origin->fadecolor; } + gl_RenderState.SetColor(0xffffffff); gl_RenderState.EnableFog(false); gl_RenderState.EnableAlphaTest(false); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -561,18 +522,7 @@ void GLSkyPortal::DrawContents() if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox) { - if (gl_fixedcolormap != CM_DEFAULT) - { - float rr,gg,bb; - - gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb); - R=rr; - G=gg; - B=bb; - } - else R=G=B=1.f; - - RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], CM_Index, origin->sky2); + RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2); gl_RenderState.EnableAlphaTest(true); } else @@ -582,7 +532,7 @@ void GLSkyPortal::DrawContents() if (origin->texture[0]) { gl_RenderState.SetTextureMode(TM_OPAQUE); - RenderDome(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->y_offset, origin->mirrored, CM_Index); + RenderDome(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->y_offset, origin->mirrored); gl_RenderState.SetTextureMode(TM_MODULATE); } @@ -592,7 +542,7 @@ void GLSkyPortal::DrawContents() if (origin->doublesky && origin->texture[1]) { secondlayer=true; - RenderDome(FNullTextureID(), origin->texture[1], origin->x_offset[1], origin->y_offset, false, CM_Index); + RenderDome(FNullTextureID(), origin->texture[1], origin->x_offset[1], origin->y_offset, false); secondlayer=false; } @@ -601,7 +551,7 @@ void GLSkyPortal::DrawContents() gl_RenderState.EnableTexture(false); foglayer=true; gl_RenderState.SetColorAlpha(FadeColor, skyfog / 255.0f); - RenderDome(FNullTextureID(), NULL, 0, 0, false, CM_DEFAULT); + RenderDome(FNullTextureID(), NULL, 0, 0, false); gl_RenderState.EnableTexture(true); foglayer=false; } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index d64f62b71..9c8bba2f0 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -179,23 +179,11 @@ void GLSprite::Draw(int pass) } if (RenderStyle.BlendOp!=STYLEOP_Shadow) { - if (actor) + if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap) { - lightlevel = gl_SetSpriteLighting(RenderStyle, actor, lightlevel, rel, &Colormap, 0xffffffff, trans, - fullbright || gl_fixedcolormap >= CM_FIRSTSPECIALCOLORMAP, false); + gl_SetDynSpriteLight(gl_light_sprites ? actor : NULL, gl_light_particles ? particle : NULL); } - else if (particle) - { - if (gl_light_particles) - { - lightlevel = gl_SetSpriteLight(particle, lightlevel, rel, &Colormap, trans, 0xffffffff); - } - else - { - gl_SetColor(lightlevel, rel, &Colormap, trans); - } - } - else return; + gl_SetColor(lightlevel, rel, &Colormap, trans); } gl_RenderState.SetObjectColor(ThingColor); @@ -207,11 +195,6 @@ void GLSprite::Draw(int pass) additivefog = true; } - if (RenderStyle.Flags & STYLEF_InvertOverlay) - { - Colormap.FadeColor = Colormap.FadeColor.InverseColor(); - additivefog=false; - } if (RenderStyle.BlendOp == STYLEOP_RevSub || RenderStyle.BlendOp == STYLEOP_Sub) { if (!modelframe) @@ -243,7 +226,7 @@ void GLSprite::Draw(int pass) gl_RenderState.SetFog(0, 0); } - if (gltexture) gltexture->BindPatch(Colormap.colormap, translation, OverrideShader); + if (gltexture) gltexture->BindPatch(translation, OverrideShader); else if (!modelframe) gl_RenderState.EnableTexture(false); if (!modelframe) @@ -309,7 +292,7 @@ void GLSprite::Draw(int pass) { // If we get here we know that we have colored fog and no fixed colormap. gl_SetFog(foglevel, rel, &Colormap, additivefog); - gl_RenderState.SetFixedColormap(CM_FOGLAYER); + //gl_RenderState.SetFixedColormap(CM_FOGLAYER); fixme: does not work yet. gl_RenderState.BlendEquation(GL_FUNC_ADD); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.Apply(); @@ -335,7 +318,7 @@ void GLSprite::Draw(int pass) } else { - gl_RenderModel(this, Colormap.colormap); + gl_RenderModel(this); } if (pass==GLPASS_TRANSLUCENT) @@ -361,6 +344,7 @@ void GLSprite::Draw(int pass) Colormap.FadeColor = backupfade; gl_RenderState.EnableTexture(true); + gl_RenderState.SetObjectColor(0xffffffff); gl_RenderState.SetDynLight(0,0,0); } diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index 66a2b6c7f..e4e2e855a 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -127,248 +127,3 @@ void gl_SetDynSpriteLight(AActor *thing, particle_t *particle) gl_SetDynSpriteLight(NULL, particle->x, particle->y, particle->z, particle->subsector); } } - -//========================================================================== -// -// Gets the light for a sprite - takes dynamic lights into account -// -//========================================================================== - -bool gl_GetSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsector_t * subsec, int desaturation, float * out, line_t *line, int side) -{ - ADynamicLight *light; - float frac, lr, lg, lb; - float radius; - bool changed = false; - - out[0]=out[1]=out[2]=0; - - for(int j=0;j<2;j++) - { - // Go through both light lists - FLightNode * node = subsec->lighthead[j]; - while (node) - { - light=node->lightsource; - if (!light->owned || light->target == NULL || light->target->IsVisibleToPlayer()) - { - if (!(light->flags2&MF2_DORMANT) && - (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) - { - float dist = FVector3(FIXED2FLOAT(x - light->x), FIXED2FLOAT(y - light->y), FIXED2FLOAT(z - light->z)).Length(); - radius = light->GetRadius() * gl_lights_size; - - if (dist < radius) - { - frac = 1.0f - (dist / radius); - - if (frac > 0) - { - if (line != NULL) - { - if (P_PointOnLineSide(light->x, light->y, line) != side) - { - node = node->nextLight; - continue; - } - } - lr = light->GetRed() / 255.0f * gl_lights_intensity; - lg = light->GetGreen() / 255.0f * gl_lights_intensity; - lb = light->GetBlue() / 255.0f * gl_lights_intensity; - if (light->IsSubtractive()) - { - float bright = FVector3(lr, lg, lb).Length(); - FVector3 lightColor(lr, lg, lb); - lr = (bright - lr) * -1; - lg = (bright - lg) * -1; - lb = (bright - lb) * -1; - } - - out[0] += lr * frac; - out[1] += lg * frac; - out[2] += lb * frac; - changed = true; - } - } - } - } - node = node->nextLight; - } - } - - // Desaturate dynamic lighting if applicable - if (desaturation>0 && desaturation<=CM_DESAT31) - { - float gray=(out[0]*77 + out[1]*143 + out[2]*37)/257; - - out[0]= (out[0]*(31-desaturation)+ gray*desaturation)/31; - out[1]= (out[1]*(31-desaturation)+ gray*desaturation)/31; - out[2]= (out[2]*(31-desaturation)+ gray*desaturation)/31; - } - return changed; -} - - - -//========================================================================== -// -// Sets the light for a sprite - takes dynamic lights into account -// -//========================================================================== - -static int gl_SetSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsector_t * subsec, - int lightlevel, int rellight, FColormap * cm, float alpha, - PalEntry ThingColor, bool weapon) -{ - float r,g,b; - float result[4]; // Korshun. - - gl_GetLightColor(lightlevel, rellight, cm, &r, &g, &b, weapon); - bool res = gl_GetSpriteLight(self, x, y, z, subsec, cm? cm->colormap : 0, result); - if (!res || glset.lightmode == 8) - { - r *= ThingColor.r/255.f; - g *= ThingColor.g/255.f; - b *= ThingColor.b/255.f; - glColor4f(r, g, b, alpha); - if (glset.lightmode == 8) - { - glVertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(lightlevel, rellight, weapon) / 255.0f); // Korshun. - gl_RenderState.SetDynLight(result[0], result[1], result[2]); - } - return lightlevel; - } - else - { - // Note: Due to subtractive lights the values can easily become negative so we have to clamp both - // at the low and top end of the range! - r = clamp(result[0]+r, 0, 1.0f); - g = clamp(result[1]+g, 0, 1.0f); - b = clamp(result[2]+b, 0, 1.0f); - - float dlightlevel = r*77 + g*143 + b*35; - - r *= ThingColor.r/255.f; - g *= ThingColor.g/255.f; - b *= ThingColor.b/255.f; - - glColor4f(r, g, b, alpha); - - if (dlightlevel == 0) return 0; - - if (glset.lightmode&2 && dlightlevel<192.f) - { - return xs_CRoundToInt(192.f - (192.f - dlightlevel) / 1.95f); - } - else - { - return xs_CRoundToInt(dlightlevel); - } - } -} - -int gl_SetSpriteLight(AActor * thing, int lightlevel, int rellight, FColormap * cm, - float alpha, PalEntry ThingColor, bool weapon) -{ - subsector_t * subsec = thing->subsector; - return gl_SetSpriteLight(thing, thing->x, thing->y, thing->z+(thing->height>>1), subsec, - lightlevel, rellight, cm, alpha, ThingColor, weapon); -} - -int gl_SetSpriteLight(particle_t * thing, int lightlevel, int rellight, FColormap *cm, float alpha, PalEntry ThingColor) -{ - return gl_SetSpriteLight(NULL, thing->x, thing->y, thing->z, thing->subsector, lightlevel, rellight, - cm, alpha, ThingColor, false); -} - -//========================================================================== -// -// Modifies the color values depending on the render style -// -//========================================================================== - -void gl_GetSpriteLighting(FRenderStyle style, AActor *thing, FColormap *cm, PalEntry &ThingColor) -{ - if (style.Flags & STYLEF_RedIsAlpha) - { - cm->colormap = CM_SHADE; - } - if (style.Flags & STYLEF_ColorIsFixed) - { - if (style.Flags & STYLEF_InvertSource) - { - ThingColor = PalEntry(thing->fillcolor).InverseColor(); - } - else - { - ThingColor = thing->fillcolor; - } - } - - // This doesn't work like in the software renderer. - if (style.Flags & STYLEF_InvertSource) - { - int gray = (cm->LightColor.r*77 + cm->LightColor.r*143 + cm->LightColor.r*36)>>8; - cm->LightColor.r = cm->LightColor.g = cm->LightColor.b = gray; - } -} - - -//========================================================================== -// -// Sets render state to draw the given render style -// -//========================================================================== - -int gl_SetSpriteLighting(FRenderStyle style, AActor *thing, int lightlevel, int rellight, FColormap *cm, - PalEntry ThingColor, float alpha, bool fullbright, bool weapon) -{ - FColormap internal_cm; - - if (style.Flags & STYLEF_RedIsAlpha) - { - cm->colormap = CM_SHADE; - } - if (style.Flags & STYLEF_ColorIsFixed) - { - if (style.Flags & STYLEF_InvertSource) - { - ThingColor = PalEntry(thing->fillcolor).InverseColor(); - } - else - { - ThingColor = thing->fillcolor; - } - gl_ModifyColor(ThingColor.r, ThingColor.g, ThingColor.b, cm->colormap); - } - - // This doesn't work like in the software renderer. - if (style.Flags & STYLEF_InvertSource) - { - internal_cm = *cm; - cm = &internal_cm; - - int gray = (internal_cm.LightColor.r*77 + internal_cm.LightColor.r*143 + internal_cm.LightColor.r*36)>>8; - cm->LightColor.r = cm->LightColor.g = cm->LightColor.b = gray; - } - - if (style.BlendOp == STYLEOP_Shadow) - { - glColor4f(0.2f * ThingColor.r / 255.f, 0.2f * ThingColor.g / 255.f, - 0.2f * ThingColor.b / 255.f, (alpha = 0.33f)); - } - else - { - if (gl_light_sprites && gl_lights && GLRenderer->mLightCount && !fullbright) - { - lightlevel = gl_SetSpriteLight(thing, lightlevel, rellight, cm, alpha, ThingColor, weapon); - } - else - { - gl_SetColor(lightlevel, rellight, cm, alpha, weapon); - } - } - gl_RenderState.AlphaFunc(GL_GEQUAL,alpha*gl_mask_sprite_threshold); - return lightlevel; -} - diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index ba050c1b6..a9d0c1087 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -354,21 +354,4 @@ inline float Dist2(float x1,float y1,float x2,float y2) void gl_SetDynSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsector_t *subsec); void gl_SetDynSpriteLight(AActor *actor, particle_t *particle); - -bool gl_GetSpriteLight(AActor *Self, fixed_t x, fixed_t y, fixed_t z, subsector_t * subsec, int desaturation, float * out, line_t *line = NULL, int side = 0); -int gl_SetSpriteLight(AActor * thing, int lightlevel, int rellight, FColormap * cm, float alpha, PalEntry ThingColor = 0xffffff, bool weapon=false); - -void gl_GetSpriteLight(AActor * thing, int lightlevel, int rellight, FColormap * cm, - float *red, float *green, float *blue, - PalEntry ThingColor, bool weapon); - -int gl_SetSpriteLighting(FRenderStyle style, AActor *thing, int lightlevel, int rellight, FColormap *cm, - PalEntry ThingColor, float alpha, bool fullbright, bool weapon); - -int gl_SetSpriteLight(particle_t * thing, int lightlevel, int rellight, FColormap *cm, float alpha, PalEntry ThingColor = 0xffffff); -void gl_GetLightForThing(AActor * thing, float upper, float lower, float & r, float & g, float & b); - - - - #endif diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 2d14e0949..e8c23ad81 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -152,7 +152,7 @@ void GLWall::PutWall(bool translucent) }; bool masked; - bool light = gl_forcemultipass; + bool light = false; if (!gl_fixedcolormap) { diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index b4af1e28d..38adfeeab 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -412,7 +412,7 @@ void GLWall::RenderMirrorSurface() gl_SetFog(lightlevel, getExtraLight(), &Colormap, true); FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrortexture); - pat->BindPatch(Colormap.colormap, 0); + pat->BindPatch(0); flags &= ~GLWF_GLOW; //flags |= GLWF_NOSHADER; @@ -465,7 +465,7 @@ void GLWall::RenderTranslucentWall() { if (flags&GLWF_FOGGY) gl_RenderState.EnableBrightmap(false); gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); - gltexture->Bind(Colormap.colormap, flags, 0); + gltexture->Bind(flags, 0); extra = getExtraLight(); } else @@ -532,7 +532,7 @@ void GLWall::Draw(int pass) else gl_SetFog(255, 0, NULL, false); gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); - gltexture->Bind(Colormap.colormap, flags, 0); + gltexture->Bind(flags, 0); RenderWall(3, NULL); gl_RenderState.EnableGlow(false); gl_RenderState.EnableLight(false); @@ -552,7 +552,7 @@ void GLWall::Draw(int pass) if (pass != GLPASS_BASE) { - gltexture->Bind(Colormap.colormap, flags, 0); + gltexture->Bind(flags, 0); } RenderWall(pass == GLPASS_BASE? 2:3, NULL); gl_RenderState.EnableGlow(false); @@ -560,7 +560,7 @@ void GLWall::Draw(int pass) break; case GLPASS_TEXTURE: // modulated texture - gltexture->Bind(Colormap.colormap, flags, 0); + gltexture->Bind(flags, 0); RenderWall(1, NULL); break; diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index c9f8434c4..d582b7165 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -69,7 +69,7 @@ EXTERN_CVAR(Int, gl_fuzztype) // //========================================================================== -void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, int cm_index, bool hudModelStep, int OverrideShader) +void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, bool hudModelStep, int OverrideShader) { float fU1,fV1; float fU2,fV2; @@ -83,7 +83,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed // [BB] In the HUD model step we just render the model and break out. if ( hudModelStep ) { - gl_RenderHUDModel( psp, sx, sy, cm_index ); + gl_RenderHUDModel( psp, sx, sy); return; } @@ -95,7 +95,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed FMaterial * tex = FMaterial::ValidateTexture(lump, false); if (!tex) return; - tex->BindPatch(cm_index, 0, OverrideShader); + tex->BindPatch(0, OverrideShader); int vw = viewwidth; int vh = viewheight; @@ -192,17 +192,13 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) (players[consoleplayer].cheats & CF_CHASECAM)) return; - /* - if(!player || playermo->renderflags&RF_INVISIBLE || !r_drawplayersprites || - mViewActor!=playermo || playermo->RenderStyle.BlendOp == STYLEOP_None) return; - */ - P_BobWeapon (player, &player->psprites[ps_weapon], &ofsx, &ofsy); // check for fullbright if (player->fixedcolormap==NOFIXEDCOLORMAP) { - for (i=0, psp=player->psprites; i<=ps_flash; i++,psp++) + for (i = 0, psp = player->psprites; i <= ps_flash; i++, psp++) + { if (psp->state != NULL) { bool disablefullbright = false; @@ -215,7 +211,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) } statebright[i] = !!psp->state->GetFullbright() && !disablefullbright; } - + } } if (gl_fixedcolormap) @@ -300,8 +296,8 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) vis.colormap < SpecialColormaps[SpecialColormaps.Size()].Colormap && cm.colormap == CM_DEFAULT) { - ptrdiff_t specialmap = (vis.colormap - SpecialColormaps[0].Colormap) / sizeof(FSpecialColormap); - cm.colormap = int(CM_FIRSTSPECIALCOLORMAP + specialmap); + // this only happens for Strife's inverted weapon sprite + vis.RenderStyle.Flags |= STYLEF_InvertSource; } } @@ -380,10 +376,17 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) cmc.LightColor.b = (3*cmc.LightColor.b + 0xff)/4; } } - // set the lighting parameters (only calls glColor and glAlphaFunc) - gl_SetSpriteLighting(vis.RenderStyle, playermo, statebright[i]? 255 : lightlevel, - 0, &cmc, 0xffffff, trans, statebright[i], true); - DrawPSprite (player,psp,psp->sx+ofsx, psp->sy+ofsy, cm.colormap, hudModelStep, OverrideShader); + // set the lighting parameters + if (vis.RenderStyle.BlendOp == STYLEOP_Shadow) + { + gl_RenderState.SetColor(0.2f, 0.2f, 0.2f, 0.33f);// 0x55333333, cmc.desaturation); + } + else + { + gl_SetDynSpriteLight(playermo, NULL); + gl_SetColor(statebright[i] ? 255 : lightlevel, 0, &cmc, trans, true); + } + DrawPSprite (player,psp,psp->sx+ofsx, psp->sy+ofsy, hudModelStep, OverrideShader); } } gl_RenderState.SetObjectColor(0xffffffff); @@ -417,5 +420,5 @@ void FGLRenderer::DrawTargeterSprites() // The Targeter's sprites are always drawn normally. for (i=ps_targetcenter, psp = &player->psprites[ps_targetcenter]; istate) DrawPSprite (player,psp,psp->sx, psp->sy, CM_DEFAULT, false, 0); + if (psp->state) DrawPSprite (player,psp,psp->sx, psp->sy, false, 0); } \ No newline at end of file diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index f748f9b52..79321f5b5 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -10,12 +10,6 @@ #pragma warning(disable:4244) #endif -EXTERN_CVAR(Bool, gl_warp_shader) -EXTERN_CVAR(Bool, gl_fog_shader) -EXTERN_CVAR(Bool, gl_colormap_shader) -EXTERN_CVAR(Bool, gl_brightmap_shader) -EXTERN_CVAR(Bool, gl_glow_shader) - EXTERN_CVAR(Bool,gl_enhanced_nightvision) EXTERN_CVAR(Int, screenblocks); EXTERN_CVAR(Bool, gl_texture) @@ -27,8 +21,6 @@ EXTERN_CVAR(Bool, gl_usefb) EXTERN_CVAR(Int, gl_weaponlight) -EXTERN_CVAR(Bool, gl_forcemultipass) - EXTERN_CVAR (Bool, gl_lights); EXTERN_CVAR (Bool, gl_attachedlights); EXTERN_CVAR (Bool, gl_lights_checkside); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 2299ddabb..5f35c4ec2 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -179,10 +179,10 @@ void gl_PrintStartupLog() Printf ("Max. vertex uniforms: %d\n", v); glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); Printf ("Max. varying: %d\n", v); - glGetIntegerv(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, &v); - Printf ("Max. combined uniforms: %d\n", v); - glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &v); - Printf ("Max. combined uniform blocks: %d\n", v); + glGetIntegerv(GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS, &v); + Printf("Max. combined shader storage blocks: %d\n", v); + glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &v); + Printf("Max. vertex shader storage blocks: %d\n", v); } diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index b7751b7ec..28cfa0e6d 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -279,9 +279,9 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.SetTextureMode(TM_OPAQUE); gl_RenderState.EnableAlphaTest(false); + gl_RenderState.ResetColor(); gl_RenderState.Apply(); fb->wipestartscreen->Bind(0); - glColor4f(1.f, 1.f, 1.f, 1.f); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, vb); glVertex2i(0, 0); @@ -294,7 +294,8 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) glEnd(); fb->wipeendscreen->Bind(0); - glColor4f(1.f, 1.f, 1.f, clamp(Clock/32.f, 0.f, 1.f)); + gl_RenderState.SetColorAlpha(0xffffff, clamp(Clock/32.f, 0.f, 1.f)); + gl_RenderState.Apply(); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, vb); glVertex2i(0, 0); @@ -346,9 +347,9 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) // Draw the new screen on the bottom. gl_RenderState.SetTextureMode(TM_OPAQUE); + gl_RenderState.ResetColor(); gl_RenderState.Apply(); fb->wipeendscreen->Bind(0); - glColor4f(1.f, 1.f, 1.f, 1.f); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, vb); glVertex2i(0, 0); @@ -398,7 +399,6 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) float th = (float)FHardwareTexture::GetTexDimension(fb->Height); rect.bottom = fb->Height - rect.bottom; rect.top = fb->Height - rect.top; - glColor4f(1.f, 1.f, 1.f, 1.f); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(rect.left / tw, rect.top / th); glVertex2i(rect.left, rect.bottom); @@ -491,9 +491,9 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) // Put the initial screen back to the buffer. gl_RenderState.SetTextureMode(TM_OPAQUE); gl_RenderState.EnableAlphaTest(false); + gl_RenderState.ResetColor(); gl_RenderState.Apply(); fb->wipestartscreen->Bind(0); - glColor4f(1.f, 1.f, 1.f, 1.f); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, vb); glVertex2i(0, 0); @@ -522,7 +522,6 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) glActiveTexture(GL_TEXTURE0); // Burn the new screen on top of it. - glColor4f(1.f, 1.f, 1.f, 1.f); fb->wipeendscreen->Bind(1); //BurnTexture->Bind(0, CM_DEFAULT); diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h index fc962f3ea..4e13bc841 100644 --- a/src/gl/textures/gl_hwtexture.h +++ b/src/gl/textures/gl_hwtexture.h @@ -2,6 +2,10 @@ #ifndef __GLTEXTURE_H #define __GLTEXTURE_H +#ifdef LoadImage +#undef LoadImage +#endif + #define SHADED_TEXTURE -1 #define DIRECT_PALETTE -2 diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 8253c3262..9faf996be 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -835,14 +835,14 @@ outl: // //=========================================================================== -void FMaterial::Bind(int cm, int clampmode, int translation, int overrideshader) +void FMaterial::Bind(int clampmode, int translation, int overrideshader) { int usebright = false; int shaderindex = overrideshader > 0? overrideshader : mShaderIndex; int maxbound = 0; bool allowhires = tex->xScale == FRACUNIT && tex->yScale == FRACUNIT; - int softwarewarp = gl_RenderState.SetupShader(tex->bHasCanvas, shaderindex, cm, tex->gl_info.shaderspeed); + int softwarewarp = gl_RenderState.SetupShader(tex->bHasCanvas, shaderindex, tex->gl_info.shaderspeed); if (tex->bHasCanvas || tex->bWarped) clampmode = 0; else if (clampmode != -1) clampmode &= 3; @@ -883,13 +883,13 @@ void FMaterial::Bind(int cm, int clampmode, int translation, int overrideshader) // //=========================================================================== -void FMaterial::BindPatch(int cm, int translation, int overrideshader) +void FMaterial::BindPatch(int translation, int overrideshader) { int usebright = false; int shaderindex = overrideshader > 0? overrideshader : mShaderIndex; int maxbound = 0; - int softwarewarp = gl_RenderState.SetupShader(tex->bHasCanvas, shaderindex, cm, tex->gl_info.shaderspeed); + int softwarewarp = gl_RenderState.SetupShader(tex->bHasCanvas, shaderindex, tex->gl_info.shaderspeed); const FHardwareTexture *glpatch = mBaseLayer->BindPatch(0, translation, softwarewarp, gl.needAlphaTexture); // The only multitexture effect usable on sprites is the brightmap. @@ -916,7 +916,7 @@ void FMaterial::Precache() { if (tex->UseType==FTexture::TEX_Sprite) { - BindPatch(CM_DEFAULT, 0); + BindPatch(0); } else { @@ -925,10 +925,10 @@ void FMaterial::Precache() { if (mBaseLayer->gltexture[i] != 0) { - Bind (CM_DEFAULT, i, 0); + Bind (i, 0); cached++; } - if (cached == 0) Bind(CM_DEFAULT, -1, 0); + if (cached == 0) Bind(-1, 0); } } } diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 16f1ed451..f01e39cd3 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -120,7 +120,6 @@ class FMaterial float SpriteU[2], SpriteV[2]; float spriteright, spritebottom; - void SetupShader(int shaderindex, int &cm); FGLTexture * ValidateSysTexture(FTexture * tex, bool expand); bool TrimBorders(int *rect); @@ -135,8 +134,8 @@ public: return !!mBaseLayer->tex->bMasked; } - void Bind(int cm, int clamp = 0, int translation = 0, int overrideshader = 0); - void BindPatch(int cm, int translation = 0, int overrideshader = 0); + void Bind(int clamp = 0, int translation = 0, int overrideshader = 0); + void BindPatch(int translation = 0, int overrideshader = 0); unsigned char * CreateTexBuffer(int translation, int & w, int & h, bool expand = false, bool allowhires=true) const { diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 68c33f125..70f5f05be 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -210,7 +210,7 @@ PalEntry averageColor(const DWORD *data, int size, fixed_t maxout_factor) g = Scale(g, maxout_factor, maxv); b = Scale(b, maxout_factor, maxv); } - return PalEntry(r,g,b); + return PalEntry(255,r,g,b); } From c47c7421a36f4594f1637367607ba09666c44b35 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 May 2014 22:57:42 +0200 Subject: [PATCH 0084/1509] - route all glColor calls through render state. - add sector links to dynamic lights. --- src/gl/data/gl_data.h | 4 ++- src/gl/dynlights/a_dynlight.cpp | 46 ++++++++++++++++++++----- src/gl/dynlights/gl_dynlight.h | 4 ++- src/gl/dynlights/gl_dynlight1.cpp | 40 +++++++++++++++++++--- src/gl/renderer/gl_colormap.h | 24 ++++++------- src/gl/renderer/gl_lightdata.cpp | 50 +-------------------------- src/gl/renderer/gl_lightdata.h | 11 ------ src/gl/renderer/gl_renderer.cpp | 57 +++++++++++++------------------ src/gl/scene/gl_decal.cpp | 3 +- src/gl/scene/gl_drawinfo.cpp | 6 ++-- src/gl/scene/gl_flats.cpp | 7 ++-- src/gl/scene/gl_scene.cpp | 14 ++++---- src/gl/scene/gl_skydome.cpp | 6 ++-- src/gl/scene/gl_sprite.cpp | 30 +++++----------- src/gl/scene/gl_walls.cpp | 12 +++---- src/gl/scene/gl_walls_draw.cpp | 10 +++--- src/gl/scene/gl_weapon.cpp | 8 ++--- src/gl/shaders/gl_shader.cpp | 2 ++ src/r_defs.h | 1 + 19 files changed, 160 insertions(+), 175 deletions(-) diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index 6a71dd1ac..6a1589cde 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -33,7 +33,7 @@ EXTERN_CVAR(Int, gl_weaponlight); inline int getExtraLight() { - return extralight * gl_weaponlight; // ((glset.lightmode == 8)? 16:8); + return extralight * gl_weaponlight; } void gl_RecalcVertexHeights(vertex_t * v); @@ -58,4 +58,6 @@ extern TArray currentmapsection; void gl_InitPortals(); void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, FPortal *portal); +extern long gl_frameMS; + #endif diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index bc12288cd..6ac50a785 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -526,6 +526,11 @@ void ADynamicLight::CollectWithinRadius(subsector_t *subSec, float radius) subSec->validcount = ::validcount; touching_subsectors = AddLightNode(&subSec->lighthead[additive], subSec, this, touching_subsectors); + if (subSec->sector->validcount != ::validcount) + { + touching_sector = AddLightNode(&subSec->sector->lighthead[additive], subSec->sector, this, touching_sector); + subSec->sector->validcount = ::validcount; + } for (unsigned int i = 0; i < subSec->numlines; i++) { @@ -537,8 +542,7 @@ void ADynamicLight::CollectWithinRadius(subsector_t *subSec, float radius) if (DMulScale32 (y-seg->v1->y, seg->v2->x-seg->v1->x, seg->v1->x-x, seg->v2->y-seg->v1->y) <=0) { seg->linedef->validcount=validcount; - touching_sides = AddLightNode(&seg->sidedef->lighthead[additive], - seg->sidedef, this, touching_sides); + touching_sides = AddLightNode(&seg->sidedef->lighthead[additive], seg->sidedef, this, touching_sides); } } @@ -581,15 +585,21 @@ void ADynamicLight::LinkLight() node->lightsource = NULL; node = node->nextTarget; } + node = touching_sector; + while (node) + { + node->lightsource = NULL; + node = node->nextTarget; + } if (radius>0) { // passing in radius*radius allows us to do a distance check without any calls to sqrtf - ::validcount++; subsector_t * subSec = R_PointInSubsector(x, y); if (subSec) { float fradius = FIXED2FLOAT(radius); + ::validcount++; CollectWithinRadius(subSec, fradius*fradius); } } @@ -618,6 +628,17 @@ void ADynamicLight::LinkLight() else node = node->nextTarget; } + + node = touching_sector; + while (node) + { + if (node->lightsource == NULL) + { + node = DeleteLightNode(node); + } + else + node = node->nextTarget; + } } @@ -670,8 +691,8 @@ size_t AActor::PropagateMark() CCMD(listlights) { - int walls, sectors; - int allwalls=0, allsectors=0; + int walls, sectors, subsecs; + int allwalls=0, allsectors=0, allsubsecs = 0; int i=0; ADynamicLight * dl; TThinkerIterator it; @@ -680,6 +701,7 @@ CCMD(listlights) { walls=0; sectors=0; + subsecs = 0; Printf("%s at (%f, %f, %f), color = 0x%02x%02x%02x, radius = %f ", dl->target? dl->target->GetClass()->TypeName.GetChars() : dl->GetClass()->TypeName.GetChars(), FIXED2FLOAT(dl->x), FIXED2FLOAT(dl->y), FIXED2FLOAT(dl->z), dl->args[LIGHT_RED], @@ -706,17 +728,25 @@ CCMD(listlights) node=dl->touching_subsectors; + while (node) + { + allsubsecs++; + subsecs++; + node = node->nextTarget; + } + + node = dl->touching_sector; + while (node) { allsectors++; sectors++; node = node->nextTarget; } - - Printf("- %d walls, %d subsectors\n", walls, sectors); + Printf("- %d walls, %d subsectors, %d sectors\n", walls, subsecs, sectors); } - Printf("%i dynamic lights, %d walls, %d subsectors\n\n\n", i, allwalls, allsectors); + Printf("%i dynamic lights, %d walls, %d subsectors, %d sectors\n\n\n", i, allwalls, allsubsecs, allsectors); } CCMD(listsublights) diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index dbf89324b..37cbc4f93 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -95,6 +95,7 @@ public: FState *targetState; FLightNode * touching_sides; FLightNode * touching_subsectors; + FLightNode * touching_sector; private: float DistToSeg(seg_t *seg); @@ -183,8 +184,9 @@ struct FDynLightData bool gl_GetLight(Plane & p, ADynamicLight * light, bool checkside, bool forceadditive, FDynLightData &data); -bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, float & scale, bool checkside=true, bool forceadditive=true); +bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, float & scale, int desaturation, bool checkside=true, bool forceadditive=true); bool gl_SetupLightTexture(); +void gl_UploadLights(FDynLightData &data); #endif diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index c1bb9dbbf..f13f24ab6 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -159,15 +159,13 @@ bool gl_GetLight(Plane & p, ADynamicLight * light, bool checkside, bool forceadd } - - //========================================================================== // // Sets up the parameters to render one dynamic light onto one plane // //========================================================================== bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, - float & scale, bool checkside, bool forceadditive) + float & scale, int desaturation, bool checkside, bool forceadditive) { Vector fn, pos; @@ -225,11 +223,45 @@ bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & u { gl_RenderState.BlendEquation(GL_FUNC_ADD); } - glColor3f(r,g,b); + gl_RenderState.SetColor(r, g, b, 1.f, desaturation); return true; } +//========================================================================== +// +// +// +//========================================================================== + +#if 0 +void gl_UploadLights(FDynLightData &data) +{ + ParameterBufferElement *pptr; + int size0 = data.arrays[0].Size()/4; + int size1 = data.arrays[1].Size()/4; + int size2 = data.arrays[2].Size()/4; + + if (size0 + size1 + size2 > 0) + { + int sizetotal = size0 + size1 + size2 + 1; + int index = GLRenderer->mParmBuffer->Reserve(sizetotal, &pptr); + + float parmcnt[] = { index + 1, index + 1 + size0, index + 1 + size0 + size1, index + 1 + size0 + size1 + size2 }; + + memcpy(&pptr[0], parmcnt, 4 * sizeof(float)); + memcpy(&pptr[1], &data.arrays[0][0], 4 * size0*sizeof(float)); + memcpy(&pptr[1 + size0], &data.arrays[1][0], 4 * size1*sizeof(float)); + memcpy(&pptr[1 + size0 + size1], &data.arrays[2][0], 4 * size2*sizeof(float)); + gl_RenderState.SetDynLightIndex(index); + } + else + { + gl_RenderState.SetDynLightIndex(-1); + } +} +#endif + //========================================================================== // // diff --git a/src/gl/renderer/gl_colormap.h b/src/gl/renderer/gl_colormap.h index 59ccf9961..7d2bdb7ee 100644 --- a/src/gl/renderer/gl_colormap.h +++ b/src/gl/renderer/gl_colormap.h @@ -13,9 +13,6 @@ enum EColorManipulation CM_INVALID=-1, CM_DEFAULT=0, // untranslated - CM_DESAT0=CM_DEFAULT, - CM_DESAT1, // minimum desaturation - CM_DESAT31=CM_DESAT1+30, // maximum desaturation = grayscale CM_FIRSTSPECIALCOLORMAP, // first special fixed colormap // special internal values for texture creation @@ -34,14 +31,14 @@ struct FColormap { PalEntry LightColor; // a is saturation (0 full, 31=b/w, other=custom colormap) PalEntry FadeColor; // a is fadedensity>>1 - int colormap; + int desaturation; int blendfactor; void Clear() { LightColor=0xffffff; FadeColor=0; - colormap = CM_DEFAULT; + desaturation = 0; blendfactor=0; } @@ -49,19 +46,14 @@ struct FColormap { LightColor.r=LightColor.g=LightColor.b=0xff; blendfactor=0; + desaturation = 0; } - void GetFixedColormap() - { - Clear(); - colormap = gl_fixedcolormap >= (int)CM_LITE? (int)CM_DEFAULT : gl_fixedcolormap; - } - FColormap & operator=(FDynamicColormap * from) { LightColor = from->Color; - colormap = from->Desaturate>>3; + desaturation = from->Desaturate; FadeColor = from->Fade; blendfactor = from->Color.a; return * this; @@ -70,9 +62,15 @@ struct FColormap void CopyLightColor(FDynamicColormap * from) { LightColor = from->Color; - colormap = from->Desaturate>>3; + desaturation = from->Desaturate; blendfactor = from->Color.a; } + + void Decolorize() // this for 'nocoloredspritelighting' and not the same as desaturation. The normal formula results in a value that's too dark. + { + int v = (LightColor.r + LightColor.g + LightColor.b) / 3; + LightColor.r = LightColor.g = LightColor.b = (255 + v + v) / 3; + } }; diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 7d69ababd..c5bf4c1c8 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -72,22 +72,6 @@ CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE); -//========================================================================== -// -// -// -//========================================================================== - -bool gl_BrightmapsActive() -{ - return gl.hasGLSL(); -} - -bool gl_GlowActive() -{ - return gl.hasGLSL(); -} - //========================================================================== // // Sets up the fog tables @@ -337,7 +321,7 @@ void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, boo gl_GetLightColor(light, rellight, cm, &r, &g, &b, weapon); - gl_RenderState.SetColor(r, g, b, alpha); + gl_RenderState.SetColor(r, g, b, alpha, cm->desaturation); if (glset.lightmode == 8) { if (gl_fixedcolormap) @@ -518,15 +502,9 @@ bool gl_CheckFog(sector_t *frontsector, sector_t *backsector) void gl_SetShaderLight(float level, float olight) { -#if 1 //ndef _DEBUG const float MAXDIST = 256.f; const float THRESHOLD = 96.f; const float FACTOR = 0.75f; -#else - const float MAXDIST = 256.f; - const float THRESHOLD = 96.f; - const float FACTOR = 2.75f; -#endif if (level > 0) { @@ -606,9 +584,6 @@ void gl_SetFog(int lightlevel, int rellight, const FColormap *cmap, bool isaddit { fogcolor=0; } - // Handle desaturation - if (cmap->colormap != CM_DEFAULT) - gl_ModifyColor(fogcolor.r, fogcolor.g, fogcolor.b, cmap->colormap); gl_RenderState.EnableFog(true); gl_RenderState.SetFog(fogcolor, fogdensity); @@ -619,29 +594,6 @@ void gl_SetFog(int lightlevel, int rellight, const FColormap *cmap, bool isaddit } } -//========================================================================== -// -// Modifies a color according to a specified colormap -// -//========================================================================== - -void gl_ModifyColor(BYTE & red, BYTE & green, BYTE & blue, int cm) -{ - int gray = (red*77 + green*143 + blue*36)>>8; - if (cm >= CM_FIRSTSPECIALCOLORMAP && cm < CM_MAXCOLORMAP) - { - PalEntry pe = SpecialColormaps[cm - CM_FIRSTSPECIALCOLORMAP].GrayscaleToColor[gray]; - red = pe.r; - green = pe.g; - blue = pe.b; - } - else if (cm >= CM_DESAT1 && cm <= CM_DESAT31) - { - gl_Desaturate(gray, red, green, blue, red, green, blue, cm - CM_DESAT0); - } -} - - //========================================================================== // diff --git a/src/gl/renderer/gl_lightdata.h b/src/gl/renderer/gl_lightdata.h index 8eb70bbb9..b968bfe7a 100644 --- a/src/gl/renderer/gl_lightdata.h +++ b/src/gl/renderer/gl_lightdata.h @@ -5,9 +5,6 @@ #include "r_data/renderstyle.h" #include "gl/renderer/gl_colormap.h" -bool gl_BrightmapsActive(); -bool gl_GlowActive(); - inline int gl_ClampLight(int lightlevel) { return clamp(lightlevel, 0, 255); @@ -46,14 +43,6 @@ inline bool gl_isFullbright(PalEntry color, int lightlevel) return gl_fixedcolormap || (gl_isWhite(color) && lightlevel==255); } -__forceinline void gl_Desaturate(int gray, int ired, int igreen, int iblue, BYTE & red, BYTE & green, BYTE & blue, int fac) -{ - red = (ired*(31-fac) + gray*fac)/31; - green = (igreen*(31-fac) + gray*fac)/31; - blue = (iblue*(31-fac) + gray*fac)/31; -} - -void gl_ModifyColor(BYTE & red, BYTE & green, BYTE & blue, int cm); void gl_DeleteAllAttachedLights(); void gl_RecreateAllAttachedLights(); diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 3e88ebceb..b94995cc7 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -273,10 +273,10 @@ void FGLRenderer::ClearBorders() glLoadIdentity(); glOrtho(0.0, width * 1.0, 0.0, trueHeight, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); - glColor3f(0.f, 0.f, 0.f); + gl_RenderState.SetColor(0.f ,0.f ,0.f ,1.f); gl_RenderState.Set2DMode(true); gl_RenderState.EnableTexture(false); - gl_RenderState.Apply(true); + gl_RenderState.Apply(); glBegin(GL_QUADS); // upper quad @@ -311,36 +311,35 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) double y = parms.y - parms.top * yscale; double w = parms.destwidth; double h = parms.destheight; - float u1, v1, u2, v2, r, g, b; - float light = 1.f; + float u1, v1, u2, v2; + int light = 255; FMaterial * gltex = FMaterial::ValidateTexture(img); if (parms.colorOverlay && (parms.colorOverlay & 0xffffff) == 0) { // Right now there's only black. Should be implemented properly later - light = 1.f - APART(parms.colorOverlay)/255.f; + light = 255 - APART(parms.colorOverlay); parms.colorOverlay = 0; } if (!img->bHasCanvas) { - if (!parms.alphaChannel) + int translation = 0; + if (!parms.alphaChannel) { - int translation = 0; if (parms.remap != NULL && !parms.remap->Inactive) { GLTranslationPalette * pal = static_cast(parms.remap->GetNative()); if (pal) translation = -pal->GetIndex(); } - gltex->BindPatch(translation); } else { // This is an alpha texture gl_RenderState.SetTextureMode(TM_REDTOALPHA); - gltex->BindPatch(0); } + gltex->BindPatch(translation); u1 = gltex->GetUL(); v1 = gltex->GetVT(); @@ -373,17 +372,17 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) u2 = float(u2 - (parms.texwidth - parms.windowright) / parms.texwidth); } + PalEntry color; if (parms.style.Flags & STYLEF_ColorIsFixed) { - r = RPART(parms.fillcolor)/255.0f; - g = GPART(parms.fillcolor)/255.0f; - b = BPART(parms.fillcolor)/255.0f; + color = parms.fillcolor; } else { - r = g = b = light; + color = PalEntry(light, light, light); } - + color.a = Scale(parms.alpha, 255, FRACUNIT); + // scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates int btm = (SCREENHEIGHT - screen->GetHeight()) / 2; btm = SCREENHEIGHT - btm; @@ -398,8 +397,7 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) gl_RenderState.SetTextureMode(TM_OPAQUE); } - glColor4f(r, g, b, FIXED2FLOAT(parms.alpha)); - + gl_RenderState.SetColor(color); gl_RenderState.EnableAlphaTest(false); gl_RenderState.Apply(); glBegin(GL_TRIANGLE_STRIP); @@ -418,8 +416,9 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) gl_RenderState.SetTextureMode(TM_MASK); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.SetColor(PalEntry(parms.colorOverlay)); gl_RenderState.Apply(); - glColor4ub(RPART(parms.colorOverlay),GPART(parms.colorOverlay),BPART(parms.colorOverlay),APART(parms.colorOverlay)); + glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(u1, v1); glVertex2d(x, y); @@ -450,8 +449,8 @@ void FGLRenderer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 { PalEntry p = color? (PalEntry)color : GPalette.BaseColors[palcolor]; gl_RenderState.EnableTexture(false); - gl_RenderState.Apply(true); - glColor3ub(p.r, p.g, p.b); + gl_RenderState.SetColorAlpha(p, 1.f); + gl_RenderState.Apply(); glBegin(GL_LINES); glVertex2i(x1, y1); glVertex2i(x2, y2); @@ -468,8 +467,8 @@ void FGLRenderer::DrawPixel(int x1, int y1, int palcolor, uint32 color) { PalEntry p = color? (PalEntry)color : GPalette.BaseColors[palcolor]; gl_RenderState.EnableTexture(false); - gl_RenderState.Apply(true); - glColor3ub(p.r, p.g, p.b); + gl_RenderState.SetColorAlpha(p, 1.f); + gl_RenderState.Apply(); glBegin(GL_POINTS); glVertex2i(x1, y1); glEnd(); @@ -484,19 +483,13 @@ void FGLRenderer::DrawPixel(int x1, int y1, int palcolor, uint32 color) void FGLRenderer::Dim(PalEntry color, float damount, int x1, int y1, int w, int h) { - float r, g, b; - gl_RenderState.EnableTexture(false); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.AlphaFunc(GL_GREATER,0); - gl_RenderState.Apply(true); - - r = color.r/255.0f; - g = color.g/255.0f; - b = color.b/255.0f; + gl_RenderState.SetColorAlpha(color, damount); + gl_RenderState.Apply(); glBegin(GL_TRIANGLE_FAN); - glColor4f(r, g, b, damount); glVertex2i(x1, y1); glVertex2i(x1, y1 + h); glVertex2i(x1 + w, y1 + h); @@ -536,9 +529,9 @@ void FGLRenderer::FlatFill (int left, int top, int right, int bottom, FTexture * fU2 = float(right-left) / src->GetWidth(); fV2 = float(bottom-top) / src->GetHeight(); } + gl_RenderState.ResetColor(); gl_RenderState.Apply(); glBegin(GL_TRIANGLE_STRIP); - glColor4f(1, 1, 1, 1); glTexCoord2f(fU1, fV1); glVertex2f(left, top); glTexCoord2f(fU1, fV2); glVertex2f(left, bottom); glTexCoord2f(fU2, fV1); glVertex2f(right, top); @@ -609,9 +602,7 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint FColormap cm; cm = colormap; - lightlevel = gl_CalcLightLevel(lightlevel, 0, true); - PalEntry pe = gl_CalcLightColor(lightlevel, cm.LightColor, cm.blendfactor, true); - glColor3ub(pe.r, pe.g, pe.b); + gl_SetColor(lightlevel, 0, &cm, 1.f); gltexture->Bind(); diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index ed54e9e32..bc878ec0d 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -183,8 +183,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) if (glset.nocoloredspritelighting) { - int v = (Colormap.LightColor.r * 77 + Colormap.LightColor.g*143 + Colormap.LightColor.b*35)/255; - p.LightColor = PalEntry(p.colormap, v, v, v); + p.Decolorize(); } diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 52177cbe2..4db9602dc 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -985,7 +985,7 @@ void FDrawInfo::SetupFloodStencil(wallseg * ws) glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); // increment stencil of valid pixels glColorMask(0,0,0,0); // don't write to the graphics buffer gl_RenderState.EnableTexture(false); - glColor3f(1,1,1); + gl_RenderState.ResetColor(); glEnable(GL_DEPTH_TEST); glDepthMask(true); @@ -1013,7 +1013,7 @@ void FDrawInfo::ClearFloodStencil(wallseg * ws) glStencilOp(GL_KEEP,GL_KEEP,GL_DECR); gl_RenderState.EnableTexture(false); glColorMask(0,0,0,0); // don't write to the graphics buffer - glColor3f(1,1,1); + gl_RenderState.ResetColor(); gl_RenderState.Apply(); glBegin(GL_TRIANGLE_FAN); @@ -1051,7 +1051,7 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo if (gl_fixedcolormap) { - Colormap.GetFixedColormap(); + Colormap.Clear(); lightlevel=255; } else diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 179c087d1..b5a5fc5c6 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -143,12 +143,13 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) } p.Set(plane.plane); - if (!gl_SetupLight(p, light, nearPt, up, right, scale, false, foggy)) + if (!gl_SetupLight(p, light, nearPt, up, right, scale, Colormap.desaturation, false, foggy)) { node=node->nextLight; continue; } draw_dlightf++; + gl_RenderState.Apply(); // Render the light glBegin(GL_TRIANGLE_FAN); @@ -501,7 +502,7 @@ inline void GLFlat::PutFlat(bool fog) if (gl_fixedcolormap) { - Colormap.GetFixedColormap(); + Colormap.Clear(); } if (renderstyle!=STYLE_Translucent || alpha < 1.f - FLT_EPSILON || fog) { @@ -533,7 +534,7 @@ inline void GLFlat::PutFlat(bool fog) else foggy = false; list = list_indices[light][masked][foggy]; - if (list == GLDL_LIGHT && gltexture->tex->gl_info.Brightmap && gl_BrightmapsActive()) list = GLDL_LIGHTBRIGHT; + if (list == GLDL_LIGHT && gltexture->tex->gl_info.Brightmap && gl.hasGLSL()) list = GLDL_LIGHTBRIGHT; gl_drawinfo->drawlists[list].AddFlat (this); } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 0c4439bc6..4b47abb1f 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -474,7 +474,7 @@ void FGLRenderer::RenderScene(int recursion) } // third pass: modulated texture - glColor3f(1.0f, 1.0f, 1.0f); + gl_RenderState.ResetColor(); gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); gl_RenderState.EnableFog(false); glDepthFunc(GL_LEQUAL); @@ -619,7 +619,7 @@ static void FillScreen() { gl_RenderState.EnableAlphaTest(false); gl_RenderState.EnableTexture(false); - gl_RenderState.Apply(true); + gl_RenderState.Apply(); glBegin(GL_TRIANGLE_STRIP); glVertex2f(0.0f, 0.0f); glVertex2f(0.0f, (float)SCREENHEIGHT); @@ -715,7 +715,7 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) if (extra_red || extra_green || extra_blue) { gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); - glColor4f(extra_red, extra_green, extra_blue, 1.0f); + gl_RenderState.SetColor(extra_red, extra_green, extra_blue, 1.0f); FillScreen(); } } @@ -773,14 +773,14 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) if (inverse) { gl_RenderState.BlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); - glColor4f(1.f, 1.f, 1.f, 1.f); + gl_RenderState.ResetColor(); FillScreen(); } if (r < WHITE_THRESH || g < WHITE_THRESH || b < WHITE_THRESH) { gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); - glColor4f(r, g, b, 1.0f); + gl_RenderState.SetColor(r, g, b, 1.0f); FillScreen(); } } @@ -806,7 +806,7 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) if (blend[3]>0.0f) { gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4fv(blend); + gl_RenderState.SetColor(blend[0], blend[1], blend[2], blend[3]); FillScreen(); } } @@ -850,7 +850,7 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) // Restore standard rendering state gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor3f(1.0f,1.0f,1.0f); + gl_RenderState.ResetColor(); gl_RenderState.EnableTexture(true); gl_RenderState.EnableAlphaTest(true); glDisable(GL_SCISSOR_TEST); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index f56076ef6..5492a1649 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -109,7 +109,7 @@ static void SkyVertex(int r, int c) if (!foglayer) { - // this cannot use the renderstate because it's inside a primitive. + // this must not use the renderstate because it's inside a primitive. glColor4f(1.f, 1.f, 1.f, r==0? 0.0f : 1.0f); // And the texture coordinates. @@ -244,7 +244,7 @@ static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float int texh = 0; bool texscale = false; - // 57 worls units roughly represent one sky texel for the glTranslate call. + // 57 world units roughly represent one sky texel for the glTranslate call. const float skyoffsetfactor = 57; if (tex) @@ -511,7 +511,7 @@ void GLSkyPortal::DrawContents() FadeColor = origin->fadecolor; } - gl_RenderState.SetColor(0xffffffff); + gl_RenderState.ResetColor(); gl_RenderState.EnableFog(false); gl_RenderState.EnableAlphaTest(false); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 9c8bba2f0..325fe9082 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -112,10 +112,6 @@ void GLSprite::Draw(int pass) { if (pass!=GLPASS_PLAIN && pass != GLPASS_ALL && pass!=GLPASS_TRANSLUCENT) return; - // Hack to enable bright sprites in faded maps - uint32 backupfade = Colormap.FadeColor.d; - if (gl_spritebrightfog && fullbright) - Colormap.FadeColor = 0; bool additivefog = false; @@ -126,16 +122,15 @@ void GLSprite::Draw(int pass) { // The translucent pass requires special setup for the various modes. - // Brightmaps will only be used when doing regular drawing ops and having no fog - if (!gl_spritebrightfog && (!gl_isBlack(Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE || - RenderStyle.BlendOp != STYLEOP_Add)) + // for special render styles brightmaps would not look good - especially for subtractive. + if (RenderStyle.BlendOp != STYLEOP_Add) { gl_RenderState.EnableBrightmap(false); } gl_SetRenderStyle(RenderStyle, false, // The rest of the needed checks are done inside gl_SetRenderStyle - trans > 1.f - FLT_EPSILON && gl_usecolorblending && gl_fixedcolormap < CM_FIRSTSPECIALCOLORMAP && actor && + trans > 1.f - FLT_EPSILON && gl_usecolorblending && gl_fixedcolormap == CM_DEFAULT && actor && fullbright && gltexture && !gltexture->GetTransparent()); if (hw_styleflags == STYLEHW_NoAlphaTest) @@ -169,7 +164,7 @@ void GLSprite::Draw(int pass) } gl_RenderState.AlphaFunc(GL_GEQUAL,minalpha*gl_mask_sprite_threshold); - gl_RenderState.SetColor(0.2f,0.2f,0.2f,fuzzalpha); + gl_RenderState.SetColor(0.2f,0.2f,0.2f,fuzzalpha, Colormap.desaturation); additivefog = true; } else if (RenderStyle.BlendOp == STYLEOP_Add && RenderStyle.DestAlpha == STYLEALPHA_One) @@ -339,12 +334,8 @@ void GLSprite::Draw(int pass) } } - // End of gl_sprite_brightfog hack: restore FadeColor to normalcy - if (backupfade != Colormap.FadeColor.d) - Colormap.FadeColor = backupfade; - - gl_RenderState.EnableTexture(true); gl_RenderState.SetObjectColor(0xffffffff); + gl_RenderState.EnableTexture(true); gl_RenderState.SetDynLight(0,0,0); } @@ -696,7 +687,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) // allow disabling of the fullbright flag by a brightmap definition // (e.g. to do the gun flashes of Doom's zombies correctly. fullbright = (thing->flags5 & MF5_BRIGHT) || - ((thing->renderflags & RF_FULLBRIGHT) && (!gl_BrightmapsActive() || !gltexture || !gltexture->tex->gl_info.bBrightmapDisablesFullbright)); + ((thing->renderflags & RF_FULLBRIGHT) && (!gl.hasGLSL() || !gltexture || !gltexture->tex->gl_info.bBrightmapDisablesFullbright)); lightlevel=fullbright? 255 : gl_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ? @@ -717,7 +708,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) || (gl_enhanced_nv_stealth == 3)) // Any fixed colormap enhancedvision=true; - Colormap.GetFixedColormap(); + Colormap.Clear(); if (gl_fixedcolormap==CM_LITE) { @@ -750,10 +741,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) } else if (glset.nocoloredspritelighting) { - int v = (Colormap.LightColor.r /* * 77 */ + Colormap.LightColor.g /**143 */ + Colormap.LightColor.b /**35*/)/3;//255; - Colormap.LightColor.r= - Colormap.LightColor.g= - Colormap.LightColor.b=(255+v+v)/3; + Colormap.Decolorize(); } } @@ -894,7 +882,7 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s if (gl_fixedcolormap) { - Colormap.GetFixedColormap(); + Colormap.Clear(); } else if (!particle->bright) { diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index e8c23ad81..2d6b78fd5 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -71,7 +71,7 @@ void GLWall::CheckGlowing() { bottomglowcolor[3] = topglowcolor[3] = 0; - if (!gl_isFullbright(Colormap.LightColor, lightlevel) && gl_GlowActive()) + if (!gl_isFullbright(Colormap.LightColor, lightlevel) && gl.hasGLSL()) { FTexture *tex = TexMan[topflat]; if (tex != NULL && tex->isGlowing()) @@ -133,7 +133,7 @@ void GLWall::PutWall(bool translucent) // light planes don't get drawn with fullbright rendering if (!gltexture && passflag[type]!=4) return; - Colormap.GetFixedColormap(); + Colormap.Clear(); } CheckGlowing(); @@ -184,7 +184,7 @@ void GLWall::PutWall(bool translucent) list = list_indices[light][masked][!!(flags&GLWF_FOGGY)]; if (list == GLDL_LIGHT) { - if (gltexture->tex->gl_info.Brightmap && gl_BrightmapsActive()) list = GLDL_LIGHTBRIGHT; + if (gltexture->tex->gl_info.Brightmap && gl.hasGLSL()) list = GLDL_LIGHTBRIGHT; if (flags & GLWF_GLOW) list = GLDL_LIGHTBRIGHT; } gl_drawinfo->drawlists[list].AddWall(this); @@ -525,7 +525,7 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) hi.colormap.LightColor = (light->extra_colormap)->Color; } - if (gl_fixedcolormap) hi.colormap.GetFixedColormap(); + if (gl_fixedcolormap) hi.colormap.Clear(); horizon = &hi; PutWall(0); } @@ -554,8 +554,8 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) hi.colormap.LightColor = (light->extra_colormap)->Color; } - if (gl_fixedcolormap) hi.colormap.GetFixedColormap(); - horizon=&hi; + if (gl_fixedcolormap) hi.colormap.Clear(); + horizon = &hi; PutWall(0); } } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 38adfeeab..937549195 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -81,7 +81,7 @@ bool GLWall::PrepareLight(texcoord * tcs, ADynamicLight * light) return false; } - if (!gl_SetupLight(p, light, nearPt, up, right, scale, true, !!(flags&GLWF_FOGGY))) + if (!gl_SetupLight(p, light, nearPt, up, right, scale, Colormap.desaturation, true, !!(flags&GLWF_FOGGY))) { return false; } @@ -267,7 +267,7 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs); - // color for right side + // color for right side (do not set in render state!) if (color2) glColor4fv(color2); // upper right corner @@ -365,15 +365,13 @@ void GLWall::RenderFogBoundary() float fogd1=(0.95f-exp(-fogdensity*dist1/62500.f)) * 1.05f; float fogd2=(0.95f-exp(-fogdensity*dist2/62500.f)) * 1.05f; - gl_ModifyColor(Colormap.FadeColor.r, Colormap.FadeColor.g, Colormap.FadeColor.b, Colormap.colormap); float fc[4]={Colormap.FadeColor.r/255.0f,Colormap.FadeColor.g/255.0f,Colormap.FadeColor.b/255.0f,fogd2}; gl_RenderState.EnableTexture(false); gl_RenderState.EnableFog(false); gl_RenderState.AlphaFunc(GL_GREATER,0); glDepthFunc(GL_LEQUAL); - glColor4f(fc[0],fc[1],fc[2], fogd1); - gl_RenderState.SetColor(-1, 0, 0, 0); // we do not want the render state to control the color. + gl_RenderState.SetColor(fc[0], fc[1], fc[2], fogd1, Colormap.desaturation); if (glset.lightmode == 8) glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); // Korshun. flags &= ~GLWF_GLOW; @@ -406,10 +404,10 @@ void GLWall::RenderMirrorSurface() gl_RenderState.SetEffect(EFF_SPHEREMAP); gl_SetColor(lightlevel, 0, &Colormap ,0.1f); + gl_SetFog(lightlevel, 0, &Colormap, true); gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE); gl_RenderState.AlphaFunc(GL_GREATER,0); glDepthFunc(GL_LEQUAL); - gl_SetFog(lightlevel, getExtraLight(), &Colormap, true); FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrortexture); pat->BindPatch(0); diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index d582b7165..57d05931f 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -203,7 +203,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) { bool disablefullbright = false; FTextureID lump = gl_GetSpriteFrame(psp->sprite, psp->frame, 0, 0, NULL); - if (lump.isValid() && gl_BrightmapsActive()) + if (lump.isValid() && gl.hasGLSL()) { FMaterial * tex=FMaterial::ValidateTexture(lump, false); if (tex) @@ -217,7 +217,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) if (gl_fixedcolormap) { lightlevel=255; - cm.GetFixedColormap(); + cm.Clear(); statebright[0] = statebright[1] = true; fakesec = viewsector; } @@ -294,7 +294,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) playermo->Inventory->AlterWeaponSprite(&vis); if (vis.colormap >= SpecialColormaps[0].Colormap && vis.colormap < SpecialColormaps[SpecialColormaps.Size()].Colormap && - cm.colormap == CM_DEFAULT) + gl_fixedcolormap == CM_DEFAULT) { // this only happens for Strife's inverted weapon sprite vis.RenderStyle.Flags |= STYLEF_InvertSource; @@ -379,7 +379,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) // set the lighting parameters if (vis.RenderStyle.BlendOp == STYLEOP_Shadow) { - gl_RenderState.SetColor(0.2f, 0.2f, 0.2f, 0.33f);// 0x55333333, cmc.desaturation); + gl_RenderState.SetColor(0.2f, 0.2f, 0.2f, 0.33f, cmc.desaturation); } else { diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 8f993b857..768d3ad53 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -393,6 +393,7 @@ FShader *FShaderContainer::Bind(int cm, bool glowing, float Speed, bool lights) glUniform3fv(sh->colormaprange_index, 1, m); } } + /* else { bool desat = cm>=CM_DESAT1 && cm<=CM_DESAT31; @@ -407,6 +408,7 @@ FShader *FShaderContainer::Bind(int cm, bool glowing, float Speed, bool lights) } } } + */ return sh; } diff --git a/src/r_defs.h b/src/r_defs.h index bb2401684..80f908e81 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -771,6 +771,7 @@ struct sector_t int subsectorcount; // list of subsectors subsector_t ** subsectors; FPortal * portals[2]; // floor and ceiling portals + FLightNode * lighthead[2]; enum { From 506798f134c857557e5cd15b093a2976490ba3b2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 May 2014 23:12:28 +0200 Subject: [PATCH 0085/1509] allow brightmaps and fullbright objects in fog. The reasons why they were disabled no longer exist. --- src/gl/scene/gl_flats.cpp | 2 -- src/gl/scene/gl_scene.cpp | 3 --- src/gl/scene/gl_walls_draw.cpp | 2 -- src/gl/shaders/gl_shader.cpp | 6 ++---- 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index b5a5fc5c6..383ee1574 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -471,11 +471,9 @@ void GLFlat::Draw(int pass) } else { - if (foggy) gl_RenderState.EnableBrightmap(false); gltexture->Bind(); bool pushed = gl_SetPlaneTextureRotation(&plane, gltexture); DrawSubsectors(pass, true); - gl_RenderState.EnableBrightmap(true); if (pushed) { glPopMatrix(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 4b47abb1f..d32432a28 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -405,7 +405,6 @@ void FGLRenderer::RenderScene(int recursion) gl_RenderState.EnableBrightmap(gl_fixedcolormap == CM_DEFAULT); gl_drawinfo->drawlists[GLDL_PLAIN].Sort(); gl_drawinfo->drawlists[GLDL_PLAIN].Draw(pass); - gl_RenderState.EnableBrightmap(false); gl_drawinfo->drawlists[GLDL_FOG].Sort(); gl_drawinfo->drawlists[GLDL_FOG].Draw(pass); gl_drawinfo->drawlists[GLDL_LIGHTFOG].Sort(); @@ -422,10 +421,8 @@ void FGLRenderer::RenderScene(int recursion) } if (pass == GLPASS_BASE) pass = GLPASS_BASE_MASKED; gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_threshold); - gl_RenderState.EnableBrightmap(true); gl_drawinfo->drawlists[GLDL_MASKED].Sort(); gl_drawinfo->drawlists[GLDL_MASKED].Draw(pass); - gl_RenderState.EnableBrightmap(false); gl_drawinfo->drawlists[GLDL_FOGMASKED].Sort(); gl_drawinfo->drawlists[GLDL_FOGMASKED].Draw(pass); gl_drawinfo->drawlists[GLDL_LIGHTFOGMASKED].Sort(); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 937549195..d3574ebe9 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -461,7 +461,6 @@ void GLWall::RenderTranslucentWall() int extra; if (gltexture) { - if (flags&GLWF_FOGGY) gl_RenderState.EnableBrightmap(false); gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); gltexture->Bind(flags, 0); extra = getExtraLight(); @@ -486,7 +485,6 @@ void GLWall::RenderTranslucentWall() { gl_RenderState.EnableTexture(true); } - gl_RenderState.EnableBrightmap(true); gl_RenderState.EnableGlow(false); } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 768d3ad53..a132e65dd 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -393,10 +393,9 @@ FShader *FShaderContainer::Bind(int cm, bool glowing, float Speed, bool lights) glUniform3fv(sh->colormaprange_index, 1, m); } } - /* else { - bool desat = cm>=CM_DESAT1 && cm<=CM_DESAT31; + bool desat = false;// cm >= CM_DESAT1 && cm <= CM_DESAT31; sh = shader[glowing + 2*desat + 4*lights + (glset.lightmode & 8)]; // [BB] If there was a problem when loading the shader, sh is NULL here. if( sh ) @@ -404,11 +403,10 @@ FShader *FShaderContainer::Bind(int cm, bool glowing, float Speed, bool lights) sh->Bind(Speed); if (desat) { - glUniform1f(sh->desaturation_index, 1.f-float(cm-CM_DESAT0)/(CM_DESAT31-CM_DESAT0)); + //glUniform1f(sh->desaturation_index, 1.f-float(cm-CM_DESAT0)/(CM_DESAT31-CM_DESAT0)); } } } - */ return sh; } From b9a6fe80a466fd39afa063a5f245d944919d8ef8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 May 2014 23:56:53 +0200 Subject: [PATCH 0086/1509] Do not use the shader to handle STYLEF_RedIsAlpha. Turns out that the name doesn't accurately describe what it does. It is correct for images that come with their own palette or are true color. But for images using the game palette it doesn't use the red channel to determine translucency but the palette index! Ugh... This means it cannot be done with a simple operation in the shader because it won't get a proper source image. The only solution is to create a separate texture. --- src/gl/renderer/gl_lightdata.cpp | 6 +----- src/gl/renderer/gl_renderer.cpp | 15 +++------------ src/gl/renderer/gl_renderer.h | 2 +- src/gl/renderer/gl_renderstate.h | 1 - src/gl/scene/gl_decal.cpp | 2 +- src/gl/scene/gl_sprite.cpp | 2 +- src/gl/scene/gl_weapon.cpp | 8 ++++---- src/gl/system/gl_interface.h | 9 --------- src/gl/textures/gl_material.cpp | 4 ++-- src/gl/textures/gl_material.h | 2 +- wadsrc/static/shaders/glsl/main.fp | 4 ---- wadsrc/static/shaders/glsl/main_colormap.fp | 4 ---- 12 files changed, 14 insertions(+), 45 deletions(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index c5bf4c1c8..60bc1bd67 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -144,11 +144,7 @@ void gl_GetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblend int blendequation = renderops[style.BlendOp&15]; int texturemode = drawopaque? TM_OPAQUE : TM_MODULATE; - if (style.Flags & STYLEF_RedIsAlpha) - { - texturemode = TM_REDTOALPHA; - } - else if (style.Flags & STYLEF_ColorIsFixed) + if (style.Flags & STYLEF_ColorIsFixed) { texturemode = TM_MASK; } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index b94995cc7..f6420ce28 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -334,17 +334,14 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) if (pal) translation = -pal->GetIndex(); } } - else - { - // This is an alpha texture - gl_RenderState.SetTextureMode(TM_REDTOALPHA); - } - gltex->BindPatch(translation); + gl_SetRenderStyle(parms.style, !parms.masked, false); + gltex->BindPatch(translation, 0, !!(parms.style.Flags & STYLEF_RedIsAlpha)); u1 = gltex->GetUL(); v1 = gltex->GetVT(); u2 = gltex->GetUR(); v2 = gltex->GetVB(); + } else { @@ -391,12 +388,6 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) int space = (static_cast(screen)->GetTrueHeight()-screen->GetHeight())/2; glScissor(parms.lclip, btm - parms.dclip + space, parms.rclip - parms.lclip, parms.dclip - parms.uclip); - gl_SetRenderStyle(parms.style, !parms.masked, false); - if (img->bHasCanvas) - { - gl_RenderState.SetTextureMode(TM_OPAQUE); - } - gl_RenderState.SetColor(color); gl_RenderState.EnableAlphaTest(false); gl_RenderState.Apply(); diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 4a4e31c10..fde918d16 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -91,7 +91,7 @@ public: void DrawScene(bool toscreen = false); void DrawBlend(sector_t * viewsector); - void DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, bool hudModelStep, int OverrideShader); + void DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, bool hudModelStep, int OverrideShader, bool alphatexture); void DrawPlayerSprites(sector_t * viewsector, bool hudModelStep); void DrawTargeterSprites(); diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index d01cc53cf..ab58c9509 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -178,7 +178,6 @@ public: void SetTextureMode(int mode) { mTextureMode = mode; - gl.checkTextureMode(mode); } void EnableTexture(bool on) diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index bc878ec0d..5e490b8a7 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -328,7 +328,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) gl_SetRenderStyle(decal->RenderStyle, false, false); - tex->BindPatch(decal->Translation); + tex->BindPatch(decal->Translation, 0, !!(decal->RenderStyle.Flags & STYLEF_RedIsAlpha)); // If srcalpha is one it looks better with a higher alpha threshold diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 325fe9082..c051e94ee 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -221,7 +221,7 @@ void GLSprite::Draw(int pass) gl_RenderState.SetFog(0, 0); } - if (gltexture) gltexture->BindPatch(translation, OverrideShader); + if (gltexture) gltexture->BindPatch(translation, OverrideShader, !!(RenderStyle.Flags & STYLEF_RedIsAlpha)); else if (!modelframe) gl_RenderState.EnableTexture(false); if (!modelframe) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 57d05931f..1b0c99053 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -69,7 +69,7 @@ EXTERN_CVAR(Int, gl_fuzztype) // //========================================================================== -void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, bool hudModelStep, int OverrideShader) +void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, bool hudModelStep, int OverrideShader, bool alphatexture) { float fU1,fV1; float fU2,fV2; @@ -95,7 +95,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed FMaterial * tex = FMaterial::ValidateTexture(lump, false); if (!tex) return; - tex->BindPatch(0, OverrideShader); + tex->BindPatch(0, OverrideShader, alphatexture); int vw = viewwidth; int vh = viewheight; @@ -386,7 +386,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) gl_SetDynSpriteLight(playermo, NULL); gl_SetColor(statebright[i] ? 255 : lightlevel, 0, &cmc, trans, true); } - DrawPSprite (player,psp,psp->sx+ofsx, psp->sy+ofsy, hudModelStep, OverrideShader); + DrawPSprite(player, psp, psp->sx + ofsx, psp->sy + ofsy, hudModelStep, OverrideShader, !!(vis.RenderStyle.Flags & STYLEF_RedIsAlpha)); } } gl_RenderState.SetObjectColor(0xffffffff); @@ -420,5 +420,5 @@ void FGLRenderer::DrawTargeterSprites() // The Targeter's sprites are always drawn normally. for (i=ps_targetcenter, psp = &player->psprites[ps_targetcenter]; istate) DrawPSprite (player,psp,psp->sx, psp->sy, false, 0); + if (psp->state) DrawPSprite (player,psp,psp->sx, psp->sy, false, 0, false); } \ No newline at end of file diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 8618c246a..45e0a09ac 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -20,9 +20,6 @@ enum TexMode TM_MASK = 1, // (1, 1, 1, a) TM_OPAQUE = 2, // (r, g, b, 1) TM_INVERSE = 3, // (1-r, 1-g, 1-b, a) - TM_REDTOALPHA = 4, // (1, 1, 1, r) - - // 4 cannot be done natively without shaders and requires special textures. }; struct RenderContext @@ -33,7 +30,6 @@ struct RenderContext float glslversion; int max_texturesize; char * vendorstring; - bool needAlphaTexture; int MaxLights() const { @@ -44,11 +40,6 @@ struct RenderContext { return glslversion >= 1.3f; } - - void checkTextureMode(int mode) - { - if (!hasGLSL()) needAlphaTexture = (mode == TM_REDTOALPHA); - } }; extern RenderContext gl; diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 9faf996be..ce3c75181 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -883,7 +883,7 @@ void FMaterial::Bind(int clampmode, int translation, int overrideshader) // //=========================================================================== -void FMaterial::BindPatch(int translation, int overrideshader) +void FMaterial::BindPatch(int translation, int overrideshader, bool alphatexture) { int usebright = false; int shaderindex = overrideshader > 0? overrideshader : mShaderIndex; @@ -891,7 +891,7 @@ void FMaterial::BindPatch(int translation, int overrideshader) int softwarewarp = gl_RenderState.SetupShader(tex->bHasCanvas, shaderindex, tex->gl_info.shaderspeed); - const FHardwareTexture *glpatch = mBaseLayer->BindPatch(0, translation, softwarewarp, gl.needAlphaTexture); + const FHardwareTexture *glpatch = mBaseLayer->BindPatch(0, translation, softwarewarp, alphatexture); // The only multitexture effect usable on sprites is the brightmap. if (glpatch != NULL && shaderindex == 3) { diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index f01e39cd3..e1a5e93cd 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -135,7 +135,7 @@ public: } void Bind(int clamp = 0, int translation = 0, int overrideshader = 0); - void BindPatch(int translation = 0, int overrideshader = 0); + void BindPatch(int translation = 0, int overrideshader = 0, bool alphatexture = false); unsigned char * CreateTexBuffer(int translation, int & w, int & h, bool expand = false, bool allowhires=true) const { diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index d4334251b..086cda7f9 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -155,10 +155,6 @@ vec4 getTexel(vec2 st) texel = vec4(1.0-texel.r, 1.0-texel.g, 1.0-texel.b, texel.a); return texel; } - else if (texturemode == 4) - { - texel = vec4(1.0, 1.0, 1.0, texel.r); - } else if (texturemode == 2) { texel.a = 1.0; diff --git a/wadsrc/static/shaders/glsl/main_colormap.fp b/wadsrc/static/shaders/glsl/main_colormap.fp index d78a21f5f..5f88baaa7 100644 --- a/wadsrc/static/shaders/glsl/main_colormap.fp +++ b/wadsrc/static/shaders/glsl/main_colormap.fp @@ -26,10 +26,6 @@ vec4 getTexel(vec2 st) texel = vec4(1.0-texel.r, 1.0-texel.g, 1.0-texel.b, texel.a); return texel; } - else if (texturemode == 4) - { - texel = vec4(1.0, 1.0, 1.0, texel.r); - } else if (texturemode == 2) { texel.a = 1.0; From 98cc7eeb99087e3e2976c9474bd05d08ed3a926c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 May 2014 00:13:19 +0200 Subject: [PATCH 0087/1509] pass softlightlevel through render state. --- src/gl/renderer/gl_lightdata.cpp | 91 ++++++------------------------ src/gl/renderer/gl_lightdata.h | 4 +- src/gl/renderer/gl_renderer.cpp | 2 +- src/gl/renderer/gl_renderstate.cpp | 5 ++ src/gl/renderer/gl_renderstate.h | 6 ++ src/gl/scene/gl_decal.cpp | 2 +- src/gl/scene/gl_drawinfo.cpp | 2 +- src/gl/scene/gl_flats.cpp | 6 +- src/gl/scene/gl_portal.cpp | 4 +- src/gl/scene/gl_scene.cpp | 2 +- src/gl/scene/gl_sprite.cpp | 2 +- src/gl/scene/gl_walls_draw.cpp | 11 ++-- src/gl/scene/gl_weapon.cpp | 2 +- 13 files changed, 45 insertions(+), 94 deletions(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 60bc1bd67..60ecf70be 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -225,11 +225,11 @@ int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon) // //========================================================================== -PalEntry gl_CalcLightColor(int light, PalEntry pe, int blendfactor, bool force) +static PalEntry gl_CalcLightColor(int light, PalEntry pe, int blendfactor) { int r,g,b; - if (glset.lightmode == 8 && !force) + if (glset.lightmode == 8) { return pe; } @@ -254,81 +254,22 @@ PalEntry gl_CalcLightColor(int light, PalEntry pe, int blendfactor, bool force) //========================================================================== // -// Get current light color +// set current light color // //========================================================================== -void gl_GetLightColor(int lightlevel, int rellight, const FColormap * cm, float * pred, float * pgreen, float * pblue, bool weapon) -{ - float & r=*pred,& g=*pgreen,& b=*pblue; - int torch=0; - - if (gl_fixedcolormap) +void gl_SetColor(int sectorlightlevel, int rellight, const FColormap &cm, float alpha, bool weapon) +{ + if (gl_fixedcolormap != CM_DEFAULT) { - if (!gl_enhanced_nightvision || !gl.hasGLSL()) - { - // we cannot multiply the light in here without causing major problems with the ThingColor so for older hardware - // these maps are done as a postprocessing overlay. - r = g = b = 1.0f; - } - else if (gl_fixedcolormap == CM_LITE) - { - r = 0.375f, g = 1.0f, b = 0.375f; - } - else if (gl_fixedcolormap >= CM_TORCH) - { - int flicker = gl_fixedcolormap - CM_TORCH; - r = (0.8f + (7 - flicker) / 70.0f); - if (r > 1.0f) r = 1.0f; - g = r; - b = g * 0.75f; - } - else r = g = b = 1.0f; - return; + gl_RenderState.SetColorAlpha(0xffffff, alpha, 0); + gl_RenderState.SetSoftLightLevel(255); } - - PalEntry lightcolor = cm? cm->LightColor : PalEntry(255,255,255); - int blendfactor = cm? cm->blendfactor : 0; - - lightlevel = gl_CalcLightLevel(lightlevel, rellight, weapon); - PalEntry pe = gl_CalcLightColor(lightlevel, lightcolor, blendfactor); - r = pe.r/255.f; - g = pe.g/255.f; - b = pe.b/255.f; -} - -//========================================================================== -// -// set current light color -// -//========================================================================== -void gl_SetColor(int light, int rellight, const FColormap * cm, float *red, float *green, float *blue, bool weapon) -{ - gl_GetLightColor(light, rellight, cm, red, green, blue, weapon); -} - -//========================================================================== -// -// set current light color -// -//========================================================================== -void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, bool weapon) -{ - float r,g,b; - - gl_GetLightColor(light, rellight, cm, &r, &g, &b, weapon); - - gl_RenderState.SetColor(r, g, b, alpha, cm->desaturation); - if (glset.lightmode == 8) - { - if (gl_fixedcolormap) - { - glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); - } - else - { - float lightlevel = gl_CalcLightLevel(light, rellight, weapon) / 255.0f; - glVertexAttrib1f(VATTR_LIGHTLEVEL, lightlevel); - } + else + { + int hwlightlevel = gl_CalcLightLevel(sectorlightlevel, rellight, weapon); + PalEntry pe = gl_CalcLightColor(hwlightlevel, cm.LightColor, cm.blendfactor); + gl_RenderState.SetColorAlpha(pe, alpha, cm.desaturation); + gl_RenderState.SetSoftLightLevel(gl_ClampLight(sectorlightlevel + rellight)); } } @@ -586,7 +527,9 @@ void gl_SetFog(int lightlevel, int rellight, const FColormap *cmap, bool isaddit // Korshun: fullbright fog like in software renderer. if (glset.lightmode == 8 && glset.brightfog && fogdensity != 0 && fogcolor != 0) - glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); + { + gl_RenderState.SetSoftLightLevel(255); + } } } diff --git a/src/gl/renderer/gl_lightdata.h b/src/gl/renderer/gl_lightdata.h index b968bfe7a..f76f732af 100644 --- a/src/gl/renderer/gl_lightdata.h +++ b/src/gl/renderer/gl_lightdata.h @@ -15,9 +15,7 @@ void gl_GetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblend void gl_SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog); int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon); -PalEntry gl_CalcLightColor(int light, PalEntry pe, int blendfactor, bool force = false); -void gl_GetLightColor(int lightlevel, int rellight, const FColormap * cm, float * pred, float * pgreen, float * pblue, bool weapon=false); -void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, bool weapon=false); +void gl_SetColor(int light, int rellight, const FColormap &cm, float alpha, bool weapon=false); float gl_GetFogDensity(int lightlevel, PalEntry fogcolor); struct sector_t; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index f6420ce28..b6d64eeee 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -593,7 +593,7 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint FColormap cm; cm = colormap; - gl_SetColor(lightlevel, 0, &cm, 1.f); + gl_SetColor(lightlevel, 0, cm, 1.f); gltexture->Bind(); diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index d6cf1804e..71198bafe 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -212,6 +212,11 @@ bool FRenderState::ApplyShader() glUniform4f(activeShader->dlightcolor_index, mDynColor.r / 255.f, mDynColor.g / 255.f, mDynColor.b / 255.f, 0); } + if (glset.lightmode == 8) + { + glVertexAttrib1f(VATTR_LIGHTLEVEL, mSoftLight / 255.f); + } + return true; } return false; diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index ab58c9509..5308da42b 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -96,6 +96,7 @@ class FRenderState bool mBrightmapEnabled; int mSpecialEffect; int mTextureMode; + int mSoftLight; float mLightParms[2]; int mNumLights[3]; float *mLightData; @@ -221,6 +222,11 @@ public: mGlowBottom.Set(b[0], b[1], b[2], b[3]); } + void SetSoftLightLevel(int level) + { + mSoftLight = level; + } + void SetGlowPlanes(const secplane_t &top, const secplane_t &bottom) { mGlowTopPlane.Set(FIXED2FLOAT(top.a), FIXED2FLOAT(top.b), FIXED2FLOAT(top.ic), FIXED2FLOAT(top.d)); diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 5e490b8a7..1d15ebcab 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -317,7 +317,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) gl_RenderState.SetObjectColor(decal->AlphaColor); } - gl_SetColor(light, rel, &p, a); + gl_SetColor(light, rel, p, a); // for additively drawn decals we must temporarily set the fog color to black. PalEntry fc = gl_RenderState.GetFogColor(); diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 4db9602dc..2c7a4a15a 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -1066,7 +1066,7 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo } int rel = getExtraLight(); - gl_SetColor(lightlevel, rel, &Colormap, 1.0f); + gl_SetColor(lightlevel, rel, Colormap, 1.0f); gl_SetFog(lightlevel, rel, &Colormap, false); gltexture->Bind(); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 383ee1574..7be264e68 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -395,7 +395,7 @@ void GLFlat::Draw(int pass) switch (pass) { case GLPASS_BASE: - gl_SetColor(lightlevel, rel, &Colormap,1.0f); + gl_SetColor(lightlevel, rel, Colormap,1.0f); if (!foggy) gl_SetFog(lightlevel, rel, &Colormap, false); DrawSubsectors(pass, false); break; @@ -403,7 +403,7 @@ void GLFlat::Draw(int pass) case GLPASS_PLAIN: // Single-pass rendering case GLPASS_ALL: case GLPASS_BASE_MASKED: - gl_SetColor(lightlevel, rel, &Colormap,1.0f); + gl_SetColor(lightlevel, rel, Colormap,1.0f); if (!foggy || pass != GLPASS_BASE_MASKED) gl_SetFog(lightlevel, rel, &Colormap, false); // fall through case GLPASS_TEXTURE: @@ -460,7 +460,7 @@ void GLFlat::Draw(int pass) case GLPASS_TRANSLUCENT: if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE); - gl_SetColor(lightlevel, rel, &Colormap, alpha); + gl_SetColor(lightlevel, rel, Colormap, alpha); gl_SetFog(lightlevel, rel, &Colormap, false); gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_threshold*(alpha)); if (!gltexture) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 020a37b4e..b49b0027d 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -962,13 +962,13 @@ void GLHorizonPortal::DrawContents() if (gltexture && gltexture->tex->isFullbright()) { // glowing textures are always drawn full bright without color - gl_SetColor(255, 0, &origin->colormap, 1.f); + gl_SetColor(255, 0, origin->colormap, 1.f); gl_SetFog(255, 0, &origin->colormap, false); } else { int rel = getExtraLight(); - gl_SetColor(origin->lightlevel, rel, &origin->colormap, 1.0f); + gl_SetColor(origin->lightlevel, rel, origin->colormap, 1.0f); gl_SetFog(origin->lightlevel, rel, &origin->colormap, false); } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index d32432a28..3804ea048 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -460,7 +460,7 @@ void FGLRenderer::RenderScene(int recursion) { gl_RenderState.BlendFunc(GL_ONE, GL_ONE); glDepthFunc(GL_EQUAL); - if (glset.lightmode == 8) glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0f); // Korshun. + gl_RenderState.SetSoftLightLevel(255); for(int i=GLDL_FIRSTLIGHT; i<=GLDL_LASTLIGHT; i++) { gl_drawinfo->drawlists[i].Draw(GLPASS_LIGHT); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index c051e94ee..41e94a73b 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -178,7 +178,7 @@ void GLSprite::Draw(int pass) { gl_SetDynSpriteLight(gl_light_sprites ? actor : NULL, gl_light_particles ? particle : NULL); } - gl_SetColor(lightlevel, rel, &Colormap, trans); + gl_SetColor(lightlevel, rel, Colormap, trans); } gl_RenderState.SetObjectColor(ThingColor); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index d3574ebe9..dc7127690 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -371,8 +371,7 @@ void GLWall::RenderFogBoundary() gl_RenderState.EnableFog(false); gl_RenderState.AlphaFunc(GL_GREATER,0); glDepthFunc(GL_LEQUAL); - gl_RenderState.SetColor(fc[0], fc[1], fc[2], fogd1, Colormap.desaturation); - if (glset.lightmode == 8) glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); // Korshun. + gl_RenderState.SetColor(fc[0], fc[1], fc[2], fogd1); flags &= ~GLWF_GLOW; RenderWall(4,fc); @@ -403,7 +402,7 @@ void GLWall::RenderMirrorSurface() // Use sphere mapping for this gl_RenderState.SetEffect(EFF_SPHEREMAP); - gl_SetColor(lightlevel, 0, &Colormap ,0.1f); + gl_SetColor(lightlevel, 0, Colormap ,0.1f); gl_SetFog(lightlevel, 0, &Colormap, true); gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE); gl_RenderState.AlphaFunc(GL_GREATER,0); @@ -471,7 +470,7 @@ void GLWall::RenderTranslucentWall() extra = 0; } - gl_SetColor(lightlevel, extra, &Colormap, fabsf(alpha)); + gl_SetColor(lightlevel, extra, Colormap, fabsf(alpha)); if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, extra, &Colormap, isadditive); else gl_SetFog(255, 0, NULL, false); @@ -523,7 +522,7 @@ void GLWall::Draw(int pass) // fall through case GLPASS_PLAIN: // Single-pass rendering rel = rellight + getExtraLight(); - gl_SetColor(lightlevel, rel, &Colormap,1.0f); + gl_SetColor(lightlevel, rel, Colormap,1.0f); if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, false); else gl_SetFog(255, 0, NULL, false); @@ -537,7 +536,7 @@ void GLWall::Draw(int pass) case GLPASS_BASE: // Base pass for non-masked polygons (all opaque geometry) case GLPASS_BASE_MASKED: // Base pass for masked polygons (2sided mid-textures and transparent 3D floors) rel = rellight + getExtraLight(); - gl_SetColor(lightlevel, rel, &Colormap,1.0f); + gl_SetColor(lightlevel, rel, Colormap,1.0f); if (!(flags&GLWF_FOGGY)) { if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, false); diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 1b0c99053..c6cd3c5dd 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -384,7 +384,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) else { gl_SetDynSpriteLight(playermo, NULL); - gl_SetColor(statebright[i] ? 255 : lightlevel, 0, &cmc, trans, true); + gl_SetColor(statebright[i] ? 255 : lightlevel, 0, cmc, trans, true); } DrawPSprite(player, psp, psp->sx + ofsx, psp->sy + ofsy, hudModelStep, OverrideShader, !!(vis.RenderStyle.Flags & STYLEF_RedIsAlpha)); } From 4d005bdfa0aa769331241005f59b66130266d425 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 May 2014 14:45:41 +0200 Subject: [PATCH 0088/1509] shader rework All those special shaders have been merged together. Mostly working but the non-shader lighting seems a bit broken. --- src/gl/renderer/gl_colormap.h | 4 +- src/gl/renderer/gl_renderstate.cpp | 134 +++--- src/gl/renderer/gl_renderstate.h | 101 ++--- src/gl/scene/gl_scene.cpp | 2 + src/gl/scene/gl_sprite.cpp | 4 +- src/gl/scene/gl_weapon.cpp | 1 + src/gl/shaders/gl_shader.cpp | 405 +++++++----------- src/gl/shaders/gl_shader.h | 271 ++++++++---- src/gl/textures/gl_bitmap.cpp | 2 +- wadsrc/static/shaders/glsl/fogboundary.fp | 15 +- wadsrc/static/shaders/glsl/func_brightmap.fp | 11 +- .../static/shaders/glsl/func_defaultlight.fp | 5 + wadsrc/static/shaders/glsl/func_normal.fp | 5 +- wadsrc/static/shaders/glsl/func_notexture.fp | 4 +- wadsrc/static/shaders/glsl/func_warp1.fp | 4 +- wadsrc/static/shaders/glsl/func_warp2.fp | 4 +- wadsrc/static/shaders/glsl/func_wavex.fp | 4 +- wadsrc/static/shaders/glsl/fuzz_jagged.fp | 4 +- wadsrc/static/shaders/glsl/fuzz_noise.fp | 4 +- wadsrc/static/shaders/glsl/fuzz_smooth.fp | 4 +- .../static/shaders/glsl/fuzz_smoothnoise.fp | 4 +- .../shaders/glsl/fuzz_smoothtranslucent.fp | 4 +- wadsrc/static/shaders/glsl/fuzz_standard.fp | 4 +- wadsrc/static/shaders/glsl/fuzz_swirly.fp | 4 +- wadsrc/static/shaders/glsl/main.fp | 390 +++++++++-------- wadsrc/static/shaders/glsl/main.vp | 52 +-- wadsrc/static/shaders/glsl/main_colormap.fp | 51 --- wadsrc/static/shaders/glsl/main_foglayer.fp | 55 --- 28 files changed, 722 insertions(+), 830 deletions(-) create mode 100644 wadsrc/static/shaders/glsl/func_defaultlight.fp delete mode 100644 wadsrc/static/shaders/glsl/main_colormap.fp delete mode 100644 wadsrc/static/shaders/glsl/main_foglayer.fp diff --git a/src/gl/renderer/gl_colormap.h b/src/gl/renderer/gl_colormap.h index 7d2bdb7ee..8126cb5d4 100644 --- a/src/gl/renderer/gl_colormap.h +++ b/src/gl/renderer/gl_colormap.h @@ -15,13 +15,11 @@ enum EColorManipulation CM_DEFAULT=0, // untranslated CM_FIRSTSPECIALCOLORMAP, // first special fixed colormap - // special internal values for texture creation - CM_SHADE= 0x10000002, // alpha channel texture + CM_FOGLAYER = 0x10000000, // Sprite shaped fog layer // These are not to be passed to the texture manager CM_LITE = 0x20000000, // special values to handle these items without excessive hacking CM_TORCH= 0x20000010, // These are not real color manipulations - CM_FOGLAYER= 0x20000020, // Sprite shaped fog layer }; #define CM_MAXCOLORMAP int(CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size()) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 71198bafe..7efa1d30f 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -38,6 +38,7 @@ ** */ +#include "templates.h" #include "gl/system/gl_system.h" #include "gl/system/gl_interface.h" #include "gl/data/gl_data.h" @@ -51,7 +52,6 @@ void gl_SetTextureMode(int type); FRenderState gl_RenderState; -int FStateAttr::ChangeCounter; CVAR(Bool, gl_direct_state_change, true, 0) @@ -71,6 +71,7 @@ void FRenderState::Reset() mFogColor.d = ffFogColor.d = -1; mFogDensity = ffFogDensity = 0; mTextureMode = ffTextureMode = -1; + mDesaturation = 0; mSrcBlend = GL_SRC_ALPHA; mDstBlend = GL_ONE_MINUS_SRC_ALPHA; glSrcBlend = glDstBlend = -1; @@ -83,6 +84,7 @@ void FRenderState::Reset() m2D = true; mVertexBuffer = mCurrentVertexBuffer = NULL; mColormapState = CM_DEFAULT; + mLightParms[3] = -1.f; } @@ -128,11 +130,12 @@ bool FRenderState::ApplyShader() { activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect); } - FShaderContainer *shd = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4); + FShader *shd = GLRenderer->mShaderManager->Get(mTextureEnabled? mEffectState : 4); if (shd != NULL) { - activeShader = shd->Bind(mColormapState, mGlowEnabled, mWarpTime, mLightEnabled); + activeShader = shd; + shd->Bind(); } int fogset = 0; @@ -149,74 +152,93 @@ bool FRenderState::ApplyShader() } } - if (fogset != activeShader->currentfogenabled) - { - glUniform1i(activeShader->fogenabled_index, (activeShader->currentfogenabled = fogset)); - } - if (mTextureMode != activeShader->currenttexturemode) - { - glUniform1i(activeShader->texturemode_index, (activeShader->currenttexturemode = mTextureMode)); - } - if (activeShader->currentcamerapos.Update(&mCameraPos)) - { - glUniform3fv(activeShader->camerapos_index, 1, mCameraPos.vec); - } - /*if (mLightParms[0] != activeShader->currentlightfactor || - mLightParms[1] != activeShader->currentlightdist || - mFogDensity != activeShader->currentfogdensity)*/ - { - const float LOG2E = 1.442692f; // = 1/log(2) - //activeShader->currentlightdist = mLightParms[1]; - //activeShader->currentlightfactor = mLightParms[0]; - //activeShader->currentfogdensity = mFogDensity; - // premultiply the density with as much as possible here to reduce shader - // execution time. - glVertexAttrib4f(VATTR_FOGPARAMS, mLightParms[0], mLightParms[1], mFogDensity * (-LOG2E / 64000.f), 0); - } - if (mFogColor != activeShader->currentfogcolor) - { - activeShader->currentfogcolor = mFogColor; + glColor4fv(mColor.vec); + + activeShader->muDesaturation.Set(mDesaturation); + activeShader->muFogEnabled.Set(fogset); + activeShader->muTextureMode.Set(mTextureMode); + activeShader->muCameraPos.Set(mCameraPos.vec); + activeShader->muLightParms.Set(mLightParms); + activeShader->muFogColor.Set(mFogColor); + activeShader->muObjectColor.Set(mObjectColor); + activeShader->muDynLightColor.Set(mDynColor); - glUniform4f (activeShader->fogcolor_index, mFogColor.r/255.f, mFogColor.g/255.f, - mFogColor.b/255.f, 0); - } if (mGlowEnabled) { - glUniform4fv(activeShader->glowtopcolor_index, 1, mGlowTop.vec); - glUniform4fv(activeShader->glowbottomcolor_index, 1, mGlowBottom.vec); - glUniform4fv(activeShader->glowtopplane_index, 1, mGlowTopPlane.vec); - glUniform4fv(activeShader->glowbottomplane_index, 1, mGlowBottomPlane.vec); + activeShader->muGlowTopColor.Set(mGlowTop.vec); + activeShader->muGlowBottomColor.Set(mGlowBottom.vec); + activeShader->muGlowTopPlane.Set(mGlowTopPlane.vec); + activeShader->muGlowBottomPlane.Set(mGlowBottomPlane.vec); activeShader->currentglowstate = 1; } else if (activeShader->currentglowstate) { // if glowing is on, disable it. - glUniform4f(activeShader->glowtopcolor_index, 0.f, 0.f, 0.f, 0.f); - glUniform4f(activeShader->glowbottomcolor_index, 0.f, 0.f, 0.f, 0.f); + static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f }; + activeShader->muGlowTopColor.Set(nulvec); + activeShader->muGlowBottomColor.Set(nulvec); + activeShader->muGlowTopPlane.Set(nulvec); + activeShader->muGlowBottomPlane.Set(nulvec); activeShader->currentglowstate = 0; } if (mLightEnabled) { - glUniform3iv(activeShader->lightrange_index, 1, mNumLights); - glUniform4fv(activeShader->lights_index, mNumLights[2], mLightData); + activeShader->muLightRange.Set(mNumLights); + glUniform4fv(activeShader->lights_index, mNumLights[3], mLightData); } - if (mObjectColor != activeShader->currentobjectcolor) + else { - activeShader->currentobjectcolor = mObjectColor; - glUniform4f(activeShader->objectcolor_index, mObjectColor.r / 255.f, mObjectColor.g / 255.f, mObjectColor.b / 255.f, mObjectColor.a / 255.f); - } - if (mDynColor != activeShader->currentdlightcolor) - { - activeShader->currentobjectcolor = mObjectColor; - glUniform4f(activeShader->dlightcolor_index, mDynColor.r / 255.f, mDynColor.g / 255.f, mDynColor.b / 255.f, 0); + static const int nulint[] = { 0, 0, 0, 0 }; + activeShader->muLightRange.Set(nulint); } - if (glset.lightmode == 8) + if (mColormapState != activeShader->currentfixedcolormap) { - glVertexAttrib1f(VATTR_LIGHTLEVEL, mSoftLight / 255.f); - } + float r, g, b; + activeShader->currentfixedcolormap = mColormapState; + if (mColormapState == CM_DEFAULT) + { + activeShader->muFixedColormap.Set(0); + } + else if (mColormapState < CM_MAXCOLORMAP) + { + FSpecialColormap *scm = &SpecialColormaps[gl_fixedcolormap - CM_FIRSTSPECIALCOLORMAP]; + float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0], + scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f }; + activeShader->muFixedColormap.Set(1); + activeShader->muColormapStart.Set(scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f); + activeShader->muColormapRange.Set(m); + } + else if (mColormapState == CM_FOGLAYER) + { + activeShader->muFixedColormap.Set(3); + } + else if (mColormapState == CM_LITE) + { + if (gl_enhanced_nightvision) + { + r = 0.375f, g = 1.0f, b = 0.375f; + } + else + { + r = g = b = 1.f; + } + activeShader->muFixedColormap.Set(2); + activeShader->muColormapStart.Set(r, g, b, 1.f); + } + else if (mColormapState >= CM_TORCH) + { + int flicker = mColormapState - CM_TORCH; + r = (0.8f + (7 - flicker) / 70.0f); + if (r > 1.0f) r = 1.0f; + b = g = r; + if (gl_enhanced_nightvision) b = g * 0.75f; + activeShader->muFixedColormap.Set(2); + activeShader->muColormapStart.Set(r, g, b, 1.f); + } + } return true; } return false; @@ -326,6 +348,14 @@ void FRenderState::Apply(bool forcenoshader) } ffSpecialEffect = mSpecialEffect; } + // Now compose the final color for this... + float realcolor[4]; + realcolor[0] = clamp((mColor.vec[0] + mDynColor.r / 255.f), 0.f, 1.f) * (mObjectColor.r / 255.f); + realcolor[1] = clamp((mColor.vec[1] + mDynColor.g / 255.f), 0.f, 1.f) * (mObjectColor.g / 255.f); + realcolor[2] = clamp((mColor.vec[2] + mDynColor.b / 255.f), 0.f, 1.f) * (mObjectColor.b / 255.f); + realcolor[3] = mColor.vec[3] * (mObjectColor.a / 255.f); + glColor4fv(realcolor); + } } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 5308da42b..e8de712f6 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -3,6 +3,7 @@ #include #include "gl/system/gl_interface.h" +#include "gl/data/gl_data.h" #include "c_cvars.h" #include "r_defs.h" @@ -10,81 +11,29 @@ class FVertexBuffer; EXTERN_CVAR(Bool, gl_direct_state_change) -struct FStateAttr -{ - static int ChangeCounter; - int mLastChange; - - FStateAttr() - { - mLastChange = -1; - } - - bool operator == (const FStateAttr &other) - { - return mLastChange == other.mLastChange; - } - - bool operator != (const FStateAttr &other) - { - return mLastChange != other.mLastChange; - } - -}; - -struct FStateVec3 : public FStateAttr -{ - float vec[3]; - - bool Update(FStateVec3 *other) - { - if (mLastChange != other->mLastChange) - { - *this = *other; - return true; - } - return false; - } - - void Set(float x, float y, float z) - { - vec[0] = x; - vec[1] = z; - vec[2] = y; - mLastChange = ++ChangeCounter; - } -}; - -struct FStateVec4 : public FStateAttr +struct FStateVec4 { float vec[4]; - bool Update(FStateVec4 *other) - { - if (mLastChange != other->mLastChange) - { - *this = *other; - return true; - } - return false; - } - void Set(float r, float g, float b, float a) { vec[0] = r; vec[1] = g; vec[2] = b; vec[3] = a; - mLastChange = ++ChangeCounter; } }; enum EEffect { - EFF_NONE, + EFF_NONE=-1, EFF_FOGBOUNDARY, EFF_SPHEREMAP, + EFF_BURN, + EFF_STENCIL, + + MAX_EFFECTS }; class FRenderState @@ -96,9 +45,10 @@ class FRenderState bool mBrightmapEnabled; int mSpecialEffect; int mTextureMode; + int mDesaturation; int mSoftLight; - float mLightParms[2]; - int mNumLights[3]; + float mLightParms[4]; + int mNumLights[4]; float *mLightData; int mSrcBlend, mDstBlend; int mAlphaFunc; @@ -109,7 +59,7 @@ class FRenderState FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; FStateVec4 mColor; - FStateVec3 mCameraPos; + FStateVec4 mCameraPos; FStateVec4 mGlowTop, mGlowBottom; FStateVec4 mGlowTopPlane, mGlowBottomPlane; PalEntry mFogColor; @@ -155,25 +105,25 @@ public: void SetColor(float r, float g, float b, float a = 1.f, int desat = 0) { mColor.Set(r, g, b, a); - glColor4fv(mColor.vec); + mDesaturation = desat; } void SetColor(PalEntry pe, int desat = 0) { mColor.Set(pe.r/255.f, pe.g/255.f, pe.b/255.f, pe.a/255.f); - glColor4fv(mColor.vec); + mDesaturation = desat; } void SetColorAlpha(PalEntry pe, float alpha = 1.f, int desat = 0) { mColor.Set(pe.r/255.f, pe.g/255.f, pe.b/255.f, alpha); - glColor4fv(mColor.vec); + mDesaturation = desat; } void ResetColor() { mColor.Set(1,1,1,1); - glColor4fv(mColor.vec); + mDesaturation = 0; } void SetTextureMode(int mode) @@ -213,7 +163,7 @@ public: void SetCameraPos(float x, float y, float z) { - mCameraPos.Set(x,y,z); + mCameraPos.Set(x, z, y, 0); } void SetGlowParams(float *t, float *b) @@ -224,7 +174,8 @@ public: void SetSoftLightLevel(int level) { - mSoftLight = level; + if (glset.lightmode == 8) mLightParms[3] = level / 255.f; + else mLightParms[3] = -1.f; } void SetGlowPlanes(const secplane_t &top, const secplane_t &bottom) @@ -235,7 +186,7 @@ public: void SetDynLight(float r, float g, float b) { - mDynColor = PalEntry(xs_CRoundToInt(r*255), xs_CRoundToInt(g*255), xs_CRoundToInt(b*255)); + mDynColor = PalEntry(255, xs_CRoundToInt(r*255), xs_CRoundToInt(g*255), xs_CRoundToInt(b*255)); } void SetDynLight(PalEntry pe) @@ -250,21 +201,23 @@ public: void SetFog(PalEntry c, float d) { + const float LOG2E = 1.442692f; // = 1/log(2) mFogColor = c; - if (d >= 0.0f) mFogDensity = d; + if (d >= 0.0f) mLightParms[2] = d * (-LOG2E / 64000.f); } void SetLightParms(float f, float d) { - mLightParms[0] = f; - mLightParms[1] = d; + mLightParms[1] = f; + mLightParms[0] = d; } void SetLights(int *numlights, float *lightdata) { - mNumLights[0] = numlights[0]; - mNumLights[1] = numlights[1]; - mNumLights[2] = numlights[2]; + mNumLights[0] = 0; + mNumLights[1] = numlights[0]; + mNumLights[2] = numlights[1]; + mNumLights[3] = numlights[2]; mLightData = lightdata; // caution: the data must be preserved by the caller until the 'apply' call! } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 3804ea048..8670c1d49 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -842,6 +842,7 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) DrawPlayerSprites (viewsector, false); } gl_RenderState.SetFixedColormap(CM_DEFAULT); + gl_RenderState.SetSoftLightLevel(-1); DrawTargeterSprites(); DrawBlend(viewsector); @@ -1059,6 +1060,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei FieldOfView * 360.0f / FINEANGLES, 1.6f, 1.6f, true, false); glDisable(GL_STENCIL_TEST); gl_RenderState.SetFixedColormap(CM_DEFAULT); + gl_RenderState.SetSoftLightLevel(-1); screen->Begin2D(false); DrawBlend(viewsector); glFlush(); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 41e94a73b..84ecbf0a1 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -287,7 +287,7 @@ void GLSprite::Draw(int pass) { // If we get here we know that we have colored fog and no fixed colormap. gl_SetFog(foglevel, rel, &Colormap, additivefog); - //gl_RenderState.SetFixedColormap(CM_FOGLAYER); fixme: does not work yet. + gl_RenderState.SetFixedColormap(CM_FOGLAYER); gl_RenderState.BlendEquation(GL_FUNC_ADD); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.Apply(); @@ -308,7 +308,7 @@ void GLSprite::Draw(int pass) glVertex3fv(&v4[0]); } glEnd(); - + gl_RenderState.SetFixedColormap(CM_DEFAULT); } } else diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index c6cd3c5dd..6991bed5c 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -283,6 +283,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) } PalEntry ThingColor = (playermo->RenderStyle.Flags & STYLEF_ColorIsFixed) ? playermo->fillcolor : 0xffffff; + ThingColor.a = 255; visstyle_t vis; diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index a132e65dd..35916bd00 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -57,17 +57,6 @@ #include "gl/shaders/gl_shader.h" #include "gl/textures/gl_material.h" -// these will only have an effect on SM3 cards. -// For SM4 they are always on and for SM2 always off -CVAR(Bool, gl_warp_shader, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) -CVAR(Bool, gl_fog_shader, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) -CVAR(Bool, gl_colormap_shader, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) -CVAR(Bool, gl_brightmap_shader, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) -CVAR(Bool, gl_glow_shader, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) - - -extern long gl_frameMS; - //========================================================================== // // @@ -81,6 +70,10 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * if (gl.hasGLSL()) { + int i_lump = Wads.CheckNumForFullName("shaders/glsl/shaderdefs.i"); + if (i_lump == -1) I_Error("Unable to load 'shaders/glsl/shaderdefs.i'"); + FMemLump i_data = Wads.ReadLump(i_lump); + int vp_lump = Wads.CheckNumForFullName(vert_prog_lump); if (vp_lump == -1) I_Error("Unable to load '%s'", vert_prog_lump); FMemLump vp_data = Wads.ReadLump(vp_lump); @@ -90,12 +83,18 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * FMemLump fp_data = Wads.ReadLump(fp_lump); - FString vp_comb; - FString fp_comb; - vp_comb = defines; - fp_comb = vp_comb; - // This uses GetChars on the strings to get rid of terminating 0 characters. + // + // The following code uses GetChars on the strings to get rid of terminating 0 characters. Do not remove or the code may break! + // + + FString vp_comb = "#version 130\n"; + if (gl.glslversion >= 3.3f) vp_comb = "#version 330 compatibility\n"; // I can't shut up the deprecation warnings in GLSL 1.3 so if available use a version with compatibility profile. + // todo when using shader storage buffers, add + // "#version 400 compatibility\n#extension GL_ARB_shader_storage_buffer_object : require\n" instead. + vp_comb << defines << i_data.GetString().GetChars(); + FString fp_comb = vp_comb; + vp_comb << vp_data.GetString().GetChars() << "\n"; fp_comb << fp_data.GetString().GetChars() << "\n"; @@ -107,12 +106,27 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * if (pp_lump == -1) I_Error("Unable to load '%s'", proc_prog_lump); FMemLump pp_data = Wads.ReadLump(pp_lump); + if (pp_data.GetString().IndexOf("ProcessTexel") < 0) + { + // this looks like an old custom hardware shader. + // We need to replace the ProcessTexel call to make it work. + + fp_comb.Substitute("vec4 frag = ProcessTexel();", "vec4 frag = Process(vec4(1.0));"); + } fp_comb << pp_data.GetString().GetChars(); + + if (pp_data.GetString().IndexOf("ProcessLight") < 0) + { + int pl_lump = Wads.CheckNumForFullName("shaders/glsl/func_defaultlight.fp"); + if (pl_lump == -1) I_Error("Unable to load '%s'", "shaders/glsl/func_defaultlight.fp"); + FMemLump pl_data = Wads.ReadLump(pl_lump); + fp_comb << "\n" << pl_data.GetString().GetChars(); + } } - else + else { // Proc_prog_lump is not a lump name but the source itself (from generated shaders) - fp_comb << proc_prog_lump+1; + fp_comb << proc_prog_lump + 1; } } @@ -137,9 +151,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * glAttachShader(hShader, hVertProg); glAttachShader(hShader, hFragProg); - glBindAttribLocation(hShader, VATTR_FOGPARAMS, "fogparams"); - glBindAttribLocation(hShader, VATTR_LIGHTLEVEL, "lightlevel_in"); // Korshun. - glLinkProgram(hShader); glGetShaderInfoLog(hVertProg, 10000, NULL, buffer); @@ -159,30 +170,34 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * error << "Linking:\n" << buffer << "\n"; } int linked; - glGetShaderiv(hShader, GL_LINK_STATUS, &linked); + glGetProgramiv(hShader, GL_LINK_STATUS, &linked); if (linked == 0) { // only print message if there's an error. - Printf("Init Shader '%s':\n%s\n", name, error.GetChars()); + I_Error("Init Shader '%s':\n%s\n", name, error.GetChars()); } - timer_index = glGetUniformLocation(hShader, "timer"); - desaturation_index = glGetUniformLocation(hShader, "desaturation_factor"); - fogenabled_index = glGetUniformLocation(hShader, "fogenabled"); - texturemode_index = glGetUniformLocation(hShader, "texturemode"); - camerapos_index = glGetUniformLocation(hShader, "camerapos"); - lightparms_index = glGetUniformLocation(hShader, "lightparms"); - colormapstart_index = glGetUniformLocation(hShader, "colormapstart"); - colormaprange_index = glGetUniformLocation(hShader, "colormaprange"); - lightrange_index = glGetUniformLocation(hShader, "lightrange"); - fogcolor_index = glGetUniformLocation(hShader, "fogcolor"); - lights_index = glGetUniformLocation(hShader, "lights"); - dlightcolor_index = glGetUniformLocation(hShader, "dlightcolor"); - objectcolor_index = glGetUniformLocation(hShader, "objectcolor"); - glowbottomcolor_index = glGetUniformLocation(hShader, "bottomglowcolor"); - glowtopcolor_index = glGetUniformLocation(hShader, "topglowcolor"); - glowbottomplane_index = glGetUniformLocation(hShader, "glowbottomplane"); - glowtopplane_index = glGetUniformLocation(hShader, "glowtopplane"); + + muDesaturation.Init(hShader, "uDesaturationFactor"); + muFogEnabled.Init(hShader, "uFogEnabled"); + muTextureMode.Init(hShader, "uTextureMode"); + muCameraPos.Init(hShader, "uCameraPos"); + muLightParms.Init(hShader, "uLightAttr"); + muColormapStart.Init(hShader, "uFixedColormapStart"); + muColormapRange.Init(hShader, "uFixedColormapRange"); + muLightRange.Init(hShader, "uLightRange"); + muFogColor.Init(hShader, "uFogColor"); + muDynLightColor.Init(hShader, "uDynLightColor"); + muObjectColor.Init(hShader, "uObjectColor"); + muGlowBottomColor.Init(hShader, "uGlowBottomColor"); + muGlowTopColor.Init(hShader, "uGlowTopColor"); + muGlowBottomPlane.Init(hShader, "uGlowBottomPlane"); + muGlowTopPlane.Init(hShader, "uGlowTopPlane"); + muFixedColormap.Init(hShader, "uFixedColormap"); + + timer_index = glGetUniformLocation(hShader, "timer"); + lights_index = glGetUniformLocation(hShader, "lights"); + glUseProgram(hShader); @@ -203,9 +218,12 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * FShader::~FShader() { - glDeleteProgram(hShader); - glDeleteShader(hVertProg); - glDeleteShader(hFragProg); + if (gl.hasGLSL()) + { + glDeleteProgram(hShader); + glDeleteShader(hVertProg); + glDeleteShader(hFragProg); + } } @@ -215,202 +233,41 @@ FShader::~FShader() // //========================================================================== -bool FShader::Bind(float Speed) +bool FShader::Bind() { GLRenderer->mShaderManager->SetActiveShader(this); - if (timer_index >=0 && Speed > 0.f) glUniform1f(timer_index, gl_frameMS*Speed/1000.f); return true; } //========================================================================== // -// +// Since all shaders are REQUIRED, any error here needs to be fatal // //========================================================================== -FShaderContainer::FShaderContainer(const char *ShaderName, const char *ShaderPath) +FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath) { - const char * shaderdefines[] = { - "#define NO_GLOW\n#define NO_DESATURATE\n", - "#define NO_DESATURATE\n", - "#define NO_GLOW\n", - "\n", - "#define NO_GLOW\n#define NO_DESATURATE\n#define DYNLIGHT\n", - "#define NO_DESATURATE\n#define DYNLIGHT\n", - "#define NO_GLOW\n#define DYNLIGHT\n", - "\n#define DYNLIGHT\n", - "#define NO_GLOW\n#define NO_DESATURATE\n#define SOFTLIGHT\n", - "#define NO_DESATURATE\n#define SOFTLIGHT\n", - "#define NO_GLOW\n#define SOFTLIGHT\n", - "\n#define SOFTLIGHT\n", - "#define NO_GLOW\n#define NO_DESATURATE\n#define DYNLIGHT\n#define SOFTLIGHT\n", - "#define NO_DESATURATE\n#define DYNLIGHT\n#define SOFTLIGHT\n", - "#define NO_GLOW\n#define DYNLIGHT\n#define SOFTLIGHT\n", - "\n#define DYNLIGHT\n#define SOFTLIGHT\n" - }; - - const char * shaderdesc[] = { - "::default", - "::glow", - "::desaturate", - "::glow+desaturate", - "::default+dynlight", - "::glow+dynlight", - "::desaturate+dynlight", - "::glow+desaturate+dynlight", - "::softlight", - "::glow+softlight", - "::desaturate+softlight", - "::glow+desaturate+softlight", - "::default+dynlight+softlight", - "::glow+dynlight+softlight", - "::desaturate+dynlight+softlight", - "::glow+desaturate+dynlight+softlight", - }; - - FString name; - - name << ShaderName << "::colormap"; + // this can't be in the shader code due to ATI strangeness. + const char *str = (gl.MaxLights() == 128)? "#define MAXLIGHTS128\n" : ""; + FShader *shader = NULL; try { - shader_cm = new FShader; - if (!shader_cm->Load(name, "shaders/glsl/main.vp", "shaders/glsl/main_colormap.fp", ShaderPath, "#define NO_FOG\n#define NO_GLOW\n")) + shader = new FShader(ShaderName); + if (!shader->Load(ShaderName, "shaders/glsl/main.vp", "shaders/glsl/main.fp", ShaderPath, str)) { - delete shader_cm; - shader_cm = NULL; + I_Error("Unable to load shader %s\n", ShaderName); } } catch(CRecoverableError &err) { - shader_cm = NULL; - I_Error("Unable to load shader %s:\n%s\n", name.GetChars(), err.GetMessage()); - } - - name << ShaderName << "::foglayer"; - - try - { - shader_fl = new FShader; - if (!shader_fl->Load(name, "shaders/glsl/main.vp", "shaders/glsl/main_foglayer.fp", ShaderPath, "#define NO_GLOW\n")) - { - delete shader_fl; - shader_fl = NULL; - } - } - catch (CRecoverableError &err) - { - shader_fl = NULL; - I_Error("Unable to load shader %s:\n%s\n", name.GetChars(), err.GetMessage()); - } - - for(int i = 0;i < NUM_SHADERS; i++) - { - FString name; - - name << ShaderName << shaderdesc[i]; - - try - { - FString str; - if ((i&4) != 0) - { - if (gl.maxuniforms < 1024) - { - shader[i] = NULL; - continue; - } - // this can't be in the shader code due to ATI strangeness. - str = "#version 120\n#extension GL_EXT_gpu_shader4 : enable\n"; - if (gl.MaxLights() == 128) str += "#define MAXLIGHTS128\n"; - } - str += shaderdefines[i]; - shader[i] = new FShader; - if (!shader[i]->Load(name, "shaders/glsl/main.vp", "shaders/glsl/main.fp", ShaderPath, str.GetChars())) - { - delete shader[i]; - shader[i] = NULL; - } - } - catch(CRecoverableError &err) - { - shader[i] = NULL; - I_Error("Unable to load shader %s:\n%s\n", name.GetChars(), err.GetMessage()); - } + if (shader != NULL) delete shader; + shader = NULL; + I_Error("Unable to load shader %s:\n%s\n", ShaderName, err.GetMessage()); } + return shader; } -//========================================================================== -// -// -// -//========================================================================== -FShaderContainer::~FShaderContainer() -{ - if (shader_cm != NULL) delete shader_cm; - if (shader_fl != NULL) delete shader_fl; - for (int i = 0; i < NUM_SHADERS; i++) - { - if (shader[i] != NULL) - { - delete shader[i]; - shader[i] = NULL; - } - } -} - -//========================================================================== -// -// -// -//========================================================================== - -FShader *FShaderContainer::Bind(int cm, bool glowing, float Speed, bool lights) -{ - FShader *sh=NULL; - - if (cm == CM_FOGLAYER) - { - if (shader_fl) - { - shader_fl->Bind(Speed); - } - return shader_fl; - } - else if (cm >= CM_FIRSTSPECIALCOLORMAP && cm < CM_MAXCOLORMAP) - { - // these are never used with any kind of lighting or fog - sh = shader_cm; - // [BB] If there was a problem when loading the shader, sh is NULL here. - if( sh ) - { - FSpecialColormap *map = &SpecialColormaps[cm - CM_FIRSTSPECIALCOLORMAP]; - sh->Bind(Speed); - float m[3]= {map->ColorizeEnd[0] - map->ColorizeStart[0], - map->ColorizeEnd[1] - map->ColorizeStart[1], map->ColorizeEnd[2] - map->ColorizeStart[2]}; - - glUniform3fv(sh->colormapstart_index, 1, map->ColorizeStart); - glUniform3fv(sh->colormaprange_index, 1, m); - } - } - else - { - bool desat = false;// cm >= CM_DESAT1 && cm <= CM_DESAT31; - sh = shader[glowing + 2*desat + 4*lights + (glset.lightmode & 8)]; - // [BB] If there was a problem when loading the shader, sh is NULL here. - if( sh ) - { - sh->Bind(Speed); - if (desat) - { - //glUniform1f(sh->desaturation_index, 1.f-float(cm-CM_DESAT0)/(CM_DESAT31-CM_DESAT0)); - } - } - } - return sh; -} - - //========================================================================== // // @@ -454,8 +311,10 @@ struct FEffectShader static const FEffectShader effectshaders[]= { - {"fogboundary", "shaders/glsl/main.vp", "shaders/glsl/fogboundary.fp", NULL, "#define NO_GLOW\n"}, - {"spheremap", "shaders/glsl/main.vp", "shaders/glsl/main.fp", "shaders/glsl/func_normal.fp", "#define NO_GLOW\n#define NO_DESATURATE\n#define SPHEREMAP\n#define SPHEREMAP_0\n"} + { "fogboundary", "shaders/glsl/main.vp", "shaders/glsl/fogboundary.fp", NULL, "" }, + { "spheremap", "shaders/glsl/main.vp", "shaders/glsl/main.fp", "shaders/glsl/func_normal.fp", "#define SPHEREMAP\n" }, + { "burn", "shaders/glsl/burn.vp", "shaders/glsl/burn.fp", NULL, "" }, + { "stencil", "shaders/glsl/stencil.vp", "shaders/glsl/stencil.fp", NULL, "" }, }; @@ -489,35 +348,46 @@ FShaderManager::~FShaderManager() void FShaderManager::CompileShaders() { - mActiveShader = mEffectShaders[0] = mEffectShaders[1] = NULL; - if (gl.hasGLSL()) + try { - for(int i=0;defaultshaders[i].ShaderName != NULL;i++) + mActiveShader = mEffectShaders[0] = mEffectShaders[1] = NULL; + if (gl.hasGLSL()) { - FShaderContainer * shc = new FShaderContainer(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc); - mTextureEffects.Push(shc); - } - - for(unsigned i = 0; i < usershaders.Size(); i++) - { - FString name = ExtractFileBase(usershaders[i]); - FName sfn = name; - - FShaderContainer * shc = new FShaderContainer(sfn, usershaders[i]); - mTextureEffects.Push(shc); - } - - for(int i=0;iLoad(effectshaders[i].ShaderName, effectshaders[i].vp, effectshaders[i].fp1, - effectshaders[i].fp2, effectshaders[i].defines)) + for (int i = 0; defaultshaders[i].ShaderName != NULL; i++) { - delete eff; + FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc); + mTextureEffects.Push(shc); + } + + for (unsigned i = 0; i < usershaders.Size(); i++) + { + FString name = ExtractFileBase(usershaders[i]); + FName sfn = name; + + FShader *shc = Compile(sfn, usershaders[i]); + mTextureEffects.Push(shc); + } + + for (int i = 0; i < MAX_EFFECTS; i++) + { + FShader *eff = new FShader(effectshaders[i].ShaderName); + if (!eff->Load(effectshaders[i].ShaderName, effectshaders[i].vp, effectshaders[i].fp1, + effectshaders[i].fp2, effectshaders[i].defines)) + { + delete eff; + } + else mEffectShaders[i] = eff; } - else mEffectShaders[i] = eff; } } + catch (CRecoverableError &err) + { + // If shader compilation failed we can still run the fixed function mode so do that instead of aborting. + Printf("%s\n", err.GetMessage()); + Printf(PRINT_HIGH, "Failed to compile shaders. Reverting to fixed function mode\n"); + gl_usevbo = false; + gl.glslversion = 0.0; + } } //========================================================================== @@ -528,17 +398,22 @@ void FShaderManager::CompileShaders() void FShaderManager::Clean() { - SetActiveShader(NULL); - for(unsigned int i=0;iName == sfn) + if (mTextureEffects[i]->mName == sfn) { return i; } @@ -569,26 +444,42 @@ int FShaderManager::Find(const char * shn) void FShaderManager::SetActiveShader(FShader *sh) { - // shadermodel needs to be tested here because without it UseProgram will be NULL. if (gl.hasGLSL() && mActiveShader != sh) { - glUseProgram(sh == NULL? 0 : sh->GetHandle()); + glUseProgram(sh!= NULL? sh->GetHandle() : NULL); mActiveShader = sh; } } + //========================================================================== // +// To avoid maintenance this will be set when a warped texture is bound +// because at that point the draw buffer needs to be flushed anyway. // +//========================================================================== + +void FShaderManager::SetWarpSpeed(unsigned int eff, float speed) +{ + // indices 0-2 match the warping modes, 3 is brightmap, 4 no texture, the following are custom + if (eff < mTextureEffects.Size()) + { + FShader *sh = mTextureEffects[eff]; + + float warpphase = gl_frameMS * speed / 1000.f; + glProgramUniform1f(sh->GetHandle(), sh->timer_index, warpphase); + } +} + // //========================================================================== FShader *FShaderManager::BindEffect(int effect) { - if (effect > 0 && effect <= NUM_EFFECTS && mEffectShaders[effect-1] != NULL) + if (effect >= 0 && effect < MAX_EFFECTS && mEffectShaders[effect] != NULL) { - mEffectShaders[effect-1]->Bind(0); - return mEffectShaders[effect-1]; + mEffectShaders[effect]->Bind(); + return mEffectShaders[effect]; } return NULL; } diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 62c87c1f9..3497ed3b0 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -7,80 +7,198 @@ extern bool gl_shaderactive; -const int VATTR_FOGPARAMS = 14; -const int VATTR_LIGHTLEVEL = 13; // Korshun. +//========================================================================== +// +// +//========================================================================== + +class FUniform1i +{ + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + } + + void Set(int newvalue) + { + glUniform1i(mIndex, newvalue); + } +}; + +class FBufferedUniform1i +{ + int mBuffer; + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + mBuffer = 0; + } + + void Set(int newvalue) + { + if (newvalue != mBuffer) + { + mBuffer = newvalue; + glUniform1i(mIndex, newvalue); + } + } +}; + +class FBufferedUniform4i +{ + int mBuffer[4]; + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + memset(mBuffer, 0, sizeof(mBuffer)); + } + + void Set(const int *newvalue) + { + if (memcmp(newvalue, mBuffer, sizeof(mBuffer))) + { + memcpy(mBuffer, newvalue, sizeof(mBuffer)); + glUniform4iv(mIndex, 1, newvalue); + } + } +}; + +class FBufferedUniform1f +{ + int mBuffer; + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + mBuffer = 0; + } + + void Set(float newvalue) + { + if (newvalue != mBuffer) + { + mBuffer = newvalue; + glUniform1f(mIndex, newvalue); + } + } +}; + +class FBufferedUniform4f +{ + float mBuffer[4]; + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + memset(mBuffer, 0, sizeof(mBuffer)); + } + + void Set(const float *newvalue) + { + if (memcmp(newvalue, mBuffer, sizeof(mBuffer))) + { + memcpy(mBuffer, newvalue, sizeof(mBuffer)); + glUniform4fv(mIndex, 1, newvalue); + } + } +}; + +class FUniform4f +{ + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + } + + void Set(const float *newvalue) + { + glUniform4fv(mIndex, 1, newvalue); + } + + void Set(float a, float b, float c, float d) + { + glUniform4f(mIndex, a, b, c, d); + } +}; + +class FBufferedUniformPE +{ + PalEntry mBuffer; + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + mBuffer = 0; + } + + void Set(PalEntry newvalue) + { + if (newvalue != mBuffer) + { + mBuffer = newvalue; + glUniform4f(mIndex, newvalue.r/255.f, newvalue.g/255.f, newvalue.b/255.f, newvalue.a/255.f); + } + } +}; -//========================================================================== -// -// -//========================================================================== class FShader { - friend class FShaderContainer; + friend class FShaderManager; friend class FRenderState; unsigned int hShader; unsigned int hVertProg; unsigned int hFragProg; + FName mName; + FBufferedUniform1f muDesaturation; + FBufferedUniform1i muFogEnabled; + FBufferedUniform1i muTextureMode; + FBufferedUniform4f muCameraPos; + FBufferedUniform4f muLightParms; + FUniform1i muFixedColormap; + FUniform4f muColormapStart; + FUniform4f muColormapRange; + FBufferedUniform4i muLightRange; + FBufferedUniformPE muFogColor; + FBufferedUniformPE muDynLightColor; + FBufferedUniformPE muObjectColor; + FUniform4f muGlowBottomColor; + FUniform4f muGlowTopColor; + FUniform4f muGlowBottomPlane; + FUniform4f muGlowTopPlane; + int timer_index; - int desaturation_index; - int fogenabled_index; - int texturemode_index; - int camerapos_index; - int lightparms_index; - int colormapstart_index; - int colormaprange_index; - int lightrange_index; - int fogcolor_index; int lights_index; - int dlightcolor_index; - int glowbottomcolor_index; - int glowtopcolor_index; - int glowbottomplane_index; - int glowtopplane_index; - int objectcolor_index; - - PalEntry currentdlightcolor; - PalEntry currentobjectcolor; int currentglowstate; - int currentfogenabled; - int currenttexturemode; - float currentlightfactor; - float currentlightdist; - - PalEntry currentfogcolor; - float currentfogdensity; - - FStateVec3 currentcamerapos; + int currentfixedcolormap; public: - FShader() + FShader(const char *name) + : mName(name) { hShader = hVertProg = hFragProg = 0; - currentglowstate = currentfogenabled = currenttexturemode = 0; - currentlightfactor = currentlightdist = 0.0f; - currentfogdensity = -1; - currentdlightcolor = currentobjectcolor = currentfogcolor = 0; - - timer_index = -1; - desaturation_index = -1; - fogenabled_index = -1; - texturemode_index = -1; - camerapos_index = -1; - lightparms_index = -1; - colormapstart_index = -1; - colormaprange_index = -1; - lightrange_index = -1; - fogcolor_index = -1; - lights_index = -1; - dlightcolor_index = -1; - objectcolor_index = -1; - glowtopplane_index = -1; - glowbottomplane_index = -1; - glowtopcolor_index = -1; - glowbottomcolor_index = -1; + currentglowstate = 0; + currentfixedcolormap = 0; } ~FShader(); @@ -91,34 +209,10 @@ public: void SetGlowParams(float *topcolors, float topheight, float *bottomcolors, float bottomheight); void SetLightRange(int start, int end, int forceadd); - bool Bind(float Speed); + bool Bind(); unsigned int GetHandle() const { return hShader; } -}; -//========================================================================== -// -// This class contains the shaders for the different lighting modes -// that are required (e.g. special colormaps etc.) -// -//========================================================================== - -class FShaderContainer -{ - friend class FShaderManager; - - FName Name; - - enum { NUM_SHADERS = 16 }; - - FShader *shader[NUM_SHADERS]; - FShader *shader_cm; // the shader for fullscreen colormaps - FShader *shader_fl; // the shader for the fog layer - -public: - FShaderContainer(const char *ShaderName, const char *ShaderPath); - ~FShaderContainer(); - FShader *Bind(int cm, bool glowing, float Speed, bool lights); }; @@ -129,14 +223,9 @@ public: //========================================================================== class FShaderManager { - enum - { - NUM_EFFECTS = 2 - }; - - TArray mTextureEffects; + TArray mTextureEffects; FShader *mActiveShader; - FShader *mEffectShaders[NUM_EFFECTS]; + FShader *mEffectShaders[MAX_EFFECTS]; void Clean(); void CompileShaders(); @@ -144,11 +233,13 @@ class FShaderManager public: FShaderManager(); ~FShaderManager(); + FShader *Compile(const char *ShaderName, const char *ShaderPath); int Find(const char *mame); FShader *BindEffect(int effect); void SetActiveShader(FShader *sh); + void SetWarpSpeed(unsigned int eff, float speed); - FShaderContainer *Get(unsigned int eff) + FShader *Get(unsigned int eff) { // indices 0-2 match the warping modes, 3 is brightmap, 4 no texture, the following are custom if (eff < mTextureEffects.Size()) diff --git a/src/gl/textures/gl_bitmap.cpp b/src/gl/textures/gl_bitmap.cpp index 51e03aa98..83a92e0fe 100644 --- a/src/gl/textures/gl_bitmap.cpp +++ b/src/gl/textures/gl_bitmap.cpp @@ -136,7 +136,7 @@ void FGLBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int { BYTE *buffer = GetPixels() + 4*originx + Pitch*originy; - // CM_SHADE is an alpha map with 0==transparent and 1==opaque + // alpha map with 0==transparent and 1==opaque if (alphatex) { for(int i=0;i<256;i++) diff --git a/wadsrc/static/shaders/glsl/fogboundary.fp b/wadsrc/static/shaders/glsl/fogboundary.fp index 5ab8ac717..0d4fb9a0d 100644 --- a/wadsrc/static/shaders/glsl/fogboundary.fp +++ b/wadsrc/static/shaders/glsl/fogboundary.fp @@ -1,8 +1,5 @@ -uniform int fogenabled; -uniform vec4 fogcolor; -uniform vec3 camerapos; -varying vec4 pixelpos; -varying vec4 fogparm; +in vec4 pixelpos; +in vec2 glowdist; //=========================================================================== // @@ -18,15 +15,15 @@ void main() // // calculate fog factor // - if (fogenabled == -1) + if (uFogEnabled == -1) { fogdist = pixelpos.w; } else { - fogdist = max(16.0, distance(pixelpos.xyz, camerapos)); + fogdist = max(16.0, distance(pixelpos.xyz, uCameraPos.xyz)); } - fogfactor = exp2 (fogparm.z * fogdist); - gl_FragColor = vec4(fogcolor.rgb, 1.0 - fogfactor); + fogfactor = exp2 (uFogDensity * fogdist); + gl_FragColor = vec4(uFogColor.rgb, 1.0 - fogfactor); } diff --git a/wadsrc/static/shaders/glsl/func_brightmap.fp b/wadsrc/static/shaders/glsl/func_brightmap.fp index e8ad0bb3d..b8b2a9f20 100644 --- a/wadsrc/static/shaders/glsl/func_brightmap.fp +++ b/wadsrc/static/shaders/glsl/func_brightmap.fp @@ -1,9 +1,12 @@ uniform sampler2D texture2; -vec4 Process(vec4 color) +vec4 ProcessTexel() { - vec4 brightpix = desaturate(texture2D(texture2, gl_TexCoord[0].st)); - vec4 texel = getTexel(gl_TexCoord[0].st); - return vec4(texel.rgb * min (color.rgb + brightpix.rgb, 1.0), texel.a*color.a); + return getTexel(gl_TexCoord[0].st); } +vec4 ProcessLight(vec4 color) +{ + vec4 brightpix = desaturate(texture2D(texture2, gl_TexCoord[0].st)); + return vec4(min (color.rgb + brightpix.rgb, 1.0), color.a); +} diff --git a/wadsrc/static/shaders/glsl/func_defaultlight.fp b/wadsrc/static/shaders/glsl/func_defaultlight.fp new file mode 100644 index 000000000..227d38c6a --- /dev/null +++ b/wadsrc/static/shaders/glsl/func_defaultlight.fp @@ -0,0 +1,5 @@ + +vec4 ProcessLight(vec4 color) +{ + return color; +} diff --git a/wadsrc/static/shaders/glsl/func_normal.fp b/wadsrc/static/shaders/glsl/func_normal.fp index f9297ca6f..d3b0d182c 100644 --- a/wadsrc/static/shaders/glsl/func_normal.fp +++ b/wadsrc/static/shaders/glsl/func_normal.fp @@ -1,7 +1,6 @@ -vec4 Process(vec4 color) +vec4 ProcessTexel() { - vec4 pix = getTexel(gl_TexCoord[0].st); - return pix * color; + return getTexel(gl_TexCoord[0].st); } diff --git a/wadsrc/static/shaders/glsl/func_notexture.fp b/wadsrc/static/shaders/glsl/func_notexture.fp index 904d4a6cd..9337ad6b1 100644 --- a/wadsrc/static/shaders/glsl/func_notexture.fp +++ b/wadsrc/static/shaders/glsl/func_notexture.fp @@ -1,6 +1,6 @@ -vec4 Process(vec4 color) +vec4 ProcessTexel() { - return color*objectcolor; + return desaturate(uObjectColor); } diff --git a/wadsrc/static/shaders/glsl/func_warp1.fp b/wadsrc/static/shaders/glsl/func_warp1.fp index c4acb8854..2dbf8a420 100644 --- a/wadsrc/static/shaders/glsl/func_warp1.fp +++ b/wadsrc/static/shaders/glsl/func_warp1.fp @@ -1,6 +1,6 @@ uniform float timer; -vec4 Process(vec4 color) +vec4 ProcessTexel() { vec2 texCoord = gl_TexCoord[0].st; @@ -12,6 +12,6 @@ vec4 Process(vec4 color) texCoord += offset; - return getTexel(texCoord) * color; + return getTexel(texCoord); } diff --git a/wadsrc/static/shaders/glsl/func_warp2.fp b/wadsrc/static/shaders/glsl/func_warp2.fp index 9d5b8f9db..78044f970 100644 --- a/wadsrc/static/shaders/glsl/func_warp2.fp +++ b/wadsrc/static/shaders/glsl/func_warp2.fp @@ -1,6 +1,6 @@ uniform float timer; -vec4 Process(vec4 color) +vec4 ProcessTexel() { vec2 texCoord = gl_TexCoord[0].st; @@ -13,6 +13,6 @@ vec4 Process(vec4 color) texCoord += offset; - return getTexel(texCoord) * color; + return getTexel(texCoord); } diff --git a/wadsrc/static/shaders/glsl/func_wavex.fp b/wadsrc/static/shaders/glsl/func_wavex.fp index d90486358..5172239c7 100644 --- a/wadsrc/static/shaders/glsl/func_wavex.fp +++ b/wadsrc/static/shaders/glsl/func_wavex.fp @@ -1,6 +1,6 @@ uniform float timer; -vec4 Process(vec4 color) +vec4 ProcessTexel() { vec2 texCoord = gl_TexCoord[0].st; @@ -8,6 +8,6 @@ vec4 Process(vec4 color) texCoord.x += sin(pi * 2.0 * (texCoord.y + timer * 0.125)) * 0.1; - return getTexel(texCoord) * color; + return getTexel(texCoord); } diff --git a/wadsrc/static/shaders/glsl/fuzz_jagged.fp b/wadsrc/static/shaders/glsl/fuzz_jagged.fp index d1d1c9727..103f34689 100644 --- a/wadsrc/static/shaders/glsl/fuzz_jagged.fp +++ b/wadsrc/static/shaders/glsl/fuzz_jagged.fp @@ -1,7 +1,7 @@ //created by Evil Space Tomato uniform float timer; -vec4 Process(vec4 color) +vec4 ProcessTexel() { vec2 texCoord = gl_TexCoord[0].st; @@ -10,7 +10,7 @@ vec4 Process(vec4 color) texSplat.x = texCoord.x + mod(sin(pi * 2.0 * (texCoord.y + timer * 2.0)),0.1) * 0.1; texSplat.y = texCoord.y + mod(cos(pi * 2.0 * (texCoord.x + timer * 2.0)),0.1) * 0.1; - vec4 basicColor = getTexel(texSplat) * color; + vec4 basicColor = getTexel(texSplat); float texX = sin(texCoord.x * 100.0 + timer*5.0); float texY = cos(texCoord.x * 100.0 + timer*5.0); diff --git a/wadsrc/static/shaders/glsl/fuzz_noise.fp b/wadsrc/static/shaders/glsl/fuzz_noise.fp index 7e08646cb..02985a122 100644 --- a/wadsrc/static/shaders/glsl/fuzz_noise.fp +++ b/wadsrc/static/shaders/glsl/fuzz_noise.fp @@ -1,10 +1,10 @@ //created by Evil Space Tomato uniform float timer; -vec4 Process(vec4 color) +vec4 ProcessTexel() { vec2 texCoord = gl_TexCoord[0].st; - vec4 basicColor = getTexel(texCoord) * color; + vec4 basicColor = getTexel(texCoord); texCoord.x = float( int(texCoord.x * 128.0) ) / 128.0; texCoord.y = float( int(texCoord.y * 128.0) ) / 128.0; diff --git a/wadsrc/static/shaders/glsl/fuzz_smooth.fp b/wadsrc/static/shaders/glsl/fuzz_smooth.fp index 9cb840e78..597debb53 100644 --- a/wadsrc/static/shaders/glsl/fuzz_smooth.fp +++ b/wadsrc/static/shaders/glsl/fuzz_smooth.fp @@ -1,10 +1,10 @@ //created by Evil Space Tomato uniform float timer; -vec4 Process(vec4 color) +vec4 ProcessTexel() { vec2 texCoord = gl_TexCoord[0].st; - vec4 basicColor = getTexel(texCoord) * color; + vec4 basicColor = getTexel(texCoord); float texX = texCoord.x / 3.0 + 0.66; float texY = 0.34 - texCoord.y / 3.0; diff --git a/wadsrc/static/shaders/glsl/fuzz_smoothnoise.fp b/wadsrc/static/shaders/glsl/fuzz_smoothnoise.fp index 4c796de60..196cca33a 100644 --- a/wadsrc/static/shaders/glsl/fuzz_smoothnoise.fp +++ b/wadsrc/static/shaders/glsl/fuzz_smoothnoise.fp @@ -1,10 +1,10 @@ //created by Evil Space Tomato uniform float timer; -vec4 Process(vec4 color) +vec4 ProcessTexel() { vec2 texCoord = gl_TexCoord[0].st; - vec4 basicColor = getTexel(texCoord) * color; + vec4 basicColor = getTexel(texCoord); float texX = sin(mod(texCoord.x * 100.0 + timer*5.0, 3.489)) + texCoord.x / 4.0; float texY = cos(mod(texCoord.y * 100.0 + timer*5.0, 3.489)) + texCoord.y / 4.0; diff --git a/wadsrc/static/shaders/glsl/fuzz_smoothtranslucent.fp b/wadsrc/static/shaders/glsl/fuzz_smoothtranslucent.fp index 074e5f10d..bfd60de57 100644 --- a/wadsrc/static/shaders/glsl/fuzz_smoothtranslucent.fp +++ b/wadsrc/static/shaders/glsl/fuzz_smoothtranslucent.fp @@ -1,10 +1,10 @@ //created by Evil Space Tomato uniform float timer; -vec4 Process(vec4 color) +vec4 ProcessTexel() { vec2 texCoord = gl_TexCoord[0].st; - vec4 basicColor = getTexel(texCoord) * color; + vec4 basicColor = getTexel(texCoord); float texX = sin(texCoord.x * 100.0 + timer*5.0); float texY = cos(texCoord.x * 100.0 + timer*5.0); diff --git a/wadsrc/static/shaders/glsl/fuzz_standard.fp b/wadsrc/static/shaders/glsl/fuzz_standard.fp index a93bef849..a1bd0ebaf 100644 --- a/wadsrc/static/shaders/glsl/fuzz_standard.fp +++ b/wadsrc/static/shaders/glsl/fuzz_standard.fp @@ -1,10 +1,10 @@ //created by Evil Space Tomato uniform float timer; -vec4 Process(vec4 color) +vec4 ProcessTexel() { vec2 texCoord = gl_TexCoord[0].st; - vec4 basicColor = getTexel(texCoord) * color; + vec4 basicColor = getTexel(texCoord); texCoord.x = float( int(texCoord.x * 128.0) ) / 128.0; texCoord.y = float( int(texCoord.y * 128.0) ) / 128.0; diff --git a/wadsrc/static/shaders/glsl/fuzz_swirly.fp b/wadsrc/static/shaders/glsl/fuzz_swirly.fp index 19816f8f4..de91e47d6 100644 --- a/wadsrc/static/shaders/glsl/fuzz_swirly.fp +++ b/wadsrc/static/shaders/glsl/fuzz_swirly.fp @@ -1,10 +1,10 @@ //created by Evil Space Tomato uniform float timer; -vec4 Process(vec4 color) +vec4 ProcessTexel() { vec2 texCoord = gl_TexCoord[0].st; - vec4 basicColor = getTexel(texCoord) * color; + vec4 basicColor = getTexel(texCoord); float texX = sin(texCoord.x * 100.0 + timer*5.0); float texY = cos(texCoord.x * 100.0 + timer*5.0); diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 086cda7f9..db5b8cb19 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -1,56 +1,93 @@ - -// Changing this constant gives results very similar to changing r_visibility. -// Default is 232, it seems to give exactly the same light bands as software renderer. -#define DOOMLIGHTFACTOR 232.0 +in vec4 pixelpos; +in vec2 glowdist; -#ifdef DYNLIGHT - -// ATI does not like this inside an #ifdef so it will be prepended by the compiling code inside the .EXE now. -//#version 120 -//#extension GL_EXT_gpu_shader4 : enable - -uniform ivec3 lightrange; -#ifndef MAXLIGHTS128 -uniform vec4 lights[256]; +#ifdef SHADER_STORAGE_LIGHTS + layout(std430, binding = 3) buffer ParameterBuffer + { + vec4 lights[]; + }; +#elif defined MAXLIGHTS128 + uniform vec4 lights[256]; #else -uniform vec4 lights[128]; -#endif - + uniform vec4 lights[128]; #endif - -uniform int fogenabled; -uniform vec4 fogcolor; -uniform vec4 objectcolor; -uniform vec4 dlightcolor; -uniform vec3 camerapos; -varying vec4 pixelpos; -varying vec4 fogparm; -//uniform vec2 lightparms; -uniform float desaturation_factor; - -uniform vec4 topglowcolor; -uniform vec4 bottomglowcolor; -varying vec2 glowdist; - -uniform int texturemode; uniform sampler2D tex; vec4 Process(vec4 color); +vec4 ProcessTexel(); +vec4 ProcessLight(vec4 color); -varying float lightlevel; +//=========================================================================== +// +// Desaturate a color +// +//=========================================================================== -#ifdef SOFTLIGHT +vec4 desaturate(vec4 texel) +{ + if (uDesaturationFactor > 0.0) + { + float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14); + return mix (vec4(gray,gray,gray,texel.a), texel, uDesaturationFactor); + } + else + { + return texel; + } +} + +//=========================================================================== +// +// This function is common for all (non-special-effect) fragment shaders +// +//=========================================================================== + +vec4 getTexel(vec2 st) +{ + vec4 texel = texture2D(tex, st); + + // + // Apply texture modes + // + switch (uTextureMode) + { + case 1: + texel.rgb = vec3(1.0,1.0,1.0); + break; + + case 2: + texel.a = 1.0; + break; + + case 3: + texel = vec4(1.0-texel.r, 1.0-texel.b, 1.0-texel.g, texel.a); + break; + } + texel *= uObjectColor; + + return desaturate(texel); +} + +//=========================================================================== +// // Doom lighting equation ripped from EDGE. // Big thanks to EDGE developers for making the only port // that actually replicates software renderer's lighting in OpenGL. // Float version. // Basically replace int with float and divide all constants by 31. +// +//=========================================================================== + float R_DoomLightingEquation(float light, float dist) { + // Changing this constant gives results very similar to changing r_visibility. + // Default is 232, it seems to give exactly the same light bands as software renderer. + #define DOOMLIGHTFACTOR 232.0 + /* L in the range 0 to 63 */ float L = light * 63.0/31.0; @@ -66,106 +103,97 @@ float R_DoomLightingEquation(float light, float dist) /* result is colormap index (0 bright .. 31 dark) */ return clamp(index, min_L, 1.0); } -#endif - -//=========================================================================== -// -// Desaturate a color -// -//=========================================================================== - -vec4 desaturate(vec4 texel) -{ - #ifndef NO_DESATURATE - float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14); - return mix (vec4(gray,gray,gray,texel.a), texel, desaturation_factor); - #else - return texel; - #endif -} //=========================================================================== // // Calculate light // +// It is important to note that the light color is not desaturated +// due to ZDoom's implementation weirdness. Everything that's added +// on top of it, e.g. dynamic lights and glows are, though, because +// the objects emitting these lights are also. +// +// This is making this a bit more complicated than it needs to +// because we can't just desaturate the final fragment color. +// //=========================================================================== vec4 getLightColor(float fogdist, float fogfactor) { vec4 color = gl_Color; - #ifdef SOFTLIGHT - float newlightlevel = 1.0 - R_DoomLightingEquation(lightlevel, gl_FragCoord.z); - color.rgb *= clamp(vec3(newlightlevel), 0.0, 1.0); - #endif - #ifndef NO_FOG - // - // apply light diminishing - // - if (fogenabled > 0) + + if (uLightLevel >= 0.0) { - #if (defined(DOOMLIGHT)) && !defined SOFTLIGHT - // special lighting mode 'Doom' not available on older cards for performance reasons. - if (fogdist < fogparm.y) - { - color.rgb *= fogparm.x - (fogdist / fogparm.y) * (fogparm.x - 1.0); - } - #endif + float newlightlevel = 1.0 - R_DoomLightingEquation(uLightLevel, gl_FragCoord.z); + color.rgb *= newlightlevel; + } + else if (uFogEnabled > 0.0) + { + // brightening around the player for light mode 2 + if (fogdist < uLightDist) + { + color.rgb *= uLightFactor - (fogdist / uLightDist) * (uLightFactor - 1.0); + } - //color = vec4(color.rgb * (1.0 - fogfactor), color.a); + // + // apply light diminishing through fog equation + // color.rgb = mix(vec3(0.0, 0.0, 0.0), color.rgb, fogfactor); } - #endif - #ifndef NO_GLOW // // handle glowing walls // - if (topglowcolor.a > 0.0 && glowdist.x < topglowcolor.a) + if (uGlowTopColor.a > 0.0 && glowdist.x < uGlowTopColor.a) { - color.rgb += desaturate(topglowcolor * (1.0 - glowdist.x / topglowcolor.a)).rgb; + color.rgb += desaturate(uGlowTopColor * (1.0 - glowdist.x / uGlowTopColor.a)).rgb; } - if (bottomglowcolor.a > 0.0 && glowdist.y < bottomglowcolor.a) + if (uGlowBottomColor.a > 0.0 && glowdist.y < uGlowBottomColor.a) { - color.rgb += desaturate(bottomglowcolor * (1.0 - glowdist.y / bottomglowcolor.a)).rgb; + color.rgb += desaturate(uGlowBottomColor * (1.0 - glowdist.y / uGlowBottomColor.a)).rgb; } color = min(color, 1.0); - #endif - - // calculation of actual light color is complete. - return color; -} -//=========================================================================== -// -// Gets a texel and performs common manipulations -// -//=========================================================================== - -vec4 getTexel(vec2 st) -{ - vec4 texel = texture2D(tex, st); - - #ifndef NO_TEXTUREMODE // - // Apply texture modes + // apply brightmaps (or other light manipulation by custom shaders. // - if (texturemode == 3) - { - texel *=objectcolor; - texel = vec4(1.0-texel.r, 1.0-texel.g, 1.0-texel.b, texel.a); - return texel; - } - else if (texturemode == 2) - { - texel.a = 1.0; - } - else if (texturemode == 1) - { - texel.rgb = vec3(1.0,1.0,1.0); - } - #endif + color = ProcessLight(color); - return desaturate(texel * objectcolor); + // + // apply dynamic lights (except additive) + // + + vec4 dynlight = uDynLightColor; + + if (uLightRange.z > uLightRange.x) + { + // + // modulated lights + // + for(int i=uLightRange.x; i uLightRange.z) + { + vec4 addlight = vec4(0.0,0.0,0.0,0.0); + + // + // additive lights - these can be done after the alpha test. + // + for(int i=uLightRange.z; i Date: Mon, 12 May 2014 14:58:37 +0200 Subject: [PATCH 0089/1509] - fixed: fog density calculation for fixed function was not correct. --- src/gl/renderer/gl_renderstate.cpp | 9 +++++---- src/gl/renderer/gl_renderstate.h | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 7efa1d30f..746bbb176 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -69,7 +69,7 @@ void FRenderState::Reset() ffTextureEnabled = ffFogEnabled = false; mSpecialEffect = ffSpecialEffect = EFF_NONE; mFogColor.d = ffFogColor.d = -1; - mFogDensity = ffFogDensity = 0; + ffFogDensity = 0; mTextureMode = ffTextureMode = -1; mDesaturation = 0; mSrcBlend = GL_SRC_ALPHA; @@ -316,10 +316,11 @@ void FRenderState::Apply(bool forcenoshader) GLfloat FogColor[4]={mFogColor.r/255.0f,mFogColor.g/255.0f,mFogColor.b/255.0f,0.0f}; glFogfv(GL_FOG_COLOR, FogColor); } - if (ffFogDensity != mFogDensity) + if (ffFogDensity != mLightParms[2]) { - glFogf(GL_FOG_DENSITY, mFogDensity/64000.f); - ffFogDensity=mFogDensity; + const float LOG2E = 1.442692f; // = 1/log(2) + glFogf(GL_FOG_DENSITY, -mLightParms[2] / LOG2E); + ffFogDensity = mLightParms[2]; } } if (mSpecialEffect != ffSpecialEffect) diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index e8de712f6..888ead0d7 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -65,7 +65,6 @@ class FRenderState PalEntry mFogColor; PalEntry mObjectColor; PalEntry mDynColor; - float mFogDensity; int mEffectState; int mColormapState; From 9c659b948c8b857dbb56d26e1d367003a6324826 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 May 2014 15:13:07 +0200 Subject: [PATCH 0090/1509] - reactivated texture warping. --- src/gl/renderer/gl_renderstate.cpp | 5 ++--- src/gl/renderer/gl_renderstate.h | 3 +-- src/gl/textures/gl_material.cpp | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 746bbb176..4668bf2b7 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -94,15 +94,14 @@ void FRenderState::Reset() // //========================================================================== -int FRenderState::SetupShader(bool cameratexture, int &shaderindex, float warptime) +int FRenderState::SetupShader(int &shaderindex, float warptime) { int softwarewarp = 0; - if (gl.hasGLSL()) { mEffectState = shaderindex; - mWarpTime = warptime; + if (shaderindex > 0) GLRenderer->mShaderManager->SetWarpSpeed(shaderindex, warptime); } else { diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 888ead0d7..79e277948 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -68,7 +68,6 @@ class FRenderState int mEffectState; int mColormapState; - float mWarpTime; int glSrcBlend, glDstBlend; int glAlphaFunc; @@ -93,7 +92,7 @@ public: void Reset(); - int SetupShader(bool cameratexture, int &shaderindex, float warptime); + int SetupShader(int &shaderindex, float warptime); void Apply(bool forcenoshader = false); void SetVertexBuffer(FVertexBuffer *vb) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index ce3c75181..988ac8121 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -842,7 +842,7 @@ void FMaterial::Bind(int clampmode, int translation, int overrideshader) int maxbound = 0; bool allowhires = tex->xScale == FRACUNIT && tex->yScale == FRACUNIT; - int softwarewarp = gl_RenderState.SetupShader(tex->bHasCanvas, shaderindex, tex->gl_info.shaderspeed); + int softwarewarp = gl_RenderState.SetupShader(shaderindex, tex->gl_info.shaderspeed); if (tex->bHasCanvas || tex->bWarped) clampmode = 0; else if (clampmode != -1) clampmode &= 3; @@ -889,7 +889,7 @@ void FMaterial::BindPatch(int translation, int overrideshader, bool alphatexture int shaderindex = overrideshader > 0? overrideshader : mShaderIndex; int maxbound = 0; - int softwarewarp = gl_RenderState.SetupShader(tex->bHasCanvas, shaderindex, tex->gl_info.shaderspeed); + int softwarewarp = gl_RenderState.SetupShader(shaderindex, tex->gl_info.shaderspeed); const FHardwareTexture *glpatch = mBaseLayer->BindPatch(0, translation, softwarewarp, alphatexture); // The only multitexture effect usable on sprites is the brightmap. From b514a815f4341c29ab05b075e7b3e36c7aa1f668 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 May 2014 20:23:54 +0200 Subject: [PATCH 0091/1509] - enable use of vertex buffer for sprite rendering. --- src/gl/data/gl_vertexbuffer.h | 8 ++++ src/gl/dynlights/a_dynlight.cpp | 2 +- src/gl/scene/gl_sprite.cpp | 80 ++++++++++++++++++++++----------- src/gl/scene/gl_walls_draw.cpp | 24 ++-------- 4 files changed, 67 insertions(+), 47 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 24fe5b4d5..0a32abf6b 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -26,6 +26,14 @@ struct FFlatVertex float u,v; // texture coordinates void SetFlatVertex(vertex_t *vt, const secplane_t &plane); + void Set(float xx, float zz, float yy, float uu, float vv) + { + x = xx; + z = zz; + y = yy; + u = uu; + v = vv; + } }; #define VTO ((FFlatVertex*)NULL) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 6ac50a785..1945e8bf5 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -528,7 +528,7 @@ void ADynamicLight::CollectWithinRadius(subsector_t *subSec, float radius) touching_subsectors = AddLightNode(&subSec->lighthead[additive], subSec, this, touching_subsectors); if (subSec->sector->validcount != ::validcount) { - touching_sector = AddLightNode(&subSec->sector->lighthead[additive], subSec->sector, this, touching_sector); + touching_sector = AddLightNode(&subSec->render_sector->lighthead[additive], subSec->sector, this, touching_sector); subSec->sector->validcount = ::validcount; } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 84ecbf0a1..63c7bd46b 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -52,6 +52,7 @@ #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_renderer.h" #include "gl/data/gl_data.h" #include "gl/dynlights/gl_glow.h" #include "gl/scene/gl_drawinfo.h" @@ -60,6 +61,7 @@ #include "gl/shaders/gl_shader.h" #include "gl/textures/gl_material.h" #include "gl/utility/gl_clock.h" +#include "gl/data/gl_vertexbuffer.h" CVAR(Bool, gl_usecolorblending, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, gl_spritebrightfog, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); @@ -265,33 +267,10 @@ void GLSprite::Draw(int pass) v4 = Vector(x2, z2, y2); } - glBegin(GL_TRIANGLE_STRIP); - if (gltexture) + FFlatVertex *ptr; + unsigned int offset, count; + if (!gl_usevbo) { - glTexCoord2f(ul, vt); glVertex3fv(&v1[0]); - glTexCoord2f(ur, vt); glVertex3fv(&v2[0]); - glTexCoord2f(ul, vb); glVertex3fv(&v3[0]); - glTexCoord2f(ur, vb); glVertex3fv(&v4[0]); - } - else // Particle - { - glVertex3fv(&v1[0]); - glVertex3fv(&v2[0]); - glVertex3fv(&v3[0]); - glVertex3fv(&v4[0]); - } - - glEnd(); - - if (foglayer) - { - // If we get here we know that we have colored fog and no fixed colormap. - gl_SetFog(foglevel, rel, &Colormap, additivefog); - gl_RenderState.SetFixedColormap(CM_FOGLAYER); - gl_RenderState.BlendEquation(GL_FUNC_ADD); - gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_STRIP); if (gltexture) { @@ -307,7 +286,56 @@ void GLSprite::Draw(int pass) glVertex3fv(&v3[0]); glVertex3fv(&v4[0]); } + glEnd(); + } + else + { + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(v1[0], v1[1], v1[2], ul, vt); + ptr++; + ptr->Set(v2[0], v2[1], v2[2], ur, vt); + ptr++; + ptr->Set(v3[0], v3[1], v3[2], ul, vb); + ptr++; + ptr->Set(v4[0], v4[1], v4[2], ur, vb); + ptr++; + count = GLRenderer->mVBO->GetCount(ptr, &offset); + glDrawArrays(GL_TRIANGLE_STRIP, offset, count); + } + + if (foglayer) + { + // If we get here we know that we have colored fog and no fixed colormap. + gl_SetFog(foglevel, rel, &Colormap, additivefog); + gl_RenderState.SetFixedColormap(CM_FOGLAYER); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.Apply(); + + if (!gl_usevbo) + { + glBegin(GL_TRIANGLE_STRIP); + if (gltexture) + { + glTexCoord2f(ul, vt); glVertex3fv(&v1[0]); + glTexCoord2f(ur, vt); glVertex3fv(&v2[0]); + glTexCoord2f(ul, vb); glVertex3fv(&v3[0]); + glTexCoord2f(ur, vb); glVertex3fv(&v4[0]); + } + else // Particle + { + glVertex3fv(&v1[0]); + glVertex3fv(&v2[0]); + glVertex3fv(&v3[0]); + glVertex3fv(&v4[0]); + } + glEnd(); + } + else + { + glDrawArrays(GL_TRIANGLE_STRIP, offset, count); + } gl_RenderState.SetFixedColormap(CM_DEFAULT); } } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index dc7127690..ca32e98a6 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -290,32 +290,16 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) { FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->x = glseg.x1; - ptr->y = glseg.y1; - ptr->z = zbottom[0]; - ptr->u = tcs[0].u; - ptr->v = tcs[0].v; + ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[0].u, tcs[0].v); ptr++; if (split && glseg.fracleft == 0) SplitLeftEdge(tcs, ptr); - ptr->x = glseg.x1; - ptr->y = glseg.y1; - ptr->z = ztop[0]; - ptr->u = tcs[1].u; - ptr->v = tcs[1].v; + ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[1].u, tcs[1].v); ptr++; if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs, ptr); - ptr->x = glseg.x2; - ptr->y = glseg.y2; - ptr->z = ztop[1]; - ptr->u = tcs[2].u; - ptr->v = tcs[2].v; + ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[2].u, tcs[2].v); ptr++; if (split && glseg.fracright == 1) SplitRightEdge(tcs, ptr); - ptr->x = glseg.x2; - ptr->y = glseg.y2; - ptr->z = zbottom[1]; - ptr->u = tcs[3].u; - ptr->v = tcs[3].v; + ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[3].u, tcs[3].v); ptr++; if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, ptr); unsigned int offset; From cf45f2d718eb9548f7eba91565fcaa860fab780a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 May 2014 22:24:26 +0200 Subject: [PATCH 0092/1509] - added missing shader files. --- src/gl/scene/gl_weapon.cpp | 31 +++++++++++++++---- wadsrc/static/shaders/glsl/burn.fp | 12 ++++++++ wadsrc/static/shaders/glsl/burn.vp | 7 +++++ wadsrc/static/shaders/glsl/shaderdefs.i | 41 +++++++++++++++++++++++++ wadsrc/static/shaders/glsl/stencil.fp | 7 +++++ wadsrc/static/shaders/glsl/stencil.vp | 14 +++++++++ 6 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 wadsrc/static/shaders/glsl/burn.fp create mode 100644 wadsrc/static/shaders/glsl/burn.vp create mode 100644 wadsrc/static/shaders/glsl/shaderdefs.i create mode 100644 wadsrc/static/shaders/glsl/stencil.fp create mode 100644 wadsrc/static/shaders/glsl/stencil.vp diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 6991bed5c..5fca4bb49 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -51,6 +51,7 @@ #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" #include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" #include "gl/dynlights/gl_glow.h" #include "gl/scene/gl_drawinfo.h" #include "gl/models/gl_models.h" @@ -153,12 +154,30 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed gl_RenderState.EnableAlphaTest(false); } gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(fU1, fV1); glVertex2f(x1,y1); - glTexCoord2f(fU1, fV2); glVertex2f(x1,y2); - glTexCoord2f(fU2, fV1); glVertex2f(x2,y1); - glTexCoord2f(fU2, fV2); glVertex2f(x2,y2); - glEnd(); + if (!gl_usevbo) + { + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(fU1, fV1); glVertex2f(x1, y1); + glTexCoord2f(fU1, fV2); glVertex2f(x1, y2); + glTexCoord2f(fU2, fV1); glVertex2f(x2, y1); + glTexCoord2f(fU2, fV2); glVertex2f(x2, y2); + glEnd(); + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x1, y1, 0, fU1, fV1); + ptr++; + ptr->Set(x1, y2, 0, fU1, fV2); + ptr++; + ptr->Set(x2, y1, 0, fU2, fV1); + ptr++; + ptr->Set(x2, y2, 0, fU2, fV2); + ptr++; + unsigned int offset; + unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); + glDrawArrays(GL_TRIANGLE_STRIP, offset, count); + } if (tex->GetTransparent() || OverrideShader != 0) { gl_RenderState.EnableAlphaTest(true); diff --git a/wadsrc/static/shaders/glsl/burn.fp b/wadsrc/static/shaders/glsl/burn.fp new file mode 100644 index 000000000..8ccb553f8 --- /dev/null +++ b/wadsrc/static/shaders/glsl/burn.fp @@ -0,0 +1,12 @@ +uniform sampler2D tex; +uniform sampler2D texture2; + +void main() +{ + vec4 frag = gl_Color; + + vec4 t1 = texture2D(texture2, gl_TexCoord[0].xy); + vec4 t2 = texture2D(tex, vec2(gl_TexCoord[0].x, 1.0-gl_TexCoord[0].y)); + + gl_FragColor = frag * vec4(t1.r, t1.g, t1.b, t2.a); +} diff --git a/wadsrc/static/shaders/glsl/burn.vp b/wadsrc/static/shaders/glsl/burn.vp new file mode 100644 index 000000000..6a8d2b37b --- /dev/null +++ b/wadsrc/static/shaders/glsl/burn.vp @@ -0,0 +1,7 @@ + +void main() +{ + gl_FrontColor = gl_Color; + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_Position = ProjectionMatrix * gl_Vertex; +} diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i new file mode 100644 index 000000000..efedca5e5 --- /dev/null +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -0,0 +1,41 @@ +// This file contains common data definitions for both vertex and fragment shader + +uniform vec4 uCameraPos; + +uniform int uTextureMode; + +// colors +uniform vec4 uObjectColor; +uniform vec4 uDynLightColor; +uniform vec4 uFogColor; +uniform float uDesaturationFactor; + +// Fixed colormap stuff +uniform int uFixedColormap; // 0, when no fixed colormap, 1 for a light value, 2 for a color blend, 3 for a fog layer +uniform vec4 uFixedColormapStart; +uniform vec4 uFixedColormapRange; + +// Glowing walls stuff +uniform vec4 uGlowTopPlane; +uniform vec4 uGlowTopColor; +uniform vec4 uGlowBottomPlane; +uniform vec4 uGlowBottomColor; + +// Lighting + Fog +uniform vec4 uLightAttr; +#define uLightLevel uLightAttr.a +#define uFogDensity uLightAttr.b +#define uLightFactor uLightAttr.g +#define uLightDist uLightAttr.r +uniform int uFogEnabled; + +// dynamic lights +uniform ivec4 uLightRange; + + +// redefine the matrix names to what they actually represent. +#define ModelMatrix gl_TextureMatrix[7] +#define ViewMatrix gl_ModelViewMatrix +#define ProjectionMatrix gl_ProjectionMatrix +#define TextureMatrix gl_TextureMatrix[0] + diff --git a/wadsrc/static/shaders/glsl/stencil.fp b/wadsrc/static/shaders/glsl/stencil.fp new file mode 100644 index 000000000..9e4afec04 --- /dev/null +++ b/wadsrc/static/shaders/glsl/stencil.fp @@ -0,0 +1,7 @@ +in vec4 pixelpos; + +void main() +{ + gl_FragColor = vec4(1.0); +} + diff --git a/wadsrc/static/shaders/glsl/stencil.vp b/wadsrc/static/shaders/glsl/stencil.vp new file mode 100644 index 000000000..f5ac9fdd1 --- /dev/null +++ b/wadsrc/static/shaders/glsl/stencil.vp @@ -0,0 +1,14 @@ + +out vec4 pixelpos; + +void main() +{ + // perform exactly the same relevant steps as in the main shader to ensure matching results (that also means including the model matrix here!) + vec4 worldcoord = ModelMatrix * gl_Vertex; + vec4 eyeCoordPos = ViewMatrix * worldcoord; + + pixelpos.xyz = worldcoord.xyz; + pixelpos.w = -eyeCoordPos.z/eyeCoordPos.w; + + gl_Position = ProjectionMatrix * eyeCoordPos; +} From 579eff5b9648d671579a4c68c8d4aa0e58496485 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 May 2014 22:46:30 +0200 Subject: [PATCH 0093/1509] - add vertex buffer based rendering for decals. --- src/gl/scene/gl_decal.cpp | 26 +++++++++++++++++++++----- src/gl/scene/gl_flats.cpp | 4 ++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 1d15ebcab..61c92d3fd 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -45,6 +45,7 @@ #include "gl/system/gl_cvars.h" #include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" @@ -336,13 +337,28 @@ void GLWall::DrawDecal(DBaseDecal *decal) else gl_RenderState.AlphaFunc(GL_GREATER, 0.f); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); - for(i=0;i<4;i++) + if (!gl_usevbo) { - glTexCoord2f(dv[i].u,dv[i].v); - glVertex3f(dv[i].x,dv[i].z,dv[i].y); + glBegin(GL_TRIANGLE_FAN); + for (i = 0; i < 4; i++) + { + glTexCoord2f(dv[i].u, dv[i].v); + glVertex3f(dv[i].x, dv[i].z, dv[i].y); + } + glEnd(); + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (i = 0; i < 4; i++) + { + ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); + ptr++; + } + unsigned int offset; + unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); + glDrawArrays(GL_TRIANGLE_FAN, offset, count); } - glEnd(); rendered_decals++; gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.SetObjectColor(0xffffffff); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 7be264e68..4d3f4c3f6 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -153,14 +153,14 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) // Render the light glBegin(GL_TRIANGLE_FAN); - for(k = 0, v = sub->firstline; k < sub->numlines; k++, v++) + for (k = 0, v = sub->firstline; k < sub->numlines; k++, v++) { vertex_t *vt = v->v1; float zc = plane.plane.ZatPoint(vt->fx, vt->fy) + dz; t1.Set(vt->fx, zc, vt->fy); Vector nearToVert = t1 - nearPt; - glTexCoord2f( (nearToVert.Dot(right) * scale) + 0.5f, (nearToVert.Dot(up) * scale) + 0.5f); + glTexCoord2f((nearToVert.Dot(right) * scale) + 0.5f, (nearToVert.Dot(up) * scale) + 0.5f); glVertex3f(vt->fx, zc, vt->fy); } From 60f0ab5f1b4de47ae4bfb01830edee896b490774 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 13 May 2014 12:00:11 +0200 Subject: [PATCH 0094/1509] - fixed Linux warning with type cast. --- src/gl/data/gl_vertexbuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 0a32abf6b..013e6d73a 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -64,7 +64,7 @@ public: } unsigned int GetCount(FFlatVertex *newptr, unsigned int *poffset) { - unsigned int newofs = unsigned int(newptr - map); + unsigned int newofs = (unsigned int)(newptr - map); unsigned int diff = newofs - mCurIndex; *poffset = mCurIndex; mCurIndex = newofs; From 03d4f23a6e94b9c6d89ac3dcea2b187014d1384c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 15 May 2014 19:27:22 +0200 Subject: [PATCH 0095/1509] - made adjustments to the texture loading code to account for the recent changes to handle long texture names. --- src/gl/models/gl_models.cpp | 9 +------ src/gl/textures/gl_material.cpp | 2 +- src/gl/textures/gl_skyboxtexture.cpp | 10 +++---- src/gl/textures/gl_texture.cpp | 40 +++++----------------------- src/gl/utility/gl_clock.cpp | 2 +- 5 files changed, 14 insertions(+), 49 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 39668cd02..808cbff95 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -141,14 +141,7 @@ FTexture * LoadSkin(const char * path, const char * fn) int texlump = FindGFXFile(buffer); if (texlump>=0) { - FTextureID texno = TexMan.FindTextureByLumpNum(texlump); - if (!texno.isValid()) - { - FTexture *tex = FTexture::CreateTexture("", texlump, FTexture::TEX_Override); - TexMan.AddTexture(tex); - return tex; - } - return TexMan[texno]; + return TexMan.FindTexture(Wads.GetLumpFullName(texlump), FTexture::TEX_Any, FTextureManager::TEXMAN_TryAny); } else { diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 9cb3ef523..008e6e8cd 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -855,7 +855,7 @@ void FMaterial::Bind(int cm, int clampmode, int translation, int overrideshader) FTexture *layer; if (mTextureLayers[i].animated) { - FTextureID id = mTextureLayers[i].texture->GetID(); + FTextureID id = mTextureLayers[i].texture->id; layer = TexMan(id); ValidateSysTexture(layer, false); } diff --git a/src/gl/textures/gl_skyboxtexture.cpp b/src/gl/textures/gl_skyboxtexture.cpp index f9918dff2..2db39c7a0 100644 --- a/src/gl/textures/gl_skyboxtexture.cpp +++ b/src/gl/textures/gl_skyboxtexture.cpp @@ -205,15 +205,13 @@ void gl_ParseVavoomSkybox() sc.MustGetString(); maplump = Wads.CheckNumForFullName(sc.String, true); - if (maplump==-1) - Printf("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->Name); - FTextureID tex = TexMan.FindTextureByLumpNum(maplump); - if (!tex.isValid()) + FTexture *tex = TexMan.FindTexture(sc.String, FTexture::TEX_Wall, FTextureManager::TEXMAN_TryAny); + if (tex != NULL) { - tex = TexMan.CreateTexture(maplump, FTexture::TEX_MiscPatch); + Printf("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->Name); } - sb->faces[facecount] = TexMan[tex]; + sb->faces[facecount] = tex; sc.MustGetStringName("}"); } facecount++; diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 68c33f125..29cafe27b 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -696,8 +696,7 @@ void gl_ParseBrightmap(FScanner &sc, int deflump) bool disable_fullbright=false; bool thiswad = false; bool iwad = false; - int maplump = -1; - FString maplumpname; + FTexture *bmtex = NULL; sc.MustGetString(); if (sc.Compare("texture")) type = FTexture::TEX_Wall; @@ -734,17 +733,15 @@ void gl_ParseBrightmap(FScanner &sc, int deflump) { sc.MustGetString(); - if (maplump >= 0) + if (bmtex != NULL) { Printf("Multiple brightmap definitions in texture %s\n", tex? tex->Name : "(null)"); } - maplump = Wads.CheckNumForFullName(sc.String, true); + bmtex = TexMan.FindTexture(sc.String, FTexture::TEX_Any, FTextureManager::TEXMAN_TryAny); - if (maplump==-1) + if (bmtex == NULL) Printf("Brightmap '%s' not found in texture '%s'\n", sc.String, tex? tex->Name : "(null)"); - - maplumpname = sc.String; } } if (!tex) @@ -764,7 +761,7 @@ void gl_ParseBrightmap(FScanner &sc, int deflump) if (!useme) return; } - if (maplump != -1) + if (bmtex != NULL) { if (tex->bWarped != 0) { @@ -772,31 +769,8 @@ void gl_ParseBrightmap(FScanner &sc, int deflump) return; } - // Brightmap textures are stored in the texture manager so that multiple - // instances of the same textures can be avoided. - FTexture *brightmap; - FTextureID brightmapId = TexMan.FindTextureByLumpNum(maplump); - - if (!brightmapId.isValid()) - { - // a texture for this lump has not been created yet. - brightmap = FTexture::CreateTexture(maplump, tex->UseType); - if (!brightmap) - { - Printf("Unable to create texture from '%s' in brightmap definition for '%s'\n", - maplumpname.GetChars(), tex->Name); - return; - } - brightmap->gl_info.bBrightmap = true; - brightmap->Name[0] = 0; // brightmaps don't have names - TexMan.AddTexture(brightmap); - } - else - { - brightmap = TexMan[brightmapId]; - } - - tex->gl_info.Brightmap = brightmap; + bmtex->gl_info.bBrightmap = true; + tex->gl_info.Brightmap = bmtex; } tex->gl_info.bBrightmapDisablesFullbright = disable_fullbright; } diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp index 7ad32f8ee..7759f5582 100644 --- a/src/gl/utility/gl_clock.cpp +++ b/src/gl/utility/gl_clock.cpp @@ -183,7 +183,7 @@ void CheckBench() FString compose; compose.Format("Map %s: \"%s\",\nx = %1.4f, y = %1.4f, z = %1.4f, angle = %1.4f, pitch = %1.4f\n", - level.mapname, level.LevelName.GetChars(), FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz), + level.MapName.GetChars(), level.LevelName.GetChars(), FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz), ANGLE_TO_FLOAT(viewangle), ANGLE_TO_FLOAT(viewpitch)); AppendRenderStats(compose); From 23fbd6996390dc134f8e0d1098a5b4da34542613 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 20 May 2014 22:20:15 +0200 Subject: [PATCH 0096/1509] - 4 more places where immediate mode drawing has been substituted with a buffer-based alternative. --- src/gl/scene/gl_drawinfo.cpp | 99 ++++++++++++++++++++++++++++-------- src/gl/scene/gl_scene.cpp | 30 ++++++++--- 2 files changed, 101 insertions(+), 28 deletions(-) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 2c7a4a15a..e0e6cf8df 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -47,6 +47,7 @@ #include "gl/system/gl_cvars.h" #include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" #include "gl/dynlights/gl_lightbuffer.h" @@ -990,12 +991,30 @@ void FDrawInfo::SetupFloodStencil(wallseg * ws) glDepthMask(true); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); - glVertex3f(ws->x1, ws->z1, ws->y1); - glVertex3f(ws->x1, ws->z2, ws->y1); - glVertex3f(ws->x2, ws->z2, ws->y2); - glVertex3f(ws->x2, ws->z1, ws->y2); - glEnd(); + if (!gl_usevbo) + { + glBegin(GL_TRIANGLE_FAN); + glVertex3f(ws->x1, ws->z1, ws->y1); + glVertex3f(ws->x1, ws->z2, ws->y1); + glVertex3f(ws->x2, ws->z2, ws->y2); + glVertex3f(ws->x2, ws->z1, ws->y2); + glEnd(); + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); + ptr++; + unsigned int offset; + unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); + glDrawArrays(GL_TRIANGLE_FAN, offset, count); + } glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil @@ -1016,12 +1035,30 @@ void FDrawInfo::ClearFloodStencil(wallseg * ws) gl_RenderState.ResetColor(); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); - glVertex3f(ws->x1, ws->z1, ws->y1); - glVertex3f(ws->x1, ws->z2, ws->y1); - glVertex3f(ws->x2, ws->z2, ws->y2); - glVertex3f(ws->x2, ws->z1, ws->y2); - glEnd(); + if (!gl_usevbo) + { + glBegin(GL_TRIANGLE_FAN); + glVertex3f(ws->x1, ws->z1, ws->y1); + glVertex3f(ws->x1, ws->z2, ws->y1); + glVertex3f(ws->x2, ws->z2, ws->y2); + glVertex3f(ws->x2, ws->z1, ws->y2); + glEnd(); + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); + ptr++; + unsigned int offset; + unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); + glDrawArrays(GL_TRIANGLE_FAN, offset, count); + } // restore old stencil op. glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); @@ -1078,7 +1115,6 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo bool pushed = gl_SetPlaneTextureRotation(&plane, gltexture); - glBegin(GL_TRIANGLE_FAN); float prj_fac1 = (planez-fviewz)/(ws->z1-fviewz); float prj_fac2 = (planez-fviewz)/(ws->z2-fviewz); @@ -1094,19 +1130,38 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo float px4 = fviewx + prj_fac1 * (ws->x2-fviewx); float py4 = fviewy + prj_fac1 * (ws->y2-fviewy); - glTexCoord2f(px1 / 64, -py1 / 64); - glVertex3f(px1, planez, py1); + if (!gl_usevbo) + { + glBegin(GL_TRIANGLE_FAN); + glTexCoord2f(px1 / 64, -py1 / 64); + glVertex3f(px1, planez, py1); - glTexCoord2f(px2 / 64, -py2 / 64); - glVertex3f(px2, planez, py2); + glTexCoord2f(px2 / 64, -py2 / 64); + glVertex3f(px2, planez, py2); - glTexCoord2f(px3 / 64, -py3 / 64); - glVertex3f(px3, planez, py3); + glTexCoord2f(px3 / 64, -py3 / 64); + glVertex3f(px3, planez, py3); - glTexCoord2f(px4 / 64, -py4 / 64); - glVertex3f(px4, planez, py4); + glTexCoord2f(px4 / 64, -py4 / 64); + glVertex3f(px4, planez, py4); - glEnd(); + glEnd(); + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(px1, planez, py1, px1 / 64, -py1 / 64); + ptr++; + ptr->Set(px2, planez, py2, px2 / 64, -py2 / 64); + ptr++; + ptr->Set(px3, planez, py3, px3 / 64, -py3 / 64); + ptr++; + ptr->Set(px4, planez, py4, px4 / 64, -py4 / 64); + ptr++; + unsigned int offset; + unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); + glDrawArrays(GL_TRIANGLE_FAN, offset, count); + } if (pushed) { diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 8670c1d49..809a516e7 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -617,12 +617,30 @@ static void FillScreen() gl_RenderState.EnableAlphaTest(false); gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_STRIP); - glVertex2f(0.0f, 0.0f); - glVertex2f(0.0f, (float)SCREENHEIGHT); - glVertex2f((float)SCREENWIDTH, 0.0f); - glVertex2f((float)SCREENWIDTH, (float)SCREENHEIGHT); - glEnd(); + if (!gl_usevbo) + { + glBegin(GL_TRIANGLE_STRIP); + glVertex2f(0.0f, 0.0f); + glVertex2f(0.0f, (float)SCREENHEIGHT); + glVertex2f((float)SCREENWIDTH, 0.0f); + glVertex2f((float)SCREENWIDTH, (float)SCREENHEIGHT); + glEnd(); + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(0, 0, 0, 0, 0); + ptr++; + ptr->Set(0, (float)SCREENHEIGHT, 0, 0, 0); + ptr++; + ptr->Set((float)SCREENWIDTH, 0, 0, 0, 0); + ptr++; + ptr->Set((float)SCREENWIDTH, (float)SCREENHEIGHT, 0, 0, 0); + ptr++; + unsigned int offset; + unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); + glDrawArrays(GL_TRIANGLE_FAN, offset, count); + } } //========================================================================== From 09ba62fbef5a858ea5ed35f5926baeca74988441 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 20 May 2014 22:37:38 +0200 Subject: [PATCH 0097/1509] - put all the common part of buffer based drawing into a separate method of the vertex buffer. --- src/gl/data/gl_vertexbuffer.h | 8 ++++++++ src/gl/scene/gl_decal.cpp | 4 +--- src/gl/scene/gl_drawinfo.cpp | 12 +++--------- src/gl/scene/gl_flats.cpp | 4 +--- src/gl/scene/gl_scene.cpp | 4 +--- src/gl/scene/gl_walls_draw.cpp | 4 +--- src/gl/scene/gl_weapon.cpp | 4 +--- 7 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 013e6d73a..80db0d64e 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -70,6 +70,14 @@ public: mCurIndex = newofs; return diff; } +#ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway. + void RenderCurrent(FFlatVertex *newptr, unsigned int primtype) + { + unsigned int offset; + unsigned int count = GetCount(newptr, &offset); + glDrawArrays(primtype, offset, count); + } +#endif void Reset() { mCurIndex = mIndex; diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 61c92d3fd..8f2e7977a 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -355,9 +355,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); ptr++; } - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_FAN, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); } rendered_decals++; gl_RenderState.SetTextureMode(TM_MODULATE); diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index e0e6cf8df..fc44c7896 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -1011,9 +1011,7 @@ void FDrawInfo::SetupFloodStencil(wallseg * ws) ptr++; ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); ptr++; - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_FAN, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); } glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil @@ -1055,9 +1053,7 @@ void FDrawInfo::ClearFloodStencil(wallseg * ws) ptr++; ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); ptr++; - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_FAN, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); } // restore old stencil op. @@ -1158,9 +1154,7 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo ptr++; ptr->Set(px4, planez, py4, px4 / 64, -py4 / 64); ptr++; - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_FAN, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); } if (pushed) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 4d3f4c3f6..71bb2197b 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -295,9 +295,7 @@ void GLFlat::DrawSubsector(subsector_t * sub) ptr++; } } - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_FAN, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); } flatvertices += sub->numlines; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 809a516e7..15f9444d4 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -637,9 +637,7 @@ static void FillScreen() ptr++; ptr->Set((float)SCREENWIDTH, (float)SCREENHEIGHT, 0, 0, 0); ptr++; - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_FAN, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index ca32e98a6..98ae66800 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -302,9 +302,7 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[3].u, tcs[3].v); ptr++; if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, ptr); - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_FAN, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); vertexcount += 4; } diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 5fca4bb49..a91fa252f 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -174,9 +174,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed ptr++; ptr->Set(x2, y2, 0, fU2, fV2); ptr++; - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_STRIP, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } if (tex->GetTransparent() || OverrideShader != 0) { From f5ea31b51810d52642723e626344b5bc05f37ca8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 21 May 2014 00:36:04 +0200 Subject: [PATCH 0098/1509] - use vertex buffer for all the common 2D rendering functions. --- src/gl/data/gl_vertexbuffer.cpp | 5 +- src/gl/data/gl_vertexbuffer.h | 3 + src/gl/renderer/gl_renderer.cpp | 229 +++++++++++++++++++++++--------- 3 files changed, 172 insertions(+), 65 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index a0f9aa849..8c43d968f 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -49,8 +49,6 @@ #include "gl/data/gl_vertexbuffer.h" -const int BUFFER_SIZE = 2000000; - CUSTOM_CVAR(Int, gl_usevbo, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { if (self < -1 || self > 1 || !(gl.flags & RFL_BUFFER_STORAGE)) @@ -105,6 +103,7 @@ FFlatVertexBuffer::FFlatVertexBuffer() { map = NULL; } + mIndex = mCurIndex = 0; } FFlatVertexBuffer::~FFlatVertexBuffer() @@ -296,7 +295,7 @@ void FFlatVertexBuffer::CreateVBO() { CreateFlatVBO(); memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); - mIndex = vbo_shadowdata.Size(); + mCurIndex = mIndex = vbo_shadowdata.Size(); } else if (sectors) { diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 80db0d64e..806368ab0 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -47,6 +47,8 @@ class FFlatVertexBuffer : public FVertexBuffer void CheckPlanes(sector_t *sector); + const unsigned int BUFFER_SIZE = 2000000; + public: int vbo_arg; TArray vbo_shadowdata; // this is kept around for updating the actual (non-readable) buffer @@ -68,6 +70,7 @@ public: unsigned int diff = newofs - mCurIndex; *poffset = mCurIndex; mCurIndex = newofs; + if (mCurIndex >= BUFFER_SIZE) mCurIndex = mIndex; return diff; } #ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway. diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index b6d64eeee..71595ffbc 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -53,6 +53,7 @@ #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_threads.h" +#include "gl/system/gl_cvars.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" @@ -106,6 +107,7 @@ void FGLRenderer::Initialize() gllight = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/gllight.png"), FTexture::TEX_MiscPatch); mVBO = new FFlatVertexBuffer; + gl_RenderState.SetVertexBuffer(mVBO); mFBID = 0; SetupLevel(); mShaderManager = new FShaderManager; @@ -278,20 +280,36 @@ void FGLRenderer::ClearBorders() gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); - glBegin(GL_QUADS); - // upper quad - glVertex2i(0, borderHeight); - glVertex2i(0, 0); - glVertex2i(width, 0); - glVertex2i(width, borderHeight); - - // lower quad - glVertex2i(0, trueHeight); - glVertex2i(0, trueHeight - borderHeight); - glVertex2i(width, trueHeight - borderHeight); - glVertex2i(width, trueHeight); - glEnd(); + if (!gl_usevbo) + { + glBegin(GL_QUADS); + // upper quad + glVertex2i(0, borderHeight); + glVertex2i(0, 0); + glVertex2i(width, 0); + glVertex2i(width, borderHeight); + // lower quad + glVertex2i(0, trueHeight); + glVertex2i(0, trueHeight - borderHeight); + glVertex2i(width, trueHeight - borderHeight); + glVertex2i(width, trueHeight); + glEnd(); + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(0, borderHeight, 0, 0, 0); ptr++; + ptr->Set(0, 0, 0, 0, 0); ptr++; + ptr->Set(width, 0, 0, 0, 0); ptr++; + ptr->Set(width, borderHeight, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + ptr->Set(0, trueHeight, 0, 0, 0); ptr++; + ptr->Set(0, trueHeight - borderHeight, 0, 0, 0); ptr++; + ptr->Set(width, trueHeight - borderHeight, 0, 0, 0); ptr++; + ptr->Set(width, trueHeight, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } gl_RenderState.EnableTexture(true); glViewport(0, (trueHeight - height) / 2, width, height); @@ -391,25 +409,8 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) gl_RenderState.SetColor(color); gl_RenderState.EnableAlphaTest(false); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(u1, v1); - glVertex2d(x, y); - glTexCoord2f(u1, v2); - glVertex2d(x, y + h); - glTexCoord2f(u2, v1); - glVertex2d(x + w, y); - glTexCoord2f(u2, v2); - glVertex2d(x + w, y + h); - glEnd(); - - if (parms.colorOverlay) + if (!gl_usevbo) { - gl_RenderState.SetTextureMode(TM_MASK); - gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl_RenderState.BlendEquation(GL_FUNC_ADD); - gl_RenderState.SetColor(PalEntry(parms.colorOverlay)); - gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(u1, v1); glVertex2d(x, y); @@ -421,6 +422,47 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) glVertex2d(x + w, y + h); glEnd(); } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x, y, 0, u1, v1); ptr++; + ptr->Set(x, y + h, 0, u1, v2); ptr++; + ptr->Set(x + w, y, 0, u2, v1); ptr++; + ptr->Set(x + w, y + h, 0, u2, v2); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } + + if (parms.colorOverlay) + { + gl_RenderState.SetTextureMode(TM_MASK); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.SetColor(PalEntry(parms.colorOverlay)); + gl_RenderState.Apply(); + + if (!gl_usevbo) + { + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(u1, v1); + glVertex2d(x, y); + glTexCoord2f(u1, v2); + glVertex2d(x, y + h); + glTexCoord2f(u2, v1); + glVertex2d(x + w, y); + glTexCoord2f(u2, v2); + glVertex2d(x + w, y + h); + glEnd(); + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x, y, 0, u1, v1); ptr++; + ptr->Set(x, y + h, 0, u1, v2); ptr++; + ptr->Set(x + w, y, 0, u2, v1); ptr++; + ptr->Set(x + w, y + h, 0, u2, v2); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } + } gl_RenderState.EnableAlphaTest(true); @@ -442,10 +484,20 @@ void FGLRenderer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 gl_RenderState.EnableTexture(false); gl_RenderState.SetColorAlpha(p, 1.f); gl_RenderState.Apply(); - glBegin(GL_LINES); - glVertex2i(x1, y1); - glVertex2i(x2, y2); - glEnd(); + if (!gl_usevbo) + { + glBegin(GL_LINES); + glVertex2i(x1, y1); + glVertex2i(x2, y2); + glEnd(); + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x1, y1, 0, 0, 0); ptr++; + ptr->Set(x2, y2, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_LINES); + } gl_RenderState.EnableTexture(true); } @@ -460,9 +512,18 @@ void FGLRenderer::DrawPixel(int x1, int y1, int palcolor, uint32 color) gl_RenderState.EnableTexture(false); gl_RenderState.SetColorAlpha(p, 1.f); gl_RenderState.Apply(); - glBegin(GL_POINTS); - glVertex2i(x1, y1); - glEnd(); + if (!gl_usevbo) + { + glBegin(GL_POINTS); + glVertex2i(x1, y1); + glEnd(); + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x1, y1, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_POINTS); + } gl_RenderState.EnableTexture(true); } @@ -480,13 +541,24 @@ void FGLRenderer::Dim(PalEntry color, float damount, int x1, int y1, int w, int gl_RenderState.SetColorAlpha(color, damount); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); - glVertex2i(x1, y1); - glVertex2i(x1, y1 + h); - glVertex2i(x1 + w, y1 + h); - glVertex2i(x1 + w, y1); - glEnd(); - + if (!gl_usevbo) + { + glBegin(GL_TRIANGLE_FAN); + glVertex2i(x1, y1); + glVertex2i(x1, y1 + h); + glVertex2i(x1 + w, y1 + h); + glVertex2i(x1 + w, y1); + glEnd(); + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x1, y1, 0, 0, 0); ptr++; + ptr->Set(x1, y1+h, 0, 0, 0); ptr++; + ptr->Set(x1+w, y1+h, 0, 0, 0); ptr++; + ptr->Set(x1+w, y1, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + } gl_RenderState.EnableTexture(true); } @@ -522,12 +594,24 @@ void FGLRenderer::FlatFill (int left, int top, int right, int bottom, FTexture * } gl_RenderState.ResetColor(); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(fU1, fV1); glVertex2f(left, top); - glTexCoord2f(fU1, fV2); glVertex2f(left, bottom); - glTexCoord2f(fU2, fV1); glVertex2f(right, top); - glTexCoord2f(fU2, fV2); glVertex2f(right, bottom); - glEnd(); + if (!gl_usevbo) + { + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(fU1, fV1); glVertex2f(left, top); + glTexCoord2f(fU1, fV2); glVertex2f(left, bottom); + glTexCoord2f(fU2, fV1); glVertex2f(right, top); + glTexCoord2f(fU2, fV2); glVertex2f(right, bottom); + glEnd(); + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(left, top, 0, fU1, fV1); ptr++; + ptr->Set(left, bottom, 0, fU1, fV2); ptr++; + ptr->Set(right, top, 0, fU2, fV1); ptr++; + ptr->Set(right, bottom, 0, fU2, fV2); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } } //========================================================================== @@ -615,20 +699,41 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint float oy = float(originy); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); - for (i = 0; i < npoints; ++i) + if (!gl_usevbo) { - float u = points[i].X - 0.5f - ox; - float v = points[i].Y - 0.5f - oy; - if (dorotate) + glBegin(GL_TRIANGLE_FAN); + for (i = 0; i < npoints; ++i) { - float t = u; - u = t * cosrot - v * sinrot; - v = v * cosrot + t * sinrot; + float u = points[i].X - 0.5f - ox; + float v = points[i].Y - 0.5f - oy; + if (dorotate) + { + float t = u; + u = t * cosrot - v * sinrot; + v = v * cosrot + t * sinrot; + } + glTexCoord2f(u * uscale, v * vscale); + glVertex3f(points[i].X, points[i].Y /* + yoffs */, 0); } - glTexCoord2f(u * uscale, v * vscale); - glVertex3f(points[i].X, points[i].Y /* + yoffs */, 0); + glEnd(); + } + else + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (i = 0; i < npoints; ++i) + { + float u = points[i].X - 0.5f - ox; + float v = points[i].Y - 0.5f - oy; + if (dorotate) + { + float t = u; + u = t * cosrot - v * sinrot; + v = v * cosrot + t * sinrot; + } + ptr->Set(points[i].X, points[i].Y, 0, u*uscale, v*vscale); + ptr++; + } + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); } - glEnd(); } From 0cf37f2e512b4467b9826d54fff623cf5aee2d30 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 21 May 2014 12:36:29 +0200 Subject: [PATCH 0099/1509] - fixed problem with selecting special shaders. --- src/gl/renderer/gl_renderstate.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 4668bf2b7..7f5fd3b0d 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -129,12 +129,10 @@ bool FRenderState::ApplyShader() { activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect); } - FShader *shd = GLRenderer->mShaderManager->Get(mTextureEnabled? mEffectState : 4); - - if (shd != NULL) + else { - activeShader = shd; - shd->Bind(); + activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4); + activeShader->Bind(); } int fogset = 0; From 54425ee2efd4de0e8cb501dd214b3c9d6b1ade9e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 21 May 2014 13:40:46 +0200 Subject: [PATCH 0100/1509] - fixed: Desaturation factor was applied incorrectly. - Also fixed some very strange thing in the shader's desaturate function. For unknown reasons using the 'mix' function there did not work. - fixed: The fog boundary special shader could not be used. --- src/gl/renderer/gl_renderstate.cpp | 4 ++-- wadsrc/static/shaders/glsl/main.fp | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 7f5fd3b0d..673c201b8 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -125,7 +125,7 @@ bool FRenderState::ApplyShader() if (gl.hasGLSL()) { FShader *activeShader; - if (mSpecialEffect > 0) + if (mSpecialEffect > EFF_NONE) { activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect); } @@ -151,7 +151,7 @@ bool FRenderState::ApplyShader() glColor4fv(mColor.vec); - activeShader->muDesaturation.Set(mDesaturation); + activeShader->muDesaturation.Set(mDesaturation / 255.f); activeShader->muFogEnabled.Set(fogset); activeShader->muTextureMode.Set(mTextureMode); activeShader->muCameraPos.Set(mCameraPos.vec); diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index db5b8cb19..35b355206 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -31,8 +31,13 @@ vec4 desaturate(vec4 texel) { if (uDesaturationFactor > 0.0) { - float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14); - return mix (vec4(gray,gray,gray,texel.a), texel, uDesaturationFactor); + float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14) * uDesaturationFactor; + + vec4 desaturated = vec4(gray,gray,gray,texel.a); + // I have absolutely no idea why this works and 'mix' doesn't... + texel *= (1.0-uDesaturationFactor); + return texel + desaturated; + //return mix (desaturated, texel, uDesaturationFactor); } else { From 39775cc904b34b7470abaef6c483eec5709c1471 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 21 May 2014 15:25:25 +0200 Subject: [PATCH 0101/1509] - mystery of desaturation shader solved: The old code passed '1-desaturation' to the shader, the new code 'desaturation', so for the 'mix' function to work its arguments must be swapped. --- wadsrc/static/shaders/glsl/main.fp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 35b355206..afd075984 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -31,13 +31,8 @@ vec4 desaturate(vec4 texel) { if (uDesaturationFactor > 0.0) { - float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14) * uDesaturationFactor; - - vec4 desaturated = vec4(gray,gray,gray,texel.a); - // I have absolutely no idea why this works and 'mix' doesn't... - texel *= (1.0-uDesaturationFactor); - return texel + desaturated; - //return mix (desaturated, texel, uDesaturationFactor); + float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14); + return mix (texel, vec4(gray,gray,gray,texel.a), uDesaturationFactor); } else { From e813ddf251691299f490c6930045c07a62f6a9c2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 May 2014 16:47:34 +0200 Subject: [PATCH 0102/1509] - fixed bad comparison. --- src/gl/textures/gl_material.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 008e6e8cd..f27e1bed9 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -1009,7 +1009,7 @@ int FMaterial::GetAreas(FloatRect **pAreas) const void FMaterial::BindToFrameBuffer() { - if (mBaseLayer->gltexture == NULL) + if (mBaseLayer->gltexture[0] == NULL) { // must create the hardware texture first mBaseLayer->Bind(0, CM_DEFAULT, 0, 0, NULL, 0); From a1ec6ab1ba62361e3f9c35ba706369c6953422fa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 May 2014 16:53:57 +0200 Subject: [PATCH 0103/1509] - fixed some Linux warnings. --- src/gl/scene/gl_scene.cpp | 8 +++++--- src/gl/shaders/gl_shader.cpp | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 15f9444d4..a05aadde4 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -747,7 +747,7 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) // for various reasons (performance and keeping the lighting code clean) // we no longer do colormapped textures on pre GL 3.0 hardware and instead do // just a fullscreen overlay to emulate the inverse invulnerability effect or similar fullscreen blends. - if (gl_fixedcolormap >= CM_FIRSTSPECIALCOLORMAP && gl_fixedcolormap < CM_MAXCOLORMAP) + if (gl_fixedcolormap >= (DWORD)CM_FIRSTSPECIALCOLORMAP && gl_fixedcolormap < (DWORD)CM_MAXCOLORMAP) { FSpecialColormap *scm = &SpecialColormaps[gl_fixedcolormap - CM_FIRSTSPECIALCOLORMAP]; @@ -764,13 +764,14 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) g = scm->ColorizeEnd[1]; b = scm->ColorizeEnd[2]; } - } else if (gl_enhanced_nightvision) { if (gl_fixedcolormap == CM_LITE) { - r = 0.375f, g = 1.0f, b = 0.375f; + r = 0.375f; + g = 1.0f; + b = 0.375f; } else if (gl_fixedcolormap >= CM_TORCH) { @@ -782,6 +783,7 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) } else r = g = b = 1.f; } + else r = g = b = 1.f; if (inverse) { diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 35916bd00..994fdbf97 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -400,7 +400,7 @@ void FShaderManager::Clean() { if (gl.hasGLSL()) { - glUseProgram(NULL); + glUseProgram(0); mActiveShader = NULL; for (unsigned int i = 0; i < mTextureEffects.Size(); i++) @@ -446,7 +446,7 @@ void FShaderManager::SetActiveShader(FShader *sh) { if (gl.hasGLSL() && mActiveShader != sh) { - glUseProgram(sh!= NULL? sh->GetHandle() : NULL); + glUseProgram(sh!= NULL? sh->GetHandle() : 0); mActiveShader = sh; } } From c39318f406a12c48d997d6169177edef91e3d320 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 31 May 2014 09:32:17 +0200 Subject: [PATCH 0104/1509] - use vertex buffer and reuse of data for stencil drawing. A stencil needs to be drawn multiple times with the same polygons so this is a good place to optimize. --- src/gl/models/gl_models.cpp | 1 - src/gl/scene/gl_portal.cpp | 78 ++++++++++---- src/gl/scene/gl_portal.h | 1 + src/gl/scene/gl_vertex.cpp | 189 +++++++++++++++++++-------------- src/gl/scene/gl_wall.h | 1 + src/gl/scene/gl_walls_draw.cpp | 30 ++++++ 6 files changed, 202 insertions(+), 98 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 9c5212468..568a2e3f2 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -68,7 +68,6 @@ static inline float GetTimeFloat() CVAR(Bool, gl_interpolate_model_frames, true, CVAR_ARCHIVE) CVAR(Bool, gl_light_models, true, CVAR_ARCHIVE) EXTERN_CVAR(Int, gl_fogmode) -EXTERN_CVAR(Bool, gl_dynlight_shader) extern TDeletingArray Voxels; extern TDeletingArray VoxelDefs; diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index b49b0027d..18c6dcff5 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -54,6 +54,7 @@ #include "gl/renderer/gl_renderstate.h" #include "gl/dynlights/gl_glow.h" #include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_clipper.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" @@ -138,33 +139,74 @@ void GLPortal::ClearScreen() //----------------------------------------------------------------------------- void GLPortal::DrawPortalStencil() { - for(unsigned int i=0;i 1) + { + // Cap the stencil at the top and bottom + // (cheap ass version) + glBegin(GL_TRIANGLE_FAN); + glVertex3f(-32767.0f, 32767.0f, -32767.0f); + glVertex3f(-32767.0f, 32767.0f, 32767.0f); + glVertex3f(32767.0f, 32767.0f, 32767.0f); + glVertex3f(32767.0f, 32767.0f, -32767.0f); + glEnd(); + glBegin(GL_TRIANGLE_FAN); + glVertex3f(-32767.0f, -32767.0f, -32767.0f); + glVertex3f(-32767.0f, -32767.0f, 32767.0f); + glVertex3f(32767.0f, -32767.0f, 32767.0f); + glVertex3f(32767.0f, -32767.0f, -32767.0f); + glEnd(); + } } - - if (NeedCap() && lines.Size() > 1) + else { - // Cap the stencil at the top and bottom - // (cheap ass version) - glBegin(GL_TRIANGLE_FAN); - glVertex3f(-32767.0f,32767.0f,-32767.0f); - glVertex3f(-32767.0f,32767.0f, 32767.0f); - glVertex3f( 32767.0f,32767.0f, 32767.0f); - glVertex3f( 32767.0f,32767.0f,-32767.0f); - glEnd(); - glBegin(GL_TRIANGLE_FAN); - glVertex3f(-32767.0f,-32767.0f,-32767.0f); - glVertex3f(-32767.0f,-32767.0f, 32767.0f); - glVertex3f( 32767.0f,-32767.0f, 32767.0f); - glVertex3f( 32767.0f,-32767.0f,-32767.0f); - glEnd(); + if (mPrimIndices.Size() == 0) + { + bool cap = NeedCap() && lines.Size() > 1; + mPrimIndices.Resize(2 * lines.Size() + 4 * cap); + + for (unsigned int i = 0; imVBO->GetBuffer(); + ptr->Set(-32767.0f, 32767.0f, -32767.0f, 0, 0); + ptr->Set(-32767.0f, 32767.0f, 32767.0f, 0, 0); + ptr->Set(32767.0f, 32767.0f, 32767.0f, 0, 0); + ptr->Set(32767.0f, 32767.0f, -32767.0f, 0, 0); + mPrimIndices[n + 1] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n]); + ptr->Set(-32767.0f, -32767.0f, -32767.0f, 0, 0); + ptr->Set(-32767.0f, -32767.0f, 32767.0f, 0, 0); + ptr->Set(32767.0f, -32767.0f, 32767.0f, 0, 0); + ptr->Set(32767.0f, -32767.0f, -32767.0f, 0, 0); + mPrimIndices[n + 3] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n + 2]); + } + } + for (unsigned int i = 0; i < mPrimIndices.Size(); i += 2) + { + glDrawArrays(GL_TRIANGLE_FAN, mPrimIndices[i], mPrimIndices[i + 1]); + } } } + + + //----------------------------------------------------------------------------- // // Start diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index b04873ec8..970fc3523 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -104,6 +104,7 @@ private: unsigned char clipsave; GLPortal *NextPortal; TArray savedmapsection; + TArray mPrimIndices; protected: TArray lines; diff --git a/src/gl/scene/gl_vertex.cpp b/src/gl/scene/gl_vertex.cpp index 03f7df520..b3ee9c8b5 100644 --- a/src/gl/scene/gl_vertex.cpp +++ b/src/gl/scene/gl_vertex.cpp @@ -89,6 +89,116 @@ void GLWall::SplitUpperEdge(texcoord * tcs) vertexcount += sidedef->numsegs-1; } +//========================================================================== +// +// Split upper edge of wall +// +//========================================================================== + +void GLWall::SplitLowerEdge(texcoord * tcs) +{ + if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; + + side_t *sidedef = seg->sidedef; + float polyw = glseg.fracright - glseg.fracleft; + float facu = (tcs[3].u - tcs[0].u) / polyw; + float facv = (tcs[3].v - tcs[0].v) / polyw; + float facb = (zbottom[1] - zbottom[0]) / polyw; + float facc = (zceil[1] - zceil[0]) / polyw; + float facf = (zfloor[1] - zfloor[0]) / polyw; + + for (int i = sidedef->numsegs-2; i >= 0; i--) + { + seg_t *cseg = sidedef->segs[i]; + float sidefrac = cseg->sidefrac; + if (sidefrac >= glseg.fracright) continue; + if (sidefrac <= glseg.fracleft) return; + + float fracfac = sidefrac - glseg.fracleft; + + glTexCoord2f(tcs[0].u + facu * fracfac, tcs[0].v + facv * fracfac); + glVertex3f(cseg->v2->fx, zbottom[0] + facb * fracfac, cseg->v2->fy); + } + vertexcount += sidedef->numsegs-1; +} + +//========================================================================== +// +// Split left edge of wall +// +//========================================================================== + +void GLWall::SplitLeftEdge(texcoord * tcs) +{ + if (vertexes[0]==NULL) return; + + vertex_t * vi=vertexes[0]; + + if (vi->numheights) + { + int i=0; + + float polyh1=ztop[0] - zbottom[0]; + float factv1=polyh1? (tcs[1].v - tcs[0].v) / polyh1:0; + float factu1=polyh1? (tcs[1].u - tcs[0].u) / polyh1:0; + + while (inumheights && vi->heightlist[i] <= zbottom[0] ) i++; + while (inumheights && vi->heightlist[i] < ztop[0]) + { + glTexCoord2f(factu1*(vi->heightlist[i] - ztop[0]) + tcs[1].u, + factv1*(vi->heightlist[i] - ztop[0]) + tcs[1].v); + glVertex3f(glseg.x1, vi->heightlist[i], glseg.y1); + i++; + } + vertexcount+=i; + } +} + +//========================================================================== +// +// Split right edge of wall +// +//========================================================================== + +void GLWall::SplitRightEdge(texcoord * tcs) +{ + if (vertexes[1]==NULL) return; + + vertex_t * vi=vertexes[1]; + + if (vi->numheights) + { + int i=vi->numheights-1; + + float polyh2 = ztop[1] - zbottom[1]; + float factv2 = polyh2? (tcs[2].v - tcs[3].v) / polyh2:0; + float factu2 = polyh2? (tcs[2].u - tcs[3].u) / polyh2:0; + + while (i>0 && vi->heightlist[i] >= ztop[1]) i--; + while (i>0 && vi->heightlist[i] > zbottom[1]) + { + glTexCoord2f(factu2 * (vi->heightlist[i] - ztop[1]) + tcs[2].u, + factv2 * (vi->heightlist[i] - ztop[1]) + tcs[2].v); + glVertex3f(glseg.x2, vi->heightlist[i], glseg.y2); + i--; + } + vertexcount+=i; + } +} + + +//========================================================================== +// +// same for vertex buffer mode +// +//========================================================================== + +//========================================================================== +// +// Split upper edge of wall +// +//========================================================================== + void GLWall::SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr) { if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; @@ -126,33 +236,6 @@ void GLWall::SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr) // //========================================================================== -void GLWall::SplitLowerEdge(texcoord * tcs) -{ - if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; - - side_t *sidedef = seg->sidedef; - float polyw = glseg.fracright - glseg.fracleft; - float facu = (tcs[3].u - tcs[0].u) / polyw; - float facv = (tcs[3].v - tcs[0].v) / polyw; - float facb = (zbottom[1] - zbottom[0]) / polyw; - float facc = (zceil[1] - zceil[0]) / polyw; - float facf = (zfloor[1] - zfloor[0]) / polyw; - - for (int i = sidedef->numsegs-2; i >= 0; i--) - { - seg_t *cseg = sidedef->segs[i]; - float sidefrac = cseg->sidefrac; - if (sidefrac >= glseg.fracright) continue; - if (sidefrac <= glseg.fracleft) return; - - float fracfac = sidefrac - glseg.fracleft; - - glTexCoord2f(tcs[0].u + facu * fracfac, tcs[0].v + facv * fracfac); - glVertex3f(cseg->v2->fx, zbottom[0] + facb * fracfac, cseg->v2->fy); - } - vertexcount += sidedef->numsegs-1; -} - void GLWall::SplitLowerEdge(texcoord * tcs, FFlatVertex *&ptr) { if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; @@ -190,32 +273,6 @@ void GLWall::SplitLowerEdge(texcoord * tcs, FFlatVertex *&ptr) // //========================================================================== -void GLWall::SplitLeftEdge(texcoord * tcs) -{ - if (vertexes[0]==NULL) return; - - vertex_t * vi=vertexes[0]; - - if (vi->numheights) - { - int i=0; - - float polyh1=ztop[0] - zbottom[0]; - float factv1=polyh1? (tcs[1].v - tcs[0].v) / polyh1:0; - float factu1=polyh1? (tcs[1].u - tcs[0].u) / polyh1:0; - - while (inumheights && vi->heightlist[i] <= zbottom[0] ) i++; - while (inumheights && vi->heightlist[i] < ztop[0]) - { - glTexCoord2f(factu1*(vi->heightlist[i] - ztop[0]) + tcs[1].u, - factv1*(vi->heightlist[i] - ztop[0]) + tcs[1].v); - glVertex3f(glseg.x1, vi->heightlist[i], glseg.y1); - i++; - } - vertexcount+=i; - } -} - void GLWall::SplitLeftEdge(texcoord * tcs, FFlatVertex *&ptr) { if (vertexes[0] == NULL) return; @@ -251,32 +308,6 @@ void GLWall::SplitLeftEdge(texcoord * tcs, FFlatVertex *&ptr) // //========================================================================== -void GLWall::SplitRightEdge(texcoord * tcs) -{ - if (vertexes[1]==NULL) return; - - vertex_t * vi=vertexes[1]; - - if (vi->numheights) - { - int i=vi->numheights-1; - - float polyh2 = ztop[1] - zbottom[1]; - float factv2 = polyh2? (tcs[2].v - tcs[3].v) / polyh2:0; - float factu2 = polyh2? (tcs[2].u - tcs[3].u) / polyh2:0; - - while (i>0 && vi->heightlist[i] >= ztop[1]) i--; - while (i>0 && vi->heightlist[i] > zbottom[1]) - { - glTexCoord2f(factu2 * (vi->heightlist[i] - ztop[1]) + tcs[2].u, - factv2 * (vi->heightlist[i] - ztop[1]) + tcs[2].v); - glVertex3f(glseg.x2, vi->heightlist[i], glseg.y2); - i--; - } - vertexcount+=i; - } -} - void GLWall::SplitRightEdge(texcoord * tcs, FFlatVertex *&ptr) { if (vertexes[1] == NULL) return; diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index a9d0c1087..dd1365193 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -160,6 +160,7 @@ private: void SetupLights(); bool PrepareLight(texcoord * tcs, ADynamicLight * light); void RenderWall(int textured, float * color2, ADynamicLight * light=NULL); + void GetPrimitive(unsigned int *store); void FloodPlane(int pass); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 98ae66800..9c5baae6a 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -309,6 +309,36 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) } +//========================================================================== +// +// Gets the vertex data for rendering a stencil which needs to be +// repeated several times +// +//========================================================================== + +void GLWall::GetPrimitive(unsigned int *store) +{ + static texcoord tcs[4] = { 0, 0, 0, 0 }; + bool split = (gl_seamless && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ)); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + + ptr->Set(glseg.x1, zbottom[0], glseg.y1, 0, 0); + ptr++; + if (split && glseg.fracleft == 0) SplitLeftEdge(tcs, ptr); + ptr->Set(glseg.x1, ztop[0], glseg.y1, 0, 0); + ptr++; + if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs, ptr); + ptr->Set(glseg.x2, ztop[1], glseg.y2, 0, 0); + ptr++; + if (split && glseg.fracright == 1) SplitRightEdge(tcs, ptr); + ptr->Set(glseg.x2, zbottom[1], glseg.y2, 0, 0); + ptr++; + if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, ptr); + store[1] = GLRenderer->mVBO->GetCount(ptr, &store[0]); + vertexcount += 4; + } + //========================================================================== // // From d925279befed7d9d3c514ec9cf55c4900c3370e2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 1 Jun 2014 00:04:28 +0200 Subject: [PATCH 0105/1509] - fixed texture name handling in GL related texture classes for recent changes in ZDoom to eliminate the 8 character name limit. --- src/gl/textures/gl_skyboxtexture.cpp | 8 ++++---- src/gl/textures/gl_texture.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gl/textures/gl_skyboxtexture.cpp b/src/gl/textures/gl_skyboxtexture.cpp index 2db39c7a0..c004a4489 100644 --- a/src/gl/textures/gl_skyboxtexture.cpp +++ b/src/gl/textures/gl_skyboxtexture.cpp @@ -150,8 +150,8 @@ void gl_ParseSkybox(FScanner &sc) sc.MustGetString(); FSkyBox * sb = new FSkyBox; - uppercopy(sb->Name, sc.String); - sb->Name[8]=0; + sb->Name = sc.String; + sb->Name.ToUpper(); if (sc.CheckString("fliptop")) { sb->fliptop = true; @@ -192,8 +192,8 @@ void gl_ParseVavoomSkybox() int facecount=0; int maplump = -1; FSkyBox * sb = new FSkyBox; - uppercopy(sb->Name, sc.String); - sb->Name[8]=0; + sb->Name = sc.String; + sb->Name.ToUpper(); sb->fliptop = true; sc.MustGetStringName("{"); while (!sc.CheckString("}")) diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 29cafe27b..c4ead8b87 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -603,7 +603,7 @@ bool FTexture::ProcessData(unsigned char * buffer, int w, int h, bool ispatch) FBrightmapTexture::FBrightmapTexture (FTexture *source) { - memset(Name, 0, sizeof(Name)); + Name = ""; SourcePic = source; CopySize(source); bNoDecals = source->bNoDecals; @@ -650,7 +650,7 @@ int FBrightmapTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotat FCloneTexture::FCloneTexture (FTexture *source, int usetype) { - memset(Name, 0, sizeof(Name)); + Name = ""; SourcePic = source; CopySize(source); bNoDecals = source->bNoDecals; From a26fbc74f091270bd127cea737d4135074de94d1 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 1 Jun 2014 10:27:16 +0300 Subject: [PATCH 0106/1509] Fix compilation errors in latest texture-related changes GCC and Clang complain about non-POD type passed to variadic function. --- src/gl/dynlights/a_dynlight.cpp | 2 +- src/gl/shaders/gl_shader.cpp | 2 +- src/gl/textures/gl_hirestex.cpp | 4 ++-- src/gl/textures/gl_material.cpp | 2 +- src/gl/textures/gl_skyboxtexture.cpp | 6 +++--- src/gl/textures/gl_texture.cpp | 10 +++++----- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index bc12288cd..a123f34fc 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -689,7 +689,7 @@ CCMD(listlights) if (dl->target) { FTextureID spr = gl_GetSpriteFrame(dl->target->sprite, dl->target->frame, 0, 0, NULL); - Printf(", frame = %s ", TexMan[spr]->Name); + Printf(", frame = %s ", TexMan[spr]->Name.GetChars()); } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index ca1921bd4..7ac44f661 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -689,7 +689,7 @@ void gl_ParseHardwareShader(FScanner &sc, int deflump) { if (tex->bWarped != 0) { - Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name); + Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars()); return; } tex->gl_info.shaderspeed = speed; diff --git a/src/gl/textures/gl_hirestex.cpp b/src/gl/textures/gl_hirestex.cpp index b7824bf11..e3d115c4e 100644 --- a/src/gl/textures/gl_hirestex.cpp +++ b/src/gl/textures/gl_hirestex.cpp @@ -177,7 +177,7 @@ int CheckDDPK3(FTexture *tex) for (const char ** extp=extensions; *extp; extp++) { - checkName.Format(*checklist, tex->Name, *extp); + checkName.Format(*checklist, tex->Name.GetChars(), *extp); int lumpnum = Wads.CheckNumForFullName(checkName); if (lumpnum >= 0) return lumpnum; } @@ -358,7 +358,7 @@ int CheckExternalFile(FTexture *tex, bool & hascolorkey) for (const char ** extp=extensions; *extp; extp++) { - checkName.Format(*checklist, progdir.GetChars(), tex->Name, *extp); + checkName.Format(*checklist, progdir.GetChars(), tex->Name.GetChars(), *extp); if (_access(checkName, 0) == 0) { hascolorkey = !!strstr(checkName, "-ck."); diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index f27e1bed9..5e9a9be1a 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -1092,7 +1092,7 @@ int FGLTexture::Dump(int i) { int cnt = 0; int lump = tex->GetSourceLump(); - Printf(PRINT_LOG, "Texture '%s' (Index %d, Lump %d, Name '%s'):\n", tex->Name, i, lump, Wads.GetLumpFullName(lump)); + Printf(PRINT_LOG, "Texture '%s' (Index %d, Lump %d, Name '%s'):\n", tex->Name.GetChars(), i, lump, Wads.GetLumpFullName(lump)); if (hirestexture) Printf(PRINT_LOG, "\tHirestexture\n"); if (glpatch) Printf(PRINT_LOG, "\tPatch\n"),cnt++; if (gltexture[0]) Printf(PRINT_LOG, "\tTexture (x:no, y:no )\n"),cnt++; diff --git a/src/gl/textures/gl_skyboxtexture.cpp b/src/gl/textures/gl_skyboxtexture.cpp index c004a4489..658eb2004 100644 --- a/src/gl/textures/gl_skyboxtexture.cpp +++ b/src/gl/textures/gl_skyboxtexture.cpp @@ -168,7 +168,7 @@ void gl_ParseSkybox(FScanner &sc) } if (facecount != 3 && facecount != 6) { - sc.ScriptError("%s: Skybox definition requires either 3 or 6 faces", sb->Name); + sc.ScriptError("%s: Skybox definition requires either 3 or 6 faces", sb->Name.GetChars()); } sb->SetSize(); TexMan.AddTexture(sb); @@ -209,7 +209,7 @@ void gl_ParseVavoomSkybox() FTexture *tex = TexMan.FindTexture(sc.String, FTexture::TEX_Wall, FTextureManager::TEXMAN_TryAny); if (tex != NULL) { - Printf("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->Name); + Printf("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->Name.GetChars()); } sb->faces[facecount] = tex; sc.MustGetStringName("}"); @@ -218,7 +218,7 @@ void gl_ParseVavoomSkybox() } if (facecount != 6) { - sc.ScriptError("%s: Skybox definition requires 6 faces", sb->Name); + sc.ScriptError("%s: Skybox definition requires 6 faces", sb->Name.GetChars()); } sb->SetSize(); TexMan.AddTexture(sb); diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index c4ead8b87..4f6e999f2 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -294,7 +294,7 @@ void FTexture::CreateDefaultBrightmap() if (GlobalBrightmap.Remap[texbuf[i]] == white) { // Create a brightmap - DPrintf("brightmap created for texture '%s'\n", Name); + DPrintf("brightmap created for texture '%s'\n", Name.GetChars()); gl_info.Brightmap = new FBrightmapTexture(this); gl_info.bBrightmapChecked = 1; TexMan.AddTexture(gl_info.Brightmap); @@ -302,7 +302,7 @@ void FTexture::CreateDefaultBrightmap() } } // No bright pixels found - DPrintf("No bright pixels found in texture '%s'\n", Name); + DPrintf("No bright pixels found in texture '%s'\n", Name.GetChars()); gl_info.bBrightmapChecked = 1; } else @@ -735,13 +735,13 @@ void gl_ParseBrightmap(FScanner &sc, int deflump) if (bmtex != NULL) { - Printf("Multiple brightmap definitions in texture %s\n", tex? tex->Name : "(null)"); + Printf("Multiple brightmap definitions in texture %s\n", tex? tex->Name.GetChars() : "(null)"); } bmtex = TexMan.FindTexture(sc.String, FTexture::TEX_Any, FTextureManager::TEXMAN_TryAny); if (bmtex == NULL) - Printf("Brightmap '%s' not found in texture '%s'\n", sc.String, tex? tex->Name : "(null)"); + Printf("Brightmap '%s' not found in texture '%s'\n", sc.String, tex? tex->Name.GetChars() : "(null)"); } } if (!tex) @@ -765,7 +765,7 @@ void gl_ParseBrightmap(FScanner &sc, int deflump) { if (tex->bWarped != 0) { - Printf("Cannot combine warping with brightmap on texture '%s'\n", tex->Name); + Printf("Cannot combine warping with brightmap on texture '%s'\n", tex->Name.GetChars()); return; } From 2d8813a1650e6bb2e12a13e275b75444523409f3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 Jun 2014 18:58:25 +0200 Subject: [PATCH 0107/1509] - fixed dynamic light definition for Hexen's blue candle. --- wadsrc_lights/static/hexndefs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc_lights/static/hexndefs.txt b/wadsrc_lights/static/hexndefs.txt index ae062bd85..6c03da6db 100644 --- a/wadsrc_lights/static/hexndefs.txt +++ b/wadsrc_lights/static/hexndefs.txt @@ -1324,7 +1324,7 @@ flickerlight2 BCANDLE object ZBlueCandle { - frame CAND { light BCANDLE } + frame BCAN { light BCANDLE } } // Small flame From 8d9a90cd229edb2ba04e1c82cfd9e24f82be229c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 14 Jun 2014 01:24:28 +0200 Subject: [PATCH 0108/1509] - rewrote sky dome rendering to use a static vertex buffer if not on OpenGL 2.x. --- src/gl/data/gl_vertexbuffer.cpp | 1 + src/gl/data/gl_vertexbuffer.h | 43 ++++ src/gl/models/gl_voxels.cpp | 2 +- src/gl/renderer/gl_renderer.cpp | 3 + src/gl/renderer/gl_renderer.h | 2 + src/gl/renderer/gl_renderstate.h | 6 + src/gl/scene/gl_skydome.cpp | 331 +++++++++++++++++-------------- src/gl/system/gl_interface.cpp | 9 +- 8 files changed, 244 insertions(+), 153 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 8c43d968f..f7b4bdbf2 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -325,6 +325,7 @@ void FFlatVertexBuffer::BindVBO() glTexCoordPointer(2,GL_FLOAT, sizeof(FFlatVertex), &VTO->u); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); } } diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 806368ab0..dfa2afbc3 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -95,4 +95,47 @@ private: }; + +struct FSkyVertex +{ + float x, y, z, u, v; + PalEntry color; +}; + +class FSkyVertexBuffer : public FVertexBuffer +{ +public: + static const int SKYHEMI_UPPER = 1; + static const int SKYHEMI_LOWER = 2; + + enum + { + SKYMODE_MAINLAYER = 0, + SKYMODE_SECONDLAYER = 1, + SKYMODE_FOGLAYER = 2 + }; + +private: + TArray mVertices; + TArray mPrimStart; + + int mRows, mColumns; + + void SkyVertex(int r, int c, bool yflip); + void CreateSkyHemisphere(int hemi); + void CreateDome(); + void RenderRow(int prim, int row, bool color); + +public: + + FSkyVertexBuffer(); + virtual ~FSkyVertexBuffer(); + virtual void BindVBO(); + void RenderDome(FMaterial *tex, int mode); + +}; + +#define VSO ((FSkyVertex*)NULL) + + #endif \ No newline at end of file diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 99b565fc5..3a04cb5ca 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -284,7 +284,7 @@ void FVoxelVertexBuffer::BindVBO() glTexCoordPointer(2,GL_FLOAT, sizeof(FVoxelVertex), &VVO->u); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_INDEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 71595ffbc..1d1535d9a 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -94,6 +94,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mViewVector = FVector2(0,0); mCameraPos = FVector3(0,0,0); mVBO = NULL; + mSkyVBO = NULL; gl_spriteindex = 0; mShaderManager = NULL; glpart2 = glpart = gllight = mirrortexture = NULL; @@ -107,6 +108,7 @@ void FGLRenderer::Initialize() gllight = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/gllight.png"), FTexture::TEX_MiscPatch); mVBO = new FFlatVertexBuffer; + mSkyVBO = new FSkyVertexBuffer; gl_RenderState.SetVertexBuffer(mVBO); mFBID = 0; SetupLevel(); @@ -122,6 +124,7 @@ FGLRenderer::~FGLRenderer() //if (mThreadManager != NULL) delete mThreadManager; if (mShaderManager != NULL) delete mShaderManager; if (mVBO != NULL) delete mVBO; + if (mSkyVBO != NULL) delete mSkyVBO; if (glpart2) delete glpart2; if (glpart) delete glpart; if (mirrortexture) delete mirrortexture; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index fde918d16..77a38e7ae 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -9,6 +9,7 @@ struct particle_t; class FCanvasTexture; class FFlatVertexBuffer; +class FSkyVertexBuffer; class OpenGLFrameBuffer; struct FDrawInfo; struct pspdef_t; @@ -69,6 +70,7 @@ public: FVector3 mCameraPos; FFlatVertexBuffer *mVBO; + FSkyVertexBuffer *mSkyVBO; FGLRenderer(OpenGLFrameBuffer *fb); diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 79e277948..8bcedcac7 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -100,6 +100,12 @@ public: mVertexBuffer = vb; } + void ResetVertexBuffer() + { + // forces rebinding with the next 'apply' call. + mCurrentVertexBuffer = NULL; + } + void SetColor(float r, float g, float b, float a = 1.f, int desat = 0) { mColor.Set(r, g, b, a); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 5492a1649..7e33903c4 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -45,6 +45,7 @@ #include "gl/system/gl_interface.h" #include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" #include "gl/scene/gl_drawinfo.h" @@ -63,171 +64,208 @@ // //----------------------------------------------------------------------------- -CVAR (Int, gl_sky_detail, 16, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -EXTERN_CVAR (Bool, r_stretchsky) +CVAR(Float, skyoffset, 0, 0) // for testing extern int skyfog; -// The texture offset to be applied to the texture coordinates in SkyVertex(). - -static angle_t maxSideAngle = ANGLE_180 / 3; -static int rows, columns; -static fixed_t scale = 10000 << FRACBITS; -static bool yflip; -static int texw; -static float yAdd; -static bool foglayer; -static bool secondlayer; -static bool skymirror; - -#define SKYHEMI_UPPER 0x1 -#define SKYHEMI_LOWER 0x2 - - //----------------------------------------------------------------------------- // // // //----------------------------------------------------------------------------- -static void SkyVertex(int r, int c) +FSkyVertexBuffer::FSkyVertexBuffer() { - angle_t topAngle= (angle_t)(c / (float)columns * ANGLE_MAX); - angle_t sideAngle = maxSideAngle * (rows - r) / rows; + CreateDome(); +} + +FSkyVertexBuffer::~FSkyVertexBuffer() +{ +} + +void FSkyVertexBuffer::BindVBO() +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glVertexPointer(3, GL_FLOAT, sizeof(FSkyVertex), &VSO->x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FSkyVertex), &VSO->u); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(FSkyVertex), &VSO->color); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void FSkyVertexBuffer::SkyVertex(int r, int c, bool yflip) +{ + static const angle_t maxSideAngle = ANGLE_180 / 3; + static const fixed_t scale = 10000 << FRACBITS; + + angle_t topAngle= (angle_t)(c / (float)mColumns * ANGLE_MAX); + angle_t sideAngle = maxSideAngle * (mRows - r) / mRows; fixed_t height = finesine[sideAngle>>ANGLETOFINESHIFT]; fixed_t realRadius = FixedMul(scale, finecosine[sideAngle>>ANGLETOFINESHIFT]); fixed_t x = FixedMul(realRadius, finecosine[topAngle>>ANGLETOFINESHIFT]); fixed_t y = (!yflip) ? FixedMul(scale, height) : FixedMul(scale, height) * -1; fixed_t z = FixedMul(realRadius, finesine[topAngle>>ANGLETOFINESHIFT]); - float fx, fy, fz; - float color = r * 1.f / rows; - float u, v; - float timesRepeat; + + FSkyVertex vert; - timesRepeat = (short)(4 * (256.f / texw)); - if (timesRepeat == 0.f) timesRepeat = 1.f; - - if (!foglayer) + vert.color = r == 0 ? 0xffffff : 0xffffffff; + + // And the texture coordinates. + if(!yflip) // Flipped Y is for the lower hemisphere. { - // this must not use the renderstate because it's inside a primitive. - glColor4f(1.f, 1.f, 1.f, r==0? 0.0f : 1.0f); - - // And the texture coordinates. - if(!yflip) // Flipped Y is for the lower hemisphere. - { - u = (-timesRepeat * c / (float)columns) ; - v = (r / (float)rows) + yAdd; - } - else - { - u = (-timesRepeat * c / (float)columns) ; - v = 1.0f + ((rows-r)/(float)rows) + yAdd; - } - - - glTexCoord2f(skymirror? -u:u, v); + vert.u = (-c / (float)mColumns) ; + vert.v = (r / (float)mRows); } + else + { + vert.u = (-c / (float)mColumns); + vert.v = 1.0f + ((mRows - r) / (float)mRows); + } + if (r != 4) y+=FRACUNIT*300; // And finally the vertex. - fx =-FIXED2FLOAT(x); // Doom mirrors the sky vertically! - fy = FIXED2FLOAT(y); - fz = FIXED2FLOAT(z); - glVertex3f(fx, fy - 1.f, fz); + vert.x =-FIXED2FLOAT(x); // Doom mirrors the sky vertically! + vert.y = FIXED2FLOAT(y) - 1.f; + vert.z = FIXED2FLOAT(z); + + mVertices.Push(vert); } //----------------------------------------------------------------------------- // -// Hemi is Upper or Lower. Zero is not acceptable. -// The current texture is used. SKYHEMI_NO_TOPCAP can be used. +// // //----------------------------------------------------------------------------- -static void RenderSkyHemisphere(int hemi, bool mirror) +void FSkyVertexBuffer::CreateSkyHemisphere(int hemi) { int r, c; - - if (hemi & SKYHEMI_LOWER) + bool yflip = !!(hemi & SKYHEMI_LOWER); + + mPrimStart.Push(mVertices.Size()); + + for (c = 0; c < mColumns; c++) { - yflip = true; - } - else - { - yflip = false; + SkyVertex(1, c, yflip); } - skymirror = mirror; - - // The top row (row 0) is the one that's faded out. - // There must be at least 4 columns. The preferable number - // is 4n, where n is 1, 2, 3... There should be at least - // two rows because the first one is always faded. - rows = 4; - - // Draw the cap as one solid color polygon - if (!foglayer) + // The total number of triangles per hemisphere can be calculated + // as follows: rows * columns * 2 + 2 (for the top cap). + for (r = 0; r < mRows; r++) { - columns = 4 * (gl_sky_detail > 0 ? gl_sky_detail : 1); - foglayer=true; - gl_RenderState.EnableTexture(false); - gl_RenderState.Apply(); - - - if (!secondlayer) + mPrimStart.Push(mVertices.Size()); + for (c = 0; c <= mColumns; c++) { - glBegin(GL_TRIANGLE_FAN); - for(c = 0; c < columns; c++) - { - SkyVertex(1, c); - } - glEnd(); - gl_RenderState.SetObjectColor(0xffffffff); // unset the cap's color + SkyVertex(r + yflip, c, yflip); + SkyVertex(r + 1 - yflip, c, yflip); } + } +} - gl_RenderState.EnableTexture(true); - foglayer=false; - gl_RenderState.Apply(); +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void FSkyVertexBuffer::CreateDome() +{ + if (gl.version < 3.0f) + { + mColumns = 64; + mRows = 4; } else { - gl_RenderState.Apply(); - columns=4; // no need to do more! - glBegin(GL_TRIANGLE_FAN); - for(c = 0; c < columns; c++) + mColumns = 128; + mRows = 4; + } + CreateSkyHemisphere(SKYHEMI_UPPER); + CreateSkyHemisphere(SKYHEMI_LOWER); + mPrimStart.Push(mVertices.Size()); + if (gl.version >= 3.f) + { + // we won't bother with a real buffer for GL 2.x because the lack of shaders and therefore the objectColor uniform will require different handling. + // It'd also prevent changing to core features only. + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferData(GL_ARRAY_BUFFER, mVertices.Size() * sizeof(FSkyVertex), &mVertices[0], GL_STATIC_DRAW); + } +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void FSkyVertexBuffer::RenderRow(int prim, int row, bool color) +{ + if (gl.version < 3.f) + { + glBegin(prim); + for (unsigned int i = mPrimStart[row]; i < mPrimStart[row + 1]; i++) { - SkyVertex(0, c); + if (color) glColor4ubv((GLubyte*)&mVertices[i].color); + glTexCoord2fv(&mVertices[i].u); + glVertex3fv(&mVertices[i].x); } glEnd(); } - - // The total number of triangles per hemisphere can be calculated - // as follows: rows * columns * 2 + 2 (for the top cap). - for(r = 0; r < rows; r++) + else { - if (yflip) + glDrawArrays(prim, mPrimStart[row], mPrimStart[row + 1] - mPrimStart[row]); + } +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void FSkyVertexBuffer::RenderDome(FMaterial *tex, int mode) +{ + int rc = mRows + 1; + + if (mode != SKYMODE_SECONDLAYER) + { + if (mode == SKYMODE_MAINLAYER && tex != NULL) { - glBegin(GL_TRIANGLE_STRIP); - SkyVertex(r + 1, 0); - SkyVertex(r, 0); - for(c = 1; c <= columns; c++) - { - SkyVertex(r + 1, c); - SkyVertex(r, c); - } - glEnd(); + PalEntry pe = tex->tex->GetSkyCapColor(false); + gl_RenderState.SetObjectColor(pe); + gl_RenderState.EnableTexture(false); } - else + gl_RenderState.Apply(); + RenderRow(GL_TRIANGLE_FAN, 0, false); + + if (mode == SKYMODE_MAINLAYER && tex != NULL) { - glBegin(GL_TRIANGLE_STRIP); - SkyVertex(r, 0); - SkyVertex(r + 1, 0); - for(c = 1; c <= columns; c++) - { - SkyVertex(r, c); - SkyVertex(r + 1, c); - } - glEnd(); + PalEntry pe = tex->tex->GetSkyCapColor(true); + gl_RenderState.SetObjectColor(pe); } + gl_RenderState.Apply(); + RenderRow(GL_TRIANGLE_FAN, rc, false); + if (mode == SKYMODE_MAINLAYER && tex != NULL) + { + gl_RenderState.EnableTexture(true); + } + } + gl_RenderState.SetObjectColor(0xffffffff); + gl_RenderState.Apply(); + for (int i = 1; i <= mRows; i++) + { + RenderRow(GL_TRIANGLE_STRIP, i, true); + RenderRow(GL_TRIANGLE_STRIP, rc + i, true); } } @@ -237,12 +275,11 @@ static void RenderSkyHemisphere(int hemi, bool mirror) // // //----------------------------------------------------------------------------- -CVAR(Float, skyoffset, 0, 0) // for testing -static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float y_offset, bool mirror) +void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, int mode) { int texh = 0; - bool texscale = false; + int texw = 0; // 57 world units roughly represent one sky texel for the glTranslate call. const float skyoffsetfactor = 57; @@ -255,8 +292,9 @@ static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float texh = tex->TextureHeight(GLUSE_TEXTURE); glRotatef(-180.0f+x_offset, 0.f, 1.f, 0.f); - yAdd = y_offset/texh; + float xscale = 1024.f / float(texw); + float yscale = 1.f; if (texh < 200) { glTranslatef(0.f, -1250.f, 0.f); @@ -271,37 +309,25 @@ static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float { glTranslatef(0.f, (-40 + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); glScalef(1.f, 1.2f * 1.17f, 1.f); - glMatrixMode(GL_TEXTURE); - glPushMatrix(); - glLoadIdentity(); - glScalef(1.f, 240.f / texh, 1.f); - glMatrixMode(GL_MODELVIEW); - texscale = true; + yscale = 240.f / texh; } + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glLoadIdentity(); + glScalef(mirror? -xscale : xscale, yscale, 1.f); + glTranslatef(1.f, y_offset / texh, 1.f); + glMatrixMode(GL_MODELVIEW); } - if (tex && !secondlayer) - { - PalEntry pe = tex->tex->GetSkyCapColor(false); - gl_RenderState.SetObjectColor(pe); - } + GLRenderer->mSkyVBO->RenderDome(tex, mode); - RenderSkyHemisphere(SKYHEMI_UPPER, mirror); - - if (tex && !secondlayer) - { - PalEntry pe = tex->tex->GetSkyCapColor(true); - gl_RenderState.SetObjectColor(pe); - } - - RenderSkyHemisphere(SKYHEMI_LOWER, mirror); - if (texscale) + if (tex) { glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL_MODELVIEW); + glPopMatrix(); } - if (tex) glPopMatrix(); } @@ -527,12 +553,16 @@ void GLSkyPortal::DrawContents() } else { + if (gl.version >= 3.f) + { + gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO); + } if (origin->texture[0]==origin->texture[1] && origin->doublesky) origin->doublesky=false; if (origin->texture[0]) { gl_RenderState.SetTextureMode(TM_OPAQUE); - RenderDome(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->y_offset, origin->mirrored); + RenderDome(origin->texture[0], origin->x_offset[0], origin->y_offset, origin->mirrored, FSkyVertexBuffer::SKYMODE_MAINLAYER); gl_RenderState.SetTextureMode(TM_MODULATE); } @@ -541,19 +571,22 @@ void GLSkyPortal::DrawContents() if (origin->doublesky && origin->texture[1]) { - secondlayer=true; - RenderDome(FNullTextureID(), origin->texture[1], origin->x_offset[1], origin->y_offset, false); - secondlayer=false; + RenderDome(origin->texture[1], origin->x_offset[1], origin->y_offset, false, FSkyVertexBuffer::SKYMODE_SECONDLAYER); } if (skyfog>0 && (FadeColor.r ||FadeColor.g || FadeColor.b)) { gl_RenderState.EnableTexture(false); - foglayer=true; gl_RenderState.SetColorAlpha(FadeColor, skyfog / 255.0f); - RenderDome(FNullTextureID(), NULL, 0, 0, false); + // for the fog layer we must temporarily disable the color part of the vertex buffer. + glDisableClientState(GL_COLOR_ARRAY); + RenderDome(NULL, 0, 0, false, FSkyVertexBuffer::SKYMODE_FOGLAYER); + glEnableClientState(GL_COLOR_ARRAY); gl_RenderState.EnableTexture(true); - foglayer=false; + } + if (gl.version >= 3.f) + { + gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); } } glPopMatrix(); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 5f35c4ec2..e0d363446 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -122,7 +122,10 @@ void gl_LoadExtensions() InitContext(); CollectExtensions(); - const char *version = (const char*)glGetString(GL_VERSION); + const char *version = Args->CheckValue("-glversion"); + if (version == NULL) version = (const char*)glGetString(GL_VERSION); + else Printf("Emulating OpenGL v %s\n", version); + // Don't even start if it's lower than 1.3 if (strcmp(version, "2.0") < 0) @@ -139,9 +142,9 @@ void gl_LoadExtensions() if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; if (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; - gl.version = strtod((char*)glGetString(GL_VERSION), NULL); + gl.version = strtod(version, NULL); gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL); - if (Args->CheckParm("-noshader")) gl.glslversion = 0.0f; + if (gl.version < 3.f) gl.glslversion = 0.f; glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); From 5e22c82e79a600c7031d2c86442ab38d857db597 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 14 Jun 2014 10:38:30 +0200 Subject: [PATCH 0109/1509] - use buffer for rendering the sky on all GL versions since the differences for making GL2.0 work are rather small. --- src/gl/data/gl_vertexbuffer.h | 11 +++ src/gl/scene/gl_skydome.cpp | 123 ++++++++++++++-------------------- 2 files changed, 61 insertions(+), 73 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index dfa2afbc3..d7aeab9a2 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -100,6 +100,17 @@ struct FSkyVertex { float x, y, z, u, v; PalEntry color; + + void Set(float xx, float zz, float yy, float uu=0, float vv=0, PalEntry col=0xffffffff) + { + x = xx; + z = zz; + y = yy; + u = uu; + v = vv; + color = col; + } + }; class FSkyVertexBuffer : public FVertexBuffer diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 7e33903c4..0f5e86284 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -180,26 +180,32 @@ void FSkyVertexBuffer::CreateSkyHemisphere(int hemi) void FSkyVertexBuffer::CreateDome() { - if (gl.version < 3.0f) - { - mColumns = 64; - mRows = 4; - } - else - { - mColumns = 128; - mRows = 4; - } + // the first thing we put into the buffer is the fog layer object which is just 4 triangles around the viewpoint. + + mVertices.Reserve(12); + mVertices[0].Set( 1.0f, 1.0f, -1.0f); + mVertices[1].Set( 1.0f, -1.0f, -1.0f); + mVertices[2].Set(-1.0f, 0.0f, -1.0f); + + mVertices[3].Set( 1.0f, 1.0f, -1.0f); + mVertices[4].Set( 1.0f, -1.0f, -1.0f); + mVertices[5].Set( 0.0f, 0.0f, 1.0f); + + mVertices[6].Set(-1.0f, 0.0f, -1.0f); + mVertices[7].Set( 1.0f, 1.0f, -1.0f); + mVertices[8].Set( 0.0f, 0.0f, 1.0f); + + mVertices[9].Set(1.0f, -1.0f, -1.0f); + mVertices[10].Set(-1.0f, 0.0f, -1.0f); + mVertices[11].Set( 0.0f, 0.0f, 1.0f); + + mColumns = 128; + mRows = 4; CreateSkyHemisphere(SKYHEMI_UPPER); CreateSkyHemisphere(SKYHEMI_LOWER); mPrimStart.Push(mVertices.Size()); - if (gl.version >= 3.f) - { - // we won't bother with a real buffer for GL 2.x because the lack of shaders and therefore the objectColor uniform will require different handling. - // It'd also prevent changing to core features only. - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBufferData(GL_ARRAY_BUFFER, mVertices.Size() * sizeof(FSkyVertex), &mVertices[0], GL_STATIC_DRAW); - } + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferData(GL_ARRAY_BUFFER, mVertices.Size() * sizeof(FSkyVertex), &mVertices[0], GL_STATIC_DRAW); } //----------------------------------------------------------------------------- @@ -208,23 +214,9 @@ void FSkyVertexBuffer::CreateDome() // //----------------------------------------------------------------------------- -void FSkyVertexBuffer::RenderRow(int prim, int row, bool color) +inline void FSkyVertexBuffer::RenderRow(int prim, int row) { - if (gl.version < 3.f) - { - glBegin(prim); - for (unsigned int i = mPrimStart[row]; i < mPrimStart[row + 1]; i++) - { - if (color) glColor4ubv((GLubyte*)&mVertices[i].color); - glTexCoord2fv(&mVertices[i].u); - glVertex3fv(&mVertices[i].x); - } - glEnd(); - } - else - { - glDrawArrays(prim, mPrimStart[row], mPrimStart[row + 1] - mPrimStart[row]); - } + glDrawArrays(prim, mPrimStart[row], mPrimStart[row + 1] - mPrimStart[row]); } //----------------------------------------------------------------------------- @@ -237,35 +229,29 @@ void FSkyVertexBuffer::RenderDome(FMaterial *tex, int mode) { int rc = mRows + 1; - if (mode != SKYMODE_SECONDLAYER) + if (mode == SKYMODE_MAINLAYER && tex != NULL) { - if (mode == SKYMODE_MAINLAYER && tex != NULL) - { - PalEntry pe = tex->tex->GetSkyCapColor(false); - gl_RenderState.SetObjectColor(pe); - gl_RenderState.EnableTexture(false); - } + // if there's no shader we cannot use the default color from the buffer because the object color is part of the preset vertex attribute. + if (!gl.hasGLSL()) glDisableClientState(GL_COLOR_ARRAY); + PalEntry pe = tex->tex->GetSkyCapColor(false); + gl_RenderState.SetObjectColor(pe); + gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); - RenderRow(GL_TRIANGLE_FAN, 0, false); + RenderRow(GL_TRIANGLE_FAN, 0); - if (mode == SKYMODE_MAINLAYER && tex != NULL) - { - PalEntry pe = tex->tex->GetSkyCapColor(true); - gl_RenderState.SetObjectColor(pe); - } + PalEntry pe = tex->tex->GetSkyCapColor(true); + gl_RenderState.SetObjectColor(pe); gl_RenderState.Apply(); - RenderRow(GL_TRIANGLE_FAN, rc, false); - if (mode == SKYMODE_MAINLAYER && tex != NULL) - { - gl_RenderState.EnableTexture(true); - } + RenderRow(GL_TRIANGLE_FAN, rc); + gl_RenderState.EnableTexture(true); + if (!gl.hasGLSL()) glEnableClientState(GL_COLOR_ARRAY); } gl_RenderState.SetObjectColor(0xffffffff); gl_RenderState.Apply(); for (int i = 1; i <= mRows; i++) { - RenderRow(GL_TRIANGLE_STRIP, i, true); - RenderRow(GL_TRIANGLE_STRIP, rc + i, true); + RenderRow(GL_TRIANGLE_STRIP, i); + RenderRow(GL_TRIANGLE_STRIP, rc + i); } } @@ -525,18 +511,12 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool void GLSkyPortal::DrawContents() { bool drawBoth = false; - PalEntry FadeColor(0,0,0,0); // We have no use for Doom lighting special handling here, so disable it for this function. int oldlightmode = glset.lightmode; if (glset.lightmode == 8) glset.lightmode = 2; - if (!gl_fixedcolormap) - { - FadeColor = origin->fadecolor; - } - gl_RenderState.ResetColor(); gl_RenderState.EnableFog(false); gl_RenderState.EnableAlphaTest(false); @@ -553,10 +533,7 @@ void GLSkyPortal::DrawContents() } else { - if (gl.version >= 3.f) - { - gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO); - } + gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO); if (origin->texture[0]==origin->texture[1] && origin->doublesky) origin->doublesky=false; if (origin->texture[0]) @@ -574,20 +551,20 @@ void GLSkyPortal::DrawContents() RenderDome(origin->texture[1], origin->x_offset[1], origin->y_offset, false, FSkyVertexBuffer::SKYMODE_SECONDLAYER); } - if (skyfog>0 && (FadeColor.r ||FadeColor.g || FadeColor.b)) + if (skyfog>0 && gl_fixedcolormap == CM_DEFAULT && (origin->fadecolor & 0xffffff) != 0) { + PalEntry FadeColor = origin->fadecolor; + FadeColor.a = clamp(skyfog, 0, 255); + gl_RenderState.EnableTexture(false); - gl_RenderState.SetColorAlpha(FadeColor, skyfog / 255.0f); - // for the fog layer we must temporarily disable the color part of the vertex buffer. - glDisableClientState(GL_COLOR_ARRAY); - RenderDome(NULL, 0, 0, false, FSkyVertexBuffer::SKYMODE_FOGLAYER); - glEnableClientState(GL_COLOR_ARRAY); + gl_RenderState.SetObjectColor(FadeColor); + gl_RenderState.Apply(); + if (!gl.hasGLSL()) glDisableClientState(GL_COLOR_ARRAY); + glDrawArrays(GL_TRIANGLES, 0, 12); + if (!gl.hasGLSL()) glEnableClientState(GL_COLOR_ARRAY); gl_RenderState.EnableTexture(true); } - if (gl.version >= 3.f) - { - gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); - } + gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); } glPopMatrix(); glset.lightmode = oldlightmode; From 0ce6b406725407420df2a1fd10bd549d3b0e312b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 14 Jun 2014 14:58:17 +0200 Subject: [PATCH 0110/1509] - fixed compile error in gl_skydome.cpp - disable GL_ARB_buffer_storage when a -glversion parameter less than 4.0 is given. According to the spec this extension requires 4.0 so if emulating something lower it should not be used. --- src/gl/scene/gl_skydome.cpp | 3 ++- src/gl/system/gl_interface.cpp | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 0f5e86284..1a8794c58 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -229,6 +229,7 @@ void FSkyVertexBuffer::RenderDome(FMaterial *tex, int mode) { int rc = mRows + 1; + // The caps only get drawn for the main layer but not for the overlay. if (mode == SKYMODE_MAINLAYER && tex != NULL) { // if there's no shader we cannot use the default color from the buffer because the object color is part of the preset vertex attribute. @@ -239,7 +240,7 @@ void FSkyVertexBuffer::RenderDome(FMaterial *tex, int mode) gl_RenderState.Apply(); RenderRow(GL_TRIANGLE_FAN, 0); - PalEntry pe = tex->tex->GetSkyCapColor(true); + pe = tex->tex->GetSkyCapColor(true); gl_RenderState.SetObjectColor(pe); gl_RenderState.Apply(); RenderRow(GL_TRIANGLE_FAN, rc); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index e0d363446..ac34bd2c1 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -132,6 +132,9 @@ void gl_LoadExtensions() { I_FatalError("Unsupported OpenGL version.\nAt least GL 2.0 is required to run " GAMENAME ".\n"); } + gl.version = strtod(version, NULL); + gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL); + if (gl.version < 3.f) gl.glslversion = 0.f; // This loads any function pointers and flags that require a vaild render context to // initialize properly @@ -140,11 +143,7 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; - if (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; - - gl.version = strtod(version, NULL); - gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL); - if (gl.version < 3.f) gl.glslversion = 0.f; + if (gl.version >= 4.f && CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); From 5b302ed3a6157acb56820c0871b479aba7abd072 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 14 Jun 2014 15:16:33 +0200 Subject: [PATCH 0111/1509] - added benchmarking calls for glDrawArrays to see how well issunig draw calls performs on different hardware. --- src/gl/data/gl_vertexbuffer.h | 9 +++++++-- src/gl/scene/gl_flats.cpp | 2 ++ src/gl/scene/gl_sprite.cpp | 3 +-- src/gl/utility/gl_clock.cpp | 6 ++++-- src/gl/utility/gl_clock.h | 1 + 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index d7aeab9a2..0862106d7 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -2,6 +2,7 @@ #define __VERTEXBUFFER_H #include "tarray.h" +#include "gl/utility/gl_clock.h" struct vertex_t; struct secplane_t; @@ -74,11 +75,15 @@ public: return diff; } #ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway. - void RenderCurrent(FFlatVertex *newptr, unsigned int primtype) + void RenderCurrent(FFlatVertex *newptr, unsigned int primtype, unsigned int *poffset = NULL, unsigned int *pcount = NULL) { unsigned int offset; unsigned int count = GetCount(newptr, &offset); + drawcalls.Clock(); glDrawArrays(primtype, offset, count); + drawcalls.Unclock(); + if (poffset) *poffset = offset; + if (pcount) *pcount = count; } #endif void Reset() @@ -135,7 +140,7 @@ private: void SkyVertex(int r, int c, bool yflip); void CreateSkyHemisphere(int hemi); void CreateDome(); - void RenderRow(int prim, int row, bool color); + void RenderRow(int prim, int row); public: diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 71bb2197b..39731bf74 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -332,7 +332,9 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) { if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub); + drawcalls.Clock(); glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines); + drawcalls.Unclock(); flatvertices += sub->numlines; flatprimitives++; } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 63c7bd46b..e36dd4b0e 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -300,8 +300,7 @@ void GLSprite::Draw(int pass) ptr++; ptr->Set(v4[0], v4[1], v4[2], ur, vb); ptr++; - count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_STRIP, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); } if (foglayer) diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp index 7759f5582..d8d3c28be 100644 --- a/src/gl/utility/gl_clock.cpp +++ b/src/gl/utility/gl_clock.cpp @@ -23,6 +23,7 @@ glcycle_t All, Finish, PortalAll, Bsp; glcycle_t ProcessAll; glcycle_t RenderAll; glcycle_t Dirty; +glcycle_t drawcalls; int vertexcount, flatvertices, flatprimitives; int rendered_lines,rendered_flats,rendered_sprites,render_vertexsplit,render_texsplit,rendered_decals, rendered_portals; @@ -96,6 +97,7 @@ void ResetProfilingData() SetupFlat.Reset(); RenderSprite.Reset(); SetupSprite.Reset(); + drawcalls.Reset(); flatvertices=flatprimitives=vertexcount=0; render_texsplit=render_vertexsplit=rendered_lines=rendered_flats=rendered_sprites=rendered_decals=rendered_portals = 0; @@ -116,10 +118,10 @@ static void AppendRenderTimes(FString &str) str.AppendFormat("W: Render=%2.3f, Split = %2.3f, Setup=%2.3f, Clip=%2.3f\n" "F: Render=%2.3f, Setup=%2.3f\n" "S: Render=%2.3f, Setup=%2.3f\n" - "All=%2.3f, Render=%2.3f, Setup=%2.3f, BSP = %2.3f, Portal=%2.3f, Finish=%2.3f\n", + "All=%2.3f, Render=%2.3f, Setup=%2.3f, BSP = %2.3f, Portal=%2.3f, Drawcalls=%2.3f, Finish=%2.3f\n", RenderWall.TimeMS(), SplitWall.TimeMS(), setupwall, clipwall, RenderFlat.TimeMS(), SetupFlat.TimeMS(), RenderSprite.TimeMS(), SetupSprite.TimeMS(), All.TimeMS() + Finish.TimeMS(), RenderAll.TimeMS(), - ProcessAll.TimeMS(), bsp, PortalAll.TimeMS(), Finish.TimeMS()); + ProcessAll.TimeMS(), bsp, PortalAll.TimeMS(), drawcalls.TimeMS(), Finish.TimeMS()); } static void AppendRenderStats(FString &out) diff --git a/src/gl/utility/gl_clock.h b/src/gl/utility/gl_clock.h index cb9d0173e..604a40a02 100644 --- a/src/gl/utility/gl_clock.h +++ b/src/gl/utility/gl_clock.h @@ -108,6 +108,7 @@ extern glcycle_t All, Finish, PortalAll, Bsp; extern glcycle_t ProcessAll; extern glcycle_t RenderAll; extern glcycle_t Dirty; +extern glcycle_t drawcalls; extern int iter_dlightf, iter_dlight, draw_dlight, draw_dlightf; extern int rendered_lines,rendered_flats,rendered_sprites,rendered_decals,render_vertexsplit,render_texsplit; From 3644073bbd57161c571b666b0cdcade298637c8a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Jun 2014 01:14:41 +0200 Subject: [PATCH 0112/1509] - use a software buffer for immediate mode rendering. This allows using the regular buffer code to collect data for both render modes and allows removal of a lot of duplicated code. --- src/gl/data/gl_vertexbuffer.cpp | 26 +++- src/gl/data/gl_vertexbuffer.h | 27 +++- src/gl/renderer/gl_renderer.cpp | 229 +++++++++----------------------- src/gl/scene/gl_decal.cpp | 24 +--- src/gl/scene/gl_drawinfo.cpp | 105 +++++---------- src/gl/scene/gl_flats.cpp | 73 +++------- src/gl/scene/gl_scene.cpp | 32 ++--- src/gl/scene/gl_sprite.cpp | 68 ++-------- src/gl/scene/gl_vertex.cpp | 142 -------------------- src/gl/scene/gl_wall.h | 7 +- src/gl/scene/gl_walls_draw.cpp | 103 +++++--------- src/gl/scene/gl_weapon.cpp | 32 ++--- 12 files changed, 232 insertions(+), 636 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index f7b4bdbf2..8093a57a0 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -53,7 +53,7 @@ CUSTOM_CVAR(Int, gl_usevbo, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCA { if (self < -1 || self > 1 || !(gl.flags & RFL_BUFFER_STORAGE)) { - self = 0; + if (self != 0) self = 0; } else if (self == -1) { @@ -101,7 +101,8 @@ FFlatVertexBuffer::FFlatVertexBuffer() } else { - map = NULL; + vbo_shadowdata.Reserve(BUFFER_SIZE); + map = &vbo_shadowdata[0]; } mIndex = mCurIndex = 0; } @@ -113,6 +114,25 @@ FFlatVertexBuffer::~FFlatVertexBuffer() glBindBuffer(GL_ARRAY_BUFFER, 0); } +//========================================================================== +// +// Renders the buffer's contents with immediate mode functions +// This is here so that the immediate mode fallback does not need +// to double all rendering code and can instead reuse the buffer-based version +// +//========================================================================== + +void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count) +{ + glBegin(primtype); + for (unsigned int i = 0; i < count; i++) + { + glTexCoord2fv(&map[offset + i].u); + glVertex3fv(&map[offset + i].x); + } + glEnd(); +} + //========================================================================== // // Initialize a single vertex @@ -369,7 +389,7 @@ void FFlatVertexBuffer::CheckPlanes(sector_t *sector) void FFlatVertexBuffer::CheckUpdate(sector_t *sector) { - if (vbo_arg == 2) + if (gl.flags & RFL_BUFFER_STORAGE) { CheckPlanes(sector); sector_t *hs = sector->GetHeightSec(); diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 0862106d7..50ddd7d13 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -3,6 +3,7 @@ #include "tarray.h" #include "gl/utility/gl_clock.h" +#include "gl/system/gl_interface.h" struct vertex_t; struct secplane_t; @@ -43,6 +44,7 @@ struct FFlatVertex class FFlatVertexBuffer : public FVertexBuffer { FFlatVertex *map; + FFlatVertex mDrawBuffer[1000]; unsigned int mIndex; unsigned int mCurIndex; @@ -50,9 +52,10 @@ class FFlatVertexBuffer : public FVertexBuffer const unsigned int BUFFER_SIZE = 2000000; + void ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count); + public: - int vbo_arg; - TArray vbo_shadowdata; // this is kept around for updating the actual (non-readable) buffer + TArray vbo_shadowdata; // this is kept around for updating the actual (non-readable) buffer and as stand-in for pre GL 4.x FFlatVertexBuffer(); ~FFlatVertexBuffer(); @@ -67,6 +70,7 @@ public: } unsigned int GetCount(FFlatVertex *newptr, unsigned int *poffset) { + unsigned int newofs = (unsigned int)(newptr - map); unsigned int diff = newofs - mCurIndex; *poffset = mCurIndex; @@ -75,16 +79,29 @@ public: return diff; } #ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway. + void RenderArray(unsigned int primtype, unsigned int offset, unsigned int count) + { + drawcalls.Clock(); + if (gl.flags & RFL_BUFFER_STORAGE) + { + glDrawArrays(primtype, offset, count); + } + else + { + ImmRenderBuffer(primtype, offset, count); + } + drawcalls.Unclock(); + } + void RenderCurrent(FFlatVertex *newptr, unsigned int primtype, unsigned int *poffset = NULL, unsigned int *pcount = NULL) { unsigned int offset; unsigned int count = GetCount(newptr, &offset); - drawcalls.Clock(); - glDrawArrays(primtype, offset, count); - drawcalls.Unclock(); + RenderArray(primtype, offset, count); if (poffset) *poffset = offset; if (pcount) *pcount = count; } + #endif void Reset() { diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 1d1535d9a..78ec2e34e 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -283,36 +283,17 @@ void FGLRenderer::ClearBorders() gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); - if (!gl_usevbo) - { - glBegin(GL_QUADS); - // upper quad - glVertex2i(0, borderHeight); - glVertex2i(0, 0); - glVertex2i(width, 0); - glVertex2i(width, borderHeight); - - // lower quad - glVertex2i(0, trueHeight); - glVertex2i(0, trueHeight - borderHeight); - glVertex2i(width, trueHeight - borderHeight); - glVertex2i(width, trueHeight); - glEnd(); - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(0, borderHeight, 0, 0, 0); ptr++; - ptr->Set(0, 0, 0, 0, 0); ptr++; - ptr->Set(width, 0, 0, 0, 0); ptr++; - ptr->Set(width, borderHeight, 0, 0, 0); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - ptr->Set(0, trueHeight, 0, 0, 0); ptr++; - ptr->Set(0, trueHeight - borderHeight, 0, 0, 0); ptr++; - ptr->Set(width, trueHeight - borderHeight, 0, 0, 0); ptr++; - ptr->Set(width, trueHeight, 0, 0, 0); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(0, borderHeight, 0, 0, 0); ptr++; + ptr->Set(0, 0, 0, 0, 0); ptr++; + ptr->Set(width, 0, 0, 0, 0); ptr++; + ptr->Set(width, borderHeight, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + ptr->Set(0, trueHeight, 0, 0, 0); ptr++; + ptr->Set(0, trueHeight - borderHeight, 0, 0, 0); ptr++; + ptr->Set(width, trueHeight - borderHeight, 0, 0, 0); ptr++; + ptr->Set(width, trueHeight, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); gl_RenderState.EnableTexture(true); glViewport(0, (trueHeight - height) / 2, width, height); @@ -412,28 +393,13 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) gl_RenderState.SetColor(color); gl_RenderState.EnableAlphaTest(false); gl_RenderState.Apply(); - if (!gl_usevbo) - { - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(u1, v1); - glVertex2d(x, y); - glTexCoord2f(u1, v2); - glVertex2d(x, y + h); - glTexCoord2f(u2, v1); - glVertex2d(x + w, y); - glTexCoord2f(u2, v2); - glVertex2d(x + w, y + h); - glEnd(); - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(x, y, 0, u1, v1); ptr++; - ptr->Set(x, y + h, 0, u1, v2); ptr++; - ptr->Set(x + w, y, 0, u2, v1); ptr++; - ptr->Set(x + w, y + h, 0, u2, v2); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x, y, 0, u1, v1); ptr++; + ptr->Set(x, y + h, 0, u1, v2); ptr++; + ptr->Set(x + w, y, 0, u2, v1); ptr++; + ptr->Set(x + w, y + h, 0, u2, v2); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); if (parms.colorOverlay) { @@ -443,28 +409,12 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) gl_RenderState.SetColor(PalEntry(parms.colorOverlay)); gl_RenderState.Apply(); - if (!gl_usevbo) - { - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(u1, v1); - glVertex2d(x, y); - glTexCoord2f(u1, v2); - glVertex2d(x, y + h); - glTexCoord2f(u2, v1); - glVertex2d(x + w, y); - glTexCoord2f(u2, v2); - glVertex2d(x + w, y + h); - glEnd(); - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(x, y, 0, u1, v1); ptr++; - ptr->Set(x, y + h, 0, u1, v2); ptr++; - ptr->Set(x + w, y, 0, u2, v1); ptr++; - ptr->Set(x + w, y + h, 0, u2, v2); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x, y, 0, u1, v1); ptr++; + ptr->Set(x, y + h, 0, u1, v2); ptr++; + ptr->Set(x + w, y, 0, u2, v1); ptr++; + ptr->Set(x + w, y + h, 0, u2, v2); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } gl_RenderState.EnableAlphaTest(true); @@ -487,20 +437,12 @@ void FGLRenderer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 gl_RenderState.EnableTexture(false); gl_RenderState.SetColorAlpha(p, 1.f); gl_RenderState.Apply(); - if (!gl_usevbo) - { - glBegin(GL_LINES); - glVertex2i(x1, y1); - glVertex2i(x2, y2); - glEnd(); - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(x1, y1, 0, 0, 0); ptr++; - ptr->Set(x2, y2, 0, 0, 0); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_LINES); - } + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x1, y1, 0, 0, 0); ptr++; + ptr->Set(x2, y2, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_LINES); + gl_RenderState.EnableTexture(true); } @@ -515,18 +457,11 @@ void FGLRenderer::DrawPixel(int x1, int y1, int palcolor, uint32 color) gl_RenderState.EnableTexture(false); gl_RenderState.SetColorAlpha(p, 1.f); gl_RenderState.Apply(); - if (!gl_usevbo) - { - glBegin(GL_POINTS); - glVertex2i(x1, y1); - glEnd(); - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(x1, y1, 0, 0, 0); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_POINTS); - } + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x1, y1, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_POINTS); + gl_RenderState.EnableTexture(true); } @@ -544,24 +479,13 @@ void FGLRenderer::Dim(PalEntry color, float damount, int x1, int y1, int w, int gl_RenderState.SetColorAlpha(color, damount); gl_RenderState.Apply(); - if (!gl_usevbo) - { - glBegin(GL_TRIANGLE_FAN); - glVertex2i(x1, y1); - glVertex2i(x1, y1 + h); - glVertex2i(x1 + w, y1 + h); - glVertex2i(x1 + w, y1); - glEnd(); - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(x1, y1, 0, 0, 0); ptr++; - ptr->Set(x1, y1+h, 0, 0, 0); ptr++; - ptr->Set(x1+w, y1+h, 0, 0, 0); ptr++; - ptr->Set(x1+w, y1, 0, 0, 0); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); - } + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x1, y1, 0, 0, 0); ptr++; + ptr->Set(x1, y1+h, 0, 0, 0); ptr++; + ptr->Set(x1+w, y1+h, 0, 0, 0); ptr++; + ptr->Set(x1+w, y1, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + gl_RenderState.EnableTexture(true); } @@ -597,24 +521,13 @@ void FGLRenderer::FlatFill (int left, int top, int right, int bottom, FTexture * } gl_RenderState.ResetColor(); gl_RenderState.Apply(); - if (!gl_usevbo) - { - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(fU1, fV1); glVertex2f(left, top); - glTexCoord2f(fU1, fV2); glVertex2f(left, bottom); - glTexCoord2f(fU2, fV1); glVertex2f(right, top); - glTexCoord2f(fU2, fV2); glVertex2f(right, bottom); - glEnd(); - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(left, top, 0, fU1, fV1); ptr++; - ptr->Set(left, bottom, 0, fU1, fV2); ptr++; - ptr->Set(right, top, 0, fU2, fV1); ptr++; - ptr->Set(right, bottom, 0, fU2, fV2); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(left, top, 0, fU1, fV1); ptr++; + ptr->Set(left, bottom, 0, fU1, fV2); ptr++; + ptr->Set(right, top, 0, fU2, fV1); ptr++; + ptr->Set(right, bottom, 0, fU2, fV2); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } //========================================================================== @@ -702,41 +615,21 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint float oy = float(originy); gl_RenderState.Apply(); - if (!gl_usevbo) + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (i = 0; i < npoints; ++i) { - glBegin(GL_TRIANGLE_FAN); - for (i = 0; i < npoints; ++i) + float u = points[i].X - 0.5f - ox; + float v = points[i].Y - 0.5f - oy; + if (dorotate) { - float u = points[i].X - 0.5f - ox; - float v = points[i].Y - 0.5f - oy; - if (dorotate) - { - float t = u; - u = t * cosrot - v * sinrot; - v = v * cosrot + t * sinrot; - } - glTexCoord2f(u * uscale, v * vscale); - glVertex3f(points[i].X, points[i].Y /* + yoffs */, 0); + float t = u; + u = t * cosrot - v * sinrot; + v = v * cosrot + t * sinrot; } - glEnd(); - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - for (i = 0; i < npoints; ++i) - { - float u = points[i].X - 0.5f - ox; - float v = points[i].Y - 0.5f - oy; - if (dorotate) - { - float t = u; - u = t * cosrot - v * sinrot; - v = v * cosrot + t * sinrot; - } - ptr->Set(points[i].X, points[i].Y, 0, u*uscale, v*vscale); - ptr++; - } - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + ptr->Set(points[i].X, points[i].Y, 0, u*uscale, v*vscale); + ptr++; } + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); } diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 8f2e7977a..e6d5c144f 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -337,26 +337,14 @@ void GLWall::DrawDecal(DBaseDecal *decal) else gl_RenderState.AlphaFunc(GL_GREATER, 0.f); gl_RenderState.Apply(); - if (!gl_usevbo) + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (i = 0; i < 4; i++) { - glBegin(GL_TRIANGLE_FAN); - for (i = 0; i < 4; i++) - { - glTexCoord2f(dv[i].u, dv[i].v); - glVertex3f(dv[i].x, dv[i].z, dv[i].y); - } - glEnd(); - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - for (i = 0; i < 4; i++) - { - ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); - ptr++; - } - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); + ptr++; } + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + rendered_decals++; gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.SetObjectColor(0xffffffff); diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index fc44c7896..8c620d93e 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -991,28 +991,17 @@ void FDrawInfo::SetupFloodStencil(wallseg * ws) glDepthMask(true); gl_RenderState.Apply(); - if (!gl_usevbo) - { - glBegin(GL_TRIANGLE_FAN); - glVertex3f(ws->x1, ws->z1, ws->y1); - glVertex3f(ws->x1, ws->z2, ws->y1); - glVertex3f(ws->x2, ws->z2, ws->y2); - glVertex3f(ws->x2, ws->z1, ws->y2); - glEnd(); - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0); - ptr++; - ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0); - ptr++; - ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0); - ptr++; - ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); - } + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil @@ -1033,28 +1022,16 @@ void FDrawInfo::ClearFloodStencil(wallseg * ws) gl_RenderState.ResetColor(); gl_RenderState.Apply(); - if (!gl_usevbo) - { - glBegin(GL_TRIANGLE_FAN); - glVertex3f(ws->x1, ws->z1, ws->y1); - glVertex3f(ws->x1, ws->z2, ws->y1); - glVertex3f(ws->x2, ws->z2, ws->y2); - glVertex3f(ws->x2, ws->z1, ws->y2); - glEnd(); - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0); - ptr++; - ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0); - ptr++; - ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0); - ptr++; - ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); - } + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); // restore old stencil op. glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); @@ -1126,36 +1103,16 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo float px4 = fviewx + prj_fac1 * (ws->x2-fviewx); float py4 = fviewy + prj_fac1 * (ws->y2-fviewy); - if (!gl_usevbo) - { - glBegin(GL_TRIANGLE_FAN); - glTexCoord2f(px1 / 64, -py1 / 64); - glVertex3f(px1, planez, py1); - - glTexCoord2f(px2 / 64, -py2 / 64); - glVertex3f(px2, planez, py2); - - glTexCoord2f(px3 / 64, -py3 / 64); - glVertex3f(px3, planez, py3); - - glTexCoord2f(px4 / 64, -py4 / 64); - glVertex3f(px4, planez, py4); - - glEnd(); - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(px1, planez, py1, px1 / 64, -py1 / 64); - ptr++; - ptr->Set(px2, planez, py2, px2 / 64, -py2 / 64); - ptr++; - ptr->Set(px3, planez, py3, px3 / 64, -py3 / 64); - ptr++; - ptr->Set(px4, planez, py4, px4 / 64, -py4 / 64); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); - } + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(px1, planez, py1, px1 / 64, -py1 / 64); + ptr++; + ptr->Set(px2, planez, py2, px2 / 64, -py2 / 64); + ptr++; + ptr->Set(px3, planez, py3, px3 / 64, -py3 / 64); + ptr++; + ptr->Set(px4, planez, py4, px4 / 64, -py4 / 64); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); if (pushed) { diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 39731bf74..59d4192e7 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -239,64 +239,35 @@ bool GLFlat::SetupSubsectorLights(bool lightsapplied, subsector_t * sub) void GLFlat::DrawSubsector(subsector_t * sub) { - if (!gl_usevbo) + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + if (plane.plane.a | plane.plane.b) { - glBegin(GL_TRIANGLE_FAN); - - if (plane.plane.a | plane.plane.b) + for (unsigned int k = 0; k < sub->numlines; k++) { - for (unsigned int k = 0; k < sub->numlines; k++) - { - vertex_t *vt = sub->firstline[k].v1; - glTexCoord2f(vt->fx / 64.f, -vt->fy / 64.f); - float zc = plane.plane.ZatPoint(vt->fx, vt->fy) + dz; - glVertex3f(vt->fx, zc, vt->fy); - } + vertex_t *vt = sub->firstline[k].v1; + ptr->x = vt->fx; + ptr->y = vt->fy; + ptr->z = plane.plane.ZatPoint(vt->fx, vt->fy) + dz; + ptr->u = vt->fx / 64.f; + ptr->v = -vt->fy / 64.f; + ptr++; } - else - { - float zc = FIXED2FLOAT(plane.plane.Zat0()) + dz; - for (unsigned int k = 0; k < sub->numlines; k++) - { - vertex_t *vt = sub->firstline[k].v1; - glTexCoord2f(vt->fx / 64.f, -vt->fy / 64.f); - glVertex3f(vt->fx, zc, vt->fy); - } - } - glEnd(); } else { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - if (plane.plane.a | plane.plane.b) + float zc = FIXED2FLOAT(plane.plane.Zat0()) + dz; + for (unsigned int k = 0; k < sub->numlines; k++) { - for (unsigned int k = 0; k < sub->numlines; k++) - { - vertex_t *vt = sub->firstline[k].v1; - ptr->x = vt->fx; - ptr->y = vt->fy; - ptr->z = plane.plane.ZatPoint(vt->fx, vt->fy) + dz; - ptr->u = vt->fx / 64.f; - ptr->v = -vt->fy / 64.f; - ptr++; - } + vertex_t *vt = sub->firstline[k].v1; + ptr->x = vt->fx; + ptr->y = vt->fy; + ptr->z = zc; + ptr->u = vt->fx / 64.f; + ptr->v = -vt->fy / 64.f; + ptr++; } - else - { - float zc = FIXED2FLOAT(plane.plane.Zat0()) + dz; - for (unsigned int k = 0; k < sub->numlines; k++) - { - vertex_t *vt = sub->firstline[k].v1; - ptr->x = vt->fx; - ptr->y = vt->fy; - ptr->z = zc; - ptr->u = vt->fx / 64.f; - ptr->v = -vt->fy / 64.f; - ptr++; - } - } - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); } + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); flatvertices += sub->numlines; flatprimitives++; @@ -332,9 +303,9 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) { if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub); - drawcalls.Clock(); + //drawcalls.Clock(); glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines); - drawcalls.Unclock(); + //drawcalls.Unclock(); flatvertices += sub->numlines; flatprimitives++; } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index a05aadde4..8f8d50532 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -617,28 +617,16 @@ static void FillScreen() gl_RenderState.EnableAlphaTest(false); gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); - if (!gl_usevbo) - { - glBegin(GL_TRIANGLE_STRIP); - glVertex2f(0.0f, 0.0f); - glVertex2f(0.0f, (float)SCREENHEIGHT); - glVertex2f((float)SCREENWIDTH, 0.0f); - glVertex2f((float)SCREENWIDTH, (float)SCREENHEIGHT); - glEnd(); - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(0, 0, 0, 0, 0); - ptr++; - ptr->Set(0, (float)SCREENHEIGHT, 0, 0, 0); - ptr++; - ptr->Set((float)SCREENWIDTH, 0, 0, 0, 0); - ptr++; - ptr->Set((float)SCREENWIDTH, (float)SCREENHEIGHT, 0, 0, 0); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(0, 0, 0, 0, 0); + ptr++; + ptr->Set(0, (float)SCREENHEIGHT, 0, 0, 0); + ptr++; + ptr->Set((float)SCREENWIDTH, 0, 0, 0, 0); + ptr++; + ptr->Set((float)SCREENWIDTH, (float)SCREENHEIGHT, 0, 0, 0); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } //========================================================================== diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index e36dd4b0e..00f2ccada 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -269,39 +269,16 @@ void GLSprite::Draw(int pass) FFlatVertex *ptr; unsigned int offset, count; - if (!gl_usevbo) - { - glBegin(GL_TRIANGLE_STRIP); - if (gltexture) - { - glTexCoord2f(ul, vt); glVertex3fv(&v1[0]); - glTexCoord2f(ur, vt); glVertex3fv(&v2[0]); - glTexCoord2f(ul, vb); glVertex3fv(&v3[0]); - glTexCoord2f(ur, vb); glVertex3fv(&v4[0]); - } - else // Particle - { - glVertex3fv(&v1[0]); - glVertex3fv(&v2[0]); - glVertex3fv(&v3[0]); - glVertex3fv(&v4[0]); - } - - glEnd(); - } - else - { - ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(v1[0], v1[1], v1[2], ul, vt); - ptr++; - ptr->Set(v2[0], v2[1], v2[2], ur, vt); - ptr++; - ptr->Set(v3[0], v3[1], v3[2], ul, vb); - ptr++; - ptr->Set(v4[0], v4[1], v4[2], ur, vb); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); - } + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(v1[0], v1[1], v1[2], ul, vt); + ptr++; + ptr->Set(v2[0], v2[1], v2[2], ur, vt); + ptr++; + ptr->Set(v3[0], v3[1], v3[2], ul, vb); + ptr++; + ptr->Set(v4[0], v4[1], v4[2], ur, vb); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); if (foglayer) { @@ -311,30 +288,7 @@ void GLSprite::Draw(int pass) gl_RenderState.BlendEquation(GL_FUNC_ADD); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.Apply(); - - if (!gl_usevbo) - { - glBegin(GL_TRIANGLE_STRIP); - if (gltexture) - { - glTexCoord2f(ul, vt); glVertex3fv(&v1[0]); - glTexCoord2f(ur, vt); glVertex3fv(&v2[0]); - glTexCoord2f(ul, vb); glVertex3fv(&v3[0]); - glTexCoord2f(ur, vb); glVertex3fv(&v4[0]); - } - else // Particle - { - glVertex3fv(&v1[0]); - glVertex3fv(&v2[0]); - glVertex3fv(&v3[0]); - glVertex3fv(&v4[0]); - } - glEnd(); - } - else - { - glDrawArrays(GL_TRIANGLE_STRIP, offset, count); - } + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); gl_RenderState.SetFixedColormap(CM_DEFAULT); } } diff --git a/src/gl/scene/gl_vertex.cpp b/src/gl/scene/gl_vertex.cpp index b3ee9c8b5..c0f21adce 100644 --- a/src/gl/scene/gl_vertex.cpp +++ b/src/gl/scene/gl_vertex.cpp @@ -54,144 +54,6 @@ #include "gl/utility/gl_templates.h" EXTERN_CVAR(Bool, gl_seamless) -extern int vertexcount; - -//========================================================================== -// -// Split upper edge of wall -// -//========================================================================== - -void GLWall::SplitUpperEdge(texcoord * tcs) -{ - if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; - - side_t *sidedef = seg->sidedef; - float polyw = glseg.fracright - glseg.fracleft; - float facu = (tcs[2].u - tcs[1].u) / polyw; - float facv = (tcs[2].v - tcs[1].v) / polyw; - float fact = (ztop[1] - ztop[0]) / polyw; - float facc = (zceil[1] - zceil[0]) / polyw; - float facf = (zfloor[1] - zfloor[0]) / polyw; - - for (int i=0; i < sidedef->numsegs - 1; i++) - { - seg_t *cseg = sidedef->segs[i]; - float sidefrac = cseg->sidefrac; - if (sidefrac <= glseg.fracleft) continue; - if (sidefrac >= glseg.fracright) return; - - float fracfac = sidefrac - glseg.fracleft; - - glTexCoord2f(tcs[1].u + facu * fracfac, tcs[1].v + facv * fracfac); - glVertex3f(cseg->v2->fx, ztop[0] + fact * fracfac, cseg->v2->fy); - } - vertexcount += sidedef->numsegs-1; -} - -//========================================================================== -// -// Split upper edge of wall -// -//========================================================================== - -void GLWall::SplitLowerEdge(texcoord * tcs) -{ - if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; - - side_t *sidedef = seg->sidedef; - float polyw = glseg.fracright - glseg.fracleft; - float facu = (tcs[3].u - tcs[0].u) / polyw; - float facv = (tcs[3].v - tcs[0].v) / polyw; - float facb = (zbottom[1] - zbottom[0]) / polyw; - float facc = (zceil[1] - zceil[0]) / polyw; - float facf = (zfloor[1] - zfloor[0]) / polyw; - - for (int i = sidedef->numsegs-2; i >= 0; i--) - { - seg_t *cseg = sidedef->segs[i]; - float sidefrac = cseg->sidefrac; - if (sidefrac >= glseg.fracright) continue; - if (sidefrac <= glseg.fracleft) return; - - float fracfac = sidefrac - glseg.fracleft; - - glTexCoord2f(tcs[0].u + facu * fracfac, tcs[0].v + facv * fracfac); - glVertex3f(cseg->v2->fx, zbottom[0] + facb * fracfac, cseg->v2->fy); - } - vertexcount += sidedef->numsegs-1; -} - -//========================================================================== -// -// Split left edge of wall -// -//========================================================================== - -void GLWall::SplitLeftEdge(texcoord * tcs) -{ - if (vertexes[0]==NULL) return; - - vertex_t * vi=vertexes[0]; - - if (vi->numheights) - { - int i=0; - - float polyh1=ztop[0] - zbottom[0]; - float factv1=polyh1? (tcs[1].v - tcs[0].v) / polyh1:0; - float factu1=polyh1? (tcs[1].u - tcs[0].u) / polyh1:0; - - while (inumheights && vi->heightlist[i] <= zbottom[0] ) i++; - while (inumheights && vi->heightlist[i] < ztop[0]) - { - glTexCoord2f(factu1*(vi->heightlist[i] - ztop[0]) + tcs[1].u, - factv1*(vi->heightlist[i] - ztop[0]) + tcs[1].v); - glVertex3f(glseg.x1, vi->heightlist[i], glseg.y1); - i++; - } - vertexcount+=i; - } -} - -//========================================================================== -// -// Split right edge of wall -// -//========================================================================== - -void GLWall::SplitRightEdge(texcoord * tcs) -{ - if (vertexes[1]==NULL) return; - - vertex_t * vi=vertexes[1]; - - if (vi->numheights) - { - int i=vi->numheights-1; - - float polyh2 = ztop[1] - zbottom[1]; - float factv2 = polyh2? (tcs[2].v - tcs[3].v) / polyh2:0; - float factu2 = polyh2? (tcs[2].u - tcs[3].u) / polyh2:0; - - while (i>0 && vi->heightlist[i] >= ztop[1]) i--; - while (i>0 && vi->heightlist[i] > zbottom[1]) - { - glTexCoord2f(factu2 * (vi->heightlist[i] - ztop[1]) + tcs[2].u, - factv2 * (vi->heightlist[i] - ztop[1]) + tcs[2].v); - glVertex3f(glseg.x2, vi->heightlist[i], glseg.y2); - i--; - } - vertexcount+=i; - } -} - - -//========================================================================== -// -// same for vertex buffer mode -// -//========================================================================== //========================================================================== // @@ -227,7 +89,6 @@ void GLWall::SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr) ptr->v = tcs[1].v + facv * fracfac; ptr++; } - vertexcount += sidedef->numsegs - 1; } //========================================================================== @@ -264,7 +125,6 @@ void GLWall::SplitLowerEdge(texcoord * tcs, FFlatVertex *&ptr) ptr->v = tcs[0].v + facv * fracfac; ptr++; } - vertexcount += sidedef->numsegs - 1; } //========================================================================== @@ -298,7 +158,6 @@ void GLWall::SplitLeftEdge(texcoord * tcs, FFlatVertex *&ptr) ptr++; i++; } - vertexcount += i; } } @@ -333,7 +192,6 @@ void GLWall::SplitRightEdge(texcoord * tcs, FFlatVertex *&ptr) ptr++; i--; } - vertexcount += i; } } diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index dd1365193..25815ab76 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -159,7 +159,7 @@ private: void SetupLights(); bool PrepareLight(texcoord * tcs, ADynamicLight * light); - void RenderWall(int textured, float * color2, ADynamicLight * light=NULL); + void RenderWall(int textured, ADynamicLight * light=NULL); void GetPrimitive(unsigned int *store); void FloodPlane(int pass); @@ -212,11 +212,6 @@ private: void RenderMirrorSurface(); void RenderTranslucentWall(); - void SplitLeftEdge(texcoord * tcs); - void SplitRightEdge(texcoord * tcs); - void SplitUpperEdge(texcoord * tcs); - void SplitLowerEdge(texcoord * tcs); - void SplitLeftEdge(texcoord * tcs, FFlatVertex *&ptr); void SplitRightEdge(texcoord * tcs, FFlatVertex *&ptr); void SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 9c5baae6a..1388eb782 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -215,6 +215,7 @@ void GLWall::SetupLights() } } + //========================================================================== // // General purpose wall rendering function @@ -222,7 +223,7 @@ void GLWall::SetupLights() // //========================================================================== -void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) +void GLWall::RenderWall(int textured, ADynamicLight * light) { texcoord tcs[4]; bool split = (gl_seamless && !(textured&4) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ)); @@ -249,64 +250,22 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) gl_RenderState.Apply(); // the rest of the code is identical for textured rendering and lights + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - - if (!gl_usevbo) - { - glBegin(GL_TRIANGLE_FAN); - - // lower left corner - if (textured & 1) glTexCoord2f(tcs[0].u, tcs[0].v); - glVertex3f(glseg.x1, zbottom[0], glseg.y1); - - if (split && glseg.fracleft == 0) SplitLeftEdge(tcs); - - // upper left corner - if (textured & 1) glTexCoord2f(tcs[1].u, tcs[1].v); - glVertex3f(glseg.x1, ztop[0], glseg.y1); - - if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs); - - // color for right side (do not set in render state!) - if (color2) glColor4fv(color2); - - // upper right corner - if (textured & 1) glTexCoord2f(tcs[2].u, tcs[2].v); - glVertex3f(glseg.x2, ztop[1], glseg.y2); - - if (split && glseg.fracright == 1) SplitRightEdge(tcs); - - // lower right corner - if (textured & 1) glTexCoord2f(tcs[3].u, tcs[3].v); - glVertex3f(glseg.x2, zbottom[1], glseg.y2); - - if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs); - - glEnd(); - - vertexcount += 4; - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - - ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[0].u, tcs[0].v); - ptr++; - if (split && glseg.fracleft == 0) SplitLeftEdge(tcs, ptr); - ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[1].u, tcs[1].v); - ptr++; - if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs, ptr); - ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[2].u, tcs[2].v); - ptr++; - if (split && glseg.fracright == 1) SplitRightEdge(tcs, ptr); - ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[3].u, tcs[3].v); - ptr++; - if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, ptr); - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); - vertexcount += 4; - } - - + ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[0].u, tcs[0].v); + ptr++; + if (split && glseg.fracleft == 0) SplitLeftEdge(tcs, ptr); + ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[1].u, tcs[1].v); + ptr++; + if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs, ptr); + ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[2].u, tcs[2].v); + ptr++; + if (split && glseg.fracright == 1) SplitRightEdge(tcs, ptr); + ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[3].u, tcs[3].v); + ptr++; + if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, ptr); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + vertexcount += 4; } //========================================================================== @@ -356,7 +315,7 @@ void GLWall::RenderFogBoundary() gl_SetFog(lightlevel, rel, &Colormap, false); gl_RenderState.SetEffect(EFF_FOGBOUNDARY); gl_RenderState.EnableAlphaTest(false); - RenderWall(0, NULL); + RenderWall(0); gl_RenderState.EnableAlphaTest(true); gl_RenderState.SetEffect(EFF_NONE); } @@ -385,8 +344,17 @@ void GLWall::RenderFogBoundary() glDepthFunc(GL_LEQUAL); gl_RenderState.SetColor(fc[0], fc[1], fc[2], fogd1); - flags &= ~GLWF_GLOW; - RenderWall(4,fc); + // this case is special because it needs to change the color in the middle of the polygon so it cannot use the standard function + // This also needs no splits so it's relatively simple. + gl_RenderState.Apply(); + glBegin(GL_TRIANGLE_FAN); + glVertex3f(glseg.x1, zbottom[0], glseg.y1); + glVertex3f(glseg.x1, ztop[0], glseg.y1); + glColor4fv(fc); + glVertex3f(glseg.x2, ztop[1], glseg.y2); + glVertex3f(glseg.x2, zbottom[1], glseg.y2); + glEnd(); + vertexcount += 4; glDepthFunc(GL_LESS); gl_RenderState.EnableFog(true); @@ -424,8 +392,7 @@ void GLWall::RenderMirrorSurface() pat->BindPatch(0); flags &= ~GLWF_GLOW; - //flags |= GLWF_NOSHADER; - RenderWall(0,NULL); + RenderWall(0); gl_RenderState.SetEffect(EFF_NONE); @@ -486,7 +453,7 @@ void GLWall::RenderTranslucentWall() if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, extra, &Colormap, isadditive); else gl_SetFog(255, 0, NULL, false); - RenderWall(5,NULL); + RenderWall(5); // restore default settings if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -540,7 +507,7 @@ void GLWall::Draw(int pass) gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); gltexture->Bind(flags, 0); - RenderWall(3, NULL); + RenderWall(3); gl_RenderState.EnableGlow(false); gl_RenderState.EnableLight(false); break; @@ -561,14 +528,14 @@ void GLWall::Draw(int pass) { gltexture->Bind(flags, 0); } - RenderWall(pass == GLPASS_BASE? 2:3, NULL); + RenderWall(pass == GLPASS_BASE? 2:3); gl_RenderState.EnableGlow(false); gl_RenderState.EnableLight(false); break; case GLPASS_TEXTURE: // modulated texture gltexture->Bind(flags, 0); - RenderWall(1, NULL); + RenderWall(1); break; case GLPASS_LIGHT: @@ -597,7 +564,7 @@ void GLWall::Draw(int pass) if (!(node->lightsource->flags2&MF2_DORMANT)) { iter_dlight++; - RenderWall(1, NULL, node->lightsource); + RenderWall(1, node->lightsource); } node = node->nextLight; } diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index a91fa252f..8f76b0571 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -154,28 +154,16 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed gl_RenderState.EnableAlphaTest(false); } gl_RenderState.Apply(); - if (!gl_usevbo) - { - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(fU1, fV1); glVertex2f(x1, y1); - glTexCoord2f(fU1, fV2); glVertex2f(x1, y2); - glTexCoord2f(fU2, fV1); glVertex2f(x2, y1); - glTexCoord2f(fU2, fV2); glVertex2f(x2, y2); - glEnd(); - } - else - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(x1, y1, 0, fU1, fV1); - ptr++; - ptr->Set(x1, y2, 0, fU1, fV2); - ptr++; - ptr->Set(x2, y1, 0, fU2, fV1); - ptr++; - ptr->Set(x2, y2, 0, fU2, fV2); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x1, y1, 0, fU1, fV1); + ptr++; + ptr->Set(x1, y2, 0, fU1, fV2); + ptr++; + ptr->Set(x2, y1, 0, fU2, fV1); + ptr++; + ptr->Set(x2, y2, 0, fU2, fV2); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); if (tex->GetTransparent() || OverrideShader != 0) { gl_RenderState.EnableAlphaTest(true); From 1b91a8f88cf7cf2fc5dc802f6d11d28918c2b600 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Jun 2014 10:15:44 +0200 Subject: [PATCH 0113/1509] - removed old immediate mode path for generating stencils. --- src/gl/scene/gl_portal.cpp | 78 +++++++++++----------------------- src/gl/scene/gl_wall.h | 13 +++++- src/gl/scene/gl_walls_draw.cpp | 72 ++++++++++++------------------- 3 files changed, 63 insertions(+), 100 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 18c6dcff5..2d5fcd3a3 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -139,66 +139,36 @@ void GLPortal::ClearScreen() //----------------------------------------------------------------------------- void GLPortal::DrawPortalStencil() { - if (!gl_usevbo) + if (mPrimIndices.Size() == 0) { + bool cap = NeedCap() && lines.Size() > 1; + mPrimIndices.Resize(2 * lines.Size() + 4 * cap); + for (unsigned int i = 0; i 1) + if (cap) { - // Cap the stencil at the top and bottom - // (cheap ass version) - glBegin(GL_TRIANGLE_FAN); - glVertex3f(-32767.0f, 32767.0f, -32767.0f); - glVertex3f(-32767.0f, 32767.0f, 32767.0f); - glVertex3f(32767.0f, 32767.0f, 32767.0f); - glVertex3f(32767.0f, 32767.0f, -32767.0f); - glEnd(); - glBegin(GL_TRIANGLE_FAN); - glVertex3f(-32767.0f, -32767.0f, -32767.0f); - glVertex3f(-32767.0f, -32767.0f, 32767.0f); - glVertex3f(32767.0f, -32767.0f, 32767.0f); - glVertex3f(32767.0f, -32767.0f, -32767.0f); - glEnd(); + // Cap the stencil at the top and bottom + int n = lines.Size() * 2; + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(-32767.0f, 32767.0f, -32767.0f, 0, 0); + ptr->Set(-32767.0f, 32767.0f, 32767.0f, 0, 0); + ptr->Set(32767.0f, 32767.0f, 32767.0f, 0, 0); + ptr->Set(32767.0f, 32767.0f, -32767.0f, 0, 0); + mPrimIndices[n + 1] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n]); + ptr->Set(-32767.0f, -32767.0f, -32767.0f, 0, 0); + ptr->Set(-32767.0f, -32767.0f, 32767.0f, 0, 0); + ptr->Set(32767.0f, -32767.0f, 32767.0f, 0, 0); + ptr->Set(32767.0f, -32767.0f, -32767.0f, 0, 0); + mPrimIndices[n + 3] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n + 2]); } } - else + for (unsigned int i = 0; i < mPrimIndices.Size(); i += 2) { - if (mPrimIndices.Size() == 0) - { - bool cap = NeedCap() && lines.Size() > 1; - mPrimIndices.Resize(2 * lines.Size() + 4 * cap); - - for (unsigned int i = 0; imVBO->GetBuffer(); - ptr->Set(-32767.0f, 32767.0f, -32767.0f, 0, 0); - ptr->Set(-32767.0f, 32767.0f, 32767.0f, 0, 0); - ptr->Set(32767.0f, 32767.0f, 32767.0f, 0, 0); - ptr->Set(32767.0f, 32767.0f, -32767.0f, 0, 0); - mPrimIndices[n + 1] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n]); - ptr->Set(-32767.0f, -32767.0f, -32767.0f, 0, 0); - ptr->Set(-32767.0f, -32767.0f, 32767.0f, 0, 0); - ptr->Set(32767.0f, -32767.0f, 32767.0f, 0, 0); - ptr->Set(32767.0f, -32767.0f, -32767.0f, 0, 0); - mPrimIndices[n + 3] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n + 2]); - } - } - for (unsigned int i = 0; i < mPrimIndices.Size(); i += 2) - { - glDrawArrays(GL_TRIANGLE_FAN, mPrimIndices[i], mPrimIndices[i + 1]); - } + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, mPrimIndices[i], mPrimIndices[i + 1]); } } @@ -244,13 +214,13 @@ bool GLPortal::Start(bool usestencil, bool doquery) if (!QueryObject) glGenQueries(1, &QueryObject); if (QueryObject) { - glBeginQuery(GL_SAMPLES_PASSED_ARB, QueryObject); + glBeginQuery(GL_SAMPLES_PASSED, QueryObject); } else doquery = false; // some kind of error happened DrawPortalStencil(); - glEndQuery(GL_SAMPLES_PASSED_ARB); + glEndQuery(GL_SAMPLES_PASSED); // Clear Z-buffer glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil @@ -268,7 +238,7 @@ bool GLPortal::Start(bool usestencil, bool doquery) GLuint sampleCount; - glGetQueryObjectuiv(QueryObject, GL_QUERY_RESULT_ARB, &sampleCount); + glGetQueryObjectuiv(QueryObject, GL_QUERY_RESULT, &sampleCount); if (sampleCount==0) // not visible { diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 25815ab76..28fa51868 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -104,6 +104,16 @@ public: GLWF_NOSPLITLOWER=128, }; + enum + { + RWF_BLANK = 0, + RWF_TEXTURED = 1, // actually not being used anymore because with buffers it's even less efficient not writing the texture coordinates - but leave it here + RWF_GLOW = 2, + RWF_NOSPLIT = 4, + RWF_NORENDER = 8, + }; + + friend struct GLDrawList; friend class GLPortal; @@ -159,8 +169,7 @@ private: void SetupLights(); bool PrepareLight(texcoord * tcs, ADynamicLight * light); - void RenderWall(int textured, ADynamicLight * light=NULL); - void GetPrimitive(unsigned int *store); + void RenderWall(int textured, ADynamicLight * light=NULL, unsigned int *store = NULL); void FloodPlane(int pass); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 1388eb782..7648625d3 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -223,10 +223,10 @@ void GLWall::SetupLights() // //========================================================================== -void GLWall::RenderWall(int textured, ADynamicLight * light) +void GLWall::RenderWall(int textured, ADynamicLight * light, unsigned int *store) { texcoord tcs[4]; - bool split = (gl_seamless && !(textured&4) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ)); + bool split = (gl_seamless && !(textured&RWF_NOSPLIT) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ)); if (!light) { @@ -234,7 +234,7 @@ void GLWall::RenderWall(int textured, ADynamicLight * light) tcs[1]=uplft; tcs[2]=uprgt; tcs[3]=lorgt; - if (!!(flags&GLWF_GLOW) && (textured & 2)) + if ((flags&GLWF_GLOW) && (textured & RWF_GLOW)) { gl_RenderState.SetGlowPlanes(topplane, bottomplane); gl_RenderState.SetGlowParams(topglowcolor, bottomglowcolor); @@ -247,10 +247,14 @@ void GLWall::RenderWall(int textured, ADynamicLight * light) } - gl_RenderState.Apply(); + if (!(textured & RWF_NORENDER)) + { + gl_RenderState.Apply(); + } // the rest of the code is identical for textured rendering and lights FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + unsigned int count, offset; ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[0].u, tcs[0].v); ptr++; @@ -264,40 +268,19 @@ void GLWall::RenderWall(int textured, ADynamicLight * light) ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[3].u, tcs[3].v); ptr++; if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, ptr); - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); - vertexcount += 4; + count = GLRenderer->mVBO->GetCount(ptr, &offset); + if (!(textured & RWF_NORENDER)) + { + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, offset, count); + vertexcount += count; + } + if (store != NULL) + { + store[0] = offset; + store[1] = count; + } } -//========================================================================== -// -// Gets the vertex data for rendering a stencil which needs to be -// repeated several times -// -//========================================================================== - -void GLWall::GetPrimitive(unsigned int *store) -{ - static texcoord tcs[4] = { 0, 0, 0, 0 }; - bool split = (gl_seamless && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ)); - - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - - ptr->Set(glseg.x1, zbottom[0], glseg.y1, 0, 0); - ptr++; - if (split && glseg.fracleft == 0) SplitLeftEdge(tcs, ptr); - ptr->Set(glseg.x1, ztop[0], glseg.y1, 0, 0); - ptr++; - if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs, ptr); - ptr->Set(glseg.x2, ztop[1], glseg.y2, 0, 0); - ptr++; - if (split && glseg.fracright == 1) SplitRightEdge(tcs, ptr); - ptr->Set(glseg.x2, zbottom[1], glseg.y2, 0, 0); - ptr++; - if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, ptr); - store[1] = GLRenderer->mVBO->GetCount(ptr, &store[0]); - vertexcount += 4; - } - //========================================================================== // // @@ -315,13 +298,14 @@ void GLWall::RenderFogBoundary() gl_SetFog(lightlevel, rel, &Colormap, false); gl_RenderState.SetEffect(EFF_FOGBOUNDARY); gl_RenderState.EnableAlphaTest(false); - RenderWall(0); + RenderWall(RWF_BLANK); gl_RenderState.EnableAlphaTest(true); gl_RenderState.SetEffect(EFF_NONE); } else { - // otherwise some approximation is needed. This won't look as good + // If we use the fixed function pipeline (GL 2.x) + // some approximation is needed. This won't look as good // as the shader version but it's an acceptable compromise. float fogdensity=gl_GetFogDensity(lightlevel, Colormap.FadeColor); @@ -392,7 +376,7 @@ void GLWall::RenderMirrorSurface() pat->BindPatch(0); flags &= ~GLWF_GLOW; - RenderWall(0); + RenderWall(RWF_BLANK); gl_RenderState.SetEffect(EFF_NONE); @@ -453,7 +437,7 @@ void GLWall::RenderTranslucentWall() if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, extra, &Colormap, isadditive); else gl_SetFog(255, 0, NULL, false); - RenderWall(5); + RenderWall(RWF_TEXTURED|RWF_NOSPLIT); // restore default settings if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -507,7 +491,7 @@ void GLWall::Draw(int pass) gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); gltexture->Bind(flags, 0); - RenderWall(3); + RenderWall(RWF_TEXTURED|RWF_GLOW); gl_RenderState.EnableGlow(false); gl_RenderState.EnableLight(false); break; @@ -528,14 +512,14 @@ void GLWall::Draw(int pass) { gltexture->Bind(flags, 0); } - RenderWall(pass == GLPASS_BASE? 2:3); + RenderWall(RWF_TEXTURED|RWF_GLOW); gl_RenderState.EnableGlow(false); gl_RenderState.EnableLight(false); break; case GLPASS_TEXTURE: // modulated texture gltexture->Bind(flags, 0); - RenderWall(1); + RenderWall(RWF_TEXTURED); break; case GLPASS_LIGHT: @@ -564,7 +548,7 @@ void GLWall::Draw(int pass) if (!(node->lightsource->flags2&MF2_DORMANT)) { iter_dlight++; - RenderWall(1, node->lightsource); + RenderWall(RWF_TEXTURED, node->lightsource); } node = node->nextLight; } From 2abf1644a443e72bff06ee5afb68527a2850ff57 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Jun 2014 10:18:46 +0200 Subject: [PATCH 0114/1509] - fixed: Plane height changes only updated the first buffered vertex for the respective plane. --- src/gl/data/gl_vertexbuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 8093a57a0..559131d36 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -294,7 +294,7 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) secplane_t &splane = sec->GetSecPlane(plane); FFlatVertex *vt = &vbo_shadowdata[startvt]; FFlatVertex *mapvt = &map[startvt]; - for(int i=0; iz = splane.ZatPoint(vt->x, vt->y); if (plane == sector_t::floor && sec->transdoor) vt->z -= 1; From 6b038a5daed5a4db7e4452d835957b827f53158e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Jun 2014 10:30:03 +0200 Subject: [PATCH 0115/1509] - fixed: GLPortal::DrawPortalStencil must apply the render state before drawing anything. --- src/gl/scene/gl_portal.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 2d5fcd3a3..4e07fc1a8 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -166,6 +166,7 @@ void GLPortal::DrawPortalStencil() mPrimIndices[n + 3] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n + 2]); } } + gl_RenderState.Apply(); for (unsigned int i = 0; i < mPrimIndices.Size(); i += 2) { GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, mPrimIndices[i], mPrimIndices[i + 1]); From ea332383a8de95e3d379ae171a6983f023ae8747 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Jun 2014 11:50:54 +0200 Subject: [PATCH 0116/1509] - convert skybox rendering to use the buffer interface. --- src/gl/scene/gl_skydome.cpp | 216 +++++++++++++++--------------------- 1 file changed, 89 insertions(+), 127 deletions(-) diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 1a8794c58..d36e5fdba 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -336,6 +336,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool else glRotatef(-180.0f+x_offset, glset.skyrotatevector2.X, glset.skyrotatevector2.Z, glset.skyrotatevector2.Y); + FFlatVertex *ptr; if (sb->faces[5]) { faces=4; @@ -344,164 +345,125 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool tex = FMaterial::ValidateTexture(sb->faces[0]); tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); - glTexCoord2f(0, 0); - glVertex3f(128.f, 128.f, -128.f); - glTexCoord2f(1, 0); - glVertex3f(-128.f, 128.f, -128.f); - glTexCoord2f(1, 1); - glVertex3f(-128.f, -128.f, -128.f); - glTexCoord2f(0, 1); - glVertex3f(128.f, -128.f, -128.f); - glEnd(); + + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(128.f, 128.f, -128.f, 0, 0); + ptr++; + ptr->Set(-128.f, 128.f, -128.f, 1, 0); + ptr++; + ptr->Set(128.f, -128.f, -128.f, 0, 1); + ptr++; + ptr->Set(-128.f, -128.f, -128.f, 1, 1); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); // east tex = FMaterial::ValidateTexture(sb->faces[1]); - tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); + tex->Bind(GLT_CLAMPX | GLT_CLAMPY, 0); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); - glTexCoord2f(0, 0); - glVertex3f(-128.f, 128.f, -128.f); - glTexCoord2f(1, 0); - glVertex3f(-128.f, 128.f, 128.f); - glTexCoord2f(1, 1); - glVertex3f(-128.f, -128.f, 128.f); - glTexCoord2f(0, 1); - glVertex3f(-128.f, -128.f, -128.f); - glEnd(); + + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(-128.f, 128.f, -128.f, 0, 0); + ptr++; + ptr->Set(-128.f, 128.f, 128.f, 1, 0); + ptr++; + ptr->Set(-128.f, -128.f, -128.f, 0, 1); + ptr++; + ptr->Set(-128.f, -128.f, 128.f, 1, 1); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); // south tex = FMaterial::ValidateTexture(sb->faces[2]); - tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); + tex->Bind(GLT_CLAMPX | GLT_CLAMPY, 0); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); - glTexCoord2f(0, 0); - glVertex3f(-128.f, 128.f, 128.f); - glTexCoord2f(1, 0); - glVertex3f(128.f, 128.f, 128.f); - glTexCoord2f(1, 1); - glVertex3f(128.f, -128.f, 128.f); - glTexCoord2f(0, 1); - glVertex3f(-128.f, -128.f, 128.f); - glEnd(); + + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(-128.f, 128.f, 128.f, 0, 0); + ptr++; + ptr->Set(128.f, 128.f, 128.f, 1, 0); + ptr++; + ptr->Set(-128.f, -128.f, 128.f, 0, 1); + ptr++; + ptr->Set(128.f, -128.f, 128.f, 1, 1); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); // west tex = FMaterial::ValidateTexture(sb->faces[3]); tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); - glTexCoord2f(0, 0); - glVertex3f(128.f, 128.f, 128.f); - glTexCoord2f(1, 0); - glVertex3f(128.f, 128.f, -128.f); - glTexCoord2f(1, 1); - glVertex3f(128.f, -128.f, -128.f); - glTexCoord2f(0, 1); - glVertex3f(128.f, -128.f, 128.f); - glEnd(); + + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(128.f, 128.f, 128.f, 0, 0); + ptr++; + ptr->Set(128.f, 128.f, -128.f, 1, 0); + ptr++; + ptr->Set(128.f, -128.f, 128.f, 0, 1); + ptr++; + ptr->Set(128.f, -128.f, -128.f, 1, 1); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } else { faces=1; - // all 4 sides - tex = FMaterial::ValidateTexture(sb->faces[0]); - tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); - gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); - glTexCoord2f(0, 0); - glVertex3f(128.f, 128.f, -128.f); - glTexCoord2f(.25f, 0); - glVertex3f(-128.f, 128.f, -128.f); - glTexCoord2f(.25f, 1); - glVertex3f(-128.f, -128.f, -128.f); - glTexCoord2f(0, 1); - glVertex3f(128.f, -128.f, -128.f); - glEnd(); - - // east - glBegin(GL_TRIANGLE_FAN); - glTexCoord2f(.25f, 0); - glVertex3f(-128.f, 128.f, -128.f); - glTexCoord2f(.5f, 0); - glVertex3f(-128.f, 128.f, 128.f); - glTexCoord2f(.5f, 1); - glVertex3f(-128.f, -128.f, 128.f); - glTexCoord2f(.25f, 1); - glVertex3f(-128.f, -128.f, -128.f); - glEnd(); - - // south - glBegin(GL_TRIANGLE_FAN); - glTexCoord2f(.5f, 0); - glVertex3f(-128.f, 128.f, 128.f); - glTexCoord2f(.75f, 0); - glVertex3f(128.f, 128.f, 128.f); - glTexCoord2f(.75f, 1); - glVertex3f(128.f, -128.f, 128.f); - glTexCoord2f(.5f, 1); - glVertex3f(-128.f, -128.f, 128.f); - glEnd(); - - // west - glBegin(GL_TRIANGLE_FAN); - glTexCoord2f(.75f, 0); - glVertex3f(128.f, 128.f, 128.f); - glTexCoord2f(1, 0); - glVertex3f(128.f, 128.f, -128.f); - glTexCoord2f(1, 1); - glVertex3f(128.f, -128.f, -128.f); - glTexCoord2f(.75f, 1); - glVertex3f(128.f, -128.f, 128.f); - glEnd(); + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(128.f, 128.f, -128.f, 0, 0); + ptr++; + ptr->Set(128.f, -128.f, -128.f, 0, 1); + ptr++; + ptr->Set(-128.f, 128.f, -128.f, 0.25f, 0); + ptr++; + ptr->Set(-128.f, -128.f, -128.f, 0.25f, 1); + ptr++; + ptr->Set(-128.f, 128.f, 128.f, 0.5f, 0); + ptr++; + ptr->Set(-128.f, -128.f, 128.f, 0.5f, 1); + ptr++; + ptr->Set(128.f, 128.f, 128.f, 0.75f, 0); + ptr++; + ptr->Set(128.f, -128.f, 128.f, 0.75f, 1); + ptr++; + ptr->Set(128.f, 128.f, -128.f, 1, 0); + ptr++; + ptr->Set(128.f, -128.f, -128.f, 1, 1); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } // top tex = FMaterial::ValidateTexture(sb->faces[faces]); tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); - if (!sb->fliptop) - { - glTexCoord2f(0, 0); - glVertex3f(128.f, 128.f, -128.f); - glTexCoord2f(1, 0); - glVertex3f(-128.f, 128.f, -128.f); - glTexCoord2f(1, 1); - glVertex3f(-128.f, 128.f, 128.f); - glTexCoord2f(0, 1); - glVertex3f(128.f, 128.f, 128.f); - } - else - { - glTexCoord2f(0, 0); - glVertex3f(128.f, 128.f, 128.f); - glTexCoord2f(1, 0); - glVertex3f(-128.f, 128.f, 128.f); - glTexCoord2f(1, 1); - glVertex3f(-128.f, 128.f, -128.f); - glTexCoord2f(0, 1); - glVertex3f(128.f, 128.f, -128.f); - } - glEnd(); + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(128.f, 128.f, -128.f, 0, sb->fliptop); + ptr++; + ptr->Set(-128.f, 128.f, -128.f, 1, sb->fliptop); + ptr++; + ptr->Set(128.f, 128.f, 128.f, 0, !sb->fliptop); + ptr++; + ptr->Set(-128.f, 128.f, 128.f, 1, !sb->fliptop); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); // bottom tex = FMaterial::ValidateTexture(sb->faces[faces+1]); tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); - glTexCoord2f(0, 0); - glVertex3f(128.f, -128.f, -128.f); - glTexCoord2f(1, 0); - glVertex3f(-128.f, -128.f, -128.f); - glTexCoord2f(1, 1); - glVertex3f(-128.f, -128.f, 128.f); - glTexCoord2f(0, 1); - glVertex3f(128.f, -128.f, 128.f); - glEnd(); - + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(128.f, -128.f, -128.f, 0, 0); + ptr++; + ptr->Set(-128.f, -128.f, -128.f, 1, 0); + ptr++; + ptr->Set(128.f, -128.f, 128.f, 0, 1); + ptr++; + ptr->Set(-128.f, -128.f, 128.f, 1, 1); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } //----------------------------------------------------------------------------- From 1aaa1b7bad8a83ca7689d37b94c4c55e896d969d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Jun 2014 12:12:24 +0200 Subject: [PATCH 0117/1509] - removed gl_usevbo CVAR because with recent code changes it has become useless. If GL_ARB_buffer_storage is present, buffers will always be used. --- src/gl/data/gl_vertexbuffer.cpp | 14 -------------- src/gl/scene/gl_flats.cpp | 6 +++--- src/gl/shaders/gl_shader.cpp | 2 +- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 559131d36..6ba9f794e 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -49,19 +49,6 @@ #include "gl/data/gl_vertexbuffer.h" -CUSTOM_CVAR(Int, gl_usevbo, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ - if (self < -1 || self > 1 || !(gl.flags & RFL_BUFFER_STORAGE)) - { - if (self != 0) self = 0; - } - else if (self == -1) - { - if (!(gl.flags & RFL_BUFFER_STORAGE)) self = 0; - else self = 1; - } -} - //========================================================================== // // Create / destroy the VBO @@ -71,7 +58,6 @@ CUSTOM_CVAR(Int, gl_usevbo, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCA FVertexBuffer::FVertexBuffer() { vbo_id = 0; - if (gl_usevbo == -1) gl_usevbo.Callback(); glGenBuffers(1, &vbo_id); } diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 59d4192e7..6b34fb659 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -293,7 +293,7 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) } else { - if (gl_usevbo && vboindex >= 0) + if (vboindex >= 0) { int index = vboindex; for (int i=0; isubsectorcount; i++) @@ -303,9 +303,9 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) { if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub); - //drawcalls.Clock(); + drawcalls.Clock(); glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines); - //drawcalls.Unclock(); + drawcalls.Unclock(); flatvertices += sub->numlines; flatprimitives++; } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 0b55fbd35..b90974222 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -385,8 +385,8 @@ void FShaderManager::CompileShaders() // If shader compilation failed we can still run the fixed function mode so do that instead of aborting. Printf("%s\n", err.GetMessage()); Printf(PRINT_HIGH, "Failed to compile shaders. Reverting to fixed function mode\n"); - gl_usevbo = false; gl.glslversion = 0.0; + gl.flags &= ~RFL_BUFFER_STORAGE; } } From e6f14b055a6b10aaea80a952d79b9ec2ee91a621 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Jun 2014 20:28:23 +0200 Subject: [PATCH 0118/1509] - use buffer based rendering for dynamic light pass and horizon portals. --- src/gl/scene/gl_flats.cpp | 10 ++--- src/gl/scene/gl_portal.cpp | 77 +++++++++++++++------------------- src/gl/scene/gl_walls_draw.cpp | 2 +- src/gl/system/gl_cvars.h | 4 -- 4 files changed, 38 insertions(+), 55 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 6b34fb659..56d2bd8d6 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -152,7 +152,7 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) gl_RenderState.Apply(); // Render the light - glBegin(GL_TRIANGLE_FAN); + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); for (k = 0, v = sub->firstline; k < sub->numlines; k++, v++) { vertex_t *vt = v->v1; @@ -160,12 +160,10 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) t1.Set(vt->fx, zc, vt->fy); Vector nearToVert = t1 - nearPt; - glTexCoord2f((nearToVert.Dot(right) * scale) + 0.5f, (nearToVert.Dot(up) * scale) + 0.5f); - - glVertex3f(vt->fx, zc, vt->fy); + ptr->Set(vt->fx, zc, vt->fy, (nearToVert.Dot(right) * scale) + 0.5f, (nearToVert.Dot(up) * scale) + 0.5f); + ptr++; } - - glEnd(); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); node = node->nextLight; } } diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 4e07fc1a8..a7400ec22 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -999,26 +999,21 @@ void GLHorizonPortal::DrawContents() float vy=FIXED2FLOAT(viewy); // Draw to some far away boundary + // This is not drawn as larher strips because it causes visual glitches. for(float x=-32768+vx; x<32768+vx; x+=4096) { for(float y=-32768+vy; y<32768+vy;y+=4096) { - glBegin(GL_TRIANGLE_FAN); - - glTexCoord2f(x/64, -y/64); - glVertex3f(x, z, y); - - glTexCoord2f(x/64 + 64, -y/64); - glVertex3f(x + 4096, z, y); - - glTexCoord2f(x/64 + 64, -y/64 - 64); - glVertex3f(x + 4096, z, y + 4096); - - glTexCoord2f(x/64, -y/64 - 64); - glVertex3f(x, z, y + 4096); - - glEnd(); - + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x, z, y, x / 64, -y / 64); + ptr++; + ptr->Set(x + 4096, z, y, x / 64 + 64, -y / 64); + ptr++; + ptr->Set(x, z, y + 4096, x / 64, -y / 64 - 64); + ptr++; + ptr->Set(x + 4096, z, y + 4096, x / 64 + 64, -y / 64 - 64); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } } @@ -1029,34 +1024,28 @@ void GLHorizonPortal::DrawContents() // Since I can't draw into infinity there can always be a // small gap - glBegin(GL_TRIANGLE_STRIP); - - glTexCoord2f(512.f, 0); - glVertex3f(-32768+vx, z, -32768+vy); - glTexCoord2f(512.f, tz); - glVertex3f(-32768+vx, vz, -32768+vy); - - glTexCoord2f(-512.f, 0); - glVertex3f(-32768+vx, z, 32768+vy); - glTexCoord2f(-512.f, tz); - glVertex3f(-32768+vx, vz, 32768+vy); - - glTexCoord2f(512.f, 0); - glVertex3f( 32768+vx, z, 32768+vy); - glTexCoord2f(512.f, tz); - glVertex3f( 32768+vx, vz, 32768+vy); - - glTexCoord2f(-512.f, 0); - glVertex3f( 32768+vx, z, -32768+vy); - glTexCoord2f(-512.f, tz); - glVertex3f( 32768+vx, vz, -32768+vy); - - glTexCoord2f(512.f, 0); - glVertex3f(-32768+vx, z, -32768+vy); - glTexCoord2f(512.f, tz); - glVertex3f(-32768+vx, vz, -32768+vy); - - glEnd(); + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(-32768 + vx, z, -32768 + vy, 512.f, 0); + ptr++; + ptr->Set(-32768 + vx, vz, -32768 + vy, 512.f, tz); + ptr++; + ptr->Set(-32768 + vx, z, 32768 + vy, -512.f, 0); + ptr++; + ptr->Set(-32768 + vx, vz, 32768 + vy, -512.f, tz); + ptr++; + ptr->Set(32768 + vx, z, 32768 + vy, 512.f, 0); + ptr++; + ptr->Set(32768 + vx, vz, 32768 + vy, 512.f, tz); + ptr++; + ptr->Set(32768 + vx, z, -32768 + vy, -512.f, 0); + ptr++; + ptr->Set(32768 + vx, vz, -32768 + vy, -512.f, tz); + ptr++; + ptr->Set(-32768 + vx, z, -32768 + vy, 512.f, 0); + ptr++; + ptr->Set(-32768 + vx, vz, -32768 + vy, 512.f, tz); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); if (pushed) { diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 7648625d3..2879ade62 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -331,7 +331,7 @@ void GLWall::RenderFogBoundary() // this case is special because it needs to change the color in the middle of the polygon so it cannot use the standard function // This also needs no splits so it's relatively simple. gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); + glBegin(GL_TRIANGLE_FAN); // only used on GL 2.x! glVertex3f(glseg.x1, zbottom[0], glseg.y1); glVertex3f(glseg.x1, ztop[0], glseg.y1); glColor4fv(fc); diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index 79321f5b5..d0e18bca4 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -43,8 +43,4 @@ EXTERN_CVAR(Bool, gl_dynlight_shader) EXTERN_CVAR(Float, gl_mask_threshold) EXTERN_CVAR(Float, gl_mask_sprite_threshold) -EXTERN_CVAR(Int, gl_usevbo) - - - #endif // _GL_INTERN_H From 965a2a2d791c9f966f7e0eae4f63eb931d83c176 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Jun 2014 21:56:37 +0200 Subject: [PATCH 0119/1509] definition for model vertex buffer. --- src/gl/data/gl_vertexbuffer.h | 33 ++++++++++++++++++++++++++++++++- src/gl/models/gl_models.h | 2 ++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 50ddd7d13..f82172d08 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -44,7 +44,6 @@ struct FFlatVertex class FFlatVertexBuffer : public FVertexBuffer { FFlatVertex *map; - FFlatVertex mDrawBuffer[1000]; unsigned int mIndex; unsigned int mCurIndex; @@ -170,5 +169,37 @@ public: #define VSO ((FSkyVertex*)NULL) +struct FModelVertex +{ + float x, y, z; // world position + float u, v; // texture coordinates + + void Set(float xx, float yy, float zz, float uu, float vv) + { + x = xx; + y = yy; + z = zz; + u = uu; + v = vv; + } +}; + + +class FModelVertexBuffer : public FVertexBuffer +{ + int mIndexFrame[2]; + +public: + TArray vbo_shadowdata; // this is kept around for interpolating on GL 2.0 + + FModelVertexBuffer(); + ~FModelVertexBuffer(); + + void BindVBO(); + void UpdateBufferPointers(int frame1, int frame2); +}; + +#define VMO ((FModelVertex*)NULL) + #endif \ No newline at end of file diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index ebfb8b8c5..4ba206983 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -2,9 +2,11 @@ #define __GL_MODELS_H_ #include "gl/utility/gl_geometric.h" +#include "gl/data/gl_vertexbuffer.h" #include "p_pspr.h" #include "r_data/voxels.h" + #define MAX_LODS 4 enum { VX, VZ, VY }; From 7757755e40c353b931c69fe5ed58af2685f56974 Mon Sep 17 00:00:00 2001 From: darealshinji Date: Thu, 19 Jun 2014 10:43:37 +0200 Subject: [PATCH 0120/1509] fix detection of libglew library on GNU/Linux --- src/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c20a86ba7..e4ac655ca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -253,7 +253,11 @@ endif( GLEW_INCLUDE_DIR ) # GLEW include directory include_directories( "${GLEW_INCLUDE_DIR}" ) -find_library( GLEW_LIBRARY glew32 ) +if( NOT WIN32 OR APPLE ) + find_library( GLEW_LIBRARY libGLEW.so ) +else( NOT WIN32 OR APPLE ) + find_library( GLEW_LIBRARY glew32 ) +endif( NOT WIN32 OR APPLE ) if( NOT GLEW_LIBRARY ) message( SEND_ERROR "Could not find GLEW library files" ) From 59522f7065f6d32fb75e8d966e36f88380da51e3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 19 Jun 2014 13:37:30 +0200 Subject: [PATCH 0121/1509] - simplified MD2 drawing code as preparation for a buffer based implementation. --- src/gl/models/gl_models.h | 2 +- src/gl/models/gl_models_md2.cpp | 116 ++++++++++---------------------- src/gl/system/gl_interface.cpp | 1 + src/gl/system/gl_interface.h | 1 + 4 files changed, 39 insertions(+), 81 deletions(-) diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 4ba206983..a4effd51d 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -125,7 +125,7 @@ protected: char *vertexUsage; // Bitfield for each vertex. bool allowTexComp; // Allow texture compression with this. - static void RenderGLCommands(void *glCommands, unsigned int numVertices,FModelVertex * vertices); + static void RenderGLCommands(void *glCommands, unsigned int numVertices,FModelVertex * vertices, FModelVertex *vertices2, double inter); public: FDMDModel() diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index 12c8bebe7..46a7238a7 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -263,11 +263,13 @@ int FDMDModel::FindFrame(const char * name) // Render a set of GL commands using the given data. // //=========================================================================== -void FDMDModel::RenderGLCommands(void *glCommands, unsigned int numVertices,FModelVertex * vertices) + +void FDMDModel::RenderGLCommands(void *glCommands, unsigned int numVertices, FModelVertex * vertices, FModelVertex *vertices2, double inter) { char *pos; FGLCommandVertex * v; int count; + const bool interpolate = (vertices2 != NULL && inter != 0.); gl_RenderState.Apply(); for(pos = (char*)glCommands; *pos;) @@ -277,101 +279,55 @@ void FDMDModel::RenderGLCommands(void *glCommands, unsigned int numVertices,FMod // The type of primitive depends on the sign. glBegin(count > 0 ? GL_TRIANGLE_STRIP : GL_TRIANGLE_FAN); + count = abs(count); - while(count--) + while (count--) { - v = (FGLCommandVertex *) pos; + v = (FGLCommandVertex *)pos; pos += sizeof(FGLCommandVertex); glTexCoord2fv(&v->s); - glVertex3fv((float*)&vertices[v->index]); + if (!interpolate) + { + glVertex3fv(vertices[v->index].xyz); + } + else + { + float interp[3]; + for (int i = 0; i < 3; i++) + interp[i] = inter * vertices[v->index].xyz[i] + (1. - inter) * vertices2[v->index].xyz[i]; + glVertex3fv(interp); + } } - glEnd(); } } +void FDMDModel::RenderFrameInterpolated(FTexture * skin, int frameno, int frameno2, double inter, int translation) +{ + if (frameno >= info.numFrames || frameno2 >= info.numFrames) return; + + if (!skin) + { + if (info.numSkins == 0) return; + skin = skins[0]; + if (!skin) return; + } + + FMaterial * tex = FMaterial::ValidateTexture(skin); + + tex->Bind(0, translation); + + RenderGLCommands(lods[0].glCommands, info.numVertices, frames[frameno].vertices, frames[frameno2].vertices, inter); +} + void FDMDModel::RenderFrame(FTexture * skin, int frameno, int translation) { - int activeLod; - - if (frameno>=info.numFrames) return; - - ModelFrame * frame = &frames[frameno]; - //int mainFlags = mf->flags; - - if (!skin) - { - if (info.numSkins==0) return; - skin = skins[0]; - if (!skin) return; - } - - FMaterial * tex = FMaterial::ValidateTexture(skin); - - tex->Bind(0, translation); - - int numVerts = info.numVertices; - - // Determine the suitable LOD. - /* - if(info.numLODs > 1 && rend_model_lod != 0) - { - float lodFactor = rend_model_lod * screen->Width() / 640.0f / (GLRenderer->mCurrentFoV / 90.0f); - if(lodFactor) lodFactor = 1 / lodFactor; - - // Determine the LOD we will be using. - activeLod = (int) (lodFactor * spr->distance); - if(activeLod < 0) activeLod = 0; - if(activeLod >= mdl->info.numLODs) activeLod = mdl->info.numLODs - 1; - vertexUsage = mdl->vertexUsage; - } - else - */ - { - activeLod = 0; - } - - RenderGLCommands(lods[activeLod].glCommands, numVerts, frame->vertices/*, modelColors, NULL*/); + RenderFrameInterpolated(skin, frameno, frameno, 0., translation); } -void FDMDModel::RenderFrameInterpolated(FTexture * skin, int frameno, int frameno2, double inter, int translation) -{ - int activeLod = 0; - - if (frameno>=info.numFrames || frameno2>=info.numFrames) return; - - FModelVertex *vertices1 = frames[frameno].vertices; - FModelVertex *vertices2 = frames[frameno2].vertices; - - if (!skin) - { - if (info.numSkins==0) return; - skin = skins[0]; - if (!skin) return; - } - - FMaterial * tex = FMaterial::ValidateTexture(skin); - - tex->Bind(0, translation); - - int numVerts = info.numVertices; - - // [BB] Calculate the interpolated vertices by linear interpolation. - FModelVertex *verticesInterpolated = new FModelVertex[numVerts]; - for( int k = 0; k < numVerts; k++ ) - { - for ( int i = 0; i < 3; i++ ) - verticesInterpolated[k].xyz[i] = (1-inter)*vertices1[k].xyz[i]+ (inter)*vertices2[k].xyz[i]; - } - - RenderGLCommands(lods[activeLod].glCommands, numVerts, verticesInterpolated/*, modelColors, NULL*/); - delete[] verticesInterpolated; -} - - //=========================================================================== // // FMD2Model::Load diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index ac34bd2c1..d9816e120 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -144,6 +144,7 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; if (gl.version >= 4.f && CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; + if (gl.version >= 3.2f || CheckExtension("GL_ARB_draw_elements_base_vertex")) gl.flags |= RFL_BASEINDEX; glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 45e0a09ac..d280242e1 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -12,6 +12,7 @@ enum RenderFlags RFL_FRAMEBUFFER = 4, RFL_BUFFER_STORAGE = 8, RFL_SHADER_STORAGE_BUFFER = 16, + RFL_BASEINDEX = 32, }; enum TexMode From 03916d75de18162fb7efb1bb6c6ad25b7b60b4ce Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 19 Jun 2014 13:58:49 +0200 Subject: [PATCH 0122/1509] - cleaned up MD3 rendering and merged RenderFrame and RenderFrameInterpolated into one function. --- src/gl/models/gl_models.cpp | 4 +-- src/gl/models/gl_models.h | 15 +++----- src/gl/models/gl_models_md2.cpp | 9 ++--- src/gl/models/gl_models_md3.cpp | 64 +++++++++------------------------ src/gl/models/gl_voxels.cpp | 15 ++------ 5 files changed, 28 insertions(+), 79 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 568a2e3f2..76e8006aa 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -675,9 +675,9 @@ void gl_RenderFrameModels( const FSpriteModelFrame *smf, if (mdl!=NULL) { if ( smfNext && smf->modelframes[i] != smfNext->modelframes[i] ) - mdl->RenderFrameInterpolated(smf->skins[i], smf->modelframes[i], smfNext->modelframes[i], inter, translation); + mdl->RenderFrame(smf->skins[i], smf->modelframes[i], smfNext->modelframes[i], inter, translation); else - mdl->RenderFrame(smf->skins[i], smf->modelframes[i], translation); + mdl->RenderFrame(smf->skins[i], smf->modelframes[i], NULL, 0.f, translation); } } } diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index a4effd51d..181784b9b 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -29,9 +29,7 @@ public: virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0; virtual int FindFrame(const char * name) = 0; - virtual void RenderFrame(FTexture * skin, int frame, int translation=0) = 0; - // [BB] Added RenderFrameInterpolated - virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0; + virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0; virtual void MakeGLData() {} virtual void CleanGLData() {} @@ -140,8 +138,7 @@ public: virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); virtual int FindFrame(const char * name); - virtual void RenderFrame(FTexture * skin, int frame, int translation=0); - virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int translation=0); + virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); }; @@ -222,7 +219,7 @@ class FMD3Model : public FModel MD3Frame * frames; MD3Surface * surfaces; - void RenderTriangles(MD3Surface * surf, MD3Vertex * vert); + void RenderTriangles(MD3Surface * surf, MD3Vertex * vert, MD3Vertex *vert2, double inter); public: FMD3Model() { } @@ -230,8 +227,7 @@ public: virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); virtual int FindFrame(const char * name); - virtual void RenderFrame(FTexture * skin, int frame, int translation=0); - virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int translation=0); + virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); }; class FVoxelVertexBuffer; @@ -293,8 +289,7 @@ public: void MakeGLData(); void CleanGLData(); virtual int FindFrame(const char * name); - virtual void RenderFrame(FTexture * skin, int frame, int translation=0); - virtual void RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int translation=0); + virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); FTexture *GetPaletteTexture() const { return mPalette; } }; diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index 46a7238a7..8fa8310f7 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -269,7 +269,7 @@ void FDMDModel::RenderGLCommands(void *glCommands, unsigned int numVertices, FMo char *pos; FGLCommandVertex * v; int count; - const bool interpolate = (vertices2 != NULL && inter != 0.); + const bool interpolate = (vertices2 != NULL && inter != 0. && vertices != vertices2); gl_RenderState.Apply(); for(pos = (char*)glCommands; *pos;) @@ -304,7 +304,7 @@ void FDMDModel::RenderGLCommands(void *glCommands, unsigned int numVertices, FMo } } -void FDMDModel::RenderFrameInterpolated(FTexture * skin, int frameno, int frameno2, double inter, int translation) +void FDMDModel::RenderFrame(FTexture * skin, int frameno, int frameno2, double inter, int translation) { if (frameno >= info.numFrames || frameno2 >= info.numFrames) return; @@ -323,11 +323,6 @@ void FDMDModel::RenderFrameInterpolated(FTexture * skin, int frameno, int framen } -void FDMDModel::RenderFrame(FTexture * skin, int frameno, int translation) -{ - RenderFrameInterpolated(skin, frameno, frameno, 0., translation); -} - //=========================================================================== // // FMD2Model::Load diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index bd1b4e972..6b380ea29 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -215,8 +215,10 @@ int FMD3Model::FindFrame(const char * name) return -1; } -void FMD3Model::RenderTriangles(MD3Surface * surf, MD3Vertex * vert) +void FMD3Model::RenderTriangles(MD3Surface * surf, MD3Vertex * vert, MD3Vertex *vert2, double inter) { + const bool interpolate = (vert2 != NULL && inter != 0. && vert != vert2); + gl_RenderState.Apply(); glBegin(GL_TRIANGLES); for(int i=0; inumTriangles;i++) @@ -226,44 +228,24 @@ void FMD3Model::RenderTriangles(MD3Surface * surf, MD3Vertex * vert) int x = surf->tris[i].VertIndex[j]; glTexCoord2fv(&surf->texcoords[x].s); - glVertex3f(vert[x].x, vert[x].z, vert[x].y); + if (!interpolate) + { + glVertex3f(vert[x].x, vert[x].z, vert[x].y); + } + else + { + float interp[3]; + interp[0] = inter * vert[x].x + (1. - inter) * vert2[x].x; + interp[1] = inter * vert[x].z + (1. - inter) * vert2[x].z; + interp[2] = inter * vert[x].y + (1. - inter) * vert2[x].y; + glVertex3fv(interp); + } } } glEnd(); } -void FMD3Model::RenderFrame(FTexture * skin, int frameno, int translation) -{ - if (frameno>=numFrames) return; - - MD3Frame * frame = &frames[frameno]; - - // I can't confirm correctness of this because no model I have tested uses this information - // glMatrixMode(GL_MODELVIEW); - // glTranslatef(frame->origin[0], frame->origin[1], frame->origin[2]); - - for(int i=0;inumSkins==0) return; - surfaceSkin = surf->skins[0]; - if (!surfaceSkin) return; - } - - FMaterial * tex = FMaterial::ValidateTexture(surfaceSkin); - - tex->Bind(0, translation); - RenderTriangles(surf, surf->vertices + frameno * surf->numVertices); - } -} - -void FMD3Model::RenderFrameInterpolated(FTexture * skin, int frameno, int frameno2, double inter, int translation) +void FMD3Model::RenderFrame(FTexture * skin, int frameno, int frameno2, double inter, int translation) { if (frameno>=numFrames || frameno2>=numFrames) return; @@ -285,22 +267,10 @@ void FMD3Model::RenderFrameInterpolated(FTexture * skin, int frameno, int framen tex->Bind(0, translation); - MD3Vertex* verticesInterpolated = new MD3Vertex[surfaces[i].numVertices]; MD3Vertex* vertices1 = surf->vertices + frameno * surf->numVertices; MD3Vertex* vertices2 = surf->vertices + frameno2 * surf->numVertices; - // [BB] Calculate the interpolated vertices by linear interpolation. - for( int k = 0; k < surf->numVertices; k++ ) - { - verticesInterpolated[k].x = (1-inter)*vertices1[k].x+ (inter)*vertices2[k].x; - verticesInterpolated[k].y = (1-inter)*vertices1[k].y+ (inter)*vertices2[k].y; - verticesInterpolated[k].z = (1-inter)*vertices1[k].z+ (inter)*vertices2[k].z; - // [BB] Apparently RenderTriangles doesn't use nx, ny, nz, so don't interpolate them. - } - - RenderTriangles(surf, verticesInterpolated); - - delete[] verticesInterpolated; + RenderTriangles(surf, vertices1, vertices2, inter); } } diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 3a04cb5ca..873390f9c 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -498,11 +498,11 @@ int FVoxelModel::FindFrame(const char * name) //=========================================================================== // -// +// Voxels never interpolate between frames // //=========================================================================== -void FVoxelModel::RenderFrame(FTexture * skin, int frame, int translation) +void FVoxelModel::RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation) { FMaterial * tex = FMaterial::ValidateTexture(skin); tex->Bind(0, translation); @@ -529,14 +529,3 @@ void FVoxelModel::RenderFrame(FTexture * skin, int frame, int translation) } } -//=========================================================================== -// -// Voxels never interpolate between frames -// -//=========================================================================== - -void FVoxelModel::RenderFrameInterpolated(FTexture * skin, int frame, int frame2, double inter, int translation) -{ - RenderFrame(skin, frame, translation); -} - From 412d6499d967c9ab660c76756df39c1ee7cec0ed Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 19 Jun 2014 14:46:55 +0200 Subject: [PATCH 0123/1509] - removed the voxel vertex buffer because it needs to be gone before implementing a model vertex buffer. --- src/gl/models/gl_models.cpp | 13 --- src/gl/models/gl_models.h | 6 -- src/gl/models/gl_voxels.cpp | 139 ++------------------------------ src/gl/renderer/gl_renderer.cpp | 1 - 4 files changed, 7 insertions(+), 152 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 76e8006aa..fc248b2cc 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -899,16 +899,3 @@ bool gl_IsHUDModelForPlayerAvailable (player_t * player) return ( smf != NULL ); } -//=========================================================================== -// -// gl_CleanModelData -// -//=========================================================================== - -void gl_CleanModelData() -{ - for (unsigned i=0;iCleanGLData(); - } -} diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 181784b9b..e20010931 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -30,8 +30,6 @@ public: virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0; virtual int FindFrame(const char * name) = 0; virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0; - virtual void MakeGLData() {} - virtual void CleanGLData() {} @@ -274,7 +272,6 @@ protected: bool mOwningVoxel; // if created through MODELDEF deleting this object must also delete the voxel object TArray mVertices; TArray mIndices; - FVoxelVertexBuffer *mVBO; FTexture *mPalette; void MakeSlabPolys(int x, int y, kvxslab_t *voxptr, FVoxelMap &check); @@ -286,8 +283,6 @@ public: ~FVoxelModel(); bool Load(const char * fn, int lumpnum, const char * buffer, int length); void Initialize(); - void MakeGLData(); - void CleanGLData(); virtual int FindFrame(const char * name); virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); FTexture *GetPaletteTexture() const { return mPalette; } @@ -345,6 +340,5 @@ void gl_RenderModel(GLSprite * spr); // [BB] HUD weapon model rendering functions. void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy); bool gl_IsHUDModelForPlayerAvailable (player_t * player); -void gl_CleanModelData(); #endif diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 873390f9c..e1fb094af 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -203,92 +203,6 @@ int FVoxelTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, F return 0; } -//=========================================================================== -// -// -// -//=========================================================================== - - -class FVoxelVertexBuffer : public FVertexBuffer -{ - unsigned int ibo_id; - bool isint; - -public: - FVoxelVertexBuffer(TArray &verts, TArray &indices); - ~FVoxelVertexBuffer(); - void BindVBO(); - bool IsInt() const { return isint; } -}; - - -//=========================================================================== -// -// -// -//=========================================================================== - -FVoxelVertexBuffer::FVoxelVertexBuffer(TArray &verts, TArray &indices) -{ - ibo_id = 0; - glGenBuffers(1, &ibo_id); - - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBufferData(GL_ARRAY_BUFFER, verts.Size() * sizeof(FVoxelVertex), &verts[0], GL_STATIC_DRAW); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); - if (verts.Size() > 65535) - { - glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.Size() * sizeof(unsigned int), &indices[0], GL_STATIC_DRAW); - isint = true; - } - else - { - unsigned short *sbuffer = new unsigned short[indices.Size()]; - for(unsigned i=0;ix); - glTexCoordPointer(2,GL_FLOAT, sizeof(FVoxelVertex), &VVO->u); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); -} - - - //=========================================================================== // // @@ -299,7 +213,6 @@ FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned) { mVoxel = voxel; mOwningVoxel = owned; - mVBO = NULL; mPalette = new FVoxelTexture(voxel); Initialize(); } @@ -312,7 +225,6 @@ FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned) FVoxelModel::~FVoxelModel() { - CleanGLData(); delete mPalette; if (mOwningVoxel) delete mVoxel; } @@ -459,32 +371,6 @@ bool FVoxelModel::Load(const char * fn, int lumpnum, const char * buffer, int le return false; // not needed } -//=========================================================================== -// -// -// -//=========================================================================== - -void FVoxelModel::MakeGLData() -{ - mVBO = new FVoxelVertexBuffer(mVertices, mIndices); -} - -//=========================================================================== -// -// -// -//=========================================================================== - -void FVoxelModel::CleanGLData() -{ - if (mVBO != NULL) - { - delete mVBO; - mVBO = NULL; - } -} - //=========================================================================== // // Voxels don't have frames so always return 0 @@ -507,25 +393,14 @@ void FVoxelModel::RenderFrame(FTexture * skin, int frame, int frame2, double int FMaterial * tex = FMaterial::ValidateTexture(skin); tex->Bind(0, translation); - if (mVBO == NULL) MakeGLData(); - if (mVBO != NULL) + gl_RenderState.Apply(); + glBegin(GL_QUADS); + for (unsigned i = 0; i < mIndices.Size(); i++) { - gl_RenderState.SetVertexBuffer(mVBO); - gl_RenderState.Apply(); - glDrawElements(GL_QUADS, mIndices.Size(), mVBO->IsInt() ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, 0); - gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); - } - else - { - gl_RenderState.Apply(); - glBegin(GL_QUADS); - for (unsigned i = 0; i < mIndices.Size(); i++) - { - FVoxelVertex *vert = &mVertices[mIndices[i]]; - glTexCoord2fv(&vert->u); - glVertex3fv(&vert->x); - } - glEnd(); + FVoxelVertex *vert = &mVertices[mIndices[i]]; + glTexCoord2fv(&vert->u); + glVertex3fv(&vert->x); } + glEnd(); } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 78ec2e34e..a51e1fc37 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -118,7 +118,6 @@ void FGLRenderer::Initialize() FGLRenderer::~FGLRenderer() { - gl_CleanModelData(); gl_DeleteAllAttachedLights(); FMaterial::FlushAll(); //if (mThreadManager != NULL) delete mThreadManager; From 3e9b9c280bcddadca4c2b7854535ef4deb3884c5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 19 Jun 2014 15:22:00 +0200 Subject: [PATCH 0124/1509] - initialize model data at engine start, not at level start. --- src/gl/data/gl_data.cpp | 5 ++--- src/gl/data/gl_data.h | 1 + src/gl/data/gl_setup.cpp | 10 ---------- src/gl/models/gl_models.h | 1 - src/gl/scene/gl_scene.cpp | 1 + src/r_data/sprites.cpp | 4 ++++ 6 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index da72f6313..641b6b14c 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -477,9 +477,8 @@ void gl_RecalcVertexHeights(vertex_t * v) void gl_InitData() { - LineSpecials[157]=LS_SetGlobalFogParameter; - LineSpecials[159]=LS_Sector_SetPlaneReflection; - gl_InitModels(); + LineSpecials[157] = LS_SetGlobalFogParameter; + LineSpecials[159] = LS_Sector_SetPlaneReflection; AdjustSpriteOffsets(); } diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index 6a1589cde..42b6df26e 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -57,6 +57,7 @@ extern TArray currentmapsection; void gl_InitPortals(); void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, FPortal *portal); +void gl_InitData(); extern long gl_frameMS; diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index a76e618d9..458019b41 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -62,7 +62,6 @@ #include "gl/gl_functions.h" void InitGLRMapinfoData(); -void gl_InitData(); //========================================================================== // @@ -613,15 +612,6 @@ void gl_PreprocessLevel() { int i; - static int datadone=-1; - - - if (datadone != restart) - { - datadone = restart; - gl_InitData(); - } - PrepareSegs(); PrepareSectorData(); InitVertexData(); diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index e20010931..7b32be085 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -333,7 +333,6 @@ struct FSpriteModelFrame class GLSprite; -void gl_InitModels(); FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped); void gl_RenderModel(GLSprite * spr); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 8f8d50532..b1bf9e343 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -1224,6 +1224,7 @@ void FGLInterface::RenderView(player_t *player) void FGLInterface::Init() { gl_ParseDefs(); + gl_InitData(); } //=========================================================================== diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index c1e59c415..236355f3b 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -15,6 +15,8 @@ #include "r_data/voxels.h" #include "textures/textures.h" +void gl_InitModels(); + // variables used to look up // and range check thing_t sprites patches TArray sprites; @@ -988,6 +990,8 @@ void R_InitSprites () // [RH] Sort the skins, but leave base as skin 0 //qsort (&skins[PlayerClasses.Size ()], numskins-PlayerClasses.Size (), sizeof(FPlayerSkin), skinsorter); + + gl_InitModels(); } void R_DeinitSpriteData() From 59448941389c01f1b7fcfc2d9b89f28d5e8781b5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 19 Jun 2014 17:06:26 +0200 Subject: [PATCH 0125/1509] - create vertex buffer data for MD2/DMD models. --- src/gl/data/gl_vertexbuffer.h | 7 +++ src/gl/models/gl_models.h | 15 +++-- src/gl/models/gl_models_md2.cpp | 98 +++++++++++++++++++++++++++++++-- 3 files changed, 111 insertions(+), 9 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index f82172d08..ad09fb5d9 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -182,6 +182,11 @@ struct FModelVertex u = uu; v = vv; } + + void SetNormal(float nx, float ny, float nz) + { + // GZDoom currently doesn't use normals. This function is so that the high level code can pretend it does. + } }; @@ -190,7 +195,9 @@ class FModelVertexBuffer : public FVertexBuffer int mIndexFrame[2]; public: + // these are public because it's the models having to fill them in. TArray vbo_shadowdata; // this is kept around for interpolating on GL 2.0 + TArray ibo_shadowdata; // this is kept around for interpolating on GL 2.0 FModelVertexBuffer(); ~FModelVertexBuffer(); diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 7b32be085..cc900649b 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -30,6 +30,7 @@ public: virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0; virtual int FindFrame(const char * name) = 0; virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0; + virtual void BuildVertexBuffer(FModelVertexBuffer *buf); @@ -54,7 +55,7 @@ protected: int flags; }; - struct FModelVertex + struct DMDModelVertex { float xyz[3]; }; @@ -90,8 +91,9 @@ protected: struct ModelFrame { char name[16]; - FModelVertex *vertices; - FModelVertex *normals; + DMDModelVertex *vertices; + DMDModelVertex *normals; + unsigned int vindex; }; struct DMDLoDInfo @@ -114,6 +116,9 @@ protected: DMDInfo info; FTexture ** skins; FTexCoord * texCoords; + + unsigned int ib_index; + unsigned int ib_count; ModelFrame * frames; DMDLoDInfo lodInfo[MAX_LODS]; @@ -121,7 +126,7 @@ protected: char *vertexUsage; // Bitfield for each vertex. bool allowTexComp; // Allow texture compression with this. - static void RenderGLCommands(void *glCommands, unsigned int numVertices,FModelVertex * vertices, FModelVertex *vertices2, double inter); + static void RenderGLCommands(void *glCommands, unsigned int numVertices,DMDModelVertex * vertices, DMDModelVertex *vertices2, double inter); public: FDMDModel() @@ -131,12 +136,14 @@ public: skins = NULL; lods[0].glCommands = NULL; info.numLODs = 0; + ib_count = 0; } virtual ~FDMDModel(); virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); virtual int FindFrame(const char * name); virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); + virtual void BuildVertexBuffer(FModelVertexBuffer *buf); }; diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index 8fa8310f7..ccf604dca 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -163,6 +163,7 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length) temp = (char*)buffer + info.offsetFrames; frames = new ModelFrame[info.numFrames]; + ib_count = 0; for(i = 0, frame = frames; i < info.numFrames; i++, frame++) { @@ -170,8 +171,9 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length) dmd_packedVertex_t *pVtx; memcpy(frame->name, pfr->name, sizeof(pfr->name)); - frame->vertices = new FModelVertex[info.numVertices]; - frame->normals = new FModelVertex[info.numVertices]; + frame->vertices = new DMDModelVertex[info.numVertices]; + frame->normals = new DMDModelVertex[info.numVertices]; + frame->vindex = UINT_MAX; // Translate each vertex. for(k = 0, pVtx = pfr->vertices; k < info.numVertices; k++, pVtx++) @@ -244,6 +246,91 @@ FDMDModel::~FDMDModel() if (vertexUsage != NULL) delete [] vertexUsage; } + +void FDMDModel::BuildVertexBuffer(FModelVertexBuffer *buf) +{ + for (int i = 0; i < info.numFrames; i++) + { + ModelFrame *frame = &frames[i]; + DMDModelVertex *vert = frame->vertices; + DMDModelVertex *norm = frame->normals; + void *glCommands = lods[0].glCommands; + + frame->vindex = buf->vbo_shadowdata.Size(); + + for (char *pos = (char*)glCommands; *pos;) + { + int count = *(int *)pos; + pos += 4; + + // The type of primitive depends on the sign. + int primtype = count > 0 ? GL_TRIANGLE_STRIP : GL_TRIANGLE_FAN; + count = abs(count); + + if (i == 0) + { + // build the index buffer - we'll use the same buffer for all frames so only create it once + unsigned int bufindex = buf->vbo_shadowdata.Size() - frame->vindex; + unsigned int bufp = bufindex; + + if (primtype == GL_TRIANGLE_STRIP) + { + for (int t = 0; t < count - 2; t++) + { + unsigned int *p = &buf->ibo_shadowdata[buf->ibo_shadowdata.Reserve(3)]; + if ((t & 1) == 0) + { + p[0] = bufp; + p[1] = bufp + 1; + p[2] = bufp + 2; + } + else + { + p[0] = bufp; + p[2] = bufp + 2; + p[1] = bufp + 1; + } + bufp++; + } + } + else + { + bufp++; + for (int t = 0; t < count - 2; t++) + { + unsigned int *p = &buf->ibo_shadowdata[buf->ibo_shadowdata.Reserve(3)]; + p[0] = bufindex; + p[1] = bufp; + p[2] = bufp + 1; + bufp++; + } + } + } + + while (count--) + { + FModelVertex bvert; + + FGLCommandVertex * v = (FGLCommandVertex *)pos; + pos += sizeof(FGLCommandVertex); + + bvert.Set(vert[v->index].xyz[0], vert[v->index].xyz[1], vert[v->index].xyz[2], v->s, v->t); + bvert.SetNormal(norm[v->index].xyz[0], norm[v->index].xyz[1], norm[v->index].xyz[2]); + buf->vbo_shadowdata.Push(bvert); + } + } + } +} + + + + + + + + + + //=========================================================================== // // FDMDModel::FindFrame @@ -264,7 +351,7 @@ int FDMDModel::FindFrame(const char * name) // //=========================================================================== -void FDMDModel::RenderGLCommands(void *glCommands, unsigned int numVertices, FModelVertex * vertices, FModelVertex *vertices2, double inter) +void FDMDModel::RenderGLCommands(void *glCommands, unsigned int numVertices, DMDModelVertex * vertices, DMDModelVertex *vertices2, double inter) { char *pos; FGLCommandVertex * v; @@ -418,8 +505,9 @@ bool FMD2Model::Load(const char * path, int, const char * buffer, int length) md2_triangleVertex_t *pVtx; memcpy(frame->name, pfr->name, sizeof(pfr->name)); - frame->vertices = new FModelVertex[info.numVertices]; - frame->normals = new FModelVertex[info.numVertices]; + frame->vertices = new DMDModelVertex[info.numVertices]; + frame->normals = new DMDModelVertex[info.numVertices]; + frame->vindex = UINT_MAX; // Translate each vertex. for(k = 0, pVtx = pfr->vertices; k < info.numVertices; k++, pVtx++) From ca76c2525e63fd9ae5fd6586017bdc3511fff74e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 19 Jun 2014 22:24:33 +0200 Subject: [PATCH 0126/1509] - more vertex buffer stuff for models, still not tested. --- src/gl/models/gl_models.h | 28 +++++++++---------- src/gl/models/gl_models_md3.cpp | 31 +++++++++++++++++++++ src/gl/models/gl_voxels.cpp | 48 +++++++++++++++++++++++++-------- 3 files changed, 82 insertions(+), 25 deletions(-) diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index cc900649b..f9f8f4f22 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -30,7 +30,7 @@ public: virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0; virtual int FindFrame(const char * name) = 0; virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0; - virtual void BuildVertexBuffer(FModelVertexBuffer *buf); + virtual void BuildVertexBuffer(FModelVertexBuffer *buf) = 0; @@ -193,11 +193,15 @@ class FMD3Model : public FModel MD3TexCoord * texcoords; MD3Vertex * vertices; + unsigned int vindex; // contains numframes arrays of vertices + unsigned int iindex; + MD3Surface() { tris=NULL; vertices=NULL; texcoords=NULL; + vindex = iindex = UINT_MAX; } ~MD3Surface() @@ -233,20 +237,13 @@ public: virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); virtual int FindFrame(const char * name); virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); -}; - -class FVoxelVertexBuffer; - -struct FVoxelVertex -{ - float x,y,z; - float u,v; + virtual void BuildVertexBuffer(FModelVertexBuffer *buf); }; struct FVoxelVertexHash { // Returns the hash value for a key. - hash_t Hash(const FVoxelVertex &key) + hash_t Hash(const FModelVertex &key) { int ix = xs_RoundToInt(key.x); int iy = xs_RoundToInt(key.y); @@ -255,7 +252,7 @@ struct FVoxelVertexHash } // Compares two keys, returning zero if they are the same. - int Compare(const FVoxelVertex &left, const FVoxelVertex &right) + int Compare(const FModelVertex &left, const FModelVertex &right) { return left.x != right.x || left.y != right.y || left.z != right.z || left.u != right.u || left.v != right.v; } @@ -269,7 +266,7 @@ struct FIndexInit } }; -typedef TMap FVoxelMap; +typedef TMap FVoxelMap; class FVoxelModel : public FModel @@ -277,13 +274,15 @@ class FVoxelModel : public FModel protected: FVoxel *mVoxel; bool mOwningVoxel; // if created through MODELDEF deleting this object must also delete the voxel object - TArray mVertices; + TArray mVertices; TArray mIndices; FTexture *mPalette; + unsigned int vindex; + unsigned int iindex; void MakeSlabPolys(int x, int y, kvxslab_t *voxptr, FVoxelMap &check); void AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3, int x4, int y4, int z4, BYTE color, FVoxelMap &check); - void AddVertex(FVoxelVertex &vert, FVoxelMap &check); + unsigned int AddVertex(FModelVertex &vert, FVoxelMap &check); public: FVoxelModel(FVoxel *voxel, bool owned); @@ -293,6 +292,7 @@ public: virtual int FindFrame(const char * name); virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); FTexture *GetPaletteTexture() const { return mPalette; } + void BuildVertexBuffer(FModelVertexBuffer *buf); }; diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index 6b380ea29..2c6f39d05 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -206,6 +206,37 @@ bool FMD3Model::Load(const char * path, int, const char * buffer, int length) return true; } +void FMD3Model::BuildVertexBuffer(FModelVertexBuffer *buf) +{ + for (int i = 0; i < numSurfaces; i++) + { + MD3Surface * surf = &surfaces[i]; + + surf->vindex = buf->vbo_shadowdata.Size(); + surf->iindex = buf->ibo_shadowdata.Size(); + for (int j = 0; j < numFrames * surf->numVertices; j++) + { + MD3Vertex* vert = surf->vertices + j; + + FModelVertex bvert; + + int tc = j % surf->numVertices; + bvert.Set(vert->x, vert->z, vert->y, surf->texcoords[tc].s, surf->texcoords[tc].t); + bvert.SetNormal(vert->nx, vert->nz, vert->ny); + buf->vbo_shadowdata.Push(bvert); + } + + for (int k = 0; k < surf->numTriangles; k++) + { + for (int l = 0; l < 3; l++) + { + buf->ibo_shadowdata.Push(surf->tris[k].VertIndex[l]); + } + } + } +} + + int FMD3Model::FindFrame(const char * name) { for (int i=0;ivbo_shadowdata.Size(); + iindex = buf->ibo_shadowdata.Size(); + + FModelVertex *mv = &buf->vbo_shadowdata[buf->vbo_shadowdata.Reserve(mVertices.Size())]; + unsigned int *mi = &buf->ibo_shadowdata[buf->ibo_shadowdata.Reserve(mIndices.Size())]; + + memcpy(mv, &mVertices[0], sizeof(FModelVertex)* mVertices.Size()); + memcpy(mi, &mIndices[0], sizeof(unsigned int)* mIndices.Size()); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +unsigned int FVoxelModel::AddVertex(FModelVertex &vert, FVoxelMap &check) { unsigned int index = check[vert]; if (index == 0xffffffff) { index = check[vert] =mVertices.Push(vert); } - mIndices.Push(index); + return index; } //=========================================================================== @@ -257,8 +277,8 @@ void FVoxelModel::AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3 float PivotY = mVoxel->Mips[0].PivotY / 256.f; float PivotZ = mVoxel->Mips[0].PivotZ / 256.f; int h = mVoxel->Mips[0].SizeZ; - FVoxelVertex vert; - + FModelVertex vert; + unsigned int indx[4]; vert.u = (((col & 15) * 255 / 16) + 7) / 255.f; vert.v = (((col / 16) * 255 / 16) + 7) / 255.f; @@ -266,23 +286,29 @@ void FVoxelModel::AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3 vert.x = x1 - PivotX; vert.z = -y1 + PivotY; vert.y = -z1 + PivotZ; - AddVertex(vert, check); + indx[0] = AddVertex(vert, check); vert.x = x2 - PivotX; vert.z = -y2 + PivotY; vert.y = -z2 + PivotZ; - AddVertex(vert, check); + indx[1] = AddVertex(vert, check); vert.x = x4 - PivotX; vert.z = -y4 + PivotY; vert.y = -z4 + PivotZ; - AddVertex(vert, check); + indx[2] = AddVertex(vert, check); vert.x = x3 - PivotX; vert.z = -y3 + PivotY; vert.y = -z3 + PivotZ; - AddVertex(vert, check); + indx[3] = AddVertex(vert, check); + mIndices.Push(indx[0]); + mIndices.Push(indx[1]); + mIndices.Push(indx[2]); + mIndices.Push(indx[1]); + mIndices.Push(indx[3]); + mIndices.Push(indx[2]); } //=========================================================================== @@ -384,7 +410,7 @@ int FVoxelModel::FindFrame(const char * name) //=========================================================================== // -// Voxels never interpolate between frames +// Voxels never interpolate between frames, they only have one. // //=========================================================================== @@ -394,10 +420,10 @@ void FVoxelModel::RenderFrame(FTexture * skin, int frame, int frame2, double int tex->Bind(0, translation); gl_RenderState.Apply(); - glBegin(GL_QUADS); + glBegin(GL_TRIANGLES); for (unsigned i = 0; i < mIndices.Size(); i++) { - FVoxelVertex *vert = &mVertices[mIndices[i]]; + FModelVertex *vert = &mVertices[mIndices[i]]; glTexCoord2fv(&vert->u); glVertex3fv(&vert->x); } From d5dceb68748e93d1949136104e8b8a17a21bf84f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 21 Jun 2014 12:52:19 +0200 Subject: [PATCH 0127/1509] - changed alpha texture handling to avoid using the deprecated GL_ALPHA8 texture format unless we have a compatibility context of an older GL version. --- src/gl/system/gl_interface.cpp | 1 - src/gl/system/gl_interface.h | 5 +++++ src/gl/textures/gl_bitmap.cpp | 26 ++++++++++++++++++++------ src/gl/textures/gl_hwtexture.cpp | 27 +++++++++++++++++++++++++-- 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index d9816e120..7d979f921 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -153,7 +153,6 @@ void gl_LoadExtensions() { gl.flags|=RFL_FRAMEBUFFER; } - } //========================================================================== diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index d280242e1..d5346fa7d 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -41,6 +41,11 @@ struct RenderContext { return glslversion >= 1.3f; } + + bool hasCompatibility() // will return false, once transition to a core profile is possible and a core profile is used. + { + return true; + } }; extern RenderContext gl; diff --git a/src/gl/textures/gl_bitmap.cpp b/src/gl/textures/gl_bitmap.cpp index 83a92e0fe..c37e7a90e 100644 --- a/src/gl/textures/gl_bitmap.cpp +++ b/src/gl/textures/gl_bitmap.cpp @@ -42,6 +42,7 @@ #include "gl/renderer/gl_lightdata.h" #include "gl/textures/gl_translate.h" #include "gl/textures/gl_bitmap.h" +#include "gl/system/gl_interface.h" //=========================================================================== // @@ -54,7 +55,7 @@ void iCopyColors(unsigned char * pout, const unsigned char * pin, bool alphatex, { int i; - if (!alphatex) + if (!alphatex || gl.version >= 3.3f) // GL 3.3+ uses a GL_R8 texture for alpha textures so the channels can remain as they are. { for(i=0;i 0) diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 7aa8b610c..a2a83e5db 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -190,8 +190,26 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i bool deletebuffer=false; bool use_mipmapping = TexFilter[gl_texture_filter].mipmapping; - if (alphatexture) texformat=GL_ALPHA8; - else if (forcenocompression) texformat = GL_RGBA8; + if (alphatexture) + { + // thanks to deprecation and delayed introduction of a suitable replacement feature this has become a bit messy... + if (gl.version >= 3.3f) + { + texformat = GL_R8; + } + else if (gl.version <= 3.0f || gl.hasCompatibility()) + { + texformat = GL_ALPHA8; + } + else + { + texformat = GL_RGBA8; + } + } + else if (forcenocompression) + { + texformat = GL_RGBA8; + } if (glTexID==0) glGenTextures(1,&glTexID); glBindTexture(GL_TEXTURE_2D, glTexID); lastbound[texunit]=glTexID; @@ -238,6 +256,11 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); + if (alphatexture && gl.version >= 3.3f) + { + static const GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_RED}; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } clampmode = wrapparam==GL_CLAMP? GLT_CLAMPX|GLT_CLAMPY : 0; if (forcenofiltering) From 2925c96b596ce71a4e01463a611318465e8c4661 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 21 Jun 2014 15:50:32 +0200 Subject: [PATCH 0128/1509] removed all GL 2.x code. After thinking about it for a day or so I believe it's the best option to remove all compatibility code because it's a major obstacle for a transition to a core profile. --- src/gl/data/gl_data.cpp | 8 - src/gl/dynlights/gl_dynlight1.cpp | 6 +- src/gl/models/gl_models.cpp | 34 +-- src/gl/renderer/gl_lightdata.cpp | 2 - src/gl/renderer/gl_renderer.cpp | 15 +- src/gl/renderer/gl_renderstate.cpp | 291 +++++++++---------------- src/gl/renderer/gl_renderstate.h | 4 +- src/gl/scene/gl_flats.cpp | 2 +- src/gl/scene/gl_scene.cpp | 83 +------- src/gl/scene/gl_skydome.cpp | 5 - src/gl/scene/gl_sprite.cpp | 19 +- src/gl/scene/gl_walls.cpp | 4 +- src/gl/scene/gl_walls_draw.cpp | 61 +----- src/gl/scene/gl_weapon.cpp | 4 +- src/gl/shaders/gl_shader.cpp | 329 ++++++++++++++--------------- src/gl/system/gl_interface.cpp | 17 +- src/gl/system/gl_interface.h | 11 - src/gl/system/gl_menu.cpp | 36 ---- src/gl/system/gl_wipe.cpp | 47 +---- src/gl/textures/gl_hqresize.cpp | 4 - src/gl/textures/gl_hwtexture.cpp | 41 ++-- src/gl/textures/gl_material.cpp | 143 ++----------- src/gl/textures/gl_material.h | 10 +- src/gl/textures/gl_texture.cpp | 1 - 24 files changed, 339 insertions(+), 838 deletions(-) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 641b6b14c..47a08af83 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -356,14 +356,6 @@ void InitGLRMapinfoData() glset.map_notexturefill = opt->notexturefill; glset.skyrotatevector = opt->skyrotatevector; glset.skyrotatevector2 = opt->skyrotatevector2; - if (!gl.hasGLSL()) - { - // light modes 2 and 8 require shaders - if (glset.map_lightmode == 2 || glset.map_lightmode == 8) - { - glset.map_lightmode = 3; - } - } } else { diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index f13f24ab6..42053e8a5 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -72,11 +72,7 @@ CUSTOM_CVAR (Bool, gl_dynlight_shader, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | { if (self) { - if (!gl.hasGLSL()) - { - self = false; - } - else if (gl.maxuniforms < 1024 && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + if (gl.maxuniforms < 1024 && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) { self = false; } diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index fc248b2cc..0ee9c563f 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -744,17 +744,9 @@ void gl_RenderModel(GLSprite * spr) if(smf->flags & MDL_INHERITACTORPITCH) pitch += float(static_cast(spr->actor->pitch >> 16) / (1 << 13) * 45 + static_cast(spr->actor->pitch & 0x0000FFFF) / (1 << 29) * 45); if(smf->flags & MDL_INHERITACTORROLL) roll += float(static_cast(spr->actor->roll >> 16) / (1 << 13) * 45 + static_cast(spr->actor->roll & 0x0000FFFF) / (1 << 29) * 45); - if (!gl.hasGLSL()) - { - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - } - else - { - glActiveTexture(GL_TEXTURE7); // Hijack the otherwise unused seventh texture matrix for the model to world transformation. - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - } + glActiveTexture(GL_TEXTURE7); // Hijack the otherwise unused seventh texture matrix for the model to world transformation. + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); // Model space => World space glTranslatef(spr->x, spr->z, spr->y ); @@ -786,7 +778,7 @@ void gl_RenderModel(GLSprite * spr) glRotatef(smf->pitchoffset, 0, 0, 1); glRotatef(-smf->rolloffset, 1, 0, 0); - if (gl.hasGLSL()) glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); #if 0 if (gl_light_models) @@ -805,19 +797,11 @@ void gl_RenderModel(GLSprite * spr) gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), NULL, translation ); - if (!gl.hasGLSL()) - { - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - } - else - { - glActiveTexture(GL_TEXTURE7); - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - glActiveTexture(GL_TEXTURE0); - glMatrixMode(GL_MODELVIEW); - } + glActiveTexture(GL_TEXTURE7); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glActiveTexture(GL_TEXTURE0); + glMatrixMode(GL_MODELVIEW); glDepthFunc(GL_LESS); if (!( spr->actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 60ecf70be..29013f280 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -109,7 +109,6 @@ CUSTOM_CVAR(Int,gl_fogmode,1,CVAR_ARCHIVE|CVAR_NOINITCALL) { if (self>2) self=2; if (self<0) self=0; - if (self == 2 && !gl.hasGLSL()) self = 1; } CUSTOM_CVAR(Int, gl_lightmode, 3 ,CVAR_ARCHIVE|CVAR_NOINITCALL) @@ -117,7 +116,6 @@ CUSTOM_CVAR(Int, gl_lightmode, 3 ,CVAR_ARCHIVE|CVAR_NOINITCALL) int newself = self; if (newself > 4) newself=8; // use 8 for software lighting to avoid conflicts with the bit mask if (newself < 0) newself=0; - if ((newself == 2 || newself == 8) && !gl.hasGLSL()) newself = 3; if (self != newself) self = newself; glset.lightmode = newself; } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index a51e1fc37..97cf6d10f 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -216,13 +216,9 @@ void FGLRenderer::FlushTextures() bool FGLRenderer::StartOffscreen() { - if (gl.flags & RFL_FRAMEBUFFER) - { - if (mFBID == 0) glGenFramebuffers(1, &mFBID); - glBindFramebuffer(GL_FRAMEBUFFER, mFBID); - return true; - } - return false; + if (mFBID == 0) glGenFramebuffers(1, &mFBID); + glBindFramebuffer(GL_FRAMEBUFFER, mFBID); + return true; } //=========================================================================== @@ -233,10 +229,7 @@ bool FGLRenderer::StartOffscreen() void FGLRenderer::EndOffscreen() { - if (gl.flags & RFL_FRAMEBUFFER) - { - glBindFramebuffer(GL_FRAMEBUFFER, 0); - } + glBindFramebuffer(GL_FRAMEBUFFER, 0); } //=========================================================================== diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 673c201b8..8ce695cbc 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -94,22 +94,10 @@ void FRenderState::Reset() // //========================================================================== -int FRenderState::SetupShader(int &shaderindex, float warptime) +void FRenderState::SetupShader(int &shaderindex, float warptime) { - int softwarewarp = 0; - - if (gl.hasGLSL()) - { - mEffectState = shaderindex; - if (shaderindex > 0) GLRenderer->mShaderManager->SetWarpSpeed(shaderindex, warptime); - } - else - { - softwarewarp = shaderindex > 0 && shaderindex < 3? shaderindex : 0; - shaderindex = 0; - } - - return softwarewarp; + mEffectState = shaderindex; + if (shaderindex > 0) GLRenderer->mShaderManager->SetWarpSpeed(shaderindex, warptime); } @@ -121,124 +109,119 @@ int FRenderState::SetupShader(int &shaderindex, float warptime) bool FRenderState::ApplyShader() { - - if (gl.hasGLSL()) + FShader *activeShader; + if (mSpecialEffect > EFF_NONE) { - FShader *activeShader; - if (mSpecialEffect > EFF_NONE) + activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect); + } + else + { + activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4); + activeShader->Bind(); + } + + int fogset = 0; + //glColor4fv(mColor.vec); + if (mFogEnabled) + { + if ((mFogColor & 0xffffff) == 0) { - activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect); + fogset = gl_fogmode; } else { - activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4); - activeShader->Bind(); + fogset = -gl_fogmode; } + } - int fogset = 0; - //glColor4fv(mColor.vec); - if (mFogEnabled) + glColor4fv(mColor.vec); + + activeShader->muDesaturation.Set(mDesaturation / 255.f); + activeShader->muFogEnabled.Set(fogset); + activeShader->muTextureMode.Set(mTextureMode); + activeShader->muCameraPos.Set(mCameraPos.vec); + activeShader->muLightParms.Set(mLightParms); + activeShader->muFogColor.Set(mFogColor); + activeShader->muObjectColor.Set(mObjectColor); + activeShader->muDynLightColor.Set(mDynColor); + + if (mGlowEnabled) + { + activeShader->muGlowTopColor.Set(mGlowTop.vec); + activeShader->muGlowBottomColor.Set(mGlowBottom.vec); + activeShader->muGlowTopPlane.Set(mGlowTopPlane.vec); + activeShader->muGlowBottomPlane.Set(mGlowBottomPlane.vec); + activeShader->currentglowstate = 1; + } + else if (activeShader->currentglowstate) + { + // if glowing is on, disable it. + static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f }; + activeShader->muGlowTopColor.Set(nulvec); + activeShader->muGlowBottomColor.Set(nulvec); + activeShader->muGlowTopPlane.Set(nulvec); + activeShader->muGlowBottomPlane.Set(nulvec); + activeShader->currentglowstate = 0; + } + + if (mLightEnabled) + { + activeShader->muLightRange.Set(mNumLights); + glUniform4fv(activeShader->lights_index, mNumLights[3], mLightData); + } + else + { + static const int nulint[] = { 0, 0, 0, 0 }; + activeShader->muLightRange.Set(nulint); + } + + if (mColormapState != activeShader->currentfixedcolormap) + { + float r, g, b; + activeShader->currentfixedcolormap = mColormapState; + if (mColormapState == CM_DEFAULT) { - if ((mFogColor & 0xffffff) == 0) + activeShader->muFixedColormap.Set(0); + } + else if (mColormapState < CM_MAXCOLORMAP) + { + FSpecialColormap *scm = &SpecialColormaps[gl_fixedcolormap - CM_FIRSTSPECIALCOLORMAP]; + float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0], + scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f }; + + activeShader->muFixedColormap.Set(1); + activeShader->muColormapStart.Set(scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f); + activeShader->muColormapRange.Set(m); + } + else if (mColormapState == CM_FOGLAYER) + { + activeShader->muFixedColormap.Set(3); + } + else if (mColormapState == CM_LITE) + { + if (gl_enhanced_nightvision) { - fogset = gl_fogmode; + r = 0.375f, g = 1.0f, b = 0.375f; } else { - fogset = -gl_fogmode; + r = g = b = 1.f; } + activeShader->muFixedColormap.Set(2); + activeShader->muColormapStart.Set(r, g, b, 1.f); } - - glColor4fv(mColor.vec); - - activeShader->muDesaturation.Set(mDesaturation / 255.f); - activeShader->muFogEnabled.Set(fogset); - activeShader->muTextureMode.Set(mTextureMode); - activeShader->muCameraPos.Set(mCameraPos.vec); - activeShader->muLightParms.Set(mLightParms); - activeShader->muFogColor.Set(mFogColor); - activeShader->muObjectColor.Set(mObjectColor); - activeShader->muDynLightColor.Set(mDynColor); - - if (mGlowEnabled) + else if (mColormapState >= CM_TORCH) { - activeShader->muGlowTopColor.Set(mGlowTop.vec); - activeShader->muGlowBottomColor.Set(mGlowBottom.vec); - activeShader->muGlowTopPlane.Set(mGlowTopPlane.vec); - activeShader->muGlowBottomPlane.Set(mGlowBottomPlane.vec); - activeShader->currentglowstate = 1; + int flicker = mColormapState - CM_TORCH; + r = (0.8f + (7 - flicker) / 70.0f); + if (r > 1.0f) r = 1.0f; + b = g = r; + if (gl_enhanced_nightvision) b = g * 0.75f; + activeShader->muFixedColormap.Set(2); + activeShader->muColormapStart.Set(r, g, b, 1.f); } - else if (activeShader->currentglowstate) - { - // if glowing is on, disable it. - static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f }; - activeShader->muGlowTopColor.Set(nulvec); - activeShader->muGlowBottomColor.Set(nulvec); - activeShader->muGlowTopPlane.Set(nulvec); - activeShader->muGlowBottomPlane.Set(nulvec); - activeShader->currentglowstate = 0; - } - - if (mLightEnabled) - { - activeShader->muLightRange.Set(mNumLights); - glUniform4fv(activeShader->lights_index, mNumLights[3], mLightData); - } - else - { - static const int nulint[] = { 0, 0, 0, 0 }; - activeShader->muLightRange.Set(nulint); - } - - if (mColormapState != activeShader->currentfixedcolormap) - { - float r, g, b; - activeShader->currentfixedcolormap = mColormapState; - if (mColormapState == CM_DEFAULT) - { - activeShader->muFixedColormap.Set(0); - } - else if (mColormapState < CM_MAXCOLORMAP) - { - FSpecialColormap *scm = &SpecialColormaps[gl_fixedcolormap - CM_FIRSTSPECIALCOLORMAP]; - float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0], - scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f }; - - activeShader->muFixedColormap.Set(1); - activeShader->muColormapStart.Set(scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f); - activeShader->muColormapRange.Set(m); - } - else if (mColormapState == CM_FOGLAYER) - { - activeShader->muFixedColormap.Set(3); - } - else if (mColormapState == CM_LITE) - { - if (gl_enhanced_nightvision) - { - r = 0.375f, g = 1.0f, b = 0.375f; - } - else - { - r = g = b = 1.f; - } - activeShader->muFixedColormap.Set(2); - activeShader->muColormapStart.Set(r, g, b, 1.f); - } - else if (mColormapState >= CM_TORCH) - { - int flicker = mColormapState - CM_TORCH; - r = (0.8f + (7 - flicker) / 70.0f); - if (r > 1.0f) r = 1.0f; - b = g = r; - if (gl_enhanced_nightvision) b = g * 0.75f; - activeShader->muFixedColormap.Set(2); - activeShader->muColormapStart.Set(r, g, b, 1.f); - } - } - return true; } - return false; + return true; } @@ -248,7 +231,7 @@ bool FRenderState::ApplyShader() // //========================================================================== -void FRenderState::Apply(bool forcenoshader) +void FRenderState::Apply() { if (!gl_direct_state_change) { @@ -283,78 +266,6 @@ void FRenderState::Apply(bool forcenoshader) else mVertexBuffer->BindVBO(); mCurrentVertexBuffer = mVertexBuffer; } - if (forcenoshader || !ApplyShader()) - { - //if (mColor.vec[0] >= 0.f) glColor4fv(mColor.vec); - - GLRenderer->mShaderManager->SetActiveShader(NULL); - if (mTextureMode != ffTextureMode) - { - gl_SetTextureMode((ffTextureMode = mTextureMode)); - } - if (mTextureEnabled != ffTextureEnabled) - { - if ((ffTextureEnabled = mTextureEnabled)) glEnable(GL_TEXTURE_2D); - else glDisable(GL_TEXTURE_2D); - } - if (mFogEnabled != ffFogEnabled) - { - if ((ffFogEnabled = mFogEnabled)) - { - glEnable(GL_FOG); - } - else glDisable(GL_FOG); - } - if (mFogEnabled) - { - if (ffFogColor != mFogColor) - { - ffFogColor = mFogColor; - GLfloat FogColor[4]={mFogColor.r/255.0f,mFogColor.g/255.0f,mFogColor.b/255.0f,0.0f}; - glFogfv(GL_FOG_COLOR, FogColor); - } - if (ffFogDensity != mLightParms[2]) - { - const float LOG2E = 1.442692f; // = 1/log(2) - glFogf(GL_FOG_DENSITY, -mLightParms[2] / LOG2E); - ffFogDensity = mLightParms[2]; - } - } - if (mSpecialEffect != ffSpecialEffect) - { - switch (ffSpecialEffect) - { - case EFF_SPHEREMAP: - glDisable(GL_TEXTURE_GEN_T); - glDisable(GL_TEXTURE_GEN_S); - - default: - break; - } - switch (mSpecialEffect) - { - case EFF_SPHEREMAP: - // Use sphere mapping for this - glEnable(GL_TEXTURE_GEN_T); - glEnable(GL_TEXTURE_GEN_S); - glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP); - glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP); - break; - - default: - break; - } - ffSpecialEffect = mSpecialEffect; - } - // Now compose the final color for this... - float realcolor[4]; - realcolor[0] = clamp((mColor.vec[0] + mDynColor.r / 255.f), 0.f, 1.f) * (mObjectColor.r / 255.f); - realcolor[1] = clamp((mColor.vec[1] + mDynColor.g / 255.f), 0.f, 1.f) * (mObjectColor.g / 255.f); - realcolor[2] = clamp((mColor.vec[2] + mDynColor.b / 255.f), 0.f, 1.f) * (mObjectColor.b / 255.f); - realcolor[3] = mColor.vec[3] * (mObjectColor.a / 255.f); - glColor4fv(realcolor); - - } - + ApplyShader(); } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 8bcedcac7..c3ca1e273 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -92,8 +92,8 @@ public: void Reset(); - int SetupShader(int &shaderindex, float warptime); - void Apply(bool forcenoshader = false); + void SetupShader(int &shaderindex, float warptime); + void Apply(); void SetVertexBuffer(FVertexBuffer *vb) { diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 56d2bd8d6..7e327ab9c 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -501,7 +501,7 @@ inline void GLFlat::PutFlat(bool fog) else foggy = false; list = list_indices[light][masked][foggy]; - if (list == GLDL_LIGHT && gltexture->tex->gl_info.Brightmap && gl.hasGLSL()) list = GLDL_LIGHTBRIGHT; + if (list == GLDL_LIGHT && gltexture->tex->gl_info.Brightmap) list = GLDL_LIGHTBRIGHT; gl_drawinfo->drawlists[list].AddFlat (this); } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index b1bf9e343..4868d07bd 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -287,12 +287,10 @@ void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) void FGLRenderer::SetViewMatrix(bool mirror, bool planemirror) { - if (gl.hasGLSL()) - { - glActiveTexture(GL_TEXTURE7); - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - } + glActiveTexture(GL_TEXTURE7); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glActiveTexture(GL_TEXTURE0); glMatrixMode(GL_TEXTURE); glLoadIdentity(); @@ -725,69 +723,6 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) V_AddBlend(blendv.r / 255.f, blendv.g / 255.f, blendv.b / 255.f, blendv.a / 255.0f, blend); } } - else if (!gl.hasGLSL()) - { - float r, g, b; - bool inverse = false; - const float BLACK_THRESH = 0.05f; - const float WHITE_THRESH = 0.95f; - - // for various reasons (performance and keeping the lighting code clean) - // we no longer do colormapped textures on pre GL 3.0 hardware and instead do - // just a fullscreen overlay to emulate the inverse invulnerability effect or similar fullscreen blends. - if (gl_fixedcolormap >= (DWORD)CM_FIRSTSPECIALCOLORMAP && gl_fixedcolormap < (DWORD)CM_MAXCOLORMAP) - { - FSpecialColormap *scm = &SpecialColormaps[gl_fixedcolormap - CM_FIRSTSPECIALCOLORMAP]; - - if (scm->ColorizeEnd[0] < BLACK_THRESH && scm->ColorizeEnd[1] < BLACK_THRESH && scm->ColorizeEnd[2] < BLACK_THRESH) - { - r = scm->ColorizeStart[0]; - g = scm->ColorizeStart[1]; - b = scm->ColorizeStart[2]; - inverse = true; - } - else - { - r = scm->ColorizeEnd[0]; - g = scm->ColorizeEnd[1]; - b = scm->ColorizeEnd[2]; - } - } - else if (gl_enhanced_nightvision) - { - if (gl_fixedcolormap == CM_LITE) - { - r = 0.375f; - g = 1.0f; - b = 0.375f; - } - else if (gl_fixedcolormap >= CM_TORCH) - { - int flicker = gl_fixedcolormap - CM_TORCH; - r = (0.8f + (7 - flicker) / 70.0f); - if (r > 1.0f) r = 1.0f; - g = r; - b = g * 0.75f; - } - else r = g = b = 1.f; - } - else r = g = b = 1.f; - - if (inverse) - { - gl_RenderState.BlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); - gl_RenderState.ResetColor(); - FillScreen(); - } - - if (r < WHITE_THRESH || g < WHITE_THRESH || b < WHITE_THRESH) - { - gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); - gl_RenderState.SetColor(r, g, b, 1.0f); - FillScreen(); - } - } - // This mostly duplicates the code in shared_sbar.cpp // When I was writing this the original was called too late so that I @@ -1245,15 +1180,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in gl_fixedcolormap=CM_DEFAULT; gl_RenderState.SetFixedColormap(CM_DEFAULT); - bool usefb; - - if (gl.flags & RFL_FRAMEBUFFER) - { - usefb = gl_usefb || width > screen->GetWidth() || height > screen->GetHeight(); - } - else usefb = false; - - + bool usefb = gl_usefb || width > screen->GetWidth() || height > screen->GetHeight(); if (!usefb) { glFlush(); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index d36e5fdba..ad3b1c90b 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -232,8 +232,6 @@ void FSkyVertexBuffer::RenderDome(FMaterial *tex, int mode) // The caps only get drawn for the main layer but not for the overlay. if (mode == SKYMODE_MAINLAYER && tex != NULL) { - // if there's no shader we cannot use the default color from the buffer because the object color is part of the preset vertex attribute. - if (!gl.hasGLSL()) glDisableClientState(GL_COLOR_ARRAY); PalEntry pe = tex->tex->GetSkyCapColor(false); gl_RenderState.SetObjectColor(pe); gl_RenderState.EnableTexture(false); @@ -245,7 +243,6 @@ void FSkyVertexBuffer::RenderDome(FMaterial *tex, int mode) gl_RenderState.Apply(); RenderRow(GL_TRIANGLE_FAN, rc); gl_RenderState.EnableTexture(true); - if (!gl.hasGLSL()) glEnableClientState(GL_COLOR_ARRAY); } gl_RenderState.SetObjectColor(0xffffffff); gl_RenderState.Apply(); @@ -522,9 +519,7 @@ void GLSkyPortal::DrawContents() gl_RenderState.EnableTexture(false); gl_RenderState.SetObjectColor(FadeColor); gl_RenderState.Apply(); - if (!gl.hasGLSL()) glDisableClientState(GL_COLOR_ARRAY); glDrawArrays(GL_TRIANGLES, 0, 12); - if (!gl.hasGLSL()) glEnableClientState(GL_COLOR_ARRAY); gl_RenderState.EnableTexture(true); } gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 00f2ccada..ab0586f58 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -199,18 +199,9 @@ void GLSprite::Draw(int pass) // non-black fog with subtractive style needs special treatment if (!gl_isBlack(Colormap.FadeColor)) { - if (gl.hasGLSL() && !gl_nolayer) - { - // fog layer only works on modern hardware. - foglayer = true; - // Due to the two-layer approach we need to force an alpha test that lets everything pass - gl_RenderState.AlphaFunc(GL_GREATER, 0); - } - else - { - // this at least partially handles the fog issue - Colormap.FadeColor = Colormap.FadeColor.InverseColor(); - } + foglayer = true; + // Due to the two-layer approach we need to force an alpha test that lets everything pass + gl_RenderState.AlphaFunc(GL_GREATER, 0); } } else RenderStyle.BlendOp = STYLEOP_Fuzz; // subtractive with models is not going to work. @@ -668,7 +659,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) // allow disabling of the fullbright flag by a brightmap definition // (e.g. to do the gun flashes of Doom's zombies correctly. fullbright = (thing->flags5 & MF5_BRIGHT) || - ((thing->renderflags & RF_FULLBRIGHT) && (!gl.hasGLSL() || !gltexture || !gltexture->tex->gl_info.bBrightmapDisablesFullbright)); + ((thing->renderflags & RF_FULLBRIGHT) && (!gltexture || !gltexture->tex->gl_info.bBrightmapDisablesFullbright)); lightlevel=fullbright? 255 : gl_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ? @@ -737,7 +728,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) RenderStyle.CheckFuzz(); if (RenderStyle.BlendOp == STYLEOP_Fuzz) { - if (gl.hasGLSL() && gl_fuzztype != 0) + if (gl_fuzztype != 0) { // Todo: implement shader selection here RenderStyle = LegacyRenderStyles[STYLE_Translucent]; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 2d6b78fd5..bf9d52066 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -71,7 +71,7 @@ void GLWall::CheckGlowing() { bottomglowcolor[3] = topglowcolor[3] = 0; - if (!gl_isFullbright(Colormap.LightColor, lightlevel) && gl.hasGLSL()) + if (!gl_isFullbright(Colormap.LightColor, lightlevel)) { FTexture *tex = TexMan[topflat]; if (tex != NULL && tex->isGlowing()) @@ -184,7 +184,7 @@ void GLWall::PutWall(bool translucent) list = list_indices[light][masked][!!(flags&GLWF_FOGGY)]; if (list == GLDL_LIGHT) { - if (gltexture->tex->gl_info.Brightmap && gl.hasGLSL()) list = GLDL_LIGHTBRIGHT; + if (gltexture->tex->gl_info.Brightmap) list = GLDL_LIGHTBRIGHT; if (flags & GLWF_GLOW) list = GLDL_LIGHTBRIGHT; } gl_drawinfo->drawlists[list].AddWall(this); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 2879ade62..8e3a4b955 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -291,60 +291,13 @@ void GLWall::RenderFogBoundary() { if (gl_fogmode && gl_fixedcolormap == 0) { - // with shaders this can be done properly - if (gl.hasGLSL()) - { - int rel = rellight + getExtraLight(); - gl_SetFog(lightlevel, rel, &Colormap, false); - gl_RenderState.SetEffect(EFF_FOGBOUNDARY); - gl_RenderState.EnableAlphaTest(false); - RenderWall(RWF_BLANK); - gl_RenderState.EnableAlphaTest(true); - gl_RenderState.SetEffect(EFF_NONE); - } - else - { - // If we use the fixed function pipeline (GL 2.x) - // some approximation is needed. This won't look as good - // as the shader version but it's an acceptable compromise. - float fogdensity=gl_GetFogDensity(lightlevel, Colormap.FadeColor); - - float xcamera=FIXED2FLOAT(viewx); - float ycamera=FIXED2FLOAT(viewy); - - float dist1=Dist2(xcamera,ycamera, glseg.x1,glseg.y1); - float dist2=Dist2(xcamera,ycamera, glseg.x2,glseg.y2); - - - // these values were determined by trial and error and are scale dependent! - float fogd1=(0.95f-exp(-fogdensity*dist1/62500.f)) * 1.05f; - float fogd2=(0.95f-exp(-fogdensity*dist2/62500.f)) * 1.05f; - - float fc[4]={Colormap.FadeColor.r/255.0f,Colormap.FadeColor.g/255.0f,Colormap.FadeColor.b/255.0f,fogd2}; - - gl_RenderState.EnableTexture(false); - gl_RenderState.EnableFog(false); - gl_RenderState.AlphaFunc(GL_GREATER,0); - glDepthFunc(GL_LEQUAL); - gl_RenderState.SetColor(fc[0], fc[1], fc[2], fogd1); - - // this case is special because it needs to change the color in the middle of the polygon so it cannot use the standard function - // This also needs no splits so it's relatively simple. - gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); // only used on GL 2.x! - glVertex3f(glseg.x1, zbottom[0], glseg.y1); - glVertex3f(glseg.x1, ztop[0], glseg.y1); - glColor4fv(fc); - glVertex3f(glseg.x2, ztop[1], glseg.y2); - glVertex3f(glseg.x2, zbottom[1], glseg.y2); - glEnd(); - vertexcount += 4; - - glDepthFunc(GL_LESS); - gl_RenderState.EnableFog(true); - gl_RenderState.AlphaFunc(GL_GEQUAL,0.5f); - gl_RenderState.EnableTexture(true); - } + int rel = rellight + getExtraLight(); + gl_SetFog(lightlevel, rel, &Colormap, false); + gl_RenderState.SetEffect(EFF_FOGBOUNDARY); + gl_RenderState.EnableAlphaTest(false); + RenderWall(RWF_BLANK); + gl_RenderState.EnableAlphaTest(true); + gl_RenderState.SetEffect(EFF_NONE); } } diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 8f76b0571..219eaf115 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -208,7 +208,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) { bool disablefullbright = false; FTextureID lump = gl_GetSpriteFrame(psp->sprite, psp->frame, 0, 0, NULL); - if (lump.isValid() && gl.hasGLSL()) + if (lump.isValid()) { FMaterial * tex=FMaterial::ValidateTexture(lump, false); if (tex) @@ -316,7 +316,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) vis.RenderStyle.CheckFuzz(); if (vis.RenderStyle.BlendOp == STYLEOP_Fuzz) { - if (gl.hasGLSL() && gl_fuzztype != 0) + if (gl_fuzztype != 0) { // Todo: implement shader selection here vis.RenderStyle = LegacyRenderStyles[STYLE_Translucent]; diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index b90974222..ca7f8be72 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -68,146 +68,142 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * static char buffer[10000]; FString error; - if (gl.hasGLSL()) + int i_lump = Wads.CheckNumForFullName("shaders/glsl/shaderdefs.i"); + if (i_lump == -1) I_Error("Unable to load 'shaders/glsl/shaderdefs.i'"); + FMemLump i_data = Wads.ReadLump(i_lump); + + int vp_lump = Wads.CheckNumForFullName(vert_prog_lump); + if (vp_lump == -1) I_Error("Unable to load '%s'", vert_prog_lump); + FMemLump vp_data = Wads.ReadLump(vp_lump); + + int fp_lump = Wads.CheckNumForFullName(frag_prog_lump); + if (fp_lump == -1) I_Error("Unable to load '%s'", frag_prog_lump); + FMemLump fp_data = Wads.ReadLump(fp_lump); + + + +// +// The following code uses GetChars on the strings to get rid of terminating 0 characters. Do not remove or the code may break! +// + + FString vp_comb = "#version 130\n"; + if (gl.glslversion >= 3.3f) vp_comb = "#version 330 compatibility\n"; // I can't shut up the deprecation warnings in GLSL 1.3 so if available use a version with compatibility profile. + // todo when using shader storage buffers, add + // "#version 400 compatibility\n#extension GL_ARB_shader_storage_buffer_object : require\n" instead. + vp_comb << defines << i_data.GetString().GetChars(); + FString fp_comb = vp_comb; + + vp_comb << vp_data.GetString().GetChars() << "\n"; + fp_comb << fp_data.GetString().GetChars() << "\n"; + + if (proc_prog_lump != NULL) { - int i_lump = Wads.CheckNumForFullName("shaders/glsl/shaderdefs.i"); - if (i_lump == -1) I_Error("Unable to load 'shaders/glsl/shaderdefs.i'"); - FMemLump i_data = Wads.ReadLump(i_lump); - - int vp_lump = Wads.CheckNumForFullName(vert_prog_lump); - if (vp_lump == -1) I_Error("Unable to load '%s'", vert_prog_lump); - FMemLump vp_data = Wads.ReadLump(vp_lump); - - int fp_lump = Wads.CheckNumForFullName(frag_prog_lump); - if (fp_lump == -1) I_Error("Unable to load '%s'", frag_prog_lump); - FMemLump fp_data = Wads.ReadLump(fp_lump); - - - - // - // The following code uses GetChars on the strings to get rid of terminating 0 characters. Do not remove or the code may break! - // - - FString vp_comb = "#version 130\n"; - if (gl.glslversion >= 3.3f) vp_comb = "#version 330 compatibility\n"; // I can't shut up the deprecation warnings in GLSL 1.3 so if available use a version with compatibility profile. - // todo when using shader storage buffers, add - // "#version 400 compatibility\n#extension GL_ARB_shader_storage_buffer_object : require\n" instead. - vp_comb << defines << i_data.GetString().GetChars(); - FString fp_comb = vp_comb; - - vp_comb << vp_data.GetString().GetChars() << "\n"; - fp_comb << fp_data.GetString().GetChars() << "\n"; - - if (proc_prog_lump != NULL) + if (*proc_prog_lump != '#') { - if (*proc_prog_lump != '#') + int pp_lump = Wads.CheckNumForFullName(proc_prog_lump); + if (pp_lump == -1) I_Error("Unable to load '%s'", proc_prog_lump); + FMemLump pp_data = Wads.ReadLump(pp_lump); + + if (pp_data.GetString().IndexOf("ProcessTexel") < 0) { - int pp_lump = Wads.CheckNumForFullName(proc_prog_lump); - if (pp_lump == -1) I_Error("Unable to load '%s'", proc_prog_lump); - FMemLump pp_data = Wads.ReadLump(pp_lump); + // this looks like an old custom hardware shader. + // We need to replace the ProcessTexel call to make it work. - if (pp_data.GetString().IndexOf("ProcessTexel") < 0) - { - // this looks like an old custom hardware shader. - // We need to replace the ProcessTexel call to make it work. - - fp_comb.Substitute("vec4 frag = ProcessTexel();", "vec4 frag = Process(vec4(1.0));"); - } - fp_comb << pp_data.GetString().GetChars(); - - if (pp_data.GetString().IndexOf("ProcessLight") < 0) - { - int pl_lump = Wads.CheckNumForFullName("shaders/glsl/func_defaultlight.fp"); - if (pl_lump == -1) I_Error("Unable to load '%s'", "shaders/glsl/func_defaultlight.fp"); - FMemLump pl_data = Wads.ReadLump(pl_lump); - fp_comb << "\n" << pl_data.GetString().GetChars(); - } + fp_comb.Substitute("vec4 frag = ProcessTexel();", "vec4 frag = Process(vec4(1.0));"); } - else + fp_comb << pp_data.GetString().GetChars(); + + if (pp_data.GetString().IndexOf("ProcessLight") < 0) { - // Proc_prog_lump is not a lump name but the source itself (from generated shaders) - fp_comb << proc_prog_lump + 1; + int pl_lump = Wads.CheckNumForFullName("shaders/glsl/func_defaultlight.fp"); + if (pl_lump == -1) I_Error("Unable to load '%s'", "shaders/glsl/func_defaultlight.fp"); + FMemLump pl_data = Wads.ReadLump(pl_lump); + fp_comb << "\n" << pl_data.GetString().GetChars(); } } - - hVertProg = glCreateShader(GL_VERTEX_SHADER); - hFragProg = glCreateShader(GL_FRAGMENT_SHADER); - - - int vp_size = (int)vp_comb.Len(); - int fp_size = (int)fp_comb.Len(); - - const char *vp_ptr = vp_comb.GetChars(); - const char *fp_ptr = fp_comb.GetChars(); - - glShaderSource(hVertProg, 1, &vp_ptr, &vp_size); - glShaderSource(hFragProg, 1, &fp_ptr, &fp_size); - - glCompileShader(hVertProg); - glCompileShader(hFragProg); - - hShader = glCreateProgram(); - - glAttachShader(hShader, hVertProg); - glAttachShader(hShader, hFragProg); - - glLinkProgram(hShader); - - glGetShaderInfoLog(hVertProg, 10000, NULL, buffer); - if (*buffer) + else { - error << "Vertex shader:\n" << buffer << "\n"; + // Proc_prog_lump is not a lump name but the source itself (from generated shaders) + fp_comb << proc_prog_lump + 1; } - glGetShaderInfoLog(hFragProg, 10000, NULL, buffer); - if (*buffer) - { - error << "Fragment shader:\n" << buffer << "\n"; - } - - glGetProgramInfoLog(hShader, 10000, NULL, buffer); - if (*buffer) - { - error << "Linking:\n" << buffer << "\n"; - } - int linked; - glGetProgramiv(hShader, GL_LINK_STATUS, &linked); - if (linked == 0) - { - // only print message if there's an error. - I_Error("Init Shader '%s':\n%s\n", name, error.GetChars()); - } - - - muDesaturation.Init(hShader, "uDesaturationFactor"); - muFogEnabled.Init(hShader, "uFogEnabled"); - muTextureMode.Init(hShader, "uTextureMode"); - muCameraPos.Init(hShader, "uCameraPos"); - muLightParms.Init(hShader, "uLightAttr"); - muColormapStart.Init(hShader, "uFixedColormapStart"); - muColormapRange.Init(hShader, "uFixedColormapRange"); - muLightRange.Init(hShader, "uLightRange"); - muFogColor.Init(hShader, "uFogColor"); - muDynLightColor.Init(hShader, "uDynLightColor"); - muObjectColor.Init(hShader, "uObjectColor"); - muGlowBottomColor.Init(hShader, "uGlowBottomColor"); - muGlowTopColor.Init(hShader, "uGlowTopColor"); - muGlowBottomPlane.Init(hShader, "uGlowBottomPlane"); - muGlowTopPlane.Init(hShader, "uGlowTopPlane"); - muFixedColormap.Init(hShader, "uFixedColormap"); - - timer_index = glGetUniformLocation(hShader, "timer"); - lights_index = glGetUniformLocation(hShader, "lights"); - - - glUseProgram(hShader); - - int texture_index = glGetUniformLocation(hShader, "texture2"); - if (texture_index > 0) glUniform1i(texture_index, 1); - - glUseProgram(0); - return !!linked; } - return false; + + hVertProg = glCreateShader(GL_VERTEX_SHADER); + hFragProg = glCreateShader(GL_FRAGMENT_SHADER); + + + int vp_size = (int)vp_comb.Len(); + int fp_size = (int)fp_comb.Len(); + + const char *vp_ptr = vp_comb.GetChars(); + const char *fp_ptr = fp_comb.GetChars(); + + glShaderSource(hVertProg, 1, &vp_ptr, &vp_size); + glShaderSource(hFragProg, 1, &fp_ptr, &fp_size); + + glCompileShader(hVertProg); + glCompileShader(hFragProg); + + hShader = glCreateProgram(); + + glAttachShader(hShader, hVertProg); + glAttachShader(hShader, hFragProg); + + glLinkProgram(hShader); + + glGetShaderInfoLog(hVertProg, 10000, NULL, buffer); + if (*buffer) + { + error << "Vertex shader:\n" << buffer << "\n"; + } + glGetShaderInfoLog(hFragProg, 10000, NULL, buffer); + if (*buffer) + { + error << "Fragment shader:\n" << buffer << "\n"; + } + + glGetProgramInfoLog(hShader, 10000, NULL, buffer); + if (*buffer) + { + error << "Linking:\n" << buffer << "\n"; + } + int linked; + glGetProgramiv(hShader, GL_LINK_STATUS, &linked); + if (linked == 0) + { + // only print message if there's an error. + I_Error("Init Shader '%s':\n%s\n", name, error.GetChars()); + } + + + muDesaturation.Init(hShader, "uDesaturationFactor"); + muFogEnabled.Init(hShader, "uFogEnabled"); + muTextureMode.Init(hShader, "uTextureMode"); + muCameraPos.Init(hShader, "uCameraPos"); + muLightParms.Init(hShader, "uLightAttr"); + muColormapStart.Init(hShader, "uFixedColormapStart"); + muColormapRange.Init(hShader, "uFixedColormapRange"); + muLightRange.Init(hShader, "uLightRange"); + muFogColor.Init(hShader, "uFogColor"); + muDynLightColor.Init(hShader, "uDynLightColor"); + muObjectColor.Init(hShader, "uObjectColor"); + muGlowBottomColor.Init(hShader, "uGlowBottomColor"); + muGlowTopColor.Init(hShader, "uGlowTopColor"); + muGlowBottomPlane.Init(hShader, "uGlowBottomPlane"); + muGlowTopPlane.Init(hShader, "uGlowTopPlane"); + muFixedColormap.Init(hShader, "uFixedColormap"); + + timer_index = glGetUniformLocation(hShader, "timer"); + lights_index = glGetUniformLocation(hShader, "lights"); + + + glUseProgram(hShader); + + int texture_index = glGetUniformLocation(hShader, "texture2"); + if (texture_index > 0) glUniform1i(texture_index, 1); + + glUseProgram(0); + return !!linked; } //========================================================================== @@ -218,12 +214,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * FShader::~FShader() { - if (gl.hasGLSL()) - { - glDeleteProgram(hShader); - glDeleteShader(hVertProg); - glDeleteShader(hFragProg); - } + glDeleteProgram(hShader); + glDeleteShader(hVertProg); + glDeleteShader(hFragProg); } @@ -351,33 +344,30 @@ void FShaderManager::CompileShaders() try { mActiveShader = mEffectShaders[0] = mEffectShaders[1] = NULL; - if (gl.hasGLSL()) + for (int i = 0; defaultshaders[i].ShaderName != NULL; i++) { - for (int i = 0; defaultshaders[i].ShaderName != NULL; i++) - { - FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc); - mTextureEffects.Push(shc); - } + FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc); + mTextureEffects.Push(shc); + } - for (unsigned i = 0; i < usershaders.Size(); i++) - { - FString name = ExtractFileBase(usershaders[i]); - FName sfn = name; + for (unsigned i = 0; i < usershaders.Size(); i++) + { + FString name = ExtractFileBase(usershaders[i]); + FName sfn = name; - FShader *shc = Compile(sfn, usershaders[i]); - mTextureEffects.Push(shc); - } + FShader *shc = Compile(sfn, usershaders[i]); + mTextureEffects.Push(shc); + } - for (int i = 0; i < MAX_EFFECTS; i++) + for (int i = 0; i < MAX_EFFECTS; i++) + { + FShader *eff = new FShader(effectshaders[i].ShaderName); + if (!eff->Load(effectshaders[i].ShaderName, effectshaders[i].vp, effectshaders[i].fp1, + effectshaders[i].fp2, effectshaders[i].defines)) { - FShader *eff = new FShader(effectshaders[i].ShaderName); - if (!eff->Load(effectshaders[i].ShaderName, effectshaders[i].vp, effectshaders[i].fp1, - effectshaders[i].fp2, effectshaders[i].defines)) - { - delete eff; - } - else mEffectShaders[i] = eff; + delete eff; } + else mEffectShaders[i] = eff; } } catch (CRecoverableError &err) @@ -398,22 +388,19 @@ void FShaderManager::CompileShaders() void FShaderManager::Clean() { - if (gl.hasGLSL()) - { - glUseProgram(0); - mActiveShader = NULL; + glUseProgram(0); + mActiveShader = NULL; - for (unsigned int i = 0; i < mTextureEffects.Size(); i++) - { - if (mTextureEffects[i] != NULL) delete mTextureEffects[i]; - } - for (int i = 0; i < MAX_EFFECTS; i++) - { - if (mEffectShaders[i] != NULL) delete mEffectShaders[i]; - mEffectShaders[i] = NULL; - } - mTextureEffects.Clear(); + for (unsigned int i = 0; i < mTextureEffects.Size(); i++) + { + if (mTextureEffects[i] != NULL) delete mTextureEffects[i]; } + for (int i = 0; i < MAX_EFFECTS; i++) + { + if (mEffectShaders[i] != NULL) delete mEffectShaders[i]; + mEffectShaders[i] = NULL; + } + mTextureEffects.Clear(); } //========================================================================== @@ -444,7 +431,7 @@ int FShaderManager::Find(const char * shn) void FShaderManager::SetActiveShader(FShader *sh) { - if (gl.hasGLSL() && mActiveShader != sh) + if (mActiveShader != sh) { glUseProgram(sh!= NULL? sh->GetHandle() : 0); mActiveShader = sh; diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 7d979f921..aaa9568f9 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -127,17 +127,13 @@ void gl_LoadExtensions() else Printf("Emulating OpenGL v %s\n", version); - // Don't even start if it's lower than 1.3 - if (strcmp(version, "2.0") < 0) + // Don't even start if it's lower than 3.0 + if (strcmp(version, "3.0") < 0) { - I_FatalError("Unsupported OpenGL version.\nAt least GL 2.0 is required to run " GAMENAME ".\n"); + I_FatalError("Unsupported OpenGL version.\nAt least GL 3.0 is required to run " GAMENAME ".\n"); } gl.version = strtod(version, NULL); gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL); - if (gl.version < 3.f) gl.glslversion = 0.f; - - // This loads any function pointers and flags that require a vaild render context to - // initialize properly gl.vendorstring=(char*)glGetString(GL_VENDOR); @@ -148,11 +144,6 @@ void gl_LoadExtensions() glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - if (gl.version >= 3.f) - { - gl.flags|=RFL_FRAMEBUFFER; - } } //========================================================================== @@ -176,7 +167,7 @@ void gl_PrintStartupLog() Printf ("Max. texture units: %d\n", v); glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); Printf ("Max. fragment uniforms: %d\n", v); - if (gl.hasGLSL()) gl.maxuniforms = v; + gl.maxuniforms = v; glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &v); Printf ("Max. vertex uniforms: %d\n", v); glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index d5346fa7d..74beb72a4 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -9,7 +9,6 @@ enum RenderFlags RFL_TEXTURE_COMPRESSION=1, RFL_TEXTURE_COMPRESSION_S3TC=2, - RFL_FRAMEBUFFER = 4, RFL_BUFFER_STORAGE = 8, RFL_SHADER_STORAGE_BUFFER = 16, RFL_BASEINDEX = 32, @@ -36,16 +35,6 @@ struct RenderContext { return maxuniforms>=2048? 128:64; } - - bool hasGLSL() const - { - return glslversion >= 1.3f; - } - - bool hasCompatibility() // will return false, once transition to a core profile is possible and a core profile is used. - { - return true; - } }; extern RenderContext gl; diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index 0518606b9..972b9421e 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -59,40 +59,4 @@ CUSTOM_CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // when they are actually valid. void gl_SetupMenu() { - if (!gl.hasGLSL()) - { - // Radial fog and Doom lighting are not available in SM < 4 cards - // The way they are implemented does not work well on older hardware. - - FOptionValues **opt = OptionValues.CheckKey("LightingModes"); - if (opt != NULL) - { - for(int i = (*opt)->mValues.Size()-1; i>=0; i--) - { - // Delete 'Doom' lighting mode - if ((*opt)->mValues[i].Value == 2.0 || (*opt)->mValues[i].Value == 8.0) - { - (*opt)->mValues.Delete(i); - } - } - } - - opt = OptionValues.CheckKey("FogMode"); - if (opt != NULL) - { - for(int i = (*opt)->mValues.Size()-1; i>=0; i--) - { - // Delete 'Radial' fog mode - if ((*opt)->mValues[i].Value == 2.0) - { - (*opt)->mValues.Delete(i); - } - } - } - - // disable features that don't work without shaders. - if (gl_lightmode == 2 || gl_lightmode == 8) gl_lightmode = 3; - if (gl_fogmode == 2) gl_fogmode = 1; - if (gl_dynlight_shader) gl_dynlight_shader = false; - } } diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 28cfa0e6d..18c4ebfdf 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -505,52 +505,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) glVertex2i(fb->Width, fb->Height); glEnd(); - gl_RenderState.SetTextureMode(TM_MODULATE); - gl_RenderState.Apply(true); - glActiveTexture(GL_TEXTURE1); - glEnable(GL_TEXTURE_2D); - - // mask out the alpha channel of the wipeendscreen. - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE1); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - - glActiveTexture(GL_TEXTURE0); - - // Burn the new screen on top of it. - fb->wipeendscreen->Bind(1); - //BurnTexture->Bind(0, CM_DEFAULT); - - BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, false, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - - glBegin(GL_TRIANGLE_STRIP); - glMultiTexCoord2f(GL_TEXTURE0, 0, 0); - glMultiTexCoord2f(GL_TEXTURE1, 0, vb); - glVertex2i(0, 0); - glMultiTexCoord2f(GL_TEXTURE0, 0, 1); - glMultiTexCoord2f(GL_TEXTURE1, 0, 0); - glVertex2i(0, fb->Height); - glMultiTexCoord2f(GL_TEXTURE0, 1, 0); - glMultiTexCoord2f(GL_TEXTURE1, ur, vb); - glVertex2i(fb->Width, 0); - glMultiTexCoord2f(GL_TEXTURE0, 1, 1); - glMultiTexCoord2f(GL_TEXTURE1, ur, 0); - glVertex2i(fb->Width, fb->Height); - glEnd(); - - glActiveTexture(GL_TEXTURE1); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glDisable(GL_TEXTURE_2D); - glActiveTexture(GL_TEXTURE0); + // the old burn warp code is obsolete and has to be replaced. // The fire may not always stabilize, so the wipe is forced to end // after an arbitrary maximum time. diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 837977145..59e84051e 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -224,10 +224,6 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u if ( inputTexture->bHasCanvas ) return inputBuffer; - // [BB] Don't upsample non-shader handled warped textures. Needs too much memory and time - if (inputTexture->bWarped && !gl.hasGLSL()) - return inputBuffer; - switch (inputTexture->UseType) { case FTexture::TEX_Sprite: diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index a2a83e5db..3330d1f0c 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -54,7 +54,6 @@ extern TexFilter_s TexFilter[]; extern int TexFormat[]; -EXTERN_CVAR(Bool, gl_clamp_per_texture) //=========================================================================== @@ -197,10 +196,6 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i { texformat = GL_R8; } - else if (gl.version <= 3.0f || gl.hasCompatibility()) - { - texformat = GL_ALPHA8; - } else { texformat = GL_RGBA8; @@ -251,16 +246,17 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i if (deletebuffer) free(buffer); - // When using separate samplers the stuff below is not needed. - // if (gl.flags & RFL_SAMPLER_OBJECTS) return; - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); if (alphatexture && gl.version >= 3.3f) { static const GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_RED}; glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); } + + // When using separate samplers the stuff below is not needed. + // if (gl.flags & RFL_SAMPLER_OBJECTS) return; + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); clampmode = wrapparam==GL_CLAMP? GLT_CLAMPX|GLT_CLAMPY : 0; if (forcenofiltering) @@ -439,19 +435,15 @@ void FHardwareTexture::UnbindAll() int FHardwareTexture::GetDepthBuffer() { - if (gl.flags & RFL_FRAMEBUFFER) + if (glDepthID == 0) { - if (glDepthID == 0) - { - glGenRenderbuffers(1, &glDepthID); - glBindRenderbuffer(GL_RENDERBUFFER, glDepthID); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, - GetTexDimension(texwidth), GetTexDimension(texheight)); - glBindRenderbuffer(GL_RENDERBUFFER, 0); - } - return glDepthID; + glGenRenderbuffers(1, &glDepthID); + glBindRenderbuffer(GL_RENDERBUFFER, glDepthID); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, + GetTexDimension(texwidth), GetTexDimension(texheight)); + glBindRenderbuffer(GL_RENDERBUFFER, 0); } - return 0; + return glDepthID; } @@ -463,11 +455,8 @@ int FHardwareTexture::GetDepthBuffer() void FHardwareTexture::BindToFrameBuffer() { - if (gl.flags & RFL_FRAMEBUFFER) - { - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glDefTexID, 0); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); - } + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glDefTexID, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); } diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index d949addc8..b6d83eb52 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -85,7 +85,6 @@ FGLTexture::FGLTexture(FTexture * tx, bool expandpatches) for(int i=0;i<5;i++) gltexture[i]=NULL; HiresLump=-1; hirestexture = NULL; - currentwarp = 0; bHasColorkey = false; bIsTransparent = -1; bExpand = expandpatches; @@ -186,84 +185,6 @@ void FGLTexture::Clean(bool all) } } -//=========================================================================== -// -// FGLTex::WarpBuffer -// -//=========================================================================== - -BYTE *FGLTexture::WarpBuffer(BYTE *buffer, int Width, int Height, int warp) -{ - if (Width > 256 || Height > 256) return buffer; - - DWORD *in = (DWORD*)buffer; - DWORD *out = (DWORD*)new BYTE[4*Width*Height]; - float Speed = static_cast(tex)->GetSpeed(); - - static_cast(tex)->GenTime = r_FrameTime; - - static DWORD linebuffer[256]; // anything larger will bring down performance so it is excluded above. - DWORD timebase = DWORD(r_FrameTime*Speed*23/28); - int xsize = Width; - int ysize = Height; - int xmask = xsize - 1; - int ymask = ysize - 1; - int ds_xbits; - int i,x; - - if (warp == 1) - { - for(ds_xbits=-1,i=Width; i; i>>=1, ds_xbits++); - - for (x = xsize-1; x >= 0; x--) - { - int yt, yf = (finesine[(timebase+(x+17)*128)&FINEMASK]>>13) & ymask; - const DWORD *source = in + x; - DWORD *dest = out + x; - for (yt = ysize; yt; yt--, yf = (yf+1)&ymask, dest += xsize) - { - *dest = *(source+(yf<= 0; y--) - { - int xt, xf = (finesine[(timebase+y*128)&FINEMASK]>>13) & xmask; - DWORD *source = out + (y<>=1, ybits++); - - DWORD timebase = (r_FrameTime * Speed * 40 / 28); - for (x = xsize-1; x >= 0; x--) - { - for (int y = ysize-1; y >= 0; y--) - { - int xt = (x + 128 - + ((finesine[(y*128 + timebase*5 + 900) & 8191]*2)>>FRACBITS) - + ((finesine[(x*256 + timebase*4 + 300) & 8191]*2)>>FRACBITS)) & xmask; - int yt = (y + 128 - + ((finesine[(y*128 + timebase*3 + 700) & 8191]*2)>>FRACBITS) - + ((finesine[(x*256 + timebase*4 + 1200) & 8191]*2)>>FRACBITS)) & ymask; - const DWORD *source = in + (xt << ybits) + yt; - DWORD *dest = out + (x << ybits) + y; - *dest = *source; - } - } - } - delete [] buffer; - return (BYTE*)out; -} //=========================================================================== // @@ -271,7 +192,7 @@ BYTE *FGLTexture::WarpBuffer(BYTE *buffer, int Width, int Height, int warp) // //=========================================================================== -unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, bool expand, FTexture *hirescheck, int warp, bool alphatexture) +unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, bool expand, FTexture *hirescheck, bool alphatexture) { unsigned char * buffer; int W, H; @@ -329,21 +250,9 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, b bIsTransparent = 0; } - if (warp != 0) - { - buffer = WarpBuffer(buffer, W, H, warp); - } // [BB] The hqnx upsampling (not the scaleN one) destroys partial transparency, don't upsamle textures using it. - // Also don't upsample warped textures. - else //if (bIsTransparent != 1) - { - // [BB] Potentially upsample the buffer. - buffer = gl_CreateUpsampledTextureBuffer ( tex, buffer, W, H, w, h, bIsTransparent || alphatexture); - } - currentwarp = warp; - currentwarptime = gl_frameMS; - - return buffer; + // [BB] Potentially upsample the buffer. + return gl_CreateUpsampledTextureBuffer ( tex, buffer, W, H, w, h, bIsTransparent || alphatexture); } @@ -387,7 +296,7 @@ bool FGLTexture::CreatePatch() // //=========================================================================== -const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int translation, FTexture *hirescheck, int warp) +const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int translation, FTexture *hirescheck) { int usebright = false; @@ -414,15 +323,8 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla if (hwtex) { - if ((warp != 0 || currentwarp != warp) && currentwarptime != gl_frameMS) - { - // must recreate the texture - Clean(true); - hwtex = CreateTexture(clampmode); - } - - // Texture has become invalid - this is only for special textures, not the regular warping, which is handled above - else if ((warp == 0 && !tex->bHasCanvas && !tex->bWarped) && tex->CheckModified()) + // Texture has become invalid + if ((!tex->bHasCanvas && !tex->bWarped) && tex->CheckModified()) { Clean(true); hwtex = CreateTexture(clampmode); @@ -439,7 +341,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla if (!tex->bHasCanvas) { - buffer = CreateTexBuffer(translation, w, h, false, hirescheck, warp); + buffer = CreateTexBuffer(translation, w, h, false, hirescheck); tex->ProcessData(buffer, w, h, false); } if (!hwtex->CreateTexture(buffer, w, h, true, texunit, translation)) @@ -464,7 +366,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla // Binds a sprite to the renderer // //=========================================================================== -const FHardwareTexture * FGLTexture::BindPatch(int texunit, int translation, int warp, bool alphatexture) +const FHardwareTexture * FGLTexture::BindPatch(int texunit, int translation, bool alphatexture) { bool usebright = false; int transparm = translation; @@ -474,15 +376,8 @@ const FHardwareTexture * FGLTexture::BindPatch(int texunit, int translation, int if (CreatePatch()) { - if (warp != 0 || currentwarp != warp) - { - // must recreate the texture - Clean(true); - CreatePatch(); - } - // Texture has become invalid - this is only for special textures, not the regular warping, which is handled above - else if ((warp == 0 && !tex->bHasCanvas && !tex->bWarped) && tex->CheckModified()) + if ((!tex->bHasCanvas && !tex->bWarped) && tex->CheckModified()) { Clean(true); CreatePatch(); @@ -495,7 +390,7 @@ const FHardwareTexture * FGLTexture::BindPatch(int texunit, int translation, int int w, h; // Create this texture - unsigned char * buffer = CreateTexBuffer(translation, w, h, bExpand, NULL, warp, alphatexture); + unsigned char * buffer = CreateTexBuffer(translation, w, h, bExpand, NULL, alphatexture); tex->ProcessData(buffer, w, h, true); if (!glpatch->CreateTexture(buffer, w, h, false, texunit, translation, alphatexture)) { @@ -625,7 +520,7 @@ FMaterial::FMaterial(FTexture * tx, bool forceexpand) { expanded = false; } - else if (gl.hasGLSL()) + else { if (tx->gl_info.shaderindex >= FIRST_USER_SHADER) { @@ -671,7 +566,7 @@ FMaterial::FMaterial(FTexture * tx, bool forceexpand) tex = tx; tx->gl_info.mExpanded = expanded; - FTexture *basetex = tx->GetRedirect(!gl.hasGLSL()); + FTexture *basetex = tx->GetRedirect(false); if (!expanded && !basetex->gl_info.mExpanded && basetex->UseType != FTexture::TEX_Sprite) { // check if the texture is just a simple redirect to a patch @@ -842,13 +737,13 @@ void FMaterial::Bind(int clampmode, int translation, int overrideshader) int maxbound = 0; bool allowhires = tex->xScale == FRACUNIT && tex->yScale == FRACUNIT; - int softwarewarp = gl_RenderState.SetupShader(shaderindex, tex->gl_info.shaderspeed); + gl_RenderState.SetupShader(shaderindex, tex->gl_info.shaderspeed); if (tex->bHasCanvas || tex->bWarped) clampmode = 0; else if (clampmode != -1) clampmode &= 3; else clampmode = 4; - const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, allowhires? tex:NULL, softwarewarp); + const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, allowhires? tex:NULL); if (gltexture != NULL && shaderindex > 0 && overrideshader == 0) { for(unsigned i=0;igl_info.SystemTexture->Bind(i+1, clampmode, 0, NULL, false); + layer->gl_info.SystemTexture->Bind(i+1, clampmode, 0, NULL); maxbound = i+1; } } @@ -889,13 +784,13 @@ void FMaterial::BindPatch(int translation, int overrideshader, bool alphatexture int shaderindex = overrideshader > 0? overrideshader : mShaderIndex; int maxbound = 0; - int softwarewarp = gl_RenderState.SetupShader(shaderindex, tex->gl_info.shaderspeed); + gl_RenderState.SetupShader(shaderindex, tex->gl_info.shaderspeed); - const FHardwareTexture *glpatch = mBaseLayer->BindPatch(0, translation, softwarewarp, alphatexture); + const FHardwareTexture *glpatch = mBaseLayer->BindPatch(0, translation, alphatexture); // The only multitexture effect usable on sprites is the brightmap. if (glpatch != NULL && shaderindex == 3) { - mTextureLayers[0].texture->gl_info.SystemTexture->BindPatch(1, 0, 0, false); + mTextureLayers[0].texture->gl_info.SystemTexture->BindPatch(1, 0, false); maxbound = 1; } // unbind everything from the last texture that's still active @@ -1013,7 +908,7 @@ void FMaterial::BindToFrameBuffer() if (mBaseLayer->gltexture[0] == NULL) { // must create the hardware texture first - mBaseLayer->Bind(0, 0, 0, NULL, 0); + mBaseLayer->Bind(0, 0, 0, NULL); FHardwareTexture::Unbind(0); } mBaseLayer->gltexture[0]->BindToFrameBuffer(); diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index e1a5e93cd..81f4dd10f 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -61,28 +61,24 @@ private: FHardwareTexture *gltexture[5]; FHardwareTexture *glpatch; - int currentwarp; - int currentwarptime; - bool bHasColorkey; // only for hires bool bExpand; float AlphaThreshold; unsigned char * LoadHiresTexture(FTexture *hirescheck, int *width, int *height, bool alphatexture); - BYTE *WarpBuffer(BYTE *buffer, int Width, int Height, int warp); FHardwareTexture *CreateTexture(int clampmode); //bool CreateTexture(); bool CreatePatch(); - const FHardwareTexture *Bind(int texunit, int clamp, int translation, FTexture *hirescheck, int warp); - const FHardwareTexture *BindPatch(int texunit, int translation, int warp, bool alphatexture); + const FHardwareTexture *Bind(int texunit, int clamp, int translation, FTexture *hirescheck); + const FHardwareTexture *BindPatch(int texunit, int translation, bool alphatexture); public: FGLTexture(FTexture * tx, bool expandpatches); ~FGLTexture(); - unsigned char * CreateTexBuffer(int translation, int & w, int & h, bool expand, FTexture *hirescheck, int warp, bool alphatexture = false); + unsigned char * CreateTexBuffer(int translation, int & w, int & h, bool expand, FTexture *hirescheck, bool alphatexture = false); void Clean(bool all); int Dump(int i); diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 53adb9551..a864c7e3e 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -94,7 +94,6 @@ CUSTOM_CVAR(Bool, gl_texture_usehires, true, CVAR_ARCHIVE|CVAR_NOINITCALL) } CVAR(Bool, gl_precache, false, CVAR_ARCHIVE) -CVAR(Bool, gl_clamp_per_texture, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, gl_trimsprites, true, CVAR_ARCHIVE); From 1f0c69a0e9d7ab988497e2cfaa0501cb20a33045 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 21 Jun 2014 16:41:45 +0200 Subject: [PATCH 0129/1509] - some cleanup after GL 2.x code removal - reinstated burn warp with shader based code. --- src/gl/system/gl_interface.cpp | 56 -------------------------------- src/gl/system/gl_wipe.cpp | 23 ++++++++++++- src/gl/textures/gl_hwtexture.cpp | 4 +-- 3 files changed, 23 insertions(+), 60 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index aaa9568f9..42224767b 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -179,59 +179,3 @@ void gl_PrintStartupLog() } -//========================================================================== -// -// -// -//========================================================================== - -void gl_SetTextureMode(int type) -{ - if (type == TM_MASK) - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); - } - else if (type == TM_OPAQUE) - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - } - else if (type == TM_INVERSE) - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); - } - else // if (type == TM_MODULATE) - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } -} - -//} // extern "C" diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 18c4ebfdf..e2fe134f6 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -53,6 +53,7 @@ #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderstate.h" #include "gl/system/gl_framebuffer.h" +#include "gl/shaders/gl_shader.h" #include "gl/textures/gl_translate.h" #include "gl/textures/gl_material.h" #include "gl/utility/gl_templates.h" @@ -505,7 +506,27 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) glVertex2i(fb->Width, fb->Height); glEnd(); - // the old burn warp code is obsolete and has to be replaced. + gl_RenderState.SetTextureMode(TM_MODULATE); + gl_RenderState.SetEffect(EFF_BURN); + gl_RenderState.ResetColor(); + gl_RenderState.Apply(); + + // Burn the new screen on top of it. + fb->wipeendscreen->Bind(1); + + BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, false, 0); + + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(0, vb); + glVertex2i(0, 0); + glTexCoord2f(0, 0); + glVertex2i(0, fb->Height); + glTexCoord2f(ur, vb); + glVertex2i(fb->Width, 0); + glTexCoord2f(ur, 0); + glVertex2i(fb->Width, fb->Height); + glEnd(); + gl_RenderState.SetEffect(EFF_NONE); // The fire may not always stabilize, so the wipe is forced to end // after an arbitrary maximum time. diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 3330d1f0c..9d81b54ce 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -218,7 +218,6 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i // The texture must at least be initialized if no data is present. mipmap=false; - glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, false); buffer=(unsigned char *)calloc(4,rw * (rh+1)); deletebuffer=true; //texheight=-h; @@ -228,8 +227,6 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i rw = GetTexDimension (w); rh = GetTexDimension (h); - glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, (mipmap && use_mipmapping && !forcenofiltering)); - if (rw < w || rh < h) { // The texture is larger than what the hardware can handle so scale it down. @@ -246,6 +243,7 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i if (deletebuffer) free(buffer); + if (mipmap && use_mipmapping && !forcenofiltering) glGenerateMipmap(GL_TEXTURE_2D); if (alphatexture && gl.version >= 3.3f) { static const GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_RED}; From e2e71e072e33a49e1a20277426120b5359323377 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 23 Jun 2014 09:26:29 +0200 Subject: [PATCH 0130/1509] removed error suppression code from shader compilation. With GL 2.x support the engine still had something to fall back on, with that removed it needs to abort. --- src/gl/shaders/gl_shader.cpp | 63 ++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index ca7f8be72..33381eb88 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -249,14 +249,14 @@ FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath shader = new FShader(ShaderName); if (!shader->Load(ShaderName, "shaders/glsl/main.vp", "shaders/glsl/main.fp", ShaderPath, str)) { - I_Error("Unable to load shader %s\n", ShaderName); + I_FatalError("Unable to load shader %s\n", ShaderName); } } catch(CRecoverableError &err) { if (shader != NULL) delete shader; shader = NULL; - I_Error("Unable to load shader %s:\n%s\n", ShaderName, err.GetMessage()); + I_FatalError("Unable to load shader %s:\n%s\n", ShaderName, err.GetMessage()); } return shader; } @@ -341,42 +341,32 @@ FShaderManager::~FShaderManager() void FShaderManager::CompileShaders() { - try + mActiveShader = mEffectShaders[0] = mEffectShaders[1] = NULL; + + for(int i=0;defaultshaders[i].ShaderName != NULL;i++) { - mActiveShader = mEffectShaders[0] = mEffectShaders[1] = NULL; - for (int i = 0; defaultshaders[i].ShaderName != NULL; i++) - { - FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc); - mTextureEffects.Push(shc); - } - - for (unsigned i = 0; i < usershaders.Size(); i++) - { - FString name = ExtractFileBase(usershaders[i]); - FName sfn = name; - - FShader *shc = Compile(sfn, usershaders[i]); - mTextureEffects.Push(shc); - } - - for (int i = 0; i < MAX_EFFECTS; i++) - { - FShader *eff = new FShader(effectshaders[i].ShaderName); - if (!eff->Load(effectshaders[i].ShaderName, effectshaders[i].vp, effectshaders[i].fp1, - effectshaders[i].fp2, effectshaders[i].defines)) - { - delete eff; - } - else mEffectShaders[i] = eff; - } + FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc); + mTextureEffects.Push(shc); } - catch (CRecoverableError &err) + + for(unsigned i = 0; i < usershaders.Size(); i++) { - // If shader compilation failed we can still run the fixed function mode so do that instead of aborting. - Printf("%s\n", err.GetMessage()); - Printf(PRINT_HIGH, "Failed to compile shaders. Reverting to fixed function mode\n"); - gl.glslversion = 0.0; - gl.flags &= ~RFL_BUFFER_STORAGE; + FString name = ExtractFileBase(usershaders[i]); + FName sfn = name; + + FShader *shc = Compile(sfn, usershaders[i]); + mTextureEffects.Push(shc); + } + + for(int i=0;iLoad(effectshaders[i].ShaderName, effectshaders[i].vp, effectshaders[i].fp1, + effectshaders[i].fp2, effectshaders[i].defines)) + { + delete eff; + } + else mEffectShaders[i] = eff; } } @@ -458,6 +448,9 @@ void FShaderManager::SetWarpSpeed(unsigned int eff, float speed) } } +//========================================================================== +// +// // //========================================================================== From ffcb6cb70a5940b45d483a506b5ce0d25b4a3bde Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 29 Jun 2014 11:00:21 +0200 Subject: [PATCH 0131/1509] - added second vertex coordinate attribute for model interpolation. --- src/gl/renderer/gl_renderstate.cpp | 9 ++++----- src/gl/renderer/gl_renderstate.h | 13 ++++++------- src/gl/shaders/gl_shader.cpp | 2 ++ src/gl/shaders/gl_shader.h | 7 +++++++ src/gl/system/gl_framebuffer.cpp | 5 +++++ wadsrc/static/shaders/glsl/main.vp | 4 +++- wadsrc/static/shaders/glsl/shaderdefs.i | 1 + 7 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 8ce695cbc..cf8604924 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -66,11 +66,8 @@ void FRenderState::Reset() { mTextureEnabled = true; mBrightmapEnabled = mFogEnabled = mGlowEnabled = mLightEnabled = false; - ffTextureEnabled = ffFogEnabled = false; - mSpecialEffect = ffSpecialEffect = EFF_NONE; - mFogColor.d = ffFogColor.d = -1; - ffFogDensity = 0; - mTextureMode = ffTextureMode = -1; + mFogColor.d = -1; + mTextureMode = -1; mDesaturation = 0; mSrcBlend = GL_SRC_ALPHA; mDstBlend = GL_ONE_MINUS_SRC_ALPHA; @@ -85,6 +82,7 @@ void FRenderState::Reset() mVertexBuffer = mCurrentVertexBuffer = NULL; mColormapState = CM_DEFAULT; mLightParms[3] = -1.f; + mSpecialEffect = EFF_NONE; } @@ -144,6 +142,7 @@ bool FRenderState::ApplyShader() activeShader->muFogColor.Set(mFogColor); activeShader->muObjectColor.Set(mObjectColor); activeShader->muDynLightColor.Set(mDynColor); + activeShader->muInterpolationFactor.Set(mInterpolationFactor); if (mGlowEnabled) { diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index c3ca1e273..1bfaf7135 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -56,6 +56,7 @@ class FRenderState bool mAlphaTest; int mBlendEquation; bool m2D; + float mInterpolationFactor; FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; FStateVec4 mColor; @@ -75,13 +76,6 @@ class FRenderState bool glAlphaTest; int glBlendEquation; - bool ffTextureEnabled; - bool ffFogEnabled; - int ffTextureMode; - int ffSpecialEffect; - PalEntry ffFogColor; - float ffFogDensity; - bool ApplyShader(); public: @@ -290,6 +284,11 @@ public: { m2D = on; } + + void SetInterpolationFactor(float fac) + { + mInterpolationFactor = fac; + } }; extern FRenderState gl_RenderState; diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 33381eb88..76049eb1f 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -192,10 +192,12 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muGlowBottomPlane.Init(hShader, "uGlowBottomPlane"); muGlowTopPlane.Init(hShader, "uGlowTopPlane"); muFixedColormap.Init(hShader, "uFixedColormap"); + muInterpolationFactor.Init(hShader, "uInterpolationFactor"); timer_index = glGetUniformLocation(hShader, "timer"); lights_index = glGetUniformLocation(hShader, "lights"); + glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2"); glUseProgram(hShader); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 3497ed3b0..173a1c781 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -7,6 +7,12 @@ extern bool gl_shaderactive; +enum +{ + VATTR_VERTEX2 = 15 +}; + + //========================================================================== // // @@ -186,6 +192,7 @@ class FShader FUniform4f muGlowTopColor; FUniform4f muGlowBottomPlane; FUniform4f muGlowTopPlane; + FBufferedUniform1f muInterpolationFactor; int timer_index; int lights_index; diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index d22c6a5ed..30f791d50 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -386,6 +386,11 @@ FNativePalette *OpenGLFrameBuffer::CreatePalette(FRemapTable *remap) //========================================================================== bool OpenGLFrameBuffer::Begin2D(bool) { + glActiveTexture(GL_TEXTURE7); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glActiveTexture(GL_TEXTURE0); + glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMatrixMode(GL_PROJECTION); diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 2cde5324b..5e7890a61 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -1,10 +1,12 @@ +in vec4 aVertex2; out vec4 pixelpos; out vec2 glowdist; + void main() { - vec4 worldcoord = ModelMatrix * gl_Vertex; + vec4 worldcoord = /* ModelMatrix * */ mix(gl_Vertex, aVertex2, uInterpolationFactor); vec4 eyeCoordPos = ViewMatrix * worldcoord; gl_FrontColor = gl_Color; diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index efedca5e5..5a36473bf 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -9,6 +9,7 @@ uniform vec4 uObjectColor; uniform vec4 uDynLightColor; uniform vec4 uFogColor; uniform float uDesaturationFactor; +uniform float uInterpolationFactor; // Fixed colormap stuff uniform int uFixedColormap; // 0, when no fixed colormap, 1 for a light value, 2 for a color blend, 3 for a fog layer From 9d1dbf4eab1ad27390f44e729b1e99d6bc522bd4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 29 Jun 2014 14:08:44 +0200 Subject: [PATCH 0132/1509] - fixed: FBufferedUniform1f didn'T work because it used an int as its buffered value. --- src/gl/shaders/gl_shader.h | 2 +- wadsrc/static/shaders/glsl/main.vp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 173a1c781..d1518088d 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -80,7 +80,7 @@ public: class FBufferedUniform1f { - int mBuffer; + float mBuffer; int mIndex; public: diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 5e7890a61..66ef3b51e 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -6,7 +6,7 @@ out vec2 glowdist; void main() { - vec4 worldcoord = /* ModelMatrix * */ mix(gl_Vertex, aVertex2, uInterpolationFactor); + vec4 worldcoord = mix(gl_Vertex, aVertex2, uInterpolationFactor); vec4 eyeCoordPos = ViewMatrix * worldcoord; gl_FrontColor = gl_Color; From 1efc2938b77925bb931b1063e6aa2814aaae6dce Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 29 Jun 2014 23:24:16 +0200 Subject: [PATCH 0133/1509] - implement model vertex buffer and draw MD2 models using it instead of using the GLCommands from the model. --- src/gl/data/gl_vertexbuffer.cpp | 2 + src/gl/data/gl_vertexbuffer.h | 3 +- src/gl/models/gl_models.cpp | 77 ++++++++++++++- src/gl/models/gl_models.h | 15 ++- src/gl/models/gl_models_md2.cpp | 154 ++++++----------------------- src/gl/models/gl_models_md3.cpp | 1 + src/gl/renderer/gl_renderer.cpp | 2 + src/gl/renderer/gl_renderer.h | 2 + src/gl/scene/gl_skydome.cpp | 1 + wadsrc/static/shaders/glsl/main.vp | 2 +- 10 files changed, 122 insertions(+), 137 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 6ba9f794e..3ea401dcd 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -45,6 +45,7 @@ #include "c_cvars.h" #include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" +#include "gl/shaders/gl_shader.h" #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" @@ -332,6 +333,7 @@ void FFlatVertexBuffer::BindVBO() glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); + glDisableVertexAttribArray(VATTR_VERTEX2); } } diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index ad09fb5d9..a183a7a2e 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -193,6 +193,7 @@ struct FModelVertex class FModelVertexBuffer : public FVertexBuffer { int mIndexFrame[2]; + unsigned int ibo_id; public: // these are public because it's the models having to fill them in. @@ -203,7 +204,7 @@ public: ~FModelVertexBuffer(); void BindVBO(); - void UpdateBufferPointers(int frame1, int frame2); + unsigned int SetupFrame(unsigned int frame1, unsigned int frame2, float factor); }; #define VMO ((FModelVertex*)NULL) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 0ee9c563f..f6aad15fa 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -59,6 +59,7 @@ #include "gl/utility/gl_geometric.h" #include "gl/utility/gl_convert.h" #include "gl/renderer/gl_renderstate.h" +#include "gl/shaders/gl_shader.h" static inline float GetTimeFloat() { @@ -91,6 +92,76 @@ public: DeletingModelArray Models; + +//=========================================================================== +// +// +// +//=========================================================================== + +FModelVertexBuffer::FModelVertexBuffer() +{ + ibo_id = 0; + glGenBuffers(1, &ibo_id); + //for (unsigned i = 1; i < Models.Size(); i++) + for (int i = Models.Size() - 1; i >= 0; i--) + { + Models[i]->BuildVertexBuffer(this); + } + + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferData(GL_ARRAY_BUFFER,vbo_shadowdata.Size() * sizeof(FModelVertex), &vbo_shadowdata[0], GL_STATIC_DRAW); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); + glBufferData(GL_ELEMENT_ARRAY_BUFFER,ibo_shadowdata.Size() * sizeof(unsigned int), &ibo_shadowdata[0], GL_STATIC_DRAW); + +} + +FModelVertexBuffer::~FModelVertexBuffer() +{ + if (ibo_id != 0) + { + glDeleteBuffers(1, &ibo_id); + } +} + + +//=========================================================================== +// +// +// +//=========================================================================== + +void FModelVertexBuffer::BindVBO() +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); + //glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &VMO->x); + //glTexCoordPointer(2, GL_FLOAT, sizeof(FModelVertex), &VMO->u); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + glEnableVertexAttribArray(VATTR_VERTEX2); +} + +//=========================================================================== +// +// Sets up the buffer starts for frame interpolation +// This must be called after gl_RenderState.Apply! +// +//=========================================================================== + +unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int frame2, float factor) +{ + glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].u); + glVertexAttribPointer(VATTR_VERTEX2, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame2].x); + return frame1; +} + + + + + static TArray SpriteModelFrames; static int * SpriteModelHash; //TArray StateModelFrames; @@ -674,10 +745,14 @@ void gl_RenderFrameModels( const FSpriteModelFrame *smf, if (mdl!=NULL) { + gl_RenderState.SetVertexBuffer(GLRenderer->mModelVBO); + if ( smfNext && smf->modelframes[i] != smfNext->modelframes[i] ) mdl->RenderFrame(smf->skins[i], smf->modelframes[i], smfNext->modelframes[i], inter, translation); else - mdl->RenderFrame(smf->skins[i], smf->modelframes[i], NULL, 0.f, translation); + mdl->RenderFrame(smf->skins[i], smf->modelframes[i], smf->modelframes[i], 0.f, translation); + + gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); } } } diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index f9f8f4f22..00df383ba 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -107,7 +107,6 @@ protected: struct DMDLoD { FTriangle * triangles; - int * glCommands; }; @@ -116,27 +115,24 @@ protected: DMDInfo info; FTexture ** skins; FTexCoord * texCoords; - - unsigned int ib_index; - unsigned int ib_count; ModelFrame * frames; DMDLoDInfo lodInfo[MAX_LODS]; DMDLoD lods[MAX_LODS]; - char *vertexUsage; // Bitfield for each vertex. bool allowTexComp; // Allow texture compression with this. - static void RenderGLCommands(void *glCommands, unsigned int numVertices,DMDModelVertex * vertices, DMDModelVertex *vertices2, double inter); - public: FDMDModel() { loaded = false; frames = NULL; skins = NULL; - lods[0].glCommands = NULL; + for (int i = 0; i < MAX_LODS; i++) + { + lods[i].triangles = NULL; + } info.numLODs = 0; - ib_count = 0; + texCoords = NULL; } virtual ~FDMDModel(); @@ -195,6 +191,7 @@ class FMD3Model : public FModel unsigned int vindex; // contains numframes arrays of vertices unsigned int iindex; + unsigned int icount; MD3Surface() { diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index ccf604dca..df6d8f88e 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -43,11 +43,13 @@ #include "sc_man.h" #include "m_crc32.h" +#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderstate.h" #include "gl/scene/gl_drawinfo.h" #include "gl/models/gl_models.h" #include "gl/textures/gl_material.h" #include "gl/shaders/gl_shader.h" +#include "gl/data/gl_vertexbuffer.h" static float avertexnormals[NUMVERTEXNORMALS][3] = { #include "tab_anorms.h" @@ -160,10 +162,11 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length) skins[i] = LoadSkin(path, buffer + info.offsetSkins + i*64); } + texCoords = new FTexCoord[info.numTexCoords]; + memcpy(texCoords, (byte*)buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord)); temp = (char*)buffer + info.offsetFrames; frames = new ModelFrame[info.numFrames]; - ib_count = 0; for(i = 0, frame = frames; i < info.numFrames; i++, frame++) { @@ -193,25 +196,11 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length) for(i = 0; i < info.numLODs; i++) { lodInfo[i].numTriangles = LittleLong(lodInfo[i].numTriangles); - lodInfo[i].numGlCommands = LittleLong(lodInfo[i].numGlCommands); lodInfo[i].offsetTriangles = LittleLong(lodInfo[i].offsetTriangles); - lodInfo[i].offsetGlCommands = LittleLong(lodInfo[i].offsetGlCommands); - triangles[i] = (FTriangle*)(buffer + lodInfo[i].offsetTriangles); - - lods[i].glCommands = new int[lodInfo[i].numGlCommands]; - memcpy(lods[i].glCommands, buffer + lodInfo[i].offsetGlCommands, sizeof(int) * lodInfo[i].numGlCommands); + lods[i].triangles = triangles[i] = (FTriangle*)(buffer + lodInfo[i].offsetTriangles); } - // Determine vertex usage at each LOD level. - vertexUsage = new char[info.numVertices]; - memset(vertexUsage, 0, info.numVertices); - - for(i = 0; i < info.numLODs; i++) - for(k = 0; k < lodInfo[i].numTriangles; k++) - for(c = 0; c < 3; c++) - vertexUsage[short(triangles[i][k].vertexIndices[c])] |= 1 << i; - loaded=true; return true; } @@ -240,10 +229,10 @@ FDMDModel::~FDMDModel() for(i = 0; i < info.numLODs; i++) { - delete [] lods[i].glCommands; + if (lods[i].triangles != NULL) delete[] lods[i].triangles; } - if (vertexUsage != NULL) delete [] vertexUsage; + if (texCoords != NULL) delete[] texCoords; } @@ -254,83 +243,33 @@ void FDMDModel::BuildVertexBuffer(FModelVertexBuffer *buf) ModelFrame *frame = &frames[i]; DMDModelVertex *vert = frame->vertices; DMDModelVertex *norm = frame->normals; - void *glCommands = lods[0].glCommands; frame->vindex = buf->vbo_shadowdata.Size(); - for (char *pos = (char*)glCommands; *pos;) + + FTriangle *tri = lods[0].triangles; + + for (int i = 0; i < lodInfo[0].numTriangles; i++) { - int count = *(int *)pos; - pos += 4; - - // The type of primitive depends on the sign. - int primtype = count > 0 ? GL_TRIANGLE_STRIP : GL_TRIANGLE_FAN; - count = abs(count); - - if (i == 0) - { - // build the index buffer - we'll use the same buffer for all frames so only create it once - unsigned int bufindex = buf->vbo_shadowdata.Size() - frame->vindex; - unsigned int bufp = bufindex; - - if (primtype == GL_TRIANGLE_STRIP) - { - for (int t = 0; t < count - 2; t++) - { - unsigned int *p = &buf->ibo_shadowdata[buf->ibo_shadowdata.Reserve(3)]; - if ((t & 1) == 0) - { - p[0] = bufp; - p[1] = bufp + 1; - p[2] = bufp + 2; - } - else - { - p[0] = bufp; - p[2] = bufp + 2; - p[1] = bufp + 1; - } - bufp++; - } - } - else - { - bufp++; - for (int t = 0; t < count - 2; t++) - { - unsigned int *p = &buf->ibo_shadowdata[buf->ibo_shadowdata.Reserve(3)]; - p[0] = bufindex; - p[1] = bufp; - p[2] = bufp + 1; - bufp++; - } - } - } - - while (count--) + for (int j = 0; j < 3; j++) { FModelVertex bvert; - FGLCommandVertex * v = (FGLCommandVertex *)pos; - pos += sizeof(FGLCommandVertex); + int ti = tri->textureIndices[j]; + int vi = tri->vertexIndices[j]; - bvert.Set(vert[v->index].xyz[0], vert[v->index].xyz[1], vert[v->index].xyz[2], v->s, v->t); - bvert.SetNormal(norm[v->index].xyz[0], norm[v->index].xyz[1], norm[v->index].xyz[2]); + bvert.Set(vert[vi].xyz[0], vert[vi].xyz[1], vert[vi].xyz[2], (float)texCoords[ti].s /info.skinWidth, (float)texCoords[ti].t/info.skinHeight); + bvert.SetNormal(norm[vi].xyz[0], norm[vi].xyz[1], norm[vi].xyz[2]); buf->vbo_shadowdata.Push(bvert); } + tri++; } + } } - - - - - - - //=========================================================================== // // FDMDModel::FindFrame @@ -347,50 +286,10 @@ int FDMDModel::FindFrame(const char * name) //=========================================================================== // -// Render a set of GL commands using the given data. +// // //=========================================================================== -void FDMDModel::RenderGLCommands(void *glCommands, unsigned int numVertices, DMDModelVertex * vertices, DMDModelVertex *vertices2, double inter) -{ - char *pos; - FGLCommandVertex * v; - int count; - const bool interpolate = (vertices2 != NULL && inter != 0. && vertices != vertices2); - - gl_RenderState.Apply(); - for(pos = (char*)glCommands; *pos;) - { - count = *(int *) pos; - pos += 4; - - // The type of primitive depends on the sign. - glBegin(count > 0 ? GL_TRIANGLE_STRIP : GL_TRIANGLE_FAN); - - count = abs(count); - - while (count--) - { - v = (FGLCommandVertex *)pos; - pos += sizeof(FGLCommandVertex); - - glTexCoord2fv(&v->s); - if (!interpolate) - { - glVertex3fv(vertices[v->index].xyz); - } - else - { - float interp[3]; - for (int i = 0; i < 3; i++) - interp[i] = inter * vertices[v->index].xyz[i] + (1. - inter) * vertices2[v->index].xyz[i]; - glVertex3fv(interp); - } - } - glEnd(); - } -} - void FDMDModel::RenderFrame(FTexture * skin, int frameno, int frameno2, double inter, int translation) { if (frameno >= info.numFrames || frameno2 >= info.numFrames) return; @@ -406,7 +305,9 @@ void FDMDModel::RenderFrame(FTexture * skin, int frameno, int frameno2, double i tex->Bind(0, translation); - RenderGLCommands(lods[0].glCommands, info.numVertices, frames[frameno].vertices, frames[frameno2].vertices, inter); + gl_RenderState.Apply(); + GLRenderer->mModelVBO->SetupFrame(frames[frameno].vindex, frames[frameno2].vindex, inter); + glDrawArrays(GL_TRIANGLES, 0, lodInfo[0].numTriangles * 3); } @@ -464,7 +365,6 @@ bool FMD2Model::Load(const char * path, int, const char * buffer, int length) header.magic = MD2_MAGIC; header.version = 8; header.flags = 0; - vertexUsage = NULL; info.skinWidth = LittleLong(md2header->skinWidth); info.skinHeight = LittleLong(md2header->skinHeight); info.frameSize = LittleLong(md2header->frameSize); @@ -496,9 +396,12 @@ bool FMD2Model::Load(const char * path, int, const char * buffer, int length) // The frames need to be unpacked. md2_frames = (byte*)buffer + info.offsetFrames; - frames = new ModelFrame[info.numFrames]; + texCoords = new FTexCoord[info.numTexCoords]; + memcpy(texCoords, (byte*)buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord)); + + for(i = 0, frame = frames; i < info.numFrames; i++, frame++) { md2_packedFrame_t *pfr = (md2_packedFrame_t *) (md2_frames + info.frameSize * i); @@ -526,8 +429,9 @@ bool FMD2Model::Load(const char * path, int, const char * buffer, int length) } - lods[0].glCommands = new int[lodInfo[0].numGlCommands]; - memcpy(lods[0].glCommands, buffer + lodInfo[0].offsetGlCommands, sizeof(int) * lodInfo[0].numGlCommands); + lods[0].triangles = new FTriangle[lodInfo[0].numTriangles]; + + memcpy(lods[0].triangles, buffer + lodInfo[0].offsetTriangles, sizeof(FTriangle) * lodInfo[0].numTriangles); skins = new FTexture *[info.numSkins]; diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index 2c6f39d05..4ae403fb4 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -233,6 +233,7 @@ void FMD3Model::BuildVertexBuffer(FModelVertexBuffer *buf) buf->ibo_shadowdata.Push(surf->tris[k].VertIndex[l]); } } + surf->icount = buf->ibo_shadowdata.Size() - surf->iindex; } } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 97cf6d10f..b2b3edd8e 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -109,6 +109,7 @@ void FGLRenderer::Initialize() mVBO = new FFlatVertexBuffer; mSkyVBO = new FSkyVertexBuffer; + mModelVBO = new FModelVertexBuffer; gl_RenderState.SetVertexBuffer(mVBO); mFBID = 0; SetupLevel(); @@ -123,6 +124,7 @@ FGLRenderer::~FGLRenderer() //if (mThreadManager != NULL) delete mThreadManager; if (mShaderManager != NULL) delete mShaderManager; if (mVBO != NULL) delete mVBO; + if (mModelVBO) delete mModelVBO; if (mSkyVBO != NULL) delete mSkyVBO; if (glpart2) delete glpart2; if (glpart) delete glpart; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 77a38e7ae..733123599 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -10,6 +10,7 @@ struct particle_t; class FCanvasTexture; class FFlatVertexBuffer; class FSkyVertexBuffer; +class FModelVertexBuffer; class OpenGLFrameBuffer; struct FDrawInfo; struct pspdef_t; @@ -71,6 +72,7 @@ public: FFlatVertexBuffer *mVBO; FSkyVertexBuffer *mSkyVBO; + FModelVertexBuffer *mModelVBO; FGLRenderer(OpenGLFrameBuffer *fb); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index ad3b1c90b..0d9026ea6 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -93,6 +93,7 @@ void FSkyVertexBuffer::BindVBO() glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_COLOR_ARRAY); + glDisableVertexAttribArray(VATTR_VERTEX2); } diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 66ef3b51e..3ec5990b2 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -6,7 +6,7 @@ out vec2 glowdist; void main() { - vec4 worldcoord = mix(gl_Vertex, aVertex2, uInterpolationFactor); + vec4 worldcoord = ModelMatrix * mix(gl_Vertex, aVertex2, uInterpolationFactor); vec4 eyeCoordPos = ViewMatrix * worldcoord; gl_FrontColor = gl_Color; From 9c5cec0056ca64544293657acb05ce60b7289f74 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 30 Jun 2014 10:05:15 +0200 Subject: [PATCH 0134/1509] - draw wipes with buffers Only two things left that still use immediate mode directly: MD3 models and voxels. --- src/gl/system/gl_wipe.cpp | 114 ++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 61 deletions(-) diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index e2fe134f6..e4627fd35 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -57,6 +57,7 @@ #include "gl/textures/gl_translate.h" #include "gl/textures/gl_material.h" #include "gl/utility/gl_templates.h" +#include "gl/data/gl_vertexbuffer.h" #ifndef _WIN32 struct POINT { @@ -283,30 +284,24 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.ResetColor(); gl_RenderState.Apply(); fb->wipestartscreen->Bind(0); - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(0, vb); - glVertex2i(0, 0); - glTexCoord2f(0, 0); - glVertex2i(0, fb->Height); - glTexCoord2f(ur, vb); - glVertex2i(fb->Width, 0); - glTexCoord2f(ur, 0); - glVertex2i(fb->Width, fb->Height); - glEnd(); + + FFlatVertex *ptr; + unsigned int offset, count; + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(0, 0, 0, 0, vb); + ptr++; + ptr->Set(0, fb->Height, 0, 0, 0); + ptr++; + ptr->Set(fb->Width, 0, 0, ur, vb); + ptr++; + ptr->Set(fb->Width, fb->Height, 0, ur, 0); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); fb->wipeendscreen->Bind(0); gl_RenderState.SetColorAlpha(0xffffff, clamp(Clock/32.f, 0.f, 1.f)); gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(0, vb); - glVertex2i(0, 0); - glTexCoord2f(0, 0); - glVertex2i(0, fb->Height); - glTexCoord2f(ur, vb); - glVertex2i(fb->Width, 0); - glTexCoord2f(ur, 0); - glVertex2i(fb->Width, fb->Height); - glEnd(); + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); gl_RenderState.EnableAlphaTest(true); gl_RenderState.SetTextureMode(TM_MODULATE); @@ -351,16 +346,17 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.ResetColor(); gl_RenderState.Apply(); fb->wipeendscreen->Bind(0); - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(0, vb); - glVertex2i(0, 0); - glTexCoord2f(0, 0); - glVertex2i(0, fb->Height); - glTexCoord2f(ur, vb); - glVertex2i(fb->Width, 0); - glTexCoord2f(ur, 0); - glVertex2i(fb->Width, fb->Height); - glEnd(); + FFlatVertex *ptr; + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(0, 0, 0, 0, vb); + ptr++; + ptr->Set(0, fb->Height, 0, 0, 0); + ptr++; + ptr->Set(fb->Width, 0, 0, ur, vb); + ptr++; + ptr->Set(fb->Width, fb->Height, 0, ur, 0); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); int i, dy; bool done = false; @@ -384,7 +380,9 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) done = false; } if (ticks == 0) - { // Only draw for the final tick. + { + // Only draw for the final tick. + // No need for optimization. Wipes won't ever be drawn with anything else. RECT rect; POINT dpt; @@ -400,16 +398,17 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) float th = (float)FHardwareTexture::GetTexDimension(fb->Height); rect.bottom = fb->Height - rect.bottom; rect.top = fb->Height - rect.top; - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(rect.left / tw, rect.top / th); - glVertex2i(rect.left, rect.bottom); - glTexCoord2f(rect.left / tw, rect.bottom / th); - glVertex2i(rect.left, rect.top); - glTexCoord2f(rect.right / tw, rect.top / th); - glVertex2i(rect.right, rect.bottom); - glTexCoord2f(rect.right / tw, rect.bottom / th); - glVertex2i(rect.right, rect.top); - glEnd(); + + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(rect.left, rect.bottom, 0, rect.left / tw, rect.top / th); + ptr++; + ptr->Set(rect.left, rect.top, 0, rect.left / tw, rect.bottom / th); + ptr++; + ptr->Set(rect.right, rect.bottom, 0, rect.right / tw, rect.top / th); + ptr++; + ptr->Set(rect.right, rect.top, 0, rect.right / tw, rect.bottom / th); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } } } @@ -495,16 +494,18 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.ResetColor(); gl_RenderState.Apply(); fb->wipestartscreen->Bind(0); - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(0, vb); - glVertex2i(0, 0); - glTexCoord2f(0, 0); - glVertex2i(0, fb->Height); - glTexCoord2f(ur, vb); - glVertex2i(fb->Width, 0); - glTexCoord2f(ur, 0); - glVertex2i(fb->Width, fb->Height); - glEnd(); + FFlatVertex *ptr; + unsigned int offset, count; + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(0, 0, 0, 0, vb); + ptr++; + ptr->Set(0, fb->Height, 0, 0, 0); + ptr++; + ptr->Set(fb->Width, 0, 0, ur, vb); + ptr++; + ptr->Set(fb->Width, fb->Height, 0, ur, 0); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.SetEffect(EFF_BURN); @@ -516,16 +517,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, false, 0); - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(0, vb); - glVertex2i(0, 0); - glTexCoord2f(0, 0); - glVertex2i(0, fb->Height); - glTexCoord2f(ur, vb); - glVertex2i(fb->Width, 0); - glTexCoord2f(ur, 0); - glVertex2i(fb->Width, fb->Height); - glEnd(); + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); gl_RenderState.SetEffect(EFF_NONE); // The fire may not always stabilize, so the wipe is forced to end From 54297acde4a3bd826e27656387657dab0ce9cfc3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 30 Jun 2014 13:30:10 +0200 Subject: [PATCH 0135/1509] - removed obsolete gl_lightbuffer code. This never worked properly and by now far better options are available to solve the problem of dynamic light data uploads. --- src/CMakeLists.txt | 1 - src/gl/dynlights/gl_lightbuffer.cpp | 243 ---------------------------- src/gl/dynlights/gl_lightbuffer.h | 66 -------- src/gl/renderer/gl_renderer.cpp | 1 - src/gl/scene/gl_drawinfo.cpp | 1 - src/gl/scene/gl_flats.cpp | 1 - src/gl/scene/gl_scene.cpp | 1 - src/gl/scene/gl_walls.cpp | 1 - 8 files changed, 315 deletions(-) delete mode 100644 src/gl/dynlights/gl_lightbuffer.cpp delete mode 100644 src/gl/dynlights/gl_lightbuffer.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bf750ce80..fad134fc3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1086,7 +1086,6 @@ add_executable( zdoom WIN32 gl/dynlights/gl_dynlight.cpp gl/dynlights/gl_glow.cpp gl/dynlights/gl_dynlight1.cpp - gl/dynlights/gl_lightbuffer.cpp gl/shaders/gl_shader.cpp gl/shaders/gl_texshader.cpp gl/system/gl_interface.cpp diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp deleted file mode 100644 index 9f141e6af..000000000 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/* -** gl_dynlight1.cpp -** dynamic light buffer for shader rendering -** -**--------------------------------------------------------------------------- -** Copyright 2009 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ - -#if 0 // unused for now. Code doesn't work - -#include "gl/system/gl_system.h" -#include "c_dispatch.h" -#include "p_local.h" -#include "vectors.h" -#include "g_level.h" - -#include "gl/system/gl_cvars.h" -#include "gl/renderer/gl_renderer.h" -#include "gl/renderer/gl_lightdata.h" -#include "gl/data/gl_data.h" -#include "gl/dynlights/gl_dynlight.h" -#include "gl/dynlights/gl_lightbuffer.h" -#include "gl/scene/gl_drawinfo.h" -#include "gl/scene/gl_portal.h" -#include "gl/shaders/gl_shader.h" -#include "gl/textures/gl_material.h" - - -//========================================================================== -// -// -// -//========================================================================== - -FLightBuffer::FLightBuffer() -{ - glGenBuffers(1, &mIDbuf_RGB); - glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB); - - glGenBuffers(1, &mIDbuf_Position); - glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); - - glGenTextures(1, &mIDtex_RGB); - glBindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB); - gl.TexBufferARB(GL_TEXTURE_BUFFER, GL_RGBA8, mIDbuf_RGB); - - glGenTextures(1, &mIDtex_Position); - glBindTexture(GL_TEXTURE_BUFFER, mIDtex_Position); - gl.TexBufferARB(GL_TEXTURE_BUFFER, GL_RGBA32F, mIDbuf_Position); -} - - -//========================================================================== -// -// -// -//========================================================================== - -FLightBuffer::~FLightBuffer() -{ - glBindBuffer(GL_TEXTURE_BUFFER, 0); - glDeleteBuffers(1, &mIDbuf_RGB); - glDeleteBuffers(1, &mIDbuf_Position); - - glBindTexture(GL_TEXTURE_BUFFER, 0); - glDeleteTextures(1, &mIDtex_RGB); - glDeleteTextures(1, &mIDtex_Position); - -} - -//========================================================================== -// -// -// -//========================================================================== - -void FLightBuffer::BindTextures(int texunit1, int texunit2) -{ - glActiveTexture(texunit1); - glBindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB); - glActiveTexture(texunit2); - glBindTexture(GL_TEXTURE_BUFFER, mIDtex_Position); - glActiveTexture(GL_TEXTURE0); -} - - -//========================================================================== -// -// This collects all currently actove -// -//========================================================================== - -void FLightBuffer::CollectLightSources() -{ - if (gl_dynlight_shader && gl_lights && GLRenderer->mLightCount && gl_fixedcolormap == CM_DEFAULT) - { - TArray pLights(100); - TArray pPos(100); - TThinkerIterator it(STAT_DLIGHT); - - ADynamicLight *light; - - while ((light = it.Next()) != NULL) - { - if (!(light->flags2 & MF2_DORMANT)) - { - FLightRGB rgb; - FLightPosition pos; - - rgb.R = light->GetRed(); - rgb.G = light->GetGreen(); - rgb.B = light->GetBlue(); - rgb.Type = (light->flags4 & MF4_SUBTRACTIVE)? 128 : (light->flags4 & MF4_ADDITIVE || foggy)? 255:0; - pos.X = FIXED2FLOAT(light->x); - pos.Y = FIXED2FLOAT(light->y); - pos.Z = FIXED2FLOAT(light->z); - pos.Distance = (light->GetRadius() * gl_lights_size); - light->bufferindex = pPos.Size(); - pLights.Push(rgb); - pPos.Push(pos); - } - else light->bufferindex = -1; - } - GLRenderer->mLightCount = pPos.Size(); - - glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB); - glBufferData(GL_TEXTURE_BUFFER, pLights.Size() * sizeof (FLightRGB), &pLights[0], GL_STREAM_DRAW); - - glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); - glBufferData(GL_TEXTURE_BUFFER, pPos.Size() * sizeof (FLightPosition), &pPos[0], GL_STREAM_DRAW); - - } -} - - -//========================================================================== -// -// -// -//========================================================================== - -FLightIndexBuffer::FLightIndexBuffer() -{ - glGenBuffers(1, &mIDBuffer); - glBindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); - - glGenTextures(1, &mIDTexture); - glBindTexture(GL_TEXTURE_BUFFER, mIDTexture); - gl.TexBufferARB(GL_TEXTURE_BUFFER, GL_R16UI, mIDBuffer); -} - -//========================================================================== -// -// -// -//========================================================================== - -FLightIndexBuffer::~FLightIndexBuffer() -{ - glBindBuffer(GL_TEXTURE_BUFFER, 0); - glDeleteBuffers(1, &mIDBuffer); - - glBindTexture(GL_TEXTURE_BUFFER, 0); - glDeleteTextures(1, &mIDTexture); -} - - -//========================================================================== -// -// -// -//========================================================================== - -void FLightIndexBuffer::AddLight(ADynamicLight *light) -{ - if (light->bufferindex >= 0) - { - mBuffer.Push(light->bufferindex); - } -} - -//========================================================================== -// -// -// -//========================================================================== - -void FLightIndexBuffer::SendBuffer() -{ - glBindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); - glBufferData(GL_TEXTURE_BUFFER, mBuffer.Size() * sizeof (short), &mBuffer[0], GL_STREAM_DRAW); - glBindBuffer(GL_TEXTURE_BUFFER, 0); -} - - -//========================================================================== -// -// -// -//========================================================================== - -void FLightIndexBuffer::BindTexture(int texunit1) -{ - glActiveTexture(texunit1); - glBindTexture(GL_TEXTURE_BUFFER, mIDTexture); - glActiveTexture(GL_TEXTURE0); -} - - - -#endif \ No newline at end of file diff --git a/src/gl/dynlights/gl_lightbuffer.h b/src/gl/dynlights/gl_lightbuffer.h deleted file mode 100644 index d0da46b98..000000000 --- a/src/gl/dynlights/gl_lightbuffer.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef __GL_LIGHTBUFFER_H -#define __GL_LIGHTBUFFER_H - -#if 0 -class ADynamicLight; - -const int MAX_DYNLIGHTS = 40000; // should hopefully be enough - -struct FLightRGB -{ - unsigned char R,G,B,Type; // Type is 0 for normal, 1 for additive and 2 for subtractive -}; - -struct FLightPosition -{ - float X,Z,Y,Distance; -}; - -class FLightBuffer -{ - unsigned int mIDbuf_RGB; - unsigned int mIDbuf_Position; - - unsigned int mIDtex_RGB; - unsigned int mIDtex_Position; - -public: - FLightBuffer(); - ~FLightBuffer(); - //void MapBuffer(); - //void UnmapBuffer(); - void BindTextures(int uniloc1, int uniloc2); - //void AddLight(ADynamicLight *light, bool foggy); - void CollectLightSources(); -}; - -class FLightIndexBuffer -{ - unsigned int mIDBuffer; - unsigned int mIDTexture; - - TArray mBuffer; - -public: - - FLightIndexBuffer(); - ~FLightIndexBuffer(); - void AddLight(ADynamicLight *light); - void SendBuffer(); - void BindTexture(int loc1); - - void ClearBuffer() - { - mBuffer.Clear(); - } - - int GetLightIndex() - { - return mBuffer.Size(); - } - -}; - -#endif - -#endif \ No newline at end of file diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index b2b3edd8e..ece007c19 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -59,7 +59,6 @@ #include "gl/renderer/gl_renderstate.h" #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" -#include "gl/dynlights/gl_lightbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/shaders/gl_shader.h" #include "gl/textures/gl_texture.h" diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 8c620d93e..7dcf6319e 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -50,7 +50,6 @@ #include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" -#include "gl/dynlights/gl_lightbuffer.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" #include "gl/textures/gl_material.h" diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 7e327ab9c..9f0195307 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -56,7 +56,6 @@ #include "gl/data/gl_vertexbuffer.h" #include "gl/dynlights/gl_dynlight.h" #include "gl/dynlights/gl_glow.h" -#include "gl/dynlights/gl_lightbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/shaders/gl_shader.h" #include "gl/textures/gl_material.h" diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 4868d07bd..d013d7b30 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -65,7 +65,6 @@ #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/dynlights/gl_dynlight.h" -#include "gl/dynlights/gl_lightbuffer.h" #include "gl/models/gl_models.h" #include "gl/scene/gl_clipper.h" #include "gl/scene/gl_drawinfo.h" diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index bf9d52066..f720f1678 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -53,7 +53,6 @@ #include "gl/data/gl_data.h" #include "gl/dynlights/gl_dynlight.h" #include "gl/dynlights/gl_glow.h" -#include "gl/dynlights/gl_lightbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" #include "gl/textures/gl_material.h" From 6efefd9b7f4098c878a04637dedd7bbd93413d58 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 30 Jun 2014 18:02:52 +0200 Subject: [PATCH 0136/1509] - use vertex buffer to render MD3 models. --- src/gl/models/gl_models.h | 3 --- src/gl/models/gl_models_md3.cpp | 39 ++++----------------------------- 2 files changed, 4 insertions(+), 38 deletions(-) diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 00df383ba..d608f9874 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -191,7 +191,6 @@ class FMD3Model : public FModel unsigned int vindex; // contains numframes arrays of vertices unsigned int iindex; - unsigned int icount; MD3Surface() { @@ -225,8 +224,6 @@ class FMD3Model : public FModel MD3Frame * frames; MD3Surface * surfaces; - void RenderTriangles(MD3Surface * surf, MD3Vertex * vert, MD3Vertex *vert2, double inter); - public: FMD3Model() { } virtual ~FMD3Model(); diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index 4ae403fb4..cb9bb6c25 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -42,6 +42,7 @@ #include "m_crc32.h" #include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_renderer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/models/gl_models.h" #include "gl/textures/gl_material.h" @@ -233,7 +234,6 @@ void FMD3Model::BuildVertexBuffer(FModelVertexBuffer *buf) buf->ibo_shadowdata.Push(surf->tris[k].VertIndex[l]); } } - surf->icount = buf->ibo_shadowdata.Size() - surf->iindex; } } @@ -247,36 +247,6 @@ int FMD3Model::FindFrame(const char * name) return -1; } -void FMD3Model::RenderTriangles(MD3Surface * surf, MD3Vertex * vert, MD3Vertex *vert2, double inter) -{ - const bool interpolate = (vert2 != NULL && inter != 0. && vert != vert2); - - gl_RenderState.Apply(); - glBegin(GL_TRIANGLES); - for(int i=0; inumTriangles;i++) - { - for(int j=0;j<3;j++) - { - int x = surf->tris[i].VertIndex[j]; - - glTexCoord2fv(&surf->texcoords[x].s); - if (!interpolate) - { - glVertex3f(vert[x].x, vert[x].z, vert[x].y); - } - else - { - float interp[3]; - interp[0] = inter * vert[x].x + (1. - inter) * vert2[x].x; - interp[1] = inter * vert[x].z + (1. - inter) * vert2[x].z; - interp[2] = inter * vert[x].y + (1. - inter) * vert2[x].y; - glVertex3fv(interp); - } - } - } - glEnd(); -} - void FMD3Model::RenderFrame(FTexture * skin, int frameno, int frameno2, double inter, int translation) { if (frameno>=numFrames || frameno2>=numFrames) return; @@ -299,10 +269,9 @@ void FMD3Model::RenderFrame(FTexture * skin, int frameno, int frameno2, double i tex->Bind(0, translation); - MD3Vertex* vertices1 = surf->vertices + frameno * surf->numVertices; - MD3Vertex* vertices2 = surf->vertices + frameno2 * surf->numVertices; - - RenderTriangles(surf, vertices1, vertices2, inter); + gl_RenderState.Apply(); + GLRenderer->mModelVBO->SetupFrame(surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices, inter); + glDrawElements(GL_TRIANGLES, surf->numTriangles * 3, GL_UNSIGNED_INT, (void*)(intptr_t)(surf->iindex * sizeof(unsigned int))); } } From f7105189036de62db1ddef10be818c21c20d18bb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 30 Jun 2014 18:10:55 +0200 Subject: [PATCH 0137/1509] - use a uniform array to store vertex data to render dynamic stuff on GL 3.x hardware without the ARB_buffer_storage extension. Due to the way the engine works it needs to render a lot of small primitives with frequent state changes. But due to the performance of buffer uploads it is impossible to upload each primitive's vertices to a buffer separately because buffer uploads nearly always stall the GPU. On the other hand, in order to reduce the amount of buffer uploads all the necessary state changes would have to be saved in an array until they can finally be used. This method also imposed an unacceptable overhead. Fortunately, uploading uniform arrays is very fast and doesn't cause GPU stalls, so now the engine puts the vertex data per primitive into a uniform array and uses a static vertex buffer to index the array in the vertex shader. This method offers the same performance as immediate mode but only uses core profile features. --- src/gl/data/gl_vertexbuffer.cpp | 60 +++++++++++++++++++++++++++--- src/gl/shaders/gl_shader.cpp | 8 ++++ src/gl/shaders/gl_shader.h | 7 ++++ wadsrc/static/shaders/glsl/main.vp | 28 +++++++++++++- 4 files changed, 95 insertions(+), 8 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 3ea401dcd..b6d33dacd 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -90,6 +90,14 @@ FFlatVertexBuffer::FFlatVertexBuffer() { vbo_shadowdata.Reserve(BUFFER_SIZE); map = &vbo_shadowdata[0]; + + FFlatVertex fill[20]; + for (int i = 0; i < 20; i++) + { + fill[i].Set(0, 0, 0, 100001.f, i); + } + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferData(GL_ARRAY_BUFFER, 20 * sizeof(FFlatVertex), fill, GL_STATIC_DRAW); } mIndex = mCurIndex = 0; } @@ -109,15 +117,55 @@ FFlatVertexBuffer::~FFlatVertexBuffer() // //========================================================================== +CVAR(Bool, gl_testbuffer, false, 0) + void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count) { - glBegin(primtype); - for (unsigned int i = 0; i < count; i++) + if (!gl_testbuffer) // todo: remove the immediate mode calls once the uniform array method has been tested. { - glTexCoord2fv(&map[offset + i].u); - glVertex3fv(&map[offset + i].x); + glBegin(primtype); + for (unsigned int i = 0; i < count; i++) + { + glTexCoord2fv(&map[offset + i].u); + glVertex3fv(&map[offset + i].x); + } + glEnd(); + } + else + { + if (count > 20) + { + int start = offset; + FFlatVertex ff = map[offset]; + while (count > 20) + { + + if (primtype == GL_TRIANGLE_FAN) + { + // split up the fan into multiple sub-fans + map[offset] = map[start]; + glUniform1fv(GLRenderer->mShaderManager->GetActiveShader()->fakevb_index, 20 * 5, &map[offset].x); + glDrawArrays(primtype, 0, 20); + offset += 18; + count -= 18; + } + else + { + // we only have triangle fans of this size so don't bother with strips and triangles here. + break; + } + } + map[offset] = map[start]; + glUniform1fv(GLRenderer->mShaderManager->GetActiveShader()->fakevb_index, count * 5, &map[offset].x); + glDrawArrays(primtype, 0, count); + map[offset] = ff; + } + else + { + glUniform1fv(GLRenderer->mShaderManager->GetActiveShader()->fakevb_index, count * 5, &map[offset].x); + glDrawArrays(primtype, 0, count); + } } - glEnd(); } //========================================================================== @@ -324,7 +372,7 @@ void FFlatVertexBuffer::CreateVBO() void FFlatVertexBuffer::BindVBO() { - if (gl.flags & RFL_BUFFER_STORAGE) + //if (gl.flags & RFL_BUFFER_STORAGE) { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 76049eb1f..bd96c1ce2 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -90,6 +90,13 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * if (gl.glslversion >= 3.3f) vp_comb = "#version 330 compatibility\n"; // I can't shut up the deprecation warnings in GLSL 1.3 so if available use a version with compatibility profile. // todo when using shader storage buffers, add // "#version 400 compatibility\n#extension GL_ARB_shader_storage_buffer_object : require\n" instead. + + if (!(gl.flags & RFL_BUFFER_STORAGE)) + { + // we only want the uniform array hack in the shader if we actually need it. + vp_comb << "#define UNIFORM_VB\n"; + } + vp_comb << defines << i_data.GetString().GetChars(); FString fp_comb = vp_comb; @@ -196,6 +203,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * timer_index = glGetUniformLocation(hShader, "timer"); lights_index = glGetUniformLocation(hShader, "lights"); + fakevb_index = glGetUniformLocation(hShader, "fakeVB"); glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index d1518088d..b079e74c4 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -196,6 +196,9 @@ class FShader int timer_index; int lights_index; +public: + int fakevb_index; +private: int currentglowstate; int currentfixedcolormap; @@ -245,6 +248,10 @@ public: FShader *BindEffect(int effect); void SetActiveShader(FShader *sh); void SetWarpSpeed(unsigned int eff, float speed); + FShader *GetActiveShader() const + { + return mActiveShader; + } FShader *Get(unsigned int eff) { diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 3ec5990b2..81b0601c5 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -3,10 +3,34 @@ in vec4 aVertex2; out vec4 pixelpos; out vec2 glowdist; +#ifdef UNIFORM_VB +uniform float fakeVB[100]; +#endif void main() { - vec4 worldcoord = ModelMatrix * mix(gl_Vertex, aVertex2, uInterpolationFactor); + +#ifdef UNIFORM_VB + vec4 vert; + vec4 tc; + + if (gl_MultiTexCoord0.x >= 100000.0) + { + int fakeVI = int(gl_MultiTexCoord0.y)*5; + vert = gl_Vertex + vec4(fakeVB[fakeVI], fakeVB[fakeVI+1], fakeVB[fakeVI+2], 0.0); + tc = vec4(fakeVB[fakeVI+3], fakeVB[fakeVI+4], 0.0, 0.0); + } + else + { + vert = gl_Vertex; + tc = gl_MultiTexCoord0; + } +#else + #define vert gl_Vertex + #define tc gl_MultiTexCoord0 +#endif + + vec4 worldcoord = ModelMatrix * mix(vert, aVertex2, uInterpolationFactor); vec4 eyeCoordPos = ViewMatrix * worldcoord; gl_FrontColor = gl_Color; @@ -25,7 +49,7 @@ void main() vec2 sst = vec2(r.x/m + 0.5, r.y/m + 0.5); gl_TexCoord[0].xy = sst; #else - gl_TexCoord[0] = TextureMatrix * gl_MultiTexCoord0; + gl_TexCoord[0] = TextureMatrix * tc; #endif gl_Position = ProjectionMatrix * eyeCoordPos; From 5ee626459d1926fe96e11d3fb7bc47c9520f23e8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 30 Jun 2014 18:57:24 +0200 Subject: [PATCH 0138/1509] - use model vertex buffer to render voxels. --- src/gl/models/gl_voxels.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index c81dfcec0..ffd2a65de 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -305,7 +305,7 @@ void FVoxelModel::AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3 mIndices.Push(indx[0]); mIndices.Push(indx[1]); - mIndices.Push(indx[2]); + mIndices.Push(indx[3]); mIndices.Push(indx[1]); mIndices.Push(indx[3]); mIndices.Push(indx[2]); @@ -420,13 +420,7 @@ void FVoxelModel::RenderFrame(FTexture * skin, int frame, int frame2, double int tex->Bind(0, translation); gl_RenderState.Apply(); - glBegin(GL_TRIANGLES); - for (unsigned i = 0; i < mIndices.Size(); i++) - { - FModelVertex *vert = &mVertices[mIndices[i]]; - glTexCoord2fv(&vert->u); - glVertex3fv(&vert->x); - } - glEnd(); + GLRenderer->mModelVBO->SetupFrame(vindex, vindex, 0.f); + glDrawElements(GL_TRIANGLES, mIndices.Size(), GL_UNSIGNED_INT, (void*)(intptr_t)(iindex * sizeof(unsigned int))); } From 9a6bc64381434e631c96358cba19159697b873a3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 1 Jul 2014 00:51:02 +0200 Subject: [PATCH 0139/1509] - use vertex array objects to manage vertex buffers. --- src/gl/data/gl_vertexbuffer.cpp | 42 ++++++++++++++++----------------- src/gl/data/gl_vertexbuffer.h | 6 ++--- src/gl/models/gl_models.cpp | 24 +++++-------------- src/gl/scene/gl_skydome.cpp | 15 +++++------- 4 files changed, 34 insertions(+), 53 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index b6d33dacd..d9d96c855 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -58,8 +58,10 @@ FVertexBuffer::FVertexBuffer() { - vbo_id = 0; + vao_id = vbo_id = 0; glGenBuffers(1, &vbo_id); + glGenVertexArrays(1, &vao_id); + } FVertexBuffer::~FVertexBuffer() @@ -68,6 +70,15 @@ FVertexBuffer::~FVertexBuffer() { glDeleteBuffers(1, &vbo_id); } + if (vao_id != 0) + { + glDeleteVertexArrays(1, &vao_id); + } +} + +void FVertexBuffer::BindVBO() +{ + glBindVertexArray(vao_id); } //========================================================================== @@ -100,6 +111,14 @@ FFlatVertexBuffer::FFlatVertexBuffer() glBufferData(GL_ARRAY_BUFFER, 20 * sizeof(FFlatVertex), fill, GL_STATIC_DRAW); } mIndex = mCurIndex = 0; + + glBindVertexArray(vao_id); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glVertexPointer(3,GL_FLOAT, sizeof(FFlatVertex), &VTO->x); + glTexCoordPointer(2,GL_FLOAT, sizeof(FFlatVertex), &VTO->u); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glBindVertexArray(0); } FFlatVertexBuffer::~FFlatVertexBuffer() @@ -370,27 +389,6 @@ void FFlatVertexBuffer::CreateVBO() // //========================================================================== -void FFlatVertexBuffer::BindVBO() -{ - //if (gl.flags & RFL_BUFFER_STORAGE) - { - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glVertexPointer(3,GL_FLOAT, sizeof(FFlatVertex), &VTO->x); - glTexCoordPointer(2,GL_FLOAT, sizeof(FFlatVertex), &VTO->u); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - glDisableVertexAttribArray(VATTR_VERTEX2); - } -} - -//========================================================================== -// -// -// -//========================================================================== - void FFlatVertexBuffer::CheckPlanes(sector_t *sector) { if (gl.flags & RFL_BUFFER_STORAGE) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index a183a7a2e..d9e259db6 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -15,11 +15,12 @@ class FVertexBuffer { protected: unsigned int vbo_id; + unsigned int vao_id; public: FVertexBuffer(); virtual ~FVertexBuffer(); - virtual void BindVBO() = 0; + void BindVBO(); }; struct FFlatVertex @@ -60,7 +61,6 @@ public: ~FFlatVertexBuffer(); void CreateVBO(); - void BindVBO(); void CheckUpdate(sector_t *sector); FFlatVertex *GetBuffer() @@ -162,7 +162,6 @@ public: FSkyVertexBuffer(); virtual ~FSkyVertexBuffer(); - virtual void BindVBO(); void RenderDome(FMaterial *tex, int mode); }; @@ -203,7 +202,6 @@ public: FModelVertexBuffer(); ~FModelVertexBuffer(); - void BindVBO(); unsigned int SetupFrame(unsigned int frame1, unsigned int frame2, float factor); }; diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index f6aad15fa..67ec241e3 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -109,11 +109,17 @@ FModelVertexBuffer::FModelVertexBuffer() Models[i]->BuildVertexBuffer(this); } + glBindVertexArray(vao_id); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glBufferData(GL_ARRAY_BUFFER,vbo_shadowdata.Size() * sizeof(FModelVertex), &vbo_shadowdata[0], GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); glBufferData(GL_ELEMENT_ARRAY_BUFFER,ibo_shadowdata.Size() * sizeof(unsigned int), &ibo_shadowdata[0], GL_STATIC_DRAW); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableVertexAttribArray(VATTR_VERTEX2); + glBindVertexArray(0); } FModelVertexBuffer::~FModelVertexBuffer() @@ -125,24 +131,6 @@ FModelVertexBuffer::~FModelVertexBuffer() } -//=========================================================================== -// -// -// -//=========================================================================== - -void FModelVertexBuffer::BindVBO() -{ - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); - //glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &VMO->x); - //glTexCoordPointer(2, GL_FLOAT, sizeof(FModelVertex), &VMO->u); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - glEnableVertexAttribArray(VATTR_VERTEX2); -} - //=========================================================================== // // Sets up the buffer starts for frame interpolation diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 0d9026ea6..221f2203b 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -77,25 +77,22 @@ extern int skyfog; FSkyVertexBuffer::FSkyVertexBuffer() { CreateDome(); -} -FSkyVertexBuffer::~FSkyVertexBuffer() -{ -} - -void FSkyVertexBuffer::BindVBO() -{ + glBindVertexArray(vao_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glVertexPointer(3, GL_FLOAT, sizeof(FSkyVertex), &VSO->x); glTexCoordPointer(2, GL_FLOAT, sizeof(FSkyVertex), &VSO->u); glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(FSkyVertex), &VSO->color); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_COLOR_ARRAY); - glDisableVertexAttribArray(VATTR_VERTEX2); + glBindVertexArray(0); + } +FSkyVertexBuffer::~FSkyVertexBuffer() +{ +} //----------------------------------------------------------------------------- // From 92185f96ebf0e7afc8389ba9fb8a0c165082deec Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 1 Jul 2014 09:52:41 +0200 Subject: [PATCH 0140/1509] - fixed overflow with storing a sprite's dynamic light color in a PalEntry. --- src/gl/renderer/gl_renderstate.cpp | 2 +- src/gl/renderer/gl_renderstate.h | 9 ++------- src/gl/shaders/gl_shader.h | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index cf8604924..64647b670 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -141,7 +141,7 @@ bool FRenderState::ApplyShader() activeShader->muLightParms.Set(mLightParms); activeShader->muFogColor.Set(mFogColor); activeShader->muObjectColor.Set(mObjectColor); - activeShader->muDynLightColor.Set(mDynColor); + activeShader->muDynLightColor.Set(mDynColor.vec); activeShader->muInterpolationFactor.Set(mInterpolationFactor); if (mGlowEnabled) diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 1bfaf7135..f569c3eab 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -65,7 +65,7 @@ class FRenderState FStateVec4 mGlowTopPlane, mGlowBottomPlane; PalEntry mFogColor; PalEntry mObjectColor; - PalEntry mDynColor; + FStateVec4 mDynColor; int mEffectState; int mColormapState; @@ -184,12 +184,7 @@ public: void SetDynLight(float r, float g, float b) { - mDynColor = PalEntry(255, xs_CRoundToInt(r*255), xs_CRoundToInt(g*255), xs_CRoundToInt(b*255)); - } - - void SetDynLight(PalEntry pe) - { - mDynColor = pe; + mDynColor.Set(r, g, b, 0); } void SetObjectColor(PalEntry pe) diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index b079e74c4..833f97fbb 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -186,7 +186,7 @@ class FShader FUniform4f muColormapRange; FBufferedUniform4i muLightRange; FBufferedUniformPE muFogColor; - FBufferedUniformPE muDynLightColor; + FBufferedUniform4f muDynLightColor; FBufferedUniformPE muObjectColor; FUniform4f muGlowBottomColor; FUniform4f muGlowTopColor; From a936629cec470e3c4bdf6bfcf9481c6bae39e5ec Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 10 Jul 2014 10:33:07 +0200 Subject: [PATCH 0141/1509] - use default fragment shader for burn and stencil shader, with the time consuming parts disabled by a #define, to avoid code duplication. --- src/gl/shaders/gl_shader.cpp | 25 +++++++++++++++++++++++-- wadsrc/static/shaders/glsl/burn.vp | 7 ------- wadsrc/static/shaders/glsl/main.vp | 21 +++++++++++++++------ wadsrc/static/shaders/glsl/stencil.vp | 14 -------------- 4 files changed, 38 insertions(+), 29 deletions(-) delete mode 100644 wadsrc/static/shaders/glsl/burn.vp delete mode 100644 wadsrc/static/shaders/glsl/stencil.vp diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index bd96c1ce2..013e56709 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -212,6 +212,27 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * int texture_index = glGetUniformLocation(hShader, "texture2"); if (texture_index > 0) glUniform1i(texture_index, 1); + + GLint binaryLength; + void* binary; + FILE* outfile; + GLenum binaryFormat; + // + // Retrieve the binary from the program object + // + glGetProgramiv(hShader, GL_PROGRAM_BINARY_LENGTH, &binaryLength); + binary = (void*)malloc(binaryLength); + glGetProgramBinary(hShader, binaryLength, NULL, &binaryFormat, binary); + + // + // Cache the program binary for future runs + // + outfile = fopen(name, "wb"); + fwrite(binary, binaryLength, 1, outfile); + fclose(outfile); + free(binary); + + glUseProgram(0); return !!linked; } @@ -316,8 +337,8 @@ static const FEffectShader effectshaders[]= { { "fogboundary", "shaders/glsl/main.vp", "shaders/glsl/fogboundary.fp", NULL, "" }, { "spheremap", "shaders/glsl/main.vp", "shaders/glsl/main.fp", "shaders/glsl/func_normal.fp", "#define SPHEREMAP\n" }, - { "burn", "shaders/glsl/burn.vp", "shaders/glsl/burn.fp", NULL, "" }, - { "stencil", "shaders/glsl/stencil.vp", "shaders/glsl/stencil.fp", NULL, "" }, + { "burn", "shaders/glsl/main.vp", "shaders/glsl/burn.fp", NULL, "#define SIMPLE\n" }, + { "stencil", "shaders/glsl/main.vp", "shaders/glsl/stencil.fp", NULL, "#define SIMPLE\n" }, }; diff --git a/wadsrc/static/shaders/glsl/burn.vp b/wadsrc/static/shaders/glsl/burn.vp deleted file mode 100644 index 6a8d2b37b..000000000 --- a/wadsrc/static/shaders/glsl/burn.vp +++ /dev/null @@ -1,7 +0,0 @@ - -void main() -{ - gl_FrontColor = gl_Color; - gl_TexCoord[0] = gl_MultiTexCoord0; - gl_Position = ProjectionMatrix * gl_Vertex; -} diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 81b0601c5..f0bbdd413 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -1,7 +1,9 @@ +#ifndef SIMPLE // we do not need these for simple shaders in vec4 aVertex2; out vec4 pixelpos; out vec2 glowdist; +#endif #ifdef UNIFORM_VB uniform float fakeVB[100]; @@ -30,16 +32,23 @@ void main() #define tc gl_MultiTexCoord0 #endif - vec4 worldcoord = ModelMatrix * mix(vert, aVertex2, uInterpolationFactor); + #ifndef SIMPLE + vec4 worldcoord = ModelMatrix * mix(vert, aVertex2, uInterpolationFactor); + #else + vec4 worldcoord = ModelMatrix * vert; + #endif + vec4 eyeCoordPos = ViewMatrix * worldcoord; gl_FrontColor = gl_Color; - - pixelpos.xyz = worldcoord.xyz; - pixelpos.w = -eyeCoordPos.z/eyeCoordPos.w; - glowdist.x = -((uGlowTopPlane.w + uGlowTopPlane.x * worldcoord.x + uGlowTopPlane.y * worldcoord.z) * uGlowTopPlane.z) - worldcoord.y; - glowdist.y = worldcoord.y + ((uGlowBottomPlane.w + uGlowBottomPlane.x * worldcoord.x + uGlowBottomPlane.y * worldcoord.z) * uGlowBottomPlane.z); + #ifndef SIMPLE + pixelpos.xyz = worldcoord.xyz; + pixelpos.w = -eyeCoordPos.z/eyeCoordPos.w; + + glowdist.x = -((uGlowTopPlane.w + uGlowTopPlane.x * worldcoord.x + uGlowTopPlane.y * worldcoord.z) * uGlowTopPlane.z) - worldcoord.y; + glowdist.y = worldcoord.y + ((uGlowBottomPlane.w + uGlowBottomPlane.x * worldcoord.x + uGlowBottomPlane.y * worldcoord.z) * uGlowBottomPlane.z); + #endif #ifdef SPHEREMAP vec3 u = normalize(eyeCoordPos.xyz); diff --git a/wadsrc/static/shaders/glsl/stencil.vp b/wadsrc/static/shaders/glsl/stencil.vp deleted file mode 100644 index f5ac9fdd1..000000000 --- a/wadsrc/static/shaders/glsl/stencil.vp +++ /dev/null @@ -1,14 +0,0 @@ - -out vec4 pixelpos; - -void main() -{ - // perform exactly the same relevant steps as in the main shader to ensure matching results (that also means including the model matrix here!) - vec4 worldcoord = ModelMatrix * gl_Vertex; - vec4 eyeCoordPos = ViewMatrix * worldcoord; - - pixelpos.xyz = worldcoord.xyz; - pixelpos.w = -eyeCoordPos.z/eyeCoordPos.w; - - gl_Position = ProjectionMatrix * eyeCoordPos; -} From 7cbffc7c14e0a3e7b68891bde39263db5e8905a8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 10 Jul 2014 10:35:02 +0200 Subject: [PATCH 0142/1509] - test code removal. --- src/gl/shaders/gl_shader.cpp | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 013e56709..a15d5a106 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -212,27 +212,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * int texture_index = glGetUniformLocation(hShader, "texture2"); if (texture_index > 0) glUniform1i(texture_index, 1); - - GLint binaryLength; - void* binary; - FILE* outfile; - GLenum binaryFormat; - // - // Retrieve the binary from the program object - // - glGetProgramiv(hShader, GL_PROGRAM_BINARY_LENGTH, &binaryLength); - binary = (void*)malloc(binaryLength); - glGetProgramBinary(hShader, binaryLength, NULL, &binaryFormat, binary); - - // - // Cache the program binary for future runs - // - outfile = fopen(name, "wb"); - fwrite(binary, binaryLength, 1, outfile); - fclose(outfile); - free(binary); - - glUseProgram(0); return !!linked; } From d868f60f6c21c8df307b569e6dd947449870da09 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 13 Jul 2014 12:14:12 +0200 Subject: [PATCH 0143/1509] - since the clip planes for plane mirrors did not work anymore I reimplemented them using shader based logic. It still needs to be seen if this affects performance on older hardware. --- src/CMakeLists.txt | 1 + src/gl/data/gl_matrix.cpp | 496 ++++++++++++++++++++++ src/gl/data/gl_matrix.h | 93 ++++ src/gl/renderer/gl_renderstate.cpp | 5 +- src/gl/renderer/gl_renderstate.h | 11 + src/gl/scene/gl_portal.cpp | 37 +- src/gl/scene/gl_portal.h | 2 +- src/gl/shaders/gl_shader.cpp | 1 + src/gl/shaders/gl_shader.h | 1 + wadsrc/static/shaders/glsl/fogboundary.fp | 6 + wadsrc/static/shaders/glsl/main.fp | 6 + wadsrc/static/shaders/glsl/shaderdefs.i | 1 + wadsrc/static/shaders/glsl/stencil.fp | 6 + 13 files changed, 650 insertions(+), 16 deletions(-) create mode 100644 src/gl/data/gl_matrix.cpp create mode 100644 src/gl/data/gl_matrix.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fad134fc3..efbeab3b5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1046,6 +1046,7 @@ add_executable( zdoom WIN32 gl/data/gl_data.cpp gl/data/gl_portaldata.cpp gl/data/gl_setup.cpp + gl/data/gl_matrix.cpp gl/data/gl_vertexbuffer.cpp gl/dynlights/a_dynlight.cpp gl/utility/gl_clock.cpp diff --git a/src/gl/data/gl_matrix.cpp b/src/gl/data/gl_matrix.cpp new file mode 100644 index 000000000..589cfb8cc --- /dev/null +++ b/src/gl/data/gl_matrix.cpp @@ -0,0 +1,496 @@ +/* -------------------------------------------------- + +Lighthouse3D + +VSMatrix - Very Simple Matrix Library + +http://www.lighthouse3d.com/very-simple-libs + +This is a simplified version of VSMatrix that has been adjusted for GZDoom's needs. + +----------------------------------------------------*/ + +#include "gl/system/gl_system.h" +#include +#include +#include +#include +#include "doomtype.h" +#include "gl/data/gl_matrix.h" + +static inline double +DegToRad(double degrees) +{ + return (double)(degrees * (M_PI / 180.0f)); +}; + +// sets the square matrix mat to the identity matrix, +// size refers to the number of rows (or columns) +void +VSMatrix::setIdentityMatrix( double *mat, int size) { + + // fill matrix with 0s + for (int i = 0; i < size * size; ++i) + mat[i] = 0.0f; + + // fill diagonal with 1s + for (int i = 0; i < size; ++i) + mat[i + i * size] = 1.0f; +} + + + +// glLoadIdentity implementation +void +VSMatrix::loadIdentity() +{ + // fill matrix with 0s + for (int i = 0; i < 16; ++i) + mMatrix[i] = 0.0f; + + // fill diagonal with 1s + for (int i = 0; i < 4; ++i) + mMatrix[i + i * 4] = 1.0f; +} + + +// glMultMatrix implementation +void +VSMatrix::multMatrix(const double *aMatrix) +{ + + double res[16]; + + for (int i = 0; i < 4; ++i) + { + for (int j = 0; j < 4; ++j) + { + res[j*4 + i] = 0.0f; + for (int k = 0; k < 4; ++k) + { + res[j*4 + i] += mMatrix[k*4 + i] * aMatrix[j*4 + k]; + } + } + } + memcpy(mMatrix, res, 16 * sizeof(double)); +} + +// glMultMatrix implementation +void +VSMatrix::multMatrix(const float *aMatrix) +{ + + double res[16]; + + for (int i = 0; i < 4; ++i) + { + for (int j = 0; j < 4; ++j) + { + res[j * 4 + i] = 0.0f; + for (int k = 0; k < 4; ++k) + { + res[j*4 + i] += mMatrix[k*4 + i] * aMatrix[j*4 + k]; + } + } + } + memcpy(mMatrix, res, 16 * sizeof(double)); +} + + + +// glLoadMatrix implementation +void +VSMatrix::loadMatrix(const double *aMatrix) +{ + memcpy(mMatrix, aMatrix, 16 * sizeof(double)); +} + +// glLoadMatrix implementation +void +VSMatrix::loadMatrix(const float *aMatrix) +{ + for (int i = 0; i < 16; ++i) + { + mMatrix[i] = aMatrix[i]; + } +} + + +// gl Translate implementation with matrix selection +void +VSMatrix::translate(double x, double y, double z) +{ + double mat[16]; + + setIdentityMatrix(mat); + mat[12] = x; + mat[13] = y; + mat[14] = z; + + multMatrix(mat); +} + + +// gl Scale implementation with matrix selection +void +VSMatrix::scale(double x, double y, double z) +{ + double mat[16]; + + setIdentityMatrix(mat,4); + mat[0] = x; + mat[5] = y; + mat[10] = z; + + multMatrix(mat); +} + + +// gl Rotate implementation with matrix selection +void +VSMatrix::rotate(double angle, double x, double y, double z) +{ + double mat[16]; + double v[3]; + + v[0] = x; + v[1] = y; + v[2] = z; + + double radAngle = DegToRad(angle); + double co = cos(radAngle); + double si = sin(radAngle); + normalize(v); + double x2 = v[0]*v[0]; + double y2 = v[1]*v[1]; + double z2 = v[2]*v[2]; + +// mat[0] = x2 + (y2 + z2) * co; + mat[0] = co + x2 * (1 - co);// + (y2 + z2) * co; + mat[4] = v[0] * v[1] * (1 - co) - v[2] * si; + mat[8] = v[0] * v[2] * (1 - co) + v[1] * si; + mat[12]= 0.0f; + + mat[1] = v[0] * v[1] * (1 - co) + v[2] * si; +// mat[5] = y2 + (x2 + z2) * co; + mat[5] = co + y2 * (1 - co); + mat[9] = v[1] * v[2] * (1 - co) - v[0] * si; + mat[13]= 0.0f; + + mat[2] = v[0] * v[2] * (1 - co) - v[1] * si; + mat[6] = v[1] * v[2] * (1 - co) + v[0] * si; +// mat[10]= z2 + (x2 + y2) * co; + mat[10]= co + z2 * (1 - co); + mat[14]= 0.0f; + + mat[3] = 0.0f; + mat[7] = 0.0f; + mat[11]= 0.0f; + mat[15]= 1.0f; + + multMatrix(mat); +} + + +// gluLookAt implementation +void +VSMatrix::lookAt(double xPos, double yPos, double zPos, + double xLook, double yLook, double zLook, + double xUp, double yUp, double zUp) +{ + double dir[3], right[3], up[3]; + + up[0] = xUp; up[1] = yUp; up[2] = zUp; + + dir[0] = (xLook - xPos); + dir[1] = (yLook - yPos); + dir[2] = (zLook - zPos); + normalize(dir); + + crossProduct(dir,up,right); + normalize(right); + + crossProduct(right,dir,up); + normalize(up); + + double m1[16],m2[16]; + + m1[0] = right[0]; + m1[4] = right[1]; + m1[8] = right[2]; + m1[12] = 0.0f; + + m1[1] = up[0]; + m1[5] = up[1]; + m1[9] = up[2]; + m1[13] = 0.0f; + + m1[2] = -dir[0]; + m1[6] = -dir[1]; + m1[10] = -dir[2]; + m1[14] = 0.0f; + + m1[3] = 0.0f; + m1[7] = 0.0f; + m1[11] = 0.0f; + m1[15] = 1.0f; + + setIdentityMatrix(m2,4); + m2[12] = -xPos; + m2[13] = -yPos; + m2[14] = -zPos; + + multMatrix(m1); + multMatrix(m2); +} + + +// gluPerspective implementation +void +VSMatrix::perspective(double fov, double ratio, double nearp, double farp) +{ + double projMatrix[16]; + + double f = 1.0f / tan (fov * (M_PI / 360.0f)); + + setIdentityMatrix(projMatrix,4); + + projMatrix[0] = f / ratio; + projMatrix[1 * 4 + 1] = f; + projMatrix[2 * 4 + 2] = (farp + nearp) / (nearp - farp); + projMatrix[3 * 4 + 2] = (2.0f * farp * nearp) / (nearp - farp); + projMatrix[2 * 4 + 3] = -1.0f; + projMatrix[3 * 4 + 3] = 0.0f; + + multMatrix(projMatrix); +} + + +// glOrtho implementation +void +VSMatrix::ortho(double left, double right, + double bottom, double top, + double nearp, double farp) +{ + double m[16]; + + setIdentityMatrix(m,4); + + m[0 * 4 + 0] = 2 / (right - left); + m[1 * 4 + 1] = 2 / (top - bottom); + m[2 * 4 + 2] = -2 / (farp - nearp); + m[3 * 4 + 0] = -(right + left) / (right - left); + m[3 * 4 + 1] = -(top + bottom) / (top - bottom); + m[3 * 4 + 2] = -(farp + nearp) / (farp - nearp); + + multMatrix(m); +} + + +// glFrustum implementation +void +VSMatrix::frustum(double left, double right, + double bottom, double top, + double nearp, double farp) +{ + double m[16]; + + setIdentityMatrix(m,4); + + m[0 * 4 + 0] = 2 * nearp / (right-left); + m[1 * 4 + 1] = 2 * nearp / (top - bottom); + m[2 * 4 + 0] = (right + left) / (right - left); + m[2 * 4 + 1] = (top + bottom) / (top - bottom); + m[2 * 4 + 2] = - (farp + nearp) / (farp - nearp); + m[2 * 4 + 3] = -1.0f; + m[3 * 4 + 2] = - 2 * farp * nearp / (farp-nearp); + m[3 * 4 + 3] = 0.0f; + + multMatrix(m); +} + + +/* +// returns a pointer to the requested matrix +double * +VSMatrix::get(MatrixTypes aType) +{ + return mMatrix[aType]; +} +*/ + + +/* ----------------------------------------------------- + SEND MATRICES TO OPENGL +------------------------------------------------------*/ + + + + +// universal +void +VSMatrix::matrixToGL(int loc) +{ + float copyto[16]; + copy(copyto); + glUniformMatrix4fv(loc, 1, false, copyto); +} + +// ----------------------------------------------------- +// AUX functions +// ----------------------------------------------------- + + +// Compute res = M * point +void +VSMatrix::multMatrixPoint(const double *point, double *res) +{ + + for (int i = 0; i < 4; ++i) + { + + res[i] = 0.0f; + + for (int j = 0; j < 4; j++) { + + res[i] += point[j] * mMatrix[j*4 + i]; + } + } +} + +// res = a cross b; +void +VSMatrix::crossProduct(const double *a, const double *b, double *res) { + + res[0] = a[1] * b[2] - b[1] * a[2]; + res[1] = a[2] * b[0] - b[2] * a[0]; + res[2] = a[0] * b[1] - b[0] * a[1]; +} + + +// returns a . b +double +VSMatrix::dotProduct(const double *a, const double *b) { + + double res = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; + + return res; +} + + +// Normalize a vec3 +void +VSMatrix::normalize(double *a) { + + double mag = sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); + + a[0] /= mag; + a[1] /= mag; + a[2] /= mag; +} + + +// res = b - a +void +VSMatrix::subtract(const double *a, const double *b, double *res) { + + res[0] = b[0] - a[0]; + res[1] = b[1] - a[1]; + res[2] = b[2] - a[2]; +} + + +// res = a + b +void +VSMatrix::add(const double *a, const double *b, double *res) { + + res[0] = b[0] + a[0]; + res[1] = b[1] + a[1]; + res[2] = b[2] + a[2]; +} + + +// returns |a| +double +VSMatrix::length(const double *a) { + + return(sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])); + +} + + +static inline int +M3(int i, int j) +{ + return (i*3+j); +}; + + + +// computes the derived normal matrix for the view matrix +void +VSMatrix::computeNormalMatrix(const double *aMatrix) +{ + + double mMat3x3[9]; + + mMat3x3[0] = aMatrix[0]; + mMat3x3[1] = aMatrix[1]; + mMat3x3[2] = aMatrix[2]; + + mMat3x3[3] = aMatrix[4]; + mMat3x3[4] = aMatrix[5]; + mMat3x3[5] = aMatrix[6]; + + mMat3x3[6] = aMatrix[8]; + mMat3x3[7] = aMatrix[9]; + mMat3x3[8] = aMatrix[10]; + + double det, invDet; + + det = mMat3x3[0] * (mMat3x3[4] * mMat3x3[8] - mMat3x3[5] * mMat3x3[7]) + + mMat3x3[1] * (mMat3x3[5] * mMat3x3[6] - mMat3x3[8] * mMat3x3[3]) + + mMat3x3[2] * (mMat3x3[3] * mMat3x3[7] - mMat3x3[4] * mMat3x3[6]); + + invDet = 1.0f/det; + + mMatrix[0] = (mMat3x3[4] * mMat3x3[8] - mMat3x3[5] * mMat3x3[7]) * invDet; + mMatrix[1] = (mMat3x3[5] * mMat3x3[6] - mMat3x3[8] * mMat3x3[3]) * invDet; + mMatrix[2] = (mMat3x3[3] * mMat3x3[7] - mMat3x3[4] * mMat3x3[6]) * invDet; + mMatrix[3] = 0.0f; + mMatrix[4] = (mMat3x3[2] * mMat3x3[7] - mMat3x3[1] * mMat3x3[8]) * invDet; + mMatrix[5] = (mMat3x3[0] * mMat3x3[8] - mMat3x3[2] * mMat3x3[6]) * invDet; + mMatrix[6] = (mMat3x3[1] * mMat3x3[6] - mMat3x3[7] * mMat3x3[0]) * invDet; + mMatrix[7] = 0.0f; + mMatrix[8] = (mMat3x3[1] * mMat3x3[5] - mMat3x3[4] * mMat3x3[2]) * invDet; + mMatrix[9] = (mMat3x3[2] * mMat3x3[3] - mMat3x3[0] * mMat3x3[5]) * invDet; + mMatrix[10] =(mMat3x3[0] * mMat3x3[4] - mMat3x3[3] * mMat3x3[1]) * invDet; + mMatrix[11] = 0.0; + mMatrix[12] = 0.0; + mMatrix[13] = 0.0; + mMatrix[14] = 0.0; + mMatrix[15] = 1.0; + +} + + +// aux function resMat = resMat * aMatrix +void +VSMatrix::multMatrix(double *resMat, const double *aMatrix) +{ + + double res[16]; + + for (int i = 0; i < 4; ++i) + { + for (int j = 0; j < 4; ++j) + { + res[j*4 + i] = 0.0f; + for (int k = 0; k < 4; ++k) + { + res[j*4 + i] += resMat[k*4 + i] * aMatrix[j*4 + k]; + } + } + } + memcpy(resMat, res, 16 * sizeof(double)); +} diff --git a/src/gl/data/gl_matrix.h b/src/gl/data/gl_matrix.h new file mode 100644 index 000000000..1ccbc5c37 --- /dev/null +++ b/src/gl/data/gl_matrix.h @@ -0,0 +1,93 @@ + +// Matrix class based on code from VSML: + +/** ---------------------------------------------------------- + * \class VSMathLib + * + * Lighthouse3D + * + * VSMathLib - Very Simple Matrix Library + * + * Full documentation at + * http://www.lighthouse3d.com/very-simple-libs + * + * This class aims at easing geometric transforms, camera + * placement and projection definition for programmers + * working with OpenGL core versions. + * + * + ---------------------------------------------------------------*/ +#ifndef __VSMatrix__ +#define __VSMatrix__ + +#include + +class VSMatrix { + + public: + + VSMatrix() + { + } + + VSMatrix(int) + { + loadIdentity(); + } + + void translate(double x, double y, double z); + void scale(double x, double y, double z); + void rotate(double angle, double x, double y, double z); + void loadIdentity(); + void multMatrix(const float *aMatrix); + void multMatrix(const double *aMatrix); + void multMatrix(const VSMatrix &aMatrix) + { + multMatrix(aMatrix.mMatrix); + } + void loadMatrix(const double *aMatrix); + void loadMatrix(const float *aMatrix); + void lookAt(double xPos, double yPos, double zPos, double xLook, double yLook, double zLook, double xUp, double yUp, double zUp); + void perspective(double fov, double ratio, double nearp, double farp); + void ortho(double left, double right, double bottom, double top, double nearp=-1.0f, double farp=1.0f); + void frustum(double left, double right, double bottom, double top, double nearp, double farp); + void copy(double * pDest) + { + memcpy(pDest, mMatrix, 16 * sizeof(double)); + } + + void copy(float * pDest) + { + for (int i = 0; i < 16; i++) + { + pDest[i] = (float)mMatrix[i]; + } + } + + void matrixToGL(int location); + void multMatrixPoint(const double *point, double *res); + + void computeNormalMatrix(const float *aMatrix); + void computeNormalMatrix(const double *aMatrix); + void computeNormalMatrix(const VSMatrix &aMatrix) + { + computeNormalMatrix(aMatrix.mMatrix); + } + + protected: + static void crossProduct(const double *a, const double *b, double *res); + static double dotProduct(const double *a, const double * b); + static void normalize(double *a); + static void subtract(const double *a, const double *b, double *res); + static void add(const double *a, const double *b, double *res); + static double length(const double *a); + static void multMatrix(double *resMatrix, const double *aMatrix); + + static void setIdentityMatrix(double *mat, int size = 4); + + /// The storage for matrices + double mMatrix[16]; + +}; + +#endif \ No newline at end of file diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 64647b670..83b630c91 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -83,6 +83,7 @@ void FRenderState::Reset() mColormapState = CM_DEFAULT; mLightParms[3] = -1.f; mSpecialEffect = EFF_NONE; + mClipHeight = 0.f; } @@ -114,12 +115,13 @@ bool FRenderState::ApplyShader() } else { + // todo: check how performance is affected by using 'discard' in a shader and if necessary create a separate set of discard-less shaders. activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4); activeShader->Bind(); } int fogset = 0; - //glColor4fv(mColor.vec); + if (mFogEnabled) { if ((mFogColor & 0xffffff) == 0) @@ -143,6 +145,7 @@ bool FRenderState::ApplyShader() activeShader->muObjectColor.Set(mObjectColor); activeShader->muDynLightColor.Set(mDynColor.vec); activeShader->muInterpolationFactor.Set(mInterpolationFactor); + activeShader->muClipHeight.Set(mClipHeight); if (mGlowEnabled) { diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index f569c3eab..6653a7c0d 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -57,6 +57,7 @@ class FRenderState int mBlendEquation; bool m2D; float mInterpolationFactor; + float mClipHeight; FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; FStateVec4 mColor; @@ -100,6 +101,16 @@ public: mCurrentVertexBuffer = NULL; } + void SetClipHeight(float clip) + { + mClipHeight = clip; + } + + float GetClipHeight() + { + return mClipHeight; + } + void SetColor(float r, float g, float b, float a = 1.f, int desat = 0) { mColor.Set(r, g, b, a); diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index a7400ec22..276679b74 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -79,6 +79,7 @@ EXTERN_CVAR(Bool, gl_noquery) EXTERN_CVAR(Int, r_mirror_recursions) TArray GLPortal::portals; +TArray GLPortal::planestack; int GLPortal::recursion; int GLPortal::MirrorFlag; int GLPortal::PlaneMirrorFlag; @@ -200,6 +201,7 @@ bool GLPortal::Start(bool usestencil, bool doquery) glStencilFunc(GL_EQUAL,recursion,~0); // create stencil glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); // increment stencil of valid pixels glColorMask(0,0,0,0); // don't write to the graphics buffer + gl_RenderState.SetEffect(EFF_STENCIL); gl_RenderState.EnableTexture(false); gl_RenderState.ResetColor(); glDepthFunc(GL_LESS); @@ -235,7 +237,8 @@ bool GLPortal::Start(bool usestencil, bool doquery) gl_RenderState.EnableTexture(true); glDepthFunc(GL_LESS); glColorMask(1,1,1,1); - glDepthRange(0,1); + gl_RenderState.SetEffect(EFF_NONE); + glDepthRange(0, 1); GLuint sampleCount; @@ -264,6 +267,7 @@ bool GLPortal::Start(bool usestencil, bool doquery) glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil gl_RenderState.EnableTexture(true); glColorMask(1,1,1,1); + gl_RenderState.SetEffect(EFF_NONE); glDisable(GL_DEPTH_TEST); glDepthMask(false); // don't write to Z-buffer! } @@ -283,9 +287,8 @@ bool GLPortal::Start(bool usestencil, bool doquery) glDisable(GL_DEPTH_TEST); } } - // The clip plane from the previous portal must be deactivated for this one. - clipsave = glIsEnabled(GL_CLIP_PLANE0+renderdepth-1); - if (clipsave) glDisable(GL_CLIP_PLANE0+renderdepth-1); + planestack.Push(gl_RenderState.GetClipHeight()); + gl_RenderState.SetClipHeight(0.f); // save viewpoint savedviewx=viewx; @@ -345,7 +348,11 @@ void GLPortal::End(bool usestencil) PortalAll.Clock(); GLRenderer->mCurrentPortal = NextPortal; - if (clipsave) glEnable (GL_CLIP_PLANE0+renderdepth-1); + + float f; + planestack.Pop(f); + gl_RenderState.SetClipHeight(f); + if (usestencil) { if (needdepth) FDrawInfo::EndDrawInfo(); @@ -360,6 +367,7 @@ void GLPortal::End(bool usestencil) GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); glColorMask(0,0,0,0); // no graphics + gl_RenderState.SetEffect(EFF_NONE); gl_RenderState.ResetColor(); gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); @@ -386,7 +394,8 @@ void GLPortal::End(bool usestencil) gl_RenderState.EnableTexture(true); - glColorMask(1,1,1,1); + gl_RenderState.SetEffect(EFF_NONE); + glColorMask(1, 1, 1, 1); recursion--; // restore old stencil op. @@ -421,8 +430,10 @@ void GLPortal::End(bool usestencil) glDepthFunc(GL_LEQUAL); glDepthRange(0,1); glColorMask(0,0,0,0); // no graphics + gl_RenderState.SetEffect(EFF_STENCIL); gl_RenderState.EnableTexture(false); DrawPortalStencil(); + gl_RenderState.SetEffect(EFF_NONE); gl_RenderState.EnableTexture(true); glColorMask(1,1,1,1); glDepthFunc(GL_LESS); @@ -778,18 +789,16 @@ void GLPlaneMirrorPortal::DrawContents() validcount++; + float f = FIXED2FLOAT(planez); + if (PlaneMirrorMode < 0) f -= 65536.f; // ceiling mirror: clip everytihng with a z lower than the portal's ceiling + else f += 65536.f; // floor mirror: clip everything with a z higher than the portal's floor + gl_RenderState.SetClipHeight(f); + PlaneMirrorFlag++; GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); ClearClipper(); - glEnable(GL_CLIP_PLANE0+renderdepth); - // This only works properly for non-sloped planes so don't bother with the math. - //double d[4]={origin->a/65536., origin->c/65536., origin->b/65536., FIXED2FLOAT(origin->d)}; - double d[4]={0, static_cast(PlaneMirrorMode), 0, FIXED2FLOAT(origin->d)}; - glClipPlane(GL_CLIP_PLANE0+renderdepth, d); - GLRenderer->DrawScene(); - glDisable(GL_CLIP_PLANE0+renderdepth); PlaneMirrorFlag--; PlaneMirrorMode=old_pm; } @@ -988,12 +997,12 @@ void GLHorizonPortal::DrawContents() gltexture->Bind(); + bool pushed = gl_SetPlaneTextureRotation(sp, gltexture); gl_RenderState.EnableAlphaTest(false); gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); gl_RenderState.Apply(); - bool pushed = gl_SetPlaneTextureRotation(sp, gltexture); float vx=FIXED2FLOAT(viewx); float vy=FIXED2FLOAT(viewy); diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 970fc3523..ccc6d174d 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -82,6 +82,7 @@ class GLPortal static int recursion; static unsigned int QueryObject; protected: + static TArray planestack; static int MirrorFlag; static int PlaneMirrorFlag; static int renderdepth; @@ -101,7 +102,6 @@ private: angle_t savedviewangle; AActor * savedviewactor; area_t savedviewarea; - unsigned char clipsave; GLPortal *NextPortal; TArray savedmapsection; TArray mPrimIndices; diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index a15d5a106..f3b483461 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -200,6 +200,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muGlowTopPlane.Init(hShader, "uGlowTopPlane"); muFixedColormap.Init(hShader, "uFixedColormap"); muInterpolationFactor.Init(hShader, "uInterpolationFactor"); + muClipHeight.Init(hShader, "uClipHeight"); timer_index = glGetUniformLocation(hShader, "timer"); lights_index = glGetUniformLocation(hShader, "lights"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 833f97fbb..eea46c8c8 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -193,6 +193,7 @@ class FShader FUniform4f muGlowBottomPlane; FUniform4f muGlowTopPlane; FBufferedUniform1f muInterpolationFactor; + FBufferedUniform1f muClipHeight; int timer_index; int lights_index; diff --git a/wadsrc/static/shaders/glsl/fogboundary.fp b/wadsrc/static/shaders/glsl/fogboundary.fp index 0d4fb9a0d..264f8e8cd 100644 --- a/wadsrc/static/shaders/glsl/fogboundary.fp +++ b/wadsrc/static/shaders/glsl/fogboundary.fp @@ -9,6 +9,12 @@ in vec2 glowdist; void main() { +#ifndef NO_DISCARD + // clip plane emulation for plane reflections. These are always perfectly horizontal so a simple check of the pixelpos's y coordinate is sufficient. + if (pixelpos.y > uClipHeight + 65536.0) discard; + if (pixelpos.y < uClipHeight - 65536.0) discard; +#endif + float fogdist; float fogfactor; diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index afd075984..467723330 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -216,6 +216,12 @@ vec4 applyFog(vec4 frag, float fogfactor) void main() { +#ifndef NO_DISCARD + // clip plane emulation for plane reflections. These are always perfectly horizontal so a simple check of the pixelpos's y coordinate is sufficient. + if (pixelpos.y > uClipHeight + 65536.0) discard; + if (pixelpos.y < uClipHeight - 65536.0) discard; +#endif + vec4 frag = ProcessTexel(); switch (uFixedColormap) diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 5a36473bf..198992fe6 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -1,6 +1,7 @@ // This file contains common data definitions for both vertex and fragment shader uniform vec4 uCameraPos; +uniform float uClipHeight; uniform int uTextureMode; diff --git a/wadsrc/static/shaders/glsl/stencil.fp b/wadsrc/static/shaders/glsl/stencil.fp index 9e4afec04..7cc579d9e 100644 --- a/wadsrc/static/shaders/glsl/stencil.fp +++ b/wadsrc/static/shaders/glsl/stencil.fp @@ -2,6 +2,12 @@ in vec4 pixelpos; void main() { +#ifndef NO_DISCARD + // clip plane emulation for plane reflections. These are always perfectly horizontal so a simple check of the pixelpos's y coordinate is sufficient. + if (pixelpos.y > uClipHeight + 65536.0) discard; + if (pixelpos.y < uClipHeight - 65536.0) discard; +#endif + gl_FragColor = vec4(1.0); } From 60dc2e112214b623562744d0918a8dd43f635d59 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 13 Jul 2014 13:01:35 +0200 Subject: [PATCH 0144/1509] - some shader fixes. --- wadsrc/static/shaders/glsl/stencil.fp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/wadsrc/static/shaders/glsl/stencil.fp b/wadsrc/static/shaders/glsl/stencil.fp index 7cc579d9e..9e4afec04 100644 --- a/wadsrc/static/shaders/glsl/stencil.fp +++ b/wadsrc/static/shaders/glsl/stencil.fp @@ -2,12 +2,6 @@ in vec4 pixelpos; void main() { -#ifndef NO_DISCARD - // clip plane emulation for plane reflections. These are always perfectly horizontal so a simple check of the pixelpos's y coordinate is sufficient. - if (pixelpos.y > uClipHeight + 65536.0) discard; - if (pixelpos.y < uClipHeight - 65536.0) discard; -#endif - gl_FragColor = vec4(1.0); } From 00fcf4bc06d1af43990bb08ca51c5fa1f3986f05 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 13 Jul 2014 13:25:42 +0200 Subject: [PATCH 0145/1509] - for some reason using world coordinates for clipping in the shader is somewhat imprecise so the clip plane heights have to be adjusted a bit for it. --- src/gl/renderer/gl_renderstate.cpp | 6 ++++-- src/gl/renderer/gl_renderstate.h | 20 +++++++++++++++----- src/gl/scene/gl_portal.cpp | 16 ++++++++++------ src/gl/shaders/gl_shader.cpp | 22 +++++++++++++++------- src/gl/shaders/gl_shader.h | 5 +++-- wadsrc/static/shaders/glsl/fogboundary.fp | 4 ++-- wadsrc/static/shaders/glsl/main.fp | 4 ++-- wadsrc/static/shaders/glsl/shaderdefs.i | 2 +- 8 files changed, 52 insertions(+), 27 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 83b630c91..6a510f85a 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -83,7 +83,8 @@ void FRenderState::Reset() mColormapState = CM_DEFAULT; mLightParms[3] = -1.f; mSpecialEffect = EFF_NONE; - mClipHeight = 0.f; + mClipHeightTop = 65536.f; + mClipHeightBottom = -65536.f; } @@ -145,7 +146,8 @@ bool FRenderState::ApplyShader() activeShader->muObjectColor.Set(mObjectColor); activeShader->muDynLightColor.Set(mDynColor.vec); activeShader->muInterpolationFactor.Set(mInterpolationFactor); - activeShader->muClipHeight.Set(mClipHeight); + activeShader->muClipHeightTop.Set(mClipHeightTop); + activeShader->muClipHeightBottom.Set(mClipHeightBottom); if (mGlowEnabled) { diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 6653a7c0d..815974d97 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -57,7 +57,7 @@ class FRenderState int mBlendEquation; bool m2D; float mInterpolationFactor; - float mClipHeight; + float mClipHeightTop, mClipHeightBottom; FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; FStateVec4 mColor; @@ -101,14 +101,24 @@ public: mCurrentVertexBuffer = NULL; } - void SetClipHeight(float clip) + void SetClipHeightTop(float clip) { - mClipHeight = clip; + mClipHeightTop = clip; } - float GetClipHeight() + float GetClipHeightTop() { - return mClipHeight; + return mClipHeightTop; + } + + void SetClipHeightBottom(float clip) + { + mClipHeightBottom = clip; + } + + float GetClipHeightBottom() + { + return mClipHeightBottom; } void SetColor(float r, float g, float b, float a = 1.f, int desat = 0) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 276679b74..28b9a1282 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -287,8 +287,10 @@ bool GLPortal::Start(bool usestencil, bool doquery) glDisable(GL_DEPTH_TEST); } } - planestack.Push(gl_RenderState.GetClipHeight()); - gl_RenderState.SetClipHeight(0.f); + planestack.Push(gl_RenderState.GetClipHeightTop()); + planestack.Push(gl_RenderState.GetClipHeightBottom()); + gl_RenderState.SetClipHeightTop(65536.f); + gl_RenderState.SetClipHeightBottom(-65536.f); // save viewpoint savedviewx=viewx; @@ -351,7 +353,9 @@ void GLPortal::End(bool usestencil) float f; planestack.Pop(f); - gl_RenderState.SetClipHeight(f); + gl_RenderState.SetClipHeightBottom(f); + planestack.Pop(f); + gl_RenderState.SetClipHeightTop(f); if (usestencil) { @@ -790,9 +794,9 @@ void GLPlaneMirrorPortal::DrawContents() validcount++; float f = FIXED2FLOAT(planez); - if (PlaneMirrorMode < 0) f -= 65536.f; // ceiling mirror: clip everytihng with a z lower than the portal's ceiling - else f += 65536.f; // floor mirror: clip everything with a z higher than the portal's floor - gl_RenderState.SetClipHeight(f); + // the coordinate fudging is needed because for some reason this is nowhere near precise and leaves gaps. Strange... + if (PlaneMirrorMode < 0) gl_RenderState.SetClipHeightTop(f+0.3f); // ceiling mirror: clip everytihng with a z lower than the portal's ceiling + else gl_RenderState.SetClipHeightBottom(f-0.3f); // floor mirror: clip everything with a z higher than the portal's floor PlaneMirrorFlag++; GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index f3b483461..50b67c4ca 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -200,7 +200,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muGlowTopPlane.Init(hShader, "uGlowTopPlane"); muFixedColormap.Init(hShader, "uFixedColormap"); muInterpolationFactor.Init(hShader, "uInterpolationFactor"); - muClipHeight.Init(hShader, "uClipHeight"); + muClipHeightTop.Init(hShader, "uClipHeightTop"); + muClipHeightBottom.Init(hShader, "uClipHeightBottom"); timer_index = glGetUniformLocation(hShader, "timer"); lights_index = glGetUniformLocation(hShader, "lights"); @@ -249,16 +250,18 @@ bool FShader::Bind() // //========================================================================== -FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath) +FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath, bool usediscard) { + FString defines; // this can't be in the shader code due to ATI strangeness. - const char *str = (gl.MaxLights() == 128)? "#define MAXLIGHTS128\n" : ""; + if (gl.MaxLights() == 128) defines += "#define MAXLIGHTS128\n"; + if (!usediscard) defines += "#define NO_DISCARD\n"; FShader *shader = NULL; try { shader = new FShader(ShaderName); - if (!shader->Load(ShaderName, "shaders/glsl/main.vp", "shaders/glsl/main.fp", ShaderPath, str)) + if (!shader->Load(ShaderName, "shaders/glsl/main.vp", "shaders/glsl/main.fp", ShaderPath, defines.GetChars())) { I_FatalError("Unable to load shader %s\n", ShaderName); } @@ -352,11 +355,16 @@ FShaderManager::~FShaderManager() void FShaderManager::CompileShaders() { - mActiveShader = mEffectShaders[0] = mEffectShaders[1] = NULL; + mActiveShader = NULL; + + for (int i = 0; i < MAX_EFFECTS; i++) + { + mEffectShaders[i] = NULL; + } for(int i=0;defaultshaders[i].ShaderName != NULL;i++) { - FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc); + FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, true); mTextureEffects.Push(shc); } @@ -365,7 +373,7 @@ void FShaderManager::CompileShaders() FString name = ExtractFileBase(usershaders[i]); FName sfn = name; - FShader *shc = Compile(sfn, usershaders[i]); + FShader *shc = Compile(sfn, usershaders[i], true); mTextureEffects.Push(shc); } diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index eea46c8c8..da3be18cb 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -193,7 +193,8 @@ class FShader FUniform4f muGlowBottomPlane; FUniform4f muGlowTopPlane; FBufferedUniform1f muInterpolationFactor; - FBufferedUniform1f muClipHeight; + FBufferedUniform1f muClipHeightTop; + FBufferedUniform1f muClipHeightBottom; int timer_index; int lights_index; @@ -244,7 +245,7 @@ class FShaderManager public: FShaderManager(); ~FShaderManager(); - FShader *Compile(const char *ShaderName, const char *ShaderPath); + FShader *Compile(const char *ShaderName, const char *ShaderPath, bool usediscard); int Find(const char *mame); FShader *BindEffect(int effect); void SetActiveShader(FShader *sh); diff --git a/wadsrc/static/shaders/glsl/fogboundary.fp b/wadsrc/static/shaders/glsl/fogboundary.fp index 264f8e8cd..edf9384c6 100644 --- a/wadsrc/static/shaders/glsl/fogboundary.fp +++ b/wadsrc/static/shaders/glsl/fogboundary.fp @@ -11,8 +11,8 @@ void main() { #ifndef NO_DISCARD // clip plane emulation for plane reflections. These are always perfectly horizontal so a simple check of the pixelpos's y coordinate is sufficient. - if (pixelpos.y > uClipHeight + 65536.0) discard; - if (pixelpos.y < uClipHeight - 65536.0) discard; + if (pixelpos.y > uClipHeightTop) discard; + if (pixelpos.y < uClipHeightBottom) discard; #endif float fogdist; diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 467723330..5655493bd 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -218,8 +218,8 @@ void main() { #ifndef NO_DISCARD // clip plane emulation for plane reflections. These are always perfectly horizontal so a simple check of the pixelpos's y coordinate is sufficient. - if (pixelpos.y > uClipHeight + 65536.0) discard; - if (pixelpos.y < uClipHeight - 65536.0) discard; + if (pixelpos.y > uClipHeightTop) discard; + if (pixelpos.y < uClipHeightBottom) discard; #endif vec4 frag = ProcessTexel(); diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 198992fe6..d281ee231 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -1,7 +1,7 @@ // This file contains common data definitions for both vertex and fragment shader uniform vec4 uCameraPos; -uniform float uClipHeight; +uniform float uClipHeightTop, uClipHeightBottom; uniform int uTextureMode; From 9230a20f18a22d7880813dd045854e02e57dcee2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 13 Jul 2014 17:15:17 +0200 Subject: [PATCH 0146/1509] - added some checks to the wall rendering code that will allow to disable the clip planes in many cases, even when a plane mirror portal is active. This also solves the precision issue with using world coordinates for clip checks. --- src/gl/scene/gl_portal.cpp | 5 ++--- src/gl/scene/gl_walls_draw.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 28b9a1282..c0fee3385 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -794,9 +794,8 @@ void GLPlaneMirrorPortal::DrawContents() validcount++; float f = FIXED2FLOAT(planez); - // the coordinate fudging is needed because for some reason this is nowhere near precise and leaves gaps. Strange... - if (PlaneMirrorMode < 0) gl_RenderState.SetClipHeightTop(f+0.3f); // ceiling mirror: clip everytihng with a z lower than the portal's ceiling - else gl_RenderState.SetClipHeightBottom(f-0.3f); // floor mirror: clip everything with a z higher than the portal's floor + if (PlaneMirrorMode < 0) gl_RenderState.SetClipHeightTop(f); // ceiling mirror: clip everytihng with a z lower than the portal's ceiling + else gl_RenderState.SetClipHeightBottom(f); // floor mirror: clip everything with a z higher than the portal's floor PlaneMirrorFlag++; GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 8e3a4b955..aabec775e 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -225,7 +225,7 @@ void GLWall::SetupLights() void GLWall::RenderWall(int textured, ADynamicLight * light, unsigned int *store) { - texcoord tcs[4]; + static texcoord tcs[4]; // making this variable static saves us a relatively costly stack integrity check. bool split = (gl_seamless && !(textured&RWF_NOSPLIT) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ)); if (!light) @@ -249,7 +249,14 @@ void GLWall::RenderWall(int textured, ADynamicLight * light, unsigned int *store if (!(textured & RWF_NORENDER)) { + // disable the clip plane if it isn't needed (which can be determined by a simple check.) + float ct = gl_RenderState.GetClipHeightTop(); + float cb = gl_RenderState.GetClipHeightBottom(); + if (ztop[0] <= ct && ztop[1] <= ct) gl_RenderState.SetClipHeightTop(65536.f); + if (zbottom[0] >= cb && zbottom[1] >= cb) gl_RenderState.SetClipHeightBottom(-65536.f); gl_RenderState.Apply(); + gl_RenderState.SetClipHeightTop(ct); + gl_RenderState.SetClipHeightBottom(cb); } // the rest of the code is identical for textured rendering and lights From dbb05c5f339d6e7ca40bfbfe19f96e4709c8b707 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 13 Jul 2014 20:41:20 +0200 Subject: [PATCH 0147/1509] - remove use of builtin texture matrices. - make matrix class single precision. --- src/gl/data/gl_matrix.cpp | 124 +++++++++++++----------- src/gl/data/gl_matrix.h | 63 +++++++----- src/gl/models/gl_models.cpp | 56 +++-------- src/gl/renderer/gl_renderstate.cpp | 23 +++++ src/gl/renderer/gl_renderstate.h | 20 ++++ src/gl/scene/gl_drawinfo.cpp | 9 +- src/gl/scene/gl_drawinfo.h | 2 +- src/gl/scene/gl_flats.cpp | 32 +++--- src/gl/scene/gl_portal.cpp | 9 +- src/gl/scene/gl_scene.cpp | 8 -- src/gl/scene/gl_skydome.cpp | 13 +-- src/gl/shaders/gl_shader.cpp | 2 + src/gl/shaders/gl_shader.h | 6 ++ wadsrc/static/shaders/glsl/shaderdefs.i | 6 +- 14 files changed, 198 insertions(+), 175 deletions(-) diff --git a/src/gl/data/gl_matrix.cpp b/src/gl/data/gl_matrix.cpp index 589cfb8cc..c92f43c26 100644 --- a/src/gl/data/gl_matrix.cpp +++ b/src/gl/data/gl_matrix.cpp @@ -18,16 +18,16 @@ This is a simplified version of VSMatrix that has been adjusted for GZDoom's nee #include "doomtype.h" #include "gl/data/gl_matrix.h" -static inline double -DegToRad(double degrees) +static inline FLOATTYPE +DegToRad(FLOATTYPE degrees) { - return (double)(degrees * (M_PI / 180.0f)); + return (FLOATTYPE)(degrees * (M_PI / 180.0f)); }; // sets the square matrix mat to the identity matrix, // size refers to the number of rows (or columns) void -VSMatrix::setIdentityMatrix( double *mat, int size) { +VSMatrix::setIdentityMatrix( FLOATTYPE *mat, int size) { // fill matrix with 0s for (int i = 0; i < size * size; ++i) @@ -56,10 +56,10 @@ VSMatrix::loadIdentity() // glMultMatrix implementation void -VSMatrix::multMatrix(const double *aMatrix) +VSMatrix::multMatrix(const FLOATTYPE *aMatrix) { - double res[16]; + FLOATTYPE res[16]; for (int i = 0; i < 4; ++i) { @@ -72,15 +72,16 @@ VSMatrix::multMatrix(const double *aMatrix) } } } - memcpy(mMatrix, res, 16 * sizeof(double)); + memcpy(mMatrix, res, 16 * sizeof(FLOATTYPE)); } +#ifdef USE_DOUBLE // glMultMatrix implementation void VSMatrix::multMatrix(const float *aMatrix) { - double res[16]; + FLOATTYPE res[16]; for (int i = 0; i < 4; ++i) { @@ -93,18 +94,20 @@ VSMatrix::multMatrix(const float *aMatrix) } } } - memcpy(mMatrix, res, 16 * sizeof(double)); + memcpy(mMatrix, res, 16 * sizeof(FLOATTYPE)); } +#endif // glLoadMatrix implementation void -VSMatrix::loadMatrix(const double *aMatrix) +VSMatrix::loadMatrix(const FLOATTYPE *aMatrix) { - memcpy(mMatrix, aMatrix, 16 * sizeof(double)); + memcpy(mMatrix, aMatrix, 16 * sizeof(FLOATTYPE)); } +#ifdef USE_DOUBLE // glLoadMatrix implementation void VSMatrix::loadMatrix(const float *aMatrix) @@ -114,13 +117,14 @@ VSMatrix::loadMatrix(const float *aMatrix) mMatrix[i] = aMatrix[i]; } } +#endif // gl Translate implementation with matrix selection void -VSMatrix::translate(double x, double y, double z) +VSMatrix::translate(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) { - double mat[16]; + FLOATTYPE mat[16]; setIdentityMatrix(mat); mat[12] = x; @@ -133,9 +137,9 @@ VSMatrix::translate(double x, double y, double z) // gl Scale implementation with matrix selection void -VSMatrix::scale(double x, double y, double z) +VSMatrix::scale(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) { - double mat[16]; + FLOATTYPE mat[16]; setIdentityMatrix(mat,4); mat[0] = x; @@ -148,22 +152,22 @@ VSMatrix::scale(double x, double y, double z) // gl Rotate implementation with matrix selection void -VSMatrix::rotate(double angle, double x, double y, double z) +VSMatrix::rotate(FLOATTYPE angle, FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) { - double mat[16]; - double v[3]; + FLOATTYPE mat[16]; + FLOATTYPE v[3]; v[0] = x; v[1] = y; v[2] = z; - double radAngle = DegToRad(angle); - double co = cos(radAngle); - double si = sin(radAngle); + FLOATTYPE radAngle = DegToRad(angle); + FLOATTYPE co = cos(radAngle); + FLOATTYPE si = sin(radAngle); normalize(v); - double x2 = v[0]*v[0]; - double y2 = v[1]*v[1]; - double z2 = v[2]*v[2]; + FLOATTYPE x2 = v[0]*v[0]; + FLOATTYPE y2 = v[1]*v[1]; + FLOATTYPE z2 = v[2]*v[2]; // mat[0] = x2 + (y2 + z2) * co; mat[0] = co + x2 * (1 - co);// + (y2 + z2) * co; @@ -194,11 +198,11 @@ VSMatrix::rotate(double angle, double x, double y, double z) // gluLookAt implementation void -VSMatrix::lookAt(double xPos, double yPos, double zPos, - double xLook, double yLook, double zLook, - double xUp, double yUp, double zUp) +VSMatrix::lookAt(FLOATTYPE xPos, FLOATTYPE yPos, FLOATTYPE zPos, + FLOATTYPE xLook, FLOATTYPE yLook, FLOATTYPE zLook, + FLOATTYPE xUp, FLOATTYPE yUp, FLOATTYPE zUp) { - double dir[3], right[3], up[3]; + FLOATTYPE dir[3], right[3], up[3]; up[0] = xUp; up[1] = yUp; up[2] = zUp; @@ -213,7 +217,7 @@ VSMatrix::lookAt(double xPos, double yPos, double zPos, crossProduct(right,dir,up); normalize(up); - double m1[16],m2[16]; + FLOATTYPE m1[16],m2[16]; m1[0] = right[0]; m1[4] = right[1]; @@ -247,11 +251,11 @@ VSMatrix::lookAt(double xPos, double yPos, double zPos, // gluPerspective implementation void -VSMatrix::perspective(double fov, double ratio, double nearp, double farp) +VSMatrix::perspective(FLOATTYPE fov, FLOATTYPE ratio, FLOATTYPE nearp, FLOATTYPE farp) { - double projMatrix[16]; + FLOATTYPE projMatrix[16]; - double f = 1.0f / tan (fov * (M_PI / 360.0f)); + FLOATTYPE f = 1.0f / tan (fov * (M_PI / 360.0f)); setIdentityMatrix(projMatrix,4); @@ -268,11 +272,11 @@ VSMatrix::perspective(double fov, double ratio, double nearp, double farp) // glOrtho implementation void -VSMatrix::ortho(double left, double right, - double bottom, double top, - double nearp, double farp) +VSMatrix::ortho(FLOATTYPE left, FLOATTYPE right, + FLOATTYPE bottom, FLOATTYPE top, + FLOATTYPE nearp, FLOATTYPE farp) { - double m[16]; + FLOATTYPE m[16]; setIdentityMatrix(m,4); @@ -289,11 +293,11 @@ VSMatrix::ortho(double left, double right, // glFrustum implementation void -VSMatrix::frustum(double left, double right, - double bottom, double top, - double nearp, double farp) +VSMatrix::frustum(FLOATTYPE left, FLOATTYPE right, + FLOATTYPE bottom, FLOATTYPE top, + FLOATTYPE nearp, FLOATTYPE farp) { - double m[16]; + FLOATTYPE m[16]; setIdentityMatrix(m,4); @@ -312,7 +316,7 @@ VSMatrix::frustum(double left, double right, /* // returns a pointer to the requested matrix -double * +FLOATTYPE * VSMatrix::get(MatrixTypes aType) { return mMatrix[aType]; @@ -331,9 +335,13 @@ VSMatrix::get(MatrixTypes aType) void VSMatrix::matrixToGL(int loc) { +#ifdef USE_DOUBLE float copyto[16]; copy(copyto); glUniformMatrix4fv(loc, 1, false, copyto); +#else + glUniformMatrix4fv(loc, 1, false, mMatrix); +#endif } // ----------------------------------------------------- @@ -343,7 +351,7 @@ VSMatrix::matrixToGL(int loc) // Compute res = M * point void -VSMatrix::multMatrixPoint(const double *point, double *res) +VSMatrix::multMatrixPoint(const FLOATTYPE *point, FLOATTYPE *res) { for (int i = 0; i < 4; ++i) @@ -360,7 +368,7 @@ VSMatrix::multMatrixPoint(const double *point, double *res) // res = a cross b; void -VSMatrix::crossProduct(const double *a, const double *b, double *res) { +VSMatrix::crossProduct(const FLOATTYPE *a, const FLOATTYPE *b, FLOATTYPE *res) { res[0] = a[1] * b[2] - b[1] * a[2]; res[1] = a[2] * b[0] - b[2] * a[0]; @@ -369,10 +377,10 @@ VSMatrix::crossProduct(const double *a, const double *b, double *res) { // returns a . b -double -VSMatrix::dotProduct(const double *a, const double *b) { +FLOATTYPE +VSMatrix::dotProduct(const FLOATTYPE *a, const FLOATTYPE *b) { - double res = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; + FLOATTYPE res = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; return res; } @@ -380,9 +388,9 @@ VSMatrix::dotProduct(const double *a, const double *b) { // Normalize a vec3 void -VSMatrix::normalize(double *a) { +VSMatrix::normalize(FLOATTYPE *a) { - double mag = sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); + FLOATTYPE mag = sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); a[0] /= mag; a[1] /= mag; @@ -392,7 +400,7 @@ VSMatrix::normalize(double *a) { // res = b - a void -VSMatrix::subtract(const double *a, const double *b, double *res) { +VSMatrix::subtract(const FLOATTYPE *a, const FLOATTYPE *b, FLOATTYPE *res) { res[0] = b[0] - a[0]; res[1] = b[1] - a[1]; @@ -402,7 +410,7 @@ VSMatrix::subtract(const double *a, const double *b, double *res) { // res = a + b void -VSMatrix::add(const double *a, const double *b, double *res) { +VSMatrix::add(const FLOATTYPE *a, const FLOATTYPE *b, FLOATTYPE *res) { res[0] = b[0] + a[0]; res[1] = b[1] + a[1]; @@ -411,8 +419,8 @@ VSMatrix::add(const double *a, const double *b, double *res) { // returns |a| -double -VSMatrix::length(const double *a) { +FLOATTYPE +VSMatrix::length(const FLOATTYPE *a) { return(sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])); @@ -429,10 +437,10 @@ M3(int i, int j) // computes the derived normal matrix for the view matrix void -VSMatrix::computeNormalMatrix(const double *aMatrix) +VSMatrix::computeNormalMatrix(const FLOATTYPE *aMatrix) { - double mMat3x3[9]; + FLOATTYPE mMat3x3[9]; mMat3x3[0] = aMatrix[0]; mMat3x3[1] = aMatrix[1]; @@ -446,7 +454,7 @@ VSMatrix::computeNormalMatrix(const double *aMatrix) mMat3x3[7] = aMatrix[9]; mMat3x3[8] = aMatrix[10]; - double det, invDet; + FLOATTYPE det, invDet; det = mMat3x3[0] * (mMat3x3[4] * mMat3x3[8] - mMat3x3[5] * mMat3x3[7]) + mMat3x3[1] * (mMat3x3[5] * mMat3x3[6] - mMat3x3[8] * mMat3x3[3]) + @@ -476,10 +484,10 @@ VSMatrix::computeNormalMatrix(const double *aMatrix) // aux function resMat = resMat * aMatrix void -VSMatrix::multMatrix(double *resMat, const double *aMatrix) +VSMatrix::multMatrix(FLOATTYPE *resMat, const FLOATTYPE *aMatrix) { - double res[16]; + FLOATTYPE res[16]; for (int i = 0; i < 4; ++i) { @@ -492,5 +500,5 @@ VSMatrix::multMatrix(double *resMat, const double *aMatrix) } } } - memcpy(resMat, res, 16 * sizeof(double)); + memcpy(resMat, res, 16 * sizeof(FLOATTYPE)); } diff --git a/src/gl/data/gl_matrix.h b/src/gl/data/gl_matrix.h index 1ccbc5c37..de4b400da 100644 --- a/src/gl/data/gl_matrix.h +++ b/src/gl/data/gl_matrix.h @@ -22,6 +22,12 @@ #include +#ifdef USE_DOUBLE +typedef double FLOATTYPE; +#else +typedef float FLOATTYPE; +#endif + class VSMatrix { public: @@ -35,27 +41,32 @@ class VSMatrix { loadIdentity(); } - void translate(double x, double y, double z); - void scale(double x, double y, double z); - void rotate(double angle, double x, double y, double z); + void translate(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z); + void scale(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z); + void rotate(FLOATTYPE angle, FLOATTYPE x, FLOATTYPE y, FLOATTYPE z); void loadIdentity(); +#ifdef USE_DOUBLE void multMatrix(const float *aMatrix); - void multMatrix(const double *aMatrix); +#endif + void multMatrix(const FLOATTYPE *aMatrix); void multMatrix(const VSMatrix &aMatrix) { multMatrix(aMatrix.mMatrix); } - void loadMatrix(const double *aMatrix); + void loadMatrix(const FLOATTYPE *aMatrix); +#ifdef USE_DOUBLE void loadMatrix(const float *aMatrix); - void lookAt(double xPos, double yPos, double zPos, double xLook, double yLook, double zLook, double xUp, double yUp, double zUp); - void perspective(double fov, double ratio, double nearp, double farp); - void ortho(double left, double right, double bottom, double top, double nearp=-1.0f, double farp=1.0f); - void frustum(double left, double right, double bottom, double top, double nearp, double farp); - void copy(double * pDest) +#endif + void lookAt(FLOATTYPE xPos, FLOATTYPE yPos, FLOATTYPE zPos, FLOATTYPE xLook, FLOATTYPE yLook, FLOATTYPE zLook, FLOATTYPE xUp, FLOATTYPE yUp, FLOATTYPE zUp); + void perspective(FLOATTYPE fov, FLOATTYPE ratio, FLOATTYPE nearp, FLOATTYPE farp); + void ortho(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, FLOATTYPE nearp=-1.0f, FLOATTYPE farp=1.0f); + void frustum(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, FLOATTYPE nearp, FLOATTYPE farp); + void copy(FLOATTYPE * pDest) { - memcpy(pDest, mMatrix, 16 * sizeof(double)); + memcpy(pDest, mMatrix, 16 * sizeof(FLOATTYPE)); } +#ifdef USE_DOUBLE void copy(float * pDest) { for (int i = 0; i < 16; i++) @@ -63,30 +74,38 @@ class VSMatrix { pDest[i] = (float)mMatrix[i]; } } +#endif + + const FLOATTYPE *get() const + { + return mMatrix; + } void matrixToGL(int location); - void multMatrixPoint(const double *point, double *res); + void multMatrixPoint(const FLOATTYPE *point, FLOATTYPE *res); +#ifdef USE_DOUBLE void computeNormalMatrix(const float *aMatrix); - void computeNormalMatrix(const double *aMatrix); +#endif + void computeNormalMatrix(const FLOATTYPE *aMatrix); void computeNormalMatrix(const VSMatrix &aMatrix) { computeNormalMatrix(aMatrix.mMatrix); } protected: - static void crossProduct(const double *a, const double *b, double *res); - static double dotProduct(const double *a, const double * b); - static void normalize(double *a); - static void subtract(const double *a, const double *b, double *res); - static void add(const double *a, const double *b, double *res); - static double length(const double *a); - static void multMatrix(double *resMatrix, const double *aMatrix); + static void crossProduct(const FLOATTYPE *a, const FLOATTYPE *b, FLOATTYPE *res); + static FLOATTYPE dotProduct(const FLOATTYPE *a, const FLOATTYPE * b); + static void normalize(FLOATTYPE *a); + static void subtract(const FLOATTYPE *a, const FLOATTYPE *b, FLOATTYPE *res); + static void add(const FLOATTYPE *a, const FLOATTYPE *b, FLOATTYPE *res); + static FLOATTYPE length(const FLOATTYPE *a); + static void multMatrix(FLOATTYPE *resMatrix, const FLOATTYPE *aMatrix); - static void setIdentityMatrix(double *mat, int size = 4); + static void setIdentityMatrix(FLOATTYPE *mat, int size = 4); /// The storage for matrices - double mMatrix[16]; + FLOATTYPE mMatrix[16]; }; diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 67ec241e3..adec46570 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -806,65 +806,41 @@ void gl_RenderModel(GLSprite * spr) // This is rather crappy way to transfer fixet_t type into angle in degrees, but its works! if(smf->flags & MDL_INHERITACTORPITCH) pitch += float(static_cast(spr->actor->pitch >> 16) / (1 << 13) * 45 + static_cast(spr->actor->pitch & 0x0000FFFF) / (1 << 29) * 45); if(smf->flags & MDL_INHERITACTORROLL) roll += float(static_cast(spr->actor->roll >> 16) / (1 << 13) * 45 + static_cast(spr->actor->roll & 0x0000FFFF) / (1 << 29) * 45); - - glActiveTexture(GL_TEXTURE7); // Hijack the otherwise unused seventh texture matrix for the model to world transformation. - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); + + gl_RenderState.mModelMatrix.loadIdentity(); // Model space => World space - glTranslatef(spr->x, spr->z, spr->y ); + gl_RenderState.mModelMatrix.translate(spr->x, spr->z, spr->y ); // Applying model transformations: // 1) Applying actor angle, pitch and roll to the model - glRotatef(-angle, 0, 1, 0); - glRotatef(pitch, 0, 0, 1); - glRotatef(-roll, 1, 0, 0); + gl_RenderState.mModelMatrix.rotate(-angle, 0, 1, 0); + gl_RenderState.mModelMatrix.rotate(pitch, 0, 0, 1); + gl_RenderState.mModelMatrix.rotate(-roll, 1, 0, 0); // 2) Applying Doomsday like rotation of the weapon pickup models // The rotation angle is based on the elapsed time. if( smf->flags & MDL_ROTATING ) { - glTranslatef(smf->rotationCenterX, smf->rotationCenterY, smf->rotationCenterZ); - glRotatef(rotateOffset, smf->xrotate, smf->yrotate, smf->zrotate); - glTranslatef(-smf->rotationCenterX, -smf->rotationCenterY, -smf->rotationCenterZ); + gl_RenderState.mModelMatrix.translate(smf->rotationCenterX, smf->rotationCenterY, smf->rotationCenterZ); + gl_RenderState.mModelMatrix.rotate(rotateOffset, smf->xrotate, smf->yrotate, smf->zrotate); + gl_RenderState.mModelMatrix.translate(-smf->rotationCenterX, -smf->rotationCenterY, -smf->rotationCenterZ); } // 3) Scaling model. - glScalef(scaleFactorX, scaleFactorZ, scaleFactorY); + gl_RenderState.mModelMatrix.scale(scaleFactorX, scaleFactorZ, scaleFactorY); // 4) Aplying model offsets (model offsets do not depend on model scalings). - glTranslatef(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); + gl_RenderState.mModelMatrix.translate(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); // 5) Applying model rotations. - glRotatef(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); - glRotatef(smf->pitchoffset, 0, 0, 1); - glRotatef(-smf->rolloffset, 1, 0, 0); - - glActiveTexture(GL_TEXTURE0); - -#if 0 - if (gl_light_models) - { - // The normal transform matrix only contains the inverse rotations and scalings but not the translations - NormalTransform.MakeIdentity(); - - NormalTransform.Scale(1.f/scaleFactorX, 1.f/scaleFactorZ, 1.f/scaleFactorY); - if( smf->flags & MDL_ROTATING ) NormalTransform.Rotate(smf->xrotate, smf->yrotate, smf->zrotate, -rotateOffset); - if (pitch != 0) NormalTransform.Rotate(0,0,1,-pitch); - if (angle != 0) NormalTransform.Rotate(0,1,0, angle); - - gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), &ModelToWorld, &NormalTransform, translation ); - } -#endif - + gl_RenderState.mModelMatrix.rotate(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); + gl_RenderState.mModelMatrix.rotate(smf->pitchoffset, 0, 0, 1); + gl_RenderState.mModelMatrix.rotate(-smf->rolloffset, 1, 0, 0); + gl_RenderState.EnableModelMatrix(true); gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), NULL, translation ); - - glActiveTexture(GL_TEXTURE7); - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - glActiveTexture(GL_TEXTURE0); - glMatrixMode(GL_MODELVIEW); + gl_RenderState.EnableModelMatrix(false); glDepthFunc(GL_LESS); if (!( spr->actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 6a510f85a..6f7382c91 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -56,6 +56,8 @@ FRenderState gl_RenderState; CVAR(Bool, gl_direct_state_change, true, 0) +static VSMatrix identityMatrix(1); + //========================================================================== // // @@ -225,6 +227,27 @@ bool FRenderState::ApplyShader() activeShader->muColormapStart.Set(r, g, b, 1.f); } } + if (mTextureMatrixEnabled) + { + mTextureMatrix.matrixToGL(activeShader->texturematrix_index); + activeShader->currentTextureMatrixState = true; + } + else if (activeShader->currentTextureMatrixState) + { + activeShader->currentTextureMatrixState = false; + identityMatrix.matrixToGL(activeShader->texturematrix_index); + } + + if (mModelMatrixEnabled) + { + mModelMatrix.matrixToGL(activeShader->modelmatrix_index); + activeShader->currentModelMatrixState = true; + } + else if (activeShader->currentModelMatrixState) + { + activeShader->currentModelMatrixState = false; + identityMatrix.matrixToGL(activeShader->modelmatrix_index); + } return true; } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 815974d97..6c2965e22 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -4,6 +4,7 @@ #include #include "gl/system/gl_interface.h" #include "gl/data/gl_data.h" +#include "gl/data/gl_matrix.h" #include "c_cvars.h" #include "r_defs.h" @@ -58,6 +59,8 @@ class FRenderState bool m2D; float mInterpolationFactor; float mClipHeightTop, mClipHeightBottom; + bool mModelMatrixEnabled; + bool mTextureMatrixEnabled; FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; FStateVec4 mColor; @@ -80,6 +83,12 @@ class FRenderState bool ApplyShader(); public: + + VSMatrix mProjectionMatrix; + VSMatrix mViewMatrix; + VSMatrix mModelMatrix; + VSMatrix mTextureMatrix; + FRenderState() { Reset(); @@ -89,6 +98,7 @@ public: void SetupShader(int &shaderindex, float warptime); void Apply(); + void ApplyMatrices(); void SetVertexBuffer(FVertexBuffer *vb) { @@ -180,6 +190,16 @@ public: mBrightmapEnabled = on; } + void EnableModelMatrix(bool on) + { + mModelMatrixEnabled = on; + } + + void EnableTextureMatrix(bool on) + { + mTextureMatrixEnabled = on; + } + void SetCameraPos(float x, float y, float z) { mCameraPos.Set(x, z, y, 0); diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 7dcf6319e..cac3bad6a 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -1083,10 +1083,9 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo float fviewy = FIXED2FLOAT(viewy); float fviewz = FIXED2FLOAT(viewz); + gl_SetPlaneTextureRotation(&plane, gltexture); gl_RenderState.Apply(); - bool pushed = gl_SetPlaneTextureRotation(&plane, gltexture); - float prj_fac1 = (planez-fviewz)/(ws->z1-fviewz); float prj_fac2 = (planez-fviewz)/(ws->z2-fviewz); @@ -1113,11 +1112,7 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo ptr++; GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); - if (pushed) - { - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - } + gl_RenderState.EnableTextureMatrix(false); } //========================================================================== diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index 07735eb3f..01a72701b 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -273,7 +273,7 @@ public: extern FDrawInfo * gl_drawinfo; -bool gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * gltexture); +void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * gltexture); void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending); #endif \ No newline at end of file diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 9f0195307..6b449ded3 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -70,7 +70,7 @@ // //========================================================================== -bool gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * gltexture) +void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * gltexture) { // only manipulate the texture matrix if needed. if (secplane->xoffs != 0 || secplane->yoffs != 0 || @@ -93,15 +93,13 @@ bool gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * glte float xscale2=64.f/gltexture->TextureWidth(GLUSE_TEXTURE); float yscale2=64.f/gltexture->TextureHeight(GLUSE_TEXTURE); - glMatrixMode(GL_TEXTURE); - glPushMatrix(); - glScalef(xscale1 ,yscale1,1.0f); - glTranslatef(uoffs,voffs,0.0f); - glScalef(xscale2 ,yscale2,1.0f); - glRotatef(angle,0.0f,0.0f,1.0f); - return true; + gl_RenderState.mTextureMatrix.loadIdentity(); + gl_RenderState.mTextureMatrix.scale(xscale1 ,yscale1,1.0f); + gl_RenderState.mTextureMatrix.translate(uoffs,voffs,0.0f); + gl_RenderState.mTextureMatrix.scale(xscale2 ,yscale2,1.0f); + gl_RenderState.mTextureMatrix.rotate(angle,0.0f,0.0f,1.0f); + gl_RenderState.EnableTextureMatrix(true); } - return false; } @@ -377,13 +375,9 @@ void GLFlat::Draw(int pass) case GLPASS_TEXTURE: { gltexture->Bind(); - bool pushed = gl_SetPlaneTextureRotation(&plane, gltexture); + gl_SetPlaneTextureRotation(&plane, gltexture); DrawSubsectors(pass, false); - if (pushed) - { - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - } + gl_RenderState.EnableTextureMatrix(false); break; } @@ -440,13 +434,9 @@ void GLFlat::Draw(int pass) else { gltexture->Bind(); - bool pushed = gl_SetPlaneTextureRotation(&plane, gltexture); + gl_SetPlaneTextureRotation(&plane, gltexture); DrawSubsectors(pass, true); - if (pushed) - { - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - } + gl_RenderState.EnableTextureMatrix(false); } if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); break; diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index c0fee3385..557fbd106 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -1000,7 +1000,7 @@ void GLHorizonPortal::DrawContents() gltexture->Bind(); - bool pushed = gl_SetPlaneTextureRotation(sp, gltexture); + gl_SetPlaneTextureRotation(sp, gltexture); gl_RenderState.EnableAlphaTest(false); gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); gl_RenderState.Apply(); @@ -1059,12 +1059,7 @@ void GLHorizonPortal::DrawContents() ptr++; GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - if (pushed) - { - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - } - + gl_RenderState.EnableTextureMatrix(false); PortalAll.Unclock(); } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index d013d7b30..e93df197c 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -286,14 +286,6 @@ void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) void FGLRenderer::SetViewMatrix(bool mirror, bool planemirror) { - glActiveTexture(GL_TEXTURE7); - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - - glActiveTexture(GL_TEXTURE0); - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); glLoadIdentity(); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 221f2203b..04f77a80f 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -293,20 +293,17 @@ void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, in glScalef(1.f, 1.2f * 1.17f, 1.f); yscale = 240.f / texh; } - glMatrixMode(GL_TEXTURE); - glPushMatrix(); - glLoadIdentity(); - glScalef(mirror? -xscale : xscale, yscale, 1.f); - glTranslatef(1.f, y_offset / texh, 1.f); - glMatrixMode(GL_MODELVIEW); + gl_RenderState.EnableTextureMatrix(true); + gl_RenderState.mTextureMatrix.loadIdentity(); + gl_RenderState.mTextureMatrix.scale(mirror? -xscale : xscale, yscale, 1.f); + gl_RenderState.mTextureMatrix.translate(1.f, y_offset / texh, 1.f); } GLRenderer->mSkyVBO->RenderDome(tex, mode); + gl_RenderState.EnableTextureMatrix(false); if (tex) { - glMatrixMode(GL_TEXTURE); - glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 50b67c4ca..79746e5c2 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -206,6 +206,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * timer_index = glGetUniformLocation(hShader, "timer"); lights_index = glGetUniformLocation(hShader, "lights"); fakevb_index = glGetUniformLocation(hShader, "fakeVB"); + modelmatrix_index = glGetUniformLocation(hShader, "ModelMatrix"); + texturematrix_index = glGetUniformLocation(hShader, "TextureMatrix"); glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index da3be18cb..a87b1e576 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -198,11 +198,15 @@ class FShader int timer_index; int lights_index; + int modelmatrix_index; + int texturematrix_index; public: int fakevb_index; private: int currentglowstate; int currentfixedcolormap; + bool currentTextureMatrixState; + bool currentModelMatrixState; public: FShader(const char *name) @@ -211,6 +215,8 @@ public: hShader = hVertProg = hFragProg = 0; currentglowstate = 0; currentfixedcolormap = 0; + currentTextureMatrixState = true; // by setting the matrix state to 'true' it is guaranteed to be set the first time the render state gets applied. + currentModelMatrixState = true; } ~FShader(); diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index d281ee231..ebe751c96 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -36,8 +36,8 @@ uniform ivec4 uLightRange; // redefine the matrix names to what they actually represent. -#define ModelMatrix gl_TextureMatrix[7] -#define ViewMatrix gl_ModelViewMatrix #define ProjectionMatrix gl_ProjectionMatrix -#define TextureMatrix gl_TextureMatrix[0] +#define ViewMatrix gl_ModelViewMatrix +uniform mat4 ModelMatrix; +uniform mat4 TextureMatrix; From 2214c0ac06081711244beb529703ff381d3b2223 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 13 Jul 2014 22:37:34 +0200 Subject: [PATCH 0148/1509] - remove all uses of builtin matrix manipulation. Only glLoadMatrix for view and projection matrix are left. --- src/gl/data/gl_matrix.cpp | 37 ++++++++++--------------- src/gl/models/gl_models.cpp | 28 +++++++++---------- src/gl/renderer/gl_renderer.cpp | 7 +++-- src/gl/renderer/gl_renderstate.cpp | 10 +++++++ src/gl/renderer/gl_renderstate.h | 1 + src/gl/scene/gl_portal.cpp | 13 ++++----- src/gl/scene/gl_scene.cpp | 43 +++++++----------------------- src/gl/scene/gl_skydome.cpp | 38 +++++++++++++------------- src/gl/system/gl_framebuffer.cpp | 22 ++++----------- 9 files changed, 78 insertions(+), 121 deletions(-) diff --git a/src/gl/data/gl_matrix.cpp b/src/gl/data/gl_matrix.cpp index c92f43c26..aa98a3c66 100644 --- a/src/gl/data/gl_matrix.cpp +++ b/src/gl/data/gl_matrix.cpp @@ -253,20 +253,15 @@ VSMatrix::lookAt(FLOATTYPE xPos, FLOATTYPE yPos, FLOATTYPE zPos, void VSMatrix::perspective(FLOATTYPE fov, FLOATTYPE ratio, FLOATTYPE nearp, FLOATTYPE farp) { - FLOATTYPE projMatrix[16]; - FLOATTYPE f = 1.0f / tan (fov * (M_PI / 360.0f)); - setIdentityMatrix(projMatrix,4); - - projMatrix[0] = f / ratio; - projMatrix[1 * 4 + 1] = f; - projMatrix[2 * 4 + 2] = (farp + nearp) / (nearp - farp); - projMatrix[3 * 4 + 2] = (2.0f * farp * nearp) / (nearp - farp); - projMatrix[2 * 4 + 3] = -1.0f; - projMatrix[3 * 4 + 3] = 0.0f; - - multMatrix(projMatrix); + loadIdentity(); + mMatrix[0] = f / ratio; + mMatrix[1 * 4 + 1] = f; + mMatrix[2 * 4 + 2] = (farp + nearp) / (nearp - farp); + mMatrix[3 * 4 + 2] = (2.0f * farp * nearp) / (nearp - farp); + mMatrix[2 * 4 + 3] = -1.0f; + mMatrix[3 * 4 + 3] = 0.0f; } @@ -276,18 +271,14 @@ VSMatrix::ortho(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, FLOATTYPE nearp, FLOATTYPE farp) { - FLOATTYPE m[16]; + loadIdentity(); - setIdentityMatrix(m,4); - - m[0 * 4 + 0] = 2 / (right - left); - m[1 * 4 + 1] = 2 / (top - bottom); - m[2 * 4 + 2] = -2 / (farp - nearp); - m[3 * 4 + 0] = -(right + left) / (right - left); - m[3 * 4 + 1] = -(top + bottom) / (top - bottom); - m[3 * 4 + 2] = -(farp + nearp) / (farp - nearp); - - multMatrix(m); + mMatrix[0 * 4 + 0] = 2 / (right - left); + mMatrix[1 * 4 + 1] = 2 / (top - bottom); + mMatrix[2 * 4 + 2] = -2 / (farp - nearp); + mMatrix[3 * 4 + 0] = -(right + left) / (right - left); + mMatrix[3 * 4 + 1] = -(top + bottom) / (top - bottom); + mMatrix[3 * 4 + 2] = -(farp + nearp) / (farp - nearp); } diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index adec46570..3ea25aead 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -863,11 +863,6 @@ void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy) if ( smf == NULL ) return; - // [BB] The model has to be drawn independtly from the position of the player, - // so we have to reset the GL_MODELVIEW matrix. - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); glDepthFunc(GL_LEQUAL); // [BB] In case the model should be rendered translucent, do back face culling. @@ -879,28 +874,31 @@ void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy) glFrontFace(GL_CCW); } + // [BB] The model has to be drawn independently from the position of the player, + // so we have to reset the view matrix. + gl_RenderState.mViewMatrix.loadIdentity(); + // Scaling model (y scale for a sprite means height, i.e. z in the world!). - glScalef(smf->xscale, smf->zscale, smf->yscale); + gl_RenderState.mViewMatrix.scale(smf->xscale, smf->zscale, smf->yscale); // Aplying model offsets (model offsets do not depend on model scalings). - glTranslatef(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); + gl_RenderState.mViewMatrix.translate(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); // [BB] Weapon bob, very similar to the normal Doom weapon bob. - glRotatef(FIXED2FLOAT(ofsx)/4, 0, 1, 0); - glRotatef(-FIXED2FLOAT(ofsy-WEAPONTOP)/4, 1, 0, 0); + gl_RenderState.mViewMatrix.rotate(FIXED2FLOAT(ofsx)/4, 0, 1, 0); + gl_RenderState.mViewMatrix.rotate(-FIXED2FLOAT(ofsy-WEAPONTOP)/4, 1, 0, 0); // [BB] For some reason the jDoom models need to be rotated. - glRotatef(90., 0, 1, 0); + gl_RenderState.mViewMatrix.rotate(90.f, 0, 1, 0); // Applying angleoffset, pitchoffset, rolloffset. - glRotatef(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); - glRotatef(smf->pitchoffset, 0, 0, 1); - glRotatef(-smf->rolloffset, 1, 0, 0); + gl_RenderState.mViewMatrix.rotate(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); + gl_RenderState.mViewMatrix.rotate(smf->pitchoffset, 0, 0, 1); + gl_RenderState.mViewMatrix.rotate(-smf->rolloffset, 1, 0, 0); + gl_RenderState.ApplyMatrices(); gl_RenderFrameModels( smf, psp->state, psp->tics, playermo->player->ReadyWeapon->GetClass(), NULL, 0 ); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); glDepthFunc(GL_LESS); if (!( playermo->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) glDisable(GL_CULL_FACE); diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index ece007c19..2f17ff99b 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -267,14 +267,13 @@ void FGLRenderer::ClearBorders() int borderHeight = (trueHeight - height) / 2; glViewport(0, 0, width, trueHeight); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.0, width * 1.0, 0.0, trueHeight, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); + gl_RenderState.mProjectionMatrix.loadIdentity(); + gl_RenderState.mProjectionMatrix.ortho(0.0f, width * 1.0f, 0.0f, trueHeight, -1.0f, 1.0f); gl_RenderState.SetColor(0.f ,0.f ,0.f ,1.f); gl_RenderState.Set2DMode(true); gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); + gl_RenderState.ApplyMatrices(); FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); ptr->Set(0, borderHeight, 0, 0, 0); ptr++; diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 6f7382c91..95b0513b8 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -57,6 +57,7 @@ CVAR(Bool, gl_direct_state_change, true, 0) static VSMatrix identityMatrix(1); +TArray gl_MatrixStack; //========================================================================== // @@ -296,3 +297,12 @@ void FRenderState::Apply() ApplyShader(); } + + +void FRenderState::ApplyMatrices() +{ + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(mViewMatrix.get()); + glMatrixMode(GL_PROJECTION); + glLoadMatrixf(mProjectionMatrix.get()); +} diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 6c2965e22..d650e49b4 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -9,6 +9,7 @@ #include "r_defs.h" class FVertexBuffer; +extern TArray gl_MatrixStack; EXTERN_CVAR(Bool, gl_direct_state_change) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 557fbd106..922269636 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -117,17 +117,14 @@ void GLPortal::BeginScene() void GLPortal::ClearScreen() { bool multi = !!glIsEnabled(GL_MULTISAMPLE); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glMatrixMode(GL_PROJECTION); - glPushMatrix(); + gl_MatrixStack.Push(gl_RenderState.mViewMatrix); + gl_MatrixStack.Push(gl_RenderState.mProjectionMatrix); screen->Begin2D(false); screen->Dim(0, 1.f, 0, 0, SCREENWIDTH, SCREENHEIGHT); glEnable(GL_DEPTH_TEST); - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); + gl_MatrixStack.Pop(gl_RenderState.mProjectionMatrix); + gl_MatrixStack.Pop(gl_RenderState.mViewMatrix); + gl_RenderState.ApplyMatrices(); if (multi) glEnable(GL_MULTISAMPLE); gl_RenderState.Set2DMode(false); } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index e93df197c..bf11730aa 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -245,36 +245,11 @@ void FGLRenderer::SetCameraPos(fixed_t viewx, fixed_t viewy, fixed_t viewz, angl // //----------------------------------------------------------------------------- -static void setPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar) -{ - GLdouble m[4][4]; - double sine, cotangent, deltaZ; - double radians = fovy / 2 * M_PI / 180; - - deltaZ = zFar - zNear; - sine = sin(radians); - if ((deltaZ == 0) || (sine == 0) || (aspect == 0)) { - return; - } - cotangent = cos(radians) / sine; - - memset(m, 0, sizeof(m)); - m[0][0] = cotangent / aspect; - m[1][1] = cotangent; - m[2][2] = -(zFar + zNear) / deltaZ; - m[2][3] = -1; - m[3][2] = -2 * zNear * zFar / deltaZ; - m[3][3] = 0; - glLoadMatrixd(&m[0][0]); -} - - void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) { - glMatrixMode(GL_PROJECTION); float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovratio)); - setPerspective(fovy, ratio, 5.f, 65536.f); + gl_RenderState.mProjectionMatrix.perspective(fovy, ratio, 5.f, 65536.f); gl_RenderState.Set2DMode(false); } @@ -286,17 +261,15 @@ void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) void FGLRenderer::SetViewMatrix(bool mirror, bool planemirror) { - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - float mult = mirror? -1:1; float planemult = planemirror? -1:1; - glRotatef(GLRenderer->mAngles.Roll, 0.0f, 0.0f, 1.0f); - glRotatef(GLRenderer->mAngles.Pitch, 1.0f, 0.0f, 0.0f); - glRotatef(GLRenderer->mAngles.Yaw, 0.0f, mult, 0.0f); - glTranslatef( GLRenderer->mCameraPos.X * mult, -GLRenderer->mCameraPos.Z*planemult, -GLRenderer->mCameraPos.Y); - glScalef(-mult, planemult, 1); + gl_RenderState.mViewMatrix.loadIdentity(); + gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll, 0.0f, 0.0f, 1.0f); + gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Pitch, 1.0f, 0.0f, 0.0f); + gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Yaw, 0.0f, mult, 0.0f); + gl_RenderState.mViewMatrix.translate( GLRenderer->mCameraPos.X * mult, -GLRenderer->mCameraPos.Z*planemult, -GLRenderer->mCameraPos.Y); + gl_RenderState.mViewMatrix.scale(-mult, planemult, 1); } @@ -310,6 +283,7 @@ void FGLRenderer::SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t { SetCameraPos(viewx, viewy, viewz, viewangle); SetViewMatrix(mirror, planemirror); + gl_RenderState.ApplyMatrices(); } //----------------------------------------------------------------------------- @@ -887,6 +861,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper SetCameraPos(viewx, viewy, viewz, viewangle); SetViewMatrix(false, false); + gl_RenderState.ApplyMatrices(); clipper.Clear(); angle_t a1 = FrustumAngle(); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 04f77a80f..d2014c654 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -268,29 +268,30 @@ void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, in if (tex) { - glPushMatrix(); tex->Bind(0, 0); texw = tex->TextureWidth(GLUSE_TEXTURE); texh = tex->TextureHeight(GLUSE_TEXTURE); + gl_RenderState.EnableModelMatrix(true); - glRotatef(-180.0f+x_offset, 0.f, 1.f, 0.f); + gl_RenderState.mModelMatrix.loadIdentity(); + gl_RenderState.mModelMatrix.rotate(-180.0f+x_offset, 0.f, 1.f, 0.f); float xscale = 1024.f / float(texw); float yscale = 1.f; if (texh < 200) { - glTranslatef(0.f, -1250.f, 0.f); - glScalef(1.f, texh/230.f, 1.f); + gl_RenderState.mModelMatrix.translate(0.f, -1250.f, 0.f); + gl_RenderState.mModelMatrix.scale(1.f, texh/230.f, 1.f); } else if (texh <= 240) { - glTranslatef(0.f, (200 - texh + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); - glScalef(1.f, 1.f + ((texh-200.f)/200.f) * 1.17f, 1.f); + gl_RenderState.mModelMatrix.translate(0.f, (200 - texh + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); + gl_RenderState.mModelMatrix.scale(1.f, 1.f + ((texh-200.f)/200.f) * 1.17f, 1.f); } else { - glTranslatef(0.f, (-40 + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); - glScalef(1.f, 1.2f * 1.17f, 1.f); + gl_RenderState.mModelMatrix.translate(0.f, (-40 + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); + gl_RenderState.mModelMatrix.scale(1.f, 1.2f * 1.17f, 1.f); yscale = 240.f / texh; } gl_RenderState.EnableTextureMatrix(true); @@ -301,13 +302,7 @@ void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, in GLRenderer->mSkyVBO->RenderDome(tex, mode); gl_RenderState.EnableTextureMatrix(false); - - if (tex) - { - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - } - + gl_RenderState.EnableModelMatrix(false); } @@ -323,10 +318,12 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool int faces; FMaterial * tex; + gl_RenderState.EnableModelMatrix(true); + if (!sky2) - glRotatef(-180.0f+x_offset, glset.skyrotatevector.X, glset.skyrotatevector.Z, glset.skyrotatevector.Y); + gl_RenderState.mModelMatrix.rotate(-180.0f+x_offset, glset.skyrotatevector.X, glset.skyrotatevector.Z, glset.skyrotatevector.Y); else - glRotatef(-180.0f+x_offset, glset.skyrotatevector2.X, glset.skyrotatevector2.Z, glset.skyrotatevector2.Y); + gl_RenderState.mModelMatrix.rotate(-180.0f+x_offset, glset.skyrotatevector2.X, glset.skyrotatevector2.Z, glset.skyrotatevector2.Y); FFlatVertex *ptr; if (sb->faces[5]) @@ -456,6 +453,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool ptr->Set(-128.f, -128.f, 128.f, 1, 1); ptr++; GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + gl_RenderState.EnableModelMatrix(false); } //----------------------------------------------------------------------------- @@ -477,8 +475,7 @@ void GLSkyPortal::DrawContents() gl_RenderState.EnableAlphaTest(false); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); + gl_MatrixStack.Push(gl_RenderState.mViewMatrix); GLRenderer->SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox) @@ -519,7 +516,8 @@ void GLSkyPortal::DrawContents() } gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); } - glPopMatrix(); + gl_MatrixStack.Pop(gl_RenderState.mViewMatrix); + gl_RenderState.ApplyMatrices(); glset.lightmode = oldlightmode; } diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 30f791d50..96abf833d 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -54,6 +54,7 @@ #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_lightdata.h" #include "gl/data/gl_data.h" #include "gl/textures/gl_hwtexture.h" @@ -386,23 +387,10 @@ FNativePalette *OpenGLFrameBuffer::CreatePalette(FRemapTable *remap) //========================================================================== bool OpenGLFrameBuffer::Begin2D(bool) { - glActiveTexture(GL_TEXTURE7); - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - glActiveTexture(GL_TEXTURE0); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho( - (GLdouble) 0, - (GLdouble) GetWidth(), - (GLdouble) GetHeight(), - (GLdouble) 0, - (GLdouble) -1.0, - (GLdouble) 1.0 - ); + gl_RenderState.mViewMatrix.loadIdentity(); + gl_RenderState.mProjectionMatrix.ortho(0, GetWidth(), GetHeight(), 0, -1.0f, 1.0f); + gl_RenderState.ApplyMatrices(); + glDisable(GL_DEPTH_TEST); // Korshun: ENABLE AUTOMAP ANTIALIASING!!! From ce3653f6e1d2ccba096e2e9f0f59b3ba1c1be715 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 13 Jul 2014 23:13:40 +0200 Subject: [PATCH 0149/1509] - remove all uses of builtin matrices. --- src/gl/data/gl_vertexbuffer.h | 4 +-- src/gl/renderer/gl_renderstate.cpp | 10 +++--- src/gl/scene/gl_flats.cpp | 4 +-- src/gl/shaders/gl_shader.cpp | 43 +++++++++++++++++++++++++ src/gl/shaders/gl_shader.h | 4 +++ wadsrc/static/shaders/glsl/shaderdefs.i | 4 +-- 6 files changed, 59 insertions(+), 10 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index d9e259db6..ff9d14278 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -80,7 +80,7 @@ public: #ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway. void RenderArray(unsigned int primtype, unsigned int offset, unsigned int count) { - drawcalls.Clock(); + //drawcalls.Clock(); if (gl.flags & RFL_BUFFER_STORAGE) { glDrawArrays(primtype, offset, count); @@ -89,7 +89,7 @@ public: { ImmRenderBuffer(primtype, offset, count); } - drawcalls.Unclock(); + //drawcalls.Unclock(); } void RenderCurrent(FFlatVertex *newptr, unsigned int primtype, unsigned int *poffset = NULL, unsigned int *pcount = NULL) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 95b0513b8..67a02440c 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -301,8 +301,10 @@ void FRenderState::Apply() void FRenderState::ApplyMatrices() { - glMatrixMode(GL_MODELVIEW); - glLoadMatrixf(mViewMatrix.get()); - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(mProjectionMatrix.get()); + drawcalls.Clock(); + if (GLRenderer->mShaderManager != NULL) + { + GLRenderer->mShaderManager->ApplyMatrices(&mProjectionMatrix, &mViewMatrix); + } + drawcalls.Unclock(); } diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 6b449ded3..fb5da4fd2 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -298,9 +298,9 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) { if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub); - drawcalls.Clock(); + //drawcalls.Clock(); glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines); - drawcalls.Unclock(); + //drawcalls.Unclock(); flatvertices += sub->numlines; flatprimitives++; } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 79746e5c2..1dbdada24 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -51,6 +51,7 @@ #include "gl/system/gl_interface.h" #include "gl/data/gl_data.h" +#include "gl/data/gl_matrix.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderstate.h" #include "gl/system/gl_cvars.h" @@ -206,6 +207,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * timer_index = glGetUniformLocation(hShader, "timer"); lights_index = glGetUniformLocation(hShader, "lights"); fakevb_index = glGetUniformLocation(hShader, "fakeVB"); + projectionmatrix_index = glGetUniformLocation(hShader, "ProjectionMatrix"); + viewmatrix_index = glGetUniformLocation(hShader, "ViewMatrix"); modelmatrix_index = glGetUniformLocation(hShader, "ModelMatrix"); texturematrix_index = glGetUniformLocation(hShader, "TextureMatrix"); @@ -277,6 +280,19 @@ FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath return shader; } +//========================================================================== +// +// +// +//========================================================================== + +void FShader::ApplyMatrices(VSMatrix *proj, VSMatrix *view) +{ + glProgramUniformMatrix4fv(hShader, projectionmatrix_index, 1, false, proj->get()); + glProgramUniformMatrix4fv(hShader, viewmatrix_index, 1, false, view->get()); +} + + //========================================================================== // // @@ -486,6 +502,33 @@ FShader *FShaderManager::BindEffect(int effect) } +//========================================================================== +// +// +// +//========================================================================== +EXTERN_CVAR(Int, gl_fuzztype) + +void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view) +{ + for (int i = 0; i <= 4; i++) + { + mTextureEffects[i]->ApplyMatrices(proj, view); + } + if (gl_fuzztype != 0) + { + mTextureEffects[4+gl_fuzztype]->ApplyMatrices(proj, view); + } + for (unsigned i = 12; i < mTextureEffects.Size(); i++) + { + mTextureEffects[i]->ApplyMatrices(proj, view); + } + for (int i = 0; i < MAX_EFFECTS; i++) + { + mEffectShaders[i]->ApplyMatrices(proj, view); + } +} + //========================================================================== // // diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index a87b1e576..663d09122 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -198,6 +198,8 @@ class FShader int timer_index; int lights_index; + int projectionmatrix_index; + int viewmatrix_index; int modelmatrix_index; int texturematrix_index; public: @@ -230,6 +232,7 @@ public: bool Bind(); unsigned int GetHandle() const { return hShader; } + void ApplyMatrices(VSMatrix *proj, VSMatrix *view); }; @@ -256,6 +259,7 @@ public: FShader *BindEffect(int effect); void SetActiveShader(FShader *sh); void SetWarpSpeed(unsigned int eff, float speed); + void ApplyMatrices(VSMatrix *proj, VSMatrix *view); FShader *GetActiveShader() const { return mActiveShader; diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index ebe751c96..867e9a709 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -36,8 +36,8 @@ uniform ivec4 uLightRange; // redefine the matrix names to what they actually represent. -#define ProjectionMatrix gl_ProjectionMatrix -#define ViewMatrix gl_ModelViewMatrix +uniform mat4 ProjectionMatrix; +uniform mat4 ViewMatrix; uniform mat4 ModelMatrix; uniform mat4 TextureMatrix; From 150135a07d31a2fd5471a2d9907784ef705f0aee Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 13 Jul 2014 23:14:28 +0200 Subject: [PATCH 0150/1509] - reinstate drawcall timing. --- src/gl/data/gl_vertexbuffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index ff9d14278..d9e259db6 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -80,7 +80,7 @@ public: #ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway. void RenderArray(unsigned int primtype, unsigned int offset, unsigned int count) { - //drawcalls.Clock(); + drawcalls.Clock(); if (gl.flags & RFL_BUFFER_STORAGE) { glDrawArrays(primtype, offset, count); @@ -89,7 +89,7 @@ public: { ImmRenderBuffer(primtype, offset, count); } - //drawcalls.Unclock(); + drawcalls.Unclock(); } void RenderCurrent(FFlatVertex *newptr, unsigned int primtype, unsigned int *poffset = NULL, unsigned int *pcount = NULL) From 1f2f7616e17e93b52f2bddf93433ffcb58038a88 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 14 Jul 2014 00:31:10 +0200 Subject: [PATCH 0151/1509] - remove timing of matrix application method --- src/gl/renderer/gl_renderstate.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 67a02440c..27e4465c1 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -301,10 +301,8 @@ void FRenderState::Apply() void FRenderState::ApplyMatrices() { - drawcalls.Clock(); if (GLRenderer->mShaderManager != NULL) { GLRenderer->mShaderManager->ApplyMatrices(&mProjectionMatrix, &mViewMatrix); } - drawcalls.Unclock(); } From ed5ee4e8d196a27af348a769a55e11140786767b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 14 Jul 2014 18:48:46 +0200 Subject: [PATCH 0152/1509] - removed some obsolete init stuff and some deprecated constants. --- src/gl/system/gl_framebuffer.cpp | 12 +----------- src/gl/system/gl_interface.cpp | 1 - src/gl/textures/gl_hwtexture.cpp | 8 ++++---- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 96abf833d..e34eb5fce 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -138,7 +138,6 @@ void OpenGLFrameBuffer::InitializeState() glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glDepthFunc(GL_LESS); - glShadeModel(GL_SMOOTH); glEnable(GL_DITHER); glEnable(GL_ALPHA_TEST); @@ -146,7 +145,7 @@ void OpenGLFrameBuffer::InitializeState() glDisable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_LINE); glEnable(GL_BLEND); - glEnable(GL_DEPTH_CLAMP_NV); + glEnable(GL_DEPTH_CLAMP); glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glDisable(GL_LINE_SMOOTH); @@ -154,15 +153,6 @@ void OpenGLFrameBuffer::InitializeState() glAlphaFunc(GL_GEQUAL,0.5f); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); - - // This was to work around a bug in some older driver. Probably doesn't make sense anymore. - glEnable(GL_FOG); - glDisable(GL_FOG); - - glHint(GL_FOG_HINT, GL_FASTEST); - glFogi(GL_FOG_MODE, GL_EXP); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 42224767b..5b99bd562 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -140,7 +140,6 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; if (gl.version >= 4.f && CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; - if (gl.version >= 3.2f || CheckExtension("GL_ARB_draw_elements_base_vertex")) gl.flags |= RFL_BASEINDEX; glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 9d81b54ce..516b5aaf5 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -253,9 +253,9 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i // When using separate samplers the stuff below is not needed. // if (gl.flags & RFL_SAMPLER_OBJECTS) return; - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); - clampmode = wrapparam==GL_CLAMP? GLT_CLAMPX|GLT_CLAMPY : 0; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapparam); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapparam); + clampmode = wrapparam==GL_CLAMP_TO_EDGE? GLT_CLAMPX|GLT_CLAMPY : 0; if (forcenofiltering) { @@ -469,7 +469,7 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int unsigned int * pTexID=GetTexID(translation); if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); - LoadImage(buffer, w, h, *pTexID, wrap? GL_REPEAT:GL_CLAMP, alphatexture, texunit); + LoadImage(buffer, w, h, *pTexID, wrap? GL_REPEAT:GL_CLAMP_TO_EDGE, alphatexture, texunit); if (texunit != 0) glActiveTexture(GL_TEXTURE0); return *pTexID; } From 84a49e37eed36e939e05536bcd9859a751452b2b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 14 Jul 2014 19:54:07 +0200 Subject: [PATCH 0153/1509] - handle normals for spheremapped mirror surfaces using non-deprecated features. - move all WGL references out of global header files so that global wgl header include is no longer necessary --- src/gl/scene/gl_walls_draw.cpp | 9 ++++++++- src/win32/win32gliface.cpp | 23 +++++++++++++++++------ src/win32/win32gliface.h | 3 --- wadsrc/static/shaders/glsl/main.vp | 2 +- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index aabec775e..b932691de 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -321,7 +321,13 @@ void GLWall::RenderMirrorSurface() // For the sphere map effect we need a normal of the mirror surface, Vector v(glseg.y2-glseg.y1, 0 ,-glseg.x2+glseg.x1); v.Normalize(); - glNormal3fv(&v[0]); + + // we use texture coordinates and texture matrix to pass the normal stuff to the shader so that the default vertex buffer format can be used as is. + lolft.u = lorgt.u = uplft.u = uprgt.u = v.X(); + lolft.v = lorgt.v = uplft.v = uprgt.v = v.Z(); + + gl_RenderState.EnableTextureMatrix(true); + gl_RenderState.mTextureMatrix.computeNormalMatrix(gl_RenderState.mViewMatrix); // Use sphere mapping for this gl_RenderState.SetEffect(EFF_SPHEREMAP); @@ -338,6 +344,7 @@ void GLWall::RenderMirrorSurface() flags &= ~GLWF_GLOW; RenderWall(RWF_BLANK); + gl_RenderState.EnableTextureMatrix(false); gl_RenderState.SetEffect(EFF_NONE); // Restore the defaults for the translucent pass diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 5623b7062..7b70e9172 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -1,5 +1,10 @@ #include "gl/system/gl_system.h" +#define DWORD WINDOWS_DWORD +#include +#undef DWORD + + #include "win32iface.h" #include "win32gliface.h" //#include "gl/gl_intern.h" @@ -22,6 +27,12 @@ void gl_CalculateCPUSpeed(); extern int NewWidth, NewHeight, NewBits, DisplayBits; +// these get used before GLEW is initialized so we have to use separate pointers with different names +PFNWGLCHOOSEPIXELFORMATARBPROC myWglChoosePixelFormatARB; // = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); +PFNWGLCREATECONTEXTATTRIBSARBPROC myWglCreateContextAttribsARB; +PFNWGLSWAPINTERVALEXTPROC vsyncfunc; + + CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL ) { Printf("This won't take effect until "GAMENAME" is restarted.\n"); @@ -581,8 +592,8 @@ bool Win32GLVideo::SetPixelFormat() hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); - wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); - wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); + myWglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); + myWglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); // any extra stuff here? wglMakeCurrent(NULL, NULL); @@ -612,7 +623,7 @@ bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, int multisample) colorDepth = GetDeviceCaps(deskDC, BITSPIXEL); ReleaseDC(GetDesktopWindow(), deskDC); - if (wglChoosePixelFormatARB) + if (myWglChoosePixelFormatARB) { attributes[0] = WGL_RED_BITS_ARB; //bits attributes[1] = 8; @@ -662,7 +673,7 @@ bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, int multisample) attributes[24] = 0; attributes[25] = 0; - if (!wglChoosePixelFormatARB(m_hDC, attributes, attribsFloat, 1, &pixelFormat, &numFormats)) + if (!myWglChoosePixelFormatARB(m_hDC, attributes, attribsFloat, 1, &pixelFormat, &numFormats)) { Printf("R_OPENGL: Couldn't choose pixel format. Retrying in compatibility mode\n"); goto oldmethod; @@ -736,7 +747,7 @@ bool Win32GLVideo::InitHardware (HWND Window, bool allowsoftware, int multisampl } m_hRC = 0; - if (wglCreateContextAttribsARB != NULL) + if (myWglCreateContextAttribsARB != NULL) { int ctxAttribs[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 3, @@ -746,7 +757,7 @@ bool Win32GLVideo::InitHardware (HWND Window, bool allowsoftware, int multisampl 0 }; - m_hRC = wglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); + m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); } if (m_hRC == 0) { diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index 4457c5372..f39a9f70b 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -46,8 +46,6 @@ public: void Shutdown(); bool SetFullscreen(const char *devicename, int w, int h, int bits, int hz); - PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB; // = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); - PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; HDC m_hDC; protected: @@ -107,7 +105,6 @@ public: Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen); virtual ~Win32GLFrameBuffer(); - PFNWGLSWAPINTERVALEXTPROC vsyncfunc; // unused but must be defined virtual void Blank (); diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index f0bbdd413..58ca931fb 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -52,7 +52,7 @@ void main() #ifdef SPHEREMAP vec3 u = normalize(eyeCoordPos.xyz); - vec3 n = normalize(gl_NormalMatrix * gl_Normal); + vec3 n = normalize(TextureMatrix * vec4(tc.x, 0.0, tc.y, 0.0); // use texture matrix and coordinates for our normal. Since this is only used on walls, the normal's y coordinate is always 0. vec3 r = reflect(u, n); float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) ); vec2 sst = vec2(r.x/m + 0.5, r.y/m + 0.5); From ed8a21fd86d5f9636e6bb47f81c3e320166a4b61 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 14 Jul 2014 21:14:43 +0200 Subject: [PATCH 0154/1509] - replaced deprecated alpha testing with shader code. --- src/gl/renderer/gl_renderer.cpp | 4 +--- src/gl/renderer/gl_renderstate.cpp | 15 +------------- src/gl/renderer/gl_renderstate.h | 26 ++----------------------- src/gl/scene/gl_decal.cpp | 2 +- src/gl/scene/gl_flats.cpp | 2 +- src/gl/scene/gl_portal.cpp | 2 +- src/gl/scene/gl_scene.cpp | 21 ++++++++------------ src/gl/scene/gl_skydome.cpp | 6 ++---- src/gl/scene/gl_sprite.cpp | 16 +++------------ src/gl/scene/gl_walls_draw.cpp | 10 ++++------ src/gl/scene/gl_weapon.cpp | 7 ++----- src/gl/shaders/gl_shader.cpp | 1 + src/gl/shaders/gl_shader.h | 1 + src/gl/system/gl_framebuffer.cpp | 1 - src/gl/system/gl_system.h | 4 +--- src/gl/system/gl_wipe.cpp | 6 +++--- wadsrc/static/shaders/glsl/main.fp | 6 ++++++ wadsrc/static/shaders/glsl/main.vp | 4 ++-- wadsrc/static/shaders/glsl/shaderdefs.i | 4 ++-- 19 files changed, 42 insertions(+), 96 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 2f17ff99b..ae2ba2125 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -383,7 +383,7 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) glScissor(parms.lclip, btm - parms.dclip + space, parms.rclip - parms.lclip, parms.dclip - parms.uclip); gl_RenderState.SetColor(color); - gl_RenderState.EnableAlphaTest(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.Apply(); FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); @@ -409,8 +409,6 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } - gl_RenderState.EnableAlphaTest(true); - glScissor(0, 0, screen->GetWidth(), screen->GetHeight()); glDisable(GL_SCISSOR_TEST); gl_RenderState.SetTextureMode(TM_MODULATE); diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 27e4465c1..917170872 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -75,8 +75,6 @@ void FRenderState::Reset() mSrcBlend = GL_SRC_ALPHA; mDstBlend = GL_ONE_MINUS_SRC_ALPHA; glSrcBlend = glDstBlend = -1; - glAlphaFunc = -1; - mAlphaFunc = GL_GEQUAL; mAlphaThreshold = 0.5f; mBlendEquation = GL_FUNC_ADD; mObjectColor = 0xffffffff; @@ -151,6 +149,7 @@ bool FRenderState::ApplyShader() activeShader->muInterpolationFactor.Set(mInterpolationFactor); activeShader->muClipHeightTop.Set(mClipHeightTop); activeShader->muClipHeightBottom.Set(mClipHeightBottom); + activeShader->muAlphaThreshold.Set(mAlphaThreshold); if (mGlowEnabled) { @@ -269,18 +268,6 @@ void FRenderState::Apply() glDstBlend = mDstBlend; glBlendFunc(mSrcBlend, mDstBlend); } - if (mAlphaFunc != glAlphaFunc || mAlphaThreshold != glAlphaThreshold) - { - glAlphaFunc = mAlphaFunc; - glAlphaThreshold = mAlphaThreshold; - ::glAlphaFunc(mAlphaFunc, mAlphaThreshold); - } - if (mAlphaTest != glAlphaTest) - { - glAlphaTest = mAlphaTest; - if (mAlphaTest) glEnable(GL_ALPHA_TEST); - else glDisable(GL_ALPHA_TEST); - } if (mBlendEquation != glBlendEquation) { glBlendEquation = mBlendEquation; diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index d650e49b4..d8168bca5 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -53,7 +53,6 @@ class FRenderState int mNumLights[4]; float *mLightData; int mSrcBlend, mDstBlend; - int mAlphaFunc; float mAlphaThreshold; bool mAlphaTest; int mBlendEquation; @@ -76,7 +75,6 @@ class FRenderState int mColormapState; int glSrcBlend, glDstBlend; - int glAlphaFunc; float glAlphaThreshold; bool glAlphaTest; int glBlendEquation; @@ -281,28 +279,8 @@ public: void AlphaFunc(int func, float thresh) { - if (!gl_direct_state_change) - { - mAlphaFunc = func; - mAlphaThreshold = thresh; - } - else - { - ::glAlphaFunc(func, thresh); - } - } - - void EnableAlphaTest(bool on) - { - if (!gl_direct_state_change) - { - mAlphaTest = on; - } - else - { - if (on) glEnable(GL_ALPHA_TEST); - else glDisable(GL_ALPHA_TEST); - } + if (func == GL_GREATER) mAlphaThreshold = thresh; + else mAlphaThreshold = thresh - 0.001f; } void BlendEquation(int eq) diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index e6d5c144f..98101c987 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -333,7 +333,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) // If srcalpha is one it looks better with a higher alpha threshold - if (decal->RenderStyle.SrcAlpha == STYLEALPHA_One) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); + if (decal->RenderStyle.SrcAlpha == STYLEALPHA_One) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); else gl_RenderState.AlphaFunc(GL_GREATER, 0.f); gl_RenderState.Apply(); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index fb5da4fd2..91c7f1c7e 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -424,7 +424,7 @@ void GLFlat::Draw(int pass) if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE); gl_SetColor(lightlevel, rel, Colormap, alpha); gl_SetFog(lightlevel, rel, &Colormap, false); - gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_threshold*(alpha)); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); if (!gltexture) { gl_RenderState.EnableTexture(false); diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 922269636..0cc602967 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -998,7 +998,7 @@ void GLHorizonPortal::DrawContents() gltexture->Bind(); gl_SetPlaneTextureRotation(sp, gltexture); - gl_RenderState.EnableAlphaTest(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); gl_RenderState.Apply(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index bf11730aa..e6dc3098c 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -345,7 +345,7 @@ void FGLRenderer::RenderScene(int recursion) glDepthFunc(GL_LESS); - gl_RenderState.EnableAlphaTest(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); glDisable(GL_POLYGON_OFFSET_FILL); // just in case @@ -374,8 +374,6 @@ void FGLRenderer::RenderScene(int recursion) gl_drawinfo->drawlists[GLDL_LIGHTFOG].Draw(pass); - gl_RenderState.EnableAlphaTest(true); - // Part 2: masked geometry. This is set up so that only pixels with alpha>0.5 will show if (!gl_texture) { @@ -383,7 +381,7 @@ void FGLRenderer::RenderScene(int recursion) gl_RenderState.SetTextureMode(TM_MASK); } if (pass == GLPASS_BASE) pass = GLPASS_BASE_MASKED; - gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_threshold); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); gl_drawinfo->drawlists[GLDL_MASKED].Sort(); gl_drawinfo->drawlists[GLDL_MASKED].Draw(pass); gl_drawinfo->drawlists[GLDL_FOGMASKED].Sort(); @@ -440,10 +438,10 @@ void FGLRenderer::RenderScene(int recursion) glDepthFunc(GL_LEQUAL); if (gl_texture) { - gl_RenderState.EnableAlphaTest(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_drawinfo->drawlists[GLDL_LIGHT].Sort(); gl_drawinfo->drawlists[GLDL_LIGHT].Draw(GLPASS_TEXTURE); - gl_RenderState.EnableAlphaTest(true); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); gl_drawinfo->drawlists[GLDL_LIGHTBRIGHT].Sort(); gl_drawinfo->drawlists[GLDL_LIGHTBRIGHT].Draw(GLPASS_TEXTURE); gl_drawinfo->drawlists[GLDL_LIGHTMASKED].Sort(); @@ -495,10 +493,9 @@ void FGLRenderer::RenderScene(int recursion) glDepthMask(false); // don't write to Z-buffer! gl_RenderState.EnableFog(true); - gl_RenderState.EnableAlphaTest(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); gl_drawinfo->DrawUnhandledMissingTextures(); - gl_RenderState.EnableAlphaTest(true); glDepthMask(true); glPolygonOffset(0.0f, 0.0f); @@ -523,8 +520,7 @@ void FGLRenderer::RenderTranslucent() gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); // final pass: translucent stuff - gl_RenderState.EnableAlphaTest(true); - gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_sprite_threshold); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.EnableBrightmap(true); @@ -534,7 +530,7 @@ void FGLRenderer::RenderTranslucent() glDepthMask(true); - gl_RenderState.AlphaFunc(GL_GEQUAL,0.5f); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f); RenderAll.Unclock(); } @@ -577,7 +573,7 @@ void FGLRenderer::DrawScene(bool toscreen) static void FillScreen() { - gl_RenderState.EnableAlphaTest(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); @@ -756,7 +752,6 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.ResetColor(); gl_RenderState.EnableTexture(true); - gl_RenderState.EnableAlphaTest(true); glDisable(GL_SCISSOR_TEST); } diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index d2014c654..240bf6762 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -472,7 +472,7 @@ void GLSkyPortal::DrawContents() gl_RenderState.ResetColor(); gl_RenderState.EnableFog(false); - gl_RenderState.EnableAlphaTest(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_MatrixStack.Push(gl_RenderState.mViewMatrix); @@ -481,7 +481,6 @@ void GLSkyPortal::DrawContents() if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox) { RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2); - gl_RenderState.EnableAlphaTest(true); } else { @@ -495,8 +494,7 @@ void GLSkyPortal::DrawContents() gl_RenderState.SetTextureMode(TM_MODULATE); } - gl_RenderState.EnableAlphaTest(true); - gl_RenderState.AlphaFunc(GL_GEQUAL,0.05f); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.05f); if (origin->doublesky && origin->texture[1]) { diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index ab0586f58..c70422b32 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -137,11 +137,11 @@ void GLSprite::Draw(int pass) if (hw_styleflags == STYLEHW_NoAlphaTest) { - gl_RenderState.EnableAlphaTest(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); } else { - gl_RenderState.AlphaFunc(GL_GEQUAL,trans*gl_mask_sprite_threshold); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); } if (RenderStyle.BlendOp == STYLEOP_Shadow) @@ -165,7 +165,7 @@ void GLSprite::Draw(int pass) minalpha*=factor; } - gl_RenderState.AlphaFunc(GL_GEQUAL,minalpha*gl_mask_sprite_threshold); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); gl_RenderState.SetColor(0.2f,0.2f,0.2f,fuzzalpha, Colormap.desaturation); additivefog = true; } @@ -294,16 +294,6 @@ void GLSprite::Draw(int pass) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.BlendEquation(GL_FUNC_ADD); gl_RenderState.SetTextureMode(TM_MODULATE); - - // [BB] Restore the alpha test after drawing a smooth particle. - if (hw_styleflags == STYLEHW_NoAlphaTest) - { - gl_RenderState.EnableAlphaTest(true); - } - else - { - gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_sprite_threshold); - } } gl_RenderState.SetObjectColor(0xffffffff); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index b932691de..e28f6315c 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -301,9 +301,8 @@ void GLWall::RenderFogBoundary() int rel = rellight + getExtraLight(); gl_SetFog(lightlevel, rel, &Colormap, false); gl_RenderState.SetEffect(EFF_FOGBOUNDARY); - gl_RenderState.EnableAlphaTest(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); RenderWall(RWF_BLANK); - gl_RenderState.EnableAlphaTest(true); gl_RenderState.SetEffect(EFF_NONE); } } @@ -349,7 +348,7 @@ void GLWall::RenderMirrorSurface() // Restore the defaults for the translucent pass gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl_RenderState.AlphaFunc(GL_GEQUAL,0.5f*gl_mask_sprite_threshold); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); glDepthFunc(GL_LESS); // This is drawn in the translucent pass which is done after the decal pass @@ -383,8 +382,8 @@ void GLWall::RenderTranslucentWall() // and until that changes I won't fix this code for the new blending modes! bool isadditive = RenderStyle == STYLE_Add; - if (!transparent) gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_threshold*fabs(alpha)); - else gl_RenderState.EnableAlphaTest(false); + if (!transparent) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); + else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE); int extra; @@ -408,7 +407,6 @@ void GLWall::RenderTranslucentWall() // restore default settings if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - if (transparent) gl_RenderState.EnableAlphaTest(true); if (!gltexture) { diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 219eaf115..d0f2ab370 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -151,7 +151,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed if (tex->GetTransparent() || OverrideShader != 0) { - gl_RenderState.EnableAlphaTest(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); } gl_RenderState.Apply(); FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); @@ -164,10 +164,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed ptr->Set(x2, y2, 0, fU2, fV2); ptr++; GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - if (tex->GetTransparent() || OverrideShader != 0) - { - gl_RenderState.EnableAlphaTest(true); - } + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f); } //========================================================================== diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 1dbdada24..4373955c2 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -203,6 +203,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muInterpolationFactor.Init(hShader, "uInterpolationFactor"); muClipHeightTop.Init(hShader, "uClipHeightTop"); muClipHeightBottom.Init(hShader, "uClipHeightBottom"); + muAlphaThreshold.Init(hShader, "uAlphaThreshold"); timer_index = glGetUniformLocation(hShader, "timer"); lights_index = glGetUniformLocation(hShader, "lights"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 663d09122..bed37cbb0 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -195,6 +195,7 @@ class FShader FBufferedUniform1f muInterpolationFactor; FBufferedUniform1f muClipHeightTop; FBufferedUniform1f muClipHeightBottom; + FBufferedUniform1f muAlphaThreshold; int timer_index; int lights_index; diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index e34eb5fce..d3783fd42 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -150,7 +150,6 @@ void OpenGLFrameBuffer::InitializeState() glEnable(GL_TEXTURE_2D); glDisable(GL_LINE_SMOOTH); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glAlphaFunc(GL_GEQUAL,0.5f); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h index 8140904a2..8273960f9 100644 --- a/src/gl/system/gl_system.h +++ b/src/gl/system/gl_system.h @@ -68,15 +68,13 @@ //GL headers #include +//#include "gl_load.h" #if defined(__APPLE__) #include #elif defined(__unix__) //#include #else // !__APPLE__ && !__unix__ - #define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code! - #include - #undef DWORD #endif #ifdef _WIN32 diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index e4627fd35..12e7c9e02 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -280,7 +280,7 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight()); gl_RenderState.SetTextureMode(TM_OPAQUE); - gl_RenderState.EnableAlphaTest(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.ResetColor(); gl_RenderState.Apply(); fb->wipestartscreen->Bind(0); @@ -302,7 +302,7 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.SetColorAlpha(0xffffff, clamp(Clock/32.f, 0.f, 1.f)); gl_RenderState.Apply(); GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); - gl_RenderState.EnableAlphaTest(true); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f); gl_RenderState.SetTextureMode(TM_MODULATE); return Clock >= 32; @@ -490,7 +490,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) // Put the initial screen back to the buffer. gl_RenderState.SetTextureMode(TM_OPAQUE); - gl_RenderState.EnableAlphaTest(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.ResetColor(); gl_RenderState.Apply(); fb->wipestartscreen->Bind(0); diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 5655493bd..30a815b3c 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -223,6 +223,12 @@ void main() #endif vec4 frag = ProcessTexel(); + +#ifndef NO_DISCARD + // alpha testing + if (frag.a <= uAlphaThreshold) discard; +#endif + switch (uFixedColormap) { diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 58ca931fb..7a434ccbe 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -52,8 +52,8 @@ void main() #ifdef SPHEREMAP vec3 u = normalize(eyeCoordPos.xyz); - vec3 n = normalize(TextureMatrix * vec4(tc.x, 0.0, tc.y, 0.0); // use texture matrix and coordinates for our normal. Since this is only used on walls, the normal's y coordinate is always 0. - vec3 r = reflect(u, n); + vec4 n = normalize(TextureMatrix * vec4(tc.x, 0.0, tc.y, 0.0)); // use texture matrix and coordinates for our normal. Since this is only used on walls, the normal's y coordinate is always 0. + vec3 r = reflect(u, n.xyz); float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) ); vec2 sst = vec2(r.x/m + 0.5, r.y/m + 0.5); gl_TexCoord[0].xy = sst; diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 867e9a709..56e6965b2 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -4,6 +4,7 @@ uniform vec4 uCameraPos; uniform float uClipHeightTop, uClipHeightBottom; uniform int uTextureMode; +uniform float uAlphaThreshold; // colors uniform vec4 uObjectColor; @@ -34,8 +35,7 @@ uniform int uFogEnabled; // dynamic lights uniform ivec4 uLightRange; - -// redefine the matrix names to what they actually represent. +// matrices uniform mat4 ProjectionMatrix; uniform mat4 ViewMatrix; uniform mat4 ModelMatrix; From 5193f6cfef8dde32d0b37005d94c726c09a6d01e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Jul 2014 00:19:41 +0200 Subject: [PATCH 0155/1509] - remove use of builtin deprecated varyings in shaders. --- wadsrc/static/shaders/glsl/burn.fp | 8 +++++--- wadsrc/static/shaders/glsl/func_brightmap.fp | 4 ++-- wadsrc/static/shaders/glsl/func_normal.fp | 2 +- wadsrc/static/shaders/glsl/func_warp1.fp | 2 +- wadsrc/static/shaders/glsl/func_warp2.fp | 2 +- wadsrc/static/shaders/glsl/func_wavex.fp | 2 +- wadsrc/static/shaders/glsl/fuzz_jagged.fp | 2 +- wadsrc/static/shaders/glsl/fuzz_noise.fp | 2 +- wadsrc/static/shaders/glsl/fuzz_smooth.fp | 2 +- wadsrc/static/shaders/glsl/fuzz_smoothnoise.fp | 2 +- wadsrc/static/shaders/glsl/fuzz_smoothtranslucent.fp | 2 +- wadsrc/static/shaders/glsl/fuzz_standard.fp | 2 +- wadsrc/static/shaders/glsl/fuzz_swirly.fp | 2 +- wadsrc/static/shaders/glsl/main.fp | 12 +++++++----- wadsrc/static/shaders/glsl/main.vp | 9 ++++++--- 15 files changed, 31 insertions(+), 24 deletions(-) diff --git a/wadsrc/static/shaders/glsl/burn.fp b/wadsrc/static/shaders/glsl/burn.fp index 8ccb553f8..d14748212 100644 --- a/wadsrc/static/shaders/glsl/burn.fp +++ b/wadsrc/static/shaders/glsl/burn.fp @@ -1,12 +1,14 @@ uniform sampler2D tex; uniform sampler2D texture2; +in vec4 vTexCoord; +in vec4 vColor; void main() { - vec4 frag = gl_Color; + vec4 frag = vColor; - vec4 t1 = texture2D(texture2, gl_TexCoord[0].xy); - vec4 t2 = texture2D(tex, vec2(gl_TexCoord[0].x, 1.0-gl_TexCoord[0].y)); + vec4 t1 = texture2D(texture2, vTexCoord.xy); + vec4 t2 = texture2D(tex, vec2(vTexCoord.x, 1.0-vTexCoord.y)); gl_FragColor = frag * vec4(t1.r, t1.g, t1.b, t2.a); } diff --git a/wadsrc/static/shaders/glsl/func_brightmap.fp b/wadsrc/static/shaders/glsl/func_brightmap.fp index b8b2a9f20..bea336eb6 100644 --- a/wadsrc/static/shaders/glsl/func_brightmap.fp +++ b/wadsrc/static/shaders/glsl/func_brightmap.fp @@ -2,11 +2,11 @@ uniform sampler2D texture2; vec4 ProcessTexel() { - return getTexel(gl_TexCoord[0].st); + return getTexel(vTexCoord.st); } vec4 ProcessLight(vec4 color) { - vec4 brightpix = desaturate(texture2D(texture2, gl_TexCoord[0].st)); + vec4 brightpix = desaturate(texture2D(texture2, vTexCoord.st)); return vec4(min (color.rgb + brightpix.rgb, 1.0), color.a); } diff --git a/wadsrc/static/shaders/glsl/func_normal.fp b/wadsrc/static/shaders/glsl/func_normal.fp index d3b0d182c..184c14851 100644 --- a/wadsrc/static/shaders/glsl/func_normal.fp +++ b/wadsrc/static/shaders/glsl/func_normal.fp @@ -1,6 +1,6 @@ vec4 ProcessTexel() { - return getTexel(gl_TexCoord[0].st); + return getTexel(vTexCoord.st); } diff --git a/wadsrc/static/shaders/glsl/func_warp1.fp b/wadsrc/static/shaders/glsl/func_warp1.fp index 2dbf8a420..891eaa936 100644 --- a/wadsrc/static/shaders/glsl/func_warp1.fp +++ b/wadsrc/static/shaders/glsl/func_warp1.fp @@ -2,7 +2,7 @@ uniform float timer; vec4 ProcessTexel() { - vec2 texCoord = gl_TexCoord[0].st; + vec2 texCoord = vTexCoord.st; const float pi = 3.14159265358979323846; vec2 offset = vec2(0,0); diff --git a/wadsrc/static/shaders/glsl/func_warp2.fp b/wadsrc/static/shaders/glsl/func_warp2.fp index 78044f970..7cc5e7ebb 100644 --- a/wadsrc/static/shaders/glsl/func_warp2.fp +++ b/wadsrc/static/shaders/glsl/func_warp2.fp @@ -2,7 +2,7 @@ uniform float timer; vec4 ProcessTexel() { - vec2 texCoord = gl_TexCoord[0].st; + vec2 texCoord = vTexCoord.st; const float pi = 3.14159265358979323846; vec2 offset = vec2(0.0,0.0); diff --git a/wadsrc/static/shaders/glsl/func_wavex.fp b/wadsrc/static/shaders/glsl/func_wavex.fp index 5172239c7..e4230ae87 100644 --- a/wadsrc/static/shaders/glsl/func_wavex.fp +++ b/wadsrc/static/shaders/glsl/func_wavex.fp @@ -2,7 +2,7 @@ uniform float timer; vec4 ProcessTexel() { - vec2 texCoord = gl_TexCoord[0].st; + vec2 texCoord = vTexCoord.st; const float pi = 3.14159265358979323846; diff --git a/wadsrc/static/shaders/glsl/fuzz_jagged.fp b/wadsrc/static/shaders/glsl/fuzz_jagged.fp index 103f34689..c088c7b30 100644 --- a/wadsrc/static/shaders/glsl/fuzz_jagged.fp +++ b/wadsrc/static/shaders/glsl/fuzz_jagged.fp @@ -3,7 +3,7 @@ uniform float timer; vec4 ProcessTexel() { - vec2 texCoord = gl_TexCoord[0].st; + vec2 texCoord = vTexCoord.st; vec2 texSplat; const float pi = 3.14159265358979323846; diff --git a/wadsrc/static/shaders/glsl/fuzz_noise.fp b/wadsrc/static/shaders/glsl/fuzz_noise.fp index 02985a122..9f5da5f25 100644 --- a/wadsrc/static/shaders/glsl/fuzz_noise.fp +++ b/wadsrc/static/shaders/glsl/fuzz_noise.fp @@ -3,7 +3,7 @@ uniform float timer; vec4 ProcessTexel() { - vec2 texCoord = gl_TexCoord[0].st; + vec2 texCoord = vTexCoord.st; vec4 basicColor = getTexel(texCoord); texCoord.x = float( int(texCoord.x * 128.0) ) / 128.0; diff --git a/wadsrc/static/shaders/glsl/fuzz_smooth.fp b/wadsrc/static/shaders/glsl/fuzz_smooth.fp index 597debb53..4261d5415 100644 --- a/wadsrc/static/shaders/glsl/fuzz_smooth.fp +++ b/wadsrc/static/shaders/glsl/fuzz_smooth.fp @@ -3,7 +3,7 @@ uniform float timer; vec4 ProcessTexel() { - vec2 texCoord = gl_TexCoord[0].st; + vec2 texCoord = vTexCoord.st; vec4 basicColor = getTexel(texCoord); float texX = texCoord.x / 3.0 + 0.66; diff --git a/wadsrc/static/shaders/glsl/fuzz_smoothnoise.fp b/wadsrc/static/shaders/glsl/fuzz_smoothnoise.fp index 196cca33a..bfe04ec16 100644 --- a/wadsrc/static/shaders/glsl/fuzz_smoothnoise.fp +++ b/wadsrc/static/shaders/glsl/fuzz_smoothnoise.fp @@ -3,7 +3,7 @@ uniform float timer; vec4 ProcessTexel() { - vec2 texCoord = gl_TexCoord[0].st; + vec2 texCoord = vTexCoord.st; vec4 basicColor = getTexel(texCoord); float texX = sin(mod(texCoord.x * 100.0 + timer*5.0, 3.489)) + texCoord.x / 4.0; diff --git a/wadsrc/static/shaders/glsl/fuzz_smoothtranslucent.fp b/wadsrc/static/shaders/glsl/fuzz_smoothtranslucent.fp index bfd60de57..75bee0330 100644 --- a/wadsrc/static/shaders/glsl/fuzz_smoothtranslucent.fp +++ b/wadsrc/static/shaders/glsl/fuzz_smoothtranslucent.fp @@ -3,7 +3,7 @@ uniform float timer; vec4 ProcessTexel() { - vec2 texCoord = gl_TexCoord[0].st; + vec2 texCoord = vTexCoord.st; vec4 basicColor = getTexel(texCoord); float texX = sin(texCoord.x * 100.0 + timer*5.0); diff --git a/wadsrc/static/shaders/glsl/fuzz_standard.fp b/wadsrc/static/shaders/glsl/fuzz_standard.fp index a1bd0ebaf..fd87eaa46 100644 --- a/wadsrc/static/shaders/glsl/fuzz_standard.fp +++ b/wadsrc/static/shaders/glsl/fuzz_standard.fp @@ -3,7 +3,7 @@ uniform float timer; vec4 ProcessTexel() { - vec2 texCoord = gl_TexCoord[0].st; + vec2 texCoord = vTexCoord.st; vec4 basicColor = getTexel(texCoord); texCoord.x = float( int(texCoord.x * 128.0) ) / 128.0; diff --git a/wadsrc/static/shaders/glsl/fuzz_swirly.fp b/wadsrc/static/shaders/glsl/fuzz_swirly.fp index de91e47d6..86a66ac8e 100644 --- a/wadsrc/static/shaders/glsl/fuzz_swirly.fp +++ b/wadsrc/static/shaders/glsl/fuzz_swirly.fp @@ -3,7 +3,7 @@ uniform float timer; vec4 ProcessTexel() { - vec2 texCoord = gl_TexCoord[0].st; + vec2 texCoord = vTexCoord.st; vec4 basicColor = getTexel(texCoord); float texX = sin(texCoord.x * 100.0 + timer*5.0); diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 30a815b3c..6bb96aa9a 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -1,6 +1,8 @@ in vec4 pixelpos; in vec2 glowdist; +in vec4 vTexCoord; +in vec4 vColor; #ifdef SHADER_STORAGE_LIGHTS layout(std430, binding = 3) buffer ParameterBuffer @@ -120,7 +122,7 @@ float R_DoomLightingEquation(float light, float dist) vec4 getLightColor(float fogdist, float fogfactor) { - vec4 color = gl_Color; + vec4 color = vColor; if (uLightLevel >= 0.0) { @@ -193,7 +195,7 @@ vec4 getLightColor(float fogdist, float fogfactor) color.rgb = clamp(color.rgb + desaturate(dynlight).rgb, 0.0, 1.4); // prevent any unintentional messing around with the alpha. - return vec4(color.rgb, gl_Color.a); + return vec4(color.rgb, vColor.a); } //=========================================================================== @@ -291,14 +293,14 @@ void main() { float gray = (frag.r * 0.3 + frag.g * 0.56 + frag.b * 0.14); vec4 cm = uFixedColormapStart + gray * uFixedColormapRange; - frag = vec4(clamp(cm.rgb, 0.0, 1.0), frag.a*gl_Color.a); + frag = vec4(clamp(cm.rgb, 0.0, 1.0), frag.a*vColor.a); break; } case 2: { frag = frag * uFixedColormapStart; - frag.a *= gl_Color.a; + frag.a *= vColor.a; break; } @@ -320,7 +322,7 @@ void main() } fogfactor = exp2 (uFogDensity * fogdist); - frag = vec4(uFogColor.rgb, (1.0 - fogfactor) * frag.a * 0.75 * gl_Color.a); + frag = vec4(uFogColor.rgb, (1.0 - fogfactor) * frag.a * 0.75 * vColor.a); break; } } diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 7a434ccbe..e1349857e 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -5,6 +5,9 @@ out vec4 pixelpos; out vec2 glowdist; #endif +out vec4 vTexCoord; +out vec4 vColor; + #ifdef UNIFORM_VB uniform float fakeVB[100]; #endif @@ -40,7 +43,7 @@ void main() vec4 eyeCoordPos = ViewMatrix * worldcoord; - gl_FrontColor = gl_Color; + vColor = gl_Color; #ifndef SIMPLE pixelpos.xyz = worldcoord.xyz; @@ -56,9 +59,9 @@ void main() vec3 r = reflect(u, n.xyz); float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) ); vec2 sst = vec2(r.x/m + 0.5, r.y/m + 0.5); - gl_TexCoord[0].xy = sst; + vTexCoord.xy = sst; #else - gl_TexCoord[0] = TextureMatrix * tc; + vTexCoord = TextureMatrix * tc; #endif gl_Position = ProjectionMatrix * eyeCoordPos; From 5a322742c350007b5f2b715de7e565673e78a635 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Jul 2014 00:37:13 +0200 Subject: [PATCH 0156/1509] - remove use of builtin and deprecated color vertex attribute. --- src/gl/renderer/gl_renderstate.cpp | 2 +- src/gl/scene/gl_skydome.cpp | 4 ++-- src/gl/shaders/gl_shader.cpp | 5 +++-- src/gl/shaders/gl_shader.h | 1 + wadsrc/static/shaders/glsl/main.vp | 3 ++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 917170872..6f5b9be14 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -136,7 +136,7 @@ bool FRenderState::ApplyShader() } } - glColor4fv(mColor.vec); + glVertexAttrib4fv(VATTR_COLOR, mColor.vec); activeShader->muDesaturation.Set(mDesaturation / 255.f); activeShader->muFogEnabled.Set(fogset); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 240bf6762..c54fb8c16 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -82,10 +82,10 @@ FSkyVertexBuffer::FSkyVertexBuffer() glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glVertexPointer(3, GL_FLOAT, sizeof(FSkyVertex), &VSO->x); glTexCoordPointer(2, GL_FLOAT, sizeof(FSkyVertex), &VSO->u); - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(FSkyVertex), &VSO->color); + glVertexAttribPointer(VATTR_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(FSkyVertex), &VSO->color); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); + glEnableVertexAttribArray(VATTR_COLOR); glBindVertexArray(0); } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 4373955c2..ba3db27ea 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -120,6 +120,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * fp_comb.Substitute("vec4 frag = ProcessTexel();", "vec4 frag = Process(vec4(1.0));"); } fp_comb << pp_data.GetString().GetChars(); + fp_comb.Substitute("gl_TexCoord[0]", "vTexCoord"); // fix old custom shaders. if (pp_data.GetString().IndexOf("ProcessLight") < 0) { @@ -156,6 +157,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * glAttachShader(hShader, hVertProg); glAttachShader(hShader, hFragProg); + glBindAttribLocation(hShader, VATTR_COLOR, "aColor"); + glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2"); glLinkProgram(hShader); @@ -213,8 +216,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * modelmatrix_index = glGetUniformLocation(hShader, "ModelMatrix"); texturematrix_index = glGetUniformLocation(hShader, "TextureMatrix"); - glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2"); - glUseProgram(hShader); int texture_index = glGetUniformLocation(hShader, "texture2"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index bed37cbb0..2e0731346 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -9,6 +9,7 @@ extern bool gl_shaderactive; enum { + VATTR_COLOR = 14, VATTR_VERTEX2 = 15 }; diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index e1349857e..8a1709ecf 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -1,4 +1,5 @@ +in vec4 aColor; #ifndef SIMPLE // we do not need these for simple shaders in vec4 aVertex2; out vec4 pixelpos; @@ -43,7 +44,7 @@ void main() vec4 eyeCoordPos = ViewMatrix * worldcoord; - vColor = gl_Color; + vColor = aColor; #ifndef SIMPLE pixelpos.xyz = worldcoord.xyz; From 1b7f5a2e6aca704711e581259c335ba05f1be662 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Jul 2014 00:59:01 +0200 Subject: [PATCH 0157/1509] - replaced builtin texture coordinate vertex attribute. --- src/gl/data/gl_vertexbuffer.cpp | 6 ++++-- src/gl/models/gl_models.cpp | 4 ++-- src/gl/scene/gl_skydome.cpp | 4 ++-- src/gl/shaders/gl_shader.cpp | 2 ++ src/gl/shaders/gl_shader.h | 6 ++++-- wadsrc/static/shaders/glsl/main.vp | 14 ++++++-------- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index d9d96c855..a1d553e15 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -115,9 +115,9 @@ FFlatVertexBuffer::FFlatVertexBuffer() glBindVertexArray(vao_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glVertexPointer(3,GL_FLOAT, sizeof(FFlatVertex), &VTO->x); - glTexCoordPointer(2,GL_FLOAT, sizeof(FFlatVertex), &VTO->u); + glVertexAttribPointer(VATTR_TEXCOORD, 2,GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableVertexAttribArray(VATTR_TEXCOORD); glBindVertexArray(0); } @@ -140,6 +140,7 @@ CVAR(Bool, gl_testbuffer, false, 0) void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count) { +#if 0 if (!gl_testbuffer) // todo: remove the immediate mode calls once the uniform array method has been tested. { glBegin(primtype); @@ -151,6 +152,7 @@ void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offs glEnd(); } else +#endif { if (count > 20) { diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 3ea25aead..e779cb0c9 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -117,7 +117,7 @@ FModelVertexBuffer::FModelVertexBuffer() glBufferData(GL_ELEMENT_ARRAY_BUFFER,ibo_shadowdata.Size() * sizeof(unsigned int), &ibo_shadowdata[0], GL_STATIC_DRAW); glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableVertexAttribArray(VATTR_TEXCOORD); glEnableVertexAttribArray(VATTR_VERTEX2); glBindVertexArray(0); } @@ -141,7 +141,7 @@ FModelVertexBuffer::~FModelVertexBuffer() unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int frame2, float factor) { glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].x); - glTexCoordPointer(2, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].u); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].u); glVertexAttribPointer(VATTR_VERTEX2, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame2].x); return frame1; } diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index c54fb8c16..0b902bba0 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -81,10 +81,10 @@ FSkyVertexBuffer::FSkyVertexBuffer() glBindVertexArray(vao_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glVertexPointer(3, GL_FLOAT, sizeof(FSkyVertex), &VSO->x); - glTexCoordPointer(2, GL_FLOAT, sizeof(FSkyVertex), &VSO->u); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->u); glVertexAttribPointer(VATTR_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(FSkyVertex), &VSO->color); glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableVertexAttribArray(VATTR_TEXCOORD); glEnableVertexAttribArray(VATTR_COLOR); glBindVertexArray(0); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index ba3db27ea..86f4ec928 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -157,6 +157,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * glAttachShader(hShader, hVertProg); glAttachShader(hShader, hFragProg); + + glBindAttribLocation(hShader, VATTR_TEXCOORD, "aTexCoord"); glBindAttribLocation(hShader, VATTR_COLOR, "aColor"); glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 2e0731346..6675e235e 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -9,8 +9,10 @@ extern bool gl_shaderactive; enum { - VATTR_COLOR = 14, - VATTR_VERTEX2 = 15 + VATTR_VERTEX = 0, + VATTR_TEXCOORD = 1, + VATTR_COLOR = 2, + VATTR_VERTEX2 = 3 }; diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 8a1709ecf..7c62f77f8 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -1,4 +1,5 @@ +in vec2 aTexCoord; in vec4 aColor; #ifndef SIMPLE // we do not need these for simple shaders in vec4 aVertex2; @@ -15,26 +16,23 @@ uniform float fakeVB[100]; void main() { - -#ifdef UNIFORM_VB vec4 vert; vec4 tc; + +#ifdef UNIFORM_VB if (gl_MultiTexCoord0.x >= 100000.0) { - int fakeVI = int(gl_MultiTexCoord0.y)*5; + int fakeVI = int(aTexCoord.y)*5; vert = gl_Vertex + vec4(fakeVB[fakeVI], fakeVB[fakeVI+1], fakeVB[fakeVI+2], 0.0); tc = vec4(fakeVB[fakeVI+3], fakeVB[fakeVI+4], 0.0, 0.0); } else +#endif { vert = gl_Vertex; - tc = gl_MultiTexCoord0; + tc = vec4(aTexCoord, 0.0, 0.0); } -#else - #define vert gl_Vertex - #define tc gl_MultiTexCoord0 -#endif #ifndef SIMPLE vec4 worldcoord = ModelMatrix * mix(vert, aVertex2, uInterpolationFactor); From eedc5a69be772ab045d79539c8bbeb0f253cdc20 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Jul 2014 01:02:48 +0200 Subject: [PATCH 0158/1509] - replaced builtin position vertex attribute. --- src/gl/data/gl_vertexbuffer.cpp | 4 ++-- src/gl/models/gl_models.cpp | 4 ++-- src/gl/scene/gl_skydome.cpp | 4 ++-- src/gl/shaders/gl_shader.cpp | 1 + wadsrc/static/shaders/glsl/main.vp | 5 +++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index a1d553e15..01c7ee3b9 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -114,9 +114,9 @@ FFlatVertexBuffer::FFlatVertexBuffer() glBindVertexArray(vao_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glVertexPointer(3,GL_FLOAT, sizeof(FFlatVertex), &VTO->x); + glVertexAttribPointer(VATTR_VERTEX, 3,GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); glVertexAttribPointer(VATTR_TEXCOORD, 2,GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); - glEnableClientState(GL_VERTEX_ARRAY); + glEnableVertexAttribArray(VATTR_VERTEX); glEnableVertexAttribArray(VATTR_TEXCOORD); glBindVertexArray(0); } diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index e779cb0c9..3d2d0db05 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -116,7 +116,7 @@ FModelVertexBuffer::FModelVertexBuffer() glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); glBufferData(GL_ELEMENT_ARRAY_BUFFER,ibo_shadowdata.Size() * sizeof(unsigned int), &ibo_shadowdata[0], GL_STATIC_DRAW); - glEnableClientState(GL_VERTEX_ARRAY); + glEnableVertexAttribArray(VATTR_VERTEX); glEnableVertexAttribArray(VATTR_TEXCOORD); glEnableVertexAttribArray(VATTR_VERTEX2); glBindVertexArray(0); @@ -140,7 +140,7 @@ FModelVertexBuffer::~FModelVertexBuffer() unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int frame2, float factor) { - glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].x); + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].x); glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].u); glVertexAttribPointer(VATTR_VERTEX2, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame2].x); return frame1; diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 0b902bba0..a2c0cf981 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -80,10 +80,10 @@ FSkyVertexBuffer::FSkyVertexBuffer() glBindVertexArray(vao_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glVertexPointer(3, GL_FLOAT, sizeof(FSkyVertex), &VSO->x); + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->x); glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->u); glVertexAttribPointer(VATTR_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(FSkyVertex), &VSO->color); - glEnableClientState(GL_VERTEX_ARRAY); + glEnableVertexAttribArray(VATTR_VERTEX); glEnableVertexAttribArray(VATTR_TEXCOORD); glEnableVertexAttribArray(VATTR_COLOR); glBindVertexArray(0); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 86f4ec928..2ce815500 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -158,6 +158,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * glAttachShader(hShader, hVertProg); glAttachShader(hShader, hFragProg); + glBindAttribLocation(hShader, VATTR_VERTEX, "aPosition"); glBindAttribLocation(hShader, VATTR_TEXCOORD, "aTexCoord"); glBindAttribLocation(hShader, VATTR_COLOR, "aColor"); glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2"); diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 7c62f77f8..eab0e1ab2 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -1,4 +1,5 @@ +in vec4 aPosition; in vec2 aTexCoord; in vec4 aColor; #ifndef SIMPLE // we do not need these for simple shaders @@ -24,13 +25,13 @@ void main() if (gl_MultiTexCoord0.x >= 100000.0) { int fakeVI = int(aTexCoord.y)*5; - vert = gl_Vertex + vec4(fakeVB[fakeVI], fakeVB[fakeVI+1], fakeVB[fakeVI+2], 0.0); + vert = aPosition + vec4(fakeVB[fakeVI], fakeVB[fakeVI+1], fakeVB[fakeVI+2], 0.0); tc = vec4(fakeVB[fakeVI+3], fakeVB[fakeVI+4], 0.0, 0.0); } else #endif { - vert = gl_Vertex; + vert = aPosition; tc = vec4(aTexCoord, 0.0, 0.0); } From 6046b11b4f38b8657a41666b8a8985955c09e1e5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Jul 2014 01:05:53 +0200 Subject: [PATCH 0159/1509] - all shaders now compile in core profile. --- src/gl/shaders/gl_shader.cpp | 2 +- wadsrc/static/shaders/glsl/burn.fp | 3 ++- wadsrc/static/shaders/glsl/fogboundary.fp | 3 ++- wadsrc/static/shaders/glsl/main.fp | 4 +++- wadsrc/static/shaders/glsl/stencil.fp | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 2ce815500..b056def8e 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -88,7 +88,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * // FString vp_comb = "#version 130\n"; - if (gl.glslversion >= 3.3f) vp_comb = "#version 330 compatibility\n"; // I can't shut up the deprecation warnings in GLSL 1.3 so if available use a version with compatibility profile. + if (gl.glslversion >= 3.3f) vp_comb = "#version 330 core\n"; // I can't shut up the deprecation warnings in GLSL 1.3 so if available use a version with compatibility profile. // todo when using shader storage buffers, add // "#version 400 compatibility\n#extension GL_ARB_shader_storage_buffer_object : require\n" instead. diff --git a/wadsrc/static/shaders/glsl/burn.fp b/wadsrc/static/shaders/glsl/burn.fp index d14748212..0cc3f7950 100644 --- a/wadsrc/static/shaders/glsl/burn.fp +++ b/wadsrc/static/shaders/glsl/burn.fp @@ -2,6 +2,7 @@ uniform sampler2D tex; uniform sampler2D texture2; in vec4 vTexCoord; in vec4 vColor; +out vec4 FragColor; void main() { @@ -10,5 +11,5 @@ void main() vec4 t1 = texture2D(texture2, vTexCoord.xy); vec4 t2 = texture2D(tex, vec2(vTexCoord.x, 1.0-vTexCoord.y)); - gl_FragColor = frag * vec4(t1.r, t1.g, t1.b, t2.a); + FragColor = frag * vec4(t1.r, t1.g, t1.b, t2.a); } diff --git a/wadsrc/static/shaders/glsl/fogboundary.fp b/wadsrc/static/shaders/glsl/fogboundary.fp index edf9384c6..1a2b0b0f9 100644 --- a/wadsrc/static/shaders/glsl/fogboundary.fp +++ b/wadsrc/static/shaders/glsl/fogboundary.fp @@ -1,5 +1,6 @@ in vec4 pixelpos; in vec2 glowdist; +out vec4 FragColor; //=========================================================================== // @@ -30,6 +31,6 @@ void main() fogdist = max(16.0, distance(pixelpos.xyz, uCameraPos.xyz)); } fogfactor = exp2 (uFogDensity * fogdist); - gl_FragColor = vec4(uFogColor.rgb, 1.0 - fogfactor); + FragColor = vec4(uFogColor.rgb, 1.0 - fogfactor); } diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 6bb96aa9a..c56057401 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -4,6 +4,8 @@ in vec2 glowdist; in vec4 vTexCoord; in vec4 vColor; +out vec4 FragColor; + #ifdef SHADER_STORAGE_LIGHTS layout(std430, binding = 3) buffer ParameterBuffer { @@ -326,6 +328,6 @@ void main() break; } } - gl_FragColor = frag; + FragColor = frag; } diff --git a/wadsrc/static/shaders/glsl/stencil.fp b/wadsrc/static/shaders/glsl/stencil.fp index 9e4afec04..d1b8745f6 100644 --- a/wadsrc/static/shaders/glsl/stencil.fp +++ b/wadsrc/static/shaders/glsl/stencil.fp @@ -1,7 +1,8 @@ in vec4 pixelpos; +out vec4 FragColor; void main() { - gl_FragColor = vec4(1.0); + FragColor = vec4(1.0); } From fc0cf4f998ec4721a7c44dd9f16bdcef45ca80f8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Jul 2014 02:26:23 +0200 Subject: [PATCH 0160/1509] - GZDoom now runs on an OpenGL core profile. :) It's probably still necessary to replace GLEW with another loader library. GLEW is pretty much broken on core OpenGL without some hacky workarounds... --- src/gl/system/gl_framebuffer.cpp | 2 +- src/gl/system/gl_interface.cpp | 37 ++++++++++------------ src/gl/system/gl_system.h | 1 - src/win32/win32gliface.cpp | 50 ++++++++++++++---------------- src/win32/win32gliface.h | 4 +-- wadsrc/static/shaders/glsl/main.vp | 2 +- 6 files changed, 45 insertions(+), 51 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index d3783fd42..fa5370b2d 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -121,6 +121,7 @@ void OpenGLFrameBuffer::InitializeState() if (first) { + glewExperimental=TRUE; glewInit(); } @@ -140,7 +141,6 @@ void OpenGLFrameBuffer::InitializeState() glDepthFunc(GL_LESS); glEnable(GL_DITHER); - glEnable(GL_ALPHA_TEST); glDisable(GL_CULL_FACE); glDisable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_LINE); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 5b99bd562..e1c70b14a 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -61,24 +61,15 @@ int occlusion_type=0; static void CollectExtensions() { - const char *supported = NULL; - char *extensions, *extension; + const char *extension; - supported = (char *)glGetString(GL_EXTENSIONS); + int max = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &max); - if (supported) + for(int i = 0; i < max; i++) { - extensions = new char[strlen(supported) + 1]; - strcpy(extensions, supported); - - extension = strtok(extensions, " "); - while(extension) - { - m_Extensions.Push(FString(extension)); - extension = strtok(NULL, " "); - } - - delete [] extensions; + extension = (const char*)glGetStringi(GL_EXTENSIONS, i); + m_Extensions.Push(FString(extension)); } } @@ -132,14 +123,16 @@ void gl_LoadExtensions() { I_FatalError("Unsupported OpenGL version.\nAt least GL 3.0 is required to run " GAMENAME ".\n"); } - gl.version = strtod(version, NULL); - gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL); + + // add 0.01 to account for roundoff errors making the number a tad smaller than the actual version + gl.version = strtod(version, NULL) + 0.01f; + gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL) + 0.01f; gl.vendorstring=(char*)glGetString(GL_VENDOR); if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; - if (gl.version >= 4.f && CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; + if (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -157,11 +150,15 @@ void gl_PrintStartupLog() Printf ("GL_RENDERER: %s\n", glGetString(GL_RENDERER)); Printf ("GL_VERSION: %s\n", glGetString(GL_VERSION)); Printf ("GL_SHADING_LANGUAGE_VERSION: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); - Printf ("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS)); + Printf ("GL_EXTENSIONS:"); + for (unsigned i = 0; i < m_Extensions.Size(); i++) + { + Printf(" %s", m_Extensions[i].GetChars()); + } int v; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &v); - Printf("Max. texture size: %d\n", v); + Printf("\nMax. texture size: %d\n", v); glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &v); Printf ("Max. texture units: %d\n", v); glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h index 8273960f9..2130c9cbb 100644 --- a/src/gl/system/gl_system.h +++ b/src/gl/system/gl_system.h @@ -68,7 +68,6 @@ //GL headers #include -//#include "gl_load.h" #if defined(__APPLE__) #include diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 7b70e9172..db414bae6 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -610,7 +610,7 @@ bool Win32GLVideo::SetPixelFormat() // //========================================================================== -bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, int multisample) +bool Win32GLVideo::SetupPixelFormat(int multisample) { int colorDepth; HDC deskDC; @@ -646,14 +646,7 @@ bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, int multisample) attributes[17] = true; attributes[18] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB - if (allowsoftware) - { - attributes[19] = WGL_NO_ACCELERATION_ARB; - } - else - { - attributes[19] = WGL_FULL_ACCELERATION_ARB; - } + attributes[19] = WGL_FULL_ACCELERATION_ARB; if (multisample > 0) { @@ -713,11 +706,8 @@ bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, int multisample) if (pfd.dwFlags & PFD_GENERIC_FORMAT) { - if (!allowsoftware) - { - Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n"); - return false; - } + Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n"); + return false; } } @@ -735,32 +725,40 @@ bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, int multisample) // //========================================================================== -bool Win32GLVideo::InitHardware (HWND Window, bool allowsoftware, int multisample) +bool Win32GLVideo::InitHardware (HWND Window, int multisample) { m_Window=Window; m_hDC = GetDC(Window); - if (!SetupPixelFormat(allowsoftware, multisample)) + if (!SetupPixelFormat(multisample)) { Printf ("R_OPENGL: Reverting to software mode...\n"); return false; } - m_hRC = 0; + m_hRC = NULL; if (myWglCreateContextAttribsARB != NULL) { - int ctxAttribs[] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3, - WGL_CONTEXT_MINOR_VERSION_ARB, 3, - WGL_CONTEXT_FLAGS_ARB, gl_debug? WGL_CONTEXT_DEBUG_BIT_ARB : 0, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, - 0 - }; + // let's try to get the best version possible. + static int versions[] = { 44, 43, 42, 41, 40, 33, 32, -1 }; - m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); + for (int i = 0; versions[i] > 0; i++) + { + int ctxAttribs[] = { + WGL_CONTEXT_MAJOR_VERSION_ARB, versions[i] / 10, + WGL_CONTEXT_MINOR_VERSION_ARB, versions[i] % 10, + WGL_CONTEXT_FLAGS_ARB, gl_debug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; + + m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); + if (m_hRC != NULL) break; + } } if (m_hRC == 0) { + // If we are unable to get a core context, let's try whatever the system gives us. m_hRC = wglCreateContext(m_hDC); } @@ -903,7 +901,7 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in I_RestoreWindowedPos(); } - if (!static_cast(Video)->InitHardware(Window, false, localmultisample)) + if (!static_cast(Video)->InitHardware(Window, localmultisample)) { vid_renderer = 0; return; diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index f39a9f70b..f61c31857 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -42,7 +42,7 @@ public: DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old); virtual bool SetResolution (int width, int height, int bits); void DumpAdapters(); - bool InitHardware (HWND Window, bool allowsoftware, int multisample); + bool InitHardware (HWND Window, int multisample); void Shutdown(); bool SetFullscreen(const char *devicename, int w, int h, int bits, int hz); @@ -81,7 +81,7 @@ protected: HWND InitDummy(); void ShutdownDummy(HWND dummy); bool SetPixelFormat(); - bool SetupPixelFormat(bool allowsoftware, int multisample); + bool SetupPixelFormat(int multisample); void GetDisplayDeviceName(); void MakeModesList(); diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index eab0e1ab2..c40426829 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -22,7 +22,7 @@ void main() #ifdef UNIFORM_VB - if (gl_MultiTexCoord0.x >= 100000.0) + if (aTexCoord.x >= 100000.0) { int fakeVI = int(aTexCoord.y)*5; vert = aPosition + vec4(fakeVB[fakeVI], fakeVB[fakeVI+1], fakeVB[fakeVI+2], 0.0); From fb6b4238ed32e82ff1dfb1f08cc49a9bb972e8d8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Jul 2014 02:48:59 +0200 Subject: [PATCH 0161/1509] - fixed: glProgramUniform is only present from GL 4.1 or a specific extension so it may not be used on systems not supporting it. --- src/gl/scene/gl_flats.cpp | 4 ++-- src/gl/shaders/gl_shader.cpp | 25 ++++++++++++++++++++++--- src/gl/system/gl_interface.cpp | 2 ++ src/gl/system/gl_interface.h | 7 ++++--- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 91c7f1c7e..19eb3b9e1 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -298,9 +298,9 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) { if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub); - //drawcalls.Clock(); + drawcalls.Clock(); glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines); - //drawcalls.Unclock(); + drawcalls.Unclock(); flatvertices += sub->numlines; flatprimitives++; } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index b056def8e..db3e68298 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -293,8 +293,18 @@ FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath void FShader::ApplyMatrices(VSMatrix *proj, VSMatrix *view) { - glProgramUniformMatrix4fv(hShader, projectionmatrix_index, 1, false, proj->get()); - glProgramUniformMatrix4fv(hShader, viewmatrix_index, 1, false, view->get()); + + if (gl.flags & RFL_SEPARATE_SHADER_OBJECTS) + { + glProgramUniformMatrix4fv(hShader, projectionmatrix_index, 1, false, proj->get()); + glProgramUniformMatrix4fv(hShader, viewmatrix_index, 1, false, view->get()); + } + else + { + Bind(); + glUniformMatrix4fv(projectionmatrix_index, 1, false, proj->get()); + glUniformMatrix4fv(viewmatrix_index, 1, false, view->get()); + } } @@ -486,7 +496,16 @@ void FShaderManager::SetWarpSpeed(unsigned int eff, float speed) FShader *sh = mTextureEffects[eff]; float warpphase = gl_frameMS * speed / 1000.f; - glProgramUniform1f(sh->GetHandle(), sh->timer_index, warpphase); + if (gl.flags & RFL_SEPARATE_SHADER_OBJECTS) + { + glProgramUniform1f(sh->GetHandle(), sh->timer_index, warpphase); + } + else + { + // not so pretty... + sh->Bind(); + glUniform1f(sh->timer_index, warpphase); + } } } diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index e1c70b14a..f00202fd8 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -133,6 +133,8 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; if (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; + if (CheckExtension("GL_ARB_separate_shader_objects")) gl.flags |= RFL_SEPARATE_SHADER_OBJECTS; + glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 74beb72a4..0f569d2c4 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -9,9 +9,10 @@ enum RenderFlags RFL_TEXTURE_COMPRESSION=1, RFL_TEXTURE_COMPRESSION_S3TC=2, - RFL_BUFFER_STORAGE = 8, - RFL_SHADER_STORAGE_BUFFER = 16, - RFL_BASEINDEX = 32, + RFL_SEPARATE_SHADER_OBJECTS = 4, // we need this extension for glProgramUniform. On hardware not supporting it we need some rather clumsy workarounds + RFL_BUFFER_STORAGE = 8, // allows persistently mapped buffers, which are the only efficient way to actually use a dynamic vertex buffer. If this isn't present, a workaround with uniform arrays is used. + RFL_SHADER_STORAGE_BUFFER = 16, // to be used later for a parameter buffer + RFL_BASEINDEX = 32, // currently unused }; enum TexMode From b8bcbe819be221b9fed81615158fdcc0dda2e861 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Jul 2014 20:49:21 +0200 Subject: [PATCH 0162/1509] - removed texture based dynamic lighting. For GL 3.x the shader approach is always better. - fixed: sky fog was not unset. --- src/gl/dynlights/a_dynlight.cpp | 19 +-- src/gl/dynlights/gl_dynlight.h | 2 - src/gl/dynlights/gl_dynlight1.cpp | 108 ------------- src/gl/renderer/gl_renderer.cpp | 4 +- src/gl/renderer/gl_renderer.h | 3 +- src/gl/scene/gl_drawinfo.h | 22 +-- src/gl/scene/gl_flats.cpp | 163 ++------------------ src/gl/scene/gl_portal.cpp | 2 +- src/gl/scene/gl_scene.cpp | 97 +----------- src/gl/scene/gl_skydome.cpp | 1 + src/gl/scene/gl_sprite.cpp | 2 +- src/gl/scene/gl_spritelight.cpp | 55 ++++--- src/gl/scene/gl_wall.h | 2 +- src/gl/scene/gl_walls.cpp | 52 +------ src/gl/scene/gl_walls_draw.cpp | 248 ++++++++---------------------- src/r_defs.h | 6 +- wadsrc/static/glstuff/gllight.png | Bin 13073 -> 0 bytes 17 files changed, 129 insertions(+), 657 deletions(-) delete mode 100644 wadsrc/static/glstuff/gllight.png diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index b462b62ac..bcc126ecf 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -521,14 +521,12 @@ void ADynamicLight::CollectWithinRadius(subsector_t *subSec, float radius) { if (!subSec) return; - bool additive = (flags4&MF4_ADDITIVE) || gl_lights_additive; - subSec->validcount = ::validcount; - touching_subsectors = AddLightNode(&subSec->lighthead[additive], subSec, this, touching_subsectors); + touching_subsectors = AddLightNode(&subSec->lighthead, subSec, this, touching_subsectors); if (subSec->sector->validcount != ::validcount) { - touching_sector = AddLightNode(&subSec->render_sector->lighthead[additive], subSec->sector, this, touching_sector); + touching_sector = AddLightNode(&subSec->render_sector->lighthead, subSec->sector, this, touching_sector); subSec->sector->validcount = ::validcount; } @@ -542,7 +540,7 @@ void ADynamicLight::CollectWithinRadius(subsector_t *subSec, float radius) if (DMulScale32 (y-seg->v1->y, seg->v2->x-seg->v1->x, seg->v1->x-x, seg->v2->y-seg->v1->y) <=0) { seg->linedef->validcount=validcount; - touching_sides = AddLightNode(&seg->sidedef->lighthead[additive], seg->sidedef, this, touching_sides); + touching_sides = AddLightNode(&seg->sidedef->lighthead, seg->sidedef, this, touching_sides); } } @@ -755,22 +753,15 @@ CCMD(listsublights) { subsector_t *sub = &subsectors[i]; int lights = 0; - int addlights = 0; - FLightNode * node = sub->lighthead[0]; + FLightNode * node = sub->lighthead; while (node != NULL) { lights++; node = node->nextLight; } - node = sub->lighthead[1]; - while (node != NULL) - { - addlights++; - node = node->nextLight; - } - Printf(PRINT_LOG, "Subsector %d - %d lights, %d additive lights\n", i, lights, addlights); + Printf(PRINT_LOG, "Subsector %d - %d lights\n", i, lights); } } diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index 37cbc4f93..568630898 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -184,8 +184,6 @@ struct FDynLightData bool gl_GetLight(Plane & p, ADynamicLight * light, bool checkside, bool forceadditive, FDynLightData &data); -bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, float & scale, int desaturation, bool checkside=true, bool forceadditive=true); -bool gl_SetupLightTexture(); void gl_UploadLights(FDynLightData &data); diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index 42053e8a5..cee31ee42 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -68,17 +68,6 @@ CUSTOM_CVAR (Bool, gl_lights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOIN else gl_DeleteAllAttachedLights(); } -CUSTOM_CVAR (Bool, gl_dynlight_shader, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ - if (self) - { - if (gl.maxuniforms < 1024 && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) - { - self = false; - } - } -} - CVAR (Bool, gl_attachedlights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CVAR (Bool, gl_lights_checkside, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CVAR (Float, gl_lights_intensity, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); @@ -155,75 +144,6 @@ bool gl_GetLight(Plane & p, ADynamicLight * light, bool checkside, bool forceadd } -//========================================================================== -// -// Sets up the parameters to render one dynamic light onto one plane -// -//========================================================================== -bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, - float & scale, int desaturation, bool checkside, bool forceadditive) -{ - Vector fn, pos; - - float x = FIXED2FLOAT(light->x); - float y = FIXED2FLOAT(light->y); - float z = FIXED2FLOAT(light->z); - - float dist = fabsf(p.DistToPoint(x, z, y)); - float radius = (light->GetRadius() * gl_lights_size); - - if (radius <= 0.f) return false; - if (dist > radius) return false; - if (checkside && gl_lights_checkside && p.PointOnSide(x, z, y)) - { - return false; - } - if (light->owned && light->target != NULL && !light->target->IsVisibleToPlayer()) - { - return false; - } - - scale = 1.0f / ((2.f * radius) - dist); - - // project light position onto plane (find closest point on plane) - - - pos.Set(x,z,y); - fn=p.Normal(); - fn.GetRightUp(right, up); - -#ifdef _MSC_VER - nearPt = pos + fn * dist; -#else - Vector tmpVec = fn * dist; - nearPt = pos + tmpVec; -#endif - - float cs = 1.0f - (dist / radius); - if (gl_lights_additive || light->flags4&MF4_ADDITIVE || forceadditive) cs*=0.2f; // otherwise the light gets too strong. - float r = light->GetRed() / 255.0f * cs * gl_lights_intensity; - float g = light->GetGreen() / 255.0f * cs * gl_lights_intensity; - float b = light->GetBlue() / 255.0f * cs * gl_lights_intensity; - - if (light->IsSubtractive()) - { - Vector v; - - gl_RenderState.BlendEquation(GL_FUNC_REVERSE_SUBTRACT); - v.Set(r, g, b); - r = v.Length() - r; - g = v.Length() - g; - b = v.Length() - b; - } - else - { - gl_RenderState.BlendEquation(GL_FUNC_ADD); - } - gl_RenderState.SetColor(r, g, b, 1.f, desaturation); - return true; -} - - //========================================================================== // // @@ -257,31 +177,3 @@ void gl_UploadLights(FDynLightData &data) } } #endif - -//========================================================================== -// -// -// -//========================================================================== - -bool gl_SetupLightTexture() -{ - - if (GLRenderer->gllight == NULL) return false; - FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight); - pat->BindPatch(0); - return true; -} - - -//========================================================================== -// -// -// -//========================================================================== - -inline fixed_t P_AproxDistance3(fixed_t dx, fixed_t dy, fixed_t dz) -{ - return P_AproxDistance(P_AproxDistance(dx,dy),dz); -} - diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index ae2ba2125..42773496e 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -96,7 +96,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mSkyVBO = NULL; gl_spriteindex = 0; mShaderManager = NULL; - glpart2 = glpart = gllight = mirrortexture = NULL; + glpart2 = glpart = mirrortexture = NULL; } void FGLRenderer::Initialize() @@ -104,7 +104,6 @@ void FGLRenderer::Initialize() glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch); glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch); mirrortexture = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/mirror.png"), FTexture::TEX_MiscPatch); - gllight = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/gllight.png"), FTexture::TEX_MiscPatch); mVBO = new FFlatVertexBuffer; mSkyVBO = new FSkyVertexBuffer; @@ -128,7 +127,6 @@ FGLRenderer::~FGLRenderer() if (glpart2) delete glpart2; if (glpart) delete glpart; if (mirrortexture) delete mirrortexture; - if (gllight) delete gllight; if (mFBID != 0) glDeleteFramebuffers(1, &mFBID); } diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 733123599..a2679f665 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -62,8 +62,7 @@ public: FTexture *glpart2; FTexture *glpart; FTexture *mirrortexture; - FTexture *gllight; - + float mSky1Pos, mSky2Pos; FRotator mAngles; diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index 01a72701b..f4b104392 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -13,14 +13,6 @@ enum GLDrawItemType enum DrawListType { - // These are organized so that the various multipass rendering modes - // have to be set as few times as possible - GLDL_LIGHT, - GLDL_LIGHTBRIGHT, - GLDL_LIGHTMASKED, - GLDL_LIGHTFOG, - GLDL_LIGHTFOGMASKED, - GLDL_PLAIN, GLDL_MASKED, GLDL_FOG, @@ -30,25 +22,15 @@ enum DrawListType GLDL_TRANSLUCENTBORDER, GLDL_TYPES, - - GLDL_FIRSTLIGHT = GLDL_LIGHT, - GLDL_LASTLIGHT = GLDL_LIGHTFOGMASKED, - GLDL_FIRSTNOLIGHT = GLDL_PLAIN, - GLDL_LASTNOLIGHT = GLDL_FOGMASKED, }; enum Drawpasses { - GLPASS_BASE, // Draws the untextured surface only - GLPASS_BASE_MASKED, // Draws an untextured surface that is masked by the texture - GLPASS_PLAIN, // Draws a texture that isn't affected by dynamic lights with sector light settings - GLPASS_LIGHT, // Draws dynamic lights - GLPASS_LIGHT_ADDITIVE, // Draws additive dynamic lights - GLPASS_TEXTURE, // Draws the texture to be modulated with the light information on the base surface + GLPASS_PLAIN, // Main pass without dynamic lights + GLPASS_ALL, // Main pass with dynamic lights GLPASS_DECALS, // Draws a decal GLPASS_DECALS_NOFOG,// Draws a decal without setting the fog (used for passes that need a fog layer) GLPASS_TRANSLUCENT, // Draws translucent objects - GLPASS_ALL // Everything at once, using shaders for dynamic lights }; //========================================================================== diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 19eb3b9e1..2767a5e80 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -103,26 +103,24 @@ void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * glte } + //========================================================================== // // Flats // //========================================================================== +extern FDynLightData lightdata; -void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) +bool GLFlat::SetupSubsectorLights(bool lightsapplied, subsector_t * sub) { Plane p; - Vector nearPt, up, right, t1; - float scale; - unsigned int k; - seg_t *v; - FLightNode * node = sub->lighthead[pass==GLPASS_LIGHT_ADDITIVE]; - gl_RenderState.Apply(); + lightdata.Clear(); + FLightNode * node = sub->lighthead; while (node) { ADynamicLight * light = node->lightsource; - + if (light->flags2&MF2_DORMANT) { node=node->nextLight; @@ -140,72 +138,9 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) } p.Set(plane.plane); - if (!gl_SetupLight(p, light, nearPt, up, right, scale, Colormap.desaturation, false, foggy)) - { - node=node->nextLight; - continue; - } - draw_dlightf++; - gl_RenderState.Apply(); - - // Render the light - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - for (k = 0, v = sub->firstline; k < sub->numlines; k++, v++) - { - vertex_t *vt = v->v1; - float zc = plane.plane.ZatPoint(vt->fx, vt->fy) + dz; - - t1.Set(vt->fx, zc, vt->fy); - Vector nearToVert = t1 - nearPt; - ptr->Set(vt->fx, zc, vt->fy, (nearToVert.Dot(right) * scale) + 0.5f, (nearToVert.Dot(up) * scale) + 0.5f); - ptr++; - } - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + gl_GetLight(p, light, false, false, lightdata); node = node->nextLight; } -} - - -//========================================================================== -// -// Flats -// -//========================================================================== -extern FDynLightData lightdata; - -bool GLFlat::SetupSubsectorLights(bool lightsapplied, subsector_t * sub) -{ - Plane p; - - lightdata.Clear(); - for(int i=0;i<2;i++) - { - FLightNode * node = sub->lighthead[i]; - while (node) - { - ADynamicLight * light = node->lightsource; - - if (light->flags2&MF2_DORMANT) - { - node=node->nextLight; - continue; - } - iter_dlightf++; - - // we must do the side check here because gl_SetupLight needs the correct plane orientation - // which we don't have for Legacy-style 3D-floors - fixed_t planeh = plane.plane.ZatPoint(light->x, light->y); - if (gl_lights_checkside && ((planehz && ceiling) || (planeh>light->z && !ceiling))) - { - node=node->nextLight; - continue; - } - - p.Set(plane.plane); - gl_GetLight(p, light, false, false, lightdata); - node = node->nextLight; - } - } int numlights[3]; @@ -347,7 +282,6 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) //========================================================================== void GLFlat::Draw(int pass) { - int i; int rel = getExtraLight(); #ifdef _DEBUG @@ -360,65 +294,15 @@ void GLFlat::Draw(int pass) switch (pass) { - case GLPASS_BASE: - gl_SetColor(lightlevel, rel, Colormap,1.0f); - if (!foggy) gl_SetFog(lightlevel, rel, &Colormap, false); - DrawSubsectors(pass, false); - break; - case GLPASS_PLAIN: // Single-pass rendering case GLPASS_ALL: - case GLPASS_BASE_MASKED: gl_SetColor(lightlevel, rel, Colormap,1.0f); - if (!foggy || pass != GLPASS_BASE_MASKED) gl_SetFog(lightlevel, rel, &Colormap, false); - // fall through - case GLPASS_TEXTURE: - { + gl_SetFog(lightlevel, rel, &Colormap, false); gltexture->Bind(); gl_SetPlaneTextureRotation(&plane, gltexture); DrawSubsectors(pass, false); gl_RenderState.EnableTextureMatrix(false); break; - } - - case GLPASS_LIGHT: - case GLPASS_LIGHT_ADDITIVE: - - if (!foggy) gl_SetFog((255+lightlevel)>>1, 0, &Colormap, false); - else gl_SetFog(lightlevel, 0, &Colormap, true); - - if (sub) - { - DrawSubsectorLights(sub, pass); - } - else - { - // Draw the subsectors belonging to this sector - for (i=0; isubsectorcount; i++) - { - subsector_t * sub = sector->subsectors[i]; - - if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags) - { - DrawSubsectorLights(sub, pass); - } - } - - // Draw the subsectors assigned to it due to missing textures - if (!(renderflags&SSRF_RENDER3DPLANES)) - { - gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR)? - gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) : - gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum); - - while (node) - { - DrawSubsectorLights(node->sub, pass); - node = node->next; - } - } - } - break; case GLPASS_TRANSLUCENT: if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE); @@ -462,38 +346,15 @@ inline void GLFlat::PutFlat(bool fog) } if (renderstyle!=STYLE_Translucent || alpha < 1.f - FLT_EPSILON || fog) { - int list = (renderflags&SSRF_RENDER3DPLANES) ? GLDL_TRANSLUCENT : GLDL_TRANSLUCENTBORDER; - gl_drawinfo->drawlists[list].AddFlat (this); + // translucent 3D floors go into the regular translucent list, translucent portals go into the translucent border list. + list = (renderflags&SSRF_RENDER3DPLANES) ? GLDL_TRANSLUCENT : GLDL_TRANSLUCENTBORDER; } else if (gltexture != NULL) { - static DrawListType list_indices[2][2][2]={ - { { GLDL_PLAIN, GLDL_FOG }, { GLDL_MASKED, GLDL_FOGMASKED } }, - { { GLDL_LIGHT, GLDL_LIGHTFOG }, { GLDL_LIGHTMASKED, GLDL_LIGHTFOGMASKED } } - }; - - bool light = false; bool masked = gltexture->isMasked() && ((renderflags&SSRF_RENDER3DPLANES) || stack); - - if (!gl_fixedcolormap) - { - foggy = gl_CheckFog(&Colormap, lightlevel) || level.flags&LEVEL_HASFADETABLE; - - if (gl_lights && !gl_dynlight_shader && GLRenderer->mLightCount) // Are lights touching this sector? - { - for(int i=0;isubsectorcount;i++) if (sector->subsectors[i]->lighthead[0] != NULL) - { - light=true; - } - } - } - else foggy = false; - - list = list_indices[light][masked][foggy]; - if (list == GLDL_LIGHT && gltexture->tex->gl_info.Brightmap) list = GLDL_LIGHTBRIGHT; - - gl_drawinfo->drawlists[list].AddFlat (this); + list = masked ? GLDL_MASKED : GLDL_PLAIN; } + gl_drawinfo->drawlists[list].AddFlat (this); } //========================================================================== diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 0cc602967..afc5cf1f2 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -144,7 +144,7 @@ void GLPortal::DrawPortalStencil() for (unsigned int i = 0; i 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && gl_dynlight_shader) + if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights) { pass = GLPASS_ALL; } - else if (gl_texture) + else { pass = GLPASS_PLAIN; } - else - { - pass = GLPASS_BASE; - } gl_RenderState.EnableTexture(gl_texture); - gl_RenderState.EnableBrightmap(gl_fixedcolormap == CM_DEFAULT); + gl_RenderState.EnableBrightmap(true); gl_drawinfo->drawlists[GLDL_PLAIN].Sort(); gl_drawinfo->drawlists[GLDL_PLAIN].Draw(pass); - gl_drawinfo->drawlists[GLDL_FOG].Sort(); - gl_drawinfo->drawlists[GLDL_FOG].Draw(pass); - gl_drawinfo->drawlists[GLDL_LIGHTFOG].Sort(); - gl_drawinfo->drawlists[GLDL_LIGHTFOG].Draw(pass); - // Part 2: masked geometry. This is set up so that only pixels with alpha>0.5 will show + // Part 2: masked geometry. This is set up so that only pixels with alpha>gl_mask_threshold will show if (!gl_texture) { gl_RenderState.EnableTexture(true); gl_RenderState.SetTextureMode(TM_MASK); } - if (pass == GLPASS_BASE) pass = GLPASS_BASE_MASKED; gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); gl_drawinfo->drawlists[GLDL_MASKED].Sort(); gl_drawinfo->drawlists[GLDL_MASKED].Draw(pass); - gl_drawinfo->drawlists[GLDL_FOGMASKED].Sort(); - gl_drawinfo->drawlists[GLDL_FOGMASKED].Draw(pass); - gl_drawinfo->drawlists[GLDL_LIGHTFOGMASKED].Sort(); - gl_drawinfo->drawlists[GLDL_LIGHTFOGMASKED].Draw(pass); - // And now the multipass stuff - if (!gl_dynlight_shader && gl_lights) - { - // First pass: empty background with sector light only - - // Part 1: solid geometry. This is set up so that there are no transparent parts - - // remove any remaining texture bindings and shaders whick may get in the way. - gl_RenderState.EnableTexture(false); - gl_RenderState.EnableBrightmap(false); - gl_RenderState.Apply(); - gl_drawinfo->drawlists[GLDL_LIGHT].Draw(GLPASS_BASE); - gl_RenderState.EnableTexture(true); - - // Part 2: masked geometry. This is set up so that only pixels with alpha>0.5 will show - // This creates a blank surface that only fills the nontransparent parts of the texture - gl_RenderState.SetTextureMode(TM_MASK); - gl_RenderState.EnableBrightmap(true); - gl_drawinfo->drawlists[GLDL_LIGHTBRIGHT].Draw(GLPASS_BASE_MASKED); - gl_drawinfo->drawlists[GLDL_LIGHTMASKED].Draw(GLPASS_BASE_MASKED); - gl_RenderState.EnableBrightmap(false); - gl_RenderState.SetTextureMode(TM_MODULATE); - - - // second pass: draw lights (on fogged surfaces they are added to the textures!) - glDepthMask(false); - if (mLightCount && !gl_fixedcolormap) - { - if (gl_SetupLightTexture()) - { - gl_RenderState.BlendFunc(GL_ONE, GL_ONE); - glDepthFunc(GL_EQUAL); - gl_RenderState.SetSoftLightLevel(255); - for(int i=GLDL_FIRSTLIGHT; i<=GLDL_LASTLIGHT; i++) - { - gl_drawinfo->drawlists[i].Draw(GLPASS_LIGHT); - } - gl_RenderState.BlendEquation(GL_FUNC_ADD); - } - else gl_lights=false; - } - - // third pass: modulated texture - gl_RenderState.ResetColor(); - gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); - gl_RenderState.EnableFog(false); - glDepthFunc(GL_LEQUAL); - if (gl_texture) - { - gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); - gl_drawinfo->drawlists[GLDL_LIGHT].Sort(); - gl_drawinfo->drawlists[GLDL_LIGHT].Draw(GLPASS_TEXTURE); - gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); - gl_drawinfo->drawlists[GLDL_LIGHTBRIGHT].Sort(); - gl_drawinfo->drawlists[GLDL_LIGHTBRIGHT].Draw(GLPASS_TEXTURE); - gl_drawinfo->drawlists[GLDL_LIGHTMASKED].Sort(); - gl_drawinfo->drawlists[GLDL_LIGHTMASKED].Draw(GLPASS_TEXTURE); - } - - // fourth pass: additive lights - gl_RenderState.EnableFog(true); - if (gl_lights && mLightCount && !gl_fixedcolormap) - { - gl_RenderState.BlendFunc(GL_ONE, GL_ONE); - glDepthFunc(GL_EQUAL); - if (gl_SetupLightTexture()) - { - for(int i=0; idrawlists[i].Draw(GLPASS_LIGHT_ADDITIVE); - } - gl_RenderState.BlendEquation(GL_FUNC_ADD); - } - else gl_lights=false; - } - } gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index a2c0cf981..d0932a89f 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -511,6 +511,7 @@ void GLSkyPortal::DrawContents() gl_RenderState.Apply(); glDrawArrays(GL_TRIANGLES, 0, 12); gl_RenderState.EnableTexture(true); + gl_RenderState.SetObjectColor(0xffffffff); } gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index c70422b32..554b8ff1f 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -112,7 +112,7 @@ CVAR(Bool, gl_nolayer, false, 0) //========================================================================== void GLSprite::Draw(int pass) { - if (pass!=GLPASS_PLAIN && pass != GLPASS_ALL && pass!=GLPASS_TRANSLUCENT) return; + if (pass == GLPASS_DECALS) return; diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index e4e2e855a..e66941283 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -71,47 +71,44 @@ void gl_SetDynSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsect float out[3] = { 0.0f, 0.0f, 0.0f }; // Go through both light lists - for (int i = 0; i < 2; i++) + FLightNode * node = subsec->lighthead; + while (node) { - FLightNode * node = subsec->lighthead[i]; - while (node) + light=node->lightsource; + if (!light->owned || light->target == NULL || light->target->IsVisibleToPlayer()) { - light = node->lightsource; - if (!light->owned || light->target == NULL || light->target->IsVisibleToPlayer()) + if (!(light->flags2&MF2_DORMANT) && + (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) { - if (!(light->flags2&MF2_DORMANT) && - (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) + float dist = FVector3(FIXED2FLOAT(x - light->x), FIXED2FLOAT(y - light->y), FIXED2FLOAT(z - light->z)).Length(); + radius = light->GetRadius() * gl_lights_size; + + if (dist < radius) { - float dist = FVector3(FIXED2FLOAT(x - light->x), FIXED2FLOAT(y - light->y), FIXED2FLOAT(z - light->z)).Length(); - radius = light->GetRadius() * gl_lights_size; + frac = 1.0f - (dist / radius); - if (dist < radius) + if (frac > 0) { - frac = 1.0f - (dist / radius); - - if (frac > 0) + lr = light->GetRed() / 255.0f * gl_lights_intensity; + lg = light->GetGreen() / 255.0f * gl_lights_intensity; + lb = light->GetBlue() / 255.0f * gl_lights_intensity; + if (light->IsSubtractive()) { - lr = light->GetRed() / 255.0f * gl_lights_intensity; - lg = light->GetGreen() / 255.0f * gl_lights_intensity; - lb = light->GetBlue() / 255.0f * gl_lights_intensity; - if (light->IsSubtractive()) - { - float bright = FVector3(lr, lg, lb).Length(); - FVector3 lightColor(lr, lg, lb); - lr = (bright - lr) * -1; - lg = (bright - lg) * -1; - lb = (bright - lb) * -1; - } - - out[0] += lr * frac; - out[1] += lg * frac; - out[2] += lb * frac; + float bright = FVector3(lr, lg, lb).Length(); + FVector3 lightColor(lr, lg, lb); + lr = (bright - lr) * -1; + lg = (bright - lg) * -1; + lb = (bright - lb) * -1; } + + out[0] += lr * frac; + out[1] += lg * frac; + out[2] += lb * frac; } } } - node = node->nextLight; } + node = node->nextLight; } gl_RenderState.SetDynLight(out[0], out[1], out[2]); } diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 28fa51868..fe2ec6e8e 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -169,7 +169,7 @@ private: void SetupLights(); bool PrepareLight(texcoord * tcs, ADynamicLight * light); - void RenderWall(int textured, ADynamicLight * light=NULL, unsigned int *store = NULL); + void RenderWall(int textured, unsigned int *store = NULL); void FloodPlane(int pass); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index f720f1678..60e9287bf 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -114,9 +114,8 @@ void GLWall::PutWall(bool translucent) 4, //RENDERWALL_SECTORSTACK, // special 4, //RENDERWALL_PLANEMIRROR, // special 4, //RENDERWALL_MIRROR, // special - 1, //RENDERWALL_MIRRORSURFACE, // needs special handling - 2, //RENDERWALL_M2SNF, // depends on render and texture settings, no fog - 2, //RENDERWALL_M2SFOG, // depends on render and texture settings, no fog + 1, //RENDERWALL_MIRRORSURFACE, // only created here from RENDERWALL_MIRROR + 2, //RENDERWALL_M2SNF, // depends on render and texture settings, no fog, used on mid texture lines with a fog boundary. 3, //RENDERWALL_COLOR, // translucent 2, //RENDERWALL_FFBLOCK // depends on render and texture settings 4, //RENDERWALL_COLORLAYER // color layer needs special handling @@ -145,47 +144,11 @@ void GLWall::PutWall(bool translucent) } else if (passflag[type]!=4) // non-translucent walls { - static DrawListType list_indices[2][2][2]={ - { { GLDL_PLAIN, GLDL_FOG }, { GLDL_MASKED, GLDL_FOGMASKED } }, - { { GLDL_LIGHT, GLDL_LIGHTFOG }, { GLDL_LIGHTMASKED, GLDL_LIGHTFOGMASKED } } - }; bool masked; - bool light = false; - if (!gl_fixedcolormap) - { - if (gl_lights && !gl_dynlight_shader) - { - if (seg->sidedef == NULL) - { - light = false; - } - else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) - { - light = seg->sidedef->lighthead[0] != NULL; - } - else if (sub) - { - // for polyobjects we cannot use the side's light list. - // We must use the subsector's. - light = sub->lighthead[0] != NULL; - } - } - } - else - { - flags&=~GLWF_FOGGY; - } - - masked = passflag[type]==1? false : (light && type!=RENDERWALL_FFBLOCK) || (gltexture && gltexture->isMasked()); - - list = list_indices[light][masked][!!(flags&GLWF_FOGGY)]; - if (list == GLDL_LIGHT) - { - if (gltexture->tex->gl_info.Brightmap) list = GLDL_LIGHTBRIGHT; - if (flags & GLWF_GLOW) list = GLDL_LIGHTBRIGHT; - } + masked = passflag[type]==1? false : (gltexture && gltexture->isMasked()); + list = masked ? GLDL_MASKED : GLDL_PLAIN; gl_drawinfo->drawlists[list].AddWall(this); } @@ -1514,11 +1477,12 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) glseg.x2= FIXED2FLOAT(v2->x); glseg.y2= FIXED2FLOAT(v2->y); Colormap=frontsector->ColorMap; - flags = (!gl_isBlack(Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE)? GLWF_FOGGY : 0; + flags = 0; int rel = 0; int orglightlevel = gl_ClampLight(frontsector->lightlevel); - lightlevel = gl_ClampLight(seg->sidedef->GetLightLevel(!!(flags&GLWF_FOGGY), orglightlevel, false, &rel)); + bool foggy = (!gl_isBlack(Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE); // fog disables fake contrast + lightlevel = gl_ClampLight(seg->sidedef->GetLightLevel(foggy, orglightlevel, false, &rel)); if (orglightlevel >= 253) // with the software renderer fake contrast won't be visible above this. { rellight = 0; @@ -1764,7 +1728,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * glseg.fracleft = 0; glseg.fracright = 1; - flags = (!gl_isBlack(Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE)? GLWF_FOGGY : 0; + flags = 0; // can't do fake contrast without a sidedef lightlevel = gl_ClampLight(frontsector->lightlevel); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index e28f6315c..8cdae097a 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -62,57 +62,6 @@ EXTERN_CVAR(Bool, gl_seamless) -//========================================================================== -// -// Sets up the texture coordinates for one light to be rendered -// -//========================================================================== -bool GLWall::PrepareLight(texcoord * tcs, ADynamicLight * light) -{ - float vtx[]={glseg.x1,zbottom[0],glseg.y1, glseg.x1,ztop[0],glseg.y1, glseg.x2,ztop[1],glseg.y2, glseg.x2,zbottom[1],glseg.y2}; - Plane p; - Vector nearPt, up, right; - float scale; - - p.Init(vtx,4); - - if (!p.ValidNormal()) - { - return false; - } - - if (!gl_SetupLight(p, light, nearPt, up, right, scale, Colormap.desaturation, true, !!(flags&GLWF_FOGGY))) - { - return false; - } - - if (tcs != NULL) - { - Vector t1; - int outcnt[4]={0,0,0,0}; - - for(int i=0;i<4;i++) - { - t1.Set(&vtx[i*3]); - Vector nearToVert = t1 - nearPt; - tcs[i].u = (nearToVert.Dot(right) * scale) + 0.5f; - tcs[i].v = (nearToVert.Dot(up) * scale) + 0.5f; - - // quick check whether the light touches this polygon - if (tcs[i].u<0) outcnt[0]++; - if (tcs[i].u>1) outcnt[1]++; - if (tcs[i].v<0) outcnt[2]++; - if (tcs[i].v>1) outcnt[3]++; - - } - // The light doesn't touch this polygon - if (outcnt[0]==4 || outcnt[1]==4 || outcnt[2]==4 || outcnt[3]==4) return false; - } - - draw_dlight++; - return true; -} - //========================================================================== // // Collect lights for shader @@ -132,77 +81,74 @@ void GLWall::SetupLights() { return; } - for(int i=0;i<2;i++) + FLightNode *node; + if (seg->sidedef == NULL) { - FLightNode *node; - if (seg->sidedef == NULL) - { - node = NULL; - } - else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) - { - node = seg->sidedef->lighthead[i]; - } - else if (sub) - { - // Polobject segs cannot be checked per sidedef so use the subsector instead. - node = sub->lighthead[i]; - } - else node = NULL; + node = NULL; + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + node = seg->sidedef->lighthead; + } + else if (sub) + { + // Polobject segs cannot be checked per sidedef so use the subsector instead. + node = sub->lighthead; + } + else node = NULL; - // Iterate through all dynamic lights which touch this wall and render them - while (node) + // Iterate through all dynamic lights which touch this wall and render them + while (node) + { + if (!(node->lightsource->flags2&MF2_DORMANT)) { - if (!(node->lightsource->flags2&MF2_DORMANT)) + iter_dlight++; + + Vector fn, pos; + + float x = FIXED2FLOAT(node->lightsource->x); + float y = FIXED2FLOAT(node->lightsource->y); + float z = FIXED2FLOAT(node->lightsource->z); + float dist = fabsf(p.DistToPoint(x, z, y)); + float radius = (node->lightsource->GetRadius() * gl_lights_size); + float scale = 1.0f / ((2.f * radius) - dist); + + if (radius > 0.f && dist < radius) { - iter_dlight++; + Vector nearPt, up, right; - Vector fn, pos; + pos.Set(x,z,y); + fn=p.Normal(); + fn.GetRightUp(right, up); - float x = FIXED2FLOAT(node->lightsource->x); - float y = FIXED2FLOAT(node->lightsource->y); - float z = FIXED2FLOAT(node->lightsource->z); - float dist = fabsf(p.DistToPoint(x, z, y)); - float radius = (node->lightsource->GetRadius() * gl_lights_size); - float scale = 1.0f / ((2.f * radius) - dist); + Vector tmpVec = fn * dist; + nearPt = pos + tmpVec; - if (radius > 0.f && dist < radius) + Vector t1; + int outcnt[4]={0,0,0,0}; + texcoord tcs[4]; + + // do a quick check whether the light touches this polygon + for(int i=0;i<4;i++) { - Vector nearPt, up, right; + t1.Set(&vtx[i*3]); + Vector nearToVert = t1 - nearPt; + tcs[i].u = (nearToVert.Dot(right) * scale) + 0.5f; + tcs[i].v = (nearToVert.Dot(up) * scale) + 0.5f; - pos.Set(x,z,y); - fn=p.Normal(); - fn.GetRightUp(right, up); + if (tcs[i].u<0) outcnt[0]++; + if (tcs[i].u>1) outcnt[1]++; + if (tcs[i].v<0) outcnt[2]++; + if (tcs[i].v>1) outcnt[3]++; - Vector tmpVec = fn * dist; - nearPt = pos + tmpVec; - - Vector t1; - int outcnt[4]={0,0,0,0}; - texcoord tcs[4]; - - // do a quick check whether the light touches this polygon - for(int i=0;i<4;i++) - { - t1.Set(&vtx[i*3]); - Vector nearToVert = t1 - nearPt; - tcs[i].u = (nearToVert.Dot(right) * scale) + 0.5f; - tcs[i].v = (nearToVert.Dot(up) * scale) + 0.5f; - - if (tcs[i].u<0) outcnt[0]++; - if (tcs[i].u>1) outcnt[1]++; - if (tcs[i].v<0) outcnt[2]++; - if (tcs[i].v>1) outcnt[3]++; - - } - if (outcnt[0]!=4 && outcnt[1]!=4 && outcnt[2]!=4 && outcnt[3]!=4) - { - gl_GetLight(p, node->lightsource, true, false, lightdata); - } + } + if (outcnt[0]!=4 && outcnt[1]!=4 && outcnt[2]!=4 && outcnt[3]!=4) + { + gl_GetLight(p, node->lightsource, true, false, lightdata); } } - node = node->nextLight; } + node = node->nextLight; } int numlights[3]; @@ -223,29 +169,20 @@ void GLWall::SetupLights() // //========================================================================== -void GLWall::RenderWall(int textured, ADynamicLight * light, unsigned int *store) +void GLWall::RenderWall(int textured, unsigned int *store) { static texcoord tcs[4]; // making this variable static saves us a relatively costly stack integrity check. bool split = (gl_seamless && !(textured&RWF_NOSPLIT) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ)); - if (!light) + tcs[0]=lolft; + tcs[1]=uplft; + tcs[2]=uprgt; + tcs[3]=lorgt; + if ((flags&GLWF_GLOW) && (textured & RWF_GLOW)) { - tcs[0]=lolft; - tcs[1]=uplft; - tcs[2]=uprgt; - tcs[3]=lorgt; - if ((flags&GLWF_GLOW) && (textured & RWF_GLOW)) - { - gl_RenderState.SetGlowPlanes(topplane, bottomplane); - gl_RenderState.SetGlowParams(topglowcolor, bottomglowcolor); - } - + gl_RenderState.SetGlowPlanes(topplane, bottomplane); + gl_RenderState.SetGlowParams(topglowcolor, bottomglowcolor); } - else - { - if (!PrepareLight(tcs, light)) return; - } - if (!(textured & RWF_NORENDER)) { @@ -422,7 +359,6 @@ void GLWall::RenderTranslucentWall() //========================================================================== void GLWall::Draw(int pass) { - FLightNode * node; int rel; #ifdef _DEBUG @@ -461,64 +397,6 @@ void GLWall::Draw(int pass) gl_RenderState.EnableLight(false); break; - case GLPASS_BASE: // Base pass for non-masked polygons (all opaque geometry) - case GLPASS_BASE_MASKED: // Base pass for masked polygons (2sided mid-textures and transparent 3D floors) - rel = rellight + getExtraLight(); - gl_SetColor(lightlevel, rel, Colormap,1.0f); - if (!(flags&GLWF_FOGGY)) - { - if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, false); - else gl_SetFog(255, 0, NULL, false); - } - gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); - // fall through - - if (pass != GLPASS_BASE) - { - gltexture->Bind(flags, 0); - } - RenderWall(RWF_TEXTURED|RWF_GLOW); - gl_RenderState.EnableGlow(false); - gl_RenderState.EnableLight(false); - break; - - case GLPASS_TEXTURE: // modulated texture - gltexture->Bind(flags, 0); - RenderWall(RWF_TEXTURED); - break; - - case GLPASS_LIGHT: - case GLPASS_LIGHT_ADDITIVE: - // black fog is diminishing light and should affect lights less than the rest! - if (!(flags&GLWF_FOGGY)) gl_SetFog((255+lightlevel)>>1, 0, NULL, false); - else gl_SetFog(lightlevel, 0, &Colormap, true); - - if (seg->sidedef == NULL) - { - node = NULL; - } - else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) - { - // Iterate through all dynamic lights which touch this wall and render them - node = seg->sidedef->lighthead[pass==GLPASS_LIGHT_ADDITIVE]; - } - else if (sub) - { - // To avoid constant rechecking for polyobjects use the subsector's lightlist instead - node = sub->lighthead[pass==GLPASS_LIGHT_ADDITIVE]; - } - else node = NULL; - while (node) - { - if (!(node->lightsource->flags2&MF2_DORMANT)) - { - iter_dlight++; - RenderWall(RWF_TEXTURED, node->lightsource); - } - node = node->nextLight; - } - break; - case GLPASS_DECALS: case GLPASS_DECALS_NOFOG: if (seg->sidedef && seg->sidedef->AttachedDecals) diff --git a/src/r_defs.h b/src/r_defs.h index 6b76803b4..dea227cc5 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -772,7 +772,7 @@ struct sector_t int subsectorcount; // list of subsectors subsector_t ** subsectors; FPortal * portals[2]; // floor and ceiling portals - FLightNode * lighthead[2]; + FLightNode * lighthead; enum { @@ -949,7 +949,7 @@ struct side_t vertex_t *V2() const; //For GL - FLightNode * lighthead[2]; // all blended lights that may affect this wall + FLightNode * lighthead; // all blended lights that may affect this wall seg_t **segs; // all segs belonging to this sidedef in ascending order. Used for precise rendering int numsegs; @@ -1082,7 +1082,7 @@ struct subsector_t void BuildPolyBSP(); // subsector related GL data - FLightNode * lighthead[2]; // Light nodes (blended and additive) + FLightNode * lighthead; // Light nodes (blended and additive) int validcount; short mapsection; char hacked; // 1: is part of a render hack diff --git a/wadsrc/static/glstuff/gllight.png b/wadsrc/static/glstuff/gllight.png deleted file mode 100644 index a3a296b9f856f4654aae244e3400a4f33fd95902..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13073 zcmeAS@N?(olHy`uVBq!ia0y~yU}OMc4h9AWhDyoryBHXZZg{#lhE&{o8v8P7uH~wf zpZETEMnC!|AkuoS@R3THe(~kWN6KvO3OebyGV1+5U;o4YqkL#+sOi*Su5W65ztl%F zloo^rpFJPqb3}yc!hcW3IiF|Fidk+hbn54#2haa^F`WD8bLCv-=WtQs)t|LZ8tMeE z{@=rJZtLn*ow9}zdl@b3m9nbrwoGCbae0$}f#v@*@%*3ObMKvdI$K6CWA5(`$55XT z*Q4h)PyF@PUcJF)YNYJ85XPXu)4|hg4SdrtoOk>n^DmjnW3HK1*4=%Zw66GD=QDQ& zMJcHEyf5ber~7`N|GKoltyWt$TKfp!WK+0*?B^rFwwn3LAM!2tPYH^i=@`T)Y~0-Q ziT`Eh6x9_69@w;03I5Mxlu0$;`|qUjG>#xW)z-=%iKfvitE9fkPMlQ#^5xbmw*I*l zf5Y-7$kj!%H_Cj-7bxOi`A1f@b|udr@3(d(H(z}Fyz28cZ^chp$^97ve z-JJTxvGA{e*H0(q=LtJX-fj@!3pCw#LhhHi?EIMhQ`@fRulvJV%5kjCQfFi64}&Cj z+f3s)=NsZH56$ffs9s#MplbHfGeyhFqE5~B~%z4`O^^a2Coh!9I>iSm4ZORQT1rhOwf-V1onO0o) zTy7p*Ty2@36}dK5K*C=_h3l_Bh$vF z6DPPj=9UZ8Z)SL~^x^Z@?f2!k`sxI~sH%Vcfsun-(%|w;o$K%CD$7p(Q_k72rf}!( zkXm{7^5Ax}9jn4?9_SiA{t?mZ*gUOa#;O@9f1fDiv`)Md{3Evi#s2iaukKVye%+I% zoE#s&z~W_%XS%`*9yNg)6;8RV`@dVI=D9DZpUn2+=k9s?_sv-OY^68nmZ`U|p1M;h zeX_VLzuoW;vn{g=^KtPhY%|2NPRy9NB>YbvV@hZ9r+Gc;w*QysK7M_)x^92@nu34l z@3|F5HMaTh&Z`i)|Kiii8PjH*%=b7@|M%x?&PA0m3A0U3b6;2PO=k7-G+8?3m{Y%< zW%|V_463v8SSP4t&2wco^y3Y2a;?8B|6_f1{Z;G7g~fAjM@tBt+W5zA?Y?5a92xof zIUW}J(*jLhp7Q83R$ly`8AZd^{p6H}ZaXFeB`UlUXx^2$$8rX0?uv zCI9{h<$d60+93GflBr?xqaS~TF7Z7x-=*EGa)S5c%5Wc^BN7u0vzD@5)t|FtmHVZc zjVJU|-RFxlEVZ3^cnZfJ|G5(je%gQKX}KC*i;aaa@>_hjA~P zVCSkuN5i=pw(2aY+`y36C;mW`H~q(BWow5A3sQww_?7%qw|cegmgy!=&MizAgf(P4 z;yF0}eExR-)%v-1y*e|Z=kNcM5ZP$-*>9(C%>GxcZ2@K(2M&b>*d1GXm^r{;#S|2%9LMtufAjzN5F@L3Tk<5M`Pu*TM8nWe{Owp z!Cvy;%2l1$@9$c$zSybde?iNMR)(Jz50}K62(8vQ-t*T!!gSHGQ}GAooey8SBv8dT z-;{a2kVBI3v;*z0d2&v2p3%ReTv$}Mg59i-f&Ii+CpQK^s~js4hKu%d_hqwwEHz_T zuzZ^8`}B8NaqLUk6T%uBC$2o8tnS*_{l>u~^1HuK#4LpeA%?313V+_Z^&!*x!TeAE zWi}qzS}O74_&sY|j{T1uPG@i$6@BFnPBV)Ei~sn~ikB>?n{_>J(WjRY2kevo z?M`y^G5YHXgNg@nJO=1827rM+B za4@d6`t$V0^E-QI-)t`468q-B!Mk!tc$K3T?b=y7bB9pU59fyx5ldD&Gq?%z&3)f( zf1M#jYxjoR7SpZWt^P_qVA`aYlJ@P1`SLAu-ZU(eY`mId;}OK(;ieTLAv0}#yzK$Q zzg&zr9-25Z|LLoln={Y+Q~bt$?YZAKhOiiyJMqt5<;5PZT`Q2Q5Ypke`quIEggv3k z{sQ$%4V~57#RKFS^;{+#W6+qn?AGk+)&CApX$+K_B{tcsS%$OV#rjo=rT;EyHYRh{ z&yxDZzg}LTf$3V))$e|+qW+EVM9t%$e>W0+X?rrRY+-@g*^>)>EJ8R0mjy&{2~1wd zvXt%PZz%(bxX>4i*dJ{8Z_yWQb|ZdC$x4?*8P9WFyR<|*&RD$+f3?b>t1WrKLMf?P z@!cVl?+Y`$nSal{-m~E${}$bvNSpPat2`4E+zV!@Ygql4eEG$(J5;ZXZ*d6Eq;1Sr z&E<|&GWKCi|2dhK9eGn}TfJ)U`I-+M3-#`u_5IsuuuP%D{lF)ivVM;vbN!0Ue@q!C56=T>q!=JNxzb zIVLl#AM{L8v|jU|ztga#;c2|tBn!!++fKEHeDj4EF8$|YsGU{2uBE)tqW^tC-@h5N z?LRa=VU^VPnGpE?&4U?JKeGh!1qKStUuhC+{42Od=;Pyr1NO%nIuCrTD%vmW#C3AM zNp|qtx%Zro_uOM`I=FD5QDtMZy6%~90p5-m-Y2A+9cF4y{5Ok%Yl61jeC;jwazpB0 z9y)d5_T&DWk5j*C%lVi#Y&2=%^$~8o7r9LF)XxBOp~6kvJ{loz{;m#!c6@Aq*yS3M z?A?R-A6SRZRFeJ^@Lm10{rBZ}?p1PC{$t}!>saZjvT&O6g%%-kQSaw@G0d6u^0j4x z7dzyQy#5}RkTBq=tdc*u^F@$oE;ubB4N? zt*s@wEc+EayZGNW)X!lSn7wp;6g!98f%3RrvzG~1oD#QMqoC>{@>QgoqwT#0%ey!! zUa!82)`L(AFcw|t%4(>(j&&56P_9)DNXOu5h= zypm%sYp>YpvjVGgEUeV8Rh(>oWq3e5BVf*tOkM>x6~X;AYz~|c1*}iq{cE|&BHfkk6<;tuAYc+^cV@8J4mI(6Ti z|C4up*dV#!LVP=K;NnvjFC5D|d!$|pFtfh-&-rK3G*O6NSNC*%Onb>~GT+JW!M|5`&U-R*7`a}FxhI;twc@*(PQ0m-p@L3`Xf@~i z#ZF1zS^||i&r3R9z4$$XEg=2lZE2=OH~v@p-TFLdvHet$O?N+kD|d@sZ2T=WH*ZIQ zer~6N5f8_w{E5#+`&gZvoK?@gRE~Sd_%Z89&#j%aSM<*JAHn<$SJZep z6%Tyr=_>JfX16$gv4)4{mrV5!g5pZ|r2d+pyKq0PF_gb`qY__--7A+Kykpfb+$S}O58~nux&A3fe#zQsytRM!`D6IM?0-Dz3#U4(zH{De>UW1x zkSDGqi$CP0*NF|8lI+^8`*(cxl?%n3Z7S;OczU}@;zuZ<_$ z=dI(_Bq3>uFWOhWTUs?3EjW9iQ<|x}s_K?Q7jw|_{NRAF{XgYyt&+c`Ht+EQg-V%> z1eZqntOGCoH#oL`U(%$>T5^oo{3IycNHzbA#)b|FQoi4koADGh}8bZ#w3))lfxc z3;S`8Z=EfC$`@Yd-rOJCQL(yqHB()`*`)PM0aE`McU=1|xg`8Wv2Ezbnw%$fKewt) z4ijhKKXh^RIdvudvkStKxAY`A|XnN3Z`Ag|nNQ>ZJ6UJdBL|9SV{@?FwJ-v+#lF zx3G7=C6pT8sVK+U--+IKP~&{_igN+a4hd<#k`g%>#&FZ$WsXOLAp0S%Lvjj6@9Jms ztDJCmzoT#{PSIc~BY&2XsLH|oo_%dMKY5ndI89)(ZE8C{)tVzz=|Iu4`{CX#3yw6r zs#m%yhx9@iy}*1t~?XTdFyeqyN2nYW~1FXkOX@ zEyjO2EUzxUpCJ49+2T|I5s@j0HMLB4j~)nFz+~?xoFTQlo!jv#JhW$4 zPwLUHZtQvy_)w{QV;}g1VD`S=^F5moSrc!6KVG4Zr73dUkXs!_~j? zla6N0bUHk_B&j@uZ|0qzXW_G28NTrsCq9`fcx~Rg;C*WY8YXbu{QF5#sd6!+%`?Fz z5wn;sgw9=Zz*h8`-CWLsO%0hDO&2SU_0&HVAmox79ck}Rf)}PHC z0yhn14qEdXNU<)z@@lEW|Bn`{o~8c_VZ5P{ZlkcPugY(coXe~0|JEyMKRZ^jthsb{ zK<55aXFmO|TF-y}ZGI=mS{=_VNy$PC1sug8Zqgj#`yxWTd{xF>Mpug6-DH7SF@t&qoy+&bRvQ z88M~XA?wcl*4N9Y_a8iXFqL2A-!lUi-z(o)_Dd}}p7SQ^{l}*hYAsuWTD+N6c1L8| z2+aC-_cou2`LT=4g^I3aYR5YHnl>A3PY>Ap(!b+bZS?*}uH|=&D;&8Pmaetu+rRWP z)7t!WMu}tf&F_5nHn@oD$!<90*b`BBcIM(A{8!J)HC$3Zek0>uch;f$0{aNnU6RL_ zTHjZSc1lv_bx10>S2v-2$`1{`1(s$n@??3^dKgzm#jD!$3qSSdNn(DG1ATY&F` zjwM-NC%sP;4|!5oS|9S;?VETkQ^30S0eUmoTg?}QE9S7K$lup>eO<6x{$}yh~KgQ_o3z-B3H{SfRyy=Zu z|85TvXNGCDr_ToOxsa&TJj1q2{6ImV&8Z{5BNzTt}BZ6@W;X^?SGYqRDDw$fJt zfol3@TOPdF%cFc@VnL6(!R?TDYRk(0KfA*C<;ITsCcYOd?>D@cV45JK1>5%>t$CUj0X`(l@{Mc8?WP z8-xyNGMwJ&>l5LweL3N~h2#8Ct}`#(SHI?NJ{aG2H}G-$wzrSvI3iBZi1BdgJjke^ zS6snp)A%#g^JIt1n=8vQls%mPT=;V8@i`6^hR)SoG8hF+T*{9SEMcQXFj)3BOb2!iW%a?dI%=2x^T5=@E@At%uAI~Z#rZN@9F#F{jU8~)vlcuDA8U*oC&xf(q8+NX$T zWSyJS@_vd~qS`af`g0Nq7ydp`efG4&fkP-EfJen)62snKGx<3;e7Ldly}+Sm`nrTf)x3raIQd$K!H&N@{>a9zts=^2p=)0_(qS~_K{ zzoL9&)AxJTr~7L4YP?-NqffX8?0dl)Zg4R`qXUuI`z5u4Th(AmHU@J$xcpvugf6b z*v~m<_aU}J&5OT7L~CB<+l@1W!N3rFM>{LxyNTs*az-&)K@Ez8r6D1jX7Czva)OC+Jz=}7^CWi5)t26_P^H-*C zKJAU2M?9wZTRpj|c5U`P8RzCKAqBzbhHhJY7bG{{V{z8JuI^=0>+An|wU$)RcxQ)n0?Z&jB#3md6kS(W6p&sY_`9=@2^O* zI8(uJFZkf!(x08@TDD)ZzO~${BzETS)y#YL|DI>@rBV0 zGtz0ct_8~)MWd>-6SU+Kt_!e#^dFzdDT1+l3UM#QT76i}Tuv6bZ~1&chom6ILCqtZ%#*2c{|zW37?X?qbJ);;a_uQRXMc_A^; z=%jq;ud5gDiRXMx5Oz{y>&m{beT>^dNkYcx+vF1#3dP2YFLv(a%QaHT2zjvAp<(&l z0@pJw>Hp8TCUR6e3$V7Hk)A$JU_rx?sizXBGQO`hV$^VGZBqBL5ZC`vwY1|n+lz<- z_s6>KsZ*rxTRXDFP57_AbIyXE%oX1yUgR-^Evvg2_HfrxTRiV^Np`~9K1asN^UBBL{UBvUvK)Z?IKj&|1{4-&hYFh`- zpL}J37+Ddo>l{rE&Wg_s_ArFSoc-$GwY0*{ZB-TT-lAKRF6{|>8K>^o)RT4i>Mu@v z`N=#I2kKUcglsg7ZrsvTeKcK1_35H4xz`jq~AQOwEE_J?bMEIz3p~k=TJluz{+KjDez{$AXyP|<#5`4e-g1N!H_+w!VAAAbDr zf}-t(4INX%_j?JS5(=xC5Ws17P+7w#pfxG+X|MPd=R?k-*}1ngmR{hqke#yPp6dD4 z3`L)Ur`CSiI@fu*E@jbQ-+z(QI%==dE=!iF3w>(2Sx;VGf7kB8 zio*;Y-}do3W;*n*Tj2Ts#RAWkBh{P2dMAWW-{>eB`tDn$Fvl`=hm&iC>a7_%1BFV| z8d;)JoF@D^-p#S-p2O`%t~o~4DK0s?4jP`g_$5_5N!)YmcI_3b(o6!EoqMvVYQMtc zsXUARI`2Gdt={}h-6}Wf=s|b3*K_Jv=hi*FJ%Nwio12SUpOafVMYU+OW0Azjo+L! z6W#}#SO*q%Guw(hQgVw6sNA5O&-Tv6ac9_rt-ltlDV)w`R*7Ord$WA`c!*DGHcyeJ>a!i@BY{~^XK1| zZ?7f(pK3Ln@^hE0L54=m8Mhk;mPmZ@N@<(jZr}OgR`q(5Hg3zLc1}^&x18)UE+;me z3)(up{-y0p@ASJf4n8sbrrC0O?_Son?}-|7tk1-parF3nIbnXlDLHk{EbR?VSx27o zGIq~5Vw&C1bR?^9$2nVlo8$b&qEmKvOkI|^GH$V5+z-Dhk=e%+ddzM-h}&Svrfd;= z&x7&z^DJ+PYENdC+4m1TlM2jc5aV3QS1{%H-TR#fSy?5|){F7(RM0=Wi~r_z(VrbCqVK`S|`tjzPncC;A)E~S_ z)wDYM`&!_~hYlU>`x*b7UAKWD!0-97CtE&$T0FIWt16FCvxu;;-UJ8D(*BU+9{vSu zqQ$#DHe2!$@UL06+ocW%QA#3>A5}U?lo?Z8J z85EjR1Y~sEvsF@Fo}Sa+dbwZb#gYBbf243;_FKa@^^$>(WW$M!xo172wC-3RaShI$ z=IY5*Rg;N2Rml*1isAN;Zn)+YH_mBh0`zm zrGy>Sb<{T`tzFE+J%MA6!*m~psp+*Do7p&~v$MLNYIP6!F3r7B+Uep=F|EzN)E#XD zT3F=*A{L)^GE$3a>3McPSfER^;$ipV`CGroWl!zy*{dCG;kG$j^Q2@~bsLAEn)ZX0 z-P2wlFjY|3O**$g&~zs6`D6#Ki1Y4jhGvN`Bsy)`T3DYt6#CSE+4%W+eD&ME;cwRT zs}-*36xN-hG&Sb#l8Sm2!TVwcOS-7dpxvz8BE;p{5x!^ccmbKH`lODzNnIk&~n19|&ibd@px@HGo$an{qHP%FH?!l5`mm}gnpe)h@tT20wlPn=eW zIdkmzl z;*~hIW`6x5$LzN!jt5N3+o<+tfz!)-v(w(5jZCsSR`+Smf4TOc_j?z)&71b&*6Xsf zj&|Ag&!iS~a)(*%$c*DNTEO?R;7{ny4?jbmeP2+U5IQkOegC7oHU}@iD42UILTg7# zj_rbdzXiX2h$`6mYkueVzE}Fp&5Uza-S)u67uBQh?K2;b8ZGJQ(`RC4`8=D)N=XmJWZ7h60O;YvypX4u(S=;um zb39YIpz?XIu-fjgAL`shMP`18YdFRp`XR-q*=TdC^qKg(3R3_4HYqzRKPz@vpzwXp zit0~u`<|{a^ga~x>!Rf=zJ!Q*^3Uo686q4Lx*WwGHE4Ct31Ns~G`X~Qw$|;%vDGK} zOC6*(D)?6X+a7l&eOB$NJMR|<8g+bQf6hKpi%Y7!O} z8BCGs<~4cs`2}m^Er|tg_0|4|*1ullHldZ}$NEVQQAdsz7Wt_3#2yek*K(hOq4tf$ zr^M?y+w)qVDs{x2wbv5={y+6!`3X@j_k~O*vdWzPyYDbC%`ahO7ER%OVYaDsqtYgm zUl+T2CHYU@C~XiA+Isi&+mE|mUvIO2c+JAB^DOTYM$Obe?lJe<-8C};Q#?K;v(y z|E!RR2>9P~)0d~|gM!!T<7NwL56-D_J)(cn@Xz94h6II=L9cz*+b@?Aw_ou5@YLC- zPK6gJhuqqKmE#3t)AcCs_UFGoyzA3?#v1!Xdb+rFM)}q$v+JvvQV!P~t)Kjmqq*|j zZ1;Obf`5GWs46+^{I_+tfW^IfHm22q9~pdW7UvXMd|uqVjGg;m##OQ7Oqs89zZ~v& zW#7ZZ{obzPiy_;77G2vWxp#p~6Wesc>~4pu9B^eg(8TQFo53ege*V+f_mTX+FK)9G zYl`J9FnzZs=kSRVuCM1p7nppXdd$v1WxMSa;w2ki@+Uqa-G=IDEce}eWgRJF!N6*9yjn`MS9qnL!vX^O3+QMh`;KpOE52N0S#b5|`$mSaNat5#J&$?= zFFPDzW&Lx71!kLf2D1wc|Y#`8y##UjacMh*a?mgdcGkqUCzN7V`PQq9(22Jg>Yx|DBe zKBtG@=ET+R6CE1P&iGJoTo?8@UY(&SRAtZd7fFKNry3@Ozlr!gnMq=?Lav_W&N6%V z@Be!e(=$Fi%C*o>_Mf$R!h`!y|0FB^PY%inJiIbh;Ks{avsWHkTpVSm%dqH&^s|4a zx796Vd%~wF>s$8<%=#{2lv5Y5xcwhit8*>F+TA!pX z+{7{^kn>fd{GNt>mIB=d%}L5UEbLuP(;%ED3J>2;+aZiio_f(@>k-Vqo>OZO9Y}l}V zzrLOCsYPp6eEIKw{C@<4?Vo);^LoFpzb^N9#@#wa+ed$*nj9i>+ikyF$9)VJVB5D- z>)Ni(RSg#wed(`KHFSF7%vrOBaq^qUEBbnGpZ=b|blQa5%3qeemwCNy@`s)756y4f zS-RQ!C7)_zEQ8h3^`&ym4vinToU@qwEC2s4hIN7)rpwwGHpG2?zi39jEYIZ!kGoD@ ze^cF~^?^;y!VuwpLYmWOuKx4&ci%*@ z72L0Gm~pJzHH(_@BOolHj2AE zf3VaenW;d%?&^=bZ}TTc9#p#TuDU4EKG}7%I|FZzV)CcoOb2dXll$=J+pp(h8moTx z>|FNd-*LuID>jQO?f5hGtX{Rj{hbo~(z>6#v-GyN{NF#H;Y0mg=?|xF2_6j16t7~B zJ6p`~FmlH|*QouoE^pS5NSbxJ%X7vnjTt3bfpxNq_LU6tH!zwXUpuj(L88yQ=i(!V zqtiFCG~M2wDU?@`uqR9F&?~Ko zICOfQ5T~Hg)5izSHZ1$HjQLo{?guB6r({g=GI5fLuB-cZo}*!stX>~$u}vj^iMhiC zuN^u~vit7IUF2y!e3!4?C6iTnzvhL-Z5u@Y{4n(U{haMVILm>@{`Nm4?>tdETe`Gy z-`(5w1_xcI+pe%H5SziX-*Kj`*hbSNK@pGFVc*iv{nupl2ydw5b=k|H*LjIeV&T^~ zC+md;O*f3UtkyR^sXsxV{VHRg(*wC+*Oh$VIycvPF-+&@NHaew%dwqTV)lh{{liZ( zD^m7meQGzE<9{td@Xp?s-*&o-1iZd^Kv^hWjp5AS)j!j3+16dTb@1l>n4eKK9Fp}G z2GM&ScowGY3ct)I{d@XR+p7{ACuLXcd%?NF&%#Ijyymep)17}gI{$fgRISoF*7CrU z&%GP_E&o;i_$qX6QtfU5w`mfo|IU1^k7D-QznrzaapCVq?}JgZ>b2~JuKYI^U-0cn z@V!aLPWcBLTVJn#_g5 zZ+bm06&SUxWN%S85W9Bk$7GfV=D7|hwlaCGw=;KY;NYGzqas24_5@CFkqU(Abn?5Z?QzKDVJmSl(yY)b$M44v%)0DNy3jfj;{DEB5*HfLm#*1o=LBG z{`~n_@5sQc8zxod|1w_n{$J^7wQqNr+G}1+w)YD7{ohJ4ZVTg_zw%eaVt)9CK6qNq zvfxt^=X!QQOO=V@`@$j)%)P*Q<*l~Ff!p`4Y6u3tF?{xKZ{*6L)646>{@K5V@nZ5t zrFEe@1e3KM&1lq1zVZF%?RVW8QpH>m=3FL%bC~KDK6<}_aev9b`xQ)vxeooi*4)?; zsNr=YLfouO;oU(Ig+uuQ*A;h!YIs;FOkv~i{Jr(_|2DQen;lB{tQ7M?RG(}%(=&ba zZ^ePY-!o;8aJ&;YF;%sf2_PykMyT( zOYmoRNs_33<-K|SH&d~P(ySM1PH2R7boLZqpIuTqN%OUd)I9a4#r^O19lGmSwQ#y} z2=mY0&;Q#PDqc@#TbOh!Cc>iCuc}GxXxoKt(|I>=yp#XXaNt{fhJg63vYHc3f7BRz zp2n{VkKLpAFhTOdz4N!K6;9mlx@;PCcUSzJiSJ~^|MK77T=)FPe$57LmKT35toGRM z2&($Y};s{;CS&x($+ImJACHe zHkZ1z!Ql5^xvBq{`5tWNdf=}aZmKRY%t}sS=+wEmzn>{EV3GV3ojbA%Zp{3~&-vh~?THsc3)lo_#?@b9 zJ=L4~{c%Rw67|4_|NEw$J3e3Le?P0hck3M|l8Vh9ypVa3^ipo(g~UBxXYTZex!igA zW&Yd)`=7nrDEc=`q~oN-Ja2pU@@aKtcg(e3Dc@hY=fD5?|EB&5pFUKbb(cNF;97Tl z&zT#^#&;atKE5fAk71s_JF&e!is2x$;?i@6wf=Q&C&t&i=`s=xbke+2Wf;sv#7;$BXBOCr@D+FrCU z5o_{TJNf;o*ZU(FOxU;ocCU6TI@uVo=&rVbroo}CfQNm-oj+c^{>8?t;Kjnr_Nqux zqxdl|$6MyQ*eQOmum59aTHyNV>qW83*nj(4qpYmWvzm%OJm~$=cDa5s!xKK1CBn)= z2i|qfG}tx!^wG>`N2lBWc`we8di=bjALol7Xz+hpt@~$xG{gT% b^8eXyONlr0HB~$X?RD{V^>bP0l+XkK3f!mG From 6b9d6787d9e674f579b214af94ac3328534e9be1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Jul 2014 21:16:59 +0200 Subject: [PATCH 0163/1509] - move models into their own draw list to avoid frequent buffer changes. - same for SKYHACK walls. Although rare, they would get in the way of optimizing the draw calls if not being separated out. --- src/gl/scene/gl_drawinfo.h | 9 +++++++-- src/gl/scene/gl_scene.cpp | 12 ++++++++++++ src/gl/scene/gl_sprite.cpp | 6 +----- src/gl/scene/gl_wall.h | 8 +++----- src/gl/scene/gl_walls.cpp | 12 ++++++++++-- src/gl/scene/gl_walls_draw.cpp | 19 ++++++------------- 6 files changed, 39 insertions(+), 27 deletions(-) diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index f4b104392..780be6f36 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -15,8 +15,8 @@ enum DrawListType { GLDL_PLAIN, GLDL_MASKED, - GLDL_FOG, - GLDL_FOGMASKED, + GLDL_MASKEDOFS, + GLDL_MODELS, GLDL_TRANSLUCENT, GLDL_TRANSLUCENTBORDER, @@ -96,6 +96,11 @@ public: Reset(); } + unsigned int Size() + { + return drawitems.Size(); + } + void AddWall(GLWall * wall); void AddFlat(GLFlat * flat); void AddSprite(GLSprite * sprite); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 110a36420..1d1cfd29c 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -376,6 +376,18 @@ void FGLRenderer::RenderScene(int recursion) gl_drawinfo->drawlists[GLDL_MASKED].Sort(); gl_drawinfo->drawlists[GLDL_MASKED].Draw(pass); + // this list is empty most of the time so only waste time on it when in use. + if (gl_drawinfo->drawlists[GLDL_MASKEDOFS].Size() > 0) + { + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); + gl_drawinfo->drawlists[GLDL_MASKEDOFS].Sort(); + gl_drawinfo->drawlists[GLDL_MASKEDOFS].Draw(pass); + glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(0, 0); + } + + gl_drawinfo->drawlists[GLDL_MODELS].Draw(pass); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 554b8ff1f..9ce6856b0 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -315,13 +315,9 @@ inline void GLSprite::PutSprite(bool translucent) { list = GLDL_TRANSLUCENT; } - else if ((!gl_isBlack (Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE)) - { - list = GLDL_FOGMASKED; - } else { - list = GLDL_MASKED; + list = GLDL_MODELS; } gl_drawinfo->drawlists[list].AddSprite(this); } diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index fe2ec6e8e..fafd5ccb8 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -97,11 +97,9 @@ public: //GLWF_CLAMPX=1, use GLT_* for these! //GLWF_CLAMPY=2, GLWF_SKYHACK=4, - GLWF_FOGGY=8, - GLWF_GLOW=16, // illuminated by glowing flats - GLWF_NOSHADER=32, // cannot be drawn with shaders. - GLWF_NOSPLITUPPER=64, - GLWF_NOSPLITLOWER=128, + GLWF_GLOW=8, // illuminated by glowing flats + GLWF_NOSPLITUPPER=16, + GLWF_NOSPLITLOWER=32, }; enum diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 60e9287bf..e665eeb89 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -148,14 +148,22 @@ void GLWall::PutWall(bool translucent) bool masked; masked = passflag[type]==1? false : (gltexture && gltexture->isMasked()); - list = masked ? GLDL_MASKED : GLDL_PLAIN; + + if ((flags&GLWF_SKYHACK && type == RENDERWALL_M2S)) + { + list = GLDL_MASKEDOFS; + } + else + { + list = masked ? GLDL_MASKED : GLDL_PLAIN; + } gl_drawinfo->drawlists[list].AddWall(this); } else switch (type) { case RENDERWALL_COLORLAYER: - gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this); + gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].AddWall(this); break; // portals don't go into the draw list. diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 8cdae097a..932451298 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -369,14 +369,10 @@ void GLWall::Draw(int pass) #endif - // This allows mid textures to be drawn on lines that might overlap a sky wall - if ((flags&GLWF_SKYHACK && type==RENDERWALL_M2S) || type == RENDERWALL_COLORLAYER) + if (type == RENDERWALL_COLORLAYER) { - if (pass != GLPASS_DECALS) - { - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(-1.0f, -128.0f); - } + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); } switch (pass) @@ -426,12 +422,9 @@ void GLWall::Draw(int pass) } } - if ((flags&GLWF_SKYHACK && type==RENDERWALL_M2S) || type == RENDERWALL_COLORLAYER) + if (type == RENDERWALL_COLORLAYER) { - if (pass!=GLPASS_DECALS) - { - glDisable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(0, 0); - } + glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(0, 0); } } From eb9d2d99171e0fac2fb99770f4330b57708ab5e1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 17 Jul 2014 02:37:18 +0200 Subject: [PATCH 0164/1509] - reactivate compatibility profile so that immediate mode drawing can be used on older hardware not supporting persistently mapped buffers. - reactivate alpha testing per fixed function pipeline - use the 'modern' way to define clip planes (GL_CLIP_DISTANCE). This is far more portable than the old glClipPlane method and a lot more robust than checking this in the fragment shader. --- src/gl/data/gl_vertexbuffer.cpp | 35 +++++++++++++++------- src/gl/renderer/gl_renderstate.cpp | 24 ++++++++++++++- src/gl/renderer/gl_renderstate.h | 4 ++- src/gl/scene/gl_portal.cpp | 26 ++++++++++++---- src/gl/scene/gl_walls_draw.cpp | 7 ----- src/gl/system/gl_interface.cpp | 1 + src/gl/system/gl_interface.h | 1 + src/gl/textures/gl_material.h | 1 - src/win32/win32gliface.cpp | 36 ++++++++++++++++++----- wadsrc/static/shaders/glsl/fogboundary.fp | 6 ---- wadsrc/static/shaders/glsl/main.fp | 10 ++----- wadsrc/static/shaders/glsl/main.vp | 2 ++ wadsrc/static/shaders/glsl/shaderdefs.i | 5 +++- 13 files changed, 110 insertions(+), 48 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 01c7ee3b9..6fd7f3f98 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -136,24 +136,29 @@ FFlatVertexBuffer::~FFlatVertexBuffer() // //========================================================================== -CVAR(Bool, gl_testbuffer, false, 0) +CUSTOM_CVAR(Int, gl_rendermethod, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ +} void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count) { -#if 0 - if (!gl_testbuffer) // todo: remove the immediate mode calls once the uniform array method has been tested. + switch (gl_rendermethod) { - glBegin(primtype); - for (unsigned int i = 0; i < count; i++) + case 0: +#ifndef CORE_PROFILE + if (!(gl.flags & RFL_COREPROFILE)) { - glTexCoord2fv(&map[offset + i].u); - glVertex3fv(&map[offset + i].x); + glBegin(primtype); + for (unsigned int i = 0; i < count; i++) + { + glVertexAttrib2fv(VATTR_TEXCOORD, &map[offset + i].u); + glVertexAttrib3fv(VATTR_VERTEX, &map[offset + i].x); + } + glEnd(); + break; } - glEnd(); - } - else #endif - { + case 1: if (count > 20) { int start = offset; @@ -186,6 +191,14 @@ void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offs glUniform1fv(GLRenderer->mShaderManager->GetActiveShader()->fakevb_index, count * 5, &map[offset].x); glDrawArrays(primtype, 0, count); } + break; + + case 2: + // glBufferSubData + + case 3: + // glMapBufferRange + break; } } diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 6f5b9be14..73d7d5ef3 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -149,7 +149,29 @@ bool FRenderState::ApplyShader() activeShader->muInterpolationFactor.Set(mInterpolationFactor); activeShader->muClipHeightTop.Set(mClipHeightTop); activeShader->muClipHeightBottom.Set(mClipHeightBottom); - activeShader->muAlphaThreshold.Set(mAlphaThreshold); + +#ifndef CORE_PROFILE + if (!(gl.flags & RFL_COREPROFILE)) + { + if (mAlphaThreshold != glAlphaThreshold) + { + glAlphaThreshold = mAlphaThreshold; + if (mAlphaThreshold < 0.f) + { + glDisable(GL_ALPHA_TEST); + } + else + { + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, mAlphaThreshold); + } + } + } + else +#endif + { + activeShader->muAlphaThreshold.Set(mAlphaThreshold); + } if (mGlowEnabled) { diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index d8168bca5..a07cd3401 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -74,8 +74,10 @@ class FRenderState int mEffectState; int mColormapState; - int glSrcBlend, glDstBlend; float glAlphaThreshold; + bool glClipOn; + + int glSrcBlend, glDstBlend; bool glAlphaTest; int glBlendEquation; diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index afc5cf1f2..7c7efc91d 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -286,8 +286,10 @@ bool GLPortal::Start(bool usestencil, bool doquery) } planestack.Push(gl_RenderState.GetClipHeightTop()); planestack.Push(gl_RenderState.GetClipHeightBottom()); - gl_RenderState.SetClipHeightTop(65536.f); + glDisable(GL_CLIP_DISTANCE0); + glDisable(GL_CLIP_DISTANCE1); gl_RenderState.SetClipHeightBottom(-65536.f); + gl_RenderState.SetClipHeightTop(65536.f); // save viewpoint savedviewx=viewx; @@ -351,8 +353,10 @@ void GLPortal::End(bool usestencil) float f; planestack.Pop(f); gl_RenderState.SetClipHeightBottom(f); + if (f > -65535.f) glEnable(GL_CLIP_DISTANCE0); planestack.Pop(f); gl_RenderState.SetClipHeightTop(f); + if (f < 65535.f) glEnable(GL_CLIP_DISTANCE1); if (usestencil) { @@ -790,15 +794,27 @@ void GLPlaneMirrorPortal::DrawContents() validcount++; - float f = FIXED2FLOAT(planez); - if (PlaneMirrorMode < 0) gl_RenderState.SetClipHeightTop(f); // ceiling mirror: clip everytihng with a z lower than the portal's ceiling - else gl_RenderState.SetClipHeightBottom(f); // floor mirror: clip everything with a z higher than the portal's floor - PlaneMirrorFlag++; GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); ClearClipper(); + float f = FIXED2FLOAT(planez); + if (PlaneMirrorMode < 0) + { + gl_RenderState.SetClipHeightTop(f); // ceiling mirror: clip everytihng with a z lower than the portal's ceiling + glEnable(GL_CLIP_DISTANCE1); + } + else + { + gl_RenderState.SetClipHeightBottom(f); // floor mirror: clip everything with a z higher than the portal's floor + glEnable(GL_CLIP_DISTANCE0); + } + GLRenderer->DrawScene(); + glDisable(GL_CLIP_DISTANCE0); + glDisable(GL_CLIP_DISTANCE1); + gl_RenderState.SetClipHeightBottom(-65536.f); + gl_RenderState.SetClipHeightTop(65536.f); PlaneMirrorFlag--; PlaneMirrorMode=old_pm; } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 932451298..b9965972c 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -186,14 +186,7 @@ void GLWall::RenderWall(int textured, unsigned int *store) if (!(textured & RWF_NORENDER)) { - // disable the clip plane if it isn't needed (which can be determined by a simple check.) - float ct = gl_RenderState.GetClipHeightTop(); - float cb = gl_RenderState.GetClipHeightBottom(); - if (ztop[0] <= ct && ztop[1] <= ct) gl_RenderState.SetClipHeightTop(65536.f); - if (zbottom[0] >= cb && zbottom[1] >= cb) gl_RenderState.SetClipHeightBottom(-65536.f); gl_RenderState.Apply(); - gl_RenderState.SetClipHeightTop(ct); - gl_RenderState.SetClipHeightBottom(cb); } // the rest of the code is identical for textured rendering and lights diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index f00202fd8..0b1e88548 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -134,6 +134,7 @@ void gl_LoadExtensions() if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; if (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; if (CheckExtension("GL_ARB_separate_shader_objects")) gl.flags |= RFL_SEPARATE_SHADER_OBJECTS; + if (!CheckExtension("GL_ARB_compatibility")) gl.flags |= RFL_COREPROFILE; glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 0f569d2c4..2209f0bed 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -13,6 +13,7 @@ enum RenderFlags RFL_BUFFER_STORAGE = 8, // allows persistently mapped buffers, which are the only efficient way to actually use a dynamic vertex buffer. If this isn't present, a workaround with uniform arrays is used. RFL_SHADER_STORAGE_BUFFER = 16, // to be used later for a parameter buffer RFL_BASEINDEX = 32, // currently unused + RFL_COREPROFILE = 64, }; enum TexMode diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 81f4dd10f..259f881b4 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -63,7 +63,6 @@ private: bool bHasColorkey; // only for hires bool bExpand; - float AlphaThreshold; unsigned char * LoadHiresTexture(FTexture *hirescheck, int *width, int *height, bool alphatexture); diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index db414bae6..3b630177a 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -17,6 +17,7 @@ #include "i_system.h" #include "doomstat.h" #include "v_text.h" +#include "m_argv.h" //#include "gl_defs.h" #include "gl/renderer/gl_renderer.h" @@ -739,21 +740,42 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) m_hRC = NULL; if (myWglCreateContextAttribsARB != NULL) { - // let's try to get the best version possible. - static int versions[] = { 44, 43, 42, 41, 40, 33, 32, -1 }; +#ifndef CORE_PROFILE + bool core = !!Args->CheckParm("-core"); +#else + bool core = true; +#endif + if (core) + { + // let's try to get the best version possible. + static int versions[] = { 44, 43, 42, 41, 40, 33, 32, -1 }; - for (int i = 0; versions[i] > 0; i++) + for (int i = 0; versions[i] > 0; i++) + { + int ctxAttribs[] = { + WGL_CONTEXT_MAJOR_VERSION_ARB, versions[i] / 10, + WGL_CONTEXT_MINOR_VERSION_ARB, versions[i] % 10, + WGL_CONTEXT_FLAGS_ARB, gl_debug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; + + m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); + if (m_hRC != NULL) break; + } + } + else { int ctxAttribs[] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, versions[i] / 10, - WGL_CONTEXT_MINOR_VERSION_ARB, versions[i] % 10, + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, + WGL_CONTEXT_MINOR_VERSION_ARB, 0, WGL_CONTEXT_FLAGS_ARB, gl_debug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0 }; m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); - if (m_hRC != NULL) break; + } } if (m_hRC == 0) diff --git a/wadsrc/static/shaders/glsl/fogboundary.fp b/wadsrc/static/shaders/glsl/fogboundary.fp index 1a2b0b0f9..d8259c845 100644 --- a/wadsrc/static/shaders/glsl/fogboundary.fp +++ b/wadsrc/static/shaders/glsl/fogboundary.fp @@ -10,12 +10,6 @@ out vec4 FragColor; void main() { -#ifndef NO_DISCARD - // clip plane emulation for plane reflections. These are always perfectly horizontal so a simple check of the pixelpos's y coordinate is sufficient. - if (pixelpos.y > uClipHeightTop) discard; - if (pixelpos.y < uClipHeightBottom) discard; -#endif - float fogdist; float fogfactor; diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index c56057401..a4e4d782b 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -220,16 +220,10 @@ vec4 applyFog(vec4 frag, float fogfactor) void main() { -#ifndef NO_DISCARD - // clip plane emulation for plane reflections. These are always perfectly horizontal so a simple check of the pixelpos's y coordinate is sufficient. - if (pixelpos.y > uClipHeightTop) discard; - if (pixelpos.y < uClipHeightBottom) discard; -#endif - vec4 frag = ProcessTexel(); -#ifndef NO_DISCARD - // alpha testing +#ifdef CORE_PROFILE + // alpha testing - only for the core profile, in compatibility mode we use the alpha test. if (frag.a <= uAlphaThreshold) discard; #endif diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index c40426829..e355141f0 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -65,4 +65,6 @@ void main() #endif gl_Position = ProjectionMatrix * eyeCoordPos; + gl_ClipDistance[0] = worldcoord.y - uClipHeightBottom; + gl_ClipDistance[1] = uClipHeightTop - worldcoord.y; } diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 56e6965b2..2870cf975 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -1,10 +1,13 @@ // This file contains common data definitions for both vertex and fragment shader uniform vec4 uCameraPos; +uniform int uTextureMode; uniform float uClipHeightTop, uClipHeightBottom; -uniform int uTextureMode; +#ifdef CORE_PROFILE uniform float uAlphaThreshold; +#endif + // colors uniform vec4 uObjectColor; From e0b756e511974a9bd603deccd5bcd0f8deee8ad2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 17 Jul 2014 10:04:20 +0200 Subject: [PATCH 0165/1509] - fixed: The cubemapped skybox renderer did not set up the model matrix properly. --- src/gl/scene/gl_skydome.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index d0932a89f..583c6fc62 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -319,6 +319,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool FMaterial * tex; gl_RenderState.EnableModelMatrix(true); + gl_RenderState.mModelMatrix.loadIdentity(); if (!sky2) gl_RenderState.mModelMatrix.rotate(-180.0f+x_offset, glset.skyrotatevector.X, glset.skyrotatevector.Z, glset.skyrotatevector.Y); From 6c9a818220d7a7c69b3b8848340e8153a07e6f54 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Jul 2014 10:23:07 +0200 Subject: [PATCH 0166/1509] - allow different render modes if persistent buffers are not available (untested!) --- src/gl/data/gl_vertexbuffer.cpp | 31 ++++++++++++++++++++++++++----- src/gl/data/gl_vertexbuffer.h | 3 ++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 6fd7f3f98..c09996bf0 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -96,21 +96,21 @@ FFlatVertexBuffer::FFlatVertexBuffer() glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + mIndex = mCurIndex = 0; } else { vbo_shadowdata.Reserve(BUFFER_SIZE); map = &vbo_shadowdata[0]; - FFlatVertex fill[20]; for (int i = 0; i < 20; i++) { - fill[i].Set(0, 0, 0, 100001.f, i); + map[i].Set(0, 0, 0, 100001.f, i); } glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBufferData(GL_ARRAY_BUFFER, 20 * sizeof(FFlatVertex), fill, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, BUFFER_SIZE * sizeof(FFlatVertex), map, GL_STREAM_DRAW); + mIndex = mCurIndex = 20; } - mIndex = mCurIndex = 0; glBindVertexArray(vao_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); @@ -136,15 +136,23 @@ FFlatVertexBuffer::~FFlatVertexBuffer() // //========================================================================== -CUSTOM_CVAR(Int, gl_rendermethod, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CUSTOM_CVAR(Int, gl_rendermethod, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { + int newself = self; + if (newself < 0) newself = 0; + if (newself == 0 && (gl.flags & RFL_COREPROFILE)) newself = 1; + if (newself > 3) newself = 3; } void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count) { + // this will only get called if we can't acquire a persistently mapped buffer. + // Any of the provided methods are rather shitty, with immediate mode being the most reliable across different hardware. + // Still, allow this to be set per CVAR, just in case. Fortunately for newer hardware all this nonsense is not needed anymore. switch (gl_rendermethod) { case 0: + // trusty old immediate mode #ifndef CORE_PROFILE if (!(gl.flags & RFL_COREPROFILE)) { @@ -159,6 +167,7 @@ void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offs } #endif case 1: + // uniform array if (count > 20) { int start = offset; @@ -195,9 +204,21 @@ void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offs case 2: // glBufferSubData + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferSubData(GL_ARRAY_BUFFER, offset * sizeof(FFlatVertex), count * sizeof(FFlatVertex), &vbo_shadowdata[offset]); + glDrawArrays(primtype, offset, count); + break; case 3: // glMapBufferRange + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + void *p = glMapBufferRange(GL_ARRAY_BUFFER, offset * sizeof(FFlatVertex), count * sizeof(FFlatVertex), GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT); + if (p != NULL) + { + memcpy(p, &vbo_shadowdata[offset], count * sizeof(FFlatVertex)); + glUnmapBuffer(GL_ARRAY_BUFFER); + glDrawArrays(primtype, offset, count); + } break; } } diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index d9e259db6..cb287f6c8 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -51,6 +51,7 @@ class FFlatVertexBuffer : public FVertexBuffer void CheckPlanes(sector_t *sector); const unsigned int BUFFER_SIZE = 2000000; + const unsigned int BUFFER_SIZE_TO_USE = 1999500; void ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count); @@ -74,7 +75,7 @@ public: unsigned int diff = newofs - mCurIndex; *poffset = mCurIndex; mCurIndex = newofs; - if (mCurIndex >= BUFFER_SIZE) mCurIndex = mIndex; + if (mCurIndex >= BUFFER_SIZE_TO_USE) mCurIndex = mIndex; return diff; } #ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway. From 637aa9d77e8b0abce6b49b0ca4d085fe370fb8df Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Jul 2014 18:43:54 +0200 Subject: [PATCH 0167/1509] - some adjustments to allow testing the different rendering methods. --- src/gl/system/gl_cvars.h | 1 - src/gl/system/gl_interface.cpp | 7 ++++++- wadsrc/static/menudef.z | 17 +++++++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index d0e18bca4..567d9f85f 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -38,7 +38,6 @@ EXTERN_CVAR(Bool,gl_mirrors) EXTERN_CVAR(Bool,gl_mirror_envmap) EXTERN_CVAR(Bool, gl_render_segs) EXTERN_CVAR(Bool, gl_seamless) -EXTERN_CVAR(Bool, gl_dynlight_shader) EXTERN_CVAR(Float, gl_mask_threshold) EXTERN_CVAR(Float, gl_mask_sprite_threshold) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 0b1e88548..72d5a457b 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -52,6 +52,7 @@ RenderContext gl; int occlusion_type=0; +CVAR(Bool, gl_persistent_avail, false, CVAR_NOSET); //========================================================================== // @@ -132,7 +133,11 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; - if (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; + if (CheckExtension("GL_ARB_buffer_storage") && !Args->CheckParm("-nopersistentbuffers")) + { + gl.flags |= RFL_BUFFER_STORAGE; // the cmdline option is for testing the fallback implementation on newer hardware. + gl_persistent_avail = true; + } if (CheckExtension("GL_ARB_separate_shader_objects")) gl.flags |= RFL_SEPARATE_SHADER_OBJECTS; if (!CheckExtension("GL_ARB_compatibility")) gl.flags |= RFL_COREPROFILE; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 0db780620..e448e42d9 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -105,12 +105,6 @@ OptionValue "HqResizeModes" 6, "hq4x" } -OptionValue "HqResizeTargets" -{ - 0, "Everything" - 1, "Sprites/fonts" -} - OptionValue "FogMode" { 0, "Off" @@ -130,6 +124,14 @@ OptionValue "FuzzStyle" //5, "Jagged fuzz" I can't see any difference between this and 4 so it's disabled for now. } +OptionValue "RenderMethods" +{ + 0, "Immediate mode" + 1, "Uniform array" + 2, "Buffer upload" + 3, "Mapped buffer" +} + OptionMenu "GLTextureGLOptions" { Title "TEXTURE OPTIONS" @@ -158,7 +160,6 @@ OptionMenu "GLLightOptions" Option "Force additive lighting", gl_lights_additive, "YesNo" Slider "Light intensity", gl_lights_intensity, 0.0, 1.0, 0.1 Slider "Light size", gl_lights_size, 0.0, 2.0, 0.1 - Option "Use shaders for lights", gl_dynlight_shader, "YesNo" } OptionMenu "GLPrefOptions" @@ -179,7 +180,7 @@ OptionMenu "GLPrefOptions" Option "Particle style", gl_particles_style, "Particles" Slider "Ambient light level", gl_light_ambient, 1.0, 255.0, 5.0 Option "Rendering quality", gl_render_precise, "Precision" - Option "Use vertex buffer", gl_usevbo, "OnOff" + Option "Render method", gl_rendermethod, "RenderMethods", "gl_persistent_avail" } OptionMenu "OpenGLOptions" From bdf5bbd34e0148a4f8a5085b6761e9b72ccb3213 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Jul 2014 20:56:10 +0200 Subject: [PATCH 0168/1509] - make the shader timer part of the render state. --- src/gl/renderer/gl_renderstate.cpp | 15 +-------------- src/gl/renderer/gl_renderstate.h | 8 +++++++- src/gl/shaders/gl_shader.cpp | 30 +----------------------------- src/gl/shaders/gl_shader.h | 3 +-- src/gl/textures/gl_material.cpp | 4 ++-- 5 files changed, 12 insertions(+), 48 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 73d7d5ef3..807912bca 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -88,20 +88,6 @@ void FRenderState::Reset() mClipHeightBottom = -65536.f; } - -//========================================================================== -// -// Set texture shader info -// -//========================================================================== - -void FRenderState::SetupShader(int &shaderindex, float warptime) -{ - mEffectState = shaderindex; - if (shaderindex > 0) GLRenderer->mShaderManager->SetWarpSpeed(shaderindex, warptime); -} - - //========================================================================== // // Apply shader settings @@ -149,6 +135,7 @@ bool FRenderState::ApplyShader() activeShader->muInterpolationFactor.Set(mInterpolationFactor); activeShader->muClipHeightTop.Set(mClipHeightTop); activeShader->muClipHeightBottom.Set(mClipHeightBottom); + activeShader->muTimer.Set(gl_frameMS * mShaderTimer / 1000.f); #ifndef CORE_PROFILE if (!(gl.flags & RFL_COREPROFILE)) diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index a07cd3401..63fdab4ea 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -61,6 +61,7 @@ class FRenderState float mClipHeightTop, mClipHeightBottom; bool mModelMatrixEnabled; bool mTextureMatrixEnabled; + float mShaderTimer; FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; FStateVec4 mColor; @@ -97,7 +98,12 @@ public: void Reset(); - void SetupShader(int &shaderindex, float warptime); + void SetShader(int shaderindex, float warptime) + { + mEffectState = shaderindex; + mShaderTimer = warptime; + } + void Apply(); void ApplyMatrices(); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index db3e68298..870b6184a 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -210,8 +210,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muClipHeightTop.Init(hShader, "uClipHeightTop"); muClipHeightBottom.Init(hShader, "uClipHeightBottom"); muAlphaThreshold.Init(hShader, "uAlphaThreshold"); + muTimer.Init(hShader, "timer"); - timer_index = glGetUniformLocation(hShader, "timer"); lights_index = glGetUniformLocation(hShader, "lights"); fakevb_index = glGetUniformLocation(hShader, "fakeVB"); projectionmatrix_index = glGetUniformLocation(hShader, "ProjectionMatrix"); @@ -481,34 +481,6 @@ void FShaderManager::SetActiveShader(FShader *sh) } -//========================================================================== -// -// To avoid maintenance this will be set when a warped texture is bound -// because at that point the draw buffer needs to be flushed anyway. -// -//========================================================================== - -void FShaderManager::SetWarpSpeed(unsigned int eff, float speed) -{ - // indices 0-2 match the warping modes, 3 is brightmap, 4 no texture, the following are custom - if (eff < mTextureEffects.Size()) - { - FShader *sh = mTextureEffects[eff]; - - float warpphase = gl_frameMS * speed / 1000.f; - if (gl.flags & RFL_SEPARATE_SHADER_OBJECTS) - { - glProgramUniform1f(sh->GetHandle(), sh->timer_index, warpphase); - } - else - { - // not so pretty... - sh->Bind(); - glUniform1f(sh->timer_index, warpphase); - } - } -} - //========================================================================== // // diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 6675e235e..c825996ee 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -199,8 +199,8 @@ class FShader FBufferedUniform1f muClipHeightTop; FBufferedUniform1f muClipHeightBottom; FBufferedUniform1f muAlphaThreshold; + FBufferedUniform1f muTimer; - int timer_index; int lights_index; int projectionmatrix_index; int viewmatrix_index; @@ -262,7 +262,6 @@ public: int Find(const char *mame); FShader *BindEffect(int effect); void SetActiveShader(FShader *sh); - void SetWarpSpeed(unsigned int eff, float speed); void ApplyMatrices(VSMatrix *proj, VSMatrix *view); FShader *GetActiveShader() const { diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index b6d83eb52..9ec948b37 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -737,7 +737,7 @@ void FMaterial::Bind(int clampmode, int translation, int overrideshader) int maxbound = 0; bool allowhires = tex->xScale == FRACUNIT && tex->yScale == FRACUNIT; - gl_RenderState.SetupShader(shaderindex, tex->gl_info.shaderspeed); + gl_RenderState.SetShader(shaderindex, tex->gl_info.shaderspeed); if (tex->bHasCanvas || tex->bWarped) clampmode = 0; else if (clampmode != -1) clampmode &= 3; @@ -784,7 +784,7 @@ void FMaterial::BindPatch(int translation, int overrideshader, bool alphatexture int shaderindex = overrideshader > 0? overrideshader : mShaderIndex; int maxbound = 0; - gl_RenderState.SetupShader(shaderindex, tex->gl_info.shaderspeed); + gl_RenderState.SetShader(shaderindex, tex->gl_info.shaderspeed); const FHardwareTexture *glpatch = mBaseLayer->BindPatch(0, translation, alphatexture); // The only multitexture effect usable on sprites is the brightmap. From 7ae25906fd343f1b61dfe69929ef8c1243ffd13b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Jul 2014 22:26:17 +0200 Subject: [PATCH 0169/1509] - fixed: fog must be disabled before drawing the HUD model, not after it. --- src/gl/scene/gl_scene.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 513abaa57..9244ba21f 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -765,6 +765,8 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) void FGLRenderer::EndDrawScene(sector_t * viewsector) { + gl_RenderState.EnableFog(false); + // [BB] HUD models need to be rendered here. Make sure that // DrawPlayerSprites is only called once. Either to draw // HUD models or to draw the weapon sprites. @@ -779,7 +781,6 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) glDisable(GL_STENCIL_TEST); glDisable(GL_POLYGON_SMOOTH); - gl_RenderState.EnableFog(false); framebuffer->Begin2D(false); ResetViewport(); From 77d9d9b2a588c5902dfb26ebb8affe3fdab2bdd7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Jul 2014 11:53:18 +0200 Subject: [PATCH 0170/1509] - fixed: For updating the model VAO's attribute pointers it is necessary to first bind the vertex buffer we need to refer to, because this is not part of the VAO's state. --- src/gl/models/gl_models.cpp | 1 + src/gl/shaders/gl_shader.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 3d2d0db05..39663ab53 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -140,6 +140,7 @@ FModelVertexBuffer::~FModelVertexBuffer() unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int frame2, float factor) { + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].x); glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].u); glVertexAttribPointer(VATTR_VERTEX2, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame2].x); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 870b6184a..20abe17e5 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -88,7 +88,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * // FString vp_comb = "#version 130\n"; - if (gl.glslversion >= 3.3f) vp_comb = "#version 330 core\n"; // I can't shut up the deprecation warnings in GLSL 1.3 so if available use a version with compatibility profile. // todo when using shader storage buffers, add // "#version 400 compatibility\n#extension GL_ARB_shader_storage_buffer_object : require\n" instead. From c1d8f235c25e9caaa720dbb47f86eb7defd26fab Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Jul 2014 12:33:54 +0200 Subject: [PATCH 0171/1509] - renamed some stuff that clashed with gl function names. --- src/gl/data/gl_matrix.cpp | 14 +++++++------- src/gl/renderer/gl_renderstate.cpp | 24 +++++++++++++----------- src/gl/renderer/gl_renderstate.h | 12 +++++------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/gl/data/gl_matrix.cpp b/src/gl/data/gl_matrix.cpp index aa98a3c66..35683dbb8 100644 --- a/src/gl/data/gl_matrix.cpp +++ b/src/gl/data/gl_matrix.cpp @@ -40,7 +40,7 @@ VSMatrix::setIdentityMatrix( FLOATTYPE *mat, int size) { -// glLoadIdentity implementation +// gl LoadIdentity implementation void VSMatrix::loadIdentity() { @@ -54,7 +54,7 @@ VSMatrix::loadIdentity() } -// glMultMatrix implementation +// gl MultMatrix implementation void VSMatrix::multMatrix(const FLOATTYPE *aMatrix) { @@ -76,7 +76,7 @@ VSMatrix::multMatrix(const FLOATTYPE *aMatrix) } #ifdef USE_DOUBLE -// glMultMatrix implementation +// gl MultMatrix implementation void VSMatrix::multMatrix(const float *aMatrix) { @@ -100,7 +100,7 @@ VSMatrix::multMatrix(const float *aMatrix) -// glLoadMatrix implementation +// gl LoadMatrix implementation void VSMatrix::loadMatrix(const FLOATTYPE *aMatrix) { @@ -108,7 +108,7 @@ VSMatrix::loadMatrix(const FLOATTYPE *aMatrix) } #ifdef USE_DOUBLE -// glLoadMatrix implementation +// gl LoadMatrix implementation void VSMatrix::loadMatrix(const float *aMatrix) { @@ -265,7 +265,7 @@ VSMatrix::perspective(FLOATTYPE fov, FLOATTYPE ratio, FLOATTYPE nearp, FLOATTYPE } -// glOrtho implementation +// gl Ortho implementation void VSMatrix::ortho(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, @@ -282,7 +282,7 @@ VSMatrix::ortho(FLOATTYPE left, FLOATTYPE right, } -// glFrustum implementation +// gl Frustum implementation void VSMatrix::frustum(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 807912bca..bee49cd96 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -74,11 +74,9 @@ void FRenderState::Reset() mDesaturation = 0; mSrcBlend = GL_SRC_ALPHA; mDstBlend = GL_ONE_MINUS_SRC_ALPHA; - glSrcBlend = glDstBlend = -1; mAlphaThreshold = 0.5f; mBlendEquation = GL_FUNC_ADD; mObjectColor = 0xffffffff; - glBlendEquation = -1; m2D = true; mVertexBuffer = mCurrentVertexBuffer = NULL; mColormapState = CM_DEFAULT; @@ -86,6 +84,10 @@ void FRenderState::Reset() mSpecialEffect = EFF_NONE; mClipHeightTop = 65536.f; mClipHeightBottom = -65536.f; + + stSrcBlend = stDstBlend = -1; + stBlendEquation = -1; + stAlphaThreshold = -1.f; } //========================================================================== @@ -140,9 +142,9 @@ bool FRenderState::ApplyShader() #ifndef CORE_PROFILE if (!(gl.flags & RFL_COREPROFILE)) { - if (mAlphaThreshold != glAlphaThreshold) + if (mAlphaThreshold != stAlphaThreshold) { - glAlphaThreshold = mAlphaThreshold; + stAlphaThreshold = mAlphaThreshold; if (mAlphaThreshold < 0.f) { glDisable(GL_ALPHA_TEST); @@ -150,7 +152,7 @@ bool FRenderState::ApplyShader() else { glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, mAlphaThreshold); + glAlphaFunc(GL_GREATER, mAlphaThreshold * mColor.vec[3]); } } } @@ -271,16 +273,16 @@ void FRenderState::Apply() { if (!gl_direct_state_change) { - if (mSrcBlend != glSrcBlend || mDstBlend != glDstBlend) + if (mSrcBlend != stSrcBlend || mDstBlend != stDstBlend) { - glSrcBlend = mSrcBlend; - glDstBlend = mDstBlend; + stSrcBlend = mSrcBlend; + stDstBlend = mDstBlend; glBlendFunc(mSrcBlend, mDstBlend); } - if (mBlendEquation != glBlendEquation) + if (mBlendEquation != stBlendEquation) { - glBlendEquation = mBlendEquation; - ::glBlendEquation(mBlendEquation); + stBlendEquation = mBlendEquation; + glBlendEquation(mBlendEquation); } } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 63fdab4ea..562cfb0ef 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -75,12 +75,10 @@ class FRenderState int mEffectState; int mColormapState; - float glAlphaThreshold; - bool glClipOn; - - int glSrcBlend, glDstBlend; - bool glAlphaTest; - int glBlendEquation; + float stAlphaThreshold; + int stSrcBlend, stDstBlend; + bool stAlphaTest; + int stBlendEquation; bool ApplyShader(); @@ -299,7 +297,7 @@ public: } else { - ::glBlendEquation(eq); + glBlendEquation(eq); } } From 97341fcb31b0e0c11f592882f4c4e98fd099e31b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Jul 2014 13:46:35 +0200 Subject: [PATCH 0172/1509] - reenabled the flat vertex buffer for GL 3.x NVidia hardware. On AMD and Intel it'll stay off because past tests have shown that it won't improve performance at all. --- src/gl/data/gl_vertexbuffer.cpp | 55 +++++++++++++++++---------------- src/gl/data/gl_vertexbuffer.h | 1 + src/gl/system/gl_interface.cpp | 5 +-- src/gl/system/gl_interface.h | 1 + 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index c09996bf0..f68883edf 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -96,7 +96,7 @@ FFlatVertexBuffer::FFlatVertexBuffer() glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); - mIndex = mCurIndex = 0; + mNumReserved = mIndex = mCurIndex = 0; } else { @@ -109,7 +109,7 @@ FFlatVertexBuffer::FFlatVertexBuffer() } glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glBufferData(GL_ARRAY_BUFFER, BUFFER_SIZE * sizeof(FFlatVertex), map, GL_STREAM_DRAW); - mIndex = mCurIndex = 20; + mNumReserved = mIndex = mCurIndex = 20; } glBindVertexArray(vao_id); @@ -390,6 +390,11 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) if (plane == sector_t::floor && sec->transdoor) vt->z -= 1; mapvt->z = vt->z; } + if (!(gl.flags & RFL_BUFFER_STORAGE)) + { + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferSubData(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex), &vbo_shadowdata[startvt]); + } } //========================================================================== @@ -400,12 +405,20 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) void FFlatVertexBuffer::CreateVBO() { - vbo_shadowdata.Clear(); - if (gl.flags & RFL_BUFFER_STORAGE) + if (!(gl.flags & RFL_NOBUFFER)) { + vbo_shadowdata.Resize(mNumReserved); CreateFlatVBO(); - memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); mCurIndex = mIndex = vbo_shadowdata.Size(); + if (gl.flags & RFL_BUFFER_STORAGE) + { + memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); + } + else + { + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferSubData(GL_ARRAY_BUFFER, mNumReserved * sizeof(FFlatVertex), (mIndex - mNumReserved) * sizeof(FFlatVertex), &vbo_shadowdata[mNumReserved]); + } } else if (sectors) { @@ -417,6 +430,7 @@ void FFlatVertexBuffer::CreateVBO() sectors[i].vboheight[1] = sectors[i].vboheight[0] = FIXED_MIN; } } + } //========================================================================== @@ -427,39 +441,28 @@ void FFlatVertexBuffer::CreateVBO() void FFlatVertexBuffer::CheckPlanes(sector_t *sector) { - if (gl.flags & RFL_BUFFER_STORAGE) + if (sector->GetPlaneTexZ(sector_t::ceiling) != sector->vboheight[sector_t::ceiling]) { - if (sector->GetPlaneTexZ(sector_t::ceiling) != sector->vboheight[sector_t::ceiling]) - { - //if (sector->ceilingdata == NULL) // only update if there's no thinker attached - { - UpdatePlaneVertices(sector, sector_t::ceiling); - sector->vboheight[sector_t::ceiling] = sector->GetPlaneTexZ(sector_t::ceiling); - } - } - if (sector->GetPlaneTexZ(sector_t::floor) != sector->vboheight[sector_t::floor]) - { - //if (sector->floordata == NULL) // only update if there's no thinker attached - { - UpdatePlaneVertices(sector, sector_t::floor); - sector->vboheight[sector_t::floor] = sector->GetPlaneTexZ(sector_t::floor); - } - } + UpdatePlaneVertices(sector, sector_t::ceiling); + sector->vboheight[sector_t::ceiling] = sector->GetPlaneTexZ(sector_t::ceiling); + } + if (sector->GetPlaneTexZ(sector_t::floor) != sector->vboheight[sector_t::floor]) + { + UpdatePlaneVertices(sector, sector_t::floor); + sector->vboheight[sector_t::floor] = sector->GetPlaneTexZ(sector_t::floor); } } //========================================================================== // // checks the validity of all planes attached to this sector -// and updates them if possible. Anything moving will not be -// updated unless it stops. This is to ensure that we never -// have to synchronize with the rendering process. +// and updates them if possible. // //========================================================================== void FFlatVertexBuffer::CheckUpdate(sector_t *sector) { - if (gl.flags & RFL_BUFFER_STORAGE) + if (!(gl.flags & RFL_NOBUFFER)) { CheckPlanes(sector); sector_t *hs = sector->GetHeightSec(); diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index cb287f6c8..b6d61f2da 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -47,6 +47,7 @@ class FFlatVertexBuffer : public FVertexBuffer FFlatVertex *map; unsigned int mIndex; unsigned int mCurIndex; + unsigned int mNumReserved; void CheckPlanes(sector_t *sector); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 72d5a457b..2d5f13125 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -120,7 +120,7 @@ void gl_LoadExtensions() // Don't even start if it's lower than 3.0 - if (strcmp(version, "3.0") < 0) + if (strcmp(version, "3.0") < 0) { I_FatalError("Unsupported OpenGL version.\nAt least GL 3.0 is required to run " GAMENAME ".\n"); } @@ -129,8 +129,9 @@ void gl_LoadExtensions() gl.version = strtod(version, NULL) + 0.01f; gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL) + 0.01f; - gl.vendorstring=(char*)glGetString(GL_VENDOR); + gl.vendorstring = (char*)glGetString(GL_VENDOR); + if (!strstr(gl.vendorstring, "NVIDIA Corporation")); gl.flags |= RFL_NOBUFFER; if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; if (CheckExtension("GL_ARB_buffer_storage") && !Args->CheckParm("-nopersistentbuffers")) diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 2209f0bed..d33ce77fc 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -14,6 +14,7 @@ enum RenderFlags RFL_SHADER_STORAGE_BUFFER = 16, // to be used later for a parameter buffer RFL_BASEINDEX = 32, // currently unused RFL_COREPROFILE = 64, + RFL_NOBUFFER = 128, // the static buffer makes no sense on GL 3.x AMD and Intel hardware, as long as compatibility mode is on }; enum TexMode From 4904abfc1cfc54c54b82207958dd20862c410674 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Jul 2014 13:47:37 +0200 Subject: [PATCH 0173/1509] - forgot test stuff. --- src/gl/system/gl_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 2d5f13125..f4d13f8f2 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -131,7 +131,7 @@ void gl_LoadExtensions() gl.vendorstring = (char*)glGetString(GL_VENDOR); - if (!strstr(gl.vendorstring, "NVIDIA Corporation")); gl.flags |= RFL_NOBUFFER; + if (!strstr(gl.vendorstring, "NVIDIA Corporation")) gl.flags |= RFL_NOBUFFER; if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; if (CheckExtension("GL_ARB_buffer_storage") && !Args->CheckParm("-nopersistentbuffers")) From 754c96a540c1f84706a169aac22f5c6793730dd7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Jul 2014 16:09:47 +0200 Subject: [PATCH 0174/1509] - added default precision settings to shader include because some old ATI drivers complain if they aren't there - even though the spec doesn't require them... --- wadsrc/static/shaders/glsl/shaderdefs.i | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 2870cf975..242b7244b 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -1,5 +1,9 @@ // This file contains common data definitions for both vertex and fragment shader +// these settings are actually pointless but there seem to be some old ATI drivers that fail to compile the shader without setting the precision here. +precision highp int; +precision highp float; + uniform vec4 uCameraPos; uniform int uTextureMode; uniform float uClipHeightTop, uClipHeightBottom; From 925305aa051157709ae6a98f21c6d2497ec4b9f9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Jul 2014 17:57:53 +0200 Subject: [PATCH 0175/1509] - fixed: The code for updating vertex dirty state had been completely missing. I have no idea when it disappeared... --- src/gl/data/gl_setup.cpp | 28 +++++++++++++++++++++++++++- src/gl/system/gl_menu.cpp | 2 -- src/r_defs.h | 18 ++++++++++++++++-- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index a76e618d9..cf2f62d74 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -625,12 +625,38 @@ void gl_PreprocessLevel() PrepareSegs(); PrepareSectorData(); InitVertexData(); + int *checkmap = new int[numvertexes]; + memset(checkmap, -1, sizeof(int)*numvertexes); for(i=0;isidedef[0]->Flags & WALLF_POLYOBJ) continue; // don't bother with polyobjects + + int vtnum1 = int(l->v1 - vertexes); + int vtnum2 = int(l->v2 - vertexes); + + if (checkmap[numsectors + vtnum1] < i) + { + checkmap[numsectors + vtnum1] = i; + sectors[i].e->vertices.Push(&vertexes[vtnum1]); + vertexes[vtnum1].dirty = true; + } + + if (checkmap[numsectors + vtnum2] < i) + { + checkmap[numsectors + vtnum2] = i; + sectors[i].e->vertices.Push(&vertexes[vtnum2]); + vertexes[vtnum2].dirty = true; + } + } } + delete[] checkmap; gl_InitPortals(); diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index 75436209c..2ec515300 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -18,7 +18,6 @@ CVAR(Bool, gl_portals, true, 0) CVAR(Bool, gl_noquery, false, 0) CVAR(Bool,gl_mirrors,true,0) // This is for debugging only! CVAR(Bool,gl_mirror_envmap, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) -CVAR(Bool, gl_render_segs, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, gl_seamless, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CUSTOM_CVAR(Int, r_mirror_recursions,4,CVAR_GLOBALCONFIG|CVAR_ARCHIVE) @@ -34,7 +33,6 @@ CUSTOM_CVAR(Bool, gl_plane_reflection, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) CUSTOM_CVAR(Bool, gl_render_precise, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) { - //gl_render_segs=self; gl_seamless=self; } diff --git a/src/r_defs.h b/src/r_defs.h index a87d46cc2..2a76510f8 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -438,6 +438,8 @@ struct extsector_t TArray lightlist; // 3D light list TArray attached; // 3D floors attached to this sector } XFloor; + + TArray vertices; void Serialize(FArchive &arc); }; @@ -635,14 +637,28 @@ struct sector_t return planes[pos].TexZ; } + void SetVerticesDirty() + { + for (unsigned i = 0; i < e->vertices.Size(); i++) e->vertices[i]->dirty = true; + } + + void SetAllVerticesDirty() + { + SetVerticesDirty(); + for (unsigned i = 0; i < e->FakeFloor.Sectors.Size(); i++) e->FakeFloor.Sectors[i]->SetVerticesDirty(); + for (unsigned i = 0; i < e->XFloor.attached.Size(); i++) e->XFloor.attached[i]->SetVerticesDirty(); + } + void SetPlaneTexZ(int pos, fixed_t val) { planes[pos].TexZ = val; + SetAllVerticesDirty(); } void ChangePlaneTexZ(int pos, fixed_t val) { planes[pos].TexZ += val; + SetAllVerticesDirty(); } static inline short ClampLight(int level) @@ -765,8 +781,6 @@ struct sector_t // GL only stuff starts here float reflect[2]; - int dirtyframe[3]; // last frame this sector was marked dirty - bool dirty; // marked for recalculation bool transdoor; // For transparent door hacks fixed_t transdoorheight; // for transparent door hacks int subsectorcount; // list of subsectors From 3d24f58bf05ed4eeaa6e84d2bf9033712f45d51f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Jul 2014 20:18:32 +0200 Subject: [PATCH 0176/1509] - fixed conditions for disabling the flat vertex buffer. --- src/gl/system/gl_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index f4d13f8f2..ca40bc60e 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -131,7 +131,6 @@ void gl_LoadExtensions() gl.vendorstring = (char*)glGetString(GL_VENDOR); - if (!strstr(gl.vendorstring, "NVIDIA Corporation")) gl.flags |= RFL_NOBUFFER; if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; if (CheckExtension("GL_ARB_buffer_storage") && !Args->CheckParm("-nopersistentbuffers")) @@ -142,6 +141,7 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_separate_shader_objects")) gl.flags |= RFL_SEPARATE_SHADER_OBJECTS; if (!CheckExtension("GL_ARB_compatibility")) gl.flags |= RFL_COREPROFILE; + if (!(gl.flags & (RFL_COREPROFILE|RFL_BUFFER_STORAGE)) && !strstr(gl.vendorstring, "NVIDIA Corporation")) gl.flags |= RFL_NOBUFFER; glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); From c9c93a58a2129f79a3c53f7bc4102d03f9ea9e69 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Jul 2014 21:55:25 +0200 Subject: [PATCH 0177/1509] - fixed bad constant and potential use of uninitialized variable. --- src/gl/scene/gl_flats.cpp | 4 ++-- src/gl/system/gl_framebuffer.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 2767a5e80..60b1237d5 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -344,12 +344,12 @@ inline void GLFlat::PutFlat(bool fog) { Colormap.Clear(); } - if (renderstyle!=STYLE_Translucent || alpha < 1.f - FLT_EPSILON || fog) + if (renderstyle!=STYLE_Translucent || alpha < 1.f - FLT_EPSILON || fog || gltexture == NULL) { // translucent 3D floors go into the regular translucent list, translucent portals go into the translucent border list. list = (renderflags&SSRF_RENDER3DPLANES) ? GLDL_TRANSLUCENT : GLDL_TRANSLUCENTBORDER; } - else if (gltexture != NULL) + else { bool masked = gltexture->isMasked() && ((renderflags&SSRF_RENDER3DPLANES) || stack); list = masked ? GLDL_MASKED : GLDL_PLAIN; diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index fa5370b2d..b2f147dc1 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -121,7 +121,7 @@ void OpenGLFrameBuffer::InitializeState() if (first) { - glewExperimental=TRUE; + glewExperimental=true; glewInit(); } From ece10bb57ff0c5b1a708af9c6413af38059098f3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Jul 2014 21:57:05 +0200 Subject: [PATCH 0178/1509] - fixed several incorrect uses of abs instead of fabs. --- src/gl/models/gl_models.cpp | 2 +- src/gl/scene/gl_sprite.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 808cbff95..fac9bd5bb 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -731,7 +731,7 @@ void gl_RenderModel(GLSprite * spr, int cm) { if((x * cos(angle * M_PI / 180) + y * sin(angle * M_PI / 180)) / sqrt(x * x + y * y) < 0) pitch *= -1; } - else pitch = abs(pitch); + else pitch = fabs(pitch); } if( smf->flags & MDL_ROTATING ) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 63efb978e..0ba386b1a 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -663,9 +663,9 @@ void GLSprite::Process(AActor* thing,sector_t * sector) if (smarterclip) { // Reduce slightly clipping adjustment of corpses - if (thing->flags & MF_CORPSE || spriteheight > abs(diffb)) + if (thing->flags & MF_CORPSE || spriteheight > fabs(diffb)) { - float ratio = clamp((abs(diffb) * (float)gl_sclipfactor/(spriteheight+1)), 0.5, 1.0); + float ratio = clamp((fabs(diffb) * (float)gl_sclipfactor/(spriteheight+1)), 0.5, 1.0); diffb*=ratio; } if (!diffb) @@ -679,9 +679,9 @@ void GLSprite::Process(AActor* thing,sector_t * sector) difft=0; } } - if (spriteheight > abs(difft)) + if (spriteheight > fabs(difft)) { - float ratio = clamp((abs(difft) * (float)gl_sclipfactor/(spriteheight+1)), 0.5, 1.0); + float ratio = clamp((fabs(difft) * (float)gl_sclipfactor/(spriteheight+1)), 0.5, 1.0); difft*=ratio; } z2-=difft; From 355dd1c2f5e958bab31da71068e1ab2c53c9f69e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Jul 2014 18:01:01 +0200 Subject: [PATCH 0179/1509] - fixed some issues with setting the vertex dirty state. It was also called from several sector init functions and copy code for Boom deep water. The only case where SetPlaneTexZ should call it is from the interpolation code so this is a special case now. --- src/r_data/r_interpolate.cpp | 6 +++--- src/r_defs.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/r_data/r_interpolate.cpp b/src/r_data/r_interpolate.cpp index 3ca3b557c..29f54c39b 100644 --- a/src/r_data/r_interpolate.cpp +++ b/src/r_data/r_interpolate.cpp @@ -451,12 +451,12 @@ void DSectorPlaneInterpolation::Restore() if (!ceiling) { sector->floorplane.d = bakheight; - sector->SetPlaneTexZ(sector_t::floor, baktexz); + sector->SetPlaneTexZ(sector_t::floor, baktexz, true); } else { sector->ceilingplane.d = bakheight; - sector->SetPlaneTexZ(sector_t::ceiling, baktexz); + sector->SetPlaneTexZ(sector_t::ceiling, baktexz, true); } P_RecalculateAttached3DFloors(sector); } @@ -487,7 +487,7 @@ void DSectorPlaneInterpolation::Interpolate(fixed_t smoothratio) baktexz = sector->GetPlaneTexZ(pos); *pheight = oldheight + FixedMul(bakheight - oldheight, smoothratio); - sector->SetPlaneTexZ(pos, oldtexz + FixedMul(baktexz - oldtexz, smoothratio)); + sector->SetPlaneTexZ(pos, oldtexz + FixedMul(baktexz - oldtexz, smoothratio), true); P_RecalculateAttached3DFloors(sector); } diff --git a/src/r_defs.h b/src/r_defs.h index 2a76510f8..d0d538aa5 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -649,10 +649,10 @@ struct sector_t for (unsigned i = 0; i < e->XFloor.attached.Size(); i++) e->XFloor.attached[i]->SetVerticesDirty(); } - void SetPlaneTexZ(int pos, fixed_t val) + void SetPlaneTexZ(int pos, fixed_t val, bool dirtify = false) // This mainly gets used by init code. The only place where it must set the vertex to dirty is the interpolation code. { planes[pos].TexZ = val; - SetAllVerticesDirty(); + if (dirtify) SetAllVerticesDirty(); } void ChangePlaneTexZ(int pos, fixed_t val) From 318aebc4ad9ff6cfc490ece5051b8e49b16c5235 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Jul 2014 22:23:17 +0200 Subject: [PATCH 0180/1509] - fixed: the vertex collection code used incorrect indices for checking the checkmap array. --- src/gl/data/gl_setup.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index cf2f62d74..9603cc858 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -641,16 +641,16 @@ void gl_PreprocessLevel() int vtnum1 = int(l->v1 - vertexes); int vtnum2 = int(l->v2 - vertexes); - if (checkmap[numsectors + vtnum1] < i) + if (checkmap[vtnum1] < i) { - checkmap[numsectors + vtnum1] = i; + checkmap[vtnum1] = i; sectors[i].e->vertices.Push(&vertexes[vtnum1]); vertexes[vtnum1].dirty = true; } - if (checkmap[numsectors + vtnum2] < i) + if (checkmap[vtnum2] < i) { - checkmap[numsectors + vtnum2] = i; + checkmap[vtnum2] = i; sectors[i].e->vertices.Push(&vertexes[vtnum2]); vertexes[vtnum2].dirty = true; } From ef8f66c9a1acd6df65e5d6700305e4e391b8cb26 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 30 Jul 2014 23:13:16 +0200 Subject: [PATCH 0181/1509] - removed the code for hardware alpha testing again because it didn't work anymore with how things are set up now. - we need to check all GL versions when trying to get a context because some drivers only give us the version we request, leaving out newer features that are not exposed via extension. - added some status info about uniform blocks. --- src/gl/renderer/gl_renderstate.cpp | 24 +------------------ src/gl/system/gl_interface.cpp | 4 ++++ src/gl/system/gl_interface.h | 1 + src/gl/textures/gl_hwtexture.cpp | 2 ++ src/win32/win32gliface.cpp | 31 +++++++------------------ wadsrc/static/shaders/glsl/main.fp | 4 +--- wadsrc/static/shaders/glsl/shaderdefs.i | 2 -- 7 files changed, 17 insertions(+), 51 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index bee49cd96..24492c495 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -138,29 +138,7 @@ bool FRenderState::ApplyShader() activeShader->muClipHeightTop.Set(mClipHeightTop); activeShader->muClipHeightBottom.Set(mClipHeightBottom); activeShader->muTimer.Set(gl_frameMS * mShaderTimer / 1000.f); - -#ifndef CORE_PROFILE - if (!(gl.flags & RFL_COREPROFILE)) - { - if (mAlphaThreshold != stAlphaThreshold) - { - stAlphaThreshold = mAlphaThreshold; - if (mAlphaThreshold < 0.f) - { - glDisable(GL_ALPHA_TEST); - } - else - { - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, mAlphaThreshold * mColor.vec[3]); - } - } - } - else -#endif - { - activeShader->muAlphaThreshold.Set(mAlphaThreshold); - } + activeShader->muAlphaThreshold.Set(mAlphaThreshold); if (mGlowEnabled) { diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index ca40bc60e..404c068d7 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -175,6 +175,9 @@ void gl_PrintStartupLog() gl.maxuniforms = v; glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &v); Printf ("Max. vertex uniforms: %d\n", v); + glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); + Printf ("Max. uniform block size: %d\n", v); + gl.maxuniformblock = v; glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); Printf ("Max. varying: %d\n", v); glGetIntegerv(GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS, &v); @@ -182,5 +185,6 @@ void gl_PrintStartupLog() glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &v); Printf("Max. vertex shader storage blocks: %d\n", v); + } diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index d33ce77fc..a88133929 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -29,6 +29,7 @@ struct RenderContext { unsigned int flags; unsigned int maxuniforms; + unsigned int maxuniformblock; float version; float glslversion; int max_texturesize; diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 516b5aaf5..98229a1ca 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -192,6 +192,8 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i if (alphatexture) { // thanks to deprecation and delayed introduction of a suitable replacement feature this has become a bit messy... + // Of all the targeted hardware, the Intel GMA 2000 and 3000 are the only ones not supporting texture swizzle, and they + // are also the only ones not supoorting GL 3.3. On those we are forced to use a full RGBA texture here. if (gl.version >= 3.3f) { texformat = GL_R8; diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 3b630177a..a0e55d673 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -745,37 +745,22 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) #else bool core = true; #endif - if (core) - { - // let's try to get the best version possible. - static int versions[] = { 44, 43, 42, 41, 40, 33, 32, -1 }; + // let's try to get the best version possible. Some drivers only give us the version we request + // which breaks all version checks for feature support. The highest used features we use are from version 4.4, and 3.0 is a requirement. + static int versions[] = { 44, 43, 42, 41, 40, 33, 32, 30, -1 }; - for (int i = 0; versions[i] > 0; i++) - { - int ctxAttribs[] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, versions[i] / 10, - WGL_CONTEXT_MINOR_VERSION_ARB, versions[i] % 10, - WGL_CONTEXT_FLAGS_ARB, gl_debug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - 0 - }; - - m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); - if (m_hRC != NULL) break; - } - } - else + for (int i = 0; versions[i] > 0; i++) { int ctxAttribs[] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3, - WGL_CONTEXT_MINOR_VERSION_ARB, 0, + WGL_CONTEXT_MAJOR_VERSION_ARB, versions[i] / 10, + WGL_CONTEXT_MINOR_VERSION_ARB, versions[i] % 10, WGL_CONTEXT_FLAGS_ARB, gl_debug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + WGL_CONTEXT_PROFILE_MASK_ARB, core? WGL_CONTEXT_CORE_PROFILE_BIT_ARB : WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0 }; m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); - + if (m_hRC != NULL) break; } } if (m_hRC == 0) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index a4e4d782b..482afc0ca 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -222,12 +222,10 @@ void main() { vec4 frag = ProcessTexel(); -#ifdef CORE_PROFILE - // alpha testing - only for the core profile, in compatibility mode we use the alpha test. +#ifndef NO_ALPHATEST if (frag.a <= uAlphaThreshold) discard; #endif - switch (uFixedColormap) { case 0: diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 242b7244b..d310126ab 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -8,9 +8,7 @@ uniform vec4 uCameraPos; uniform int uTextureMode; uniform float uClipHeightTop, uClipHeightBottom; -#ifdef CORE_PROFILE uniform float uAlphaThreshold; -#endif // colors From 1ec58011d2dc761043d19e9b098b3969cf26ed55 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 31 Jul 2014 00:44:22 +0200 Subject: [PATCH 0182/1509] - start of light buffer implementation so that we don't have to use uniform arrays which appear to be broken on AMD. --- src/CMakeLists.txt | 1 + src/gl/dynlights/gl_lightbuffer.cpp | 153 ++++++++++++++++++++++++++++ src/gl/dynlights/gl_lightbuffer.h | 30 ++++++ src/gl/scene/gl_wall.h | 2 +- src/gl/scene/gl_walls.cpp | 2 + src/gl/shaders/gl_shader.cpp | 10 +- 6 files changed, 192 insertions(+), 6 deletions(-) create mode 100644 src/gl/dynlights/gl_lightbuffer.cpp create mode 100644 src/gl/dynlights/gl_lightbuffer.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 22fd833b4..fdc4bb6e4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1088,6 +1088,7 @@ add_executable( zdoom WIN32 gl/dynlights/gl_dynlight.cpp gl/dynlights/gl_glow.cpp gl/dynlights/gl_dynlight1.cpp + gl/dynlights/gl_lightbuffer.cpp gl/shaders/gl_shader.cpp gl/shaders/gl_texshader.cpp gl/system/gl_interface.cpp diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp new file mode 100644 index 000000000..663631240 --- /dev/null +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -0,0 +1,153 @@ +/* +** gl_lightbuffer.cpp +** Buffer data maintenance for dynamic lights +** +**--------------------------------------------------------------------------- +** Copyright 2014 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "gl/dynlights/gl_lightbuffer.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/system/gl_interface.h" + +static const int LIGHTBUF_BINDINGPOINT = 1; + +FLightBuffer::FLightBuffer() +{ + if (gl.flags & RFL_SHADER_STORAGE_BUFFER) + { + mBufferType = GL_SHADER_STORAGE_BUFFER; + mBufferSize = 80000; // 40000 lights per scene should be plenty. The largest I've ever seen was around 5000. + } + else + { + mBufferType = GL_UNIFORM_BUFFER; + mBufferSize = gl.maxuniformblock / 4 - 100; // we need to be a bit careful here so don't use the full buffer size + } + AddBuffer(); + Clear(); +} + +FLightBuffer::~FLightBuffer() +{ + glBindBuffer(mBufferType, 0); + for (unsigned int i = 0; i < mBufferIds.Size(); i++) + { + glDeleteBuffers(1, &mBufferIds[i]); + } +} + +void FLightBuffer::AddBuffer() +{ + unsigned int id; + glGenBuffers(1, &id); + mBufferIds.Push(id); + glBindBuffer(mBufferType, id); + unsigned int bytesize = mBufferSize * 8 * sizeof(float); + if (gl.flags & RFL_BUFFER_STORAGE) + { + glBufferStorage(mBufferType, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + void *map = glMapBufferRange(mBufferType, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + mBufferPointers.Push((float*)map); + } + else + { + glBufferData(mBufferType, bytesize, NULL, GL_STREAM_DRAW); + } +} + +void FLightBuffer::Clear() +{ + mBufferNum = 0; + mIndex = 0; + mBufferArray.Clear(); + mBufferStart.Clear(); +} + +void FLightBuffer::UploadLights(FDynLightData &data, unsigned int &buffernum, unsigned int &bufferindex) +{ + int size0 = data.arrays[0].Size()/4; + int size1 = data.arrays[1].Size()/4; + int size2 = data.arrays[2].Size()/4; + int totalsize = size0 + size1 + size2 + 1; + + if (totalsize == 0) return; + + if (mIndex + totalsize > mBufferSize) + { + if (gl.flags & RFL_SHADER_STORAGE_BUFFER) + { + return; // we do not want multiple shader storage blocks. 40000 lights is too much already + } + else + { + mBufferNum++; + mBufferStart.Push(mIndex); + mIndex = 0; + if (mBufferIds.Size() <= mBufferNum) AddBuffer(); + } + } + + float *copyptr; + + if (gl.flags & RFL_BUFFER_STORAGE) + { + copyptr = mBufferPointers[mBufferNum] + mIndex * 4; + } + else + { + unsigned int pos = mBufferArray.Reserve(totalsize * 4); + copyptr = &mBufferArray[pos]; + } + + float parmcnt[] = { mIndex + 1, mIndex + 1 + size0, mIndex + 1 + size0 + size1, mIndex + totalsize }; + + memcpy(©ptr[0], parmcnt, 4 * sizeof(float)); + memcpy(©ptr[1], &data.arrays[0][0], 4 * size0*sizeof(float)); + memcpy(©ptr[1 + size0], &data.arrays[1][0], 4 * size1*sizeof(float)); + memcpy(©ptr[1 + size0 + size1], &data.arrays[2][0], 4 * size2*sizeof(float)); + buffernum = mBufferNum; + bufferindex = mIndex; + mIndex += totalsize; +} + +void FLightBuffer::Finish() +{ + //glBindBufferBase(mBufferType, LIGHTBUF_BINDINGPOINT, mBufferIds[0]); +} + + + diff --git a/src/gl/dynlights/gl_lightbuffer.h b/src/gl/dynlights/gl_lightbuffer.h new file mode 100644 index 000000000..57e6bf0c8 --- /dev/null +++ b/src/gl/dynlights/gl_lightbuffer.h @@ -0,0 +1,30 @@ +#ifndef __GL_LIGHTBUFFER_H +#define __GL_LIGHTBUFFER_H + +#include "tarray.h" +struct FDynLightData; + +class FLightBuffer +{ + TArray mBufferArray; + TArray mBufferIds; + TArray mBufferStart; + TArray mBufferPointers; + unsigned int mBufferType; + unsigned int mBufferSize; + unsigned int mIndex; + unsigned int mBufferNum; + + void AddBuffer(); + +public: + + FLightBuffer(); + ~FLightBuffer(); + void Clear(); + void UploadLights(FDynLightData &data, unsigned int &buffernum, unsigned int &bufferindex); + void Finish(); +}; + +#endif + diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index fafd5ccb8..e17f61c3e 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -135,7 +135,7 @@ public: float topglowcolor[4]; float bottomglowcolor[4]; - int firstdynlight, lastdynlight; + unsigned int dynlightindex, dynlightbuffer; int firstwall, numwalls; // splitting info. union diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index e665eeb89..cd179a265 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1486,6 +1486,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) glseg.y2= FIXED2FLOAT(v2->y); Colormap=frontsector->ColorMap; flags = 0; + dynlightindex = UINT_MAX; int rel = 0; int orglightlevel = gl_ClampLight(frontsector->lightlevel); @@ -1750,6 +1751,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * bottomflat = frontsector->GetTexture(sector_t::floor); topplane = frontsector->ceilingplane; bottomplane = frontsector->floorplane; + dynlightindex = UINT_MAX; zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 20abe17e5..1ddb58076 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -264,7 +264,7 @@ FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath FString defines; // this can't be in the shader code due to ATI strangeness. if (gl.MaxLights() == 128) defines += "#define MAXLIGHTS128\n"; - if (!usediscard) defines += "#define NO_DISCARD\n"; + if (!usediscard) defines += "#define NO_ALPHATEST\n"; FShader *shader = NULL; try @@ -350,10 +350,10 @@ struct FEffectShader static const FEffectShader effectshaders[]= { - { "fogboundary", "shaders/glsl/main.vp", "shaders/glsl/fogboundary.fp", NULL, "" }, - { "spheremap", "shaders/glsl/main.vp", "shaders/glsl/main.fp", "shaders/glsl/func_normal.fp", "#define SPHEREMAP\n" }, - { "burn", "shaders/glsl/main.vp", "shaders/glsl/burn.fp", NULL, "#define SIMPLE\n" }, - { "stencil", "shaders/glsl/main.vp", "shaders/glsl/stencil.fp", NULL, "#define SIMPLE\n" }, + { "fogboundary", "shaders/glsl/main.vp", "shaders/glsl/fogboundary.fp", NULL, "#define NO_ALPHATEST\n" }, + { "spheremap", "shaders/glsl/main.vp", "shaders/glsl/main.fp", "shaders/glsl/func_normal.fp", "#define SPHEREMAP\n#define NO_ALPHATEST\n" }, + { "burn", "shaders/glsl/main.vp", "shaders/glsl/burn.fp", NULL, "#define SIMPLE\n#define NO_ALPHATEST\n" }, + { "stencil", "shaders/glsl/main.vp", "shaders/glsl/stencil.fp", NULL, "#define SIMPLE\n#define NO_ALPHATEST\n" }, }; From 7967082e603cb13fe45f14d40bd2f4485bcf4e1c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 1 Aug 2014 20:59:39 +0200 Subject: [PATCH 0183/1509] - use the light buffer to handle dynamic lighting. --- src/gl/dynlights/gl_dynlight1.cpp | 33 ------- src/gl/dynlights/gl_lightbuffer.cpp | 118 +++++++++++++----------- src/gl/dynlights/gl_lightbuffer.h | 20 ++-- src/gl/renderer/gl_renderer.cpp | 4 + src/gl/renderer/gl_renderer.h | 2 + src/gl/renderer/gl_renderstate.cpp | 26 +++--- src/gl/renderer/gl_renderstate.h | 27 ++---- src/gl/scene/gl_flats.cpp | 21 +---- src/gl/scene/gl_scene.cpp | 2 + src/gl/scene/gl_wall.h | 2 +- src/gl/scene/gl_walls_draw.cpp | 12 +-- src/gl/shaders/gl_shader.cpp | 25 +++-- src/gl/shaders/gl_shader.h | 6 +- src/gl/system/gl_interface.cpp | 5 + src/gl/system/gl_interface.h | 1 + wadsrc/static/shaders/glsl/main.fp | 85 +++++++++-------- wadsrc/static/shaders/glsl/shaderdefs.i | 2 +- 17 files changed, 194 insertions(+), 197 deletions(-) diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index cee31ee42..c504a33c4 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -144,36 +144,3 @@ bool gl_GetLight(Plane & p, ADynamicLight * light, bool checkside, bool forceadd } -//========================================================================== -// -// -// -//========================================================================== - -#if 0 -void gl_UploadLights(FDynLightData &data) -{ - ParameterBufferElement *pptr; - int size0 = data.arrays[0].Size()/4; - int size1 = data.arrays[1].Size()/4; - int size2 = data.arrays[2].Size()/4; - - if (size0 + size1 + size2 > 0) - { - int sizetotal = size0 + size1 + size2 + 1; - int index = GLRenderer->mParmBuffer->Reserve(sizetotal, &pptr); - - float parmcnt[] = { index + 1, index + 1 + size0, index + 1 + size0 + size1, index + 1 + size0 + size1 + size2 }; - - memcpy(&pptr[0], parmcnt, 4 * sizeof(float)); - memcpy(&pptr[1], &data.arrays[0][0], 4 * size0*sizeof(float)); - memcpy(&pptr[1 + size0], &data.arrays[1][0], 4 * size1*sizeof(float)); - memcpy(&pptr[1 + size0 + size1], &data.arrays[2][0], 4 * size2*sizeof(float)); - gl_RenderState.SetDynLightIndex(index); - } - else - { - gl_RenderState.SetDynLightIndex(-1); - } -} -#endif diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index 663631240..b91b0fe55 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -39,93 +39,79 @@ */ #include "gl/system/gl_system.h" +#include "gl/shaders/gl_shader.h" #include "gl/dynlights/gl_lightbuffer.h" #include "gl/dynlights/gl_dynlight.h" #include "gl/system/gl_interface.h" +#include "gl/utility//gl_clock.h" -static const int LIGHTBUF_BINDINGPOINT = 1; +static const int BUFFER_SIZE = 160000; // This means 80000 lights per frame and 160000*16 bytes == 2.56 MB. FLightBuffer::FLightBuffer() { if (gl.flags & RFL_SHADER_STORAGE_BUFFER) { mBufferType = GL_SHADER_STORAGE_BUFFER; - mBufferSize = 80000; // 40000 lights per scene should be plenty. The largest I've ever seen was around 5000. + mBlockAlign = 0; } else { mBufferType = GL_UNIFORM_BUFFER; - mBufferSize = gl.maxuniformblock / 4 - 100; // we need to be a bit careful here so don't use the full buffer size + mBlockSize = 2048;// gl.maxuniformblock / 4 - 100; + mBlockAlign = 1024;// ((mBlockSize * 2) & ~(gl.uniformblockalignment - 1)) / 4; // count in vec4's } - AddBuffer(); + + glGenBuffers(1, &mBufferId); + glBindBuffer(mBufferType, mBufferId); + unsigned int bytesize = BUFFER_SIZE * 4 * sizeof(float); + if (gl.flags & RFL_BUFFER_STORAGE) + { + glBufferStorage(mBufferType, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + void *map = glMapBufferRange(mBufferType, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + mBufferPointer = (float*)map; + glBindBufferBase(mBufferType, LIGHTBUF_BINDINGPOINT, mBufferId); + } + else + { + glBufferData(mBufferType, bytesize, NULL, GL_STREAM_DRAW); + mBufferPointer = NULL; + } + Clear(); + mLastMappedIndex = UINT_MAX; } FLightBuffer::~FLightBuffer() { glBindBuffer(mBufferType, 0); - for (unsigned int i = 0; i < mBufferIds.Size(); i++) - { - glDeleteBuffers(1, &mBufferIds[i]); - } -} - -void FLightBuffer::AddBuffer() -{ - unsigned int id; - glGenBuffers(1, &id); - mBufferIds.Push(id); - glBindBuffer(mBufferType, id); - unsigned int bytesize = mBufferSize * 8 * sizeof(float); - if (gl.flags & RFL_BUFFER_STORAGE) - { - glBufferStorage(mBufferType, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); - void *map = glMapBufferRange(mBufferType, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); - mBufferPointers.Push((float*)map); - } - else - { - glBufferData(mBufferType, bytesize, NULL, GL_STREAM_DRAW); - } + glDeleteBuffers(1, &mBufferId); } void FLightBuffer::Clear() { - mBufferNum = 0; mIndex = 0; mBufferArray.Clear(); - mBufferStart.Clear(); } -void FLightBuffer::UploadLights(FDynLightData &data, unsigned int &buffernum, unsigned int &bufferindex) +int FLightBuffer::UploadLights(FDynLightData &data) { int size0 = data.arrays[0].Size()/4; int size1 = data.arrays[1].Size()/4; int size2 = data.arrays[2].Size()/4; int totalsize = size0 + size1 + size2 + 1; - if (totalsize == 0) return; + if (totalsize <= 1) return -1; - if (mIndex + totalsize > mBufferSize) + if (mIndex + totalsize > BUFFER_SIZE) { - if (gl.flags & RFL_SHADER_STORAGE_BUFFER) - { - return; // we do not want multiple shader storage blocks. 40000 lights is too much already - } - else - { - mBufferNum++; - mBufferStart.Push(mIndex); - mIndex = 0; - if (mBufferIds.Size() <= mBufferNum) AddBuffer(); - } + return -1; // we ran out of space. All following lights will be ignored } float *copyptr; - if (gl.flags & RFL_BUFFER_STORAGE) + if (mBufferPointer != NULL) { - copyptr = mBufferPointers[mBufferNum] + mIndex * 4; + copyptr = mBufferPointer + mIndex * 4; } else { @@ -133,20 +119,48 @@ void FLightBuffer::UploadLights(FDynLightData &data, unsigned int &buffernum, un copyptr = &mBufferArray[pos]; } - float parmcnt[] = { mIndex + 1, mIndex + 1 + size0, mIndex + 1 + size0 + size1, mIndex + totalsize }; + float parmcnt[] = { 0, size0, size0 + size1, size0 + size1 + size2 }; memcpy(©ptr[0], parmcnt, 4 * sizeof(float)); - memcpy(©ptr[1], &data.arrays[0][0], 4 * size0*sizeof(float)); - memcpy(©ptr[1 + size0], &data.arrays[1][0], 4 * size1*sizeof(float)); - memcpy(©ptr[1 + size0 + size1], &data.arrays[2][0], 4 * size2*sizeof(float)); - buffernum = mBufferNum; - bufferindex = mIndex; + memcpy(©ptr[4], &data.arrays[0][0], 4 * size0*sizeof(float)); + memcpy(©ptr[4 + 4*size0], &data.arrays[1][0], 4 * size1*sizeof(float)); + memcpy(©ptr[4 + 4*(size0 + size1)], &data.arrays[2][0], 4 * size2*sizeof(float)); + + if (mBufferPointer == NULL) // if we can't persistently map the buffer we need to upload it after all lights have been added. + { + glBindBuffer(mBufferType, mBufferId); + glBufferSubData(mBufferType, mIndex, totalsize * 4 * sizeof(float), copyptr); + } + + unsigned int bufferindex = mIndex; mIndex += totalsize; + draw_dlight += (totalsize-1) / 2; + return bufferindex; } void FLightBuffer::Finish() { - //glBindBufferBase(mBufferType, LIGHTBUF_BINDINGPOINT, mBufferIds[0]); + /* + if (!(gl.flags & RFL_BUFFER_STORAGE)) // if we can't persistently map the buffer we need to upload it after all lights have been added. + { + glBindBuffer(mBufferType, mBufferId); + glBufferSubData(mBufferType, 0, mBufferArray.Size() * sizeof(float), &mBufferArray[0]); + } + */ + Clear(); +} + +int FLightBuffer::BindUBO(unsigned int index) +{ + unsigned int offset = (index / mBlockAlign) * mBlockAlign; + + if (offset != mLastMappedIndex) + { + // this will only get called if a uniform buffer is used. For a shader storage buffer we only need to bind the buffer once at the start to all shader programs + mLastMappedIndex = offset; + glBindBufferRange(GL_UNIFORM_BUFFER, LIGHTBUF_BINDINGPOINT, mBufferId, offset*16, mBlockSize*16); // we go from counting vec4's to counting bytes here. + } + return (index - offset); } diff --git a/src/gl/dynlights/gl_lightbuffer.h b/src/gl/dynlights/gl_lightbuffer.h index 57e6bf0c8..8e50555c3 100644 --- a/src/gl/dynlights/gl_lightbuffer.h +++ b/src/gl/dynlights/gl_lightbuffer.h @@ -7,23 +7,25 @@ struct FDynLightData; class FLightBuffer { TArray mBufferArray; - TArray mBufferIds; - TArray mBufferStart; - TArray mBufferPointers; - unsigned int mBufferType; - unsigned int mBufferSize; - unsigned int mIndex; - unsigned int mBufferNum; + unsigned int mBufferId; + float * mBufferPointer; - void AddBuffer(); + unsigned int mBufferType; + unsigned int mIndex; + unsigned int mLastMappedIndex; + unsigned int mBlockAlign; + unsigned int mBlockSize; public: FLightBuffer(); ~FLightBuffer(); void Clear(); - void UploadLights(FDynLightData &data, unsigned int &buffernum, unsigned int &bufferindex); + int UploadLights(FDynLightData &data); void Finish(); + int BindUBO(unsigned int index); + unsigned int GetBlockSize() const { return mBlockSize; } + unsigned int GetBufferType() const { return mBufferType; } }; #endif diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 42773496e..ceb553f86 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -67,6 +67,7 @@ #include "gl/utility/gl_clock.h" #include "gl/utility/gl_templates.h" #include "gl/models/gl_models.h" +#include "gl/dynlights/gl_lightbuffer.h" //=========================================================================== // @@ -97,6 +98,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) gl_spriteindex = 0; mShaderManager = NULL; glpart2 = glpart = mirrortexture = NULL; + mLights = NULL; } void FGLRenderer::Initialize() @@ -108,6 +110,7 @@ void FGLRenderer::Initialize() mVBO = new FFlatVertexBuffer; mSkyVBO = new FSkyVertexBuffer; mModelVBO = new FModelVertexBuffer; + mLights = new FLightBuffer; gl_RenderState.SetVertexBuffer(mVBO); mFBID = 0; SetupLevel(); @@ -124,6 +127,7 @@ FGLRenderer::~FGLRenderer() if (mVBO != NULL) delete mVBO; if (mModelVBO) delete mModelVBO; if (mSkyVBO != NULL) delete mSkyVBO; + if (mLights != NULL) delete mLights; if (glpart2) delete glpart2; if (glpart) delete glpart; if (mirrortexture) delete mirrortexture; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index a2679f665..15c8a2e16 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -17,6 +17,7 @@ struct pspdef_t; class FShaderManager; class GLPortal; class FGLThreadManager; +class FLightBuffer; enum SectorRenderFlags { @@ -72,6 +73,7 @@ public: FFlatVertexBuffer *mVBO; FSkyVertexBuffer *mSkyVBO; FModelVertexBuffer *mModelVBO; + FLightBuffer *mLights; FGLRenderer(OpenGLFrameBuffer *fb); diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 24492c495..464880895 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -48,6 +48,7 @@ #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_colormap.h" +#include "gl/dynlights//gl_lightbuffer.h" void gl_SetTextureMode(int type); @@ -68,9 +69,10 @@ TArray gl_MatrixStack; void FRenderState::Reset() { mTextureEnabled = true; - mBrightmapEnabled = mFogEnabled = mGlowEnabled = mLightEnabled = false; + mBrightmapEnabled = mFogEnabled = mGlowEnabled = false; mFogColor.d = -1; mTextureMode = -1; + mLightIndex = -1; mDesaturation = 0; mSrcBlend = GL_SRC_ALPHA; mDstBlend = GL_ONE_MINUS_SRC_ALPHA; @@ -98,7 +100,6 @@ void FRenderState::Reset() bool FRenderState::ApplyShader() { - FShader *activeShader; if (mSpecialEffect > EFF_NONE) { activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect); @@ -139,6 +140,7 @@ bool FRenderState::ApplyShader() activeShader->muClipHeightBottom.Set(mClipHeightBottom); activeShader->muTimer.Set(gl_frameMS * mShaderTimer / 1000.f); activeShader->muAlphaThreshold.Set(mAlphaThreshold); + activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now if (mGlowEnabled) { @@ -159,17 +161,6 @@ bool FRenderState::ApplyShader() activeShader->currentglowstate = 0; } - if (mLightEnabled) - { - activeShader->muLightRange.Set(mNumLights); - glUniform4fv(activeShader->lights_index, mNumLights[3], mLightData); - } - else - { - static const int nulint[] = { 0, 0, 0, 0 }; - activeShader->muLightRange.Set(nulint); - } - if (mColormapState != activeShader->currentfixedcolormap) { float r, g, b; @@ -282,3 +273,12 @@ void FRenderState::ApplyMatrices() GLRenderer->mShaderManager->ApplyMatrices(&mProjectionMatrix, &mViewMatrix); } } + +void FRenderState::ApplyLightIndex(int index) +{ + if (GLRenderer->mLights->GetBufferType() == GL_UNIFORM_BUFFER && index > -1) + { + index = GLRenderer->mLights->BindUBO(index); + } + activeShader->muLightIndex.Set(index); +} \ No newline at end of file diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 562cfb0ef..0e290adb3 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -9,6 +9,7 @@ #include "r_defs.h" class FVertexBuffer; +class FShader; extern TArray gl_MatrixStack; EXTERN_CVAR(Bool, gl_direct_state_change) @@ -43,24 +44,22 @@ class FRenderState bool mTextureEnabled; bool mFogEnabled; bool mGlowEnabled; - bool mLightEnabled; bool mBrightmapEnabled; + int mLightIndex; int mSpecialEffect; int mTextureMode; int mDesaturation; int mSoftLight; float mLightParms[4]; - int mNumLights[4]; - float *mLightData; int mSrcBlend, mDstBlend; float mAlphaThreshold; - bool mAlphaTest; int mBlendEquation; + bool mAlphaTest; bool m2D; - float mInterpolationFactor; - float mClipHeightTop, mClipHeightBottom; bool mModelMatrixEnabled; bool mTextureMatrixEnabled; + float mInterpolationFactor; + float mClipHeightTop, mClipHeightBottom; float mShaderTimer; FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; @@ -80,6 +79,8 @@ class FRenderState bool stAlphaTest; int stBlendEquation; + FShader *activeShader; + bool ApplyShader(); public: @@ -104,6 +105,7 @@ public: void Apply(); void ApplyMatrices(); + void ApplyLightIndex(int index); void SetVertexBuffer(FVertexBuffer *vb) { @@ -185,9 +187,9 @@ public: mGlowEnabled = on; } - void EnableLight(bool on) + void SetLightIndex(int n) { - mLightEnabled = on; + mLightIndex = n; } void EnableBrightmap(bool on) @@ -251,15 +253,6 @@ public: mLightParms[0] = d; } - void SetLights(int *numlights, float *lightdata) - { - mNumLights[0] = 0; - mNumLights[1] = numlights[0]; - mNumLights[2] = numlights[1]; - mNumLights[3] = numlights[2]; - mLightData = lightdata; // caution: the data must be preserved by the caller until the 'apply' call! - } - void SetFixedColormap(int cm) { mColormapState = cm; diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 60b1237d5..9e4a8ec6d 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -56,6 +56,7 @@ #include "gl/data/gl_vertexbuffer.h" #include "gl/dynlights/gl_dynlight.h" #include "gl/dynlights/gl_glow.h" +#include "gl/dynlights/gl_lightbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/shaders/gl_shader.h" #include "gl/textures/gl_material.h" @@ -142,22 +143,8 @@ bool GLFlat::SetupSubsectorLights(bool lightsapplied, subsector_t * sub) node = node->nextLight; } - int numlights[3]; - - lightdata.Combine(numlights, gl.MaxLights()); - if (numlights[2] > 0) - { - draw_dlightf+=numlights[2]/2; - gl_RenderState.EnableLight(true); - gl_RenderState.SetLights(numlights, &lightdata.arrays[0][0]); - gl_RenderState.Apply(); - return true; - } - if (lightsapplied) - { - gl_RenderState.EnableLight(false); - gl_RenderState.Apply(); - } + dynlightindex = GLRenderer->mLights->UploadLights(lightdata); + gl_RenderState.ApplyLightIndex(dynlightindex); return false; } @@ -271,7 +258,6 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) } } } - gl_RenderState.EnableLight(false); } @@ -450,6 +436,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) sector=§ors[frontsector->sectornum]; extsector_t::xfloor &x = sector->e->XFloor; this->sub=NULL; + dynlightindex = -1; byte &srf = gl_drawinfo->sectorrenderflags[sector->sectornum]; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 0a73a06f6..e301b3da6 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -57,6 +57,7 @@ #include "p_local.h" #include "gl/gl_functions.h" +#include "gl/dynlights/gl_lightbuffer.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_cvars.h" @@ -348,6 +349,7 @@ void FGLRenderer::RenderScene(int recursion) gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); glDisable(GL_POLYGON_OFFSET_FILL); // just in case + GLRenderer->mLights->Finish(); int pass; diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index e17f61c3e..36d4d2fc3 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -135,7 +135,7 @@ public: float topglowcolor[4]; float bottomglowcolor[4]; - unsigned int dynlightindex, dynlightbuffer; + int dynlightindex; int firstwall, numwalls; // splitting info. union diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index b9965972c..98bc9f661 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -53,6 +53,7 @@ #include "gl/data/gl_vertexbuffer.h" #include "gl/dynlights/gl_dynlight.h" #include "gl/dynlights/gl_glow.h" +#include "gl/dynlights/gl_lightbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" #include "gl/shaders/gl_shader.h" @@ -150,15 +151,8 @@ void GLWall::SetupLights() } node = node->nextLight; } - int numlights[3]; - lightdata.Combine(numlights, gl.MaxLights()); - if (numlights[2] > 0) - { - draw_dlight+=numlights[2]/2; - gl_RenderState.EnableLight(true); - gl_RenderState.SetLights(numlights, &lightdata.arrays[0][0]); - } + dynlightindex = GLRenderer->mLights->UploadLights(lightdata); } @@ -187,6 +181,7 @@ void GLWall::RenderWall(int textured, unsigned int *store) if (!(textured & RWF_NORENDER)) { gl_RenderState.Apply(); + gl_RenderState.ApplyLightIndex(dynlightindex); } // the rest of the code is identical for textured rendering and lights @@ -383,7 +378,6 @@ void GLWall::Draw(int pass) gltexture->Bind(flags, 0); RenderWall(RWF_TEXTURED|RWF_GLOW); gl_RenderState.EnableGlow(false); - gl_RenderState.EnableLight(false); break; case GLPASS_DECALS: diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 1ddb58076..00683dd20 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -57,6 +57,7 @@ #include "gl/system/gl_cvars.h" #include "gl/shaders/gl_shader.h" #include "gl/textures/gl_material.h" +#include "gl/dynlights/gl_lightbuffer.h" //========================================================================== // @@ -86,10 +87,19 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * // // The following code uses GetChars on the strings to get rid of terminating 0 characters. Do not remove or the code may break! // + unsigned int lightbuffertype = GLRenderer->mLights->GetBufferType(); + unsigned int lightbuffersize = GLRenderer->mLights->GetBlockSize(); - FString vp_comb = "#version 130\n"; - // todo when using shader storage buffers, add - // "#version 400 compatibility\n#extension GL_ARB_shader_storage_buffer_object : require\n" instead. + FString vp_comb; + + if (lightbuffertype == GL_UNIFORM_BUFFER) + { + vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); + } + else + { + vp_comb = "#version 400 compatibility\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n"; + } if (!(gl.flags & RFL_BUFFER_STORAGE)) { @@ -196,7 +206,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muLightParms.Init(hShader, "uLightAttr"); muColormapStart.Init(hShader, "uFixedColormapStart"); muColormapRange.Init(hShader, "uFixedColormapRange"); - muLightRange.Init(hShader, "uLightRange"); + muLightIndex.Init(hShader, "uLightIndex"); muFogColor.Init(hShader, "uFogColor"); muDynLightColor.Init(hShader, "uDynLightColor"); muObjectColor.Init(hShader, "uObjectColor"); @@ -218,10 +228,13 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * modelmatrix_index = glGetUniformLocation(hShader, "ModelMatrix"); texturematrix_index = glGetUniformLocation(hShader, "TextureMatrix"); + int tempindex = glGetUniformBlockIndex(hShader, "LightBufferUBO"); + if (tempindex != -1) glUniformBlockBinding(hShader, tempindex, LIGHTBUF_BINDINGPOINT); + glUseProgram(hShader); - int texture_index = glGetUniformLocation(hShader, "texture2"); - if (texture_index > 0) glUniform1i(texture_index, 1); + tempindex = glGetUniformLocation(hShader, "texture2"); + if (tempindex > 0) glUniform1i(tempindex, 1); glUseProgram(0); return !!linked; diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index c825996ee..e100e9bf1 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -187,7 +187,7 @@ class FShader FUniform1i muFixedColormap; FUniform4f muColormapStart; FUniform4f muColormapRange; - FBufferedUniform4i muLightRange; + FBufferedUniform1i muLightIndex; FBufferedUniformPE muFogColor; FBufferedUniform4f muDynLightColor; FBufferedUniformPE muObjectColor; @@ -281,6 +281,10 @@ public: #define FIRST_USER_SHADER 12 +enum +{ + LIGHTBUF_BINDINGPOINT = 1 +}; #endif diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 404c068d7..ee30084f0 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -133,6 +133,7 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; + if (CheckExtension("GL_ARB_shader_storage_buffer_object")) gl.flags |= RFL_SHADER_STORAGE_BUFFER; if (CheckExtension("GL_ARB_buffer_storage") && !Args->CheckParm("-nopersistentbuffers")) { gl.flags |= RFL_BUFFER_STORAGE; // the cmdline option is for testing the fallback implementation on newer hardware. @@ -178,6 +179,10 @@ void gl_PrintStartupLog() glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); Printf ("Max. uniform block size: %d\n", v); gl.maxuniformblock = v; + glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v); + Printf ("Uniform block alignment: %d\n", v); + gl.uniformblockalignment = v; + glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); Printf ("Max. varying: %d\n", v); glGetIntegerv(GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS, &v); diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index a88133929..9a5c18ac4 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -30,6 +30,7 @@ struct RenderContext unsigned int flags; unsigned int maxuniforms; unsigned int maxuniformblock; + unsigned int uniformblockalignment; float version; float glslversion; int max_texturesize; diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 482afc0ca..532529f0b 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -7,14 +7,15 @@ in vec4 vColor; out vec4 FragColor; #ifdef SHADER_STORAGE_LIGHTS - layout(std430, binding = 3) buffer ParameterBuffer + layout(std430, binding = 1) buffer LightBufferSSO { vec4 lights[]; }; -#elif defined MAXLIGHTS128 - uniform vec4 lights[256]; #else - uniform vec4 lights[128]; + layout(std140) uniform LightBufferUBO + { + vec4 lights[NUM_UBO_LIGHTS]; + }; #endif @@ -169,29 +170,33 @@ vec4 getLightColor(float fogdist, float fogfactor) vec4 dynlight = uDynLightColor; - if (uLightRange.z > uLightRange.x) + if (uLightIndex >= 0) { - // - // modulated lights - // - for(int i=uLightRange.x; i lightRange.x) { - vec4 lightpos = lights[i]; - vec4 lightcolor = lights[i+1]; - - lightcolor.rgb *= max(lightpos.w - distance(pixelpos.xyz, lightpos.xyz),0.0) / lightpos.w; - dynlight.rgb += lightcolor.rgb; - } - // - // subtractive lights - // - for(int i=uLightRange.y; i uLightRange.z) + if (uLightIndex >= 0) { - vec4 addlight = vec4(0.0,0.0,0.0,0.0); - - // - // additive lights - these can be done after the alpha test. - // - for(int i=uLightRange.z; i lightRange.z) { - vec4 lightpos = lights[i]; - vec4 lightcolor = lights[i+1]; - - lightcolor.rgb *= max(lightpos.w - distance(pixelpos.xyz, lightpos.xyz),0.0) / lightpos.w; - addlight.rgb += lightcolor.rgb; + vec4 addlight = vec4(0.0,0.0,0.0,0.0); + + // + // additive lights - these can be done after the alpha test. + // + for(int i=lightRange.z; i Date: Fri, 1 Aug 2014 22:42:39 +0200 Subject: [PATCH 0184/1509] - decided to restrict the 2.0 beta to OpenGL 4.x with GL_ARB_buffer_storage extension and removed all code for supporting older versions. Sadly, anything else makes no sense. All the recently made changes live or die, depending on this extension's presence. Without it, there are major performance issues with the buffer uploads. All of the traditional buffer upload methods are without exception horrendously slow, especially in the context of a Doom engine where frequent small updates are required. It could be solved with a complete restructuring of the engine, of course, but that's hardly worth the effort, considering it's only for legacy hardware whose market share will inevitably shrink considerably over the next years. And even then, under the best circumstances I'd still get the same performance as the old immediate mode renderer in GZDoom 1.x and still couldn't implement the additions I'd like to make. So, since I need to keep GZDoom 1.x around anyway for older GL 2.x hardware, it may as well serve for 3.x hardware, too. It's certainly less work than constantly trying to find workarounds for the older hardware's limitations that cost more time than working on future-proofing the engine. This new, trimmed down 4.x renderer runs on a core profile configuration and uses persistently mapped buffers for nearly everything that is getting transferred to the GPU. (The global uniforms are still being used as such but they'll be phased out after the first beta release. --- src/gl/data/gl_vertexbuffer.cpp | 169 +++------------------------- src/gl/data/gl_vertexbuffer.h | 9 +- src/gl/dynlights/gl_lightbuffer.cpp | 39 +------ src/gl/shaders/gl_shader.cpp | 12 +- src/gl/system/gl_interface.cpp | 15 +-- src/gl/system/gl_interface.h | 3 - src/gl/textures/gl_bitmap.cpp | 56 +++------ src/gl/textures/gl_hwtexture.cpp | 14 +-- src/win32/win32gliface.cpp | 14 +-- wadsrc/static/menudef.z | 9 -- wadsrc/static/shaders/glsl/main.vp | 30 +---- 11 files changed, 46 insertions(+), 324 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index f68883edf..854750ecb 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -90,27 +90,11 @@ void FVertexBuffer::BindVBO() FFlatVertexBuffer::FFlatVertexBuffer() : FVertexBuffer() { - if (gl.flags & RFL_BUFFER_STORAGE) - { - unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); - map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); - mNumReserved = mIndex = mCurIndex = 0; - } - else - { - vbo_shadowdata.Reserve(BUFFER_SIZE); - map = &vbo_shadowdata[0]; - - for (int i = 0; i < 20; i++) - { - map[i].Set(0, 0, 0, 100001.f, i); - } - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBufferData(GL_ARRAY_BUFFER, BUFFER_SIZE * sizeof(FFlatVertex), map, GL_STREAM_DRAW); - mNumReserved = mIndex = mCurIndex = 20; - } + unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + mNumReserved = mIndex = mCurIndex = 0; glBindVertexArray(vao_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); @@ -128,101 +112,6 @@ FFlatVertexBuffer::~FFlatVertexBuffer() glBindBuffer(GL_ARRAY_BUFFER, 0); } -//========================================================================== -// -// Renders the buffer's contents with immediate mode functions -// This is here so that the immediate mode fallback does not need -// to double all rendering code and can instead reuse the buffer-based version -// -//========================================================================== - -CUSTOM_CVAR(Int, gl_rendermethod, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ - int newself = self; - if (newself < 0) newself = 0; - if (newself == 0 && (gl.flags & RFL_COREPROFILE)) newself = 1; - if (newself > 3) newself = 3; -} - -void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count) -{ - // this will only get called if we can't acquire a persistently mapped buffer. - // Any of the provided methods are rather shitty, with immediate mode being the most reliable across different hardware. - // Still, allow this to be set per CVAR, just in case. Fortunately for newer hardware all this nonsense is not needed anymore. - switch (gl_rendermethod) - { - case 0: - // trusty old immediate mode -#ifndef CORE_PROFILE - if (!(gl.flags & RFL_COREPROFILE)) - { - glBegin(primtype); - for (unsigned int i = 0; i < count; i++) - { - glVertexAttrib2fv(VATTR_TEXCOORD, &map[offset + i].u); - glVertexAttrib3fv(VATTR_VERTEX, &map[offset + i].x); - } - glEnd(); - break; - } -#endif - case 1: - // uniform array - if (count > 20) - { - int start = offset; - FFlatVertex ff = map[offset]; - while (count > 20) - { - - if (primtype == GL_TRIANGLE_FAN) - { - // split up the fan into multiple sub-fans - map[offset] = map[start]; - glUniform1fv(GLRenderer->mShaderManager->GetActiveShader()->fakevb_index, 20 * 5, &map[offset].x); - glDrawArrays(primtype, 0, 20); - offset += 18; - count -= 18; - } - else - { - // we only have triangle fans of this size so don't bother with strips and triangles here. - break; - } - } - map[offset] = map[start]; - glUniform1fv(GLRenderer->mShaderManager->GetActiveShader()->fakevb_index, count * 5, &map[offset].x); - glDrawArrays(primtype, 0, count); - map[offset] = ff; - } - else - { - glUniform1fv(GLRenderer->mShaderManager->GetActiveShader()->fakevb_index, count * 5, &map[offset].x); - glDrawArrays(primtype, 0, count); - } - break; - - case 2: - // glBufferSubData - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBufferSubData(GL_ARRAY_BUFFER, offset * sizeof(FFlatVertex), count * sizeof(FFlatVertex), &vbo_shadowdata[offset]); - glDrawArrays(primtype, offset, count); - break; - - case 3: - // glMapBufferRange - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - void *p = glMapBufferRange(GL_ARRAY_BUFFER, offset * sizeof(FFlatVertex), count * sizeof(FFlatVertex), GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT); - if (p != NULL) - { - memcpy(p, &vbo_shadowdata[offset], count * sizeof(FFlatVertex)); - glUnmapBuffer(GL_ARRAY_BUFFER); - glDrawArrays(primtype, offset, count); - } - break; - } -} - //========================================================================== // // Initialize a single vertex @@ -390,11 +279,6 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) if (plane == sector_t::floor && sec->transdoor) vt->z -= 1; mapvt->z = vt->z; } - if (!(gl.flags & RFL_BUFFER_STORAGE)) - { - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBufferSubData(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex), &vbo_shadowdata[startvt]); - } } //========================================================================== @@ -405,32 +289,10 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) void FFlatVertexBuffer::CreateVBO() { - if (!(gl.flags & RFL_NOBUFFER)) - { - vbo_shadowdata.Resize(mNumReserved); - CreateFlatVBO(); - mCurIndex = mIndex = vbo_shadowdata.Size(); - if (gl.flags & RFL_BUFFER_STORAGE) - { - memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); - } - else - { - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBufferSubData(GL_ARRAY_BUFFER, mNumReserved * sizeof(FFlatVertex), (mIndex - mNumReserved) * sizeof(FFlatVertex), &vbo_shadowdata[mNumReserved]); - } - } - else if (sectors) - { - // set all VBO info to invalid values so that we can save some checks in the rendering code - for(int i=0;iGetHeightSec(); - if (hs != NULL) CheckPlanes(hs); - for(unsigned i = 0; i < sector->e->XFloor.ffloors.Size(); i++) - CheckPlanes(sector->e->XFloor.ffloors[i]->model); - } + CheckPlanes(sector); + sector_t *hs = sector->GetHeightSec(); + if (hs != NULL) CheckPlanes(hs); + for(unsigned i = 0; i < sector->e->XFloor.ffloors.Size(); i++) + CheckPlanes(sector->e->XFloor.ffloors[i]->model); } \ No newline at end of file diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index b6d61f2da..de61fb7cb 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -83,14 +83,7 @@ public: void RenderArray(unsigned int primtype, unsigned int offset, unsigned int count) { drawcalls.Clock(); - if (gl.flags & RFL_BUFFER_STORAGE) - { - glDrawArrays(primtype, offset, count); - } - else - { - ImmRenderBuffer(primtype, offset, count); - } + glDrawArrays(primtype, offset, count); drawcalls.Unclock(); } diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index b91b0fe55..c507b1657 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -64,18 +64,10 @@ FLightBuffer::FLightBuffer() glGenBuffers(1, &mBufferId); glBindBuffer(mBufferType, mBufferId); unsigned int bytesize = BUFFER_SIZE * 4 * sizeof(float); - if (gl.flags & RFL_BUFFER_STORAGE) - { - glBufferStorage(mBufferType, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); - void *map = glMapBufferRange(mBufferType, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); - mBufferPointer = (float*)map; - glBindBufferBase(mBufferType, LIGHTBUF_BINDINGPOINT, mBufferId); - } - else - { - glBufferData(mBufferType, bytesize, NULL, GL_STREAM_DRAW); - mBufferPointer = NULL; - } + glBufferStorage(mBufferType, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + void *map = glMapBufferRange(mBufferType, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + mBufferPointer = (float*)map; + glBindBufferBase(mBufferType, LIGHTBUF_BINDINGPOINT, mBufferId); Clear(); mLastMappedIndex = UINT_MAX; @@ -109,15 +101,7 @@ int FLightBuffer::UploadLights(FDynLightData &data) float *copyptr; - if (mBufferPointer != NULL) - { - copyptr = mBufferPointer + mIndex * 4; - } - else - { - unsigned int pos = mBufferArray.Reserve(totalsize * 4); - copyptr = &mBufferArray[pos]; - } + copyptr = mBufferPointer + mIndex * 4; float parmcnt[] = { 0, size0, size0 + size1, size0 + size1 + size2 }; @@ -126,12 +110,6 @@ int FLightBuffer::UploadLights(FDynLightData &data) memcpy(©ptr[4 + 4*size0], &data.arrays[1][0], 4 * size1*sizeof(float)); memcpy(©ptr[4 + 4*(size0 + size1)], &data.arrays[2][0], 4 * size2*sizeof(float)); - if (mBufferPointer == NULL) // if we can't persistently map the buffer we need to upload it after all lights have been added. - { - glBindBuffer(mBufferType, mBufferId); - glBufferSubData(mBufferType, mIndex, totalsize * 4 * sizeof(float), copyptr); - } - unsigned int bufferindex = mIndex; mIndex += totalsize; draw_dlight += (totalsize-1) / 2; @@ -140,13 +118,6 @@ int FLightBuffer::UploadLights(FDynLightData &data) void FLightBuffer::Finish() { - /* - if (!(gl.flags & RFL_BUFFER_STORAGE)) // if we can't persistently map the buffer we need to upload it after all lights have been added. - { - glBindBuffer(mBufferType, mBufferId); - glBufferSubData(mBufferType, 0, mBufferArray.Size() * sizeof(float), &mBufferArray[0]); - } - */ Clear(); } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 00683dd20..a1a22e770 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -94,17 +94,11 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * if (lightbuffertype == GL_UNIFORM_BUFFER) { - vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); + vp_comb.Format("#version 330 core\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); } else { - vp_comb = "#version 400 compatibility\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n"; - } - - if (!(gl.flags & RFL_BUFFER_STORAGE)) - { - // we only want the uniform array hack in the shader if we actually need it. - vp_comb << "#define UNIFORM_VB\n"; + vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n"; } vp_comb << defines << i_data.GetString().GetChars(); @@ -306,7 +300,7 @@ FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath void FShader::ApplyMatrices(VSMatrix *proj, VSMatrix *view) { - if (gl.flags & RFL_SEPARATE_SHADER_OBJECTS) + if (gl.flags & RFL_SEPARATE_SHADER_OBJECTS) // this check is just for safety. All supported hardware reports this extension as being present. { glProgramUniformMatrix4fv(hShader, projectionmatrix_index, 1, false, proj->get()); glProgramUniformMatrix4fv(hShader, viewmatrix_index, 1, false, view->get()); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index ee30084f0..2f9425fe9 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -52,8 +52,6 @@ RenderContext gl; int occlusion_type=0; -CVAR(Bool, gl_persistent_avail, false, CVAR_NOSET); - //========================================================================== // // @@ -118,11 +116,10 @@ void gl_LoadExtensions() if (version == NULL) version = (const char*)glGetString(GL_VERSION); else Printf("Emulating OpenGL v %s\n", version); - // Don't even start if it's lower than 3.0 - if (strcmp(version, "3.0") < 0) + if (strcmp(version, "3.3") < 0 || !CheckExtension("GL_ARB_buffer_storage")) { - I_FatalError("Unsupported OpenGL version.\nAt least GL 3.0 is required to run " GAMENAME ".\n"); + I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 3.3 and the »GL_ARB_buffer_storage« extension is required to run " GAMENAME ".\n"); } // add 0.01 to account for roundoff errors making the number a tad smaller than the actual version @@ -134,16 +131,8 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; if (CheckExtension("GL_ARB_shader_storage_buffer_object")) gl.flags |= RFL_SHADER_STORAGE_BUFFER; - if (CheckExtension("GL_ARB_buffer_storage") && !Args->CheckParm("-nopersistentbuffers")) - { - gl.flags |= RFL_BUFFER_STORAGE; // the cmdline option is for testing the fallback implementation on newer hardware. - gl_persistent_avail = true; - } if (CheckExtension("GL_ARB_separate_shader_objects")) gl.flags |= RFL_SEPARATE_SHADER_OBJECTS; - if (!CheckExtension("GL_ARB_compatibility")) gl.flags |= RFL_COREPROFILE; - if (!(gl.flags & (RFL_COREPROFILE|RFL_BUFFER_STORAGE)) && !strstr(gl.vendorstring, "NVIDIA Corporation")) gl.flags |= RFL_NOBUFFER; - glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 9a5c18ac4..fbafc7ca6 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -10,11 +10,8 @@ enum RenderFlags RFL_TEXTURE_COMPRESSION_S3TC=2, RFL_SEPARATE_SHADER_OBJECTS = 4, // we need this extension for glProgramUniform. On hardware not supporting it we need some rather clumsy workarounds - RFL_BUFFER_STORAGE = 8, // allows persistently mapped buffers, which are the only efficient way to actually use a dynamic vertex buffer. If this isn't present, a workaround with uniform arrays is used. RFL_SHADER_STORAGE_BUFFER = 16, // to be used later for a parameter buffer RFL_BASEINDEX = 32, // currently unused - RFL_COREPROFILE = 64, - RFL_NOBUFFER = 128, // the static buffer makes no sense on GL 3.x AMD and Intel hardware, as long as compatibility mode is on }; enum TexMode diff --git a/src/gl/textures/gl_bitmap.cpp b/src/gl/textures/gl_bitmap.cpp index c37e7a90e..0c74c9ae7 100644 --- a/src/gl/textures/gl_bitmap.cpp +++ b/src/gl/textures/gl_bitmap.cpp @@ -55,34 +55,17 @@ void iCopyColors(unsigned char * pout, const unsigned char * pin, bool alphatex, { int i; - if (!alphatex || gl.version >= 3.3f) // GL 3.3+ uses a GL_R8 texture for alpha textures so the channels can remain as they are. + for(i=0;i 0) diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 98229a1ca..697bcda4d 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -191,17 +191,7 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i if (alphatexture) { - // thanks to deprecation and delayed introduction of a suitable replacement feature this has become a bit messy... - // Of all the targeted hardware, the Intel GMA 2000 and 3000 are the only ones not supporting texture swizzle, and they - // are also the only ones not supoorting GL 3.3. On those we are forced to use a full RGBA texture here. - if (gl.version >= 3.3f) - { - texformat = GL_R8; - } - else - { - texformat = GL_RGBA8; - } + texformat = GL_R8; } else if (forcenocompression) { @@ -246,7 +236,7 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i if (deletebuffer) free(buffer); if (mipmap && use_mipmapping && !forcenofiltering) glGenerateMipmap(GL_TEXTURE_2D); - if (alphatexture && gl.version >= 3.3f) + if (alphatexture) { static const GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_RED}; glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index a0e55d673..ab6d15254 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -740,14 +740,9 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) m_hRC = NULL; if (myWglCreateContextAttribsARB != NULL) { -#ifndef CORE_PROFILE - bool core = !!Args->CheckParm("-core"); -#else - bool core = true; -#endif // let's try to get the best version possible. Some drivers only give us the version we request // which breaks all version checks for feature support. The highest used features we use are from version 4.4, and 3.0 is a requirement. - static int versions[] = { 44, 43, 42, 41, 40, 33, 32, 30, -1 }; + static int versions[] = { 44, 43, 42, 41, 40, 33, -1 }; for (int i = 0; versions[i] > 0; i++) { @@ -755,7 +750,7 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) WGL_CONTEXT_MAJOR_VERSION_ARB, versions[i] / 10, WGL_CONTEXT_MINOR_VERSION_ARB, versions[i] % 10, WGL_CONTEXT_FLAGS_ARB, gl_debug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0, - WGL_CONTEXT_PROFILE_MASK_ARB, core? WGL_CONTEXT_CORE_PROFILE_BIT_ARB : WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, 0 }; @@ -763,11 +758,6 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) if (m_hRC != NULL) break; } } - if (m_hRC == 0) - { - // If we are unable to get a core context, let's try whatever the system gives us. - m_hRC = wglCreateContext(m_hDC); - } if (m_hRC == NULL) { diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index e448e42d9..cdfce4145 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -124,14 +124,6 @@ OptionValue "FuzzStyle" //5, "Jagged fuzz" I can't see any difference between this and 4 so it's disabled for now. } -OptionValue "RenderMethods" -{ - 0, "Immediate mode" - 1, "Uniform array" - 2, "Buffer upload" - 3, "Mapped buffer" -} - OptionMenu "GLTextureGLOptions" { Title "TEXTURE OPTIONS" @@ -180,7 +172,6 @@ OptionMenu "GLPrefOptions" Option "Particle style", gl_particles_style, "Particles" Slider "Ambient light level", gl_light_ambient, 1.0, 255.0, 5.0 Option "Rendering quality", gl_render_precise, "Precision" - Option "Render method", gl_rendermethod, "RenderMethods", "gl_persistent_avail" } OptionMenu "OpenGLOptions" diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index e355141f0..16c3c8738 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -11,34 +11,12 @@ out vec2 glowdist; out vec4 vTexCoord; out vec4 vColor; -#ifdef UNIFORM_VB -uniform float fakeVB[100]; -#endif - void main() { - vec4 vert; - vec4 tc; - -#ifdef UNIFORM_VB - - if (aTexCoord.x >= 100000.0) - { - int fakeVI = int(aTexCoord.y)*5; - vert = aPosition + vec4(fakeVB[fakeVI], fakeVB[fakeVI+1], fakeVB[fakeVI+2], 0.0); - tc = vec4(fakeVB[fakeVI+3], fakeVB[fakeVI+4], 0.0, 0.0); - } - else -#endif - { - vert = aPosition; - tc = vec4(aTexCoord, 0.0, 0.0); - } - #ifndef SIMPLE - vec4 worldcoord = ModelMatrix * mix(vert, aVertex2, uInterpolationFactor); + vec4 worldcoord = ModelMatrix * mix(aPosition, aVertex2, uInterpolationFactor); #else - vec4 worldcoord = ModelMatrix * vert; + vec4 worldcoord = ModelMatrix * aPosition; #endif vec4 eyeCoordPos = ViewMatrix * worldcoord; @@ -55,13 +33,13 @@ void main() #ifdef SPHEREMAP vec3 u = normalize(eyeCoordPos.xyz); - vec4 n = normalize(TextureMatrix * vec4(tc.x, 0.0, tc.y, 0.0)); // use texture matrix and coordinates for our normal. Since this is only used on walls, the normal's y coordinate is always 0. + vec4 n = normalize(TextureMatrix * vec4(aTexCoord.x, 0.0, aTexCoord.y, 0.0)); // use texture matrix and coordinates for our normal. Since this is only used on walls, the normal's y coordinate is always 0. vec3 r = reflect(u, n.xyz); float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) ); vec2 sst = vec2(r.x/m + 0.5, r.y/m + 0.5); vTexCoord.xy = sst; #else - vTexCoord = TextureMatrix * tc; + vTexCoord = TextureMatrix * vec4(aTexCoord, 0.0, 0.0); #endif gl_Position = ProjectionMatrix * eyeCoordPos; From b2860a1d63170ed4ff4e1db651764dbd64af6b1e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 2 Aug 2014 11:57:42 +0200 Subject: [PATCH 0185/1509] - it looks like glProgramUniform is not working correctly with Intel drivers, so better forget about it for setting the view and projection matrices. Even on NVidia the time difference can only be measured in microseconds per frame so it's not a big loss. --- src/gl/shaders/gl_shader.cpp | 15 +++------------ src/gl/system/gl_interface.cpp | 1 - src/gl/system/gl_interface.h | 4 +--- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index a1a22e770..480d97d25 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -299,18 +299,9 @@ FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath void FShader::ApplyMatrices(VSMatrix *proj, VSMatrix *view) { - - if (gl.flags & RFL_SEPARATE_SHADER_OBJECTS) // this check is just for safety. All supported hardware reports this extension as being present. - { - glProgramUniformMatrix4fv(hShader, projectionmatrix_index, 1, false, proj->get()); - glProgramUniformMatrix4fv(hShader, viewmatrix_index, 1, false, view->get()); - } - else - { - Bind(); - glUniformMatrix4fv(projectionmatrix_index, 1, false, proj->get()); - glUniformMatrix4fv(viewmatrix_index, 1, false, view->get()); - } + Bind(); + glUniformMatrix4fv(projectionmatrix_index, 1, false, proj->get()); + glUniformMatrix4fv(viewmatrix_index, 1, false, view->get()); } diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 2f9425fe9..4da1d9a42 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -131,7 +131,6 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; if (CheckExtension("GL_ARB_shader_storage_buffer_object")) gl.flags |= RFL_SHADER_STORAGE_BUFFER; - if (CheckExtension("GL_ARB_separate_shader_objects")) gl.flags |= RFL_SEPARATE_SHADER_OBJECTS; glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index fbafc7ca6..5d59e5560 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -9,9 +9,7 @@ enum RenderFlags RFL_TEXTURE_COMPRESSION=1, RFL_TEXTURE_COMPRESSION_S3TC=2, - RFL_SEPARATE_SHADER_OBJECTS = 4, // we need this extension for glProgramUniform. On hardware not supporting it we need some rather clumsy workarounds - RFL_SHADER_STORAGE_BUFFER = 16, // to be used later for a parameter buffer - RFL_BASEINDEX = 32, // currently unused + RFL_SHADER_STORAGE_BUFFER = 4, // to be used later for a parameter buffer }; enum TexMode From e35fefdc06b9a185899df9f3d3bcdaedfb0d2895 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 2 Aug 2014 11:59:04 +0200 Subject: [PATCH 0186/1509] - better rebind the active shader after updating the matrices. --- src/gl/shaders/gl_shader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 480d97d25..7cd6ead74 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -520,6 +520,7 @@ void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view) { mEffectShaders[i]->ApplyMatrices(proj, view); } + if (mActiveShader != NULL) mActiveShader->Bind(); } //========================================================================== From a97b58fa27e648afff6f6097896957ba6db0f4d9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 2 Aug 2014 20:41:13 +0200 Subject: [PATCH 0187/1509] - added check for light uniform buffer overflows, because uniform buffers on Intel are rather small. --- src/gl/dynlights/gl_lightbuffer.cpp | 32 ++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index c507b1657..b787be9e2 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -52,13 +52,15 @@ FLightBuffer::FLightBuffer() if (gl.flags & RFL_SHADER_STORAGE_BUFFER) { mBufferType = GL_SHADER_STORAGE_BUFFER; - mBlockAlign = 0; + mBlockAlign = -1; + mBlockSize = BUFFER_SIZE; } else { mBufferType = GL_UNIFORM_BUFFER; - mBlockSize = 2048;// gl.maxuniformblock / 4 - 100; - mBlockAlign = 1024;// ((mBlockSize * 2) & ~(gl.uniformblockalignment - 1)) / 4; // count in vec4's + mBlockSize = gl.maxuniformblock / 16; + if (mBlockSize > 2048) mBlockSize = 2048; // we don't really need a larger buffer + mBlockAlign = mBlockSize / 2; } glGenBuffers(1, &mBufferId); @@ -92,6 +94,30 @@ int FLightBuffer::UploadLights(FDynLightData &data) int size2 = data.arrays[2].Size()/4; int totalsize = size0 + size1 + size2 + 1; + if (mBlockAlign >= 0 && totalsize + (mIndex % mBlockAlign) > mBlockSize) + { + mIndex = ((mIndex + mBlockAlign) / mBlockAlign) * mBlockAlign; + + // can't be rendered all at once. + if (totalsize > mBlockSize) + { + int diff = totalsize - mBlockSize; + + size2 -= diff; + if (size2 < 0) + { + size1 += size2; + size2 = 0; + } + if (size1 < 0) + { + size0 += size1; + size1 = 0; + } + totalsize = size0 + size1 + size2 + 1; + } + } + if (totalsize <= 1) return -1; if (mIndex + totalsize > BUFFER_SIZE) From a63871d1709beedb4a8ec34a2f81733e491bdb3d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 2 Aug 2014 21:06:34 +0200 Subject: [PATCH 0188/1509] - at least for Intel GMA we need shaders without 'discard' to render non-transparent stuff. The performance penalty is rather hefty here. --- src/gl/renderer/gl_renderstate.cpp | 3 +-- src/gl/shaders/gl_shader.cpp | 16 +++++++++++++++- src/gl/shaders/gl_shader.h | 7 ++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 464880895..bdd0867b9 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -106,8 +106,7 @@ bool FRenderState::ApplyShader() } else { - // todo: check how performance is affected by using 'discard' in a shader and if necessary create a separate set of discard-less shaders. - activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4); + activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4, mAlphaThreshold >= 0.f); activeShader->Bind(); } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 7cd6ead74..26a1b3159 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -387,6 +387,8 @@ void FShaderManager::CompileShaders() { mActiveShader = NULL; + mTextureEffects.Clear(); + mTextureEffectsNAT.Clear(); for (int i = 0; i < MAX_EFFECTS; i++) { mEffectShaders[i] = NULL; @@ -396,6 +398,11 @@ void FShaderManager::CompileShaders() { FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, true); mTextureEffects.Push(shc); + if (i <= 3) + { + FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, false); + mTextureEffectsNAT.Push(shc); + } } for(unsigned i = 0; i < usershaders.Size(); i++) @@ -430,6 +437,10 @@ void FShaderManager::Clean() glUseProgram(0); mActiveShader = NULL; + for (unsigned int i = 0; i < mTextureEffectsNAT.Size(); i++) + { + if (mTextureEffectsNAT[i] != NULL) delete mTextureEffectsNAT[i]; + } for (unsigned int i = 0; i < mTextureEffects.Size(); i++) { if (mTextureEffects[i] != NULL) delete mTextureEffects[i]; @@ -440,6 +451,7 @@ void FShaderManager::Clean() mEffectShaders[i] = NULL; } mTextureEffects.Clear(); + mTextureEffectsNAT.Clear(); } //========================================================================== @@ -504,10 +516,12 @@ EXTERN_CVAR(Int, gl_fuzztype) void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view) { - for (int i = 0; i <= 4; i++) + for (int i = 0; i < 4; i++) { mTextureEffects[i]->ApplyMatrices(proj, view); + mTextureEffectsNAT[i]->ApplyMatrices(proj, view); } + mTextureEffects[4]->ApplyMatrices(proj, view); if (gl_fuzztype != 0) { mTextureEffects[4+gl_fuzztype]->ApplyMatrices(proj, view); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index e100e9bf1..92ef221af 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -249,6 +249,7 @@ public: class FShaderManager { TArray mTextureEffects; + TArray mTextureEffectsNAT; FShader *mActiveShader; FShader *mEffectShaders[MAX_EFFECTS]; @@ -268,9 +269,13 @@ public: return mActiveShader; } - FShader *Get(unsigned int eff) + FShader *Get(unsigned int eff, bool alphateston) { // indices 0-2 match the warping modes, 3 is brightmap, 4 no texture, the following are custom + if (!alphateston && eff <= 3) + { + return mTextureEffectsNAT[eff]; // Non-alphatest shaders are only created for default, warp1+2 and brightmap. The rest won't get used anyway + } if (eff < mTextureEffects.Size()) { return mTextureEffects[eff]; From cd5e429d3b0251b3d6da23e64e2a0d59cd2b9499 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 2 Aug 2014 23:12:08 +0200 Subject: [PATCH 0189/1509] - adjust version number. --- src/version.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/version.h b/src/version.h index fca56ab8c..4db09f1c6 100644 --- a/src/version.h +++ b/src/version.h @@ -41,12 +41,12 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "1.9pre" +#define VERSIONSTR "2.0.01pre" // The version as seen in the Windows resource -#define RC_FILEVERSION 1,8,9999,0 -#define RC_PRODUCTVERSION 1,8,9999,0 -#define RC_PRODUCTVERSION2 "1.9pre" +#define RC_FILEVERSION 2,0,9999,0 +#define RC_PRODUCTVERSION 2,0,9999,0 +#define RC_PRODUCTVERSION2 "2.0.01pre" // Version identifier for network games. // Bump it every time you do a release unless you're certain you From 398d902e7e527f78d109ff70eed53676ce63e9aa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Aug 2014 10:22:12 +0200 Subject: [PATCH 0190/1509] - split off sprite clipping adjustment code into its own function. --- src/gl/scene/gl_sprite.cpp | 187 ++++++++++++++++++++----------------- src/gl/scene/gl_wall.h | 1 + src/p_setup.cpp | 1 + 3 files changed, 101 insertions(+), 88 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 0ba386b1a..f420256f3 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -489,6 +489,103 @@ void GLSprite::SetSpriteColor(sector_t *sector, fixed_t center_y) // //========================================================================== +void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_t thingy, float spriteheight) +{ + bool smarterclip = false; // Set to true if one condition triggers the test below + if (((thing->player || thing->flags3&MF3_ISMONSTER || + thing->IsKindOf(RUNTIME_CLASS(AInventory))) && (thing->flags&MF_ICECORPSE || + !(thing->flags&MF_CORPSE))) || (gl_spriteclip == 3 && (smarterclip = true)) || gl_spriteclip > 1) + { + float btm = 1000000.0f; + float top = -1000000.0f; + extsector_t::xfloor &x = thing->Sector->e->XFloor; + + if (x.ffloors.Size()) + { + for (unsigned int i = 0; i < x.ffloors.Size(); i++) + { + F3DFloor * ff = x.ffloors[i]; + fixed_t floorh = ff->top.plane->ZatPoint(thingx, thingy); + fixed_t ceilingh = ff->bottom.plane->ZatPoint(thingx, thingy); + if (floorh == thing->floorz) + { + btm = FIXED2FLOAT(floorh); + } + if (ceilingh == thing->ceilingz) + { + top = FIXED2FLOAT(ceilingh); + } + if (btm != 1000000.0f && top != -1000000.0f) + { + break; + } + } + } + else if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) + { + if (thing->flags2&MF2_ONMOBJ && thing->floorz == + thing->Sector->heightsec->floorplane.ZatPoint(thingx, thingy)) + { + btm = FIXED2FLOAT(thing->floorz); + top = FIXED2FLOAT(thing->ceilingz); + } + } + if (btm == 1000000.0f) + btm = FIXED2FLOAT(thing->Sector->floorplane.ZatPoint(thingx, thingy) - thing->floorclip); + if (top == -1000000.0f) + top = FIXED2FLOAT(thing->Sector->ceilingplane.ZatPoint(thingx, thingy)); + + float diffb = z2 - btm; + float difft = z1 - top; + if (diffb >= 0 /*|| !gl_sprite_clip_to_floor*/) diffb = 0; + // Adjust sprites clipping into ceiling and adjust clipping adjustment for tall graphics + if (smarterclip) + { + // Reduce slightly clipping adjustment of corpses + if (thing->flags & MF_CORPSE || spriteheight > fabs(diffb)) + { + float ratio = clamp((fabs(diffb) * (float)gl_sclipfactor / (spriteheight + 1)), 0.5, 1.0); + diffb *= ratio; + } + if (!diffb) + { + if (difft <= 0) difft = 0; + if (difft >= (float)gl_sclipthreshold) + { + // dumb copy of the above. + if (!(thing->flags3&MF3_ISMONSTER) || (thing->flags&MF_NOGRAVITY) || (thing->flags&MF_CORPSE) || difft > (float)gl_sclipthreshold) + { + difft = 0; + } + } + if (spriteheight > fabs(difft)) + { + float ratio = clamp((fabs(difft) * (float)gl_sclipfactor / (spriteheight + 1)), 0.5, 1.0); + difft *= ratio; + } + z2 -= difft; + z1 -= difft; + } + } + if (diffb <= (0 - (float)gl_sclipthreshold)) // such a large displacement can't be correct! + { + // for living monsters standing on the floor allow a little more. + if (!(thing->flags3&MF3_ISMONSTER) || (thing->flags&MF_NOGRAVITY) || (thing->flags&MF_CORPSE) || diffb < (-1.8*(float)gl_sclipthreshold)) + { + diffb = 0; + } + } + z2 -= diffb; + z1 -= diffb; + } +} + +//========================================================================== +// +// +// +//========================================================================== + void GLSprite::Process(AActor* thing,sector_t * sector) { sector_t rs; @@ -610,95 +707,9 @@ void GLSprite::Process(AActor* thing,sector_t * sector) float spriteheight = FIXED2FLOAT(spritescaleY) * gltexture->GetScaledHeightFloat(GLUSE_SPRITE); // Tests show that this doesn't look good for many decorations and corpses - if (spriteheight>0 && gl_spriteclip>0) + if (spriteheight > 0 && gl_spriteclip > 0 && (thing->renderflags & RF_SPRITETYPEMASK) == RF_FACESPRITE) { - bool smarterclip = false; // Set to true if one condition triggers the test below - if (((thing->player || thing->flags3&MF3_ISMONSTER || - thing->IsKindOf(RUNTIME_CLASS(AInventory))) && (thing->flags&MF_ICECORPSE || - !(thing->flags&MF_CORPSE))) || (gl_spriteclip==3 && (smarterclip = true)) || gl_spriteclip > 1) - { - float btm= 1000000.0f; - float top=-1000000.0f; - extsector_t::xfloor &x = thing->Sector->e->XFloor; - - if (x.ffloors.Size()) - { - for(unsigned int i=0;itop.plane->ZatPoint(thingx, thingy); - fixed_t ceilingh=ff->bottom.plane->ZatPoint(thingx, thingy); - if (floorh==thing->floorz) - { - btm=FIXED2FLOAT(floorh); - } - if (ceilingh==thing->ceilingz) - { - top=FIXED2FLOAT(ceilingh); - } - if (btm != 1000000.0f && top != -1000000.0f) - { - break; - } - } - } - else if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) - { - if (thing->flags2&MF2_ONMOBJ && thing->floorz== - thing->Sector->heightsec->floorplane.ZatPoint(thingx, thingy)) - { - btm=FIXED2FLOAT(thing->floorz); - top=FIXED2FLOAT(thing->ceilingz); - } - } - if (btm==1000000.0f) - btm= FIXED2FLOAT(thing->Sector->floorplane.ZatPoint(thingx, thingy)-thing->floorclip); - if (top==-1000000.0f) - top= FIXED2FLOAT(thing->Sector->ceilingplane.ZatPoint(thingx, thingy)); - - float diffb = z2 - btm; - float difft = z1 - top; - if (diffb >= 0 /*|| !gl_sprite_clip_to_floor*/) diffb = 0; - // Adjust sprites clipping into ceiling and adjust clipping adjustment for tall graphics - if (smarterclip) - { - // Reduce slightly clipping adjustment of corpses - if (thing->flags & MF_CORPSE || spriteheight > fabs(diffb)) - { - float ratio = clamp((fabs(diffb) * (float)gl_sclipfactor/(spriteheight+1)), 0.5, 1.0); - diffb*=ratio; - } - if (!diffb) - { - if (difft <= 0) difft = 0; - if (difft >= (float)gl_sclipthreshold) - { - // dumb copy of the above. - if (!(thing->flags3&MF3_ISMONSTER) || (thing->flags&MF_NOGRAVITY) || (thing->flags&MF_CORPSE) || difft > (float)gl_sclipthreshold) - { - difft=0; - } - } - if (spriteheight > fabs(difft)) - { - float ratio = clamp((fabs(difft) * (float)gl_sclipfactor/(spriteheight+1)), 0.5, 1.0); - difft*=ratio; - } - z2-=difft; - z1-=difft; - } - } - if (diffb <= (0 - (float)gl_sclipthreshold)) // such a large displacement can't be correct! - { - // for living monsters standing on the floor allow a little more. - if (!(thing->flags3&MF3_ISMONSTER) || (thing->flags&MF_NOGRAVITY) || (thing->flags&MF_CORPSE) || diffb<(-1.8*(float)gl_sclipthreshold)) - { - diffb=0; - } - } - z2-=diffb; - z1-=diffb; - } + PerformSpriteClipAdjustment(thing, thingx, thingy, spriteheight); } float viewvecX = GLRenderer->mViewVector.X; float viewvecY = GLRenderer->mViewVector.Y; diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index e53513167..2fecf1d60 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -324,6 +324,7 @@ public: void SplitSprite(sector_t * frontsector, bool translucent); void SetLowerParam(); + void PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_t thingy, float spriteheight); public: diff --git a/src/p_setup.cpp b/src/p_setup.cpp index a6dbca868..0312feba5 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1858,6 +1858,7 @@ void P_SpawnThings (int position) { SetMapThingUserData(actor, *udi); } + if (actor != NULL) actor->renderflags |= RF_WALLSPRITE; } for(int i=0; i Date: Sun, 3 Aug 2014 10:57:58 +0200 Subject: [PATCH 0191/1509] - implemented rendering of wall sprites. --- src/gl/scene/gl_sprite.cpp | 47 ++++++++++++++++++++++++++------------ src/p_setup.cpp | 1 - 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index f420256f3..a600ef5a2 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -678,7 +678,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) bool mirror; FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, ang - thing->angle, &mirror); if (!patch.isValid()) return; - gltexture=FMaterial::ValidateTexture(patch, false); + gltexture = FMaterial::ValidateTexture(patch, false); if (!gltexture) return; vt = gltexture->GetSpriteVT(); @@ -686,7 +686,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) gltexture->GetRect(&r, GLUSE_SPRITE); if (mirror) { - r.left=-r.width-r.left; // mirror the sprite's x-offset + r.left = -r.width - r.left; // mirror the sprite's x-offset ul = gltexture->GetSpriteUL(); ur = gltexture->GetSpriteUR(); } @@ -696,28 +696,46 @@ void GLSprite::Process(AActor* thing,sector_t * sector) ur = gltexture->GetSpriteUL(); } - r.Scale(FIXED2FLOAT(spritescaleX),FIXED2FLOAT(spritescaleY)); + r.Scale(FIXED2FLOAT(spritescaleX), FIXED2FLOAT(spritescaleY)); - float rightfac=-r.left; - float leftfac=rightfac-r.width; + float rightfac = -r.left; + float leftfac = rightfac - r.width; - z1=z-r.top; - z2=z1-r.height; + z1 = z - r.top; + z2 = z1 - r.height; float spriteheight = FIXED2FLOAT(spritescaleY) * gltexture->GetScaledHeightFloat(GLUSE_SPRITE); - + // Tests show that this doesn't look good for many decorations and corpses if (spriteheight > 0 && gl_spriteclip > 0 && (thing->renderflags & RF_SPRITETYPEMASK) == RF_FACESPRITE) { PerformSpriteClipAdjustment(thing, thingx, thingy, spriteheight); } - float viewvecX = GLRenderer->mViewVector.X; - float viewvecY = GLRenderer->mViewVector.Y; - x1=x-viewvecY*leftfac; - x2=x-viewvecY*rightfac; - y1=y+viewvecX*leftfac; - y2=y+viewvecX*rightfac; + float viewvecX; + float viewvecY; + switch (thing->renderflags & RF_SPRITETYPEMASK) + { + case RF_FACESPRITE: + viewvecX = GLRenderer->mViewVector.X; + viewvecY = GLRenderer->mViewVector.Y; + + x1 = x - viewvecY*leftfac; + x2 = x - viewvecY*rightfac; + y1 = y + viewvecX*leftfac; + y2 = y + viewvecX*rightfac; + break; + + case RF_WALLSPRITE: + viewvecX = FIXED2FLOAT(finecosine[thing->angle >> ANGLETOFINESHIFT]); + viewvecY = FIXED2FLOAT(finesine[thing->angle >> ANGLETOFINESHIFT]); + + x1 = x + viewvecY*leftfac; + x2 = x + viewvecY*rightfac; + y1 = y - viewvecX*leftfac; + y2 = y - viewvecX*rightfac; + break; + } } else { @@ -887,6 +905,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) particle=NULL; const bool drawWithXYBillboard = ( !(actor->renderflags & RF_FORCEYBILLBOARD) + && (actor->renderflags & RF_SPRITETYPEMASK) == RF_FACESPRITE && players[consoleplayer].camera && (gl_billboard_mode == 1 || actor->renderflags & RF_FORCEXYBILLBOARD ) ); diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 0312feba5..a6dbca868 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1858,7 +1858,6 @@ void P_SpawnThings (int position) { SetMapThingUserData(actor, *udi); } - if (actor != NULL) actor->renderflags |= RF_WALLSPRITE; } for(int i=0; i Date: Sun, 3 Aug 2014 12:21:05 +0200 Subject: [PATCH 0192/1509] - fixed: the WallTypes enum contained a value that no longer was valid. This was fixed orignally last week but it seems to have gotten lost. --- src/gl/scene/gl_wall.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index ffe9ba2a5..37501c607 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -39,7 +39,6 @@ enum WallTypes RENDERWALL_MIRROR, RENDERWALL_MIRRORSURFACE, RENDERWALL_M2SNF, - RENDERWALL_M2SFOG, RENDERWALL_COLOR, RENDERWALL_FFBLOCK, RENDERWALL_COLORLAYER, From 370582d2fad3429d99dcc7811cfed454709f2eda Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Aug 2014 12:25:59 +0200 Subject: [PATCH 0193/1509] - corrected versioning info for development branch. --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 4db09f1c6..c24e51a21 100644 --- a/src/version.h +++ b/src/version.h @@ -41,12 +41,12 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "2.0.01pre" +#define VERSIONSTR "2.1pre" // The version as seen in the Windows resource #define RC_FILEVERSION 2,0,9999,0 #define RC_PRODUCTVERSION 2,0,9999,0 -#define RC_PRODUCTVERSION2 "2.0.01pre" +#define RC_PRODUCTVERSION2 "2.1pre" // Version identifier for network games. // Bump it every time you do a release unless you're certain you From 09a68e8c9372f47920036d60cac0b9139f714a7d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Aug 2014 18:14:19 +0200 Subject: [PATCH 0194/1509] - fixed incorrect function call in shader compiler. --- src/gl/shaders/gl_shader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 7ac44f661..ef0f84f0d 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -163,7 +163,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * error << "Linking:\n" << buffer << "\n"; } int linked; - glGetShaderiv(hShader, GL_LINK_STATUS, &linked); + glGetProgramiv(hShader, GL_LINK_STATUS, &linked); if (linked == 0) { // only print message if there's an error. From b9ffb51d0c7d61693982fdfe7e7d5803d29c853f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 4 Aug 2014 23:00:40 +0200 Subject: [PATCH 0195/1509] - small but important optimization: Two-sided lines with both sides in the same sector don't really require vertex splitting for precise rendering. --- src/gl/scene/gl_wall.h | 1 + src/gl/scene/gl_walls.cpp | 1 + src/gl/scene/gl_walls_draw.cpp | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 37501c607..a317ac267 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -99,6 +99,7 @@ public: GLWF_GLOW=8, // illuminated by glowing flats GLWF_NOSPLITUPPER=16, GLWF_NOSPLITLOWER=32, + GLWF_NOSPLIT=64, }; enum diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index cd179a265..ab6d710d4 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -984,6 +984,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // FloatRect *splitrect; int v = gltexture->GetAreas(&splitrect); + if (seg->frontsector == seg->backsector) flags |= GLWF_NOSPLIT; // we don't need to do vertex splits if a line has both sides in the same sector if (v>0 && !drawfogboundary && !(seg->linedef->flags&ML_WRAP_MIDTEX)) { // split the poly! diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 98bc9f661..c4576acc8 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -166,7 +166,7 @@ void GLWall::SetupLights() void GLWall::RenderWall(int textured, unsigned int *store) { static texcoord tcs[4]; // making this variable static saves us a relatively costly stack integrity check. - bool split = (gl_seamless && !(textured&RWF_NOSPLIT) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ)); + bool split = (gl_seamless && !(textured&RWF_NOSPLIT) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT)); tcs[0]=lolft; tcs[1]=uplft; From 38796e7714730ba4836720ef4023b3234fb53e03 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Aug 2014 11:41:03 +0200 Subject: [PATCH 0196/1509] - removed some obsolete and useless GL calls. --- src/gl/scene/gl_scene.cpp | 1 - src/gl/system/gl_framebuffer.cpp | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index e301b3da6..38fc5a7eb 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -659,7 +659,6 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) } glDisable(GL_STENCIL_TEST); - glDisable(GL_POLYGON_SMOOTH); framebuffer->Begin2D(false); diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index b2f147dc1..2b03db013 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -150,8 +150,6 @@ void OpenGLFrameBuffer::InitializeState() glEnable(GL_TEXTURE_2D); glDisable(GL_LINE_SMOOTH); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); - glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); From 00d7707aef51582a391edb9c9a546a92ad1dd051 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 19 Aug 2014 14:18:21 +0200 Subject: [PATCH 0197/1509] - allow reallocation of light buffer if more lights are needed. - added a light preprocessing pass to the renderer so that a non-persistent buffer can be used with minimal mapping/unmapping. This only gets used if necessary because it adds some overhead to the renderer. --- src/gl/dynlights/gl_lightbuffer.cpp | 81 ++++++++-- src/gl/dynlights/gl_lightbuffer.h | 9 +- src/gl/renderer/gl_renderer.cpp | 2 +- src/gl/scene/gl_drawinfo.cpp | 10 +- src/gl/scene/gl_drawinfo.h | 5 +- src/gl/scene/gl_flats.cpp | 94 ++++++++++-- src/gl/scene/gl_scene.cpp | 37 +++-- src/gl/scene/gl_sprite.cpp | 2 +- src/gl/scene/gl_wall.h | 7 +- src/gl/scene/gl_walls.cpp | 222 ++++++++++++++-------------- src/gl/scene/gl_walls_draw.cpp | 23 ++- 11 files changed, 323 insertions(+), 169 deletions(-) diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index b787be9e2..05dc7ec55 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -45,15 +45,20 @@ #include "gl/system/gl_interface.h" #include "gl/utility//gl_clock.h" -static const int BUFFER_SIZE = 160000; // This means 80000 lights per frame and 160000*16 bytes == 2.56 MB. +static const int INITIAL_BUFFER_SIZE = 160000; // This means 80000 lights per frame and 160000*16 bytes == 2.56 MB. + +float *mMap; FLightBuffer::FLightBuffer() { + + mBufferSize = INITIAL_BUFFER_SIZE; + mByteSize = mBufferSize * sizeof(float); if (gl.flags & RFL_SHADER_STORAGE_BUFFER) { mBufferType = GL_SHADER_STORAGE_BUFFER; mBlockAlign = -1; - mBlockSize = BUFFER_SIZE; + mBlockSize = mBufferSize; } else { @@ -64,12 +69,17 @@ FLightBuffer::FLightBuffer() } glGenBuffers(1, &mBufferId); - glBindBuffer(mBufferType, mBufferId); - unsigned int bytesize = BUFFER_SIZE * 4 * sizeof(float); - glBufferStorage(mBufferType, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); - void *map = glMapBufferRange(mBufferType, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); - mBufferPointer = (float*)map; glBindBufferBase(mBufferType, LIGHTBUF_BINDINGPOINT, mBufferId); + if (gl.flags & RFL_SHADER_STORAGE_BUFFER) + { + glBufferStorage(mBufferType, mByteSize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + } + else + { + glBufferData(mBufferType, mByteSize, NULL, GL_DYNAMIC_DRAW); + mBufferPointer = NULL; + } Clear(); mLastMappedIndex = UINT_MAX; @@ -84,7 +94,8 @@ FLightBuffer::~FLightBuffer() void FLightBuffer::Clear() { mIndex = 0; - mBufferArray.Clear(); + mIndices.Clear(); + mUploadIndex = 0; } int FLightBuffer::UploadLights(FDynLightData &data) @@ -120,13 +131,45 @@ int FLightBuffer::UploadLights(FDynLightData &data) if (totalsize <= 1) return -1; - if (mIndex + totalsize > BUFFER_SIZE) + if (mIndex + totalsize > mBufferSize) { - return -1; // we ran out of space. All following lights will be ignored + // reallocate the buffer with twice the size + unsigned int newbuffer; + + // first unmap the old buffer + glBindBuffer(mBufferType, mBufferId); + glUnmapBuffer(mBufferType); + + // create and bind the new buffer, bind the old one to a copy target (too bad that DSA is not yet supported well enough to omit this crap.) + glGenBuffers(1, &newbuffer); + glBindBufferBase(mBufferType, LIGHTBUF_BINDINGPOINT, newbuffer); + glBindBuffer(GL_COPY_READ_BUFFER, mBufferId); + + // create the new buffer's storage (twice as large as the old one) + mBufferSize *= 2; + mByteSize *= 2; + if (gl.flags & RFL_SHADER_STORAGE_BUFFER) + { + glBufferStorage(mBufferType, mByteSize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + } + else + { + glBufferData(mBufferType, mByteSize, NULL, GL_DYNAMIC_DRAW); + mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_BUFFER_BIT); + } + + // copy contents and delete the old buffer. + glCopyBufferSubData(GL_COPY_READ_BUFFER, mBufferType, 0, 0, mByteSize/2); + glBindBuffer(GL_COPY_READ_BUFFER, 0); + glDeleteBuffers(1, &mBufferId); + mBufferId = newbuffer; } float *copyptr; - + + assert(mBufferPointer != NULL); + if (mBufferPointer == NULL) return -1; copyptr = mBufferPointer + mIndex * 4; float parmcnt[] = { 0, size0, size0 + size1, size0 + size1 + size2 }; @@ -142,9 +185,23 @@ int FLightBuffer::UploadLights(FDynLightData &data) return bufferindex; } +void FLightBuffer::Begin() +{ + if (!(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + { + glBindBuffer(mBufferType, mBufferId); + mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_BUFFER_BIT); + } +} + void FLightBuffer::Finish() { - Clear(); + if (!(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + { + glBindBuffer(mBufferType, mBufferId); + glUnmapBuffer(mBufferType); + mBufferPointer = NULL; + } } int FLightBuffer::BindUBO(unsigned int index) diff --git a/src/gl/dynlights/gl_lightbuffer.h b/src/gl/dynlights/gl_lightbuffer.h index 8e50555c3..8781ccb57 100644 --- a/src/gl/dynlights/gl_lightbuffer.h +++ b/src/gl/dynlights/gl_lightbuffer.h @@ -6,15 +6,18 @@ struct FDynLightData; class FLightBuffer { - TArray mBufferArray; + TArray mIndices; unsigned int mBufferId; float * mBufferPointer; unsigned int mBufferType; unsigned int mIndex; + unsigned int mUploadIndex; unsigned int mLastMappedIndex; unsigned int mBlockAlign; unsigned int mBlockSize; + unsigned int mBufferSize; + unsigned int mByteSize; public: @@ -22,10 +25,14 @@ public: ~FLightBuffer(); void Clear(); int UploadLights(FDynLightData &data); + void Begin(); void Finish(); int BindUBO(unsigned int index); unsigned int GetBlockSize() const { return mBlockSize; } unsigned int GetBufferType() const { return mBufferType; } + unsigned int GetIndexPtr() const { return mIndices.Size(); } + void StoreIndex(int index) { mIndices.Push(index); } + int GetIndex(int i) const { return mIndices[i]; } }; #endif diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index ceb553f86..effbec942 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -110,7 +110,7 @@ void FGLRenderer::Initialize() mVBO = new FFlatVertexBuffer; mSkyVBO = new FSkyVertexBuffer; mModelVBO = new FModelVertexBuffer; - mLights = new FLightBuffer; + mLights = new FLightBuffer(); gl_RenderState.SetVertexBuffer(mVBO); mFBID = 0; SetupLevel(); diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index cac3bad6a..8461a90eb 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -692,7 +692,7 @@ SortNode * GLDrawList::DoSort(SortNode * head) // // //========================================================================== -void GLDrawList::DoDraw(int pass, int i) +void GLDrawList::DoDraw(int pass, int i, bool trans) { switch(drawitems[i].rendertype) { @@ -700,7 +700,7 @@ void GLDrawList::DoDraw(int pass, int i) { GLFlat * f=&flats[drawitems[i].index]; RenderFlat.Clock(); - f->Draw(pass); + f->Draw(pass, trans); RenderFlat.Unclock(); } break; @@ -739,13 +739,13 @@ void GLDrawList::DoDrawSorted(SortNode * head) { DoDrawSorted(head->left); } - DoDraw(GLPASS_TRANSLUCENT, head->itemindex); + DoDraw(GLPASS_TRANSLUCENT, head->itemindex, true); if (head->equal) { SortNode * ehead=head->equal; while (ehead) { - DoDraw(GLPASS_TRANSLUCENT, ehead->itemindex); + DoDraw(GLPASS_TRANSLUCENT, ehead->itemindex, true); ehead=ehead->equal; } } @@ -779,7 +779,7 @@ void GLDrawList::Draw(int pass) { for(unsigned i=0;imLights->GetIndex(*dli)); + (*dli)++; + return; + } + lightdata.Clear(); FLightNode * node = sub->lighthead; while (node) @@ -143,9 +150,15 @@ bool GLFlat::SetupSubsectorLights(bool lightsapplied, subsector_t * sub) node = node->nextLight; } - dynlightindex = GLRenderer->mLights->UploadLights(lightdata); - gl_RenderState.ApplyLightIndex(dynlightindex); - return false; + int d = GLRenderer->mLights->UploadLights(lightdata); + if (pass == GLPASS_LIGHTSONLY) + { + GLRenderer->mLights->StoreIndex(d); + } + else + { + gl_RenderState.ApplyLightIndex(d); + } } //========================================================================== @@ -197,15 +210,59 @@ void GLFlat::DrawSubsector(subsector_t * sub) // //========================================================================== -void GLFlat::DrawSubsectors(int pass, bool istrans) +void GLFlat::ProcessLights(bool istrans) { - bool lightsapplied = false; + dynlightindex = GLRenderer->mLights->GetIndexPtr(); + + if (sub) + { + // This represents a single subsector + SetupSubsectorLights(GLPASS_LIGHTSONLY, sub); + } + else + { + // Draw the subsectors belonging to this sector + for (int i=0; isubsectorcount; i++) + { + subsector_t * sub = sector->subsectors[i]; + if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) + { + SetupSubsectorLights(GLPASS_LIGHTSONLY, sub); + } + } + + // Draw the subsectors assigned to it due to missing textures + if (!(renderflags&SSRF_RENDER3DPLANES)) + { + gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR)? + gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) : + gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum); + + while (node) + { + SetupSubsectorLights(GLPASS_LIGHTSONLY, node->sub); + node = node->next; + } + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +void GLFlat::DrawSubsectors(int pass, bool processlights, bool istrans) +{ + int dli = dynlightindex; gl_RenderState.Apply(); if (sub) { // This represents a single subsector - if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub); + if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli); DrawSubsector(sub); } else @@ -216,10 +273,10 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) for (int i=0; isubsectorcount; i++) { subsector_t * sub = sector->subsectors[i]; - // This is just a quick hack to make translucent 3D floors and portals work. + if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) { - if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub); + if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli); drawcalls.Clock(); glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines); drawcalls.Unclock(); @@ -237,7 +294,7 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) subsector_t * sub = sector->subsectors[i]; if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) { - if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub); + if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli); DrawSubsector(sub); } } @@ -252,7 +309,7 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) while (node) { - if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, node->sub); + if (processlights) SetupSubsectorLights(GLPASS_ALL, node->sub, &dli); DrawSubsector(node->sub); node = node->next; } @@ -266,7 +323,7 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) // // //========================================================================== -void GLFlat::Draw(int pass) +void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIGHTSONLY { int rel = getExtraLight(); @@ -286,10 +343,17 @@ void GLFlat::Draw(int pass) gl_SetFog(lightlevel, rel, &Colormap, false); gltexture->Bind(); gl_SetPlaneTextureRotation(&plane, gltexture); - DrawSubsectors(pass, false); + DrawSubsectors(pass, (pass == GLPASS_ALL || dynlightindex > -1), false); gl_RenderState.EnableTextureMatrix(false); break; + case GLPASS_LIGHTSONLY: + if (!trans || gltexture) + { + ProcessLights(trans); + } + break; + case GLPASS_TRANSLUCENT: if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE); gl_SetColor(lightlevel, rel, Colormap, alpha); @@ -298,14 +362,14 @@ void GLFlat::Draw(int pass) if (!gltexture) { gl_RenderState.EnableTexture(false); - DrawSubsectors(pass, true); + DrawSubsectors(pass, false, true); gl_RenderState.EnableTexture(true); } else { gltexture->Bind(); gl_SetPlaneTextureRotation(&plane, gltexture); - DrawSubsectors(pass, true); + DrawSubsectors(pass, true, true); gl_RenderState.EnableTextureMatrix(false); } if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 38fc5a7eb..93bda9494 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -340,20 +340,31 @@ void FGLRenderer::RenderScene(int recursion) gl_RenderState.EnableFog(true); gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); - // First draw all single-pass stuff + gl_drawinfo->drawlists[GLDL_PLAIN].Sort(); + gl_drawinfo->drawlists[GLDL_MASKED].Sort(); + gl_drawinfo->drawlists[GLDL_MASKEDOFS].Sort(); + + // if we don't have a persistently mapped buffer, we have to process all the dynamic lights up front, + // so that we don't have to do repeated map/unmap calls on the buffer. + if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + { + GLRenderer->mLights->Begin(); + gl_drawinfo->drawlists[GLDL_PLAIN].Draw(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_MASKED].Draw(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_MASKEDOFS].Draw(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_TRANSLUCENT].Draw(GLPASS_LIGHTSONLY); + GLRenderer->mLights->Finish(); + } // Part 1: solid geometry. This is set up so that there are no transparent parts glDepthFunc(GL_LESS); - - gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); - - glDisable(GL_POLYGON_OFFSET_FILL); // just in case - GLRenderer->mLights->Finish(); + glDisable(GL_POLYGON_OFFSET_FILL); int pass; - if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights) + if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && (gl.flags & RFL_SHADER_STORAGE_BUFFER)) { pass = GLPASS_ALL; } @@ -364,7 +375,6 @@ void FGLRenderer::RenderScene(int recursion) gl_RenderState.EnableTexture(gl_texture); gl_RenderState.EnableBrightmap(true); - gl_drawinfo->drawlists[GLDL_PLAIN].Sort(); gl_drawinfo->drawlists[GLDL_PLAIN].Draw(pass); @@ -375,15 +385,13 @@ void FGLRenderer::RenderScene(int recursion) gl_RenderState.SetTextureMode(TM_MASK); } gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); - gl_drawinfo->drawlists[GLDL_MASKED].Sort(); gl_drawinfo->drawlists[GLDL_MASKED].Draw(pass); - // this list is empty most of the time so only waste time on it when in use. + // Part 3: masked geometry with polygon offset. This list is empty most of the time so only waste time on it when in use. if (gl_drawinfo->drawlists[GLDL_MASKEDOFS].Size() > 0) { glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1.0f, -128.0f); - gl_drawinfo->drawlists[GLDL_MASKEDOFS].Sort(); gl_drawinfo->drawlists[GLDL_MASKEDOFS].Draw(pass); glDisable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0, 0); @@ -393,7 +401,7 @@ void FGLRenderer::RenderScene(int recursion) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - // Draw decals (not a real pass) + // Part 4: Draw decals (not a real pass) glDepthFunc(GL_LEQUAL); glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1.0f, -128.0f); @@ -413,8 +421,8 @@ void FGLRenderer::RenderScene(int recursion) // so they don't interfere with overlapping mid textures. glPolygonOffset(1.0f, 128.0f); - // flood all the gaps with the back sector's flat texture - // This will always be drawn like GLDL_PLAIN or GLDL_FOG, depending on the fog settings + // Part 5: flood all the gaps with the back sector's flat texture + // This will always be drawn like GLDL_PLAIN, depending on the fog settings glDepthMask(false); // don't write to Z-buffer! gl_RenderState.EnableFog(true); @@ -782,6 +790,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo SetCameraPos(viewx, viewy, viewz, viewangle); SetViewMatrix(false, false); gl_RenderState.ApplyMatrices(); + GLRenderer->mLights->Clear(); clipper.Clear(); angle_t a1 = FrustumAngle(); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index e21b0e985..4aa0f90bc 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -112,7 +112,7 @@ CVAR(Bool, gl_nolayer, false, 0) //========================================================================== void GLSprite::Draw(int pass) { - if (pass == GLPASS_DECALS) return; + if (pass == GLPASS_DECALS || pass == GLPASS_LIGHTSONLY) return; diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index a317ac267..7a6acbc89 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -279,16 +279,17 @@ public: int dynlightindex; - bool SetupSubsectorLights(bool lightsapplied, subsector_t * sub); + void SetupSubsectorLights(int pass, subsector_t * sub, int *dli = NULL); void DrawSubsector(subsector_t * sub); void DrawSubsectorLights(subsector_t * sub, int pass); - void DrawSubsectors(int pass, bool istrans); + void DrawSubsectors(int pass, bool processlights, bool istrans); + void ProcessLights(bool istrans); void PutFlat(bool fog = false); void Process(sector_t * model, int whichplane, bool notexture); void SetFrom3DFloor(F3DFloor *rover, bool top, bool underside); void ProcessSector(sector_t * frontsector); - void Draw(int pass); + void Draw(int pass, bool trans); }; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index ab6d710d4..bcf0080d0 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1408,7 +1408,7 @@ void GLWall::DoFFloorBlocks(seg_t * seg,sector_t * frontsector,sector_t * backse //========================================================================== void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) { - vertex_t * v1, * v2; + vertex_t * v1, *v2; fixed_t fch1; fixed_t ffh1; fixed_t fch2; @@ -1422,7 +1422,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) int a = 0; } #endif - + // note: we always have a valid sidedef and linedef reference when getting here. this->seg = seg; @@ -1437,24 +1437,24 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) { // Need these for aligning the textures realfront = §ors[frontsector->sectornum]; - realback = backsector? §ors[backsector->sectornum] : NULL; + realback = backsector ? §ors[backsector->sectornum] : NULL; } if (seg->sidedef == seg->linedef->sidedef[0]) { - v1=seg->linedef->v1; - v2=seg->linedef->v2; + v1 = seg->linedef->v1; + v2 = seg->linedef->v2; } else { - v1=seg->linedef->v2; - v2=seg->linedef->v1; + v1 = seg->linedef->v2; + v2 = seg->linedef->v1; } if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) { - glseg.fracleft=0; - glseg.fracright=1; + glseg.fracleft = 0; + glseg.fracright = 1; if (gl_seamless) { if (v1->dirty) gl_RecalcVertexHeights(v1); @@ -1463,29 +1463,29 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else // polyobjects must be rendered per seg. { - if (abs(v1->x-v2->x) > abs(v1->y-v2->y)) + if (abs(v1->x - v2->x) > abs(v1->y - v2->y)) { - glseg.fracleft = float(seg->v1->x - v1->x)/float(v2->x-v1->x); - glseg.fracright = float(seg->v2->x - v1->x)/float(v2->x-v1->x); + glseg.fracleft = float(seg->v1->x - v1->x) / float(v2->x - v1->x); + glseg.fracright = float(seg->v2->x - v1->x) / float(v2->x - v1->x); } else { - glseg.fracleft = float(seg->v1->y - v1->y)/float(v2->y-v1->y); - glseg.fracright = float(seg->v2->y - v1->y)/float(v2->y-v1->y); + glseg.fracleft = float(seg->v1->y - v1->y) / float(v2->y - v1->y); + glseg.fracright = float(seg->v2->y - v1->y) / float(v2->y - v1->y); } - v1=seg->v1; - v2=seg->v2; + v1 = seg->v1; + v2 = seg->v2; } - vertexes[0]=v1; - vertexes[1]=v2; + vertexes[0] = v1; + vertexes[1] = v2; - glseg.x1= FIXED2FLOAT(v1->x); - glseg.y1= FIXED2FLOAT(v1->y); - glseg.x2= FIXED2FLOAT(v2->x); - glseg.y2= FIXED2FLOAT(v2->y); - Colormap=frontsector->ColorMap; + glseg.x1 = FIXED2FLOAT(v1->x); + glseg.y1 = FIXED2FLOAT(v1->y); + glseg.x2 = FIXED2FLOAT(v2->x); + glseg.y2 = FIXED2FLOAT(v2->y); + Colormap = frontsector->ColorMap; flags = 0; dynlightindex = UINT_MAX; @@ -1495,10 +1495,10 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) lightlevel = gl_ClampLight(seg->sidedef->GetLightLevel(foggy, orglightlevel, false, &rel)); if (orglightlevel >= 253) // with the software renderer fake contrast won't be visible above this. { - rellight = 0; + rellight = 0; } else if (lightlevel - rel > 256) // the brighter part of fake contrast will be clamped so also clamp the darker part by the same amount for better looks - { + { rellight = 256 - lightlevel + rel; } else @@ -1506,35 +1506,35 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) rellight = rel; } - alpha=1.0f; - RenderStyle=STYLE_Normal; - gltexture=NULL; + alpha = 1.0f; + RenderStyle = STYLE_Normal; + gltexture = NULL; - topflat=frontsector->GetTexture(sector_t::ceiling); // for glowing textures. These must be saved because - bottomflat=frontsector->GetTexture(sector_t::floor); // the sector passed here might be a temporary copy. + topflat = frontsector->GetTexture(sector_t::ceiling); // for glowing textures. These must be saved because + bottomflat = frontsector->GetTexture(sector_t::floor); // the sector passed here might be a temporary copy. topplane = frontsector->ceilingplane; bottomplane = frontsector->floorplane; // Save a little time (up to 0.3 ms per frame ;) ) if (frontsector->floorplane.a | frontsector->floorplane.b) { - ffh1=frontsector->floorplane.ZatPoint(v1); - ffh2=frontsector->floorplane.ZatPoint(v2); - zfloor[0]=FIXED2FLOAT(ffh1); - zfloor[1]=FIXED2FLOAT(ffh2); + ffh1 = frontsector->floorplane.ZatPoint(v1); + ffh2 = frontsector->floorplane.ZatPoint(v2); + zfloor[0] = FIXED2FLOAT(ffh1); + zfloor[1] = FIXED2FLOAT(ffh2); } else { - ffh1 = ffh2 = -frontsector->floorplane.d; + ffh1 = ffh2 = -frontsector->floorplane.d; zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh2); } if (frontsector->ceilingplane.a | frontsector->ceilingplane.b) { - fch1=frontsector->ceilingplane.ZatPoint(v1); - fch2=frontsector->ceilingplane.ZatPoint(v2); - zceil[0]= FIXED2FLOAT(fch1); - zceil[1]= FIXED2FLOAT(fch2); + fch1 = frontsector->ceilingplane.ZatPoint(v1); + fch2 = frontsector->ceilingplane.ZatPoint(v2); + zceil[0] = FIXED2FLOAT(fch1); + zceil[1] = FIXED2FLOAT(fch2); } else { @@ -1543,27 +1543,27 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } - if (seg->linedef->special==Line_Horizon) + if (seg->linedef->special == Line_Horizon) { - SkyNormal(frontsector,v1,v2); - DoHorizon(seg,frontsector, v1,v2); + SkyNormal(frontsector, v1, v2); + DoHorizon(seg, frontsector, v1, v2); return; } //return; // [GZ] 3D middle textures are necessarily two-sided, even if they lack the explicit two-sided flag - if (!backsector || !(seg->linedef->flags&(ML_TWOSIDED|ML_3DMIDTEX))) // one sided + if (!backsector || !(seg->linedef->flags&(ML_TWOSIDED | ML_3DMIDTEX))) // one sided { // sector's sky - SkyNormal(frontsector,v1,v2); - + SkyNormal(frontsector, v1, v2); + // normal texture - gltexture=FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::mid), true); - if (gltexture) + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::mid), true); + if (gltexture) { - DoTexture(RENDERWALL_M1S,seg,(seg->linedef->flags & ML_DONTPEGBOTTOM)>0, - realfront->GetPlaneTexZ(sector_t::ceiling),realfront->GetPlaneTexZ(sector_t::floor), // must come from the original! - fch1,fch2,ffh1,ffh2,0); + DoTexture(RENDERWALL_M1S, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, + realfront->GetPlaneTexZ(sector_t::ceiling), realfront->GetPlaneTexZ(sector_t::floor), // must come from the original! + fch1, fch2, ffh1, ffh2, 0); } } else // two sided @@ -1576,8 +1576,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (backsector->floorplane.a | backsector->floorplane.b) { - bfh1=backsector->floorplane.ZatPoint(v1); - bfh2=backsector->floorplane.ZatPoint(v2); + bfh1 = backsector->floorplane.ZatPoint(v1); + bfh2 = backsector->floorplane.ZatPoint(v2); } else { @@ -1586,51 +1586,51 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (backsector->ceilingplane.a | backsector->ceilingplane.b) { - bch1=backsector->ceilingplane.ZatPoint(v1); - bch2=backsector->ceilingplane.ZatPoint(v2); + bch1 = backsector->ceilingplane.ZatPoint(v1); + bch2 = backsector->ceilingplane.ZatPoint(v2); } else { bch1 = bch2 = backsector->ceilingplane.d; } - SkyTop(seg,frontsector,backsector,v1,v2); - SkyBottom(seg,frontsector,backsector,v1,v2); - + SkyTop(seg, frontsector, backsector, v1, v2); + SkyBottom(seg, frontsector, backsector, v1, v2); + // upper texture - if (frontsector->GetTexture(sector_t::ceiling)!=skyflatnum || backsector->GetTexture(sector_t::ceiling)!=skyflatnum) + if (frontsector->GetTexture(sector_t::ceiling) != skyflatnum || backsector->GetTexture(sector_t::ceiling) != skyflatnum) { - fixed_t bch1a=bch1, bch2a=bch2; - if (frontsector->GetTexture(sector_t::floor)!=skyflatnum || backsector->GetTexture(sector_t::floor)!=skyflatnum) + fixed_t bch1a = bch1, bch2a = bch2; + if (frontsector->GetTexture(sector_t::floor) != skyflatnum || backsector->GetTexture(sector_t::floor) != skyflatnum) { // the back sector's floor obstructs part of this wall - if (ffh1>bch1 && ffh2>bch2) + if (ffh1 > bch1 && ffh2 > bch2) { - bch2a=ffh2; - bch1a=ffh1; + bch2a = ffh2; + bch1a = ffh1; } } - if (bch1asidedef->GetTexture(side_t::top), true); - if (gltexture) + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), true); + if (gltexture) { - DoTexture(RENDERWALL_TOP,seg,(seg->linedef->flags & (ML_DONTPEGTOP))==0, - realfront->GetPlaneTexZ(sector_t::ceiling),realback->GetPlaneTexZ(sector_t::ceiling), - fch1,fch2,bch1a,bch2a,0); + DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, + realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling), + fch1, fch2, bch1a, bch2a, 0); } - else if ((frontsector->ceilingplane.a | frontsector->ceilingplane.b | - backsector->ceilingplane.a | backsector->ceilingplane.b) && - frontsector->GetTexture(sector_t::ceiling)!=skyflatnum && - backsector->GetTexture(sector_t::ceiling)!=skyflatnum) + else if ((frontsector->ceilingplane.a | frontsector->ceilingplane.b | + backsector->ceilingplane.a | backsector->ceilingplane.b) && + frontsector->GetTexture(sector_t::ceiling) != skyflatnum && + backsector->GetTexture(sector_t::ceiling) != skyflatnum) { - gltexture=FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::ceiling), true); + gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::ceiling), true); if (gltexture) { - DoTexture(RENDERWALL_TOP,seg,(seg->linedef->flags & (ML_DONTPEGTOP))==0, - realfront->GetPlaneTexZ(sector_t::ceiling),realback->GetPlaneTexZ(sector_t::ceiling), - fch1,fch2,bch1a,bch2a,0); + DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, + realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling), + fch1, fch2, bch1a, bch2a, 0); } } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) @@ -1650,58 +1650,58 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) { tex = tex->GetRawTexture(); } - gltexture=FMaterial::ValidateTexture(tex); + gltexture = FMaterial::ValidateTexture(tex); } else gltexture = NULL; if (gltexture || drawfogboundary) { - DoMidTexture(seg, drawfogboundary, frontsector, backsector, realfront, realback, + DoMidTexture(seg, drawfogboundary, frontsector, backsector, realfront, realback, fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); } - if (backsector->e->XFloor.ffloors.Size() || frontsector->e->XFloor.ffloors.Size()) + if (backsector->e->XFloor.ffloors.Size() || frontsector->e->XFloor.ffloors.Size()) { - DoFFloorBlocks(seg,frontsector,backsector, fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); + DoFFloorBlocks(seg, frontsector, backsector, fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); } - + /* bottom texture */ // the back sector's ceiling obstructs part of this wall (specially important for sky sectors) if (fch1ffh1 || bfh2>ffh2) { - gltexture=FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), true); - if (gltexture) + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), true); + if (gltexture) { - DoTexture(RENDERWALL_BOTTOM,seg,(seg->linedef->flags & ML_DONTPEGBOTTOM)>0, - realback->GetPlaneTexZ(sector_t::floor),realfront->GetPlaneTexZ(sector_t::floor), - bfh1,bfh2,ffh1,ffh2, - frontsector->GetTexture(sector_t::ceiling)==skyflatnum && backsector->GetTexture(sector_t::ceiling)==skyflatnum ? - realfront->GetPlaneTexZ(sector_t::floor)-realback->GetPlaneTexZ(sector_t::ceiling) : - realfront->GetPlaneTexZ(sector_t::floor)-realfront->GetPlaneTexZ(sector_t::ceiling)); + DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, + realback->GetPlaneTexZ(sector_t::floor), realfront->GetPlaneTexZ(sector_t::floor), + bfh1, bfh2, ffh1, ffh2, + frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum ? + realfront->GetPlaneTexZ(sector_t::floor) - realback->GetPlaneTexZ(sector_t::ceiling) : + realfront->GetPlaneTexZ(sector_t::floor) - realfront->GetPlaneTexZ(sector_t::ceiling)); } - else if ((frontsector->floorplane.a | frontsector->floorplane.b | - backsector->floorplane.a | backsector->floorplane.b) && - frontsector->GetTexture(sector_t::floor)!=skyflatnum && - backsector->GetTexture(sector_t::floor)!=skyflatnum) + else if ((frontsector->floorplane.a | frontsector->floorplane.b | + backsector->floorplane.a | backsector->floorplane.b) && + frontsector->GetTexture(sector_t::floor) != skyflatnum && + backsector->GetTexture(sector_t::floor) != skyflatnum) { // render it anyway with the sector's floor texture. With a background sky // there are ugly holes otherwise and slopes are simply not precise enough // to mach in any case. - gltexture=FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), true); + gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), true); if (gltexture) { - DoTexture(RENDERWALL_BOTTOM,seg,(seg->linedef->flags & ML_DONTPEGBOTTOM)>0, - realback->GetPlaneTexZ(sector_t::floor),realfront->GetPlaneTexZ(sector_t::floor), - bfh1,bfh2,ffh1,ffh2, realfront->GetPlaneTexZ(sector_t::floor)-realfront->GetPlaneTexZ(sector_t::ceiling)); + DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, + realback->GetPlaneTexZ(sector_t::floor), realfront->GetPlaneTexZ(sector_t::floor), + bfh1, bfh2, ffh1, ffh2, realfront->GetPlaneTexZ(sector_t::floor) - realfront->GetPlaneTexZ(sector_t::ceiling)); } } - else if (backsector->GetTexture(sector_t::floor)!=skyflatnum && + else if (backsector->GetTexture(sector_t::floor) != skyflatnum && !(seg->sidedef->Flags & WALLF_POLYOBJ)) { gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1); @@ -1717,19 +1717,19 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) //========================================================================== void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector) { - if (frontsector->GetTexture(sector_t::floor)==skyflatnum) return; + if (frontsector->GetTexture(sector_t::floor) == skyflatnum) return; - fixed_t ffh = frontsector->GetPlaneTexZ(sector_t::floor); - fixed_t bfh = backsector->GetPlaneTexZ(sector_t::floor); - if (bfh>ffh) + fixed_t ffh = frontsector->GetPlaneTexZ(sector_t::floor); + fixed_t bfh = backsector->GetPlaneTexZ(sector_t::floor); + if (bfh > ffh) { this->seg = seg; this->sub = NULL; - vertex_t * v1=seg->v1; - vertex_t * v2=seg->v2; - vertexes[0]=v1; - vertexes[1]=v2; + vertex_t * v1 = seg->v1; + vertex_t * v2 = seg->v2; + vertexes[0] = v1; + vertexes[1] = v2; glseg.x1 = FIXED2FLOAT(v1->x); glseg.y1 = FIXED2FLOAT(v1->y); @@ -1758,10 +1758,10 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), true); - if (gltexture) + if (gltexture) { FTexCoordInfo tci; - type=RENDERWALL_BOTTOM; + type = RENDERWALL_BOTTOM; gltexture->GetTexCoordInfo(&tci, FRACUNIT, FRACUNIT); SetWallCoordinates(seg, &tci, FIXED2FLOAT(bfh), bfh, bfh, ffh, ffh, 0); PutWall(false); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index c4576acc8..51bf5de18 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -70,8 +70,19 @@ EXTERN_CVAR(Bool, gl_seamless) //========================================================================== FDynLightData lightdata; + void GLWall::SetupLights() { + // check for wall types which cannot have dynamic lights on them (portal types never get here so they don't need to be checked.) + switch (type) + { + case RENDERWALL_FOGBOUNDARY: + case RENDERWALL_MIRRORSURFACE: + case RENDERWALL_COLOR: + case RENDERWALL_COLORLAYER: + return; + } + float vtx[]={glseg.x1,zbottom[0],glseg.y1, glseg.x1,ztop[0],glseg.y1, glseg.x2,ztop[1],glseg.y2, glseg.x2,zbottom[1],glseg.y2}; Plane p; @@ -357,7 +368,7 @@ void GLWall::Draw(int pass) #endif - if (type == RENDERWALL_COLORLAYER) + if (type == RENDERWALL_COLORLAYER && pass != GLPASS_LIGHTSONLY) { glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1.0f, -128.0f); @@ -365,10 +376,14 @@ void GLWall::Draw(int pass) switch (pass) { - case GLPASS_ALL: // Single-pass rendering + case GLPASS_LIGHTSONLY: + SetupLights(); + break; + + case GLPASS_ALL: SetupLights(); // fall through - case GLPASS_PLAIN: // Single-pass rendering + case GLPASS_PLAIN: rel = rellight + getExtraLight(); gl_SetColor(lightlevel, rel, Colormap,1.0f); if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, false); @@ -409,7 +424,7 @@ void GLWall::Draw(int pass) } } - if (type == RENDERWALL_COLORLAYER) + if (type == RENDERWALL_COLORLAYER && pass != GLPASS_LIGHTSONLY) { glDisable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0, 0); From a2dc4afe3f7318c4d5650b77b1277e5e26d2b640 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 19 Aug 2014 14:25:47 +0200 Subject: [PATCH 0198/1509] - screwed by the editor's autocompletion... (wrong GL flag was used...) --- src/gl/dynlights/gl_lightbuffer.cpp | 10 +++++----- src/gl/scene/gl_scene.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index 05dc7ec55..3031d3916 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -54,7 +54,7 @@ FLightBuffer::FLightBuffer() mBufferSize = INITIAL_BUFFER_SIZE; mByteSize = mBufferSize * sizeof(float); - if (gl.flags & RFL_SHADER_STORAGE_BUFFER) + if (gl.flags & RFL_BUFFER_STORAGE) { mBufferType = GL_SHADER_STORAGE_BUFFER; mBlockAlign = -1; @@ -70,7 +70,7 @@ FLightBuffer::FLightBuffer() glGenBuffers(1, &mBufferId); glBindBufferBase(mBufferType, LIGHTBUF_BINDINGPOINT, mBufferId); - if (gl.flags & RFL_SHADER_STORAGE_BUFFER) + if (gl.flags & RFL_BUFFER_STORAGE) { glBufferStorage(mBufferType, mByteSize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); @@ -148,7 +148,7 @@ int FLightBuffer::UploadLights(FDynLightData &data) // create the new buffer's storage (twice as large as the old one) mBufferSize *= 2; mByteSize *= 2; - if (gl.flags & RFL_SHADER_STORAGE_BUFFER) + if (gl.flags & RFL_BUFFER_STORAGE) { glBufferStorage(mBufferType, mByteSize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); @@ -187,7 +187,7 @@ int FLightBuffer::UploadLights(FDynLightData &data) void FLightBuffer::Begin() { - if (!(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + if (!(gl.flags & RFL_BUFFER_STORAGE)) { glBindBuffer(mBufferType, mBufferId); mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_BUFFER_BIT); @@ -196,7 +196,7 @@ void FLightBuffer::Begin() void FLightBuffer::Finish() { - if (!(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + if (!(gl.flags & RFL_BUFFER_STORAGE)) { glBindBuffer(mBufferType, mBufferId); glUnmapBuffer(mBufferType); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 93bda9494..afd9259f2 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -346,7 +346,7 @@ void FGLRenderer::RenderScene(int recursion) // if we don't have a persistently mapped buffer, we have to process all the dynamic lights up front, // so that we don't have to do repeated map/unmap calls on the buffer. - if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && !(gl.flags & RFL_BUFFER_STORAGE)) { GLRenderer->mLights->Begin(); gl_drawinfo->drawlists[GLDL_PLAIN].Draw(GLPASS_LIGHTSONLY); @@ -364,7 +364,7 @@ void FGLRenderer::RenderScene(int recursion) int pass; - if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && (gl.flags & RFL_SHADER_STORAGE_BUFFER)) + if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && (gl.flags & RFL_BUFFER_STORAGE)) { pass = GLPASS_ALL; } From 86d37e06f961c55d4ad02d5aac8788cd15e5190b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 19 Aug 2014 15:56:33 +0200 Subject: [PATCH 0199/1509] - lowered requirements of GL 2.x to OpenGL 3.3. There was one issue preventing the previous 2.0 betas from running under GL 3.x: The lack of persistently mapped buffers. For the dynamic light buffer today's changes take care of that problem. For the vertex buffer there is no good workaround but we can use immediate mode render calls instead which have been reinstated. To handle the current setup, the engine first tries to get a core profile context and checks for presence of GL 4.4 or the GL_ARB_buffer_storage extension. If this fails the context is deleted again and a compatibility context retrieved which is then used for 'old style' rendering which does work on older GL versions. This new version does not support GL 3.2 or lower, meaning that Intel GMA 3000 or lower is not supported. The reason for this is that the engine uses a few GL 3.3 features which are not present in the latest Intel driver. In general the Intel GMA 3000 is far too weak, though, to run the demanding shader of GZDoom 2.x, so this is no real loss. Performance would be far from satisfying. A command line option '-gl3' exists to force the fallback render path. On my Geforce 550Ti there's approx. 10% performance loss on this path. --- src/gl/data/gl_vertexbuffer.cpp | 99 +++++++++++++++++++++++++-------- src/gl/data/gl_vertexbuffer.h | 9 ++- src/gl/system/gl_interface.cpp | 11 +++- src/gl/system/gl_interface.h | 3 +- src/win32/win32gliface.cpp | 90 +++++++++++++++++++++--------- src/win32/win32gliface.h | 1 + 6 files changed, 159 insertions(+), 54 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 854750ecb..0e9065557 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -90,26 +90,60 @@ void FVertexBuffer::BindVBO() FFlatVertexBuffer::FFlatVertexBuffer() : FVertexBuffer() { - unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); - map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); - mNumReserved = mIndex = mCurIndex = 0; + if (gl.flags & RFL_BUFFER_STORAGE) + { + unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); - glBindVertexArray(vao_id); - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glVertexAttribPointer(VATTR_VERTEX, 3,GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); - glVertexAttribPointer(VATTR_TEXCOORD, 2,GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); - glEnableVertexAttribArray(VATTR_VERTEX); - glEnableVertexAttribArray(VATTR_TEXCOORD); - glBindVertexArray(0); + glBindVertexArray(vao_id); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glVertexAttribPointer(VATTR_VERTEX, 3,GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); + glVertexAttribPointer(VATTR_TEXCOORD, 2,GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); + glEnableVertexAttribArray(VATTR_VERTEX); + glEnableVertexAttribArray(VATTR_TEXCOORD); + glBindVertexArray(0); + } + else + { + vbo_shadowdata.Reserve(BUFFER_SIZE); + map = &vbo_shadowdata[0]; + } + mNumReserved = mIndex = mCurIndex = 0; } FFlatVertexBuffer::~FFlatVertexBuffer() { - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glUnmapBuffer(GL_ARRAY_BUFFER); - glBindBuffer(GL_ARRAY_BUFFER, 0); + if (gl.flags & RFL_BUFFER_STORAGE) + { + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glUnmapBuffer(GL_ARRAY_BUFFER); + glBindBuffer(GL_ARRAY_BUFFER, 0); + } +} + +//========================================================================== +// +// immediate mode fallback for drivers without GL_ARB_buffer_storage +// +// No single core method is performant enough to handle this adequately +// so we have to resort to immediate mode instead... +// +//========================================================================== + +void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count) +{ + // this will only get called if we can't acquire a persistently mapped buffer. +#ifndef CORE_PROFILE + glBegin(primtype); + for (unsigned int i = 0; i < count; i++) + { + glVertexAttrib2fv(VATTR_TEXCOORD, &map[offset + i].u); + glVertexAttrib3fv(VATTR_VERTEX, &map[offset + i].x); + } + glEnd(); +#endif } //========================================================================== @@ -289,10 +323,24 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) void FFlatVertexBuffer::CreateVBO() { - vbo_shadowdata.Resize(mNumReserved); - CreateFlatVBO(); - mCurIndex = mIndex = vbo_shadowdata.Size(); - memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); + if (gl.flags & RFL_BUFFER_STORAGE) + { + vbo_shadowdata.Resize(mNumReserved); + CreateFlatVBO(); + mCurIndex = mIndex = vbo_shadowdata.Size(); + memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); + } + else if (sectors) + { + // set all VBO info to invalid values so that we can save some checks in the rendering code + for(int i=0;iGetHeightSec(); - if (hs != NULL) CheckPlanes(hs); - for(unsigned i = 0; i < sector->e->XFloor.ffloors.Size(); i++) - CheckPlanes(sector->e->XFloor.ffloors[i]->model); + if (gl.flags & RFL_BUFFER_STORAGE) + { + CheckPlanes(sector); + sector_t *hs = sector->GetHeightSec(); + if (hs != NULL) CheckPlanes(hs); + for (unsigned i = 0; i < sector->e->XFloor.ffloors.Size(); i++) + CheckPlanes(sector->e->XFloor.ffloors[i]->model); + } } \ No newline at end of file diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index de61fb7cb..b6d61f2da 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -83,7 +83,14 @@ public: void RenderArray(unsigned int primtype, unsigned int offset, unsigned int count) { drawcalls.Clock(); - glDrawArrays(primtype, offset, count); + if (gl.flags & RFL_BUFFER_STORAGE) + { + glDrawArrays(primtype, offset, count); + } + else + { + ImmRenderBuffer(primtype, offset, count); + } drawcalls.Unclock(); } diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 4da1d9a42..7a745110b 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -117,9 +117,9 @@ void gl_LoadExtensions() else Printf("Emulating OpenGL v %s\n", version); // Don't even start if it's lower than 3.0 - if (strcmp(version, "3.3") < 0 || !CheckExtension("GL_ARB_buffer_storage")) + if (strcmp(version, "3.3") < 0) { - I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 3.3 and the »GL_ARB_buffer_storage« extension is required to run " GAMENAME ".\n"); + I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 3.3 is required to run " GAMENAME ".\n"); } // add 0.01 to account for roundoff errors making the number a tad smaller than the actual version @@ -130,7 +130,12 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; - if (CheckExtension("GL_ARB_shader_storage_buffer_object")) gl.flags |= RFL_SHADER_STORAGE_BUFFER; + if (!Args->CheckParm("-gl3")) + { + // don't use GL 4.x features when running in GL 3 emulation mode. + if (CheckExtension("GL_ARB_shader_storage_buffer_object")) gl.flags |= RFL_SHADER_STORAGE_BUFFER; + if (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; + } glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 5d59e5560..af4c4f7c2 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -9,7 +9,8 @@ enum RenderFlags RFL_TEXTURE_COMPRESSION=1, RFL_TEXTURE_COMPRESSION_S3TC=2, - RFL_SHADER_STORAGE_BUFFER = 4, // to be used later for a parameter buffer + RFL_SHADER_STORAGE_BUFFER = 4, + RFL_BUFFER_STORAGE = 8 }; enum TexMode diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index ab6d15254..a9911460f 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -726,6 +726,32 @@ bool Win32GLVideo::SetupPixelFormat(int multisample) // //========================================================================== +bool Win32GLVideo::checkCoreUsability() +{ + // if we explicitly want to disable 4.x features this must fail. + if (Args->CheckParm("-gl3")) return false; + + // GL 4.4 implies GL_ARB_buffer_storage + if (strcmp((char*)glGetString(GL_VERSION), "4.4") >= 0) return true; + + // at this point GLEW has not been initialized so we have to retrieve glGetStringi ourselves. + PFNGLGETSTRINGIPROC myglGetStringi = (PFNGLGETSTRINGIPROC)wglGetProcAddress("glGetStringi"); + if (!myglGetStringi) return false; // this should not happen. + + const char *extension; + + int max = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &max); + + // step through all reported extensions and see if we got what we need... + for (int i = 0; i < max; i++) + { + extension = (const char*)myglGetStringi(GL_EXTENSIONS, i); + if (!strcmp(extension, "GL_ARB_buffer_storage")) return true; + } + return false; +} + bool Win32GLVideo::InitHardware (HWND Window, int multisample) { m_Window=Window; @@ -737,36 +763,50 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) return false; } - m_hRC = NULL; - if (myWglCreateContextAttribsARB != NULL) + for (int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; prof <= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; prof++) { - // let's try to get the best version possible. Some drivers only give us the version we request - // which breaks all version checks for feature support. The highest used features we use are from version 4.4, and 3.0 is a requirement. - static int versions[] = { 44, 43, 42, 41, 40, 33, -1 }; - - for (int i = 0; versions[i] > 0; i++) + m_hRC = NULL; + if (myWglCreateContextAttribsARB != NULL) { - int ctxAttribs[] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, versions[i] / 10, - WGL_CONTEXT_MINOR_VERSION_ARB, versions[i] % 10, - WGL_CONTEXT_FLAGS_ARB, gl_debug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - 0 - }; + // let's try to get the best version possible. Some drivers only give us the version we request + // which breaks all version checks for feature support. The highest used features we use are from version 4.4, and 3.3 is a requirement. + static int versions[] = { 45, 44, 43, 42, 41, 40, 33, -1 }; - m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); - if (m_hRC != NULL) break; + for (int i = 0; versions[i] > 0; i++) + { + int ctxAttribs[] = { + WGL_CONTEXT_MAJOR_VERSION_ARB, versions[i] / 10, + WGL_CONTEXT_MINOR_VERSION_ARB, versions[i] % 10, + WGL_CONTEXT_FLAGS_ARB, gl_debug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0, + WGL_CONTEXT_PROFILE_MASK_ARB, prof, + 0 + }; + + m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); + if (m_hRC != NULL) break; + } + } + + if (m_hRC == NULL && prof == WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) + { + Printf("R_OPENGL: Couldn't create render context. Reverting to software mode...\n"); + return false; + } + + wglMakeCurrent(m_hDC, m_hRC); + + // we can only use core profile contexts if GL_ARB_buffer_storage is supported or GL version is >= 4.4 + if (prof == WGL_CONTEXT_CORE_PROFILE_BIT_ARB && !checkCoreUsability()) + { + wglMakeCurrent(0, 0); + wglDeleteContext(m_hRC); + } + else + { + return true; } } - - if (m_hRC == NULL) - { - Printf ("R_OPENGL: Couldn't create render context. Reverting to software mode...\n"); - return false; - } - - wglMakeCurrent(m_hDC, m_hRC); - return true; + return false; } //========================================================================== diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index f61c31857..f425757f1 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -87,6 +87,7 @@ protected: void MakeModesList(); void AddMode(int x, int y, int bits, int baseHeight, int refreshHz); void FreeModes(); + bool checkCoreUsability(); public: int GetTrueHeight() { return m_trueHeight; } From 6f65bccf1c805ef001294b86f604cd49d7a291ec Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 20 Aug 2014 12:45:33 +0200 Subject: [PATCH 0200/1509] - reinstated the far superior assembly HQnX version for Visual C++. --- src/CMakeLists.txt | 6 + src/gl/hqnx_asm/hq2x_asm.cpp | 2991 +++++++++++++++ src/gl/hqnx_asm/hq3x_asm.cpp | 3874 ++++++++++++++++++++ src/gl/hqnx_asm/hq4x_asm.cpp | 5474 ++++++++++++++++++++++++++++ src/gl/hqnx_asm/hqnx_asm.h | 39 + src/gl/hqnx_asm/hqnx_asm_Image.cpp | 1179 ++++++ src/gl/hqnx_asm/hqnx_asm_Image.h | 150 + src/gl/textures/gl_hqresize.cpp | 52 +- 8 files changed, 13761 insertions(+), 4 deletions(-) create mode 100644 src/gl/hqnx_asm/hq2x_asm.cpp create mode 100644 src/gl/hqnx_asm/hq3x_asm.cpp create mode 100644 src/gl/hqnx_asm/hq4x_asm.cpp create mode 100644 src/gl/hqnx_asm/hqnx_asm.h create mode 100644 src/gl/hqnx_asm/hqnx_asm_Image.cpp create mode 100644 src/gl/hqnx_asm/hqnx_asm_Image.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e495f6f6..a219d2054 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -581,6 +581,10 @@ endif( NOT DYN_FLUIDSYNTH ) # Start defining source files for ZDoom set( PLAT_WIN32_SOURCES + gl/hqnx_asm/hq2x_asm.cpp + gl/hqnx_asm/hq3x_asm.cpp + gl/hqnx_asm/hq4x_asm.cpp + gl/hqnx_asm/hqnx_asm_Image.cpp win32/eaxedit.cpp win32/fb_d3d9.cpp win32/fb_d3d9_wipe.cpp @@ -727,6 +731,7 @@ file( GLOB HEADER_FILES gl/data/*.h gl/dynlights/*.h gl/hqnx/*.h + gl/hqnx_asm/*.h gl/models/*.h gl/renderer/*.h gl/scene/*.h @@ -1298,6 +1303,7 @@ source_group("OpenGL Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/ source_group("OpenGL Renderer\\Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/data/.+") source_group("OpenGL Renderer\\Dynamic Lights" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/dynlights/.+") source_group("OpenGL Renderer\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx/.+") +source_group("OpenGL Renderer\\HQ Resize Assembly version" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx_asm/.+") source_group("OpenGL Renderer\\Models" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/models/.+") source_group("OpenGL Renderer\\Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/renderer/.+") source_group("OpenGL Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/scene/.+") diff --git a/src/gl/hqnx_asm/hq2x_asm.cpp b/src/gl/hqnx_asm/hq2x_asm.cpp new file mode 100644 index 000000000..59d52c180 --- /dev/null +++ b/src/gl/hqnx_asm/hq2x_asm.cpp @@ -0,0 +1,2991 @@ +//hq2x filter demo program +//---------------------------------------------------------- +//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +// +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU Lesser General Public +//License as published by the Free Software Foundation; either +//version 2.1 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public +//License along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#include "hqnx_asm.h" + +namespace HQnX_asm +{ + +extern int LUT16to32[65536*2]; +extern int RGBtoYUV[65536*2]; + +static const __int64 reg_blank = 0; +static const __int64 const3 = 0x0003000300030003; +static const __int64 const5 = 0x0005000500050005; +static const __int64 const6 = 0x0006000600060006; +static const __int64 const14 = 0x000E000E000E000E; +static const __int64 treshold = 0x0000000000300706; + +inline void Interp1(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1*3+c2)/4; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + pmullw mm1, const3 + paddw mm1, mm2 + psrlw mm1, 2 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp2(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*2+c2+c3) >> 2; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + psllw mm1, 1 + paddw mm1, mm2 + paddw mm1, mm3 + psrlw mm1, 2 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp5(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1+c2)/2; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + paddw mm1, mm2 + psrlw mm1, 1 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp6(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*5+c2*2+c3)/8; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + pmullw mm1, const5 + psllw mm2, 1 + paddw mm1, mm3 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp7(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*6+c2+c3)/8; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + pmullw mm1, const6 + paddw mm2, mm3 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp9(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*2+(c2+c3)*3)/8; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + psllw mm1, 1 + paddw mm2, mm3 + pmullw mm2, const3 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp10(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*14+c2+c3)/16; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + pmullw mm1, const14 + paddw mm2, mm3 + paddw mm1, mm2 + psrlw mm1, 4 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +#define PIXEL00_0 *((int*)(pOut)) = c[5]; +#define PIXEL00_10 Interp1(pOut, c[5], c[1]); +#define PIXEL00_11 Interp1(pOut, c[5], c[4]); +#define PIXEL00_12 Interp1(pOut, c[5], c[2]); +#define PIXEL00_20 Interp2(pOut, c[5], c[4], c[2]); +#define PIXEL00_21 Interp2(pOut, c[5], c[1], c[2]); +#define PIXEL00_22 Interp2(pOut, c[5], c[1], c[4]); +#define PIXEL00_60 Interp6(pOut, c[5], c[2], c[4]); +#define PIXEL00_61 Interp6(pOut, c[5], c[4], c[2]); +#define PIXEL00_70 Interp7(pOut, c[5], c[4], c[2]); +#define PIXEL00_90 Interp9(pOut, c[5], c[4], c[2]); +#define PIXEL00_100 Interp10(pOut, c[5], c[4], c[2]); +#define PIXEL01_0 *((int*)(pOut+4)) = c[5]; +#define PIXEL01_10 Interp1(pOut+4, c[5], c[3]); +#define PIXEL01_11 Interp1(pOut+4, c[5], c[2]); +#define PIXEL01_12 Interp1(pOut+4, c[5], c[6]); +#define PIXEL01_20 Interp2(pOut+4, c[5], c[2], c[6]); +#define PIXEL01_21 Interp2(pOut+4, c[5], c[3], c[6]); +#define PIXEL01_22 Interp2(pOut+4, c[5], c[3], c[2]); +#define PIXEL01_60 Interp6(pOut+4, c[5], c[6], c[2]); +#define PIXEL01_61 Interp6(pOut+4, c[5], c[2], c[6]); +#define PIXEL01_70 Interp7(pOut+4, c[5], c[2], c[6]); +#define PIXEL01_90 Interp9(pOut+4, c[5], c[2], c[6]); +#define PIXEL01_100 Interp10(pOut+4, c[5], c[2], c[6]); +#define PIXEL10_0 *((int*)(pOut+BpL)) = c[5]; +#define PIXEL10_10 Interp1(pOut+BpL, c[5], c[7]); +#define PIXEL10_11 Interp1(pOut+BpL, c[5], c[8]); +#define PIXEL10_12 Interp1(pOut+BpL, c[5], c[4]); +#define PIXEL10_20 Interp2(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL10_21 Interp2(pOut+BpL, c[5], c[7], c[4]); +#define PIXEL10_22 Interp2(pOut+BpL, c[5], c[7], c[8]); +#define PIXEL10_60 Interp6(pOut+BpL, c[5], c[4], c[8]); +#define PIXEL10_61 Interp6(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL10_70 Interp7(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL10_90 Interp9(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL10_100 Interp10(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL11_0 *((int*)(pOut+BpL+4)) = c[5]; +#define PIXEL11_10 Interp1(pOut+BpL+4, c[5], c[9]); +#define PIXEL11_11 Interp1(pOut+BpL+4, c[5], c[6]); +#define PIXEL11_12 Interp1(pOut+BpL+4, c[5], c[8]); +#define PIXEL11_20 Interp2(pOut+BpL+4, c[5], c[6], c[8]); +#define PIXEL11_21 Interp2(pOut+BpL+4, c[5], c[9], c[8]); +#define PIXEL11_22 Interp2(pOut+BpL+4, c[5], c[9], c[6]); +#define PIXEL11_60 Interp6(pOut+BpL+4, c[5], c[8], c[6]); +#define PIXEL11_61 Interp6(pOut+BpL+4, c[5], c[6], c[8]); +#define PIXEL11_70 Interp7(pOut+BpL+4, c[5], c[6], c[8]); +#define PIXEL11_90 Interp9(pOut+BpL+4, c[5], c[6], c[8]); +#define PIXEL11_100 Interp10(pOut+BpL+4, c[5], c[6], c[8]); + + +int Diff(unsigned int w5, unsigned int w1); + +void DLL hq2x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) +{ + int i, j, k; + int w[10]; + unsigned int c[10]; + + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ + + for (j=0; j0) + { + w[1] = *(pIn - Xres - 1); + } + else + { + w[1] = 0; + } + + w[2] = *(pIn - Xres); + + if (i0) + { + w[4] = *(pIn - 1); + } + else + { + w[4] = 0; + } + + w[5] = *(pIn); + if (i0) + { + w[7] = *(pIn + Xres - 1); + } + else + { + w[7] = 0; + } + + w[8] = *(pIn + Xres); + if (i0) w[1] = *(pIn - Xres - 1); else w[1] = 0; + w[2] = *(pIn - Xres); + if (i0) w[4] = *(pIn - 1); else w[4] = 0; + w[5] = *(pIn); + if (i0) w[7] = *(pIn + Xres - 1); else w[7] = 0; + w[8] = *(pIn + Xres); + if (i +#include +#include +#include +#include "hqnx_asm.h" + +namespace HQnX_asm +{ + +int LUT16to32[65536*2]; +int RGBtoYUV[65536*2]; + +static const __int64 reg_blank = 0; +static const __int64 const3 = 0x0003000300030003; +static const __int64 const5 = 0x0005000500050005; +static const __int64 const6 = 0x0006000600060006; +static const __int64 const7 = 0x0007000700070007; +static const __int64 treshold = 0x0000000000300706; + + +inline void Interp1(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1*3+c2)/4; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + pmullw mm1, const3 + paddw mm1, mm2 + psrlw mm1, 2 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp2(unsigned char * pc, int c1, int c2, int c3) +{ +// *((int*)pc) = (c1*2+c2+c3)/4; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + psllw mm1, 1 + paddw mm1, mm2 + paddw mm1, mm3 + psrlw mm1, 2 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp3(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1*7+c2)/8; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + pmullw mm1, const7 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp5(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1+c2)/2; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + paddw mm1, mm2 + psrlw mm1, 1 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp6(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*5+c2*2+c3)/8; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + pmullw mm1, const5 + psllw mm2, 1 + paddw mm1, mm3 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp7(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*6+c2+c3)/8; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + pmullw mm1, const6 + paddw mm2, mm3 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +inline void Interp8(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1*5+c2*3)/8; + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + pmullw mm1, const5 + pmullw mm2, const3 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + } +} + +#define PIXEL00_0 *((int*)(pOut)) = c[5]; +#define PIXEL00_11 Interp1(pOut, c[5], c[4]); +#define PIXEL00_12 Interp1(pOut, c[5], c[2]); +#define PIXEL00_20 Interp2(pOut, c[5], c[2], c[4]); +#define PIXEL00_50 Interp5(pOut, c[2], c[4]); +#define PIXEL00_80 Interp8(pOut, c[5], c[1]); +#define PIXEL00_81 Interp8(pOut, c[5], c[4]); +#define PIXEL00_82 Interp8(pOut, c[5], c[2]); +#define PIXEL01_0 *((int*)(pOut+4)) = c[5]; +#define PIXEL01_10 Interp1(pOut+4, c[5], c[1]); +#define PIXEL01_12 Interp1(pOut+4, c[5], c[2]); +#define PIXEL01_14 Interp1(pOut+4, c[2], c[5]); +#define PIXEL01_21 Interp2(pOut+4, c[2], c[5], c[4]); +#define PIXEL01_31 Interp3(pOut+4, c[5], c[4]); +#define PIXEL01_50 Interp5(pOut+4, c[2], c[5]); +#define PIXEL01_60 Interp6(pOut+4, c[5], c[2], c[4]); +#define PIXEL01_61 Interp6(pOut+4, c[5], c[2], c[1]); +#define PIXEL01_82 Interp8(pOut+4, c[5], c[2]); +#define PIXEL01_83 Interp8(pOut+4, c[2], c[4]); +#define PIXEL02_0 *((int*)(pOut+8)) = c[5]; +#define PIXEL02_10 Interp1(pOut+8, c[5], c[3]); +#define PIXEL02_11 Interp1(pOut+8, c[5], c[2]); +#define PIXEL02_13 Interp1(pOut+8, c[2], c[5]); +#define PIXEL02_21 Interp2(pOut+8, c[2], c[5], c[6]); +#define PIXEL02_32 Interp3(pOut+8, c[5], c[6]); +#define PIXEL02_50 Interp5(pOut+8, c[2], c[5]); +#define PIXEL02_60 Interp6(pOut+8, c[5], c[2], c[6]); +#define PIXEL02_61 Interp6(pOut+8, c[5], c[2], c[3]); +#define PIXEL02_81 Interp8(pOut+8, c[5], c[2]); +#define PIXEL02_83 Interp8(pOut+8, c[2], c[6]); +#define PIXEL03_0 *((int*)(pOut+12)) = c[5]; +#define PIXEL03_11 Interp1(pOut+12, c[5], c[2]); +#define PIXEL03_12 Interp1(pOut+12, c[5], c[6]); +#define PIXEL03_20 Interp2(pOut+12, c[5], c[2], c[6]); +#define PIXEL03_50 Interp5(pOut+12, c[2], c[6]); +#define PIXEL03_80 Interp8(pOut+12, c[5], c[3]); +#define PIXEL03_81 Interp8(pOut+12, c[5], c[2]); +#define PIXEL03_82 Interp8(pOut+12, c[5], c[6]); +#define PIXEL10_0 *((int*)(pOut+BpL)) = c[5]; +#define PIXEL10_10 Interp1(pOut+BpL, c[5], c[1]); +#define PIXEL10_11 Interp1(pOut+BpL, c[5], c[4]); +#define PIXEL10_13 Interp1(pOut+BpL, c[4], c[5]); +#define PIXEL10_21 Interp2(pOut+BpL, c[4], c[5], c[2]); +#define PIXEL10_32 Interp3(pOut+BpL, c[5], c[2]); +#define PIXEL10_50 Interp5(pOut+BpL, c[4], c[5]); +#define PIXEL10_60 Interp6(pOut+BpL, c[5], c[4], c[2]); +#define PIXEL10_61 Interp6(pOut+BpL, c[5], c[4], c[1]); +#define PIXEL10_81 Interp8(pOut+BpL, c[5], c[4]); +#define PIXEL10_83 Interp8(pOut+BpL, c[4], c[2]); +#define PIXEL11_0 *((int*)(pOut+BpL+4)) = c[5]; +#define PIXEL11_30 Interp3(pOut+BpL+4, c[5], c[1]); +#define PIXEL11_31 Interp3(pOut+BpL+4, c[5], c[4]); +#define PIXEL11_32 Interp3(pOut+BpL+4, c[5], c[2]); +#define PIXEL11_70 Interp7(pOut+BpL+4, c[5], c[4], c[2]); +#define PIXEL12_0 *((int*)(pOut+BpL+8)) = c[5]; +#define PIXEL12_30 Interp3(pOut+BpL+8, c[5], c[3]); +#define PIXEL12_31 Interp3(pOut+BpL+8, c[5], c[2]); +#define PIXEL12_32 Interp3(pOut+BpL+8, c[5], c[6]); +#define PIXEL12_70 Interp7(pOut+BpL+8, c[5], c[6], c[2]); +#define PIXEL13_0 *((int*)(pOut+BpL+12)) = c[5]; +#define PIXEL13_10 Interp1(pOut+BpL+12, c[5], c[3]); +#define PIXEL13_12 Interp1(pOut+BpL+12, c[5], c[6]); +#define PIXEL13_14 Interp1(pOut+BpL+12, c[6], c[5]); +#define PIXEL13_21 Interp2(pOut+BpL+12, c[6], c[5], c[2]); +#define PIXEL13_31 Interp3(pOut+BpL+12, c[5], c[2]); +#define PIXEL13_50 Interp5(pOut+BpL+12, c[6], c[5]); +#define PIXEL13_60 Interp6(pOut+BpL+12, c[5], c[6], c[2]); +#define PIXEL13_61 Interp6(pOut+BpL+12, c[5], c[6], c[3]); +#define PIXEL13_82 Interp8(pOut+BpL+12, c[5], c[6]); +#define PIXEL13_83 Interp8(pOut+BpL+12, c[6], c[2]); +#define PIXEL20_0 *((int*)(pOut+BpL+BpL)) = c[5]; +#define PIXEL20_10 Interp1(pOut+BpL+BpL, c[5], c[7]); +#define PIXEL20_12 Interp1(pOut+BpL+BpL, c[5], c[4]); +#define PIXEL20_14 Interp1(pOut+BpL+BpL, c[4], c[5]); +#define PIXEL20_21 Interp2(pOut+BpL+BpL, c[4], c[5], c[8]); +#define PIXEL20_31 Interp3(pOut+BpL+BpL, c[5], c[8]); +#define PIXEL20_50 Interp5(pOut+BpL+BpL, c[4], c[5]); +#define PIXEL20_60 Interp6(pOut+BpL+BpL, c[5], c[4], c[8]); +#define PIXEL20_61 Interp6(pOut+BpL+BpL, c[5], c[4], c[7]); +#define PIXEL20_82 Interp8(pOut+BpL+BpL, c[5], c[4]); +#define PIXEL20_83 Interp8(pOut+BpL+BpL, c[4], c[8]); +#define PIXEL21_0 *((int*)(pOut+BpL+BpL+4)) = c[5]; +#define PIXEL21_30 Interp3(pOut+BpL+BpL+4, c[5], c[7]); +#define PIXEL21_31 Interp3(pOut+BpL+BpL+4, c[5], c[8]); +#define PIXEL21_32 Interp3(pOut+BpL+BpL+4, c[5], c[4]); +#define PIXEL21_70 Interp7(pOut+BpL+BpL+4, c[5], c[4], c[8]); +#define PIXEL22_0 *((int*)(pOut+BpL+BpL+8)) = c[5]; +#define PIXEL22_30 Interp3(pOut+BpL+BpL+8, c[5], c[9]); +#define PIXEL22_31 Interp3(pOut+BpL+BpL+8, c[5], c[6]); +#define PIXEL22_32 Interp3(pOut+BpL+BpL+8, c[5], c[8]); +#define PIXEL22_70 Interp7(pOut+BpL+BpL+8, c[5], c[6], c[8]); +#define PIXEL23_0 *((int*)(pOut+BpL+BpL+12)) = c[5]; +#define PIXEL23_10 Interp1(pOut+BpL+BpL+12, c[5], c[9]); +#define PIXEL23_11 Interp1(pOut+BpL+BpL+12, c[5], c[6]); +#define PIXEL23_13 Interp1(pOut+BpL+BpL+12, c[6], c[5]); +#define PIXEL23_21 Interp2(pOut+BpL+BpL+12, c[6], c[5], c[8]); +#define PIXEL23_32 Interp3(pOut+BpL+BpL+12, c[5], c[8]); +#define PIXEL23_50 Interp5(pOut+BpL+BpL+12, c[6], c[5]); +#define PIXEL23_60 Interp6(pOut+BpL+BpL+12, c[5], c[6], c[8]); +#define PIXEL23_61 Interp6(pOut+BpL+BpL+12, c[5], c[6], c[9]); +#define PIXEL23_81 Interp8(pOut+BpL+BpL+12, c[5], c[6]); +#define PIXEL23_83 Interp8(pOut+BpL+BpL+12, c[6], c[8]); +#define PIXEL30_0 *((int*)(pOut+BpL+BpL+BpL)) = c[5]; +#define PIXEL30_11 Interp1(pOut+BpL+BpL+BpL, c[5], c[8]); +#define PIXEL30_12 Interp1(pOut+BpL+BpL+BpL, c[5], c[4]); +#define PIXEL30_20 Interp2(pOut+BpL+BpL+BpL, c[5], c[8], c[4]); +#define PIXEL30_50 Interp5(pOut+BpL+BpL+BpL, c[8], c[4]); +#define PIXEL30_80 Interp8(pOut+BpL+BpL+BpL, c[5], c[7]); +#define PIXEL30_81 Interp8(pOut+BpL+BpL+BpL, c[5], c[8]); +#define PIXEL30_82 Interp8(pOut+BpL+BpL+BpL, c[5], c[4]); +#define PIXEL31_0 *((int*)(pOut+BpL+BpL+BpL+4)) = c[5]; +#define PIXEL31_10 Interp1(pOut+BpL+BpL+BpL+4, c[5], c[7]); +#define PIXEL31_11 Interp1(pOut+BpL+BpL+BpL+4, c[5], c[8]); +#define PIXEL31_13 Interp1(pOut+BpL+BpL+BpL+4, c[8], c[5]); +#define PIXEL31_21 Interp2(pOut+BpL+BpL+BpL+4, c[8], c[5], c[4]); +#define PIXEL31_32 Interp3(pOut+BpL+BpL+BpL+4, c[5], c[4]); +#define PIXEL31_50 Interp5(pOut+BpL+BpL+BpL+4, c[8], c[5]); +#define PIXEL31_60 Interp6(pOut+BpL+BpL+BpL+4, c[5], c[8], c[4]); +#define PIXEL31_61 Interp6(pOut+BpL+BpL+BpL+4, c[5], c[8], c[7]); +#define PIXEL31_81 Interp8(pOut+BpL+BpL+BpL+4, c[5], c[8]); +#define PIXEL31_83 Interp8(pOut+BpL+BpL+BpL+4, c[8], c[4]); +#define PIXEL32_0 *((int*)(pOut+BpL+BpL+BpL+8)) = c[5]; +#define PIXEL32_10 Interp1(pOut+BpL+BpL+BpL+8, c[5], c[9]); +#define PIXEL32_12 Interp1(pOut+BpL+BpL+BpL+8, c[5], c[8]); +#define PIXEL32_14 Interp1(pOut+BpL+BpL+BpL+8, c[8], c[5]); +#define PIXEL32_21 Interp2(pOut+BpL+BpL+BpL+8, c[8], c[5], c[6]); +#define PIXEL32_31 Interp3(pOut+BpL+BpL+BpL+8, c[5], c[6]); +#define PIXEL32_50 Interp5(pOut+BpL+BpL+BpL+8, c[8], c[5]); +#define PIXEL32_60 Interp6(pOut+BpL+BpL+BpL+8, c[5], c[8], c[6]); +#define PIXEL32_61 Interp6(pOut+BpL+BpL+BpL+8, c[5], c[8], c[9]); +#define PIXEL32_82 Interp8(pOut+BpL+BpL+BpL+8, c[5], c[8]); +#define PIXEL32_83 Interp8(pOut+BpL+BpL+BpL+8, c[8], c[6]); +#define PIXEL33_0 *((int*)(pOut+BpL+BpL+BpL+12)) = c[5]; +#define PIXEL33_11 Interp1(pOut+BpL+BpL+BpL+12, c[5], c[6]); +#define PIXEL33_12 Interp1(pOut+BpL+BpL+BpL+12, c[5], c[8]); +#define PIXEL33_20 Interp2(pOut+BpL+BpL+BpL+12, c[5], c[8], c[6]); +#define PIXEL33_50 Interp5(pOut+BpL+BpL+BpL+12, c[8], c[6]); +#define PIXEL33_80 Interp8(pOut+BpL+BpL+BpL+12, c[5], c[9]); +#define PIXEL33_81 Interp8(pOut+BpL+BpL+BpL+12, c[5], c[6]); +#define PIXEL33_82 Interp8(pOut+BpL+BpL+BpL+12, c[5], c[8]); + + +#pragma warning(disable: 4035) + +int Diff(unsigned int w5, unsigned int w1) +{ + __asm + { + xor eax,eax + mov ebx,w5 + mov edx,w1 + cmp ebx,edx + je FIN + mov ecx,offset RGBtoYUV + movd mm1,[ecx + ebx*4] + movq mm5,mm1 + movd mm2,[ecx + edx*4] + psubusb mm1,mm2 + psubusb mm2,mm5 + por mm1,mm2 + psubusb mm1,treshold + movd eax,mm1 +FIN: + } +} +// returns result in eax register + +#pragma warning(default: 4035) + +void DLL hq4x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) +{ + int i, j, k; + int w[10]; + int c[10]; + + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ + + for (j = 0; j < Yres; j++) + { + for (i = 0; i < Xres; i++) + { + if (j == 0) + { + w[1] = 0; + w[2] = 0; + w[3] = 0; + } + else + { + if (i > 0) + w[1] = *(pIn - Xres - 1); + else + w[1] = 0; + + w[2] = *(pIn - Xres); + + if (i < Xres - 1) + w[3] = *(pIn - Xres + 1); + else + w[3] = 0; + } + + if (i > 0) + w[4] = *(pIn - 1); + else + w[4] = 0; + + w[5] = *(pIn); + + if (i < Xres - 1) + w[6] = *(pIn + 1); + else + w[6] = 0; + + if (j == Yres - 1) + { + w[7] = 0; + w[8] = 0; + w[9] = 0; + } + else + { + if (i > 0) + w[7] = *(pIn + Xres - 1); + else + w[7] = 0; + + w[8] = *(pIn + Xres); + + if (i < Xres-1) + w[9] = *(pIn + Xres + 1); + else + w[9] = 0; + } + + int pattern = 0; + + if ( Diff(w[5],w[1]) ) pattern |= 0x0001; + if ( Diff(w[5],w[2]) ) pattern |= 0x0002; + if ( Diff(w[5],w[3]) ) pattern |= 0x0004; + if ( Diff(w[5],w[4]) ) pattern |= 0x0008; + if ( Diff(w[5],w[6]) ) pattern |= 0x0010; + if ( Diff(w[5],w[7]) ) pattern |= 0x0020; + if ( Diff(w[5],w[8]) ) pattern |= 0x0040; + if ( Diff(w[5],w[9]) ) pattern |= 0x0080; + + for (k=1; k<=9; k++) + c[k] = LUT16to32[w[k]]; + + switch (pattern) + { + case 0: + case 1: + case 4: + case 32: + case 128: + case 5: + case 132: + case 160: + case 33: + case 129: + case 36: + case 133: + case 164: + case 161: + case 37: + case 165: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 2: + case 34: + case 130: + case 162: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 16: + case 17: + case 48: + case 49: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 64: + case 65: + case 68: + case 69: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 8: + case 12: + case 136: + case 140: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 3: + case 35: + case 131: + case 163: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 6: + case 38: + case 134: + case 166: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 20: + case 21: + case 52: + case 53: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 144: + case 145: + case 176: + case 177: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 192: + case 193: + case 196: + case 197: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 96: + case 97: + case 100: + case 101: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 40: + case 44: + case 168: + case 172: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 9: + case 13: + case 137: + case 141: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 18: + case 50: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL12_0 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 80: + case 81: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 72: + case 76: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_50 + PIXEL21_0 + PIXEL30_50 + PIXEL31_50 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 10: + case 138: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 66: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 24: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 7: + case 39: + case 135: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 148: + case 149: + case 180: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 224: + case 228: + case 225: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 41: + case 169: + case 45: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 22: + case 54: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 208: + case 209: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 104: + case 108: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 11: + case 139: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 19: + case 51: + { + if (Diff(w[2], w[6])) + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 146: + case 178: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + PIXEL23_32 + PIXEL33_82 + } + else + { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + break; + } + case 84: + case 85: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + if (Diff(w[6], w[8])) + { + PIXEL03_81 + PIXEL13_31 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL20_61 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; + } + case 112: + case 113: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; + } + case 200: + case 204: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + } + else + { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; + } + case 73: + case 77: + { + if (Diff(w[8], w[4])) + { + PIXEL00_82 + PIXEL10_32 + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 42: + case 170: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + PIXEL20_31 + PIXEL30_81 + } + else + { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 14: + case 142: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 67: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 70: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 28: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 152: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 194: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 98: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 56: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 25: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 26: + case 31: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL11_0 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 82: + case 214: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 88: + case 248: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 74: + case 107: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 27: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 86: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 216: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 106: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 30: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 210: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 120: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 75: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 29: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 198: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 184: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 99: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 57: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 71: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 156: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 226: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 60: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 195: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 102: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 153: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 58: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 83: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 92: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 202: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 78: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 154: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 114: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 89: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 90: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 55: + case 23: + { + if (Diff(w[2], w[6])) + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + } + else + { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 182: + case 150: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + PIXEL23_32 + PIXEL33_82 + } + else + { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + break; + } + case 213: + case 212: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + if (Diff(w[6], w[8])) + { + PIXEL03_81 + PIXEL13_31 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL20_61 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; + } + case 241: + case 240: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; + } + case 236: + case 232: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + } + else + { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; + } + case 109: + case 105: + { + if (Diff(w[8], w[4])) + { + PIXEL00_82 + PIXEL10_32 + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 171: + case 43: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + PIXEL11_0 + PIXEL20_31 + PIXEL30_81 + } + else + { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 143: + case 15: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + } + else + { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 124: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 203: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 62: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 211: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 118: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 217: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 110: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 155: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 188: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 185: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 61: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 157: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 103: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 227: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 230: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 199: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 220: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 158: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 234: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 242: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 59: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL11_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 121: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 87: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 79: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_32 + PIXEL03_82 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 122: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 94: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 218: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 91: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL11_0 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 229: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 167: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 173: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 181: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 186: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 115: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 93: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 206: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 205: + case 201: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 174: + case 46: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 179: + case 147: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 117: + case 116: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 189: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 231: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 126: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 219: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 125: + { + if (Diff(w[8], w[4])) + { + PIXEL00_82 + PIXEL10_32 + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 221: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + if (Diff(w[6], w[8])) + { + PIXEL03_81 + PIXEL13_31 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; + } + case 207: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + } + else + { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 238: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + } + else + { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; + } + case 190: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + PIXEL23_32 + PIXEL33_82 + } + else + { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_10 + PIXEL11_30 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + break; + } + case 187: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + PIXEL11_0 + PIXEL20_31 + PIXEL30_81 + } + else + { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 243: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; + } + case 119: + { + if (Diff(w[2], w[6])) + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + } + else + { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 237: + case 233: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; + } + case 175: + case 47: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 183: + case 151: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 245: + case 244: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 250: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 123: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 95: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL11_0 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 222: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 252: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 249: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + break; + } + case 235: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; + } + case 111: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 63: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 159: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 215: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 246: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 254: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 253: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 251: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + break; + } + case 239: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; + } + case 127: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 191: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 223: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 247: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 255: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + } + pIn++; // next source pixel (just increment since it's an int*) + pOut += 16; // skip 4 pixels (4 bytes * 4 pixels) + } + pOut += BpL; // skip next 3 rows + pOut += BpL; + pOut += BpL; + } + __asm emms +} + +void DLL InitLUTs() +{ + int i, j, k, r, g, b, Y, u, v; + +#if 0 // colorOutlines() after hqresize + for (i=0; i<65536; i++) + LUT16to32[i] = 0x00404040; + for (i=0; i<65536; i++) + LUT16to32[i+65536] = 0xFF000000 + ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3); +#else // colorOutlines() before hqresize + for (i=0; i<65536; i++) + LUT16to32[i] = ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3); + for (i=0; i<65536; i++) + LUT16to32[i+65536] = 0xFF000000 + LUT16to32[i]; +#endif + + for (i=0; i<65536; i++) + RGBtoYUV[i] = 0xFF000000; + + for (i=0; i<32; i++) + for (j=0; j<64; j++) + for (k=0; k<32; k++) + { + r = i << 3; + g = j << 2; + b = k << 3; + Y = (r + g + b) >> 2; + u = 128 + ((r - b) >> 2); + v = 128 + ((-r + 2*g -b)>>3); + RGBtoYUV[ 65536 + (i << 11) + (j << 5) + k ] = (Y<<16) + (u<<8) + v; + } +} + +/* +int DLL hq4x_32 ( CImage &ImageIn, CImage &ImageOut ) +{ + if ( ImageIn.Convert32To17() != 0 ) + { + printf( "ERROR: conversion to 17 bit failed\n" ); + return 1; + } + + if ( ImageOut.Init( ImageIn.m_Xres*4, ImageIn.m_Yres*4, 32 ) != 0 ) + { + printf( "ERROR: ImageOut.Init()\n" ); + return 1; + }; + + InitLUTs(); + hq4x_32( (int*)ImageIn.m_pBitmap, ImageOut.m_pBitmap, ImageIn.m_Xres, ImageIn.m_Yres, ImageOut.m_Xres*4 ); + + printf( "\nOK\n" ); + return 0; +} +*/ + +} \ No newline at end of file diff --git a/src/gl/hqnx_asm/hqnx_asm.h b/src/gl/hqnx_asm/hqnx_asm.h new file mode 100644 index 000000000..341e2dad3 --- /dev/null +++ b/src/gl/hqnx_asm/hqnx_asm.h @@ -0,0 +1,39 @@ +//hqnx filter library +//---------------------------------------------------------- +//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +//Copyright (C) 2009 Benjamin Berkels +// +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU Lesser General Public +//License as published by the Free Software Foundation; either +//version 2.1 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public +//License along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef __HQNX_H__ +#define __HQNX_H__ + +#pragma warning(disable:4799) + +#include "hqnx_asm_Image.h" + +namespace HQnX_asm +{ +void DLL hq2x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ); +void DLL hq3x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ); +void DLL hq4x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ); +int DLL hq4x_32 ( CImage &ImageIn, CImage &ImageOut ); + +void DLL InitLUTs(); + +} + + +#endif //__HQNX_H__ \ No newline at end of file diff --git a/src/gl/hqnx_asm/hqnx_asm_Image.cpp b/src/gl/hqnx_asm/hqnx_asm_Image.cpp new file mode 100644 index 000000000..be7d1b350 --- /dev/null +++ b/src/gl/hqnx_asm/hqnx_asm_Image.cpp @@ -0,0 +1,1179 @@ +//CImage class - loading and saving BMP and TGA files +//---------------------------------------------------------- +//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +// +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU Lesser General Public +//License as published by the Free Software Foundation; either +//version 2.1 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public +//License along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#include +#include +#include "hqnx_asm_Image.h" + +namespace HQnX_asm +{ + +DLL CImage::CImage() +{ + m_Xres = m_Yres = m_NumPixel = 0; + m_pBitmap = NULL; +} + +DLL CImage::~CImage() +{ + Destroy(); +} + +int DLL CImage::Init( int X, int Y, unsigned short BitPerPixel ) +{ + if (m_pBitmap != NULL) + free(m_pBitmap); + + m_Xres = X; + m_Yres = Y; + m_BitPerPixel = BitPerPixel<=8 ? 8 : BitPerPixel<=16 ? 16 : BitPerPixel<=24 ? 24 : 32; + m_BytePerPixel = m_BitPerPixel >> 3; + m_NumPixel = m_Xres*m_Yres; + int size = m_NumPixel*((m_BitPerPixel+7)/8); + m_pBitmap=(unsigned char *)malloc(size); + return (m_pBitmap != NULL) ? 0 : 1; +} + +int DLL CImage::SetImage(unsigned char *img, int width, int height, int bpp) +{ + Init(width, height, bpp); + + memcpy(m_pBitmap, img, m_NumPixel * m_BytePerPixel); + + return 0; +} + +int DLL CImage::Destroy() +{ + if (m_pBitmap) + { + free(m_pBitmap); + m_pBitmap = NULL; + } + m_Xres = 0; + m_Yres = 0; + m_NumPixel = 0; + m_BitPerPixel = 0; + return 0; +} + +int DLL CImage::Convert32To17( void ) +{ + int nRes = eConvUnknownFormat; + + if ( m_BitPerPixel == 32 ) + { + if ( m_pBitmap != NULL ) + { + unsigned char * pTemp8 = m_pBitmap; + unsigned int * pTemp32 = (unsigned int *)m_pBitmap; + unsigned int a, r, g, b; + for ( int i=0; i> 3; + g = (*(pTemp8++)) >> 2; + r = (*(pTemp8++)) >> 3; + a = *(pTemp8++); + *pTemp32 = (r << 11) + (g << 5) + b + (a > 127 ? 0x10000 : 0); + pTemp32++; + } + } + else + nRes = eConvSourceMemory; + + nRes = 0; + } + + return nRes; +} + +int DLL CImage::ConvertTo32( void ) +{ + int nRes = eConvUnknownFormat; + + if ( m_pBitmap == NULL ) + return eConvSourceMemory; + + switch ( m_BitPerPixel ) + { + case 8: + { + nRes = 0; + m_BitPerPixel = 32; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*4); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp8 = m_pBitmap; + unsigned char * pTemp32 = pNewBitmap; + unsigned char c; + for ( int i=0; i> 3); + *(pTemp24++) = ((rgb & 0xF800) >> 8); + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + break; + } + case 32: + { + nRes = 0; + m_BitPerPixel = 24; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*3); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp32 = m_pBitmap; + unsigned char * pTemp24 = pNewBitmap; + for ( int i=0; i> 3; + g = m_Pal[c].g >> 2; + b = m_Pal[c].b >> 3; + *(pTemp16++) = (r << 11) + (g << 5) + b; + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + break; + } + case 24: + { + nRes = 0; + m_BitPerPixel = 16; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*2); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp24 = m_pBitmap; + unsigned short * pTemp16 = (unsigned short *)pNewBitmap; + unsigned short r, g, b; + for ( int i=0; i> 3; + g = (*(pTemp24++)) >> 2; + r = (*(pTemp24++)) >> 3; + *(pTemp16++) = (r << 11) + (g << 5) + b; + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + break; + } + case 32: + { + nRes = 0; + m_BitPerPixel = 16; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*2); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp32 = m_pBitmap; + unsigned short * pTemp16 = (unsigned short *)pNewBitmap; + unsigned short r, g, b; + for ( int i=0; i> 3; + g = (*(pTemp32++)) >> 2; + r = (*(pTemp32++)) >> 3; + pTemp32++; + *(pTemp16++) = (r << 11) + (g << 5) + b; + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + break; + } + } + + return nRes; +} + +int CImage::Convert8To17( int transindex ) +{ + int nRes = eConvUnknownFormat; + + if ( m_BitPerPixel == 8 ) + { + m_BitPerPixel = 32; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*4); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp8 = m_pBitmap; + unsigned int * pTemp32 = (unsigned int *)pNewBitmap; + unsigned int r, g, b; + unsigned char c; + for ( int i=0; i> 3; + g = m_Pal[c].g >> 2; + b = m_Pal[c].b >> 3; + *(pTemp32++) = (r << 11) + (g << 5) + b + (transindex != c ? 0x10000 : 0); + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + nRes = 0; + } + + return nRes; +} + +int CImage::SaveBmp(char *szFilename) +{ + _BMPFILEHEADER fh; + _BMPIMAGEHEADER ih; + unsigned char BmpPal[256][4]; + long int SuffLen; + long int Dummy = 0; + unsigned char * pBuf; + short i; + + if (!(f = fopen(szFilename, "wb"))) return eSaveBmpFileOpen; + if ( m_pBitmap == NULL ) return eSaveBmpSourceMemory; + + fh.bfType=0x4D42; + if (m_BitPerPixel==8) + { + SuffLen=((m_Xres+3)/4)*4-m_Xres; + ih.biSize=0x28; + ih.biWidth=m_Xres; + ih.biHeight=m_Yres; + ih.biPlanes=1; + ih.biBitCount=8; + ih.biCompression=0; + ih.biSizeImage=(m_Xres+SuffLen)*m_Yres; + ih.biXPelsPerMeter=ih.biYPelsPerMeter=0x2E23; // 300dpi (pixels per meter) + ih.biClrUsed=ih.biClrImportant=0; + fh.bfSize=(ih.biSizeImage)+0x0436; + fh.bfRes1=0; + fh.bfOffBits=0x0436; + if (fwrite(&fh, 14, 1, f) != 1) return eSaveBmpFileWrite; + if (fwrite(&ih, 40, 1, f) != 1) return eSaveBmpFileWrite; + for (i=0; i<256; i++) + { + BmpPal[i][0]=m_Pal[i].b; + BmpPal[i][1]=m_Pal[i].g; + BmpPal[i][2]=m_Pal[i].r; + BmpPal[i][3]=0; + } + if (fwrite(&BmpPal, 1024, 1, f) != 1) return eSaveBmpFileWrite; + pBuf=m_pBitmap; + pBuf+=m_NumPixel; + for (i=0; i0) + { + if (fwrite(&Dummy, SuffLen, 1, f) != 1) return eSaveBmpFileWrite; + } + } + } + else + if (m_BitPerPixel==24) + { + SuffLen=((m_Xres*3+3)/4)*4-m_Xres*3; + ih.biSize=0x28; + ih.biWidth=m_Xres; + ih.biHeight=m_Yres; + ih.biPlanes=1; + ih.biBitCount=24; + ih.biCompression=0; + ih.biSizeImage=(m_Xres*3+SuffLen)*m_Yres; + ih.biXPelsPerMeter=ih.biYPelsPerMeter=0x2E23; // 300dpi (pixels per meter) + ih.biClrUsed=ih.biClrImportant=0; + fh.bfSize=(ih.biSizeImage)+0x0036; + fh.bfRes1=0; + fh.bfOffBits=0x0036; + if (fwrite(&fh, 14, 1, f) != 1) return eSaveBmpFileWrite; + if (fwrite(&ih, 40, 1, f) != 1) return eSaveBmpFileWrite; + pBuf=m_pBitmap; + pBuf+=m_NumPixel*3; + for (i=0; i0) + { + if (fwrite(&Dummy, SuffLen, 1, f) != 1) return eSaveBmpFileWrite; + } + } + } + else + return eSaveBmpColorDepth; + + fclose(f); + + return 0; +} + +int CImage::LoadBmp(char *szFilename) +{ + _BMPFILEHEADER fh; + _BMPIMAGEHEADEROLD ih_old; + _BMPIMAGEHEADER ih; + unsigned char BmpPal[256][4]; + long int biSize; + long int SuffLen; + long int Dummy = 0; + unsigned char * pBuf; + short i; + long int xres, yres; + unsigned short bits; + + if (!(f = fopen(szFilename, "rb"))) return eLoadBmpFileOpen; + if (fread(&fh, 14, 1, f) != 1) return eLoadBmpFileRead; + if (fh.bfType != 0x4D42) return eLoadBmpBadFormat; + if (fread(&biSize, 4, 1, f) != 1) return eLoadBmpFileRead; + if (biSize > 12) + { + fseek( f, -4, SEEK_CUR ); + if (fread(&ih, biSize, 1, f) != 1) return eLoadBmpFileRead; + xres = ih.biWidth; + yres = ih.biHeight; + bits = ih.biBitCount; + } + else + { + fseek( f, -4, SEEK_CUR ); + if (fread(&ih_old, biSize, 1, f) != 1) return eLoadBmpFileRead; + xres = ih_old.biWidth; + yres = ih_old.biHeight; + bits = ih_old.biBitCount; + } + + if ( Init( xres, yres, bits ) != 0 ) return eLoadBmpInit; + if (m_BitPerPixel==8) + { + SuffLen=((m_Xres+3)/4)*4-m_Xres; + if (fread(&BmpPal, 1024, 1, f) != 1) return eLoadBmpFileRead; + for (i=0; i<256; i++) + { + m_Pal[i].b=BmpPal[i][0]; + m_Pal[i].g=BmpPal[i][1]; + m_Pal[i].r=BmpPal[i][2]; + } + pBuf=m_pBitmap; + pBuf+=m_NumPixel; + for (i=0; i0) + { + if (fread(&Dummy, SuffLen, 1, f) != 1) return eLoadBmpFileRead; + } + } + } + else + if (m_BitPerPixel==24) + { + SuffLen=((m_Xres*3+3)/4)*4-(m_Xres*3); + pBuf=m_pBitmap; + pBuf+=m_NumPixel*3; + for (i=0; i0) + { + if (fread(&Dummy, SuffLen, 1, f) != 1) return eLoadBmpFileRead; + } + } + } + else + return eLoadBmpColorDepth; + + fclose(f); + + return 0; +} + +void CImage::Output( void ) +{ + fwrite(m_cBuf, m_nCount, 1, f); + m_nCount=0; +} + +void CImage::Output( char c ) +{ + if ( m_nCount == sizeof(m_cBuf) ) + { + fwrite(m_cBuf, m_nCount, 1, f); + m_nCount=0; + } + m_cBuf[m_nCount++] = c; +} + +void CImage::Output( char * pcData, int nSize ) +{ + for ( int i=0; i 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+i-nDif-nRep), nDif ); + } + nDif = 1; + } + } + else + { + if ( bEqual && (nRep<127) ) + nRep++; + else + { + Output( nRep+128 ); + Output( (char*)&colOld, 1 ); + nRep = 0; + nDif = 1; + } + } + } + + if ( nRep == 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+m_Xres-nDif), nDif ); + } + else + { + Output( nRep+128 ); + Output( (char*)&colOld, 1 ); + } + Output(); + } + } + } + else + if (m_BitPerPixel==24) + { + fh.tiImageType = bCompressed ? 10 : 2; + if (fwrite(&fh, sizeof(fh), 1, f) != 1) return eSaveTgaFileWrite; + + _BGR * pcolBuf = (_BGR *)m_pBitmap; + pcolBuf += m_NumPixel; + + if ( !bCompressed ) + { + for (j=0; j 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+i-nDif-nRep), sizeof(_BGR)*nDif ); + } + nDif = 1; + } + } + else + { + if ( bEqual && (nRep<127) ) + nRep++; + else + { + Output( nRep+128 ); + Output( (char*)&colOld, sizeof(_BGR) ); + nRep = 0; + nDif = 1; + } + } + } + + if ( nRep == 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+m_Xres-nDif), sizeof(_BGR)*nDif ); + } + else + { + Output( nRep+128 ); + Output( (char*)&colOld, sizeof(_BGR) ); + } + Output(); + } + } + } + else + if (m_BitPerPixel==32) + { + fh.tiImageType = bCompressed ? 10 : 2; + fh.tiAttrBits = 8; + if (fwrite(&fh, sizeof(fh), 1, f) != 1) return eSaveTgaFileWrite; + + _BGRA * pcolBuf = (_BGRA *)m_pBitmap; + pcolBuf += m_NumPixel; + + if ( !bCompressed ) + { + for (j=0; j 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+i-nDif-nRep), sizeof(_BGRA)*nDif ); + } + nDif = 1; + } + } + else + { + if ( bEqual && (nRep<127) ) + nRep++; + else + { + Output( nRep+128 ); + Output( (char*)&colOld, sizeof(_BGRA) ); + nRep = 0; + nDif = 1; + } + } + } + + if ( nRep == 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+m_Xres-nDif), sizeof(_BGRA)*nDif ); + } + else + { + Output( nRep+128 ); + Output( (char*)&colOld, sizeof(_BGRA) ); + } + Output(); + } + } + } + else + return eSaveTgaColorDepth; + + fclose(f); + + return 0; +} + +int CImage::LoadTga(char *szFilename) +{ + _TGAHEADER fh; + int i, j, k; + unsigned char nCount; + + if (!(f = fopen(szFilename, "rb"))) return eLoadTgaFileOpen; + if (fread(&fh, sizeof(fh), 1, f) != 1) return eLoadTgaFileRead; + bool bCompressed = (( fh.tiImageType & 8 ) != 0); + if ((fh.tiBitPerPixel<=0) || (fh.tiBitPerPixel>32)) + return eLoadTgaBadFormat; + + if ( Init( fh.tiXres, fh.tiYres, fh.tiBitPerPixel ) != 0 ) + return eLoadTgaInit; + + if ( m_BitPerPixel == 8 ) + { + if ( fh.tiPaletteIncluded == 1 ) + { + if ( fh.tiPaletteBpp == 24) + { + if (fread(&m_Pal, 3, fh.tiPaletteSize, f) != fh.tiPaletteSize) + return eLoadTgaFileRead; + } + else + if ( fh.tiPaletteBpp == 32) + { + unsigned char BmpPal[256][4]; + + if (fread(&BmpPal, 4, fh.tiPaletteSize, f) != fh.tiPaletteSize) + return eLoadTgaFileRead; + + for (i=0; i= m_pBitmap ) + { + nCount = Input(); + if ((nCount & 128)==0) + { + for (k=0; k<=nCount; k++) + { + colCur = Input(); + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + else + { + colCur = Input(); + for (k=0; k<=nCount-128; k++) + { + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + } + } + } + else + if ( m_BitPerPixel == 24 ) + { + _BGR * pcolBuf = (_BGR *)m_pBitmap; + pcolBuf += m_NumPixel; + + if ( !bCompressed ) + { + for (j=0; j= (_BGR *)m_pBitmap ) + { + nCount = Input(); + if ((nCount & 128)==0) + { + for (k=0; k<=nCount; k++) + { + colCur.b = Input(); + colCur.g = Input(); + colCur.r = Input(); + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + else + { + colCur.b = Input(); + colCur.g = Input(); + colCur.r = Input(); + for (k=0; k<=nCount-128; k++) + { + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + } + } + } + else + if ( m_BitPerPixel == 32 ) + { + _BGRA * pcolBuf = (_BGRA *)m_pBitmap; + pcolBuf += m_NumPixel; + + if ( !bCompressed ) + { + for (j=0; j= (_BGRA *)m_pBitmap ) + { + nCount = Input(); + if ((nCount & 128)==0) + { + for (k=0; k<=nCount; k++) + { + colCur.b = Input(); + colCur.g = Input(); + colCur.r = Input(); + colCur.a = Input(); + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + else + { + colCur.b = Input(); + colCur.g = Input(); + colCur.r = Input(); + colCur.a = Input(); + for (k=0; k<=nCount-128; k++) + { + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + } + } + } + else + return eLoadTgaColorDepth; + + fclose(f); + + return 0; +} + +int DLL CImage::Load(char *szFilename) +{ + int nRes = 0; + + if ( szFilename != NULL ) + { + char * szExt = strrchr( szFilename, '.' ); + int nNotTGA = 1; + + if ( szExt != NULL ) + nNotTGA = _stricmp( szExt, ".tga" ); + + if ( nNotTGA != 0 ) + nRes = LoadBmp( szFilename ); + else + nRes = LoadTga( szFilename ); + } + else + nRes = eLoadFilename; + + return nRes; +} + +int DLL CImage::Save(char *szFilename) +{ + int nRes = 0; + int nNotTGA = 1; + + if ( szFilename != NULL ) + { + char * szExt = strrchr( szFilename, '.' ); + + if ( szExt != NULL ) + nNotTGA = _stricmp( szExt, ".tga" ); + + if ( nNotTGA != 0 ) + { + if (( m_BitPerPixel == 16 ) || ( m_BitPerPixel == 32 )) + nRes = ConvertTo24(); + + if (nRes == 0) + nRes = SaveBmp( szFilename ); + } + else + { + if ( m_BitPerPixel == 16 ) + nRes = ConvertTo24(); + + if (nRes == 0) + nRes = SaveTga( szFilename, true ); + } + } + else + nRes = eSaveFilename; + + return nRes; +} + +} \ No newline at end of file diff --git a/src/gl/hqnx_asm/hqnx_asm_Image.h b/src/gl/hqnx_asm/hqnx_asm_Image.h new file mode 100644 index 000000000..8f57d7865 --- /dev/null +++ b/src/gl/hqnx_asm/hqnx_asm_Image.h @@ -0,0 +1,150 @@ +//CImage class - loading and saving BMP and TGA files +//---------------------------------------------------------- +//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +// +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU Lesser General Public +//License as published by the Free Software Foundation; either +//version 2.1 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public +//License along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +//#ifdef WIN32 +//#define DLL __declspec(dllexport) +//#else +#define DLL +//#endif + +#include +#pragma once +#pragma warning(disable: 4103) +#pragma pack(1) + +namespace HQnX_asm +{ + +typedef struct { unsigned char b, g, r; } _BGR; +typedef struct { unsigned char b, g, r, a; } _BGRA; + +class CImage +{ + public: + DLL CImage(); + DLL ~CImage(); + + enum CImageErrors + { + eConvUnknownFormat = 10, + eConvSourceMemory = 11, + eConvDestMemory = 12, + + eSaveBmpFileOpen = 20, + eSaveBmpFileWrite = 21, + eSaveBmpSourceMemory = 22, + eSaveBmpColorDepth = 23, + + eLoadBmpFileOpen = 30, + eLoadBmpFileRead = 31, + eLoadBmpBadFormat = 32, + eLoadBmpInit = 33, + eLoadBmpColorDepth = 34, + + eSaveTgaFileOpen = 40, + eSaveTgaFileWrite = 41, + eSaveTgaSourceMemory = 42, + eSaveTgaColorDepth = 43, + + eLoadTgaFileOpen = 50, + eLoadTgaFileRead = 51, + eLoadTgaBadFormat = 52, + eLoadTgaInit = 53, + eLoadTgaColorDepth = 54, + + eLoadFilename = 60, + eSaveFilename = 61, + }; + + struct _BMPFILEHEADER + { + unsigned short bfType; + long int bfSize, bfRes1, bfOffBits; + }; + + struct _BMPIMAGEHEADEROLD + { + long int biSize; + unsigned short biWidth, biHeight; + unsigned short biPlanes, biBitCount; + }; + + struct _BMPIMAGEHEADER + { + long int biSize, biWidth, biHeight; + unsigned short biPlanes, biBitCount; + long int biCompression, biSizeImage; + long int biXPelsPerMeter, biYPelsPerMeter; + long int biClrUsed, biClrImportant; + }; + + struct _TGAHEADER + { + unsigned char tiIdentSize; + unsigned char tiPaletteIncluded; + unsigned char tiImageType; + unsigned short tiPaletteStart; + unsigned short tiPaletteSize; + unsigned char tiPaletteBpp; + unsigned short tiX0; + unsigned short tiY0; + unsigned short tiXres; + unsigned short tiYres; + unsigned char tiBitPerPixel; + unsigned char tiAttrBits; + }; + + public: + int DLL Init( int Xres, int Yres, unsigned short BitPerPixel ); + int DLL SetImage(unsigned char *img, int width, int height, int bpp); + int DLL Destroy(); + int DLL ConvertTo32( void ); + int DLL ConvertTo24( void ); + int DLL ConvertTo16( void ); + int DLL Convert8To17( int transindex ); + int DLL Convert32To17( void ); + int SaveBmp(char *szFilename); + int LoadBmp(char *szFilename); + int SaveTga(char *szFilename, bool bCompressed ); + int LoadTga(char *szFilename); + int DLL Load(char *szFilename); + int DLL Save(char *szFilename); + + private: + void Output( char * pcData, int nSize ); + void Output( char c ); + void Output( void ); + unsigned char Input( void ); + + public: + int m_Xres, m_Yres; + unsigned short m_BitPerPixel; + unsigned short m_BytePerPixel; + unsigned char * m_pBitmap; + _BGR m_Pal[256]; + + private: + int m_NumPixel; + FILE * f; + int m_nCount; + char m_cBuf[32768]; +}; + +#pragma pack(8) + +} \ No newline at end of file diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 59e84051e..a4f192ce8 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -40,6 +40,9 @@ #include "gl/textures/gl_texture.h" #include "c_cvars.h" #include "gl/hqnx/hqx.h" +#ifdef _MSC_VER +#include "gl/hqnx_asm/hqnx_asm.h" +#endif CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { @@ -179,6 +182,38 @@ static unsigned char *scaleNxHelper( void (*scaleNxFunction) ( uint32* , uint32* return newBuffer; } +// [BB] hqnx scaling is only supported with the MS compiler. +#ifdef _MSC_VER +static unsigned char *hqNxAsmHelper( void (*hqNxFunction) ( int*, unsigned char*, int, int, int ), + const int N, + unsigned char *inputBuffer, + const int inWidth, + const int inHeight, + int &outWidth, + int &outHeight ) +{ + outWidth = N * inWidth; + outHeight = N *inHeight; + + static int initdone = false; + + if (!initdone) + { + HQnX_asm::InitLUTs(); + initdone = true; + } + + HQnX_asm::CImage cImageIn; + cImageIn.SetImage(inputBuffer, inWidth, inHeight, 32); + cImageIn.Convert32To17(); + + unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; + hqNxFunction( reinterpret_cast(cImageIn.m_pBitmap), newBuffer, cImageIn.m_Xres, cImageIn.m_Yres, outWidth*4 ); + delete[] inputBuffer; + return newBuffer; +} +#endif + static unsigned char *hqNxHelper( void (*hqNxFunction) ( unsigned*, unsigned*, int, int ), const int N, unsigned char *inputBuffer, @@ -203,6 +238,7 @@ static unsigned char *hqNxHelper( void (*hqNxFunction) ( unsigned*, unsigned*, i return newBuffer; } + //=========================================================================== // // [BB] Upsamples the texture in inputBuffer, frees inputBuffer and returns @@ -245,11 +281,11 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u outWidth = inWidth; outHeight = inHeight; int type = gl_texture_hqresize; -#if 0 - // hqNx does not preserve the alpha channel so fall back to ScaleNx for such textures - if (hasAlpha && type > 3) +#ifdef _MSC_VER + // ASM-hqNx does not preserve the alpha channel so fall back to C-version for such textures + if (!hasAlpha && type > 3 && type <= 6) { - type -= 3; + type += 3; } #endif @@ -267,6 +303,14 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u return hqNxHelper( &hq3x_32, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); case 6: return hqNxHelper( &hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); +#ifdef _MSC_VER + case 7: + return hqNxAsmHelper( &HQnX_asm::hq2x_32, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 8: + return hqNxAsmHelper( &HQnX_asm::hq3x_32, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 9: + return hqNxAsmHelper( &HQnX_asm::hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); +#endif } } return inputBuffer; From e132fc5eed66fb4403c70055e500e2ffa727a337 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 21 Aug 2014 11:02:46 +0200 Subject: [PATCH 0201/1509] - replaced GLEW with GLLoadGen for GL access. This allows to have a header that only contains what's actually required, namely OpenGL 3.3 plus glBegin and glEnd which are the only compatibility functions needed for the fallback render path. GLEW has two major problems: - it always includes everything, there is no way to restrict the header to a specific GL version - it is mostly broken with a core profile and only works if all sanity checks get switched off. --- src/CMakeLists.txt | 28 +- src/gl/system/gl_framebuffer.cpp | 6 +- src/gl/system/gl_load.c | 1344 ++++++++++++++++++++++ src/gl/system/gl_load.h | 1793 ++++++++++++++++++++++++++++++ src/gl/system/gl_system.h | 5 +- src/win32/win32gliface.cpp | 22 +- src/win32/win32gliface.h | 1 - 7 files changed, 3156 insertions(+), 43 deletions(-) create mode 100644 src/gl/system/gl_load.c create mode 100644 src/gl/system/gl_load.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a219d2054..dcaddff32 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -239,33 +239,6 @@ set( ZDOOM_LIBS ${ZDOOM_LIBS} ${OPENGL_LIBRARIES} ) include_directories( ${OPENGL_INCLUDE_DIR} ) -# check for GLEW -find_path( GLEW_INCLUDE_DIR GL/glew.h - PATHS "/usr/include" - "/usr/local/include" ) - -if( GLEW_INCLUDE_DIR ) - message( STATUS "GLEW include files found at ${GLEW_INCLUDE_DIR}" ) -else( GLEW_INCLUDE_DIR ) - message( SEND_ERROR "Could not find GLEW include files" ) -endif( GLEW_INCLUDE_DIR ) - -# GLEW include directory -include_directories( "${GLEW_INCLUDE_DIR}" ) - -if( NOT WIN32 OR APPLE ) - find_library( GLEW_LIBRARY libGLEW.so ) -else( NOT WIN32 OR APPLE ) - find_library( GLEW_LIBRARY glew32 ) -endif( NOT WIN32 OR APPLE ) - -if( NOT GLEW_LIBRARY ) - message( SEND_ERROR "Could not find GLEW library files" ) -endif( NOT GLEW_LIBRARY ) - -set( ZDOOM_LIBS ${ZDOOM_LIBS} ${GLEW_LIBRARY} ) - - # Decide on the name of the FMOD library we want to use. if( NOT FMOD_LIB_NAME AND MSVC ) @@ -1099,6 +1072,7 @@ add_executable( zdoom WIN32 gl/system/gl_framebuffer.cpp gl/system/gl_menu.cpp gl/system/gl_wipe.cpp + gl/system/gl_load.c gl/models/gl_models_md3.cpp gl/models/gl_models_md2.cpp gl/models/gl_models.cpp diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 2b03db013..54df9b851 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -121,8 +121,7 @@ void OpenGLFrameBuffer::InitializeState() if (first) { - glewExperimental=true; - glewInit(); + ogl_LoadFunctions(); } gl_LoadExtensions(); @@ -536,4 +535,5 @@ void OpenGLFrameBuffer::GameRestart() ScreenshotBuffer = NULL; LastCamera = NULL; gl_GenerateGlobalBrightmapFromColormap(); -} \ No newline at end of file +} + diff --git a/src/gl/system/gl_load.c b/src/gl/system/gl_load.c new file mode 100644 index 000000000..2b55cb3a9 --- /dev/null +++ b/src/gl/system/gl_load.c @@ -0,0 +1,1344 @@ +#include +#include +#include +#include "gl_load.h" + +#if defined(__APPLE__) +#include + +static void* AppleGLGetProcAddress (const GLubyte *name) +{ + static const struct mach_header* image = NULL; + NSSymbol symbol; + char* symbolName; + if (NULL == image) + { + image = NSAddImage("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", NSADDIMAGE_OPTION_RETURN_ON_ERROR); + } + /* prepend a '_' for the Unix C symbol mangling convention */ + symbolName = malloc(strlen((const char*)name) + 2); + strcpy(symbolName+1, (const char*)name); + symbolName[0] = '_'; + symbol = NULL; + /* if (NSIsSymbolNameDefined(symbolName)) + symbol = NSLookupAndBindSymbol(symbolName); */ + symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : NULL; + free(symbolName); + return symbol ? NSAddressOfSymbol(symbol) : NULL; +} +#endif /* __APPLE__ */ + +#if defined(__sgi) || defined (__sun) +#include +#include + +static void* SunGetProcAddress (const GLubyte* name) +{ + static void* h = NULL; + static void* gpa; + + if (h == NULL) + { + if ((h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL)) == NULL) return NULL; + gpa = dlsym(h, "glXGetProcAddress"); + } + + if (gpa != NULL) + return ((void*(*)(const GLubyte*))gpa)(name); + else + return dlsym(h, (const char*)name); +} +#endif /* __sgi || __sun */ + +#if defined(_WIN32) + +#ifdef _MSC_VER +#pragma warning(disable: 4055) +#pragma warning(disable: 4054) +#endif + +static int TestPointer(const PROC pTest) +{ + ptrdiff_t iTest; + if(!pTest) return 0; + iTest = (ptrdiff_t)pTest; + + if(iTest == 1 || iTest == 2 || iTest == 3 || iTest == -1) return 0; + + return 1; +} + +static PROC WinGetProcAddress(const char *name) +{ + HMODULE glMod = NULL; + PROC pFunc = wglGetProcAddress((LPCSTR)name); + if(TestPointer(pFunc)) + { + return pFunc; + } + glMod = GetModuleHandleA("OpenGL32.dll"); + return (PROC)GetProcAddress(glMod, (LPCSTR)name); +} + +#define IntGetProcAddress(name) WinGetProcAddress(name) +#else + #if defined(__APPLE__) + #define IntGetProcAddress(name) AppleGLGetProcAddress(name) + #else + #if defined(__sgi) || defined(__sun) + #define IntGetProcAddress(name) SunGetProcAddress(name) + #else /* GLX */ + #include + + #define IntGetProcAddress(name) (*glXGetProcAddressARB)((const GLubyte*)name) + #endif + #endif +#endif + +int ogl_ext_ARB_texture_compression = ogl_LOAD_FAILED; +int ogl_ext_EXT_texture_compression_s3tc = ogl_LOAD_FAILED; +int ogl_ext_ARB_buffer_storage = ogl_LOAD_FAILED; +int ogl_ext_ARB_shader_storage_buffer_object = ogl_LOAD_FAILED; +int ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; +int ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; + +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1DARB)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1DARB)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2DARB)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3DARB)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImageARB)(GLenum, GLint, GLvoid *) = NULL; + +static int Load_ARB_texture_compression() +{ + int numFailed = 0; + _ptrc_glCompressedTexImage1DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage1DARB"); + if(!_ptrc_glCompressedTexImage1DARB) numFailed++; + _ptrc_glCompressedTexImage2DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage2DARB"); + if(!_ptrc_glCompressedTexImage2DARB) numFailed++; + _ptrc_glCompressedTexImage3DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage3DARB"); + if(!_ptrc_glCompressedTexImage3DARB) numFailed++; + _ptrc_glCompressedTexSubImage1DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage1DARB"); + if(!_ptrc_glCompressedTexSubImage1DARB) numFailed++; + _ptrc_glCompressedTexSubImage2DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage2DARB"); + if(!_ptrc_glCompressedTexSubImage2DARB) numFailed++; + _ptrc_glCompressedTexSubImage3DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage3DARB"); + if(!_ptrc_glCompressedTexSubImage3DARB) numFailed++; + _ptrc_glGetCompressedTexImageARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLvoid *))IntGetProcAddress("glGetCompressedTexImageARB"); + if(!_ptrc_glGetCompressedTexImageARB) numFailed++; + return numFailed; +} + +void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum, GLsizeiptr, const void *, GLbitfield) = NULL; + +static int Load_ARB_buffer_storage() +{ + int numFailed = 0; + _ptrc_glBufferStorage = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizeiptr, const void *, GLbitfield))IntGetProcAddress("glBufferStorage"); + if(!_ptrc_glBufferStorage) numFailed++; + return numFailed; +} + +void (CODEGEN_FUNCPTR *_ptrc_glShaderStorageBlockBinding)(GLuint, GLuint, GLuint) = NULL; + +static int Load_ARB_shader_storage_buffer_object() +{ + int numFailed = 0; + _ptrc_glShaderStorageBlockBinding = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress("glShaderStorageBlockBinding"); + if(!_ptrc_glShaderStorageBlockBinding) numFailed++; + return numFailed; +} + +void (CODEGEN_FUNCPTR *_ptrc_glBegin)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnd)() = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFinish)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFlush)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum, GLboolean *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum, GLdouble *) = NULL; +GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum, GLint *) = NULL; +const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum, GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum, GLenum) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint, GLint, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum, GLint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum, GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum, GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum, GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum, GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum, GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint, GLint, GLsizei, GLsizei) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum, GLint, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum, GLsizei, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei, GLuint *) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum, GLint, GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat, GLboolean) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum, const GLint *, const GLsizei *, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum, const GLint *) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum, GLsizeiptr, const GLvoid *, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum, GLenum, GLvoid **) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum, GLintptr, GLsizeiptr, GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint, GLenum, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum, GLenum, GLint *) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint) = NULL; +void * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum, GLenum) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint, GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)() = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei, const GLenum *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint, GLsizei, GLsizei *, GLuint *) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint, GLenum, GLint *) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint, GLint, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint, GLint, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint, GLenum, GLvoid **) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint, GLenum, GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint, GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint, GLenum, GLint *) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint, GLsizei, const GLchar *const*, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint, GLsizei, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint, GLsizei, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint, GLsizei, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint, GLsizei, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint, GLsizei, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint, GLsizei, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint, GLsizei, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint, GLint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint, GLsizei, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint, GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint, GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint, const GLbyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint, const GLubyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint, const GLushort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint, const GLbyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint, GLshort, GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint, const GLubyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint, const GLushort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint, GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum) = NULL; +GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum, GLint, GLfloat, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum, GLint, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum, GLint, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum, GLint, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum, GLenum, GLenum, GLuint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum, GLenum, GLuint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum, GLuint, GLboolean *) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum, GLuint, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum, GLenum, GLint *) = NULL; +const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum, GLenum, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint, GLint, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint, GLenum, GLuint *) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum, GLuint) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint) = NULL; +void * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum, GLsizei, GLenum, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum, GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum, GLenum, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint, GLsizei, const GLchar *const*, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint, GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint, GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint, GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint, GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint, GLuint, GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint, GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint, GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint, const GLbyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint, GLint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint, const GLubyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint, GLuint, GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint, const GLushort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint, GLint, GLenum, GLsizei, const GLvoid *) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum, GLint, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint, GLuint, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint, GLsizei, const GLuint *, GLenum, GLint *) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint, GLsizei, const GLchar *const*, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum, GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint, GLuint, GLuint) = NULL; + +GLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync, GLbitfield, GLuint64) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint) = NULL; +GLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum, GLbitfield) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum, GLenum, GLuint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum, GLenum, GLint64 *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum, GLuint, GLint64 *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum, GLint64 *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum, GLuint, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync, GLenum, GLsizei, GLsizei *, GLint *) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint, GLbitfield) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync, GLbitfield, GLuint64) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint, GLuint, GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei, GLuint *) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint, GLenum, GLint64 *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint, GLenum, GLuint64 *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint, GLenum, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint, GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint, GLenum, GLint *) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint, GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint, GLenum, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint, GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint, GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint, GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint, GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint, GLenum, GLboolean, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint, GLenum, GLboolean, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint, GLenum, GLboolean, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint, GLenum, GLboolean, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL; + +static int Load_Version_3_3() +{ + int numFailed = 0; + _ptrc_glBegin = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glBegin"); + if(!_ptrc_glBegin) numFailed++; + _ptrc_glEnd = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glEnd"); + if(!_ptrc_glEnd) numFailed++; + _ptrc_glBlendFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glBlendFunc"); + if(!_ptrc_glBlendFunc) numFailed++; + _ptrc_glClear = (void (CODEGEN_FUNCPTR *)(GLbitfield))IntGetProcAddress("glClear"); + if(!_ptrc_glClear) numFailed++; + _ptrc_glClearColor = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glClearColor"); + if(!_ptrc_glClearColor) numFailed++; + _ptrc_glClearDepth = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress("glClearDepth"); + if(!_ptrc_glClearDepth) numFailed++; + _ptrc_glClearStencil = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress("glClearStencil"); + if(!_ptrc_glClearStencil) numFailed++; + _ptrc_glColorMask = (void (CODEGEN_FUNCPTR *)(GLboolean, GLboolean, GLboolean, GLboolean))IntGetProcAddress("glColorMask"); + if(!_ptrc_glColorMask) numFailed++; + _ptrc_glCullFace = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glCullFace"); + if(!_ptrc_glCullFace) numFailed++; + _ptrc_glDepthFunc = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glDepthFunc"); + if(!_ptrc_glDepthFunc) numFailed++; + _ptrc_glDepthMask = (void (CODEGEN_FUNCPTR *)(GLboolean))IntGetProcAddress("glDepthMask"); + if(!_ptrc_glDepthMask) numFailed++; + _ptrc_glDepthRange = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress("glDepthRange"); + if(!_ptrc_glDepthRange) numFailed++; + _ptrc_glDisable = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glDisable"); + if(!_ptrc_glDisable) numFailed++; + _ptrc_glDrawBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glDrawBuffer"); + if(!_ptrc_glDrawBuffer) numFailed++; + _ptrc_glEnable = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glEnable"); + if(!_ptrc_glEnable) numFailed++; + _ptrc_glFinish = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glFinish"); + if(!_ptrc_glFinish) numFailed++; + _ptrc_glFlush = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glFlush"); + if(!_ptrc_glFlush) numFailed++; + _ptrc_glFrontFace = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glFrontFace"); + if(!_ptrc_glFrontFace) numFailed++; + _ptrc_glGetBooleanv = (void (CODEGEN_FUNCPTR *)(GLenum, GLboolean *))IntGetProcAddress("glGetBooleanv"); + if(!_ptrc_glGetBooleanv) numFailed++; + _ptrc_glGetDoublev = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble *))IntGetProcAddress("glGetDoublev"); + if(!_ptrc_glGetDoublev) numFailed++; + _ptrc_glGetError = (GLenum (CODEGEN_FUNCPTR *)())IntGetProcAddress("glGetError"); + if(!_ptrc_glGetError) numFailed++; + _ptrc_glGetFloatv = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat *))IntGetProcAddress("glGetFloatv"); + if(!_ptrc_glGetFloatv) numFailed++; + _ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress("glGetIntegerv"); + if(!_ptrc_glGetIntegerv) numFailed++; + _ptrc_glGetString = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGetString"); + if(!_ptrc_glGetString) numFailed++; + _ptrc_glGetTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLenum, GLvoid *))IntGetProcAddress("glGetTexImage"); + if(!_ptrc_glGetTexImage) numFailed++; + _ptrc_glGetTexLevelParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLfloat *))IntGetProcAddress("glGetTexLevelParameterfv"); + if(!_ptrc_glGetTexLevelParameterfv) numFailed++; + _ptrc_glGetTexLevelParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint *))IntGetProcAddress("glGetTexLevelParameteriv"); + if(!_ptrc_glGetTexLevelParameteriv) numFailed++; + _ptrc_glGetTexParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress("glGetTexParameterfv"); + if(!_ptrc_glGetTexParameterfv) numFailed++; + _ptrc_glGetTexParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetTexParameteriv"); + if(!_ptrc_glGetTexParameteriv) numFailed++; + _ptrc_glHint = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glHint"); + if(!_ptrc_glHint) numFailed++; + _ptrc_glIsEnabled = (GLboolean (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glIsEnabled"); + if(!_ptrc_glIsEnabled) numFailed++; + _ptrc_glLineWidth = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glLineWidth"); + if(!_ptrc_glLineWidth) numFailed++; + _ptrc_glLogicOp = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glLogicOp"); + if(!_ptrc_glLogicOp) numFailed++; + _ptrc_glPixelStoref = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glPixelStoref"); + if(!_ptrc_glPixelStoref) numFailed++; + _ptrc_glPixelStorei = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress("glPixelStorei"); + if(!_ptrc_glPixelStorei) numFailed++; + _ptrc_glPointSize = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glPointSize"); + if(!_ptrc_glPointSize) numFailed++; + _ptrc_glPolygonMode = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glPolygonMode"); + if(!_ptrc_glPolygonMode) numFailed++; + _ptrc_glReadBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glReadBuffer"); + if(!_ptrc_glReadBuffer) numFailed++; + _ptrc_glReadPixels = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *))IntGetProcAddress("glReadPixels"); + if(!_ptrc_glReadPixels) numFailed++; + _ptrc_glScissor = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glScissor"); + if(!_ptrc_glScissor) numFailed++; + _ptrc_glStencilFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLuint))IntGetProcAddress("glStencilFunc"); + if(!_ptrc_glStencilFunc) numFailed++; + _ptrc_glStencilMask = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glStencilMask"); + if(!_ptrc_glStencilMask) numFailed++; + _ptrc_glStencilOp = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum))IntGetProcAddress("glStencilOp"); + if(!_ptrc_glStencilOp) numFailed++; + _ptrc_glTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexImage1D"); + if(!_ptrc_glTexImage1D) numFailed++; + _ptrc_glTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexImage2D"); + if(!_ptrc_glTexImage2D) numFailed++; + _ptrc_glTexParameterf = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat))IntGetProcAddress("glTexParameterf"); + if(!_ptrc_glTexParameterf) numFailed++; + _ptrc_glTexParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLfloat *))IntGetProcAddress("glTexParameterfv"); + if(!_ptrc_glTexParameterfv) numFailed++; + _ptrc_glTexParameteri = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint))IntGetProcAddress("glTexParameteri"); + if(!_ptrc_glTexParameteri) numFailed++; + _ptrc_glTexParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress("glTexParameteriv"); + if(!_ptrc_glTexParameteriv) numFailed++; + _ptrc_glViewport = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glViewport"); + if(!_ptrc_glViewport) numFailed++; + _ptrc_glBindTexture = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindTexture"); + if(!_ptrc_glBindTexture) numFailed++; + _ptrc_glCopyTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint))IntGetProcAddress("glCopyTexImage1D"); + if(!_ptrc_glCopyTexImage1D) numFailed++; + _ptrc_glCopyTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint))IntGetProcAddress("glCopyTexImage2D"); + if(!_ptrc_glCopyTexImage2D) numFailed++; + _ptrc_glCopyTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei))IntGetProcAddress("glCopyTexSubImage1D"); + if(!_ptrc_glCopyTexSubImage1D) numFailed++; + _ptrc_glCopyTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glCopyTexSubImage2D"); + if(!_ptrc_glCopyTexSubImage2D) numFailed++; + _ptrc_glDeleteTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteTextures"); + if(!_ptrc_glDeleteTextures) numFailed++; + _ptrc_glDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLsizei))IntGetProcAddress("glDrawArrays"); + if(!_ptrc_glDrawArrays) numFailed++; + _ptrc_glDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *))IntGetProcAddress("glDrawElements"); + if(!_ptrc_glDrawElements) numFailed++; + _ptrc_glGenTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenTextures"); + if(!_ptrc_glGenTextures) numFailed++; + _ptrc_glIsTexture = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsTexture"); + if(!_ptrc_glIsTexture) numFailed++; + _ptrc_glPolygonOffset = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glPolygonOffset"); + if(!_ptrc_glPolygonOffset) numFailed++; + _ptrc_glTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexSubImage1D"); + if(!_ptrc_glTexSubImage1D) numFailed++; + _ptrc_glTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexSubImage2D"); + if(!_ptrc_glTexSubImage2D) numFailed++; + _ptrc_glBlendColor = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glBlendColor"); + if(!_ptrc_glBlendColor) numFailed++; + _ptrc_glBlendEquation = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glBlendEquation"); + if(!_ptrc_glBlendEquation) numFailed++; + _ptrc_glCopyTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glCopyTexSubImage3D"); + if(!_ptrc_glCopyTexSubImage3D) numFailed++; + _ptrc_glDrawRangeElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *))IntGetProcAddress("glDrawRangeElements"); + if(!_ptrc_glDrawRangeElements) numFailed++; + _ptrc_glTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexImage3D"); + if(!_ptrc_glTexImage3D) numFailed++; + _ptrc_glTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexSubImage3D"); + if(!_ptrc_glTexSubImage3D) numFailed++; + _ptrc_glActiveTexture = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glActiveTexture"); + if(!_ptrc_glActiveTexture) numFailed++; + _ptrc_glCompressedTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage1D"); + if(!_ptrc_glCompressedTexImage1D) numFailed++; + _ptrc_glCompressedTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage2D"); + if(!_ptrc_glCompressedTexImage2D) numFailed++; + _ptrc_glCompressedTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage3D"); + if(!_ptrc_glCompressedTexImage3D) numFailed++; + _ptrc_glCompressedTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage1D"); + if(!_ptrc_glCompressedTexSubImage1D) numFailed++; + _ptrc_glCompressedTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage2D"); + if(!_ptrc_glCompressedTexSubImage2D) numFailed++; + _ptrc_glCompressedTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage3D"); + if(!_ptrc_glCompressedTexSubImage3D) numFailed++; + _ptrc_glGetCompressedTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLvoid *))IntGetProcAddress("glGetCompressedTexImage"); + if(!_ptrc_glGetCompressedTexImage) numFailed++; + _ptrc_glSampleCoverage = (void (CODEGEN_FUNCPTR *)(GLfloat, GLboolean))IntGetProcAddress("glSampleCoverage"); + if(!_ptrc_glSampleCoverage) numFailed++; + _ptrc_glBlendFuncSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum))IntGetProcAddress("glBlendFuncSeparate"); + if(!_ptrc_glBlendFuncSeparate) numFailed++; + _ptrc_glMultiDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *, const GLsizei *, GLsizei))IntGetProcAddress("glMultiDrawArrays"); + if(!_ptrc_glMultiDrawArrays) numFailed++; + _ptrc_glMultiDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei))IntGetProcAddress("glMultiDrawElements"); + if(!_ptrc_glMultiDrawElements) numFailed++; + _ptrc_glPointParameterf = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glPointParameterf"); + if(!_ptrc_glPointParameterf) numFailed++; + _ptrc_glPointParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress("glPointParameterfv"); + if(!_ptrc_glPointParameterfv) numFailed++; + _ptrc_glPointParameteri = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress("glPointParameteri"); + if(!_ptrc_glPointParameteri) numFailed++; + _ptrc_glPointParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glPointParameteriv"); + if(!_ptrc_glPointParameteriv) numFailed++; + _ptrc_glBeginQuery = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBeginQuery"); + if(!_ptrc_glBeginQuery) numFailed++; + _ptrc_glBindBuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindBuffer"); + if(!_ptrc_glBindBuffer) numFailed++; + _ptrc_glBufferData = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizeiptr, const GLvoid *, GLenum))IntGetProcAddress("glBufferData"); + if(!_ptrc_glBufferData) numFailed++; + _ptrc_glBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, const GLvoid *))IntGetProcAddress("glBufferSubData"); + if(!_ptrc_glBufferSubData) numFailed++; + _ptrc_glDeleteBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteBuffers"); + if(!_ptrc_glDeleteBuffers) numFailed++; + _ptrc_glDeleteQueries = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteQueries"); + if(!_ptrc_glDeleteQueries) numFailed++; + _ptrc_glEndQuery = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glEndQuery"); + if(!_ptrc_glEndQuery) numFailed++; + _ptrc_glGenBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenBuffers"); + if(!_ptrc_glGenBuffers) numFailed++; + _ptrc_glGenQueries = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenQueries"); + if(!_ptrc_glGenQueries) numFailed++; + _ptrc_glGetBufferParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetBufferParameteriv"); + if(!_ptrc_glGetBufferParameteriv) numFailed++; + _ptrc_glGetBufferPointerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLvoid **))IntGetProcAddress("glGetBufferPointerv"); + if(!_ptrc_glGetBufferPointerv) numFailed++; + _ptrc_glGetBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, GLvoid *))IntGetProcAddress("glGetBufferSubData"); + if(!_ptrc_glGetBufferSubData) numFailed++; + _ptrc_glGetQueryObjectiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetQueryObjectiv"); + if(!_ptrc_glGetQueryObjectiv) numFailed++; + _ptrc_glGetQueryObjectuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress("glGetQueryObjectuiv"); + if(!_ptrc_glGetQueryObjectuiv) numFailed++; + _ptrc_glGetQueryiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetQueryiv"); + if(!_ptrc_glGetQueryiv) numFailed++; + _ptrc_glIsBuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsBuffer"); + if(!_ptrc_glIsBuffer) numFailed++; + _ptrc_glIsQuery = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsQuery"); + if(!_ptrc_glIsQuery) numFailed++; + _ptrc_glMapBuffer = (void * (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glMapBuffer"); + if(!_ptrc_glMapBuffer) numFailed++; + _ptrc_glUnmapBuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glUnmapBuffer"); + if(!_ptrc_glUnmapBuffer) numFailed++; + _ptrc_glAttachShader = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress("glAttachShader"); + if(!_ptrc_glAttachShader) numFailed++; + _ptrc_glBindAttribLocation = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, const GLchar *))IntGetProcAddress("glBindAttribLocation"); + if(!_ptrc_glBindAttribLocation) numFailed++; + _ptrc_glBlendEquationSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glBlendEquationSeparate"); + if(!_ptrc_glBlendEquationSeparate) numFailed++; + _ptrc_glCompileShader = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glCompileShader"); + if(!_ptrc_glCompileShader) numFailed++; + _ptrc_glCreateProgram = (GLuint (CODEGEN_FUNCPTR *)())IntGetProcAddress("glCreateProgram"); + if(!_ptrc_glCreateProgram) numFailed++; + _ptrc_glCreateShader = (GLuint (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glCreateShader"); + if(!_ptrc_glCreateShader) numFailed++; + _ptrc_glDeleteProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glDeleteProgram"); + if(!_ptrc_glDeleteProgram) numFailed++; + _ptrc_glDeleteShader = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glDeleteShader"); + if(!_ptrc_glDeleteShader) numFailed++; + _ptrc_glDetachShader = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress("glDetachShader"); + if(!_ptrc_glDetachShader) numFailed++; + _ptrc_glDisableVertexAttribArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glDisableVertexAttribArray"); + if(!_ptrc_glDisableVertexAttribArray) numFailed++; + _ptrc_glDrawBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLenum *))IntGetProcAddress("glDrawBuffers"); + if(!_ptrc_glDrawBuffers) numFailed++; + _ptrc_glEnableVertexAttribArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glEnableVertexAttribArray"); + if(!_ptrc_glEnableVertexAttribArray) numFailed++; + _ptrc_glGetActiveAttrib = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *))IntGetProcAddress("glGetActiveAttrib"); + if(!_ptrc_glGetActiveAttrib) numFailed++; + _ptrc_glGetActiveUniform = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *))IntGetProcAddress("glGetActiveUniform"); + if(!_ptrc_glGetActiveUniform) numFailed++; + _ptrc_glGetAttachedShaders = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLuint *))IntGetProcAddress("glGetAttachedShaders"); + if(!_ptrc_glGetAttachedShaders) numFailed++; + _ptrc_glGetAttribLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress("glGetAttribLocation"); + if(!_ptrc_glGetAttribLocation) numFailed++; + _ptrc_glGetProgramInfoLog = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetProgramInfoLog"); + if(!_ptrc_glGetProgramInfoLog) numFailed++; + _ptrc_glGetProgramiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetProgramiv"); + if(!_ptrc_glGetProgramiv) numFailed++; + _ptrc_glGetShaderInfoLog = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetShaderInfoLog"); + if(!_ptrc_glGetShaderInfoLog) numFailed++; + _ptrc_glGetShaderSource = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetShaderSource"); + if(!_ptrc_glGetShaderSource) numFailed++; + _ptrc_glGetShaderiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetShaderiv"); + if(!_ptrc_glGetShaderiv) numFailed++; + _ptrc_glGetUniformLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress("glGetUniformLocation"); + if(!_ptrc_glGetUniformLocation) numFailed++; + _ptrc_glGetUniformfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLfloat *))IntGetProcAddress("glGetUniformfv"); + if(!_ptrc_glGetUniformfv) numFailed++; + _ptrc_glGetUniformiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint *))IntGetProcAddress("glGetUniformiv"); + if(!_ptrc_glGetUniformiv) numFailed++; + _ptrc_glGetVertexAttribPointerv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLvoid **))IntGetProcAddress("glGetVertexAttribPointerv"); + if(!_ptrc_glGetVertexAttribPointerv) numFailed++; + _ptrc_glGetVertexAttribdv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLdouble *))IntGetProcAddress("glGetVertexAttribdv"); + if(!_ptrc_glGetVertexAttribdv) numFailed++; + _ptrc_glGetVertexAttribfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat *))IntGetProcAddress("glGetVertexAttribfv"); + if(!_ptrc_glGetVertexAttribfv) numFailed++; + _ptrc_glGetVertexAttribiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetVertexAttribiv"); + if(!_ptrc_glGetVertexAttribiv) numFailed++; + _ptrc_glIsProgram = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsProgram"); + if(!_ptrc_glIsProgram) numFailed++; + _ptrc_glIsShader = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsShader"); + if(!_ptrc_glIsShader) numFailed++; + _ptrc_glLinkProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glLinkProgram"); + if(!_ptrc_glLinkProgram) numFailed++; + _ptrc_glShaderSource = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, const GLint *))IntGetProcAddress("glShaderSource"); + if(!_ptrc_glShaderSource) numFailed++; + _ptrc_glStencilFuncSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint, GLuint))IntGetProcAddress("glStencilFuncSeparate"); + if(!_ptrc_glStencilFuncSeparate) numFailed++; + _ptrc_glStencilMaskSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glStencilMaskSeparate"); + if(!_ptrc_glStencilMaskSeparate) numFailed++; + _ptrc_glStencilOpSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum))IntGetProcAddress("glStencilOpSeparate"); + if(!_ptrc_glStencilOpSeparate) numFailed++; + _ptrc_glUniform1f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat))IntGetProcAddress("glUniform1f"); + if(!_ptrc_glUniform1f) numFailed++; + _ptrc_glUniform1fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress("glUniform1fv"); + if(!_ptrc_glUniform1fv) numFailed++; + _ptrc_glUniform1i = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress("glUniform1i"); + if(!_ptrc_glUniform1i) numFailed++; + _ptrc_glUniform1iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress("glUniform1iv"); + if(!_ptrc_glUniform1iv) numFailed++; + _ptrc_glUniform2f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat))IntGetProcAddress("glUniform2f"); + if(!_ptrc_glUniform2f) numFailed++; + _ptrc_glUniform2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress("glUniform2fv"); + if(!_ptrc_glUniform2fv) numFailed++; + _ptrc_glUniform2i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glUniform2i"); + if(!_ptrc_glUniform2i) numFailed++; + _ptrc_glUniform2iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress("glUniform2iv"); + if(!_ptrc_glUniform2iv) numFailed++; + _ptrc_glUniform3f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glUniform3f"); + if(!_ptrc_glUniform3f) numFailed++; + _ptrc_glUniform3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress("glUniform3fv"); + if(!_ptrc_glUniform3fv) numFailed++; + _ptrc_glUniform3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress("glUniform3i"); + if(!_ptrc_glUniform3i) numFailed++; + _ptrc_glUniform3iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress("glUniform3iv"); + if(!_ptrc_glUniform3iv) numFailed++; + _ptrc_glUniform4f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glUniform4f"); + if(!_ptrc_glUniform4f) numFailed++; + _ptrc_glUniform4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress("glUniform4fv"); + if(!_ptrc_glUniform4fv) numFailed++; + _ptrc_glUniform4i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint, GLint))IntGetProcAddress("glUniform4i"); + if(!_ptrc_glUniform4i) numFailed++; + _ptrc_glUniform4iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress("glUniform4iv"); + if(!_ptrc_glUniform4iv) numFailed++; + _ptrc_glUniformMatrix2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix2fv"); + if(!_ptrc_glUniformMatrix2fv) numFailed++; + _ptrc_glUniformMatrix3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix3fv"); + if(!_ptrc_glUniformMatrix3fv) numFailed++; + _ptrc_glUniformMatrix4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix4fv"); + if(!_ptrc_glUniformMatrix4fv) numFailed++; + _ptrc_glUseProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glUseProgram"); + if(!_ptrc_glUseProgram) numFailed++; + _ptrc_glValidateProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glValidateProgram"); + if(!_ptrc_glValidateProgram) numFailed++; + _ptrc_glVertexAttrib1d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble))IntGetProcAddress("glVertexAttrib1d"); + if(!_ptrc_glVertexAttrib1d) numFailed++; + _ptrc_glVertexAttrib1dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress("glVertexAttrib1dv"); + if(!_ptrc_glVertexAttrib1dv) numFailed++; + _ptrc_glVertexAttrib1f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat))IntGetProcAddress("glVertexAttrib1f"); + if(!_ptrc_glVertexAttrib1f) numFailed++; + _ptrc_glVertexAttrib1fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress("glVertexAttrib1fv"); + if(!_ptrc_glVertexAttrib1fv) numFailed++; + _ptrc_glVertexAttrib1s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort))IntGetProcAddress("glVertexAttrib1s"); + if(!_ptrc_glVertexAttrib1s) numFailed++; + _ptrc_glVertexAttrib1sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress("glVertexAttrib1sv"); + if(!_ptrc_glVertexAttrib1sv) numFailed++; + _ptrc_glVertexAttrib2d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble))IntGetProcAddress("glVertexAttrib2d"); + if(!_ptrc_glVertexAttrib2d) numFailed++; + _ptrc_glVertexAttrib2dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress("glVertexAttrib2dv"); + if(!_ptrc_glVertexAttrib2dv) numFailed++; + _ptrc_glVertexAttrib2f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat))IntGetProcAddress("glVertexAttrib2f"); + if(!_ptrc_glVertexAttrib2f) numFailed++; + _ptrc_glVertexAttrib2fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress("glVertexAttrib2fv"); + if(!_ptrc_glVertexAttrib2fv) numFailed++; + _ptrc_glVertexAttrib2s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort))IntGetProcAddress("glVertexAttrib2s"); + if(!_ptrc_glVertexAttrib2s) numFailed++; + _ptrc_glVertexAttrib2sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress("glVertexAttrib2sv"); + if(!_ptrc_glVertexAttrib2sv) numFailed++; + _ptrc_glVertexAttrib3d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glVertexAttrib3d"); + if(!_ptrc_glVertexAttrib3d) numFailed++; + _ptrc_glVertexAttrib3dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress("glVertexAttrib3dv"); + if(!_ptrc_glVertexAttrib3dv) numFailed++; + _ptrc_glVertexAttrib3f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glVertexAttrib3f"); + if(!_ptrc_glVertexAttrib3f) numFailed++; + _ptrc_glVertexAttrib3fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress("glVertexAttrib3fv"); + if(!_ptrc_glVertexAttrib3fv) numFailed++; + _ptrc_glVertexAttrib3s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort, GLshort))IntGetProcAddress("glVertexAttrib3s"); + if(!_ptrc_glVertexAttrib3s) numFailed++; + _ptrc_glVertexAttrib3sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress("glVertexAttrib3sv"); + if(!_ptrc_glVertexAttrib3sv) numFailed++; + _ptrc_glVertexAttrib4Nbv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress("glVertexAttrib4Nbv"); + if(!_ptrc_glVertexAttrib4Nbv) numFailed++; + _ptrc_glVertexAttrib4Niv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress("glVertexAttrib4Niv"); + if(!_ptrc_glVertexAttrib4Niv) numFailed++; + _ptrc_glVertexAttrib4Nsv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress("glVertexAttrib4Nsv"); + if(!_ptrc_glVertexAttrib4Nsv) numFailed++; + _ptrc_glVertexAttrib4Nub = (void (CODEGEN_FUNCPTR *)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte))IntGetProcAddress("glVertexAttrib4Nub"); + if(!_ptrc_glVertexAttrib4Nub) numFailed++; + _ptrc_glVertexAttrib4Nubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress("glVertexAttrib4Nubv"); + if(!_ptrc_glVertexAttrib4Nubv) numFailed++; + _ptrc_glVertexAttrib4Nuiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress("glVertexAttrib4Nuiv"); + if(!_ptrc_glVertexAttrib4Nuiv) numFailed++; + _ptrc_glVertexAttrib4Nusv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress("glVertexAttrib4Nusv"); + if(!_ptrc_glVertexAttrib4Nusv) numFailed++; + _ptrc_glVertexAttrib4bv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress("glVertexAttrib4bv"); + if(!_ptrc_glVertexAttrib4bv) numFailed++; + _ptrc_glVertexAttrib4d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glVertexAttrib4d"); + if(!_ptrc_glVertexAttrib4d) numFailed++; + _ptrc_glVertexAttrib4dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress("glVertexAttrib4dv"); + if(!_ptrc_glVertexAttrib4dv) numFailed++; + _ptrc_glVertexAttrib4f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glVertexAttrib4f"); + if(!_ptrc_glVertexAttrib4f) numFailed++; + _ptrc_glVertexAttrib4fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress("glVertexAttrib4fv"); + if(!_ptrc_glVertexAttrib4fv) numFailed++; + _ptrc_glVertexAttrib4iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress("glVertexAttrib4iv"); + if(!_ptrc_glVertexAttrib4iv) numFailed++; + _ptrc_glVertexAttrib4s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort, GLshort, GLshort))IntGetProcAddress("glVertexAttrib4s"); + if(!_ptrc_glVertexAttrib4s) numFailed++; + _ptrc_glVertexAttrib4sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress("glVertexAttrib4sv"); + if(!_ptrc_glVertexAttrib4sv) numFailed++; + _ptrc_glVertexAttrib4ubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress("glVertexAttrib4ubv"); + if(!_ptrc_glVertexAttrib4ubv) numFailed++; + _ptrc_glVertexAttrib4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress("glVertexAttrib4uiv"); + if(!_ptrc_glVertexAttrib4uiv) numFailed++; + _ptrc_glVertexAttrib4usv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress("glVertexAttrib4usv"); + if(!_ptrc_glVertexAttrib4usv) numFailed++; + _ptrc_glVertexAttribPointer = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *))IntGetProcAddress("glVertexAttribPointer"); + if(!_ptrc_glVertexAttribPointer) numFailed++; + _ptrc_glUniformMatrix2x3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix2x3fv"); + if(!_ptrc_glUniformMatrix2x3fv) numFailed++; + _ptrc_glUniformMatrix2x4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix2x4fv"); + if(!_ptrc_glUniformMatrix2x4fv) numFailed++; + _ptrc_glUniformMatrix3x2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix3x2fv"); + if(!_ptrc_glUniformMatrix3x2fv) numFailed++; + _ptrc_glUniformMatrix3x4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix3x4fv"); + if(!_ptrc_glUniformMatrix3x4fv) numFailed++; + _ptrc_glUniformMatrix4x2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix4x2fv"); + if(!_ptrc_glUniformMatrix4x2fv) numFailed++; + _ptrc_glUniformMatrix4x3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix4x3fv"); + if(!_ptrc_glUniformMatrix4x3fv) numFailed++; + _ptrc_glBeginConditionalRender = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum))IntGetProcAddress("glBeginConditionalRender"); + if(!_ptrc_glBeginConditionalRender) numFailed++; + _ptrc_glBeginTransformFeedback = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glBeginTransformFeedback"); + if(!_ptrc_glBeginTransformFeedback) numFailed++; + _ptrc_glBindBufferBase = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint))IntGetProcAddress("glBindBufferBase"); + if(!_ptrc_glBindBufferBase) numFailed++; + _ptrc_glBindBufferRange = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr))IntGetProcAddress("glBindBufferRange"); + if(!_ptrc_glBindBufferRange) numFailed++; + _ptrc_glBindFragDataLocation = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, const GLchar *))IntGetProcAddress("glBindFragDataLocation"); + if(!_ptrc_glBindFragDataLocation) numFailed++; + _ptrc_glBindFramebuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindFramebuffer"); + if(!_ptrc_glBindFramebuffer) numFailed++; + _ptrc_glBindRenderbuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindRenderbuffer"); + if(!_ptrc_glBindRenderbuffer) numFailed++; + _ptrc_glBindVertexArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glBindVertexArray"); + if(!_ptrc_glBindVertexArray) numFailed++; + _ptrc_glBlitFramebuffer = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum))IntGetProcAddress("glBlitFramebuffer"); + if(!_ptrc_glBlitFramebuffer) numFailed++; + _ptrc_glCheckFramebufferStatus = (GLenum (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glCheckFramebufferStatus"); + if(!_ptrc_glCheckFramebufferStatus) numFailed++; + _ptrc_glClampColor = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glClampColor"); + if(!_ptrc_glClampColor) numFailed++; + _ptrc_glClearBufferfi = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLfloat, GLint))IntGetProcAddress("glClearBufferfi"); + if(!_ptrc_glClearBufferfi) numFailed++; + _ptrc_glClearBufferfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLfloat *))IntGetProcAddress("glClearBufferfv"); + if(!_ptrc_glClearBufferfv) numFailed++; + _ptrc_glClearBufferiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLint *))IntGetProcAddress("glClearBufferiv"); + if(!_ptrc_glClearBufferiv) numFailed++; + _ptrc_glClearBufferuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLuint *))IntGetProcAddress("glClearBufferuiv"); + if(!_ptrc_glClearBufferuiv) numFailed++; + _ptrc_glColorMaski = (void (CODEGEN_FUNCPTR *)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean))IntGetProcAddress("glColorMaski"); + if(!_ptrc_glColorMaski) numFailed++; + _ptrc_glDeleteFramebuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteFramebuffers"); + if(!_ptrc_glDeleteFramebuffers) numFailed++; + _ptrc_glDeleteRenderbuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteRenderbuffers"); + if(!_ptrc_glDeleteRenderbuffers) numFailed++; + _ptrc_glDeleteVertexArrays = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteVertexArrays"); + if(!_ptrc_glDeleteVertexArrays) numFailed++; + _ptrc_glDisablei = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glDisablei"); + if(!_ptrc_glDisablei) numFailed++; + _ptrc_glEnablei = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glEnablei"); + if(!_ptrc_glEnablei) numFailed++; + _ptrc_glEndConditionalRender = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glEndConditionalRender"); + if(!_ptrc_glEndConditionalRender) numFailed++; + _ptrc_glEndTransformFeedback = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glEndTransformFeedback"); + if(!_ptrc_glEndTransformFeedback) numFailed++; + _ptrc_glFlushMappedBufferRange = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr))IntGetProcAddress("glFlushMappedBufferRange"); + if(!_ptrc_glFlushMappedBufferRange) numFailed++; + _ptrc_glFramebufferRenderbuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint))IntGetProcAddress("glFramebufferRenderbuffer"); + if(!_ptrc_glFramebufferRenderbuffer) numFailed++; + _ptrc_glFramebufferTexture1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress("glFramebufferTexture1D"); + if(!_ptrc_glFramebufferTexture1D) numFailed++; + _ptrc_glFramebufferTexture2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress("glFramebufferTexture2D"); + if(!_ptrc_glFramebufferTexture2D) numFailed++; + _ptrc_glFramebufferTexture3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint, GLint))IntGetProcAddress("glFramebufferTexture3D"); + if(!_ptrc_glFramebufferTexture3D) numFailed++; + _ptrc_glFramebufferTextureLayer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint, GLint, GLint))IntGetProcAddress("glFramebufferTextureLayer"); + if(!_ptrc_glFramebufferTextureLayer) numFailed++; + _ptrc_glGenFramebuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenFramebuffers"); + if(!_ptrc_glGenFramebuffers) numFailed++; + _ptrc_glGenRenderbuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenRenderbuffers"); + if(!_ptrc_glGenRenderbuffers) numFailed++; + _ptrc_glGenVertexArrays = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenVertexArrays"); + if(!_ptrc_glGenVertexArrays) numFailed++; + _ptrc_glGenerateMipmap = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGenerateMipmap"); + if(!_ptrc_glGenerateMipmap) numFailed++; + _ptrc_glGetBooleani_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLboolean *))IntGetProcAddress("glGetBooleani_v"); + if(!_ptrc_glGetBooleani_v) numFailed++; + _ptrc_glGetFragDataLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress("glGetFragDataLocation"); + if(!_ptrc_glGetFragDataLocation) numFailed++; + _ptrc_glGetFramebufferAttachmentParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLint *))IntGetProcAddress("glGetFramebufferAttachmentParameteriv"); + if(!_ptrc_glGetFramebufferAttachmentParameteriv) numFailed++; + _ptrc_glGetIntegeri_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLint *))IntGetProcAddress("glGetIntegeri_v"); + if(!_ptrc_glGetIntegeri_v) numFailed++; + _ptrc_glGetRenderbufferParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetRenderbufferParameteriv"); + if(!_ptrc_glGetRenderbufferParameteriv) numFailed++; + _ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi"); + if(!_ptrc_glGetStringi) numFailed++; + _ptrc_glGetTexParameterIiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetTexParameterIiv"); + if(!_ptrc_glGetTexParameterIiv) numFailed++; + _ptrc_glGetTexParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint *))IntGetProcAddress("glGetTexParameterIuiv"); + if(!_ptrc_glGetTexParameterIuiv) numFailed++; + _ptrc_glGetTransformFeedbackVarying = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *))IntGetProcAddress("glGetTransformFeedbackVarying"); + if(!_ptrc_glGetTransformFeedbackVarying) numFailed++; + _ptrc_glGetUniformuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLuint *))IntGetProcAddress("glGetUniformuiv"); + if(!_ptrc_glGetUniformuiv) numFailed++; + _ptrc_glGetVertexAttribIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetVertexAttribIiv"); + if(!_ptrc_glGetVertexAttribIiv) numFailed++; + _ptrc_glGetVertexAttribIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress("glGetVertexAttribIuiv"); + if(!_ptrc_glGetVertexAttribIuiv) numFailed++; + _ptrc_glIsEnabledi = (GLboolean (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glIsEnabledi"); + if(!_ptrc_glIsEnabledi) numFailed++; + _ptrc_glIsFramebuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsFramebuffer"); + if(!_ptrc_glIsFramebuffer) numFailed++; + _ptrc_glIsRenderbuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsRenderbuffer"); + if(!_ptrc_glIsRenderbuffer) numFailed++; + _ptrc_glIsVertexArray = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsVertexArray"); + if(!_ptrc_glIsVertexArray) numFailed++; + _ptrc_glMapBufferRange = (void * (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, GLbitfield))IntGetProcAddress("glMapBufferRange"); + if(!_ptrc_glMapBufferRange) numFailed++; + _ptrc_glRenderbufferStorage = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLsizei, GLsizei))IntGetProcAddress("glRenderbufferStorage"); + if(!_ptrc_glRenderbufferStorage) numFailed++; + _ptrc_glRenderbufferStorageMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei))IntGetProcAddress("glRenderbufferStorageMultisample"); + if(!_ptrc_glRenderbufferStorageMultisample) numFailed++; + _ptrc_glTexParameterIiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress("glTexParameterIiv"); + if(!_ptrc_glTexParameterIiv) numFailed++; + _ptrc_glTexParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLuint *))IntGetProcAddress("glTexParameterIuiv"); + if(!_ptrc_glTexParameterIuiv) numFailed++; + _ptrc_glTransformFeedbackVaryings = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, GLenum))IntGetProcAddress("glTransformFeedbackVaryings"); + if(!_ptrc_glTransformFeedbackVaryings) numFailed++; + _ptrc_glUniform1ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint))IntGetProcAddress("glUniform1ui"); + if(!_ptrc_glUniform1ui) numFailed++; + _ptrc_glUniform1uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress("glUniform1uiv"); + if(!_ptrc_glUniform1uiv) numFailed++; + _ptrc_glUniform2ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint))IntGetProcAddress("glUniform2ui"); + if(!_ptrc_glUniform2ui) numFailed++; + _ptrc_glUniform2uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress("glUniform2uiv"); + if(!_ptrc_glUniform2uiv) numFailed++; + _ptrc_glUniform3ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint, GLuint))IntGetProcAddress("glUniform3ui"); + if(!_ptrc_glUniform3ui) numFailed++; + _ptrc_glUniform3uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress("glUniform3uiv"); + if(!_ptrc_glUniform3uiv) numFailed++; + _ptrc_glUniform4ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint, GLuint, GLuint))IntGetProcAddress("glUniform4ui"); + if(!_ptrc_glUniform4ui) numFailed++; + _ptrc_glUniform4uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress("glUniform4uiv"); + if(!_ptrc_glUniform4uiv) numFailed++; + _ptrc_glVertexAttribI1i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint))IntGetProcAddress("glVertexAttribI1i"); + if(!_ptrc_glVertexAttribI1i) numFailed++; + _ptrc_glVertexAttribI1iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress("glVertexAttribI1iv"); + if(!_ptrc_glVertexAttribI1iv) numFailed++; + _ptrc_glVertexAttribI1ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress("glVertexAttribI1ui"); + if(!_ptrc_glVertexAttribI1ui) numFailed++; + _ptrc_glVertexAttribI1uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress("glVertexAttribI1uiv"); + if(!_ptrc_glVertexAttribI1uiv) numFailed++; + _ptrc_glVertexAttribI2i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint))IntGetProcAddress("glVertexAttribI2i"); + if(!_ptrc_glVertexAttribI2i) numFailed++; + _ptrc_glVertexAttribI2iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress("glVertexAttribI2iv"); + if(!_ptrc_glVertexAttribI2iv) numFailed++; + _ptrc_glVertexAttribI2ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress("glVertexAttribI2ui"); + if(!_ptrc_glVertexAttribI2ui) numFailed++; + _ptrc_glVertexAttribI2uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress("glVertexAttribI2uiv"); + if(!_ptrc_glVertexAttribI2uiv) numFailed++; + _ptrc_glVertexAttribI3i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint, GLint))IntGetProcAddress("glVertexAttribI3i"); + if(!_ptrc_glVertexAttribI3i) numFailed++; + _ptrc_glVertexAttribI3iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress("glVertexAttribI3iv"); + if(!_ptrc_glVertexAttribI3iv) numFailed++; + _ptrc_glVertexAttribI3ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, GLuint))IntGetProcAddress("glVertexAttribI3ui"); + if(!_ptrc_glVertexAttribI3ui) numFailed++; + _ptrc_glVertexAttribI3uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress("glVertexAttribI3uiv"); + if(!_ptrc_glVertexAttribI3uiv) numFailed++; + _ptrc_glVertexAttribI4bv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress("glVertexAttribI4bv"); + if(!_ptrc_glVertexAttribI4bv) numFailed++; + _ptrc_glVertexAttribI4i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint, GLint, GLint))IntGetProcAddress("glVertexAttribI4i"); + if(!_ptrc_glVertexAttribI4i) numFailed++; + _ptrc_glVertexAttribI4iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress("glVertexAttribI4iv"); + if(!_ptrc_glVertexAttribI4iv) numFailed++; + _ptrc_glVertexAttribI4sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress("glVertexAttribI4sv"); + if(!_ptrc_glVertexAttribI4sv) numFailed++; + _ptrc_glVertexAttribI4ubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress("glVertexAttribI4ubv"); + if(!_ptrc_glVertexAttribI4ubv) numFailed++; + _ptrc_glVertexAttribI4ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, GLuint, GLuint))IntGetProcAddress("glVertexAttribI4ui"); + if(!_ptrc_glVertexAttribI4ui) numFailed++; + _ptrc_glVertexAttribI4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress("glVertexAttribI4uiv"); + if(!_ptrc_glVertexAttribI4uiv) numFailed++; + _ptrc_glVertexAttribI4usv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress("glVertexAttribI4usv"); + if(!_ptrc_glVertexAttribI4usv) numFailed++; + _ptrc_glVertexAttribIPointer = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glVertexAttribIPointer"); + if(!_ptrc_glVertexAttribIPointer) numFailed++; + _ptrc_glCopyBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr))IntGetProcAddress("glCopyBufferSubData"); + if(!_ptrc_glCopyBufferSubData) numFailed++; + _ptrc_glDrawArraysInstanced = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLsizei, GLsizei))IntGetProcAddress("glDrawArraysInstanced"); + if(!_ptrc_glDrawArraysInstanced) numFailed++; + _ptrc_glDrawElementsInstanced = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei))IntGetProcAddress("glDrawElementsInstanced"); + if(!_ptrc_glDrawElementsInstanced) numFailed++; + _ptrc_glGetActiveUniformBlockName = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetActiveUniformBlockName"); + if(!_ptrc_glGetActiveUniformBlockName) numFailed++; + _ptrc_glGetActiveUniformBlockiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLenum, GLint *))IntGetProcAddress("glGetActiveUniformBlockiv"); + if(!_ptrc_glGetActiveUniformBlockiv) numFailed++; + _ptrc_glGetActiveUniformName = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetActiveUniformName"); + if(!_ptrc_glGetActiveUniformName) numFailed++; + _ptrc_glGetActiveUniformsiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLuint *, GLenum, GLint *))IntGetProcAddress("glGetActiveUniformsiv"); + if(!_ptrc_glGetActiveUniformsiv) numFailed++; + _ptrc_glGetUniformBlockIndex = (GLuint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress("glGetUniformBlockIndex"); + if(!_ptrc_glGetUniformBlockIndex) numFailed++; + _ptrc_glGetUniformIndices = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, GLuint *))IntGetProcAddress("glGetUniformIndices"); + if(!_ptrc_glGetUniformIndices) numFailed++; + _ptrc_glPrimitiveRestartIndex = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glPrimitiveRestartIndex"); + if(!_ptrc_glPrimitiveRestartIndex) numFailed++; + _ptrc_glTexBuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint))IntGetProcAddress("glTexBuffer"); + if(!_ptrc_glTexBuffer) numFailed++; + _ptrc_glUniformBlockBinding = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress("glUniformBlockBinding"); + if(!_ptrc_glUniformBlockBinding) numFailed++; + _ptrc_glClientWaitSync = (GLenum (CODEGEN_FUNCPTR *)(GLsync, GLbitfield, GLuint64))IntGetProcAddress("glClientWaitSync"); + if(!_ptrc_glClientWaitSync) numFailed++; + _ptrc_glDeleteSync = (void (CODEGEN_FUNCPTR *)(GLsync))IntGetProcAddress("glDeleteSync"); + if(!_ptrc_glDeleteSync) numFailed++; + _ptrc_glDrawElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLint))IntGetProcAddress("glDrawElementsBaseVertex"); + if(!_ptrc_glDrawElementsBaseVertex) numFailed++; + _ptrc_glDrawElementsInstancedBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint))IntGetProcAddress("glDrawElementsInstancedBaseVertex"); + if(!_ptrc_glDrawElementsInstancedBaseVertex) numFailed++; + _ptrc_glDrawRangeElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint))IntGetProcAddress("glDrawRangeElementsBaseVertex"); + if(!_ptrc_glDrawRangeElementsBaseVertex) numFailed++; + _ptrc_glFenceSync = (GLsync (CODEGEN_FUNCPTR *)(GLenum, GLbitfield))IntGetProcAddress("glFenceSync"); + if(!_ptrc_glFenceSync) numFailed++; + _ptrc_glFramebufferTexture = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint, GLint))IntGetProcAddress("glFramebufferTexture"); + if(!_ptrc_glFramebufferTexture) numFailed++; + _ptrc_glGetBufferParameteri64v = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint64 *))IntGetProcAddress("glGetBufferParameteri64v"); + if(!_ptrc_glGetBufferParameteri64v) numFailed++; + _ptrc_glGetInteger64i_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLint64 *))IntGetProcAddress("glGetInteger64i_v"); + if(!_ptrc_glGetInteger64i_v) numFailed++; + _ptrc_glGetInteger64v = (void (CODEGEN_FUNCPTR *)(GLenum, GLint64 *))IntGetProcAddress("glGetInteger64v"); + if(!_ptrc_glGetInteger64v) numFailed++; + _ptrc_glGetMultisamplefv = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLfloat *))IntGetProcAddress("glGetMultisamplefv"); + if(!_ptrc_glGetMultisamplefv) numFailed++; + _ptrc_glGetSynciv = (void (CODEGEN_FUNCPTR *)(GLsync, GLenum, GLsizei, GLsizei *, GLint *))IntGetProcAddress("glGetSynciv"); + if(!_ptrc_glGetSynciv) numFailed++; + _ptrc_glIsSync = (GLboolean (CODEGEN_FUNCPTR *)(GLsync))IntGetProcAddress("glIsSync"); + if(!_ptrc_glIsSync) numFailed++; + _ptrc_glMultiDrawElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *))IntGetProcAddress("glMultiDrawElementsBaseVertex"); + if(!_ptrc_glMultiDrawElementsBaseVertex) numFailed++; + _ptrc_glProvokingVertex = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glProvokingVertex"); + if(!_ptrc_glProvokingVertex) numFailed++; + _ptrc_glSampleMaski = (void (CODEGEN_FUNCPTR *)(GLuint, GLbitfield))IntGetProcAddress("glSampleMaski"); + if(!_ptrc_glSampleMaski) numFailed++; + _ptrc_glTexImage2DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean))IntGetProcAddress("glTexImage2DMultisample"); + if(!_ptrc_glTexImage2DMultisample) numFailed++; + _ptrc_glTexImage3DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean))IntGetProcAddress("glTexImage3DMultisample"); + if(!_ptrc_glTexImage3DMultisample) numFailed++; + _ptrc_glWaitSync = (void (CODEGEN_FUNCPTR *)(GLsync, GLbitfield, GLuint64))IntGetProcAddress("glWaitSync"); + if(!_ptrc_glWaitSync) numFailed++; + _ptrc_glBindFragDataLocationIndexed = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, const GLchar *))IntGetProcAddress("glBindFragDataLocationIndexed"); + if(!_ptrc_glBindFragDataLocationIndexed) numFailed++; + _ptrc_glBindSampler = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress("glBindSampler"); + if(!_ptrc_glBindSampler) numFailed++; + _ptrc_glDeleteSamplers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteSamplers"); + if(!_ptrc_glDeleteSamplers) numFailed++; + _ptrc_glGenSamplers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenSamplers"); + if(!_ptrc_glGenSamplers) numFailed++; + _ptrc_glGetFragDataIndex = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress("glGetFragDataIndex"); + if(!_ptrc_glGetFragDataIndex) numFailed++; + _ptrc_glGetQueryObjecti64v = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint64 *))IntGetProcAddress("glGetQueryObjecti64v"); + if(!_ptrc_glGetQueryObjecti64v) numFailed++; + _ptrc_glGetQueryObjectui64v = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint64 *))IntGetProcAddress("glGetQueryObjectui64v"); + if(!_ptrc_glGetQueryObjectui64v) numFailed++; + _ptrc_glGetSamplerParameterIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetSamplerParameterIiv"); + if(!_ptrc_glGetSamplerParameterIiv) numFailed++; + _ptrc_glGetSamplerParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress("glGetSamplerParameterIuiv"); + if(!_ptrc_glGetSamplerParameterIuiv) numFailed++; + _ptrc_glGetSamplerParameterfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat *))IntGetProcAddress("glGetSamplerParameterfv"); + if(!_ptrc_glGetSamplerParameterfv) numFailed++; + _ptrc_glGetSamplerParameteriv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetSamplerParameteriv"); + if(!_ptrc_glGetSamplerParameteriv) numFailed++; + _ptrc_glIsSampler = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsSampler"); + if(!_ptrc_glIsSampler) numFailed++; + _ptrc_glQueryCounter = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum))IntGetProcAddress("glQueryCounter"); + if(!_ptrc_glQueryCounter) numFailed++; + _ptrc_glSamplerParameterIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLint *))IntGetProcAddress("glSamplerParameterIiv"); + if(!_ptrc_glSamplerParameterIiv) numFailed++; + _ptrc_glSamplerParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLuint *))IntGetProcAddress("glSamplerParameterIuiv"); + if(!_ptrc_glSamplerParameterIuiv) numFailed++; + _ptrc_glSamplerParameterf = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat))IntGetProcAddress("glSamplerParameterf"); + if(!_ptrc_glSamplerParameterf) numFailed++; + _ptrc_glSamplerParameterfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLfloat *))IntGetProcAddress("glSamplerParameterfv"); + if(!_ptrc_glSamplerParameterfv) numFailed++; + _ptrc_glSamplerParameteri = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint))IntGetProcAddress("glSamplerParameteri"); + if(!_ptrc_glSamplerParameteri) numFailed++; + _ptrc_glSamplerParameteriv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLint *))IntGetProcAddress("glSamplerParameteriv"); + if(!_ptrc_glSamplerParameteriv) numFailed++; + _ptrc_glVertexAttribDivisor = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress("glVertexAttribDivisor"); + if(!_ptrc_glVertexAttribDivisor) numFailed++; + _ptrc_glVertexAttribP1ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress("glVertexAttribP1ui"); + if(!_ptrc_glVertexAttribP1ui) numFailed++; + _ptrc_glVertexAttribP1uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress("glVertexAttribP1uiv"); + if(!_ptrc_glVertexAttribP1uiv) numFailed++; + _ptrc_glVertexAttribP2ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress("glVertexAttribP2ui"); + if(!_ptrc_glVertexAttribP2ui) numFailed++; + _ptrc_glVertexAttribP2uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress("glVertexAttribP2uiv"); + if(!_ptrc_glVertexAttribP2uiv) numFailed++; + _ptrc_glVertexAttribP3ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress("glVertexAttribP3ui"); + if(!_ptrc_glVertexAttribP3ui) numFailed++; + _ptrc_glVertexAttribP3uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress("glVertexAttribP3uiv"); + if(!_ptrc_glVertexAttribP3uiv) numFailed++; + _ptrc_glVertexAttribP4ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress("glVertexAttribP4ui"); + if(!_ptrc_glVertexAttribP4ui) numFailed++; + _ptrc_glVertexAttribP4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress("glVertexAttribP4uiv"); + if(!_ptrc_glVertexAttribP4uiv) numFailed++; + return numFailed; +} + +typedef int (*PFN_LOADFUNCPOINTERS)(); +typedef struct ogl_StrToExtMap_s +{ + char *extensionName; + int *extensionVariable; + PFN_LOADFUNCPOINTERS LoadExtension; +} ogl_StrToExtMap; + +static ogl_StrToExtMap ExtensionMap[6] = { + {"GL_ARB_texture_compression", &ogl_ext_ARB_texture_compression, Load_ARB_texture_compression}, + {"GL_EXT_texture_compression_s3tc", &ogl_ext_EXT_texture_compression_s3tc, NULL}, + {"GL_ARB_buffer_storage", &ogl_ext_ARB_buffer_storage, Load_ARB_buffer_storage}, + {"GL_ARB_shader_storage_buffer_object", &ogl_ext_ARB_shader_storage_buffer_object, Load_ARB_shader_storage_buffer_object}, + {"GL_EXT_texture_sRGB", &ogl_ext_EXT_texture_sRGB, NULL}, + {"GL_EXT_texture_filter_anisotropic", &ogl_ext_EXT_texture_filter_anisotropic, NULL}, +}; + +static int g_extensionMapSize = 6; + +static ogl_StrToExtMap *FindExtEntry(const char *extensionName) +{ + int loop; + ogl_StrToExtMap *currLoc = ExtensionMap; + for(loop = 0; loop < g_extensionMapSize; ++loop, ++currLoc) + { + if(strcmp(extensionName, currLoc->extensionName) == 0) + return currLoc; + } + + return NULL; +} + +static void ClearExtensionVars() +{ + ogl_ext_ARB_texture_compression = ogl_LOAD_FAILED; + ogl_ext_EXT_texture_compression_s3tc = ogl_LOAD_FAILED; + ogl_ext_ARB_buffer_storage = ogl_LOAD_FAILED; + ogl_ext_ARB_shader_storage_buffer_object = ogl_LOAD_FAILED; + ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; + ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; +} + + +static void LoadExtByName(const char *extensionName) +{ + ogl_StrToExtMap *entry = NULL; + entry = FindExtEntry(extensionName); + if(entry) + { + if(entry->LoadExtension) + { + int numFailed = entry->LoadExtension(); + if(numFailed == 0) + { + *(entry->extensionVariable) = ogl_LOAD_SUCCEEDED; + } + else + { + *(entry->extensionVariable) = ogl_LOAD_SUCCEEDED + numFailed; + } + } + else + { + *(entry->extensionVariable) = ogl_LOAD_SUCCEEDED; + } + } +} + + +static void ProcExtsFromExtList() +{ + GLint iLoop; + GLint iNumExtensions = 0; + _ptrc_glGetIntegerv(GL_NUM_EXTENSIONS, &iNumExtensions); + + for(iLoop = 0; iLoop < iNumExtensions; iLoop++) + { + const char *strExtensionName = (const char *)_ptrc_glGetStringi(GL_EXTENSIONS, iLoop); + LoadExtByName(strExtensionName); + } +} + +int ogl_LoadFunctions() +{ + int numFailed = 0; + ClearExtensionVars(); + + _ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress("glGetIntegerv"); + if(!_ptrc_glGetIntegerv) return ogl_LOAD_FAILED; + _ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi"); + if(!_ptrc_glGetStringi) return ogl_LOAD_FAILED; + + ProcExtsFromExtList(); + numFailed = Load_Version_3_3(); + + if(numFailed == 0) + return ogl_LOAD_SUCCEEDED; + else + return ogl_LOAD_SUCCEEDED + numFailed; +} + +static int g_major_version = 0; +static int g_minor_version = 0; + +static void GetGLVersion() +{ + glGetIntegerv(GL_MAJOR_VERSION, &g_major_version); + glGetIntegerv(GL_MINOR_VERSION, &g_minor_version); +} + +int ogl_GetMajorVersion() +{ + if(g_major_version == 0) + GetGLVersion(); + return g_major_version; +} + +int ogl_GetMinorVersion() +{ + if(g_major_version == 0) //Yes, check the major version to get the minor one. + GetGLVersion(); + return g_minor_version; +} + +int ogl_IsVersionGEQ(int majorVersion, int minorVersion) +{ + if(g_major_version == 0) + GetGLVersion(); + + if(majorVersion > g_major_version) return 1; + if(majorVersion < g_major_version) return 0; + if(minorVersion >= g_minor_version) return 1; + return 0; +} + diff --git a/src/gl/system/gl_load.h b/src/gl/system/gl_load.h new file mode 100644 index 000000000..307f3893a --- /dev/null +++ b/src/gl/system/gl_load.h @@ -0,0 +1,1793 @@ +#ifndef POINTER_C_GENERATED_HEADER_OPENGL_H +#define POINTER_C_GENERATED_HEADER_OPENGL_H + +#if defined(__glew_h__) || defined(__GLEW_H__) +#error Attempt to include auto-generated header after including glew.h +#endif +#if defined(__gl_h_) || defined(__GL_H__) +#error Attempt to include auto-generated header after including gl.h +#endif +#if defined(__glext_h_) || defined(__GLEXT_H_) +#error Attempt to include auto-generated header after including glext.h +#endif +#if defined(__gltypes_h_) +#error Attempt to include auto-generated header after gltypes.h +#endif +#if defined(__gl_ATI_h_) +#error Attempt to include auto-generated header after including glATI.h +#endif + +#define __glew_h__ +#define __GLEW_H__ +#define __gl_h_ +#define __GL_H__ +#define __glext_h_ +#define __GLEXT_H_ +#define __gltypes_h_ +#define __gl_ATI_h_ + +#ifndef APIENTRY + #if defined(__MINGW32__) + #ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN 1 + #endif + #ifndef NOMINMAX + #define NOMINMAX + #endif + #include + #elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) + #ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN 1 + #endif + #ifndef NOMINMAX + #define NOMINMAX + #endif + #include + #else + #define APIENTRY + #endif +#endif /*APIENTRY*/ + +#ifndef CODEGEN_FUNCPTR + #define CODEGEN_REMOVE_FUNCPTR + #if defined(_WIN32) + #define CODEGEN_FUNCPTR APIENTRY + #else + #define CODEGEN_FUNCPTR + #endif +#endif /*CODEGEN_FUNCPTR*/ + +#ifndef GLAPI + #define GLAPI extern +#endif + + +#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS +#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS + + +#endif /*GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS*/ + + +#include +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif + typedef unsigned int GLenum; + typedef unsigned char GLboolean; + typedef unsigned int GLbitfield; + typedef void GLvoid; + typedef signed char GLbyte; + typedef short GLshort; + typedef int GLint; + typedef unsigned char GLubyte; + typedef unsigned short GLushort; + typedef unsigned int GLuint; + typedef int GLsizei; + typedef float GLfloat; + typedef float GLclampf; + typedef double GLdouble; + typedef double GLclampd; + typedef char GLchar; + typedef char GLcharARB; + #ifdef __APPLE__ +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; +#endif + typedef unsigned short GLhalfARB; + typedef unsigned short GLhalf; + typedef GLint GLfixed; + typedef ptrdiff_t GLintptr; + typedef ptrdiff_t GLsizeiptr; + typedef int64_t GLint64; + typedef uint64_t GLuint64; + typedef ptrdiff_t GLintptrARB; + typedef ptrdiff_t GLsizeiptrARB; + typedef int64_t GLint64EXT; + typedef uint64_t GLuint64EXT; + typedef struct __GLsync *GLsync; + struct _cl_context; + struct _cl_event; + typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); + typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); + typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); + typedef unsigned short GLhalfNV; + typedef GLintptr GLvdpauSurfaceNV; + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus*/ + +extern int ogl_ext_ARB_texture_compression; +extern int ogl_ext_EXT_texture_compression_s3tc; +extern int ogl_ext_ARB_buffer_storage; +extern int ogl_ext_ARB_shader_storage_buffer_object; +extern int ogl_ext_EXT_texture_sRGB; +extern int ogl_ext_EXT_texture_filter_anisotropic; + +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF + +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 + +#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F +#define GL_BUFFER_STORAGE_FLAGS 0x8220 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 +#define GL_CLIENT_STORAGE_BIT 0x0200 +#define GL_DYNAMIC_STORAGE_BIT 0x0100 +#define GL_MAP_COHERENT_BIT 0x0080 +#define GL_MAP_PERSISTENT_BIT 0x0040 +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 + +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 + +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB_EXT 0x8C40 + +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE + +#define GL_ALPHA 0x1906 +#define GL_ALWAYS 0x0207 +#define GL_AND 0x1501 +#define GL_AND_INVERTED 0x1504 +#define GL_AND_REVERSE 0x1502 +#define GL_BACK 0x0405 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_BLEND 0x0BE2 +#define GL_BLEND_DST 0x0BE0 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLUE 0x1905 +#define GL_BYTE 0x1400 +#define GL_CCW 0x0901 +#define GL_CLEAR 0x1500 +#define GL_COLOR 0x1800 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_COPY 0x1503 +#define GL_COPY_INVERTED 0x150C +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_CW 0x0900 +#define GL_DECR 0x1E03 +#define GL_DEPTH 0x1801 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DITHER 0x0BD0 +#define GL_DONT_CARE 0x1100 +#define GL_DOUBLE 0x140A +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_DST_ALPHA 0x0304 +#define GL_DST_COLOR 0x0306 +#define GL_EQUAL 0x0202 +#define GL_EQUIV 0x1509 +#define GL_EXTENSIONS 0x1F03 +#define GL_FALSE 0 +#define GL_FASTEST 0x1101 +#define GL_FILL 0x1B02 +#define GL_FLOAT 0x1406 +#define GL_FRONT 0x0404 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_FRONT_FACE 0x0B46 +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_GEQUAL 0x0206 +#define GL_GREATER 0x0204 +#define GL_GREEN 0x1904 +#define GL_INCR 0x1E02 +#define GL_INT 0x1404 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_OPERATION 0x0502 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVERT 0x150A +#define GL_KEEP 0x1E00 +#define GL_LEFT 0x0406 +#define GL_LEQUAL 0x0203 +#define GL_LESS 0x0201 +#define GL_LINE 0x1B01 +#define GL_LINEAR 0x2601 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_LINE_STRIP 0x0003 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_LINE_WIDTH_RANGE 0x0B22 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_NAND 0x150E +#define GL_NEAREST 0x2600 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_NEVER 0x0200 +#define GL_NICEST 0x1102 +#define GL_NONE 0 +#define GL_NOOP 0x1505 +#define GL_NOR 0x1508 +#define GL_NOTEQUAL 0x0205 +#define GL_NO_ERROR 0 +#define GL_ONE 1 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_OR 0x1507 +#define GL_OR_INVERTED 0x150D +#define GL_OR_REVERSE 0x150B +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_POINT 0x1B00 +#define GL_POINTS 0x0000 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_POINT_SIZE_RANGE 0x0B12 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_QUADS 0x0007 +#define GL_R3_G3_B2 0x2A10 +#define GL_READ_BUFFER 0x0C02 +#define GL_RED 0x1903 +#define GL_RENDERER 0x1F01 +#define GL_REPEAT 0x2901 +#define GL_REPLACE 0x1E01 +#define GL_RGB 0x1907 +#define GL_RGB10 0x8052 +#define GL_RGB10_A2 0x8059 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB5_A1 0x8057 +#define GL_RGB8 0x8051 +#define GL_RGBA 0x1908 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGBA8 0x8058 +#define GL_RIGHT 0x0407 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_SET 0x150F +#define GL_SHORT 0x1402 +#define GL_SRC_ALPHA 0x0302 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_SRC_COLOR 0x0300 +#define GL_STENCIL 0x1802 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_INDEX 0x1901 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STEREO 0x0C33 +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_TEXTURE 0x1702 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRUE 1 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_UNSIGNED_INT 0x1405 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_VENDOR 0x1F00 +#define GL_VERSION 0x1F02 +#define GL_VIEWPORT 0x0BA2 +#define GL_XOR 0x1506 +#define GL_ZERO 0 + +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_TEXTURE_3D 0x806F +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 + +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_MULTISAMPLE 0x809D +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 + +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_DECR_WRAP 0x8508 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_INCR_WRAP 0x8507 +#define GL_MAX 0x8008 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_MIN 0x8007 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_LOD_BIAS 0x8501 + +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_CURRENT_QUERY 0x8865 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_READ_ONLY 0x88B8 +#define GL_READ_WRITE 0x88BA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 +#define GL_STATIC_COPY 0x88E6 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STREAM_COPY 0x88E2 +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_WRITE_ONLY 0x88B9 + +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_DELETE_STATUS 0x8B80 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_LINK_STATUS 0x8B82 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_TYPE 0x8B4F +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_SHADER 0x8B31 + +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_SRGB_ALPHA 0x8C42 + +#define GL_BGRA_INTEGER 0x8D9B +#define GL_BGR_INTEGER 0x8D9A +#define GL_BLUE_INTEGER 0x8D96 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_RG 0x8226 +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_CONTEXT_FLAGS 0x821E +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_FIXED_ONLY 0x891D +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_FRAMEBUFFER 0x8D40 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_GREEN_INTEGER 0x8D95 +#define GL_HALF_FLOAT 0x140B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_MAJOR_VERSION 0x821B +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +/*Copied GL_MAP_READ_BIT From: ARB_buffer_storage*/ +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +/*Copied GL_MAP_WRITE_BIT From: ARB_buffer_storage*/ +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_MINOR_VERSION 0x821C +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_NUM_EXTENSIONS 0x821D +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_WAIT 0x8E13 +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_R16 0x822A +#define GL_R16F 0x822D +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32F 0x822E +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_R8 0x8229 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RED_INTEGER 0x8D94 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RG 0x8227 +#define GL_RG16 0x822C +#define GL_RG16F 0x822F +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32F 0x8230 +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_RG8 0x822B +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RGB16F 0x881B +#define GL_RGB16I 0x8D89 +#define GL_RGB16UI 0x8D77 +#define GL_RGB32F 0x8815 +#define GL_RGB32I 0x8D83 +#define GL_RGB32UI 0x8D71 +#define GL_RGB8I 0x8D8F +#define GL_RGB8UI 0x8D7D +#define GL_RGB9_E5 0x8C3D +#define GL_RGBA16F 0x881A +#define GL_RGBA16I 0x8D88 +#define GL_RGBA16UI 0x8D76 +#define GL_RGBA32F 0x8814 +#define GL_RGBA32I 0x8D82 +#define GL_RGBA32UI 0x8D70 +#define GL_RGBA8I 0x8D8E +#define GL_RGBA8UI 0x8D7C +#define GL_RGBA_INTEGER 0x8D99 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RG_INTEGER 0x8228 +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD + +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_INVALID_INDEX 0xFFFFFFFF +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_R16_SNORM 0x8F98 +#define GL_R8_SNORM 0x8F94 +#define GL_RG16_SNORM 0x8F99 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA16_SNORM 0x8F9B +#define GL_RGBA8_SNORM 0x8F97 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 + +#define GL_ALREADY_SIGNALED 0x911A +#define GL_CONDITION_SATISFIED 0x911C +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_INTEGER_SAMPLES 0x9110 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_OBJECT_TYPE 0x9112 +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SIGNALED 0x9119 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_SYNC_STATUS 0x9114 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_UNSIGNALED 0x9118 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_WAIT_FAILED 0x911D + +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_INT_2_10_10_10_REV 0x8D9F +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_RGB10_A2UI 0x906F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_SRC1_COLOR 0x88F9 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIMESTAMP 0x8E28 +#define GL_TIME_ELAPSED 0x88BF +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1DARB)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +#define glCompressedTexImage1DARB _ptrc_glCompressedTexImage1DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +#define glCompressedTexImage2DARB _ptrc_glCompressedTexImage2DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +#define glCompressedTexImage3DARB _ptrc_glCompressedTexImage3DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1DARB)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +#define glCompressedTexSubImage1DARB _ptrc_glCompressedTexSubImage1DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2DARB)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +#define glCompressedTexSubImage2DARB _ptrc_glCompressedTexSubImage2DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3DARB)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +#define glCompressedTexSubImage3DARB _ptrc_glCompressedTexSubImage3DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImageARB)(GLenum, GLint, GLvoid *); +#define glGetCompressedTexImageARB _ptrc_glGetCompressedTexImageARB +#endif /*GL_ARB_texture_compression*/ + + +#ifndef GL_ARB_buffer_storage +#define GL_ARB_buffer_storage 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum, GLsizeiptr, const void *, GLbitfield); +#define glBufferStorage _ptrc_glBufferStorage +#endif /*GL_ARB_buffer_storage*/ + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glShaderStorageBlockBinding)(GLuint, GLuint, GLuint); +#define glShaderStorageBlockBinding _ptrc_glShaderStorageBlockBinding +#endif /*GL_ARB_shader_storage_buffer_object*/ + + +extern void (CODEGEN_FUNCPTR *_ptrc_glBegin)(GLenum); +#define glBegin _ptrc_glBegin +extern void (CODEGEN_FUNCPTR *_ptrc_glEnd)(); +#define glEnd _ptrc_glEnd + + +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum, GLenum); +#define glBlendFunc _ptrc_glBlendFunc +extern void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield); +#define glClear _ptrc_glClear +extern void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat); +#define glClearColor _ptrc_glClearColor +extern void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble); +#define glClearDepth _ptrc_glClearDepth +extern void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint); +#define glClearStencil _ptrc_glClearStencil +extern void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean); +#define glColorMask _ptrc_glColorMask +extern void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum); +#define glCullFace _ptrc_glCullFace +extern void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum); +#define glDepthFunc _ptrc_glDepthFunc +extern void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean); +#define glDepthMask _ptrc_glDepthMask +extern void (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble, GLdouble); +#define glDepthRange _ptrc_glDepthRange +extern void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum); +#define glDisable _ptrc_glDisable +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum); +#define glDrawBuffer _ptrc_glDrawBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum); +#define glEnable _ptrc_glEnable +extern void (CODEGEN_FUNCPTR *_ptrc_glFinish)(); +#define glFinish _ptrc_glFinish +extern void (CODEGEN_FUNCPTR *_ptrc_glFlush)(); +#define glFlush _ptrc_glFlush +extern void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum); +#define glFrontFace _ptrc_glFrontFace +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum, GLboolean *); +#define glGetBooleanv _ptrc_glGetBooleanv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum, GLdouble *); +#define glGetDoublev _ptrc_glGetDoublev +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)(); +#define glGetError _ptrc_glGetError +extern void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum, GLfloat *); +#define glGetFloatv _ptrc_glGetFloatv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum, GLint *); +#define glGetIntegerv _ptrc_glGetIntegerv +extern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum); +#define glGetString _ptrc_glGetString +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *); +#define glGetTexImage _ptrc_glGetTexImage +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *); +#define glGetTexLevelParameterfv _ptrc_glGetTexLevelParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *); +#define glGetTexLevelParameteriv _ptrc_glGetTexLevelParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum, GLenum, GLfloat *); +#define glGetTexParameterfv _ptrc_glGetTexParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum, GLenum, GLint *); +#define glGetTexParameteriv _ptrc_glGetTexParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum, GLenum); +#define glHint _ptrc_glHint +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum); +#define glIsEnabled _ptrc_glIsEnabled +extern void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat); +#define glLineWidth _ptrc_glLineWidth +extern void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum); +#define glLogicOp _ptrc_glLogicOp +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum, GLfloat); +#define glPixelStoref _ptrc_glPixelStoref +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum, GLint); +#define glPixelStorei _ptrc_glPixelStorei +extern void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat); +#define glPointSize _ptrc_glPointSize +extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum, GLenum); +#define glPolygonMode _ptrc_glPolygonMode +extern void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum); +#define glReadBuffer _ptrc_glReadBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *); +#define glReadPixels _ptrc_glReadPixels +extern void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint, GLint, GLsizei, GLsizei); +#define glScissor _ptrc_glScissor +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum, GLint, GLuint); +#define glStencilFunc _ptrc_glStencilFunc +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint); +#define glStencilMask _ptrc_glStencilMask +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum, GLenum, GLenum); +#define glStencilOp _ptrc_glStencilOp +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +#define glTexImage1D _ptrc_glTexImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +#define glTexImage2D _ptrc_glTexImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum, GLenum, GLfloat); +#define glTexParameterf _ptrc_glTexParameterf +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum, GLenum, const GLfloat *); +#define glTexParameterfv _ptrc_glTexParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum, GLenum, GLint); +#define glTexParameteri _ptrc_glTexParameteri +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum, GLenum, const GLint *); +#define glTexParameteriv _ptrc_glTexParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint, GLint, GLsizei, GLsizei); +#define glViewport _ptrc_glViewport + +extern void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum, GLuint); +#define glBindTexture _ptrc_glBindTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +#define glCopyTexImage1D _ptrc_glCopyTexImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +#define glCopyTexImage2D _ptrc_glCopyTexImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei); +#define glCopyTexSubImage1D _ptrc_glCopyTexSubImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#define glCopyTexSubImage2D _ptrc_glCopyTexSubImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei, const GLuint *); +#define glDeleteTextures _ptrc_glDeleteTextures +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum, GLint, GLsizei); +#define glDrawArrays _ptrc_glDrawArrays +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum, GLsizei, GLenum, const GLvoid *); +#define glDrawElements _ptrc_glDrawElements +extern void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei, GLuint *); +#define glGenTextures _ptrc_glGenTextures +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint); +#define glIsTexture _ptrc_glIsTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat, GLfloat); +#define glPolygonOffset _ptrc_glPolygonOffset +extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +#define glTexSubImage1D _ptrc_glTexSubImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#define glTexSubImage2D _ptrc_glTexSubImage2D + +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat); +#define glBlendColor _ptrc_glBlendColor +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum); +#define glBlendEquation _ptrc_glBlendEquation +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#define glCopyTexSubImage3D _ptrc_glCopyTexSubImage3D +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +#define glDrawRangeElements _ptrc_glDrawRangeElements +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +#define glTexImage3D _ptrc_glTexImage3D +extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#define glTexSubImage3D _ptrc_glTexSubImage3D + +extern void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum); +#define glActiveTexture _ptrc_glActiveTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +#define glCompressedTexImage1D _ptrc_glCompressedTexImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +#define glCompressedTexImage2D _ptrc_glCompressedTexImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +#define glCompressedTexImage3D _ptrc_glCompressedTexImage3D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +#define glCompressedTexSubImage1D _ptrc_glCompressedTexSubImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +#define glCompressedTexSubImage2D _ptrc_glCompressedTexSubImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +#define glCompressedTexSubImage3D _ptrc_glCompressedTexSubImage3D +extern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum, GLint, GLvoid *); +#define glGetCompressedTexImage _ptrc_glGetCompressedTexImage +extern void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat, GLboolean); +#define glSampleCoverage _ptrc_glSampleCoverage + +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum); +#define glBlendFuncSeparate _ptrc_glBlendFuncSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum, const GLint *, const GLsizei *, GLsizei); +#define glMultiDrawArrays _ptrc_glMultiDrawArrays +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei); +#define glMultiDrawElements _ptrc_glMultiDrawElements +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum, GLfloat); +#define glPointParameterf _ptrc_glPointParameterf +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum, const GLfloat *); +#define glPointParameterfv _ptrc_glPointParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum, GLint); +#define glPointParameteri _ptrc_glPointParameteri +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum, const GLint *); +#define glPointParameteriv _ptrc_glPointParameteriv + +extern void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum, GLuint); +#define glBeginQuery _ptrc_glBeginQuery +extern void (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum, GLuint); +#define glBindBuffer _ptrc_glBindBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum, GLsizeiptr, const GLvoid *, GLenum); +#define glBufferData _ptrc_glBufferData +extern void (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const GLvoid *); +#define glBufferSubData _ptrc_glBufferSubData +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei, const GLuint *); +#define glDeleteBuffers _ptrc_glDeleteBuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei, const GLuint *); +#define glDeleteQueries _ptrc_glDeleteQueries +extern void (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum); +#define glEndQuery _ptrc_glEndQuery +extern void (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei, GLuint *); +#define glGenBuffers _ptrc_glGenBuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei, GLuint *); +#define glGenQueries _ptrc_glGenQueries +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum, GLenum, GLint *); +#define glGetBufferParameteriv _ptrc_glGetBufferParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum, GLenum, GLvoid **); +#define glGetBufferPointerv _ptrc_glGetBufferPointerv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum, GLintptr, GLsizeiptr, GLvoid *); +#define glGetBufferSubData _ptrc_glGetBufferSubData +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint, GLenum, GLint *); +#define glGetQueryObjectiv _ptrc_glGetQueryObjectiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint, GLenum, GLuint *); +#define glGetQueryObjectuiv _ptrc_glGetQueryObjectuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum, GLenum, GLint *); +#define glGetQueryiv _ptrc_glGetQueryiv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint); +#define glIsBuffer _ptrc_glIsBuffer +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint); +#define glIsQuery _ptrc_glIsQuery +extern void * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum, GLenum); +#define glMapBuffer _ptrc_glMapBuffer +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum); +#define glUnmapBuffer _ptrc_glUnmapBuffer + +extern void (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint, GLuint); +#define glAttachShader _ptrc_glAttachShader +extern void (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint, GLuint, const GLchar *); +#define glBindAttribLocation _ptrc_glBindAttribLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum, GLenum); +#define glBlendEquationSeparate _ptrc_glBlendEquationSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint); +#define glCompileShader _ptrc_glCompileShader +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)(); +#define glCreateProgram _ptrc_glCreateProgram +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum); +#define glCreateShader _ptrc_glCreateShader +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint); +#define glDeleteProgram _ptrc_glDeleteProgram +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint); +#define glDeleteShader _ptrc_glDeleteShader +extern void (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint, GLuint); +#define glDetachShader _ptrc_glDetachShader +extern void (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint); +#define glDisableVertexAttribArray _ptrc_glDisableVertexAttribArray +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei, const GLenum *); +#define glDrawBuffers _ptrc_glDrawBuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint); +#define glEnableVertexAttribArray _ptrc_glEnableVertexAttribArray +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +#define glGetActiveAttrib _ptrc_glGetActiveAttrib +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +#define glGetActiveUniform _ptrc_glGetActiveUniform +extern void (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint, GLsizei, GLsizei *, GLuint *); +#define glGetAttachedShaders _ptrc_glGetAttachedShaders +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint, const GLchar *); +#define glGetAttribLocation _ptrc_glGetAttribLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *); +#define glGetProgramInfoLog _ptrc_glGetProgramInfoLog +extern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint, GLenum, GLint *); +#define glGetProgramiv _ptrc_glGetProgramiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *); +#define glGetShaderInfoLog _ptrc_glGetShaderInfoLog +extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint, GLsizei, GLsizei *, GLchar *); +#define glGetShaderSource _ptrc_glGetShaderSource +extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint, GLenum, GLint *); +#define glGetShaderiv _ptrc_glGetShaderiv +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint, const GLchar *); +#define glGetUniformLocation _ptrc_glGetUniformLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint, GLint, GLfloat *); +#define glGetUniformfv _ptrc_glGetUniformfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint, GLint, GLint *); +#define glGetUniformiv _ptrc_glGetUniformiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint, GLenum, GLvoid **); +#define glGetVertexAttribPointerv _ptrc_glGetVertexAttribPointerv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint, GLenum, GLdouble *); +#define glGetVertexAttribdv _ptrc_glGetVertexAttribdv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint, GLenum, GLfloat *); +#define glGetVertexAttribfv _ptrc_glGetVertexAttribfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint, GLenum, GLint *); +#define glGetVertexAttribiv _ptrc_glGetVertexAttribiv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint); +#define glIsProgram _ptrc_glIsProgram +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint); +#define glIsShader _ptrc_glIsShader +extern void (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint); +#define glLinkProgram _ptrc_glLinkProgram +extern void (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint, GLsizei, const GLchar *const*, const GLint *); +#define glShaderSource _ptrc_glShaderSource +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint); +#define glStencilFuncSeparate _ptrc_glStencilFuncSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum, GLuint); +#define glStencilMaskSeparate _ptrc_glStencilMaskSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum); +#define glStencilOpSeparate _ptrc_glStencilOpSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint, GLfloat); +#define glUniform1f _ptrc_glUniform1f +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint, GLsizei, const GLfloat *); +#define glUniform1fv _ptrc_glUniform1fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint, GLint); +#define glUniform1i _ptrc_glUniform1i +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint, GLsizei, const GLint *); +#define glUniform1iv _ptrc_glUniform1iv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint, GLfloat, GLfloat); +#define glUniform2f _ptrc_glUniform2f +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint, GLsizei, const GLfloat *); +#define glUniform2fv _ptrc_glUniform2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint, GLint, GLint); +#define glUniform2i _ptrc_glUniform2i +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint, GLsizei, const GLint *); +#define glUniform2iv _ptrc_glUniform2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint, GLfloat, GLfloat, GLfloat); +#define glUniform3f _ptrc_glUniform3f +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint, GLsizei, const GLfloat *); +#define glUniform3fv _ptrc_glUniform3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint, GLint, GLint, GLint); +#define glUniform3i _ptrc_glUniform3i +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint, GLsizei, const GLint *); +#define glUniform3iv _ptrc_glUniform3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat); +#define glUniform4f _ptrc_glUniform4f +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint, GLsizei, const GLfloat *); +#define glUniform4fv _ptrc_glUniform4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint, GLint, GLint, GLint, GLint); +#define glUniform4i _ptrc_glUniform4i +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint, GLsizei, const GLint *); +#define glUniform4iv _ptrc_glUniform4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix2fv _ptrc_glUniformMatrix2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix3fv _ptrc_glUniformMatrix3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix4fv _ptrc_glUniformMatrix4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint); +#define glUseProgram _ptrc_glUseProgram +extern void (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint); +#define glValidateProgram _ptrc_glValidateProgram +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint, GLdouble); +#define glVertexAttrib1d _ptrc_glVertexAttrib1d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint, const GLdouble *); +#define glVertexAttrib1dv _ptrc_glVertexAttrib1dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint, GLfloat); +#define glVertexAttrib1f _ptrc_glVertexAttrib1f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint, const GLfloat *); +#define glVertexAttrib1fv _ptrc_glVertexAttrib1fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint, GLshort); +#define glVertexAttrib1s _ptrc_glVertexAttrib1s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint, const GLshort *); +#define glVertexAttrib1sv _ptrc_glVertexAttrib1sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint, GLdouble, GLdouble); +#define glVertexAttrib2d _ptrc_glVertexAttrib2d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint, const GLdouble *); +#define glVertexAttrib2dv _ptrc_glVertexAttrib2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint, GLfloat, GLfloat); +#define glVertexAttrib2f _ptrc_glVertexAttrib2f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint, const GLfloat *); +#define glVertexAttrib2fv _ptrc_glVertexAttrib2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint, GLshort, GLshort); +#define glVertexAttrib2s _ptrc_glVertexAttrib2s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint, const GLshort *); +#define glVertexAttrib2sv _ptrc_glVertexAttrib2sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint, GLdouble, GLdouble, GLdouble); +#define glVertexAttrib3d _ptrc_glVertexAttrib3d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint, const GLdouble *); +#define glVertexAttrib3dv _ptrc_glVertexAttrib3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat); +#define glVertexAttrib3f _ptrc_glVertexAttrib3f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint, const GLfloat *); +#define glVertexAttrib3fv _ptrc_glVertexAttrib3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint, GLshort, GLshort, GLshort); +#define glVertexAttrib3s _ptrc_glVertexAttrib3s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint, const GLshort *); +#define glVertexAttrib3sv _ptrc_glVertexAttrib3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint, const GLbyte *); +#define glVertexAttrib4Nbv _ptrc_glVertexAttrib4Nbv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint, const GLint *); +#define glVertexAttrib4Niv _ptrc_glVertexAttrib4Niv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint, const GLshort *); +#define glVertexAttrib4Nsv _ptrc_glVertexAttrib4Nsv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +#define glVertexAttrib4Nub _ptrc_glVertexAttrib4Nub +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint, const GLubyte *); +#define glVertexAttrib4Nubv _ptrc_glVertexAttrib4Nubv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint, const GLuint *); +#define glVertexAttrib4Nuiv _ptrc_glVertexAttrib4Nuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint, const GLushort *); +#define glVertexAttrib4Nusv _ptrc_glVertexAttrib4Nusv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint, const GLbyte *); +#define glVertexAttrib4bv _ptrc_glVertexAttrib4bv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +#define glVertexAttrib4d _ptrc_glVertexAttrib4d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint, const GLdouble *); +#define glVertexAttrib4dv _ptrc_glVertexAttrib4dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +#define glVertexAttrib4f _ptrc_glVertexAttrib4f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint, const GLfloat *); +#define glVertexAttrib4fv _ptrc_glVertexAttrib4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint, const GLint *); +#define glVertexAttrib4iv _ptrc_glVertexAttrib4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint, GLshort, GLshort, GLshort, GLshort); +#define glVertexAttrib4s _ptrc_glVertexAttrib4s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint, const GLshort *); +#define glVertexAttrib4sv _ptrc_glVertexAttrib4sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint, const GLubyte *); +#define glVertexAttrib4ubv _ptrc_glVertexAttrib4ubv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint, const GLuint *); +#define glVertexAttrib4uiv _ptrc_glVertexAttrib4uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint, const GLushort *); +#define glVertexAttrib4usv _ptrc_glVertexAttrib4usv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +#define glVertexAttribPointer _ptrc_glVertexAttribPointer + +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix2x3fv _ptrc_glUniformMatrix2x3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix2x4fv _ptrc_glUniformMatrix2x4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix3x2fv _ptrc_glUniformMatrix3x2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix3x4fv _ptrc_glUniformMatrix3x4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix4x2fv _ptrc_glUniformMatrix4x2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix4x3fv _ptrc_glUniformMatrix4x3fv + +extern void (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint, GLenum); +#define glBeginConditionalRender _ptrc_glBeginConditionalRender +extern void (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum); +#define glBeginTransformFeedback _ptrc_glBeginTransformFeedback +extern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum, GLuint, GLuint); +#define glBindBufferBase _ptrc_glBindBufferBase +extern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr); +#define glBindBufferRange _ptrc_glBindBufferRange +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint, GLuint, const GLchar *); +#define glBindFragDataLocation _ptrc_glBindFragDataLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum, GLuint); +#define glBindFramebuffer _ptrc_glBindFramebuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum, GLuint); +#define glBindRenderbuffer _ptrc_glBindRenderbuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint); +#define glBindVertexArray _ptrc_glBindVertexArray +extern void (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); +#define glBlitFramebuffer _ptrc_glBlitFramebuffer +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum); +#define glCheckFramebufferStatus _ptrc_glCheckFramebufferStatus +extern void (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum, GLenum); +#define glClampColor _ptrc_glClampColor +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum, GLint, GLfloat, GLint); +#define glClearBufferfi _ptrc_glClearBufferfi +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum, GLint, const GLfloat *); +#define glClearBufferfv _ptrc_glClearBufferfv +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum, GLint, const GLint *); +#define glClearBufferiv _ptrc_glClearBufferiv +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum, GLint, const GLuint *); +#define glClearBufferuiv _ptrc_glClearBufferuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean); +#define glColorMaski _ptrc_glColorMaski +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei, const GLuint *); +#define glDeleteFramebuffers _ptrc_glDeleteFramebuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei, const GLuint *); +#define glDeleteRenderbuffers _ptrc_glDeleteRenderbuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei, const GLuint *); +#define glDeleteVertexArrays _ptrc_glDeleteVertexArrays +extern void (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum, GLuint); +#define glDisablei _ptrc_glDisablei +extern void (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum, GLuint); +#define glEnablei _ptrc_glEnablei +extern void (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)(); +#define glEndConditionalRender _ptrc_glEndConditionalRender +extern void (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)(); +#define glEndTransformFeedback _ptrc_glEndTransformFeedback +extern void (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr); +#define glFlushMappedBufferRange _ptrc_glFlushMappedBufferRange +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint); +#define glFramebufferRenderbuffer _ptrc_glFramebufferRenderbuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum, GLenum, GLenum, GLuint, GLint); +#define glFramebufferTexture1D _ptrc_glFramebufferTexture1D +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint); +#define glFramebufferTexture2D _ptrc_glFramebufferTexture2D +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum, GLenum, GLenum, GLuint, GLint, GLint); +#define glFramebufferTexture3D _ptrc_glFramebufferTexture3D +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum, GLenum, GLuint, GLint, GLint); +#define glFramebufferTextureLayer _ptrc_glFramebufferTextureLayer +extern void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei, GLuint *); +#define glGenFramebuffers _ptrc_glGenFramebuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei, GLuint *); +#define glGenRenderbuffers _ptrc_glGenRenderbuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei, GLuint *); +#define glGenVertexArrays _ptrc_glGenVertexArrays +extern void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum); +#define glGenerateMipmap _ptrc_glGenerateMipmap +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum, GLuint, GLboolean *); +#define glGetBooleani_v _ptrc_glGetBooleani_v +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint, const GLchar *); +#define glGetFragDataLocation _ptrc_glGetFragDataLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint *); +#define glGetFramebufferAttachmentParameteriv _ptrc_glGetFramebufferAttachmentParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum, GLuint, GLint *); +#define glGetIntegeri_v _ptrc_glGetIntegeri_v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum, GLenum, GLint *); +#define glGetRenderbufferParameteriv _ptrc_glGetRenderbufferParameteriv +extern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum, GLuint); +#define glGetStringi _ptrc_glGetStringi +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum, GLenum, GLint *); +#define glGetTexParameterIiv _ptrc_glGetTexParameterIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum, GLenum, GLuint *); +#define glGetTexParameterIuiv _ptrc_glGetTexParameterIuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *); +#define glGetTransformFeedbackVarying _ptrc_glGetTransformFeedbackVarying +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint, GLint, GLuint *); +#define glGetUniformuiv _ptrc_glGetUniformuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint, GLenum, GLint *); +#define glGetVertexAttribIiv _ptrc_glGetVertexAttribIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint, GLenum, GLuint *); +#define glGetVertexAttribIuiv _ptrc_glGetVertexAttribIuiv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum, GLuint); +#define glIsEnabledi _ptrc_glIsEnabledi +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint); +#define glIsFramebuffer _ptrc_glIsFramebuffer +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint); +#define glIsRenderbuffer _ptrc_glIsRenderbuffer +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint); +#define glIsVertexArray _ptrc_glIsVertexArray +extern void * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield); +#define glMapBufferRange _ptrc_glMapBufferRange +extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei); +#define glRenderbufferStorage _ptrc_glRenderbufferStorage +extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum, GLsizei, GLenum, GLsizei, GLsizei); +#define glRenderbufferStorageMultisample _ptrc_glRenderbufferStorageMultisample +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum, GLenum, const GLint *); +#define glTexParameterIiv _ptrc_glTexParameterIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum, GLenum, const GLuint *); +#define glTexParameterIuiv _ptrc_glTexParameterIuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint, GLsizei, const GLchar *const*, GLenum); +#define glTransformFeedbackVaryings _ptrc_glTransformFeedbackVaryings +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint, GLuint); +#define glUniform1ui _ptrc_glUniform1ui +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint, GLsizei, const GLuint *); +#define glUniform1uiv _ptrc_glUniform1uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint, GLuint, GLuint); +#define glUniform2ui _ptrc_glUniform2ui +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint, GLsizei, const GLuint *); +#define glUniform2uiv _ptrc_glUniform2uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint, GLuint, GLuint, GLuint); +#define glUniform3ui _ptrc_glUniform3ui +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint, GLsizei, const GLuint *); +#define glUniform3uiv _ptrc_glUniform3uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint, GLuint, GLuint, GLuint, GLuint); +#define glUniform4ui _ptrc_glUniform4ui +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint, GLsizei, const GLuint *); +#define glUniform4uiv _ptrc_glUniform4uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint, GLint); +#define glVertexAttribI1i _ptrc_glVertexAttribI1i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint, const GLint *); +#define glVertexAttribI1iv _ptrc_glVertexAttribI1iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint, GLuint); +#define glVertexAttribI1ui _ptrc_glVertexAttribI1ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint, const GLuint *); +#define glVertexAttribI1uiv _ptrc_glVertexAttribI1uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint, GLint, GLint); +#define glVertexAttribI2i _ptrc_glVertexAttribI2i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint, const GLint *); +#define glVertexAttribI2iv _ptrc_glVertexAttribI2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint, GLuint, GLuint); +#define glVertexAttribI2ui _ptrc_glVertexAttribI2ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint, const GLuint *); +#define glVertexAttribI2uiv _ptrc_glVertexAttribI2uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint, GLint, GLint, GLint); +#define glVertexAttribI3i _ptrc_glVertexAttribI3i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint, const GLint *); +#define glVertexAttribI3iv _ptrc_glVertexAttribI3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint, GLuint, GLuint, GLuint); +#define glVertexAttribI3ui _ptrc_glVertexAttribI3ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint, const GLuint *); +#define glVertexAttribI3uiv _ptrc_glVertexAttribI3uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint, const GLbyte *); +#define glVertexAttribI4bv _ptrc_glVertexAttribI4bv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint, GLint, GLint, GLint, GLint); +#define glVertexAttribI4i _ptrc_glVertexAttribI4i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint, const GLint *); +#define glVertexAttribI4iv _ptrc_glVertexAttribI4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint, const GLshort *); +#define glVertexAttribI4sv _ptrc_glVertexAttribI4sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint, const GLubyte *); +#define glVertexAttribI4ubv _ptrc_glVertexAttribI4ubv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint, GLuint, GLuint, GLuint, GLuint); +#define glVertexAttribI4ui _ptrc_glVertexAttribI4ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint, const GLuint *); +#define glVertexAttribI4uiv _ptrc_glVertexAttribI4uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint, const GLushort *); +#define glVertexAttribI4usv _ptrc_glVertexAttribI4usv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint, GLint, GLenum, GLsizei, const GLvoid *); +#define glVertexAttribIPointer _ptrc_glVertexAttribIPointer + +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr); +#define glCopyBufferSubData _ptrc_glCopyBufferSubData +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum, GLint, GLsizei, GLsizei); +#define glDrawArraysInstanced _ptrc_glDrawArraysInstanced +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei); +#define glDrawElementsInstanced _ptrc_glDrawElementsInstanced +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *); +#define glGetActiveUniformBlockName _ptrc_glGetActiveUniformBlockName +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint, GLuint, GLenum, GLint *); +#define glGetActiveUniformBlockiv _ptrc_glGetActiveUniformBlockiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *); +#define glGetActiveUniformName _ptrc_glGetActiveUniformName +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint, GLsizei, const GLuint *, GLenum, GLint *); +#define glGetActiveUniformsiv _ptrc_glGetActiveUniformsiv +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint, const GLchar *); +#define glGetUniformBlockIndex _ptrc_glGetUniformBlockIndex +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint, GLsizei, const GLchar *const*, GLuint *); +#define glGetUniformIndices _ptrc_glGetUniformIndices +extern void (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint); +#define glPrimitiveRestartIndex _ptrc_glPrimitiveRestartIndex +extern void (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum, GLenum, GLuint); +#define glTexBuffer _ptrc_glTexBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint, GLuint, GLuint); +#define glUniformBlockBinding _ptrc_glUniformBlockBinding + +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync, GLbitfield, GLuint64); +#define glClientWaitSync _ptrc_glClientWaitSync +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync); +#define glDeleteSync _ptrc_glDeleteSync +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLint); +#define glDrawElementsBaseVertex _ptrc_glDrawElementsBaseVertex +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint); +#define glDrawElementsInstancedBaseVertex _ptrc_glDrawElementsInstancedBaseVertex +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint); +#define glDrawRangeElementsBaseVertex _ptrc_glDrawRangeElementsBaseVertex +extern GLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum, GLbitfield); +#define glFenceSync _ptrc_glFenceSync +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum, GLenum, GLuint, GLint); +#define glFramebufferTexture _ptrc_glFramebufferTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum, GLenum, GLint64 *); +#define glGetBufferParameteri64v _ptrc_glGetBufferParameteri64v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum, GLuint, GLint64 *); +#define glGetInteger64i_v _ptrc_glGetInteger64i_v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum, GLint64 *); +#define glGetInteger64v _ptrc_glGetInteger64v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum, GLuint, GLfloat *); +#define glGetMultisamplefv _ptrc_glGetMultisamplefv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync, GLenum, GLsizei, GLsizei *, GLint *); +#define glGetSynciv _ptrc_glGetSynciv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync); +#define glIsSync _ptrc_glIsSync +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *); +#define glMultiDrawElementsBaseVertex _ptrc_glMultiDrawElementsBaseVertex +extern void (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum); +#define glProvokingVertex _ptrc_glProvokingVertex +extern void (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint, GLbitfield); +#define glSampleMaski _ptrc_glSampleMaski +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean); +#define glTexImage2DMultisample _ptrc_glTexImage2DMultisample +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean); +#define glTexImage3DMultisample _ptrc_glTexImage3DMultisample +extern void (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync, GLbitfield, GLuint64); +#define glWaitSync _ptrc_glWaitSync + +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint, GLuint, GLuint, const GLchar *); +#define glBindFragDataLocationIndexed _ptrc_glBindFragDataLocationIndexed +extern void (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint, GLuint); +#define glBindSampler _ptrc_glBindSampler +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei, const GLuint *); +#define glDeleteSamplers _ptrc_glDeleteSamplers +extern void (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei, GLuint *); +#define glGenSamplers _ptrc_glGenSamplers +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint, const GLchar *); +#define glGetFragDataIndex _ptrc_glGetFragDataIndex +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint, GLenum, GLint64 *); +#define glGetQueryObjecti64v _ptrc_glGetQueryObjecti64v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint, GLenum, GLuint64 *); +#define glGetQueryObjectui64v _ptrc_glGetQueryObjectui64v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint, GLenum, GLint *); +#define glGetSamplerParameterIiv _ptrc_glGetSamplerParameterIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint, GLenum, GLuint *); +#define glGetSamplerParameterIuiv _ptrc_glGetSamplerParameterIuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint, GLenum, GLfloat *); +#define glGetSamplerParameterfv _ptrc_glGetSamplerParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint, GLenum, GLint *); +#define glGetSamplerParameteriv _ptrc_glGetSamplerParameteriv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint); +#define glIsSampler _ptrc_glIsSampler +extern void (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint, GLenum); +#define glQueryCounter _ptrc_glQueryCounter +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint, GLenum, const GLint *); +#define glSamplerParameterIiv _ptrc_glSamplerParameterIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint, GLenum, const GLuint *); +#define glSamplerParameterIuiv _ptrc_glSamplerParameterIuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint, GLenum, GLfloat); +#define glSamplerParameterf _ptrc_glSamplerParameterf +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint, GLenum, const GLfloat *); +#define glSamplerParameterfv _ptrc_glSamplerParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint, GLenum, GLint); +#define glSamplerParameteri _ptrc_glSamplerParameteri +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint, GLenum, const GLint *); +#define glSamplerParameteriv _ptrc_glSamplerParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint, GLuint); +#define glVertexAttribDivisor _ptrc_glVertexAttribDivisor +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint, GLenum, GLboolean, GLuint); +#define glVertexAttribP1ui _ptrc_glVertexAttribP1ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint, GLenum, GLboolean, const GLuint *); +#define glVertexAttribP1uiv _ptrc_glVertexAttribP1uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint, GLenum, GLboolean, GLuint); +#define glVertexAttribP2ui _ptrc_glVertexAttribP2ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint, GLenum, GLboolean, const GLuint *); +#define glVertexAttribP2uiv _ptrc_glVertexAttribP2uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint, GLenum, GLboolean, GLuint); +#define glVertexAttribP3ui _ptrc_glVertexAttribP3ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint, GLenum, GLboolean, const GLuint *); +#define glVertexAttribP3uiv _ptrc_glVertexAttribP3uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint, GLenum, GLboolean, GLuint); +#define glVertexAttribP4ui _ptrc_glVertexAttribP4ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint, GLenum, GLboolean, const GLuint *); +#define glVertexAttribP4uiv _ptrc_glVertexAttribP4uiv + +enum ogl_LoadStatus +{ + ogl_LOAD_FAILED = 0, + ogl_LOAD_SUCCEEDED = 1, +}; + +int ogl_LoadFunctions(); + +int ogl_GetMinorVersion(); +int ogl_GetMajorVersion(); +int ogl_IsVersionGEQ(int majorVersion, int minorVersion); + +#ifdef __cplusplus +} +#endif /*__cplusplus*/ + +#endif //POINTER_C_GENERATED_HEADER_OPENGL_H diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h index 2130c9cbb..5cfd7fe5c 100644 --- a/src/gl/system/gl_system.h +++ b/src/gl/system/gl_system.h @@ -67,13 +67,10 @@ #include //GL headers -#include +#include "gl_load.h" #if defined(__APPLE__) #include -#elif defined(__unix__) - //#include -#else // !__APPLE__ && !__unix__ #endif #ifdef _WIN32 diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index a9911460f..81b1d9418 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -1,13 +1,15 @@ -#include "gl/system/gl_system.h" - -#define DWORD WINDOWS_DWORD -#include -#undef DWORD +//#include "gl/system/gl_system.h" +#define WIN32_LEAN_AND_MEAN +#include +#include +#include "wglext.h" +#define USE_WINDOWS_DWORD #include "win32iface.h" #include "win32gliface.h" //#include "gl/gl_intern.h" +#include "x86.h" #include "templates.h" #include "version.h" #include "c_console.h" @@ -22,8 +24,6 @@ #include "gl/renderer/gl_renderer.h" #include "gl/system/gl_framebuffer.h" -#include "gl/shaders/gl_shader.h" -#include "gl/utility/gl_templates.h" void gl_CalculateCPUSpeed(); extern int NewWidth, NewHeight, NewBits, DisplayBits; @@ -726,6 +726,12 @@ bool Win32GLVideo::SetupPixelFormat(int multisample) // //========================================================================== +// since we cannot use the extension loader here, before it gets initialized, +// we have to define the extended GL stuff we need, ourselves here. +// The headers generated by GLLoadGen only work if the loader gets initialized. +typedef const GLubyte * (APIENTRY *PFNGLGETSTRINGIPROC)(GLenum, GLuint); +#define GL_NUM_EXTENSIONS 0x821D + bool Win32GLVideo::checkCoreUsability() { // if we explicitly want to disable 4.x features this must fail. @@ -734,7 +740,7 @@ bool Win32GLVideo::checkCoreUsability() // GL 4.4 implies GL_ARB_buffer_storage if (strcmp((char*)glGetString(GL_VERSION), "4.4") >= 0) return true; - // at this point GLEW has not been initialized so we have to retrieve glGetStringi ourselves. + // at this point the extension loader has not been initialized so we have to retrieve glGetStringi ourselves. PFNGLGETSTRINGIPROC myglGetStringi = (PFNGLGETSTRINGIPROC)wglGetProcAddress("glGetStringi"); if (!myglGetStringi) return false; // this should not happen. diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index f425757f1..4ef48ce18 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -1,7 +1,6 @@ #ifndef __WIN32GLIFACE_H__ #define __WIN32GLIFACE_H__ -#include "gl/system/gl_system.h" #include "hardware.h" #include "win32iface.h" #include "v_video.h" From 78815a960195bc095a0041764e060b034ca280ab Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 21 Aug 2014 11:29:43 +0200 Subject: [PATCH 0202/1509] -we need this, too. --- src/win32/wglext.h | 840 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 840 insertions(+) create mode 100644 src/win32/wglext.h diff --git a/src/win32/wglext.h b/src/win32/wglext.h new file mode 100644 index 000000000..daba41091 --- /dev/null +++ b/src/win32/wglext.h @@ -0,0 +1,840 @@ +#ifndef __wglext_h_ +#define __wglext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision: 27684 $ on $Date: 2014-08-11 01:21:35 -0700 (Mon, 11 Aug 2014) $ +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#define WGL_WGLEXT_VERSION 20140810 + +/* Generated C header for: + * API: wgl + * Versions considered: .* + * Versions emitted: _nomatch_^ + * Default extensions included: wgl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef WGL_ARB_buffer_region +#define WGL_ARB_buffer_region 1 +#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 +#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 +#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 +#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 +typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); +typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); +typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); +typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#ifdef WGL_WGLEXT_PROTOTYPES +HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); +VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); +BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); +BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#endif +#endif /* WGL_ARB_buffer_region */ + +#ifndef WGL_ARB_context_flush_control +#define WGL_ARB_context_flush_control 1 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#endif /* WGL_ARB_context_flush_control */ + +#ifndef WGL_ARB_create_context +#define WGL_ARB_create_context 1 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define ERROR_INVALID_VERSION_ARB 0x2095 +typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); +#ifdef WGL_WGLEXT_PROTOTYPES +HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); +#endif +#endif /* WGL_ARB_create_context */ + +#ifndef WGL_ARB_create_context_profile +#define WGL_ARB_create_context_profile 1 +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define ERROR_INVALID_PROFILE_ARB 0x2096 +#endif /* WGL_ARB_create_context_profile */ + +#ifndef WGL_ARB_create_context_robustness +#define WGL_ARB_create_context_robustness 1 +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif /* WGL_ARB_create_context_robustness */ + +#ifndef WGL_ARB_extensions_string +#define WGL_ARB_extensions_string 1 +typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +#ifdef WGL_WGLEXT_PROTOTYPES +const char *WINAPI wglGetExtensionsStringARB (HDC hdc); +#endif +#endif /* WGL_ARB_extensions_string */ + +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_ARB_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 +#endif /* WGL_ARB_framebuffer_sRGB */ + +#ifndef WGL_ARB_make_current_read +#define WGL_ARB_make_current_read 1 +#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +HDC WINAPI wglGetCurrentReadDCARB (void); +#endif +#endif /* WGL_ARB_make_current_read */ + +#ifndef WGL_ARB_multisample +#define WGL_ARB_multisample 1 +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 +#endif /* WGL_ARB_multisample */ + +#ifndef WGL_ARB_pbuffer +#define WGL_ARB_pbuffer 1 +DECLARE_HANDLE(HPBUFFERARB); +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 +typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); +int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); +BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); +BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#endif +#endif /* WGL_ARB_pbuffer */ + +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif +#endif /* WGL_ARB_pixel_format */ + +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#endif /* WGL_ARB_pixel_format_float */ + +#ifndef WGL_ARB_render_texture +#define WGL_ARB_render_texture 1 +#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 +#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 +#define WGL_TEXTURE_FORMAT_ARB 0x2072 +#define WGL_TEXTURE_TARGET_ARB 0x2073 +#define WGL_MIPMAP_TEXTURE_ARB 0x2074 +#define WGL_TEXTURE_RGB_ARB 0x2075 +#define WGL_TEXTURE_RGBA_ARB 0x2076 +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 +#define WGL_TEXTURE_1D_ARB 0x2079 +#define WGL_TEXTURE_2D_ARB 0x207A +#define WGL_MIPMAP_LEVEL_ARB 0x207B +#define WGL_CUBE_MAP_FACE_ARB 0x207C +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 +#define WGL_FRONT_LEFT_ARB 0x2083 +#define WGL_FRONT_RIGHT_ARB 0x2084 +#define WGL_BACK_LEFT_ARB 0x2085 +#define WGL_BACK_RIGHT_ARB 0x2086 +#define WGL_AUX0_ARB 0x2087 +#define WGL_AUX1_ARB 0x2088 +#define WGL_AUX2_ARB 0x2089 +#define WGL_AUX3_ARB 0x208A +#define WGL_AUX4_ARB 0x208B +#define WGL_AUX5_ARB 0x208C +#define WGL_AUX6_ARB 0x208D +#define WGL_AUX7_ARB 0x208E +#define WGL_AUX8_ARB 0x208F +#define WGL_AUX9_ARB 0x2090 +typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); +#endif +#endif /* WGL_ARB_render_texture */ + +#ifndef WGL_ARB_robustness_application_isolation +#define WGL_ARB_robustness_application_isolation 1 +#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 +#endif /* WGL_ARB_robustness_application_isolation */ + +#ifndef WGL_ARB_robustness_share_group_isolation +#define WGL_ARB_robustness_share_group_isolation 1 +#endif /* WGL_ARB_robustness_share_group_isolation */ + +#ifndef WGL_3DFX_multisample +#define WGL_3DFX_multisample 1 +#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 +#define WGL_SAMPLES_3DFX 0x2061 +#endif /* WGL_3DFX_multisample */ + +#ifndef WGL_3DL_stereo_control +#define WGL_3DL_stereo_control 1 +#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 +#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 +#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 +#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 +typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); +#endif +#endif /* WGL_3DL_stereo_control */ + +#ifndef WGL_AMD_gpu_association +#define WGL_AMD_gpu_association 1 +#define WGL_GPU_VENDOR_AMD 0x1F00 +#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 +#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define WGL_GPU_RAM_AMD 0x21A3 +#define WGL_GPU_CLOCK_AMD 0x21A4 +#define WGL_GPU_NUM_PIPES_AMD 0x21A5 +#define WGL_GPU_NUM_SIMD_AMD 0x21A6 +#define WGL_GPU_NUM_RB_AMD 0x21A7 +#define WGL_GPU_NUM_SPI_AMD 0x21A8 +typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); +typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data); +typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); +typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); +typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); +typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef WGL_WGLEXT_PROTOTYPES +UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); +INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data); +UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); +HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); +HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); +BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); +BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); +HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); +VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* WGL_AMD_gpu_association */ + +#ifndef WGL_ATI_pixel_format_float +#define WGL_ATI_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 +#endif /* WGL_ATI_pixel_format_float */ + +#ifndef WGL_EXT_create_context_es2_profile +#define WGL_EXT_create_context_es2_profile 1 +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es2_profile */ + +#ifndef WGL_EXT_create_context_es_profile +#define WGL_EXT_create_context_es_profile 1 +#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es_profile */ + +#ifndef WGL_EXT_depth_float +#define WGL_EXT_depth_float 1 +#define WGL_DEPTH_FLOAT_EXT 0x2040 +#endif /* WGL_EXT_depth_float */ + +#ifndef WGL_EXT_display_color_table +#define WGL_EXT_display_color_table 1 +typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); +typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); +#ifdef WGL_WGLEXT_PROTOTYPES +GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); +GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); +GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); +VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); +#endif +#endif /* WGL_EXT_display_color_table */ + +#ifndef WGL_EXT_extensions_string +#define WGL_EXT_extensions_string 1 +typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +const char *WINAPI wglGetExtensionsStringEXT (void); +#endif +#endif /* WGL_EXT_extensions_string */ + +#ifndef WGL_EXT_framebuffer_sRGB +#define WGL_EXT_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 +#endif /* WGL_EXT_framebuffer_sRGB */ + +#ifndef WGL_EXT_make_current_read +#define WGL_EXT_make_current_read 1 +#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +HDC WINAPI wglGetCurrentReadDCEXT (void); +#endif +#endif /* WGL_EXT_make_current_read */ + +#ifndef WGL_EXT_multisample +#define WGL_EXT_multisample 1 +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#define WGL_SAMPLES_EXT 0x2042 +#endif /* WGL_EXT_multisample */ + +#ifndef WGL_EXT_pbuffer +#define WGL_EXT_pbuffer 1 +DECLARE_HANDLE(HPBUFFEREXT); +#define WGL_DRAW_TO_PBUFFER_EXT 0x202D +#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E +#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 +#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 +#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 +#define WGL_PBUFFER_LARGEST_EXT 0x2033 +#define WGL_PBUFFER_WIDTH_EXT 0x2034 +#define WGL_PBUFFER_HEIGHT_EXT 0x2035 +typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); +int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); +BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); +BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#endif +#endif /* WGL_EXT_pbuffer */ + +#ifndef WGL_EXT_pixel_format +#define WGL_EXT_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 +#define WGL_DRAW_TO_WINDOW_EXT 0x2001 +#define WGL_DRAW_TO_BITMAP_EXT 0x2002 +#define WGL_ACCELERATION_EXT 0x2003 +#define WGL_NEED_PALETTE_EXT 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 +#define WGL_SWAP_METHOD_EXT 0x2007 +#define WGL_NUMBER_OVERLAYS_EXT 0x2008 +#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 +#define WGL_TRANSPARENT_EXT 0x200A +#define WGL_TRANSPARENT_VALUE_EXT 0x200B +#define WGL_SHARE_DEPTH_EXT 0x200C +#define WGL_SHARE_STENCIL_EXT 0x200D +#define WGL_SHARE_ACCUM_EXT 0x200E +#define WGL_SUPPORT_GDI_EXT 0x200F +#define WGL_SUPPORT_OPENGL_EXT 0x2010 +#define WGL_DOUBLE_BUFFER_EXT 0x2011 +#define WGL_STEREO_EXT 0x2012 +#define WGL_PIXEL_TYPE_EXT 0x2013 +#define WGL_COLOR_BITS_EXT 0x2014 +#define WGL_RED_BITS_EXT 0x2015 +#define WGL_RED_SHIFT_EXT 0x2016 +#define WGL_GREEN_BITS_EXT 0x2017 +#define WGL_GREEN_SHIFT_EXT 0x2018 +#define WGL_BLUE_BITS_EXT 0x2019 +#define WGL_BLUE_SHIFT_EXT 0x201A +#define WGL_ALPHA_BITS_EXT 0x201B +#define WGL_ALPHA_SHIFT_EXT 0x201C +#define WGL_ACCUM_BITS_EXT 0x201D +#define WGL_ACCUM_RED_BITS_EXT 0x201E +#define WGL_ACCUM_GREEN_BITS_EXT 0x201F +#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 +#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 +#define WGL_DEPTH_BITS_EXT 0x2022 +#define WGL_STENCIL_BITS_EXT 0x2023 +#define WGL_AUX_BUFFERS_EXT 0x2024 +#define WGL_NO_ACCELERATION_EXT 0x2025 +#define WGL_GENERIC_ACCELERATION_EXT 0x2026 +#define WGL_FULL_ACCELERATION_EXT 0x2027 +#define WGL_SWAP_EXCHANGE_EXT 0x2028 +#define WGL_SWAP_COPY_EXT 0x2029 +#define WGL_SWAP_UNDEFINED_EXT 0x202A +#define WGL_TYPE_RGBA_EXT 0x202B +#define WGL_TYPE_COLORINDEX_EXT 0x202C +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif +#endif /* WGL_EXT_pixel_format */ + +#ifndef WGL_EXT_pixel_format_packed_float +#define WGL_EXT_pixel_format_packed_float 1 +#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 +#endif /* WGL_EXT_pixel_format_packed_float */ + +#ifndef WGL_EXT_swap_control +#define WGL_EXT_swap_control 1 +typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); +typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglSwapIntervalEXT (int interval); +int WINAPI wglGetSwapIntervalEXT (void); +#endif +#endif /* WGL_EXT_swap_control */ + +#ifndef WGL_EXT_swap_control_tear +#define WGL_EXT_swap_control_tear 1 +#endif /* WGL_EXT_swap_control_tear */ + +#ifndef WGL_I3D_digital_video_control +#define WGL_I3D_digital_video_control 1 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 +#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 +#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 +typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); +BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); +#endif +#endif /* WGL_I3D_digital_video_control */ + +#ifndef WGL_I3D_gamma +#define WGL_I3D_gamma 1 +#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E +#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); +BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); +BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#endif +#endif /* WGL_I3D_gamma */ + +#ifndef WGL_I3D_genlock +#define WGL_I3D_genlock 1 +#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 +#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 +#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 +#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 +#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 +#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 +#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A +#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B +#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C +typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); +typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); +typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnableGenlockI3D (HDC hDC); +BOOL WINAPI wglDisableGenlockI3D (HDC hDC); +BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); +BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); +BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); +BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); +BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); +BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); +BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); +BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); +BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); +BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#endif +#endif /* WGL_I3D_genlock */ + +#ifndef WGL_I3D_image_buffer +#define WGL_I3D_image_buffer 1 +#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 +#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 +typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); +typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); +typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); +#ifdef WGL_WGLEXT_PROTOTYPES +LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); +BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); +BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); +#endif +#endif /* WGL_I3D_image_buffer */ + +#ifndef WGL_I3D_swap_frame_lock +#define WGL_I3D_swap_frame_lock 1 +typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnableFrameLockI3D (void); +BOOL WINAPI wglDisableFrameLockI3D (void); +BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); +BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); +#endif +#endif /* WGL_I3D_swap_frame_lock */ + +#ifndef WGL_I3D_swap_frame_usage +#define WGL_I3D_swap_frame_usage 1 +typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); +typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); +BOOL WINAPI wglBeginFrameTrackingI3D (void); +BOOL WINAPI wglEndFrameTrackingI3D (void); +BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#endif +#endif /* WGL_I3D_swap_frame_usage */ + +#ifndef WGL_NV_DX_interop +#define WGL_NV_DX_interop 1 +#define WGL_ACCESS_READ_ONLY_NV 0x00000000 +#define WGL_ACCESS_READ_WRITE_NV 0x00000001 +#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 +typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle); +typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice); +typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); +typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); +typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle); +HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice); +BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice); +HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject); +BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access); +BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +#endif +#endif /* WGL_NV_DX_interop */ + +#ifndef WGL_NV_DX_interop2 +#define WGL_NV_DX_interop2 1 +#endif /* WGL_NV_DX_interop2 */ + +#ifndef WGL_NV_copy_image +#define WGL_NV_copy_image 1 +typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* WGL_NV_copy_image */ + +#ifndef WGL_NV_delay_before_swap +#define WGL_NV_delay_before_swap 1 +typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglDelayBeforeSwapNV (HDC hDC, GLfloat seconds); +#endif +#endif /* WGL_NV_delay_before_swap */ + +#ifndef WGL_NV_float_buffer +#define WGL_NV_float_buffer 1 +#define WGL_FLOAT_COMPONENTS_NV 0x20B0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 +#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 +#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 +#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 +#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 +#endif /* WGL_NV_float_buffer */ + +#ifndef WGL_NV_gpu_affinity +#define WGL_NV_gpu_affinity 1 +DECLARE_HANDLE(HGPUNV); +struct _GPU_DEVICE { + DWORD cb; + CHAR DeviceName[32]; + CHAR DeviceString[128]; + DWORD Flags; + RECT rcVirtualScreen; +}; +typedef struct _GPU_DEVICE *PGPU_DEVICE; +#define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 +#define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 +typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); +typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); +typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); +BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); +BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +BOOL WINAPI wglDeleteDCNV (HDC hdc); +#endif +#endif /* WGL_NV_gpu_affinity */ + +#ifndef WGL_NV_multisample_coverage +#define WGL_NV_multisample_coverage 1 +#define WGL_COVERAGE_SAMPLES_NV 0x2042 +#define WGL_COLOR_SAMPLES_NV 0x20B9 +#endif /* WGL_NV_multisample_coverage */ + +#ifndef WGL_NV_present_video +#define WGL_NV_present_video 1 +DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); +#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 +typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); +#endif +#endif /* WGL_NV_present_video */ + +#ifndef WGL_NV_render_depth_texture +#define WGL_NV_render_depth_texture 1 +#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 +#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 +#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 +#define WGL_DEPTH_COMPONENT_NV 0x20A7 +#endif /* WGL_NV_render_depth_texture */ + +#ifndef WGL_NV_render_texture_rectangle +#define WGL_NV_render_texture_rectangle 1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 +#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 +#endif /* WGL_NV_render_texture_rectangle */ + +#ifndef WGL_NV_swap_group +#define WGL_NV_swap_group 1 +typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); +typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); +typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); +typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); +typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); +BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); +BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); +BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); +BOOL WINAPI wglResetFrameCountNV (HDC hDC); +#endif +#endif /* WGL_NV_swap_group */ + +#ifndef WGL_NV_vertex_array_range +#define WGL_NV_vertex_array_range 1 +typedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); +#ifdef WGL_WGLEXT_PROTOTYPES +void *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +void WINAPI wglFreeMemoryNV (void *pointer); +#endif +#endif /* WGL_NV_vertex_array_range */ + +#ifndef WGL_NV_video_capture +#define WGL_NV_video_capture 1 +DECLARE_HANDLE(HVIDEOINPUTDEVICENV); +#define WGL_UNIQUE_ID_NV 0x20CE +#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF +typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#endif +#endif /* WGL_NV_video_capture */ + +#ifndef WGL_NV_video_output +#define WGL_NV_video_output 1 +DECLARE_HANDLE(HPVIDEODEV); +#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 +#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 +#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 +#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 +#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 +#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 +#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define WGL_VIDEO_OUT_FRAME 0x20C8 +#define WGL_VIDEO_OUT_FIELD_1 0x20C9 +#define WGL_VIDEO_OUT_FIELD_2 0x20CA +#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB +#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC +typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); +typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); +BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); +BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#endif +#endif /* WGL_NV_video_output */ + +#ifndef WGL_OML_sync_control +#define WGL_OML_sync_control 1 +typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); +typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); +INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#endif +#endif /* WGL_OML_sync_control */ + +#ifdef __cplusplus +} +#endif + +#endif From 274a4216ea2b65d1d086884933adfb08bf8d1a0d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 21 Aug 2014 11:47:53 +0200 Subject: [PATCH 0203/1509] - disabling inlining in the GL loader produces an executable that's 8kb smaller. --- src/gl/system/gl_load.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gl/system/gl_load.c b/src/gl/system/gl_load.c index 2b55cb3a9..282395016 100644 --- a/src/gl/system/gl_load.c +++ b/src/gl/system/gl_load.c @@ -53,6 +53,8 @@ static void* SunGetProcAddress (const GLubyte* name) #if defined(_WIN32) #ifdef _MSC_VER +// disable inlining here because it creates an incredible amount of bloat here. +#pragma inline_depth(0) #pragma warning(disable: 4055) #pragma warning(disable: 4054) #endif From 1050013017a5c37814269f6823cafb0df5b0d49d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 22 Aug 2014 23:50:38 +0200 Subject: [PATCH 0204/1509] major cleanup of the texture manager: - use sampler objects to avoid creating up to 4 different system textures for one game texture just because of different clamping settings. - avoids flushing all textures for change of texture filter mode. - separate sprite and regular dimensions on the material level to have better control over which one gets used. It's now an explicit parameter of ValidateTexture. The main reason for this change is better handling of wall sprites which may not be subjected to such handling. - create mipmaps based on use case, not texture type. - allows removal of FCloneTexture hack for proper sharing of the same sprite for decals and other purposes. - better precaching of skyboxes. --- src/CMakeLists.txt | 1 + src/gl/models/gl_models_md2.cpp | 4 +- src/gl/models/gl_models_md3.cpp | 4 +- src/gl/models/gl_voxels.cpp | 4 +- src/gl/renderer/gl_renderer.cpp | 26 +- src/gl/renderer/gl_renderer.h | 2 + src/gl/scene/gl_decal.cpp | 22 +- src/gl/scene/gl_drawinfo.cpp | 4 +- src/gl/scene/gl_flats.cpp | 18 +- src/gl/scene/gl_portal.cpp | 4 +- src/gl/scene/gl_scene.cpp | 16 +- src/gl/scene/gl_sky.cpp | 8 +- src/gl/scene/gl_skydome.cpp | 30 +- src/gl/scene/gl_sprite.cpp | 20 +- src/gl/scene/gl_walls.cpp | 28 +- src/gl/scene/gl_walls_draw.cpp | 8 +- src/gl/scene/gl_weapon.cpp | 18 +- src/gl/system/gl_wipe.cpp | 35 +-- src/gl/textures/gl_hwtexture.cpp | 148 ++++------ src/gl/textures/gl_hwtexture.h | 27 +- src/gl/textures/gl_material.cpp | 414 +++++++-------------------- src/gl/textures/gl_material.h | 131 +++++---- src/gl/textures/gl_samplers.cpp | 112 ++++++++ src/gl/textures/gl_samplers.h | 28 ++ src/gl/textures/gl_skyboxtexture.cpp | 10 +- src/gl/textures/gl_skyboxtexture.h | 2 +- src/gl/textures/gl_texture.cpp | 134 +++++---- src/gl/textures/gl_texture.h | 17 -- src/textures/texturemanager.cpp | 2 + src/textures/textures.h | 11 +- src/v_video.cpp | 8 +- 31 files changed, 596 insertions(+), 700 deletions(-) create mode 100644 src/gl/textures/gl_samplers.cpp create mode 100644 src/gl/textures/gl_samplers.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dcaddff32..38cc45189 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1042,6 +1042,7 @@ add_executable( zdoom WIN32 gl/textures/gl_material.cpp gl/textures/gl_hirestex.cpp gl/textures/gl_bitmap.cpp + gl/textures/gl_samplers.cpp gl/textures/gl_translate.cpp gl/textures/gl_hqresize.cpp gl/textures/gl_skyboxtexture.cpp diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index df6d8f88e..76835c737 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -301,9 +301,9 @@ void FDMDModel::RenderFrame(FTexture * skin, int frameno, int frameno2, double i if (!skin) return; } - FMaterial * tex = FMaterial::ValidateTexture(skin); + FMaterial * tex = FMaterial::ValidateTexture(skin, false); - tex->Bind(0, translation); + tex->Bind(CLAMP_NONE, translation, -1, false); gl_RenderState.Apply(); GLRenderer->mModelVBO->SetupFrame(frames[frameno].vindex, frames[frameno2].vindex, inter); diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index cb9bb6c25..d3f71af5c 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -265,9 +265,9 @@ void FMD3Model::RenderFrame(FTexture * skin, int frameno, int frameno2, double i if (!surfaceSkin) return; } - FMaterial * tex = FMaterial::ValidateTexture(surfaceSkin); + FMaterial * tex = FMaterial::ValidateTexture(surfaceSkin, false); - tex->Bind(0, translation); + tex->Bind(CLAMP_NONE, translation, -1, false); gl_RenderState.Apply(); GLRenderer->mModelVBO->SetupFrame(surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices, inter); diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index ffd2a65de..0ce907aa5 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -416,8 +416,8 @@ int FVoxelModel::FindFrame(const char * name) void FVoxelModel::RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation) { - FMaterial * tex = FMaterial::ValidateTexture(skin); - tex->Bind(0, translation); + FMaterial * tex = FMaterial::ValidateTexture(skin, false); + tex->Bind(CLAMP_NOFILTER, translation, -1, false); gl_RenderState.Apply(); GLRenderer->mModelVBO->SetupFrame(vindex, vindex, 0.f); diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index effbec942..ec0680bbc 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -64,6 +64,7 @@ #include "gl/textures/gl_texture.h" #include "gl/textures/gl_translate.h" #include "gl/textures/gl_material.h" +#include "gl/textures/gl_samplers.h" #include "gl/utility/gl_clock.h" #include "gl/utility/gl_templates.h" #include "gl/models/gl_models.h" @@ -115,6 +116,7 @@ void FGLRenderer::Initialize() mFBID = 0; SetupLevel(); mShaderManager = new FShaderManager; + mSamplerManager = new FSamplerManager; //mThreadManager = new FGLThreadManager; } @@ -124,6 +126,7 @@ FGLRenderer::~FGLRenderer() FMaterial::FlushAll(); //if (mThreadManager != NULL) delete mThreadManager; if (mShaderManager != NULL) delete mShaderManager; + if (mSamplerManager != NULL) delete mSamplerManager; if (mVBO != NULL) delete mVBO; if (mModelVBO) delete mModelVBO; if (mSkyVBO != NULL) delete mSkyVBO; @@ -243,7 +246,7 @@ void FGLRenderer::EndOffscreen() unsigned char *FGLRenderer::GetTextureBuffer(FTexture *tex, int &w, int &h) { - FMaterial * gltex = FMaterial::ValidateTexture(tex); + FMaterial * gltex = FMaterial::ValidateTexture(tex, false); if (gltex) { return gltex->CreateTexBuffer(0, w, h); @@ -310,7 +313,7 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) float u1, v1, u2, v2; int light = 255; - FMaterial * gltex = FMaterial::ValidateTexture(img); + FMaterial * gltex = FMaterial::ValidateTexture(img, false); if (parms.colorOverlay && (parms.colorOverlay & 0xffffff) == 0) { @@ -331,7 +334,7 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) } } gl_SetRenderStyle(parms.style, !parms.masked, false); - gltex->BindPatch(translation, 0, !!(parms.style.Flags & STYLEF_RedIsAlpha)); + gltex->Bind(CLAMP_XY_NOMIP, translation, 0, !!(parms.style.Flags & STYLEF_RedIsAlpha)); u1 = gltex->GetUL(); v1 = gltex->GetVT(); @@ -341,10 +344,11 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) } else { - gltex->Bind(0, 0); - u2=1.f; - v2=-1.f; - u1 = v1 = 0.f; + gltex->Bind(CLAMP_XY_NOMIP, 0, -1, false); + u1 = 0.f; + v1 = 1.f; + u2 = 1.f; + v2 = 0.f; gl_RenderState.SetTextureMode(TM_OPAQUE); } @@ -490,11 +494,11 @@ void FGLRenderer::FlatFill (int left, int top, int right, int bottom, FTexture * { float fU1,fU2,fV1,fV2; - FMaterial *gltexture=FMaterial::ValidateTexture(src); + FMaterial *gltexture=FMaterial::ValidateTexture(src, false); if (!gltexture) return; - gltexture->Bind(0, 0); + gltexture->Bind(CLAMP_NONE, 0, -1, false); // scaling is not used here. if (!local_origin) @@ -575,7 +579,7 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint return; } - FMaterial *gltexture = FMaterial::ValidateTexture(texture); + FMaterial *gltexture = FMaterial::ValidateTexture(texture, false); if (gltexture == NULL) { @@ -587,7 +591,7 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint gl_SetColor(lightlevel, 0, cm, 1.f); - gltexture->Bind(); + gltexture->Bind(CLAMP_NONE, 0, -1, false); int i; float rot = float(rotation * M_PI / float(1u << 31)); diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 15c8a2e16..aee400def 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -18,6 +18,7 @@ class FShaderManager; class GLPortal; class FGLThreadManager; class FLightBuffer; +class FSamplerManager; enum SectorRenderFlags { @@ -56,6 +57,7 @@ public: float mCurrentFoV; AActor *mViewActor; FShaderManager *mShaderManager; + FSamplerManager *mSamplerManager; FGLThreadManager *mThreadManager; int gl_spriteindex; unsigned int mFBID; diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 98101c987..db6d1ad7c 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -103,17 +103,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) FMaterial *tex; - if (texture->UseType == FTexture::TEX_MiscPatch) - { - // We need to create a clone of this texture where we can force the - // texture filtering offset in. - if (texture->gl_info.DecalTexture == NULL) - { - texture->gl_info.DecalTexture = new FCloneTexture(texture, FTexture::TEX_Decal); - } - tex = FMaterial::ValidateTexture(texture->gl_info.DecalTexture); - } - else tex = FMaterial::ValidateTexture(texture); + tex = FMaterial::ValidateTexture(texture, true); // the sectors are only used for their texture origin coordinates @@ -192,10 +182,10 @@ void GLWall::DrawDecal(DBaseDecal *decal) a = FIXED2FLOAT(decal->Alpha); // now clip the decal to the actual polygon - float decalwidth = tex->TextureWidth(GLUSE_PATCH) * FIXED2FLOAT(decal->ScaleX); - float decalheight= tex->TextureHeight(GLUSE_PATCH) * FIXED2FLOAT(decal->ScaleY); - float decallefto = tex->GetLeftOffset(GLUSE_PATCH) * FIXED2FLOAT(decal->ScaleX); - float decaltopo = tex->GetTopOffset(GLUSE_PATCH) * FIXED2FLOAT(decal->ScaleY); + float decalwidth = tex->TextureWidth() * FIXED2FLOAT(decal->ScaleX); + float decalheight= tex->TextureHeight() * FIXED2FLOAT(decal->ScaleY); + float decallefto = tex->GetLeftOffset() * FIXED2FLOAT(decal->ScaleX); + float decaltopo = tex->GetTopOffset() * FIXED2FLOAT(decal->ScaleY); float leftedge = glseg.fracleft * side->TexelLength; @@ -329,7 +319,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) gl_SetRenderStyle(decal->RenderStyle, false, false); - tex->BindPatch(decal->Translation, 0, !!(decal->RenderStyle.Flags & STYLEF_RedIsAlpha)); + tex->Bind(CLAMP_XY, decal->Translation, 0, !!(decal->RenderStyle.Flags & STYLEF_RedIsAlpha)); // If srcalpha is one it looks better with a higher alpha threshold diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 8461a90eb..2cda1e396 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -1055,7 +1055,7 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo plane.GetFromSector(sec, ceiling); - gltexture=FMaterial::ValidateTexture(plane.texture, true); + gltexture=FMaterial::ValidateTexture(plane.texture, false, true); if (!gltexture) return; if (gl_fixedcolormap) @@ -1077,7 +1077,7 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo int rel = getExtraLight(); gl_SetColor(lightlevel, rel, Colormap, 1.0f); gl_SetFog(lightlevel, rel, &Colormap, false); - gltexture->Bind(); + gltexture->Bind(CLAMP_NONE, 0, -1, false); float fviewx = FIXED2FLOAT(viewx); float fviewy = FIXED2FLOAT(viewy); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index f997e69da..0df465caf 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -77,11 +77,11 @@ void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * glte if (secplane->xoffs != 0 || secplane->yoffs != 0 || secplane->xscale != FRACUNIT || secplane->yscale != FRACUNIT || secplane->angle != 0 || - gltexture->TextureWidth(GLUSE_TEXTURE) != 64 || - gltexture->TextureHeight(GLUSE_TEXTURE) != 64) + gltexture->TextureWidth() != 64 || + gltexture->TextureHeight() != 64) { - float uoffs=FIXED2FLOAT(secplane->xoffs)/gltexture->TextureWidth(GLUSE_TEXTURE); - float voffs=FIXED2FLOAT(secplane->yoffs)/gltexture->TextureHeight(GLUSE_TEXTURE); + float uoffs=FIXED2FLOAT(secplane->xoffs)/gltexture->TextureWidth(); + float voffs=FIXED2FLOAT(secplane->yoffs)/gltexture->TextureHeight(); float xscale1=FIXED2FLOAT(secplane->xscale); float yscale1=FIXED2FLOAT(secplane->yscale); @@ -91,8 +91,8 @@ void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * glte } float angle=-ANGLE_TO_FLOAT(secplane->angle); - float xscale2=64.f/gltexture->TextureWidth(GLUSE_TEXTURE); - float yscale2=64.f/gltexture->TextureHeight(GLUSE_TEXTURE); + float xscale2=64.f/gltexture->TextureWidth(); + float yscale2=64.f/gltexture->TextureHeight(); gl_RenderState.mTextureMatrix.loadIdentity(); gl_RenderState.mTextureMatrix.scale(xscale1 ,yscale1,1.0f); @@ -341,7 +341,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG case GLPASS_ALL: gl_SetColor(lightlevel, rel, Colormap,1.0f); gl_SetFog(lightlevel, rel, &Colormap, false); - gltexture->Bind(); + gltexture->Bind(CLAMP_NONE, 0, -1, false); gl_SetPlaneTextureRotation(&plane, gltexture); DrawSubsectors(pass, (pass == GLPASS_ALL || dynlightindex > -1), false); gl_RenderState.EnableTextureMatrix(false); @@ -367,7 +367,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG } else { - gltexture->Bind(); + gltexture->Bind(CLAMP_NONE, 0, -1, false); gl_SetPlaneTextureRotation(&plane, gltexture); DrawSubsectors(pass, true, true); gl_RenderState.EnableTextureMatrix(false); @@ -424,7 +424,7 @@ void GLFlat::Process(sector_t * model, int whichplane, bool fog) { if (plane.texture==skyflatnum) return; - gltexture=FMaterial::ValidateTexture(plane.texture, true); + gltexture=FMaterial::ValidateTexture(plane.texture, false, true); if (!gltexture) return; if (gltexture->tex->isFullbright()) { diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 7c7efc91d..5e82dbd7b 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -985,7 +985,7 @@ void GLHorizonPortal::DrawContents() float z; player_t * player=&players[consoleplayer]; - gltexture=FMaterial::ValidateTexture(sp->texture, true); + gltexture=FMaterial::ValidateTexture(sp->texture, false, true); if (!gltexture) { ClearScreen(); @@ -1011,7 +1011,7 @@ void GLHorizonPortal::DrawContents() } - gltexture->Bind(); + gltexture->Bind(CLAMP_NONE, 0, -1, false); gl_SetPlaneTextureRotation(sp, gltexture); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index afd9259f2..fb4de22ea 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -959,7 +959,7 @@ void FGLInterface::PrecacheTexture(FTexture *tex, int cache) { if (cache) { - tex->PrecacheGL(); + tex->PrecacheGL(cache); } else { @@ -1067,10 +1067,10 @@ extern TexFilter_s TexFilter[]; void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, int FOV) { - FMaterial * gltex = FMaterial::ValidateTexture(tex); + FMaterial * gltex = FMaterial::ValidateTexture(tex, false); - int width = gltex->TextureWidth(GLUSE_TEXTURE); - int height = gltex->TextureHeight(GLUSE_TEXTURE); + int width = gltex->TextureWidth(); + int height = gltex->TextureHeight(); gl_fixedcolormap=CM_DEFAULT; gl_RenderState.SetFixedColormap(CM_DEFAULT); @@ -1102,15 +1102,15 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in GL_IRECT bounds; bounds.left=bounds.top=0; - bounds.width=FHardwareTexture::GetTexDimension(gltex->GetWidth(GLUSE_TEXTURE)); - bounds.height=FHardwareTexture::GetTexDimension(gltex->GetHeight(GLUSE_TEXTURE)); + bounds.width=FHardwareTexture::GetTexDimension(gltex->GetWidth()); + bounds.height=FHardwareTexture::GetTexDimension(gltex->GetHeight()); GLRenderer->RenderViewpoint(Viewpoint, &bounds, FOV, (float)width/height, (float)width/height, false, false); if (!usefb) { glFlush(); - gltex->Bind(0, 0); + gltex->Bind(0, 0, -1, false); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, bounds.width, bounds.height); } else @@ -1118,8 +1118,6 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in GLRenderer->EndOffscreen(); } - gltex->Bind(0, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); tex->SetUpdated(); } diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index b236f45d8..d208e6875 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -111,7 +111,7 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) } FTextureID texno = s->GetTexture(pos); - skyinfo.texture[0] = FMaterial::ValidateTexture(texno, true); + skyinfo.texture[0] = FMaterial::ValidateTexture(texno, false, true); if (!skyinfo.texture[0] || skyinfo.texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky; skyinfo.skytexno1 = texno; skyinfo.x_offset[0] = ANGLE_TO_FLOAT(s->GetTextureXOffset(pos)); @@ -123,7 +123,7 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) normalsky: if (level.flags&LEVEL_DOUBLESKY) { - skyinfo.texture[1]=FMaterial::ValidateTexture(sky1texture, true); + skyinfo.texture[1]=FMaterial::ValidateTexture(sky1texture, false, true); skyinfo.x_offset[1] = GLRenderer->mSky1Pos; skyinfo.doublesky = true; } @@ -131,14 +131,14 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) if ((level.flags&LEVEL_SWAPSKIES || (sky1==PL_SKYFLAT) || (level.flags&LEVEL_DOUBLESKY)) && sky2texture!=sky1texture) // If both skies are equal use the scroll offset of the first! { - skyinfo.texture[0]=FMaterial::ValidateTexture(sky2texture, true); + skyinfo.texture[0]=FMaterial::ValidateTexture(sky2texture, false, true); skyinfo.skytexno1=sky2texture; skyinfo.sky2 = true; skyinfo.x_offset[0] = GLRenderer->mSky2Pos; } else { - skyinfo.texture[0]=FMaterial::ValidateTexture(sky1texture, true); + skyinfo.texture[0]=FMaterial::ValidateTexture(sky1texture, false, true); skyinfo.skytexno1=sky1texture; skyinfo.x_offset[0] = GLRenderer->mSky1Pos; } diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 583c6fc62..b12ada3fc 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -268,9 +268,9 @@ void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, in if (tex) { - tex->Bind(0, 0); - texw = tex->TextureWidth(GLUSE_TEXTURE); - texh = tex->TextureHeight(GLUSE_TEXTURE); + tex->Bind(CLAMP_NONE, 0, -1, false); + texw = tex->TextureWidth(); + texh = tex->TextureHeight(); gl_RenderState.EnableModelMatrix(true); gl_RenderState.mModelMatrix.loadIdentity(); @@ -332,8 +332,8 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool faces=4; // north - tex = FMaterial::ValidateTexture(sb->faces[0]); - tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); + tex = FMaterial::ValidateTexture(sb->faces[0], false); + tex->Bind(CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); ptr = GLRenderer->mVBO->GetBuffer(); @@ -348,8 +348,8 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); // east - tex = FMaterial::ValidateTexture(sb->faces[1]); - tex->Bind(GLT_CLAMPX | GLT_CLAMPY, 0); + tex = FMaterial::ValidateTexture(sb->faces[1], false); + tex->Bind(CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); ptr = GLRenderer->mVBO->GetBuffer(); @@ -364,8 +364,8 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); // south - tex = FMaterial::ValidateTexture(sb->faces[2]); - tex->Bind(GLT_CLAMPX | GLT_CLAMPY, 0); + tex = FMaterial::ValidateTexture(sb->faces[2], false); + tex->Bind(CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); ptr = GLRenderer->mVBO->GetBuffer(); @@ -380,8 +380,8 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); // west - tex = FMaterial::ValidateTexture(sb->faces[3]); - tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); + tex = FMaterial::ValidateTexture(sb->faces[3], false); + tex->Bind(CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); ptr = GLRenderer->mVBO->GetBuffer(); @@ -424,8 +424,8 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool } // top - tex = FMaterial::ValidateTexture(sb->faces[faces]); - tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); + tex = FMaterial::ValidateTexture(sb->faces[faces], false); + tex->Bind(CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); ptr = GLRenderer->mVBO->GetBuffer(); @@ -440,8 +440,8 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); // bottom - tex = FMaterial::ValidateTexture(sb->faces[faces+1]); - tex->Bind(GLT_CLAMPX|GLT_CLAMPY, 0); + tex = FMaterial::ValidateTexture(sb->faces[faces+1], false); + tex->Bind(CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); ptr = GLRenderer->mVBO->GetBuffer(); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 4aa0f90bc..502264e20 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -214,7 +214,7 @@ void GLSprite::Draw(int pass) gl_RenderState.SetFog(0, 0); } - if (gltexture) gltexture->BindPatch(translation, OverrideShader, !!(RenderStyle.Flags & STYLEF_RedIsAlpha)); + if (gltexture) gltexture->Bind(CLAMP_XY, translation, OverrideShader, !!(RenderStyle.Flags & STYLEF_RedIsAlpha)); else if (!modelframe) gl_RenderState.EnableTexture(false); if (!modelframe) @@ -455,8 +455,9 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_ if (top == -1000000.0f) top = FIXED2FLOAT(thing->Sector->ceilingplane.ZatPoint(thingx, thingy)); - float diffb = z2 - btm; - float difft = z1 - top; + // +/-1 to account for the one pixel empty frame around the sprite. + float diffb = (z2+1) - btm; + float difft = (z1-1) - top; if (diffb >= 0 /*|| !gl_sprite_clip_to_floor*/) diffb = 0; // Adjust sprites clipping into ceiling and adjust clipping adjustment for tall graphics if (smarterclip) @@ -598,12 +599,13 @@ void GLSprite::Process(AActor* thing,sector_t * sector) bool mirror; FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, ang - thing->angle, &mirror); if (!patch.isValid()) return; - gltexture = FMaterial::ValidateTexture(patch, false); + int type = thing->renderflags & RF_SPRITETYPEMASK; + gltexture = FMaterial::ValidateTexture(patch, (type == RF_FACESPRITE), false); if (!gltexture) return; vt = gltexture->GetSpriteVT(); vb = gltexture->GetSpriteVB(); - gltexture->GetRect(&r, GLUSE_SPRITE); + gltexture->GetSpriteRect(&r); if (mirror) { r.left = -r.width - r.left; // mirror the sprite's x-offset @@ -624,7 +626,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) z1 = z - r.top; z2 = z1 - r.height; - float spriteheight = FIXED2FLOAT(spritescaleY) * gltexture->GetScaledHeightFloat(GLUSE_SPRITE); + float spriteheight = FIXED2FLOAT(spritescaleY) * r.height; // Tests show that this doesn't look good for many decorations and corpses if (spriteheight > 0 && gl_spriteclip > 0 && (thing->renderflags & RF_SPRITETYPEMASK) == RF_FACESPRITE) @@ -734,7 +736,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) translation=thing->Translation; - OverrideShader = 0; + OverrideShader = -1; trans = FIXED2FLOAT(thing->alpha); hw_styleflags = STYLEHW_Normal; @@ -923,7 +925,7 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s if (lump != NULL) { - gltexture=FMaterial::ValidateTexture(lump); + gltexture = FMaterial::ValidateTexture(lump, true); translation = 0; ul = gltexture->GetUL(); @@ -931,7 +933,7 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s vt = gltexture->GetVT(); vb = gltexture->GetVB(); FloatRect r; - gltexture->GetRect(&r, GLUSE_PATCH); + gltexture->GetSpriteRect(&r); } } diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index bcf0080d0..1a9e30a72 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -783,12 +783,12 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, if ( (seg->linedef->flags & ML_DONTPEGBOTTOM) >0) { texturebottom = MAX(realfront->GetPlaneTexZ(sector_t::floor),realback->GetPlaneTexZ(sector_t::floor))+rowoffset; - texturetop=texturebottom+(gltexture->TextureHeight(GLUSE_TEXTURE)<TextureHeight()<GetPlaneTexZ(sector_t::ceiling),realback->GetPlaneTexZ(sector_t::ceiling))+rowoffset; - texturebottom=texturetop-(gltexture->TextureHeight(GLUSE_TEXTURE)<TextureHeight()<>FRACBITS)+seg->sidedef->TexelLength; - if ((textureoffset==0 && righttex<=gltexture->TextureWidth(GLUSE_TEXTURE)) || - (textureoffset>=0 && righttex==gltexture->TextureWidth(GLUSE_TEXTURE))) + if ((textureoffset==0 && righttex<=gltexture->TextureWidth()) || + (textureoffset>=0 && righttex==gltexture->TextureWidth())) { flags|=GLT_CLAMPX; } @@ -1094,19 +1094,19 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, if (rover->flags&FF_UPPERTEXTURE) { - gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), true); + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), false, true); if (!gltexture) return; gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::top), seg->sidedef->GetTextureYScale(side_t::top)); } else if (rover->flags&FF_LOWERTEXTURE) { - gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), true); + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), false, true); if (!gltexture) return; gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::bottom), seg->sidedef->GetTextureYScale(side_t::bottom)); } else { - gltexture = FMaterial::ValidateTexture(mastersd->GetTexture(side_t::mid), true); + gltexture = FMaterial::ValidateTexture(mastersd->GetTexture(side_t::mid), false, true); if (!gltexture) return; gltexture->GetTexCoordInfo(&tci, mastersd->GetTextureXScale(side_t::mid), mastersd->GetTextureYScale(side_t::mid)); } @@ -1558,7 +1558,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) SkyNormal(frontsector, v1, v2); // normal texture - gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::mid), true); + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::mid), false, true); if (gltexture) { DoTexture(RENDERWALL_M1S, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, @@ -1613,7 +1613,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (bch1a < fch1 || bch2a < fch2) { - gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), true); + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), false, true); if (gltexture) { DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, @@ -1625,7 +1625,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) frontsector->GetTexture(sector_t::ceiling) != skyflatnum && backsector->GetTexture(sector_t::ceiling) != skyflatnum) { - gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::ceiling), true); + gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::ceiling), false, true); if (gltexture) { DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, @@ -1650,7 +1650,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) { tex = tex->GetRawTexture(); } - gltexture = FMaterial::ValidateTexture(tex); + gltexture = FMaterial::ValidateTexture(tex, false); } else gltexture = NULL; @@ -1675,7 +1675,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (bfh1>ffh1 || bfh2>ffh2) { - gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), true); + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), false, true); if (gltexture) { DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, @@ -1693,7 +1693,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) // render it anyway with the sector's floor texture. With a background sky // there are ugly holes otherwise and slopes are simply not precise enough // to mach in any case. - gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), true); + gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), false, true); if (gltexture) { DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, @@ -1756,7 +1756,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh); - gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), true); + gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), false, true); if (gltexture) { diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 51bf5de18..5bb81fbe5 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -273,8 +273,8 @@ void GLWall::RenderMirrorSurface() gl_RenderState.AlphaFunc(GL_GREATER,0); glDepthFunc(GL_LEQUAL); - FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrortexture); - pat->BindPatch(0); + FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrortexture, false); + pat->Bind(CLAMP_NONE, 0, -1, false); flags &= ~GLWF_GLOW; RenderWall(RWF_BLANK); @@ -326,7 +326,7 @@ void GLWall::RenderTranslucentWall() if (gltexture) { gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); - gltexture->Bind(flags, 0); + gltexture->Bind(flags & 3, 0, -1, false); extra = getExtraLight(); } else @@ -390,7 +390,7 @@ void GLWall::Draw(int pass) else gl_SetFog(255, 0, NULL, false); gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); - gltexture->Bind(flags, 0); + gltexture->Bind(flags & 3, false, -1, false); RenderWall(RWF_TEXTURED|RWF_GLOW); gl_RenderState.EnableGlow(false); break; diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index d0f2ab370..67e2f9576 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -93,10 +93,10 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed FTextureID lump = gl_GetSpriteFrame(psp->sprite, psp->frame, 0, 0, &mirror); if (!lump.isValid()) return; - FMaterial * tex = FMaterial::ValidateTexture(lump, false); + FMaterial * tex = FMaterial::ValidateTexture(lump, true, false); if (!tex) return; - tex->BindPatch(0, OverrideShader, alphatexture); + tex->Bind(CLAMP_XY_NOMIP, 0, OverrideShader, alphatexture); int vw = viewwidth; int vh = viewheight; @@ -104,18 +104,18 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed // calculate edges of the shape scalex = xratio[WidescreenRatio] * vw / 320; - tx = sx - ((160 + tex->GetScaledLeftOffset(GLUSE_PATCH))<GetScaledLeftOffset())<>FRACBITS) + (vw>>1); if (x1 > vw) return; // off the right side x1+=viewwindowx; - tx += tex->TextureWidth(GLUSE_PATCH) << FRACBITS; + tx += tex->TextureWidth() << FRACBITS; x2 = (FixedMul(tx, scalex)>>FRACBITS) + (vw>>1); if (x2 < 0) return; // off the left side x2+=viewwindowx; // killough 12/98: fix psprite positioning problem - texturemid = (100<GetScaledTopOffset(GLUSE_PATCH)<GetScaledTopOffset()<ReadyWeapon; if (wi && wi->YAdjust) @@ -132,7 +132,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed scale = ((SCREENHEIGHT*vw)/SCREENWIDTH) / 200.0f; y1 = viewwindowy + (vh >> 1) - (int)(((float)texturemid / (float)FRACUNIT) * scale); - y2 = y1 + (int)((float)tex->TextureHeight(GLUSE_PATCH) * scale) + 1; + y2 = y1 + (int)((float)tex->TextureHeight() * scale) + 1; if (!mirror) { @@ -149,7 +149,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed fV2=tex->GetVB(); } - if (tex->GetTransparent() || OverrideShader != 0) + if (tex->GetTransparent() || OverrideShader != -1) { gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); } @@ -207,7 +207,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) FTextureID lump = gl_GetSpriteFrame(psp->sprite, psp->frame, 0, 0, NULL); if (lump.isValid()) { - FMaterial * tex=FMaterial::ValidateTexture(lump, false); + FMaterial * tex=FMaterial::ValidateTexture(lump, false, false); if (tex) disablefullbright = tex->tex->gl_info.bBrightmapDisablesFullbright; } @@ -306,7 +306,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) // Set the render parameters - int OverrideShader = 0; + int OverrideShader = -1; float trans = 0.f; if (vis.RenderStyle.BlendOp >= STYLEOP_Fuzz && vis.RenderStyle.BlendOp <= STYLEOP_FuzzOrRevSub) { diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 12e7c9e02..57ad3ba89 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -56,6 +56,7 @@ #include "gl/shaders/gl_shader.h" #include "gl/textures/gl_translate.h" #include "gl/textures/gl_material.h" +#include "gl/textures/gl_samplers.h" #include "gl/utility/gl_templates.h" #include "gl/data/gl_vertexbuffer.h" @@ -146,13 +147,12 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) return false; } - wipestartscreen = new FHardwareTexture(Width, Height, false, false, false, true); - wipestartscreen->CreateTexture(NULL, Width, Height, false, 0); + wipestartscreen = new FHardwareTexture(Width, Height, true); + wipestartscreen->CreateTexture(NULL, Width, Height, 0, false, 0, false); + GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER); glFinish(); - wipestartscreen->Bind(0); + wipestartscreen->Bind(0, false, false, false); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); @@ -169,10 +169,11 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) void OpenGLFrameBuffer::WipeEndScreen() { - wipeendscreen = new FHardwareTexture(Width, Height, false, false, false, true); - wipeendscreen->CreateTexture(NULL, Width, Height, false, 0); - glFlush(); - wipeendscreen->Bind(0); + wipeendscreen = new FHardwareTexture(Width, Height, true); + wipeendscreen->CreateTexture(NULL, Width, Height, 0, false, 0, false); + GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER); + glFinish(); + wipeendscreen->Bind(0, false, false, false); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -283,7 +284,7 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.ResetColor(); gl_RenderState.Apply(); - fb->wipestartscreen->Bind(0); + fb->wipestartscreen->Bind(0, 0, false, false); FFlatVertex *ptr; unsigned int offset, count; @@ -298,7 +299,7 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) ptr++; GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); - fb->wipeendscreen->Bind(0); + fb->wipeendscreen->Bind(0, 0, false, false); gl_RenderState.SetColorAlpha(0xffffff, clamp(Clock/32.f, 0.f, 1.f)); gl_RenderState.Apply(); GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); @@ -345,7 +346,7 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.SetTextureMode(TM_OPAQUE); gl_RenderState.ResetColor(); gl_RenderState.Apply(); - fb->wipeendscreen->Bind(0); + fb->wipeendscreen->Bind(0, 0, false, false); FFlatVertex *ptr; ptr = GLRenderer->mVBO->GetBuffer(); ptr->Set(0, 0, 0, 0, vb); @@ -361,7 +362,7 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) int i, dy; bool done = false; - fb->wipestartscreen->Bind(0); + fb->wipestartscreen->Bind(0, 0, false, false); // Copy the old screen in vertical strips on top of the new one. while (ticks--) { @@ -468,7 +469,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) } if (BurnTexture != NULL) delete BurnTexture; - BurnTexture = new FHardwareTexture(WIDTH, HEIGHT, false, false, false, true); + BurnTexture = new FHardwareTexture(WIDTH, HEIGHT, true); // Update the burn texture with the new burn data BYTE rgb_buffer[WIDTH*HEIGHT*4]; @@ -493,7 +494,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.ResetColor(); gl_RenderState.Apply(); - fb->wipestartscreen->Bind(0); + fb->wipestartscreen->Bind(0, 0, false, false); FFlatVertex *ptr; unsigned int offset, count; ptr = GLRenderer->mVBO->GetBuffer(); @@ -513,9 +514,9 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.Apply(); // Burn the new screen on top of it. - fb->wipeendscreen->Bind(1); + fb->wipeendscreen->Bind(1, 0, false, false); - BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, false, 0); + BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, 0, false, 0, false); GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); gl_RenderState.SetEffect(EFF_NONE); diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 697bcda4d..d076f6a3e 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -4,7 +4,7 @@ ** containers for the various translations a texture can have. ** **--------------------------------------------------------------------------- -** Copyright 2004-2005 Christoph Oelckers +** Copyright 2004-2014 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -173,6 +173,7 @@ void FHardwareTexture::Resize(int width, int height, unsigned char *src_data, un } + //=========================================================================== // // Loads the texture image into the hardware @@ -182,24 +183,27 @@ void FHardwareTexture::Resize(int width, int height, unsigned char *src_data, un // strange crashes deep inside the GL driver when I didn't do it! // //=========================================================================== -void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned int & glTexID,int wrapparam, bool alphatexture, int texunit) + +unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, bool alphatexture) { int rh,rw; int texformat=TexFormat[gl_texture_format]; bool deletebuffer=false; - bool use_mipmapping = TexFilter[gl_texture_filter].mipmapping; if (alphatexture) { texformat = GL_R8; + translation = TRANS_Alpha; } else if (forcenocompression) { texformat = GL_RGBA8; } - if (glTexID==0) glGenTextures(1,&glTexID); - glBindTexture(GL_TEXTURE_2D, glTexID); - lastbound[texunit]=glTexID; + TranslatedTexture * glTex=GetTexID(translation); + if (glTex->glTexID==0) glGenTextures(1,&glTex->glTexID); + if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); + glBindTexture(GL_TEXTURE_2D, glTex->glTexID); + lastbound[texunit] = glTex->glTexID; if (!buffer) { @@ -209,7 +213,7 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i rh = GetTexDimension (h); // The texture must at least be initialized if no data is present. - mipmap=false; + glTex->mipmapped = false; buffer=(unsigned char *)calloc(4,rw * (rh+1)); deletebuffer=true; //texheight=-h; @@ -235,42 +239,19 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i if (deletebuffer) free(buffer); - if (mipmap && use_mipmapping && !forcenofiltering) glGenerateMipmap(GL_TEXTURE_2D); + if (mipmap && TexFilter[gl_texture_filter].mipmapping) + { + glGenerateMipmap(GL_TEXTURE_2D); + glTex->mipmapped = true; + } + if (alphatexture) { static const GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_RED}; glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); } - - // When using separate samplers the stuff below is not needed. - // if (gl.flags & RFL_SAMPLER_OBJECTS) return; - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapparam); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapparam); - clampmode = wrapparam==GL_CLAMP_TO_EDGE? GLT_CLAMPX|GLT_CLAMPY : 0; - - if (forcenofiltering) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); - } - else - { - if (mipmap && use_mipmapping) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); - if (gl_texture_filter_anisotropic) - { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); - } - } - else - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); - } - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); - } + if (texunit != 0) glActiveTexture(GL_TEXTURE0); + return glTex->glTexID; } @@ -279,17 +260,16 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i // Creates a texture // //=========================================================================== -FHardwareTexture::FHardwareTexture(int _width, int _height, bool _mipmap, bool wrap, bool nofilter, bool nocompression) +FHardwareTexture::FHardwareTexture(int _width, int _height, bool nocompression) { forcenocompression = nocompression; - mipmap=_mipmap; texwidth=_width; texheight=_height; - glDefTexID = 0; - clampmode=0; + glDefTex.glTexID = 0; + glDefTex.translation = 0; + glDefTex.mipmapped = false; glDepthID = 0; - forcenofiltering = nofilter; } @@ -298,18 +278,20 @@ FHardwareTexture::FHardwareTexture(int _width, int _height, bool _mipmap, bool w // Deletes a texture id and unbinds it from the texture units // //=========================================================================== -void FHardwareTexture::DeleteTexture(unsigned int texid) +void FHardwareTexture::TranslatedTexture::Delete() { - if (texid != 0) + if (glTexID != 0) { for(int i = 0; i < MAX_TEXTURES; i++) { - if (lastbound[i] == texid) + if (lastbound[i] == glTexID) { lastbound[i] = 0; } } - glDeleteTextures(1, &texid); + glDeleteTextures(1, &glTexID); + glTexID = 0; + mipmapped = false; } } @@ -324,14 +306,13 @@ void FHardwareTexture::Clean(bool all) if (all) { - DeleteTexture(glDefTexID); - glDefTexID = 0; + glDefTex.Delete(); } - for(unsigned int i=0;iglTexID != 0) { - if (lastbound[texunit]==*pTexID) return *pTexID; - lastbound[texunit]=*pTexID; - if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); - glBindTexture(GL_TEXTURE_2D, *pTexID); + if (lastbound[texunit] == pTex->glTexID) return pTex->glTexID; + lastbound[texunit] = pTex->glTexID; + if (texunit != 0) glActiveTexture(GL_TEXTURE0 + texunit); + glBindTexture(GL_TEXTURE_2D, pTex->glTexID); + // Check if we need mipmaps on a texture that was creted without them. + if (needmipmap && !pTex->mipmapped && TexFilter[gl_texture_filter].mipmapping) + { + glGenerateMipmap(GL_TEXTURE_2D); + pTex->mipmapped = true; + } if (texunit != 0) glActiveTexture(GL_TEXTURE0); - return *pTexID; + return pTex->glTexID; } return 0; } @@ -445,25 +433,7 @@ int FHardwareTexture::GetDepthBuffer() void FHardwareTexture::BindToFrameBuffer() { - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glDefTexID, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glDefTex.glTexID, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); } - -//=========================================================================== -// -// (re-)creates the texture -// -//=========================================================================== -unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int h, bool wrap, int texunit, int translation, bool alphatexture) -{ - if (alphatexture) translation = TRANS_Alpha; - unsigned int * pTexID=GetTexID(translation); - - if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); - LoadImage(buffer, w, h, *pTexID, wrap? GL_REPEAT:GL_CLAMP_TO_EDGE, alphatexture, texunit); - if (texunit != 0) glActiveTexture(GL_TEXTURE0); - return *pTexID; -} - - diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h index 4e13bc841..eabc7a6ef 100644 --- a/src/gl/textures/gl_hwtexture.h +++ b/src/gl/textures/gl_hwtexture.h @@ -33,23 +33,26 @@ enum class FHardwareTexture { +public: enum { MAX_TEXTURES = 16 }; +private: struct TranslatedTexture { unsigned int glTexID; int translation; - //int cm; + bool mipmapped; + + void Delete(); }; public: static unsigned int lastbound[MAX_TEXTURES]; static int lastactivetexture; - static bool supportsNonPower2; static int max_texturesize; static int GetTexDimension(int value); @@ -57,25 +60,20 @@ public: private: short texwidth, texheight; - //float scalexfac, scaleyfac; - bool mipmap; - BYTE clampmode; - bool forcenofiltering; bool forcenocompression; - unsigned glDefTexID; - TArray glTexID_Translated; + TranslatedTexture glDefTex; + TArray glTex_Translated; unsigned int glDepthID; // only used by camera textures - void LoadImage(unsigned char * buffer,int w, int h, unsigned int & glTexID,int wrapparam, bool alphatexture, int texunit); - unsigned * GetTexID(int translation); + void LoadImage(unsigned char * buffer,int w, int h, TranslatedTexture *glTex, bool mipmap, bool alphatexture, int texunit); + TranslatedTexture * GetTexID(int translation); int GetDepthBuffer(); - void DeleteTexture(unsigned int texid); void Resize(int width, int height, unsigned char *src_data, unsigned char *dst_data); public: - FHardwareTexture(int w, int h, bool mip, bool wrap, bool nofilter, bool nocompress); + FHardwareTexture(int w, int h, bool nocompress); ~FHardwareTexture(); static void Unbind(int texunit); @@ -83,9 +81,8 @@ public: void BindToFrameBuffer(); - unsigned int Bind(int texunit, int translation=0, bool alphatexture = false); - unsigned int CreateTexture(unsigned char * buffer, int w, int h,bool wrap, int texunit, int translation=0, bool alphatexture = false); - void Resize(int _width, int _height) ; + unsigned int Bind(int texunit, int translation, bool alphatexture, bool needmipmap); + unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, bool alphatexture); void Clean(bool all); }; diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 9ec948b37..443560c7f 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -53,11 +53,13 @@ #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderer.h" #include "gl/data/gl_data.h" #include "gl/textures/gl_texture.h" #include "gl/textures/gl_translate.h" #include "gl/textures/gl_bitmap.h" #include "gl/textures/gl_material.h" +#include "gl/textures/gl_samplers.h" #include "gl/shaders/gl_shader.h" EXTERN_CVAR(Bool, gl_render_precise) @@ -78,17 +80,16 @@ EXTERN_CVAR(Bool, gl_texture_usehires) //=========================================================================== FGLTexture::FGLTexture(FTexture * tx, bool expandpatches) { - assert(tx->gl_info.SystemTexture == NULL); + assert(tx->gl_info.SystemTexture[expandpatches] == NULL); tex = tx; - glpatch=NULL; - for(int i=0;i<5;i++) gltexture[i]=NULL; - HiresLump=-1; + mHwTexture = NULL; + HiresLump = -1; hirestexture = NULL; bHasColorkey = false; bIsTransparent = -1; bExpand = expandpatches; - tex->gl_info.SystemTexture = this; + tex->gl_info.SystemTexture[expandpatches] = this; } //=========================================================================== @@ -162,25 +163,13 @@ unsigned char *FGLTexture::LoadHiresTexture(FTexture *tex, int *width, int *heig void FGLTexture::Clean(bool all) { - for(int i=0;i<5;i++) + if (mHwTexture) { - if (gltexture[i]) - { - if (!all) gltexture[i]->Clean(false); - else - { - delete gltexture[i]; - gltexture[i]=NULL; - } - } - } - if (glpatch) - { - if (!all) glpatch->Clean(false); + if (!all) mHwTexture->Clean(false); else { - delete glpatch; - glpatch=NULL; + delete mHwTexture; + mHwTexture = NULL; } } } @@ -192,7 +181,7 @@ void FGLTexture::Clean(bool all) // //=========================================================================== -unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, bool expand, FTexture *hirescheck, bool alphatexture) +unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool alphatexture) { unsigned char * buffer; int W, H; @@ -209,8 +198,8 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, b } } - W = w = tex->GetWidth() + expand*2; - H = h = tex->GetHeight() + expand*2; + W = w = tex->GetWidth() + bExpand*2; + H = h = tex->GetHeight() + bExpand*2; buffer=new unsigned char[W*(H+1)*4]; @@ -229,7 +218,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, b if (imgCreate.Create(W, H)) { memset(imgCreate.GetPixels(), 0, W * H * 4); - int trans = tex->CopyTrueColorPixels(&imgCreate, expand, expand); + int trans = tex->CopyTrueColorPixels(&imgCreate, bExpand, bExpand); bmp.CopyPixelDataRGB(0, 0, imgCreate.GetPixels(), W, H, 4, W * 4, 0, CF_BGRA); tex->CheckTrans(buffer, W*H, trans); bIsTransparent = tex->gl_info.mIsTransparent; @@ -237,7 +226,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, b } else if (translation<=0) { - int trans = tex->CopyTrueColorPixels(&bmp, expand, expand); + int trans = tex->CopyTrueColorPixels(&bmp, bExpand, bExpand); tex->CheckTrans(buffer, W*H, trans); bIsTransparent = tex->gl_info.mIsTransparent; } @@ -246,7 +235,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, b // When using translations everything must be mapped to the base palette. // Since FTexture's method is doing exactly that by calling GetPixels let's use that here // to do all the dirty work for us. ;) - tex->FTexture::CopyTrueColorPixels(&bmp, expand, expand); + tex->FTexture::CopyTrueColorPixels(&bmp, bExpand, bExpand); bIsTransparent = 0; } @@ -262,64 +251,32 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, b // //=========================================================================== -FHardwareTexture *FGLTexture::CreateTexture(int clampmode) +FHardwareTexture *FGLTexture::CreateHwTexture() { if (tex->UseType==FTexture::TEX_Null) return NULL; // Cannot register a NULL texture - if (!gltexture[clampmode]) + if (mHwTexture == NULL) { - gltexture[clampmode] = new FHardwareTexture(tex->GetWidth(), tex->GetHeight(), true, true, false, tex->gl_info.bNoCompress); + mHwTexture = new FHardwareTexture(tex->GetWidth() + bExpand*2, tex->GetHeight() + bExpand*2, tex->gl_info.bNoCompress); } - return gltexture[clampmode]; + return mHwTexture; } -//=========================================================================== -// -// Create Hardware texture for patch use -// -//=========================================================================== - -bool FGLTexture::CreatePatch() -{ - if (tex->UseType==FTexture::TEX_Null) return false; // Cannot register a NULL texture - if (!glpatch) - { - glpatch=new FHardwareTexture(tex->GetWidth() + bExpand, tex->GetHeight() + bExpand, false, false, tex->gl_info.bNoFilter, tex->gl_info.bNoCompress); - } - if (glpatch) return true; - return false; -} - - //=========================================================================== // // Binds a texture to the renderer // //=========================================================================== -const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int translation, FTexture *hirescheck) +const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int translation, bool alphatexture, FTexture *hirescheck) { int usebright = false; if (translation <= 0) translation = -translation; else translation = GLTranslationPalette::GetInternalTranslation(translation); - FHardwareTexture *hwtex; - - if (gltexture[4] != NULL && clampmode < 4 && gltexture[clampmode] == NULL) - { - hwtex = gltexture[clampmode] = gltexture[4]; - gltexture[4] = NULL; + bool needmipmap = (clampmode <= CLAMP_XY); - if (hwtex->Bind(texunit, translation)) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (clampmode & GLT_CLAMPX)? GL_CLAMP_TO_EDGE : GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (clampmode & GLT_CLAMPY)? GL_CLAMP_TO_EDGE : GL_REPEAT); - } - } - else - { - hwtex = CreateTexture(clampmode); - } + FHardwareTexture *hwtex = CreateHwTexture(); if (hwtex) { @@ -327,11 +284,11 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla if ((!tex->bHasCanvas && !tex->bWarped) && tex->CheckModified()) { Clean(true); - hwtex = CreateTexture(clampmode); + hwtex = CreateHwTexture(); } // Bind it to the system. - if (!hwtex->Bind(texunit, translation)) + if (!hwtex->Bind(texunit, translation, alphatexture, needmipmap)) { int w=0, h=0; @@ -341,73 +298,25 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla if (!tex->bHasCanvas) { - buffer = CreateTexBuffer(translation, w, h, false, hirescheck); + buffer = CreateTexBuffer(translation, w, h, hirescheck, alphatexture); tex->ProcessData(buffer, w, h, false); } - if (!hwtex->CreateTexture(buffer, w, h, true, texunit, translation)) + if (!hwtex->CreateTexture(buffer, w, h, texunit, needmipmap, translation, alphatexture)) { // could not create texture delete[] buffer; return NULL; } - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (clampmode & GLT_CLAMPX)? GL_CLAMP_TO_EDGE : GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (clampmode & GLT_CLAMPY)? GL_CLAMP_TO_EDGE : GL_REPEAT); delete[] buffer; } if (tex->bHasCanvas) static_cast(tex)->NeedUpdate(); + GLRenderer->mSamplerManager->Bind(texunit, clampmode); return hwtex; } return NULL; } -//=========================================================================== -// -// Binds a sprite to the renderer -// -//=========================================================================== -const FHardwareTexture * FGLTexture::BindPatch(int texunit, int translation, bool alphatexture) -{ - bool usebright = false; - int transparm = translation; - - if (translation <= 0) translation = -translation; - else translation = GLTranslationPalette::GetInternalTranslation(translation); - - if (CreatePatch()) - { - // Texture has become invalid - this is only for special textures, not the regular warping, which is handled above - if ((!tex->bHasCanvas && !tex->bWarped) && tex->CheckModified()) - { - Clean(true); - CreatePatch(); - } - - - // Bind it to the system. - if (!glpatch->Bind(texunit, translation, alphatexture)) - { - int w, h; - - // Create this texture - unsigned char * buffer = CreateTexBuffer(translation, w, h, bExpand, NULL, alphatexture); - tex->ProcessData(buffer, w, h, true); - if (!glpatch->CreateTexture(buffer, w, h, false, texunit, translation, alphatexture)) - { - // could not create texture - delete[] buffer; - return NULL; - } - delete[] buffer; - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - } - return glpatch; - } - return NULL; -} - - //=========================================================================== // // @@ -475,7 +384,7 @@ FGLTexture * FMaterial::ValidateSysTexture(FTexture * tex, bool expand) { if (tex && tex->UseType!=FTexture::TEX_Null) { - FGLTexture *gltex = tex->gl_info.SystemTexture; + FGLTexture *gltex = tex->gl_info.SystemTexture[expand]; if (gltex == NULL) { gltex = new FGLTexture(tex, expand); @@ -493,15 +402,8 @@ FGLTexture * FMaterial::ValidateSysTexture(FTexture * tex, bool expand) TArray FMaterial::mMaterials; int FMaterial::mMaxBound; -FMaterial::FMaterial(FTexture * tx, bool forceexpand) +FMaterial::FMaterial(FTexture * tx, bool expanded) { - assert(tx->gl_info.Material == NULL); - - bool expanded = tx->UseType == FTexture::TEX_Sprite || - tx->UseType == FTexture::TEX_SkinSprite || - tx->UseType == FTexture::TEX_Decal || - forceexpand; - mShaderIndex = 0; // TODO: apply custom shader object here @@ -539,83 +441,62 @@ FMaterial::FMaterial(FTexture * tx, bool forceexpand) } } } + assert(tx->gl_info.Material[expanded] == NULL); + mBaseLayer = ValidateSysTexture(tx, true); - for (int i=GLUSE_PATCH; i<=GLUSE_TEXTURE; i++) - { - Width[i] = tx->GetWidth(); - Height[i] = tx->GetHeight(); - LeftOffset[i] = tx->LeftOffset; - TopOffset[i] = tx->TopOffset; - RenderWidth[i] = tx->GetScaledWidth(); - RenderHeight[i] = tx->GetScaledHeight(); - } - Width[GLUSE_SPRITE] = Width[GLUSE_PATCH]; - Height[GLUSE_SPRITE] = Height[GLUSE_PATCH]; - LeftOffset[GLUSE_SPRITE] = LeftOffset[GLUSE_PATCH]; - TopOffset[GLUSE_SPRITE] = TopOffset[GLUSE_PATCH]; - SpriteU[0] = SpriteV[0] = 0; - spriteright = SpriteU[1] = Width[GLUSE_PATCH] / (float)FHardwareTexture::GetTexDimension(Width[GLUSE_PATCH]); - spritebottom = SpriteV[1] = Height[GLUSE_PATCH] / (float)FHardwareTexture::GetTexDimension(Height[GLUSE_PATCH]); + mWidth = tx->GetWidth(); + mHeight = tx->GetHeight(); + mLeftOffset = tx->LeftOffset; + mTopOffset = tx->TopOffset; + mRenderWidth = tx->GetScaledWidth(); + mRenderHeight = tx->GetScaledHeight(); + mSpriteU[0] = mSpriteV[0] = 0.f; + mSpriteU[1] = mSpriteV[1] = 1.f; - mTextureLayers.ShrinkToFit(); - mMaxBound = -1; - mMaterials.Push(this); - tx->gl_info.Material = this; - if (tx->bHasCanvas) tx->gl_info.mIsTransparent = 0; - tex = tx; - - tx->gl_info.mExpanded = expanded; FTexture *basetex = tx->GetRedirect(false); - if (!expanded && !basetex->gl_info.mExpanded && basetex->UseType != FTexture::TEX_Sprite) - { - // check if the texture is just a simple redirect to a patch - // If so we should use the patch for texture creation to - // avoid eventual redundancies. - // This may only be done if both textures use the same expansion mode - // Redirects to sprites are not permitted because sprites get expanded, however, this won't have been set - // if the sprite hadn't been used yet. - mBaseLayer = ValidateSysTexture(basetex, false); - } - else if (!expanded) - { - // if we got a non-expanded texture that redirects to an expanded one - mBaseLayer = ValidateSysTexture(tx, false); - } - else + mBaseLayer = ValidateSysTexture(basetex, expanded); + + // mSpriteRect is for positioning the sprite in the scene. + mSpriteRect.left = -mLeftOffset / FIXED2FLOAT(tx->xScale); + mSpriteRect.top = -mTopOffset / FIXED2FLOAT(tx->yScale); + mSpriteRect.width = mWidth / FIXED2FLOAT(tx->xScale); + mSpriteRect.height = mHeight / FIXED2FLOAT(tx->yScale); + + if (expanded) { // a little adjustment to make sprites look better with texture filtering: // create a 1 pixel wide empty frame around them. - RenderWidth[GLUSE_PATCH]+=2; - RenderHeight[GLUSE_PATCH]+=2; - Width[GLUSE_PATCH]+=2; - Height[GLUSE_PATCH]+=2; - LeftOffset[GLUSE_PATCH]+=1; - TopOffset[GLUSE_PATCH]+=1; - Width[GLUSE_SPRITE] += 2; - Height[GLUSE_SPRITE] += 2; - LeftOffset[GLUSE_SPRITE] += 1; - TopOffset[GLUSE_SPRITE] += 1; - spriteright = SpriteU[1] = Width[GLUSE_PATCH] / (float)FHardwareTexture::GetTexDimension(Width[GLUSE_PATCH]); - spritebottom = SpriteV[1] = Height[GLUSE_PATCH] / (float)FHardwareTexture::GetTexDimension(Height[GLUSE_PATCH]); - - mBaseLayer = ValidateSysTexture(tx, true); + mWidth+=2; + mHeight+=2; + mLeftOffset+=1; + mTopOffset+=1; + mRenderWidth = mRenderWidth * mWidth / (mWidth-2); + mRenderHeight = mRenderHeight * mHeight / (mHeight-2); int trim[4]; if (TrimBorders(trim)) { - Width[GLUSE_SPRITE] = trim[2] + 2; - Height[GLUSE_SPRITE] = trim[3] + 2; - LeftOffset[GLUSE_SPRITE] -= trim[0]; - TopOffset[GLUSE_SPRITE] -= trim[1]; + mSpriteRect.left = -(mLeftOffset - trim[0]) / FIXED2FLOAT(tx->xScale); + mSpriteRect.top = -(mTopOffset - trim[1]) / FIXED2FLOAT(tx->yScale); + mSpriteRect.width = (trim[2] + 2) / FIXED2FLOAT(tx->xScale); + mSpriteRect.height = (trim[3] + 2) / FIXED2FLOAT(tx->yScale); - SpriteU[0] = SpriteU[1] * (trim[0] / (float)Width[GLUSE_PATCH]); - SpriteV[0] = SpriteV[1] * (trim[1] / (float)Height[GLUSE_PATCH]); - SpriteU[1] *= (trim[0]+trim[2]+2) / (float)Width[GLUSE_PATCH]; - SpriteV[1] *= (trim[1]+trim[3]+2) / (float)Height[GLUSE_PATCH]; + mSpriteU[0] = trim[0] / (float)mWidth; + mSpriteV[0] = trim[1] / (float)mHeight; + mSpriteU[1] *= (trim[0]+trim[2]+2) / (float)mWidth; + mSpriteV[1] *= (trim[1]+trim[3]+2) / (float)mHeight; } } + + mTextureLayers.ShrinkToFit(); + mMaxBound = -1; + mMaterials.Push(this); + tx->gl_info.Material[expanded] = this; + if (tx->bHasCanvas) tx->gl_info.mIsTransparent = 0; + tex = tx; + mExpanded = expanded; } //=========================================================================== @@ -657,7 +538,7 @@ bool FMaterial::TrimBorders(int *rect) { return false; } - if (w != Width[GLUSE_TEXTURE] || h != Height[GLUSE_TEXTURE]) + if (w != mWidth || h != mHeight) { // external Hires replacements cannot be trimmed. delete [] buffer; @@ -730,20 +611,19 @@ outl: // //=========================================================================== -void FMaterial::Bind(int clampmode, int translation, int overrideshader) +void FMaterial::Bind(int clampmode, int translation, int overrideshader, bool alphatexture) { int usebright = false; int shaderindex = overrideshader > 0? overrideshader : mShaderIndex; int maxbound = 0; - bool allowhires = tex->xScale == FRACUNIT && tex->yScale == FRACUNIT; + bool allowhires = tex->xScale == FRACUNIT && tex->yScale == FRACUNIT && clampmode <= CLAMP_XY && !mExpanded; gl_RenderState.SetShader(shaderindex, tex->gl_info.shaderspeed); - if (tex->bHasCanvas || tex->bWarped) clampmode = 0; - else if (clampmode != -1) clampmode &= 3; - else clampmode = 4; + if (tex->bHasCanvas) clampmode = CLAMP_CAMTEX; + else if (tex->bWarped && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE; - const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, allowhires? tex:NULL); + const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, alphatexture, allowhires? tex:NULL); if (gltexture != NULL && shaderindex > 0 && overrideshader == 0) { for(unsigned i=0;iid; layer = TexMan(id); - ValidateSysTexture(layer, false); + ValidateSysTexture(layer, mExpanded); } else { layer = mTextureLayers[i].texture; } - layer->gl_info.SystemTexture->Bind(i+1, clampmode, 0, NULL); + layer->gl_info.SystemTexture[mExpanded]->Bind(i+1, clampmode, 0, false, NULL); maxbound = i+1; } } @@ -772,36 +652,6 @@ void FMaterial::Bind(int clampmode, int translation, int overrideshader) } -//=========================================================================== -// -// Binds a texture to the renderer -// -//=========================================================================== - -void FMaterial::BindPatch(int translation, int overrideshader, bool alphatexture) -{ - int usebright = false; - int shaderindex = overrideshader > 0? overrideshader : mShaderIndex; - int maxbound = 0; - - gl_RenderState.SetShader(shaderindex, tex->gl_info.shaderspeed); - - const FHardwareTexture *glpatch = mBaseLayer->BindPatch(0, translation, alphatexture); - // The only multitexture effect usable on sprites is the brightmap. - if (glpatch != NULL && shaderindex == 3) - { - mTextureLayers[0].texture->gl_info.SystemTexture->BindPatch(1, 0, false); - maxbound = 1; - } - // unbind everything from the last texture that's still active - for(int i=maxbound+1; i<=mMaxBound;i++) - { - FHardwareTexture::Unbind(i); - mMaxBound = maxbound; - } -} - - //=========================================================================== // // @@ -809,31 +659,12 @@ void FMaterial::BindPatch(int translation, int overrideshader, bool alphatexture //=========================================================================== void FMaterial::Precache() { - if (tex->UseType==FTexture::TEX_Sprite) - { - BindPatch(0); - } - else - { - int cached = 0; - for(int i=0;i<4;i++) - { - if (mBaseLayer->gltexture[i] != 0) - { - Bind (i, 0); - cached++; - } - if (cached == 0) Bind(-1, 0); - } - } + Bind(0, 0, 0, false); } //=========================================================================== // -// This function is needed here to temporarily manipulate the texture -// for per-wall scaling so that the coordinate functions return proper -// results. Doing this here is much easier than having the calling code -// make these calculations. +// Retrieve texture coordinate info for per-wall scaling // //=========================================================================== @@ -841,14 +672,14 @@ void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const { if (x == FRACUNIT) { - tci->mRenderWidth = RenderWidth[GLUSE_TEXTURE]; + tci->mRenderWidth = mRenderWidth; tci->mScaleX = tex->xScale; tci->mTempScaleX = FRACUNIT; } else { fixed_t scale_x = FixedMul(x, tex->xScale); - int foo = (Width[GLUSE_TEXTURE] << 17) / scale_x; + int foo = (mWidth << 17) / scale_x; tci->mRenderWidth = (foo >> 1) + (foo & 1); tci->mScaleX = scale_x; tci->mTempScaleX = x; @@ -856,14 +687,14 @@ void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const if (y == FRACUNIT) { - tci->mRenderHeight = RenderHeight[GLUSE_TEXTURE]; + tci->mRenderHeight = mRenderHeight; tci->mScaleY = tex->yScale; tci->mTempScaleY = FRACUNIT; } else { fixed_t scale_y = FixedMul(y, tex->yScale); - int foo = (Height[GLUSE_TEXTURE] << 17) / scale_y; + int foo = (mHeight << 17) / scale_y; tci->mRenderHeight = (foo >> 1) + (foo & 1); tci->mScaleY = scale_y; tci->mTempScaleY = y; @@ -874,7 +705,7 @@ void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const tci->mRenderHeight = -tci->mRenderHeight; } tci->mWorldPanning = tex->bWorldPanning; - tci->mWidth = Width[GLUSE_TEXTURE]; + tci->mWidth = mWidth; } //=========================================================================== @@ -905,30 +736,15 @@ int FMaterial::GetAreas(FloatRect **pAreas) const void FMaterial::BindToFrameBuffer() { - if (mBaseLayer->gltexture[0] == NULL) + if (mBaseLayer->mHwTexture == NULL) { // must create the hardware texture first - mBaseLayer->Bind(0, 0, 0, NULL); + mBaseLayer->Bind(0, 0, 0, false, NULL); FHardwareTexture::Unbind(0); } - mBaseLayer->gltexture[0]->BindToFrameBuffer(); + mBaseLayer->mHwTexture->BindToFrameBuffer(); } -//=========================================================================== -// -// GetRect -// -//=========================================================================== - -void FMaterial::GetRect(FloatRect * r, ETexUse i) const -{ - r->left = -GetScaledLeftOffsetFloat(i); - r->top = -GetScaledTopOffsetFloat(i); - r->width = GetScaledWidthFloat(i); - r->height = GetScaledHeightFloat(i); -} - - //========================================================================== // // Gets a texture from the texture manager and checks its validity for @@ -936,24 +752,24 @@ void FMaterial::GetRect(FloatRect * r, ETexUse i) const // //========================================================================== -FMaterial * FMaterial::ValidateTexture(FTexture * tex) +FMaterial * FMaterial::ValidateTexture(FTexture * tex, bool expand) { if (tex && tex->UseType!=FTexture::TEX_Null) { - FMaterial *gltex = tex->gl_info.Material; + FMaterial *gltex = tex->gl_info.Material[expand]; if (gltex == NULL) { //@sync-tex - gltex = new FMaterial(tex, false); + gltex = new FMaterial(tex, expand); } return gltex; } return NULL; } -FMaterial * FMaterial::ValidateTexture(FTextureID no, bool translate) +FMaterial * FMaterial::ValidateTexture(FTextureID no, bool expand, bool translate) { - return ValidateTexture(translate? TexMan(no) : TexMan[no]); + return ValidateTexture(translate? TexMan(no) : TexMan[no], expand); } @@ -973,47 +789,11 @@ void FMaterial::FlushAll() // so this will catch everything. for(int i=TexMan.NumTextures()-1;i>=0;i--) { - FGLTexture *gltex = TexMan.ByIndex(i)->gl_info.SystemTexture; - if (gltex != NULL) gltex->Clean(true); - } -} - -//========================================================================== -// -// Prints some texture info -// -//========================================================================== - -int FGLTexture::Dump(int i) -{ - int cnt = 0; - int lump = tex->GetSourceLump(); - Printf(PRINT_LOG, "Texture '%s' (Index %d, Lump %d, Name '%s'):\n", tex->Name.GetChars(), i, lump, Wads.GetLumpFullName(lump)); - if (hirestexture) Printf(PRINT_LOG, "\tHirestexture\n"); - if (glpatch) Printf(PRINT_LOG, "\tPatch\n"),cnt++; - if (gltexture[0]) Printf(PRINT_LOG, "\tTexture (x:no, y:no )\n"),cnt++; - if (gltexture[1]) Printf(PRINT_LOG, "\tTexture (x:yes, y:no )\n"),cnt++; - if (gltexture[2]) Printf(PRINT_LOG, "\tTexture (x:no, y:yes)\n"),cnt++; - if (gltexture[3]) Printf(PRINT_LOG, "\tTexture (x:yes, y:yes)\n"),cnt++; - if (gltexture[4]) Printf(PRINT_LOG, "\tTexture precache\n"),cnt++; - return cnt; -} - -CCMD(textureinfo) -{ - int cnth = 0, cntt = 0, pix = 0; - for(int i=0; igl_info.SystemTexture; - if (systex != NULL) + for (int j = 0; j < 2; j++) { - int cnt = systex->Dump(i); - cnth+=cnt; - cntt++; - pix += cnt * tex->GetWidth() * tex->GetHeight(); + FGLTexture *gltex = TexMan.ByIndex(i)->gl_info.SystemTexture[j]; + if (gltex != NULL) gltex->Clean(true); } } - Printf(PRINT_LOG, "%d system textures, %d hardware textures, %d pixels\n", cntt, cnth, pix); } diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 259f881b4..714ab5a03 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -13,6 +13,17 @@ EXTERN_CVAR(Bool, gl_precache) struct FRemapTable; class FTextureShader; +enum +{ + CLAMP_NONE = 0, + CLAMP_X = 1, + CLAMP_Y = 2, + CLAMP_XY = 3, + CLAMP_XY_NOMIP = 4, + CLAMP_NOFILTER = 5, + CLAMP_CAMTEX = 6, +}; + struct FTexCoordInfo @@ -40,13 +51,6 @@ struct FTexCoordInfo //=========================================================================== class FMaterial; -enum ETexUse -{ - GLUSE_PATCH, - GLUSE_TEXTURE, - GLUSE_SPRITE, -}; - class FGLTexture { @@ -58,26 +62,23 @@ public: int HiresLump; private: - FHardwareTexture *gltexture[5]; - FHardwareTexture *glpatch; + FHardwareTexture *mHwTexture; bool bHasColorkey; // only for hires bool bExpand; unsigned char * LoadHiresTexture(FTexture *hirescheck, int *width, int *height, bool alphatexture); - FHardwareTexture *CreateTexture(int clampmode); - //bool CreateTexture(); - bool CreatePatch(); + FHardwareTexture *CreateHwTexture(); - const FHardwareTexture *Bind(int texunit, int clamp, int translation, FTexture *hirescheck); + const FHardwareTexture *Bind(int texunit, int clamp, int translation, bool alphatexture, FTexture *hirescheck); const FHardwareTexture *BindPatch(int texunit, int translation, bool alphatexture); public: FGLTexture(FTexture * tx, bool expandpatches); ~FGLTexture(); - unsigned char * CreateTexBuffer(int translation, int & w, int & h, bool expand, FTexture *hirescheck, bool alphatexture = false); + unsigned char * CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool alphatexture); void Clean(bool all); int Dump(int i); @@ -105,15 +106,16 @@ class FMaterial TArray mTextureLayers; int mShaderIndex; - short LeftOffset[3]; - short TopOffset[3]; - short Width[3]; - short Height[3]; - short RenderWidth[2]; - short RenderHeight[2]; + short mLeftOffset; + short mTopOffset; + short mWidth; + short mHeight; + short mRenderWidth; + short mRenderHeight; + bool mExpanded; - float SpriteU[2], SpriteV[2]; - float spriteright, spritebottom; + float mSpriteU[2], mSpriteV[2]; + FloatRect mSpriteRect; FGLTexture * ValidateSysTexture(FTexture * tex, bool expand); bool TrimBorders(int *rect); @@ -129,12 +131,17 @@ public: return !!mBaseLayer->tex->bMasked; } - void Bind(int clamp = 0, int translation = 0, int overrideshader = 0); - void BindPatch(int translation = 0, int overrideshader = 0, bool alphatexture = false); - - unsigned char * CreateTexBuffer(int translation, int & w, int & h, bool expand = false, bool allowhires=true) const + int GetLayers() const { - return mBaseLayer->CreateTexBuffer(translation, w, h, expand, allowhires? tex:NULL, 0); + return mTextureLayers.Size() + 1; + } + + //void Bind(int clamp = 0, int translation = 0, int overrideshader = 0, bool alphatexture = false); + void Bind(int clamp, int translation, int overrideshader, bool alphatexture); + + unsigned char * CreateTexBuffer(int translation, int & w, int & h, bool allowhires=true) const + { + return mBaseLayer->CreateTexBuffer(translation, w, h, allowhires? tex:NULL, 0); } void Clean(bool f) @@ -145,78 +152,82 @@ public: void BindToFrameBuffer(); // Patch drawing utilities - void GetRect(FloatRect *r, ETexUse i) const; + void GetSpriteRect(FloatRect * r) const + { + *r = mSpriteRect; + } + void GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const; // This is scaled size in integer units as needed by walls and flats - int TextureHeight(ETexUse i) const { return RenderHeight[i]; } - int TextureWidth(ETexUse i) const { return RenderWidth[i]; } + int TextureHeight() const { return mRenderHeight; } + int TextureWidth() const { return mRenderWidth; } int GetAreas(FloatRect **pAreas) const; - int GetWidth(ETexUse i) const + int GetWidth() const { - return Width[i]; + return mWidth; } - int GetHeight(ETexUse i) const + int GetHeight() const { - return Height[i]; + return mHeight; } - int GetLeftOffset(ETexUse i) const + int GetLeftOffset() const { - return LeftOffset[i]; + return mLeftOffset; } - int GetTopOffset(ETexUse i) const + int GetTopOffset() const { - return TopOffset[i]; + return mTopOffset; } - int GetScaledLeftOffset(ETexUse i) const + int GetScaledLeftOffset() const { - return DivScale16(LeftOffset[i], tex->xScale); + return DivScale16(mLeftOffset, tex->xScale); } - int GetScaledTopOffset(ETexUse i) const + int GetScaledTopOffset() const { - return DivScale16(TopOffset[i], tex->yScale); + return DivScale16(mTopOffset, tex->yScale); } - float GetScaledLeftOffsetFloat(ETexUse i) const + float GetScaledLeftOffsetFloat() const { - return LeftOffset[i] / FIXED2FLOAT(tex->xScale); + return mLeftOffset / FIXED2FLOAT(tex->xScale); } - float GetScaledTopOffsetFloat(ETexUse i) const + float GetScaledTopOffsetFloat() const { - return TopOffset[i] / FIXED2FLOAT(tex->yScale); + return mTopOffset/ FIXED2FLOAT(tex->yScale); } // This is scaled size in floating point as needed by sprites - float GetScaledWidthFloat(ETexUse i) const + float GetScaledWidthFloat() const { - return Width[i] / FIXED2FLOAT(tex->xScale); + return mWidth / FIXED2FLOAT(tex->xScale); } - float GetScaledHeightFloat(ETexUse i) const + float GetScaledHeightFloat() const { - return Height[i] / FIXED2FLOAT(tex->yScale); + return mHeight / FIXED2FLOAT(tex->yScale); } // Get right/bottom UV coordinates for patch drawing float GetUL() const { return 0; } float GetVT() const { return 0; } - float GetUR() const { return spriteright; } - float GetVB() const { return spritebottom; } - float GetU(float upix) const { return upix/(float)Width[GLUSE_PATCH] * spriteright; } - float GetV(float vpix) const { return vpix/(float)Height[GLUSE_PATCH] * spritebottom; } + float GetUR() const { return 1; } + float GetVB() const { return 1; } + float GetU(float upix) const { return upix/(float)mWidth; } + float GetV(float vpix) const { return vpix/(float)mHeight; } - float GetSpriteUL() const { return SpriteU[0]; } - float GetSpriteVT() const { return SpriteV[0]; } - float GetSpriteUR() const { return SpriteU[1]; } - float GetSpriteVB() const { return SpriteV[1]; } + float GetSpriteUL() const { return mSpriteU[0]; } + float GetSpriteVT() const { return mSpriteV[0]; } + float GetSpriteUR() const { return mSpriteU[1]; } + float GetSpriteVB() const { return mSpriteV[1]; } @@ -240,8 +251,8 @@ public: static void DeleteAll(); static void FlushAll(); - static FMaterial *ValidateTexture(FTexture * tex); - static FMaterial *ValidateTexture(FTextureID no, bool trans); + static FMaterial *ValidateTexture(FTexture * tex, bool expand); + static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans); }; diff --git a/src/gl/textures/gl_samplers.cpp b/src/gl/textures/gl_samplers.cpp new file mode 100644 index 000000000..1eb54ff10 --- /dev/null +++ b/src/gl/textures/gl_samplers.cpp @@ -0,0 +1,112 @@ +/* +** gl_samplers.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2014 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "templates.h" +#include "c_cvars.h" +#include "c_dispatch.h" + +#include "gl/system/gl_interface.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl_samplers.h" + +extern TexFilter_s TexFilter[]; + + +FSamplerManager::FSamplerManager() +{ + glGenSamplers(6, mSamplers); + SetTextureFilterMode(); + glSamplerParameteri(mSamplers[5], GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glSamplerParameteri(mSamplers[5], GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glSamplerParameterf(mSamplers[5], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + glSamplerParameterf(mSamplers[4], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + glSamplerParameterf(mSamplers[6], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + + glSamplerParameteri(mSamplers[1], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[2], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[3], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[3], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + +} + +FSamplerManager::~FSamplerManager() +{ + UnbindAll(); + glDeleteSamplers(6, mSamplers); +} + +void FSamplerManager::UnbindAll() +{ + for (int i = 0; i < FHardwareTexture::MAX_TEXTURES; i++) + { + mLastBound[i] = 0; + glBindSampler(i, 0); + } +} + +void FSamplerManager::Bind(int texunit, int num) +{ + unsigned int samp = mSamplers[num]; + //if (samp != mLastBound[texunit]) + { + glBindSampler(texunit, samp); + mLastBound[texunit] = samp; + } +} + + +void FSamplerManager::SetTextureFilterMode() +{ + UnbindAll(); + + for (int i = 0; i < 4; i++) + { + glSamplerParameteri(mSamplers[i], GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + glSamplerParameteri(mSamplers[i], GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glSamplerParameterf(mSamplers[i], GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + } + glSamplerParameteri(mSamplers[4], GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + glSamplerParameteri(mSamplers[4], GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glSamplerParameteri(mSamplers[6], GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + glSamplerParameteri(mSamplers[6], GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); +} + + diff --git a/src/gl/textures/gl_samplers.h b/src/gl/textures/gl_samplers.h new file mode 100644 index 000000000..a9802674f --- /dev/null +++ b/src/gl/textures/gl_samplers.h @@ -0,0 +1,28 @@ +#ifndef __GL_SAMPLERS_H +#define __GL_SAMPLERS_H + +#include "gl_hwtexture.h" + +class FSamplerManager +{ + // We need 6 different samplers: 4 for the different clamping modes, + // one for 2D-textures and one for voxel textures + unsigned int mSamplers[6]; + unsigned int mLastBound[FHardwareTexture::MAX_TEXTURES]; + + void UnbindAll(); + +public: + + FSamplerManager(); + ~FSamplerManager(); + + void Bind(int texunit, int num); + void SetTextureFilterMode(); + + +}; + + +#endif + diff --git a/src/gl/textures/gl_skyboxtexture.cpp b/src/gl/textures/gl_skyboxtexture.cpp index 658eb2004..71f5be8f4 100644 --- a/src/gl/textures/gl_skyboxtexture.cpp +++ b/src/gl/textures/gl_skyboxtexture.cpp @@ -132,9 +132,15 @@ void FSkyBox::Unload () // //----------------------------------------------------------------------------- -void FSkyBox::PrecacheGL() +void FSkyBox::PrecacheGL(int cache) { - //for(int i=0;i<6;i++) if (faces[i]) faces[i]->PrecacheGL(); + for (int i = 0; i < 6; i++) + { + if (faces[i]) + { + faces[i]->PrecacheGL(cache); + } + } } //----------------------------------------------------------------------------- diff --git a/src/gl/textures/gl_skyboxtexture.h b/src/gl/textures/gl_skyboxtexture.h index a85e14190..ce58308a1 100644 --- a/src/gl/textures/gl_skyboxtexture.h +++ b/src/gl/textures/gl_skyboxtexture.h @@ -21,7 +21,7 @@ public: int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf); bool UseBasePalette(); void Unload (); - void PrecacheGL(); + void PrecacheGL(int cache); void SetSize() { diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index a864c7e3e..5725f831c 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -52,6 +52,7 @@ #include "gl/renderer/gl_renderer.h" #include "gl/textures/gl_texture.h" #include "gl/textures/gl_material.h" +#include "gl/textures/gl_samplers.h" //========================================================================== // @@ -60,7 +61,7 @@ //========================================================================== CUSTOM_CVAR(Float,gl_texture_filter_anisotropic,8.0f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) { - if (GLRenderer != NULL) GLRenderer->FlushTextures(); + if (GLRenderer != NULL && GLRenderer->mSamplerManager != NULL) GLRenderer->mSamplerManager->SetTextureFilterMode(); } CCMD(gl_flush) @@ -71,7 +72,7 @@ CCMD(gl_flush) CUSTOM_CVAR(Int, gl_texture_filter, 4, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) { if (self < 0 || self > 5) self=4; - if (GLRenderer != NULL) GLRenderer->FlushTextures(); + if (GLRenderer != NULL && GLRenderer->mSamplerManager != NULL) GLRenderer->mSamplerManager->SetTextureFilterMode(); } CUSTOM_CVAR(Int, gl_texture_format, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) @@ -235,37 +236,34 @@ FTexture::MiscGLInfo::MiscGLInfo() throw() bBrightmapDisablesFullbright = false; bNoFilter = false; bNoCompress = false; - mExpanded = false; areas = NULL; areacount = 0; mIsTransparent = -1; shaderspeed = 1.f; shaderindex = 0; + precacheTime = 0; - Material = NULL; - SystemTexture = NULL; + Material[1] = Material[0] = NULL; + SystemTexture[1] = SystemTexture[0] = NULL; Brightmap = NULL; - DecalTexture = NULL; } FTexture::MiscGLInfo::~MiscGLInfo() { - if (Material != NULL) delete Material; - Material = NULL; + for (int i = 0; i < 2; i++) + { + if (Material[i] != NULL) delete Material[i]; + Material[i] = NULL; - if (SystemTexture != NULL) delete SystemTexture; - SystemTexture = NULL; + if (SystemTexture[i] != NULL) delete SystemTexture[i]; + SystemTexture[i] = NULL; + } - // this is managed by the texture manager so it may not be deleted here. - //if (Brightmap != NULL) delete Brightmap; + // this is just a reference to another texture in the texture manager. Brightmap = NULL; if (areas != NULL) delete [] areas; areas = NULL; - - if (DecalTexture != NULL) delete DecalTexture; - DecalTexture = NULL; - } //=========================================================================== @@ -319,12 +317,21 @@ void FTexture::CreateDefaultBrightmap() // //========================================================================== -void FTexture::PrecacheGL() +void FTexture::PrecacheGL(int cache) { if (gl_precache) { - FMaterial * gltex = FMaterial::ValidateTexture(this); - if (gltex) gltex->Precache(); + if (cache & 2) + { + FMaterial * gltex = FMaterial::ValidateTexture(this, false); + if (gltex) gltex->Precache(); + } + if (cache & 4) + { + FMaterial * gltex = FMaterial::ValidateTexture(this, true); + if (gltex) gltex->Precache(); + } + gl_info.precacheTime = TexMan.precacheTime; } } @@ -336,7 +343,12 @@ void FTexture::PrecacheGL() void FTexture::UncacheGL() { - if (gl_info.Material) gl_info.Material->Clean(true); + if (gl_info.precacheTime != TexMan.precacheTime) + { + if (gl_info.Material[0]) gl_info.Material[0]->Clean(true); + if (gl_info.Material[1]) gl_info.Material[1]->Clean(true); + gl_info.precacheTime = 0; + } } //========================================================================== @@ -640,49 +652,6 @@ int FBrightmapTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotat } -//=========================================================================== -// -// A cloned texture. This is needed by the decal code which needs to assign -// a different texture type to some of its graphics. -// -//=========================================================================== - -FCloneTexture::FCloneTexture (FTexture *source, int usetype) -{ - Name = ""; - SourcePic = source; - CopySize(source); - bNoDecals = source->bNoDecals; - Rotations = source->Rotations; - UseType = usetype; - gl_info.bBrightmap = false; - id.SetInvalid(); - SourceLump = -1; -} - -FCloneTexture::~FCloneTexture () -{ -} - -const BYTE *FCloneTexture::GetColumn (unsigned int column, const Span **spans_out) -{ - return NULL; -} - -const BYTE *FCloneTexture::GetPixels () -{ - return NULL; -} - -void FCloneTexture::Unload () -{ -} - -int FCloneTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) -{ - return SourcePic->CopyTrueColorPixels(bmp, x, y, rotate, inf); -} - //========================================================================== // // Parses a brightmap definition @@ -829,3 +798,42 @@ void gl_ParseDetailTexture(FScanner &sc) } } + +//========================================================================== +// +// Prints some texture info +// +//========================================================================== + +CCMD(textureinfo) +{ + int cntt = 0; + for (int i = 0; i < TexMan.NumTextures(); i++) + { + FTexture *tex = TexMan.ByIndex(i); + if (tex->gl_info.SystemTexture[0] || tex->gl_info.SystemTexture[1] || tex->gl_info.Material[0] || tex->gl_info.Material[1]) + { + int lump = tex->GetSourceLump(); + Printf(PRINT_LOG, "Texture '%s' (Index %d, Lump %d, Name '%s'):\n", tex->Name, i, lump, Wads.GetLumpFullName(lump)); + if (tex->gl_info.Material[0]) + { + Printf(PRINT_LOG, "in use (normal)\n"); + } + else if (tex->gl_info.SystemTexture[0]) + { + Printf(PRINT_LOG, "referenced (normal)\n"); + } + if (tex->gl_info.Material[1]) + { + Printf(PRINT_LOG, "in use (expanded)\n"); + } + else if (tex->gl_info.SystemTexture[1]) + { + Printf(PRINT_LOG, "referenced (normal)\n"); + } + cntt++; + } + } + Printf(PRINT_LOG, "%d system textures\n", cntt); +} + diff --git a/src/gl/textures/gl_texture.h b/src/gl/textures/gl_texture.h index afb812ff0..a70ccebc5 100644 --- a/src/gl/textures/gl_texture.h +++ b/src/gl/textures/gl_texture.h @@ -56,23 +56,6 @@ protected: //Span **Spans; }; -class FCloneTexture : public FTexture -{ -public: - FCloneTexture (FTexture *source, int usetype); - ~FCloneTexture (); - - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); - void Unload (); - - int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf); - bool UseBasePalette() { return false; } - -protected: - FTexture *SourcePic; -}; - void gl_GenerateGlobalBrightmapFromColormap(); PalEntry averageColor(const DWORD *data, int size, fixed_t maxout); diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index b8256bc65..b4df6a045 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -1239,6 +1239,8 @@ void FTextureManager::PrecacheLevel (void) if (demoplayback) return; + precacheTime = I_MSTime(); + hitlist = new BYTE[cnt]; memset (hitlist, 0, cnt); diff --git a/src/textures/textures.h b/src/textures/textures.h index ff0e22c0c..df2707401 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -329,10 +329,9 @@ public: struct MiscGLInfo { - FMaterial *Material; - FGLTexture *SystemTexture; + FMaterial *Material[2]; + FGLTexture *SystemTexture[2]; FTexture *Brightmap; - FTexture *DecalTexture; // This is needed for decals of UseType TEX_MiscPatch- PalEntry GlowColor; PalEntry FloorSkyColor; PalEntry CeilingSkyColor; @@ -340,6 +339,7 @@ public: FloatRect *areas; int areacount; int shaderindex; + unsigned int precacheTime; float shaderspeed; int mIsTransparent:2; bool bGlowing:1; // Texture glows @@ -351,14 +351,13 @@ public: bool bBrightmapDisablesFullbright:1; // This disables fullbright display bool bNoFilter:1; bool bNoCompress:1; - bool mExpanded:1; MiscGLInfo() throw (); ~MiscGLInfo(); }; MiscGLInfo gl_info; - virtual void PrecacheGL(); + virtual void PrecacheGL(int cache); virtual void UncacheGL(); void GetGlowColor(float *data); PalEntry GetSkyCapColor(bool bottom); @@ -479,6 +478,8 @@ public: FSwitchDef *FindSwitch (FTextureID texture); FDoorAnimation *FindAnimatedDoor (FTextureID picnum); + unsigned int precacheTime; + private: // texture counting diff --git a/src/v_video.cpp b/src/v_video.cpp index fa94cd49f..c6994d974 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1245,7 +1245,7 @@ void DFrameBuffer::GetHitlist(BYTE *hitlist) FTextureID pic = frame->Texture[k]; if (pic.isValid()) { - hitlist[pic.GetIndex()] = 1; + hitlist[pic.GetIndex()] = 5; } } } @@ -1264,7 +1264,7 @@ void DFrameBuffer::GetHitlist(BYTE *hitlist) { hitlist[sides[i].GetTexture(side_t::top).GetIndex()] = hitlist[sides[i].GetTexture(side_t::mid).GetIndex()] = - hitlist[sides[i].GetTexture(side_t::bottom).GetIndex()] |= 1; + hitlist[sides[i].GetTexture(side_t::bottom).GetIndex()] |= 3; } // Sky texture is always present. @@ -1276,11 +1276,11 @@ void DFrameBuffer::GetHitlist(BYTE *hitlist) if (sky1texture.isValid()) { - hitlist[sky1texture.GetIndex()] |= 1; + hitlist[sky1texture.GetIndex()] |= 3; } if (sky2texture.isValid()) { - hitlist[sky2texture.GetIndex()] |= 1; + hitlist[sky2texture.GetIndex()] |= 3; } } From bf6079af4693bb1e486da4620c4629d9bee730ae Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 23 Aug 2014 00:47:05 +0200 Subject: [PATCH 0205/1509] - fixed incorrect check for overrideshader. --- src/gl/textures/gl_material.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 443560c7f..d29f75ddb 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -614,7 +614,7 @@ outl: void FMaterial::Bind(int clampmode, int translation, int overrideshader, bool alphatexture) { int usebright = false; - int shaderindex = overrideshader > 0? overrideshader : mShaderIndex; + int shaderindex = overrideshader >= 0? overrideshader : mShaderIndex; int maxbound = 0; bool allowhires = tex->xScale == FRACUNIT && tex->yScale == FRACUNIT && clampmode <= CLAMP_XY && !mExpanded; @@ -624,7 +624,7 @@ void FMaterial::Bind(int clampmode, int translation, int overrideshader, bool al else if (tex->bWarped && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE; const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, alphatexture, allowhires? tex:NULL); - if (gltexture != NULL && shaderindex > 0 && overrideshader == 0) + if (gltexture != NULL && shaderindex > 0 && overrideshader == -1) { for(unsigned i=0;i Date: Sat, 23 Aug 2014 18:54:24 +0200 Subject: [PATCH 0206/1509] - some code cleanup. --- src/gl/renderer/gl_renderer.cpp | 5 - src/gl/renderer/gl_renderer.h | 2 - src/gl/scene/gl_bsp.cpp | 59 ++------ src/gl/system/gl_cvars.h | 1 - src/gl/system/gl_threads.h | 247 -------------------------------- 5 files changed, 9 insertions(+), 305 deletions(-) delete mode 100644 src/gl/system/gl_threads.h diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index ec0680bbc..ea48d6486 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -52,7 +52,6 @@ #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" -#include "gl/system/gl_threads.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" @@ -76,8 +75,6 @@ // //=========================================================================== -EXTERN_CVAR(Bool, gl_render_segs) - //----------------------------------------------------------------------------- // // Initialize @@ -117,14 +114,12 @@ void FGLRenderer::Initialize() SetupLevel(); mShaderManager = new FShaderManager; mSamplerManager = new FSamplerManager; - //mThreadManager = new FGLThreadManager; } FGLRenderer::~FGLRenderer() { gl_DeleteAllAttachedLights(); FMaterial::FlushAll(); - //if (mThreadManager != NULL) delete mThreadManager; if (mShaderManager != NULL) delete mShaderManager; if (mSamplerManager != NULL) delete mSamplerManager; if (mVBO != NULL) delete mVBO; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index aee400def..90f2c4a46 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -16,7 +16,6 @@ struct FDrawInfo; struct pspdef_t; class FShaderManager; class GLPortal; -class FGLThreadManager; class FLightBuffer; class FSamplerManager; @@ -58,7 +57,6 @@ public: AActor *mViewActor; FShaderManager *mShaderManager; FSamplerManager *mSamplerManager; - FGLThreadManager *mThreadManager; int gl_spriteindex; unsigned int mFBID; diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index 5bdb99b88..4de31bd61 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -186,20 +186,9 @@ static void AddLine (seg_t *seg) { SetupWall.Clock(); - //if (!gl_multithreading) - { - GLWall wall; - wall.sub = currentsubsector; - wall.Process(seg, currentsector, backsector); - } - /* - else - { - FJob *job = new FGLJobProcessWall(currentsubsector, seg, - currentsector->sectornum, backsector != NULL? backsector->sectornum : -1); - GLRenderer->mThreadManager->AddJob(job); - } - */ + GLWall wall; + wall.sub = currentsubsector; + wall.Process(seg, currentsector, backsector); rendered_lines++; SetupWall.Unclock(); @@ -341,21 +330,11 @@ static inline void RenderThings(subsector_t * sub, sector_t * sector) sector_t * sec=sub->sector; if (sec->thinglist != NULL) { - //if (!gl_multithreading) + // Handle all things in sector. + for (AActor * thing = sec->thinglist; thing; thing = thing->snext) { - // Handle all things in sector. - for (AActor * thing = sec->thinglist; thing; thing = thing->snext) - { - GLRenderer->ProcessSprite(thing, sector); - } + GLRenderer->ProcessSprite(thing, sector); } - /* - else if (sec->thinglist != NULL) - { - FJob *job = new FGLJobProcessSprites(sector); - GLRenderer->mThreadManager->AddJob(job); - } - */ } SetupSprite.Unclock(); } @@ -416,20 +395,10 @@ static void DoSubsector(subsector_t * sub) { SetupSprite.Clock(); - //if (!gl_multithreading) + for (i = ParticlesInSubsec[DWORD(sub-subsectors)]; i != NO_PARTICLE; i = Particles[i].snext) { - for (i = ParticlesInSubsec[DWORD(sub-subsectors)]; i != NO_PARTICLE; i = Particles[i].snext) - { - GLRenderer->ProcessParticle(&Particles[i], fakesector); - } + GLRenderer->ProcessParticle(&Particles[i], fakesector); } - /* - else if (ParticlesInSubsec[DWORD(sub-subsectors)] != NO_PARTICLE) - { - FJob job = new FGLJobProcessParticles(sub); - GLRenderer->mThreadManager->AddJob(job); - } - */ SetupSprite.Unclock(); } @@ -476,17 +445,7 @@ static void DoSubsector(subsector_t * sub) srf |= SSRF_PROCESSED; SetupFlat.Clock(); - //if (!gl_multithreading) - { - GLRenderer->ProcessSector(fakesector); - } - /* - else - { - FJob *job = new FGLJobProcessFlats(sub); - GLRenderer->mThreadManager->AddJob(job); - } - */ + GLRenderer->ProcessSector(fakesector); SetupFlat.Unclock(); } // mark subsector as processed - but mark for rendering only if it has an actual area. diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index 567d9f85f..cedeec06a 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -36,7 +36,6 @@ EXTERN_CVAR(Bool,gl_mirror_envmap) EXTERN_CVAR(Bool,gl_mirrors) EXTERN_CVAR(Bool,gl_mirror_envmap) -EXTERN_CVAR(Bool, gl_render_segs) EXTERN_CVAR(Bool, gl_seamless) EXTERN_CVAR(Float, gl_mask_threshold) diff --git a/src/gl/system/gl_threads.h b/src/gl/system/gl_threads.h deleted file mode 100644 index 68919776c..000000000 --- a/src/gl/system/gl_threads.h +++ /dev/null @@ -1,247 +0,0 @@ -#if 0 //ndef __GL_THREADS_H -#define __GL_THREADS_H - -#ifdef WIN32 -#include -#endif - -#include "critsec.h" - -// system specific Base classes - should be externalized to a separate header later. -#ifdef WIN32 -class FEvent -{ - HANDLE mEvent; - -public: - - FEvent(bool manual = true, bool initial = false) - { - mEvent = CreateEvent(NULL, manual, initial, NULL); - } - - ~FEvent() - { - CloseHandle(mEvent); - } - - void Set() - { - SetEvent(mEvent); - } - - void Reset() - { - ResetEvent(mEvent); - } -}; - -class FThread -{ -protected: - uintptr_t hThread; - bool mTerminateRequest; -public: - - FThread(int stacksize) - { - hThread = _beginthreadex(NULL, stacksize, StaticRun, this, 0, NULL); - } - - virtual ~FThread() - { - CloseHandle((HANDLE)hThread); - } - - void SignalTerminate() - { - mTerminateRequest = true; - } - - virtual void Run() = 0; - -private: - static unsigned __stdcall StaticRun(void *param) - { - FThread *thread = (FThread*)param; - thread->Run(); - return 0; - } - -}; - -#else -class FEvent -{ -public: - - FEvent(bool manual = true, bool initial = false) - { - } - - ~FEvent() - { - } - - void Set() - { - } - - void Reset() - { - } -}; - -class FThread -{ -protected: - bool mTerminateRequest; -public: - - FThread(int stacksize) - { - } - - virtual ~FThread() - { - } - - void SignalTerminate() - { - mTerminateRequest = true; - } - - virtual void Run() = 0; -}; - -#endif - - - -enum -{ - CS_ValidateTexture, - CS_Hacks, - CS_Drawlist, - CS_Portals, - - MAX_GL_CRITICAL_SECTIONS -}; - -class FJob -{ - friend class FJobQueue; - FJob *pNext; - FJob *pPrev; - -public: - FJob() { pNext = pPrev = NULL; } - virtual ~FJob(); - virtual void Run() = 0; -}; - -class FJobQueue -{ - FCriticalSection mCritSec; // for limiting access - FEvent mEvent; // signals that the queue is emoty or not - FJob *pFirst; - FJob *pLast; - -public: - FJobQueue(); - ~FJobQueue(); - - void AddJob(FJob *job); - FJob *GetJob(); -}; - -class FJobThread : public FThread -{ - FJobQueue *mQueue; - -public: - FJobThread(FJobQueue *queue); - ~FJobThread(); - void Run(); -}; - -class FGLJobProcessWall : public FJob -{ - seg_t *mSeg; - subsector_t *mSub; - int mFrontsector, mBacksector; -public: - FGLJobProcessWall(seg_t *seg, subsector_t *sub, int frontsector, int backsector) - { - mSeg = seg; - mSub = sub; - mFrontsector = frontsector; - mBacksector = backsector; - } - - void Run(); -}; - -class FGLJobProcessSprites : public FJob -{ - sector_t *mSector; -public: - FGLJobProcessSprites(sector_t *sector); - void Run(); -}; - -class FGLJobProcessParticles : public FJob -{ - subsector_t *mSubsector; -public: - FGLJobProcessParticles(subsector_t *subsector); - void Run(); -}; - -class FGLJobProcessFlats : public FJob -{ - subsector_t *mSubsector; -public: - FGLJobProcessFlats(subsector_t *subsector); - void Run(); -}; - - -class FGLThreadManager -{ -#if 0 - FCriticalSection mCritSecs[MAX_GL_CRITICAL_SECTIONS]; - FJobQueue mJobs; - FJobThread *mThreads[2]; - -public: - FGLThreadManager() {} - ~FGLThreadManager() {} - - void StartJobs(); - - void PauseJobs(); - - void EnterCS(int index) - { - mCritSecs[index].Enter(); - } - - void LeaveCS(int index) - { - mCritSecs[index].Leave(); - } - - void AddJob(FJob *job) - { - mJobs.AddJob(job); - } - - FJob *GetJob() - { - return mJobs.GetJob(); - } -#endif -}; - -#endif \ No newline at end of file From bf03d022280a82f27bf947b5854a8f4edbf2d741 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 24 Aug 2014 01:09:44 +0200 Subject: [PATCH 0207/1509] - print OpenGL profile type in startup log. --- src/gl/system/gl_interface.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 7a745110b..95ab2e289 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -149,16 +149,18 @@ void gl_LoadExtensions() void gl_PrintStartupLog() { + int v; + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &v); + Printf ("GL_VENDOR: %s\n", glGetString(GL_VENDOR)); Printf ("GL_RENDERER: %s\n", glGetString(GL_RENDERER)); - Printf ("GL_VERSION: %s\n", glGetString(GL_VERSION)); + Printf ("GL_VERSION: %s (%s profile)\n", glGetString(GL_VERSION), (v & GL_CONTEXT_CORE_PROFILE_BIT)? "Core" : "Compatibility"); Printf ("GL_SHADING_LANGUAGE_VERSION: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); Printf ("GL_EXTENSIONS:"); for (unsigned i = 0; i < m_Extensions.Size(); i++) { Printf(" %s", m_Extensions[i].GetChars()); } - int v; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &v); Printf("\nMax. texture size: %d\n", v); From a903cbe12e9122ba0b325321cc2ad8e241da73ac Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 24 Aug 2014 13:10:45 +0200 Subject: [PATCH 0208/1509] - sorting draw items by light level no longer makes sense so remove all corresponding code from dicmp. --- src/gl/scene/gl_drawinfo.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 2cda1e396..050860a48 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -794,7 +794,6 @@ static int __cdecl dicmp (const void *a, const void *b) { const GLDrawItem * di[2]; FMaterial * tx[2]; - int lights[2]; int clamp[2]; //colormap_t cm[2]; di[0]=(const GLDrawItem *)a; @@ -808,7 +807,6 @@ static int __cdecl dicmp (const void *a, const void *b) { GLFlat * f=&sortinfo->flats[di[i]->index]; tx[i]=f->gltexture; - lights[i]=f->lightlevel; clamp[i] = 0; } break; @@ -817,7 +815,6 @@ static int __cdecl dicmp (const void *a, const void *b) { GLWall * w=&sortinfo->walls[di[i]->index]; tx[i]=w->gltexture; - lights[i]=w->lightlevel; clamp[i] = w->flags & 3; } break; @@ -826,16 +823,14 @@ static int __cdecl dicmp (const void *a, const void *b) { GLSprite * s=&sortinfo->sprites[di[i]->index]; tx[i]=s->gltexture; - lights[i]=s->lightlevel; - clamp[i] = 4; + clamp[i] = 3; } break; case GLDIT_POLY: break; } } if (tx[0]!=tx[1]) return tx[0]-tx[1]; - if (clamp[0]!=clamp[1]) return clamp[0]-clamp[1]; // clamping forces different textures. - return lights[0]-lights[1]; + return clamp[0]-clamp[1]; // clamping forces different textures. } From 49ec7beb8f1211cf76191e117f49e63fb70e9b66 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Aug 2014 13:04:41 +0200 Subject: [PATCH 0209/1509] - separate draw lists for walls and flats. This makes the sorting much more efficient because draw types no longer need to be checked in the compare function. This is a lot more important than having perfect texture order. --- src/gl/scene/gl_drawinfo.cpp | 101 ++++++++++++++++++++--------------- src/gl/scene/gl_drawinfo.h | 13 +++-- src/gl/scene/gl_flats.cpp | 2 +- src/gl/scene/gl_scene.cpp | 26 +++++---- src/gl/scene/gl_walls.cpp | 4 +- 5 files changed, 87 insertions(+), 59 deletions(-) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 050860a48..c468b2a7a 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -644,7 +644,6 @@ SortNode * GLDrawList::DoSort(SortNode * head) case GLDIT_SPRITE: SortSpriteIntoPlane(head,node); break; - case GLDIT_POLY: break; } node=next; } @@ -670,7 +669,7 @@ SortNode * GLDrawList::DoSort(SortNode * head) case GLDIT_SPRITE: SortSpriteIntoWall(head,node); break; - case GLDIT_POLY: break; + case GLDIT_FLAT: break; } node=next; @@ -722,7 +721,6 @@ void GLDrawList::DoDraw(int pass, int i, bool trans) RenderSprite.Unclock(); } break; - case GLDIT_POLY: break; } } @@ -783,6 +781,36 @@ void GLDrawList::Draw(int pass) } } +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::DrawWalls(int pass) +{ + RenderWall.Clock(); + for(unsigned i=0;iwalls[di1->index]; - for(int i=0;i<2;i++) - { - switch(di[i]->rendertype) - { - case GLDIT_FLAT: - { - GLFlat * f=&sortinfo->flats[di[i]->index]; - tx[i]=f->gltexture; - clamp[i] = 0; - } - break; + const GLDrawItem * di2 = (const GLDrawItem *)b; + GLWall * w2=&sortinfo->walls[di2->index]; - case GLDIT_WALL: - { - GLWall * w=&sortinfo->walls[di[i]->index]; - tx[i]=w->gltexture; - clamp[i] = w->flags & 3; - } - break; + if (w1->gltexture != w2->gltexture) return w1->gltexture - w2->gltexture; + return ((w1->flags & 3) - (w2->flags & 3)); +} - case GLDIT_SPRITE: - { - GLSprite * s=&sortinfo->sprites[di[i]->index]; - tx[i]=s->gltexture; - clamp[i] = 3; - } - break; - case GLDIT_POLY: break; - } - } - if (tx[0]!=tx[1]) return tx[0]-tx[1]; - return clamp[0]-clamp[1]; // clamping forces different textures. +static int __cdecl difcmp (const void *a, const void *b) +{ + const GLDrawItem * di1 = (const GLDrawItem *)a; + GLFlat * w1=&sortinfo->flats[di1->index]; + + const GLDrawItem * di2 = (const GLDrawItem *)b; + GLFlat* w2=&sortinfo->flats[di2->index]; + + return w1->gltexture - w2->gltexture; } -void GLDrawList::Sort() +void GLDrawList::SortWalls() { if (drawitems.Size()!=0 && gl_sort_textures) { sortinfo=this; - qsort(&drawitems[0], drawitems.Size(), sizeof(drawitems[0]), dicmp); + qsort(&drawitems[0], drawitems.Size(), sizeof(drawitems[0]), diwcmp); + } +} + +void GLDrawList::SortFlats() +{ + if (drawitems.Size()!=0 && gl_sort_textures) + { + sortinfo=this; + qsort(&drawitems[0], drawitems.Size(), sizeof(drawitems[0]), difcmp); } } diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index 9f8b2c383..b0a139108 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -13,9 +13,11 @@ enum GLDrawItemType enum DrawListType { - GLDL_PLAIN, - GLDL_MASKED, - GLDL_MASKEDOFS, + GLDL_PLAINWALLS, + GLDL_PLAINFLATS, + GLDL_MASKEDWALLS, + GLDL_MASKEDFLATS, + GLDL_MASKEDWALLSOFS, GLDL_MODELS, GLDL_TRANSLUCENT, @@ -106,7 +108,8 @@ public: void AddFlat(GLFlat * flat); void AddSprite(GLSprite * sprite); void Reset(); - void Sort(); + void SortWalls(); + void SortFlats(); void MakeSortList(); @@ -125,6 +128,8 @@ public: void DoDrawSorted(SortNode * node); void DrawSorted(); void Draw(int pass); + void DrawWalls(int pass); + void DrawFlats(int pass); GLDrawList * next; } ; diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 0df465caf..0bd4d9eb5 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -402,7 +402,7 @@ inline void GLFlat::PutFlat(bool fog) else { bool masked = gltexture->isMasked() && ((renderflags&SSRF_RENDER3DPLANES) || stack); - list = masked ? GLDL_MASKED : GLDL_PLAIN; + list = masked ? GLDL_MASKEDFLATS : GLDL_PLAINFLATS; } gl_drawinfo->drawlists[list].AddFlat (this); } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index fb4de22ea..89d505168 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -340,18 +340,22 @@ void FGLRenderer::RenderScene(int recursion) gl_RenderState.EnableFog(true); gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); - gl_drawinfo->drawlists[GLDL_PLAIN].Sort(); - gl_drawinfo->drawlists[GLDL_MASKED].Sort(); - gl_drawinfo->drawlists[GLDL_MASKEDOFS].Sort(); + gl_drawinfo->drawlists[GLDL_PLAINWALLS].SortWalls(); + gl_drawinfo->drawlists[GLDL_PLAINFLATS].SortFlats(); + gl_drawinfo->drawlists[GLDL_MASKEDWALLS].SortWalls(); + gl_drawinfo->drawlists[GLDL_MASKEDFLATS].SortFlats(); + gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].SortWalls(); // if we don't have a persistently mapped buffer, we have to process all the dynamic lights up front, // so that we don't have to do repeated map/unmap calls on the buffer. if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && !(gl.flags & RFL_BUFFER_STORAGE)) { GLRenderer->mLights->Begin(); - gl_drawinfo->drawlists[GLDL_PLAIN].Draw(GLPASS_LIGHTSONLY); - gl_drawinfo->drawlists[GLDL_MASKED].Draw(GLPASS_LIGHTSONLY); - gl_drawinfo->drawlists[GLDL_MASKEDOFS].Draw(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_PLAINWALLS].Draw(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_PLAINFLATS].Draw(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_MASKEDWALLS].Draw(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_MASKEDFLATS].Draw(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].Draw(GLPASS_LIGHTSONLY); gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(GLPASS_LIGHTSONLY); gl_drawinfo->drawlists[GLDL_TRANSLUCENT].Draw(GLPASS_LIGHTSONLY); GLRenderer->mLights->Finish(); @@ -375,7 +379,8 @@ void FGLRenderer::RenderScene(int recursion) gl_RenderState.EnableTexture(gl_texture); gl_RenderState.EnableBrightmap(true); - gl_drawinfo->drawlists[GLDL_PLAIN].Draw(pass); + gl_drawinfo->drawlists[GLDL_PLAINWALLS].Draw(pass); + gl_drawinfo->drawlists[GLDL_PLAINFLATS].Draw(pass); // Part 2: masked geometry. This is set up so that only pixels with alpha>gl_mask_threshold will show @@ -385,14 +390,15 @@ void FGLRenderer::RenderScene(int recursion) gl_RenderState.SetTextureMode(TM_MASK); } gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); - gl_drawinfo->drawlists[GLDL_MASKED].Draw(pass); + gl_drawinfo->drawlists[GLDL_MASKEDWALLS].Draw(pass); + gl_drawinfo->drawlists[GLDL_MASKEDFLATS].Draw(pass); // Part 3: masked geometry with polygon offset. This list is empty most of the time so only waste time on it when in use. - if (gl_drawinfo->drawlists[GLDL_MASKEDOFS].Size() > 0) + if (gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].Size() > 0) { glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1.0f, -128.0f); - gl_drawinfo->drawlists[GLDL_MASKEDOFS].Draw(pass); + gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].Draw(pass); glDisable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0, 0); } diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 1a9e30a72..bb160a790 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -151,11 +151,11 @@ void GLWall::PutWall(bool translucent) if ((flags&GLWF_SKYHACK && type == RENDERWALL_M2S)) { - list = GLDL_MASKEDOFS; + list = GLDL_MASKEDWALLSOFS; } else { - list = masked ? GLDL_MASKED : GLDL_PLAIN; + list = masked ? GLDL_MASKEDWALLS : GLDL_PLAINWALLS; } gl_drawinfo->drawlists[list].AddWall(this); From 6a3cd6378a833e15dc0af76d14d1602a34049824 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Aug 2014 14:33:06 +0200 Subject: [PATCH 0210/1509] - found out that reading the CPU's real time clock costs a not insignificant amount of time so this is now only done when either the benchmark command is running or the rendertimes are shown. --- src/gl/scene/gl_scene.cpp | 29 ++++++++++++++--------------- src/gl/utility/gl_clock.cpp | 11 ++++++++++- src/gl/utility/gl_clock.h | 6 ++++-- src/stats.h | 4 ++++ 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 89d505168..f9b713335 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -351,11 +351,11 @@ void FGLRenderer::RenderScene(int recursion) if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && !(gl.flags & RFL_BUFFER_STORAGE)) { GLRenderer->mLights->Begin(); - gl_drawinfo->drawlists[GLDL_PLAINWALLS].Draw(GLPASS_LIGHTSONLY); - gl_drawinfo->drawlists[GLDL_PLAINFLATS].Draw(GLPASS_LIGHTSONLY); - gl_drawinfo->drawlists[GLDL_MASKEDWALLS].Draw(GLPASS_LIGHTSONLY); - gl_drawinfo->drawlists[GLDL_MASKEDFLATS].Draw(GLPASS_LIGHTSONLY); - gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].Draw(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(GLPASS_LIGHTSONLY); gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(GLPASS_LIGHTSONLY); gl_drawinfo->drawlists[GLDL_TRANSLUCENT].Draw(GLPASS_LIGHTSONLY); GLRenderer->mLights->Finish(); @@ -379,8 +379,8 @@ void FGLRenderer::RenderScene(int recursion) gl_RenderState.EnableTexture(gl_texture); gl_RenderState.EnableBrightmap(true); - gl_drawinfo->drawlists[GLDL_PLAINWALLS].Draw(pass); - gl_drawinfo->drawlists[GLDL_PLAINFLATS].Draw(pass); + gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(pass); + gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(pass); // Part 2: masked geometry. This is set up so that only pixels with alpha>gl_mask_threshold will show @@ -390,15 +390,15 @@ void FGLRenderer::RenderScene(int recursion) gl_RenderState.SetTextureMode(TM_MASK); } gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); - gl_drawinfo->drawlists[GLDL_MASKEDWALLS].Draw(pass); - gl_drawinfo->drawlists[GLDL_MASKEDFLATS].Draw(pass); + gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(pass); + gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(pass); // Part 3: masked geometry with polygon offset. This list is empty most of the time so only waste time on it when in use. if (gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].Size() > 0) { glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1.0f, -128.0f); - gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].Draw(pass); + gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(pass); glDisable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0, 0); } @@ -413,10 +413,8 @@ void FGLRenderer::RenderScene(int recursion) glPolygonOffset(-1.0f, -128.0f); glDepthMask(false); - for(int i=0; idrawlists[i].Draw(GLPASS_DECALS); - } + // this is the only geometry type on which decals can possibly appear + gl_drawinfo->drawlists[GLDL_PLAINWALLS].Draw(GLPASS_DECALS); gl_RenderState.SetTextureMode(TM_MODULATE); @@ -439,8 +437,8 @@ void FGLRenderer::RenderScene(int recursion) glPolygonOffset(0.0f, 0.0f); glDisable(GL_POLYGON_OFFSET_FILL); - RenderAll.Unclock(); + } //----------------------------------------------------------------------------- @@ -821,6 +819,7 @@ void FGLRenderer::RenderView (player_t* player) OpenGLFrameBuffer* GLTarget = static_cast(screen); AActor *&LastCamera = GLTarget->LastCamera; + checkBenchActive(); if (player->camera != LastCamera) { // If the camera changed don't interpolate diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp index d8d3c28be..48c21dde2 100644 --- a/src/gl/utility/gl_clock.cpp +++ b/src/gl/utility/gl_clock.cpp @@ -221,4 +221,13 @@ CCMD(bench) switchfps = false; } C_HideConsole (); -} \ No newline at end of file +} + +bool gl_benching = false; + +void checkBenchActive() +{ + FStat *stat = FStat::FindStat("rendertimes"); + gl_benching = ((stat != NULL && stat->isActive()) || printstats); +} + diff --git a/src/gl/utility/gl_clock.h b/src/gl/utility/gl_clock.h index 604a40a02..f12cf1ef9 100644 --- a/src/gl/utility/gl_clock.h +++ b/src/gl/utility/gl_clock.h @@ -9,6 +9,7 @@ extern double gl_SecondsPerCycle; extern double gl_MillisecPerCycle; +extern bool gl_benching; __forceinline long long GetClockCycle () @@ -75,13 +76,13 @@ public: // Not using QueryPerformanceCounter directly, so we don't need // to pull in the Windows headers for every single file that // wants to do some profiling. - long long time = GetClockCycle(); + long long time = (gl_benching? GetClockCycle() : 0); Counter -= time; } __forceinline void Unclock() { - long long time = GetClockCycle(); + long long time = (gl_benching? GetClockCycle() : 0); Counter += time; } @@ -118,6 +119,7 @@ extern int vertexcount, flatvertices, flatprimitives; void ResetProfilingData(); void CheckBench(); +void checkBenchActive(); #endif \ No newline at end of file diff --git a/src/stats.h b/src/stats.h index ed493188b..24ab24cdf 100644 --- a/src/stats.h +++ b/src/stats.h @@ -267,6 +267,10 @@ public: virtual FString GetStats () = 0; void ToggleStat (); + bool isActive() const + { + return m_Active; + } static void PrintStat (); static FStat *FindStat (const char *name); From 12160bd29c7efd09f92aecd4a025fc6f77ed6b85 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Aug 2014 15:34:14 +0200 Subject: [PATCH 0211/1509] - remove some obsolete code from decal rendering. - avoid rebinding the same texture multiple times, as there's considerable overhead in the texture manager. - check gl_sort_textures only once per scene, not per draw list. --- src/gl/scene/gl_decal.cpp | 12 ++++++++---- src/gl/scene/gl_drawinfo.cpp | 19 +++++++++++++++---- src/gl/scene/gl_drawinfo.h | 2 +- src/gl/scene/gl_scene.cpp | 16 ++++++++++------ src/gl/scene/gl_walls_draw.cpp | 12 ------------ src/gl/textures/gl_material.cpp | 18 +++++++++++++++--- wadsrc/static/menudef.z | 1 + 7 files changed, 50 insertions(+), 30 deletions(-) diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index db6d1ad7c..4fc7603cf 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -349,11 +349,15 @@ void GLWall::DrawDecal(DBaseDecal *decal) //========================================================================== void GLWall::DoDrawDecals() { - DBaseDecal *decal = seg->sidedef->AttachedDecals; - while (decal) + if (seg->sidedef && seg->sidedef->AttachedDecals) { - DrawDecal(decal); - decal = decal->WallNext; + gl_SetFog(lightlevel, rellight + getExtraLight(), &Colormap, false); + DBaseDecal *decal = seg->sidedef->AttachedDecals; + while (decal) + { + DrawDecal(decal); + decal = decal->WallNext; + } } } diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index c468b2a7a..3f469d999 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -59,8 +59,6 @@ FDrawInfo * gl_drawinfo; -CVAR(Bool, gl_sort_textures, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) - //========================================================================== // // @@ -811,6 +809,19 @@ void GLDrawList::DrawFlats(int pass) RenderFlat.Unclock(); } +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::DrawDecals() +{ + for(unsigned i=0;i 1) { sortinfo=this; qsort(&drawitems[0], drawitems.Size(), sizeof(drawitems[0]), diwcmp); @@ -853,7 +864,7 @@ void GLDrawList::SortWalls() void GLDrawList::SortFlats() { - if (drawitems.Size()!=0 && gl_sort_textures) + if (drawitems.Size() > 1) { sortinfo=this; qsort(&drawitems[0], drawitems.Size(), sizeof(drawitems[0]), difcmp); diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index b0a139108..67ed2099c 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -32,7 +32,6 @@ enum Drawpasses GLPASS_LIGHTSONLY, // only collect dynamic lights GLPASS_PLAIN, // Main pass without dynamic lights GLPASS_DECALS, // Draws a decal - GLPASS_DECALS_NOFOG,// Draws a decal without setting the fog (used for passes that need a fog layer) GLPASS_TRANSLUCENT, // Draws translucent objects }; @@ -130,6 +129,7 @@ public: void Draw(int pass); void DrawWalls(int pass); void DrawFlats(int pass); + void DrawDecals(); GLDrawList * next; } ; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index f9b713335..f1fdfb812 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -85,6 +85,7 @@ CVAR(Bool, gl_texture, true, 0) CVAR(Bool, gl_no_skyclear, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_sprite_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Bool, gl_sort_textures, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) EXTERN_CVAR (Int, screenblocks) EXTERN_CVAR (Bool, cl_capfps) @@ -340,11 +341,14 @@ void FGLRenderer::RenderScene(int recursion) gl_RenderState.EnableFog(true); gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); - gl_drawinfo->drawlists[GLDL_PLAINWALLS].SortWalls(); - gl_drawinfo->drawlists[GLDL_PLAINFLATS].SortFlats(); - gl_drawinfo->drawlists[GLDL_MASKEDWALLS].SortWalls(); - gl_drawinfo->drawlists[GLDL_MASKEDFLATS].SortFlats(); - gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].SortWalls(); + if (gl_sort_textures) + { + gl_drawinfo->drawlists[GLDL_PLAINWALLS].SortWalls(); + gl_drawinfo->drawlists[GLDL_PLAINFLATS].SortFlats(); + gl_drawinfo->drawlists[GLDL_MASKEDWALLS].SortWalls(); + gl_drawinfo->drawlists[GLDL_MASKEDFLATS].SortFlats(); + gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].SortWalls(); + } // if we don't have a persistently mapped buffer, we have to process all the dynamic lights up front, // so that we don't have to do repeated map/unmap calls on the buffer. @@ -414,7 +418,7 @@ void FGLRenderer::RenderScene(int recursion) glDepthMask(false); // this is the only geometry type on which decals can possibly appear - gl_drawinfo->drawlists[GLDL_PLAINWALLS].Draw(GLPASS_DECALS); + gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawDecals(); gl_RenderState.SetTextureMode(TM_MODULATE); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 5bb81fbe5..bf3e9dbd1 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -395,18 +395,6 @@ void GLWall::Draw(int pass) gl_RenderState.EnableGlow(false); break; - case GLPASS_DECALS: - case GLPASS_DECALS_NOFOG: - if (seg->sidedef && seg->sidedef->AttachedDecals) - { - if (pass==GLPASS_DECALS) - { - gl_SetFog(lightlevel, rellight + getExtraLight(), &Colormap, false); - } - DoDrawDecals(); - } - break; - case GLPASS_TRANSLUCENT: switch (type) { diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index d29f75ddb..503c0b793 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -611,15 +611,27 @@ outl: // //=========================================================================== +static FMaterial *last; +static int lastclamp; +static int lasttrans; +static bool lastalpha; + void FMaterial::Bind(int clampmode, int translation, int overrideshader, bool alphatexture) { - int usebright = false; int shaderindex = overrideshader >= 0? overrideshader : mShaderIndex; + gl_RenderState.SetShader(shaderindex, tex->gl_info.shaderspeed); + + // avoid rebinding the same texture multiple times. + if (this == last && lastclamp == clampmode && translation == lasttrans && lastalpha == alphatexture) return; + last = this; + lastclamp = clampmode; + lastalpha = alphatexture; + lasttrans = translation; + + int usebright = false; int maxbound = 0; bool allowhires = tex->xScale == FRACUNIT && tex->yScale == FRACUNIT && clampmode <= CLAMP_XY && !mExpanded; - gl_RenderState.SetShader(shaderindex, tex->gl_info.shaderspeed); - if (tex->bHasCanvas) clampmode = CLAMP_CAMTEX; else if (tex->bWarped && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index cdfce4145..d3394fc96 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -139,6 +139,7 @@ OptionMenu "GLTextureGLOptions" Option "Precache GL textures", gl_precache, "YesNo" Option "Camera textures offscreen", gl_usefb, "OnOff" Option "Trim sprite edges", gl_trimsprites, "OnOff" + Option "Sort draw lists by texture", gl_sort_textures, "YesNo" } OptionMenu "GLLightOptions" From a280c20b4eb7b378ae8e404d5d80112b47cffc3d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 31 Aug 2014 19:00:17 +0200 Subject: [PATCH 0212/1509] - fixed: If we want to cache texture binding state we have to reset it in all places where a texture becomes unbound. --- src/gl/system/gl_wipe.cpp | 1 + src/gl/textures/gl_hwtexture.cpp | 1 + src/gl/textures/gl_material.cpp | 5 +++++ src/gl/textures/gl_material.h | 1 + 4 files changed, 8 insertions(+) diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 57ad3ba89..53af826bd 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -240,6 +240,7 @@ void OpenGLFrameBuffer::WipeCleanup() delete wipeendscreen; wipeendscreen = NULL; } + FMaterial::ClearLastTexture(); } //========================================================================== diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index d076f6a3e..f491169b4 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -403,6 +403,7 @@ void FHardwareTexture::UnbindAll() { Unbind(texunit); } + FMaterial::ClearLastTexture(); } //=========================================================================== diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 503c0b793..efbbec332 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -753,6 +753,7 @@ void FMaterial::BindToFrameBuffer() // must create the hardware texture first mBaseLayer->Bind(0, 0, 0, false, NULL); FHardwareTexture::Unbind(0); + ClearLastTexture(); } mBaseLayer->mHwTexture->BindToFrameBuffer(); } @@ -809,3 +810,7 @@ void FMaterial::FlushAll() } } +void FMaterial::ClearLastTexture() +{ + last = NULL; +} diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 714ab5a03..dfdbeb743 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -253,6 +253,7 @@ public: static void FlushAll(); static FMaterial *ValidateTexture(FTexture * tex, bool expand); static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans); + static void ClearLastTexture(); }; From fa3a62e954f6f106e598f0721a5e264a0c77221f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 31 Aug 2014 23:01:53 +0200 Subject: [PATCH 0213/1509] - fix a render glitch with Back to Saturn X MAP06: Do not flood missing upper and lower textures with the backsector's flat if that backsector is malformed (i.e. has no area.) --- src/gl/data/gl_setup.cpp | 3 ++- src/gl/scene/gl_walls.cpp | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index fc63cb95b..5e6e0767b 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -233,6 +233,7 @@ static void SpreadHackedFlag(subsector_t * sub) if (!(sub2->hacked&1) && sub2->render_sector == sub->render_sector) { sub2->hacked|=1; + sub->hacked &= ~4; SpreadHackedFlag (sub2); } } @@ -285,7 +286,7 @@ static void PrepareSectorData() subsectors[i].render_sector != seg[j].PartnerSeg->Subsector->render_sector) { DPrintf("Found hack: (%d,%d) (%d,%d)\n", seg[j].v1->x>>16, seg[j].v1->y>>16, seg[j].v2->x>>16, seg[j].v2->y>>16); - subsectors[i].hacked|=1; + subsectors[i].hacked|=5; SpreadHackedFlag(&subsectors[i]); } if (seg[j].PartnerSeg==NULL) subsectors[i].hacked|=2; // used for quick termination checks diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index bb160a790..e86b03d49 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1417,7 +1417,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) sector_t * realback; #ifdef _DEBUG - if (seg->linedef-lines==636) + if (seg->linedef-lines==1276) { int a = 0; } @@ -1635,7 +1635,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) { - gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a); + // skip processing if the back is a malformed subsector + if (!(seg->PartnerSeg->Subsector->hacked & 4)) + { + gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a); + } } } } @@ -1704,7 +1708,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) else if (backsector->GetTexture(sector_t::floor) != skyflatnum && !(seg->sidedef->Flags & WALLF_POLYOBJ)) { - gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1); + // skip processing if the back is a malformed subsector + if (!(seg->PartnerSeg->Subsector->hacked & 4)) + { + gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1); + } } } } From b96dd6c42142fcd1683e5349480ecd0286522c8f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 2 Sep 2014 10:31:48 +0200 Subject: [PATCH 0214/1509] - fixed: The missing fourth component of the texture coordinate must be filled with 1.0, not 0.0 before applying the texture matrix. Not doing so will cancel out the translation part of the matrix. --- src/gl/scene/gl_flats.cpp | 8 ++++---- wadsrc/static/shaders/glsl/main.vp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 0bd4d9eb5..ec442294a 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -70,7 +70,7 @@ // information // //========================================================================== - +static float tics; void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * gltexture) { // only manipulate the texture matrix if needed. @@ -80,8 +80,8 @@ void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * glte gltexture->TextureWidth() != 64 || gltexture->TextureHeight() != 64) { - float uoffs=FIXED2FLOAT(secplane->xoffs)/gltexture->TextureWidth(); - float voffs=FIXED2FLOAT(secplane->yoffs)/gltexture->TextureHeight(); + float uoffs = FIXED2FLOAT(secplane->xoffs) / gltexture->TextureWidth(); + float voffs = FIXED2FLOAT(secplane->yoffs) / gltexture->TextureHeight(); float xscale1=FIXED2FLOAT(secplane->xscale); float yscale1=FIXED2FLOAT(secplane->yscale); @@ -328,7 +328,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG int rel = getExtraLight(); #ifdef _DEBUG - if (sector->sectornum == 2) + if (sector->sectornum == 130) { int a = 0; } diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 16c3c8738..86fad75cc 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -39,7 +39,7 @@ void main() vec2 sst = vec2(r.x/m + 0.5, r.y/m + 0.5); vTexCoord.xy = sst; #else - vTexCoord = TextureMatrix * vec4(aTexCoord, 0.0, 0.0); + vTexCoord = TextureMatrix * vec4(aTexCoord, 0.0, 1.0); #endif gl_Position = ProjectionMatrix * eyeCoordPos; From e29fce6951c70e5c2036e6dfc4ccf0fe38f24f00 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 7 Sep 2014 11:52:51 +0300 Subject: [PATCH 0215/1509] Fixed missing transparency on upscaled textures Textures with diagonal patterns were treated as opaque after resizing Images upscaled by hqNx were affected mostly by this issue http://forum.drdteam.org/viewtopic.php?f=24&t=5370 http://zandronum.com/tracker/view.php?id=269 http://zandronum.com/tracker/view.php?id=315 --- src/gl/textures/gl_texture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 4f6e999f2..d74314e99 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -558,7 +558,7 @@ bool FTexture::SmoothEdges(unsigned char * buffer,int w, int h) l1+=4; for(x=1;x Date: Tue, 9 Sep 2014 01:27:41 +0200 Subject: [PATCH 0216/1509] - add some compatibility settings to fix rendering glitches in BTSX_E1 MAP12. --- src/gl/data/gl_data.cpp | 1 - src/gl/scene/gl_drawinfo.cpp | 3 --- src/gl/scene/gl_renderhacks.cpp | 7 +------ src/gl/scene/gl_walls.cpp | 5 ----- src/gl/textures/gl_material.cpp | 1 - src/p_3dfloors.cpp | 1 + wadsrc/static/compatibility.txt | 14 ++++++++++++++ 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index e0bb5ee6b..385b7409b 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -438,7 +438,6 @@ void gl_RecalcVertexHeights(vertex_t * v) int i,j,k; float height; - //@sync-vertexheights v->numheights=0; for(i=0;inumsectors;i++) { diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 62e604aca..f078c52c9 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -855,7 +855,6 @@ void GLDrawList::Sort() //========================================================================== void GLDrawList::AddWall(GLWall * wall) { - //@sync-drawinfo drawitems.Push(GLDrawItem(GLDIT_WALL,walls.Push(*wall))); } @@ -866,7 +865,6 @@ void GLDrawList::AddWall(GLWall * wall) //========================================================================== void GLDrawList::AddFlat(GLFlat * flat) { - //@sync-drawinfo drawitems.Push(GLDrawItem(GLDIT_FLAT,flats.Push(*flat))); } @@ -877,7 +875,6 @@ void GLDrawList::AddFlat(GLFlat * flat) //========================================================================== void GLDrawList::AddSprite(GLSprite * sprite) { - //@sync-drawinfo drawitems.Push(GLDrawItem(GLDIT_SPRITE,sprites.Push(*sprite))); } diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index a6452a01f..7aba676f5 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -163,7 +163,6 @@ void FDrawInfo::AddUpperMissingTexture(side_t * side, subsector_t *sub, fixed_t return; } - //@sync-hack for(unsigned int i=0;ibacksector->e->XFloor.ffloors.Size() && seg->backsector->e->XFloor.ffloors[0]->flags&FF_FIX) + if (seg->backsector->e->XFloor.ffloors.Size() && (seg->backsector->e->XFloor.ffloors[0]->flags&(FF_FIX|FF_SEETHROUGH)) == FF_FIX) { totalms.Unclock(); return; } - //@sync-hack for(unsigned int i=0;iAddLine(this); break; case RENDERWALL_SECTORSTACK: - //@sync-portal portal = this->portal->GetGLPortal(); portal->AddLine(this); break; @@ -231,7 +228,6 @@ void GLWall::PutWall(bool translucent) break; case RENDERWALL_MIRROR: - //@sync-portal portal=GLPortal::FindPortal(seg->linedef); if (!portal) portal=new GLMirrorPortal(seg->linedef); portal->AddLine(this); @@ -244,7 +240,6 @@ void GLWall::PutWall(bool translucent) break; case RENDERWALL_SKY: - //@sync-portal portal=GLPortal::FindPortal(sky); if (!portal) portal=new GLSkyPortal(sky); portal->AddLine(this); diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 5e9a9be1a..500a0afab 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -1047,7 +1047,6 @@ FMaterial * FMaterial::ValidateTexture(FTexture * tex) FMaterial *gltex = tex->gl_info.Material; if (gltex == NULL) { - //@sync-tex gltex = new FMaterial(tex, false); } return gltex; diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index ce6224b53..67933a75a 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -264,6 +264,7 @@ static int P_Set3DFloor(line_t * line, int param, int param2, int alpha) else if (param==4) { flags=FF_EXISTS|FF_RENDERPLANES|FF_INVERTPLANES|FF_NOSHADE|FF_FIX; + if (param2 & 1) flags |= FF_SEETHROUGH; // marker for allowing missing texture checks alpha=255; } else diff --git a/wadsrc/static/compatibility.txt b/wadsrc/static/compatibility.txt index 1c2307ec0..bf5f3cc3b 100644 --- a/wadsrc/static/compatibility.txt +++ b/wadsrc/static/compatibility.txt @@ -381,3 +381,17 @@ B9DFF13207EACAC675C71D82624D0007 // XtheaterIII map01 { DisablePushWindowCheck } + +712BB4CFBD0753178CA0C6814BE4C288 // map12 BTSX_E1 - patch some rendering glitches that are problematic to detect +{ + setsectortag 545 32000 + setsectortag 1618 32000 + setlinespecial 2853 Sector_Set3DFloor 32000 4 0 0 0 + setsectortag 439 32001 + setsectortag 458 32001 + setlinespecial 2182 Sector_Set3DFloor 32001 4 0 0 0 + setsectortag 454 32002 + setsectortag 910 32002 + setlinespecial 2410 Sector_Set3DFloor 32002 4 1 0 0 +} + From 62880f113be972a97255af4c1e9b2af484278567 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 31 Aug 2014 23:01:53 +0200 Subject: [PATCH 0217/1509] - fix a render glitch with Back to Saturn X MAP06: Do not flood missing upper and lower textures with the backsector's flat if that backsector is malformed (i.e. has no area.) --- src/gl/data/gl_setup.cpp | 3 ++- src/gl/scene/gl_walls.cpp | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index 9603cc858..dae203774 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -234,6 +234,7 @@ static void SpreadHackedFlag(subsector_t * sub) if (!(sub2->hacked&1) && sub2->render_sector == sub->render_sector) { sub2->hacked|=1; + sub->hacked &= ~4; SpreadHackedFlag (sub2); } } @@ -286,7 +287,7 @@ static void PrepareSectorData() subsectors[i].render_sector != seg[j].PartnerSeg->Subsector->render_sector) { DPrintf("Found hack: (%d,%d) (%d,%d)\n", seg[j].v1->x>>16, seg[j].v1->y>>16, seg[j].v2->x>>16, seg[j].v2->y>>16); - subsectors[i].hacked|=1; + subsectors[i].hacked|=5; SpreadHackedFlag(&subsectors[i]); } if (seg[j].PartnerSeg==NULL) subsectors[i].hacked|=2; // used for quick termination checks diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 84e7e5636..24c850112 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1441,7 +1441,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) sector_t * realback; #ifdef _DEBUG - if (seg->linedef-lines==636) + if (seg->linedef-lines==1276) { int a = 0; } @@ -1657,7 +1657,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) { - gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a); + // skip processing if the back is a malformed subsector + if (!(seg->PartnerSeg->Subsector->hacked & 4)) + { + gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a); + } } } } @@ -1726,7 +1730,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) else if (backsector->GetTexture(sector_t::floor)!=skyflatnum && !(seg->sidedef->Flags & WALLF_POLYOBJ)) { - gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1); + // skip processing if the back is a malformed subsector + if (!(seg->PartnerSeg->Subsector->hacked & 4)) + { + gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1); + } } } } From c6f4c0b6f0c54bb27911f198a64a681da537d8c2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 9 Sep 2014 10:03:34 +0200 Subject: [PATCH 0218/1509] - fixed: FMaterial's tex pointer could be accessed before it was set. - allow more than two texture units in shaders. --- src/gl/shaders/gl_shader.cpp | 10 ++++++++-- src/gl/textures/gl_material.cpp | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 26a1b3159..72815f2e2 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -227,8 +227,14 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * glUseProgram(hShader); - tempindex = glGetUniformLocation(hShader, "texture2"); - if (tempindex > 0) glUniform1i(tempindex, 1); + // set up other texture units (if needed by the shader) + for (int i = 2; i<16; i++) + { + char stringbuf[20]; + mysnprintf(stringbuf, 20, "texture%d", i); + tempindex = glGetUniformLocation(hShader, stringbuf); + if (tempindex > 0) glUniform1i(tempindex, i - 1); + } glUseProgram(0); return !!linked; diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 05fcb992b..7995b572b 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -405,6 +405,7 @@ int FMaterial::mMaxBound; FMaterial::FMaterial(FTexture * tx, bool expanded) { mShaderIndex = 0; + tex = tx; // TODO: apply custom shader object here /* if (tx->CustomShaderDefinition) @@ -495,7 +496,6 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) mMaterials.Push(this); tx->gl_info.Material[expanded] = this; if (tx->bHasCanvas) tx->gl_info.mIsTransparent = 0; - tex = tx; mExpanded = expanded; } From d5633701b4587ca38e838f53de18a91bb8845fba Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 9 Sep 2014 10:17:44 +0200 Subject: [PATCH 0219/1509] - swapped order of textures in burn shader to avoid some problems with the texture samplers. - fixed: texture sampler state for the burn texture was never set. --- src/gl/system/gl_wipe.cpp | 5 +++-- wadsrc/static/shaders/glsl/burn.fp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 53af826bd..564dd1e03 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -150,6 +150,7 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) wipestartscreen = new FHardwareTexture(Width, Height, true); wipestartscreen->CreateTexture(NULL, Width, Height, 0, false, 0, false); GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER); + GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE); glFinish(); wipestartscreen->Bind(0, false, false, false); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); @@ -515,9 +516,9 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.Apply(); // Burn the new screen on top of it. - fb->wipeendscreen->Bind(1, 0, false, false); + fb->wipeendscreen->Bind(0, 0, false, false); - BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, 0, false, 0, false); + BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, 1, true, 0, false); GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); gl_RenderState.SetEffect(EFF_NONE); diff --git a/wadsrc/static/shaders/glsl/burn.fp b/wadsrc/static/shaders/glsl/burn.fp index 0cc3f7950..4ab4cac95 100644 --- a/wadsrc/static/shaders/glsl/burn.fp +++ b/wadsrc/static/shaders/glsl/burn.fp @@ -8,8 +8,8 @@ void main() { vec4 frag = vColor; - vec4 t1 = texture2D(texture2, vTexCoord.xy); - vec4 t2 = texture2D(tex, vec2(vTexCoord.x, 1.0-vTexCoord.y)); + vec4 t1 = texture2D(tex, vTexCoord.xy); + vec4 t2 = texture2D(texture2, vec2(vTexCoord.x, 1.0-vTexCoord.y)); FragColor = frag * vec4(t1.r, t1.g, t1.b, t2.a); } From 4bb320a27c461af3e99ad92e75dbf9679148df62 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 9 Sep 2014 12:00:42 +0200 Subject: [PATCH 0220/1509] - route texture binding through the renderstate class for better control. Currently it's just a direct passthrough but this will change. --- src/gl/models/gl_models_md2.cpp | 2 +- src/gl/models/gl_models_md3.cpp | 2 +- src/gl/models/gl_voxels.cpp | 2 +- src/gl/renderer/gl_renderer.cpp | 8 ++++---- src/gl/renderer/gl_renderstate.h | 8 +++++--- src/gl/scene/gl_decal.cpp | 2 +- src/gl/scene/gl_drawinfo.cpp | 2 +- src/gl/scene/gl_flats.cpp | 4 ++-- src/gl/scene/gl_portal.cpp | 2 +- src/gl/scene/gl_scene.cpp | 2 +- src/gl/scene/gl_skydome.cpp | 14 +++++++------- src/gl/scene/gl_sprite.cpp | 2 +- src/gl/scene/gl_walls_draw.cpp | 6 +++--- src/gl/scene/gl_weapon.cpp | 2 +- src/gl/textures/gl_material.cpp | 10 ++++------ src/gl/textures/gl_material.h | 4 +++- 16 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index 76835c737..3d0fad8aa 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -303,7 +303,7 @@ void FDMDModel::RenderFrame(FTexture * skin, int frameno, int frameno2, double i FMaterial * tex = FMaterial::ValidateTexture(skin, false); - tex->Bind(CLAMP_NONE, translation, -1, false); + gl_RenderState.SetMaterial(tex, CLAMP_NONE, translation, -1, false); gl_RenderState.Apply(); GLRenderer->mModelVBO->SetupFrame(frames[frameno].vindex, frames[frameno2].vindex, inter); diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index d3f71af5c..4b1788306 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -267,7 +267,7 @@ void FMD3Model::RenderFrame(FTexture * skin, int frameno, int frameno2, double i FMaterial * tex = FMaterial::ValidateTexture(surfaceSkin, false); - tex->Bind(CLAMP_NONE, translation, -1, false); + gl_RenderState.SetMaterial(tex, CLAMP_NONE, translation, -1, false); gl_RenderState.Apply(); GLRenderer->mModelVBO->SetupFrame(surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices, inter); diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 0ce907aa5..b1bb4de5a 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -417,7 +417,7 @@ int FVoxelModel::FindFrame(const char * name) void FVoxelModel::RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation) { FMaterial * tex = FMaterial::ValidateTexture(skin, false); - tex->Bind(CLAMP_NOFILTER, translation, -1, false); + gl_RenderState.SetMaterial(tex, CLAMP_NOFILTER, translation, -1, false); gl_RenderState.Apply(); GLRenderer->mModelVBO->SetupFrame(vindex, vindex, 0.f); diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index ea48d6486..dbf0c10c8 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -329,7 +329,7 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) } } gl_SetRenderStyle(parms.style, !parms.masked, false); - gltex->Bind(CLAMP_XY_NOMIP, translation, 0, !!(parms.style.Flags & STYLEF_RedIsAlpha)); + gl_RenderState.SetMaterial(gltex, CLAMP_XY_NOMIP, translation, 0, !!(parms.style.Flags & STYLEF_RedIsAlpha)); u1 = gltex->GetUL(); v1 = gltex->GetVT(); @@ -339,7 +339,7 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) } else { - gltex->Bind(CLAMP_XY_NOMIP, 0, -1, false); + gl_RenderState.SetMaterial(gltex, CLAMP_XY_NOMIP, 0, -1, false); u1 = 0.f; v1 = 1.f; u2 = 1.f; @@ -493,7 +493,7 @@ void FGLRenderer::FlatFill (int left, int top, int right, int bottom, FTexture * if (!gltexture) return; - gltexture->Bind(CLAMP_NONE, 0, -1, false); + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); // scaling is not used here. if (!local_origin) @@ -586,7 +586,7 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint gl_SetColor(lightlevel, 0, cm, 1.f); - gltexture->Bind(CLAMP_NONE, 0, -1, false); + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); int i; float rot = float(rotation * M_PI / float(1u << 31)); diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 0e290adb3..236b5d551 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -5,6 +5,7 @@ #include "gl/system/gl_interface.h" #include "gl/data/gl_data.h" #include "gl/data/gl_matrix.h" +#include "gl/textures/gl_material.h" #include "c_cvars.h" #include "r_defs.h" @@ -97,10 +98,11 @@ public: void Reset(); - void SetShader(int shaderindex, float warptime) + void SetMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader, bool alphatexture) { - mEffectState = shaderindex; - mShaderTimer = warptime; + mEffectState = overrideshader >= 0? overrideshader : mat->mShaderIndex; + mShaderTimer = mat->tex->gl_info.shaderspeed; + mat->Bind(clampmode, translation, alphatexture); } void Apply(); diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 4fc7603cf..c938e9043 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -319,7 +319,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) gl_SetRenderStyle(decal->RenderStyle, false, false); - tex->Bind(CLAMP_XY, decal->Translation, 0, !!(decal->RenderStyle.Flags & STYLEF_RedIsAlpha)); + gl_RenderState.SetMaterial(tex, CLAMP_XY, decal->Translation, 0, !!(decal->RenderStyle.Flags & STYLEF_RedIsAlpha)); // If srcalpha is one it looks better with a higher alpha threshold diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 1e6bc1bfe..b92a2c6cf 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -1097,7 +1097,7 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo int rel = getExtraLight(); gl_SetColor(lightlevel, rel, Colormap, 1.0f); gl_SetFog(lightlevel, rel, &Colormap, false); - gltexture->Bind(CLAMP_NONE, 0, -1, false); + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); float fviewx = FIXED2FLOAT(viewx); float fviewy = FIXED2FLOAT(viewy); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index ec442294a..ac185aee9 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -341,7 +341,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG case GLPASS_ALL: gl_SetColor(lightlevel, rel, Colormap,1.0f); gl_SetFog(lightlevel, rel, &Colormap, false); - gltexture->Bind(CLAMP_NONE, 0, -1, false); + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); gl_SetPlaneTextureRotation(&plane, gltexture); DrawSubsectors(pass, (pass == GLPASS_ALL || dynlightindex > -1), false); gl_RenderState.EnableTextureMatrix(false); @@ -367,7 +367,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG } else { - gltexture->Bind(CLAMP_NONE, 0, -1, false); + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); gl_SetPlaneTextureRotation(&plane, gltexture); DrawSubsectors(pass, true, true); gl_RenderState.EnableTextureMatrix(false); diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 5e82dbd7b..02e7747bc 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -1011,7 +1011,7 @@ void GLHorizonPortal::DrawContents() } - gltexture->Bind(CLAMP_NONE, 0, -1, false); + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); gl_SetPlaneTextureRotation(sp, gltexture); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index f1fdfb812..b095d261b 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -1119,7 +1119,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in if (!usefb) { glFlush(); - gltex->Bind(0, 0, -1, false); + gl_RenderState.SetMaterial(gltex, 0, 0, -1, false); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, bounds.width, bounds.height); } else diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index b12ada3fc..a6ee502d5 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -268,7 +268,7 @@ void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, in if (tex) { - tex->Bind(CLAMP_NONE, 0, -1, false); + gl_RenderState.SetMaterial(tex, CLAMP_NONE, 0, -1, false); texw = tex->TextureWidth(); texh = tex->TextureHeight(); gl_RenderState.EnableModelMatrix(true); @@ -333,7 +333,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool // north tex = FMaterial::ValidateTexture(sb->faces[0], false); - tex->Bind(CLAMP_XY, 0, -1, false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); ptr = GLRenderer->mVBO->GetBuffer(); @@ -349,7 +349,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool // east tex = FMaterial::ValidateTexture(sb->faces[1], false); - tex->Bind(CLAMP_XY, 0, -1, false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); ptr = GLRenderer->mVBO->GetBuffer(); @@ -365,7 +365,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool // south tex = FMaterial::ValidateTexture(sb->faces[2], false); - tex->Bind(CLAMP_XY, 0, -1, false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); ptr = GLRenderer->mVBO->GetBuffer(); @@ -381,7 +381,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool // west tex = FMaterial::ValidateTexture(sb->faces[3], false); - tex->Bind(CLAMP_XY, 0, -1, false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); ptr = GLRenderer->mVBO->GetBuffer(); @@ -425,7 +425,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool // top tex = FMaterial::ValidateTexture(sb->faces[faces], false); - tex->Bind(CLAMP_XY, 0, -1, false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); ptr = GLRenderer->mVBO->GetBuffer(); @@ -441,7 +441,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool // bottom tex = FMaterial::ValidateTexture(sb->faces[faces+1], false); - tex->Bind(CLAMP_XY, 0, -1, false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); ptr = GLRenderer->mVBO->GetBuffer(); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 502264e20..5d8995a34 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -214,7 +214,7 @@ void GLSprite::Draw(int pass) gl_RenderState.SetFog(0, 0); } - if (gltexture) gltexture->Bind(CLAMP_XY, translation, OverrideShader, !!(RenderStyle.Flags & STYLEF_RedIsAlpha)); + if (gltexture) gl_RenderState.SetMaterial(gltexture, CLAMP_XY, translation, OverrideShader, !!(RenderStyle.Flags & STYLEF_RedIsAlpha)); else if (!modelframe) gl_RenderState.EnableTexture(false); if (!modelframe) diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index bf3e9dbd1..bad0aa5d1 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -274,7 +274,7 @@ void GLWall::RenderMirrorSurface() glDepthFunc(GL_LEQUAL); FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrortexture, false); - pat->Bind(CLAMP_NONE, 0, -1, false); + gl_RenderState.SetMaterial(pat, CLAMP_NONE, 0, -1, false); flags &= ~GLWF_GLOW; RenderWall(RWF_BLANK); @@ -326,7 +326,7 @@ void GLWall::RenderTranslucentWall() if (gltexture) { gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); - gltexture->Bind(flags & 3, 0, -1, false); + gl_RenderState.SetMaterial(gltexture, flags & 3, 0, -1, false); extra = getExtraLight(); } else @@ -390,7 +390,7 @@ void GLWall::Draw(int pass) else gl_SetFog(255, 0, NULL, false); gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); - gltexture->Bind(flags & 3, false, -1, false); + gl_RenderState.SetMaterial(gltexture, flags & 3, false, -1, false); RenderWall(RWF_TEXTURED|RWF_GLOW); gl_RenderState.EnableGlow(false); break; diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 67e2f9576..d64c0a39a 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -96,7 +96,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed FMaterial * tex = FMaterial::ValidateTexture(lump, true, false); if (!tex) return; - tex->Bind(CLAMP_XY_NOMIP, 0, OverrideShader, alphatexture); + gl_RenderState.SetMaterial(tex, CLAMP_XY_NOMIP, 0, OverrideShader, alphatexture); int vw = viewwidth; int vh = viewheight; diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 7995b572b..063f948c0 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -616,11 +616,9 @@ static int lastclamp; static int lasttrans; static bool lastalpha; -void FMaterial::Bind(int clampmode, int translation, int overrideshader, bool alphatexture) -{ - int shaderindex = overrideshader >= 0? overrideshader : mShaderIndex; - gl_RenderState.SetShader(shaderindex, tex->gl_info.shaderspeed); +void FMaterial::Bind(int clampmode, int translation, bool alphatexture) +{ // avoid rebinding the same texture multiple times. if (this == last && lastclamp == clampmode && translation == lasttrans && lastalpha == alphatexture) return; last = this; @@ -636,7 +634,7 @@ void FMaterial::Bind(int clampmode, int translation, int overrideshader, bool al else if (tex->bWarped && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE; const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, alphatexture, allowhires? tex:NULL); - if (gltexture != NULL && shaderindex > 0 && overrideshader == -1) + if (gltexture != NULL) { for(unsigned i=0;i Date: Tue, 9 Sep 2014 13:21:36 +0200 Subject: [PATCH 0221/1509] - changed the handling of alpha textures. The only special case they need is with palette-less textures and this can be handled far more easily and robustly with a predefined translation instead of passing another parameter through all the layers of the texture management code. This also fixes problems with paletted PNGs that get used as an alpha texture because the old method clobbered the image's palette. --- src/gl/renderer/gl_lightdata.cpp | 6 +++++- src/gl/renderer/gl_renderstate.h | 10 ++++++++- src/gl/system/gl_interface.h | 7 ++++--- src/gl/system/gl_wipe.cpp | 22 ++++++++++---------- src/gl/textures/gl_bitmap.cpp | 19 ++++------------- src/gl/textures/gl_bitmap.h | 11 +--------- src/gl/textures/gl_hwtexture.cpp | 17 +++------------ src/gl/textures/gl_hwtexture.h | 10 ++------- src/gl/textures/gl_material.cpp | 33 +++++++++++++----------------- src/gl/textures/gl_material.h | 14 ++++++------- src/r_data/r_translate.cpp | 9 ++++++++ wadsrc/static/shaders/glsl/main.fp | 10 ++++++--- 12 files changed, 75 insertions(+), 93 deletions(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 29013f280..a02762eb8 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -142,7 +142,11 @@ void gl_GetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblend int blendequation = renderops[style.BlendOp&15]; int texturemode = drawopaque? TM_OPAQUE : TM_MODULATE; - if (style.Flags & STYLEF_ColorIsFixed) + if (style.Flags & STYLEF_RedIsAlpha) + { + texturemode = TM_REDTOALPHA; + } + else if (style.Flags & STYLEF_ColorIsFixed) { texturemode = TM_MASK; } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 236b5d551..e0f5406dd 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -8,6 +8,7 @@ #include "gl/textures/gl_material.h" #include "c_cvars.h" #include "r_defs.h" +#include "r_data/r_translate.h" class FVertexBuffer; class FShader; @@ -100,9 +101,16 @@ public: void SetMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader, bool alphatexture) { + // textures without their own palette are a special case for use as an alpha texture: + // They use the color index directly as an alpha value instead of using the palette's red. + // To handle this case, we need to set a special translation for such textures. + if (alphatexture) + { + if (mat->tex->UseBasePalette()) translation = TRANSLATION(TRANSLATION_Standard, 8); + } mEffectState = overrideshader >= 0? overrideshader : mat->mShaderIndex; mShaderTimer = mat->tex->gl_info.shaderspeed; - mat->Bind(clampmode, translation, alphatexture); + mat->Bind(clampmode, translation); } void Apply(); diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index af4c4f7c2..2d2e26d51 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -16,9 +16,10 @@ enum RenderFlags enum TexMode { TM_MODULATE = 0, // (r, g, b, a) - TM_MASK = 1, // (1, 1, 1, a) - TM_OPAQUE = 2, // (r, g, b, 1) - TM_INVERSE = 3, // (1-r, 1-g, 1-b, a) + TM_MASK, // (1, 1, 1, a) + TM_OPAQUE, // (r, g, b, 1) + TM_INVERSE, // (1-r, 1-g, 1-b, a) + TM_REDTOALPHA, // (1, 1, 1, r) }; struct RenderContext diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 564dd1e03..30a996816 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -148,11 +148,11 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) } wipestartscreen = new FHardwareTexture(Width, Height, true); - wipestartscreen->CreateTexture(NULL, Width, Height, 0, false, 0, false); + wipestartscreen->CreateTexture(NULL, Width, Height, 0, false, 0); GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER); GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE); glFinish(); - wipestartscreen->Bind(0, false, false, false); + wipestartscreen->Bind(0, false, false); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); @@ -171,10 +171,10 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) void OpenGLFrameBuffer::WipeEndScreen() { wipeendscreen = new FHardwareTexture(Width, Height, true); - wipeendscreen->CreateTexture(NULL, Width, Height, 0, false, 0, false); + wipeendscreen->CreateTexture(NULL, Width, Height, 0, false, 0); GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER); glFinish(); - wipeendscreen->Bind(0, false, false, false); + wipeendscreen->Bind(0, false, false); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -286,7 +286,7 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.ResetColor(); gl_RenderState.Apply(); - fb->wipestartscreen->Bind(0, 0, false, false); + fb->wipestartscreen->Bind(0, 0, false); FFlatVertex *ptr; unsigned int offset, count; @@ -301,7 +301,7 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) ptr++; GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); - fb->wipeendscreen->Bind(0, 0, false, false); + fb->wipeendscreen->Bind(0, 0, false); gl_RenderState.SetColorAlpha(0xffffff, clamp(Clock/32.f, 0.f, 1.f)); gl_RenderState.Apply(); GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); @@ -348,7 +348,7 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.SetTextureMode(TM_OPAQUE); gl_RenderState.ResetColor(); gl_RenderState.Apply(); - fb->wipeendscreen->Bind(0, 0, false, false); + fb->wipeendscreen->Bind(0, 0, false); FFlatVertex *ptr; ptr = GLRenderer->mVBO->GetBuffer(); ptr->Set(0, 0, 0, 0, vb); @@ -364,7 +364,7 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) int i, dy; bool done = false; - fb->wipestartscreen->Bind(0, 0, false, false); + fb->wipestartscreen->Bind(0, 0, false); // Copy the old screen in vertical strips on top of the new one. while (ticks--) { @@ -496,7 +496,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.ResetColor(); gl_RenderState.Apply(); - fb->wipestartscreen->Bind(0, 0, false, false); + fb->wipestartscreen->Bind(0, 0, false); FFlatVertex *ptr; unsigned int offset, count; ptr = GLRenderer->mVBO->GetBuffer(); @@ -516,9 +516,9 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.Apply(); // Burn the new screen on top of it. - fb->wipeendscreen->Bind(0, 0, false, false); + fb->wipeendscreen->Bind(0, 0, false); - BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, 1, true, 0, false); + BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, 1, true, 0); GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); gl_RenderState.SetEffect(EFF_NONE); diff --git a/src/gl/textures/gl_bitmap.cpp b/src/gl/textures/gl_bitmap.cpp index 0c74c9ae7..a2319f67c 100644 --- a/src/gl/textures/gl_bitmap.cpp +++ b/src/gl/textures/gl_bitmap.cpp @@ -51,7 +51,7 @@ // //=========================================================================== template -void iCopyColors(unsigned char * pout, const unsigned char * pin, bool alphatex, int count, int step) +void iCopyColors(unsigned char * pout, const unsigned char * pin, int count, int step) { int i; @@ -69,7 +69,7 @@ void iCopyColors(unsigned char * pout, const unsigned char * pin, bool alphatex, } } -typedef void (*CopyFunc)(unsigned char * pout, const unsigned char * pin, bool alphatex, int count, int step); +typedef void (*CopyFunc)(unsigned char * pout, const unsigned char * pin, int count, int step); static CopyFunc copyfuncs[]={ iCopyColors, @@ -99,7 +99,7 @@ void FGLBitmap::CopyPixelDataRGB(int originx, int originy, BYTE *buffer = GetPixels() + 4*originx + Pitch*originy; for (int y=0;y 0) + if (translation > 0) { PalEntry *ptrans = GLTranslationPalette::GetPalette(translation); if (ptrans) diff --git a/src/gl/textures/gl_bitmap.h b/src/gl/textures/gl_bitmap.h index 98addb51d..6aea6d008 100644 --- a/src/gl/textures/gl_bitmap.h +++ b/src/gl/textures/gl_bitmap.h @@ -7,34 +7,25 @@ class FGLBitmap : public FBitmap { - bool alphatex; int translation; public: FGLBitmap() { - alphatex = false; translation = 0; } FGLBitmap(BYTE *buffer, int pitch, int width, int height) : FBitmap(buffer, pitch, width, height) { - alphatex = false; translation = 0; } void SetTranslationInfo(int _trans) { - if (_trans == -1) alphatex = true; - else if (_trans != -1337) translation = _trans; + if (_trans != -1337) translation = _trans; } - void SetAlphaTex() - { - alphatex = true; - } - virtual void CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int srcwidth, int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf = NULL); virtual void CopyPixelData(int originx, int originy, const BYTE * patch, int srcwidth, int srcheight, diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index f491169b4..c855ef285 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -184,18 +184,13 @@ void FHardwareTexture::Resize(int width, int height, unsigned char *src_data, un // //=========================================================================== -unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, bool alphatexture) +unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation) { int rh,rw; int texformat=TexFormat[gl_texture_format]; bool deletebuffer=false; - if (alphatexture) - { - texformat = GL_R8; - translation = TRANS_Alpha; - } - else if (forcenocompression) + if (forcenocompression) { texformat = GL_RGBA8; } @@ -245,11 +240,6 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int glTex->mipmapped = true; } - if (alphatexture) - { - static const GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_RED}; - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); - } if (texunit != 0) glActiveTexture(GL_TEXTURE0); return glTex->glTexID; } @@ -362,9 +352,8 @@ FHardwareTexture::TranslatedTexture *FHardwareTexture::GetTexID(int translation) // Binds this patch // //=========================================================================== -unsigned int FHardwareTexture::Bind(int texunit, int translation, bool alphatexture, bool needmipmap) +unsigned int FHardwareTexture::Bind(int texunit, int translation, bool needmipmap) { - if (alphatexture) translation = TRANS_Alpha; TranslatedTexture *pTex = GetTexID(translation); if (pTex->glTexID != 0) diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h index eabc7a6ef..7fa0f0580 100644 --- a/src/gl/textures/gl_hwtexture.h +++ b/src/gl/textures/gl_hwtexture.h @@ -20,11 +20,6 @@ enum EInvalid Invalid = 0 }; -enum ETranslation -{ - TRANS_Alpha = INT_MAX -}; - enum { GLT_CLAMPX=1, @@ -66,7 +61,6 @@ private: TArray glTex_Translated; unsigned int glDepthID; // only used by camera textures - void LoadImage(unsigned char * buffer,int w, int h, TranslatedTexture *glTex, bool mipmap, bool alphatexture, int texunit); TranslatedTexture * GetTexID(int translation); int GetDepthBuffer(); @@ -81,8 +75,8 @@ public: void BindToFrameBuffer(); - unsigned int Bind(int texunit, int translation, bool alphatexture, bool needmipmap); - unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, bool alphatexture); + unsigned int Bind(int texunit, int translation, bool needmipmap); + unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation); void Clean(bool all); }; diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 063f948c0..6b22e0a5e 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -109,7 +109,7 @@ FGLTexture::~FGLTexture() // Checks for the presence of a hires texture replacement and loads it // //========================================================================== -unsigned char *FGLTexture::LoadHiresTexture(FTexture *tex, int *width, int *height, bool alphatexture) +unsigned char *FGLTexture::LoadHiresTexture(FTexture *tex, int *width, int *height) { if (HiresLump==-1) { @@ -131,8 +131,6 @@ unsigned char *FGLTexture::LoadHiresTexture(FTexture *tex, int *width, int *heig memset(buffer, 0, w * (h+1) * 4); FGLBitmap bmp(buffer, w*4, w, h); - if (alphatexture) bmp.SetAlphaTex(); - int trans = hirestexture->CopyTrueColorPixels(&bmp, 0, 0); hirestexture->CheckTrans(buffer, w*h, trans); @@ -181,7 +179,7 @@ void FGLTexture::Clean(bool all) // //=========================================================================== -unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool alphatexture) +unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck) { unsigned char * buffer; int W, H; @@ -191,7 +189,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F // by hires textures if (gl_texture_usehires && hirescheck != NULL) { - buffer = LoadHiresTexture (hirescheck, &w, &h, alphatexture); + buffer = LoadHiresTexture (hirescheck, &w, &h); if (buffer) { return buffer; @@ -207,7 +205,6 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F FGLBitmap bmp(buffer, W*4, W, H); bmp.SetTranslationInfo(translation); - if (alphatexture) bmp.SetAlphaTex(); if (tex->bComplex) { @@ -241,7 +238,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F // [BB] The hqnx upsampling (not the scaleN one) destroys partial transparency, don't upsamle textures using it. // [BB] Potentially upsample the buffer. - return gl_CreateUpsampledTextureBuffer ( tex, buffer, W, H, w, h, bIsTransparent || alphatexture); + return gl_CreateUpsampledTextureBuffer ( tex, buffer, W, H, w, h, !!bIsTransparent); } @@ -267,7 +264,7 @@ FHardwareTexture *FGLTexture::CreateHwTexture() // //=========================================================================== -const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int translation, bool alphatexture, FTexture *hirescheck) +const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int translation, FTexture *hirescheck) { int usebright = false; @@ -288,7 +285,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla } // Bind it to the system. - if (!hwtex->Bind(texunit, translation, alphatexture, needmipmap)) + if (!hwtex->Bind(texunit, translation, needmipmap)) { int w=0, h=0; @@ -298,10 +295,10 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla if (!tex->bHasCanvas) { - buffer = CreateTexBuffer(translation, w, h, hirescheck, alphatexture); + buffer = CreateTexBuffer(translation, w, h, hirescheck); tex->ProcessData(buffer, w, h, false); } - if (!hwtex->CreateTexture(buffer, w, h, texunit, needmipmap, translation, alphatexture)) + if (!hwtex->CreateTexture(buffer, w, h, texunit, needmipmap, translation)) { // could not create texture delete[] buffer; @@ -614,16 +611,14 @@ outl: static FMaterial *last; static int lastclamp; static int lasttrans; -static bool lastalpha; -void FMaterial::Bind(int clampmode, int translation, bool alphatexture) +void FMaterial::Bind(int clampmode, int translation) { // avoid rebinding the same texture multiple times. - if (this == last && lastclamp == clampmode && translation == lasttrans && lastalpha == alphatexture) return; + if (this == last && lastclamp == clampmode && translation == lasttrans) return; last = this; lastclamp = clampmode; - lastalpha = alphatexture; lasttrans = translation; int usebright = false; @@ -633,7 +628,7 @@ void FMaterial::Bind(int clampmode, int translation, bool alphatexture) if (tex->bHasCanvas) clampmode = CLAMP_CAMTEX; else if (tex->bWarped && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE; - const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, alphatexture, allowhires? tex:NULL); + const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, allowhires? tex:NULL); if (gltexture != NULL) { for(unsigned i=0;igl_info.SystemTexture[mExpanded]->Bind(i+1, clampmode, 0, false, NULL); + layer->gl_info.SystemTexture[mExpanded]->Bind(i+1, clampmode, 0, NULL); maxbound = i+1; } } @@ -669,7 +664,7 @@ void FMaterial::Bind(int clampmode, int translation, bool alphatexture) //=========================================================================== void FMaterial::Precache() { - Bind(0, 0, false); + Bind(0, 0); } //=========================================================================== @@ -749,7 +744,7 @@ void FMaterial::BindToFrameBuffer() if (mBaseLayer->mHwTexture == NULL) { // must create the hardware texture first - mBaseLayer->Bind(0, 0, 0, false, NULL); + mBaseLayer->Bind(0, 0, 0, NULL); FHardwareTexture::Unbind(0); ClearLastTexture(); } diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 6d3015a52..b5f055d24 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -67,18 +67,17 @@ private: bool bHasColorkey; // only for hires bool bExpand; - unsigned char * LoadHiresTexture(FTexture *hirescheck, int *width, int *height, bool alphatexture); + unsigned char * LoadHiresTexture(FTexture *hirescheck, int *width, int *height); FHardwareTexture *CreateHwTexture(); - const FHardwareTexture *Bind(int texunit, int clamp, int translation, bool alphatexture, FTexture *hirescheck); - const FHardwareTexture *BindPatch(int texunit, int translation, bool alphatexture); - + const FHardwareTexture *Bind(int texunit, int clamp, int translation, FTexture *hirescheck); + public: FGLTexture(FTexture * tx, bool expandpatches); ~FGLTexture(); - unsigned char * CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool alphatexture); + unsigned char * CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck); void Clean(bool all); int Dump(int i); @@ -138,12 +137,11 @@ public: return mTextureLayers.Size() + 1; } - //void Bind(int clamp = 0, int translation = 0, int overrideshader = 0, bool alphatexture = false); - void Bind(int clamp, int translation, bool alphatexture); + void Bind(int clamp, int translation); unsigned char * CreateTexBuffer(int translation, int & w, int & h, bool allowhires=true) const { - return mBaseLayer->CreateTexBuffer(translation, w, h, allowhires? tex:NULL, 0); + return mBaseLayer->CreateTexBuffer(translation, w, h, allowhires? tex : NULL); } void Clean(bool f) diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index d11388e6e..8d867f25f 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -824,6 +824,15 @@ void R_InitTranslationTables () remap->Remap[i] = IcePaletteRemap[v]; remap->Palette[i] = PalEntry(255, IcePalette[v][0], IcePalette[v][1], IcePalette[v][2]); } + + // The alphatexture translation. Since alphatextures use the red channel this is just a standard grayscale mapping. + PushIdentityTable(TRANSLATION_Standard); + remap = translationtables[TRANSLATION_Standard][8]; + for (i = 0; i < 256; i++) + { + remap->Remap[i] = i; + remap->Palette[i] = PalEntry(255, i, i, i); + } } //---------------------------------------------------------------------------- diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 532529f0b..c77a058c2 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -60,17 +60,21 @@ vec4 getTexel(vec2 st) // switch (uTextureMode) { - case 1: + case 1: // TM_MASK texel.rgb = vec3(1.0,1.0,1.0); break; - case 2: + case 2: // TM_OPAQUE texel.a = 1.0; break; - case 3: + case 3: // TM_INVERSE texel = vec4(1.0-texel.r, 1.0-texel.b, 1.0-texel.g, texel.a); break; + + case 4: // TM_REDTOALPHA + texel = vec4(1.0, 1.0, 1.0, texel.r); + break; } texel *= uObjectColor; From 25951362fc3522cf1d9224215a56b81587763a6e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 11 Sep 2014 13:02:39 +0200 Subject: [PATCH 0222/1509] - fixed: When applying Boom's Transfer_Heights effect to a sector, gl_FakeFlat needs to remove all portals from the original sector planes that are being replaced in the sector copy. --- src/gl/scene/gl_fakeflat.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gl/scene/gl_fakeflat.cpp b/src/gl/scene/gl_fakeflat.cpp index d46449ddb..86408272a 100644 --- a/src/gl/scene/gl_fakeflat.cpp +++ b/src/gl/scene/gl_fakeflat.cpp @@ -311,6 +311,9 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::vbo_fakefloor]; dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::floor]; + + dest->portals[sector_t::ceiling] = NULL; + if (!(s->MoreFlags & SECF_NOFAKELIGHT)) { dest->lightlevel = s->lightlevel; @@ -347,12 +350,12 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac } } } - else if (in_area==area_above) + else if (in_area == area_above) { - dest->ColorMap=s->ColorMap; + dest->ColorMap = s->ColorMap; dest->SetPlaneTexZ(sector_t::ceiling, sec->GetPlaneTexZ(sector_t::ceiling)); dest->SetPlaneTexZ(sector_t::floor, s->GetPlaneTexZ(sector_t::ceiling)); - dest->ceilingplane= sec->ceilingplane; + dest->ceilingplane = sec->ceilingplane; dest->floorplane = s->ceilingplane; dest->floorplane.FlipVert(); @@ -362,6 +365,8 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::ceiling]; dest->vboheight[sector_t::ceiling] = sec->vboheight[sector_t::ceiling]; + dest->portals[sector_t::floor] = NULL; + if (!(s->MoreFlags & SECF_NOFAKELIGHT)) { dest->lightlevel = s->lightlevel; From ddf58b43c984384ff4284c8a63b9a9eeb3770c0a Mon Sep 17 00:00:00 2001 From: Ralgor Date: Sun, 14 Sep 2014 14:28:05 -0500 Subject: [PATCH 0223/1509] Fix compile errors on linux. --- src/gl/textures/gl_texture.cpp | 2 +- src/gl/utility/gl_clock.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index b737ced77..838510bcd 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -814,7 +814,7 @@ CCMD(textureinfo) if (tex->gl_info.SystemTexture[0] || tex->gl_info.SystemTexture[1] || tex->gl_info.Material[0] || tex->gl_info.Material[1]) { int lump = tex->GetSourceLump(); - Printf(PRINT_LOG, "Texture '%s' (Index %d, Lump %d, Name '%s'):\n", tex->Name, i, lump, Wads.GetLumpFullName(lump)); + Printf(PRINT_LOG, "Texture '%s' (Index %d, Lump %d, Name '%s'):\n", (const char*)(tex->Name), i, lump, Wads.GetLumpFullName(lump)); if (tex->gl_info.Material[0]) { Printf(PRINT_LOG, "in use (normal)\n"); diff --git a/src/gl/utility/gl_clock.h b/src/gl/utility/gl_clock.h index f12cf1ef9..46a01d1e4 100644 --- a/src/gl/utility/gl_clock.h +++ b/src/gl/utility/gl_clock.h @@ -5,12 +5,12 @@ #include "x86.h" #include "m_fixed.h" +extern bool gl_benching; + #ifdef _MSC_VER extern double gl_SecondsPerCycle; extern double gl_MillisecPerCycle; -extern bool gl_benching; - __forceinline long long GetClockCycle () { From 1a70a6aabcb6079a08222507515f3be3515e95e7 Mon Sep 17 00:00:00 2001 From: Ralgor Date: Sun, 14 Sep 2014 14:29:13 -0500 Subject: [PATCH 0224/1509] The light buffer should check for shader_storage_buffer_object rather than buffer_storage. --- src/gl/dynlights/gl_lightbuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index 3031d3916..e8d2520da 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -54,7 +54,7 @@ FLightBuffer::FLightBuffer() mBufferSize = INITIAL_BUFFER_SIZE; mByteSize = mBufferSize * sizeof(float); - if (gl.flags & RFL_BUFFER_STORAGE) + if (gl.flags & RFL_SHADER_STORAGE_BUFFER) { mBufferType = GL_SHADER_STORAGE_BUFFER; mBlockAlign = -1; From cfc8f3dbbf7ed1938d2fb70a0d6c7d4718a89e93 Mon Sep 17 00:00:00 2001 From: Ralgor Date: Sun, 14 Sep 2014 14:42:14 -0500 Subject: [PATCH 0225/1509] Global GL render context shouldn't be initialized inside of gl_PrintStartupLog, since it's not compiled in non MSC builds. --- src/gl/system/gl_framebuffer.cpp | 9 +++++++++ src/gl/system/gl_interface.cpp | 3 --- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 54df9b851..2ddbf3439 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -126,6 +126,15 @@ void OpenGLFrameBuffer::InitializeState() gl_LoadExtensions(); Super::InitializeState(); + + int v; + glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); + gl.maxuniforms = v; + glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); + gl.maxuniformblock = v; + glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v); + gl.uniformblockalignment = v; + if (first) { first=false; diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 95ab2e289..af03bf1d1 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -168,15 +168,12 @@ void gl_PrintStartupLog() Printf ("Max. texture units: %d\n", v); glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); Printf ("Max. fragment uniforms: %d\n", v); - gl.maxuniforms = v; glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &v); Printf ("Max. vertex uniforms: %d\n", v); glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); Printf ("Max. uniform block size: %d\n", v); - gl.maxuniformblock = v; glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v); Printf ("Uniform block alignment: %d\n", v); - gl.uniformblockalignment = v; glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); Printf ("Max. varying: %d\n", v); From 5cc43137a12fa5868729b7c5616422401a6ec9bf Mon Sep 17 00:00:00 2001 From: Ralgor Date: Sun, 14 Sep 2014 14:43:42 -0500 Subject: [PATCH 0226/1509] Only require OpenGL 3.0 compatibility profile. --- src/gl/shaders/gl_shader.cpp | 2 +- src/gl/system/gl_interface.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 72815f2e2..3d4afdbcc 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -94,7 +94,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * if (lightbuffertype == GL_UNIFORM_BUFFER) { - vp_comb.Format("#version 330 core\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); + vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); } else { diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index af03bf1d1..5d4e8efeb 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -117,9 +117,9 @@ void gl_LoadExtensions() else Printf("Emulating OpenGL v %s\n", version); // Don't even start if it's lower than 3.0 - if (strcmp(version, "3.3") < 0) + if (strcmp(version, "3.0") < 0) { - I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 3.3 is required to run " GAMENAME ".\n"); + I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 3.0 is required to run " GAMENAME ".\n"); } // add 0.01 to account for roundoff errors making the number a tad smaller than the actual version From 32f08adaf366a30d9bd091139211fc72555c11b3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 14 Sep 2014 23:01:57 +0200 Subject: [PATCH 0227/1509] - moved some code to better places. - allow GL version 3.0 in Windows, too. --- src/gl/system/gl_framebuffer.cpp | 8 -------- src/gl/system/gl_interface.cpp | 8 ++++++++ src/gl/textures/gl_texture.cpp | 2 +- src/win32/win32gliface.cpp | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 2ddbf3439..d9f05bea6 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -127,14 +127,6 @@ void OpenGLFrameBuffer::InitializeState() gl_LoadExtensions(); Super::InitializeState(); - int v; - glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); - gl.maxuniforms = v; - glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); - gl.maxuniformblock = v; - glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v); - gl.uniformblockalignment = v; - if (first) { first=false; diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 5d4e8efeb..be0beaf4e 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -137,6 +137,14 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; } + int v; + glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); + gl.maxuniforms = v; + glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); + gl.maxuniformblock = v; + glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v); + gl.uniformblockalignment = v; + glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 838510bcd..53a07d437 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -814,7 +814,7 @@ CCMD(textureinfo) if (tex->gl_info.SystemTexture[0] || tex->gl_info.SystemTexture[1] || tex->gl_info.Material[0] || tex->gl_info.Material[1]) { int lump = tex->GetSourceLump(); - Printf(PRINT_LOG, "Texture '%s' (Index %d, Lump %d, Name '%s'):\n", (const char*)(tex->Name), i, lump, Wads.GetLumpFullName(lump)); + Printf(PRINT_LOG, "Texture '%s' (Index %d, Lump %d, Name '%s'):\n", tex->Name.GetChars(), i, lump, Wads.GetLumpFullName(lump)); if (tex->gl_info.Material[0]) { Printf(PRINT_LOG, "in use (normal)\n"); diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 81b1d9418..59ce1e65e 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -775,8 +775,8 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) if (myWglCreateContextAttribsARB != NULL) { // let's try to get the best version possible. Some drivers only give us the version we request - // which breaks all version checks for feature support. The highest used features we use are from version 4.4, and 3.3 is a requirement. - static int versions[] = { 45, 44, 43, 42, 41, 40, 33, -1 }; + // which breaks all version checks for feature support. The highest used features we use are from version 4.4, and 3.0 is a requirement. + static int versions[] = { 45, 44, 43, 42, 41, 40, 33, 32, 31, 30, -1 }; for (int i = 0; versions[i] > 0; i++) { From 8e7e16f73a8f14945d8e4aacf28aa4c359eb2676 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 15 Sep 2014 10:27:09 +0200 Subject: [PATCH 0228/1509] - fixed: The light uniform buffer may not be mapped with GL_MAP_INVALIDATE_BUFFER_BIT, because it needs to be mapped for each portal in a scene but it must preserve the existing data for the remaining translucent objects. --- src/gl/dynlights/gl_lightbuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index e8d2520da..7e96c43ce 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -190,7 +190,7 @@ void FLightBuffer::Begin() if (!(gl.flags & RFL_BUFFER_STORAGE)) { glBindBuffer(mBufferType, mBufferId); - mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_BUFFER_BIT); + mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT); } } From a25ed3c80768fc2c85bdb7cc2d5781080ab62f40 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 15 Sep 2014 12:15:19 +0200 Subject: [PATCH 0229/1509] - fixed: inverted rendering for fuzzy things with light powerup was switched off due to change of render style. --- src/gl/scene/gl_sprite.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 5d8995a34..833bc2f4e 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -808,7 +808,9 @@ void GLSprite::Process(AActor* thing,sector_t * sector) { // enhanced vision makes them more visible! trans=0.5f; + FRenderStyle rs = RenderStyle; RenderStyle = STYLE_Translucent; + RenderStyle.Flags = rs.Flags; // Flags must be preserved, at this point it can only be STYLEF_InvertSource } else if (thing->flags & MF_STEALTH) { From c773a500f29eecaf167ef768d33ed2b6df5c89c1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 17 Sep 2014 09:01:16 +0200 Subject: [PATCH 0230/1509] - only activate shader storage buffers on modern drivers also supporting GL_ARB_buffer storage. Early adopters of this extension (i.e. older AMD drivers mainly) tend to implement this badly. --- src/gl/system/gl_interface.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index be0beaf4e..4541cfb18 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -133,8 +133,16 @@ void gl_LoadExtensions() if (!Args->CheckParm("-gl3")) { // don't use GL 4.x features when running in GL 3 emulation mode. - if (CheckExtension("GL_ARB_shader_storage_buffer_object")) gl.flags |= RFL_SHADER_STORAGE_BUFFER; - if (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; + if (CheckExtension("GL_ARB_buffer_storage")) + { + // work around a problem with older AMD drivers: Their implementation of shader storage buffer objects is piss-poor and does not match uniform buffers even closely. + // Recent drivers, GL 4.4 don't have this problem, these can easily be recognized by also supporting the GL_ARB_buffer_storage extension. + if (CheckExtension("GL_ARB_shader_storage_buffer_object")) + { + gl.flags |= RFL_SHADER_STORAGE_BUFFER; + } + gl.flags |= RFL_BUFFER_STORAGE; + } } int v; From c5e00dbc533a30e9d14948dbeaae7e5e3d0b4308 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 17 Sep 2014 10:52:34 +0200 Subject: [PATCH 0231/1509] fixed: The sampler object for camera textures was never initialized. --- src/gl/textures/gl_samplers.cpp | 4 ++-- src/gl/textures/gl_samplers.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/textures/gl_samplers.cpp b/src/gl/textures/gl_samplers.cpp index 1eb54ff10..3851d6c71 100644 --- a/src/gl/textures/gl_samplers.cpp +++ b/src/gl/textures/gl_samplers.cpp @@ -50,7 +50,7 @@ extern TexFilter_s TexFilter[]; FSamplerManager::FSamplerManager() { - glGenSamplers(6, mSamplers); + glGenSamplers(7, mSamplers); SetTextureFilterMode(); glSamplerParameteri(mSamplers[5], GL_TEXTURE_MIN_FILTER, GL_NEAREST); glSamplerParameteri(mSamplers[5], GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -70,7 +70,7 @@ FSamplerManager::FSamplerManager() FSamplerManager::~FSamplerManager() { UnbindAll(); - glDeleteSamplers(6, mSamplers); + glDeleteSamplers(7, mSamplers); } void FSamplerManager::UnbindAll() diff --git a/src/gl/textures/gl_samplers.h b/src/gl/textures/gl_samplers.h index a9802674f..26589b4ad 100644 --- a/src/gl/textures/gl_samplers.h +++ b/src/gl/textures/gl_samplers.h @@ -7,7 +7,7 @@ class FSamplerManager { // We need 6 different samplers: 4 for the different clamping modes, // one for 2D-textures and one for voxel textures - unsigned int mSamplers[6]; + unsigned int mSamplers[7]; unsigned int mLastBound[FHardwareTexture::MAX_TEXTURES]; void UnbindAll(); From 92dcf2e5efff356143483fe7db81bdef8a1613ff Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 17 Sep 2014 11:03:05 +0200 Subject: [PATCH 0232/1509] - fixed some of those supremely annoying and supremely pointless GCC/Clang compiler warnings. --- src/gl/data/gl_vertexbuffer.h | 4 ++-- src/gl/dynlights/gl_lightbuffer.cpp | 14 +++++++------- src/gl/scene/gl_drawinfo.h | 1 - 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index b6d61f2da..84967a9ee 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -51,8 +51,8 @@ class FFlatVertexBuffer : public FVertexBuffer void CheckPlanes(sector_t *sector); - const unsigned int BUFFER_SIZE = 2000000; - const unsigned int BUFFER_SIZE_TO_USE = 1999500; + static const unsigned int BUFFER_SIZE = 2000000; + static const unsigned int BUFFER_SIZE_TO_USE = 1999500; void ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count); diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index 7e96c43ce..1e0ec7e5a 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -57,7 +57,7 @@ FLightBuffer::FLightBuffer() if (gl.flags & RFL_SHADER_STORAGE_BUFFER) { mBufferType = GL_SHADER_STORAGE_BUFFER; - mBlockAlign = -1; + mBlockAlign = 0; mBlockSize = mBufferSize; } else @@ -100,12 +100,12 @@ void FLightBuffer::Clear() int FLightBuffer::UploadLights(FDynLightData &data) { - int size0 = data.arrays[0].Size()/4; - int size1 = data.arrays[1].Size()/4; - int size2 = data.arrays[2].Size()/4; - int totalsize = size0 + size1 + size2 + 1; + unsigned int size0 = data.arrays[0].Size()/4; + unsigned int size1 = data.arrays[1].Size()/4; + unsigned int size2 = data.arrays[2].Size()/4; + unsigned int totalsize = size0 + size1 + size2 + 1; - if (mBlockAlign >= 0 && totalsize + (mIndex % mBlockAlign) > mBlockSize) + if (mBlockAlign > 0 && totalsize + (mIndex % mBlockAlign) > mBlockSize) { mIndex = ((mIndex + mBlockAlign) / mBlockAlign) * mBlockAlign; @@ -172,7 +172,7 @@ int FLightBuffer::UploadLights(FDynLightData &data) if (mBufferPointer == NULL) return -1; copyptr = mBufferPointer + mIndex * 4; - float parmcnt[] = { 0, size0, size0 + size1, size0 + size1 + size2 }; + float parmcnt[] = { 0, float(size0), float(size0 + size1), float(size0 + size1 + size2) }; memcpy(©ptr[0], parmcnt, 4 * sizeof(float)); memcpy(©ptr[4], &data.arrays[0][0], 4 * size0*sizeof(float)); diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index 67ed2099c..4e86073d8 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -8,7 +8,6 @@ enum GLDrawItemType GLDIT_WALL, GLDIT_FLAT, GLDIT_SPRITE, - GLDIT_POLY, }; enum DrawListType From 43e2d704a3dbfb777445d88f6078a23c3e5ff90a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 20 Sep 2014 09:04:36 +0200 Subject: [PATCH 0233/1509] - always use glPolygonOffset to render translucent geometry. --- src/gl/dynlights/gl_lightbuffer.cpp | 15 ++++++++------- src/gl/scene/gl_walls_draw.cpp | 25 +++++++++++++------------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index 1e0ec7e5a..a5b6ee9de 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -100,19 +100,20 @@ void FLightBuffer::Clear() int FLightBuffer::UploadLights(FDynLightData &data) { - unsigned int size0 = data.arrays[0].Size()/4; - unsigned int size1 = data.arrays[1].Size()/4; - unsigned int size2 = data.arrays[2].Size()/4; - unsigned int totalsize = size0 + size1 + size2 + 1; + int size0 = data.arrays[0].Size()/4; + int size1 = data.arrays[1].Size()/4; + int size2 = data.arrays[2].Size()/4; + int totalsize = size0 + size1 + size2 + 1; - if (mBlockAlign > 0 && totalsize + (mIndex % mBlockAlign) > mBlockSize) + // pointless type casting because some compilers can't print enough warnings. + if (mBlockAlign > 0 && (unsigned int)totalsize + (mIndex % mBlockAlign) > mBlockSize) { mIndex = ((mIndex + mBlockAlign) / mBlockAlign) * mBlockAlign; // can't be rendered all at once. - if (totalsize > mBlockSize) + if ((unsigned int)totalsize > mBlockSize) { - int diff = totalsize - mBlockSize; + int diff = totalsize - (int)mBlockSize; size2 -= diff; if (size2 < 0) diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index bad0aa5d1..1644c6605 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -238,7 +238,11 @@ void GLWall::RenderFogBoundary() gl_SetFog(lightlevel, rel, &Colormap, false); gl_RenderState.SetEffect(EFF_FOGBOUNDARY); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); RenderWall(RWF_BLANK); + glPolygonOffset(0.0f, 0.0f); + glDisable(GL_POLYGON_OFFSET_FILL); gl_RenderState.SetEffect(EFF_NONE); } } @@ -368,12 +372,6 @@ void GLWall::Draw(int pass) #endif - if (type == RENDERWALL_COLORLAYER && pass != GLPASS_LIGHTSONLY) - { - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(-1.0f, -128.0f); - } - switch (pass) { case GLPASS_LIGHTSONLY: @@ -396,6 +394,8 @@ void GLWall::Draw(int pass) break; case GLPASS_TRANSLUCENT: + + switch (type) { case RENDERWALL_MIRRORSURFACE: @@ -406,15 +406,16 @@ void GLWall::Draw(int pass) RenderFogBoundary(); break; + case RENDERWALL_COLORLAYER: + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); + RenderTranslucentWall(); + glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(0, 0); + default: RenderTranslucentWall(); break; } } - - if (type == RENDERWALL_COLORLAYER && pass != GLPASS_LIGHTSONLY) - { - glDisable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(0, 0); - } } From 835dbe5bd030b7eac11f65cc57990b9616a4b13a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 20 Sep 2014 09:10:01 +0200 Subject: [PATCH 0234/1509] - removed the 'layout' qualifier from the uniform buffer declaration. It's not really needed because the layout of a single vec4 array cannot possibly change, and Intel drivers are complaining for unknown reasons. --- wadsrc/static/shaders/glsl/main.fp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index c77a058c2..6fa304f92 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -12,7 +12,7 @@ out vec4 FragColor; vec4 lights[]; }; #else - layout(std140) uniform LightBufferUBO + /*layout(std140)*/ uniform LightBufferUBO { vec4 lights[NUM_UBO_LIGHTS]; }; From a93cb0bfabfb9f4219e89fc5ed51c109a36f8db2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Sep 2014 09:19:17 +0200 Subject: [PATCH 0235/1509] - added a NULL check for GL resource context in init code. --- src/win32/win32gliface.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 59ce1e65e..e0fe92648 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -799,17 +799,20 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) return false; } - wglMakeCurrent(m_hDC, m_hRC); + if (m_hRC != NULL) + { + wglMakeCurrent(m_hDC, m_hRC); - // we can only use core profile contexts if GL_ARB_buffer_storage is supported or GL version is >= 4.4 - if (prof == WGL_CONTEXT_CORE_PROFILE_BIT_ARB && !checkCoreUsability()) - { - wglMakeCurrent(0, 0); - wglDeleteContext(m_hRC); - } - else - { - return true; + // we can only use core profile contexts if GL_ARB_buffer_storage is supported or GL version is >= 4.4 + if (prof == WGL_CONTEXT_CORE_PROFILE_BIT_ARB && !checkCoreUsability()) + { + wglMakeCurrent(0, 0); + wglDeleteContext(m_hRC); + } + else + { + return true; + } } } return false; From da87a34a6f37c6bf0787d80797e27c1b771070fa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Sep 2014 09:40:41 +0200 Subject: [PATCH 0236/1509] - fixed: MODELDEF's FrameIndex command was case sensitive. --- src/gl/models/gl_models.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index babab5050..96d604ecb 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -542,7 +542,7 @@ void gl_InitModels() smf.sprite = -1; for (i = 0; i < (int)sprites.Size (); ++i) { - if (strncmp (sprites[i].name, sc.String, 4) == 0) + if (strnicmp (sprites[i].name, sc.String, 4) == 0) { if (sprites[i].numframes==0) { From 468273658521ba20335a43da4e2c1d6ceaf5ceef Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Sep 2014 11:08:17 +0200 Subject: [PATCH 0237/1509] - fixed: non-tiled mid textures on a fog boundary require some special clamping to be performed in the shader. --- src/gl/renderer/gl_renderstate.h | 5 +++++ src/gl/scene/gl_walls_draw.cpp | 24 +++++++++++++++++++++--- src/gl/system/gl_interface.h | 1 + wadsrc/static/shaders/glsl/main.fp | 7 +++++++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index e0f5406dd..b30d7920f 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -177,6 +177,11 @@ public: mTextureMode = mode; } + int GetTextureMode() + { + return mTextureMode; + } + void EnableTexture(bool on) { mTextureEnabled = on; diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 1644c6605..801bebcc5 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -338,10 +338,18 @@ void GLWall::RenderTranslucentWall() gl_RenderState.EnableTexture(false); extra = 0; } + int tmode = gl_RenderState.GetTextureMode(); gl_SetColor(lightlevel, extra, Colormap, fabsf(alpha)); if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, extra, &Colormap, isadditive); - else gl_SetFog(255, 0, NULL, false); + else + { + if (flags & GLT_CLAMPY) + { + if (tmode == TM_MODULATE) gl_RenderState.SetTextureMode(TM_CLAMPY); + } + gl_SetFog(255, 0, NULL, false); + } RenderWall(RWF_TEXTURED|RWF_NOSPLIT); @@ -353,6 +361,7 @@ void GLWall::RenderTranslucentWall() gl_RenderState.EnableTexture(true); } gl_RenderState.EnableGlow(false); + gl_RenderState.SetTextureMode(tmode); } //========================================================================== @@ -363,6 +372,7 @@ void GLWall::RenderTranslucentWall() void GLWall::Draw(int pass) { int rel; + int tmode; #ifdef _DEBUG if (seg->linedef-lines==879) @@ -384,13 +394,21 @@ void GLWall::Draw(int pass) case GLPASS_PLAIN: rel = rellight + getExtraLight(); gl_SetColor(lightlevel, rel, Colormap,1.0f); + tmode = gl_RenderState.GetTextureMode(); if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, false); - else gl_SetFog(255, 0, NULL, false); - + else + { + if (flags & GLT_CLAMPY) + { + if (tmode == TM_MODULATE) gl_RenderState.SetTextureMode(TM_CLAMPY); + } + gl_SetFog(255, 0, NULL, false); + } gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); gl_RenderState.SetMaterial(gltexture, flags & 3, false, -1, false); RenderWall(RWF_TEXTURED|RWF_GLOW); gl_RenderState.EnableGlow(false); + gl_RenderState.SetTextureMode(tmode); break; case GLPASS_TRANSLUCENT: diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 2d2e26d51..6f2fb2bfc 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -20,6 +20,7 @@ enum TexMode TM_OPAQUE, // (r, g, b, 1) TM_INVERSE, // (1-r, 1-g, 1-b, a) TM_REDTOALPHA, // (1, 1, 1, r) + TM_CLAMPY, // (r, g, b, (t >= 0.0 && t <= 1.0)? a:0) }; struct RenderContext diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 6fa304f92..e7421106b 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -75,6 +75,13 @@ vec4 getTexel(vec2 st) case 4: // TM_REDTOALPHA texel = vec4(1.0, 1.0, 1.0, texel.r); break; + + case 5: // TM_CLAMPY + if (st.t < 0.0 || st.t > 1.0) + { + texel.a = 0.0; + } + break; } texel *= uObjectColor; From 7359631a43274e3c8850b0a53a9a237aaa970b9c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Sep 2014 11:08:38 +0200 Subject: [PATCH 0238/1509] - fixed weapon drawing rules to account for the death camera. --- src/gl/scene/gl_weapon.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index d64c0a39a..96b4d9137 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -62,6 +62,7 @@ EXTERN_CVAR (Bool, r_drawplayersprites) EXTERN_CVAR(Float, transsouls) EXTERN_CVAR (Bool, st_scale) EXTERN_CVAR(Int, gl_fuzztype) +EXTERN_CVAR (Bool, r_deathcamera) //========================================================================== @@ -191,7 +192,8 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) if (!player || !r_drawplayersprites || !camera->player || - (players[consoleplayer].cheats & CF_CHASECAM)) + (player->cheats & CF_CHASECAM) || + (r_deathcamera && camera->health <= 0)) return; P_BobWeapon (player, &player->psprites[ps_weapon], &ofsx, &ofsy); From b2cf7d651256d9d02cf16352c4d7dff1046aecf0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Sep 2014 12:40:08 +0200 Subject: [PATCH 0239/1509] - fixed memory leak: The sector links for dynamic lights were never freed. --- src/gl/dynlights/a_dynlight.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index bcc126ecf..4507e783c 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -411,7 +411,6 @@ size_t ADynamicLight::PointerSubstitution (DObject *old, DObject *notOld) // nodes that will get linked in later. Returns a pointer to the new node. // //============================================================================= -static FreeList freelist; FLightNode * AddLightNode(FLightNode ** thread, void * linkto, ADynamicLight * light, FLightNode *& nextnode) { @@ -431,7 +430,7 @@ FLightNode * AddLightNode(FLightNode ** thread, void * linkto, ADynamicLight * l // Couldn't find an existing node for this sector. Add one at the head // of the list. - node = freelist.GetNew(); + node = new FLightNode; node->targ = linkto; node->lightsource = light; @@ -474,7 +473,7 @@ static FLightNode * DeleteLightNode(FLightNode * node) // Return this node to the freelist tn=node->nextTarget; - freelist.Release(node); + delete node; return(tn); } return(NULL); @@ -661,6 +660,7 @@ void ADynamicLight::UnlinkLight () } while (touching_sides) touching_sides = DeleteLightNode(touching_sides); while (touching_subsectors) touching_subsectors = DeleteLightNode(touching_subsectors); + while (touching_sector) touching_sector = DeleteLightNode(touching_sector); } void ADynamicLight::Destroy() @@ -765,3 +765,4 @@ CCMD(listsublights) } } + From 48da2f87bbba5beae46c89b865e43c551929338a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Sep 2014 21:01:11 +0200 Subject: [PATCH 0240/1509] - fixed: The light buffer index must not be reset between rendering a camera texture and the main scene. Since rendering is asynchronous, the camera texture scene may not be finished once the main scene's lights get filled in. Unfortunately forcing a synchronization with glFinisg has bad side effects on performance the only remaining option is to use separate parts of the buffer for both scenes, which in extreme cases may increase the light buffer's size - but on modern hardware that shouldn't be a problem. --- src/gl/scene/gl_scene.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index b095d261b..eed892c6f 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -798,7 +798,6 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo SetCameraPos(viewx, viewy, viewz, viewangle); SetViewMatrix(false, false); gl_RenderState.ApplyMatrices(); - GLRenderer->mLights->Clear(); clipper.Clear(); angle_t a1 = FrustumAngle(); @@ -845,6 +844,8 @@ void FGLRenderer::RenderView (player_t* player) P_FindParticleSubsectors (); + GLRenderer->mLights->Clear(); + // prepare all camera textures that have been used in the last frame FCanvasTextureInfo::UpdateAll(); @@ -896,6 +897,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei SetFixedColormap(player); gl_RenderState.SetVertexBuffer(mVBO); GLRenderer->mVBO->Reset(); + GLRenderer->mLights->Clear(); // Check if there's some lights. If not some code can be skipped. TThinkerIterator it(STAT_DLIGHT); From fd3128a1645bbe3990d822d5183ad7830b906ceb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Oct 2014 09:40:36 +0200 Subject: [PATCH 0241/1509] - fixed: When changing enhanced nightvision mode the shaders need to have their fixed colormap state reset to ensure that the new settings get used. - fixed: The shader code for handling special fixed colormaps did not use the color vertex attribute which was most evident with the 'shadow' render style on the spectre. --- src/gl/renderer/gl_lightdata.cpp | 7 ++++++- src/gl/shaders/gl_shader.h | 12 ++++++++++++ wadsrc/static/shaders/glsl/main.fp | 3 +-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index a02762eb8..771c4c65c 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -67,7 +67,12 @@ CUSTOM_CVAR (Int, gl_light_ambient, 20, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) } CVAR(Int, gl_weaponlight, 8, CVAR_ARCHIVE); -CVAR(Bool,gl_enhanced_nightvision,true,CVAR_ARCHIVE) +CUSTOM_CVAR(Bool, gl_enhanced_nightvision, true, CVAR_ARCHIVE|CVAR_NOINITCALL) +{ + // The fixed colormap state needs to be reset because if this happens when + // a shader is set to CM_LITE or CM_TORCH it won't register the change in behavior caused by this CVAR. + GLRenderer->mShaderManager->ResetFixedColormap(); +} CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 92ef221af..8b6f7b4a6 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -269,6 +269,18 @@ public: return mActiveShader; } + void ResetFixedColormap() + { + for (unsigned i = 0; i < mTextureEffects.Size(); i++) + { + mTextureEffects[i]->currentfixedcolormap = -1; + } + for (unsigned i = 0; i < mTextureEffectsNAT.Size(); i++) + { + mTextureEffectsNAT[i]->currentfixedcolormap = -1; + } + } + FShader *Get(unsigned int eff, bool alphateston) { // indices 0-2 match the warping modes, 3 is brightmap, 4 no texture, the following are custom diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index e7421106b..1bf583b06 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -313,8 +313,7 @@ void main() case 2: { - frag = frag * uFixedColormapStart; - frag.a *= vColor.a; + frag = vColor * frag * uFixedColormapStart; break; } From ead8a2874d3b2d9ea4a2b988b8a025352b1ef591 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Oct 2014 12:03:55 +0200 Subject: [PATCH 0242/1509] - fixed: The texture mode implied by render style did not work for models. --- src/gl/models/gl_models.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 96d604ecb..ae34e882d 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -753,7 +753,6 @@ void gl_RenderModel(GLSprite * spr) // Setup transformation. glDepthFunc(GL_LEQUAL); - gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.EnableTexture(true); // [BB] In case the model should be rendered translucent, do back face culling. // This solves a few of the problems caused by the lack of depth sorting. From 3e2a17538bef6aa291a0b32ec274501a326fc73f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Oct 2014 09:05:42 +0200 Subject: [PATCH 0243/1509] - fixed: HUD weapons were affected by dynamic lights even when the CVARs said that they shouldn't. --- src/gl/scene/gl_weapon.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 96b4d9137..db428bc48 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -388,7 +388,10 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) } else { - gl_SetDynSpriteLight(playermo, NULL); + if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap) + { + gl_SetDynSpriteLight(playermo, NULL); + } gl_SetColor(statebright[i] ? 255 : lightlevel, 0, cmc, trans, true); } DrawPSprite(player, psp, psp->sx + ofsx, psp->sy + ofsy, hudModelStep, OverrideShader, !!(vis.RenderStyle.Flags & STYLEF_RedIsAlpha)); From 5d032f3fcfe3317c075778a7c74e0723252a0724 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Oct 2014 10:00:02 +0200 Subject: [PATCH 0244/1509] - fixed: Since the engine can no longer change renderers on the fly, thanks to ZDoom's messed up video startup code, we have to abort with a fatal error if we can't create a GL context. Otherwise the user will never see a meaningful message. --- src/gl/scene/gl_weapon.cpp | 2 +- src/win32/win32gliface.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index db428bc48..35cf93183 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -388,7 +388,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) } else { - if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap) + if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap && gl_light_sprites) { gl_SetDynSpriteLight(playermo, NULL); } diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index e0fe92648..2787d9128 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -20,6 +20,7 @@ #include "doomstat.h" #include "v_text.h" #include "m_argv.h" +#include "doomerrors.h" //#include "gl_defs.h" #include "gl/renderer/gl_renderer.h" @@ -378,9 +379,7 @@ DFrameBuffer *Win32GLVideo::CreateFrameBuffer(int width, int height, bool fs, DF //old->GetFlash(flashColor, flashAmount); delete old; } - fb = new OpenGLFrameBuffer(m_hMonitor, m_DisplayWidth, m_DisplayHeight, m_DisplayBits, m_DisplayHz, fs); - return fb; } @@ -707,14 +706,14 @@ bool Win32GLVideo::SetupPixelFormat(int multisample) if (pfd.dwFlags & PFD_GENERIC_FORMAT) { - Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n"); + I_Error("R_OPENGL: OpenGL driver not accelerated!"); return false; } } if (!::SetPixelFormat(m_hDC, pixelFormat, NULL)) { - Printf("R_OPENGL: Couldn't set pixel format.\n"); + I_Error("R_OPENGL: Couldn't set pixel format.\n"); return false; } return true; @@ -765,7 +764,7 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) if (!SetupPixelFormat(multisample)) { - Printf ("R_OPENGL: Reverting to software mode...\n"); + I_Error ("R_OPENGL: Unabl...\n"); return false; } @@ -795,7 +794,7 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) if (m_hRC == NULL && prof == WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) { - Printf("R_OPENGL: Couldn't create render context. Reverting to software mode...\n"); + I_Error ("R_OPENGL: Unable to create an OpenGL 3.x render context.\n"); return false; } @@ -815,6 +814,8 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) } } } + // We get here if the driver doesn't support the modern context creation API which always means an old driver. + I_Error ("R_OPENGL: Unable to create an OpenGL 3.x render context.\n"); return false; } From 9f1f17c306222ffb186eccfccb89fdbf78ba7ff1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 14 Oct 2014 08:54:08 +0200 Subject: [PATCH 0245/1509] - fixed: The PolyBSPs weren't fully initialized. Some GZDoom-only fields in the segs were skipped. --- src/gl/scene/gl_bsp.cpp | 5 +++++ src/gl/scene/gl_walls.cpp | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index 4de31bd61..dd6df8287 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -267,6 +267,11 @@ static void AddPolyobjs(subsector_t *sub) if (sub->BSP == NULL || sub->BSP->bDirty) { sub->BuildPolyBSP(); + for (unsigned i = 0; i < sub->BSP->Segs.Size(); i++) + { + sub->BSP->Segs[i].Subsector = sub; + sub->BSP->Segs[i].PartnerSeg = NULL; + } } if (sub->BSP->Nodes.Size() == 0) { diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 94386c9a5..2e784b857 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1631,7 +1631,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) { // skip processing if the back is a malformed subsector - if (!(seg->PartnerSeg->Subsector->hacked & 4)) + if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4)) { gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a); } @@ -1704,7 +1704,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) !(seg->sidedef->Flags & WALLF_POLYOBJ)) { // skip processing if the back is a malformed subsector - if (!(seg->PartnerSeg->Subsector->hacked & 4)) + if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4)) { gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1); } From 89ce0b8cb77073ed3a18dedb8325153a6f0a4c41 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 22 Oct 2014 16:54:26 +0200 Subject: [PATCH 0246/1509] - test if GLSL version 1.4 can handle uniform buffers on old Intel hardware without making problems... --- src/gl/shaders/gl_shader.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 3d4afdbcc..7c04bdf45 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -94,7 +94,14 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * if (lightbuffertype == GL_UNIFORM_BUFFER) { - vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); + if (gl.glslversion < 1.4f || gl.version < 3.1f) + { + vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); + } + else + { + vp_comb.Format("#version 140\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); + } } else { From 5302a10a7d0f9ad50bcaf3975dbe09212288a9cb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 23 Oct 2014 09:19:30 +0200 Subject: [PATCH 0247/1509] - diable software lighting for textured automap. * since it is designed for software-style light diminishing it doesn't work for 2D. * additionally it left the lighting state in an unsuitable setting for further 2D rendering. --- src/gl/renderer/gl_renderer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index dbf0c10c8..26e16d4dd 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -584,8 +584,14 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint FColormap cm; cm = colormap; + // We cannot use the software light mode here because it doesn't properly calculate the light for 2D rendering. + SBYTE savedlightmode = glset.lightmode; + if (glset.lightmode == 8) glset.lightmode = 0; + gl_SetColor(lightlevel, 0, cm, 1.f); + glset.lightmode = savedlightmode; + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); int i; From 618c23303f18cc33f50ef2a6707c29b19fbca96e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 23 Oct 2014 09:57:27 +0200 Subject: [PATCH 0248/1509] - fixed: The interpolation factor for models was never passed to the shader. --- src/gl/data/gl_vertexbuffer.h | 2 +- src/gl/models/gl_models.cpp | 2 +- src/gl/models/gl_models_md2.cpp | 4 +++- src/gl/models/gl_models_md3.cpp | 4 +++- src/gl/models/gl_voxels.cpp | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 84967a9ee..a9619876d 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -204,7 +204,7 @@ public: FModelVertexBuffer(); ~FModelVertexBuffer(); - unsigned int SetupFrame(unsigned int frame1, unsigned int frame2, float factor); + unsigned int SetupFrame(unsigned int frame1, unsigned int frame2); }; #define VMO ((FModelVertex*)NULL) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index ae34e882d..31d05ab41 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -138,7 +138,7 @@ FModelVertexBuffer::~FModelVertexBuffer() // //=========================================================================== -unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int frame2, float factor) +unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int frame2) { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].x); diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index 3d0fad8aa..33548f2e6 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -304,10 +304,12 @@ void FDMDModel::RenderFrame(FTexture * skin, int frameno, int frameno2, double i FMaterial * tex = FMaterial::ValidateTexture(skin, false); gl_RenderState.SetMaterial(tex, CLAMP_NONE, translation, -1, false); + gl_RenderState.SetInterpolationFactor((float)inter); gl_RenderState.Apply(); - GLRenderer->mModelVBO->SetupFrame(frames[frameno].vindex, frames[frameno2].vindex, inter); + GLRenderer->mModelVBO->SetupFrame(frames[frameno].vindex, frames[frameno2].vindex); glDrawArrays(GL_TRIANGLES, 0, lodInfo[0].numTriangles * 3); + gl_RenderState.SetInterpolationFactor(0.f); } diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index 4b1788306..1dbda6acd 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -251,6 +251,7 @@ void FMD3Model::RenderFrame(FTexture * skin, int frameno, int frameno2, double i { if (frameno>=numFrames || frameno2>=numFrames) return; + gl_RenderState.SetInterpolationFactor((float)inter); for(int i=0;imModelVBO->SetupFrame(surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices, inter); + GLRenderer->mModelVBO->SetupFrame(surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices); glDrawElements(GL_TRIANGLES, surf->numTriangles * 3, GL_UNSIGNED_INT, (void*)(intptr_t)(surf->iindex * sizeof(unsigned int))); } + gl_RenderState.SetInterpolationFactor(0.f); } FMD3Model::~FMD3Model() diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index b1bb4de5a..7fb18766f 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -420,7 +420,7 @@ void FVoxelModel::RenderFrame(FTexture * skin, int frame, int frame2, double int gl_RenderState.SetMaterial(tex, CLAMP_NOFILTER, translation, -1, false); gl_RenderState.Apply(); - GLRenderer->mModelVBO->SetupFrame(vindex, vindex, 0.f); + GLRenderer->mModelVBO->SetupFrame(vindex, vindex); glDrawElements(GL_TRIANGLES, mIndices.Size(), GL_UNSIGNED_INT, (void*)(intptr_t)(iindex * sizeof(unsigned int))); } From 066e53ae4ca179b9200c94b323d5b90fa5868801 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 23 Oct 2014 10:54:26 +0200 Subject: [PATCH 0249/1509] - fixed: sprites rendered as 'bright' should not be affected by dynamic lights. --- src/gl/scene/gl_sprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 833bc2f4e..df6f37dd0 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -176,7 +176,7 @@ void GLSprite::Draw(int pass) } if (RenderStyle.BlendOp!=STYLEOP_Shadow) { - if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap) + if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap && !fullbright) { gl_SetDynSpriteLight(gl_light_sprites ? actor : NULL, gl_light_particles ? particle : NULL); } From 36b35e85f3fc067d0a8316b15bbb4cee91a5d0de Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 23 Oct 2014 12:06:00 +0200 Subject: [PATCH 0250/1509] - fixed: overflow checks for dynamic light buffer were not correct. --- src/gl/dynlights/gl_lightbuffer.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index a5b6ee9de..1f105b4ea 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -132,7 +132,7 @@ int FLightBuffer::UploadLights(FDynLightData &data) if (totalsize <= 1) return -1; - if (mIndex + totalsize > mBufferSize) + if (mIndex + totalsize > mBufferSize/4) { // reallocate the buffer with twice the size unsigned int newbuffer; @@ -173,6 +173,13 @@ int FLightBuffer::UploadLights(FDynLightData &data) if (mBufferPointer == NULL) return -1; copyptr = mBufferPointer + mIndex * 4; + static unsigned int lastindex = 0; + if (mIndex > lastindex) + { + Printf("Light index: %d, size: %d\n", mIndex, totalsize); + lastindex = mIndex; + } + float parmcnt[] = { 0, float(size0), float(size0 + size1), float(size0 + size1 + size2) }; memcpy(©ptr[0], parmcnt, 4 * sizeof(float)); From bca47bb9bce19e9ae361b5b160bfb15a8fbd63e2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 23 Oct 2014 17:35:58 +0200 Subject: [PATCH 0251/1509] - removed debug code. - fixed: planes that are created by splitting translucent 3D-floors may never be rendered. --- src/gl/dynlights/gl_lightbuffer.cpp | 7 ------- src/gl/scene/gl_flats.cpp | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index 1f105b4ea..979cbff77 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -173,13 +173,6 @@ int FLightBuffer::UploadLights(FDynLightData &data) if (mBufferPointer == NULL) return -1; copyptr = mBufferPointer + mIndex * 4; - static unsigned int lastindex = 0; - if (mIndex > lastindex) - { - Printf("Light index: %d, size: %d\n", mIndex, totalsize); - lastindex = mIndex; - } - float parmcnt[] = { 0, float(size0), float(size0 + size1), float(size0 + size1 + size2) }; memcpy(©ptr[0], parmcnt, 4 * sizeof(float)); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index ac185aee9..378cd81f0 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -639,6 +639,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) if ((rover->flags&(FF_EXISTS|FF_RENDERPLANES|FF_THISINSIDE))==(FF_EXISTS|FF_RENDERPLANES)) { if (rover->flags&FF_FOG && gl_fixedcolormap) continue; + if (rover->top.copied) continue; // this plane has been dynamically created and does not produce any rendered surface. if (rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) { fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector)); @@ -679,6 +680,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) if ((rover->flags&(FF_EXISTS|FF_RENDERPLANES|FF_THISINSIDE))==(FF_EXISTS|FF_RENDERPLANES)) { if (rover->flags&FF_FOG && gl_fixedcolormap) continue; + if (rover->bottom.copied) continue; // this plane has been dynamically created and does not produce any rendered surface. if (rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) { fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector)); From e5cd90f3230b7b4b73499f0d85e525381a54bcef Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 24 Oct 2014 11:43:25 +0200 Subject: [PATCH 0252/1509] - use separate vertex buffers per model to avoid large memory usage peaks. Also delete the geometry data for the models once it has been copied into the vertex buffer. --- src/gl/data/gl_vertexbuffer.h | 11 ++-- src/gl/models/gl_models.cpp | 111 +++++++++++++++++++++++++++----- src/gl/models/gl_models.h | 35 ++++++---- src/gl/models/gl_models_md2.cpp | 92 +++++++++++++++++--------- src/gl/models/gl_models_md3.cpp | 83 ++++++++++++++++++------ src/gl/models/gl_voxels.cpp | 55 +++++++++------- src/gl/renderer/gl_renderer.cpp | 5 +- src/gl/renderer/gl_renderer.h | 2 - 8 files changed, 287 insertions(+), 107 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index a9619876d..12b536f10 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -197,13 +197,16 @@ class FModelVertexBuffer : public FVertexBuffer unsigned int ibo_id; public: - // these are public because it's the models having to fill them in. - TArray vbo_shadowdata; // this is kept around for interpolating on GL 2.0 - TArray ibo_shadowdata; // this is kept around for interpolating on GL 2.0 - FModelVertexBuffer(); + FModelVertexBuffer(bool needindex); ~FModelVertexBuffer(); + FModelVertex *LockVertexBuffer(unsigned int size); + void UnlockVertexBuffer(); + + unsigned int *LockIndexBuffer(unsigned int size); + void UnlockIndexBuffer(); + unsigned int SetupFrame(unsigned int frame1, unsigned int frame2); }; diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 31d05ab41..13a1ef9c3 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -93,35 +93,44 @@ public: DeletingModelArray Models; -//=========================================================================== -// -// -// -//=========================================================================== - -FModelVertexBuffer::FModelVertexBuffer() +void gl_LoadModels() { - ibo_id = 0; - glGenBuffers(1, &ibo_id); - //for (unsigned i = 1; i < Models.Size(); i++) for (int i = Models.Size() - 1; i >= 0; i--) { - Models[i]->BuildVertexBuffer(this); + Models[i]->BuildVertexBuffer(); } +} +//=========================================================================== +// +// +// +//=========================================================================== + +FModelVertexBuffer::FModelVertexBuffer(bool needindex) +{ glBindVertexArray(vao_id); - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBufferData(GL_ARRAY_BUFFER,vbo_shadowdata.Size() * sizeof(FModelVertex), &vbo_shadowdata[0], GL_STATIC_DRAW); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); - glBufferData(GL_ELEMENT_ARRAY_BUFFER,ibo_shadowdata.Size() * sizeof(unsigned int), &ibo_shadowdata[0], GL_STATIC_DRAW); + ibo_id = 0; + if (needindex) + { + glGenBuffers(1, &ibo_id); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); + } + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glEnableVertexAttribArray(VATTR_VERTEX); glEnableVertexAttribArray(VATTR_TEXCOORD); glEnableVertexAttribArray(VATTR_VERTEX2); glBindVertexArray(0); } +//=========================================================================== +// +// +// +//=========================================================================== + FModelVertexBuffer::~FModelVertexBuffer() { if (ibo_id != 0) @@ -130,6 +139,63 @@ FModelVertexBuffer::~FModelVertexBuffer() } } +//=========================================================================== +// +// +// +//=========================================================================== + +FModelVertex *FModelVertexBuffer::LockVertexBuffer(unsigned int size) +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferData(GL_ARRAY_BUFFER, size * sizeof(FModelVertex), NULL, GL_STATIC_DRAW); + return (FModelVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, size * sizeof(FModelVertex), GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_BUFFER_BIT); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FModelVertexBuffer::UnlockVertexBuffer() +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glUnmapBuffer(GL_ARRAY_BUFFER); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +unsigned int *FModelVertexBuffer::LockIndexBuffer(unsigned int size) +{ + if (ibo_id != 0) + { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, size * sizeof(unsigned int), NULL, GL_STATIC_DRAW); + return (unsigned int*)glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, size * sizeof(unsigned int), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + } + else + { + return NULL; + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FModelVertexBuffer::UnlockIndexBuffer() +{ + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); + glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); +} + //=========================================================================== // @@ -147,6 +213,16 @@ unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int fr return frame1; } +//=========================================================================== +// +// FModel::~FModel +// +//=========================================================================== + +FModel::~FModel() +{ + if (mVBuf != NULL) delete mVBuf; +} @@ -293,7 +369,7 @@ static FModel * FindModel(const char * path, const char * modelfile) return NULL; } } - + // The vertex buffer cannot be initialized here because this gets called before OpenGL is initialized model->mFileName = fullname; Models.Push(model); return model; @@ -734,7 +810,8 @@ void gl_RenderFrameModels( const FSpriteModelFrame *smf, if (mdl!=NULL) { - gl_RenderState.SetVertexBuffer(GLRenderer->mModelVBO); + mdl->BuildVertexBuffer(); + gl_RenderState.SetVertexBuffer(mdl->mVBuf); if ( smfNext && smf->modelframes[i] != smfNext->modelframes[i] ) mdl->RenderFrame(smf->skins[i], smf->modelframes[i], smfNext->modelframes[i], inter, translation); diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index d608f9874..b80a11df4 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -24,16 +24,19 @@ FTexture * LoadSkin(const char * path, const char * fn); class FModel { public: - FModel() { } - virtual ~FModel() { } + + FModel() + { + mVBuf = NULL; + } + virtual ~FModel(); virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0; virtual int FindFrame(const char * name) = 0; virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0; - virtual void BuildVertexBuffer(FModelVertexBuffer *buf) = 0; - - + virtual void BuildVertexBuffer() = 0; + FModelVertexBuffer *mVBuf; FString mFileName; }; @@ -139,7 +142,8 @@ public: virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); virtual int FindFrame(const char * name); virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); - virtual void BuildVertexBuffer(FModelVertexBuffer *buf); + void BuildVertexBuffer(); + void CleanTempData(); }; @@ -201,11 +205,19 @@ class FMD3Model : public FModel } ~MD3Surface() + { + if (skins) delete [] skins; + CleanTempData(); + } + + void CleanTempData() { if (tris) delete [] tris; if (vertices) delete [] vertices; if (texcoords) delete [] texcoords; - if (skins) delete [] skins; + tris = NULL; + vertices = NULL; + texcoords = NULL; } }; @@ -231,7 +243,7 @@ public: virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); virtual int FindFrame(const char * name); virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); - virtual void BuildVertexBuffer(FModelVertexBuffer *buf); + void BuildVertexBuffer(); }; struct FVoxelVertexHash @@ -268,11 +280,10 @@ class FVoxelModel : public FModel protected: FVoxel *mVoxel; bool mOwningVoxel; // if created through MODELDEF deleting this object must also delete the voxel object + FTexture *mPalette; + unsigned int mNumIndices; TArray mVertices; TArray mIndices; - FTexture *mPalette; - unsigned int vindex; - unsigned int iindex; void MakeSlabPolys(int x, int y, kvxslab_t *voxptr, FVoxelMap &check); void AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3, int x4, int y4, int z4, BYTE color, FVoxelMap &check); @@ -286,7 +297,7 @@ public: virtual int FindFrame(const char * name); virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); FTexture *GetPaletteTexture() const { return mPalette; } - void BuildVertexBuffer(FModelVertexBuffer *buf); + void BuildVertexBuffer(); }; diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index 33548f2e6..3d01ade21 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -206,65 +206,97 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length) } +//=========================================================================== +// +// +// +//=========================================================================== + FDMDModel::~FDMDModel() { - int i; + CleanTempData(); - // clean up - if (skins != NULL) - { - // skins are managed by the texture manager so they must not be deleted here. - delete [] skins; - } + // skins are managed by the texture manager so they must not be deleted here. + if (skins != NULL) delete [] skins; + if (frames != NULL) delete [] frames; +} + +//=========================================================================== +// +// Deletes everything that's no longer needed after building the vertex buffer +// +//=========================================================================== + +void FDMDModel::CleanTempData() +{ + int i; if (frames != NULL) { for (i=0;ivertices; - DMDModelVertex *norm = frame->normals; + int VertexBufferSize = info.numFrames * lodInfo[0].numTriangles * 3; + unsigned int vindex = 0; - frame->vindex = buf->vbo_shadowdata.Size(); + mVBuf = new FModelVertexBuffer(false); + FModelVertex *vertptr = mVBuf->LockVertexBuffer(VertexBufferSize); - - FTriangle *tri = lods[0].triangles; - - for (int i = 0; i < lodInfo[0].numTriangles; i++) + for (int i = 0; i < info.numFrames; i++) { - for (int j = 0; j < 3; j++) + ModelFrame *frame = &frames[i]; + DMDModelVertex *vert = frame->vertices; + DMDModelVertex *norm = frame->normals; + + frame->vindex = vindex; + + + FTriangle *tri = lods[0].triangles; + + for (int i = 0; i < lodInfo[0].numTriangles; i++) { - FModelVertex bvert; + for (int j = 0; j < 3; j++) + { - int ti = tri->textureIndices[j]; - int vi = tri->vertexIndices[j]; + int ti = tri->textureIndices[j]; + int vi = tri->vertexIndices[j]; - bvert.Set(vert[vi].xyz[0], vert[vi].xyz[1], vert[vi].xyz[2], (float)texCoords[ti].s /info.skinWidth, (float)texCoords[ti].t/info.skinHeight); - bvert.SetNormal(norm[vi].xyz[0], norm[vi].xyz[1], norm[vi].xyz[2]); - buf->vbo_shadowdata.Push(bvert); + FModelVertex *bvert = &vertptr[vindex++]; + bvert->Set(vert[vi].xyz[0], vert[vi].xyz[1], vert[vi].xyz[2], (float)texCoords[ti].s / info.skinWidth, (float)texCoords[ti].t / info.skinHeight); + bvert->SetNormal(norm[vi].xyz[0], norm[vi].xyz[1], norm[vi].xyz[2]); + } + tri++; } - tri++; } - + mVBuf->UnlockVertexBuffer(); + CleanTempData(); } } @@ -307,7 +339,7 @@ void FDMDModel::RenderFrame(FTexture * skin, int frameno, int frameno2, double i gl_RenderState.SetInterpolationFactor((float)inter); gl_RenderState.Apply(); - GLRenderer->mModelVBO->SetupFrame(frames[frameno].vindex, frames[frameno2].vindex); + mVBuf->SetupFrame(frames[frameno].vindex, frames[frameno2].vindex); glDrawArrays(GL_TRIANGLES, 0, lodInfo[0].numTriangles * 3); gl_RenderState.SetInterpolationFactor(0.f); } diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index 1dbda6acd..cdd8d7082 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -207,37 +207,72 @@ bool FMD3Model::Load(const char * path, int, const char * buffer, int length) return true; } -void FMD3Model::BuildVertexBuffer(FModelVertexBuffer *buf) +//=========================================================================== +// +// +// +//=========================================================================== + +void FMD3Model::BuildVertexBuffer() { - for (int i = 0; i < numSurfaces; i++) + if (mVBuf == NULL) { - MD3Surface * surf = &surfaces[i]; + unsigned int vbufsize = 0; + unsigned int ibufsize = 0; - surf->vindex = buf->vbo_shadowdata.Size(); - surf->iindex = buf->ibo_shadowdata.Size(); - for (int j = 0; j < numFrames * surf->numVertices; j++) + for (int i = 0; i < numSurfaces; i++) { - MD3Vertex* vert = surf->vertices + j; - - FModelVertex bvert; - - int tc = j % surf->numVertices; - bvert.Set(vert->x, vert->z, vert->y, surf->texcoords[tc].s, surf->texcoords[tc].t); - bvert.SetNormal(vert->nx, vert->nz, vert->ny); - buf->vbo_shadowdata.Push(bvert); + MD3Surface * surf = &surfaces[i]; + vbufsize += numFrames * surf->numVertices; + ibufsize += 3 * surf->numTriangles; } - for (int k = 0; k < surf->numTriangles; k++) + mVBuf = new FModelVertexBuffer(true); + FModelVertex *vertptr = mVBuf->LockVertexBuffer(vbufsize); + unsigned int *indxptr = mVBuf->LockIndexBuffer(ibufsize); + + assert(vertptr != NULL && indxptr != NULL); + + unsigned int vindex = 0, iindex = 0; + + for (int i = 0; i < numSurfaces; i++) { - for (int l = 0; l < 3; l++) + MD3Surface * surf = &surfaces[i]; + + surf->vindex = vindex; + surf->iindex = iindex; + for (int j = 0; j < numFrames * surf->numVertices; j++) { - buf->ibo_shadowdata.Push(surf->tris[k].VertIndex[l]); + MD3Vertex* vert = surf->vertices + j; + + FModelVertex *bvert = &vertptr[vindex++]; + + int tc = j % surf->numVertices; + bvert->Set(vert->x, vert->z, vert->y, surf->texcoords[tc].s, surf->texcoords[tc].t); + bvert->SetNormal(vert->nx, vert->nz, vert->ny); } + + for (int k = 0; k < surf->numTriangles; k++) + { + for (int l = 0; l < 3; l++) + { + indxptr[iindex++] = surf->tris[k].VertIndex[l]; + } + } + surf->CleanTempData(); } + mVBuf->UnlockVertexBuffer(); + mVBuf->UnlockIndexBuffer(); } } +//=========================================================================== +// +// +// +//=========================================================================== + int FMD3Model::FindFrame(const char * name) { for (int i=0;i=numFrames || frameno2>=numFrames) return; @@ -271,12 +312,18 @@ void FMD3Model::RenderFrame(FTexture * skin, int frameno, int frameno2, double i gl_RenderState.SetMaterial(tex, CLAMP_NONE, translation, -1, false); gl_RenderState.Apply(); - GLRenderer->mModelVBO->SetupFrame(surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices); + mVBuf->SetupFrame(surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices); glDrawElements(GL_TRIANGLES, surf->numTriangles * 3, GL_UNSIGNED_INT, (void*)(intptr_t)(surf->iindex * sizeof(unsigned int))); } gl_RenderState.SetInterpolationFactor(0.f); } +//=========================================================================== +// +// +// +//=========================================================================== + FMD3Model::~FMD3Model() { if (frames) delete [] frames; diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 7fb18766f..c3ef4cd27 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -214,8 +214,6 @@ FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned) mVoxel = voxel; mOwningVoxel = owned; mPalette = new FVoxelTexture(voxel); - Initialize(); - iindex = vindex = UINT_MAX; } //=========================================================================== @@ -231,24 +229,6 @@ FVoxelModel::~FVoxelModel() } -//=========================================================================== -// -// -// -//=========================================================================== - -void FVoxelModel::BuildVertexBuffer(FModelVertexBuffer *buf) -{ - vindex = buf->vbo_shadowdata.Size(); - iindex = buf->ibo_shadowdata.Size(); - - FModelVertex *mv = &buf->vbo_shadowdata[buf->vbo_shadowdata.Reserve(mVertices.Size())]; - unsigned int *mi = &buf->ibo_shadowdata[buf->ibo_shadowdata.Reserve(mIndices.Size())]; - - memcpy(mv, &mVertices[0], sizeof(FModelVertex)* mVertices.Size()); - memcpy(mi, &mIndices[0], sizeof(unsigned int)* mIndices.Size()); -} - //=========================================================================== // // @@ -386,6 +366,37 @@ void FVoxelModel::Initialize() } } +//=========================================================================== +// +// +// +//=========================================================================== + +void FVoxelModel::BuildVertexBuffer() +{ + if (mVBuf == NULL) + { + Initialize(); + + mVBuf = new FModelVertexBuffer(true); + FModelVertex *vertptr = mVBuf->LockVertexBuffer(mVertices.Size()); + unsigned int *indxptr = mVBuf->LockIndexBuffer(mIndices.Size()); + + memcpy(vertptr, &mVertices[0], sizeof(FModelVertex)* mVertices.Size()); + memcpy(indxptr, &mIndices[0], sizeof(unsigned int)* mIndices.Size()); + + mVBuf->UnlockVertexBuffer(); + mVBuf->UnlockIndexBuffer(); + + // delete our temporary buffers + mVertices.Clear(); + mIndices.Clear(); + mVertices.ShrinkToFit(); + mIndices.ShrinkToFit(); + } +} + + //=========================================================================== // // @@ -420,7 +431,7 @@ void FVoxelModel::RenderFrame(FTexture * skin, int frame, int frame2, double int gl_RenderState.SetMaterial(tex, CLAMP_NOFILTER, translation, -1, false); gl_RenderState.Apply(); - GLRenderer->mModelVBO->SetupFrame(vindex, vindex); - glDrawElements(GL_TRIANGLES, mIndices.Size(), GL_UNSIGNED_INT, (void*)(intptr_t)(iindex * sizeof(unsigned int))); + mVBuf->SetupFrame(0, 0); + glDrawElements(GL_TRIANGLES, mNumIndices, GL_UNSIGNED_INT, (void*)(intptr_t)0); } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 26e16d4dd..9466e5fd0 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -99,6 +99,8 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mLights = NULL; } +void gl_LoadModels(); + void FGLRenderer::Initialize() { glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch); @@ -107,13 +109,13 @@ void FGLRenderer::Initialize() mVBO = new FFlatVertexBuffer; mSkyVBO = new FSkyVertexBuffer; - mModelVBO = new FModelVertexBuffer; mLights = new FLightBuffer(); gl_RenderState.SetVertexBuffer(mVBO); mFBID = 0; SetupLevel(); mShaderManager = new FShaderManager; mSamplerManager = new FSamplerManager; + gl_LoadModels(); } FGLRenderer::~FGLRenderer() @@ -123,7 +125,6 @@ FGLRenderer::~FGLRenderer() if (mShaderManager != NULL) delete mShaderManager; if (mSamplerManager != NULL) delete mSamplerManager; if (mVBO != NULL) delete mVBO; - if (mModelVBO) delete mModelVBO; if (mSkyVBO != NULL) delete mSkyVBO; if (mLights != NULL) delete mLights; if (glpart2) delete glpart2; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 90f2c4a46..0e5e99643 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -10,7 +10,6 @@ struct particle_t; class FCanvasTexture; class FFlatVertexBuffer; class FSkyVertexBuffer; -class FModelVertexBuffer; class OpenGLFrameBuffer; struct FDrawInfo; struct pspdef_t; @@ -72,7 +71,6 @@ public: FFlatVertexBuffer *mVBO; FSkyVertexBuffer *mSkyVBO; - FModelVertexBuffer *mModelVBO; FLightBuffer *mLights; From f8016bef86910830da3c9fb65c5e7e71009ec8c3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 24 Oct 2014 11:52:45 +0200 Subject: [PATCH 0253/1509] - fixed: voxels didn't set their index count. --- src/gl/models/gl_voxels.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index c3ef4cd27..62377c681 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -387,6 +387,7 @@ void FVoxelModel::BuildVertexBuffer() mVBuf->UnlockVertexBuffer(); mVBuf->UnlockIndexBuffer(); + mNumIndices = mIndices.Size(); // delete our temporary buffers mVertices.Clear(); From 5a91fd0ad44ef9c7f748ad8b6478b9ceba3a0e3d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 24 Oct 2014 13:03:26 +0200 Subject: [PATCH 0254/1509] - fixed: DMD models didn't load their triangle data. - fixed: MD2 models didn't handle the triangles' byte order. --- src/gl/models/gl_models_md2.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index 3d01ade21..21e24c768 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -115,7 +115,6 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length) char *temp; ModelFrame *frame; int i, k, c; - FTriangle *triangles[MAX_LODS]; int axis[3] = { VX, VY, VZ }; int fileoffset=12+sizeof(dmd_chunk_t); @@ -197,8 +196,19 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length) { lodInfo[i].numTriangles = LittleLong(lodInfo[i].numTriangles); lodInfo[i].offsetTriangles = LittleLong(lodInfo[i].offsetTriangles); - - lods[i].triangles = triangles[i] = (FTriangle*)(buffer + lodInfo[i].offsetTriangles); + if (lodInfo[i].numTriangles > 0) + { + lods[i].triangles = new FTriangle[lodInfo[i].numTriangles]; + memcpy(lods[i].triangles, buffer + lodInfo[i].offsetTriangles, lodInfo[i].numTriangles * sizeof(FTriangle)); + for (int j = 0; j < lodInfo[i].numTriangles; j++) + { + for (int k = 0; k < 3; k++) + { + lods[i].triangles[j].textureIndices[k] = LittleShort(lods[i].triangles[j].textureIndices[k]); + lods[i].triangles[j].vertexIndices[k] = LittleShort(lods[i].triangles[j].vertexIndices[k]); + } + } + } } loaded=true; @@ -465,7 +475,16 @@ bool FMD2Model::Load(const char * path, int, const char * buffer, int length) lods[0].triangles = new FTriangle[lodInfo[0].numTriangles]; - memcpy(lods[0].triangles, buffer + lodInfo[0].offsetTriangles, sizeof(FTriangle) * lodInfo[0].numTriangles); + int cnt = lodInfo[0].numTriangles; + memcpy(lods[0].triangles, buffer + lodInfo[0].offsetTriangles, sizeof(FTriangle) * cnt); + for (int j = 0; j < cnt; j++) + { + for (int k = 0; k < 3; k++) + { + lods[0].triangles[j].textureIndices[k] = LittleShort(lods[0].triangles[j].textureIndices[k]); + lods[0].triangles[j].vertexIndices[k] = LittleShort(lods[0].triangles[j].vertexIndices[k]); + } + } skins = new FTexture *[info.numSkins]; From 3c7664a4608ab6f6e963a2b35e971a32245bd80b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 26 Oct 2014 08:41:52 +0100 Subject: [PATCH 0255/1509] - we don't really need a bBrightmap in a texture. All it did was duplicate some functionality of bMasked. - renamed bBrightmapDisablesFullbright flag. --- src/gl/scene/gl_sprite.cpp | 2 +- src/gl/scene/gl_weapon.cpp | 2 +- src/gl/textures/gl_texture.cpp | 13 ++++++------- src/textures/textures.h | 3 +-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index df6f37dd0..89ff9cdb9 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -676,7 +676,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) // allow disabling of the fullbright flag by a brightmap definition // (e.g. to do the gun flashes of Doom's zombies correctly. fullbright = (thing->flags5 & MF5_BRIGHT) || - ((thing->renderflags & RF_FULLBRIGHT) && (!gltexture || !gltexture->tex->gl_info.bBrightmapDisablesFullbright)); + ((thing->renderflags & RF_FULLBRIGHT) && (!gltexture || !gltexture->tex->gl_info.bDisableFullbright)); lightlevel=fullbright? 255 : gl_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ? diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 35cf93183..67950ce0e 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -211,7 +211,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) { FMaterial * tex=FMaterial::ValidateTexture(lump, false, false); if (tex) - disablefullbright = tex->tex->gl_info.bBrightmapDisablesFullbright; + disablefullbright = tex->tex->gl_info.bDisableFullbright; } statebright[i] = !!psp->state->GetFullbright() && !disablefullbright; } diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 53a07d437..8b314f02f 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -158,7 +158,7 @@ void gl_GenerateGlobalBrightmapFromColormap() if (cmapdata[i+j*256]!=i || (paldata[3*i]<10 && paldata[3*i+1]<10 && paldata[3*i+2]<10)) { GlobalBrightmap.Remap[i]=black; - GlobalBrightmap.Palette[i]=PalEntry(0,0,0); + GlobalBrightmap.Palette[i] = PalEntry(255, 0, 0, 0); } } } @@ -232,8 +232,7 @@ FTexture::MiscGLInfo::MiscGLInfo() throw() bFullbright = false; bSkyColorDone = false; bBrightmapChecked = false; - bBrightmap = false; - bBrightmapDisablesFullbright = false; + bDisableFullbright = false; bNoFilter = false; bNoCompress = false; areas = NULL; @@ -594,7 +593,7 @@ bool FTexture::SmoothEdges(unsigned char * buffer,int w, int h) bool FTexture::ProcessData(unsigned char * buffer, int w, int h, bool ispatch) { - if (bMasked && !gl_info.bBrightmap) + if (bMasked) { bMasked = SmoothEdges(buffer, w, h); if (bMasked && !ispatch) FindHoles(buffer, w, h); @@ -620,7 +619,7 @@ FBrightmapTexture::FBrightmapTexture (FTexture *source) bNoDecals = source->bNoDecals; Rotations = source->Rotations; UseType = source->UseType; - gl_info.bBrightmap = true; + bMasked = false; id.SetInvalid(); SourceLump = -1; } @@ -737,10 +736,10 @@ void gl_ParseBrightmap(FScanner &sc, int deflump) return; } - bmtex->gl_info.bBrightmap = true; + bmtex->bMasked = false; tex->gl_info.Brightmap = bmtex; } - tex->gl_info.bBrightmapDisablesFullbright = disable_fullbright; + tex->gl_info.bDisableFullbright = disable_fullbright; } //========================================================================== diff --git a/src/textures/textures.h b/src/textures/textures.h index df2707401..fbdce0f5c 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -347,8 +347,7 @@ public: bool bSkybox:1; // This is a skybox bool bSkyColorDone:1; // Fill color for sky char bBrightmapChecked:1; // Set to 1 if brightmap has been checked - bool bBrightmap:1; // This is a brightmap - bool bBrightmapDisablesFullbright:1; // This disables fullbright display + bool bDisableFullbright:1; // This texture will not be displayed as fullbright sprite bool bNoFilter:1; bool bNoCompress:1; From 3e50db9bf059debc6366f79ecc6e84a16276e433 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 26 Oct 2014 15:11:04 +0100 Subject: [PATCH 0256/1509] - fixed: When setting the object color for a shaded decal, the alpha channel must be forced to be 255. The decal's AlphaColor contains the palette index in those bits. --- src/gl/scene/gl_decal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index c938e9043..7cc766cd0 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -305,7 +305,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) // alpha color only has an effect when using an alpha texture. if (decal->RenderStyle.Flags & STYLEF_RedIsAlpha) { - gl_RenderState.SetObjectColor(decal->AlphaColor); + gl_RenderState.SetObjectColor(decal->AlphaColor|0xff000000); } gl_SetColor(light, rel, p, a); From 5638aab63c72906896ba8dec1a844a758b5423e2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 26 Oct 2014 21:17:29 +0100 Subject: [PATCH 0257/1509] - fixed: Even though the name REDISALPHA implies otherwise, this render mode still needs to respect a texture's alpha channel to ensure that things get rendered properly. Otherwise the SmoothEdges function cannot be used which is necessary to ensure that filtered textures look correct. --- wadsrc/static/shaders/glsl/main.fp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 1bf583b06..41150fa20 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -73,7 +73,7 @@ vec4 getTexel(vec2 st) break; case 4: // TM_REDTOALPHA - texel = vec4(1.0, 1.0, 1.0, texel.r); + texel = vec4(1.0, 1.0, 1.0, texel.r*texel.a); break; case 5: // TM_CLAMPY From b0a6c94fa4f60b6641ac5169175118ddc2c3027d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 9 Nov 2014 12:10:33 +0100 Subject: [PATCH 0258/1509] - fixed: the translucency flag for the flags renderer was inconsistent between the light pass and the render pass on GL 3.x hardware, resulting in bad buffer indices being sent to the shader. --- src/gl/scene/gl_drawinfo.cpp | 4 ++-- src/gl/scene/gl_drawinfo.h | 2 +- src/gl/scene/gl_scene.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index b92a2c6cf..d0da4e0d4 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -771,11 +771,11 @@ void GLDrawList::DrawSorted() // // //========================================================================== -void GLDrawList::Draw(int pass) +void GLDrawList::Draw(int pass, bool trans) { for(unsigned i=0;idrawlists[GLDL_MASKEDFLATS].DrawFlats(GLPASS_LIGHTSONLY); gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(GLPASS_LIGHTSONLY); gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(GLPASS_LIGHTSONLY); - gl_drawinfo->drawlists[GLDL_TRANSLUCENT].Draw(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_TRANSLUCENT].Draw(GLPASS_LIGHTSONLY, true); GLRenderer->mLights->Finish(); } From a7f4185981713510beb0c5243c67b0c6b797542a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 16 Nov 2014 09:08:47 +0100 Subject: [PATCH 0259/1509] - now that we don't have to care anymore about SVN-related merging problems, let's save the 3 global variables of the GL renderer unconditionally, even if the software renderer is running. --- src/g_level.cpp | 2 ++ src/gl/scene/gl_scene.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/g_level.cpp b/src/g_level.cpp index 2a2d6471a..7eeb443fb 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1439,12 +1439,14 @@ void G_AirControlChanged () // // //========================================================================== +void gl_SerializeGlobals(FArchive &arc); void G_SerializeLevel (FArchive &arc, bool hubLoad) { int i = level.totaltime; Renderer->StartSerialize(arc); + gl_SerializeGlobals(arc); arc << level.flags << level.flags2 diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 79d21e4e3..395403690 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -999,6 +999,10 @@ void FGLInterface::StateChanged(AActor *actor) void FGLInterface::StartSerialize(FArchive &arc) { gl_DeleteAllAttachedLights(); +} + +void gl_SerializeGlobals(FArchive &arc) +{ arc << fogdensity << outsidefogdensity << skyfog; } From 60d78bcdf6c7d6f2aa31613ee60e483556821582 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 27 Nov 2014 10:58:34 +0200 Subject: [PATCH 0260/1509] - implemented hqNx image scaling algorithms using MMX and SSE2 intrinsics --- src/gl/hqnx_asm/hq2x_asm.cpp | 182 +++++++++---------------- src/gl/hqnx_asm/hq3x_asm.cpp | 123 +++++++---------- src/gl/hqnx_asm/hq4x_asm.cpp | 212 +++++++++++------------------ src/gl/hqnx_asm/hqnx_asm.h | 193 ++++++++++++++++++++++++++ src/gl/hqnx_asm/hqnx_asm_Image.cpp | 4 + 5 files changed, 390 insertions(+), 324 deletions(-) diff --git a/src/gl/hqnx_asm/hq2x_asm.cpp b/src/gl/hqnx_asm/hq2x_asm.cpp index 59d52c180..65e460377 100644 --- a/src/gl/hqnx_asm/hq2x_asm.cpp +++ b/src/gl/hqnx_asm/hq2x_asm.cpp @@ -1,6 +1,7 @@ //hq2x filter demo program //---------------------------------------------------------- //Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +//Copyright (C) 2012-2014 Alexey Lysiuk // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU Lesser General Public @@ -24,153 +25,104 @@ namespace HQnX_asm extern int LUT16to32[65536*2]; extern int RGBtoYUV[65536*2]; -static const __int64 reg_blank = 0; -static const __int64 const3 = 0x0003000300030003; -static const __int64 const5 = 0x0005000500050005; -static const __int64 const6 = 0x0006000600060006; -static const __int64 const14 = 0x000E000E000E000E; -static const __int64 treshold = 0x0000000000300706; +static const hq_vec const3 = hq_vec::expand(0x0003); +static const hq_vec const5 = hq_vec::expand(0x0005); +static const hq_vec const6 = hq_vec::expand(0x0006); +static const hq_vec const14 = hq_vec::expand(0x000E); inline void Interp1(unsigned char * pc, int c1, int c2) { //*((int*)pc) = (c1*3+c2)/4; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - pmullw mm1, const3 - paddw mm1, mm2 - psrlw mm1, 2 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result *= const3; + result += hq_vec::load(c2); + result >> 2; + + result.store(pc); } inline void Interp2(unsigned char * pc, int c1, int c2, int c3) { //*((int*)pc) = (c1*2+c2+c3) >> 2; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - psllw mm1, 1 - paddw mm1, mm2 - paddw mm1, mm3 - psrlw mm1, 2 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result << 1; + result += hq_vec::load(c2); + result += hq_vec::load(c3); + result >> 2; + + result.store(pc); } inline void Interp5(unsigned char * pc, int c1, int c2) { //*((int*)pc) = (c1+c2)/2; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - paddw mm1, mm2 - psrlw mm1, 1 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result += hq_vec::load(c2); + result >> 1; + + result.store(pc); } inline void Interp6(unsigned char * pc, int c1, int c2, int c3) { //*((int*)pc) = (c1*5+c2*2+c3)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - pmullw mm1, const5 - psllw mm2, 1 - paddw mm1, mm3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result *= const5; + result += hq_vec::load(c2) << 1; + result += hq_vec::load(c3); + result >> 3; + + result.store(pc); } inline void Interp7(unsigned char * pc, int c1, int c2, int c3) { //*((int*)pc) = (c1*6+c2+c3)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - pmullw mm1, const6 - paddw mm2, mm3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result *= const6; + result += hq_vec::load(c2); + result += hq_vec::load(c3); + result >> 3; + + result.store(pc); } inline void Interp9(unsigned char * pc, int c1, int c2, int c3) { //*((int*)pc) = (c1*2+(c2+c3)*3)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - psllw mm1, 1 - paddw mm2, mm3 - pmullw mm2, const3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c2); + + result += hq_vec::load(c3); + result *= const3; + result += hq_vec::load(c1) << 1; + result >> 3; + + result.store(pc); } inline void Interp10(unsigned char * pc, int c1, int c2, int c3) { //*((int*)pc) = (c1*14+c2+c3)/16; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - pmullw mm1, const14 - paddw mm2, mm3 - paddw mm1, mm2 - psrlw mm1, 4 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result *= const14; + result += hq_vec::load(c2); + result += hq_vec::load(c3); + result >> 4; + + result.store(pc); } #define PIXEL00_0 *((int*)(pOut)) = c[5]; @@ -223,7 +175,7 @@ inline void Interp10(unsigned char * pc, int c1, int c2, int c3) #define PIXEL11_100 Interp10(pOut+BpL+4, c[5], c[6], c[8]); -int Diff(unsigned int w5, unsigned int w1); +bool Diff(const unsigned int, const unsigned int); void DLL hq2x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) { @@ -2985,7 +2937,7 @@ void DLL hq2x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) } pOut+=BpL; } - __asm emms + hq_vec::reset(); } } \ No newline at end of file diff --git a/src/gl/hqnx_asm/hq3x_asm.cpp b/src/gl/hqnx_asm/hq3x_asm.cpp index 8d1f3572a..073ce6656 100644 --- a/src/gl/hqnx_asm/hq3x_asm.cpp +++ b/src/gl/hqnx_asm/hq3x_asm.cpp @@ -1,6 +1,7 @@ //hq3x filter demo program //---------------------------------------------------------- //Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +//Copyright (C) 2012-2014 Alexey Lysiuk // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU Lesser General Public @@ -24,105 +25,73 @@ namespace HQnX_asm extern int LUT16to32[65536*2]; extern int RGBtoYUV[65536*2]; -static const __int64 reg_blank = 0; -static const __int64 const3 = 0x0003000300030003; -static const __int64 const7 = 0x0007000700070007; -static const __int64 treshold = 0x0000000000300706; +static const hq_vec const3 = hq_vec::expand(0x0003); +static const hq_vec const7 = hq_vec::expand(0x0007); inline void Interp1(unsigned char * pc, int c1, int c2) { //*((int*)pc) = (c1*3+c2)/4; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - pmullw mm1, const3 - paddw mm1, mm2 - psrlw mm1, 2 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result *= const3; + result += hq_vec::load(c2); + result >> 2; + + result.store(pc); } inline void Interp2(unsigned char * pc, int c1, int c2, int c3) { // *((int*)pc) = (c1*2+c2+c3)/4; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - psllw mm1, 1 - paddw mm1, mm2 - paddw mm1, mm3 - psrlw mm1, 2 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result << 1; + result += hq_vec::load(c2); + result += hq_vec::load(c3); + result >> 2; + + result.store(pc); } inline void Interp3(unsigned char * pc, int c1, int c2) { //*((int*)pc) = (c1*7+c2)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - pmullw mm1, const7 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result *= const7; + result += hq_vec::load(c2); + result >> 3; + + result.store(pc); } inline void Interp4(unsigned char * pc, int c1, int c2, int c3) { //*((int*)pc) = (c1*2+(c2+c3)*7)/16; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - psllw mm1, 1 - paddw mm2, mm3 - pmullw mm2, const7 - paddw mm1, mm2 - psrlw mm1, 4 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c2); + + result += hq_vec::load(c3); + result *= const7; + result += hq_vec::load(c1) << 1; + result >> 4; + + result.store(pc); } inline void Interp5(unsigned char * pc, int c1, int c2) { //*((int*)pc) = (c1+c2)/2; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - paddw mm1, mm2 - psrlw mm1, 1 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result += hq_vec::load(c2); + result >> 1; + + result.store(pc); } #define PIXEL00_1M Interp1(pOut, c[5], c[1]); @@ -179,7 +148,7 @@ inline void Interp5(unsigned char * pc, int c1, int c2) #define PIXEL22_5 Interp5(pOut+BpL+BpL+8, c[6], c[8]); #define PIXEL22_C *((int*)(pOut+BpL+BpL+8)) = c[5]; -int Diff(unsigned int w5, unsigned int w1); +bool Diff(const unsigned int, const unsigned int); void DLL hq3x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) { @@ -3867,7 +3836,7 @@ void DLL hq3x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) pOut+=BpL; pOut+=BpL; } - __asm emms + hq_vec::reset(); } diff --git a/src/gl/hqnx_asm/hq4x_asm.cpp b/src/gl/hqnx_asm/hq4x_asm.cpp index 57a496c72..34a474405 100644 --- a/src/gl/hqnx_asm/hq4x_asm.cpp +++ b/src/gl/hqnx_asm/hq4x_asm.cpp @@ -1,6 +1,7 @@ //hq4x filter demo program //---------------------------------------------------------- //Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +//Copyright (C) 2012-2014 Alexey Lysiuk // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU Lesser General Public @@ -19,7 +20,6 @@ #include #include -#include #include #include "hqnx_asm.h" @@ -29,148 +29,103 @@ namespace HQnX_asm int LUT16to32[65536*2]; int RGBtoYUV[65536*2]; -static const __int64 reg_blank = 0; -static const __int64 const3 = 0x0003000300030003; -static const __int64 const5 = 0x0005000500050005; -static const __int64 const6 = 0x0006000600060006; -static const __int64 const7 = 0x0007000700070007; -static const __int64 treshold = 0x0000000000300706; +static const hq_vec const3 = hq_vec::expand(0x0003); +static const hq_vec const5 = hq_vec::expand(0x0005); +static const hq_vec const6 = hq_vec::expand(0x0006); +static const hq_vec const7 = hq_vec::expand(0x0007); inline void Interp1(unsigned char * pc, int c1, int c2) { //*((int*)pc) = (c1*3+c2)/4; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - pmullw mm1, const3 - paddw mm1, mm2 - psrlw mm1, 2 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result *= const3; + result += hq_vec::load(c2); + result >> 2; + + result.store(pc); } inline void Interp2(unsigned char * pc, int c1, int c2, int c3) { // *((int*)pc) = (c1*2+c2+c3)/4; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - psllw mm1, 1 - paddw mm1, mm2 - paddw mm1, mm3 - psrlw mm1, 2 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result << 1; + result += hq_vec::load(c2); + result += hq_vec::load(c3); + result >> 2; + + result.store(pc); } inline void Interp3(unsigned char * pc, int c1, int c2) { //*((int*)pc) = (c1*7+c2)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - pmullw mm1, const7 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result *= const7; + result += hq_vec::load(c2); + result >> 3; + + result.store(pc); } inline void Interp5(unsigned char * pc, int c1, int c2) { //*((int*)pc) = (c1+c2)/2; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - paddw mm1, mm2 - psrlw mm1, 1 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result += hq_vec::load(c2); + result >> 1; + + result.store(pc); } inline void Interp6(unsigned char * pc, int c1, int c2, int c3) { //*((int*)pc) = (c1*5+c2*2+c3)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - pmullw mm1, const5 - psllw mm2, 1 - paddw mm1, mm3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result *= const5; + result += hq_vec::load(c2) << 1; + result += hq_vec::load(c3); + result >> 3; + + result.store(pc); } inline void Interp7(unsigned char * pc, int c1, int c2, int c3) { //*((int*)pc) = (c1*6+c2+c3)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - pmullw mm1, const6 - paddw mm2, mm3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result *= const6; + result += hq_vec::load(c2); + result += hq_vec::load(c3); + result >> 3; + + result.store(pc); } inline void Interp8(unsigned char * pc, int c1, int c2) { //*((int*)pc) = (c1*5+c2*3)/8; - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - pmullw mm1, const5 - pmullw mm2, const3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } + + hq_vec result = hq_vec::load(c1); + + result *= const5; + result += hq_vec::load(c2) * const3; + result >> 3; + + result.store(pc); } #define PIXEL00_0 *((int*)(pOut)) = c[5]; @@ -314,33 +269,26 @@ inline void Interp8(unsigned char * pc, int c1, int c2) #define PIXEL33_81 Interp8(pOut+BpL+BpL+BpL+12, c[5], c[6]); #define PIXEL33_82 Interp8(pOut+BpL+BpL+BpL+12, c[5], c[8]); - -#pragma warning(disable: 4035) - -int Diff(unsigned int w5, unsigned int w1) +bool Diff(const unsigned int rgb1, const unsigned int rgb2) { - __asm + if (rgb1 == rgb2) { - xor eax,eax - mov ebx,w5 - mov edx,w1 - cmp ebx,edx - je FIN - mov ecx,offset RGBtoYUV - movd mm1,[ecx + ebx*4] - movq mm5,mm1 - movd mm2,[ecx + edx*4] - psubusb mm1,mm2 - psubusb mm2,mm5 - por mm1,mm2 - psubusb mm1,treshold - movd eax,mm1 -FIN: + return false; } -} -// returns result in eax register + + static const hq_vec THRESHOLD = 0x00300706; + + const hq_vec yuv1 = RGBtoYUV[rgb1]; + const hq_vec yuv2 = RGBtoYUV[rgb2]; -#pragma warning(default: 4035) + const hq_vec delta1 = yuv1 - yuv2; + const hq_vec delta2 = yuv2 - yuv1; + + const hq_vec delta = delta1 | delta2; + const hq_vec result = delta - THRESHOLD; + + return 0 != result; +} void DLL hq4x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) { @@ -5412,7 +5360,7 @@ void DLL hq4x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) pOut += BpL; pOut += BpL; } - __asm emms + hq_vec::reset(); } void DLL InitLUTs() diff --git a/src/gl/hqnx_asm/hqnx_asm.h b/src/gl/hqnx_asm/hqnx_asm.h index 341e2dad3..2580f80ef 100644 --- a/src/gl/hqnx_asm/hqnx_asm.h +++ b/src/gl/hqnx_asm/hqnx_asm.h @@ -2,6 +2,7 @@ //---------------------------------------------------------- //Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) //Copyright (C) 2009 Benjamin Berkels +//Copyright (C) 2012-2014 Alexey Lysiuk // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU Lesser General Public @@ -24,6 +25,198 @@ #include "hqnx_asm_Image.h" +// IMPORTANT NOTE! +// The following is not a generic vectorized math class +// Each member function or overloaded operator does specific task to simplify client code +// To re-implement this class for different platform you need check very carefully +// the Intel C++ Intrinsic Reference at http://software.intel.com/file/18072/ + +#if defined _MSC_VER && defined _M_X64 + +// Implementation via SSE2 intrinsics +// MSVC doesn't support MMX intrinsics on x64 + +#include + +class hq_vec +{ +public: + hq_vec(const int value) + : m_value(_mm_cvtsi32_si128(value)) + { + } + + static hq_vec load(const int source) + { + return _mm_unpacklo_epi8(_mm_cvtsi32_si128(source), _mm_cvtsi32_si128(0)); + } + + static hq_vec expand(const short source) + { + return _mm_set_epi16(source, source, source, source, source, source, source, source); + } + + void store(unsigned char* const destination) const + { + *reinterpret_cast(destination) = _mm_cvtsi128_si32(_mm_packus_epi16(m_value, _mm_cvtsi32_si128(0))); + } + + static void reset() + { + } + + hq_vec& operator+=(const hq_vec& right) + { + m_value = _mm_add_epi16(m_value, right.m_value); + return *this; + } + + hq_vec& operator*=(const hq_vec& right) + { + m_value = _mm_mullo_epi16(m_value, right.m_value); + return *this; + } + + hq_vec& operator<<(const int count) + { + m_value = _mm_sll_epi16(m_value, _mm_cvtsi32_si128(count)); + return *this; + } + + hq_vec& operator>>(const int count) + { + m_value = _mm_srl_epi16(m_value, _mm_cvtsi32_si128(count)); + return *this; + } + +private: + __m128i m_value; + + hq_vec(const __m128i value) + : m_value(value) + { + } + + friend hq_vec operator- (const hq_vec&, const hq_vec&); + friend hq_vec operator* (const hq_vec&, const hq_vec&); + friend hq_vec operator| (const hq_vec&, const hq_vec&); + friend bool operator!=(const int, const hq_vec&); +}; + +inline hq_vec operator-(const hq_vec& left, const hq_vec& right) +{ + return _mm_subs_epu8(left.m_value, right.m_value); +} + +inline hq_vec operator*(const hq_vec& left, const hq_vec& right) +{ + return _mm_mullo_epi16(left.m_value, right.m_value); +} + +inline hq_vec operator|(const hq_vec& left, const hq_vec& right) +{ + return _mm_or_si128(left.m_value, right.m_value); +} + +inline bool operator!=(const int left, const hq_vec& right) +{ + return left != _mm_cvtsi128_si32(right.m_value); +} + +#else // _M_X64 + +// Implementation via MMX intrinsics + +#include + +class hq_vec +{ +public: + hq_vec(const int value) + : m_value(_mm_cvtsi32_si64(value)) + { + } + + static hq_vec load(const int source) + { + return _mm_unpacklo_pi8(_mm_cvtsi32_si64(source), _mm_cvtsi32_si64(0)); + } + + static hq_vec expand(const short source) + { + return _mm_set_pi16(source, source, source, source); + } + + void store(unsigned char* const destination) const + { + *reinterpret_cast(destination) = _mm_cvtsi64_si32(_mm_packs_pu16(m_value, _mm_cvtsi32_si64(0))); + } + + static void reset() + { + _mm_empty(); + } + + hq_vec& operator+=(const hq_vec& right) + { + m_value = _mm_add_pi16(m_value, right.m_value); + return *this; + } + + hq_vec& operator*=(const hq_vec& right) + { + m_value = _mm_mullo_pi16(m_value, right.m_value); + return *this; + } + + hq_vec& operator<<(const int count) + { + m_value = _mm_sll_pi16(m_value, _mm_cvtsi32_si64(count)); + return *this; + } + + hq_vec& operator>>(const int count) + { + m_value = _mm_srl_pi16(m_value, _mm_cvtsi32_si64(count)); + return *this; + } + +private: + __m64 m_value; + + hq_vec(const __m64 value) + : m_value(value) + { + } + + friend hq_vec operator- (const hq_vec&, const hq_vec&); + friend hq_vec operator* (const hq_vec&, const hq_vec&); + friend hq_vec operator| (const hq_vec&, const hq_vec&); + friend bool operator!=(const int, const hq_vec&); +}; + +inline hq_vec operator-(const hq_vec& left, const hq_vec& right) +{ + return _mm_subs_pu8(left.m_value, right.m_value); +} + +inline hq_vec operator*(const hq_vec& left, const hq_vec& right) +{ + return _mm_mullo_pi16(left.m_value, right.m_value); +} + +inline hq_vec operator|(const hq_vec& left, const hq_vec& right) +{ + return _mm_or_si64(left.m_value, right.m_value); +} + +inline bool operator!=(const int left, const hq_vec& right) +{ + return left != _mm_cvtsi64_si32(right.m_value); +} + +#endif // _MSC_VER && _M_X64 + namespace HQnX_asm { void DLL hq2x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ); diff --git a/src/gl/hqnx_asm/hqnx_asm_Image.cpp b/src/gl/hqnx_asm/hqnx_asm_Image.cpp index be7d1b350..7af120173 100644 --- a/src/gl/hqnx_asm/hqnx_asm_Image.cpp +++ b/src/gl/hqnx_asm/hqnx_asm_Image.cpp @@ -20,6 +20,10 @@ #include #include "hqnx_asm_Image.h" +#ifndef _MSC_VER +#define _stricmp strcasecmp +#endif + namespace HQnX_asm { From 99d81621f968674a28b788d193f9ec648b367233 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 27 Nov 2014 10:46:28 +0100 Subject: [PATCH 0261/1509] - fixed: The 'copied' information of a 3D floor plane should only apply to that particular plane, but never the opposite one of the same 3D floor. --- src/gl/scene/gl_flats.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 378cd81f0..d8329f214 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -64,6 +64,9 @@ #include "gl/utility/gl_convert.h" #include "gl/utility/gl_templates.h" +#ifdef _DEBUG +CVAR(Int, gl_breaksec, -1, 0) +#endif //========================================================================== // // Sets the texture matrix according to the plane's texture positioning @@ -328,7 +331,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG int rel = getExtraLight(); #ifdef _DEBUG - if (sector->sectornum == 130) + if (sector->sectornum == gl_breaksec) { int a = 0; } @@ -490,7 +493,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) lightlist_t * light; #ifdef _DEBUG - if (frontsector->sectornum==0) + if (frontsector->sectornum==gl_breaksec) { int a = 0; } @@ -639,8 +642,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) if ((rover->flags&(FF_EXISTS|FF_RENDERPLANES|FF_THISINSIDE))==(FF_EXISTS|FF_RENDERPLANES)) { if (rover->flags&FF_FOG && gl_fixedcolormap) continue; - if (rover->top.copied) continue; // this plane has been dynamically created and does not produce any rendered surface. - if (rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) + if (!rover->top.copied && rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) { fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector)); if (ff_topflags&(FF_EXISTS|FF_RENDERPLANES|FF_THISINSIDE))==(FF_EXISTS|FF_RENDERPLANES)) { if (rover->flags&FF_FOG && gl_fixedcolormap) continue; - if (rover->bottom.copied) continue; // this plane has been dynamically created and does not produce any rendered surface. - if (rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) + if (!rover->bottom.copied && rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) { fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector)); if (ff_bottom>lastfloorheight || (rover->flags&FF_FIX)) From eb753a0b7c921c07ca903bfc036944e9b14a180d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 27 Nov 2014 10:49:03 +0100 Subject: [PATCH 0262/1509] - fixed: We also should use the proper 'copied' info for the non-inverted planes. --- src/gl/scene/gl_flats.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index d8329f214..b0533ceb5 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -656,7 +656,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) lastceilingheight=ff_top; } } - if (!(rover->flags&FF_INVERTPLANES)) + if (!rover->bottom.copied && !(rover->flags&FF_INVERTPLANES)) { fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector)); if (ff_bottomflags&FF_INVERTPLANES)) + if (!rover->top.copied && !(rover->flags&FF_INVERTPLANES)) { fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector)); if (ff_top>lastfloorheight) From ec627d94dd7016506c6b3983d7d57bbf7cdf020d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 27 Nov 2014 12:26:52 +0100 Subject: [PATCH 0263/1509] - fixed: The depth clamp setting needs to be tracked per portal so that it can be properly restored afterward. Regular skies need it off but SkyViewpoints need it on - and all others need to use the parent's setting. So without engine side tracking we can end up rendering the sky with this setting off, resulting in omission of the fog layer. --- src/gl/renderer/gl_renderstate.cpp | 1 + src/gl/renderer/gl_renderstate.h | 11 +++++++++++ src/gl/scene/gl_portal.cpp | 5 ++--- src/gl/scene/gl_skydome.cpp | 2 ++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index bdd0867b9..358c9fe7f 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -90,6 +90,7 @@ void FRenderState::Reset() stSrcBlend = stDstBlend = -1; stBlendEquation = -1; stAlphaThreshold = -1.f; + mLastDepthClamp = true; } //========================================================================== diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index b30d7920f..8c3b60772 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -63,6 +63,7 @@ class FRenderState float mInterpolationFactor; float mClipHeightTop, mClipHeightBottom; float mShaderTimer; + bool mLastDepthClamp; FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; FStateVec4 mColor; @@ -309,6 +310,16 @@ public: } } + // This wraps the depth clamp setting because we frequently need to read it which OpenGL is not particularly performant at... + bool SetDepthClamp(bool on) + { + bool res = mLastDepthClamp; + if (!on) glDisable(GL_DEPTH_CLAMP); + else glEnable(GL_DEPTH_CLAMP); + mLastDepthClamp = on; + return res; + } + void Set2DMode(bool on) { m2D = on; diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 02e7747bc..eba8b4d06 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -633,8 +633,7 @@ void GLSkyboxPortal::DrawContents() PlaneMirrorMode=0; - glDisable(GL_DEPTH_CLAMP); - + bool oldclamp = gl_RenderState.SetDepthClamp(false); viewx = origin->PrevX + FixedMul(r_TicFrac, origin->x - origin->PrevX); viewy = origin->PrevY + FixedMul(r_TicFrac, origin->y - origin->PrevY); viewz = origin->PrevZ + FixedMul(r_TicFrac, origin->z - origin->PrevZ); @@ -663,7 +662,7 @@ void GLSkyboxPortal::DrawContents() GLRenderer->DrawScene(); origin->flags&=~MF_JUSTHIT; inskybox=false; - glEnable(GL_DEPTH_CLAMP); + gl_RenderState.SetDepthClamp(oldclamp); skyboxrecursion--; PlaneMirrorMode=old_pm; diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index a6ee502d5..f431e06a6 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -475,6 +475,7 @@ void GLSkyPortal::DrawContents() gl_RenderState.EnableFog(false); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + bool oldClamp = gl_RenderState.SetDepthClamp(true); gl_MatrixStack.Push(gl_RenderState.mViewMatrix); GLRenderer->SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); @@ -519,5 +520,6 @@ void GLSkyPortal::DrawContents() gl_MatrixStack.Pop(gl_RenderState.mViewMatrix); gl_RenderState.ApplyMatrices(); glset.lightmode = oldlightmode; + gl_RenderState.SetDepthClamp(oldClamp); } From 020b02e073c6a67f86dfe951c91a2f0b520aab3c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 28 Nov 2014 12:28:45 +0100 Subject: [PATCH 0264/1509] - changed deprecated texture sampler access function names. --- wadsrc/static/shaders/glsl/burn.fp | 4 ++-- wadsrc/static/shaders/glsl/func_brightmap.fp | 2 +- wadsrc/static/shaders/glsl/main.fp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wadsrc/static/shaders/glsl/burn.fp b/wadsrc/static/shaders/glsl/burn.fp index 4ab4cac95..f928fd8db 100644 --- a/wadsrc/static/shaders/glsl/burn.fp +++ b/wadsrc/static/shaders/glsl/burn.fp @@ -8,8 +8,8 @@ void main() { vec4 frag = vColor; - vec4 t1 = texture2D(tex, vTexCoord.xy); - vec4 t2 = texture2D(texture2, vec2(vTexCoord.x, 1.0-vTexCoord.y)); + vec4 t1 = texture(tex, vTexCoord.xy); + vec4 t2 = texture(texture2, vec2(vTexCoord.x, 1.0-vTexCoord.y)); FragColor = frag * vec4(t1.r, t1.g, t1.b, t2.a); } diff --git a/wadsrc/static/shaders/glsl/func_brightmap.fp b/wadsrc/static/shaders/glsl/func_brightmap.fp index bea336eb6..8e5f44d04 100644 --- a/wadsrc/static/shaders/glsl/func_brightmap.fp +++ b/wadsrc/static/shaders/glsl/func_brightmap.fp @@ -7,6 +7,6 @@ vec4 ProcessTexel() vec4 ProcessLight(vec4 color) { - vec4 brightpix = desaturate(texture2D(texture2, vTexCoord.st)); + vec4 brightpix = desaturate(texture(texture2, vTexCoord.st)); return vec4(min (color.rgb + brightpix.rgb, 1.0), color.a); } diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 41150fa20..90fab0e25 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -53,7 +53,7 @@ vec4 desaturate(vec4 texel) vec4 getTexel(vec2 st) { - vec4 texel = texture2D(tex, st); + vec4 texel = texture(tex, st); // // Apply texture modes From 717c82ee4a05bf00e78913635d53fd1cda5ea6db Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Dec 2014 09:58:23 +0100 Subject: [PATCH 0265/1509] - On Intel, we have to disable shader storage buffers because their complier contains a bug disallowing unsized arrays. --- src/gl/system/gl_interface.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 4541cfb18..fe27b419c 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -139,7 +139,11 @@ void gl_LoadExtensions() // Recent drivers, GL 4.4 don't have this problem, these can easily be recognized by also supporting the GL_ARB_buffer_storage extension. if (CheckExtension("GL_ARB_shader_storage_buffer_object")) { - gl.flags |= RFL_SHADER_STORAGE_BUFFER; + // Shader storage buffer objects are broken on current Intel drivers. + if (strstr(gl.vendorstring, "Intel") == NULL) + { + gl.flags |= RFL_SHADER_STORAGE_BUFFER; + } } gl.flags |= RFL_BUFFER_STORAGE; } From 0bc2c0094a90baef7bac15a068bb079336601ecc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 Dec 2014 16:35:34 +0100 Subject: [PATCH 0266/1509] - fixed: For cubemapped skies with one texture for all 4 sides the texture was never set before rendering. --- src/gl/scene/gl_skydome.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index f431e06a6..528c649b9 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -398,6 +398,9 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool else { faces=1; + tex = FMaterial::ValidateTexture(sb->faces[0], false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); + gl_RenderState.Apply(); ptr = GLRenderer->mVBO->GetBuffer(); ptr->Set(128.f, 128.f, -128.f, 0, 0); From ffa069205fa94de5bac2a8bbbe5f891bff2fd79b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 25 Dec 2014 18:30:34 +0100 Subject: [PATCH 0267/1509] - fixed: For fullbright sprites, a weapon's extra light must be ignored because it can be negative. --- src/gl/scene/gl_sprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 89ff9cdb9..e8d919a28 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -118,7 +118,7 @@ void GLSprite::Draw(int pass) bool additivefog = false; bool foglayer = false; - int rel = getExtraLight(); + int rel = fullbright? 0 : getExtraLight(); if (pass==GLPASS_TRANSLUCENT) { From c66a2112008de62d3c89dde570fbeeac26354252 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 25 Dec 2014 22:45:40 +0100 Subject: [PATCH 0268/1509] - fixed: The sky renderer must not only alter the light mode but also reset the software light level to a 'disabled' value. --- src/gl/scene/gl_skydome.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 528c649b9..e6f9efd38 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -471,7 +471,11 @@ void GLSkyPortal::DrawContents() // We have no use for Doom lighting special handling here, so disable it for this function. int oldlightmode = glset.lightmode; - if (glset.lightmode == 8) glset.lightmode = 2; + if (glset.lightmode == 8) + { + glset.lightmode = 2; + gl_RenderState.SetSoftLightLevel(-1); + } gl_RenderState.ResetColor(); From fbfe0f1e7a0f8de19070aa598000a833cbd6fdf7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Dec 2014 11:53:38 +0100 Subject: [PATCH 0269/1509] - fixed: y-clamped textures with negative scale need to shift their texture coordinates into the proper [0..1] range. --- src/gl/scene/gl_walls.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 2e784b857..1879515a4 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -606,8 +606,8 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto if (topright >= bottomright) { // normal case - ztop[1]=FIXED2FLOAT(topright) ; - zbottom[1]=FIXED2FLOAT(bottomright) ; + ztop[1]=FIXED2FLOAT(topright); + zbottom[1]=FIXED2FLOAT(bottomright); if (tci) { @@ -640,17 +640,25 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto uplft.u = lolft.u = l_ul + texlength * glseg.fracleft; uprgt.u = lorgt.u = l_ul + texlength * glseg.fracright; - - if (gltexture && gltexture->tex->bHasCanvas && flags&GLT_CLAMPY) + if (gltexture != NULL) { - // Camera textures are upside down so we have to shift the y-coordinate - // from [-1..0] to [0..1] when using texture clamping - - uplft.v+=1.f; - uprgt.v+=1.f; - lolft.v+=1.f; - lorgt.v+=1.f; + bool normalize = false; + if (gltexture->tex->bHasCanvas) normalize = true; + else if (flags & GLT_CLAMPY) + { + // for negative scales we can get negative coordinates here. + normalize = (uplft.v > lolft.v || uprgt.v > lorgt.v); + } + if (normalize) + { + // we have to shift the y-coordinate from [-1..0] to [0..1] when using texture clamping with a negative scale + uplft.v+=1.f; + uprgt.v+=1.f; + lolft.v+=1.f; + lorgt.v+=1.f; + } } + return true; } From 045725de158f5c4452726adf66715f286685f7e0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 29 Dec 2014 16:35:30 +0100 Subject: [PATCH 0270/1509] - use strncpy instead of sprintf tp init static char array to ensure that all elements get initialized. --- src/gl/dynlights/gl_dynlight.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index 6c6209664..f9349bdb2 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -102,7 +102,7 @@ public: FLightAssociation(FName actorName, const char *frameName, FName lightName) : m_ActorName(actorName), m_AssocLight(lightName) { - mysnprintf(m_FrameName, 8, "%s", frameName); + strncpy(m_FrameName, frameName, 8); } FName ActorName() { return m_ActorName; } From 45cf65afbd4f8b7e7dc35c9c374e5cc6f074eabe Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 29 Dec 2014 22:42:19 +0100 Subject: [PATCH 0271/1509] - moved the aspect ratio correction factor from the projection to the view matrix where it should have been from the start. - removed the mCameraPos variable in FGLRenderer because it was only used in one place where it is just as easy to use the global viewx/y/z variables directly. --- src/gl/renderer/gl_renderer.cpp | 1 - src/gl/renderer/gl_renderer.h | 5 ++--- src/gl/scene/gl_scene.cpp | 23 +++++++++++------------ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 9466e5fd0..7d8b36a42 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -90,7 +90,6 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mLightCount = 0; mAngles = FRotator(0,0,0); mViewVector = FVector2(0,0); - mCameraPos = FVector3(0,0,0); mVBO = NULL; mSkyVBO = NULL; gl_spriteindex = 0; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 0e5e99643..534745869 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -67,7 +67,6 @@ public: FRotator mAngles; FVector2 mViewVector; - FVector3 mCameraPos; FFlatVertexBuffer *mVBO; FSkyVertexBuffer *mSkyVBO; @@ -83,7 +82,7 @@ public: void SetViewport(GL_IRECT *bounds); sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen); void RenderView(player_t *player); - void SetCameraPos(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle); + void SetViewAngle(angle_t viewangle); void SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror); void Initialize(); @@ -121,7 +120,7 @@ public: void Flush() {} void SetProjection(float fov, float ratio, float fovratio); - void SetViewMatrix(bool mirror, bool planemirror); + void SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, bool mirror, bool planemirror); void ProcessScene(bool toscreen = false); bool StartOffscreen(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 395403690..189c3acc3 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -86,6 +86,7 @@ CVAR(Bool, gl_no_skyclear, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_sprite_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, gl_sort_textures, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Float, gl_aspect, 1.2f, 0) EXTERN_CVAR (Int, screenblocks) EXTERN_CVAR (Bool, cl_capfps) @@ -228,13 +229,12 @@ void FGLRenderer::SetViewport(GL_IRECT *bounds) // //----------------------------------------------------------------------------- -void FGLRenderer::SetCameraPos(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle) +void FGLRenderer::SetViewAngle(angle_t viewangle) { float fviewangle=(float)(viewangle>>ANGLETOFINESHIFT)*360.0f/FINEANGLES; mAngles.Yaw = 270.0f-fviewangle; mViewVector = FVector2(cos(DEG2RAD(fviewangle)), sin(DEG2RAD(fviewangle))); - mCameraPos = FVector3(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); R_SetViewAngle(); } @@ -261,16 +261,16 @@ void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) // //----------------------------------------------------------------------------- -void FGLRenderer::SetViewMatrix(bool mirror, bool planemirror) +void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, bool mirror, bool planemirror) { float mult = mirror? -1:1; - float planemult = planemirror? -1:1; + float planemult = planemirror? -gl_aspect:gl_aspect; gl_RenderState.mViewMatrix.loadIdentity(); gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll, 0.0f, 0.0f, 1.0f); gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Pitch, 1.0f, 0.0f, 0.0f); gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Yaw, 0.0f, mult, 0.0f); - gl_RenderState.mViewMatrix.translate( GLRenderer->mCameraPos.X * mult, -GLRenderer->mCameraPos.Z*planemult, -GLRenderer->mCameraPos.Y); + gl_RenderState.mViewMatrix.translate(FIXED2FLOAT(viewx) * mult, -FIXED2FLOAT(viewz) * planemult , -FIXED2FLOAT(viewy)); gl_RenderState.mViewMatrix.scale(-mult, planemult, 1); } @@ -283,8 +283,8 @@ void FGLRenderer::SetViewMatrix(bool mirror, bool planemirror) //----------------------------------------------------------------------------- void FGLRenderer::SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror) { - SetCameraPos(viewx, viewy, viewz, viewangle); - SetViewMatrix(mirror, planemirror); + SetViewAngle(viewangle); + SetViewMatrix(viewx, viewy, viewz, mirror, planemirror); gl_RenderState.ApplyMatrices(); } @@ -795,8 +795,8 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo SetViewport(bounds); mCurrentFoV = fov; SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper - SetCameraPos(viewx, viewy, viewz, viewangle); - SetViewMatrix(false, false); + SetViewAngle(viewangle); + SetViewMatrix(viewx, viewy, viewz, false, false); gl_RenderState.ApplyMatrices(); clipper.Clear(); @@ -851,16 +851,15 @@ void FGLRenderer::RenderView (player_t* player) // I stopped using BaseRatioSizes here because the information there wasn't well presented. - #define RMUL (1.6f/1.333333f) // 4:3 16:9 16:10 17:10 5:4 - static float ratios[]={RMUL*1.333333f, RMUL*1.777777f, RMUL*1.6f, RMUL*1.7f, RMUL*1.25f}; + static float ratios[]={1.333333f, 1.777777f, 1.6f, 1.7f, 1.25f}; // now render the main view float fovratio; float ratio = ratios[WidescreenRatio]; if (!(WidescreenRatio&4)) { - fovratio = 1.6f; + fovratio = 1.333333f; } else { From 315827015cb0d10780a4e22556d6d3ccdd8a626d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 29 Dec 2014 23:52:20 +0100 Subject: [PATCH 0272/1509] - made aspect ratio correction factor configurable through MAPINFO. --- src/gl/data/gl_data.cpp | 14 ++++++++++++++ src/gl/data/gl_data.h | 2 ++ src/gl/scene/gl_scene.cpp | 3 +-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 52166f0a8..6aa05c64a 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -212,6 +212,7 @@ struct FGLROptions : public FOptionalMapinfoData notexturefill = -1; skyrotatevector = FVector3(0,0,1); skyrotatevector2 = FVector3(0,0,1); + pixelstretch = 1.2f; } virtual FOptionalMapinfoData *Clone() const { @@ -225,6 +226,7 @@ struct FGLROptions : public FOptionalMapinfoData newopt->notexturefill = notexturefill; newopt->skyrotatevector = skyrotatevector; newopt->skyrotatevector2 = skyrotatevector2; + newopt->pixelstretch = pixelstretch; return newopt; } int fogdensity; @@ -236,6 +238,7 @@ struct FGLROptions : public FOptionalMapinfoData SBYTE notexturefill; FVector3 skyrotatevector; FVector3 skyrotatevector2; + float pixelstretch; }; DEFINE_MAP_OPTION(fogdensity, false) @@ -338,6 +341,15 @@ DEFINE_MAP_OPTION(skyrotate2, false) opt->skyrotatevector2.MakeUnit(); } +DEFINE_MAP_OPTION(pixelratio, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + + parse.ParseAssign(); + parse.sc.MustGetFloat(); + opt->pixelstretch = (float)parse.sc.Float; +} + bool IsLightmodeValid() { return (glset.map_lightmode >= 0 && glset.map_lightmode <= 4) || glset.map_lightmode == 8; @@ -356,6 +368,7 @@ void InitGLRMapinfoData() glset.map_notexturefill = opt->notexturefill; glset.skyrotatevector = opt->skyrotatevector; glset.skyrotatevector2 = opt->skyrotatevector2; + glset.pixelstretch = opt->pixelstretch; } else { @@ -366,6 +379,7 @@ void InitGLRMapinfoData() glset.map_notexturefill = -1; glset.skyrotatevector = FVector3(0,0,1); glset.skyrotatevector2 = FVector3(0,0,1); + glset.pixelstretch = 1.2f; } if (!IsLightmodeValid()) glset.lightmode = gl_lightmode; diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index 42b6df26e..ac2fe0285 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -20,6 +20,8 @@ struct GLRenderSettings FVector3 skyrotatevector; FVector3 skyrotatevector2; + float pixelstretch; + }; extern GLRenderSettings glset; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 189c3acc3..b1efbf830 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -86,7 +86,6 @@ CVAR(Bool, gl_no_skyclear, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_sprite_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, gl_sort_textures, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -CVAR(Float, gl_aspect, 1.2f, 0) EXTERN_CVAR (Int, screenblocks) EXTERN_CVAR (Bool, cl_capfps) @@ -264,7 +263,7 @@ void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, bool mirror, bool planemirror) { float mult = mirror? -1:1; - float planemult = planemirror? -gl_aspect:gl_aspect; + float planemult = planemirror? -glset.pixelstretch : glset.pixelstretch; gl_RenderState.mViewMatrix.loadIdentity(); gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll, 0.0f, 0.0f, 1.0f); From e6d59ec429b6196a5d3afc9ddff97bd93570fb8e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 31 Dec 2014 12:04:55 +0100 Subject: [PATCH 0273/1509] - fixed: with aspect ratio compensation in the view matrix it is necessary to adjust the view pitch for this because the playsim does not know anything about pixel ratio. --- src/gl/scene/gl_scene.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index b1efbf830..ef2889795 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -771,7 +771,17 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo sector_t * retval; R_SetupFrame (camera); SetViewArea(); - mAngles.Pitch = clamp((float)((double)(int)(viewpitch))/ANGLE_1, -90, 90); + + // We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1. + double radPitch = bam2rad(viewpitch); + if (radPitch > PI) radPitch -= 2 * PI; + radPitch = clamp(radPitch, -PI / 2, PI / 2); + + double angx = cos(radPitch); + double angy = sin(radPitch) * glset.pixelstretch; + double alen = sqrt(angx*angx + angy*angy); + + mAngles.Pitch = (float)RAD2DEG(asin(angy / alen)); // Scroll the sky mSky1Pos = (float)fmod(gl_frameMS * level.skyspeed1, 1024.f) * 90.f/256.f; From 4f08b20df5ae90966429074cd38cd35957823199 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 31 Dec 2014 12:53:29 +0100 Subject: [PATCH 0274/1509] - consider pixel stretching when rendering models. For non-voxels an aspect ratio of 1:1 must always be assumed while voxels need to be stretched so that 1 voxel unit == 1 map unit. --- src/gl/models/gl_models.cpp | 6 ++++++ src/gl/models/gl_models.h | 4 ++-- src/gl/models/gl_models_md2.cpp | 4 ---- src/gl/models/gl_models_md3.cpp | 2 +- src/gl/models/gl_voxels.cpp | 11 +++++++++++ 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 13a1ef9c3..bfbf21dd2 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -915,6 +915,12 @@ void gl_RenderModel(GLSprite * spr) gl_RenderState.mModelMatrix.rotate(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); gl_RenderState.mModelMatrix.rotate(smf->pitchoffset, 0, 0, 1); gl_RenderState.mModelMatrix.rotate(-smf->rolloffset, 1, 0, 0); + + // consider the pixel stretching. For non-voxels this must be factored out here + float stretch = (smf->models[0] != NULL ? smf->models[0]->getAspectFactor() : 1.f) / glset.pixelstretch; + gl_RenderState.mModelMatrix.scale(1, stretch, 1); + + gl_RenderState.EnableModelMatrix(true); gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), NULL, translation ); gl_RenderState.EnableModelMatrix(false); diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index b80a11df4..0d479b68c 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -11,8 +11,6 @@ enum { VX, VZ, VY }; -static const float rModelAspectMod = 1 / 1.2f; //.833334f; - #define MD2_MAGIC 0x32504449 #define DMD_MAGIC 0x4D444D44 #define MD3_MAGIC 0x33504449 @@ -35,6 +33,7 @@ public: virtual int FindFrame(const char * name) = 0; virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0; virtual void BuildVertexBuffer() = 0; + virtual float getAspectFactor() { return 1.f; } FModelVertexBuffer *mVBuf; FString mFileName; @@ -298,6 +297,7 @@ public: virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); FTexture *GetPaletteTexture() const { return mPalette; } void BuildVertexBuffer(); + float getAspectFactor(); }; diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index 21e24c768..402b20472 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -186,8 +186,6 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length) frame->vertices[k].xyz[axis[c]] = (pVtx->vertex[c] * FLOAT(pfr->scale[c]) + FLOAT(pfr->translate[c])); } - // Aspect undo. - frame->vertices[k].xyz[VZ] *= rModelAspectMod; } } @@ -467,8 +465,6 @@ bool FMD2Model::Load(const char * path, int, const char * buffer, int length) frame->vertices[k].xyz[axis[c]] = (pVtx->vertex[c] * pfr->scale[c] + pfr->translate[c]); } - // Aspect ratio adjustment (1.33 -> 1.6.) - frame->vertices[k].xyz[VZ] *= rModelAspectMod; } } diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index cdd8d7082..9cc72307c 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -200,7 +200,7 @@ bool FMD3Model::Load(const char * path, int, const char * buffer, int length) { s->vertices[i].x = LittleShort(vt[i].x)/64.f; s->vertices[i].y = LittleShort(vt[i].y)/64.f; - s->vertices[i].z = LittleShort(vt[i].z)/64.f * rModelAspectMod; + s->vertices[i].z = LittleShort(vt[i].z)/64.f; UnpackVector( LittleShort(vt[i].n), s->vertices[i].nx, s->vertices[i].ny, s->vertices[i].nz); } } diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 62377c681..c092f9dd7 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -420,6 +420,17 @@ int FVoxelModel::FindFrame(const char * name) return 0; } +//=========================================================================== +// +// Voxels need aspect ratio correction according to the current map's setting +// +//=========================================================================== + +float FVoxelModel::getAspectFactor() +{ + return glset.pixelstretch; +} + //=========================================================================== // // Voxels never interpolate between frames, they only have one. From a8398e70b01dcca803d663d8db807f9c81eeed37 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 31 Dec 2014 23:01:06 +0100 Subject: [PATCH 0275/1509] - fixed: The brightfog flag in the GL related map settings was never initialized. - fixed: brightfog should not disable colored lighting for the weapon sprite. --- src/gl/data/gl_data.cpp | 1 + src/gl/scene/gl_weapon.cpp | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 6aa05c64a..735ef0439 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -207,6 +207,7 @@ struct FGLROptions : public FOptionalMapinfoData fogdensity = 0; outsidefogdensity = 0; skyfog = 0; + brightfog = false; lightmode = -1; nocoloredspritelighting = -1; notexturefill = -1; diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 67950ce0e..42397166b 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -279,11 +279,10 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) } - // Korshun: fullbright fog in opengl, render weapon sprites fullbright. + // Korshun: fullbright fog in opengl, render weapon sprites fullbright (but don't cancel out the light color!) if (glset.brightfog && ((level.flags&LEVEL_HASFADETABLE) || cm.FadeColor != 0)) { lightlevel = 255; - statebright[0] = statebright[1] = true; } PalEntry ThingColor = (playermo->RenderStyle.Flags & STYLEF_ColorIsFixed) ? playermo->fillcolor : 0xffffff; From c9150497e3472e1057ed8286237fcf07106a075d Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Wed, 7 Jan 2015 21:07:40 +0100 Subject: [PATCH 0276/1509] - Move sdlglvideo code from sdl to posix/sdl. Re-add sdlglvideo.cpp path in CMakeLists.txt . Warning: it won't compile yet. --- src/CMakeLists.txt | 6 ++---- src/{ => posix}/sdl/sdlglvideo.cpp | 0 src/{ => posix}/sdl/sdlglvideo.h | 0 3 files changed, 2 insertions(+), 4 deletions(-) rename src/{ => posix}/sdl/sdlglvideo.cpp (100%) rename src/{ => posix}/sdl/sdlglvideo.h (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4803006c2..3edcbaf5d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -584,13 +584,11 @@ set( PLAT_SDL_SOURCES posix/sdl/i_joystick.cpp posix/sdl/i_main.cpp posix/sdl/i_timer.cpp - posix/sdl/sdlvideo.cpp ) + posix/sdl/sdlvideo.cpp + posix/sdl/sdlglvideo.cpp ) set( PLAT_OSX_SOURCES posix/osx/iwadpicker_cocoa.mm posix/osx/zdoom.icns ) - -# Fixme: This must be adjusted to the new way of doing things: -# sdl/sdlglvideo.cpp set( PLAT_COCOA_SOURCES posix/cocoa/hid/HID_Config_Utilities.c posix/cocoa/hid/HID_Error_Handler.c diff --git a/src/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp similarity index 100% rename from src/sdl/sdlglvideo.cpp rename to src/posix/sdl/sdlglvideo.cpp diff --git a/src/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h similarity index 100% rename from src/sdl/sdlglvideo.h rename to src/posix/sdl/sdlglvideo.h From 37321d1d483cee0c01285774921fb861bd6f9c1e Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Thu, 8 Jan 2015 00:23:14 +0100 Subject: [PATCH 0277/1509] - Implement SDL2 into GZDoom (needs improvements). Make also minor fixes. Now it compiles and runs fine for me, except for the invisible cursor in the menu (no idea why). --- src/posix/sdl/sdlglvideo.cpp | 67 +++++++++++++++++++++--------------- src/posix/sdl/sdlglvideo.h | 9 ++--- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 649989e6d..9331c0f02 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -1,8 +1,6 @@ // HEADER FILES ------------------------------------------------------------ -#include - #include "doomtype.h" #include "templates.h" @@ -48,6 +46,7 @@ extern IVideo *Video; // extern int vid_renderer; EXTERN_CVAR (Float, Gamma) +EXTERN_CVAR (Int, vid_adapter) EXTERN_CVAR (Int, vid_displaybits) EXTERN_CVAR (Int, vid_renderer) @@ -156,14 +155,19 @@ bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox) } else { - SDL_Rect **modes = SDL_ListModes (NULL, SDL_FULLSCREEN|SDL_HWSURFACE); - if (modes != NULL && modes[IteratorMode] != NULL) + SDL_DisplayMode mode = {}, oldmode = {}; + if(IteratorMode != 0) + SDL_GetDisplayMode(vid_adapter, IteratorMode-1, &oldmode); + do { - *width = modes[IteratorMode]->w; - *height = modes[IteratorMode]->h; + if (SDL_GetDisplayMode(vid_adapter, IteratorMode, &mode) != 0) + return false; ++IteratorMode; - return true; - } + } while(mode.w == oldmode.w && mode.h == oldmode.h); + + *width = mode.w; + *height = mode.h; + return true; } return false; } @@ -182,11 +186,11 @@ DFrameBuffer *SDLGLVideo::CreateFrameBuffer (int width, int height, bool fullscr if (fb->Width == width && fb->Height == height) { - bool fsnow = (fb->Screen->flags & SDL_FULLSCREEN) != 0; + bool fsnow = (SDL_GetWindowFlags (fb->Screen) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0; if (fsnow != fullscreen) { - SDL_WM_ToggleFullScreen (fb->Screen); + SDL_SetWindowFullscreen (fb->Screen, fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); } return old; } @@ -336,30 +340,37 @@ SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen) return; } - - Screen = SDL_SetVideoMode (width, height, - 32, - SDL_HWSURFACE|SDL_HWPALETTE|SDL_OPENGL | SDL_GL_DOUBLEBUFFER|SDL_ANYFORMAT| - (fullscreen ? SDL_FULLSCREEN : 0)); + FString caption; + caption.Format(GAMESIG " %s (%s)", GetVersionString(), GetGitTime()); + Screen = SDL_CreateWindow (caption, + SDL_WINDOWPOS_UNDEFINED_DISPLAY(vid_adapter), SDL_WINDOWPOS_UNDEFINED_DISPLAY(vid_adapter), + width, height, (fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0)|SDL_WINDOW_OPENGL); if (Screen == NULL) return; - m_supportsGamma = -1 != SDL_GetGammaRamp(m_origGamma[0], m_origGamma[1], m_origGamma[2]); - -#if defined(__APPLE__) - // Need to set title here because a window is not created yet when calling the same function from main() - char caption[100]; - mysnprintf(caption, countof(caption), GAMESIG " %s (%s)", GetVersionString(), GetGitTime()); - SDL_WM_SetCaption(caption, NULL); -#endif // __APPLE__ + GLContext = SDL_GL_CreateContext(Screen); + if (GLContext == NULL) + return; + + m_supportsGamma = -1 != SDL_GetWindowGammaRamp(Screen, m_origGamma[0], m_origGamma[1], m_origGamma[2]); } SDLGLFB::~SDLGLFB () { - if (m_supportsGamma) + if (Screen) { - SDL_SetGammaRamp(m_origGamma[0], m_origGamma[1], m_origGamma[2]); + if (m_supportsGamma) + { + SDL_SetWindowGammaRamp(Screen, m_origGamma[0], m_origGamma[1], m_origGamma[2]); + } + + if (GLContext) + { + SDL_GL_DeleteContext(GLContext); + } + + SDL_DestroyWindow(Screen); } } @@ -386,7 +397,7 @@ bool SDLGLFB::CanUpdate () void SDLGLFB::SetGammaTable(WORD *tbl) { - SDL_SetGammaRamp(&tbl[0], &tbl[256], &tbl[512]); + SDL_SetWindowGammaRamp(Screen, &tbl[0], &tbl[256], &tbl[512]); } bool SDLGLFB::Lock(bool buffered) @@ -420,7 +431,7 @@ bool SDLGLFB::IsLocked () bool SDLGLFB::IsFullscreen () { - return (Screen->flags & SDL_FULLSCREEN) != 0; + return (SDL_GetWindowFlags (Screen) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0; } @@ -443,6 +454,6 @@ void SDLGLFB::NewRefreshRate () void SDLGLFB::SwapBuffers() { - SDL_GL_SwapBuffers (); + SDL_GL_SwapWindow (Screen); } diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h index 205e416c0..3867be69c 100644 --- a/src/posix/sdl/sdlglvideo.h +++ b/src/posix/sdl/sdlglvideo.h @@ -3,7 +3,6 @@ #include "hardware.h" #include "v_video.h" -#include #include "gl/system/gl_system.h" EXTERN_CVAR (Float, dimamount) @@ -70,9 +69,11 @@ protected: SDLGLFB () {} BYTE GammaTable[3][256]; bool UpdatePending; - - SDL_Surface *Screen; - + + SDL_Window *Screen; + + SDL_GLContext GLContext; + void UpdateColors (); int m_Lock; From cab509c4d20f0e5e57099d24792a853a7adaa326 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Thu, 8 Jan 2015 01:39:29 +0100 Subject: [PATCH 0278/1509] Various improvements to SDL2 video code. - Ported the missing resolutions from zdoom. - Remove unneeded code which was removed also from zdoom. - Uncomment DOUBLEBUFFER GL attribute. It was present in the old SDL_SetVideoMode call code, so why not. --- src/posix/sdl/sdlglvideo.cpp | 60 +++++++++++++++--------------------- src/posix/sdl/sdlglvideo.h | 1 - 2 files changed, 25 insertions(+), 36 deletions(-) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 9331c0f02..54506b813 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -77,6 +77,7 @@ static MiniModeInfo WinModes[] = { 720, 480 }, // 16:10 { 720, 540 }, { 800, 450 }, // 16:9 + { 800, 480 }, { 800, 500 }, // 16:10 { 800, 600 }, { 848, 480 }, // 16:9 @@ -91,23 +92,33 @@ static MiniModeInfo WinModes[] = { 1152, 720 }, // 16:10 { 1152, 864 }, { 1280, 720 }, // 16:9 + { 1280, 854 }, { 1280, 800 }, // 16:10 { 1280, 960 }, - { 1344, 756 }, // 16:9 + { 1280, 1024 }, // 5:4 { 1360, 768 }, // 16:9 + { 1366, 768 }, { 1400, 787 }, // 16:9 { 1400, 875 }, // 16:10 - { 1440, 900 }, { 1400, 1050 }, + { 1440, 900 }, + { 1440, 960 }, + { 1440, 1080 }, { 1600, 900 }, // 16:9 { 1600, 1000 }, // 16:10 { 1600, 1200 }, - { 1680, 1050 }, // 16:10 - { 1920, 1080 }, // 16:9 - { 1920, 1200 }, // 16:10 - { 2054, 1536 }, - { 2560, 1440 }, // 16:9 - { 2880, 1800 } // 16:10 + { 1920, 1080 }, + { 1920, 1200 }, + { 2048, 1536 }, + { 2560, 1440 }, + { 2560, 1600 }, + { 2560, 2048 }, + { 2880, 1800 }, + { 3200, 1800 }, + { 3840, 2160 }, + { 3840, 2400 }, + { 4096, 2160 }, + { 5120, 2880 } }; // CODE -------------------------------------------------------------------- @@ -115,7 +126,6 @@ static MiniModeInfo WinModes[] = SDLGLVideo::SDLGLVideo (int parm) { IteratorBits = 0; - IteratorFS = false; if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { fprintf( stderr, "Video initialization failed: %s\n", SDL_GetError( ) ); @@ -135,38 +145,18 @@ void SDLGLVideo::StartModeIterator (int bits, bool fs) { IteratorMode = 0; IteratorBits = bits; - IteratorFS = fs; } bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox) { if (IteratorBits != 8) return false; - - if (!IteratorFS) - { - if ((unsigned)IteratorMode < sizeof(WinModes)/sizeof(WinModes[0])) - { - *width = WinModes[IteratorMode].Width; - *height = WinModes[IteratorMode].Height; - ++IteratorMode; - return true; - } - } - else - { - SDL_DisplayMode mode = {}, oldmode = {}; - if(IteratorMode != 0) - SDL_GetDisplayMode(vid_adapter, IteratorMode-1, &oldmode); - do - { - if (SDL_GetDisplayMode(vid_adapter, IteratorMode, &mode) != 0) - return false; - ++IteratorMode; - } while(mode.w == oldmode.w && mode.h == oldmode.h); - *width = mode.w; - *height = mode.h; + if ((unsigned)IteratorMode < sizeof(WinModes)/sizeof(WinModes[0])) + { + *width = WinModes[IteratorMode].Width; + *height = WinModes[IteratorMode].Height; + ++IteratorMode; return true; } return false; @@ -294,7 +284,7 @@ bool SDLGLVideo::SetupPixelFormat(bool allowsoftware, int multisample) SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); -// SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); if (multisample > 0) { SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample ); diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h index 3867be69c..c2be3ba47 100644 --- a/src/posix/sdl/sdlglvideo.h +++ b/src/posix/sdl/sdlglvideo.h @@ -32,7 +32,6 @@ class SDLGLVideo : public IVideo private: int IteratorMode; int IteratorBits; - bool IteratorFS; }; class SDLGLFB : public DFrameBuffer { From fb3bf0eb5868742d1771834588a4bbf3c888ac7d Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Thu, 8 Jan 2015 13:18:00 +0100 Subject: [PATCH 0279/1509] - Oops, forgot to reinclude missing SDL header. Strangely it compiled fine for me, though. --- src/posix/sdl/sdlglvideo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h index c2be3ba47..19e6a5ff5 100644 --- a/src/posix/sdl/sdlglvideo.h +++ b/src/posix/sdl/sdlglvideo.h @@ -3,6 +3,7 @@ #include "hardware.h" #include "v_video.h" +#include #include "gl/system/gl_system.h" EXTERN_CVAR (Float, dimamount) From d4d041d5fc5111433939961679a2eb2613f53632 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Jan 2015 18:44:55 +0100 Subject: [PATCH 0280/1509] - fixed: FMaterial::ValidateTexture must determine whether to expand sprites before actually constructing the FMaterial object. --- src/gl/textures/gl_material.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 6b22e0a5e..eca7c66c5 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -413,19 +413,16 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) if (tx->bWarped) { mShaderIndex = tx->bWarped; - expanded = false; tx->gl_info.shaderspeed = static_cast(tx)->GetSpeed(); } else if (tx->bHasCanvas) { - expanded = false; } else { if (tx->gl_info.shaderindex >= FIRST_USER_SHADER) { mShaderIndex = tx->gl_info.shaderindex; - expanded = false; } else { @@ -439,7 +436,6 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) } } } - assert(tx->gl_info.Material[expanded] == NULL); mBaseLayer = ValidateSysTexture(tx, true); @@ -765,6 +761,10 @@ FMaterial * FMaterial::ValidateTexture(FTexture * tex, bool expand) FMaterial *gltex = tex->gl_info.Material[expand]; if (gltex == NULL) { + if (tex->bWarped || tex->bHasCanvas || tex->gl_info.shaderindex >= FIRST_USER_SHADER) + { + expand = false; + } gltex = new FMaterial(tex, expand); } return gltex; From a578ff5d06991e70262e1fa516dd4582c0fb0e92 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Jan 2015 13:13:54 +0100 Subject: [PATCH 0281/1509] - fixed a problem with some older AMD drivers: Normally calling glBindBufferBase should imply a call to glBindBuffer, but on these drivers it was never done, which resulted in the light uniform buffer never being created... --- src/gl/dynlights/gl_lightbuffer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index 979cbff77..4fd3b985a 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -70,6 +70,7 @@ FLightBuffer::FLightBuffer() glGenBuffers(1, &mBufferId); glBindBufferBase(mBufferType, LIGHTBUF_BINDINGPOINT, mBufferId); + glBindBuffer(mBufferType, mBufferId); // Note: Some older AMD drivers don't do that in glBindBufferBase, as they should. if (gl.flags & RFL_BUFFER_STORAGE) { glBufferStorage(mBufferType, mByteSize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); @@ -144,6 +145,7 @@ int FLightBuffer::UploadLights(FDynLightData &data) // create and bind the new buffer, bind the old one to a copy target (too bad that DSA is not yet supported well enough to omit this crap.) glGenBuffers(1, &newbuffer); glBindBufferBase(mBufferType, LIGHTBUF_BINDINGPOINT, newbuffer); + glBindBuffer(mBufferType, newbuffer); // Note: Some older AMD drivers don't do that in glBindBufferBase, as they should. glBindBuffer(GL_COPY_READ_BUFFER, mBufferId); // create the new buffer's storage (twice as large as the old one) From 1c375c9100f9132273503e0afcc3def41f440246 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Jan 2015 13:30:45 +0100 Subject: [PATCH 0282/1509] - cleanup and fixing of ALoreShot::DoSpecialDamage. --- src/g_strife/a_loremaster.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/g_strife/a_loremaster.cpp b/src/g_strife/a_loremaster.cpp index d720b7b9b..38cadab34 100644 --- a/src/g_strife/a_loremaster.cpp +++ b/src/g_strife/a_loremaster.cpp @@ -14,27 +14,27 @@ class ALoreShot : public AActor { DECLARE_CLASS (ALoreShot, AActor) public: - int DoSpecialDamage (AActor *target, int damage, FName damagetype); + int DoSpecialDamage (AActor *victim, int damage, FName damagetype); }; IMPLEMENT_CLASS (ALoreShot) -int ALoreShot::DoSpecialDamage (AActor *target, int damage, FName damagetype) +int ALoreShot::DoSpecialDamage (AActor *victim, int damage, FName damagetype) { FVector3 thrust; - if (this->target != NULL && !(this->target->flags7 & MF7_DONTTHRUST)) + if (victim != NULL && target != NULL && !(victim->flags7 & MF7_DONTTHRUST)) { - thrust.X = float(this->target->x - target->x); - thrust.Y = float(this->target->y - target->y); - thrust.Z = float(this->target->z - target->z); + thrust.X = float(target->x - victim->x); + thrust.Y = float(target->y - victim->y); + thrust.Z = float(target->z - victim->z); thrust.MakeUnit(); - thrust *= float((255*50*FRACUNIT) / (target->Mass ? target->Mass : 1)); + thrust *= float((255*50*FRACUNIT) / (victim->Mass ? target->Mass : 1)); - target->velx += fixed_t(thrust.X); - target->vely += fixed_t(thrust.Y); - target->velz += fixed_t(thrust.Z); + victim->velx += fixed_t(thrust.X); + victim->vely += fixed_t(thrust.Y); + victim->velz += fixed_t(thrust.Z); } return damage; } From 8a9692c29f0d5706c1ffd41886fd94f5d20d28b0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Feb 2015 20:16:25 +0100 Subject: [PATCH 0283/1509] - fixed: The code which decided whether to clamp two sided middle textures used the texture size instead of the render size for the specific linedef, meaning that any per-sidedef scaling was ignored. --- src/gl/scene/gl_walls.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 1879515a4..d192bf36f 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -786,12 +786,12 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, if ( (seg->linedef->flags & ML_DONTPEGBOTTOM) >0) { texturebottom = MAX(realfront->GetPlaneTexZ(sector_t::floor),realback->GetPlaneTexZ(sector_t::floor))+rowoffset; - texturetop=texturebottom+(gltexture->TextureHeight()<GetPlaneTexZ(sector_t::ceiling),realback->GetPlaneTexZ(sector_t::ceiling))+rowoffset; - texturebottom=texturetop-(gltexture->TextureHeight()<>FRACBITS)+seg->sidedef->TexelLength; - if ((textureoffset==0 && righttex<=gltexture->TextureWidth()) || - (textureoffset>=0 && righttex==gltexture->TextureWidth())) + if ((textureoffset == 0 && righttex <= tci.mRenderWidth) || + (textureoffset >= 0 && righttex == tci.mRenderWidth)) { - flags|=GLT_CLAMPX; + flags |= GLT_CLAMPX; } else { @@ -1420,7 +1420,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) sector_t * realback; #ifdef _DEBUG - if (seg->linedef-lines==1276) + if (seg->linedef-lines==4) { int a = 0; } From 962fc64d2b144115a38f60d1bdc32a8dfa58c366 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Feb 2015 20:27:09 +0100 Subject: [PATCH 0284/1509] - updated video menu in menudef.z. --- wadsrc/static/menudef.z | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index d3394fc96..57dd1da40 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -214,8 +214,10 @@ OptionMenu "VideoOptions" Option "Blood Type", "cl_bloodtype", "BloodTypes" Option "Bullet Puff Type", "cl_pufftype", "PuffTypes" Slider "Number of particles", "r_maxparticles", 100, 10000, 100, 0 + Slider "Number of decals", "cl_maxdecals", 0, 10000, 100, 0 Option "Show player sprites", "r_drawplayersprites", "OnOff" Option "Death camera", "r_deathcamera", "OnOff" Option "Teleporter zoom", "telezoom", "OnOff" + Slider "Earthquake shake intensity", "r_quakeintensity", 0.0, 1.0, 0.05, 2 Option "Interpolate monster movement", "nomonsterinterpolation", "NoYes" } From 00639121c075066dc7626b282ccc5a0ff6faea35 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Feb 2015 20:34:10 +0100 Subject: [PATCH 0285/1509] - added the missed parts of camera roll in gl_scene.cpp. --- src/gl/scene/gl_scene.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index ef2889795..3d716e215 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -782,6 +782,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo double alen = sqrt(angx*angx + angy*angy); mAngles.Pitch = (float)RAD2DEG(asin(angy / alen)); + mAngles.Roll = (float)(camera->roll>>ANGLETOFINESHIFT)*360.0f/FINEANGLES; // Scroll the sky mSky1Pos = (float)fmod(gl_frameMS * level.skyspeed1, 1024.f) * 90.f/256.f; From a5a53c51e6d98b42bda870317b22db5b6c4f311c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Feb 2015 21:52:19 +0100 Subject: [PATCH 0286/1509] - fixed: The flat drawing code assumed that the first element of the light list originated from the sector itself. This had been true formerly but in some situations it no longer is. --- src/gl/scene/gl_flats.cpp | 2 +- src/p_3dfloors.cpp | 4 ++++ src/p_3dfloors.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index b0533ceb5..78d9b44bd 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -546,7 +546,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) if (x.ffloors.Size()) { light = P_GetPlaneLight(sector, &frontsector->floorplane, false); - if ((!(sector->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING) || light!=&x.lightlist[0]) + if ((!(sector->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING) || !light->fromsector) && (light->p_lightlevel != &frontsector->lightlevel)) { lightlevel = *light->p_lightlevel; diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index cad1f16fa..da72bc171 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -584,6 +584,7 @@ void P_Recalculate3DFloors(sector_t * sector) lightlist[0].extra_colormap = sector->ColorMap; lightlist[0].blend = 0; lightlist[0].flags = 0; + lightlist[0].fromsector = true; maxheight = sector->CenterCeiling(); minheight = sector->CenterFloor(); @@ -605,6 +606,7 @@ void P_Recalculate3DFloors(sector_t * sector) newlight.extra_colormap = rover->GetColormap(); newlight.blend = rover->GetBlend(); newlight.flags = rover->flags; + newlight.fromsector = false; lightlist.Push(newlight); } else if (i==0) @@ -619,6 +621,7 @@ void P_Recalculate3DFloors(sector_t * sector) lightlist[0].extra_colormap = rover->GetColormap(); lightlist[0].blend = rover->GetBlend(); lightlist[0].flags = rover->flags; + lightlist[0].fromsector = false; } } if (rover->flags&FF_DOUBLESHADOW) @@ -643,6 +646,7 @@ void P_Recalculate3DFloors(sector_t * sector) newlight.blend = 0; } newlight.flags = rover->flags; + newlight.fromsector = false; lightlist.Push(newlight); } } diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index 8d42560af..4321ad0e5 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -123,6 +123,7 @@ struct lightlist_t int flags; F3DFloor* lightsource; F3DFloor* caster; + bool fromsector; }; From c6cb8493eab6d288619d56b840d51e2bf294fa8b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Feb 2015 23:07:14 +0100 Subject: [PATCH 0287/1509] - missed a menu option. --- wadsrc/static/menudef.z | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 57dd1da40..1dd676d50 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -197,6 +197,7 @@ OptionMenu "VideoOptions" Slider "Contrast", "vid_contrast", 0.1, 3.0, 0.1 Option "Vertical Sync", "vid_vsync", "OnOff" + Option "Rendering Interpolation", "cl_capfps", "OffOn" StaticText " " Option "Screen wipe style", "wipetype", "Wipes" From fad3a54100fb216f512b4aeef06468afedd91f14 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Mar 2015 12:10:22 +0100 Subject: [PATCH 0288/1509] - fixed positioning for sky textures that are less than 128 pixels tall. --- src/gl/scene/gl_skydome.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index e6f9efd38..59b0f634d 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -278,7 +278,14 @@ void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, in float xscale = 1024.f / float(texw); float yscale = 1.f; - if (texh < 200) + if (texh < 128) + { + // smaller sky textures must be tiled. We restrict it to 128 sky pixels, though + gl_RenderState.mModelMatrix.translate(0.f, -1250.f, 0.f); + gl_RenderState.mModelMatrix.scale(1.f, 128/230.f, 1.f); + yscale = 128 / texh; // intentionally left as integer. + } + else if (texh < 200) { gl_RenderState.mModelMatrix.translate(0.f, -1250.f, 0.f); gl_RenderState.mModelMatrix.scale(1.f, texh/230.f, 1.f); From 7701d54b1fe378f09c16353b9d73a7a93deff6a6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Mar 2015 12:24:28 +0100 Subject: [PATCH 0289/1509] - fixed: associated dynamic lights took the sprite/frame info from the actor's current state instead of from the actor's current sprite and frame, which may differ in case some placeholder sprite is used in the state. --- src/gl/dynlights/gl_dynlight.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index f9349bdb2..f143a479b 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -1113,8 +1113,8 @@ void gl_SetActorLights(AActor *actor) ADynamicLight *lights, *tmpLight; unsigned int i; - int sprite = actor->state->sprite; - int frame = actor->state->GetFrame(); + int sprite = actor->sprite; + int frame = actor->frame; lights = tmpLight = NULL; From 1e9a6e667e4b6e620b7f3a8a1e20638f20ec7d8f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 1 Apr 2015 11:59:41 +0200 Subject: [PATCH 0290/1509] - GL code adjustments for reworked precaching. --- src/gl/system/gl_framebuffer.cpp | 4 ++-- src/gl/textures/gl_skyboxtexture.cpp | 17 ----------------- src/gl/textures/gl_skyboxtexture.h | 1 - src/gl/textures/gl_texture.cpp | 4 ++-- 4 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index d9f05bea6..38de87cae 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -332,7 +332,7 @@ void OpenGLFrameBuffer::GetHitlist(BYTE *hitlist) // check skybox textures and mark the separate faces as used for(int i=0;igl_info.bSkybox) @@ -343,7 +343,7 @@ void OpenGLFrameBuffer::GetHitlist(BYTE *hitlist) if (sb->faces[i]) { int index = sb->faces[i]->id.GetIndex(); - hitlist[index] |= 1; + hitlist[index] |= FTextureManager::HIT_Flat; } } } diff --git a/src/gl/textures/gl_skyboxtexture.cpp b/src/gl/textures/gl_skyboxtexture.cpp index 71f5be8f4..c86556ea9 100644 --- a/src/gl/textures/gl_skyboxtexture.cpp +++ b/src/gl/textures/gl_skyboxtexture.cpp @@ -132,23 +132,6 @@ void FSkyBox::Unload () // //----------------------------------------------------------------------------- -void FSkyBox::PrecacheGL(int cache) -{ - for (int i = 0; i < 6; i++) - { - if (faces[i]) - { - faces[i]->PrecacheGL(cache); - } - } -} - -//----------------------------------------------------------------------------- -// -// -// -//----------------------------------------------------------------------------- - void gl_ParseSkybox(FScanner &sc) { int facecount=0; diff --git a/src/gl/textures/gl_skyboxtexture.h b/src/gl/textures/gl_skyboxtexture.h index ce58308a1..28a052be9 100644 --- a/src/gl/textures/gl_skyboxtexture.h +++ b/src/gl/textures/gl_skyboxtexture.h @@ -21,7 +21,6 @@ public: int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf); bool UseBasePalette(); void Unload (); - void PrecacheGL(int cache); void SetSize() { diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 8b314f02f..27a489162 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -320,12 +320,12 @@ void FTexture::PrecacheGL(int cache) { if (gl_precache) { - if (cache & 2) + if (cache & (FTextureManager::HIT_Wall | FTextureManager::HIT_Flat | FTextureManager::HIT_Sky)) { FMaterial * gltex = FMaterial::ValidateTexture(this, false); if (gltex) gltex->Precache(); } - if (cache & 4) + if (cache & FTextureManager::HIT_Sprite) { FMaterial * gltex = FMaterial::ValidateTexture(this, true); if (gltex) gltex->Precache(); From 48e21f6759b4dfb5bb17a29dd1088c0fc13e6d02 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 1 Apr 2015 12:08:42 +0200 Subject: [PATCH 0291/1509] - consider MBF sky transfers when checking for skybox precaching. --- src/gl/system/gl_framebuffer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 38de87cae..7a3fef1a3 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -332,7 +332,8 @@ void OpenGLFrameBuffer::GetHitlist(BYTE *hitlist) // check skybox textures and mark the separate faces as used for(int i=0;igl_info.bSkybox) From a65c9bec40b27d9493fe116c53c63532362cd869 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 4 Apr 2015 10:37:31 +0200 Subject: [PATCH 0292/1509] - move video options override out of menudef.z. This is to allow easier merging with future ZDoom changes It was done this way only to avoid having to deal with SVN's poor merging capabilities but with Git this is no longer an issue. The OpenGL submenus will remain where they are, though. --- wadsrc/static/menudef.txt | 16 +++++++++++-- wadsrc/static/menudef.z | 47 --------------------------------------- 2 files changed, 14 insertions(+), 49 deletions(-) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 07f841545..42d84852a 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -656,17 +656,29 @@ OptionValue Fuzziness 2.0, "Shadow" } +OptionMenu "OpenGLOptions" +{ + Title "OPENGL OPTIONS" + Submenu "Dynamic Light Options", "GLLightOptions" + Submenu "Texture Options", "GLTextureGLOptions" + Submenu "Preferences", "GLPrefOptions" +} + OptionMenu "VideoOptions" { Title "DISPLAY OPTIONS" + Submenu "OpenGL Options", "OpenGLOptions" Submenu "Scoreboard Options", "ScoreboardOptions" StaticText " " Slider "Screen size", "screenblocks", 3.0, 12.0, 1.0, 0 - Slider "Brightness", "Gamma", 0.75, 3.0, 0.05, 2 + + Slider "Gamma correction", "Gamma", 0.75, 3.0, 0.05, 2 + Slider "Brightness", "vid_brightness", -0.8,0.8, 0.05 + Slider "Contrast", "vid_contrast", 0.1, 3.0, 0.1 + Option "Vertical Sync", "vid_vsync", "OnOff" Option "Rendering Interpolation", "cl_capfps", "OffOn" - Option "Column render mode", "r_columnmethod", "ColumnMethods" StaticText " " Option "Screen wipe style", "wipetype", "Wipes" diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 1dd676d50..75ea1bf5f 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -175,50 +175,3 @@ OptionMenu "GLPrefOptions" Option "Rendering quality", gl_render_precise, "Precision" } -OptionMenu "OpenGLOptions" -{ - Title "OPENGL OPTIONS" - Submenu "Dynamic Light Options", "GLLightOptions" - Submenu "Texture Options", "GLTextureGLOptions" - Submenu "Preferences", "GLPrefOptions" -} - -OptionMenu "VideoOptions" -{ - Title "DISPLAY OPTIONS" - - Submenu "OpenGL Options", "OpenGLOptions" - Submenu "Scoreboard Options", "ScoreboardOptions" - StaticText " " - Slider "Screen size", "screenblocks", 3.0, 12.0, 1.0, 0 - - Slider "Gamma correction", "Gamma", 0.75, 3.0, 0.05, 2 - Slider "Brightness", "vid_brightness", -0.8,0.8, 0.05 - Slider "Contrast", "vid_contrast", 0.1, 3.0, 0.1 - - Option "Vertical Sync", "vid_vsync", "OnOff" - Option "Rendering Interpolation", "cl_capfps", "OffOn" - - StaticText " " - Option "Screen wipe style", "wipetype", "Wipes" - - IfOption(Windows) - { - Option "Show ENDOOM screen", "showendoom", "Endoom" - } - - Option "Stretch short skies", "r_stretchsky", "OnOff" - Option "Use fuzz effect", "r_drawfuzz", "Fuzziness" - Slider "Lost Soul translucency", "transsouls", 0.25, 1.0, 0.05, 2 - Option "Use fake contrast", "r_fakecontrast", "Contrast" - Option "Rocket Trails", "cl_rockettrails", "RocketTrailTypes" - Option "Blood Type", "cl_bloodtype", "BloodTypes" - Option "Bullet Puff Type", "cl_pufftype", "PuffTypes" - Slider "Number of particles", "r_maxparticles", 100, 10000, 100, 0 - Slider "Number of decals", "cl_maxdecals", 0, 10000, 100, 0 - Option "Show player sprites", "r_drawplayersprites", "OnOff" - Option "Death camera", "r_deathcamera", "OnOff" - Option "Teleporter zoom", "telezoom", "OnOff" - Slider "Earthquake shake intensity", "r_quakeintensity", 0.0, 1.0, 0.05, 2 - Option "Interpolate monster movement", "nomonsterinterpolation", "NoYes" -} From b0c0012d60b584d944528629a96f7c5384676539 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 4 Apr 2015 10:42:44 +0200 Subject: [PATCH 0293/1509] - add dynamic lights to editor number table and remove them from DECORATE definitions. --- wadsrc/static/decorate.z | 36 ++++++++++++++++---------------- wadsrc/static/mapinfo/common.txt | 36 ++++++++++++++++---------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/wadsrc/static/decorate.z b/wadsrc/static/decorate.z index 7a14a0281..4a2940be1 100644 --- a/wadsrc/static/decorate.z +++ b/wadsrc/static/decorate.z @@ -10,93 +10,93 @@ ACTOR DynamicLight native } -ACTOR PointLight : DynamicLight 9800 +ACTOR PointLight : DynamicLight { DynamicLight.Type "Point" } -ACTOR PointLightPulse : PointLight 9801 +ACTOR PointLightPulse : PointLight { DynamicLight.Type "Pulse" } -ACTOR PointLightFlicker : PointLight 9802 +ACTOR PointLightFlicker : PointLight { DynamicLight.Type "Flicker" } -ACTOR SectorPointLight : PointLight 9803 +ACTOR SectorPointLight : PointLight { DynamicLight.Type "Sector" } -ACTOR PointLightFlickerRandom : PointLight 9804 +ACTOR PointLightFlickerRandom : PointLight { DynamicLight.Type "RandomFlicker" } // MISSILEMORE and MISSILEEVENMORE are used by the lights for additive and subtractive lights -ACTOR PointLightAdditive : PointLight 9810 +ACTOR PointLightAdditive : PointLight { +MISSILEMORE } -ACTOR PointLightPulseAdditive : PointLightPulse 9811 +ACTOR PointLightPulseAdditive : PointLightPulse { +MISSILEMORE } -ACTOR PointLightFlickerAdditive : PointLightFlicker 9812 +ACTOR PointLightFlickerAdditive : PointLightFlicker { +MISSILEMORE } -ACTOR SectorPointLightAdditive : SectorPointLight 9813 +ACTOR SectorPointLightAdditive : SectorPointLight { +MISSILEMORE } -ACTOR PointLightFlickerRandomAdditive :PointLightFlickerRandom 9814 +ACTOR PointLightFlickerRandomAdditive :PointLightFlickerRandom { +MISSILEMORE } -ACTOR PointLightSubtractive : PointLight 9820 +ACTOR PointLightSubtractive : PointLight { +MISSILEEVENMORE } -ACTOR PointLightPulseSubtractive : PointLightPulse 9821 +ACTOR PointLightPulseSubtractive : PointLightPulse { +MISSILEEVENMORE } -ACTOR PointLightFlickerSubtractive : PointLightFlicker 9822 +ACTOR PointLightFlickerSubtractive : PointLightFlicker { +MISSILEEVENMORE } -ACTOR SectorPointLightSubtractive : SectorPointLight 9823 +ACTOR SectorPointLightSubtractive : SectorPointLight { +MISSILEEVENMORE } -ACTOR PointLightFlickerRandomSubtractive : PointLightFlickerRandom 9824 +ACTOR PointLightFlickerRandomSubtractive : PointLightFlickerRandom { +MISSILEEVENMORE } -ACTOR VavoomLight : DynamicLight 9825 native +ACTOR VavoomLight : DynamicLight native { } -ACTOR VavoomLightWhite : VavoomLight 1502 native +ACTOR VavoomLightWhite : VavoomLight native { } -ACTOR VavoomLightColor : VavoomLight 1503 native +ACTOR VavoomLightColor : VavoomLight native { } diff --git a/wadsrc/static/mapinfo/common.txt b/wadsrc/static/mapinfo/common.txt index 807c677be..d2b1d314c 100644 --- a/wadsrc/static/mapinfo/common.txt +++ b/wadsrc/static/mapinfo/common.txt @@ -28,8 +28,8 @@ DoomEdNums 1411 = "$SSeqOverride" 1500 = "$VavoomFloor" 1501 = "$VavoomCeiling" - 1502 = none - 1503 = none + 1502 = VavoomLightWhite + 1503 = VavoomLightColor 1504 = "$VertexFloorZ" 1505 = "$VertexCeilingZ" 5001 = PointPusher @@ -85,22 +85,22 @@ DoomEdNums 9503 = "$SetCeilingSlope" 9510 = "$CopyFloorPlane" 9511 = "$CopyCeilingPlane" - 9800 = none - 9801 = none - 9802 = none - 9803 = none - 9804 = none - 9810 = none - 9811 = none - 9812 = none - 9813 = none - 9814 = none - 9820 = none - 9821 = none - 9822 = none - 9823 = none - 9824 = none - 9825 = none + 9800 = PointLight + 9801 = PointLightPulse + 9802 = PointLightFlicker + 9803 = SectorPointLight + 9804 = PointLightFlickerRandom + 9810 = PointLightAdditive + 9811 = PointLightPulseAdditive + 9812 = PointLightFlickerAdditive + 9813 = SectorPointLightAdditive + 9814 = PointLightFlickerRandomAdditive + 9820 = PointLightSubtractive + 9821 = PointLightPulseSubtractive + 9822 = PointLightFlickerSubtractive + 9823 = SectorPointLightSubtractive + 9824 = PointLightFlickerRandomSubtractive + 9825 = VavoomLight 9982 = SecActEyesAboveC 9983 = SecActEyesBelowC 9988 = CustomSprite From 67334bfa2bc26c641e1a9705db901af1b4889743 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 4 Apr 2015 12:35:10 +0200 Subject: [PATCH 0294/1509] - calculate weapon positions fully in floating point to avoid roundoff errors. - In order to get reliable results the empty border around scaled sprites must be the same scale as the sprite (i.e. 2 pixels for 2x scale and 4 pixels for 4x scale.) --- src/gl/scene/gl_weapon.cpp | 14 +++++++------ src/gl/textures/gl_material.cpp | 35 +++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 42397166b..89a5e1efb 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -79,7 +79,8 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed int x1,y1,x2,y2; float scale; fixed_t scalex; - fixed_t texturemid;// 4:3 16:9 16:10 17:10 5:4 + float ftexturemid; + // 4:3 16:9 16:10 17:10 5:4 static fixed_t xratio[] = {FRACUNIT, FRACUNIT*3/4, FRACUNIT*5/6, FRACUNIT*40/51, FRACUNIT}; // [BB] In the HUD model step we just render the model and break out. @@ -116,23 +117,24 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed x2+=viewwindowx; // killough 12/98: fix psprite positioning problem - texturemid = (100<GetScaledTopOffset()<GetScaledTopOffsetFloat(); AWeapon * wi=player->ReadyWeapon; if (wi && wi->YAdjust) { + float fYAd = FIXED2FLOAT(wi->YAdjust); if (screenblocks>=11) { - texturemid -= wi->YAdjust; + ftexturemid -= fYAd; } else if (!st_scale) { - texturemid -= FixedMul (StatusBar->GetDisplacement (), wi->YAdjust); + ftexturemid -= FIXED2FLOAT(StatusBar->GetDisplacement ()) * fYAd; } } - scale = ((SCREENHEIGHT*vw)/SCREENWIDTH) / 200.0f; - y1 = viewwindowy + (vh >> 1) - (int)(((float)texturemid / (float)FRACUNIT) * scale); + scale = (SCREENHEIGHT*vw)/ (SCREENWIDTH * 200.0f); + y1 = viewwindowy + (vh >> 1) - (int)(ftexturemid * scale); y2 = y1 + (int)((float)tex->TextureHeight() * scale) + 1; if (!mirror) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index eca7c66c5..c5eb7fc34 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -460,17 +460,25 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) if (expanded) { // a little adjustment to make sprites look better with texture filtering: - // create a 1 pixel wide empty frame around them. - mWidth+=2; - mHeight+=2; - mLeftOffset+=1; - mTopOffset+=1; - mRenderWidth = mRenderWidth * mWidth / (mWidth-2); - mRenderHeight = mRenderHeight * mHeight / (mHeight-2); - + // create a 1 pixel wide empty frame around them. The frame must be the same size as the texture scale so that + // position calculations remain scale independent. int trim[4]; + bool trimmed = TrimBorders(trim); // get the trim size before adding the empty frame - if (TrimBorders(trim)) + int intscaleX = MAX(1, tex->xScale >> FRACBITS); + int intscaleY = MAX(1, tex->yScale >> FRACBITS); + int oldwidth = mWidth; + int oldheight = mHeight; + + mWidth+=2*intscaleX; + mHeight+=2*intscaleY; + mLeftOffset+=intscaleX; + mTopOffset+=intscaleY; + mRenderWidth = mRenderWidth * mWidth / oldwidth; + mRenderHeight = mRenderHeight * mHeight / oldheight; + + /* NOTE: This formula is a bit broken and needs fixing.*/ + if (trimmed) { mSpriteRect.left = -(mLeftOffset - trim[0]) / FIXED2FLOAT(tx->xScale); mSpriteRect.top = -(mTopOffset - trim[1]) / FIXED2FLOAT(tx->yScale); @@ -482,6 +490,13 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) mSpriteU[1] *= (trim[0]+trim[2]+2) / (float)mWidth; mSpriteV[1] *= (trim[1]+trim[3]+2) / (float)mHeight; } + else + { + mSpriteRect.left = -mLeftOffset / FIXED2FLOAT(tx->xScale); + mSpriteRect.top = -mTopOffset / FIXED2FLOAT(tx->yScale); + mSpriteRect.width = mWidth / FIXED2FLOAT(tx->xScale); + mSpriteRect.height = mHeight / FIXED2FLOAT(tx->yScale); + } } mTextureLayers.ShrinkToFit(); @@ -761,7 +776,7 @@ FMaterial * FMaterial::ValidateTexture(FTexture * tex, bool expand) FMaterial *gltex = tex->gl_info.Material[expand]; if (gltex == NULL) { - if (tex->bWarped || tex->bHasCanvas || tex->gl_info.shaderindex >= FIRST_USER_SHADER) + if (tex->bWarped || tex->bHasCanvas || tex->gl_info.shaderindex >= FIRST_USER_SHADER)// || tex->xScale != FRACUNIT && tex->yScale != FRACUNIT) { expand = false; } From 91eafed5d374689537f98a16b2671af1f6d463b7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 4 Apr 2015 13:37:55 +0200 Subject: [PATCH 0295/1509] - fixed coordinate calculations for trimmed sprites which were quite a bit broken. --- src/gl/textures/gl_material.cpp | 76 +++++++++++++++++++++------------ src/gl/textures/gl_material.h | 15 +++++-- 2 files changed, 60 insertions(+), 31 deletions(-) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index c5eb7fc34..f54cad27b 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -88,7 +88,8 @@ FGLTexture::FGLTexture(FTexture * tx, bool expandpatches) hirestexture = NULL; bHasColorkey = false; bIsTransparent = -1; - bExpand = expandpatches; + bExpandFlag = expandpatches; + mExpandX = mExpandY = 0; tex->gl_info.SystemTexture[expandpatches] = this; } @@ -111,6 +112,8 @@ FGLTexture::~FGLTexture() //========================================================================== unsigned char *FGLTexture::LoadHiresTexture(FTexture *tex, int *width, int *height) { + if (bExpandFlag) return NULL; // doesn't work for expanded textures + if (HiresLump==-1) { bHasColorkey = false; @@ -179,7 +182,7 @@ void FGLTexture::Clean(bool all) // //=========================================================================== -unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck) +unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded) { unsigned char * buffer; int W, H; @@ -196,8 +199,20 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F } } - W = w = tex->GetWidth() + bExpand*2; - H = h = tex->GetHeight() + bExpand*2; + int exx, exy; + if (createexpanded) + { + exx = mExpandX; + exy = mExpandY; + } + else + { + exx = exy = 0; + } + + + W = w = tex->GetWidth() + 2 * exx; + H = h = tex->GetHeight() + 2 * exy; buffer=new unsigned char[W*(H+1)*4]; @@ -215,7 +230,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F if (imgCreate.Create(W, H)) { memset(imgCreate.GetPixels(), 0, W * H * 4); - int trans = tex->CopyTrueColorPixels(&imgCreate, bExpand, bExpand); + int trans = tex->CopyTrueColorPixels(&imgCreate, exx, exy); bmp.CopyPixelDataRGB(0, 0, imgCreate.GetPixels(), W, H, 4, W * 4, 0, CF_BGRA); tex->CheckTrans(buffer, W*H, trans); bIsTransparent = tex->gl_info.mIsTransparent; @@ -223,7 +238,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F } else if (translation<=0) { - int trans = tex->CopyTrueColorPixels(&bmp, bExpand, bExpand); + int trans = tex->CopyTrueColorPixels(&bmp, exx, exy); tex->CheckTrans(buffer, W*H, trans); bIsTransparent = tex->gl_info.mIsTransparent; } @@ -232,10 +247,13 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F // When using translations everything must be mapped to the base palette. // Since FTexture's method is doing exactly that by calling GetPixels let's use that here // to do all the dirty work for us. ;) - tex->FTexture::CopyTrueColorPixels(&bmp, bExpand, bExpand); + tex->FTexture::CopyTrueColorPixels(&bmp, exx, exy); bIsTransparent = 0; } + // if we just want the texture for some checks there's no need for upsampling. + if (!createexpanded) return buffer; + // [BB] The hqnx upsampling (not the scaleN one) destroys partial transparency, don't upsamle textures using it. // [BB] Potentially upsample the buffer. return gl_CreateUpsampledTextureBuffer ( tex, buffer, W, H, w, h, !!bIsTransparent); @@ -253,7 +271,7 @@ FHardwareTexture *FGLTexture::CreateHwTexture() if (tex->UseType==FTexture::TEX_Null) return NULL; // Cannot register a NULL texture if (mHwTexture == NULL) { - mHwTexture = new FHardwareTexture(tex->GetWidth() + bExpand*2, tex->GetHeight() + bExpand*2, tex->gl_info.bNoCompress); + mHwTexture = new FHardwareTexture(tex->GetWidth() + mExpandX*2, tex->GetHeight() + mExpandY*2, tex->gl_info.bNoCompress); } return mHwTexture; } @@ -451,11 +469,14 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) FTexture *basetex = tx->GetRedirect(false); mBaseLayer = ValidateSysTexture(basetex, expanded); + float fxScale = FIXED2FLOAT(tx->xScale); + float fyScale = FIXED2FLOAT(tx->yScale); + // mSpriteRect is for positioning the sprite in the scene. - mSpriteRect.left = -mLeftOffset / FIXED2FLOAT(tx->xScale); - mSpriteRect.top = -mTopOffset / FIXED2FLOAT(tx->yScale); - mSpriteRect.width = mWidth / FIXED2FLOAT(tx->xScale); - mSpriteRect.height = mHeight / FIXED2FLOAT(tx->yScale); + mSpriteRect.left = -mLeftOffset / fxScale; + mSpriteRect.top = -mTopOffset / fyScale; + mSpriteRect.width = mWidth / fxScale; + mSpriteRect.height = mHeight / fyScale; if (expanded) { @@ -477,25 +498,24 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) mRenderWidth = mRenderWidth * mWidth / oldwidth; mRenderHeight = mRenderHeight * mHeight / oldheight; - /* NOTE: This formula is a bit broken and needs fixing.*/ + // Reposition the sprite with the frame considered + mSpriteRect.left = -mLeftOffset / fxScale; + mSpriteRect.top = -mTopOffset / fyScale; + mSpriteRect.width = mWidth / fxScale; + mSpriteRect.height = mHeight / fyScale; + if (trimmed) { - mSpriteRect.left = -(mLeftOffset - trim[0]) / FIXED2FLOAT(tx->xScale); - mSpriteRect.top = -(mTopOffset - trim[1]) / FIXED2FLOAT(tx->yScale); - mSpriteRect.width = (trim[2] + 2) / FIXED2FLOAT(tx->xScale); - mSpriteRect.height = (trim[3] + 2) / FIXED2FLOAT(tx->yScale); + mSpriteRect.left += trim[0] / fxScale; + mSpriteRect.top += trim[1] / fyScale; + + mSpriteRect.width -= (oldwidth - trim[2]) / fxScale; + mSpriteRect.height -= (oldheight - trim[3]) / fyScale; mSpriteU[0] = trim[0] / (float)mWidth; mSpriteV[0] = trim[1] / (float)mHeight; - mSpriteU[1] *= (trim[0]+trim[2]+2) / (float)mWidth; - mSpriteV[1] *= (trim[1]+trim[3]+2) / (float)mHeight; - } - else - { - mSpriteRect.left = -mLeftOffset / FIXED2FLOAT(tx->xScale); - mSpriteRect.top = -mTopOffset / FIXED2FLOAT(tx->yScale); - mSpriteRect.width = mWidth / FIXED2FLOAT(tx->xScale); - mSpriteRect.height = mHeight / FIXED2FLOAT(tx->yScale); + mSpriteU[1] -= (oldwidth - trim[0] - trim[2]) / (float)mWidth; + mSpriteV[1] -= (oldheight - trim[1] - trim[3]) / (float)mHeight; } } @@ -540,7 +560,7 @@ bool FMaterial::TrimBorders(int *rect) int w; int h; - unsigned char *buffer = CreateTexBuffer(0, w, h); + unsigned char *buffer = CreateTexBuffer(0, w, h, false, false); if (buffer == NULL) { @@ -554,6 +574,7 @@ bool FMaterial::TrimBorders(int *rect) } int size = w*h; + if (size == 1) return false; int first, last; @@ -563,6 +584,7 @@ bool FMaterial::TrimBorders(int *rect) } if (first >= size) { + // completely empty rect[0] = 0; rect[1] = 0; rect[2] = 1; diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index b5f055d24..96404c316 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -65,7 +65,9 @@ private: FHardwareTexture *mHwTexture; bool bHasColorkey; // only for hires - bool bExpand; + bool bExpandFlag; + int mExpandX; + int mExpandY; unsigned char * LoadHiresTexture(FTexture *hirescheck, int *width, int *height); @@ -77,7 +79,12 @@ public: FGLTexture(FTexture * tx, bool expandpatches); ~FGLTexture(); - unsigned char * CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck); + unsigned char * CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded = true); + void SetExpand(int x, int y) + { + mExpandX = x; + mExpandY = y; + } void Clean(bool all); int Dump(int i); @@ -139,9 +146,9 @@ public: void Bind(int clamp, int translation); - unsigned char * CreateTexBuffer(int translation, int & w, int & h, bool allowhires=true) const + unsigned char * CreateTexBuffer(int translation, int & w, int & h, bool allowhires=true, bool createexpanded = true) const { - return mBaseLayer->CreateTexBuffer(translation, w, h, allowhires? tex : NULL); + return mBaseLayer->CreateTexBuffer(translation, w, h, allowhires? tex : NULL, createexpanded); } void Clean(bool f) From bead3e046bd5c440254143a74a96c290a8e41299 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 4 Apr 2015 17:50:22 +0200 Subject: [PATCH 0296/1509] - fixed weapon positioning again, after finding out that the first fix just worked around the actual problem: The entire coordinate calculation must be done in floating point with no integer math at all. Due to roundoff errors the stored int values needed for wall and flat placement significantly lack precision and with the high scaling factor that needs to be used for weapon HUD sprites these can easily become several pixels. After fixing this the border around sprite textures could be reverted to one pixel again. - fixed: The 'may not be expanded' state should be stored in the texture and reused later. This also needs to revalidate the material if it decides that expansion should be disallowed. --- src/gl/scene/gl_weapon.cpp | 56 +++++++++++++++-------------- src/gl/textures/gl_material.cpp | 64 ++++++++++++++++++--------------- src/gl/textures/gl_material.h | 7 ---- src/gl/textures/gl_texture.cpp | 1 + src/textures/textures.h | 1 + 5 files changed, 67 insertions(+), 62 deletions(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 89a5e1efb..71b4a8fdc 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -75,13 +75,13 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed { float fU1,fV1; float fU2,fV2; - fixed_t tx; - int x1,y1,x2,y2; + float tx; + float x1,y1,x2,y2; float scale; - fixed_t scalex; + float scalex; float ftexturemid; - // 4:3 16:9 16:10 17:10 5:4 - static fixed_t xratio[] = {FRACUNIT, FRACUNIT*3/4, FRACUNIT*5/6, FRACUNIT*40/51, FRACUNIT}; + // 4:3 16:9 16:10 17:10 5:4 + static float xratio[] = {1.f, 3.f/4, 5.f/6, 40.f/51, 1.f}; // [BB] In the HUD model step we just render the model and break out. if ( hudModelStep ) @@ -100,30 +100,34 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed gl_RenderState.SetMaterial(tex, CLAMP_XY_NOMIP, 0, OverrideShader, alphatexture); - int vw = viewwidth; - int vh = viewheight; + float vw = (float)viewwidth; + float vh = (float)viewheight; + + FloatRect r; + tex->GetSpriteRect(&r); // calculate edges of the shape scalex = xratio[WidescreenRatio] * vw / 320; - tx = sx - ((160 + tex->GetScaledLeftOffset())<>FRACBITS) + (vw>>1); + tx = FIXED2FLOAT(sx) - (160 - r.left); + x1 = tx * scalex + vw/2; if (x1 > vw) return; // off the right side - x1+=viewwindowx; + x1 += viewwindowx; - tx += tex->TextureWidth() << FRACBITS; - x2 = (FixedMul(tx, scalex)>>FRACBITS) + (vw>>1); + tx += r.width; + x2 = tx * scalex + vw / 2; if (x2 < 0) return; // off the left side - x2+=viewwindowx; + x2 += viewwindowx; + // killough 12/98: fix psprite positioning problem - ftexturemid = 100.f - FIXED2FLOAT(sy) + tex->GetScaledTopOffsetFloat(); + ftexturemid = 100.f - FIXED2FLOAT(sy) - r.top; AWeapon * wi=player->ReadyWeapon; if (wi && wi->YAdjust) { float fYAd = FIXED2FLOAT(wi->YAdjust); - if (screenblocks>=11) + if (screenblocks >= 11) { ftexturemid -= fYAd; } @@ -133,23 +137,23 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed } } - scale = (SCREENHEIGHT*vw)/ (SCREENWIDTH * 200.0f); - y1 = viewwindowy + (vh >> 1) - (int)(ftexturemid * scale); - y2 = y1 + (int)((float)tex->TextureHeight() * scale) + 1; + scale = (SCREENHEIGHT*vw) / (SCREENWIDTH * 200.0f); + y1 = viewwindowy + vh / 2 - (ftexturemid * scale); + y2 = y1 + (r.height * scale) + 1; if (!mirror) { - fU1=tex->GetUL(); - fV1=tex->GetVT(); - fU2=tex->GetUR(); - fV2=tex->GetVB(); + fU1=tex->GetSpriteUL(); + fV1=tex->GetSpriteVT(); + fU2=tex->GetSpriteUR(); + fV2=tex->GetSpriteVB(); } else { - fU2=tex->GetUL(); - fV1=tex->GetVT(); - fU1=tex->GetUR(); - fV2=tex->GetVB(); + fU2=tex->GetSpriteUL(); + fV1=tex->GetSpriteVT(); + fU1=tex->GetSpriteUR(); + fV2=tex->GetSpriteVB(); } if (tex->GetTransparent() || OverrideShader != -1) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index f54cad27b..a359191e1 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -89,7 +89,6 @@ FGLTexture::FGLTexture(FTexture * tx, bool expandpatches) bHasColorkey = false; bIsTransparent = -1; bExpandFlag = expandpatches; - mExpandX = mExpandY = 0; tex->gl_info.SystemTexture[expandpatches] = this; } @@ -199,20 +198,10 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F } } - int exx, exy; - if (createexpanded) - { - exx = mExpandX; - exy = mExpandY; - } - else - { - exx = exy = 0; - } - + int exx = bExpandFlag && createexpanded; W = w = tex->GetWidth() + 2 * exx; - H = h = tex->GetHeight() + 2 * exy; + H = h = tex->GetHeight() + 2 * exx; buffer=new unsigned char[W*(H+1)*4]; @@ -230,7 +219,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F if (imgCreate.Create(W, H)) { memset(imgCreate.GetPixels(), 0, W * H * 4); - int trans = tex->CopyTrueColorPixels(&imgCreate, exx, exy); + int trans = tex->CopyTrueColorPixels(&imgCreate, exx, exx); bmp.CopyPixelDataRGB(0, 0, imgCreate.GetPixels(), W, H, 4, W * 4, 0, CF_BGRA); tex->CheckTrans(buffer, W*H, trans); bIsTransparent = tex->gl_info.mIsTransparent; @@ -238,7 +227,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F } else if (translation<=0) { - int trans = tex->CopyTrueColorPixels(&bmp, exx, exy); + int trans = tex->CopyTrueColorPixels(&bmp, exx, exx); tex->CheckTrans(buffer, W*H, trans); bIsTransparent = tex->gl_info.mIsTransparent; } @@ -247,7 +236,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F // When using translations everything must be mapped to the base palette. // Since FTexture's method is doing exactly that by calling GetPixels let's use that here // to do all the dirty work for us. ;) - tex->FTexture::CopyTrueColorPixels(&bmp, exx, exy); + tex->FTexture::CopyTrueColorPixels(&bmp, exx, exx); bIsTransparent = 0; } @@ -271,7 +260,7 @@ FHardwareTexture *FGLTexture::CreateHwTexture() if (tex->UseType==FTexture::TEX_Null) return NULL; // Cannot register a NULL texture if (mHwTexture == NULL) { - mHwTexture = new FHardwareTexture(tex->GetWidth() + mExpandX*2, tex->GetHeight() + mExpandY*2, tex->gl_info.bNoCompress); + mHwTexture = new FHardwareTexture(tex->GetWidth() + bExpandFlag*2, tex->GetHeight() + bExpandFlag*2, tex->gl_info.bNoCompress); } return mHwTexture; } @@ -454,7 +443,7 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) } } } - mBaseLayer = ValidateSysTexture(tx, true); + mBaseLayer = ValidateSysTexture(tx, expanded); mWidth = tx->GetWidth(); @@ -467,7 +456,11 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) mSpriteU[1] = mSpriteV[1] = 1.f; FTexture *basetex = tx->GetRedirect(false); - mBaseLayer = ValidateSysTexture(basetex, expanded); + // allow the redirect only if the textute is not expanded or the scale matches. + if (!expanded || (tx->xScale == basetex->xScale && tx->yScale == basetex->yScale)) + { + mBaseLayer = ValidateSysTexture(basetex, expanded); + } float fxScale = FIXED2FLOAT(tx->xScale); float fyScale = FIXED2FLOAT(tx->yScale); @@ -481,20 +474,17 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) if (expanded) { // a little adjustment to make sprites look better with texture filtering: - // create a 1 pixel wide empty frame around them. The frame must be the same size as the texture scale so that - // position calculations remain scale independent. + // create a 1 pixel wide empty frame around them. int trim[4]; bool trimmed = TrimBorders(trim); // get the trim size before adding the empty frame - int intscaleX = MAX(1, tex->xScale >> FRACBITS); - int intscaleY = MAX(1, tex->yScale >> FRACBITS); int oldwidth = mWidth; int oldheight = mHeight; - mWidth+=2*intscaleX; - mHeight+=2*intscaleY; - mLeftOffset+=intscaleX; - mTopOffset+=intscaleY; + mWidth+=2; + mHeight+=2; + mLeftOffset+=1; + mTopOffset+=1; mRenderWidth = mRenderWidth * mWidth / oldwidth; mRenderHeight = mRenderHeight * mHeight / oldheight; @@ -793,14 +783,30 @@ void FMaterial::BindToFrameBuffer() FMaterial * FMaterial::ValidateTexture(FTexture * tex, bool expand) { +again: if (tex && tex->UseType!=FTexture::TEX_Null) { + if (tex->gl_info.bNoExpand) expand = false; + FMaterial *gltex = tex->gl_info.Material[expand]; if (gltex == NULL) { - if (tex->bWarped || tex->bHasCanvas || tex->gl_info.shaderindex >= FIRST_USER_SHADER)// || tex->xScale != FRACUNIT && tex->yScale != FRACUNIT) + if (expand) { - expand = false; + if (tex->bWarped || tex->bHasCanvas || tex->gl_info.shaderindex >= FIRST_USER_SHADER) + { + tex->gl_info.bNoExpand = true; + goto again; + } + if (tex->gl_info.Brightmap != NULL && + (tex->GetWidth() != tex->gl_info.Brightmap->GetWidth() || + tex->GetHeight() != tex->gl_info.Brightmap->GetHeight()) + ) + { + // do not expand if the brightmap's size differs. + tex->gl_info.bNoExpand = true; + goto again; + } } gltex = new FMaterial(tex, expand); } diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 96404c316..61fdd6e46 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -66,8 +66,6 @@ private: bool bHasColorkey; // only for hires bool bExpandFlag; - int mExpandX; - int mExpandY; unsigned char * LoadHiresTexture(FTexture *hirescheck, int *width, int *height); @@ -80,11 +78,6 @@ public: ~FGLTexture(); unsigned char * CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded = true); - void SetExpand(int x, int y) - { - mExpandX = x; - mExpandY = y; - } void Clean(bool all); int Dump(int i); diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 27a489162..414f631a4 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -235,6 +235,7 @@ FTexture::MiscGLInfo::MiscGLInfo() throw() bDisableFullbright = false; bNoFilter = false; bNoCompress = false; + bNoExpand = false; areas = NULL; areacount = 0; mIsTransparent = -1; diff --git a/src/textures/textures.h b/src/textures/textures.h index 6192da835..6a75dfed3 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -352,6 +352,7 @@ public: bool bDisableFullbright:1; // This texture will not be displayed as fullbright sprite bool bNoFilter:1; bool bNoCompress:1; + bool bNoExpand:1; MiscGLInfo() throw (); ~MiscGLInfo(); From 45526c276953355074f845f4531a741ddc542e5e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Apr 2015 18:55:21 +0200 Subject: [PATCH 0297/1509] - basics for using hardware clip planes to split translucent stuff by 3D floor planes. --- src/gl/renderer/gl_renderstate.cpp | 2 ++ src/gl/renderer/gl_renderstate.h | 23 +++++++++++++++++++++++ src/gl/shaders/gl_shader.cpp | 1 + src/gl/shaders/gl_shader.h | 23 +++++++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 358c9fe7f..15b046349 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -86,6 +86,7 @@ void FRenderState::Reset() mSpecialEffect = EFF_NONE; mClipHeightTop = 65536.f; mClipHeightBottom = -65536.f; + ClearClipSplit(); stSrcBlend = stDstBlend = -1; stBlendEquation = -1; @@ -141,6 +142,7 @@ bool FRenderState::ApplyShader() activeShader->muTimer.Set(gl_frameMS * mShaderTimer / 1000.f); activeShader->muAlphaThreshold.Set(mAlphaThreshold); activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now + activeShader->muClipSplit.Set(mClipSplit); if (mGlowEnabled) { diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 8c3b60772..74065fe4c 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -73,6 +73,7 @@ class FRenderState PalEntry mFogColor; PalEntry mObjectColor; FStateVec4 mDynColor; + float mClipSplit[2]; int mEffectState; int mColormapState; @@ -279,6 +280,28 @@ public: return mFogColor; } + void SetClipSplit(float bottom, float top) + { + mClipSplit[0] = bottom; + mClipSplit[1] = top; + } + + void SetClipSplit(float *vals) + { + memcpy(mClipSplit, vals, 2 * sizeof(float)); + } + + void GetClipSplit(float *out) + { + memcpy(out, mClipSplit, 2 * sizeof(float)); + } + + void ClearClipSplit() + { + mClipSplit[0] = -1000000.f; + mClipSplit[1] = 1000000.f; + } + void BlendFunc(int src, int dst) { if (!gl_direct_state_change) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 7c04bdf45..2955cf7c8 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -205,6 +205,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muTextureMode.Init(hShader, "uTextureMode"); muCameraPos.Init(hShader, "uCameraPos"); muLightParms.Init(hShader, "uLightAttr"); + muClipSplit.Init(hShader, "uClipSplit"); muColormapStart.Init(hShader, "uFixedColormapStart"); muColormapRange.Init(hShader, "uFixedColormapRange"); muLightIndex.Init(hShader, "uLightIndex"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 8b6f7b4a6..c5baceceb 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -103,6 +103,28 @@ public: } }; +class FBufferedUniform2f +{ + float mBuffer[2]; + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + memset(mBuffer, 0, sizeof(mBuffer)); + } + + void Set(const float *newvalue) + { + if (memcmp(newvalue, mBuffer, sizeof(mBuffer))) + { + memcpy(mBuffer, newvalue, sizeof(mBuffer)); + glUniform2fv(mIndex, 1, newvalue); + } + } +}; + class FBufferedUniform4f { float mBuffer[4]; @@ -184,6 +206,7 @@ class FShader FBufferedUniform1i muTextureMode; FBufferedUniform4f muCameraPos; FBufferedUniform4f muLightParms; + FBufferedUniform2f muClipSplit; FUniform1i muFixedColormap; FUniform4f muColormapStart; FUniform4f muColormapRange; From cf7cb4f00f5bcfabfd229ff5650572269889e18f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Apr 2015 19:00:35 +0200 Subject: [PATCH 0298/1509] - use hardware clip planes to split translucent walls and sprites by 3D floor planes. This method has the advantage that it also works for models, xy-billboarded sprites and walls that require complex splitting of the polygon. The old method using actual polygon splitting only works for strictly vertical data that could be trivially split in two. --- src/gl/scene/gl_drawinfo.cpp | 112 ++++++++++++++++++----------------- 1 file changed, 59 insertions(+), 53 deletions(-) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index d0da4e0d4..48864ab24 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -307,41 +307,23 @@ void GLDrawList::SortWallIntoPlane(SortNode * head,SortNode * sort) { GLFlat * fh=&flats[drawitems[head->itemindex].index]; GLWall * ws=&walls[drawitems[sort->itemindex].index]; - GLWall * ws1; bool ceiling = fh->z > FIXED2FLOAT(viewz); - - if (ws->ztop[0]>fh->z && ws->zbottom[0]z) + if ((ws->ztop[0] > fh->z || ws->ztop[1] > fh->z) && (ws->zbottom[0] < fh->z || ws->zbottom[1] < fh->z)) { // We have to split this wall! // WARNING: NEVER EVER push a member of an array onto the array itself. // Bad things will happen if the memory must be reallocated! - GLWall w=*ws; + GLWall w = *ws; AddWall(&w); - ws1=&walls[walls.Size()-1]; - ws=&walls[drawitems[sort->itemindex].index]; // may have been reallocated! - float newtexv = ws->uplft.v + ((ws->lolft.v - ws->uplft.v) / (ws->zbottom[0] - ws->ztop[0])) * (fh->z - ws->ztop[0]); + // Splitting is done in the shader with clip planes. - // I make the very big assumption here that translucent walls in sloped sectors - // and 3D-floors never coexist in the same level. If that were the case this - // code would become extremely more complicated. - if (!ceiling) - { - ws->ztop[1] = ws1->zbottom[1] = ws->ztop[0] = ws1->zbottom[0] = fh->z; - ws->uprgt.v = ws1->lorgt.v = ws->uplft.v = ws1->lolft.v = newtexv; - } - else - { - ws1->ztop[1] = ws->zbottom[1] = ws1->ztop[0] = ws->zbottom[0] = fh->z; - ws1->uplft.v = ws->lolft.v = ws1->uprgt.v = ws->lorgt.v=newtexv; - } - - SortNode * sort2=SortNodes.GetNew(); - memset(sort2,0,sizeof(SortNode)); - sort2->itemindex=drawitems.Size()-1; + SortNode * sort2 = SortNodes.GetNew(); + memset(sort2, 0, sizeof(SortNode)); + sort2->itemindex = drawitems.Size() - 1; head->AddToLeft(sort); head->AddToRight(sort2); @@ -366,29 +348,16 @@ void GLDrawList::SortSpriteIntoPlane(SortNode * head,SortNode * sort) { GLFlat * fh=&flats[drawitems[head->itemindex].index]; GLSprite * ss=&sprites[drawitems[sort->itemindex].index]; - GLSprite * ss1; bool ceiling = fh->z > FIXED2FLOAT(viewz); - if (ss->z1>fh->z && ss->z2z) + if ((ss->z1>fh->z && ss->z2z) || ss->modelframe) { - // We have to split this sprite! + // We have to split this sprite GLSprite s=*ss; - AddSprite(&s); - ss1=&sprites[sprites.Size()-1]; - ss=&sprites[drawitems[sort->itemindex].index]; // may have been reallocated! - float newtexv=ss->vt + ((ss->vb-ss->vt)/(ss->z2-ss->z1))*(fh->z-ss->z1); + AddSprite(&s); // add a copy to avoid reallocation issues. - if (!ceiling) - { - ss->z1=ss1->z2=fh->z; - ss->vt=ss1->vb=newtexv; - } - else - { - ss1->z1=ss->z2=fh->z; - ss1->vt=ss->vb=newtexv; - } + // Splitting is done in the shader with clip planes. SortNode * sort2=SortNodes.GetNew(); memset(sort2,0,sizeof(SortNode)); @@ -729,24 +698,57 @@ void GLDrawList::DoDraw(int pass, int i, bool trans) //========================================================================== void GLDrawList::DoDrawSorted(SortNode * head) { - do + float clipsplit[2]; + int relation = 0; + float z = 0.f; + + gl_RenderState.GetClipSplit(clipsplit); + + if (drawitems[head->itemindex].rendertype == GLDIT_FLAT) { - if (head->left) + z = flats[drawitems[head->itemindex].index].z; + relation = z > FIXED2FLOAT(viewz)? 1 : -1; + } + + + // left is further away, i.e. for stuff above viewz its z coordinate higher, for stuff below viewz its z coordinate is lower + if (head->left) + { + if (relation == -1) { - DoDrawSorted(head->left); + gl_RenderState.SetClipSplit(clipsplit[0], z); // render below: set flat as top clip plane } - DoDraw(GLPASS_TRANSLUCENT, head->itemindex, true); - if (head->equal) + else if (relation == 1) { - SortNode * ehead=head->equal; - while (ehead) - { - DoDraw(GLPASS_TRANSLUCENT, ehead->itemindex, true); - ehead=ehead->equal; - } + gl_RenderState.SetClipSplit(z, clipsplit[1]); // render above: set flat as bottom clip plane + } + DoDrawSorted(head->left); + gl_RenderState.SetClipSplit(clipsplit); + } + DoDraw(GLPASS_TRANSLUCENT, head->itemindex, true); + if (head->equal) + { + SortNode * ehead=head->equal; + while (ehead) + { + DoDraw(GLPASS_TRANSLUCENT, ehead->itemindex, true); + ehead=ehead->equal; } } - while ((head=head->right)); + // right is closer, i.e. for stuff above viewz its z coordinate is lower, for stuff below viewz its z coordinate is higher + if (head->right) + { + if (relation == 1) + { + gl_RenderState.SetClipSplit(clipsplit[0], z); // render below: set flat as top clip plane + } + else if (relation == -1) + { + gl_RenderState.SetClipSplit(z, clipsplit[1]); // render above: set flat as bottom clip plane + } + DoDrawSorted(head->right); + gl_RenderState.SetClipSplit(clipsplit); + } } //========================================================================== @@ -763,7 +765,11 @@ void GLDrawList::DrawSorted() MakeSortList(); sorted=DoSort(SortNodes[SortNodeStart]); } + glEnable(GL_CLIP_DISTANCE2); + glEnable(GL_CLIP_DISTANCE3); DoDrawSorted(sorted); + glDisable(GL_CLIP_DISTANCE2); + glDisable(GL_CLIP_DISTANCE3); } //========================================================================== From b45c88fc4f9af2808d0df5b9e7c2a53b3e723eda Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Apr 2015 20:20:56 +0200 Subject: [PATCH 0299/1509] - changed shaders. --- wadsrc/static/shaders/glsl/main.vp | 5 +++++ wadsrc/static/shaders/glsl/shaderdefs.i | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 86fad75cc..75f814887 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -43,6 +43,11 @@ void main() #endif gl_Position = ProjectionMatrix * eyeCoordPos; + + // clip planes used for reflective flats gl_ClipDistance[0] = worldcoord.y - uClipHeightBottom; gl_ClipDistance[1] = uClipHeightTop - worldcoord.y; + + gl_ClipDistance[2] = worldcoord.y - uClipSplit.x; + gl_ClipDistance[3] = uClipSplit.y - worldcoord.y; } diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 3711bf814..d49034973 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -7,6 +7,7 @@ precision highp float; uniform vec4 uCameraPos; uniform int uTextureMode; uniform float uClipHeightTop, uClipHeightBottom; +uniform vec2 uClipSplit; uniform float uAlphaThreshold; @@ -29,6 +30,9 @@ uniform vec4 uGlowTopColor; uniform vec4 uGlowBottomPlane; uniform vec4 uGlowBottomColor; +uniform vec4 uSplitTopPlane; +uniform vec4 uSplitBottomPlane; + // Lighting + Fog uniform vec4 uLightAttr; #define uLightLevel uLightAttr.a From feeebf52659f7aa43e20bf52e3ecd95c2b9dd920 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 12 Apr 2015 18:26:52 +0200 Subject: [PATCH 0300/1509] - rework MD2 code for reloading/precaching of geometry data. --- src/gl/models/gl_models.cpp | 8 + src/gl/models/gl_models.h | 28 ++- src/gl/models/gl_models_md2.cpp | 326 +++++++++++++++++++------------- src/gl/scene/gl_drawinfo.cpp | 2 + src/gl/scene/gl_portal.cpp | 2 +- 5 files changed, 223 insertions(+), 143 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index bfbf21dd2..fb63c2cf6 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -101,6 +101,14 @@ void gl_LoadModels() } } +void gl_FlushModels() +{ + for (int i = Models.Size() - 1; i >= 0; i--) + { + Models[i]->DestroyVertexBuffer(); + } +} + //=========================================================================== // // diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 0d479b68c..6ca096ca1 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -33,6 +33,11 @@ public: virtual int FindFrame(const char * name) = 0; virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0; virtual void BuildVertexBuffer() = 0; + void DestroyVertexBuffer() + { + delete mVBuf; + mVBuf = NULL; + } virtual float getAspectFactor() { return 1.f; } FModelVertexBuffer *mVBuf; @@ -93,9 +98,13 @@ protected: struct ModelFrame { char name[16]; + unsigned int vindex; + }; + + struct ModelFrameVertexData + { DMDModelVertex *vertices; DMDModelVertex *normals; - unsigned int vindex; }; struct DMDLoDInfo @@ -112,21 +121,23 @@ protected: }; - bool loaded; + int mLumpNum; DMDHeader header; DMDInfo info; FTexture ** skins; - FTexCoord * texCoords; - ModelFrame * frames; + bool allowTexComp; // Allow texture compression with this. + + // Temp data only needed for buffer construction + FTexCoord * texCoords; + ModelFrameVertexData *framevtx; DMDLoDInfo lodInfo[MAX_LODS]; DMDLoD lods[MAX_LODS]; - bool allowTexComp; // Allow texture compression with this. public: FDMDModel() { - loaded = false; + mLumpNum = -1; frames = NULL; skins = NULL; for (int i = 0; i < MAX_LODS; i++) @@ -135,14 +146,16 @@ public: } info.numLODs = 0; texCoords = NULL; + framevtx = NULL; } virtual ~FDMDModel(); virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); virtual int FindFrame(const char * name); virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); + virtual void LoadGeometry(); + void UnloadGeometry(); void BuildVertexBuffer(); - void CleanTempData(); }; @@ -154,6 +167,7 @@ public: virtual ~FMD2Model(); virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); + virtual void LoadGeometry(); }; diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index 402b20472..c40e20d90 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -74,53 +74,58 @@ static void UnpackVector(unsigned short packed, float vec[3]) } +//=========================================================================== +// +// DMD file structure +// +//=========================================================================== + +struct dmd_chunk_t +{ + int type; + int length; // Next chunk follows... +}; + +#pragma pack(1) +struct dmd_packedVertex_t +{ + byte vertex[3]; + unsigned short normal; // Yaw and pitch. +}; + +struct dmd_packedFrame_t +{ + float scale[3]; + float translate[3]; + char name[16]; + dmd_packedVertex_t vertices[1]; +}; +#pragma pack() + +// Chunk types. +enum +{ + DMC_END, // Must be the last chunk. + DMC_INFO // Required; will be expected to exist. +}; + //=========================================================================== // // FDMDModel::Load // //=========================================================================== -bool FDMDModel::Load(const char * path, int, const char * buffer, int length) +bool FDMDModel::Load(const char * path, int lumpnum, const char * buffer, int length) { - struct dmd_chunk_t - { - int type; - int length; // Next chunk follows... - }; - -#pragma pack(1) - struct dmd_packedVertex_t - { - byte vertex[3]; - unsigned short normal; // Yaw and pitch. - }; - - struct dmd_packedFrame_t - { - float scale[3]; - float translate[3]; - char name[16]; - dmd_packedVertex_t vertices[1]; - } ; -#pragma pack() - - // Chunk types. - enum - { - DMC_END, // Must be the last chunk. - DMC_INFO // Required; will be expected to exist. - }; - - dmd_chunk_t * chunk = (dmd_chunk_t*)(buffer+12); + dmd_chunk_t * chunk = (dmd_chunk_t*)(buffer + 12); char *temp; ModelFrame *frame; - int i, k, c; - int axis[3] = { VX, VY, VZ }; + int i; - int fileoffset=12+sizeof(dmd_chunk_t); + int fileoffset = 12 + sizeof(dmd_chunk_t); chunk->type = LittleLong(chunk->type); - while(chunk->type != DMC_END) + while (chunk->type != DMC_END) { switch (chunk->type) { @@ -148,7 +153,7 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length) break; } // Read the next chunk header. - chunk = (dmd_chunk_t*)(buffer+fileoffset); + chunk = (dmd_chunk_t*)(buffer + fileoffset); chunk->type = LittleLong(chunk->type); fileoffset += sizeof(dmd_chunk_t); } @@ -156,34 +161,58 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length) // Allocate and load in the data. skins = new FTexture *[info.numSkins]; - for(i = 0; i < info.numSkins; i++) + for (i = 0; i < info.numSkins; i++) { - skins[i] = LoadSkin(path, buffer + info.offsetSkins + i*64); + skins[i] = LoadSkin(path, buffer + info.offsetSkins + i * 64); } - - texCoords = new FTexCoord[info.numTexCoords]; - memcpy(texCoords, (byte*)buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord)); - temp = (char*)buffer + info.offsetFrames; frames = new ModelFrame[info.numFrames]; - for(i = 0, frame = frames; i < info.numFrames; i++, frame++) + for (i = 0, frame = frames; i < info.numFrames; i++, frame++) + { + dmd_packedFrame_t *pfr = (dmd_packedFrame_t *)(temp + info.frameSize * i); + + memcpy(frame->name, pfr->name, sizeof(pfr->name)); + frame->vindex = UINT_MAX; + } + mLumpNum = lumpnum; + return true; +} + +//=========================================================================== +// +// FDMDModel::LoadGeometry +// +//=========================================================================== + +void FDMDModel::LoadGeometry() +{ + static int axis[3] = { VX, VY, VZ }; + FMemLump lumpdata = Wads.ReadLump(mLumpNum); + const char *buffer = (const char *)lumpdata.GetMem(); + texCoords = new FTexCoord[info.numTexCoords]; + memcpy(texCoords, buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord)); + + const char *temp = buffer + info.offsetFrames; + framevtx= new ModelFrameVertexData[info.numFrames]; + + ModelFrameVertexData *framev; + int i, k, c; + for(i = 0, framev = framevtx; i < info.numFrames; i++, framev++) { dmd_packedFrame_t *pfr = (dmd_packedFrame_t *) (temp + info.frameSize * i); dmd_packedVertex_t *pVtx; - memcpy(frame->name, pfr->name, sizeof(pfr->name)); - frame->vertices = new DMDModelVertex[info.numVertices]; - frame->normals = new DMDModelVertex[info.numVertices]; - frame->vindex = UINT_MAX; + framev->vertices = new DMDModelVertex[info.numVertices]; + framev->normals = new DMDModelVertex[info.numVertices]; // Translate each vertex. for(k = 0, pVtx = pfr->vertices; k < info.numVertices; k++, pVtx++) { - UnpackVector((unsigned short)(pVtx->normal), frame->normals[k].xyz); + UnpackVector((unsigned short)(pVtx->normal), framev->normals[k].xyz); for(c = 0; c < 3; c++) { - frame->vertices[k].xyz[axis[c]] = + framev->vertices[k].xyz[axis[c]] = (pVtx->vertex[c] * FLOAT(pfr->scale[c]) + FLOAT(pfr->translate[c])); } } @@ -209,24 +238,6 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length) } } - loaded=true; - return true; -} - - -//=========================================================================== -// -// -// -//=========================================================================== - -FDMDModel::~FDMDModel() -{ - CleanTempData(); - - // skins are managed by the texture manager so they must not be deleted here. - if (skins != NULL) delete [] skins; - if (frames != NULL) delete [] frames; } //=========================================================================== @@ -235,20 +246,22 @@ FDMDModel::~FDMDModel() // //=========================================================================== -void FDMDModel::CleanTempData() +void FDMDModel::UnloadGeometry() { int i; - if (frames != NULL) + if (framevtx != NULL) { for (i=0;ivertices; - DMDModelVertex *norm = frame->normals; - - frame->vindex = vindex; + DMDModelVertex *vert = framevtx[i].vertices; + DMDModelVertex *norm = framevtx[i].normals; + frames[i].vindex = vindex; FTriangle *tri = lods[0].triangles; @@ -304,7 +332,7 @@ void FDMDModel::BuildVertexBuffer() } } mVBuf->UnlockVertexBuffer(); - CleanTempData(); + UnloadGeometry(); } } @@ -353,55 +381,60 @@ void FDMDModel::RenderFrame(FTexture * skin, int frameno, int frameno2, double i } + +//=========================================================================== +// +// Internal data structures of MD2 files - only used during loading +// +//=========================================================================== + +struct md2_header_t +{ + int magic; + int version; + int skinWidth; + int skinHeight; + int frameSize; + int numSkins; + int numVertices; + int numTexCoords; + int numTriangles; + int numGlCommands; + int numFrames; + int offsetSkins; + int offsetTexCoords; + int offsetTriangles; + int offsetFrames; + int offsetGlCommands; + int offsetEnd; +}; + +struct md2_triangleVertex_t +{ + byte vertex[3]; + byte lightNormalIndex; +}; + +struct md2_packedFrame_t +{ + float scale[3]; + float translate[3]; + char name[16]; + md2_triangleVertex_t vertices[1]; +}; + //=========================================================================== // // FMD2Model::Load // //=========================================================================== -bool FMD2Model::Load(const char * path, int, const char * buffer, int length) +bool FMD2Model::Load(const char * path, int lumpnum, const char * buffer, int length) { - // Internal data structures of MD2 files - only used during loading! - struct md2_header_t - { - int magic; - int version; - int skinWidth; - int skinHeight; - int frameSize; - int numSkins; - int numVertices; - int numTexCoords; - int numTriangles; - int numGlCommands; - int numFrames; - int offsetSkins; - int offsetTexCoords; - int offsetTriangles; - int offsetFrames; - int offsetGlCommands; - int offsetEnd; - } ; - - struct md2_triangleVertex_t - { - byte vertex[3]; - byte lightNormalIndex; - }; - - struct md2_packedFrame_t - { - float scale[3]; - float translate[3]; - char name[16]; - md2_triangleVertex_t vertices[1]; - }; - md2_header_t * md2header = (md2_header_t *)buffer; ModelFrame *frame; byte *md2_frames; - int i, k, c; - int axis[3] = { VX, VY, VZ }; + int i; // Convert it to DMD. header.magic = MD2_MAGIC; @@ -436,39 +469,71 @@ bool FMD2Model::Load(const char * path, int, const char * buffer, int length) return false; } + skins = new FTexture *[info.numSkins]; + + for (i = 0; i < info.numSkins; i++) + { + skins[i] = LoadSkin(path, buffer + info.offsetSkins + i * 64); + } + // The frames need to be unpacked. md2_frames = (byte*)buffer + info.offsetFrames; frames = new ModelFrame[info.numFrames]; + for (i = 0, frame = frames; i < info.numFrames; i++, frame++) + { + md2_packedFrame_t *pfr = (md2_packedFrame_t *)(md2_frames + info.frameSize * i); + + memcpy(frame->name, pfr->name, sizeof(pfr->name)); + frame->vindex = UINT_MAX; + } + mLumpNum = lumpnum; + return true; +} + +//=========================================================================== +// +// FMD2Model::LoadGeometry +// +//=========================================================================== + +void FMD2Model::LoadGeometry() +{ + static int axis[3] = { VX, VY, VZ }; + byte *md2_frames; + FMemLump lumpdata = Wads.ReadLump(mLumpNum); + const char *buffer = (const char *)lumpdata.GetMem(); + texCoords = new FTexCoord[info.numTexCoords]; memcpy(texCoords, (byte*)buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord)); + md2_frames = (byte*)buffer + info.offsetFrames; + framevtx = new ModelFrameVertexData[info.numFrames]; + ModelFrameVertexData *framev; + int i, k, c; - for(i = 0, frame = frames; i < info.numFrames; i++, frame++) + for(i = 0, framev = framevtx; i < info.numFrames; i++, framev++) { md2_packedFrame_t *pfr = (md2_packedFrame_t *) (md2_frames + info.frameSize * i); md2_triangleVertex_t *pVtx; - memcpy(frame->name, pfr->name, sizeof(pfr->name)); - frame->vertices = new DMDModelVertex[info.numVertices]; - frame->normals = new DMDModelVertex[info.numVertices]; - frame->vindex = UINT_MAX; + framev->vertices = new DMDModelVertex[info.numVertices]; + framev->normals = new DMDModelVertex[info.numVertices]; // Translate each vertex. for(k = 0, pVtx = pfr->vertices; k < info.numVertices; k++, pVtx++) { - memcpy(frame->normals[k].xyz, + memcpy(framev->normals[k].xyz, avertexnormals[pVtx->lightNormalIndex], sizeof(float) * 3); for(c = 0; c < 3; c++) { - frame->vertices[k].xyz[axis[c]] = + framev->vertices[k].xyz[axis[c]] = (pVtx->vertex[c] * pfr->scale[c] + pfr->translate[c]); } } } - lods[0].triangles = new FTriangle[lodInfo[0].numTriangles]; int cnt = lodInfo[0].numTriangles; @@ -481,15 +546,6 @@ bool FMD2Model::Load(const char * path, int, const char * buffer, int length) lods[0].triangles[j].vertexIndices[k] = LittleShort(lods[0].triangles[j].vertexIndices[k]); } } - - skins = new FTexture *[info.numSkins]; - - for(i = 0; i < info.numSkins; i++) - { - skins[i] = LoadSkin(path, buffer + info.offsetSkins + i*64); - } - loaded=true; - return true; } FMD2Model::~FMD2Model() diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 48864ab24..08eb3b26d 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -765,11 +765,13 @@ void GLDrawList::DrawSorted() MakeSortList(); sorted=DoSort(SortNodes[SortNodeStart]); } + gl_RenderState.ClearClipSplit(); glEnable(GL_CLIP_DISTANCE2); glEnable(GL_CLIP_DISTANCE3); DoDrawSorted(sorted); glDisable(GL_CLIP_DISTANCE2); glDisable(GL_CLIP_DISTANCE3); + gl_RenderState.ClearClipSplit(); } //========================================================================== diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index eba8b4d06..54bc9b540 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -800,7 +800,7 @@ void GLPlaneMirrorPortal::DrawContents() float f = FIXED2FLOAT(planez); if (PlaneMirrorMode < 0) { - gl_RenderState.SetClipHeightTop(f); // ceiling mirror: clip everytihng with a z lower than the portal's ceiling + gl_RenderState.SetClipHeightTop(f); // ceiling mirror: clip everything with a z lower than the portal's ceiling glEnable(GL_CLIP_DISTANCE1); } else From 052dda0fdd96edb7da138558465203a72ace846c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 12 Apr 2015 19:42:03 +0200 Subject: [PATCH 0301/1509] - made MD3 models reloadable. --- src/gl/models/gl_models.h | 6 +- src/gl/models/gl_models_md3.cpp | 200 +++++++++++++++++++------------- src/gl/renderer/gl_renderer.cpp | 2 + 3 files changed, 127 insertions(+), 81 deletions(-) diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 6ca096ca1..89834df8c 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -220,10 +220,10 @@ class FMD3Model : public FModel ~MD3Surface() { if (skins) delete [] skins; - CleanTempData(); + UnloadGeometry(); } - void CleanTempData() + void UnloadGeometry() { if (tris) delete [] tris; if (vertices) delete [] vertices; @@ -245,6 +245,7 @@ class FMD3Model : public FModel int numFrames; int numTags; int numSurfaces; + int mLumpNum; MD3Frame * frames; MD3Surface * surfaces; @@ -256,6 +257,7 @@ public: virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); virtual int FindFrame(const char * name); virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); + void LoadGeometry(); void BuildVertexBuffer(); }; diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index 9cc72307c..13f02bc0a 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -50,9 +50,14 @@ #define MAX_QPATH 64 +//=========================================================================== +// +// decode the lat/lng normal to a 3 float normal +// +//=========================================================================== + static void UnpackVector(unsigned short packed, float & nx, float & ny, float & nz) { - // decode the lat/lng normal to a 3 float normal double lat = ( packed >> 8 ) & 0xff; double lng = ( packed & 0xff ); lat *= PI/128; @@ -63,75 +68,86 @@ static void UnpackVector(unsigned short packed, float & nx, float & ny, float & nz = cos(lng); } +//=========================================================================== +// +// MD3 File structure +// +//=========================================================================== - -bool FMD3Model::Load(const char * path, int, const char * buffer, int length) +#pragma pack(4) +struct md3_header_t { - #pragma pack(4) - struct md3_header_t - { - DWORD Magic; - DWORD Version; - char Name[MAX_QPATH]; - DWORD Flags; - DWORD Num_Frames; - DWORD Num_Tags; - DWORD Num_Surfaces; - DWORD Num_Skins; - DWORD Ofs_Frames; - DWORD Ofs_Tags; - DWORD Ofs_Surfaces; - DWORD Ofs_Eof; - }; + DWORD Magic; + DWORD Version; + char Name[MAX_QPATH]; + DWORD Flags; + DWORD Num_Frames; + DWORD Num_Tags; + DWORD Num_Surfaces; + DWORD Num_Skins; + DWORD Ofs_Frames; + DWORD Ofs_Tags; + DWORD Ofs_Surfaces; + DWORD Ofs_Eof; +}; - struct md3_surface_t - { - DWORD Magic; - char Name[MAX_QPATH]; - DWORD Flags; - DWORD Num_Frames; - DWORD Num_Shaders; - DWORD Num_Verts; - DWORD Num_Triangles; - DWORD Ofs_Triangles; - DWORD Ofs_Shaders; - DWORD Ofs_Texcoord; - DWORD Ofs_XYZNormal; - DWORD Ofs_End; - }; +struct md3_surface_t +{ + DWORD Magic; + char Name[MAX_QPATH]; + DWORD Flags; + DWORD Num_Frames; + DWORD Num_Shaders; + DWORD Num_Verts; + DWORD Num_Triangles; + DWORD Ofs_Triangles; + DWORD Ofs_Shaders; + DWORD Ofs_Texcoord; + DWORD Ofs_XYZNormal; + DWORD Ofs_End; +}; - struct md3_triangle_t - { - DWORD vt_index[3]; - }; +struct md3_triangle_t +{ + DWORD vt_index[3]; +}; - struct md3_shader_t - { - char Name[MAX_QPATH]; - DWORD index; - }; +struct md3_shader_t +{ + char Name[MAX_QPATH]; + DWORD index; +}; - struct md3_texcoord_t - { - float s,t; - }; +struct md3_texcoord_t +{ + float s, t; +}; - struct md3_vertex_t - { - short x,y,z,n; - }; +struct md3_vertex_t +{ + short x, y, z, n; +}; - struct md3_frame_t - { - float min_Bounds[3]; - float max_Bounds[3]; - float localorigin[3]; - float radius; - char Name[16]; - }; - #pragma pack() +struct md3_frame_t +{ + float min_Bounds[3]; + float max_Bounds[3]; + float localorigin[3]; + float radius; + char Name[16]; +}; +#pragma pack() - md3_header_t * hdr=(md3_header_t *)buffer; + +//=========================================================================== +// +// +// +//=========================================================================== + +bool FMD3Model::Load(const char * path, int lumpnum, const char * buffer, int length) +{ + md3_header_t * hdr = (md3_header_t *)buffer; numFrames = LittleLong(hdr->Num_Frames); numTags = LittleLong(hdr->Num_Tags); @@ -140,16 +156,17 @@ bool FMD3Model::Load(const char * path, int, const char * buffer, int length) md3_frame_t * frm = (md3_frame_t*)(buffer + LittleLong(hdr->Ofs_Frames)); frames = new MD3Frame[numFrames]; - for(int i=0;iOfs_Surfaces)); surfaces = new MD3Surface[numSurfaces]; - for(int i=0;inumTriangles = LittleLong(ss->Num_Triangles); s->numVertices = LittleLong(ss->Num_Verts); + // copy shaders (skins) + md3_shader_t * shader = (md3_shader_t*)(((char*)ss) + LittleLong(ss->Ofs_Shaders)); + s->skins = new FTexture *[s->numSkins]; + + for (int i = 0; i < s->numSkins; i++) + { + // [BB] According to the MD3 spec, Name is supposed to include the full path. + s->skins[i] = LoadSkin("", shader[i].Name); + // [BB] Fall back and check if Name is relative. + if (s->skins[i] == NULL) + s->skins[i] = LoadSkin(path, shader[i].Name); + } + } + mLumpNum = lumpnum; + return true; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FMD3Model::LoadGeometry() +{ + FMemLump lumpdata = Wads.ReadLump(mLumpNum); + const char *buffer = (const char *)lumpdata.GetMem(); + md3_header_t * hdr = (md3_header_t *)buffer; + md3_surface_t * surf = (md3_surface_t*)(buffer + LittleLong(hdr->Ofs_Surfaces)); + + for(int i=0;iOfs_End)); + // copy triangle indices md3_triangle_t * tris = (md3_triangle_t*)(((char*)ss)+LittleLong(ss->Ofs_Triangles)); s->tris = new MD3Triangle[s->numTriangles]; @@ -169,19 +223,6 @@ bool FMD3Model::Load(const char * path, int, const char * buffer, int length) s->tris[i].VertIndex[j]=LittleLong(tris[i].vt_index[j]); } - // copy shaders (skins) - md3_shader_t * shader = (md3_shader_t*)(((char*)ss)+LittleLong(ss->Ofs_Shaders)); - s->skins = new FTexture *[s->numSkins]; - - for(int i=0;inumSkins;i++) - { - // [BB] According to the MD3 spec, Name is supposed to include the full path. - s->skins[i] = LoadSkin("", shader[i].Name); - // [BB] Fall back and check if Name is relative. - if ( s->skins[i] == NULL ) - s->skins[i] = LoadSkin(path, shader[i].Name); - } - // Load texture coordinates md3_texcoord_t * tc = (md3_texcoord_t*)(((char*)ss)+LittleLong(ss->Ofs_Texcoord)); s->texcoords = new MD3TexCoord[s->numVertices]; @@ -204,7 +245,6 @@ bool FMD3Model::Load(const char * path, int, const char * buffer, int length) UnpackVector( LittleShort(vt[i].n), s->vertices[i].nx, s->vertices[i].ny, s->vertices[i].nz); } } - return true; } //=========================================================================== @@ -217,6 +257,8 @@ void FMD3Model::BuildVertexBuffer() { if (mVBuf == NULL) { + LoadGeometry(); + unsigned int vbufsize = 0; unsigned int ibufsize = 0; @@ -259,7 +301,7 @@ void FMD3Model::BuildVertexBuffer() indxptr[iindex++] = surf->tris[k].VertIndex[l]; } } - surf->CleanTempData(); + surf->UnloadGeometry(); } mVBuf->UnlockVertexBuffer(); mVBuf->UnlockIndexBuffer(); diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 7d8b36a42..3a44a714f 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -99,6 +99,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) } void gl_LoadModels(); +void gl_FlushModels(); void FGLRenderer::Initialize() { @@ -119,6 +120,7 @@ void FGLRenderer::Initialize() FGLRenderer::~FGLRenderer() { + gl_FlushModels(); gl_DeleteAllAttachedLights(); FMaterial::FlushAll(); if (mShaderManager != NULL) delete mShaderManager; From a602e47261d7f814d34f4b6daeb299922a63711c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 16 Apr 2015 19:57:18 +0200 Subject: [PATCH 0302/1509] - commit of the correct version of p_3dfloors.cpp --- src/p_3dfloors.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index 42d79dcc0..ae1c31a86 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -44,6 +44,7 @@ #include "r_data/colormaps.h" #ifdef _3DFLOORS +EXTERN_CVAR(Int, vid_renderer) //========================================================================== // @@ -201,7 +202,7 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag // kg3D - software renderer only hack // this is really required because of ceilingclip and floorclip - if(flags & FF_BOTHPLANES) + if((vid_renderer == 0) && (flags & FF_BOTHPLANES)) { P_Add3DFloor(sec, sec2, master, FF_EXISTS | FF_THISINSIDE | FF_RENDERPLANES | FF_NOSHADE | FF_SEETHROUGH | FF_SHOOTTHROUGH | (flags & (FF_INVERTSECTOR | FF_TRANSLUCENT | FF_ADDITIVETRANS)), alpha); @@ -220,8 +221,7 @@ static int P_Set3DFloor(line_t * line, int param, int param2, int alpha) int tag=line->args[0]; sector_t * sec = line->frontsector, * ss; - FSectorTagIterator it(tag); - while ((s = it.Next()) >= 0) + for (s=-1; (s = P_FindSectorFromTag(tag,s)) >= 0;) { ss=§ors[s]; @@ -265,6 +265,7 @@ static int P_Set3DFloor(line_t * line, int param, int param2, int alpha) else if (param==4) { flags=FF_EXISTS|FF_RENDERPLANES|FF_INVERTPLANES|FF_NOSHADE|FF_FIX; + if (param2 & 1) flags |= FF_SEETHROUGH; // marker for allowing missing texture checks alpha=255; } else @@ -583,6 +584,7 @@ void P_Recalculate3DFloors(sector_t * sector) lightlist[0].extra_colormap = sector->ColorMap; lightlist[0].blend = 0; lightlist[0].flags = 0; + lightlist[0].fromsector = true; maxheight = sector->CenterCeiling(); minheight = sector->CenterFloor(); @@ -604,6 +606,7 @@ void P_Recalculate3DFloors(sector_t * sector) newlight.extra_colormap = rover->GetColormap(); newlight.blend = rover->GetBlend(); newlight.flags = rover->flags; + newlight.fromsector = false; lightlist.Push(newlight); } else if (i==0) @@ -618,6 +621,7 @@ void P_Recalculate3DFloors(sector_t * sector) lightlist[0].extra_colormap = rover->GetColormap(); lightlist[0].blend = rover->GetBlend(); lightlist[0].flags = rover->flags; + lightlist[0].fromsector = false; } } if (rover->flags&FF_DOUBLESHADOW) @@ -642,6 +646,7 @@ void P_Recalculate3DFloors(sector_t * sector) newlight.blend = 0; } newlight.flags = rover->flags; + newlight.fromsector = false; lightlist.Push(newlight); } } @@ -844,7 +849,7 @@ void P_Spawn3DFloors (void) { if (line->args[1]&8) { - line->SetMainId(line->args[4]); + line->id = line->args[4]; } else { From df6ffe64180e85d5ca1faf73ae2290a0b1da737b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 16 Apr 2015 22:50:26 +0200 Subject: [PATCH 0303/1509] - adjustments for recent ZDoom changes. --- src/gl/data/gl_data.cpp | 5 ++- src/p_3dfloors.cpp | 95 +++++++++++++++++++++-------------------- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 735ef0439..182b818b3 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -150,9 +150,10 @@ static int LS_Sector_SetPlaneReflection (line_t *ln, AActor *it, bool backSide, int arg0, int arg1, int arg2, int arg3, int arg4) { // Sector_SetPlaneReflection (tag, floor, ceiling) - int secnum = -1; + int secnum; + FSectorTagIterator itr(arg0); - while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) + while ((secnum = itr.Next()) >= 0) { sector_t * s = §ors[secnum]; if (s->floorplane.a==0 && s->floorplane.b==0) s->reflect[sector_t::floor] = arg1/255.f; diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index ae1c31a86..7ca03d261 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -216,96 +216,97 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag //========================================================================== static int P_Set3DFloor(line_t * line, int param, int param2, int alpha) { - int s,i; + int s, i; int flags; - int tag=line->args[0]; - sector_t * sec = line->frontsector, * ss; + int tag = line->args[0]; + sector_t * sec = line->frontsector, *ss; - for (s=-1; (s = P_FindSectorFromTag(tag,s)) >= 0;) + FSectorTagIterator itr(tag); + while ((s = itr.Next()) >= 0) { - ss=§ors[s]; + ss = §ors[s]; - if (param==0) + if (param == 0) { - flags=FF_EXISTS|FF_RENDERALL|FF_SOLID|FF_INVERTSECTOR; + flags = FF_EXISTS | FF_RENDERALL | FF_SOLID | FF_INVERTSECTOR; alpha = 255; - for (i=0;ilinecount;i++) + for (i = 0; i < sec->linecount; i++) { - line_t * l=sec->lines[i]; + line_t * l = sec->lines[i]; - if (l->special==Sector_SetContents && l->frontsector==sec) + if (l->special == Sector_SetContents && l->frontsector == sec) { - alpha=clamp(l->args[1], 0, 100); + alpha = clamp(l->args[1], 0, 100); if (l->args[2] & 1) flags &= ~FF_SOLID; if (l->args[2] & 2) flags |= FF_SEETHROUGH; if (l->args[2] & 4) flags |= FF_SHOOTTHROUGH; if (l->args[2] & 8) flags |= FF_ADDITIVETRANS; - if (alpha!=100) flags|=FF_TRANSLUCENT;//|FF_BOTHPLANES|FF_ALLSIDES; - if (l->args[0]) + if (alpha != 100) flags |= FF_TRANSLUCENT;//|FF_BOTHPLANES|FF_ALLSIDES; + if (l->args[0]) { // Yes, Vavoom's 3D-floor definitions suck! // The content list changed in r1783 of Vavoom to be unified // among all its supported games, so it has now ten different // values instead of just five. - static DWORD vavoomcolors[]={VC_EMPTY, + static DWORD vavoomcolors[] = { VC_EMPTY, VC_WATER, VC_LAVA, VC_NUKAGE, VC_SLIME, VC_HELLSLIME, - VC_BLOOD, VC_SLUDGE, VC_HAZARD, VC_BOOMWATER}; - flags|=FF_SWIMMABLE|FF_BOTHPLANES|FF_ALLSIDES|FF_FLOOD; + VC_BLOOD, VC_SLUDGE, VC_HAZARD, VC_BOOMWATER }; + flags |= FF_SWIMMABLE | FF_BOTHPLANES | FF_ALLSIDES | FF_FLOOD; - l->frontsector->ColorMap = - GetSpecialLights (l->frontsector->ColorMap->Color, - vavoomcolors[l->args[0]], - l->frontsector->ColorMap->Desaturate); + l->frontsector->ColorMap = + GetSpecialLights(l->frontsector->ColorMap->Color, + vavoomcolors[l->args[0]], + l->frontsector->ColorMap->Desaturate); } - alpha=(alpha*255)/100; + alpha = (alpha * 255) / 100; break; } } } - else if (param==4) + else if (param == 4) { - flags=FF_EXISTS|FF_RENDERPLANES|FF_INVERTPLANES|FF_NOSHADE|FF_FIX; + flags = FF_EXISTS | FF_RENDERPLANES | FF_INVERTPLANES | FF_NOSHADE | FF_FIX; if (param2 & 1) flags |= FF_SEETHROUGH; // marker for allowing missing texture checks - alpha=255; + alpha = 255; } - else + else { - static const int defflags[]= {0, - FF_SOLID, - FF_SWIMMABLE|FF_BOTHPLANES|FF_ALLSIDES|FF_SHOOTTHROUGH|FF_SEETHROUGH, - FF_SHOOTTHROUGH|FF_SEETHROUGH, + static const int defflags[] = { 0, + FF_SOLID, + FF_SWIMMABLE | FF_BOTHPLANES | FF_ALLSIDES | FF_SHOOTTHROUGH | FF_SEETHROUGH, + FF_SHOOTTHROUGH | FF_SEETHROUGH, }; - flags = defflags[param&3] | FF_EXISTS|FF_RENDERALL; + flags = defflags[param & 3] | FF_EXISTS | FF_RENDERALL; - if (param&4) flags |= FF_ALLSIDES|FF_BOTHPLANES; - if (param&16) flags ^= FF_SEETHROUGH; - if (param&32) flags ^= FF_SHOOTTHROUGH; + if (param & 4) flags |= FF_ALLSIDES | FF_BOTHPLANES; + if (param & 16) flags ^= FF_SEETHROUGH; + if (param & 32) flags ^= FF_SHOOTTHROUGH; - if (param2&1) flags |= FF_NOSHADE; - if (param2&2) flags |= FF_DOUBLESHADOW; - if (param2&4) flags |= FF_FOG; - if (param2&8) flags |= FF_THINFLOOR; - if (param2&16) flags |= FF_UPPERTEXTURE; - if (param2&32) flags |= FF_LOWERTEXTURE; - if (param2&64) flags |= FF_ADDITIVETRANS|FF_TRANSLUCENT; + if (param2 & 1) flags |= FF_NOSHADE; + if (param2 & 2) flags |= FF_DOUBLESHADOW; + if (param2 & 4) flags |= FF_FOG; + if (param2 & 8) flags |= FF_THINFLOOR; + if (param2 & 16) flags |= FF_UPPERTEXTURE; + if (param2 & 32) flags |= FF_LOWERTEXTURE; + if (param2 & 64) flags |= FF_ADDITIVETRANS | FF_TRANSLUCENT; // if flooding is used the floor must be non-solid and is automatically made shootthrough and seethrough - if ((param2&128) && !(flags & FF_SOLID)) flags |= FF_FLOOD|FF_SEETHROUGH|FF_SHOOTTHROUGH; - if (param2&512) flags |= FF_FADEWALLS; + if ((param2 & 128) && !(flags & FF_SOLID)) flags |= FF_FLOOD | FF_SEETHROUGH | FF_SHOOTTHROUGH; + if (param2 & 512) flags |= FF_FADEWALLS; FTextureID tex = line->sidedef[0]->GetTexture(side_t::top); - if (!tex.Exists() && alpha<255) + if (!tex.Exists() && alpha < 255) { alpha = -tex.GetIndex(); } alpha = clamp(alpha, 0, 255); - if (alpha==0) flags&=~(FF_RENDERALL|FF_BOTHPLANES|FF_ALLSIDES); - else if (alpha!=255) flags|=FF_TRANSLUCENT; - + if (alpha == 0) flags &= ~(FF_RENDERALL | FF_BOTHPLANES | FF_ALLSIDES); + else if (alpha != 255) flags |= FF_TRANSLUCENT; + } P_Add3DFloor(ss, sec, line, flags, alpha); } // To be 100% safe this should be done even if the alpha by texture value isn't used. - if (!line->sidedef[0]->GetTexture(side_t::top).isValid()) + if (!line->sidedef[0]->GetTexture(side_t::top).isValid()) line->sidedef[0]->SetTexture(side_t::top, FNullTextureID()); return 1; } From baa775b31c59cdc8a3216a0e366706febc3032ec Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 24 Apr 2015 16:55:31 +0200 Subject: [PATCH 0304/1509] - fixed: Light level must be clamped before accessing the distfogtable. --- src/gl/renderer/gl_lightdata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 771c4c65c..1e5922d0a 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -312,7 +312,7 @@ float gl_GetFogDensity(int lightlevel, PalEntry fogcolor) // case 1: black fog if (glset.lightmode != 8) { - density=distfogtable[glset.lightmode!=0][lightlevel]; + density=distfogtable[glset.lightmode!=0][gl_ClampLight(lightlevel)]; } else { From 364e8811134ca096f3a0d35c3ce4ade695ae9b73 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 25 Apr 2015 20:30:10 +0200 Subject: [PATCH 0305/1509] - this was still in the repo...? --- gzdoom.sln | 203 ----------------------------------------------------- 1 file changed, 203 deletions(-) delete mode 100644 gzdoom.sln diff --git a/gzdoom.sln b/gzdoom.sln deleted file mode 100644 index 0a1de5eec..000000000 --- a/gzdoom.sln +++ /dev/null @@ -1,203 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zdoom", "gzdoom.vcproj", "{8049475B-5C87-46F9-9358-635218A4EF18}" - ProjectSection(ProjectDependencies) = postProject - {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96} = {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96} - {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} - {6077B7D6-349F-4077-B552-3BC302EF5859} = {6077B7D6-349F-4077-B552-3BC302EF5859} - {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E} = {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E} - {0F80ACBF-460E-44F0-B28E-B3272D1774A7} = {0F80ACBF-460E-44F0-B28E-B3272D1774A7} - {DA47396F-60C1-4BDE-A977-7F7DE461CF77} = {DA47396F-60C1-4BDE-A977-7F7DE461CF77} - {1D179D4B-F008-431B-8C72-111F8372584F} = {1D179D4B-F008-431B-8C72-111F8372584F} - {B68E0ABF-B627-48A3-A92F-D8F827A75054} = {B68E0ABF-B627-48A3-A92F-D8F827A75054} - {8997289F-10BF-4678-8BAA-3BB509C84953} = {8997289F-10BF-4678-8BAA-3BB509C84953} - {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466} = {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466} - {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4} = {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4} - {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F} = {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib\zlib.vcproj", "{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lemon", "tools\lemon\lemon.vcproj", "{0F80ACBF-460E-44F0-B28E-B3272D1774A7}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "re2c", "tools\re2c\re2c.vcproj", "{667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wadsrc", "wadsrc\wadsrc.vcproj", "{1D179D4B-F008-431B-8C72-111F8372584F}" - ProjectSection(ProjectDependencies) = postProject - {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} = {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wadsrc-brightmaps", "wadsrc_bm\brightmaps.vcproj", "{087B206F-F49E-4EFB-92CB-E1F6E32D1278}" - ProjectSection(ProjectDependencies) = postProject - {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} = {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wadsrc-lights", "wadsrc_lights\lights.vcproj", "{31090871-A623-4BBC-A167-DE821CD1240C}" - ProjectSection(ProjectDependencies) = postProject - {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} = {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "updaterevision", "tools\updaterevision\updaterevision.vcproj", "{6077B7D6-349F-4077-B552-3BC302EF5859}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jpeg-6b", "jpeg-6b\jpeg-6b.vcproj", "{AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fixrtext", "tools\fixrtext\fixrtext.vcproj", "{DA47396F-60C1-4BDE-A977-7F7DE461CF77}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dumb_static", "dumb\vc6\dumb_static\dumb_static.vcproj", "{8997289F-10BF-4678-8BAA-3BB509C84953}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gdtoa", "gdtoa\gdtoa.vcproj", "{B68E0ABF-B627-48A3-A92F-D8F827A75054}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zipdir", "tools\zipdir\zipdir.vcproj", "{24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}" - ProjectSection(ProjectDependencies) = postProject - {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4} = {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4} - {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} - {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F} = {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lzmalib", "lzma\lzmalib.vcproj", "{6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bzip2", "bzip2\bzip2.vcproj", "{A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "game-music-emu", "game-music-emu\game-music-emu.vcproj", "{9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8049475B-5C87-46F9-9358-635218A4EF18}.Debug|Win32.ActiveCfg = Debug|Win32 - {8049475B-5C87-46F9-9358-635218A4EF18}.Debug|Win32.Build.0 = Debug|Win32 - {8049475B-5C87-46F9-9358-635218A4EF18}.Debug|x64.ActiveCfg = Debug|x64 - {8049475B-5C87-46F9-9358-635218A4EF18}.Debug|x64.Build.0 = Debug|x64 - {8049475B-5C87-46F9-9358-635218A4EF18}.Release|Win32.ActiveCfg = Release|Win32 - {8049475B-5C87-46F9-9358-635218A4EF18}.Release|Win32.Build.0 = Release|Win32 - {8049475B-5C87-46F9-9358-635218A4EF18}.Release|x64.ActiveCfg = Release|x64 - {8049475B-5C87-46F9-9358-635218A4EF18}.Release|x64.Build.0 = Release|x64 - {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Debug|Win32.ActiveCfg = Debug|Win32 - {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Debug|Win32.Build.0 = Debug|Win32 - {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Debug|x64.ActiveCfg = Debug|x64 - {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Debug|x64.Build.0 = Debug|x64 - {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Release|Win32.ActiveCfg = Release|Win32 - {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Release|Win32.Build.0 = Release|Win32 - {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Release|x64.ActiveCfg = Release|x64 - {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Release|x64.Build.0 = Release|x64 - {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Debug|Win32.ActiveCfg = Debug|Win32 - {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Debug|Win32.Build.0 = Debug|Win32 - {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Debug|x64.ActiveCfg = Release|Win32 - {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Debug|x64.Build.0 = Release|Win32 - {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Release|Win32.ActiveCfg = Release|Win32 - {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Release|Win32.Build.0 = Release|Win32 - {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Release|x64.ActiveCfg = Release|Win32 - {0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Release|x64.Build.0 = Release|Win32 - {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Debug|Win32.ActiveCfg = Debug|Win32 - {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Debug|Win32.Build.0 = Debug|Win32 - {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Debug|x64.ActiveCfg = Release|Win32 - {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Debug|x64.Build.0 = Release|Win32 - {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Release|Win32.ActiveCfg = Release|Win32 - {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Release|Win32.Build.0 = Release|Win32 - {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Release|x64.ActiveCfg = Release|Win32 - {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}.Release|x64.Build.0 = Release|Win32 - {1D179D4B-F008-431B-8C72-111F8372584F}.Debug|Win32.ActiveCfg = Debug|Win32 - {1D179D4B-F008-431B-8C72-111F8372584F}.Debug|Win32.Build.0 = Debug|Win32 - {1D179D4B-F008-431B-8C72-111F8372584F}.Debug|x64.ActiveCfg = Release|Win32 - {1D179D4B-F008-431B-8C72-111F8372584F}.Debug|x64.Build.0 = Release|Win32 - {1D179D4B-F008-431B-8C72-111F8372584F}.Release|Win32.ActiveCfg = Release|Win32 - {1D179D4B-F008-431B-8C72-111F8372584F}.Release|Win32.Build.0 = Release|Win32 - {1D179D4B-F008-431B-8C72-111F8372584F}.Release|x64.ActiveCfg = Release|Win32 - {1D179D4B-F008-431B-8C72-111F8372584F}.Release|x64.Build.0 = Release|Win32 - {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Debug|Win32.ActiveCfg = Debug|Win32 - {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Debug|Win32.Build.0 = Debug|Win32 - {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Debug|x64.ActiveCfg = Debug|Win32 - {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Debug|x64.Build.0 = Debug|Win32 - {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Release|Win32.ActiveCfg = Release|Win32 - {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Release|Win32.Build.0 = Release|Win32 - {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Release|x64.ActiveCfg = Release|Win32 - {087B206F-F49E-4EFB-92CB-E1F6E32D1278}.Release|x64.Build.0 = Release|Win32 - {31090871-A623-4BBC-A167-DE821CD1240C}.Debug|Win32.ActiveCfg = Debug|Win32 - {31090871-A623-4BBC-A167-DE821CD1240C}.Debug|Win32.Build.0 = Debug|Win32 - {31090871-A623-4BBC-A167-DE821CD1240C}.Debug|x64.ActiveCfg = Debug|Win32 - {31090871-A623-4BBC-A167-DE821CD1240C}.Debug|x64.Build.0 = Debug|Win32 - {31090871-A623-4BBC-A167-DE821CD1240C}.Release|Win32.ActiveCfg = Release|Win32 - {31090871-A623-4BBC-A167-DE821CD1240C}.Release|Win32.Build.0 = Release|Win32 - {31090871-A623-4BBC-A167-DE821CD1240C}.Release|x64.ActiveCfg = Release|Win32 - {31090871-A623-4BBC-A167-DE821CD1240C}.Release|x64.Build.0 = Release|Win32 - {6077B7D6-349F-4077-B552-3BC302EF5859}.Debug|Win32.ActiveCfg = Debug|Win32 - {6077B7D6-349F-4077-B552-3BC302EF5859}.Debug|Win32.Build.0 = Debug|Win32 - {6077B7D6-349F-4077-B552-3BC302EF5859}.Debug|x64.ActiveCfg = Debug|x64 - {6077B7D6-349F-4077-B552-3BC302EF5859}.Debug|x64.Build.0 = Debug|x64 - {6077B7D6-349F-4077-B552-3BC302EF5859}.Release|Win32.ActiveCfg = Release|Win32 - {6077B7D6-349F-4077-B552-3BC302EF5859}.Release|Win32.Build.0 = Release|Win32 - {6077B7D6-349F-4077-B552-3BC302EF5859}.Release|x64.ActiveCfg = Release|x64 - {6077B7D6-349F-4077-B552-3BC302EF5859}.Release|x64.Build.0 = Release|x64 - {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Debug|Win32.ActiveCfg = Debug|Win32 - {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Debug|Win32.Build.0 = Debug|Win32 - {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Debug|x64.ActiveCfg = Debug|x64 - {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Debug|x64.Build.0 = Debug|x64 - {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Release|Win32.ActiveCfg = Release|Win32 - {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Release|Win32.Build.0 = Release|Win32 - {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Release|x64.ActiveCfg = Release|x64 - {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}.Release|x64.Build.0 = Release|x64 - {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Debug|Win32.ActiveCfg = Debug|Win32 - {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Debug|Win32.Build.0 = Debug|Win32 - {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Debug|x64.ActiveCfg = Debug|Win32 - {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Debug|x64.Build.0 = Debug|Win32 - {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Release|Win32.ActiveCfg = Release|Win32 - {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Release|Win32.Build.0 = Release|Win32 - {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Release|x64.ActiveCfg = Release|Win32 - {DA47396F-60C1-4BDE-A977-7F7DE461CF77}.Release|x64.Build.0 = Release|Win32 - {8997289F-10BF-4678-8BAA-3BB509C84953}.Debug|Win32.ActiveCfg = Debug|Win32 - {8997289F-10BF-4678-8BAA-3BB509C84953}.Debug|Win32.Build.0 = Debug|Win32 - {8997289F-10BF-4678-8BAA-3BB509C84953}.Debug|x64.ActiveCfg = Debug|x64 - {8997289F-10BF-4678-8BAA-3BB509C84953}.Debug|x64.Build.0 = Debug|x64 - {8997289F-10BF-4678-8BAA-3BB509C84953}.Release|Win32.ActiveCfg = Release|Win32 - {8997289F-10BF-4678-8BAA-3BB509C84953}.Release|Win32.Build.0 = Release|Win32 - {8997289F-10BF-4678-8BAA-3BB509C84953}.Release|x64.ActiveCfg = Release|x64 - {8997289F-10BF-4678-8BAA-3BB509C84953}.Release|x64.Build.0 = Release|x64 - {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Debug|Win32.ActiveCfg = Debug|Win32 - {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Debug|Win32.Build.0 = Debug|Win32 - {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Debug|x64.ActiveCfg = Debug|x64 - {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Debug|x64.Build.0 = Debug|x64 - {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Release|Win32.ActiveCfg = Release|Win32 - {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Release|Win32.Build.0 = Release|Win32 - {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Release|x64.ActiveCfg = Release|x64 - {B68E0ABF-B627-48A3-A92F-D8F827A75054}.Release|x64.Build.0 = Release|x64 - {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Debug|Win32.ActiveCfg = Debug|Win32 - {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Debug|Win32.Build.0 = Debug|Win32 - {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Debug|x64.ActiveCfg = Debug|x64 - {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Debug|x64.Build.0 = Debug|x64 - {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Release|Win32.ActiveCfg = Release|Win32 - {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Release|Win32.Build.0 = Release|Win32 - {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Release|x64.ActiveCfg = Release|x64 - {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Release|x64.Build.0 = Release|x64 - {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Debug|Win32.ActiveCfg = Debug|Win32 - {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Debug|Win32.Build.0 = Debug|Win32 - {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Debug|x64.ActiveCfg = Debug|x64 - {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Debug|x64.Build.0 = Debug|x64 - {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Release|Win32.ActiveCfg = Release|Win32 - {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Release|Win32.Build.0 = Release|Win32 - {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Release|x64.ActiveCfg = Release|x64 - {6EB27E78-7C7A-4F08-8E19-957E8EB3A20F}.Release|x64.Build.0 = Release|x64 - {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Debug|Win32.ActiveCfg = Debug|Win32 - {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Debug|Win32.Build.0 = Debug|Win32 - {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Debug|x64.ActiveCfg = Debug|x64 - {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Debug|x64.Build.0 = Debug|x64 - {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|Win32.ActiveCfg = Release|Win32 - {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|Win32.Build.0 = Release|Win32 - {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|x64.ActiveCfg = Release|x64 - {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|x64.Build.0 = Release|x64 - {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|Win32.ActiveCfg = Release|Win32 - {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|Win32.Build.0 = Release|Win32 - {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|x64.ActiveCfg = Release|x64 - {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|x64.Build.0 = Release|x64 - {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Release|Win32.ActiveCfg = Release|Win32 - {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Release|Win32.Build.0 = Release|Win32 - {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Release|x64.ActiveCfg = Release|x64 - {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal From 8b3045e255d91b94eb62fa9282e27b891e3be1bb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 27 Apr 2015 09:51:39 +0200 Subject: [PATCH 0306/1509] - seems some OpenGL related stuff got lost during merge. Reinstated checks for OpenGL itself but since GLU is no longer needed it was removed for good from the project files. --- src/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5feab8402..50862bbe6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -213,6 +213,18 @@ else( WIN32 ) endif( FPU_CONTROL_DIR ) endif( WIN32 ) +if( X64 ) + set( NO_ASM ON ) +endif( X64 ) + +# Check if we have OpenGL + +if( NOT OPENGL_FOUND ) + message( FATAL_ERROR "OpenGL is required for building." ) +endif( NOT OPENGL_FOUND ) + +set( ZDOOM_LIBS ${ZDOOM_LIBS} ${OPENGL_LIBRARIES} ) +include_directories( ${OPENGL_INCLUDE_DIR} ) if( NOT NO_OPENAL ) find_package( OpenAL ) From 0132c639b106574efcd01bd073e1bf83d429cd82 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 27 Apr 2015 11:00:50 +0200 Subject: [PATCH 0307/1509] - fixed: The display mode enumeration code could add a screen size multiple times if later ones had lower refresh rates. --- src/win32/win32gliface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 2787d9128..c6715b0a7 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -259,6 +259,7 @@ void Win32GLVideo::AddMode(int x, int y, int bits, int baseHeight, int refreshHz // not present, add it to the right spot in the list; otherwise, do nothing. // Modes are sorted first by width, then by height, then by depth. In each // case the order is ascending. + if (bits < 32) return; for (; probe != 0; probep = &probe->next, probe = probe->next) { if (probe->width != x) continue; @@ -269,7 +270,7 @@ void Win32GLVideo::AddMode(int x, int y, int bits, int baseHeight, int refreshHz // Height is equal if (probe->bits != bits) continue; // Bits is equal - if (probe->refreshHz > refreshHz) continue; + if (probe->refreshHz > refreshHz) return; probe->refreshHz = refreshHz; return; } From 6b1e7522e6c5177cc4f7ebf509766217009c5a8b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 27 Apr 2015 15:14:01 +0200 Subject: [PATCH 0308/1509] - Assigned editor number 5006 to SkyCamCompat class, to match Eternity's definition. --- wadsrc/static/mapinfo/common.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/mapinfo/common.txt b/wadsrc/static/mapinfo/common.txt index f292f79a2..e4f190a23 100644 --- a/wadsrc/static/mapinfo/common.txt +++ b/wadsrc/static/mapinfo/common.txt @@ -37,6 +37,7 @@ DoomEdNums 5001 = PointPusher 5002 = PointPuller 5004 = FS_Mapspot + 5006 = SkyCamCompat 5061 = InvisibleBridge32 5064 = InvisibleBridge16 5065 = InvisibleBridge8 From f273b6c46d9d663584a51561bc4f12ca2bc7b83e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 27 Apr 2015 21:25:16 +0200 Subject: [PATCH 0309/1509] - fix uninitialized variable. --- src/gl/system/gl_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index fe27b419c..4a043afe5 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -169,7 +169,7 @@ void gl_LoadExtensions() void gl_PrintStartupLog() { - int v; + int v = 0; glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &v); Printf ("GL_VENDOR: %s\n", glGetString(GL_VENDOR)); From a59824cd8897dea5dd452c31be1328415478f990 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 May 2015 11:36:31 +0200 Subject: [PATCH 0310/1509] - fixed: MD2 vertex indices were signed shorts but should be unsigned. - fixed a few warnings from Visual C++ 2015. --- CMakeLists.txt | 2 +- src/gl/models/gl_models.h | 4 ++-- src/win32/fb_d3d9.cpp | 4 ++-- src/win32/hardware.cpp | 2 +- src/win32/win32gliface.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index db58ccf2f..197593646 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,7 +123,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS( GME if( MSVC ) # Eliminate unreferenced functions and data # Perform identical COMDAT folding - set( REL_LINKER_FLAGS "/opt:ref /opt:icf /nodefaultlib:msvcrt /TSAWARE" ) + set( REL_LINKER_FLAGS "/opt:ref /opt:icf /nodefaultlib:msvcrt /TSAWARE /LARGEADDRESSAWARE" ) # String pooling # Function-level linking diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 89834df8c..af7af7c0f 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -50,8 +50,8 @@ protected: struct FTriangle { - short vertexIndices[3]; - short textureIndices[3]; + unsigned short vertexIndices[3]; + unsigned short textureIndices[3]; }; diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index e23275734..30846fedc 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -3277,8 +3277,8 @@ void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, return; } - cosrot = cos(rot); - sinrot = sin(rot); + cosrot = (float)cos(rot); + sinrot = (float)sin(rot); CheckQuadBatch(npoints - 2, npoints); quad = &QuadExtra[QuadBatchPos]; diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index e9d1bc5e6..2c3fbdea4 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -92,7 +92,7 @@ CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINI break; } //changerenderer = true; - Printf("You must restart "GAMENAME" to switch the renderer\n"); + Printf("You must restart " GAMENAME " to switch the renderer\n"); } } diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index c6715b0a7..fbb276568 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -37,7 +37,7 @@ PFNWGLSWAPINTERVALEXTPROC vsyncfunc; CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL ) { - Printf("This won't take effect until "GAMENAME" is restarted.\n"); + Printf("This won't take effect until " GAMENAME " is restarted.\n"); } CVAR(Bool, gl_debug, false, 0) From 065b7f9ad27b66197bcd63111e9483593e67cd64 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 29 May 2015 12:03:50 +0200 Subject: [PATCH 0311/1509] - fixed: The CollectSectorStack functions had a local sector_t variable used by gl_FakeFlat which caused a stack overflow. Using the global one defined at the top of the file is ok here. --- src/gl/scene/gl_renderhacks.cpp | 7 ++----- src/gl/scene/gl_wall.h | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index a8ef49e25..2a3839037 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -1045,8 +1045,6 @@ void FDrawInfo::AddCeilingStack(sector_t * sec) void FDrawInfo::CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor) { - sector_t fake; - // mark it checked sub->validcount=validcount; @@ -1057,7 +1055,7 @@ void FDrawInfo::CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor) if (sub->numlines>2 && !(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return; // Must be the exact same visplane - sector_t * me = gl_FakeFlat(sub->render_sector, &fake, false); + sector_t * me = gl_FakeFlat(sub->render_sector, &fakesec, false); if (me->GetTexture(sector_t::ceiling) != anchor->GetTexture(sector_t::ceiling) || me->ceilingplane != anchor->ceilingplane || me->GetCeilingLight() != anchor->GetCeilingLight() || @@ -1094,7 +1092,6 @@ void FDrawInfo::CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor) void FDrawInfo::CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor) { - sector_t fake; // mark it checked sub->validcount=validcount; @@ -1105,7 +1102,7 @@ void FDrawInfo::CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor) if (sub->numlines>2 && !(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return; // Must be the exact same visplane - sector_t * me = gl_FakeFlat(sub->render_sector, &fake, false); + sector_t * me = gl_FakeFlat(sub->render_sector, &fakesec, false); if (me->GetTexture(sector_t::floor) != anchor->GetTexture(sector_t::floor) || me->floorplane != anchor->floorplane || me->GetFloorLight() != anchor->GetFloorLight() || diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 7a6acbc89..47ac06c46 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -136,7 +136,6 @@ public: float bottomglowcolor[4]; int dynlightindex; - int firstwall, numwalls; // splitting info. union { From abf11f1a124b4aeb21a389f30342dab5347ca859 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 13 Jul 2015 09:49:02 +0200 Subject: [PATCH 0312/1509] - print an error message if GL_ARB_sampler_objects cannot be found. GZDoom requires this extension and all supported hardware has drivers implementing it but there still seem to be people out there who stuck to some older, obsolete drivers that don't. --- src/gl/system/gl_interface.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 4a043afe5..2e7d0f1e0 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -128,6 +128,10 @@ void gl_LoadExtensions() gl.vendorstring = (char*)glGetString(GL_VENDOR); + if (gl.version < 3.3f && !CheckExtension("GL_ARB_sampler_objects")) + { + I_FatalError("'GL_ARB_sampler_objects' extension not found. Please update your graphics driver."); + } if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; if (!Args->CheckParm("-gl3")) From d90b40909bb4fa5fb45200a54a49d1b634dae94a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 15 Jul 2015 13:02:54 +0200 Subject: [PATCH 0313/1509] - removed leftover #ifdef from a badly resolved merge conflict. --- src/p_3dfloors.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index 285c85f1a..d5ef77709 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -44,7 +44,6 @@ #include "p_terrain.h" #include "r_data/colormaps.h" -#ifdef _3DFLOORS EXTERN_CVAR(Int, vid_renderer) //========================================================================== From d9cc7c52ee187fcab842edaf902cf9b7b329542a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 1 Aug 2015 09:38:20 +0200 Subject: [PATCH 0314/1509] - some declarations for selecting the proper GPU on modern laptops. --- src/win32/win32gliface.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index fbb276568..ca6800de8 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -26,6 +26,11 @@ #include "gl/renderer/gl_renderer.h" #include "gl/system/gl_framebuffer.h" +extern "C" { + _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; + __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; +} + void gl_CalculateCPUSpeed(); extern int NewWidth, NewHeight, NewBits, DisplayBits; From 694dff67e4d48de31cb4620ede937015e612b6cb Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Mon, 26 Oct 2015 09:08:18 -0400 Subject: [PATCH 0315/1509] Copy stereo3d source files from my GLOOME fork. --- src/gl/stereo3d/gl_anaglyph.cpp | 29 +++++++++ src/gl/stereo3d/gl_anaglyph.h | 75 +++++++++++++++++++++++ src/gl/stereo3d/gl_stereo3d.cpp | 71 ++++++++++++++++++++++ src/gl/stereo3d/gl_stereo3d.h | 80 +++++++++++++++++++++++++ src/gl/stereo3d/gl_stereo_cvars.cpp | 51 ++++++++++++++++ src/gl/stereo3d/gl_stereo_leftright.cpp | 79 ++++++++++++++++++++++++ src/gl/stereo3d/gl_stereo_leftright.h | 71 ++++++++++++++++++++++ src/gl/stereo3d/scoped_color_mask.h | 38 ++++++++++++ src/gl/stereo3d/scoped_view_shifter.cpp | 29 +++++++++ src/gl/stereo3d/scoped_view_shifter.h | 25 ++++++++ 10 files changed, 548 insertions(+) create mode 100644 src/gl/stereo3d/gl_anaglyph.cpp create mode 100644 src/gl/stereo3d/gl_anaglyph.h create mode 100644 src/gl/stereo3d/gl_stereo3d.cpp create mode 100644 src/gl/stereo3d/gl_stereo3d.h create mode 100644 src/gl/stereo3d/gl_stereo_cvars.cpp create mode 100644 src/gl/stereo3d/gl_stereo_leftright.cpp create mode 100644 src/gl/stereo3d/gl_stereo_leftright.h create mode 100644 src/gl/stereo3d/scoped_color_mask.h create mode 100644 src/gl/stereo3d/scoped_view_shifter.cpp create mode 100644 src/gl/stereo3d/scoped_view_shifter.h diff --git a/src/gl/stereo3d/gl_anaglyph.cpp b/src/gl/stereo3d/gl_anaglyph.cpp new file mode 100644 index 000000000..ff3926cfc --- /dev/null +++ b/src/gl/stereo3d/gl_anaglyph.cpp @@ -0,0 +1,29 @@ +#include "gl_anaglyph.h" + +namespace s3d { + +MaskAnaglyph::MaskAnaglyph(const ColorMask& leftColorMask, double ipdMeters) + : leftEye(leftColorMask, ipdMeters), rightEye(leftColorMask.inverse(), ipdMeters) +{ + eye_ptrs.push_back(&leftEye); + eye_ptrs.push_back(&rightEye); +} + + +/* static */ +const GreenMagenta& GreenMagenta::getInstance(float ipd) +{ + static GreenMagenta instance(ipd); + return instance; +} + + +/* static */ +const RedCyan& RedCyan::getInstance(float ipd) +{ + static RedCyan instance(ipd); + return instance; +} + + +} /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_anaglyph.h b/src/gl/stereo3d/gl_anaglyph.h new file mode 100644 index 000000000..c95d04205 --- /dev/null +++ b/src/gl/stereo3d/gl_anaglyph.h @@ -0,0 +1,75 @@ +#ifndef GL_ANAGLYPH_H_ +#define GL_ANAGLYPH_H_ + +#include "gl_stereo3d.h" +#include "gl_stereo_leftright.h" + + +namespace s3d { + + +class ColorMask +{ +public: + ColorMask(bool r, bool g, bool b) : r(r), g(g), b(b) {} + ColorMask inverse() const { return ColorMask(!r, !g, !b); } + + GLboolean r; + GLboolean g; + GLboolean b; +}; + + +class AnaglyphLeftPose : public LeftEyePose +{ +public: + AnaglyphLeftPose(const ColorMask& colorMask, float ipd) : LeftEyePose(ipd), colorMask(colorMask) {} + virtual void SetUp() const { glColorMask(colorMask.r, colorMask.g, colorMask.b, true); } + virtual void TearDown() const { glColorMask(1,1,1,1); } +private: + ColorMask colorMask; +}; + +class AnaglyphRightPose : public RightEyePose +{ +public: + AnaglyphRightPose(const ColorMask& colorMask, float ipd) : RightEyePose(ipd), colorMask(colorMask) {} + virtual void SetUp() const { glColorMask(colorMask.r, colorMask.g, colorMask.b, true); } + virtual void TearDown() const { glColorMask(1,1,1,1); } +private: + ColorMask colorMask; +}; + +class MaskAnaglyph : public Stereo3DMode +{ +public: + MaskAnaglyph(const ColorMask& leftColorMask, double ipdMeters); +private: + AnaglyphLeftPose leftEye; + AnaglyphRightPose rightEye; +}; + + +class RedCyan : public MaskAnaglyph +{ +public: + static const RedCyan& getInstance(float ipd); + + RedCyan(float ipd) : MaskAnaglyph(ColorMask(true, false, false), ipd) {} +}; + +class GreenMagenta : public MaskAnaglyph +{ +public: + static const GreenMagenta& getInstance(float ipd); + + GreenMagenta(float ipd) : MaskAnaglyph(ColorMask(false, true, false), ipd) {} +}; + +// TODO matrix anaglyph + + +} /* namespace st3d */ + + +#endif /* GL_ANAGLYPH_H_ */ diff --git a/src/gl/stereo3d/gl_stereo3d.cpp b/src/gl/stereo3d/gl_stereo3d.cpp new file mode 100644 index 000000000..74b36a0fb --- /dev/null +++ b/src/gl/stereo3d/gl_stereo3d.cpp @@ -0,0 +1,71 @@ +#include "gl/stereo3d/gl_stereo3d.h" +#include "vectors.h" // RAD2DEG +#include "doomtype.h" // M_PI + +namespace s3d { + + +/* virtual */ +void EyePose::GetProjection(float fov, float aspectRatio, float fovRatio, GLdouble m[4][4]) const +{ + // Lifted from gl_scene.cpp FGLRenderer::SetProjection() + float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)); + const double zNear = 5.0; + const double zFar = 65536.0; + + double sine, cotangent, deltaZ; + double radians = fovy / 2 * M_PI / 180; + + deltaZ = zFar - zNear; + sine = sin(radians); + if ((deltaZ == 0) || (sine == 0) || (aspectRatio == 0)) { + return; + } + cotangent = cos(radians) / sine; + + memset(m, 0, 16*sizeof(GLdouble)); + m[0][0] = cotangent / aspectRatio; + m[1][1] = cotangent; + m[2][2] = -(zFar + zNear) / deltaZ; + m[2][3] = -1; + m[3][2] = -2 * zNear * zFar / deltaZ; + m[3][3] = 0; +} + +/* virtual */ +Viewport EyePose::GetViewport(const Viewport& fullViewport) const +{ + return fullViewport; +} + + +/* virtual */ +void EyePose::GetViewShift(float yaw, float outViewShift[3]) const +{ + // pass-through for Mono view + outViewShift[0] = 0; + outViewShift[1] = 0; + outViewShift[2] = 0; +} + + +Stereo3DMode::Stereo3DMode() +{ +} + +Stereo3DMode::~Stereo3DMode() +{ +} + +// Avoid static initialization order fiasco by declaring first Mode type (Mono) here in the +// same source file as Stereo3DMode::getCurrentMode() +// https://isocpp.org/wiki/faq/ctors#static-init-order + +/* static */ +const MonoView& MonoView::getInstance() +{ + static MonoView instance; + return instance; +} + +} /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h new file mode 100644 index 000000000..ddbaafaf2 --- /dev/null +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -0,0 +1,80 @@ +#ifndef GL_STEREO3D_H_ +#define GL_STEREO3D_H_ + +#include +#include "gl/system/gl_system.h" + + +/* stereoscopic 3D API */ +namespace s3d { + + +/* Subregion of current display window */ +class Viewport +{ +public: + int x, y; + int width, height; +}; + + +/* Viewpoint of one eye */ +class EyePose +{ +public: + EyePose() {} + virtual ~EyePose() {} + virtual void GetProjection(float fov, float aspectRatio, float fovRatio, GLdouble outMatrix[4][4]) const; + virtual Viewport GetViewport(const Viewport& fullViewport) const; + virtual void GetViewShift(float yaw, float outViewShift[3]) const; + virtual void SetUp() const {}; + virtual void TearDown() const {}; +}; + + +/* Base class for stereoscopic 3D rendering modes */ +class Stereo3DMode +{ +public: + /* const_iterator cycles through the various eye viewpoints */ + typedef std::vector::const_iterator const_iterator; + + /* static methods for managing the selected stereoscopic view state */ + static const Stereo3DMode& getCurrentMode(); + + Stereo3DMode(); + virtual ~Stereo3DMode(); + /* const_iterator cycles through the various eye viewpoints */ + virtual const_iterator begin() const { return eye_ptrs.begin(); } + virtual const_iterator end() const { return eye_ptrs.end(); } + /* hooks for setup and cleanup operations for each stereo mode */ + virtual void SetUp() const {}; + virtual void TearDown() const {}; + +protected: + std::vector eye_ptrs; + +private: + static Stereo3DMode const * currentStereo3DMode; + static void setCurrentMode(const Stereo3DMode& mode); +}; + + +/** +* Ordinary non-3D rendering +*/ +class MonoView : public Stereo3DMode +{ +public: + static const MonoView& getInstance(); + +protected: + MonoView() { eye_ptrs.push_back(¢ralEye); } + EyePose centralEye; +}; + + +} /* namespace st3d */ + + +#endif /* GL_STEREO3D_H_ */ diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp new file mode 100644 index 000000000..e9d115080 --- /dev/null +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -0,0 +1,51 @@ +#include "gl/stereo3d/gl_stereo3d.h" +#include "gl/stereo3d/gl_stereo_leftright.h" +#include "gl/stereo3d/gl_anaglyph.h" +#include "gl/system/gl_cvars.h" + +// Set up 3D-specific console variables: +CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG) +// intraocular distance in meters +CVAR(Float, vr_ipd, 0.062f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // METERS +CVAR(Float, vr_screendist, 0.80f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS +CVAR(Float, vr_hunits_per_meter, 41.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS + +// Manage changing of 3D modes: +namespace s3d { + +// Initialize static member +Stereo3DMode const * Stereo3DMode::currentStereo3DMode = nullptr; + +/* static */ +void Stereo3DMode::setCurrentMode(const Stereo3DMode& mode) { + Stereo3DMode::currentStereo3DMode = &mode; +} + +/* static */ +const Stereo3DMode& Stereo3DMode::getCurrentMode() +{ + // NOTE: Ensure that these vr_mode values correspond to the ones in wadsrc/static/menudef.z + switch (vr_mode) + { + case 1: + setCurrentMode(GreenMagenta::getInstance(vr_ipd)); + break; + case 2: + setCurrentMode(RedCyan::getInstance(vr_ipd)); + break; + case 3: + setCurrentMode(LeftEyeView::getInstance(vr_ipd)); + break; + case 4: + setCurrentMode(RightEyeView::getInstance(vr_ipd)); + break; + case 0: + default: + setCurrentMode(MonoView::getInstance()); + break; + } + return *currentStereo3DMode; +} + +} /* namespace s3d */ + diff --git a/src/gl/stereo3d/gl_stereo_leftright.cpp b/src/gl/stereo3d/gl_stereo_leftright.cpp new file mode 100644 index 000000000..fd1f97729 --- /dev/null +++ b/src/gl/stereo3d/gl_stereo_leftright.cpp @@ -0,0 +1,79 @@ +#include "gl_stereo_leftright.h" +#include "vectors.h" // RAD2DEG +#include "doomtype.h" // M_PI +#include "gl/system/gl_cvars.h" +#include + +EXTERN_CVAR(Float, vr_screendist) +EXTERN_CVAR(Float, vr_hunits_per_meter) + +namespace s3d { + + +/* virtual */ +void ShiftedEyePose::GetProjection(float fov, float aspectRatio, float fovRatio, GLdouble m[4][4]) const +{ + // Lifted from gl_scene.cpp FGLRenderer::SetProjection() + float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)); + double zNear = 5.0; + double zFar = 65536.0; + + // For stereo 3D, use asymmetric frustum shift in projection matrix + // Q: shouldn't shift vary with roll angle, at least for desktop display? + // A: (lab) roll is not measured on desktop display (yet) + double frustumShift = zNear * shift / vr_screendist; // meters cancel + // double frustumShift = 0; // Turning off shift for debugging + double fH = tan(fovy / 360 * M_PI) * zNear; + double fW = fH * aspectRatio; + // Emulate glFrustum command: + // glFrustum(-fW - frustumShift, fW - frustumShift, -fH, fH, zNear, zFar); + double left = -fW - frustumShift; + double right = fW - frustumShift; + double bottom = -fH; + double top = fH; + double deltaZ = zFar - zNear; + + memset(m, 0, 16 * sizeof(GLdouble)); // set all elements to zero, cleverly + + // https://www.opengl.org/sdk/docs/man2/xhtml/glFrustum.xml + m[0][0] = 2 * zNear / (right - left); + m[1][1] = 2 * zNear / (top - bottom); + m[2][2] = -(zFar + zNear) / deltaZ; + m[2][3] = -1; + m[3][2] = -2 * zNear * zFar / deltaZ; + // m[3][3] = 0; // redundant + // m[2][1] = (top + bottom) / (top - bottom); // zero for the cases I know of... + m[2][0] = (right + left) / (right - left); // asymmetric shift is in this term +} + + +/* virtual */ +void ShiftedEyePose::GetViewShift(float yaw, float outViewShift[3]) const +{ + float dx = cos(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; + float dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; + outViewShift[0] = dx; + outViewShift[1] = dy; + outViewShift[2] = 0; +} + + +/* static */ +const LeftEyeView& LeftEyeView::getInstance(float ipd) +{ + static LeftEyeView instance(ipd); + instance.setIpd(ipd); + return instance; +} + + +/* static */ +const RightEyeView& RightEyeView::getInstance(float ipd) +{ + static RightEyeView instance(ipd); + instance.setIpd(ipd); + return instance; +} + + +} /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_stereo_leftright.h b/src/gl/stereo3d/gl_stereo_leftright.h new file mode 100644 index 000000000..78f66e7fe --- /dev/null +++ b/src/gl/stereo3d/gl_stereo_leftright.h @@ -0,0 +1,71 @@ +#ifndef GL_STEREO_LEFTRIGHT_H_ +#define GL_STEREO_LEFTRIGHT_H_ + +#include "gl_stereo3d.h" + +namespace s3d { + + +class ShiftedEyePose : public EyePose +{ +public: + ShiftedEyePose(float shift) : shift(shift) {}; + float getShift() const { return shift; } + void setShift(float shift) { this->shift = shift; } + virtual void GetProjection(float fov, float aspectRatio, float fovRatio, GLdouble outMatrix[4][4]) const; + virtual void GetViewShift(float yaw, float outViewShift[3]) const; +protected: + float shift; +}; + + +class LeftEyePose : public ShiftedEyePose +{ +public: + LeftEyePose(float ipd) : ShiftedEyePose(-0.5*ipd) {} + float getIpd() const { return -2.0*getShift(); } + void setIpd(float ipd) { setShift(-0.5*ipd); } +}; + + +class RightEyePose : public ShiftedEyePose +{ +public: + RightEyePose(float ipd) : ShiftedEyePose(+0.5*ipd) {} + float getIpd() const { return +2.0*shift; } + void setIpd(float ipd) { setShift(+0.5*ipd); } +}; + + +/** + * As if viewed through the left eye only + */ +class LeftEyeView : public Stereo3DMode +{ +public: + static const LeftEyeView& getInstance(float ipd); + + LeftEyeView(float ipd) : eye(ipd) { eye_ptrs.push_back(&eye); } + float getIpd() const { return eye.getIpd(); } + void setIpd(float ipd) { eye.setIpd(ipd); } +protected: + LeftEyePose eye; +}; + + +class RightEyeView : public Stereo3DMode +{ +public: + static const RightEyeView& getInstance(float ipd); + + RightEyeView(float ipd) : eye(ipd) { eye_ptrs.push_back(&eye); } + float getIpd() const { return eye.getIpd(); } + void setIpd(float ipd) { eye.setIpd(ipd); } +protected: + RightEyePose eye; +}; + + +} /* namespace s3d */ + +#endif /* GL_STEREO_LEFTRIGHT_H_ */ diff --git a/src/gl/stereo3d/scoped_color_mask.h b/src/gl/stereo3d/scoped_color_mask.h new file mode 100644 index 000000000..cc3a1df1d --- /dev/null +++ b/src/gl/stereo3d/scoped_color_mask.h @@ -0,0 +1,38 @@ +#ifndef GL_STEREO3D_SCOPED_COLOR_MASK_H_ +#define GL_STEREO3D_SCOPED_COLOR_MASK_H_ + +#include "gl/glew.h" + +/** +* Temporarily change color mask +*/ +class ScopedColorMask +{ +public: + ScopedColorMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a) + : isPushed(false) + { + setColorMask(r, g, b, a); + } + ~ScopedColorMask() { + revert(); + } + void setColorMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a) { + if (!isPushed) { + glPushAttrib(GL_COLOR_BUFFER_BIT); + isPushed = true; + } + glColorMask(r, g, b, a); + } + void revert() { + if (isPushed) { + glPopAttrib(); + isPushed = false; + } + } +private: + bool isPushed; +}; + + +#endif // GL_STEREO3D_SCOPED_COLOR_MASK_H_ diff --git a/src/gl/stereo3d/scoped_view_shifter.cpp b/src/gl/stereo3d/scoped_view_shifter.cpp new file mode 100644 index 000000000..74511f3f5 --- /dev/null +++ b/src/gl/stereo3d/scoped_view_shifter.cpp @@ -0,0 +1,29 @@ +#include "scoped_view_shifter.h" +#include "r_utility.h" + +namespace s3d { + +ScopedViewShifter::ScopedViewShifter(float dxyz[3]) // in meters +{ + // save original values + cachedViewx = viewx; + cachedViewy = viewy; + cachedViewz = viewz; + // modify values + float fViewx = FIXED2FLOAT(viewx) - dxyz[0]; + float fViewy = FIXED2FLOAT(viewy) + dxyz[1]; + float fViewz = FIXED2FLOAT(viewz) + dxyz[2]; + viewx = FLOAT2FIXED(fViewx); + viewy = FLOAT2FIXED(fViewy); + viewz = FLOAT2FIXED(fViewz); +} + +ScopedViewShifter::~ScopedViewShifter() +{ + // restore original values + viewx = cachedViewx; + viewy = cachedViewy; + viewz = cachedViewz; +} + +} \ No newline at end of file diff --git a/src/gl/stereo3d/scoped_view_shifter.h b/src/gl/stereo3d/scoped_view_shifter.h new file mode 100644 index 000000000..0b4f201a4 --- /dev/null +++ b/src/gl/stereo3d/scoped_view_shifter.h @@ -0,0 +1,25 @@ +#ifndef GL_STEREO3D_SCOPED_VIEW_SHIFTER_H_ +#define GL_STEREO3D_SCOPED_VIEW_SHIFTER_H_ + +#include "basictypes.h" + +namespace s3d { + + /** + * Temporarily shift viewx, viewy, viewz + */ + class ScopedViewShifter + { + public: + ScopedViewShifter(float dxyz[3]); // in meters + ~ScopedViewShifter(); + + private: + fixed_t cachedViewx; + fixed_t cachedViewy; + fixed_t cachedViewz; + }; + +} /* namespace s3d */ + +#endif // GL_STEREO3D_SCOPED_VIEW_SHIFTER_H_ From 0874455faf8c169e0c50504032e645b89bb7f462 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Fri, 30 Oct 2015 20:51:35 -0400 Subject: [PATCH 0316/1509] Initial implementation of five 3D modes -- some bugs remain. --- .gitattributes | 1 + .gitignore | 1 + src/CMakeLists.txt | 7 ++ src/gl/renderer/gl_renderer.h | 2 + src/gl/scene/gl_drawinfo.cpp | 83 ++++++++-------- src/gl/scene/gl_portal.cpp | 126 +++++++++++++----------- src/gl/scene/gl_scene.cpp | 47 +++++++-- src/gl/stereo3d/gl_anaglyph.cpp | 4 +- src/gl/stereo3d/gl_anaglyph.h | 1 + src/gl/stereo3d/gl_stereo3d.cpp | 19 ++-- src/gl/stereo3d/gl_stereo3d.h | 6 +- src/gl/stereo3d/gl_stereo_cvars.cpp | 5 +- src/gl/stereo3d/gl_stereo_leftright.cpp | 16 +-- src/gl/stereo3d/gl_stereo_leftright.h | 40 ++++---- src/gl/stereo3d/scoped_color_mask.h | 23 +---- wadsrc/static/menudef.z | 10 ++ 16 files changed, 219 insertions(+), 172 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..5ce158013 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.cpp text diff --git a/.gitignore b/.gitignore index 849ed7b2a..b3d0eb257 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ /zlib/x64/ /build_vc2013_64bit /build_vc2015 +/build_cmake diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 799bf6dd4..3ef99327b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -762,6 +762,7 @@ file( GLOB HEADER_FILES gl/models/*.h gl/renderer/*.h gl/scene/*.h + gl/stereo3d/*.h gl/shaders/*.h gl/system/*.h gl/textures/*.h @@ -1120,6 +1121,11 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE gl/scene/gl_walls_draw.cpp gl/scene/gl_vertex.cpp gl/scene/gl_spritelight.cpp + gl/stereo3d/gl_stereo3d.cpp + gl/stereo3d/gl_stereo_cvars.cpp + gl/stereo3d/gl_stereo_leftright.cpp + gl/stereo3d/scoped_view_shifter.cpp + gl/stereo3d/gl_anaglyph.cpp gl/dynlights/gl_dynlight.cpp gl/dynlights/gl_glow.cpp gl/dynlights/gl_dynlight1.cpp @@ -1371,6 +1377,7 @@ source_group("OpenGL Renderer\\HQ Resize Assembly version" REGULAR_EXPRESSION "^ source_group("OpenGL Renderer\\Models" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/models/.+") source_group("OpenGL Renderer\\Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/renderer/.+") source_group("OpenGL Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/scene/.+") +source_group("OpenGL Renderer\\Stereo3D" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/stereo3d/.+") source_group("OpenGL Renderer\\Shaders" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/shaders/.+") source_group("OpenGL Renderer\\System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/system/.+") source_group("OpenGL Renderer\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/textures/.+") diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 534745869..3374c904a 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -5,6 +5,7 @@ #include "v_video.h" #include "vectors.h" #include "r_renderer.h" +#include "gl/data/gl_matrix.h" struct particle_t; class FCanvasTexture; @@ -120,6 +121,7 @@ public: void Flush() {} void SetProjection(float fov, float ratio, float fovratio); + void SetProjection(FLOATTYPE matrix[4][4]); // raw matrix input from stereo 3d modes void SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, bool mirror, bool planemirror); void ProcessScene(bool toscreen = false); diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 08eb3b26d..4dba1a2a0 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -56,6 +56,7 @@ #include "gl/utility/gl_clock.h" #include "gl/utility/gl_templates.h" #include "gl/shaders/gl_shader.h" +#include "gl/stereo3d/scoped_color_mask.h" FDrawInfo * gl_drawinfo; @@ -1009,31 +1010,33 @@ void FDrawInfo::SetupFloodStencil(wallseg * ws) int recursion = GLPortal::GetRecursion(); // Create stencil - glStencilFunc(GL_EQUAL,recursion,~0); // create stencil - glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); // increment stencil of valid pixels - glColorMask(0,0,0,0); // don't write to the graphics buffer - gl_RenderState.EnableTexture(false); - gl_RenderState.ResetColor(); - glEnable(GL_DEPTH_TEST); - glDepthMask(true); + glStencilFunc(GL_EQUAL, recursion, ~0); // create stencil + glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); // increment stencil of valid pixels + { + // Use revertible color mask, to avoid stomping on anaglyph 3D state + ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // don't write to the graphics buffer + gl_RenderState.EnableTexture(false); + gl_RenderState.ResetColor(); + glEnable(GL_DEPTH_TEST); + glDepthMask(true); - gl_RenderState.Apply(); - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0); - ptr++; - ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0); - ptr++; - ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0); - ptr++; - ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + gl_RenderState.Apply(); + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); - glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil - glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil + glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil - glColorMask(1,1,1,1); // don't write to the graphics buffer + } // glColorMask(1, 1, 1, 1); // don't write to the graphics buffer gl_RenderState.EnableTexture(true); glDisable(GL_DEPTH_TEST); glDepthMask(false); @@ -1045,26 +1048,28 @@ void FDrawInfo::ClearFloodStencil(wallseg * ws) glStencilOp(GL_KEEP,GL_KEEP,GL_DECR); gl_RenderState.EnableTexture(false); - glColorMask(0,0,0,0); // don't write to the graphics buffer - gl_RenderState.ResetColor(); + { + // Use revertible color mask, to avoid stomping on anaglyph 3D state + ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0,0,0,0); // don't write to the graphics buffer + gl_RenderState.ResetColor(); - gl_RenderState.Apply(); - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0); - ptr++; - ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0); - ptr++; - ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0); - ptr++; - ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + gl_RenderState.Apply(); + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); - // restore old stencil op. - glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); - glStencilFunc(GL_EQUAL,recursion,~0); - gl_RenderState.EnableTexture(true); - glColorMask(1,1,1,1); + // restore old stencil op. + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + glStencilFunc(GL_EQUAL, recursion, ~0); + gl_RenderState.EnableTexture(true); + } // glColorMask(1, 1, 1, 1); glEnable(GL_DEPTH_TEST); glDepthMask(true); } diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 54bc9b540..7ff82db4c 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -59,6 +59,7 @@ #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" #include "gl/shaders/gl_shader.h" +#include "gl/stereo3d/scoped_color_mask.h" #include "gl/textures/gl_material.h" #include "gl/utility/gl_clock.h" #include "gl/utility/gl_templates.h" @@ -197,7 +198,7 @@ bool GLPortal::Start(bool usestencil, bool doquery) // Create stencil glStencilFunc(GL_EQUAL,recursion,~0); // create stencil glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); // increment stencil of valid pixels - glColorMask(0,0,0,0); // don't write to the graphics buffer + // glColorMask(0,0,0,0); // don't write to the graphics buffer gl_RenderState.SetEffect(EFF_STENCIL); gl_RenderState.EnableTexture(false); gl_RenderState.ResetColor(); @@ -206,34 +207,36 @@ bool GLPortal::Start(bool usestencil, bool doquery) if (NeedDepthBuffer()) { - glDepthMask(false); // don't write to Z-buffer! - if (!NeedDepthBuffer()) doquery = false; // too much overhead and nothing to gain. - else if (gl_noquery) doquery = false; - - // If occlusion query is supported let's use it to avoid rendering portals that aren't visible - if (!QueryObject) glGenQueries(1, &QueryObject); - if (QueryObject) { - glBeginQuery(GL_SAMPLES_PASSED, QueryObject); - } - else doquery = false; // some kind of error happened + ScopedColorMask colorMask(0, 0, 0, 0); + glDepthMask(false); // don't write to Z-buffer! + if (!NeedDepthBuffer()) doquery = false; // too much overhead and nothing to gain. + else if (gl_noquery) doquery = false; - DrawPortalStencil(); + // If occlusion query is supported let's use it to avoid rendering portals that aren't visible + if (!QueryObject) glGenQueries(1, &QueryObject); + if (QueryObject) + { + glBeginQuery(GL_SAMPLES_PASSED, QueryObject); + } + else doquery = false; // some kind of error happened - glEndQuery(GL_SAMPLES_PASSED); + DrawPortalStencil(); - // Clear Z-buffer - glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil - glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil - glDepthMask(true); // enable z-buffer again - glDepthRange(1,1); - glDepthFunc(GL_ALWAYS); - DrawPortalStencil(); + glEndQuery(GL_SAMPLES_PASSED); - // set normal drawing mode - gl_RenderState.EnableTexture(true); - glDepthFunc(GL_LESS); - glColorMask(1,1,1,1); + // Clear Z-buffer + glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil + glDepthMask(true); // enable z-buffer again + glDepthRange(1, 1); + glDepthFunc(GL_ALWAYS); + DrawPortalStencil(); + + // set normal drawing mode + gl_RenderState.EnableTexture(true); + glDepthFunc(GL_LESS); + } // glColorMask(1, 1, 1, 1); gl_RenderState.SetEffect(EFF_NONE); glDepthRange(0, 1); @@ -258,12 +261,13 @@ bool GLPortal::Start(bool usestencil, bool doquery) // than the benefit. // Note: We must draw the stencil with z-write enabled here because there is no second pass! + ScopedColorMask colorMask(0, 0, 0, 0); glDepthMask(true); DrawPortalStencil(); glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil gl_RenderState.EnableTexture(true); - glColorMask(1,1,1,1); + // glColorMask(1,1,1,1); gl_RenderState.SetEffect(EFF_NONE); glDisable(GL_DEPTH_TEST); glDepthMask(false); // don't write to Z-buffer! @@ -369,38 +373,39 @@ void GLPortal::End(bool usestencil) viewangle=savedviewangle; GLRenderer->mViewActor=savedviewactor; in_area=savedviewarea; - GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); - glColorMask(0,0,0,0); // no graphics - gl_RenderState.SetEffect(EFF_NONE); - gl_RenderState.ResetColor(); - gl_RenderState.EnableTexture(false); - gl_RenderState.Apply(); - - if (needdepth) { - // first step: reset the depth buffer to max. depth - glDepthRange(1,1); // always - glDepthFunc(GL_ALWAYS); // write the farthest depth value + ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // no graphics + gl_RenderState.SetEffect(EFF_NONE); + gl_RenderState.ResetColor(); + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(); + + if (needdepth) + { + // first step: reset the depth buffer to max. depth + glDepthRange(1, 1); // always + glDepthFunc(GL_ALWAYS); // write the farthest depth value + DrawPortalStencil(); + } + else + { + glEnable(GL_DEPTH_TEST); + } + + // second step: restore the depth buffer to the previous values and reset the stencil + glDepthFunc(GL_LEQUAL); + glDepthRange(0, 1); + glStencilOp(GL_KEEP, GL_KEEP, GL_DECR); + glStencilFunc(GL_EQUAL, recursion, ~0); // draw sky into stencil DrawPortalStencil(); - } - else - { - glEnable(GL_DEPTH_TEST); - } - - // second step: restore the depth buffer to the previous values and reset the stencil - glDepthFunc(GL_LEQUAL); - glDepthRange(0,1); - glStencilOp(GL_KEEP,GL_KEEP,GL_DECR); - glStencilFunc(GL_EQUAL,recursion,~0); // draw sky into stencil - DrawPortalStencil(); - glDepthFunc(GL_LESS); + glDepthFunc(GL_LESS); - gl_RenderState.EnableTexture(true); - gl_RenderState.SetEffect(EFF_NONE); - glColorMask(1, 1, 1, 1); + gl_RenderState.EnableTexture(true); + gl_RenderState.SetEffect(EFF_NONE); + } // glColorMask(1, 1, 1, 1); recursion--; // restore old stencil op. @@ -433,14 +438,15 @@ void GLPortal::End(bool usestencil) gl_RenderState.ResetColor(); glDepthFunc(GL_LEQUAL); - glDepthRange(0,1); - glColorMask(0,0,0,0); // no graphics - gl_RenderState.SetEffect(EFF_STENCIL); - gl_RenderState.EnableTexture(false); - DrawPortalStencil(); - gl_RenderState.SetEffect(EFF_NONE); - gl_RenderState.EnableTexture(true); - glColorMask(1,1,1,1); + glDepthRange(0, 1); + { + ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0,0,0,0); // no graphics + gl_RenderState.SetEffect(EFF_STENCIL); + gl_RenderState.EnableTexture(false); + DrawPortalStencil(); + gl_RenderState.SetEffect(EFF_NONE); + gl_RenderState.EnableTexture(true); + } // glColorMask(1, 1, 1, 1); glDepthFunc(GL_LESS); } PortalAll.Unclock(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 3d716e215..618c285c0 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -71,6 +71,8 @@ #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" #include "gl/shaders/gl_shader.h" +#include "gl/stereo3d/gl_stereo3d.h" +#include "gl/stereo3d/scoped_view_shifter.h" #include "gl/textures/gl_material.h" #include "gl/utility/gl_clock.h" #include "gl/utility/gl_convert.h" @@ -254,6 +256,13 @@ void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) gl_RenderState.Set2DMode(false); } +// raw matrix input from stereo 3d modes +void FGLRenderer::SetProjection(FLOATTYPE matrix[4][4]) +{ + gl_RenderState.mProjectionMatrix.loadMatrix(&matrix[0][0]); + gl_RenderState.Set2DMode(false); +} + //----------------------------------------------------------------------------- // // Setup the modelview matrix @@ -802,18 +811,36 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo retval = viewsector; - SetViewport(bounds); - mCurrentFoV = fov; - SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper - SetViewAngle(viewangle); - SetViewMatrix(viewx, viewy, viewz, false, false); - gl_RenderState.ApplyMatrices(); + // Render (potentially) multiple views for stereo 3d + FLOATTYPE projectionMatrix[4][4]; + float viewShift[3]; + const s3d::Stereo3DMode& stereo3dMode = s3d::Stereo3DMode::getCurrentMode(); + stereo3dMode.SetUp(); + s3d::Stereo3DMode::const_iterator eye; + for (eye = stereo3dMode.begin(); eye != stereo3dMode.end(); ++eye) + { + (*eye)->SetUp(); + // TODO: stereo specific viewport - needed when implementing side-by-side modes etc. + SetViewport(bounds); + mCurrentFoV = fov; + // Stereo mode specific perspective projection + (*eye)->GetProjection(fov, ratio, fovratio, projectionMatrix); + SetProjection(projectionMatrix); + SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper + SetViewAngle(viewangle); + // Stereo mode specific viewpoint adjustment - temporarily shifts global viewx, viewy, viewz + (*eye)->GetViewShift(GLRenderer->mAngles.Yaw, viewShift); + s3d::ScopedViewShifter viewShifter(viewShift); + SetViewMatrix(viewx, viewy, viewz, false, false); + gl_RenderState.ApplyMatrices(); - clipper.Clear(); - angle_t a1 = FrustumAngle(); - clipper.SafeAddClipRangeRealAngles(viewangle+a1, viewangle-a1); + clipper.Clear(); + angle_t a1 = FrustumAngle(); + clipper.SafeAddClipRangeRealAngles(viewangle + a1, viewangle - a1); - ProcessScene(toscreen); + ProcessScene(toscreen); + } + stereo3dMode.TearDown(); gl_frameCount++; // This counter must be increased right before the interpolations are restored. interpolator.RestoreInterpolations (); diff --git a/src/gl/stereo3d/gl_anaglyph.cpp b/src/gl/stereo3d/gl_anaglyph.cpp index ff3926cfc..e8be92882 100644 --- a/src/gl/stereo3d/gl_anaglyph.cpp +++ b/src/gl/stereo3d/gl_anaglyph.cpp @@ -11,7 +11,7 @@ MaskAnaglyph::MaskAnaglyph(const ColorMask& leftColorMask, double ipdMeters) /* static */ -const GreenMagenta& GreenMagenta::getInstance(float ipd) +const GreenMagenta& GreenMagenta::getInstance(FLOATTYPE ipd) { static GreenMagenta instance(ipd); return instance; @@ -19,7 +19,7 @@ const GreenMagenta& GreenMagenta::getInstance(float ipd) /* static */ -const RedCyan& RedCyan::getInstance(float ipd) +const RedCyan& RedCyan::getInstance(FLOATTYPE ipd) { static RedCyan instance(ipd); return instance; diff --git a/src/gl/stereo3d/gl_anaglyph.h b/src/gl/stereo3d/gl_anaglyph.h index c95d04205..4be6da99e 100644 --- a/src/gl/stereo3d/gl_anaglyph.h +++ b/src/gl/stereo3d/gl_anaglyph.h @@ -3,6 +3,7 @@ #include "gl_stereo3d.h" #include "gl_stereo_leftright.h" +#include "gl/system/gl_system.h" namespace s3d { diff --git a/src/gl/stereo3d/gl_stereo3d.cpp b/src/gl/stereo3d/gl_stereo3d.cpp index 74b36a0fb..e053266b7 100644 --- a/src/gl/stereo3d/gl_stereo3d.cpp +++ b/src/gl/stereo3d/gl_stereo3d.cpp @@ -6,24 +6,23 @@ namespace s3d { /* virtual */ -void EyePose::GetProjection(float fov, float aspectRatio, float fovRatio, GLdouble m[4][4]) const +void EyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio, FLOATTYPE m[4][4]) const { // Lifted from gl_scene.cpp FGLRenderer::SetProjection() - float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)); - const double zNear = 5.0; - const double zFar = 65536.0; + double fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)); + const FLOATTYPE zNear = 5.0; + const FLOATTYPE zFar = 65536.0; - double sine, cotangent, deltaZ; double radians = fovy / 2 * M_PI / 180; - deltaZ = zFar - zNear; - sine = sin(radians); + FLOATTYPE deltaZ = zFar - zNear; + double sine = sin(radians); if ((deltaZ == 0) || (sine == 0) || (aspectRatio == 0)) { return; } - cotangent = cos(radians) / sine; + FLOATTYPE cotangent = FLOATTYPE(cos(radians) / sine); - memset(m, 0, 16*sizeof(GLdouble)); + memset(m, 0, 16*sizeof(FLOATTYPE)); m[0][0] = cotangent / aspectRatio; m[1][1] = cotangent; m[2][2] = -(zFar + zNear) / deltaZ; @@ -40,7 +39,7 @@ Viewport EyePose::GetViewport(const Viewport& fullViewport) const /* virtual */ -void EyePose::GetViewShift(float yaw, float outViewShift[3]) const +void EyePose::GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const { // pass-through for Mono view outViewShift[0] = 0; diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h index ddbaafaf2..6421b2a9e 100644 --- a/src/gl/stereo3d/gl_stereo3d.h +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -2,7 +2,7 @@ #define GL_STEREO3D_H_ #include -#include "gl/system/gl_system.h" +#include "gl/data/gl_matrix.h" /* stereoscopic 3D API */ @@ -24,9 +24,9 @@ class EyePose public: EyePose() {} virtual ~EyePose() {} - virtual void GetProjection(float fov, float aspectRatio, float fovRatio, GLdouble outMatrix[4][4]) const; + virtual void GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio, FLOATTYPE outMatrix[4][4]) const; virtual Viewport GetViewport(const Viewport& fullViewport) const; - virtual void GetViewShift(float yaw, float outViewShift[3]) const; + virtual void GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const; virtual void SetUp() const {}; virtual void TearDown() const {}; }; diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index e9d115080..b91a47daa 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -33,10 +33,11 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() case 2: setCurrentMode(RedCyan::getInstance(vr_ipd)); break; - case 3: + // TODO: missing indices 3, 4 for not-yet-implemented side-by-side modes, to match values from GZ3Doom + case 5: setCurrentMode(LeftEyeView::getInstance(vr_ipd)); break; - case 4: + case 6: setCurrentMode(RightEyeView::getInstance(vr_ipd)); break; case 0: diff --git a/src/gl/stereo3d/gl_stereo_leftright.cpp b/src/gl/stereo3d/gl_stereo_leftright.cpp index fd1f97729..58cbb086e 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.cpp +++ b/src/gl/stereo3d/gl_stereo_leftright.cpp @@ -11,10 +11,10 @@ namespace s3d { /* virtual */ -void ShiftedEyePose::GetProjection(float fov, float aspectRatio, float fovRatio, GLdouble m[4][4]) const +void ShiftedEyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio, FLOATTYPE m[4][4]) const { // Lifted from gl_scene.cpp FGLRenderer::SetProjection() - float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)); + FLOATTYPE fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)); double zNear = 5.0; double zFar = 65536.0; @@ -33,7 +33,7 @@ void ShiftedEyePose::GetProjection(float fov, float aspectRatio, float fovRatio, double top = fH; double deltaZ = zFar - zNear; - memset(m, 0, 16 * sizeof(GLdouble)); // set all elements to zero, cleverly + memset(m, 0, 16 * sizeof(FLOATTYPE)); // set all elements to zero, cleverly // https://www.opengl.org/sdk/docs/man2/xhtml/glFrustum.xml m[0][0] = 2 * zNear / (right - left); @@ -48,10 +48,10 @@ void ShiftedEyePose::GetProjection(float fov, float aspectRatio, float fovRatio, /* virtual */ -void ShiftedEyePose::GetViewShift(float yaw, float outViewShift[3]) const +void ShiftedEyePose::GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const { - float dx = cos(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; - float dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; + FLOATTYPE dx = cos(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; + FLOATTYPE dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; outViewShift[0] = dx; outViewShift[1] = dy; outViewShift[2] = 0; @@ -59,7 +59,7 @@ void ShiftedEyePose::GetViewShift(float yaw, float outViewShift[3]) const /* static */ -const LeftEyeView& LeftEyeView::getInstance(float ipd) +const LeftEyeView& LeftEyeView::getInstance(FLOATTYPE ipd) { static LeftEyeView instance(ipd); instance.setIpd(ipd); @@ -68,7 +68,7 @@ const LeftEyeView& LeftEyeView::getInstance(float ipd) /* static */ -const RightEyeView& RightEyeView::getInstance(float ipd) +const RightEyeView& RightEyeView::getInstance(FLOATTYPE ipd) { static RightEyeView instance(ipd); instance.setIpd(ipd); diff --git a/src/gl/stereo3d/gl_stereo_leftright.h b/src/gl/stereo3d/gl_stereo_leftright.h index 78f66e7fe..228b6459f 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.h +++ b/src/gl/stereo3d/gl_stereo_leftright.h @@ -9,31 +9,31 @@ namespace s3d { class ShiftedEyePose : public EyePose { public: - ShiftedEyePose(float shift) : shift(shift) {}; - float getShift() const { return shift; } - void setShift(float shift) { this->shift = shift; } - virtual void GetProjection(float fov, float aspectRatio, float fovRatio, GLdouble outMatrix[4][4]) const; - virtual void GetViewShift(float yaw, float outViewShift[3]) const; + ShiftedEyePose(FLOATTYPE shift) : shift(shift) {}; + FLOATTYPE getShift() const { return shift; } + void setShift(FLOATTYPE shift) { this->shift = shift; } + virtual void GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio, FLOATTYPE outMatrix[4][4]) const; + virtual void GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const; protected: - float shift; + FLOATTYPE shift; }; class LeftEyePose : public ShiftedEyePose { public: - LeftEyePose(float ipd) : ShiftedEyePose(-0.5*ipd) {} - float getIpd() const { return -2.0*getShift(); } - void setIpd(float ipd) { setShift(-0.5*ipd); } + LeftEyePose(FLOATTYPE ipd) : ShiftedEyePose( FLOATTYPE(-0.5) * ipd) {} + FLOATTYPE getIpd() const { return FLOATTYPE(-2.0)*getShift(); } + void setIpd(FLOATTYPE ipd) { setShift(FLOATTYPE(-0.5)*ipd); } }; class RightEyePose : public ShiftedEyePose { public: - RightEyePose(float ipd) : ShiftedEyePose(+0.5*ipd) {} - float getIpd() const { return +2.0*shift; } - void setIpd(float ipd) { setShift(+0.5*ipd); } + RightEyePose(FLOATTYPE ipd) : ShiftedEyePose(FLOATTYPE(+0.5)*ipd) {} + FLOATTYPE getIpd() const { return FLOATTYPE(+2.0)*shift; } + void setIpd(FLOATTYPE ipd) { setShift(FLOATTYPE(+0.5)*ipd); } }; @@ -43,11 +43,11 @@ public: class LeftEyeView : public Stereo3DMode { public: - static const LeftEyeView& getInstance(float ipd); + static const LeftEyeView& getInstance(FLOATTYPE ipd); - LeftEyeView(float ipd) : eye(ipd) { eye_ptrs.push_back(&eye); } - float getIpd() const { return eye.getIpd(); } - void setIpd(float ipd) { eye.setIpd(ipd); } + LeftEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.push_back(&eye); } + FLOATTYPE getIpd() const { return eye.getIpd(); } + void setIpd(FLOATTYPE ipd) { eye.setIpd(ipd); } protected: LeftEyePose eye; }; @@ -56,11 +56,11 @@ protected: class RightEyeView : public Stereo3DMode { public: - static const RightEyeView& getInstance(float ipd); + static const RightEyeView& getInstance(FLOATTYPE ipd); - RightEyeView(float ipd) : eye(ipd) { eye_ptrs.push_back(&eye); } - float getIpd() const { return eye.getIpd(); } - void setIpd(float ipd) { eye.setIpd(ipd); } + RightEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.push_back(&eye); } + FLOATTYPE getIpd() const { return eye.getIpd(); } + void setIpd(FLOATTYPE ipd) { eye.setIpd(ipd); } protected: RightEyePose eye; }; diff --git a/src/gl/stereo3d/scoped_color_mask.h b/src/gl/stereo3d/scoped_color_mask.h index cc3a1df1d..f746ba9e4 100644 --- a/src/gl/stereo3d/scoped_color_mask.h +++ b/src/gl/stereo3d/scoped_color_mask.h @@ -1,7 +1,7 @@ #ifndef GL_STEREO3D_SCOPED_COLOR_MASK_H_ #define GL_STEREO3D_SCOPED_COLOR_MASK_H_ -#include "gl/glew.h" +#include "gl/system/gl_system.h" /** * Temporarily change color mask @@ -10,28 +10,15 @@ class ScopedColorMask { public: ScopedColorMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a) - : isPushed(false) { - setColorMask(r, g, b, a); - } - ~ScopedColorMask() { - revert(); - } - void setColorMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a) { - if (!isPushed) { - glPushAttrib(GL_COLOR_BUFFER_BIT); - isPushed = true; - } + glGetBooleanv(GL_COLOR_WRITEMASK, saved); glColorMask(r, g, b, a); } - void revert() { - if (isPushed) { - glPopAttrib(); - isPushed = false; - } + ~ScopedColorMask() { + glColorMask(saved[0], saved[1], saved[2], saved[3]); } private: - bool isPushed; + GLboolean saved[4]; }; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 75ea1bf5f..3874b0328 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -124,6 +124,15 @@ OptionValue "FuzzStyle" //5, "Jagged fuzz" I can't see any difference between this and 4 so it's disabled for now. } +OptionValue VRMode +{ + 0, "Normal" + 1, "Green/Magenta" + 2, "Red/Cyan" + 5, "Left Eye" + 6, "Right Eye" +} + OptionMenu "GLTextureGLOptions" { Title "TEXTURE OPTIONS" @@ -173,5 +182,6 @@ OptionMenu "GLPrefOptions" Option "Particle style", gl_particles_style, "Particles" Slider "Ambient light level", gl_light_ambient, 1.0, 255.0, 5.0 Option "Rendering quality", gl_render_precise, "Precision" + Option "Stereo 3D VR", vr_mode, "VRMode" } From b82d61193669657c2bc24bc280bc5735c15aeacc Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Fri, 30 Oct 2015 21:29:36 -0400 Subject: [PATCH 0317/1509] Call EndDrawScene for each eye. Actually use stereoscopic projection matrix. --- src/gl/scene/gl_drawinfo.cpp | 10 +- src/gl/scene/gl_portal.cpp | 61 +- src/gl/scene/gl_scene.cpp | 4 +- src/win32/i_system.cpp | 3404 +++++++++++++++++----------------- 4 files changed, 1740 insertions(+), 1739 deletions(-) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 4dba1a2a0..5c0c53047 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -1014,7 +1014,8 @@ void FDrawInfo::SetupFloodStencil(wallseg * ws) glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); // increment stencil of valid pixels { // Use revertible color mask, to avoid stomping on anaglyph 3D state - ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // don't write to the graphics buffer + // ScopedColorMask colorMask(0, 0, 0, 0); + glColorMask(0, 0, 0, 0); // don't write to the graphics buffer gl_RenderState.EnableTexture(false); gl_RenderState.ResetColor(); glEnable(GL_DEPTH_TEST); @@ -1036,7 +1037,7 @@ void FDrawInfo::SetupFloodStencil(wallseg * ws) glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil - } // glColorMask(1, 1, 1, 1); // don't write to the graphics buffer + } glColorMask(1, 1, 1, 1); // don't write to the graphics buffer gl_RenderState.EnableTexture(true); glDisable(GL_DEPTH_TEST); glDepthMask(false); @@ -1050,7 +1051,8 @@ void FDrawInfo::ClearFloodStencil(wallseg * ws) gl_RenderState.EnableTexture(false); { // Use revertible color mask, to avoid stomping on anaglyph 3D state - ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0,0,0,0); // don't write to the graphics buffer + // ScopedColorMask colorMask(0, 0, 0, 0); + glColorMask(0,0,0,0); // don't write to the graphics buffer gl_RenderState.ResetColor(); gl_RenderState.Apply(); @@ -1069,7 +1071,7 @@ void FDrawInfo::ClearFloodStencil(wallseg * ws) glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilFunc(GL_EQUAL, recursion, ~0); gl_RenderState.EnableTexture(true); - } // glColorMask(1, 1, 1, 1); + } glColorMask(1, 1, 1, 1); glEnable(GL_DEPTH_TEST); glDepthMask(true); } diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 7ff82db4c..8af0619a1 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -198,7 +198,7 @@ bool GLPortal::Start(bool usestencil, bool doquery) // Create stencil glStencilFunc(GL_EQUAL,recursion,~0); // create stencil glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); // increment stencil of valid pixels - // glColorMask(0,0,0,0); // don't write to the graphics buffer + glColorMask(0,0,0,0); // don't write to the graphics buffer gl_RenderState.SetEffect(EFF_STENCIL); gl_RenderState.EnableTexture(false); gl_RenderState.ResetColor(); @@ -207,36 +207,34 @@ bool GLPortal::Start(bool usestencil, bool doquery) if (NeedDepthBuffer()) { + glDepthMask(false); // don't write to Z-buffer! + if (!NeedDepthBuffer()) doquery = false; // too much overhead and nothing to gain. + else if (gl_noquery) doquery = false; + + // If occlusion query is supported let's use it to avoid rendering portals that aren't visible + if (!QueryObject) glGenQueries(1, &QueryObject); + if (QueryObject) { - ScopedColorMask colorMask(0, 0, 0, 0); - glDepthMask(false); // don't write to Z-buffer! - if (!NeedDepthBuffer()) doquery = false; // too much overhead and nothing to gain. - else if (gl_noquery) doquery = false; + glBeginQuery(GL_SAMPLES_PASSED, QueryObject); + } + else doquery = false; // some kind of error happened - // If occlusion query is supported let's use it to avoid rendering portals that aren't visible - if (!QueryObject) glGenQueries(1, &QueryObject); - if (QueryObject) - { - glBeginQuery(GL_SAMPLES_PASSED, QueryObject); - } - else doquery = false; // some kind of error happened + DrawPortalStencil(); - DrawPortalStencil(); + glEndQuery(GL_SAMPLES_PASSED); - glEndQuery(GL_SAMPLES_PASSED); + // Clear Z-buffer + glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil + glDepthMask(true); // enable z-buffer again + glDepthRange(1, 1); + glDepthFunc(GL_ALWAYS); + DrawPortalStencil(); - // Clear Z-buffer - glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil - glDepthMask(true); // enable z-buffer again - glDepthRange(1, 1); - glDepthFunc(GL_ALWAYS); - DrawPortalStencil(); - - // set normal drawing mode - gl_RenderState.EnableTexture(true); - glDepthFunc(GL_LESS); - } // glColorMask(1, 1, 1, 1); + // set normal drawing mode + gl_RenderState.EnableTexture(true); + glDepthFunc(GL_LESS); + glColorMask(1, 1, 1, 1); gl_RenderState.SetEffect(EFF_NONE); glDepthRange(0, 1); @@ -261,13 +259,12 @@ bool GLPortal::Start(bool usestencil, bool doquery) // than the benefit. // Note: We must draw the stencil with z-write enabled here because there is no second pass! - ScopedColorMask colorMask(0, 0, 0, 0); glDepthMask(true); DrawPortalStencil(); glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil gl_RenderState.EnableTexture(true); - // glColorMask(1,1,1,1); + glColorMask(1,1,1,1); gl_RenderState.SetEffect(EFF_NONE); glDisable(GL_DEPTH_TEST); glDepthMask(false); // don't write to Z-buffer! @@ -376,7 +373,8 @@ void GLPortal::End(bool usestencil) GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); { - ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // no graphics + // ScopedColorMask colorMask(0, 0, 0, 0); + glColorMask(0, 0, 0, 0); // no graphics gl_RenderState.SetEffect(EFF_NONE); gl_RenderState.ResetColor(); gl_RenderState.EnableTexture(false); @@ -405,7 +403,7 @@ void GLPortal::End(bool usestencil) gl_RenderState.EnableTexture(true); gl_RenderState.SetEffect(EFF_NONE); - } // glColorMask(1, 1, 1, 1); + } glColorMask(1, 1, 1, 1); recursion--; // restore old stencil op. @@ -440,7 +438,8 @@ void GLPortal::End(bool usestencil) glDepthFunc(GL_LEQUAL); glDepthRange(0, 1); { - ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0,0,0,0); // no graphics + ScopedColorMask colorMask(0, 0, 0, 0); + // glColorMask(0,0,0,0); // no graphics gl_RenderState.SetEffect(EFF_STENCIL); gl_RenderState.EnableTexture(false); DrawPortalStencil(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 618c285c0..bde423078 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -826,7 +826,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo // Stereo mode specific perspective projection (*eye)->GetProjection(fov, ratio, fovratio, projectionMatrix); SetProjection(projectionMatrix); - SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper + // SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper SetViewAngle(viewangle); // Stereo mode specific viewpoint adjustment - temporarily shifts global viewx, viewy, viewz (*eye)->GetViewShift(GLRenderer->mAngles.Yaw, viewShift); @@ -839,6 +839,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo clipper.SafeAddClipRangeRealAngles(viewangle + a1, viewangle - a1); ProcessScene(toscreen); + EndDrawScene(viewsector); } stereo3dMode.TearDown(); @@ -910,7 +911,6 @@ void FGLRenderer::RenderView (player_t* player) GLRenderer->mLightCount = ((it.Next()) != NULL); sector_t * viewsector = RenderViewpoint(player->camera, NULL, FieldOfView * 360.0f / FINEANGLES, ratio, fovratio, true, true); - EndDrawScene(viewsector); All.Unclock(); } diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index 372da8685..65f8c1ef5 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -1,1702 +1,1702 @@ -/* -** i_system.cpp -** Timers, pre-console output, IWAD selection, and misc system routines. -** -**--------------------------------------------------------------------------- -** Copyright 1998-2009 Randy Heit -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ - -// HEADER FILES ------------------------------------------------------------ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define WIN32_LEAN_AND_MEAN -#include -#include -#include -#include - -#define USE_WINDOWS_DWORD -#include "hardware.h" -#include "doomerrors.h" -#include - -#include "doomtype.h" -#include "version.h" -#include "doomdef.h" -#include "cmdlib.h" -#include "m_argv.h" -#include "m_misc.h" -#include "i_video.h" -#include "i_sound.h" -#include "i_music.h" -#include "resource.h" -#include "x86.h" -#include "stats.h" - -#include "d_main.h" -#include "d_net.h" -#include "g_game.h" -#include "i_input.h" -#include "i_system.h" -#include "c_dispatch.h" -#include "templates.h" -#include "gameconfigfile.h" -#include "v_font.h" -#include "g_level.h" -#include "doomstat.h" -#include "v_palette.h" -#include "stats.h" -#include "textures/bitmap.h" -#include "textures/textures.h" - -// MACROS ------------------------------------------------------------------ - -#ifdef _MSC_VER -// Turn off "conversion from 'LONG_PTR' to 'LONG', possible loss of data" -// generated by SetClassLongPtr(). -#pragma warning(disable:4244) -#endif - -// TYPES ------------------------------------------------------------------- - -// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- - -extern void CheckCPUID(CPUInfo *cpu); -extern void LayoutMainWindow(HWND hWnd, HWND pane); - -// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- - -// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- - -static void CalculateCPUSpeed(); -static void I_SelectTimer(); - -static int I_GetTimePolled(bool saveMS); -static int I_WaitForTicPolled(int prevtic); -static void I_FreezeTimePolled(bool frozen); -static int I_GetTimeEventDriven(bool saveMS); -static int I_WaitForTicEvent(int prevtic); -static void I_FreezeTimeEventDriven(bool frozen); -static void CALLBACK TimerTicked(UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2); - -static HCURSOR CreateCompatibleCursor(FTexture *cursorpic); -static HCURSOR CreateAlphaCursor(FTexture *cursorpic); -static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP color_mask); -static void DestroyCustomCursor(); - -// EXTERNAL DATA DECLARATIONS ---------------------------------------------- - -EXTERN_CVAR(String, language); -EXTERN_CVAR (Bool, queryiwad); - -extern HWND Window, ConWindow, GameTitleWindow; -extern HANDLE StdOut; -extern bool FancyStdOut; -extern HINSTANCE g_hInst; -extern FILE *Logfile; -extern bool NativeMouse; -extern bool ConWindowHidden; - -// PUBLIC DATA DEFINITIONS ------------------------------------------------- - -CVAR (String, queryiwad_key, "shift", CVAR_GLOBALCONFIG|CVAR_ARCHIVE); - -double PerfToSec, PerfToMillisec; -UINT TimerPeriod; -UINT TimerEventID; -UINT MillisecondsPerTic; -HANDLE NewTicArrived; -uint32 LanguageIDs[4]; - -int (*I_GetTime) (bool saveMS); -int (*I_WaitForTic) (int); -void (*I_FreezeTime) (bool frozen); - -os_t OSPlatform; -bool gameisdead; - -// PRIVATE DATA DEFINITIONS ------------------------------------------------ - -static ticcmd_t emptycmd; -static bool HasExited; - -static DWORD basetime = 0; -// These are for the polled timer. -static DWORD TicStart; -static DWORD TicNext; -static int TicFrozen; - -// These are for the event-driven timer. -static int tics; -static DWORD ted_start, ted_next; - -static WadStuff *WadList; -static int NumWads; -static int DefaultWad; - -static HCURSOR CustomCursor; - -// CODE -------------------------------------------------------------------- - -//========================================================================== -// -// I_Tactile -// -// Doom calls it when you take damage, so presumably it could be converted -// to something compatible with force feedback. -// -//========================================================================== - -void I_Tactile(int on, int off, int total) -{ - // UNUSED. - on = off = total = 0; -} - -//========================================================================== -// -// I_BaseTiccmd -// -// Returns an empty ticcmd. I have no idea why this should be system- -// specific. -// -//========================================================================== - -ticcmd_t *I_BaseTiccmd() -{ - return &emptycmd; -} - -// Stubs that select the timer to use and then call into it ---------------- - -//========================================================================== -// -// I_GetTimeSelect -// -//========================================================================== - -static int I_GetTimeSelect(bool saveMS) -{ - I_SelectTimer(); - return I_GetTime(saveMS); -} - -//========================================================================== -// -// I_WaitForTicSelect -// -//========================================================================== - -static int I_WaitForTicSelect(int prevtic) -{ - I_SelectTimer(); - return I_WaitForTic(prevtic); -} - -//========================================================================== -// -// I_SelectTimer -// -// Tries to create a timer event for efficent CPU use when the FPS is -// capped. Failing that, it sets things up for a polling timer instead. -// -//========================================================================== - -static void I_SelectTimer() -{ - assert(basetime == 0); - - // Use a timer event if possible. - NewTicArrived = CreateEvent(NULL, FALSE, FALSE, NULL); - if (NewTicArrived) - { - UINT delay; - const char *cmdDelay; - - cmdDelay = Args->CheckValue("-timerdelay"); - delay = 0; - if (cmdDelay != 0) - { - delay = atoi(cmdDelay); - } - if (delay == 0) - { - delay = 1000/TICRATE; - } - MillisecondsPerTic = delay; - TimerEventID = timeSetEvent(delay, 0, TimerTicked, 0, TIME_PERIODIC); - } - // Get the current time as the basetime. - basetime = timeGetTime(); - // Set timer functions. - if (TimerEventID != 0) - { - I_GetTime = I_GetTimeEventDriven; - I_WaitForTic = I_WaitForTicEvent; - I_FreezeTime = I_FreezeTimeEventDriven; - } - else - { - I_GetTime = I_GetTimePolled; - I_WaitForTic = I_WaitForTicPolled; - I_FreezeTime = I_FreezeTimePolled; - } -} - -//========================================================================== -// -// I_MSTime -// -// Returns the current time in milliseconds, where 0 is the first call -// to I_GetTime or I_WaitForTic. -// -//========================================================================== - -unsigned int I_MSTime() -{ - assert(basetime != 0); - return timeGetTime() - basetime; -} - -//========================================================================== -// -// I_FPSTime -// -// Returns the current system time in milliseconds. This is used by the FPS -// meter of DFrameBuffer::DrawRateStuff(). Since the screen can display -// before the play simulation is ready to begin, this needs to be -// separate from I_MSTime(). -// -//========================================================================== - -unsigned int I_FPSTime() -{ - return timeGetTime(); -} - -//========================================================================== -// -// I_GetTimePolled -// -// Returns the current time in tics. If saveMS is true, then calls to -// I_GetTimeFrac() will use this tic as 0 and the next tic as 1. -// -//========================================================================== - -static int I_GetTimePolled(bool saveMS) -{ - DWORD tm; - - if (TicFrozen != 0) - { - return TicFrozen; - } - - tm = timeGetTime(); - if (basetime == 0) - { - basetime = tm; - } - if (saveMS) - { - TicStart = tm; - TicNext = (tm * TICRATE / 1000 + 1) * 1000 / TICRATE; - } - - return ((tm-basetime)*TICRATE)/1000; -} - -//========================================================================== -// -// I_WaitForTicPolled -// -// Busy waits until the current tic is greater than prevtic. Time must not -// be frozen. -// -//========================================================================== - -static int I_WaitForTicPolled(int prevtic) -{ - int time; - - assert(TicFrozen == 0); - while ((time = I_GetTimePolled(false)) <= prevtic) - { } - - return time; -} - -//========================================================================== -// -// I_FreezeTimePolled -// -// Freeze/unfreeze the timer. -// -//========================================================================== - -static void I_FreezeTimePolled(bool frozen) -{ - if (frozen) - { - assert(TicFrozen == 0); - TicFrozen = I_GetTimePolled(false); - } - else - { - assert(TicFrozen != 0); - int froze = TicFrozen; - TicFrozen = 0; - int now = I_GetTimePolled(false); - basetime += (now - froze) * 1000 / TICRATE; - } -} - -//========================================================================== -// -// I_GetTimeEventDriven -// -// Returns the current tick counter. This is incremented asynchronously as -// the timer event fires. -// -//========================================================================== - -static int I_GetTimeEventDriven(bool saveMS) -{ - if (saveMS) - { - TicStart = ted_start; - TicNext = ted_next; - } - return tics; -} - -//========================================================================== -// -// I_WaitForTicEvent -// -// Waits on the timer event as long as the current tic is not later than -// prevtic. -// -//========================================================================== - -static int I_WaitForTicEvent(int prevtic) -{ - assert(!TicFrozen); - while (prevtic >= tics) - { - WaitForSingleObject(NewTicArrived, 1000/TICRATE); - } - return tics; -} - -//========================================================================== -// -// I_FreezeTimeEventDriven -// -// Freeze/unfreeze the ticker. -// -//========================================================================== - -static void I_FreezeTimeEventDriven(bool frozen) -{ - TicFrozen = frozen; -} - -//========================================================================== -// -// TimerTicked -// -// Advance the tick count and signal the NewTicArrived event. -// -//========================================================================== - -static void CALLBACK TimerTicked(UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2) -{ - if (!TicFrozen) - { - tics++; - } - ted_start = timeGetTime (); - ted_next = ted_start + MillisecondsPerTic; - SetEvent(NewTicArrived); -} - -//========================================================================== -// -// I_GetTimeFrac -// -// Returns the fractional amount of a tic passed since the most recently -// saved tic. -// -//========================================================================== - -fixed_t I_GetTimeFrac(uint32 *ms) -{ - DWORD now = timeGetTime(); - if (ms != NULL) - { - *ms = TicNext; - } - DWORD step = TicNext - TicStart; - if (step == 0) - { - return FRACUNIT; - } - else - { - fixed_t frac = clamp ((now - TicStart)*FRACUNIT/step, 0, FRACUNIT); - return frac; - } -} - -//========================================================================== -// -// I_WaitVBL -// -// I_WaitVBL is never used to actually synchronize to the vertical blank. -// Instead, it's used for delay purposes. Doom used a 70 Hz display mode, -// so that's what we use to determine how long to wait for. -// -//========================================================================== - -void I_WaitVBL(int count) -{ - Sleep(1000 * count / 70); -} - -//========================================================================== -// -// I_DetectOS -// -// Determine which version of Windows the game is running on. -// -//========================================================================== - -void I_DetectOS(void) -{ - OSVERSIONINFOEX info; - const char *osname; - - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - if (!GetVersionEx((OSVERSIONINFO *)&info)) - { - // Retry with the older OSVERSIONINFO structure. - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx((OSVERSIONINFO *)&info); - } - - switch (info.dwPlatformId) - { - case VER_PLATFORM_WIN32_WINDOWS: - OSPlatform = os_Win95; - if (info.dwMinorVersion < 10) - { - osname = "95"; - } - else if (info.dwMinorVersion < 90) - { - osname = "98"; - } - else - { - osname = "Me"; - } - break; - - case VER_PLATFORM_WIN32_NT: - OSPlatform = info.dwMajorVersion < 5 ? os_WinNT4 : os_Win2k; - osname = "NT"; - if (info.dwMajorVersion == 5) - { - if (info.dwMinorVersion == 0) - { - osname = "2000"; - } - if (info.dwMinorVersion == 1) - { - osname = "XP"; - } - else if (info.dwMinorVersion == 2) - { - osname = "Server 2003"; - } - } - else if (info.dwMajorVersion == 6) - { - if (info.dwMinorVersion == 0) - { - osname = (info.wProductType == VER_NT_WORKSTATION) ? "Vista" : "Server 2008"; - } - else if (info.dwMinorVersion == 1) - { - osname = (info.wProductType == VER_NT_WORKSTATION) ? "7" : "Server 2008 R2"; - } - else if (info.dwMinorVersion == 2) - { - // Starting with Windows 8.1, you need to specify in your manifest - // the highest version of Windows you support, which will also be the - // highest version of Windows this function returns. - osname = (info.wProductType == VER_NT_WORKSTATION) ? "8" : "Server 2012"; - } - else if (info.dwMinorVersion == 3) - { - osname = (info.wProductType == VER_NT_WORKSTATION) ? "8.1" : "Server 2012 R2"; - } - else if (info.dwMinorVersion == 4) - { - osname = (info.wProductType == VER_NT_WORKSTATION) ? "10 (or higher)" : "Server 10 (or higher)"; - } - } - break; - - default: - OSPlatform = os_unknown; - osname = "Unknown OS"; - break; - } - - if (OSPlatform == os_Win95) - { - Printf ("OS: Windows %s %lu.%lu.%lu %s\n", - osname, - info.dwMajorVersion, info.dwMinorVersion, - info.dwBuildNumber & 0xffff, info.szCSDVersion); - } - else - { - Printf ("OS: Windows %s (NT %lu.%lu) Build %lu\n %s\n", - osname, - info.dwMajorVersion, info.dwMinorVersion, - info.dwBuildNumber, info.szCSDVersion); - } - - if (OSPlatform == os_unknown) - { - Printf ("(Assuming Windows 2000)\n"); - OSPlatform = os_Win2k; - } -} - -//========================================================================== -// -// SubsetLanguageIDs -// -// Helper function for SetLanguageIDs. -// -//========================================================================== - -static void SubsetLanguageIDs(LCID id, LCTYPE type, int idx) -{ - char buf[8]; - LCID langid; - char *idp; - - if (!GetLocaleInfo(id, type, buf, 8)) - return; - langid = MAKELCID(strtoul(buf, NULL, 16), SORT_DEFAULT); - if (!GetLocaleInfo(langid, LOCALE_SABBREVLANGNAME, buf, 8)) - return; - idp = (char *)(&LanguageIDs[idx]); - memset (idp, 0, 4); - idp[0] = tolower(buf[0]); - idp[1] = tolower(buf[1]); - idp[2] = tolower(buf[2]); - idp[3] = 0; -} - -//========================================================================== -// -// SetLanguageIDs -// -//========================================================================== - -void SetLanguageIDs() -{ - size_t langlen = strlen(language); - - if (langlen < 2 || langlen > 3) - { - memset(LanguageIDs, 0, sizeof(LanguageIDs)); - SubsetLanguageIDs(LOCALE_USER_DEFAULT, LOCALE_ILANGUAGE, 0); - SubsetLanguageIDs(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTLANGUAGE, 1); - SubsetLanguageIDs(LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, 2); - SubsetLanguageIDs(LOCALE_SYSTEM_DEFAULT, LOCALE_IDEFAULTLANGUAGE, 3); - } - else - { - DWORD lang = 0; - - ((BYTE *)&lang)[0] = (language)[0]; - ((BYTE *)&lang)[1] = (language)[1]; - ((BYTE *)&lang)[2] = (language)[2]; - LanguageIDs[0] = lang; - LanguageIDs[1] = lang; - LanguageIDs[2] = lang; - LanguageIDs[3] = lang; - } -} - -//========================================================================== -// -// CalculateCPUSpeed -// -// Make a decent guess at how much time elapses between TSC steps. This can -// vary over runtime depending on power management settings, so should not -// be used anywhere that truely accurate timing actually matters. -// -//========================================================================== - -void CalculateCPUSpeed() -{ - LARGE_INTEGER freq; - - QueryPerformanceFrequency (&freq); - - if (freq.QuadPart != 0 && CPU.bRDTSC) - { - LARGE_INTEGER count1, count2; - cycle_t ClockCalibration; - DWORD min_diff; - - ClockCalibration.Reset(); - - // Count cycles for at least 55 milliseconds. - // The performance counter may be very low resolution compared to CPU - // speeds today, so the longer we count, the more accurate our estimate. - // On the other hand, we don't want to count too long, because we don't - // want the user to notice us spend time here, since most users will - // probably never use the performance statistics. - min_diff = freq.LowPart * 11 / 200; - - // Minimize the chance of task switching during the testing by going very - // high priority. This is another reason to avoid timing for too long. - SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); - - // Make sure we start timing on a counter boundary. - QueryPerformanceCounter(&count1); - do { QueryPerformanceCounter(&count2); } while (count1.QuadPart == count2.QuadPart); - - // Do the timing loop. - ClockCalibration.Clock(); - do { QueryPerformanceCounter(&count1); } while ((count1.QuadPart - count2.QuadPart) < min_diff); - ClockCalibration.Unclock(); - - SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); - - PerfToSec = double(count1.QuadPart - count2.QuadPart) / (double(ClockCalibration.GetRawCounter()) * freq.QuadPart); - PerfToMillisec = PerfToSec * 1000.0; - } - - Printf ("CPU Speed: %.0f MHz\n", 0.001 / PerfToMillisec); -} - -//========================================================================== -// -// I_Init -// -//========================================================================== - -void I_Init() -{ - CheckCPUID(&CPU); - CalculateCPUSpeed(); - DumpCPUInfo(&CPU); - - I_GetTime = I_GetTimeSelect; - I_WaitForTic = I_WaitForTicSelect; - - atterm (I_ShutdownSound); - I_InitSound (); -} - -//========================================================================== -// -// I_Quit -// -//========================================================================== - -void I_Quit() -{ - HasExited = true; /* Prevent infinitely recursive exits -- killough */ - - if (TimerEventID != 0) - { - timeKillEvent(TimerEventID); - } - if (NewTicArrived != NULL) - { - CloseHandle(NewTicArrived); - } - timeEndPeriod(TimerPeriod); - if (demorecording) - { - G_CheckDemoStatus(); - } - - C_DeinitConsole(); -} - - -//========================================================================== -// -// I_FatalError -// -// Throw an error that will end the game. -// -//========================================================================== - -void STACK_ARGS I_FatalError(const char *error, ...) -{ - static BOOL alreadyThrown = false; - gameisdead = true; - - if (!alreadyThrown) // ignore all but the first message -- killough - { - alreadyThrown = true; - char errortext[MAX_ERRORTEXT]; - va_list argptr; - va_start(argptr, error); - myvsnprintf(errortext, MAX_ERRORTEXT, error, argptr); - va_end(argptr); - - // Record error to log (if logging) - if (Logfile) - { - fprintf(Logfile, "\n**** DIED WITH FATAL ERROR:\n%s\n", errortext); - fflush(Logfile); - } - - throw CFatalError(errortext); - } - - if (!HasExited) // If it hasn't exited yet, exit now -- killough - { - HasExited = 1; // Prevent infinitely recursive exits -- killough - exit(-1); - } -} - -//========================================================================== -// -// I_Error -// -// Throw an error that will send us to the console if we are far enough -// along in the startup process. -// -//========================================================================== - -void STACK_ARGS I_Error(const char *error, ...) -{ - va_list argptr; - char errortext[MAX_ERRORTEXT]; - - va_start(argptr, error); - myvsnprintf(errortext, MAX_ERRORTEXT, error, argptr); - va_end(argptr); - - throw CRecoverableError(errortext); -} - -//========================================================================== -// -// ToEditControl -// -// Converts string to Unicode and inserts it into the control. -// -//========================================================================== - -void ToEditControl(HWND edit, const char *buf, wchar_t *wbuf, int bpos) -{ - // Let's just do this ourself. It's not hard, and we can compensate for - // special console characters at the same time. -#if 0 - MultiByteToWideChar(1252 /* Western */, 0, buf, bpos, wbuf, countof(wbuf)); - wbuf[bpos] = 0; -#else - static wchar_t notlatin1[32] = // code points 0x80-0x9F - { - 0x20AC, // Euro sign - 0x0081, // Undefined - 0x201A, // Single low-9 quotation mark - 0x0192, // Latin small letter f with hook - 0x201E, // Double low-9 quotation mark - 0x2026, // Horizontal ellipsis - 0x2020, // Dagger - 0x2021, // Double dagger - 0x02C6, // Modifier letter circumflex accent - 0x2030, // Per mille sign - 0x0160, // Latin capital letter S with caron - 0x2039, // Single left-pointing angle quotation mark - 0x0152, // Latin capital ligature OE - 0x008D, // Undefined - 0x017D, // Latin capital letter Z with caron - 0x008F, // Undefined - 0x0090, // Undefined - 0x2018, // Left single quotation mark - 0x2019, // Right single quotation mark - 0x201C, // Left double quotation mark - 0x201D, // Right double quotation mark - 0x2022, // Bullet - 0x2013, // En dash - 0x2014, // Em dash - 0x02DC, // Small tilde - 0x2122, // Trade mark sign - 0x0161, // Latin small letter s with caron - 0x203A, // Single right-pointing angle quotation mark - 0x0153, // Latin small ligature oe - 0x009D, // Undefined - 0x017E, // Latin small letter z with caron - 0x0178 // Latin capital letter Y with diaeresis - }; - for (int i = 0; i <= bpos; ++i) - { - wchar_t code = (BYTE)buf[i]; - if (code >= 0x1D && code <= 0x1F) - { // The bar characters, most commonly used to indicate map changes - code = 0x2550; // Box Drawings Double Horizontal - } - else if (code >= 0x80 && code <= 0x9F) - { - code = notlatin1[code - 0x80]; - } - wbuf[i] = code; - } -#endif - SendMessageW(edit, EM_REPLACESEL, FALSE, (LPARAM)wbuf); -} - -//========================================================================== -// -// I_PrintStr -// -// Send output to the list box shown during startup (and hidden during -// gameplay). -// -//========================================================================== - -static void DoPrintStr(const char *cp, HWND edit, HANDLE StdOut) -{ - if (edit == NULL && StdOut == NULL) - return; - - char buf[256]; - wchar_t wbuf[countof(buf)]; - int bpos = 0; - CHARRANGE selection; - CHARRANGE endselection; - LONG lines_before = 0, lines_after; - CHARFORMAT format; - - if (edit != NULL) - { - // Store the current selection and set it to the end so we can append text. - SendMessage(edit, EM_EXGETSEL, 0, (LPARAM)&selection); - endselection.cpMax = endselection.cpMin = GetWindowTextLength(edit); - SendMessage(edit, EM_EXSETSEL, 0, (LPARAM)&endselection); - - // GetWindowTextLength and EM_EXSETSEL can disagree on where the end of - // the text is. Find out what EM_EXSETSEL thought it was and use that later. - SendMessage(edit, EM_EXGETSEL, 0, (LPARAM)&endselection); - - // Remember how many lines there were before we added text. - lines_before = (LONG)SendMessage(edit, EM_GETLINECOUNT, 0, 0); - } - - while (*cp != 0) - { - // 28 is the escape code for a color change. - if ((*cp == 28 && bpos != 0) || bpos == 255) - { - buf[bpos] = 0; - if (edit != NULL) - { - ToEditControl(edit, buf, wbuf, bpos); - } - if (StdOut != NULL) - { - DWORD bytes_written; - WriteFile(StdOut, buf, bpos, &bytes_written, NULL); - } - bpos = 0; - } - if (*cp != 28) - { - buf[bpos++] = *cp++; - } - else - { - const BYTE *color_id = (const BYTE *)cp + 1; - EColorRange range = V_ParseFontColor(color_id, CR_UNTRANSLATED, CR_YELLOW); - cp = (const char *)color_id; - - if (range != CR_UNDEFINED) - { - // Change the color of future text added to the control. - PalEntry color = V_LogColorFromColorRange(range); - if (StdOut != NULL && FancyStdOut) - { - // Unfortunately, we are pretty limited here: There are only - // eight basic colors, and each comes in a dark and a bright - // variety. - float h, s, v, r, g, b; - WORD attrib = 0; - - RGBtoHSV(color.r / 255.f, color.g / 255.f, color.b / 255.f, &h, &s, &v); - if (s != 0) - { // color - HSVtoRGB(&r, &g, &b, h, 1, 1); - if (r == 1) attrib = FOREGROUND_RED; - if (g == 1) attrib |= FOREGROUND_GREEN; - if (b == 1) attrib |= FOREGROUND_BLUE; - if (v > 0.6) attrib |= FOREGROUND_INTENSITY; - } - else - { // gray - if (v < 0.33) attrib = FOREGROUND_INTENSITY; - else if (v < 0.90) attrib = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; - else attrib = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; - } - SetConsoleTextAttribute(StdOut, attrib); - } - if (edit != NULL) - { - // GDI uses BGR colors, but color is RGB, so swap the R and the B. - swapvalues(color.r, color.b); - // Change the color. - format.cbSize = sizeof(format); - format.dwMask = CFM_COLOR; - format.dwEffects = 0; - format.crTextColor = color; - SendMessage(edit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&format); - } - } - } - } - if (bpos != 0) - { - buf[bpos] = 0; - if (edit != NULL) - { - ToEditControl(edit, buf, wbuf, bpos); - } - if (StdOut != NULL) - { - DWORD bytes_written; - WriteFile(StdOut, buf, bpos, &bytes_written, NULL); - } - } - - if (edit != NULL) - { - // If the old selection was at the end of the text, keep it at the end and - // scroll. Don't scroll if the selection is anywhere else. - if (selection.cpMin == endselection.cpMin && selection.cpMax == endselection.cpMax) - { - selection.cpMax = selection.cpMin = GetWindowTextLength (edit); - lines_after = (LONG)SendMessage(edit, EM_GETLINECOUNT, 0, 0); - if (lines_after > lines_before) - { - SendMessage(edit, EM_LINESCROLL, 0, lines_after - lines_before); - } - } - // Restore the previous selection. - SendMessage(edit, EM_EXSETSEL, 0, (LPARAM)&selection); - // Give the edit control a chance to redraw itself. - I_GetEvent(); - } - if (StdOut != NULL && FancyStdOut) - { // Set text back to gray, in case it was changed. - SetConsoleTextAttribute(StdOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); - } -} - -static TArray bufferedConsoleStuff; - -void I_PrintStr(const char *cp) -{ - if (ConWindowHidden) - { - bufferedConsoleStuff.Push(cp); - DoPrintStr(cp, NULL, StdOut); - } - else - { - DoPrintStr(cp, ConWindow, StdOut); - } -} - -void I_FlushBufferedConsoleStuff() -{ - for (unsigned i = 0; i < bufferedConsoleStuff.Size(); i++) - { - DoPrintStr(bufferedConsoleStuff[i], ConWindow, NULL); - } - bufferedConsoleStuff.Clear(); -} - -//========================================================================== -// -// SetQueryIWAD -// -// The user had the "Don't ask again" box checked when they closed the -// IWAD selection dialog. -// -//========================================================================== - -static void SetQueryIWad(HWND dialog) -{ - HWND checkbox = GetDlgItem(dialog, IDC_DONTASKIWAD); - int state = (int)SendMessage(checkbox, BM_GETCHECK, 0, 0); - bool query = (state != BST_CHECKED); - - if (!query && queryiwad) - { - MessageBox(dialog, - "You have chosen not to show this dialog box in the future.\n" - "If you wish to see it again, hold down SHIFT while starting " GAMENAME ".", - "Don't ask me this again", - MB_OK | MB_ICONINFORMATION); - } - - queryiwad = query; -} - -//========================================================================== -// -// IWADBoxCallback -// -// Dialog proc for the IWAD selector. -// -//========================================================================== - -BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - HWND ctrl; - int i; - - switch (message) - { - case WM_INITDIALOG: - // Add our program name to the window title - { - TCHAR label[256]; - FString newlabel; - - GetWindowText(hDlg, label, countof(label)); - newlabel.Format(GAMESIG " %s: %s", GetVersionString(), label); - SetWindowText(hDlg, newlabel.GetChars()); - } - // Populate the list with all the IWADs found - ctrl = GetDlgItem(hDlg, IDC_IWADLIST); - for (i = 0; i < NumWads; i++) - { - FString work; - const char *filepart = strrchr(WadList[i].Path, '/'); - if (filepart == NULL) - filepart = WadList[i].Path; - else - filepart++; - work.Format("%s (%s)", WadList[i].Name.GetChars(), filepart); - SendMessage(ctrl, LB_ADDSTRING, 0, (LPARAM)work.GetChars()); - SendMessage(ctrl, LB_SETITEMDATA, i, (LPARAM)i); - } - SendMessage(ctrl, LB_SETCURSEL, DefaultWad, 0); - SetFocus(ctrl); - // Set the state of the "Don't ask me again" checkbox - ctrl = GetDlgItem(hDlg, IDC_DONTASKIWAD); - SendMessage(ctrl, BM_SETCHECK, queryiwad ? BST_UNCHECKED : BST_CHECKED, 0); - // Make sure the dialog is in front. If SHIFT was pressed to force it visible, - // then the other window will normally be on top. - SetForegroundWindow(hDlg); - break; - - case WM_COMMAND: - if (LOWORD(wParam) == IDCANCEL) - { - EndDialog (hDlg, -1); - } - else if (LOWORD(wParam) == IDOK || - (LOWORD(wParam) == IDC_IWADLIST && HIWORD(wParam) == LBN_DBLCLK)) - { - SetQueryIWad(hDlg); - ctrl = GetDlgItem (hDlg, IDC_IWADLIST); - EndDialog(hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0)); - } - break; - } - return FALSE; -} - -//========================================================================== -// -// I_PickIWad -// -// Open a dialog to pick the IWAD, if there is more than one found. -// -//========================================================================== - -int I_PickIWad(WadStuff *wads, int numwads, bool showwin, int defaultiwad) -{ - int vkey; - - if (stricmp(queryiwad_key, "shift") == 0) - { - vkey = VK_SHIFT; - } - else if (stricmp(queryiwad_key, "control") == 0 || stricmp (queryiwad_key, "ctrl") == 0) - { - vkey = VK_CONTROL; - } - else - { - vkey = 0; - } - if (showwin || (vkey != 0 && GetAsyncKeyState(vkey))) - { - WadList = wads; - NumWads = numwads; - DefaultWad = defaultiwad; - - return (int)DialogBox(g_hInst, MAKEINTRESOURCE(IDD_IWADDIALOG), - (HWND)Window, (DLGPROC)IWADBoxCallback); - } - return defaultiwad; -} - -//========================================================================== -// -// I_SetCursor -// -// Returns true if the cursor was successfully changed. -// -//========================================================================== - -bool I_SetCursor(FTexture *cursorpic) -{ - HCURSOR cursor; - - if (cursorpic != NULL && cursorpic->UseType != FTexture::TEX_Null && - (screen == NULL || !screen->Is8BitMode())) - { - // Must be no larger than 32x32. - if (cursorpic->GetWidth() > 32 || cursorpic->GetHeight() > 32) - { - return false; - } - - cursor = CreateAlphaCursor(cursorpic); - if (cursor == NULL) - { - cursor = CreateCompatibleCursor(cursorpic); - } - if (cursor == NULL) - { - return false; - } - // Replace the existing cursor with the new one. - DestroyCustomCursor(); - CustomCursor = cursor; - atterm(DestroyCustomCursor); - } - else - { - DestroyCustomCursor(); - cursor = LoadCursor(NULL, IDC_ARROW); - } - SetClassLongPtr(Window, GCLP_HCURSOR, (LONG_PTR)cursor); - if (NativeMouse) - { - POINT pt; - RECT client; - - // If the mouse pointer is within the window's client rect, set it now. - if (GetCursorPos(&pt) && GetClientRect(Window, &client) && - ClientToScreen(Window, (LPPOINT)&client.left) && - ClientToScreen(Window, (LPPOINT)&client.right)) - { - if (pt.x >= client.left && pt.x < client.right && - pt.y >= client.top && pt.y < client.bottom) - { - SetCursor(cursor); - } - } - } - return true; -} - -//========================================================================== -// -// CreateCompatibleCursor -// -// Creates a cursor with a 1-bit alpha channel. -// -//========================================================================== - -static HCURSOR CreateCompatibleCursor(FTexture *cursorpic) -{ - int picwidth = cursorpic->GetWidth(); - int picheight = cursorpic->GetHeight(); - - // Create bitmap masks for the cursor from the texture. - HDC dc = GetDC(NULL); - if (dc == NULL) - { - return false; - } - HDC and_mask_dc = CreateCompatibleDC(dc); - HDC xor_mask_dc = CreateCompatibleDC(dc); - HBITMAP and_mask = CreateCompatibleBitmap(dc, 32, 32); - HBITMAP xor_mask = CreateCompatibleBitmap(dc, 32, 32); - ReleaseDC(NULL, dc); - - SelectObject(and_mask_dc, and_mask); - SelectObject(xor_mask_dc, xor_mask); - - // Initialize with an invisible cursor. - SelectObject(and_mask_dc, GetStockObject(WHITE_PEN)); - SelectObject(and_mask_dc, GetStockObject(WHITE_BRUSH)); - Rectangle(and_mask_dc, 0, 0, 32, 32); - SelectObject(xor_mask_dc, GetStockObject(BLACK_PEN)); - SelectObject(xor_mask_dc, GetStockObject(BLACK_BRUSH)); - Rectangle(xor_mask_dc, 0, 0, 32, 32); - - FBitmap bmp; - const BYTE *pixels; - - bmp.Create(picwidth, picheight); - cursorpic->CopyTrueColorPixels(&bmp, 0, 0); - pixels = bmp.GetPixels(); - - // Copy color data from the source texture to the cursor bitmaps. - for (int y = 0; y < picheight; ++y) - { - for (int x = 0; x < picwidth; ++x) - { - const BYTE *bgra = &pixels[x*4 + y*bmp.GetPitch()]; - if (bgra[3] != 0) - { - SetPixelV(and_mask_dc, x, y, RGB(0,0,0)); - SetPixelV(xor_mask_dc, x, y, RGB(bgra[2], bgra[1], bgra[0])); - } - } - } - DeleteDC(and_mask_dc); - DeleteDC(xor_mask_dc); - - // Create the cursor from the bitmaps. - return CreateBitmapCursor(cursorpic->LeftOffset, cursorpic->TopOffset, and_mask, xor_mask); -} - -//========================================================================== -// -// CreateAlphaCursor -// -// Creates a cursor with a full alpha channel. -// -//========================================================================== - -static HCURSOR CreateAlphaCursor(FTexture *cursorpic) -{ - HDC dc; - BITMAPV5HEADER bi; - HBITMAP color, mono; - void *bits; - - memset(&bi, 0, sizeof(bi)); - bi.bV5Size = sizeof(bi); - bi.bV5Width = 32; - bi.bV5Height = 32; - bi.bV5Planes = 1; - bi.bV5BitCount = 32; - bi.bV5Compression = BI_BITFIELDS; - bi.bV5RedMask = 0x00FF0000; - bi.bV5GreenMask = 0x0000FF00; - bi.bV5BlueMask = 0x000000FF; - bi.bV5AlphaMask = 0xFF000000; - - dc = GetDC(NULL); - if (dc == NULL) - { - return NULL; - } - - // Create the DIB section with an alpha channel. - color = CreateDIBSection(dc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, &bits, NULL, 0); - ReleaseDC(NULL, dc); - - if (color == NULL) - { - return NULL; - } - - // Create an empty mask bitmap, since CreateIconIndirect requires this. - mono = CreateBitmap(32, 32, 1, 1, NULL); - if (mono == NULL) - { - DeleteObject(color); - return NULL; - } - - // Copy cursor to the color bitmap. Note that GDI bitmaps are upside down compared - // to normal conventions, so we create the FBitmap pointing at the last row and use - // a negative pitch so that CopyTrueColorPixels will use GDI's orientation. - FBitmap bmp((BYTE *)bits + 31*32*4, -32*4, 32, 32); - cursorpic->CopyTrueColorPixels(&bmp, 0, 0); - - return CreateBitmapCursor(cursorpic->LeftOffset, cursorpic->TopOffset, mono, color); -} - -//========================================================================== -// -// CreateBitmapCursor -// -// Create the cursor from the bitmaps. Deletes the bitmaps before returning. -// -//========================================================================== - -static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP color_mask) -{ - ICONINFO iconinfo = - { - FALSE, // fIcon - xhot, // xHotspot - yhot, // yHotspot - and_mask, // hbmMask - color_mask // hbmColor - }; - HCURSOR cursor = CreateIconIndirect(&iconinfo); - - // Delete the bitmaps. - DeleteObject(and_mask); - DeleteObject(color_mask); - - return cursor; -} - -//========================================================================== -// -// DestroyCustomCursor -// -//========================================================================== - -static void DestroyCustomCursor() -{ - if (CustomCursor != NULL) - { - DestroyCursor(CustomCursor); - CustomCursor = NULL; - } -} - -//========================================================================== -// -// I_WriteIniFailed -// -// Display a message when the config failed to save. -// -//========================================================================== - -bool I_WriteIniFailed() -{ - char *lpMsgBuf; - FString errortext; - - FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPSTR)&lpMsgBuf, - 0, - NULL - ); - errortext.Format ("The config file %s could not be written:\n%s", GameConfig->GetPathName(), lpMsgBuf); - LocalFree (lpMsgBuf); - return MessageBox(Window, errortext.GetChars(), GAMENAME " configuration not saved", MB_ICONEXCLAMATION | MB_RETRYCANCEL) == IDRETRY; -} - -//========================================================================== -// -// I_FindFirst -// -// Start a pattern matching sequence. -// -//========================================================================== - -void *I_FindFirst(const char *filespec, findstate_t *fileinfo) -{ - return FindFirstFileA(filespec, (LPWIN32_FIND_DATAA)fileinfo); -} - -//========================================================================== -// -// I_FindNext -// -// Return the next file in a pattern matching sequence. -// -//========================================================================== - -int I_FindNext(void *handle, findstate_t *fileinfo) -{ - return !FindNextFileA((HANDLE)handle, (LPWIN32_FIND_DATAA)fileinfo); -} - -//========================================================================== -// -// I_FindClose -// -// Finish a pattern matching sequence. -// -//========================================================================== - -int I_FindClose(void *handle) -{ - return FindClose((HANDLE)handle); -} - -//========================================================================== -// -// QueryPathKey -// -// Returns the value of a registry key into the output variable value. -// -//========================================================================== - -static bool QueryPathKey(HKEY key, const char *keypath, const char *valname, FString &value) -{ - HKEY pathkey; - DWORD pathtype; - DWORD pathlen; - LONG res; - - if(ERROR_SUCCESS == RegOpenKeyEx(key, keypath, 0, KEY_QUERY_VALUE, &pathkey)) - { - if (ERROR_SUCCESS == RegQueryValueEx(pathkey, valname, 0, &pathtype, NULL, &pathlen) && - pathtype == REG_SZ && pathlen != 0) - { - // Don't include terminating null in count - char *chars = value.LockNewBuffer(pathlen - 1); - res = RegQueryValueEx(pathkey, valname, 0, NULL, (LPBYTE)chars, &pathlen); - value.UnlockBuffer(); - if (res != ERROR_SUCCESS) - { - value = ""; - } - } - RegCloseKey(pathkey); - } - return value.IsNotEmpty(); -} - -//========================================================================== -// -// I_GetGogPaths -// -// Check the registry for GOG installation paths, so we can search for IWADs -// that were bought from GOG.com. This is a bit different from the Steam -// version because each game has its own independent installation path, no -// such thing as /SteamApps/common/. -// -//========================================================================== - -TArray I_GetGogPaths() -{ - TArray result; - FString path; - FString gamepath; - -#ifdef _WIN64 - FString gogregistrypath = "Software\\Wow6432Node\\GOG.com\\Games"; -#else - // If a 32-bit ZDoom runs on a 64-bit Windows, this will be transparently and - // automatically redirected to the Wow6432Node address instead, so this address - // should be safe to use in all cases. - FString gogregistrypath = "Software\\GOG.com\\Games"; -#endif - - // Look for Ultimate Doom - gamepath = gogregistrypath + "\\1435827232"; - if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) - { - result.Push(path); // directly in install folder - } - - // Look for Doom II - gamepath = gogregistrypath + "\\1435848814"; - if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) - { - result.Push(path + "/doom2"); // in a subdirectory - // If direct support for the Master Levels is ever added, they are in path + /master/wads - } - - // Look for Final Doom - gamepath = gogregistrypath + "\\1435848742"; - if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) - { - // in subdirectories - result.Push(path + "/TNT"); - result.Push(path + "/Plutonia"); - } - - return result; -} - -//========================================================================== -// -// I_GetSteamPath -// -// Check the registry for the path to Steam, so that we can search for -// IWADs that were bought with Steam. -// -//========================================================================== - -TArray I_GetSteamPath() -{ - TArray result; - static const char *const steam_dirs[] = - { - "doom 2/base", - "final doom/base", - "heretic shadow of the serpent riders/base", - "hexen/base", - "hexen deathkings of the dark citadel/base", - "ultimate doom/base", - "DOOM 3 BFG Edition/base/wads", - "Strife" - }; - - FString path; - - if (!QueryPathKey(HKEY_CURRENT_USER, "Software\\Valve\\Steam", "SteamPath", path)) - { - if (!QueryPathKey(HKEY_LOCAL_MACHINE, "Software\\Valve\\Steam", "InstallPath", path)) - return result; - } - path += "/SteamApps/common/"; - - for(unsigned int i = 0; i < countof(steam_dirs); ++i) - { - result.Push(path + steam_dirs[i]); - } - - return result; -} - -//========================================================================== -// -// I_MakeRNGSeed -// -// Returns a 32-bit random seed, preferably one with lots of entropy. -// -//========================================================================== - -unsigned int I_MakeRNGSeed() -{ - unsigned int seed; - - // If RtlGenRandom is available, use that to avoid increasing the - // working set by pulling in all of the crytographic API. - HMODULE advapi = GetModuleHandle("advapi32.dll"); - if (advapi != NULL) - { - BOOLEAN (APIENTRY *RtlGenRandom)(void *, ULONG) = - (BOOLEAN (APIENTRY *)(void *, ULONG))GetProcAddress(advapi, "SystemFunction036"); - if (RtlGenRandom != NULL) - { - if (RtlGenRandom(&seed, sizeof(seed))) - { - return seed; - } - } - } - - // Use the full crytographic API to produce a seed. If that fails, - // time() is used as a fallback. - HCRYPTPROV prov; - - if (!CryptAcquireContext(&prov, NULL, MS_DEF_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) - { - return (unsigned int)time(NULL); - } - if (!CryptGenRandom(prov, sizeof(seed), (BYTE *)&seed)) - { - seed = (unsigned int)time(NULL); - } - CryptReleaseContext(prov, 0); - return seed; -} - -//========================================================================== -// -// I_GetLongPathName -// -// Returns the long version of the path, or the original if there isn't -// anything worth changing. -// -//========================================================================== - -FString I_GetLongPathName(FString shortpath) -{ - static TOptWin32Proc - GetLongPathNameA("kernel32.dll", "GetLongPathNameA"); - - // Doesn't exist on NT4 - if (GetLongPathName == NULL) - return shortpath; - - DWORD buffsize = GetLongPathNameA.Call(shortpath.GetChars(), NULL, 0); - if (buffsize == 0) - { // nothing to change (it doesn't exist, maybe?) - return shortpath; - } - TCHAR *buff = new TCHAR[buffsize]; - DWORD buffsize2 = GetLongPathNameA.Call(shortpath.GetChars(), buff, buffsize); - if (buffsize2 >= buffsize) - { // Failure! Just return the short path - delete[] buff; - return shortpath; - } - FString longpath(buff, buffsize2); - delete[] buff; - return longpath; -} +/* +** i_system.cpp +** Timers, pre-console output, IWAD selection, and misc system routines. +** +**--------------------------------------------------------------------------- +** Copyright 1998-2009 Randy Heit +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +// HEADER FILES ------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include + +#define USE_WINDOWS_DWORD +#include "hardware.h" +#include "doomerrors.h" +#include + +#include "doomtype.h" +#include "version.h" +#include "doomdef.h" +#include "cmdlib.h" +#include "m_argv.h" +#include "m_misc.h" +#include "i_video.h" +#include "i_sound.h" +#include "i_music.h" +#include "resource.h" +#include "x86.h" +#include "stats.h" + +#include "d_main.h" +#include "d_net.h" +#include "g_game.h" +#include "i_input.h" +#include "i_system.h" +#include "c_dispatch.h" +#include "templates.h" +#include "gameconfigfile.h" +#include "v_font.h" +#include "g_level.h" +#include "doomstat.h" +#include "v_palette.h" +#include "stats.h" +#include "textures/bitmap.h" +#include "textures/textures.h" + +// MACROS ------------------------------------------------------------------ + +#ifdef _MSC_VER +// Turn off "conversion from 'LONG_PTR' to 'LONG', possible loss of data" +// generated by SetClassLongPtr(). +#pragma warning(disable:4244) +#endif + +// TYPES ------------------------------------------------------------------- + +// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- + +extern void CheckCPUID(CPUInfo *cpu); +extern void LayoutMainWindow(HWND hWnd, HWND pane); + +// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- + +// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- + +static void CalculateCPUSpeed(); +static void I_SelectTimer(); + +static int I_GetTimePolled(bool saveMS); +static int I_WaitForTicPolled(int prevtic); +static void I_FreezeTimePolled(bool frozen); +static int I_GetTimeEventDriven(bool saveMS); +static int I_WaitForTicEvent(int prevtic); +static void I_FreezeTimeEventDriven(bool frozen); +static void CALLBACK TimerTicked(UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2); + +static HCURSOR CreateCompatibleCursor(FTexture *cursorpic); +static HCURSOR CreateAlphaCursor(FTexture *cursorpic); +static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP color_mask); +static void DestroyCustomCursor(); + +// EXTERNAL DATA DECLARATIONS ---------------------------------------------- + +EXTERN_CVAR(String, language); +EXTERN_CVAR (Bool, queryiwad); + +extern HWND Window, ConWindow, GameTitleWindow; +extern HANDLE StdOut; +extern bool FancyStdOut; +extern HINSTANCE g_hInst; +extern FILE *Logfile; +extern bool NativeMouse; +extern bool ConWindowHidden; + +// PUBLIC DATA DEFINITIONS ------------------------------------------------- + +CVAR (String, queryiwad_key, "shift", CVAR_GLOBALCONFIG|CVAR_ARCHIVE); + +double PerfToSec, PerfToMillisec; +UINT TimerPeriod; +UINT TimerEventID; +UINT MillisecondsPerTic; +HANDLE NewTicArrived; +uint32 LanguageIDs[4]; + +int (*I_GetTime) (bool saveMS); +int (*I_WaitForTic) (int); +void (*I_FreezeTime) (bool frozen); + +os_t OSPlatform; +bool gameisdead; + +// PRIVATE DATA DEFINITIONS ------------------------------------------------ + +static ticcmd_t emptycmd; +static bool HasExited; + +static DWORD basetime = 0; +// These are for the polled timer. +static DWORD TicStart; +static DWORD TicNext; +static int TicFrozen; + +// These are for the event-driven timer. +static int tics; +static DWORD ted_start, ted_next; + +static WadStuff *WadList; +static int NumWads; +static int DefaultWad; + +static HCURSOR CustomCursor; + +// CODE -------------------------------------------------------------------- + +//========================================================================== +// +// I_Tactile +// +// Doom calls it when you take damage, so presumably it could be converted +// to something compatible with force feedback. +// +//========================================================================== + +void I_Tactile(int on, int off, int total) +{ + // UNUSED. + on = off = total = 0; +} + +//========================================================================== +// +// I_BaseTiccmd +// +// Returns an empty ticcmd. I have no idea why this should be system- +// specific. +// +//========================================================================== + +ticcmd_t *I_BaseTiccmd() +{ + return &emptycmd; +} + +// Stubs that select the timer to use and then call into it ---------------- + +//========================================================================== +// +// I_GetTimeSelect +// +//========================================================================== + +static int I_GetTimeSelect(bool saveMS) +{ + I_SelectTimer(); + return I_GetTime(saveMS); +} + +//========================================================================== +// +// I_WaitForTicSelect +// +//========================================================================== + +static int I_WaitForTicSelect(int prevtic) +{ + I_SelectTimer(); + return I_WaitForTic(prevtic); +} + +//========================================================================== +// +// I_SelectTimer +// +// Tries to create a timer event for efficent CPU use when the FPS is +// capped. Failing that, it sets things up for a polling timer instead. +// +//========================================================================== + +static void I_SelectTimer() +{ + assert(basetime == 0); + + // Use a timer event if possible. + NewTicArrived = CreateEvent(NULL, FALSE, FALSE, NULL); + if (NewTicArrived) + { + UINT delay; + const char *cmdDelay; + + cmdDelay = Args->CheckValue("-timerdelay"); + delay = 0; + if (cmdDelay != 0) + { + delay = atoi(cmdDelay); + } + if (delay == 0) + { + delay = 1000/TICRATE; + } + MillisecondsPerTic = delay; + TimerEventID = timeSetEvent(delay, 0, TimerTicked, 0, TIME_PERIODIC); + } + // Get the current time as the basetime. + basetime = timeGetTime(); + // Set timer functions. + if (TimerEventID != 0) + { + I_GetTime = I_GetTimeEventDriven; + I_WaitForTic = I_WaitForTicEvent; + I_FreezeTime = I_FreezeTimeEventDriven; + } + else + { + I_GetTime = I_GetTimePolled; + I_WaitForTic = I_WaitForTicPolled; + I_FreezeTime = I_FreezeTimePolled; + } +} + +//========================================================================== +// +// I_MSTime +// +// Returns the current time in milliseconds, where 0 is the first call +// to I_GetTime or I_WaitForTic. +// +//========================================================================== + +unsigned int I_MSTime() +{ + // assert(basetime != 0); + return timeGetTime() - basetime; +} + +//========================================================================== +// +// I_FPSTime +// +// Returns the current system time in milliseconds. This is used by the FPS +// meter of DFrameBuffer::DrawRateStuff(). Since the screen can display +// before the play simulation is ready to begin, this needs to be +// separate from I_MSTime(). +// +//========================================================================== + +unsigned int I_FPSTime() +{ + return timeGetTime(); +} + +//========================================================================== +// +// I_GetTimePolled +// +// Returns the current time in tics. If saveMS is true, then calls to +// I_GetTimeFrac() will use this tic as 0 and the next tic as 1. +// +//========================================================================== + +static int I_GetTimePolled(bool saveMS) +{ + DWORD tm; + + if (TicFrozen != 0) + { + return TicFrozen; + } + + tm = timeGetTime(); + if (basetime == 0) + { + basetime = tm; + } + if (saveMS) + { + TicStart = tm; + TicNext = (tm * TICRATE / 1000 + 1) * 1000 / TICRATE; + } + + return ((tm-basetime)*TICRATE)/1000; +} + +//========================================================================== +// +// I_WaitForTicPolled +// +// Busy waits until the current tic is greater than prevtic. Time must not +// be frozen. +// +//========================================================================== + +static int I_WaitForTicPolled(int prevtic) +{ + int time; + + assert(TicFrozen == 0); + while ((time = I_GetTimePolled(false)) <= prevtic) + { } + + return time; +} + +//========================================================================== +// +// I_FreezeTimePolled +// +// Freeze/unfreeze the timer. +// +//========================================================================== + +static void I_FreezeTimePolled(bool frozen) +{ + if (frozen) + { + assert(TicFrozen == 0); + TicFrozen = I_GetTimePolled(false); + } + else + { + assert(TicFrozen != 0); + int froze = TicFrozen; + TicFrozen = 0; + int now = I_GetTimePolled(false); + basetime += (now - froze) * 1000 / TICRATE; + } +} + +//========================================================================== +// +// I_GetTimeEventDriven +// +// Returns the current tick counter. This is incremented asynchronously as +// the timer event fires. +// +//========================================================================== + +static int I_GetTimeEventDriven(bool saveMS) +{ + if (saveMS) + { + TicStart = ted_start; + TicNext = ted_next; + } + return tics; +} + +//========================================================================== +// +// I_WaitForTicEvent +// +// Waits on the timer event as long as the current tic is not later than +// prevtic. +// +//========================================================================== + +static int I_WaitForTicEvent(int prevtic) +{ + assert(!TicFrozen); + while (prevtic >= tics) + { + WaitForSingleObject(NewTicArrived, 1000/TICRATE); + } + return tics; +} + +//========================================================================== +// +// I_FreezeTimeEventDriven +// +// Freeze/unfreeze the ticker. +// +//========================================================================== + +static void I_FreezeTimeEventDriven(bool frozen) +{ + TicFrozen = frozen; +} + +//========================================================================== +// +// TimerTicked +// +// Advance the tick count and signal the NewTicArrived event. +// +//========================================================================== + +static void CALLBACK TimerTicked(UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2) +{ + if (!TicFrozen) + { + tics++; + } + ted_start = timeGetTime (); + ted_next = ted_start + MillisecondsPerTic; + SetEvent(NewTicArrived); +} + +//========================================================================== +// +// I_GetTimeFrac +// +// Returns the fractional amount of a tic passed since the most recently +// saved tic. +// +//========================================================================== + +fixed_t I_GetTimeFrac(uint32 *ms) +{ + DWORD now = timeGetTime(); + if (ms != NULL) + { + *ms = TicNext; + } + DWORD step = TicNext - TicStart; + if (step == 0) + { + return FRACUNIT; + } + else + { + fixed_t frac = clamp ((now - TicStart)*FRACUNIT/step, 0, FRACUNIT); + return frac; + } +} + +//========================================================================== +// +// I_WaitVBL +// +// I_WaitVBL is never used to actually synchronize to the vertical blank. +// Instead, it's used for delay purposes. Doom used a 70 Hz display mode, +// so that's what we use to determine how long to wait for. +// +//========================================================================== + +void I_WaitVBL(int count) +{ + Sleep(1000 * count / 70); +} + +//========================================================================== +// +// I_DetectOS +// +// Determine which version of Windows the game is running on. +// +//========================================================================== + +void I_DetectOS(void) +{ + OSVERSIONINFOEX info; + const char *osname; + + info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + if (!GetVersionEx((OSVERSIONINFO *)&info)) + { + // Retry with the older OSVERSIONINFO structure. + info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx((OSVERSIONINFO *)&info); + } + + switch (info.dwPlatformId) + { + case VER_PLATFORM_WIN32_WINDOWS: + OSPlatform = os_Win95; + if (info.dwMinorVersion < 10) + { + osname = "95"; + } + else if (info.dwMinorVersion < 90) + { + osname = "98"; + } + else + { + osname = "Me"; + } + break; + + case VER_PLATFORM_WIN32_NT: + OSPlatform = info.dwMajorVersion < 5 ? os_WinNT4 : os_Win2k; + osname = "NT"; + if (info.dwMajorVersion == 5) + { + if (info.dwMinorVersion == 0) + { + osname = "2000"; + } + if (info.dwMinorVersion == 1) + { + osname = "XP"; + } + else if (info.dwMinorVersion == 2) + { + osname = "Server 2003"; + } + } + else if (info.dwMajorVersion == 6) + { + if (info.dwMinorVersion == 0) + { + osname = (info.wProductType == VER_NT_WORKSTATION) ? "Vista" : "Server 2008"; + } + else if (info.dwMinorVersion == 1) + { + osname = (info.wProductType == VER_NT_WORKSTATION) ? "7" : "Server 2008 R2"; + } + else if (info.dwMinorVersion == 2) + { + // Starting with Windows 8.1, you need to specify in your manifest + // the highest version of Windows you support, which will also be the + // highest version of Windows this function returns. + osname = (info.wProductType == VER_NT_WORKSTATION) ? "8" : "Server 2012"; + } + else if (info.dwMinorVersion == 3) + { + osname = (info.wProductType == VER_NT_WORKSTATION) ? "8.1" : "Server 2012 R2"; + } + else if (info.dwMinorVersion == 4) + { + osname = (info.wProductType == VER_NT_WORKSTATION) ? "10 (or higher)" : "Server 10 (or higher)"; + } + } + break; + + default: + OSPlatform = os_unknown; + osname = "Unknown OS"; + break; + } + + if (OSPlatform == os_Win95) + { + Printf ("OS: Windows %s %lu.%lu.%lu %s\n", + osname, + info.dwMajorVersion, info.dwMinorVersion, + info.dwBuildNumber & 0xffff, info.szCSDVersion); + } + else + { + Printf ("OS: Windows %s (NT %lu.%lu) Build %lu\n %s\n", + osname, + info.dwMajorVersion, info.dwMinorVersion, + info.dwBuildNumber, info.szCSDVersion); + } + + if (OSPlatform == os_unknown) + { + Printf ("(Assuming Windows 2000)\n"); + OSPlatform = os_Win2k; + } +} + +//========================================================================== +// +// SubsetLanguageIDs +// +// Helper function for SetLanguageIDs. +// +//========================================================================== + +static void SubsetLanguageIDs(LCID id, LCTYPE type, int idx) +{ + char buf[8]; + LCID langid; + char *idp; + + if (!GetLocaleInfo(id, type, buf, 8)) + return; + langid = MAKELCID(strtoul(buf, NULL, 16), SORT_DEFAULT); + if (!GetLocaleInfo(langid, LOCALE_SABBREVLANGNAME, buf, 8)) + return; + idp = (char *)(&LanguageIDs[idx]); + memset (idp, 0, 4); + idp[0] = tolower(buf[0]); + idp[1] = tolower(buf[1]); + idp[2] = tolower(buf[2]); + idp[3] = 0; +} + +//========================================================================== +// +// SetLanguageIDs +// +//========================================================================== + +void SetLanguageIDs() +{ + size_t langlen = strlen(language); + + if (langlen < 2 || langlen > 3) + { + memset(LanguageIDs, 0, sizeof(LanguageIDs)); + SubsetLanguageIDs(LOCALE_USER_DEFAULT, LOCALE_ILANGUAGE, 0); + SubsetLanguageIDs(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTLANGUAGE, 1); + SubsetLanguageIDs(LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, 2); + SubsetLanguageIDs(LOCALE_SYSTEM_DEFAULT, LOCALE_IDEFAULTLANGUAGE, 3); + } + else + { + DWORD lang = 0; + + ((BYTE *)&lang)[0] = (language)[0]; + ((BYTE *)&lang)[1] = (language)[1]; + ((BYTE *)&lang)[2] = (language)[2]; + LanguageIDs[0] = lang; + LanguageIDs[1] = lang; + LanguageIDs[2] = lang; + LanguageIDs[3] = lang; + } +} + +//========================================================================== +// +// CalculateCPUSpeed +// +// Make a decent guess at how much time elapses between TSC steps. This can +// vary over runtime depending on power management settings, so should not +// be used anywhere that truely accurate timing actually matters. +// +//========================================================================== + +void CalculateCPUSpeed() +{ + LARGE_INTEGER freq; + + QueryPerformanceFrequency (&freq); + + if (freq.QuadPart != 0 && CPU.bRDTSC) + { + LARGE_INTEGER count1, count2; + cycle_t ClockCalibration; + DWORD min_diff; + + ClockCalibration.Reset(); + + // Count cycles for at least 55 milliseconds. + // The performance counter may be very low resolution compared to CPU + // speeds today, so the longer we count, the more accurate our estimate. + // On the other hand, we don't want to count too long, because we don't + // want the user to notice us spend time here, since most users will + // probably never use the performance statistics. + min_diff = freq.LowPart * 11 / 200; + + // Minimize the chance of task switching during the testing by going very + // high priority. This is another reason to avoid timing for too long. + SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); + + // Make sure we start timing on a counter boundary. + QueryPerformanceCounter(&count1); + do { QueryPerformanceCounter(&count2); } while (count1.QuadPart == count2.QuadPart); + + // Do the timing loop. + ClockCalibration.Clock(); + do { QueryPerformanceCounter(&count1); } while ((count1.QuadPart - count2.QuadPart) < min_diff); + ClockCalibration.Unclock(); + + SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); + + PerfToSec = double(count1.QuadPart - count2.QuadPart) / (double(ClockCalibration.GetRawCounter()) * freq.QuadPart); + PerfToMillisec = PerfToSec * 1000.0; + } + + Printf ("CPU Speed: %.0f MHz\n", 0.001 / PerfToMillisec); +} + +//========================================================================== +// +// I_Init +// +//========================================================================== + +void I_Init() +{ + CheckCPUID(&CPU); + CalculateCPUSpeed(); + DumpCPUInfo(&CPU); + + I_GetTime = I_GetTimeSelect; + I_WaitForTic = I_WaitForTicSelect; + + atterm (I_ShutdownSound); + I_InitSound (); +} + +//========================================================================== +// +// I_Quit +// +//========================================================================== + +void I_Quit() +{ + HasExited = true; /* Prevent infinitely recursive exits -- killough */ + + if (TimerEventID != 0) + { + timeKillEvent(TimerEventID); + } + if (NewTicArrived != NULL) + { + CloseHandle(NewTicArrived); + } + timeEndPeriod(TimerPeriod); + if (demorecording) + { + G_CheckDemoStatus(); + } + + C_DeinitConsole(); +} + + +//========================================================================== +// +// I_FatalError +// +// Throw an error that will end the game. +// +//========================================================================== + +void STACK_ARGS I_FatalError(const char *error, ...) +{ + static BOOL alreadyThrown = false; + gameisdead = true; + + if (!alreadyThrown) // ignore all but the first message -- killough + { + alreadyThrown = true; + char errortext[MAX_ERRORTEXT]; + va_list argptr; + va_start(argptr, error); + myvsnprintf(errortext, MAX_ERRORTEXT, error, argptr); + va_end(argptr); + + // Record error to log (if logging) + if (Logfile) + { + fprintf(Logfile, "\n**** DIED WITH FATAL ERROR:\n%s\n", errortext); + fflush(Logfile); + } + + throw CFatalError(errortext); + } + + if (!HasExited) // If it hasn't exited yet, exit now -- killough + { + HasExited = 1; // Prevent infinitely recursive exits -- killough + exit(-1); + } +} + +//========================================================================== +// +// I_Error +// +// Throw an error that will send us to the console if we are far enough +// along in the startup process. +// +//========================================================================== + +void STACK_ARGS I_Error(const char *error, ...) +{ + va_list argptr; + char errortext[MAX_ERRORTEXT]; + + va_start(argptr, error); + myvsnprintf(errortext, MAX_ERRORTEXT, error, argptr); + va_end(argptr); + + throw CRecoverableError(errortext); +} + +//========================================================================== +// +// ToEditControl +// +// Converts string to Unicode and inserts it into the control. +// +//========================================================================== + +void ToEditControl(HWND edit, const char *buf, wchar_t *wbuf, int bpos) +{ + // Let's just do this ourself. It's not hard, and we can compensate for + // special console characters at the same time. +#if 0 + MultiByteToWideChar(1252 /* Western */, 0, buf, bpos, wbuf, countof(wbuf)); + wbuf[bpos] = 0; +#else + static wchar_t notlatin1[32] = // code points 0x80-0x9F + { + 0x20AC, // Euro sign + 0x0081, // Undefined + 0x201A, // Single low-9 quotation mark + 0x0192, // Latin small letter f with hook + 0x201E, // Double low-9 quotation mark + 0x2026, // Horizontal ellipsis + 0x2020, // Dagger + 0x2021, // Double dagger + 0x02C6, // Modifier letter circumflex accent + 0x2030, // Per mille sign + 0x0160, // Latin capital letter S with caron + 0x2039, // Single left-pointing angle quotation mark + 0x0152, // Latin capital ligature OE + 0x008D, // Undefined + 0x017D, // Latin capital letter Z with caron + 0x008F, // Undefined + 0x0090, // Undefined + 0x2018, // Left single quotation mark + 0x2019, // Right single quotation mark + 0x201C, // Left double quotation mark + 0x201D, // Right double quotation mark + 0x2022, // Bullet + 0x2013, // En dash + 0x2014, // Em dash + 0x02DC, // Small tilde + 0x2122, // Trade mark sign + 0x0161, // Latin small letter s with caron + 0x203A, // Single right-pointing angle quotation mark + 0x0153, // Latin small ligature oe + 0x009D, // Undefined + 0x017E, // Latin small letter z with caron + 0x0178 // Latin capital letter Y with diaeresis + }; + for (int i = 0; i <= bpos; ++i) + { + wchar_t code = (BYTE)buf[i]; + if (code >= 0x1D && code <= 0x1F) + { // The bar characters, most commonly used to indicate map changes + code = 0x2550; // Box Drawings Double Horizontal + } + else if (code >= 0x80 && code <= 0x9F) + { + code = notlatin1[code - 0x80]; + } + wbuf[i] = code; + } +#endif + SendMessageW(edit, EM_REPLACESEL, FALSE, (LPARAM)wbuf); +} + +//========================================================================== +// +// I_PrintStr +// +// Send output to the list box shown during startup (and hidden during +// gameplay). +// +//========================================================================== + +static void DoPrintStr(const char *cp, HWND edit, HANDLE StdOut) +{ + if (edit == NULL && StdOut == NULL) + return; + + char buf[256]; + wchar_t wbuf[countof(buf)]; + int bpos = 0; + CHARRANGE selection; + CHARRANGE endselection; + LONG lines_before = 0, lines_after; + CHARFORMAT format; + + if (edit != NULL) + { + // Store the current selection and set it to the end so we can append text. + SendMessage(edit, EM_EXGETSEL, 0, (LPARAM)&selection); + endselection.cpMax = endselection.cpMin = GetWindowTextLength(edit); + SendMessage(edit, EM_EXSETSEL, 0, (LPARAM)&endselection); + + // GetWindowTextLength and EM_EXSETSEL can disagree on where the end of + // the text is. Find out what EM_EXSETSEL thought it was and use that later. + SendMessage(edit, EM_EXGETSEL, 0, (LPARAM)&endselection); + + // Remember how many lines there were before we added text. + lines_before = (LONG)SendMessage(edit, EM_GETLINECOUNT, 0, 0); + } + + while (*cp != 0) + { + // 28 is the escape code for a color change. + if ((*cp == 28 && bpos != 0) || bpos == 255) + { + buf[bpos] = 0; + if (edit != NULL) + { + ToEditControl(edit, buf, wbuf, bpos); + } + if (StdOut != NULL) + { + DWORD bytes_written; + WriteFile(StdOut, buf, bpos, &bytes_written, NULL); + } + bpos = 0; + } + if (*cp != 28) + { + buf[bpos++] = *cp++; + } + else + { + const BYTE *color_id = (const BYTE *)cp + 1; + EColorRange range = V_ParseFontColor(color_id, CR_UNTRANSLATED, CR_YELLOW); + cp = (const char *)color_id; + + if (range != CR_UNDEFINED) + { + // Change the color of future text added to the control. + PalEntry color = V_LogColorFromColorRange(range); + if (StdOut != NULL && FancyStdOut) + { + // Unfortunately, we are pretty limited here: There are only + // eight basic colors, and each comes in a dark and a bright + // variety. + float h, s, v, r, g, b; + WORD attrib = 0; + + RGBtoHSV(color.r / 255.f, color.g / 255.f, color.b / 255.f, &h, &s, &v); + if (s != 0) + { // color + HSVtoRGB(&r, &g, &b, h, 1, 1); + if (r == 1) attrib = FOREGROUND_RED; + if (g == 1) attrib |= FOREGROUND_GREEN; + if (b == 1) attrib |= FOREGROUND_BLUE; + if (v > 0.6) attrib |= FOREGROUND_INTENSITY; + } + else + { // gray + if (v < 0.33) attrib = FOREGROUND_INTENSITY; + else if (v < 0.90) attrib = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; + else attrib = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; + } + SetConsoleTextAttribute(StdOut, attrib); + } + if (edit != NULL) + { + // GDI uses BGR colors, but color is RGB, so swap the R and the B. + swapvalues(color.r, color.b); + // Change the color. + format.cbSize = sizeof(format); + format.dwMask = CFM_COLOR; + format.dwEffects = 0; + format.crTextColor = color; + SendMessage(edit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&format); + } + } + } + } + if (bpos != 0) + { + buf[bpos] = 0; + if (edit != NULL) + { + ToEditControl(edit, buf, wbuf, bpos); + } + if (StdOut != NULL) + { + DWORD bytes_written; + WriteFile(StdOut, buf, bpos, &bytes_written, NULL); + } + } + + if (edit != NULL) + { + // If the old selection was at the end of the text, keep it at the end and + // scroll. Don't scroll if the selection is anywhere else. + if (selection.cpMin == endselection.cpMin && selection.cpMax == endselection.cpMax) + { + selection.cpMax = selection.cpMin = GetWindowTextLength (edit); + lines_after = (LONG)SendMessage(edit, EM_GETLINECOUNT, 0, 0); + if (lines_after > lines_before) + { + SendMessage(edit, EM_LINESCROLL, 0, lines_after - lines_before); + } + } + // Restore the previous selection. + SendMessage(edit, EM_EXSETSEL, 0, (LPARAM)&selection); + // Give the edit control a chance to redraw itself. + I_GetEvent(); + } + if (StdOut != NULL && FancyStdOut) + { // Set text back to gray, in case it was changed. + SetConsoleTextAttribute(StdOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + } +} + +static TArray bufferedConsoleStuff; + +void I_PrintStr(const char *cp) +{ + if (ConWindowHidden) + { + bufferedConsoleStuff.Push(cp); + DoPrintStr(cp, NULL, StdOut); + } + else + { + DoPrintStr(cp, ConWindow, StdOut); + } +} + +void I_FlushBufferedConsoleStuff() +{ + for (unsigned i = 0; i < bufferedConsoleStuff.Size(); i++) + { + DoPrintStr(bufferedConsoleStuff[i], ConWindow, NULL); + } + bufferedConsoleStuff.Clear(); +} + +//========================================================================== +// +// SetQueryIWAD +// +// The user had the "Don't ask again" box checked when they closed the +// IWAD selection dialog. +// +//========================================================================== + +static void SetQueryIWad(HWND dialog) +{ + HWND checkbox = GetDlgItem(dialog, IDC_DONTASKIWAD); + int state = (int)SendMessage(checkbox, BM_GETCHECK, 0, 0); + bool query = (state != BST_CHECKED); + + if (!query && queryiwad) + { + MessageBox(dialog, + "You have chosen not to show this dialog box in the future.\n" + "If you wish to see it again, hold down SHIFT while starting " GAMENAME ".", + "Don't ask me this again", + MB_OK | MB_ICONINFORMATION); + } + + queryiwad = query; +} + +//========================================================================== +// +// IWADBoxCallback +// +// Dialog proc for the IWAD selector. +// +//========================================================================== + +BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + HWND ctrl; + int i; + + switch (message) + { + case WM_INITDIALOG: + // Add our program name to the window title + { + TCHAR label[256]; + FString newlabel; + + GetWindowText(hDlg, label, countof(label)); + newlabel.Format(GAMESIG " %s: %s", GetVersionString(), label); + SetWindowText(hDlg, newlabel.GetChars()); + } + // Populate the list with all the IWADs found + ctrl = GetDlgItem(hDlg, IDC_IWADLIST); + for (i = 0; i < NumWads; i++) + { + FString work; + const char *filepart = strrchr(WadList[i].Path, '/'); + if (filepart == NULL) + filepart = WadList[i].Path; + else + filepart++; + work.Format("%s (%s)", WadList[i].Name.GetChars(), filepart); + SendMessage(ctrl, LB_ADDSTRING, 0, (LPARAM)work.GetChars()); + SendMessage(ctrl, LB_SETITEMDATA, i, (LPARAM)i); + } + SendMessage(ctrl, LB_SETCURSEL, DefaultWad, 0); + SetFocus(ctrl); + // Set the state of the "Don't ask me again" checkbox + ctrl = GetDlgItem(hDlg, IDC_DONTASKIWAD); + SendMessage(ctrl, BM_SETCHECK, queryiwad ? BST_UNCHECKED : BST_CHECKED, 0); + // Make sure the dialog is in front. If SHIFT was pressed to force it visible, + // then the other window will normally be on top. + SetForegroundWindow(hDlg); + break; + + case WM_COMMAND: + if (LOWORD(wParam) == IDCANCEL) + { + EndDialog (hDlg, -1); + } + else if (LOWORD(wParam) == IDOK || + (LOWORD(wParam) == IDC_IWADLIST && HIWORD(wParam) == LBN_DBLCLK)) + { + SetQueryIWad(hDlg); + ctrl = GetDlgItem (hDlg, IDC_IWADLIST); + EndDialog(hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0)); + } + break; + } + return FALSE; +} + +//========================================================================== +// +// I_PickIWad +// +// Open a dialog to pick the IWAD, if there is more than one found. +// +//========================================================================== + +int I_PickIWad(WadStuff *wads, int numwads, bool showwin, int defaultiwad) +{ + int vkey; + + if (stricmp(queryiwad_key, "shift") == 0) + { + vkey = VK_SHIFT; + } + else if (stricmp(queryiwad_key, "control") == 0 || stricmp (queryiwad_key, "ctrl") == 0) + { + vkey = VK_CONTROL; + } + else + { + vkey = 0; + } + if (showwin || (vkey != 0 && GetAsyncKeyState(vkey))) + { + WadList = wads; + NumWads = numwads; + DefaultWad = defaultiwad; + + return (int)DialogBox(g_hInst, MAKEINTRESOURCE(IDD_IWADDIALOG), + (HWND)Window, (DLGPROC)IWADBoxCallback); + } + return defaultiwad; +} + +//========================================================================== +// +// I_SetCursor +// +// Returns true if the cursor was successfully changed. +// +//========================================================================== + +bool I_SetCursor(FTexture *cursorpic) +{ + HCURSOR cursor; + + if (cursorpic != NULL && cursorpic->UseType != FTexture::TEX_Null && + (screen == NULL || !screen->Is8BitMode())) + { + // Must be no larger than 32x32. + if (cursorpic->GetWidth() > 32 || cursorpic->GetHeight() > 32) + { + return false; + } + + cursor = CreateAlphaCursor(cursorpic); + if (cursor == NULL) + { + cursor = CreateCompatibleCursor(cursorpic); + } + if (cursor == NULL) + { + return false; + } + // Replace the existing cursor with the new one. + DestroyCustomCursor(); + CustomCursor = cursor; + atterm(DestroyCustomCursor); + } + else + { + DestroyCustomCursor(); + cursor = LoadCursor(NULL, IDC_ARROW); + } + SetClassLongPtr(Window, GCLP_HCURSOR, (LONG_PTR)cursor); + if (NativeMouse) + { + POINT pt; + RECT client; + + // If the mouse pointer is within the window's client rect, set it now. + if (GetCursorPos(&pt) && GetClientRect(Window, &client) && + ClientToScreen(Window, (LPPOINT)&client.left) && + ClientToScreen(Window, (LPPOINT)&client.right)) + { + if (pt.x >= client.left && pt.x < client.right && + pt.y >= client.top && pt.y < client.bottom) + { + SetCursor(cursor); + } + } + } + return true; +} + +//========================================================================== +// +// CreateCompatibleCursor +// +// Creates a cursor with a 1-bit alpha channel. +// +//========================================================================== + +static HCURSOR CreateCompatibleCursor(FTexture *cursorpic) +{ + int picwidth = cursorpic->GetWidth(); + int picheight = cursorpic->GetHeight(); + + // Create bitmap masks for the cursor from the texture. + HDC dc = GetDC(NULL); + if (dc == NULL) + { + return false; + } + HDC and_mask_dc = CreateCompatibleDC(dc); + HDC xor_mask_dc = CreateCompatibleDC(dc); + HBITMAP and_mask = CreateCompatibleBitmap(dc, 32, 32); + HBITMAP xor_mask = CreateCompatibleBitmap(dc, 32, 32); + ReleaseDC(NULL, dc); + + SelectObject(and_mask_dc, and_mask); + SelectObject(xor_mask_dc, xor_mask); + + // Initialize with an invisible cursor. + SelectObject(and_mask_dc, GetStockObject(WHITE_PEN)); + SelectObject(and_mask_dc, GetStockObject(WHITE_BRUSH)); + Rectangle(and_mask_dc, 0, 0, 32, 32); + SelectObject(xor_mask_dc, GetStockObject(BLACK_PEN)); + SelectObject(xor_mask_dc, GetStockObject(BLACK_BRUSH)); + Rectangle(xor_mask_dc, 0, 0, 32, 32); + + FBitmap bmp; + const BYTE *pixels; + + bmp.Create(picwidth, picheight); + cursorpic->CopyTrueColorPixels(&bmp, 0, 0); + pixels = bmp.GetPixels(); + + // Copy color data from the source texture to the cursor bitmaps. + for (int y = 0; y < picheight; ++y) + { + for (int x = 0; x < picwidth; ++x) + { + const BYTE *bgra = &pixels[x*4 + y*bmp.GetPitch()]; + if (bgra[3] != 0) + { + SetPixelV(and_mask_dc, x, y, RGB(0,0,0)); + SetPixelV(xor_mask_dc, x, y, RGB(bgra[2], bgra[1], bgra[0])); + } + } + } + DeleteDC(and_mask_dc); + DeleteDC(xor_mask_dc); + + // Create the cursor from the bitmaps. + return CreateBitmapCursor(cursorpic->LeftOffset, cursorpic->TopOffset, and_mask, xor_mask); +} + +//========================================================================== +// +// CreateAlphaCursor +// +// Creates a cursor with a full alpha channel. +// +//========================================================================== + +static HCURSOR CreateAlphaCursor(FTexture *cursorpic) +{ + HDC dc; + BITMAPV5HEADER bi; + HBITMAP color, mono; + void *bits; + + memset(&bi, 0, sizeof(bi)); + bi.bV5Size = sizeof(bi); + bi.bV5Width = 32; + bi.bV5Height = 32; + bi.bV5Planes = 1; + bi.bV5BitCount = 32; + bi.bV5Compression = BI_BITFIELDS; + bi.bV5RedMask = 0x00FF0000; + bi.bV5GreenMask = 0x0000FF00; + bi.bV5BlueMask = 0x000000FF; + bi.bV5AlphaMask = 0xFF000000; + + dc = GetDC(NULL); + if (dc == NULL) + { + return NULL; + } + + // Create the DIB section with an alpha channel. + color = CreateDIBSection(dc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, &bits, NULL, 0); + ReleaseDC(NULL, dc); + + if (color == NULL) + { + return NULL; + } + + // Create an empty mask bitmap, since CreateIconIndirect requires this. + mono = CreateBitmap(32, 32, 1, 1, NULL); + if (mono == NULL) + { + DeleteObject(color); + return NULL; + } + + // Copy cursor to the color bitmap. Note that GDI bitmaps are upside down compared + // to normal conventions, so we create the FBitmap pointing at the last row and use + // a negative pitch so that CopyTrueColorPixels will use GDI's orientation. + FBitmap bmp((BYTE *)bits + 31*32*4, -32*4, 32, 32); + cursorpic->CopyTrueColorPixels(&bmp, 0, 0); + + return CreateBitmapCursor(cursorpic->LeftOffset, cursorpic->TopOffset, mono, color); +} + +//========================================================================== +// +// CreateBitmapCursor +// +// Create the cursor from the bitmaps. Deletes the bitmaps before returning. +// +//========================================================================== + +static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP color_mask) +{ + ICONINFO iconinfo = + { + FALSE, // fIcon + xhot, // xHotspot + yhot, // yHotspot + and_mask, // hbmMask + color_mask // hbmColor + }; + HCURSOR cursor = CreateIconIndirect(&iconinfo); + + // Delete the bitmaps. + DeleteObject(and_mask); + DeleteObject(color_mask); + + return cursor; +} + +//========================================================================== +// +// DestroyCustomCursor +// +//========================================================================== + +static void DestroyCustomCursor() +{ + if (CustomCursor != NULL) + { + DestroyCursor(CustomCursor); + CustomCursor = NULL; + } +} + +//========================================================================== +// +// I_WriteIniFailed +// +// Display a message when the config failed to save. +// +//========================================================================== + +bool I_WriteIniFailed() +{ + char *lpMsgBuf; + FString errortext; + + FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPSTR)&lpMsgBuf, + 0, + NULL + ); + errortext.Format ("The config file %s could not be written:\n%s", GameConfig->GetPathName(), lpMsgBuf); + LocalFree (lpMsgBuf); + return MessageBox(Window, errortext.GetChars(), GAMENAME " configuration not saved", MB_ICONEXCLAMATION | MB_RETRYCANCEL) == IDRETRY; +} + +//========================================================================== +// +// I_FindFirst +// +// Start a pattern matching sequence. +// +//========================================================================== + +void *I_FindFirst(const char *filespec, findstate_t *fileinfo) +{ + return FindFirstFileA(filespec, (LPWIN32_FIND_DATAA)fileinfo); +} + +//========================================================================== +// +// I_FindNext +// +// Return the next file in a pattern matching sequence. +// +//========================================================================== + +int I_FindNext(void *handle, findstate_t *fileinfo) +{ + return !FindNextFileA((HANDLE)handle, (LPWIN32_FIND_DATAA)fileinfo); +} + +//========================================================================== +// +// I_FindClose +// +// Finish a pattern matching sequence. +// +//========================================================================== + +int I_FindClose(void *handle) +{ + return FindClose((HANDLE)handle); +} + +//========================================================================== +// +// QueryPathKey +// +// Returns the value of a registry key into the output variable value. +// +//========================================================================== + +static bool QueryPathKey(HKEY key, const char *keypath, const char *valname, FString &value) +{ + HKEY pathkey; + DWORD pathtype; + DWORD pathlen; + LONG res; + + if(ERROR_SUCCESS == RegOpenKeyEx(key, keypath, 0, KEY_QUERY_VALUE, &pathkey)) + { + if (ERROR_SUCCESS == RegQueryValueEx(pathkey, valname, 0, &pathtype, NULL, &pathlen) && + pathtype == REG_SZ && pathlen != 0) + { + // Don't include terminating null in count + char *chars = value.LockNewBuffer(pathlen - 1); + res = RegQueryValueEx(pathkey, valname, 0, NULL, (LPBYTE)chars, &pathlen); + value.UnlockBuffer(); + if (res != ERROR_SUCCESS) + { + value = ""; + } + } + RegCloseKey(pathkey); + } + return value.IsNotEmpty(); +} + +//========================================================================== +// +// I_GetGogPaths +// +// Check the registry for GOG installation paths, so we can search for IWADs +// that were bought from GOG.com. This is a bit different from the Steam +// version because each game has its own independent installation path, no +// such thing as /SteamApps/common/. +// +//========================================================================== + +TArray I_GetGogPaths() +{ + TArray result; + FString path; + FString gamepath; + +#ifdef _WIN64 + FString gogregistrypath = "Software\\Wow6432Node\\GOG.com\\Games"; +#else + // If a 32-bit ZDoom runs on a 64-bit Windows, this will be transparently and + // automatically redirected to the Wow6432Node address instead, so this address + // should be safe to use in all cases. + FString gogregistrypath = "Software\\GOG.com\\Games"; +#endif + + // Look for Ultimate Doom + gamepath = gogregistrypath + "\\1435827232"; + if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) + { + result.Push(path); // directly in install folder + } + + // Look for Doom II + gamepath = gogregistrypath + "\\1435848814"; + if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) + { + result.Push(path + "/doom2"); // in a subdirectory + // If direct support for the Master Levels is ever added, they are in path + /master/wads + } + + // Look for Final Doom + gamepath = gogregistrypath + "\\1435848742"; + if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) + { + // in subdirectories + result.Push(path + "/TNT"); + result.Push(path + "/Plutonia"); + } + + return result; +} + +//========================================================================== +// +// I_GetSteamPath +// +// Check the registry for the path to Steam, so that we can search for +// IWADs that were bought with Steam. +// +//========================================================================== + +TArray I_GetSteamPath() +{ + TArray result; + static const char *const steam_dirs[] = + { + "doom 2/base", + "final doom/base", + "heretic shadow of the serpent riders/base", + "hexen/base", + "hexen deathkings of the dark citadel/base", + "ultimate doom/base", + "DOOM 3 BFG Edition/base/wads", + "Strife" + }; + + FString path; + + if (!QueryPathKey(HKEY_CURRENT_USER, "Software\\Valve\\Steam", "SteamPath", path)) + { + if (!QueryPathKey(HKEY_LOCAL_MACHINE, "Software\\Valve\\Steam", "InstallPath", path)) + return result; + } + path += "/SteamApps/common/"; + + for(unsigned int i = 0; i < countof(steam_dirs); ++i) + { + result.Push(path + steam_dirs[i]); + } + + return result; +} + +//========================================================================== +// +// I_MakeRNGSeed +// +// Returns a 32-bit random seed, preferably one with lots of entropy. +// +//========================================================================== + +unsigned int I_MakeRNGSeed() +{ + unsigned int seed; + + // If RtlGenRandom is available, use that to avoid increasing the + // working set by pulling in all of the crytographic API. + HMODULE advapi = GetModuleHandle("advapi32.dll"); + if (advapi != NULL) + { + BOOLEAN (APIENTRY *RtlGenRandom)(void *, ULONG) = + (BOOLEAN (APIENTRY *)(void *, ULONG))GetProcAddress(advapi, "SystemFunction036"); + if (RtlGenRandom != NULL) + { + if (RtlGenRandom(&seed, sizeof(seed))) + { + return seed; + } + } + } + + // Use the full crytographic API to produce a seed. If that fails, + // time() is used as a fallback. + HCRYPTPROV prov; + + if (!CryptAcquireContext(&prov, NULL, MS_DEF_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) + { + return (unsigned int)time(NULL); + } + if (!CryptGenRandom(prov, sizeof(seed), (BYTE *)&seed)) + { + seed = (unsigned int)time(NULL); + } + CryptReleaseContext(prov, 0); + return seed; +} + +//========================================================================== +// +// I_GetLongPathName +// +// Returns the long version of the path, or the original if there isn't +// anything worth changing. +// +//========================================================================== + +FString I_GetLongPathName(FString shortpath) +{ + static TOptWin32Proc + GetLongPathNameA("kernel32.dll", "GetLongPathNameA"); + + // Doesn't exist on NT4 + if (GetLongPathName == NULL) + return shortpath; + + DWORD buffsize = GetLongPathNameA.Call(shortpath.GetChars(), NULL, 0); + if (buffsize == 0) + { // nothing to change (it doesn't exist, maybe?) + return shortpath; + } + TCHAR *buff = new TCHAR[buffsize]; + DWORD buffsize2 = GetLongPathNameA.Call(shortpath.GetChars(), buff, buffsize); + if (buffsize2 >= buffsize) + { // Failure! Just return the short path + delete[] buff; + return shortpath; + } + FString longpath(buff, buffsize2); + delete[] buff; + return longpath; +} From 89328e685c967300a37de941bba3377e95bf20d3 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Fri, 30 Oct 2015 21:48:42 -0400 Subject: [PATCH 0318/1509] Use eye->TearDown method to restore glColorMask. Restore assert in i_system.cpp that was interfering with my debugging. Restore scoped colorMask-ing in gl_portal.cpp and gl_drawinfo.cpp. --- src/gl/scene/gl_drawinfo.cpp | 10 +-- src/gl/scene/gl_portal.cpp | 139 ++++++++++++++++++----------------- src/gl/scene/gl_scene.cpp | 1 + src/win32/i_system.cpp | 2 +- 4 files changed, 76 insertions(+), 76 deletions(-) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 5c0c53047..4dba1a2a0 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -1014,8 +1014,7 @@ void FDrawInfo::SetupFloodStencil(wallseg * ws) glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); // increment stencil of valid pixels { // Use revertible color mask, to avoid stomping on anaglyph 3D state - // ScopedColorMask colorMask(0, 0, 0, 0); - glColorMask(0, 0, 0, 0); // don't write to the graphics buffer + ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // don't write to the graphics buffer gl_RenderState.EnableTexture(false); gl_RenderState.ResetColor(); glEnable(GL_DEPTH_TEST); @@ -1037,7 +1036,7 @@ void FDrawInfo::SetupFloodStencil(wallseg * ws) glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil - } glColorMask(1, 1, 1, 1); // don't write to the graphics buffer + } // glColorMask(1, 1, 1, 1); // don't write to the graphics buffer gl_RenderState.EnableTexture(true); glDisable(GL_DEPTH_TEST); glDepthMask(false); @@ -1051,8 +1050,7 @@ void FDrawInfo::ClearFloodStencil(wallseg * ws) gl_RenderState.EnableTexture(false); { // Use revertible color mask, to avoid stomping on anaglyph 3D state - // ScopedColorMask colorMask(0, 0, 0, 0); - glColorMask(0,0,0,0); // don't write to the graphics buffer + ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0,0,0,0); // don't write to the graphics buffer gl_RenderState.ResetColor(); gl_RenderState.Apply(); @@ -1071,7 +1069,7 @@ void FDrawInfo::ClearFloodStencil(wallseg * ws) glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilFunc(GL_EQUAL, recursion, ~0); gl_RenderState.EnableTexture(true); - } glColorMask(1, 1, 1, 1); + } // glColorMask(1, 1, 1, 1); glEnable(GL_DEPTH_TEST); glDepthMask(true); } diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 8af0619a1..bff47e47a 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -197,77 +197,79 @@ bool GLPortal::Start(bool usestencil, bool doquery) // Create stencil glStencilFunc(GL_EQUAL,recursion,~0); // create stencil - glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); // increment stencil of valid pixels - glColorMask(0,0,0,0); // don't write to the graphics buffer - gl_RenderState.SetEffect(EFF_STENCIL); - gl_RenderState.EnableTexture(false); - gl_RenderState.ResetColor(); - glDepthFunc(GL_LESS); - gl_RenderState.Apply(); - - if (NeedDepthBuffer()) + glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); // increment stencil of valid pixels { - glDepthMask(false); // don't write to Z-buffer! - if (!NeedDepthBuffer()) doquery = false; // too much overhead and nothing to gain. - else if (gl_noquery) doquery = false; - - // If occlusion query is supported let's use it to avoid rendering portals that aren't visible - if (!QueryObject) glGenQueries(1, &QueryObject); - if (QueryObject) - { - glBeginQuery(GL_SAMPLES_PASSED, QueryObject); - } - else doquery = false; // some kind of error happened - - DrawPortalStencil(); - - glEndQuery(GL_SAMPLES_PASSED); - - // Clear Z-buffer - glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil - glDepthMask(true); // enable z-buffer again - glDepthRange(1, 1); - glDepthFunc(GL_ALWAYS); - DrawPortalStencil(); - - // set normal drawing mode - gl_RenderState.EnableTexture(true); + ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0,0,0,0); // don't write to the graphics buffer + gl_RenderState.SetEffect(EFF_STENCIL); + gl_RenderState.EnableTexture(false); + gl_RenderState.ResetColor(); glDepthFunc(GL_LESS); - glColorMask(1, 1, 1, 1); - gl_RenderState.SetEffect(EFF_NONE); - glDepthRange(0, 1); + gl_RenderState.Apply(); - GLuint sampleCount; - - glGetQueryObjectuiv(QueryObject, GL_QUERY_RESULT, &sampleCount); - - if (sampleCount==0) // not visible + if (NeedDepthBuffer()) { - // restore default stencil op. - glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); - glStencilFunc(GL_EQUAL,recursion,~0); // draw sky into stencil - PortalAll.Unclock(); - return false; - } - FDrawInfo::StartDrawInfo(); - } - else - { - // No z-buffer is needed therefore we can skip all the complicated stuff that is involved - // No occlusion queries will be done here. For these portals the overhead is far greater - // than the benefit. - // Note: We must draw the stencil with z-write enabled here because there is no second pass! + glDepthMask(false); // don't write to Z-buffer! + if (!NeedDepthBuffer()) doquery = false; // too much overhead and nothing to gain. + else if (gl_noquery) doquery = false; - glDepthMask(true); - DrawPortalStencil(); - glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil - glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil - gl_RenderState.EnableTexture(true); - glColorMask(1,1,1,1); - gl_RenderState.SetEffect(EFF_NONE); - glDisable(GL_DEPTH_TEST); - glDepthMask(false); // don't write to Z-buffer! + // If occlusion query is supported let's use it to avoid rendering portals that aren't visible + if (!QueryObject) glGenQueries(1, &QueryObject); + if (QueryObject) + { + glBeginQuery(GL_SAMPLES_PASSED, QueryObject); + } + else doquery = false; // some kind of error happened + + DrawPortalStencil(); + + glEndQuery(GL_SAMPLES_PASSED); + + // Clear Z-buffer + glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil + glDepthMask(true); // enable z-buffer again + glDepthRange(1, 1); + glDepthFunc(GL_ALWAYS); + DrawPortalStencil(); + + // set normal drawing mode + gl_RenderState.EnableTexture(true); + glDepthFunc(GL_LESS); + // glColorMask(1, 1, 1, 1); + gl_RenderState.SetEffect(EFF_NONE); + glDepthRange(0, 1); + + GLuint sampleCount; + + glGetQueryObjectuiv(QueryObject, GL_QUERY_RESULT, &sampleCount); + + if (sampleCount == 0) // not visible + { + // restore default stencil op. + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + glStencilFunc(GL_EQUAL, recursion, ~0); // draw sky into stencil + PortalAll.Unclock(); + return false; + } + FDrawInfo::StartDrawInfo(); + } + else + { + // No z-buffer is needed therefore we can skip all the complicated stuff that is involved + // No occlusion queries will be done here. For these portals the overhead is far greater + // than the benefit. + // Note: We must draw the stencil with z-write enabled here because there is no second pass! + + glDepthMask(true); + DrawPortalStencil(); + glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil + gl_RenderState.EnableTexture(true); + // glColorMask(1,1,1,1); + gl_RenderState.SetEffect(EFF_NONE); + glDisable(GL_DEPTH_TEST); + glDepthMask(false); // don't write to Z-buffer! + } } recursion++; @@ -373,8 +375,7 @@ void GLPortal::End(bool usestencil) GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); { - // ScopedColorMask colorMask(0, 0, 0, 0); - glColorMask(0, 0, 0, 0); // no graphics + ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // no graphics gl_RenderState.SetEffect(EFF_NONE); gl_RenderState.ResetColor(); gl_RenderState.EnableTexture(false); @@ -403,7 +404,7 @@ void GLPortal::End(bool usestencil) gl_RenderState.EnableTexture(true); gl_RenderState.SetEffect(EFF_NONE); - } glColorMask(1, 1, 1, 1); + } // glColorMask(1, 1, 1, 1); recursion--; // restore old stencil op. diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index bde423078..6c04b9e39 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -840,6 +840,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo ProcessScene(toscreen); EndDrawScene(viewsector); + (*eye)->TearDown(); } stereo3dMode.TearDown(); diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index 65f8c1ef5..530dba1e4 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -291,7 +291,7 @@ static void I_SelectTimer() unsigned int I_MSTime() { - // assert(basetime != 0); + assert(basetime != 0); return timeGetTime() - basetime; } From d603999ee37a3817a29fe22d88aa0532619037fd Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Fri, 30 Oct 2015 21:57:23 -0400 Subject: [PATCH 0319/1509] Revert stereo3d-unrelated changes to .gitignore and .gitattributes --- .gitattributes | 1 - .gitignore | 1 - 2 files changed, 2 deletions(-) delete mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 5ce158013..000000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.cpp text diff --git a/.gitignore b/.gitignore index b3d0eb257..849ed7b2a 100644 --- a/.gitignore +++ b/.gitignore @@ -40,4 +40,3 @@ /zlib/x64/ /build_vc2013_64bit /build_vc2015 -/build_cmake From 789dca2ab369a003b35186c4218a44e68c86e2e5 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 31 Oct 2015 07:46:36 -0400 Subject: [PATCH 0320/1509] Refactor stereo 3d projection matrix calculations to use VSMatrix. --- src/gl/renderer/gl_renderer.h | 2 +- src/gl/scene/gl_scene.cpp | 9 ++++----- src/gl/stereo3d/gl_stereo3d.cpp | 26 ++++++------------------- src/gl/stereo3d/gl_stereo3d.h | 2 +- src/gl/stereo3d/gl_stereo_leftright.cpp | 21 ++++++-------------- src/gl/stereo3d/gl_stereo_leftright.h | 2 +- 6 files changed, 19 insertions(+), 43 deletions(-) diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 3374c904a..a388ced35 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -121,7 +121,7 @@ public: void Flush() {} void SetProjection(float fov, float ratio, float fovratio); - void SetProjection(FLOATTYPE matrix[4][4]); // raw matrix input from stereo 3d modes + void SetProjection(VSMatrix matrix); // raw matrix input from stereo 3d modes void SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, bool mirror, bool planemirror); void ProcessScene(bool toscreen = false); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 6c04b9e39..d94748f6d 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -257,9 +257,10 @@ void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) } // raw matrix input from stereo 3d modes -void FGLRenderer::SetProjection(FLOATTYPE matrix[4][4]) +void FGLRenderer::SetProjection(VSMatrix matrix) { - gl_RenderState.mProjectionMatrix.loadMatrix(&matrix[0][0]); + gl_RenderState.mProjectionMatrix.loadIdentity(); + gl_RenderState.mProjectionMatrix.multMatrix(matrix); gl_RenderState.Set2DMode(false); } @@ -812,7 +813,6 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo retval = viewsector; // Render (potentially) multiple views for stereo 3d - FLOATTYPE projectionMatrix[4][4]; float viewShift[3]; const s3d::Stereo3DMode& stereo3dMode = s3d::Stereo3DMode::getCurrentMode(); stereo3dMode.SetUp(); @@ -824,8 +824,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo SetViewport(bounds); mCurrentFoV = fov; // Stereo mode specific perspective projection - (*eye)->GetProjection(fov, ratio, fovratio, projectionMatrix); - SetProjection(projectionMatrix); + SetProjection( (*eye)->GetProjection(fov, ratio, fovratio) ); // SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper SetViewAngle(viewangle); // Stereo mode specific viewpoint adjustment - temporarily shifts global viewx, viewy, viewz diff --git a/src/gl/stereo3d/gl_stereo3d.cpp b/src/gl/stereo3d/gl_stereo3d.cpp index e053266b7..bc006a2f9 100644 --- a/src/gl/stereo3d/gl_stereo3d.cpp +++ b/src/gl/stereo3d/gl_stereo3d.cpp @@ -6,29 +6,15 @@ namespace s3d { /* virtual */ -void EyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio, FLOATTYPE m[4][4]) const +VSMatrix EyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const { + VSMatrix result; + // Lifted from gl_scene.cpp FGLRenderer::SetProjection() - double fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)); - const FLOATTYPE zNear = 5.0; - const FLOATTYPE zFar = 65536.0; + float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)); + result.perspective(fovy, aspectRatio, 5.f, 65536.f); - double radians = fovy / 2 * M_PI / 180; - - FLOATTYPE deltaZ = zFar - zNear; - double sine = sin(radians); - if ((deltaZ == 0) || (sine == 0) || (aspectRatio == 0)) { - return; - } - FLOATTYPE cotangent = FLOATTYPE(cos(radians) / sine); - - memset(m, 0, 16*sizeof(FLOATTYPE)); - m[0][0] = cotangent / aspectRatio; - m[1][1] = cotangent; - m[2][2] = -(zFar + zNear) / deltaZ; - m[2][3] = -1; - m[3][2] = -2 * zNear * zFar / deltaZ; - m[3][3] = 0; + return result; } /* virtual */ diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h index 6421b2a9e..8cfe886ac 100644 --- a/src/gl/stereo3d/gl_stereo3d.h +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -24,7 +24,7 @@ class EyePose public: EyePose() {} virtual ~EyePose() {} - virtual void GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio, FLOATTYPE outMatrix[4][4]) const; + virtual VSMatrix GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const; virtual Viewport GetViewport(const Viewport& fullViewport) const; virtual void GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const; virtual void SetUp() const {}; diff --git a/src/gl/stereo3d/gl_stereo_leftright.cpp b/src/gl/stereo3d/gl_stereo_leftright.cpp index 58cbb086e..f93edb38a 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.cpp +++ b/src/gl/stereo3d/gl_stereo_leftright.cpp @@ -11,7 +11,7 @@ namespace s3d { /* virtual */ -void ShiftedEyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio, FLOATTYPE m[4][4]) const +VSMatrix ShiftedEyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const { // Lifted from gl_scene.cpp FGLRenderer::SetProjection() FLOATTYPE fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)); @@ -20,10 +20,10 @@ void ShiftedEyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTY // For stereo 3D, use asymmetric frustum shift in projection matrix // Q: shouldn't shift vary with roll angle, at least for desktop display? - // A: (lab) roll is not measured on desktop display (yet) + // A: No. (lab) roll is not measured on desktop display (yet) double frustumShift = zNear * shift / vr_screendist; // meters cancel // double frustumShift = 0; // Turning off shift for debugging - double fH = tan(fovy / 360 * M_PI) * zNear; + double fH = tan(DEG2RAD(fovy/2)) * zNear; double fW = fH * aspectRatio; // Emulate glFrustum command: // glFrustum(-fW - frustumShift, fW - frustumShift, -fH, fH, zNear, zFar); @@ -31,19 +31,10 @@ void ShiftedEyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTY double right = fW - frustumShift; double bottom = -fH; double top = fH; - double deltaZ = zFar - zNear; - memset(m, 0, 16 * sizeof(FLOATTYPE)); // set all elements to zero, cleverly - - // https://www.opengl.org/sdk/docs/man2/xhtml/glFrustum.xml - m[0][0] = 2 * zNear / (right - left); - m[1][1] = 2 * zNear / (top - bottom); - m[2][2] = -(zFar + zNear) / deltaZ; - m[2][3] = -1; - m[3][2] = -2 * zNear * zFar / deltaZ; - // m[3][3] = 0; // redundant - // m[2][1] = (top + bottom) / (top - bottom); // zero for the cases I know of... - m[2][0] = (right + left) / (right - left); // asymmetric shift is in this term + VSMatrix result(1); + result.frustum(left, right, bottom, top, zNear, zFar); + return result; } diff --git a/src/gl/stereo3d/gl_stereo_leftright.h b/src/gl/stereo3d/gl_stereo_leftright.h index 228b6459f..f256ced33 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.h +++ b/src/gl/stereo3d/gl_stereo_leftright.h @@ -12,7 +12,7 @@ public: ShiftedEyePose(FLOATTYPE shift) : shift(shift) {}; FLOATTYPE getShift() const { return shift; } void setShift(FLOATTYPE shift) { this->shift = shift; } - virtual void GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio, FLOATTYPE outMatrix[4][4]) const; + virtual VSMatrix GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const; virtual void GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const; protected: FLOATTYPE shift; From 382d2cf74f2bf947f1881db557802d3b3e8287da Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 31 Oct 2015 08:02:41 -0400 Subject: [PATCH 0321/1509] Simplify ShiftedEyePose::GetProjection() maths. --- src/gl/stereo3d/gl_stereo_leftright.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gl/stereo3d/gl_stereo_leftright.cpp b/src/gl/stereo3d/gl_stereo_leftright.cpp index f93edb38a..a05d1b82f 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.cpp +++ b/src/gl/stereo3d/gl_stereo_leftright.cpp @@ -13,20 +13,16 @@ namespace s3d { /* virtual */ VSMatrix ShiftedEyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const { - // Lifted from gl_scene.cpp FGLRenderer::SetProjection() - FLOATTYPE fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)); double zNear = 5.0; double zFar = 65536.0; // For stereo 3D, use asymmetric frustum shift in projection matrix // Q: shouldn't shift vary with roll angle, at least for desktop display? // A: No. (lab) roll is not measured on desktop display (yet) - double frustumShift = zNear * shift / vr_screendist; // meters cancel + double frustumShift = zNear * shift / vr_screendist; // meters cancel, leaving doom units // double frustumShift = 0; // Turning off shift for debugging - double fH = tan(DEG2RAD(fovy/2)) * zNear; + double fH = zNear * tan(DEG2RAD(fov) / 2) / fovRatio; double fW = fH * aspectRatio; - // Emulate glFrustum command: - // glFrustum(-fW - frustumShift, fW - frustumShift, -fH, fH, zNear, zFar); double left = -fW - frustumShift; double right = fW - frustumShift; double bottom = -fH; From 16cb4407a420018a8d1f3f8fff024bd973221cb6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 Nov 2015 23:55:16 +0100 Subject: [PATCH 0322/1509] - disabled 'isVisibleToPlayerClass' check for dynamic lights affecting sprites. Calling this function in the inner loop of a time critical rendering function apparently wreaks havoc with the CPU instruction cache - even though the function doesn't do anything substantial. This needs some more in-depth investigation why just having that call can increase sprite rendering time by a factor of 10 and more if there's many lights in view. --- src/gl/scene/gl_spritelight.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index e66941283..97f326844 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -75,7 +75,7 @@ void gl_SetDynSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsect while (node) { light=node->lightsource; - if (!light->owned || light->target == NULL || light->target->IsVisibleToPlayer()) + //if (!light->owned || light->target == NULL || light->target->IsVisibleToPlayer()) { if (!(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) From ad6ce5a726b905dc51ddad93809877b60d72b618 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 9 Nov 2015 13:49:17 +0100 Subject: [PATCH 0323/1509] - added a NULL check to gl_enhanced_nightvision's handler so that it won't crash without an uninitialized GL renderer. --- src/gl/renderer/gl_lightdata.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 1e5922d0a..5d153894f 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -71,7 +71,10 @@ CUSTOM_CVAR(Bool, gl_enhanced_nightvision, true, CVAR_ARCHIVE|CVAR_NOINITCALL) { // The fixed colormap state needs to be reset because if this happens when // a shader is set to CM_LITE or CM_TORCH it won't register the change in behavior caused by this CVAR. - GLRenderer->mShaderManager->ResetFixedColormap(); + if (GLRenderer != NULL && GLRenderer->mShaderManager != NULL) + { + GLRenderer->mShaderManager->ResetFixedColormap(); + } } CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE); From b00b49c111bb537ed14c26e83646615f9fc98627 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 25 Nov 2015 11:57:53 +0100 Subject: [PATCH 0324/1509] - fixed skybox picking in GL renderer. --- src/gl/scene/gl_sky.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index d208e6875..38dbfca49 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -80,8 +80,7 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) else if (sector->GetTexture(plane)==skyflatnum) { GLSkyInfo skyinfo; - ASkyViewpoint * skyboxx = plane == sector_t::floor? sector->FloorSkyBox : sector->CeilingSkyBox; - if (skyboxx == NULL) skyboxx = level.DefaultSkybox; + ASkyViewpoint * skyboxx = sector->GetSkyBox(plane); // JUSTHIT is used as an indicator that a skybox is in use. // This is to avoid recursion From f9cbaef1df62767ae49e1fe4d45d33c348190dc0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 30 Nov 2015 00:11:30 +0100 Subject: [PATCH 0325/1509] - fixed: Boom's Transfer_Heights did not work for upper parts in sectors with a sky ceiling. This incorrect check has been in the code for 12 years, unfortunately I have no idea anymore why it was added. --- src/gl/scene/gl_fakeflat.cpp | 2 +- src/gl/scene/gl_walls.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_fakeflat.cpp b/src/gl/scene/gl_fakeflat.cpp index 86408272a..6ff6bd113 100644 --- a/src/gl/scene/gl_fakeflat.cpp +++ b/src/gl/scene/gl_fakeflat.cpp @@ -227,7 +227,7 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac if (in_area==area_above) { - if (sec->heightsec->MoreFlags&SECF_FAKEFLOORONLY || sec->GetTexture(sector_t::ceiling)==skyflatnum) in_area=area_normal; + if (sec->heightsec->MoreFlags&SECF_FAKEFLOORONLY /*|| sec->GetTexture(sector_t::ceiling)==skyflatnum*/) in_area=area_normal; } int diffTex = (sec->heightsec->MoreFlags & SECF_CLIPFAKEPLANES); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index d192bf36f..b5317dc2a 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1420,7 +1420,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) sector_t * realback; #ifdef _DEBUG - if (seg->linedef-lines==4) + if (seg->linedef-lines==5835) { int a = 0; } From 841ddb0d63a60b3ca97443bcfd9c9eed856d2478 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Thu, 10 Dec 2015 23:01:59 -0600 Subject: [PATCH 0326/1509] has replaced on FreeBSD as well --- src/gl/system/gl_system.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h index 5cfd7fe5c..ed52ab7ef 100644 --- a/src/gl/system/gl_system.h +++ b/src/gl/system/gl_system.h @@ -49,7 +49,7 @@ #include #include #include -#if !defined(__APPLE__) +#if !defined(__APPLE__) && !defined(__FreeBSD__) #include #endif #include From 37ea94abf3ddc126fb67c79e94f87b069640c309 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 11 Dec 2015 22:26:10 +0100 Subject: [PATCH 0327/1509] - fixed: translucent walls did not set up their dynamic lights in the GL4 render path. --- src/gl/scene/gl_walls_draw.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 801bebcc5..5135a5947 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -322,6 +322,11 @@ void GLWall::RenderTranslucentWall() // and until that changes I won't fix this code for the new blending modes! bool isadditive = RenderStyle == STYLE_Add; + if (gl_fixedcolormap == CM_DEFAULT && gl_lights && (gl.flags & RFL_BUFFER_STORAGE)) + { + SetupLights(); + } + if (!transparent) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE); From c8810db5fe7b8ded8bcbf257d23f77ffaa10653b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Dec 2015 16:34:00 +0100 Subject: [PATCH 0328/1509] - fixed: clipping swimmable against non-swimmable translucent 3D-floors was broken due to an incorrect flag check. --- src/gl/scene/gl_walls.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index b5317dc2a..9856f1d02 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1261,7 +1261,7 @@ void GLWall::ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector, F3DFloor * rover=frontffloors[i]; if (!(rover->flags&FF_EXISTS)) continue; if (!(rover->flags&FF_RENDERSIDES)) continue; - if ((rover->flags&flags)!=flags) continue; + if ((rover->flags&(FF_SWIMMABLE|FF_TRANSLUCENT))!=flags) continue; fixed_t ff_topleft; fixed_t ff_topright; From 571f7a4eb6b85f6ac24e92156df92693f27a36a6 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 24 Dec 2015 10:32:19 +0200 Subject: [PATCH 0329/1509] - fixed: debug assertion failure in texture precaching loading of level from command line attempted to use uninitialized time value --- src/textures/texturemanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index 3de5016fd..0612fa792 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -1239,7 +1239,7 @@ void FTextureManager::PrecacheLevel (void) if (demoplayback) return; - precacheTime = I_MSTime(); + precacheTime = I_FPSTime(); hitlist = new BYTE[cnt]; memset (hitlist, 0, cnt); From 19ae244f66fdda01de08b0db458aa0a5a486d024 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 24 Dec 2015 10:33:30 +0200 Subject: [PATCH 0330/1509] - fixed: allow to use all hqNx texture upscale modes --- src/gl/textures/gl_hqresize.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index a4f192ce8..621f444bc 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -46,7 +46,11 @@ CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { +#ifdef _MSC_VER + if (self < 0 || self > 9) +#else if (self < 0 || self > 6) +#endif self = 0; GLRenderer->FlushTextures(); } From 69813993b0e023b2452da1a9097cac1a393e7c23 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 24 Dec 2015 11:13:31 +0200 Subject: [PATCH 0331/1509] - added missing hqNx modes to options menu --- src/gl/system/gl_menu.cpp | 14 ++++++++++++++ wadsrc/static/menudef.z | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index a9167b7a6..41304be0f 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -57,4 +57,18 @@ CUSTOM_CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // when they are actually valid. void gl_SetupMenu() { +#ifndef _MSC_VER + FOptionValues **opt = OptionValues.CheckKey("HqResizeModes"); + if (opt != NULL) + { + for(int i = (*opt)->mValues.Size()-1; i>=0; i--) + { + // Delete HQnX resize modes for non MSVC targets + if ((*opt)->mValues[i].Value >= 7.0) + { + (*opt)->mValues.Delete(i); + } + } + } +#endif } diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 75ea1bf5f..ffe67ee51 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -103,6 +103,9 @@ OptionValue "HqResizeModes" 4, "hq2x" 5, "hq3x" 6, "hq4x" + 7, "hq2x MMX" + 8, "hq3x MMX" + 9, "hq4x MMX" } OptionValue "FogMode" From 1c5d0ccd65e8a8ae631fd3160abf808fb26635d6 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 25 Dec 2015 15:41:06 +0200 Subject: [PATCH 0332/1509] - enabled hqNx MMX on all platforms with Intel intrinsics support --- src/CMakeLists.txt | 39 +++++++++++++++++++++++++++++---- src/gl/system/gl_menu.cpp | 2 +- src/gl/textures/gl_hqresize.cpp | 11 +++++----- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9332e4919..d4da7e7ce 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -449,6 +449,22 @@ else( SSE_MATTERS ) set( BACKPATCH 0 ) endif( SSE_MATTERS ) +if( X64 ) + set( HAVE_MMX 1 ) +else( X64 ) + set( SAFE_CMAKE_C_FLAGS ${CMAKE_C_FLAGS} ) + + if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmmx") + endif( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) + + CHECK_CXX_SOURCE_COMPILES("#include + int main(void) { __m64 v = _m_from_int(0); }" + HAVE_MMX) + + set( CMAKE_C_FLAGS ${SAFE_CMAKE_C_FLAGS} ) +endif( X64 ) + # Set up flags for GCC if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) @@ -581,10 +597,6 @@ endif( NOT DYN_FLUIDSYNTH ) # Start defining source files for ZDoom set( PLAT_WIN32_SOURCES - gl/hqnx_asm/hq2x_asm.cpp - gl/hqnx_asm/hq3x_asm.cpp - gl/hqnx_asm/hq4x_asm.cpp - gl/hqnx_asm/hqnx_asm_Image.cpp win32/eaxedit.cpp win32/fb_d3d9.cpp win32/fb_d3d9_wipe.cpp @@ -668,6 +680,25 @@ else( WIN32 ) set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_OSX_SOURCES} ${PLAT_COCOA_SOURCES} ) endif( WIN32 ) +if( HAVE_MMX ) + add_definitions( -DHAVE_MMX=1 ) + + set( SYSTEM_SOURCES ${SYSTEM_SOURCES} + gl/hqnx_asm/hq2x_asm.cpp + gl/hqnx_asm/hq3x_asm.cpp + gl/hqnx_asm/hq4x_asm.cpp + gl/hqnx_asm/hqnx_asm_Image.cpp) + + if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) + set_source_files_properties( + gl/hqnx_asm/hq2x_asm.cpp + gl/hqnx_asm/hq3x_asm.cpp + gl/hqnx_asm/hq4x_asm.cpp + gl/textures/gl_hqresize.cpp + PROPERTIES COMPILE_FLAGS "-mmmx" ) + endif( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) +endif( HAVE_MMX ) + if( NOT ASM_SOURCES ) set( ASM_SOURCES "" ) endif( NOT ASM_SOURCES ) diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index 41304be0f..d4688cfd1 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -57,7 +57,7 @@ CUSTOM_CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // when they are actually valid. void gl_SetupMenu() { -#ifndef _MSC_VER +#ifndef HAVE_MMX FOptionValues **opt = OptionValues.CheckKey("HqResizeModes"); if (opt != NULL) { diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 621f444bc..261f66e6a 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -40,13 +40,13 @@ #include "gl/textures/gl_texture.h" #include "c_cvars.h" #include "gl/hqnx/hqx.h" -#ifdef _MSC_VER +#ifdef HAVE_MMX #include "gl/hqnx_asm/hqnx_asm.h" #endif CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { -#ifdef _MSC_VER +#ifdef HAVE_MMX if (self < 0 || self > 9) #else if (self < 0 || self > 6) @@ -186,8 +186,7 @@ static unsigned char *scaleNxHelper( void (*scaleNxFunction) ( uint32* , uint32* return newBuffer; } -// [BB] hqnx scaling is only supported with the MS compiler. -#ifdef _MSC_VER +#ifdef HAVE_MMX static unsigned char *hqNxAsmHelper( void (*hqNxFunction) ( int*, unsigned char*, int, int, int ), const int N, unsigned char *inputBuffer, @@ -285,7 +284,7 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u outWidth = inWidth; outHeight = inHeight; int type = gl_texture_hqresize; -#ifdef _MSC_VER +#ifdef HAVE_MMX // ASM-hqNx does not preserve the alpha channel so fall back to C-version for such textures if (!hasAlpha && type > 3 && type <= 6) { @@ -307,7 +306,7 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u return hqNxHelper( &hq3x_32, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); case 6: return hqNxHelper( &hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); -#ifdef _MSC_VER +#ifdef HAVE_MMX case 7: return hqNxAsmHelper( &HQnX_asm::hq2x_32, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight ); case 8: From f8c38a0bbe9571dee33ed722d96b67ac016074c5 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 25 Dec 2015 15:42:13 +0200 Subject: [PATCH 0333/1509] - fixed GCC's 'unknown pragma' warnings in hqNx MMX implementation --- src/gl/hqnx_asm/hqnx_asm.h | 2 ++ src/gl/hqnx_asm/hqnx_asm_Image.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/gl/hqnx_asm/hqnx_asm.h b/src/gl/hqnx_asm/hqnx_asm.h index 2580f80ef..9ced349fa 100644 --- a/src/gl/hqnx_asm/hqnx_asm.h +++ b/src/gl/hqnx_asm/hqnx_asm.h @@ -21,7 +21,9 @@ #ifndef __HQNX_H__ #define __HQNX_H__ +#ifdef _MSC_VER #pragma warning(disable:4799) +#endif // _MSC_VER #include "hqnx_asm_Image.h" diff --git a/src/gl/hqnx_asm/hqnx_asm_Image.h b/src/gl/hqnx_asm/hqnx_asm_Image.h index 8f57d7865..e4157a7b5 100644 --- a/src/gl/hqnx_asm/hqnx_asm_Image.h +++ b/src/gl/hqnx_asm/hqnx_asm_Image.h @@ -24,7 +24,9 @@ #include #pragma once +#ifdef _MSC_VER #pragma warning(disable: 4103) +#endif // _MSC_VER #pragma pack(1) namespace HQnX_asm From 655defed2842ab5984110b23731ea4871462c33b Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Wed, 30 Dec 2015 17:54:54 -0500 Subject: [PATCH 0334/1509] Avoid compile errors on Linux. Fixes #107. --- src/gl/stereo3d/gl_stereo3d.cpp | 2 +- src/gl/stereo3d/gl_stereo3d.h | 1 + src/gl/stereo3d/gl_stereo_cvars.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gl/stereo3d/gl_stereo3d.cpp b/src/gl/stereo3d/gl_stereo3d.cpp index bc006a2f9..6e4a4a376 100644 --- a/src/gl/stereo3d/gl_stereo3d.cpp +++ b/src/gl/stereo3d/gl_stereo3d.cpp @@ -11,7 +11,7 @@ VSMatrix EyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE VSMatrix result; // Lifted from gl_scene.cpp FGLRenderer::SetProjection() - float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)); + float fovy = (float)(2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio))); result.perspective(fovy, aspectRatio, 5.f, 65536.f); return result; diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h index 8cfe886ac..44a76839e 100644 --- a/src/gl/stereo3d/gl_stereo3d.h +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -2,6 +2,7 @@ #define GL_STEREO3D_H_ #include +#include // needed for memcpy on linux, which is needed by VSMatrix copy ctor #include "gl/data/gl_matrix.h" diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index b91a47daa..7fc2941d5 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -14,7 +14,7 @@ CVAR(Float, vr_hunits_per_meter, 41.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // MET namespace s3d { // Initialize static member -Stereo3DMode const * Stereo3DMode::currentStereo3DMode = nullptr; +Stereo3DMode const * Stereo3DMode::currentStereo3DMode = 0; // "nullptr" not resolved on linux (presumably not C++11) /* static */ void Stereo3DMode::setCurrentMode(const Stereo3DMode& mode) { From 5b7f9b04cd9334aef782fa2f7bc8c270c8dbfa46 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Thu, 31 Dec 2015 09:06:44 -0500 Subject: [PATCH 0335/1509] Add license headers to stereo3d source files. --- src/gl/stereo3d/gl_anaglyph.cpp | 35 ++++++++++++++++++++++ src/gl/stereo3d/gl_anaglyph.h | 35 ++++++++++++++++++++++ src/gl/stereo3d/gl_stereo3d.cpp | 35 ++++++++++++++++++++++ src/gl/stereo3d/gl_stereo3d.h | 35 ++++++++++++++++++++++ src/gl/stereo3d/gl_stereo_cvars.cpp | 40 +++++++++++++++++++++++++ src/gl/stereo3d/gl_stereo_leftright.cpp | 35 ++++++++++++++++++++++ src/gl/stereo3d/gl_stereo_leftright.h | 35 ++++++++++++++++++++++ src/gl/stereo3d/scoped_color_mask.h | 35 ++++++++++++++++++++++ src/gl/stereo3d/scoped_view_shifter.cpp | 36 ++++++++++++++++++++++ src/gl/stereo3d/scoped_view_shifter.h | 36 ++++++++++++++++++++++ 10 files changed, 357 insertions(+) diff --git a/src/gl/stereo3d/gl_anaglyph.cpp b/src/gl/stereo3d/gl_anaglyph.cpp index e8be92882..ec0d049ec 100644 --- a/src/gl/stereo3d/gl_anaglyph.cpp +++ b/src/gl/stereo3d/gl_anaglyph.cpp @@ -1,3 +1,38 @@ +/* +** gl_anaglyph.cpp +** Color mask based stereoscopic 3D modes for GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + #include "gl_anaglyph.h" namespace s3d { diff --git a/src/gl/stereo3d/gl_anaglyph.h b/src/gl/stereo3d/gl_anaglyph.h index 4be6da99e..6f86540fe 100644 --- a/src/gl/stereo3d/gl_anaglyph.h +++ b/src/gl/stereo3d/gl_anaglyph.h @@ -1,3 +1,38 @@ +/* +** gl_anaglyph.h +** Color mask based stereoscopic 3D modes for GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + #ifndef GL_ANAGLYPH_H_ #define GL_ANAGLYPH_H_ diff --git a/src/gl/stereo3d/gl_stereo3d.cpp b/src/gl/stereo3d/gl_stereo3d.cpp index 6e4a4a376..ed16d9db5 100644 --- a/src/gl/stereo3d/gl_stereo3d.cpp +++ b/src/gl/stereo3d/gl_stereo3d.cpp @@ -1,3 +1,38 @@ +/* +** gl_stereo3d.cpp +** Stereoscopic 3D API +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + #include "gl/stereo3d/gl_stereo3d.h" #include "vectors.h" // RAD2DEG #include "doomtype.h" // M_PI diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h index 44a76839e..aca769734 100644 --- a/src/gl/stereo3d/gl_stereo3d.h +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -1,3 +1,38 @@ +/* +** gl_stereo3d.h +** Stereoscopic 3D API +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + #ifndef GL_STEREO3D_H_ #define GL_STEREO3D_H_ diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index 7fc2941d5..56895bbc6 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -1,3 +1,38 @@ +/* +** gl_stereo_cvars.cpp +** Console variables related to stereoscopic 3D in GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + #include "gl/stereo3d/gl_stereo3d.h" #include "gl/stereo3d/gl_stereo_leftright.h" #include "gl/stereo3d/gl_anaglyph.h" @@ -5,9 +40,14 @@ // Set up 3D-specific console variables: CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG) + // intraocular distance in meters CVAR(Float, vr_ipd, 0.062f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // METERS + +// distance between viewer and the display screen CVAR(Float, vr_screendist, 0.80f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS + +// default conversion between (vertical) DOOM units and meters CVAR(Float, vr_hunits_per_meter, 41.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS // Manage changing of 3D modes: diff --git a/src/gl/stereo3d/gl_stereo_leftright.cpp b/src/gl/stereo3d/gl_stereo_leftright.cpp index a05d1b82f..bf9fea09c 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.cpp +++ b/src/gl/stereo3d/gl_stereo_leftright.cpp @@ -1,3 +1,38 @@ +/* +** gl_stereo_leftright.cpp +** Offsets for left and right eye views +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + #include "gl_stereo_leftright.h" #include "vectors.h" // RAD2DEG #include "doomtype.h" // M_PI diff --git a/src/gl/stereo3d/gl_stereo_leftright.h b/src/gl/stereo3d/gl_stereo_leftright.h index f256ced33..24e026675 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.h +++ b/src/gl/stereo3d/gl_stereo_leftright.h @@ -1,3 +1,38 @@ +/* +** gl_stereo_leftright.h +** Offsets for left and right eye views +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + #ifndef GL_STEREO_LEFTRIGHT_H_ #define GL_STEREO_LEFTRIGHT_H_ diff --git a/src/gl/stereo3d/scoped_color_mask.h b/src/gl/stereo3d/scoped_color_mask.h index f746ba9e4..262d34cf7 100644 --- a/src/gl/stereo3d/scoped_color_mask.h +++ b/src/gl/stereo3d/scoped_color_mask.h @@ -1,3 +1,38 @@ +/* +** scoped_color_mask.h +** Stack-scoped class for temporarily changing the OpenGL color mask setting. +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + #ifndef GL_STEREO3D_SCOPED_COLOR_MASK_H_ #define GL_STEREO3D_SCOPED_COLOR_MASK_H_ diff --git a/src/gl/stereo3d/scoped_view_shifter.cpp b/src/gl/stereo3d/scoped_view_shifter.cpp index 74511f3f5..4e70c596d 100644 --- a/src/gl/stereo3d/scoped_view_shifter.cpp +++ b/src/gl/stereo3d/scoped_view_shifter.cpp @@ -1,3 +1,39 @@ +/* +** scoped_view_shifter.cpp +** Stack-scoped class for temporarily changing player viewpoint global variables viewx, viewy, viewz. +** Used for stereoscopic 3D. +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + #include "scoped_view_shifter.h" #include "r_utility.h" diff --git a/src/gl/stereo3d/scoped_view_shifter.h b/src/gl/stereo3d/scoped_view_shifter.h index 0b4f201a4..d43e2b32a 100644 --- a/src/gl/stereo3d/scoped_view_shifter.h +++ b/src/gl/stereo3d/scoped_view_shifter.h @@ -1,3 +1,39 @@ +/* +** scoped_view_shifter.h +** Stack-scoped class for temporarily changing player viewpoint global variables viewx, viewy, viewz. +** Used for stereoscopic 3D. +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + #ifndef GL_STEREO3D_SCOPED_VIEW_SHIFTER_H_ #define GL_STEREO3D_SCOPED_VIEW_SHIFTER_H_ From 95f413463052b70c2559cfd1fcbee8b8e93fd5cd Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Thu, 31 Dec 2015 09:36:37 -0500 Subject: [PATCH 0336/1509] Refactor stereo3d classes to use TArray instead of std::vector. --- src/gl/scene/gl_scene.cpp | 12 ++++++------ src/gl/stereo3d/gl_anaglyph.cpp | 4 ++-- src/gl/stereo3d/gl_stereo3d.h | 15 ++++++--------- src/gl/stereo3d/gl_stereo_leftright.h | 4 ++-- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index d94748f6d..518c35934 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -816,19 +816,19 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo float viewShift[3]; const s3d::Stereo3DMode& stereo3dMode = s3d::Stereo3DMode::getCurrentMode(); stereo3dMode.SetUp(); - s3d::Stereo3DMode::const_iterator eye; - for (eye = stereo3dMode.begin(); eye != stereo3dMode.end(); ++eye) + for (int eye_ix = 0; eye_ix < stereo3dMode.eye_count(); ++eye_ix) { - (*eye)->SetUp(); + const s3d::EyePose * eye = stereo3dMode.getEyePose(eye_ix); + eye->SetUp(); // TODO: stereo specific viewport - needed when implementing side-by-side modes etc. SetViewport(bounds); mCurrentFoV = fov; // Stereo mode specific perspective projection - SetProjection( (*eye)->GetProjection(fov, ratio, fovratio) ); + SetProjection( eye->GetProjection(fov, ratio, fovratio) ); // SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper SetViewAngle(viewangle); // Stereo mode specific viewpoint adjustment - temporarily shifts global viewx, viewy, viewz - (*eye)->GetViewShift(GLRenderer->mAngles.Yaw, viewShift); + eye->GetViewShift(GLRenderer->mAngles.Yaw, viewShift); s3d::ScopedViewShifter viewShifter(viewShift); SetViewMatrix(viewx, viewy, viewz, false, false); gl_RenderState.ApplyMatrices(); @@ -839,7 +839,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo ProcessScene(toscreen); EndDrawScene(viewsector); - (*eye)->TearDown(); + eye->TearDown(); } stereo3dMode.TearDown(); diff --git a/src/gl/stereo3d/gl_anaglyph.cpp b/src/gl/stereo3d/gl_anaglyph.cpp index ec0d049ec..4b3d4d00e 100644 --- a/src/gl/stereo3d/gl_anaglyph.cpp +++ b/src/gl/stereo3d/gl_anaglyph.cpp @@ -40,8 +40,8 @@ namespace s3d { MaskAnaglyph::MaskAnaglyph(const ColorMask& leftColorMask, double ipdMeters) : leftEye(leftColorMask, ipdMeters), rightEye(leftColorMask.inverse(), ipdMeters) { - eye_ptrs.push_back(&leftEye); - eye_ptrs.push_back(&rightEye); + eye_ptrs.Push(&leftEye); + eye_ptrs.Push(&rightEye); } diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h index aca769734..48b6ef900 100644 --- a/src/gl/stereo3d/gl_stereo3d.h +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -36,8 +36,8 @@ #ifndef GL_STEREO3D_H_ #define GL_STEREO3D_H_ -#include #include // needed for memcpy on linux, which is needed by VSMatrix copy ctor +#include "tarray.h" #include "gl/data/gl_matrix.h" @@ -72,23 +72,20 @@ public: class Stereo3DMode { public: - /* const_iterator cycles through the various eye viewpoints */ - typedef std::vector::const_iterator const_iterator; - /* static methods for managing the selected stereoscopic view state */ static const Stereo3DMode& getCurrentMode(); Stereo3DMode(); virtual ~Stereo3DMode(); - /* const_iterator cycles through the various eye viewpoints */ - virtual const_iterator begin() const { return eye_ptrs.begin(); } - virtual const_iterator end() const { return eye_ptrs.end(); } + virtual int eye_count() const { return eye_ptrs.Size(); } + virtual const EyePose * getEyePose(int ix) const { return eye_ptrs(ix); } + /* hooks for setup and cleanup operations for each stereo mode */ virtual void SetUp() const {}; virtual void TearDown() const {}; protected: - std::vector eye_ptrs; + TArray eye_ptrs; private: static Stereo3DMode const * currentStereo3DMode; @@ -105,7 +102,7 @@ public: static const MonoView& getInstance(); protected: - MonoView() { eye_ptrs.push_back(¢ralEye); } + MonoView() { eye_ptrs.Push(¢ralEye); } EyePose centralEye; }; diff --git a/src/gl/stereo3d/gl_stereo_leftright.h b/src/gl/stereo3d/gl_stereo_leftright.h index 24e026675..6bca9de90 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.h +++ b/src/gl/stereo3d/gl_stereo_leftright.h @@ -80,7 +80,7 @@ class LeftEyeView : public Stereo3DMode public: static const LeftEyeView& getInstance(FLOATTYPE ipd); - LeftEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.push_back(&eye); } + LeftEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.Push(&eye); } FLOATTYPE getIpd() const { return eye.getIpd(); } void setIpd(FLOATTYPE ipd) { eye.setIpd(ipd); } protected: @@ -93,7 +93,7 @@ class RightEyeView : public Stereo3DMode public: static const RightEyeView& getInstance(FLOATTYPE ipd); - RightEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.push_back(&eye); } + RightEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.Push(&eye); } FLOATTYPE getIpd() const { return eye.getIpd(); } void setIpd(FLOATTYPE ipd) { eye.setIpd(ipd); } protected: From ac6e2f4979605b65b9b794a229a94872e2fe664c Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Thu, 31 Dec 2015 11:57:21 -0500 Subject: [PATCH 0337/1509] Use gl_RenderState to manipulate OpenGL color mask for anaglyph modes, to avoid glGet... --- src/gl/renderer/gl_renderstate.cpp | 19 +++++++++++++++++++ src/gl/renderer/gl_renderstate.h | 25 +++++++++++++++++++++++++ src/gl/stereo3d/gl_anaglyph.h | 27 ++++++++++++++++++++------- src/gl/stereo3d/scoped_color_mask.h | 12 +++++++----- 4 files changed, 71 insertions(+), 12 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 15b046349..3e5900e45 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -70,6 +70,8 @@ void FRenderState::Reset() { mTextureEnabled = true; mBrightmapEnabled = mFogEnabled = mGlowEnabled = false; + mColorMask[0] = mColorMask[1] = mColorMask[2] = mColorMask[3] = true; + currentColorMask[0] = currentColorMask[1] = currentColorMask[2] = currentColorMask[3] = true; mFogColor.d = -1; mTextureMode = -1; mLightIndex = -1; @@ -257,6 +259,8 @@ void FRenderState::Apply() } } + ApplyColorMask(); + if (mVertexBuffer != mCurrentVertexBuffer) { if (mVertexBuffer == NULL) glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -268,6 +272,21 @@ void FRenderState::Apply() +void FRenderState::ApplyColorMask() +{ + if ((mColorMask[0] != currentColorMask[0]) || + (mColorMask[1] != currentColorMask[1]) || + (mColorMask[2] != currentColorMask[2]) || + (mColorMask[3] != currentColorMask[3])) + { + glColorMask(mColorMask[0], mColorMask[1], mColorMask[2], mColorMask[3]); + currentColorMask[0] = mColorMask[0]; + currentColorMask[1] = mColorMask[1]; + currentColorMask[2] = mColorMask[2]; + currentColorMask[3] = mColorMask[3]; + } +} + void FRenderState::ApplyMatrices() { if (GLRenderer->mShaderManager != NULL) diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 74065fe4c..aa24072c2 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -47,6 +47,8 @@ class FRenderState bool mFogEnabled; bool mGlowEnabled; bool mBrightmapEnabled; + bool mColorMask[4]; + bool currentColorMask[4]; int mLightIndex; int mSpecialEffect; int mTextureMode; @@ -116,6 +118,7 @@ public: } void Apply(); + void ApplyColorMask(); void ApplyMatrices(); void ApplyLightIndex(int index); @@ -174,6 +177,28 @@ public: mDesaturation = 0; } + void GetColorMask(bool& r, bool &g, bool& b, bool& a) const + { + r = mColorMask[0]; + g = mColorMask[1]; + b = mColorMask[2]; + a = mColorMask[3]; + } + + void SetColorMask(bool r, bool g, bool b, bool a) + { + mColorMask[0] = r; + mColorMask[1] = g; + mColorMask[2] = b; + mColorMask[3] = a; + } + + void ResetColorMask() + { + for (int i = 0; i < 4; ++i) + mColorMask[i] = true; + } + void SetTextureMode(int mode) { mTextureMode = mode; diff --git a/src/gl/stereo3d/gl_anaglyph.h b/src/gl/stereo3d/gl_anaglyph.h index 6f86540fe..d60506dde 100644 --- a/src/gl/stereo3d/gl_anaglyph.h +++ b/src/gl/stereo3d/gl_anaglyph.h @@ -39,6 +39,7 @@ #include "gl_stereo3d.h" #include "gl_stereo_leftright.h" #include "gl/system/gl_system.h" +#include "gl/renderer/gl_renderstate.h" namespace s3d { @@ -50,9 +51,9 @@ public: ColorMask(bool r, bool g, bool b) : r(r), g(g), b(b) {} ColorMask inverse() const { return ColorMask(!r, !g, !b); } - GLboolean r; - GLboolean g; - GLboolean b; + bool r; + bool g; + bool b; }; @@ -60,8 +61,14 @@ class AnaglyphLeftPose : public LeftEyePose { public: AnaglyphLeftPose(const ColorMask& colorMask, float ipd) : LeftEyePose(ipd), colorMask(colorMask) {} - virtual void SetUp() const { glColorMask(colorMask.r, colorMask.g, colorMask.b, true); } - virtual void TearDown() const { glColorMask(1,1,1,1); } + virtual void SetUp() const { + gl_RenderState.SetColorMask(colorMask.r, colorMask.g, colorMask.b, true); + gl_RenderState.ApplyColorMask(); + } + virtual void TearDown() const { + gl_RenderState.ResetColorMask(); + gl_RenderState.ApplyColorMask(); + } private: ColorMask colorMask; }; @@ -70,8 +77,14 @@ class AnaglyphRightPose : public RightEyePose { public: AnaglyphRightPose(const ColorMask& colorMask, float ipd) : RightEyePose(ipd), colorMask(colorMask) {} - virtual void SetUp() const { glColorMask(colorMask.r, colorMask.g, colorMask.b, true); } - virtual void TearDown() const { glColorMask(1,1,1,1); } + virtual void SetUp() const { + gl_RenderState.SetColorMask(colorMask.r, colorMask.g, colorMask.b, true); + gl_RenderState.ApplyColorMask(); + } + virtual void TearDown() const { + gl_RenderState.ResetColorMask(); + gl_RenderState.ApplyColorMask(); + } private: ColorMask colorMask; }; diff --git a/src/gl/stereo3d/scoped_color_mask.h b/src/gl/stereo3d/scoped_color_mask.h index 262d34cf7..5c35752e5 100644 --- a/src/gl/stereo3d/scoped_color_mask.h +++ b/src/gl/stereo3d/scoped_color_mask.h @@ -44,16 +44,18 @@ class ScopedColorMask { public: - ScopedColorMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a) + ScopedColorMask(bool r, bool g, bool b, bool a) { - glGetBooleanv(GL_COLOR_WRITEMASK, saved); - glColorMask(r, g, b, a); + gl_RenderState.GetColorMask(saved[0], saved[1], saved[2], saved[3]); + gl_RenderState.SetColorMask(r, g, b, a); + gl_RenderState.ApplyColorMask(); } ~ScopedColorMask() { - glColorMask(saved[0], saved[1], saved[2], saved[3]); + gl_RenderState.SetColorMask(saved[0], saved[1], saved[2], saved[3]); + gl_RenderState.ApplyColorMask(); } private: - GLboolean saved[4]; + bool saved[4]; }; From f2c890272f1ec3cf8d3f2634186e6d55bb7c3f2b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 1 Jan 2016 10:59:34 +0100 Subject: [PATCH 0338/1509] - FRenderState::Apply does not need to call ApplyColorMask. --- src/gl/renderer/gl_renderstate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 3e5900e45..15aa56da9 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -259,7 +259,7 @@ void FRenderState::Apply() } } - ApplyColorMask(); + //ApplyColorMask(); I don't think this is needed. if (mVertexBuffer != mCurrentVertexBuffer) { From cc10fe9bc3a16dde9fbc21f4edb1b80c65e3f7ff Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 4 Jan 2016 00:45:44 +0100 Subject: [PATCH 0339/1509] - fixed: The stereo3D code accessed the global 'viewsector' variable at a place where it no longer contained a correct value. - fixed: The same code did not exclude camera texture views from drawing the 2D overlay. --- src/gl/scene/gl_scene.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 518c35934..7a961d2cd 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -810,6 +810,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo mViewActor=camera; } + // 'viewsector' will not survive the rendering so it cannot be used anymore below. retval = viewsector; // Render (potentially) multiple views for stereo 3d @@ -838,7 +839,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo clipper.SafeAddClipRangeRealAngles(viewangle + a1, viewangle - a1); ProcessScene(toscreen); - EndDrawScene(viewsector); + if (mainview) EndDrawScene(retval); // do not call this for camera textures. eye->TearDown(); } stereo3dMode.TearDown(); From 7d2bbbd35150f482349c0b995a6f41fb6dee7c02 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 5 Jan 2016 18:59:32 +0100 Subject: [PATCH 0340/1509] - fixed rendering of two-sided polyobjects that have their upper or lower textures exposed. --- src/gl/scene/gl_walls.cpp | 115 ++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 53 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 9856f1d02..a906c47aa 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1418,9 +1418,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) fixed_t ffh2; sector_t * realfront; sector_t * realback; + sector_t * segfront; + sector_t * segback; #ifdef _DEBUG - if (seg->linedef-lines==5835) + if (seg->linedef-lines==904) { int a = 0; } @@ -1433,14 +1435,16 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if ((seg->sidedef->Flags & WALLF_POLYOBJ) && seg->backsector) { // Textures on 2-sided polyobjects are aligned to the actual seg's sectors - realfront = seg->frontsector; - realback = seg->backsector; + segfront = realfront = seg->frontsector; + segback = realback = seg->backsector; } else { // Need these for aligning the textures realfront = §ors[frontsector->sectornum]; realback = backsector ? §ors[backsector->sectornum] : NULL; + segfront = frontsector; + segback = backsector; } if (seg->sidedef == seg->linedef->sidedef[0]) @@ -1521,27 +1525,27 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) // Save a little time (up to 0.3 ms per frame ;) ) if (frontsector->floorplane.a | frontsector->floorplane.b) { - ffh1 = frontsector->floorplane.ZatPoint(v1); - ffh2 = frontsector->floorplane.ZatPoint(v2); + ffh1 = segfront->floorplane.ZatPoint(v1); + ffh2 = segfront->floorplane.ZatPoint(v2); zfloor[0] = FIXED2FLOAT(ffh1); zfloor[1] = FIXED2FLOAT(ffh2); } else { - ffh1 = ffh2 = -frontsector->floorplane.d; + ffh1 = ffh2 = -segfront->floorplane.d; zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh2); } - if (frontsector->ceilingplane.a | frontsector->ceilingplane.b) + if (segfront->ceilingplane.a | segfront->ceilingplane.b) { - fch1 = frontsector->ceilingplane.ZatPoint(v1); - fch2 = frontsector->ceilingplane.ZatPoint(v2); + fch1 = segfront->ceilingplane.ZatPoint(v1); + fch2 = segfront->ceilingplane.ZatPoint(v2); zceil[0] = FIXED2FLOAT(fch1); zceil[1] = FIXED2FLOAT(fch2); } else { - fch1 = fch2 = frontsector->ceilingplane.d; + fch1 = fch2 = segfront->ceilingplane.d; zceil[0] = zceil[1] = FIXED2FLOAT(fch2); } @@ -1577,24 +1581,24 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) fixed_t bfh1; fixed_t bfh2; - if (backsector->floorplane.a | backsector->floorplane.b) + if (segback->floorplane.a | segback->floorplane.b) { - bfh1 = backsector->floorplane.ZatPoint(v1); - bfh2 = backsector->floorplane.ZatPoint(v2); + bfh1 = segback->floorplane.ZatPoint(v1); + bfh2 = segback->floorplane.ZatPoint(v2); } else { - bfh1 = bfh2 = -backsector->floorplane.d; + bfh1 = bfh2 = -segback->floorplane.d; } - if (backsector->ceilingplane.a | backsector->ceilingplane.b) + if (segback->ceilingplane.a | segback->ceilingplane.b) { - bch1 = backsector->ceilingplane.ZatPoint(v1); - bch2 = backsector->ceilingplane.ZatPoint(v2); + bch1 = segback->ceilingplane.ZatPoint(v1); + bch2 = segback->ceilingplane.ZatPoint(v2); } else { - bch1 = bch2 = backsector->ceilingplane.d; + bch1 = bch2 = segback->ceilingplane.d; } SkyTop(seg, frontsector, backsector, v1, v2); @@ -1623,25 +1627,28 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling), fch1, fch2, bch1a, bch2a, 0); } - else if ((frontsector->ceilingplane.a | frontsector->ceilingplane.b | - backsector->ceilingplane.a | backsector->ceilingplane.b) && - frontsector->GetTexture(sector_t::ceiling) != skyflatnum && - backsector->GetTexture(sector_t::ceiling) != skyflatnum) - { - gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::ceiling), false, true); - if (gltexture) - { - DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, - realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling), - fch1, fch2, bch1a, bch2a, 0); - } - } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) { - // skip processing if the back is a malformed subsector - if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4)) + if ((frontsector->ceilingplane.a | frontsector->ceilingplane.b | + backsector->ceilingplane.a | backsector->ceilingplane.b) && + frontsector->GetTexture(sector_t::ceiling) != skyflatnum && + backsector->GetTexture(sector_t::ceiling) != skyflatnum) { - gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a); + gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::ceiling), false, true); + if (gltexture) + { + DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, + realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling), + fch1, fch2, bch1a, bch2a, 0); + } + } + else + { + // skip processing if the back is a malformed subsector + if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4)) + { + gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a); + } } } } @@ -1692,29 +1699,31 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) realfront->GetPlaneTexZ(sector_t::floor) - realback->GetPlaneTexZ(sector_t::ceiling) : realfront->GetPlaneTexZ(sector_t::floor) - realfront->GetPlaneTexZ(sector_t::ceiling)); } - else if ((frontsector->floorplane.a | frontsector->floorplane.b | - backsector->floorplane.a | backsector->floorplane.b) && - frontsector->GetTexture(sector_t::floor) != skyflatnum && - backsector->GetTexture(sector_t::floor) != skyflatnum) + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) { - // render it anyway with the sector's floor texture. With a background sky - // there are ugly holes otherwise and slopes are simply not precise enough - // to mach in any case. - gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), false, true); - if (gltexture) + if ((frontsector->floorplane.a | frontsector->floorplane.b | + backsector->floorplane.a | backsector->floorplane.b) && + frontsector->GetTexture(sector_t::floor) != skyflatnum && + backsector->GetTexture(sector_t::floor) != skyflatnum) { - DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, - realback->GetPlaneTexZ(sector_t::floor), realfront->GetPlaneTexZ(sector_t::floor), - bfh1, bfh2, ffh1, ffh2, realfront->GetPlaneTexZ(sector_t::floor) - realfront->GetPlaneTexZ(sector_t::ceiling)); + // render it anyway with the sector's floor texture. With a background sky + // there are ugly holes otherwise and slopes are simply not precise enough + // to mach in any case. + gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), false, true); + if (gltexture) + { + DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, + realback->GetPlaneTexZ(sector_t::floor), realfront->GetPlaneTexZ(sector_t::floor), + bfh1, bfh2, ffh1, ffh2, realfront->GetPlaneTexZ(sector_t::floor) - realfront->GetPlaneTexZ(sector_t::ceiling)); + } } - } - else if (backsector->GetTexture(sector_t::floor) != skyflatnum && - !(seg->sidedef->Flags & WALLF_POLYOBJ)) - { - // skip processing if the back is a malformed subsector - if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4)) + else if (backsector->GetTexture(sector_t::floor) != skyflatnum) { - gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1); + // skip processing if the back is a malformed subsector + if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4)) + { + gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1); + } } } } From 926e9fdac491e73e7725d8670947444b4790206c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Jan 2016 22:20:57 +0100 Subject: [PATCH 0341/1509] - fixed: For 2D-drawing of camera textures the render style was not set. --- src/gl/renderer/gl_renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 3a44a714f..dd4730687 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -319,6 +319,7 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) parms.colorOverlay = 0; } + gl_SetRenderStyle(parms.style, !parms.masked, false); if (!img->bHasCanvas) { int translation = 0; @@ -330,7 +331,6 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) if (pal) translation = -pal->GetIndex(); } } - gl_SetRenderStyle(parms.style, !parms.masked, false); gl_RenderState.SetMaterial(gltex, CLAMP_XY_NOMIP, translation, 0, !!(parms.style.Flags & STYLEF_RedIsAlpha)); u1 = gltex->GetUL(); From d97494afea573d5ae2c886d3d8a03f9f20b6d57b Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 8 Jan 2016 10:18:16 +0200 Subject: [PATCH 0342/1509] - fixed: check for MMX availability the check was using C compiler flags instead of C++ which led to test failure for 32-bit Intel targets, at least on Linux with GCC --- src/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2b27aa95b..5b762de70 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -453,17 +453,17 @@ endif( SSE_MATTERS ) if( X64 ) set( HAVE_MMX 1 ) else( X64 ) - set( SAFE_CMAKE_C_FLAGS ${CMAKE_C_FLAGS} ) + set( SAFE_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ) if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) - set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmmx") + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmmx") endif( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) CHECK_CXX_SOURCE_COMPILES("#include int main(void) { __m64 v = _m_from_int(0); }" HAVE_MMX) - set( CMAKE_C_FLAGS ${SAFE_CMAKE_C_FLAGS} ) + set( CMAKE_CXX_FLAGS ${SAFE_CMAKE_CXX_FLAGS} ) endif( X64 ) # Set up flags for GCC From 9fe016d6d087d8906307a5f77c3ee8edda7f52b1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 6 Jan 2016 17:15:08 +0100 Subject: [PATCH 0343/1509] - EDF parser part 1: Mapthings. --- src/CMakeLists.txt | 1 + src/edf.cpp | 295 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 296 insertions(+) create mode 100644 src/edf.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 90748f257..1f60d686a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -880,6 +880,7 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE doomstat.cpp dsectoreffect.cpp dthinker.cpp + edf.cpp f_wipe.cpp farchive.cpp files.cpp diff --git a/src/edf.cpp b/src/edf.cpp new file mode 100644 index 000000000..afc9e3f55 --- /dev/null +++ b/src/edf.cpp @@ -0,0 +1,295 @@ +/* +** edf.cpp +** Parses Eternity EDF lumps +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "w_wad.h" +#include "m_argv.h" +#include "zstring.h" +#include "sc_man.h" +#include "g_level.h" +#include "doomdata.h" +#include "r_defs.h" +#include "info.h" + + +struct FEdfOptions : public FOptionalMapinfoData +{ + FEdfOptions() + { + identifier = "EDF"; + } + virtual FOptionalMapinfoData *Clone() const + { + FEdfOptions *newopt = new FEdfOptions; + newopt->identifier = identifier; + newopt->edfName = edfName; + newopt->acsName = acsName; + return newopt; + } + FString edfName; + FString acsName; +}; + +DEFINE_MAP_OPTION(edf, false) +{ + FEdfOptions *opt = info->GetOptData("EDF"); + + parse.ParseAssign(); + parse.sc.MustGetString(); + opt->edfName = parse.sc.String; +} + +DEFINE_MAP_OPTION(loadacs, false) +{ + FEdfOptions *opt = info->GetOptData("EDF"); + + parse.ParseAssign(); + parse.sc.MustGetString(); + opt->acsName = parse.sc.String; +} + +struct EDFMapthing +{ + int recordnum; + int tid; + int type; + fixed_t height; + int args[5]; + WORD skillfilter; + DWORD flags; +}; + +struct EDFLinedef +{ + int recordnum; + int special; + int tag; + int id; + int args[5]; + float alpha; + DWORD flags; +}; + +struct EDFSector +{ + int recordnum; + + DWORD flags; + DWORD flagsRemove; + DWORD flagsAdd; + + int damageamount; + int damageinterval; + FNameNoInit damagetype; + + // These do not represent any of ZDoom's features. They are maintained like this so that the Add and Remove versions work as intended. + int damageflags; + int damageflagsAdd; + int damageflagsRemove; + + // floorterrain (Type TBD) + + // ceilingterrain is ignored + // colormaptop/mid/bottom need to be translated into color values (the colormap implementation in Eternity is not the same as in Boom!) + + FTransform planexform[2]; + DWORD portalflags[2]; + fixed_t overlayalpha[2]; +}; + +static TMap EDFLines; +static TMap EDFSectors; +static TMap EDFThings; + + +static void parseLinedef(FScanner &sc) +{ +} + +static void parseSector(FScanner &sc) +{ +} + +static void parseMapthing(FScanner &sc) +{ + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + EDFMapthing mt; + + memset(&mt, 0, sizeof(mt)); + mt.flags |= MTF_SINGLE | MTF_COOPERATIVE | MTF_DEATHMATCH; // EDF uses inverse logic, like Doom.exe + sc.MustGetString(); + if (sc.Compare("recordnum")) + { + sc.CheckString("="); + sc.MustGetNumber(); + mt.recordnum = sc.Number; + } + else if (sc.Compare("tid")) + { + sc.CheckString("="); + sc.MustGetNumber(); + mt.tid = sc.Number; + } + else if (sc.Compare("type")) + { + sc.CheckString("="); + if (sc.CheckNumber()) + { + mt.type = sc.Number; + } + else + { + // Class name. + sc.MustGetString(); + // According to the Eternity Wiki a name may be prefixed with 'thing:'. + const char *pos = strchr(sc.String, ':'); // Eternity never checks if the prefix actually is 'thing'. + if (pos) pos++; + else pos = sc.String; + const PClass *cls = PClass::FindClass(pos); + if (cls != NULL) + { + FDoomEdMap::Iterator it(DoomEdMap); + FDoomEdMap::Pair *pair; + while (it.NextPair(pair)) + { + if (pair->Value.Type == cls) + { + mt.type = pair->Key; + break; + } + } + } + else + { + //Let's hope not something internal to Eternity... + sc.ScriptError("Unknown type '%s'", sc.String); + } + + } + } + else if (sc.Compare("args")) + { + sc.CheckString("="); + sc.MustGetStringName("{"); + int c = 0; + while (!sc.CheckString("}")) + { + sc.MustGetNumber(); + mt.args[c++] = sc.Number; + + } + } + else if (sc.Compare("height")) + { + sc.CheckString("="); + sc.MustGetFloat(); // no idea if Eternity allows fractional numbers. Better be safe and do it anyway. + mt.height = FLOAT2FIXED(sc.Float); + } + else if (sc.Compare("options")) + { + do + { + sc.MustGetString(); + for (const char *tok = strtok(sc.String, ",+ \t"); tok != NULL; tok = strtok(NULL, ",+ \t")) + { + if (!stricmp(tok, "EASY")) mt.skillfilter |= 3; + else if (!stricmp(tok, "NORMAL")) mt.skillfilter |= 4; + else if (!stricmp(tok, "HARD")) mt.skillfilter |= 24; + else if (!stricmp(tok, "AMBUSH")) mt.flags |= MTF_AMBUSH; + else if (!stricmp(tok, "NOTSINGLE")) mt.flags &= ~MTF_SINGLE; + else if (!stricmp(tok, "NOTDM")) mt.flags &= ~MTF_DEATHMATCH; + else if (!stricmp(tok, "NOTCOOP")) mt.flags &= ~MTF_COOPERATIVE; + else if (!stricmp(tok, "FRIEND")) mt.flags |= MTF_FRIENDLY; + else if (!stricmp(tok, "DORMANT")) mt.flags |= MTF_DORMANT; + else sc.ScriptError("Unknown option '%s'", tok); + } + } while (sc.CheckString("|")); // Unquoted strings with '|' separator - parse as a separate string in the loop. + } + else + { + sc.ScriptError("Unknown property '%s'", sc.String); + } + } +} + +void loadEDF() +{ + FString filename; + FScanner sc; + + EDFLines.Clear(); + EDFSectors.Clear(); + EDFThings.Clear(); + + const char *arg = Args->CheckValue("-edf"); + + if (arg != NULL) filename = arg; + else + { + FEdfOptions *opt = level.info->GetOptData("EDF", false); + if (opt != NULL) + { + filename = opt->edfName; + } + } + + if (filename.IsEmpty()) return; + int lump = Wads.CheckNumForFullName(filename, true, ns_global); + if (lump == -1) return; + sc.OpenLumpNum(lump); + + sc.SetCMode(true); + while (sc.GetString()) + { + if (sc.Compare("linedef")) + { + parseLinedef(sc); + } + else if (sc.Compare("mapthing")) + { + parseMapthing(sc); + } + else if (sc.Compare("sector")) + { + parseSector(sc); + } + else + { + sc.ScriptError("Unknown keyword '%s'", sc.String); + } + } + + +} \ No newline at end of file From bdfac02f696abc646f49e7b4614e289078251789 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 6 Jan 2016 22:40:11 +0100 Subject: [PATCH 0344/1509] - EDF parser for linedefs and sectors. Also extended the Eternity xlat table to handle the parameterized types to the point EDF needs. --- src/edf.cpp | 320 +++++++++++++++++++++++++++++++- src/p_spec.cpp | 2 + wadsrc/static/xlat/eternity.txt | 167 +++++++++-------- 3 files changed, 406 insertions(+), 83 deletions(-) diff --git a/src/edf.cpp b/src/edf.cpp index afc9e3f55..05c66ee8b 100644 --- a/src/edf.cpp +++ b/src/edf.cpp @@ -40,6 +40,8 @@ #include "doomdata.h" #include "r_defs.h" #include "info.h" +#include "p_lnspec.h" +#include "p_setup.h" struct FEdfOptions : public FOptionalMapinfoData @@ -96,10 +98,13 @@ struct EDFLinedef int tag; int id; int args[5]; - float alpha; + fixed_t alpha; DWORD flags; + DWORD activation; }; + + struct EDFSector { int recordnum; @@ -113,9 +118,9 @@ struct EDFSector FNameNoInit damagetype; // These do not represent any of ZDoom's features. They are maintained like this so that the Add and Remove versions work as intended. - int damageflags; - int damageflagsAdd; - int damageflagsRemove; + DWORD damageflags; + DWORD damageflagsAdd; + DWORD damageflagsRemove; // floorterrain (Type TBD) @@ -134,10 +139,317 @@ static TMap EDFThings; static void parseLinedef(FScanner &sc) { + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + EDFLinedef ld; + bool argsset = false; + + memset(&ld, 0, sizeof(ld)); + ld.alpha = FRACUNIT; + sc.MustGetString(); + if (sc.Compare("recordnum")) + { + sc.CheckString("="); + sc.MustGetNumber(); + ld.recordnum = sc.Number; + } + else if (sc.Compare("tag")) + { + sc.CheckString("="); + sc.MustGetNumber(); + ld.tag = sc.Number; + } + else if (sc.Compare("id")) + { + sc.CheckString("="); + sc.MustGetNumber(); + ld.id = sc.Number; + } + else if (sc.Compare("special")) + { + sc.CheckString("="); + if (sc.CheckNumber()) + { + // Oh joy, this is going to be fun... + // Here we cannot do anything because we need the tag to make this work. + // For now just store a negative number. + ld.special = -sc.Number; + } + else + { + sc.MustGetString(); + ld.special = P_FindLineSpecial(sc.String); + } + } + else if (sc.Compare("args")) + { + sc.CheckString("="); + sc.MustGetStringName("{"); + int c = 0; + while (!sc.CheckString("}")) + { + sc.MustGetNumber(); + ld.args[c++] = sc.Number; + + } + argsset = true; + } + else if (sc.Compare("alpha")) + { + sc.CheckString("="); + sc.MustGetFloat(); + ld.alpha = FLOAT2FIXED(sc.Float); + } + else if (sc.Compare("options")) + { + // these are needed to build the proper activation mask out of the possible flags which do not match ZDoom 1:1. + DWORD actmethod = 0; + DWORD acttype = 0; + do + { + sc.MustGetString(); + for (const char *tok = strtok(sc.String, ",+ \t"); tok != NULL; tok = strtok(NULL, ",+ \t")) + { + if (!stricmp(tok, "USE")) actmethod |= SPAC_Use | SPAC_MUse; + else if (!stricmp(tok, "CROSS")) actmethod |= SPAC_Cross | SPAC_MCross | SPAC_PCross; + else if (!stricmp(tok, "IMPACT")) ld.activation |= SPAC_Impact; + else if (!stricmp(tok, "PUSH")) actmethod |= SPAC_Push; + else if (!stricmp(tok, "PLAYER")) acttype |= SPAC_Use | SPAC_Cross | SPAC_Push; + else if (!stricmp(tok, "MONSTER")) acttype |= SPAC_MUse | SPAC_MCross | SPAC_MPush; + else if (!stricmp(tok, "MISSILE")) acttype |= SPAC_PCross; + else if (!stricmp(tok, "REPEAT")) ld.flags |= ML_REPEAT_SPECIAL; + else if (!stricmp(tok, "1SONLY")) ld.flags |= ML_FIRSTSIDEONLY; + else if (!stricmp(tok, "ADDITIVE")) ld.flags |= ML_ADDTRANS; + else if (!stricmp(tok, "BLOCKALL")) ld.flags |= ML_BLOCKEVERYTHING; + else if (!stricmp(tok, "ZONEBOUNDARY")) ld.flags |= ML_ZONEBOUNDARY; + else if (!stricmp(tok, "CLIPMIDTEX")) ld.flags |= ML_CLIP_MIDTEX; + else sc.ScriptError("Unknown option '%s'", tok); + } + } while (sc.CheckString("|")); // Unquoted strings with '|' separator - parse as a separate string in the loop. + + // and finally we must mask in the activation method + ld.activation |= (actmethod & acttype); + } + else + { + sc.ScriptError("Unknown property '%s'", sc.String); + } + if (ld.tag == 0) ld.tag = ld.id; // urgh... + if (ld.special < 0) // translate numeric specials. + { + line_t line; + maplinedef_t mld; + mld.special = -ld.special; + mld.tag = ld.tag; + P_TranslateLineDef(&line, &mld); + ld.special = line.special; + if (!argsset) memcpy(ld.args, line.args, sizeof(ld.args)); + } + } } static void parseSector(FScanner &sc) { + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + EDFSector sec; + + memset(&sec, 0, sizeof(sec)); + sec.overlayalpha[sector_t::floor] = sec.overlayalpha[sector_t::ceiling] = FRACUNIT; + sc.MustGetString(); + if (sc.Compare("recordnum")) + { + sc.CheckString("="); + sc.MustGetNumber(); + sec.recordnum = sc.Number; + } + else if (sc.Compare("flags")) + { + DWORD *flagvar = NULL; + if (sc.CheckString(".")) + { + sc.MustGetString(); + if (sc.Compare("add")) + { + flagvar = &sec.flagsAdd; + } + else if (sc.Compare("remove")) + { + flagvar = &sec.flagsRemove; + } + else + { + sc.ScriptError("Invalid property 'flags.%s'", sc.String); + } + } + else + { + flagvar = &sec.flags; + } + do + { + sc.MustGetString(); + for (const char *tok = strtok(sc.String, ",+ \t"); tok != NULL; tok = strtok(NULL, ",+ \t")) + { + if (!stricmp(tok, "SECRET")) *flagvar |= SECF_SECRET; + else if (!stricmp(tok, "FRICTION")) *flagvar |= SECF_FRICTION; + else if (!stricmp(tok, "PUSH")) *flagvar |= SECF_PUSH; + else if (!stricmp(tok, "KILLSOUND")) *flagvar |= SECF_SILENT; + else if (!stricmp(tok, "KILLMOVESOUND")) *flagvar |= SECF_SILENTMOVE; + else sc.ScriptError("Unknown option '%s'", tok); + } + } while (sc.CheckString("|")); // Unquoted strings with '|' separator - parse as a separate string in the loop. + } + else if (sc.Compare("damage")) + { + sc.CheckString("="); + sc.MustGetNumber(); + sec.damageamount = sc.Number; + } + else if (sc.Compare("damagemask")) + { + sc.CheckString("="); + sc.MustGetNumber(); + sec.damageinterval = sc.Number; + } + else if (sc.Compare("damageflags")) + { + DWORD *flagvar = NULL; + if (sc.CheckString(".")) + { + sc.MustGetString(); + if (sc.Compare("add")) + { + flagvar = &sec.damageflagsAdd; + } + else if (sc.Compare("remove")) + { + flagvar = &sec.damageflagsRemove; + } + else + { + sc.ScriptError("Invalid property 'flags.%s'", sc.String); + } + } + else + { + flagvar = &sec.damageflags; + } + do + { + sc.MustGetString(); + for (const char *tok = strtok(sc.String, ",+ \t"); tok != NULL; tok = strtok(NULL, ",+ \t")) + { + if (!stricmp(tok, "LEAKYSUIT")) *flagvar |= 1; + else if (!stricmp(tok, "IGNORESUIT")) *flagvar |= 2; // these first 2 bits will be used to set 'leakychance', but this can only be done when the sector gets initialized + else if (!stricmp(tok, "ENDGODMODE")) *flagvar |= SECF_ENDGODMODE; + else if (!stricmp(tok, "ENDLEVEL")) *flagvar |= SECF_ENDLEVEL; + else if (!stricmp(tok, "TERRAINHIT")) *flagvar |= SECF_DMGTERRAINFX; + else sc.ScriptError("Unknown option '%s'", tok); + } + } while (sc.CheckString("|")); // Unquoted strings with '|' separator - parse as a separate string in the loop. + } + else if (sc.Compare("floorterrain")) + { + sc.CheckString("="); + sc.MustGetString(); + // ZDoom does not implement this yet. + } + else if (sc.Compare("floorangle")) + { + sc.CheckString("="); + sc.MustGetFloat(); + sec.planexform[sector_t::floor].angle = angle_t(sc.Float * ANGLE_90 / 90.); + } + else if (sc.Compare("flooroffsetx")) + { + sc.CheckString("="); + sc.MustGetFloat(); + sec.planexform[sector_t::floor].xoffs = FLOAT2FIXED(sc.Float); + } + else if (sc.Compare("flooroffsety")) + { + sc.CheckString("="); + sc.MustGetFloat(); + sec.planexform[sector_t::floor].yoffs = FLOAT2FIXED(sc.Float); + } + else if (sc.Compare("ceilingangle")) + { + sc.CheckString("="); + sc.MustGetFloat(); + sec.planexform[sector_t::ceiling].angle = angle_t(sc.Float * ANGLE_90 / 90.); + } + else if (sc.Compare("ceilingoffsetx")) + { + sc.CheckString("="); + sc.MustGetFloat(); + sec.planexform[sector_t::ceiling].xoffs = FLOAT2FIXED(sc.Float); + } + else if (sc.Compare("ceilingoffsety")) + { + sc.CheckString("="); + sc.MustGetFloat(); + sec.planexform[sector_t::ceiling].yoffs = FLOAT2FIXED(sc.Float); + } + else if (sc.Compare("colormaptop") || sc.Compare("colormapbottom")) + { + sc.CheckString("="); + sc.MustGetString(); + // not implemented by ZDoom + } + else if (sc.Compare("colormapmid")) + { + sc.CheckString("="); + sc.MustGetString(); + // the colormap should be analyzed and converted into an RGB color value. + } + else if (sc.Compare("overlayalpha")) + { + sc.MustGetStringName("."); + sc.MustGetString(); + if (sc.Compare("floor")) + { + sc.MustGetFloat(); + sec.overlayalpha[sector_t::floor] = FLOAT2FIXED(sc.Float); + } + else if (sc.Compare("ceiling")) + { + sc.MustGetFloat(); + sec.overlayalpha[sector_t::floor] = FLOAT2FIXED(sc.Float); + } + } + else if (sc.Compare("portalflags")) + { + int dest = 0; + sc.MustGetStringName("."); + sc.MustGetString(); + if (sc.Compare("floor")) dest = sector_t::floor; + else if (sc.Compare("ceiling")) dest = sector_t::ceiling; + else sc.ScriptError("Unknown portal type '%s'", sc.String); + + do + { + sc.MustGetString(); + for (const char *tok = strtok(sc.String, ",+ \t"); tok != NULL; tok = strtok(NULL, ",+ \t")) + { + if (!stricmp(tok, "DISABLED")) sec.portalflags[dest] |= 0; + else if (!stricmp(tok, "NORENDER")) sec.portalflags[dest] |= 0; + else if (!stricmp(tok, "NOPASS")) sec.portalflags[dest] |= 0; + else if (!stricmp(tok, "BLOCKSOUND")) sec.portalflags[dest] |= 0; + else if (!stricmp(tok, "OVERLAY")) sec.portalflags[dest] |= 0; + else if (!stricmp(tok, "ADDITIVE")) sec.portalflags[dest] |= 0; + else if (!stricmp(tok, "USEGLOBALTEX")) {} // not implemented + else sc.ScriptError("Unknown option '%s'", tok); + } + } while (sc.CheckString("|")); // Unquoted strings with '|' separator - parse as a separate string in the loop. + } + else + { + sc.ScriptError("Unknown property '%s'", sc.String); + } + } } static void parseMapthing(FScanner &sc) diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 918d07ed2..1ce505da9 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -1320,6 +1320,8 @@ void P_SpawnSpecials (void) P_InitSectorSpecial(sector, sector->special, false); } + + // Here is the place to handle EDF for sectors. // Init other misc stuff diff --git a/wadsrc/static/xlat/eternity.txt b/wadsrc/static/xlat/eternity.txt index 7b4367ee3..fe88e5cde 100644 --- a/wadsrc/static/xlat/eternity.txt +++ b/wadsrc/static/xlat/eternity.txt @@ -60,53 +60,52 @@ define Unsupported (0) // Parameterized linedefs // They are never used directly in Doom-format maps. Instead, it passes through ExtraData and 270. // Hexen format is incomplete; and Quasar wants to use ZDoom-compatible special values for UDMF. -// So there is no need to bother with them and they are listed only for completeness' sake. -/* - 300: "Door_Raise" - 301: "Door_Open" - 302: "Door_Close" - 303: "Door_CloseWaitOpen" - 304: "Door_WaitRaise" - 305: "Door_WaitClose" - 306: "Floor_RaiseToHighest" - 307: "Floor_LowerToHighest" - 308: "Floor_RaiseToLowest" - 309: "Floor_LowerToLowest" - 310: "Floor_RaiseToNearest" - 311: "Floor_LowerToNearest" - 312: "Floor_RaiseToLowestCeiling" - 313: "Floor_LowerToLowestCeiling" - 314: "Floor_RaiseToCeiling" - 315: "Floor_RaiseByTexture" - 316: "Floor_LowerByTexture" - 317: "Floor_RaiseByValue" - 318: "Floor_LowerByValue" - 319: "Floor_MoveToValue" - 320: "Floor_RaiseInstant" - 321: "Floor_LowerInstant" - 322: "Floor_ToCeilingInstant" - 323: "Ceiling_RaiseToHighest" - 324: "Ceiling_ToHighestInstant" - 325: "Ceiling_RaiseToNearest" - 326: "Ceiling_LowerToNearest" - 327: "Ceiling_RaiseToLowest" - 328: "Ceiling_LowerToLowest" - 329: "Ceiling_RaiseToHighestFloor" - 330: "Ceiling_LowerToHighestFloor" - 331: "Ceiling_ToFloorInstant" - 332: "Ceiling_LowerToFloor" - 333: "Ceiling_RaiseByTexture" - 334: "Ceiling_LowerByTexture" - 335: "Ceiling_RaiseByValue" - 336: "Ceiling_LowerByValue" - 337: "Ceiling_MoveToValue" - 338: "Ceiling_RaiseInstant" - 339: "Ceiling_LowerInstant" - 340: "Stairs_BuildUpDoom" - 341: "Stairs_BuildDownDoom" - 342: "Stairs_BuildUpDoomSync" - 343: "Stairs_BuildDownDoomSync" -*/ +// The translation here is for the odd EDF that specifies them as numbers. + +300 = 0, Door_Raise(0) +301 = 0, Door_Open(0) +302 = 0, Door_Close(0) +303 = 0, Door_CloseWaitOpen(0) +304 = 0, Door_WaitRaise(0) +305 = 0, Door_WaitClose(0) +306 = 0, Floor_RaiseToHighest(0) +307 = 0, Floor_LowerToHighest(0) +308 = 0, Floor_RaiseToLowest(0) +309 = 0, Floor_LowerToLowest(0) +310 = 0, Floor_RaiseToNearest(0) +311 = 0, Floor_LowerToNearest(0) +312 = 0, Floor_RaiseToLowestCeiling(0) +313 = 0, Floor_LowerToLowestCeiling(0) +314 = 0, Floor_RaiseToCeiling(0) +315 = 0, Floor_RaiseByTexture(0) +316 = 0, Floor_LowerByTexture(0) +317 = 0, Floor_RaiseByValue(0) +318 = 0, Floor_LowerByValue(0) +319 = 0, Floor_MoveToValue(0) +320 = 0, Floor_RaiseInstant(0) +321 = 0, Floor_LowerInstant(0) +322 = 0, Floor_ToCeilingInstant(0) +323 = 0, Ceiling_RaiseToHighest(0) +324 = 0, Ceiling_ToHighestInstant(0) +325 = 0, Ceiling_RaiseToNearest(0) +326 = 0, Ceiling_LowerToNearest(0) +327 = 0, Ceiling_RaiseToLowest(0) +328 = 0, Ceiling_LowerToLowest(0) +329 = 0, Ceiling_RaiseToHighestFloor(0) +330 = 0, Ceiling_LowerToHighestFloor(0) +331 = 0, Ceiling_ToFloorInstant(0) +332 = 0, Ceiling_LowerToFloor(0) +333 = 0, Ceiling_RaiseByTexture(0) +334 = 0, Ceiling_LowerByTexture(0) +335 = 0, Ceiling_RaiseByValue(0) +336 = 0, Ceiling_LowerByValue(0) +337 = 0, Ceiling_MoveToValue(0) +338 = 0, Ceiling_RaiseInstant(0) +339 = 0, Ceiling_LowerInstant(0) +340 = 0, Stairs_BuildUpDoom(0) +341 = 0, Stairs_BuildDownDoom(0) +342 = 0, Stairs_BuildUpDoomSync(0) +343 = 0, Stairs_BuildDownDoomSync(0) // Two-way portals are not supported yet either 344 = 0, Unsupported() // "Portal_TwowayCeiling" @@ -115,18 +114,16 @@ define Unsupported (0) 347 = 0, Unsupported() // "Portal_TwowayAnchorLineFloor" // More parameterized linedefs -/* - 348: "Polyobj_StartLine" - 349: "Polyobj_ExplicitLine" - 350: "Polyobj_DoorSlide" - 351: "Polyobj_DoorSwing" - 352: "Polyobj_Move" - 353: "Polyobj_OR_Move" - 354: "Polyobj_RotateRight" - 355: "Polyobj_OR_RotateRight" - 356: "Polyobj_RotateLeft" - 357: "Polyobj_OR_RotateLeft" -*/ +348 = 0, Polyobj_StartLine(0) +349 = 0, Polyobj_ExplicitLine(0) +350 = 0, Polyobj_DoorSlide(0) +351 = 0, Polyobj_DoorSwing(0) +352 = 0, Polyobj_Move(0) +353 = 0, Polyobj_OR_Move(0) +354 = 0, Polyobj_RotateRight(0) +355 = 0, Polyobj_OR_RotateRight(0) +356 = 0, Polyobj_RotateLeft(0) +357 = 0, Polyobj_OR_RotateLeft(0) // Eternity's linked portals, vertical link version (floor-to-ceiling) 358 = 0, Unsupported() // "Portal_LinkedCeiling" @@ -135,22 +132,20 @@ define Unsupported (0) 361 = 0, Unsupported() // "Portal_LinkedAnchorLineFloor" // Even more parameterized linedefs -/* - 362: "Pillar_Build" - 363: "Pillar_BuildAndCrush" - 364: "Pillar_Open" - 365: "ACS_Execute" - 366: "ACS_Suspend" - 367: "ACS_Terminate" - 368: "Light_RaiseByValue" - 369: "Light_LowerByValue" - 370: "Light_ChangeToValue" - 371: "Light_Fade" - 372: "Light_Glow" - 373: "Light_Flicker" - 374: "Light_Strobe" - 375: "Radius_Quake" -*/ +362 = 0, Pillar_Build(0) +363 = 0, Pillar_BuildAndCrush(0) +364 = 0, Pillar_Open(0) +365 = 0, ACS_Execute(0) +366 = 0, ACS_Suspend(0) +367 = 0, ACS_Terminate(0) +368 = 0, Light_RaiseByValue(0) +369 = 0, Light_LowerByValue(0) +370 = 0, Light_ChangeToValue(0) +371 = 0, Light_Fade(0) +372 = 0, Light_Glow(0) +373 = 0, Light_Flicker(0) +374 = 0, Light_Strobe(0) +375 = 0, Radius_Quake(0) // Eternity's linked portals, horizontal link version (wall-to-wall) 376 = 0, Unsupported() // "Portal_LinkedLineToLine" @@ -186,7 +181,21 @@ define Unsupported (0) 396 = 0, Plane_Copy(tag, tag)// "Slope_FrontFloorAndCeilingToTaggedSlope" // Last parameterized linedefs -// 397 = Floor_Waggle -// 398 = Thing_Spawn -// 399 = Thing_SpawnNoFog -// 400 = Teleport_EndGame +397 = 0, Floor_Waggle(0) +398 = 0, Thing_Spawn(0) +399 = 0, Thing_SpawnNoFog(0) +400 = 0, Teleport_EndGame(0) + +402 = 0, Thing_Projectile(0) +403 = 0, Thing_ProjectileGravity(0) +404 = 0, Thing_Activate(0) +405 = 0, Thing_Deactivate(0) +410 = 0, Plat_PerpetualRaise(0) +411 = 0, Plat_Stop(0) +412 = 0, Plat_DownWaitUpStay(0) +413 = 0, Plat_DownByValue(0) +414 = 0, Plat_UpWaitDownStay(0) +415 = 0, Plat_UpByValue(0) +416 = 0, Floor_LowerToHighest(0) +420 = 0, ACS_ExecuteWithResult(0) +421 = 0, Thing_ChangeTID(0) From feeaf29c461d77c1e28ae9e9f5e920686ed1ab33 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Jan 2016 22:20:01 +0100 Subject: [PATCH 0345/1509] - set translations for Eternity's linked portals for testing. --- wadsrc/static/xlat/eternity.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wadsrc/static/xlat/eternity.txt b/wadsrc/static/xlat/eternity.txt index fe88e5cde..d1cb400f5 100644 --- a/wadsrc/static/xlat/eternity.txt +++ b/wadsrc/static/xlat/eternity.txt @@ -125,11 +125,11 @@ define Unsupported (0) 356 = 0, Polyobj_RotateLeft(0) 357 = 0, Polyobj_OR_RotateLeft(0) -// Eternity's linked portals, vertical link version (floor-to-ceiling) -358 = 0, Unsupported() // "Portal_LinkedCeiling" -359 = 0, Unsupported() // "Portal_LinkedFloor" -360 = 0, Unsupported() // "Portal_LinkedAnchorLine" -361 = 0, Unsupported() // "Portal_LinkedAnchorLineFloor" +// Eternity's linked portals, vertical link version (floor-to-ceiling) (NOTE: Type needs changing!) +358 = 0, Sector_SetPortal(tag, 0, 1, 1, 0) // "Portal_AnchoredCeiling" +359 = 0, Sector_SetPortal(tag, 0, 0, 1, 0) // "Portal_AnchoredFloor" +360 = 0, Sector_SetPortal(tag, 0, 1, 0, 0) // "Portal_AnchorLine" +361 = 0, Sector_SetPortal(tag, 0, 0, 0, 0) // "Portal_AnchorLineFloor" // Even more parameterized linedefs 362 = 0, Pillar_Build(0) From 4fd0a726b1fe76ca35fefc3d154e05b5e66cfd81 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 9 Jan 2016 00:58:13 +0100 Subject: [PATCH 0346/1509] - more work on EDF handling. Vaporware demo is now loading. --- src/edf.cpp | 222 +++++++++++++++++++---------- src/g_doomedmap.cpp | 1 + src/info.h | 1 + src/p_lnspec.h | 2 + src/p_setup.cpp | 74 ++++++---- src/p_tags.cpp | 22 +++ src/p_tags.h | 1 + wadsrc/static/mapinfo/eternity.txt | 8 ++ wadsrc/static/xlat/eternity.txt | 15 +- 9 files changed, 246 insertions(+), 100 deletions(-) create mode 100644 wadsrc/static/mapinfo/eternity.txt diff --git a/src/edf.cpp b/src/edf.cpp index 05c66ee8b..439cd542d 100644 --- a/src/edf.cpp +++ b/src/edf.cpp @@ -30,6 +30,8 @@ ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** +** This code was written based on the documentation in the Eternity Wiki +** */ #include "w_wad.h" @@ -42,6 +44,8 @@ #include "info.h" #include "p_lnspec.h" #include "p_setup.h" +#include "p_tags.h" +#include "r_data/colormaps.h" struct FEdfOptions : public FOptionalMapinfoData @@ -116,22 +120,23 @@ struct EDFSector int damageamount; int damageinterval; FNameNoInit damagetype; + FNameNoInit floorterrain; + + DWORD color; - // These do not represent any of ZDoom's features. They are maintained like this so that the Add and Remove versions work as intended. DWORD damageflags; DWORD damageflagsAdd; DWORD damageflagsRemove; - // floorterrain (Type TBD) - // ceilingterrain is ignored - // colormaptop/mid/bottom need to be translated into color values (the colormap implementation in Eternity is not the same as in Boom!) + // colormaptop//bottom cannot be used because ZDoom has no corresponding properties. FTransform planexform[2]; DWORD portalflags[2]; fixed_t overlayalpha[2]; }; +static FString EDFMap; static TMap EDFLines; static TMap EDFSectors; static TMap EDFThings; @@ -139,14 +144,15 @@ static TMap EDFThings; static void parseLinedef(FScanner &sc) { + EDFLinedef ld; + bool argsset = false; + + memset(&ld, 0, sizeof(ld)); + ld.alpha = FRACUNIT; + sc.MustGetStringName("{"); while (!sc.CheckString("}")) { - EDFLinedef ld; - bool argsset = false; - - memset(&ld, 0, sizeof(ld)); - ld.alpha = FRACUNIT; sc.MustGetString(); if (sc.Compare("recordnum")) { @@ -173,7 +179,7 @@ static void parseLinedef(FScanner &sc) { // Oh joy, this is going to be fun... // Here we cannot do anything because we need the tag to make this work. - // For now just store a negative number. + // For now just store a negative number and resolve this later. ld.special = -sc.Number; } else @@ -187,11 +193,12 @@ static void parseLinedef(FScanner &sc) sc.CheckString("="); sc.MustGetStringName("{"); int c = 0; - while (!sc.CheckString("}")) + while (true) { sc.MustGetNumber(); ld.args[c++] = sc.Number; - + if (sc.CheckString("}")) break; + sc.MustGetStringName(","); } argsset = true; } @@ -201,13 +208,14 @@ static void parseLinedef(FScanner &sc) sc.MustGetFloat(); ld.alpha = FLOAT2FIXED(sc.Float); } - else if (sc.Compare("options")) + else if (sc.Compare("extflags")) { // these are needed to build the proper activation mask out of the possible flags which do not match ZDoom 1:1. DWORD actmethod = 0; DWORD acttype = 0; do { + sc.CheckString("="); sc.MustGetString(); for (const char *tok = strtok(sc.String, ",+ \t"); tok != NULL; tok = strtok(NULL, ",+ \t")) { @@ -235,29 +243,33 @@ static void parseLinedef(FScanner &sc) { sc.ScriptError("Unknown property '%s'", sc.String); } - if (ld.tag == 0) ld.tag = ld.id; // urgh... - if (ld.special < 0) // translate numeric specials. - { - line_t line; - maplinedef_t mld; - mld.special = -ld.special; - mld.tag = ld.tag; - P_TranslateLineDef(&line, &mld); - ld.special = line.special; - if (!argsset) memcpy(ld.args, line.args, sizeof(ld.args)); - } } + if (ld.tag == 0) ld.tag = ld.id; // urgh... + if (ld.special < 0) // translate numeric specials. + { + line_t line; + maplinedef_t mld; + mld.special = -ld.special; + mld.tag = ld.tag; + P_TranslateLineDef(&line, &mld); + ld.special = line.special; + ld.activation = line.activation; + ld.flags = (ld.flags & ~(ML_REPEAT_SPECIAL | ML_FIRSTSIDEONLY)) | (line.flags & (ML_REPEAT_SPECIAL | ML_FIRSTSIDEONLY)); + if (!argsset) memcpy(ld.args, line.args, sizeof(ld.args)); + } + EDFLines[ld.recordnum] = ld; } static void parseSector(FScanner &sc) { + EDFSector sec; + + memset(&sec, 0, sizeof(sec)); + sec.overlayalpha[sector_t::floor] = sec.overlayalpha[sector_t::ceiling] = FRACUNIT; + sc.MustGetStringName("{"); while (!sc.CheckString("}")) { - EDFSector sec; - - memset(&sec, 0, sizeof(sec)); - sec.overlayalpha[sector_t::floor] = sec.overlayalpha[sector_t::ceiling] = FRACUNIT; sc.MustGetString(); if (sc.Compare("recordnum")) { @@ -288,6 +300,7 @@ static void parseSector(FScanner &sc) { flagvar = &sec.flags; } + sc.CheckString("="); do { sc.MustGetString(); @@ -337,6 +350,7 @@ static void parseSector(FScanner &sc) { flagvar = &sec.damageflags; } + sc.CheckString("="); do { sc.MustGetString(); @@ -355,7 +369,8 @@ static void parseSector(FScanner &sc) { sc.CheckString("="); sc.MustGetString(); - // ZDoom does not implement this yet. + sec.floorterrain = sc.String; // Todo: ZDoom does not implement this yet. + } else if (sc.Compare("floorangle")) { @@ -393,17 +408,23 @@ static void parseSector(FScanner &sc) sc.MustGetFloat(); sec.planexform[sector_t::ceiling].yoffs = FLOAT2FIXED(sc.Float); } - else if (sc.Compare("colormaptop") || sc.Compare("colormapbottom")) + else if (sc.Compare("colormaptop") || sc.Compare("colormapbottom") || sc.Compare("ceilingterrain")) { sc.CheckString("="); sc.MustGetString(); - // not implemented by ZDoom + // these properties are not implemented by ZDoom } else if (sc.Compare("colormapmid")) { sc.CheckString("="); sc.MustGetString(); - // the colormap should be analyzed and converted into an RGB color value. + // Eternity is based on SMMU and uses colormaps differently than all other ports. + // The only solution here is to convert the colormap to an RGB value and set it as the sector's color. + DWORD cmap = R_ColormapNumForName(sc.String); + if (cmap != 0) + { + sec.color = R_BlendForColormap(cmap) & 0xff000000; + } } else if (sc.Compare("overlayalpha")) { @@ -411,12 +432,16 @@ static void parseSector(FScanner &sc) sc.MustGetString(); if (sc.Compare("floor")) { - sc.MustGetFloat(); + sc.MustGetNumber(); + if (sc.CheckString("%")) sc.Float = sc.Number / 100.f; + else sc.Float = sc.Number / 255.f; sec.overlayalpha[sector_t::floor] = FLOAT2FIXED(sc.Float); } else if (sc.Compare("ceiling")) { sc.MustGetFloat(); + if (sc.CheckString("%")) sc.Float = sc.Number / 100.f; + else sc.Float = sc.Number / 255.f; sec.overlayalpha[sector_t::floor] = FLOAT2FIXED(sc.Float); } } @@ -429,6 +454,7 @@ static void parseSector(FScanner &sc) else if (sc.Compare("ceiling")) dest = sector_t::ceiling; else sc.ScriptError("Unknown portal type '%s'", sc.String); + sc.CheckString("="); do { sc.MustGetString(); @@ -450,17 +476,19 @@ static void parseSector(FScanner &sc) sc.ScriptError("Unknown property '%s'", sc.String); } } + EDFSectors[sec.recordnum] = sec; } static void parseMapthing(FScanner &sc) { + EDFMapthing mt; + + memset(&mt, 0, sizeof(mt)); + mt.flags |= MTF_SINGLE | MTF_COOPERATIVE | MTF_DEATHMATCH; // EDF uses inverse logic, like Doom.exe + sc.MustGetStringName("{"); while (!sc.CheckString("}")) { - EDFMapthing mt; - - memset(&mt, 0, sizeof(mt)); - mt.flags |= MTF_SINGLE | MTF_COOPERATIVE | MTF_DEATHMATCH; // EDF uses inverse logic, like Doom.exe sc.MustGetString(); if (sc.Compare("recordnum")) { @@ -505,7 +533,8 @@ static void parseMapthing(FScanner &sc) } else { - //Let's hope not something internal to Eternity... + // Let's hope this isn't an internal Eternity name. + // If so, a name mapping needs to be defined... sc.ScriptError("Unknown type '%s'", sc.String); } @@ -531,6 +560,7 @@ static void parseMapthing(FScanner &sc) } else if (sc.Compare("options")) { + sc.CheckString("="); do { sc.MustGetString(); @@ -554,54 +584,98 @@ static void parseMapthing(FScanner &sc) sc.ScriptError("Unknown property '%s'", sc.String); } } + EDFThings[mt.recordnum] = mt; } -void loadEDF() +void InitEDF() { FString filename; FScanner sc; - EDFLines.Clear(); - EDFSectors.Clear(); - EDFThings.Clear(); - - const char *arg = Args->CheckValue("-edf"); - - if (arg != NULL) filename = arg; - else + if (EDFMap.CompareNoCase(level.MapName) != 0) { - FEdfOptions *opt = level.info->GetOptData("EDF", false); - if (opt != NULL) - { - filename = opt->edfName; - } - } + EDFLines.Clear(); + EDFSectors.Clear(); + EDFThings.Clear(); + EDFMap = level.MapName; - if (filename.IsEmpty()) return; - int lump = Wads.CheckNumForFullName(filename, true, ns_global); - if (lump == -1) return; - sc.OpenLumpNum(lump); + const char *arg = Args->CheckValue("-edf"); - sc.SetCMode(true); - while (sc.GetString()) - { - if (sc.Compare("linedef")) - { - parseLinedef(sc); - } - else if (sc.Compare("mapthing")) - { - parseMapthing(sc); - } - else if (sc.Compare("sector")) - { - parseSector(sc); - } + if (arg != NULL) filename = arg; else { - sc.ScriptError("Unknown keyword '%s'", sc.String); + FEdfOptions *opt = level.info->GetOptData("EDF", false); + if (opt != NULL) + { + filename = opt->edfName; + } + } + + if (filename.IsEmpty()) return; + int lump = Wads.CheckNumForFullName(filename, true, ns_global); + if (lump == -1) return; + sc.OpenLumpNum(lump); + + sc.SetCMode(true); + while (sc.GetString()) + { + if (sc.Compare("linedef")) + { + parseLinedef(sc); + } + else if (sc.Compare("mapthing")) + { + parseMapthing(sc); + } + else if (sc.Compare("sector")) + { + parseSector(sc); + } + else + { + sc.ScriptError("Unknown keyword '%s'", sc.String); + } } } +} +void ProcessEDFMapthing(FMapThing *mt, int recordnum) +{ + InitEDF(); + + EDFMapthing *emt = EDFThings.CheckKey(recordnum); + if (emt == NULL) + { + Printf("EDF Mapthing record %d not found\n", recordnum); + mt->EdNum = 0; + return; + } + mt->thingid = emt->tid; + mt->EdNum = emt->type; + mt->info = DoomEdMap.CheckKey(mt->EdNum); + mt->z = emt->height; + memcpy(mt->args, emt->args, sizeof(mt->args)); + mt->SkillFilter = emt->skillfilter; + mt->flags = emt->flags; +} + +void ProcessEDFLinedef(line_t *ld, int recordnum) +{ + InitEDF(); + + EDFLinedef *eld = EDFLines.CheckKey(recordnum); + if (eld == NULL) + { + Printf("EDF Linedef record %d not found\n", recordnum); + ld->special = 0; + return; + } + const DWORD fmask = ML_REPEAT_SPECIAL | ML_FIRSTSIDEONLY | ML_ADDTRANS | ML_BLOCKEVERYTHING | ML_ZONEBOUNDARY | ML_CLIP_MIDTEX; + ld->special = eld->special; + ld->activation = eld->activation; + ld->flags = (ld->flags&~fmask) | eld->flags; + ld->Alpha = eld->alpha; + memcpy(ld->args, eld->args, sizeof(ld->args)); + tagManager.AddLineID(int(ld - lines), eld->tag); +} -} \ No newline at end of file diff --git a/src/g_doomedmap.cpp b/src/g_doomedmap.cpp index 42157101d..9a2cc137d 100644 --- a/src/g_doomedmap.cpp +++ b/src/g_doomedmap.cpp @@ -69,6 +69,7 @@ const char *SpecialMapthingNames[] = { "$CopyCeilingPlane", "$VertexFloorZ", "$VertexCeilingZ", + "$EDFThing", }; //========================================================================== diff --git a/src/info.h b/src/info.h index 22e3b2f5c..cd32f2f1b 100644 --- a/src/info.h +++ b/src/info.h @@ -313,6 +313,7 @@ enum ESpecialMapthings SMT_CopyCeilingPlane, SMT_VertexFloorZ, SMT_VertexCeilingZ, + SMT_EDFThing, }; diff --git a/src/p_lnspec.h b/src/p_lnspec.h index 9fb4c17b3..3f97c75e6 100644 --- a/src/p_lnspec.h +++ b/src/p_lnspec.h @@ -60,6 +60,8 @@ typedef enum { Init_Damage = 2, Init_SectorLink = 3, NUM_STATIC_INITS, + Init_EDFSector = 253, + Init_EDFLine = 254, Init_TransferSky = 255 } staticinit_t; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 3749e97aa..6bbb85035 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -68,6 +68,9 @@ #include "po_man.h" #include "r_renderer.h" #include "r_data/colormaps.h" +#ifndef NO_EDF +#include "edf.h" +#endif #include "fragglescript/t_fs.h" @@ -1759,34 +1762,45 @@ void P_LoadThings (MapData * map) mti[i].alpha = -1; mti[i].health = 1; mti[i].FloatbobPhase = -1; - flags &= ~MTF_SKILLMASK; - mti[i].flags = (short)((flags & 0xf) | 0x7e0); - if (gameinfo.gametype == GAME_Strife) - { - mti[i].flags &= ~MTF_AMBUSH; - if (flags & STF_SHADOW) mti[i].flags |= MTF_SHADOW; - if (flags & STF_ALTSHADOW) mti[i].flags |= MTF_ALTSHADOW; - if (flags & STF_STANDSTILL) mti[i].flags |= MTF_STANDSTILL; - if (flags & STF_AMBUSH) mti[i].flags |= MTF_AMBUSH; - if (flags & STF_FRIENDLY) mti[i].flags |= MTF_FRIENDLY; - } - else - { - if (flags & BTF_BADEDITORCHECK) - { - flags &= 0x1F; - } - if (flags & BTF_NOTDEATHMATCH) mti[i].flags &= ~MTF_DEATHMATCH; - if (flags & BTF_NOTCOOPERATIVE) mti[i].flags &= ~MTF_COOPERATIVE; - if (flags & BTF_FRIENDLY) mti[i].flags |= MTF_FRIENDLY; - } - if (flags & BTF_NOTSINGLE) mti[i].flags &= ~MTF_SINGLE; mti[i].x = LittleShort(mt->x) << FRACBITS; mti[i].y = LittleShort(mt->y) << FRACBITS; mti[i].angle = LittleShort(mt->angle); mti[i].EdNum = LittleShort(mt->type); mti[i].info = DoomEdMap.CheckKey(mti[i].EdNum); + + +#ifndef NO_EDF + if (mti[i].info != NULL && mti[i].info->Special == SMT_EDFThing) + { + ProcessEDFMapthing(&mti[i], flags); + } + else +#endif + { + flags &= ~MTF_SKILLMASK; + mti[i].flags = (short)((flags & 0xf) | 0x7e0); + if (gameinfo.gametype == GAME_Strife) + { + mti[i].flags &= ~MTF_AMBUSH; + if (flags & STF_SHADOW) mti[i].flags |= MTF_SHADOW; + if (flags & STF_ALTSHADOW) mti[i].flags |= MTF_ALTSHADOW; + if (flags & STF_STANDSTILL) mti[i].flags |= MTF_STANDSTILL; + if (flags & STF_AMBUSH) mti[i].flags |= MTF_AMBUSH; + if (flags & STF_FRIENDLY) mti[i].flags |= MTF_FRIENDLY; + } + else + { + if (flags & BTF_BADEDITORCHECK) + { + flags &= 0x1F; + } + if (flags & BTF_NOTDEATHMATCH) mti[i].flags &= ~MTF_DEATHMATCH; + if (flags & BTF_NOTCOOPERATIVE) mti[i].flags &= ~MTF_COOPERATIVE; + if (flags & BTF_FRIENDLY) mti[i].flags |= MTF_FRIENDLY; + } + if (flags & BTF_NOTSINGLE) mti[i].flags &= ~MTF_SINGLE; + } } delete [] mtp; } @@ -2157,7 +2171,19 @@ void P_LoadLineDefs (MapData * map) // [RH] Translate old linedef special and flags to be // compatible with the new format. - P_TranslateLineDef (ld, mld, i); + + P_TranslateLineDef (ld, mld, -1); + // do not assign the tag for EDF lines. + if (ld->special != Static_Init || (ld->args[1] != Init_EDFLine && ld->args[1] != Init_EDFSector)) + { + tagManager.AddLineID(i, mld->tag); + } +#ifndef NO_EDF + if (ld->special == Static_Init && ld->args[1] == Init_EDFLine) + { + ProcessEDFLinedef(ld, mld->tag); + } +#endif ld->v1 = &vertexes[LittleShort(mld->v1)]; ld->v2 = &vertexes[LittleShort(mld->v2)]; @@ -3325,7 +3351,7 @@ void P_LoadBehavior (MapData * map) void P_GetPolySpots (MapData * map, TArray &spots, TArray &anchors) { - if (map->HasBehavior) + //if (map->HasBehavior) { for (unsigned int i = 0; i < MapThingsConverted.Size(); ++i) { diff --git a/src/p_tags.cpp b/src/p_tags.cpp index 15528378b..50e5694a3 100644 --- a/src/p_tags.cpp +++ b/src/p_tags.cpp @@ -118,6 +118,28 @@ void FTagManager::RemoveSectorTags(int sect) // //----------------------------------------------------------------------------- +void FTagManager::RemoveLineIDs(int sect) +{ + if (startForLine.Size() > (unsigned int)sect) + { + int start = startForLine[sect]; + if (start >= 0) + { + while (allIDs[start].target == sect) + { + allIDs[start].tag = allIDs[start].target = -1; + start++; + } + } + } +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + void FTagManager::AddLineID(int line, int tag) { if (tag == -1) return; // For line IDs -1 means 'not set', unlike sectors. diff --git a/src/p_tags.h b/src/p_tags.h index c3162d9b5..e196600a6 100644 --- a/src/p_tags.h +++ b/src/p_tags.h @@ -64,6 +64,7 @@ public: void AddSectorTag(int sector, int tag); void AddLineID(int line, int tag); void RemoveSectorTags(int sect); + void RemoveLineIDs(int sect); void DumpTags(); }; diff --git a/wadsrc/static/mapinfo/eternity.txt b/wadsrc/static/mapinfo/eternity.txt new file mode 100644 index 000000000..ad0bab886 --- /dev/null +++ b/wadsrc/static/mapinfo/eternity.txt @@ -0,0 +1,8 @@ +// This should be included by any converted Eternity project so set the DoomEdNums that conflict with regular ZDoom get set. + +DoomEdNums +{ + 5003 = none + 5004 = "$EDFThing" +} + diff --git a/wadsrc/static/xlat/eternity.txt b/wadsrc/static/xlat/eternity.txt index d1cb400f5..02fbc0303 100644 --- a/wadsrc/static/xlat/eternity.txt +++ b/wadsrc/static/xlat/eternity.txt @@ -8,11 +8,18 @@ define Unsupported (0) +enum +{ + Init_EDFSector = 253, + Init_EDFLine = 254 +} + // The tag for such a line is actually a key to find, in an ExtraData lump // indicated for the current level by the EMAPINFO lump, what line special // to actually use. This is how parameterized linedefs are used by Eternity -// in the Doom format. "xlating" this would thus be quite complicated... -270 = 0, Unsupported() // "ExtraDataSpecial" +// in the Doom format. + +270 = 0, Static_Init(tag, Init_EDFLine) // "ExtraDataSpecial" // These two are standard MBF specials, no need to redefine them, they're in xlat/doom.txt // 271 = 0, Static_Init (tag, Init_TransferSky, 0) @@ -62,6 +69,7 @@ define Unsupported (0) // Hexen format is incomplete; and Quasar wants to use ZDoom-compatible special values for UDMF. // The translation here is for the odd EDF that specifies them as numbers. +/* 300 = 0, Door_Raise(0) 301 = 0, Door_Open(0) 302 = 0, Door_Close(0) @@ -106,6 +114,7 @@ define Unsupported (0) 341 = 0, Stairs_BuildDownDoom(0) 342 = 0, Stairs_BuildUpDoomSync(0) 343 = 0, Stairs_BuildDownDoomSync(0) +*/ // Two-way portals are not supported yet either 344 = 0, Unsupported() // "Portal_TwowayCeiling" @@ -186,6 +195,8 @@ define Unsupported (0) 399 = 0, Thing_SpawnNoFog(0) 400 = 0, Teleport_EndGame(0) +401 = 0, Static_Init(tag, Init_EDFSector) + 402 = 0, Thing_Projectile(0) 403 = 0, Thing_ProjectileGravity(0) 404 = 0, Thing_Activate(0) From d0978d07602307e5523989dd7302cbd7c6c9dbb8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 10 Jan 2016 09:52:02 +0100 Subject: [PATCH 0347/1509] - added EDF sector handling. --- src/edf.cpp | 120 +++++++++++++++++++++++++++++++++++++++++++------ src/p_spec.cpp | 9 +++- src/r_defs.h | 6 +++ 3 files changed, 120 insertions(+), 15 deletions(-) diff --git a/src/edf.cpp b/src/edf.cpp index 439cd542d..3676e445c 100644 --- a/src/edf.cpp +++ b/src/edf.cpp @@ -45,6 +45,8 @@ #include "p_lnspec.h" #include "p_setup.h" #include "p_tags.h" +#include "p_terrain.h" +#include "v_palette.h" #include "r_data/colormaps.h" @@ -120,7 +122,11 @@ struct EDFSector int damageamount; int damageinterval; FNameNoInit damagetype; - FNameNoInit floorterrain; + BYTE leaky; + BYTE leakyadd; + BYTE leakyremove; + int floorterrain; + int ceilingterrain; DWORD color; @@ -128,7 +134,10 @@ struct EDFSector DWORD damageflagsAdd; DWORD damageflagsRemove; - // ceilingterrain is ignored + bool flagsSet; + bool damageflagsSet; + bool colorSet; + // colormaptop//bottom cannot be used because ZDoom has no corresponding properties. FTransform planexform[2]; @@ -266,6 +275,7 @@ static void parseSector(FScanner &sc) memset(&sec, 0, sizeof(sec)); sec.overlayalpha[sector_t::floor] = sec.overlayalpha[sector_t::ceiling] = FRACUNIT; + sec.floorterrain = sec.ceilingterrain = -1; sc.MustGetStringName("{"); while (!sc.CheckString("}")) @@ -298,6 +308,7 @@ static void parseSector(FScanner &sc) } else { + sec.flagsSet = true; flagvar = &sec.flags; } sc.CheckString("="); @@ -306,7 +317,7 @@ static void parseSector(FScanner &sc) sc.MustGetString(); for (const char *tok = strtok(sc.String, ",+ \t"); tok != NULL; tok = strtok(NULL, ",+ \t")) { - if (!stricmp(tok, "SECRET")) *flagvar |= SECF_SECRET; + if (!stricmp(tok, "SECRET")) *flagvar |= SECF_SECRET | SECF_WASSECRET; else if (!stricmp(tok, "FRICTION")) *flagvar |= SECF_FRICTION; else if (!stricmp(tok, "PUSH")) *flagvar |= SECF_PUSH; else if (!stricmp(tok, "KILLSOUND")) *flagvar |= SECF_SILENT; @@ -330,16 +341,19 @@ static void parseSector(FScanner &sc) else if (sc.Compare("damageflags")) { DWORD *flagvar = NULL; + BYTE *leakvar = NULL; if (sc.CheckString(".")) { sc.MustGetString(); if (sc.Compare("add")) { flagvar = &sec.damageflagsAdd; + leakvar = &sec.leakyadd; } else if (sc.Compare("remove")) { flagvar = &sec.damageflagsRemove; + leakvar = &sec.leakyremove; } else { @@ -348,7 +362,9 @@ static void parseSector(FScanner &sc) } else { + sec.damageflagsSet = true; flagvar = &sec.damageflags; + leakvar = &sec.leaky; } sc.CheckString("="); do @@ -356,8 +372,8 @@ static void parseSector(FScanner &sc) sc.MustGetString(); for (const char *tok = strtok(sc.String, ",+ \t"); tok != NULL; tok = strtok(NULL, ",+ \t")) { - if (!stricmp(tok, "LEAKYSUIT")) *flagvar |= 1; - else if (!stricmp(tok, "IGNORESUIT")) *flagvar |= 2; // these first 2 bits will be used to set 'leakychance', but this can only be done when the sector gets initialized + if (!stricmp(tok, "LEAKYSUIT")) *leakvar |= 1; + else if (!stricmp(tok, "IGNORESUIT")) *leakvar |= 2; // these 2 bits will be used to set 'leakychance', but this can only be done when the sector gets initialized else if (!stricmp(tok, "ENDGODMODE")) *flagvar |= SECF_ENDGODMODE; else if (!stricmp(tok, "ENDLEVEL")) *flagvar |= SECF_ENDLEVEL; else if (!stricmp(tok, "TERRAINHIT")) *flagvar |= SECF_DMGTERRAINFX; @@ -369,8 +385,7 @@ static void parseSector(FScanner &sc) { sc.CheckString("="); sc.MustGetString(); - sec.floorterrain = sc.String; // Todo: ZDoom does not implement this yet. - + sec.floorterrain = P_FindTerrain(sc.String); } else if (sc.Compare("floorangle")) { @@ -390,6 +405,12 @@ static void parseSector(FScanner &sc) sc.MustGetFloat(); sec.planexform[sector_t::floor].yoffs = FLOAT2FIXED(sc.Float); } + else if (sc.Compare("ceilingterrain")) + { + sc.CheckString("="); + sc.MustGetString(); + sec.ceilingterrain = P_FindTerrain(sc.String); + } else if (sc.Compare("ceilingangle")) { sc.CheckString("="); @@ -408,7 +429,7 @@ static void parseSector(FScanner &sc) sc.MustGetFloat(); sec.planexform[sector_t::ceiling].yoffs = FLOAT2FIXED(sc.Float); } - else if (sc.Compare("colormaptop") || sc.Compare("colormapbottom") || sc.Compare("ceilingterrain")) + else if (sc.Compare("colormaptop") || sc.Compare("colormapbottom")) { sc.CheckString("="); sc.MustGetString(); @@ -424,6 +445,7 @@ static void parseSector(FScanner &sc) if (cmap != 0) { sec.color = R_BlendForColormap(cmap) & 0xff000000; + sec.colorSet = true; } } else if (sc.Compare("overlayalpha")) @@ -460,12 +482,12 @@ static void parseSector(FScanner &sc) sc.MustGetString(); for (const char *tok = strtok(sc.String, ",+ \t"); tok != NULL; tok = strtok(NULL, ",+ \t")) { - if (!stricmp(tok, "DISABLED")) sec.portalflags[dest] |= 0; - else if (!stricmp(tok, "NORENDER")) sec.portalflags[dest] |= 0; - else if (!stricmp(tok, "NOPASS")) sec.portalflags[dest] |= 0; - else if (!stricmp(tok, "BLOCKSOUND")) sec.portalflags[dest] |= 0; - else if (!stricmp(tok, "OVERLAY")) sec.portalflags[dest] |= 0; - else if (!stricmp(tok, "ADDITIVE")) sec.portalflags[dest] |= 0; + if (!stricmp(tok, "DISABLED")) sec.portalflags[dest] |= PLANEF_DISABLED; + else if (!stricmp(tok, "NORENDER")) sec.portalflags[dest] |= PLANEF_NORENDER; + else if (!stricmp(tok, "NOPASS")) sec.portalflags[dest] |= PLANEF_NOPASS; + else if (!stricmp(tok, "BLOCKSOUND")) sec.portalflags[dest] |= PLANEF_BLOCKSOUND; + else if (!stricmp(tok, "OVERLAY")) sec.portalflags[dest] |= 0; // we do not use this. Alpha is the sole determinant for overlay drawing + else if (!stricmp(tok, "ADDITIVE")) sec.portalflags[dest] |= PLANEF_ADDITIVE; else if (!stricmp(tok, "USEGLOBALTEX")) {} // not implemented else sc.ScriptError("Unknown option '%s'", tok); } @@ -679,3 +701,73 @@ void ProcessEDFLinedef(line_t *ld, int recordnum) tagManager.AddLineID(int(ld - lines), eld->tag); } +void ProcessEDFSector(sector_t *sec, int recordnum) +{ + EDFSector *esec = EDFSectors.CheckKey(recordnum); + if (esec == NULL) + { + Printf("EDF Sector record %d not found\n", recordnum); + return; + } + + // In ZDoom the regular and the damage flags are part of the same flag word so we need to do some masking. + const DWORD flagmask = SECF_SECRET | SECF_WASSECRET | SECF_FRICTION | SECF_PUSH | SECF_SILENT | SECF_SILENTMOVE; + if (esec->flagsSet) sec->Flags = (sec->Flags & ~flagmask); + sec->Flags = (sec->Flags | esec->flags | esec->flagsAdd) & ~esec->flagsRemove; + + BYTE leak = 0; + if (esec->damageflagsSet) sec->Flags = (sec->Flags & ~SECF_DAMAGEFLAGS); + else leak = sec->leakydamage >= 256 ? 2 : sec->leakydamage >= 5 ? 1 : 0; + sec->Flags = (sec->Flags | esec->damageflags | esec->damageflagsAdd) & ~esec->damageflagsRemove; + leak = (leak | esec->leaky | esec->leakyadd) & ~esec->leakyremove; + + // the damage properties will be unconditionally overridden by EDF. + sec->leakydamage = leak == 0 ? 0 : leak == 1 ? 5 : 256; + sec->damageamount = esec->damageamount; + sec->damageinterval = esec->damageinterval; + sec->damagetype = esec->damagetype; + + sec->terrainnum[sector_t::floor] = esec->floorterrain; + sec->terrainnum[sector_t::ceiling] = esec->ceilingterrain; + + if (esec->colorSet) sec->SetColor(RPART(esec->color), GPART(esec->color), BPART(esec->color), 0); + + const DWORD pflagmask = PLANEF_DISABLED | PLANEF_NORENDER | PLANEF_NOPASS | PLANEF_BLOCKSOUND | PLANEF_ADDITIVE; + for (int i = 0; i < 2; i++) + { + sec->planes[i].xform.xoffs = esec->planexform[i].xoffs; + sec->planes[i].xform.yoffs = esec->planexform[i].yoffs; + sec->planes[i].xform.angle = esec->planexform[i].angle; + sec->planes[i].alpha = esec->overlayalpha[i]; + sec->planes[i].Flags = (sec->planes[i].Flags & ~pflagmask) | esec->portalflags[i]; + } +} + + +void ProcessEDFSectors() +{ + int i; + + InitEDF(); + if (EDFSectors.CountUsed() == 0) return; // don't waste time if there's no records. + + // collect all EDF sector records up front so we do not need to search the complete line array for each sector separately. + int *edfsectorrecord = new int[numsectors]; + memset(edfsectorrecord, -1, numsectors * sizeof(int)); + for (i = 0; i < numlines; i++) + { + if (lines[i].special == Static_Init && lines[i].args[1] == Init_EDFSector) + { + edfsectorrecord[lines[i].frontsector - sectors] = lines[i].args[0]; + lines[i].special = 0; + } + } + for (i = 0; i < numsectors; i++) + { + if (edfsectorrecord[i] >= 0) + { + ProcessEDFSector(§ors[i], edfsectorrecord[i]); + } + } + delete[] edfsectorrecord; +} \ No newline at end of file diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 1ce505da9..18f6cc26f 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -62,6 +62,9 @@ #include "farchive.h" #include "a_keys.h" #include "c_dispatch.h" +#ifndef NO_EDF +#include "edf.h" +#endif // State. #include "r_state.h" @@ -1313,6 +1316,7 @@ void P_SpawnSpecials (void) // Init special SECTORs. sector = sectors; + for (i = 0; i < numsectors; i++, sector++) { if (sector->special == 0) @@ -1321,7 +1325,10 @@ void P_SpawnSpecials (void) P_InitSectorSpecial(sector, sector->special, false); } - // Here is the place to handle EDF for sectors. +#ifndef NO_EDF + ProcessEDFSectors(); +#endif + // Init other misc stuff diff --git a/src/r_defs.h b/src/r_defs.h index a7e37f369..c05fdf2fc 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -331,6 +331,12 @@ enum PLANEF_ABSLIGHTING = 1, // floor/ceiling light is absolute, not relative PLANEF_BLOCKED = 2, // can not be moved anymore. PLANEF_ADDITIVE = 4, // rendered additive + + // linked portal stuff + PLANEF_NORENDER = 8, + PLANEF_NOPASS = 16, + PLANEF_BLOCKSOUND = 32, + PLANEF_DISABLED = 64, }; // Internal sector flags From 1e193206bf27d6ae79507b4c16109b432bca8159 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 10 Jan 2016 10:08:06 +0100 Subject: [PATCH 0348/1509] - removed unused RemoveLineIDs function. --- src/p_tags.cpp | 22 ---------------------- src/p_tags.h | 1 - 2 files changed, 23 deletions(-) diff --git a/src/p_tags.cpp b/src/p_tags.cpp index 50e5694a3..15528378b 100644 --- a/src/p_tags.cpp +++ b/src/p_tags.cpp @@ -118,28 +118,6 @@ void FTagManager::RemoveSectorTags(int sect) // //----------------------------------------------------------------------------- -void FTagManager::RemoveLineIDs(int sect) -{ - if (startForLine.Size() > (unsigned int)sect) - { - int start = startForLine[sect]; - if (start >= 0) - { - while (allIDs[start].target == sect) - { - allIDs[start].tag = allIDs[start].target = -1; - start++; - } - } - } -} - -//----------------------------------------------------------------------------- -// -// -// -//----------------------------------------------------------------------------- - void FTagManager::AddLineID(int line, int tag) { if (tag == -1) return; // For line IDs -1 means 'not set', unlike sectors. diff --git a/src/p_tags.h b/src/p_tags.h index e196600a6..c3162d9b5 100644 --- a/src/p_tags.h +++ b/src/p_tags.h @@ -64,7 +64,6 @@ public: void AddSectorTag(int sector, int tag); void AddLineID(int line, int tag); void RemoveSectorTags(int sect); - void RemoveLineIDs(int sect); void DumpTags(); }; From 39cdb7cf30d5b6ddbee19c6c968a1da434b85ea0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 10 Jan 2016 10:21:17 +0100 Subject: [PATCH 0349/1509] - implement 'loadacs' option for MAPINFO. --- src/edf.cpp | 13 ++++++++++++- src/p_setup.cpp | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/edf.cpp b/src/edf.cpp index 3676e445c..50ac2835c 100644 --- a/src/edf.cpp +++ b/src/edf.cpp @@ -47,6 +47,7 @@ #include "p_tags.h" #include "p_terrain.h" #include "v_palette.h" +#include "p_acs.h" #include "r_data/colormaps.h" @@ -770,4 +771,14 @@ void ProcessEDFSectors() } } delete[] edfsectorrecord; -} \ No newline at end of file +} + +void LoadMapinfoACSLump() +{ + FEdfOptions *opt = level.info->GetOptData("EDF", false); + if (opt != NULL) + { + int lump = Wads.CheckNumForName(opt->acsName); + if (lump >= 0) FBehavior::StaticLoadModule(lump); + } +} diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 6bbb85035..46f984bf1 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3702,6 +3702,10 @@ void P_SetupLevel (const char *lumpname, int position) } FBehavior::StaticLoadDefaultModules (); +#ifndef NO_EDF + LoadMapinfoACSLump(); +#endif + P_LoadStrifeConversations (map, lumpname); From ef7bcb3a66ed78dd6ee29b0d48403138b4a0e48c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Jan 2016 15:07:58 +0100 Subject: [PATCH 0350/1509] - implement Eternity-Style flat and horizon portals. Not tested yet due to lack of material to work with. --- src/actor.h | 2392 ++++++++++++++++++------------------ src/gl/scene/gl_portal.cpp | 68 +- src/gl/scene/gl_portal.h | 32 +- src/gl/scene/gl_sky.cpp | 130 +- src/gl/scene/gl_walls.cpp | 9 +- src/p_spec.cpp | 54 +- src/r_bsp.cpp | 4 + 7 files changed, 1426 insertions(+), 1263 deletions(-) diff --git a/src/actor.h b/src/actor.h index ecfd700d8..001f4698c 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1,859 +1,859 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// $Id:$ -// -// Copyright (C) 1993-1996 by id Software, Inc. -// -// This source is available for distribution and/or modification -// only under the terms of the DOOM Source Code License as -// published by id Software. All rights reserved. -// -// The source is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License -// for more details. -// -// DESCRIPTION: -// Map Objects, MObj, definition and handling. -// -//----------------------------------------------------------------------------- - - -#ifndef __P_MOBJ_H__ -#define __P_MOBJ_H__ - -// Basics. -#include "tables.h" - -// We need the thinker_t stuff. -#include "dthinker.h" - - -// States are tied to finite states are tied to animation frames. -#include "info.h" - -#include "doomdef.h" -#include "textures/textures.h" -#include "r_data/renderstyle.h" -#include "s_sound.h" -#include "memarena.h" -#include "g_level.h" -#include "tflags.h" - -struct subsector_t; -// -// NOTES: AActor -// -// Actors are used to tell the refresh where to draw an image, -// tell the world simulation when objects are contacted, -// and tell the sound driver how to position a sound. -// -// The refresh uses the next and prev links to follow -// lists of things in sectors as they are being drawn. -// The sprite, frame, and angle elements determine which patch_t -// is used to draw the sprite if it is visible. -// The sprite and frame values are almost always set -// from state_t structures. -// The statescr.exe utility generates the states.h and states.c -// files that contain the sprite/frame numbers from the -// statescr.txt source file. -// The xyz origin point represents a point at the bottom middle -// of the sprite (between the feet of a biped). -// This is the default origin position for patch_ts grabbed -// with lumpy.exe. -// A walking creature will have its z equal to the floor -// it is standing on. -// -// The sound code uses the x,y, and sometimes z fields -// to do stereo positioning of any sound emitted by the actor. -// -// The play simulation uses the blocklinks, x,y,z, radius, height -// to determine when AActors are touching each other, -// touching lines in the map, or hit by trace lines (gunshots, -// lines of sight, etc). -// The AActor->flags element has various bit flags -// used by the simulation. -// -// Every actor is linked into a single sector -// based on its origin coordinates. -// The subsector_t is found with R_PointInSubsector(x,y), -// and the sector_t can be found with subsector->sector. -// The sector links are only used by the rendering code, -// the play simulation does not care about them at all. -// -// Any actor that needs to be acted upon by something else -// in the play world (block movement, be shot, etc) will also -// need to be linked into the blockmap. -// If the thing has the MF_NOBLOCK flag set, it will not use -// the block links. It can still interact with other things, -// but only as the instigator (missiles will run into other -// things, but nothing can run into a missile). -// Each block in the grid is 128*128 units, and knows about -// every line_t that it contains a piece of, and every -// interactable actor that has its origin contained. -// -// A valid actor is an actor that has the proper subsector_t -// filled in for its xy coordinates and is linked into the -// sector from which the subsector was made, or has the -// MF_NOSECTOR flag set (the subsector_t needs to be valid -// even if MF_NOSECTOR is set), and is linked into a blockmap -// block or has the MF_NOBLOCKMAP flag set. -// Links should only be modified by the P_[Un]SetThingPosition() -// functions. -// Do not change the MF_NO* flags while a thing is valid. -// -// Any questions? -// - -// --- mobj.flags --- -enum ActorFlag -{ - MF_SPECIAL = 0x00000001, // call P_SpecialThing when touched - MF_SOLID = 0x00000002, - MF_SHOOTABLE = 0x00000004, - MF_NOSECTOR = 0x00000008, // don't use the sector links - // (invisible but touchable) - MF_NOBLOCKMAP = 0x00000010, // don't use the blocklinks - // (inert but displayable) - MF_AMBUSH = 0x00000020, // not activated by sound; deaf monster - MF_JUSTHIT = 0x00000040, // try to attack right back - MF_JUSTATTACKED = 0x00000080, // take at least one step before attacking - MF_SPAWNCEILING = 0x00000100, // hang from ceiling instead of floor - MF_NOGRAVITY = 0x00000200, // don't apply gravity every tic - -// movement flags - MF_DROPOFF = 0x00000400, // allow jumps from high places - MF_PICKUP = 0x00000800, // for players to pick up items - MF_NOCLIP = 0x00001000, // player cheat - MF_INCHASE = 0x00002000, // [RH] used by A_Chase and A_Look to avoid recursion - MF_FLOAT = 0x00004000, // allow moves to any height, no gravity - MF_TELEPORT = 0x00008000, // don't cross lines or look at heights - MF_MISSILE = 0x00010000, // don't hit same species, explode on block - - MF_DROPPED = 0x00020000, // dropped by a demon, not level spawned - MF_SHADOW = 0x00040000, // actor is hard for monsters to see - MF_NOBLOOD = 0x00080000, // don't bleed when shot (use puff) - MF_CORPSE = 0x00100000, // don't stop moving halfway off a step - MF_INFLOAT = 0x00200000, // floating to a height for a move, don't - // auto float to target's height - MF_INBOUNCE = 0x00200000, // used by Heretic bouncing missiles - - MF_COUNTKILL = 0x00400000, // count towards intermission kill total - MF_COUNTITEM = 0x00800000, // count towards intermission item total - - MF_SKULLFLY = 0x01000000, // skull in flight - MF_NOTDMATCH = 0x02000000, // don't spawn in death match (key cards) - - MF_SPAWNSOUNDSOURCE = 0x04000000, // Plays missile's see sound at spawning object. - MF_FRIENDLY = 0x08000000, // [RH] Friendly monsters for Strife (and MBF) - MF_UNMORPHED = 0x10000000, // [RH] Actor is the unmorphed version of something else - MF_NOLIFTDROP = 0x20000000, // [RH] Used with MF_NOGRAVITY to avoid dropping with lifts - MF_STEALTH = 0x40000000, // [RH] Andy Baker's stealth monsters - MF_ICECORPSE = 0x80000000, // a frozen corpse (for blasting) [RH] was 0x800000 - - // --- dummies for unknown/unimplemented Strife flags --- - MF_STRIFEx8000000 = 0, // seems related to MF_SHADOW -}; - -// --- mobj.flags2 --- -enum ActorFlag2 -{ - MF2_DONTREFLECT = 0x00000001, // this projectile cannot be reflected - MF2_WINDTHRUST = 0x00000002, // gets pushed around by the wind specials - MF2_DONTSEEKINVISIBLE=0x00000004, // For seeker missiles: Don't home in on invisible/shadow targets - MF2_BLASTED = 0x00000008, // actor will temporarily take damage from impact - MF2_FLY = 0x00000010, // fly mode is active - MF2_FLOORCLIP = 0x00000020, // if feet are allowed to be clipped - MF2_SPAWNFLOAT = 0x00000040, // spawn random float z - MF2_NOTELEPORT = 0x00000080, // does not teleport - MF2_RIP = 0x00000100, // missile rips through solid targets - MF2_PUSHABLE = 0x00000200, // can be pushed by other moving actors - MF2_SLIDE = 0x00000400, // slides against walls - MF2_ONMOBJ = 0x00000800, // actor is resting on top of another actor - MF2_PASSMOBJ = 0x00001000, // Enable z block checking. If on, - // this flag will allow the actor to - // pass over/under other actors. - MF2_CANNOTPUSH = 0x00002000, // cannot push other pushable mobjs - MF2_THRUGHOST = 0x00004000, // missile will pass through ghosts [RH] was 8 - MF2_BOSS = 0x00008000, // mobj is a major boss - - MF2_DONTTRANSLATE = 0x00010000, // Don't apply palette translations - MF2_NODMGTHRUST = 0x00020000, // does not thrust target when damaging - MF2_TELESTOMP = 0x00040000, // mobj can stomp another - MF2_FLOATBOB = 0x00080000, // use float bobbing z movement - MF2_THRUACTORS = 0x00100000, // performs no actor<->actor collision checks - MF2_IMPACT = 0x00200000, // an MF_MISSILE mobj can activate SPAC_IMPACT - MF2_PUSHWALL = 0x00400000, // mobj can push walls - MF2_MCROSS = 0x00800000, // can activate monster cross lines - MF2_PCROSS = 0x01000000, // can activate projectile cross lines - MF2_CANTLEAVEFLOORPIC=0x02000000, // stay within a certain floor type - MF2_NONSHOOTABLE = 0x04000000, // mobj is totally non-shootable, - // but still considered solid - MF2_INVULNERABLE = 0x08000000, // mobj is invulnerable - MF2_DORMANT = 0x10000000, // thing is dormant - MF2_ARGSDEFINED = 0x20000000, // Internal flag used by DECORATE to signal that the - // args should not be taken from the mapthing definition - MF2_SEEKERMISSILE = 0x40000000, // is a seeker (for reflection) - MF2_REFLECTIVE = 0x80000000, // reflects missiles -}; - -// --- mobj.flags3 --- -enum ActorFlag3 -{ - MF3_FLOORHUGGER = 0x00000001, // Missile stays on floor - MF3_CEILINGHUGGER = 0x00000002, // Missile stays on ceiling - MF3_NORADIUSDMG = 0x00000004, // Actor does not take radius damage - MF3_GHOST = 0x00000008, // Actor is a ghost - MF3_ALWAYSPUFF = 0x00000010, // Puff always appears, even when hit nothing - MF3_SPECIALFLOORCLIP= 0x00000020, // Actor uses floorclip for special effect (e.g. Wraith) - MF3_DONTSPLASH = 0x00000040, // Thing doesn't make a splash - MF3_NOSIGHTCHECK = 0x00000080, // Go after first acceptable target without checking sight - MF3_DONTOVERLAP = 0x00000100, // Don't pass over/under other things with this bit set - MF3_DONTMORPH = 0x00000200, // Immune to arti_egg - MF3_DONTSQUASH = 0x00000400, // Death ball can't squash this actor - MF3_EXPLOCOUNT = 0x00000800, // Don't explode until special2 counts to special1 - MF3_FULLVOLACTIVE = 0x00001000, // Active sound is played at full volume - MF3_ISMONSTER = 0x00002000, // Actor is a monster - MF3_SKYEXPLODE = 0x00004000, // Explode missile when hitting sky - MF3_STAYMORPHED = 0x00008000, // Monster cannot unmorph - MF3_DONTBLAST = 0x00010000, // Actor cannot be pushed by blasting - MF3_CANBLAST = 0x00020000, // Actor is not a monster but can be blasted - MF3_NOTARGET = 0x00040000, // This actor not targetted when it hurts something else - MF3_DONTGIB = 0x00080000, // Don't gib this corpse - MF3_NOBLOCKMONST = 0x00100000, // Can cross ML_BLOCKMONSTERS lines - MF3_CRASHED = 0x00200000, // Actor entered its crash state - MF3_FULLVOLDEATH = 0x00400000, // DeathSound is played full volume (for missiles) - MF3_AVOIDMELEE = 0x00800000, // Avoids melee attacks (same as MBF's monster_backing but must be explicitly set) - MF3_SCREENSEEKER = 0x01000000, // Fails the IsOkayToAttack test if potential target is outside player FOV - MF3_FOILINVUL = 0x02000000, // Actor can hurt MF2_INVULNERABLE things - MF3_NOTELEOTHER = 0x04000000, // Monster is unaffected by teleport other artifact - MF3_BLOODLESSIMPACT = 0x08000000, // Projectile does not leave blood - MF3_NOEXPLODEFLOOR = 0x10000000, // Missile stops at floor instead of exploding - MF3_WARNBOT = 0x20000000, // Missile warns bot - MF3_PUFFONACTORS = 0x40000000, // Puff appears even when hit bleeding actors - MF3_HUNTPLAYERS = 0x80000000, // Used with TIDtoHate, means to hate players too -}; - -// --- mobj.flags4 --- -enum ActorFlag4 -{ - MF4_NOHATEPLAYERS = 0x00000001, // Ignore player attacks - MF4_QUICKTORETALIATE= 0x00000002, // Always switch targets when hurt - MF4_NOICEDEATH = 0x00000004, // Actor never enters an ice death, not even the generic one - MF4_BOSSDEATH = 0x00000008, // A_FreezeDeathChunks calls A_BossDeath - MF4_RANDOMIZE = 0x00000010, // Missile has random initial tic count - MF4_NOSKIN = 0x00000020, // Player cannot use skins - MF4_FIXMAPTHINGPOS = 0x00000040, // Fix this actor's position when spawned as a map thing - MF4_ACTLIKEBRIDGE = 0x00000080, // Pickups can "stand" on this actor / cannot be moved by any sector action. - MF4_STRIFEDAMAGE = 0x00000100, // Strife projectiles only do up to 4x damage, not 8x - - MF4_CANUSEWALLS = 0x00000200, // Can activate 'use' specials - MF4_MISSILEMORE = 0x00000400, // increases the chance of a missile attack - MF4_MISSILEEVENMORE = 0x00000800, // significantly increases the chance of a missile attack - MF4_FORCERADIUSDMG = 0x00001000, // if put on an object it will override MF3_NORADIUSDMG - MF4_DONTFALL = 0x00002000, // Doesn't have NOGRAVITY disabled when dying. - MF4_SEESDAGGERS = 0x00004000, // This actor can see you striking with a dagger - MF4_INCOMBAT = 0x00008000, // Don't alert others when attacked by a dagger - MF4_LOOKALLAROUND = 0x00010000, // Monster has eyes in the back of its head - MF4_STANDSTILL = 0x00020000, // Monster should not chase targets unless attacked? - MF4_SPECTRAL = 0x00040000, - MF4_SCROLLMOVE = 0x00080000, // velocity has been applied by a scroller - MF4_NOSPLASHALERT = 0x00100000, // Splashes don't alert this monster - MF4_SYNCHRONIZED = 0x00200000, // For actors spawned at load-time only: Do not randomize tics - MF4_NOTARGETSWITCH = 0x00400000, // monster never switches target until current one is dead - MF4_VFRICTION = 0x00800000, // Internal flag used by A_PainAttack to push a monster down - MF4_DONTHARMCLASS = 0x01000000, // Don't hurt one's own kind with explosions (hitscans, too?) - MF4_SHIELDREFLECT = 0x02000000, - MF4_DEFLECT = 0x04000000, // different projectile reflection styles - MF4_ALLOWPARTICLES = 0x08000000, // this puff type can be replaced by particles - MF4_NOEXTREMEDEATH = 0x10000000, // this projectile or weapon never gibs its victim - MF4_EXTREMEDEATH = 0x20000000, // this projectile or weapon always gibs its victim - MF4_FRIGHTENED = 0x40000000, // Monster runs away from player - MF4_BOSSSPAWNED = 0x80000000, // Spawned by a boss spawn cube -}; - -// --- mobj.flags5 --- - -enum ActorFlag5 -{ - MF5_DONTDRAIN = 0x00000001, // cannot be drained health from. - /* = 0x00000002, reserved for use by scripting branch */ - MF5_NODROPOFF = 0x00000004, // cannot drop off under any circumstances. - MF5_NOFORWARDFALL = 0x00000008, // Does not make any actor fall forward by being damaged by this - MF5_COUNTSECRET = 0x00000010, // From Doom 64: actor acts like a secret - MF5_AVOIDINGDROPOFF = 0x00000020, // Used to move monsters away from dropoffs - MF5_NODAMAGE = 0x00000040, // Actor can be shot and reacts to being shot but takes no damage - MF5_CHASEGOAL = 0x00000080, // Walks to goal instead of target if a valid goal is set. - MF5_BLOODSPLATTER = 0x00000100, // Blood splatter like in Raven's games. - MF5_OLDRADIUSDMG = 0x00000200, // Use old radius damage code (for barrels and boss brain) - MF5_DEHEXPLOSION = 0x00000400, // Use the DEHACKED explosion options when this projectile explodes - MF5_PIERCEARMOR = 0x00000800, // Armor doesn't protect against damage from this actor - MF5_NOBLOODDECALS = 0x00001000, // Actor bleeds but doesn't spawn blood decals - MF5_USESPECIAL = 0x00002000, // Actor executes its special when being 'used'. - MF5_NOPAIN = 0x00004000, // If set the pain state won't be entered - MF5_ALWAYSFAST = 0x00008000, // always uses 'fast' attacking logic - MF5_NEVERFAST = 0x00010000, // never uses 'fast' attacking logic - MF5_ALWAYSRESPAWN = 0x00020000, // always respawns, regardless of skill setting - MF5_NEVERRESPAWN = 0x00040000, // never respawns, regardless of skill setting - MF5_DONTRIP = 0x00080000, // Ripping projectiles explode when hitting this actor - MF5_NOINFIGHTING = 0x00100000, // This actor doesn't switch target when it's hurt - MF5_NOINTERACTION = 0x00200000, // Thing is completely excluded from any gameplay related checks - MF5_NOTIMEFREEZE = 0x00400000, // Actor is not affected by time freezer - MF5_PUFFGETSOWNER = 0x00800000, // [BB] Sets the owner of the puff to the player who fired it - MF5_SPECIALFIREDAMAGE=0x01000000, // Special treatment of PhoenixFX1 turned into a flag to remove - // dependence of main engine code of specific actor types. - MF5_SUMMONEDMONSTER = 0x02000000, // To mark the friendly Minotaur. Hopefully to be generalized later. - MF5_NOVERTICALMELEERANGE=0x04000000,// Does not check vertical distance for melee range - MF5_BRIGHT = 0x08000000, // Actor is always rendered fullbright - MF5_CANTSEEK = 0x10000000, // seeker missiles cannot home in on this actor - MF5_INCONVERSATION = 0x20000000, // Actor is having a conversation - MF5_PAINLESS = 0x40000000, // Actor always inflicts painless damage. - MF5_MOVEWITHSECTOR = 0x80000000, // P_ChangeSector() will still process this actor if it has MF_NOBLOCKMAP -}; - -// --- mobj.flags6 --- -enum ActorFlag6 -{ - MF6_NOBOSSRIP = 0x00000001, // For rippermissiles: Don't rip through bosses. - MF6_THRUSPECIES = 0x00000002, // Actors passes through other of the same species. - MF6_MTHRUSPECIES = 0x00000004, // Missile passes through actors of its shooter's species. - MF6_FORCEPAIN = 0x00000008, // forces target into painstate (unless it has the NOPAIN flag) - MF6_NOFEAR = 0x00000010, // Not scared of frightening players - MF6_BUMPSPECIAL = 0x00000020, // Actor executes its special when being collided (as the ST flag) - MF6_DONTHARMSPECIES = 0x00000040, // Don't hurt one's own species with explosions (hitscans, too?) - MF6_STEPMISSILE = 0x00000080, // Missile can "walk" up steps - MF6_NOTELEFRAG = 0x00000100, // [HW] Actor can't be telefragged - MF6_TOUCHY = 0x00000200, // From MBF: killough 11/98: dies when solids touch it - MF6_CANJUMP = 0x00000400, // From MBF: a dedicated flag instead of the BOUNCES+FLOAT+sentient combo - MF6_JUMPDOWN = 0x00000800, // From MBF: generalization of dog behavior wrt. dropoffs. - MF6_VULNERABLE = 0x00001000, // Actor can be damaged (even if not shootable). - MF6_ARMED = 0x00002000, // From MBF: Object is armed (for MF6_TOUCHY objects) - MF6_FALLING = 0x00004000, // From MBF: Object is falling (for pseudotorque simulation) - MF6_LINEDONE = 0x00008000, // From MBF: Object has already run a line effect - MF6_NOTRIGGER = 0x00010000, // actor cannot trigger any line actions - MF6_SHATTERING = 0x00020000, // marks an ice corpse for forced shattering - MF6_KILLED = 0x00040000, // Something that was killed (but not necessarily a corpse) - MF6_BLOCKEDBYSOLIDACTORS = 0x00080000, // Blocked by solid actors, even if not solid itself - MF6_ADDITIVEPOISONDAMAGE = 0x00100000, - MF6_ADDITIVEPOISONDURATION = 0x00200000, - MF6_NOMENU = 0x00400000, // Player class should not appear in the class selection menu. - MF6_BOSSCUBE = 0x00800000, // Actor spawned by A_BrainSpit, flagged for timefreeze reasons. - MF6_SEEINVISIBLE = 0x01000000, // Monsters can see invisible player. - MF6_DONTCORPSE = 0x02000000, // [RC] Don't autoset MF_CORPSE upon death and don't force Crash state change. - MF6_POISONALWAYS = 0x04000000, // Always apply poison, even when target can't take the damage. - MF6_DOHARMSPECIES = 0x08000000, // Do hurt one's own species with projectiles. - MF6_INTRYMOVE = 0x10000000, // Executing P_TryMove - MF6_NOTAUTOAIMED = 0x20000000, // Do not subject actor to player autoaim. - MF6_NOTONAUTOMAP = 0x40000000, // will not be shown on automap with the 'scanner' powerup. - MF6_RELATIVETOFLOOR = 0x80000000, // [RC] Make flying actors be affected by lifts. -}; - -// --- mobj.flags7 --- -enum ActorFlag7 -{ - MF7_NEVERTARGET = 0x00000001, // can not be targetted at all, even if monster friendliness is considered. - MF7_NOTELESTOMP = 0x00000002, // cannot telefrag under any circumstances (even when set by MAPINFO) - MF7_ALWAYSTELEFRAG = 0x00000004, // will unconditionally be telefragged when in the way. Overrides all other settings. - MF7_HANDLENODELAY = 0x00000008, // respect NoDelay state flag - MF7_WEAPONSPAWN = 0x00000010, // subject to DF_NO_COOP_WEAPON_SPAWN dmflag - MF7_HARMFRIENDS = 0x00000020, // is allowed to harm friendly monsters. - MF7_BUDDHA = 0x00000040, // Behaves just like the buddha cheat. - MF7_FOILBUDDHA = 0x00000080, // Similar to FOILINVUL, foils buddha mode. - MF7_DONTTHRUST = 0x00000100, // Thrusting functions do not take, and do not give thrust (damage) to actors with this flag. - MF7_ALLOWPAIN = 0x00000200, // Invulnerable or immune (via damagefactors) actors can still react to taking damage even if they don't. - MF7_CAUSEPAIN = 0x00000400, // Damage sources with this flag can cause similar effects like ALLOWPAIN. - MF7_THRUREFLECT = 0x00000800, // Actors who are reflective cause the missiles to not slow down or change angles. - MF7_MIRRORREFLECT = 0x00001000, // Actor is turned directly 180 degrees around when reflected. - MF7_AIMREFLECT = 0x00002000, // Actor is directly reflected straight back at the one who fired the projectile. - MF7_HITTARGET = 0x00004000, // The actor the projectile dies on is set to target, provided it's targetable anyway. - MF7_HITMASTER = 0x00008000, // Same as HITTARGET, except it's master instead of target. - MF7_HITTRACER = 0x00010000, // Same as HITTARGET, but for tracer. - MF7_FLYCHEAT = 0x00020000, // must be part of the actor so that it can be tracked properly - MF7_NODECAL = 0x00040000, // [ZK] Forces puff to have no impact decal - MF7_FORCEDECAL = 0x00080000, // [ZK] Forces puff's decal to override the weapon's. - MF7_LAXTELEFRAGDMG = 0x00100000, // [MC] Telefrag damage can be reduced. - MF7_ICESHATTER = 0x00200000, // [MC] Shatters ice corpses regardless of damagetype. -}; - -// --- mobj.renderflags --- -enum ActorRenderFlag -{ - RF_XFLIP = 0x0001, // Flip sprite horizontally - RF_YFLIP = 0x0002, // Flip sprite vertically - RF_ONESIDED = 0x0004, // Wall/floor sprite is visible from front only - RF_FULLBRIGHT = 0x0010, // Sprite is drawn at full brightness - - RF_RELMASK = 0x0300, // ---Relative z-coord for bound actors (these obey texture pegging) - RF_RELABSOLUTE = 0x0000, // Actor z is absolute - RF_RELUPPER = 0x0100, // Actor z is relative to upper part of wall - RF_RELLOWER = 0x0200, // Actor z is relative to lower part of wall - RF_RELMID = 0x0300, // Actor z is relative to middle part of wall - - RF_CLIPMASK = 0x0c00, // ---Clipping for bound actors - RF_CLIPFULL = 0x0000, // Clip sprite to full height of wall - RF_CLIPUPPER = 0x0400, // Clip sprite to upper part of wall - RF_CLIPMID = 0x0800, // Clip sprite to mid part of wall - RF_CLIPLOWER = 0x0c00, // Clip sprite to lower part of wall - - RF_DECALMASK = RF_RELMASK|RF_CLIPMASK, - - RF_SPRITETYPEMASK = 0x7000, // ---Different sprite types, not all implemented - RF_FACESPRITE = 0x0000, // Face sprite - RF_WALLSPRITE = 0x1000, // Wall sprite - RF_FLOORSPRITE = 0x2000, // Floor sprite - RF_VOXELSPRITE = 0x3000, // Voxel object - RF_INVISIBLE = 0x8000, // Don't bother drawing this actor - - RF_FORCEYBILLBOARD = 0x10000, // [BB] OpenGL only: draw with y axis billboard, i.e. anchored to the floor (overrides gl_billboard_mode setting) - RF_FORCEXYBILLBOARD = 0x20000, // [BB] OpenGL only: draw with xy axis billboard, i.e. unanchored (overrides gl_billboard_mode setting) -}; - -#define TRANSLUC25 (FRACUNIT/4) -#define TRANSLUC33 (FRACUNIT/3) -#define TRANSLUC50 (FRACUNIT/2) -#define TRANSLUC66 ((FRACUNIT*2)/3) -#define TRANSLUC75 ((FRACUNIT*3)/4) - -// also #defines OPAQUE -#ifndef OPAQUE -#define OPAQUE (FRACUNIT) -#endif - -// This translucency value produces the closest match to Heretic's TINTTAB. -// ~40% of the value of the overlaid image shows through. -#define HR_SHADOW (0x6800) - -// Hexen's TINTTAB is the same as Heretic's, just reversed. -#define HX_SHADOW (0x9800) -#define HX_ALTSHADOW (0x6800) - -// This could easily be a bool but then it'd be much harder to find later. ;) -enum replace_t -{ - NO_REPLACE = 0, - ALLOW_REPLACE = 1 -}; - -enum ActorBounceFlag -{ - BOUNCE_Walls = 1<<0, // bounces off of walls - BOUNCE_Floors = 1<<1, // bounces off of floors - BOUNCE_Ceilings = 1<<2, // bounces off of ceilings - BOUNCE_Actors = 1<<3, // bounces off of some actors - BOUNCE_AllActors = 1<<4, // bounces off of all actors (requires BOUNCE_Actors to be set, too) - BOUNCE_AutoOff = 1<<5, // when bouncing off a sector plane, if the new Z velocity is below 3.0, disable further bouncing - BOUNCE_HereticType = 1<<6, // goes into Death state when bouncing on floors or ceilings - - BOUNCE_UseSeeSound = 1<<7, // compatibility fallback. This will only be set by - // the compatibility handlers for the old bounce flags. - BOUNCE_NoWallSound = 1<<8, // don't make noise when bouncing off a wall - BOUNCE_Quiet = 1<<9, // Strife's grenades don't make a bouncing sound - BOUNCE_ExplodeOnWater = 1<<10, // explodes when hitting a water surface - BOUNCE_CanBounceWater = 1<<11, // can bounce on water - // MBF bouncing is a bit different from other modes as Killough coded many special behavioral cases - // for them that are not present in ZDoom, so it is necessary to identify it properly. - BOUNCE_MBF = 1<<12, // This in itself is not a valid mode, but replaces MBF's MF_BOUNCE flag. - BOUNCE_AutoOffFloorOnly = 1<<13, // like BOUNCE_AutoOff, but only on floors - BOUNCE_UseBounceState = 1<<14, // Use Bounce[.*] states - - BOUNCE_TypeMask = BOUNCE_Walls | BOUNCE_Floors | BOUNCE_Ceilings | BOUNCE_Actors | BOUNCE_AutoOff | BOUNCE_HereticType | BOUNCE_MBF, - - // The three "standard" types of bounciness are: - // HERETIC - Missile will only bounce off the floor once and then enter - // its death state. It does not bounce off walls at all. - // HEXEN - Missile bounces off of walls and floors indefinitely. - // DOOM - Like Hexen, but the bounce turns off if its vertical velocity - // is too low. - BOUNCE_None = 0, - BOUNCE_Heretic = BOUNCE_Floors | BOUNCE_Ceilings | BOUNCE_HereticType, - BOUNCE_Doom = BOUNCE_Walls | BOUNCE_Floors | BOUNCE_Ceilings | BOUNCE_Actors | BOUNCE_AutoOff, - BOUNCE_Hexen = BOUNCE_Walls | BOUNCE_Floors | BOUNCE_Ceilings | BOUNCE_Actors, - BOUNCE_Grenade = BOUNCE_MBF | BOUNCE_Doom, // Bounces on walls and flats like ZDoom bounce. - BOUNCE_Classic = BOUNCE_MBF | BOUNCE_Floors | BOUNCE_Ceilings, // Bounces on flats only, but - // does not die when bouncing. - - // combined types - BOUNCE_DoomCompat = BOUNCE_Doom | BOUNCE_UseSeeSound, - BOUNCE_HereticCompat = BOUNCE_Heretic | BOUNCE_UseSeeSound, - BOUNCE_HexenCompat = BOUNCE_Hexen | BOUNCE_UseSeeSound - - // The distinction between BOUNCE_Actors and BOUNCE_AllActors: A missile with - // BOUNCE_Actors set will bounce off of reflective and "non-sentient" actors. - // A missile that also has BOUNCE_AllActors set will bounce off of any actor. - // For compatibility reasons when BOUNCE_Actors was implied by the bounce type - // being "Doom" or "Hexen" and BOUNCE_AllActors was the separate - // MF5_BOUNCEONACTORS, you must set BOUNCE_Actors for BOUNCE_AllActors to have - // an effect. - - -}; - -// [TP] Flagset definitions -typedef TFlags ActorFlags; -typedef TFlags ActorFlags2; -typedef TFlags ActorFlags3; -typedef TFlags ActorFlags4; -typedef TFlags ActorFlags5; -typedef TFlags ActorFlags6; -typedef TFlags ActorFlags7; -typedef TFlags ActorRenderFlags; -typedef TFlags ActorBounceFlags; -DEFINE_TFLAGS_OPERATORS (ActorFlags) -DEFINE_TFLAGS_OPERATORS (ActorFlags2) -DEFINE_TFLAGS_OPERATORS (ActorFlags3) -DEFINE_TFLAGS_OPERATORS (ActorFlags4) -DEFINE_TFLAGS_OPERATORS (ActorFlags5) -DEFINE_TFLAGS_OPERATORS (ActorFlags6) -DEFINE_TFLAGS_OPERATORS (ActorFlags7) -DEFINE_TFLAGS_OPERATORS (ActorRenderFlags) -DEFINE_TFLAGS_OPERATORS (ActorBounceFlags) - -// Used to affect the logic for thing activation through death, USESPECIAL and BUMPSPECIAL -// "thing" refers to what has the flag and the special, "trigger" refers to what used or bumped it -enum EThingSpecialActivationType -{ - THINGSPEC_Default = 0, // Normal behavior: a player must be the trigger, and is the activator - THINGSPEC_ThingActs = 1, // The thing itself is the activator of the special - THINGSPEC_ThingTargets = 1<<1, // The thing changes its target to the trigger - THINGSPEC_TriggerTargets = 1<<2, // The trigger changes its target to the thing - THINGSPEC_MonsterTrigger = 1<<3, // The thing can be triggered by a monster - THINGSPEC_MissileTrigger = 1<<4, // The thing can be triggered by a projectile - THINGSPEC_ClearSpecial = 1<<5, // Clears special after successful activation - THINGSPEC_NoDeathSpecial = 1<<6, // Don't activate special on death - THINGSPEC_TriggerActs = 1<<7, // The trigger is the activator of the special - // (overrides LEVEL_ACTOWNSPECIAL Hexen hack) - THINGSPEC_Activate = 1<<8, // The thing is activated when triggered - THINGSPEC_Deactivate = 1<<9, // The thing is deactivated when triggered - THINGSPEC_Switch = 1<<10, // The thing is alternatively activated and deactivated when triggered -}; - -// [RH] Like msecnode_t, but for the blockmap -struct FBlockNode -{ - AActor *Me; // actor this node references - int BlockIndex; // index into blocklinks for the block this node is in - FBlockNode **PrevActor; // previous actor in this block - FBlockNode *NextActor; // next actor in this block - FBlockNode **PrevBlock; // previous block this actor is in - FBlockNode *NextBlock; // next block this actor is in - - static FBlockNode *Create (AActor *who, int x, int y); - void Release (); - - static FBlockNode *FreeBlocks; -}; - -class FDecalBase; -class AInventory; - -inline AActor *GetDefaultByName (const char *name) -{ - return (AActor *)(PClass::FindClass(name)->Defaults); -} - -inline AActor *GetDefaultByType (const PClass *type) -{ - return (AActor *)(type->Defaults); -} - -template -inline T *GetDefault () -{ - return (T *)(RUNTIME_CLASS(T)->Defaults); -} - -struct line_t; -struct secplane_t; -struct FStrifeDialogueNode; - -enum -{ - AMETA_BASE = 0x12000, - - AMETA_Obituary, // string (player was killed by this actor) - AMETA_HitObituary, // string (player was killed by this actor in melee) - AMETA_DeathHeight, // fixed (height on normal death) - AMETA_BurnHeight, // fixed (height on burning death) - AMETA_StrifeName, // string (for named Strife objects) - AMETA_BloodColor, // colorized blood - AMETA_GibHealth, // negative health below which this monster dies an extreme death - AMETA_WoundHealth, // health needed to enter wound state - AMETA_FastSpeed, // Speed in fast mode - AMETA_RDFactor, // Radius damage factor - AMETA_CameraHeight, // Height of camera when used as such - AMETA_HowlSound, // Sound being played when electrocuted or poisoned - AMETA_BloodType, // Blood replacement type - AMETA_BloodType2, // Bloodsplatter replacement type - AMETA_BloodType3, // AxeBlood replacement type -}; - -struct FDropItem -{ - FName Name; - int probability; - int amount; - FDropItem * Next; -}; - -class FDropItemPtrArray : public TArray -{ -public: - ~FDropItemPtrArray() - { - Clear(); - } - - void Clear(); -}; - -extern FDropItemPtrArray DropItemList; - -void FreeDropItemChain(FDropItem *chain); -int StoreDropItemChain(FDropItem *chain); +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id:$ +// +// Copyright (C) 1993-1996 by id Software, Inc. +// +// This source is available for distribution and/or modification +// only under the terms of the DOOM Source Code License as +// published by id Software. All rights reserved. +// +// The source is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License +// for more details. +// +// DESCRIPTION: +// Map Objects, MObj, definition and handling. +// +//----------------------------------------------------------------------------- + + +#ifndef __P_MOBJ_H__ +#define __P_MOBJ_H__ + +// Basics. +#include "tables.h" + +// We need the thinker_t stuff. +#include "dthinker.h" + + +// States are tied to finite states are tied to animation frames. +#include "info.h" + +#include "doomdef.h" +#include "textures/textures.h" +#include "r_data/renderstyle.h" +#include "s_sound.h" +#include "memarena.h" +#include "g_level.h" +#include "tflags.h" + +struct subsector_t; +// +// NOTES: AActor +// +// Actors are used to tell the refresh where to draw an image, +// tell the world simulation when objects are contacted, +// and tell the sound driver how to position a sound. +// +// The refresh uses the next and prev links to follow +// lists of things in sectors as they are being drawn. +// The sprite, frame, and angle elements determine which patch_t +// is used to draw the sprite if it is visible. +// The sprite and frame values are almost always set +// from state_t structures. +// The statescr.exe utility generates the states.h and states.c +// files that contain the sprite/frame numbers from the +// statescr.txt source file. +// The xyz origin point represents a point at the bottom middle +// of the sprite (between the feet of a biped). +// This is the default origin position for patch_ts grabbed +// with lumpy.exe. +// A walking creature will have its z equal to the floor +// it is standing on. +// +// The sound code uses the x,y, and sometimes z fields +// to do stereo positioning of any sound emitted by the actor. +// +// The play simulation uses the blocklinks, x,y,z, radius, height +// to determine when AActors are touching each other, +// touching lines in the map, or hit by trace lines (gunshots, +// lines of sight, etc). +// The AActor->flags element has various bit flags +// used by the simulation. +// +// Every actor is linked into a single sector +// based on its origin coordinates. +// The subsector_t is found with R_PointInSubsector(x,y), +// and the sector_t can be found with subsector->sector. +// The sector links are only used by the rendering code, +// the play simulation does not care about them at all. +// +// Any actor that needs to be acted upon by something else +// in the play world (block movement, be shot, etc) will also +// need to be linked into the blockmap. +// If the thing has the MF_NOBLOCK flag set, it will not use +// the block links. It can still interact with other things, +// but only as the instigator (missiles will run into other +// things, but nothing can run into a missile). +// Each block in the grid is 128*128 units, and knows about +// every line_t that it contains a piece of, and every +// interactable actor that has its origin contained. +// +// A valid actor is an actor that has the proper subsector_t +// filled in for its xy coordinates and is linked into the +// sector from which the subsector was made, or has the +// MF_NOSECTOR flag set (the subsector_t needs to be valid +// even if MF_NOSECTOR is set), and is linked into a blockmap +// block or has the MF_NOBLOCKMAP flag set. +// Links should only be modified by the P_[Un]SetThingPosition() +// functions. +// Do not change the MF_NO* flags while a thing is valid. +// +// Any questions? +// + +// --- mobj.flags --- +enum ActorFlag +{ + MF_SPECIAL = 0x00000001, // call P_SpecialThing when touched + MF_SOLID = 0x00000002, + MF_SHOOTABLE = 0x00000004, + MF_NOSECTOR = 0x00000008, // don't use the sector links + // (invisible but touchable) + MF_NOBLOCKMAP = 0x00000010, // don't use the blocklinks + // (inert but displayable) + MF_AMBUSH = 0x00000020, // not activated by sound; deaf monster + MF_JUSTHIT = 0x00000040, // try to attack right back + MF_JUSTATTACKED = 0x00000080, // take at least one step before attacking + MF_SPAWNCEILING = 0x00000100, // hang from ceiling instead of floor + MF_NOGRAVITY = 0x00000200, // don't apply gravity every tic + +// movement flags + MF_DROPOFF = 0x00000400, // allow jumps from high places + MF_PICKUP = 0x00000800, // for players to pick up items + MF_NOCLIP = 0x00001000, // player cheat + MF_INCHASE = 0x00002000, // [RH] used by A_Chase and A_Look to avoid recursion + MF_FLOAT = 0x00004000, // allow moves to any height, no gravity + MF_TELEPORT = 0x00008000, // don't cross lines or look at heights + MF_MISSILE = 0x00010000, // don't hit same species, explode on block + + MF_DROPPED = 0x00020000, // dropped by a demon, not level spawned + MF_SHADOW = 0x00040000, // actor is hard for monsters to see + MF_NOBLOOD = 0x00080000, // don't bleed when shot (use puff) + MF_CORPSE = 0x00100000, // don't stop moving halfway off a step + MF_INFLOAT = 0x00200000, // floating to a height for a move, don't + // auto float to target's height + MF_INBOUNCE = 0x00200000, // used by Heretic bouncing missiles + + MF_COUNTKILL = 0x00400000, // count towards intermission kill total + MF_COUNTITEM = 0x00800000, // count towards intermission item total + + MF_SKULLFLY = 0x01000000, // skull in flight + MF_NOTDMATCH = 0x02000000, // don't spawn in death match (key cards) + + MF_SPAWNSOUNDSOURCE = 0x04000000, // Plays missile's see sound at spawning object. + MF_FRIENDLY = 0x08000000, // [RH] Friendly monsters for Strife (and MBF) + MF_UNMORPHED = 0x10000000, // [RH] Actor is the unmorphed version of something else + MF_NOLIFTDROP = 0x20000000, // [RH] Used with MF_NOGRAVITY to avoid dropping with lifts + MF_STEALTH = 0x40000000, // [RH] Andy Baker's stealth monsters + MF_ICECORPSE = 0x80000000, // a frozen corpse (for blasting) [RH] was 0x800000 + + // --- dummies for unknown/unimplemented Strife flags --- + MF_STRIFEx8000000 = 0, // seems related to MF_SHADOW +}; + +// --- mobj.flags2 --- +enum ActorFlag2 +{ + MF2_DONTREFLECT = 0x00000001, // this projectile cannot be reflected + MF2_WINDTHRUST = 0x00000002, // gets pushed around by the wind specials + MF2_DONTSEEKINVISIBLE=0x00000004, // For seeker missiles: Don't home in on invisible/shadow targets + MF2_BLASTED = 0x00000008, // actor will temporarily take damage from impact + MF2_FLY = 0x00000010, // fly mode is active + MF2_FLOORCLIP = 0x00000020, // if feet are allowed to be clipped + MF2_SPAWNFLOAT = 0x00000040, // spawn random float z + MF2_NOTELEPORT = 0x00000080, // does not teleport + MF2_RIP = 0x00000100, // missile rips through solid targets + MF2_PUSHABLE = 0x00000200, // can be pushed by other moving actors + MF2_SLIDE = 0x00000400, // slides against walls + MF2_ONMOBJ = 0x00000800, // actor is resting on top of another actor + MF2_PASSMOBJ = 0x00001000, // Enable z block checking. If on, + // this flag will allow the actor to + // pass over/under other actors. + MF2_CANNOTPUSH = 0x00002000, // cannot push other pushable mobjs + MF2_THRUGHOST = 0x00004000, // missile will pass through ghosts [RH] was 8 + MF2_BOSS = 0x00008000, // mobj is a major boss + + MF2_DONTTRANSLATE = 0x00010000, // Don't apply palette translations + MF2_NODMGTHRUST = 0x00020000, // does not thrust target when damaging + MF2_TELESTOMP = 0x00040000, // mobj can stomp another + MF2_FLOATBOB = 0x00080000, // use float bobbing z movement + MF2_THRUACTORS = 0x00100000, // performs no actor<->actor collision checks + MF2_IMPACT = 0x00200000, // an MF_MISSILE mobj can activate SPAC_IMPACT + MF2_PUSHWALL = 0x00400000, // mobj can push walls + MF2_MCROSS = 0x00800000, // can activate monster cross lines + MF2_PCROSS = 0x01000000, // can activate projectile cross lines + MF2_CANTLEAVEFLOORPIC=0x02000000, // stay within a certain floor type + MF2_NONSHOOTABLE = 0x04000000, // mobj is totally non-shootable, + // but still considered solid + MF2_INVULNERABLE = 0x08000000, // mobj is invulnerable + MF2_DORMANT = 0x10000000, // thing is dormant + MF2_ARGSDEFINED = 0x20000000, // Internal flag used by DECORATE to signal that the + // args should not be taken from the mapthing definition + MF2_SEEKERMISSILE = 0x40000000, // is a seeker (for reflection) + MF2_REFLECTIVE = 0x80000000, // reflects missiles +}; + +// --- mobj.flags3 --- +enum ActorFlag3 +{ + MF3_FLOORHUGGER = 0x00000001, // Missile stays on floor + MF3_CEILINGHUGGER = 0x00000002, // Missile stays on ceiling + MF3_NORADIUSDMG = 0x00000004, // Actor does not take radius damage + MF3_GHOST = 0x00000008, // Actor is a ghost + MF3_ALWAYSPUFF = 0x00000010, // Puff always appears, even when hit nothing + MF3_SPECIALFLOORCLIP= 0x00000020, // Actor uses floorclip for special effect (e.g. Wraith) + MF3_DONTSPLASH = 0x00000040, // Thing doesn't make a splash + MF3_NOSIGHTCHECK = 0x00000080, // Go after first acceptable target without checking sight + MF3_DONTOVERLAP = 0x00000100, // Don't pass over/under other things with this bit set + MF3_DONTMORPH = 0x00000200, // Immune to arti_egg + MF3_DONTSQUASH = 0x00000400, // Death ball can't squash this actor + MF3_EXPLOCOUNT = 0x00000800, // Don't explode until special2 counts to special1 + MF3_FULLVOLACTIVE = 0x00001000, // Active sound is played at full volume + MF3_ISMONSTER = 0x00002000, // Actor is a monster + MF3_SKYEXPLODE = 0x00004000, // Explode missile when hitting sky + MF3_STAYMORPHED = 0x00008000, // Monster cannot unmorph + MF3_DONTBLAST = 0x00010000, // Actor cannot be pushed by blasting + MF3_CANBLAST = 0x00020000, // Actor is not a monster but can be blasted + MF3_NOTARGET = 0x00040000, // This actor not targetted when it hurts something else + MF3_DONTGIB = 0x00080000, // Don't gib this corpse + MF3_NOBLOCKMONST = 0x00100000, // Can cross ML_BLOCKMONSTERS lines + MF3_CRASHED = 0x00200000, // Actor entered its crash state + MF3_FULLVOLDEATH = 0x00400000, // DeathSound is played full volume (for missiles) + MF3_AVOIDMELEE = 0x00800000, // Avoids melee attacks (same as MBF's monster_backing but must be explicitly set) + MF3_SCREENSEEKER = 0x01000000, // Fails the IsOkayToAttack test if potential target is outside player FOV + MF3_FOILINVUL = 0x02000000, // Actor can hurt MF2_INVULNERABLE things + MF3_NOTELEOTHER = 0x04000000, // Monster is unaffected by teleport other artifact + MF3_BLOODLESSIMPACT = 0x08000000, // Projectile does not leave blood + MF3_NOEXPLODEFLOOR = 0x10000000, // Missile stops at floor instead of exploding + MF3_WARNBOT = 0x20000000, // Missile warns bot + MF3_PUFFONACTORS = 0x40000000, // Puff appears even when hit bleeding actors + MF3_HUNTPLAYERS = 0x80000000, // Used with TIDtoHate, means to hate players too +}; + +// --- mobj.flags4 --- +enum ActorFlag4 +{ + MF4_NOHATEPLAYERS = 0x00000001, // Ignore player attacks + MF4_QUICKTORETALIATE= 0x00000002, // Always switch targets when hurt + MF4_NOICEDEATH = 0x00000004, // Actor never enters an ice death, not even the generic one + MF4_BOSSDEATH = 0x00000008, // A_FreezeDeathChunks calls A_BossDeath + MF4_RANDOMIZE = 0x00000010, // Missile has random initial tic count + MF4_NOSKIN = 0x00000020, // Player cannot use skins + MF4_FIXMAPTHINGPOS = 0x00000040, // Fix this actor's position when spawned as a map thing + MF4_ACTLIKEBRIDGE = 0x00000080, // Pickups can "stand" on this actor / cannot be moved by any sector action. + MF4_STRIFEDAMAGE = 0x00000100, // Strife projectiles only do up to 4x damage, not 8x + + MF4_CANUSEWALLS = 0x00000200, // Can activate 'use' specials + MF4_MISSILEMORE = 0x00000400, // increases the chance of a missile attack + MF4_MISSILEEVENMORE = 0x00000800, // significantly increases the chance of a missile attack + MF4_FORCERADIUSDMG = 0x00001000, // if put on an object it will override MF3_NORADIUSDMG + MF4_DONTFALL = 0x00002000, // Doesn't have NOGRAVITY disabled when dying. + MF4_SEESDAGGERS = 0x00004000, // This actor can see you striking with a dagger + MF4_INCOMBAT = 0x00008000, // Don't alert others when attacked by a dagger + MF4_LOOKALLAROUND = 0x00010000, // Monster has eyes in the back of its head + MF4_STANDSTILL = 0x00020000, // Monster should not chase targets unless attacked? + MF4_SPECTRAL = 0x00040000, + MF4_SCROLLMOVE = 0x00080000, // velocity has been applied by a scroller + MF4_NOSPLASHALERT = 0x00100000, // Splashes don't alert this monster + MF4_SYNCHRONIZED = 0x00200000, // For actors spawned at load-time only: Do not randomize tics + MF4_NOTARGETSWITCH = 0x00400000, // monster never switches target until current one is dead + MF4_VFRICTION = 0x00800000, // Internal flag used by A_PainAttack to push a monster down + MF4_DONTHARMCLASS = 0x01000000, // Don't hurt one's own kind with explosions (hitscans, too?) + MF4_SHIELDREFLECT = 0x02000000, + MF4_DEFLECT = 0x04000000, // different projectile reflection styles + MF4_ALLOWPARTICLES = 0x08000000, // this puff type can be replaced by particles + MF4_NOEXTREMEDEATH = 0x10000000, // this projectile or weapon never gibs its victim + MF4_EXTREMEDEATH = 0x20000000, // this projectile or weapon always gibs its victim + MF4_FRIGHTENED = 0x40000000, // Monster runs away from player + MF4_BOSSSPAWNED = 0x80000000, // Spawned by a boss spawn cube +}; + +// --- mobj.flags5 --- + +enum ActorFlag5 +{ + MF5_DONTDRAIN = 0x00000001, // cannot be drained health from. + /* = 0x00000002, reserved for use by scripting branch */ + MF5_NODROPOFF = 0x00000004, // cannot drop off under any circumstances. + MF5_NOFORWARDFALL = 0x00000008, // Does not make any actor fall forward by being damaged by this + MF5_COUNTSECRET = 0x00000010, // From Doom 64: actor acts like a secret + MF5_AVOIDINGDROPOFF = 0x00000020, // Used to move monsters away from dropoffs + MF5_NODAMAGE = 0x00000040, // Actor can be shot and reacts to being shot but takes no damage + MF5_CHASEGOAL = 0x00000080, // Walks to goal instead of target if a valid goal is set. + MF5_BLOODSPLATTER = 0x00000100, // Blood splatter like in Raven's games. + MF5_OLDRADIUSDMG = 0x00000200, // Use old radius damage code (for barrels and boss brain) + MF5_DEHEXPLOSION = 0x00000400, // Use the DEHACKED explosion options when this projectile explodes + MF5_PIERCEARMOR = 0x00000800, // Armor doesn't protect against damage from this actor + MF5_NOBLOODDECALS = 0x00001000, // Actor bleeds but doesn't spawn blood decals + MF5_USESPECIAL = 0x00002000, // Actor executes its special when being 'used'. + MF5_NOPAIN = 0x00004000, // If set the pain state won't be entered + MF5_ALWAYSFAST = 0x00008000, // always uses 'fast' attacking logic + MF5_NEVERFAST = 0x00010000, // never uses 'fast' attacking logic + MF5_ALWAYSRESPAWN = 0x00020000, // always respawns, regardless of skill setting + MF5_NEVERRESPAWN = 0x00040000, // never respawns, regardless of skill setting + MF5_DONTRIP = 0x00080000, // Ripping projectiles explode when hitting this actor + MF5_NOINFIGHTING = 0x00100000, // This actor doesn't switch target when it's hurt + MF5_NOINTERACTION = 0x00200000, // Thing is completely excluded from any gameplay related checks + MF5_NOTIMEFREEZE = 0x00400000, // Actor is not affected by time freezer + MF5_PUFFGETSOWNER = 0x00800000, // [BB] Sets the owner of the puff to the player who fired it + MF5_SPECIALFIREDAMAGE=0x01000000, // Special treatment of PhoenixFX1 turned into a flag to remove + // dependence of main engine code of specific actor types. + MF5_SUMMONEDMONSTER = 0x02000000, // To mark the friendly Minotaur. Hopefully to be generalized later. + MF5_NOVERTICALMELEERANGE=0x04000000,// Does not check vertical distance for melee range + MF5_BRIGHT = 0x08000000, // Actor is always rendered fullbright + MF5_CANTSEEK = 0x10000000, // seeker missiles cannot home in on this actor + MF5_INCONVERSATION = 0x20000000, // Actor is having a conversation + MF5_PAINLESS = 0x40000000, // Actor always inflicts painless damage. + MF5_MOVEWITHSECTOR = 0x80000000, // P_ChangeSector() will still process this actor if it has MF_NOBLOCKMAP +}; + +// --- mobj.flags6 --- +enum ActorFlag6 +{ + MF6_NOBOSSRIP = 0x00000001, // For rippermissiles: Don't rip through bosses. + MF6_THRUSPECIES = 0x00000002, // Actors passes through other of the same species. + MF6_MTHRUSPECIES = 0x00000004, // Missile passes through actors of its shooter's species. + MF6_FORCEPAIN = 0x00000008, // forces target into painstate (unless it has the NOPAIN flag) + MF6_NOFEAR = 0x00000010, // Not scared of frightening players + MF6_BUMPSPECIAL = 0x00000020, // Actor executes its special when being collided (as the ST flag) + MF6_DONTHARMSPECIES = 0x00000040, // Don't hurt one's own species with explosions (hitscans, too?) + MF6_STEPMISSILE = 0x00000080, // Missile can "walk" up steps + MF6_NOTELEFRAG = 0x00000100, // [HW] Actor can't be telefragged + MF6_TOUCHY = 0x00000200, // From MBF: killough 11/98: dies when solids touch it + MF6_CANJUMP = 0x00000400, // From MBF: a dedicated flag instead of the BOUNCES+FLOAT+sentient combo + MF6_JUMPDOWN = 0x00000800, // From MBF: generalization of dog behavior wrt. dropoffs. + MF6_VULNERABLE = 0x00001000, // Actor can be damaged (even if not shootable). + MF6_ARMED = 0x00002000, // From MBF: Object is armed (for MF6_TOUCHY objects) + MF6_FALLING = 0x00004000, // From MBF: Object is falling (for pseudotorque simulation) + MF6_LINEDONE = 0x00008000, // From MBF: Object has already run a line effect + MF6_NOTRIGGER = 0x00010000, // actor cannot trigger any line actions + MF6_SHATTERING = 0x00020000, // marks an ice corpse for forced shattering + MF6_KILLED = 0x00040000, // Something that was killed (but not necessarily a corpse) + MF6_BLOCKEDBYSOLIDACTORS = 0x00080000, // Blocked by solid actors, even if not solid itself + MF6_ADDITIVEPOISONDAMAGE = 0x00100000, + MF6_ADDITIVEPOISONDURATION = 0x00200000, + MF6_NOMENU = 0x00400000, // Player class should not appear in the class selection menu. + MF6_BOSSCUBE = 0x00800000, // Actor spawned by A_BrainSpit, flagged for timefreeze reasons. + MF6_SEEINVISIBLE = 0x01000000, // Monsters can see invisible player. + MF6_DONTCORPSE = 0x02000000, // [RC] Don't autoset MF_CORPSE upon death and don't force Crash state change. + MF6_POISONALWAYS = 0x04000000, // Always apply poison, even when target can't take the damage. + MF6_DOHARMSPECIES = 0x08000000, // Do hurt one's own species with projectiles. + MF6_INTRYMOVE = 0x10000000, // Executing P_TryMove + MF6_NOTAUTOAIMED = 0x20000000, // Do not subject actor to player autoaim. + MF6_NOTONAUTOMAP = 0x40000000, // will not be shown on automap with the 'scanner' powerup. + MF6_RELATIVETOFLOOR = 0x80000000, // [RC] Make flying actors be affected by lifts. +}; + +// --- mobj.flags7 --- +enum ActorFlag7 +{ + MF7_NEVERTARGET = 0x00000001, // can not be targetted at all, even if monster friendliness is considered. + MF7_NOTELESTOMP = 0x00000002, // cannot telefrag under any circumstances (even when set by MAPINFO) + MF7_ALWAYSTELEFRAG = 0x00000004, // will unconditionally be telefragged when in the way. Overrides all other settings. + MF7_HANDLENODELAY = 0x00000008, // respect NoDelay state flag + MF7_WEAPONSPAWN = 0x00000010, // subject to DF_NO_COOP_WEAPON_SPAWN dmflag + MF7_HARMFRIENDS = 0x00000020, // is allowed to harm friendly monsters. + MF7_BUDDHA = 0x00000040, // Behaves just like the buddha cheat. + MF7_FOILBUDDHA = 0x00000080, // Similar to FOILINVUL, foils buddha mode. + MF7_DONTTHRUST = 0x00000100, // Thrusting functions do not take, and do not give thrust (damage) to actors with this flag. + MF7_ALLOWPAIN = 0x00000200, // Invulnerable or immune (via damagefactors) actors can still react to taking damage even if they don't. + MF7_CAUSEPAIN = 0x00000400, // Damage sources with this flag can cause similar effects like ALLOWPAIN. + MF7_THRUREFLECT = 0x00000800, // Actors who are reflective cause the missiles to not slow down or change angles. + MF7_MIRRORREFLECT = 0x00001000, // Actor is turned directly 180 degrees around when reflected. + MF7_AIMREFLECT = 0x00002000, // Actor is directly reflected straight back at the one who fired the projectile. + MF7_HITTARGET = 0x00004000, // The actor the projectile dies on is set to target, provided it's targetable anyway. + MF7_HITMASTER = 0x00008000, // Same as HITTARGET, except it's master instead of target. + MF7_HITTRACER = 0x00010000, // Same as HITTARGET, but for tracer. + MF7_FLYCHEAT = 0x00020000, // must be part of the actor so that it can be tracked properly + MF7_NODECAL = 0x00040000, // [ZK] Forces puff to have no impact decal + MF7_FORCEDECAL = 0x00080000, // [ZK] Forces puff's decal to override the weapon's. + MF7_LAXTELEFRAGDMG = 0x00100000, // [MC] Telefrag damage can be reduced. + MF7_ICESHATTER = 0x00200000, // [MC] Shatters ice corpses regardless of damagetype. +}; + +// --- mobj.renderflags --- +enum ActorRenderFlag +{ + RF_XFLIP = 0x0001, // Flip sprite horizontally + RF_YFLIP = 0x0002, // Flip sprite vertically + RF_ONESIDED = 0x0004, // Wall/floor sprite is visible from front only + RF_FULLBRIGHT = 0x0010, // Sprite is drawn at full brightness + + RF_RELMASK = 0x0300, // ---Relative z-coord for bound actors (these obey texture pegging) + RF_RELABSOLUTE = 0x0000, // Actor z is absolute + RF_RELUPPER = 0x0100, // Actor z is relative to upper part of wall + RF_RELLOWER = 0x0200, // Actor z is relative to lower part of wall + RF_RELMID = 0x0300, // Actor z is relative to middle part of wall + + RF_CLIPMASK = 0x0c00, // ---Clipping for bound actors + RF_CLIPFULL = 0x0000, // Clip sprite to full height of wall + RF_CLIPUPPER = 0x0400, // Clip sprite to upper part of wall + RF_CLIPMID = 0x0800, // Clip sprite to mid part of wall + RF_CLIPLOWER = 0x0c00, // Clip sprite to lower part of wall + + RF_DECALMASK = RF_RELMASK|RF_CLIPMASK, + + RF_SPRITETYPEMASK = 0x7000, // ---Different sprite types, not all implemented + RF_FACESPRITE = 0x0000, // Face sprite + RF_WALLSPRITE = 0x1000, // Wall sprite + RF_FLOORSPRITE = 0x2000, // Floor sprite + RF_VOXELSPRITE = 0x3000, // Voxel object + RF_INVISIBLE = 0x8000, // Don't bother drawing this actor + + RF_FORCEYBILLBOARD = 0x10000, // [BB] OpenGL only: draw with y axis billboard, i.e. anchored to the floor (overrides gl_billboard_mode setting) + RF_FORCEXYBILLBOARD = 0x20000, // [BB] OpenGL only: draw with xy axis billboard, i.e. unanchored (overrides gl_billboard_mode setting) +}; + +#define TRANSLUC25 (FRACUNIT/4) +#define TRANSLUC33 (FRACUNIT/3) +#define TRANSLUC50 (FRACUNIT/2) +#define TRANSLUC66 ((FRACUNIT*2)/3) +#define TRANSLUC75 ((FRACUNIT*3)/4) + +// also #defines OPAQUE +#ifndef OPAQUE +#define OPAQUE (FRACUNIT) +#endif + +// This translucency value produces the closest match to Heretic's TINTTAB. +// ~40% of the value of the overlaid image shows through. +#define HR_SHADOW (0x6800) + +// Hexen's TINTTAB is the same as Heretic's, just reversed. +#define HX_SHADOW (0x9800) +#define HX_ALTSHADOW (0x6800) + +// This could easily be a bool but then it'd be much harder to find later. ;) +enum replace_t +{ + NO_REPLACE = 0, + ALLOW_REPLACE = 1 +}; + +enum ActorBounceFlag +{ + BOUNCE_Walls = 1<<0, // bounces off of walls + BOUNCE_Floors = 1<<1, // bounces off of floors + BOUNCE_Ceilings = 1<<2, // bounces off of ceilings + BOUNCE_Actors = 1<<3, // bounces off of some actors + BOUNCE_AllActors = 1<<4, // bounces off of all actors (requires BOUNCE_Actors to be set, too) + BOUNCE_AutoOff = 1<<5, // when bouncing off a sector plane, if the new Z velocity is below 3.0, disable further bouncing + BOUNCE_HereticType = 1<<6, // goes into Death state when bouncing on floors or ceilings + + BOUNCE_UseSeeSound = 1<<7, // compatibility fallback. This will only be set by + // the compatibility handlers for the old bounce flags. + BOUNCE_NoWallSound = 1<<8, // don't make noise when bouncing off a wall + BOUNCE_Quiet = 1<<9, // Strife's grenades don't make a bouncing sound + BOUNCE_ExplodeOnWater = 1<<10, // explodes when hitting a water surface + BOUNCE_CanBounceWater = 1<<11, // can bounce on water + // MBF bouncing is a bit different from other modes as Killough coded many special behavioral cases + // for them that are not present in ZDoom, so it is necessary to identify it properly. + BOUNCE_MBF = 1<<12, // This in itself is not a valid mode, but replaces MBF's MF_BOUNCE flag. + BOUNCE_AutoOffFloorOnly = 1<<13, // like BOUNCE_AutoOff, but only on floors + BOUNCE_UseBounceState = 1<<14, // Use Bounce[.*] states + + BOUNCE_TypeMask = BOUNCE_Walls | BOUNCE_Floors | BOUNCE_Ceilings | BOUNCE_Actors | BOUNCE_AutoOff | BOUNCE_HereticType | BOUNCE_MBF, + + // The three "standard" types of bounciness are: + // HERETIC - Missile will only bounce off the floor once and then enter + // its death state. It does not bounce off walls at all. + // HEXEN - Missile bounces off of walls and floors indefinitely. + // DOOM - Like Hexen, but the bounce turns off if its vertical velocity + // is too low. + BOUNCE_None = 0, + BOUNCE_Heretic = BOUNCE_Floors | BOUNCE_Ceilings | BOUNCE_HereticType, + BOUNCE_Doom = BOUNCE_Walls | BOUNCE_Floors | BOUNCE_Ceilings | BOUNCE_Actors | BOUNCE_AutoOff, + BOUNCE_Hexen = BOUNCE_Walls | BOUNCE_Floors | BOUNCE_Ceilings | BOUNCE_Actors, + BOUNCE_Grenade = BOUNCE_MBF | BOUNCE_Doom, // Bounces on walls and flats like ZDoom bounce. + BOUNCE_Classic = BOUNCE_MBF | BOUNCE_Floors | BOUNCE_Ceilings, // Bounces on flats only, but + // does not die when bouncing. + + // combined types + BOUNCE_DoomCompat = BOUNCE_Doom | BOUNCE_UseSeeSound, + BOUNCE_HereticCompat = BOUNCE_Heretic | BOUNCE_UseSeeSound, + BOUNCE_HexenCompat = BOUNCE_Hexen | BOUNCE_UseSeeSound + + // The distinction between BOUNCE_Actors and BOUNCE_AllActors: A missile with + // BOUNCE_Actors set will bounce off of reflective and "non-sentient" actors. + // A missile that also has BOUNCE_AllActors set will bounce off of any actor. + // For compatibility reasons when BOUNCE_Actors was implied by the bounce type + // being "Doom" or "Hexen" and BOUNCE_AllActors was the separate + // MF5_BOUNCEONACTORS, you must set BOUNCE_Actors for BOUNCE_AllActors to have + // an effect. + + +}; + +// [TP] Flagset definitions +typedef TFlags ActorFlags; +typedef TFlags ActorFlags2; +typedef TFlags ActorFlags3; +typedef TFlags ActorFlags4; +typedef TFlags ActorFlags5; +typedef TFlags ActorFlags6; +typedef TFlags ActorFlags7; +typedef TFlags ActorRenderFlags; +typedef TFlags ActorBounceFlags; +DEFINE_TFLAGS_OPERATORS (ActorFlags) +DEFINE_TFLAGS_OPERATORS (ActorFlags2) +DEFINE_TFLAGS_OPERATORS (ActorFlags3) +DEFINE_TFLAGS_OPERATORS (ActorFlags4) +DEFINE_TFLAGS_OPERATORS (ActorFlags5) +DEFINE_TFLAGS_OPERATORS (ActorFlags6) +DEFINE_TFLAGS_OPERATORS (ActorFlags7) +DEFINE_TFLAGS_OPERATORS (ActorRenderFlags) +DEFINE_TFLAGS_OPERATORS (ActorBounceFlags) + +// Used to affect the logic for thing activation through death, USESPECIAL and BUMPSPECIAL +// "thing" refers to what has the flag and the special, "trigger" refers to what used or bumped it +enum EThingSpecialActivationType +{ + THINGSPEC_Default = 0, // Normal behavior: a player must be the trigger, and is the activator + THINGSPEC_ThingActs = 1, // The thing itself is the activator of the special + THINGSPEC_ThingTargets = 1<<1, // The thing changes its target to the trigger + THINGSPEC_TriggerTargets = 1<<2, // The trigger changes its target to the thing + THINGSPEC_MonsterTrigger = 1<<3, // The thing can be triggered by a monster + THINGSPEC_MissileTrigger = 1<<4, // The thing can be triggered by a projectile + THINGSPEC_ClearSpecial = 1<<5, // Clears special after successful activation + THINGSPEC_NoDeathSpecial = 1<<6, // Don't activate special on death + THINGSPEC_TriggerActs = 1<<7, // The trigger is the activator of the special + // (overrides LEVEL_ACTOWNSPECIAL Hexen hack) + THINGSPEC_Activate = 1<<8, // The thing is activated when triggered + THINGSPEC_Deactivate = 1<<9, // The thing is deactivated when triggered + THINGSPEC_Switch = 1<<10, // The thing is alternatively activated and deactivated when triggered +}; + +// [RH] Like msecnode_t, but for the blockmap +struct FBlockNode +{ + AActor *Me; // actor this node references + int BlockIndex; // index into blocklinks for the block this node is in + FBlockNode **PrevActor; // previous actor in this block + FBlockNode *NextActor; // next actor in this block + FBlockNode **PrevBlock; // previous block this actor is in + FBlockNode *NextBlock; // next block this actor is in + + static FBlockNode *Create (AActor *who, int x, int y); + void Release (); + + static FBlockNode *FreeBlocks; +}; + +class FDecalBase; +class AInventory; + +inline AActor *GetDefaultByName (const char *name) +{ + return (AActor *)(PClass::FindClass(name)->Defaults); +} + +inline AActor *GetDefaultByType (const PClass *type) +{ + return (AActor *)(type->Defaults); +} + +template +inline T *GetDefault () +{ + return (T *)(RUNTIME_CLASS(T)->Defaults); +} + +struct line_t; +struct secplane_t; +struct FStrifeDialogueNode; + +enum +{ + AMETA_BASE = 0x12000, + + AMETA_Obituary, // string (player was killed by this actor) + AMETA_HitObituary, // string (player was killed by this actor in melee) + AMETA_DeathHeight, // fixed (height on normal death) + AMETA_BurnHeight, // fixed (height on burning death) + AMETA_StrifeName, // string (for named Strife objects) + AMETA_BloodColor, // colorized blood + AMETA_GibHealth, // negative health below which this monster dies an extreme death + AMETA_WoundHealth, // health needed to enter wound state + AMETA_FastSpeed, // Speed in fast mode + AMETA_RDFactor, // Radius damage factor + AMETA_CameraHeight, // Height of camera when used as such + AMETA_HowlSound, // Sound being played when electrocuted or poisoned + AMETA_BloodType, // Blood replacement type + AMETA_BloodType2, // Bloodsplatter replacement type + AMETA_BloodType3, // AxeBlood replacement type +}; + +struct FDropItem +{ + FName Name; + int probability; + int amount; + FDropItem * Next; +}; + +class FDropItemPtrArray : public TArray +{ +public: + ~FDropItemPtrArray() + { + Clear(); + } + + void Clear(); +}; + +extern FDropItemPtrArray DropItemList; + +void FreeDropItemChain(FDropItem *chain); +int StoreDropItemChain(FDropItem *chain); fixed_t P_AproxDistance (fixed_t dx, fixed_t dy); // since we cannot include p_local here... angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2); // same reason here with r_defs.h - - -// Map Object definition. -class AActor : public DThinker -{ - DECLARE_CLASS (AActor, DThinker) - HAS_OBJECT_POINTERS -public: - AActor () throw(); - AActor (const AActor &other) throw(); - AActor &operator= (const AActor &other); - void Destroy (); - ~AActor (); - - void Serialize (FArchive &arc); - - static AActor *StaticSpawn (const PClass *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement, bool SpawningMapThing = false); - - inline AActor *GetDefault () const - { - return (AActor *)(RUNTIME_TYPE(this)->Defaults); - } - - FDropItem *GetDropItems(); - - // Return true if the monster should use a missile attack, false for melee - bool SuggestMissileAttack (fixed_t dist); - - // Adjusts the angle for deflection/reflection of incoming missiles - // Returns true if the missile should be allowed to explode anyway - bool AdjustReflectionAngle (AActor *thing, angle_t &angle); - - // Returns true if this actor is within melee range of its target - bool CheckMeleeRange(); - - virtual void BeginPlay(); // Called immediately after the actor is created - virtual void PostBeginPlay(); // Called immediately before the actor's first tick - virtual void LevelSpawned(); // Called after BeginPlay if this actor was spawned by the world - virtual void HandleSpawnFlags(); // Translates SpawnFlags into in-game flags. - - virtual void MarkPrecacheSounds() const; // Marks sounds used by this actor for precaching. - - virtual void Activate (AActor *activator); - virtual void Deactivate (AActor *activator); - - virtual void Tick (); - - // Called when actor dies - virtual void Die (AActor *source, AActor *inflictor, int dmgflags = 0); - - // Perform some special damage action. Returns the amount of damage to do. - // Returning -1 signals the damage routine to exit immediately - virtual int DoSpecialDamage (AActor *target, int damage, FName damagetype); - - // Like DoSpecialDamage, but called on the actor receiving the damage. - virtual int TakeSpecialDamage (AActor *inflictor, AActor *source, int damage, FName damagetype); - - // Centaurs and ettins squeal when electrocuted, poisoned, or "holy"-ed - // Made a metadata property so no longer virtual - void Howl (); - - // Actor just hit the floor - virtual void HitFloor (); - - // plays bouncing sound - void PlayBounceSound(bool onfloor); - - // Called when an actor with MF_MISSILE and MF2_FLOORBOUNCE hits the floor - virtual bool FloorBounceMissile (secplane_t &plane); - - // Called when an actor is to be reflected by a disc of repulsion. - // Returns true to continue normal blast processing. - virtual bool SpecialBlastHandling (AActor *source, fixed_t strength); - - // Called by RoughBlockCheck - bool IsOkayToAttack (AActor *target); - - // Plays the actor's ActiveSound if its voice isn't already making noise. - void PlayActiveSound (); - - // Actor had MF_SKULLFLY set and rammed into something - // Returns false to stop moving and true to keep moving - virtual bool Slam (AActor *victim); - - // Called by PIT_CheckThing() and needed for some Hexen things. - // Returns -1 for normal behavior, 0 to return false, and 1 to return true. - // I'm not sure I like it this way, but it will do for now. - virtual int SpecialMissileHit (AActor *victim); - - // Returns true if it's okay to switch target to "other" after being attacked by it. - virtual bool OkayToSwitchTarget (AActor *other); - - // Something just touched this actor. - virtual void Touch (AActor *toucher); - - // Adds the item to this actor's inventory and sets its Owner. - virtual void AddInventory (AInventory *item); - - // Removes the item from the inventory list. - virtual void RemoveInventory (AInventory *item); - - // Take the amount value of an item from the inventory list. - // If nothing is left, the item may be destroyed. - // Returns true if the initial item count is positive. - virtual bool TakeInventory (const PClass *itemclass, int amount, bool fromdecorate = false, bool notakeinfinite = false); - - // Uses an item and removes it from the inventory. - virtual bool UseInventory (AInventory *item); - - // Tosses an item out of the inventory. - virtual AInventory *DropInventory (AInventory *item); - - // Removes all items from the inventory. - void ClearInventory(); - - // Returns true if this view is considered "local" for the player. - bool CheckLocalView (int playernum) const; - - // Finds the first item of a particular type. - AInventory *FindInventory (const PClass *type, bool subclass = false); - AInventory *FindInventory (FName type); - template T *FindInventory () - { - return static_cast (FindInventory (RUNTIME_CLASS(T))); - } - - // Adds one item of a particular type. Returns NULL if it could not be added. - AInventory *GiveInventoryType (const PClass *type); - - // Returns the first item held with IF_INVBAR set. - AInventory *FirstInv (); - - // Tries to give the actor some ammo. - bool GiveAmmo (const PClass *type, int amount); - - // Destroys all the inventory the actor is holding. - void DestroyAllInventory (); - - // Set the alphacolor field properly - void SetShade (DWORD rgb); - void SetShade (int r, int g, int b); - - // Plays a conversation animation - void ConversationAnimation (int animnum); - - // Make this actor hate the same things as another actor - void CopyFriendliness (AActor *other, bool changeTarget, bool resetHealth=true); - - // Moves the other actor's inventory to this one - void ObtainInventory (AActor *other); - - // Die. Now. - virtual bool Massacre (); - - // Transforms the actor into a finely-ground paste - virtual bool Grind(bool items); - - // Get this actor's team - int GetTeam(); - - // Is the other actor on my team? - bool IsTeammate (AActor *other); - - // Is the other actor my friend? - bool IsFriend (AActor *other); - - // Do I hate the other actor? - bool IsHostile (AActor *other); - - inline bool IsNoClip2() const; - - // What species am I? - virtual FName GetSpecies(); - - fixed_t GetBobOffset(fixed_t ticfrac=0) const - { - if (!(flags2 & MF2_FLOATBOB)) - { - return 0; - } - return finesine[MulScale22(((FloatBobPhase + level.maptime) << FRACBITS) + ticfrac, FINEANGLES) & FINEMASK] * 8; - } - - // Enter the crash state - void Crash(); - - // Return starting health adjusted by skill level - int SpawnHealth(); - int GibHealth(); - - inline bool isMissile(bool precise=true) - { - return (flags&MF_MISSILE) || (precise && GetDefault()->flags&MF_MISSILE); - } - - // Check for monsters that count as kill but excludes all friendlies. - bool CountsAsKill() const - { - return (flags & MF_COUNTKILL) && !(flags & MF_FRIENDLY); - } - - bool intersects(AActor *other) const - { - fixed_t blockdist = radius + other->radius; - return ( abs(x - other->x) < blockdist && abs(y - other->y) < blockdist); - } - - PalEntry GetBloodColor() const - { - return (PalEntry)GetClass()->Meta.GetMetaInt(AMETA_BloodColor); - } - - // These also set CF_INTERPVIEW for players. - void SetPitch(int p, bool interpolate, bool forceclamp = false); - void SetAngle(angle_t ang, bool interpolate); - void SetRoll(angle_t roll, bool interpolate); - - const PClass *GetBloodType(int type = 0) const - { - const PClass *bloodcls; - if (type == 0) - { - bloodcls = PClass::FindClass((ENamedName)GetClass()->Meta.GetMetaInt(AMETA_BloodType, NAME_Blood)); - } - else if (type == 1) - { - bloodcls = PClass::FindClass((ENamedName)GetClass()->Meta.GetMetaInt(AMETA_BloodType2, NAME_BloodSplatter)); - } - else if (type == 2) - { - bloodcls = PClass::FindClass((ENamedName)GetClass()->Meta.GetMetaInt(AMETA_BloodType3, NAME_AxeBlood)); - } - else return NULL; - - if (bloodcls != NULL) - { - bloodcls = bloodcls->GetReplacement(); - } - return bloodcls; - } - + + +// Map Object definition. +class AActor : public DThinker +{ + DECLARE_CLASS (AActor, DThinker) + HAS_OBJECT_POINTERS +public: + AActor () throw(); + AActor (const AActor &other) throw(); + AActor &operator= (const AActor &other); + void Destroy (); + ~AActor (); + + void Serialize (FArchive &arc); + + static AActor *StaticSpawn (const PClass *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement, bool SpawningMapThing = false); + + inline AActor *GetDefault () const + { + return (AActor *)(RUNTIME_TYPE(this)->Defaults); + } + + FDropItem *GetDropItems(); + + // Return true if the monster should use a missile attack, false for melee + bool SuggestMissileAttack (fixed_t dist); + + // Adjusts the angle for deflection/reflection of incoming missiles + // Returns true if the missile should be allowed to explode anyway + bool AdjustReflectionAngle (AActor *thing, angle_t &angle); + + // Returns true if this actor is within melee range of its target + bool CheckMeleeRange(); + + virtual void BeginPlay(); // Called immediately after the actor is created + virtual void PostBeginPlay(); // Called immediately before the actor's first tick + virtual void LevelSpawned(); // Called after BeginPlay if this actor was spawned by the world + virtual void HandleSpawnFlags(); // Translates SpawnFlags into in-game flags. + + virtual void MarkPrecacheSounds() const; // Marks sounds used by this actor for precaching. + + virtual void Activate (AActor *activator); + virtual void Deactivate (AActor *activator); + + virtual void Tick (); + + // Called when actor dies + virtual void Die (AActor *source, AActor *inflictor, int dmgflags = 0); + + // Perform some special damage action. Returns the amount of damage to do. + // Returning -1 signals the damage routine to exit immediately + virtual int DoSpecialDamage (AActor *target, int damage, FName damagetype); + + // Like DoSpecialDamage, but called on the actor receiving the damage. + virtual int TakeSpecialDamage (AActor *inflictor, AActor *source, int damage, FName damagetype); + + // Centaurs and ettins squeal when electrocuted, poisoned, or "holy"-ed + // Made a metadata property so no longer virtual + void Howl (); + + // Actor just hit the floor + virtual void HitFloor (); + + // plays bouncing sound + void PlayBounceSound(bool onfloor); + + // Called when an actor with MF_MISSILE and MF2_FLOORBOUNCE hits the floor + virtual bool FloorBounceMissile (secplane_t &plane); + + // Called when an actor is to be reflected by a disc of repulsion. + // Returns true to continue normal blast processing. + virtual bool SpecialBlastHandling (AActor *source, fixed_t strength); + + // Called by RoughBlockCheck + bool IsOkayToAttack (AActor *target); + + // Plays the actor's ActiveSound if its voice isn't already making noise. + void PlayActiveSound (); + + // Actor had MF_SKULLFLY set and rammed into something + // Returns false to stop moving and true to keep moving + virtual bool Slam (AActor *victim); + + // Called by PIT_CheckThing() and needed for some Hexen things. + // Returns -1 for normal behavior, 0 to return false, and 1 to return true. + // I'm not sure I like it this way, but it will do for now. + virtual int SpecialMissileHit (AActor *victim); + + // Returns true if it's okay to switch target to "other" after being attacked by it. + virtual bool OkayToSwitchTarget (AActor *other); + + // Something just touched this actor. + virtual void Touch (AActor *toucher); + + // Adds the item to this actor's inventory and sets its Owner. + virtual void AddInventory (AInventory *item); + + // Removes the item from the inventory list. + virtual void RemoveInventory (AInventory *item); + + // Take the amount value of an item from the inventory list. + // If nothing is left, the item may be destroyed. + // Returns true if the initial item count is positive. + virtual bool TakeInventory (const PClass *itemclass, int amount, bool fromdecorate = false, bool notakeinfinite = false); + + // Uses an item and removes it from the inventory. + virtual bool UseInventory (AInventory *item); + + // Tosses an item out of the inventory. + virtual AInventory *DropInventory (AInventory *item); + + // Removes all items from the inventory. + void ClearInventory(); + + // Returns true if this view is considered "local" for the player. + bool CheckLocalView (int playernum) const; + + // Finds the first item of a particular type. + AInventory *FindInventory (const PClass *type, bool subclass = false); + AInventory *FindInventory (FName type); + template T *FindInventory () + { + return static_cast (FindInventory (RUNTIME_CLASS(T))); + } + + // Adds one item of a particular type. Returns NULL if it could not be added. + AInventory *GiveInventoryType (const PClass *type); + + // Returns the first item held with IF_INVBAR set. + AInventory *FirstInv (); + + // Tries to give the actor some ammo. + bool GiveAmmo (const PClass *type, int amount); + + // Destroys all the inventory the actor is holding. + void DestroyAllInventory (); + + // Set the alphacolor field properly + void SetShade (DWORD rgb); + void SetShade (int r, int g, int b); + + // Plays a conversation animation + void ConversationAnimation (int animnum); + + // Make this actor hate the same things as another actor + void CopyFriendliness (AActor *other, bool changeTarget, bool resetHealth=true); + + // Moves the other actor's inventory to this one + void ObtainInventory (AActor *other); + + // Die. Now. + virtual bool Massacre (); + + // Transforms the actor into a finely-ground paste + virtual bool Grind(bool items); + + // Get this actor's team + int GetTeam(); + + // Is the other actor on my team? + bool IsTeammate (AActor *other); + + // Is the other actor my friend? + bool IsFriend (AActor *other); + + // Do I hate the other actor? + bool IsHostile (AActor *other); + + inline bool IsNoClip2() const; + + // What species am I? + virtual FName GetSpecies(); + + fixed_t GetBobOffset(fixed_t ticfrac=0) const + { + if (!(flags2 & MF2_FLOATBOB)) + { + return 0; + } + return finesine[MulScale22(((FloatBobPhase + level.maptime) << FRACBITS) + ticfrac, FINEANGLES) & FINEMASK] * 8; + } + + // Enter the crash state + void Crash(); + + // Return starting health adjusted by skill level + int SpawnHealth(); + int GibHealth(); + + inline bool isMissile(bool precise=true) + { + return (flags&MF_MISSILE) || (precise && GetDefault()->flags&MF_MISSILE); + } + + // Check for monsters that count as kill but excludes all friendlies. + bool CountsAsKill() const + { + return (flags & MF_COUNTKILL) && !(flags & MF_FRIENDLY); + } + + bool intersects(AActor *other) const + { + fixed_t blockdist = radius + other->radius; + return ( abs(x - other->x) < blockdist && abs(y - other->y) < blockdist); + } + + PalEntry GetBloodColor() const + { + return (PalEntry)GetClass()->Meta.GetMetaInt(AMETA_BloodColor); + } + + // These also set CF_INTERPVIEW for players. + void SetPitch(int p, bool interpolate, bool forceclamp = false); + void SetAngle(angle_t ang, bool interpolate); + void SetRoll(angle_t roll, bool interpolate); + + const PClass *GetBloodType(int type = 0) const + { + const PClass *bloodcls; + if (type == 0) + { + bloodcls = PClass::FindClass((ENamedName)GetClass()->Meta.GetMetaInt(AMETA_BloodType, NAME_Blood)); + } + else if (type == 1) + { + bloodcls = PClass::FindClass((ENamedName)GetClass()->Meta.GetMetaInt(AMETA_BloodType2, NAME_BloodSplatter)); + } + else if (type == 2) + { + bloodcls = PClass::FindClass((ENamedName)GetClass()->Meta.GetMetaInt(AMETA_BloodType3, NAME_AxeBlood)); + } + else return NULL; + + if (bloodcls != NULL) + { + bloodcls = bloodcls->GetReplacement(); + } + return bloodcls; + } + // 'absolute' is reserved for a linked portal implementation which needs // to distinguish between portal-aware and portal-unaware distance calculation. fixed_t AproxDistance(AActor *other, bool absolute = false) @@ -909,345 +909,345 @@ public: return R_PointToAngle2(myx, myy, other->x, other->y); } - inline void SetFriendPlayer(player_t *player); - - bool IsVisibleToPlayer() const; - - // Calculate amount of missile damage - virtual int GetMissileDamage(int mask, int add); - - bool CanSeek(AActor *target) const; - - fixed_t GetGravity() const; - bool IsSentient() const; - const char *GetTag(const char *def = NULL) const; - void SetTag(const char *def); - - // Triggers SECSPAC_Exit/SECSPAC_Enter and related events if oldsec != current sector - void CheckSectorTransition(sector_t *oldsec); - -// info for drawing -// NOTE: The first member variable *must* be x. - fixed_t x,y,z; - AActor *snext, **sprev; // links in sector (if needed) - angle_t angle; - WORD sprite; // used to find patch_t and flip value - BYTE frame; // sprite frame to draw - fixed_t scaleX, scaleY; // Scaling values; FRACUNIT is normal size - FRenderStyle RenderStyle; // Style to draw this actor with - ActorRenderFlags renderflags; // Different rendering flags - FTextureID picnum; // Draw this instead of sprite if valid - DWORD effects; // [RH] see p_effect.h - fixed_t alpha; - DWORD fillcolor; // Color to draw when STYLE_Shaded - -// interaction info - fixed_t pitch; - angle_t roll; // This was fixed_t before, which is probably wrong - FBlockNode *BlockNode; // links in blocks (if needed) - struct sector_t *Sector; - subsector_t * subsector; - fixed_t floorz, ceilingz; // closest together of contacted secs - fixed_t dropoffz; // killough 11/98: the lowest floor over all contacted Sectors. - - struct sector_t *floorsector; - FTextureID floorpic; // contacted sec floorpic - int floorterrain; - struct sector_t *ceilingsector; - FTextureID ceilingpic; // contacted sec ceilingpic - fixed_t radius, height; // for movement checking - fixed_t projectilepassheight; // height for clipping projectile movement against this actor - fixed_t velx, vely, velz; // velocity - SDWORD tics; // state tic counter - FState *state; - SDWORD Damage; // For missiles and monster railgun - int projectileKickback; - ActorFlags flags; - ActorFlags2 flags2; // Heretic flags - ActorFlags3 flags3; // [RH] Hexen/Heretic actor-dependant behavior made flaggable - ActorFlags4 flags4; // [RH] Even more flags! - ActorFlags5 flags5; // OMG! We need another one. - ActorFlags6 flags6; // Shit! Where did all the flags go? - ActorFlags7 flags7; // WHO WANTS TO BET ON 8!? - - // [BB] If 0, everybody can see the actor, if > 0, only members of team (VisibleToTeam-1) can see it. - DWORD VisibleToTeam; - - int special1; // Special info - int special2; // Special info - int weaponspecial; // Special info for weapons. - int health; - BYTE movedir; // 0-7 - SBYTE visdir; - SWORD movecount; // when 0, select a new dir - SWORD strafecount; // for MF3_AVOIDMELEE - TObjPtr target; // thing being chased/attacked (or NULL) - // also the originator for missiles - TObjPtr lastenemy; // Last known enemy -- killough 2/15/98 - TObjPtr LastHeard; // [RH] Last actor this one heard - SDWORD reactiontime; // if non 0, don't attack yet; used by - // player to freeze a bit after teleporting - SDWORD threshold; // if > 0, the target will be chased - // no matter what (even if shot) - player_t *player; // only valid if type of APlayerPawn - TObjPtr LastLookActor; // Actor last looked for (if TIDtoHate != 0) - fixed_t SpawnPoint[3]; // For nightmare respawn - WORD SpawnAngle; - int StartHealth; - BYTE WeaveIndexXY; // Separated from special2 because it's used by globally accessible functions. - BYTE WeaveIndexZ; - int skillrespawncount; - int TIDtoHate; // TID of things to hate (0 if none) - FNameNoInit Species; // For monster families - TObjPtr tracer; // Thing being chased/attacked for tracers - TObjPtr master; // Thing which spawned this one (prevents mutual attacks) - fixed_t floorclip; // value to use for floor clipping - int tid; // thing identifier - int special; // special - int args[5]; // special arguments - - int accuracy, stamina; // [RH] Strife stats -- [XA] moved here for DECORATE/ACS access. - - AActor *inext, **iprev;// Links to other mobjs in same bucket - TObjPtr goal; // Monster's goal if not chasing anything - int waterlevel; // 0=none, 1=feet, 2=waist, 3=eyes - BYTE boomwaterlevel; // splash information for non-swimmable water sectors - BYTE MinMissileChance;// [RH] If a random # is > than this, then missile attack. - SBYTE LastLookPlayerNumber;// Player number last looked for (if TIDtoHate == 0) - ActorBounceFlags BounceFlags; // which bouncing type? - DWORD SpawnFlags; // Increased to DWORD because of Doom 64 - fixed_t meleerange; // specifies how far a melee attack reaches. - fixed_t meleethreshold; // Distance below which a monster doesn't try to shoot missiles anynore - // but instead tries to come closer for a melee attack. - // This is not the same as meleerange - fixed_t maxtargetrange; // any target farther away cannot be attacked - fixed_t bouncefactor; // Strife's grenades use 50%, Hexen's Flechettes 70. - fixed_t wallbouncefactor; // The bounce factor for walls can be different. - int bouncecount; // Strife's grenades only bounce twice before exploding - fixed_t gravity; // [GRB] Gravity factor - fixed_t Friction; - int FastChaseStrafeCount; - fixed_t pushfactor; - int lastpush; - int activationtype; // How the thing behaves when activated with USESPECIAL or BUMPSPECIAL - int lastbump; // Last time the actor was bumped, used to control BUMPSPECIAL - int Score; // manipulated by score items, ACS or DECORATE. The engine doesn't use this itself for anything. - FString * Tag; // Strife's tag name. - int DesignatedTeam; // Allow for friendly fire cacluations to be done on non-players. - - AActor *BlockingMobj; // Actor that blocked the last move - line_t *BlockingLine; // Line that blocked the last move - - int PoisonDamage; // Damage received per tic from poison. - FNameNoInit PoisonDamageType; // Damage type dealt by poison. - int PoisonDuration; // Duration left for receiving poison damage. - int PoisonPeriod; // How often poison damage is applied. (Every X tics.) - - int PoisonDamageReceived; // Damage received per tic from poison. - FNameNoInit PoisonDamageTypeReceived; // Damage type received by poison. - int PoisonDurationReceived; // Duration left for receiving poison damage. - int PoisonPeriodReceived; // How often poison damage is applied. (Every X tics.) - TObjPtr Poisoner; // Last source of received poison damage. - - // a linked list of sectors where this object appears - struct msecnode_t *touching_sectorlist; // phares 3/14/98 - - TObjPtr Inventory; // [RH] This actor's inventory - DWORD InventoryID; // A unique ID to keep track of inventory items - - BYTE smokecounter; - BYTE FloatBobPhase; - BYTE FriendPlayer; // [RH] Player # + 1 this friendly monster works for (so 0 is no player, 1 is player 0, etc) - DWORD Translation; - - // [RH] Stuff that used to be part of an Actor Info - FSoundIDNoInit SeeSound; - FSoundIDNoInit AttackSound; - FSoundIDNoInit PainSound; - FSoundIDNoInit DeathSound; - FSoundIDNoInit ActiveSound; - FSoundIDNoInit UseSound; // [RH] Sound to play when an actor is used. - FSoundIDNoInit BounceSound; - FSoundIDNoInit WallBounceSound; - FSoundIDNoInit CrushPainSound; - - fixed_t Speed; - fixed_t FloatSpeed; - fixed_t MaxDropOffHeight, MaxStepHeight; - SDWORD Mass; - SWORD PainChance; - int PainThreshold; - FNameNoInit DamageType; - FNameNoInit DamageTypeReceived; - fixed_t DamageFactor; - fixed_t DamageMultiply; - - FNameNoInit PainType; - FNameNoInit DeathType; - const PClass *TeleFogSourceType; - const PClass *TeleFogDestType; - int RipperLevel; - int RipLevelMin; - int RipLevelMax; - - FState *SpawnState; - FState *SeeState; - FState *MeleeState; - FState *MissileState; - - - int ConversationRoot; // THe root of the current dialogue - FStrifeDialogueNode *Conversation; // [RH] The dialogue to show when this actor is "used." - - // [RH] Decal(s) this weapon/projectile generates on impact. - FDecalBase *DecalGenerator; - - // [RH] Used to interpolate the view to get >35 FPS - fixed_t PrevX, PrevY, PrevZ; - angle_t PrevAngle; - - // ThingIDs - static void ClearTIDHashes (); - void AddToHash (); - void RemoveFromHash (); - -private: - static AActor *TIDHash[128]; - static inline int TIDHASH (int key) { return key & 127; } - static FSharedStringArena mStringPropertyData; - - friend class FActorIterator; - friend bool P_IsTIDUsed(int tid); - - sector_t *LinkToWorldForMapThing (); - -public: - void LinkToWorld (bool buggy=false); - void LinkToWorld (sector_t *sector); - void UnlinkFromWorld (); - void AdjustFloorClip (); - void SetOrigin (fixed_t x, fixed_t y, fixed_t z); - bool InStateSequence(FState * newstate, FState * basestate); - int GetTics(FState * newstate); - bool SetState (FState *newstate, bool nofunction=false); - virtual bool UpdateWaterLevel (fixed_t oldz, bool splash=true); - bool isFast(); - bool isSlow(); - void SetIdle(bool nofunction=false); - void ClearCounters(); - FState *GetRaiseState(); - void Revive(); - - FState *FindState (FName label) const - { - return GetClass()->ActorInfo->FindState(1, &label); - } - - FState *FindState (FName label, FName sublabel, bool exact = false) const - { - FName names[] = { label, sublabel }; - return GetClass()->ActorInfo->FindState(2, names, exact); - } - - FState *FindState(int numnames, FName *names, bool exact = false) const - { - return GetClass()->ActorInfo->FindState(numnames, names, exact); - } - - bool HasSpecialDeathStates () const; - - // begin of GZDoom specific additions - TArray > dynamiclights; - void * lightassociations; - bool hasmodel; - // end of GZDoom specific additions - - size_t PropagateMark(); -}; - -class FActorIterator -{ -public: - FActorIterator (int i) : base (NULL), id (i) - { - } - FActorIterator (int i, AActor *start) : base (start), id (i) - { - } - AActor *Next () - { - if (id == 0) - return NULL; - if (!base) - base = AActor::TIDHash[id & 127]; - else - base = base->inext; - - while (base && base->tid != id) - base = base->inext; - - return base; - } -private: - AActor *base; - int id; -}; - -template -class TActorIterator : public FActorIterator -{ -public: - TActorIterator (int id) : FActorIterator (id) {} - T *Next () - { - AActor *actor; - do - { - actor = FActorIterator::Next (); - } while (actor && !actor->IsKindOf (RUNTIME_CLASS(T))); - return static_cast(actor); - } -}; - -class NActorIterator : public FActorIterator -{ - const PClass *type; -public: - NActorIterator (const PClass *cls, int id) : FActorIterator (id) { type = cls; } - NActorIterator (FName cls, int id) : FActorIterator (id) { type = PClass::FindClass(cls); } - NActorIterator (const char *cls, int id) : FActorIterator (id) { type = PClass::FindClass(cls); } - AActor *Next () - { - AActor *actor; - if (type == NULL) return NULL; - do - { - actor = FActorIterator::Next (); - } while (actor && !actor->IsKindOf (type)); - return actor; - } -}; - -bool P_IsTIDUsed(int tid); -int P_FindUniqueTID(int start_tid, int limit); - -inline AActor *Spawn (const PClass *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement) -{ - return AActor::StaticSpawn (type, x, y, z, allowreplacement); -} - -AActor *Spawn (const char *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement); -AActor *Spawn (FName classname, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement); - -template -inline T *Spawn (fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement) -{ - return static_cast(AActor::StaticSpawn (RUNTIME_CLASS(T), x, y, z, allowreplacement)); -} - - -void PrintMiscActorInfo(AActor * query); - -#define S_FREETARGMOBJ 1 - -#endif // __P_MOBJ_H__ + inline void SetFriendPlayer(player_t *player); + + bool IsVisibleToPlayer() const; + + // Calculate amount of missile damage + virtual int GetMissileDamage(int mask, int add); + + bool CanSeek(AActor *target) const; + + fixed_t GetGravity() const; + bool IsSentient() const; + const char *GetTag(const char *def = NULL) const; + void SetTag(const char *def); + + // Triggers SECSPAC_Exit/SECSPAC_Enter and related events if oldsec != current sector + void CheckSectorTransition(sector_t *oldsec); + +// info for drawing +// NOTE: The first member variable *must* be x. + fixed_t x,y,z; + AActor *snext, **sprev; // links in sector (if needed) + angle_t angle; + WORD sprite; // used to find patch_t and flip value + BYTE frame; // sprite frame to draw + fixed_t scaleX, scaleY; // Scaling values; FRACUNIT is normal size + FRenderStyle RenderStyle; // Style to draw this actor with + ActorRenderFlags renderflags; // Different rendering flags + FTextureID picnum; // Draw this instead of sprite if valid + DWORD effects; // [RH] see p_effect.h + fixed_t alpha; + DWORD fillcolor; // Color to draw when STYLE_Shaded + +// interaction info + fixed_t pitch; + angle_t roll; // This was fixed_t before, which is probably wrong + FBlockNode *BlockNode; // links in blocks (if needed) + struct sector_t *Sector; + subsector_t * subsector; + fixed_t floorz, ceilingz; // closest together of contacted secs + fixed_t dropoffz; // killough 11/98: the lowest floor over all contacted Sectors. + + struct sector_t *floorsector; + FTextureID floorpic; // contacted sec floorpic + int floorterrain; + struct sector_t *ceilingsector; + FTextureID ceilingpic; // contacted sec ceilingpic + fixed_t radius, height; // for movement checking + fixed_t projectilepassheight; // height for clipping projectile movement against this actor + fixed_t velx, vely, velz; // velocity + SDWORD tics; // state tic counter + FState *state; + SDWORD Damage; // For missiles and monster railgun + int projectileKickback; + ActorFlags flags; + ActorFlags2 flags2; // Heretic flags + ActorFlags3 flags3; // [RH] Hexen/Heretic actor-dependant behavior made flaggable + ActorFlags4 flags4; // [RH] Even more flags! + ActorFlags5 flags5; // OMG! We need another one. + ActorFlags6 flags6; // Shit! Where did all the flags go? + ActorFlags7 flags7; // WHO WANTS TO BET ON 8!? + + // [BB] If 0, everybody can see the actor, if > 0, only members of team (VisibleToTeam-1) can see it. + DWORD VisibleToTeam; + + int special1; // Special info + int special2; // Special info + int weaponspecial; // Special info for weapons. + int health; + BYTE movedir; // 0-7 + SBYTE visdir; + SWORD movecount; // when 0, select a new dir + SWORD strafecount; // for MF3_AVOIDMELEE + TObjPtr target; // thing being chased/attacked (or NULL) + // also the originator for missiles + TObjPtr lastenemy; // Last known enemy -- killough 2/15/98 + TObjPtr LastHeard; // [RH] Last actor this one heard + SDWORD reactiontime; // if non 0, don't attack yet; used by + // player to freeze a bit after teleporting + SDWORD threshold; // if > 0, the target will be chased + // no matter what (even if shot) + player_t *player; // only valid if type of APlayerPawn + TObjPtr LastLookActor; // Actor last looked for (if TIDtoHate != 0) + fixed_t SpawnPoint[3]; // For nightmare respawn + WORD SpawnAngle; + int StartHealth; + BYTE WeaveIndexXY; // Separated from special2 because it's used by globally accessible functions. + BYTE WeaveIndexZ; + int skillrespawncount; + int TIDtoHate; // TID of things to hate (0 if none) + FNameNoInit Species; // For monster families + TObjPtr tracer; // Thing being chased/attacked for tracers + TObjPtr master; // Thing which spawned this one (prevents mutual attacks) + fixed_t floorclip; // value to use for floor clipping + int tid; // thing identifier + int special; // special + int args[5]; // special arguments + + int accuracy, stamina; // [RH] Strife stats -- [XA] moved here for DECORATE/ACS access. + + AActor *inext, **iprev;// Links to other mobjs in same bucket + TObjPtr goal; // Monster's goal if not chasing anything + int waterlevel; // 0=none, 1=feet, 2=waist, 3=eyes + BYTE boomwaterlevel; // splash information for non-swimmable water sectors + BYTE MinMissileChance;// [RH] If a random # is > than this, then missile attack. + SBYTE LastLookPlayerNumber;// Player number last looked for (if TIDtoHate == 0) + ActorBounceFlags BounceFlags; // which bouncing type? + DWORD SpawnFlags; // Increased to DWORD because of Doom 64 + fixed_t meleerange; // specifies how far a melee attack reaches. + fixed_t meleethreshold; // Distance below which a monster doesn't try to shoot missiles anynore + // but instead tries to come closer for a melee attack. + // This is not the same as meleerange + fixed_t maxtargetrange; // any target farther away cannot be attacked + fixed_t bouncefactor; // Strife's grenades use 50%, Hexen's Flechettes 70. + fixed_t wallbouncefactor; // The bounce factor for walls can be different. + int bouncecount; // Strife's grenades only bounce twice before exploding + fixed_t gravity; // [GRB] Gravity factor + fixed_t Friction; + int FastChaseStrafeCount; + fixed_t pushfactor; + int lastpush; + int activationtype; // How the thing behaves when activated with USESPECIAL or BUMPSPECIAL + int lastbump; // Last time the actor was bumped, used to control BUMPSPECIAL + int Score; // manipulated by score items, ACS or DECORATE. The engine doesn't use this itself for anything. + FString * Tag; // Strife's tag name. + int DesignatedTeam; // Allow for friendly fire cacluations to be done on non-players. + + AActor *BlockingMobj; // Actor that blocked the last move + line_t *BlockingLine; // Line that blocked the last move + + int PoisonDamage; // Damage received per tic from poison. + FNameNoInit PoisonDamageType; // Damage type dealt by poison. + int PoisonDuration; // Duration left for receiving poison damage. + int PoisonPeriod; // How often poison damage is applied. (Every X tics.) + + int PoisonDamageReceived; // Damage received per tic from poison. + FNameNoInit PoisonDamageTypeReceived; // Damage type received by poison. + int PoisonDurationReceived; // Duration left for receiving poison damage. + int PoisonPeriodReceived; // How often poison damage is applied. (Every X tics.) + TObjPtr Poisoner; // Last source of received poison damage. + + // a linked list of sectors where this object appears + struct msecnode_t *touching_sectorlist; // phares 3/14/98 + + TObjPtr Inventory; // [RH] This actor's inventory + DWORD InventoryID; // A unique ID to keep track of inventory items + + BYTE smokecounter; + BYTE FloatBobPhase; + BYTE FriendPlayer; // [RH] Player # + 1 this friendly monster works for (so 0 is no player, 1 is player 0, etc) + DWORD Translation; + + // [RH] Stuff that used to be part of an Actor Info + FSoundIDNoInit SeeSound; + FSoundIDNoInit AttackSound; + FSoundIDNoInit PainSound; + FSoundIDNoInit DeathSound; + FSoundIDNoInit ActiveSound; + FSoundIDNoInit UseSound; // [RH] Sound to play when an actor is used. + FSoundIDNoInit BounceSound; + FSoundIDNoInit WallBounceSound; + FSoundIDNoInit CrushPainSound; + + fixed_t Speed; + fixed_t FloatSpeed; + fixed_t MaxDropOffHeight, MaxStepHeight; + SDWORD Mass; + SWORD PainChance; + int PainThreshold; + FNameNoInit DamageType; + FNameNoInit DamageTypeReceived; + fixed_t DamageFactor; + fixed_t DamageMultiply; + + FNameNoInit PainType; + FNameNoInit DeathType; + const PClass *TeleFogSourceType; + const PClass *TeleFogDestType; + int RipperLevel; + int RipLevelMin; + int RipLevelMax; + + FState *SpawnState; + FState *SeeState; + FState *MeleeState; + FState *MissileState; + + + int ConversationRoot; // THe root of the current dialogue + FStrifeDialogueNode *Conversation; // [RH] The dialogue to show when this actor is "used." + + // [RH] Decal(s) this weapon/projectile generates on impact. + FDecalBase *DecalGenerator; + + // [RH] Used to interpolate the view to get >35 FPS + fixed_t PrevX, PrevY, PrevZ; + angle_t PrevAngle; + + // ThingIDs + static void ClearTIDHashes (); + void AddToHash (); + void RemoveFromHash (); + +private: + static AActor *TIDHash[128]; + static inline int TIDHASH (int key) { return key & 127; } + static FSharedStringArena mStringPropertyData; + + friend class FActorIterator; + friend bool P_IsTIDUsed(int tid); + + sector_t *LinkToWorldForMapThing (); + +public: + void LinkToWorld (bool buggy=false); + void LinkToWorld (sector_t *sector); + void UnlinkFromWorld (); + void AdjustFloorClip (); + void SetOrigin (fixed_t x, fixed_t y, fixed_t z); + bool InStateSequence(FState * newstate, FState * basestate); + int GetTics(FState * newstate); + bool SetState (FState *newstate, bool nofunction=false); + virtual bool UpdateWaterLevel (fixed_t oldz, bool splash=true); + bool isFast(); + bool isSlow(); + void SetIdle(bool nofunction=false); + void ClearCounters(); + FState *GetRaiseState(); + void Revive(); + + FState *FindState (FName label) const + { + return GetClass()->ActorInfo->FindState(1, &label); + } + + FState *FindState (FName label, FName sublabel, bool exact = false) const + { + FName names[] = { label, sublabel }; + return GetClass()->ActorInfo->FindState(2, names, exact); + } + + FState *FindState(int numnames, FName *names, bool exact = false) const + { + return GetClass()->ActorInfo->FindState(numnames, names, exact); + } + + bool HasSpecialDeathStates () const; + + // begin of GZDoom specific additions + TArray > dynamiclights; + void * lightassociations; + bool hasmodel; + // end of GZDoom specific additions + + size_t PropagateMark(); +}; + +class FActorIterator +{ +public: + FActorIterator (int i) : base (NULL), id (i) + { + } + FActorIterator (int i, AActor *start) : base (start), id (i) + { + } + AActor *Next () + { + if (id == 0) + return NULL; + if (!base) + base = AActor::TIDHash[id & 127]; + else + base = base->inext; + + while (base && base->tid != id) + base = base->inext; + + return base; + } +private: + AActor *base; + int id; +}; + +template +class TActorIterator : public FActorIterator +{ +public: + TActorIterator (int id) : FActorIterator (id) {} + T *Next () + { + AActor *actor; + do + { + actor = FActorIterator::Next (); + } while (actor && !actor->IsKindOf (RUNTIME_CLASS(T))); + return static_cast(actor); + } +}; + +class NActorIterator : public FActorIterator +{ + const PClass *type; +public: + NActorIterator (const PClass *cls, int id) : FActorIterator (id) { type = cls; } + NActorIterator (FName cls, int id) : FActorIterator (id) { type = PClass::FindClass(cls); } + NActorIterator (const char *cls, int id) : FActorIterator (id) { type = PClass::FindClass(cls); } + AActor *Next () + { + AActor *actor; + if (type == NULL) return NULL; + do + { + actor = FActorIterator::Next (); + } while (actor && !actor->IsKindOf (type)); + return actor; + } +}; + +bool P_IsTIDUsed(int tid); +int P_FindUniqueTID(int start_tid, int limit); + +inline AActor *Spawn (const PClass *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement) +{ + return AActor::StaticSpawn (type, x, y, z, allowreplacement); +} + +AActor *Spawn (const char *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement); +AActor *Spawn (FName classname, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement); + +template +inline T *Spawn (fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement) +{ + return static_cast(AActor::StaticSpawn (RUNTIME_CLASS(T), x, y, z, allowreplacement)); +} + + +void PrintMiscActorInfo(AActor * query); + +#define S_FREETARGMOBJ 1 + +#endif // __P_MOBJ_H__ diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index bff47e47a..c2087f2f4 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -45,6 +45,7 @@ #include "c_dispatch.h" #include "doomstat.h" #include "a_sharedglobal.h" +#include "r_sky.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" @@ -533,7 +534,7 @@ void GLPortal::EndFrame() //----------------------------------------------------------------------------- // // Renders one sky portal without a stencil. -// In more complex scenes using a stencil for skies can severly stall +// In more complex scenes using a stencil for skies can severely stall // the GPU and there's rarely more than one sky visible at a time. // //----------------------------------------------------------------------------- @@ -1080,6 +1081,69 @@ void GLHorizonPortal::DrawContents() gl_RenderState.EnableTextureMatrix(false); PortalAll.Unclock(); +} + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Eternity-style horizon portal +// +// To the rest of the engine these masquerade as a skybox portal +// Internally they need to draw two horizon or sky portals +// and will use the respective classes to achieve that. +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void GLEEHorizonPortal::DrawContents() +{ + PortalAll.Clock(); + if (origin->Sector->GetTexture(sector_t::floor) == skyflatnum || + origin->Sector->GetTexture(sector_t::ceiling) == skyflatnum) + { + GLSkyInfo skyinfo; + skyinfo.init(origin->Sector->sky, 0); + GLSkyPortal sky(&skyinfo, true); + sky.DrawContents(); + } + if (origin->Sector->GetTexture(sector_t::ceiling) != skyflatnum) + { + GLHorizonInfo horz; + horz.plane.GetFromSector(origin->Sector, true); + horz.lightlevel = gl_ClampLight(origin->Sector->GetCeilingLight()); + horz.colormap = origin->Sector->ColorMap; + if (origin->flags & MF_FLOAT) + { + horz.plane.texheight = viewz + abs(horz.plane.texheight); + } + GLHorizonPortal ceil(&horz, true); + ceil.DrawContents(); + } + if (origin->Sector->GetTexture(sector_t::floor) != skyflatnum) + { + GLHorizonInfo horz; + horz.plane.GetFromSector(origin->Sector, false); + horz.lightlevel = gl_ClampLight(origin->Sector->GetFloorLight()); + horz.colormap = origin->Sector->ColorMap; + if (origin->flags & MF_FLOAT) + { + horz.plane.texheight = viewz - abs(horz.plane.texheight); + } + GLHorizonPortal floor(&horz, true); + floor.DrawContents(); + } + + + } const char *GLSkyPortal::GetName() { return "Sky"; } @@ -1088,3 +1152,5 @@ const char *GLSectorStackPortal::GetName() { return "Sectorstack"; } const char *GLPlaneMirrorPortal::GetName() { return "Planemirror"; } const char *GLMirrorPortal::GetName() { return "Mirror"; } const char *GLHorizonPortal::GetName() { return "Horizon"; } +const char *GLEEHorizonPortal::GetName() { return "EEHorizon"; } + diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index ccc6d174d..384a34f7d 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -70,11 +70,13 @@ struct GLSkyInfo { return !!memcmp(this, &inf, sizeof(*this)); } + void init(int sky1, PalEntry fadecolor); }; extern UniqueList UniqueSkies; extern UniqueList UniqueHorizons; extern UniqueList UniquePlaneMirrors; +struct GLEEHorizonPortal; class GLPortal { @@ -110,7 +112,7 @@ protected: TArray lines; int level; - GLPortal() { portals.Push(this); } + GLPortal(bool local = false) { if (!local) portals.Push(this); } virtual ~GLPortal() { } bool Start(bool usestencil, bool doquery); @@ -215,6 +217,7 @@ public: struct GLSkyPortal : public GLPortal { GLSkyInfo * origin; + friend struct GLEEHorizonPortal; protected: virtual void DrawContents(); @@ -226,7 +229,8 @@ protected: public: - GLSkyPortal(GLSkyInfo * pt) + GLSkyPortal(GLSkyInfo * pt, bool local = false) + : GLPortal(local) { origin=pt; } @@ -281,6 +285,7 @@ public: struct GLHorizonPortal : public GLPortal { GLHorizonInfo * origin; + friend struct GLEEHorizonPortal; protected: virtual void DrawContents(); @@ -291,7 +296,28 @@ protected: public: - GLHorizonPortal(GLHorizonInfo * pt) + GLHorizonPortal(GLHorizonInfo * pt, bool local = false) + : GLPortal(local) + { + origin=pt; + } + +}; + +struct GLEEHorizonPortal : public GLPortal +{ + AActor * origin; + +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return origin; } + virtual bool NeedDepthBuffer() { return false; } + virtual bool NeedCap() { return false; } + virtual const char *GetName(); + +public: + + GLEEHorizonPortal(AActor *pt) { origin=pt; } diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 38dbfca49..c4a6c1c60 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -63,6 +63,72 @@ enum }; +//========================================================================== +// +// Set up the skyinfo struct +// +//========================================================================== + +void GLSkyInfo::init(int sky1, PalEntry FadeColor) +{ + memset(this, 0, sizeof(*this)); + if ((sky1 & PL_SKYFLAT) && (sky1 & (PL_SKYFLAT - 1))) + { + const line_t *l = &lines[(sky1&(PL_SKYFLAT - 1)) - 1]; + const side_t *s = l->sidedef[0]; + int pos; + + if (level.flags & LEVEL_SWAPSKIES && s->GetTexture(side_t::bottom).isValid()) + { + pos = side_t::bottom; + } + else + { + pos = side_t::top; + } + + FTextureID texno = s->GetTexture(pos); + texture[0] = FMaterial::ValidateTexture(texno, false, true); + if (!texture[0] || texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky; + skytexno1 = texno; + x_offset[0] = ANGLE_TO_FLOAT(s->GetTextureXOffset(pos)); + y_offset = FIXED2FLOAT(s->GetTextureYOffset(pos)); + mirrored = !l->args[2]; + } + else + { + normalsky: + if (level.flags&LEVEL_DOUBLESKY) + { + texture[1] = FMaterial::ValidateTexture(sky1texture, false, true); + x_offset[1] = GLRenderer->mSky1Pos; + doublesky = true; + } + + if ((level.flags&LEVEL_SWAPSKIES || (sky1 == PL_SKYFLAT) || (level.flags&LEVEL_DOUBLESKY)) && + sky2texture != sky1texture) // If both skies are equal use the scroll offset of the first! + { + texture[0] = FMaterial::ValidateTexture(sky2texture, false, true); + skytexno1 = sky2texture; + sky2 = true; + x_offset[0] = GLRenderer->mSky2Pos; + } + else if (!doublesky) + { + texture[0] = FMaterial::ValidateTexture(sky1texture, false, true); + skytexno1 = sky1texture; + x_offset[0] = GLRenderer->mSky1Pos; + } + } + if (skyfog > 0) + { + fadecolor = FadeColor; + fadecolor.a = 0; + } + else fadecolor = 0; + +} + //========================================================================== // // Calculate sky texture @@ -92,64 +158,8 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) } else { - int sky1 = sector->sky; - memset(&skyinfo, 0, sizeof(skyinfo)); - if ((sky1 & PL_SKYFLAT) && (sky1 & (PL_SKYFLAT-1))) - { - const line_t *l = &lines[(sky1&(PL_SKYFLAT-1))-1]; - const side_t *s = l->sidedef[0]; - int pos; - - if (level.flags & LEVEL_SWAPSKIES && s->GetTexture(side_t::bottom).isValid()) - { - pos = side_t::bottom; - } - else - { - pos = side_t::top; - } - - FTextureID texno = s->GetTexture(pos); - skyinfo.texture[0] = FMaterial::ValidateTexture(texno, false, true); - if (!skyinfo.texture[0] || skyinfo.texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky; - skyinfo.skytexno1 = texno; - skyinfo.x_offset[0] = ANGLE_TO_FLOAT(s->GetTextureXOffset(pos)); - skyinfo.y_offset = FIXED2FLOAT(s->GetTextureYOffset(pos)); - skyinfo.mirrored = !l->args[2]; - } - else - { - normalsky: - if (level.flags&LEVEL_DOUBLESKY) - { - skyinfo.texture[1]=FMaterial::ValidateTexture(sky1texture, false, true); - skyinfo.x_offset[1] = GLRenderer->mSky1Pos; - skyinfo.doublesky = true; - } - - if ((level.flags&LEVEL_SWAPSKIES || (sky1==PL_SKYFLAT) || (level.flags&LEVEL_DOUBLESKY)) && - sky2texture!=sky1texture) // If both skies are equal use the scroll offset of the first! - { - skyinfo.texture[0]=FMaterial::ValidateTexture(sky2texture, false, true); - skyinfo.skytexno1=sky2texture; - skyinfo.sky2 = true; - skyinfo.x_offset[0] = GLRenderer->mSky2Pos; - } - else - { - skyinfo.texture[0]=FMaterial::ValidateTexture(sky1texture, false, true); - skyinfo.skytexno1=sky1texture; - skyinfo.x_offset[0] = GLRenderer->mSky1Pos; - } - } - if (skyfog>0) - { - skyinfo.fadecolor=Colormap.FadeColor; - skyinfo.fadecolor.a=0; - } - else skyinfo.fadecolor=0; - - type=RENDERWALL_SKY; + skyinfo.init(sector->sky, Colormap.FadeColor); + type = RENDERWALL_SKY; sky=UniqueSkies.Get(&skyinfo); } } @@ -194,7 +204,7 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex { if (fs->GetTexture(sector_t::ceiling)==skyflatnum) { - if ((bs->special&0xff) == NoSkyDraw) return; + if (bs->special == NoSkyDraw) return; if (bs->GetTexture(sector_t::ceiling)==skyflatnum) { // if the back sector is closed the sky must be drawn! @@ -285,7 +295,7 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver { if (fs->GetTexture(sector_t::floor)==skyflatnum) { - if ((bs->special&0xff) == NoSkyDraw) return; + if (bs->special == NoSkyDraw) return; FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::bottom)); // For lower skies the normal logic only applies to walls with no lower texture! diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index a906c47aa..68a60f062 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -176,8 +176,13 @@ void GLWall::PutWall(bool translucent) break; case RENDERWALL_SKYBOX: - portal=GLPortal::FindPortal(skybox); - if (!portal) portal=new GLSkyboxPortal(skybox); + portal = GLPortal::FindPortal(skybox); + if (!portal) + { + // either a regulat skybox or an Eternity-style horizon + if (skybox->flags7 & MF7_HANDLENODELAY) portal = new GLEEHorizonPortal(skybox); + else portal = new GLSkyboxPortal(skybox); + } portal->AddLine(this); break; diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 698cf4f72..d43cd70e9 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -65,6 +65,7 @@ // State. #include "r_state.h" +#include "r_sky.h" #include "c_console.h" @@ -986,7 +987,7 @@ void P_SetupPortals() } } -inline void SetPortal(sector_t *sector, int plane, AStackPoint *portal, fixed_t alpha) +inline void SetPortal(sector_t *sector, int plane, ASkyViewpoint *portal, fixed_t alpha) { // plane: 0=floor, 1=ceiling, 2=both if (plane > 0) @@ -996,6 +997,8 @@ inline void SetPortal(sector_t *sector, int plane, AStackPoint *portal, fixed_t sector->CeilingSkyBox = portal; if (sector->GetAlpha(sector_t::ceiling) == OPAQUE) sector->SetAlpha(sector_t::ceiling, alpha); + + if (!portal->bAlways) sector->SetTexture(sector_t::ceiling, skyflatnum); } } if (plane == 2 || plane == 0) @@ -1006,6 +1009,8 @@ inline void SetPortal(sector_t *sector, int plane, AStackPoint *portal, fixed_t } if (sector->GetAlpha(sector_t::floor) == OPAQUE) sector->SetAlpha(sector_t::floor, alpha); + + if (!portal->bAlways) sector->SetTexture(sector_t::floor, skyflatnum); } } @@ -1076,6 +1081,47 @@ void P_SpawnPortal(line_t *line, int sectortag, int plane, int alpha) } +void P_SpawnHorizon(line_t *line) +{ + ASkyViewpoint *origin = Spawn(0, 0, 0, NO_REPLACE); + origin->Sector = line->frontsector; + origin->flags7 |= MF7_HANDLENODELAY; // mark as 'special' + if (line->args[1] == 3) origin->flags |= MF_FLOAT; // well, it actually does 'float'... :P + + + int s; + FSectorTagIterator itr(line->args[0]); + while ((s = itr.Next()) >= 0) + { + SetPortal(§ors[s], line->args[2], origin, 0); + } + + for (int j=0;jargs[2] || lines[j].args[2] == 3) && + lines[j].args[3] == line->args[0]) + { + if (lines[j].args[0] == 0) + { + SetPortal(lines[j].frontsector, line->args[2], origin, 0); + } + else + { + FSectorTagIterator itr(lines[j].args[0]); + while ((s = itr.Next()) >= 0) + { + SetPortal(§ors[s], line->args[2], origin, 0); + } + } + } + } +} + + // // P_SetSectorDamage // @@ -1408,6 +1454,8 @@ void P_SpawnSpecials (void) // - 0: normal (handled here) // - 1: copy (handled by the portal they copy) // - 2: EE-style skybox (handled by the camera object) + // - 3: EE-style flat portal (HW renderer only for now) + // - 4: EE-style horizon portal (HW renderer only for now) // other values reserved for later use // arg 2 = 0:floor, 1:ceiling, 2:both // arg 3 = 0: anchor, 1: reference line @@ -1416,6 +1464,10 @@ void P_SpawnSpecials (void) { P_SpawnPortal(&lines[i], lines[i].args[0], lines[i].args[2], lines[i].args[4]); } + else if (lines[i].args[1] == 3 || lines[i].args[1] == 4) + { + P_SpawnHorizon(&lines[i]); + } break; // [RH] ZDoom Static_Init settings diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 545d009d9..b7fd7b4f6 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -1088,6 +1088,7 @@ void R_Subsector (subsector_t *sub) } skybox = frontsector->GetSkyBox(sector_t::ceiling); + if (skybox->flags7 & MF7_HANDLENODELAY) skybox = NULL; // HW renderer only. ceilingplane = frontsector->ceilingplane.PointOnSide(viewx, viewy, viewz) > 0 || frontsector->GetTexture(sector_t::ceiling) == skyflatnum || @@ -1128,7 +1129,10 @@ void R_Subsector (subsector_t *sub) // killough 3/7/98: Add (x,y) offsets to flats, add deep water check // killough 3/16/98: add floorlightlevel // killough 10/98: add support for skies transferred from sidedefs + skybox = frontsector->GetSkyBox(sector_t::floor); + if (skybox->flags7 & MF7_HANDLENODELAY) skybox = NULL; // HW renderer only. + floorplane = frontsector->floorplane.PointOnSide(viewx, viewy, viewz) > 0 || // killough 3/7/98 frontsector->GetTexture(sector_t::floor) == skyflatnum || (skybox != NULL && skybox->bAlways) || From 0e017f1e2d60736dbbb5bfc4fd15e0a6b2ac2e24 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Jan 2016 15:40:25 +0100 Subject: [PATCH 0351/1509] - cleaned up the merge and consolidated redundant code. --- src/p_spec.cpp | 61 +++++++++++--------------------------------------- 1 file changed, 13 insertions(+), 48 deletions(-) diff --git a/src/p_spec.cpp b/src/p_spec.cpp index e4f98f07f..4a3df3994 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -66,7 +66,6 @@ // State. #include "r_state.h" -#include "r_sky.h" #include "c_console.h" @@ -1080,7 +1079,7 @@ void P_SpawnPortal(line_t *line, int sectortag, int plane, int alpha) CopyPortal(sectortag, plane, reference, alpha, false); return; - } + } } } @@ -1090,68 +1089,28 @@ void P_SpawnSkybox(ASkyViewpoint *origin) { sector_t *Sector = origin->Sector; if (Sector == NULL) - { + { Printf("Sector not initialized for SkyCamCompat\n"); origin->Sector = Sector = P_PointInSector(origin->x, origin->y); } if (Sector) - { + { line_t * refline = NULL; for (short i = 0; i < Sector->linecount; i++) - { + { refline = Sector->lines[i]; if (refline->special == Sector_SetPortal && refline->args[1] == 2) - { + { // We found the setup linedef for this skybox, so let's use it for our init. CopyPortal(refline->args[0], refline->args[2], origin, 0, true); return; - } - } - } -} - - -void P_SpawnHorizon(line_t *line) -{ - ASkyViewpoint *origin = Spawn(0, 0, 0, NO_REPLACE); - origin->Sector = line->frontsector; - origin->flags7 |= MF7_HANDLENODELAY; // mark as 'special' - if (line->args[1] == 3) origin->flags |= MF_FLOAT; // well, it actually does 'float'... :P - - - int s; - FSectorTagIterator itr(line->args[0]); - while ((s = itr.Next()) >= 0) - { - SetPortal(§ors[s], line->args[2], origin, 0); - } - - for (int j=0;jargs[2] || lines[j].args[2] == 3) && - lines[j].args[3] == line->args[0]) - { - if (lines[j].args[0] == 0) - { - SetPortal(lines[j].frontsector, line->args[2], origin, 0); - } - else - { - FSectorTagIterator itr(lines[j].args[0]); - while ((s = itr.Next()) >= 0) - { - SetPortal(§ors[s], line->args[2], origin, 0); - } } } } } + // // P_SetSectorDamage // @@ -1503,7 +1462,13 @@ void P_SpawnSpecials (void) } else if (lines[i].args[1] == 3 || lines[i].args[1] == 4) { - P_SpawnHorizon(&lines[i]); + line_t *line = &lines[i]; + ASkyViewpoint *origin = Spawn(0, 0, 0, NO_REPLACE); + origin->Sector = line->frontsector; + origin->flags7 |= MF7_HANDLENODELAY; // mark as 'special' + if (line->args[1] == 3) origin->flags |= MF_FLOAT; // well, it actually does 'float'... :P + + CopyPortal(line->args[0], line->args[2], origin, 0, true); } break; From 196c9bc34d0654b152465a85fd833d21bf7e9e8a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Jan 2016 20:29:24 +0100 Subject: [PATCH 0352/1509] - cleaned up the skybox type detection logic. --- src/gl/scene/gl_portal.cpp | 4 +-- src/gl/scene/gl_sky.cpp | 51 +++++++++++++++++---------------- src/gl/scene/gl_walls.cpp | 2 +- src/p_spec.cpp | 3 +- src/r_bsp.cpp | 4 +-- src/r_sky.h | 6 ++++ wadsrc/static/xlat/eternity.txt | 12 ++++---- 7 files changed, 45 insertions(+), 37 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index c2087f2f4..cb8f361a9 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -1121,7 +1121,7 @@ void GLEEHorizonPortal::DrawContents() horz.plane.GetFromSector(origin->Sector, true); horz.lightlevel = gl_ClampLight(origin->Sector->GetCeilingLight()); horz.colormap = origin->Sector->ColorMap; - if (origin->flags & MF_FLOAT) + if (origin->special1 == SKYBOX_PLANE) { horz.plane.texheight = viewz + abs(horz.plane.texheight); } @@ -1134,7 +1134,7 @@ void GLEEHorizonPortal::DrawContents() horz.plane.GetFromSector(origin->Sector, false); horz.lightlevel = gl_ClampLight(origin->Sector->GetFloorLight()); horz.colormap = origin->Sector->ColorMap; - if (origin->flags & MF_FLOAT) + if (origin->special1 == SKYBOX_PLANE) { horz.plane.texheight = viewz - abs(horz.plane.texheight); } diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index c4a6c1c60..17e864476 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -139,39 +139,42 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) FPortal *portal = sector->portals[plane]; if (portal != NULL) { - if (GLPortal::instack[1-plane]) return; - type=RENDERWALL_SECTORSTACK; + if (GLPortal::instack[1 - plane]) return; + type = RENDERWALL_SECTORSTACK; this->portal = portal; } - else if (sector->GetTexture(plane)==skyflatnum) + else { - GLSkyInfo skyinfo; ASkyViewpoint * skyboxx = sector->GetSkyBox(plane); - - // JUSTHIT is used as an indicator that a skybox is in use. - // This is to avoid recursion - - if (!gl_noskyboxes && skyboxx && GLRenderer->mViewActor!=skyboxx && !(skyboxx->flags&MF_JUSTHIT)) + if (sector->GetTexture(plane) == skyflatnum || (skyboxx != NULL && skyboxx->bAlways)) { - type=RENDERWALL_SKYBOX; - skybox=skyboxx; + GLSkyInfo skyinfo; + + // JUSTHIT is used as an indicator that a skybox is in use. + // This is to avoid recursion + + if (!gl_noskyboxes && skyboxx && GLRenderer->mViewActor != skyboxx && !(skyboxx->flags&MF_JUSTHIT)) + { + type = RENDERWALL_SKYBOX; + skybox = skyboxx; + } + else + { + skyinfo.init(sector->sky, Colormap.FadeColor); + type = RENDERWALL_SKY; + sky = UniqueSkies.Get(&skyinfo); + } } - else + else if (allowreflect && sector->GetReflect(plane) > 0) { - skyinfo.init(sector->sky, Colormap.FadeColor); - type = RENDERWALL_SKY; - sky=UniqueSkies.Get(&skyinfo); + if ((plane == sector_t::ceiling && viewz > sector->ceilingplane.d) || + (plane == sector_t::floor && viewz < -sector->floorplane.d)) return; + type = RENDERWALL_PLANEMIRROR; + planemirror = plane == sector_t::ceiling ? §or->ceilingplane : §or->floorplane; } + else return; + PutWall(0); } - else if (allowreflect && sector->GetReflect(plane) > 0) - { - if ((plane == sector_t::ceiling && viewz > sector->ceilingplane.d) || - (plane == sector_t::floor && viewz < -sector->floorplane.d)) return; - type=RENDERWALL_PLANEMIRROR; - planemirror = plane == sector_t::ceiling? §or->ceilingplane : §or->floorplane; - } - else return; - PutWall(0); } diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 68a60f062..ad2a3aa93 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -180,7 +180,7 @@ void GLWall::PutWall(bool translucent) if (!portal) { // either a regulat skybox or an Eternity-style horizon - if (skybox->flags7 & MF7_HANDLENODELAY) portal = new GLEEHorizonPortal(skybox); + if (skybox->special1 != SKYBOX_MAP) portal = new GLEEHorizonPortal(skybox); else portal = new GLSkyboxPortal(skybox); } portal->AddLine(this); diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 4a3df3994..fba5e2a2d 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -1465,8 +1465,7 @@ void P_SpawnSpecials (void) line_t *line = &lines[i]; ASkyViewpoint *origin = Spawn(0, 0, 0, NO_REPLACE); origin->Sector = line->frontsector; - origin->flags7 |= MF7_HANDLENODELAY; // mark as 'special' - if (line->args[1] == 3) origin->flags |= MF_FLOAT; // well, it actually does 'float'... :P + origin->special1 = line->args[1] == 3? SKYBOX_PLANE:SKYBOX_HORIZON; CopyPortal(line->args[0], line->args[2], origin, 0, true); } diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index b7fd7b4f6..09c39b49e 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -1088,7 +1088,7 @@ void R_Subsector (subsector_t *sub) } skybox = frontsector->GetSkyBox(sector_t::ceiling); - if (skybox->flags7 & MF7_HANDLENODELAY) skybox = NULL; // HW renderer only. + if (skybox->special1 != SKYBOX_MAP) skybox = NULL; // HW renderer only. ceilingplane = frontsector->ceilingplane.PointOnSide(viewx, viewy, viewz) > 0 || frontsector->GetTexture(sector_t::ceiling) == skyflatnum || @@ -1131,7 +1131,7 @@ void R_Subsector (subsector_t *sub) // killough 10/98: add support for skies transferred from sidedefs skybox = frontsector->GetSkyBox(sector_t::floor); - if (skybox->flags7 & MF7_HANDLENODELAY) skybox = NULL; // HW renderer only. + if (skybox->special1 != SKYBOX_MAP) skybox = NULL; // HW renderer only. floorplane = frontsector->floorplane.PointOnSide(viewx, viewy, viewz) > 0 || // killough 3/7/98 frontsector->GetTexture(sector_t::floor) == skyflatnum || diff --git a/src/r_sky.h b/src/r_sky.h index 2c8c62dc7..6881f4943 100644 --- a/src/r_sky.h +++ b/src/r_sky.h @@ -24,6 +24,12 @@ #include "textures/textures.h" +enum +{ + SKYBOX_MAP = 0, + SKYBOX_PLANE, + SKYBOX_HORIZON +}; extern FTextureID skyflatnum; extern fixed_t sky1cyl, sky2cyl; diff --git a/wadsrc/static/xlat/eternity.txt b/wadsrc/static/xlat/eternity.txt index 7b4367ee3..ba569393e 100644 --- a/wadsrc/static/xlat/eternity.txt +++ b/wadsrc/static/xlat/eternity.txt @@ -33,12 +33,12 @@ define Unsupported (0) 282 = 0, Sector_Attach3DMidtex(tag, 0, 1) // "3DMidTex_MoveWithCeiling" // Plane portals are not supported in ZDoom, though they probably wouldn't be too hard to implement. -283 = 0, Unsupported() // "Portal_PlaneCeiling" -284 = 0, Unsupported() // "Portal_PlaneFloor" -285 = 0, Unsupported() // "Portal_PlaneFloorCeiling" -286 = 0, Unsupported() // "Portal_HorizonCeiling" -287 = 0, Unsupported() // "Portal_HorizonFloor" -288 = 0, Unsupported() // "Portal_HorizonFloorCeiling" +283 = 0, Sector_SetPortal(tag,3, 1, 0, 0) // "Portal_PlaneCeiling" +284 = 0, Sector_SetPortal(tag,3, 0, 0, 0) // "Portal_PlaneFloor" +285 = 0, Sector_SetPortal(tag,3, 2, 0, 0) // "Portal_PlaneFloorCeiling" +286 = 0, Sector_SetPortal(tag,4, 1, 0, 0) // "Portal_HorizonCeiling" +287 = 0, Sector_SetPortal(tag,4, 0, 0, 0) // "Portal_HorizonFloor" +288 = 0, Sector_SetPortal(tag,4, 2, 0, 0) // "Portal_HorizonFloorCeiling" 289 = 0, Unsupported() // "Portal_LineTransfer" // Skybox portals From 65022b780ae586d95e05e3deccf6c7f7584e53a2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Jan 2016 22:44:53 +0100 Subject: [PATCH 0353/1509] - implemented 'copy portal to wall' linedef type. --- src/gl/scene/gl_sky.cpp | 41 ++++++++++++++++++++++++++++++++- src/gl/scene/gl_wall.h | 1 + src/gl/scene/gl_walls.cpp | 15 +++++++----- src/p_saveg.cpp | 5 ++++ src/p_spec.cpp | 17 ++++++++++++++ src/r_defs.h | 1 + src/version.h | 2 +- wadsrc/static/xlat/eternity.txt | 2 +- 8 files changed, 75 insertions(+), 9 deletions(-) diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 17e864476..2b3b06eaa 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -131,9 +131,10 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor) //========================================================================== // -// Calculate sky texture +// Calculate sky texture for ceiling or floor // //========================================================================== + void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) { FPortal *portal = sector->portals[plane]; @@ -178,6 +179,35 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) } +//========================================================================== +// +// Calculate sky texture for a line +// +//========================================================================== + +void GLWall::SkyLine(line_t *line) +{ + ASkyViewpoint * skyboxx = line->skybox; + GLSkyInfo skyinfo; + + // JUSTHIT is used as an indicator that a skybox is in use. + // This is to avoid recursion + + if (!gl_noskyboxes && skyboxx && GLRenderer->mViewActor != skyboxx && !(skyboxx->flags&MF_JUSTHIT)) + { + type = RENDERWALL_SKYBOX; + skybox = skyboxx; + } + else + { + skyinfo.init(line->frontsector->sky, Colormap.FadeColor); + type = RENDERWALL_SKY; + sky = UniqueSkies.Get(&skyinfo); + } + PutWall(0); +} + + //========================================================================== // // Skies on one sided walls @@ -191,6 +221,15 @@ void GLWall::SkyNormal(sector_t * fs,vertex_t * v1,vertex_t * v2) zbottom[1]=zceil[1]; SkyPlane(fs, sector_t::ceiling, true); + if (seg->linedef->skybox != NULL) + { + ztop[0] = zceil[0]; + ztop[1] = zceil[1]; + zbottom[0] = zfloor[0]; + zbottom[1] = zfloor[1]; + SkyLine(seg->linedef); + } + ztop[0]=zfloor[0]; ztop[1]=zfloor[1]; zbottom[0]=zbottom[1]=-32768.0f; diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 47ac06c46..b7f8653e9 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -171,6 +171,7 @@ private: void FloodPlane(int pass); void SkyPlane(sector_t *sector, int plane, bool allowmirror); + void SkyLine(line_t *line); void SkyNormal(sector_t * fs,vertex_t * v1,vertex_t * v2); void SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2); void SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index ad2a3aa93..bb2392295 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1569,13 +1569,16 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) // sector's sky SkyNormal(frontsector, v1, v2); - // normal texture - gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::mid), false, true); - if (gltexture) + if (seg->linedef->skybox == NULL) { - DoTexture(RENDERWALL_M1S, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, - realfront->GetPlaneTexZ(sector_t::ceiling), realfront->GetPlaneTexZ(sector_t::floor), // must come from the original! - fch1, fch2, ffh1, ffh2, 0); + // normal texture + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::mid), false, true); + if (gltexture) + { + DoTexture(RENDERWALL_M1S, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, + realfront->GetPlaneTexZ(sector_t::ceiling), realfront->GetPlaneTexZ(sector_t::floor), // must come from the original! + fch1, fch2, ffh1, ffh2, 0); + } } } else // two sided diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 7a09b2ee8..bcbc3deeb 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -478,6 +478,11 @@ void P_SerializeWorld (FArchive &arc) } arc << li->args[1] << li->args[2] << li->args[3] << li->args[4]; + if (SaveVersion >= 4531) + { + arc << li->skybox; + } + for (j = 0; j < 2; j++) { if (li->sidedef[j] == NULL) diff --git a/src/p_spec.cpp b/src/p_spec.cpp index fba5e2a2d..520586791 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -1044,6 +1044,23 @@ static void CopyPortal(int sectortag, int plane, ASkyViewpoint *origin, fixed_t } } } + if (tolines && lines[j].special == Sector_SetPortal && + lines[j].args[1] == 5 && + lines[j].args[3] == sectortag) + { + if (lines[j].args[0] == 0) + { + lines[j].skybox = origin; + } + else + { + FLineIdIterator itr(lines[j].args[0]); + while ((s = itr.Next()) >= 0) + { + lines[s].skybox = origin; + } + } + } } } diff --git a/src/r_defs.h b/src/r_defs.h index 0b68bcb8a..11e4a0e6d 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1057,6 +1057,7 @@ struct line_t sector_t *frontsector, *backsector; int validcount; // if == validcount, already checked int locknumber; // [Dusk] lock number for special + TObjPtr skybox; }; // phares 3/14/98 diff --git a/src/version.h b/src/version.h index 1ebc9ac5d..875b009df 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4530 +#define SAVEVER 4531 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) diff --git a/wadsrc/static/xlat/eternity.txt b/wadsrc/static/xlat/eternity.txt index ba569393e..7d52af39c 100644 --- a/wadsrc/static/xlat/eternity.txt +++ b/wadsrc/static/xlat/eternity.txt @@ -39,7 +39,7 @@ define Unsupported (0) 286 = 0, Sector_SetPortal(tag,4, 1, 0, 0) // "Portal_HorizonCeiling" 287 = 0, Sector_SetPortal(tag,4, 0, 0, 0) // "Portal_HorizonFloor" 288 = 0, Sector_SetPortal(tag,4, 2, 0, 0) // "Portal_HorizonFloorCeiling" -289 = 0, Unsupported() // "Portal_LineTransfer" +289 = 0, Sector_SetPortal(0, 5, 0, tag) // "Portal_LineTransfer" // Skybox portals 290 = 0, Sector_SetPortal(tag, 2, 1, 1, 0) // "Portal_SkyboxCeiling" From 9e33599536574c096e1e9dae9bbc2300e6bc7986 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 12 Jan 2016 09:13:55 +0100 Subject: [PATCH 0354/1509] - at least get the terms being used right. Of course it's not EDF (which would way beyond the scope of what's intended here) but only Extradata, that's being supported. (For EDF an external converter would make more sense.) --- src/CMakeLists.txt | 2 +- src/{edf.cpp => edata.cpp} | 110 ++++++++++++++++---------------- src/edata.h | 12 ++++ src/p_lnspec.h | 4 +- src/p_setup.cpp | 20 +++--- src/p_spec.cpp | 8 +-- wadsrc/static/xlat/eternity.txt | 8 +-- 7 files changed, 88 insertions(+), 76 deletions(-) rename src/{edf.cpp => edata.cpp} (90%) create mode 100644 src/edata.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 83dd1ce13..b269e677b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -944,7 +944,7 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE doomstat.cpp dsectoreffect.cpp dthinker.cpp - edf.cpp + edata.cpp f_wipe.cpp farchive.cpp files.cpp diff --git a/src/edf.cpp b/src/edata.cpp similarity index 90% rename from src/edf.cpp rename to src/edata.cpp index 50ac2835c..13e986425 100644 --- a/src/edf.cpp +++ b/src/edata.cpp @@ -1,6 +1,6 @@ /* -** edf.cpp -** Parses Eternity EDF lumps +** edata.cpp +** Parses Eternity Extradata lumps ** **--------------------------------------------------------------------------- ** Copyright 2015 Christoph Oelckers @@ -51,43 +51,43 @@ #include "r_data/colormaps.h" -struct FEdfOptions : public FOptionalMapinfoData +struct FEDOptions : public FOptionalMapinfoData { - FEdfOptions() + FEDOptions() { - identifier = "EDF"; + identifier = "EData"; } virtual FOptionalMapinfoData *Clone() const { - FEdfOptions *newopt = new FEdfOptions; + FEDOptions *newopt = new FEDOptions; newopt->identifier = identifier; - newopt->edfName = edfName; + newopt->EDName = EDName; newopt->acsName = acsName; return newopt; } - FString edfName; + FString EDName; FString acsName; }; -DEFINE_MAP_OPTION(edf, false) +DEFINE_MAP_OPTION(edata, false) { - FEdfOptions *opt = info->GetOptData("EDF"); + FEDOptions *opt = info->GetOptData("EData"); parse.ParseAssign(); parse.sc.MustGetString(); - opt->edfName = parse.sc.String; + opt->EDName = parse.sc.String; } DEFINE_MAP_OPTION(loadacs, false) { - FEdfOptions *opt = info->GetOptData("EDF"); + FEDOptions *opt = info->GetOptData("EData"); parse.ParseAssign(); parse.sc.MustGetString(); opt->acsName = parse.sc.String; } -struct EDFMapthing +struct EDMapthing { int recordnum; int tid; @@ -98,7 +98,7 @@ struct EDFMapthing DWORD flags; }; -struct EDFLinedef +struct EDLinedef { int recordnum; int special; @@ -112,7 +112,7 @@ struct EDFLinedef -struct EDFSector +struct EDSector { int recordnum; @@ -146,15 +146,15 @@ struct EDFSector fixed_t overlayalpha[2]; }; -static FString EDFMap; -static TMap EDFLines; -static TMap EDFSectors; -static TMap EDFThings; +static FString EDMap; +static TMap EDLines; +static TMap EDSectors; +static TMap EDThings; static void parseLinedef(FScanner &sc) { - EDFLinedef ld; + EDLinedef ld; bool argsset = false; memset(&ld, 0, sizeof(ld)); @@ -267,12 +267,12 @@ static void parseLinedef(FScanner &sc) ld.flags = (ld.flags & ~(ML_REPEAT_SPECIAL | ML_FIRSTSIDEONLY)) | (line.flags & (ML_REPEAT_SPECIAL | ML_FIRSTSIDEONLY)); if (!argsset) memcpy(ld.args, line.args, sizeof(ld.args)); } - EDFLines[ld.recordnum] = ld; + EDLines[ld.recordnum] = ld; } static void parseSector(FScanner &sc) { - EDFSector sec; + EDSector sec; memset(&sec, 0, sizeof(sec)); sec.overlayalpha[sector_t::floor] = sec.overlayalpha[sector_t::ceiling] = FRACUNIT; @@ -499,15 +499,15 @@ static void parseSector(FScanner &sc) sc.ScriptError("Unknown property '%s'", sc.String); } } - EDFSectors[sec.recordnum] = sec; + EDSectors[sec.recordnum] = sec; } static void parseMapthing(FScanner &sc) { - EDFMapthing mt; + EDMapthing mt; memset(&mt, 0, sizeof(mt)); - mt.flags |= MTF_SINGLE | MTF_COOPERATIVE | MTF_DEATHMATCH; // EDF uses inverse logic, like Doom.exe + mt.flags |= MTF_SINGLE | MTF_COOPERATIVE | MTF_DEATHMATCH; // Extradata uses inverse logic, like Doom.exe sc.MustGetStringName("{"); while (!sc.CheckString("}")) @@ -607,30 +607,30 @@ static void parseMapthing(FScanner &sc) sc.ScriptError("Unknown property '%s'", sc.String); } } - EDFThings[mt.recordnum] = mt; + EDThings[mt.recordnum] = mt; } -void InitEDF() +void InitED() { FString filename; FScanner sc; - if (EDFMap.CompareNoCase(level.MapName) != 0) + if (EDMap.CompareNoCase(level.MapName) != 0) { - EDFLines.Clear(); - EDFSectors.Clear(); - EDFThings.Clear(); - EDFMap = level.MapName; + EDLines.Clear(); + EDSectors.Clear(); + EDThings.Clear(); + EDMap = level.MapName; const char *arg = Args->CheckValue("-edf"); if (arg != NULL) filename = arg; else { - FEdfOptions *opt = level.info->GetOptData("EDF", false); + FEDOptions *opt = level.info->GetOptData("EData", false); if (opt != NULL) { - filename = opt->edfName; + filename = opt->EDName; } } @@ -662,11 +662,11 @@ void InitEDF() } } -void ProcessEDFMapthing(FMapThing *mt, int recordnum) +void ProcessEDMapthing(FMapThing *mt, int recordnum) { - InitEDF(); + InitED(); - EDFMapthing *emt = EDFThings.CheckKey(recordnum); + EDMapthing *emt = EDThings.CheckKey(recordnum); if (emt == NULL) { Printf("EDF Mapthing record %d not found\n", recordnum); @@ -682,11 +682,11 @@ void ProcessEDFMapthing(FMapThing *mt, int recordnum) mt->flags = emt->flags; } -void ProcessEDFLinedef(line_t *ld, int recordnum) +void ProcessEDLinedef(line_t *ld, int recordnum) { - InitEDF(); + InitED(); - EDFLinedef *eld = EDFLines.CheckKey(recordnum); + EDLinedef *eld = EDLines.CheckKey(recordnum); if (eld == NULL) { Printf("EDF Linedef record %d not found\n", recordnum); @@ -702,9 +702,9 @@ void ProcessEDFLinedef(line_t *ld, int recordnum) tagManager.AddLineID(int(ld - lines), eld->tag); } -void ProcessEDFSector(sector_t *sec, int recordnum) +void ProcessEDSector(sector_t *sec, int recordnum) { - EDFSector *esec = EDFSectors.CheckKey(recordnum); + EDSector *esec = EDSectors.CheckKey(recordnum); if (esec == NULL) { Printf("EDF Sector record %d not found\n", recordnum); @@ -722,7 +722,7 @@ void ProcessEDFSector(sector_t *sec, int recordnum) sec->Flags = (sec->Flags | esec->damageflags | esec->damageflagsAdd) & ~esec->damageflagsRemove; leak = (leak | esec->leaky | esec->leakyadd) & ~esec->leakyremove; - // the damage properties will be unconditionally overridden by EDF. + // the damage properties will be unconditionally overridden by Extradata. sec->leakydamage = leak == 0 ? 0 : leak == 1 ? 5 : 256; sec->damageamount = esec->damageamount; sec->damageinterval = esec->damageinterval; @@ -745,37 +745,37 @@ void ProcessEDFSector(sector_t *sec, int recordnum) } -void ProcessEDFSectors() +void ProcessEDSectors() { int i; - InitEDF(); - if (EDFSectors.CountUsed() == 0) return; // don't waste time if there's no records. + InitED(); + if (EDSectors.CountUsed() == 0) return; // don't waste time if there's no records. - // collect all EDF sector records up front so we do not need to search the complete line array for each sector separately. - int *edfsectorrecord = new int[numsectors]; - memset(edfsectorrecord, -1, numsectors * sizeof(int)); + // collect all Extradata sector records up front so we do not need to search the complete line array for each sector separately. + int *sectorrecord = new int[numsectors]; + memset(sectorrecord, -1, numsectors * sizeof(int)); for (i = 0; i < numlines; i++) { - if (lines[i].special == Static_Init && lines[i].args[1] == Init_EDFSector) + if (lines[i].special == Static_Init && lines[i].args[1] == Init_EDSector) { - edfsectorrecord[lines[i].frontsector - sectors] = lines[i].args[0]; + sectorrecord[lines[i].frontsector - sectors] = lines[i].args[0]; lines[i].special = 0; } } for (i = 0; i < numsectors; i++) { - if (edfsectorrecord[i] >= 0) + if (sectorrecord[i] >= 0) { - ProcessEDFSector(§ors[i], edfsectorrecord[i]); + ProcessEDSector(§ors[i], sectorrecord[i]); } } - delete[] edfsectorrecord; + delete[] sectorrecord; } void LoadMapinfoACSLump() { - FEdfOptions *opt = level.info->GetOptData("EDF", false); + FEDOptions *opt = level.info->GetOptData("EData", false); if (opt != NULL) { int lump = Wads.CheckNumForName(opt->acsName); diff --git a/src/edata.h b/src/edata.h new file mode 100644 index 000000000..ffbe7d59a --- /dev/null +++ b/src/edata.h @@ -0,0 +1,12 @@ +#ifndef EDATA_H +#define EDATA_H + +struct FMapThing; +struct line_t; + +void ProcessEDMapthing(FMapThing *mt, int recordnum); +void ProcessEDLinedef(line_t *line, int recordnum); +void ProcessEDSectors(); +void LoadMapinfoACSLump(); + +#endif \ No newline at end of file diff --git a/src/p_lnspec.h b/src/p_lnspec.h index 3f97c75e6..2ddccd67d 100644 --- a/src/p_lnspec.h +++ b/src/p_lnspec.h @@ -60,8 +60,8 @@ typedef enum { Init_Damage = 2, Init_SectorLink = 3, NUM_STATIC_INITS, - Init_EDFSector = 253, - Init_EDFLine = 254, + Init_EDSector = 253, + Init_EDLine = 254, Init_TransferSky = 255 } staticinit_t; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 46f984bf1..f4b66cbe6 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -68,8 +68,8 @@ #include "po_man.h" #include "r_renderer.h" #include "r_data/colormaps.h" -#ifndef NO_EDF -#include "edf.h" +#ifndef NO_EDATA +#include "edata.h" #endif #include "fragglescript/t_fs.h" @@ -1770,10 +1770,10 @@ void P_LoadThings (MapData * map) mti[i].info = DoomEdMap.CheckKey(mti[i].EdNum); -#ifndef NO_EDF +#ifndef NO_EDATA if (mti[i].info != NULL && mti[i].info->Special == SMT_EDFThing) { - ProcessEDFMapthing(&mti[i], flags); + ProcessEDMapthing(&mti[i], flags); } else #endif @@ -2173,15 +2173,15 @@ void P_LoadLineDefs (MapData * map) // compatible with the new format. P_TranslateLineDef (ld, mld, -1); - // do not assign the tag for EDF lines. - if (ld->special != Static_Init || (ld->args[1] != Init_EDFLine && ld->args[1] != Init_EDFSector)) + // do not assign the tag for Extradata lines. + if (ld->special != Static_Init || (ld->args[1] != Init_EDLine && ld->args[1] != Init_EDSector)) { tagManager.AddLineID(i, mld->tag); } -#ifndef NO_EDF - if (ld->special == Static_Init && ld->args[1] == Init_EDFLine) +#ifndef NO_EDATA + if (ld->special == Static_Init && ld->args[1] == Init_EDLine) { - ProcessEDFLinedef(ld, mld->tag); + ProcessEDLinedef(ld, mld->tag); } #endif @@ -3702,7 +3702,7 @@ void P_SetupLevel (const char *lumpname, int position) } FBehavior::StaticLoadDefaultModules (); -#ifndef NO_EDF +#ifndef NO_EDATA LoadMapinfoACSLump(); #endif diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 5499d737f..e153e0fb8 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -63,8 +63,8 @@ #include "a_keys.h" #include "c_dispatch.h" #include "r_sky.h" -#ifndef NO_EDF -#include "edf.h" +#ifndef NO_EDATA +#include "edata.h" #endif // State. @@ -1377,8 +1377,8 @@ void P_SpawnSpecials (void) P_InitSectorSpecial(sector, sector->special, false); } -#ifndef NO_EDF - ProcessEDFSectors(); +#ifndef NO_EDATA + ProcessEDSectors(); #endif diff --git a/wadsrc/static/xlat/eternity.txt b/wadsrc/static/xlat/eternity.txt index f56d5f62b..bfe275b1f 100644 --- a/wadsrc/static/xlat/eternity.txt +++ b/wadsrc/static/xlat/eternity.txt @@ -10,8 +10,8 @@ define Unsupported (0) enum { - Init_EDFSector = 253, - Init_EDFLine = 254 + Init_EDSector = 253, + Init_EDLine = 254 } // The tag for such a line is actually a key to find, in an ExtraData lump @@ -19,7 +19,7 @@ enum // to actually use. This is how parameterized linedefs are used by Eternity // in the Doom format. -270 = 0, Static_Init(tag, Init_EDFLine) // "ExtraDataSpecial" +270 = 0, Static_Init(tag, Init_EDLine) // "ExtraDataSpecial" // These two are standard MBF specials, no need to redefine them, they're in xlat/doom.txt // 271 = 0, Static_Init (tag, Init_TransferSky, 0) @@ -195,7 +195,7 @@ enum 399 = 0, Thing_SpawnNoFog(0) 400 = 0, Teleport_EndGame(0) -401 = 0, Static_Init(tag, Init_EDFSector) +401 = 0, Static_Init(tag, Init_EDSector) 402 = 0, Thing_Projectile(0) 403 = 0, Thing_ProjectileGravity(0) From 4d2ca0da457a4fcacbab5c13be106d9416b5816f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 12 Jan 2016 21:36:33 +0100 Subject: [PATCH 0355/1509] - empty gl_portals.cpp file. --- src/CMakeLists.txt | 1 + src/p_portals.cpp | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/p_portals.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 92a6577ae..5a017d6ac 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1004,6 +1004,7 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE p_mobj.cpp p_pillar.cpp p_plats.cpp + p_portals.cpp p_pspr.cpp p_saveg.cpp p_sectors.cpp diff --git a/src/p_portals.cpp b/src/p_portals.cpp new file mode 100644 index 000000000..92ecfd075 --- /dev/null +++ b/src/p_portals.cpp @@ -0,0 +1,35 @@ +/* +** p_portals.cpp +** +** portal stuff +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + From cd778b6bdc09924cf78e529f8afcd1495820bc5d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 13 Jan 2016 00:15:04 +0100 Subject: [PATCH 0356/1509] - fixed CollectPortalSectors --- src/gl/data/gl_portaldata.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 676f6a630..7841512e0 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -354,24 +354,17 @@ static void CollectPortalSectors(FPortalMap &collection) for (int i=0;iCeilingSkyBox != NULL && sec->CeilingSkyBox->bAlways && sec->CeilingSkyBox->Mate != NULL) + for (int j = 0; j < 2; j++) { - FPortalID id = { sec->CeilingSkyBox->x - sec->CeilingSkyBox->Mate->x, - sec->CeilingSkyBox->y - sec->CeilingSkyBox->Mate->y}; + ASkyViewpoint *SkyBox = sec->SkyBoxes[j]; + if (SkyBox != NULL && SkyBox->bAlways && SkyBox->Mate != NULL) + { + FPortalID id = { SkyBox->x - SkyBox->Mate->x, SkyBox->y - SkyBox->Mate->y }; - FPortalSectors &sss = collection[id]; - FPortalSector ss = { sec, sector_t::ceiling }; - sss.Push(ss); - } - - if (sec->FloorSkyBox != NULL && sec->FloorSkyBox->bAlways && sec->FloorSkyBox->Mate != NULL) - { - FPortalID id = { sec->FloorSkyBox->x - sec->FloorSkyBox->Mate->x, - sec->FloorSkyBox->y - sec->FloorSkyBox->Mate->y }; - - FPortalSectors &sss = collection[id]; - FPortalSector ss = { sec, sector_t::floor }; - sss.Push(ss); + FPortalSectors &sss = collection[id]; + FPortalSector ss = { sec, j }; + sss.Push(ss); + } } } } From 2657c08831aec5c97a1fce13313c7fd2fb2871a9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 13 Jan 2016 21:33:27 +0100 Subject: [PATCH 0357/1509] - fixed: stacked sector portals were not added to the render list --- src/gl/scene/gl_sky.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 2b3b06eaa..7eeda5f3d 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -174,8 +174,8 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) planemirror = plane == sector_t::ceiling ? §or->ceilingplane : §or->floorplane; } else return; - PutWall(0); } + PutWall(0); } From 4df8c12534cf4372f5c40b4043d017cb5be4f769 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 19 Jan 2016 10:50:01 +0100 Subject: [PATCH 0358/1509] - added a missing NULL pointer check in software rendering code. --- src/r_bsp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 09c39b49e..397d29f9b 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -1088,7 +1088,7 @@ void R_Subsector (subsector_t *sub) } skybox = frontsector->GetSkyBox(sector_t::ceiling); - if (skybox->special1 != SKYBOX_MAP) skybox = NULL; // HW renderer only. + if (skybox != NULL && skybox->special1 != SKYBOX_MAP) skybox = NULL; // HW renderer only. ceilingplane = frontsector->ceilingplane.PointOnSide(viewx, viewy, viewz) > 0 || frontsector->GetTexture(sector_t::ceiling) == skyflatnum || @@ -1131,7 +1131,7 @@ void R_Subsector (subsector_t *sub) // killough 10/98: add support for skies transferred from sidedefs skybox = frontsector->GetSkyBox(sector_t::floor); - if (skybox->special1 != SKYBOX_MAP) skybox = NULL; // HW renderer only. + if (skybox != NULL && skybox->special1 != SKYBOX_MAP) skybox = NULL; // HW renderer only. floorplane = frontsector->floorplane.PointOnSide(viewx, viewy, viewz) > 0 || // killough 3/7/98 frontsector->GetTexture(sector_t::floor) == skyflatnum || From 58160495103895c0a63523d223ff9fb16b1e71ae Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 21 Jan 2016 12:36:37 +0100 Subject: [PATCH 0359/1509] - made necessary adjustments for the coordinate refactoring in ZDoom. --- src/gl/data/gl_portaldata.cpp | 2 +- src/gl/dynlights/a_dynlight.cpp | 35 ++++++++++++++++++------------- src/gl/dynlights/gl_dynlight.cpp | 2 +- src/gl/dynlights/gl_dynlight1.cpp | 6 +++--- src/gl/scene/gl_flats.cpp | 4 ++-- src/gl/scene/gl_portal.cpp | 13 ++++++------ src/gl/scene/gl_sprite.cpp | 34 ++++++++++++++---------------- src/gl/scene/gl_spritelight.cpp | 4 ++-- src/gl/scene/gl_walls_draw.cpp | 6 +++--- src/gl/scene/gl_weapon.cpp | 2 +- 10 files changed, 56 insertions(+), 52 deletions(-) diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 7841512e0..6640d2d4a 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -359,7 +359,7 @@ static void CollectPortalSectors(FPortalMap &collection) ASkyViewpoint *SkyBox = sec->SkyBoxes[j]; if (SkyBox != NULL && SkyBox->bAlways && SkyBox->Mate != NULL) { - FPortalID id = { SkyBox->x - SkyBox->Mate->x, SkyBox->y - SkyBox->Mate->y }; + FPortalID id = { SkyBox->X() - SkyBox->Mate->X(), SkyBox->Y() - SkyBox->Mate->Y() }; FPortalSectors &sss = collection[id]; FPortalSector ss = { sec, j }; diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 4507e783c..575fa2e11 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -89,7 +89,7 @@ void AVavoomLight::BeginPlay () { // This must not call Super::BeginPlay! ChangeStatNum(STAT_DLIGHT); - if (Sector) z -= Sector->floorplane.ZatPoint(x, y); + if (Sector) AddZ(-Sector->floorplane.ZatPoint(this), false); lighttype = PointLight; } @@ -170,7 +170,7 @@ void ADynamicLight::PostBeginPlay() Activate (NULL); } - subsector = R_PointInSubsector(x,y); + subsector = R_PointInSubsector(X(), Y()); } @@ -333,8 +333,8 @@ void ADynamicLight::Tick() //========================================================================== void ADynamicLight::UpdateLocation() { - fixed_t oldx=x; - fixed_t oldy=y; + fixed_t oldx=X(); + fixed_t oldy=Y(); fixed_t oldradius=radius; float intensity; @@ -343,10 +343,15 @@ void ADynamicLight::UpdateLocation() if (target) { angle_t angle = target->angle>>ANGLETOFINESHIFT; - PrevX = x = target->x + FixedMul(m_offX, finecosine[angle]) + FixedMul(m_offZ, finesine[angle]); - PrevY = y = target->y + FixedMul(m_offX, finesine[angle]) - FixedMul(m_offZ, finecosine[angle]); - PrevZ = z = target->z + m_offY + target->GetBobOffset(); - subsector = R_PointInSubsector(x, y); + fixedvec3 pos = target->Vec3Offset( + FixedMul(m_offX, finecosine[angle]) + FixedMul(m_offZ, finesine[angle]), + FixedMul(m_offX, finesine[angle]) - FixedMul(m_offZ, finecosine[angle]), + m_offY + target->GetBobOffset()); + SetXYZ(pos); // attached lights do not need to go into the regular blockmap + PrevX = pos.x; + PrevY = pos.y; + PrevZ = pos.z; + subsector = R_PointInSubsector(pos.x, pos.y); Sector = subsector->sector; } @@ -364,7 +369,7 @@ void ADynamicLight::UpdateLocation() } radius = FLOAT2FIXED(intensity * 2.0f * gl_lights_size); - if (x!=oldx || y!=oldy || radius!=oldradius) + if (X()!=oldx || Y()!=oldy || radius!=oldradius) { //Update the light lists LinkLight(); @@ -495,15 +500,15 @@ float ADynamicLight::DistToSeg(seg_t *seg) float seg_dy = FIXED2FLOAT(seg->v2->y - seg->v1->y); float seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy; - u = ( FIXED2FLOAT(x - seg->v1->x) * seg_dx + FIXED2FLOAT(y - seg->v1->y) * seg_dy) / seg_length_sq; + u = ( FIXED2FLOAT(X() - seg->v1->x) * seg_dx + FIXED2FLOAT(Y() - seg->v1->y) * seg_dy) / seg_length_sq; if (u < 0.f) u = 0.f; // clamp the test point to the line segment if (u > 1.f) u = 1.f; px = FIXED2FLOAT(seg->v1->x) + (u * seg_dx); py = FIXED2FLOAT(seg->v1->y) + (u * seg_dy); - px -= FIXED2FLOAT(x); - py -= FIXED2FLOAT(y); + px -= FIXED2FLOAT(X()); + py -= FIXED2FLOAT(Y()); return (px*px) + (py*py); } @@ -536,7 +541,7 @@ void ADynamicLight::CollectWithinRadius(subsector_t *subSec, float radius) if (seg->sidedef && seg->linedef && seg->linedef->validcount!=::validcount) { // light is in front of the seg - if (DMulScale32 (y-seg->v1->y, seg->v2->x-seg->v1->x, seg->v1->x-x, seg->v2->y-seg->v1->y) <=0) + if (DMulScale32 (Y()-seg->v1->y, seg->v2->x-seg->v1->x, seg->v1->x-X(), seg->v2->y-seg->v1->y) <=0) { seg->linedef->validcount=validcount; touching_sides = AddLightNode(&seg->sidedef->lighthead, seg->sidedef, this, touching_sides); @@ -592,7 +597,7 @@ void ADynamicLight::LinkLight() if (radius>0) { // passing in radius*radius allows us to do a distance check without any calls to sqrtf - subsector_t * subSec = R_PointInSubsector(x, y); + subsector_t * subSec = R_PointInSubsector(X(), Y()); if (subSec) { float fradius = FIXED2FLOAT(radius); @@ -702,7 +707,7 @@ CCMD(listlights) subsecs = 0; Printf("%s at (%f, %f, %f), color = 0x%02x%02x%02x, radius = %f ", dl->target? dl->target->GetClass()->TypeName.GetChars() : dl->GetClass()->TypeName.GetChars(), - FIXED2FLOAT(dl->x), FIXED2FLOAT(dl->y), FIXED2FLOAT(dl->z), dl->args[LIGHT_RED], + FIXED2FLOAT(dl->X()), FIXED2FLOAT(dl->Y()), FIXED2FLOAT(dl->Z()), dl->args[LIGHT_RED], dl->args[LIGHT_GREEN], dl->args[LIGHT_BLUE], FIXED2FLOAT(dl->radius)); i++; diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index f143a479b..4afacc7d1 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -1085,7 +1085,7 @@ void gl_AttachLight(AActor *actor, unsigned int count, const FLightDefaults *lig } else { - light = Spawn(actor->x, actor->y, actor->z, NO_REPLACE); + light = Spawn(actor->Pos(), NO_REPLACE); light->target = actor; light->owned = true; actor->dynamiclights.Push(light); diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index c504a33c4..864a9f3ce 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -90,9 +90,9 @@ bool gl_GetLight(Plane & p, ADynamicLight * light, bool checkside, bool forceadd Vector fn, pos; int i = 0; - float x = FIXED2FLOAT(light->x); - float y = FIXED2FLOAT(light->y); - float z = FIXED2FLOAT(light->z); + float x = FIXED2FLOAT(light->X()); + float y = FIXED2FLOAT(light->Y()); + float z = FIXED2FLOAT(light->Z()); float dist = fabsf(p.DistToPoint(x, z, y)); float radius = (light->GetRadius() * gl_lights_size); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 78d9b44bd..16b892b15 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -141,8 +141,8 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli) // we must do the side check here because gl_SetupLight needs the correct plane orientation // which we don't have for Legacy-style 3D-floors - fixed_t planeh = plane.plane.ZatPoint(light->x, light->y); - if (gl_lights_checkside && ((planehz && ceiling) || (planeh>light->z && !ceiling))) + fixed_t planeh = plane.plane.ZatPoint(light); + if (gl_lights_checkside && ((planehZ() && ceiling) || (planeh>light->Z() && !ceiling))) { node=node->nextLight; continue; diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index cb8f361a9..5b6c8e27d 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -641,14 +641,15 @@ void GLSkyboxPortal::DrawContents() PlaneMirrorMode=0; bool oldclamp = gl_RenderState.SetDepthClamp(false); - viewx = origin->PrevX + FixedMul(r_TicFrac, origin->x - origin->PrevX); - viewy = origin->PrevY + FixedMul(r_TicFrac, origin->y - origin->PrevY); - viewz = origin->PrevZ + FixedMul(r_TicFrac, origin->z - origin->PrevZ); + fixedvec3 viewpos = origin->InterpolatedPosition(r_TicFrac); + viewx = viewpos.x; + viewy = viewpos.y; + viewz = viewpos.z; viewangle += origin->PrevAngle + FixedMul(r_TicFrac, origin->angle - origin->PrevAngle); - // Don't let the viewpoint be too close to a floor or ceiling! - fixed_t floorh = origin->Sector->floorplane.ZatPoint(origin->x, origin->y); - fixed_t ceilh = origin->Sector->ceilingplane.ZatPoint(origin->x, origin->y); + // Don't let the viewpoint be too close to a floor or ceiling + fixed_t floorh = origin->Sector->floorplane.ZatPoint(origin); + fixed_t ceilh = origin->Sector->ceilingplane.ZatPoint(origin); if (viewzceilh-4*FRACUNIT) viewz=ceilh-4*FRACUNIT; diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index e8d919a28..75e698762 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -339,8 +339,8 @@ void GLSprite::SplitSprite(sector_t * frontsector, bool translucent) for(i=0;ix,actor->y); - else lightbottom=frontsector->floorplane.ZatPoint(actor->x,actor->y); + if (ifloorplane.ZatPoint(actor); maplightbottom=FIXED2FLOAT(lightbottom); if (maplightbottomx,actor->y); - else lightbottom=sector->floorplane.ZatPoint(actor->x,actor->y); + if (ifloorplane.ZatPoint(actor); //maplighttop=FIXED2FLOAT(lightlist[i].height); maplightbottom=FIXED2FLOAT(lightbottom); @@ -538,12 +538,10 @@ void GLSprite::Process(AActor* thing,sector_t * sector) if (!(currentmapsection[thing->subsector->mapsection>>3] & (1 << (thing->subsector->mapsection & 7)))) return; // [RH] Interpolate the sprite's position to make it look smooth - fixed_t thingx = thing->PrevX + FixedMul (r_TicFrac, thing->x - thing->PrevX); - fixed_t thingy = thing->PrevY + FixedMul (r_TicFrac, thing->y - thing->PrevY); - fixed_t thingz = thing->PrevZ + FixedMul (r_TicFrac, thing->z - thing->PrevZ); + fixedvec3 thingpos = thing->InterpolatedPosition(r_TicFrac); // Too close to the camera. This doesn't look good if it is a sprite. - if (P_AproxDistance(thingx-viewx, thingy-viewy)<2*FRACUNIT) + if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy)<2*FRACUNIT) { // exclude vertically moving objects from this check. if (!(thing->velx==0 && thing->vely==0 && thing->velz!=0)) @@ -558,12 +556,12 @@ void GLSprite::Process(AActor* thing,sector_t * sector) // don't draw first frame of a player missile if (thing->flags&MF_MISSILE && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) { - if (P_AproxDistance(thingx-viewx, thingy-viewy) < thing->Speed ) return; + if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy) < thing->Speed ) return; } if (GLRenderer->mCurrentPortal) { - int clipres = GLRenderer->mCurrentPortal->ClipPoint(thingx, thingy); + int clipres = GLRenderer->mCurrentPortal->ClipPoint(thingpos.x, thingpos.y); if (clipres == GLPortal::PClip_InFront) return; } @@ -580,9 +578,9 @@ void GLSprite::Process(AActor* thing,sector_t * sector) } - x = FIXED2FLOAT(thingx); - z = FIXED2FLOAT(thingz-thing->floorclip); - y = FIXED2FLOAT(thingy); + x = FIXED2FLOAT(thingpos.x); + z = FIXED2FLOAT(thingpos.z-thing->floorclip); + y = FIXED2FLOAT(thingpos.y); // [RH] Make floatbobbing a renderer-only effect. if (thing->flags2 & MF2_FLOATBOB) @@ -594,7 +592,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) modelframe = gl_FindModelFrame(RUNTIME_TYPE(thing), spritenum, thing->frame, !!(thing->flags & MF_DROPPED)); if (!modelframe) { - angle_t ang = R_PointToAngle(thingx, thingy); + angle_t ang = R_PointToAngle(thingpos.x, thingpos.y); bool mirror; FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, ang - thing->angle, &mirror); @@ -631,7 +629,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) // Tests show that this doesn't look good for many decorations and corpses if (spriteheight > 0 && gl_spriteclip > 0 && (thing->renderflags & RF_SPRITETYPEMASK) == RF_FACESPRITE) { - PerformSpriteClipAdjustment(thing, thingx, thingy, spriteheight); + PerformSpriteClipAdjustment(thing, thingpos.x, thingpos.y, spriteheight); } float viewvecX; @@ -667,7 +665,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) gltexture=NULL; } - depth = DMulScale20 (thing->x-viewx, viewtancos, thing->y-viewy, viewtansin); + depth = DMulScale20 (thingpos.x-viewx, viewtancos, thingpos.y-viewy, viewtansin); // light calculation @@ -683,7 +681,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) rendersector->GetCeilingLight() : rendersector->GetFloorLight()); foglevel = (BYTE)clamp(rendersector->lightlevel, 0, 255); - lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, thingx, thingy, thingz); + lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, thingpos.x, thingpos.y, thingpos.z); ThingColor = (thing->RenderStyle.Flags & STYLEF_ColorIsFixed) ? thing->fillcolor : 0xffffff; ThingColor.a = 255; @@ -835,7 +833,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) if (drawWithXYBillboard || modelframe) { - if (!gl_fixedcolormap && !fullbright) SetSpriteColor(actor->Sector, actor->y + (actor->height>>1)); + if (!gl_fixedcolormap && !fullbright) SetSpriteColor(actor->Sector, thingpos.y + (actor->height>>1)); PutSprite(hw_styleflags != STYLEHW_Solid); } else if (thing->Sector->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap || fullbright) diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index 97f326844..9740448f4 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -80,7 +80,7 @@ void gl_SetDynSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsect if (!(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) { - float dist = FVector3(FIXED2FLOAT(x - light->x), FIXED2FLOAT(y - light->y), FIXED2FLOAT(z - light->z)).Length(); + float dist = FVector3(FIXED2FLOAT(x - light->X()), FIXED2FLOAT(y - light->Y()), FIXED2FLOAT(z - light->Z())).Length(); radius = light->GetRadius() * gl_lights_size; if (dist < radius) @@ -117,7 +117,7 @@ void gl_SetDynSpriteLight(AActor *thing, particle_t *particle) { if (thing != NULL) { - gl_SetDynSpriteLight(thing, thing->x, thing->y, thing->z + (thing->height >> 1), thing->subsector); + gl_SetDynSpriteLight(thing, thing->X(), thing->Y(), thing->Z() + (thing->height >> 1), thing->subsector); } else if (particle != NULL) { diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 5135a5947..5cf321ec8 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -118,9 +118,9 @@ void GLWall::SetupLights() Vector fn, pos; - float x = FIXED2FLOAT(node->lightsource->x); - float y = FIXED2FLOAT(node->lightsource->y); - float z = FIXED2FLOAT(node->lightsource->z); + float x = FIXED2FLOAT(node->lightsource->X()); + float y = FIXED2FLOAT(node->lightsource->Y()); + float z = FIXED2FLOAT(node->lightsource->Z()); float dist = fabsf(p.DistToPoint(x, z, y)); float radius = (node->lightsource->GetRadius() * gl_lights_size); float scale = 1.0f / ((2.f * radius) - dist); diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 71b4a8fdc..3fcc0c251 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -250,7 +250,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) lightlevel = (1.0 - min_L) * 255; } - lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->x, playermo->y, playermo->z); + lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->X(), playermo->Y(), playermo->Z()); // calculate colormap for weapon sprites if (viewsector->e->XFloor.ffloors.Size() && !glset.nocoloredspritelighting) From 685385635fe87742732174365daa03264b0d5ed6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Jan 2016 12:05:40 +0100 Subject: [PATCH 0360/1509] - made adjustments to FGLBitmap for the changes in its base class. --- src/gl/textures/gl_bitmap.cpp | 14 ++++++++------ src/gl/textures/gl_bitmap.h | 4 +++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/gl/textures/gl_bitmap.cpp b/src/gl/textures/gl_bitmap.cpp index a2319f67c..991ebc650 100644 --- a/src/gl/textures/gl_bitmap.cpp +++ b/src/gl/textures/gl_bitmap.cpp @@ -51,28 +51,30 @@ // //=========================================================================== template -void iCopyColors(unsigned char * pout, const unsigned char * pin, int count, int step) +void iCopyColors(unsigned char * pout, const unsigned char * pin, int count, int step, BYTE tr, BYTE tg, BYTE tb) { int i; + unsigned char a; for(i=0;i, + iCopyColors, iCopyColors, iCopyColors, iCopyColors, @@ -92,14 +94,14 @@ static CopyFunc copyfuncs[]={ //=========================================================================== void FGLBitmap::CopyPixelDataRGB(int originx, int originy, const BYTE * patch, int srcwidth, int srcheight, int step_x, int step_y, - int rotate, int ct, FCopyInfo *inf) + int rotate, int ct, FCopyInfo *inf, int r, int g, int b) { if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate)) { BYTE *buffer = GetPixels() + 4*originx + Pitch*originy; for (int y=0;y Date: Wed, 27 Jan 2016 12:02:43 +0100 Subject: [PATCH 0361/1509] - when rendering mirrors, discard subsectors lying behind them. --- src/gl/scene/gl_bsp.cpp | 13 ++++++++----- src/gl/scene/gl_portal.cpp | 13 +++++++++++-- src/gl/scene/gl_portal.h | 2 ++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index dd6df8287..ef7af4d21 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -361,11 +361,6 @@ static void DoSubsector(subsector_t * sub) sector_t * fakesector; sector_t fake; - // check for visibility of this entire subsector. This requires GL nodes. - // (disabled because it costs more time than it saves.) - //if (!clipper.CheckBox(sub->bbox)) return; - - #ifdef _DEBUG if (sub->sector-sectors==931) { @@ -387,6 +382,14 @@ static void DoSubsector(subsector_t * sub) UnclipSubsector(sub); } + if (GLRenderer->mCurrentPortal) + { + int clipres = GLRenderer->mCurrentPortal->ClipSubsector(sub); + if (clipres == GLPortal::PClip_InFront) return; + } + + + fakesector=gl_FakeFlat(sector, &fake, false); if (sector->validcount != validcount) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 5b6c8e27d..a22c25e2d 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -750,7 +750,6 @@ void GLSectorStackPortal::DrawContents() viewx += origin->xDisplacement; viewy += origin->yDisplacement; GLRenderer->mViewActor = NULL; - GLRenderer->mCurrentPortal = this; validcount++; @@ -937,7 +936,7 @@ void GLMirrorPortal::DrawContents() int GLMirrorPortal::ClipSeg(seg_t *seg) { - // this seg is completely behind the mirror! + // this seg is completely behind the mirror. if (P_PointOnLineSide(seg->v1->x, seg->v1->y, linedef) && P_PointOnLineSide(seg->v2->x, seg->v2->y, linedef)) { @@ -946,6 +945,16 @@ int GLMirrorPortal::ClipSeg(seg_t *seg) return PClip_Inside; } +int GLMirrorPortal::ClipSubsector(subsector_t *sub) +{ + // this seg is completely behind the mirror! + for(int i=0;inumlines;i++) + { + if (P_PointOnLineSide(sub->firstline[i].v1->x, sub->firstline[i].v1->y, linedef) == 0) return PClip_Inside; + } + return PClip_InFront; +} + int GLMirrorPortal::ClipPoint(fixed_t x, fixed_t y) { if (P_PointOnLineSide(x, y, linedef)) diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 384a34f7d..c7c07986b 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -160,6 +160,7 @@ public: } virtual int ClipSeg(seg_t *seg) { return PClip_Inside; } + virtual int ClipSubsector(subsector_t *sub) { return PClip_Inside; } virtual int ClipPoint(fixed_t x, fixed_t y) { return PClip_Inside; } static void BeginScene(); @@ -189,6 +190,7 @@ public: virtual bool NeedCap() { return false; } virtual int ClipSeg(seg_t *seg); + virtual int ClipSubsector(subsector_t *sub); virtual int ClipPoint(fixed_t x, fixed_t y); }; From 47db3252f4916c7e5473d5209b6d421286d59d6e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 27 Jan 2016 12:30:55 +0100 Subject: [PATCH 0362/1509] - it's really not necessary to waste two clip planes for reflective surfaces because only one can be active at any time. --- src/gl/scene/gl_portal.cpp | 9 ++++----- wadsrc/static/shaders/glsl/main.vp | 10 ++++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index a22c25e2d..b5ef31e36 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -291,7 +291,6 @@ bool GLPortal::Start(bool usestencil, bool doquery) planestack.Push(gl_RenderState.GetClipHeightTop()); planestack.Push(gl_RenderState.GetClipHeightBottom()); glDisable(GL_CLIP_DISTANCE0); - glDisable(GL_CLIP_DISTANCE1); gl_RenderState.SetClipHeightBottom(-65536.f); gl_RenderState.SetClipHeightTop(65536.f); @@ -360,7 +359,7 @@ void GLPortal::End(bool usestencil) if (f > -65535.f) glEnable(GL_CLIP_DISTANCE0); planestack.Pop(f); gl_RenderState.SetClipHeightTop(f); - if (f < 65535.f) glEnable(GL_CLIP_DISTANCE1); + if (f < 65535.f) glEnable(GL_CLIP_DISTANCE0); if (usestencil) { @@ -808,17 +807,17 @@ void GLPlaneMirrorPortal::DrawContents() if (PlaneMirrorMode < 0) { gl_RenderState.SetClipHeightTop(f); // ceiling mirror: clip everything with a z lower than the portal's ceiling - glEnable(GL_CLIP_DISTANCE1); + gl_RenderState.SetClipHeightBottom(-65536.f); } else { gl_RenderState.SetClipHeightBottom(f); // floor mirror: clip everything with a z higher than the portal's floor - glEnable(GL_CLIP_DISTANCE0); + gl_RenderState.SetClipHeightTop(65536.f); } + glEnable(GL_CLIP_DISTANCE0); GLRenderer->DrawScene(); glDisable(GL_CLIP_DISTANCE0); - glDisable(GL_CLIP_DISTANCE1); gl_RenderState.SetClipHeightBottom(-65536.f); gl_RenderState.SetClipHeightTop(65536.f); PlaneMirrorFlag--; diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 75f814887..0aef2d35a 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -45,8 +45,14 @@ void main() gl_Position = ProjectionMatrix * eyeCoordPos; // clip planes used for reflective flats - gl_ClipDistance[0] = worldcoord.y - uClipHeightBottom; - gl_ClipDistance[1] = uClipHeightTop - worldcoord.y; + if (uClipHeightBottom > -65536.0) + { + gl_ClipDistance[0] = worldcoord.y - uClipHeightBottom; + } + else if (uClipHeightTop < 65536.0) + { + gl_ClipDistance[0] = uClipHeightTop - worldcoord.y; + } gl_ClipDistance[2] = worldcoord.y - uClipSplit.x; gl_ClipDistance[3] = uClipSplit.y - worldcoord.y; From 238990c8718ed89ee49eb65a4eeecae040159321 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 27 Jan 2016 12:32:39 +0100 Subject: [PATCH 0363/1509] don't leave any gaps in the used clip planes. --- src/gl/scene/gl_drawinfo.cpp | 4 ++-- wadsrc/static/shaders/glsl/main.vp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 4dba1a2a0..72e0c8d1d 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -767,11 +767,11 @@ void GLDrawList::DrawSorted() sorted=DoSort(SortNodes[SortNodeStart]); } gl_RenderState.ClearClipSplit(); + glEnable(GL_CLIP_DISTANCE1); glEnable(GL_CLIP_DISTANCE2); - glEnable(GL_CLIP_DISTANCE3); DoDrawSorted(sorted); + glDisable(GL_CLIP_DISTANCE1); glDisable(GL_CLIP_DISTANCE2); - glDisable(GL_CLIP_DISTANCE3); gl_RenderState.ClearClipSplit(); } diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 0aef2d35a..827644eea 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -54,6 +54,6 @@ void main() gl_ClipDistance[0] = uClipHeightTop - worldcoord.y; } - gl_ClipDistance[2] = worldcoord.y - uClipSplit.x; - gl_ClipDistance[3] = uClipSplit.y - worldcoord.y; + gl_ClipDistance[1] = worldcoord.y - uClipSplit.x; + gl_ClipDistance[2] = uClipSplit.y - worldcoord.y; } From d037493ffe735566a30b7b22b5e0976307ae2852 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 29 Jan 2016 17:13:14 +0100 Subject: [PATCH 0364/1509] - fixed handling of FF_FADEWALLS on 3D floors. The problems with the old method became quite obvious in the demo map after the light list bug got fixed. --- src/gl/renderer/gl_colormap.h | 3 +++ src/gl/renderer/gl_lightdata.h | 12 ++++++++++++ src/gl/scene/gl_flats.cpp | 9 +++++---- src/gl/scene/gl_sprite.cpp | 6 +++--- src/gl/scene/gl_wall.h | 1 - src/gl/scene/gl_walls.cpp | 28 ++-------------------------- src/gl/scene/gl_walls_draw.cpp | 8 -------- src/gl/textures/gl_bitmap.cpp | 1 - src/p_3dfloors.cpp | 5 ----- src/p_3dfloors.h | 1 - 10 files changed, 25 insertions(+), 49 deletions(-) diff --git a/src/gl/renderer/gl_colormap.h b/src/gl/renderer/gl_colormap.h index 8126cb5d4..2122b1248 100644 --- a/src/gl/renderer/gl_colormap.h +++ b/src/gl/renderer/gl_colormap.h @@ -7,6 +7,7 @@ extern DWORD gl_fixedcolormap; +struct lightlist_t; enum EColorManipulation { @@ -64,6 +65,8 @@ struct FColormap blendfactor = from->Color.a; } + void CopyFrom3DLight(lightlist_t *light); + void Decolorize() // this for 'nocoloredspritelighting' and not the same as desaturation. The normal formula results in a value that's too dark. { int v = (LightColor.r + LightColor.g + LightColor.b) / 3; diff --git a/src/gl/renderer/gl_lightdata.h b/src/gl/renderer/gl_lightdata.h index f76f732af..4cc7a7d04 100644 --- a/src/gl/renderer/gl_lightdata.h +++ b/src/gl/renderer/gl_lightdata.h @@ -2,6 +2,7 @@ #define __GL_LIGHTDATA #include "v_palette.h" +#include "p_3dfloors.h" #include "r_data/renderstyle.h" #include "gl/renderer/gl_colormap.h" @@ -49,4 +50,15 @@ extern int outsidefogdensity; extern int skyfog; +inline void FColormap::CopyFrom3DLight(lightlist_t *light) +{ + LightColor = light->extra_colormap->Color; + desaturation = light->extra_colormap->Desaturate; + blendfactor = light->extra_colormap->Color.a; + if (light->caster && (light->caster->flags&FF_FADEWALLS) && (light->extra_colormap->Fade & 0xffffff) != 0) + FadeColor = light->extra_colormap->Fade; +} + + + #endif \ No newline at end of file diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 16b892b15..c747236d2 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -466,7 +466,8 @@ void GLFlat::SetFrom3DFloor(F3DFloor *rover, bool top, bool underside) lightlevel = *light->p_lightlevel; if (rover->flags & FF_FOG) Colormap.LightColor = (light->extra_colormap)->Fade; - else Colormap.CopyLightColor(light->extra_colormap); + else Colormap.CopyFrom3DLight(light); + alpha = rover->alpha/255.0f; renderstyle = rover->flags&FF_ADDITIVETRANS? STYLE_Add : STYLE_Translucent; @@ -546,13 +547,13 @@ void GLFlat::ProcessSector(sector_t * frontsector) if (x.ffloors.Size()) { light = P_GetPlaneLight(sector, &frontsector->floorplane, false); - if ((!(sector->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING) || !light->fromsector) + if ((!(sector->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING) || light->lightsource == NULL) && (light->p_lightlevel != &frontsector->lightlevel)) { lightlevel = *light->p_lightlevel; } - Colormap.CopyLightColor(light->extra_colormap); + Colormap.CopyFrom3DLight(light); } renderstyle = STYLE_Translucent; if (alpha!=0.0f) Process(frontsector, false, false); @@ -604,7 +605,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) { lightlevel = *light->p_lightlevel; } - Colormap.CopyLightColor(light->extra_colormap); + Colormap.CopyFrom3DLight(light); } renderstyle = STYLE_Translucent; if (alpha!=0.0f) Process(frontsector, true, false); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 75e698762..2abfd47f7 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -349,8 +349,8 @@ void GLSprite::SplitSprite(sector_t * frontsector, bool translucent) { copySprite=*this; copySprite.lightlevel = gl_ClampLight(*lightlist[i].p_lightlevel); - copySprite.Colormap.CopyLightColor(lightlist[i].extra_colormap); - + copySprite.Colormap.CopyFrom3DLight(&lightlist[i]); + if (glset.nocoloredspritelighting) { int v = (copySprite.Colormap.LightColor.r + copySprite.Colormap.LightColor.g + copySprite.Colormap.LightColor.b )/3; @@ -389,7 +389,7 @@ void GLSprite::SetSpriteColor(sector_t *sector, fixed_t center_y) if (maplightbottomGetTransparent() && passflag[type] == 2) @@ -162,10 +161,6 @@ void GLWall::PutWall(bool translucent) } else switch (type) { - case RENDERWALL_COLORLAYER: - gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].AddWall(this); - break; - // portals don't go into the draw list. // Instead they are added to the portal manager case RENDERWALL_HORIZON: @@ -230,9 +225,6 @@ void GLWall::PutWall(bool translucent) void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent) { - bool fadewall = (!translucent && lightlist->caster && (lightlist->caster->flags&FF_FADEWALLS) && - !gl_isBlack((lightlist->extra_colormap)->Fade)) && gl_isBlack(Colormap.FadeColor); - // only modify the light level if it doesn't originate from the seg's frontsector. This is to account for light transferring effects if (lightlist->p_lightlevel != &seg->sidedef->sector->lightlevel) { @@ -240,23 +232,8 @@ void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent) } // relative light won't get changed here. It is constant across the entire wall. - Colormap.CopyLightColor(lightlist->extra_colormap); - if (fadewall) lightlevel=255; + Colormap.CopyFrom3DLight(lightlist); PutWall(translucent); - - if (fadewall) - { - FMaterial *tex = gltexture; - type = RENDERWALL_COLORLAYER; - gltexture = NULL; - Colormap.LightColor = (lightlist->extra_colormap)->Fade; - alpha = (255-(*lightlist->p_lightlevel))/255.f*1.f; - if (alpha>0.f) PutWall(true); - - type = RENDERWALL_FFBLOCK; - alpha = 1.0; - gltexture = tex; - } } //========================================================================== @@ -410,8 +387,7 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) int ll=lightlevel; FColormap lc=Colormap; - if (i > 0) Put3DWall(&lightlist[i], translucent); - else PutWall(translucent); // uppermost section does not alter light at all. + Put3DWall(&lightlist[i], translucent); lightlevel=ll; Colormap=lc; diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 5cf321ec8..ce14e16d3 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -79,7 +79,6 @@ void GLWall::SetupLights() case RENDERWALL_FOGBOUNDARY: case RENDERWALL_MIRRORSURFACE: case RENDERWALL_COLOR: - case RENDERWALL_COLORLAYER: return; } @@ -429,13 +428,6 @@ void GLWall::Draw(int pass) RenderFogBoundary(); break; - case RENDERWALL_COLORLAYER: - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(-1.0f, -128.0f); - RenderTranslucentWall(); - glDisable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(0, 0); - default: RenderTranslucentWall(); break; diff --git a/src/gl/textures/gl_bitmap.cpp b/src/gl/textures/gl_bitmap.cpp index 991ebc650..ee28e8911 100644 --- a/src/gl/textures/gl_bitmap.cpp +++ b/src/gl/textures/gl_bitmap.cpp @@ -39,7 +39,6 @@ #include "v_palette.h" #include "templates.h" -#include "gl/renderer/gl_lightdata.h" #include "gl/textures/gl_translate.h" #include "gl/textures/gl_bitmap.h" #include "gl/system/gl_interface.h" diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index f915c3e0f..c4a057e63 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -593,8 +593,6 @@ void P_Recalculate3DFloors(sector_t * sector) lightlist[0].extra_colormap = sector->ColorMap; lightlist[0].blend = 0; lightlist[0].flags = 0; - lightlist[0].fromsector = true; - resetlight = lightlist[0]; @@ -618,7 +616,6 @@ void P_Recalculate3DFloors(sector_t * sector) newlight.extra_colormap = rover->GetColormap(); newlight.blend = rover->GetBlend(); newlight.flags = rover->flags; - newlight.fromsector = false; lightlist.Push(newlight); } else @@ -633,7 +630,6 @@ void P_Recalculate3DFloors(sector_t * sector) lightlist[0].extra_colormap = rover->GetColormap(); lightlist[0].blend = rover->GetBlend(); lightlist[0].flags = rover->flags; - lightlist[0].fromsector = false; } } if (!(rover->flags & (FF_DOUBLESHADOW | FF_RESET))) @@ -660,7 +656,6 @@ void P_Recalculate3DFloors(sector_t * sector) newlight.extra_colormap = resetlight.extra_colormap; newlight.blend = resetlight.blend; newlight.flags = rover->flags; - newlight.fromsector = false; lightlist.Push(newlight); } } diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index 93fd13d1b..5ddded3d3 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -120,7 +120,6 @@ struct lightlist_t int flags; F3DFloor* lightsource; F3DFloor* caster; - bool fromsector; }; From 342f1abcc7882183f00df1da4c17d09515f57307 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Jan 2016 00:45:47 +0100 Subject: [PATCH 0365/1509] - fixed: flickering dynamic lights with their first intensity value larger than the second one weren't properly linked into all touching sectors. --- src/gl/dynlights/a_dynlight.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 575fa2e11..9a13d9e09 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -42,6 +42,7 @@ #include "g_level.h" #include "thingdef/thingdef.h" #include "i_system.h" +#include "templates.h" #include "gl/renderer/gl_renderer.h" @@ -361,7 +362,7 @@ void ADynamicLight::UpdateLocation() if (lighttype == FlickerLight || lighttype == RandomFlickerLight) { - intensity = float(m_intensity[1]); + intensity = float(MAX(m_intensity[0], m_intensity[1])); } else { From 4a9b2bf76d148b95a3baa71aa67601cf5643856e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Jan 2016 01:08:11 +0100 Subject: [PATCH 0366/1509] - fixed: The stencil cap drawer did not properly advance the vertex pointer. --- src/gl/scene/gl_portal.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index b5ef31e36..42e6fb143 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -154,15 +154,17 @@ void GLPortal::DrawPortalStencil() // Cap the stencil at the top and bottom int n = lines.Size() * 2; FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(-32767.0f, 32767.0f, -32767.0f, 0, 0); - ptr->Set(-32767.0f, 32767.0f, 32767.0f, 0, 0); - ptr->Set(32767.0f, 32767.0f, 32767.0f, 0, 0); - ptr->Set(32767.0f, 32767.0f, -32767.0f, 0, 0); + ptr[0].Set(-32767.0f, 32767.0f, -32767.0f, 0, 0); + ptr[1].Set(-32767.0f, 32767.0f, 32767.0f, 0, 0); + ptr[2].Set(32767.0f, 32767.0f, 32767.0f, 0, 0); + ptr[3].Set(32767.0f, 32767.0f, -32767.0f, 0, 0); + ptr += 4; mPrimIndices[n + 1] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n]); - ptr->Set(-32767.0f, -32767.0f, -32767.0f, 0, 0); - ptr->Set(-32767.0f, -32767.0f, 32767.0f, 0, 0); - ptr->Set(32767.0f, -32767.0f, 32767.0f, 0, 0); - ptr->Set(32767.0f, -32767.0f, -32767.0f, 0, 0); + ptr[0].Set(-32767.0f, -32767.0f, -32767.0f, 0, 0); + ptr[1].Set(-32767.0f, -32767.0f, 32767.0f, 0, 0); + ptr[2].Set(32767.0f, -32767.0f, 32767.0f, 0, 0); + ptr[3].Set(32767.0f, -32767.0f, -32767.0f, 0, 0); + ptr += 4; mPrimIndices[n + 3] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n + 2]); } } From 37ac6ef9a04078cd0491acab82970e3777fd481f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Jan 2016 02:13:47 +0100 Subject: [PATCH 0367/1509] - fixed: Translucency detection for GL textures was broken. - fixed: Textures which are already scaled should not be upsampled. - fixed: The transparency check in the upscaling code checked the wrong modes for exclusion when handling translucent textures. --- src/gl/textures/gl_hqresize.cpp | 10 +++++++--- src/gl/textures/gl_texture.cpp | 3 +-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 261f66e6a..1563895b5 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -263,6 +263,10 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u if ( inputTexture->bHasCanvas ) return inputBuffer; + // already scaled? + if (inputTexture->xScale >= FRACUNIT*2 && inputTexture->yScale >= FRACUNIT*2) + return inputBuffer; + switch (inputTexture->UseType) { case FTexture::TEX_Sprite: @@ -281,14 +285,14 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u if (inputBuffer) { + int type = gl_texture_hqresize; outWidth = inWidth; outHeight = inHeight; - int type = gl_texture_hqresize; #ifdef HAVE_MMX // ASM-hqNx does not preserve the alpha channel so fall back to C-version for such textures - if (!hasAlpha && type > 3 && type <= 6) + if (!hasAlpha && type > 6 && type <= 9) { - type += 3; + type -= 3; } #endif diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 414f631a4..b7347ae54 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -510,7 +510,7 @@ void FTexture::CheckTrans(unsigned char * buffer, int size, int trans) if (trans == -1) { DWORD * dwbuf = (DWORD*)buffer; - if (gl_info.mIsTransparent == -1) for(int i=0;i>24; @@ -521,7 +521,6 @@ void FTexture::CheckTrans(unsigned char * buffer, int size, int trans) } } } - gl_info.mIsTransparent = 0; } } From fc57180d7e8737ab869517b34fafa9406bc7b27c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Jan 2016 23:01:11 +0100 Subject: [PATCH 0368/1509] - added necessary state to implement 3D light splitting using hardware clipping planes. --- src/gl/renderer/gl_renderstate.cpp | 16 ++++++++++++++-- src/gl/renderer/gl_renderstate.h | 13 +++++++++++++ src/gl/scene/gl_wall.h | 2 ++ src/gl/shaders/gl_shader.cpp | 2 ++ src/gl/shaders/gl_shader.h | 4 ++++ src/gl/system/gl_interface.cpp | 2 +- wadsrc/static/shaders/glsl/main.vp | 7 +++++++ 7 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 15aa56da9..d7f46e07e 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -69,7 +69,7 @@ TArray gl_MatrixStack; void FRenderState::Reset() { mTextureEnabled = true; - mBrightmapEnabled = mFogEnabled = mGlowEnabled = false; + mSplitEnabled = mBrightmapEnabled = mFogEnabled = mGlowEnabled = false; mColorMask[0] = mColorMask[1] = mColorMask[2] = mColorMask[3] = true; currentColorMask[0] = currentColorMask[1] = currentColorMask[2] = currentColorMask[3] = true; mFogColor.d = -1; @@ -104,6 +104,7 @@ void FRenderState::Reset() bool FRenderState::ApplyShader() { + static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f }; if (mSpecialEffect > EFF_NONE) { activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect); @@ -157,7 +158,6 @@ bool FRenderState::ApplyShader() else if (activeShader->currentglowstate) { // if glowing is on, disable it. - static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f }; activeShader->muGlowTopColor.Set(nulvec); activeShader->muGlowBottomColor.Set(nulvec); activeShader->muGlowTopPlane.Set(nulvec); @@ -165,6 +165,18 @@ bool FRenderState::ApplyShader() activeShader->currentglowstate = 0; } + if (mSplitEnabled) + { + activeShader->muSplitTopPlane.Set(mSplitTopPlane.vec); + activeShader->muSplitBottomPlane.Set(mSplitBottomPlane.vec); + activeShader->currentsplitstate = 1; + } + else + { + activeShader->muSplitTopPlane.Set(nulvec); + activeShader->muSplitBottomPlane.Set(nulvec); + } + if (mColormapState != activeShader->currentfixedcolormap) { float r, g, b; diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index aa24072c2..d46bb4996 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -46,6 +46,7 @@ class FRenderState bool mTextureEnabled; bool mFogEnabled; bool mGlowEnabled; + bool mSplitEnabled; bool mBrightmapEnabled; bool mColorMask[4]; bool currentColorMask[4]; @@ -72,6 +73,7 @@ class FRenderState FStateVec4 mCameraPos; FStateVec4 mGlowTop, mGlowBottom; FStateVec4 mGlowTopPlane, mGlowBottomPlane; + FStateVec4 mSplitTopPlane, mSplitBottomPlane; PalEntry mFogColor; PalEntry mObjectColor; FStateVec4 mDynColor; @@ -229,6 +231,11 @@ public: mGlowEnabled = on; } + void EnableSplit(bool on) + { + mSplitEnabled = on; + } + void SetLightIndex(int n) { mLightIndex = n; @@ -272,6 +279,12 @@ public: mGlowBottomPlane.Set(FIXED2FLOAT(bottom.a), FIXED2FLOAT(bottom.b), FIXED2FLOAT(bottom.ic), FIXED2FLOAT(bottom.d)); } + void SetSplitPlanes(const secplane_t &top, const secplane_t &bottom) + { + mSplitTopPlane.Set(FIXED2FLOAT(top.a), FIXED2FLOAT(top.b), FIXED2FLOAT(top.ic), FIXED2FLOAT(top.d)); + mSplitBottomPlane.Set(FIXED2FLOAT(bottom.a), FIXED2FLOAT(bottom.b), FIXED2FLOAT(bottom.ic), FIXED2FLOAT(bottom.d)); + } + void SetDynLight(float r, float g, float b) { mDynColor.Set(r, g, b, 0); diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 5b27d9435..6dc694585 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -150,6 +150,8 @@ public: FTextureID topflat,bottomflat; secplane_t topplane, bottomplane; // we need to save these to pass them to the shader for calculating glows. + secplane_t *toplight, *bottomlight; // These refer to the planes within the lightlist_t entries. + // these are not the same as ytop and ybottom!!! float zceil[2]; float zfloor[2]; diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 2955cf7c8..aa8dfac2b 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -216,6 +216,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muGlowTopColor.Init(hShader, "uGlowTopColor"); muGlowBottomPlane.Init(hShader, "uGlowBottomPlane"); muGlowTopPlane.Init(hShader, "uGlowTopPlane"); + muSplitBottomPlane.Init(hShader, "uSplitBottomPlane"); + muSplitTopPlane.Init(hShader, "uSplitTopPlane"); muFixedColormap.Init(hShader, "uFixedColormap"); muInterpolationFactor.Init(hShader, "uInterpolationFactor"); muClipHeightTop.Init(hShader, "uClipHeightTop"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index c5baceceb..cf6480d9b 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -218,6 +218,8 @@ class FShader FUniform4f muGlowTopColor; FUniform4f muGlowBottomPlane; FUniform4f muGlowTopPlane; + FUniform4f muSplitBottomPlane; + FUniform4f muSplitTopPlane; FBufferedUniform1f muInterpolationFactor; FBufferedUniform1f muClipHeightTop; FBufferedUniform1f muClipHeightBottom; @@ -233,6 +235,7 @@ public: int fakevb_index; private: int currentglowstate; + int currentsplitstate; int currentfixedcolormap; bool currentTextureMatrixState; bool currentModelMatrixState; @@ -243,6 +246,7 @@ public: { hShader = hVertProg = hFragProg = 0; currentglowstate = 0; + currentsplitstate = 0; currentfixedcolormap = 0; currentTextureMatrixState = true; // by setting the matrix state to 'true' it is guaranteed to be set the first time the render state gets applied. currentModelMatrixState = true; diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 2e7d0f1e0..3fd718ff7 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -174,7 +174,7 @@ void gl_LoadExtensions() void gl_PrintStartupLog() { int v = 0; - glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &v); + if (gl.version >= 3.2) glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &v); Printf ("GL_VENDOR: %s\n", glGetString(GL_VENDOR)); Printf ("GL_RENDERER: %s\n", glGetString(GL_RENDERER)); diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 827644eea..1c6aebe47 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -29,6 +29,12 @@ void main() glowdist.x = -((uGlowTopPlane.w + uGlowTopPlane.x * worldcoord.x + uGlowTopPlane.y * worldcoord.z) * uGlowTopPlane.z) - worldcoord.y; glowdist.y = worldcoord.y + ((uGlowBottomPlane.w + uGlowBottomPlane.x * worldcoord.x + uGlowBottomPlane.y * worldcoord.z) * uGlowBottomPlane.z); + + if (uSplitBottomPlane.z != 0) + { + gl_ClipDistance[3] = -((uSplitTopPlane.w + uSplitTopPlane.x * worldcoord.x + uSplitTopPlane.y * worldcoord.z) * uSplitTopPlane.z) - worldcoord.y; + gl_ClipDistance[4] = worldcoord.y + ((uSplitBottomPlane.w + uSplitBottomPlane.x * worldcoord.x + uSplitBottomPlane.y * worldcoord.z) * uSplitBottomPlane.z); + } #endif #ifdef SPHEREMAP @@ -56,4 +62,5 @@ void main() gl_ClipDistance[1] = worldcoord.y - uClipSplit.x; gl_ClipDistance[2] = uClipSplit.y - worldcoord.y; + } From 1d9ab5c63270a3c3ba0e43b546c7135bcc413d56 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 31 Jan 2016 00:45:29 +0100 Subject: [PATCH 0369/1509] - clean out GLWall::SplitWall and instead of actually splitting the wall just attach a list of lights to it. Actual handling will be in the rendering function because this doesn't need multiple vertex transfers to the GPU. All slices can be drawn from the same buffer with different uniform info being set. --- src/gl/scene/gl_wall.h | 13 ++- src/gl/scene/gl_walls.cpp | 205 ++------------------------------------ 2 files changed, 21 insertions(+), 197 deletions(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 6dc694585..1bdc86fe9 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -85,6 +85,15 @@ struct GLSectorPlane }; +struct GLWallLightEntry +{ + secplane_t *cliptop; + secplane_t *clipbottom; + int lightlevel; + FColormap colormap; +}; + +extern FMemArena GLWallLightEntryArena; class GLWall { @@ -126,6 +135,7 @@ public: fixed_t viewdistance; + GLWallLightEntry *lights; int lightlevel; BYTE type; BYTE flags; @@ -150,8 +160,6 @@ public: FTextureID topflat,bottomflat; secplane_t topplane, bottomplane; // we need to save these to pass them to the shader for calculating glows. - secplane_t *toplight, *bottomlight; // These refer to the planes within the lightlist_t entries. - // these are not the same as ytop and ybottom!!! float zceil[2]; float zfloor[2]; @@ -177,7 +185,6 @@ private: void SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2); void SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2); - void Put3DWall(lightlist_t * lightlist, bool translucent); void SplitWall(sector_t * frontsector, bool translucent); void LightPass(); void SetHorizon(vertex_t * ul, vertex_t * ur, vertex_t * ll, vertex_t * lr); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index bbe36b71f..4a7efaf88 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -62,6 +62,8 @@ #include "gl/shaders/gl_shader.h" +FMemArena GLWallLightEntryArena; + //========================================================================== // // Checks whether a wall should glow @@ -217,25 +219,6 @@ void GLWall::PutWall(bool translucent) } } -//========================================================================== -// -// Sets 3D-floor lighting info -// -//========================================================================== - -void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent) -{ - // only modify the light level if it doesn't originate from the seg's frontsector. This is to account for light transferring effects - if (lightlist->p_lightlevel != &seg->sidedef->sector->lightlevel) - { - lightlevel = gl_ClampLight(*lightlist->p_lightlevel); - } - // relative light won't get changed here. It is constant across the entire wall. - - Colormap.CopyFrom3DLight(lightlist); - PutWall(translucent); -} - //========================================================================== // // Splits a wall vertically if a 3D-floor @@ -245,11 +228,6 @@ void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent) void GLWall::SplitWall(sector_t * frontsector, bool translucent) { - GLWall copyWall1,copyWall2; - float maplightbottomleft; - float maplightbottomright; - unsigned int i; - int origlight = lightlevel; TArray & lightlist=frontsector->e->XFloor.lightlist; if (glseg.x1==glseg.x2 && glseg.y1==glseg.y2) @@ -258,178 +236,17 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) } ::SplitWall.Clock(); -#ifdef _DEBUG - if (seg->linedef-lines==1) + lights = (GLWallLightEntry*)GLWallLightEntryArena.Alloc(sizeof(GLWallLightEntry)*lightlist.Size()); + secplane_t *upperplane = &topplane; + for (unsigned i = 0; i < lightlist.Size(); i++) { - int a = 0; + lights[i].cliptop = &lightlist[i].plane; + lights[i].clipbottom = i == lightlist.Size() - 1 ? &bottomplane : &lightlist[i + 1].plane; + lights[i].lightlevel = lightlist[i].caster != NULL? gl_ClampLight(*lightlist[i].p_lightlevel) : lightlevel; + lights[i].colormap.FadeColor = Colormap.FadeColor; + lights[i].colormap.CopyFrom3DLight(&lightlist[i]); } -#endif - - if (lightlist.Size()>1) - { - for(i=0;i=ztop[0] && maplightbottomright>=ztop[1]) - { - continue; - } - - // check for an intersection with the upper plane - if ((maplightbottomleftztop[1]) || - (maplightbottomleft>ztop[0] && maplightbottomright(fabsf(glseg.x2-glseg.x1), fabsf(glseg.y2-glseg.y2)); - - float dch=ztop[1]-ztop[0]; - float dfh=maplightbottomright-maplightbottomleft; - float coeff= (ztop[0]-maplightbottomleft)/(dfh-dch); - - // check for inaccuracies - let's be a little generous here! - if (coeff*clen<.1f) - { - maplightbottomleft=ztop[0]; - } - else if (coeff*clen>clen-.1f) - { - maplightbottomright=ztop[1]; - } - else - { - // split the wall in 2 at the intersection and recursively split both halves - copyWall1=copyWall2=*this; - - copyWall1.glseg.x2 = copyWall2.glseg.x1 = glseg.x1 + coeff * (glseg.x2-glseg.x1); - copyWall1.glseg.y2 = copyWall2.glseg.y1 = glseg.y1 + coeff * (glseg.y2-glseg.y1); - copyWall1.ztop[1] = copyWall2.ztop[0] = ztop[0] + coeff * (ztop[1]-ztop[0]); - copyWall1.zbottom[1] = copyWall2.zbottom[0] = zbottom[0] + coeff * (zbottom[1]-zbottom[0]); - copyWall1.glseg.fracright = copyWall2.glseg.fracleft = glseg.fracleft + coeff * (glseg.fracright-glseg.fracleft); - copyWall1.uprgt.u = copyWall2.uplft.u = uplft.u + coeff * (uprgt.u-uplft.u); - copyWall1.uprgt.v = copyWall2.uplft.v = uplft.v + coeff * (uprgt.v-uplft.v); - copyWall1.lorgt.u = copyWall2.lolft.u = lolft.u + coeff * (lorgt.u-lolft.u); - copyWall1.lorgt.v = copyWall2.lolft.v = lolft.v + coeff * (lorgt.v-lolft.v); - - ::SplitWall.Unclock(); - - copyWall1.SplitWall(frontsector, translucent); - copyWall2.SplitWall(frontsector, translucent); - return; - } - } - - // check for an intersection with the lower plane - if ((maplightbottomleftzbottom[1]) || - (maplightbottomleft>zbottom[0] && maplightbottomright(fabsf(glseg.x2-glseg.x1), fabsf(glseg.y2-glseg.y2)); - - float dch=zbottom[1]-zbottom[0]; - float dfh=maplightbottomright-maplightbottomleft; - float coeff= (zbottom[0]-maplightbottomleft)/(dfh-dch); - - // check for inaccuracies - let's be a little generous here because there's - // some conversions between floats and fixed_t's involved - if (coeff*clen<.1f) - { - maplightbottomleft=zbottom[0]; - } - else if (coeff*clen>clen-.1f) - { - maplightbottomright=zbottom[1]; - } - else - { - // split the wall in 2 at the intersection and recursively split both halves - copyWall1=copyWall2=*this; - - copyWall1.glseg.x2 = copyWall2.glseg.x1 = glseg.x1 + coeff * (glseg.x2-glseg.x1); - copyWall1.glseg.y2 = copyWall2.glseg.y1 = glseg.y1 + coeff * (glseg.y2-glseg.y1); - copyWall1.ztop[1] = copyWall2.ztop[0] = ztop[0] + coeff * (ztop[1]-ztop[0]); - copyWall1.zbottom[1] = copyWall2.zbottom[0] = zbottom[0] + coeff * (zbottom[1]-zbottom[0]); - copyWall1.glseg.fracright = copyWall2.glseg.fracleft = glseg.fracleft + coeff * (glseg.fracright-glseg.fracleft); - copyWall1.uprgt.u = copyWall2.uplft.u = uplft.u + coeff * (uprgt.u-uplft.u); - copyWall1.uprgt.v = copyWall2.uplft.v = uplft.v + coeff * (uprgt.v-uplft.v); - copyWall1.lorgt.u = copyWall2.lolft.u = lolft.u + coeff * (lorgt.u-lolft.u); - copyWall1.lorgt.v = copyWall2.lolft.v = lolft.v + coeff * (lorgt.v-lolft.v); - - ::SplitWall.Unclock(); - - copyWall1.SplitWall(frontsector, translucent); - copyWall2.SplitWall(frontsector, translucent); - return; - } - } - - // 3D floor is completely within this light - if (maplightbottomleft<=zbottom[0] && maplightbottomright<=zbottom[1]) - { - // These values must not be destroyed! - int ll=lightlevel; - FColormap lc=Colormap; - - Put3DWall(&lightlist[i], translucent); - - lightlevel=ll; - Colormap=lc; - - ::SplitWall.Unclock(); - - return; - } - - if (maplightbottomleft<=ztop[0] && maplightbottomright<=ztop[1] && - (maplightbottomleft!=ztop[0] || maplightbottomright!=ztop[1])) - { - copyWall1=*this; - - copyWall1.flags |= GLWF_NOSPLITLOWER; - flags |= GLWF_NOSPLITUPPER; - ztop[0]=copyWall1.zbottom[0]=maplightbottomleft; - ztop[1]=copyWall1.zbottom[1]=maplightbottomright; - uplft.v=copyWall1.lolft.v=copyWall1.uplft.v+ - (maplightbottomleft-copyWall1.ztop[0])*(copyWall1.lolft.v-copyWall1.uplft.v)/(zbottom[0]-copyWall1.ztop[0]); - uprgt.v=copyWall1.lorgt.v=copyWall1.uprgt.v+ - (maplightbottomright-copyWall1.ztop[1])*(copyWall1.lorgt.v-copyWall1.uprgt.v)/(zbottom[1]-copyWall1.ztop[1]); - copyWall1.Put3DWall(&lightlist[i], translucent); - } - if (ztop[0]==zbottom[0] && ztop[1]==zbottom[1]) - { - ::SplitWall.Unclock(); - return; - } - } - } - - // These values must not be destroyed! - int ll=lightlevel; - FColormap lc=Colormap; - - Put3DWall(&lightlist[lightlist.Size()-1], translucent); - - lightlevel=ll; - Colormap=lc; - flags &= ~GLWF_NOSPLITUPPER; - ::SplitWall.Unclock(); + PutWall(translucent); } From f86535407d8a7626e877939b5daa3ca44201aad9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 31 Jan 2016 00:52:50 +0100 Subject: [PATCH 0370/1509] - forgot this. --- src/gl/scene/gl_scene.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 7a961d2cd..99776afbe 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -838,6 +838,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo angle_t a1 = FrustumAngle(); clipper.SafeAddClipRangeRealAngles(viewangle + a1, viewangle - a1); + GLWallLightEntryArena.FreeAll(); ProcessScene(toscreen); if (mainview) EndDrawScene(retval); // do not call this for camera textures. eye->TearDown(); From 5448b335c6f534dbf91b6a26e32e649905b95795 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 31 Jan 2016 21:10:59 +0100 Subject: [PATCH 0371/1509] - rewrote render loop for walls. Not working yet. --- src/gl/scene/gl_wall.h | 3 +- src/gl/scene/gl_walls.cpp | 4 +- src/gl/scene/gl_walls_draw.cpp | 139 +++++++++++++++------------------ 3 files changed, 69 insertions(+), 77 deletions(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 1bdc86fe9..c9b2e12bd 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -114,7 +114,6 @@ public: { RWF_BLANK = 0, RWF_TEXTURED = 1, // actually not being used anymore because with buffers it's even less efficient not writing the texture coordinates - but leave it here - RWF_GLOW = 2, RWF_NOSPLIT = 4, RWF_NORENDER = 8, }; @@ -136,6 +135,7 @@ public: fixed_t viewdistance; GLWallLightEntry *lights; + unsigned int lightsize; int lightlevel; BYTE type; BYTE flags; @@ -176,6 +176,7 @@ private: void SetupLights(); bool PrepareLight(texcoord * tcs, ADynamicLight * light); void RenderWall(int textured, unsigned int *store = NULL); + void RenderTextured(int rflags); void FloodPlane(int pass); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 4a7efaf88..d9eb74354 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -236,7 +236,8 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) } ::SplitWall.Clock(); - lights = (GLWallLightEntry*)GLWallLightEntryArena.Alloc(sizeof(GLWallLightEntry)*lightlist.Size()); + lightsize = lightlist.Size(); + lights = (GLWallLightEntry*)GLWallLightEntryArena.Alloc(sizeof(GLWallLightEntry)*lightsize); secplane_t *upperplane = &topplane; for (unsigned i = 0; i < lightlist.Size(); i++) { @@ -1293,6 +1294,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) Colormap = frontsector->ColorMap; flags = 0; dynlightindex = UINT_MAX; + lights = NULL; int rel = 0; int orglightlevel = gl_ClampLight(frontsector->lightlevel); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index ce14e16d3..90eddd2e9 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -182,11 +182,6 @@ void GLWall::RenderWall(int textured, unsigned int *store) tcs[1]=uplft; tcs[2]=uprgt; tcs[3]=lorgt; - if ((flags&GLWF_GLOW) && (textured & RWF_GLOW)) - { - gl_RenderState.SetGlowPlanes(topplane, bottomplane); - gl_RenderState.SetGlowParams(topglowcolor, bottomglowcolor); - } if (!(textured & RWF_NORENDER)) { @@ -306,6 +301,59 @@ void GLWall::RenderMirrorSurface() } } +//========================================================================== +// +// +// +//========================================================================== + +void GLWall::RenderTextured(int rflags) +{ + int tmode = gl_RenderState.GetTextureMode(); + int rel = getExtraLight(); + + if (flags & GLWF_GLOW) + { + gl_RenderState.EnableGlow(true); + gl_RenderState.SetGlowPlanes(topplane, bottomplane); + gl_RenderState.SetGlowParams(topglowcolor, bottomglowcolor); + } + gl_RenderState.SetMaterial(gltexture, flags & 3, 0, -1, false); + + if (type == RENDERWALL_M2SNF) + { + if (flags & GLT_CLAMPY) + { + if (tmode == TM_MODULATE) gl_RenderState.SetTextureMode(TM_CLAMPY); + } + gl_SetFog(255, 0, NULL, false); + } + + float absalpha = fabsf(alpha); + if (lights == NULL) + { + gl_SetColor(lightlevel, rel, Colormap, absalpha); + if (type != RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, RenderStyle == STYLE_Add); + RenderWall(rflags); + } + else + { + unsigned int store[2]; + //RenderWall(rflags, store); + gl_RenderState.EnableSplit(true); + for (unsigned i = 0; i < lightsize; i++) + { + gl_SetColor(lights[i].lightlevel, rel, lights[i].colormap, absalpha); + if (type != RENDERWALL_M2SNF) gl_SetFog(lights[i].lightlevel, rel, &lights[i].colormap, RenderStyle == STYLE_Add); + gl_RenderState.SetSplitPlanes(*lights[i].cliptop, *lights[i].clipbottom); + //GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, store[0], store[1]); + RenderWall(rflags); + } + gl_RenderState.EnableSplit(false); + } + gl_RenderState.SetTextureMode(tmode); + gl_RenderState.EnableGlow(false); +} //========================================================================== // @@ -315,57 +363,26 @@ void GLWall::RenderMirrorSurface() void GLWall::RenderTranslucentWall() { - bool transparent = gltexture? gltexture->GetTransparent() : false; - - // currently the only modes possible are solid, additive or translucent - // and until that changes I won't fix this code for the new blending modes! - bool isadditive = RenderStyle == STYLE_Add; - if (gl_fixedcolormap == CM_DEFAULT && gl_lights && (gl.flags & RFL_BUFFER_STORAGE)) { SetupLights(); } - - if (!transparent) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); - else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); - if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE); - - int extra; - if (gltexture) + if (gltexture) { - gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); - gl_RenderState.SetMaterial(gltexture, flags & 3, 0, -1, false); - extra = getExtraLight(); + if (!gltexture->GetTransparent()) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); + else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + if (RenderStyle == STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE); + RenderTextured(RWF_TEXTURED | RWF_NOSPLIT); + if (RenderStyle == STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } - else - { - gl_RenderState.EnableTexture(false); - extra = 0; - } - int tmode = gl_RenderState.GetTextureMode(); - - gl_SetColor(lightlevel, extra, Colormap, fabsf(alpha)); - if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, extra, &Colormap, isadditive); else { - if (flags & GLT_CLAMPY) - { - if (tmode == TM_MODULATE) gl_RenderState.SetTextureMode(TM_CLAMPY); - } - gl_SetFog(255, 0, NULL, false); - } - - RenderWall(RWF_TEXTURED|RWF_NOSPLIT); - - // restore default settings - if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - if (!gltexture) - { + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_SetColor(lightlevel, 0, Colormap, fabsf(alpha)); + gl_SetFog(lightlevel, 0, &Colormap, RenderStyle == STYLE_Add); + RenderWall(RWF_NOSPLIT); gl_RenderState.EnableTexture(true); } - gl_RenderState.EnableGlow(false); - gl_RenderState.SetTextureMode(tmode); } //========================================================================== @@ -375,17 +392,6 @@ void GLWall::RenderTranslucentWall() //========================================================================== void GLWall::Draw(int pass) { - int rel; - int tmode; - -#ifdef _DEBUG - if (seg->linedef-lines==879) - { - int a = 0; - } -#endif - - switch (pass) { case GLPASS_LIGHTSONLY: @@ -396,28 +402,11 @@ void GLWall::Draw(int pass) SetupLights(); // fall through case GLPASS_PLAIN: - rel = rellight + getExtraLight(); - gl_SetColor(lightlevel, rel, Colormap,1.0f); - tmode = gl_RenderState.GetTextureMode(); - if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, false); - else - { - if (flags & GLT_CLAMPY) - { - if (tmode == TM_MODULATE) gl_RenderState.SetTextureMode(TM_CLAMPY); - } - gl_SetFog(255, 0, NULL, false); - } - gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); - gl_RenderState.SetMaterial(gltexture, flags & 3, false, -1, false); - RenderWall(RWF_TEXTURED|RWF_GLOW); - gl_RenderState.EnableGlow(false); - gl_RenderState.SetTextureMode(tmode); + RenderTextured(RWF_TEXTURED); break; case GLPASS_TRANSLUCENT: - switch (type) { case RENDERWALL_MIRRORSURFACE: From 9ce6a7932c669293c612bea9b65c3edcd2f0bb88 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 31 Jan 2016 22:04:20 +0100 Subject: [PATCH 0372/1509] - implemented rendering of 3D lights with clip planes. --- src/gl/scene/gl_walls.cpp | 2 +- src/gl/scene/gl_walls_draw.cpp | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index d9eb74354..2e4e21e5c 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -242,7 +242,7 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) for (unsigned i = 0; i < lightlist.Size(); i++) { lights[i].cliptop = &lightlist[i].plane; - lights[i].clipbottom = i == lightlist.Size() - 1 ? &bottomplane : &lightlist[i + 1].plane; + lights[i].clipbottom = i == lightlist.Size() - 1 ? (secplane_t*)NULL : &lightlist[i + 1].plane; lights[i].lightlevel = lightlist[i].caster != NULL? gl_ClampLight(*lightlist[i].p_lightlevel) : lightlevel; lights[i].colormap.FadeColor = Colormap.FadeColor; lights[i].colormap.CopyFrom3DLight(&lightlist[i]); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 90eddd2e9..4bff69238 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -338,17 +338,18 @@ void GLWall::RenderTextured(int rflags) } else { - unsigned int store[2]; - //RenderWall(rflags, store); gl_RenderState.EnableSplit(true); - for (unsigned i = 0; i < lightsize; i++) + glEnable(GL_CLIP_DISTANCE3); + glEnable(GL_CLIP_DISTANCE4); + for (unsigned i = 0; i mVBO->RenderArray(GL_TRIANGLE_FAN, store[0], store[1]); + gl_RenderState.SetSplitPlanes(*lights[i].cliptop, lights[i].clipbottom? *lights[i].clipbottom : bottomplane); RenderWall(rflags); } + glDisable(GL_CLIP_DISTANCE3); + glDisable(GL_CLIP_DISTANCE4); gl_RenderState.EnableSplit(false); } gl_RenderState.SetTextureMode(tmode); From 53a389aafc2d5827bcf120b8412386498bf7df89 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 31 Jan 2016 22:24:48 +0100 Subject: [PATCH 0373/1509] - fixed: for untextured walls, the texture must be disabled before rendering. - fixed: untextured walls should never be passed to SplitWall. - fixed: untextured walls should not be affected by dynamic lights (it's either fog boundaries or outsides of 3D fog volumes.) --- src/gl/scene/gl_walls.cpp | 10 ++++++---- src/gl/scene/gl_walls_draw.cpp | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 2e4e21e5c..6e51c2702 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -248,6 +248,8 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) lights[i].colormap.CopyFrom3DLight(&lightlist[i]); } PutWall(translucent); + lights = NULL; + lightsize = 0; } @@ -543,7 +545,7 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg, // Add this wall to the render list sector_t * sec = sub? sub->sector : seg->frontsector; - if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(false); + if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap || !gltexture) PutWall(false); else SplitWall(sec, false); glseg=glsave; @@ -832,7 +834,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // Draw the stuff // // - if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) split.PutWall(translucent); + if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap || !gltexture) split.PutWall(translucent); else split.SplitWall(realfront, translucent); t=1; @@ -846,7 +848,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // Draw the stuff without splitting // // - if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(translucent); + if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap || !gltexture) PutWall(translucent); else SplitWall(realfront, translucent); } alpha=1.0f; @@ -958,7 +960,7 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, sector_t * sec = sub? sub->sector : seg->frontsector; - if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(translucent); + if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap || !gltexture) PutWall(translucent); else SplitWall(sec, translucent); alpha=1.0f; diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 4bff69238..814bc3545 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -364,12 +364,12 @@ void GLWall::RenderTextured(int rflags) void GLWall::RenderTranslucentWall() { - if (gl_fixedcolormap == CM_DEFAULT && gl_lights && (gl.flags & RFL_BUFFER_STORAGE)) - { - SetupLights(); - } if (gltexture) { + if (gl_fixedcolormap == CM_DEFAULT && gl_lights && (gl.flags & RFL_BUFFER_STORAGE)) + { + SetupLights(); + } if (!gltexture->GetTransparent()) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); if (RenderStyle == STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE); @@ -381,6 +381,7 @@ void GLWall::RenderTranslucentWall() gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_SetColor(lightlevel, 0, Colormap, fabsf(alpha)); gl_SetFog(lightlevel, 0, &Colormap, RenderStyle == STYLE_Add); + gl_RenderState.EnableTexture(false); RenderWall(RWF_NOSPLIT); gl_RenderState.EnableTexture(true); } From 71da7406bd8961c197e42c57f8275e904c115f4e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Feb 2016 00:42:37 +0100 Subject: [PATCH 0374/1509] - since we no longer split walls at 3D floor boundaries, those planes no longer need to be added to the vertex height lists. --- src/gl/data/gl_setup.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index 5e6e0767b..07e5c8347 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -436,15 +436,6 @@ static void InitVertexData() AddToVertex(sec, vt_sectorlists[v-vertexes]); if (sec->heightsec) AddToVertex(sec->heightsec, vt_sectorlists[v-vertexes]); - - for(l=0;lflags & FF_EXISTS)) continue; - if (rover->flags&FF_NOSHADE) continue; // FF_NOSHADE doesn't create any wall splits - - AddToVertex(rover->model, vt_sectorlists[v-vertexes]); - } } } } From 9305cd86a09579a2b38fea5d29561e21d3d97e9d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Feb 2016 01:03:34 +0100 Subject: [PATCH 0375/1509] - remove the GLWallLightEntry type. Everything it contains can be retrieved from the existing lightlist just as easily, and this approach avoids a lot of memory allocations. - removed the SplitWall profiling timer because all it measures now is an almost empty function. --- src/gl/data/gl_setup.cpp | 1 - src/gl/scene/gl_scene.cpp | 1 - src/gl/scene/gl_wall.h | 13 +------------ src/gl/scene/gl_walls.cpp | 22 +++------------------- src/gl/scene/gl_walls_draw.cpp | 16 +++++++++++----- src/gl/utility/gl_clock.cpp | 9 ++++----- src/gl/utility/gl_clock.h | 2 +- 7 files changed, 20 insertions(+), 44 deletions(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index 07e5c8347..c42a2c19c 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -413,7 +413,6 @@ static void InitVertexData() TArray * vt_sectorlists; int i,j,k; - unsigned int l; vt_sectorlists = new TArray[numvertexes]; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 99776afbe..7a961d2cd 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -838,7 +838,6 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo angle_t a1 = FrustumAngle(); clipper.SafeAddClipRangeRealAngles(viewangle + a1, viewangle - a1); - GLWallLightEntryArena.FreeAll(); ProcessScene(toscreen); if (mainview) EndDrawScene(retval); // do not call this for camera textures. eye->TearDown(); diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index c9b2e12bd..4d83e726b 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -85,16 +85,6 @@ struct GLSectorPlane }; -struct GLWallLightEntry -{ - secplane_t *cliptop; - secplane_t *clipbottom; - int lightlevel; - FColormap colormap; -}; - -extern FMemArena GLWallLightEntryArena; - class GLWall { public: @@ -134,8 +124,7 @@ public: fixed_t viewdistance; - GLWallLightEntry *lights; - unsigned int lightsize; + TArray *lightlist; int lightlevel; BYTE type; BYTE flags; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 6e51c2702..ac90e6123 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -62,8 +62,6 @@ #include "gl/shaders/gl_shader.h" -FMemArena GLWallLightEntryArena; - //========================================================================== // // Checks whether a wall should glow @@ -228,28 +226,14 @@ void GLWall::PutWall(bool translucent) void GLWall::SplitWall(sector_t * frontsector, bool translucent) { - TArray & lightlist=frontsector->e->XFloor.lightlist; if (glseg.x1==glseg.x2 && glseg.y1==glseg.y2) { return; } - ::SplitWall.Clock(); - - lightsize = lightlist.Size(); - lights = (GLWallLightEntry*)GLWallLightEntryArena.Alloc(sizeof(GLWallLightEntry)*lightsize); - secplane_t *upperplane = &topplane; - for (unsigned i = 0; i < lightlist.Size(); i++) - { - lights[i].cliptop = &lightlist[i].plane; - lights[i].clipbottom = i == lightlist.Size() - 1 ? (secplane_t*)NULL : &lightlist[i + 1].plane; - lights[i].lightlevel = lightlist[i].caster != NULL? gl_ClampLight(*lightlist[i].p_lightlevel) : lightlevel; - lights[i].colormap.FadeColor = Colormap.FadeColor; - lights[i].colormap.CopyFrom3DLight(&lightlist[i]); - } + lightlist=&frontsector->e->XFloor.lightlist; PutWall(translucent); - lights = NULL; - lightsize = 0; + lightlist = NULL; } @@ -1296,7 +1280,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) Colormap = frontsector->ColorMap; flags = 0; dynlightindex = UINT_MAX; - lights = NULL; + lightlist = NULL; int rel = 0; int orglightlevel = gl_ClampLight(frontsector->lightlevel); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 814bc3545..cd404f4c9 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -330,7 +330,7 @@ void GLWall::RenderTextured(int rflags) } float absalpha = fabsf(alpha); - if (lights == NULL) + if (lightlist == NULL) { gl_SetColor(lightlevel, rel, Colormap, absalpha); if (type != RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, RenderStyle == STYLE_Add); @@ -341,13 +341,19 @@ void GLWall::RenderTextured(int rflags) gl_RenderState.EnableSplit(true); glEnable(GL_CLIP_DISTANCE3); glEnable(GL_CLIP_DISTANCE4); - for (unsigned i = 0; i Size(); i++) { - gl_SetColor(lights[i].lightlevel, rel, lights[i].colormap, absalpha); - if (type != RENDERWALL_M2SNF) gl_SetFog(lights[i].lightlevel, rel, &lights[i].colormap, RenderStyle == STYLE_Add); - gl_RenderState.SetSplitPlanes(*lights[i].cliptop, lights[i].clipbottom? *lights[i].clipbottom : bottomplane); + int thisll = (*lightlist)[i].caster != NULL? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel; + FColormap thiscm; + thiscm.FadeColor = Colormap.FadeColor; + thiscm.CopyFrom3DLight(&(*lightlist)[i]); + gl_SetColor(thisll, rel, thiscm, absalpha); + if (type != RENDERWALL_M2SNF) gl_SetFog(thisll, rel, &thiscm, RenderStyle == STYLE_Add); + gl_RenderState.SetSplitPlanes((*lightlist)[i].plane, i == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[i + 1].plane); RenderWall(rflags); } + glDisable(GL_CLIP_DISTANCE3); glDisable(GL_CLIP_DISTANCE4); gl_RenderState.EnableSplit(false); diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp index 48c21dde2..545607ea1 100644 --- a/src/gl/utility/gl_clock.cpp +++ b/src/gl/utility/gl_clock.cpp @@ -16,7 +16,7 @@ #include "gl/utility/gl_convert.h" -glcycle_t RenderWall,SetupWall,ClipWall,SplitWall; +glcycle_t RenderWall,SetupWall,ClipWall; glcycle_t RenderFlat,SetupFlat; glcycle_t RenderSprite,SetupSprite; glcycle_t All, Finish, PortalAll, Bsp; @@ -91,7 +91,6 @@ void ResetProfilingData() ProcessAll.Reset(); RenderWall.Reset(); SetupWall.Reset(); - SplitWall.Reset(); ClipWall.Reset(); RenderFlat.Reset(); SetupFlat.Reset(); @@ -111,15 +110,15 @@ void ResetProfilingData() static void AppendRenderTimes(FString &str) { - double setupwall = SetupWall.TimeMS() - SplitWall.TimeMS(); + double setupwall = SetupWall.TimeMS(); double clipwall = ClipWall.TimeMS() - SetupWall.TimeMS(); double bsp = Bsp.TimeMS() - ClipWall.TimeMS() - SetupFlat.TimeMS() - SetupSprite.TimeMS(); - str.AppendFormat("W: Render=%2.3f, Split = %2.3f, Setup=%2.3f, Clip=%2.3f\n" + str.AppendFormat("W: Render=%2.3f, Setup=%2.3f, Clip=%2.3f\n" "F: Render=%2.3f, Setup=%2.3f\n" "S: Render=%2.3f, Setup=%2.3f\n" "All=%2.3f, Render=%2.3f, Setup=%2.3f, BSP = %2.3f, Portal=%2.3f, Drawcalls=%2.3f, Finish=%2.3f\n", - RenderWall.TimeMS(), SplitWall.TimeMS(), setupwall, clipwall, RenderFlat.TimeMS(), SetupFlat.TimeMS(), + RenderWall.TimeMS(), setupwall, clipwall, RenderFlat.TimeMS(), SetupFlat.TimeMS(), RenderSprite.TimeMS(), SetupSprite.TimeMS(), All.TimeMS() + Finish.TimeMS(), RenderAll.TimeMS(), ProcessAll.TimeMS(), bsp, PortalAll.TimeMS(), drawcalls.TimeMS(), Finish.TimeMS()); } diff --git a/src/gl/utility/gl_clock.h b/src/gl/utility/gl_clock.h index 46a01d1e4..4d5163d86 100644 --- a/src/gl/utility/gl_clock.h +++ b/src/gl/utility/gl_clock.h @@ -102,7 +102,7 @@ private: #endif // __APPLE__ -extern glcycle_t RenderWall,SetupWall,ClipWall,SplitWall; +extern glcycle_t RenderWall,SetupWall,ClipWall; extern glcycle_t RenderFlat,SetupFlat; extern glcycle_t RenderSprite,SetupSprite; extern glcycle_t All, Finish, PortalAll, Bsp; From 67fc35e7382c0b6a68b58a5e21a3077b6a63199d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Feb 2016 01:49:49 +0100 Subject: [PATCH 0376/1509] - some cleanup of wall processing code. * removed SplitWall function * split PutWall into PutWall and PutPortal because none of the portal cases needs the overhead for normal walls. --- src/gl/scene/gl_sky.cpp | 22 ++++--- src/gl/scene/gl_wall.h | 20 +++--- src/gl/scene/gl_walls.cpp | 124 ++++++++++++++++---------------------- 3 files changed, 76 insertions(+), 90 deletions(-) diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 7eeda5f3d..c020ab276 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -137,11 +137,12 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor) void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) { + int ptype = -1; FPortal *portal = sector->portals[plane]; if (portal != NULL) { if (GLPortal::instack[1 - plane]) return; - type = RENDERWALL_SECTORSTACK; + ptype = PORTALTYPE_SECTORSTACK; this->portal = portal; } else @@ -156,13 +157,13 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) if (!gl_noskyboxes && skyboxx && GLRenderer->mViewActor != skyboxx && !(skyboxx->flags&MF_JUSTHIT)) { - type = RENDERWALL_SKYBOX; + ptype = PORTALTYPE_SKYBOX; skybox = skyboxx; } else { skyinfo.init(sector->sky, Colormap.FadeColor); - type = RENDERWALL_SKY; + ptype = PORTALTYPE_SKY; sky = UniqueSkies.Get(&skyinfo); } } @@ -170,12 +171,14 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) { if ((plane == sector_t::ceiling && viewz > sector->ceilingplane.d) || (plane == sector_t::floor && viewz < -sector->floorplane.d)) return; - type = RENDERWALL_PLANEMIRROR; + ptype = PORTALTYPE_PLANEMIRROR; planemirror = plane == sector_t::ceiling ? §or->ceilingplane : §or->floorplane; } - else return; } - PutWall(0); + if (ptype != -1) + { + PutPortal(ptype); + } } @@ -189,22 +192,23 @@ void GLWall::SkyLine(line_t *line) { ASkyViewpoint * skyboxx = line->skybox; GLSkyInfo skyinfo; + int ptype; // JUSTHIT is used as an indicator that a skybox is in use. // This is to avoid recursion if (!gl_noskyboxes && skyboxx && GLRenderer->mViewActor != skyboxx && !(skyboxx->flags&MF_JUSTHIT)) { - type = RENDERWALL_SKYBOX; + ptype = PORTALTYPE_SKYBOX; skybox = skyboxx; } else { skyinfo.init(line->frontsector->sky, Colormap.FadeColor); - type = RENDERWALL_SKY; + ptype = PORTALTYPE_SKY; sky = UniqueSkies.Get(&skyinfo); } - PutWall(0); + PutPortal(ptype); } diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 4d83e726b..d9ef91232 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -30,13 +30,7 @@ enum WallTypes RENDERWALL_M1S, RENDERWALL_M2S, RENDERWALL_BOTTOM, - RENDERWALL_SKY, RENDERWALL_FOGBOUNDARY, - RENDERWALL_HORIZON, - RENDERWALL_SKYBOX, - RENDERWALL_SECTORSTACK, - RENDERWALL_PLANEMIRROR, - RENDERWALL_MIRROR, RENDERWALL_MIRRORSURFACE, RENDERWALL_M2SNF, RENDERWALL_COLOR, @@ -44,6 +38,16 @@ enum WallTypes // Insert new types at the end! }; +enum PortalTypes +{ + PORTALTYPE_SKY, + PORTALTYPE_HORIZON, + PORTALTYPE_SKYBOX, + PORTALTYPE_SECTORSTACK, + PORTALTYPE_PLANEMIRROR, + PORTALTYPE_MIRROR, +}; + struct GLSeg { float x1,x2; @@ -159,7 +163,8 @@ public: private: void CheckGlowing(); - void PutWall(bool translucent); + void PutWall(sector_t *sec, bool translucent); + void PutPortal(int ptype); void CheckTexturePosition(); void SetupLights(); @@ -175,7 +180,6 @@ private: void SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2); void SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2); - void SplitWall(sector_t * frontsector, bool translucent); void LightPass(); void SetHorizon(vertex_t * ul, vertex_t * ur, vertex_t * ll, vertex_t * lr); bool DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index ac90e6123..c8808e79b 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -96,57 +96,54 @@ void GLWall::CheckGlowing() // // //========================================================================== -void GLWall::PutWall(bool translucent) +void GLWall::PutWall(sector_t *sec, bool translucent) { - GLPortal * portal; int list; - static char passflag[]={ + static char passflag[] = { 0, //RENDERWALL_NONE, 1, //RENDERWALL_TOP, // unmasked 1, //RENDERWALL_M1S, // unmasked 2, //RENDERWALL_M2S, // depends on render and texture settings 1, //RENDERWALL_BOTTOM, // unmasked - 4, //RENDERWALL_SKYDOME, // special 3, //RENDERWALL_FOGBOUNDARY, // translucent - 4, //RENDERWALL_HORIZON, // special - 4, //RENDERWALL_SKYBOX, // special - 4, //RENDERWALL_SECTORSTACK, // special - 4, //RENDERWALL_PLANEMIRROR, // special - 4, //RENDERWALL_MIRROR, // special - 1, //RENDERWALL_MIRRORSURFACE, // only created here from RENDERWALL_MIRROR + 1, //RENDERWALL_MIRRORSURFACE, // only created from PORTALTYPE_MIRROR 2, //RENDERWALL_M2SNF, // depends on render and texture settings, no fog, used on mid texture lines with a fog boundary. 3, //RENDERWALL_COLOR, // translucent 2, //RENDERWALL_FFBLOCK // depends on render and texture settings }; - + + if (gltexture && gltexture->GetTransparent() && passflag[type] == 2) { translucent = true; } - if (gl_fixedcolormap) + if (gl_fixedcolormap) { // light planes don't get drawn with fullbright rendering - if (!gltexture && passflag[type]!=4) return; - + if (gltexture == NULL) return; Colormap.Clear(); } + else if (sec->e->XFloor.lightlist.Size() > 0 && gltexture != NULL) + { + lightlist = &sec->e->XFloor.lightlist; + } CheckGlowing(); if (translucent) // translucent walls { - viewdistance = P_AproxDistance( ((seg->linedef->v1->x+seg->linedef->v2->x)>>1) - viewx, - ((seg->linedef->v1->y+seg->linedef->v2->y)>>1) - viewy); + viewdistance = P_AproxDistance(((seg->linedef->v1->x + seg->linedef->v2->x) >> 1) - viewx, + ((seg->linedef->v1->y + seg->linedef->v2->y) >> 1) - viewy); gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this); } - else if (passflag[type]!=4) // non-translucent walls + else { bool masked; - masked = passflag[type]==1? false : (gltexture && gltexture->isMasked()); + masked = passflag[type] == 1 ? false : (gltexture && gltexture->isMasked()); if ((flags&GLWF_SKYHACK && type == RENDERWALL_M2S)) { @@ -159,18 +156,25 @@ void GLWall::PutWall(bool translucent) gl_drawinfo->drawlists[list].AddWall(this); } - else switch (type) + lightlist = NULL; +} + +void GLWall::PutPortal(int ptype) +{ + GLPortal * portal; + + switch (ptype) { // portals don't go into the draw list. // Instead they are added to the portal manager - case RENDERWALL_HORIZON: + case PORTALTYPE_HORIZON: horizon=UniqueHorizons.Get(horizon); portal=GLPortal::FindPortal(horizon); if (!portal) portal=new GLHorizonPortal(horizon); portal->AddLine(this); break; - case RENDERWALL_SKYBOX: + case PORTALTYPE_SKYBOX: portal = GLPortal::FindPortal(skybox); if (!portal) { @@ -181,12 +185,12 @@ void GLWall::PutWall(bool translucent) portal->AddLine(this); break; - case RENDERWALL_SECTORSTACK: + case PORTALTYPE_SECTORSTACK: portal = this->portal->GetGLPortal(); portal->AddLine(this); break; - case RENDERWALL_PLANEMIRROR: + case PORTALTYPE_PLANEMIRROR: if (GLPortal::PlaneMirrorMode * planemirror->c <=0) { //@sync-portal @@ -197,7 +201,7 @@ void GLWall::PutWall(bool translucent) } break; - case RENDERWALL_MIRROR: + case PORTALTYPE_MIRROR: portal=GLPortal::FindPortal(seg->linedef); if (!portal) portal=new GLMirrorPortal(seg->linedef); portal->AddLine(this); @@ -209,7 +213,7 @@ void GLWall::PutWall(bool translucent) } break; - case RENDERWALL_SKY: + case PORTALTYPE_SKY: portal=GLPortal::FindPortal(sky); if (!portal) portal=new GLSkyPortal(sky); portal->AddLine(this); @@ -217,26 +221,6 @@ void GLWall::PutWall(bool translucent) } } -//========================================================================== -// -// Splits a wall vertically if a 3D-floor -// creates different lighting across the wall -// -//========================================================================== - -void GLWall::SplitWall(sector_t * frontsector, bool translucent) -{ - - if (glseg.x1==glseg.x2 && glseg.y1==glseg.y2) - { - return; - } - lightlist=&frontsector->e->XFloor.lightlist; - PutWall(translucent); - lightlist = NULL; -} - - //========================================================================== // // @@ -262,7 +246,6 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) } else { - type = RENDERWALL_HORIZON; hi.plane.GetFromSector(fs, true); hi.lightlevel = gl_ClampLight(fs->GetCeilingLight()); hi.colormap = fs->ColorMap; @@ -277,7 +260,7 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) if (gl_fixedcolormap) hi.colormap.Clear(); horizon = &hi; - PutWall(0); + PutPortal(PORTALTYPE_HORIZON); } ztop[1] = ztop[0] = zbottom[0]; } @@ -291,7 +274,6 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) } else { - type = RENDERWALL_HORIZON; hi.plane.GetFromSector(fs, false); hi.lightlevel = gl_ClampLight(fs->GetFloorLight()); hi.colormap = fs->ColorMap; @@ -306,7 +288,7 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) if (gl_fixedcolormap) hi.colormap.Clear(); horizon = &hi; - PutWall(0); + PutPortal(PORTALTYPE_HORIZON); } } return true; @@ -516,7 +498,7 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg, gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(texpos), seg->sidedef->GetTextureYScale(texpos)); - type = (seg->linedef->special == Line_Mirror && _type == RENDERWALL_M1S && gl_mirrors) ? RENDERWALL_MIRROR : _type; + type = _type; float floatceilingref = FIXED2FLOAT(ceilingrefheight + tci.RowOffset(seg->sidedef->GetTextureYOffset(texpos))); if (peg) floatceilingref += tci.mRenderHeight - FIXED2FLOAT(lh + v_offset); @@ -524,13 +506,16 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg, if (!SetWallCoordinates(seg, &tci, floatceilingref, topleft, topright, bottomleft, bottomright, seg->sidedef->GetTextureXOffset(texpos))) return; - CheckTexturePosition(); - - // Add this wall to the render list - sector_t * sec = sub? sub->sector : seg->frontsector; - - if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap || !gltexture) PutWall(false); - else SplitWall(sec, false); + if (seg->linedef->special == Line_Mirror && _type == RENDERWALL_M1S && gl_mirrors) + { + PutPortal(PORTALTYPE_MIRROR); + } + else + { + CheckTexturePosition(); + // Add this wall to the render list + PutWall(sub ? sub->sector : seg->frontsector, false); + } glseg=glsave; flags&=~GLT_CLAMPY; @@ -728,12 +713,15 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, { flags |= GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER; type=RENDERWALL_FOGBOUNDARY; - PutWall(true); - if (!gltexture) + FMaterial *savetex = gltexture; + gltexture = NULL; + PutWall(seg->frontsector, true); + if (!savetex) { flags &= ~(GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER); return; } + gltexture = savetex; type=RENDERWALL_M2SNF; } else type=RENDERWALL_M2S; @@ -818,8 +806,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // Draw the stuff // // - if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap || !gltexture) split.PutWall(translucent); - else split.SplitWall(realfront, translucent); + split.PutWall(realfront, translucent); t=1; } @@ -827,13 +814,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, } else { - // - // - // Draw the stuff without splitting - // - // - if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap || !gltexture) PutWall(translucent); - else SplitWall(realfront, translucent); + PutWall(realfront, translucent); } alpha=1.0f; } @@ -941,11 +922,8 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, RenderStyle=STYLE_Normal; translucent=false; } - - sector_t * sec = sub? sub->sector : seg->frontsector; - if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap || !gltexture) PutWall(translucent); - else SplitWall(sec, translucent); + PutWall(sub? sub->sector : seg->frontsector, translucent); alpha=1.0f; lightlevel = savelight; @@ -1573,7 +1551,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * type = RENDERWALL_BOTTOM; gltexture->GetTexCoordInfo(&tci, FRACUNIT, FRACUNIT); SetWallCoordinates(seg, &tci, FIXED2FLOAT(bfh), bfh, bfh, ffh, ffh, 0); - PutWall(false); + PutWall(seg->frontsector, false); } } } From 1ad310e69ba6a63a62359ee4a1644313c0ed35d3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Feb 2016 16:13:07 +0100 Subject: [PATCH 0377/1509] - only draw visible 3D-lights. --- src/gl/scene/gl_walls_draw.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index cd404f4c9..7e91d1fe5 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -344,14 +344,23 @@ void GLWall::RenderTextured(int rflags) for (unsigned i = 0; i < lightlist->Size(); i++) { - int thisll = (*lightlist)[i].caster != NULL? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel; - FColormap thiscm; - thiscm.FadeColor = Colormap.FadeColor; - thiscm.CopyFrom3DLight(&(*lightlist)[i]); - gl_SetColor(thisll, rel, thiscm, absalpha); - if (type != RENDERWALL_M2SNF) gl_SetFog(thisll, rel, &thiscm, RenderStyle == STYLE_Add); - gl_RenderState.SetSplitPlanes((*lightlist)[i].plane, i == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[i + 1].plane); - RenderWall(rflags); + secplane_t &lowplane = i == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[i + 1].plane; + // this must use the exact same calculation method as GLWall::Process etc. + float low1 = FIXED2FLOAT(lowplane.ZatPoint(vertexes[0])); + float low2 = FIXED2FLOAT(lowplane.ZatPoint(vertexes[1])); + + if (low1 < ztop[0] && low2 < ztop[1]) + { + int thisll = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel; + FColormap thiscm; + thiscm.FadeColor = Colormap.FadeColor; + thiscm.CopyFrom3DLight(&(*lightlist)[i]); + gl_SetColor(thisll, rel, thiscm, absalpha); + if (type != RENDERWALL_M2SNF) gl_SetFog(thisll, rel, &thiscm, RenderStyle == STYLE_Add); + gl_RenderState.SetSplitPlanes((*lightlist)[i].plane, lowplane); + RenderWall(rflags); + } + if (low1 <= zbottom[0] && low2 <= zbottom[1]) break; } glDisable(GL_CLIP_DISTANCE3); From 2c55dcca27155882221f68f8f101dd0a1d652c1b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Feb 2016 18:14:00 +0100 Subject: [PATCH 0378/1509] - use hardware clipping to apply 3D lights to sprites. This solves all the problems with properly lighting models and billboarded sprites. - add some restrictions for the checks that exclude sprites which are too close to the camera. Most importantly, for clipping the first frame of a projectile, do not solely clip against the projectile's speed but use the player's radius as a limiting factor to avoid too large distances. --- src/gl/scene/gl_sprite.cpp | 298 +++++++++++++++++-------------------- src/gl/scene/gl_wall.h | 3 +- 2 files changed, 139 insertions(+), 162 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 2abfd47f7..bfd2a9deb 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -217,75 +217,120 @@ void GLSprite::Draw(int pass) if (gltexture) gl_RenderState.SetMaterial(gltexture, CLAMP_XY, translation, OverrideShader, !!(RenderStyle.Flags & STYLEF_RedIsAlpha)); else if (!modelframe) gl_RenderState.EnableTexture(false); - if (!modelframe) + //gl_SetColor(lightlevel, rel, Colormap, trans); + + unsigned int iter; + + if (lightlist) { - // [BB] Billboard stuff - const bool drawWithXYBillboard = ( (particle && gl_billboard_particles) || (!(actor && actor->renderflags & RF_FORCEYBILLBOARD) - //&& GLRenderer->mViewActor != NULL - && (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD ))) ); - gl_RenderState.Apply(); - - Vector v1; - Vector v2; - Vector v3; - Vector v4; - - if (drawWithXYBillboard) - { - // Rotate the sprite about the vector starting at the center of the sprite - // triangle strip and with direction orthogonal to where the player is looking - // in the x/y plane. - float xcenter = (x1 + x2)*0.5; - float ycenter = (y1 + y2)*0.5; - float zcenter = (z1 + z2)*0.5; - float angleRad = DEG2RAD(270. - float(GLRenderer->mAngles.Yaw)); - - Matrix3x4 mat; - mat.MakeIdentity(); - mat.Translate(xcenter, zcenter, ycenter); - mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch); - mat.Translate(-xcenter, -zcenter, -ycenter); - v1 = mat * Vector(x1, z1, y1); - v2 = mat * Vector(x2, z1, y2); - v3 = mat * Vector(x1, z2, y1); - v4 = mat * Vector(x2, z2, y2); - } - else - { - v1 = Vector(x1, z1, y1); - v2 = Vector(x2, z1, y2); - v3 = Vector(x1, z2, y1); - v4 = Vector(x2, z2, y2); - } - - FFlatVertex *ptr; - unsigned int offset, count; - ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(v1[0], v1[1], v1[2], ul, vt); - ptr++; - ptr->Set(v2[0], v2[1], v2[2], ur, vt); - ptr++; - ptr->Set(v3[0], v3[1], v3[2], ul, vb); - ptr++; - ptr->Set(v4[0], v4[1], v4[2], ur, vb); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); - - if (foglayer) - { - // If we get here we know that we have colored fog and no fixed colormap. - gl_SetFog(foglevel, rel, &Colormap, additivefog); - gl_RenderState.SetFixedColormap(CM_FOGLAYER); - gl_RenderState.BlendEquation(GL_FUNC_ADD); - gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl_RenderState.Apply(); - GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); - gl_RenderState.SetFixedColormap(CM_DEFAULT); - } + iter = lightlist->Size(); + gl_RenderState.EnableSplit(true); + glEnable(GL_CLIP_DISTANCE3); + glEnable(GL_CLIP_DISTANCE4); } else { - gl_RenderModel(this); + iter = 1; + } + + for (unsigned i = 0; i < iter; i++) + { + if (lightlist) + { + // set up the light slice + static secplane_t bottommost = { 0, 0, FRACUNIT, 32767<renderflags & RF_FORCEYBILLBOARD) + //&& GLRenderer->mViewActor != NULL + && (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD)))); + + gl_RenderState.Apply(); + + Vector v1; + Vector v2; + Vector v3; + Vector v4; + + if (drawWithXYBillboard) + { + // Rotate the sprite about the vector starting at the center of the sprite + // triangle strip and with direction orthogonal to where the player is looking + // in the x/y plane. + float xcenter = (x1 + x2)*0.5; + float ycenter = (y1 + y2)*0.5; + float zcenter = (z1 + z2)*0.5; + float angleRad = DEG2RAD(270. - float(GLRenderer->mAngles.Yaw)); + + Matrix3x4 mat; + mat.MakeIdentity(); + mat.Translate(xcenter, zcenter, ycenter); + mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch); + mat.Translate(-xcenter, -zcenter, -ycenter); + v1 = mat * Vector(x1, z1, y1); + v2 = mat * Vector(x2, z1, y2); + v3 = mat * Vector(x1, z2, y1); + v4 = mat * Vector(x2, z2, y2); + } + else + { + + v1 = Vector(x1, z1, y1); + v2 = Vector(x2, z1, y2); + v3 = Vector(x1, z2, y1); + v4 = Vector(x2, z2, y2); + } + + FFlatVertex *ptr; + unsigned int offset, count; + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(v1[0], v1[1], v1[2], ul, vt); + ptr++; + ptr->Set(v2[0], v2[1], v2[2], ur, vt); + ptr++; + ptr->Set(v3[0], v3[1], v3[2], ul, vb); + ptr++; + ptr->Set(v4[0], v4[1], v4[2], ur, vb); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); + + if (foglayer) + { + // If we get here we know that we have colored fog and no fixed colormap. + gl_SetFog(foglevel, rel, &Colormap, additivefog); + gl_RenderState.SetFixedColormap(CM_FOGLAYER); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.Apply(); + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); + gl_RenderState.SetFixedColormap(CM_DEFAULT); + } + } + else + { + gl_RenderModel(this); + } + } + + if (lightlist) + { + glDisable(GL_CLIP_DISTANCE3); + glDisable(GL_CLIP_DISTANCE4); + gl_RenderState.EnableSplit(false); } if (pass==GLPASS_TRANSLUCENT) @@ -322,87 +367,6 @@ inline void GLSprite::PutSprite(bool translucent) gl_drawinfo->drawlists[list].AddSprite(this); } -//========================================================================== -// -// -// -//========================================================================== -void GLSprite::SplitSprite(sector_t * frontsector, bool translucent) -{ - GLSprite copySprite; - fixed_t lightbottom; - float maplightbottom; - unsigned int i; - bool put=false; - TArray & lightlist=frontsector->e->XFloor.lightlist; - - for(i=0;ifloorplane.ZatPoint(actor); - - maplightbottom=FIXED2FLOAT(lightbottom); - if (maplightbottom & lightlist=actor->Sector->e->XFloor.lightlist; - - for(i=0;ifloorplane.ZatPoint(actor); - - //maplighttop=FIXED2FLOAT(lightlist[i].height); - maplightbottom=FIXED2FLOAT(lightbottom); - if (maplightbottomvelx==0 && thing->vely==0 && thing->velz!=0)) + if (viewz >= thingpos.z - 2 * FRACUNIT && viewz <= thingpos.z + thing->height + 2 * FRACUNIT) { - if (!gl_FindModelFrame(RUNTIME_TYPE(thing), spritenum, thing->frame, false)) + // exclude vertically moving objects from this check. + if (!(thing->velx == 0 && thing->vely == 0 && thing->velz != 0)) { - return; + if (!gl_FindModelFrame(RUNTIME_TYPE(thing), spritenum, thing->frame, false)) + { + return; + } } } } // don't draw first frame of a player missile - if (thing->flags&MF_MISSILE && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) + if (thing->flags&MF_MISSILE && !(thing->flags7 & MF7_FLYCHEAT) && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) { - if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy) < thing->Speed ) return; + fixed_t clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius*2); + if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy) < clipdist) return; } + thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again. if (GLRenderer->mCurrentPortal) { @@ -831,19 +800,23 @@ void GLSprite::Process(AActor* thing,sector_t * sector) && (gl_billboard_mode == 1 || actor->renderflags & RF_FORCEXYBILLBOARD ) ); - if (drawWithXYBillboard || modelframe) + // no light splitting when: + // 1. no lightlist + // 2. any fixed colormap + // 3. any bright object + // 4. any with render style shadow (which doesn't use the sector light) + // 5. anything with render style reverse subtract (light effect is not what would be desired here) + if (thing->Sector->e->XFloor.lightlist.Size() != 0 && gl_fixedcolormap == CM_DEFAULT && !fullbright && + RenderStyle.BlendOp != STYLEOP_Shadow && RenderStyle.BlendOp != STYLEOP_RevSub) { - if (!gl_fixedcolormap && !fullbright) SetSpriteColor(actor->Sector, thingpos.y + (actor->height>>1)); - PutSprite(hw_styleflags != STYLEHW_Solid); - } - else if (thing->Sector->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap || fullbright) - { - PutSprite(hw_styleflags != STYLEHW_Solid); + lightlist = &thing->Sector->e->XFloor.lightlist; } else { - SplitSprite(thing->Sector, hw_styleflags != STYLEHW_Solid); + lightlist = NULL; } + + PutSprite(hw_styleflags != STYLEHW_Solid); rendered_sprites++; } @@ -965,6 +938,11 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s if (gl_particles_style != 2 && trans>=1.0f-FLT_EPSILON) hw_styleflags = STYLEHW_Solid; else hw_styleflags = STYLEHW_NoAlphaTest; + if (sector->e->XFloor.lightlist.Size() != 0 && gl_fixedcolormap == CM_DEFAULT && !fullbright) + lightlist = §or->e->XFloor.lightlist; + else + lightlist = NULL; + PutSprite(hw_styleflags != STYLEHW_Solid); rendered_sprites++; } diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index d9ef91232..67d75dc3d 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -333,8 +333,8 @@ public: float trans; AActor * actor; particle_t * particle; + TArray *lightlist; - void SplitSprite(sector_t * frontsector, bool translucent); void SetLowerParam(); void PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_t thingy, float spriteheight); @@ -345,7 +345,6 @@ public: void Process(AActor* thing,sector_t * sector); void ProcessParticle (particle_t *particle, sector_t *sector);//, int shade, int fakeside) void SetThingColor(PalEntry); - void SetSpriteColor(sector_t *sector, fixed_t y); // Lines start-end and fdiv must intersect. double CalcIntersectionVertex(GLWall * w2); From faa08410de97c19254c8ea60815a2f8317fcfa3c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Feb 2016 19:10:15 +0100 Subject: [PATCH 0379/1509] - handle nocoloredspritelighting with 3D light splitter --- src/gl/scene/gl_sprite.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index bfd2a9deb..0fb01eb13 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -248,6 +248,11 @@ void GLSprite::Draw(int pass) FColormap thiscm; thiscm.FadeColor = Colormap.FadeColor; thiscm.CopyFrom3DLight(&(*lightlist)[i]); + if (glset.nocoloredspritelighting) + { + thiscm.Decolorize(); + } + gl_SetColor(thisll, rel, thiscm, trans); gl_RenderState.SetSplitPlanes(*topplane, *lowplane); } From f11f86f05d7d39229259d58672577abf33a6ab4f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Feb 2016 21:45:26 +0100 Subject: [PATCH 0380/1509] - added light plane clipping for decals as well. --- src/gl/scene/gl_decal.cpp | 83 ++++++++++++++++++++++++++++++++------- 1 file changed, 69 insertions(+), 14 deletions(-) diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 7cc766cd0..8bd5dd7a4 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -308,14 +308,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) gl_RenderState.SetObjectColor(decal->AlphaColor|0xff000000); } - gl_SetColor(light, rel, p, a); - // for additively drawn decals we must temporarily set the fog color to black. - PalEntry fc = gl_RenderState.GetFogColor(); - if (decal->RenderStyle.BlendOp == STYLEOP_Add && decal->RenderStyle.DestAlpha == STYLEALPHA_One) - { - gl_RenderState.SetFog(0,-1); - } gl_SetRenderStyle(decal->RenderStyle, false, false); @@ -326,14 +319,58 @@ void GLWall::DrawDecal(DBaseDecal *decal) if (decal->RenderStyle.SrcAlpha == STYLEALPHA_One) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); else gl_RenderState.AlphaFunc(GL_GREATER, 0.f); - gl_RenderState.Apply(); - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - for (i = 0; i < 4; i++) + + gl_SetColor(light, rel, p, a); + // for additively drawn decals we must temporarily set the fog color to black. + PalEntry fc = gl_RenderState.GetFogColor(); + if (decal->RenderStyle.BlendOp == STYLEOP_Add && decal->RenderStyle.DestAlpha == STYLEALPHA_One) { - ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); - ptr++; + gl_RenderState.SetFog(0,-1); + } + + if (lightlist == NULL) + { + gl_RenderState.Apply(); + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (i = 0; i < 4; i++) + { + ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); + ptr++; + } + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + } + else + { + for (unsigned k = 0; k < lightlist->Size(); k++) + { + secplane_t &lowplane = k == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[k + 1].plane; + + float low1 = lowplane.ZatPoint(dv[1].x, dv[i].y); + float low2 = lowplane.ZatPoint(dv[2].x, dv[2].y); + + if (low1 < dv[1].z && low2 < dv[2].z) + { + int thisll = (*lightlist)[k].caster != NULL ? gl_ClampLight(*(*lightlist)[k].p_lightlevel) : lightlevel; + FColormap thiscm; + thiscm.FadeColor = Colormap.FadeColor; + thiscm.CopyFrom3DLight(&(*lightlist)[k]); + gl_SetColor(thisll, rel, thiscm, a); + if (glset.nocoloredspritelighting) thiscm.Decolorize(); + gl_SetFog(thisll, rel, &thiscm, RenderStyle == STYLE_Add); + gl_RenderState.SetSplitPlanes((*lightlist)[k].plane, lowplane); + + gl_RenderState.Apply(); + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (i = 0; i < 4; i++) + { + ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); + ptr++; + } + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + } + if (low1 <= dv[0].z && low2 <= dv[3].z) break; + } } - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); rendered_decals++; gl_RenderState.SetTextureMode(TM_MODULATE); @@ -351,13 +388,31 @@ void GLWall::DoDrawDecals() { if (seg->sidedef && seg->sidedef->AttachedDecals) { - gl_SetFog(lightlevel, rellight + getExtraLight(), &Colormap, false); + if (lightlist != NULL) + { + gl_RenderState.EnableSplit(true); + glEnable(GL_CLIP_DISTANCE3); + glEnable(GL_CLIP_DISTANCE4); + } + else + { + gl_SetFog(lightlevel, rellight + getExtraLight(), &Colormap, false); + } + DBaseDecal *decal = seg->sidedef->AttachedDecals; while (decal) { DrawDecal(decal); decal = decal->WallNext; } + + if (lightlist != NULL) + { + glDisable(GL_CLIP_DISTANCE3); + glDisable(GL_CLIP_DISTANCE4); + gl_RenderState.EnableSplit(false); + } + } } From 9453a8a7e6dd952c9932a3bce823b2ef42dec03d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Feb 2016 21:50:55 +0100 Subject: [PATCH 0381/1509] - reuse the same vertex buffer data for all slices of a decal. --- src/gl/scene/gl_decal.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 8bd5dd7a4..df9ae6e3d 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -327,20 +327,23 @@ void GLWall::DrawDecal(DBaseDecal *decal) { gl_RenderState.SetFog(0,-1); } - + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (i = 0; i < 4; i++) + { + ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); + ptr++; + } + if (lightlist == NULL) { gl_RenderState.Apply(); - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - for (i = 0; i < 4; i++) - { - ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); - ptr++; - } GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); } else { + unsigned int offset; + unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); for (unsigned k = 0; k < lightlist->Size(); k++) { secplane_t &lowplane = k == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[k + 1].plane; @@ -360,13 +363,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) gl_RenderState.SetSplitPlanes((*lightlist)[k].plane, lowplane); gl_RenderState.Apply(); - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - for (i = 0; i < 4; i++) - { - ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); - ptr++; - } - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, offset, count); } if (low1 <= dv[0].z && low2 <= dv[3].z) break; } From 22e9fc9b7618d57a1f2b78ed9e361a7e726e33d4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 2 Feb 2016 11:37:39 +0100 Subject: [PATCH 0382/1509] - re-fixed FTexture::CheckTrans The original broken code had it always reset the translucency info to 'not present'. The first fix completely removed that line, although it was merely misplaced, but still necessary to avoid constant re-checking of the same texture. --- src/gl/textures/gl_texture.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index b7347ae54..cc2905bb9 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -520,6 +520,7 @@ void FTexture::CheckTrans(unsigned char * buffer, int size, int trans) return; } } + gl_info.mIsTransparent = 0; } } } From d797415745ba2344d5e1964dfbe6b797cbf2211d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 2 Feb 2016 11:58:00 +0100 Subject: [PATCH 0383/1509] - fixed: dynamic lights did not relink themselves when their position changed. --- src/actor.h | 2 +- src/gl/dynlights/a_dynlight.cpp | 13 +++++++++++++ src/gl/dynlights/gl_dynlight.h | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/actor.h b/src/actor.h index 700999b51..4cc4e2de4 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1186,7 +1186,7 @@ public: void LinkToWorld (sector_t *sector); void UnlinkFromWorld (); void AdjustFloorClip (); - void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving = false); + virtual void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving = false); bool InStateSequence(FState * newstate, FState * basestate); int GetTics(FState * newstate); bool SetState (FState *newstate, bool nofunction=false); diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 9a13d9e09..3e1cace46 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -384,6 +384,19 @@ void ADynamicLight::UpdateLocation() // // //========================================================================== + +void ADynamicLight::SetOrigin(fixed_t x, fixed_t y, fixed_t z, bool moving) +{ + Super::SetOrigin(x, y, z, moving); + LinkLight(); +} + +//========================================================================== +// +// +// +//========================================================================== + void ADynamicLight::SetOffset(fixed_t x, fixed_t y, fixed_t z) { m_offX = x; diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index 568630898..c78a0c927 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -81,7 +81,8 @@ public: void UnlinkLight(); size_t PointerSubstitution (DObject *old, DObject *notOld); - virtual void BeginPlay(); + void BeginPlay(); + void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving = false); void PostBeginPlay(); void Destroy(); void Activate(AActor *activator); From df9c59bcff5270c8c855b87db8b0428ec71cbccd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 2 Feb 2016 12:07:07 +0100 Subject: [PATCH 0384/1509] - moved gl_builddraw.cpp to a new 'unused' directory and also added gl_sections, which is needed by the Build algorithm to preprocess the level. --- src/gl/{ => unused}/gl_builddraw.cpp | 4 + src/gl/unused/gl_sections.cpp | 845 +++++++++++++++++++++++++++ src/gl/unused/gl_sections.h | 57 ++ 3 files changed, 906 insertions(+) rename src/gl/{ => unused}/gl_builddraw.cpp (98%) create mode 100644 src/gl/unused/gl_sections.cpp create mode 100644 src/gl/unused/gl_sections.h diff --git a/src/gl/gl_builddraw.cpp b/src/gl/unused/gl_builddraw.cpp similarity index 98% rename from src/gl/gl_builddraw.cpp rename to src/gl/unused/gl_builddraw.cpp index 60b94b984..82b93b4f3 100644 --- a/src/gl/gl_builddraw.cpp +++ b/src/gl/unused/gl_builddraw.cpp @@ -3,6 +3,10 @@ ** a build-like rendering algorithm ** Uses the sections created in gl_sections.cpp ** +** NOTE: Although this code generally works, it clearly shows the limitations +** of Build's algorithm. This requires constant sorting of the collected geometry +** and that causes extreme slowdowns on larger maps. +** **--------------------------------------------------------------------------- ** Copyright 2008 Christoph Oelckers ** All rights reserved. diff --git a/src/gl/unused/gl_sections.cpp b/src/gl/unused/gl_sections.cpp new file mode 100644 index 000000000..b39db0292 --- /dev/null +++ b/src/gl/unused/gl_sections.cpp @@ -0,0 +1,845 @@ +/* +** gl_sections.cpp +** Splits sectors into continuous separate parts +** +**--------------------------------------------------------------------------- +** Copyright 2008 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include +#include "i_system.h" +#include "p_local.h" +#include "c_dispatch.h" +#include "gl/data/gl_sections.h" + +typedef void (CALLBACK *tessFunc)(); + +TArray SectionLines; +TArray SectionLoops; +TArray Sections; +TArray SectionForSubsector; + +CVAR (Bool, dumpsections, false, 0) + +#define ISDONE(no, p) (p[(no)>>3] & (1 << ((no)&7))) +#define SETDONE(no, p) p[(no)>>3] |= (1 << ((no)&7)) + +inline vertex_t *V1(side_t *s) +{ + line_t *ln = s->linedef; + return s == ln->sidedef[0]? ln->v1: ln->v2; +} + +inline vertex_t *V2(side_t *s) +{ + line_t *ln = s->linedef; + return s == ln->sidedef[0]? ln->v2: ln->v1; +} + +//========================================================================== +// +// +// +//========================================================================== + +class FSectionCreator +{ + static FSectionCreator *creator; + + BYTE *processed_segs; + BYTE *processed_subsectors; + int *section_for_segs; + + vertex_t *v1_l1, *v2_l1; + + FGLSectionLoop *loop; + FGLSection *section; // current working section + +public: + //========================================================================== + // + // + // + //========================================================================== + + FSectionCreator() + { + processed_segs = new BYTE[(numsegs+7)/8]; + processed_subsectors = new BYTE[(numsubsectors+7)/8]; + + memset(processed_segs, 0, (numsegs+7)/8); + memset(processed_subsectors, 0, (numsubsectors+7)/8); + + section_for_segs = new int[numsegs]; + memset(section_for_segs, -1, numsegs * sizeof(int)); + } + + //========================================================================== + // + // + // + //========================================================================== + + ~FSectionCreator() + { + delete [] processed_segs; + delete [] processed_subsectors; + delete [] section_for_segs; + } + + //========================================================================== + // + // + // + //========================================================================== + + void NewLoop() + { + section->numloops++; + loop = &SectionLoops[SectionLoops.Reserve(1)]; + loop->startline = SectionLines.Size(); + loop->numlines = 0 ; + } + + void NewSection(sector_t *sec) + { + section = &Sections[Sections.Reserve(1)]; + section->sector = sec; + section->subsectors.Clear(); + section->numloops = 0; + section->startloop = SectionLoops.Size(); + section->validcount = -1; + NewLoop(); + } + + void FinalizeSection() + { + } + + //========================================================================== + // + // + // + //========================================================================== + + bool AddSeg(seg_t *seg) + { + FGLSectionLine &line = SectionLines[SectionLines.Reserve(1)]; + + + bool firstline = loop->numlines == 0; + + if (ISDONE(seg-segs, processed_segs)) + { + // should never happen! + DPrintf("Tried to add seg %d to Sections twice. Cannot create Sections.\n", seg-segs); + return false; + } + + SETDONE(seg-segs, processed_segs); + section_for_segs[seg-segs] = Sections.Size()-1; + + line.start = seg->v1; + line.end = seg->v2; + line.sidedef = seg->sidedef; + line.linedef = seg->linedef; + line.refseg = seg; + line.polysub = NULL; + line.otherside = -1; + + if (loop->numlines == 0) + { + v1_l1 = seg->v1; + v2_l1 = seg->v2; + } + loop->numlines++; + return true; + } + + //========================================================================== + // + // Utility stuff + // + //========================================================================== + + sector_t *FrontRenderSector(seg_t *seg) + { + return seg->Subsector->render_sector; + } + + sector_t *BackRenderSector(seg_t *seg) + { + if (seg->PartnerSeg == NULL) return NULL; + return seg->PartnerSeg->Subsector->render_sector; + } + + bool IntraSectorSeg(seg_t *seg) + { + return FrontRenderSector(seg) == BackRenderSector(seg); + } + + + //========================================================================== + // + // returns the seg whose partner seg determines where this + // section continues + // + //========================================================================== + bool AddSubSector(subsector_t *subsec, vertex_t *startpt, seg_t **pNextSeg) + { + unsigned i = 0; + if (startpt != NULL) + { + // find the seg in this subsector that starts at the given vertex + for(i = 0; i < subsec->numlines; i++) + { + if (subsec->firstline[i].v1 == startpt) break; + } + if (i == subsec->numlines) + { + DPrintf("Vertex not found in subsector %d. Cannot create Sections.\n", subsec-subsectors); + return false; // Nodes are bad + } + } + else + { + // Find the first unprocessed non-miniseg + for(i = 0; i < subsec->numlines; i++) + { + seg_t *seg = subsec->firstline + i; + + if (seg->sidedef == NULL) continue; + if (IntraSectorSeg(seg)) continue; + if (ISDONE(seg-segs, processed_segs)) continue; + break; + } + if (i == subsec->numlines) + { + DPrintf("Unable to find a start seg. Cannot create Sections.\n"); + return false; // Nodes are bad + } + + startpt = subsec->firstline[i].v1; + } + + seg_t *thisseg = subsec->firstline + i; + if (IntraSectorSeg(thisseg)) + { + SETDONE(thisseg-segs, processed_segs); + // continue with the loop in the adjoining subsector + *pNextSeg = thisseg; + return true; + } + + while(1) + { + if (loop->numlines > 0 && thisseg->v1 == v1_l1 && thisseg->v2 == v2_l1) + { + // This loop is complete + *pNextSeg = NULL; + return true; + } + + if (!AddSeg(thisseg)) return NULL; + + i = (i+1) % subsec->numlines; + seg_t *nextseg = subsec->firstline + i; + + if (thisseg->v2 != nextseg->v1) + { + DPrintf("Segs in subsector %d are not continuous. Cannot create Sections.\n", subsec-subsectors); + return false; // Nodes are bad + } + + if (IntraSectorSeg(nextseg)) + { + SETDONE(nextseg-segs, processed_segs); + // continue with the loop in the adjoining subsector + *pNextSeg = nextseg; + return true; + } + thisseg = nextseg; + } + } + + //============================================================================= + // + // + // + //============================================================================= + + bool FindNextSeg(seg_t **pSeg) + { + // find an unprocessed non-miniseg or a miniseg with an unprocessed + // partner subsector that belongs to the same rendersector + for (unsigned i = 0; i < section->subsectors.Size(); i++) + { + for(unsigned j = 0; j < section->subsectors[i]->numlines; j++) + { + seg_t *seg = section->subsectors[i]->firstline + j; + bool intra = IntraSectorSeg(seg); + + if (!intra && !ISDONE(seg-segs, processed_segs)) + { + *pSeg = seg; + return true; + } + else if (intra && + !ISDONE(seg->PartnerSeg->Subsector-subsectors, processed_subsectors)) + { + *pSeg = seg->PartnerSeg; + return true; + } + } + } + *pSeg = NULL; + return true; + } + + //============================================================================= + // + // all segs and subsectors must be grouped into Sections + // + //============================================================================= + bool CheckSections() + { + bool res = true; + for (int i = 0; i < numsegs; i++) + { + if (segs[i].sidedef != NULL && !ISDONE(i, processed_segs) && !IntraSectorSeg(&segs[i])) + { + Printf("Seg %d (Linedef %d) not processed during section creation\n", i, segs[i].linedef-lines); + res = false; + } + } + for (int i = 0; i < numsubsectors; i++) + { + if (!ISDONE(i, processed_subsectors)) + { + Printf("Subsector %d (Sector %d) not processed during section creation\n", i, subsectors[i].sector-sectors); + res = false; + } + } + return res; + } + + //============================================================================= + // + // + // + //============================================================================= + void DeleteLine(int i) + { + SectionLines.Delete(i); + for(int i = SectionLoops.Size() - 1; i >= 0; i--) + { + FGLSectionLoop *loop = &SectionLoops[i]; + if (loop->startline > i) loop->startline--; + } + } + + //============================================================================= + // + // + // + //============================================================================= + void MergeLines(FGLSectionLoop *loop) + { + int i; + int deleted = 0; + FGLSectionLine *ln1; + FGLSectionLine *ln2; + // Merge identical lines in the list + for(i = loop->numlines - 1; i > 0; i--) + { + ln1 = loop->GetLine(i); + ln2 = loop->GetLine(i-1); + + if (ln1->sidedef == ln2->sidedef && ln1->otherside == ln2->otherside) + { + // identical references. These 2 lines can be merged. + ln2->end = ln1->end; + SectionLines.Delete(loop->startline + i); + loop->numlines--; + deleted++; + } + } + + // If we started in the middle of a sidedef the first and last lines + // may reference the same sidedef. check that, too. + + int loopstart = 0; + + ln1 = loop->GetLine(0); + for(i = loop->numlines - 1; i > 0; i--) + { + ln2 = loop->GetLine(i); + if (ln1->sidedef != ln2->sidedef || ln1->otherside != ln2->otherside) + break; + } + if (i < loop->numlines-1) + { + i++; + ln2 = loop->GetLine(i); + ln1->start = ln2->start; + SectionLines.Delete(loop->startline + i, loop->numlines - i); + deleted += loop->numlines - i; + loop->numlines = i; + } + + // Adjust all following loops + for(unsigned ii = unsigned(loop - &SectionLoops[0]) + 1; ii < SectionLoops.Size(); ii++) + { + SectionLoops[ii].startline -= deleted; + } + } + + //============================================================================= + // + // + // + //============================================================================= + void SetReferences() + { + for(unsigned i = 0; i < SectionLines.Size(); i++) + { + FGLSectionLine *ln = &SectionLines[i]; + seg_t *seg = ln->refseg; + + if (seg != NULL) + { + seg_t *partner = seg->PartnerSeg; + + if (seg->PartnerSeg == NULL) + { + ln->otherside = -1; + } + else + { + ln->otherside = section_for_segs[partner-segs]; + } + } + else + { + ln->otherside = -1; + } + } + + for(unsigned i = 0; i < SectionLoops.Size(); i++) + { + MergeLines(&SectionLoops[i]); + } + } + + //============================================================================= + // + // cbTessBegin + // + // called when the tesselation of a new loop starts + // + //============================================================================= + + static void CALLBACK cbTessBegin(GLenum type, void *section) + { + FGLSection *sect = (FGLSection*)section; + sect->primitives.Push(type); + sect->primitives.Push(sect->vertices.Size()); + } + + //============================================================================= + // + // cbTessError + // + // called when the tesselation failed + // + //============================================================================= + + static void CALLBACK cbTessError(GLenum error, void *section) + { + } + + //============================================================================= + // + // cbTessCombine + // + // called when the two or more vertexes are on the same coordinate + // + //============================================================================= + + static void CALLBACK cbTessCombine( GLdouble coords[3], void *vert[4], GLfloat w[4], void **dataOut ) + { + *dataOut = vert[0]; + } + + //============================================================================= + // + // cbTessVertex + // + // called when a vertex is found + // + //============================================================================= + + static void CALLBACK cbTessVertex( void *vert, void *section ) + { + FGLSection *sect = (FGLSection*)section; + sect->vertices.Push(int(intptr_t(vert))); + } + + //============================================================================= + // + // cbTessEnd + // + // called when the tesselation of a the current loop ends + // + //============================================================================= + + static void CALLBACK cbTessEnd(void *section) + { + } + + //============================================================================= + // + // + // + //============================================================================= + void tesselateSections() + { + // init tesselator + GLUtesselator *tess = gluNewTess(); + if (!tess) + { + return; + } + // set callbacks + gluTessCallback(tess, GLU_TESS_BEGIN_DATA, (tessFunc)cbTessBegin); + gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (tessFunc)cbTessVertex); + gluTessCallback(tess, GLU_TESS_ERROR_DATA, (tessFunc)cbTessError); + gluTessCallback(tess, GLU_TESS_COMBINE, (tessFunc)cbTessCombine); + gluTessCallback(tess, GLU_TESS_END_DATA, (tessFunc)cbTessEnd); + + for(unsigned int i=0;inumloops; j++) + { + gluTessBeginContour(tess); + FGLSectionLoop *loop = sect->GetLoop(j); + for(int k=0; knumlines; k++) + { + FGLSectionLine *line = loop->GetLine(k); + vertex_t *vert = line->start; + GLdouble v[3] = { + -(double)vert->x/(double)FRACUNIT, // negate to get proper winding + 0.0, + (double)vert->y/(double)FRACUNIT + }; + gluTessVertex(tess, v, (void*)(vert - vertexes)); + } + gluTessEndContour(tess); + } + gluTessEndPolygon(tess); + sect->vertices.Push(-1337); + sect->vertices.ShrinkToFit(); + } + gluDeleteTess(tess); + } + + + //============================================================================= + // + // First mark all subsectors that have no outside boundaries as processed + // No line in such a subsector will ever be part of a section's border + // + //============================================================================= + + void MarkInternalSubsectors() + { + for(int i=0; i < numsubsectors; i++) + { + subsector_t *sub = &subsectors[i]; + int j; + + for(j=0; j < sub->numlines; j++) + { + seg_t *seg = sub->firstline + j; + if (!IntraSectorSeg(seg)) break; + } + if (j==sub->numlines) + { + // All lines are intra-sector so mark this as processed + SETDONE(i, processed_subsectors); + for(j=0; j < sub->numlines; j++) + { + seg_t *seg = sub->firstline + j; + SETDONE((sub->firstline-segs)+j, processed_segs); + if (seg->PartnerSeg != NULL) + { + SETDONE(int(seg->PartnerSeg - segs), processed_segs); + } + } + } + } + } + + //============================================================================= + // + // + // + //============================================================================= + bool CreateSections() + { + int pick = 0; + + MarkInternalSubsectors(); + while (pick < numsubsectors) + { + if (ISDONE(pick, processed_subsectors)) + { + pick++; + continue; + } + + + subsector_t *subsector = &subsectors[pick]; + + seg_t *workseg = NULL; + vertex_t *startpt = NULL; + + NewSection(subsector->render_sector); + while (1) + { + if (!ISDONE(subsector-subsectors, processed_subsectors)) + { + SETDONE(subsector-subsectors, processed_subsectors); + section->subsectors.Push(subsector); + SectionForSubsector[subsector - subsectors] = int(section - &Sections[0]); + } + + bool result = AddSubSector(subsector, startpt, &workseg); + + if (!result) + { + return false; // couldn't create Sections + } + else if (workseg != NULL) + { + // crossing into another subsector + seg_t *partner = workseg->PartnerSeg; + if (workseg->v2 != partner->v1) + { + DPrintf("Inconsistent subsector references in seg %d. Cannot create Sections.\n", workseg-segs); + return false; + } + subsector = partner->Subsector; + startpt = workseg->v1; + } + else + { + // loop complete. Check adjoining subsectors for other loops to + // be added to this section + if (!FindNextSeg(&workseg)) + { + return false; + } + else if (workseg == NULL) + { + // No more subsectors found. This section is complete! + FinalizeSection(); + break; + } + else + { + subsector = workseg->Subsector; + // If this is a regular seg, start there, otherwise start + // at the subsector's first seg + startpt = workseg->sidedef == NULL? NULL : workseg->v1; + + NewLoop(); + } + } + } + } + + if (!CheckSections()) return false; + SetReferences(); + + Sections.ShrinkToFit(); + SectionLoops.ShrinkToFit(); + SectionLines.ShrinkToFit(); + + tesselateSections(); + + return true; + } +}; + +FSectionCreator *FSectionCreator::creator; + + +//============================================================================= +// +// +// +//============================================================================= + +void DumpSection(int no, FGLSection *sect) +{ + Printf(PRINT_LOG, "Section %d, sector %d\n{\n", no, sect->sector->sectornum); + + for(int i = 0; i < sect->numloops; i++) + { + Printf(PRINT_LOG, "\tLoop %d\n\t{\n", i); + + FGLSectionLoop *loop = sect->GetLoop(i); + + for(int i = 0; i < loop->numlines; i++) + { + FGLSectionLine *ln = loop->GetLine(i); + if (ln->sidedef != NULL) + { + vertex_t *v1 = V1(ln->sidedef); + vertex_t *v2 = V2(ln->sidedef); + double dx = FIXED2FLOAT(v2->x-v1->x); + double dy = FIXED2FLOAT(v2->y-v1->y); + double dx1 = FIXED2FLOAT(ln->start->x-v1->x); + double dy1 = FIXED2FLOAT(ln->start->y-v1->y); + double dx2 = FIXED2FLOAT(ln->end->x-v1->x); + double dy2 = FIXED2FLOAT(ln->end->y-v1->y); + double d = sqrt(dx*dx+dy*dy); + double d1 = sqrt(dx1*dx1+dy1*dy1); + double d2 = sqrt(dx2*dx2+dy2*dy2); + + Printf(PRINT_LOG, "\t\tLinedef %d, %s: Start (%1.2f, %1.2f), End (%1.2f, %1.2f)", + ln->linedef - lines, ln->sidedef == ln->linedef->sidedef[0]? "front":"back", + ln->start->x/65536.f, ln->start->y/65536.f, + ln->end->x/65536.f, ln->end->y/65536.f); + + if (ln->otherside != -1) + { + Printf (PRINT_LOG, ", other side = %d", ln->otherside); + } + if (d1 > 0.005 || d2 < 0.995) + { + Printf(PRINT_LOG, ", Range = %1.3f, %1.3f", d1/d, d2/d); + } + } + else + { + Printf(PRINT_LOG, "\t\tMiniseg: Start (%1.3f, %1.3f), End (%1.3f, %1.3f)\n", + ln->start->x/65536.f, ln->start->y/65536.f, ln->end->x/65536.f, ln->end->y/65536.f); + + if (ln->otherside != -1) + { + Printf (PRINT_LOG, ", other side = %d", ln->otherside); + } + } + Printf(PRINT_LOG, "\n"); + } + Printf(PRINT_LOG, "\t}\n"); + } + int prim = 1; + for(unsigned i = 0; i < sect->vertices.Size(); i++) + { + int v = sect->vertices[i]; + if (v < 0) + { + if (i > 0) + { + Printf(PRINT_LOG, "\t}\n"); + } + switch (v) + { + case -GL_TRIANGLE_FAN: + Printf(PRINT_LOG, "\t%d: Triangle fan\n\t{\n", prim); + break; + + case -GL_TRIANGLE_STRIP: + Printf(PRINT_LOG, "\t%d: Triangle strip\n\t{\n", prim); + break; + + case -GL_TRIANGLES: + Printf(PRINT_LOG, "\t%d: Triangles\n\t{\n", prim); + break; + + default: + break; + } + prim++; + } + else + { + Printf(PRINT_LOG, "\t\tVertex %d: (%1.2f, %1.2f)\n", + v, vertexes[v].x/65536.f, vertexes[v].y/65536.f); + } + } + Printf(PRINT_LOG, "}\n\n"); +} + +//============================================================================= +// +// +// +//============================================================================= + +void DumpSections() +{ + for(unsigned i = 0; i < Sections.Size(); i++) + { + DumpSection(i, &Sections[i]); + } +} + +//============================================================================= +// +// +// +//============================================================================= + +void gl_CreateSections() +{ + SectionLines.Clear(); + SectionLoops.Clear(); + Sections.Clear(); + SectionForSubsector.Resize(numsubsectors); + memset(&SectionForSubsector[0], -1, numsubsectors * sizeof(SectionForSubsector[0])); + FSectionCreator creat; + creat.CreateSections(); + if (dumpsections) DumpSections(); +} + diff --git a/src/gl/unused/gl_sections.h b/src/gl/unused/gl_sections.h new file mode 100644 index 000000000..1974fab46 --- /dev/null +++ b/src/gl/unused/gl_sections.h @@ -0,0 +1,57 @@ + +#ifndef __GL_SECTIONS_H +#define __GL_SECTIONS_H + +#include "tarray.h" +#include "r_defs.h" + +struct FGLSectionLine +{ + vertex_t *start; + vertex_t *end; + side_t *sidedef; + line_t *linedef; + seg_t *refseg; // we need to reference at least one seg for each line. + subsector_t *polysub; // If this is part of a polyobject we need a reference to the containing subsector + int otherside; +}; + +struct FGLSectionLoop +{ + int startline; + int numlines; + + FGLSectionLine *GetLine(int no); +}; + +struct FGLSection +{ + sector_t *sector; + TArray subsectors; + TArray primitives; // each primitive has 2 entries: Primitive type and vertex count + TArray vertices; + int startloop; + int numloops; + int validcount; + + FGLSectionLoop *GetLoop(int no); +}; + +extern TArray SectionLines; +extern TArray SectionLoops; +extern TArray Sections; +extern TArray SectionForSubsector; + +inline FGLSectionLine *FGLSectionLoop::GetLine(int no) +{ + return &SectionLines[startline + no]; +} + +inline FGLSectionLoop *FGLSection::GetLoop(int no) +{ + return &SectionLoops[startloop + no]; +} + +void gl_CreateSections(); + +#endif \ No newline at end of file From db766f9fe50f1af1249bd37e732629acc4b00eb8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 3 Feb 2016 13:03:38 +0100 Subject: [PATCH 0385/1509] - fixed some warnings. --- src/gl/scene/gl_decal.cpp | 2 +- src/gl/scene/gl_portal.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index df9ae6e3d..745346db7 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -348,7 +348,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) { secplane_t &lowplane = k == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[k + 1].plane; - float low1 = lowplane.ZatPoint(dv[1].x, dv[i].y); + float low1 = lowplane.ZatPoint(dv[1].x, dv[1].y); float low2 = lowplane.ZatPoint(dv[2].x, dv[2].y); if (low1 < dv[1].z && low2 < dv[2].z) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 42e6fb143..48b630586 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -949,7 +949,7 @@ int GLMirrorPortal::ClipSeg(seg_t *seg) int GLMirrorPortal::ClipSubsector(subsector_t *sub) { // this seg is completely behind the mirror! - for(int i=0;inumlines;i++) + for(unsigned int i=0;inumlines;i++) { if (P_PointOnLineSide(sub->firstline[i].v1->x, sub->firstline[i].v1->y, linedef) == 0) return PClip_Inside; } From 0c8a817df484c424b3c2d13cb3e324d702f645af Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 4 Feb 2016 01:12:18 +0100 Subject: [PATCH 0386/1509] - fixed wall clipping with 3D lights. --- src/gl/scene/gl_decal.cpp | 2 +- src/gl/scene/gl_walls_draw.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 745346db7..de175fffd 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -351,7 +351,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) float low1 = lowplane.ZatPoint(dv[1].x, dv[1].y); float low2 = lowplane.ZatPoint(dv[2].x, dv[2].y); - if (low1 < dv[1].z && low2 < dv[2].z) + if (low1 < dv[1].z || low2 < dv[2].z) { int thisll = (*lightlist)[k].caster != NULL ? gl_ClampLight(*(*lightlist)[k].p_lightlevel) : lightlevel; FColormap thiscm; diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 7e91d1fe5..c06558b11 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -349,7 +349,7 @@ void GLWall::RenderTextured(int rflags) float low1 = FIXED2FLOAT(lowplane.ZatPoint(vertexes[0])); float low2 = FIXED2FLOAT(lowplane.ZatPoint(vertexes[1])); - if (low1 < ztop[0] && low2 < ztop[1]) + if (low1 < ztop[0] || low2 < ztop[1]) { int thisll = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel; FColormap thiscm; From 70e569f79c90833e7c0e06c1d520f39536274d12 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 4 Feb 2016 11:57:26 +0200 Subject: [PATCH 0387/1509] Fixed restoration of window position with OpenGL renderer Software renderer was not affected as it has maximize window button enabled --- src/win32/hardware.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 2c3fbdea4..bf1838ae2 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -299,7 +299,8 @@ void I_SaveWindowedPos () return; } // Make sure we only save the window position if it's not fullscreen. - if ((GetWindowLong (Window, GWL_STYLE) & WS_OVERLAPPEDWINDOW) == WS_OVERLAPPEDWINDOW) + static const int WINDOW_STYLE = WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX; + if ((GetWindowLong (Window, GWL_STYLE) & WINDOW_STYLE) == WINDOW_STYLE) { RECT wrect; From c129cb3ca4b38f6f037521a836c04c2162a5e55f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 4 Feb 2016 15:34:12 +0100 Subject: [PATCH 0388/1509] - reinstated software clipping by light volumes for walls. It turned out that using hardware clipping planes exclusively to handle this cost more than it gained. Now only the expensive or formerly impossible cases of intersecting light volumes or light volumes intersecting with the top and bottom of the wall polygon will use hardware clipping. The trivial cases will go back to software splitting. --- src/gl/scene/gl_wall.h | 3 + src/gl/scene/gl_walls.cpp | 158 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 153 insertions(+), 8 deletions(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 67d75dc3d..ef770bfde 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -167,6 +167,9 @@ private: void PutPortal(int ptype); void CheckTexturePosition(); + void Put3DWall(lightlist_t * lightlist, bool translucent); + void SplitWall(sector_t * frontsector, bool translucent); + void SetupLights(); bool PrepareLight(texcoord * tcs, ADynamicLight * light); void RenderWall(int textured, unsigned int *store = NULL); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index c8808e79b..828092b92 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -125,10 +125,6 @@ void GLWall::PutWall(sector_t *sec, bool translucent) if (gltexture == NULL) return; Colormap.Clear(); } - else if (sec->e->XFloor.lightlist.Size() > 0 && gltexture != NULL) - { - lightlist = &sec->e->XFloor.lightlist; - } CheckGlowing(); @@ -220,6 +216,138 @@ void GLWall::PutPortal(int ptype) break; } } +//========================================================================== +// +// Sets 3D-floor lighting info +// +//========================================================================== + +void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent) +{ + // only modify the light level if it doesn't originate from the seg's frontsector. This is to account for light transferring effects + if (lightlist->p_lightlevel != &seg->sidedef->sector->lightlevel) + { + lightlevel = gl_ClampLight(*lightlist->p_lightlevel); + } + // relative light won't get changed here. It is constant across the entire wall. + + Colormap.CopyFrom3DLight(lightlist); + PutWall(NULL, translucent); +} + +//========================================================================== +// +// Splits a wall vertically if a 3D-floor +// creates different lighting across the wall +// +//========================================================================== + +void GLWall::SplitWall(sector_t * frontsector, bool translucent) +{ + GLWall copyWall1,copyWall2; + float maplightbottomleft; + float maplightbottomright; + unsigned int i; + int origlight = lightlevel; + FColormap origcm=Colormap; + + TArray & lightlist=frontsector->e->XFloor.lightlist; + + if (glseg.x1==glseg.x2 && glseg.y1==glseg.y2) + { + return; + } + //::SplitWall.Clock(); + +#ifdef _DEBUG + if (seg->linedef-lines==1) + { + int a = 0; + } +#endif + + if (lightlist.Size()>1) + { + for(i=0;i=ztop[0] && maplightbottomright>=ztop[1]) + { + continue; + } + + // check for an intersection with the upper and lower planes of the wall segment + if ((maplightbottomleftztop[1]) || + (maplightbottomleft>ztop[0] && maplightbottomrightzbottom[1]) || + (maplightbottomleft>zbottom[0] && maplightbottomrightlightlist = &lightlist; + PutWall(frontsector, translucent); + goto out; + } + + // 3D floor is completely within this light + if (maplightbottomleft<=zbottom[0] && maplightbottomright<=zbottom[1]) + { + Put3DWall(&lightlist[i], translucent); + goto out; + } + + if (maplightbottomleft<=ztop[0] && maplightbottomright<=ztop[1] && + (maplightbottomleft!=ztop[0] || maplightbottomright!=ztop[1])) + { + copyWall1=*this; + + copyWall1.flags |= GLWF_NOSPLITLOWER; + flags |= GLWF_NOSPLITUPPER; + ztop[0]=copyWall1.zbottom[0]=maplightbottomleft; + ztop[1]=copyWall1.zbottom[1]=maplightbottomright; + uplft.v=copyWall1.lolft.v=copyWall1.uplft.v+ + (maplightbottomleft-copyWall1.ztop[0])*(copyWall1.lolft.v-copyWall1.uplft.v)/(zbottom[0]-copyWall1.ztop[0]); + uprgt.v=copyWall1.lorgt.v=copyWall1.uprgt.v+ + (maplightbottomright-copyWall1.ztop[1])*(copyWall1.lorgt.v-copyWall1.uprgt.v)/(zbottom[1]-copyWall1.ztop[1]); + copyWall1.Put3DWall(&lightlist[i], translucent); + } + if (ztop[0]==zbottom[0] && ztop[1]==zbottom[1]) + { + //::SplitWall.Unclock(); + goto out; + } + } + } + + Put3DWall(&lightlist[lightlist.Size()-1], translucent); + +out: + lightlevel=origlight; + Colormap=origcm; + flags &= ~GLWF_NOSPLITUPPER; + this->lightlist = NULL; + //::SplitWall.Unclock(); +} + //========================================================================== // @@ -514,7 +642,10 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg, { CheckTexturePosition(); // Add this wall to the render list - PutWall(sub ? sub->sector : seg->frontsector, false); + sector_t * sec = sub? sub->sector : seg->frontsector; + + if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(sec, false); + else SplitWall(sec, false); } glseg=glsave; @@ -806,7 +937,8 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // Draw the stuff // // - split.PutWall(realfront, translucent); + if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) split.PutWall(realfront, translucent); + else split.SplitWall(realfront, translucent); t=1; } @@ -814,7 +946,13 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, } else { - PutWall(realfront, translucent); + // + // + // Draw the stuff without splitting + // + // + if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(realfront, translucent); + else SplitWall(realfront, translucent); } alpha=1.0f; } @@ -922,8 +1060,11 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, RenderStyle=STYLE_Normal; translucent=false; } + + sector_t * sec = sub? sub->sector : seg->frontsector; - PutWall(sub? sub->sector : seg->frontsector, translucent); + if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(sec, translucent); + else SplitWall(sec, translucent); alpha=1.0f; lightlevel = savelight; @@ -1505,6 +1646,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector) { if (frontsector->GetTexture(sector_t::floor) == skyflatnum) return; + lightlist = NULL; fixed_t ffh = frontsector->GetPlaneTexZ(sector_t::floor); fixed_t bfh = backsector->GetPlaneTexZ(sector_t::floor); From b2158c5b96f613bd64295c9626e90a7b8b9e62e1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 5 Feb 2016 01:48:53 +0100 Subject: [PATCH 0389/1509] - removed unneeded parameter. --- src/gl/scene/gl_wall.h | 2 +- src/gl/scene/gl_walls.cpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index ef770bfde..1aa902372 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -163,7 +163,7 @@ public: private: void CheckGlowing(); - void PutWall(sector_t *sec, bool translucent); + void PutWall(bool translucent); void PutPortal(int ptype); void CheckTexturePosition(); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 828092b92..b7243dcf8 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -96,7 +96,7 @@ void GLWall::CheckGlowing() // // //========================================================================== -void GLWall::PutWall(sector_t *sec, bool translucent) +void GLWall::PutWall(bool translucent) { int list; @@ -232,7 +232,7 @@ void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent) // relative light won't get changed here. It is constant across the entire wall. Colormap.CopyFrom3DLight(lightlist); - PutWall(NULL, translucent); + PutWall(translucent); } //========================================================================== @@ -304,7 +304,7 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) { // Use hardware clipping if this cannot be done cleanly. this->lightlist = &lightlist; - PutWall(frontsector, translucent); + PutWall(translucent); goto out; } @@ -391,7 +391,7 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) PutPortal(PORTALTYPE_HORIZON); } ztop[1] = ztop[0] = zbottom[0]; - } + } if (viewz > fs->GetPlaneTexZ(sector_t::floor)) { @@ -644,7 +644,7 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg, // Add this wall to the render list sector_t * sec = sub? sub->sector : seg->frontsector; - if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(sec, false); + if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(false); else SplitWall(sec, false); } @@ -846,7 +846,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, type=RENDERWALL_FOGBOUNDARY; FMaterial *savetex = gltexture; gltexture = NULL; - PutWall(seg->frontsector, true); + PutWall(true); if (!savetex) { flags &= ~(GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER); @@ -937,7 +937,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // Draw the stuff // // - if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) split.PutWall(realfront, translucent); + if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) split.PutWall(translucent); else split.SplitWall(realfront, translucent); t=1; @@ -951,7 +951,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // Draw the stuff without splitting // // - if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(realfront, translucent); + if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(translucent); else SplitWall(realfront, translucent); } alpha=1.0f; @@ -1063,7 +1063,7 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, sector_t * sec = sub? sub->sector : seg->frontsector; - if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(sec, translucent); + if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(translucent); else SplitWall(sec, translucent); alpha=1.0f; @@ -1693,7 +1693,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * type = RENDERWALL_BOTTOM; gltexture->GetTexCoordInfo(&tci, FRACUNIT, FRACUNIT); SetWallCoordinates(seg, &tci, FIXED2FLOAT(bfh), bfh, bfh, ffh, ffh, 0); - PutWall(seg->frontsector, false); + PutWall(false); } } } From a7d1d72d6bc830317f7a345823ec6c1d69fad9ba Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 5 Feb 2016 12:11:02 +0100 Subject: [PATCH 0390/1509] - increase version number. --- src/version.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/version.h b/src/version.h index 7f24ee5db..e7b7c5477 100644 --- a/src/version.h +++ b/src/version.h @@ -41,12 +41,12 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "2.1pre" +#define VERSIONSTR "2.2pre" // The version as seen in the Windows resource -#define RC_FILEVERSION 2,0,9999,0 -#define RC_PRODUCTVERSION 2,0,9999,0 -#define RC_PRODUCTVERSION2 "2.1pre" +#define RC_FILEVERSION 2,1,9999,0 +#define RC_PRODUCTVERSION 2,1,9999,0 +#define RC_PRODUCTVERSION2 "2.2pre" // Version identifier for network games. // Bump it every time you do a release unless you're certain you From c4b1b9648473d22253343a3ed031fcc59ce1fc47 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 5 Feb 2016 13:47:07 +0100 Subject: [PATCH 0391/1509] - handle one particular edge case when checking if a line is completely behind a mirror. This is not really sufficient to detect all cases where something gets incorrectly flagged as ok, but it's the easiest one to detect. --- src/gl/scene/gl_portal.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 48b630586..0775b3652 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -937,9 +937,12 @@ void GLMirrorPortal::DrawContents() int GLMirrorPortal::ClipSeg(seg_t *seg) { + we cannot use P_PointOnLineSide here because it loses the special meaning of 0 == 'on the line'. + int side1 = DMulScale32(seg->v1->y - linedef->v1->y, linedef->dx, linedef->v1->x - seg->v1->x, linedef->dy); + int side2 = DMulScale32(seg->v2->y - linedef->v1->y, linedef->dx, linedef->v1->x - seg->v2->x, linedef->dy); + + if (side1 >= 0 && side2 >= 0) // this seg is completely behind the mirror. - if (P_PointOnLineSide(seg->v1->x, seg->v1->y, linedef) && - P_PointOnLineSide(seg->v2->x, seg->v2->y, linedef)) { return PClip_InFront; } From e6337537edabc86bd9dbc4ded62e54303b294e54 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 5 Feb 2016 14:04:28 +0100 Subject: [PATCH 0392/1509] - this was missing the double slashes... --- src/gl/scene/gl_portal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 0775b3652..8b7bd010a 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -937,7 +937,7 @@ void GLMirrorPortal::DrawContents() int GLMirrorPortal::ClipSeg(seg_t *seg) { - we cannot use P_PointOnLineSide here because it loses the special meaning of 0 == 'on the line'. + //we cannot use P_PointOnLineSide here because it loses the special meaning of 0 == 'on the line'. int side1 = DMulScale32(seg->v1->y - linedef->v1->y, linedef->dx, linedef->v1->x - seg->v1->x, linedef->dy); int side2 = DMulScale32(seg->v2->y - linedef->v1->y, linedef->dx, linedef->v1->x - seg->v2->x, linedef->dy); From 25f1dc86d576520dc16c17accc70b1a040f408f7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 6 Feb 2016 00:50:43 +0100 Subject: [PATCH 0393/1509] - removed duplicate function definition. --- src/gl/scene/gl_clipper.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/gl/scene/gl_clipper.h b/src/gl/scene/gl_clipper.h index 637839f4f..367cf515f 100644 --- a/src/gl/scene/gl_clipper.h +++ b/src/gl/scene/gl_clipper.h @@ -138,11 +138,6 @@ extern Clipper clipper; angle_t R_PointToPseudoAngle (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y); -inline angle_t R_PointToAnglePrecise (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y) -{ - return xs_RoundToUInt(atan2(double(y-viewy), double(x-viewx)) * (ANGLE_180/M_PI)); -} - // Used to speed up angle calculations during clipping inline angle_t vertex_t::GetClipAngle() { From 297cf52ac9dea46e2a4ca489317f34ac1f2f8c46 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 6 Feb 2016 05:17:47 +0100 Subject: [PATCH 0394/1509] - copied line portal code from portal branch and made some adjustments to make it compile. Portal rendering is not yet working. --- src/gl/scene/gl_portal.cpp | 104 +++++++++++++++++++++++++++++++++---- src/gl/scene/gl_portal.h | 34 ++++++++++++ src/gl/scene/gl_sky.cpp | 32 ++++++++++-- src/gl/scene/gl_wall.h | 5 +- src/gl/scene/gl_walls.cpp | 17 +++++- 5 files changed, 177 insertions(+), 15 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 8b7bd010a..5cb35f20c 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -95,6 +95,7 @@ bool GLPortal::inskybox; UniqueList UniqueSkies; UniqueList UniqueHorizons; UniqueList UniquePlaneMirrors; +UniqueList UniqueLineToLines; @@ -109,6 +110,7 @@ void GLPortal::BeginScene() UniqueSkies.Clear(); UniqueHorizons.Clear(); UniquePlaneMirrors.Clear(); + UniqueLineToLines.Clear(); } //========================================================================== @@ -216,7 +218,7 @@ bool GLPortal::Start(bool usestencil, bool doquery) else if (gl_noquery) doquery = false; // If occlusion query is supported let's use it to avoid rendering portals that aren't visible - if (!QueryObject) glGenQueries(1, &QueryObject); + if (!QueryObject && doquery) glGenQueries(1, &QueryObject); if (QueryObject) { glBeginQuery(GL_SAMPLES_PASSED, QueryObject); @@ -244,15 +246,18 @@ bool GLPortal::Start(bool usestencil, bool doquery) GLuint sampleCount; - glGetQueryObjectuiv(QueryObject, GL_QUERY_RESULT, &sampleCount); - - if (sampleCount == 0) // not visible + if (QueryObject) { - // restore default stencil op. - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - glStencilFunc(GL_EQUAL, recursion, ~0); // draw sky into stencil - PortalAll.Unclock(); - return false; + glGetQueryObjectuiv(QueryObject, GL_QUERY_RESULT, &sampleCount); + + if (sampleCount == 0) // not visible + { + // restore default stencil op. + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + glStencilFunc(GL_EQUAL, recursion, ~0); // draw sky into stencil + PortalAll.Unclock(); + return false; + } } FDrawInfo::StartDrawInfo(); } @@ -969,6 +974,86 @@ int GLMirrorPortal::ClipPoint(fixed_t x, fixed_t y) } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Line to line Portal +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- +void GLLineToLinePortal::DrawContents() +{ + // TODO: Handle recursion more intelligently + if (renderdepth>r_mirror_recursions) + { + ClearScreen(); + return; + } + + GLRenderer->mCurrentPortal = this; + + viewx += l2l->xDisplacement; + viewy += l2l->yDisplacement; + SaveMapSection(); + + for (unsigned i = 0; i < lines.Size(); i++) + { + ASkyViewpoint *pt = lines[i].seg->linedef->skybox; + int mapsection = lines[i].seg->Subsector->mapsection; + currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7); + } + + GLRenderer->mViewActor = NULL; + validcount++; + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + + ClearClipper(); + GLRenderer->DrawScene(); + RestoreMapSection(); +} + + +int GLLineToLinePortal::ClipSeg(seg_t *seg) +{ + line_t *masterline = lines[0].seg->linedef->getPortalDestination(); + // this seg is completely behind the portal + if (P_PointOnLineSide(seg->v1->x, seg->v1->y, masterline) && + P_PointOnLineSide(seg->v2->x, seg->v2->y, masterline)) + { + return PClip_InFront; + } + return PClip_Inside; +} + +int GLLineToLinePortal::ClipSubsector(subsector_t *sub) +{ + line_t *masterline = lines[0].seg->linedef->getPortalDestination(); + + for(unsigned int i=0;inumlines;i++) + { + if (P_PointOnLineSide(sub->firstline[i].v1->x, sub->firstline[i].v1->y, masterline) == 0) return PClip_Inside; + } + return PClip_InFront; +} + +int GLLineToLinePortal::ClipPoint(fixed_t x, fixed_t y) +{ + line_t *masterline = lines[0].seg->linedef->getPortalDestination(); + if (P_PointOnLineSide(x, y, masterline)) + { + return PClip_InFront; + } + return PClip_Inside; +} + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // @@ -1165,6 +1250,7 @@ const char *GLSkyboxPortal::GetName() { return "Skybox"; } const char *GLSectorStackPortal::GetName() { return "Sectorstack"; } const char *GLPlaneMirrorPortal::GetName() { return "Planemirror"; } const char *GLMirrorPortal::GetName() { return "Mirror"; } +const char *GLLineToLinePortal::GetName() { return "LineToLine"; } const char *GLHorizonPortal::GetName() { return "Horizon"; } const char *GLEEHorizonPortal::GetName() { return "EEHorizon"; } diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index c7c07986b..279c2e715 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -51,6 +51,17 @@ struct GLHorizonInfo FColormap colormap; }; +struct GLLineToLineInfo +{ + fixed_t xDisplacement; + fixed_t yDisplacement; + fixed_t turnangle; + fixed_t angle; + fixed_t x0; + fixed_t y0; + void init(line_t *line); +}; + struct GLSkyInfo { float x_offset[2]; @@ -76,6 +87,7 @@ struct GLSkyInfo extern UniqueList UniqueSkies; extern UniqueList UniqueHorizons; extern UniqueList UniquePlaneMirrors; +extern UniqueList UniqueLineToLines; struct GLEEHorizonPortal; class GLPortal @@ -195,6 +207,28 @@ public: }; +struct GLLineToLinePortal : public GLPortal +{ + GLLineToLineInfo *l2l; +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return l2l; } + virtual const char *GetName(); + +public: + + GLLineToLinePortal(GLLineToLineInfo *ll) + { + l2l=ll; + } + + virtual bool NeedCap() { return false; } + virtual int ClipSeg(seg_t *seg); + virtual int ClipSubsector(subsector_t *sub); + virtual int ClipPoint(fixed_t x, fixed_t y); +}; + + struct GLSkyboxPortal : public GLPortal { AActor * origin; diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index c020ab276..10ed2ffa1 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -129,6 +129,23 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor) } + +void GLLineToLineInfo::init(line_t *line) +{ +/* + static const divline_t divlx = { 0, 0, 128 * FRACUNIT, 0 }; + static const divline_t divly = { 0, 0, 0, 128 * FRACUNIT }; + xDisplacement = line->skybox->scaleX; + yDisplacement = line->skybox->scaleY; + angle = R_PointToAnglePrecise(line->v1->x, line->v1->y, line->v2->x, line->v2->y); + + divline_t divl; + P_MakeDivline(line, &divl); + x0 = P_InterceptVector(&divlx, &divl); + y0 = P_InterceptVector(&divly, &divl); +*/ +} + //========================================================================== // // Calculate sky texture for ceiling or floor @@ -188,23 +205,30 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) // //========================================================================== -void GLWall::SkyLine(line_t *line) +void GLWall::SkyLine(sector_t *fs, line_t *line) { ASkyViewpoint * skyboxx = line->skybox; GLSkyInfo skyinfo; + GLLineToLineInfo llinfo; int ptype; // JUSTHIT is used as an indicator that a skybox is in use. // This is to avoid recursion - if (!gl_noskyboxes && skyboxx && GLRenderer->mViewActor != skyboxx && !(skyboxx->flags&MF_JUSTHIT)) + if (line->isVisualPortal()) + { + ptype = PORTALTYPE_LINETOLINE; + llinfo.init(line); + l2l = UniqueLineToLines.Get(&llinfo); + } + else if (!gl_noskyboxes && skyboxx && GLRenderer->mViewActor != skyboxx && !(skyboxx->flags&MF_JUSTHIT)) { ptype = PORTALTYPE_SKYBOX; skybox = skyboxx; } else { - skyinfo.init(line->frontsector->sky, Colormap.FadeColor); + skyinfo.init(fs->sky, Colormap.FadeColor); ptype = PORTALTYPE_SKY; sky = UniqueSkies.Get(&skyinfo); } @@ -231,7 +255,7 @@ void GLWall::SkyNormal(sector_t * fs,vertex_t * v1,vertex_t * v2) ztop[1] = zceil[1]; zbottom[0] = zfloor[0]; zbottom[1] = zfloor[1]; - SkyLine(seg->linedef); + SkyLine(fs, seg->linedef); } ztop[0]=zfloor[0]; diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 1aa902372..1dc060e66 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -21,6 +21,7 @@ struct GLSkyInfo; struct FTexCoordInfo; struct FPortal; struct FFlatVertex; +struct GLLineToLineInfo; enum WallTypes @@ -46,6 +47,7 @@ enum PortalTypes PORTALTYPE_SECTORSTACK, PORTALTYPE_PLANEMIRROR, PORTALTYPE_MIRROR, + PORTALTYPE_LINETOLINE, }; struct GLSeg @@ -147,6 +149,7 @@ public: GLHorizonInfo * horizon; // for horizon information FPortal * portal; // stacked sector portals secplane_t * planemirror; // for plane mirrors + GLLineToLineInfo *l2l; // line-to-line portals }; @@ -178,7 +181,7 @@ private: void FloodPlane(int pass); void SkyPlane(sector_t *sector, int plane, bool allowmirror); - void SkyLine(line_t *line); + void SkyLine(sector_t *sec, line_t *line); void SkyNormal(sector_t * fs,vertex_t * v1,vertex_t * v2); void SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2); void SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index b7243dcf8..92628f879 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -209,6 +209,12 @@ void GLWall::PutPortal(int ptype) } break; + case PORTALTYPE_LINETOLINE: + portal=GLPortal::FindPortal(l2l); + if (!portal) portal=new GLLineToLinePortal(l2l); + portal->AddLine(this); + break; + case PORTALTYPE_SKY: portal=GLPortal::FindPortal(sky); if (!portal) portal=new GLSkyPortal(sky); @@ -1582,7 +1588,16 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); } - if (backsector->e->XFloor.ffloors.Size() || frontsector->e->XFloor.ffloors.Size()) + if (seg->linedef->isVisualPortal() && seg->sidedef == seg->linedef->sidedef[0]) + { + ztop[0] = FIXED2FLOAT(bch1); + ztop[1] = FIXED2FLOAT(bch2); + zbottom[0] = FIXED2FLOAT(bfh1); + zbottom[1] = FIXED2FLOAT(bfh2); + + //SkyLine(frontsector, seg->linedef); + } + else if (backsector->e->XFloor.ffloors.Size() || frontsector->e->XFloor.ffloors.Size()) { DoFFloorBlocks(seg, frontsector, backsector, fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); } From 3683a8ac580967a66a41c1780e61d91a5e7500d6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 6 Feb 2016 12:32:47 +0100 Subject: [PATCH 0395/1509] - implemented line-to-line portal rendering. So far working for two-sided portal lines - one-sided yet to come. --- src/gl/scene/gl_portal.cpp | 68 ++++++++++++++++++++++++++++++++------ src/gl/scene/gl_portal.h | 13 ++++---- src/gl/scene/gl_sky.cpp | 16 --------- src/gl/scene/gl_walls.cpp | 2 +- 4 files changed, 65 insertions(+), 34 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 5cb35f20c..2d74af820 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -46,6 +46,7 @@ #include "doomstat.h" #include "a_sharedglobal.h" #include "r_sky.h" +#include "portal.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" @@ -959,14 +960,14 @@ int GLMirrorPortal::ClipSubsector(subsector_t *sub) // this seg is completely behind the mirror! for(unsigned int i=0;inumlines;i++) { - if (P_PointOnLineSide(sub->firstline[i].v1->x, sub->firstline[i].v1->y, linedef) == 0) return PClip_Inside; + if (P_PointOnLineSidePrecise(sub->firstline[i].v1->x, sub->firstline[i].v1->y, linedef) == 0) return PClip_Inside; } return PClip_InFront; } int GLMirrorPortal::ClipPoint(fixed_t x, fixed_t y) { - if (P_PointOnLineSide(x, y, linedef)) + if (P_PointOnLineSidePrecise(x, y, linedef)) { return PClip_InFront; } @@ -984,6 +985,47 @@ int GLMirrorPortal::ClipPoint(fixed_t x, fixed_t y) //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +static void glTranslatePortal(line_t* src, line_t* dst, fixed_t& x, fixed_t& y, angle_t & angle) +{ + // Get the angle between the two linedefs, for rotating + // orientation and velocity. Rotate 180 degrees, and flip + // the position across the exit linedef, if reversed. + + double xangle = atan2(double(dst->dy), double(dst->dx)) - atan2(double(src->dy), double(src->dx)) + M_PI; + double s = sin(xangle); + double c = cos(xangle); + + fixed_t nposx = x - src->v1->x; + fixed_t nposy = y - src->v1->y; + + // Rotate position along normal to match exit linedef + x = xs_RoundToInt(nposx * c - nposy * s) + dst->v2->x; + y = xs_RoundToInt(nposy * c + nposx * s) + dst->v2->y; + angle += xs_CRoundToInt(xangle * (ANGLE_180 / M_PI)); +} + +void GLLineToLineInfo::init(line_t *line) +{ + static const divline_t divlx = { 0, 0, 128 * FRACUNIT, 0 }; + static const divline_t divly = { 0, 0, 0, 128 * FRACUNIT }; + + // store some info about the portal line + divline_t divl; + P_MakeDivline(line, &divl); + x0 = P_InterceptVector(&divlx, &divl); + y0 = P_InterceptVector(&divly, &divl); + lineangle = R_PointToAnglePrecise(line->v1->x, line->v1->y, line->v2->x, line->v2->y); + + // and some info about the viewpoint translation + viewx = ::viewx; + viewy = ::viewy; + viewz = ::viewz; + viewangle = ::viewangle; + glTranslatePortal(line, line->getPortalDestination(), viewx, viewy, viewangle); + P_TranslatePortalZ(line, line->getPortalDestination(), viewz); +} + + //----------------------------------------------------------------------------- // // @@ -1000,14 +1042,15 @@ void GLLineToLinePortal::DrawContents() GLRenderer->mCurrentPortal = this; - viewx += l2l->xDisplacement; - viewy += l2l->yDisplacement; + viewx = l2l->viewx; + viewy = l2l->viewy; + viewz = l2l->viewz; + viewangle = l2l->viewangle; SaveMapSection(); for (unsigned i = 0; i < lines.Size(); i++) { - ASkyViewpoint *pt = lines[i].seg->linedef->skybox; - int mapsection = lines[i].seg->Subsector->mapsection; + int mapsection = lines[i].seg->linedef->getPortalDestination()->frontsector->subsectors[0]->mapsection; currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7); } @@ -1023,10 +1066,13 @@ void GLLineToLinePortal::DrawContents() int GLLineToLinePortal::ClipSeg(seg_t *seg) { - line_t *masterline = lines[0].seg->linedef->getPortalDestination(); + line_t *linedef = lines[0].seg->linedef->getPortalDestination(); // this seg is completely behind the portal - if (P_PointOnLineSide(seg->v1->x, seg->v1->y, masterline) && - P_PointOnLineSide(seg->v2->x, seg->v2->y, masterline)) + //we cannot use P_PointOnLineSide here because it loses the special meaning of 0 == 'on the line'. + int side1 = DMulScale32(seg->v1->y - linedef->v1->y, linedef->dx, linedef->v1->x - seg->v1->x, linedef->dy); + int side2 = DMulScale32(seg->v2->y - linedef->v1->y, linedef->dx, linedef->v1->x - seg->v2->x, linedef->dy); + + if (side1 >= 0 && side2 >= 0) { return PClip_InFront; } @@ -1039,7 +1085,7 @@ int GLLineToLinePortal::ClipSubsector(subsector_t *sub) for(unsigned int i=0;inumlines;i++) { - if (P_PointOnLineSide(sub->firstline[i].v1->x, sub->firstline[i].v1->y, masterline) == 0) return PClip_Inside; + if (P_PointOnLineSidePrecise(sub->firstline[i].v1->x, sub->firstline[i].v1->y, masterline) == 0) return PClip_Inside; } return PClip_InFront; } @@ -1047,7 +1093,7 @@ int GLLineToLinePortal::ClipSubsector(subsector_t *sub) int GLLineToLinePortal::ClipPoint(fixed_t x, fixed_t y) { line_t *masterline = lines[0].seg->linedef->getPortalDestination(); - if (P_PointOnLineSide(x, y, masterline)) + if (P_PointOnLineSidePrecise(x, y, masterline)) { return PClip_InFront; } diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 279c2e715..5a2af3807 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -53,12 +53,13 @@ struct GLHorizonInfo struct GLLineToLineInfo { - fixed_t xDisplacement; - fixed_t yDisplacement; - fixed_t turnangle; - fixed_t angle; - fixed_t x0; - fixed_t y0; + angle_t viewangle; + fixed_t viewx; + fixed_t viewy; + fixed_t viewz; + fixed_t x0, y0; + angle_t lineangle; + void init(line_t *line); }; diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 10ed2ffa1..c882674dd 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -130,22 +130,6 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor) } -void GLLineToLineInfo::init(line_t *line) -{ -/* - static const divline_t divlx = { 0, 0, 128 * FRACUNIT, 0 }; - static const divline_t divly = { 0, 0, 0, 128 * FRACUNIT }; - xDisplacement = line->skybox->scaleX; - yDisplacement = line->skybox->scaleY; - angle = R_PointToAnglePrecise(line->v1->x, line->v1->y, line->v2->x, line->v2->y); - - divline_t divl; - P_MakeDivline(line, &divl); - x0 = P_InterceptVector(&divlx, &divl); - y0 = P_InterceptVector(&divly, &divl); -*/ -} - //========================================================================== // // Calculate sky texture for ceiling or floor diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 92628f879..c8430986f 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1595,7 +1595,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) zbottom[0] = FIXED2FLOAT(bfh1); zbottom[1] = FIXED2FLOAT(bfh2); - //SkyLine(frontsector, seg->linedef); + SkyLine(frontsector, seg->linedef); } else if (backsector->e->XFloor.ffloors.Size() || frontsector->e->XFloor.ffloors.Size()) { From 7105a87a1e5472a77b3f71109017eb15409d87a3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 6 Feb 2016 19:19:18 +0100 Subject: [PATCH 0396/1509] - fixed retrieval of mapsection for polyportals. - render wall portals on one sided lines. --- src/gl/scene/gl_portal.cpp | 7 ++++++- src/gl/scene/gl_sky.cpp | 9 +-------- src/gl/scene/gl_walls.cpp | 19 ++++++++++++++++--- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 2d74af820..5ce683f57 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -1050,7 +1050,12 @@ void GLLineToLinePortal::DrawContents() for (unsigned i = 0; i < lines.Size(); i++) { - int mapsection = lines[i].seg->linedef->getPortalDestination()->frontsector->subsectors[0]->mapsection; + line_t *line = lines[i].seg->linedef->getPortalDestination(); + subsector_t *sub; + if (line->sidedef[0]->Flags & WALLF_POLYOBJ) + sub = R_PointInSubsector(line->v1->x, line->v1->y); + else sub = line->frontsector->subsectors[0]; + int mapsection = sub->mapsection; currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7); } diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index c882674dd..5a5a10a26 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -193,19 +193,12 @@ void GLWall::SkyLine(sector_t *fs, line_t *line) { ASkyViewpoint * skyboxx = line->skybox; GLSkyInfo skyinfo; - GLLineToLineInfo llinfo; int ptype; // JUSTHIT is used as an indicator that a skybox is in use. // This is to avoid recursion - if (line->isVisualPortal()) - { - ptype = PORTALTYPE_LINETOLINE; - llinfo.init(line); - l2l = UniqueLineToLines.Get(&llinfo); - } - else if (!gl_noskyboxes && skyboxx && GLRenderer->mViewActor != skyboxx && !(skyboxx->flags&MF_JUSTHIT)) + if (!gl_noskyboxes && skyboxx && GLRenderer->mViewActor != skyboxx && !(skyboxx->flags&MF_JUSTHIT)) { ptype = PORTALTYPE_SKYBOX; skybox = skyboxx; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index c8430986f..5d33670ce 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1475,7 +1475,18 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) // sector's sky SkyNormal(frontsector, v1, v2); - if (seg->linedef->skybox == NULL) + if (seg->linedef->isVisualPortal()) + { + GLLineToLineInfo llinfo; + ztop[0] = zceil[0]; + ztop[1] = zceil[1]; + zbottom[0] = zfloor[0]; + zbottom[1] = zfloor[1]; + llinfo.init(seg->linedef); + l2l = UniqueLineToLines.Get(&llinfo); + PutPortal(PORTALTYPE_LINETOLINE); + } + else if (seg->linedef->skybox == NULL && !seg->linedef->isVisualPortal()) { // normal texture gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::mid), false, true); @@ -1590,12 +1601,14 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (seg->linedef->isVisualPortal() && seg->sidedef == seg->linedef->sidedef[0]) { + GLLineToLineInfo llinfo; ztop[0] = FIXED2FLOAT(bch1); ztop[1] = FIXED2FLOAT(bch2); zbottom[0] = FIXED2FLOAT(bfh1); zbottom[1] = FIXED2FLOAT(bfh2); - - SkyLine(frontsector, seg->linedef); + llinfo.init(seg->linedef); + l2l = UniqueLineToLines.Get(&llinfo); + PutPortal(PORTALTYPE_LINETOLINE); } else if (backsector->e->XFloor.ffloors.Size() || frontsector->e->XFloor.ffloors.Size()) { From eb7a908a92ecd8cd3a5e852e5d56f873ec775fcb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 8 Feb 2016 22:06:26 +0100 Subject: [PATCH 0397/1509] - account for removed bam2rad function. --- src/gl/scene/gl_scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 7a961d2cd..5f0cb8994 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -783,7 +783,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo SetViewArea(); // We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1. - double radPitch = bam2rad(viewpitch); + double radPitch = ANGLE2RAD(viewpitch); if (radPitch > PI) radPitch -= 2 * PI; radPitch = clamp(radPitch, -PI / 2, PI / 2); From bd981820959c7765172c8d33aec42d34b9814e39 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 9 Feb 2016 15:23:45 +0100 Subject: [PATCH 0398/1509] - fixed: The check for missing textures in Vavoom skyboxes was inverted. --- src/gl/textures/gl_skyboxtexture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/textures/gl_skyboxtexture.cpp b/src/gl/textures/gl_skyboxtexture.cpp index c86556ea9..4e4a9c72f 100644 --- a/src/gl/textures/gl_skyboxtexture.cpp +++ b/src/gl/textures/gl_skyboxtexture.cpp @@ -196,7 +196,7 @@ void gl_ParseVavoomSkybox() maplump = Wads.CheckNumForFullName(sc.String, true); FTexture *tex = TexMan.FindTexture(sc.String, FTexture::TEX_Wall, FTextureManager::TEXMAN_TryAny); - if (tex != NULL) + if (tex == NULL) { Printf("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->Name.GetChars()); } From 6a408b1a9963aac6cc4ea193016e35f1d3e54c58 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 10 Feb 2016 20:49:06 +0100 Subject: [PATCH 0399/1509] - added missing include to gl_walls.cpp --- src/gl/scene/gl_walls.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 5d33670ce..01b19bc39 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -47,6 +47,7 @@ #include "vectors.h" #include "r_defs.h" #include "r_sky.h" +#include "portal.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" From 0931134a9c1701ea58c9ef8efe2e68f05acf3514 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 12 Feb 2016 11:20:33 +0100 Subject: [PATCH 0400/1509] - fixed: part of the special handling of projectiles being spawned near the camera also affected other actors, this caused the fly cheat to break. --- src/gl/scene/gl_sprite.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 7c51e55c2..81c9cc3cd 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -526,12 +526,15 @@ void GLSprite::Process(AActor* thing,sector_t * sector) } // don't draw first frame of a player missile - if (thing->flags&MF_MISSILE && !(thing->flags7 & MF7_FLYCHEAT) && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) + if (thing->flags&MF_MISSILE) { - fixed_t clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius*2); - if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy) < clipdist) return; + if (!(thing->flags7 & MF7_FLYCHEAT) && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) + { + fixed_t clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius*2); + if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy) < clipdist) return; + } + thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again. } - thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again. if (GLRenderer->mCurrentPortal) { From 71fc4c295f81cb02d41e196a26672b2b0063ef4c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 13 Feb 2016 15:36:54 +0100 Subject: [PATCH 0401/1509] - removed global fastmath setting now that it is controlled by per-source-file settings. --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee2a970a2..550bc807f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,8 +118,7 @@ if( MSVC ) # String pooling # Function-level linking # Disable run-time type information - # Set floating point model to fast or the GL render will suffer for it. - set( ALL_C_FLAGS "/GF /Gy /GR- /fp:fast" ) + set( ALL_C_FLAGS "/GF /Gy /GR-" ) if( CMAKE_SIZEOF_VOID_P MATCHES "4") # SSE2 option (mostly to switch it off in VC2012 and later where it's the default From 141065c3d5e8ffb237a5823766ace7621adae723 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 14 Feb 2016 14:33:52 +0100 Subject: [PATCH 0402/1509] - fixed: positioning of camera textures on 2-sided walls was not correct. --- src/gl/scene/gl_walls.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 01b19bc39..5d3fe4f37 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -678,6 +678,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, GLSeg glsave=glseg; fixed_t texturetop, texturebottom; bool wrap = (seg->linedef->flags&ML_WRAP_MIDTEX) || (seg->sidedef->Flags&WALLF_WRAP_MIDTEX); + bool mirrory = false; // // @@ -690,16 +691,22 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // At this point slopes don't matter because they don't affect the texture's z-position gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::mid), seg->sidedef->GetTextureYScale(side_t::mid)); - fixed_t rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); - if ( (seg->linedef->flags & ML_DONTPEGBOTTOM) >0) + if (tci.mRenderHeight < 0) { - texturebottom = MAX(realfront->GetPlaneTexZ(sector_t::floor),realback->GetPlaneTexZ(sector_t::floor))+rowoffset; - texturetop=texturebottom+(tci.mRenderHeight << FRACBITS); + mirrory = true; + tci.mRenderHeight = -tci.mRenderHeight; + tci.mScaleY = -tci.mScaleY; + } + fixed_t rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); + if ((seg->linedef->flags & ML_DONTPEGBOTTOM) >0) + { + texturebottom = MAX(realfront->GetPlaneTexZ(sector_t::floor), realback->GetPlaneTexZ(sector_t::floor)) + rowoffset; + texturetop = texturebottom + (tci.mRenderHeight << FRACBITS); } else { - texturetop = MIN(realfront->GetPlaneTexZ(sector_t::ceiling),realback->GetPlaneTexZ(sector_t::ceiling))+rowoffset; - texturebottom=texturetop-(tci.mRenderHeight << FRACBITS); + texturetop = MIN(realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling)) + rowoffset; + texturebottom = texturetop - (tci.mRenderHeight << FRACBITS); } } else texturetop=texturebottom=0; @@ -840,6 +847,11 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, flags|=GLT_CLAMPY; } } + if (mirrory) + { + tci.mRenderHeight = -tci.mRenderHeight; + tci.mScaleY = -tci.mScaleY; + } SetWallCoordinates(seg, &tci, FIXED2FLOAT(texturetop), topleft, topright, bottomleft, bottomright, t_ofs); // From 960825287337319bc419685324028b319a47f253 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 15 Feb 2016 13:11:31 +0100 Subject: [PATCH 0403/1509] - copied over some stuff from the abandoned portals branch. --- src/gl/scene/gl_fakeflat.cpp | 2 ++ src/gl/scene/gl_flats.cpp | 22 ++++++++++++++++++---- src/gl/scene/gl_sky.cpp | 20 ++++++++++++-------- src/gl/scene/gl_walls.cpp | 2 +- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/gl/scene/gl_fakeflat.cpp b/src/gl/scene/gl_fakeflat.cpp index 6ff6bd113..8399526da 100644 --- a/src/gl/scene/gl_fakeflat.cpp +++ b/src/gl/scene/gl_fakeflat.cpp @@ -212,6 +212,8 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac dest->ceilingplane=sec->floorplane; dest->ceilingplane.FlipVert(); dest->planes[sector_t::ceiling].TexZ = dest->planes[sector_t::floor].TexZ; + dest->portals[sector_t::ceiling] = NULL; + dest->portals[sector_t::floor] = NULL; return dest; } } diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index c747236d2..104452953 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -525,8 +525,15 @@ void GLFlat::ProcessSector(sector_t * frontsector) Colormap=frontsector->ColorMap; if ((stack = (frontsector->portals[sector_t::floor] != NULL))) { - gl_drawinfo->AddFloorStack(sector); - alpha = frontsector->GetAlpha(sector_t::floor)/65536.0f; + if (!frontsector->PortalBlocksView(sector_t::floor)) + { + gl_drawinfo->AddFloorStack(sector); + alpha = frontsector->GetAlpha(sector_t::floor) / 65536.0f; + } + else + { + alpha = 1.f; + } } else { @@ -576,8 +583,15 @@ void GLFlat::ProcessSector(sector_t * frontsector) Colormap=frontsector->ColorMap; if ((stack = (frontsector->portals[sector_t::ceiling] != NULL))) { - gl_drawinfo->AddCeilingStack(sector); - alpha = frontsector->GetAlpha(sector_t::ceiling)/65536.0f; + if (!frontsector->PortalBlocksView(sector_t::ceiling)) + { + gl_drawinfo->AddCeilingStack(sector); + alpha = frontsector->GetAlpha(sector_t::ceiling) / 65536.0f; + } + else + { + alpha = 1.f; + } } else { diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 5a5a10a26..0a26e285d 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -142,6 +142,8 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) FPortal *portal = sector->portals[plane]; if (portal != NULL) { + if (sector->PortalBlocksView(plane)) return; + if (GLPortal::instack[1 - plane]) return; ptype = PORTALTYPE_SECTORSTACK; this->portal = portal; @@ -302,8 +304,6 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex } else { - FPortal *pfront = fs->portals[sector_t::ceiling]; - FPortal *pback = bs->portals[sector_t::ceiling]; float frontreflect = fs->GetReflect(sector_t::ceiling); if (frontreflect > 0) { @@ -314,9 +314,12 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex return; } } - else if (pfront == NULL || pfront == pback) + else { - return; + FPortal *pfront = fs->portals[sector_t::ceiling]; + FPortal *pback = bs->portals[sector_t::ceiling]; + if (pfront == NULL || fs->PortalBlocksView(sector_t::ceiling)) return; + if (pfront == pback && !bs->PortalBlocksView(sector_t::ceiling)) return; } // stacked sectors @@ -378,8 +381,6 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver } else { - FPortal *pfront = fs->portals[sector_t::floor]; - FPortal *pback = bs->portals[sector_t::floor]; float frontreflect = fs->GetReflect(sector_t::floor); if (frontreflect > 0) { @@ -390,9 +391,12 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver return; } } - else if (pfront == NULL || pfront == pback) + else { - return; + FPortal *pfront = fs->portals[sector_t::floor]; + FPortal *pback = bs->portals[sector_t::floor]; + if (pfront == NULL || fs->PortalBlocksView(sector_t::floor)) return; + if (pfront == pback && !bs->PortalBlocksView(sector_t::floor)) return; } // stacked sectors diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 5d3fe4f37..132745563 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -175,7 +175,7 @@ void GLWall::PutPortal(int ptype) portal = GLPortal::FindPortal(skybox); if (!portal) { - // either a regulat skybox or an Eternity-style horizon + // either a regular skybox or an Eternity-style horizon if (skybox->special1 != SKYBOX_MAP) portal = new GLEEHorizonPortal(skybox); else portal = new GLSkyboxPortal(skybox); } From c69fd3ac80d25ba0196e1221e2a59a73131daf44 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 16 Feb 2016 10:14:37 +0100 Subject: [PATCH 0404/1509] - removed redundant SKYBOX enum. --- src/gl/scene/gl_walls.cpp | 2 +- src/r_sky.h | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 132745563..32d4ff98a 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -176,7 +176,7 @@ void GLWall::PutPortal(int ptype) if (!portal) { // either a regular skybox or an Eternity-style horizon - if (skybox->special1 != SKYBOX_MAP) portal = new GLEEHorizonPortal(skybox); + if (skybox->special1 != SKYBOX_SKYVIEWPOINT) portal = new GLEEHorizonPortal(skybox); else portal = new GLSkyboxPortal(skybox); } portal->AddLine(this); diff --git a/src/r_sky.h b/src/r_sky.h index 6881f4943..9d33e82a3 100644 --- a/src/r_sky.h +++ b/src/r_sky.h @@ -24,13 +24,6 @@ #include "textures/textures.h" -enum -{ - SKYBOX_MAP = 0, - SKYBOX_PLANE, - SKYBOX_HORIZON -}; - extern FTextureID skyflatnum; extern fixed_t sky1cyl, sky2cyl; extern FTextureID sky1texture, sky2texture; From bd9907f20f4b887fd70d63288269da84c6283afc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 16 Feb 2016 22:01:04 +0100 Subject: [PATCH 0405/1509] - missing #includes in GL code. --- src/gl/data/gl_data.cpp | 1 + src/gl/data/gl_setup.cpp | 1 + src/gl/data/gl_vertexbuffer.cpp | 1 + src/gl/dynlights/a_dynlight.cpp | 2 ++ src/gl/scene/gl_bsp.cpp | 1 + src/gl/scene/gl_flats.cpp | 1 + src/gl/scene/gl_portal.cpp | 2 ++ src/gl/scene/gl_sky.cpp | 1 + src/gl/scene/gl_sprite.cpp | 2 ++ src/gl/scene/gl_walls.cpp | 3 +++ 10 files changed, 15 insertions(+) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index fbebcf954..d69d491f8 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -44,6 +44,7 @@ #include "colormatcher.h" #include "i_system.h" #include "p_local.h" +#include "p_tags.h" #include "p_lnspec.h" #include "c_dispatch.h" #include "r_sky.h" diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index c42a2c19c..7eeabaa33 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -44,6 +44,7 @@ #include "colormatcher.h" #include "i_system.h" #include "p_local.h" +#include "p_spec.h" #include "p_lnspec.h" #include "c_dispatch.h" #include "r_sky.h" diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 0e9065557..87b600d4b 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -41,6 +41,7 @@ #include "gl/system/gl_system.h" #include "doomtype.h" #include "p_local.h" +#include "r_state.h" #include "m_argv.h" #include "c_cvars.h" #include "gl/system/gl_interface.h" diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 3e1cace46..93000e83a 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -43,6 +43,8 @@ #include "thingdef/thingdef.h" #include "i_system.h" #include "templates.h" +#include "doomdata.h" +#include "r_utility.h" #include "gl/renderer/gl_renderer.h" diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index ef7af4d21..613493e2c 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -44,6 +44,7 @@ #include "r_sky.h" #include "p_effect.h" #include "po_man.h" +#include "doomdata.h" #include "gl/renderer/gl_renderer.h" #include "gl/data/gl_data.h" diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 104452953..b996aa97c 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -46,6 +46,7 @@ #include "g_level.h" #include "doomstat.h" #include "d_player.h" +#include "portal.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 5ce683f57..d088d9d70 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -47,6 +47,8 @@ #include "a_sharedglobal.h" #include "r_sky.h" #include "portal.h" +#include "p_maputl.h" +#include "d_player.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 0a26e285d..ca235c0e7 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -45,6 +45,7 @@ #include "r_state.h" #include "r_utility.h" #include "doomdata.h" +#include "portal.h" #include "gl/gl_functions.h" #include "gl/data/gl_data.h" diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 81c9cc3cd..5d8e7436e 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -46,6 +46,8 @@ #include "r_defs.h" #include "r_sky.h" #include "r_utility.h" +#include "a_pickups.h" +#include "d_player.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 32d4ff98a..985cd1353 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -47,6 +47,9 @@ #include "vectors.h" #include "r_defs.h" #include "r_sky.h" +#include "r_utility.h" +#include "p_maputl.h" +#include "doomdata.h" #include "portal.h" #include "gl/system/gl_cvars.h" From 0ecfc682058e6aba55ef7683a16c36b799f1d066 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 16 Feb 2016 22:56:36 +0100 Subject: [PATCH 0406/1509] - fixed conditions for PortalBlocksView. Created a new function PortalBlocksSight that's relevant for playsim-related sight checks. --- src/portal.h | 7 +++++++ src/r_defs.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/portal.h b/src/portal.h index 40c4a30fc..b37ee3b7b 100644 --- a/src/portal.h +++ b/src/portal.h @@ -205,6 +205,13 @@ inline int line_t::getPortalAlignment() const } inline bool sector_t::PortalBlocksView(int plane) +{ + if (SkyBoxes[plane] == NULL) return true; + if (SkyBoxes[plane]->special1 != SKYBOX_LINKEDPORTAL) return false; + return !!(planes[plane].Flags & (PLANEF_NORENDER | PLANEF_DISABLED | PLANEF_OBSTRUCTED)); +} + +inline bool sector_t::PortalBlocksSight(int plane) { if (SkyBoxes[plane] == NULL || SkyBoxes[plane]->special1 != SKYBOX_LINKEDPORTAL) return true; return !!(planes[plane].Flags & (PLANEF_NORENDER | PLANEF_DISABLED | PLANEF_OBSTRUCTED)); diff --git a/src/r_defs.h b/src/r_defs.h index 920c1f3f8..13a20cade 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -793,6 +793,7 @@ struct sector_t } bool PortalBlocksView(int plane); + bool PortalBlocksSight(int plane); bool PortalBlocksMovement(int plane); bool PortalBlocksSound(int plane); From 0a539ed2d5c9f9b4bbb6d9af528ee3d3591a9727 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 Feb 2016 17:40:08 +0100 Subject: [PATCH 0407/1509] - fixed: fake contrast was not applied. --- src/gl/scene/gl_walls_draw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index c06558b11..02a48c706 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -310,7 +310,7 @@ void GLWall::RenderMirrorSurface() void GLWall::RenderTextured(int rflags) { int tmode = gl_RenderState.GetTextureMode(); - int rel = getExtraLight(); + int rel = rellight + getExtraLight(); if (flags & GLWF_GLOW) { From bd67f3b3e5bbc1878509d051d76ed89b8a3b43d6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 Feb 2016 18:36:10 +0100 Subject: [PATCH 0408/1509] - added skybox cast for GL code. --- src/gl/data/gl_portaldata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 6640d2d4a..14a78c7a1 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -356,7 +356,7 @@ static void CollectPortalSectors(FPortalMap &collection) sector_t *sec = §ors[i]; for (int j = 0; j < 2; j++) { - ASkyViewpoint *SkyBox = sec->SkyBoxes[j]; + ASkyViewpoint *SkyBox = barrier_cast(sec->SkyBoxes[j]); if (SkyBox != NULL && SkyBox->bAlways && SkyBox->Mate != NULL) { FPortalID id = { SkyBox->X() - SkyBox->Mate->X(), SkyBox->Y() - SkyBox->Mate->Y() }; From 9af5dd357fcd3c6777c7c922bbf955191513159a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 20 Feb 2016 02:20:18 +0100 Subject: [PATCH 0409/1509] - removed the camera adjustment in FGLRenderer::SetViewArea because this had already been done by R_SetupFrame. --- src/gl/scene/gl_scene.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 5f0cb8994..6780a0e55 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -132,19 +132,6 @@ void FGLRenderer::SetViewArea() // The render_sector is better suited to represent the current position in GL viewsector = R_PointInSubsector(viewx, viewy)->render_sector; - // keep the view within the render sector's floor and ceiling - fixed_t theZ = viewsector->ceilingplane.ZatPoint (viewx, viewy) - 4*FRACUNIT; - if (viewz > theZ) - { - viewz = theZ; - } - - theZ = viewsector->floorplane.ZatPoint (viewx, viewy) + 4*FRACUNIT; - if (viewz < theZ) - { - viewz = theZ; - } - // Get the heightsec state from the render sector, not the current one! if (viewsector->heightsec && !(viewsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) { From a9018759251767a5c944b5d45dfe02369dc8f536 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Feb 2016 01:38:41 +0100 Subject: [PATCH 0410/1509] - fixed: The horizon portal drawer must set the camera position for the shader. This gets lost when several portals are drawn sequentially and this is the only portal type which needs this information but doesn't go through the normal setup. If this is not done, fog on the horizon plane can break. --- src/gl/scene/gl_portal.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index d088d9d70..4737f518d 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -1150,6 +1150,7 @@ void GLHorizonPortal::DrawContents() PortalAll.Unclock(); return; } + gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); z=FIXED2FLOAT(sp->texheight); From 939823a1413d3485e8e9f39adbdc5f6862fe0874 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 21 Feb 2016 10:19:15 +0200 Subject: [PATCH 0411/1509] Restored layout of Video Options menu Screen size option was missed during the last merge --- wadsrc/static/menudef.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 13a2a2e65..8b605e6f3 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -663,13 +663,17 @@ OptionMenu "VideoOptions" Title "$DSPLYMNU_TITLE" Submenu "OpenGL Options", "OpenGLOptions" - Submenu "$DSPLYMNU_SCOREBOARD", "ScoreboardOptions" StaticText " " + Submenu "$DSPLYMNU_SCOREBOARD", "ScoreboardOptions" + StaticText " " + Slider "$DSPLYMNU_SCREENSIZE", "screenblocks", 3.0, 12.0, 1.0, 0 + Slider "Gamma correction", "Gamma", 0.75, 3.0, 0.05, 2 Slider "Brightness", "vid_brightness", -0.8,0.8, 0.05 Slider "Contrast", "vid_contrast", 0.1, 3.0, 0.1 + Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff" Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn" - + StaticText " " Option "$DSPLYMNU_WIPETYPE", "wipetype", "Wipes" From 8f536323175e438a0fcbb34cc06ce0a66a67d405 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Feb 2016 11:37:31 +0100 Subject: [PATCH 0412/1509] - externalized the GZDoom-exclusive strings in Menudefs.enu --- wadsrc/static/language.enu | 11 +++++++++++ wadsrc/static/menudef.txt | 16 ++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 1fbf83b08..2d407cd44 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2540,3 +2540,14 @@ MUSIC_ULTIMA = "ultima"; MUSIC_READ_M = "read_m"; MUSIC_DM2TTL = "dm2ttl"; MUSIC_DM2INT = "dm2int"; + +// GZDoom exclusive: + +DSPLYMNU_GLOPT = "OpenGL Options"; +DSPLYMNU_GAMMA = "Gamma correction"; +DSPLYMNU_CONTRAST ="Contrast"; + +GLMNU_TITLE = "OPENGL OPTIONS"; +GLMNU_DYNLIGHT = "Dynamic Light Options"; +GLMNU_TEXOPT = "Texture Options"; +GLMNU_PREFS = "Preferences"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 8b605e6f3..f85bcd9b0 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -652,24 +652,24 @@ OptionValue Fuzziness OptionMenu "OpenGLOptions" { - Title "OPENGL OPTIONS" - Submenu "Dynamic Light Options", "GLLightOptions" - Submenu "Texture Options", "GLTextureGLOptions" - Submenu "Preferences", "GLPrefOptions" + Title "$GLMNU_TITLE" + Submenu "$GLMNU_DYNLIGHT", "GLLightOptions" + Submenu "$GLMNU_TEXOPT", "GLTextureGLOptions" + Submenu "$GLMNU_PREFS", "GLPrefOptions" } OptionMenu "VideoOptions" { Title "$DSPLYMNU_TITLE" - Submenu "OpenGL Options", "OpenGLOptions" + Submenu "$DSPLYMNU_GLOPT", "OpenGLOptions" Submenu "$DSPLYMNU_SCOREBOARD", "ScoreboardOptions" StaticText " " Slider "$DSPLYMNU_SCREENSIZE", "screenblocks", 3.0, 12.0, 1.0, 0 - Slider "Gamma correction", "Gamma", 0.75, 3.0, 0.05, 2 - Slider "Brightness", "vid_brightness", -0.8,0.8, 0.05 - Slider "Contrast", "vid_contrast", 0.1, 3.0, 0.1 + Slider "$DSPLYMNU_GAMMA", "Gamma", 0.75, 3.0, 0.05, 2 + Slider "$DSPLYMNU_BRIGHTNESS", "vid_brightness", -0.8,0.8, 0.05 + Slider "$DSPLYMNU_CONTRAST", "vid_contrast", 0.1, 3.0, 0.1 Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff" Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn" From e3ddc74eb12ce058dd565564488a63d19328664b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 24 Feb 2016 01:13:55 +0100 Subject: [PATCH 0413/1509] - check r_showviewer when deciding whether to render the player sprite. This is necessary when camera and player end up on different sides of a portal. --- src/gl/scene/gl_sprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 5d8e7436e..01bc1717d 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -483,7 +483,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) sector_t rs; sector_t * rendersector; // don't draw the thing that's used as camera (for viewshifts during quakes!) - if (thing==GLRenderer->mViewActor) return; + if (thing==GLRenderer->mViewActor || (thing == players[consoleplayer].camera && !r_showviewer)) return; // Don't waste time projecting sprites that are definitely not visible. if (thing == NULL || thing->sprite == 0 || !thing->IsVisibleToPlayer()) From 387f3dd03a55260ac5d7dffb0f244593db964c6b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 25 Feb 2016 13:06:13 +0100 Subject: [PATCH 0414/1509] - fixed compile errors due to changes in ZDoom. --- src/gl/scene/gl_flats.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index b996aa97c..ff42999b4 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -660,7 +660,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) if (rover->flags&FF_FOG && gl_fixedcolormap) continue; if (!rover->top.copied && rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) { - fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector)); + fixed_t ff_top=rover->top.plane->ZatPoint(sector->centerspot); if (ff_toptop.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) @@ -674,7 +674,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) } if (!rover->bottom.copied && !(rover->flags&FF_INVERTPLANES)) { - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector)); + fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sector->centerspot); if (ff_bottombottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) @@ -700,7 +700,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) if (rover->flags&FF_FOG && gl_fixedcolormap) continue; if (!rover->bottom.copied && rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) { - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector)); + fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sector->centerspot); if (ff_bottom>lastfloorheight || (rover->flags&FF_FIX)) { if (FIXED2FLOAT(viewz) >= rover->bottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) @@ -721,7 +721,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) } if (!rover->top.copied && !(rover->flags&FF_INVERTPLANES)) { - fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector)); + fixed_t ff_top=rover->top.plane->ZatPoint(sector->centerspot); if (ff_top>lastfloorheight) { if (FIXED2FLOAT(viewz) >= rover->top.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) From 213d7a75c2081f1e08346b1085fbf3d343b2d544 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Feb 2016 12:09:59 +0100 Subject: [PATCH 0415/1509] - fixed: r_showviewer must always be true when rendering a mirror portal. --- src/gl/scene/gl_portal.cpp | 7 +++++++ src/gl/scene/gl_portal.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 4737f518d..a186d4ff0 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -83,6 +83,8 @@ EXTERN_CVAR(Bool, gl_portals) EXTERN_CVAR(Bool, gl_noquery) EXTERN_CVAR(Int, r_mirror_recursions) +extern bool r_showviewer; + TArray GLPortal::portals; TArray GLPortal::planestack; int GLPortal::recursion; @@ -311,6 +313,7 @@ bool GLPortal::Start(bool usestencil, bool doquery) savedviewactor=GLRenderer->mViewActor; savedviewangle=viewangle; savedviewarea=in_area; + savedshowviewer = r_showviewer; NextPortal = GLRenderer->mCurrentPortal; GLRenderer->mCurrentPortal = NULL; // Portals which need this have to set it themselves @@ -382,6 +385,7 @@ void GLPortal::End(bool usestencil) viewangle=savedviewangle; GLRenderer->mViewActor=savedviewactor; in_area=savedviewarea; + r_showviewer = savedshowviewer; GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); { @@ -440,6 +444,7 @@ void GLPortal::End(bool usestencil) viewangle=savedviewangle; GLRenderer->mViewActor=savedviewactor; in_area=savedviewarea; + r_showviewer = savedshowviewer; GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); // This draws a valid z-buffer into the stencil's contents to ensure it @@ -806,6 +811,7 @@ void GLPlaneMirrorPortal::DrawContents() viewz = 2*planez - viewz; GLRenderer->mViewActor = NULL; PlaneMirrorMode = ksgn(origin->c); + r_showviewer = true; validcount++; @@ -922,6 +928,7 @@ void GLMirrorPortal::DrawContents() linedef->v2->x, linedef->v2->y) - startang; GLRenderer->mViewActor = NULL; + r_showviewer = true; validcount++; diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 5a2af3807..177c2230e 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -117,6 +117,7 @@ private: angle_t savedviewangle; AActor * savedviewactor; area_t savedviewarea; + bool savedshowviewer; GLPortal *NextPortal; TArray savedmapsection; TArray mPrimIndices; From ee18fdeb83212f82d311a6dc646f9bb6fb938da7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 28 Feb 2016 10:10:01 +0100 Subject: [PATCH 0416/1509] - fixed: Visplane merging should not be done for linedef based portals. --- src/gl/scene/gl_flats.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index ff42999b4..c6ca9df96 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -528,7 +528,10 @@ void GLFlat::ProcessSector(sector_t * frontsector) { if (!frontsector->PortalBlocksView(sector_t::floor)) { - gl_drawinfo->AddFloorStack(sector); + if (sector->SkyBoxes[sector_t::floor]->special1 == SKYBOX_STACKEDSECTORTHING) + { + gl_drawinfo->AddFloorStack(sector); + } alpha = frontsector->GetAlpha(sector_t::floor) / 65536.0f; } else @@ -586,7 +589,10 @@ void GLFlat::ProcessSector(sector_t * frontsector) { if (!frontsector->PortalBlocksView(sector_t::ceiling)) { - gl_drawinfo->AddCeilingStack(sector); + if (sector->SkyBoxes[sector_t::ceiling]->special1 == SKYBOX_STACKEDSECTORTHING) + { + gl_drawinfo->AddCeilingStack(sector); + } alpha = frontsector->GetAlpha(sector_t::ceiling) / 65536.0f; } else From ec4b3da93de3bdb45c7aa007044bfef78376165f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 4 Mar 2016 01:39:55 +0100 Subject: [PATCH 0417/1509] - added some more British English text variants. --- wadsrc/static/language.eng | 61 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/wadsrc/static/language.eng b/wadsrc/static/language.eng index 6f9095032..11c5b8f0a 100644 --- a/wadsrc/static/language.eng +++ b/wadsrc/static/language.eng @@ -1,11 +1,51 @@ -/* British English */ +/* British, Canadian, Australian, New Zealand, Hiberno, South African, Jamaican, +Caribbean, Belizean, Trinidadian, and Zimbabwean English */ -[eng] +[eng enc ena enz eni ens enj enb enl ent enw] GOTARMOR = "Picked up the armour."; GOTMEGA = "Picked up the MegaArmour!"; GOTARMBONUS = "Picked up an armour bonus."; +C2TEXT = + "YOU HAVE WON! YOUR VICTORY HAS ENABLED\n" + "HUMANKIND TO EVACUATE EARTH AND ESCAPE\n" + "THE NIGHTMARE. NOW YOU ARE THE ONLY\n" + "HUMAN LEFT ON THE FACE OF THE PLANET.\n" + "CANNIBAL MUTATIONS, CARNIVOROUS ALIENS,\n" + "AND EVIL SPIRITS ARE YOUR ONLY NEIGHBOURS.\n" + "YOU SIT BACK AND WAIT FOR DEATH, CONTENT\n" + "THAT YOU HAVE SAVED YOUR SPECIES.\n" + "\n" + "BUT THEN, EARTH CONTROL BEAMS DOWN A\n" + "MESSAGE FROM SPACE: \"SENSORS HAVE LOCATED\n" + "THE SOURCE OF THE ALIEN INVASION. IF YOU\n" + "GO THERE, YOU MAY BE ABLE TO BLOCK THEIR\n" + "ENTRY. THE ALIEN BASE IS IN THE HEART OF\n" + "YOUR OWN HOME CITY, NOT FAR FROM THE\n" + "STARPORT.\" SLOWLY AND PAINFULLY YOU GET\n" + "UP AND RETURN TO THE FRAY."; +NERVETEXT = + "TROUBLE WAS BREWING AGAIN IN YOUR FAVOURITE\n" + "VACATION SPOT... HELL. SOME CYBERDEMON\n" + "PUNK THOUGHT HE COULD TURN HELL INTO A\n" + "PERSONAL AMUSEMENT PARK, AND MAKE EARTH\n" + "THE TICKET BOOTH.\n" + "\n" + "WELL THAT HALF-ROBOT FREAK SHOW DIDN'T\n" + "KNOW WHO WAS COMING TO THE FAIR. THERE'S\n" + "NOTHING LIKE A SHOOTING GALLERY FULL OF\n" + "HELLSPAWN TO GET THE BLOOD PUMPING...\n" + "\n" + "NOW THE WALLS OF THE DEMON'S LABYRINTH\n" + "ECHO WITH THE SOUND OF HIS METALLIC LIMBS\n" + "HITTING THE FLOOR. HIS DEATH MOAN GURGLES\n" + "OUT THROUGH THE MESS YOU LEFT OF HIS FACE.\n" + "\n" + "THIS RIDE IS CLOSED.\n"; + +OB_TURRET = "%o triggered the automatic defences."; + SCORE_COLOR = "COLOUR"; TAG_SHADOWARMOR = "Shadow Armour"; @@ -19,12 +59,14 @@ TXT_METALARMOR = "You picked up the Metal Armour."; TXT_LEATHERARMOR = "You picked up the Leather Armour."; TXT_SHADOWARMOR = "You picked up the Shadow armour."; +TXT_RANDOM_PGUARD_10 = "If there is any honour inside that pathetic shell of a body, you'll enter into the arms of the order."; GOTCHEXARMOR = "Picked up the Chex(R) Armour."; GOTSUPERCHEXARMOR = "Picked up the Super Chex(R) Armour!"; OB_BIPEDICUS2 = "%o was slimed by an armoured bipedicus."; MNU_COLORPICKER = "SELECT COLOUR"; +CNTRLMNU_CENTERVIEW = "Centre view"; PLYRMNU_PLAYERCOLOR = "Colour"; DSPLYMNU_DIMCOLOR = "Dim colour"; HUDMNU_CROSSHAIRCOLOR = "Crosshair colour"; @@ -45,10 +87,25 @@ AUTOMAPMNU_CUSTOMCOLORS = "Allow map defined colours"; AUTOMAPMNU_SETCUSTOMCOLORS = "Set custom colours"; MAPCOLORMNU_TITLE = "CUSTOMIZE MAP COLOURS"; MAPCOLORMNU_DEFAULTMAPCOLORS = "Restore default custom colours"; +MAPCOLORMNU_XHAIRCOLOR = "Centre point"; +MSGMNU_CENTERMESSAGES = "Centre messages"; MSGMNU_MESSAGECOLORS = "Message Colours"; +MSGMNU_CENTEREDMESSAGES = "Centred Messages"; SCRBRDMNU_HEADERCOLOR = "Header Colour"; SCRBRDMNU_YOURCOLOR = "Your Player Colour"; SCRBRDMNU_OTHERPLAYERCOLOR = "Other Players' Colour"; GMPLYMNU_ALLOWARMOR = "Allow armour"; GMPLYMNU_KEEPARMOR = "Keep armour"; +CMPTMNU_ACTORBEHAVIOR = "Actor Behaviour"; +CMPTMNU_DEHACKEDBEHAVIOR = "DehackEd Behaviour"; +CMPTMNU_MAPACTIONBEHAVIOR = "Map/Action Behaviour"; +CMPTMNU_LIGHT = "Find neighbouring light like Doom"; +CMPTMNU_FLOORMOVE = "Use Doom's floor motion behaviour"; +CMPTMNU_PHYSICSBEHAVIOR = "Physics Behaviour"; +CMPTMNU_RENDERINGBEHAVIOR = "Rendering Behaviour"; +CMPTMNU_SOUNDBEHAVIOR = "Sound Behaviour"; +CMPTMNU_SECTORSOUNDS = "Sector sounds use centre as source"; OPTVAL_MAPDEFINEDCOLORSONLY = "Map defined colours only"; +C_GRAY = "\ccgrey"; +C_DARKGRAY = "\cudark grey"; +MNU_COLORPICKER = "SELECT COLOUR"; From 7ceb6d86dd2ea769f2b09dcaa7e47b4edca35667 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 4 Mar 2016 10:39:10 +0100 Subject: [PATCH 0418/1509] - fixed compilation. --- src/gl/scene/gl_portal.cpp | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index a186d4ff0..106bf4828 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -952,16 +952,7 @@ void GLMirrorPortal::DrawContents() int GLMirrorPortal::ClipSeg(seg_t *seg) { - //we cannot use P_PointOnLineSide here because it loses the special meaning of 0 == 'on the line'. - int side1 = DMulScale32(seg->v1->y - linedef->v1->y, linedef->dx, linedef->v1->x - seg->v1->x, linedef->dy); - int side2 = DMulScale32(seg->v2->y - linedef->v1->y, linedef->dx, linedef->v1->x - seg->v2->x, linedef->dy); - - if (side1 >= 0 && side2 >= 0) - // this seg is completely behind the mirror. - { - return PClip_InFront; - } - return PClip_Inside; + return P_ClipLineToPortal(seg->linedef, linedef, viewx, viewy) ? PClip_InFront : PClip_Inside; } int GLMirrorPortal::ClipSubsector(subsector_t *sub) @@ -994,25 +985,6 @@ int GLMirrorPortal::ClipPoint(fixed_t x, fixed_t y) //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -static void glTranslatePortal(line_t* src, line_t* dst, fixed_t& x, fixed_t& y, angle_t & angle) -{ - // Get the angle between the two linedefs, for rotating - // orientation and velocity. Rotate 180 degrees, and flip - // the position across the exit linedef, if reversed. - - double xangle = atan2(double(dst->dy), double(dst->dx)) - atan2(double(src->dy), double(src->dx)) + M_PI; - double s = sin(xangle); - double c = cos(xangle); - - fixed_t nposx = x - src->v1->x; - fixed_t nposy = y - src->v1->y; - - // Rotate position along normal to match exit linedef - x = xs_RoundToInt(nposx * c - nposy * s) + dst->v2->x; - y = xs_RoundToInt(nposy * c + nposx * s) + dst->v2->y; - angle += xs_CRoundToInt(xangle * (ANGLE_180 / M_PI)); -} - void GLLineToLineInfo::init(line_t *line) { static const divline_t divlx = { 0, 0, 128 * FRACUNIT, 0 }; @@ -1030,8 +1002,9 @@ void GLLineToLineInfo::init(line_t *line) viewy = ::viewy; viewz = ::viewz; viewangle = ::viewangle; - glTranslatePortal(line, line->getPortalDestination(), viewx, viewy, viewangle); - P_TranslatePortalZ(line, line->getPortalDestination(), viewz); + P_TranslatePortalXY(line, viewx, viewy); + P_TranslatePortalAngle(line, viewangle); + P_TranslatePortalZ(line, viewz); } From af1b70376b04418a48e3047b614c2196940d005f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 4 Mar 2016 11:47:15 +0100 Subject: [PATCH 0419/1509] - added 21:9 handling to GL code. --- src/gl/scene/gl_scene.cpp | 4 ++-- src/gl/scene/gl_weapon.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 6780a0e55..22911a21b 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -878,12 +878,12 @@ void FGLRenderer::RenderView (player_t* player) // I stopped using BaseRatioSizes here because the information there wasn't well presented. // 4:3 16:9 16:10 17:10 5:4 - static float ratios[]={1.333333f, 1.777777f, 1.6f, 1.7f, 1.25f}; + static float ratios[]={1.333333f, 1.777777f, 1.6f, 1.7f, 1.25f, 1.7f, 2.333333f}; // now render the main view float fovratio; float ratio = ratios[WidescreenRatio]; - if (!(WidescreenRatio&4)) + if (! Is54Aspect(WidescreenRatio)) { fovratio = 1.333333f; } diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 3fcc0c251..2d0f08511 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -80,8 +80,8 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed float scale; float scalex; float ftexturemid; - // 4:3 16:9 16:10 17:10 5:4 - static float xratio[] = {1.f, 3.f/4, 5.f/6, 40.f/51, 1.f}; + // 4:3 16:9 16:10 17:10 5:4 17:10 21:9 + static float xratio[] = {1.f, 3.f/4, 5.f/6, 40.f/51, 1.f, 40.f/51, 4.f/7}; // [BB] In the HUD model step we just render the model and break out. if ( hudModelStep ) From dbd89c2702987278536bb85c346b54df18a07561 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 4 Mar 2016 14:10:13 +0100 Subject: [PATCH 0420/1509] - refactoring of portal grouping for the renderer, to allow more efficient clipping. --- src/gl/data/gl_data.h | 10 +++++ src/gl/data/gl_portaldata.cpp | 73 ++++++++++++++++++++++++++++++++ src/gl/scene/gl_portal.cpp | 48 +++++++-------------- src/gl/scene/gl_portal.h | 78 +++++++++++++++++++++-------------- src/gl/scene/gl_wall.h | 4 +- src/gl/scene/gl_walls.cpp | 12 ++---- 6 files changed, 151 insertions(+), 74 deletions(-) diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index ac2fe0285..9618a5bef 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -54,7 +54,17 @@ struct FPortal GLSectorStackPortal *GetGLPortal(); }; +struct FGLLinePortal +{ + // defines the complete span of this portal + vertex_t *v1, *v2; // vertices, from v1 to v2 + fixed_t dx, dy; // precalculated v2 - v1 for side checking + FLinePortal *reference; // one of the associated line portals, for retrieving translation info etc. +}; + extern TArray portals; +extern TArray linePortalToGL; + extern TArray currentmapsection; void gl_InitPortals(); diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 14a78c7a1..77a93434b 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -87,6 +87,8 @@ typedef TArray FPortalSectors; typedef TMap FPortalMap; TArray portals; +TArray linePortalToGL; +TArray glLinePortals; //========================================================================== // @@ -426,6 +428,77 @@ void gl_InitPortals() } } } + + // Now group the line portals (each group must be a continuous set of colinear linedefs with no gaps) + glLinePortals.Clear(); + linePortalToGL.Clear(); + TArray tempindex; + + tempindex.Reserve(linePortals.Size()); + memset(&tempindex[0], -1, linePortals.Size() * sizeof(int)); + + for (unsigned i = 0; i < linePortals.Size(); i++) + { + auto port = linePortals[i]; + bool gotsome; + + if (tempindex[i] == -1) + { + tempindex[i] = glLinePortals.Size(); + line_t *pSrcLine = linePortals[i].mOrigin; + line_t *pLine = linePortals[i].mDestination; + FGLLinePortal glport = { pLine->v1, pLine->v2, 0, 0, &linePortals[i] }; + glLinePortals.Push(glport); + + // We cannot do this grouping for non-linked portals because they can be changed at run time. + if (linePortals[i].mType == PORTT_LINKED) + do + { + // now collect all other colinear lines connected to this one. We run this loop as long as it still finds a match + gotsome = false; + for (unsigned j = 0; j < linePortals.Size(); j++) + { + if (tempindex[j] == -1) + { + line_t *pSrcLine2 = linePortals[j].mOrigin; + line_t *pLine2 = linePortals[j].mDestination; + // angular precision is intentionally reduced to 32 bit BAM to account for precision problems (otherwise many not perfectly horizontal or vertical portals aren't found here.) + angle_t srcang = RAD2ANGLE(atan2(pSrcLine->dy, pSrcLine->dx)); + angle_t dstang = RAD2ANGLE(atan2(pLine->dy, pLine->dx)); + if ((pSrcLine->v2 == pSrcLine2->v1 && pLine->v1 == pLine2->v2) || + (pSrcLine->v1 == pSrcLine2->v2 && pLine->v2 == pLine2->v1)) + { + // The line connects, now check the translation + fixed_t srcang2 = RAD2ANGLE(atan2(pSrcLine2->dy, pSrcLine2->dx)); + fixed_t dstang2 = RAD2ANGLE(atan2(pLine2->dy, pLine2->dx)); + if (srcang == srcang2 && dstang == dstang2) + { + // The lines connect and both source and destination are colinear, so this is a match + gotsome = true; + tempindex[j] = tempindex[i]; + if (pLine->v1 == pLine2->v2) glLinePortals[tempindex[i]].v1 = pLine2->v1; + else glLinePortals[tempindex[i]].v2 = pLine2->v2; + } + } + } + } + } while (gotsome); + } + } + for (auto glport : glLinePortals) + { + glport.dx = glport.v2->x - glport.v1->x; + glport.dy = glport.v2->y - glport.v1->y; + } + linePortalToGL.Resize(linePortals.Size()); + for (unsigned i = 0; i < linePortals.Size(); i++) + { + linePortalToGL[i] = &glLinePortals[tempindex[i]]; + /* + Printf("portal at line %d translates to GL portal %d, range = %f,%f to %f,%f\n", + int(linePortals[i].mOrigin - lines), tempindex[i], linePortalToGL[i]->v1->x / 65536., linePortalToGL[i]->v1->y / 65536., linePortalToGL[i]->v2->x / 65536., linePortalToGL[i]->v2->y / 65536.); + */ + } } CCMD(dumpportals) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 106bf4828..9dd9edc94 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -100,7 +100,7 @@ bool GLPortal::inskybox; UniqueList UniqueSkies; UniqueList UniqueHorizons; UniqueList UniquePlaneMirrors; -UniqueList UniqueLineToLines; +UniqueList UniqueLineToLines; @@ -950,24 +950,24 @@ void GLMirrorPortal::DrawContents() } -int GLMirrorPortal::ClipSeg(seg_t *seg) +int GLLinePortal::ClipSeg(seg_t *seg) { - return P_ClipLineToPortal(seg->linedef, linedef, viewx, viewy) ? PClip_InFront : PClip_Inside; + return PClip_Inside;// P_ClipLineToPortal(seg->linedef, line(), viewx, viewy) ? PClip_InFront : PClip_Inside; } -int GLMirrorPortal::ClipSubsector(subsector_t *sub) +int GLLinePortal::ClipSubsector(subsector_t *sub) { // this seg is completely behind the mirror! for(unsigned int i=0;inumlines;i++) { - if (P_PointOnLineSidePrecise(sub->firstline[i].v1->x, sub->firstline[i].v1->y, linedef) == 0) return PClip_Inside; + if (P_PointOnLineSidePrecise(sub->firstline[i].v1->x, sub->firstline[i].v1->y, line()) == 0) return PClip_Inside; } return PClip_InFront; } -int GLMirrorPortal::ClipPoint(fixed_t x, fixed_t y) +int GLLinePortal::ClipPoint(fixed_t x, fixed_t y) { - if (P_PointOnLineSidePrecise(x, y, linedef)) + if (P_PointOnLineSidePrecise(x, y, line())) { return PClip_InFront; } @@ -985,29 +985,6 @@ int GLMirrorPortal::ClipPoint(fixed_t x, fixed_t y) //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void GLLineToLineInfo::init(line_t *line) -{ - static const divline_t divlx = { 0, 0, 128 * FRACUNIT, 0 }; - static const divline_t divly = { 0, 0, 0, 128 * FRACUNIT }; - - // store some info about the portal line - divline_t divl; - P_MakeDivline(line, &divl); - x0 = P_InterceptVector(&divlx, &divl); - y0 = P_InterceptVector(&divly, &divl); - lineangle = R_PointToAnglePrecise(line->v1->x, line->v1->y, line->v2->x, line->v2->y); - - // and some info about the viewpoint translation - viewx = ::viewx; - viewy = ::viewy; - viewz = ::viewz; - viewangle = ::viewangle; - P_TranslatePortalXY(line, viewx, viewy); - P_TranslatePortalAngle(line, viewangle); - P_TranslatePortalZ(line, viewz); -} - - //----------------------------------------------------------------------------- // // @@ -1024,10 +1001,11 @@ void GLLineToLinePortal::DrawContents() GLRenderer->mCurrentPortal = this; - viewx = l2l->viewx; - viewy = l2l->viewy; - viewz = l2l->viewz; - viewangle = l2l->viewangle; + line_t *origin = glport->reference->mOrigin; + P_TranslatePortalXY(origin, viewx, viewy); + P_TranslatePortalAngle(origin, viewangle); + P_TranslatePortalZ(origin, viewz); + SaveMapSection(); for (unsigned i = 0; i < lines.Size(); i++) @@ -1051,6 +1029,7 @@ void GLLineToLinePortal::DrawContents() } +/* int GLLineToLinePortal::ClipSeg(seg_t *seg) { line_t *linedef = lines[0].seg->linedef->getPortalDestination(); @@ -1086,6 +1065,7 @@ int GLLineToLinePortal::ClipPoint(fixed_t x, fixed_t y) } return PClip_Inside; } +*/ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 177c2230e..6b94e649c 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -41,9 +41,11 @@ #include "gl/renderer/gl_renderer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/utility/gl_templates.h" +#include "gl/data/gl_data.h" class ASkyViewpoint; + struct GLHorizonInfo { GLSectorPlane plane; @@ -51,18 +53,6 @@ struct GLHorizonInfo FColormap colormap; }; -struct GLLineToLineInfo -{ - angle_t viewangle; - fixed_t viewx; - fixed_t viewy; - fixed_t viewz; - fixed_t x0, y0; - angle_t lineangle; - - void init(line_t *line); -}; - struct GLSkyInfo { float x_offset[2]; @@ -88,7 +78,7 @@ struct GLSkyInfo extern UniqueList UniqueSkies; extern UniqueList UniqueHorizons; extern UniqueList UniquePlaneMirrors; -extern UniqueList UniqueLineToLines; +extern UniqueList UniqueLineToLines; struct GLEEHorizonPortal; class GLPortal @@ -184,8 +174,44 @@ public: static GLPortal * FindPortal(const void * src); }; +struct GLLinePortal : public GLPortal +{ + // this must be the same as at the start of line_t, so that we can pass in this structure directly to P_ClipLineToPortal. + vertex_t *v1, *v2; // vertices, from v1 to v2 + fixed_t dx, dy; // precalculated v2 - v1 for side checking -struct GLMirrorPortal : public GLPortal + angle_t angv1, angv2; // for quick comparisons with a line or subsector + + GLLinePortal(line_t *line) + { + v1 = line->v1; + v2 = line->v2; + dx = line->dx; + dy = line->dy; + } + + GLLinePortal(FGLLinePortal *line) + { + v1 = line->v1; + v2 = line->v2; + dx = line->dx; + dy = line->dy; + } + + line_t *line() + { + vertex_t **pv = &v1; + return reinterpret_cast(pv); + } + + virtual int ClipSeg(seg_t *seg); + virtual int ClipSubsector(subsector_t *sub); + virtual int ClipPoint(fixed_t x, fixed_t y); + virtual bool NeedCap() { return false; } +}; + + +struct GLMirrorPortal : public GLLinePortal { // mirror portals always consist of single linedefs! line_t * linedef; @@ -198,36 +224,28 @@ protected: public: GLMirrorPortal(line_t * line) + : GLLinePortal(line) { linedef=line; } - - virtual bool NeedCap() { return false; } - virtual int ClipSeg(seg_t *seg); - virtual int ClipSubsector(subsector_t *sub); - virtual int ClipPoint(fixed_t x, fixed_t y); }; -struct GLLineToLinePortal : public GLPortal +struct GLLineToLinePortal : public GLLinePortal { - GLLineToLineInfo *l2l; + FGLLinePortal *glport; protected: virtual void DrawContents(); - virtual void * GetSource() const { return l2l; } + virtual void * GetSource() const { return glport; } virtual const char *GetName(); public: - GLLineToLinePortal(GLLineToLineInfo *ll) + GLLineToLinePortal(FGLLinePortal *ll) + : GLLinePortal(ll) { - l2l=ll; + glport = ll; } - - virtual bool NeedCap() { return false; } - virtual int ClipSeg(seg_t *seg); - virtual int ClipSubsector(subsector_t *sub); - virtual int ClipPoint(fixed_t x, fixed_t y); }; @@ -238,7 +256,7 @@ struct GLSkyboxPortal : public GLPortal protected: virtual void DrawContents(); virtual void * GetSource() const { return origin; } - virtual bool IsSky() { return true; } // later! + virtual bool IsSky() { return true; } virtual const char *GetName(); public: diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 1dc060e66..ce03267a3 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -21,7 +21,7 @@ struct GLSkyInfo; struct FTexCoordInfo; struct FPortal; struct FFlatVertex; -struct GLLineToLineInfo; +struct FGLLinePortal; enum WallTypes @@ -149,7 +149,7 @@ public: GLHorizonInfo * horizon; // for horizon information FPortal * portal; // stacked sector portals secplane_t * planemirror; // for plane mirrors - GLLineToLineInfo *l2l; // line-to-line portals + FGLLinePortal *lineportal; // line-to-line portals }; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 985cd1353..1d974205c 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -214,8 +214,8 @@ void GLWall::PutPortal(int ptype) break; case PORTALTYPE_LINETOLINE: - portal=GLPortal::FindPortal(l2l); - if (!portal) portal=new GLLineToLinePortal(l2l); + portal=GLPortal::FindPortal(lineportal); + if (!portal) portal=new GLLineToLinePortal(lineportal); portal->AddLine(this); break; @@ -1493,13 +1493,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (seg->linedef->isVisualPortal()) { - GLLineToLineInfo llinfo; + lineportal = linePortalToGL[seg->linedef->portalindex]; ztop[0] = zceil[0]; ztop[1] = zceil[1]; zbottom[0] = zfloor[0]; zbottom[1] = zfloor[1]; - llinfo.init(seg->linedef); - l2l = UniqueLineToLines.Get(&llinfo); PutPortal(PORTALTYPE_LINETOLINE); } else if (seg->linedef->skybox == NULL && !seg->linedef->isVisualPortal()) @@ -1617,13 +1615,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (seg->linedef->isVisualPortal() && seg->sidedef == seg->linedef->sidedef[0]) { - GLLineToLineInfo llinfo; + lineportal = linePortalToGL[seg->linedef->portalindex]; ztop[0] = FIXED2FLOAT(bch1); ztop[1] = FIXED2FLOAT(bch2); zbottom[0] = FIXED2FLOAT(bfh1); zbottom[1] = FIXED2FLOAT(bfh2); - llinfo.init(seg->linedef); - l2l = UniqueLineToLines.Get(&llinfo); PutPortal(PORTALTYPE_LINETOLINE); } else if (backsector->e->XFloor.ffloors.Size() || frontsector->e->XFloor.ffloors.Size()) From ef9f3da31de97fa8c3645f6c8465847412c2ad94 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 4 Mar 2016 14:41:24 +0100 Subject: [PATCH 0421/1509] - do not use the precalculated coordinates for non-linked portals because they are not static. --- src/gl/scene/gl_portal.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 6b94e649c..89431b1c2 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -192,10 +192,23 @@ struct GLLinePortal : public GLPortal GLLinePortal(FGLLinePortal *line) { - v1 = line->v1; - v2 = line->v2; - dx = line->dx; - dy = line->dy; + if (line->reference->mType != PORTT_LINKED) + { + // For non-linked portals we must check the actual linedef. + line_t *lline = line->reference->mDestination; + v1 = lline->v1; + v2 = lline->v2; + dx = lline->dx; + dy = lline->dy; + } + else + { + // For linked portals we can check the merged span. + v1 = line->v1; + v2 = line->v2; + dx = line->dx; + dy = line->dy; + } } line_t *line() From 26a05857d01e27a7532d865a7b7b859ac27a3d78 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 5 Mar 2016 12:46:47 +0100 Subject: [PATCH 0422/1509] - fixed: Camera textures should not intercept and clear the NoInterpolateView flag. Thanks to some really bad use of a global variable this was causing problems with the inverted order in which GZDoom needs to draw this stuff. --- src/gl/scene/gl_scene.cpp | 7 ++++++- src/r_utility.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 22911a21b..3d8d72aba 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -95,7 +95,8 @@ EXTERN_CVAR (Bool, r_deathcamera) extern int viewpitch; - +extern bool NoInterpolateView; + DWORD gl_fixedcolormap; area_t in_area; TArray currentmapsection; @@ -872,8 +873,12 @@ void FGLRenderer::RenderView (player_t* player) GLRenderer->mLights->Clear(); + // NoInterpolateView should have no bearing on camera textures, but needs to be preserved for the main view below. + bool saved_niv = NoInterpolateView; + NoInterpolateView = false; // prepare all camera textures that have been used in the last frame FCanvasTextureInfo::UpdateAll(); + NoInterpolateView = true; // I stopped using BaseRatioSizes here because the information there wasn't well presented. diff --git a/src/r_utility.cpp b/src/r_utility.cpp index d301b45fc..7be6e0f82 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -80,7 +80,7 @@ struct InterpolationViewer static TArray PastViewers; static FRandom pr_torchflicker ("TorchFlicker"); static FRandom pr_hom; -static bool NoInterpolateView; +bool NoInterpolateView; // GL needs access to this. static TArray InterpolationPath; // PUBLIC DATA DEFINITIONS ------------------------------------------------- From 87d6e03cc279506e887c9652547922c515320a44 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 5 Mar 2016 13:09:49 +0100 Subject: [PATCH 0423/1509] - should have saved before committing... --- src/gl/scene/gl_scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 3d8d72aba..378929897 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -878,7 +878,7 @@ void FGLRenderer::RenderView (player_t* player) NoInterpolateView = false; // prepare all camera textures that have been used in the last frame FCanvasTextureInfo::UpdateAll(); - NoInterpolateView = true; + NoInterpolateView = saved_niv; // I stopped using BaseRatioSizes here because the information there wasn't well presented. From 365c192a1de6c670075be03f7bd25707fb854711 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 8 Mar 2016 21:22:12 +0100 Subject: [PATCH 0424/1509] - added portal support for dynamic lights. This requires fixed offsets so it only works with linked portals. --- src/gl/dynlights/a_dynlight.cpp | 85 ++++++++++++++++++++++--------- src/gl/dynlights/gl_dynlight.h | 6 +-- src/gl/dynlights/gl_dynlight1.cpp | 9 ++-- src/gl/scene/gl_flats.cpp | 2 +- src/gl/scene/gl_walls_draw.cpp | 2 +- 5 files changed, 71 insertions(+), 33 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 93000e83a..e7d41aa22 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -45,6 +45,7 @@ #include "templates.h" #include "doomdata.h" #include "r_utility.h" +#include "portal.h" #include "gl/renderer/gl_renderer.h" @@ -508,25 +509,25 @@ static FLightNode * DeleteLightNode(FLightNode * node) // //========================================================================== -float ADynamicLight::DistToSeg(seg_t *seg) +float ADynamicLight::DistToSeg(const fixedvec3 &pos, seg_t *seg) { - float u, px, py; + float u, px, py; - float seg_dx = FIXED2FLOAT(seg->v2->x - seg->v1->x); - float seg_dy = FIXED2FLOAT(seg->v2->y - seg->v1->y); - float seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy; + float seg_dx = FIXED2FLOAT(seg->v2->x - seg->v1->x); + float seg_dy = FIXED2FLOAT(seg->v2->y - seg->v1->y); + float seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy; - u = ( FIXED2FLOAT(X() - seg->v1->x) * seg_dx + FIXED2FLOAT(Y() - seg->v1->y) * seg_dy) / seg_length_sq; - if (u < 0.f) u = 0.f; // clamp the test point to the line segment - if (u > 1.f) u = 1.f; + u = (FIXED2FLOAT(pos.x - seg->v1->x) * seg_dx + FIXED2FLOAT(pos.y - seg->v1->y) * seg_dy) / seg_length_sq; + if (u < 0.f) u = 0.f; // clamp the test point to the line segment + if (u > 1.f) u = 1.f; - px = FIXED2FLOAT(seg->v1->x) + (u * seg_dx); - py = FIXED2FLOAT(seg->v1->y) + (u * seg_dy); + px = FIXED2FLOAT(seg->v1->x) + (u * seg_dx); + py = FIXED2FLOAT(seg->v1->y) + (u * seg_dy); - px -= FIXED2FLOAT(X()); - py -= FIXED2FLOAT(Y()); + px -= FIXED2FLOAT(pos.x); + py -= FIXED2FLOAT(pos.y); - return (px*px) + (py*py); + return (px*px) + (py*py); } @@ -537,7 +538,7 @@ float ADynamicLight::DistToSeg(seg_t *seg) // //========================================================================== -void ADynamicLight::CollectWithinRadius(subsector_t *subSec, float radius) +void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSec, float radius) { if (!subSec) return; @@ -557,12 +558,28 @@ void ADynamicLight::CollectWithinRadius(subsector_t *subSec, float radius) if (seg->sidedef && seg->linedef && seg->linedef->validcount!=::validcount) { // light is in front of the seg - if (DMulScale32 (Y()-seg->v1->y, seg->v2->x-seg->v1->x, seg->v1->x-X(), seg->v2->y-seg->v1->y) <=0) + if (DMulScale32(pos.y - seg->v1->y, seg->v2->x - seg->v1->x, seg->v1->x - pos.x, seg->v2->y - seg->v1->y) <= 0) { - seg->linedef->validcount=validcount; + seg->linedef->validcount = validcount; touching_sides = AddLightNode(&seg->sidedef->lighthead, seg->sidedef, this, touching_sides); } } + if (seg->linedef) + { + FLinePortal *port = seg->linedef->getPortal(); + if (port && port->mType == PORTT_LINKED) + { + if (DistToSeg(pos, seg) <= radius) + { + line_t *other = port->mDestination; + if (other->validcount != ::validcount) + { + subsector_t *othersub = R_PointInSubsector(other->v1->x + other->dx / 2, other->v1->y + other->dy / 2); + if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(other), othersub, radius); + } + } + } + } seg_t *partner = seg->PartnerSeg; if (partner) @@ -571,13 +588,35 @@ void ADynamicLight::CollectWithinRadius(subsector_t *subSec, float radius) if (sub != NULL && sub->validcount!=::validcount) { // check distance from x/y to seg and if within radius add opposing subsector (lather/rinse/repeat) - if (DistToSeg(seg) <= radius) + if (DistToSeg(pos, seg) <= radius) { - CollectWithinRadius(sub, radius); + CollectWithinRadius(pos, sub, radius); } } } } + if (subSec->sector->PortalIsLinked(sector_t::ceiling)) + { + line_t *other = subSec->firstline->linedef; + AActor *sb = subSec->sector->SkyBoxes[sector_t::ceiling]; + if (sb->threshold < Z() + radius) + { + fixedvec2 refpos = { other->v1->x + other->dx / 2 + sb->scaleX, other->v1->y + other->dy / 2 + sb->scaleY }; + subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y); + if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius); + } + } + if (subSec->sector->PortalIsLinked(sector_t::floor)) + { + line_t *other = subSec->firstline->linedef; + AActor *sb = subSec->sector->SkyBoxes[sector_t::floor]; + if (sb->threshold > Z() - radius) + { + fixedvec2 refpos = { other->v1->x + other->dx / 2 + sb->scaleX, other->v1->y + other->dy / 2 + sb->scaleY }; + subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y); + if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius); + } + } } //========================================================================== @@ -614,12 +653,10 @@ void ADynamicLight::LinkLight() { // passing in radius*radius allows us to do a distance check without any calls to sqrtf subsector_t * subSec = R_PointInSubsector(X(), Y()); - if (subSec) - { - float fradius = FIXED2FLOAT(radius); - ::validcount++; - CollectWithinRadius(subSec, fradius*fradius); - } + float fradius = FIXED2FLOAT(radius); + ::validcount++; + CollectWithinRadius(Pos(), subSec, fradius*fradius); + } // Now delete any nodes that won't be used. These are the ones where diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index c78a0c927..3e263c895 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -99,8 +99,8 @@ public: FLightNode * touching_sector; private: - float DistToSeg(seg_t *seg); - void CollectWithinRadius(subsector_t *subSec, float radius); + float DistToSeg(const fixedvec3 &pos, seg_t *seg); + void CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSec, float radius); protected: fixed_t m_offX, m_offY, m_offZ; @@ -184,7 +184,7 @@ struct FDynLightData -bool gl_GetLight(Plane & p, ADynamicLight * light, bool checkside, bool forceadditive, FDynLightData &data); +bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, bool forceadditive, FDynLightData &data); void gl_UploadLights(FDynLightData &data); diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index 864a9f3ce..b57882dcf 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -85,14 +85,15 @@ CUSTOM_CVAR (Bool, gl_lights_additive, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG // Sets up the parameters to render one dynamic light onto one plane // //========================================================================== -bool gl_GetLight(Plane & p, ADynamicLight * light, bool checkside, bool forceadditive, FDynLightData &ldata) +bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, bool forceadditive, FDynLightData &ldata) { Vector fn, pos; int i = 0; - float x = FIXED2FLOAT(light->X()); - float y = FIXED2FLOAT(light->Y()); - float z = FIXED2FLOAT(light->Z()); + fixedvec3 lpos = light->PosRelative(group); + float x = FIXED2FLOAT(lpos.x); + float y = FIXED2FLOAT(lpos.y); + float z = FIXED2FLOAT(lpos.z); float dist = fabsf(p.DistToPoint(x, z, y)); float radius = (light->GetRadius() * gl_lights_size); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index c6ca9df96..7b8209eb3 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -150,7 +150,7 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli) } p.Set(plane.plane); - gl_GetLight(p, light, false, false, lightdata); + gl_GetLight(sub->sector->PortalGroup, p, light, false, false, lightdata); node = node->nextLight; } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 02a48c706..2b2e5bc6f 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -155,7 +155,7 @@ void GLWall::SetupLights() } if (outcnt[0]!=4 && outcnt[1]!=4 && outcnt[2]!=4 && outcnt[3]!=4) { - gl_GetLight(p, node->lightsource, true, false, lightdata); + gl_GetLight(seg->frontsector->PortalGroup, p, node->lightsource, true, false, lightdata); } } } From 7134f53638de8e7b68f01961b642f33a8fbe645a Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 9 Mar 2016 13:17:42 +0200 Subject: [PATCH 0425/1509] - fixed: partial transparency wasn't taken into account Smoothing of edges could mark textures as non-transparent when hqNx upscale filter is used See http://forum.drdteam.org/viewtopic.php?t=6812 --- src/gl/textures/gl_texture.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index cc2905bb9..0ad87fbfe 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -547,6 +547,7 @@ bool FTexture::SmoothEdges(unsigned char * buffer,int w, int h) int x,y; bool trans=buffer[MSB]==0; // If I set this to false here the code won't detect textures // that only contain transparent pixels. + bool semitrans = false; unsigned char * l1; if (h<=1 || w<=1) return false; // makes (a) no sense and (b) doesn't work with this code! @@ -555,35 +556,44 @@ bool FTexture::SmoothEdges(unsigned char * buffer,int w, int h) if (l1[MSB]==0 && !CHKPIX(1)) CHKPIX(w); + else if (l1[MSB]<255) semitrans=true; l1+=4; for(x=1;x Date: Thu, 10 Mar 2016 15:15:37 +0100 Subject: [PATCH 0426/1509] - that portal check was not correct. --- src/gl/dynlights/a_dynlight.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index e7d41aa22..d1b71a38d 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -595,7 +595,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe } } } - if (subSec->sector->PortalIsLinked(sector_t::ceiling)) + if (!subSec->sector->PortalBlocksSight(sector_t::ceiling)) { line_t *other = subSec->firstline->linedef; AActor *sb = subSec->sector->SkyBoxes[sector_t::ceiling]; @@ -606,7 +606,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius); } } - if (subSec->sector->PortalIsLinked(sector_t::floor)) + if (!subSec->sector->PortalBlocksSight(sector_t::floor)) { line_t *other = subSec->firstline->linedef; AActor *sb = subSec->sector->SkyBoxes[sector_t::floor]; From ae1571158c059fbc72dd635b36e20006ef880dba Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Mar 2016 17:43:36 +0100 Subject: [PATCH 0427/1509] - fixed: The portal link table was not created when there were no sector portals. - fixed: P_TryMove could loop endlessly over a list of static portals when there was an error during portal creation. --- src/gl/models/gl_models.cpp | 6 +++--- src/gl/scene/gl_sprite.cpp | 2 +- src/p_map.cpp | 12 +++++++++-- src/portal.cpp | 42 +++++++++++++++++-------------------- 4 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index ed717693d..508443e31 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -865,9 +865,9 @@ void gl_RenderModel(GLSprite * spr) // [BB] Workaround for the missing pitch information. if ( (smf->flags & MDL_PITCHFROMMOMENTUM) ) { - const double x = static_cast(spr->actor->velx); - const double y = static_cast(spr->actor->vely); - const double z = static_cast(spr->actor->velz); + const double x = static_cast(spr->actor->vel.x); + const double y = static_cast(spr->actor->vel.y); + const double z = static_cast(spr->actor->vel.z); // [BB] Calculate the pitch using spherical coordinates. if(z || x || y) pitch = float(atan( z/sqrt(x*x+y*y) ) / M_PI * 180); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 01bc1717d..d8b3c019f 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -517,7 +517,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) if (viewz >= thingpos.z - 2 * FRACUNIT && viewz <= thingpos.z + thing->height + 2 * FRACUNIT) { // exclude vertically moving objects from this check. - if (!(thing->velx == 0 && thing->vely == 0 && thing->velz != 0)) + if (!(thing->vel.x == 0 && thing->vel.y == 0 && thing->vel.z != 0)) { if (!gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, false)) { diff --git a/src/p_map.cpp b/src/p_map.cpp index 9dc666468..ca8b7b751 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2287,9 +2287,12 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, { fixed_t bestfrac = FIXED_MAX; spechit_t besthit; + int besthitnum; // find the portal nearest to the crossing actor - for (auto &spec : portalhit) + for (unsigned i = 0; i < portalhit.Size();i++) { + auto &spec = portalhit[i]; + line_t *ld = spec.line; if (ld->frontsector->PortalGroup != thing->Sector->PortalGroup) continue; // must be in the same group to be considered valid. @@ -2305,12 +2308,14 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, { besthit = spec; bestfrac = frac; + besthitnum = i; } } } if (bestfrac < FIXED_MAX) { + portalhit.Delete(besthitnum); line_t *ld = besthit.line; FLinePortal *port = ld->getPortal(); if (port->mType == PORTT_LINKED) @@ -2370,7 +2375,10 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, } R_AddInterpolationPoint(hit); } - if (port->mType == PORTT_LINKED) continue; + if (port->mType == PORTT_LINKED) + { + continue; + } } break; } diff --git a/src/portal.cpp b/src/portal.cpp index 63dfeafe6..013403ba5 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -933,7 +933,7 @@ void P_CreateLinkedPortals() TThinkerIterator it; AStackPoint *mo; TArray orgs; - int id = 0; + int id = 1; bool bogus = false; while ((mo = it.Next())) @@ -952,36 +952,32 @@ void P_CreateLinkedPortals() } } } - if (orgs.Size() == 0) + if (orgs.Size() != 0) { - // Create the 0->0 translation which is always needed. - Displacements.Create(1); - return; - } - for (int i = 0; i < numsectors; i++) - { - for (int j = 0; j < 2; j++) + for (int i = 0; i < numsectors; i++) { - AActor *box = sectors[i].SkyBoxes[j]; - if (box != NULL && box->special1 == SKYBOX_LINKEDPORTAL) + for (int j = 0; j < 2; j++) { - secplane_t &plane = j == 0 ? sectors[i].floorplane : sectors[i].ceilingplane; - if (plane.a || plane.b) + AActor *box = sectors[i].SkyBoxes[j]; + if (box != NULL && box->special1 == SKYBOX_LINKEDPORTAL) { - // The engine cannot deal with portals on a sloped plane. - sectors[i].SkyBoxes[j] = NULL; - Printf("Portal on %s of sector %d is sloped and will be disabled\n", j==0? "floor":"ceiling", i); + secplane_t &plane = j == 0 ? sectors[i].floorplane : sectors[i].ceilingplane; + if (plane.a || plane.b) + { + // The engine cannot deal with portals on a sloped plane. + sectors[i].SkyBoxes[j] = NULL; + Printf("Portal on %s of sector %d is sloped and will be disabled\n", j == 0 ? "floor" : "ceiling", i); + } } } } - } - // Group all sectors, starting at each portal origin. - id = 1; - for (unsigned i = 0; i < orgs.Size(); i++) - { - if (CollectSectors(id, orgs[i]->Sector)) id++; - if (CollectSectors(id, orgs[i]->Mate->Sector)) id++; + // Group all sectors, starting at each portal origin. + for (unsigned i = 0; i < orgs.Size(); i++) + { + if (CollectSectors(id, orgs[i]->Sector)) id++; + if (CollectSectors(id, orgs[i]->Mate->Sector)) id++; + } } for (unsigned i = 0; i < linePortals.Size(); i++) { From 1f64d7ee2281d02dfb9ae19064f8bc4aeb367b76 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 15 Mar 2016 11:30:34 +0200 Subject: [PATCH 0428/1509] Fixed wrong starting frame for wipe animation Menu graphics appeared in starting frame with hardware renderer only Software renderer was not affected as it reads pixels from front buffer instead of back buffer like OpenGL counterpart did See http://forum.drdteam.org/viewtopic.php?t=6857 --- src/gl/system/gl_wipe.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 30a996816..232be87a1 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -153,7 +153,11 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE); glFinish(); wipestartscreen->Bind(0, false, false); + GLint readbuffer = 0; + glGetIntegerv(GL_READ_BUFFER, &readbuffer); + glReadBuffer(GL_FRONT); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); + glReadBuffer(readbuffer); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); From b54b34a5122da241e79c577cdfab2f96287a295d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 21 Mar 2016 02:57:02 +0100 Subject: [PATCH 0429/1509] - adjustments for floating point changes. --- src/gl/data/gl_data.h | 1 + src/gl/data/gl_portaldata.cpp | 2 +- src/gl/dynlights/a_dynlight.cpp | 45 ++++++++++++----------- src/gl/dynlights/gl_dynlight.cpp | 4 +- src/gl/models/gl_models.cpp | 25 ++++++------- src/gl/renderer/gl_renderer.cpp | 2 +- src/gl/renderer/gl_renderer.h | 12 +++++- src/gl/scene/gl_flats.cpp | 4 +- src/gl/scene/gl_portal.cpp | 6 ++- src/gl/scene/gl_scene.cpp | 14 +++---- src/gl/scene/gl_sky.cpp | 2 +- src/gl/scene/gl_sprite.cpp | 49 ++++++++++++------------- src/gl/scene/gl_spritelight.cpp | 4 +- src/gl/scene/gl_walls_draw.cpp | 6 +-- src/gl/scene/gl_weapon.cpp | 15 +++++--- src/gl/stereo3d/gl_stereo3d.cpp | 2 + src/gl/stereo3d/gl_stereo_leftright.cpp | 1 + src/gl/utility/gl_clock.cpp | 2 +- src/gl/utility/gl_convert.h | 2 - 19 files changed, 107 insertions(+), 91 deletions(-) diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index 9618a5bef..d43134bce 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -3,6 +3,7 @@ #define __GLC_DATA_H #include "doomtype.h" +#include "vectors.h" struct GLRenderSettings { diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 77a93434b..a821ddd4f 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -361,7 +361,7 @@ static void CollectPortalSectors(FPortalMap &collection) ASkyViewpoint *SkyBox = barrier_cast(sec->SkyBoxes[j]); if (SkyBox != NULL && SkyBox->bAlways && SkyBox->Mate != NULL) { - FPortalID id = { SkyBox->X() - SkyBox->Mate->X(), SkyBox->Y() - SkyBox->Mate->Y() }; + FPortalID id = { SkyBox->_f_X() - SkyBox->Mate->_f_X(), SkyBox->_f_Y() - SkyBox->Mate->_f_Y() }; FPortalSectors &sss = collection[id]; FPortalSector ss = { sec, j }; diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index d1b71a38d..8aed91e50 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -35,6 +35,8 @@ ** */ +#include "gl/system/gl_system.h" + #include "templates.h" #include "m_random.h" #include "p_local.h" @@ -174,7 +176,7 @@ void ADynamicLight::PostBeginPlay() Activate (NULL); } - subsector = R_PointInSubsector(X(), Y()); + subsector = R_PointInSubsector(_f_X(), _f_Y()); } @@ -193,7 +195,7 @@ void ADynamicLight::Activate(AActor *activator) if (lighttype == PulseLight) { - float pulseTime = ANGLE_TO_FLOAT(this->angle) / TICRATE; + float pulseTime = Angles.Yaw.Degrees / TICRATE; m_lastUpdate = level.maptime; m_cycler.SetParams(float(m_intensity[1]), float(m_intensity[0]), pulseTime); @@ -257,7 +259,7 @@ void ADynamicLight::Tick() case FlickerLight: { BYTE rnd = randLight(); - float pct = ANGLE_TO_FLOAT(angle)/360.f; + float pct = Angles.Yaw.Degrees / 360.f; m_currentIntensity = float(m_intensity[rnd >= pct * 255]); break; @@ -270,7 +272,7 @@ void ADynamicLight::Tick() m_tickCount++; - if (m_tickCount > ANGLE_TO_FLOAT(angle)) + if (m_tickCount > Angles.Yaw.Degrees) { m_currentIntensity = float(m_intensity[0] + (amt * flickerRange)); m_tickCount = 0; @@ -283,7 +285,7 @@ void ADynamicLight::Tick() case ColorFlickerLight: { BYTE rnd = randLight(); - float pct = ANGLE_TO_FLOAT(angle)/360.f; + float pct = ANGLE2FLOAT(angle)/360.f; m_currentIntensity = m_intensity[rnd >= pct * 255]; break; @@ -296,7 +298,7 @@ void ADynamicLight::Tick() m_tickCount++; - if (m_tickCount > ANGLE_TO_FLOAT(angle)) + if (m_tickCount > ANGLE2FLOAT(angle)) { m_currentIntensity = m_intensity[0] + (amt * flickerRange); m_tickCount = 0; @@ -337,16 +339,16 @@ void ADynamicLight::Tick() //========================================================================== void ADynamicLight::UpdateLocation() { - fixed_t oldx=X(); - fixed_t oldy=Y(); - fixed_t oldradius=radius; + double oldx= X(); + double oldy= Y(); + double oldradius= radius; float intensity; if (IsActive()) { if (target) { - angle_t angle = target->angle>>ANGLETOFINESHIFT; + angle_t angle = target->_f_angle() >> ANGLETOFINESHIFT; fixedvec3 pos = target->Vec3Offset( FixedMul(m_offX, finecosine[angle]) + FixedMul(m_offZ, finesine[angle]), FixedMul(m_offX, finesine[angle]) - FixedMul(m_offZ, finecosine[angle]), @@ -363,7 +365,7 @@ void ADynamicLight::UpdateLocation() // The radius being used here is always the maximum possible with the // current settings. This avoids constant relinking of flickering lights - if (lighttype == FlickerLight || lighttype == RandomFlickerLight) + if (lighttype == FlickerLight || lighttype == RandomFlickerLight) { intensity = float(MAX(m_intensity[0], m_intensity[1])); } @@ -371,9 +373,9 @@ void ADynamicLight::UpdateLocation() { intensity = m_currentIntensity; } - radius = FLOAT2FIXED(intensity * 2.0f * gl_lights_size); + radius = intensity * 2.0f * gl_lights_size; - if (X()!=oldx || Y()!=oldy || radius!=oldradius) + if (X() != oldx || Y() != oldy || radius != oldradius) { //Update the light lists LinkLight(); @@ -599,9 +601,9 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe { line_t *other = subSec->firstline->linedef; AActor *sb = subSec->sector->SkyBoxes[sector_t::ceiling]; - if (sb->threshold < Z() + radius) + if (sb->specialf1 < Z() + radius) { - fixedvec2 refpos = { other->v1->x + other->dx / 2 + sb->scaleX, other->v1->y + other->dy / 2 + sb->scaleY }; + fixedvec2 refpos = { other->v1->x + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->y + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) }; subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y); if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius); } @@ -610,9 +612,9 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe { line_t *other = subSec->firstline->linedef; AActor *sb = subSec->sector->SkyBoxes[sector_t::floor]; - if (sb->threshold > Z() - radius) + if (sb->specialf1 > Z() - radius) { - fixedvec2 refpos = { other->v1->x + other->dx / 2 + sb->scaleX, other->v1->y + other->dy / 2 + sb->scaleY }; + fixedvec2 refpos = { other->v1->x + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->y + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) }; subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y); if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius); } @@ -652,10 +654,9 @@ void ADynamicLight::LinkLight() if (radius>0) { // passing in radius*radius allows us to do a distance check without any calls to sqrtf - subsector_t * subSec = R_PointInSubsector(X(), Y()); - float fradius = FIXED2FLOAT(radius); + subsector_t * subSec = R_PointInSubsector(_f_X(), _f_Y()); ::validcount++; - CollectWithinRadius(Pos(), subSec, fradius*fradius); + CollectWithinRadius(_f_Pos(), subSec, radius*radius); } @@ -760,8 +761,8 @@ CCMD(listlights) subsecs = 0; Printf("%s at (%f, %f, %f), color = 0x%02x%02x%02x, radius = %f ", dl->target? dl->target->GetClass()->TypeName.GetChars() : dl->GetClass()->TypeName.GetChars(), - FIXED2FLOAT(dl->X()), FIXED2FLOAT(dl->Y()), FIXED2FLOAT(dl->Z()), dl->args[LIGHT_RED], - dl->args[LIGHT_GREEN], dl->args[LIGHT_BLUE], FIXED2FLOAT(dl->radius)); + dl->X(), dl->Y(), dl->Z(), dl->args[LIGHT_RED], + dl->args[LIGHT_GREEN], dl->args[LIGHT_BLUE], dl->radius); i++; if (dl->target) diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index 4f126e11b..528e6c683 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -171,7 +171,7 @@ FLightDefaults::FLightDefaults(FName name, ELightType type) void FLightDefaults::ApplyProperties(ADynamicLight * light) const { light->lighttype = m_type; - light->angle = m_Angle; + light->Angles.Yaw = ANGLE2DBL(m_Angle); light->SetOffset(m_X, m_Y, m_Z); light->halo = m_halo; for (int a = 0; a < 3; a++) light->args[a] = clamp((int)(m_Args[a] * gl_lights_intensity), 0, 255); @@ -423,7 +423,7 @@ void gl_ParsePulseLight(FScanner &sc) break; case LIGHTTAG_INTERVAL: floatVal = gl_ParseFloat(sc); - defaults->SetAngle(FLOAT_TO_ANGLE(floatVal * TICRATE)); + defaults->SetAngle(FLOAT2ANGLE(floatVal * TICRATE)); break; case LIGHTTAG_SUBTRACTIVE: defaults->SetSubtractive(gl_ParseInt(sc) != 0); diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 508443e31..7776657db 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -523,7 +523,7 @@ void gl_InitModels() else if (sc.Compare("angleoffset")) { sc.MustGetFloat(); - smf.angleoffset = FLOAT_TO_ANGLE(sc.Float); + smf.angleoffset = FLOAT2ANGLE(sc.Float); } else if (sc.Compare("pitchoffset")) { @@ -854,20 +854,20 @@ void gl_RenderModel(GLSprite * spr) // y scale for a sprite means height, i.e. z in the world! - float scaleFactorX = FIXED2FLOAT(spr->actor->scaleX) * smf->xscale; - float scaleFactorY = FIXED2FLOAT(spr->actor->scaleX) * smf->yscale; - float scaleFactorZ = FIXED2FLOAT(spr->actor->scaleY) * smf->zscale; + float scaleFactorX = spr->actor->Scale.X * smf->xscale; + float scaleFactorY = spr->actor->Scale.X * smf->yscale; + float scaleFactorZ = spr->actor->Scale.Y * smf->zscale; float pitch = 0; float roll = 0; float rotateOffset = 0; - float angle = ANGLE_TO_FLOAT(spr->actor->angle); + float angle = spr->actor->Angles.Yaw.Degrees; // [BB] Workaround for the missing pitch information. if ( (smf->flags & MDL_PITCHFROMMOMENTUM) ) { - const double x = static_cast(spr->actor->vel.x); - const double y = static_cast(spr->actor->vel.y); - const double z = static_cast(spr->actor->vel.z); + const double x = spr->actor->Vel.X; + const double y = spr->actor->Vel.Y; + const double z = spr->actor->Vel.Z; // [BB] Calculate the pitch using spherical coordinates. if(z || x || y) pitch = float(atan( z/sqrt(x*x+y*y) ) / M_PI * 180); @@ -888,9 +888,8 @@ void gl_RenderModel(GLSprite * spr) // Added MDL_INHERITACTORPITCH and MDL_INHERITACTORROLL flags processing. // If both flags MDL_INHERITACTORPITCH and MDL_PITCHFROMMOMENTUM are set, the pitch sums up the actor pitch and the momentum vector pitch. - // This is rather crappy way to transfer fixet_t type into angle in degrees, but its works! - if(smf->flags & MDL_INHERITACTORPITCH) pitch += float(static_cast(spr->actor->pitch >> 16) / (1 << 13) * 45 + static_cast(spr->actor->pitch & 0x0000FFFF) / (1 << 29) * 45); - if(smf->flags & MDL_INHERITACTORROLL) roll += float(static_cast(spr->actor->roll >> 16) / (1 << 13) * 45 + static_cast(spr->actor->roll & 0x0000FFFF) / (1 << 29) * 45); + if(smf->flags & MDL_INHERITACTORPITCH) pitch += spr->actor->Angles.Pitch.Degrees; + if(smf->flags & MDL_INHERITACTORROLL) roll += spr->actor->Angles.Roll.Degrees; gl_RenderState.mModelMatrix.loadIdentity(); @@ -920,7 +919,7 @@ void gl_RenderModel(GLSprite * spr) gl_RenderState.mModelMatrix.translate(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); // 5) Applying model rotations. - gl_RenderState.mModelMatrix.rotate(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); + gl_RenderState.mModelMatrix.rotate(-ANGLE2FLOAT(smf->angleoffset), 0, 1, 0); gl_RenderState.mModelMatrix.rotate(smf->pitchoffset, 0, 0, 1); gl_RenderState.mModelMatrix.rotate(-smf->rolloffset, 1, 0, 0); @@ -983,7 +982,7 @@ void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy) gl_RenderState.mViewMatrix.rotate(90.f, 0, 1, 0); // Applying angleoffset, pitchoffset, rolloffset. - gl_RenderState.mViewMatrix.rotate(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); + gl_RenderState.mViewMatrix.rotate(-ANGLE2FLOAT(smf->angleoffset), 0, 1, 0); gl_RenderState.mViewMatrix.rotate(smf->pitchoffset, 0, 0, 1); gl_RenderState.mViewMatrix.rotate(-smf->rolloffset, 1, 0, 0); gl_RenderState.ApplyMatrices(); diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index dd4730687..9654f8998 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -88,7 +88,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mMirrorCount = 0; mPlaneMirrorCount = 0; mLightCount = 0; - mAngles = FRotator(0,0,0); + mAngles = FRotator(0.f, 0.f, 0.f); mViewVector = FVector2(0,0); mVBO = NULL; mSkyVBO = NULL; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index a388ced35..42bcb54cc 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -19,6 +19,16 @@ class GLPortal; class FLightBuffer; class FSamplerManager; +inline float DEG2RAD(float deg) +{ + return deg * float(M_PI / 180.0); +} + +inline float RAD2DEG(float deg) +{ + return deg * float(180. / M_PI); +} + enum SectorRenderFlags { // This is used to avoid creating too many drawinfos @@ -94,7 +104,7 @@ public: void DrawScene(bool toscreen = false); void DrawBlend(sector_t * viewsector); - void DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, bool hudModelStep, int OverrideShader, bool alphatexture); + void DrawPSprite (player_t * player,pspdef_t *psp,float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture); void DrawPlayerSprites(sector_t * viewsector, bool hudModelStep); void DrawTargeterSprites(); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 7b8209eb3..cffa1ee25 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -93,7 +93,7 @@ void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * glte { yscale1 = 0 - yscale1; } - float angle=-ANGLE_TO_FLOAT(secplane->angle); + float angle=-ANGLE2FLOAT(secplane->angle); float xscale2=64.f/gltexture->TextureWidth(); float yscale2=64.f/gltexture->TextureHeight(); @@ -143,7 +143,7 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli) // we must do the side check here because gl_SetupLight needs the correct plane orientation // which we don't have for Legacy-style 3D-floors fixed_t planeh = plane.plane.ZatPoint(light); - if (gl_lights_checkside && ((planehZ() && ceiling) || (planeh>light->Z() && !ceiling))) + if (gl_lights_checkside && ((planeh_f_Z() && ceiling) || (planeh>light->_f_Z() && !ceiling))) { node=node->nextLight; continue; diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 9dd9edc94..0ebf78b5c 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -659,7 +659,7 @@ void GLSkyboxPortal::DrawContents() viewx = viewpos.x; viewy = viewpos.y; viewz = viewpos.z; - viewangle += origin->PrevAngle + FixedMul(r_TicFrac, origin->angle - origin->PrevAngle); + viewangle += (origin->PrevAngles.Yaw + deltaangle(origin->PrevAngles.Yaw, origin->Angles.Yaw) * FIXED2DBL(r_TicFrac)).BAMs(); // Don't let the viewpoint be too close to a floor or ceiling fixed_t floorh = origin->Sector->floorplane.ZatPoint(origin); @@ -1003,7 +1003,9 @@ void GLLineToLinePortal::DrawContents() line_t *origin = glport->reference->mOrigin; P_TranslatePortalXY(origin, viewx, viewy); - P_TranslatePortalAngle(origin, viewangle); + DAngle va = ANGLE2DBL(viewangle); + P_TranslatePortalAngle(origin, va); + viewangle = va.BAMs(); P_TranslatePortalZ(origin, viewz); SaveMapSection(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 378929897..1821c1fdf 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -110,7 +110,7 @@ void gl_ParseDefs(); //----------------------------------------------------------------------------- angle_t FGLRenderer::FrustumAngle() { - float tilt= fabs(mAngles.Pitch); + float tilt= fabs(mAngles.Pitch.Degrees); // If the pitch is larger than this you can look all around at a FOV of 90° if (tilt>46.0f) return 0xffffffff; @@ -118,7 +118,7 @@ angle_t FGLRenderer::FrustumAngle() // ok, this is a gross hack that barely works... // but at least it doesn't overestimate too much... double floatangle=2.0+(45.0+((tilt/1.9)))*mCurrentFoV*48.0/BaseRatioSizes[WidescreenRatio][3]/90.0; - angle_t a1 = FLOAT_TO_ANGLE(floatangle); + angle_t a1 = FLOAT2ANGLE(floatangle); if (a1>=ANGLE_180) return 0xffffffff; return a1; } @@ -264,9 +264,9 @@ void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, boo float planemult = planemirror? -glset.pixelstretch : glset.pixelstretch; gl_RenderState.mViewMatrix.loadIdentity(); - gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll, 0.0f, 0.0f, 1.0f); - gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Pitch, 1.0f, 0.0f, 0.0f); - gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Yaw, 0.0f, mult, 0.0f); + gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll.Degrees, 0.0f, 0.0f, 1.0f); + gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Pitch.Degrees, 1.0f, 0.0f, 0.0f); + gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Yaw.Degrees, 0.0f, mult, 0.0f); gl_RenderState.mViewMatrix.translate(FIXED2FLOAT(viewx) * mult, -FIXED2FLOAT(viewz) * planemult , -FIXED2FLOAT(viewy)); gl_RenderState.mViewMatrix.scale(-mult, planemult, 1); } @@ -780,7 +780,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo double alen = sqrt(angx*angx + angy*angy); mAngles.Pitch = (float)RAD2DEG(asin(angy / alen)); - mAngles.Roll = (float)(camera->roll>>ANGLETOFINESHIFT)*360.0f/FINEANGLES; + mAngles.Roll.Degrees = camera->Angles.Roll.Degrees; // Scroll the sky mSky1Pos = (float)fmod(gl_frameMS * level.skyspeed1, 1024.f) * 90.f/256.f; @@ -817,7 +817,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo // SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper SetViewAngle(viewangle); // Stereo mode specific viewpoint adjustment - temporarily shifts global viewx, viewy, viewz - eye->GetViewShift(GLRenderer->mAngles.Yaw, viewShift); + eye->GetViewShift(GLRenderer->mAngles.Yaw.Degrees, viewShift); s3d::ScopedViewShifter viewShifter(viewShift); SetViewMatrix(viewx, viewy, viewz, false, false); gl_RenderState.ApplyMatrices(); diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index ca235c0e7..3cedd38c3 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -92,7 +92,7 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor) texture[0] = FMaterial::ValidateTexture(texno, false, true); if (!texture[0] || texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky; skytexno1 = texno; - x_offset[0] = ANGLE_TO_FLOAT(s->GetTextureXOffset(pos)); + x_offset[0] = ANGLE2FLOAT(s->GetTextureXOffset(pos)); y_offset = FIXED2FLOAT(s->GetTextureYOffset(pos)); mirrored = !l->args[2]; } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index d8b3c019f..35ac2dc2e 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -281,12 +281,12 @@ void GLSprite::Draw(int pass) float xcenter = (x1 + x2)*0.5; float ycenter = (y1 + y2)*0.5; float zcenter = (z1 + z2)*0.5; - float angleRad = DEG2RAD(270. - float(GLRenderer->mAngles.Yaw)); + float angleRad = ToRadians(270. - GLRenderer->mAngles.Yaw); Matrix3x4 mat; mat.MakeIdentity(); mat.Translate(xcenter, zcenter, ycenter); - mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch); + mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); mat.Translate(-xcenter, -zcenter, -ycenter); v1 = mat * Vector(x1, z1, y1); v2 = mat * Vector(x2, z1, y2); @@ -387,8 +387,8 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_ thing->IsKindOf(RUNTIME_CLASS(AInventory))) && (thing->flags&MF_ICECORPSE || !(thing->flags&MF_CORPSE))) || (gl_spriteclip == 3 && (smarterclip = true)) || gl_spriteclip > 1) { - float btm = 1000000.0f; - float top = -1000000.0f; + float btm = 100000000.0f; + float top = -100000000.0f; extsector_t::xfloor &x = thing->Sector->e->XFloor; if (x.ffloors.Size()) @@ -396,17 +396,17 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_ for (unsigned int i = 0; i < x.ffloors.Size(); i++) { F3DFloor * ff = x.ffloors[i]; - fixed_t floorh = ff->top.plane->ZatPoint(thingx, thingy); - fixed_t ceilingh = ff->bottom.plane->ZatPoint(thingx, thingy); + float floorh = FIXED2FLOAT(ff->top.plane->ZatPoint(thingx, thingy)); + float ceilingh = FIXED2FLOAT(ff->bottom.plane->ZatPoint(thingx, thingy)); if (floorh == thing->floorz) { - btm = FIXED2FLOAT(floorh); + btm = floorh; } if (ceilingh == thing->ceilingz) { - top = FIXED2FLOAT(ceilingh); + top = ceilingh; } - if (btm != 1000000.0f && top != -1000000.0f) + if (btm != 100000000.0f && top != -100000000.0f) { break; } @@ -415,14 +415,14 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_ else if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) { if (thing->flags2&MF2_ONMOBJ && thing->floorz == - thing->Sector->heightsec->floorplane.ZatPoint(thingx, thingy)) + FIXED2FLOAT(thing->Sector->heightsec->floorplane.ZatPoint(thingx, thingy))) { - btm = FIXED2FLOAT(thing->floorz); - top = FIXED2FLOAT(thing->ceilingz); + btm = thing->floorz; + top = thing->ceilingz; } } if (btm == 1000000.0f) - btm = FIXED2FLOAT(thing->Sector->floorplane.ZatPoint(thingx, thingy) - thing->floorclip); + btm = FIXED2FLOAT(thing->Sector->floorplane.ZatPoint(thing)) - thing->Floorclip; if (top == -1000000.0f) top = FIXED2FLOAT(thing->Sector->ceilingplane.ZatPoint(thingx, thingy)); @@ -492,11 +492,10 @@ void GLSprite::Process(AActor* thing,sector_t * sector) } int spritenum = thing->sprite; - fixed_t spritescaleX = thing->scaleX; - fixed_t spritescaleY = thing->scaleY; + DVector2 sprscale = thing->Scale; if (thing->player != NULL) { - P_CheckPlayerSprite(thing, spritenum, spritescaleX, spritescaleY); + P_CheckPlayerSprite(thing, spritenum, sprscale); } if (thing->renderflags & RF_INVISIBLE || !thing->RenderStyle.IsVisible(thing->alpha)) @@ -514,10 +513,10 @@ void GLSprite::Process(AActor* thing,sector_t * sector) // Too close to the camera. This doesn't look good if it is a sprite. if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy)<2*FRACUNIT) { - if (viewz >= thingpos.z - 2 * FRACUNIT && viewz <= thingpos.z + thing->height + 2 * FRACUNIT) + if (viewz >= thingpos.z - 2 * FRACUNIT && viewz <= thingpos.z + FLOAT2FIXED(thing->Height) + 2 * FRACUNIT) { // exclude vertically moving objects from this check. - if (!(thing->vel.x == 0 && thing->vel.y == 0 && thing->vel.z != 0)) + if (!thing->Vel.isZero()) { if (!gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, false)) { @@ -532,7 +531,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) { if (!(thing->flags7 & MF7_FLYCHEAT) && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) { - fixed_t clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius*2); + fixed_t clipdist = FLOAT2FIXED(clamp(thing->Speed, thing->target->radius, thing->target->radius*2)); if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy) < clipdist) return; } thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again. @@ -558,7 +557,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) x = FIXED2FLOAT(thingpos.x); - z = FIXED2FLOAT(thingpos.z-thing->floorclip); + z = FIXED2FLOAT(thingpos.z)-thing->Floorclip; y = FIXED2FLOAT(thingpos.y); // [RH] Make floatbobbing a renderer-only effect. @@ -574,7 +573,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) angle_t ang = R_PointToAngle(thingpos.x, thingpos.y); bool mirror; - FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, ang - thing->angle, &mirror); + FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, ang - thing->Angles.Yaw.BAMs(), &mirror); if (!patch.isValid()) return; int type = thing->renderflags & RF_SPRITETYPEMASK; gltexture = FMaterial::ValidateTexture(patch, (type == RF_FACESPRITE), false); @@ -595,7 +594,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) ur = gltexture->GetSpriteUL(); } - r.Scale(FIXED2FLOAT(spritescaleX), FIXED2FLOAT(spritescaleY)); + r.Scale(sprscale.X, sprscale.Y); float rightfac = -r.left; float leftfac = rightfac - r.width; @@ -603,7 +602,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) z1 = z - r.top; z2 = z1 - r.height; - float spriteheight = FIXED2FLOAT(spritescaleY) * r.height; + float spriteheight = sprscale.Y * r.height; // Tests show that this doesn't look good for many decorations and corpses if (spriteheight > 0 && gl_spriteclip > 0 && (thing->renderflags & RF_SPRITETYPEMASK) == RF_FACESPRITE) @@ -626,8 +625,8 @@ void GLSprite::Process(AActor* thing,sector_t * sector) break; case RF_WALLSPRITE: - viewvecX = FIXED2FLOAT(finecosine[thing->angle >> ANGLETOFINESHIFT]); - viewvecY = FIXED2FLOAT(finesine[thing->angle >> ANGLETOFINESHIFT]); + viewvecX = thing->Angles.Yaw.Cos(); + viewvecY = thing->Angles.Yaw.Sin(); x1 = x + viewvecY*leftfac; x2 = x + viewvecY*rightfac; diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index 9740448f4..7cfb0e908 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -80,7 +80,7 @@ void gl_SetDynSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsect if (!(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) { - float dist = FVector3(FIXED2FLOAT(x - light->X()), FIXED2FLOAT(y - light->Y()), FIXED2FLOAT(z - light->Z())).Length(); + float dist = FVector3(FIXED2FLOAT(x - light->_f_X()), FIXED2FLOAT(y - light->_f_Y()), FIXED2FLOAT(z - light->_f_Z())).Length(); radius = light->GetRadius() * gl_lights_size; if (dist < radius) @@ -117,7 +117,7 @@ void gl_SetDynSpriteLight(AActor *thing, particle_t *particle) { if (thing != NULL) { - gl_SetDynSpriteLight(thing, thing->X(), thing->Y(), thing->Z() + (thing->height >> 1), thing->subsector); + gl_SetDynSpriteLight(thing, thing->_f_X(), thing->_f_Y(), thing->_f_Z() + (thing->_f_height() >> 1), thing->subsector); } else if (particle != NULL) { diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 2b2e5bc6f..54e47386c 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -117,9 +117,9 @@ void GLWall::SetupLights() Vector fn, pos; - float x = FIXED2FLOAT(node->lightsource->X()); - float y = FIXED2FLOAT(node->lightsource->Y()); - float z = FIXED2FLOAT(node->lightsource->Z()); + float x = node->lightsource->X(); + float y = node->lightsource->Y(); + float z = node->lightsource->Z(); float dist = fabsf(p.DistToPoint(x, z, y)); float radius = (node->lightsource->GetRadius() * gl_lights_size); float scale = 1.0f / ((2.f * radius) - dist); diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 2d0f08511..102c30ff5 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -71,7 +71,7 @@ EXTERN_CVAR (Bool, r_deathcamera) // //========================================================================== -void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, bool hudModelStep, int OverrideShader, bool alphatexture) +void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp, float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture) { float fU1,fV1; float fU2,fV2; @@ -109,7 +109,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed // calculate edges of the shape scalex = xratio[WidescreenRatio] * vw / 320; - tx = FIXED2FLOAT(sx) - (160 - r.left); + tx = sx - (160 - r.left); x1 = tx * scalex + vw/2; if (x1 > vw) return; // off the right side x1 += viewwindowx; @@ -121,7 +121,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed // killough 12/98: fix psprite positioning problem - ftexturemid = 100.f - FIXED2FLOAT(sy) - r.top; + ftexturemid = 100.f - sy - r.top; AWeapon * wi=player->ReadyWeapon; if (wi && wi->YAdjust) @@ -188,7 +188,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) unsigned int i; pspdef_t *psp; int lightlevel=0; - fixed_t ofsx, ofsy; + float ofsx, ofsy; FColormap cm; sector_t * fakesec, fs; AActor * playermo=players[consoleplayer].camera; @@ -202,7 +202,10 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) (r_deathcamera && camera->health <= 0)) return; - P_BobWeapon (player, &player->psprites[ps_weapon], &ofsx, &ofsy); + fixed_t ox, oy; + P_BobWeapon (player, &player->psprites[ps_weapon], &ox, &oy); + ofsx = FIXED2FLOAT(ox); + ofsy = FIXED2FLOAT(oy); // check for fullbright if (player->fixedcolormap==NOFIXEDCOLORMAP) @@ -250,7 +253,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) lightlevel = (1.0 - min_L) * 255; } - lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->X(), playermo->Y(), playermo->Z()); + lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->_f_X(), playermo->_f_Y(), playermo->_f_Z()); // calculate colormap for weapon sprites if (viewsector->e->XFloor.ffloors.Size() && !glset.nocoloredspritelighting) diff --git a/src/gl/stereo3d/gl_stereo3d.cpp b/src/gl/stereo3d/gl_stereo3d.cpp index ed16d9db5..d7f5183d0 100644 --- a/src/gl/stereo3d/gl_stereo3d.cpp +++ b/src/gl/stereo3d/gl_stereo3d.cpp @@ -33,7 +33,9 @@ ** */ +#include "gl/system/gl_system.h" #include "gl/stereo3d/gl_stereo3d.h" +#include "gl/renderer/gl_renderer.h" #include "vectors.h" // RAD2DEG #include "doomtype.h" // M_PI diff --git a/src/gl/stereo3d/gl_stereo_leftright.cpp b/src/gl/stereo3d/gl_stereo_leftright.cpp index bf9fea09c..6b7f5fe80 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.cpp +++ b/src/gl/stereo3d/gl_stereo_leftright.cpp @@ -37,6 +37,7 @@ #include "vectors.h" // RAD2DEG #include "doomtype.h" // M_PI #include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" #include EXTERN_CVAR(Float, vr_screendist) diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp index 545607ea1..ac83811fa 100644 --- a/src/gl/utility/gl_clock.cpp +++ b/src/gl/utility/gl_clock.cpp @@ -185,7 +185,7 @@ void CheckBench() compose.Format("Map %s: \"%s\",\nx = %1.4f, y = %1.4f, z = %1.4f, angle = %1.4f, pitch = %1.4f\n", level.MapName.GetChars(), level.LevelName.GetChars(), FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz), - ANGLE_TO_FLOAT(viewangle), ANGLE_TO_FLOAT(viewpitch)); + ANGLE2FLOAT(viewangle), ANGLE2FLOAT(viewpitch)); AppendRenderStats(compose); AppendRenderTimes(compose); diff --git a/src/gl/utility/gl_convert.h b/src/gl/utility/gl_convert.h index 7f99412fa..61eede6b4 100644 --- a/src/gl/utility/gl_convert.h +++ b/src/gl/utility/gl_convert.h @@ -3,7 +3,5 @@ #define __GLC_CONVERT #include "m_fixed.h" -#define ANGLE_TO_FLOAT(ang) ((float)((ang) * 180. / ANGLE_180)) -#define FLOAT_TO_ANGLE(ang) xs_RoundToUInt((ang) / 180. * ANGLE_180) #endif \ No newline at end of file From bd7df76059239151f259058f8e1e41fe5dd43e58 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 22 Mar 2016 12:56:20 +0100 Subject: [PATCH 0430/1509] - fixed compilation of AActor::alpha --- src/gl/scene/gl_sprite.cpp | 4 ++-- src/gl/scene/gl_weapon.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 35ac2dc2e..ccc069f89 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -498,7 +498,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) P_CheckPlayerSprite(thing, spritenum, sprscale); } - if (thing->renderflags & RF_INVISIBLE || !thing->RenderStyle.IsVisible(thing->alpha)) + if (thing->renderflags & RF_INVISIBLE || !thing->RenderStyle.IsVisible(thing->Alpha)) { if (!(thing->flags & MF_STEALTH) || !gl_fixedcolormap || !gl_enhanced_nightvision) return; @@ -713,7 +713,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) translation=thing->Translation; OverrideShader = -1; - trans = FIXED2FLOAT(thing->alpha); + trans = thing->Alpha; hw_styleflags = STYLEHW_Normal; if (RenderStyle.BlendOp >= STYLEOP_Fuzz && RenderStyle.BlendOp <= STYLEOP_FuzzOrRevSub) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 102c30ff5..c8a9889eb 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -300,7 +300,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) visstyle_t vis; vis.RenderStyle=playermo->RenderStyle; - vis.alpha=playermo->alpha; + vis.alpha=playermo->Alpha; vis.colormap = NULL; if (playermo->Inventory) { From eadecaf407c0670177c19cc8fc0b580aad3b4b6a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 22 Mar 2016 23:19:21 +0100 Subject: [PATCH 0431/1509] - adjustments to GL renderer for decal and alpha changes. - handle portals in sprite lighting, but do not use the playsim's utility functions for efficiency. --- src/gl/renderer/gl_renderer.cpp | 2 +- src/gl/scene/gl_decal.cpp | 36 ++++++++++++++++----------------- src/gl/scene/gl_spritelight.cpp | 29 ++++++++++++++++++++++---- src/gl/scene/gl_wall.h | 2 +- src/gl/scene/gl_weapon.cpp | 4 ++-- 5 files changed, 47 insertions(+), 26 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 9654f8998..da6a8e54c 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -375,7 +375,7 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) { color = PalEntry(light, light, light); } - color.a = Scale(parms.alpha, 255, FRACUNIT); + color.a = (BYTE)(parms.Alpha * 255); // scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates int btm = (SCREENHEIGHT - screen->GetHeight()) / 2; diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index de175fffd..0bda67191 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -71,7 +71,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) line_t * line=seg->linedef; side_t * side=seg->sidedef; int i; - fixed_t zpos; + float zpos; int light; int rel; float a; @@ -129,33 +129,33 @@ void GLWall::DrawDecal(DBaseDecal *decal) if (type!=RENDERWALL_TOP) return; if (line->flags & ML_DONTPEGTOP) { - zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling); + zpos = decal->Z + frontsector->GetPlaneTexZF(sector_t::ceiling); } else { - zpos = decal->Z + seg->backsector->GetPlaneTexZ(sector_t::ceiling); + zpos = decal->Z + seg->backsector->GetPlaneTexZF(sector_t::ceiling); } break; case RF_RELLOWER: if (type!=RENDERWALL_BOTTOM) return; if (line->flags & ML_DONTPEGBOTTOM) { - zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling); + zpos = decal->Z + frontsector->GetPlaneTexZF(sector_t::ceiling); } else { - zpos = decal->Z + seg->backsector->GetPlaneTexZ(sector_t::floor); + zpos = decal->Z + seg->backsector->GetPlaneTexZF(sector_t::floor); } break; case RF_RELMID: if (type==RENDERWALL_TOP || type==RENDERWALL_BOTTOM) return; if (line->flags & ML_DONTPEGBOTTOM) { - zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::floor); + zpos = decal->Z + frontsector->GetPlaneTexZF(sector_t::floor); } else { - zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling); + zpos = decal->Z + frontsector->GetPlaneTexZF(sector_t::ceiling); } } @@ -179,20 +179,20 @@ void GLWall::DrawDecal(DBaseDecal *decal) - a = FIXED2FLOAT(decal->Alpha); + a = decal->Alpha; // now clip the decal to the actual polygon - float decalwidth = tex->TextureWidth() * FIXED2FLOAT(decal->ScaleX); - float decalheight= tex->TextureHeight() * FIXED2FLOAT(decal->ScaleY); - float decallefto = tex->GetLeftOffset() * FIXED2FLOAT(decal->ScaleX); - float decaltopo = tex->GetTopOffset() * FIXED2FLOAT(decal->ScaleY); + float decalwidth = tex->TextureWidth() * decal->ScaleX; + float decalheight= tex->TextureHeight() * decal->ScaleY; + float decallefto = tex->GetLeftOffset() * decal->ScaleX; + float decaltopo = tex->GetTopOffset() * decal->ScaleY; float leftedge = glseg.fracleft * side->TexelLength; float linelength = glseg.fracright * side->TexelLength - leftedge; // texel index of the decal's left edge - float decalpixpos = (float)side->TexelLength * decal->LeftDistance / (1<<30) - (flipx? decalwidth-decallefto : decallefto) - leftedge; + float decalpixpos = (float)side->TexelLength * decal->LeftDistance - (flipx? decalwidth-decallefto : decallefto) - leftedge; float left,right; float lefttex,righttex; @@ -232,14 +232,14 @@ void GLWall::DrawDecal(DBaseDecal *decal) dv[3].x=dv[2].x=glseg.x1+vx*right; dv[3].y=dv[2].y=glseg.y1+vy*right; - zpos+= FRACUNIT*(flipy? decalheight-decaltopo : decaltopo); + zpos+= (flipy? decalheight-decaltopo : decaltopo); - dv[1].z=dv[2].z = FIXED2FLOAT(zpos); + dv[1].z=dv[2].z = zpos; dv[0].z=dv[3].z = dv[1].z - decalheight; dv[1].v=dv[2].v = tex->GetVT(); - dv[1].u=dv[0].u = tex->GetU(lefttex / FIXED2FLOAT(decal->ScaleX)); - dv[3].u=dv[2].u = tex->GetU(righttex / FIXED2FLOAT(decal->ScaleX)); + dv[1].u=dv[0].u = tex->GetU(lefttex / decal->ScaleX); + dv[3].u=dv[2].u = tex->GetU(righttex / decal->ScaleX); dv[0].v=dv[3].v = tex->GetVB(); @@ -297,7 +297,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap && gl_light_sprites) { // Note: This should be replaced with proper shader based lighting. - fixed_t x, y; + double x, y; decal->GetXY(seg->sidedef, x, y); gl_SetDynSpriteLight(NULL, x, y, zpos, sub); } diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index 7cfb0e908..2afc67524 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -63,7 +63,7 @@ // //========================================================================== -void gl_SetDynSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsector_t * subsec) +void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t * subsec) { ADynamicLight *light; float frac, lr, lg, lb; @@ -80,7 +80,28 @@ void gl_SetDynSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsect if (!(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) { - float dist = FVector3(FIXED2FLOAT(x - light->_f_X()), FIXED2FLOAT(y - light->_f_Y()), FIXED2FLOAT(z - light->_f_Z())).Length(); + float dist; + + // This is a performance critical section of code where we cannot afford to let the compiler decide whether to inline the function or not. + // This will do the calculations explicitly rather than calling one of AActor's utility functions. + if (Displacements.size > 0) + { + int fromgroup = light->Sector->PortalGroup; + int togroup = subsec->sector->PortalGroup; + if (fromgroup == togroup || fromgroup == 0 || togroup == 0) goto direct; + + fixedvec2 offset = Displacements.getOffset(fromgroup, togroup); + dist = FVector3(x - light->X() - FIXED2FLOAT(offset.x), y - light->Y() - FIXED2FLOAT(offset.y), z - light->Z()).LengthSquared(); + } + else + { + direct: + dist = FVector3(x - light->X(), y - light->Y(), z - light->Z()).LengthSquared(); + } + // This is to avoid calling the software-implemented sqrt function which gets used by FVector3::Length(). + // With fast math on in this module this call will be mapped to a machine instruction on most platforms. + dist = sqrtf(dist); + radius = light->GetRadius() * gl_lights_size; if (dist < radius) @@ -117,10 +138,10 @@ void gl_SetDynSpriteLight(AActor *thing, particle_t *particle) { if (thing != NULL) { - gl_SetDynSpriteLight(thing, thing->_f_X(), thing->_f_Y(), thing->_f_Z() + (thing->_f_height() >> 1), thing->subsector); + gl_SetDynSpriteLight(thing, thing->X(), thing->Y(), thing->Center(), thing->subsector); } else if (particle != NULL) { - gl_SetDynSpriteLight(NULL, particle->x, particle->y, particle->z, particle->subsector); + gl_SetDynSpriteLight(NULL, FIXED2FLOAT(particle->x), FIXED2FLOAT(particle->y), FIXED2FLOAT(particle->z), particle->subsector); } } diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index ce03267a3..0069fe863 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -363,7 +363,7 @@ inline float Dist2(float x1,float y1,float x2,float y2) // Light + color -void gl_SetDynSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsector_t *subsec); +void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t *subsec); void gl_SetDynSpriteLight(AActor *actor, particle_t *particle); #endif diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index c8a9889eb..5fa57db50 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -300,7 +300,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) visstyle_t vis; vis.RenderStyle=playermo->RenderStyle; - vis.alpha=playermo->Alpha; + vis.Alpha=playermo->Alpha; vis.colormap = NULL; if (playermo->Inventory) { @@ -350,7 +350,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) } else if (trans == 0.f) { - trans = FIXED2FLOAT(vis.alpha); + trans = vis.Alpha; } // now draw the different layers of the weapon From f62c988a0e6339bc38685a88add39383abcb813a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 12:47:08 +0100 Subject: [PATCH 0432/1509] - adjustments for next update. --- src/gl/scene/gl_weapon.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 5fa57db50..c80fa2c8f 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -124,16 +124,16 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp, float sx, float ftexturemid = 100.f - sy - r.top; AWeapon * wi=player->ReadyWeapon; - if (wi && wi->YAdjust) + if (wi && wi->YAdjust != 0) { - float fYAd = FIXED2FLOAT(wi->YAdjust); + float fYAd = wi->YAdjust; if (screenblocks >= 11) { ftexturemid -= fYAd; } else if (!st_scale) { - ftexturemid -= FIXED2FLOAT(StatusBar->GetDisplacement ()) * fYAd; + ftexturemid -= StatusBar->GetDisplacement () * fYAd; } } From 379d5bc0c5112e0f23ac4b842f2281219acd3f05 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 13:38:37 +0100 Subject: [PATCH 0433/1509] - fixed some issues with dynamic lights caused by the floatification changes --- src/gl/dynlights/a_dynlight.cpp | 28 +++++++++++++--------------- src/gl/dynlights/gl_dynlight.cpp | 29 +++++++++++++++-------------- src/gl/dynlights/gl_dynlight.h | 4 ++-- src/gl/scene/gl_weapon.cpp | 5 +---- src/p_spec.cpp | 2 +- 5 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 8aed91e50..b19e1924a 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -285,7 +285,7 @@ void ADynamicLight::Tick() case ColorFlickerLight: { BYTE rnd = randLight(); - float pct = ANGLE2FLOAT(angle)/360.f; + float pct = Angles.Yaw.Degrees/360.f; m_currentIntensity = m_intensity[rnd >= pct * 255]; break; @@ -298,7 +298,7 @@ void ADynamicLight::Tick() m_tickCount++; - if (m_tickCount > ANGLE2FLOAT(angle)) + if (m_tickCount > Angles.Yaw.Degrees) { m_currentIntensity = m_intensity[0] + (amt * flickerRange); m_tickCount = 0; @@ -348,16 +348,16 @@ void ADynamicLight::UpdateLocation() { if (target) { - angle_t angle = target->_f_angle() >> ANGLETOFINESHIFT; - fixedvec3 pos = target->Vec3Offset( - FixedMul(m_offX, finecosine[angle]) + FixedMul(m_offZ, finesine[angle]), - FixedMul(m_offX, finesine[angle]) - FixedMul(m_offZ, finecosine[angle]), - m_offY + target->GetBobOffset()); + DAngle angle = target->Angles.Yaw; + double s = angle.Sin(); + double c = angle.Cos(); + + DVector3 pos = target->Vec3Offset(m_off.X * c + m_off.Y * s, m_off.X * s - m_off.Y * c, m_off.Z + target->GetBobOffset()); SetXYZ(pos); // attached lights do not need to go into the regular blockmap - PrevX = pos.x; - PrevY = pos.y; - PrevZ = pos.z; - subsector = R_PointInSubsector(pos.x, pos.y); + PrevX = target->_f_X(); + PrevY = target->_f_Y(); + PrevZ = target->_f_Z(); + subsector = R_PointInSubsector(target->_f_X(), target->_f_Y()); Sector = subsector->sector; } @@ -402,11 +402,9 @@ void ADynamicLight::SetOrigin(fixed_t x, fixed_t y, fixed_t z, bool moving) // //========================================================================== -void ADynamicLight::SetOffset(fixed_t x, fixed_t y, fixed_t z) +void ADynamicLight::SetOffset(const DVector3 &pos) { - m_offX = x; - m_offY = y; - m_offZ = z; + m_off = pos; UpdateLocation(); } diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index 528e6c683..d51c4315b 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -129,10 +129,10 @@ public: void ApplyProperties(ADynamicLight * light) const; FName GetName() const { return m_Name; } - void SetAngle(angle_t angle) { m_Angle = angle; } + void SetParameter(double p) { m_Param = p; } void SetArg(int arg, BYTE val) { m_Args[arg] = val; } BYTE GetArg(int arg) { return m_Args[arg]; } - void SetOffset(float* ft) { m_X = FLOAT2FIXED(ft[0]); m_Y = FLOAT2FIXED(ft[1]); m_Z = FLOAT2FIXED(ft[2]); } + void SetOffset(float* ft) { m_Pos.X = ft[0]; m_Pos.Z = ft[1]; m_Pos.Y = ft[2]; } void SetSubtractive(bool subtract) { m_subtractive = subtract; } void SetAdditive(bool add) { m_additive = add; } void SetDontLightSelf(bool add) { m_dontlightself = add; } @@ -140,8 +140,8 @@ public: protected: FName m_Name; unsigned char m_Args[5]; - angle_t m_Angle; - fixed_t m_X, m_Y, m_Z; + double m_Param; + DVector3 m_Pos; ELightType m_type; bool m_subtractive, m_additive, m_halo, m_dontlightself; }; @@ -159,8 +159,9 @@ FLightDefaults::FLightDefaults(FName name, ELightType type) m_Name = name; m_type = type; - m_X = m_Y = m_Z = 0; + m_Pos.Zero(); memset(m_Args, 0, 5); + m_Param = 0; m_subtractive = false; m_additive = false; @@ -171,16 +172,16 @@ FLightDefaults::FLightDefaults(FName name, ELightType type) void FLightDefaults::ApplyProperties(ADynamicLight * light) const { light->lighttype = m_type; - light->Angles.Yaw = ANGLE2DBL(m_Angle); - light->SetOffset(m_X, m_Y, m_Z); + light->Angles.Yaw.Degrees = m_Param; + light->SetOffset(m_Pos); light->halo = m_halo; for (int a = 0; a < 3; a++) light->args[a] = clamp((int)(m_Args[a] * gl_lights_intensity), 0, 255); light->m_intensity[0] = int(m_Args[LIGHT_INTENSITY]); light->m_intensity[1] = int(m_Args[LIGHT_SECONDARY_INTENSITY]); - light->flags4&=~(MF4_ADDITIVE|MF4_SUBTRACTIVE|MF4_DONTLIGHTSELF); - if (m_subtractive) light->flags4|=MF4_SUBTRACTIVE; - if (m_additive) light->flags4|=MF4_ADDITIVE; - if (m_dontlightself) light->flags4|=MF4_DONTLIGHTSELF; + light->flags4 &= ~(MF4_ADDITIVE | MF4_SUBTRACTIVE | MF4_DONTLIGHTSELF); + if (m_subtractive) light->flags4 |= MF4_SUBTRACTIVE; + if (m_additive) light->flags4 |= MF4_ADDITIVE; + if (m_dontlightself) light->flags4 |= MF4_DONTLIGHTSELF; } @@ -423,7 +424,7 @@ void gl_ParsePulseLight(FScanner &sc) break; case LIGHTTAG_INTERVAL: floatVal = gl_ParseFloat(sc); - defaults->SetAngle(FLOAT2ANGLE(floatVal * TICRATE)); + defaults->SetParameter(floatVal * TICRATE); break; case LIGHTTAG_SUBTRACTIVE: defaults->SetSubtractive(gl_ParseInt(sc) != 0); @@ -502,7 +503,7 @@ void gl_ParseFlickerLight(FScanner &sc) break; case LIGHTTAG_CHANCE: floatVal = gl_ParseFloat(sc); - defaults->SetAngle((angle_t)(floatVal * ANGLE_MAX)); + defaults->SetParameter(floatVal*360.); break; case LIGHTTAG_SUBTRACTIVE: defaults->SetSubtractive(gl_ParseInt(sc) != 0); @@ -581,7 +582,7 @@ void gl_ParseFlickerLight2(FScanner &sc) break; case LIGHTTAG_INTERVAL: floatVal = gl_ParseFloat(sc); - defaults->SetAngle((angle_t)(floatVal * ANGLE_MAX)); + defaults->SetParameter(floatVal * 360.); break; case LIGHTTAG_SUBTRACTIVE: defaults->SetSubtractive(gl_ParseInt(sc) != 0); diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index 3e263c895..7d98154fe 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -87,7 +87,7 @@ public: void Destroy(); void Activate(AActor *activator); void Deactivate(AActor *activator); - void SetOffset(fixed_t x, fixed_t y, fixed_t z); + void SetOffset(const DVector3 &pos); void UpdateLocation(); bool IsOwned() const { return owned; } bool IsActive() const { return !(flags2&MF2_DORMANT); } @@ -103,7 +103,7 @@ private: void CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSec, float radius); protected: - fixed_t m_offX, m_offY, m_offZ; + DVector3 m_off; float m_currentIntensity; int m_tickCount; unsigned int m_lastUpdate; diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index c80fa2c8f..0712ae328 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -202,10 +202,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) (r_deathcamera && camera->health <= 0)) return; - fixed_t ox, oy; - P_BobWeapon (player, &player->psprites[ps_weapon], &ox, &oy); - ofsx = FIXED2FLOAT(ox); - ofsy = FIXED2FLOAT(oy); + P_BobWeapon (player, &player->psprites[ps_weapon], &ofsx, &ofsy); // check for fullbright if (player->fixedcolormap==NOFIXEDCOLORMAP) diff --git a/src/p_spec.cpp b/src/p_spec.cpp index f006db682..97fbcb8bc 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -1469,7 +1469,7 @@ void P_SpawnSpecials (void) else if (lines[i].args[1] == 3 || lines[i].args[1] == 4) { line_t *line = &lines[i]; - ASkyViewpoint *origin = Spawn(0, 0, 0, NO_REPLACE); + ASkyViewpoint *origin = Spawn(); origin->Sector = line->frontsector; origin->special1 = line->args[1] == 3? SKYBOX_PLANE:SKYBOX_HORIZON; From 37bb81685056882d2de50d88195e0fda643d60e0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 16:10:17 +0100 Subject: [PATCH 0434/1509] - some adjustments for voxels. --- src/gl/models/gl_models.cpp | 10 +++++----- src/gl/models/gl_models.h | 2 +- src/gl/models/gl_voxels.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 7776657db..a33a91604 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -421,8 +421,8 @@ void gl_InitModels() memset(&smf, 0, sizeof(smf)); smf.models[0] = md; smf.skins[0] = md->GetPaletteTexture(); - smf.xscale = smf.yscale = smf.zscale = FIXED2FLOAT(VoxelDefs[i]->Scale); - smf.angleoffset = VoxelDefs[i]->AngleOffset; + smf.xscale = smf.yscale = smf.zscale = VoxelDefs[i]->Scale; + smf.angleoffset = VoxelDefs[i]->AngleOffset.Degrees; if (VoxelDefs[i]->PlacedSpin != 0) { smf.yrotate = 1.f; @@ -523,7 +523,7 @@ void gl_InitModels() else if (sc.Compare("angleoffset")) { sc.MustGetFloat(); - smf.angleoffset = FLOAT2ANGLE(sc.Float); + smf.angleoffset = sc.Float; } else if (sc.Compare("pitchoffset")) { @@ -919,7 +919,7 @@ void gl_RenderModel(GLSprite * spr) gl_RenderState.mModelMatrix.translate(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); // 5) Applying model rotations. - gl_RenderState.mModelMatrix.rotate(-ANGLE2FLOAT(smf->angleoffset), 0, 1, 0); + gl_RenderState.mModelMatrix.rotate(-smf->angleoffset, 0, 1, 0); gl_RenderState.mModelMatrix.rotate(smf->pitchoffset, 0, 0, 1); gl_RenderState.mModelMatrix.rotate(-smf->rolloffset, 1, 0, 0); @@ -982,7 +982,7 @@ void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy) gl_RenderState.mViewMatrix.rotate(90.f, 0, 1, 0); // Applying angleoffset, pitchoffset, rolloffset. - gl_RenderState.mViewMatrix.rotate(-ANGLE2FLOAT(smf->angleoffset), 0, 1, 0); + gl_RenderState.mViewMatrix.rotate(-smf->angleoffset, 0, 1, 0); gl_RenderState.mViewMatrix.rotate(smf->pitchoffset, 0, 0, 1); gl_RenderState.mViewMatrix.rotate(-smf->rolloffset, 1, 0, 0); gl_RenderState.ApplyMatrices(); diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index af7af7c0f..0159d2667 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -354,7 +354,7 @@ struct FSpriteModelFrame short frame; FState * state; // for later! int hashnext; - angle_t angleoffset; + float angleoffset; // added pithoffset, rolloffset. float pitchoffset, rolloffset; // I don't want to bother with type transformations, so I made this variables float. }; diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index c092f9dd7..3a34117b9 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -253,9 +253,9 @@ unsigned int FVoxelModel::AddVertex(FModelVertex &vert, FVoxelMap &check) void FVoxelModel::AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3, int x4, int y4, int z4, BYTE col, FVoxelMap &check) { - float PivotX = mVoxel->Mips[0].PivotX / 256.f; - float PivotY = mVoxel->Mips[0].PivotY / 256.f; - float PivotZ = mVoxel->Mips[0].PivotZ / 256.f; + float PivotX = mVoxel->Mips[0].Pivot.X; + float PivotY = mVoxel->Mips[0].Pivot.Y; + float PivotZ = mVoxel->Mips[0].Pivot.Z; int h = mVoxel->Mips[0].SizeZ; FModelVertex vert; unsigned int indx[4]; From 59406c12730dc22feb113861fc28db569f77f5f5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 16:40:15 +0100 Subject: [PATCH 0435/1509] - adjust. --- src/gl/renderer/gl_renderer.cpp | 9 ++++----- src/gl/renderer/gl_renderer.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index da6a8e54c..5c6766228 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -569,7 +569,7 @@ void FGLRenderer::Clear(int left, int top, int right, int bottom, int palcolor, void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, - angle_t rotation, FDynamicColormap *colormap, int lightlevel) + DAngle rotation, FDynamicColormap *colormap, int lightlevel) { if (npoints < 3) { // This is no polygon. @@ -597,11 +597,10 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); int i; - float rot = float(rotation * M_PI / float(1u << 31)); - bool dorotate = rot != 0; + bool dorotate = rotation != 0; - float cosrot = cos(rot); - float sinrot = sin(rot); + float cosrot = cos(ToRadians(rotation)); + float sinrot = sin(ToRadians(rotation)); //float yoffs = GatheringWipeScreen ? 0 : LBOffset; float uscale = float(1.f / (texture->GetScaledWidth() * scalex)); diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 42bcb54cc..72f5d3171 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -140,7 +140,7 @@ public: void FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, - angle_t rotation, FDynamicColormap *colormap, int lightlevel); + DAngle rotation, FDynamicColormap *colormap, int lightlevel); }; // Global functions. Make them members of GLRenderer later? From b958a5d74852c5eb59c45feef26ac9d4d6a5b6b8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 25 Mar 2016 15:14:09 +0100 Subject: [PATCH 0436/1509] - adjustments in GL code. --- src/gl/dynlights/a_dynlight.cpp | 6 +++--- src/gl/dynlights/gl_dynlight1.cpp | 2 +- src/gl/system/gl_framebuffer.cpp | 2 +- src/gl/system/gl_framebuffer.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index b19e1924a..91292d350 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -575,7 +575,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe if (other->validcount != ::validcount) { subsector_t *othersub = R_PointInSubsector(other->v1->x + other->dx / 2, other->v1->y + other->dy / 2); - if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(other), othersub, radius); + if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(other), othersub, radius); } } } @@ -603,7 +603,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe { fixedvec2 refpos = { other->v1->x + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->y + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) }; subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y); - if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius); + if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(othersub->sector), othersub, radius); } } if (!subSec->sector->PortalBlocksSight(sector_t::floor)) @@ -614,7 +614,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe { fixedvec2 refpos = { other->v1->x + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->y + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) }; subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y); - if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius); + if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(othersub->sector), othersub, radius); } } } diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index b57882dcf..926b75aae 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -90,7 +90,7 @@ bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, bo Vector fn, pos; int i = 0; - fixedvec3 lpos = light->PosRelative(group); + fixedvec3 lpos = light->_f_PosRelative(group); float x = FIXED2FLOAT(lpos.x); float y = FIXED2FLOAT(lpos.y); float z = FIXED2FLOAT(lpos.z); diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 7a3fef1a3..8d87d7d6a 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -485,7 +485,7 @@ void OpenGLFrameBuffer::Clear(int left, int top, int right, int bottom, int palc void OpenGLFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, - angle_t rotation, FDynamicColormap *colormap, int lightlevel) + DAngle rotation, FDynamicColormap *colormap, int lightlevel) { if (GLRenderer != NULL) { diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index c2a4fc277..501d40925 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -68,7 +68,7 @@ public: void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, - angle_t rotation, FDynamicColormap *colormap, int lightlevel); + DAngle rotation, FDynamicColormap *colormap, int lightlevel); FNativePalette *CreatePalette(FRemapTable *remap); From a87c292f10fb4629cb4cab277839c9c77de09935 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 29 Mar 2016 11:26:33 +0200 Subject: [PATCH 0437/1509] - adjustments to GL code for texture scale and vertex coordinate access. --- src/gl/data/gl_data.cpp | 4 ++-- src/gl/data/gl_portaldata.cpp | 14 ++++++------- src/gl/data/gl_setup.cpp | 8 ++++---- src/gl/dynlights/a_dynlight.cpp | 36 ++++++++++++++++----------------- src/gl/dynlights/gl_dynlight.h | 2 +- src/gl/scene/gl_drawinfo.cpp | 16 +++++++-------- src/gl/scene/gl_portal.cpp | 32 ++++++++++++++--------------- src/gl/scene/gl_sprite.cpp | 26 ++++++++++++------------ src/gl/scene/gl_spritelight.cpp | 4 ++-- src/gl/scene/gl_walls.cpp | 30 +++++++++++++-------------- src/gl/textures/gl_hqresize.cpp | 2 +- src/gl/textures/gl_material.cpp | 16 +++++++-------- src/gl/textures/gl_material.h | 12 +++++------ 13 files changed, 100 insertions(+), 102 deletions(-) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index d69d491f8..df5d0d35f 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -512,13 +512,13 @@ CCMD(dumpgeometry) if (seg->linedef) { Printf(PRINT_LOG, " (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, linedef %d, side %d", - FIXED2FLOAT(seg->v1->x), FIXED2FLOAT(seg->v1->y), FIXED2FLOAT(seg->v2->x), FIXED2FLOAT(seg->v2->y), + seg->v1->fX(), seg->v1->fY(), seg->v2->fX(), seg->v2->fY(), int(seg-segs), int(seg->linedef-lines), seg->sidedef != seg->linedef->sidedef[0]); } else { Printf(PRINT_LOG, " (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, miniseg", - FIXED2FLOAT(seg->v1->x), FIXED2FLOAT(seg->v1->y), FIXED2FLOAT(seg->v2->x), FIXED2FLOAT(seg->v2->y), + seg->v1->fX(), seg->v1->fY(), seg->v2->fX(), seg->v2->fY(), int(seg-segs)); } if (seg->PartnerSeg) diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index a821ddd4f..de59c0583 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -331,8 +331,8 @@ void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, F shape.Resize(subsector->numlines); for(unsigned i=0; inumlines; i++) { - centerx += (shape[i].x = subsector->firstline[i].v1->x + portal->xDisplacement); - centery += (shape[i].y = subsector->firstline[i].v1->y + portal->yDisplacement); + centerx += (shape[i].x = subsector->firstline[i].v1->fixX() + portal->xDisplacement); + centery += (shape[i].y = subsector->firstline[i].v1->fixY() + portal->yDisplacement); } FCoverageBuilder build(subsector, portal); @@ -487,8 +487,8 @@ void gl_InitPortals() } for (auto glport : glLinePortals) { - glport.dx = glport.v2->x - glport.v1->x; - glport.dy = glport.v2->y - glport.v1->y; + glport.dx = glport.v2->fixX() - glport.v1->fixX(); + glport.dy = glport.v2->fixY() - glport.v1->fixY(); } linePortalToGL.Resize(linePortals.Size()); for (unsigned i = 0; i < linePortals.Size(); i++) @@ -496,7 +496,7 @@ void gl_InitPortals() linePortalToGL[i] = &glLinePortals[tempindex[i]]; /* Printf("portal at line %d translates to GL portal %d, range = %f,%f to %f,%f\n", - int(linePortals[i].mOrigin - lines), tempindex[i], linePortalToGL[i]->v1->x / 65536., linePortalToGL[i]->v1->y / 65536., linePortalToGL[i]->v2->x / 65536., linePortalToGL[i]->v2->y / 65536.); + int(linePortals[i].mOrigin - lines), tempindex[i], linePortalToGL[i]->v1->fixX() / 65536., linePortalToGL[i]->v1->fixY() / 65536., linePortalToGL[i]->v2->fixX() / 65536., linePortalToGL[i]->v2->fixY() / 65536.); */ } } @@ -519,7 +519,7 @@ CCMD(dumpportals) Printf(PRINT_LOG, "\tSubsector %d (%d):\n\t\t", j, sub->render_sector->sectornum); for(unsigned k = 0;k< sub->numlines; k++) { - Printf(PRINT_LOG, "(%.3f,%.3f), ", sub->firstline[k].v1->x/65536. + xdisp, sub->firstline[k].v1->y/65536. + ydisp); + Printf(PRINT_LOG, "(%.3f,%.3f), ", sub->firstline[k].v1->fixX()/65536. + xdisp, sub->firstline[k].v1->fixY()/65536. + ydisp); } Printf(PRINT_LOG, "\n\t\tCovered by subsectors:\n"); FPortalCoverage *cov = &sub->portalcoverage[portals[i]->plane]; @@ -529,7 +529,7 @@ CCMD(dumpportals) Printf(PRINT_LOG, "\t\t\t%5d (%4d): ", cov->subsectors[l], csub->render_sector->sectornum); for(unsigned m = 0;m< csub->numlines; m++) { - Printf(PRINT_LOG, "(%.3f,%.3f), ", csub->firstline[m].v1->x/65536., csub->firstline[m].v1->y/65536.); + Printf(PRINT_LOG, "(%.3f,%.3f), ", csub->firstline[m].v1->fixX()/65536., csub->firstline[m].v1->fixY()/65536.); } Printf(PRINT_LOG, "\n"); } diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index 7eeabaa33..3b879df7a 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -106,7 +106,7 @@ struct cvertex_t operator int () const { return ((x>>16)&0xffff) | y; } bool operator!= (const cvertex_t &other) const { return x != other.x || y != other.y; } - cvertex_t& operator =(const vertex_t *v) { x = v->x; y = v->y; return *this; } + cvertex_t& operator =(const vertex_t *v) { x = v->fixX(); y = v->fixY(); return *this; } }; typedef TMap FSectionVertexMap; @@ -286,7 +286,7 @@ static void PrepareSectorData() seg[j].PartnerSeg!=NULL && subsectors[i].render_sector != seg[j].PartnerSeg->Subsector->render_sector) { - DPrintf("Found hack: (%d,%d) (%d,%d)\n", seg[j].v1->x>>16, seg[j].v1->y>>16, seg[j].v2->x>>16, seg[j].v2->y>>16); + DPrintf("Found hack: (%f,%f) (%f,%f)\n", seg[j].v1->fX(), seg[j].v1->fY(), seg[j].v2->fX(), seg[j].v2->fY()); subsectors[i].hacked|=5; SpreadHackedFlag(&subsectors[i]); } @@ -512,8 +512,8 @@ static void PrepareSegs() // Get floatng point coordinates of vertices for(int i = 0; i < numvertexes; i++) { - vertexes[i].fx = FIXED2FLOAT(vertexes[i].x); - vertexes[i].fy = FIXED2FLOAT(vertexes[i].y); + vertexes[i].fx = vertexes[i].fX(); + vertexes[i].fy = vertexes[i].fY(); vertexes[i].dirty = true; } diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 91292d350..99f1a4d9b 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -354,9 +354,7 @@ void ADynamicLight::UpdateLocation() DVector3 pos = target->Vec3Offset(m_off.X * c + m_off.Y * s, m_off.X * s - m_off.Y * c, m_off.Z + target->GetBobOffset()); SetXYZ(pos); // attached lights do not need to go into the regular blockmap - PrevX = target->_f_X(); - PrevY = target->_f_Y(); - PrevZ = target->_f_Z(); + Prev = target->Pos(); subsector = R_PointInSubsector(target->_f_X(), target->_f_Y()); Sector = subsector->sector; } @@ -509,23 +507,23 @@ static FLightNode * DeleteLightNode(FLightNode * node) // //========================================================================== -float ADynamicLight::DistToSeg(const fixedvec3 &pos, seg_t *seg) +double ADynamicLight::DistToSeg(const fixedvec3 &pos, seg_t *seg) { - float u, px, py; + double u, px, py; - float seg_dx = FIXED2FLOAT(seg->v2->x - seg->v1->x); - float seg_dy = FIXED2FLOAT(seg->v2->y - seg->v1->y); - float seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy; + double seg_dx = seg->v2->fX() - seg->v1->fX(); + double seg_dy = seg->v2->fY() - seg->v1->fY(); + double seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy; - u = (FIXED2FLOAT(pos.x - seg->v1->x) * seg_dx + FIXED2FLOAT(pos.y - seg->v1->y) * seg_dy) / seg_length_sq; - if (u < 0.f) u = 0.f; // clamp the test point to the line segment - if (u > 1.f) u = 1.f; + u = ((FIXED2DBL(pos.x) - seg->v1->fX()) * seg_dx + (FIXED2DBL(pos.y) - seg->v1->fY()) * seg_dy) / seg_length_sq; + if (u < 0.) u = 0.; // clamp the test point to the line segment + if (u > 1.) u = 1.; - px = FIXED2FLOAT(seg->v1->x) + (u * seg_dx); - py = FIXED2FLOAT(seg->v1->y) + (u * seg_dy); + px = seg->v1->fX() + (u * seg_dx); + py = seg->v1->fY() + (u * seg_dy); - px -= FIXED2FLOAT(pos.x); - py -= FIXED2FLOAT(pos.y); + px -= FIXED2DBL(pos.x); + py -= FIXED2DBL(pos.y); return (px*px) + (py*py); } @@ -558,7 +556,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe if (seg->sidedef && seg->linedef && seg->linedef->validcount!=::validcount) { // light is in front of the seg - if (DMulScale32(pos.y - seg->v1->y, seg->v2->x - seg->v1->x, seg->v1->x - pos.x, seg->v2->y - seg->v1->y) <= 0) + if (DMulScale32(pos.y - seg->v1->fixY(), seg->v2->fixX() - seg->v1->fixX(), seg->v1->fixX() - pos.x, seg->v2->fixY() - seg->v1->fixY()) <= 0) { seg->linedef->validcount = validcount; touching_sides = AddLightNode(&seg->sidedef->lighthead, seg->sidedef, this, touching_sides); @@ -574,7 +572,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe line_t *other = port->mDestination; if (other->validcount != ::validcount) { - subsector_t *othersub = R_PointInSubsector(other->v1->x + other->dx / 2, other->v1->y + other->dy / 2); + subsector_t *othersub = R_PointInSubsector(other->v1->fixX() + other->dx / 2, other->v1->fixY() + other->dy / 2); if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(other), othersub, radius); } } @@ -601,7 +599,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe AActor *sb = subSec->sector->SkyBoxes[sector_t::ceiling]; if (sb->specialf1 < Z() + radius) { - fixedvec2 refpos = { other->v1->x + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->y + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) }; + fixedvec2 refpos = { other->v1->fixX() + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->fixY() + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) }; subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y); if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(othersub->sector), othersub, radius); } @@ -612,7 +610,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe AActor *sb = subSec->sector->SkyBoxes[sector_t::floor]; if (sb->specialf1 > Z() - radius) { - fixedvec2 refpos = { other->v1->x + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->y + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) }; + fixedvec2 refpos = { other->v1->fixX() + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->fixY() + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) }; subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y); if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(othersub->sector), othersub, radius); } diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index 7d98154fe..076f56ecd 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -99,7 +99,7 @@ public: FLightNode * touching_sector; private: - float DistToSeg(const fixedvec3 &pos, seg_t *seg); + double DistToSeg(const fixedvec3 &pos, seg_t *seg); void CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSec, float radius); protected: diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 72e0c8d1d..b9f38ca50 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -1182,10 +1182,10 @@ void FDrawInfo::FloodUpperGap(seg_t * seg) v2=seg->linedef->v1; } - ws.x1= FIXED2FLOAT(v1->x); - ws.y1= FIXED2FLOAT(v1->y); - ws.x2= FIXED2FLOAT(v2->x); - ws.y2= FIXED2FLOAT(v2->y); + ws.x1 = v1->fX(); + ws.y1 = v1->fY(); + ws.x2 = v2->fX(); + ws.y2 = v2->fY(); ws.z1= FIXED2FLOAT(frontz); ws.z2= FIXED2FLOAT(backz); @@ -1235,10 +1235,10 @@ void FDrawInfo::FloodLowerGap(seg_t * seg) v2=seg->linedef->v1; } - ws.x1= FIXED2FLOAT(v1->x); - ws.y1= FIXED2FLOAT(v1->y); - ws.x2= FIXED2FLOAT(v2->x); - ws.y2= FIXED2FLOAT(v2->y); + ws.x1 = v1->fX(); + ws.y1 = v1->fY(); + ws.x2 = v2->fX(); + ws.y2 = v2->fY(); ws.z2= FIXED2FLOAT(frontz); ws.z1= FIXED2FLOAT(backz); diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 0ebf78b5c..0fda331b4 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -655,10 +655,10 @@ void GLSkyboxPortal::DrawContents() PlaneMirrorMode=0; bool oldclamp = gl_RenderState.SetDepthClamp(false); - fixedvec3 viewpos = origin->InterpolatedPosition(r_TicFrac); - viewx = viewpos.x; - viewy = viewpos.y; - viewz = viewpos.z; + DVector3 viewpos = origin->InterpolatedPosition(r_TicFracF); + viewx = FLOAT2FIXED(viewpos.X); + viewy = FLOAT2FIXED(viewpos.Y); + viewz = FLOAT2FIXED(viewpos.Z); viewangle += (origin->PrevAngles.Yaw + deltaangle(origin->PrevAngles.Yaw, origin->Angles.Yaw) * FIXED2DBL(r_TicFrac)).BAMs(); // Don't let the viewpoint be too close to a floor or ceiling @@ -883,19 +883,19 @@ void GLMirrorPortal::DrawContents() if (linedef->dx == 0) { // vertical mirror - viewx = v1->x - startx + v1->x; + viewx = v1->fixX() - startx + v1->fixX(); // Compensation for reendering inaccuracies - if (startxx) viewx -= FRACUNIT/2; + if (startxfixX()) viewx -= FRACUNIT/2; else viewx += FRACUNIT/2; } else if (linedef->dy == 0) { // horizontal mirror - viewy = v1->y - starty + v1->y; + viewy = v1->fixY() - starty + v1->fixY(); // Compensation for reendering inaccuracies - if (startyy) viewy -= FRACUNIT/2; + if (startyfixY()) viewy -= FRACUNIT/2; else viewy += FRACUNIT/2; } else @@ -903,10 +903,10 @@ void GLMirrorPortal::DrawContents() // any mirror--use floats to avoid integer overflow. // Use doubles to avoid losing precision which is very important here. - double dx = FIXED2DBL(v2->x - v1->x); - double dy = FIXED2DBL(v2->y - v1->y); - double x1 = FIXED2DBL(v1->x); - double y1 = FIXED2DBL(v1->y); + double dx = v2->fX() - v1->fX(); + double dy = v2->fY() - v1->fY(); + double x1 = v1->fX(); + double y1 = v1->fY(); double x = FIXED2DBL(startx); double y = FIXED2DBL(starty); @@ -924,8 +924,8 @@ void GLMirrorPortal::DrawContents() viewy+= FLOAT2FIXED(v[0] * renderdepth / 2); } // we cannot afford any imprecisions caused by R_PointToAngle2 here. They'd be visible as seams around the mirror. - viewangle = 2*R_PointToAnglePrecise (linedef->v1->x, linedef->v1->y, - linedef->v2->x, linedef->v2->y) - startang; + viewangle = 2*R_PointToAnglePrecise (linedef->v1->fixX(), linedef->v1->fixY(), + linedef->v2->fixX(), linedef->v2->fixY()) - startang; GLRenderer->mViewActor = NULL; r_showviewer = true; @@ -960,7 +960,7 @@ int GLLinePortal::ClipSubsector(subsector_t *sub) // this seg is completely behind the mirror! for(unsigned int i=0;inumlines;i++) { - if (P_PointOnLineSidePrecise(sub->firstline[i].v1->x, sub->firstline[i].v1->y, line()) == 0) return PClip_Inside; + if (P_PointOnLineSidePrecise(sub->firstline[i].v1->fixX(), sub->firstline[i].v1->fixY(), line()) == 0) return PClip_Inside; } return PClip_InFront; } @@ -1015,7 +1015,7 @@ void GLLineToLinePortal::DrawContents() line_t *line = lines[i].seg->linedef->getPortalDestination(); subsector_t *sub; if (line->sidedef[0]->Flags & WALLF_POLYOBJ) - sub = R_PointInSubsector(line->v1->x, line->v1->y); + sub = R_PointInSubsector(line->v1->fixX(), line->v1->fixY()); else sub = line->frontsector->subsectors[0]; int mapsection = sub->mapsection; currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index ccc069f89..80961ae6d 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -508,12 +508,12 @@ void GLSprite::Process(AActor* thing,sector_t * sector) if (!(currentmapsection[thing->subsector->mapsection>>3] & (1 << (thing->subsector->mapsection & 7)))) return; // [RH] Interpolate the sprite's position to make it look smooth - fixedvec3 thingpos = thing->InterpolatedPosition(r_TicFrac); + DVector3 thingpos = thing->InterpolatedPosition(r_TicFracF); // Too close to the camera. This doesn't look good if it is a sprite. - if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy)<2*FRACUNIT) + if (fabs(thingpos.X - FIXED2DBL(viewx) < 2 && fabs(thingpos.Y - FIXED2DBL(viewy) < 2))) { - if (viewz >= thingpos.z - 2 * FRACUNIT && viewz <= thingpos.z + FLOAT2FIXED(thing->Height) + 2 * FRACUNIT) + if (FIXED2DBL(viewz) >= thingpos.Z - 2 && FIXED2DBL(viewz) <= thingpos.Z + thing->Height + 2) { // exclude vertically moving objects from this check. if (!thing->Vel.isZero()) @@ -532,14 +532,14 @@ void GLSprite::Process(AActor* thing,sector_t * sector) if (!(thing->flags7 & MF7_FLYCHEAT) && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) { fixed_t clipdist = FLOAT2FIXED(clamp(thing->Speed, thing->target->radius, thing->target->radius*2)); - if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy) < clipdist) return; + if (P_AproxDistance(FLOAT2FIXED(thingpos.X)-viewx, FLOAT2FIXED(thingpos.Y)-viewy) < clipdist) return; } thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again. } if (GLRenderer->mCurrentPortal) { - int clipres = GLRenderer->mCurrentPortal->ClipPoint(thingpos.x, thingpos.y); + int clipres = GLRenderer->mCurrentPortal->ClipPoint(FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y)); if (clipres == GLPortal::PClip_InFront) return; } @@ -556,21 +556,21 @@ void GLSprite::Process(AActor* thing,sector_t * sector) } - x = FIXED2FLOAT(thingpos.x); - z = FIXED2FLOAT(thingpos.z)-thing->Floorclip; - y = FIXED2FLOAT(thingpos.y); + x = thingpos.X; + z = thingpos.Z - thing->Floorclip; + y = thingpos.Y; // [RH] Make floatbobbing a renderer-only effect. if (thing->flags2 & MF2_FLOATBOB) { - float fz = FIXED2FLOAT(thing->GetBobOffset(r_TicFrac)); + float fz = thing->GetBobOffset(r_TicFracF); z += fz; } modelframe = gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED)); if (!modelframe) { - angle_t ang = R_PointToAngle(thingpos.x, thingpos.y); + angle_t ang = R_PointToAngle(FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y)); bool mirror; FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, ang - thing->Angles.Yaw.BAMs(), &mirror); @@ -607,7 +607,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) // Tests show that this doesn't look good for many decorations and corpses if (spriteheight > 0 && gl_spriteclip > 0 && (thing->renderflags & RF_SPRITETYPEMASK) == RF_FACESPRITE) { - PerformSpriteClipAdjustment(thing, thingpos.x, thingpos.y, spriteheight); + PerformSpriteClipAdjustment(thing, FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y), spriteheight); } float viewvecX; @@ -643,7 +643,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) gltexture=NULL; } - depth = DMulScale20 (thingpos.x-viewx, viewtancos, thingpos.y-viewy, viewtansin); + depth = DMulScale20 (FLOAT2FIXED(thingpos.X)-viewx, viewtancos, FLOAT2FIXED(thingpos.Y)-viewy, viewtansin); // light calculation @@ -659,7 +659,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) rendersector->GetCeilingLight() : rendersector->GetFloorLight()); foglevel = (BYTE)clamp(rendersector->lightlevel, 0, 255); - lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, thingpos.x, thingpos.y, thingpos.z); + lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y), FLOAT2FIXED(thingpos.Z)); ThingColor = (thing->RenderStyle.Flags & STYLEF_ColorIsFixed) ? thing->fillcolor : 0xffffff; ThingColor.a = 255; diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index 2afc67524..227427e0d 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -90,8 +90,8 @@ void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t * int togroup = subsec->sector->PortalGroup; if (fromgroup == togroup || fromgroup == 0 || togroup == 0) goto direct; - fixedvec2 offset = Displacements.getOffset(fromgroup, togroup); - dist = FVector3(x - light->X() - FIXED2FLOAT(offset.x), y - light->Y() - FIXED2FLOAT(offset.y), z - light->Z()).LengthSquared(); + DVector2 offset = Displacements.getOffset(fromgroup, togroup); + dist = FVector3(x - light->X() - offset.X, y - light->Y() - offset.Y, z - light->Z()).LengthSquared(); } else { diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 1d974205c..fad482dda 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -134,8 +134,8 @@ void GLWall::PutWall(bool translucent) if (translucent) // translucent walls { - viewdistance = P_AproxDistance(((seg->linedef->v1->x + seg->linedef->v2->x) >> 1) - viewx, - ((seg->linedef->v1->y + seg->linedef->v2->y) >> 1) - viewy); + viewdistance = P_AproxDistance(((seg->linedef->v1->fixX() + seg->linedef->v2->fixX()) >> 1) - viewx, + ((seg->linedef->v1->fixY() + seg->linedef->v2->fixY()) >> 1) - viewy); gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this); } else @@ -1396,15 +1396,15 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else // polyobjects must be rendered per seg. { - if (abs(v1->x - v2->x) > abs(v1->y - v2->y)) + if (fabs(v1->fX() - v2->fX()) > fabs(v1->fY() - v2->fY())) { - glseg.fracleft = float(seg->v1->x - v1->x) / float(v2->x - v1->x); - glseg.fracright = float(seg->v2->x - v1->x) / float(v2->x - v1->x); + glseg.fracleft = (seg->v1->fX() - v1->fX()) / (v2->fX() - v1->fX()); + glseg.fracright = (seg->v2->fX() - v1->fX()) / float(v2->fX() - v1->fX()); } else { - glseg.fracleft = float(seg->v1->y - v1->y) / float(v2->y - v1->y); - glseg.fracright = float(seg->v2->y - v1->y) / float(v2->y - v1->y); + glseg.fracleft = (seg->v1->fY() - v1->fY()) / (v2->fY() - v1->fY()); + glseg.fracright = (seg->v2->fY() - v1->fY()) / (v2->fY() - v1->fY()); } v1 = seg->v1; v2 = seg->v2; @@ -1414,10 +1414,10 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) vertexes[0] = v1; vertexes[1] = v2; - glseg.x1 = FIXED2FLOAT(v1->x); - glseg.y1 = FIXED2FLOAT(v1->y); - glseg.x2 = FIXED2FLOAT(v2->x); - glseg.y2 = FIXED2FLOAT(v2->y); + glseg.x1 = v1->fX(); + glseg.y1 = v1->fY(); + glseg.x2 = v2->fX(); + glseg.y2 = v2->fY(); Colormap = frontsector->ColorMap; flags = 0; dynlightindex = UINT_MAX; @@ -1700,10 +1700,10 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * vertexes[0] = v1; vertexes[1] = v2; - glseg.x1 = FIXED2FLOAT(v1->x); - glseg.y1 = FIXED2FLOAT(v1->y); - glseg.x2 = FIXED2FLOAT(v2->x); - glseg.y2 = FIXED2FLOAT(v2->y); + glseg.x1 = v1->fX(); + glseg.y1 = v1->fY(); + glseg.x2 = v2->fX(); + glseg.y2 = v2->fY(); glseg.fracleft = 0; glseg.fracright = 1; diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 1563895b5..c4a61f758 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -264,7 +264,7 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u return inputBuffer; // already scaled? - if (inputTexture->xScale >= FRACUNIT*2 && inputTexture->yScale >= FRACUNIT*2) + if (inputTexture->Scale.X >= 2 && inputTexture->Scale.Y >= 2) return inputBuffer; switch (inputTexture->UseType) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index a359191e1..ea6811603 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -457,13 +457,13 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) FTexture *basetex = tx->GetRedirect(false); // allow the redirect only if the textute is not expanded or the scale matches. - if (!expanded || (tx->xScale == basetex->xScale && tx->yScale == basetex->yScale)) + if (!expanded || (tx->Scale.X == basetex->Scale.X && tx->Scale.Y == basetex->Scale.Y)) { mBaseLayer = ValidateSysTexture(basetex, expanded); } - float fxScale = FIXED2FLOAT(tx->xScale); - float fyScale = FIXED2FLOAT(tx->yScale); + float fxScale = tx->Scale.X; + float fyScale = tx->Scale.Y; // mSpriteRect is for positioning the sprite in the scene. mSpriteRect.left = -mLeftOffset / fxScale; @@ -646,7 +646,7 @@ void FMaterial::Bind(int clampmode, int translation) int usebright = false; int maxbound = 0; - bool allowhires = tex->xScale == FRACUNIT && tex->yScale == FRACUNIT && clampmode <= CLAMP_XY && !mExpanded; + bool allowhires = tex->Scale.X == 1 && tex->Scale.Y == 1 && clampmode <= CLAMP_XY && !mExpanded; if (tex->bHasCanvas) clampmode = CLAMP_CAMTEX; else if (tex->bWarped && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE; @@ -701,12 +701,12 @@ void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const if (x == FRACUNIT) { tci->mRenderWidth = mRenderWidth; - tci->mScaleX = tex->xScale; + tci->mScaleX = FLOAT2FIXED(tex->Scale.X); tci->mTempScaleX = FRACUNIT; } else { - fixed_t scale_x = FixedMul(x, tex->xScale); + fixed_t scale_x = fixed_t(x * tex->Scale.X); int foo = (mWidth << 17) / scale_x; tci->mRenderWidth = (foo >> 1) + (foo & 1); tci->mScaleX = scale_x; @@ -716,12 +716,12 @@ void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const if (y == FRACUNIT) { tci->mRenderHeight = mRenderHeight; - tci->mScaleY = tex->yScale; + tci->mScaleY = FLOAT2FIXED(tex->Scale.Y); tci->mTempScaleY = FRACUNIT; } else { - fixed_t scale_y = FixedMul(y, tex->yScale); + fixed_t scale_y = fixed_t(y * tex->Scale.Y); int foo = (mHeight << 17) / scale_y; tci->mRenderHeight = (foo >> 1) + (foo & 1); tci->mScaleY = scale_y; diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 61fdd6e46..ac1ccc274 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -187,33 +187,33 @@ public: int GetScaledLeftOffset() const { - return DivScale16(mLeftOffset, tex->xScale); + return int(mLeftOffset / tex->Scale.X); } int GetScaledTopOffset() const { - return DivScale16(mTopOffset, tex->yScale); + return int(mTopOffset / tex->Scale.Y); } float GetScaledLeftOffsetFloat() const { - return mLeftOffset / FIXED2FLOAT(tex->xScale); + return float(mLeftOffset / tex->Scale.X); } float GetScaledTopOffsetFloat() const { - return mTopOffset/ FIXED2FLOAT(tex->yScale); + return float(mTopOffset/ tex->Scale.Y); } // This is scaled size in floating point as needed by sprites float GetScaledWidthFloat() const { - return mWidth / FIXED2FLOAT(tex->xScale); + return float(mWidth / tex->Scale.X); } float GetScaledHeightFloat() const { - return mHeight / FIXED2FLOAT(tex->yScale); + return float(mHeight / tex->Scale.Y); } // Get right/bottom UV coordinates for patch drawing From 59bb0032853012dbd1afd4f5bd5948fcc15f9d7a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 29 Mar 2016 13:45:50 +0200 Subject: [PATCH 0438/1509] - GL adjustments for plane changes. --- src/gl/data/gl_data.cpp | 4 ++-- src/gl/data/gl_setup.cpp | 2 +- src/gl/renderer/gl_renderstate.h | 8 ++++---- src/gl/scene/gl_fakeflat.cpp | 18 ++++++++--------- src/gl/scene/gl_flats.cpp | 2 +- src/gl/scene/gl_portal.cpp | 2 +- src/gl/scene/gl_renderhacks.cpp | 8 ++++---- src/gl/scene/gl_sky.cpp | 10 +++++----- src/gl/scene/gl_sprite.cpp | 5 +++-- src/gl/scene/gl_wall.h | 4 ++-- src/gl/scene/gl_walls.cpp | 34 +++++++++++++++----------------- src/gl/utility/gl_geometric.cpp | 8 ++++---- 12 files changed, 52 insertions(+), 53 deletions(-) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index df5d0d35f..6ec57b055 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -157,8 +157,8 @@ int LS_Sector_SetPlaneReflection (line_t *ln, AActor *it, bool backSide, while ((secnum = itr.Next()) >= 0) { sector_t * s = §ors[secnum]; - if (s->floorplane.a==0 && s->floorplane.b==0) s->reflect[sector_t::floor] = arg1/255.f; - if (s->ceilingplane.a==0 && s->ceilingplane.b==0) sectors[secnum].reflect[sector_t::ceiling] = arg2/255.f; + if (!s->floorplane.isSlope()) s->reflect[sector_t::floor] = arg1/255.f; + if (!s->ceilingplane.isSlope()) sectors[secnum].reflect[sector_t::ceiling] = arg2/255.f; } return true; diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index 3b879df7a..a13192694 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -324,7 +324,7 @@ static void PrepareTransparentDoors(sector_t * sector) if (sector->subsectorcount==0) return; sector->transdoorheight=sector->GetPlaneTexZ(sector_t::floor); - sector->transdoor= !(sector->e->XFloor.ffloors.Size() || sector->heightsec || sector->floorplane.a || sector->floorplane.b); + sector->transdoor= !(sector->e->XFloor.ffloors.Size() || sector->heightsec || sector->floorplane.isSlope()); if (sector->transdoor) { diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index d46bb4996..87df78a6b 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -275,14 +275,14 @@ public: void SetGlowPlanes(const secplane_t &top, const secplane_t &bottom) { - mGlowTopPlane.Set(FIXED2FLOAT(top.a), FIXED2FLOAT(top.b), FIXED2FLOAT(top.ic), FIXED2FLOAT(top.d)); - mGlowBottomPlane.Set(FIXED2FLOAT(bottom.a), FIXED2FLOAT(bottom.b), FIXED2FLOAT(bottom.ic), FIXED2FLOAT(bottom.d)); + mGlowTopPlane.Set(top.fA(), top.fB(), 1. / top.fC(), top.fD()); + mGlowBottomPlane.Set(bottom.fA(), bottom.fB(), 1. / bottom.fC(), bottom.fD()); } void SetSplitPlanes(const secplane_t &top, const secplane_t &bottom) { - mSplitTopPlane.Set(FIXED2FLOAT(top.a), FIXED2FLOAT(top.b), FIXED2FLOAT(top.ic), FIXED2FLOAT(top.d)); - mSplitBottomPlane.Set(FIXED2FLOAT(bottom.a), FIXED2FLOAT(bottom.b), FIXED2FLOAT(bottom.ic), FIXED2FLOAT(bottom.d)); + mSplitTopPlane.Set(top.fA(), top.fB(), 1. / top.fC(), top.fD()); + mSplitBottomPlane.Set(bottom.fA(), bottom.fB(), 1. / bottom.fC(), bottom.fD()); } void SetDynLight(float r, float g, float b) diff --git a/src/gl/scene/gl_fakeflat.cpp b/src/gl/scene/gl_fakeflat.cpp index 8399526da..101fcc8a3 100644 --- a/src/gl/scene/gl_fakeflat.cpp +++ b/src/gl/scene/gl_fakeflat.cpp @@ -80,44 +80,44 @@ bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto // on large levels this distinction can save some time // That's a lot of avoided multiplications if there's a lot to see! - if (frontsector->ceilingplane.a | frontsector->ceilingplane.b) + if (frontsector->ceilingplane.isSlope()) { fs_ceilingheight1=frontsector->ceilingplane.ZatPoint(linedef->v1); fs_ceilingheight2=frontsector->ceilingplane.ZatPoint(linedef->v2); } else { - fs_ceilingheight2=fs_ceilingheight1=frontsector->ceilingplane.d; + fs_ceilingheight2=fs_ceilingheight1=frontsector->ceilingplane.fixD(); } - if (frontsector->floorplane.a | frontsector->floorplane.b) + if (frontsector->floorplane.isSlope()) { fs_floorheight1=frontsector->floorplane.ZatPoint(linedef->v1); fs_floorheight2=frontsector->floorplane.ZatPoint(linedef->v2); } else { - fs_floorheight2=fs_floorheight1=-frontsector->floorplane.d; + fs_floorheight2=fs_floorheight1=-frontsector->floorplane.fixD(); } - if (backsector->ceilingplane.a | backsector->ceilingplane.b) + if (backsector->ceilingplane.isSlope()) { bs_ceilingheight1=backsector->ceilingplane.ZatPoint(linedef->v1); bs_ceilingheight2=backsector->ceilingplane.ZatPoint(linedef->v2); } else { - bs_ceilingheight2=bs_ceilingheight1=backsector->ceilingplane.d; + bs_ceilingheight2=bs_ceilingheight1=backsector->ceilingplane.fixD(); } - if (backsector->floorplane.a | backsector->floorplane.b) + if (backsector->floorplane.isSlope()) { bs_floorheight1=backsector->floorplane.ZatPoint(linedef->v1); bs_floorheight2=backsector->floorplane.ZatPoint(linedef->v2); } else { - bs_floorheight2=bs_floorheight1=-backsector->floorplane.d; + bs_floorheight2=bs_floorheight1=-backsector->floorplane.fixD(); } // now check for closed sectors! @@ -206,7 +206,7 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac // visual glitches because upper amd lower textures overlap. if (back && sec->planes[sector_t::floor].TexZ > sec->planes[sector_t::ceiling].TexZ) { - if (!(sec->floorplane.a | sec->floorplane.b | sec->ceilingplane.a | sec->ceilingplane.b)) + if (!sec->floorplane.isSlope() && !sec->ceilingplane.isSlope()) { *dest = *sec; dest->ceilingplane=sec->floorplane; diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index cffa1ee25..29602fbd2 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -174,7 +174,7 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli) void GLFlat::DrawSubsector(subsector_t * sub) { FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - if (plane.plane.a | plane.plane.b) + if (plane.plane.isSlope()) { for (unsigned int k = 0; k < sub->numlines; k++) { diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 0fda331b4..1d69d2b99 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -810,7 +810,7 @@ void GLPlaneMirrorPortal::DrawContents() fixed_t planez = origin->ZatPoint(viewx, viewy); viewz = 2*planez - viewz; GLRenderer->mViewActor = NULL; - PlaneMirrorMode = ksgn(origin->c); + PlaneMirrorMode = origin->fC() < 0 ? -1 : 1; r_showviewer = true; validcount++; diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index 2a3839037..972e970d5 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -296,7 +296,7 @@ bool FDrawInfo::DoOneSectorUpper(subsector_t * subsec, fixed_t planez) sector_t * sec = gl_FakeFlat(seg->backsector, &fakesec, true); // Don't bother with slopes - if (sec->ceilingplane.a!=0 || sec->ceilingplane.b!=0) return false; + if (sec->ceilingplane.isSlope()) return false; // Is the neighboring ceiling lower than the desired height? if (sec->GetPlaneTexZ(sector_t::ceiling)backsector, &fakesec, true); // Don't bother with slopes - if (sec->floorplane.a!=0 || sec->floorplane.b!=0) return false; + if (sec->floorplane.isSlope()) return false; // Is the neighboring floor higher than the desired height? if (sec->GetPlaneTexZ(sector_t::floor)>planez) @@ -413,7 +413,7 @@ bool FDrawInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez) sector_t * sec = gl_FakeFlat(seg->backsector, &fakesec, true); // Don't bother with slopes - if (sec->floorplane.a!=0 || sec->floorplane.b!=0) return false; + if (sec->floorplane.isSlope()) return false; // Is the neighboring floor higher than the desired height? if (sec->GetPlaneTexZ(sector_t::floor)backsector, &fakesec, true); // Don't bother with slopes - if (sec->ceilingplane.a!=0 || sec->ceilingplane.b!=0) return false; + if (sec->ceilingplane.isSlope()) return false; // Is the neighboring ceiling higher than the desired height? if (sec->GetPlaneTexZ(sector_t::ceiling)>planez) diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 3cedd38c3..3180b0ecf 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -173,8 +173,8 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) } else if (allowreflect && sector->GetReflect(plane) > 0) { - if ((plane == sector_t::ceiling && viewz > sector->ceilingplane.d) || - (plane == sector_t::floor && viewz < -sector->floorplane.d)) return; + if ((plane == sector_t::ceiling && viewz > sector->ceilingplane.fixD()) || + (plane == sector_t::floor && viewz < -sector->floorplane.fixD())) return; ptype = PORTALTYPE_PLANEMIRROR; planemirror = plane == sector_t::ceiling ? §or->ceilingplane : §or->floorplane; } @@ -263,7 +263,7 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex return; // one more check for some ugly transparent door hacks - if (bs->floorplane.a==0 && bs->floorplane.b==0 && fs->floorplane.a==0 && fs->floorplane.b==0) + if (!bs->floorplane.isSlope() && !fs->floorplane.isSlope()) { if (bs->GetPlaneTexZ(sector_t::floor)==fs->GetPlaneTexZ(sector_t::floor)+FRACUNIT) { @@ -309,7 +309,7 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex if (frontreflect > 0) { float backreflect = bs->GetReflect(sector_t::ceiling); - if (backreflect > 0 && bs->ceilingplane.d == fs->ceilingplane.d) + if (backreflect > 0 && bs->ceilingplane.fD() == fs->ceilingplane.fD()) { // Don't add intra-portal line to the portal. return; @@ -386,7 +386,7 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver if (frontreflect > 0) { float backreflect = bs->GetReflect(sector_t::floor); - if (backreflect > 0 && bs->floorplane.d == fs->floorplane.d) + if (backreflect > 0 && bs->floorplane.fD() == fs->floorplane.fD()) { // Don't add intra-portal line to the portal. return; diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 80961ae6d..30d5baecc 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -240,8 +240,9 @@ void GLSprite::Draw(int pass) if (lightlist) { // set up the light slice - static secplane_t bottommost = { 0, 0, FRACUNIT, 32767<GetAngle(ceiling); texture = sec->GetTexture(ceiling); plane = sec->GetSecPlane(ceiling); - texheight = (ceiling == sector_t::ceiling)? plane.d : -plane.d; + texheight = (ceiling == sector_t::ceiling)? plane.fixD() : -plane.fixD(); } }; @@ -205,7 +205,7 @@ private: fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2); - void GetPlanePos(F3DFloor::planeref *planeref, int &left, int &right); + void GetPlanePos(F3DFloor::planeref *planeref, fixed_t &left, fixed_t &right); void BuildFFBlock(seg_t * seg, F3DFloor * rover, fixed_t ff_topleft, fixed_t ff_topright, diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index fad482dda..28eb76777 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -191,7 +191,7 @@ void GLWall::PutPortal(int ptype) break; case PORTALTYPE_PLANEMIRROR: - if (GLPortal::PlaneMirrorMode * planemirror->c <=0) + if (GLPortal::PlaneMirrorMode * planemirror->fC() <=0) { //@sync-portal planemirror=UniquePlaneMirrors.Get(planemirror); @@ -283,7 +283,7 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) if (iplane->a | planeref->plane->b) + if (planeref->plane->isSlope()) { left=planeref->plane->ZatPoint(vertexes[0]); right=planeref->plane->ZatPoint(vertexes[1]); } else if(planeref->isceiling == sector_t::ceiling) { - left = right = planeref->plane->d; + left = right = planeref->plane->fixD(); } else { - left = right = -planeref->plane->d; + left = right = -planeref->plane->fixD(); } } @@ -1450,7 +1450,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) bottomplane = frontsector->floorplane; // Save a little time (up to 0.3 ms per frame ;) ) - if (frontsector->floorplane.a | frontsector->floorplane.b) + if (frontsector->floorplane.isSlope()) { ffh1 = segfront->floorplane.ZatPoint(v1); ffh2 = segfront->floorplane.ZatPoint(v2); @@ -1459,11 +1459,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else { - ffh1 = ffh2 = -segfront->floorplane.d; + ffh1 = ffh2 = -segfront->floorplane.fixD(); zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh2); } - if (segfront->ceilingplane.a | segfront->ceilingplane.b) + if (segfront->ceilingplane.isSlope()) { fch1 = segfront->ceilingplane.ZatPoint(v1); fch2 = segfront->ceilingplane.ZatPoint(v2); @@ -1472,7 +1472,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else { - fch1 = fch2 = segfront->ceilingplane.d; + fch1 = fch2 = segfront->ceilingplane.fixD(); zceil[0] = zceil[1] = FIXED2FLOAT(fch2); } @@ -1520,24 +1520,24 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) fixed_t bfh1; fixed_t bfh2; - if (segback->floorplane.a | segback->floorplane.b) + if (segback->floorplane.isSlope()) { bfh1 = segback->floorplane.ZatPoint(v1); bfh2 = segback->floorplane.ZatPoint(v2); } else { - bfh1 = bfh2 = -segback->floorplane.d; + bfh1 = bfh2 = -segback->floorplane.fixD(); } - if (segback->ceilingplane.a | segback->ceilingplane.b) + if (segback->ceilingplane.isSlope()) { bch1 = segback->ceilingplane.ZatPoint(v1); bch2 = segback->ceilingplane.ZatPoint(v2); } else { - bch1 = bch2 = segback->ceilingplane.d; + bch1 = bch2 = segback->ceilingplane.fixD(); } SkyTop(seg, frontsector, backsector, v1, v2); @@ -1568,8 +1568,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) { - if ((frontsector->ceilingplane.a | frontsector->ceilingplane.b | - backsector->ceilingplane.a | backsector->ceilingplane.b) && + if ((frontsector->ceilingplane.isSlope() || backsector->ceilingplane.isSlope()) && frontsector->GetTexture(sector_t::ceiling) != skyflatnum && backsector->GetTexture(sector_t::ceiling) != skyflatnum) { @@ -1649,8 +1648,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) { - if ((frontsector->floorplane.a | frontsector->floorplane.b | - backsector->floorplane.a | backsector->floorplane.b) && + if ((frontsector->ceilingplane.isSlope() || backsector->ceilingplane.isSlope()) && frontsector->GetTexture(sector_t::floor) != skyflatnum && backsector->GetTexture(sector_t::floor) != skyflatnum) { diff --git a/src/gl/utility/gl_geometric.cpp b/src/gl/utility/gl_geometric.cpp index 5e3f93ba8..ef9bc88d4 100644 --- a/src/gl/utility/gl_geometric.cpp +++ b/src/gl/utility/gl_geometric.cpp @@ -229,10 +229,10 @@ void Plane::Set(secplane_t &plane) { float a, b, c, d; - a = FIXED2FLOAT(plane.a); - b = FIXED2FLOAT(plane.b); - c = FIXED2FLOAT(plane.c); - d = FIXED2FLOAT(plane.d); + a = (float)plane.fA(); + b = (float)plane.fB(); + c = (float)plane.fC(); + d = (float)plane.fD(); m_normal.Set(a, c, b); //m_normal.Normalize(); the vector is already normalized From cadd8f2d4a7f20cfff557486d22abd718182e7ce Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 29 Mar 2016 16:31:58 +0200 Subject: [PATCH 0439/1509] - made adjustments for changes to linedef delta. --- src/gl/data/gl_portaldata.cpp | 8 ++++---- src/gl/dynlights/a_dynlight.cpp | 6 +++--- src/gl/scene/gl_portal.cpp | 4 ++-- src/gl/scene/gl_portal.h | 8 ++++---- src/gl/scene/gl_walls.cpp | 10 +++++----- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index de59c0583..8229767c1 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -463,14 +463,14 @@ void gl_InitPortals() line_t *pSrcLine2 = linePortals[j].mOrigin; line_t *pLine2 = linePortals[j].mDestination; // angular precision is intentionally reduced to 32 bit BAM to account for precision problems (otherwise many not perfectly horizontal or vertical portals aren't found here.) - angle_t srcang = RAD2ANGLE(atan2(pSrcLine->dy, pSrcLine->dx)); - angle_t dstang = RAD2ANGLE(atan2(pLine->dy, pLine->dx)); + unsigned srcang = pSrcLine->Delta().Angle().BAMs(); + unsigned dstang = pLine->Delta().Angle().BAMs(); if ((pSrcLine->v2 == pSrcLine2->v1 && pLine->v1 == pLine2->v2) || (pSrcLine->v1 == pSrcLine2->v2 && pLine->v2 == pLine2->v1)) { // The line connects, now check the translation - fixed_t srcang2 = RAD2ANGLE(atan2(pSrcLine2->dy, pSrcLine2->dx)); - fixed_t dstang2 = RAD2ANGLE(atan2(pLine2->dy, pLine2->dx)); + unsigned srcang2 = pSrcLine2->Delta().Angle().BAMs(); + unsigned dstang2 = pLine2->Delta().Angle().BAMs(); if (srcang == srcang2 && dstang == dstang2) { // The lines connect and both source and destination are colinear, so this is a match diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 99f1a4d9b..06df7f12b 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -572,7 +572,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe line_t *other = port->mDestination; if (other->validcount != ::validcount) { - subsector_t *othersub = R_PointInSubsector(other->v1->fixX() + other->dx / 2, other->v1->fixY() + other->dy / 2); + subsector_t *othersub = R_PointInSubsector(other->v1->fixX() + other->fixDx() / 2, other->v1->fixY() + other->fixDy() / 2); if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(other), othersub, radius); } } @@ -599,7 +599,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe AActor *sb = subSec->sector->SkyBoxes[sector_t::ceiling]; if (sb->specialf1 < Z() + radius) { - fixedvec2 refpos = { other->v1->fixX() + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->fixY() + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) }; + fixedvec2 refpos = { other->v1->fixX() + other->fixDx() / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->fixY() + other->fixDy() / 2 + FLOAT2FIXED(sb->Scale.Y) }; subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y); if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(othersub->sector), othersub, radius); } @@ -610,7 +610,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe AActor *sb = subSec->sector->SkyBoxes[sector_t::floor]; if (sb->specialf1 > Z() - radius) { - fixedvec2 refpos = { other->v1->fixX() + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->fixY() + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) }; + fixedvec2 refpos = { other->v1->fixX() + other->fixDx() / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->fixY() + other->fixDy() / 2 + FLOAT2FIXED(sb->Scale.Y) }; subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y); if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(othersub->sector), othersub, radius); } diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 1d69d2b99..0c4f04db3 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -880,7 +880,7 @@ void GLMirrorPortal::DrawContents() vertex_t *v2 = linedef->v2; // Reflect the current view behind the mirror. - if (linedef->dx == 0) + if (linedef->Delta().X == 0) { // vertical mirror viewx = v1->fixX() - startx + v1->fixX(); @@ -889,7 +889,7 @@ void GLMirrorPortal::DrawContents() if (startxfixX()) viewx -= FRACUNIT/2; else viewx += FRACUNIT/2; } - else if (linedef->dy == 0) + else if (linedef->Delta().Y == 0) { // horizontal mirror viewy = v1->fixY() - starty + v1->fixY(); diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 89431b1c2..22955a911 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -186,8 +186,8 @@ struct GLLinePortal : public GLPortal { v1 = line->v1; v2 = line->v2; - dx = line->dx; - dy = line->dy; + dx = line->fixDx(); + dy = line->fixDy(); } GLLinePortal(FGLLinePortal *line) @@ -198,8 +198,8 @@ struct GLLinePortal : public GLPortal line_t *lline = line->reference->mDestination; v1 = lline->v1; v2 = lline->v2; - dx = lline->dx; - dy = lline->dy; + dx = lline->fixDy(); + dy = lline->fixDy(); } else { diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 28eb76777..25ba616df 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1054,12 +1054,12 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, to= (rover->flags&(FF_UPPERTEXTURE|FF_LOWERTEXTURE))? 0.f : FIXED2FLOAT(tci.RowOffset(mastersd->GetTextureYOffset(side_t::mid))); - to += FIXED2FLOAT(rowoffset); + to += FIXED2FLOAT(rowoffset) + rover->top.model->GetPlaneTexZF(rover->top.isceiling); - uplft.v=tci.FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_topleft)); - uprgt.v=tci.FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_topright)); - lolft.v=tci.FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_bottomleft)); - lorgt.v=tci.FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_bottomright)); + uplft.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_topleft)); + uprgt.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_topright)); + lolft.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_bottomleft)); + lorgt.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_bottomright)); type=RENDERWALL_FFBLOCK; CheckTexturePosition(); } From cf44d2e37a85fa1f4687be135256680e6e055e5e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 30 Mar 2016 20:01:44 +0200 Subject: [PATCH 0440/1509] - adjustments. --- src/gl/data/gl_data.cpp | 4 +- src/gl/data/gl_vertexbuffer.cpp | 2 +- src/gl/dynlights/a_dynlight.cpp | 40 +++++++------- src/gl/dynlights/gl_dynlight.h | 4 +- src/gl/dynlights/gl_dynlight1.cpp | 16 ++---- src/gl/renderer/gl_renderer.cpp | 4 +- src/gl/scene/gl_drawinfo.cpp | 8 +-- src/gl/scene/gl_fakeflat.cpp | 92 +++++++++++++++---------------- src/gl/scene/gl_flats.cpp | 16 +++--- src/gl/scene/gl_portal.cpp | 6 +- src/gl/scene/gl_scene.cpp | 8 +-- src/gl/scene/gl_sky.cpp | 27 ++++----- src/gl/scene/gl_sprite.cpp | 4 +- src/gl/scene/gl_walls.cpp | 20 +++---- src/gl/scene/gl_walls_draw.cpp | 4 +- src/gl/utility/gl_clock.cpp | 2 +- src/r_defs.h | 8 +-- src/r_utility.h | 5 ++ 18 files changed, 133 insertions(+), 137 deletions(-) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 6ec57b055..ba6105d5a 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -459,8 +459,8 @@ void gl_RecalcVertexHeights(vertex_t * v) { for(j=0;j<2;j++) { - if (j==0) height=FIXED2FLOAT(v->sectors[i]->ceilingplane.ZatPoint(v)); - else height=FIXED2FLOAT(v->sectors[i]->floorplane.ZatPoint(v)); + if (j==0) height=v->sectors[i]->ceilingplane.ZatPoint(v); + else height=v->sectors[i]->floorplane.ZatPoint(v); for(k=0;knumheights;k++) { diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 87b600d4b..cd0ea5d60 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -157,7 +157,7 @@ void FFlatVertex::SetFlatVertex(vertex_t *vt, const secplane_t & plane) { x = vt->fx; y = vt->fy; - z = plane.ZatPoint(vt->fx, vt->fy); + z = plane.ZatPoint(vt->fx, vt->fy); // this is the original position without polyobject translation. u = vt->fx/64.f; v = -vt->fy/64.f; } diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 06df7f12b..f9e11a2f2 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -176,7 +176,7 @@ void ADynamicLight::PostBeginPlay() Activate (NULL); } - subsector = R_PointInSubsector(_f_X(), _f_Y()); + subsector = R_PointInSubsector(Pos()); } @@ -355,7 +355,7 @@ void ADynamicLight::UpdateLocation() DVector3 pos = target->Vec3Offset(m_off.X * c + m_off.Y * s, m_off.X * s - m_off.Y * c, m_off.Z + target->GetBobOffset()); SetXYZ(pos); // attached lights do not need to go into the regular blockmap Prev = target->Pos(); - subsector = R_PointInSubsector(target->_f_X(), target->_f_Y()); + subsector = R_PointInSubsector(Prev); Sector = subsector->sector; } @@ -507,7 +507,7 @@ static FLightNode * DeleteLightNode(FLightNode * node) // //========================================================================== -double ADynamicLight::DistToSeg(const fixedvec3 &pos, seg_t *seg) +double ADynamicLight::DistToSeg(const DVector3 &pos, seg_t *seg) { double u, px, py; @@ -515,15 +515,15 @@ double ADynamicLight::DistToSeg(const fixedvec3 &pos, seg_t *seg) double seg_dy = seg->v2->fY() - seg->v1->fY(); double seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy; - u = ((FIXED2DBL(pos.x) - seg->v1->fX()) * seg_dx + (FIXED2DBL(pos.y) - seg->v1->fY()) * seg_dy) / seg_length_sq; + u = ((pos.X - seg->v1->fX()) * seg_dx + pos.Y - seg->v1->fY()) * seg_dy / seg_length_sq; if (u < 0.) u = 0.; // clamp the test point to the line segment - if (u > 1.) u = 1.; + else if (u > 1.) u = 1.; px = seg->v1->fX() + (u * seg_dx); py = seg->v1->fY() + (u * seg_dy); - px -= FIXED2DBL(pos.x); - py -= FIXED2DBL(pos.y); + px -= pos.X; + py -= pos.Y; return (px*px) + (py*py); } @@ -536,7 +536,7 @@ double ADynamicLight::DistToSeg(const fixedvec3 &pos, seg_t *seg) // //========================================================================== -void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSec, float radius) +void ADynamicLight::CollectWithinRadius(const DVector3 &pos, subsector_t *subSec, float radius) { if (!subSec) return; @@ -556,7 +556,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe if (seg->sidedef && seg->linedef && seg->linedef->validcount!=::validcount) { // light is in front of the seg - if (DMulScale32(pos.y - seg->v1->fixY(), seg->v2->fixX() - seg->v1->fixX(), seg->v1->fixX() - pos.x, seg->v2->fixY() - seg->v1->fixY()) <= 0) + if ((pos.Y - seg->v1->fixY()) * (seg->v2->fX() - seg->v1->fixX()) + (seg->v1->fX() - pos.X * (seg->v2->fY() - seg->v1->fY())) <= 0) { seg->linedef->validcount = validcount; touching_sides = AddLightNode(&seg->sidedef->lighthead, seg->sidedef, this, touching_sides); @@ -572,8 +572,8 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe line_t *other = port->mDestination; if (other->validcount != ::validcount) { - subsector_t *othersub = R_PointInSubsector(other->v1->fixX() + other->fixDx() / 2, other->v1->fixY() + other->fixDy() / 2); - if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(other), othersub, radius); + subsector_t *othersub = R_PointInSubsector(other->v1->fPos() + other->Delta() / 2); + if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(other), othersub, radius); } } } @@ -599,9 +599,9 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe AActor *sb = subSec->sector->SkyBoxes[sector_t::ceiling]; if (sb->specialf1 < Z() + radius) { - fixedvec2 refpos = { other->v1->fixX() + other->fixDx() / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->fixY() + other->fixDy() / 2 + FLOAT2FIXED(sb->Scale.Y) }; - subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y); - if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(othersub->sector), othersub, radius); + DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sb->Scale; + subsector_t *othersub = R_PointInSubsector(refpos); + if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius); } } if (!subSec->sector->PortalBlocksSight(sector_t::floor)) @@ -610,9 +610,9 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe AActor *sb = subSec->sector->SkyBoxes[sector_t::floor]; if (sb->specialf1 > Z() - radius) { - fixedvec2 refpos = { other->v1->fixX() + other->fixDx() / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->fixY() + other->fixDy() / 2 + FLOAT2FIXED(sb->Scale.Y) }; - subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y); - if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(othersub->sector), othersub, radius); + DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sb->Scale; + subsector_t *othersub = R_PointInSubsector(refpos); + if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius); } } } @@ -649,10 +649,10 @@ void ADynamicLight::LinkLight() if (radius>0) { - // passing in radius*radius allows us to do a distance check without any calls to sqrtf - subsector_t * subSec = R_PointInSubsector(_f_X(), _f_Y()); + // passing in radius*radius allows us to do a distance check without any calls to sqrt + subsector_t * subSec = R_PointInSubsector(Pos()); ::validcount++; - CollectWithinRadius(_f_Pos(), subSec, radius*radius); + CollectWithinRadius(Pos(), subSec, radius*radius); } diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index 076f56ecd..aa3f28ae2 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -99,8 +99,8 @@ public: FLightNode * touching_sector; private: - double DistToSeg(const fixedvec3 &pos, seg_t *seg); - void CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSec, float radius); + double DistToSeg(const DVector3 &pos, seg_t *seg); + void CollectWithinRadius(const DVector3 &pos, subsector_t *subSec, float radius); protected: DVector3 m_off; diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index 926b75aae..debb10cea 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -87,20 +87,16 @@ CUSTOM_CVAR (Bool, gl_lights_additive, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG //========================================================================== bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, bool forceadditive, FDynLightData &ldata) { - Vector fn, pos; int i = 0; - fixedvec3 lpos = light->_f_PosRelative(group); - float x = FIXED2FLOAT(lpos.x); - float y = FIXED2FLOAT(lpos.y); - float z = FIXED2FLOAT(lpos.z); + DVector3 pos = light->PosRelative(group); - float dist = fabsf(p.DistToPoint(x, z, y)); + float dist = fabsf(p.DistToPoint(pos.X, pos.Z, pos.Y)); float radius = (light->GetRadius() * gl_lights_size); if (radius <= 0.f) return false; if (dist > radius) return false; - if (checkside && gl_lights_checkside && p.PointOnSide(x, z, y)) + if (checkside && gl_lights_checkside && p.PointOnSide(pos.X, pos.Z, pos.Y)) { return false; } @@ -133,9 +129,9 @@ bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, bo } float *data = &ldata.arrays[i][ldata.arrays[i].Reserve(8)]; - data[0] = x; - data[1] = z; - data[2] = y; + data[0] = pos.X; + data[1] = pos.Z; + data[2] = pos.Y; data[3] = radius; data[4] = r; data[5] = g; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 5c6766228..b28a0553c 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -599,8 +599,8 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint int i; bool dorotate = rotation != 0; - float cosrot = cos(ToRadians(rotation)); - float sinrot = sin(ToRadians(rotation)); + float cosrot = cos(rotation.Radians()); + float sinrot = sin(rotation.Radians()); //float yoffs = GatheringWipeScreen ? 0 : LBOffset; float uscale = float(1.f / (texture->GetScaledWidth() * scalex)); diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index b9f38ca50..c7bfce854 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -1165,8 +1165,8 @@ void FDrawInfo::FloodUpperGap(seg_t * seg) // Although the plane can be sloped this code will only be called // when the edge itself is not. - fixed_t backz = fakebsector->ceilingplane.ZatPoint(seg->v1); - fixed_t frontz = fakefsector->ceilingplane.ZatPoint(seg->v1); + fixed_t backz = fakebsector->ceilingplane.ZatPoint(seg->v1->x, seg->v1->y); + fixed_t frontz = fakefsector->ceilingplane.ZatPoint(seg->v1->x, seg->v1->y); if (fakebsector->GetTexture(sector_t::ceiling)==skyflatnum) return; if (backz < viewz) return; @@ -1217,8 +1217,8 @@ void FDrawInfo::FloodLowerGap(seg_t * seg) // Although the plane can be sloped this code will only be called // when the edge itself is not. - fixed_t backz = fakebsector->floorplane.ZatPoint(seg->v1); - fixed_t frontz = fakefsector->floorplane.ZatPoint(seg->v1); + fixed_t backz = fakebsector->floorplane.ZatPoint(seg->v1->x, seg->v1->y); + fixed_t frontz = fakefsector->floorplane.ZatPoint(seg->v1->x, seg->v1->y); if (fakebsector->GetTexture(sector_t::floor) == skyflatnum) return; diff --git a/src/gl/scene/gl_fakeflat.cpp b/src/gl/scene/gl_fakeflat.cpp index 101fcc8a3..57da91f63 100644 --- a/src/gl/scene/gl_fakeflat.cpp +++ b/src/gl/scene/gl_fakeflat.cpp @@ -57,14 +57,14 @@ CVAR(Bool, gltest_slopeopt, false, 0) bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsector) { line_t *linedef = sidedef->linedef; - fixed_t bs_floorheight1; - fixed_t bs_floorheight2; - fixed_t bs_ceilingheight1; - fixed_t bs_ceilingheight2; - fixed_t fs_floorheight1; - fixed_t fs_floorheight2; - fixed_t fs_ceilingheight1; - fixed_t fs_ceilingheight2; + double bs_floorheight1; + double bs_floorheight2; + double bs_ceilingheight1; + double bs_ceilingheight2; + double fs_floorheight1; + double fs_floorheight2; + double fs_ceilingheight1; + double fs_ceilingheight2; // Mirrors and horizons always block the view //if (linedef->special==Line_Mirror || linedef->special==Line_Horizon) return true; @@ -82,82 +82,82 @@ bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto if (frontsector->ceilingplane.isSlope()) { - fs_ceilingheight1=frontsector->ceilingplane.ZatPoint(linedef->v1); - fs_ceilingheight2=frontsector->ceilingplane.ZatPoint(linedef->v2); + fs_ceilingheight1 = frontsector->ceilingplane.ZatPoint(linedef->v1); + fs_ceilingheight2 = frontsector->ceilingplane.ZatPoint(linedef->v2); } else { - fs_ceilingheight2=fs_ceilingheight1=frontsector->ceilingplane.fixD(); + fs_ceilingheight2 = fs_ceilingheight1 = frontsector->ceilingplane.fixD(); } if (frontsector->floorplane.isSlope()) { - fs_floorheight1=frontsector->floorplane.ZatPoint(linedef->v1); - fs_floorheight2=frontsector->floorplane.ZatPoint(linedef->v2); + fs_floorheight1 = frontsector->floorplane.ZatPoint(linedef->v1); + fs_floorheight2 = frontsector->floorplane.ZatPoint(linedef->v2); } else { - fs_floorheight2=fs_floorheight1=-frontsector->floorplane.fixD(); + fs_floorheight2 = fs_floorheight1 = -frontsector->floorplane.fixD(); } - + if (backsector->ceilingplane.isSlope()) { - bs_ceilingheight1=backsector->ceilingplane.ZatPoint(linedef->v1); - bs_ceilingheight2=backsector->ceilingplane.ZatPoint(linedef->v2); + bs_ceilingheight1 = backsector->ceilingplane.ZatPoint(linedef->v1); + bs_ceilingheight2 = backsector->ceilingplane.ZatPoint(linedef->v2); } else { - bs_ceilingheight2=bs_ceilingheight1=backsector->ceilingplane.fixD(); + bs_ceilingheight2 = bs_ceilingheight1 = backsector->ceilingplane.fixD(); } if (backsector->floorplane.isSlope()) { - bs_floorheight1=backsector->floorplane.ZatPoint(linedef->v1); - bs_floorheight2=backsector->floorplane.ZatPoint(linedef->v2); + bs_floorheight1 = backsector->floorplane.ZatPoint(linedef->v1); + bs_floorheight2 = backsector->floorplane.ZatPoint(linedef->v2); } else { - bs_floorheight2=bs_floorheight1=-backsector->floorplane.fixD(); + bs_floorheight2 = bs_floorheight1 = -backsector->floorplane.fixD(); } // now check for closed sectors! - if (bs_ceilingheight1<=fs_floorheight1 && bs_ceilingheight2<=fs_floorheight2) + if (bs_ceilingheight1 <= fs_floorheight1 && bs_ceilingheight2 <= fs_floorheight2) { FTexture * tex = TexMan(sidedef->GetTexture(side_t::top)); - if (!tex || tex->UseType==FTexture::TEX_Null) return false; - if (backsector->GetTexture(sector_t::ceiling)==skyflatnum && - frontsector->GetTexture(sector_t::ceiling)==skyflatnum) return false; + if (!tex || tex->UseType == FTexture::TEX_Null) return false; + if (backsector->GetTexture(sector_t::ceiling) == skyflatnum && + frontsector->GetTexture(sector_t::ceiling) == skyflatnum) return false; return true; } - if (fs_ceilingheight1<=bs_floorheight1 && fs_ceilingheight2<=bs_floorheight2) + if (fs_ceilingheight1 <= bs_floorheight1 && fs_ceilingheight2 <= bs_floorheight2) { FTexture * tex = TexMan(sidedef->GetTexture(side_t::bottom)); - if (!tex || tex->UseType==FTexture::TEX_Null) return false; + if (!tex || tex->UseType == FTexture::TEX_Null) return false; // properly render skies (consider door "open" if both floors are sky): - if (backsector->GetTexture(sector_t::ceiling)==skyflatnum && - frontsector->GetTexture(sector_t::ceiling)==skyflatnum) return false; + if (backsector->GetTexture(sector_t::ceiling) == skyflatnum && + frontsector->GetTexture(sector_t::ceiling) == skyflatnum) return false; return true; } - if (bs_ceilingheight1<=bs_floorheight1 && bs_ceilingheight2<=bs_floorheight2) + if (bs_ceilingheight1 <= bs_floorheight1 && bs_ceilingheight2 <= bs_floorheight2) { // preserve a kind of transparent door/lift special effect: - if (bs_ceilingheight1 < fs_ceilingheight1 || bs_ceilingheight2 < fs_ceilingheight2) + if (bs_ceilingheight1 < fs_ceilingheight1 || bs_ceilingheight2 < fs_ceilingheight2) { FTexture * tex = TexMan(sidedef->GetTexture(side_t::top)); - if (!tex || tex->UseType==FTexture::TEX_Null) return false; + if (!tex || tex->UseType == FTexture::TEX_Null) return false; } if (bs_floorheight1 > fs_floorheight1 || bs_floorheight2 > fs_floorheight2) { FTexture * tex = TexMan(sidedef->GetTexture(side_t::bottom)); - if (!tex || tex->UseType==FTexture::TEX_Null) return false; + if (!tex || tex->UseType == FTexture::TEX_Null) return false; } - if (backsector->GetTexture(sector_t::ceiling)==skyflatnum && - frontsector->GetTexture(sector_t::ceiling)==skyflatnum) return false; - if (backsector->GetTexture(sector_t::floor)==skyflatnum && frontsector->GetTexture(sector_t::floor) - ==skyflatnum) return false; + if (backsector->GetTexture(sector_t::ceiling) == skyflatnum && + frontsector->GetTexture(sector_t::ceiling) == skyflatnum) return false; + if (backsector->GetTexture(sector_t::floor) == skyflatnum && frontsector->GetTexture(sector_t::floor) + == skyflatnum) return false; return true; } @@ -172,22 +172,22 @@ bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto void gl_CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector) { - if (in_area==area_default && + if (in_area == area_default && (backsector->heightsec && !(backsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) && (!frontsector->heightsec || frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) { sector_t * s = backsector->heightsec; - fixed_t cz1 = frontsector->ceilingplane.ZatPoint(v1); - fixed_t cz2 = frontsector->ceilingplane.ZatPoint(v2); - fixed_t fz1 = s->floorplane.ZatPoint(v1); - fixed_t fz2 = s->floorplane.ZatPoint(v2); + double cz1 = frontsector->ceilingplane.ZatPoint(v1); + double cz2 = frontsector->ceilingplane.ZatPoint(v2); + double fz1 = s->floorplane.ZatPoint(v1); + double fz2 = s->floorplane.ZatPoint(v2); // allow some tolerance in case slopes are involved - if (cz1 <= fz1 + FRACUNIT/100 && cz2<=fz2 + FRACUNIT/100) - in_area=area_below; - else - in_area=area_normal; + if (cz1 <= fz1 + 1. / 100 && cz2 <= fz2 + 1. / 100) + in_area = area_below; + else + in_area = area_normal; } } diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 29602fbd2..106d7adfb 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -93,7 +93,7 @@ void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * glte { yscale1 = 0 - yscale1; } - float angle=-ANGLE2FLOAT(secplane->angle); + float angle=-AngleToFloat(secplane->angle); float xscale2=64.f/gltexture->TextureWidth(); float yscale2=64.f/gltexture->TextureHeight(); @@ -142,10 +142,10 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli) // we must do the side check here because gl_SetupLight needs the correct plane orientation // which we don't have for Legacy-style 3D-floors - fixed_t planeh = plane.plane.ZatPoint(light); - if (gl_lights_checkside && ((planeh_f_Z() && ceiling) || (planeh>light->_f_Z() && !ceiling))) + double planeh = plane.plane.ZatPoint(light); + if (gl_lights_checkside && ((planehZ() && ceiling) || (planeh>light->Z() && !ceiling))) { - node=node->nextLight; + node = node->nextLight; continue; } @@ -666,7 +666,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) if (rover->flags&FF_FOG && gl_fixedcolormap) continue; if (!rover->top.copied && rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) { - fixed_t ff_top=rover->top.plane->ZatPoint(sector->centerspot); + fixed_t ff_top=FLOAT2FIXED(rover->top.plane->ZatPoint(sector->centerspot)); if (ff_toptop.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) @@ -680,7 +680,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) } if (!rover->bottom.copied && !(rover->flags&FF_INVERTPLANES)) { - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sector->centerspot); + fixed_t ff_bottom=FLOAT2FIXED(rover->bottom.plane->ZatPoint(sector->centerspot)); if (ff_bottombottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) @@ -706,7 +706,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) if (rover->flags&FF_FOG && gl_fixedcolormap) continue; if (!rover->bottom.copied && rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) { - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sector->centerspot); + fixed_t ff_bottom=FLOAT2FIXED(rover->bottom.plane->ZatPoint(sector->centerspot)); if (ff_bottom>lastfloorheight || (rover->flags&FF_FIX)) { if (FIXED2FLOAT(viewz) >= rover->bottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) @@ -727,7 +727,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) } if (!rover->top.copied && !(rover->flags&FF_INVERTPLANES)) { - fixed_t ff_top=rover->top.plane->ZatPoint(sector->centerspot); + fixed_t ff_top=FLOAT2FIXED(rover->top.plane->ZatPoint(sector->centerspot)); if (ff_top>lastfloorheight) { if (FIXED2FLOAT(viewz) >= rover->top.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 0c4f04db3..6b47266e8 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -659,11 +659,11 @@ void GLSkyboxPortal::DrawContents() viewx = FLOAT2FIXED(viewpos.X); viewy = FLOAT2FIXED(viewpos.Y); viewz = FLOAT2FIXED(viewpos.Z); - viewangle += (origin->PrevAngles.Yaw + deltaangle(origin->PrevAngles.Yaw, origin->Angles.Yaw) * FIXED2DBL(r_TicFrac)).BAMs(); + viewangle += (origin->PrevAngles.Yaw + deltaangle(origin->PrevAngles.Yaw, origin->Angles.Yaw) * r_TicFracF).BAMs(); // Don't let the viewpoint be too close to a floor or ceiling - fixed_t floorh = origin->Sector->floorplane.ZatPoint(origin); - fixed_t ceilh = origin->Sector->ceilingplane.ZatPoint(origin); + fixed_t floorh = origin->Sector->floorplane.ZatPoint(origin->_f_Pos()); + fixed_t ceilh = origin->Sector->ceilingplane.ZatPoint(origin->_f_Pos()); if (viewzceilh-4*FRACUNIT) viewz=ceilh-4*FRACUNIT; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 1821c1fdf..4a4c42d8d 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -118,7 +118,7 @@ angle_t FGLRenderer::FrustumAngle() // ok, this is a gross hack that barely works... // but at least it doesn't overestimate too much... double floatangle=2.0+(45.0+((tilt/1.9)))*mCurrentFoV*48.0/BaseRatioSizes[WidescreenRatio][3]/90.0; - angle_t a1 = FLOAT2ANGLE(floatangle); + angle_t a1 = DAngle(floatangle).BAMs(); if (a1>=ANGLE_180) return 0xffffffff; return a1; } @@ -771,7 +771,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo SetViewArea(); // We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1. - double radPitch = ANGLE2RAD(viewpitch); + double radPitch = (viewpitch)* M_PI / 0x80000000; if (radPitch > PI) radPitch -= 2 * PI; radPitch = clamp(radPitch, -PI / 2, PI / 2); @@ -865,8 +865,8 @@ void FGLRenderer::RenderView (player_t* player) ResetProfilingData(); // Get this before everything else - if (cl_capfps || r_NoInterpolate) r_TicFrac = FRACUNIT; - else r_TicFrac = I_GetTimeFrac (&r_FrameTime); + if (cl_capfps || r_NoInterpolate) r_TicFracF = 1.; + else r_TicFracF = I_GetTimeFrac (&r_FrameTime); gl_frameMS = I_MSTime(); P_FindParticleSubsectors (); diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 3180b0ecf..864a0d281 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -92,7 +92,7 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor) texture[0] = FMaterial::ValidateTexture(texno, false, true); if (!texture[0] || texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky; skytexno1 = texno; - x_offset[0] = ANGLE2FLOAT(s->GetTextureXOffset(pos)); + x_offset[0] = AngleToFloat(s->GetTextureXOffset(pos)); y_offset = FIXED2FLOAT(s->GetTextureYOffset(pos)); mirrored = !l->args[2]; } @@ -279,7 +279,7 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex { ztop[0]=ztop[1]=32768.0f; zbottom[0]=zbottom[1]= - FIXED2FLOAT(bs->ceilingplane.ZatPoint(v2) + seg->sidedef->GetTextureYOffset(side_t::mid)); + bs->ceilingplane.ZatPoint(v2) + seg->sidedef->GetTextureYOffsetF(side_t::mid); SkyPlane(fs, sector_t::ceiling, false); return; } @@ -298,8 +298,8 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex } else { - zbottom[0]=FIXED2FLOAT(bs->ceilingplane.ZatPoint(v1)); - zbottom[1]=FIXED2FLOAT(bs->ceilingplane.ZatPoint(v2)); + zbottom[0] = bs->ceilingplane.ZatPoint(v1); + zbottom[1] = bs->ceilingplane.ZatPoint(v2); flags|=GLWF_SKYHACK; // mid textures on such lines need special treatment! } } @@ -324,12 +324,10 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex } // stacked sectors - fixed_t fsc1=fs->ceilingplane.ZatPoint(v1); - fixed_t fsc2=fs->ceilingplane.ZatPoint(v2); + ztop[0] = ztop[1] = 32768.0f; + zbottom[0] = fs->ceilingplane.ZatPoint(v1); + zbottom[1] = fs->ceilingplane.ZatPoint(v2); - ztop[0]=ztop[1]=32768.0f; - zbottom[0]=FIXED2FLOAT(fsc1); - zbottom[1]=FIXED2FLOAT(fsc2); } SkyPlane(fs, sector_t::ceiling, true); @@ -375,8 +373,8 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver } else { - ztop[0]=FIXED2FLOAT(bs->floorplane.ZatPoint(v1)); - ztop[1]=FIXED2FLOAT(bs->floorplane.ZatPoint(v2)); + ztop[0] = bs->floorplane.ZatPoint(v1); + ztop[1] = bs->floorplane.ZatPoint(v2); flags|=GLWF_SKYHACK; // mid textures on such lines need special treatment! } } @@ -401,12 +399,9 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver } // stacked sectors - fixed_t fsc1=fs->floorplane.ZatPoint(v1); - fixed_t fsc2=fs->floorplane.ZatPoint(v2); - zbottom[0]=zbottom[1]=-32768.0f; - ztop[0]=FIXED2FLOAT(fsc1); - ztop[1]=FIXED2FLOAT(fsc2); + ztop[0] = fs->floorplane.ZatPoint(v1); + ztop[1] = fs->floorplane.ZatPoint(v2); } SkyPlane(fs, sector_t::floor, true); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 30d5baecc..5dbaa7fec 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -282,7 +282,7 @@ void GLSprite::Draw(int pass) float xcenter = (x1 + x2)*0.5; float ycenter = (y1 + y2)*0.5; float zcenter = (z1 + z2)*0.5; - float angleRad = ToRadians(270. - GLRenderer->mAngles.Yaw); + float angleRad = (270. - GLRenderer->mAngles.Yaw).Radians(); Matrix3x4 mat; mat.MakeIdentity(); @@ -423,7 +423,7 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_ } } if (btm == 1000000.0f) - btm = FIXED2FLOAT(thing->Sector->floorplane.ZatPoint(thing)) - thing->Floorclip; + btm = thing->Sector->floorplane.ZatPoint(thing) - thing->Floorclip; if (top == -1000000.0f) top = FIXED2FLOAT(thing->Sector->ceilingplane.ZatPoint(thingx, thingy)); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 25ba616df..4a560e107 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1105,8 +1105,8 @@ __forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, fixed_t &le { if (planeref->plane->isSlope()) { - left=planeref->plane->ZatPoint(vertexes[0]); - right=planeref->plane->ZatPoint(vertexes[1]); + left=planeref->plane->ZatPoint(vertexes[0]->x, vertexes[0]->y); + right=planeref->plane->ZatPoint(vertexes[1]->x, vertexes[1]->y); } else if(planeref->isceiling == sector_t::ceiling) { @@ -1452,8 +1452,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) // Save a little time (up to 0.3 ms per frame ;) ) if (frontsector->floorplane.isSlope()) { - ffh1 = segfront->floorplane.ZatPoint(v1); - ffh2 = segfront->floorplane.ZatPoint(v2); + ffh1 = segfront->floorplane.ZatPoint(v1->x, v1->y); + ffh2 = segfront->floorplane.ZatPoint(v2->x, v2->y); zfloor[0] = FIXED2FLOAT(ffh1); zfloor[1] = FIXED2FLOAT(ffh2); } @@ -1465,8 +1465,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (segfront->ceilingplane.isSlope()) { - fch1 = segfront->ceilingplane.ZatPoint(v1); - fch2 = segfront->ceilingplane.ZatPoint(v2); + fch1 = segfront->ceilingplane.ZatPoint(v1->x, v1->y); + fch2 = segfront->ceilingplane.ZatPoint(v2->x, v2->y); zceil[0] = FIXED2FLOAT(fch1); zceil[1] = FIXED2FLOAT(fch2); } @@ -1522,8 +1522,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (segback->floorplane.isSlope()) { - bfh1 = segback->floorplane.ZatPoint(v1); - bfh2 = segback->floorplane.ZatPoint(v2); + bfh1 = segback->floorplane.ZatPoint(v1->x, v1->y); + bfh2 = segback->floorplane.ZatPoint(v2->x, v2->y); } else { @@ -1532,8 +1532,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (segback->ceilingplane.isSlope()) { - bch1 = segback->ceilingplane.ZatPoint(v1); - bch2 = segback->ceilingplane.ZatPoint(v2); + bch1 = segback->ceilingplane.ZatPoint(v1->x, v1->y); + bch2 = segback->ceilingplane.ZatPoint(v2->x, v2->y); } else { diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 54e47386c..5d5a1a7c3 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -346,8 +346,8 @@ void GLWall::RenderTextured(int rflags) { secplane_t &lowplane = i == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[i + 1].plane; // this must use the exact same calculation method as GLWall::Process etc. - float low1 = FIXED2FLOAT(lowplane.ZatPoint(vertexes[0])); - float low2 = FIXED2FLOAT(lowplane.ZatPoint(vertexes[1])); + float low1 = lowplane.ZatPoint(vertexes[0]); + float low2 = lowplane.ZatPoint(vertexes[1]); if (low1 < ztop[0] || low2 < ztop[1]) { diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp index ac83811fa..c6be1c813 100644 --- a/src/gl/utility/gl_clock.cpp +++ b/src/gl/utility/gl_clock.cpp @@ -185,7 +185,7 @@ void CheckBench() compose.Format("Map %s: \"%s\",\nx = %1.4f, y = %1.4f, z = %1.4f, angle = %1.4f, pitch = %1.4f\n", level.MapName.GetChars(), level.LevelName.GetChars(), FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz), - ANGLE2FLOAT(viewangle), ANGLE2FLOAT(viewpitch)); + AngleToFloat(viewangle), AngleToFloat(viewpitch)); AppendRenderStats(compose); AppendRenderTimes(compose); diff --git a/src/r_defs.h b/src/r_defs.h index 10fa01beb..78fd9e157 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -104,7 +104,7 @@ typedef double vtype; struct vertex_t { -private: +//private: fixed_t x, y; public: @@ -998,15 +998,15 @@ struct sector_t for (unsigned i = 0; i < e->XFloor.attached.Size(); i++) e->XFloor.attached[i]->SetVerticesDirty(); } - void SetPlaneTexZ(int pos, fixed_t val, bool dirtify = false) // This mainly gets used by init code. The only place where it must set the vertex to dirty is the interpolation code. + void SetPlaneTexZ(int pos, fixed_t val) { planes[pos].TexZ = val; - if (dirtify) SetAllVerticesDirty(); } - void SetPlaneTexZ(int pos, double val) + void SetPlaneTexZ(int pos, double val, bool dirtify = false) // This mainly gets used by init code. The only place where it must set the vertex to dirty is the interpolation code. { planes[pos].TexZ = FLOAT2FIXED(val); + if (dirtify) SetAllVerticesDirty(); } void ChangePlaneTexZ(int pos, fixed_t val) diff --git a/src/r_utility.h b/src/r_utility.h index b3cfb10ad..87599faa6 100644 --- a/src/r_utility.h +++ b/src/r_utility.h @@ -72,6 +72,11 @@ struct DVector3a subsector_t *R_PointInSubsector (fixed_t x, fixed_t y); +inline subsector_t *R_PointInSubsector(const DVector2 &pos) +{ + return R_PointInSubsector(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y)); +} + fixed_t R_PointToDist2 (fixed_t dx, fixed_t dy); void R_ResetViewInterpolation (); void R_RebuildViewInterpolation(player_t *player); From c6ada2397c72abbe74f0a1d00b80fa34073d0ac0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 31 Mar 2016 09:50:59 +0200 Subject: [PATCH 0441/1509] - adjustments. --- src/gl/scene/gl_fakeflat.cpp | 8 ++++---- src/gl/scene/gl_flats.cpp | 28 ++++++++++++++-------------- src/gl/scene/gl_portal.cpp | 6 +++--- src/gl/scene/gl_sky.cpp | 4 ++-- src/gl/scene/gl_wall.h | 20 ++++++++++---------- src/gl/scene/gl_walls.cpp | 12 ++++++------ 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/gl/scene/gl_fakeflat.cpp b/src/gl/scene/gl_fakeflat.cpp index 57da91f63..29f2f52a3 100644 --- a/src/gl/scene/gl_fakeflat.cpp +++ b/src/gl/scene/gl_fakeflat.cpp @@ -87,7 +87,7 @@ bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto } else { - fs_ceilingheight2 = fs_ceilingheight1 = frontsector->ceilingplane.fixD(); + fs_ceilingheight2 = fs_ceilingheight1 = frontsector->ceilingplane.fD(); } if (frontsector->floorplane.isSlope()) @@ -97,7 +97,7 @@ bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto } else { - fs_floorheight2 = fs_floorheight1 = -frontsector->floorplane.fixD(); + fs_floorheight2 = fs_floorheight1 = -frontsector->floorplane.fD(); } if (backsector->ceilingplane.isSlope()) @@ -107,7 +107,7 @@ bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto } else { - bs_ceilingheight2 = bs_ceilingheight1 = backsector->ceilingplane.fixD(); + bs_ceilingheight2 = bs_ceilingheight1 = backsector->ceilingplane.fD(); } if (backsector->floorplane.isSlope()) @@ -117,7 +117,7 @@ bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto } else { - bs_floorheight2 = bs_floorheight1 = -backsector->floorplane.fixD(); + bs_floorheight2 = bs_floorheight1 = -backsector->floorplane.fD(); } // now check for closed sectors! diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 106d7adfb..8e825ab5b 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -78,31 +78,31 @@ static float tics; void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * gltexture) { // only manipulate the texture matrix if needed. - if (secplane->xoffs != 0 || secplane->yoffs != 0 || - secplane->xscale != FRACUNIT || secplane->yscale != FRACUNIT || - secplane->angle != 0 || + if (!secplane->Offs.isZero() || + secplane->Scale.X != 1. || secplane->Scale.Y != 1 || + secplane->Angle != 0 || gltexture->TextureWidth() != 64 || gltexture->TextureHeight() != 64) { - float uoffs = FIXED2FLOAT(secplane->xoffs) / gltexture->TextureWidth(); - float voffs = FIXED2FLOAT(secplane->yoffs) / gltexture->TextureHeight(); + float uoffs = secplane->Offs.X / gltexture->TextureWidth(); + float voffs = secplane->Offs.Y / gltexture->TextureHeight(); - float xscale1=FIXED2FLOAT(secplane->xscale); - float yscale1=FIXED2FLOAT(secplane->yscale); + float xscale1 = secplane->Scale.X; + float yscale1 = secplane->Scale.Y; if (gltexture->tex->bHasCanvas) { yscale1 = 0 - yscale1; } - float angle=-AngleToFloat(secplane->angle); + float angle = -secplane->Angle; - float xscale2=64.f/gltexture->TextureWidth(); - float yscale2=64.f/gltexture->TextureHeight(); + float xscale2 = 64.f / gltexture->TextureWidth(); + float yscale2 = 64.f / gltexture->TextureHeight(); gl_RenderState.mTextureMatrix.loadIdentity(); - gl_RenderState.mTextureMatrix.scale(xscale1 ,yscale1,1.0f); - gl_RenderState.mTextureMatrix.translate(uoffs,voffs,0.0f); - gl_RenderState.mTextureMatrix.scale(xscale2 ,yscale2,1.0f); - gl_RenderState.mTextureMatrix.rotate(angle,0.0f,0.0f,1.0f); + gl_RenderState.mTextureMatrix.scale(xscale1, yscale1, 1.0f); + gl_RenderState.mTextureMatrix.translate(uoffs, voffs, 0.0f); + gl_RenderState.mTextureMatrix.scale(xscale2, yscale2, 1.0f); + gl_RenderState.mTextureMatrix.rotate(angle, 0.0f, 0.0f, 1.0f); gl_RenderState.EnableTextureMatrix(true); } } diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 6b47266e8..bc57674ca 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -1115,7 +1115,7 @@ void GLHorizonPortal::DrawContents() gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); - z=FIXED2FLOAT(sp->texheight); + z=sp->Texheight; if (gltexture && gltexture->tex->isFullbright()) @@ -1238,7 +1238,7 @@ void GLEEHorizonPortal::DrawContents() horz.colormap = origin->Sector->ColorMap; if (origin->special1 == SKYBOX_PLANE) { - horz.plane.texheight = viewz + abs(horz.plane.texheight); + horz.plane.Texheight = FIXED2FLOAT(viewz) + fabs(horz.plane.Texheight); } GLHorizonPortal ceil(&horz, true); ceil.DrawContents(); @@ -1251,7 +1251,7 @@ void GLEEHorizonPortal::DrawContents() horz.colormap = origin->Sector->ColorMap; if (origin->special1 == SKYBOX_PLANE) { - horz.plane.texheight = viewz - abs(horz.plane.texheight); + horz.plane.Texheight = FIXED2FLOAT(viewz) - fabs(horz.plane.Texheight); } GLHorizonPortal floor(&horz, true); floor.DrawContents(); diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 864a0d281..c04b90129 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -173,8 +173,8 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) } else if (allowreflect && sector->GetReflect(plane) > 0) { - if ((plane == sector_t::ceiling && viewz > sector->ceilingplane.fixD()) || - (plane == sector_t::floor && viewz < -sector->floorplane.fixD())) return; + if ((plane == sector_t::ceiling && FIXED2DBL(viewz) > sector->ceilingplane.fD()) || + (plane == sector_t::floor && FIXED2DBL(viewz) < -sector->floorplane.fD())) return; ptype = PORTALTYPE_PLANEMIRROR; planemirror = plane == sector_t::ceiling ? §or->ceilingplane : §or->floorplane; } diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 91567ecb5..d71cccba5 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -72,21 +72,21 @@ struct GLSectorPlane { FTextureID texture; secplane_t plane; - fixed_t texheight; - fixed_t xoffs, yoffs; - fixed_t xscale, yscale; - angle_t angle; + float Texheight; + float Angle; + FVector2 Offs; + FVector2 Scale; void GetFromSector(sector_t * sec, int ceiling) { - xoffs = sec->GetXOffset(ceiling); - yoffs = sec->GetYOffset(ceiling); - xscale = sec->GetXScale(ceiling); - yscale = sec->GetYScale(ceiling); - angle = sec->GetAngle(ceiling); + Offs.X = (float)sec->GetXOffsetF(ceiling); + Offs.Y = (float)sec->GetYOffsetF(ceiling); + Scale.X = (float)sec->GetXScaleF(ceiling); + Scale.Y = (float)sec->GetYScaleF(ceiling); + Angle = (float)sec->GetAngleF(ceiling).Degrees; texture = sec->GetTexture(ceiling); plane = sec->GetSecPlane(ceiling); - texheight = (ceiling == sector_t::ceiling)? plane.fixD() : -plane.fixD(); + Texheight = (float)((ceiling == sector_t::ceiling)? plane.fD() : -plane.fD()); } }; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 4a560e107..590e7734f 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1110,11 +1110,11 @@ __forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, fixed_t &le } else if(planeref->isceiling == sector_t::ceiling) { - left = right = planeref->plane->fixD(); + left = right = FLOAT2FIXED(planeref->plane->fD()); } else { - left = right = -planeref->plane->fixD(); + left = right = -FLOAT2FIXED(planeref->plane->fD()); } } @@ -1459,7 +1459,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else { - ffh1 = ffh2 = -segfront->floorplane.fixD(); + ffh1 = ffh2 = -FLOAT2FIXED(segfront->floorplane.fD()); zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh2); } @@ -1472,7 +1472,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else { - fch1 = fch2 = segfront->ceilingplane.fixD(); + fch1 = fch2 = FLOAT2FIXED(segfront->ceilingplane.fD()); zceil[0] = zceil[1] = FIXED2FLOAT(fch2); } @@ -1527,7 +1527,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else { - bfh1 = bfh2 = -segback->floorplane.fixD(); + bfh1 = bfh2 = -FLOAT2FIXED(segback->floorplane.fD()); } if (segback->ceilingplane.isSlope()) @@ -1537,7 +1537,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else { - bch1 = bch2 = segback->ceilingplane.fixD(); + bch1 = bch2 = FLOAT2FIXED(segback->ceilingplane.fD()); } SkyTop(seg, frontsector, backsector, v1, v2); From a27181cb0b1fc700202fb8c8da10f3e70fb04cf2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 31 Mar 2016 21:42:27 +0200 Subject: [PATCH 0442/1509] - partial adjustments. No point changing all the viewx/y/z stuff when that is about to get floatified next. --- src/gl/dynlights/gl_glow.cpp | 14 +++++++------- src/gl/dynlights/gl_glow.h | 2 +- src/gl/scene/gl_portal.cpp | 34 +++++++++++++++++----------------- src/gl/scene/gl_portal.h | 8 ++++---- src/gl/scene/gl_sprite.cpp | 6 +++--- src/gl/scene/gl_walls.cpp | 4 ++-- src/gl/scene/gl_weapon.cpp | 2 +- 7 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/gl/dynlights/gl_glow.cpp b/src/gl/dynlights/gl_glow.cpp index ce763109d..eee1788dc 100644 --- a/src/gl/dynlights/gl_glow.cpp +++ b/src/gl/dynlights/gl_glow.cpp @@ -119,19 +119,19 @@ void gl_InitGlow(FScanner &sc) // Checks whether a sprite should be affected by a glow // //========================================================================== -int gl_CheckSpriteGlow(sector_t *sec, int lightlevel, int x, int y, int z) +int gl_CheckSpriteGlow(sector_t *sec, int lightlevel, const DVector3 &pos) { FTextureID floorpic = sec->GetTexture(sector_t::floor); FTexture *tex = TexMan[floorpic]; if (tex != NULL && tex->isGlowing()) { - fixed_t floordiff = z - sec->floorplane.ZatPoint(x, y); - if (floordiff < tex->gl_info.GlowHeight*FRACUNIT && tex->gl_info.GlowHeight != 0) + double floordiff = pos.Z - sec->floorplane.ZatPoint(pos); + if (floordiff < tex->gl_info.GlowHeight && tex->gl_info.GlowHeight != 0) { - int maxlight = (255+lightlevel)>>1; - fixed_t lightfrac = floordiff / tex->gl_info.GlowHeight; - if (lightfrac<0) lightfrac=0; - lightlevel= (lightfrac*lightlevel + maxlight*(FRACUNIT-lightfrac))>>FRACBITS; + int maxlight = (255 + lightlevel) >> 1; + double lightfrac = floordiff / tex->gl_info.GlowHeight; + if (lightfrac < 0) lightfrac = 0; + lightlevel = int(lightfrac*lightlevel + maxlight*(1 - lightfrac)); } } return lightlevel; diff --git a/src/gl/dynlights/gl_glow.h b/src/gl/dynlights/gl_glow.h index bc3235685..7d9ae9f7f 100644 --- a/src/gl/dynlights/gl_glow.h +++ b/src/gl/dynlights/gl_glow.h @@ -5,6 +5,6 @@ struct sector_t; void gl_InitGlow(const char * lumpnm); -int gl_CheckSpriteGlow(sector_t *sec, int lightlevel, int x, int y, int z); +int gl_CheckSpriteGlow(sector_t *sec, int lightlevel, const DVector3 &pos); #endif diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index bc57674ca..860c822bc 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -639,55 +639,55 @@ void GLPortal::RestoreMapSection() static int skyboxrecursion=0; void GLSkyboxPortal::DrawContents() { - int old_pm=PlaneMirrorMode; + int old_pm = PlaneMirrorMode; int saved_extralight = extralight; - if (skyboxrecursion>=3) + if (skyboxrecursion >= 3) { ClearScreen(); return; } skyboxrecursion++; - origin->flags|=MF_JUSTHIT; + origin->flags |= MF_JUSTHIT; extralight = 0; - PlaneMirrorMode=0; + PlaneMirrorMode = 0; bool oldclamp = gl_RenderState.SetDepthClamp(false); DVector3 viewpos = origin->InterpolatedPosition(r_TicFracF); - viewx = FLOAT2FIXED(viewpos.X); - viewy = FLOAT2FIXED(viewpos.Y); - viewz = FLOAT2FIXED(viewpos.Z); viewangle += (origin->PrevAngles.Yaw + deltaangle(origin->PrevAngles.Yaw, origin->Angles.Yaw) * r_TicFracF).BAMs(); // Don't let the viewpoint be too close to a floor or ceiling - fixed_t floorh = origin->Sector->floorplane.ZatPoint(origin->_f_Pos()); - fixed_t ceilh = origin->Sector->ceilingplane.ZatPoint(origin->_f_Pos()); - if (viewzceilh-4*FRACUNIT) viewz=ceilh-4*FRACUNIT; + double floorh = origin->Sector->floorplane.ZatPoint(origin->Pos()); + double ceilh = origin->Sector->ceilingplane.ZatPoint(origin->Pos()); + if (viewpos.Z < floorh + 4) viewpos.Z = floorh + 4; + if (viewpos.Z > ceilh - 4) viewz = ceilh - 4; + viewx = FLOAT2FIXED(viewpos.X); + viewy = FLOAT2FIXED(viewpos.Y); + viewz = FLOAT2FIXED(viewpos.Z); GLRenderer->mViewActor = origin; validcount++; - inskybox=true; - GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + inskybox = true; + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); GLRenderer->SetViewArea(); ClearClipper(); int mapsection = R_PointInSubsector(viewx, viewy)->mapsection; SaveMapSection(); - currentmapsection[mapsection>>3] |= 1 << (mapsection & 7); + currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7); GLRenderer->DrawScene(); - origin->flags&=~MF_JUSTHIT; - inskybox=false; + origin->flags &= ~MF_JUSTHIT; + inskybox = false; gl_RenderState.SetDepthClamp(oldclamp); skyboxrecursion--; - PlaneMirrorMode=old_pm; + PlaneMirrorMode = old_pm; extralight = saved_extralight; RestoreMapSection(); diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 22955a911..ca22d2d05 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -186,8 +186,8 @@ struct GLLinePortal : public GLPortal { v1 = line->v1; v2 = line->v2; - dx = line->fixDx(); - dy = line->fixDy(); + dx = FLOAT2FIXED(line->Delta().X); + dy = FLOAT2FIXED(line->Delta().Y); } GLLinePortal(FGLLinePortal *line) @@ -198,8 +198,8 @@ struct GLLinePortal : public GLPortal line_t *lline = line->reference->mDestination; v1 = lline->v1; v2 = lline->v2; - dx = lline->fixDy(); - dy = lline->fixDy(); + dx = FLOAT2FIXED(lline->Delta().X); + dy = FLOAT2FIXED(lline->Delta().Y); } else { diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 5dbaa7fec..1ffd07c2d 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -532,8 +532,8 @@ void GLSprite::Process(AActor* thing,sector_t * sector) { if (!(thing->flags7 & MF7_FLYCHEAT) && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) { - fixed_t clipdist = FLOAT2FIXED(clamp(thing->Speed, thing->target->radius, thing->target->radius*2)); - if (P_AproxDistance(FLOAT2FIXED(thingpos.X)-viewx, FLOAT2FIXED(thingpos.Y)-viewy) < clipdist) return; + double clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius*2); + if (P_AproxDistance(thingpos.X-viewx, thingpos.Y-viewy) < clipdist) return; } thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again. } @@ -660,7 +660,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) rendersector->GetCeilingLight() : rendersector->GetFloorLight()); foglevel = (BYTE)clamp(rendersector->lightlevel, 0, 255); - lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y), FLOAT2FIXED(thingpos.Z)); + lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, thingpos); ThingColor = (thing->RenderStyle.Flags & STYLEF_ColorIsFixed) ? thing->fillcolor : 0xffffff; ThingColor.a = 255; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 590e7734f..683f83de5 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -134,8 +134,8 @@ void GLWall::PutWall(bool translucent) if (translucent) // translucent walls { - viewdistance = P_AproxDistance(((seg->linedef->v1->fixX() + seg->linedef->v2->fixX()) >> 1) - viewx, - ((seg->linedef->v1->fixY() + seg->linedef->v2->fixY()) >> 1) - viewy); + viewdistance = P_AproxDistance(((seg->linedef->v1->fX() + seg->linedef->v2->fX()) /2) - viewx, + ((seg->linedef->v1->fY() + seg->linedef->v2->fY()) /2) - viewy); gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this); } else diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 0712ae328..5ed442318 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -250,7 +250,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) lightlevel = (1.0 - min_L) * 255; } - lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->_f_X(), playermo->_f_Y(), playermo->_f_Z()); + lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->Pos()); // calculate colormap for weapon sprites if (viewsector->e->XFloor.ffloors.Size() && !glset.nocoloredspritelighting) From 348c384bb63ddbaf295d73703574187f804450d6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 1 Apr 2016 18:07:18 +0200 Subject: [PATCH 0443/1509] - fixed scaling of skies with unusual dimensions. --- src/gl/scene/gl_clipper.cpp | 2 +- src/gl/scene/gl_skydome.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_clipper.cpp b/src/gl/scene/gl_clipper.cpp index c6f8d9019..388048181 100644 --- a/src/gl/scene/gl_clipper.cpp +++ b/src/gl/scene/gl_clipper.cpp @@ -379,7 +379,7 @@ angle_t Clipper::AngleToPseudo(angle_t ang) // // ! Returns the pseudoangle between the line p1 to (infinity, p1.y) and the // line from p1 to p2. The pseudoangle has the property that the ordering of -// points by true angle anround p1 and ordering of points by pseudoangle are the +// points by true angle around p1 and ordering of points by pseudoangle are the // same. // // For clipping exact angles are not needed. Only the ordering matters. diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 59b0f634d..37950ae72 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -276,7 +276,7 @@ void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, in gl_RenderState.mModelMatrix.loadIdentity(); gl_RenderState.mModelMatrix.rotate(-180.0f+x_offset, 0.f, 1.f, 0.f); - float xscale = 1024.f / float(texw); + float xscale = texw < 1024.f ? floor(1024.f / float(texw)) : 1.f; float yscale = 1.f; if (texh < 128) { From af78937a15e06fd1ca72031dcf52ead26ff96c76 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 2 Apr 2016 23:17:16 +0200 Subject: [PATCH 0444/1509] - updated GL renderer. --- src/gl/data/gl_data.h | 3 +- src/gl/data/gl_portaldata.cpp | 21 ++- src/gl/renderer/gl_renderer.h | 6 +- src/gl/scene/gl_clipper.cpp | 12 +- src/gl/scene/gl_clipper.h | 5 +- src/gl/scene/gl_drawinfo.cpp | 74 +++++----- src/gl/scene/gl_flats.cpp | 12 +- src/gl/scene/gl_portal.cpp | 184 +++++++++--------------- src/gl/scene/gl_portal.h | 25 ++-- src/gl/scene/gl_renderhacks.cpp | 22 +-- src/gl/scene/gl_scene.cpp | 56 ++++---- src/gl/scene/gl_sky.cpp | 6 +- src/gl/scene/gl_skydome.cpp | 3 +- src/gl/scene/gl_sprite.cpp | 46 +++--- src/gl/scene/gl_spritelight.cpp | 2 +- src/gl/scene/gl_wall.h | 2 +- src/gl/scene/gl_walls.cpp | 33 +++-- src/gl/scene/gl_weapon.cpp | 6 +- src/gl/stereo3d/scoped_view_shifter.cpp | 15 +- src/gl/stereo3d/scoped_view_shifter.h | 5 +- src/gl/utility/gl_clock.cpp | 5 +- src/r_defs.h | 1 - 22 files changed, 238 insertions(+), 306 deletions(-) diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index d43134bce..859f8de1a 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -47,8 +47,7 @@ struct GLSectorStackPortal; struct FPortal { - fixed_t xDisplacement; - fixed_t yDisplacement; + DVector2 mDisplacement; int plane; GLSectorStackPortal *glportal; // for quick access to the render data. This is only valid during BSP traversal! diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 8229767c1..de030ad30 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -64,15 +64,13 @@ struct FPortalID { - fixed_t mXDisplacement; - fixed_t mYDisplacement; + DVector2 mDisplacement; // for the hash code - operator intptr_t() const { return (mXDisplacement >> 8) + (mYDisplacement << 8); } + operator intptr_t() const { return (FLOAT2FIXED(mDisplacement.X) >> 8) + (FLOAT2FIXED(mDisplacement.Y) << 8); } bool operator != (const FPortalID &other) const { - return mXDisplacement != other.mXDisplacement || - mYDisplacement != other.mYDisplacement; + return mDisplacement != other.mDisplacement; } }; @@ -331,8 +329,8 @@ void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, F shape.Resize(subsector->numlines); for(unsigned i=0; inumlines; i++) { - centerx += (shape[i].x = subsector->firstline[i].v1->fixX() + portal->xDisplacement); - centery += (shape[i].y = subsector->firstline[i].v1->fixY() + portal->yDisplacement); + centerx += (shape[i].x = FLOAT2FIXED(subsector->firstline[i].v1->fX() + portal->mDisplacement.X)); + centery += (shape[i].y = FLOAT2FIXED(subsector->firstline[i].v1->fY() + portal->mDisplacement.Y)); } FCoverageBuilder build(subsector, portal); @@ -361,7 +359,7 @@ static void CollectPortalSectors(FPortalMap &collection) ASkyViewpoint *SkyBox = barrier_cast(sec->SkyBoxes[j]); if (SkyBox != NULL && SkyBox->bAlways && SkyBox->Mate != NULL) { - FPortalID id = { SkyBox->_f_X() - SkyBox->Mate->_f_X(), SkyBox->_f_Y() - SkyBox->Mate->_f_Y() }; + FPortalID id = { {SkyBox->X() - SkyBox->Mate->X(), SkyBox->Y() - SkyBox->Mate->Y()} }; FPortalSectors &sss = collection[id]; FPortalSector ss = { sec, j }; @@ -406,8 +404,7 @@ void gl_InitPortals() if (planeflags & i) { FPortal *portal = new FPortal; - portal->xDisplacement = pair->Key.mXDisplacement; - portal->yDisplacement = pair->Key.mYDisplacement; + portal->mDisplacement = pair->Key.mDisplacement; portal->plane = (i==1? sector_t::floor : sector_t::ceiling); /**/ portal->glportal = NULL; portals.Push(portal); @@ -505,8 +502,8 @@ CCMD(dumpportals) { for(unsigned i=0;ixDisplacement/65536.; - double ydisp = portals[i]->yDisplacement/65536.; + double xdisp = portals[i]->mDisplacement.X; + double ydisp = portals[i]->mDisplacement.Y; Printf(PRINT_LOG, "Portal #%d, %s, displacement = (%f,%f)\n", i, portals[i]->plane==0? "floor":"ceiling", xdisp, ydisp); Printf(PRINT_LOG, "Coverage:\n"); diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 72f5d3171..6a1c2f9a2 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -93,8 +93,8 @@ public: void SetViewport(GL_IRECT *bounds); sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen); void RenderView(player_t *player); - void SetViewAngle(angle_t viewangle); - void SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror); + void SetViewAngle(DAngle viewangle); + void SetupView(float viewx, float viewy, float viewz, DAngle viewangle, bool mirror, bool planemirror); void Initialize(); @@ -132,7 +132,7 @@ public: void SetProjection(float fov, float ratio, float fovratio); void SetProjection(VSMatrix matrix); // raw matrix input from stereo 3d modes - void SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, bool mirror, bool planemirror); + void SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror); void ProcessScene(bool toscreen = false); bool StartOffscreen(); diff --git a/src/gl/scene/gl_clipper.cpp b/src/gl/scene/gl_clipper.cpp index 388048181..57f9fb9ac 100644 --- a/src/gl/scene/gl_clipper.cpp +++ b/src/gl/scene/gl_clipper.cpp @@ -388,7 +388,13 @@ angle_t Clipper::AngleToPseudo(angle_t ang) // //----------------------------------------------------------------------------- -angle_t R_PointToPseudoAngle (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y) +void R_SetView() +{ + viewx = FLOAT2FIXED(ViewPos.X); + viewy = FLOAT2FIXED(ViewPos.Y); +} + +angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y) { // Note: float won't work here as it's less precise than the BAM values being passed as parameters double vecx = double(x-viewx); @@ -450,8 +456,8 @@ bool Clipper::CheckBox(const fixed_t *bspcoord) if (boxpos == 5) return true; check = checkcoord[boxpos]; - angle1 = R_PointToPseudoAngle (viewx, viewy, bspcoord[check[0]], bspcoord[check[1]]); - angle2 = R_PointToPseudoAngle (viewx, viewy, bspcoord[check[2]], bspcoord[check[3]]); + angle1 = R_PointToPseudoAngle (bspcoord[check[0]], bspcoord[check[1]]); + angle2 = R_PointToPseudoAngle (bspcoord[check[2]], bspcoord[check[3]]); return SafeCheckRange(angle2, angle1); } diff --git a/src/gl/scene/gl_clipper.h b/src/gl/scene/gl_clipper.h index 367cf515f..8092cd284 100644 --- a/src/gl/scene/gl_clipper.h +++ b/src/gl/scene/gl_clipper.h @@ -136,12 +136,13 @@ public: extern Clipper clipper; -angle_t R_PointToPseudoAngle (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y); +angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y); +void R_SetView(); // Used to speed up angle calculations during clipping inline angle_t vertex_t::GetClipAngle() { - return angletime == Clipper::anglecache? viewangle : (angletime = Clipper::anglecache, viewangle = R_PointToPseudoAngle(viewx, viewy, x,y)); + return angletime == Clipper::anglecache? viewangle : (angletime = Clipper::anglecache, viewangle = R_PointToPseudoAngle(x,y)); } #endif \ No newline at end of file diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index c7bfce854..e12d61ce3 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -243,39 +243,39 @@ SortNode * GLDrawList::FindSortPlane(SortNode * head) //========================================================================== SortNode * GLDrawList::FindSortWall(SortNode * head) { - fixed_t farthest=INT_MIN; - fixed_t nearest=INT_MAX; - SortNode * best=NULL; - SortNode * node=head; - fixed_t bestdist=INT_MAX; + float farthest = -FLT_MAX; + float nearest = FLT_MAX; + SortNode * best = NULL; + SortNode * node = head; + float bestdist = FLT_MAX; while (node) { - GLDrawItem * it=&drawitems[node->itemindex]; - if (it->rendertype==GLDIT_WALL) + GLDrawItem * it = &drawitems[node->itemindex]; + if (it->rendertype == GLDIT_WALL) { - fixed_t d=walls[it->index].viewdistance; - if (d>farthest) farthest=d; - if (dindex].ViewDistance; + if (d > farthest) farthest = d; + if (d < nearest) nearest = d; } - node=node->next; + node = node->next; } - if (farthest==INT_MIN) return NULL; - node=head; - farthest=(farthest+nearest)>>1; + if (farthest == INT_MIN) return NULL; + node = head; + farthest = (farthest + nearest) / 2; while (node) { - GLDrawItem * it=&drawitems[node->itemindex]; - if (it->rendertype==GLDIT_WALL) + GLDrawItem * it = &drawitems[node->itemindex]; + if (it->rendertype == GLDIT_WALL) { - fixed_t di=abs(walls[it->index].viewdistance-farthest); - if (!best || diindex].ViewDistance - farthest); + if (!best || di < bestdist) { - best=node; - bestdist=di; + best = node; + bestdist = di; } } - node=node->next; + node = node->next; } return best; } @@ -309,7 +309,7 @@ void GLDrawList::SortWallIntoPlane(SortNode * head,SortNode * sort) GLFlat * fh=&flats[drawitems[head->itemindex].index]; GLWall * ws=&walls[drawitems[sort->itemindex].index]; - bool ceiling = fh->z > FIXED2FLOAT(viewz); + bool ceiling = fh->z > ViewPos.Z; if ((ws->ztop[0] > fh->z || ws->ztop[1] > fh->z) && (ws->zbottom[0] < fh->z || ws->zbottom[1] < fh->z)) { @@ -350,7 +350,7 @@ void GLDrawList::SortSpriteIntoPlane(SortNode * head,SortNode * sort) GLFlat * fh=&flats[drawitems[head->itemindex].index]; GLSprite * ss=&sprites[drawitems[sort->itemindex].index]; - bool ceiling = fh->z > FIXED2FLOAT(viewz); + bool ceiling = fh->z > ViewPos.Z; if ((ss->z1>fh->z && ss->z2z) || ss->modelframe) { @@ -708,7 +708,7 @@ void GLDrawList::DoDrawSorted(SortNode * head) if (drawitems[head->itemindex].rendertype == GLDIT_FLAT) { z = flats[drawitems[head->itemindex].index].z; - relation = z > FIXED2FLOAT(viewz)? 1 : -1; + relation = z > ViewPos.Z ? 1 : -1; } @@ -1112,9 +1112,9 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo gl_SetFog(lightlevel, rel, &Colormap, false); gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); - float fviewx = FIXED2FLOAT(viewx); - float fviewy = FIXED2FLOAT(viewy); - float fviewz = FIXED2FLOAT(viewz); + float fviewx = ViewPos.X; + float fviewy = ViewPos.Y; + float fviewz = ViewPos.Z; gl_SetPlaneTextureRotation(&plane, gltexture); gl_RenderState.Apply(); @@ -1165,11 +1165,11 @@ void FDrawInfo::FloodUpperGap(seg_t * seg) // Although the plane can be sloped this code will only be called // when the edge itself is not. - fixed_t backz = fakebsector->ceilingplane.ZatPoint(seg->v1->x, seg->v1->y); - fixed_t frontz = fakefsector->ceilingplane.ZatPoint(seg->v1->x, seg->v1->y); + double backz = fakebsector->ceilingplane.ZatPoint(seg->v1); + double frontz = fakefsector->ceilingplane.ZatPoint(seg->v1); if (fakebsector->GetTexture(sector_t::ceiling)==skyflatnum) return; - if (backz < viewz) return; + if (backz < ViewPos.Z) return; if (seg->sidedef == seg->linedef->sidedef[0]) { @@ -1187,8 +1187,8 @@ void FDrawInfo::FloodUpperGap(seg_t * seg) ws.x2 = v2->fX(); ws.y2 = v2->fY(); - ws.z1= FIXED2FLOAT(frontz); - ws.z2= FIXED2FLOAT(backz); + ws.z1= frontz; + ws.z2= backz; // Step1: Draw a stencil into the gap SetupFloodStencil(&ws); @@ -1217,12 +1217,12 @@ void FDrawInfo::FloodLowerGap(seg_t * seg) // Although the plane can be sloped this code will only be called // when the edge itself is not. - fixed_t backz = fakebsector->floorplane.ZatPoint(seg->v1->x, seg->v1->y); - fixed_t frontz = fakefsector->floorplane.ZatPoint(seg->v1->x, seg->v1->y); + double backz = fakebsector->floorplane.ZatPoint(seg->v1); + double frontz = fakefsector->floorplane.ZatPoint(seg->v1); if (fakebsector->GetTexture(sector_t::floor) == skyflatnum) return; - if (fakebsector->GetPlaneTexZ(sector_t::floor) > viewz) return; + if (fakebsector->GetPlaneTexZF(sector_t::floor) > ViewPos.Z) return; if (seg->sidedef == seg->linedef->sidedef[0]) { @@ -1240,8 +1240,8 @@ void FDrawInfo::FloodLowerGap(seg_t * seg) ws.x2 = v2->fX(); ws.y2 = v2->fY(); - ws.z2= FIXED2FLOAT(frontz); - ws.z1= FIXED2FLOAT(backz); + ws.z2= frontz; + ws.z1= backz; // Step1: Draw a stencil into the gap SetupFloodStencil(&ws); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 8e825ab5b..d234d29c9 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -516,7 +516,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) // // // - if (frontsector->floorplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) <= FIXED2FLOAT(viewz)) + if (frontsector->floorplane.ZatPoint(ViewPos) <= ViewPos.Z) { // process the original floor first. @@ -577,7 +577,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) // // // - if (frontsector->ceilingplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) >= FIXED2FLOAT(viewz)) + if (frontsector->ceilingplane.ZatPoint(ViewPos) >= ViewPos.Z) { // process the original ceiling first. @@ -669,7 +669,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) fixed_t ff_top=FLOAT2FIXED(rover->top.plane->ZatPoint(sector->centerspot)); if (ff_toptop.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) + if (ViewPos.Z <= rover->top.plane->ZatPoint(ViewPos)) { SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG)); Colormap.FadeColor=frontsector->ColorMap->Fade; @@ -683,7 +683,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) fixed_t ff_bottom=FLOAT2FIXED(rover->bottom.plane->ZatPoint(sector->centerspot)); if (ff_bottombottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) + if (ViewPos.Z <=rover->bottom.plane->ZatPoint(ViewPos)) { SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG)); Colormap.FadeColor=frontsector->ColorMap->Fade; @@ -709,7 +709,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) fixed_t ff_bottom=FLOAT2FIXED(rover->bottom.plane->ZatPoint(sector->centerspot)); if (ff_bottom>lastfloorheight || (rover->flags&FF_FIX)) { - if (FIXED2FLOAT(viewz) >= rover->bottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) + if (ViewPos.Z >= rover->bottom.plane->ZatPoint(ViewPos)) { SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG)); Colormap.FadeColor=frontsector->ColorMap->Fade; @@ -730,7 +730,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) fixed_t ff_top=FLOAT2FIXED(rover->top.plane->ZatPoint(sector->centerspot)); if (ff_top>lastfloorheight) { - if (FIXED2FLOAT(viewz) >= rover->top.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) + if (ViewPos.Z >= rover->top.plane->ZatPoint(ViewPos)) { SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG)); Colormap.FadeColor=frontsector->ColorMap->Fade; diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 860c822bc..7aaf04a77 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -307,11 +307,9 @@ bool GLPortal::Start(bool usestencil, bool doquery) gl_RenderState.SetClipHeightTop(65536.f); // save viewpoint - savedviewx=viewx; - savedviewy=viewy; - savedviewz=viewz; + savedViewPos = ViewPos; + savedAngle = ViewAngle; savedviewactor=GLRenderer->mViewActor; - savedviewangle=viewangle; savedviewarea=in_area; savedshowviewer = r_showviewer; @@ -324,7 +322,7 @@ bool GLPortal::Start(bool usestencil, bool doquery) inline void GLPortal::ClearClipper() { - fixed_t angleOffset = viewangle - savedviewangle; + DAngle angleOffset = deltaangle(savedAngle, ViewAngle); clipper.Clear(); @@ -332,23 +330,20 @@ inline void GLPortal::ClearClipper() // Set the clipper to the minimal visible area clipper.SafeAddClipRange(0,0xffffffff); - for(unsigned int i=0;i0) + if (deltaangle(endAngle, startAngle) < 0) { - clipper.SafeRemoveClipRangeRealAngles(startAngle + angleOffset, endAngle + angleOffset); + clipper.SafeRemoveClipRangeRealAngles(startAngle.BAMs(), endAngle.BAMs()); } } // and finally clip it to the visible area angle_t a1 = GLRenderer->FrustumAngle(); - if (a1mViewActor=savedviewactor; in_area=savedviewarea; r_showviewer = savedshowviewer; - GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); + GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); { ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // no graphics @@ -438,14 +431,12 @@ void GLPortal::End(bool usestencil) glDepthMask(true); } // Restore the old view - viewx=savedviewx; - viewy=savedviewy; - viewz=savedviewz; - viewangle=savedviewangle; + ViewPos = savedViewPos; + ViewAngle = savedAngle; GLRenderer->mViewActor=savedviewactor; in_area=savedviewarea; r_showviewer = savedshowviewer; - GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); // This draws a valid z-buffer into the stencil's contents to ensure it // doesn't get overwritten by the level's geometry. @@ -655,28 +646,24 @@ void GLSkyboxPortal::DrawContents() PlaneMirrorMode = 0; bool oldclamp = gl_RenderState.SetDepthClamp(false); - DVector3 viewpos = origin->InterpolatedPosition(r_TicFracF); - viewangle += (origin->PrevAngles.Yaw + deltaangle(origin->PrevAngles.Yaw, origin->Angles.Yaw) * r_TicFracF).BAMs(); + ViewPos = origin->InterpolatedPosition(r_TicFracF); + ViewAngle += (origin->PrevAngles.Yaw + deltaangle(origin->PrevAngles.Yaw, origin->Angles.Yaw) * r_TicFracF); // Don't let the viewpoint be too close to a floor or ceiling double floorh = origin->Sector->floorplane.ZatPoint(origin->Pos()); double ceilh = origin->Sector->ceilingplane.ZatPoint(origin->Pos()); - if (viewpos.Z < floorh + 4) viewpos.Z = floorh + 4; - if (viewpos.Z > ceilh - 4) viewz = ceilh - 4; - - viewx = FLOAT2FIXED(viewpos.X); - viewy = FLOAT2FIXED(viewpos.Y); - viewz = FLOAT2FIXED(viewpos.Z); + if (ViewPos.Z < floorh + 4) ViewPos.Z = floorh + 4; + if (ViewPos.Z > ceilh - 4) ViewPos.Z = ceilh - 4; GLRenderer->mViewActor = origin; validcount++; inskybox = true; - GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); + GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); GLRenderer->SetViewArea(); ClearClipper(); - int mapsection = R_PointInSubsector(viewx, viewy)->mapsection; + int mapsection = R_PointInSubsector(ViewPos)->mapsection; SaveMapSection(); currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7); @@ -761,8 +748,7 @@ void GLSectorStackPortal::DrawContents() { FPortal *portal = origin; - viewx += origin->xDisplacement; - viewy += origin->yDisplacement; + ViewPos += origin->mDisplacement; GLRenderer->mViewActor = NULL; @@ -771,7 +757,7 @@ void GLSectorStackPortal::DrawContents() // avoid recursions! if (origin->plane != -1) instack[origin->plane]++; - GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); SaveMapSection(); SetupCoverage(); ClearClipper(); @@ -807,8 +793,8 @@ void GLPlaneMirrorPortal::DrawContents() int old_pm=PlaneMirrorMode; - fixed_t planez = origin->ZatPoint(viewx, viewy); - viewz = 2*planez - viewz; + double planez = origin->ZatPoint(ViewPos); + ViewPos.Z = 2 * planez - ViewPos.Z; GLRenderer->mViewActor = NULL; PlaneMirrorMode = origin->fC() < 0 ? -1 : 1; r_showviewer = true; @@ -816,18 +802,17 @@ void GLPlaneMirrorPortal::DrawContents() validcount++; PlaneMirrorFlag++; - GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); ClearClipper(); - float f = FIXED2FLOAT(planez); if (PlaneMirrorMode < 0) { - gl_RenderState.SetClipHeightTop(f); // ceiling mirror: clip everything with a z lower than the portal's ceiling + gl_RenderState.SetClipHeightTop(planez); // ceiling mirror: clip everything with a z lower than the portal's ceiling gl_RenderState.SetClipHeightBottom(-65536.f); } else { - gl_RenderState.SetClipHeightBottom(f); // floor mirror: clip everything with a z higher than the portal's floor + gl_RenderState.SetClipHeightBottom(planez); // floor mirror: clip everything with a z higher than the portal's floor gl_RenderState.SetClipHeightTop(65536.f); } @@ -872,31 +857,30 @@ void GLMirrorPortal::DrawContents() } GLRenderer->mCurrentPortal = this; - angle_t startang = viewangle; - fixed_t startx = viewx; - fixed_t starty = viewy; + DAngle StartAngle = ViewAngle; + DVector3 StartPos = ViewPos; vertex_t *v1 = linedef->v1; vertex_t *v2 = linedef->v2; // Reflect the current view behind the mirror. if (linedef->Delta().X == 0) - { + { // vertical mirror - viewx = v1->fixX() - startx + v1->fixX(); + ViewPos.X = 2 * v1->fX() - StartPos.X; // Compensation for reendering inaccuracies - if (startxfixX()) viewx -= FRACUNIT/2; - else viewx += FRACUNIT/2; + if (StartPos.X < v1->fX()) ViewPos.X -= 0.1; + else ViewPos.X += 0.1; } else if (linedef->Delta().Y == 0) { // horizontal mirror - viewy = v1->fixY() - starty + v1->fixY(); + ViewPos.Y = 2*v1->fY() - StartPos.Y; // Compensation for reendering inaccuracies - if (startyfixY()) viewy -= FRACUNIT/2; - else viewy += FRACUNIT/2; + if (StartPos.YfY()) ViewPos.Y -= 0.1; + else ViewPos.Y += 0.1; } else { @@ -907,25 +891,23 @@ void GLMirrorPortal::DrawContents() double dy = v2->fY() - v1->fY(); double x1 = v1->fX(); double y1 = v1->fY(); - double x = FIXED2DBL(startx); - double y = FIXED2DBL(starty); + double x = StartPos.X; + double y = StartPos.Y; // the above two cases catch len == 0 double r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy); - viewx = FLOAT2FIXED((x1 + r * dx)*2 - x); - viewy = FLOAT2FIXED((y1 + r * dy)*2 - y); + ViewPos.X = (x1 + r * dx)*2 - x; + ViewPos.Y = (y1 + r * dy)*2 - y; // Compensation for reendering inaccuracies FVector2 v(-dx, dy); v.MakeUnit(); - viewx+= FLOAT2FIXED(v[1] * renderdepth / 2); - viewy+= FLOAT2FIXED(v[0] * renderdepth / 2); + ViewPos.X+= v[1] * renderdepth / 2; + ViewPos.Y+= v[0] * renderdepth / 2; } - // we cannot afford any imprecisions caused by R_PointToAngle2 here. They'd be visible as seams around the mirror. - viewangle = 2*R_PointToAnglePrecise (linedef->v1->fixX(), linedef->v1->fixY(), - linedef->v2->fixX(), linedef->v2->fixY()) - startang; + ViewAngle = linedef->Delta().Angle() * 2. - StartAngle; GLRenderer->mViewActor = NULL; r_showviewer = true; @@ -933,12 +915,12 @@ void GLMirrorPortal::DrawContents() validcount++; MirrorFlag++; - GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); clipper.Clear(); angle_t af = GLRenderer->FrustumAngle(); - if (afv1->GetClipAngle(); angle_t a1 = linedef->v2->GetClipAngle(); @@ -952,7 +934,12 @@ void GLMirrorPortal::DrawContents() int GLLinePortal::ClipSeg(seg_t *seg) { - return PClip_Inside;// P_ClipLineToPortal(seg->linedef, line(), viewx, viewy) ? PClip_InFront : PClip_Inside; + line_t *linedef = seg->linedef; + if (!linedef) + { + return PClip_Inside; // should be handled properly. + } + return P_ClipLineToPortal(linedef, line(), ViewPos) ? PClip_InFront : PClip_Inside; } int GLLinePortal::ClipSubsector(subsector_t *sub) @@ -960,14 +947,14 @@ int GLLinePortal::ClipSubsector(subsector_t *sub) // this seg is completely behind the mirror! for(unsigned int i=0;inumlines;i++) { - if (P_PointOnLineSidePrecise(sub->firstline[i].v1->fixX(), sub->firstline[i].v1->fixY(), line()) == 0) return PClip_Inside; + if (P_PointOnLineSidePrecise(sub->firstline[i].v1->fPos(), line()) == 0) return PClip_Inside; } return PClip_InFront; } -int GLLinePortal::ClipPoint(fixed_t x, fixed_t y) +int GLLinePortal::ClipPoint(const DVector2 &pos) { - if (P_PointOnLineSidePrecise(x, y, line())) + if (P_PointOnLineSidePrecise(pos, line())) { return PClip_InFront; } @@ -1002,11 +989,9 @@ void GLLineToLinePortal::DrawContents() GLRenderer->mCurrentPortal = this; line_t *origin = glport->reference->mOrigin; - P_TranslatePortalXY(origin, viewx, viewy); - DAngle va = ANGLE2DBL(viewangle); - P_TranslatePortalAngle(origin, va); - viewangle = va.BAMs(); - P_TranslatePortalZ(origin, viewz); + P_TranslatePortalXY(origin, ViewPos.X, ViewPos.Y); + P_TranslatePortalAngle(origin, ViewAngle); + P_TranslatePortalZ(origin, ViewPos.Z); SaveMapSection(); @@ -1023,52 +1008,13 @@ void GLLineToLinePortal::DrawContents() GLRenderer->mViewActor = NULL; validcount++; - GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); ClearClipper(); GLRenderer->DrawScene(); RestoreMapSection(); } - -/* -int GLLineToLinePortal::ClipSeg(seg_t *seg) -{ - line_t *linedef = lines[0].seg->linedef->getPortalDestination(); - // this seg is completely behind the portal - //we cannot use P_PointOnLineSide here because it loses the special meaning of 0 == 'on the line'. - int side1 = DMulScale32(seg->v1->y - linedef->v1->y, linedef->dx, linedef->v1->x - seg->v1->x, linedef->dy); - int side2 = DMulScale32(seg->v2->y - linedef->v1->y, linedef->dx, linedef->v1->x - seg->v2->x, linedef->dy); - - if (side1 >= 0 && side2 >= 0) - { - return PClip_InFront; - } - return PClip_Inside; -} - -int GLLineToLinePortal::ClipSubsector(subsector_t *sub) -{ - line_t *masterline = lines[0].seg->linedef->getPortalDestination(); - - for(unsigned int i=0;inumlines;i++) - { - if (P_PointOnLineSidePrecise(sub->firstline[i].v1->x, sub->firstline[i].v1->y, masterline) == 0) return PClip_Inside; - } - return PClip_InFront; -} - -int GLLineToLinePortal::ClipPoint(fixed_t x, fixed_t y) -{ - line_t *masterline = lines[0].seg->linedef->getPortalDestination(); - if (P_PointOnLineSidePrecise(x, y, masterline)) - { - return PClip_InFront; - } - return PClip_Inside; -} -*/ - //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // @@ -1112,7 +1058,7 @@ void GLHorizonPortal::DrawContents() PortalAll.Unclock(); return; } - gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); + gl_RenderState.SetCameraPos(ViewPos.X, ViewPos.Y, ViewPos.Z); z=sp->Texheight; @@ -1141,8 +1087,8 @@ void GLHorizonPortal::DrawContents() - float vx=FIXED2FLOAT(viewx); - float vy=FIXED2FLOAT(viewy); + float vx= ViewPos.X; + float vy= ViewPos.Y; // Draw to some far away boundary // This is not drawn as larher strips because it causes visual glitches. @@ -1163,7 +1109,7 @@ void GLHorizonPortal::DrawContents() } } - float vz=FIXED2FLOAT(viewz); + float vz= ViewPos.Z; float tz=(z-vz);///64.0f; // fill the gap between the polygon and the true horizon @@ -1238,7 +1184,7 @@ void GLEEHorizonPortal::DrawContents() horz.colormap = origin->Sector->ColorMap; if (origin->special1 == SKYBOX_PLANE) { - horz.plane.Texheight = FIXED2FLOAT(viewz) + fabs(horz.plane.Texheight); + horz.plane.Texheight = ViewPos.Z + fabs(horz.plane.Texheight); } GLHorizonPortal ceil(&horz, true); ceil.DrawContents(); @@ -1251,7 +1197,7 @@ void GLEEHorizonPortal::DrawContents() horz.colormap = origin->Sector->ColorMap; if (origin->special1 == SKYBOX_PLANE) { - horz.plane.Texheight = FIXED2FLOAT(viewz) - fabs(horz.plane.Texheight); + horz.plane.Texheight = ViewPos.Z - fabs(horz.plane.Texheight); } GLHorizonPortal floor(&horz, true); floor.DrawContents(); diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index ca22d2d05..43890bdec 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -101,10 +101,8 @@ public: private: void DrawPortalStencil(); - fixed_t savedviewx; - fixed_t savedviewy; - fixed_t savedviewz; - angle_t savedviewangle; + DVector3 savedViewPos; + DAngle savedAngle; AActor * savedviewactor; area_t savedviewarea; bool savedshowviewer; @@ -165,7 +163,7 @@ public: virtual int ClipSeg(seg_t *seg) { return PClip_Inside; } virtual int ClipSubsector(subsector_t *sub) { return PClip_Inside; } - virtual int ClipPoint(fixed_t x, fixed_t y) { return PClip_Inside; } + virtual int ClipPoint(const DVector2 &pos) { return PClip_Inside; } static void BeginScene(); static void StartFrame(); @@ -186,8 +184,7 @@ struct GLLinePortal : public GLPortal { v1 = line->v1; v2 = line->v2; - dx = FLOAT2FIXED(line->Delta().X); - dy = FLOAT2FIXED(line->Delta().Y); + CalcDelta(); } GLLinePortal(FGLLinePortal *line) @@ -198,17 +195,21 @@ struct GLLinePortal : public GLPortal line_t *lline = line->reference->mDestination; v1 = lline->v1; v2 = lline->v2; - dx = FLOAT2FIXED(lline->Delta().X); - dy = FLOAT2FIXED(lline->Delta().Y); } else { // For linked portals we can check the merged span. v1 = line->v1; v2 = line->v2; - dx = line->dx; - dy = line->dy; } + CalcDelta(); + } + + void CalcDelta() + { + DVector2 delta = v2->fPos() - v1->fPos(); + dx = FLOAT2FIXED(delta.X); + dy = FLOAT2FIXED(delta.Y); } line_t *line() @@ -219,7 +220,7 @@ struct GLLinePortal : public GLPortal virtual int ClipSeg(seg_t *seg); virtual int ClipSubsector(subsector_t *sub); - virtual int ClipPoint(fixed_t x, fixed_t y); + virtual int ClipPoint(const DVector2 &pos); virtual bool NeedCap() { return false; } }; diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index 972e970d5..97cefabd6 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -506,7 +506,7 @@ void FDrawInfo::HandleMissingTextures() HandledSubsectors.Clear(); validcount++; - if (MissingUpperTextures[i].planez > viewz) + if (MissingUpperTextures[i].planez > FLOAT2FIXED(ViewPos.Z)) { // close the hole only if all neighboring sectors are an exact height match // Otherwise just fill in the missing textures. @@ -578,7 +578,7 @@ void FDrawInfo::HandleMissingTextures() HandledSubsectors.Clear(); validcount++; - if (MissingLowerTextures[i].planez < viewz) + if (MissingLowerTextures[i].planez < FLOAT2FIXED(ViewPos.Z)) { // close the hole only if all neighboring sectors are an exact height match // Otherwise just fill in the missing textures. @@ -668,7 +668,7 @@ void FDrawInfo::DrawUnhandledMissingTextures() // already done! if (seg->linedef->validcount==validcount) continue; // already done seg->linedef->validcount=validcount; - if (seg->frontsector->GetPlaneTexZ(sector_t::ceiling) < viewz) continue; // out of sight + if (seg->frontsector->GetPlaneTexZF(sector_t::ceiling) < ViewPos.Z) continue; // out of sight //if (seg->frontsector->ceilingpic==skyflatnum) continue; // FIXME: The check for degenerate subsectors should be more precise @@ -692,7 +692,7 @@ void FDrawInfo::DrawUnhandledMissingTextures() if (seg->linedef->validcount==validcount) continue; // already done seg->linedef->validcount=validcount; if (!(sectorrenderflags[seg->backsector->sectornum] & SSRF_RENDERFLOOR)) continue; - if (seg->frontsector->GetPlaneTexZ(sector_t::floor) > viewz) continue; // out of sight + if (seg->frontsector->GetPlaneTexZF(sector_t::floor) > ViewPos.Z) continue; // out of sight if (seg->backsector->transdoor) continue; if (seg->backsector->GetTexture(sector_t::floor)==skyflatnum) continue; if (seg->backsector->portals[sector_t::floor] != NULL) continue; @@ -793,17 +793,17 @@ bool FDrawInfo::CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor) // We must collect any subsector that either is connected to this one with a miniseg // or has the same visplane. // We must not collect any subsector that has the anchor's visplane! - if (!(sub->flags & SSECF_DEGENERATE)) + if (!(sub->flags & SSECF_DEGENERATE)) { // Is not being rendered so don't bother. - if (!(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return true; + if (!(ss_renderflags[DWORD(sub - subsectors)] & SSRF_PROCESSED)) return true; if (sub->render_sector->GetTexture(sector_t::floor) != anchor->GetTexture(sector_t::floor) || - sub->render_sector->GetPlaneTexZ(sector_t::floor)!=anchor->GetPlaneTexZ(sector_t::floor) || - sub->render_sector->GetFloorLight() != anchor->GetFloorLight()) + sub->render_sector->GetPlaneTexZF(sector_t::floor) != anchor->GetPlaneTexZF(sector_t::floor) || + sub->render_sector->GetFloorLight() != anchor->GetFloorLight()) { - if (sub==viewsubsector && viewzGetPlaneTexZ(sector_t::floor)) inview=true; - HandledSubsectors.Push (sub); + if (sub == viewsubsector && ViewPos.Z < anchor->GetPlaneTexZF(sector_t::floor)) inview = true; + HandledSubsectors.Push(sub); } } @@ -952,7 +952,7 @@ void FDrawInfo::HandleHackedSubsectors() totalssms.Reset(); totalssms.Clock(); - viewsubsector = R_PointInSubsector(viewx, viewy); + viewsubsector = R_PointInSubsector(ViewPos); // Each subsector may only be processed once in this loop! validcount++; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 4a4c42d8d..acb8416a4 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -131,18 +131,18 @@ angle_t FGLRenderer::FrustumAngle() void FGLRenderer::SetViewArea() { // The render_sector is better suited to represent the current position in GL - viewsector = R_PointInSubsector(viewx, viewy)->render_sector; + viewsector = R_PointInSubsector(ViewPos)->render_sector; // Get the heightsec state from the render sector, not the current one! if (viewsector->heightsec && !(viewsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) { - in_area = viewz<=viewsector->heightsec->floorplane.ZatPoint(viewx,viewy) ? area_below : - (viewz>viewsector->heightsec->ceilingplane.ZatPoint(viewx,viewy) && - !(viewsector->heightsec->MoreFlags&SECF_FAKEFLOORONLY)) ? area_above:area_normal; + in_area = ViewPos.Z <= viewsector->heightsec->floorplane.ZatPoint(ViewPos) ? area_below : + (ViewPos.Z > viewsector->heightsec->ceilingplane.ZatPoint(ViewPos) && + !(viewsector->heightsec->MoreFlags&SECF_FAKEFLOORONLY)) ? area_above : area_normal; } else { - in_area=area_default; // depends on exposed lower sectors + in_area = area_default; // depends on exposed lower sectors } } @@ -218,12 +218,12 @@ void FGLRenderer::SetViewport(GL_IRECT *bounds) // //----------------------------------------------------------------------------- -void FGLRenderer::SetViewAngle(angle_t viewangle) +void FGLRenderer::SetViewAngle(DAngle viewangle) { - float fviewangle=(float)(viewangle>>ANGLETOFINESHIFT)*360.0f/FINEANGLES; - - mAngles.Yaw = 270.0f-fviewangle; - mViewVector = FVector2(cos(DEG2RAD(fviewangle)), sin(DEG2RAD(fviewangle))); + mAngles.Yaw = float(270.0-viewangle.Degrees); + DVector2 v = ViewAngle.ToVector(); + mViewVector.X = v.X; + mViewVector.Y = v.Y; R_SetViewAngle(); } @@ -258,7 +258,7 @@ void FGLRenderer::SetProjection(VSMatrix matrix) // //----------------------------------------------------------------------------- -void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, bool mirror, bool planemirror) +void FGLRenderer::SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror) { float mult = mirror? -1:1; float planemult = planemirror? -glset.pixelstretch : glset.pixelstretch; @@ -267,7 +267,7 @@ void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, boo gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll.Degrees, 0.0f, 0.0f, 1.0f); gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Pitch.Degrees, 1.0f, 0.0f, 0.0f); gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Yaw.Degrees, 0.0f, mult, 0.0f); - gl_RenderState.mViewMatrix.translate(FIXED2FLOAT(viewx) * mult, -FIXED2FLOAT(viewz) * planemult , -FIXED2FLOAT(viewy)); + gl_RenderState.mViewMatrix.translate(vx * mult, -vz * planemult , -vy); gl_RenderState.mViewMatrix.scale(-mult, planemult, 1); } @@ -278,10 +278,10 @@ void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, boo // Setup the view rotation matrix for the given viewpoint // //----------------------------------------------------------------------------- -void FGLRenderer::SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror) +void FGLRenderer::SetupView(float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror) { - SetViewAngle(viewangle); - SetViewMatrix(viewx, viewy, viewz, mirror, planemirror); + SetViewAngle(va); + SetViewMatrix(vx, vy, vz, mirror, planemirror); gl_RenderState.ApplyMatrices(); } @@ -305,6 +305,7 @@ void FGLRenderer::CreateScene() for(unsigned i=0;iglportal = NULL; gl_spriteindex=0; Bsp.Clock(); + R_SetView(); gl_RenderBSPNode (nodes + numnodes - 1); Bsp.Unclock(); @@ -333,7 +334,7 @@ void FGLRenderer::RenderScene(int recursion) glDepthMask(true); if (!gl_no_skyclear) GLPortal::RenderFirstSkyPortal(recursion); - gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); + gl_RenderState.SetCameraPos(ViewPos.X, ViewPos.Y, ViewPos.Z); gl_RenderState.EnableFog(true); gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); @@ -455,7 +456,7 @@ void FGLRenderer::RenderTranslucent() RenderAll.Clock(); glDepthMask(false); - gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); + gl_RenderState.SetCameraPos(ViewPos.X, ViewPos.Y, ViewPos.Z); // final pass: translucent stuff gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); @@ -567,13 +568,13 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) for (unsigned int i = 0; i < lightlist.Size(); i++) { - fixed_t lightbottom; + double lightbottom; if (i < lightlist.Size() - 1) - lightbottom = lightlist[i + 1].plane.ZatPoint(viewx, viewy); + lightbottom = lightlist[i + 1].plane.ZatPoint(ViewPos); else - lightbottom = viewsector->floorplane.ZatPoint(viewx, viewy); + lightbottom = viewsector->floorplane.ZatPoint(ViewPos); - if (lightbottom < viewz && (!lightlist[i].caster || !(lightlist[i].caster->flags&FF_FADEWALLS))) + if (lightbottom < ViewPos.Z && (!lightlist[i].caster || !(lightlist[i].caster->flags&FF_FADEWALLS))) { // 3d floor 'fog' is rendered as a blending value blendv = lightlist[i].blend; @@ -706,7 +707,7 @@ void FGLRenderer::ProcessScene(bool toscreen) iter_dlightf = iter_dlight = draw_dlight = draw_dlightf = 0; GLPortal::BeginScene(); - int mapsection = R_PointInSubsector(viewx, viewy)->mapsection; + int mapsection = R_PointInSubsector(ViewPos)->mapsection; memset(¤tmapsection[0], 0, currentmapsection.Size()); currentmapsection[mapsection>>3] |= 1 << (mapsection & 7); DrawScene(toscreen); @@ -771,10 +772,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo SetViewArea(); // We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1. - double radPitch = (viewpitch)* M_PI / 0x80000000; - if (radPitch > PI) radPitch -= 2 * PI; - radPitch = clamp(radPitch, -PI / 2, PI / 2); - + double radPitch = clamp(ViewPitch.Normalized180().Radians(), -PI / 2, PI / 2); double angx = cos(radPitch); double angy = sin(radPitch) * glset.pixelstretch; double alen = sqrt(angx*angx + angy*angy); @@ -815,16 +813,16 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo // Stereo mode specific perspective projection SetProjection( eye->GetProjection(fov, ratio, fovratio) ); // SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper - SetViewAngle(viewangle); + SetViewAngle(ViewAngle); // Stereo mode specific viewpoint adjustment - temporarily shifts global viewx, viewy, viewz eye->GetViewShift(GLRenderer->mAngles.Yaw.Degrees, viewShift); s3d::ScopedViewShifter viewShifter(viewShift); - SetViewMatrix(viewx, viewy, viewz, false, false); + SetViewMatrix(ViewPos.X, ViewPos.Y, ViewPos.Z, false, false); gl_RenderState.ApplyMatrices(); clipper.Clear(); angle_t a1 = FrustumAngle(); - clipper.SafeAddClipRangeRealAngles(viewangle + a1, viewangle - a1); + clipper.SafeAddClipRangeRealAngles(ViewAngle.BAMs() + a1, ViewAngle.BAMs() - a1); ProcessScene(toscreen); if (mainview) EndDrawScene(retval); // do not call this for camera textures. diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index c04b90129..d5340d7ff 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -173,8 +173,8 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) } else if (allowreflect && sector->GetReflect(plane) > 0) { - if ((plane == sector_t::ceiling && FIXED2DBL(viewz) > sector->ceilingplane.fD()) || - (plane == sector_t::floor && FIXED2DBL(viewz) < -sector->floorplane.fD())) return; + if ((plane == sector_t::ceiling && ViewPos.Z > sector->ceilingplane.fD()) || + (plane == sector_t::floor && ViewPos.Z < -sector->floorplane.fD())) return; ptype = PORTALTYPE_PLANEMIRROR; planemirror = plane == sector_t::ceiling ? §or->ceilingplane : §or->floorplane; } @@ -361,7 +361,7 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver else { // Special hack for Vrack2b - if (bs->floorplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) > FIXED2FLOAT(viewz)) return; + if (bs->floorplane.ZatPoint(ViewPos) > ViewPos.Z) return; } } zbottom[0]=zbottom[1]=-32768.0f; diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 37950ae72..a9d920420 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -41,6 +41,7 @@ #include "sc_man.h" #include "w_wad.h" #include "r_state.h" +#include "r_utility.h" //#include "gl/gl_intern.h" #include "gl/system/gl_interface.h" @@ -492,7 +493,7 @@ void GLSkyPortal::DrawContents() bool oldClamp = gl_RenderState.SetDepthClamp(true); gl_MatrixStack.Push(gl_RenderState.mViewMatrix); - GLRenderer->SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + GLRenderer->SetupView(0, 0, 0, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox) { diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 1ffd07c2d..4bdd5b517 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -154,10 +154,7 @@ void GLSprite::Draw(int pass) // fog + fuzz don't work well without some fiddling with the alpha value! if (!gl_isBlack(Colormap.FadeColor)) { - float xcamera=FIXED2FLOAT(viewx); - float ycamera=FIXED2FLOAT(viewy); - - float dist=Dist2(xcamera,ycamera, x,y); + float dist=Dist2(ViewPos.X, ViewPos.Y, x,y); if (!Colormap.FadeColor.a) Colormap.FadeColor.a=clamp(255-lightlevel,60,255); @@ -397,8 +394,8 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_ for (unsigned int i = 0; i < x.ffloors.Size(); i++) { F3DFloor * ff = x.ffloors[i]; - float floorh = FIXED2FLOAT(ff->top.plane->ZatPoint(thingx, thingy)); - float ceilingh = FIXED2FLOAT(ff->bottom.plane->ZatPoint(thingx, thingy)); + float floorh = FIXED2FLOAT(ff->top.plane->ZatPointFixed(thingx, thingy)); + float ceilingh = FIXED2FLOAT(ff->bottom.plane->ZatPointFixed(thingx, thingy)); if (floorh == thing->floorz) { btm = floorh; @@ -416,7 +413,7 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_ else if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) { if (thing->flags2&MF2_ONMOBJ && thing->floorz == - FIXED2FLOAT(thing->Sector->heightsec->floorplane.ZatPoint(thingx, thingy))) + FIXED2FLOAT(thing->Sector->heightsec->floorplane.ZatPointFixed(thingx, thingy))) { btm = thing->floorz; top = thing->ceilingz; @@ -425,7 +422,7 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_ if (btm == 1000000.0f) btm = thing->Sector->floorplane.ZatPoint(thing) - thing->Floorclip; if (top == -1000000.0f) - top = FIXED2FLOAT(thing->Sector->ceilingplane.ZatPoint(thingx, thingy)); + top = FIXED2FLOAT(thing->Sector->ceilingplane.ZatPointFixed(thingx, thingy)); // +/-1 to account for the one pixel empty frame around the sprite. float diffb = (z2+1) - btm; @@ -512,9 +509,9 @@ void GLSprite::Process(AActor* thing,sector_t * sector) DVector3 thingpos = thing->InterpolatedPosition(r_TicFracF); // Too close to the camera. This doesn't look good if it is a sprite. - if (fabs(thingpos.X - FIXED2DBL(viewx) < 2 && fabs(thingpos.Y - FIXED2DBL(viewy) < 2))) + if (fabs(thingpos.X - ViewPos.X) < 2 && fabs(thingpos.Y - ViewPos.Y) < 2) { - if (FIXED2DBL(viewz) >= thingpos.Z - 2 && FIXED2DBL(viewz) <= thingpos.Z + thing->Height + 2) + if (ViewPos.Z >= thingpos.Z - 2 && ViewPos.Z <= thingpos.Z + thing->Height + 2) { // exclude vertically moving objects from this check. if (!thing->Vel.isZero()) @@ -533,14 +530,14 @@ void GLSprite::Process(AActor* thing,sector_t * sector) if (!(thing->flags7 & MF7_FLYCHEAT) && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) { double clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius*2); - if (P_AproxDistance(thingpos.X-viewx, thingpos.Y-viewy) < clipdist) return; + if ((thingpos-ViewPos).LengthSquared() < clipdist * clipdist) return; } thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again. } if (GLRenderer->mCurrentPortal) { - int clipres = GLRenderer->mCurrentPortal->ClipPoint(FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y)); + int clipres = GLRenderer->mCurrentPortal->ClipPoint(thingpos); if (clipres == GLPortal::PClip_InFront) return; } @@ -571,10 +568,9 @@ void GLSprite::Process(AActor* thing,sector_t * sector) modelframe = gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED)); if (!modelframe) { - angle_t ang = R_PointToAngle(FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y)); - bool mirror; - FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, ang - thing->Angles.Yaw.BAMs(), &mirror); + DAngle ang = (thingpos - ViewPos).Angle(); + FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, (ang - thing->Angles.Yaw).BAMs(), &mirror); if (!patch.isValid()) return; int type = thing->renderflags & RF_SPRITETYPEMASK; gltexture = FMaterial::ValidateTexture(patch, (type == RF_FACESPRITE), false); @@ -644,7 +640,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) gltexture=NULL; } - depth = DMulScale20 (FLOAT2FIXED(thingpos.X)-viewx, viewtancos, FLOAT2FIXED(thingpos.Y)-viewy, viewtansin); + depth = (int)((x - ViewPos.X) * viewtancos + (y - ViewPos.Y) * viewtansin); // light calculation @@ -841,7 +837,7 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s { if (GLRenderer->mCurrentPortal) { - int clipres = GLRenderer->mCurrentPortal->ClipPoint(particle->x, particle->y); + int clipres = GLRenderer->mCurrentPortal->ClipPoint(particle->Pos); if (clipres == GLPortal::PClip_InFront) return; } @@ -860,15 +856,15 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s else if (!particle->bright) { TArray & lightlist=sector->e->XFloor.lightlist; - int lightbottom; + double lightbottom; Colormap = sector->ColorMap; for(unsigned int i=0;ix,particle->y); - else lightbottom = sector->floorplane.ZatPoint(particle->x,particle->y); + if (iPos); + else lightbottom = sector->floorplane.ZatPoint(particle->Pos); - if (lightbottom < particle->y) + if (lightbottom < particle->Pos.Z) { lightlevel = *lightlist[i].p_lightlevel; Colormap.LightColor = (lightlist[i].extra_colormap)->Color; @@ -920,9 +916,9 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s } } - x= FIXED2FLOAT(particle->x); - y= FIXED2FLOAT(particle->y); - z= FIXED2FLOAT(particle->z); + x = particle->Pos.X; + y = particle->Pos.Y; + z = particle->Pos.Z; float scalefac=particle->size/4.0f; // [BB] The smooth particles are smaller than the other ones. Compensate for this here. @@ -939,7 +935,7 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s z1=z-scalefac; z2=z+scalefac; - depth = DMulScale20 (particle->x-viewx, viewtancos, particle->y-viewy, viewtansin); + depth = (int)((x - ViewPos.X) * viewtancos + (y - ViewPos.Y) * viewtansin); actor=NULL; this->particle=particle; diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index 227427e0d..dfc3a6294 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -142,6 +142,6 @@ void gl_SetDynSpriteLight(AActor *thing, particle_t *particle) } else if (particle != NULL) { - gl_SetDynSpriteLight(NULL, FIXED2FLOAT(particle->x), FIXED2FLOAT(particle->y), FIXED2FLOAT(particle->z), particle->subsector); + gl_SetDynSpriteLight(NULL, particle->Pos.X, particle->Pos.Y, particle->Pos.Z, particle->subsector); } } diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index d71cccba5..3308904e9 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -128,7 +128,7 @@ public: FColormap Colormap; ERenderStyle RenderStyle; - fixed_t viewdistance; + float ViewDistance; TArray *lightlist; int lightlevel; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 683f83de5..9c6cab7da 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -134,8 +134,7 @@ void GLWall::PutWall(bool translucent) if (translucent) // translucent walls { - viewdistance = P_AproxDistance(((seg->linedef->v1->fX() + seg->linedef->v2->fX()) /2) - viewx, - ((seg->linedef->v1->fY() + seg->linedef->v2->fY()) /2) - viewy); + ViewDistance = (ViewPos - (seg->linedef->v1->fPos() + seg->linedef->Delta() / 2)).XY().LengthSquared(); gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this); } else @@ -370,13 +369,13 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) lightlist_t * light; // ZDoom doesn't support slopes in a horizon sector so I won't either! - ztop[1] = ztop[0] = FIXED2FLOAT(fs->GetPlaneTexZ(sector_t::ceiling)); - zbottom[1] = zbottom[0] = FIXED2FLOAT(fs->GetPlaneTexZ(sector_t::floor)); + ztop[1] = ztop[0] = fs->GetPlaneTexZF(sector_t::ceiling); + zbottom[1] = zbottom[0] = fs->GetPlaneTexZF(sector_t::floor); - if (viewz < fs->GetPlaneTexZ(sector_t::ceiling)) + if (ViewPos.Z < fs->GetPlaneTexZF(sector_t::ceiling)) { - if (viewz > fs->GetPlaneTexZ(sector_t::floor)) - zbottom[1] = zbottom[0] = FIXED2FLOAT(viewz); + if (ViewPos.Z > fs->GetPlaneTexZF(sector_t::floor)) + zbottom[1] = zbottom[0] = ViewPos.Z; if (fs->GetTexture(sector_t::ceiling) == skyflatnum) { @@ -1105,8 +1104,8 @@ __forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, fixed_t &le { if (planeref->plane->isSlope()) { - left=planeref->plane->ZatPoint(vertexes[0]->x, vertexes[0]->y); - right=planeref->plane->ZatPoint(vertexes[1]->x, vertexes[1]->y); + left=planeref->plane->ZatPointFixed(vertexes[0]); + right=planeref->plane->ZatPointFixed(vertexes[1]); } else if(planeref->isceiling == sector_t::ceiling) { @@ -1452,8 +1451,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) // Save a little time (up to 0.3 ms per frame ;) ) if (frontsector->floorplane.isSlope()) { - ffh1 = segfront->floorplane.ZatPoint(v1->x, v1->y); - ffh2 = segfront->floorplane.ZatPoint(v2->x, v2->y); + ffh1 = segfront->floorplane.ZatPointFixed(v1); + ffh2 = segfront->floorplane.ZatPointFixed(v2); zfloor[0] = FIXED2FLOAT(ffh1); zfloor[1] = FIXED2FLOAT(ffh2); } @@ -1465,8 +1464,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (segfront->ceilingplane.isSlope()) { - fch1 = segfront->ceilingplane.ZatPoint(v1->x, v1->y); - fch2 = segfront->ceilingplane.ZatPoint(v2->x, v2->y); + fch1 = segfront->ceilingplane.ZatPointFixed(v1); + fch2 = segfront->ceilingplane.ZatPointFixed(v2); zceil[0] = FIXED2FLOAT(fch1); zceil[1] = FIXED2FLOAT(fch2); } @@ -1522,8 +1521,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (segback->floorplane.isSlope()) { - bfh1 = segback->floorplane.ZatPoint(v1->x, v1->y); - bfh2 = segback->floorplane.ZatPoint(v2->x, v2->y); + bfh1 = segback->floorplane.ZatPointFixed(v1); + bfh2 = segback->floorplane.ZatPointFixed(v2); } else { @@ -1532,8 +1531,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (segback->ceilingplane.isSlope()) { - bch1 = segback->ceilingplane.ZatPoint(v1->x, v1->y); - bch2 = segback->ceilingplane.ZatPoint(v2->x, v2->y); + bch1 = segback->ceilingplane.ZatPointFixed(v1); + bch2 = segback->ceilingplane.ZatPointFixed(v2); } else { diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 5ed442318..e086007f5 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -258,15 +258,15 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) TArray & lightlist = viewsector->e->XFloor.lightlist; for(i=0;ifloorplane.ZatPoint(viewx,viewy); + lightbottom=viewsector->floorplane.ZatPoint(ViewPos); } if (lightbottomviewz) diff --git a/src/gl/stereo3d/scoped_view_shifter.cpp b/src/gl/stereo3d/scoped_view_shifter.cpp index 4e70c596d..5ecf1b0ab 100644 --- a/src/gl/stereo3d/scoped_view_shifter.cpp +++ b/src/gl/stereo3d/scoped_view_shifter.cpp @@ -42,24 +42,15 @@ namespace s3d { ScopedViewShifter::ScopedViewShifter(float dxyz[3]) // in meters { // save original values - cachedViewx = viewx; - cachedViewy = viewy; - cachedViewz = viewz; + cachedView = ViewPos; // modify values - float fViewx = FIXED2FLOAT(viewx) - dxyz[0]; - float fViewy = FIXED2FLOAT(viewy) + dxyz[1]; - float fViewz = FIXED2FLOAT(viewz) + dxyz[2]; - viewx = FLOAT2FIXED(fViewx); - viewy = FLOAT2FIXED(fViewy); - viewz = FLOAT2FIXED(fViewz); + ViewPos += DVector3(dxyz[0], dxyz[1], dxyz[2]); } ScopedViewShifter::~ScopedViewShifter() { // restore original values - viewx = cachedViewx; - viewy = cachedViewy; - viewz = cachedViewz; + ViewPos = cachedView; } } \ No newline at end of file diff --git a/src/gl/stereo3d/scoped_view_shifter.h b/src/gl/stereo3d/scoped_view_shifter.h index d43e2b32a..8e31cecdf 100644 --- a/src/gl/stereo3d/scoped_view_shifter.h +++ b/src/gl/stereo3d/scoped_view_shifter.h @@ -38,6 +38,7 @@ #define GL_STEREO3D_SCOPED_VIEW_SHIFTER_H_ #include "basictypes.h" +#include "vectors.h" namespace s3d { @@ -51,9 +52,7 @@ namespace s3d { ~ScopedViewShifter(); private: - fixed_t cachedViewx; - fixed_t cachedViewy; - fixed_t cachedViewz; + DVector3 cachedView; }; } /* namespace s3d */ diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp index c6be1c813..0bb75cd52 100644 --- a/src/gl/utility/gl_clock.cpp +++ b/src/gl/utility/gl_clock.cpp @@ -184,9 +184,8 @@ void CheckBench() FString compose; compose.Format("Map %s: \"%s\",\nx = %1.4f, y = %1.4f, z = %1.4f, angle = %1.4f, pitch = %1.4f\n", - level.MapName.GetChars(), level.LevelName.GetChars(), FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz), - AngleToFloat(viewangle), AngleToFloat(viewpitch)); - + level.MapName.GetChars(), level.LevelName.GetChars(), ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle.Degrees, ViewPitch.Degrees); + AppendRenderStats(compose); AppendRenderTimes(compose); AppendLightStats(compose); diff --git a/src/r_defs.h b/src/r_defs.h index 240a2b907..d820fbfb9 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -902,7 +902,6 @@ struct sector_t return FIXED2DBL(planes[pos].TexZ); } - void SetPlaneTexZ(int pos, double val) void SetPlaneTexZ(int pos, double val, bool dirtify = false) // This mainly gets used by init code. The only place where it must set the vertex to dirty is the interpolation code. { planes[pos].TexZ = FLOAT2FIXED(val); From 8a20f901a352fb439562d021f6b8ef5648aecbe3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Apr 2016 02:07:37 +0200 Subject: [PATCH 0445/1509] - removed the non.slope special handling in the wall processing code. This may have made some sense when I added this 11 years ago but on a current computer it actually hurts performance a bit due to the branching that is involved - the code runs a bit faster with those special cases removed. --- src/gl/scene/gl_walls.cpp | 86 ++++++++------------------------------- 1 file changed, 17 insertions(+), 69 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 9c6cab7da..73732c209 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -282,17 +282,8 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) if (iplane->isSlope()) - { - left=planeref->plane->ZatPointFixed(vertexes[0]); - right=planeref->plane->ZatPointFixed(vertexes[1]); - } - else if(planeref->isceiling == sector_t::ceiling) - { - left = right = FLOAT2FIXED(planeref->plane->fD()); - } - else - { - left = right = -FLOAT2FIXED(planeref->plane->fD()); - } + left=planeref->plane->ZatPointFixed(vertexes[0]); + right=planeref->plane->ZatPointFixed(vertexes[1]); } //========================================================================== @@ -1448,33 +1428,15 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) topplane = frontsector->ceilingplane; bottomplane = frontsector->floorplane; - // Save a little time (up to 0.3 ms per frame ;) ) - if (frontsector->floorplane.isSlope()) - { - ffh1 = segfront->floorplane.ZatPointFixed(v1); - ffh2 = segfront->floorplane.ZatPointFixed(v2); - zfloor[0] = FIXED2FLOAT(ffh1); - zfloor[1] = FIXED2FLOAT(ffh2); - } - else - { - ffh1 = ffh2 = -FLOAT2FIXED(segfront->floorplane.fD()); - zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh2); - } - - if (segfront->ceilingplane.isSlope()) - { - fch1 = segfront->ceilingplane.ZatPointFixed(v1); - fch2 = segfront->ceilingplane.ZatPointFixed(v2); - zceil[0] = FIXED2FLOAT(fch1); - zceil[1] = FIXED2FLOAT(fch2); - } - else - { - fch1 = fch2 = FLOAT2FIXED(segfront->ceilingplane.fD()); - zceil[0] = zceil[1] = FIXED2FLOAT(fch2); - } + ffh1 = segfront->floorplane.ZatPointFixed(v1); + ffh2 = segfront->floorplane.ZatPointFixed(v2); + zfloor[0] = FIXED2FLOAT(ffh1); + zfloor[1] = FIXED2FLOAT(ffh2); + fch1 = segfront->ceilingplane.ZatPointFixed(v1); + fch2 = segfront->ceilingplane.ZatPointFixed(v2); + zceil[0] = FIXED2FLOAT(fch1); + zceil[1] = FIXED2FLOAT(fch2); if (seg->linedef->special == Line_Horizon) { @@ -1519,26 +1481,12 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) fixed_t bfh1; fixed_t bfh2; - if (segback->floorplane.isSlope()) - { - bfh1 = segback->floorplane.ZatPointFixed(v1); - bfh2 = segback->floorplane.ZatPointFixed(v2); - } - else - { - bfh1 = bfh2 = -FLOAT2FIXED(segback->floorplane.fD()); - } - - if (segback->ceilingplane.isSlope()) - { - bch1 = segback->ceilingplane.ZatPointFixed(v1); - bch2 = segback->ceilingplane.ZatPointFixed(v2); - } - else - { - bch1 = bch2 = FLOAT2FIXED(segback->ceilingplane.fD()); - } + bfh1 = segback->floorplane.ZatPointFixed(v1); + bfh2 = segback->floorplane.ZatPointFixed(v2); + bch1 = segback->ceilingplane.ZatPointFixed(v1); + bch2 = segback->ceilingplane.ZatPointFixed(v2); + SkyTop(seg, frontsector, backsector, v1, v2); SkyBottom(seg, frontsector, backsector, v1, v2); From 5a2eac8f15f0ca478cd88fd341067e8d09b42ad5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Apr 2016 11:40:14 +0200 Subject: [PATCH 0446/1509] - floatified vertices and removed the now redundant fx and fy members. This needs an added check for polyobject origins, though, so that such subsectors don't get rendered. --- src/gl/data/gl_setup.cpp | 18 +++++---------- src/gl/data/gl_vertexbuffer.cpp | 10 ++++----- src/gl/scene/gl_bsp.cpp | 1 + src/gl/scene/gl_clipper.cpp | 21 +++++++++++++++++- src/gl/scene/gl_clipper.h | 3 ++- src/gl/scene/gl_flats.cpp | 33 +++++++--------------------- src/gl/scene/gl_vertex.cpp | 8 +++---- src/gl/utility/gl_geometric.h | 4 ++-- src/r_defs.h | 39 ++++++++++++++++----------------- 9 files changed, 67 insertions(+), 70 deletions(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index a13192694..dfc0c6d47 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -472,22 +472,18 @@ static void InitVertexData() // //========================================================================== -static void GetSideVertices(int sdnum, FVector2 *v1, FVector2 *v2) +static void GetSideVertices(int sdnum, DVector2 *v1, DVector2 *v2) { line_t *ln = sides[sdnum].linedef; if (ln->sidedef[0] == &sides[sdnum]) { - v1->X = ln->v1->fx; - v1->Y = ln->v1->fy; - v2->X = ln->v2->fx; - v2->Y = ln->v2->fy; + *v1 = ln->v1->fPos(); + *v2 = ln->v2->fPos(); } else { - v2->X = ln->v1->fx; - v2->Y = ln->v1->fy; - v1->X = ln->v2->fx; - v1->Y = ln->v2->fy; + *v2 = ln->v1->fPos(); + *v1 = ln->v2->fPos(); } } @@ -512,8 +508,6 @@ static void PrepareSegs() // Get floatng point coordinates of vertices for(int i = 0; i < numvertexes; i++) { - vertexes[i].fx = vertexes[i].fX(); - vertexes[i].fy = vertexes[i].fY(); vertexes[i].dirty = true; } @@ -559,7 +553,7 @@ static void PrepareSegs() realsegs++; segcount[sidenum]++; - FVector2 sidestart, sideend, segend(seg->v2->fx, seg->v2->fy); + DVector2 sidestart, sideend, segend = seg->v2->fPos(); GetSideVertices(sidenum, &sidestart, &sideend); sideend -=sidestart; diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index cd0ea5d60..997b34750 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -155,11 +155,11 @@ void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offs void FFlatVertex::SetFlatVertex(vertex_t *vt, const secplane_t & plane) { - x = vt->fx; - y = vt->fy; - z = plane.ZatPoint(vt->fx, vt->fy); // this is the original position without polyobject translation. - u = vt->fx/64.f; - v = -vt->fy/64.f; + x = vt->fX(); + y = vt->fY(); + z = plane.ZatPoint(vt); + u = vt->fX()/64.f; + v = -vt->fY()/64.f; } //========================================================================== diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index 613493e2c..28b08d536 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -374,6 +374,7 @@ static void DoSubsector(subsector_t * sub) // If the mapsections differ this subsector can't possibly be visible from the current view point if (!(currentmapsection[sub->mapsection>>3] & (1 << (sub->mapsection & 7)))) return; + if (sub->flags & SSECF_POLYORG) return; // never render polyobject origin subsectors because their vertices no longer are where one may expect. if (gl_drawinfo->ss_renderflags[sub-subsectors] & SSRF_SEEN) { diff --git a/src/gl/scene/gl_clipper.cpp b/src/gl/scene/gl_clipper.cpp index 57f9fb9ac..ab4bb83d4 100644 --- a/src/gl/scene/gl_clipper.cpp +++ b/src/gl/scene/gl_clipper.cpp @@ -396,7 +396,6 @@ void R_SetView() angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y) { - // Note: float won't work here as it's less precise than the BAM values being passed as parameters double vecx = double(x-viewx); double vecy = double(y-viewy); @@ -416,6 +415,26 @@ angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y) } +angle_t R_PointToPseudoAngle(double x, double y) +{ + double vecx = x - ViewPos.X; + double vecy = y - ViewPos.Y; + + if (vecx == 0 && vecy == 0) + { + return 0; + } + else + { + double result = vecy / (fabs(vecx) + fabs(vecy)); + if (vecx < 0) + { + result = 2.f - result; + } + return xs_Fix<30>::ToFix(result); + } +} + //----------------------------------------------------------------------------- diff --git a/src/gl/scene/gl_clipper.h b/src/gl/scene/gl_clipper.h index 8092cd284..7d05cf701 100644 --- a/src/gl/scene/gl_clipper.h +++ b/src/gl/scene/gl_clipper.h @@ -137,12 +137,13 @@ public: extern Clipper clipper; angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y); +angle_t R_PointToPseudoAngle(double x, double y); void R_SetView(); // Used to speed up angle calculations during clipping inline angle_t vertex_t::GetClipAngle() { - return angletime == Clipper::anglecache? viewangle : (angletime = Clipper::anglecache, viewangle = R_PointToPseudoAngle(x,y)); + return angletime == Clipper::anglecache? viewangle : (angletime = Clipper::anglecache, viewangle = R_PointToPseudoAngle(p.X, p.Y)); } #endif \ No newline at end of file diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index d234d29c9..40b6a5881 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -174,32 +174,15 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli) void GLFlat::DrawSubsector(subsector_t * sub) { FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - if (plane.plane.isSlope()) + for (unsigned int k = 0; k < sub->numlines; k++) { - for (unsigned int k = 0; k < sub->numlines; k++) - { - vertex_t *vt = sub->firstline[k].v1; - ptr->x = vt->fx; - ptr->y = vt->fy; - ptr->z = plane.plane.ZatPoint(vt->fx, vt->fy) + dz; - ptr->u = vt->fx / 64.f; - ptr->v = -vt->fy / 64.f; - ptr++; - } - } - else - { - float zc = FIXED2FLOAT(plane.plane.Zat0()) + dz; - for (unsigned int k = 0; k < sub->numlines; k++) - { - vertex_t *vt = sub->firstline[k].v1; - ptr->x = vt->fx; - ptr->y = vt->fy; - ptr->z = zc; - ptr->u = vt->fx / 64.f; - ptr->v = -vt->fy / 64.f; - ptr++; - } + vertex_t *vt = sub->firstline[k].v1; + ptr->x = vt->fX(); + ptr->y = vt->fY(); + ptr->z = plane.plane.ZatPoint(vt) + dz; + ptr->u = vt->fX() / 64.f; + ptr->v = -vt->fY() / 64.f; + ptr++; } GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); diff --git a/src/gl/scene/gl_vertex.cpp b/src/gl/scene/gl_vertex.cpp index c0f21adce..3c41f52bd 100644 --- a/src/gl/scene/gl_vertex.cpp +++ b/src/gl/scene/gl_vertex.cpp @@ -82,8 +82,8 @@ void GLWall::SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr) float fracfac = sidefrac - glseg.fracleft; - ptr->x = cseg->v2->fx; - ptr->y = cseg->v2->fy; + ptr->x = cseg->v2->fX(); + ptr->y = cseg->v2->fY(); ptr->z = ztop[0] + fact * fracfac; ptr->u = tcs[1].u + facu * fracfac; ptr->v = tcs[1].v + facv * fracfac; @@ -118,8 +118,8 @@ void GLWall::SplitLowerEdge(texcoord * tcs, FFlatVertex *&ptr) float fracfac = sidefrac - glseg.fracleft; - ptr->x = cseg->v2->fx; - ptr->y = cseg->v2->fy; + ptr->x = cseg->v2->fX(); + ptr->y = cseg->v2->fY(); ptr->z = zbottom[0] + facb * fracfac; ptr->u = tcs[0].u + facu * fracfac; ptr->v = tcs[0].v + facv * fracfac; diff --git a/src/gl/utility/gl_geometric.h b/src/gl/utility/gl_geometric.h index 6868dab21..3691d7740 100644 --- a/src/gl/utility/gl_geometric.h +++ b/src/gl/utility/gl_geometric.h @@ -33,8 +33,8 @@ public: Vector(vertex_t * v) { - SetX(v->fx); - SetY(v->fy); + SetX((float)v->fX()); + SetY((float)v->fY()); SetZ(0); } diff --git a/src/r_defs.h b/src/r_defs.h index d820fbfb9..6cf07b817 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -105,48 +105,48 @@ typedef double vtype; struct vertex_t { //private: - fixed_t x, y; + DVector2 p; + //fixed_t x, y; public: void set(fixed_t x, fixed_t y) { - this->x = x; - this->y = y; + p.X = x / 65536.; + p.Y = y / 65536.; } void set(double x, double y) { - this->x = FLOAT2FIXED(x); - this->y = FLOAT2FIXED(y); + p.X = x; + p.Y = y; } double fX() const { - return FIXED2DBL(x); + return p.X; } double fY() const { - return FIXED2DBL(y); + return p.Y; } fixed_t fixX() const { - return x; + return FLOAT2FIXED(p.X); } fixed_t fixY() const { - return y; + return FLOAT2FIXED(p.Y); } DVector2 fPos() { - return{ fX(), fY() }; + return { p.X, p.Y }; } - float fx, fy; // Floating point coordinates of this vertex (excluding polyoblect translation!) angle_t viewangle; // precalculated angle for clipping int angletime; // recalculation time for view angle bool dirty; // something has changed and needs to be recalculated @@ -157,8 +157,7 @@ public: vertex_t() { - x = y = 0; - fx = fy = 0; + p = { 0,0 }; angletime = 0; viewangle = 0; dirty = true; @@ -169,17 +168,17 @@ public: bool operator== (const vertex_t &other) { - return x == other.x && y == other.y; + return p == other.p; } bool operator!= (const vertex_t &other) { - return x != other.x || y != other.y; + return p != other.p; } void clear() { - x = y = 0; + p.Zero(); } angle_t GetClipAngle(); @@ -397,12 +396,12 @@ public: // This is for the software renderer fixed_t ZatPointFixed(const DVector2 &pos) const { - return xs_CRoundToInt((d + a*pos.X + b*pos.Y) * ic / (-65536.0)); + return FLOAT2FIXED(ZatPoint(pos)); } fixed_t ZatPointFixed(const vertex_t *v) const { - return FixedMul(ic, -d - DMulScale16(a, v->fixX(), b, v->fixY())); + return FLOAT2FIXED(ZatPoint(v)); } @@ -420,7 +419,7 @@ public: double ZatPoint(const vertex_t *v) const { - return FIXED2DBL(FixedMul(ic, -d - DMulScale16(a, v->fixX(), b, v->fixY()))); + return (d + a*v->fX() + b*v->fY()) * ic / (-65536.0 * 65536.0); } double ZatPoint(const AActor *ac) const @@ -431,7 +430,7 @@ public: // Returns the value of z at vertex v if d is equal to dist double ZatPointDist(const vertex_t *v, double dist) { - return FIXED2DBL(FixedMul(ic, -FLOAT2FIXED(dist) - DMulScale16(a, v->fixX(), b, v->fixY()))); + return (dist + a*v->fX() + b*v->fY()) * ic / (-65536.0 * 65536.0); } // Flips the plane's vertical orientiation, so that if it pointed up, // it will point down, and vice versa. From 58eb64a7e0267959f66cec458d325dea50fdce11 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Apr 2016 12:54:47 +0200 Subject: [PATCH 0447/1509] - fixed a few fixed/float parameter mixups. --- src/gl/dynlights/a_dynlight.cpp | 2 +- src/gl/dynlights/gl_dynlight.h | 2 +- src/gl/models/gl_models.cpp | 6 +++--- src/gl/models/gl_models.h | 2 +- src/gl/scene/gl_wall.h | 10 +++++----- src/gl/scene/gl_walls.cpp | 28 ++++++++++++++-------------- src/r_defs.h | 3 +-- 7 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index f9e11a2f2..05488bb3c 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -388,7 +388,7 @@ void ADynamicLight::UpdateLocation() // //========================================================================== -void ADynamicLight::SetOrigin(fixed_t x, fixed_t y, fixed_t z, bool moving) +void ADynamicLight::SetOrigin(double x, double y, double z, bool moving) { Super::SetOrigin(x, y, z, moving); LinkLight(); diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index aa3f28ae2..12ec600cd 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -82,7 +82,7 @@ public: size_t PointerSubstitution (DObject *old, DObject *notOld); void BeginPlay(); - void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving = false); + void SetOrigin (double x, double y, double z, bool moving = false); void PostBeginPlay(); void Destroy(); void Activate(AActor *activator); diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index a33a91604..a03a73931 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -944,7 +944,7 @@ void gl_RenderModel(GLSprite * spr) // //=========================================================================== -void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy) +void gl_RenderHUDModel(pspdef_t *psp, float ofsX, float ofsY) { AActor * playermo=players[consoleplayer].camera; FSpriteModelFrame *smf = gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->state->sprite, psp->state->GetFrame(), false); @@ -975,8 +975,8 @@ void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy) gl_RenderState.mViewMatrix.translate(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); // [BB] Weapon bob, very similar to the normal Doom weapon bob. - gl_RenderState.mViewMatrix.rotate(FIXED2FLOAT(ofsx)/4, 0, 1, 0); - gl_RenderState.mViewMatrix.rotate(-FIXED2FLOAT(ofsy-WEAPONTOP)/4, 1, 0, 0); + gl_RenderState.mViewMatrix.rotate(ofsX/4, 0, 1, 0); + gl_RenderState.mViewMatrix.rotate(-ofsY-WEAPONTOP/4, 1, 0, 0); // [BB] For some reason the jDoom models need to be rotated. gl_RenderState.mViewMatrix.rotate(90.f, 0, 1, 0); diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 0159d2667..a99f81322 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -365,7 +365,7 @@ FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame, void gl_RenderModel(GLSprite * spr); // [BB] HUD weapon model rendering functions. -void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy); +void gl_RenderHUDModel(pspdef_t *psp, float ofsx, float ofsy); bool gl_IsHUDModelForPlayerAvailable (player_t * player); #endif diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 3308904e9..b36248004 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -191,13 +191,13 @@ private: bool DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2); bool SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float ceilingrefheight, - int topleft,int topright, int bottomleft,int bottomright, int texoffset); + fixed_t topleft, fixed_t topright, fixed_t bottomleft, fixed_t bottomright, fixed_t t_ofs); void DoTexture(int type,seg_t * seg,int peg, - int ceilingrefheight,int floorrefheight, - int CeilingHeightstart,int CeilingHeightend, - int FloorHeightstart,int FloorHeightend, - int v_offset); + fixed_t ceilingrefheight,fixed_t floorrefheight, + fixed_t CeilingHeightstart,fixed_t CeilingHeightend, + fixed_t FloorHeightstart,fixed_t FloorHeightend, + fixed_t v_offset); void DoMidTexture(seg_t * seg, bool drawfogboundary, sector_t * front, sector_t * back, diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 73732c209..d1cc5943c 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -395,7 +395,7 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) if (viewz > fs->GetPlaneTexZ(sector_t::floor)) { - zbottom[1] = zbottom[0] = FIXED2FLOAT(fs->GetPlaneTexZ(sector_t::floor)); + zbottom[1] = zbottom[0] = fs->GetPlaneTexZF(sector_t::floor); if (fs->GetTexture(sector_t::floor) == skyflatnum) { SkyPlane(fs, sector_t::floor, false); @@ -428,7 +428,7 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) // //========================================================================== bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float texturetop, - int topleft,int topright, int bottomleft,int bottomright, int t_ofs) + fixed_t topleft, fixed_t topright, fixed_t bottomleft, fixed_t bottomright, fixed_t t_ofs) { // // @@ -597,10 +597,10 @@ void GLWall::CheckTexturePosition() // //========================================================================== void GLWall::DoTexture(int _type,seg_t * seg, int peg, - int ceilingrefheight,int floorrefheight, - int topleft,int topright, - int bottomleft,int bottomright, - int v_offset) + fixed_t ceilingrefheight,fixed_t floorrefheight, + fixed_t topleft,fixed_t topright, + fixed_t bottomleft,fixed_t bottomright, + fixed_t v_offset) { if (topleft<=bottomleft && topright<=bottomright) return; @@ -1428,15 +1428,15 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) topplane = frontsector->ceilingplane; bottomplane = frontsector->floorplane; - ffh1 = segfront->floorplane.ZatPointFixed(v1); - ffh2 = segfront->floorplane.ZatPointFixed(v2); - zfloor[0] = FIXED2FLOAT(ffh1); - zfloor[1] = FIXED2FLOAT(ffh2); + zfloor[0] = segfront->floorplane.ZatPoint(v1); + zfloor[1] = segfront->floorplane.ZatPoint(v2); + ffh1 = FLOAT2FIXED(zfloor[0]); + ffh2 = FLOAT2FIXED(zfloor[1]); - fch1 = segfront->ceilingplane.ZatPointFixed(v1); - fch2 = segfront->ceilingplane.ZatPointFixed(v2); - zceil[0] = FIXED2FLOAT(fch1); - zceil[1] = FIXED2FLOAT(fch2); + zceil[0] = segfront->ceilingplane.ZatPoint(v1); + zceil[1] = segfront->ceilingplane.ZatPoint(v2); + fch1 = FLOAT2FIXED(zceil[0]); + fch2 = FLOAT2FIXED(zceil[1]); if (seg->linedef->special == Line_Horizon) { diff --git a/src/r_defs.h b/src/r_defs.h index 6cf07b817..3fe0885a1 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -104,9 +104,8 @@ typedef double vtype; struct vertex_t { -//private: +private: DVector2 p; - //fixed_t x, y; public: From 252a6e903829e48ee0afc1abdcf2dfe18e90a4ec Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Apr 2016 13:00:09 +0200 Subject: [PATCH 0448/1509] - removed back and forth fixed<->float conversions in sprite code. --- src/gl/scene/gl_sprite.cpp | 12 ++++++------ src/gl/scene/gl_wall.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 4bdd5b517..0650e9790 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -378,7 +378,7 @@ inline void GLSprite::PutSprite(bool translucent) // //========================================================================== -void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_t thingy, float spriteheight) +void GLSprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight) { bool smarterclip = false; // Set to true if one condition triggers the test below if (((thing->player || thing->flags3&MF3_ISMONSTER || @@ -394,8 +394,8 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_ for (unsigned int i = 0; i < x.ffloors.Size(); i++) { F3DFloor * ff = x.ffloors[i]; - float floorh = FIXED2FLOAT(ff->top.plane->ZatPointFixed(thingx, thingy)); - float ceilingh = FIXED2FLOAT(ff->bottom.plane->ZatPointFixed(thingx, thingy)); + float floorh = ff->top.plane->ZatPoint(thingpos); + float ceilingh = ff->bottom.plane->ZatPoint(thingpos); if (floorh == thing->floorz) { btm = floorh; @@ -413,7 +413,7 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_ else if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) { if (thing->flags2&MF2_ONMOBJ && thing->floorz == - FIXED2FLOAT(thing->Sector->heightsec->floorplane.ZatPointFixed(thingx, thingy))) + thing->Sector->heightsec->floorplane.ZatPoint(thingpos))) { btm = thing->floorz; top = thing->ceilingz; @@ -422,7 +422,7 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_ if (btm == 1000000.0f) btm = thing->Sector->floorplane.ZatPoint(thing) - thing->Floorclip; if (top == -1000000.0f) - top = FIXED2FLOAT(thing->Sector->ceilingplane.ZatPointFixed(thingx, thingy)); + top = thing->Sector->ceilingplane.ZatPoint(thingpos); // +/-1 to account for the one pixel empty frame around the sprite. float diffb = (z2+1) - btm; @@ -604,7 +604,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) // Tests show that this doesn't look good for many decorations and corpses if (spriteheight > 0 && gl_spriteclip > 0 && (thing->renderflags & RF_SPRITETYPEMASK) == RF_FACESPRITE) { - PerformSpriteClipAdjustment(thing, FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y), spriteheight); + PerformSpriteClipAdjustment(thing, thingpos, spriteheight); } float viewvecX; diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index b36248004..10df57c63 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -342,7 +342,7 @@ public: TArray *lightlist; void SetLowerParam(); - void PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_t thingy, float spriteheight); + void PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight); public: From 603af1bb92002332f22e6431ad75259cce7bd72b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Apr 2016 22:13:38 +0200 Subject: [PATCH 0449/1509] - compile bug in gl_sprite and some optimization in gl_walls.cpp --- src/gl/scene/gl_sprite.cpp | 2 +- src/gl/scene/gl_walls.cpp | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 0650e9790..4414e3874 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -413,7 +413,7 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingp else if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) { if (thing->flags2&MF2_ONMOBJ && thing->floorz == - thing->Sector->heightsec->floorplane.ZatPoint(thingpos))) + thing->Sector->heightsec->floorplane.ZatPoint(thingpos)) { btm = thing->floorz; top = thing->ceilingz; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index d1cc5943c..043dd215a 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1428,15 +1428,22 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) topplane = frontsector->ceilingplane; bottomplane = frontsector->floorplane; - zfloor[0] = segfront->floorplane.ZatPoint(v1); - zfloor[1] = segfront->floorplane.ZatPoint(v2); - ffh1 = FLOAT2FIXED(zfloor[0]); - ffh2 = FLOAT2FIXED(zfloor[1]); + double v; + v= segfront->floorplane.ZatPoint(v1); + zfloor[0] = v; + ffh1 = FLOAT2FIXED(v); - zceil[0] = segfront->ceilingplane.ZatPoint(v1); - zceil[1] = segfront->ceilingplane.ZatPoint(v2); - fch1 = FLOAT2FIXED(zceil[0]); - fch2 = FLOAT2FIXED(zceil[1]); + v = segfront->floorplane.ZatPoint(v2); + zfloor[1] = v; + ffh2 = FLOAT2FIXED(v); + + v = segfront->ceilingplane.ZatPoint(v1); + zceil[0] = v; + fch1 = FLOAT2FIXED(v); + + v = segfront->ceilingplane.ZatPoint(v2); + zceil[1] = v; + fch2 = FLOAT2FIXED(v); if (seg->linedef->special == Line_Horizon) { From cbcde3a950abf62d2989063034506ab020b9e00b Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 4 Apr 2016 12:10:26 +0300 Subject: [PATCH 0450/1509] Fixed check for alpha channel in texture to select hqNx upscaling mode Now it's the initial check with the adjustment in mode indices only, as old hqNx MMX indices (4..6) are now occupied by generic hqNx implementation See http://forum.drdteam.org/viewtopic.php?t=6872 --- src/gl/textures/gl_hqresize.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 1563895b5..2118352b7 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -289,8 +289,8 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u outWidth = inWidth; outHeight = inHeight; #ifdef HAVE_MMX - // ASM-hqNx does not preserve the alpha channel so fall back to C-version for such textures - if (!hasAlpha && type > 6 && type <= 9) + // hqNx MMX does not preserve the alpha channel so fall back to C-version for such textures + if (hasAlpha && type > 6 && type <= 9) { type -= 3; } From f6b33acbb1ca042c5488ead2bb50be776e4b45bb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 4 Apr 2016 12:22:47 +0200 Subject: [PATCH 0451/1509] - fixed plane access in GL code. --- src/gl/renderer/gl_renderstate.h | 12 ++++++++---- src/gl/utility/gl_geometric.cpp | 11 ++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 87df78a6b..7436135a6 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -275,14 +275,18 @@ public: void SetGlowPlanes(const secplane_t &top, const secplane_t &bottom) { - mGlowTopPlane.Set(top.fA(), top.fB(), 1. / top.fC(), top.fD()); - mGlowBottomPlane.Set(bottom.fA(), bottom.fB(), 1. / bottom.fC(), bottom.fD()); + DVector3 tn = top.Normal(); + DVector3 bn = bottom.Normal(); + mGlowTopPlane.Set(tn.X, tn.Y, 1. / tn.Z, top.fD()); + mGlowBottomPlane.Set(bn.X, bn.Y, 1. / bn.Z, bottom.fD()); } void SetSplitPlanes(const secplane_t &top, const secplane_t &bottom) { - mSplitTopPlane.Set(top.fA(), top.fB(), 1. / top.fC(), top.fD()); - mSplitBottomPlane.Set(bottom.fA(), bottom.fB(), 1. / bottom.fC(), bottom.fD()); + DVector3 tn = top.Normal(); + DVector3 bn = bottom.Normal(); + mSplitTopPlane.Set(tn.X, tn.Y, 1. / tn.Z, top.fD()); + mSplitBottomPlane.Set(bn.X, bn.Y, 1. / bn.Z, bottom.fD()); } void SetDynLight(float r, float g, float b) diff --git a/src/gl/utility/gl_geometric.cpp b/src/gl/utility/gl_geometric.cpp index ef9bc88d4..c2ea6da59 100644 --- a/src/gl/utility/gl_geometric.cpp +++ b/src/gl/utility/gl_geometric.cpp @@ -227,16 +227,9 @@ void Plane::Init(float a, float b, float c, float d) void Plane::Set(secplane_t &plane) { - float a, b, c, d; - - a = (float)plane.fA(); - b = (float)plane.fB(); - c = (float)plane.fC(); - d = (float)plane.fD(); - - m_normal.Set(a, c, b); + m_normal.Set(plane.Normal().X, plane.Normal().Z, plane.Normal().Y); //m_normal.Normalize(); the vector is already normalized - m_d = d; + m_d = plane.fD(); } From a0d0d9339eb725dfbeabe41a3176fa542da5eeba Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 6 Apr 2016 14:03:21 +0200 Subject: [PATCH 0452/1509] - fixed some uninitialized stuff in particle rendering. - added gl_ClampLight to all places where the light level is set. --- src/gl/scene/gl_flats.cpp | 6 +++--- src/gl/scene/gl_sprite.cpp | 8 +++++++- src/gl/scene/gl_wall.h | 2 +- src/gl/scene/gl_weapon.cpp | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 40b6a5881..9fd5d15fb 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -447,7 +447,7 @@ void GLFlat::SetFrom3DFloor(F3DFloor *rover, bool top, bool underside) // FF_FOG requires an inverted logic where to get the light from lightlist_t *light = P_GetPlaneLight(sector, plane.plane, underside); - lightlevel = *light->p_lightlevel; + lightlevel = gl_ClampLight(*light->p_lightlevel); if (rover->flags & FF_FOG) Colormap.LightColor = (light->extra_colormap)->Fade; else Colormap.CopyFrom3DLight(light); @@ -544,7 +544,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) if ((!(sector->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING) || light->lightsource == NULL) && (light->p_lightlevel != &frontsector->lightlevel)) { - lightlevel = *light->p_lightlevel; + lightlevel = gl_ClampLight(*light->p_lightlevel); } Colormap.CopyFrom3DLight(light); @@ -607,7 +607,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) if ((!(sector->GetFlags(sector_t::ceiling)&PLANEF_ABSLIGHTING)) && (light->p_lightlevel != &frontsector->lightlevel)) { - lightlevel = *light->p_lightlevel; + lightlevel = gl_ClampLight(*light->p_lightlevel); } Colormap.CopyFrom3DLight(light); } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 4414e3874..630229ff6 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -866,11 +866,15 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s if (lightbottom < particle->Pos.Z) { - lightlevel = *lightlist[i].p_lightlevel; + lightlevel = gl_ClampLight(*lightlist[i].p_lightlevel); Colormap.LightColor = (lightlist[i].extra_colormap)->Color; break; } } + if (glset.nocoloredspritelighting) + { + Colormap.Decolorize(); // ZDoom never applies colored light to particles. + } } else { @@ -884,6 +888,7 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s OverrideShader = 0; ThingColor = particle->color; + ThingColor.g = 255; ThingColor.a = 255; modelframe=NULL; @@ -939,6 +944,7 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s actor=NULL; this->particle=particle; + fullbright = !!particle->bright; // [BB] Translucent particles have to be rendered without the alpha test. if (gl_particles_style != 2 && trans>=1.0f-FLT_EPSILON) hw_styleflags = STYLEHW_Solid; diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 10df57c63..f6dde1531 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -314,7 +314,7 @@ public: friend struct GLDrawList; friend void Mod_RenderModel(GLSprite * spr, model_t * mdl, int framenumber); - BYTE lightlevel; + int lightlevel; BYTE foglevel; BYTE hw_styleflags; bool fullbright; diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index e086007f5..9c179e148 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -272,7 +272,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) if (lightbottomviewz) { cm = lightlist[i].extra_colormap; - lightlevel = *lightlist[i].p_lightlevel; + lightlevel = gl_ClampLight(*lightlist[i].p_lightlevel); break; } } From dbad946fe3ad6dd0813b402ba54b8486feb19536 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 6 Apr 2016 22:09:21 +0200 Subject: [PATCH 0453/1509] - revert default planes to static in gl_sprite.cpp --- src/gl/scene/gl_sprite.cpp | 5 ++--- src/r_defs.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 630229ff6..c48dc7107 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -237,9 +237,8 @@ void GLSprite::Draw(int pass) if (lightlist) { // set up the light slice -#pragma message ("Undo this!") - secplane_t bottommost; bottommost.set(0, 0, FRACUNIT, 32767 << FRACBITS); - secplane_t topmost; topmost.set(0, 0, FRACUNIT, -(32767 << FRACBITS)); + static secplane_t bottommost = { {0, 0, 1.}, FLT_MAX }; + static secplane_t topmost = { { 0, 0, 1. }, -FLT_MAX }; secplane_t *topplane = i == 0 ? &topmost : &(*lightlist)[i].plane; secplane_t *lowplane = i == (*lightlist).Size() - 1 ? &bottommost : &(*lightlist)[i + 1].plane; diff --git a/src/r_defs.h b/src/r_defs.h index 5b8d440ac..e96f47a05 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -307,7 +307,7 @@ struct secplane_t // the plane is defined as a*x + b*y + c*z + d = 0 // ic is 1/c, for faster Z calculations -private: +//private: DVector3 normal; double D, negiC; // negative iC because that also saves a negation in all methods using this. public: From 37ddd20b569edcd567cbb7c9eb6478459c2740e5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 10:28:43 +0200 Subject: [PATCH 0454/1509] - removed leftover debug code from yesterday's particle fix. --- src/gl/scene/gl_sprite.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index c48dc7107..0c3daf38c 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -887,7 +887,6 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s OverrideShader = 0; ThingColor = particle->color; - ThingColor.g = 255; ThingColor.a = 255; modelframe=NULL; From 4af859094c7db491ef91d96dc7ae7b23fecc3164 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 14:09:07 +0200 Subject: [PATCH 0455/1509] - fixed: sprite clipping did not work anymore because the 'invalid' value was inconsistent. - cleaned up the 'if' condition in PerformSpriteClipAdjustment, - enabled weapon bobbing interpolation. --- src/gl/scene/gl_sprite.cpp | 19 ++++++++++--------- src/gl/scene/gl_weapon.cpp | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 0c3daf38c..923cb819f 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -379,13 +379,14 @@ inline void GLSprite::PutSprite(bool translucent) void GLSprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight) { - bool smarterclip = false; // Set to true if one condition triggers the test below - if (((thing->player || thing->flags3&MF3_ISMONSTER || - thing->IsKindOf(RUNTIME_CLASS(AInventory))) && (thing->flags&MF_ICECORPSE || - !(thing->flags&MF_CORPSE))) || (gl_spriteclip == 3 && (smarterclip = true)) || gl_spriteclip > 1) + const float NO_VAL = 100000000.0f; + bool clipthing = (thing->player || thing->flags3&MF3_ISMONSTER || thing->IsKindOf(RUNTIME_CLASS(AInventory))) && (thing->flags&MF_ICECORPSE || !(thing->flags&MF_CORPSE)); + bool smarterclip = !clipthing && gl_spriteclip == 3; + if (clipthing || gl_spriteclip > 1) { - float btm = 100000000.0f; - float top = -100000000.0f; + + float btm = NO_VAL; + float top = -NO_VAL; extsector_t::xfloor &x = thing->Sector->e->XFloor; if (x.ffloors.Size()) @@ -403,7 +404,7 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingp { top = ceilingh; } - if (btm != 100000000.0f && top != -100000000.0f) + if (btm != NO_VAL && top != -NO_VAL) { break; } @@ -418,9 +419,9 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingp top = thing->ceilingz; } } - if (btm == 1000000.0f) + if (btm == NO_VAL) btm = thing->Sector->floorplane.ZatPoint(thing) - thing->Floorclip; - if (top == -1000000.0f) + if (top == NO_VAL) top = thing->Sector->ceilingplane.ZatPoint(thingpos); // +/-1 to account for the one pixel empty frame around the sprite. diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 9c179e148..171692497 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -202,7 +202,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) (r_deathcamera && camera->health <= 0)) return; - P_BobWeapon (player, &player->psprites[ps_weapon], &ofsx, &ofsy); + P_BobWeapon (player, &player->psprites[ps_weapon], &ofsx, &ofsy, r_TicFracF); // check for fullbright if (player->fixedcolormap==NOFIXEDCOLORMAP) From 485a1bd0a5c61579ea157c0867326a2bb7305c0c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 16:25:30 +0200 Subject: [PATCH 0456/1509] - fixed: The 3D-floor plane renderer mixed float and fixed point. --- src/gl/scene/gl_flats.cpp | 110 +++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 9fd5d15fb..6dd611cdd 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -478,16 +478,16 @@ void GLFlat::ProcessSector(sector_t * frontsector) lightlist_t * light; #ifdef _DEBUG - if (frontsector->sectornum==gl_breaksec) + if (frontsector->sectornum == gl_breaksec) { int a = 0; } #endif // Get the real sector for this one. - sector=§ors[frontsector->sectornum]; + sector = §ors[frontsector->sectornum]; extsector_t::xfloor &x = sector->e->XFloor; - this->sub=NULL; + this->sub = NULL; dynlightindex = -1; byte &srf = gl_drawinfo->sectorrenderflags[sector->sectornum]; @@ -506,7 +506,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) srf |= SSRF_RENDERFLOOR; lightlevel = gl_ClampLight(frontsector->GetFloorLight()); - Colormap=frontsector->ColorMap; + Colormap = frontsector->ColorMap; if ((stack = (frontsector->portals[sector_t::floor] != NULL))) { if (!frontsector->PortalBlocksView(sector_t::floor)) @@ -524,7 +524,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) } else { - alpha = 1.0f-frontsector->GetReflect(sector_t::floor); + alpha = 1.0f - frontsector->GetReflect(sector_t::floor); } if (frontsector->VBOHeightcheck(sector_t::floor)) { @@ -535,13 +535,13 @@ void GLFlat::ProcessSector(sector_t * frontsector) vboindex = -1; } - ceiling=false; - renderflags=SSRF_RENDERFLOOR; + ceiling = false; + renderflags = SSRF_RENDERFLOOR; if (x.ffloors.Size()) { light = P_GetPlaneLight(sector, &frontsector->floorplane, false); - if ((!(sector->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING) || light->lightsource == NULL) + if ((!(sector->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING) || light->lightsource == NULL) && (light->p_lightlevel != &frontsector->lightlevel)) { lightlevel = gl_ClampLight(*light->p_lightlevel); @@ -550,9 +550,9 @@ void GLFlat::ProcessSector(sector_t * frontsector) Colormap.CopyFrom3DLight(light); } renderstyle = STYLE_Translucent; - if (alpha!=0.0f) Process(frontsector, false, false); + if (alpha != 0.0f) Process(frontsector, false, false); } - + // // // @@ -567,8 +567,8 @@ void GLFlat::ProcessSector(sector_t * frontsector) srf |= SSRF_RENDERCEILING; lightlevel = gl_ClampLight(frontsector->GetCeilingLight()); - Colormap=frontsector->ColorMap; - if ((stack = (frontsector->portals[sector_t::ceiling] != NULL))) + Colormap = frontsector->ColorMap; + if ((stack = (frontsector->portals[sector_t::ceiling] != NULL))) { if (!frontsector->PortalBlocksView(sector_t::ceiling)) { @@ -585,7 +585,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) } else { - alpha = 1.0f-frontsector->GetReflect(sector_t::ceiling); + alpha = 1.0f - frontsector->GetReflect(sector_t::ceiling); } if (frontsector->VBOHeightcheck(sector_t::ceiling)) @@ -597,8 +597,8 @@ void GLFlat::ProcessSector(sector_t * frontsector) vboindex = -1; } - ceiling=true; - renderflags=SSRF_RENDERCEILING; + ceiling = true; + renderflags = SSRF_RENDERCEILING; if (x.ffloors.Size()) { @@ -612,7 +612,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) Colormap.CopyFrom3DLight(light); } renderstyle = STYLE_Translucent; - if (alpha!=0.0f) Process(frontsector, true, false); + if (alpha != 0.0f) Process(frontsector, true, false); } // @@ -623,79 +623,79 @@ void GLFlat::ProcessSector(sector_t * frontsector) // // - stack=false; + stack = false; if (x.ffloors.Size()) { - player_t * player=players[consoleplayer].camera->player; + player_t * player = players[consoleplayer].camera->player; - renderflags=SSRF_RENDER3DPLANES; + renderflags = SSRF_RENDER3DPLANES; srf |= SSRF_RENDER3DPLANES; // 3d-floors must not overlap! - fixed_t lastceilingheight=sector->CenterCeiling(); // render only in the range of the - fixed_t lastfloorheight=sector->CenterFloor(); // current sector part (if applicable) - F3DFloor * rover; + double lastceilingheight = sector->CenterCeiling(); // render only in the range of the + double lastfloorheight = sector->CenterFloor(); // current sector part (if applicable) + F3DFloor * rover; int k; - + // floors are ordered now top to bottom so scanning the list for the best match // is no longer necessary. - ceiling=true; - for(k=0;k<(int)x.ffloors.Size();k++) + ceiling = true; + for (k = 0; k < (int)x.ffloors.Size(); k++) { - rover=x.ffloors[k]; - - if ((rover->flags&(FF_EXISTS|FF_RENDERPLANES|FF_THISINSIDE))==(FF_EXISTS|FF_RENDERPLANES)) + rover = x.ffloors[k]; + + if ((rover->flags&(FF_EXISTS | FF_RENDERPLANES | FF_THISINSIDE)) == (FF_EXISTS | FF_RENDERPLANES)) { if (rover->flags&FF_FOG && gl_fixedcolormap) continue; - if (!rover->top.copied && rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) + if (!rover->top.copied && rover->flags&(FF_INVERTPLANES | FF_BOTHPLANES)) { - fixed_t ff_top=FLOAT2FIXED(rover->top.plane->ZatPoint(sector->centerspot)); - if (ff_toptop.plane->ZatPoint(sector->centerspot); + if (ff_top < lastceilingheight) { if (ViewPos.Z <= rover->top.plane->ZatPoint(ViewPos)) { SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG)); - Colormap.FadeColor=frontsector->ColorMap->Fade; + Colormap.FadeColor = frontsector->ColorMap->Fade; Process(rover->top.model, rover->top.isceiling, !!(rover->flags&FF_FOG)); } - lastceilingheight=ff_top; + lastceilingheight = ff_top; } } if (!rover->bottom.copied && !(rover->flags&FF_INVERTPLANES)) { - fixed_t ff_bottom=FLOAT2FIXED(rover->bottom.plane->ZatPoint(sector->centerspot)); - if (ff_bottombottom.plane->ZatPoint(sector->centerspot); + if (ff_bottom < lastceilingheight) { - if (ViewPos.Z <=rover->bottom.plane->ZatPoint(ViewPos)) + if (ViewPos.Z <= rover->bottom.plane->ZatPoint(ViewPos)) { SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG)); - Colormap.FadeColor=frontsector->ColorMap->Fade; + Colormap.FadeColor = frontsector->ColorMap->Fade; Process(rover->bottom.model, rover->bottom.isceiling, !!(rover->flags&FF_FOG)); } - lastceilingheight=ff_bottom; - if (rover->alpha<255) lastceilingheight++; + lastceilingheight = ff_bottom; + if (rover->alpha < 255) lastceilingheight += EQUAL_EPSILON; } } } } - - ceiling=false; - for(k=x.ffloors.Size()-1;k>=0;k--) + + ceiling = false; + for (k = x.ffloors.Size() - 1; k >= 0; k--) { - rover=x.ffloors[k]; - - if ((rover->flags&(FF_EXISTS|FF_RENDERPLANES|FF_THISINSIDE))==(FF_EXISTS|FF_RENDERPLANES)) + rover = x.ffloors[k]; + + if ((rover->flags&(FF_EXISTS | FF_RENDERPLANES | FF_THISINSIDE)) == (FF_EXISTS | FF_RENDERPLANES)) { if (rover->flags&FF_FOG && gl_fixedcolormap) continue; - if (!rover->bottom.copied && rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) + if (!rover->bottom.copied && rover->flags&(FF_INVERTPLANES | FF_BOTHPLANES)) { - fixed_t ff_bottom=FLOAT2FIXED(rover->bottom.plane->ZatPoint(sector->centerspot)); - if (ff_bottom>lastfloorheight || (rover->flags&FF_FIX)) + double ff_bottom = rover->bottom.plane->ZatPoint(sector->centerspot); + if (ff_bottom > lastfloorheight || (rover->flags&FF_FIX)) { if (ViewPos.Z >= rover->bottom.plane->ZatPoint(ViewPos)) { SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG)); - Colormap.FadeColor=frontsector->ColorMap->Fade; + Colormap.FadeColor = frontsector->ColorMap->Fade; if (rover->flags&FF_FIX) { @@ -705,22 +705,22 @@ void GLFlat::ProcessSector(sector_t * frontsector) Process(rover->bottom.model, rover->bottom.isceiling, !!(rover->flags&FF_FOG)); } - lastfloorheight=ff_bottom; + lastfloorheight = ff_bottom; } } if (!rover->top.copied && !(rover->flags&FF_INVERTPLANES)) { - fixed_t ff_top=FLOAT2FIXED(rover->top.plane->ZatPoint(sector->centerspot)); - if (ff_top>lastfloorheight) + double ff_top = rover->top.plane->ZatPoint(sector->centerspot); + if (ff_top > lastfloorheight) { if (ViewPos.Z >= rover->top.plane->ZatPoint(ViewPos)) { SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG)); - Colormap.FadeColor=frontsector->ColorMap->Fade; + Colormap.FadeColor = frontsector->ColorMap->Fade; Process(rover->top.model, rover->top.isceiling, !!(rover->flags&FF_FOG)); } - lastfloorheight=ff_top; - if (rover->alpha<255) lastfloorheight--; + lastfloorheight = ff_top; + if (rover->alpha < 255) lastfloorheight -= EQUAL_EPSILON; } } } From ee3e3e35e621914b34cc9e18c8066ba0bdfbf91a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 17:00:13 +0200 Subject: [PATCH 0457/1509] - partial floatification of wall texturing code. --- src/gl/scene/gl_wall.h | 6 +- src/gl/scene/gl_walls.cpp | 141 ++++++++++++++++---------------------- 2 files changed, 62 insertions(+), 85 deletions(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index f6dde1531..17c3c841f 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -191,12 +191,12 @@ private: bool DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2); bool SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float ceilingrefheight, - fixed_t topleft, fixed_t topright, fixed_t bottomleft, fixed_t bottomright, fixed_t t_ofs); + float topleft, float topright, float bottomleft, float bottomright, fixed_t t_ofs); void DoTexture(int type,seg_t * seg,int peg, fixed_t ceilingrefheight,fixed_t floorrefheight, - fixed_t CeilingHeightstart,fixed_t CeilingHeightend, - fixed_t FloorHeightstart,fixed_t FloorHeightend, + float CeilingHeightstart,float CeilingHeightend, + float FloorHeightstart,float FloorHeightend, fixed_t v_offset); void DoMidTexture(seg_t * seg, bool drawfogboundary, diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 043dd215a..a684185c6 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -393,7 +393,7 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) ztop[1] = ztop[0] = zbottom[0]; } - if (viewz > fs->GetPlaneTexZ(sector_t::floor)) + if (ViewPos.Z > fs->GetPlaneTexZF(sector_t::floor)) { zbottom[1] = zbottom[0] = fs->GetPlaneTexZF(sector_t::floor); if (fs->GetTexture(sector_t::floor) == skyflatnum) @@ -428,7 +428,7 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) // //========================================================================== bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float texturetop, - fixed_t topleft, fixed_t topright, fixed_t bottomleft, fixed_t bottomright, fixed_t t_ofs) + float topleft, float topright, float bottomleft, float bottomright, fixed_t t_ofs) { // // @@ -438,18 +438,18 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto float l_ul; float texlength; - if (gltexture) + if (gltexture) { - float length = seg->sidedef? seg->sidedef->TexelLength: Dist2(glseg.x1, glseg.y1, glseg.x2, glseg.y2); + float length = seg->sidedef ? seg->sidedef->TexelLength : Dist2(glseg.x1, glseg.y1, glseg.x2, glseg.y2); - l_ul=tci->FloatToTexU(FIXED2FLOAT(tci->TextureOffset(t_ofs))); + l_ul = tci->FloatToTexU(FIXED2FLOAT(tci->TextureOffset(t_ofs))); texlength = tci->FloatToTexU(length); } - else + else { - tci=NULL; - l_ul=0; - texlength=0; + tci = NULL; + l_ul = 0; + texlength = 0; } @@ -458,38 +458,36 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto // set up coordinates for the left side of the polygon // // check left side for intersections - if (topleft>=bottomleft) + if (topleft >= bottomleft) { // normal case - ztop[0]=FIXED2FLOAT(topleft); - zbottom[0]=FIXED2FLOAT(bottomleft); + ztop[0] = topleft; + zbottom[0] = bottomleft; if (tci) { - uplft.v=tci->FloatToTexV(-ztop[0] + texturetop); - lolft.v=tci->FloatToTexV(-zbottom[0] + texturetop); + uplft.v = tci->FloatToTexV(-ztop[0] + texturetop); + lolft.v = tci->FloatToTexV(-zbottom[0] + texturetop); } } else { // ceiling below floor - clip to the visible part of the wall - fixed_t dch=topright-topleft; - fixed_t dfh=bottomright-bottomleft; - fixed_t coeff=FixedDiv(bottomleft-topleft, dch-dfh); + float dch = topright - topleft; + float dfh = bottomright - bottomleft; + float inter_x = (bottomleft - topleft) / (dch - dfh); - fixed_t inter_y=topleft+FixedMul(coeff,dch); - - float inter_x= FIXED2FLOAT(coeff); + float inter_y = topleft + inter_x * dch; glseg.x1 = glseg.x1 + inter_x * (glseg.x2 - glseg.x1); glseg.y1 = glseg.y1 + inter_x * (glseg.y2 - glseg.y1); glseg.fracleft = inter_x; - zbottom[0]=ztop[0]=FIXED2FLOAT(inter_y); + zbottom[0] = ztop[0] = inter_y; if (tci) { - lolft.v=uplft.v=tci->FloatToTexV(-ztop[0] + texturetop); + lolft.v = uplft.v = tci->FloatToTexV(-ztop[0] + texturetop); } } @@ -501,34 +499,32 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto if (topright >= bottomright) { // normal case - ztop[1]=FIXED2FLOAT(topright); - zbottom[1]=FIXED2FLOAT(bottomright); + ztop[1] = topright; + zbottom[1] = bottomright; if (tci) { - uprgt.v=tci->FloatToTexV(-ztop[1] + texturetop); - lorgt.v=tci->FloatToTexV(-zbottom[1] + texturetop); + uprgt.v = tci->FloatToTexV(-ztop[1] + texturetop); + lorgt.v = tci->FloatToTexV(-zbottom[1] + texturetop); } } else { // ceiling below floor - clip to the visible part of the wall - fixed_t dch=topright-topleft; - fixed_t dfh=bottomright-bottomleft; - fixed_t coeff=FixedDiv(bottomleft-topleft, dch-dfh); + float dch = topright - topleft; + float dfh = bottomright - bottomleft; + float inter_x = (bottomleft - topleft) / (dch - dfh); - fixed_t inter_y=topleft+FixedMul(coeff,dch); - - float inter_x= FIXED2FLOAT(coeff); + float inter_y = topleft + inter_x * dch; glseg.x2 = glseg.x1 + inter_x * (glseg.x2 - glseg.x1); glseg.y2 = glseg.y1 + inter_x * (glseg.y2 - glseg.y1); glseg.fracright = inter_x; - zbottom[1]=ztop[1]=FIXED2FLOAT(inter_y); + zbottom[1] = ztop[1] = inter_y; if (tci) { - lorgt.v=uprgt.v=tci->FloatToTexV(-ztop[1] + texturetop); + lorgt.v = uprgt.v = tci->FloatToTexV(-ztop[1] + texturetop); } } @@ -547,13 +543,13 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto if (normalize) { // we have to shift the y-coordinate from [-1..0] to [0..1] when using texture clamping with a negative scale - uplft.v+=1.f; - uprgt.v+=1.f; - lolft.v+=1.f; - lorgt.v+=1.f; + uplft.v += 1.f; + uprgt.v += 1.f; + lolft.v += 1.f; + lorgt.v += 1.f; } } - + return true; } @@ -598,8 +594,8 @@ void GLWall::CheckTexturePosition() //========================================================================== void GLWall::DoTexture(int _type,seg_t * seg, int peg, fixed_t ceilingrefheight,fixed_t floorrefheight, - fixed_t topleft,fixed_t topright, - fixed_t bottomleft,fixed_t bottomright, + float topleft,float topright, + float bottomleft,float bottomright, fixed_t v_offset) { if (topleft<=bottomleft && topright<=bottomright) return; @@ -845,7 +841,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, tci.mRenderHeight = -tci.mRenderHeight; tci.mScaleY = -tci.mScaleY; } - SetWallCoordinates(seg, &tci, FIXED2FLOAT(texturetop), topleft, topright, bottomleft, bottomright, t_ofs); + SetWallCoordinates(seg, &tci, FIXED2FLOAT(texturetop), FIXED2FLOAT(topleft), FIXED2FLOAT(topright), FIXED2FLOAT(bottomleft), FIXED2FLOAT(bottomright), t_ofs); // // @@ -1317,10 +1313,10 @@ void GLWall::DoFFloorBlocks(seg_t * seg,sector_t * frontsector,sector_t * backse void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) { vertex_t * v1, *v2; - fixed_t fch1; - fixed_t ffh1; - fixed_t fch2; - fixed_t ffh2; + float fch1; + float ffh1; + float fch2; + float ffh2; sector_t * realfront; sector_t * realback; sector_t * segfront; @@ -1428,22 +1424,10 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) topplane = frontsector->ceilingplane; bottomplane = frontsector->floorplane; - double v; - v= segfront->floorplane.ZatPoint(v1); - zfloor[0] = v; - ffh1 = FLOAT2FIXED(v); - - v = segfront->floorplane.ZatPoint(v2); - zfloor[1] = v; - ffh2 = FLOAT2FIXED(v); - - v = segfront->ceilingplane.ZatPoint(v1); - zceil[0] = v; - fch1 = FLOAT2FIXED(v); - - v = segfront->ceilingplane.ZatPoint(v2); - zceil[1] = v; - fch2 = FLOAT2FIXED(v); + zfloor[0] = ffh1 = segfront->floorplane.ZatPoint(v1); + zfloor[1] = ffh2 = segfront->floorplane.ZatPoint(v2); + zceil[0] = fch1 = segfront->ceilingplane.ZatPoint(v1); + zceil[1] = fch2 = segfront->ceilingplane.ZatPoint(v2); if (seg->linedef->special == Line_Horizon) { @@ -1482,17 +1466,10 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else // two sided { - - fixed_t bch1; - fixed_t bch2; - fixed_t bfh1; - fixed_t bfh2; - - bfh1 = segback->floorplane.ZatPointFixed(v1); - bfh2 = segback->floorplane.ZatPointFixed(v2); - - bch1 = segback->ceilingplane.ZatPointFixed(v1); - bch2 = segback->ceilingplane.ZatPointFixed(v2); + float bfh1 = segback->floorplane.ZatPoint(v1); + float bfh2 = segback->floorplane.ZatPoint(v2); + float bch1 = segback->ceilingplane.ZatPoint(v1); + float bch2 = segback->ceilingplane.ZatPoint(v2); SkyTop(seg, frontsector, backsector, v1, v2); SkyBottom(seg, frontsector, backsector, v1, v2); @@ -1500,7 +1477,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) // upper texture if (frontsector->GetTexture(sector_t::ceiling) != skyflatnum || backsector->GetTexture(sector_t::ceiling) != skyflatnum) { - fixed_t bch1a = bch1, bch2a = bch2; + float bch1a = bch1, bch2a = bch2; if (frontsector->GetTexture(sector_t::floor) != skyflatnum || backsector->GetTexture(sector_t::floor) != skyflatnum) { // the back sector's floor obstructs part of this wall @@ -1563,26 +1540,26 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture || drawfogboundary) { DoMidTexture(seg, drawfogboundary, frontsector, backsector, realfront, realback, - fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); + FLOAT2FIXED(fch1), FLOAT2FIXED(fch2), FLOAT2FIXED(ffh1), FLOAT2FIXED(ffh2), FLOAT2FIXED(bch1), FLOAT2FIXED(bch2), FLOAT2FIXED(bfh1), FLOAT2FIXED(bfh2)); } if (seg->linedef->isVisualPortal() && seg->sidedef == seg->linedef->sidedef[0]) { lineportal = linePortalToGL[seg->linedef->portalindex]; - ztop[0] = FIXED2FLOAT(bch1); - ztop[1] = FIXED2FLOAT(bch2); - zbottom[0] = FIXED2FLOAT(bfh1); - zbottom[1] = FIXED2FLOAT(bfh2); + ztop[0] = bch1; + ztop[1] = bch2; + zbottom[0] = bfh1; + zbottom[1] = bfh2; PutPortal(PORTALTYPE_LINETOLINE); } else if (backsector->e->XFloor.ffloors.Size() || frontsector->e->XFloor.ffloors.Size()) { - DoFFloorBlocks(seg, frontsector, backsector, fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); + DoFFloorBlocks(seg, frontsector, backsector, FLOAT2FIXED(fch1), FLOAT2FIXED(fch2), FLOAT2FIXED(ffh1), FLOAT2FIXED(ffh2), FLOAT2FIXED(bch1), FLOAT2FIXED(bch2), FLOAT2FIXED(bfh1), FLOAT2FIXED(bfh2)); } /* bottom texture */ // the back sector's ceiling obstructs part of this wall (specially important for sky sectors) - if (fch1GetTexCoordInfo(&tci, FRACUNIT, FRACUNIT); - SetWallCoordinates(seg, &tci, FIXED2FLOAT(bfh), bfh, bfh, ffh, ffh, 0); + SetWallCoordinates(seg, &tci, FIXED2FLOAT(bfh), FIXED2FLOAT(bfh), FIXED2FLOAT(bfh), FIXED2FLOAT(ffh), FIXED2FLOAT(ffh), 0); PutWall(false); } } From 7df1a8ae816f7ce5944d8120088f2e8698c02477 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 17:41:06 +0200 Subject: [PATCH 0458/1509] - adjusted FGLLinePortal to recent changes in line_t. --- src/gl/scene/gl_portal.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 43890bdec..47e8dcedb 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -176,7 +176,7 @@ struct GLLinePortal : public GLPortal { // this must be the same as at the start of line_t, so that we can pass in this structure directly to P_ClipLineToPortal. vertex_t *v1, *v2; // vertices, from v1 to v2 - fixed_t dx, dy; // precalculated v2 - v1 for side checking + DVector2 delta; // precalculated v2 - v1 for side checking angle_t angv1, angv2; // for quick comparisons with a line or subsector @@ -207,9 +207,7 @@ struct GLLinePortal : public GLPortal void CalcDelta() { - DVector2 delta = v2->fPos() - v1->fPos(); - dx = FLOAT2FIXED(delta.X); - dy = FLOAT2FIXED(delta.Y); + delta = v2->fPos() - v1->fPos(); } line_t *line() From ddbb8d79c1535ab3beca146e9d08ae4178043a2c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 21:13:37 +0200 Subject: [PATCH 0459/1509] - handle the player sprite when crossing a portal. --- src/gl/scene/gl_portal.cpp | 21 +++++++++++++++++++++ src/gl/scene/gl_portal.h | 1 + 2 files changed, 22 insertions(+) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 7aaf04a77..74af305c3 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -312,6 +312,8 @@ bool GLPortal::Start(bool usestencil, bool doquery) savedviewactor=GLRenderer->mViewActor; savedviewarea=in_area; savedshowviewer = r_showviewer; + savedviewpath[0] = ViewPath[0]; + savedviewpath[1] = ViewPath[1]; NextPortal = GLRenderer->mCurrentPortal; GLRenderer->mCurrentPortal = NULL; // Portals which need this have to set it themselves @@ -374,6 +376,8 @@ void GLPortal::End(bool usestencil) if (needdepth) FDrawInfo::EndDrawInfo(); // Restore the old view + ViewPath[0] = savedviewpath[0]; + ViewPath[1] = savedviewpath[1]; ViewPos = savedViewPos; ViewAngle = savedAngle; GLRenderer->mViewActor=savedviewactor; @@ -992,6 +996,23 @@ void GLLineToLinePortal::DrawContents() P_TranslatePortalXY(origin, ViewPos.X, ViewPos.Y); P_TranslatePortalAngle(origin, ViewAngle); P_TranslatePortalZ(origin, ViewPos.Z); + P_TranslatePortalXY(origin, ViewPath[0].X, ViewPath[0].Y); + P_TranslatePortalXY(origin, ViewPath[1].X, ViewPath[1].Y); + if (!r_showviewer) + { + double distp = (ViewPath[0] - ViewPath[1]).Length(); + if (distp > EQUAL_EPSILON) + { + double dist1 = (ViewPos - ViewPath[0]).Length(); + double dist2 = (ViewPos - ViewPath[1]).Length(); + + if (dist1 + dist2 > distp + 1) + { + r_showviewer = true; + } + } + } + SaveMapSection(); diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 47e8dcedb..d8c5da619 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -106,6 +106,7 @@ private: AActor * savedviewactor; area_t savedviewarea; bool savedshowviewer; + DVector3 savedviewpath[2]; GLPortal *NextPortal; TArray savedmapsection; TArray mPrimIndices; From 4ac373437543547923eb4e343e88ae0ba7cdf0b3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 Apr 2016 23:19:37 +0200 Subject: [PATCH 0460/1509] - floatified more of gl_wall.cpp. --- src/gl/scene/gl_wall.h | 22 +-- src/gl/scene/gl_walls.cpp | 305 +++++++++++++++++----------------- src/gl/unused/gl_sections.cpp | 12 +- 3 files changed, 173 insertions(+), 166 deletions(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 17c3c841f..b71b194ef 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -202,23 +202,23 @@ private: void DoMidTexture(seg_t * seg, bool drawfogboundary, sector_t * front, sector_t * back, sector_t * realfront, sector_t * realback, - fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, - fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2); + float fch1, float fch2, float ffh1, float ffh2, + float bch1, float bch2, float bfh1, float bfh2); - void GetPlanePos(F3DFloor::planeref *planeref, fixed_t &left, fixed_t &right); + void GetPlanePos(F3DFloor::planeref * planeref, float & left, float & right); void BuildFFBlock(seg_t * seg, F3DFloor * rover, - fixed_t ff_topleft, fixed_t ff_topright, - fixed_t ff_bottomleft, fixed_t ff_bottomright); + float ff_topleft, float ff_topright, + float ff_bottomleft, float ff_bottomright); void InverseFloors(seg_t * seg, sector_t * frontsector, - fixed_t topleft, fixed_t topright, - fixed_t bottomleft, fixed_t bottomright); + float topleft, float topright, + float bottomleft, float bottomright); void ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector, - fixed_t topleft, fixed_t topright, - fixed_t bottomleft, fixed_t bottomright); + float topleft, float topright, + float bottomleft, float bottomright); void DoFFloorBlocks(seg_t * seg, sector_t * frontsector, sector_t * backsector, - fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, - fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2); + float fch1, float fch2, float ffh1, float ffh2, + float bch1, float bch2, float bfh1, float bfh2); void DrawDecal(DBaseDecal *actor); void DoDrawDecals(); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index a684185c6..0ce1eb304 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -658,14 +658,14 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg, void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, sector_t * front, sector_t * back, sector_t * realfront, sector_t * realback, - fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, - fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2) + float fch1, float fch2, float ffh1, float ffh2, + float bch1, float bch2, float bfh1, float bfh2) { FTexCoordInfo tci; - fixed_t topleft,bottomleft,topright,bottomright; + float topleft,bottomleft,topright,bottomright; GLSeg glsave=glseg; - fixed_t texturetop, texturebottom; + float texturetop, texturebottom; bool wrap = (seg->linedef->flags&ML_WRAP_MIDTEX) || (seg->sidedef->Flags&WALLF_WRAP_MIDTEX); bool mirrory = false; @@ -686,16 +686,16 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, tci.mRenderHeight = -tci.mRenderHeight; tci.mScaleY = -tci.mScaleY; } - fixed_t rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); + float rowoffset = FIXED2FLOAT(tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid))); if ((seg->linedef->flags & ML_DONTPEGBOTTOM) >0) { - texturebottom = MAX(realfront->GetPlaneTexZ(sector_t::floor), realback->GetPlaneTexZ(sector_t::floor)) + rowoffset; - texturetop = texturebottom + (tci.mRenderHeight << FRACBITS); + texturebottom = MAX(realfront->GetPlaneTexZF(sector_t::floor), realback->GetPlaneTexZF(sector_t::floor)) + rowoffset; + texturetop = texturebottom + tci.mRenderHeight; } else { - texturetop = MIN(realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling)) + rowoffset; - texturebottom = texturetop - (tci.mRenderHeight << FRACBITS); + texturetop = MIN(realfront->GetPlaneTexZF(sector_t::ceiling), realback->GetPlaneTexZF(sector_t::ceiling)) + rowoffset; + texturebottom = texturetop - tci.mRenderHeight; } } else texturetop=texturebottom=0; @@ -804,22 +804,30 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // set up texture coordinate stuff // // - fixed_t t_ofs = seg->sidedef->GetTextureXOffset(side_t::mid); + float t_ofs = seg->sidedef->GetTextureXOffsetF(side_t::mid); if (gltexture) { // First adjust the texture offset so that the left edge of the linedef is inside the range [0..1]. - fixed_t texwidth = tci.TextureAdjustWidth()<= 0) + { + float div = t_ofs / texwidth; + t_ofs = (div - xs_FloorToInt(div)) * texwidth; + } + else + { + float div = (-t_ofs) / texwidth; + t_ofs = texwidth - (div - xs_FloorToInt(div)) * texwidth; + } // Now check whether the linedef is completely within the texture range of [0..1]. // If so we should use horizontal texture clamping to prevent filtering artifacts // at the edges. - fixed_t textureoffset = tci.TextureOffset(t_ofs); + fixed_t textureoffset = tci.TextureOffset(FLOAT2FIXED(t_ofs)); int righttex=(textureoffset>>FRACBITS)+seg->sidedef->TexelLength; if ((textureoffset == 0 && righttex <= tci.mRenderWidth) || @@ -841,7 +849,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, tci.mRenderHeight = -tci.mRenderHeight; tci.mScaleY = -tci.mScaleY; } - SetWallCoordinates(seg, &tci, FIXED2FLOAT(texturetop), FIXED2FLOAT(topleft), FIXED2FLOAT(topright), FIXED2FLOAT(bottomleft), FIXED2FLOAT(bottomright), t_ofs); + SetWallCoordinates(seg, &tci, texturetop, topleft, topright, bottomleft, bottomright, FLOAT2FIXED(t_ofs)); // // @@ -976,15 +984,15 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // //========================================================================== void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, - fixed_t ff_topleft, fixed_t ff_topright, - fixed_t ff_bottomleft, fixed_t ff_bottomright) + float ff_topleft, float ff_topright, + float ff_bottomleft, float ff_bottomright) { side_t * mastersd = rover->master->sidedef[0]; float to; lightlist_t * light; bool translucent; - int savelight=lightlevel; - FColormap savecolor=Colormap; + int savelight = lightlevel; + FColormap savecolor = Colormap; float ul; float texlength; FTexCoordInfo tci; @@ -994,90 +1002,90 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, if (!gl_fixedcolormap) { // this may not yet be done - light=P_GetPlaneLight(rover->target, rover->top.plane,true); + light = P_GetPlaneLight(rover->target, rover->top.plane, true); Colormap.Clear(); - Colormap.LightColor=(light->extra_colormap)->Fade; + Colormap.LightColor = (light->extra_colormap)->Fade; // the fog plane defines the light level, not the front sector lightlevel = gl_ClampLight(*light->p_lightlevel); - gltexture=NULL; - type=RENDERWALL_FFBLOCK; + gltexture = NULL; + type = RENDERWALL_FFBLOCK; } else return; } else { - - if (rover->flags&FF_UPPERTEXTURE) + + if (rover->flags&FF_UPPERTEXTURE) { - gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), false, true); + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), false, true); if (!gltexture) return; gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::top), seg->sidedef->GetTextureYScale(side_t::top)); } - else if (rover->flags&FF_LOWERTEXTURE) + else if (rover->flags&FF_LOWERTEXTURE) { gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), false, true); if (!gltexture) return; gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::bottom), seg->sidedef->GetTextureYScale(side_t::bottom)); } - else + else { gltexture = FMaterial::ValidateTexture(mastersd->GetTexture(side_t::mid), false, true); if (!gltexture) return; gltexture->GetTexCoordInfo(&tci, mastersd->GetTextureXScale(side_t::mid), mastersd->GetTextureYScale(side_t::mid)); } - - to=FIXED2FLOAT((rover->flags&(FF_UPPERTEXTURE|FF_LOWERTEXTURE))? + + to = FIXED2FLOAT((rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? 0 : tci.TextureOffset(mastersd->GetTextureXOffset(side_t::mid))); - ul=tci.FloatToTexU(to + FIXED2FLOAT(tci.TextureOffset(seg->sidedef->GetTextureXOffset(side_t::mid)))); + ul = tci.FloatToTexU(to + FIXED2FLOAT(tci.TextureOffset(seg->sidedef->GetTextureXOffset(side_t::mid)))); texlength = tci.FloatToTexU(seg->sidedef->TexelLength); uplft.u = lolft.u = ul + texlength * glseg.fracleft; uprgt.u = lorgt.u = ul + texlength * glseg.fracright; - + fixed_t rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); - to= (rover->flags&(FF_UPPERTEXTURE|FF_LOWERTEXTURE))? - 0.f : FIXED2FLOAT(tci.RowOffset(mastersd->GetTextureYOffset(side_t::mid))); - + to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? + 0.f : FIXED2FLOAT(tci.RowOffset(mastersd->GetTextureYOffset(side_t::mid))); + to += FIXED2FLOAT(rowoffset) + rover->top.model->GetPlaneTexZF(rover->top.isceiling); - - uplft.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_topleft)); - uprgt.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_topright)); - lolft.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_bottomleft)); - lorgt.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_bottomright)); - type=RENDERWALL_FFBLOCK; + + uplft.v = tci.FloatToTexV(to - ff_topleft); + uprgt.v = tci.FloatToTexV(to - ff_topright); + lolft.v = tci.FloatToTexV(to - ff_bottomleft); + lorgt.v = tci.FloatToTexV(to - ff_bottomright); + type = RENDERWALL_FFBLOCK; CheckTexturePosition(); } - ztop[0]=FIXED2FLOAT(ff_topleft); - ztop[1]=FIXED2FLOAT(ff_topright); - zbottom[0]=FIXED2FLOAT(ff_bottomleft);//-0.001f; - zbottom[1]=FIXED2FLOAT(ff_bottomright); + ztop[0] = ff_topleft; + ztop[1] = ff_topright; + zbottom[0] = ff_bottomleft;//-0.001f; + zbottom[1] = ff_bottomright; - if (rover->flags&(FF_TRANSLUCENT|FF_ADDITIVETRANS|FF_FOG)) + if (rover->flags&(FF_TRANSLUCENT | FF_ADDITIVETRANS | FF_FOG)) { - alpha=rover->alpha/255.0f; - RenderStyle = (rover->flags&FF_ADDITIVETRANS)? STYLE_Add : STYLE_Translucent; - translucent=true; - type=gltexture? RENDERWALL_M2S:RENDERWALL_COLOR; + alpha = rover->alpha / 255.0f; + RenderStyle = (rover->flags&FF_ADDITIVETRANS) ? STYLE_Add : STYLE_Translucent; + translucent = true; + type = gltexture ? RENDERWALL_M2S : RENDERWALL_COLOR; } - else + else { - alpha=1.0f; - RenderStyle=STYLE_Normal; - translucent=false; + alpha = 1.0f; + RenderStyle = STYLE_Normal; + translucent = false; } - - sector_t * sec = sub? sub->sector : seg->frontsector; - if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(translucent); + sector_t * sec = sub ? sub->sector : seg->frontsector; + + if (sec->e->XFloor.lightlist.Size() == 0 || gl_fixedcolormap) PutWall(translucent); else SplitWall(sec, translucent); - alpha=1.0f; + alpha = 1.0f; lightlevel = savelight; Colormap = savecolor; - flags&=~GLT_CLAMPY; + flags &= ~GLT_CLAMPY; } @@ -1087,10 +1095,10 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, // //========================================================================== -__forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, fixed_t &left, fixed_t &right) +__forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, float &left, float &right) { - left=planeref->plane->ZatPointFixed(vertexes[0]); - right=planeref->plane->ZatPointFixed(vertexes[1]); + left=planeref->plane->ZatPoint(vertexes[0]); + right=planeref->plane->ZatPoint(vertexes[1]); } //========================================================================== @@ -1099,49 +1107,48 @@ __forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, fixed_t &le // //========================================================================== void GLWall::InverseFloors(seg_t * seg, sector_t * frontsector, - fixed_t topleft, fixed_t topright, - fixed_t bottomleft, fixed_t bottomright) + float topleft, float topright, + float bottomleft, float bottomright) { - TArray & frontffloors=frontsector->e->XFloor.ffloors; + TArray & frontffloors = frontsector->e->XFloor.ffloors; - for(unsigned int i=0;iflags&FF_EXISTS)) continue; if (!(rover->flags&FF_RENDERSIDES)) continue; - if (!(rover->flags&(FF_INVERTSIDES|FF_ALLSIDES))) continue; + if (!(rover->flags&(FF_INVERTSIDES | FF_ALLSIDES))) continue; - fixed_t ff_topleft; - fixed_t ff_topright; - fixed_t ff_bottomleft; - fixed_t ff_bottomright; + float ff_topleft; + float ff_topright; + float ff_bottomleft; + float ff_bottomright; GetPlanePos(&rover->top, ff_topleft, ff_topright); GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright); // above ceiling - if (ff_bottomleft>topleft && ff_bottomright>topright) continue; + if (ff_bottomleft > topleft && ff_bottomright > topright) continue; - if (ff_topleft>topleft && ff_topright>topright) + if (ff_topleft > topleft && ff_topright > topright) { // the new section overlaps with the previous one - clip it! - ff_topleft=topleft; - ff_topright=topright; + ff_topleft = topleft; + ff_topright = topright; } - if (ff_bottomleft & frontffloors=frontsector->e->XFloor.ffloors; + TArray & frontffloors = frontsector->e->XFloor.ffloors; - int flags = ffloor->flags & (FF_SWIMMABLE|FF_TRANSLUCENT); + int flags = ffloor->flags & (FF_SWIMMABLE | FF_TRANSLUCENT); - for(unsigned int i=0;iflags&FF_EXISTS)) continue; if (!(rover->flags&FF_RENDERSIDES)) continue; - if ((rover->flags&(FF_SWIMMABLE|FF_TRANSLUCENT))!=flags) continue; + if ((rover->flags&(FF_SWIMMABLE | FF_TRANSLUCENT)) != flags) continue; - fixed_t ff_topleft; - fixed_t ff_topright; - fixed_t ff_bottomleft; - fixed_t ff_bottomright; + float ff_topleft; + float ff_topright; + float ff_bottomleft; + float ff_bottomright; GetPlanePos(&rover->top, ff_topleft, ff_topright); // we are completely below the bottom so unless there are some // (unsupported) intersections there won't be any more floors that // could clip this one. - if (ff_topleftbottom, ff_bottomleft, ff_bottomright); // above top line? - if (ff_bottomleft>topleft && ff_bottomright>topright) continue; + if (ff_bottomleft > topleft && ff_bottomright > topright) continue; // overlapping the top line - if (ff_topleft>=topleft && ff_topright>=topright) + if (ff_topleft >= topleft && ff_topright >= topright) { // overlapping with the entire range - if (ff_bottomleft<=bottomleft && ff_bottomright<=bottomright) return; - else if (ff_bottomleft>bottomleft && ff_bottomright>bottomright) + if (ff_bottomleft <= bottomleft && ff_bottomright <= bottomright) return; + else if (ff_bottomleft > bottomleft && ff_bottomright > bottomright) { - topleft=ff_bottomleft; - topright=ff_bottomright; + topleft = ff_bottomleft; + topright = ff_bottomright; } else { @@ -1197,12 +1204,12 @@ void GLWall::ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector, // I don't need this right now. } } - else if (ff_topleft<=topleft && ff_topright<=topright) + else if (ff_topleft <= topleft && ff_topright <= topright) { BuildFFBlock(seg, ffloor, topleft, topright, ff_topleft, ff_topright); - if (ff_bottomleft<=bottomleft && ff_bottomright<=bottomright) return; - topleft=ff_bottomleft; - topright=ff_bottomright; + if (ff_bottomleft <= bottomleft && ff_bottomright <= bottomright) return; + topleft = ff_bottomleft; + topright = ff_bottomright; } else { @@ -1222,85 +1229,85 @@ done: // // //========================================================================== -void GLWall::DoFFloorBlocks(seg_t * seg,sector_t * frontsector,sector_t * backsector, - fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, - fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2) +void GLWall::DoFFloorBlocks(seg_t * seg, sector_t * frontsector, sector_t * backsector, + float fch1, float fch2, float ffh1, float ffh2, + float bch1, float bch2, float bfh1, float bfh2) { - TArray & backffloors=backsector->e->XFloor.ffloors; - fixed_t topleft, topright, bottomleft, bottomright; - bool renderedsomething=false; + TArray & backffloors = backsector->e->XFloor.ffloors; + float topleft, topright, bottomleft, bottomright; + bool renderedsomething = false; // if the ceilings intersect use the backsector's height because this sector's ceiling will // obstruct the redundant parts. - if (fch1bfh1 && ffh2>bfh2) + if (ffh1 > bfh1 && ffh2 > bfh2) { - bottomleft=ffh1; - bottomright=ffh2; + bottomleft = ffh1; + bottomright = ffh2; } else { - bottomleft=bfh1; - bottomright=bfh2; + bottomleft = bfh1; + bottomright = bfh2; } - for(unsigned int i=0;iflags&FF_EXISTS)) continue; if (!(rover->flags&FF_RENDERSIDES) || (rover->flags&FF_INVERTSIDES)) continue; - fixed_t ff_topleft; - fixed_t ff_topright; - fixed_t ff_bottomleft; - fixed_t ff_bottomright; + float ff_topleft; + float ff_topright; + float ff_bottomleft; + float ff_bottomright; GetPlanePos(&rover->top, ff_topleft, ff_topright); GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright); // completely above ceiling - if (ff_bottomleft>topleft && ff_bottomright>topright && !renderedsomething) continue; + if (ff_bottomleft > topleft && ff_bottomright > topright && !renderedsomething) continue; - if (ff_topleft>topleft && ff_topright>topright) + if (ff_topleft > topleft && ff_topright > topright) { // the new section overlaps with the previous one - clip it! - ff_topleft=topleft; - ff_topright=topright; + ff_topleft = topleft; + ff_topright = topright; } // do all inverse floors above the current one it there is a gap between the // last 3D floor and this one. - if (topleft>ff_topleft && topright>ff_topright) + if (topleft > ff_topleft && topright > ff_topright) InverseFloors(seg, frontsector, topleft, topright, ff_topleft, ff_topright); // if translucent or liquid clip away adjoining parts of the same type of FFloors on the other side - if (rover->flags&(FF_SWIMMABLE|FF_TRANSLUCENT)) + if (rover->flags&(FF_SWIMMABLE | FF_TRANSLUCENT)) ClipFFloors(seg, rover, frontsector, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright); else BuildFFBlock(seg, rover, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright); - topleft=ff_bottomleft; - topright=ff_bottomright; - renderedsomething=true; - if (topleft<=bottomleft && topright<=bottomright) return; + topleft = ff_bottomleft; + topright = ff_bottomright; + renderedsomething = true; + if (topleft <= bottomleft && topright <= bottomright) return; } // draw all inverse floors below the lowest one if (frontsector->e->XFloor.ffloors.Size() > 0) { - if (topleft>bottomleft || topright>bottomright) + if (topleft > bottomleft || topright > bottomright) InverseFloors(seg, frontsector, topleft, topright, bottomleft, bottomright); } } @@ -1323,7 +1330,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) sector_t * segback; #ifdef _DEBUG - if (seg->linedef-lines==904) + if (seg->linedef - lines == 904) { int a = 0; } @@ -1470,7 +1477,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) float bfh2 = segback->floorplane.ZatPoint(v2); float bch1 = segback->ceilingplane.ZatPoint(v1); float bch2 = segback->ceilingplane.ZatPoint(v2); - + SkyTop(seg, frontsector, backsector, v1, v2); SkyBottom(seg, frontsector, backsector, v1, v2); @@ -1540,7 +1547,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture || drawfogboundary) { DoMidTexture(seg, drawfogboundary, frontsector, backsector, realfront, realback, - FLOAT2FIXED(fch1), FLOAT2FIXED(fch2), FLOAT2FIXED(ffh1), FLOAT2FIXED(ffh2), FLOAT2FIXED(bch1), FLOAT2FIXED(bch2), FLOAT2FIXED(bfh1), FLOAT2FIXED(bfh2)); + fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); } if (seg->linedef->isVisualPortal() && seg->sidedef == seg->linedef->sidedef[0]) @@ -1554,7 +1561,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else if (backsector->e->XFloor.ffloors.Size() || frontsector->e->XFloor.ffloors.Size()) { - DoFFloorBlocks(seg, frontsector, backsector, FLOAT2FIXED(fch1), FLOAT2FIXED(fch2), FLOAT2FIXED(ffh1), FLOAT2FIXED(ffh2), FLOAT2FIXED(bch1), FLOAT2FIXED(bch2), FLOAT2FIXED(bfh1), FLOAT2FIXED(bfh2)); + DoFFloorBlocks(seg, frontsector, backsector, fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); } /* bottom texture */ @@ -1565,7 +1572,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) bfh2 = fch2; } - if (bfh1>ffh1 || bfh2>ffh2) + if (bfh1 > ffh1 || bfh2 > ffh2) { gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), false, true); if (gltexture) @@ -1617,8 +1624,8 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * if (frontsector->GetTexture(sector_t::floor) == skyflatnum) return; lightlist = NULL; - fixed_t ffh = frontsector->GetPlaneTexZ(sector_t::floor); - fixed_t bfh = backsector->GetPlaneTexZ(sector_t::floor); + float ffh = frontsector->GetPlaneTexZF(sector_t::floor); + float bfh = backsector->GetPlaneTexZF(sector_t::floor); if (bfh > ffh) { this->seg = seg; @@ -1652,7 +1659,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * bottomplane = frontsector->floorplane; dynlightindex = UINT_MAX; - zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh); + zfloor[0] = zfloor[1] = ffh; gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), false, true); @@ -1661,7 +1668,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * FTexCoordInfo tci; type = RENDERWALL_BOTTOM; gltexture->GetTexCoordInfo(&tci, FRACUNIT, FRACUNIT); - SetWallCoordinates(seg, &tci, FIXED2FLOAT(bfh), FIXED2FLOAT(bfh), FIXED2FLOAT(bfh), FIXED2FLOAT(ffh), FIXED2FLOAT(ffh), 0); + SetWallCoordinates(seg, &tci, bfh, bfh, bfh, ffh, ffh, 0); PutWall(false); } } diff --git a/src/gl/unused/gl_sections.cpp b/src/gl/unused/gl_sections.cpp index b39db0292..34858bd3a 100644 --- a/src/gl/unused/gl_sections.cpp +++ b/src/gl/unused/gl_sections.cpp @@ -735,12 +735,12 @@ void DumpSection(int no, FGLSection *sect) { vertex_t *v1 = V1(ln->sidedef); vertex_t *v2 = V2(ln->sidedef); - double dx = FIXED2FLOAT(v2->x-v1->x); - double dy = FIXED2FLOAT(v2->y-v1->y); - double dx1 = FIXED2FLOAT(ln->start->x-v1->x); - double dy1 = FIXED2FLOAT(ln->start->y-v1->y); - double dx2 = FIXED2FLOAT(ln->end->x-v1->x); - double dy2 = FIXED2FLOAT(ln->end->y-v1->y); + double dx = FIXED2DBL(v2->x-v1->x); + double dy = FIXED2DBL(v2->y-v1->y); + double dx1 = FIXED2DBL(ln->start->x-v1->x); + double dy1 = FIXED2DBL(ln->start->y-v1->y); + double dx2 = FIXED2DBL(ln->end->x-v1->x); + double dy2 = FIXED2DBL(ln->end->y-v1->y); double d = sqrt(dx*dx+dy*dy); double d1 = sqrt(dx1*dx1+dy1*dy1); double d2 = sqrt(dx2*dx2+dy2*dy2); From eaf055dff46dc09629644bf6a914b11ac25913f7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 8 Apr 2016 00:19:51 +0200 Subject: [PATCH 0461/1509] - floatified the remaining parts of gl_walls.cpp. --- src/gl/scene/gl_wall.h | 6 ++-- src/gl/scene/gl_walls.cpp | 58 +++++++++++++++++---------------- src/gl/textures/gl_material.cpp | 16 ++++----- src/gl/textures/gl_material.h | 4 +-- src/gl/textures/gl_texture.cpp | 13 ++++---- src/gl/textures/gl_texture.h | 3 +- 6 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index b71b194ef..8bd39b372 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -191,13 +191,13 @@ private: bool DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2); bool SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float ceilingrefheight, - float topleft, float topright, float bottomleft, float bottomright, fixed_t t_ofs); + float topleft, float topright, float bottomleft, float bottomright, float t_ofs); void DoTexture(int type,seg_t * seg,int peg, - fixed_t ceilingrefheight,fixed_t floorrefheight, + float ceilingrefheight, float floorrefheight, float CeilingHeightstart,float CeilingHeightend, float FloorHeightstart,float FloorHeightend, - fixed_t v_offset); + float v_offset); void DoMidTexture(seg_t * seg, bool drawfogboundary, sector_t * front, sector_t * back, diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 0ce1eb304..86b330d7e 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -428,7 +428,7 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) // //========================================================================== bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float texturetop, - float topleft, float topright, float bottomleft, float bottomright, fixed_t t_ofs) + float topleft, float topright, float bottomleft, float bottomright, float t_ofs) { // // @@ -442,7 +442,7 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto { float length = seg->sidedef ? seg->sidedef->TexelLength : Dist2(glseg.x1, glseg.y1, glseg.x2, glseg.y2); - l_ul = tci->FloatToTexU(FIXED2FLOAT(tci->TextureOffset(t_ofs))); + l_ul = tci->FloatToTexU(tci->TextureOffset(t_ofs)); texlength = tci->FloatToTexU(length); } else @@ -593,16 +593,16 @@ void GLWall::CheckTexturePosition() // //========================================================================== void GLWall::DoTexture(int _type,seg_t * seg, int peg, - fixed_t ceilingrefheight,fixed_t floorrefheight, + float ceilingrefheight,float floorrefheight, float topleft,float topright, float bottomleft,float bottomright, - fixed_t v_offset) + float v_offset) { if (topleft<=bottomleft && topright<=bottomright) return; // The Vertex values can be destroyed in this function and must be restored aferward! GLSeg glsave=glseg; - int lh=ceilingrefheight-floorrefheight; + float flh=ceilingrefheight-floorrefheight; int texpos; switch (_type) @@ -624,11 +624,11 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg, type = _type; - float floatceilingref = FIXED2FLOAT(ceilingrefheight + tci.RowOffset(seg->sidedef->GetTextureYOffset(texpos))); - if (peg) floatceilingref += tci.mRenderHeight - FIXED2FLOAT(lh + v_offset); + float floatceilingref = ceilingrefheight + tci.RowOffset(seg->sidedef->GetTextureYOffsetF(texpos)); + if (peg) floatceilingref += tci.mRenderHeight - flh - v_offset; if (!SetWallCoordinates(seg, &tci, floatceilingref, topleft, topright, bottomleft, bottomright, - seg->sidedef->GetTextureXOffset(texpos))) return; + seg->sidedef->GetTextureXOffsetF(texpos))) return; if (seg->linedef->special == Line_Mirror && _type == RENDERWALL_M1S && gl_mirrors) { @@ -686,7 +686,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, tci.mRenderHeight = -tci.mRenderHeight; tci.mScaleY = -tci.mScaleY; } - float rowoffset = FIXED2FLOAT(tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid))); + float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffsetF(side_t::mid)); if ((seg->linedef->flags & ML_DONTPEGBOTTOM) >0) { texturebottom = MAX(realfront->GetPlaneTexZF(sector_t::floor), realback->GetPlaneTexZF(sector_t::floor)) + rowoffset; @@ -827,8 +827,8 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // If so we should use horizontal texture clamping to prevent filtering artifacts // at the edges. - fixed_t textureoffset = tci.TextureOffset(FLOAT2FIXED(t_ofs)); - int righttex=(textureoffset>>FRACBITS)+seg->sidedef->TexelLength; + float textureoffset = tci.TextureOffset(t_ofs); + int righttex = int(textureoffset) + seg->sidedef->TexelLength; if ((textureoffset == 0 && righttex <= tci.mRenderWidth) || (textureoffset >= 0 && righttex == tci.mRenderWidth)) @@ -849,7 +849,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, tci.mRenderHeight = -tci.mRenderHeight; tci.mScaleY = -tci.mScaleY; } - SetWallCoordinates(seg, &tci, texturetop, topleft, topright, bottomleft, bottomright, FLOAT2FIXED(t_ofs)); + SetWallCoordinates(seg, &tci, texturetop, topleft, topright, bottomleft, bottomright, t_ofs); // // @@ -1034,21 +1034,20 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, gltexture->GetTexCoordInfo(&tci, mastersd->GetTextureXScale(side_t::mid), mastersd->GetTextureYScale(side_t::mid)); } - to = FIXED2FLOAT((rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? - 0 : tci.TextureOffset(mastersd->GetTextureXOffset(side_t::mid))); + to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? 0 : tci.TextureOffset(mastersd->GetTextureXOffsetF(side_t::mid)); - ul = tci.FloatToTexU(to + FIXED2FLOAT(tci.TextureOffset(seg->sidedef->GetTextureXOffset(side_t::mid)))); + ul = tci.FloatToTexU(to + tci.TextureOffset(seg->sidedef->GetTextureXOffsetF(side_t::mid))); texlength = tci.FloatToTexU(seg->sidedef->TexelLength); uplft.u = lolft.u = ul + texlength * glseg.fracleft; uprgt.u = lorgt.u = ul + texlength * glseg.fracright; - fixed_t rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); + float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffsetF(side_t::mid)); to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? - 0.f : FIXED2FLOAT(tci.RowOffset(mastersd->GetTextureYOffset(side_t::mid))); + 0.f : tci.RowOffset(mastersd->GetTextureYOffsetF(side_t::mid)); - to += FIXED2FLOAT(rowoffset) + rover->top.model->GetPlaneTexZF(rover->top.isceiling); + to += rowoffset + rover->top.model->GetPlaneTexZF(rover->top.isceiling); uplft.v = tci.FloatToTexV(to - ff_topleft); uprgt.v = tci.FloatToTexV(to - ff_topright); @@ -1324,6 +1323,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) float ffh1; float fch2; float ffh2; + float frefz, crefz; sector_t * realfront; sector_t * realback; sector_t * segfront; @@ -1354,6 +1354,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) segfront = frontsector; segback = backsector; } + frefz = realfront->GetPlaneTexZF(sector_t::floor); + crefz = realfront->GetPlaneTexZF(sector_t::ceiling); if (seg->sidedef == seg->linedef->sidedef[0]) { @@ -1466,7 +1468,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_M1S, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, - realfront->GetPlaneTexZ(sector_t::ceiling), realfront->GetPlaneTexZ(sector_t::floor), // must come from the original! + crefz, frefz, // must come from the original! fch1, fch2, ffh1, ffh2, 0); } } @@ -1501,7 +1503,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, - realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling), + frefz, crefz, fch1, fch2, bch1a, bch2a, 0); } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) @@ -1514,7 +1516,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, - realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling), + frefz, crefz, fch1, fch2, bch1a, bch2a, 0); } } @@ -1523,7 +1525,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) // skip processing if the back is a malformed subsector if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4)) { - gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a); + gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, FLOAT2FIXED(bch1a)); } } } @@ -1578,11 +1580,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, - realback->GetPlaneTexZ(sector_t::floor), realfront->GetPlaneTexZ(sector_t::floor), + frefz, crefz, bfh1, bfh2, ffh1, ffh2, frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum ? - realfront->GetPlaneTexZ(sector_t::floor) - realback->GetPlaneTexZ(sector_t::ceiling) : - realfront->GetPlaneTexZ(sector_t::floor) - realfront->GetPlaneTexZ(sector_t::ceiling)); + frefz - realback->GetPlaneTexZF(sector_t::ceiling) : + frefz - crefz); } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) { @@ -1597,8 +1599,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, - realback->GetPlaneTexZ(sector_t::floor), realfront->GetPlaneTexZ(sector_t::floor), - bfh1, bfh2, ffh1, ffh2, realfront->GetPlaneTexZ(sector_t::floor) - realfront->GetPlaneTexZ(sector_t::ceiling)); + realback->GetPlaneTexZF(sector_t::floor), frefz, + bfh1, bfh2, ffh1, ffh2, frefz - crefz); } } else if (backsector->GetTexture(sector_t::floor) != skyflatnum) @@ -1606,7 +1608,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) // skip processing if the back is a malformed subsector if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4)) { - gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1); + gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, FLOAT2FIXED(bfh1)); } } } diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index ea6811603..3b2ee60af 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -327,17 +327,17 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla // //=========================================================================== -fixed_t FTexCoordInfo::RowOffset(fixed_t rowoffset) const +float FTexCoordInfo::RowOffset(float rowoffset) const { if (mTempScaleY == FRACUNIT) { if (mScaleY==FRACUNIT || mWorldPanning) return rowoffset; - else return FixedDiv(rowoffset, mScaleY); + else return rowoffset * FIXED2FLOAT(mScaleY); } else { - if (mWorldPanning) return FixedDiv(rowoffset, mTempScaleY); - else return FixedDiv(rowoffset, mScaleY); + if (mWorldPanning) return rowoffset * FIXED2FLOAT(mTempScaleY); + else return rowoffset * FIXED2FLOAT(mScaleY); } } @@ -347,17 +347,17 @@ fixed_t FTexCoordInfo::RowOffset(fixed_t rowoffset) const // //=========================================================================== -fixed_t FTexCoordInfo::TextureOffset(fixed_t textureoffset) const +float FTexCoordInfo::TextureOffset(float textureoffset) const { if (mTempScaleX == FRACUNIT) { if (mScaleX==FRACUNIT || mWorldPanning) return textureoffset; - else return FixedDiv(textureoffset, mScaleX); + else return textureoffset * FIXED2FLOAT(mScaleX); } else { - if (mWorldPanning) return FixedDiv(textureoffset, mTempScaleX); - else return FixedDiv(textureoffset, mScaleX); + if (mWorldPanning) return textureoffset * FIXED2FLOAT(mTempScaleX); + else return textureoffset * FIXED2FLOAT(mScaleX); } } diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index ac1ccc274..525d50670 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -39,8 +39,8 @@ struct FTexCoordInfo float FloatToTexU(float v) const { return v / mRenderWidth; } float FloatToTexV(float v) const { return v / mRenderHeight; } - fixed_t RowOffset(fixed_t ofs) const; - fixed_t TextureOffset(fixed_t ofs) const; + float RowOffset(float ofs) const; + float TextureOffset(float ofs) const; fixed_t TextureAdjustWidth() const; }; diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 0ad87fbfe..50671e4bd 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -177,7 +177,7 @@ void gl_GenerateGlobalBrightmapFromColormap() // component becomes one. // //=========================================================================== -PalEntry averageColor(const DWORD *data, int size, fixed_t maxout_factor) +PalEntry averageColor(const DWORD *data, int size, int maxout) { int i; unsigned int r, g, b; @@ -203,12 +203,11 @@ PalEntry averageColor(const DWORD *data, int size, fixed_t maxout_factor) int maxv=MAX(MAX(r,g),b); - if(maxv && maxout_factor) + if(maxv && maxout) { - maxout_factor = FixedMul(maxout_factor, 255); - r = Scale(r, maxout_factor, maxv); - g = Scale(g, maxout_factor, maxv); - b = Scale(b, maxout_factor, maxv); + r = Scale(r, maxout, maxv); + g = Scale(g, maxout, maxv); + b = Scale(b, maxout, maxv); } return PalEntry(255,r,g,b); } @@ -366,7 +365,7 @@ void FTexture::GetGlowColor(float *data) if (buffer) { - gl_info.GlowColor = averageColor((DWORD *) buffer, w*h, 6*FRACUNIT/10); + gl_info.GlowColor = averageColor((DWORD *) buffer, w*h, 153); delete[] buffer; } diff --git a/src/gl/textures/gl_texture.h b/src/gl/textures/gl_texture.h index a70ccebc5..a1c471ea8 100644 --- a/src/gl/textures/gl_texture.h +++ b/src/gl/textures/gl_texture.h @@ -58,14 +58,13 @@ protected: void gl_GenerateGlobalBrightmapFromColormap(); -PalEntry averageColor(const DWORD *data, int size, fixed_t maxout); +PalEntry averageColor(const DWORD *data, int size, int maxout); unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight, bool hasAlpha ); int CheckDDPK3(FTexture *tex); int CheckExternalFile(FTexture *tex, bool & hascolorkey); -PalEntry averageColor(const DWORD *data, int size, fixed_t maxout); #endif // __GL_HQRESIZE_H__ From 4d5671d654fe501b67b9933753476771af74d1eb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 8 Apr 2016 01:42:43 +0200 Subject: [PATCH 0462/1509] - floatified the texture coordinate code. --- src/gl/data/gl_data.h | 2 +- src/gl/data/gl_portaldata.cpp | 5 +- src/gl/scene/gl_drawinfo.h | 16 +-- src/gl/scene/gl_renderhacks.cpp | 204 ++++++++++++++++---------------- src/gl/scene/gl_sky.cpp | 4 +- src/gl/scene/gl_skydome.cpp | 37 +++--- src/gl/scene/gl_walls.cpp | 20 ++-- src/gl/textures/gl_material.cpp | 60 +++++----- src/gl/textures/gl_material.h | 16 ++- src/gl/utility/gl_geometric.cpp | 4 +- src/r_defs.h | 4 + 11 files changed, 188 insertions(+), 184 deletions(-) diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index 859f8de1a..c8067b3ba 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -58,7 +58,7 @@ struct FGLLinePortal { // defines the complete span of this portal vertex_t *v1, *v2; // vertices, from v1 to v2 - fixed_t dx, dy; // precalculated v2 - v1 for side checking + DVector2 delta; // precalculated v2 - v1 for side checking FLinePortal *reference; // one of the associated line portals, for retrieving translation info etc. }; diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index de030ad30..b7ba9d202 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -444,7 +444,7 @@ void gl_InitPortals() tempindex[i] = glLinePortals.Size(); line_t *pSrcLine = linePortals[i].mOrigin; line_t *pLine = linePortals[i].mDestination; - FGLLinePortal glport = { pLine->v1, pLine->v2, 0, 0, &linePortals[i] }; + FGLLinePortal glport = { pLine->v1, pLine->v2, {0, 0}, &linePortals[i] }; glLinePortals.Push(glport); // We cannot do this grouping for non-linked portals because they can be changed at run time. @@ -484,8 +484,7 @@ void gl_InitPortals() } for (auto glport : glLinePortals) { - glport.dx = glport.v2->fixX() - glport.v1->fixX(); - glport.dy = glport.v2->fixY() - glport.v1->fixY(); + glport.delta = glport.v2->fPos() - glport.v1->fPos(); } linePortalToGL.Resize(linePortals.Size()); for (unsigned i = 0; i < linePortals.Size(); i++) diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index 6b869ef17..8cb6a412a 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -161,8 +161,8 @@ struct FDrawInfo { seg_t * seg; subsector_t * sub; - fixed_t planez; - fixed_t planezfront; + float Planez; + float Planezfront; }; struct MissingSegInfo @@ -204,10 +204,10 @@ struct FDrawInfo ~FDrawInfo(); void ClearBuffers(); - bool DoOneSectorUpper(subsector_t * subsec, fixed_t planez); - bool DoOneSectorLower(subsector_t * subsec, fixed_t planez); - bool DoFakeBridge(subsector_t * subsec, fixed_t planez); - bool DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez); + bool DoOneSectorUpper(subsector_t * subsec, float planez); + bool DoOneSectorLower(subsector_t * subsec, float planez); + bool DoFakeBridge(subsector_t * subsec, float planez); + bool DoFakeCeilingBridge(subsector_t * subsec, float planez); bool CheckAnchorFloor(subsector_t * sub); bool CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor); @@ -216,8 +216,8 @@ struct FDrawInfo void CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor); void CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor); - void AddUpperMissingTexture(side_t * side, subsector_t *sub, fixed_t backheight); - void AddLowerMissingTexture(side_t * side, subsector_t *sub, fixed_t backheight); + void AddUpperMissingTexture(side_t * side, subsector_t *sub, float backheight); + void AddLowerMissingTexture(side_t * side, subsector_t *sub, float backheight); void HandleMissingTextures(); void DrawUnhandledMissingTextures(); void AddHackedSubsector(subsector_t * sub); diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index 97cefabd6..80f64d02e 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -140,12 +140,12 @@ void FDrawInfo::AddOtherCeilingPlane(int sector, gl_subsectorrendernode * node) // Collects all sectors that might need a fake ceiling // //========================================================================== -void FDrawInfo::AddUpperMissingTexture(side_t * side, subsector_t *sub, fixed_t backheight) +void FDrawInfo::AddUpperMissingTexture(side_t * side, subsector_t *sub, float Backheight) { if (!side->segs[0]->backsector) return; totalms.Clock(); - for(int i=0; inumsegs; i++) + for (int i = 0; i < side->numsegs; i++) { seg_t *seg = side->segs[i]; @@ -156,35 +156,35 @@ void FDrawInfo::AddUpperMissingTexture(side_t * side, subsector_t *sub, fixed_t MissingSegInfo msi; - if (sub->render_sector != sub->sector || seg->frontsector != sub->sector) + if (sub->render_sector != sub->sector || seg->frontsector != sub->sector) { totalms.Unclock(); return; } - for(unsigned int i=0;isegs[0]->backsector; if (!backsec) return; @@ -209,7 +209,7 @@ void FDrawInfo::AddLowerMissingTexture(side_t * side, subsector_t *sub, fixed_t totalms.Clock(); // we need to check all segs of this sidedef - for(int i=0; inumsegs; i++) + for (int i = 0; i < side->numsegs; i++) { seg_t *seg = side->segs[i]; @@ -221,42 +221,42 @@ void FDrawInfo::AddLowerMissingTexture(side_t * side, subsector_t *sub, fixed_t subsector_t * sub = seg->Subsector; - if (sub->render_sector != sub->sector || seg->frontsector != sub->sector) + if (sub->render_sector != sub->sector || seg->frontsector != sub->sector) { totalms.Unclock(); return; } // Ignore FF_FIX's because they are designed to abuse missing textures - if (seg->backsector->e->XFloor.ffloors.Size() && (seg->backsector->e->XFloor.ffloors[0]->flags&(FF_FIX|FF_SEETHROUGH)) == FF_FIX) + if (seg->backsector->e->XFloor.ffloors.Size() && (seg->backsector->e->XFloor.ffloors[0]->flags&(FF_FIX | FF_SEETHROUGH)) == FF_FIX) { totalms.Unclock(); return; } - for(unsigned int i=0;i MissingLowerTextures[i].planez) + if (Backheight > MissingLowerTextures[i].Planez) { - MissingLowerTextures[i].planez = backheight; + MissingLowerTextures[i].Planez = Backheight; MissingLowerTextures[i].seg = seg; } msi.MTI_Index = i; - msi.seg=seg; + msi.seg = seg; MissingLowerSegs.Push(msi); totalms.Unclock(); return; } } - mti.seg=seg; + mti.seg = seg; mti.sub = sub; - mti.planez=backheight; + mti.Planez = Backheight; msi.MTI_Index = MissingLowerTextures.Push(mti); - msi.seg=seg; + msi.seg = seg; MissingLowerSegs.Push(msi); } } @@ -269,24 +269,24 @@ void FDrawInfo::AddLowerMissingTexture(side_t * side, subsector_t *sub, fixed_t // // //========================================================================== -bool FDrawInfo::DoOneSectorUpper(subsector_t * subsec, fixed_t planez) +bool FDrawInfo::DoOneSectorUpper(subsector_t * subsec, float Planez) { // Is there a one-sided wall in this sector? // Do this first to avoid unnecessary recursion - for(DWORD i=0; i< subsec->numlines; i++) + for (DWORD i = 0; i < subsec->numlines; i++) { if (subsec->firstline[i].backsector == NULL) return false; if (subsec->firstline[i].PartnerSeg == NULL) return false; } - for(DWORD i=0; i< subsec->numlines; i++) + for (DWORD i = 0; i < subsec->numlines; i++) { - seg_t * seg = subsec->firstline +i; + seg_t * seg = subsec->firstline + i; subsector_t * backsub = seg->PartnerSeg->Subsector; // already checked? - if (backsub->validcount == validcount) continue; - backsub->validcount=validcount; + if (backsub->validcount == validcount) continue; + backsub->validcount = validcount; if (seg->frontsector != seg->backsector && seg->linedef) { @@ -299,22 +299,22 @@ bool FDrawInfo::DoOneSectorUpper(subsector_t * subsec, fixed_t planez) if (sec->ceilingplane.isSlope()) return false; // Is the neighboring ceiling lower than the desired height? - if (sec->GetPlaneTexZ(sector_t::ceiling)GetPlaneTexZF(sector_t::ceiling) < Planez) { // todo: check for missing textures. return false; } // This is an exact height match which means we don't have to do any further checks for this sector - if (sec->GetPlaneTexZ(sector_t::ceiling)==planez) + if (sec->GetPlaneTexZF(sector_t::ceiling) == Planez) { // If there's a texture abort FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::top)]; - if (!tex || tex->UseType==FTexture::TEX_Null) continue; + if (!tex || tex->UseType == FTexture::TEX_Null) continue; else return false; } } - if (!DoOneSectorUpper(backsub, planez)) return false; + if (!DoOneSectorUpper(backsub, Planez)) return false; } // all checked ok. This subsector is part of the current fake plane @@ -327,24 +327,24 @@ bool FDrawInfo::DoOneSectorUpper(subsector_t * subsec, fixed_t planez) // // //========================================================================== -bool FDrawInfo::DoOneSectorLower(subsector_t * subsec, fixed_t planez) +bool FDrawInfo::DoOneSectorLower(subsector_t * subsec, float Planez) { // Is there a one-sided wall in this subsector? // Do this first to avoid unnecessary recursion - for(DWORD i=0; i< subsec->numlines; i++) + for (DWORD i = 0; i < subsec->numlines; i++) { if (subsec->firstline[i].backsector == NULL) return false; if (subsec->firstline[i].PartnerSeg == NULL) return false; } - for(DWORD i=0; i< subsec->numlines; i++) + for (DWORD i = 0; i < subsec->numlines; i++) { seg_t * seg = subsec->firstline + i; subsector_t * backsub = seg->PartnerSeg->Subsector; // already checked? - if (backsub->validcount == validcount) continue; - backsub->validcount=validcount; + if (backsub->validcount == validcount) continue; + backsub->validcount = validcount; if (seg->frontsector != seg->backsector && seg->linedef) { @@ -357,22 +357,22 @@ bool FDrawInfo::DoOneSectorLower(subsector_t * subsec, fixed_t planez) if (sec->floorplane.isSlope()) return false; // Is the neighboring floor higher than the desired height? - if (sec->GetPlaneTexZ(sector_t::floor)>planez) + if (sec->GetPlaneTexZF(sector_t::floor) > Planez) { // todo: check for missing textures. return false; } // This is an exact height match which means we don't have to do any further checks for this sector - if (sec->GetPlaneTexZ(sector_t::floor)==planez) + if (sec->GetPlaneTexZF(sector_t::floor) == Planez) { // If there's a texture abort FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::bottom)]; - if (!tex || tex->UseType==FTexture::TEX_Null) continue; + if (!tex || tex->UseType == FTexture::TEX_Null) continue; else return false; } } - if (!DoOneSectorLower(backsub, planez)) return false; + if (!DoOneSectorLower(backsub, Planez)) return false; } // all checked ok. This sector is part of the current fake plane @@ -386,24 +386,24 @@ bool FDrawInfo::DoOneSectorLower(subsector_t * subsec, fixed_t planez) // // //========================================================================== -bool FDrawInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez) +bool FDrawInfo::DoFakeBridge(subsector_t * subsec, float Planez) { // Is there a one-sided wall in this sector? // Do this first to avoid unnecessary recursion - for(DWORD i=0; i< subsec->numlines; i++) + for (DWORD i = 0; i < subsec->numlines; i++) { if (subsec->firstline[i].backsector == NULL) return false; if (subsec->firstline[i].PartnerSeg == NULL) return false; } - for(DWORD i=0; i< subsec->numlines; i++) + for (DWORD i = 0; i < subsec->numlines; i++) { seg_t * seg = subsec->firstline + i; subsector_t * backsub = seg->PartnerSeg->Subsector; // already checked? - if (backsub->validcount == validcount) continue; - backsub->validcount=validcount; + if (backsub->validcount == validcount) continue; + backsub->validcount = validcount; if (seg->frontsector != seg->backsector && seg->linedef) { @@ -416,7 +416,7 @@ bool FDrawInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez) if (sec->floorplane.isSlope()) return false; // Is the neighboring floor higher than the desired height? - if (sec->GetPlaneTexZ(sector_t::floor)GetPlaneTexZF(sector_t::floor) < Planez) { // todo: check for missing textures. return false; @@ -424,9 +424,9 @@ bool FDrawInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez) // This is an exact height match which means we don't have to do any further checks for this sector // No texture checks though! - if (sec->GetPlaneTexZ(sector_t::floor)==planez) continue; + if (sec->GetPlaneTexZF(sector_t::floor) == Planez) continue; } - if (!DoFakeBridge(backsub, planez)) return false; + if (!DoFakeBridge(backsub, Planez)) return false; } // all checked ok. This sector is part of the current fake plane @@ -439,24 +439,24 @@ bool FDrawInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez) // // //========================================================================== -bool FDrawInfo::DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez) +bool FDrawInfo::DoFakeCeilingBridge(subsector_t * subsec, float Planez) { // Is there a one-sided wall in this sector? // Do this first to avoid unnecessary recursion - for(DWORD i=0; i< subsec->numlines; i++) + for (DWORD i = 0; i < subsec->numlines; i++) { if (subsec->firstline[i].backsector == NULL) return false; if (subsec->firstline[i].PartnerSeg == NULL) return false; } - for(DWORD i=0; i< subsec->numlines; i++) + for (DWORD i = 0; i < subsec->numlines; i++) { seg_t * seg = subsec->firstline + i; subsector_t * backsub = seg->PartnerSeg->Subsector; // already checked? - if (backsub->validcount == validcount) continue; - backsub->validcount=validcount; + if (backsub->validcount == validcount) continue; + backsub->validcount = validcount; if (seg->frontsector != seg->backsector && seg->linedef) { @@ -469,7 +469,7 @@ bool FDrawInfo::DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez) if (sec->ceilingplane.isSlope()) return false; // Is the neighboring ceiling higher than the desired height? - if (sec->GetPlaneTexZ(sector_t::ceiling)>planez) + if (sec->GetPlaneTexZF(sector_t::ceiling) > Planez) { // todo: check for missing textures. return false; @@ -477,9 +477,9 @@ bool FDrawInfo::DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez) // This is an exact height match which means we don't have to do any further checks for this sector // No texture checks though! - if (sec->GetPlaneTexZ(sector_t::ceiling)==planez) continue; + if (sec->GetPlaneTexZF(sector_t::ceiling) == Planez) continue; } - if (!DoFakeCeilingBridge(backsub, planez)) return false; + if (!DoFakeCeilingBridge(backsub, Planez)) return false; } // all checked ok. This sector is part of the current fake plane @@ -497,49 +497,49 @@ void FDrawInfo::HandleMissingTextures() { sector_t fake; totalms.Clock(); - totalupper=MissingUpperTextures.Size(); - totallower=MissingLowerTextures.Size(); + totalupper = MissingUpperTextures.Size(); + totallower = MissingLowerTextures.Size(); - for(unsigned int i=0;i FLOAT2FIXED(ViewPos.Z)) + if (MissingUpperTextures[i].Planez > ViewPos.Z) { // close the hole only if all neighboring sectors are an exact height match // Otherwise just fill in the missing textures. - MissingUpperTextures[i].sub->validcount=validcount; - if (DoOneSectorUpper(MissingUpperTextures[i].sub, MissingUpperTextures[i].planez)) + MissingUpperTextures[i].sub->validcount = validcount; + if (DoOneSectorUpper(MissingUpperTextures[i].sub, MissingUpperTextures[i].Planez)) { sector_t * sec = MissingUpperTextures[i].seg->backsector; // The mere fact that this seg has been added to the list means that the back sector // will be rendered so we can safely assume that it is already in the render list - for(unsigned int j=0;jsub = HandledSubsectors[j]; AddOtherCeilingPlane(sec->sectornum, node); } - if (HandledSubsectors.Size()!=1) + if (HandledSubsectors.Size() != 1) { // mark all subsectors in the missing list that got processed by this - for(unsigned int j=0;jfrontsector, &fake, false); - fixed_t planez = fakesector->GetPlaneTexZ(sector_t::ceiling); + float planez = (float)fakesector->GetPlaneTexZF(sector_t::ceiling); - backsub->validcount=validcount; + backsub->validcount = validcount; if (DoFakeCeilingBridge(backsub, planez)) { // The mere fact that this seg has been added to the list means that the back sector // will be rendered so we can safely assume that it is already in the render list - for(unsigned int j=0;jsub = HandledSubsectors[j]; AddOtherCeilingPlane(fakesector->sectornum, node); @@ -572,45 +572,45 @@ void FDrawInfo::HandleMissingTextures() } } - for(unsigned int i=0;ivalidcount=validcount; - if (DoOneSectorLower(MissingLowerTextures[i].sub, MissingLowerTextures[i].planez)) + MissingLowerTextures[i].sub->validcount = validcount; + if (DoOneSectorLower(MissingLowerTextures[i].sub, MissingLowerTextures[i].Planez)) { sector_t * sec = MissingLowerTextures[i].seg->backsector; // The mere fact that this seg has been added to the list means that the back sector // will be rendered so we can safely assume that it is already in the render list - for(unsigned int j=0;jsub = HandledSubsectors[j]; AddOtherFloorPlane(sec->sectornum, node); } - if (HandledSubsectors.Size()!=1) + if (HandledSubsectors.Size() != 1) { // mark all subsectors in the missing list that got processed by this - for(unsigned int j=0;jfrontsector, &fake, false); - fixed_t planez = fakesector->GetPlaneTexZ(sector_t::floor); + float planez = (float)fakesector->GetPlaneTexZF(sector_t::floor); - backsub->validcount=validcount; + backsub->validcount = validcount; if (DoFakeBridge(backsub, planez)) { // The mere fact that this seg has been added to the list means that the back sector // will be rendered so we can safely assume that it is already in the render list - for(unsigned int j=0;jsub = HandledSubsectors[j]; AddOtherFloorPlane(fakesector->sectornum, node); @@ -644,7 +644,7 @@ void FDrawInfo::HandleMissingTextures() } totalms.Unclock(); - showtotalms=totalms; + showtotalms = totalms; totalms.Reset(); } @@ -658,43 +658,43 @@ void FDrawInfo::HandleMissingTextures() void FDrawInfo::DrawUnhandledMissingTextures() { validcount++; - for(int i=MissingUpperSegs.Size()-1; i>=0; i--) + for (int i = MissingUpperSegs.Size() - 1; i >= 0; i--) { int index = MissingUpperSegs[i].MTI_Index; - if (index>=0 && MissingUpperTextures[index].seg==NULL) continue; + if (index >= 0 && MissingUpperTextures[index].seg == NULL) continue; seg_t * seg = MissingUpperSegs[i].seg; // already done! - if (seg->linedef->validcount==validcount) continue; // already done - seg->linedef->validcount=validcount; + if (seg->linedef->validcount == validcount) continue; // already done + seg->linedef->validcount = validcount; if (seg->frontsector->GetPlaneTexZF(sector_t::ceiling) < ViewPos.Z) continue; // out of sight //if (seg->frontsector->ceilingpic==skyflatnum) continue; // FIXME: The check for degenerate subsectors should be more precise if (seg->PartnerSeg && (seg->PartnerSeg->Subsector->flags & SSECF_DEGENERATE)) continue; if (seg->backsector->transdoor) continue; - if (seg->backsector->GetTexture(sector_t::ceiling)==skyflatnum) continue; + if (seg->backsector->GetTexture(sector_t::ceiling) == skyflatnum) continue; if (seg->backsector->portals[sector_t::ceiling] != NULL) continue; if (!glset.notexturefill) FloodUpperGap(seg); } validcount++; - for(int i=MissingLowerSegs.Size()-1; i>=0; i--) + for (int i = MissingLowerSegs.Size() - 1; i >= 0; i--) { int index = MissingLowerSegs[i].MTI_Index; - if (index>=0 && MissingLowerTextures[index].seg==NULL) continue; + if (index >= 0 && MissingLowerTextures[index].seg == NULL) continue; seg_t * seg = MissingLowerSegs[i].seg; // already done! - if (seg->linedef->validcount==validcount) continue; // already done - seg->linedef->validcount=validcount; + if (seg->linedef->validcount == validcount) continue; // already done + seg->linedef->validcount = validcount; if (!(sectorrenderflags[seg->backsector->sectornum] & SSRF_RENDERFLOOR)) continue; if (seg->frontsector->GetPlaneTexZF(sector_t::floor) > ViewPos.Z) continue; // out of sight if (seg->backsector->transdoor) continue; - if (seg->backsector->GetTexture(sector_t::floor)==skyflatnum) continue; + if (seg->backsector->GetTexture(sector_t::floor) == skyflatnum) continue; if (seg->backsector->portals[sector_t::floor] != NULL) continue; if (!glset.notexturefill) FloodLowerGap(seg); diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index d5340d7ff..2826236b2 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -92,8 +92,8 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor) texture[0] = FMaterial::ValidateTexture(texno, false, true); if (!texture[0] || texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky; skytexno1 = texno; - x_offset[0] = AngleToFloat(s->GetTextureXOffset(pos)); - y_offset = FIXED2FLOAT(s->GetTextureYOffset(pos)); + x_offset[0] = s->GetTextureXOffsetF(pos) * (360.f/65536.f); + y_offset = s->GetTextureYOffsetF(pos); mirrored = !l->args[2]; } else diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index a9d920420..69968ddf7 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -101,25 +101,24 @@ FSkyVertexBuffer::~FSkyVertexBuffer() // //----------------------------------------------------------------------------- -void FSkyVertexBuffer::SkyVertex(int r, int c, bool yflip) +void FSkyVertexBuffer::SkyVertex(int r, int c, bool zflip) { - static const angle_t maxSideAngle = ANGLE_180 / 3; - static const fixed_t scale = 10000 << FRACBITS; + static const FAngle maxSideAngle = 60.f; + static const float scale = 10000.; - angle_t topAngle= (angle_t)(c / (float)mColumns * ANGLE_MAX); - angle_t sideAngle = maxSideAngle * (mRows - r) / mRows; - fixed_t height = finesine[sideAngle>>ANGLETOFINESHIFT]; - fixed_t realRadius = FixedMul(scale, finecosine[sideAngle>>ANGLETOFINESHIFT]); - fixed_t x = FixedMul(realRadius, finecosine[topAngle>>ANGLETOFINESHIFT]); - fixed_t y = (!yflip) ? FixedMul(scale, height) : FixedMul(scale, height) * -1; - fixed_t z = FixedMul(realRadius, finesine[topAngle>>ANGLETOFINESHIFT]); + FAngle topAngle= (c / (float)mColumns * 360.f); + FAngle sideAngle = maxSideAngle * (mRows - r) / mRows; + float height = sideAngle.Sin(); + float realRadius = scale * sideAngle.Cos(); + FVector2 pos = topAngle.ToVector(realRadius); + float z = (!zflip) ? scale * height : -scale * height; FSkyVertex vert; vert.color = r == 0 ? 0xffffff : 0xffffffff; // And the texture coordinates. - if(!yflip) // Flipped Y is for the lower hemisphere. + if(!zflip) // Flipped Y is for the lower hemisphere. { vert.u = (-c / (float)mColumns) ; vert.v = (r / (float)mRows); @@ -130,11 +129,11 @@ void FSkyVertexBuffer::SkyVertex(int r, int c, bool yflip) vert.v = 1.0f + ((mRows - r) / (float)mRows); } - if (r != 4) y+=FRACUNIT*300; + if (r != 4) z+=300; // And finally the vertex. - vert.x =-FIXED2FLOAT(x); // Doom mirrors the sky vertically! - vert.y = FIXED2FLOAT(y) - 1.f; - vert.z = FIXED2FLOAT(z); + vert.x = -pos.X; // Doom mirrors the sky vertically! + vert.y = z - 1.f; + vert.z = pos.Y; mVertices.Push(vert); } @@ -149,13 +148,13 @@ void FSkyVertexBuffer::SkyVertex(int r, int c, bool yflip) void FSkyVertexBuffer::CreateSkyHemisphere(int hemi) { int r, c; - bool yflip = !!(hemi & SKYHEMI_LOWER); + bool zflip = !!(hemi & SKYHEMI_LOWER); mPrimStart.Push(mVertices.Size()); for (c = 0; c < mColumns; c++) { - SkyVertex(1, c, yflip); + SkyVertex(1, c, zflip); } // The total number of triangles per hemisphere can be calculated @@ -165,8 +164,8 @@ void FSkyVertexBuffer::CreateSkyHemisphere(int hemi) mPrimStart.Push(mVertices.Size()); for (c = 0; c <= mColumns; c++) { - SkyVertex(r + yflip, c, yflip); - SkyVertex(r + 1 - yflip, c, yflip); + SkyVertex(r + zflip, c, zflip); + SkyVertex(r + 1 - zflip, c, zflip); } } } diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 86b330d7e..02401e283 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -620,7 +620,7 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg, FTexCoordInfo tci; - gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(texpos), seg->sidedef->GetTextureYScale(texpos)); + gltexture->GetTexCoordInfo(&tci, seg->sidedef, texpos); type = _type; @@ -679,12 +679,12 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // Align the texture to the ORIGINAL sector's height!! // At this point slopes don't matter because they don't affect the texture's z-position - gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::mid), seg->sidedef->GetTextureYScale(side_t::mid)); + gltexture->GetTexCoordInfo(&tci, seg->sidedef, side_t::mid); if (tci.mRenderHeight < 0) { mirrory = true; tci.mRenderHeight = -tci.mRenderHeight; - tci.mScaleY = -tci.mScaleY; + tci.mScale.Y = -tci.mScale.Y; } float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffsetF(side_t::mid)); if ((seg->linedef->flags & ML_DONTPEGBOTTOM) >0) @@ -847,7 +847,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, if (mirrory) { tci.mRenderHeight = -tci.mRenderHeight; - tci.mScaleY = -tci.mScaleY; + tci.mScale.Y = -tci.mScale.Y; } SetWallCoordinates(seg, &tci, texturetop, topleft, topright, bottomleft, bottomright, t_ofs); @@ -1019,19 +1019,19 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, { gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), false, true); if (!gltexture) return; - gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::top), seg->sidedef->GetTextureYScale(side_t::top)); + gltexture->GetTexCoordInfo(&tci, seg->sidedef, side_t::top); } else if (rover->flags&FF_LOWERTEXTURE) { gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), false, true); if (!gltexture) return; - gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::bottom), seg->sidedef->GetTextureYScale(side_t::bottom)); + gltexture->GetTexCoordInfo(&tci, seg->sidedef, side_t::bottom); } else { gltexture = FMaterial::ValidateTexture(mastersd->GetTexture(side_t::mid), false, true); if (!gltexture) return; - gltexture->GetTexCoordInfo(&tci, mastersd->GetTextureXScale(side_t::mid), mastersd->GetTextureYScale(side_t::mid)); + gltexture->GetTexCoordInfo(&tci, mastersd, side_t::mid); } to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? 0 : tci.TextureOffset(mastersd->GetTextureXOffsetF(side_t::mid)); @@ -1525,7 +1525,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) // skip processing if the back is a malformed subsector if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4)) { - gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, FLOAT2FIXED(bch1a)); + gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a); } } } @@ -1608,7 +1608,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) // skip processing if the back is a malformed subsector if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4)) { - gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, FLOAT2FIXED(bfh1)); + gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1); } } } @@ -1669,7 +1669,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * { FTexCoordInfo tci; type = RENDERWALL_BOTTOM; - gltexture->GetTexCoordInfo(&tci, FRACUNIT, FRACUNIT); + gltexture->GetTexCoordInfo(&tci, 1.f, 1.f); SetWallCoordinates(seg, &tci, bfh, bfh, bfh, ffh, ffh, 0); PutWall(false); } diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 3b2ee60af..40e2931a6 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -329,15 +329,15 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla float FTexCoordInfo::RowOffset(float rowoffset) const { - if (mTempScaleY == FRACUNIT) + if (mTempScale.Y == 1.f) { - if (mScaleY==FRACUNIT || mWorldPanning) return rowoffset; - else return rowoffset * FIXED2FLOAT(mScaleY); + if (mScale.Y == 1.f || mWorldPanning) return rowoffset; + else return rowoffset * mScale.Y; } else { - if (mWorldPanning) return rowoffset * FIXED2FLOAT(mTempScaleY); - else return rowoffset * FIXED2FLOAT(mScaleY); + if (mWorldPanning) return rowoffset * mTempScale.Y; + else return rowoffset * mScale.Y; } } @@ -349,15 +349,15 @@ float FTexCoordInfo::RowOffset(float rowoffset) const float FTexCoordInfo::TextureOffset(float textureoffset) const { - if (mTempScaleX == FRACUNIT) + if (mTempScale.X == 1.f) { - if (mScaleX==FRACUNIT || mWorldPanning) return textureoffset; - else return textureoffset * FIXED2FLOAT(mScaleX); + if (mScale.X == 1.f || mWorldPanning) return textureoffset; + else return textureoffset * mScale.X; } else { - if (mWorldPanning) return textureoffset * FIXED2FLOAT(mTempScaleX); - else return textureoffset * FIXED2FLOAT(mScaleX); + if (mWorldPanning) return textureoffset * mTempScale.X; + else return textureoffset * mScale.X; } } @@ -367,12 +367,12 @@ float FTexCoordInfo::TextureOffset(float textureoffset) const // //=========================================================================== -fixed_t FTexCoordInfo::TextureAdjustWidth() const +float FTexCoordInfo::TextureAdjustWidth() const { if (mWorldPanning) { - if (mTempScaleX == FRACUNIT) return mRenderWidth; - else return FixedDiv(mWidth, mTempScaleX); + if (mTempScale.X == 1.f) return mRenderWidth; + else return mWidth * mTempScale.X; } else return mWidth; } @@ -696,40 +696,38 @@ void FMaterial::Precache() // //=========================================================================== -void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const +void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, float x, float y) const { - if (x == FRACUNIT) + if (x == 1.f) { tci->mRenderWidth = mRenderWidth; - tci->mScaleX = FLOAT2FIXED(tex->Scale.X); - tci->mTempScaleX = FRACUNIT; + tci->mScale.X = tex->Scale.X; + tci->mTempScale.X = 1.f; } else { - fixed_t scale_x = fixed_t(x * tex->Scale.X); - int foo = (mWidth << 17) / scale_x; - tci->mRenderWidth = (foo >> 1) + (foo & 1); - tci->mScaleX = scale_x; - tci->mTempScaleX = x; + float scale_x = x * tex->Scale.X; + tci->mRenderWidth = xs_CeilToInt(mWidth / scale_x); + tci->mScale.X = scale_x; + tci->mTempScale.X = x; } - if (y == FRACUNIT) + if (y == 1.f) { tci->mRenderHeight = mRenderHeight; - tci->mScaleY = FLOAT2FIXED(tex->Scale.Y); - tci->mTempScaleY = FRACUNIT; + tci->mScale.Y = tex->Scale.Y; + tci->mTempScale.Y = 1.f; } else { - fixed_t scale_y = fixed_t(y * tex->Scale.Y); - int foo = (mHeight << 17) / scale_y; - tci->mRenderHeight = (foo >> 1) + (foo & 1); - tci->mScaleY = scale_y; - tci->mTempScaleY = y; + float scale_y = y * tex->Scale.Y; + tci->mRenderHeight = xs_CeilToInt(mHeight / scale_y); + tci->mScale.Y = scale_y; + tci->mTempScale.Y = y; } if (tex->bHasCanvas) { - tci->mScaleY = -tci->mScaleY; + tci->mScale.Y = -tci->mScale.Y; tci->mRenderHeight = -tci->mRenderHeight; } tci->mWorldPanning = tex->bWorldPanning; diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 525d50670..b8a71c7ce 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -7,6 +7,7 @@ #include "gl/textures/gl_hwtexture.h" #include "gl/renderer/gl_colormap.h" #include "i_system.h" +#include "r_defs.h" EXTERN_CVAR(Bool, gl_precache) @@ -31,17 +32,15 @@ struct FTexCoordInfo int mRenderWidth; int mRenderHeight; int mWidth; - fixed_t mScaleX; - fixed_t mScaleY; - fixed_t mTempScaleX; - fixed_t mTempScaleY; + FVector2 mScale; + FVector2 mTempScale; bool mWorldPanning; float FloatToTexU(float v) const { return v / mRenderWidth; } float FloatToTexV(float v) const { return v / mRenderHeight; } float RowOffset(float ofs) const; float TextureOffset(float ofs) const; - fixed_t TextureAdjustWidth() const; + float TextureAdjustWidth() const; }; //=========================================================================== @@ -157,7 +156,12 @@ public: *r = mSpriteRect; } - void GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const; + void GetTexCoordInfo(FTexCoordInfo *tci, float x, float y) const; + + void GetTexCoordInfo(FTexCoordInfo *tci, side_t *side, int texpos) const + { + GetTexCoordInfo(tci, (float)side->GetTextureXScaleF(texpos), (float)side->GetTextureYScaleF(texpos)); + } // This is scaled size in integer units as needed by walls and flats int TextureHeight() const { return mRenderHeight; } diff --git a/src/gl/utility/gl_geometric.cpp b/src/gl/utility/gl_geometric.cpp index c2ea6da59..15b01f254 100644 --- a/src/gl/utility/gl_geometric.cpp +++ b/src/gl/utility/gl_geometric.cpp @@ -227,9 +227,9 @@ void Plane::Init(float a, float b, float c, float d) void Plane::Set(secplane_t &plane) { - m_normal.Set(plane.Normal().X, plane.Normal().Z, plane.Normal().Y); + m_normal.Set((float)plane.Normal().X, (float)plane.Normal().Z, (float)plane.Normal().Y); //m_normal.Normalize(); the vector is already normalized - m_d = plane.fD(); + m_d = (float)plane.fD(); } diff --git a/src/r_defs.h b/src/r_defs.h index 89df08cab..8eb982384 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1308,6 +1308,10 @@ struct side_t { return textures[which].xscale; } + double GetTextureXScaleF(int which) const + { + return FIXED2DBL(textures[which].xscale); + } void MultiplyTextureXScale(int which, double delta) { textures[which].xscale = fixed_t(textures[which].xscale * delta); From 3e94832bfde22d6f734477286d775436206ae7bb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 8 Apr 2016 01:58:13 +0200 Subject: [PATCH 0463/1509] - use the correct reference heights for positioning textures. --- src/gl/scene/gl_walls.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 02401e283..4691ad49e 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1503,7 +1503,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, - frefz, crefz, + frefz, realback->GetPlaneTexZF(sector_t::ceiling), fch1, fch2, bch1a, bch2a, 0); } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) @@ -1516,7 +1516,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, - frefz, crefz, + frefz, realback->GetPlaneTexZF(sector_t::ceiling), fch1, fch2, bch1a, bch2a, 0); } } @@ -1580,7 +1580,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, - frefz, crefz, + realback->GetPlaneTexZF(sector_t::floor), crefz, bfh1, bfh2, ffh1, ffh2, frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum ? frefz - realback->GetPlaneTexZF(sector_t::ceiling) : From 25d7eaed0a375c6930cf78fe838873dd24d7c260 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 8 Apr 2016 12:38:09 +0200 Subject: [PATCH 0464/1509] - fixed parentheses in ADynamicLight::DistToSeg. - floatifed OpenGL sector grouping. - optimized light node collection. It should not create light nodes for out of range segs. --- src/gl/data/gl_portaldata.cpp | 3 ++- src/gl/data/gl_setup.cpp | 8 +++--- src/gl/dynlights/a_dynlight.cpp | 44 +++++++++++++++++---------------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index b7ba9d202..497216bc8 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -102,7 +102,8 @@ GLSectorStackPortal *FPortal::GetGLPortal() //========================================================================== // -// +// this is left as fixed_t because the nodes also are, it makes no sense +// to convert this without converting the nodes as well. // //========================================================================== diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index dfc0c6d47..4e58831fa 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -102,11 +102,11 @@ static void DoSetMapSection(subsector_t *sub, int num) struct cvertex_t { - fixed_t x, y; + double X, Y; - operator int () const { return ((x>>16)&0xffff) | y; } - bool operator!= (const cvertex_t &other) const { return x != other.x || y != other.y; } - cvertex_t& operator =(const vertex_t *v) { x = v->fixX(); y = v->fixY(); return *this; } + operator int() const { return xs_FloorToInt(X) + 65536 * xs_FloorToInt(Y); } + bool operator!= (const cvertex_t &other) const { return fabs(X - other.X) >= EQUAL_EPSILON || fabs(Y - other.Y) >= EQUAL_EPSILON; } + cvertex_t& operator =(const vertex_t *v) { X = v->fX(); Y = v->fY(); return *this; } }; typedef TMap FSectionVertexMap; diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 05488bb3c..eccd8afcb 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -4,7 +4,7 @@ ** **--------------------------------------------------------------------------- ** Copyright 2003 Timothy Stump -** Copyright 2005 Christoph Oelckers +** Copyright 2005-2016 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -515,7 +515,7 @@ double ADynamicLight::DistToSeg(const DVector3 &pos, seg_t *seg) double seg_dy = seg->v2->fY() - seg->v1->fY(); double seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy; - u = ((pos.X - seg->v1->fX()) * seg_dx + pos.Y - seg->v1->fY()) * seg_dy / seg_length_sq; + u = (((pos.X - seg->v1->fX()) * seg_dx) + (pos.Y - seg->v1->fY()) * seg_dy) / seg_length_sq; if (u < 0.) u = 0.; // clamp the test point to the line segment else if (u > 1.) u = 1.; @@ -553,21 +553,23 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &pos, subsector_t *subSec { seg_t * seg = subSec->firstline + i; - if (seg->sidedef && seg->linedef && seg->linedef->validcount!=::validcount) + // check distance from x/y to seg and if within radius add this seg and, if present the opposing subsector (lather/rinse/repeat) + // If out of range we do not need to bother with this seg. + if (DistToSeg(pos, seg) <= radius) { - // light is in front of the seg - if ((pos.Y - seg->v1->fixY()) * (seg->v2->fX() - seg->v1->fixX()) + (seg->v1->fX() - pos.X * (seg->v2->fY() - seg->v1->fY())) <= 0) + if (seg->sidedef && seg->linedef && seg->linedef->validcount != ::validcount) { - seg->linedef->validcount = validcount; - touching_sides = AddLightNode(&seg->sidedef->lighthead, seg->sidedef, this, touching_sides); + // light is in front of the seg + if ((pos.Y - seg->v1->fY()) * (seg->v2->fX() - seg->v1->fX()) + (seg->v1->fX() - pos.X * (seg->v2->fY() - seg->v1->fY())) <= 0) + { + seg->linedef->validcount = validcount; + touching_sides = AddLightNode(&seg->sidedef->lighthead, seg->sidedef, this, touching_sides); + } } - } - if (seg->linedef) - { - FLinePortal *port = seg->linedef->getPortal(); - if (port && port->mType == PORTT_LINKED) + if (seg->linedef) { - if (DistToSeg(pos, seg) <= radius) + FLinePortal *port = seg->linedef->getPortal(); + if (port && port->mType == PORTT_LINKED) { line_t *other = port->mDestination; if (other->validcount != ::validcount) @@ -577,16 +579,12 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &pos, subsector_t *subSec } } } - } - seg_t *partner = seg->PartnerSeg; - if (partner) - { - subsector_t *sub = partner->Subsector; - if (sub != NULL && sub->validcount!=::validcount) + seg_t *partner = seg->PartnerSeg; + if (partner) { - // check distance from x/y to seg and if within radius add opposing subsector (lather/rinse/repeat) - if (DistToSeg(pos, seg) <= radius) + subsector_t *sub = partner->Subsector; + if (sub != NULL && sub->validcount != ::validcount) { CollectWithinRadius(pos, sub, radius); } @@ -625,6 +623,10 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &pos, subsector_t *subSec void ADynamicLight::LinkLight() { + if (X() == 1088 && Y() == 2832) + { + int a = 0; + } // mark the old light nodes FLightNode * node; From 1f0fd85d0e0a7308dd19004ad520491d5b1b195f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 9 Apr 2016 13:05:43 +0200 Subject: [PATCH 0465/1509] - adjustments for the DrawTexture interface changes. --- src/gl/renderer/gl_renderer.cpp | 2 +- src/gl/renderer/gl_renderer.h | 2 +- src/gl/system/gl_framebuffer.cpp | 9 ++------- src/gl/system/gl_framebuffer.h | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index b28a0553c..b9311ce4f 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -299,7 +299,7 @@ void FGLRenderer::ClearBorders() // //========================================================================== -void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) +void FGLRenderer::DrawTexture(FTexture *img, DrawParms &parms) { double xscale = parms.destwidth / parms.texwidth; double yscale = parms.destheight / parms.texheight; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 6a1c2f9a2..2a3763551 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -110,7 +110,7 @@ public: void Begin2D(); void ClearBorders(); - void DrawTexture(FTexture *img, DCanvas::DrawParms &parms); + void DrawTexture(FTexture *img, DrawParms &parms); void DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color); void DrawPixel(int x1, int y1, int palcolor, uint32 color); void Dim(PalEntry color, float damount, int x1, int y1, int w, int h); diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 8d87d7d6a..31bc2b069 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -402,14 +402,9 @@ bool OpenGLFrameBuffer::Begin2D(bool) // //========================================================================== -void STACK_ARGS OpenGLFrameBuffer::DrawTextureV(FTexture *img, double x0, double y0, uint32 tag, va_list tags) +void STACK_ARGS OpenGLFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) { - DrawParms parms; - - if (ParseDrawTextureTags(img, x0, y0, tag, tags, &parms, true)) - { - if (GLRenderer != NULL) GLRenderer->DrawTexture(img, parms); - } + if (GLRenderer != NULL) GLRenderer->DrawTexture(img, parms); } //========================================================================== diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index 501d40925..9c87e9dc8 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -58,7 +58,7 @@ public: virtual void ReleaseScreenshotBuffer(); // 2D drawing - void STACK_ARGS DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags); + void DrawTextureParms(FTexture *img, DrawParms &parms); void DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color); void DrawPixel(int x1, int y1, int palcolor, uint32 color); void Clear(int left, int top, int right, int bottom, int palcolor, uint32 color); From 2e16f3d77e146b379e4a3eff999cafaf963923fc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 9 Apr 2016 20:49:27 +0200 Subject: [PATCH 0466/1509] - made some adjustment for the DrawTexture changes. --- src/gl/renderer/gl_renderer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index b9311ce4f..0fa34845e 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -359,11 +359,12 @@ void FGLRenderer::DrawTexture(FTexture *img, DrawParms &parms) if (parms.windowleft > 0 || parms.windowright < parms.texwidth) { + double wi = MIN(parms.windowright, parms.texwidth); x += parms.windowleft * xscale; - w -= (parms.texwidth - parms.windowright + parms.windowleft) * xscale; + w -= (parms.texwidth - wi + parms.windowleft) * xscale; u1 = float(u1 + parms.windowleft / parms.texwidth); - u2 = float(u2 - (parms.texwidth - parms.windowright) / parms.texwidth); + u2 = float(u2 - (parms.texwidth - wi) / parms.texwidth); } PalEntry color; From 7a7e1652fcd68d7cf33feb48e3ee46c45132bb4c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 9 Apr 2016 21:06:32 +0200 Subject: [PATCH 0467/1509] - fixed: lower textures used the wrong reference height for alignment --- src/gl/scene/gl_walls.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 4691ad49e..c59d4a041 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1580,7 +1580,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, - realback->GetPlaneTexZF(sector_t::floor), crefz, + realback->GetPlaneTexZF(sector_t::floor), frefz, bfh1, bfh2, ffh1, ffh2, frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum ? frefz - realback->GetPlaneTexZF(sector_t::ceiling) : From c6fa01dfbffa145b955db86a79b826e7127769a0 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 9 Apr 2016 15:40:55 -0400 Subject: [PATCH 0468/1509] Reimplement blue/yellow and quadbuffered stereo, this time with an additional CVAR gate on quadbuffered, for better hardware compatibility.obj Something is terribly wrong with the separation in all stereo modes now though. --- src/CMakeLists.txt | 1 + src/gl/stereo3d/gl_anaglyph.cpp | 8 +++ src/gl/stereo3d/gl_anaglyph.h | 10 ++- src/gl/stereo3d/gl_quadstereo.cpp | 67 ++++++++++++++++++++ src/gl/stereo3d/gl_quadstereo.h | 97 +++++++++++++++++++++++++++++ src/gl/stereo3d/gl_stereo_cvars.cpp | 16 ++++- src/win32/win32gliface.cpp | 32 ++++++---- wadsrc/static/menudef.z | 3 + 8 files changed, 221 insertions(+), 13 deletions(-) create mode 100644 src/gl/stereo3d/gl_quadstereo.cpp create mode 100644 src/gl/stereo3d/gl_quadstereo.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cc67f4f51..05dc97c5e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1079,6 +1079,7 @@ set( FASTMATH_SOURCES gl/stereo3d/gl_stereo_leftright.cpp gl/stereo3d/scoped_view_shifter.cpp gl/stereo3d/gl_anaglyph.cpp + gl/stereo3d/gl_quadstereo.cpp gl/dynlights/gl_dynlight.cpp gl/dynlights/gl_glow.cpp gl/dynlights/gl_dynlight1.cpp diff --git a/src/gl/stereo3d/gl_anaglyph.cpp b/src/gl/stereo3d/gl_anaglyph.cpp index 4b3d4d00e..7cc66e28b 100644 --- a/src/gl/stereo3d/gl_anaglyph.cpp +++ b/src/gl/stereo3d/gl_anaglyph.cpp @@ -61,4 +61,12 @@ const RedCyan& RedCyan::getInstance(FLOATTYPE ipd) } +/* static */ +const AmberBlue& AmberBlue::getInstance(FLOATTYPE ipd) +{ + static AmberBlue instance(ipd); + return instance; +} + + } /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_anaglyph.h b/src/gl/stereo3d/gl_anaglyph.h index d60506dde..a82ce0f3b 100644 --- a/src/gl/stereo3d/gl_anaglyph.h +++ b/src/gl/stereo3d/gl_anaglyph.h @@ -115,10 +115,18 @@ public: GreenMagenta(float ipd) : MaskAnaglyph(ColorMask(false, true, false), ipd) {} }; +class AmberBlue : public MaskAnaglyph +{ +public: + static const AmberBlue& getInstance(float ipd); + + AmberBlue(float ipd) : MaskAnaglyph(ColorMask(true, true, false), ipd) {} +}; + // TODO matrix anaglyph -} /* namespace st3d */ +} /* namespace s3d */ #endif /* GL_ANAGLYPH_H_ */ diff --git a/src/gl/stereo3d/gl_quadstereo.cpp b/src/gl/stereo3d/gl_quadstereo.cpp new file mode 100644 index 000000000..63bbbedc1 --- /dev/null +++ b/src/gl/stereo3d/gl_quadstereo.cpp @@ -0,0 +1,67 @@ +/* +** gl_quadstereo.cpp +** Quad-buffered OpenGL stereoscopic 3D mode for GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + +#include "gl_quadstereo.h" + +namespace s3d { + +QuadStereo::QuadStereo(double ipdMeters) + : leftEye(ipdMeters), rightEye(ipdMeters) +{ + // Check whether quad-buffered stereo is supported in the current context + // We are assuming the OpenGL context is already current at this point, + // i.e. this constructor is called "just in time". + GLboolean supportsStereo, supportsBuffered; + glGetBooleanv(GL_STEREO, &supportsStereo); + glGetBooleanv(GL_DOUBLEBUFFER, &supportsBuffered); + bool bQuadStereoSupported = supportsStereo && supportsBuffered; + leftEye.bQuadStereoSupported = bQuadStereoSupported; + rightEye.bQuadStereoSupported = bQuadStereoSupported; + + eye_ptrs.Push(&leftEye); + // If stereo is not supported, just draw scene once (left eye view only) + if (bQuadStereoSupported) { + eye_ptrs.Push(&rightEye); + } +} + +/* static */ +const QuadStereo& QuadStereo::getInstance(float ipd) +{ + static QuadStereo instance(ipd); + return instance; +} + +} /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_quadstereo.h b/src/gl/stereo3d/gl_quadstereo.h new file mode 100644 index 000000000..615746ae7 --- /dev/null +++ b/src/gl/stereo3d/gl_quadstereo.h @@ -0,0 +1,97 @@ +/* +** gl_quadstereo.h +** Quad-buffered OpenGL stereoscopic 3D mode for GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + +#ifndef GL_QUADSTEREO_H_ +#define GL_QUADSTEREO_H_ + +#include "gl_stereo3d.h" +#include "gl_stereo_leftright.h" +#include "gl/system/gl_system.h" + +namespace s3d { + + +class QuadStereoLeftPose : public LeftEyePose +{ +public: + QuadStereoLeftPose(float ipd) : LeftEyePose(ipd), bQuadStereoSupported(false) {} + virtual void SetUp() const { + if (bQuadStereoSupported) + glDrawBuffer(GL_BACK_LEFT); + } + virtual void TearDown() const { + if (bQuadStereoSupported) + glDrawBuffer(GL_BACK); + } + bool bQuadStereoSupported; +}; + +class QuadStereoRightPose : public RightEyePose +{ +public: + QuadStereoRightPose(float ipd) : RightEyePose(ipd), bQuadStereoSupported(false){} + virtual void SetUp() const { + if (bQuadStereoSupported) + glDrawBuffer(GL_BACK_RIGHT); + } + virtual void TearDown() const { + if (bQuadStereoSupported) + glDrawBuffer(GL_BACK); + } + bool bQuadStereoSupported; +}; + +// To use Quad-buffered stereo mode with nvidia 3d vision glasses, +// you must either: +// A) be using a Quadro series video card, OR +// +// B) be using nvidia driver version 314.07 or later +// AND have your monitor set to 120 Hz refresh rate +// AND have gzdoom in true full screen mode +class QuadStereo : public Stereo3DMode +{ +public: + QuadStereo(double ipdMeters); + static const QuadStereo& QuadStereo::getInstance(float ipd); +private: + QuadStereoLeftPose leftEye; + QuadStereoRightPose rightEye; +}; + + +} /* namespace s3d */ + + +#endif /* GL_QUADSTEREO_H_ */ diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index 56895bbc6..9f1f30505 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -36,11 +36,14 @@ #include "gl/stereo3d/gl_stereo3d.h" #include "gl/stereo3d/gl_stereo_leftright.h" #include "gl/stereo3d/gl_anaglyph.h" +#include "gl/stereo3d/gl_quadstereo.h" #include "gl/system/gl_cvars.h" // Set up 3D-specific console variables: CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG) +EXTERN_CVAR(Bool, vr_enable_quadbuffered) + // intraocular distance in meters CVAR(Float, vr_ipd, 0.062f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // METERS @@ -80,7 +83,18 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() case 6: setCurrentMode(RightEyeView::getInstance(vr_ipd)); break; - case 0: + case 7: + if (vr_enable_quadbuffered) { + setCurrentMode(QuadStereo::getInstance(vr_ipd)); + } + else { + setCurrentMode(MonoView::getInstance()); + } + break ; + // TODO: 8: Oculus Rift + case 9: + setCurrentMode(AmberBlue::getInstance(vr_ipd)); + break; case 0: default: setCurrentMode(MonoView::getInstance()); break; diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index ca6800de8..1fab45406 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -47,6 +47,11 @@ CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ CVAR(Bool, gl_debug, false, 0) +// For broadest GL compatibility, require user to explicitly enable quad-buffered stereo mode. +// Setting vr_enable_quadbuffered_stereo does not automatically invoke quad-buffered stereo, +// but makes it possible for subsequent "vr_mode 7" to invoke quad-buffered stereo +CVAR(Bool, vr_enable_quadbuffered, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) + EXTERN_CVAR(Int, vid_refreshrate) //========================================================================== @@ -620,7 +625,7 @@ bool Win32GLVideo::SetupPixelFormat(int multisample) { int colorDepth; HDC deskDC; - int attributes[26]; + int attributes[28]; int pixelFormat; unsigned int numFormats; float attribsFloat[] = {0.0f, 0.0f}; @@ -651,26 +656,31 @@ bool Win32GLVideo::SetupPixelFormat(int multisample) attributes[16] = WGL_DOUBLE_BUFFER_ARB; attributes[17] = true; - attributes[18] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB - attributes[19] = WGL_FULL_ACCELERATION_ARB; + // [BB] Starting with driver version 314.07, NVIDIA GeForce cards support OpenGL quad buffered + // stereo rendering with 3D Vision hardware. Select the corresponding attribute here. + attributes[18] = vr_enable_quadbuffered ? WGL_STEREO_ARB : 0; + attributes[19] = true; + + attributes[20] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB + attributes[21] = WGL_FULL_ACCELERATION_ARB; if (multisample > 0) { - attributes[20] = WGL_SAMPLE_BUFFERS_ARB; - attributes[21] = true; - attributes[22] = WGL_SAMPLES_ARB; - attributes[23] = multisample; + attributes[22] = WGL_SAMPLE_BUFFERS_ARB; + attributes[23] = true; + attributes[24] = WGL_SAMPLES_ARB; + attributes[25] = multisample; } else { - attributes[20] = 0; - attributes[21] = 0; attributes[22] = 0; attributes[23] = 0; + attributes[24] = 0; + attributes[25] = 0; } - attributes[24] = 0; - attributes[25] = 0; + attributes[26] = 0; + attributes[27] = 0; if (!myWglChoosePixelFormatARB(m_hDC, attributes, attribsFloat, 1, &pixelFormat, &numFormats)) { diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 1f35a7651..5f607bf69 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -132,8 +132,10 @@ OptionValue VRMode 0, "Normal" 1, "Green/Magenta" 2, "Red/Cyan" + 9, "Amber/Blue" 5, "Left Eye" 6, "Right Eye" + 7, "Quad-buffered" } OptionMenu "GLTextureGLOptions" @@ -186,5 +188,6 @@ OptionMenu "GLPrefOptions" Slider "Ambient light level", gl_light_ambient, 1.0, 255.0, 5.0 Option "Rendering quality", gl_render_precise, "Precision" Option "Stereo 3D VR", vr_mode, "VRMode" + Option "Enable Quad Stereo", vr_enable_quadbuffered, "OnOff" } From 072a5e60aefe9d686d66c6876730fb10e074b9f9 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 9 Apr 2016 17:03:55 -0400 Subject: [PATCH 0469/1509] Naive change to get latest version to compile. --- src/gl/system/gl_framebuffer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 31bc2b069..50300090c 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -402,7 +402,8 @@ bool OpenGLFrameBuffer::Begin2D(bool) // //========================================================================== -void STACK_ARGS OpenGLFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) +// void STACK_ARGS OpenGLFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) +void OpenGLFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) { if (GLRenderer != NULL) GLRenderer->DrawTexture(img, parms); } From 84c8f38038c625026b46608b62be76ef40a60ad8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 10 Apr 2016 00:45:48 +0200 Subject: [PATCH 0470/1509] - fixed: The divisions in FTexCoordInfo::TextureOffset and RowOffset were turned into multiplications when converting to floating point. --- src/gl/textures/gl_material.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 40e2931a6..60a53fda3 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -332,12 +332,12 @@ float FTexCoordInfo::RowOffset(float rowoffset) const if (mTempScale.Y == 1.f) { if (mScale.Y == 1.f || mWorldPanning) return rowoffset; - else return rowoffset * mScale.Y; + else return rowoffset / mScale.Y; } else { - if (mWorldPanning) return rowoffset * mTempScale.Y; - else return rowoffset * mScale.Y; + if (mWorldPanning) return rowoffset / mTempScale.Y; + else return rowoffset / mScale.Y; } } @@ -352,12 +352,12 @@ float FTexCoordInfo::TextureOffset(float textureoffset) const if (mTempScale.X == 1.f) { if (mScale.X == 1.f || mWorldPanning) return textureoffset; - else return textureoffset * mScale.X; + else return textureoffset / mScale.X; } else { - if (mWorldPanning) return textureoffset * mTempScale.X; - else return textureoffset * mScale.X; + if (mWorldPanning) return textureoffset / mTempScale.X; + else return textureoffset / mScale.X; } } From bde94879ad594f3bd90876c9a3ae7f422efa4f29 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 9 Apr 2016 21:46:14 -0400 Subject: [PATCH 0471/1509] Restore stereoscopic geometry correctness, by inserting a minus sign where it always should have been, after finding that a compensating minus sign, where it probably should not have been anyway, was removed during the recent floating point refactoring. --- src/gl/stereo3d/gl_stereo_leftright.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/stereo3d/gl_stereo_leftright.cpp b/src/gl/stereo3d/gl_stereo_leftright.cpp index 6b7f5fe80..7b12283d2 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.cpp +++ b/src/gl/stereo3d/gl_stereo_leftright.cpp @@ -73,7 +73,7 @@ VSMatrix ShiftedEyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLO /* virtual */ void ShiftedEyePose::GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const { - FLOATTYPE dx = cos(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; + FLOATTYPE dx = -cos(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; FLOATTYPE dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; outViewShift[0] = dx; outViewShift[1] = dy; From f6d296e1030543c475382047e4aba3386cd8d3bc Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 9 Apr 2016 22:08:40 -0400 Subject: [PATCH 0472/1509] Add comment by line I modified to avoid compile problem with Visual Studio 2015 --- src/gl/system/gl_framebuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 50300090c..aa1261720 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -402,7 +402,7 @@ bool OpenGLFrameBuffer::Begin2D(bool) // //========================================================================== -// void STACK_ARGS OpenGLFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) +// void STACK_ARGS OpenGLFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) // CMB Does not compile for me on VS2015 "redefinition; different type modifiers" void OpenGLFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) { if (GLRenderer != NULL) GLRenderer->DrawTexture(img, parms); From bd8b8911d5ecec00bc63abd0132ca603f34b0734 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 11 Apr 2016 10:08:18 +0300 Subject: [PATCH 0473/1509] - fixed Windows 32-bit build --- src/gl/system/gl_framebuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 31bc2b069..ca8a5dc32 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -402,7 +402,7 @@ bool OpenGLFrameBuffer::Begin2D(bool) // //========================================================================== -void STACK_ARGS OpenGLFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) +void OpenGLFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) { if (GLRenderer != NULL) GLRenderer->DrawTexture(img, parms); } From bf2b61f61cab8abcca44bd97b2fcb2e9fa4f5e06 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Apr 2016 10:55:09 +0200 Subject: [PATCH 0474/1509] - removed remaining STACK_ARGS from GL code. --- src/gl/data/gl_setup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index 4e58831fa..1cbb3b151 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -487,7 +487,7 @@ static void GetSideVertices(int sdnum, DVector2 *v1, DVector2 *v2) } } -static int STACK_ARGS segcmp(const void *a, const void *b) +static int segcmp(const void *a, const void *b) { seg_t *A = *(seg_t**)a; seg_t *B = *(seg_t**)b; From 273c1ea51053dfc1327dd6514acc2575596c564b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Apr 2016 19:59:39 +0200 Subject: [PATCH 0475/1509] - fixed PointOnSide caclulation for dynamic lights. --- src/gl/dynlights/a_dynlight.cpp | 2 +- src/gl/scene/gl_drawinfo.cpp | 6 +++--- src/gl/system/gl_system.h | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index eccd8afcb..34c7683dc 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -560,7 +560,7 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &pos, subsector_t *subSec if (seg->sidedef && seg->linedef && seg->linedef->validcount != ::validcount) { // light is in front of the seg - if ((pos.Y - seg->v1->fY()) * (seg->v2->fX() - seg->v1->fX()) + (seg->v1->fX() - pos.X * (seg->v2->fY() - seg->v1->fY())) <= 0) + if ((pos.Y - seg->v1->fY()) * (seg->v2->fX() - seg->v1->fX()) + (seg->v1->fX() - pos.X) * (seg->v2->fY() - seg->v1->fY()) <= 0) { seg->linedef->validcount = validcount; touching_sides = AddLightNode(&seg->sidedef->lighthead, seg->sidedef, this, touching_sides); diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index e12d61ce3..7b30e41db 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -547,7 +547,7 @@ inline int GLDrawList::CompareSprites(SortNode * a,SortNode * b) // //========================================================================== static GLDrawList * gd; -int __cdecl CompareSprite(const void * a,const void * b) +int CompareSprite(const void * a,const void * b) { return gd->CompareSprites(*(SortNode**)a,*(SortNode**)b); } @@ -838,7 +838,7 @@ void GLDrawList::DrawDecals() //========================================================================== static GLDrawList * sortinfo; -static int __cdecl diwcmp (const void *a, const void *b) +static int diwcmp (const void *a, const void *b) { const GLDrawItem * di1 = (const GLDrawItem *)a; GLWall * w1=&sortinfo->walls[di1->index]; @@ -850,7 +850,7 @@ static int __cdecl diwcmp (const void *a, const void *b) return ((w1->flags & 3) - (w2->flags & 3)); } -static int __cdecl difcmp (const void *a, const void *b) +static int difcmp (const void *a, const void *b) { const GLDrawItem * di1 = (const GLDrawItem *)a; GLFlat * w1=&sortinfo->flats[di1->index]; diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h index ed52ab7ef..e9e3c5357 100644 --- a/src/gl/system/gl_system.h +++ b/src/gl/system/gl_system.h @@ -84,7 +84,6 @@ typedef unsigned char byte; typedef float FLOAT; template inline T max( T a, T b) { return (((a)>(b)) ? (a) : (b)); } -#define __cdecl #define _access(a,b) access(a,b) #endif #ifndef _WIN32 From 56f8974b6631c08ebe519c3615cae3e9930b7083 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Apr 2016 19:59:57 +0200 Subject: [PATCH 0476/1509] - removed debug code. --- src/gl/dynlights/a_dynlight.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 34c7683dc..2e4c9b005 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -623,10 +623,6 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &pos, subsector_t *subSec void ADynamicLight::LinkLight() { - if (X() == 1088 && Y() == 2832) - { - int a = 0; - } // mark the old light nodes FLightNode * node; From a411b93e1dcafa81b657c2ae74e91e9feb43ca30 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 12 Apr 2016 16:01:08 +0200 Subject: [PATCH 0477/1509] - fixed: The dynamic pulse light should always use its maximum size for linking into the sector lists, just like the other types with changing size do. These limking operations are not cheap so it's preferable to have them affect a bit more geometry than running the linking code each tic. --- src/gl/dynlights/a_dynlight.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 2e4c9b005..7cb6e91d9 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -363,7 +363,7 @@ void ADynamicLight::UpdateLocation() // The radius being used here is always the maximum possible with the // current settings. This avoids constant relinking of flickering lights - if (lighttype == FlickerLight || lighttype == RandomFlickerLight) + if (lighttype == FlickerLight || lighttype == RandomFlickerLight || lighttype == PulseLight) { intensity = float(MAX(m_intensity[0], m_intensity[1])); } From bec3208efd332a1ca6dcc4d5d115a16c94f5e32c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 12 Apr 2016 19:50:29 +0200 Subject: [PATCH 0478/1509] - added support for distancecheck property. --- src/gl/scene/gl_bsp.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index 28b08d536..d72dfae86 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -339,6 +339,17 @@ static inline void RenderThings(subsector_t * sub, sector_t * sector) // Handle all things in sector. for (AActor * thing = sec->thinglist; thing; thing = thing->snext) { + FIntCVar *cvar = thing->GetClass()->distancecheck; + if (cvar != NULL && *cvar >= 0) + { + double dist = thing->Distance2DSquared(camera); + double check = (double)**cvar; + if (dist >= check * check) + { + continue; + } + } + GLRenderer->ProcessSprite(thing, sector); } } From 37f43617d95e0a2481986cb278b08ec2758bd62f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 13 Apr 2016 11:35:05 +0200 Subject: [PATCH 0479/1509] - make distance check 3D and use proper viewpoint. --- src/gl/scene/gl_bsp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index d72dfae86..cc8c364b2 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -342,7 +342,7 @@ static inline void RenderThings(subsector_t * sub, sector_t * sector) FIntCVar *cvar = thing->GetClass()->distancecheck; if (cvar != NULL && *cvar >= 0) { - double dist = thing->Distance2DSquared(camera); + double dist = (thing->PosRelative(viewsector) - ViewPos).LengthSquared(); double check = (double)**cvar; if (dist >= check * check) { From d0b30f31e1f8f696a7c3d0b7ed003f9e6bc25ff1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 13 Apr 2016 11:41:51 +0200 Subject: [PATCH 0480/1509] - fixed: Checking for slopes at untextured bottom parts of the wall checked the ceiling's slope not the floor's. --- src/gl/scene/gl_walls.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index c59d4a041..231503407 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1588,7 +1588,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) { - if ((frontsector->ceilingplane.isSlope() || backsector->ceilingplane.isSlope()) && + if ((frontsector->floorplane.isSlope() || backsector->floorplane.isSlope()) && frontsector->GetTexture(sector_t::floor) != skyflatnum && backsector->GetTexture(sector_t::floor) != skyflatnum) { From d66a28fcde250fe2fb26d502fdaefcdeac60a22f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 13 Apr 2016 16:24:25 +0200 Subject: [PATCH 0481/1509] - fixed offsetting of player weapon sprites. --- src/gl/models/gl_models.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index a03a73931..6050ac24d 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -976,7 +976,7 @@ void gl_RenderHUDModel(pspdef_t *psp, float ofsX, float ofsY) // [BB] Weapon bob, very similar to the normal Doom weapon bob. gl_RenderState.mViewMatrix.rotate(ofsX/4, 0, 1, 0); - gl_RenderState.mViewMatrix.rotate(-ofsY-WEAPONTOP/4, 1, 0, 0); + gl_RenderState.mViewMatrix.rotate((ofsY-WEAPONTOP)/-4., 1, 0, 0); // [BB] For some reason the jDoom models need to be rotated. gl_RenderState.mViewMatrix.rotate(90.f, 0, 1, 0); From bffb7444a03b28bfaa3aeb7b7fafe44d71cb43e1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 13 Apr 2016 19:33:45 +0200 Subject: [PATCH 0482/1509] - removed portal check for distance check in GL code. --- src/gl/scene/gl_bsp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index cc8c364b2..a32b8aaa0 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -342,7 +342,7 @@ static inline void RenderThings(subsector_t * sub, sector_t * sector) FIntCVar *cvar = thing->GetClass()->distancecheck; if (cvar != NULL && *cvar >= 0) { - double dist = (thing->PosRelative(viewsector) - ViewPos).LengthSquared(); + double dist = (thing->Pos() - ViewPos).LengthSquared(); double check = (double)**cvar; if (dist >= check * check) { From ee3712ffeb25b1e3e559e9dcab5cd0834b87144f Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Thu, 14 Apr 2016 00:59:37 +0800 Subject: [PATCH 0483/1509] Exported all OpenGL menu options into the LANGUAGE lump. --- wadsrc/static/language.enu | 121 ++++++++++++++++++- wadsrc/static/menudef.z | 237 ++++++++++++++++++------------------- 2 files changed, 236 insertions(+), 122 deletions(-) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index e76df2f39..90f8f56dd 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2547,11 +2547,126 @@ MUSIC_DM2INT = "dm2int"; // GZDoom exclusive: -DSPLYMNU_GLOPT = "OpenGL Options"; -DSPLYMNU_GAMMA = "Gamma correction"; -DSPLYMNU_CONTRAST ="Contrast"; +DSPLYMNU_GLOPT = "OpenGL Options"; +DSPLYMNU_GAMMA = "Gamma correction"; +DSPLYMNU_CONTRAST ="Contrast"; +// OpenGL Options GLMNU_TITLE = "OPENGL OPTIONS"; GLMNU_DYNLIGHT = "Dynamic Light Options"; GLMNU_TEXOPT = "Texture Options"; GLMNU_PREFS = "Preferences"; + +// Texture Options +GLTEXMNU_TITLE = "TEXTURE OPTIONS"; +GLTEXMNU_TEXENABLED = "Textures enabled"; +GLTEXMNU_TEXFILTER = "Texture Filter mode"; +GLTEXMNU_ANISOTROPIC = "Anisotropic filter"; +GLTEXMNU_TEXFORMAT = "Texture Format"; +GLTEXMNU_ENABLEHIRES = "Enable hires textures"; +GLTEXMNU_HQRESIZE = "High Quality Resize mode"; +GLTEXMNU_RESIZETEX = "Resize textures"; +GLTEXMNU_RESIZESPR = "Resize sprites"; +GLTEXMNU_RESIZEFNT = "Resize fonts"; +GLTEXMNU_PRECACHETEX = "Precache GL textures"; +GLTEXMNU_CAMTEXOFFSCR = "Camera textures offscreen"; +GLTEXMNU_TRIMSPREDGE = "Trim sprite edges"; +GLTEXMNU_SORTDRAWLIST = "Sort draw lists by texture"; + +// Dynamic Light Options +GLLIGHTMNU_TITLE = "DYNAMIC LIGHTS"; +GLLIGHTMNU_LIGHTSENABLED = "Dynamic Lights enabled"; +GLLIGHTMNU_LIGHTDEFS = "Enable light definitions"; +GLLIGHTMNU_CLIPLIGHTS = "Clip lights"; +GLLIGHTMNU_LIGHTSPRITES = "Lights affect sprites"; +GLLIGHTMNU_LIGHTPARTICLES = "Lights affect particles"; +GLLIGHTMNU_FORCEADDITIVE = "Force additive lighting"; +GLLIGHTMNU_LIGHTINTENSITY = "Light intensity"; +GLLIGHTMNU_LIGHTSIZE = "Light size"; + +// OpenGL Preferences +GLPREFMNU_TITLE = "OPENGL PREFERENCES"; +GLPREFMNU_SECLIGHTMODE = "Sector light mode"; +GLPREFMNU_FOGMODE = "Fog mode"; +GLPREFMNU_FOGFORCEFULLBRIGHT = "Fog forces fullbright"; +GLPREFMNU_WPNLIGHTSTR = "Weapon light strength"; +GLPREFMNU_ENVIRONMENTMAPMIRROR = "Environment map on mirrors"; +GLPREFMNU_ENV = "Enhanced night vision mode"; +GLPREFMNU_ENVSTEALTH = "ENV shows stealth monsters"; +GLPREFMNU_SPRBRIGHTFOG = "Force brightness in fog"; +GLPREFMNU_SPRCLIP = "Adjust sprite clipping"; +GLPREFMNU_SPRBLEND = "Smooth sprite edges"; +GLPREFMNU_FUZZSTYLE = "Fuzz Style"; +GLPREFMNU_SPRBILLBOARD = "Sprite billboard"; +GLPREFMNU_PARTICLESTYLE = "Particle style"; +GLPREFMNU_AMBLIGHT = "Ambient light level"; +GLPREFMNU_RENDERQUALITY = "Rendering quality""; +GLPREFMNU_VRMODE = "Stereo 3D VR"; +GLPREFMNU_VRQUADSTEREO = "Enable Quad Stereo"; + +// Option Values +OPTVAL_SMART = "Smart"; +OPTVAL_SMARTER = "Smarter"; +OPTVAL_INFRAREDONLY = "Infrared only"; +OPTVAL_INFRAREDANDTORCH = "Infrared and torch"; +OPTVAL_ANYFIXEDCOLORMAP = "Any fixed colormap"; +OPTVAL_NONENEARESTMIPMAP = "None (nearest mipmap)"; +OPTVAL_NONELINEARMIPMAP = "None (linear mipmap)"; +OPTVAL_BILINEAR = "Bilinear"; +OPTVAL_TRILINEAR = "Trilinear"; +OPTVAL_RGBA8 = "RGBA8"; +OPTVAL_RGB5A1 = "RGB5_A1"; +OPTVAL_RGBA4 = "RGBA4"; +OPTVAL_RGBA2 = "RGBA2"; +OPTVAL_COMPRRGBA = "COMPR_RGBA"; +OPTVAL_S3TCDXT1 = "S3TC_DXT1"; +OPTVAL_S3TCDXT3 = "S3TC_DXT3"; +OPTVAL_S3TCDXT5 = "S3TC_DXT5"; +OPTVAL_2X = "2x"; +OPTVAL_4X = "4x"; +OPTVAL_8X = "8x"; +OPTVAL_16X = "16x"; +OPTVAL_USEASPALETTE = "Use as palette"; +OPTVAL_BLEND = "Blend"; +OPTVAL_STANDARD = "Standard"; +OPTVAL_BRIGHT = "Bright"; +OPTVAL_DARK = "Dark"; +OPTVAL_LEGACY = "Legacy"; +OPTVAL_SOFTWARE = "Software"; +OPTVAL_SPEED = "Speed"; +OPTVAL_QUALITY = "Quality"; +OPTVAL_OPTIMAL = "Optimal"; +OPTVAL_60 = "60"; +OPTVAL_70 = "70"; +OPTVAL_72 = "72"; +OPTVAL_75 = "75"; +OPTVAL_85 = "85"; +OPTVAL_100 = "100"; +OPTVAL_YAXIS = "Y Axis"; +OPTVAL_XYAXIS = "X/Y Axis"; +OPTVAL_SQUARE = "Square"; +OPTVAL_ROUND = "Round"; +OPTVAL_SCALE2X = "Scale2x"; +OPTVAL_SCALE3X = "Scale3x"; +OPTVAL_SCALE4X = "Scale4x"; +OPTVAL_HQ2X = "hq2x"; +OPTVAL_HQ3X = "hq3x"; +OPTVAL_HQ4X = "hq4x"; +OPTVAL_HQ2XMMX = "hq2x MMX"; +OPTVAL_HQ3XMMX = "hq3x MMX"; +OPTVAL_HQ4XMMX = "hq4x MMX"; +OPTVAL_RADIAL = "Radial"; +OPTVAL_PIXELFUZZ = "Pixel fuzz"; +OPTVAL_SMOOTHFUZZ = "Smooth fuzz"; +OPTVAL_SWIRLYFUZZ = "Swirly fuzz"; +OPTVAL_TRANSLUCENTFUZZ = "Translucent fuzz"; +OPTVAL_NOISE = "Noise"; +OPTVAL_SMOOTHNOISE = "Smooth Noise"; +OPTVAL_JAGGEDFUZZ = "Jagged fuzz"; +OPTVAL_NORMAL = "Normal"; +OPTVAL_GREENMAGENTA = "Green/Magenta"; +OPTVAL_REDCYAN = "Red/Cyan"; +OPTVAL_AMBERBLUE = "Amber/Blue"; +OPTVAL_LEFTEYE = "Left Eye"; +OPTVAL_RIGHTEYE = "Right Eye"; +OPTVAL_QUADBUFFERED = "Quad-buffered"; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 5f607bf69..ddaf82e7d 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -1,193 +1,192 @@ OptionValue "SpriteclipModes" { - 0, "Never" - 1, "Smart" - 2, "Always" - 3, "Smarter" + 0, "$OPTVAL_NEVER" + 1, "$OPTVAL_SMART" + 2, "$OPTVAL_ALWAYS" + 3, "$OPTVAL_SMARTER" } OptionValue "EnhancedStealth" { - 0, "Never" - 1, "Infrared only" - 2, "Infrared and torch" - 3, "Any fixed colormap" + 0, "$OPTVAL_NEVER" + 1, "$OPTVAL_INFRAREDONLY" + 2, "$OPTVAL_INFRAREDANDTORCH" + 3, "$OPTVAL_ANYFIXEDCOLORMAP" } OptionValue "FilterModes" { - 0, "None" - 1, "None (nearest mipmap)" - 5, "None (linear mipmap)" - 2, "Linear" - 3, "Bilinear" - 4, "Trilinear" + 0, "$OPTVAL_NONE" + 1, "$OPTVAL_NONENEARESTMIPMAP" + 5, "$OPTVAL_NONELINEARMIPMAP" + 2, "$OPTVAL_LINEAR" + 3, "$OPTVAL_BILINEAR" + 4, "$OPTVAL_TRILINEAR" } OptionValue "TextureFormats" { - 0, "RGBA8" - 1, "RGB5_A1" - 2, "RGBA4" - 3, "RGBA2" + 0, "$OPTVAL_RGBA8" + 1, "$OPTVAL_RGB5A1" + 2, "$OPTVAL_RGBA4" + 3, "$OPTVAL_RGBA2" // [BB] Added modes for texture compression. - 4, "COMPR_RGBA" - 5, "S3TC_DXT1" - 6, "S3TC_DXT3" - 7, "S3TC_DXT5" + 4, "$OPTVAL_COMPRRGBA" + 5, "$OPTVAL_S3TCDXT1" + 6, "$OPTVAL_S3TCDXT3" + 7, "$OPTVAL_S3TCDXT5" } OptionValue "Anisotropy" { - 1, "Off" - 2, "2x" - 4, "4x" - 8, "8x" - 16, "16x" + 1, "$OPTVAL_OFF" + 2, "$OPTVAL_2X" + 4, "$OPTVAL_4X" + 8, "$OPTVAL_8X" + 16, "$OPTVAL_16X" } OptionValue "Colormaps" { - 0, "Use as palette" - 1, "Blend" + 0, "$OPTVAL_USEASPALETTE" + 1, "$OPTVAL_BLEND" } OptionValue "LightingModes" { - 0, "Standard" - 1, "Bright" - 2, "Doom" - 3, "Dark" - 4, "Legacy" - 8, "Software" + 0, "$OPTVAL_STANDARD" + 1, "$OPTVAL_BRIGHT" + 2, "$OPTVAL_DOOM" + 3, "$OPTVAL_DARK" + 4, "$OPTVAL_LEGACY" + 8, "$OPTVAL_SOFTWARE" } OptionValue "Precision" { - 0, "Speed" - 1, "Quality" + 0, "$OPTVAL_SPEED" + 1, "$OPTVAL_QUALITY" } OptionValue "Hz" { - 0, "Optimal" - 60, "60" - 70, "70" - 72, "72" - 75, "75" - 85, "85" - 100, "100" + 0, "$OPTVAL_OPTIMAL" + 60, "$OPTVAL_60" + 70, "$OPTVAL_70" + 72, "$OPTVAL_72" + 75, "$OPTVAL_75" + 85, "$OPTVAL_85" + 100, "$OPTVAL_100" } OptionValue "BillboardModes" { - 0, "Y Axis" - 1, "X/Y Axis" + 0, "$OPTVAL_YAXIS" + 1, "$OPTVAL_XYAXIS" } OptionValue "Particles" { - 0, "Square" - 1, "Round" - 2, "Smooth" + 0, "$OPTVAL_SQUARE" + 1, "$OPTVAL_ROUND" + 2, "$OPTVAL_SMOOTH" } OptionValue "HqResizeModes" { - 0, "Off" - 1, "Scale2x" - 2, "Scale3x" - 3, "Scale4x" - 4, "hq2x" - 5, "hq3x" - 6, "hq4x" - 7, "hq2x MMX" - 8, "hq3x MMX" - 9, "hq4x MMX" + 0, "$OPTVAL_OFF" + 1, "$OPTVAL_SCALE2X" + 2, "$OPTVAL_SCALE3X" + 3, "$OPTVAL_SCALE4X" + 4, "$OPTVAL_HQ2X" + 5, "$OPTVAL_HQ3X" + 6, "$OPTVAL_HQ4X" + 7, "$OPTVAL_HQ2XMMX" + 8, "$OPTVAL_HQ3XMMX" + 9, "$OPTVAL_HQ4XMMX" } OptionValue "FogMode" { - 0, "Off" - 1, "Standard" - 2, "Radial" + 0, "$OPTVAL_OFF" + 1, "$OPTVAL_STANDARD" + 2, "$OPTVAL_RADIAL" } OptionValue "FuzzStyle" { - 0, "Shadow" - 1, "Pixel fuzz" - 2, "Smooth fuzz" - 3, "Swirly fuzz" - 4, "Translucent fuzz" - 6, "Noise" - 7, "Smooth Noise" - //5, "Jagged fuzz" I can't see any difference between this and 4 so it's disabled for now. + 0, "$OPTVAL_SHADOW" + 1, "$OPTVAL_PIXELFUZZ" + 2, "$OPTVAL_SMOOTHFUZZ" + 3, "$OPTVAL_SWIRLYFUZZ" + 4, "$OPTVAL_TRANSLUCENTFUZZ" + 6, "$OPTVAL_NOISE" + 7, "$OPTVAL_SMOOTHNOISE" + //5, "$OPTVAL_JAGGEDFUZZ" I can't see any difference between this and 4 so it's disabled for now. } OptionValue VRMode { - 0, "Normal" - 1, "Green/Magenta" - 2, "Red/Cyan" - 9, "Amber/Blue" - 5, "Left Eye" - 6, "Right Eye" - 7, "Quad-buffered" + 0, "$OPTVAL_NORMAL" + 1, "$OPTVAL_GREENMAGENTA" + 2, "$OPTVAL_REDCYAN" + 9, "$OPTVAL_AMBERBLUE" + 5, "$OPTVAL_LEFTEYE" + 6, "$OPTVAL_RIGHTEYE" + 7, "$OPTVAL_QUADBUFFERED" } OptionMenu "GLTextureGLOptions" { - Title "TEXTURE OPTIONS" - Option "Textures enabled", gl_texture, "YesNo" - Option "Texture Filter mode", gl_texture_filter, "FilterModes" - Option "Anisotropic filter", gl_texture_filter_anisotropic, "Anisotropy" - Option "Texture Format", gl_texture_format, "TextureFormats" - Option "Enable hires textures", gl_texture_usehires, "YesNo" - Option "High Quality Resize mode", gl_texture_hqresize, "HqResizeModes" - Option "Resize textures", gl_texture_hqresize_textures, "OnOff" - Option "Resize sprites", gl_texture_hqresize_sprites, "OnOff" - Option "Resize fonts", gl_texture_hqresize_fonts, "OnOff" - Option "Precache GL textures", gl_precache, "YesNo" - Option "Camera textures offscreen", gl_usefb, "OnOff" - Option "Trim sprite edges", gl_trimsprites, "OnOff" - Option "Sort draw lists by texture", gl_sort_textures, "YesNo" + Title "$GLTEXMNU_TITLE" + Option "$GLTEXMNU_TEXENABLED", gl_texture, "YesNo" + Option "$GLTEXMNU_TEXFILTER", gl_texture_filter, "FilterModes" + Option "$GLTEXMNU_ANISOTROPIC", gl_texture_filter_anisotropic, "Anisotropy" + Option "$GLTEXMNU_TEXFORMAT", gl_texture_format, "TextureFormats" + Option "$GLTEXMNU_ENABLEHIRES", gl_texture_usehires, "YesNo" + Option "$GLTEXMNU_HQRESIZE", gl_texture_hqresize, "HqResizeModes" + Option "$GLTEXMNU_RESIZETEX", gl_texture_hqresize_textures, "OnOff" + Option "$GLTEXMNU_RESIZESPR", gl_texture_hqresize_sprites, "OnOff" + Option "$GLTEXMNU_RESIZEFNT", gl_texture_hqresize_fonts, "OnOff" + Option "$GLTEXMNU_PRECACHETEX", gl_precache, "YesNo" + Option "$GLTEXMNU_CAMTEXOFFSCR", gl_usefb, "OnOff" + Option "$GLTEXMNU_TRIMSPREDGE", gl_trimsprites, "OnOff" + Option "$GLTEXMNU_SORTDRAWLIST", gl_sort_textures, "YesNo" } OptionMenu "GLLightOptions" { - Title "DYNAMIC LIGHTS" - Option "Dynamic Lights enabled", gl_lights, "YesNo" - Option "Enable light definitions", gl_attachedlights, "YesNo" - Option "Clip lights", gl_lights_checkside, "YesNo" - Option "Lights affect sprites", gl_light_sprites, "YesNo" - Option "Lights affect particles", gl_light_particles, "YesNo" - Option "Force additive lighting", gl_lights_additive, "YesNo" - Slider "Light intensity", gl_lights_intensity, 0.0, 1.0, 0.1 - Slider "Light size", gl_lights_size, 0.0, 2.0, 0.1 + Title "$GLLIGHTMNU_TITLE" + Option "$GLLIGHTMNU_LIGHTSENABLED", gl_lights, "YesNo" + Option "$GLLIGHTMNU_LIGHTDEFS", gl_attachedlights, "YesNo" + Option "$GLLIGHTMNU_CLIPLIGHTS", gl_lights_checkside, "YesNo" + Option "$GLLIGHTMNU_LIGHTSPRITES", gl_light_sprites, "YesNo" + Option "$GLLIGHTMNU_LIGHTPARTICLES", gl_light_particles, "YesNo" + Option "$GLLIGHTMNU_FORCEADDITIVE", gl_lights_additive, "YesNo" + Slider "$GLLIGHTMNU_LIGHTINTENSITY", gl_lights_intensity, 0.0, 1.0, 0.1 + Slider "$GLLIGHTMNU_LIGHTSIZE", gl_lights_size, 0.0, 2.0, 0.1 } OptionMenu "GLPrefOptions" { - Title "OPENGL PREFERENCES" - Option "Sector light mode", gl_lightmode, "LightingModes" - Option "Fog mode", gl_fogmode, "FogMode" - Option "Fog forces fullbright", gl_brightfog, "YesNo" - Slider "Weapon light strength", gl_weaponlight, 0,32, 2 - Option "Environment map on mirrors",gl_mirror_envmap, "OnOff" - Option "Enhanced night vision mode",gl_enhanced_nightvision, "OnOff" - Option "ENV shows stealth monsters",gl_enhanced_nv_stealth, "EnhancedStealth" - Option "Force brightness in fog", gl_spritebrightfog, "OnOff" - Option "Adjust sprite clipping", gl_spriteclip, "SpriteclipModes" - Option "Smooth sprite edges", gl_sprite_blend, "OnOff" - Option "Fuzz Style", gl_fuzztype, "FuzzStyle" - Option "Sprite billboard", gl_billboard_mode, "BillboardModes" - Option "Particle style", gl_particles_style, "Particles" - Slider "Ambient light level", gl_light_ambient, 1.0, 255.0, 5.0 - Option "Rendering quality", gl_render_precise, "Precision" - Option "Stereo 3D VR", vr_mode, "VRMode" - Option "Enable Quad Stereo", vr_enable_quadbuffered, "OnOff" + Title "$GLPREFMNU_TITLE" + Option "$GLPREFMNU_SECLIGHTMODE", gl_lightmode, "LightingModes" + Option "$GLPREFMNU_FOGMODE", gl_fogmode, "FogMode" + Option "$GLPREFMNU_FOGFORCEFULLBRIGHT", gl_brightfog, "YesNo" + Slider "$GLPREFMNU_WPNLIGHTSTR", gl_weaponlight, 0,32, 2 + Option "$GLPREFMNU_ENVIRONMENTMAPMIRROR", gl_mirror_envmap, "OnOff" + Option "$GLPREFMNU_ENV", gl_enhanced_nightvision, "OnOff" + Option "$GLPREFMNU_ENVSTEALTH", gl_enhanced_nv_stealth, "EnhancedStealth" + Option "$GLPREFMNU_SPRBRIGHTFOG", gl_spritebrightfog, "OnOff" + Option "$GLPREFMNU_SPRCLIP", gl_spriteclip, "SpriteclipModes" + Option "$GLPREFMNU_SPRBLEND", gl_sprite_blend, "OnOff" + Option "$GLPREFMNU_FUZZSTYLE", gl_fuzztype, "FuzzStyle" + Option "$GLPREFMNU_SPRBILLBOARD", gl_billboard_mode, "BillboardModes" + Option "$GLPREFMNU_PARTICLESTYLE", gl_particles_style, "Particles" + Slider "$GLPREFMNU_AMBLIGHT", gl_light_ambient, 1.0, 255.0, 5.0 + Option "$GLPREFMNU_RENDERQUALITY", gl_render_precise, "Precision" + Option "$GLPREFMNU_VRMODE", vr_mode, "VRMode" + Option "$GLPREFMNU_VRQUADSTEREO", vr_enable_quadbuffered, "OnOff" } - From bac3f1ee9b90744f6b917851e7e7ff5a11193551 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 13 Apr 2016 21:10:42 +0200 Subject: [PATCH 0484/1509] - removed redundant quote. --- wadsrc/static/language.enu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 90f8f56dd..d4caef7e6 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2600,7 +2600,7 @@ GLPREFMNU_FUZZSTYLE = "Fuzz Style"; GLPREFMNU_SPRBILLBOARD = "Sprite billboard"; GLPREFMNU_PARTICLESTYLE = "Particle style"; GLPREFMNU_AMBLIGHT = "Ambient light level"; -GLPREFMNU_RENDERQUALITY = "Rendering quality""; +GLPREFMNU_RENDERQUALITY = "Rendering quality"; GLPREFMNU_VRMODE = "Stereo 3D VR"; GLPREFMNU_VRQUADSTEREO = "Enable Quad Stereo"; From caf80e74c4ebf5324b5ab5c1a9a96c5f29bd4dcc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 13 Apr 2016 23:09:45 +0200 Subject: [PATCH 0485/1509] - fixed multiplication/division mixup in TextureAdjustWidth. - fixed: For top textures an incorrect ceiling height was passed to DoTexture. --- src/gl/scene/gl_walls.cpp | 4 ++-- src/gl/textures/gl_material.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 231503407..5d13a0720 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1503,7 +1503,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, - frefz, realback->GetPlaneTexZF(sector_t::ceiling), + crefz, realback->GetPlaneTexZF(sector_t::ceiling), fch1, fch2, bch1a, bch2a, 0); } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) @@ -1516,7 +1516,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, - frefz, realback->GetPlaneTexZF(sector_t::ceiling), + crefz, realback->GetPlaneTexZF(sector_t::ceiling), fch1, fch2, bch1a, bch2a, 0); } } diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 60a53fda3..f5c8f90b3 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -372,7 +372,7 @@ float FTexCoordInfo::TextureAdjustWidth() const if (mWorldPanning) { if (mTempScale.X == 1.f) return mRenderWidth; - else return mWidth * mTempScale.X; + else return mWidth / mTempScale.X; } else return mWidth; } From 328047ea28a92c9df0419891671e7cd2f2109da2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 14 Apr 2016 10:16:04 +0200 Subject: [PATCH 0486/1509] - fixed issues with recent Stereo3D submission: * there was a CVAR that was only defined in Windows * code did not compile with GCC. * due to bad setup it disabled multisampling. --- src/gl/stereo3d/gl_quadstereo.h | 2 +- src/gl/stereo3d/gl_stereo_cvars.cpp | 7 +++-- src/win32/win32gliface.cpp | 44 ++++++++++++++--------------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/gl/stereo3d/gl_quadstereo.h b/src/gl/stereo3d/gl_quadstereo.h index 615746ae7..f27fb78f8 100644 --- a/src/gl/stereo3d/gl_quadstereo.h +++ b/src/gl/stereo3d/gl_quadstereo.h @@ -84,7 +84,7 @@ class QuadStereo : public Stereo3DMode { public: QuadStereo(double ipdMeters); - static const QuadStereo& QuadStereo::getInstance(float ipd); + static const QuadStereo& getInstance(float ipd); private: QuadStereoLeftPose leftEye; QuadStereoRightPose rightEye; diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index 9f1f30505..e7d08df41 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -42,7 +42,10 @@ // Set up 3D-specific console variables: CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG) -EXTERN_CVAR(Bool, vr_enable_quadbuffered) +// For broadest GL compatibility, require user to explicitly enable quad-buffered stereo mode. +// Setting vr_enable_quadbuffered_stereo does not automatically invoke quad-buffered stereo, +// but makes it possible for subsequent "vr_mode 7" to invoke quad-buffered stereo +CVAR(Bool, vr_enable_quadbuffered, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // intraocular distance in meters CVAR(Float, vr_ipd, 0.062f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // METERS @@ -90,7 +93,7 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() else { setCurrentMode(MonoView::getInstance()); } - break ; + break; // TODO: 8: Oculus Rift case 9: setCurrentMode(AmberBlue::getInstance(vr_ipd)); diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 1fab45406..27cb562e2 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -47,11 +47,7 @@ CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ CVAR(Bool, gl_debug, false, 0) -// For broadest GL compatibility, require user to explicitly enable quad-buffered stereo mode. -// Setting vr_enable_quadbuffered_stereo does not automatically invoke quad-buffered stereo, -// but makes it possible for subsequent "vr_mode 7" to invoke quad-buffered stereo -CVAR(Bool, vr_enable_quadbuffered, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) - +EXTERN_CVAR(Bool, vr_enable_quadbuffered) EXTERN_CVAR(Int, vid_refreshrate) //========================================================================== @@ -623,6 +619,7 @@ bool Win32GLVideo::SetPixelFormat() bool Win32GLVideo::SetupPixelFormat(int multisample) { + int i; int colorDepth; HDC deskDC; int attributes[28]; @@ -656,31 +653,32 @@ bool Win32GLVideo::SetupPixelFormat(int multisample) attributes[16] = WGL_DOUBLE_BUFFER_ARB; attributes[17] = true; - // [BB] Starting with driver version 314.07, NVIDIA GeForce cards support OpenGL quad buffered - // stereo rendering with 3D Vision hardware. Select the corresponding attribute here. - attributes[18] = vr_enable_quadbuffered ? WGL_STEREO_ARB : 0; - attributes[19] = true; - - attributes[20] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB - attributes[21] = WGL_FULL_ACCELERATION_ARB; - if (multisample > 0) { - attributes[22] = WGL_SAMPLE_BUFFERS_ARB; - attributes[23] = true; - attributes[24] = WGL_SAMPLES_ARB; - attributes[25] = multisample; + attributes[18] = WGL_SAMPLE_BUFFERS_ARB; + attributes[19] = true; + attributes[20] = WGL_SAMPLES_ARB; + attributes[21] = multisample; + i = 22; } else { - attributes[22] = 0; - attributes[23] = 0; - attributes[24] = 0; - attributes[25] = 0; + i = 18; + } + + attributes[i++] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB + attributes[i++] = WGL_FULL_ACCELERATION_ARB; + + if (vr_enable_quadbuffered) + { + // [BB] Starting with driver version 314.07, NVIDIA GeForce cards support OpenGL quad buffered + // stereo rendering with 3D Vision hardware. Select the corresponding attribute here. + attributes[i++] = WGL_STEREO_ARB; + attributes[i++] = true; } - attributes[26] = 0; - attributes[27] = 0; + attributes[i++] = 0; + attributes[i++] = 0; if (!myWglChoosePixelFormatARB(m_hDC, attributes, attribsFloat, 1, &pixelFormat, &numFormats)) { From a0a530945d3399cbfbf75fdc2f4b2dce4947f468 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 14 Apr 2016 13:22:15 +0200 Subject: [PATCH 0487/1509] - added new sector type 90 which designates a sector that is being used as a cubemapped skybox, in case someone wants to make one of those without using an actual sky for this. --- src/gl/scene/gl_flats.cpp | 90 ++++++++++++++++++++++++++++++++++++--- src/gl/scene/gl_sky.cpp | 10 +---- src/gl/scene/gl_wall.h | 6 +++ src/gl/scene/gl_walls.cpp | 36 ++++++++++++---- 4 files changed, 119 insertions(+), 23 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 6dd611cdd..2a5ef712e 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -178,8 +178,8 @@ void GLFlat::DrawSubsector(subsector_t * sub) { vertex_t *vt = sub->firstline[k].v1; ptr->x = vt->fX(); - ptr->y = vt->fY(); ptr->z = plane.plane.ZatPoint(vt) + dz; + ptr->y = vt->fY(); ptr->u = vt->fX() / 64.f; ptr->v = -vt->fY() / 64.f; ptr++; @@ -252,7 +252,7 @@ void GLFlat::DrawSubsectors(int pass, bool processlights, bool istrans) if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli); DrawSubsector(sub); } - else + else { if (vboindex >= 0) { @@ -305,6 +305,76 @@ void GLFlat::DrawSubsectors(int pass, bool processlights, bool istrans) } +//========================================================================== +// +// special handling for skyboxes which need texture clamping. +// This will find the bounding rectangle of the sector and just +// draw one single polygon filling that rectangle with a clamped +// texture. +// +//========================================================================== + +void GLFlat::DrawSkyboxSector(int pass, bool processlights) +{ + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + + float minx = FLT_MAX, miny = FLT_MAX; + float maxx = -FLT_MAX, maxy = -FLT_MAX; + + for (int i = 0; i < sector->linecount; i++) + { + line_t *ln = sector->lines[i]; + float x = ln->v1->fX(); + float y = ln->v1->fY(); + if (x < minx) minx = x; + if (y < miny) miny = y; + if (x > maxx) maxx = x; + if (y > maxy) maxy = y; + x = ln->v2->fX(); + y = ln->v2->fY(); + if (x < minx) minx = x; + if (y < miny) miny = y; + if (x > maxx) maxx = x; + if (y > maxy) maxy = y; + } + + float z = plane.plane.ZatPoint(0., 0.) + dz; + + ptr->x = minx; + ptr->z = z; + ptr->y = miny; + ptr->u = 0; + ptr->v = 1; + ptr++; + + ptr->x = minx; + ptr->z = z; + ptr->y = maxy; + ptr->u = 0; + ptr->v = 0; + ptr++; + + ptr->x = maxx; + ptr->z = z; + ptr->y = maxy; + ptr->u = 1; + ptr->v = 0; + ptr++; + + ptr->x = maxx; + ptr->z = z; + ptr->y = miny; + ptr->u = 1; + ptr->v = 1; + ptr++; + + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + + flatvertices += 4; + flatprimitives++; +} + + //========================================================================== // // @@ -328,10 +398,18 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG case GLPASS_ALL: gl_SetColor(lightlevel, rel, Colormap,1.0f); gl_SetFog(lightlevel, rel, &Colormap, false); - gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); - gl_SetPlaneTextureRotation(&plane, gltexture); - DrawSubsectors(pass, (pass == GLPASS_ALL || dynlightindex > -1), false); - gl_RenderState.EnableTextureMatrix(false); + if (sector->special != GLSector_Skybox) + { + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); + gl_SetPlaneTextureRotation(&plane, gltexture); + DrawSubsectors(pass, (pass == GLPASS_ALL || dynlightindex > -1), false); + gl_RenderState.EnableTextureMatrix(false); + } + else + { + gl_RenderState.SetMaterial(gltexture, CLAMP_XY, 0, -1, false); + DrawSkyboxSector(pass, (pass == GLPASS_ALL || dynlightindex > -1)); + } break; case GLPASS_LIGHTSONLY: diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 2826236b2..6f6039c00 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -58,12 +58,6 @@ CVAR(Bool,gl_noskyboxes, false, 0) extern int skyfog; -enum -{ - NoSkyDraw = 89 -}; - - //========================================================================== // // Set up the skyinfo struct @@ -254,7 +248,7 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex { if (fs->GetTexture(sector_t::ceiling)==skyflatnum) { - if (bs->special == NoSkyDraw) return; + if (bs->special == GLSector_NoSkyDraw) return; if (bs->GetTexture(sector_t::ceiling)==skyflatnum) { // if the back sector is closed the sky must be drawn! @@ -344,7 +338,7 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver { if (fs->GetTexture(sector_t::floor)==skyflatnum) { - if (bs->special == NoSkyDraw) return; + if (bs->special == GLSector_NoSkyDraw) return; FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::bottom)); // For lower skies the normal logic only applies to walls with no lower texture! diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 8bd39b372..890ba980d 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -23,6 +23,11 @@ struct FPortal; struct FFlatVertex; struct FGLLinePortal; +enum +{ + GLSector_NoSkyDraw = 89, + GLSector_Skybox = 90, +}; enum WallTypes { @@ -290,6 +295,7 @@ public: void SetupSubsectorLights(int pass, subsector_t * sub, int *dli = NULL); void DrawSubsector(subsector_t * sub); void DrawSubsectorLights(subsector_t * sub, int pass); + void DrawSkyboxSector(int pass, bool processlights); void DrawSubsectors(int pass, bool processlights, bool istrans); void ProcessLights(bool istrans); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 5d13a0720..8f91b59cd 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -583,7 +583,23 @@ void GLWall::CheckTexturePosition() if ((uplft.v == 0.f && uprgt.v == 0.f && lolft.v <= 1.f && lorgt.v <= 1.f) || (uplft.v >= 0.f && uprgt.v >= 0.f && lolft.v == 1.f && lorgt.v == 1.f)) { - flags|=GLT_CLAMPY; + flags |= GLT_CLAMPY; + } + + // Check if this is marked as a skybox and if so, do the same for x. + // This intentionally only tests the seg's frontsector. + if (seg->frontsector->special == GLSector_Skybox) + { + sub = (float)xs_FloorToInt(uplft.u); + uplft.u -= sub; + uprgt.u -= sub; + lolft.u -= sub; + lorgt.u -= sub; + if ((uplft.u == 0.f && lolft.u == 0.f && uprgt.u <= 1.f && lorgt.u <= 1.f) || + (uplft.u >= 0.f && lolft.u >= 0.f && uprgt.u == 1.f && lorgt.u == 1.f)) + { + flags |= GLT_CLAMPX; + } } } @@ -604,6 +620,7 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg, GLSeg glsave=glseg; float flh=ceilingrefheight-floorrefheight; int texpos; + BYTE savedflags = flags; switch (_type) { @@ -636,16 +653,17 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg, } else { - CheckTexturePosition(); - // Add this wall to the render list - sector_t * sec = sub? sub->sector : seg->frontsector; + CheckTexturePosition(); + + // Add this wall to the render list + sector_t * sec = sub ? sub->sector : seg->frontsector; if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(false); else SplitWall(sec, false); } - glseg=glsave; - flags&=~GLT_CLAMPY; + glseg = glsave; + flags = savedflags; } @@ -837,11 +855,11 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, } else { - flags&=~GLT_CLAMPX; + flags &= ~GLT_CLAMPX; } if (!wrap) { - flags|=GLT_CLAMPY; + flags |= GLT_CLAMPY; } } if (mirrory) @@ -1330,7 +1348,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) sector_t * segback; #ifdef _DEBUG - if (seg->linedef - lines == 904) + if (seg->linedef - lines < 4) { int a = 0; } From 95de1faa808b6036b380f8e5b1ff16ac466e5119 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Apr 2016 01:16:46 +0200 Subject: [PATCH 0488/1509] - fixed: The portal coverage builder initialized node_t::len differently than the polyobject splitter. This was creating quite a mess when loading savegames with both portals and polyobjects. --- src/gl/data/gl_portaldata.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 497216bc8..98e19c80e 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -187,7 +187,7 @@ struct FCoverageBuilder double PartitionDistance(FCoverageVertex *vt, node_t *node) { - return fabs(double(-node->dy) * (vt->x - node->x) + double(node->dx) * (vt->y - node->y)) / node->len; + return fabs(double(-node->dy) * (vt->x - node->x) + double(node->dx) * (vt->y - node->y)) / (node->len * 65536.); } //========================================================================== @@ -379,8 +379,9 @@ void gl_InitPortals() for(int i=0;idx; - double fdy = (double)no->dy; + // Must be converted because the len value is also needed for polyobjects. + double fdx = FIXED2DBL(no->dx); + double fdy = FIXED2DBL(no->dy); no->len = (float)sqrt(fdx * fdx + fdy * fdy); } From 0a35027f67e94c9237fc83eef9c030db33d39088 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Apr 2016 10:39:29 +0200 Subject: [PATCH 0489/1509] - fixed use of validcount for the GL renderer. This needs to be incremented more locally to the place where it is used, so that it is guaranteed that each viewpoint that needs to be rendered increases it. As a result the uses in the portal code could be removed. --- src/gl/scene/gl_portal.cpp | 9 --------- src/gl/scene/gl_scene.cpp | 1 + 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 74af305c3..50b7fc9bb 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -661,7 +661,6 @@ void GLSkyboxPortal::DrawContents() GLRenderer->mViewActor = origin; - validcount++; inskybox = true; GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); GLRenderer->SetViewArea(); @@ -755,9 +754,6 @@ void GLSectorStackPortal::DrawContents() ViewPos += origin->mDisplacement; GLRenderer->mViewActor = NULL; - - validcount++; - // avoid recursions! if (origin->plane != -1) instack[origin->plane]++; @@ -803,8 +799,6 @@ void GLPlaneMirrorPortal::DrawContents() PlaneMirrorMode = origin->fC() < 0 ? -1 : 1; r_showviewer = true; - validcount++; - PlaneMirrorFlag++; GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); ClearClipper(); @@ -916,8 +910,6 @@ void GLMirrorPortal::DrawContents() GLRenderer->mViewActor = NULL; r_showviewer = true; - validcount++; - MirrorFlag++; GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); @@ -1028,7 +1020,6 @@ void GLLineToLinePortal::DrawContents() } GLRenderer->mViewActor = NULL; - validcount++; GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); ClearClipper(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index acb8416a4..9c2f6505c 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -306,6 +306,7 @@ void FGLRenderer::CreateScene() gl_spriteindex=0; Bsp.Clock(); R_SetView(); + validcount++; // used for processing sidedefs only once by the renderer. gl_RenderBSPNode (nodes + numnodes - 1); Bsp.Unclock(); From 8a010ab871129712b9e9552c72ec090dbbaf56ab Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Apr 2016 11:58:26 +0200 Subject: [PATCH 0490/1509] =?UTF-8?q?-=20allow=2090=C2=B0=20rotations=20in?= =?UTF-8?q?=20skybox=20sectors.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gl/scene/gl_flats.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 2a5ef712e..bdb57813a 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -339,33 +339,37 @@ void GLFlat::DrawSkyboxSector(int pass, bool processlights) } float z = plane.plane.ZatPoint(0., 0.) + dz; + static float uvals[] = { 0, 0, 1, 1 }; + static float vvals[] = { 1, 0, 0, 1 }; + int rot = -xs_FloorToInt(plane.Angle / 90.f); + ptr->x = minx; ptr->z = z; ptr->y = miny; - ptr->u = 0; - ptr->v = 1; + ptr->u = uvals[rot & 3]; + ptr->v = vvals[rot & 3]; ptr++; ptr->x = minx; ptr->z = z; ptr->y = maxy; - ptr->u = 0; - ptr->v = 0; + ptr->u = uvals[(rot + 1) & 3]; + ptr->v = vvals[(rot + 1) & 3]; ptr++; ptr->x = maxx; ptr->z = z; ptr->y = maxy; - ptr->u = 1; - ptr->v = 0; + ptr->u = uvals[(rot + 2) & 3]; + ptr->v = vvals[(rot + 2) & 3]; ptr++; ptr->x = maxx; ptr->z = z; ptr->y = miny; - ptr->u = 1; - ptr->v = 1; + ptr->u = uvals[(rot + 3) & 3]; + ptr->v = vvals[(rot + 3) & 3]; ptr++; GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); From 59133a70093c6eeddd975bb3a6f39399fe79842a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Apr 2016 12:09:04 +0200 Subject: [PATCH 0491/1509] - fixed bad merge in p_saveg.cpp --- src/p_saveg.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 308a3a26a..e8703dde1 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -341,7 +341,7 @@ void P_SerializeWorld (FArchive &arc) { arc << sec->floorplane << sec->ceilingplane; - arc << sec->lightlevel; + arc << sec->lightlevel; arc << sec->special; arc << sec->soundtraversed << sec->seqType @@ -358,12 +358,12 @@ void P_SerializeWorld (FArchive &arc) << sec->heightsec << sec->bottommap << sec->midmap << sec->topmap << sec->gravity; - P_SerializeTerrain(arc, sec->terrainnum[0]); - P_SerializeTerrain(arc, sec->terrainnum[1]); - arc << sec->damageamount; - arc << sec->damageinterval - << sec->leakydamage - << sec->damagetype; + P_SerializeTerrain(arc, sec->terrainnum[0]); + P_SerializeTerrain(arc, sec->terrainnum[1]); + arc << sec->damageamount; + arc << sec->damageinterval + << sec->leakydamage + << sec->damagetype; arc << sec->SoundTarget << sec->SecActTarget << sec->sky @@ -417,10 +417,7 @@ void P_SerializeWorld (FArchive &arc) arc << li->args[1] << li->args[2] << li->args[3] << li->args[4]; arc << li->portalindex; - if (SaveVersion >= 4531) - { - arc << li->skybox; - } + arc << li->skybox; // GZDoom addition. for (j = 0; j < 2; j++) { @@ -457,7 +454,7 @@ void P_SerializeWorld (FArchive &arc) arc << zn->Environment; } - arc << linePortals; + arc << linePortals; P_CollectLinkedPortals(); } From faeb0303fe5c0cf148a2fc0d448016d733029683 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Apr 2016 13:53:29 +0200 Subject: [PATCH 0492/1509] - renamed ADynamicLight's intensity properties to radius, to have their name match their meaning. --- src/gl/dynlights/a_dynlight.cpp | 40 ++++++++++++++++---------------- src/gl/dynlights/gl_dynlight.cpp | 4 ++-- src/gl/dynlights/gl_dynlight.h | 7 +++--- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 7cb6e91d9..032551e4f 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -101,7 +101,7 @@ void AVavoomLight::BeginPlay () void AVavoomLightWhite::BeginPlay () { - m_intensity[0] = args[0] * 4; + m_Radius[0] = args[0] * 4; args[LIGHT_RED] = 128; args[LIGHT_GREEN] = 128; args[LIGHT_BLUE] = 128; @@ -114,7 +114,7 @@ void AVavoomLightColor::BeginPlay () int l_args[5]; memcpy(l_args, args, sizeof(l_args)); memset(args, 0, sizeof(args)); - m_intensity[0] = l_args[0] * 4; + m_Radius[0] = l_args[0] * 4; args[LIGHT_RED] = l_args[1] >> 1; args[LIGHT_GREEN] = l_args[2] >> 1; args[LIGHT_BLUE] = l_args[3] >> 1; @@ -139,8 +139,8 @@ void ADynamicLight::Serialize(FArchive &arc) { Super::Serialize (arc); arc << lightflags << lighttype; - arc << m_tickCount << m_currentIntensity; - arc << m_intensity[0] << m_intensity[1]; + arc << m_tickCount << m_currentRadius; + arc << m_Radius[0] << m_Radius[1]; if (lighttype == PulseLight) arc << m_lastUpdate << m_cycler; if (arc.IsLoading()) LinkLight(); @@ -158,8 +158,8 @@ void ADynamicLight::BeginPlay() //Super::BeginPlay(); ChangeStatNum(STAT_DLIGHT); - m_intensity[0] = args[LIGHT_INTENSITY]; - m_intensity[1] = args[LIGHT_SECONDARY_INTENSITY]; + m_Radius[0] = args[LIGHT_INTENSITY]; + m_Radius[1] = args[LIGHT_SECONDARY_INTENSITY]; } //========================================================================== @@ -190,7 +190,7 @@ void ADynamicLight::Activate(AActor *activator) //Super::Activate(activator); flags2&=~MF2_DORMANT; - m_currentIntensity = float(m_intensity[0]); + m_currentRadius = float(m_Radius[0]); m_tickCount = 0; if (lighttype == PulseLight) @@ -198,10 +198,10 @@ void ADynamicLight::Activate(AActor *activator) float pulseTime = Angles.Yaw.Degrees / TICRATE; m_lastUpdate = level.maptime; - m_cycler.SetParams(float(m_intensity[1]), float(m_intensity[0]), pulseTime); + m_cycler.SetParams(float(m_Radius[1]), float(m_Radius[0]), pulseTime); m_cycler.ShouldCycle(true); m_cycler.SetCycleType(CYCLE_Sin); - m_currentIntensity = (BYTE)m_cycler.GetVal(); + m_currentRadius = (BYTE)m_cycler.GetVal(); } } @@ -252,7 +252,7 @@ void ADynamicLight::Tick() m_lastUpdate = level.maptime; m_cycler.Update(diff); - m_currentIntensity = m_cycler.GetVal(); + m_currentRadius = m_cycler.GetVal(); break; } @@ -261,20 +261,20 @@ void ADynamicLight::Tick() BYTE rnd = randLight(); float pct = Angles.Yaw.Degrees / 360.f; - m_currentIntensity = float(m_intensity[rnd >= pct * 255]); + m_currentRadius = float(m_Radius[rnd >= pct * 255]); break; } case RandomFlickerLight: { - int flickerRange = m_intensity[1] - m_intensity[0]; + int flickerRange = m_Radius[1] - m_Radius[0]; float amt = randLight() / 255.f; m_tickCount++; if (m_tickCount > Angles.Yaw.Degrees) { - m_currentIntensity = float(m_intensity[0] + (amt * flickerRange)); + m_currentRadius = float(m_Radius[0] + (amt * flickerRange)); m_tickCount = 0; } break; @@ -287,20 +287,20 @@ void ADynamicLight::Tick() BYTE rnd = randLight(); float pct = Angles.Yaw.Degrees/360.f; - m_currentIntensity = m_intensity[rnd >= pct * 255]; + m_currentRadius = m_Radius[rnd >= pct * 255]; break; } case RandomColorFlickerLight: { - int flickerRange = m_intensity[1] - m_intensity[0]; + int flickerRange = m_Radius[1] - m_Radius[0]; float amt = randLight() / 255.f; m_tickCount++; if (m_tickCount > Angles.Yaw.Degrees) { - m_currentIntensity = m_intensity[0] + (amt * flickerRange); + m_currentRadius = m_Radius[0] + (amt * flickerRange); m_tickCount = 0; } break; @@ -317,12 +317,12 @@ void ADynamicLight::Tick() intensity = Sector->lightlevel * scale; intensity = clamp(intensity, 0.f, 255.f); - m_currentIntensity = intensity; + m_currentRadius = intensity; break; } case PointLight: - m_currentIntensity = float(m_intensity[0]); + m_currentRadius = float(m_Radius[0]); break; } @@ -365,11 +365,11 @@ void ADynamicLight::UpdateLocation() if (lighttype == FlickerLight || lighttype == RandomFlickerLight || lighttype == PulseLight) { - intensity = float(MAX(m_intensity[0], m_intensity[1])); + intensity = float(MAX(m_Radius[0], m_Radius[1])); } else { - intensity = m_currentIntensity; + intensity = m_currentRadius; } radius = intensity * 2.0f * gl_lights_size; diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index d51c4315b..e7d876b2a 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -176,8 +176,8 @@ void FLightDefaults::ApplyProperties(ADynamicLight * light) const light->SetOffset(m_Pos); light->halo = m_halo; for (int a = 0; a < 3; a++) light->args[a] = clamp((int)(m_Args[a] * gl_lights_intensity), 0, 255); - light->m_intensity[0] = int(m_Args[LIGHT_INTENSITY]); - light->m_intensity[1] = int(m_Args[LIGHT_SECONDARY_INTENSITY]); + light->m_Radius[0] = int(m_Args[LIGHT_INTENSITY]); + light->m_Radius[1] = int(m_Args[LIGHT_SECONDARY_INTENSITY]); light->flags4 &= ~(MF4_ADDITIVE | MF4_SUBTRACTIVE | MF4_DONTLIGHTSELF); if (m_subtractive) light->flags4 |= MF4_SUBTRACTIVE; if (m_additive) light->flags4 |= MF4_ADDITIVE; diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index 12ec600cd..5759d4cb8 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -75,8 +75,7 @@ public: BYTE GetRed() const { return args[LIGHT_RED]; } BYTE GetGreen() const { return args[LIGHT_GREEN]; } BYTE GetBlue() const { return args[LIGHT_BLUE]; } - float GetIntensity() const { return m_currentIntensity; } - float GetRadius() const { return (IsActive() ? GetIntensity() * 2.f : 0.f); } + float GetRadius() const { return (IsActive() ? m_currentRadius * 2.f : 0.f); } void LinkLight(); void UnlinkLight(); size_t PointerSubstitution (DObject *old, DObject *notOld); @@ -104,14 +103,14 @@ private: protected: DVector3 m_off; - float m_currentIntensity; + float m_currentRadius; int m_tickCount; unsigned int m_lastUpdate; FCycler m_cycler; subsector_t * subsector; public: - int m_intensity[2]; + int m_Radius[2]; BYTE lightflags; BYTE lighttype; bool owned; From 0d7bd368face5f2eaac658c89b12ff05b223a248 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Apr 2016 15:46:04 +0200 Subject: [PATCH 0493/1509] - added some fudging to draw the outer linedefs of a portal area. This is needed so that polyportals get rendered correctly. For non-polyportals these will normally be outside the portal window and just be discarded. --- src/gl/scene/gl_bsp.cpp | 58 +++++++++++++++++++++++++++++++++------- src/gl/scene/gl_portal.h | 4 ++- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index a32b8aaa0..bb7cbce4e 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -95,7 +95,7 @@ static void UnclipSubsector(subsector_t *sub) static subsector_t *currentsubsector; static sector_t *currentsector; -static void AddLine (seg_t *seg) +static void AddLine (seg_t *seg, bool portalclip) { #ifdef _DEBUG if (seg->linedef - lines == 38) @@ -108,7 +108,7 @@ static void AddLine (seg_t *seg) sector_t * backsector = NULL; sector_t bs; - if (GLRenderer->mCurrentPortal) + if (portalclip) { int clipres = GLRenderer->mCurrentPortal->ClipSeg(seg); if (clipres == GLPortal::PClip_InFront) return; @@ -215,7 +215,7 @@ static void PolySubsector(subsector_t * sub) { if (line->linedef) { - AddLine (line); + AddLine (line, GLRenderer->mCurrentPortal != NULL); } line++; } @@ -310,11 +310,11 @@ static inline void AddLines(subsector_t * sub, sector_t * sector) { if (seg->linedef == NULL) { - if (!(sub->flags & SSECF_DRAWN)) AddLine (seg); + if (!(sub->flags & SSECF_DRAWN)) AddLine (seg, GLRenderer->mCurrentPortal != NULL); } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) { - AddLine (seg); + AddLine (seg, GLRenderer->mCurrentPortal != NULL); } seg++; } @@ -322,6 +322,40 @@ static inline void AddLines(subsector_t * sub, sector_t * sector) ClipWall.Unclock(); } +//========================================================================== +// +// Adds lines that lie directly on the portal boundary. +// Only two-sided lines will be handled here, and no polyobjects +// +//========================================================================== + +inline bool PointOnLine(const DVector2 &pos, const line_t *line) +{ + double v = (pos.Y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - pos.X) * line->Delta().Y; + return fabs(v) <= EQUAL_EPSILON; +} + +static inline void AddSpecialPortalLines(subsector_t * sub, sector_t * sector, line_t *line) +{ + currentsector = sector; + currentsubsector = sub; + + ClipWall.Clock(); + int count = sub->numlines; + seg_t * seg = sub->firstline; + + while (count--) + { + if (seg->linedef != NULL && seg->PartnerSeg != NULL) + { + if (PointOnLine(seg->v1->fPos(), line) && PointOnLine(seg->v2->fPos(), line)) + AddLine(seg, false); + } + seg++; + } + ClipWall.Unclock(); +} + //========================================================================== // @@ -395,16 +429,20 @@ static void DoSubsector(subsector_t * sub) UnclipSubsector(sub); } + fakesector=gl_FakeFlat(sector, &fake, false); + if (GLRenderer->mCurrentPortal) { int clipres = GLRenderer->mCurrentPortal->ClipSubsector(sub); - if (clipres == GLPortal::PClip_InFront) return; + if (clipres == GLPortal::PClip_InFront) + { + line_t *line = GLRenderer->mCurrentPortal->ClipLine(); + // The subsector is out of range, but we still have to check lines that lie directly on the boundary and may expose their upper or lower parts. + if (line) AddSpecialPortalLines(sub, fakesector, line); + return; + } } - - - fakesector=gl_FakeFlat(sector, &fake, false); - if (sector->validcount != validcount) { GLRenderer->mVBO->CheckUpdate(sector); diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index d8c5da619..f62db377d 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -137,7 +137,7 @@ public: { PClip_InFront, PClip_Inside, - PClip_Behind + PClip_Behind, }; void RenderPortal(bool usestencil, bool doquery) @@ -165,6 +165,7 @@ public: virtual int ClipSeg(seg_t *seg) { return PClip_Inside; } virtual int ClipSubsector(subsector_t *sub) { return PClip_Inside; } virtual int ClipPoint(const DVector2 &pos) { return PClip_Inside; } + virtual line_t *ClipLine() { return NULL; } static void BeginScene(); static void StartFrame(); @@ -251,6 +252,7 @@ protected: virtual void DrawContents(); virtual void * GetSource() const { return glport; } virtual const char *GetName(); + virtual line_t *ClipLine() { return line(); } public: From a90bef9c68deaaff994ed32939da336d80f85cde Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Apr 2016 10:38:27 +0200 Subject: [PATCH 0494/1509] - 64 bit doesn't require NO_ASM. --- src/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bfaa0d7fd..dd85479c6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -225,10 +225,6 @@ else() endif() endif() -if( X64 ) - set( NO_ASM ON ) -endif( X64 ) - # Check if we have OpenGL if( NOT OPENGL_FOUND ) From 741f0546015f938836fd2aa2fa182ae7911e7123 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Apr 2016 16:27:04 +0200 Subject: [PATCH 0495/1509] - clip sprites to linked sector portal planes. This is the first part of properly handling those transitions. --- src/gl/scene/gl_sprite.cpp | 59 +++++++++++++++++++++----------------- src/gl/scene/gl_wall.h | 5 +++- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 923cb819f..9269734b4 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -107,6 +107,8 @@ void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblend CVAR(Bool, gl_nolayer, false, 0) +static const float LARGE_VALUE = 1e19f; + //========================================================================== // // @@ -218,30 +220,25 @@ void GLSprite::Draw(int pass) //gl_SetColor(lightlevel, rel, Colormap, trans); - unsigned int iter; - - if (lightlist) + unsigned int iter = lightlist? lightlist->Size() : 1; + bool clipping = false; + if (lightlist || topclip != LARGE_VALUE || bottomclip != -LARGE_VALUE) { - iter = lightlist->Size(); + clipping = true; gl_RenderState.EnableSplit(true); glEnable(GL_CLIP_DISTANCE3); glEnable(GL_CLIP_DISTANCE4); } - else - { - iter = 1; - } + secplane_t bottomp = { { 0, 0, -1. }, bottomclip }; + secplane_t topp = { { 0, 0, -1. }, topclip }; for (unsigned i = 0; i < iter; i++) { if (lightlist) { // set up the light slice - static secplane_t bottommost = { {0, 0, 1.}, FLT_MAX }; - static secplane_t topmost = { { 0, 0, 1. }, -FLT_MAX }; - - secplane_t *topplane = i == 0 ? &topmost : &(*lightlist)[i].plane; - secplane_t *lowplane = i == (*lightlist).Size() - 1 ? &bottommost : &(*lightlist)[i + 1].plane; + secplane_t *topplane = i == 0 ? &topp : &(*lightlist)[i].plane; + secplane_t *lowplane = i == (*lightlist).Size() - 1 ? &bottomp : &(*lightlist)[i + 1].plane; int thisll = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel; FColormap thiscm; @@ -255,6 +252,10 @@ void GLSprite::Draw(int pass) gl_SetColor(thisll, rel, thiscm, trans); gl_RenderState.SetSplitPlanes(*topplane, *lowplane); } + else if (clipping) + { + gl_RenderState.SetSplitPlanes(topp, bottomp); + } if (!modelframe) { @@ -330,7 +331,7 @@ void GLSprite::Draw(int pass) } } - if (lightlist) + if (clipping) { glDisable(GL_CLIP_DISTANCE3); glDisable(GL_CLIP_DISTANCE4); @@ -476,12 +477,12 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingp // //========================================================================== -void GLSprite::Process(AActor* thing,sector_t * sector) +void GLSprite::Process(AActor* thing, sector_t * sector, bool thruportal) { sector_t rs; sector_t * rendersector; // don't draw the thing that's used as camera (for viewshifts during quakes!) - if (thing==GLRenderer->mViewActor || (thing == players[consoleplayer].camera && !r_showviewer)) return; + if (thing == GLRenderer->mViewActor || (thing == players[consoleplayer].camera && !r_showviewer)) return; // Don't waste time projecting sprites that are definitely not visible. if (thing == NULL || thing->sprite == 0 || !thing->IsVisibleToPlayer()) @@ -496,14 +497,14 @@ void GLSprite::Process(AActor* thing,sector_t * sector) P_CheckPlayerSprite(thing, spritenum, sprscale); } - if (thing->renderflags & RF_INVISIBLE || !thing->RenderStyle.IsVisible(thing->Alpha)) + if (thing->renderflags & RF_INVISIBLE || !thing->RenderStyle.IsVisible(thing->Alpha)) { if (!(thing->flags & MF_STEALTH) || !gl_fixedcolormap || !gl_enhanced_nightvision) - return; + return; } // If this thing is in a map section that's not in view it can't possibly be visible - if (!(currentmapsection[thing->subsector->mapsection>>3] & (1 << (thing->subsector->mapsection & 7)))) return; + if (!(currentmapsection[thing->subsector->mapsection >> 3] & (1 << (thing->subsector->mapsection & 7)))) return; // [RH] Interpolate the sprite's position to make it look smooth DVector3 thingpos = thing->InterpolatedPosition(r_TicFracF); @@ -527,10 +528,10 @@ void GLSprite::Process(AActor* thing,sector_t * sector) // don't draw first frame of a player missile if (thing->flags&MF_MISSILE) { - if (!(thing->flags7 & MF7_FLYCHEAT) && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) + if (!(thing->flags7 & MF7_FLYCHEAT) && thing->target == GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) { - double clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius*2); - if ((thingpos-ViewPos).LengthSquared() < clipdist * clipdist) return; + double clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius * 2); + if ((thingpos - ViewPos).LengthSquared() < clipdist * clipdist) return; } thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again. } @@ -541,18 +542,20 @@ void GLSprite::Process(AActor* thing,sector_t * sector) if (clipres == GLPortal::PClip_InFront) return; } - player_t *player=&players[consoleplayer]; + player_t *player = &players[consoleplayer]; FloatRect r; - if (sector->sectornum!=thing->Sector->sectornum) + if (sector->sectornum != thing->Sector->sectornum && !thruportal) { - rendersector=gl_FakeFlat(thing->Sector, &rs, false); + rendersector = gl_FakeFlat(thing->Sector, &rs, false); } else { - rendersector=sector; + rendersector = sector; } - + topclip = rendersector->PortalBlocksMovement(sector_t::ceiling) ? LARGE_VALUE : rendersector->SkyBoxes[sector_t::ceiling]->specialf1; + bottomclip = rendersector->PortalBlocksMovement(sector_t::floor) ? -LARGE_VALUE : rendersector->SkyBoxes[sector_t::floor]->specialf1; + x = thingpos.X; z = thingpos.Z - thing->Floorclip; @@ -892,6 +895,8 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s modelframe=NULL; gltexture=NULL; + topclip = LARGE_VALUE; + bottomclip = -LARGE_VALUE; // [BB] Load the texture for round or smooth particles if (gl_particles_style) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 890ba980d..637737971 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -334,6 +334,9 @@ public: int index; int depth; + float topclip; + float bottomclip; + float x,y,z; // needed for sorting! float ul,ur; @@ -354,7 +357,7 @@ public: void Draw(int pass); void PutSprite(bool translucent); - void Process(AActor* thing,sector_t * sector); + void Process(AActor* thing,sector_t * sector, bool thruportal = false); void ProcessParticle (particle_t *particle, sector_t *sector);//, int shade, int fakeside) void SetThingColor(PalEntry); From 573d80f144c2913a6f99f0f0258500713e8ce5ba Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Apr 2016 23:52:15 +0200 Subject: [PATCH 0496/1509] - render sproites through sector portals. --- src/gl/renderer/gl_renderer.cpp | 4 ++-- src/gl/renderer/gl_renderer.h | 2 +- src/gl/scene/gl_bsp.cpp | 39 ++++++++++++++++++++++----------- src/gl/scene/gl_sprite.cpp | 3 ++- src/p_trace.cpp | 4 ++++ 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 0fa34845e..66b68c2c3 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -170,10 +170,10 @@ void FGLRenderer::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector // //=========================================================================== -void FGLRenderer::ProcessSprite(AActor *thing, sector_t *sector) +void FGLRenderer::ProcessSprite(AActor *thing, sector_t *sector, bool thruportal) { GLSprite glsprite; - glsprite.Process(thing, sector); + glsprite.Process(thing, sector, thruportal); } //=========================================================================== diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 2a3763551..a2f4c7d34 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -118,7 +118,7 @@ public: void Clear(int left, int top, int right, int bottom, int palcolor, uint32 color); void ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector); - void ProcessSprite(AActor *thing, sector_t *sector); + void ProcessSprite(AActor *thing, sector_t *sector, bool thruportal); void ProcessParticle(particle_t *part, sector_t *sector); void ProcessSector(sector_t *fakesector); void FlushTextures(); diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index bb7cbce4e..ca7eaf849 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -368,24 +368,37 @@ static inline void RenderThings(subsector_t * sub, sector_t * sector) SetupSprite.Clock(); sector_t * sec=sub->sector; - if (sec->thinglist != NULL) + // Handle all things in sector. + for (AActor * thing = sec->thinglist; thing; thing = thing->snext) { - // Handle all things in sector. - for (AActor * thing = sec->thinglist; thing; thing = thing->snext) + FIntCVar *cvar = thing->GetClass()->distancecheck; + if (cvar != NULL && *cvar >= 0) { - FIntCVar *cvar = thing->GetClass()->distancecheck; - if (cvar != NULL && *cvar >= 0) + double dist = (thing->Pos() - ViewPos).LengthSquared(); + double check = (double)**cvar; + if (dist >= check * check) { - double dist = (thing->Pos() - ViewPos).LengthSquared(); - double check = (double)**cvar; - if (dist >= check * check) - { - continue; - } + continue; } - - GLRenderer->ProcessSprite(thing, sector); } + + GLRenderer->ProcessSprite(thing, sector, false); + } + for (msecnode_t *node = sec->render_thinglist; node; node = node->m_snext) + { + AActor *thing = node->m_thing; + FIntCVar *cvar = thing->GetClass()->distancecheck; + if (cvar != NULL && *cvar >= 0) + { + double dist = (thing->Pos() - ViewPos).LengthSquared(); + double check = (double)**cvar; + if (dist >= check * check) + { + continue; + } + } + + GLRenderer->ProcessSprite(thing, sector, true); } SetupSprite.Unclock(); } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 9269734b4..4b797f71f 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -504,10 +504,11 @@ void GLSprite::Process(AActor* thing, sector_t * sector, bool thruportal) } // If this thing is in a map section that's not in view it can't possibly be visible - if (!(currentmapsection[thing->subsector->mapsection >> 3] & (1 << (thing->subsector->mapsection & 7)))) return; + if (!thruportal && !(currentmapsection[thing->subsector->mapsection >> 3] & (1 << (thing->subsector->mapsection & 7)))) return; // [RH] Interpolate the sprite's position to make it look smooth DVector3 thingpos = thing->InterpolatedPosition(r_TicFracF); + if (thruportal) thingpos += Displacements.getOffset(thing->Sector->PortalGroup, sector->PortalGroup); // Too close to the camera. This doesn't look good if it is a sprite. if (fabs(thingpos.X - ViewPos.X) < 2 && fabs(thingpos.Y - ViewPos.Y) < 2) diff --git a/src/p_trace.cpp b/src/p_trace.cpp index 0e11e29a6..db78fa5e2 100644 --- a/src/p_trace.cpp +++ b/src/p_trace.cpp @@ -308,6 +308,7 @@ void FTraceInfo::Setup3DFloors() { Results->Crossed3DWater = rover; Results->Crossed3DWaterPos = Results->HitPos; + Results->Distance = 0; } } @@ -444,6 +445,7 @@ bool FTraceInfo::LineCheck(intercept_t *in, double dist, DVector3 hit) { Results->CrossedWater = §ors[CurSector->sectornum]; Results->CrossedWaterPos = Results->HitPos; + Results->Distance = 0; } } @@ -747,6 +749,7 @@ bool FTraceInfo::TraceTraverse (int ptflags) { Results->Crossed3DWater = rover; Results->Crossed3DWaterPos = Results->HitPos; + Results->Distance = 0; } } } @@ -835,6 +838,7 @@ bool FTraceInfo::TraceTraverse (int ptflags) { Results->CrossedWater = §ors[CurSector->sectornum]; Results->CrossedWaterPos = Results->HitPos; + Results->Distance = 0; } Results = res; } From d667f8f23fe90b499bacc5a6983c849af9086643 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 19 Apr 2016 09:58:08 +0200 Subject: [PATCH 0497/1509] - some British English. --- wadsrc/static/language.eng | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wadsrc/static/language.eng b/wadsrc/static/language.eng index ca27bf80a..bf0a0a91d 100644 --- a/wadsrc/static/language.eng +++ b/wadsrc/static/language.eng @@ -108,3 +108,5 @@ CMPTMNU_SECTORSOUNDS = "Sector sounds use centre as source"; OPTVAL_MAPDEFINEDCOLORSONLY = "Map defined colours only"; C_GRAY = "\ccgrey"; C_DARKGRAY = "\cudark grey"; + +OPTVAL_ANYFIXEDCOLORMAP = "Any fixed colourmap"; From 1f32f5a2582e167faa3723d784f323bd47886b1e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 20 Apr 2016 11:39:41 +0200 Subject: [PATCH 0498/1509] - some minor fixing and cleanup on gL portal code. --- src/gl/data/gl_data.h | 4 ++-- src/gl/data/gl_portaldata.cpp | 31 ++++++++++++++----------------- src/gl/dynlights/a_dynlight.cpp | 15 +++++++-------- src/gl/scene/gl_bsp.cpp | 10 +++++----- src/gl/scene/gl_fakeflat.cpp | 8 ++++---- src/gl/scene/gl_portal.cpp | 23 ++++++++++++----------- src/gl/scene/gl_renderhacks.cpp | 18 ++++++++---------- src/gl/scene/gl_sky.cpp | 24 ++++++++++++++++-------- src/gl/scene/gl_sprite.cpp | 4 ++-- src/gl/scene/gl_walls.cpp | 2 +- src/r_defs.h | 4 +++- 11 files changed, 74 insertions(+), 69 deletions(-) diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index c8067b3ba..1e93f9a28 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -51,7 +51,7 @@ struct FPortal int plane; GLSectorStackPortal *glportal; // for quick access to the render data. This is only valid during BSP traversal! - GLSectorStackPortal *GetGLPortal(); + GLSectorStackPortal *GetRenderState(); }; struct FGLLinePortal @@ -68,7 +68,7 @@ extern TArray linePortalToGL; extern TArray currentmapsection; void gl_InitPortals(); -void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, FPortal *portal); +void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, const DVector2 &displacement); void gl_InitData(); extern long gl_frameMS; diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 98e19c80e..413c85dc6 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -94,7 +94,7 @@ TArray glLinePortals; // //========================================================================== -GLSectorStackPortal *FPortal::GetGLPortal() +GLSectorStackPortal *FPortal::GetRenderState() { if (glportal == NULL) glportal = new GLSectorStackPortal(this); return glportal; @@ -125,7 +125,6 @@ struct FCoverageLine struct FCoverageBuilder { subsector_t *target; - FPortal *portal; TArray collect; FCoverageVertex center; @@ -135,10 +134,9 @@ struct FCoverageBuilder // //========================================================================== - FCoverageBuilder(subsector_t *sub, FPortal *port) + FCoverageBuilder(subsector_t *sub) { target = sub; - portal = port; } //========================================================================== @@ -322,7 +320,7 @@ struct FCoverageBuilder // //========================================================================== -void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, FPortal *portal) +void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, const DVector2 &displacement) { TArray shape; double centerx=0, centery=0; @@ -330,11 +328,11 @@ void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, F shape.Resize(subsector->numlines); for(unsigned i=0; inumlines; i++) { - centerx += (shape[i].x = FLOAT2FIXED(subsector->firstline[i].v1->fX() + portal->mDisplacement.X)); - centery += (shape[i].y = FLOAT2FIXED(subsector->firstline[i].v1->fY() + portal->mDisplacement.Y)); + centerx += (shape[i].x = FLOAT2FIXED(subsector->firstline[i].v1->fX() + displacement.X)); + centery += (shape[i].y = FLOAT2FIXED(subsector->firstline[i].v1->fY() + displacement.Y)); } - FCoverageBuilder build(subsector, portal); + FCoverageBuilder build(subsector); build.center.x = xs_CRoundToInt(centerx / subsector->numlines); build.center.y = xs_CRoundToInt(centery / subsector->numlines); @@ -357,10 +355,10 @@ static void CollectPortalSectors(FPortalMap &collection) sector_t *sec = §ors[i]; for (int j = 0; j < 2; j++) { - ASkyViewpoint *SkyBox = barrier_cast(sec->SkyBoxes[j]); - if (SkyBox != NULL && SkyBox->bAlways && SkyBox->Mate != NULL) + int ptype = sec->GetPortalType(j); + if (ptype== SKYBOX_STACKEDSECTORTHING || ptype == SKYBOX_PORTAL || ptype == SKYBOX_LINKEDPORTAL) // only offset-displacing portal types { - FPortalID id = { {SkyBox->X() - SkyBox->Mate->X(), SkyBox->Y() - SkyBox->Mate->Y()} }; + FPortalID id = { sec->GetPortalDisplacement(j) }; FPortalSectors &sss = collection[id]; FPortalSector ss = { sec, j }; @@ -401,8 +399,7 @@ void gl_InitPortals() } for (int i=1;i<=2;i<<=1) { - // For now, add separate portals for floor and ceiling. They can be merged once - // proper plane clipping is in. + // add separate portals for floor and ceiling. if (planeflags & i) { FPortal *portal = new FPortal; @@ -419,7 +416,7 @@ void gl_InitPortals() for(int k=0;ksubsectorcount; k++) { subsector_t *sub = sec->subsectors[k]; - gl_BuildPortalCoverage(&sub->portalcoverage[plane], sub, portal); + gl_BuildPortalCoverage(&sub->portalcoverage[plane], sub, pair->Key.mDisplacement); } sec->portals[plane] = portal; } @@ -511,13 +508,13 @@ CCMD(dumpportals) for(int j=0;jrender_sector->portals[portals[i]->plane]; + FPortal *port = sub->render_sector->GetGLPortal(portals[i]->plane); if (port == portals[i]) { Printf(PRINT_LOG, "\tSubsector %d (%d):\n\t\t", j, sub->render_sector->sectornum); for(unsigned k = 0;k< sub->numlines; k++) { - Printf(PRINT_LOG, "(%.3f,%.3f), ", sub->firstline[k].v1->fixX()/65536. + xdisp, sub->firstline[k].v1->fixY()/65536. + ydisp); + Printf(PRINT_LOG, "(%.3f,%.3f), ", sub->firstline[k].v1->fX() + xdisp, sub->firstline[k].v1->fY() + ydisp); } Printf(PRINT_LOG, "\n\t\tCovered by subsectors:\n"); FPortalCoverage *cov = &sub->portalcoverage[portals[i]->plane]; @@ -527,7 +524,7 @@ CCMD(dumpportals) Printf(PRINT_LOG, "\t\t\t%5d (%4d): ", cov->subsectors[l], csub->render_sector->sectornum); for(unsigned m = 0;m< csub->numlines; m++) { - Printf(PRINT_LOG, "(%.3f,%.3f), ", csub->firstline[m].v1->fixX()/65536., csub->firstline[m].v1->fixY()/65536.); + Printf(PRINT_LOG, "(%.3f,%.3f), ", csub->firstline[m].v1->fX(), csub->firstline[m].v1->fY()); } Printf(PRINT_LOG, "\n"); } diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 032551e4f..36382ce36 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -591,24 +591,23 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &pos, subsector_t *subSec } } } - if (!subSec->sector->PortalBlocksSight(sector_t::ceiling)) + sector_t *sec = subSec->sector; + if (!sec->PortalBlocksSight(sector_t::ceiling)) { line_t *other = subSec->firstline->linedef; - AActor *sb = subSec->sector->SkyBoxes[sector_t::ceiling]; - if (sb->specialf1 < Z() + radius) + if (sec->GetPortalPlaneZ(sector_t::ceiling) < Z() + radius) { - DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sb->Scale; + DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sec->GetPortalDisplacement(sector_t::ceiling); subsector_t *othersub = R_PointInSubsector(refpos); if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius); } } - if (!subSec->sector->PortalBlocksSight(sector_t::floor)) + if (!sec->PortalBlocksSight(sector_t::floor)) { line_t *other = subSec->firstline->linedef; - AActor *sb = subSec->sector->SkyBoxes[sector_t::floor]; - if (sb->specialf1 > Z() - radius) + if (sec->GetPortalPlaneZ(sector_t::floor) > Z() - radius) { - DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sb->Scale; + DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sec->GetPortalDisplacement(sector_t::floor); subsector_t *othersub = R_PointInSubsector(refpos); if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius); } diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index ca7eaf849..4377f68f1 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -494,7 +494,7 @@ static void DoSubsector(subsector_t * sub) if (gl_render_flats) { - // Subsectors with only 2 lines cannot have any area! + // Subsectors with only 2 lines cannot have any area if (sub->numlines>2 || (sub->hacked&1)) { // Exclude the case when it tries to render a sector with a heightsec @@ -527,17 +527,17 @@ static void DoSubsector(subsector_t * sub) FPortal *portal; - portal = fakesector->portals[sector_t::ceiling]; + portal = fakesector->GetGLPortal(sector_t::ceiling); if (portal != NULL) { - GLSectorStackPortal *glportal = portal->GetGLPortal(); + GLSectorStackPortal *glportal = portal->GetRenderState(); glportal->AddSubsector(sub); } - portal = fakesector->portals[sector_t::floor]; + portal = fakesector->GetGLPortal(sector_t::floor); if (portal != NULL) { - GLSectorStackPortal *glportal = portal->GetGLPortal(); + GLSectorStackPortal *glportal = portal->GetRenderState(); glportal->AddSubsector(sub); } } diff --git a/src/gl/scene/gl_fakeflat.cpp b/src/gl/scene/gl_fakeflat.cpp index 29f2f52a3..70ac86ec7 100644 --- a/src/gl/scene/gl_fakeflat.cpp +++ b/src/gl/scene/gl_fakeflat.cpp @@ -212,8 +212,8 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac dest->ceilingplane=sec->floorplane; dest->ceilingplane.FlipVert(); dest->planes[sector_t::ceiling].TexZ = dest->planes[sector_t::floor].TexZ; - dest->portals[sector_t::ceiling] = NULL; - dest->portals[sector_t::floor] = NULL; + dest->ClearPortal(sector_t::ceiling); + dest->ClearPortal(sector_t::floor); return dest; } } @@ -314,7 +314,7 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::vbo_fakefloor]; dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::floor]; - dest->portals[sector_t::ceiling] = NULL; + dest->ClearPortal(sector_t::ceiling); if (!(s->MoreFlags & SECF_NOFAKELIGHT)) { @@ -367,7 +367,7 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::ceiling]; dest->vboheight[sector_t::ceiling] = sec->vboheight[sector_t::ceiling]; - dest->portals[sector_t::floor] = NULL; + dest->ClearPortal(sector_t::floor); if (!(s->MoreFlags & SECF_NOFAKELIGHT)) { diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 50b7fc9bb..3c2c661be 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -1180,20 +1180,21 @@ void GLHorizonPortal::DrawContents() void GLEEHorizonPortal::DrawContents() { PortalAll.Clock(); - if (origin->Sector->GetTexture(sector_t::floor) == skyflatnum || - origin->Sector->GetTexture(sector_t::ceiling) == skyflatnum) + sector_t *sector = origin->Sector; + if (sector->GetTexture(sector_t::floor) == skyflatnum || + sector->GetTexture(sector_t::ceiling) == skyflatnum) { GLSkyInfo skyinfo; - skyinfo.init(origin->Sector->sky, 0); + skyinfo.init(sector->sky, 0); GLSkyPortal sky(&skyinfo, true); sky.DrawContents(); } - if (origin->Sector->GetTexture(sector_t::ceiling) != skyflatnum) + if (sector->GetTexture(sector_t::ceiling) != skyflatnum) { GLHorizonInfo horz; - horz.plane.GetFromSector(origin->Sector, true); - horz.lightlevel = gl_ClampLight(origin->Sector->GetCeilingLight()); - horz.colormap = origin->Sector->ColorMap; + horz.plane.GetFromSector(sector, true); + horz.lightlevel = gl_ClampLight(sector->GetCeilingLight()); + horz.colormap = sector->ColorMap; if (origin->special1 == SKYBOX_PLANE) { horz.plane.Texheight = ViewPos.Z + fabs(horz.plane.Texheight); @@ -1201,12 +1202,12 @@ void GLEEHorizonPortal::DrawContents() GLHorizonPortal ceil(&horz, true); ceil.DrawContents(); } - if (origin->Sector->GetTexture(sector_t::floor) != skyflatnum) + if (sector->GetTexture(sector_t::floor) != skyflatnum) { GLHorizonInfo horz; - horz.plane.GetFromSector(origin->Sector, false); - horz.lightlevel = gl_ClampLight(origin->Sector->GetFloorLight()); - horz.colormap = origin->Sector->ColorMap; + horz.plane.GetFromSector(sector, false); + horz.lightlevel = gl_ClampLight(sector->GetFloorLight()); + horz.colormap = sector->ColorMap; if (origin->special1 == SKYBOX_PLANE) { horz.plane.Texheight = ViewPos.Z - fabs(horz.plane.Texheight); diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index 80f64d02e..30de38eb7 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -669,7 +669,6 @@ void FDrawInfo::DrawUnhandledMissingTextures() if (seg->linedef->validcount == validcount) continue; // already done seg->linedef->validcount = validcount; if (seg->frontsector->GetPlaneTexZF(sector_t::ceiling) < ViewPos.Z) continue; // out of sight - //if (seg->frontsector->ceilingpic==skyflatnum) continue; // FIXME: The check for degenerate subsectors should be more precise if (seg->PartnerSeg && (seg->PartnerSeg->Subsector->flags & SSECF_DEGENERATE)) continue; @@ -688,7 +687,6 @@ void FDrawInfo::DrawUnhandledMissingTextures() seg_t * seg = MissingLowerSegs[i].seg; - // already done! if (seg->linedef->validcount == validcount) continue; // already done seg->linedef->validcount = validcount; if (!(sectorrenderflags[seg->backsector->sectornum] & SSRF_RENDERFLOOR)) continue; @@ -1049,7 +1047,7 @@ void FDrawInfo::CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor) sub->validcount=validcount; // Has a sector stack or skybox itself! - if (sub->render_sector->portals[sector_t::ceiling] != NULL) return; + if (sub->render_sector->GetGLPortal(sector_t::ceiling) != nullptr) return; // Don't bother processing unrendered subsectors if (sub->numlines>2 && !(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return; @@ -1096,7 +1094,7 @@ void FDrawInfo::CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor) sub->validcount=validcount; // Has a sector stack or skybox itself! - if (sub->render_sector->portals[sector_t::floor] != NULL) return; + if (sub->render_sector->GetGLPortal(sector_t::floor) != nullptr) return; // Don't bother processing unrendered subsectors if (sub->numlines>2 && !(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return; @@ -1146,7 +1144,7 @@ void FDrawInfo::ProcessSectorStacks() for (i=0;iportals[sector_t::ceiling]; + FPortal *portal = sec->GetGLPortal(sector_t::ceiling); if (portal != NULL) for(int k=0;ksubsectorcount;k++) { subsector_t * sub = sec->subsectors[k]; @@ -1170,10 +1168,10 @@ void FDrawInfo::ProcessSectorStacks() if (sub->portalcoverage[sector_t::ceiling].subsectors == NULL) { - gl_BuildPortalCoverage(&sub->portalcoverage[sector_t::ceiling], sub, portal); + gl_BuildPortalCoverage(&sub->portalcoverage[sector_t::ceiling], sub, portal->mDisplacement); } - portal->GetGLPortal()->AddSubsector(sub); + portal->GetRenderState()->AddSubsector(sub); if (sec->GetAlpha(sector_t::ceiling) != 0 && sec->GetTexture(sector_t::ceiling) != skyflatnum) { @@ -1190,7 +1188,7 @@ void FDrawInfo::ProcessSectorStacks() for (i=0;iportals[sector_t::floor]; + FPortal *portal = sec->GetGLPortal(sector_t::floor); if (portal != NULL) for(int k=0;ksubsectorcount;k++) { subsector_t * sub = sec->subsectors[k]; @@ -1215,10 +1213,10 @@ void FDrawInfo::ProcessSectorStacks() if (sub->portalcoverage[sector_t::floor].subsectors == NULL) { - gl_BuildPortalCoverage(&sub->portalcoverage[sector_t::floor], sub, portal); + gl_BuildPortalCoverage(&sub->portalcoverage[sector_t::floor], sub, portal->mDisplacement); } - GLSectorStackPortal *glportal = portal->GetGLPortal(); + GLSectorStackPortal *glportal = portal->GetRenderState(); glportal->AddSubsector(sub); if (sec->GetAlpha(sector_t::floor) != 0 && sec->GetTexture(sector_t::floor) != skyflatnum) diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 6f6039c00..ab16f57ab 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -311,10 +311,14 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex } else { - FPortal *pfront = fs->portals[sector_t::ceiling]; - FPortal *pback = bs->portals[sector_t::ceiling]; - if (pfront == NULL || fs->PortalBlocksView(sector_t::ceiling)) return; - if (pfront == pback && !bs->PortalBlocksView(sector_t::ceiling)) return; + int type = fs->GetPortalType(sector_t::ceiling); + if (type == SKYBOX_STACKEDSECTORTHING || type == SKYBOX_PORTAL || type == SKYBOX_LINKEDPORTAL) + { + FPortal *pfront = fs->GetGLPortal(sector_t::ceiling); + FPortal *pback = bs->GetGLPortal(sector_t::ceiling); + if (pfront == NULL || fs->PortalBlocksView(sector_t::ceiling)) return; + if (pfront == pback && !bs->PortalBlocksView(sector_t::ceiling)) return; + } } // stacked sectors @@ -386,10 +390,14 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver } else { - FPortal *pfront = fs->portals[sector_t::floor]; - FPortal *pback = bs->portals[sector_t::floor]; - if (pfront == NULL || fs->PortalBlocksView(sector_t::floor)) return; - if (pfront == pback && !bs->PortalBlocksView(sector_t::floor)) return; + int type = fs->GetPortalType(sector_t::floor); + if (type == SKYBOX_STACKEDSECTORTHING || type == SKYBOX_PORTAL || type == SKYBOX_LINKEDPORTAL) + { + FPortal *pfront = fs->GetGLPortal(sector_t::floor); + FPortal *pback = bs->GetGLPortal(sector_t::floor); + if (pfront == NULL || fs->PortalBlocksView(sector_t::floor)) return; + if (pfront == pback && !bs->PortalBlocksView(sector_t::floor)) return; + } } // stacked sectors diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 4b797f71f..48c20fad4 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -554,8 +554,8 @@ void GLSprite::Process(AActor* thing, sector_t * sector, bool thruportal) { rendersector = sector; } - topclip = rendersector->PortalBlocksMovement(sector_t::ceiling) ? LARGE_VALUE : rendersector->SkyBoxes[sector_t::ceiling]->specialf1; - bottomclip = rendersector->PortalBlocksMovement(sector_t::floor) ? -LARGE_VALUE : rendersector->SkyBoxes[sector_t::floor]->specialf1; + topclip = rendersector->PortalBlocksMovement(sector_t::ceiling) ? LARGE_VALUE : rendersector->GetPortalPlaneZ(sector_t::ceiling); + bottomclip = rendersector->PortalBlocksMovement(sector_t::floor) ? -LARGE_VALUE : rendersector->GetPortalPlaneZ(sector_t::floor); x = thingpos.X; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 8f91b59cd..b9dfc9ef4 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -185,7 +185,7 @@ void GLWall::PutPortal(int ptype) break; case PORTALTYPE_SECTORSTACK: - portal = this->portal->GetGLPortal(); + portal = this->portal->GetRenderState(); portal->AddLine(this); break; diff --git a/src/r_defs.h b/src/r_defs.h index 6a3894f0e..1f2f35621 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -38,6 +38,7 @@ #include "actor.h" struct FLightNode; struct FGLSection; +struct FPortal; struct seg_t; #include "dthinker.h" @@ -499,7 +500,6 @@ struct subsector_t; struct sector_t; struct side_t; extern bool gl_plane_reflection_i; -struct FPortal; // Ceiling/floor flags enum @@ -1159,6 +1159,8 @@ public: float GetReflect(int pos) { return gl_plane_reflection_i? reflect[pos] : 0; } bool VBOHeightcheck(int pos) const { return vboheight[pos] == GetPlaneTexZ(pos); } + FPortal *GetGLPortal(int plane) { return portals[plane]; } + void ClearPortal(int plane) { portals[plane] = nullptr; SkyBoxes[plane] = nullptr; } enum { From aa12772e079f37cb48cba3602eaeacb2cabbc3c8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 20 Apr 2016 13:18:53 +0200 Subject: [PATCH 0499/1509] - crash fix and minor optimization. --- src/gl/scene/gl_bsp.cpp | 8 +++++--- src/r_defs.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index 4377f68f1..725ea8663 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -141,11 +141,13 @@ static void AddLine (seg_t *seg, bool portalclip) } currentsubsector->flags |= SSECF_DRAWN; + BYTE ispoly = BYTE(seg->sidedef->Flags & WALLF_POLYOBJ); + if (!seg->backsector) { clipper.SafeAddClipRange(startAngle, endAngle); } - else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) // Two-sided polyobjects never obstruct the view + else if (!ispoly) // Two-sided polyobjects never obstruct the view { if (currentsector->sectornum == seg->backsector->sectornum) { @@ -179,9 +181,9 @@ static void AddLine (seg_t *seg, bool portalclip) seg->linedef->flags |= ML_MAPPED; - if ((seg->sidedef->Flags & WALLF_POLYOBJ) || seg->linedef->validcount!=validcount) + if (ispoly || seg->linedef->validcount!=validcount) { - if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) seg->linedef->validcount=validcount; + if (!ispoly) seg->linedef->validcount=validcount; if (gl_render_walls) { diff --git a/src/r_defs.h b/src/r_defs.h index 1f2f35621..2260dbf1d 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1001,7 +1001,7 @@ public: int GetPortalType(int plane) { - return SkyBoxes[plane]->special1; + return SkyBoxes[plane] == nullptr? -1 : SkyBoxes[plane]->special1; } int GetOppositePortalGroup(int plane) From 1c7b512cc07002d502911d10b7cb679884859fd3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 20 Apr 2016 20:08:53 +0200 Subject: [PATCH 0500/1509] - GL handling of new portal data organization. This also fixes some oversights with plane and horizon portals which were included in several checks. --- src/gl/data/gl_portaldata.cpp | 2 +- src/gl/scene/gl_fakeflat.cpp | 10 +-- src/gl/scene/gl_flats.cpp | 122 ++++++++++++++++------------------ src/gl/scene/gl_portal.cpp | 11 +-- src/gl/scene/gl_portal.h | 16 ++--- src/gl/scene/gl_sky.cpp | 95 +++++++++++++------------- src/gl/scene/gl_wall.h | 2 +- src/gl/scene/gl_walls.cpp | 12 ++-- src/p_saveg.cpp | 2 +- src/p_spec.cpp | 4 +- src/r_defs.h | 9 ++- 11 files changed, 147 insertions(+), 138 deletions(-) diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 413c85dc6..0262f964b 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -356,7 +356,7 @@ static void CollectPortalSectors(FPortalMap &collection) for (int j = 0; j < 2; j++) { int ptype = sec->GetPortalType(j); - if (ptype== SKYBOX_STACKEDSECTORTHING || ptype == SKYBOX_PORTAL || ptype == SKYBOX_LINKEDPORTAL) // only offset-displacing portal types + if (ptype== PORTS_STACKEDSECTORTHING || ptype == PORTS_PORTAL || ptype == PORTS_LINKEDPORTAL) // only offset-displacing portal types { FPortalID id = { sec->GetPortalDisplacement(j) }; diff --git a/src/gl/scene/gl_fakeflat.cpp b/src/gl/scene/gl_fakeflat.cpp index 70ac86ec7..04a19a7ed 100644 --- a/src/gl/scene/gl_fakeflat.cpp +++ b/src/gl/scene/gl_fakeflat.cpp @@ -69,10 +69,12 @@ bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto // Mirrors and horizons always block the view //if (linedef->special==Line_Mirror || linedef->special==Line_Horizon) return true; - // Lines with stacked sectors must never block! - - if (backsector->portals[sector_t::ceiling] != NULL || backsector->portals[sector_t::floor] != NULL || - frontsector->portals[sector_t::ceiling] != NULL || frontsector->portals[sector_t::floor] != NULL) + // Lines with portals must never block. + // Portals which require the sky flat are excluded here, because for them the special sky semantics apply. + if (!(frontsector->GetPortal(sector_t::ceiling)->mFlags & PORTSF_SKYFLATONLY) || + !(frontsector->GetPortal(sector_t::floor)->mFlags & PORTSF_SKYFLATONLY) || + !(backsector->GetPortal(sector_t::ceiling)->mFlags & PORTSF_SKYFLATONLY) || + !(backsector->GetPortal(sector_t::floor)->mFlags & PORTSF_SKYFLATONLY)) { return false; } diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index bdb57813a..3621973c9 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -491,8 +491,6 @@ void GLFlat::Process(sector_t * model, int whichplane, bool fog) if (!fog) { - if (plane.texture==skyflatnum) return; - gltexture=FMaterial::ValidateTexture(plane.texture, false, true); if (!gltexture) return; if (gltexture->tex->isFullbright()) @@ -558,6 +556,7 @@ void GLFlat::SetFrom3DFloor(F3DFloor *rover, bool top, bool underside) void GLFlat::ProcessSector(sector_t * frontsector) { lightlist_t * light; + FSectorPortal *port; #ifdef _DEBUG if (frontsector->sectornum == gl_breaksec) @@ -589,50 +588,48 @@ void GLFlat::ProcessSector(sector_t * frontsector) lightlevel = gl_ClampLight(frontsector->GetFloorLight()); Colormap = frontsector->ColorMap; - if ((stack = (frontsector->portals[sector_t::floor] != NULL))) + port = frontsector->ValidatePortal(sector_t::floor); + if ((stack = (port != NULL))) { - if (!frontsector->PortalBlocksView(sector_t::floor)) + if (port->mType == PORTS_STACKEDSECTORTHING) { - if (sector->SkyBoxes[sector_t::floor]->special1 == SKYBOX_STACKEDSECTORTHING) - { - gl_drawinfo->AddFloorStack(sector); - } - alpha = frontsector->GetAlpha(sector_t::floor) / 65536.0f; - } - else - { - alpha = 1.f; + gl_drawinfo->AddFloorStack(sector); // stacked sector things require visplane merging. } + alpha = frontsector->GetAlpha(sector_t::floor) / 65536.0f; } else { alpha = 1.0f - frontsector->GetReflect(sector_t::floor); } - if (frontsector->VBOHeightcheck(sector_t::floor)) - { - vboindex = frontsector->vboindex[sector_t::floor]; - } - else - { - vboindex = -1; - } - ceiling = false; - renderflags = SSRF_RENDERFLOOR; - - if (x.ffloors.Size()) + if (alpha != 0.f && sector->GetTexture(sector_t::floor) != skyflatnum) { - light = P_GetPlaneLight(sector, &frontsector->floorplane, false); - if ((!(sector->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING) || light->lightsource == NULL) - && (light->p_lightlevel != &frontsector->lightlevel)) + if (frontsector->VBOHeightcheck(sector_t::floor)) { - lightlevel = gl_ClampLight(*light->p_lightlevel); + vboindex = frontsector->vboindex[sector_t::floor]; + } + else + { + vboindex = -1; } - Colormap.CopyFrom3DLight(light); + ceiling = false; + renderflags = SSRF_RENDERFLOOR; + + if (x.ffloors.Size()) + { + light = P_GetPlaneLight(sector, &frontsector->floorplane, false); + if ((!(sector->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING) || light->lightsource == NULL) + && (light->p_lightlevel != &frontsector->lightlevel)) + { + lightlevel = gl_ClampLight(*light->p_lightlevel); + } + + Colormap.CopyFrom3DLight(light); + } + renderstyle = STYLE_Translucent; + Process(frontsector, false, false); } - renderstyle = STYLE_Translucent; - if (alpha != 0.0f) Process(frontsector, false, false); } // @@ -650,51 +647,48 @@ void GLFlat::ProcessSector(sector_t * frontsector) lightlevel = gl_ClampLight(frontsector->GetCeilingLight()); Colormap = frontsector->ColorMap; - if ((stack = (frontsector->portals[sector_t::ceiling] != NULL))) + port = frontsector->ValidatePortal(sector_t::ceiling); + if ((stack = (port != NULL))) { - if (!frontsector->PortalBlocksView(sector_t::ceiling)) + if (port->mType == PORTS_STACKEDSECTORTHING) { - if (sector->SkyBoxes[sector_t::ceiling]->special1 == SKYBOX_STACKEDSECTORTHING) - { - gl_drawinfo->AddCeilingStack(sector); - } - alpha = frontsector->GetAlpha(sector_t::ceiling) / 65536.0f; - } - else - { - alpha = 1.f; + gl_drawinfo->AddCeilingStack(sector); } + alpha = frontsector->GetAlpha(sector_t::ceiling) / 65536.0f; } else { alpha = 1.0f - frontsector->GetReflect(sector_t::ceiling); } - if (frontsector->VBOHeightcheck(sector_t::ceiling)) + if (alpha != 0.f && sector->GetTexture(sector_t::ceiling) != skyflatnum) { - vboindex = frontsector->vboindex[sector_t::ceiling]; - } - else - { - vboindex = -1; - } - - ceiling = true; - renderflags = SSRF_RENDERCEILING; - - if (x.ffloors.Size()) - { - light = P_GetPlaneLight(sector, §or->ceilingplane, true); - - if ((!(sector->GetFlags(sector_t::ceiling)&PLANEF_ABSLIGHTING)) - && (light->p_lightlevel != &frontsector->lightlevel)) + if (frontsector->VBOHeightcheck(sector_t::ceiling)) { - lightlevel = gl_ClampLight(*light->p_lightlevel); + vboindex = frontsector->vboindex[sector_t::ceiling]; } - Colormap.CopyFrom3DLight(light); + else + { + vboindex = -1; + } + + ceiling = true; + renderflags = SSRF_RENDERCEILING; + + if (x.ffloors.Size()) + { + light = P_GetPlaneLight(sector, §or->ceilingplane, true); + + if ((!(sector->GetFlags(sector_t::ceiling)&PLANEF_ABSLIGHTING)) + && (light->p_lightlevel != &frontsector->lightlevel)) + { + lightlevel = gl_ClampLight(*light->p_lightlevel); + } + Colormap.CopyFrom3DLight(light); + } + renderstyle = STYLE_Translucent; + Process(frontsector, true, false); } - renderstyle = STYLE_Translucent; - if (alpha != 0.0f) Process(frontsector, true, false); } // diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 3c2c661be..6c2a05592 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -644,7 +644,8 @@ void GLSkyboxPortal::DrawContents() } skyboxrecursion++; - origin->flags |= MF_JUSTHIT; + AActor *origin = portal->mSkybox; + portal->mFlags |= PORTSF_INSKYBOX; extralight = 0; PlaneMirrorMode = 0; @@ -672,7 +673,7 @@ void GLSkyboxPortal::DrawContents() currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7); GLRenderer->DrawScene(); - origin->flags &= ~MF_JUSTHIT; + portal->mFlags &= ~PORTSF_INSKYBOX; inskybox = false; gl_RenderState.SetDepthClamp(oldclamp); skyboxrecursion--; @@ -1180,7 +1181,7 @@ void GLHorizonPortal::DrawContents() void GLEEHorizonPortal::DrawContents() { PortalAll.Clock(); - sector_t *sector = origin->Sector; + sector_t *sector = portal->mOrigin; if (sector->GetTexture(sector_t::floor) == skyflatnum || sector->GetTexture(sector_t::ceiling) == skyflatnum) { @@ -1195,7 +1196,7 @@ void GLEEHorizonPortal::DrawContents() horz.plane.GetFromSector(sector, true); horz.lightlevel = gl_ClampLight(sector->GetCeilingLight()); horz.colormap = sector->ColorMap; - if (origin->special1 == SKYBOX_PLANE) + if (portal->mType == PORTS_PLANE) { horz.plane.Texheight = ViewPos.Z + fabs(horz.plane.Texheight); } @@ -1208,7 +1209,7 @@ void GLEEHorizonPortal::DrawContents() horz.plane.GetFromSector(sector, false); horz.lightlevel = gl_ClampLight(sector->GetFloorLight()); horz.colormap = sector->ColorMap; - if (origin->special1 == SKYBOX_PLANE) + if (portal->mType == PORTS_PLANE) { horz.plane.Texheight = ViewPos.Z - fabs(horz.plane.Texheight); } diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index f62db377d..8fe54c5b1 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -266,20 +266,20 @@ public: struct GLSkyboxPortal : public GLPortal { - AActor * origin; + FSectorPortal * portal; protected: virtual void DrawContents(); - virtual void * GetSource() const { return origin; } + virtual void * GetSource() const { return portal; } virtual bool IsSky() { return true; } virtual const char *GetName(); public: - GLSkyboxPortal(AActor * pt) + GLSkyboxPortal(FSectorPortal * pt) { - origin=pt; + portal=pt; } }; @@ -377,20 +377,20 @@ public: struct GLEEHorizonPortal : public GLPortal { - AActor * origin; + FSectorPortal * portal; protected: virtual void DrawContents(); - virtual void * GetSource() const { return origin; } + virtual void * GetSource() const { return portal; } virtual bool NeedDepthBuffer() { return false; } virtual bool NeedCap() { return false; } virtual const char *GetName(); public: - GLEEHorizonPortal(AActor *pt) + GLEEHorizonPortal(FSectorPortal *pt) { - origin=pt; + portal=pt; } }; diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index ab16f57ab..67ac94103 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -134,44 +134,52 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor) void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) { int ptype = -1; - FPortal *portal = sector->portals[plane]; - if (portal != NULL) - { - if (sector->PortalBlocksView(plane)) return; - if (GLPortal::instack[1 - plane]) return; - ptype = PORTALTYPE_SECTORSTACK; - this->portal = portal; + FSectorPortal *sportal = sector->ValidatePortal(plane); + if (sportal != nullptr && sportal->mFlags & PORTSF_INSKYBOX) sportal = nullptr; // no recursions, delete it here to simplify the following code + + // Either a regular sky or a skybox with skyboxes disabled + if ((sportal == nullptr && sector->GetTexture(plane) == skyflatnum) || (gl_noskyboxes && sportal != nullptr && sportal->mType == PORTS_SKYVIEWPOINT)) + { + GLSkyInfo skyinfo; + skyinfo.init(sector->sky, Colormap.FadeColor); + ptype = PORTALTYPE_SKY; + sky = UniqueSkies.Get(&skyinfo); } - else + else if (sportal != nullptr) { - ASkyViewpoint * skyboxx = sector->GetSkyBox(plane); - if (sector->GetTexture(plane) == skyflatnum || (skyboxx != NULL && skyboxx->bAlways)) + switch (sportal->mType) { - GLSkyInfo skyinfo; - - // JUSTHIT is used as an indicator that a skybox is in use. - // This is to avoid recursion - - if (!gl_noskyboxes && skyboxx && GLRenderer->mViewActor != skyboxx && !(skyboxx->flags&MF_JUSTHIT)) - { - ptype = PORTALTYPE_SKYBOX; - skybox = skyboxx; - } - else - { - skyinfo.init(sector->sky, Colormap.FadeColor); - ptype = PORTALTYPE_SKY; - sky = UniqueSkies.Get(&skyinfo); - } - } - else if (allowreflect && sector->GetReflect(plane) > 0) + case PORTS_STACKEDSECTORTHING: + case PORTS_PORTAL: + case PORTS_LINKEDPORTAL: { - if ((plane == sector_t::ceiling && ViewPos.Z > sector->ceilingplane.fD()) || - (plane == sector_t::floor && ViewPos.Z < -sector->floorplane.fD())) return; - ptype = PORTALTYPE_PLANEMIRROR; - planemirror = plane == sector_t::ceiling ? §or->ceilingplane : §or->floorplane; + FPortal *glport = sector->portals[plane]; + if (glport != NULL) + { + if (sector->PortalBlocksView(plane)) return; + + if (GLPortal::instack[1 - plane]) return; + ptype = PORTALTYPE_SECTORSTACK; + portal = glport; + } + break; } + + case PORTS_SKYVIEWPOINT: + case PORTS_HORIZON: + case PORTS_PLANE: + ptype = PORTALTYPE_SKYBOX; + secportal = sportal; + break; + } + } + else if (allowreflect && sector->GetReflect(plane) > 0) + { + if ((plane == sector_t::ceiling && ViewPos.Z > sector->ceilingplane.fD()) || + (plane == sector_t::floor && ViewPos.Z < -sector->floorplane.fD())) return; + ptype = PORTALTYPE_PLANEMIRROR; + planemirror = plane == sector_t::ceiling ? §or->ceilingplane : §or->floorplane; } if (ptype != -1) { @@ -188,17 +196,17 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) void GLWall::SkyLine(sector_t *fs, line_t *line) { - ASkyViewpoint * skyboxx = line->skybox; + FSectorPortal *secport = line->GetTransferredPortal(); GLSkyInfo skyinfo; int ptype; // JUSTHIT is used as an indicator that a skybox is in use. // This is to avoid recursion - if (!gl_noskyboxes && skyboxx && GLRenderer->mViewActor != skyboxx && !(skyboxx->flags&MF_JUSTHIT)) + if (!gl_noskyboxes && secport && (secport->mSkybox == nullptr || !(secport->mFlags & PORTSF_INSKYBOX))) { ptype = PORTALTYPE_SKYBOX; - skybox = skyboxx; + secportal = secport; } else { @@ -206,6 +214,10 @@ void GLWall::SkyLine(sector_t *fs, line_t *line) ptype = PORTALTYPE_SKY; sky = UniqueSkies.Get(&skyinfo); } + ztop[0] = zceil[0]; + ztop[1] = zceil[1]; + zbottom[0] = zfloor[0]; + zbottom[1] = zfloor[1]; PutPortal(ptype); } @@ -223,15 +235,6 @@ void GLWall::SkyNormal(sector_t * fs,vertex_t * v1,vertex_t * v2) zbottom[1]=zceil[1]; SkyPlane(fs, sector_t::ceiling, true); - if (seg->linedef->skybox != NULL) - { - ztop[0] = zceil[0]; - ztop[1] = zceil[1]; - zbottom[0] = zfloor[0]; - zbottom[1] = zfloor[1]; - SkyLine(fs, seg->linedef); - } - ztop[0]=zfloor[0]; ztop[1]=zfloor[1]; zbottom[0]=zbottom[1]=-32768.0f; @@ -312,7 +315,7 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex else { int type = fs->GetPortalType(sector_t::ceiling); - if (type == SKYBOX_STACKEDSECTORTHING || type == SKYBOX_PORTAL || type == SKYBOX_LINKEDPORTAL) + if (type == PORTS_STACKEDSECTORTHING || type == PORTS_PORTAL || type == PORTS_LINKEDPORTAL) { FPortal *pfront = fs->GetGLPortal(sector_t::ceiling); FPortal *pback = bs->GetGLPortal(sector_t::ceiling); @@ -391,7 +394,7 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver else { int type = fs->GetPortalType(sector_t::floor); - if (type == SKYBOX_STACKEDSECTORTHING || type == SKYBOX_PORTAL || type == SKYBOX_LINKEDPORTAL) + if (type == PORTS_STACKEDSECTORTHING || type == PORTS_PORTAL || type == PORTS_LINKEDPORTAL) { FPortal *pfront = fs->GetGLPortal(sector_t::floor); FPortal *pback = bs->GetGLPortal(sector_t::floor); diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 637737971..5d998342a 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -149,7 +149,7 @@ public: union { // it's either one of them but never more! - AActor * skybox; // for skyboxes + FSectorPortal *secportal; // sector portal (formerly skybox) GLSkyInfo * sky; // for normal sky GLHorizonInfo * horizon; // for horizon information FPortal * portal; // stacked sector portals diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index b9dfc9ef4..aec87c8af 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -174,12 +174,12 @@ void GLWall::PutPortal(int ptype) break; case PORTALTYPE_SKYBOX: - portal = GLPortal::FindPortal(skybox); + portal = GLPortal::FindPortal(secportal); if (!portal) { // either a regular skybox or an Eternity-style horizon - if (skybox->special1 != SKYBOX_SKYVIEWPOINT) portal = new GLEEHorizonPortal(skybox); - else portal = new GLSkyboxPortal(skybox); + if (secportal->mType != PORTS_SKYVIEWPOINT) portal = new GLEEHorizonPortal(secportal); + else portal = new GLSkyboxPortal(secportal); } portal->AddLine(this); break; @@ -1479,7 +1479,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) zbottom[1] = zfloor[1]; PutPortal(PORTALTYPE_LINETOLINE); } - else if (seg->linedef->skybox == NULL && !seg->linedef->isVisualPortal()) + else if (seg->linedef->portaltransferred > 0) + { + SkyLine(frontsector, seg->linedef); + } + else { // normal texture gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::mid), false, true); diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index dda47ef66..663ba6a67 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -415,7 +415,7 @@ void P_SerializeWorld (FArchive &arc) arc << li->args[1] << li->args[2] << li->args[3] << li->args[4]; arc << li->portalindex; - arc << li->skybox; // GZDoom addition. + arc << li->portaltransferred; // GZDoom addition. for (j = 0; j < 2; j++) { diff --git a/src/p_spec.cpp b/src/p_spec.cpp index c4a121507..9dad0253a 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -975,14 +975,14 @@ static void CopyPortal(int sectortag, int plane, unsigned pnum, double alpha, bo { if (lines[j].args[0] == 0) { - lines[j].skybox = origin; + lines[j].portaltransferred = pnum; } else { FLineIdIterator itr(lines[j].args[0]); while ((s = itr.Next()) >= 0) { - lines[s].skybox = origin; + lines[s].portaltransferred = pnum; } } } diff --git a/src/r_defs.h b/src/r_defs.h index ab4211465..6a69ee1d4 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -975,6 +975,7 @@ public: void ClearPortal(int plane) { Portals[plane] = 0; + portals[plane] = nullptr; } FSectorPortal *GetPortal(int plane) @@ -1152,7 +1153,6 @@ public: float GetReflect(int pos) { return gl_plane_reflection_i? reflect[pos] : 0; } bool VBOHeightcheck(int pos) const { return vboheight[pos] == GetPlaneTexZ(pos); } FPortal *GetGLPortal(int plane) { return portals[plane]; } - void ClearPortal(int plane) { portals[plane] = nullptr; SkyBoxes[plane] = nullptr; } enum { @@ -1404,7 +1404,7 @@ public: int validcount; // if == validcount, already checked int locknumber; // [Dusk] lock number for special unsigned portalindex; - TObjPtr skybox; + unsigned portaltransferred; DVector2 Delta() const { @@ -1421,6 +1421,11 @@ public: Alpha = FLOAT2FIXED(a); } + FSectorPortal *GetTransferredPortal() + { + return portaltransferred >= sectorPortals.Size() ? (FSectorPortal*)NULL : §orPortals[portaltransferred]; + } + FLinePortal *getPortal() const { return portalindex >= linePortals.Size() ? (FLinePortal*)NULL : &linePortals[portalindex]; From f299248c8ae2cad36c1683407dba2906c7ab53b8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 22 Apr 2016 09:15:22 +0200 Subject: [PATCH 0501/1509] - be a bit more careful with using unvalidated portals for checking render hacks. --- src/gl/scene/gl_renderhacks.cpp | 4 ++-- src/gl/scene/gl_sky.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index 30de38eb7..00bab423a 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -674,7 +674,7 @@ void FDrawInfo::DrawUnhandledMissingTextures() if (seg->PartnerSeg && (seg->PartnerSeg->Subsector->flags & SSECF_DEGENERATE)) continue; if (seg->backsector->transdoor) continue; if (seg->backsector->GetTexture(sector_t::ceiling) == skyflatnum) continue; - if (seg->backsector->portals[sector_t::ceiling] != NULL) continue; + if (seg->backsector->ValidatePortal(sector_t::ceiling) != NULL) continue; if (!glset.notexturefill) FloodUpperGap(seg); } @@ -693,7 +693,7 @@ void FDrawInfo::DrawUnhandledMissingTextures() if (seg->frontsector->GetPlaneTexZF(sector_t::floor) > ViewPos.Z) continue; // out of sight if (seg->backsector->transdoor) continue; if (seg->backsector->GetTexture(sector_t::floor) == skyflatnum) continue; - if (seg->backsector->portals[sector_t::floor] != NULL) continue; + if (seg->backsector->ValidatePortal(sector_t::floor) != NULL) continue; if (!glset.notexturefill) FloodLowerGap(seg); } diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 67ac94103..d556dcdab 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -154,7 +154,7 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) case PORTS_PORTAL: case PORTS_LINKEDPORTAL: { - FPortal *glport = sector->portals[plane]; + FPortal *glport = sector->GetGLPortal(plane); if (glport != NULL) { if (sector->PortalBlocksView(plane)) return; From c786b65727f42b4702e1f2f2b6908ffccf0c05c2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 22 Apr 2016 19:54:51 +0200 Subject: [PATCH 0502/1509] - allow the engine to run without sampler objects. This will create some overhead in the texture code, but that's still better than having to error out on those few systems where it may be an issue. --- src/gl/system/gl_interface.cpp | 9 +- src/gl/system/gl_interface.h | 3 +- src/gl/system/gl_wipe.cpp | 6 +- src/gl/textures/gl_material.cpp | 8 +- src/gl/textures/gl_material.h | 1 + src/gl/textures/gl_samplers.cpp | 156 +++++++++++++++++++++++++------- src/gl/textures/gl_samplers.h | 2 +- 7 files changed, 140 insertions(+), 45 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 3fd718ff7..3fcb7ced6 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -128,14 +128,15 @@ void gl_LoadExtensions() gl.vendorstring = (char*)glGetString(GL_VENDOR); - if (gl.version < 3.3f && !CheckExtension("GL_ARB_sampler_objects")) - { - I_FatalError("'GL_ARB_sampler_objects' extension not found. Please update your graphics driver."); - } if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; if (!Args->CheckParm("-gl3")) { + if (gl.version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) + { + gl.flags |= RFL_SAMPLER_OBJECTS; + } + // don't use GL 4.x features when running in GL 3 emulation mode. if (CheckExtension("GL_ARB_buffer_storage")) { diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 6f2fb2bfc..6988f873e 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -10,7 +10,8 @@ enum RenderFlags RFL_TEXTURE_COMPRESSION_S3TC=2, RFL_SHADER_STORAGE_BUFFER = 4, - RFL_BUFFER_STORAGE = 8 + RFL_BUFFER_STORAGE = 8, + RFL_SAMPLER_OBJECTS = 16 }; enum TexMode diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 232be87a1..00fc002f3 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -149,8 +149,8 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) wipestartscreen = new FHardwareTexture(Width, Height, true); wipestartscreen->CreateTexture(NULL, Width, Height, 0, false, 0); - GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER); - GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE); + GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1); + GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE, -1); glFinish(); wipestartscreen->Bind(0, false, false); GLint readbuffer = 0; @@ -176,7 +176,7 @@ void OpenGLFrameBuffer::WipeEndScreen() { wipeendscreen = new FHardwareTexture(Width, Height, true); wipeendscreen->CreateTexture(NULL, Width, Height, 0, false, 0); - GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER); + GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1); glFinish(); wipeendscreen->Bind(0, false, false); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index f5c8f90b3..961a61c04 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -89,6 +89,7 @@ FGLTexture::FGLTexture(FTexture * tx, bool expandpatches) bHasColorkey = false; bIsTransparent = -1; bExpandFlag = expandpatches; + lastSampler = 254; tex->gl_info.SystemTexture[expandpatches] = this; } @@ -278,7 +279,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla if (translation <= 0) translation = -translation; else translation = GLTranslationPalette::GetInternalTranslation(translation); - bool needmipmap = (clampmode <= CLAMP_XY); + bool needmipmap = (clampmode <= CLAMP_XY) || !(gl.flags & RFL_SAMPLER_OBJECTS); FHardwareTexture *hwtex = CreateHwTexture(); @@ -313,9 +314,10 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla } delete[] buffer; } - + if (!needmipmap) clampmode = CLAMP_XY_NOMIP; if (tex->bHasCanvas) static_cast(tex)->NeedUpdate(); - GLRenderer->mSamplerManager->Bind(texunit, clampmode); + if (lastSampler != clampmode) + lastSampler = GLRenderer->mSamplerManager->Bind(texunit, clampmode, lastSampler); return hwtex; } return NULL; diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index b8a71c7ce..83069049c 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -65,6 +65,7 @@ private: bool bHasColorkey; // only for hires bool bExpandFlag; + BYTE lastSampler; unsigned char * LoadHiresTexture(FTexture *hirescheck, int *width, int *height); diff --git a/src/gl/textures/gl_samplers.cpp b/src/gl/textures/gl_samplers.cpp index 3851d6c71..db0193c69 100644 --- a/src/gl/textures/gl_samplers.cpp +++ b/src/gl/textures/gl_samplers.cpp @@ -44,69 +44,159 @@ #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_renderer.h" #include "gl_samplers.h" +#include "gl_material.h" extern TexFilter_s TexFilter[]; FSamplerManager::FSamplerManager() { - glGenSamplers(7, mSamplers); - SetTextureFilterMode(); - glSamplerParameteri(mSamplers[5], GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glSamplerParameteri(mSamplers[5], GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glSamplerParameterf(mSamplers[5], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); - glSamplerParameterf(mSamplers[4], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); - glSamplerParameterf(mSamplers[6], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + glGenSamplers(7, mSamplers); + SetTextureFilterMode(); + glSamplerParameteri(mSamplers[5], GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glSamplerParameteri(mSamplers[5], GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glSamplerParameterf(mSamplers[5], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + glSamplerParameterf(mSamplers[4], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + glSamplerParameterf(mSamplers[6], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); - glSamplerParameteri(mSamplers[1], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glSamplerParameteri(mSamplers[2], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glSamplerParameteri(mSamplers[3], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glSamplerParameteri(mSamplers[3], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[1], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[2], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[3], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[3], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } } FSamplerManager::~FSamplerManager() { - UnbindAll(); - glDeleteSamplers(7, mSamplers); + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + UnbindAll(); + glDeleteSamplers(7, mSamplers); + } } void FSamplerManager::UnbindAll() { - for (int i = 0; i < FHardwareTexture::MAX_TEXTURES; i++) + if (gl.flags & RFL_SAMPLER_OBJECTS) { - mLastBound[i] = 0; - glBindSampler(i, 0); + for (int i = 0; i < FHardwareTexture::MAX_TEXTURES; i++) + { + mLastBound[i] = 0; + glBindSampler(i, 0); + } } } -void FSamplerManager::Bind(int texunit, int num) +BYTE FSamplerManager::Bind(int texunit, int num, int lastval) { - unsigned int samp = mSamplers[num]; - //if (samp != mLastBound[texunit]) + if (gl.flags & RFL_SAMPLER_OBJECTS) { - glBindSampler(texunit, samp); - mLastBound[texunit] = samp; + unsigned int samp = mSamplers[num]; + //if (samp != mLastBound[texunit]) + { + glBindSampler(texunit, samp); + mLastBound[texunit] = samp; + return 255; + } + } + else + { + glActiveTexture(GL_TEXTURE0 + texunit); + switch (num) + { + case CLAMP_NONE: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + if (lastval > CLAMP_XY_NOMIP) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + } + break; + + case CLAMP_X: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + if (lastval > CLAMP_XY_NOMIP) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + } + break; + + case CLAMP_Y: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + if (lastval > CLAMP_XY_NOMIP) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + } + break; + + case CLAMP_XY_NOMIP: + case CLAMP_XY: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + if (lastval > CLAMP_XY_NOMIP) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + } + break; + + case CLAMP_NOFILTER: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1); + break; + + case CLAMP_CAMTEX: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1); + break; + } + glActiveTexture(GL_TEXTURE0); + return num; } } void FSamplerManager::SetTextureFilterMode() { - UnbindAll(); - - for (int i = 0; i < 4; i++) + if (gl.flags & RFL_SAMPLER_OBJECTS) { - glSamplerParameteri(mSamplers[i], GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); - glSamplerParameteri(mSamplers[i], GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); - glSamplerParameterf(mSamplers[i], GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + UnbindAll(); + + for (int i = 0; i < 4; i++) + { + glSamplerParameteri(mSamplers[i], GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + glSamplerParameteri(mSamplers[i], GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glSamplerParameterf(mSamplers[i], GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + } + glSamplerParameteri(mSamplers[4], GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + glSamplerParameteri(mSamplers[4], GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glSamplerParameteri(mSamplers[6], GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + glSamplerParameteri(mSamplers[6], GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + } + else + { + GLRenderer->FlushTextures(); } - glSamplerParameteri(mSamplers[4], GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); - glSamplerParameteri(mSamplers[4], GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); - glSamplerParameteri(mSamplers[6], GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); - glSamplerParameteri(mSamplers[6], GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); } diff --git a/src/gl/textures/gl_samplers.h b/src/gl/textures/gl_samplers.h index 26589b4ad..daba65d45 100644 --- a/src/gl/textures/gl_samplers.h +++ b/src/gl/textures/gl_samplers.h @@ -17,7 +17,7 @@ public: FSamplerManager(); ~FSamplerManager(); - void Bind(int texunit, int num); + BYTE Bind(int texunit, int num, int lastval); void SetTextureFilterMode(); From 6450752399a5c89453252f1c081a99a353e0076e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 23 Apr 2016 10:50:19 +0200 Subject: [PATCH 0503/1509] - made it compile again. The software renderer float conversion removed viewx and viewy which are still needed for efficient position checks against nodes without constant float->fixed conversions. --- src/gl/scene/gl_bsp.cpp | 1 + src/gl/scene/gl_clipper.cpp | 2 ++ src/gl/scene/gl_sky.cpp | 2 +- src/gl/scene/gl_sprite.cpp | 4 ++-- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index 725ea8663..98053784c 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -63,6 +63,7 @@ CVAR(Bool, gl_render_things, true, 0) CVAR(Bool, gl_render_walls, true, 0) CVAR(Bool, gl_render_flats, true, 0) +extern fixed_t viewx, viewy; static void UnclipSubsector(subsector_t *sub) { diff --git a/src/gl/scene/gl_clipper.cpp b/src/gl/scene/gl_clipper.cpp index ab4bb83d4..e7cb14b26 100644 --- a/src/gl/scene/gl_clipper.cpp +++ b/src/gl/scene/gl_clipper.cpp @@ -388,6 +388,8 @@ angle_t Clipper::AngleToPseudo(angle_t ang) // //----------------------------------------------------------------------------- +fixed_t viewx, viewy; + void R_SetView() { viewx = FLOAT2FIXED(ViewPos.X); diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index d556dcdab..80ecc7632 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -272,7 +272,7 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex // or it will cause glitches elsewhere. tex = TexMan(seg->sidedef->GetTexture(side_t::mid)); if (tex != NULL && !(seg->linedef->flags & ML_DONTPEGTOP) && - seg->sidedef->GetTextureYOffset(side_t::mid) > 0) + seg->sidedef->GetTextureYOffsetF(side_t::mid) > 0) { ztop[0]=ztop[1]=32768.0f; zbottom[0]=zbottom[1]= diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 48c20fad4..5bbf26d92 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -644,7 +644,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, bool thruportal) gltexture=NULL; } - depth = (int)((x - ViewPos.X) * viewtancos + (y - ViewPos.Y) * viewtansin); + depth = FloatToFixed((x - ViewPos.X) * ViewTanCos + (y - ViewPos.Y) * ViewTanSin); // light calculation @@ -945,7 +945,7 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s z1=z-scalefac; z2=z+scalefac; - depth = (int)((x - ViewPos.X) * viewtancos + (y - ViewPos.Y) * viewtansin); + depth = FloatToFixed((x - ViewPos.X) * ViewTanCos + (y - ViewPos.Y) * ViewTanSin); actor=NULL; this->particle=particle; From a17e0b70d24f5bcad629bed9f7e61fa25b3387f0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 23 Apr 2016 11:38:33 +0200 Subject: [PATCH 0504/1509] - adjustment for function name changes. --- src/gl/scene/gl_sky.cpp | 8 ++++---- src/gl/scene/gl_walls.cpp | 16 ++++++++-------- src/gl/textures/gl_material.h | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 80ecc7632..384af7f15 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -86,8 +86,8 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor) texture[0] = FMaterial::ValidateTexture(texno, false, true); if (!texture[0] || texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky; skytexno1 = texno; - x_offset[0] = s->GetTextureXOffsetF(pos) * (360.f/65536.f); - y_offset = s->GetTextureYOffsetF(pos); + x_offset[0] = s->GetTextureXOffset(pos) * (360.f/65536.f); + y_offset = s->GetTextureYOffset(pos); mirrored = !l->args[2]; } else @@ -272,11 +272,11 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex // or it will cause glitches elsewhere. tex = TexMan(seg->sidedef->GetTexture(side_t::mid)); if (tex != NULL && !(seg->linedef->flags & ML_DONTPEGTOP) && - seg->sidedef->GetTextureYOffsetF(side_t::mid) > 0) + seg->sidedef->GetTextureYOffset(side_t::mid) > 0) { ztop[0]=ztop[1]=32768.0f; zbottom[0]=zbottom[1]= - bs->ceilingplane.ZatPoint(v2) + seg->sidedef->GetTextureYOffsetF(side_t::mid); + bs->ceilingplane.ZatPoint(v2) + seg->sidedef->GetTextureYOffset(side_t::mid); SkyPlane(fs, sector_t::ceiling, false); return; } diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index aec87c8af..7b9d99cab 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -641,11 +641,11 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg, type = _type; - float floatceilingref = ceilingrefheight + tci.RowOffset(seg->sidedef->GetTextureYOffsetF(texpos)); + float floatceilingref = ceilingrefheight + tci.RowOffset(seg->sidedef->GetTextureYOffset(texpos)); if (peg) floatceilingref += tci.mRenderHeight - flh - v_offset; if (!SetWallCoordinates(seg, &tci, floatceilingref, topleft, topright, bottomleft, bottomright, - seg->sidedef->GetTextureXOffsetF(texpos))) return; + seg->sidedef->GetTextureXOffset(texpos))) return; if (seg->linedef->special == Line_Mirror && _type == RENDERWALL_M1S && gl_mirrors) { @@ -704,7 +704,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, tci.mRenderHeight = -tci.mRenderHeight; tci.mScale.Y = -tci.mScale.Y; } - float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffsetF(side_t::mid)); + float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); if ((seg->linedef->flags & ML_DONTPEGBOTTOM) >0) { texturebottom = MAX(realfront->GetPlaneTexZF(sector_t::floor), realback->GetPlaneTexZF(sector_t::floor)) + rowoffset; @@ -822,7 +822,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // set up texture coordinate stuff // // - float t_ofs = seg->sidedef->GetTextureXOffsetF(side_t::mid); + float t_ofs = seg->sidedef->GetTextureXOffset(side_t::mid); if (gltexture) { @@ -1052,18 +1052,18 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, gltexture->GetTexCoordInfo(&tci, mastersd, side_t::mid); } - to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? 0 : tci.TextureOffset(mastersd->GetTextureXOffsetF(side_t::mid)); + to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? 0 : tci.TextureOffset(mastersd->GetTextureXOffset(side_t::mid)); - ul = tci.FloatToTexU(to + tci.TextureOffset(seg->sidedef->GetTextureXOffsetF(side_t::mid))); + ul = tci.FloatToTexU(to + tci.TextureOffset(seg->sidedef->GetTextureXOffset(side_t::mid))); texlength = tci.FloatToTexU(seg->sidedef->TexelLength); uplft.u = lolft.u = ul + texlength * glseg.fracleft; uprgt.u = lorgt.u = ul + texlength * glseg.fracright; - float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffsetF(side_t::mid)); + float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? - 0.f : tci.RowOffset(mastersd->GetTextureYOffsetF(side_t::mid)); + 0.f : tci.RowOffset(mastersd->GetTextureYOffset(side_t::mid)); to += rowoffset + rover->top.model->GetPlaneTexZF(rover->top.isceiling); diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 83069049c..9cd2d3387 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -161,7 +161,7 @@ public: void GetTexCoordInfo(FTexCoordInfo *tci, side_t *side, int texpos) const { - GetTexCoordInfo(tci, (float)side->GetTextureXScaleF(texpos), (float)side->GetTextureYScaleF(texpos)); + GetTexCoordInfo(tci, (float)side->GetTextureXScale(texpos), (float)side->GetTextureYScale(texpos)); } // This is scaled size in integer units as needed by walls and flats From 38f12133875995bcca4871ed7fc80611e01aa603 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 23 Apr 2016 13:35:51 +0200 Subject: [PATCH 0505/1509] - made some adjustments. --- src/gl/scene/gl_renderhacks.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index 00bab423a..9d51efb99 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -1058,11 +1058,7 @@ void FDrawInfo::CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor) me->ceilingplane != anchor->ceilingplane || me->GetCeilingLight() != anchor->GetCeilingLight() || me->ColorMap != anchor->ColorMap || - me->GetXOffset(sector_t::ceiling) != anchor->GetXOffset(sector_t::ceiling) || - me->GetYOffset(sector_t::ceiling) != anchor->GetYOffset(sector_t::ceiling) || - me->GetXScale(sector_t::ceiling) != anchor->GetXScale(sector_t::ceiling) || - me->GetYScale(sector_t::ceiling) != anchor->GetYScale(sector_t::ceiling) || - me->GetAngle(sector_t::ceiling) != anchor->GetAngle(sector_t::ceiling)) + me->planes[sector_t::ceiling].xform != anchor->planes[sector_t::ceiling].xform) { // different visplane so it can't belong to this stack return; @@ -1105,11 +1101,7 @@ void FDrawInfo::CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor) me->floorplane != anchor->floorplane || me->GetFloorLight() != anchor->GetFloorLight() || me->ColorMap != anchor->ColorMap || - me->GetXOffset(sector_t::floor) != anchor->GetXOffset(sector_t::floor) || - me->GetYOffset(sector_t::floor) != anchor->GetYOffset(sector_t::floor) || - me->GetXScale(sector_t::floor) != anchor->GetXScale(sector_t::floor) || - me->GetYScale(sector_t::floor) != anchor->GetYScale(sector_t::floor) || - me->GetAngle(sector_t::floor) != anchor->GetAngle(sector_t::floor)) + me->planes[sector_t::floor].xform != anchor->planes[sector_t::floor].xform) { // different visplane so it can't belong to this stack return; From 9d9219795af4e2023909b01865d736a1fc2133f8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 23 Apr 2016 13:48:25 +0200 Subject: [PATCH 0506/1509] - adjusted function names. --- src/gl/scene/gl_wall.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 5d998342a..c47b4a5cb 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -84,11 +84,11 @@ struct GLSectorPlane void GetFromSector(sector_t * sec, int ceiling) { - Offs.X = (float)sec->GetXOffsetF(ceiling); - Offs.Y = (float)sec->GetYOffsetF(ceiling); - Scale.X = (float)sec->GetXScaleF(ceiling); - Scale.Y = (float)sec->GetYScaleF(ceiling); - Angle = (float)sec->GetAngleF(ceiling).Degrees; + Offs.X = (float)sec->GetXOffset(ceiling); + Offs.Y = (float)sec->GetYOffset(ceiling); + Scale.X = (float)sec->GetXScale(ceiling); + Scale.Y = (float)sec->GetYScale(ceiling); + Angle = (float)sec->GetAngle(ceiling).Degrees; texture = sec->GetTexture(ceiling); plane = sec->GetSecPlane(ceiling); Texheight = (float)((ceiling == sector_t::ceiling)? plane.fD() : -plane.fD()); From 0d17459c363382d98bf2c8ab5497c0f825c66785 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 23 Apr 2016 15:47:51 +0200 Subject: [PATCH 0507/1509] - do not disable sampler objects with -gl3. --- src/gl/system/gl_interface.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 3fcb7ced6..7b46d1a5e 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -128,15 +128,15 @@ void gl_LoadExtensions() gl.vendorstring = (char*)glGetString(GL_VENDOR); + if (gl.version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) + { + gl.flags |= RFL_SAMPLER_OBJECTS; + } + if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; if (!Args->CheckParm("-gl3")) { - if (gl.version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) - { - gl.flags |= RFL_SAMPLER_OBJECTS; - } - // don't use GL 4.x features when running in GL 3 emulation mode. if (CheckExtension("GL_ARB_buffer_storage")) { From f77c4642cb9dc736336a667ad9ee419e9cd3d957 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 24 Apr 2016 13:35:43 +0200 Subject: [PATCH 0508/1509] - made the adjustments. --- src/gl/data/gl_setup.cpp | 2 +- src/gl/data/gl_vertexbuffer.cpp | 2 +- src/gl/scene/gl_decal.cpp | 12 +++---- src/gl/scene/gl_drawinfo.cpp | 2 +- src/gl/scene/gl_flats.cpp | 4 +-- src/gl/scene/gl_renderhacks.cpp | 56 ++++++++++++++++----------------- src/gl/scene/gl_sky.cpp | 2 +- src/gl/scene/gl_wall.h | 2 +- src/gl/scene/gl_walls.cpp | 44 +++++++++++++------------- src/r_defs.h | 4 +-- 10 files changed, 65 insertions(+), 65 deletions(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index 1cbb3b151..a6a0141f3 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -348,7 +348,7 @@ static void PrepareTransparentDoors(sector_t * sector) int side = sector->lines[i]->sidedef[0]->sector == sec; - if (sector->GetPlaneTexZ(sector_t::floor)!=sec->GetPlaneTexZ(sector_t::floor)+FRACUNIT) + if (sector->GetPlaneTexZ(sector_t::floor)!=sec->GetPlaneTexZ(sector_t::floor)+1.) { sector->transdoor=false; return; diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 997b34750..fdce68702 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -338,7 +338,7 @@ void FFlatVertexBuffer::CreateVBO() { sectors[i].vboindex[3] = sectors[i].vboindex[2] = sectors[i].vboindex[1] = sectors[i].vboindex[0] = -1; - sectors[i].vboheight[1] = sectors[i].vboheight[0] = FIXED_MIN; + sectors[i].vboheight[1] = sectors[i].vboheight[0] = FLT_MIN; } } diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 0bda67191..42d2eccbd 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -129,33 +129,33 @@ void GLWall::DrawDecal(DBaseDecal *decal) if (type!=RENDERWALL_TOP) return; if (line->flags & ML_DONTPEGTOP) { - zpos = decal->Z + frontsector->GetPlaneTexZF(sector_t::ceiling); + zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling); } else { - zpos = decal->Z + seg->backsector->GetPlaneTexZF(sector_t::ceiling); + zpos = decal->Z + seg->backsector->GetPlaneTexZ(sector_t::ceiling); } break; case RF_RELLOWER: if (type!=RENDERWALL_BOTTOM) return; if (line->flags & ML_DONTPEGBOTTOM) { - zpos = decal->Z + frontsector->GetPlaneTexZF(sector_t::ceiling); + zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling); } else { - zpos = decal->Z + seg->backsector->GetPlaneTexZF(sector_t::floor); + zpos = decal->Z + seg->backsector->GetPlaneTexZ(sector_t::floor); } break; case RF_RELMID: if (type==RENDERWALL_TOP || type==RENDERWALL_BOTTOM) return; if (line->flags & ML_DONTPEGBOTTOM) { - zpos = decal->Z + frontsector->GetPlaneTexZF(sector_t::floor); + zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::floor); } else { - zpos = decal->Z + frontsector->GetPlaneTexZF(sector_t::ceiling); + zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling); } } diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 7b30e41db..c9cdf094d 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -1222,7 +1222,7 @@ void FDrawInfo::FloodLowerGap(seg_t * seg) if (fakebsector->GetTexture(sector_t::floor) == skyflatnum) return; - if (fakebsector->GetPlaneTexZF(sector_t::floor) > ViewPos.Z) return; + if (fakebsector->GetPlaneTexZ(sector_t::floor) > ViewPos.Z) return; if (seg->sidedef == seg->linedef->sidedef[0]) { diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 3621973c9..6d563f1a7 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -595,7 +595,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) { gl_drawinfo->AddFloorStack(sector); // stacked sector things require visplane merging. } - alpha = frontsector->GetAlpha(sector_t::floor) / 65536.0f; + alpha = frontsector->GetAlpha(sector_t::floor); } else { @@ -654,7 +654,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) { gl_drawinfo->AddCeilingStack(sector); } - alpha = frontsector->GetAlpha(sector_t::ceiling) / 65536.0f; + alpha = frontsector->GetAlpha(sector_t::ceiling); } else { diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index 9d51efb99..150ad1554 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -299,14 +299,14 @@ bool FDrawInfo::DoOneSectorUpper(subsector_t * subsec, float Planez) if (sec->ceilingplane.isSlope()) return false; // Is the neighboring ceiling lower than the desired height? - if (sec->GetPlaneTexZF(sector_t::ceiling) < Planez) + if (sec->GetPlaneTexZ(sector_t::ceiling) < Planez) { // todo: check for missing textures. return false; } // This is an exact height match which means we don't have to do any further checks for this sector - if (sec->GetPlaneTexZF(sector_t::ceiling) == Planez) + if (sec->GetPlaneTexZ(sector_t::ceiling) == Planez) { // If there's a texture abort FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::top)]; @@ -357,14 +357,14 @@ bool FDrawInfo::DoOneSectorLower(subsector_t * subsec, float Planez) if (sec->floorplane.isSlope()) return false; // Is the neighboring floor higher than the desired height? - if (sec->GetPlaneTexZF(sector_t::floor) > Planez) + if (sec->GetPlaneTexZ(sector_t::floor) > Planez) { // todo: check for missing textures. return false; } // This is an exact height match which means we don't have to do any further checks for this sector - if (sec->GetPlaneTexZF(sector_t::floor) == Planez) + if (sec->GetPlaneTexZ(sector_t::floor) == Planez) { // If there's a texture abort FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::bottom)]; @@ -416,7 +416,7 @@ bool FDrawInfo::DoFakeBridge(subsector_t * subsec, float Planez) if (sec->floorplane.isSlope()) return false; // Is the neighboring floor higher than the desired height? - if (sec->GetPlaneTexZF(sector_t::floor) < Planez) + if (sec->GetPlaneTexZ(sector_t::floor) < Planez) { // todo: check for missing textures. return false; @@ -424,7 +424,7 @@ bool FDrawInfo::DoFakeBridge(subsector_t * subsec, float Planez) // This is an exact height match which means we don't have to do any further checks for this sector // No texture checks though! - if (sec->GetPlaneTexZF(sector_t::floor) == Planez) continue; + if (sec->GetPlaneTexZ(sector_t::floor) == Planez) continue; } if (!DoFakeBridge(backsub, Planez)) return false; } @@ -469,7 +469,7 @@ bool FDrawInfo::DoFakeCeilingBridge(subsector_t * subsec, float Planez) if (sec->ceilingplane.isSlope()) return false; // Is the neighboring ceiling higher than the desired height? - if (sec->GetPlaneTexZF(sector_t::ceiling) > Planez) + if (sec->GetPlaneTexZ(sector_t::ceiling) > Planez) { // todo: check for missing textures. return false; @@ -477,7 +477,7 @@ bool FDrawInfo::DoFakeCeilingBridge(subsector_t * subsec, float Planez) // This is an exact height match which means we don't have to do any further checks for this sector // No texture checks though! - if (sec->GetPlaneTexZF(sector_t::ceiling) == Planez) continue; + if (sec->GetPlaneTexZ(sector_t::ceiling) == Planez) continue; } if (!DoFakeCeilingBridge(backsub, Planez)) return false; } @@ -553,7 +553,7 @@ void FDrawInfo::HandleMissingTextures() { // It isn't a hole. Now check whether it might be a fake bridge sector_t * fakesector = gl_FakeFlat(MissingUpperTextures[i].seg->frontsector, &fake, false); - float planez = (float)fakesector->GetPlaneTexZF(sector_t::ceiling); + float planez = (float)fakesector->GetPlaneTexZ(sector_t::ceiling); backsub->validcount = validcount; if (DoFakeCeilingBridge(backsub, planez)) @@ -624,7 +624,7 @@ void FDrawInfo::HandleMissingTextures() { // It isn't a hole. Now check whether it might be a fake bridge sector_t * fakesector = gl_FakeFlat(MissingLowerTextures[i].seg->frontsector, &fake, false); - float planez = (float)fakesector->GetPlaneTexZF(sector_t::floor); + float planez = (float)fakesector->GetPlaneTexZ(sector_t::floor); backsub->validcount = validcount; if (DoFakeBridge(backsub, planez)) @@ -668,7 +668,7 @@ void FDrawInfo::DrawUnhandledMissingTextures() // already done! if (seg->linedef->validcount == validcount) continue; // already done seg->linedef->validcount = validcount; - if (seg->frontsector->GetPlaneTexZF(sector_t::ceiling) < ViewPos.Z) continue; // out of sight + if (seg->frontsector->GetPlaneTexZ(sector_t::ceiling) < ViewPos.Z) continue; // out of sight // FIXME: The check for degenerate subsectors should be more precise if (seg->PartnerSeg && (seg->PartnerSeg->Subsector->flags & SSECF_DEGENERATE)) continue; @@ -690,7 +690,7 @@ void FDrawInfo::DrawUnhandledMissingTextures() if (seg->linedef->validcount == validcount) continue; // already done seg->linedef->validcount = validcount; if (!(sectorrenderflags[seg->backsector->sectornum] & SSRF_RENDERFLOOR)) continue; - if (seg->frontsector->GetPlaneTexZF(sector_t::floor) > ViewPos.Z) continue; // out of sight + if (seg->frontsector->GetPlaneTexZ(sector_t::floor) > ViewPos.Z) continue; // out of sight if (seg->backsector->transdoor) continue; if (seg->backsector->GetTexture(sector_t::floor) == skyflatnum) continue; if (seg->backsector->ValidatePortal(sector_t::floor) != NULL) continue; @@ -758,8 +758,8 @@ bool FDrawInfo::CheckAnchorFloor(subsector_t * sub) { // I'm ignoring slopes, scaling and rotation here. The likelihood of ZDoom maps // using such crap hacks is simply too small - if (sub->render_sector->GetTexture(sector_t::floor)==backsub->render_sector->GetTexture(sector_t::floor) && - sub->render_sector->GetPlaneTexZ(sector_t::floor)==backsub->render_sector->GetPlaneTexZ(sector_t::floor) && + if (sub->render_sector->GetTexture(sector_t::floor) == backsub->render_sector->GetTexture(sector_t::floor) && + sub->render_sector->GetPlaneTexZ(sector_t::floor) == backsub->render_sector->GetPlaneTexZ(sector_t::floor) && sub->render_sector->GetFloorLight() == backsub->render_sector->GetFloorLight()) { continue; @@ -797,10 +797,10 @@ bool FDrawInfo::CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor) if (!(ss_renderflags[DWORD(sub - subsectors)] & SSRF_PROCESSED)) return true; if (sub->render_sector->GetTexture(sector_t::floor) != anchor->GetTexture(sector_t::floor) || - sub->render_sector->GetPlaneTexZF(sector_t::floor) != anchor->GetPlaneTexZF(sector_t::floor) || + sub->render_sector->GetPlaneTexZ(sector_t::floor) != anchor->GetPlaneTexZ(sector_t::floor) || sub->render_sector->GetFloorLight() != anchor->GetFloorLight()) { - if (sub == viewsubsector && ViewPos.Z < anchor->GetPlaneTexZF(sector_t::floor)) inview = true; + if (sub == viewsubsector && ViewPos.Z < anchor->GetPlaneTexZ(sector_t::floor)) inview = true; HandledSubsectors.Push(sub); } } @@ -825,9 +825,9 @@ bool FDrawInfo::CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor) else if (sub->render_sector == backsub->render_sector) { // Any anchor not within the original anchor's visplane terminates the processing. - if (sub->render_sector->GetTexture(sector_t::floor)!=anchor->GetTexture(sector_t::floor) || - sub->render_sector->GetPlaneTexZ(sector_t::floor)!=anchor->GetPlaneTexZ(sector_t::floor) || - sub->render_sector->GetFloorLight() != anchor->GetFloorLight()) + if (sub->render_sector->GetTexture(sector_t::floor) != anchor->GetTexture(sector_t::floor) || + sub->render_sector->GetPlaneTexZ(sector_t::floor) != anchor->GetPlaneTexZ(sector_t::floor) || + sub->render_sector->GetFloorLight() != anchor->GetFloorLight()) { return false; } @@ -864,8 +864,8 @@ bool FDrawInfo::CheckAnchorCeiling(subsector_t * sub) { // I'm ignoring slopes, scaling and rotation here. The likelihood of ZDoom maps // using such crap hacks is simply too small - if (sub->render_sector->GetTexture(sector_t::ceiling)==backsub->render_sector->GetTexture(sector_t::ceiling) && - sub->render_sector->GetPlaneTexZ(sector_t::ceiling)==backsub->render_sector->GetPlaneTexZ(sector_t::ceiling) && + if (sub->render_sector->GetTexture(sector_t::ceiling) == backsub->render_sector->GetTexture(sector_t::ceiling) && + sub->render_sector->GetPlaneTexZ(sector_t::ceiling) == backsub->render_sector->GetPlaneTexZ(sector_t::ceiling) && sub->render_sector->GetCeilingLight() == backsub->render_sector->GetCeilingLight()) { continue; @@ -898,11 +898,11 @@ bool FDrawInfo::CollectSubsectorsCeiling(subsector_t * sub, sector_t * anchor) // Is not being rendererd so don't bother. if (!(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return true; - if (sub->render_sector->GetTexture(sector_t::ceiling)!=anchor->GetTexture(sector_t::ceiling) || - sub->render_sector->GetPlaneTexZ(sector_t::ceiling)!=anchor->GetPlaneTexZ(sector_t::ceiling) || - sub->render_sector->GetCeilingLight() != anchor->GetCeilingLight()) + if (sub->render_sector->GetTexture(sector_t::ceiling) != anchor->GetTexture(sector_t::ceiling) || + sub->render_sector->GetPlaneTexZ(sector_t::ceiling) != anchor->GetPlaneTexZ(sector_t::ceiling) || + sub->render_sector->GetCeilingLight() != anchor->GetCeilingLight()) { - HandledSubsectors.Push (sub); + HandledSubsectors.Push(sub); } } @@ -926,9 +926,9 @@ bool FDrawInfo::CollectSubsectorsCeiling(subsector_t * sub, sector_t * anchor) else if (sub->render_sector == backsub->render_sector) { // Any anchor not within the original anchor's visplane terminates the processing. - if (sub->render_sector->GetTexture(sector_t::ceiling)!=anchor->GetTexture(sector_t::ceiling) || - sub->render_sector->GetPlaneTexZ(sector_t::ceiling)!=anchor->GetPlaneTexZ(sector_t::ceiling) || - sub->render_sector->GetCeilingLight() != anchor->GetCeilingLight()) + if (sub->render_sector->GetTexture(sector_t::ceiling) != anchor->GetTexture(sector_t::ceiling) || + sub->render_sector->GetPlaneTexZ(sector_t::ceiling) != anchor->GetPlaneTexZ(sector_t::ceiling) || + sub->render_sector->GetCeilingLight() != anchor->GetCeilingLight()) { return false; } diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 384af7f15..6d82aefa7 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -262,7 +262,7 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex // one more check for some ugly transparent door hacks if (!bs->floorplane.isSlope() && !fs->floorplane.isSlope()) { - if (bs->GetPlaneTexZ(sector_t::floor)==fs->GetPlaneTexZ(sector_t::floor)+FRACUNIT) + if (bs->GetPlaneTexZ(sector_t::floor)==fs->GetPlaneTexZ(sector_t::floor)+1.) { FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::bottom)); if (!tex || tex->UseType==FTexture::TEX_Null) return; diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index c47b4a5cb..3bc3b8a58 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -288,7 +288,7 @@ public: bool ceiling; BYTE renderflags; int vboindex; - int vboheight; + //int vboheight; int dynlightindex; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 7b9d99cab..49b2411a9 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -360,12 +360,12 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) lightlist_t * light; // ZDoom doesn't support slopes in a horizon sector so I won't either! - ztop[1] = ztop[0] = fs->GetPlaneTexZF(sector_t::ceiling); - zbottom[1] = zbottom[0] = fs->GetPlaneTexZF(sector_t::floor); + ztop[1] = ztop[0] = fs->GetPlaneTexZ(sector_t::ceiling); + zbottom[1] = zbottom[0] = fs->GetPlaneTexZ(sector_t::floor); - if (ViewPos.Z < fs->GetPlaneTexZF(sector_t::ceiling)) + if (ViewPos.Z < fs->GetPlaneTexZ(sector_t::ceiling)) { - if (ViewPos.Z > fs->GetPlaneTexZF(sector_t::floor)) + if (ViewPos.Z > fs->GetPlaneTexZ(sector_t::floor)) zbottom[1] = zbottom[0] = ViewPos.Z; if (fs->GetTexture(sector_t::ceiling) == skyflatnum) @@ -393,9 +393,9 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) ztop[1] = ztop[0] = zbottom[0]; } - if (ViewPos.Z > fs->GetPlaneTexZF(sector_t::floor)) + if (ViewPos.Z > fs->GetPlaneTexZ(sector_t::floor)) { - zbottom[1] = zbottom[0] = fs->GetPlaneTexZF(sector_t::floor); + zbottom[1] = zbottom[0] = fs->GetPlaneTexZ(sector_t::floor); if (fs->GetTexture(sector_t::floor) == skyflatnum) { SkyPlane(fs, sector_t::floor, false); @@ -707,12 +707,12 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); if ((seg->linedef->flags & ML_DONTPEGBOTTOM) >0) { - texturebottom = MAX(realfront->GetPlaneTexZF(sector_t::floor), realback->GetPlaneTexZF(sector_t::floor)) + rowoffset; + texturebottom = MAX(realfront->GetPlaneTexZ(sector_t::floor), realback->GetPlaneTexZ(sector_t::floor)) + rowoffset; texturetop = texturebottom + tci.mRenderHeight; } else { - texturetop = MIN(realfront->GetPlaneTexZF(sector_t::ceiling), realback->GetPlaneTexZF(sector_t::ceiling)) + rowoffset; + texturetop = MIN(realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling)) + rowoffset; texturebottom = texturetop - tci.mRenderHeight; } } @@ -896,7 +896,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // set up alpha blending // // - if (seg->linedef->Alpha)// && seg->linedef->special!=Line_Fogsheet) + if (seg->linedef->alpha != 0) { bool translucent = false; @@ -904,13 +904,13 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, { case 0: RenderStyle=STYLE_Translucent; - alpha=FIXED2FLOAT(seg->linedef->Alpha); - translucent = seg->linedef->Alpha < FRACUNIT || (gltexture && gltexture->GetTransparent()); + alpha = seg->linedef->alpha; + translucent =alpha < 1. || (gltexture && gltexture->GetTransparent()); break; case ML_ADDTRANS: RenderStyle=STYLE_Add; - alpha=FIXED2FLOAT(seg->linedef->Alpha); + alpha = seg->linedef->alpha; translucent=true; break; } @@ -1065,7 +1065,7 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? 0.f : tci.RowOffset(mastersd->GetTextureYOffset(side_t::mid)); - to += rowoffset + rover->top.model->GetPlaneTexZF(rover->top.isceiling); + to += rowoffset + rover->top.model->GetPlaneTexZ(rover->top.isceiling); uplft.v = tci.FloatToTexV(to - ff_topleft); uprgt.v = tci.FloatToTexV(to - ff_topright); @@ -1372,8 +1372,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) segfront = frontsector; segback = backsector; } - frefz = realfront->GetPlaneTexZF(sector_t::floor); - crefz = realfront->GetPlaneTexZF(sector_t::ceiling); + frefz = realfront->GetPlaneTexZ(sector_t::floor); + crefz = realfront->GetPlaneTexZ(sector_t::ceiling); if (seg->sidedef == seg->linedef->sidedef[0]) { @@ -1525,7 +1525,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, - crefz, realback->GetPlaneTexZF(sector_t::ceiling), + crefz, realback->GetPlaneTexZ(sector_t::ceiling), fch1, fch2, bch1a, bch2a, 0); } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) @@ -1538,7 +1538,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, - crefz, realback->GetPlaneTexZF(sector_t::ceiling), + crefz, realback->GetPlaneTexZ(sector_t::ceiling), fch1, fch2, bch1a, bch2a, 0); } } @@ -1602,10 +1602,10 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, - realback->GetPlaneTexZF(sector_t::floor), frefz, + realback->GetPlaneTexZ(sector_t::floor), frefz, bfh1, bfh2, ffh1, ffh2, frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum ? - frefz - realback->GetPlaneTexZF(sector_t::ceiling) : + frefz - realback->GetPlaneTexZ(sector_t::ceiling) : frefz - crefz); } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) @@ -1621,7 +1621,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) if (gltexture) { DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, - realback->GetPlaneTexZF(sector_t::floor), frefz, + realback->GetPlaneTexZ(sector_t::floor), frefz, bfh1, bfh2, ffh1, ffh2, frefz - crefz); } } @@ -1648,8 +1648,8 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * if (frontsector->GetTexture(sector_t::floor) == skyflatnum) return; lightlist = NULL; - float ffh = frontsector->GetPlaneTexZF(sector_t::floor); - float bfh = backsector->GetPlaneTexZF(sector_t::floor); + float ffh = frontsector->GetPlaneTexZ(sector_t::floor); + float bfh = backsector->GetPlaneTexZ(sector_t::floor); if (bfh > ffh) { this->seg = seg; diff --git a/src/r_defs.h b/src/r_defs.h index 52654b45f..11ceed067 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1081,8 +1081,8 @@ public: float reflect[2]; bool transdoor; // For transparent door hacks - fixed_t transdoorheight; // for transparent door hacks int subsectorcount; // list of subsectors + double transdoorheight; // for transparent door hacks subsector_t ** subsectors; FPortal * portals[2]; // floor and ceiling portals FLightNode * lighthead; @@ -1094,7 +1094,7 @@ public: }; int vboindex[4]; // VBO indices of the 4 planes this sector uses during rendering - fixed_t vboheight[2]; // Last calculated height for the 2 planes of this actual sector + double vboheight[2]; // Last calculated height for the 2 planes of this actual sector int vbocount[2]; // Total count of vertices belonging to this sector's planes float GetReflect(int pos) { return gl_plane_reflection_i? reflect[pos] : 0; } From 22b7a38539498e08990dce7c05598d0ba1510566 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 24 Apr 2016 14:17:06 +0200 Subject: [PATCH 0509/1509] - fixed incorrect sky texture check with Transfer_Heights. The actual sector was checked, not the one created by gl_FakeFlat. --- src/gl/scene/gl_flats.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 6d563f1a7..0ec2b5149 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -602,7 +602,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) alpha = 1.0f - frontsector->GetReflect(sector_t::floor); } - if (alpha != 0.f && sector->GetTexture(sector_t::floor) != skyflatnum) + if (alpha != 0.f && frontsector->GetTexture(sector_t::floor) != skyflatnum) { if (frontsector->VBOHeightcheck(sector_t::floor)) { @@ -661,7 +661,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) alpha = 1.0f - frontsector->GetReflect(sector_t::ceiling); } - if (alpha != 0.f && sector->GetTexture(sector_t::ceiling) != skyflatnum) + if (alpha != 0.f && frontsector->GetTexture(sector_t::ceiling) != skyflatnum) { if (frontsector->VBOHeightcheck(sector_t::ceiling)) { From fc38728309f585f306dc48a3c7879c8c9e54e2f0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 11:31:27 +0200 Subject: [PATCH 0510/1509] - made some changes to the shaders to allow downpatching them to GLSL 1.2: * disable the dynamic light code if no buffers are available * added a duplicate of the getTexel function which cannot be patched without creating syntax problems. * fixe int<->float conversion warning, which on some compilers may be an error. --- wadsrc/static/shaders/glsl/main.fp | 33 +++++++++++++++++++++++++++++- wadsrc/static/shaders/glsl/main.vp | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 90fab0e25..f6273fc09 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -11,7 +11,7 @@ out vec4 FragColor; { vec4 lights[]; }; -#else +#elif defined NUM_UBO_LIGHTS /*layout(std140)*/ uniform LightBufferUBO { vec4 lights[NUM_UBO_LIGHTS]; @@ -51,6 +51,32 @@ vec4 desaturate(vec4 texel) // //=========================================================================== +#ifdef GLSL12_COMPATIBLE +vec4 getTexel(vec2 st) +{ + vec4 texel = texture(tex, st); + + // + // Apply texture modes + // + if (uTextureMode != 0) + { + if (uTextureMode == 1) texel.rgb = vec3(1.0,1.0,1.0); + else if (uTextureMode == 2) texel.a = 1.0; + else if (uTextureMode == 3) texel = vec4(1.0-texel.r, 1.0-texel.b, 1.0-texel.g, texel.a); + else if (uTextureMode == 4) texel = vec4(1.0, 1.0, 1.0, texel.r*texel.a); + else if (uTextureMode == 5) + { + if (st.t < 0.0 || st.t > 1.0) + { + texel.a = 0.0; + } + } + } + texel *= uObjectColor; + return desaturate(texel); +} +#else vec4 getTexel(vec2 st) { vec4 texel = texture(tex, st); @@ -87,6 +113,7 @@ vec4 getTexel(vec2 st) return desaturate(texel); } +#endif //=========================================================================== // @@ -181,6 +208,7 @@ vec4 getLightColor(float fogdist, float fogfactor) vec4 dynlight = uDynLightColor; +#if defined NUM_UBO_LIGHTS || defined SHADER_STORAGE_LIGHTS if (uLightIndex >= 0) { ivec4 lightRange = ivec4(lights[uLightIndex]) + ivec4(uLightIndex + 1); @@ -210,6 +238,7 @@ vec4 getLightColor(float fogdist, float fogfactor) } } } +#endif color.rgb = clamp(color.rgb + desaturate(dynlight).rgb, 0.0, 1.4); // prevent any unintentional messing around with the alpha. @@ -270,6 +299,7 @@ void main() frag *= getLightColor(fogdist, fogfactor); +#if defined NUM_UBO_LIGHTS || defined SHADER_STORAGE_LIGHTS if (uLightIndex >= 0) { ivec4 lightRange = ivec4(lights[uLightIndex]) + ivec4(uLightIndex + 1); @@ -291,6 +321,7 @@ void main() frag.rgb = clamp(frag.rgb + desaturate(addlight).rgb, 0.0, 1.0); } } +#endif // // colored fog diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 1c6aebe47..cea479f3b 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -30,7 +30,7 @@ void main() glowdist.x = -((uGlowTopPlane.w + uGlowTopPlane.x * worldcoord.x + uGlowTopPlane.y * worldcoord.z) * uGlowTopPlane.z) - worldcoord.y; glowdist.y = worldcoord.y + ((uGlowBottomPlane.w + uGlowBottomPlane.x * worldcoord.x + uGlowBottomPlane.y * worldcoord.z) * uGlowBottomPlane.z); - if (uSplitBottomPlane.z != 0) + if (uSplitBottomPlane.z != 0.0) { gl_ClipDistance[3] = -((uSplitTopPlane.w + uSplitTopPlane.x * worldcoord.x + uSplitTopPlane.y * worldcoord.z) * uSplitTopPlane.z) - worldcoord.y; gl_ClipDistance[4] = worldcoord.y + ((uSplitBottomPlane.w + uSplitBottomPlane.x * worldcoord.x + uSplitBottomPlane.y * worldcoord.z) * uSplitBottomPlane.z); From 97bed58d7d5b800b8017df50eb50ab4cb825b8fd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 11:32:40 +0200 Subject: [PATCH 0511/1509] - use a compatibility mode version of gl_load, so that the fallback GL 2 code can get its definitions. --- src/gl/system/gl_load.c | 1118 ++++++++++++++++++++++++++++++++++- src/gl/system/gl_load.h | 1222 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 2328 insertions(+), 12 deletions(-) diff --git a/src/gl/system/gl_load.c b/src/gl/system/gl_load.c index 282395016..aaab3cf82 100644 --- a/src/gl/system/gl_load.c +++ b/src/gl/system/gl_load.c @@ -53,8 +53,6 @@ static void* SunGetProcAddress (const GLubyte* name) #if defined(_WIN32) #ifdef _MSC_VER -// disable inlining here because it creates an incredible amount of bloat here. -#pragma inline_depth(0) #pragma warning(disable: 4055) #pragma warning(disable: 4054) #endif @@ -103,6 +101,7 @@ int ogl_ext_ARB_buffer_storage = ogl_LOAD_FAILED; int ogl_ext_ARB_shader_storage_buffer_object = ogl_LOAD_FAILED; int ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; int ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; +int ogl_ext_EXT_framebuffer_object = ogl_LOAD_FAILED; void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1DARB)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; @@ -152,71 +151,401 @@ static int Load_ARB_shader_storage_buffer_object() return numFailed; } -void (CODEGEN_FUNCPTR *_ptrc_glBegin)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEnd)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindFramebufferEXT)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbufferEXT)(GLenum, GLuint) = NULL; +GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatusEXT)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffersEXT)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffersEXT)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbufferEXT)(GLenum, GLenum, GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1DEXT)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2DEXT)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3DEXT)(GLenum, GLenum, GLenum, GLuint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffersEXT)(GLsizei, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffersEXT)(GLsizei, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmapEXT)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameterivEXT)(GLenum, GLenum, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameterivEXT)(GLenum, GLenum, GLint *) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebufferEXT)(GLuint) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbufferEXT)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageEXT)(GLenum, GLenum, GLsizei, GLsizei) = NULL; +static int Load_EXT_framebuffer_object() +{ + int numFailed = 0; + _ptrc_glBindFramebufferEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindFramebufferEXT"); + if(!_ptrc_glBindFramebufferEXT) numFailed++; + _ptrc_glBindRenderbufferEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindRenderbufferEXT"); + if(!_ptrc_glBindRenderbufferEXT) numFailed++; + _ptrc_glCheckFramebufferStatusEXT = (GLenum (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glCheckFramebufferStatusEXT"); + if(!_ptrc_glCheckFramebufferStatusEXT) numFailed++; + _ptrc_glDeleteFramebuffersEXT = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteFramebuffersEXT"); + if(!_ptrc_glDeleteFramebuffersEXT) numFailed++; + _ptrc_glDeleteRenderbuffersEXT = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteRenderbuffersEXT"); + if(!_ptrc_glDeleteRenderbuffersEXT) numFailed++; + _ptrc_glFramebufferRenderbufferEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint))IntGetProcAddress("glFramebufferRenderbufferEXT"); + if(!_ptrc_glFramebufferRenderbufferEXT) numFailed++; + _ptrc_glFramebufferTexture1DEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress("glFramebufferTexture1DEXT"); + if(!_ptrc_glFramebufferTexture1DEXT) numFailed++; + _ptrc_glFramebufferTexture2DEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress("glFramebufferTexture2DEXT"); + if(!_ptrc_glFramebufferTexture2DEXT) numFailed++; + _ptrc_glFramebufferTexture3DEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint, GLint))IntGetProcAddress("glFramebufferTexture3DEXT"); + if(!_ptrc_glFramebufferTexture3DEXT) numFailed++; + _ptrc_glGenFramebuffersEXT = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenFramebuffersEXT"); + if(!_ptrc_glGenFramebuffersEXT) numFailed++; + _ptrc_glGenRenderbuffersEXT = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenRenderbuffersEXT"); + if(!_ptrc_glGenRenderbuffersEXT) numFailed++; + _ptrc_glGenerateMipmapEXT = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGenerateMipmapEXT"); + if(!_ptrc_glGenerateMipmapEXT) numFailed++; + _ptrc_glGetFramebufferAttachmentParameterivEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLint *))IntGetProcAddress("glGetFramebufferAttachmentParameterivEXT"); + if(!_ptrc_glGetFramebufferAttachmentParameterivEXT) numFailed++; + _ptrc_glGetRenderbufferParameterivEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetRenderbufferParameterivEXT"); + if(!_ptrc_glGetRenderbufferParameterivEXT) numFailed++; + _ptrc_glIsFramebufferEXT = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsFramebufferEXT"); + if(!_ptrc_glIsFramebufferEXT) numFailed++; + _ptrc_glIsRenderbufferEXT = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsRenderbufferEXT"); + if(!_ptrc_glIsRenderbufferEXT) numFailed++; + _ptrc_glRenderbufferStorageEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLsizei, GLsizei))IntGetProcAddress("glRenderbufferStorageEXT"); + if(!_ptrc_glRenderbufferStorageEXT) numFailed++; + return numFailed; +} + +void (CODEGEN_FUNCPTR *_ptrc_glAccum)(GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glAlphaFunc)(GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBegin)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBitmap)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCallList)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCallLists)(GLsizei, GLenum, const GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearAccum)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearIndex)(GLfloat) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClipPlane)(GLenum, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3b)(GLbyte, GLbyte, GLbyte) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3bv)(const GLbyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3d)(GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3f)(GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3i)(GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3s)(GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3sv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3ub)(GLubyte, GLubyte, GLubyte) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3ubv)(const GLubyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3ui)(GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3uiv)(const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3us)(GLushort, GLushort, GLushort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3usv)(const GLushort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4b)(GLbyte, GLbyte, GLbyte, GLbyte) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4bv)(const GLbyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4d)(GLdouble, GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4f)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4i)(GLint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4s)(GLshort, GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4sv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4ub)(GLubyte, GLubyte, GLubyte, GLubyte) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4ubv)(const GLubyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4ui)(GLuint, GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4uiv)(const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4us)(GLushort, GLushort, GLushort, GLushort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4usv)(const GLushort *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColorMaterial)(GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyPixels)(GLint, GLint, GLsizei, GLsizei, GLenum) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteLists)(GLuint, GLsizei) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble, GLdouble) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlag)(GLboolean) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagv)(const GLboolean *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnd)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndList)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1d)(GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1f)(GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2d)(GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2f)(GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh1)(GLenum, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh2)(GLenum, GLint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint1)(GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint2)(GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFeedbackBuffer)(GLsizei, GLenum, GLfloat *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glFinish)() = NULL; void (CODEGEN_FUNCPTR *_ptrc_glFlush)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogf)(GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogfv)(GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogi)(GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogiv)(GLenum, const GLint *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFrustum)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glGenLists)(GLsizei) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum, GLboolean *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetClipPlane)(GLenum, GLdouble *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum, GLdouble *) = NULL; GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)() = NULL; void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum, GLfloat *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetLightfv)(GLenum, GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetLightiv)(GLenum, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMapdv)(GLenum, GLenum, GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMapfv)(GLenum, GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMapiv)(GLenum, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialfv)(GLenum, GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialiv)(GLenum, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapfv)(GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapuiv)(GLenum, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapusv)(GLenum, GLushort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPolygonStipple)(GLubyte *) = NULL; const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnvfv)(GLenum, GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnviv)(GLenum, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexGendv)(GLenum, GLenum, GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexGenfv)(GLenum, GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexGeniv)(GLenum, GLenum, GLint *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum, GLenum, GLfloat *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum, GLenum, GLint *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexMask)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexd)(GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexdv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexf)(GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexfv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexi)(GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexiv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexs)(GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexsv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInitNames)() = NULL; GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsList)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightModelf)(GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightModelfv)(GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightModeli)(GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightModeliv)(GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightf)(GLenum, GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightfv)(GLenum, GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLighti)(GLenum, GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightiv)(GLenum, GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLineStipple)(GLint, GLushort) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glListBase)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadIdentity)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixd)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixf)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadName)(GLuint) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMap1d)(GLenum, GLdouble, GLdouble, GLint, GLint, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMap1f)(GLenum, GLfloat, GLfloat, GLint, GLint, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMap2d)(GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMap2f)(GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1d)(GLint, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1f)(GLint, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2d)(GLint, GLdouble, GLdouble, GLint, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2f)(GLint, GLfloat, GLfloat, GLint, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMaterialf)(GLenum, GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMaterialfv)(GLenum, GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMateriali)(GLenum, GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMaterialiv)(GLenum, GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMatrixMode)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixd)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixf)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNewList)(GLuint, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3b)(GLbyte, GLbyte, GLbyte) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3bv)(const GLbyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3d)(GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3f)(GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3i)(GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3s)(GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3sv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glOrtho)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPassThrough)(GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelMapfv)(GLenum, GLsizei, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelMapuiv)(GLenum, GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelMapusv)(GLenum, GLsizei, const GLushort *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum, GLfloat) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferf)(GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferi)(GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelZoom)(GLfloat, GLfloat) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPolygonStipple)(const GLubyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPopAttrib)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPopMatrix)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPopName)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPushAttrib)(GLbitfield) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPushMatrix)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPushName)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2d)(GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2f)(GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2i)(GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2s)(GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2sv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3d)(GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3f)(GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3i)(GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3s)(GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3sv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4f)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4i)(GLint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4s)(GLshort, GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4sv)(const GLshort *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectd)(GLdouble, GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectdv)(const GLdouble *, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectf)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectfv)(const GLfloat *, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRecti)(GLint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectiv)(const GLint *, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRects)(GLshort, GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectsv)(const GLshort *, const GLshort *) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glRenderMode)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRotated)(GLdouble, GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRotatef)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glScaled)(GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glScalef)(GLfloat, GLfloat, GLfloat) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint, GLint, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSelectBuffer)(GLsizei, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glShadeModel)(GLenum) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum, GLint, GLuint) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum, GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1d)(GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1f)(GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1i)(GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1s)(GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1sv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2d)(GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2f)(GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2i)(GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2s)(GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2sv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3d)(GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3f)(GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3i)(GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3s)(GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3sv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4d)(GLdouble, GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4f)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4i)(GLint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4s)(GLshort, GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4sv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexEnvf)(GLenum, GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexEnvfv)(GLenum, GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexEnvi)(GLenum, GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexEnviv)(GLenum, GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGend)(GLenum, GLenum, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGendv)(GLenum, GLenum, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGenf)(GLenum, GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGenfv)(GLenum, GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGeni)(GLenum, GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGeniv)(GLenum, GLenum, const GLint *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum, GLenum, GLfloat) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum, GLenum, const GLfloat *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum, GLenum, GLint) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum, GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTranslated)(GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTranslatef)(GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2d)(GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2f)(GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2i)(GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2s)(GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2sv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3d)(GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3f)(GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3i)(GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3s)(GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3sv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4d)(GLdouble, GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4f)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4i)(GLint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4s)(GLshort, GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4sv)(const GLshort *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint, GLint, GLsizei, GLsizei) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glAreTexturesResident)(GLsizei, const GLuint *, GLboolean *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glArrayElement)(GLint) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColorPointer)(GLint, GLenum, GLsizei, const GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisableClientState)(GLenum) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum, GLint, GLsizei) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum, GLsizei, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagPointer)(GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnableClientState)(GLenum) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPointerv)(GLenum, GLvoid **) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexPointer)(GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexub)(GLubyte) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexubv)(const GLubyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInterleavedArrays)(GLenum, GLsizei, const GLvoid *) = NULL; GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormalPointer)(GLenum, GLsizei, const GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPopClientAttrib)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPrioritizeTextures)(GLsizei, const GLuint *, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPushClientAttrib)(GLbitfield) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoordPointer)(GLint, GLenum, GLsizei, const GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexPointer)(GLint, GLenum, GLsizei, const GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum) = NULL; @@ -226,6 +555,7 @@ void (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsize void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClientActiveTexture)(GLenum) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; @@ -233,15 +563,89 @@ void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum, GLint, GLint, GL void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum, GLint, GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixd)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixf)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixd)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixf)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1d)(GLenum, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1dv)(GLenum, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1f)(GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1fv)(GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1i)(GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1iv)(GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1s)(GLenum, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1sv)(GLenum, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2d)(GLenum, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2dv)(GLenum, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2f)(GLenum, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2fv)(GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2i)(GLenum, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2iv)(GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2s)(GLenum, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2sv)(GLenum, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3d)(GLenum, GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3dv)(GLenum, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3f)(GLenum, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3fv)(GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3i)(GLenum, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3iv)(GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3s)(GLenum, GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3sv)(GLenum, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4d)(GLenum, GLdouble, GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4dv)(GLenum, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4f)(GLenum, GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4fv)(GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4i)(GLenum, GLint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4iv)(GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4s)(GLenum, GLshort, GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4sv)(GLenum, const GLshort *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat, GLboolean) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoordPointer)(GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoordd)(GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoorddv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoordf)(GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoordfv)(const GLfloat *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum, const GLint *, const GLsizei *, GLsizei) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum, GLfloat) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum, const GLfloat *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum, GLint) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3b)(GLbyte, GLbyte, GLbyte) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3bv)(const GLbyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3d)(GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3f)(GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3i)(GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3s)(GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3sv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ub)(GLubyte, GLubyte, GLubyte) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ubv)(const GLubyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ui)(GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3uiv)(const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3us)(GLushort, GLushort, GLushort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3usv)(const GLushort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColorPointer)(GLint, GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2d)(GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2f)(GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2i)(GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2s)(GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2sv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3d)(GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3dv)(const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3f)(GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3fv)(const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3i)(GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3iv)(const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3s)(GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3sv)(const GLshort *) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum, GLuint) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum, GLuint) = NULL; @@ -514,24 +918,108 @@ void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint, GLenum, GLboolean, con static int Load_Version_3_3() { int numFailed = 0; + _ptrc_glAccum = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glAccum"); + if(!_ptrc_glAccum) numFailed++; + _ptrc_glAlphaFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glAlphaFunc"); + if(!_ptrc_glAlphaFunc) numFailed++; _ptrc_glBegin = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glBegin"); if(!_ptrc_glBegin) numFailed++; - _ptrc_glEnd = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glEnd"); - if(!_ptrc_glEnd) numFailed++; + _ptrc_glBitmap = (void (CODEGEN_FUNCPTR *)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte *))IntGetProcAddress("glBitmap"); + if(!_ptrc_glBitmap) numFailed++; _ptrc_glBlendFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glBlendFunc"); if(!_ptrc_glBlendFunc) numFailed++; + _ptrc_glCallList = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glCallList"); + if(!_ptrc_glCallList) numFailed++; + _ptrc_glCallLists = (void (CODEGEN_FUNCPTR *)(GLsizei, GLenum, const GLvoid *))IntGetProcAddress("glCallLists"); + if(!_ptrc_glCallLists) numFailed++; _ptrc_glClear = (void (CODEGEN_FUNCPTR *)(GLbitfield))IntGetProcAddress("glClear"); if(!_ptrc_glClear) numFailed++; + _ptrc_glClearAccum = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glClearAccum"); + if(!_ptrc_glClearAccum) numFailed++; _ptrc_glClearColor = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glClearColor"); if(!_ptrc_glClearColor) numFailed++; _ptrc_glClearDepth = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress("glClearDepth"); if(!_ptrc_glClearDepth) numFailed++; + _ptrc_glClearIndex = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glClearIndex"); + if(!_ptrc_glClearIndex) numFailed++; _ptrc_glClearStencil = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress("glClearStencil"); if(!_ptrc_glClearStencil) numFailed++; + _ptrc_glClipPlane = (void (CODEGEN_FUNCPTR *)(GLenum, const GLdouble *))IntGetProcAddress("glClipPlane"); + if(!_ptrc_glClipPlane) numFailed++; + _ptrc_glColor3b = (void (CODEGEN_FUNCPTR *)(GLbyte, GLbyte, GLbyte))IntGetProcAddress("glColor3b"); + if(!_ptrc_glColor3b) numFailed++; + _ptrc_glColor3bv = (void (CODEGEN_FUNCPTR *)(const GLbyte *))IntGetProcAddress("glColor3bv"); + if(!_ptrc_glColor3bv) numFailed++; + _ptrc_glColor3d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glColor3d"); + if(!_ptrc_glColor3d) numFailed++; + _ptrc_glColor3dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glColor3dv"); + if(!_ptrc_glColor3dv) numFailed++; + _ptrc_glColor3f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glColor3f"); + if(!_ptrc_glColor3f) numFailed++; + _ptrc_glColor3fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glColor3fv"); + if(!_ptrc_glColor3fv) numFailed++; + _ptrc_glColor3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glColor3i"); + if(!_ptrc_glColor3i) numFailed++; + _ptrc_glColor3iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glColor3iv"); + if(!_ptrc_glColor3iv) numFailed++; + _ptrc_glColor3s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort))IntGetProcAddress("glColor3s"); + if(!_ptrc_glColor3s) numFailed++; + _ptrc_glColor3sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glColor3sv"); + if(!_ptrc_glColor3sv) numFailed++; + _ptrc_glColor3ub = (void (CODEGEN_FUNCPTR *)(GLubyte, GLubyte, GLubyte))IntGetProcAddress("glColor3ub"); + if(!_ptrc_glColor3ub) numFailed++; + _ptrc_glColor3ubv = (void (CODEGEN_FUNCPTR *)(const GLubyte *))IntGetProcAddress("glColor3ubv"); + if(!_ptrc_glColor3ubv) numFailed++; + _ptrc_glColor3ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress("glColor3ui"); + if(!_ptrc_glColor3ui) numFailed++; + _ptrc_glColor3uiv = (void (CODEGEN_FUNCPTR *)(const GLuint *))IntGetProcAddress("glColor3uiv"); + if(!_ptrc_glColor3uiv) numFailed++; + _ptrc_glColor3us = (void (CODEGEN_FUNCPTR *)(GLushort, GLushort, GLushort))IntGetProcAddress("glColor3us"); + if(!_ptrc_glColor3us) numFailed++; + _ptrc_glColor3usv = (void (CODEGEN_FUNCPTR *)(const GLushort *))IntGetProcAddress("glColor3usv"); + if(!_ptrc_glColor3usv) numFailed++; + _ptrc_glColor4b = (void (CODEGEN_FUNCPTR *)(GLbyte, GLbyte, GLbyte, GLbyte))IntGetProcAddress("glColor4b"); + if(!_ptrc_glColor4b) numFailed++; + _ptrc_glColor4bv = (void (CODEGEN_FUNCPTR *)(const GLbyte *))IntGetProcAddress("glColor4bv"); + if(!_ptrc_glColor4bv) numFailed++; + _ptrc_glColor4d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glColor4d"); + if(!_ptrc_glColor4d) numFailed++; + _ptrc_glColor4dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glColor4dv"); + if(!_ptrc_glColor4dv) numFailed++; + _ptrc_glColor4f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glColor4f"); + if(!_ptrc_glColor4f) numFailed++; + _ptrc_glColor4fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glColor4fv"); + if(!_ptrc_glColor4fv) numFailed++; + _ptrc_glColor4i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress("glColor4i"); + if(!_ptrc_glColor4i) numFailed++; + _ptrc_glColor4iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glColor4iv"); + if(!_ptrc_glColor4iv) numFailed++; + _ptrc_glColor4s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort, GLshort))IntGetProcAddress("glColor4s"); + if(!_ptrc_glColor4s) numFailed++; + _ptrc_glColor4sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glColor4sv"); + if(!_ptrc_glColor4sv) numFailed++; + _ptrc_glColor4ub = (void (CODEGEN_FUNCPTR *)(GLubyte, GLubyte, GLubyte, GLubyte))IntGetProcAddress("glColor4ub"); + if(!_ptrc_glColor4ub) numFailed++; + _ptrc_glColor4ubv = (void (CODEGEN_FUNCPTR *)(const GLubyte *))IntGetProcAddress("glColor4ubv"); + if(!_ptrc_glColor4ubv) numFailed++; + _ptrc_glColor4ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, GLuint))IntGetProcAddress("glColor4ui"); + if(!_ptrc_glColor4ui) numFailed++; + _ptrc_glColor4uiv = (void (CODEGEN_FUNCPTR *)(const GLuint *))IntGetProcAddress("glColor4uiv"); + if(!_ptrc_glColor4uiv) numFailed++; + _ptrc_glColor4us = (void (CODEGEN_FUNCPTR *)(GLushort, GLushort, GLushort, GLushort))IntGetProcAddress("glColor4us"); + if(!_ptrc_glColor4us) numFailed++; + _ptrc_glColor4usv = (void (CODEGEN_FUNCPTR *)(const GLushort *))IntGetProcAddress("glColor4usv"); + if(!_ptrc_glColor4usv) numFailed++; _ptrc_glColorMask = (void (CODEGEN_FUNCPTR *)(GLboolean, GLboolean, GLboolean, GLboolean))IntGetProcAddress("glColorMask"); if(!_ptrc_glColorMask) numFailed++; + _ptrc_glColorMaterial = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glColorMaterial"); + if(!_ptrc_glColorMaterial) numFailed++; + _ptrc_glCopyPixels = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei, GLenum))IntGetProcAddress("glCopyPixels"); + if(!_ptrc_glCopyPixels) numFailed++; _ptrc_glCullFace = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glCullFace"); if(!_ptrc_glCullFace) numFailed++; + _ptrc_glDeleteLists = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei))IntGetProcAddress("glDeleteLists"); + if(!_ptrc_glDeleteLists) numFailed++; _ptrc_glDepthFunc = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glDepthFunc"); if(!_ptrc_glDepthFunc) numFailed++; _ptrc_glDepthMask = (void (CODEGEN_FUNCPTR *)(GLboolean))IntGetProcAddress("glDepthMask"); @@ -542,16 +1030,66 @@ static int Load_Version_3_3() if(!_ptrc_glDisable) numFailed++; _ptrc_glDrawBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glDrawBuffer"); if(!_ptrc_glDrawBuffer) numFailed++; + _ptrc_glDrawPixels = (void (CODEGEN_FUNCPTR *)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glDrawPixels"); + if(!_ptrc_glDrawPixels) numFailed++; + _ptrc_glEdgeFlag = (void (CODEGEN_FUNCPTR *)(GLboolean))IntGetProcAddress("glEdgeFlag"); + if(!_ptrc_glEdgeFlag) numFailed++; + _ptrc_glEdgeFlagv = (void (CODEGEN_FUNCPTR *)(const GLboolean *))IntGetProcAddress("glEdgeFlagv"); + if(!_ptrc_glEdgeFlagv) numFailed++; _ptrc_glEnable = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glEnable"); if(!_ptrc_glEnable) numFailed++; + _ptrc_glEnd = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glEnd"); + if(!_ptrc_glEnd) numFailed++; + _ptrc_glEndList = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glEndList"); + if(!_ptrc_glEndList) numFailed++; + _ptrc_glEvalCoord1d = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress("glEvalCoord1d"); + if(!_ptrc_glEvalCoord1d) numFailed++; + _ptrc_glEvalCoord1dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glEvalCoord1dv"); + if(!_ptrc_glEvalCoord1dv) numFailed++; + _ptrc_glEvalCoord1f = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glEvalCoord1f"); + if(!_ptrc_glEvalCoord1f) numFailed++; + _ptrc_glEvalCoord1fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glEvalCoord1fv"); + if(!_ptrc_glEvalCoord1fv) numFailed++; + _ptrc_glEvalCoord2d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress("glEvalCoord2d"); + if(!_ptrc_glEvalCoord2d) numFailed++; + _ptrc_glEvalCoord2dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glEvalCoord2dv"); + if(!_ptrc_glEvalCoord2dv) numFailed++; + _ptrc_glEvalCoord2f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glEvalCoord2f"); + if(!_ptrc_glEvalCoord2f) numFailed++; + _ptrc_glEvalCoord2fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glEvalCoord2fv"); + if(!_ptrc_glEvalCoord2fv) numFailed++; + _ptrc_glEvalMesh1 = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint))IntGetProcAddress("glEvalMesh1"); + if(!_ptrc_glEvalMesh1) numFailed++; + _ptrc_glEvalMesh2 = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint))IntGetProcAddress("glEvalMesh2"); + if(!_ptrc_glEvalMesh2) numFailed++; + _ptrc_glEvalPoint1 = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress("glEvalPoint1"); + if(!_ptrc_glEvalPoint1) numFailed++; + _ptrc_glEvalPoint2 = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress("glEvalPoint2"); + if(!_ptrc_glEvalPoint2) numFailed++; + _ptrc_glFeedbackBuffer = (void (CODEGEN_FUNCPTR *)(GLsizei, GLenum, GLfloat *))IntGetProcAddress("glFeedbackBuffer"); + if(!_ptrc_glFeedbackBuffer) numFailed++; _ptrc_glFinish = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glFinish"); if(!_ptrc_glFinish) numFailed++; _ptrc_glFlush = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glFlush"); if(!_ptrc_glFlush) numFailed++; + _ptrc_glFogf = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glFogf"); + if(!_ptrc_glFogf) numFailed++; + _ptrc_glFogfv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress("glFogfv"); + if(!_ptrc_glFogfv) numFailed++; + _ptrc_glFogi = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress("glFogi"); + if(!_ptrc_glFogi) numFailed++; + _ptrc_glFogiv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glFogiv"); + if(!_ptrc_glFogiv) numFailed++; _ptrc_glFrontFace = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glFrontFace"); if(!_ptrc_glFrontFace) numFailed++; + _ptrc_glFrustum = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glFrustum"); + if(!_ptrc_glFrustum) numFailed++; + _ptrc_glGenLists = (GLuint (CODEGEN_FUNCPTR *)(GLsizei))IntGetProcAddress("glGenLists"); + if(!_ptrc_glGenLists) numFailed++; _ptrc_glGetBooleanv = (void (CODEGEN_FUNCPTR *)(GLenum, GLboolean *))IntGetProcAddress("glGetBooleanv"); if(!_ptrc_glGetBooleanv) numFailed++; + _ptrc_glGetClipPlane = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble *))IntGetProcAddress("glGetClipPlane"); + if(!_ptrc_glGetClipPlane) numFailed++; _ptrc_glGetDoublev = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble *))IntGetProcAddress("glGetDoublev"); if(!_ptrc_glGetDoublev) numFailed++; _ptrc_glGetError = (GLenum (CODEGEN_FUNCPTR *)())IntGetProcAddress("glGetError"); @@ -560,8 +1098,40 @@ static int Load_Version_3_3() if(!_ptrc_glGetFloatv) numFailed++; _ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress("glGetIntegerv"); if(!_ptrc_glGetIntegerv) numFailed++; + _ptrc_glGetLightfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress("glGetLightfv"); + if(!_ptrc_glGetLightfv) numFailed++; + _ptrc_glGetLightiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetLightiv"); + if(!_ptrc_glGetLightiv) numFailed++; + _ptrc_glGetMapdv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLdouble *))IntGetProcAddress("glGetMapdv"); + if(!_ptrc_glGetMapdv) numFailed++; + _ptrc_glGetMapfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress("glGetMapfv"); + if(!_ptrc_glGetMapfv) numFailed++; + _ptrc_glGetMapiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetMapiv"); + if(!_ptrc_glGetMapiv) numFailed++; + _ptrc_glGetMaterialfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress("glGetMaterialfv"); + if(!_ptrc_glGetMaterialfv) numFailed++; + _ptrc_glGetMaterialiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetMaterialiv"); + if(!_ptrc_glGetMaterialiv) numFailed++; + _ptrc_glGetPixelMapfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat *))IntGetProcAddress("glGetPixelMapfv"); + if(!_ptrc_glGetPixelMapfv) numFailed++; + _ptrc_glGetPixelMapuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint *))IntGetProcAddress("glGetPixelMapuiv"); + if(!_ptrc_glGetPixelMapuiv) numFailed++; + _ptrc_glGetPixelMapusv = (void (CODEGEN_FUNCPTR *)(GLenum, GLushort *))IntGetProcAddress("glGetPixelMapusv"); + if(!_ptrc_glGetPixelMapusv) numFailed++; + _ptrc_glGetPolygonStipple = (void (CODEGEN_FUNCPTR *)(GLubyte *))IntGetProcAddress("glGetPolygonStipple"); + if(!_ptrc_glGetPolygonStipple) numFailed++; _ptrc_glGetString = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGetString"); if(!_ptrc_glGetString) numFailed++; + _ptrc_glGetTexEnvfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress("glGetTexEnvfv"); + if(!_ptrc_glGetTexEnvfv) numFailed++; + _ptrc_glGetTexEnviv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetTexEnviv"); + if(!_ptrc_glGetTexEnviv) numFailed++; + _ptrc_glGetTexGendv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLdouble *))IntGetProcAddress("glGetTexGendv"); + if(!_ptrc_glGetTexGendv) numFailed++; + _ptrc_glGetTexGenfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress("glGetTexGenfv"); + if(!_ptrc_glGetTexGenfv) numFailed++; + _ptrc_glGetTexGeniv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetTexGeniv"); + if(!_ptrc_glGetTexGeniv) numFailed++; _ptrc_glGetTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLenum, GLvoid *))IntGetProcAddress("glGetTexImage"); if(!_ptrc_glGetTexImage) numFailed++; _ptrc_glGetTexLevelParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLfloat *))IntGetProcAddress("glGetTexLevelParameterfv"); @@ -574,32 +1144,326 @@ static int Load_Version_3_3() if(!_ptrc_glGetTexParameteriv) numFailed++; _ptrc_glHint = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glHint"); if(!_ptrc_glHint) numFailed++; + _ptrc_glIndexMask = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIndexMask"); + if(!_ptrc_glIndexMask) numFailed++; + _ptrc_glIndexd = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress("glIndexd"); + if(!_ptrc_glIndexd) numFailed++; + _ptrc_glIndexdv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glIndexdv"); + if(!_ptrc_glIndexdv) numFailed++; + _ptrc_glIndexf = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glIndexf"); + if(!_ptrc_glIndexf) numFailed++; + _ptrc_glIndexfv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glIndexfv"); + if(!_ptrc_glIndexfv) numFailed++; + _ptrc_glIndexi = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress("glIndexi"); + if(!_ptrc_glIndexi) numFailed++; + _ptrc_glIndexiv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glIndexiv"); + if(!_ptrc_glIndexiv) numFailed++; + _ptrc_glIndexs = (void (CODEGEN_FUNCPTR *)(GLshort))IntGetProcAddress("glIndexs"); + if(!_ptrc_glIndexs) numFailed++; + _ptrc_glIndexsv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glIndexsv"); + if(!_ptrc_glIndexsv) numFailed++; + _ptrc_glInitNames = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glInitNames"); + if(!_ptrc_glInitNames) numFailed++; _ptrc_glIsEnabled = (GLboolean (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glIsEnabled"); if(!_ptrc_glIsEnabled) numFailed++; + _ptrc_glIsList = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsList"); + if(!_ptrc_glIsList) numFailed++; + _ptrc_glLightModelf = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glLightModelf"); + if(!_ptrc_glLightModelf) numFailed++; + _ptrc_glLightModelfv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress("glLightModelfv"); + if(!_ptrc_glLightModelfv) numFailed++; + _ptrc_glLightModeli = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress("glLightModeli"); + if(!_ptrc_glLightModeli) numFailed++; + _ptrc_glLightModeliv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glLightModeliv"); + if(!_ptrc_glLightModeliv) numFailed++; + _ptrc_glLightf = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat))IntGetProcAddress("glLightf"); + if(!_ptrc_glLightf) numFailed++; + _ptrc_glLightfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLfloat *))IntGetProcAddress("glLightfv"); + if(!_ptrc_glLightfv) numFailed++; + _ptrc_glLighti = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint))IntGetProcAddress("glLighti"); + if(!_ptrc_glLighti) numFailed++; + _ptrc_glLightiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress("glLightiv"); + if(!_ptrc_glLightiv) numFailed++; + _ptrc_glLineStipple = (void (CODEGEN_FUNCPTR *)(GLint, GLushort))IntGetProcAddress("glLineStipple"); + if(!_ptrc_glLineStipple) numFailed++; _ptrc_glLineWidth = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glLineWidth"); if(!_ptrc_glLineWidth) numFailed++; + _ptrc_glListBase = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glListBase"); + if(!_ptrc_glListBase) numFailed++; + _ptrc_glLoadIdentity = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glLoadIdentity"); + if(!_ptrc_glLoadIdentity) numFailed++; + _ptrc_glLoadMatrixd = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glLoadMatrixd"); + if(!_ptrc_glLoadMatrixd) numFailed++; + _ptrc_glLoadMatrixf = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glLoadMatrixf"); + if(!_ptrc_glLoadMatrixf) numFailed++; + _ptrc_glLoadName = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glLoadName"); + if(!_ptrc_glLoadName) numFailed++; _ptrc_glLogicOp = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glLogicOp"); if(!_ptrc_glLogicOp) numFailed++; + _ptrc_glMap1d = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble, GLdouble, GLint, GLint, const GLdouble *))IntGetProcAddress("glMap1d"); + if(!_ptrc_glMap1d) numFailed++; + _ptrc_glMap1f = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat, GLfloat, GLint, GLint, const GLfloat *))IntGetProcAddress("glMap1f"); + if(!_ptrc_glMap1f) numFailed++; + _ptrc_glMap2d = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *))IntGetProcAddress("glMap2d"); + if(!_ptrc_glMap2d) numFailed++; + _ptrc_glMap2f = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *))IntGetProcAddress("glMap2f"); + if(!_ptrc_glMap2f) numFailed++; + _ptrc_glMapGrid1d = (void (CODEGEN_FUNCPTR *)(GLint, GLdouble, GLdouble))IntGetProcAddress("glMapGrid1d"); + if(!_ptrc_glMapGrid1d) numFailed++; + _ptrc_glMapGrid1f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat))IntGetProcAddress("glMapGrid1f"); + if(!_ptrc_glMapGrid1f) numFailed++; + _ptrc_glMapGrid2d = (void (CODEGEN_FUNCPTR *)(GLint, GLdouble, GLdouble, GLint, GLdouble, GLdouble))IntGetProcAddress("glMapGrid2d"); + if(!_ptrc_glMapGrid2d) numFailed++; + _ptrc_glMapGrid2f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat, GLint, GLfloat, GLfloat))IntGetProcAddress("glMapGrid2f"); + if(!_ptrc_glMapGrid2f) numFailed++; + _ptrc_glMaterialf = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat))IntGetProcAddress("glMaterialf"); + if(!_ptrc_glMaterialf) numFailed++; + _ptrc_glMaterialfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLfloat *))IntGetProcAddress("glMaterialfv"); + if(!_ptrc_glMaterialfv) numFailed++; + _ptrc_glMateriali = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint))IntGetProcAddress("glMateriali"); + if(!_ptrc_glMateriali) numFailed++; + _ptrc_glMaterialiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress("glMaterialiv"); + if(!_ptrc_glMaterialiv) numFailed++; + _ptrc_glMatrixMode = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glMatrixMode"); + if(!_ptrc_glMatrixMode) numFailed++; + _ptrc_glMultMatrixd = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glMultMatrixd"); + if(!_ptrc_glMultMatrixd) numFailed++; + _ptrc_glMultMatrixf = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glMultMatrixf"); + if(!_ptrc_glMultMatrixf) numFailed++; + _ptrc_glNewList = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum))IntGetProcAddress("glNewList"); + if(!_ptrc_glNewList) numFailed++; + _ptrc_glNormal3b = (void (CODEGEN_FUNCPTR *)(GLbyte, GLbyte, GLbyte))IntGetProcAddress("glNormal3b"); + if(!_ptrc_glNormal3b) numFailed++; + _ptrc_glNormal3bv = (void (CODEGEN_FUNCPTR *)(const GLbyte *))IntGetProcAddress("glNormal3bv"); + if(!_ptrc_glNormal3bv) numFailed++; + _ptrc_glNormal3d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glNormal3d"); + if(!_ptrc_glNormal3d) numFailed++; + _ptrc_glNormal3dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glNormal3dv"); + if(!_ptrc_glNormal3dv) numFailed++; + _ptrc_glNormal3f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glNormal3f"); + if(!_ptrc_glNormal3f) numFailed++; + _ptrc_glNormal3fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glNormal3fv"); + if(!_ptrc_glNormal3fv) numFailed++; + _ptrc_glNormal3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glNormal3i"); + if(!_ptrc_glNormal3i) numFailed++; + _ptrc_glNormal3iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glNormal3iv"); + if(!_ptrc_glNormal3iv) numFailed++; + _ptrc_glNormal3s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort))IntGetProcAddress("glNormal3s"); + if(!_ptrc_glNormal3s) numFailed++; + _ptrc_glNormal3sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glNormal3sv"); + if(!_ptrc_glNormal3sv) numFailed++; + _ptrc_glOrtho = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glOrtho"); + if(!_ptrc_glOrtho) numFailed++; + _ptrc_glPassThrough = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glPassThrough"); + if(!_ptrc_glPassThrough) numFailed++; + _ptrc_glPixelMapfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLfloat *))IntGetProcAddress("glPixelMapfv"); + if(!_ptrc_glPixelMapfv) numFailed++; + _ptrc_glPixelMapuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLuint *))IntGetProcAddress("glPixelMapuiv"); + if(!_ptrc_glPixelMapuiv) numFailed++; + _ptrc_glPixelMapusv = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLushort *))IntGetProcAddress("glPixelMapusv"); + if(!_ptrc_glPixelMapusv) numFailed++; _ptrc_glPixelStoref = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glPixelStoref"); if(!_ptrc_glPixelStoref) numFailed++; _ptrc_glPixelStorei = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress("glPixelStorei"); if(!_ptrc_glPixelStorei) numFailed++; + _ptrc_glPixelTransferf = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glPixelTransferf"); + if(!_ptrc_glPixelTransferf) numFailed++; + _ptrc_glPixelTransferi = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress("glPixelTransferi"); + if(!_ptrc_glPixelTransferi) numFailed++; + _ptrc_glPixelZoom = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glPixelZoom"); + if(!_ptrc_glPixelZoom) numFailed++; _ptrc_glPointSize = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glPointSize"); if(!_ptrc_glPointSize) numFailed++; _ptrc_glPolygonMode = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glPolygonMode"); if(!_ptrc_glPolygonMode) numFailed++; + _ptrc_glPolygonStipple = (void (CODEGEN_FUNCPTR *)(const GLubyte *))IntGetProcAddress("glPolygonStipple"); + if(!_ptrc_glPolygonStipple) numFailed++; + _ptrc_glPopAttrib = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glPopAttrib"); + if(!_ptrc_glPopAttrib) numFailed++; + _ptrc_glPopMatrix = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glPopMatrix"); + if(!_ptrc_glPopMatrix) numFailed++; + _ptrc_glPopName = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glPopName"); + if(!_ptrc_glPopName) numFailed++; + _ptrc_glPushAttrib = (void (CODEGEN_FUNCPTR *)(GLbitfield))IntGetProcAddress("glPushAttrib"); + if(!_ptrc_glPushAttrib) numFailed++; + _ptrc_glPushMatrix = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glPushMatrix"); + if(!_ptrc_glPushMatrix) numFailed++; + _ptrc_glPushName = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glPushName"); + if(!_ptrc_glPushName) numFailed++; + _ptrc_glRasterPos2d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress("glRasterPos2d"); + if(!_ptrc_glRasterPos2d) numFailed++; + _ptrc_glRasterPos2dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glRasterPos2dv"); + if(!_ptrc_glRasterPos2dv) numFailed++; + _ptrc_glRasterPos2f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glRasterPos2f"); + if(!_ptrc_glRasterPos2f) numFailed++; + _ptrc_glRasterPos2fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glRasterPos2fv"); + if(!_ptrc_glRasterPos2fv) numFailed++; + _ptrc_glRasterPos2i = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress("glRasterPos2i"); + if(!_ptrc_glRasterPos2i) numFailed++; + _ptrc_glRasterPos2iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glRasterPos2iv"); + if(!_ptrc_glRasterPos2iv) numFailed++; + _ptrc_glRasterPos2s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort))IntGetProcAddress("glRasterPos2s"); + if(!_ptrc_glRasterPos2s) numFailed++; + _ptrc_glRasterPos2sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glRasterPos2sv"); + if(!_ptrc_glRasterPos2sv) numFailed++; + _ptrc_glRasterPos3d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glRasterPos3d"); + if(!_ptrc_glRasterPos3d) numFailed++; + _ptrc_glRasterPos3dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glRasterPos3dv"); + if(!_ptrc_glRasterPos3dv) numFailed++; + _ptrc_glRasterPos3f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glRasterPos3f"); + if(!_ptrc_glRasterPos3f) numFailed++; + _ptrc_glRasterPos3fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glRasterPos3fv"); + if(!_ptrc_glRasterPos3fv) numFailed++; + _ptrc_glRasterPos3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glRasterPos3i"); + if(!_ptrc_glRasterPos3i) numFailed++; + _ptrc_glRasterPos3iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glRasterPos3iv"); + if(!_ptrc_glRasterPos3iv) numFailed++; + _ptrc_glRasterPos3s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort))IntGetProcAddress("glRasterPos3s"); + if(!_ptrc_glRasterPos3s) numFailed++; + _ptrc_glRasterPos3sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glRasterPos3sv"); + if(!_ptrc_glRasterPos3sv) numFailed++; + _ptrc_glRasterPos4d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glRasterPos4d"); + if(!_ptrc_glRasterPos4d) numFailed++; + _ptrc_glRasterPos4dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glRasterPos4dv"); + if(!_ptrc_glRasterPos4dv) numFailed++; + _ptrc_glRasterPos4f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glRasterPos4f"); + if(!_ptrc_glRasterPos4f) numFailed++; + _ptrc_glRasterPos4fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glRasterPos4fv"); + if(!_ptrc_glRasterPos4fv) numFailed++; + _ptrc_glRasterPos4i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress("glRasterPos4i"); + if(!_ptrc_glRasterPos4i) numFailed++; + _ptrc_glRasterPos4iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glRasterPos4iv"); + if(!_ptrc_glRasterPos4iv) numFailed++; + _ptrc_glRasterPos4s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort, GLshort))IntGetProcAddress("glRasterPos4s"); + if(!_ptrc_glRasterPos4s) numFailed++; + _ptrc_glRasterPos4sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glRasterPos4sv"); + if(!_ptrc_glRasterPos4sv) numFailed++; _ptrc_glReadBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glReadBuffer"); if(!_ptrc_glReadBuffer) numFailed++; _ptrc_glReadPixels = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *))IntGetProcAddress("glReadPixels"); if(!_ptrc_glReadPixels) numFailed++; + _ptrc_glRectd = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glRectd"); + if(!_ptrc_glRectd) numFailed++; + _ptrc_glRectdv = (void (CODEGEN_FUNCPTR *)(const GLdouble *, const GLdouble *))IntGetProcAddress("glRectdv"); + if(!_ptrc_glRectdv) numFailed++; + _ptrc_glRectf = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glRectf"); + if(!_ptrc_glRectf) numFailed++; + _ptrc_glRectfv = (void (CODEGEN_FUNCPTR *)(const GLfloat *, const GLfloat *))IntGetProcAddress("glRectfv"); + if(!_ptrc_glRectfv) numFailed++; + _ptrc_glRecti = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress("glRecti"); + if(!_ptrc_glRecti) numFailed++; + _ptrc_glRectiv = (void (CODEGEN_FUNCPTR *)(const GLint *, const GLint *))IntGetProcAddress("glRectiv"); + if(!_ptrc_glRectiv) numFailed++; + _ptrc_glRects = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort, GLshort))IntGetProcAddress("glRects"); + if(!_ptrc_glRects) numFailed++; + _ptrc_glRectsv = (void (CODEGEN_FUNCPTR *)(const GLshort *, const GLshort *))IntGetProcAddress("glRectsv"); + if(!_ptrc_glRectsv) numFailed++; + _ptrc_glRenderMode = (GLint (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glRenderMode"); + if(!_ptrc_glRenderMode) numFailed++; + _ptrc_glRotated = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glRotated"); + if(!_ptrc_glRotated) numFailed++; + _ptrc_glRotatef = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glRotatef"); + if(!_ptrc_glRotatef) numFailed++; + _ptrc_glScaled = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glScaled"); + if(!_ptrc_glScaled) numFailed++; + _ptrc_glScalef = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glScalef"); + if(!_ptrc_glScalef) numFailed++; _ptrc_glScissor = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glScissor"); if(!_ptrc_glScissor) numFailed++; + _ptrc_glSelectBuffer = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glSelectBuffer"); + if(!_ptrc_glSelectBuffer) numFailed++; + _ptrc_glShadeModel = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glShadeModel"); + if(!_ptrc_glShadeModel) numFailed++; _ptrc_glStencilFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLuint))IntGetProcAddress("glStencilFunc"); if(!_ptrc_glStencilFunc) numFailed++; _ptrc_glStencilMask = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glStencilMask"); if(!_ptrc_glStencilMask) numFailed++; _ptrc_glStencilOp = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum))IntGetProcAddress("glStencilOp"); if(!_ptrc_glStencilOp) numFailed++; + _ptrc_glTexCoord1d = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress("glTexCoord1d"); + if(!_ptrc_glTexCoord1d) numFailed++; + _ptrc_glTexCoord1dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glTexCoord1dv"); + if(!_ptrc_glTexCoord1dv) numFailed++; + _ptrc_glTexCoord1f = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glTexCoord1f"); + if(!_ptrc_glTexCoord1f) numFailed++; + _ptrc_glTexCoord1fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glTexCoord1fv"); + if(!_ptrc_glTexCoord1fv) numFailed++; + _ptrc_glTexCoord1i = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress("glTexCoord1i"); + if(!_ptrc_glTexCoord1i) numFailed++; + _ptrc_glTexCoord1iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glTexCoord1iv"); + if(!_ptrc_glTexCoord1iv) numFailed++; + _ptrc_glTexCoord1s = (void (CODEGEN_FUNCPTR *)(GLshort))IntGetProcAddress("glTexCoord1s"); + if(!_ptrc_glTexCoord1s) numFailed++; + _ptrc_glTexCoord1sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glTexCoord1sv"); + if(!_ptrc_glTexCoord1sv) numFailed++; + _ptrc_glTexCoord2d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress("glTexCoord2d"); + if(!_ptrc_glTexCoord2d) numFailed++; + _ptrc_glTexCoord2dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glTexCoord2dv"); + if(!_ptrc_glTexCoord2dv) numFailed++; + _ptrc_glTexCoord2f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glTexCoord2f"); + if(!_ptrc_glTexCoord2f) numFailed++; + _ptrc_glTexCoord2fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glTexCoord2fv"); + if(!_ptrc_glTexCoord2fv) numFailed++; + _ptrc_glTexCoord2i = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress("glTexCoord2i"); + if(!_ptrc_glTexCoord2i) numFailed++; + _ptrc_glTexCoord2iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glTexCoord2iv"); + if(!_ptrc_glTexCoord2iv) numFailed++; + _ptrc_glTexCoord2s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort))IntGetProcAddress("glTexCoord2s"); + if(!_ptrc_glTexCoord2s) numFailed++; + _ptrc_glTexCoord2sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glTexCoord2sv"); + if(!_ptrc_glTexCoord2sv) numFailed++; + _ptrc_glTexCoord3d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glTexCoord3d"); + if(!_ptrc_glTexCoord3d) numFailed++; + _ptrc_glTexCoord3dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glTexCoord3dv"); + if(!_ptrc_glTexCoord3dv) numFailed++; + _ptrc_glTexCoord3f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glTexCoord3f"); + if(!_ptrc_glTexCoord3f) numFailed++; + _ptrc_glTexCoord3fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glTexCoord3fv"); + if(!_ptrc_glTexCoord3fv) numFailed++; + _ptrc_glTexCoord3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glTexCoord3i"); + if(!_ptrc_glTexCoord3i) numFailed++; + _ptrc_glTexCoord3iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glTexCoord3iv"); + if(!_ptrc_glTexCoord3iv) numFailed++; + _ptrc_glTexCoord3s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort))IntGetProcAddress("glTexCoord3s"); + if(!_ptrc_glTexCoord3s) numFailed++; + _ptrc_glTexCoord3sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glTexCoord3sv"); + if(!_ptrc_glTexCoord3sv) numFailed++; + _ptrc_glTexCoord4d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glTexCoord4d"); + if(!_ptrc_glTexCoord4d) numFailed++; + _ptrc_glTexCoord4dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glTexCoord4dv"); + if(!_ptrc_glTexCoord4dv) numFailed++; + _ptrc_glTexCoord4f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glTexCoord4f"); + if(!_ptrc_glTexCoord4f) numFailed++; + _ptrc_glTexCoord4fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glTexCoord4fv"); + if(!_ptrc_glTexCoord4fv) numFailed++; + _ptrc_glTexCoord4i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress("glTexCoord4i"); + if(!_ptrc_glTexCoord4i) numFailed++; + _ptrc_glTexCoord4iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glTexCoord4iv"); + if(!_ptrc_glTexCoord4iv) numFailed++; + _ptrc_glTexCoord4s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort, GLshort))IntGetProcAddress("glTexCoord4s"); + if(!_ptrc_glTexCoord4s) numFailed++; + _ptrc_glTexCoord4sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glTexCoord4sv"); + if(!_ptrc_glTexCoord4sv) numFailed++; + _ptrc_glTexEnvf = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat))IntGetProcAddress("glTexEnvf"); + if(!_ptrc_glTexEnvf) numFailed++; + _ptrc_glTexEnvfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLfloat *))IntGetProcAddress("glTexEnvfv"); + if(!_ptrc_glTexEnvfv) numFailed++; + _ptrc_glTexEnvi = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint))IntGetProcAddress("glTexEnvi"); + if(!_ptrc_glTexEnvi) numFailed++; + _ptrc_glTexEnviv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress("glTexEnviv"); + if(!_ptrc_glTexEnviv) numFailed++; + _ptrc_glTexGend = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLdouble))IntGetProcAddress("glTexGend"); + if(!_ptrc_glTexGend) numFailed++; + _ptrc_glTexGendv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLdouble *))IntGetProcAddress("glTexGendv"); + if(!_ptrc_glTexGendv) numFailed++; + _ptrc_glTexGenf = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat))IntGetProcAddress("glTexGenf"); + if(!_ptrc_glTexGenf) numFailed++; + _ptrc_glTexGenfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLfloat *))IntGetProcAddress("glTexGenfv"); + if(!_ptrc_glTexGenfv) numFailed++; + _ptrc_glTexGeni = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint))IntGetProcAddress("glTexGeni"); + if(!_ptrc_glTexGeni) numFailed++; + _ptrc_glTexGeniv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress("glTexGeniv"); + if(!_ptrc_glTexGeniv) numFailed++; _ptrc_glTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexImage1D"); if(!_ptrc_glTexImage1D) numFailed++; _ptrc_glTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexImage2D"); @@ -612,10 +1476,68 @@ static int Load_Version_3_3() if(!_ptrc_glTexParameteri) numFailed++; _ptrc_glTexParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress("glTexParameteriv"); if(!_ptrc_glTexParameteriv) numFailed++; + _ptrc_glTranslated = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glTranslated"); + if(!_ptrc_glTranslated) numFailed++; + _ptrc_glTranslatef = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glTranslatef"); + if(!_ptrc_glTranslatef) numFailed++; + _ptrc_glVertex2d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress("glVertex2d"); + if(!_ptrc_glVertex2d) numFailed++; + _ptrc_glVertex2dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glVertex2dv"); + if(!_ptrc_glVertex2dv) numFailed++; + _ptrc_glVertex2f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glVertex2f"); + if(!_ptrc_glVertex2f) numFailed++; + _ptrc_glVertex2fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glVertex2fv"); + if(!_ptrc_glVertex2fv) numFailed++; + _ptrc_glVertex2i = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress("glVertex2i"); + if(!_ptrc_glVertex2i) numFailed++; + _ptrc_glVertex2iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glVertex2iv"); + if(!_ptrc_glVertex2iv) numFailed++; + _ptrc_glVertex2s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort))IntGetProcAddress("glVertex2s"); + if(!_ptrc_glVertex2s) numFailed++; + _ptrc_glVertex2sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glVertex2sv"); + if(!_ptrc_glVertex2sv) numFailed++; + _ptrc_glVertex3d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glVertex3d"); + if(!_ptrc_glVertex3d) numFailed++; + _ptrc_glVertex3dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glVertex3dv"); + if(!_ptrc_glVertex3dv) numFailed++; + _ptrc_glVertex3f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glVertex3f"); + if(!_ptrc_glVertex3f) numFailed++; + _ptrc_glVertex3fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glVertex3fv"); + if(!_ptrc_glVertex3fv) numFailed++; + _ptrc_glVertex3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glVertex3i"); + if(!_ptrc_glVertex3i) numFailed++; + _ptrc_glVertex3iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glVertex3iv"); + if(!_ptrc_glVertex3iv) numFailed++; + _ptrc_glVertex3s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort))IntGetProcAddress("glVertex3s"); + if(!_ptrc_glVertex3s) numFailed++; + _ptrc_glVertex3sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glVertex3sv"); + if(!_ptrc_glVertex3sv) numFailed++; + _ptrc_glVertex4d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glVertex4d"); + if(!_ptrc_glVertex4d) numFailed++; + _ptrc_glVertex4dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glVertex4dv"); + if(!_ptrc_glVertex4dv) numFailed++; + _ptrc_glVertex4f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glVertex4f"); + if(!_ptrc_glVertex4f) numFailed++; + _ptrc_glVertex4fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glVertex4fv"); + if(!_ptrc_glVertex4fv) numFailed++; + _ptrc_glVertex4i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress("glVertex4i"); + if(!_ptrc_glVertex4i) numFailed++; + _ptrc_glVertex4iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glVertex4iv"); + if(!_ptrc_glVertex4iv) numFailed++; + _ptrc_glVertex4s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort, GLshort))IntGetProcAddress("glVertex4s"); + if(!_ptrc_glVertex4s) numFailed++; + _ptrc_glVertex4sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glVertex4sv"); + if(!_ptrc_glVertex4sv) numFailed++; _ptrc_glViewport = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glViewport"); if(!_ptrc_glViewport) numFailed++; + _ptrc_glAreTexturesResident = (GLboolean (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *, GLboolean *))IntGetProcAddress("glAreTexturesResident"); + if(!_ptrc_glAreTexturesResident) numFailed++; + _ptrc_glArrayElement = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress("glArrayElement"); + if(!_ptrc_glArrayElement) numFailed++; _ptrc_glBindTexture = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindTexture"); if(!_ptrc_glBindTexture) numFailed++; + _ptrc_glColorPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glColorPointer"); + if(!_ptrc_glColorPointer) numFailed++; _ptrc_glCopyTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint))IntGetProcAddress("glCopyTexImage1D"); if(!_ptrc_glCopyTexImage1D) numFailed++; _ptrc_glCopyTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint))IntGetProcAddress("glCopyTexImage2D"); @@ -626,20 +1548,48 @@ static int Load_Version_3_3() if(!_ptrc_glCopyTexSubImage2D) numFailed++; _ptrc_glDeleteTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteTextures"); if(!_ptrc_glDeleteTextures) numFailed++; + _ptrc_glDisableClientState = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glDisableClientState"); + if(!_ptrc_glDisableClientState) numFailed++; _ptrc_glDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLsizei))IntGetProcAddress("glDrawArrays"); if(!_ptrc_glDrawArrays) numFailed++; _ptrc_glDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *))IntGetProcAddress("glDrawElements"); if(!_ptrc_glDrawElements) numFailed++; + _ptrc_glEdgeFlagPointer = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLvoid *))IntGetProcAddress("glEdgeFlagPointer"); + if(!_ptrc_glEdgeFlagPointer) numFailed++; + _ptrc_glEnableClientState = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glEnableClientState"); + if(!_ptrc_glEnableClientState) numFailed++; _ptrc_glGenTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenTextures"); if(!_ptrc_glGenTextures) numFailed++; + _ptrc_glGetPointerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLvoid **))IntGetProcAddress("glGetPointerv"); + if(!_ptrc_glGetPointerv) numFailed++; + _ptrc_glIndexPointer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glIndexPointer"); + if(!_ptrc_glIndexPointer) numFailed++; + _ptrc_glIndexub = (void (CODEGEN_FUNCPTR *)(GLubyte))IntGetProcAddress("glIndexub"); + if(!_ptrc_glIndexub) numFailed++; + _ptrc_glIndexubv = (void (CODEGEN_FUNCPTR *)(const GLubyte *))IntGetProcAddress("glIndexubv"); + if(!_ptrc_glIndexubv) numFailed++; + _ptrc_glInterleavedArrays = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glInterleavedArrays"); + if(!_ptrc_glInterleavedArrays) numFailed++; _ptrc_glIsTexture = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsTexture"); if(!_ptrc_glIsTexture) numFailed++; + _ptrc_glNormalPointer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glNormalPointer"); + if(!_ptrc_glNormalPointer) numFailed++; _ptrc_glPolygonOffset = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glPolygonOffset"); if(!_ptrc_glPolygonOffset) numFailed++; + _ptrc_glPopClientAttrib = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glPopClientAttrib"); + if(!_ptrc_glPopClientAttrib) numFailed++; + _ptrc_glPrioritizeTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *, const GLfloat *))IntGetProcAddress("glPrioritizeTextures"); + if(!_ptrc_glPrioritizeTextures) numFailed++; + _ptrc_glPushClientAttrib = (void (CODEGEN_FUNCPTR *)(GLbitfield))IntGetProcAddress("glPushClientAttrib"); + if(!_ptrc_glPushClientAttrib) numFailed++; + _ptrc_glTexCoordPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glTexCoordPointer"); + if(!_ptrc_glTexCoordPointer) numFailed++; _ptrc_glTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexSubImage1D"); if(!_ptrc_glTexSubImage1D) numFailed++; _ptrc_glTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexSubImage2D"); if(!_ptrc_glTexSubImage2D) numFailed++; + _ptrc_glVertexPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glVertexPointer"); + if(!_ptrc_glVertexPointer) numFailed++; _ptrc_glBlendColor = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glBlendColor"); if(!_ptrc_glBlendColor) numFailed++; _ptrc_glBlendEquation = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glBlendEquation"); @@ -654,6 +1604,8 @@ static int Load_Version_3_3() if(!_ptrc_glTexSubImage3D) numFailed++; _ptrc_glActiveTexture = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glActiveTexture"); if(!_ptrc_glActiveTexture) numFailed++; + _ptrc_glClientActiveTexture = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glClientActiveTexture"); + if(!_ptrc_glClientActiveTexture) numFailed++; _ptrc_glCompressedTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage1D"); if(!_ptrc_glCompressedTexImage1D) numFailed++; _ptrc_glCompressedTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage2D"); @@ -668,10 +1620,92 @@ static int Load_Version_3_3() if(!_ptrc_glCompressedTexSubImage3D) numFailed++; _ptrc_glGetCompressedTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLvoid *))IntGetProcAddress("glGetCompressedTexImage"); if(!_ptrc_glGetCompressedTexImage) numFailed++; + _ptrc_glLoadTransposeMatrixd = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glLoadTransposeMatrixd"); + if(!_ptrc_glLoadTransposeMatrixd) numFailed++; + _ptrc_glLoadTransposeMatrixf = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glLoadTransposeMatrixf"); + if(!_ptrc_glLoadTransposeMatrixf) numFailed++; + _ptrc_glMultTransposeMatrixd = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glMultTransposeMatrixd"); + if(!_ptrc_glMultTransposeMatrixd) numFailed++; + _ptrc_glMultTransposeMatrixf = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glMultTransposeMatrixf"); + if(!_ptrc_glMultTransposeMatrixf) numFailed++; + _ptrc_glMultiTexCoord1d = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble))IntGetProcAddress("glMultiTexCoord1d"); + if(!_ptrc_glMultiTexCoord1d) numFailed++; + _ptrc_glMultiTexCoord1dv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLdouble *))IntGetProcAddress("glMultiTexCoord1dv"); + if(!_ptrc_glMultiTexCoord1dv) numFailed++; + _ptrc_glMultiTexCoord1f = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glMultiTexCoord1f"); + if(!_ptrc_glMultiTexCoord1f) numFailed++; + _ptrc_glMultiTexCoord1fv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress("glMultiTexCoord1fv"); + if(!_ptrc_glMultiTexCoord1fv) numFailed++; + _ptrc_glMultiTexCoord1i = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress("glMultiTexCoord1i"); + if(!_ptrc_glMultiTexCoord1i) numFailed++; + _ptrc_glMultiTexCoord1iv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glMultiTexCoord1iv"); + if(!_ptrc_glMultiTexCoord1iv) numFailed++; + _ptrc_glMultiTexCoord1s = (void (CODEGEN_FUNCPTR *)(GLenum, GLshort))IntGetProcAddress("glMultiTexCoord1s"); + if(!_ptrc_glMultiTexCoord1s) numFailed++; + _ptrc_glMultiTexCoord1sv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLshort *))IntGetProcAddress("glMultiTexCoord1sv"); + if(!_ptrc_glMultiTexCoord1sv) numFailed++; + _ptrc_glMultiTexCoord2d = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble, GLdouble))IntGetProcAddress("glMultiTexCoord2d"); + if(!_ptrc_glMultiTexCoord2d) numFailed++; + _ptrc_glMultiTexCoord2dv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLdouble *))IntGetProcAddress("glMultiTexCoord2dv"); + if(!_ptrc_glMultiTexCoord2dv) numFailed++; + _ptrc_glMultiTexCoord2f = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat, GLfloat))IntGetProcAddress("glMultiTexCoord2f"); + if(!_ptrc_glMultiTexCoord2f) numFailed++; + _ptrc_glMultiTexCoord2fv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress("glMultiTexCoord2fv"); + if(!_ptrc_glMultiTexCoord2fv) numFailed++; + _ptrc_glMultiTexCoord2i = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint))IntGetProcAddress("glMultiTexCoord2i"); + if(!_ptrc_glMultiTexCoord2i) numFailed++; + _ptrc_glMultiTexCoord2iv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glMultiTexCoord2iv"); + if(!_ptrc_glMultiTexCoord2iv) numFailed++; + _ptrc_glMultiTexCoord2s = (void (CODEGEN_FUNCPTR *)(GLenum, GLshort, GLshort))IntGetProcAddress("glMultiTexCoord2s"); + if(!_ptrc_glMultiTexCoord2s) numFailed++; + _ptrc_glMultiTexCoord2sv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLshort *))IntGetProcAddress("glMultiTexCoord2sv"); + if(!_ptrc_glMultiTexCoord2sv) numFailed++; + _ptrc_glMultiTexCoord3d = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glMultiTexCoord3d"); + if(!_ptrc_glMultiTexCoord3d) numFailed++; + _ptrc_glMultiTexCoord3dv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLdouble *))IntGetProcAddress("glMultiTexCoord3dv"); + if(!_ptrc_glMultiTexCoord3dv) numFailed++; + _ptrc_glMultiTexCoord3f = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glMultiTexCoord3f"); + if(!_ptrc_glMultiTexCoord3f) numFailed++; + _ptrc_glMultiTexCoord3fv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress("glMultiTexCoord3fv"); + if(!_ptrc_glMultiTexCoord3fv) numFailed++; + _ptrc_glMultiTexCoord3i = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint))IntGetProcAddress("glMultiTexCoord3i"); + if(!_ptrc_glMultiTexCoord3i) numFailed++; + _ptrc_glMultiTexCoord3iv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glMultiTexCoord3iv"); + if(!_ptrc_glMultiTexCoord3iv) numFailed++; + _ptrc_glMultiTexCoord3s = (void (CODEGEN_FUNCPTR *)(GLenum, GLshort, GLshort, GLshort))IntGetProcAddress("glMultiTexCoord3s"); + if(!_ptrc_glMultiTexCoord3s) numFailed++; + _ptrc_glMultiTexCoord3sv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLshort *))IntGetProcAddress("glMultiTexCoord3sv"); + if(!_ptrc_glMultiTexCoord3sv) numFailed++; + _ptrc_glMultiTexCoord4d = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glMultiTexCoord4d"); + if(!_ptrc_glMultiTexCoord4d) numFailed++; + _ptrc_glMultiTexCoord4dv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLdouble *))IntGetProcAddress("glMultiTexCoord4dv"); + if(!_ptrc_glMultiTexCoord4dv) numFailed++; + _ptrc_glMultiTexCoord4f = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glMultiTexCoord4f"); + if(!_ptrc_glMultiTexCoord4f) numFailed++; + _ptrc_glMultiTexCoord4fv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress("glMultiTexCoord4fv"); + if(!_ptrc_glMultiTexCoord4fv) numFailed++; + _ptrc_glMultiTexCoord4i = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint))IntGetProcAddress("glMultiTexCoord4i"); + if(!_ptrc_glMultiTexCoord4i) numFailed++; + _ptrc_glMultiTexCoord4iv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glMultiTexCoord4iv"); + if(!_ptrc_glMultiTexCoord4iv) numFailed++; + _ptrc_glMultiTexCoord4s = (void (CODEGEN_FUNCPTR *)(GLenum, GLshort, GLshort, GLshort, GLshort))IntGetProcAddress("glMultiTexCoord4s"); + if(!_ptrc_glMultiTexCoord4s) numFailed++; + _ptrc_glMultiTexCoord4sv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLshort *))IntGetProcAddress("glMultiTexCoord4sv"); + if(!_ptrc_glMultiTexCoord4sv) numFailed++; _ptrc_glSampleCoverage = (void (CODEGEN_FUNCPTR *)(GLfloat, GLboolean))IntGetProcAddress("glSampleCoverage"); if(!_ptrc_glSampleCoverage) numFailed++; _ptrc_glBlendFuncSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum))IntGetProcAddress("glBlendFuncSeparate"); if(!_ptrc_glBlendFuncSeparate) numFailed++; + _ptrc_glFogCoordPointer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glFogCoordPointer"); + if(!_ptrc_glFogCoordPointer) numFailed++; + _ptrc_glFogCoordd = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress("glFogCoordd"); + if(!_ptrc_glFogCoordd) numFailed++; + _ptrc_glFogCoorddv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glFogCoorddv"); + if(!_ptrc_glFogCoorddv) numFailed++; + _ptrc_glFogCoordf = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glFogCoordf"); + if(!_ptrc_glFogCoordf) numFailed++; + _ptrc_glFogCoordfv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glFogCoordfv"); + if(!_ptrc_glFogCoordfv) numFailed++; _ptrc_glMultiDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *, const GLsizei *, GLsizei))IntGetProcAddress("glMultiDrawArrays"); if(!_ptrc_glMultiDrawArrays) numFailed++; _ptrc_glMultiDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei))IntGetProcAddress("glMultiDrawElements"); @@ -684,6 +1718,72 @@ static int Load_Version_3_3() if(!_ptrc_glPointParameteri) numFailed++; _ptrc_glPointParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glPointParameteriv"); if(!_ptrc_glPointParameteriv) numFailed++; + _ptrc_glSecondaryColor3b = (void (CODEGEN_FUNCPTR *)(GLbyte, GLbyte, GLbyte))IntGetProcAddress("glSecondaryColor3b"); + if(!_ptrc_glSecondaryColor3b) numFailed++; + _ptrc_glSecondaryColor3bv = (void (CODEGEN_FUNCPTR *)(const GLbyte *))IntGetProcAddress("glSecondaryColor3bv"); + if(!_ptrc_glSecondaryColor3bv) numFailed++; + _ptrc_glSecondaryColor3d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glSecondaryColor3d"); + if(!_ptrc_glSecondaryColor3d) numFailed++; + _ptrc_glSecondaryColor3dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glSecondaryColor3dv"); + if(!_ptrc_glSecondaryColor3dv) numFailed++; + _ptrc_glSecondaryColor3f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glSecondaryColor3f"); + if(!_ptrc_glSecondaryColor3f) numFailed++; + _ptrc_glSecondaryColor3fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glSecondaryColor3fv"); + if(!_ptrc_glSecondaryColor3fv) numFailed++; + _ptrc_glSecondaryColor3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glSecondaryColor3i"); + if(!_ptrc_glSecondaryColor3i) numFailed++; + _ptrc_glSecondaryColor3iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glSecondaryColor3iv"); + if(!_ptrc_glSecondaryColor3iv) numFailed++; + _ptrc_glSecondaryColor3s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort))IntGetProcAddress("glSecondaryColor3s"); + if(!_ptrc_glSecondaryColor3s) numFailed++; + _ptrc_glSecondaryColor3sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glSecondaryColor3sv"); + if(!_ptrc_glSecondaryColor3sv) numFailed++; + _ptrc_glSecondaryColor3ub = (void (CODEGEN_FUNCPTR *)(GLubyte, GLubyte, GLubyte))IntGetProcAddress("glSecondaryColor3ub"); + if(!_ptrc_glSecondaryColor3ub) numFailed++; + _ptrc_glSecondaryColor3ubv = (void (CODEGEN_FUNCPTR *)(const GLubyte *))IntGetProcAddress("glSecondaryColor3ubv"); + if(!_ptrc_glSecondaryColor3ubv) numFailed++; + _ptrc_glSecondaryColor3ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress("glSecondaryColor3ui"); + if(!_ptrc_glSecondaryColor3ui) numFailed++; + _ptrc_glSecondaryColor3uiv = (void (CODEGEN_FUNCPTR *)(const GLuint *))IntGetProcAddress("glSecondaryColor3uiv"); + if(!_ptrc_glSecondaryColor3uiv) numFailed++; + _ptrc_glSecondaryColor3us = (void (CODEGEN_FUNCPTR *)(GLushort, GLushort, GLushort))IntGetProcAddress("glSecondaryColor3us"); + if(!_ptrc_glSecondaryColor3us) numFailed++; + _ptrc_glSecondaryColor3usv = (void (CODEGEN_FUNCPTR *)(const GLushort *))IntGetProcAddress("glSecondaryColor3usv"); + if(!_ptrc_glSecondaryColor3usv) numFailed++; + _ptrc_glSecondaryColorPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glSecondaryColorPointer"); + if(!_ptrc_glSecondaryColorPointer) numFailed++; + _ptrc_glWindowPos2d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress("glWindowPos2d"); + if(!_ptrc_glWindowPos2d) numFailed++; + _ptrc_glWindowPos2dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glWindowPos2dv"); + if(!_ptrc_glWindowPos2dv) numFailed++; + _ptrc_glWindowPos2f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glWindowPos2f"); + if(!_ptrc_glWindowPos2f) numFailed++; + _ptrc_glWindowPos2fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glWindowPos2fv"); + if(!_ptrc_glWindowPos2fv) numFailed++; + _ptrc_glWindowPos2i = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress("glWindowPos2i"); + if(!_ptrc_glWindowPos2i) numFailed++; + _ptrc_glWindowPos2iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glWindowPos2iv"); + if(!_ptrc_glWindowPos2iv) numFailed++; + _ptrc_glWindowPos2s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort))IntGetProcAddress("glWindowPos2s"); + if(!_ptrc_glWindowPos2s) numFailed++; + _ptrc_glWindowPos2sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glWindowPos2sv"); + if(!_ptrc_glWindowPos2sv) numFailed++; + _ptrc_glWindowPos3d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glWindowPos3d"); + if(!_ptrc_glWindowPos3d) numFailed++; + _ptrc_glWindowPos3dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glWindowPos3dv"); + if(!_ptrc_glWindowPos3dv) numFailed++; + _ptrc_glWindowPos3f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glWindowPos3f"); + if(!_ptrc_glWindowPos3f) numFailed++; + _ptrc_glWindowPos3fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glWindowPos3fv"); + if(!_ptrc_glWindowPos3fv) numFailed++; + _ptrc_glWindowPos3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glWindowPos3i"); + if(!_ptrc_glWindowPos3i) numFailed++; + _ptrc_glWindowPos3iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glWindowPos3iv"); + if(!_ptrc_glWindowPos3iv) numFailed++; + _ptrc_glWindowPos3s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort))IntGetProcAddress("glWindowPos3s"); + if(!_ptrc_glWindowPos3s) numFailed++; + _ptrc_glWindowPos3sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glWindowPos3sv"); + if(!_ptrc_glWindowPos3sv) numFailed++; _ptrc_glBeginQuery = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBeginQuery"); if(!_ptrc_glBeginQuery) numFailed++; _ptrc_glBindBuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindBuffer"); @@ -1217,16 +2317,17 @@ typedef struct ogl_StrToExtMap_s PFN_LOADFUNCPOINTERS LoadExtension; } ogl_StrToExtMap; -static ogl_StrToExtMap ExtensionMap[6] = { +static ogl_StrToExtMap ExtensionMap[7] = { {"GL_ARB_texture_compression", &ogl_ext_ARB_texture_compression, Load_ARB_texture_compression}, {"GL_EXT_texture_compression_s3tc", &ogl_ext_EXT_texture_compression_s3tc, NULL}, {"GL_ARB_buffer_storage", &ogl_ext_ARB_buffer_storage, Load_ARB_buffer_storage}, {"GL_ARB_shader_storage_buffer_object", &ogl_ext_ARB_shader_storage_buffer_object, Load_ARB_shader_storage_buffer_object}, {"GL_EXT_texture_sRGB", &ogl_ext_EXT_texture_sRGB, NULL}, {"GL_EXT_texture_filter_anisotropic", &ogl_ext_EXT_texture_filter_anisotropic, NULL}, + {"GL_EXT_framebuffer_object", &ogl_ext_EXT_framebuffer_object, Load_EXT_framebuffer_object}, }; -static int g_extensionMapSize = 6; +static int g_extensionMapSize = 7; static ogl_StrToExtMap *FindExtEntry(const char *extensionName) { @@ -1249,6 +2350,7 @@ static void ClearExtensionVars() ogl_ext_ARB_shader_storage_buffer_object = ogl_LOAD_FAILED; ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; + ogl_ext_EXT_framebuffer_object = ogl_LOAD_FAILED; } diff --git a/src/gl/system/gl_load.h b/src/gl/system/gl_load.h index 307f3893a..e5af1a23c 100644 --- a/src/gl/system/gl_load.h +++ b/src/gl/system/gl_load.h @@ -159,6 +159,7 @@ extern int ogl_ext_ARB_buffer_storage; extern int ogl_ext_ARB_shader_storage_buffer_object; extern int ogl_ext_EXT_texture_sRGB; extern int ogl_ext_EXT_texture_filter_anisotropic; +extern int ogl_ext_EXT_framebuffer_object; #define GL_COMPRESSED_ALPHA_ARB 0x84E9 #define GL_COMPRESSED_INTENSITY_ARB 0x84EC @@ -225,54 +226,220 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 + +#define GL_2D 0x0600 +#define GL_2_BYTES 0x1407 +#define GL_3D 0x0601 +#define GL_3D_COLOR 0x0602 +#define GL_3D_COLOR_TEXTURE 0x0603 +#define GL_3_BYTES 0x1408 +#define GL_4D_COLOR_TEXTURE 0x0604 +#define GL_4_BYTES 0x1409 +#define GL_ACCUM 0x0100 +#define GL_ACCUM_ALPHA_BITS 0x0D5B +#define GL_ACCUM_BLUE_BITS 0x0D5A +#define GL_ACCUM_BUFFER_BIT 0x00000200 +#define GL_ACCUM_CLEAR_VALUE 0x0B80 +#define GL_ACCUM_GREEN_BITS 0x0D59 +#define GL_ACCUM_RED_BITS 0x0D58 +#define GL_ADD 0x0104 +#define GL_ALL_ATTRIB_BITS 0xFFFFFFFF #define GL_ALPHA 0x1906 +#define GL_ALPHA12 0x803D +#define GL_ALPHA16 0x803E +#define GL_ALPHA4 0x803B +#define GL_ALPHA8 0x803C +#define GL_ALPHA_BIAS 0x0D1D +#define GL_ALPHA_BITS 0x0D55 +#define GL_ALPHA_SCALE 0x0D1C +#define GL_ALPHA_TEST 0x0BC0 +#define GL_ALPHA_TEST_FUNC 0x0BC1 +#define GL_ALPHA_TEST_REF 0x0BC2 #define GL_ALWAYS 0x0207 +#define GL_AMBIENT 0x1200 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 #define GL_AND 0x1501 #define GL_AND_INVERTED 0x1504 #define GL_AND_REVERSE 0x1502 +#define GL_ATTRIB_STACK_DEPTH 0x0BB0 +#define GL_AUTO_NORMAL 0x0D80 +#define GL_AUX0 0x0409 +#define GL_AUX1 0x040A +#define GL_AUX2 0x040B +#define GL_AUX3 0x040C +#define GL_AUX_BUFFERS 0x0C00 #define GL_BACK 0x0405 #define GL_BACK_LEFT 0x0402 #define GL_BACK_RIGHT 0x0403 +#define GL_BITMAP 0x1A00 +#define GL_BITMAP_TOKEN 0x0704 #define GL_BLEND 0x0BE2 #define GL_BLEND_DST 0x0BE0 #define GL_BLEND_SRC 0x0BE1 #define GL_BLUE 0x1905 +#define GL_BLUE_BIAS 0x0D1B +#define GL_BLUE_BITS 0x0D54 +#define GL_BLUE_SCALE 0x0D1A #define GL_BYTE 0x1400 +#define GL_C3F_V3F 0x2A24 +#define GL_C4F_N3F_V3F 0x2A26 +#define GL_C4UB_V2F 0x2A22 +#define GL_C4UB_V3F 0x2A23 #define GL_CCW 0x0901 +#define GL_CLAMP 0x2900 #define GL_CLEAR 0x1500 +#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF +#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 +#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 +#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 +#define GL_COEFF 0x0A00 #define GL_COLOR 0x1800 +#define GL_COLOR_ARRAY 0x8076 +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_COLOR_ARRAY_TYPE 0x8082 #define GL_COLOR_BUFFER_BIT 0x00004000 #define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_INDEX 0x1900 +#define GL_COLOR_INDEXES 0x1603 #define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_COLOR_MATERIAL_FACE 0x0B55 +#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 #define GL_COLOR_WRITEMASK 0x0C23 +#define GL_COMPILE 0x1300 +#define GL_COMPILE_AND_EXECUTE 0x1301 +#define GL_CONSTANT_ATTENUATION 0x1207 #define GL_COPY 0x1503 #define GL_COPY_INVERTED 0x150C +#define GL_COPY_PIXEL_TOKEN 0x0706 #define GL_CULL_FACE 0x0B44 #define GL_CULL_FACE_MODE 0x0B45 +#define GL_CURRENT_BIT 0x00000001 +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_INDEX 0x0B01 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_RASTER_COLOR 0x0B04 +#define GL_CURRENT_RASTER_DISTANCE 0x0B09 +#define GL_CURRENT_RASTER_INDEX 0x0B05 +#define GL_CURRENT_RASTER_POSITION 0x0B07 +#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 +#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 #define GL_CW 0x0900 +#define GL_DECAL 0x2101 #define GL_DECR 0x1E03 #define GL_DEPTH 0x1801 +#define GL_DEPTH_BIAS 0x0D1F +#define GL_DEPTH_BITS 0x0D56 #define GL_DEPTH_BUFFER_BIT 0x00000100 #define GL_DEPTH_CLEAR_VALUE 0x0B73 #define GL_DEPTH_COMPONENT 0x1902 #define GL_DEPTH_FUNC 0x0B74 #define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_SCALE 0x0D1E #define GL_DEPTH_TEST 0x0B71 #define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DIFFUSE 0x1201 #define GL_DITHER 0x0BD0 +#define GL_DOMAIN 0x0A02 #define GL_DONT_CARE 0x1100 #define GL_DOUBLE 0x140A #define GL_DOUBLEBUFFER 0x0C32 #define GL_DRAW_BUFFER 0x0C01 +#define GL_DRAW_PIXEL_TOKEN 0x0705 #define GL_DST_ALPHA 0x0304 #define GL_DST_COLOR 0x0306 +#define GL_EDGE_FLAG 0x0B43 +#define GL_EDGE_FLAG_ARRAY 0x8079 +#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 +#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C +#define GL_EMISSION 0x1600 +#define GL_ENABLE_BIT 0x00002000 #define GL_EQUAL 0x0202 #define GL_EQUIV 0x1509 +#define GL_EVAL_BIT 0x00010000 +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 #define GL_EXTENSIONS 0x1F03 +#define GL_EYE_LINEAR 0x2400 +#define GL_EYE_PLANE 0x2502 #define GL_FALSE 0 #define GL_FASTEST 0x1101 +#define GL_FEEDBACK 0x1C01 +#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 +#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 +#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 #define GL_FILL 0x1B02 +#define GL_FLAT 0x1D00 #define GL_FLOAT 0x1406 +#define GL_FOG 0x0B60 +#define GL_FOG_BIT 0x00000080 +#define GL_FOG_COLOR 0x0B66 +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_END 0x0B64 +#define GL_FOG_HINT 0x0C54 +#define GL_FOG_INDEX 0x0B61 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_START 0x0B63 #define GL_FRONT 0x0404 #define GL_FRONT_AND_BACK 0x0408 #define GL_FRONT_FACE 0x0B46 @@ -281,8 +448,28 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_GEQUAL 0x0206 #define GL_GREATER 0x0204 #define GL_GREEN 0x1904 +#define GL_GREEN_BIAS 0x0D19 +#define GL_GREEN_BITS 0x0D53 +#define GL_GREEN_SCALE 0x0D18 +#define GL_HINT_BIT 0x00008000 #define GL_INCR 0x1E02 +#define GL_INDEX_ARRAY 0x8077 +#define GL_INDEX_ARRAY_POINTER 0x8091 +#define GL_INDEX_ARRAY_STRIDE 0x8086 +#define GL_INDEX_ARRAY_TYPE 0x8085 +#define GL_INDEX_BITS 0x0D51 +#define GL_INDEX_CLEAR_VALUE 0x0C20 +#define GL_INDEX_LOGIC_OP 0x0BF1 +#define GL_INDEX_MODE 0x0C30 +#define GL_INDEX_OFFSET 0x0D13 +#define GL_INDEX_SHIFT 0x0D12 +#define GL_INDEX_WRITEMASK 0x0C21 #define GL_INT 0x1404 +#define GL_INTENSITY 0x8049 +#define GL_INTENSITY12 0x804C +#define GL_INTENSITY16 0x804D +#define GL_INTENSITY4 0x804A +#define GL_INTENSITY8 0x804B #define GL_INVALID_ENUM 0x0500 #define GL_INVALID_OPERATION 0x0502 #define GL_INVALID_VALUE 0x0501 @@ -291,21 +478,102 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_LEFT 0x0406 #define GL_LEQUAL 0x0203 #define GL_LESS 0x0201 +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 +#define GL_LIGHTING 0x0B50 +#define GL_LIGHTING_BIT 0x00000040 +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 #define GL_LINE 0x1B01 #define GL_LINEAR 0x2601 +#define GL_LINEAR_ATTENUATION 0x1208 #define GL_LINEAR_MIPMAP_LINEAR 0x2703 #define GL_LINEAR_MIPMAP_NEAREST 0x2701 #define GL_LINES 0x0001 +#define GL_LINE_BIT 0x00000004 #define GL_LINE_LOOP 0x0002 +#define GL_LINE_RESET_TOKEN 0x0707 #define GL_LINE_SMOOTH 0x0B20 #define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_LINE_STIPPLE 0x0B24 +#define GL_LINE_STIPPLE_PATTERN 0x0B25 +#define GL_LINE_STIPPLE_REPEAT 0x0B26 #define GL_LINE_STRIP 0x0003 +#define GL_LINE_TOKEN 0x0702 #define GL_LINE_WIDTH 0x0B21 #define GL_LINE_WIDTH_GRANULARITY 0x0B23 #define GL_LINE_WIDTH_RANGE 0x0B22 +#define GL_LIST_BASE 0x0B32 +#define GL_LIST_BIT 0x00020000 +#define GL_LIST_INDEX 0x0B33 +#define GL_LIST_MODE 0x0B30 +#define GL_LOAD 0x0101 +#define GL_LOGIC_OP 0x0BF1 #define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE12 0x8041 +#define GL_LUMINANCE12_ALPHA12 0x8047 +#define GL_LUMINANCE12_ALPHA4 0x8046 +#define GL_LUMINANCE16 0x8042 +#define GL_LUMINANCE16_ALPHA16 0x8048 +#define GL_LUMINANCE4 0x803F +#define GL_LUMINANCE4_ALPHA4 0x8043 +#define GL_LUMINANCE6_ALPHA2 0x8044 +#define GL_LUMINANCE8 0x8040 +#define GL_LUMINANCE8_ALPHA8 0x8045 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_MAP1_COLOR_4 0x0D90 +#define GL_MAP1_GRID_DOMAIN 0x0DD0 +#define GL_MAP1_GRID_SEGMENTS 0x0DD1 +#define GL_MAP1_INDEX 0x0D91 +#define GL_MAP1_NORMAL 0x0D92 +#define GL_MAP1_TEXTURE_COORD_1 0x0D93 +#define GL_MAP1_TEXTURE_COORD_2 0x0D94 +#define GL_MAP1_TEXTURE_COORD_3 0x0D95 +#define GL_MAP1_TEXTURE_COORD_4 0x0D96 +#define GL_MAP1_VERTEX_3 0x0D97 +#define GL_MAP1_VERTEX_4 0x0D98 +#define GL_MAP2_COLOR_4 0x0DB0 +#define GL_MAP2_GRID_DOMAIN 0x0DD2 +#define GL_MAP2_GRID_SEGMENTS 0x0DD3 +#define GL_MAP2_INDEX 0x0DB1 +#define GL_MAP2_NORMAL 0x0DB2 +#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 +#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 +#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 +#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 +#define GL_MAP2_VERTEX_3 0x0DB7 +#define GL_MAP2_VERTEX_4 0x0DB8 +#define GL_MAP_COLOR 0x0D10 +#define GL_MAP_STENCIL 0x0D11 +#define GL_MATRIX_MODE 0x0BA0 +#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 +#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_EVAL_ORDER 0x0D30 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_LIST_NESTING 0x0B31 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_NAME_STACK_DEPTH 0x0D37 +#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 #define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 #define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MODELVIEW 0x1700 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_MODULATE 0x2100 +#define GL_MULT 0x0103 +#define GL_N3F_V3F 0x2A25 +#define GL_NAME_STACK_DEPTH 0x0D70 #define GL_NAND 0x150E #define GL_NEAREST 0x2600 #define GL_NEAREST_MIPMAP_LINEAR 0x2702 @@ -315,14 +583,22 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_NONE 0 #define GL_NOOP 0x1505 #define GL_NOR 0x1508 +#define GL_NORMALIZE 0x0BA1 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_NORMAL_ARRAY_TYPE 0x807E #define GL_NOTEQUAL 0x0205 #define GL_NO_ERROR 0 +#define GL_OBJECT_LINEAR 0x2401 +#define GL_OBJECT_PLANE 0x2501 #define GL_ONE 1 #define GL_ONE_MINUS_DST_ALPHA 0x0305 #define GL_ONE_MINUS_DST_COLOR 0x0307 #define GL_ONE_MINUS_SRC_ALPHA 0x0303 #define GL_ONE_MINUS_SRC_COLOR 0x0301 #define GL_OR 0x1507 +#define GL_ORDER 0x0A01 #define GL_OR_INVERTED 0x150D #define GL_OR_REVERSE 0x150B #define GL_OUT_OF_MEMORY 0x0505 @@ -332,11 +608,40 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_PACK_SKIP_PIXELS 0x0D04 #define GL_PACK_SKIP_ROWS 0x0D03 #define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_PASS_THROUGH_TOKEN 0x0700 +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_PIXEL_MAP_A_TO_A 0x0C79 +#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 +#define GL_PIXEL_MAP_B_TO_B 0x0C78 +#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 +#define GL_PIXEL_MAP_G_TO_G 0x0C77 +#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 +#define GL_PIXEL_MAP_I_TO_A 0x0C75 +#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 +#define GL_PIXEL_MAP_I_TO_B 0x0C74 +#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 +#define GL_PIXEL_MAP_I_TO_G 0x0C73 +#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 +#define GL_PIXEL_MAP_I_TO_I 0x0C70 +#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 +#define GL_PIXEL_MAP_I_TO_R 0x0C72 +#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 +#define GL_PIXEL_MAP_R_TO_R 0x0C76 +#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 +#define GL_PIXEL_MAP_S_TO_S 0x0C71 +#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 +#define GL_PIXEL_MODE_BIT 0x00000020 #define GL_POINT 0x1B00 #define GL_POINTS 0x0000 +#define GL_POINT_BIT 0x00000002 #define GL_POINT_SIZE 0x0B11 #define GL_POINT_SIZE_GRANULARITY 0x0B13 #define GL_POINT_SIZE_RANGE 0x0B12 +#define GL_POINT_SMOOTH 0x0B10 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_POINT_TOKEN 0x0701 +#define GL_POLYGON 0x0009 +#define GL_POLYGON_BIT 0x00000008 #define GL_POLYGON_MODE 0x0B40 #define GL_POLYGON_OFFSET_FACTOR 0x8038 #define GL_POLYGON_OFFSET_FILL 0x8037 @@ -345,15 +650,32 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_POLYGON_OFFSET_UNITS 0x2A00 #define GL_POLYGON_SMOOTH 0x0B41 #define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_POLYGON_STIPPLE 0x0B42 +#define GL_POLYGON_STIPPLE_BIT 0x00000010 +#define GL_POLYGON_TOKEN 0x0703 +#define GL_POSITION 0x1203 +#define GL_PROJECTION 0x1701 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 #define GL_PROXY_TEXTURE_1D 0x8063 #define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_Q 0x2003 +#define GL_QUADRATIC_ATTENUATION 0x1209 #define GL_QUADS 0x0007 +#define GL_QUAD_STRIP 0x0008 +#define GL_R 0x2002 #define GL_R3_G3_B2 0x2A10 #define GL_READ_BUFFER 0x0C02 #define GL_RED 0x1903 +#define GL_RED_BIAS 0x0D15 +#define GL_RED_BITS 0x0D52 +#define GL_RED_SCALE 0x0D14 +#define GL_RENDER 0x1C00 #define GL_RENDERER 0x1F01 +#define GL_RENDER_MODE 0x0C40 #define GL_REPEAT 0x2901 #define GL_REPLACE 0x1E01 +#define GL_RETURN 0x0102 #define GL_RGB 0x1907 #define GL_RGB10 0x8052 #define GL_RGB10_A2 0x8059 @@ -369,15 +691,32 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_RGBA2 0x8055 #define GL_RGBA4 0x8056 #define GL_RGBA8 0x8058 +#define GL_RGBA_MODE 0x0C31 #define GL_RIGHT 0x0407 +#define GL_S 0x2000 +#define GL_SCISSOR_BIT 0x00080000 #define GL_SCISSOR_BOX 0x0C10 #define GL_SCISSOR_TEST 0x0C11 +#define GL_SELECT 0x1C02 +#define GL_SELECTION_BUFFER_POINTER 0x0DF3 +#define GL_SELECTION_BUFFER_SIZE 0x0DF4 #define GL_SET 0x150F +#define GL_SHADE_MODEL 0x0B54 +#define GL_SHININESS 0x1601 #define GL_SHORT 0x1402 +#define GL_SMOOTH 0x1D01 +#define GL_SPECULAR 0x1202 +#define GL_SPHERE_MAP 0x2402 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_SPOT_EXPONENT 0x1205 #define GL_SRC_ALPHA 0x0302 #define GL_SRC_ALPHA_SATURATE 0x0308 #define GL_SRC_COLOR 0x0300 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 #define GL_STENCIL 0x1802 +#define GL_STENCIL_BITS 0x0D57 #define GL_STENCIL_BUFFER_BIT 0x00000400 #define GL_STENCIL_CLEAR_VALUE 0x0B91 #define GL_STENCIL_FAIL 0x0B94 @@ -391,23 +730,54 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_STENCIL_WRITEMASK 0x0B98 #define GL_STEREO 0x0C33 #define GL_SUBPIXEL_BITS 0x0D50 +#define GL_T 0x2001 +#define GL_T2F_C3F_V3F 0x2A2A +#define GL_T2F_C4F_N3F_V3F 0x2A2C +#define GL_T2F_C4UB_V3F 0x2A29 +#define GL_T2F_N3F_V3F 0x2A2B +#define GL_T2F_V3F 0x2A27 +#define GL_T4F_C4F_N3F_V4F 0x2A2D +#define GL_T4F_V4F 0x2A28 #define GL_TEXTURE 0x1702 #define GL_TEXTURE_1D 0x0DE0 #define GL_TEXTURE_2D 0x0DE1 #define GL_TEXTURE_ALPHA_SIZE 0x805F #define GL_TEXTURE_BINDING_1D 0x8068 #define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_BIT 0x00040000 #define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_BORDER 0x1005 #define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_COMPONENTS 0x1003 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_ENV 0x2300 +#define GL_TEXTURE_ENV_COLOR 0x2201 +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_GEN_MODE 0x2500 +#define GL_TEXTURE_GEN_Q 0x0C63 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 #define GL_TEXTURE_GREEN_SIZE 0x805D #define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_INTENSITY_SIZE 0x8061 #define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 #define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MATRIX 0x0BA8 #define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_PRIORITY 0x8066 #define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_RESIDENT 0x8067 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 #define GL_TEXTURE_WIDTH 0x1000 #define GL_TEXTURE_WRAP_S 0x2802 #define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TRANSFORM_BIT 0x00001000 #define GL_TRIANGLES 0x0004 #define GL_TRIANGLE_FAN 0x0006 #define GL_TRIANGLE_STRIP 0x0005 @@ -421,22 +791,37 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_UNSIGNED_BYTE 0x1401 #define GL_UNSIGNED_INT 0x1405 #define GL_UNSIGNED_SHORT 0x1403 +#define GL_V2F 0x2A20 +#define GL_V3F 0x2A21 #define GL_VENDOR 0x1F00 #define GL_VERSION 0x1F02 +#define GL_VERTEX_ARRAY 0x8074 +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_VERTEX_ARRAY_TYPE 0x807B #define GL_VIEWPORT 0x0BA2 +#define GL_VIEWPORT_BIT 0x00000800 #define GL_XOR 0x1506 #define GL_ZERO 0 +#define GL_ZOOM_X 0x0D16 +#define GL_ZOOM_Y 0x0D17 #define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D #define GL_BGR 0x80E0 #define GL_BGRA 0x80E1 #define GL_CLAMP_TO_EDGE 0x812F +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 #define GL_MAX_3D_TEXTURE_SIZE 0x8073 #define GL_MAX_ELEMENTS_INDICES 0x80E9 #define GL_MAX_ELEMENTS_VERTICES 0x80E8 #define GL_PACK_IMAGE_HEIGHT 0x806C #define GL_PACK_SKIP_IMAGES 0x806B #define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_RESCALE_NORMAL 0x803A +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_SINGLE_COLOR 0x81F9 #define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 #define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 #define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 @@ -465,14 +850,40 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 #define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_ADD_SIGNED 0x8574 #define GL_CLAMP_TO_BORDER 0x812D +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_COMBINE 0x8570 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB #define GL_COMPRESSED_RGB 0x84ED #define GL_COMPRESSED_RGBA 0x84EE #define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CONSTANT 0x8576 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#define GL_INTERPOLATE 0x8575 #define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_MAX_TEXTURE_UNITS 0x84E2 #define GL_MULTISAMPLE 0x809D +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_OPERAND2_RGB 0x8592 +#define GL_PREVIOUS 0x8578 +#define GL_PRIMARY_COLOR 0x8577 #define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_REFLECTION_MAP 0x8512 +#define GL_RGB_SCALE 0x8573 #define GL_SAMPLES 0x80A9 #define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E #define GL_SAMPLE_ALPHA_TO_ONE 0x809F @@ -480,6 +891,13 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_SAMPLE_COVERAGE 0x80A0 #define GL_SAMPLE_COVERAGE_INVERT 0x80AB #define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_SOURCE2_RGB 0x8582 +#define GL_SUBTRACT 0x84E7 #define GL_TEXTURE0 0x84C0 #define GL_TEXTURE1 0x84C1 #define GL_TEXTURE10 0x84CA @@ -523,6 +941,10 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 #define GL_BLEND_COLOR 0x8005 #define GL_BLEND_DST_ALPHA 0x80CA @@ -530,15 +952,29 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_BLEND_EQUATION 0x8009 #define GL_BLEND_SRC_ALPHA 0x80CB #define GL_BLEND_SRC_RGB 0x80C9 +#define GL_COLOR_SUM 0x8458 +#define GL_COMPARE_R_TO_TEXTURE 0x884E #define GL_CONSTANT_ALPHA 0x8003 #define GL_CONSTANT_COLOR 0x8001 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 #define GL_DECR_WRAP 0x8508 #define GL_DEPTH_COMPONENT16 0x81A5 #define GL_DEPTH_COMPONENT24 0x81A6 #define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_FOG_COORDINATE 0x8451 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FRAGMENT_DEPTH 0x8452 #define GL_FUNC_ADD 0x8006 #define GL_FUNC_REVERSE_SUBTRACT 0x800B #define GL_FUNC_SUBTRACT 0x800A +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 #define GL_INCR_WRAP 0x8507 #define GL_MAX 0x8008 #define GL_MAX_TEXTURE_LOD_BIAS 0x84FD @@ -546,10 +982,19 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_MIRRORED_REPEAT 0x8370 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 #define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B #define GL_TEXTURE_COMPARE_FUNC 0x884D #define GL_TEXTURE_COMPARE_MODE 0x884C #define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_FILTER_CONTROL 0x8500 #define GL_TEXTURE_LOD_BIAS 0x8501 #define GL_ARRAY_BUFFER 0x8892 @@ -559,26 +1004,48 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_BUFFER_MAP_POINTER 0x88BD #define GL_BUFFER_SIZE 0x8764 #define GL_BUFFER_USAGE 0x8765 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_CURRENT_FOG_COORD 0x8453 #define GL_CURRENT_QUERY 0x8865 #define GL_DYNAMIC_COPY 0x88EA #define GL_DYNAMIC_DRAW 0x88E8 #define GL_DYNAMIC_READ 0x88E9 +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B #define GL_ELEMENT_ARRAY_BUFFER 0x8893 #define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_FOG_COORD 0x8451 +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_SRC 0x8450 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 #define GL_QUERY_COUNTER_BITS 0x8864 #define GL_QUERY_RESULT 0x8866 #define GL_QUERY_RESULT_AVAILABLE 0x8867 #define GL_READ_ONLY 0x88B8 #define GL_READ_WRITE 0x88BA #define GL_SAMPLES_PASSED 0x8914 +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC0_RGB 0x8580 #define GL_SRC1_ALPHA 0x8589 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_ALPHA 0x858A +#define GL_SRC2_RGB 0x8582 #define GL_STATIC_COPY 0x88E6 #define GL_STATIC_DRAW 0x88E4 #define GL_STATIC_READ 0x88E5 #define GL_STREAM_COPY 0x88E2 #define GL_STREAM_DRAW 0x88E0 #define GL_STREAM_READ 0x88E1 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E #define GL_WRITE_ONLY 0x88B9 #define GL_ACTIVE_ATTRIBUTES 0x8B89 @@ -593,6 +1060,7 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_BOOL_VEC3 0x8B58 #define GL_BOOL_VEC4 0x8B59 #define GL_COMPILE_STATUS 0x8B81 +#define GL_COORD_REPLACE 0x8862 #define GL_CURRENT_PROGRAM 0x8B8D #define GL_CURRENT_VERTEX_ATTRIB 0x8626 #define GL_DELETE_STATUS 0x8B80 @@ -629,11 +1097,13 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D #define GL_MAX_DRAW_BUFFERS 0x8824 #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_TEXTURE_COORDS 0x8871 #define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 #define GL_MAX_VARYING_FLOATS 0x8B4B #define GL_MAX_VERTEX_ATTRIBS 0x8869 #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C #define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_POINT_SPRITE 0x8861 #define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 #define GL_SAMPLER_1D 0x8B5D #define GL_SAMPLER_1D_SHADOW 0x8B61 @@ -660,10 +1130,14 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 #define GL_VERTEX_SHADER 0x8B31 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B #define GL_COMPRESSED_SRGB 0x8C48 #define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F #define GL_FLOAT_MAT2x3 0x8B65 #define GL_FLOAT_MAT2x4 0x8B66 #define GL_FLOAT_MAT3x2 0x8B67 @@ -674,18 +1148,25 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; #define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED #define GL_PIXEL_UNPACK_BUFFER 0x88EC #define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE_ALPHA 0x8C44 #define GL_SRGB 0x8C40 #define GL_SRGB8 0x8C41 #define GL_SRGB8_ALPHA8 0x8C43 #define GL_SRGB_ALPHA 0x8C42 +#define GL_ALPHA_INTEGER 0x8D97 #define GL_BGRA_INTEGER 0x8D9B #define GL_BGR_INTEGER 0x8D9A #define GL_BLUE_INTEGER 0x8D96 #define GL_BUFFER_ACCESS_FLAGS 0x911F #define GL_BUFFER_MAP_LENGTH 0x9120 #define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_CLAMP_FRAGMENT_COLOR 0x891B #define GL_CLAMP_READ_COLOR 0x891C +#define GL_CLAMP_VERTEX_COLOR 0x891A #define GL_CLIP_DISTANCE0 0x3000 #define GL_CLIP_DISTANCE1 0x3001 #define GL_CLIP_DISTANCE2 0x3002 @@ -1068,26 +1549,147 @@ extern void (CODEGEN_FUNCPTR *_ptrc_glShaderStorageBlockBinding)(GLuint, GLuint, #endif /*GL_ARB_shader_storage_buffer_object*/ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFramebufferEXT)(GLenum, GLuint); +#define glBindFramebufferEXT _ptrc_glBindFramebufferEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbufferEXT)(GLenum, GLuint); +#define glBindRenderbufferEXT _ptrc_glBindRenderbufferEXT +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatusEXT)(GLenum); +#define glCheckFramebufferStatusEXT _ptrc_glCheckFramebufferStatusEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffersEXT)(GLsizei, const GLuint *); +#define glDeleteFramebuffersEXT _ptrc_glDeleteFramebuffersEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffersEXT)(GLsizei, const GLuint *); +#define glDeleteRenderbuffersEXT _ptrc_glDeleteRenderbuffersEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbufferEXT)(GLenum, GLenum, GLenum, GLuint); +#define glFramebufferRenderbufferEXT _ptrc_glFramebufferRenderbufferEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1DEXT)(GLenum, GLenum, GLenum, GLuint, GLint); +#define glFramebufferTexture1DEXT _ptrc_glFramebufferTexture1DEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2DEXT)(GLenum, GLenum, GLenum, GLuint, GLint); +#define glFramebufferTexture2DEXT _ptrc_glFramebufferTexture2DEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3DEXT)(GLenum, GLenum, GLenum, GLuint, GLint, GLint); +#define glFramebufferTexture3DEXT _ptrc_glFramebufferTexture3DEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffersEXT)(GLsizei, GLuint *); +#define glGenFramebuffersEXT _ptrc_glGenFramebuffersEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffersEXT)(GLsizei, GLuint *); +#define glGenRenderbuffersEXT _ptrc_glGenRenderbuffersEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmapEXT)(GLenum); +#define glGenerateMipmapEXT _ptrc_glGenerateMipmapEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameterivEXT)(GLenum, GLenum, GLenum, GLint *); +#define glGetFramebufferAttachmentParameterivEXT _ptrc_glGetFramebufferAttachmentParameterivEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameterivEXT)(GLenum, GLenum, GLint *); +#define glGetRenderbufferParameterivEXT _ptrc_glGetRenderbufferParameterivEXT +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebufferEXT)(GLuint); +#define glIsFramebufferEXT _ptrc_glIsFramebufferEXT +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbufferEXT)(GLuint); +#define glIsRenderbufferEXT _ptrc_glIsRenderbufferEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageEXT)(GLenum, GLenum, GLsizei, GLsizei); +#define glRenderbufferStorageEXT _ptrc_glRenderbufferStorageEXT +#endif /*GL_EXT_framebuffer_object*/ + +extern void (CODEGEN_FUNCPTR *_ptrc_glAccum)(GLenum, GLfloat); +#define glAccum _ptrc_glAccum +extern void (CODEGEN_FUNCPTR *_ptrc_glAlphaFunc)(GLenum, GLfloat); +#define glAlphaFunc _ptrc_glAlphaFunc extern void (CODEGEN_FUNCPTR *_ptrc_glBegin)(GLenum); #define glBegin _ptrc_glBegin -extern void (CODEGEN_FUNCPTR *_ptrc_glEnd)(); -#define glEnd _ptrc_glEnd - - +extern void (CODEGEN_FUNCPTR *_ptrc_glBitmap)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte *); +#define glBitmap _ptrc_glBitmap extern void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum, GLenum); #define glBlendFunc _ptrc_glBlendFunc +extern void (CODEGEN_FUNCPTR *_ptrc_glCallList)(GLuint); +#define glCallList _ptrc_glCallList +extern void (CODEGEN_FUNCPTR *_ptrc_glCallLists)(GLsizei, GLenum, const GLvoid *); +#define glCallLists _ptrc_glCallLists extern void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield); #define glClear _ptrc_glClear +extern void (CODEGEN_FUNCPTR *_ptrc_glClearAccum)(GLfloat, GLfloat, GLfloat, GLfloat); +#define glClearAccum _ptrc_glClearAccum extern void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat); #define glClearColor _ptrc_glClearColor extern void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble); #define glClearDepth _ptrc_glClearDepth +extern void (CODEGEN_FUNCPTR *_ptrc_glClearIndex)(GLfloat); +#define glClearIndex _ptrc_glClearIndex extern void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint); #define glClearStencil _ptrc_glClearStencil +extern void (CODEGEN_FUNCPTR *_ptrc_glClipPlane)(GLenum, const GLdouble *); +#define glClipPlane _ptrc_glClipPlane +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3b)(GLbyte, GLbyte, GLbyte); +#define glColor3b _ptrc_glColor3b +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3bv)(const GLbyte *); +#define glColor3bv _ptrc_glColor3bv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3d)(GLdouble, GLdouble, GLdouble); +#define glColor3d _ptrc_glColor3d +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3dv)(const GLdouble *); +#define glColor3dv _ptrc_glColor3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3f)(GLfloat, GLfloat, GLfloat); +#define glColor3f _ptrc_glColor3f +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3fv)(const GLfloat *); +#define glColor3fv _ptrc_glColor3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3i)(GLint, GLint, GLint); +#define glColor3i _ptrc_glColor3i +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3iv)(const GLint *); +#define glColor3iv _ptrc_glColor3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3s)(GLshort, GLshort, GLshort); +#define glColor3s _ptrc_glColor3s +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3sv)(const GLshort *); +#define glColor3sv _ptrc_glColor3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3ub)(GLubyte, GLubyte, GLubyte); +#define glColor3ub _ptrc_glColor3ub +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3ubv)(const GLubyte *); +#define glColor3ubv _ptrc_glColor3ubv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3ui)(GLuint, GLuint, GLuint); +#define glColor3ui _ptrc_glColor3ui +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3uiv)(const GLuint *); +#define glColor3uiv _ptrc_glColor3uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3us)(GLushort, GLushort, GLushort); +#define glColor3us _ptrc_glColor3us +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3usv)(const GLushort *); +#define glColor3usv _ptrc_glColor3usv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4b)(GLbyte, GLbyte, GLbyte, GLbyte); +#define glColor4b _ptrc_glColor4b +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4bv)(const GLbyte *); +#define glColor4bv _ptrc_glColor4bv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4d)(GLdouble, GLdouble, GLdouble, GLdouble); +#define glColor4d _ptrc_glColor4d +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4dv)(const GLdouble *); +#define glColor4dv _ptrc_glColor4dv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4f)(GLfloat, GLfloat, GLfloat, GLfloat); +#define glColor4f _ptrc_glColor4f +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4fv)(const GLfloat *); +#define glColor4fv _ptrc_glColor4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4i)(GLint, GLint, GLint, GLint); +#define glColor4i _ptrc_glColor4i +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4iv)(const GLint *); +#define glColor4iv _ptrc_glColor4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4s)(GLshort, GLshort, GLshort, GLshort); +#define glColor4s _ptrc_glColor4s +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4sv)(const GLshort *); +#define glColor4sv _ptrc_glColor4sv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4ub)(GLubyte, GLubyte, GLubyte, GLubyte); +#define glColor4ub _ptrc_glColor4ub +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4ubv)(const GLubyte *); +#define glColor4ubv _ptrc_glColor4ubv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4ui)(GLuint, GLuint, GLuint, GLuint); +#define glColor4ui _ptrc_glColor4ui +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4uiv)(const GLuint *); +#define glColor4uiv _ptrc_glColor4uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4us)(GLushort, GLushort, GLushort, GLushort); +#define glColor4us _ptrc_glColor4us +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4usv)(const GLushort *); +#define glColor4usv _ptrc_glColor4usv extern void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean); #define glColorMask _ptrc_glColorMask +extern void (CODEGEN_FUNCPTR *_ptrc_glColorMaterial)(GLenum, GLenum); +#define glColorMaterial _ptrc_glColorMaterial +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyPixels)(GLint, GLint, GLsizei, GLsizei, GLenum); +#define glCopyPixels _ptrc_glCopyPixels extern void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum); #define glCullFace _ptrc_glCullFace +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteLists)(GLuint, GLsizei); +#define glDeleteLists _ptrc_glDeleteLists extern void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum); #define glDepthFunc _ptrc_glDepthFunc extern void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean); @@ -1098,16 +1700,66 @@ extern void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum); #define glDisable _ptrc_glDisable extern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum); #define glDrawBuffer _ptrc_glDrawBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#define glDrawPixels _ptrc_glDrawPixels +extern void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlag)(GLboolean); +#define glEdgeFlag _ptrc_glEdgeFlag +extern void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagv)(const GLboolean *); +#define glEdgeFlagv _ptrc_glEdgeFlagv extern void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum); #define glEnable _ptrc_glEnable +extern void (CODEGEN_FUNCPTR *_ptrc_glEnd)(); +#define glEnd _ptrc_glEnd +extern void (CODEGEN_FUNCPTR *_ptrc_glEndList)(); +#define glEndList _ptrc_glEndList +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1d)(GLdouble); +#define glEvalCoord1d _ptrc_glEvalCoord1d +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1dv)(const GLdouble *); +#define glEvalCoord1dv _ptrc_glEvalCoord1dv +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1f)(GLfloat); +#define glEvalCoord1f _ptrc_glEvalCoord1f +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1fv)(const GLfloat *); +#define glEvalCoord1fv _ptrc_glEvalCoord1fv +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2d)(GLdouble, GLdouble); +#define glEvalCoord2d _ptrc_glEvalCoord2d +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2dv)(const GLdouble *); +#define glEvalCoord2dv _ptrc_glEvalCoord2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2f)(GLfloat, GLfloat); +#define glEvalCoord2f _ptrc_glEvalCoord2f +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2fv)(const GLfloat *); +#define glEvalCoord2fv _ptrc_glEvalCoord2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh1)(GLenum, GLint, GLint); +#define glEvalMesh1 _ptrc_glEvalMesh1 +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh2)(GLenum, GLint, GLint, GLint, GLint); +#define glEvalMesh2 _ptrc_glEvalMesh2 +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint1)(GLint); +#define glEvalPoint1 _ptrc_glEvalPoint1 +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint2)(GLint, GLint); +#define glEvalPoint2 _ptrc_glEvalPoint2 +extern void (CODEGEN_FUNCPTR *_ptrc_glFeedbackBuffer)(GLsizei, GLenum, GLfloat *); +#define glFeedbackBuffer _ptrc_glFeedbackBuffer extern void (CODEGEN_FUNCPTR *_ptrc_glFinish)(); #define glFinish _ptrc_glFinish extern void (CODEGEN_FUNCPTR *_ptrc_glFlush)(); #define glFlush _ptrc_glFlush +extern void (CODEGEN_FUNCPTR *_ptrc_glFogf)(GLenum, GLfloat); +#define glFogf _ptrc_glFogf +extern void (CODEGEN_FUNCPTR *_ptrc_glFogfv)(GLenum, const GLfloat *); +#define glFogfv _ptrc_glFogfv +extern void (CODEGEN_FUNCPTR *_ptrc_glFogi)(GLenum, GLint); +#define glFogi _ptrc_glFogi +extern void (CODEGEN_FUNCPTR *_ptrc_glFogiv)(GLenum, const GLint *); +#define glFogiv _ptrc_glFogiv extern void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum); #define glFrontFace _ptrc_glFrontFace +extern void (CODEGEN_FUNCPTR *_ptrc_glFrustum)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); +#define glFrustum _ptrc_glFrustum +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glGenLists)(GLsizei); +#define glGenLists _ptrc_glGenLists extern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum, GLboolean *); #define glGetBooleanv _ptrc_glGetBooleanv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetClipPlane)(GLenum, GLdouble *); +#define glGetClipPlane _ptrc_glGetClipPlane extern void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum, GLdouble *); #define glGetDoublev _ptrc_glGetDoublev extern GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)(); @@ -1116,8 +1768,40 @@ extern void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum, GLfloat *); #define glGetFloatv _ptrc_glGetFloatv extern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum, GLint *); #define glGetIntegerv _ptrc_glGetIntegerv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetLightfv)(GLenum, GLenum, GLfloat *); +#define glGetLightfv _ptrc_glGetLightfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetLightiv)(GLenum, GLenum, GLint *); +#define glGetLightiv _ptrc_glGetLightiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMapdv)(GLenum, GLenum, GLdouble *); +#define glGetMapdv _ptrc_glGetMapdv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMapfv)(GLenum, GLenum, GLfloat *); +#define glGetMapfv _ptrc_glGetMapfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMapiv)(GLenum, GLenum, GLint *); +#define glGetMapiv _ptrc_glGetMapiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialfv)(GLenum, GLenum, GLfloat *); +#define glGetMaterialfv _ptrc_glGetMaterialfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialiv)(GLenum, GLenum, GLint *); +#define glGetMaterialiv _ptrc_glGetMaterialiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapfv)(GLenum, GLfloat *); +#define glGetPixelMapfv _ptrc_glGetPixelMapfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapuiv)(GLenum, GLuint *); +#define glGetPixelMapuiv _ptrc_glGetPixelMapuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapusv)(GLenum, GLushort *); +#define glGetPixelMapusv _ptrc_glGetPixelMapusv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPolygonStipple)(GLubyte *); +#define glGetPolygonStipple _ptrc_glGetPolygonStipple extern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum); #define glGetString _ptrc_glGetString +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnvfv)(GLenum, GLenum, GLfloat *); +#define glGetTexEnvfv _ptrc_glGetTexEnvfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnviv)(GLenum, GLenum, GLint *); +#define glGetTexEnviv _ptrc_glGetTexEnviv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexGendv)(GLenum, GLenum, GLdouble *); +#define glGetTexGendv _ptrc_glGetTexGendv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexGenfv)(GLenum, GLenum, GLfloat *); +#define glGetTexGenfv _ptrc_glGetTexGenfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexGeniv)(GLenum, GLenum, GLint *); +#define glGetTexGeniv _ptrc_glGetTexGeniv extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *); #define glGetTexImage _ptrc_glGetTexImage extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *); @@ -1130,32 +1814,326 @@ extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum, GLenum, GLint * #define glGetTexParameteriv _ptrc_glGetTexParameteriv extern void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum, GLenum); #define glHint _ptrc_glHint +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexMask)(GLuint); +#define glIndexMask _ptrc_glIndexMask +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexd)(GLdouble); +#define glIndexd _ptrc_glIndexd +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexdv)(const GLdouble *); +#define glIndexdv _ptrc_glIndexdv +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexf)(GLfloat); +#define glIndexf _ptrc_glIndexf +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexfv)(const GLfloat *); +#define glIndexfv _ptrc_glIndexfv +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexi)(GLint); +#define glIndexi _ptrc_glIndexi +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexiv)(const GLint *); +#define glIndexiv _ptrc_glIndexiv +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexs)(GLshort); +#define glIndexs _ptrc_glIndexs +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexsv)(const GLshort *); +#define glIndexsv _ptrc_glIndexsv +extern void (CODEGEN_FUNCPTR *_ptrc_glInitNames)(); +#define glInitNames _ptrc_glInitNames extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum); #define glIsEnabled _ptrc_glIsEnabled +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsList)(GLuint); +#define glIsList _ptrc_glIsList +extern void (CODEGEN_FUNCPTR *_ptrc_glLightModelf)(GLenum, GLfloat); +#define glLightModelf _ptrc_glLightModelf +extern void (CODEGEN_FUNCPTR *_ptrc_glLightModelfv)(GLenum, const GLfloat *); +#define glLightModelfv _ptrc_glLightModelfv +extern void (CODEGEN_FUNCPTR *_ptrc_glLightModeli)(GLenum, GLint); +#define glLightModeli _ptrc_glLightModeli +extern void (CODEGEN_FUNCPTR *_ptrc_glLightModeliv)(GLenum, const GLint *); +#define glLightModeliv _ptrc_glLightModeliv +extern void (CODEGEN_FUNCPTR *_ptrc_glLightf)(GLenum, GLenum, GLfloat); +#define glLightf _ptrc_glLightf +extern void (CODEGEN_FUNCPTR *_ptrc_glLightfv)(GLenum, GLenum, const GLfloat *); +#define glLightfv _ptrc_glLightfv +extern void (CODEGEN_FUNCPTR *_ptrc_glLighti)(GLenum, GLenum, GLint); +#define glLighti _ptrc_glLighti +extern void (CODEGEN_FUNCPTR *_ptrc_glLightiv)(GLenum, GLenum, const GLint *); +#define glLightiv _ptrc_glLightiv +extern void (CODEGEN_FUNCPTR *_ptrc_glLineStipple)(GLint, GLushort); +#define glLineStipple _ptrc_glLineStipple extern void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat); #define glLineWidth _ptrc_glLineWidth +extern void (CODEGEN_FUNCPTR *_ptrc_glListBase)(GLuint); +#define glListBase _ptrc_glListBase +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadIdentity)(); +#define glLoadIdentity _ptrc_glLoadIdentity +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixd)(const GLdouble *); +#define glLoadMatrixd _ptrc_glLoadMatrixd +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixf)(const GLfloat *); +#define glLoadMatrixf _ptrc_glLoadMatrixf +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadName)(GLuint); +#define glLoadName _ptrc_glLoadName extern void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum); #define glLogicOp _ptrc_glLogicOp +extern void (CODEGEN_FUNCPTR *_ptrc_glMap1d)(GLenum, GLdouble, GLdouble, GLint, GLint, const GLdouble *); +#define glMap1d _ptrc_glMap1d +extern void (CODEGEN_FUNCPTR *_ptrc_glMap1f)(GLenum, GLfloat, GLfloat, GLint, GLint, const GLfloat *); +#define glMap1f _ptrc_glMap1f +extern void (CODEGEN_FUNCPTR *_ptrc_glMap2d)(GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); +#define glMap2d _ptrc_glMap2d +extern void (CODEGEN_FUNCPTR *_ptrc_glMap2f)(GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); +#define glMap2f _ptrc_glMap2f +extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1d)(GLint, GLdouble, GLdouble); +#define glMapGrid1d _ptrc_glMapGrid1d +extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1f)(GLint, GLfloat, GLfloat); +#define glMapGrid1f _ptrc_glMapGrid1f +extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2d)(GLint, GLdouble, GLdouble, GLint, GLdouble, GLdouble); +#define glMapGrid2d _ptrc_glMapGrid2d +extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2f)(GLint, GLfloat, GLfloat, GLint, GLfloat, GLfloat); +#define glMapGrid2f _ptrc_glMapGrid2f +extern void (CODEGEN_FUNCPTR *_ptrc_glMaterialf)(GLenum, GLenum, GLfloat); +#define glMaterialf _ptrc_glMaterialf +extern void (CODEGEN_FUNCPTR *_ptrc_glMaterialfv)(GLenum, GLenum, const GLfloat *); +#define glMaterialfv _ptrc_glMaterialfv +extern void (CODEGEN_FUNCPTR *_ptrc_glMateriali)(GLenum, GLenum, GLint); +#define glMateriali _ptrc_glMateriali +extern void (CODEGEN_FUNCPTR *_ptrc_glMaterialiv)(GLenum, GLenum, const GLint *); +#define glMaterialiv _ptrc_glMaterialiv +extern void (CODEGEN_FUNCPTR *_ptrc_glMatrixMode)(GLenum); +#define glMatrixMode _ptrc_glMatrixMode +extern void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixd)(const GLdouble *); +#define glMultMatrixd _ptrc_glMultMatrixd +extern void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixf)(const GLfloat *); +#define glMultMatrixf _ptrc_glMultMatrixf +extern void (CODEGEN_FUNCPTR *_ptrc_glNewList)(GLuint, GLenum); +#define glNewList _ptrc_glNewList +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3b)(GLbyte, GLbyte, GLbyte); +#define glNormal3b _ptrc_glNormal3b +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3bv)(const GLbyte *); +#define glNormal3bv _ptrc_glNormal3bv +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3d)(GLdouble, GLdouble, GLdouble); +#define glNormal3d _ptrc_glNormal3d +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3dv)(const GLdouble *); +#define glNormal3dv _ptrc_glNormal3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3f)(GLfloat, GLfloat, GLfloat); +#define glNormal3f _ptrc_glNormal3f +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3fv)(const GLfloat *); +#define glNormal3fv _ptrc_glNormal3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3i)(GLint, GLint, GLint); +#define glNormal3i _ptrc_glNormal3i +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3iv)(const GLint *); +#define glNormal3iv _ptrc_glNormal3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3s)(GLshort, GLshort, GLshort); +#define glNormal3s _ptrc_glNormal3s +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3sv)(const GLshort *); +#define glNormal3sv _ptrc_glNormal3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glOrtho)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); +#define glOrtho _ptrc_glOrtho +extern void (CODEGEN_FUNCPTR *_ptrc_glPassThrough)(GLfloat); +#define glPassThrough _ptrc_glPassThrough +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelMapfv)(GLenum, GLsizei, const GLfloat *); +#define glPixelMapfv _ptrc_glPixelMapfv +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelMapuiv)(GLenum, GLsizei, const GLuint *); +#define glPixelMapuiv _ptrc_glPixelMapuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelMapusv)(GLenum, GLsizei, const GLushort *); +#define glPixelMapusv _ptrc_glPixelMapusv extern void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum, GLfloat); #define glPixelStoref _ptrc_glPixelStoref extern void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum, GLint); #define glPixelStorei _ptrc_glPixelStorei +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferf)(GLenum, GLfloat); +#define glPixelTransferf _ptrc_glPixelTransferf +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferi)(GLenum, GLint); +#define glPixelTransferi _ptrc_glPixelTransferi +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelZoom)(GLfloat, GLfloat); +#define glPixelZoom _ptrc_glPixelZoom extern void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat); #define glPointSize _ptrc_glPointSize extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum, GLenum); #define glPolygonMode _ptrc_glPolygonMode +extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonStipple)(const GLubyte *); +#define glPolygonStipple _ptrc_glPolygonStipple +extern void (CODEGEN_FUNCPTR *_ptrc_glPopAttrib)(); +#define glPopAttrib _ptrc_glPopAttrib +extern void (CODEGEN_FUNCPTR *_ptrc_glPopMatrix)(); +#define glPopMatrix _ptrc_glPopMatrix +extern void (CODEGEN_FUNCPTR *_ptrc_glPopName)(); +#define glPopName _ptrc_glPopName +extern void (CODEGEN_FUNCPTR *_ptrc_glPushAttrib)(GLbitfield); +#define glPushAttrib _ptrc_glPushAttrib +extern void (CODEGEN_FUNCPTR *_ptrc_glPushMatrix)(); +#define glPushMatrix _ptrc_glPushMatrix +extern void (CODEGEN_FUNCPTR *_ptrc_glPushName)(GLuint); +#define glPushName _ptrc_glPushName +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2d)(GLdouble, GLdouble); +#define glRasterPos2d _ptrc_glRasterPos2d +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2dv)(const GLdouble *); +#define glRasterPos2dv _ptrc_glRasterPos2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2f)(GLfloat, GLfloat); +#define glRasterPos2f _ptrc_glRasterPos2f +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2fv)(const GLfloat *); +#define glRasterPos2fv _ptrc_glRasterPos2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2i)(GLint, GLint); +#define glRasterPos2i _ptrc_glRasterPos2i +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2iv)(const GLint *); +#define glRasterPos2iv _ptrc_glRasterPos2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2s)(GLshort, GLshort); +#define glRasterPos2s _ptrc_glRasterPos2s +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2sv)(const GLshort *); +#define glRasterPos2sv _ptrc_glRasterPos2sv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3d)(GLdouble, GLdouble, GLdouble); +#define glRasterPos3d _ptrc_glRasterPos3d +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3dv)(const GLdouble *); +#define glRasterPos3dv _ptrc_glRasterPos3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3f)(GLfloat, GLfloat, GLfloat); +#define glRasterPos3f _ptrc_glRasterPos3f +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3fv)(const GLfloat *); +#define glRasterPos3fv _ptrc_glRasterPos3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3i)(GLint, GLint, GLint); +#define glRasterPos3i _ptrc_glRasterPos3i +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3iv)(const GLint *); +#define glRasterPos3iv _ptrc_glRasterPos3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3s)(GLshort, GLshort, GLshort); +#define glRasterPos3s _ptrc_glRasterPos3s +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3sv)(const GLshort *); +#define glRasterPos3sv _ptrc_glRasterPos3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble); +#define glRasterPos4d _ptrc_glRasterPos4d +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4dv)(const GLdouble *); +#define glRasterPos4dv _ptrc_glRasterPos4dv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4f)(GLfloat, GLfloat, GLfloat, GLfloat); +#define glRasterPos4f _ptrc_glRasterPos4f +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4fv)(const GLfloat *); +#define glRasterPos4fv _ptrc_glRasterPos4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4i)(GLint, GLint, GLint, GLint); +#define glRasterPos4i _ptrc_glRasterPos4i +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4iv)(const GLint *); +#define glRasterPos4iv _ptrc_glRasterPos4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4s)(GLshort, GLshort, GLshort, GLshort); +#define glRasterPos4s _ptrc_glRasterPos4s +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4sv)(const GLshort *); +#define glRasterPos4sv _ptrc_glRasterPos4sv extern void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum); #define glReadBuffer _ptrc_glReadBuffer extern void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *); #define glReadPixels _ptrc_glReadPixels +extern void (CODEGEN_FUNCPTR *_ptrc_glRectd)(GLdouble, GLdouble, GLdouble, GLdouble); +#define glRectd _ptrc_glRectd +extern void (CODEGEN_FUNCPTR *_ptrc_glRectdv)(const GLdouble *, const GLdouble *); +#define glRectdv _ptrc_glRectdv +extern void (CODEGEN_FUNCPTR *_ptrc_glRectf)(GLfloat, GLfloat, GLfloat, GLfloat); +#define glRectf _ptrc_glRectf +extern void (CODEGEN_FUNCPTR *_ptrc_glRectfv)(const GLfloat *, const GLfloat *); +#define glRectfv _ptrc_glRectfv +extern void (CODEGEN_FUNCPTR *_ptrc_glRecti)(GLint, GLint, GLint, GLint); +#define glRecti _ptrc_glRecti +extern void (CODEGEN_FUNCPTR *_ptrc_glRectiv)(const GLint *, const GLint *); +#define glRectiv _ptrc_glRectiv +extern void (CODEGEN_FUNCPTR *_ptrc_glRects)(GLshort, GLshort, GLshort, GLshort); +#define glRects _ptrc_glRects +extern void (CODEGEN_FUNCPTR *_ptrc_glRectsv)(const GLshort *, const GLshort *); +#define glRectsv _ptrc_glRectsv +extern GLint (CODEGEN_FUNCPTR *_ptrc_glRenderMode)(GLenum); +#define glRenderMode _ptrc_glRenderMode +extern void (CODEGEN_FUNCPTR *_ptrc_glRotated)(GLdouble, GLdouble, GLdouble, GLdouble); +#define glRotated _ptrc_glRotated +extern void (CODEGEN_FUNCPTR *_ptrc_glRotatef)(GLfloat, GLfloat, GLfloat, GLfloat); +#define glRotatef _ptrc_glRotatef +extern void (CODEGEN_FUNCPTR *_ptrc_glScaled)(GLdouble, GLdouble, GLdouble); +#define glScaled _ptrc_glScaled +extern void (CODEGEN_FUNCPTR *_ptrc_glScalef)(GLfloat, GLfloat, GLfloat); +#define glScalef _ptrc_glScalef extern void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint, GLint, GLsizei, GLsizei); #define glScissor _ptrc_glScissor +extern void (CODEGEN_FUNCPTR *_ptrc_glSelectBuffer)(GLsizei, GLuint *); +#define glSelectBuffer _ptrc_glSelectBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glShadeModel)(GLenum); +#define glShadeModel _ptrc_glShadeModel extern void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum, GLint, GLuint); #define glStencilFunc _ptrc_glStencilFunc extern void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint); #define glStencilMask _ptrc_glStencilMask extern void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum, GLenum, GLenum); #define glStencilOp _ptrc_glStencilOp +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1d)(GLdouble); +#define glTexCoord1d _ptrc_glTexCoord1d +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1dv)(const GLdouble *); +#define glTexCoord1dv _ptrc_glTexCoord1dv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1f)(GLfloat); +#define glTexCoord1f _ptrc_glTexCoord1f +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1fv)(const GLfloat *); +#define glTexCoord1fv _ptrc_glTexCoord1fv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1i)(GLint); +#define glTexCoord1i _ptrc_glTexCoord1i +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1iv)(const GLint *); +#define glTexCoord1iv _ptrc_glTexCoord1iv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1s)(GLshort); +#define glTexCoord1s _ptrc_glTexCoord1s +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1sv)(const GLshort *); +#define glTexCoord1sv _ptrc_glTexCoord1sv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2d)(GLdouble, GLdouble); +#define glTexCoord2d _ptrc_glTexCoord2d +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2dv)(const GLdouble *); +#define glTexCoord2dv _ptrc_glTexCoord2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2f)(GLfloat, GLfloat); +#define glTexCoord2f _ptrc_glTexCoord2f +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2fv)(const GLfloat *); +#define glTexCoord2fv _ptrc_glTexCoord2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2i)(GLint, GLint); +#define glTexCoord2i _ptrc_glTexCoord2i +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2iv)(const GLint *); +#define glTexCoord2iv _ptrc_glTexCoord2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2s)(GLshort, GLshort); +#define glTexCoord2s _ptrc_glTexCoord2s +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2sv)(const GLshort *); +#define glTexCoord2sv _ptrc_glTexCoord2sv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3d)(GLdouble, GLdouble, GLdouble); +#define glTexCoord3d _ptrc_glTexCoord3d +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3dv)(const GLdouble *); +#define glTexCoord3dv _ptrc_glTexCoord3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3f)(GLfloat, GLfloat, GLfloat); +#define glTexCoord3f _ptrc_glTexCoord3f +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3fv)(const GLfloat *); +#define glTexCoord3fv _ptrc_glTexCoord3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3i)(GLint, GLint, GLint); +#define glTexCoord3i _ptrc_glTexCoord3i +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3iv)(const GLint *); +#define glTexCoord3iv _ptrc_glTexCoord3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3s)(GLshort, GLshort, GLshort); +#define glTexCoord3s _ptrc_glTexCoord3s +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3sv)(const GLshort *); +#define glTexCoord3sv _ptrc_glTexCoord3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4d)(GLdouble, GLdouble, GLdouble, GLdouble); +#define glTexCoord4d _ptrc_glTexCoord4d +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4dv)(const GLdouble *); +#define glTexCoord4dv _ptrc_glTexCoord4dv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4f)(GLfloat, GLfloat, GLfloat, GLfloat); +#define glTexCoord4f _ptrc_glTexCoord4f +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4fv)(const GLfloat *); +#define glTexCoord4fv _ptrc_glTexCoord4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4i)(GLint, GLint, GLint, GLint); +#define glTexCoord4i _ptrc_glTexCoord4i +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4iv)(const GLint *); +#define glTexCoord4iv _ptrc_glTexCoord4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4s)(GLshort, GLshort, GLshort, GLshort); +#define glTexCoord4s _ptrc_glTexCoord4s +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4sv)(const GLshort *); +#define glTexCoord4sv _ptrc_glTexCoord4sv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnvf)(GLenum, GLenum, GLfloat); +#define glTexEnvf _ptrc_glTexEnvf +extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnvfv)(GLenum, GLenum, const GLfloat *); +#define glTexEnvfv _ptrc_glTexEnvfv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnvi)(GLenum, GLenum, GLint); +#define glTexEnvi _ptrc_glTexEnvi +extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnviv)(GLenum, GLenum, const GLint *); +#define glTexEnviv _ptrc_glTexEnviv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGend)(GLenum, GLenum, GLdouble); +#define glTexGend _ptrc_glTexGend +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGendv)(GLenum, GLenum, const GLdouble *); +#define glTexGendv _ptrc_glTexGendv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGenf)(GLenum, GLenum, GLfloat); +#define glTexGenf _ptrc_glTexGenf +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGenfv)(GLenum, GLenum, const GLfloat *); +#define glTexGenfv _ptrc_glTexGenfv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGeni)(GLenum, GLenum, GLint); +#define glTexGeni _ptrc_glTexGeni +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGeniv)(GLenum, GLenum, const GLint *); +#define glTexGeniv _ptrc_glTexGeniv extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *); #define glTexImage1D _ptrc_glTexImage1D extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); @@ -1168,11 +2146,69 @@ extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum, GLenum, GLint); #define glTexParameteri _ptrc_glTexParameteri extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum, GLenum, const GLint *); #define glTexParameteriv _ptrc_glTexParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glTranslated)(GLdouble, GLdouble, GLdouble); +#define glTranslated _ptrc_glTranslated +extern void (CODEGEN_FUNCPTR *_ptrc_glTranslatef)(GLfloat, GLfloat, GLfloat); +#define glTranslatef _ptrc_glTranslatef +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2d)(GLdouble, GLdouble); +#define glVertex2d _ptrc_glVertex2d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2dv)(const GLdouble *); +#define glVertex2dv _ptrc_glVertex2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2f)(GLfloat, GLfloat); +#define glVertex2f _ptrc_glVertex2f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2fv)(const GLfloat *); +#define glVertex2fv _ptrc_glVertex2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2i)(GLint, GLint); +#define glVertex2i _ptrc_glVertex2i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2iv)(const GLint *); +#define glVertex2iv _ptrc_glVertex2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2s)(GLshort, GLshort); +#define glVertex2s _ptrc_glVertex2s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2sv)(const GLshort *); +#define glVertex2sv _ptrc_glVertex2sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3d)(GLdouble, GLdouble, GLdouble); +#define glVertex3d _ptrc_glVertex3d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3dv)(const GLdouble *); +#define glVertex3dv _ptrc_glVertex3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3f)(GLfloat, GLfloat, GLfloat); +#define glVertex3f _ptrc_glVertex3f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3fv)(const GLfloat *); +#define glVertex3fv _ptrc_glVertex3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3i)(GLint, GLint, GLint); +#define glVertex3i _ptrc_glVertex3i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3iv)(const GLint *); +#define glVertex3iv _ptrc_glVertex3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3s)(GLshort, GLshort, GLshort); +#define glVertex3s _ptrc_glVertex3s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3sv)(const GLshort *); +#define glVertex3sv _ptrc_glVertex3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4d)(GLdouble, GLdouble, GLdouble, GLdouble); +#define glVertex4d _ptrc_glVertex4d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4dv)(const GLdouble *); +#define glVertex4dv _ptrc_glVertex4dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4f)(GLfloat, GLfloat, GLfloat, GLfloat); +#define glVertex4f _ptrc_glVertex4f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4fv)(const GLfloat *); +#define glVertex4fv _ptrc_glVertex4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4i)(GLint, GLint, GLint, GLint); +#define glVertex4i _ptrc_glVertex4i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4iv)(const GLint *); +#define glVertex4iv _ptrc_glVertex4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4s)(GLshort, GLshort, GLshort, GLshort); +#define glVertex4s _ptrc_glVertex4s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4sv)(const GLshort *); +#define glVertex4sv _ptrc_glVertex4sv extern void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint, GLint, GLsizei, GLsizei); #define glViewport _ptrc_glViewport +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glAreTexturesResident)(GLsizei, const GLuint *, GLboolean *); +#define glAreTexturesResident _ptrc_glAreTexturesResident +extern void (CODEGEN_FUNCPTR *_ptrc_glArrayElement)(GLint); +#define glArrayElement _ptrc_glArrayElement extern void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum, GLuint); #define glBindTexture _ptrc_glBindTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glColorPointer)(GLint, GLenum, GLsizei, const GLvoid *); +#define glColorPointer _ptrc_glColorPointer extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); #define glCopyTexImage1D _ptrc_glCopyTexImage1D extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); @@ -1183,20 +2219,48 @@ extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum, GLint, GLint, G #define glCopyTexSubImage2D _ptrc_glCopyTexSubImage2D extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei, const GLuint *); #define glDeleteTextures _ptrc_glDeleteTextures +extern void (CODEGEN_FUNCPTR *_ptrc_glDisableClientState)(GLenum); +#define glDisableClientState _ptrc_glDisableClientState extern void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum, GLint, GLsizei); #define glDrawArrays _ptrc_glDrawArrays extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum, GLsizei, GLenum, const GLvoid *); #define glDrawElements _ptrc_glDrawElements +extern void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagPointer)(GLsizei, const GLvoid *); +#define glEdgeFlagPointer _ptrc_glEdgeFlagPointer +extern void (CODEGEN_FUNCPTR *_ptrc_glEnableClientState)(GLenum); +#define glEnableClientState _ptrc_glEnableClientState extern void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei, GLuint *); #define glGenTextures _ptrc_glGenTextures +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPointerv)(GLenum, GLvoid **); +#define glGetPointerv _ptrc_glGetPointerv +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexPointer)(GLenum, GLsizei, const GLvoid *); +#define glIndexPointer _ptrc_glIndexPointer +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexub)(GLubyte); +#define glIndexub _ptrc_glIndexub +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexubv)(const GLubyte *); +#define glIndexubv _ptrc_glIndexubv +extern void (CODEGEN_FUNCPTR *_ptrc_glInterleavedArrays)(GLenum, GLsizei, const GLvoid *); +#define glInterleavedArrays _ptrc_glInterleavedArrays extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint); #define glIsTexture _ptrc_glIsTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glNormalPointer)(GLenum, GLsizei, const GLvoid *); +#define glNormalPointer _ptrc_glNormalPointer extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat, GLfloat); #define glPolygonOffset _ptrc_glPolygonOffset +extern void (CODEGEN_FUNCPTR *_ptrc_glPopClientAttrib)(); +#define glPopClientAttrib _ptrc_glPopClientAttrib +extern void (CODEGEN_FUNCPTR *_ptrc_glPrioritizeTextures)(GLsizei, const GLuint *, const GLfloat *); +#define glPrioritizeTextures _ptrc_glPrioritizeTextures +extern void (CODEGEN_FUNCPTR *_ptrc_glPushClientAttrib)(GLbitfield); +#define glPushClientAttrib _ptrc_glPushClientAttrib +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoordPointer)(GLint, GLenum, GLsizei, const GLvoid *); +#define glTexCoordPointer _ptrc_glTexCoordPointer extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); #define glTexSubImage1D _ptrc_glTexSubImage1D extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); #define glTexSubImage2D _ptrc_glTexSubImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexPointer)(GLint, GLenum, GLsizei, const GLvoid *); +#define glVertexPointer _ptrc_glVertexPointer extern void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat); #define glBlendColor _ptrc_glBlendColor @@ -1213,6 +2277,8 @@ extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum, GLint, GLint, GLint extern void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum); #define glActiveTexture _ptrc_glActiveTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glClientActiveTexture)(GLenum); +#define glClientActiveTexture _ptrc_glClientActiveTexture extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); #define glCompressedTexImage1D _ptrc_glCompressedTexImage1D extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); @@ -1227,11 +2293,93 @@ extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum, GLint, GL #define glCompressedTexSubImage3D _ptrc_glCompressedTexSubImage3D extern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum, GLint, GLvoid *); #define glGetCompressedTexImage _ptrc_glGetCompressedTexImage +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixd)(const GLdouble *); +#define glLoadTransposeMatrixd _ptrc_glLoadTransposeMatrixd +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixf)(const GLfloat *); +#define glLoadTransposeMatrixf _ptrc_glLoadTransposeMatrixf +extern void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixd)(const GLdouble *); +#define glMultTransposeMatrixd _ptrc_glMultTransposeMatrixd +extern void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixf)(const GLfloat *); +#define glMultTransposeMatrixf _ptrc_glMultTransposeMatrixf +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1d)(GLenum, GLdouble); +#define glMultiTexCoord1d _ptrc_glMultiTexCoord1d +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1dv)(GLenum, const GLdouble *); +#define glMultiTexCoord1dv _ptrc_glMultiTexCoord1dv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1f)(GLenum, GLfloat); +#define glMultiTexCoord1f _ptrc_glMultiTexCoord1f +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1fv)(GLenum, const GLfloat *); +#define glMultiTexCoord1fv _ptrc_glMultiTexCoord1fv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1i)(GLenum, GLint); +#define glMultiTexCoord1i _ptrc_glMultiTexCoord1i +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1iv)(GLenum, const GLint *); +#define glMultiTexCoord1iv _ptrc_glMultiTexCoord1iv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1s)(GLenum, GLshort); +#define glMultiTexCoord1s _ptrc_glMultiTexCoord1s +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1sv)(GLenum, const GLshort *); +#define glMultiTexCoord1sv _ptrc_glMultiTexCoord1sv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2d)(GLenum, GLdouble, GLdouble); +#define glMultiTexCoord2d _ptrc_glMultiTexCoord2d +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2dv)(GLenum, const GLdouble *); +#define glMultiTexCoord2dv _ptrc_glMultiTexCoord2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2f)(GLenum, GLfloat, GLfloat); +#define glMultiTexCoord2f _ptrc_glMultiTexCoord2f +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2fv)(GLenum, const GLfloat *); +#define glMultiTexCoord2fv _ptrc_glMultiTexCoord2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2i)(GLenum, GLint, GLint); +#define glMultiTexCoord2i _ptrc_glMultiTexCoord2i +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2iv)(GLenum, const GLint *); +#define glMultiTexCoord2iv _ptrc_glMultiTexCoord2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2s)(GLenum, GLshort, GLshort); +#define glMultiTexCoord2s _ptrc_glMultiTexCoord2s +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2sv)(GLenum, const GLshort *); +#define glMultiTexCoord2sv _ptrc_glMultiTexCoord2sv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3d)(GLenum, GLdouble, GLdouble, GLdouble); +#define glMultiTexCoord3d _ptrc_glMultiTexCoord3d +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3dv)(GLenum, const GLdouble *); +#define glMultiTexCoord3dv _ptrc_glMultiTexCoord3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3f)(GLenum, GLfloat, GLfloat, GLfloat); +#define glMultiTexCoord3f _ptrc_glMultiTexCoord3f +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3fv)(GLenum, const GLfloat *); +#define glMultiTexCoord3fv _ptrc_glMultiTexCoord3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3i)(GLenum, GLint, GLint, GLint); +#define glMultiTexCoord3i _ptrc_glMultiTexCoord3i +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3iv)(GLenum, const GLint *); +#define glMultiTexCoord3iv _ptrc_glMultiTexCoord3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3s)(GLenum, GLshort, GLshort, GLshort); +#define glMultiTexCoord3s _ptrc_glMultiTexCoord3s +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3sv)(GLenum, const GLshort *); +#define glMultiTexCoord3sv _ptrc_glMultiTexCoord3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4d)(GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +#define glMultiTexCoord4d _ptrc_glMultiTexCoord4d +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4dv)(GLenum, const GLdouble *); +#define glMultiTexCoord4dv _ptrc_glMultiTexCoord4dv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4f)(GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +#define glMultiTexCoord4f _ptrc_glMultiTexCoord4f +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4fv)(GLenum, const GLfloat *); +#define glMultiTexCoord4fv _ptrc_glMultiTexCoord4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4i)(GLenum, GLint, GLint, GLint, GLint); +#define glMultiTexCoord4i _ptrc_glMultiTexCoord4i +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4iv)(GLenum, const GLint *); +#define glMultiTexCoord4iv _ptrc_glMultiTexCoord4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4s)(GLenum, GLshort, GLshort, GLshort, GLshort); +#define glMultiTexCoord4s _ptrc_glMultiTexCoord4s +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4sv)(GLenum, const GLshort *); +#define glMultiTexCoord4sv _ptrc_glMultiTexCoord4sv extern void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat, GLboolean); #define glSampleCoverage _ptrc_glSampleCoverage extern void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum); #define glBlendFuncSeparate _ptrc_glBlendFuncSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordPointer)(GLenum, GLsizei, const GLvoid *); +#define glFogCoordPointer _ptrc_glFogCoordPointer +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordd)(GLdouble); +#define glFogCoordd _ptrc_glFogCoordd +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoorddv)(const GLdouble *); +#define glFogCoorddv _ptrc_glFogCoorddv +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordf)(GLfloat); +#define glFogCoordf _ptrc_glFogCoordf +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordfv)(const GLfloat *); +#define glFogCoordfv _ptrc_glFogCoordfv extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum, const GLint *, const GLsizei *, GLsizei); #define glMultiDrawArrays _ptrc_glMultiDrawArrays extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei); @@ -1244,6 +2392,72 @@ extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum, GLint); #define glPointParameteri _ptrc_glPointParameteri extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum, const GLint *); #define glPointParameteriv _ptrc_glPointParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3b)(GLbyte, GLbyte, GLbyte); +#define glSecondaryColor3b _ptrc_glSecondaryColor3b +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3bv)(const GLbyte *); +#define glSecondaryColor3bv _ptrc_glSecondaryColor3bv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3d)(GLdouble, GLdouble, GLdouble); +#define glSecondaryColor3d _ptrc_glSecondaryColor3d +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3dv)(const GLdouble *); +#define glSecondaryColor3dv _ptrc_glSecondaryColor3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3f)(GLfloat, GLfloat, GLfloat); +#define glSecondaryColor3f _ptrc_glSecondaryColor3f +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3fv)(const GLfloat *); +#define glSecondaryColor3fv _ptrc_glSecondaryColor3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3i)(GLint, GLint, GLint); +#define glSecondaryColor3i _ptrc_glSecondaryColor3i +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3iv)(const GLint *); +#define glSecondaryColor3iv _ptrc_glSecondaryColor3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3s)(GLshort, GLshort, GLshort); +#define glSecondaryColor3s _ptrc_glSecondaryColor3s +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3sv)(const GLshort *); +#define glSecondaryColor3sv _ptrc_glSecondaryColor3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ub)(GLubyte, GLubyte, GLubyte); +#define glSecondaryColor3ub _ptrc_glSecondaryColor3ub +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ubv)(const GLubyte *); +#define glSecondaryColor3ubv _ptrc_glSecondaryColor3ubv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ui)(GLuint, GLuint, GLuint); +#define glSecondaryColor3ui _ptrc_glSecondaryColor3ui +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3uiv)(const GLuint *); +#define glSecondaryColor3uiv _ptrc_glSecondaryColor3uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3us)(GLushort, GLushort, GLushort); +#define glSecondaryColor3us _ptrc_glSecondaryColor3us +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3usv)(const GLushort *); +#define glSecondaryColor3usv _ptrc_glSecondaryColor3usv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColorPointer)(GLint, GLenum, GLsizei, const GLvoid *); +#define glSecondaryColorPointer _ptrc_glSecondaryColorPointer +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2d)(GLdouble, GLdouble); +#define glWindowPos2d _ptrc_glWindowPos2d +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2dv)(const GLdouble *); +#define glWindowPos2dv _ptrc_glWindowPos2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2f)(GLfloat, GLfloat); +#define glWindowPos2f _ptrc_glWindowPos2f +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2fv)(const GLfloat *); +#define glWindowPos2fv _ptrc_glWindowPos2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2i)(GLint, GLint); +#define glWindowPos2i _ptrc_glWindowPos2i +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2iv)(const GLint *); +#define glWindowPos2iv _ptrc_glWindowPos2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2s)(GLshort, GLshort); +#define glWindowPos2s _ptrc_glWindowPos2s +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2sv)(const GLshort *); +#define glWindowPos2sv _ptrc_glWindowPos2sv +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3d)(GLdouble, GLdouble, GLdouble); +#define glWindowPos3d _ptrc_glWindowPos3d +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3dv)(const GLdouble *); +#define glWindowPos3dv _ptrc_glWindowPos3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3f)(GLfloat, GLfloat, GLfloat); +#define glWindowPos3f _ptrc_glWindowPos3f +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3fv)(const GLfloat *); +#define glWindowPos3fv _ptrc_glWindowPos3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3i)(GLint, GLint, GLint); +#define glWindowPos3i _ptrc_glWindowPos3i +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3iv)(const GLint *); +#define glWindowPos3iv _ptrc_glWindowPos3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3s)(GLshort, GLshort, GLshort); +#define glWindowPos3s _ptrc_glWindowPos3s +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3sv)(const GLshort *); +#define glWindowPos3sv _ptrc_glWindowPos3sv extern void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum, GLuint); #define glBeginQuery _ptrc_glBeginQuery From 8b5c741358fa3e3b3f21fe0fdd2530cf3c17802a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 15:19:38 +0200 Subject: [PATCH 0512/1509] - check the proper command line option for rejecting a core profile. --- src/win32/win32gliface.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 27cb562e2..4ba6ad300 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -747,8 +747,12 @@ typedef const GLubyte * (APIENTRY *PFNGLGETSTRINGIPROC)(GLenum, GLuint); bool Win32GLVideo::checkCoreUsability() { - // if we explicitly want to disable 4.x features this must fail. - if (Args->CheckParm("-gl3")) return false; + const char *version = Args->CheckValue("-glversion"); + if (version != NULL) + { + if (strtod(version, NULL) < 4.0) return false; + } + if (Args->CheckParm("-noshader")) return false; // GL 4.4 implies GL_ARB_buffer_storage if (strcmp((char*)glGetString(GL_VERSION), "4.4") >= 0) return true; From 090d13b9154352cbcc0648228fa1c9443555e15b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 13:50:05 +0200 Subject: [PATCH 0513/1509] - updated gl_interface to deal with older GL versions. - added the framework for allowing multipass textured dynamic lights again. --- src/gl/renderer/gl_renderer.cpp | 3 +- src/gl/renderer/gl_renderstate.cpp | 2 +- src/gl/scene/gl_flats.cpp | 5 +- src/gl/scene/gl_scene.cpp | 21 +++++-- src/gl/scene/gl_walls.cpp | 4 +- src/gl/shaders/gl_shader.cpp | 34 +++++++---- src/gl/system/gl_interface.cpp | 94 ++++++++++++++++++++++++++---- src/gl/system/gl_interface.h | 21 ++++++- 8 files changed, 151 insertions(+), 33 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 66b68c2c3..3e198b1a0 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -109,7 +109,8 @@ void FGLRenderer::Initialize() mVBO = new FFlatVertexBuffer; mSkyVBO = new FSkyVertexBuffer; - mLights = new FLightBuffer(); + if (gl.lightmethod != LM_SOFTWARE) mLights = new FLightBuffer(); + else mLights = NULL; gl_RenderState.SetVertexBuffer(mVBO); mFBID = 0; SetupLevel(); diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index d7f46e07e..9b9d2d7e5 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -309,7 +309,7 @@ void FRenderState::ApplyMatrices() void FRenderState::ApplyLightIndex(int index) { - if (GLRenderer->mLights->GetBufferType() == GL_UNIFORM_BUFFER && index > -1) + if (index > -1 && GLRenderer->mLights->GetBufferType() == GL_UNIFORM_BUFFER) { index = GLRenderer->mLights->BindUBO(index); } diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 0ec2b5149..c90e9541b 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -193,7 +193,7 @@ void GLFlat::DrawSubsector(subsector_t * sub) //========================================================================== // -// +// this is only used by LM_DEFERRED // //========================================================================== @@ -399,7 +399,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG switch (pass) { case GLPASS_PLAIN: // Single-pass rendering - case GLPASS_ALL: + case GLPASS_ALL: // Same, but also creates the dynlight data. gl_SetColor(lightlevel, rel, Colormap,1.0f); gl_SetFog(lightlevel, rel, &Colormap, false); if (sector->special != GLSector_Skybox) @@ -473,6 +473,7 @@ inline void GLFlat::PutFlat(bool fog) bool masked = gltexture->isMasked() && ((renderflags&SSRF_RENDER3DPLANES) || stack); list = masked ? GLDL_MASKEDFLATS : GLDL_PLAINFLATS; } + dynlightindex = -1; // make sure this is always initialized to something proper. gl_drawinfo->drawlists[list].AddFlat (this); } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 9c2f6505c..7062f0cb6 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -351,7 +351,8 @@ void FGLRenderer::RenderScene(int recursion) // if we don't have a persistently mapped buffer, we have to process all the dynamic lights up front, // so that we don't have to do repeated map/unmap calls on the buffer. - if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && !(gl.flags & RFL_BUFFER_STORAGE)) + bool haslights = mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights; + if (gl.lightmethod == LM_DEFERRED && haslights) { GLRenderer->mLights->Begin(); gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(GLPASS_LIGHTSONLY); @@ -371,12 +372,20 @@ void FGLRenderer::RenderScene(int recursion) int pass; - if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && (gl.flags & RFL_BUFFER_STORAGE)) + if (!haslights || gl.lightmethod == LM_DEFERRED) + { + pass = GLPASS_PLAIN; + } + else if (gl.lightmethod == LM_DIRECT) { pass = GLPASS_ALL; } else { + // Todo: Draw lights with multipass rendering. + // RenderMultpassStuff(); + + // The remaining stuff which is unaffected by dynamic lights is just processed as normal. pass = GLPASS_PLAIN; } @@ -418,6 +427,10 @@ void FGLRenderer::RenderScene(int recursion) // this is the only geometry type on which decals can possibly appear gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawDecals(); + if (gl.lightmethod == LM_SOFTWARE) + { + // also process the render lists with walls and dynamic lights + } gl_RenderState.SetTextureMode(TM_MODULATE); @@ -870,7 +883,7 @@ void FGLRenderer::RenderView (player_t* player) P_FindParticleSubsectors (); - GLRenderer->mLights->Clear(); + if (gl.lightmethod != LM_SOFTWARE) GLRenderer->mLights->Clear(); // NoInterpolateView should have no bearing on camera textures, but needs to be preserved for the main view below. bool saved_niv = NoInterpolateView; @@ -925,7 +938,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei SetFixedColormap(player); gl_RenderState.SetVertexBuffer(mVBO); GLRenderer->mVBO->Reset(); - GLRenderer->mLights->Clear(); + if (gl.lightmethod != LM_SOFTWARE) GLRenderer->mLights->Clear(); // Check if there's some lights. If not some code can be skipped. TThinkerIterator it(STAT_DLIGHT); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 49b2411a9..caf03322d 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1422,7 +1422,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) glseg.y2 = v2->fY(); Colormap = frontsector->ColorMap; flags = 0; - dynlightindex = UINT_MAX; + dynlightindex = -1; lightlist = NULL; int rel = 0; @@ -1681,7 +1681,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * bottomflat = frontsector->GetTexture(sector_t::floor); topplane = frontsector->ceilingplane; bottomplane = frontsector->floorplane; - dynlightindex = UINT_MAX; + dynlightindex = -1; zfloor[0] = zfloor[1] = ffh; diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index aa8dfac2b..493d81818 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -87,25 +87,37 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * // // The following code uses GetChars on the strings to get rid of terminating 0 characters. Do not remove or the code may break! // - unsigned int lightbuffertype = GLRenderer->mLights->GetBufferType(); - unsigned int lightbuffersize = GLRenderer->mLights->GetBlockSize(); - FString vp_comb; - if (lightbuffertype == GL_UNIFORM_BUFFER) + if (gl.lightmethod == LM_SOFTWARE) { - if (gl.glslversion < 1.4f || gl.version < 3.1f) + if (gl.compatibility >= CMPT_GL3) { - vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); - } - else - { - vp_comb.Format("#version 140\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); + vp_comb = "#version 130\n"; } } else { - vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n"; + assert(GLRenderer->mLights != NULL); + // On the shader side there is no difference between LM_DEFERRED and LM_DIRECT, it only matters which buffer type is used by the light buffer. + unsigned int lightbuffertype = GLRenderer->mLights->GetBufferType(); + unsigned int lightbuffersize = GLRenderer->mLights->GetBlockSize(); + if (lightbuffertype == GL_UNIFORM_BUFFER) + { + // This differentiation is for some Intel drivers which fail on #extension, so use of #version 140 is necessary + if (gl.glslversion < 1.4f || gl.version < 3.1f) + { + vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); + } + else + { + vp_comb.Format("#version 140\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); + } + } + else + { + vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n"; + } } vp_comb << defines << i_data.GetString().GetChars(); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 7b46d1a5e..d057ad140 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -107,35 +107,77 @@ static void InitContext() // //========================================================================== +#define FUDGE_FUNC(name, ext) if (_ptrc_##name == NULL) _ptrc_##name = _ptrc_##name##ext; + + void gl_LoadExtensions() { InitContext(); CollectExtensions(); const char *version = Args->CheckValue("-glversion"); - if (version == NULL) version = (const char*)glGetString(GL_VERSION); - else Printf("Emulating OpenGL v %s\n", version); + const char *glversion = (const char*)glGetString(GL_VERSION); + + if (version == NULL) + { + version = glversion; + } + else + { + double v1 = strtod(version, NULL); + double v2 = strtod(glversion, NULL); + if (v2 < v1) version = glversion; + else Printf("Emulating OpenGL v %s\n", version); + } + + gl.version = strtod(version, NULL) + 0.01f; // Don't even start if it's lower than 3.0 - if (strcmp(version, "3.0") < 0) + if ((gl.version < 2.0 || !CheckExtension("GL_EXT_framebuffer_object")) && gl.version < 3.0) { - I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 3.0 is required to run " GAMENAME ".\n"); + I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 2.0 with framebuffer support is required to run " GAMENAME ".\n"); } // add 0.01 to account for roundoff errors making the number a tad smaller than the actual version - gl.version = strtod(version, NULL) + 0.01f; gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL) + 0.01f; gl.vendorstring = (char*)glGetString(GL_VENDOR); + gl.lightmethod = LM_SOFTWARE; if (gl.version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) { gl.flags |= RFL_SAMPLER_OBJECTS; } + + // Buffer lighting is only feasible with GLSL 1.3 and higher, even if 1.2 supports the extension. + if (gl.version > 3.0f && (gl.version >= 3.3f || CheckExtension("GL_ARB_uniform_buffer_object"))) + { + gl.flags |= RFL_SAMPLER_OBJECTS; + gl.lightmethod = LM_DEFERRED; + } - if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; - if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; - if (!Args->CheckParm("-gl3")) + if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION; + if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags |= RFL_TEXTURE_COMPRESSION_S3TC; + + if (Args->CheckParm("-noshader")) + { + gl.compatibility = CMPT_GL2; // force the low end path + } + if (gl.version < 3.0f) + { + if (CheckExtension("GL_NV_GPU_shader4") || CheckExtension("GL_EXT_GPU_shader4")) gl.compatibility = CMPT_GL2_SHADER; // for pre-3.0 drivers that support capable hardware. Needed for Apple. + else gl.compatibility = CMPT_GL2; + } + else if (gl.version < 4.f) + { + if (strstr(gl.vendorstring, "ATI Tech")) + { + gl.compatibility = CMPT_GL2_SHADER; // most of these drivers are irreperably broken with GLSL 1.3 and higher. + gl.lightmethod = LM_SOFTWARE; // do not use uniform buffers with the fallback shader, it may cause problems. + } + else gl.compatibility = CMPT_GL3; + } + else { // don't use GL 4.x features when running in GL 3 emulation mode. if (CheckExtension("GL_ARB_buffer_storage")) @@ -151,9 +193,22 @@ void gl_LoadExtensions() } } gl.flags |= RFL_BUFFER_STORAGE; + gl.compatibility = CMPT_GL4; + gl.lightmethod = LM_DIRECT; + } + else + { + gl.compatibility = CMPT_GL3; } } - + + const char *lm = Args->CheckValue("-lightmethod"); + if (lm != NULL) + { + if (!stricmp(lm, "deferred") && gl.lightmethod == LM_DIRECT) gl.lightmethod = LM_DEFERRED; + if (!stricmp(lm, "textured")) gl.lightmethod = LM_SOFTWARE; + } + int v; glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); gl.maxuniforms = v; @@ -161,9 +216,26 @@ void gl_LoadExtensions() gl.maxuniformblock = v; glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v); gl.uniformblockalignment = v; - - glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); + + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + // fudge a bit with the framebuffer stuff to avoid redundancies in the main code. Some of the older cards do not have the ARB stuff but the calls are nearly identical. + FUDGE_FUNC(glGenerateMipmap, EXT); + FUDGE_FUNC(glGenFramebuffers, EXT); + FUDGE_FUNC(glBindFramebuffer, EXT); + FUDGE_FUNC(glDeleteFramebuffers, EXT); + FUDGE_FUNC(glFramebufferTexture2D, EXT); + FUDGE_FUNC(glGenerateMipmap, EXT); + FUDGE_FUNC(glGenFramebuffers, EXT); + FUDGE_FUNC(glBindFramebuffer, EXT); + FUDGE_FUNC(glDeleteFramebuffers, EXT); + FUDGE_FUNC(glFramebufferTexture2D, EXT); + FUDGE_FUNC(glFramebufferRenderbuffer, EXT); + FUDGE_FUNC(glGenRenderbuffers, EXT); + FUDGE_FUNC(glDeleteRenderbuffers, EXT); + FUDGE_FUNC(glRenderbufferStorage, EXT); + FUDGE_FUNC(glBindRenderbuffer, EXT); } //========================================================================== diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 6988f873e..5248c2f8b 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -3,6 +3,14 @@ #include "basictypes.h" +enum GLCompat +{ + CMPT_GL2, + CMPT_GL2_SHADER, + CMPT_GL3, + CMPT_GL4 +}; + enum RenderFlags { // [BB] Added texture compression flags. @@ -11,7 +19,7 @@ enum RenderFlags RFL_SHADER_STORAGE_BUFFER = 4, RFL_BUFFER_STORAGE = 8, - RFL_SAMPLER_OBJECTS = 16 + RFL_SAMPLER_OBJECTS = 16, }; enum TexMode @@ -22,6 +30,15 @@ enum TexMode TM_INVERSE, // (1-r, 1-g, 1-b, a) TM_REDTOALPHA, // (1, 1, 1, r) TM_CLAMPY, // (r, g, b, (t >= 0.0 && t <= 1.0)? a:0) + + TM_INVERTOPAQUE, // used by GL 2.x fallback code. +}; + +enum ELightMethod +{ + LM_SOFTWARE = 0, // multi-pass texturing + LM_DEFERRED = 1, // calculate lights up front in a separate pass + LM_DIRECT = 2, // calculate lights on the fly along with the render data }; struct RenderContext @@ -30,6 +47,8 @@ struct RenderContext unsigned int maxuniforms; unsigned int maxuniformblock; unsigned int uniformblockalignment; + int lightmethod; + int compatibility; float version; float glslversion; int max_texturesize; From ee9a40f5e94458a83502330d6343e8a13b8c08b0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 14:03:10 +0200 Subject: [PATCH 0514/1509] - replace FLOATTYPE with float in stereo3d code. --- src/gl/stereo3d/gl_anaglyph.cpp | 6 ++-- src/gl/stereo3d/gl_stereo3d.cpp | 4 +-- src/gl/stereo3d/gl_stereo3d.h | 4 +-- src/gl/stereo3d/gl_stereo_leftright.cpp | 12 ++++---- src/gl/stereo3d/gl_stereo_leftright.h | 40 ++++++++++++------------- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/gl/stereo3d/gl_anaglyph.cpp b/src/gl/stereo3d/gl_anaglyph.cpp index 7cc66e28b..c84c35091 100644 --- a/src/gl/stereo3d/gl_anaglyph.cpp +++ b/src/gl/stereo3d/gl_anaglyph.cpp @@ -46,7 +46,7 @@ MaskAnaglyph::MaskAnaglyph(const ColorMask& leftColorMask, double ipdMeters) /* static */ -const GreenMagenta& GreenMagenta::getInstance(FLOATTYPE ipd) +const GreenMagenta& GreenMagenta::getInstance(float ipd) { static GreenMagenta instance(ipd); return instance; @@ -54,7 +54,7 @@ const GreenMagenta& GreenMagenta::getInstance(FLOATTYPE ipd) /* static */ -const RedCyan& RedCyan::getInstance(FLOATTYPE ipd) +const RedCyan& RedCyan::getInstance(float ipd) { static RedCyan instance(ipd); return instance; @@ -62,7 +62,7 @@ const RedCyan& RedCyan::getInstance(FLOATTYPE ipd) /* static */ -const AmberBlue& AmberBlue::getInstance(FLOATTYPE ipd) +const AmberBlue& AmberBlue::getInstance(float ipd) { static AmberBlue instance(ipd); return instance; diff --git a/src/gl/stereo3d/gl_stereo3d.cpp b/src/gl/stereo3d/gl_stereo3d.cpp index d7f5183d0..d686a4a43 100644 --- a/src/gl/stereo3d/gl_stereo3d.cpp +++ b/src/gl/stereo3d/gl_stereo3d.cpp @@ -43,7 +43,7 @@ namespace s3d { /* virtual */ -VSMatrix EyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const +VSMatrix EyePose::GetProjection(float fov, float aspectRatio, float fovRatio) const { VSMatrix result; @@ -62,7 +62,7 @@ Viewport EyePose::GetViewport(const Viewport& fullViewport) const /* virtual */ -void EyePose::GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const +void EyePose::GetViewShift(float yaw, float outViewShift[3]) const { // pass-through for Mono view outViewShift[0] = 0; diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h index 48b6ef900..303f18825 100644 --- a/src/gl/stereo3d/gl_stereo3d.h +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -60,9 +60,9 @@ class EyePose public: EyePose() {} virtual ~EyePose() {} - virtual VSMatrix GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const; + virtual VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio) const; virtual Viewport GetViewport(const Viewport& fullViewport) const; - virtual void GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const; + virtual void GetViewShift(float yaw, float outViewShift[3]) const; virtual void SetUp() const {}; virtual void TearDown() const {}; }; diff --git a/src/gl/stereo3d/gl_stereo_leftright.cpp b/src/gl/stereo3d/gl_stereo_leftright.cpp index 7b12283d2..354185792 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.cpp +++ b/src/gl/stereo3d/gl_stereo_leftright.cpp @@ -47,7 +47,7 @@ namespace s3d { /* virtual */ -VSMatrix ShiftedEyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const +VSMatrix ShiftedEyePose::GetProjection(float fov, float aspectRatio, float fovRatio) const { double zNear = 5.0; double zFar = 65536.0; @@ -71,10 +71,10 @@ VSMatrix ShiftedEyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLO /* virtual */ -void ShiftedEyePose::GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const +void ShiftedEyePose::GetViewShift(float yaw, float outViewShift[3]) const { - FLOATTYPE dx = -cos(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; - FLOATTYPE dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; + float dx = -cos(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; + float dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; outViewShift[0] = dx; outViewShift[1] = dy; outViewShift[2] = 0; @@ -82,7 +82,7 @@ void ShiftedEyePose::GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) cons /* static */ -const LeftEyeView& LeftEyeView::getInstance(FLOATTYPE ipd) +const LeftEyeView& LeftEyeView::getInstance(float ipd) { static LeftEyeView instance(ipd); instance.setIpd(ipd); @@ -91,7 +91,7 @@ const LeftEyeView& LeftEyeView::getInstance(FLOATTYPE ipd) /* static */ -const RightEyeView& RightEyeView::getInstance(FLOATTYPE ipd) +const RightEyeView& RightEyeView::getInstance(float ipd) { static RightEyeView instance(ipd); instance.setIpd(ipd); diff --git a/src/gl/stereo3d/gl_stereo_leftright.h b/src/gl/stereo3d/gl_stereo_leftright.h index 6bca9de90..de13a32cb 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.h +++ b/src/gl/stereo3d/gl_stereo_leftright.h @@ -44,31 +44,31 @@ namespace s3d { class ShiftedEyePose : public EyePose { public: - ShiftedEyePose(FLOATTYPE shift) : shift(shift) {}; - FLOATTYPE getShift() const { return shift; } - void setShift(FLOATTYPE shift) { this->shift = shift; } - virtual VSMatrix GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const; - virtual void GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const; + ShiftedEyePose(float shift) : shift(shift) {}; + float getShift() const { return shift; } + void setShift(float shift) { this->shift = shift; } + virtual VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio) const; + virtual void GetViewShift(float yaw, float outViewShift[3]) const; protected: - FLOATTYPE shift; + float shift; }; class LeftEyePose : public ShiftedEyePose { public: - LeftEyePose(FLOATTYPE ipd) : ShiftedEyePose( FLOATTYPE(-0.5) * ipd) {} - FLOATTYPE getIpd() const { return FLOATTYPE(-2.0)*getShift(); } - void setIpd(FLOATTYPE ipd) { setShift(FLOATTYPE(-0.5)*ipd); } + LeftEyePose(float ipd) : ShiftedEyePose( float(-0.5) * ipd) {} + float getIpd() const { return float(-2.0)*getShift(); } + void setIpd(float ipd) { setShift(float(-0.5)*ipd); } }; class RightEyePose : public ShiftedEyePose { public: - RightEyePose(FLOATTYPE ipd) : ShiftedEyePose(FLOATTYPE(+0.5)*ipd) {} - FLOATTYPE getIpd() const { return FLOATTYPE(+2.0)*shift; } - void setIpd(FLOATTYPE ipd) { setShift(FLOATTYPE(+0.5)*ipd); } + RightEyePose(float ipd) : ShiftedEyePose(float(+0.5)*ipd) {} + float getIpd() const { return float(+2.0)*shift; } + void setIpd(float ipd) { setShift(float(+0.5)*ipd); } }; @@ -78,11 +78,11 @@ public: class LeftEyeView : public Stereo3DMode { public: - static const LeftEyeView& getInstance(FLOATTYPE ipd); + static const LeftEyeView& getInstance(float ipd); - LeftEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.Push(&eye); } - FLOATTYPE getIpd() const { return eye.getIpd(); } - void setIpd(FLOATTYPE ipd) { eye.setIpd(ipd); } + LeftEyeView(float ipd) : eye(ipd) { eye_ptrs.Push(&eye); } + float getIpd() const { return eye.getIpd(); } + void setIpd(float ipd) { eye.setIpd(ipd); } protected: LeftEyePose eye; }; @@ -91,11 +91,11 @@ protected: class RightEyeView : public Stereo3DMode { public: - static const RightEyeView& getInstance(FLOATTYPE ipd); + static const RightEyeView& getInstance(float ipd); - RightEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.Push(&eye); } - FLOATTYPE getIpd() const { return eye.getIpd(); } - void setIpd(FLOATTYPE ipd) { eye.setIpd(ipd); } + RightEyeView(float ipd) : eye(ipd) { eye_ptrs.Push(&eye); } + float getIpd() const { return eye.getIpd(); } + void setIpd(float ipd) { eye.setIpd(ipd); } protected: RightEyePose eye; }; From f066457a48b623e82434724af2cec01b04db4dbe Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 15:01:23 +0200 Subject: [PATCH 0515/1509] - add shader patching to allow running the engine with GLSL 1.2. - made some initial preparations for the shader-less fallback path. --- src/gl/data/gl_vertexbuffer.cpp | 17 +++++- src/gl/renderer/gl_renderstate.cpp | 9 ++- src/gl/shaders/gl_shader.cpp | 92 ++++++++++++++++++++++++------ src/gl/system/gl_interface.cpp | 6 +- src/gl/textures/gl_hqresize.cpp | 4 ++ src/gl/textures/gl_hwtexture.cpp | 3 +- src/win32/win32gliface.cpp | 1 - wadsrc/static/shaders/glsl/main.fp | 2 +- 8 files changed, 108 insertions(+), 26 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index fdce68702..223fb67f8 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -138,10 +138,21 @@ void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offs // this will only get called if we can't acquire a persistently mapped buffer. #ifndef CORE_PROFILE glBegin(primtype); - for (unsigned int i = 0; i < count; i++) + if (gl.compatibility > CMPT_GL2) { - glVertexAttrib2fv(VATTR_TEXCOORD, &map[offset + i].u); - glVertexAttrib3fv(VATTR_VERTEX, &map[offset + i].x); + for (unsigned int i = 0; i < count; i++) + { + glVertexAttrib2fv(VATTR_TEXCOORD, &map[offset + i].u); + glVertexAttrib3fv(VATTR_VERTEX, &map[offset + i].x); + } + } + else // no shader means no vertex attributes, so use the old stuff instead. + { + for (unsigned int i = 0; i < count; i++) + { + glTexCoord2fv(&map[offset + i].u); + glVertex3fv(&map[offset + i].x); + } } glEnd(); #endif diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 9b9d2d7e5..892e384e7 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -279,7 +279,14 @@ void FRenderState::Apply() else mVertexBuffer->BindVBO(); mCurrentVertexBuffer = mVertexBuffer; } - ApplyShader(); + if (gl.compatibility > CMPT_GL2) + { + ApplyShader(); + } + else + { + //ApplyFixedFunction(); + } } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 493d81818..4a82251d0 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -59,6 +59,44 @@ #include "gl/textures/gl_material.h" #include "gl/dynlights/gl_lightbuffer.h" +//========================================================================== +// +// patch the shader source to work with +// GLSL 1.2 keywords and identifiers +// +//========================================================================== + +void PatchCommon(FString &code) +{ + code.Substitute("precision highp int;", ""); + code.Substitute("precision highp float;", ""); +} + +void PatchVertShader(FString &code) +{ + PatchCommon(code); + code.Substitute("out vec", "varying vec"); + code.Substitute("gl_ClipDistance", "//"); +} + +void PatchFragShader(FString &code) +{ + PatchCommon(code); + code.Substitute("out vec4 FragColor;", ""); + code.Substitute("FragColor", "gl_FragColor"); + code.Substitute("in vec", "varying vec"); + // this patches the switch statement to if's. + code.Substitute("break;", ""); + code.Substitute("switch (uFixedColormap)", "int i = uFixedColormap;"); + code.Substitute("case 0:", "if (i == 0)"); + code.Substitute("case 1:", "else if (i == 1)"); + code.Substitute("case 2:", "else if (i == 2)"); + code.Substitute("case 3:", "else if (i == 3)"); + code.Substitute("case 4:", "else if (i == 4)"); + code.Substitute("case 5:", "else if (i == 5)"); + code.Substitute("texture(", "texture2D("); +} + //========================================================================== // // @@ -95,6 +133,10 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * { vp_comb = "#version 130\n"; } + else + { + vp_comb = "#define GLSL12_COMPATIBLE\n"; + } } else { @@ -159,6 +201,12 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * } } + if (gl.compatibility < CMPT_GL3) + { + PatchVertShader(vp_comb); + PatchFragShader(fp_comb); + } + hVertProg = glCreateShader(GL_VERTEX_SHADER); hFragProg = glCreateShader(GL_FRAGMENT_SHADER); @@ -391,7 +439,7 @@ static const FEffectShader effectshaders[]= FShaderManager::FShaderManager() { - CompileShaders(); + if (gl.compatibility > CMPT_GL2) CompileShaders(); } //========================================================================== @@ -402,7 +450,7 @@ FShaderManager::FShaderManager() FShaderManager::~FShaderManager() { - Clean(); + if (gl.compatibility > CMPT_GL2) Clean(); } //========================================================================== @@ -544,25 +592,35 @@ EXTERN_CVAR(Int, gl_fuzztype) void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view) { - for (int i = 0; i < 4; i++) + if (gl.compatibility == CMPT_GL2) { - mTextureEffects[i]->ApplyMatrices(proj, view); - mTextureEffectsNAT[i]->ApplyMatrices(proj, view); + glMatrixMode(GL_PROJECTION); + glLoadMatrixf(proj->get()); + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(view->get()); } - mTextureEffects[4]->ApplyMatrices(proj, view); - if (gl_fuzztype != 0) + else { - mTextureEffects[4+gl_fuzztype]->ApplyMatrices(proj, view); + for (int i = 0; i < 4; i++) + { + mTextureEffects[i]->ApplyMatrices(proj, view); + mTextureEffectsNAT[i]->ApplyMatrices(proj, view); + } + mTextureEffects[4]->ApplyMatrices(proj, view); + if (gl_fuzztype != 0) + { + mTextureEffects[4 + gl_fuzztype]->ApplyMatrices(proj, view); + } + for (unsigned i = 12; i < mTextureEffects.Size(); i++) + { + mTextureEffects[i]->ApplyMatrices(proj, view); + } + for (int i = 0; i < MAX_EFFECTS; i++) + { + mEffectShaders[i]->ApplyMatrices(proj, view); + } + if (mActiveShader != NULL) mActiveShader->Bind(); } - for (unsigned i = 12; i < mTextureEffects.Size(); i++) - { - mTextureEffects[i]->ApplyMatrices(proj, view); - } - for (int i = 0; i < MAX_EFFECTS; i++) - { - mEffectShaders[i]->ApplyMatrices(proj, view); - } - if (mActiveShader != NULL) mActiveShader->Bind(); } //========================================================================== diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index d057ad140..d2b69ad0a 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -152,7 +152,6 @@ void gl_LoadExtensions() // Buffer lighting is only feasible with GLSL 1.3 and higher, even if 1.2 supports the extension. if (gl.version > 3.0f && (gl.version >= 3.3f || CheckExtension("GL_ARB_uniform_buffer_object"))) { - gl.flags |= RFL_SAMPLER_OBJECTS; gl.lightmethod = LM_DEFERRED; } @@ -161,9 +160,10 @@ void gl_LoadExtensions() if (Args->CheckParm("-noshader")) { + gl.version = 2.1f; gl.compatibility = CMPT_GL2; // force the low end path } - if (gl.version < 3.0f) + else if (gl.version < 3.0f) { if (CheckExtension("GL_NV_GPU_shader4") || CheckExtension("GL_EXT_GPU_shader4")) gl.compatibility = CMPT_GL2_SHADER; // for pre-3.0 drivers that support capable hardware. Needed for Apple. else gl.compatibility = CMPT_GL2; @@ -172,6 +172,7 @@ void gl_LoadExtensions() { if (strstr(gl.vendorstring, "ATI Tech")) { + gl.version = 2.1f; gl.compatibility = CMPT_GL2_SHADER; // most of these drivers are irreperably broken with GLSL 1.3 and higher. gl.lightmethod = LM_SOFTWARE; // do not use uniform buffers with the fallback shader, it may cause problems. } @@ -198,6 +199,7 @@ void gl_LoadExtensions() } else { + gl.version = 3.3f; gl.compatibility = CMPT_GL3; } } diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 55cf88fb1..993e9f138 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -263,6 +263,10 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u if ( inputTexture->bHasCanvas ) return inputBuffer; + // [BB] Don't upsample non-shader handled warped textures. Needs too much memory and time + if (gl.compatibility == CMPT_GL2 && inputTexture->bWarped) + return inputBuffer; + // already scaled? if (inputTexture->Scale.X >= 2 && inputTexture->Scale.Y >= 2) return inputBuffer; diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index c855ef285..02ed64290 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -424,6 +424,7 @@ int FHardwareTexture::GetDepthBuffer() void FHardwareTexture::BindToFrameBuffer() { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glDefTex.glTexID, 0); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); } diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 4ba6ad300..9ce3c8837 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -782,7 +782,6 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) if (!SetupPixelFormat(multisample)) { - I_Error ("R_OPENGL: Unabl...\n"); return false; } diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index f6273fc09..af5b30a03 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -170,7 +170,7 @@ vec4 getLightColor(float fogdist, float fogfactor) float newlightlevel = 1.0 - R_DoomLightingEquation(uLightLevel, gl_FragCoord.z); color.rgb *= newlightlevel; } - else if (uFogEnabled > 0.0) + else if (uFogEnabled > 0) { // brightening around the player for light mode 2 if (fogdist < uLightDist) From 3b1500438dc4a78cfb02f0a64926858e13b90b20 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 16:26:34 +0200 Subject: [PATCH 0516/1509] - got rid of VAO's. they have no impact on performance and are a general nuisance if some render paths cannot use them. - cleaned up gl_interface and removed gl.compatibility. --- src/gl/data/gl_vertexbuffer.cpp | 50 ++++++++++++++++-------------- src/gl/data/gl_vertexbuffer.h | 10 ++++-- src/gl/models/gl_models.cpp | 15 ++++++--- src/gl/renderer/gl_renderer.cpp | 15 +++++++++ src/gl/renderer/gl_renderer.h | 1 + src/gl/renderer/gl_renderstate.cpp | 2 +- src/gl/scene/gl_skydome.cpp | 15 ++++----- src/gl/shaders/gl_shader.cpp | 10 +++--- src/gl/system/gl_interface.cpp | 17 +++++----- src/gl/system/gl_interface.h | 1 - src/gl/textures/gl_hqresize.cpp | 2 +- 11 files changed, 82 insertions(+), 56 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 223fb67f8..a0865c435 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -57,12 +57,10 @@ // //========================================================================== -FVertexBuffer::FVertexBuffer() +FVertexBuffer::FVertexBuffer(bool wantbuffer) { - vao_id = vbo_id = 0; - glGenBuffers(1, &vbo_id); - glGenVertexArrays(1, &vao_id); - + vbo_id = 0; + if (wantbuffer) glGenBuffers(1, &vbo_id); } FVertexBuffer::~FVertexBuffer() @@ -71,15 +69,6 @@ FVertexBuffer::~FVertexBuffer() { glDeleteBuffers(1, &vbo_id); } - if (vao_id != 0) - { - glDeleteVertexArrays(1, &vao_id); - } -} - -void FVertexBuffer::BindVBO() -{ - glBindVertexArray(vao_id); } //========================================================================== @@ -89,7 +78,7 @@ void FVertexBuffer::BindVBO() //========================================================================== FFlatVertexBuffer::FFlatVertexBuffer() -: FVertexBuffer() +: FVertexBuffer(!!(gl.flags & RFL_BUFFER_STORAGE)) { if (gl.flags & RFL_BUFFER_STORAGE) { @@ -97,17 +86,10 @@ FFlatVertexBuffer::FFlatVertexBuffer() glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); - - glBindVertexArray(vao_id); - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glVertexAttribPointer(VATTR_VERTEX, 3,GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); - glVertexAttribPointer(VATTR_TEXCOORD, 2,GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); - glEnableVertexAttribArray(VATTR_VERTEX); - glEnableVertexAttribArray(VATTR_TEXCOORD); - glBindVertexArray(0); } else { + // The fallback path uses immediate mode rendering and does not set up an actual vertex buffer vbo_shadowdata.Reserve(BUFFER_SIZE); map = &vbo_shadowdata[0]; } @@ -124,6 +106,26 @@ FFlatVertexBuffer::~FFlatVertexBuffer() } } + +void FFlatVertexBuffer::BindVBO() +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + if (vbo_id != 0) // set this up only if there is an actual buffer. + { + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); + glEnableVertexAttribArray(VATTR_VERTEX); + glEnableVertexAttribArray(VATTR_TEXCOORD); + } + else + { + glDisableVertexAttribArray(VATTR_VERTEX); + glDisableVertexAttribArray(VATTR_TEXCOORD); + } + glDisableVertexAttribArray(VATTR_COLOR); + glDisableVertexAttribArray(VATTR_VERTEX2); +} + //========================================================================== // // immediate mode fallback for drivers without GL_ARB_buffer_storage @@ -138,7 +140,7 @@ void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offs // this will only get called if we can't acquire a persistently mapped buffer. #ifndef CORE_PROFILE glBegin(primtype); - if (gl.compatibility > CMPT_GL2) + if (gl.glslversion > 0) { for (unsigned int i = 0; i < count; i++) { diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 12b536f10..c56cadcba 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -15,12 +15,11 @@ class FVertexBuffer { protected: unsigned int vbo_id; - unsigned int vao_id; public: - FVertexBuffer(); + FVertexBuffer(bool wantbuffer = true); virtual ~FVertexBuffer(); - void BindVBO(); + virtual void BindVBO() = 0; }; struct FFlatVertex @@ -37,6 +36,7 @@ struct FFlatVertex u = uu; v = vv; } + void BindVBO(); }; #define VTO ((FFlatVertex*)NULL) @@ -62,6 +62,8 @@ public: FFlatVertexBuffer(); ~FFlatVertexBuffer(); + void BindVBO(); + void CreateVBO(); void CheckUpdate(sector_t *sector); @@ -165,6 +167,7 @@ public: FSkyVertexBuffer(); virtual ~FSkyVertexBuffer(); void RenderDome(FMaterial *tex, int mode); + void BindVBO(); }; @@ -208,6 +211,7 @@ public: void UnlockIndexBuffer(); unsigned int SetupFrame(unsigned int frame1, unsigned int frame2); + void BindVBO(); }; #define VMO ((FModelVertex*)NULL) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 6050ac24d..abf3efcd5 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -117,20 +117,27 @@ void gl_FlushModels() FModelVertexBuffer::FModelVertexBuffer(bool needindex) { - glBindVertexArray(vao_id); - ibo_id = 0; if (needindex) { glGenBuffers(1, &ibo_id); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); } +} +//=========================================================================== +// +// +// +//=========================================================================== + +void FModelVertexBuffer::BindVBO() +{ + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glEnableVertexAttribArray(VATTR_VERTEX); glEnableVertexAttribArray(VATTR_TEXCOORD); glEnableVertexAttribArray(VATTR_VERTEX2); - glBindVertexArray(0); + glDisableVertexAttribArray(VATTR_COLOR); } //=========================================================================== diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 3e198b1a0..cca2e9b2b 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -103,6 +103,14 @@ void gl_FlushModels(); void FGLRenderer::Initialize() { + // Only needed for the core profile, because someone decided it was a good idea to remove the default VAO. + if (gl.version >= 4.0) + { + glGenVertexArrays(1, &mVAOID); + glBindVertexArray(mVAOID); + } + else mVAOID = 0; + glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch); glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch); mirrortexture = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/mirror.png"), FTexture::TEX_MiscPatch); @@ -113,6 +121,7 @@ void FGLRenderer::Initialize() else mLights = NULL; gl_RenderState.SetVertexBuffer(mVBO); mFBID = 0; + SetupLevel(); mShaderManager = new FShaderManager; mSamplerManager = new FSamplerManager; @@ -133,6 +142,12 @@ FGLRenderer::~FGLRenderer() if (glpart) delete glpart; if (mirrortexture) delete mirrortexture; if (mFBID != 0) glDeleteFramebuffers(1, &mFBID); + if (mVAOID != 0) + { + glBindVertexArray(0); + glDeleteVertexArrays(1, &mVAOID); + } + } //=========================================================================== diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index a2f4c7d34..f266bcd37 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -69,6 +69,7 @@ public: FSamplerManager *mSamplerManager; int gl_spriteindex; unsigned int mFBID; + unsigned int mVAOID; FTexture *glpart2; FTexture *glpart; diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 892e384e7..1398191e1 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -279,7 +279,7 @@ void FRenderState::Apply() else mVertexBuffer->BindVBO(); mCurrentVertexBuffer = mVertexBuffer; } - if (gl.compatibility > CMPT_GL2) + if (gl.glslversion > 0) { ApplyShader(); } diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 69968ddf7..ae78b0291 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -78,8 +78,14 @@ extern int skyfog; FSkyVertexBuffer::FSkyVertexBuffer() { CreateDome(); +} - glBindVertexArray(vao_id); +FSkyVertexBuffer::~FSkyVertexBuffer() +{ +} + +void FSkyVertexBuffer::BindVBO() +{ glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->x); glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->u); @@ -87,12 +93,7 @@ FSkyVertexBuffer::FSkyVertexBuffer() glEnableVertexAttribArray(VATTR_VERTEX); glEnableVertexAttribArray(VATTR_TEXCOORD); glEnableVertexAttribArray(VATTR_COLOR); - glBindVertexArray(0); - -} - -FSkyVertexBuffer::~FSkyVertexBuffer() -{ + glDisableVertexAttribArray(VATTR_VERTEX2); } //----------------------------------------------------------------------------- diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 4a82251d0..af6accdb5 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -129,7 +129,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * if (gl.lightmethod == LM_SOFTWARE) { - if (gl.compatibility >= CMPT_GL3) + if (gl.glslversion >= 1.3) { vp_comb = "#version 130\n"; } @@ -201,7 +201,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * } } - if (gl.compatibility < CMPT_GL3) + if (gl.glslversion < 1.3) { PatchVertShader(vp_comb); PatchFragShader(fp_comb); @@ -439,7 +439,7 @@ static const FEffectShader effectshaders[]= FShaderManager::FShaderManager() { - if (gl.compatibility > CMPT_GL2) CompileShaders(); + if (gl.glslversion > 0) CompileShaders(); } //========================================================================== @@ -450,7 +450,7 @@ FShaderManager::FShaderManager() FShaderManager::~FShaderManager() { - if (gl.compatibility > CMPT_GL2) Clean(); + if (gl.glslversion > 0) Clean(); } //========================================================================== @@ -592,7 +592,7 @@ EXTERN_CVAR(Int, gl_fuzztype) void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view) { - if (gl.compatibility == CMPT_GL2) + if (gl.glslversion == 0) { glMatrixMode(GL_PROJECTION); glLoadMatrixf(proj->get()); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index d2b69ad0a..12e879a23 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -158,25 +158,24 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags |= RFL_TEXTURE_COMPRESSION_S3TC; - if (Args->CheckParm("-noshader")) + if (Args->CheckParm("-noshader") || gl.glslversion < 1.2f) { - gl.version = 2.1f; - gl.compatibility = CMPT_GL2; // force the low end path + gl.version = 2.11f; + gl.glslversion = 0; } else if (gl.version < 3.0f) { - if (CheckExtension("GL_NV_GPU_shader4") || CheckExtension("GL_EXT_GPU_shader4")) gl.compatibility = CMPT_GL2_SHADER; // for pre-3.0 drivers that support capable hardware. Needed for Apple. - else gl.compatibility = CMPT_GL2; + if (CheckExtension("GL_NV_GPU_shader4") || CheckExtension("GL_EXT_GPU_shader4")) gl.glslversion = 1.21f; // for pre-3.0 drivers that support capable hardware. Needed for Apple. + else gl.glslversion = 0; } else if (gl.version < 4.f) { if (strstr(gl.vendorstring, "ATI Tech")) { - gl.version = 2.1f; - gl.compatibility = CMPT_GL2_SHADER; // most of these drivers are irreperably broken with GLSL 1.3 and higher. + gl.version = 2.11f; + gl.glslversion = 1.21f; gl.lightmethod = LM_SOFTWARE; // do not use uniform buffers with the fallback shader, it may cause problems. } - else gl.compatibility = CMPT_GL3; } else { @@ -194,13 +193,11 @@ void gl_LoadExtensions() } } gl.flags |= RFL_BUFFER_STORAGE; - gl.compatibility = CMPT_GL4; gl.lightmethod = LM_DIRECT; } else { gl.version = 3.3f; - gl.compatibility = CMPT_GL3; } } diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 5248c2f8b..433c2327c 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -48,7 +48,6 @@ struct RenderContext unsigned int maxuniformblock; unsigned int uniformblockalignment; int lightmethod; - int compatibility; float version; float glslversion; int max_texturesize; diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 993e9f138..785f3c6e9 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -264,7 +264,7 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u return inputBuffer; // [BB] Don't upsample non-shader handled warped textures. Needs too much memory and time - if (gl.compatibility == CMPT_GL2 && inputTexture->bWarped) + if (gl.glslversion == 0 && inputTexture->bWarped) return inputBuffer; // already scaled? From eb2705785390fa50da6fb0d62894de1995cadd35 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 16:44:03 +0200 Subject: [PATCH 0517/1509] - enable shader-less rendering. Still very incomplete, but at least the basics are working. --- src/gl/data/gl_vertexbuffer.cpp | 27 ++++++++++++++++--------- src/gl/models/gl_models.cpp | 32 +++++++++++++++++++++++------- src/gl/renderer/gl_renderstate.cpp | 9 ++++++--- src/gl/scene/gl_skydome.cpp | 26 +++++++++++++++++------- src/gl/system/gl_interface.cpp | 1 + 5 files changed, 69 insertions(+), 26 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index a0865c435..96343b284 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -110,20 +110,29 @@ FFlatVertexBuffer::~FFlatVertexBuffer() void FFlatVertexBuffer::BindVBO() { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - if (vbo_id != 0) // set this up only if there is an actual buffer. + if (gl.glslversion > 0) { - glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); - glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); - glEnableVertexAttribArray(VATTR_VERTEX); - glEnableVertexAttribArray(VATTR_TEXCOORD); + if (vbo_id != 0) // set this up only if there is an actual buffer. + { + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); + glEnableVertexAttribArray(VATTR_VERTEX); + glEnableVertexAttribArray(VATTR_TEXCOORD); + } + else + { + glDisableVertexAttribArray(VATTR_VERTEX); + glDisableVertexAttribArray(VATTR_TEXCOORD); + } + glDisableVertexAttribArray(VATTR_COLOR); + glDisableVertexAttribArray(VATTR_VERTEX2); } else { - glDisableVertexAttribArray(VATTR_VERTEX); - glDisableVertexAttribArray(VATTR_TEXCOORD); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); } - glDisableVertexAttribArray(VATTR_COLOR); - glDisableVertexAttribArray(VATTR_VERTEX2); } //========================================================================== diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index abf3efcd5..4db7a5f66 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -134,10 +134,19 @@ void FModelVertexBuffer::BindVBO() { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glEnableVertexAttribArray(VATTR_VERTEX); - glEnableVertexAttribArray(VATTR_TEXCOORD); - glEnableVertexAttribArray(VATTR_VERTEX2); - glDisableVertexAttribArray(VATTR_COLOR); + if (gl.glslversion > 0) + { + glEnableVertexAttribArray(VATTR_VERTEX); + glEnableVertexAttribArray(VATTR_TEXCOORD); + glEnableVertexAttribArray(VATTR_VERTEX2); + glDisableVertexAttribArray(VATTR_COLOR); + } + else + { + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + } } //=========================================================================== @@ -222,9 +231,18 @@ void FModelVertexBuffer::UnlockIndexBuffer() unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int frame2) { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].x); - glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].u); - glVertexAttribPointer(VATTR_VERTEX2, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame2].x); + if (gl.glslversion > 0) + { + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].x); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].u); + glVertexAttribPointer(VATTR_VERTEX2, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame2].x); + } + else + { + // only used for single frame models so there is no vertex2 here, which has no use without a shader. + glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].u); + } return frame1; } diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 1398191e1..77d3213c8 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -316,9 +316,12 @@ void FRenderState::ApplyMatrices() void FRenderState::ApplyLightIndex(int index) { - if (index > -1 && GLRenderer->mLights->GetBufferType() == GL_UNIFORM_BUFFER) + if (gl.lightmethod != LM_SOFTWARE) { - index = GLRenderer->mLights->BindUBO(index); + if (index > -1 && GLRenderer->mLights->GetBufferType() == GL_UNIFORM_BUFFER) + { + index = GLRenderer->mLights->BindUBO(index); + } + activeShader->muLightIndex.Set(index); } - activeShader->muLightIndex.Set(index); } \ No newline at end of file diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index ae78b0291..b870b56ff 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -87,13 +87,25 @@ FSkyVertexBuffer::~FSkyVertexBuffer() void FSkyVertexBuffer::BindVBO() { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->x); - glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->u); - glVertexAttribPointer(VATTR_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(FSkyVertex), &VSO->color); - glEnableVertexAttribArray(VATTR_VERTEX); - glEnableVertexAttribArray(VATTR_TEXCOORD); - glEnableVertexAttribArray(VATTR_COLOR); - glDisableVertexAttribArray(VATTR_VERTEX2); + if (gl.glslversion > 0) + { + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->x); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->u); + glVertexAttribPointer(VATTR_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(FSkyVertex), &VSO->color); + glEnableVertexAttribArray(VATTR_VERTEX); + glEnableVertexAttribArray(VATTR_TEXCOORD); + glEnableVertexAttribArray(VATTR_COLOR); + glDisableVertexAttribArray(VATTR_VERTEX2); + } + else + { + glVertexPointer(3, GL_FLOAT, sizeof(FSkyVertex), &VSO->x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FSkyVertex), &VSO->u); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(FSkyVertex), &VSO->color); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + } } //----------------------------------------------------------------------------- diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 12e879a23..e23ae6bec 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -162,6 +162,7 @@ void gl_LoadExtensions() { gl.version = 2.11f; gl.glslversion = 0; + gl.lightmethod = LM_SOFTWARE; } else if (gl.version < 3.0f) { From 7e6e2bc0a84c47a9795b08a5326b682128ade21b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 18:24:02 +0200 Subject: [PATCH 0518/1509] - stated adding GL 2.0 compatibility handling --- src/CMakeLists.txt | 1 + src/gl/compatibility/gl_20.cpp | 310 +++++++++++++++++++++++++++++ src/gl/renderer/gl_renderstate.cpp | 2 +- src/gl/renderer/gl_renderstate.h | 8 +- src/gl/system/gl_interface.cpp | 11 + 5 files changed, 329 insertions(+), 3 deletions(-) create mode 100644 src/gl/compatibility/gl_20.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dd85479c6..fc79bc3e7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1027,6 +1027,7 @@ set( FASTMATH_SOURCES sound/sndfile_decoder.cpp sound/music_pseudo_mididevice.cpp wildmidi/wildmidi_lib.cpp + gl/compatibility/gl_20.cpp gl/data/gl_data.cpp gl/data/gl_portaldata.cpp gl/data/gl_setup.cpp diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp new file mode 100644 index 000000000..94917b871 --- /dev/null +++ b/src/gl/compatibility/gl_20.cpp @@ -0,0 +1,310 @@ +/* +** gl_20.cpp +** +** Fallback code for ancient hardware +** This file collects everything larger that is only needed for +** OpenGL 2.0/no shader compatibility. +** +**--------------------------------------------------------------------------- +** Copyright 2005-2016 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ +#include "gl/system/gl_system.h" +#include "tarray.h" +#include "doomtype.h" +#include "m_argv.h" +#include "zstring.h" +#include "version.h" +#include "i_system.h" +#include "v_text.h" +#include "r_utility.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderstate.h" + + +void gl_SetTextureMode(int type) +{ + static float white[] = {1.f,1.f,1.f,1.f}; + + if (type == TM_MASK) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); + } + else if (type == TM_OPAQUE) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + } + else if (type == TM_INVERSE) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); + } + else if (type == TM_INVERTOPAQUE) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + } + else // if (type == TM_MODULATE) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } +} + +//=========================================================================== +// +// FGLTex::WarpBuffer +// +//=========================================================================== + +BYTE *gl_WarpBuffer(BYTE *buffer, int Width, int Height, int warp, float Speed) +{ + if (Width > 256 || Height > 256) return buffer; + + DWORD *in = (DWORD*)buffer; + DWORD *out = (DWORD*)new BYTE[4 * Width*Height]; + + static DWORD linebuffer[256]; // anything larger will bring down performance so it is excluded above. + DWORD timebase = DWORD(r_FrameTime*Speed * 23 / 28); + int xsize = Width; + int ysize = Height; + int xmask = xsize - 1; + int ymask = ysize - 1; + int ds_xbits; + int i, x; + + if (warp == 1) + { + for (ds_xbits = -1, i = Width; i; i >>= 1, ds_xbits++); + + for (x = xsize - 1; x >= 0; x--) + { + int yt, yf = (finesine[(timebase + (x + 17) * 128)&FINEMASK] >> 13) & ymask; + const DWORD *source = in + x; + DWORD *dest = out + x; + for (yt = ysize; yt; yt--, yf = (yf + 1)&ymask, dest += xsize) + { + *dest = *(source + (yf << ds_xbits)); + } + } + timebase = DWORD(r_FrameTime*Speed * 32 / 28); + int y; + for (y = ysize - 1; y >= 0; y--) + { + int xt, xf = (finesine[(timebase + y * 128)&FINEMASK] >> 13) & xmask; + DWORD *source = out + (y << ds_xbits); + DWORD *dest = linebuffer; + for (xt = xsize; xt; xt--, xf = (xf + 1)&xmask) + { + *dest++ = *(source + xf); + } + memcpy(out + y*xsize, linebuffer, xsize * sizeof(DWORD)); + } + } + else + { + int ybits; + for (ybits = -1, i = ysize; i; i >>= 1, ybits++); + + DWORD timebase = (r_FrameTime * Speed * 40 / 28); + for (x = xsize - 1; x >= 0; x--) + { + for (int y = ysize - 1; y >= 0; y--) + { + int xt = (x + 128 + + ((finesine[(y * 128 + timebase * 5 + 900) & 8191] * 2) >> FRACBITS) + + ((finesine[(x * 256 + timebase * 4 + 300) & 8191] * 2) >> FRACBITS)) & xmask; + int yt = (y + 128 + + ((finesine[(y * 128 + timebase * 3 + 700) & 8191] * 2) >> FRACBITS) + + ((finesine[(x * 256 + timebase * 4 + 1200) & 8191] * 2) >> FRACBITS)) & ymask; + const DWORD *source = in + (xt << ybits) + yt; + DWORD *dest = out + (x << ybits) + y; + *dest = *source; + } + } + } + delete[] buffer; + return (BYTE*)out; +} + + +static int ffTextureMode; +static bool ffTextureEnabled; +static bool ffFogEnabled; +static PalEntry ffFogColor; +static int ffSpecialEffect; +static float ffFogDensity; + +void FRenderState::ApplyFixedFunction() +{ + if (mTextureMode != ffTextureMode) + { + ffTextureMode = mTextureMode; + if (ffTextureMode == TM_CLAMPY) ffTextureMode = TM_MODULATE; // this cannot be replicated. Too bad if it creates visual artifacts + gl_SetTextureMode(ffTextureMode); + } + if (mTextureEnabled != ffTextureEnabled) + { + if ((ffTextureEnabled = mTextureEnabled)) glEnable(GL_TEXTURE_2D); + else glDisable(GL_TEXTURE_2D); + } + if (mFogEnabled != ffFogEnabled) + { + if ((ffFogEnabled = mFogEnabled)) + { + glEnable(GL_FOG); + } + else glDisable(GL_FOG); + } + if (mFogEnabled) + { + if (ffFogColor != mFogColor) + { + ffFogColor = mFogColor; + GLfloat FogColor[4] = { mFogColor.r / 255.0f,mFogColor.g / 255.0f,mFogColor.b / 255.0f,0.0f }; + glFogfv(GL_FOG_COLOR, FogColor); + } + if (ffFogDensity != mLightParms[2]) + { + glFogf(GL_FOG_DENSITY, mLightParms[2] * -0.6931471f); // = 1/log(2) + ffFogDensity = mLightParms[2]; + } + } + if (mSpecialEffect != ffSpecialEffect) + { + switch (ffSpecialEffect) + { + case EFF_SPHEREMAP: + glDisable(GL_TEXTURE_GEN_T); + glDisable(GL_TEXTURE_GEN_S); + + default: + break; + } + switch (mSpecialEffect) + { + case EFF_SPHEREMAP: + // Use sphere mapping for this + glEnable(GL_TEXTURE_GEN_T); + glEnable(GL_TEXTURE_GEN_S); + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + break; + + default: + break; + } + ffSpecialEffect = mSpecialEffect; + } + + FStateVec4 col = mColor; + + if (mColormapState == CM_LITE) + { + if (gl_enhanced_nightvision) + { + col.vec[0] = 0.375f, col.vec[1] = 1.0f, col.vec[2] = 0.375f; + } + else + { + col.vec[0] = col.vec[1] = col.vec[2] = 1.f; + } + } + else if (mColormapState >= CM_TORCH) + { + int flicker = mColormapState - CM_TORCH; + col.vec[0] = (0.8f + (7 - flicker) / 70.0f); + if (col.vec[0] > 1.0f) col.vec[0] = 1.0f; + col.vec[1] = col.vec[2] = col.vec[0]; + if (gl_enhanced_nightvision) col.vec[0] = col.vec[0] * 0.75f; + } + col.vec[0] += mDynColor.vec[0]; + col.vec[1] += mDynColor.vec[1]; + col.vec[2] += mDynColor.vec[2]; + col.vec[0] = clamp(col.vec[0], 0.f, 1.f); + + col.vec[0] = clamp(col.vec[0], 0.f, 1.f); + col.vec[1] = clamp(col.vec[1], 0.f, 1.f); + col.vec[2] = clamp(col.vec[2], 0.f, 1.f); + col.vec[3] = clamp(col.vec[3], 0.f, 1.f); + + col.vec[0] *= (mObjectColor.r / 255.f); + col.vec[1] *= (mObjectColor.g / 255.f); + col.vec[2] *= (mObjectColor.b / 255.f); + col.vec[3] *= (mObjectColor.a / 255.f); + glColor4fv(col.vec); + + if (mAlphaThreshold > 0) + { + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, mAlphaThreshold); + } + else + { + glDisable(GL_ALPHA_TEST); + } + +} diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 77d3213c8..d1e30c560 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -285,7 +285,7 @@ void FRenderState::Apply() } else { - //ApplyFixedFunction(); + ApplyFixedFunction(); } } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 7436135a6..f5df3b78c 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -59,7 +59,6 @@ class FRenderState int mSrcBlend, mDstBlend; float mAlphaThreshold; int mBlendEquation; - bool mAlphaTest; bool m2D; bool mModelMatrixEnabled; bool mTextureMatrixEnabled; @@ -110,9 +109,10 @@ public: // textures without their own palette are a special case for use as an alpha texture: // They use the color index directly as an alpha value instead of using the palette's red. // To handle this case, we need to set a special translation for such textures. + // Without shaders this translation must be applied to any texture. if (alphatexture) { - if (mat->tex->UseBasePalette()) translation = TRANSLATION(TRANSLATION_Standard, 8); + if (mat->tex->UseBasePalette() || gl.glslversion == 0) translation = TRANSLATION(TRANSLATION_Standard, 8); } mEffectState = overrideshader >= 0? overrideshader : mat->mShaderIndex; mShaderTimer = mat->tex->gl_info.shaderspeed; @@ -394,6 +394,10 @@ public: { mInterpolationFactor = fac; } + + // Backwards compatibility crap follows + void ApplyFixedFunction(); + }; extern FRenderState gl_RenderState; diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index e23ae6bec..ffef95b8a 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -43,6 +43,7 @@ #include "version.h" #include "i_system.h" #include "v_text.h" +#include "r_data/r_translate.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" @@ -279,6 +280,16 @@ void gl_PrintStartupLog() glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &v); Printf("Max. vertex shader storage blocks: %d\n", v); + // For shader-less, the special alphatexture translation must be changed to actually set the alpha, because it won't get translated by a shader. + if (gl.glslversion == 0) + { + FRemapTable *remap = translationtables[TRANSLATION_Standard][8]; + for (int i = 0; i < 256; i++) + { + remap->Remap[i] = i; + remap->Palette[i] = PalEntry(i, 255, 255); + } + } } From 913e3df7e3e0e957f3407585499fb4fc5c058315 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 19:11:32 +0200 Subject: [PATCH 0519/1509] - fixed display of alpha textures without shaders. As it turned out, the translation's alpha channel was clobbered by the whole setup. --- src/gl/compatibility/gl_20.cpp | 1 + src/gl/system/gl_interface.cpp | 2 +- src/gl/textures/gl_bitmap.cpp | 6 +++++- src/gl/textures/gl_bitmap.h | 9 ++++----- src/gl/textures/gl_material.cpp | 15 ++++++++++----- src/gl/textures/gl_material.h | 2 +- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 94917b871..e27a6fd43 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -297,6 +297,7 @@ void FRenderState::ApplyFixedFunction() col.vec[3] *= (mObjectColor.a / 255.f); glColor4fv(col.vec); + glEnable(GL_BLEND); if (mAlphaThreshold > 0) { glEnable(GL_ALPHA_TEST); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index ffef95b8a..c09038bf8 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -287,7 +287,7 @@ void gl_PrintStartupLog() for (int i = 0; i < 256; i++) { remap->Remap[i] = i; - remap->Palette[i] = PalEntry(i, 255, 255); + remap->Palette[i] = PalEntry(i, 255, 255, 255); } } diff --git a/src/gl/textures/gl_bitmap.cpp b/src/gl/textures/gl_bitmap.cpp index ee28e8911..0db901380 100644 --- a/src/gl/textures/gl_bitmap.cpp +++ b/src/gl/textures/gl_bitmap.cpp @@ -124,13 +124,17 @@ void FGLBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int if (translation > 0) { PalEntry *ptrans = GLTranslationPalette::GetPalette(translation); - if (ptrans) + if (ptrans && !alphatrans) { for (i = 0; i < 256; i++) { penew[i] = (ptrans[i] & 0xffffff) | (palette[i] & 0xff000000); } } + else if (ptrans) + { + memcpy(penew, ptrans, 256 * sizeof(PalEntry)); + } } else { diff --git a/src/gl/textures/gl_bitmap.h b/src/gl/textures/gl_bitmap.h index e8b06b833..3c045e5ad 100644 --- a/src/gl/textures/gl_bitmap.h +++ b/src/gl/textures/gl_bitmap.h @@ -7,23 +7,22 @@ class FGLBitmap : public FBitmap { - int translation; + int translation = 0; + bool alphatrans = false; public: FGLBitmap() { - translation = 0; } FGLBitmap(BYTE *buffer, int pitch, int width, int height) : FBitmap(buffer, pitch, width, height) { - translation = 0; } - void SetTranslationInfo(int _trans) + void SetTranslationInfo(int _trans, bool _alphatrans = false) { if (_trans != -1337) translation = _trans; - + alphatrans = _alphatrans; } virtual void CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int srcwidth, diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 961a61c04..55ed91e4e 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -182,7 +182,7 @@ void FGLTexture::Clean(bool all) // //=========================================================================== -unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded) +unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded, bool alphatrans) { unsigned char * buffer; int W, H; @@ -190,7 +190,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F // Textures that are already scaled in the texture lump will not get replaced // by hires textures - if (gl_texture_usehires && hirescheck != NULL) + if (gl_texture_usehires && hirescheck != NULL && !alphatrans) { buffer = LoadHiresTexture (hirescheck, &w, &h); if (buffer) @@ -209,7 +209,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F memset(buffer, 0, W * (H+1) * 4); FGLBitmap bmp(buffer, W*4, W, H); - bmp.SetTranslationInfo(translation); + bmp.SetTranslationInfo(translation, alphatrans); if (tex->bComplex) { @@ -275,9 +275,14 @@ FHardwareTexture *FGLTexture::CreateHwTexture() const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int translation, FTexture *hirescheck) { int usebright = false; + bool alphatrans = false; if (translation <= 0) translation = -translation; - else translation = GLTranslationPalette::GetInternalTranslation(translation); + else + { + alphatrans = (gl.glslversion == 0 && translation == TRANSLATION(TRANSLATION_Standard, 8)); + translation = GLTranslationPalette::GetInternalTranslation(translation); + } bool needmipmap = (clampmode <= CLAMP_XY) || !(gl.flags & RFL_SAMPLER_OBJECTS); @@ -303,7 +308,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla if (!tex->bHasCanvas) { - buffer = CreateTexBuffer(translation, w, h, hirescheck); + buffer = CreateTexBuffer(translation, w, h, hirescheck, true, alphatrans); tex->ProcessData(buffer, w, h, false); } if (!hwtex->CreateTexture(buffer, w, h, texunit, needmipmap, translation)) diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 9cd2d3387..79e5f52e2 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -77,7 +77,7 @@ public: FGLTexture(FTexture * tx, bool expandpatches); ~FGLTexture(); - unsigned char * CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded = true); + unsigned char * CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded = true, bool alphatrans = false); void Clean(bool all); int Dump(int i); From 924b72b633848fd821b3008979ada7ed77581955 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 20:02:57 +0200 Subject: [PATCH 0520/1509] - added workarounds for the invulnerability colormap for non-shader rendering. Unlike the shader based versions these do not decolorize the screen. The advantage to the old texture duplication is that this is far less stressful on performance. --- src/gl/compatibility/gl_20.cpp | 74 ++++++++++++++++++++++++-------- src/gl/renderer/gl_renderstate.h | 7 ++- src/gl/scene/gl_scene.cpp | 13 ++++-- 3 files changed, 71 insertions(+), 23 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index e27a6fd43..fc171686b 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -262,25 +262,6 @@ void FRenderState::ApplyFixedFunction() FStateVec4 col = mColor; - if (mColormapState == CM_LITE) - { - if (gl_enhanced_nightvision) - { - col.vec[0] = 0.375f, col.vec[1] = 1.0f, col.vec[2] = 0.375f; - } - else - { - col.vec[0] = col.vec[1] = col.vec[2] = 1.f; - } - } - else if (mColormapState >= CM_TORCH) - { - int flicker = mColormapState - CM_TORCH; - col.vec[0] = (0.8f + (7 - flicker) / 70.0f); - if (col.vec[0] > 1.0f) col.vec[0] = 1.0f; - col.vec[1] = col.vec[2] = col.vec[0]; - if (gl_enhanced_nightvision) col.vec[0] = col.vec[0] * 0.75f; - } col.vec[0] += mDynColor.vec[0]; col.vec[1] += mDynColor.vec[1]; col.vec[2] += mDynColor.vec[2]; @@ -309,3 +290,58 @@ void FRenderState::ApplyFixedFunction() } } + +void gl_FillScreen(); + +void FRenderState::DrawColormapOverlay() +{ + float r, g, b; + if (mColormapState > CM_DEFAULT && mColormapState < CM_MAXCOLORMAP) + { + FSpecialColormap *scm = &SpecialColormaps[gl_fixedcolormap - CM_FIRSTSPECIALCOLORMAP]; + float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0], + scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f }; + + if (m[0] < 0 && m[1] < 0 && m[2] < 0) + { + gl_RenderState.SetColor(1, 1, 1, 1); + gl_RenderState.BlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); + gl_FillScreen(); + + r = scm->ColorizeStart[0]; + g = scm->ColorizeStart[1]; + b = scm->ColorizeStart[2]; + } + else + { + r = scm->ColorizeEnd[0]; + g = scm->ColorizeEnd[1]; + b = scm->ColorizeEnd[2]; + } + } + else if (mColormapState == CM_LITE) + { + if (gl_enhanced_nightvision) + { + r = 0.375f, g = 1.0f, b = 0.375f; + } + else + { + return; + } + } + else if (mColormapState >= CM_TORCH) + { + int flicker = mColormapState - CM_TORCH; + r = (0.8f + (7 - flicker) / 70.0f); + if (r > 1.0f) r = 1.0f; + b = g = r; + if (gl_enhanced_nightvision) b = g * 0.75f; + } + else return; + + gl_RenderState.SetColor(r, g, b, 1.f); + gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); + gl_FillScreen(); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} \ No newline at end of file diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index f5df3b78c..04142a582 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -317,6 +317,11 @@ public: mColormapState = cm; } + int GetFixedColormap() + { + return mColormapState; + } + PalEntry GetFogColor() const { return mFogColor; @@ -397,7 +402,7 @@ public: // Backwards compatibility crap follows void ApplyFixedFunction(); - + void DrawColormapOverlay(); }; extern FRenderState gl_RenderState; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 7062f0cb6..8a7a882bc 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -524,7 +524,7 @@ void FGLRenderer::DrawScene(bool toscreen) } -static void FillScreen() +void gl_FillScreen() { gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.EnableTexture(false); @@ -629,7 +629,7 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) { gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); gl_RenderState.SetColor(extra_red, extra_green, extra_blue, 1.0f); - FillScreen(); + gl_FillScreen(); } } else if (blendv.a) @@ -659,7 +659,7 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) { gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.SetColor(blend[0], blend[1], blend[2], blend[3]); - FillScreen(); + gl_FillScreen(); } } @@ -696,10 +696,17 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) { DrawPlayerSprites (viewsector, false); } + int cm = gl_RenderState.GetFixedColormap(); gl_RenderState.SetFixedColormap(CM_DEFAULT); gl_RenderState.SetSoftLightLevel(-1); DrawTargeterSprites(); DrawBlend(viewsector); + if (gl.glslversion == 0.0) + { + gl_RenderState.SetFixedColormap(cm); + gl_RenderState.DrawColormapOverlay(); + gl_RenderState.SetFixedColormap(CM_DEFAULT); + } // Restore standard rendering state gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); From 9d71c91f01d5000a13a136fb453256dca0f97233 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 20:20:00 +0200 Subject: [PATCH 0521/1509] - reenabled software warping for shader-less rendering. --- src/gl/textures/gl_material.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 55ed91e4e..f3743bd3a 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -72,6 +72,7 @@ EXTERN_CVAR(Bool, gl_texture_usehires) // The GL texture maintenance class // //=========================================================================== +BYTE *gl_WarpBuffer(BYTE *buffer, int Width, int Height, int warp, float Speed); //=========================================================================== // @@ -291,7 +292,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla if (hwtex) { // Texture has become invalid - if ((!tex->bHasCanvas && !tex->bWarped) && tex->CheckModified()) + if ((!tex->bHasCanvas && (!tex->bWarped || gl.glslversion == 0)) && tex->CheckModified()) { Clean(true); hwtex = CreateHwTexture(); @@ -309,6 +310,12 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla if (!tex->bHasCanvas) { buffer = CreateTexBuffer(translation, w, h, hirescheck, true, alphatrans); + if (tex->bWarped && gl.glslversion == 0) + { + // need to warp + buffer = gl_WarpBuffer(buffer, w, h, tex->bWarped, static_cast(tex)->GetSpeed()); + static_cast(tex)->GenTime = r_FrameTime; + } tex->ProcessData(buffer, w, h, false); } if (!hwtex->CreateTexture(buffer, w, h, texunit, needmipmap, translation)) @@ -462,7 +469,7 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) mSpriteU[0] = mSpriteV[0] = 0.f; mSpriteU[1] = mSpriteV[1] = 1.f; - FTexture *basetex = tx->GetRedirect(false); + FTexture *basetex = (tx->bWarped && gl.glslversion == 0)? tx : tx->GetRedirect(false); // allow the redirect only if the textute is not expanded or the scale matches. if (!expanded || (tx->Scale.X == basetex->Scale.X && tx->Scale.Y == basetex->Scale.Y)) { From 89f36fb963bfbd51b370da773515a66727e080a5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 20:45:56 +0200 Subject: [PATCH 0522/1509] - enabled texture and model matrices for shader-less rendering and fixed the sky cap color application. --- src/gl/compatibility/gl_20.cpp | 33 ++++++++++++++++++++++++++++++++- src/gl/scene/gl_skydome.cpp | 9 +++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index fc171686b..5498c0b0a 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -197,6 +197,8 @@ static bool ffFogEnabled; static PalEntry ffFogColor; static int ffSpecialEffect; static float ffFogDensity; +static bool currentTextureMatrixState; +static bool currentModelMatrixState; void FRenderState::ApplyFixedFunction() { @@ -282,13 +284,42 @@ void FRenderState::ApplyFixedFunction() if (mAlphaThreshold > 0) { glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, mAlphaThreshold); + glAlphaFunc(GL_GREATER, mAlphaThreshold * col.vec[3]); } else { glDisable(GL_ALPHA_TEST); } + if (mTextureMatrixEnabled) + { + glMatrixMode(GL_TEXTURE); + glLoadMatrixf(mTextureMatrix.get()); + currentTextureMatrixState = true; + } + else if (currentTextureMatrixState) + { + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + currentTextureMatrixState = false; + } + + if (mModelMatrixEnabled) + { + VSMatrix mult = mViewMatrix; + mult.multMatrix(mModelMatrix); + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(mult.get()); + currentModelMatrixState = true; + } + else if (currentModelMatrixState) + { + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(mViewMatrix.get()); + currentModelMatrixState = false; + } + + } void gl_FillScreen(); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index b870b56ff..33c73d82c 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -104,7 +104,7 @@ void FSkyVertexBuffer::BindVBO() glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(FSkyVertex), &VSO->color); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); } } @@ -254,6 +254,11 @@ void FSkyVertexBuffer::RenderDome(FMaterial *tex, int mode) gl_RenderState.Apply(); RenderRow(GL_TRIANGLE_FAN, rc); gl_RenderState.EnableTexture(true); + // The color array can only be activated now if this is drawn without shader + if (gl.glslversion == 0) + { + glEnableClientState(GL_COLOR_ARRAY); + } } gl_RenderState.SetObjectColor(0xffffffff); gl_RenderState.Apply(); @@ -523,7 +528,7 @@ void GLSkyPortal::DrawContents() gl_RenderState.SetTextureMode(TM_MODULATE); } - gl_RenderState.AlphaFunc(GL_GEQUAL, 0.05f); + gl_RenderState.AlphaFunc(GL_GREATER, 0.f); if (origin->doublesky && origin->texture[1]) { From 6e1b21d51378ec8372d190a0291b849db134a2e5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 21:31:24 +0200 Subject: [PATCH 0523/1509] - added back sprite splitting for low end, plus some dynamic light code. --- src/gl/dynlights/gl_dynlight1.cpp | 91 +++++ src/gl/renderer/gl_renderer.h | 1 + src/gl/scene/gl_sprite.cpp | 63 +++- src/gl/scene/gl_wall.h | 1 + src/posix/cocoa/i_video.mm | 584 +++++++++++++++++++++++++++++- src/v_video.h | 2 + src/win32/win32gliface.cpp | 4 +- 7 files changed, 737 insertions(+), 9 deletions(-) diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index debb10cea..b8fbfc24a 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -141,3 +141,94 @@ bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, bo } + + +//========================================================================== +// +// Sets up the parameters to render one dynamic light onto one plane +// +//========================================================================== +bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, + float & scale, int desaturation, bool checkside, bool forceadditive) +{ + Vector fn, pos; + + DVector3 lpos = light->PosRelative(group); + + float dist = fabsf(p.DistToPoint(lpos.X, lpos.Z, lpos.Y)); + float radius = (light->GetRadius() * gl_lights_size); + + if (radius <= 0.f) return false; + if (dist > radius) return false; + if (checkside && gl_lights_checkside && p.PointOnSide(lpos.X, lpos.Z, lpos.Y)) + { + return false; + } + if (light->owned && light->target != NULL && !light->target->IsVisibleToPlayer()) + { + return false; + } + + scale = 1.0f / ((2.f * radius) - dist); + + // project light position onto plane (find closest point on plane) + + + pos.Set(lpos.X, lpos.Z, lpos.Y); + fn = p.Normal(); + fn.GetRightUp(right, up); + +#ifdef _MSC_VER + nearPt = pos + fn * dist; +#else + Vector tmpVec = fn * dist; + nearPt = pos + tmpVec; +#endif + + float cs = 1.0f - (dist / radius); + if (gl_lights_additive || light->flags4&MF4_ADDITIVE || forceadditive) cs *= 0.2f; // otherwise the light gets too strong. + float r = light->GetRed() / 255.0f * cs * gl_lights_intensity; + float g = light->GetGreen() / 255.0f * cs * gl_lights_intensity; + float b = light->GetBlue() / 255.0f * cs * gl_lights_intensity; + + if (light->IsSubtractive()) + { + Vector v; + + gl_RenderState.BlendEquation(GL_FUNC_REVERSE_SUBTRACT); + v.Set(r, g, b); + r = v.Length() - r; + g = v.Length() - g; + b = v.Length() - b; + } + else + { + gl_RenderState.BlendEquation(GL_FUNC_ADD); + } + if (desaturation > 0 && gl.glslversion > 0) // no-shader excluded because no desaturated textures. + { + float gray = (r * 77 + g * 143 + b * 37) / 257; + + r = (r*(32 - desaturation) + gray*desaturation) / 32; + g = (g*(32 - desaturation) + gray*desaturation) / 32; + b = (b*(32 - desaturation) + gray*desaturation) / 32; + } + glColor3f(r, g, b); + return true; +} + + +//========================================================================== +// +// +// +//========================================================================== + +bool gl_SetupLightTexture() +{ + + if (GLRenderer->gllight == NULL) return false; + FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight, true); + pat->Bind(CLAMP_XY, 0); + return true; +} diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index f266bcd37..cc5aa9d53 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -71,6 +71,7 @@ public: unsigned int mFBID; unsigned int mVAOID; + FTexture *gllight; FTexture *glpart2; FTexture *glpart; FTexture *mirrortexture; diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 5bbf26d92..40aae9165 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -372,6 +372,54 @@ inline void GLSprite::PutSprite(bool translucent) gl_drawinfo->drawlists[list].AddSprite(this); } +//========================================================================== +// +// +// +//========================================================================== +void GLSprite::SplitSprite(sector_t * frontsector, bool translucent) +{ + GLSprite copySprite; + double lightbottom; + unsigned int i; + bool put=false; + TArray & lightlist=frontsector->e->XFloor.lightlist; + + for(i=0;ifloorplane.ZatPoint(actor); + + if (lightbottom>8; + copySprite.Colormap.LightColor.g=(copySprite.Colormap.LightColor.g*ThingColor.g)>>8; + copySprite.Colormap.LightColor.b=(copySprite.Colormap.LightColor.b*ThingColor.b)>>8; + } + + z1=copySprite.z2=lightbottom; + vt=copySprite.vb=copySprite.vt+ + (lightbottom-copySprite.z1)*(copySprite.vb-copySprite.vt)/(z2-copySprite.z1); + copySprite.PutSprite(translucent); + put=true; + } + } +} + //========================================================================== // // @@ -722,7 +770,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, bool thruportal) RenderStyle.CheckFuzz(); if (RenderStyle.BlendOp == STYLEOP_Fuzz) { - if (gl_fuzztype != 0) + if (gl_fuzztype != 0 && gl.glslversion > 0) { // Todo: implement shader selection here RenderStyle = LegacyRenderStyles[STYLE_Translucent]; @@ -819,7 +867,18 @@ void GLSprite::Process(AActor* thing, sector_t * sector, bool thruportal) if (thing->Sector->e->XFloor.lightlist.Size() != 0 && gl_fixedcolormap == CM_DEFAULT && !fullbright && RenderStyle.BlendOp != STYLEOP_Shadow && RenderStyle.BlendOp != STYLEOP_RevSub) { - lightlist = &thing->Sector->e->XFloor.lightlist; + if (gl.glslversion < 1.3) // on old hardware we are rather limited... + { + lightlist = NULL; + if (!drawWithXYBillboard && !modelframe) + { + SplitSprite(thing->Sector, hw_styleflags != STYLEHW_Solid); + } + } + else + { + lightlist = &thing->Sector->e->XFloor.lightlist; + } } else { diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 3bc3b8a58..e2334f7de 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -350,6 +350,7 @@ public: particle_t * particle; TArray *lightlist; + void SplitSprite(sector_t * frontsector, bool translucent); void SetLowerParam(); void PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight); diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 89b3714d1..702b9a61b 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -31,10 +31,11 @@ ** */ +#include "gl/system/gl_load.h" + #include "i_common.h" #import -#import // Avoid collision between DObject class and Objective-C #define Class ObjectClass @@ -45,6 +46,7 @@ #include "hardware.h" #include "i_system.h" #include "m_argv.h" +#include "m_png.h" #include "r_renderer.h" #include "r_swrenderer.h" #include "st_console.h" @@ -56,6 +58,11 @@ #include "v_video.h" #include "version.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_interface.h" +#include "gl/utility/gl_clock.h" + #undef Class @@ -111,6 +118,41 @@ CUSTOM_CVAR(Bool, vid_autoswitch, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ Printf("You must restart " GAMENAME " to apply graphics switching mode\n"); } +static int s_currentRenderer; + +CUSTOM_CVAR(Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + // 0: Software renderer + // 1: OpenGL renderer + + if (self != s_currentRenderer) + { + switch (self) + { + case 0: + Printf("Switching to software renderer...\n"); + break; + case 1: + Printf("Switching to OpenGL renderer...\n"); + break; + default: + Printf("Unknown renderer (%d). Falling back to software renderer...\n", + static_cast(vid_renderer)); + self = 0; + break; + } + + Printf("You must restart " GAMENAME " to switch the renderer\n"); + } +} + +CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + Printf("This won't take effect until " GAMENAME " is restarted.\n"); +} + +EXTERN_CVAR(Bool, gl_smooth_rendered) + RenderBufferOptions rbOpts; @@ -187,7 +229,6 @@ namespace @end - // --------------------------------------------------------------------------- @@ -235,6 +276,9 @@ private: }; +// --------------------------------------------------------------------------- + + class CocoaFrameBuffer : public DFrameBuffer { public: @@ -286,6 +330,83 @@ private: // --------------------------------------------------------------------------- +class NonCopyable +{ +protected: + NonCopyable() { } + ~NonCopyable() { } + +private: + NonCopyable(const NonCopyable&); + const NonCopyable& operator=(const NonCopyable&); +}; + + +// --------------------------------------------------------------------------- + + +class RenderTarget : private NonCopyable +{ +public: + RenderTarget(const GLsizei width, const GLsizei height); + ~RenderTarget(); + + void Bind(); + void Unbind(); + + FHardwareTexture& GetColorTexture() + { + return m_texture; + } + +private: + GLuint m_ID; + GLuint m_oldID; + + FHardwareTexture m_texture; + + static GLuint GetBoundID(); + +}; // class RenderTarget + + +// --------------------------------------------------------------------------- + + +struct CapabilityChecker +{ + CapabilityChecker(); +}; + + +// --------------------------------------------------------------------------- + + +class CocoaOpenGLFrameBuffer : public OpenGLFrameBuffer, private CapabilityChecker, private NonCopyable +{ + typedef OpenGLFrameBuffer Super; + +public: + CocoaOpenGLFrameBuffer(void* hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen); + + virtual bool Lock(bool buffered); + virtual void Update(); + + virtual void GetScreenshotBuffer(const BYTE*& buffer, int& pitch, ESSType& color_type); + + virtual void SetSmoothPicture(bool smooth); + +private: + RenderTarget m_renderTarget; + + void DrawRenderTarget(); + +}; // class CocoaOpenGLFrameBuffer + + +// --------------------------------------------------------------------------- + + EXTERN_CVAR(Float, Gamma) CUSTOM_CVAR(Float, rgamma, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) @@ -542,7 +663,17 @@ DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, c delete old; } - CocoaFrameBuffer* fb = new CocoaFrameBuffer(width, height, fullscreen); + DFrameBuffer* fb = NULL; + + if (1 == s_currentRenderer) + { + fb = new CocoaOpenGLFrameBuffer(NULL, width, height, 32, 60, fullscreen); + } + else + { + fb = new CocoaFrameBuffer(width, height, fullscreen); + } + fb->SetFlash(flashColor, flashAmount); SetMode(width, height, fullscreen, vid_hidpi); @@ -762,6 +893,9 @@ CocoaVideo* CocoaVideo::GetInstance() } +// --------------------------------------------------------------------------- + + CocoaFrameBuffer::CocoaFrameBuffer(int width, int height, bool fullscreen) : DFrameBuffer(width, height) , m_needPaletteUpdate(false) @@ -772,6 +906,14 @@ CocoaFrameBuffer::CocoaFrameBuffer(int width, int height, bool fullscreen) , m_pixelBuffer(new uint8_t[width * height * BYTES_PER_PIXEL]) , m_texture(0) { + static bool isOpenGLInitialized; + + if (!isOpenGLInitialized) + { + ogl_LoadFunctions(); + isOpenGLInitialized = true; + } + glEnable(GL_TEXTURE_RECTANGLE_ARB); glGenTextures(1, &m_texture); @@ -1011,6 +1153,423 @@ void CocoaFrameBuffer::Flip() } +// --------------------------------------------------------------------------- + + +static const uint32_t GAMMA_TABLE_ALPHA = 0xFF000000; + + +SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool fullscreen) +: DFrameBuffer(width, height) +, m_lock(-1) +, m_isUpdatePending(false) +, m_supportsGamma(true) +, m_gammaTexture(GAMMA_TABLE_SIZE, 1, false, false, true, true) +{ +} + +SDLGLFB::SDLGLFB() +: m_gammaTexture(0, 0, false, false, false, false) +{ +} + +SDLGLFB::~SDLGLFB() +{ +} + + +bool SDLGLFB::Lock(bool buffered) +{ + m_lock++; + + Buffer = MemBuffer; + + return true; +} + +void SDLGLFB::Unlock() +{ + if (m_isUpdatePending && 1 == m_lock) + { + Update(); + } + else if (--m_lock <= 0) + { + m_lock = 0; + } +} + +bool SDLGLFB::IsLocked() +{ + return m_lock > 0; +} + + +bool SDLGLFB::IsFullscreen() +{ + return CocoaVideo::IsFullscreen(); +} + +void SDLGLFB::SetVSync(bool vsync) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 + const long value = vsync ? 1 : 0; +#else // 10.5 or newer + const GLint value = vsync ? 1 : 0; +#endif // prior to 10.5 + + [[NSOpenGLContext currentContext] setValues:&value + forParameter:NSOpenGLCPSwapInterval]; +} + + +void SDLGLFB::InitializeState() +{ +} + +bool SDLGLFB::CanUpdate() +{ + if (m_lock != 1) + { + if (m_lock > 0) + { + m_isUpdatePending = true; + --m_lock; + } + + return false; + } + + return true; +} + +void SDLGLFB::SwapBuffers() +{ + [[NSOpenGLContext currentContext] flushBuffer]; +} + +void SDLGLFB::SetGammaTable(WORD* table) +{ + const WORD* const red = &table[ 0]; + const WORD* const green = &table[256]; + const WORD* const blue = &table[512]; + + for (size_t i = 0; i < GAMMA_TABLE_SIZE; ++i) + { + // Convert 16 bits colors to 8 bits by dividing on 256 + + const uint32_t r = red[i] >> 8; + const uint32_t g = green[i] >> 8; + const uint32_t b = blue[i] >> 8; + + m_gammaTable[i] = GAMMA_TABLE_ALPHA + (b << 16) + (g << 8) + r; + } + + m_gammaTexture.CreateTexture( + reinterpret_cast(m_gammaTable), + GAMMA_TABLE_SIZE, 1, false, 1, 0); +} + + +// --------------------------------------------------------------------------- + + +void BoundTextureSetFilter(const GLenum target, const GLint filter) +{ + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, filter); + glTexParameteri(target, GL_TEXTURE_MAG_FILTER, filter); + + glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); +} + +void BoundTextureDraw2D(const GLsizei width, const GLsizei height) +{ + const bool flipX = width < 0; + const bool flipY = height < 0; + + const float u0 = flipX ? 1.0f : 0.0f; + const float v0 = flipY ? 1.0f : 0.0f; + const float u1 = flipX ? 0.0f : 1.0f; + const float v1 = flipY ? 0.0f : 1.0f; + + const float x1 = 0.0f; + const float y1 = 0.0f; + const float x2 = abs(width ); + const float y2 = abs(height); + + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + + glBegin(GL_QUADS); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glTexCoord2f(u0, v1); + glVertex2f(x1, y1); + glTexCoord2f(u1, v1); + glVertex2f(x2, y1); + glTexCoord2f(u1, v0); + glVertex2f(x2, y2); + glTexCoord2f(u0, v0); + glVertex2f(x1, y2); + glEnd(); + + glEnable(GL_ALPHA_TEST); + glEnable(GL_BLEND); +} + +bool BoundTextureSaveAsPNG(const GLenum target, const char* const path) +{ + if (NULL == path) + { + return false; + } + + GLint width = 0; + GLint height = 0; + + glGetTexLevelParameteriv(target, 0, GL_TEXTURE_WIDTH, &width ); + glGetTexLevelParameteriv(target, 0, GL_TEXTURE_HEIGHT, &height); + + if (0 == width || 0 == height) + { + Printf("BoundTextureSaveAsPNG: invalid texture size %ix%i\n", width, height); + + return false; + } + + static const int BYTES_PER_PIXEL = 4; + + const int imageSize = width * height * BYTES_PER_PIXEL; + unsigned char* imageBuffer = static_cast(malloc(imageSize)); + + if (NULL == imageBuffer) + { + Printf("BoundTextureSaveAsPNG: cannot allocate %i bytes\n", imageSize); + + return false; + } + + glGetTexImage(target, 0, GL_BGRA, GL_UNSIGNED_BYTE, imageBuffer); + + const int lineSize = width * BYTES_PER_PIXEL; + unsigned char lineBuffer[lineSize]; + + for (GLint line = 0; line < height / 2; ++line) + { + void* frontLinePtr = &imageBuffer[line * lineSize]; + void* backLinePtr = &imageBuffer[(height - line - 1) * lineSize]; + + memcpy( lineBuffer, frontLinePtr, lineSize); + memcpy(frontLinePtr, backLinePtr, lineSize); + memcpy( backLinePtr, lineBuffer, lineSize); + } + + FILE* file = fopen(path, "w"); + + if (NULL == file) + { + Printf("BoundTextureSaveAsPNG: cannot open file %s\n", path); + + free(imageBuffer); + + return false; + } + + const bool result = + M_CreatePNG(file, &imageBuffer[0], NULL, SS_BGRA, width, height, width * BYTES_PER_PIXEL) + && M_FinishPNG(file); + + fclose(file); + + free(imageBuffer); + + return result; +} + + +// --------------------------------------------------------------------------- + + +RenderTarget::RenderTarget(const GLsizei width, const GLsizei height) +: m_ID(0) +, m_oldID(0) +, m_texture(width, height, false, false, true, true) +{ + glGenFramebuffersEXT(1, &m_ID); + + Bind(); + m_texture.CreateTexture(NULL, width, height, false, 0, 0); + m_texture.BindToFrameBuffer(); + Unbind(); +} + +RenderTarget::~RenderTarget() +{ + glDeleteFramebuffersEXT(1, &m_ID); +} + + +void RenderTarget::Bind() +{ + const GLuint boundID = GetBoundID(); + + if (m_ID != boundID) + { + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_ID); + m_oldID = boundID; + } +} + +void RenderTarget::Unbind() +{ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_oldID); + m_oldID = 0; +} + + +GLuint RenderTarget::GetBoundID() +{ + GLint result; + glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &result); + + return static_cast(result); +} + + +// --------------------------------------------------------------------------- + + +CapabilityChecker::CapabilityChecker() +{ + if (!(gl.flags & RFL_FRAMEBUFFER)) + { + I_FatalError( + "The graphics hardware in your system does not support Frame Buffer Object (FBO).\n" + "It is required to run this version of " GAMENAME ".\n"); + } +} + + +// --------------------------------------------------------------------------- + + +CocoaOpenGLFrameBuffer::CocoaOpenGLFrameBuffer(void* hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) +: OpenGLFrameBuffer(hMonitor, width, height, bits, refreshHz, fullscreen) +, m_renderTarget(width, height) +{ + SetSmoothPicture(gl_smooth_rendered); + + // Setup uniform samplers for gamma correction shader + + m_gammaProgram.Load("GammaCorrection", "shaders/glsl/main.vp", + "shaders/glsl/gamma_correction.fp", NULL, ""); + + const GLuint program = m_gammaProgram.GetHandle(); + + glUseProgram(program); + glUniform1i(glGetUniformLocation(program, "backbuffer"), 0); + glUniform1i(glGetUniformLocation(program, "gammaTable"), 1); + glUseProgram(0); + + // Fill render target with black color + + m_renderTarget.Bind(); + glClear(GL_COLOR_BUFFER_BIT); + m_renderTarget.Unbind(); +} + + +bool CocoaOpenGLFrameBuffer::Lock(bool buffered) +{ + if (0 == m_lock) + { + m_renderTarget.Bind(); + } + + return Super::Lock(buffered); +} + +void CocoaOpenGLFrameBuffer::Update() +{ + if (!CanUpdate()) + { + GLRenderer->Flush(); + return; + } + + Begin2D(false); + + DrawRateStuff(); + GLRenderer->Flush(); + + DrawRenderTarget(); + + Swap(); + Unlock(); + + CheckBench(); +} + + +void CocoaOpenGLFrameBuffer::GetScreenshotBuffer(const BYTE*& buffer, int& pitch, ESSType& color_type) +{ + m_renderTarget.Bind(); + + Super::GetScreenshotBuffer(buffer, pitch, color_type); + + m_renderTarget.Unbind(); +} + + +void CocoaOpenGLFrameBuffer::DrawRenderTarget() +{ + m_renderTarget.Unbind(); + + m_renderTarget.GetColorTexture().Bind(0, 0); + m_gammaTexture.Bind(1, 0); + + if (rbOpts.dirty) + { + // TODO: Figure out why the following glClear() call is needed + // to avoid drawing of garbage in fullscreen mode when + // in-game's aspect ratio is different from display one + glClear(GL_COLOR_BUFFER_BIT); + + rbOpts.dirty = false; + } + + glViewport(rbOpts.shiftX, rbOpts.shiftY, rbOpts.width, rbOpts.height); + + m_gammaProgram.Bind(0.0f); + BoundTextureDraw2D(Width, Height); + + glViewport(0, 0, Width, Height); +} + + +void CocoaOpenGLFrameBuffer::SetSmoothPicture(const bool smooth) +{ + FHardwareTexture& texture = m_renderTarget.GetColorTexture(); + texture.Bind(0, 0); + BoundTextureSetFilter(GL_TEXTURE_2D, smooth ? GL_LINEAR : GL_NEAREST); +} + + +// --------------------------------------------------------------------------- + + +CUSTOM_CVAR(Bool, gl_smooth_rendered, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (NULL != screen) + { + screen->SetSmoothPicture(self); + } +} + + +// --------------------------------------------------------------------------- + + ADD_STAT(blit) { FString result; @@ -1022,6 +1581,9 @@ ADD_STAT(blit) IVideo* Video; +// --------------------------------------------------------------------------- + + void I_ShutdownGraphics() { if (NULL != screen) @@ -1042,7 +1604,7 @@ void I_InitGraphics() val.Bool = !!Args->CheckParm("-devparm"); ticker.SetGenericRepDefault(val, CVAR_Bool); - Video = new CocoaVideo(0); + Video = new CocoaVideo(gl_vid_multisample); atterm(I_ShutdownGraphics); } @@ -1055,9 +1617,15 @@ static void I_DeleteRenderer() void I_CreateRenderer() { + s_currentRenderer = vid_renderer; + if (NULL == Renderer) { - Renderer = new FSoftwareRenderer; + extern FRenderer* gl_CreateInterface(); + + Renderer = 1 == s_currentRenderer + ? gl_CreateInterface() + : new FSoftwareRenderer; atterm(I_DeleteRenderer); } } @@ -1129,6 +1697,9 @@ void I_ClosestResolution(int *width, int *height, int bits) } +// --------------------------------------------------------------------------- + + EXTERN_CVAR(Int, vid_maxfps); EXTERN_CVAR(Bool, cl_capfps); @@ -1167,6 +1738,9 @@ CUSTOM_CVAR(Bool, vid_hidpi, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) } +// --------------------------------------------------------------------------- + + CCMD(vid_listmodes) { if (Video == NULL) diff --git a/src/v_video.h b/src/v_video.h index 693bfa687..0f3fb8224 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -416,6 +416,8 @@ public: virtual bool Is8BitMode() = 0; #endif + virtual void SetSmoothPicture(bool smooth) {} + protected: void DrawRateStuff (); void CopyFromBuff (BYTE *src, int srcPitch, int width, int height, BYTE *dest); diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 9ce3c8837..76099babb 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -811,7 +811,7 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) if (m_hRC == NULL && prof == WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) { - I_Error ("R_OPENGL: Unable to create an OpenGL 3.x render context.\n"); + I_Error ("R_OPENGL: Unable to create an OpenGL render context.\n"); return false; } @@ -832,7 +832,7 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) } } // We get here if the driver doesn't support the modern context creation API which always means an old driver. - I_Error ("R_OPENGL: Unable to create an OpenGL 3.x render context.\n"); + I_Error ("R_OPENGL: Unable to create an OpenGL render context.\n"); return false; } From b06c86db38a657e842872466289876779bd4b6a6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 21:42:15 +0200 Subject: [PATCH 0524/1509] - added old wall splitting code as a fallback for old hardware. --- src/gl/scene/gl_wall.h | 1 + src/gl/scene/gl_walls.cpp | 115 ++++++++++++++++++++++++++++++++++---- 2 files changed, 106 insertions(+), 10 deletions(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index e2334f7de..c3b7f5de2 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -176,6 +176,7 @@ private: void CheckTexturePosition(); void Put3DWall(lightlist_t * lightlist, bool translucent); + void SplitWallComplex(sector_t * frontsector, bool translucent, float maplightbottomleft, float maplightbottomright); void SplitWall(sector_t * frontsector, bool translucent); void SetupLights(); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index caf03322d..86fd36774 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -251,9 +251,95 @@ void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent) // //========================================================================== +void GLWall::SplitWallComplex(sector_t * frontsector, bool translucent, float maplightbottomleft, float maplightbottomright) +{ + GLWall copyWall1, copyWall2; + + // check for an intersection with the upper plane + if ((maplightbottomleftztop[1]) || + (maplightbottomleft>ztop[0] && maplightbottomright(fabsf(glseg.x2 - glseg.x1), fabsf(glseg.y2 - glseg.y2)); + + float dch = ztop[1] - ztop[0]; + float dfh = maplightbottomright - maplightbottomleft; + float coeff = (ztop[0] - maplightbottomleft) / (dfh - dch); + + // check for inaccuracies - let's be a little generous here! + if (coeff*clen<.1f) + { + maplightbottomleft = ztop[0]; + } + else if (coeff*clen>clen - .1f) + { + maplightbottomright = ztop[1]; + } + else + { + // split the wall in two at the intersection and recursively split both halves + copyWall1 = copyWall2 = *this; + + copyWall1.glseg.x2 = copyWall2.glseg.x1 = glseg.x1 + coeff * (glseg.x2 - glseg.x1); + copyWall1.glseg.y2 = copyWall2.glseg.y1 = glseg.y1 + coeff * (glseg.y2 - glseg.y1); + copyWall1.ztop[1] = copyWall2.ztop[0] = ztop[0] + coeff * (ztop[1] - ztop[0]); + copyWall1.zbottom[1] = copyWall2.zbottom[0] = zbottom[0] + coeff * (zbottom[1] - zbottom[0]); + copyWall1.glseg.fracright = copyWall2.glseg.fracleft = glseg.fracleft + coeff * (glseg.fracright - glseg.fracleft); + copyWall1.uprgt.u = copyWall2.uplft.u = uplft.u + coeff * (uprgt.u - uplft.u); + copyWall1.uprgt.v = copyWall2.uplft.v = uplft.v + coeff * (uprgt.v - uplft.v); + copyWall1.lorgt.u = copyWall2.lolft.u = lolft.u + coeff * (lorgt.u - lolft.u); + copyWall1.lorgt.v = copyWall2.lolft.v = lolft.v + coeff * (lorgt.v - lolft.v); + + copyWall1.SplitWall(frontsector, translucent); + copyWall2.SplitWall(frontsector, translucent); + return; + } + } + + // check for an intersection with the lower plane + if ((maplightbottomleftzbottom[1]) || + (maplightbottomleft>zbottom[0] && maplightbottomright(fabsf(glseg.x2 - glseg.x1), fabsf(glseg.y2 - glseg.y2)); + + float dch = zbottom[1] - zbottom[0]; + float dfh = maplightbottomright - maplightbottomleft; + float coeff = (zbottom[0] - maplightbottomleft) / (dfh - dch); + + // check for inaccuracies - let's be a little generous here because there's + // some conversions between floats and fixed_t's involved + if (coeff*clen<.1f) + { + maplightbottomleft = zbottom[0]; + } + else if (coeff*clen>clen - .1f) + { + maplightbottomright = zbottom[1]; + } + else + { + // split the wall in two at the intersection and recursively split both halves + copyWall1 = copyWall2 = *this; + + copyWall1.glseg.x2 = copyWall2.glseg.x1 = glseg.x1 + coeff * (glseg.x2 - glseg.x1); + copyWall1.glseg.y2 = copyWall2.glseg.y1 = glseg.y1 + coeff * (glseg.y2 - glseg.y1); + copyWall1.ztop[1] = copyWall2.ztop[0] = ztop[0] + coeff * (ztop[1] - ztop[0]); + copyWall1.zbottom[1] = copyWall2.zbottom[0] = zbottom[0] + coeff * (zbottom[1] - zbottom[0]); + copyWall1.glseg.fracright = copyWall2.glseg.fracleft = glseg.fracleft + coeff * (glseg.fracright - glseg.fracleft); + copyWall1.uprgt.u = copyWall2.uplft.u = uplft.u + coeff * (uprgt.u - uplft.u); + copyWall1.uprgt.v = copyWall2.uplft.v = uplft.v + coeff * (uprgt.v - uplft.v); + copyWall1.lorgt.u = copyWall2.lolft.u = lolft.u + coeff * (lorgt.u - lolft.u); + copyWall1.lorgt.v = copyWall2.lolft.v = lolft.v + coeff * (lorgt.v - lolft.v); + + copyWall1.SplitWall(frontsector, translucent); + copyWall2.SplitWall(frontsector, translucent); + return; + } + } +} + void GLWall::SplitWall(sector_t * frontsector, bool translucent) { - GLWall copyWall1,copyWall2; + GLWall copyWall1; float maplightbottomleft; float maplightbottomright; unsigned int i; @@ -296,16 +382,25 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) continue; } - // check for an intersection with the upper and lower planes of the wall segment - if ((maplightbottomleftztop[1]) || - (maplightbottomleft>ztop[0] && maplightbottomrightzbottom[1]) || - (maplightbottomleft>zbottom[0] && maplightbottomright= 1.3f) { - // Use hardware clipping if this cannot be done cleanly. - this->lightlist = &lightlist; - PutWall(translucent); - goto out; + // check for an intersection with the upper and lower planes of the wall segment + if ((maplightbottomleftztop[1]) || + (maplightbottomleft > ztop[0] && maplightbottomright < ztop[1]) || + (maplightbottomleftzbottom[1]) || + (maplightbottomleft > zbottom[0] && maplightbottomright < zbottom[1])) + { + // Use hardware clipping if this cannot be done cleanly. + this->lightlist = &lightlist; + PutWall(translucent); + goto out; + } + } + else + { + // crappy fallback if no clip planes available + SplitWallComplex(frontsector, translucent, maplightbottomleft, maplightbottomright); + return; } // 3D floor is completely within this light From 3faf5afa3aec40b5df9f334d915430631a740f7b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 21:49:30 +0200 Subject: [PATCH 0525/1509] - re-added software translucency splitting for old hardware. --- src/gl/scene/gl_drawinfo.cpp | 43 ++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index c9cdf094d..8bfa3df4e 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -319,8 +319,29 @@ void GLDrawList::SortWallIntoPlane(SortNode * head,SortNode * sort) // Bad things will happen if the memory must be reallocated! GLWall w = *ws; AddWall(&w); + + // Splitting is done in the shader with clip planes, if available + if (gl.glslversion < 1.3f) + { + GLWall * ws1; + ws1=&walls[walls.Size()-1]; + ws=&walls[drawitems[sort->itemindex].index]; // may have been reallocated! + float newtexv = ws->uplft.v + ((ws->lolft.v - ws->uplft.v) / (ws->zbottom[0] - ws->ztop[0])) * (fh->z - ws->ztop[0]); - // Splitting is done in the shader with clip planes. + // I make the very big assumption here that translucent walls in sloped sectors + // and 3D-floors never coexist in the same level. If that were the case this + // code would become extremely more complicated. + if (!ceiling) + { + ws->ztop[1] = ws1->zbottom[1] = ws->ztop[0] = ws1->zbottom[0] = fh->z; + ws->uprgt.v = ws1->lorgt.v = ws->uplft.v = ws1->lolft.v = newtexv; + } + else + { + ws1->ztop[1] = ws->zbottom[1] = ws1->ztop[0] = ws->zbottom[0] = fh->z; + ws1->uplft.v = ws->lolft.v = ws1->uprgt.v = ws->lorgt.v=newtexv; + } + } SortNode * sort2 = SortNodes.GetNew(); memset(sort2, 0, sizeof(SortNode)); @@ -357,8 +378,26 @@ void GLDrawList::SortSpriteIntoPlane(SortNode * head,SortNode * sort) // We have to split this sprite GLSprite s=*ss; AddSprite(&s); // add a copy to avoid reallocation issues. + + // Splitting is done in the shader with clip planes, if available + if (gl.glslversion < 1.3f) + { + GLSprite * ss1; + ss1=&sprites[sprites.Size()-1]; + ss=&sprites[drawitems[sort->itemindex].index]; // may have been reallocated! + float newtexv=ss->vt + ((ss->vb-ss->vt)/(ss->z2-ss->z1))*(fh->z-ss->z1); - // Splitting is done in the shader with clip planes. + if (!ceiling) + { + ss->z1=ss1->z2=fh->z; + ss->vt=ss1->vb=newtexv; + } + else + { + ss1->z1=ss->z2=fh->z; + ss1->vt=ss->vb=newtexv; + } + } SortNode * sort2=SortNodes.GetNew(); memset(sort2,0,sizeof(SortNode)); From 066d5c63e2599039bf69a2e1d4aa634af975f700 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 21:55:17 +0200 Subject: [PATCH 0526/1509] - better be safe and not call GL_CLIP_DISTANCE functions on old hardware. --- src/gl/renderer/gl_renderstate.h | 15 ++++++++++++++- src/gl/scene/gl_decal.cpp | 4 ---- src/gl/scene/gl_drawinfo.cpp | 14 ++++++++++---- src/gl/scene/gl_sprite.cpp | 4 ---- src/gl/scene/gl_walls_draw.cpp | 4 ---- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 04142a582..e61ab004d 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -233,7 +233,20 @@ public: void EnableSplit(bool on) { - mSplitEnabled = on; + if (gl.glslversion >= 1.3f) + { + mSplitEnabled = on; + if (on) + { + glEnable(GL_CLIP_DISTANCE3); + glEnable(GL_CLIP_DISTANCE4); + } + else + { + glDisable(GL_CLIP_DISTANCE3); + glDisable(GL_CLIP_DISTANCE4); + } + } } void SetLightIndex(int n) diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 42d2eccbd..1a10b3f4d 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -388,8 +388,6 @@ void GLWall::DoDrawDecals() if (lightlist != NULL) { gl_RenderState.EnableSplit(true); - glEnable(GL_CLIP_DISTANCE3); - glEnable(GL_CLIP_DISTANCE4); } else { @@ -405,8 +403,6 @@ void GLWall::DoDrawDecals() if (lightlist != NULL) { - glDisable(GL_CLIP_DISTANCE3); - glDisable(GL_CLIP_DISTANCE4); gl_RenderState.EnableSplit(false); } diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 8bfa3df4e..386dc6a4a 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -806,11 +806,17 @@ void GLDrawList::DrawSorted() sorted=DoSort(SortNodes[SortNodeStart]); } gl_RenderState.ClearClipSplit(); - glEnable(GL_CLIP_DISTANCE1); - glEnable(GL_CLIP_DISTANCE2); + if (gl.glslversion >= 1.3f) + { + glEnable(GL_CLIP_DISTANCE1); + glEnable(GL_CLIP_DISTANCE2); + } DoDrawSorted(sorted); - glDisable(GL_CLIP_DISTANCE1); - glDisable(GL_CLIP_DISTANCE2); + if (gl.glslversion >= 1.3f) + { + glDisable(GL_CLIP_DISTANCE1); + glDisable(GL_CLIP_DISTANCE2); + } gl_RenderState.ClearClipSplit(); } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 40aae9165..942a2e555 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -226,8 +226,6 @@ void GLSprite::Draw(int pass) { clipping = true; gl_RenderState.EnableSplit(true); - glEnable(GL_CLIP_DISTANCE3); - glEnable(GL_CLIP_DISTANCE4); } secplane_t bottomp = { { 0, 0, -1. }, bottomclip }; @@ -333,8 +331,6 @@ void GLSprite::Draw(int pass) if (clipping) { - glDisable(GL_CLIP_DISTANCE3); - glDisable(GL_CLIP_DISTANCE4); gl_RenderState.EnableSplit(false); } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 5d5a1a7c3..8fe9d948e 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -339,8 +339,6 @@ void GLWall::RenderTextured(int rflags) else { gl_RenderState.EnableSplit(true); - glEnable(GL_CLIP_DISTANCE3); - glEnable(GL_CLIP_DISTANCE4); for (unsigned i = 0; i < lightlist->Size(); i++) { @@ -363,8 +361,6 @@ void GLWall::RenderTextured(int rflags) if (low1 <= zbottom[0] && low2 <= zbottom[1]) break; } - glDisable(GL_CLIP_DISTANCE3); - glDisable(GL_CLIP_DISTANCE4); gl_RenderState.EnableSplit(false); } gl_RenderState.SetTextureMode(tmode); From 09f54b09409ddb65debc0a186eed06d1cca40252 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 27 Apr 2016 00:41:00 +0200 Subject: [PATCH 0527/1509] - cleaned up the clip plane management for portals. Unfortunately the math behind the old clip planes is utterly impenetrable and so poorly documented that I have no idea how to set that up, so it is deactivated for now. It wasn't working anyway. --- src/gl/data/gl_matrix.cpp | 12 ++++------ src/gl/data/gl_matrix.h | 5 ++++- src/gl/renderer/gl_renderstate.cpp | 33 +++++++++++++++++++++++----- src/gl/renderer/gl_renderstate.h | 20 +++++------------ src/gl/scene/gl_flats.cpp | 2 +- src/gl/scene/gl_portal.cpp | 34 +++++++---------------------- src/gl/shaders/gl_shader.cpp | 4 ++-- src/gl/shaders/gl_shader.h | 4 ++-- wadsrc/static/glstuff/gllight.png | Bin 0 -> 13073 bytes 9 files changed, 55 insertions(+), 59 deletions(-) create mode 100644 wadsrc/static/glstuff/gllight.png diff --git a/src/gl/data/gl_matrix.cpp b/src/gl/data/gl_matrix.cpp index 35683dbb8..a16dc770f 100644 --- a/src/gl/data/gl_matrix.cpp +++ b/src/gl/data/gl_matrix.cpp @@ -10,6 +10,7 @@ This is a simplified version of VSMatrix that has been adjusted for GZDoom's nee ----------------------------------------------------*/ +#include #include "gl/system/gl_system.h" #include #include @@ -139,14 +140,9 @@ VSMatrix::translate(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) void VSMatrix::scale(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) { - FLOATTYPE mat[16]; - - setIdentityMatrix(mat,4); - mat[0] = x; - mat[5] = y; - mat[10] = z; - - multMatrix(mat); + mMatrix[0] *= x; mMatrix[1] *= x; mMatrix[2] *= x; mMatrix[3] *= x; + mMatrix[4] *= y; mMatrix[5] *= y; mMatrix[6] *= y; mMatrix[7] *= y; + mMatrix[8] *= z; mMatrix[9] *= z; mMatrix[10] *= z; mMatrix[11] *= z; } diff --git a/src/gl/data/gl_matrix.h b/src/gl/data/gl_matrix.h index de4b400da..3ec1f5ff4 100644 --- a/src/gl/data/gl_matrix.h +++ b/src/gl/data/gl_matrix.h @@ -48,6 +48,7 @@ class VSMatrix { #ifdef USE_DOUBLE void multMatrix(const float *aMatrix); #endif + void multVector(FLOATTYPE *aVector); void multMatrix(const FLOATTYPE *aMatrix); void multMatrix(const VSMatrix &aMatrix) { @@ -92,7 +93,9 @@ class VSMatrix { { computeNormalMatrix(aMatrix.mMatrix); } - + bool inverseMatrix(VSMatrix &result); + void transpose(); + protected: static void crossProduct(const FLOATTYPE *a, const FLOATTYPE *b, FLOATTYPE *res); static FLOATTYPE dotProduct(const FLOATTYPE *a, const FLOATTYPE * b); diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index d1e30c560..fdb0e3cc5 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -86,8 +86,8 @@ void FRenderState::Reset() mColormapState = CM_DEFAULT; mLightParms[3] = -1.f; mSpecialEffect = EFF_NONE; - mClipHeightTop = 65536.f; - mClipHeightBottom = -65536.f; + mClipHeight = 0.f; + mClipHeightDirection = 0.f; ClearClipSplit(); stSrcBlend = stDstBlend = -1; @@ -140,8 +140,8 @@ bool FRenderState::ApplyShader() activeShader->muObjectColor.Set(mObjectColor); activeShader->muDynLightColor.Set(mDynColor.vec); activeShader->muInterpolationFactor.Set(mInterpolationFactor); - activeShader->muClipHeightTop.Set(mClipHeightTop); - activeShader->muClipHeightBottom.Set(mClipHeightBottom); + activeShader->muClipHeight.Set(mClipHeight); + activeShader->muClipHeightDirection.Set(mClipHeightDirection); activeShader->muTimer.Set(gl_frameMS * mShaderTimer / 1000.f); activeShader->muAlphaThreshold.Set(mAlphaThreshold); activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now @@ -324,4 +324,27 @@ void FRenderState::ApplyLightIndex(int index) } activeShader->muLightIndex.Set(index); } -} \ No newline at end of file +} + +void FRenderState::SetClipHeight(float height, float direction) +{ + mClipHeight = height; + mClipHeightDirection = direction; + if (direction != 0.f) + { + if (gl.glslversion >= 1.3f) glEnable(GL_CLIP_DISTANCE0); + else + { + // This does not work. Need someone who understands how glClipPlane works... + //glEnable(GL_CLIP_PLANE0); + // Plane mirrors never are slopes. + //double d[4] = { 0, direction, 0, -direction * height }; + //glClipPlane(GL_CLIP_PLANE0, d); + } + } + else + { + if (gl.glslversion >= 1.3f) glDisable(GL_CLIP_DISTANCE0); + //else glDisable(GL_CLIP_PLANE0); + } +} diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index e61ab004d..ca240c398 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -63,7 +63,7 @@ class FRenderState bool mModelMatrixEnabled; bool mTextureMatrixEnabled; float mInterpolationFactor; - float mClipHeightTop, mClipHeightBottom; + float mClipHeight, mClipHeightDirection; float mShaderTimer; bool mLastDepthClamp; @@ -135,25 +135,17 @@ public: mCurrentVertexBuffer = NULL; } - void SetClipHeightTop(float clip) + float GetClipHeight() { - mClipHeightTop = clip; + return mClipHeight; } - float GetClipHeightTop() + float GetClipHeightDirection() { - return mClipHeightTop; + return mClipHeightDirection; } - void SetClipHeightBottom(float clip) - { - mClipHeightBottom = clip; - } - - float GetClipHeightBottom() - { - return mClipHeightBottom; - } + void SetClipHeight(float height, float direction); void SetColor(float r, float g, float b, float a = 1.f, int desat = 0) { diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index c90e9541b..7406bb20e 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -438,7 +438,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG { gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); gl_SetPlaneTextureRotation(&plane, gltexture); - DrawSubsectors(pass, true, true); + DrawSubsectors(pass, gl.lightmethod != LM_SOFTWARE, true); gl_RenderState.EnableTextureMatrix(false); } if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 6c2a05592..93f25f28e 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -300,11 +300,9 @@ bool GLPortal::Start(bool usestencil, bool doquery) glDisable(GL_DEPTH_TEST); } } - planestack.Push(gl_RenderState.GetClipHeightTop()); - planestack.Push(gl_RenderState.GetClipHeightBottom()); - glDisable(GL_CLIP_DISTANCE0); - gl_RenderState.SetClipHeightBottom(-65536.f); - gl_RenderState.SetClipHeightTop(65536.f); + planestack.Push(gl_RenderState.GetClipHeight()); + planestack.Push(gl_RenderState.GetClipHeightDirection()); + gl_RenderState.SetClipHeight(0., 0.); // save viewpoint savedViewPos = ViewPos; @@ -363,13 +361,10 @@ void GLPortal::End(bool usestencil) PortalAll.Clock(); GLRenderer->mCurrentPortal = NextPortal; - float f; + float f, d; + planestack.Pop(d); planestack.Pop(f); - gl_RenderState.SetClipHeightBottom(f); - if (f > -65535.f) glEnable(GL_CLIP_DISTANCE0); - planestack.Pop(f); - gl_RenderState.SetClipHeightTop(f); - if (f < 65535.f) glEnable(GL_CLIP_DISTANCE0); + gl_RenderState.SetClipHeight(f, d); if (usestencil) { @@ -804,22 +799,9 @@ void GLPlaneMirrorPortal::DrawContents() GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); ClearClipper(); - if (PlaneMirrorMode < 0) - { - gl_RenderState.SetClipHeightTop(planez); // ceiling mirror: clip everything with a z lower than the portal's ceiling - gl_RenderState.SetClipHeightBottom(-65536.f); - } - else - { - gl_RenderState.SetClipHeightBottom(planez); // floor mirror: clip everything with a z higher than the portal's floor - gl_RenderState.SetClipHeightTop(65536.f); - } - - glEnable(GL_CLIP_DISTANCE0); + gl_RenderState.SetClipHeight(planez, PlaneMirrorMode < 0? -1.f : 1.f); GLRenderer->DrawScene(); - glDisable(GL_CLIP_DISTANCE0); - gl_RenderState.SetClipHeightBottom(-65536.f); - gl_RenderState.SetClipHeightTop(65536.f); + gl_RenderState.SetClipHeight(0.f, 0.f); PlaneMirrorFlag--; PlaneMirrorMode=old_pm; } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index af6accdb5..a86c57101 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -280,8 +280,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muSplitTopPlane.Init(hShader, "uSplitTopPlane"); muFixedColormap.Init(hShader, "uFixedColormap"); muInterpolationFactor.Init(hShader, "uInterpolationFactor"); - muClipHeightTop.Init(hShader, "uClipHeightTop"); - muClipHeightBottom.Init(hShader, "uClipHeightBottom"); + muClipHeight.Init(hShader, "uClipHeight"); + muClipHeightDirection.Init(hShader, "uClipHeightDirection"); muAlphaThreshold.Init(hShader, "uAlphaThreshold"); muTimer.Init(hShader, "timer"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index cf6480d9b..a7f7e4277 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -221,8 +221,8 @@ class FShader FUniform4f muSplitBottomPlane; FUniform4f muSplitTopPlane; FBufferedUniform1f muInterpolationFactor; - FBufferedUniform1f muClipHeightTop; - FBufferedUniform1f muClipHeightBottom; + FBufferedUniform1f muClipHeight; + FBufferedUniform1f muClipHeightDirection; FBufferedUniform1f muAlphaThreshold; FBufferedUniform1f muTimer; diff --git a/wadsrc/static/glstuff/gllight.png b/wadsrc/static/glstuff/gllight.png new file mode 100644 index 0000000000000000000000000000000000000000..a3a296b9f856f4654aae244e3400a4f33fd95902 GIT binary patch literal 13073 zcmeAS@N?(olHy`uVBq!ia0y~yU}OMc4h9AWhDyoryBHXZZg{#lhE&{o8v8P7uH~wf zpZETEMnC!|AkuoS@R3THe(~kWN6KvO3OebyGV1+5U;o4YqkL#+sOi*Su5W65ztl%F zloo^rpFJPqb3}yc!hcW3IiF|Fidk+hbn54#2haa^F`WD8bLCv-=WtQs)t|LZ8tMeE z{@=rJZtLn*ow9}zdl@b3m9nbrwoGCbae0$}f#v@*@%*3ObMKvdI$K6CWA5(`$55XT z*Q4h)PyF@PUcJF)YNYJ85XPXu)4|hg4SdrtoOk>n^DmjnW3HK1*4=%Zw66GD=QDQ& zMJcHEyf5ber~7`N|GKoltyWt$TKfp!WK+0*?B^rFwwn3LAM!2tPYH^i=@`T)Y~0-Q ziT`Eh6x9_69@w;03I5Mxlu0$;`|qUjG>#xW)z-=%iKfvitE9fkPMlQ#^5xbmw*I*l zf5Y-7$kj!%H_Cj-7bxOi`A1f@b|udr@3(d(H(z}Fyz28cZ^chp$^97ve z-JJTxvGA{e*H0(q=LtJX-fj@!3pCw#LhhHi?EIMhQ`@fRulvJV%5kjCQfFi64}&Cj z+f3s)=NsZH56$ffs9s#MplbHfGeyhFqE5~B~%z4`O^^a2Coh!9I>iSm4ZORQT1rhOwf-V1onO0o) zTy7p*Ty2@36}dK5K*C=_h3l_Bh$vF z6DPPj=9UZ8Z)SL~^x^Z@?f2!k`sxI~sH%Vcfsun-(%|w;o$K%CD$7p(Q_k72rf}!( zkXm{7^5Ax}9jn4?9_SiA{t?mZ*gUOa#;O@9f1fDiv`)Md{3Evi#s2iaukKVye%+I% zoE#s&z~W_%XS%`*9yNg)6;8RV`@dVI=D9DZpUn2+=k9s?_sv-OY^68nmZ`U|p1M;h zeX_VLzuoW;vn{g=^KtPhY%|2NPRy9NB>YbvV@hZ9r+Gc;w*QysK7M_)x^92@nu34l z@3|F5HMaTh&Z`i)|Kiii8PjH*%=b7@|M%x?&PA0m3A0U3b6;2PO=k7-G+8?3m{Y%< zW%|V_463v8SSP4t&2wco^y3Y2a;?8B|6_f1{Z;G7g~fAjM@tBt+W5zA?Y?5a92xof zIUW}J(*jLhp7Q83R$ly`8AZd^{p6H}ZaXFeB`UlUXx^2$$8rX0?uv zCI9{h<$d60+93GflBr?xqaS~TF7Z7x-=*EGa)S5c%5Wc^BN7u0vzD@5)t|FtmHVZc zjVJU|-RFxlEVZ3^cnZfJ|G5(je%gQKX}KC*i;aaa@>_hjA~P zVCSkuN5i=pw(2aY+`y36C;mW`H~q(BWow5A3sQww_?7%qw|cegmgy!=&MizAgf(P4 z;yF0}eExR-)%v-1y*e|Z=kNcM5ZP$-*>9(C%>GxcZ2@K(2M&b>*d1GXm^r{;#S|2%9LMtufAjzN5F@L3Tk<5M`Pu*TM8nWe{Owp z!Cvy;%2l1$@9$c$zSybde?iNMR)(Jz50}K62(8vQ-t*T!!gSHGQ}GAooey8SBv8dT z-;{a2kVBI3v;*z0d2&v2p3%ReTv$}Mg59i-f&Ii+CpQK^s~js4hKu%d_hqwwEHz_T zuzZ^8`}B8NaqLUk6T%uBC$2o8tnS*_{l>u~^1HuK#4LpeA%?313V+_Z^&!*x!TeAE zWi}qzS}O74_&sY|j{T1uPG@i$6@BFnPBV)Ei~sn~ikB>?n{_>J(WjRY2kevo z?M`y^G5YHXgNg@nJO=1827rM+B za4@d6`t$V0^E-QI-)t`468q-B!Mk!tc$K3T?b=y7bB9pU59fyx5ldD&Gq?%z&3)f( zf1M#jYxjoR7SpZWt^P_qVA`aYlJ@P1`SLAu-ZU(eY`mId;}OK(;ieTLAv0}#yzK$Q zzg&zr9-25Z|LLoln={Y+Q~bt$?YZAKhOiiyJMqt5<;5PZT`Q2Q5Ypke`quIEggv3k z{sQ$%4V~57#RKFS^;{+#W6+qn?AGk+)&CApX$+K_B{tcsS%$OV#rjo=rT;EyHYRh{ z&yxDZzg}LTf$3V))$e|+qW+EVM9t%$e>W0+X?rrRY+-@g*^>)>EJ8R0mjy&{2~1wd zvXt%PZz%(bxX>4i*dJ{8Z_yWQb|ZdC$x4?*8P9WFyR<|*&RD$+f3?b>t1WrKLMf?P z@!cVl?+Y`$nSal{-m~E${}$bvNSpPat2`4E+zV!@Ygql4eEG$(J5;ZXZ*d6Eq;1Sr z&E<|&GWKCi|2dhK9eGn}TfJ)U`I-+M3-#`u_5IsuuuP%D{lF)ivVM;vbN!0Ue@q!C56=T>q!=JNxzb zIVLl#AM{L8v|jU|ztga#;c2|tBn!!++fKEHeDj4EF8$|YsGU{2uBE)tqW^tC-@h5N z?LRa=VU^VPnGpE?&4U?JKeGh!1qKStUuhC+{42Od=;Pyr1NO%nIuCrTD%vmW#C3AM zNp|qtx%Zro_uOM`I=FD5QDtMZy6%~90p5-m-Y2A+9cF4y{5Ok%Yl61jeC;jwazpB0 z9y)d5_T&DWk5j*C%lVi#Y&2=%^$~8o7r9LF)XxBOp~6kvJ{loz{;m#!c6@Aq*yS3M z?A?R-A6SRZRFeJ^@Lm10{rBZ}?p1PC{$t}!>saZjvT&O6g%%-kQSaw@G0d6u^0j4x z7dzyQy#5}RkTBq=tdc*u^F@$oE;ubB4N? zt*s@wEc+EayZGNW)X!lSn7wp;6g!98f%3RrvzG~1oD#QMqoC>{@>QgoqwT#0%ey!! zUa!82)`L(AFcw|t%4(>(j&&56P_9)DNXOu5h= zypm%sYp>YpvjVGgEUeV8Rh(>oWq3e5BVf*tOkM>x6~X;AYz~|c1*}iq{cE|&BHfkk6<;tuAYc+^cV@8J4mI(6Ti z|C4up*dV#!LVP=K;NnvjFC5D|d!$|pFtfh-&-rK3G*O6NSNC*%Onb>~GT+JW!M|5`&U-R*7`a}FxhI;twc@*(PQ0m-p@L3`Xf@~i z#ZF1zS^||i&r3R9z4$$XEg=2lZE2=OH~v@p-TFLdvHet$O?N+kD|d@sZ2T=WH*ZIQ zer~6N5f8_w{E5#+`&gZvoK?@gRE~Sd_%Z89&#j%aSM<*JAHn<$SJZep z6%Tyr=_>JfX16$gv4)4{mrV5!g5pZ|r2d+pyKq0PF_gb`qY__--7A+Kykpfb+$S}O58~nux&A3fe#zQsytRM!`D6IM?0-Dz3#U4(zH{De>UW1x zkSDGqi$CP0*NF|8lI+^8`*(cxl?%n3Z7S;OczU}@;zuZ<_$ z=dI(_Bq3>uFWOhWTUs?3EjW9iQ<|x}s_K?Q7jw|_{NRAF{XgYyt&+c`Ht+EQg-V%> z1eZqntOGCoH#oL`U(%$>T5^oo{3IycNHzbA#)b|FQoi4koADGh}8bZ#w3))lfxc z3;S`8Z=EfC$`@Yd-rOJCQL(yqHB()`*`)PM0aE`McU=1|xg`8Wv2Ezbnw%$fKewt) z4ijhKKXh^RIdvudvkStKxAY`A|XnN3Z`Ag|nNQ>ZJ6UJdBL|9SV{@?FwJ-v+#lF zx3G7=C6pT8sVK+U--+IKP~&{_igN+a4hd<#k`g%>#&FZ$WsXOLAp0S%Lvjj6@9Jms ztDJCmzoT#{PSIc~BY&2XsLH|oo_%dMKY5ndI89)(ZE8C{)tVzz=|Iu4`{CX#3yw6r zs#m%yhx9@iy}*1t~?XTdFyeqyN2nYW~1FXkOX@ zEyjO2EUzxUpCJ49+2T|I5s@j0HMLB4j~)nFz+~?xoFTQlo!jv#JhW$4 zPwLUHZtQvy_)w{QV;}g1VD`S=^F5moSrc!6KVG4Zr73dUkXs!_~j? zla6N0bUHk_B&j@uZ|0qzXW_G28NTrsCq9`fcx~Rg;C*WY8YXbu{QF5#sd6!+%`?Fz z5wn;sgw9=Zz*h8`-CWLsO%0hDO&2SU_0&HVAmox79ck}Rf)}PHC z0yhn14qEdXNU<)z@@lEW|Bn`{o~8c_VZ5P{ZlkcPugY(coXe~0|JEyMKRZ^jthsb{ zK<55aXFmO|TF-y}ZGI=mS{=_VNy$PC1sug8Zqgj#`yxWTd{xF>Mpug6-DH7SF@t&qoy+&bRvQ z88M~XA?wcl*4N9Y_a8iXFqL2A-!lUi-z(o)_Dd}}p7SQ^{l}*hYAsuWTD+N6c1L8| z2+aC-_cou2`LT=4g^I3aYR5YHnl>A3PY>Ap(!b+bZS?*}uH|=&D;&8Pmaetu+rRWP z)7t!WMu}tf&F_5nHn@oD$!<90*b`BBcIM(A{8!J)HC$3Zek0>uch;f$0{aNnU6RL_ zTHjZSc1lv_bx10>S2v-2$`1{`1(s$n@??3^dKgzm#jD!$3qSSdNn(DG1ATY&F` zjwM-NC%sP;4|!5oS|9S;?VETkQ^30S0eUmoTg?}QE9S7K$lup>eO<6x{$}yh~KgQ_o3z-B3H{SfRyy=Zu z|85TvXNGCDr_ToOxsa&TJj1q2{6ImV&8Z{5BNzTt}BZ6@W;X^?SGYqRDDw$fJt zfol3@TOPdF%cFc@VnL6(!R?TDYRk(0KfA*C<;ITsCcYOd?>D@cV45JK1>5%>t$CUj0X`(l@{Mc8?WP z8-xyNGMwJ&>l5LweL3N~h2#8Ct}`#(SHI?NJ{aG2H}G-$wzrSvI3iBZi1BdgJjke^ zS6snp)A%#g^JIt1n=8vQls%mPT=;V8@i`6^hR)SoG8hF+T*{9SEMcQXFj)3BOb2!iW%a?dI%=2x^T5=@E@At%uAI~Z#rZN@9F#F{jU8~)vlcuDA8U*oC&xf(q8+NX$T zWSyJS@_vd~qS`af`g0Nq7ydp`efG4&fkP-EfJen)62snKGx<3;e7Ldly}+Sm`nrTf)x3raIQd$K!H&N@{>a9zts=^2p=)0_(qS~_K{ zzoL9&)AxJTr~7L4YP?-NqffX8?0dl)Zg4R`qXUuI`z5u4Th(AmHU@J$xcpvugf6b z*v~m<_aU}J&5OT7L~CB<+l@1W!N3rFM>{LxyNTs*az-&)K@Ez8r6D1jX7Czva)OC+Jz=}7^CWi5)t26_P^H-*C zKJAU2M?9wZTRpj|c5U`P8RzCKAqBzbhHhJY7bG{{V{z8JuI^=0>+An|wU$)RcxQ)n0?Z&jB#3md6kS(W6p&sY_`9=@2^O* zI8(uJFZkf!(x08@TDD)ZzO~${BzETS)y#YL|DI>@rBV0 zGtz0ct_8~)MWd>-6SU+Kt_!e#^dFzdDT1+l3UM#QT76i}Tuv6bZ~1&chom6ILCqtZ%#*2c{|zW37?X?qbJ);;a_uQRXMc_A^; z=%jq;ud5gDiRXMx5Oz{y>&m{beT>^dNkYcx+vF1#3dP2YFLv(a%QaHT2zjvAp<(&l z0@pJw>Hp8TCUR6e3$V7Hk)A$JU_rx?sizXBGQO`hV$^VGZBqBL5ZC`vwY1|n+lz<- z_s6>KsZ*rxTRXDFP57_AbIyXE%oX1yUgR-^Evvg2_HfrxTRiV^Np`~9K1asN^UBBL{UBvUvK)Z?IKj&|1{4-&hYFh`- zpL}J37+Ddo>l{rE&Wg_s_ArFSoc-$GwY0*{ZB-TT-lAKRF6{|>8K>^o)RT4i>Mu@v z`N=#I2kKUcglsg7ZrsvTeKcK1_35H4xz`jq~AQOwEE_J?bMEIz3p~k=TJluz{+KjDez{$AXyP|<#5`4e-g1N!H_+w!VAAAbDr zf}-t(4INX%_j?JS5(=xC5Ws17P+7w#pfxG+X|MPd=R?k-*}1ngmR{hqke#yPp6dD4 z3`L)Ur`CSiI@fu*E@jbQ-+z(QI%==dE=!iF3w>(2Sx;VGf7kB8 zio*;Y-}do3W;*n*Tj2Ts#RAWkBh{P2dMAWW-{>eB`tDn$Fvl`=hm&iC>a7_%1BFV| z8d;)JoF@D^-p#S-p2O`%t~o~4DK0s?4jP`g_$5_5N!)YmcI_3b(o6!EoqMvVYQMtc zsXUARI`2Gdt={}h-6}Wf=s|b3*K_Jv=hi*FJ%Nwio12SUpOafVMYU+OW0Azjo+L! z6W#}#SO*q%Guw(hQgVw6sNA5O&-Tv6ac9_rt-ltlDV)w`R*7Ord$WA`c!*DGHcyeJ>a!i@BY{~^XK1| zZ?7f(pK3Ln@^hE0L54=m8Mhk;mPmZ@N@<(jZr}OgR`q(5Hg3zLc1}^&x18)UE+;me z3)(up{-y0p@ASJf4n8sbrrC0O?_Son?}-|7tk1-parF3nIbnXlDLHk{EbR?VSx27o zGIq~5Vw&C1bR?^9$2nVlo8$b&qEmKvOkI|^GH$V5+z-Dhk=e%+ddzM-h}&Svrfd;= z&x7&z^DJ+PYENdC+4m1TlM2jc5aV3QS1{%H-TR#fSy?5|){F7(RM0=Wi~r_z(VrbCqVK`S|`tjzPncC;A)E~S_ z)wDYM`&!_~hYlU>`x*b7UAKWD!0-97CtE&$T0FIWt16FCvxu;;-UJ8D(*BU+9{vSu zqQ$#DHe2!$@UL06+ocW%QA#3>A5}U?lo?Z8J z85EjR1Y~sEvsF@Fo}Sa+dbwZb#gYBbf243;_FKa@^^$>(WW$M!xo172wC-3RaShI$ z=IY5*Rg;N2Rml*1isAN;Zn)+YH_mBh0`zm zrGy>Sb<{T`tzFE+J%MA6!*m~psp+*Do7p&~v$MLNYIP6!F3r7B+Uep=F|EzN)E#XD zT3F=*A{L)^GE$3a>3McPSfER^;$ipV`CGroWl!zy*{dCG;kG$j^Q2@~bsLAEn)ZX0 z-P2wlFjY|3O**$g&~zs6`D6#Ki1Y4jhGvN`Bsy)`T3DYt6#CSE+4%W+eD&ME;cwRT zs}-*36xN-hG&Sb#l8Sm2!TVwcOS-7dpxvz8BE;p{5x!^ccmbKH`lODzNnIk&~n19|&ibd@px@HGo$an{qHP%FH?!l5`mm}gnpe)h@tT20wlPn=eW zIdkmzl z;*~hIW`6x5$LzN!jt5N3+o<+tfz!)-v(w(5jZCsSR`+Smf4TOc_j?z)&71b&*6Xsf zj&|Ag&!iS~a)(*%$c*DNTEO?R;7{ny4?jbmeP2+U5IQkOegC7oHU}@iD42UILTg7# zj_rbdzXiX2h$`6mYkueVzE}Fp&5Uza-S)u67uBQh?K2;b8ZGJQ(`RC4`8=D)N=XmJWZ7h60O;YvypX4u(S=;um zb39YIpz?XIu-fjgAL`shMP`18YdFRp`XR-q*=TdC^qKg(3R3_4HYqzRKPz@vpzwXp zit0~u`<|{a^ga~x>!Rf=zJ!Q*^3Uo686q4Lx*WwGHE4Ct31Ns~G`X~Qw$|;%vDGK} zOC6*(D)?6X+a7l&eOB$NJMR|<8g+bQf6hKpi%Y7!O} z8BCGs<~4cs`2}m^Er|tg_0|4|*1ullHldZ}$NEVQQAdsz7Wt_3#2yek*K(hOq4tf$ zr^M?y+w)qVDs{x2wbv5={y+6!`3X@j_k~O*vdWzPyYDbC%`ahO7ER%OVYaDsqtYgm zUl+T2CHYU@C~XiA+Isi&+mE|mUvIO2c+JAB^DOTYM$Obe?lJe<-8C};Q#?K;v(y z|E!RR2>9P~)0d~|gM!!T<7NwL56-D_J)(cn@Xz94h6II=L9cz*+b@?Aw_ou5@YLC- zPK6gJhuqqKmE#3t)AcCs_UFGoyzA3?#v1!Xdb+rFM)}q$v+JvvQV!P~t)Kjmqq*|j zZ1;Obf`5GWs46+^{I_+tfW^IfHm22q9~pdW7UvXMd|uqVjGg;m##OQ7Oqs89zZ~v& zW#7ZZ{obzPiy_;77G2vWxp#p~6Wesc>~4pu9B^eg(8TQFo53ege*V+f_mTX+FK)9G zYl`J9FnzZs=kSRVuCM1p7nppXdd$v1WxMSa;w2ki@+Uqa-G=IDEce}eWgRJF!N6*9yjn`MS9qnL!vX^O3+QMh`;KpOE52N0S#b5|`$mSaNat5#J&$?= zFFPDzW&Lx71!kLf2D1wc|Y#`8y##UjacMh*a?mgdcGkqUCzN7V`PQq9(22Jg>Yx|DBe zKBtG@=ET+R6CE1P&iGJoTo?8@UY(&SRAtZd7fFKNry3@Ozlr!gnMq=?Lav_W&N6%V z@Be!e(=$Fi%C*o>_Mf$R!h`!y|0FB^PY%inJiIbh;Ks{avsWHkTpVSm%dqH&^s|4a zx796Vd%~wF>s$8<%=#{2lv5Y5xcwhit8*>F+TA!pX z+{7{^kn>fd{GNt>mIB=d%}L5UEbLuP(;%ED3J>2;+aZiio_f(@>k-Vqo>OZO9Y}l}V zzrLOCsYPp6eEIKw{C@<4?Vo);^LoFpzb^N9#@#wa+ed$*nj9i>+ikyF$9)VJVB5D- z>)Ni(RSg#wed(`KHFSF7%vrOBaq^qUEBbnGpZ=b|blQa5%3qeemwCNy@`s)756y4f zS-RQ!C7)_zEQ8h3^`&ym4vinToU@qwEC2s4hIN7)rpwwGHpG2?zi39jEYIZ!kGoD@ ze^cF~^?^;y!VuwpLYmWOuKx4&ci%*@ z72L0Gm~pJzHH(_@BOolHj2AE zf3VaenW;d%?&^=bZ}TTc9#p#TuDU4EKG}7%I|FZzV)CcoOb2dXll$=J+pp(h8moTx z>|FNd-*LuID>jQO?f5hGtX{Rj{hbo~(z>6#v-GyN{NF#H;Y0mg=?|xF2_6j16t7~B zJ6p`~FmlH|*QouoE^pS5NSbxJ%X7vnjTt3bfpxNq_LU6tH!zwXUpuj(L88yQ=i(!V zqtiFCG~M2wDU?@`uqR9F&?~Ko zICOfQ5T~Hg)5izSHZ1$HjQLo{?guB6r({g=GI5fLuB-cZo}*!stX>~$u}vj^iMhiC zuN^u~vit7IUF2y!e3!4?C6iTnzvhL-Z5u@Y{4n(U{haMVILm>@{`Nm4?>tdETe`Gy z-`(5w1_xcI+pe%H5SziX-*Kj`*hbSNK@pGFVc*iv{nupl2ydw5b=k|H*LjIeV&T^~ zC+md;O*f3UtkyR^sXsxV{VHRg(*wC+*Oh$VIycvPF-+&@NHaew%dwqTV)lh{{liZ( zD^m7meQGzE<9{td@Xp?s-*&o-1iZd^Kv^hWjp5AS)j!j3+16dTb@1l>n4eKK9Fp}G z2GM&ScowGY3ct)I{d@XR+p7{ACuLXcd%?NF&%#Ijyymep)17}gI{$fgRISoF*7CrU z&%GP_E&o;i_$qX6QtfU5w`mfo|IU1^k7D-QznrzaapCVq?}JgZ>b2~JuKYI^U-0cn z@V!aLPWcBLTVJn#_g5 zZ+bm06&SUxWN%S85W9Bk$7GfV=D7|hwlaCGw=;KY;NYGzqas24_5@CFkqU(Abn?5Z?QzKDVJmSl(yY)b$M44v%)0DNy3jfj;{DEB5*HfLm#*1o=LBG z{`~n_@5sQc8zxod|1w_n{$J^7wQqNr+G}1+w)YD7{ohJ4ZVTg_zw%eaVt)9CK6qNq zvfxt^=X!QQOO=V@`@$j)%)P*Q<*l~Ff!p`4Y6u3tF?{xKZ{*6L)646>{@K5V@nZ5t zrFEe@1e3KM&1lq1zVZF%?RVW8QpH>m=3FL%bC~KDK6<}_aev9b`xQ)vxeooi*4)?; zsNr=YLfouO;oU(Ig+uuQ*A;h!YIs;FOkv~i{Jr(_|2DQen;lB{tQ7M?RG(}%(=&ba zZ^ePY-!o;8aJ&;YF;%sf2_PykMyT( zOYmoRNs_33<-K|SH&d~P(ySM1PH2R7boLZqpIuTqN%OUd)I9a4#r^O19lGmSwQ#y} z2=mY0&;Q#PDqc@#TbOh!Cc>iCuc}GxXxoKt(|I>=yp#XXaNt{fhJg63vYHc3f7BRz zp2n{VkKLpAFhTOdz4N!K6;9mlx@;PCcUSzJiSJ~^|MK77T=)FPe$57LmKT35toGRM z2&($Y};s{;CS&x($+ImJACHe zHkZ1z!Ql5^xvBq{`5tWNdf=}aZmKRY%t}sS=+wEmzn>{EV3GV3ojbA%Zp{3~&-vh~?THsc3)lo_#?@b9 zJ=L4~{c%Rw67|4_|NEw$J3e3Le?P0hck3M|l8Vh9ypVa3^ipo(g~UBxXYTZex!igA zW&Yd)`=7nrDEc=`q~oN-Ja2pU@@aKtcg(e3Dc@hY=fD5?|EB&5pFUKbb(cNF;97Tl z&zT#^#&;atKE5fAk71s_JF&e!is2x$;?i@6wf=Q&C&t&i=`s=xbke+2Wf;sv#7;$BXBOCr@D+FrCU z5o_{TJNf;o*ZU(FOxU;ocCU6TI@uVo=&rVbroo}CfQNm-oj+c^{>8?t;Kjnr_Nqux zqxdl|$6MyQ*eQOmum59aTHyNV>qW83*nj(4qpYmWvzm%OJm~$=cDa5s!xKK1CBn)= z2i|qfG}tx!^wG>`N2lBWc`we8di=bjALol7Xz+hpt@~$xG{gT% b^8eXyONlr0HB~$X?RD{V^>bP0l+XkK3f!mG literal 0 HcmV?d00001 From 86f38475b0e36073c1963fae1cc4d51b8a581f64 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 27 Apr 2016 02:10:42 +0200 Subject: [PATCH 0528/1509] - shaders for last commit. --- wadsrc/static/shaders/glsl/main.vp | 20 +++++++++++--------- wadsrc/static/shaders/glsl/shaderdefs.i | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index cea479f3b..44aec6199 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -50,16 +50,18 @@ void main() gl_Position = ProjectionMatrix * eyeCoordPos; - // clip planes used for reflective flats - if (uClipHeightBottom > -65536.0) - { - gl_ClipDistance[0] = worldcoord.y - uClipHeightBottom; - } - else if (uClipHeightTop < 65536.0) - { - gl_ClipDistance[0] = uClipHeightTop - worldcoord.y; - } + #if defined __GLSL_CG_DATA_TYPES && defined GLSL12_COMPATIBILE + gl_ClipVertex = eyeCoordPos; + #endif + + // clip planes used for reflective flats + if (uClipHeightDirection != 0.0) + { + gl_ClipDistance[0] = (worldcoord.y - uClipHeight) * uClipHeightDirection; + } + + // clip planes used for translucency splitting gl_ClipDistance[1] = worldcoord.y - uClipSplit.x; gl_ClipDistance[2] = uClipSplit.y - worldcoord.y; diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index d49034973..5259bb5fd 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -6,7 +6,7 @@ precision highp float; uniform vec4 uCameraPos; uniform int uTextureMode; -uniform float uClipHeightTop, uClipHeightBottom; +uniform float uClipHeight, uClipHeightDirection; uniform vec2 uClipSplit; uniform float uAlphaThreshold; From 73823e6a095207a2a3ab91751ec58ab5be1b3e8e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 27 Apr 2016 02:56:55 +0200 Subject: [PATCH 0529/1509] - fixed the texture size checks for determining if a camera texture requires offscreen rendering were wrong and checked the scaled size, not the physical size. --- src/gl/scene/gl_scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 8a7a882bc..a4d440abb 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -1138,7 +1138,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in gl_fixedcolormap=CM_DEFAULT; gl_RenderState.SetFixedColormap(CM_DEFAULT); - bool usefb = gl_usefb || width > screen->GetWidth() || height > screen->GetHeight(); + bool usefb = gl_usefb || gltex->GetWidth() > screen->GetWidth() || gltex->GetHeight() > screen->GetHeight(); if (!usefb) { glFlush(); From 3be33b5725a822c2c1ffed2826cc399ca6a8ef7e Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Mon, 25 Apr 2016 14:12:16 -0500 Subject: [PATCH 0530/1509] The GL part of Quake Rolls. --- src/gl/scene/gl_scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index a4d440abb..658a816a5 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -799,7 +799,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo double alen = sqrt(angx*angx + angy*angy); mAngles.Pitch = (float)RAD2DEG(asin(angy / alen)); - mAngles.Roll.Degrees = camera->Angles.Roll.Degrees; + mAngles.Roll.Degrees = ViewRoll.Degrees; // Scroll the sky mSky1Pos = (float)fmod(gl_frameMS * level.skyspeed1, 1024.f) * 90.f/256.f; From ee7a4daa8c3548931e43061f1f68e4fe272968e0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 27 Apr 2016 23:19:54 +0200 Subject: [PATCH 0531/1509] - preparations for textured dynamic lights. --- src/gl/scene/gl_drawinfo.cpp | 25 +++++++++++++++++++------ src/gl/scene/gl_drawinfo.h | 29 +++++++++++++++++++++++++++++ src/win32/win32gliface.cpp | 4 +++- 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 386dc6a4a..a444dbe62 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -991,10 +991,15 @@ static FDrawInfoList di_list; FDrawInfo::FDrawInfo() { next = NULL; + if (gl.lightmethod == LM_SOFTWARE) + { + dldrawlists = new GLDrawList[GLLDL_TYPES]; + } } FDrawInfo::~FDrawInfo() { + if (dldrawlists != NULL) delete[] dldrawlists; ClearBuffers(); } @@ -1018,13 +1023,17 @@ void FDrawInfo::StartScene() ss_renderflags.Resize(numsubsectors); no_renderflags.Resize(numsubsectors); - memset(§orrenderflags[0], 0, numsectors*sizeof(sectorrenderflags[0])); - memset(&ss_renderflags[0], 0, numsubsectors*sizeof(ss_renderflags[0])); - memset(&no_renderflags[0], 0, numnodes*sizeof(no_renderflags[0])); + memset(§orrenderflags[0], 0, numsectors * sizeof(sectorrenderflags[0])); + memset(&ss_renderflags[0], 0, numsubsectors * sizeof(ss_renderflags[0])); + memset(&no_renderflags[0], 0, numnodes * sizeof(no_renderflags[0])); - next=gl_drawinfo; - gl_drawinfo=this; - for(int i=0;idrawlists[i].Reset(); + if (di->dldrawlists != NULL) + { + for (int i = 0; i < GLLDL_TYPES; i++) di->dldrawlists[i].Reset(); + } gl_drawinfo=di->next; di_list.Release(di); } diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index 8cb6a412a..1eb4882ef 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -25,6 +25,28 @@ enum DrawListType GLDL_TYPES, }; +// more lists for handling of dynamic lights +enum DLDrawListType +{ + // These are organized so that the various multipass rendering modes have to be set as few times as possible + GLLDL_WALLS_PLAIN, // dynamic lights on normal walls + GLLDL_WALLS_BRIGHT, // dynamic lights on brightmapped walls + GLLDL_WALLS_MASKED, // dynamic lights on masked midtextures + + GLLDL_FLATS_PLAIN, // dynamic lights on normal flats + GLLDL_FLATS_BRIGHT, // dynamic lights on brightmapped flats + GLLDL_FLATS_MASKED, // dynamic lights on masked flats + + GLLDL_WALLS_FOG, // lights on fogged walls + GLLDL_WALLS_FOGMASKED, // lights on fogged masked midtextures + + GLLDL_FLATS_FOG, // lights on fogged walls + GLLDL_FLATS_FOGMASKED, // lights on fogged masked midtextures + + GLLDL_TYPES, +}; + + enum Drawpasses { GLPASS_ALL, // Main pass with dynamic lights @@ -32,6 +54,12 @@ enum Drawpasses GLPASS_PLAIN, // Main pass without dynamic lights GLPASS_DECALS, // Draws a decal GLPASS_TRANSLUCENT, // Draws translucent objects + + // these are only used with texture based dynamic lights + GLPASS_BASE, // untextured base for dynamic lights + GLPASS_LIGHTTEX, // lighttexture pass + GLPASS_TEXONLY // finishing texture pass + }; //========================================================================== @@ -199,6 +227,7 @@ struct FDrawInfo FDrawInfo * next; GLDrawList drawlists[GLDL_TYPES]; + GLDrawList *dldrawlists; // only gets allocated when needed. FDrawInfo(); ~FDrawInfo(); diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 76099babb..625bda2a7 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -804,6 +804,8 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) 0 }; + //Printf("Trying to create an OpenGL %d.%d %s profile context\n", versions[i] / 10, versions[i] % 10, prof == WGL_CONTEXT_CORE_PROFILE_BIT_ARB ? "Core" : "Compatibility"); + m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); if (m_hRC != NULL) break; } @@ -832,7 +834,7 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) } } // We get here if the driver doesn't support the modern context creation API which always means an old driver. - I_Error ("R_OPENGL: Unable to create an OpenGL render context.\n"); + I_Error ("R_OPENGL: Unable to create an OpenGL render context. Insufficient driver support for context creation\n"); return false; } From d4806f82cafa8c2aae27aa84dab310866c26abbb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 28 Apr 2016 00:58:44 +0200 Subject: [PATCH 0532/1509] - reinstated some texturing-based dynamic light code. Not active yet and not tested yet. --- src/gl/compatibility/gl_20.cpp | 200 ++++++++++++++++++++++++++++++ src/gl/dynlights/gl_dynlight1.cpp | 92 -------------- src/gl/renderer/gl_renderer.h | 1 + src/gl/scene/gl_drawinfo.h | 4 +- src/gl/scene/gl_scene.cpp | 6 +- src/win32/win32gliface.cpp | 9 +- 6 files changed, 214 insertions(+), 98 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 5498c0b0a..280affa1a 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -45,10 +45,19 @@ #include "i_system.h" #include "v_text.h" #include "r_utility.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/utility/gl_geometric.h" +#include "gl/renderer/gl_renderer.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_renderstate.h" +#include "gl/scene/gl_drawinfo.h" +//========================================================================== +// +// +// +//========================================================================== void gl_SetTextureMode(int type) { @@ -190,6 +199,11 @@ BYTE *gl_WarpBuffer(BYTE *buffer, int Width, int Height, int warp, float Speed) return (BYTE*)out; } +//========================================================================== +// +// +// +//========================================================================== static int ffTextureMode; static bool ffTextureEnabled; @@ -322,6 +336,12 @@ void FRenderState::ApplyFixedFunction() } +//========================================================================== +// +// +// +//========================================================================== + void gl_FillScreen(); void FRenderState::DrawColormapOverlay() @@ -375,4 +395,184 @@ void FRenderState::DrawColormapOverlay() gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); gl_FillScreen(); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} + +//========================================================================== +// +// Sets up the parameters to render one dynamic light onto one plane +// +//========================================================================== +bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, + float & scale, int desaturation, bool checkside, bool forceadditive) +{ + Vector fn, pos; + + DVector3 lpos = light->PosRelative(group); + + float dist = fabsf(p.DistToPoint(lpos.X, lpos.Z, lpos.Y)); + float radius = (light->GetRadius() * gl_lights_size); + + if (radius <= 0.f) return false; + if (dist > radius) return false; + if (checkside && gl_lights_checkside && p.PointOnSide(lpos.X, lpos.Z, lpos.Y)) + { + return false; + } + if (light->owned && light->target != NULL && !light->target->IsVisibleToPlayer()) + { + return false; + } + + scale = 1.0f / ((2.f * radius) - dist); + + // project light position onto plane (find closest point on plane) + + + pos.Set(lpos.X, lpos.Z, lpos.Y); + fn = p.Normal(); + fn.GetRightUp(right, up); + +#ifdef _MSC_VER + nearPt = pos + fn * dist; +#else + Vector tmpVec = fn * dist; + nearPt = pos + tmpVec; +#endif + + float cs = 1.0f - (dist / radius); + if (gl_lights_additive || light->flags4&MF4_ADDITIVE || forceadditive) cs *= 0.2f; // otherwise the light gets too strong. + float r = light->GetRed() / 255.0f * cs * gl_lights_intensity; + float g = light->GetGreen() / 255.0f * cs * gl_lights_intensity; + float b = light->GetBlue() / 255.0f * cs * gl_lights_intensity; + + if (light->IsSubtractive()) + { + Vector v; + + gl_RenderState.BlendEquation(GL_FUNC_REVERSE_SUBTRACT); + v.Set(r, g, b); + r = v.Length() - r; + g = v.Length() - g; + b = v.Length() - b; + } + else + { + gl_RenderState.BlendEquation(GL_FUNC_ADD); + } + if (desaturation > 0 && gl.glslversion > 0) // no-shader excluded because no desaturated textures. + { + float gray = (r * 77 + g * 143 + b * 37) / 257; + + r = (r*(32 - desaturation) + gray*desaturation) / 32; + g = (g*(32 - desaturation) + gray*desaturation) / 32; + b = (b*(32 - desaturation) + gray*desaturation) / 32; + } + glColor3f(r, g, b); + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool gl_SetupLightTexture() +{ + if (GLRenderer->gllight == NULL) return false; + FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight, false); + pat->Bind(CLAMP_XY, 0); + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + +void FGLRenderer::RenderMultipassStuff() +{ + return; + // First pass: empty background with sector light only + + // Part 1: solid geometry. This is set up so that there are no transparent parts + + // remove any remaining texture bindings and shaders whick may get in the way. + gl_RenderState.EnableTexture(false); + gl_RenderState.EnableBrightmap(false); + gl_RenderState.Apply(); + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_BASE); + gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_BASE); + + // Part 2: masked geometry. This is set up so that only pixels with alpha>0.5 will show + // This creates a blank surface that only fills the nontransparent parts of the texture + gl_RenderState.EnableTexture(true); + gl_RenderState.SetTextureMode(TM_MASK); + gl_RenderState.EnableBrightmap(true); + gl_drawinfo->dldrawlists[GLLDL_WALLS_BRIGHT].DrawWalls(GLPASS_BASE_MASKED); + gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_BASE_MASKED); + gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_BASE_MASKED); + gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_BASE_MASKED); + + // Part 3: The base of fogged surfaces, including the texture + gl_RenderState.EnableBrightmap(false); + gl_RenderState.SetTextureMode(TM_MODULATE); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(GLPASS_PLAIN); + + // second pass: draw lights + glDepthMask(false); + if (mLightCount && !gl_fixedcolormap) + { + if (gl_SetupLightTexture()) + { + gl_RenderState.BlendFunc(GL_ONE, GL_ONE); + glDepthFunc(GL_EQUAL); + if (glset.lightmode == 8) gl_RenderState.SetSoftLightLevel(255); + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_LIGHTTEX); + gl_drawinfo->dldrawlists[GLLDL_WALLS_BRIGHT].DrawWalls(GLPASS_LIGHTTEX); + gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_LIGHTTEX); + gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX); + gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_LIGHTTEX); + gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_LIGHTTEX); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + } + else gl_lights = false; + } + + // third pass: modulated texture + gl_RenderState.SetColor(0xffffffff); + gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); + gl_RenderState.EnableFog(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0); + glDepthFunc(GL_LEQUAL); + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_TEXONLY); + gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_TEXONLY); + gl_drawinfo->dldrawlists[GLLDL_WALLS_BRIGHT].DrawWalls(GLPASS_TEXONLY); + gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_TEXONLY); + gl_RenderState.AlphaFunc(GL_GREATER, gl_mask_threshold); + gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_TEXONLY); + gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_TEXONLY); + + // fourth pass: additive lights + gl_RenderState.EnableFog(true); + gl_RenderState.BlendFunc(GL_ONE, GL_ONE); + glDepthFunc(GL_EQUAL); + if (gl_SetupLightTexture()) + { + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_WALLS_BRIGHT].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); + } + else gl_lights = false; } \ No newline at end of file diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index b8fbfc24a..361b94618 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -140,95 +140,3 @@ bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, bo return true; } - - - -//========================================================================== -// -// Sets up the parameters to render one dynamic light onto one plane -// -//========================================================================== -bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, - float & scale, int desaturation, bool checkside, bool forceadditive) -{ - Vector fn, pos; - - DVector3 lpos = light->PosRelative(group); - - float dist = fabsf(p.DistToPoint(lpos.X, lpos.Z, lpos.Y)); - float radius = (light->GetRadius() * gl_lights_size); - - if (radius <= 0.f) return false; - if (dist > radius) return false; - if (checkside && gl_lights_checkside && p.PointOnSide(lpos.X, lpos.Z, lpos.Y)) - { - return false; - } - if (light->owned && light->target != NULL && !light->target->IsVisibleToPlayer()) - { - return false; - } - - scale = 1.0f / ((2.f * radius) - dist); - - // project light position onto plane (find closest point on plane) - - - pos.Set(lpos.X, lpos.Z, lpos.Y); - fn = p.Normal(); - fn.GetRightUp(right, up); - -#ifdef _MSC_VER - nearPt = pos + fn * dist; -#else - Vector tmpVec = fn * dist; - nearPt = pos + tmpVec; -#endif - - float cs = 1.0f - (dist / radius); - if (gl_lights_additive || light->flags4&MF4_ADDITIVE || forceadditive) cs *= 0.2f; // otherwise the light gets too strong. - float r = light->GetRed() / 255.0f * cs * gl_lights_intensity; - float g = light->GetGreen() / 255.0f * cs * gl_lights_intensity; - float b = light->GetBlue() / 255.0f * cs * gl_lights_intensity; - - if (light->IsSubtractive()) - { - Vector v; - - gl_RenderState.BlendEquation(GL_FUNC_REVERSE_SUBTRACT); - v.Set(r, g, b); - r = v.Length() - r; - g = v.Length() - g; - b = v.Length() - b; - } - else - { - gl_RenderState.BlendEquation(GL_FUNC_ADD); - } - if (desaturation > 0 && gl.glslversion > 0) // no-shader excluded because no desaturated textures. - { - float gray = (r * 77 + g * 143 + b * 37) / 257; - - r = (r*(32 - desaturation) + gray*desaturation) / 32; - g = (g*(32 - desaturation) + gray*desaturation) / 32; - b = (b*(32 - desaturation) + gray*desaturation) / 32; - } - glColor3f(r, g, b); - return true; -} - - -//========================================================================== -// -// -// -//========================================================================== - -bool gl_SetupLightTexture() -{ - - if (GLRenderer->gllight == NULL) return false; - FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight, true); - pat->Bind(CLAMP_XY, 0); - return true; -} diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index cc5aa9d53..d09ac1948 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -101,6 +101,7 @@ public: void Initialize(); void CreateScene(); + void RenderMultipassStuff(); void RenderScene(int recursion); void RenderTranslucent(); void DrawScene(bool toscreen = false); diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index 1eb4882ef..9745ade88 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -57,8 +57,10 @@ enum Drawpasses // these are only used with texture based dynamic lights GLPASS_BASE, // untextured base for dynamic lights + GLPASS_BASE_MASKED, // same but with active texture GLPASS_LIGHTTEX, // lighttexture pass - GLPASS_TEXONLY // finishing texture pass + GLPASS_TEXONLY, // finishing texture pass + GLPASS_LIGHTTEX_ADDITIVE, // lighttexture pass (additive) }; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 658a816a5..a745f7307 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -382,10 +382,10 @@ void FGLRenderer::RenderScene(int recursion) } else { - // Todo: Draw lights with multipass rendering. - // RenderMultpassStuff(); + // process everything that needs to handle textured dynamic lights. + if (haslights) RenderMultipassStuff(); - // The remaining stuff which is unaffected by dynamic lights is just processed as normal. + // The remaining lists which are unaffected by dynamic lights are just processed as normal. pass = GLPASS_PLAIN; } diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 625bda2a7..11c359a32 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -813,8 +813,13 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) if (m_hRC == NULL && prof == WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) { - I_Error ("R_OPENGL: Unable to create an OpenGL render context.\n"); - return false; + + m_hRC = wglCreateContext(m_hDC); + if (m_hRC == NULL) + { + I_Error("R_OPENGL: Unable to create an OpenGL render context.\n"); + return false; + } } if (m_hRC != NULL) From 434e39e62fb0d9f912e3bd4f023fbb4c92727f38 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 28 Apr 2016 17:55:58 +0200 Subject: [PATCH 0533/1509] - made adjustments to ZDoom's last changes. --- src/gl/compatibility/gl_20.cpp | 8 +++++++- src/gl/data/gl_data.cpp | 4 ++-- src/gl/models/gl_models_md2.cpp | 4 ++-- src/gl/models/gl_models_md3.cpp | 4 ++-- src/gl/scene/gl_clipper.h | 1 - src/gl/scene/gl_drawinfo.h | 2 +- src/gl/scene/gl_scene.cpp | 6 +++--- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 280affa1a..b06ce762b 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -143,12 +143,15 @@ BYTE *gl_WarpBuffer(BYTE *buffer, int Width, int Height, int warp, float Speed) int xmask = xsize - 1; int ymask = ysize - 1; int ds_xbits; - int i, x; + int i; if (warp == 1) { for (ds_xbits = -1, i = Width; i; i >>= 1, ds_xbits++); + // pending consolidation with the software renderer's code. + + /* for (x = xsize - 1; x >= 0; x--) { int yt, yf = (finesine[(timebase + (x + 17) * 128)&FINEMASK] >> 13) & ymask; @@ -172,12 +175,14 @@ BYTE *gl_WarpBuffer(BYTE *buffer, int Width, int Height, int warp, float Speed) } memcpy(out + y*xsize, linebuffer, xsize * sizeof(DWORD)); } + */ } else { int ybits; for (ybits = -1, i = ysize; i; i >>= 1, ybits++); + /* DWORD timebase = (r_FrameTime * Speed * 40 / 28); for (x = xsize - 1; x >= 0; x--) { @@ -194,6 +199,7 @@ BYTE *gl_WarpBuffer(BYTE *buffer, int Width, int Height, int warp, float Speed) *dest = *source; } } + */ } delete[] buffer; return (BYTE*)out; diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index ba6105d5a..2aea2b8a3 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -431,11 +431,11 @@ FTextureID gl_GetSpriteFrame(unsigned sprite, int frame, int rot, angle_t ang, b { if (sprframe->Texture[0] == sprframe->Texture[1]) { - rot = (ang + (angle_t)(ANGLE_45/2)*9) >> 28; + rot = (ang + (angle_t)(ANGLE_90/4)*9) >> 28; } else { - rot = (ang + (angle_t)(ANGLE_45/2)*9-(angle_t)(ANGLE_180/16)) >> 28; + rot = (ang + (angle_t)(ANGLE_90/4)*9-(angle_t)(ANGLE_180/16)) >> 28; } } if (mirror) *mirror = !!(sprframe->Flip&(1<> 9) / 127.0f - 0.5f) * PI; + float yaw = (packed & 511) / 512.0f * 2 * M_PI; + float pitch = ((packed >> 9) / 127.0f - 0.5f) * M_PI; float cosp = (float) cos(pitch); vec[VX] = (float) cos(yaw) * cosp; diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index 13f02bc0a..7e8a4845e 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -60,8 +60,8 @@ static void UnpackVector(unsigned short packed, float & nx, float & ny, float & { double lat = ( packed >> 8 ) & 0xff; double lng = ( packed & 0xff ); - lat *= PI/128; - lng *= PI/128; + lat *= M_PI/128; + lng *= M_PI/128; nx = cos(lat) * sin(lng); ny = sin(lat) * sin(lng); diff --git a/src/gl/scene/gl_clipper.h b/src/gl/scene/gl_clipper.h index 7d05cf701..977107e61 100644 --- a/src/gl/scene/gl_clipper.h +++ b/src/gl/scene/gl_clipper.h @@ -2,7 +2,6 @@ #define __GL_CLIPPER #include "doomtype.h" -#include "tables.h" #include "xs_Float.h" #include "r_utility.h" diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index 9745ade88..744ffeef4 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -229,7 +229,7 @@ struct FDrawInfo FDrawInfo * next; GLDrawList drawlists[GLDL_TYPES]; - GLDrawList *dldrawlists; // only gets allocated when needed. + GLDrawList *dldrawlists = NULL; // only gets allocated when needed. FDrawInfo(); ~FDrawInfo(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index a745f7307..f09343f44 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -793,7 +793,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo SetViewArea(); // We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1. - double radPitch = clamp(ViewPitch.Normalized180().Radians(), -PI / 2, PI / 2); + double radPitch = ViewPitch.Normalized180().Radians(); double angx = cos(radPitch); double angy = sin(radPitch) * glset.pixelstretch; double alen = sqrt(angx*angx + angy*angy); @@ -922,7 +922,7 @@ void FGLRenderer::RenderView (player_t* player) TThinkerIterator it(STAT_DLIGHT); GLRenderer->mLightCount = ((it.Next()) != NULL); - sector_t * viewsector = RenderViewpoint(player->camera, NULL, FieldOfView * 360.0f / FINEANGLES, ratio, fovratio, true, true); + sector_t * viewsector = RenderViewpoint(player->camera, NULL, FieldOfView.Degrees, ratio, fovratio, true, true); All.Unclock(); } @@ -952,7 +952,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei GLRenderer->mLightCount = ((it.Next()) != NULL); sector_t *viewsector = RenderViewpoint(players[consoleplayer].camera, &bounds, - FieldOfView * 360.0f / FINEANGLES, 1.6f, 1.6f, true, false); + FieldOfView.Degrees, 1.6f, 1.6f, true, false); glDisable(GL_STENCIL_TEST); gl_RenderState.SetFixedColormap(CM_DEFAULT); gl_RenderState.SetSoftLightLevel(-1); From e3fad118d2722072b323db92533bd2faef3ae8b6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 28 Apr 2016 19:04:01 +0200 Subject: [PATCH 0534/1509] - use the templated warp functions instead of the limited GZDoom 1.x version. gl_WarpBuffer has been removed. --- src/gl/compatibility/gl_20.cpp | 82 --------------------------------- src/gl/textures/gl_material.cpp | 17 +++++-- src/textures/textures.h | 4 +- 3 files changed, 14 insertions(+), 89 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index b06ce762b..d0de0589c 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -123,88 +123,6 @@ void gl_SetTextureMode(int type) } } -//=========================================================================== -// -// FGLTex::WarpBuffer -// -//=========================================================================== - -BYTE *gl_WarpBuffer(BYTE *buffer, int Width, int Height, int warp, float Speed) -{ - if (Width > 256 || Height > 256) return buffer; - - DWORD *in = (DWORD*)buffer; - DWORD *out = (DWORD*)new BYTE[4 * Width*Height]; - - static DWORD linebuffer[256]; // anything larger will bring down performance so it is excluded above. - DWORD timebase = DWORD(r_FrameTime*Speed * 23 / 28); - int xsize = Width; - int ysize = Height; - int xmask = xsize - 1; - int ymask = ysize - 1; - int ds_xbits; - int i; - - if (warp == 1) - { - for (ds_xbits = -1, i = Width; i; i >>= 1, ds_xbits++); - - // pending consolidation with the software renderer's code. - - /* - for (x = xsize - 1; x >= 0; x--) - { - int yt, yf = (finesine[(timebase + (x + 17) * 128)&FINEMASK] >> 13) & ymask; - const DWORD *source = in + x; - DWORD *dest = out + x; - for (yt = ysize; yt; yt--, yf = (yf + 1)&ymask, dest += xsize) - { - *dest = *(source + (yf << ds_xbits)); - } - } - timebase = DWORD(r_FrameTime*Speed * 32 / 28); - int y; - for (y = ysize - 1; y >= 0; y--) - { - int xt, xf = (finesine[(timebase + y * 128)&FINEMASK] >> 13) & xmask; - DWORD *source = out + (y << ds_xbits); - DWORD *dest = linebuffer; - for (xt = xsize; xt; xt--, xf = (xf + 1)&xmask) - { - *dest++ = *(source + xf); - } - memcpy(out + y*xsize, linebuffer, xsize * sizeof(DWORD)); - } - */ - } - else - { - int ybits; - for (ybits = -1, i = ysize; i; i >>= 1, ybits++); - - /* - DWORD timebase = (r_FrameTime * Speed * 40 / 28); - for (x = xsize - 1; x >= 0; x--) - { - for (int y = ysize - 1; y >= 0; y--) - { - int xt = (x + 128 - + ((finesine[(y * 128 + timebase * 5 + 900) & 8191] * 2) >> FRACBITS) - + ((finesine[(x * 256 + timebase * 4 + 300) & 8191] * 2) >> FRACBITS)) & xmask; - int yt = (y + 128 - + ((finesine[(y * 128 + timebase * 3 + 700) & 8191] * 2) >> FRACBITS) - + ((finesine[(x * 256 + timebase * 4 + 1200) & 8191] * 2) >> FRACBITS)) & ymask; - const DWORD *source = in + (xt << ybits) + yt; - DWORD *dest = out + (x << ybits) + y; - *dest = *source; - } - } - */ - } - delete[] buffer; - return (BYTE*)out; -} - //========================================================================== // // diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index f3743bd3a..a900a1e45 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -47,6 +47,7 @@ #include "templates.h" #include "sc_man.h" #include "colormatcher.h" +#include "textures/warpbuffer.h" //#include "gl/gl_intern.h" @@ -72,7 +73,6 @@ EXTERN_CVAR(Bool, gl_texture_usehires) // The GL texture maintenance class // //=========================================================================== -BYTE *gl_WarpBuffer(BYTE *buffer, int Width, int Height, int warp, float Speed); //=========================================================================== // @@ -310,11 +310,18 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla if (!tex->bHasCanvas) { buffer = CreateTexBuffer(translation, w, h, hirescheck, true, alphatrans); - if (tex->bWarped && gl.glslversion == 0) + if (tex->bWarped && gl.glslversion == 0 && w*h <= 256*256) // do not software-warp larger textures, especially on the old systems that still need this fallback. { - // need to warp - buffer = gl_WarpBuffer(buffer, w, h, tex->bWarped, static_cast(tex)->GetSpeed()); - static_cast(tex)->GenTime = r_FrameTime; + // need to do software warping + FWarpTexture *wt = static_cast(tex); + unsigned char *warpbuffer = new unsigned char[w*h*4]; + if (tex->bWarped != 2) + WarpBufferType1((DWORD*)warpbuffer, (const DWORD*)buffer, w, h, wt->WidthOffsetMultiplier, wt->HeightOffsetMultiplier, r_FrameTime, wt->Speed); + else + WarpBufferType2((DWORD*)warpbuffer, (const DWORD*)buffer, w, h, wt->WidthOffsetMultiplier, wt->HeightOffsetMultiplier, r_FrameTime, wt->Speed); + delete[] buffer; + buffer = warpbuffer; + wt->GenTime = r_FrameTime; } tex->ProcessData(buffer, w, h, false); } diff --git a/src/textures/textures.h b/src/textures/textures.h index 778b955d4..4aa30605f 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -555,12 +555,12 @@ public: FTexture *GetRedirect(bool wantwarped); DWORD GenTime; + float Speed; + int WidthOffsetMultiplier, HeightOffsetMultiplier; // [mxd] protected: FTexture *SourcePic; BYTE *Pixels; Span **Spans; - float Speed; - int WidthOffsetMultiplier, HeightOffsetMultiplier; // [mxd] virtual void MakeTexture (DWORD time); int NextPo2 (int v); // [mxd] From 21283b18f447dc3ee5ff85a1a14db1302a7af2b7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 29 Apr 2016 01:48:06 +0200 Subject: [PATCH 0535/1509] - preparations for using clip planes on line portals. --- src/gl/renderer/gl_renderer.cpp | 1 + src/gl/renderer/gl_renderer.h | 1 + src/gl/renderer/gl_renderstate.cpp | 16 +++- src/gl/renderer/gl_renderstate.h | 33 ++++++++ src/gl/scene/gl_bsp.cpp | 14 ++-- src/gl/scene/gl_portal.cpp | 102 +++++++++++++----------- src/gl/scene/gl_portal.h | 7 +- src/gl/scene/gl_scene.cpp | 2 +- src/gl/scene/gl_sprite.cpp | 8 +- src/gl/shaders/gl_shader.cpp | 1 + src/gl/shaders/gl_shader.h | 17 ++-- wadsrc/static/shaders/glsl/shaderdefs.i | 1 + 12 files changed, 133 insertions(+), 70 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index cca2e9b2b..e3b9b0a8b 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -84,6 +84,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) { framebuffer = fb; + mClipPortal = NULL; mCurrentPortal = NULL; mMirrorCount = 0; mPlaneMirrorCount = 0; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index d09ac1948..52ce5b2fa 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -59,6 +59,7 @@ class FGLRenderer public: OpenGLFrameBuffer *framebuffer; + GLPortal *mClipPortal; GLPortal *mCurrentPortal; int mMirrorCount; int mPlaneMirrorCount; diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index fdb0e3cc5..15a575e79 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -69,7 +69,7 @@ TArray gl_MatrixStack; void FRenderState::Reset() { mTextureEnabled = true; - mSplitEnabled = mBrightmapEnabled = mFogEnabled = mGlowEnabled = false; + mClipLineEnabled = mSplitEnabled = mBrightmapEnabled = mFogEnabled = mGlowEnabled = false; mColorMask[0] = mColorMask[1] = mColorMask[2] = mColorMask[3] = true; currentColorMask[0] = currentColorMask[1] = currentColorMask[2] = currentColorMask[3] = true; mFogColor.d = -1; @@ -171,10 +171,22 @@ bool FRenderState::ApplyShader() activeShader->muSplitBottomPlane.Set(mSplitBottomPlane.vec); activeShader->currentsplitstate = 1; } - else + else if (activeShader->currentsplitstate) { activeShader->muSplitTopPlane.Set(nulvec); activeShader->muSplitBottomPlane.Set(nulvec); + activeShader->currentsplitstate = 0; + } + + if (mClipLineEnabled) + { + activeShader->muClipLine.Set(mClipLine.vec); + activeShader->currentcliplinestate = 1; + } + else if (activeShader->currentcliplinestate) + { + activeShader->muClipLine.Set(-10000000.0, 0, 0, 0); + activeShader->currentcliplinestate = 0; } if (mColormapState != activeShader->currentfixedcolormap) diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index ca240c398..829edeec0 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -47,6 +47,7 @@ class FRenderState bool mFogEnabled; bool mGlowEnabled; bool mSplitEnabled; + bool mClipLineEnabled; bool mBrightmapEnabled; bool mColorMask[4]; bool currentColorMask[4]; @@ -73,6 +74,7 @@ class FRenderState FStateVec4 mGlowTop, mGlowBottom; FStateVec4 mGlowTopPlane, mGlowBottomPlane; FStateVec4 mSplitTopPlane, mSplitBottomPlane; + FStateVec4 mClipLine; PalEntry mFogColor; PalEntry mObjectColor; FStateVec4 mDynColor; @@ -145,6 +147,16 @@ public: return mClipHeightDirection; } + FStateVec4 &GetClipLine() + { + return mClipLine; + } + + bool GetClipLineState() + { + return mClipLineEnabled; + } + void SetClipHeight(float height, float direction); void SetColor(float r, float g, float b, float a = 1.f, int desat = 0) @@ -241,6 +253,27 @@ public: } } + void SetClipLine(line_t *line) + { + mClipLine.Set(line->v1->fX(), line->v1->fY(), line->Delta().X, line->Delta().Y); + } + + void EnableClipLine(bool on) + { + if (gl.glslversion >= 1.3f) + { + mClipLineEnabled = on; + if (on) + { + glEnable(GL_CLIP_DISTANCE0); + } + else + { + glDisable(GL_CLIP_DISTANCE0); + } + } + } + void SetLightIndex(int n) { mLightIndex = n; diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index 98053784c..b9915dd72 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -111,7 +111,7 @@ static void AddLine (seg_t *seg, bool portalclip) if (portalclip) { - int clipres = GLRenderer->mCurrentPortal->ClipSeg(seg); + int clipres = GLRenderer->mClipPortal->ClipSeg(seg); if (clipres == GLPortal::PClip_InFront) return; } @@ -218,7 +218,7 @@ static void PolySubsector(subsector_t * sub) { if (line->linedef) { - AddLine (line, GLRenderer->mCurrentPortal != NULL); + AddLine (line, GLRenderer->mClipPortal != NULL); } line++; } @@ -313,11 +313,11 @@ static inline void AddLines(subsector_t * sub, sector_t * sector) { if (seg->linedef == NULL) { - if (!(sub->flags & SSECF_DRAWN)) AddLine (seg, GLRenderer->mCurrentPortal != NULL); + if (!(sub->flags & SSECF_DRAWN)) AddLine (seg, GLRenderer->mClipPortal != NULL); } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) { - AddLine (seg, GLRenderer->mCurrentPortal != NULL); + AddLine (seg, GLRenderer->mClipPortal != NULL); } seg++; } @@ -447,12 +447,12 @@ static void DoSubsector(subsector_t * sub) fakesector=gl_FakeFlat(sector, &fake, false); - if (GLRenderer->mCurrentPortal) + if (GLRenderer->mClipPortal) { - int clipres = GLRenderer->mCurrentPortal->ClipSubsector(sub); + int clipres = GLRenderer->mClipPortal->ClipSubsector(sub); if (clipres == GLPortal::PClip_InFront) { - line_t *line = GLRenderer->mCurrentPortal->ClipLine(); + line_t *line = GLRenderer->mClipPortal->ClipLine(); // The subsector is out of range, but we still have to check lines that lie directly on the boundary and may expose their upper or lower parts. if (line) AddSpecialPortalLines(sub, fakesector, line); return; diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 93f25f28e..f165de630 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -300,9 +300,6 @@ bool GLPortal::Start(bool usestencil, bool doquery) glDisable(GL_DEPTH_TEST); } } - planestack.Push(gl_RenderState.GetClipHeight()); - planestack.Push(gl_RenderState.GetClipHeightDirection()); - gl_RenderState.SetClipHeight(0., 0.); // save viewpoint savedViewPos = ViewPos; @@ -313,8 +310,12 @@ bool GLPortal::Start(bool usestencil, bool doquery) savedviewpath[0] = ViewPath[0]; savedviewpath[1] = ViewPath[1]; - NextPortal = GLRenderer->mCurrentPortal; - GLRenderer->mCurrentPortal = NULL; // Portals which need this have to set it themselves + PrevPortal = GLRenderer->mCurrentPortal; + PrevClipPortal = GLRenderer->mClipPortal; + GLRenderer->mClipPortal = NULL; // Portals which need this have to set it themselves + GLRenderer->mCurrentPortal = this; + + if (PrevPortal != NULL) PrevPortal->PushState(); PortalAll.Unclock(); return true; } @@ -359,12 +360,9 @@ void GLPortal::End(bool usestencil) bool needdepth = NeedDepthBuffer(); PortalAll.Clock(); - GLRenderer->mCurrentPortal = NextPortal; - - float f, d; - planestack.Pop(d); - planestack.Pop(f); - gl_RenderState.SetClipHeight(f, d); + if (PrevPortal != NULL) PrevPortal->PopState(); + GLRenderer->mCurrentPortal = PrevPortal; + GLRenderer->mClipPortal = PrevClipPortal; if (usestencil) { @@ -806,14 +804,59 @@ void GLPlaneMirrorPortal::DrawContents() PlaneMirrorMode=old_pm; } +void GLPlaneMirrorPortal::PushState() +{ + planestack.Push(gl_RenderState.GetClipHeight()); + planestack.Push(gl_RenderState.GetClipHeightDirection()); + gl_RenderState.SetClipHeight(0.f, 0.f); +} + +void GLPlaneMirrorPortal::PopState() +{ + float d, f; + planestack.Pop(d); + planestack.Pop(f); + gl_RenderState.SetClipHeight(f, d); +} + //----------------------------------------------------------------------------- // -// GLPlaneMirrorPortal::DrawContents +// Common code for line to line and mirror portals // //----------------------------------------------------------------------------- +int GLLinePortal::ClipSeg(seg_t *seg) +{ + line_t *linedef = seg->linedef; + if (!linedef) + { + return PClip_Inside; // should be handled properly. + } + return P_ClipLineToPortal(linedef, line(), ViewPos) ? PClip_InFront : PClip_Inside; +} + +int GLLinePortal::ClipSubsector(subsector_t *sub) +{ + // this seg is completely behind the mirror! + for(unsigned int i=0;inumlines;i++) + { + if (P_PointOnLineSidePrecise(sub->firstline[i].v1->fPos(), line()) == 0) return PClip_Inside; + } + return PClip_InFront; +} + +int GLLinePortal::ClipPoint(const DVector2 &pos) +{ + if (P_PointOnLineSidePrecise(pos, line())) + { + return PClip_InFront; + } + return PClip_Inside; +} + + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // @@ -837,7 +880,7 @@ void GLMirrorPortal::DrawContents() return; } - GLRenderer->mCurrentPortal = this; + GLRenderer->mClipPortal = this; DAngle StartAngle = ViewAngle; DVector3 StartPos = ViewPos; @@ -910,37 +953,6 @@ void GLMirrorPortal::DrawContents() MirrorFlag--; } - -int GLLinePortal::ClipSeg(seg_t *seg) -{ - line_t *linedef = seg->linedef; - if (!linedef) - { - return PClip_Inside; // should be handled properly. - } - return P_ClipLineToPortal(linedef, line(), ViewPos) ? PClip_InFront : PClip_Inside; -} - -int GLLinePortal::ClipSubsector(subsector_t *sub) -{ - // this seg is completely behind the mirror! - for(unsigned int i=0;inumlines;i++) - { - if (P_PointOnLineSidePrecise(sub->firstline[i].v1->fPos(), line()) == 0) return PClip_Inside; - } - return PClip_InFront; -} - -int GLLinePortal::ClipPoint(const DVector2 &pos) -{ - if (P_PointOnLineSidePrecise(pos, line())) - { - return PClip_InFront; - } - return PClip_Inside; -} - - //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // @@ -965,7 +977,7 @@ void GLLineToLinePortal::DrawContents() return; } - GLRenderer->mCurrentPortal = this; + GLRenderer->mClipPortal = this; line_t *origin = glport->reference->mOrigin; P_TranslatePortalXY(origin, ViewPos.X, ViewPos.Y); diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 8fe54c5b1..870009845 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -107,7 +107,8 @@ private: area_t savedviewarea; bool savedshowviewer; DVector3 savedviewpath[2]; - GLPortal *NextPortal; + GLPortal *PrevPortal; + GLPortal *PrevClipPortal; TArray savedmapsection; TArray mPrimIndices; @@ -130,6 +131,8 @@ protected: virtual const char *GetName() = 0; void SaveMapSection(); void RestoreMapSection(); + virtual void PushState() {} + virtual void PopState() {} public: @@ -341,6 +344,8 @@ protected: virtual void DrawContents(); virtual void * GetSource() const { return origin; } virtual const char *GetName(); + virtual void PushState(); + virtual void PopState(); secplane_t * origin; public: diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index f09343f44..1b6b8e87f 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -503,7 +503,7 @@ void FGLRenderer::DrawScene(bool toscreen) static int recursion=0; CreateScene(); - GLRenderer->mCurrentPortal = NULL; // this must be reset before any portal recursion takes place. + GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. // Up to this point in the main draw call no rendering is performed so we can wait // with swapping the render buffer until now. diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 942a2e555..63a4f9c8c 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -581,9 +581,9 @@ void GLSprite::Process(AActor* thing, sector_t * sector, bool thruportal) thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again. } - if (GLRenderer->mCurrentPortal) + if (GLRenderer->mClipPortal) { - int clipres = GLRenderer->mCurrentPortal->ClipPoint(thingpos); + int clipres = GLRenderer->mClipPortal->ClipPoint(thingpos); if (clipres == GLPortal::PClip_InFront) return; } @@ -894,9 +894,9 @@ void GLSprite::Process(AActor* thing, sector_t * sector, bool thruportal) void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int shade, int fakeside) { - if (GLRenderer->mCurrentPortal) + if (GLRenderer->mClipPortal) { - int clipres = GLRenderer->mCurrentPortal->ClipPoint(particle->Pos); + int clipres = GLRenderer->mClipPortal->ClipPoint(particle->Pos); if (clipres == GLPortal::PClip_InFront) return; } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index a86c57101..ea8f5aa92 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -278,6 +278,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muGlowTopPlane.Init(hShader, "uGlowTopPlane"); muSplitBottomPlane.Init(hShader, "uSplitBottomPlane"); muSplitTopPlane.Init(hShader, "uSplitTopPlane"); + muClipLine.Init(hShader, "uClipLine"); muFixedColormap.Init(hShader, "uFixedColormap"); muInterpolationFactor.Init(hShader, "uInterpolationFactor"); muClipHeight.Init(hShader, "uClipHeight"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index a7f7e4277..ca534c31d 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -220,6 +220,7 @@ class FShader FUniform4f muGlowTopPlane; FUniform4f muSplitBottomPlane; FUniform4f muSplitTopPlane; + FUniform4f muClipLine; FBufferedUniform1f muInterpolationFactor; FBufferedUniform1f muClipHeight; FBufferedUniform1f muClipHeightDirection; @@ -234,22 +235,18 @@ class FShader public: int fakevb_index; private: - int currentglowstate; - int currentsplitstate; - int currentfixedcolormap; - bool currentTextureMatrixState; - bool currentModelMatrixState; + int currentglowstate = 0; + int currentsplitstate = 0; + int currentcliplinestate = 0; + int currentfixedcolormap = 0; + bool currentTextureMatrixState = true;// by setting the matrix state to 'true' it is guaranteed to be set the first time the render state gets applied. + bool currentModelMatrixState = true; public: FShader(const char *name) : mName(name) { hShader = hVertProg = hFragProg = 0; - currentglowstate = 0; - currentsplitstate = 0; - currentfixedcolormap = 0; - currentTextureMatrixState = true; // by setting the matrix state to 'true' it is guaranteed to be set the first time the render state gets applied. - currentModelMatrixState = true; } ~FShader(); diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 5259bb5fd..7500a0cfc 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -8,6 +8,7 @@ uniform vec4 uCameraPos; uniform int uTextureMode; uniform float uClipHeight, uClipHeightDirection; uniform vec2 uClipSplit; +uniform vec4 uClipLine; uniform float uAlphaThreshold; From 70bf6493645b622c7994c83c743769ff4e09a0bf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 29 Apr 2016 12:26:57 +0200 Subject: [PATCH 0536/1509] - added clip planes for line portals and mirrors. This should eliminate the remaining problems with some visible geometry in front of the portal, it is also necessary to handle sprite splitting across line portals properly. --- src/gl/scene/gl_portal.cpp | 27 +++++++++++++++++++++++++++ src/gl/scene/gl_portal.h | 2 ++ wadsrc/static/shaders/glsl/main.vp | 8 ++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index f165de630..be25409e2 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -825,7 +825,28 @@ void GLPlaneMirrorPortal::PopState() // //----------------------------------------------------------------------------- +void GLLinePortal::PushState() +{ + FStateVec4 &v = gl_RenderState.GetClipLine(); + planestack.Push(v.vec[0]); + planestack.Push(v.vec[1]); + planestack.Push(v.vec[2]); + planestack.Push(v.vec[3]); + planestack.Push(gl_RenderState.GetClipLineState()); + gl_RenderState.EnableClipLine(false); +} +void GLLinePortal::PopState() +{ + FStateVec4 &v = gl_RenderState.GetClipLine(); + float e; + planestack.Pop(e); + planestack.Pop(v.vec[3]); + planestack.Pop(v.vec[2]); + planestack.Pop(v.vec[1]); + planestack.Pop(v.vec[0]); + gl_RenderState.EnableClipLine(e != 0); +} int GLLinePortal::ClipSeg(seg_t *seg) { @@ -948,7 +969,10 @@ void GLMirrorPortal::DrawContents() angle_t a1 = linedef->v2->GetClipAngle(); clipper.SafeAddClipRange(a1,a2); + gl_RenderState.SetClipLine(linedef); + gl_RenderState.EnableClipLine(true); GLRenderer->DrawScene(); + gl_RenderState.EnableClipLine(false); MirrorFlag--; } @@ -1018,7 +1042,10 @@ void GLLineToLinePortal::DrawContents() GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); ClearClipper(); + gl_RenderState.SetClipLine(glport->reference->mDestination); + gl_RenderState.EnableClipLine(true); GLRenderer->DrawScene(); + gl_RenderState.EnableClipLine(false); RestoreMapSection(); } diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 870009845..2962a4be1 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -225,6 +225,8 @@ struct GLLinePortal : public GLPortal virtual int ClipSubsector(subsector_t *sub); virtual int ClipPoint(const DVector2 &pos); virtual bool NeedCap() { return false; } + virtual void PushState(); + virtual void PopState(); }; diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 44aec6199..7cc4d4d83 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -55,11 +55,15 @@ void main() #endif - // clip planes used for reflective flats - if (uClipHeightDirection != 0.0) + + if (uClipHeightDirection != 0.0) // clip planes used for reflective flats { gl_ClipDistance[0] = (worldcoord.y - uClipHeight) * uClipHeightDirection; } + else if (uClipLine.x > -1000000.0) // and for line portals - this will never be active at the same time as the reflective planes clipping so it can use the same hardware clip plane. + { + gl_ClipDistance[0] = -( (worldcoord.z - uClipLine.y) * uClipLine.z + (uClipLine.x - worldcoord.x) * uClipLine.w ) + 1.0/32768.0; // allow a tiny bit of imprecisions for colinear linedefs. + } // clip planes used for translucency splitting gl_ClipDistance[1] = worldcoord.y - uClipSplit.x; From de6f13f0b4dfd68affd8dce6b3ae7aaa1a09887b Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 27 Apr 2016 15:03:58 +0300 Subject: [PATCH 0537/1509] Updated gl_load.* files generated with glLoadGen 2.0.5 Added OpenGL extensions list file for glLoadGen Added extensions for OS X version --- src/gl/system/gl_extlist.txt | 14 + src/gl/system/gl_load.c | 1650 +++++++++++++++++----------------- src/gl/system/gl_load.h | 1481 +++++++++++++++--------------- 3 files changed, 1592 insertions(+), 1553 deletions(-) create mode 100644 src/gl/system/gl_extlist.txt diff --git a/src/gl/system/gl_extlist.txt b/src/gl/system/gl_extlist.txt new file mode 100644 index 000000000..df59c7a27 --- /dev/null +++ b/src/gl/system/gl_extlist.txt @@ -0,0 +1,14 @@ +-- List of OpenGL extensions for glLoadGen + +-- Generation of gl_load.c and gl_load.h files: +-- > lua LoadGen.lua -style=pointer_c -spec=gl -version=3.3 -profile=compatibility -extfile=gl_extlist.txt load + +APPLE_client_storage +ARB_buffer_storage +ARB_shader_storage_buffer_object +ARB_texture_compression +ARB_texture_rectangle +EXT_framebuffer_object +EXT_texture_compression_s3tc +EXT_texture_filter_anisotropic +EXT_texture_sRGB diff --git a/src/gl/system/gl_load.c b/src/gl/system/gl_load.c index aaab3cf82..a6b7df013 100644 --- a/src/gl/system/gl_load.c +++ b/src/gl/system/gl_load.c @@ -4,27 +4,16 @@ #include "gl_load.h" #if defined(__APPLE__) -#include +#include -static void* AppleGLGetProcAddress (const GLubyte *name) +static void* AppleGLGetProcAddress (const char *name) { - static const struct mach_header* image = NULL; - NSSymbol symbol; - char* symbolName; - if (NULL == image) - { - image = NSAddImage("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", NSADDIMAGE_OPTION_RETURN_ON_ERROR); - } - /* prepend a '_' for the Unix C symbol mangling convention */ - symbolName = malloc(strlen((const char*)name) + 2); - strcpy(symbolName+1, (const char*)name); - symbolName[0] = '_'; - symbol = NULL; - /* if (NSIsSymbolNameDefined(symbolName)) - symbol = NSLookupAndBindSymbol(symbolName); */ - symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : NULL; - free(symbolName); - return symbol ? NSAddressOfSymbol(symbol) : NULL; + static void* image = NULL; + + if (NULL == image) + image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY); + + return (image ? dlsym(image, name) : NULL); } #endif /* __APPLE__ */ @@ -55,6 +44,7 @@ static void* SunGetProcAddress (const GLubyte* name) #ifdef _MSC_VER #pragma warning(disable: 4055) #pragma warning(disable: 4054) +#pragma warning(disable: 4996) #endif static int TestPointer(const PROC pTest) @@ -102,38 +92,40 @@ int ogl_ext_ARB_shader_storage_buffer_object = ogl_LOAD_FAILED; int ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; int ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; int ogl_ext_EXT_framebuffer_object = ogl_LOAD_FAILED; +int ogl_ext_APPLE_client_storage = ogl_LOAD_FAILED; +int ogl_ext_ARB_texture_rectangle = ogl_LOAD_FAILED; -void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1DARB)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1DARB)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2DARB)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3DARB)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImageARB)(GLenum, GLint, GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1DARB)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImageARB)(GLenum target, GLint level, void * img) = NULL; -static int Load_ARB_texture_compression() +static int Load_ARB_texture_compression(void) { int numFailed = 0; - _ptrc_glCompressedTexImage1DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage1DARB"); + _ptrc_glCompressedTexImage1DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress("glCompressedTexImage1DARB"); if(!_ptrc_glCompressedTexImage1DARB) numFailed++; - _ptrc_glCompressedTexImage2DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage2DARB"); + _ptrc_glCompressedTexImage2DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress("glCompressedTexImage2DARB"); if(!_ptrc_glCompressedTexImage2DARB) numFailed++; - _ptrc_glCompressedTexImage3DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage3DARB"); + _ptrc_glCompressedTexImage3DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress("glCompressedTexImage3DARB"); if(!_ptrc_glCompressedTexImage3DARB) numFailed++; - _ptrc_glCompressedTexSubImage1DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage1DARB"); + _ptrc_glCompressedTexSubImage1DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress("glCompressedTexSubImage1DARB"); if(!_ptrc_glCompressedTexSubImage1DARB) numFailed++; - _ptrc_glCompressedTexSubImage2DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage2DARB"); + _ptrc_glCompressedTexSubImage2DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress("glCompressedTexSubImage2DARB"); if(!_ptrc_glCompressedTexSubImage2DARB) numFailed++; - _ptrc_glCompressedTexSubImage3DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage3DARB"); + _ptrc_glCompressedTexSubImage3DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress("glCompressedTexSubImage3DARB"); if(!_ptrc_glCompressedTexSubImage3DARB) numFailed++; - _ptrc_glGetCompressedTexImageARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLvoid *))IntGetProcAddress("glGetCompressedTexImageARB"); + _ptrc_glGetCompressedTexImageARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, void *))IntGetProcAddress("glGetCompressedTexImageARB"); if(!_ptrc_glGetCompressedTexImageARB) numFailed++; return numFailed; } -void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum, GLsizeiptr, const void *, GLbitfield) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum target, GLsizeiptr size, const void * data, GLbitfield flags) = NULL; -static int Load_ARB_buffer_storage() +static int Load_ARB_buffer_storage(void) { int numFailed = 0; _ptrc_glBufferStorage = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizeiptr, const void *, GLbitfield))IntGetProcAddress("glBufferStorage"); @@ -141,9 +133,9 @@ static int Load_ARB_buffer_storage() return numFailed; } -void (CODEGEN_FUNCPTR *_ptrc_glShaderStorageBlockBinding)(GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glShaderStorageBlockBinding)(GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding) = NULL; -static int Load_ARB_shader_storage_buffer_object() +static int Load_ARB_shader_storage_buffer_object(void) { int numFailed = 0; _ptrc_glShaderStorageBlockBinding = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress("glShaderStorageBlockBinding"); @@ -151,25 +143,25 @@ static int Load_ARB_shader_storage_buffer_object() return numFailed; } -void (CODEGEN_FUNCPTR *_ptrc_glBindFramebufferEXT)(GLenum, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbufferEXT)(GLenum, GLuint) = NULL; -GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatusEXT)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffersEXT)(GLsizei, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffersEXT)(GLsizei, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbufferEXT)(GLenum, GLenum, GLenum, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1DEXT)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2DEXT)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3DEXT)(GLenum, GLenum, GLenum, GLuint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffersEXT)(GLsizei, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffersEXT)(GLsizei, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmapEXT)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameterivEXT)(GLenum, GLenum, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameterivEXT)(GLenum, GLenum, GLint *) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebufferEXT)(GLuint) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbufferEXT)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageEXT)(GLenum, GLenum, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindFramebufferEXT)(GLenum target, GLuint framebuffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbufferEXT)(GLenum target, GLuint renderbuffer) = NULL; +GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatusEXT)(GLenum target) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffersEXT)(GLsizei n, const GLuint * framebuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffersEXT)(GLsizei n, const GLuint * renderbuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbufferEXT)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffersEXT)(GLsizei n, GLuint * framebuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffersEXT)(GLsizei n, GLuint * renderbuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmapEXT)(GLenum target) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameterivEXT)(GLenum target, GLenum attachment, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameterivEXT)(GLenum target, GLenum pname, GLint * params) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebufferEXT)(GLuint framebuffer) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbufferEXT)(GLuint renderbuffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = NULL; -static int Load_EXT_framebuffer_object() +static int Load_EXT_framebuffer_object(void) { int numFailed = 0; _ptrc_glBindFramebufferEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindFramebufferEXT"); @@ -209,713 +201,713 @@ static int Load_EXT_framebuffer_object() return numFailed; } -void (CODEGEN_FUNCPTR *_ptrc_glAccum)(GLenum, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glAlphaFunc)(GLenum, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBegin)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBitmap)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCallList)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCallLists)(GLsizei, GLenum, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glClearAccum)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glClearIndex)(GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glClipPlane)(GLenum, const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3b)(GLbyte, GLbyte, GLbyte) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3bv)(const GLbyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3d)(GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3f)(GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3i)(GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3s)(GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3ub)(GLubyte, GLubyte, GLubyte) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3ubv)(const GLubyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3ui)(GLuint, GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3uiv)(const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3us)(GLushort, GLushort, GLushort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor3usv)(const GLushort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4b)(GLbyte, GLbyte, GLbyte, GLbyte) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4bv)(const GLbyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4d)(GLdouble, GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4f)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4i)(GLint, GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4s)(GLshort, GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4ub)(GLubyte, GLubyte, GLubyte, GLubyte) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4ubv)(const GLubyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4ui)(GLuint, GLuint, GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4uiv)(const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4us)(GLushort, GLushort, GLushort, GLushort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColor4usv)(const GLushort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColorMaterial)(GLenum, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCopyPixels)(GLint, GLint, GLsizei, GLsizei, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDeleteLists)(GLuint, GLsizei) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlag)(GLboolean) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagv)(const GLboolean *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEnd)() = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEndList)() = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1d)(GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1f)(GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2d)(GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2f)(GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh1)(GLenum, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh2)(GLenum, GLint, GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint1)(GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint2)(GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFeedbackBuffer)(GLsizei, GLenum, GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFinish)() = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFlush)() = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFogf)(GLenum, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFogfv)(GLenum, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFogi)(GLenum, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFogiv)(GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFrustum)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble) = NULL; -GLuint (CODEGEN_FUNCPTR *_ptrc_glGenLists)(GLsizei) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum, GLboolean *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetClipPlane)(GLenum, GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum, GLdouble *) = NULL; -GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)() = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum, GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetLightfv)(GLenum, GLenum, GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetLightiv)(GLenum, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetMapdv)(GLenum, GLenum, GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetMapfv)(GLenum, GLenum, GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetMapiv)(GLenum, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialfv)(GLenum, GLenum, GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialiv)(GLenum, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapfv)(GLenum, GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapuiv)(GLenum, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapusv)(GLenum, GLushort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetPolygonStipple)(GLubyte *) = NULL; -const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnvfv)(GLenum, GLenum, GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnviv)(GLenum, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetTexGendv)(GLenum, GLenum, GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetTexGenfv)(GLenum, GLenum, GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetTexGeniv)(GLenum, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum, GLenum, GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glIndexMask)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glIndexd)(GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glIndexdv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glIndexf)(GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glIndexfv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glIndexi)(GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glIndexiv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glIndexs)(GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glIndexsv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glInitNames)() = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsList)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLightModelf)(GLenum, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLightModelfv)(GLenum, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLightModeli)(GLenum, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLightModeliv)(GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLightf)(GLenum, GLenum, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLightfv)(GLenum, GLenum, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLighti)(GLenum, GLenum, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLightiv)(GLenum, GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLineStipple)(GLint, GLushort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glListBase)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLoadIdentity)() = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixd)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixf)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLoadName)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMap1d)(GLenum, GLdouble, GLdouble, GLint, GLint, const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMap1f)(GLenum, GLfloat, GLfloat, GLint, GLint, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMap2d)(GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMap2f)(GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1d)(GLint, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1f)(GLint, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2d)(GLint, GLdouble, GLdouble, GLint, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2f)(GLint, GLfloat, GLfloat, GLint, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMaterialf)(GLenum, GLenum, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMaterialfv)(GLenum, GLenum, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMateriali)(GLenum, GLenum, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMaterialiv)(GLenum, GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMatrixMode)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixd)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixf)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glNewList)(GLuint, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glNormal3b)(GLbyte, GLbyte, GLbyte) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glNormal3bv)(const GLbyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glNormal3d)(GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glNormal3dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glNormal3f)(GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glNormal3fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glNormal3i)(GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glNormal3iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glNormal3s)(GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glNormal3sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glOrtho)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPassThrough)(GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPixelMapfv)(GLenum, GLsizei, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPixelMapuiv)(GLenum, GLsizei, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPixelMapusv)(GLenum, GLsizei, const GLushort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferf)(GLenum, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferi)(GLenum, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPixelZoom)(GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPolygonStipple)(const GLubyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPopAttrib)() = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPopMatrix)() = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPopName)() = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPushAttrib)(GLbitfield) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPushMatrix)() = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPushName)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2d)(GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2f)(GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2i)(GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2s)(GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3d)(GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3f)(GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3i)(GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3s)(GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4f)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4i)(GLint, GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4s)(GLshort, GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRectd)(GLdouble, GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRectdv)(const GLdouble *, const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRectf)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRectfv)(const GLfloat *, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRecti)(GLint, GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRectiv)(const GLint *, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRects)(GLshort, GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRectsv)(const GLshort *, const GLshort *) = NULL; -GLint (CODEGEN_FUNCPTR *_ptrc_glRenderMode)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRotated)(GLdouble, GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRotatef)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glScaled)(GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glScalef)(GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint, GLint, GLsizei, GLsizei) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSelectBuffer)(GLsizei, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glShadeModel)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum, GLint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum, GLenum, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1d)(GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1f)(GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1i)(GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1s)(GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2d)(GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2f)(GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2i)(GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2s)(GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3d)(GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3f)(GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3i)(GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3s)(GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4d)(GLdouble, GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4f)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4i)(GLint, GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4s)(GLshort, GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexEnvf)(GLenum, GLenum, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexEnvfv)(GLenum, GLenum, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexEnvi)(GLenum, GLenum, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexEnviv)(GLenum, GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexGend)(GLenum, GLenum, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexGendv)(GLenum, GLenum, const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexGenf)(GLenum, GLenum, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexGenfv)(GLenum, GLenum, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexGeni)(GLenum, GLenum, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexGeniv)(GLenum, GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum, GLenum, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum, GLenum, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum, GLenum, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum, GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTranslated)(GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTranslatef)(GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex2d)(GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex2dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex2f)(GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex2fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex2i)(GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex2iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex2s)(GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex2sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex3d)(GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex3dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex3f)(GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex3fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex3i)(GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex3iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex3s)(GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex3sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex4d)(GLdouble, GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex4dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex4f)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex4fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex4i)(GLint, GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex4iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex4s)(GLshort, GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertex4sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint, GLint, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glAccum)(GLenum op, GLfloat value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glAlphaFunc)(GLenum func, GLfloat ref) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBegin)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBitmap)(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum sfactor, GLenum dfactor) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCallList)(GLuint list) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCallLists)(GLsizei n, GLenum type, const void * lists) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearAccum)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble depth) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearIndex)(GLfloat c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClipPlane)(GLenum plane, const GLdouble * equation) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3b)(GLbyte red, GLbyte green, GLbyte blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3bv)(const GLbyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3d)(GLdouble red, GLdouble green, GLdouble blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3f)(GLfloat red, GLfloat green, GLfloat blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3i)(GLint red, GLint green, GLint blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3s)(GLshort red, GLshort green, GLshort blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3ub)(GLubyte red, GLubyte green, GLubyte blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3ubv)(const GLubyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3ui)(GLuint red, GLuint green, GLuint blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3uiv)(const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3us)(GLushort red, GLushort green, GLushort blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3usv)(const GLushort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4b)(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4bv)(const GLbyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4d)(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4i)(GLint red, GLint green, GLint blue, GLint alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4s)(GLshort red, GLshort green, GLshort blue, GLshort alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4ubv)(const GLubyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4ui)(GLuint red, GLuint green, GLuint blue, GLuint alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4uiv)(const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4us)(GLushort red, GLushort green, GLushort blue, GLushort alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4usv)(const GLushort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColorMaterial)(GLenum face, GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteLists)(GLuint list, GLsizei range) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum func) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean flag) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble ren_near, GLdouble ren_far) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum cap) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum buf) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawPixels)(GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlag)(GLboolean flag) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagv)(const GLboolean * flag) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum cap) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnd)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndList)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1d)(GLdouble u) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1dv)(const GLdouble * u) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1f)(GLfloat u) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1fv)(const GLfloat * u) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2d)(GLdouble u, GLdouble v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2dv)(const GLdouble * u) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2f)(GLfloat u, GLfloat v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2fv)(const GLfloat * u) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh1)(GLenum mode, GLint i1, GLint i2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh2)(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint1)(GLint i) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint2)(GLint i, GLint j) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFeedbackBuffer)(GLsizei size, GLenum type, GLfloat * buffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFinish)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFlush)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogf)(GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogfv)(GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogi)(GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogiv)(GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFrustum)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glGenLists)(GLsizei range) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum pname, GLboolean * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetClipPlane)(GLenum plane, GLdouble * equation) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum pname, GLdouble * data) = NULL; +GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum pname, GLfloat * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum pname, GLint * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetLightfv)(GLenum light, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetLightiv)(GLenum light, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMapdv)(GLenum target, GLenum query, GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMapfv)(GLenum target, GLenum query, GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMapiv)(GLenum target, GLenum query, GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialfv)(GLenum face, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialiv)(GLenum face, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapfv)(GLenum map, GLfloat * values) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapuiv)(GLenum map, GLuint * values) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapusv)(GLenum map, GLushort * values) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPolygonStipple)(GLubyte * mask) = NULL; +const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnvfv)(GLenum target, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnviv)(GLenum target, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexGendv)(GLenum coord, GLenum pname, GLdouble * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexGenfv)(GLenum coord, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexGeniv)(GLenum coord, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum target, GLint level, GLenum format, GLenum type, void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum target, GLint level, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum target, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum target, GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexMask)(GLuint mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexd)(GLdouble c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexdv)(const GLdouble * c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexf)(GLfloat c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexfv)(const GLfloat * c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexi)(GLint c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexiv)(const GLint * c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexs)(GLshort c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexsv)(const GLshort * c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInitNames)(void) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum cap) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsList)(GLuint list) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightModelf)(GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightModelfv)(GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightModeli)(GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightModeliv)(GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightf)(GLenum light, GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightfv)(GLenum light, GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLighti)(GLenum light, GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightiv)(GLenum light, GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLineStipple)(GLint factor, GLushort pattern) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat width) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glListBase)(GLuint base) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadIdentity)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixd)(const GLdouble * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixf)(const GLfloat * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadName)(GLuint name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum opcode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMap1d)(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMap1f)(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMap2d)(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMap2f)(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1d)(GLint un, GLdouble u1, GLdouble u2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1f)(GLint un, GLfloat u1, GLfloat u2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2d)(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2f)(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMaterialf)(GLenum face, GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMaterialfv)(GLenum face, GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMateriali)(GLenum face, GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMaterialiv)(GLenum face, GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMatrixMode)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixd)(const GLdouble * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixf)(const GLfloat * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNewList)(GLuint list, GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3b)(GLbyte nx, GLbyte ny, GLbyte nz) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3bv)(const GLbyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3d)(GLdouble nx, GLdouble ny, GLdouble nz) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3f)(GLfloat nx, GLfloat ny, GLfloat nz) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3i)(GLint nx, GLint ny, GLint nz) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3s)(GLshort nx, GLshort ny, GLshort nz) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glOrtho)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPassThrough)(GLfloat token) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelMapfv)(GLenum map, GLsizei mapsize, const GLfloat * values) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelMapuiv)(GLenum map, GLsizei mapsize, const GLuint * values) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelMapusv)(GLenum map, GLsizei mapsize, const GLushort * values) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferf)(GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferi)(GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelZoom)(GLfloat xfactor, GLfloat yfactor) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat size) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum face, GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPolygonStipple)(const GLubyte * mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPopAttrib)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPopMatrix)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPopName)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPushAttrib)(GLbitfield mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPushMatrix)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPushName)(GLuint name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2d)(GLdouble x, GLdouble y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2f)(GLfloat x, GLfloat y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2i)(GLint x, GLint y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2s)(GLshort x, GLshort y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3d)(GLdouble x, GLdouble y, GLdouble z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3f)(GLfloat x, GLfloat y, GLfloat z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3i)(GLint x, GLint y, GLint z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3s)(GLshort x, GLshort y, GLshort z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4d)(GLdouble x, GLdouble y, GLdouble z, GLdouble w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4i)(GLint x, GLint y, GLint z, GLint w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4s)(GLshort x, GLshort y, GLshort z, GLshort w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum src) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectd)(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectdv)(const GLdouble * v1, const GLdouble * v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectf)(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectfv)(const GLfloat * v1, const GLfloat * v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRecti)(GLint x1, GLint y1, GLint x2, GLint y2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectiv)(const GLint * v1, const GLint * v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRects)(GLshort x1, GLshort y1, GLshort x2, GLshort y2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectsv)(const GLshort * v1, const GLshort * v2) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glRenderMode)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRotated)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glScaled)(GLdouble x, GLdouble y, GLdouble z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glScalef)(GLfloat x, GLfloat y, GLfloat z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint x, GLint y, GLsizei width, GLsizei height) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSelectBuffer)(GLsizei size, GLuint * buffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glShadeModel)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum func, GLint ref, GLuint mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1d)(GLdouble s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1f)(GLfloat s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1i)(GLint s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1s)(GLshort s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2d)(GLdouble s, GLdouble t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2f)(GLfloat s, GLfloat t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2i)(GLint s, GLint t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2s)(GLshort s, GLshort t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3d)(GLdouble s, GLdouble t, GLdouble r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3f)(GLfloat s, GLfloat t, GLfloat r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3i)(GLint s, GLint t, GLint r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3s)(GLshort s, GLshort t, GLshort r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4d)(GLdouble s, GLdouble t, GLdouble r, GLdouble q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4f)(GLfloat s, GLfloat t, GLfloat r, GLfloat q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4i)(GLint s, GLint t, GLint r, GLint q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4s)(GLshort s, GLshort t, GLshort r, GLshort q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexEnvf)(GLenum target, GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexEnvfv)(GLenum target, GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexEnvi)(GLenum target, GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexEnviv)(GLenum target, GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGend)(GLenum coord, GLenum pname, GLdouble param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGendv)(GLenum coord, GLenum pname, const GLdouble * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGenf)(GLenum coord, GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGenfv)(GLenum coord, GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGeni)(GLenum coord, GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGeniv)(GLenum coord, GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum target, GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum target, GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum target, GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum target, GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTranslated)(GLdouble x, GLdouble y, GLdouble z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTranslatef)(GLfloat x, GLfloat y, GLfloat z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2d)(GLdouble x, GLdouble y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2f)(GLfloat x, GLfloat y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2i)(GLint x, GLint y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2s)(GLshort x, GLshort y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3d)(GLdouble x, GLdouble y, GLdouble z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3f)(GLfloat x, GLfloat y, GLfloat z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3i)(GLint x, GLint y, GLint z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3s)(GLshort x, GLshort y, GLshort z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4d)(GLdouble x, GLdouble y, GLdouble z, GLdouble w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4i)(GLint x, GLint y, GLint z, GLint w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4s)(GLshort x, GLshort y, GLshort z, GLshort w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint x, GLint y, GLsizei width, GLsizei height) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glAreTexturesResident)(GLsizei, const GLuint *, GLboolean *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glArrayElement)(GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColorPointer)(GLint, GLenum, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDisableClientState)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum, GLint, GLsizei) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum, GLsizei, GLenum, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagPointer)(GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEnableClientState)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetPointerv)(GLenum, GLvoid **) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glIndexPointer)(GLenum, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glIndexub)(GLubyte) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glIndexubv)(const GLubyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glInterleavedArrays)(GLenum, GLsizei, const GLvoid *) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glNormalPointer)(GLenum, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPopClientAttrib)() = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPrioritizeTextures)(GLsizei, const GLuint *, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPushClientAttrib)(GLbitfield) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexCoordPointer)(GLint, GLenum, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexPointer)(GLint, GLenum, GLsizei, const GLvoid *) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glAreTexturesResident)(GLsizei n, const GLuint * textures, GLboolean * residences) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glArrayElement)(GLint i) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum target, GLuint texture) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColorPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei n, const GLuint * textures) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisableClientState)(GLenum ren_array) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum mode, GLint first, GLsizei count) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum mode, GLsizei count, GLenum type, const void * indices) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagPointer)(GLsizei stride, const void * pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnableClientState)(GLenum ren_array) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei n, GLuint * textures) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPointerv)(GLenum pname, void ** params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexPointer)(GLenum type, GLsizei stride, const void * pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexub)(GLubyte c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexubv)(const GLubyte * c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInterleavedArrays)(GLenum format, GLsizei stride, const void * pointer) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint texture) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormalPointer)(GLenum type, GLsizei stride, const void * pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat factor, GLfloat units) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPopClientAttrib)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPrioritizeTextures)(GLsizei n, const GLuint * textures, const GLfloat * priorities) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPushClientAttrib)(GLbitfield mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glClientActiveTexture)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum, GLint, GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixd)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixf)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixd)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixf)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1d)(GLenum, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1dv)(GLenum, const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1f)(GLenum, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1fv)(GLenum, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1i)(GLenum, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1iv)(GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1s)(GLenum, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1sv)(GLenum, const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2d)(GLenum, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2dv)(GLenum, const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2f)(GLenum, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2fv)(GLenum, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2i)(GLenum, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2iv)(GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2s)(GLenum, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2sv)(GLenum, const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3d)(GLenum, GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3dv)(GLenum, const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3f)(GLenum, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3fv)(GLenum, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3i)(GLenum, GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3iv)(GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3s)(GLenum, GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3sv)(GLenum, const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4d)(GLenum, GLdouble, GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4dv)(GLenum, const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4f)(GLenum, GLfloat, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4fv)(GLenum, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4i)(GLenum, GLint, GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4iv)(GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4s)(GLenum, GLshort, GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4sv)(GLenum, const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat, GLboolean) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum texture) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClientActiveTexture)(GLenum texture) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum target, GLint level, void * img) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixd)(const GLdouble * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixf)(const GLfloat * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixd)(const GLdouble * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixf)(const GLfloat * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1d)(GLenum target, GLdouble s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1dv)(GLenum target, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1f)(GLenum target, GLfloat s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1fv)(GLenum target, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1i)(GLenum target, GLint s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1iv)(GLenum target, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1s)(GLenum target, GLshort s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1sv)(GLenum target, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2d)(GLenum target, GLdouble s, GLdouble t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2dv)(GLenum target, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2f)(GLenum target, GLfloat s, GLfloat t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2fv)(GLenum target, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2i)(GLenum target, GLint s, GLint t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2iv)(GLenum target, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2s)(GLenum target, GLshort s, GLshort t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2sv)(GLenum target, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3d)(GLenum target, GLdouble s, GLdouble t, GLdouble r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3dv)(GLenum target, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3f)(GLenum target, GLfloat s, GLfloat t, GLfloat r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3fv)(GLenum target, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3i)(GLenum target, GLint s, GLint t, GLint r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3iv)(GLenum target, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3s)(GLenum target, GLshort s, GLshort t, GLshort r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3sv)(GLenum target, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4d)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4dv)(GLenum target, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4f)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4fv)(GLenum target, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4i)(GLenum target, GLint s, GLint t, GLint r, GLint q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4iv)(GLenum target, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4s)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4sv)(GLenum target, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat value, GLboolean invert) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFogCoordPointer)(GLenum, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFogCoordd)(GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFogCoorddv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFogCoordf)(GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFogCoordfv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum, const GLint *, const GLsizei *, GLsizei) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3b)(GLbyte, GLbyte, GLbyte) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3bv)(const GLbyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3d)(GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3f)(GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3i)(GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3s)(GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ub)(GLubyte, GLubyte, GLubyte) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ubv)(const GLubyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ui)(GLuint, GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3uiv)(const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3us)(GLushort, GLushort, GLushort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3usv)(const GLushort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColorPointer)(GLint, GLenum, GLsizei, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2d)(GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2f)(GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2i)(GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2s)(GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2sv)(const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3d)(GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3dv)(const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3f)(GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3fv)(const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3i)(GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3iv)(const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3s)(GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3sv)(const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoordPointer)(GLenum type, GLsizei stride, const void * pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoordd)(GLdouble coord) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoorddv)(const GLdouble * coord) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoordf)(GLfloat coord) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoordfv)(const GLfloat * coord) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei drawcount) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3b)(GLbyte red, GLbyte green, GLbyte blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3bv)(const GLbyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3d)(GLdouble red, GLdouble green, GLdouble blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3f)(GLfloat red, GLfloat green, GLfloat blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3i)(GLint red, GLint green, GLint blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3s)(GLshort red, GLshort green, GLshort blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ub)(GLubyte red, GLubyte green, GLubyte blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ubv)(const GLubyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ui)(GLuint red, GLuint green, GLuint blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3uiv)(const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3us)(GLushort red, GLushort green, GLushort blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3usv)(const GLushort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColorPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2d)(GLdouble x, GLdouble y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2f)(GLfloat x, GLfloat y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2i)(GLint x, GLint y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2s)(GLshort x, GLshort y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3d)(GLdouble x, GLdouble y, GLdouble z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3f)(GLfloat x, GLfloat y, GLfloat z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3i)(GLint x, GLint y, GLint z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3s)(GLshort x, GLshort y, GLshort z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3sv)(const GLshort * v) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum, GLsizeiptr, const GLvoid *, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum, GLenum, GLvoid **) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum, GLintptr, GLsizeiptr, GLvoid *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint, GLenum, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum, GLenum, GLint *) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint) = NULL; -void * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum, GLenum) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum target, GLuint id) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum target, GLuint buffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum target, GLsizeiptr size, const void * data, GLenum usage) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei n, const GLuint * buffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei n, const GLuint * ids) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum target) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei n, GLuint * buffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei n, GLuint * ids) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum target, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum target, GLenum pname, void ** params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint id, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint id, GLenum pname, GLuint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum target, GLenum pname, GLint * params) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint buffer) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint id) = NULL; +void * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum target, GLenum access) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum target) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint, GLuint, const GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint) = NULL; -GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)() = NULL; -GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei, const GLenum *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint, GLsizei, GLsizei *, GLuint *) = NULL; -GLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint, const GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint, GLenum, GLint *) = NULL; -GLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint, const GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint, GLint, GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint, GLint, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint, GLenum, GLvoid **) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint, GLenum, GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint, GLenum, GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint, GLenum, GLint *) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint, GLsizei, const GLchar *const*, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint, GLsizei, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint, GLsizei, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint, GLsizei, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint, GLsizei, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint, GLsizei, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint, GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint, GLsizei, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint, GLsizei, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint, GLint, GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint, GLsizei, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint, const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint, const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint, const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint, const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint, GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint, const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint, GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint, const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint, const GLbyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint, const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint, const GLubyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint, const GLushort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint, const GLbyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint, const GLdouble *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint, GLshort, GLshort, GLshort, GLshort) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint, const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint, const GLubyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint, const GLushort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint program, GLuint shader) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint program, GLuint index, const GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint shader) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)(void) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum type) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint program) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint shader) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint program, GLuint shader) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint index) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei n, const GLenum * bufs) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint index) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint program, const GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint program, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint shader, GLenum pname, GLint * params) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint program, const GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint program, GLint location, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint program, GLint location, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint index, GLenum pname, void ** pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint index, GLenum pname, GLdouble * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint index, GLenum pname, GLint * params) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint program) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint shader) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint program) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum face, GLuint mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint location, GLfloat v0) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint location, GLsizei count, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint location, GLint v0) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint location, GLsizei count, const GLint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint location, GLfloat v0, GLfloat v1) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint location, GLsizei count, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint location, GLint v0, GLint v1) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint location, GLsizei count, const GLint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint location, GLsizei count, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint location, GLint v0, GLint v1, GLint v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint location, GLsizei count, const GLint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint location, GLsizei count, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint location, GLsizei count, const GLint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint program) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint program) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint index, GLdouble x) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint index, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint index, GLfloat x) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint index, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint index, GLshort x) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint index, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint index, GLdouble x, GLdouble y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint index, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint index, GLfloat x, GLfloat y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint index, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint index, GLshort x, GLshort y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint index, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint index, GLdouble x, GLdouble y, GLdouble z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint index, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint index, GLfloat x, GLfloat y, GLfloat z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint index, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint index, GLshort x, GLshort y, GLshort z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint index, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint index, const GLbyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint index, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint index, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint index, const GLubyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint index, const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint index, const GLushort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint index, const GLbyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint index, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint index, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint index, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint index, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint index, const GLubyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint index, const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint index, const GLushort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum, GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint, GLuint, const GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum) = NULL; -GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum, GLint, GLfloat, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum, GLint, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum, GLint, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum, GLint, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)() = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)() = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum, GLenum, GLenum, GLuint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum, GLenum, GLuint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum, GLuint, GLboolean *) = NULL; -GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint, const GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum, GLuint, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum, GLenum, GLint *) = NULL; -const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum, GLenum, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint, GLint, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint, GLenum, GLuint *) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum, GLuint) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint) = NULL; -void * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum, GLsizei, GLenum, GLsizei, GLsizei) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum, GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum, GLenum, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint, GLsizei, const GLchar *const*, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint, GLsizei, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint, GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint, GLsizei, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint, GLuint, GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint, GLsizei, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint, GLuint, GLuint, GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint, GLsizei, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint, GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint, GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint, GLuint, GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint, const GLbyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint, GLint, GLint, GLint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint, const GLshort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint, const GLubyte *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint, GLuint, GLuint, GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint, const GLushort *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint, GLint, GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint id, GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum primitiveMode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum target, GLuint index, GLuint buffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint program, GLuint color, const GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum target, GLuint framebuffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum target, GLuint renderbuffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint ren_array) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) = NULL; +GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum target) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum target, GLenum clamp) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum buffer, GLint drawbuffer, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum buffer, GLint drawbuffer, const GLint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum buffer, GLint drawbuffer, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei n, const GLuint * framebuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei n, const GLuint * renderbuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei n, const GLuint * arrays) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum target, GLuint index) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum target, GLuint index) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei n, GLuint * framebuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei n, GLuint * renderbuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei n, GLuint * arrays) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum target) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum target, GLuint index, GLboolean * data) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint program, const GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum target, GLuint index, GLint * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint * params) = NULL; +const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum name, GLuint index) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum target, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum target, GLenum pname, GLuint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint program, GLint location, GLuint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint index, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint index, GLenum pname, GLuint * params) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum target, GLuint index) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint framebuffer) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint renderbuffer) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint ren_array) = NULL; +void * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum target, GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum target, GLenum pname, const GLuint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint location, GLuint v0) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint location, GLsizei count, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint location, GLuint v0, GLuint v1) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint location, GLsizei count, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint location, GLuint v0, GLuint v1, GLuint v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint location, GLsizei count, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint location, GLsizei count, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint index, GLint x) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint index, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint index, GLuint x) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint index, const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint index, GLint x, GLint y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint index, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint index, GLuint x, GLuint y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint index, const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint index, GLint x, GLint y, GLint z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint index, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint index, GLuint x, GLuint y, GLuint z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint index, const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint index, const GLbyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint index, GLint x, GLint y, GLint z, GLint w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint index, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint index, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint index, const GLubyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint index, const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint index, const GLushort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum, GLint, GLsizei, GLsizei) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint, GLuint, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint, GLsizei, const GLuint *, GLenum, GLint *) = NULL; -GLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint, const GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint, GLsizei, const GLchar *const*, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum, GLenum, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformName) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint program, const GLchar * uniformBlockName) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint index) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum target, GLenum internalformat, GLuint buffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) = NULL; -GLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync, GLbitfield, GLuint64) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint) = NULL; -GLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum, GLbitfield) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum, GLenum, GLuint, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum, GLenum, GLint64 *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum, GLuint, GLint64 *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum, GLint64 *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum, GLuint, GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync, GLenum, GLsizei, GLsizei *, GLint *) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint, GLbitfield) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync, GLbitfield, GLuint64) = NULL; +GLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync sync) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex) = NULL; +GLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum condition, GLbitfield flags) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum target, GLenum attachment, GLuint texture, GLint level) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum target, GLenum pname, GLint64 * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum target, GLuint index, GLint64 * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum pname, GLint64 * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum pname, GLuint index, GLfloat * val) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync sync) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint maskNumber, GLbitfield mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint, GLuint, GLuint, const GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei, GLuint *) = NULL; -GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint, const GLchar *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint, GLenum, GLint64 *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint, GLenum, GLuint64 *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint, GLenum, GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint, GLenum, GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint, GLenum, GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint, GLenum, GLint *) = NULL; -GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint, GLenum) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint, GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint, GLenum, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint, GLenum, GLfloat) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint, GLenum, const GLfloat *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint, GLenum, GLint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint, GLenum, const GLint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint, GLenum, GLboolean, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint, GLenum, GLboolean, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint, GLenum, GLboolean, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint, GLenum, GLboolean, GLuint) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint unit, GLuint sampler) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei count, const GLuint * samplers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei count, GLuint * samplers) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint program, const GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint id, GLenum pname, GLint64 * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint id, GLenum pname, GLuint64 * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint sampler, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint sampler, GLenum pname, GLuint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint sampler, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint sampler, GLenum pname, GLint * params) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint sampler) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint id, GLenum target) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint sampler, GLenum pname, const GLint * param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint sampler, GLenum pname, const GLuint * param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint sampler, GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint sampler, GLenum pname, const GLfloat * param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint sampler, GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint sampler, GLenum pname, const GLint * param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint index, GLuint divisor) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value) = NULL; -static int Load_Version_3_3() +static int Load_Version_3_3(void) { int numFailed = 0; _ptrc_glAccum = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glAccum"); @@ -930,7 +922,7 @@ static int Load_Version_3_3() if(!_ptrc_glBlendFunc) numFailed++; _ptrc_glCallList = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glCallList"); if(!_ptrc_glCallList) numFailed++; - _ptrc_glCallLists = (void (CODEGEN_FUNCPTR *)(GLsizei, GLenum, const GLvoid *))IntGetProcAddress("glCallLists"); + _ptrc_glCallLists = (void (CODEGEN_FUNCPTR *)(GLsizei, GLenum, const void *))IntGetProcAddress("glCallLists"); if(!_ptrc_glCallLists) numFailed++; _ptrc_glClear = (void (CODEGEN_FUNCPTR *)(GLbitfield))IntGetProcAddress("glClear"); if(!_ptrc_glClear) numFailed++; @@ -1030,7 +1022,7 @@ static int Load_Version_3_3() if(!_ptrc_glDisable) numFailed++; _ptrc_glDrawBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glDrawBuffer"); if(!_ptrc_glDrawBuffer) numFailed++; - _ptrc_glDrawPixels = (void (CODEGEN_FUNCPTR *)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glDrawPixels"); + _ptrc_glDrawPixels = (void (CODEGEN_FUNCPTR *)(GLsizei, GLsizei, GLenum, GLenum, const void *))IntGetProcAddress("glDrawPixels"); if(!_ptrc_glDrawPixels) numFailed++; _ptrc_glEdgeFlag = (void (CODEGEN_FUNCPTR *)(GLboolean))IntGetProcAddress("glEdgeFlag"); if(!_ptrc_glEdgeFlag) numFailed++; @@ -1038,9 +1030,9 @@ static int Load_Version_3_3() if(!_ptrc_glEdgeFlagv) numFailed++; _ptrc_glEnable = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glEnable"); if(!_ptrc_glEnable) numFailed++; - _ptrc_glEnd = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glEnd"); + _ptrc_glEnd = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glEnd"); if(!_ptrc_glEnd) numFailed++; - _ptrc_glEndList = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glEndList"); + _ptrc_glEndList = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glEndList"); if(!_ptrc_glEndList) numFailed++; _ptrc_glEvalCoord1d = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress("glEvalCoord1d"); if(!_ptrc_glEvalCoord1d) numFailed++; @@ -1068,9 +1060,9 @@ static int Load_Version_3_3() if(!_ptrc_glEvalPoint2) numFailed++; _ptrc_glFeedbackBuffer = (void (CODEGEN_FUNCPTR *)(GLsizei, GLenum, GLfloat *))IntGetProcAddress("glFeedbackBuffer"); if(!_ptrc_glFeedbackBuffer) numFailed++; - _ptrc_glFinish = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glFinish"); + _ptrc_glFinish = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glFinish"); if(!_ptrc_glFinish) numFailed++; - _ptrc_glFlush = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glFlush"); + _ptrc_glFlush = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glFlush"); if(!_ptrc_glFlush) numFailed++; _ptrc_glFogf = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glFogf"); if(!_ptrc_glFogf) numFailed++; @@ -1092,7 +1084,7 @@ static int Load_Version_3_3() if(!_ptrc_glGetClipPlane) numFailed++; _ptrc_glGetDoublev = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble *))IntGetProcAddress("glGetDoublev"); if(!_ptrc_glGetDoublev) numFailed++; - _ptrc_glGetError = (GLenum (CODEGEN_FUNCPTR *)())IntGetProcAddress("glGetError"); + _ptrc_glGetError = (GLenum (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glGetError"); if(!_ptrc_glGetError) numFailed++; _ptrc_glGetFloatv = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat *))IntGetProcAddress("glGetFloatv"); if(!_ptrc_glGetFloatv) numFailed++; @@ -1132,7 +1124,7 @@ static int Load_Version_3_3() if(!_ptrc_glGetTexGenfv) numFailed++; _ptrc_glGetTexGeniv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetTexGeniv"); if(!_ptrc_glGetTexGeniv) numFailed++; - _ptrc_glGetTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLenum, GLvoid *))IntGetProcAddress("glGetTexImage"); + _ptrc_glGetTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLenum, void *))IntGetProcAddress("glGetTexImage"); if(!_ptrc_glGetTexImage) numFailed++; _ptrc_glGetTexLevelParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLfloat *))IntGetProcAddress("glGetTexLevelParameterfv"); if(!_ptrc_glGetTexLevelParameterfv) numFailed++; @@ -1162,7 +1154,7 @@ static int Load_Version_3_3() if(!_ptrc_glIndexs) numFailed++; _ptrc_glIndexsv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glIndexsv"); if(!_ptrc_glIndexsv) numFailed++; - _ptrc_glInitNames = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glInitNames"); + _ptrc_glInitNames = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glInitNames"); if(!_ptrc_glInitNames) numFailed++; _ptrc_glIsEnabled = (GLboolean (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glIsEnabled"); if(!_ptrc_glIsEnabled) numFailed++; @@ -1190,7 +1182,7 @@ static int Load_Version_3_3() if(!_ptrc_glLineWidth) numFailed++; _ptrc_glListBase = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glListBase"); if(!_ptrc_glListBase) numFailed++; - _ptrc_glLoadIdentity = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glLoadIdentity"); + _ptrc_glLoadIdentity = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glLoadIdentity"); if(!_ptrc_glLoadIdentity) numFailed++; _ptrc_glLoadMatrixd = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glLoadMatrixd"); if(!_ptrc_glLoadMatrixd) numFailed++; @@ -1278,15 +1270,15 @@ static int Load_Version_3_3() if(!_ptrc_glPolygonMode) numFailed++; _ptrc_glPolygonStipple = (void (CODEGEN_FUNCPTR *)(const GLubyte *))IntGetProcAddress("glPolygonStipple"); if(!_ptrc_glPolygonStipple) numFailed++; - _ptrc_glPopAttrib = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glPopAttrib"); + _ptrc_glPopAttrib = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glPopAttrib"); if(!_ptrc_glPopAttrib) numFailed++; - _ptrc_glPopMatrix = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glPopMatrix"); + _ptrc_glPopMatrix = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glPopMatrix"); if(!_ptrc_glPopMatrix) numFailed++; - _ptrc_glPopName = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glPopName"); + _ptrc_glPopName = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glPopName"); if(!_ptrc_glPopName) numFailed++; _ptrc_glPushAttrib = (void (CODEGEN_FUNCPTR *)(GLbitfield))IntGetProcAddress("glPushAttrib"); if(!_ptrc_glPushAttrib) numFailed++; - _ptrc_glPushMatrix = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glPushMatrix"); + _ptrc_glPushMatrix = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glPushMatrix"); if(!_ptrc_glPushMatrix) numFailed++; _ptrc_glPushName = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glPushName"); if(!_ptrc_glPushName) numFailed++; @@ -1340,7 +1332,7 @@ static int Load_Version_3_3() if(!_ptrc_glRasterPos4sv) numFailed++; _ptrc_glReadBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glReadBuffer"); if(!_ptrc_glReadBuffer) numFailed++; - _ptrc_glReadPixels = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *))IntGetProcAddress("glReadPixels"); + _ptrc_glReadPixels = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, void *))IntGetProcAddress("glReadPixels"); if(!_ptrc_glReadPixels) numFailed++; _ptrc_glRectd = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glRectd"); if(!_ptrc_glRectd) numFailed++; @@ -1464,9 +1456,9 @@ static int Load_Version_3_3() if(!_ptrc_glTexGeni) numFailed++; _ptrc_glTexGeniv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress("glTexGeniv"); if(!_ptrc_glTexGeniv) numFailed++; - _ptrc_glTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexImage1D"); + _ptrc_glTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const void *))IntGetProcAddress("glTexImage1D"); if(!_ptrc_glTexImage1D) numFailed++; - _ptrc_glTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexImage2D"); + _ptrc_glTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))IntGetProcAddress("glTexImage2D"); if(!_ptrc_glTexImage2D) numFailed++; _ptrc_glTexParameterf = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat))IntGetProcAddress("glTexParameterf"); if(!_ptrc_glTexParameterf) numFailed++; @@ -1536,7 +1528,7 @@ static int Load_Version_3_3() if(!_ptrc_glArrayElement) numFailed++; _ptrc_glBindTexture = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindTexture"); if(!_ptrc_glBindTexture) numFailed++; - _ptrc_glColorPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glColorPointer"); + _ptrc_glColorPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const void *))IntGetProcAddress("glColorPointer"); if(!_ptrc_glColorPointer) numFailed++; _ptrc_glCopyTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint))IntGetProcAddress("glCopyTexImage1D"); if(!_ptrc_glCopyTexImage1D) numFailed++; @@ -1552,73 +1544,69 @@ static int Load_Version_3_3() if(!_ptrc_glDisableClientState) numFailed++; _ptrc_glDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLsizei))IntGetProcAddress("glDrawArrays"); if(!_ptrc_glDrawArrays) numFailed++; - _ptrc_glDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *))IntGetProcAddress("glDrawElements"); + _ptrc_glDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const void *))IntGetProcAddress("glDrawElements"); if(!_ptrc_glDrawElements) numFailed++; - _ptrc_glEdgeFlagPointer = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLvoid *))IntGetProcAddress("glEdgeFlagPointer"); + _ptrc_glEdgeFlagPointer = (void (CODEGEN_FUNCPTR *)(GLsizei, const void *))IntGetProcAddress("glEdgeFlagPointer"); if(!_ptrc_glEdgeFlagPointer) numFailed++; _ptrc_glEnableClientState = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glEnableClientState"); if(!_ptrc_glEnableClientState) numFailed++; _ptrc_glGenTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenTextures"); if(!_ptrc_glGenTextures) numFailed++; - _ptrc_glGetPointerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLvoid **))IntGetProcAddress("glGetPointerv"); + _ptrc_glGetPointerv = (void (CODEGEN_FUNCPTR *)(GLenum, void **))IntGetProcAddress("glGetPointerv"); if(!_ptrc_glGetPointerv) numFailed++; - _ptrc_glIndexPointer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glIndexPointer"); + _ptrc_glIndexPointer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const void *))IntGetProcAddress("glIndexPointer"); if(!_ptrc_glIndexPointer) numFailed++; _ptrc_glIndexub = (void (CODEGEN_FUNCPTR *)(GLubyte))IntGetProcAddress("glIndexub"); if(!_ptrc_glIndexub) numFailed++; _ptrc_glIndexubv = (void (CODEGEN_FUNCPTR *)(const GLubyte *))IntGetProcAddress("glIndexubv"); if(!_ptrc_glIndexubv) numFailed++; - _ptrc_glInterleavedArrays = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glInterleavedArrays"); + _ptrc_glInterleavedArrays = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const void *))IntGetProcAddress("glInterleavedArrays"); if(!_ptrc_glInterleavedArrays) numFailed++; _ptrc_glIsTexture = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsTexture"); if(!_ptrc_glIsTexture) numFailed++; - _ptrc_glNormalPointer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glNormalPointer"); + _ptrc_glNormalPointer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const void *))IntGetProcAddress("glNormalPointer"); if(!_ptrc_glNormalPointer) numFailed++; _ptrc_glPolygonOffset = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glPolygonOffset"); if(!_ptrc_glPolygonOffset) numFailed++; - _ptrc_glPopClientAttrib = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glPopClientAttrib"); + _ptrc_glPopClientAttrib = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glPopClientAttrib"); if(!_ptrc_glPopClientAttrib) numFailed++; _ptrc_glPrioritizeTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *, const GLfloat *))IntGetProcAddress("glPrioritizeTextures"); if(!_ptrc_glPrioritizeTextures) numFailed++; _ptrc_glPushClientAttrib = (void (CODEGEN_FUNCPTR *)(GLbitfield))IntGetProcAddress("glPushClientAttrib"); if(!_ptrc_glPushClientAttrib) numFailed++; - _ptrc_glTexCoordPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glTexCoordPointer"); + _ptrc_glTexCoordPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const void *))IntGetProcAddress("glTexCoordPointer"); if(!_ptrc_glTexCoordPointer) numFailed++; - _ptrc_glTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexSubImage1D"); + _ptrc_glTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const void *))IntGetProcAddress("glTexSubImage1D"); if(!_ptrc_glTexSubImage1D) numFailed++; - _ptrc_glTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexSubImage2D"); + _ptrc_glTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const void *))IntGetProcAddress("glTexSubImage2D"); if(!_ptrc_glTexSubImage2D) numFailed++; - _ptrc_glVertexPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glVertexPointer"); + _ptrc_glVertexPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const void *))IntGetProcAddress("glVertexPointer"); if(!_ptrc_glVertexPointer) numFailed++; - _ptrc_glBlendColor = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glBlendColor"); - if(!_ptrc_glBlendColor) numFailed++; - _ptrc_glBlendEquation = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glBlendEquation"); - if(!_ptrc_glBlendEquation) numFailed++; _ptrc_glCopyTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glCopyTexSubImage3D"); if(!_ptrc_glCopyTexSubImage3D) numFailed++; - _ptrc_glDrawRangeElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *))IntGetProcAddress("glDrawRangeElements"); + _ptrc_glDrawRangeElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const void *))IntGetProcAddress("glDrawRangeElements"); if(!_ptrc_glDrawRangeElements) numFailed++; - _ptrc_glTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexImage3D"); + _ptrc_glTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))IntGetProcAddress("glTexImage3D"); if(!_ptrc_glTexImage3D) numFailed++; - _ptrc_glTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexSubImage3D"); + _ptrc_glTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const void *))IntGetProcAddress("glTexSubImage3D"); if(!_ptrc_glTexSubImage3D) numFailed++; _ptrc_glActiveTexture = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glActiveTexture"); if(!_ptrc_glActiveTexture) numFailed++; _ptrc_glClientActiveTexture = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glClientActiveTexture"); if(!_ptrc_glClientActiveTexture) numFailed++; - _ptrc_glCompressedTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage1D"); + _ptrc_glCompressedTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress("glCompressedTexImage1D"); if(!_ptrc_glCompressedTexImage1D) numFailed++; - _ptrc_glCompressedTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage2D"); + _ptrc_glCompressedTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress("glCompressedTexImage2D"); if(!_ptrc_glCompressedTexImage2D) numFailed++; - _ptrc_glCompressedTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage3D"); + _ptrc_glCompressedTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress("glCompressedTexImage3D"); if(!_ptrc_glCompressedTexImage3D) numFailed++; - _ptrc_glCompressedTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage1D"); + _ptrc_glCompressedTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress("glCompressedTexSubImage1D"); if(!_ptrc_glCompressedTexSubImage1D) numFailed++; - _ptrc_glCompressedTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage2D"); + _ptrc_glCompressedTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress("glCompressedTexSubImage2D"); if(!_ptrc_glCompressedTexSubImage2D) numFailed++; - _ptrc_glCompressedTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage3D"); + _ptrc_glCompressedTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress("glCompressedTexSubImage3D"); if(!_ptrc_glCompressedTexSubImage3D) numFailed++; - _ptrc_glGetCompressedTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLvoid *))IntGetProcAddress("glGetCompressedTexImage"); + _ptrc_glGetCompressedTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, void *))IntGetProcAddress("glGetCompressedTexImage"); if(!_ptrc_glGetCompressedTexImage) numFailed++; _ptrc_glLoadTransposeMatrixd = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glLoadTransposeMatrixd"); if(!_ptrc_glLoadTransposeMatrixd) numFailed++; @@ -1694,9 +1682,13 @@ static int Load_Version_3_3() if(!_ptrc_glMultiTexCoord4sv) numFailed++; _ptrc_glSampleCoverage = (void (CODEGEN_FUNCPTR *)(GLfloat, GLboolean))IntGetProcAddress("glSampleCoverage"); if(!_ptrc_glSampleCoverage) numFailed++; + _ptrc_glBlendColor = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glBlendColor"); + if(!_ptrc_glBlendColor) numFailed++; + _ptrc_glBlendEquation = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glBlendEquation"); + if(!_ptrc_glBlendEquation) numFailed++; _ptrc_glBlendFuncSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum))IntGetProcAddress("glBlendFuncSeparate"); if(!_ptrc_glBlendFuncSeparate) numFailed++; - _ptrc_glFogCoordPointer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glFogCoordPointer"); + _ptrc_glFogCoordPointer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const void *))IntGetProcAddress("glFogCoordPointer"); if(!_ptrc_glFogCoordPointer) numFailed++; _ptrc_glFogCoordd = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress("glFogCoordd"); if(!_ptrc_glFogCoordd) numFailed++; @@ -1708,7 +1700,7 @@ static int Load_Version_3_3() if(!_ptrc_glFogCoordfv) numFailed++; _ptrc_glMultiDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *, const GLsizei *, GLsizei))IntGetProcAddress("glMultiDrawArrays"); if(!_ptrc_glMultiDrawArrays) numFailed++; - _ptrc_glMultiDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei))IntGetProcAddress("glMultiDrawElements"); + _ptrc_glMultiDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const void *const*, GLsizei))IntGetProcAddress("glMultiDrawElements"); if(!_ptrc_glMultiDrawElements) numFailed++; _ptrc_glPointParameterf = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glPointParameterf"); if(!_ptrc_glPointParameterf) numFailed++; @@ -1750,7 +1742,7 @@ static int Load_Version_3_3() if(!_ptrc_glSecondaryColor3us) numFailed++; _ptrc_glSecondaryColor3usv = (void (CODEGEN_FUNCPTR *)(const GLushort *))IntGetProcAddress("glSecondaryColor3usv"); if(!_ptrc_glSecondaryColor3usv) numFailed++; - _ptrc_glSecondaryColorPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glSecondaryColorPointer"); + _ptrc_glSecondaryColorPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const void *))IntGetProcAddress("glSecondaryColorPointer"); if(!_ptrc_glSecondaryColorPointer) numFailed++; _ptrc_glWindowPos2d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress("glWindowPos2d"); if(!_ptrc_glWindowPos2d) numFailed++; @@ -1788,9 +1780,9 @@ static int Load_Version_3_3() if(!_ptrc_glBeginQuery) numFailed++; _ptrc_glBindBuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindBuffer"); if(!_ptrc_glBindBuffer) numFailed++; - _ptrc_glBufferData = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizeiptr, const GLvoid *, GLenum))IntGetProcAddress("glBufferData"); + _ptrc_glBufferData = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizeiptr, const void *, GLenum))IntGetProcAddress("glBufferData"); if(!_ptrc_glBufferData) numFailed++; - _ptrc_glBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, const GLvoid *))IntGetProcAddress("glBufferSubData"); + _ptrc_glBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, const void *))IntGetProcAddress("glBufferSubData"); if(!_ptrc_glBufferSubData) numFailed++; _ptrc_glDeleteBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteBuffers"); if(!_ptrc_glDeleteBuffers) numFailed++; @@ -1804,9 +1796,9 @@ static int Load_Version_3_3() if(!_ptrc_glGenQueries) numFailed++; _ptrc_glGetBufferParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetBufferParameteriv"); if(!_ptrc_glGetBufferParameteriv) numFailed++; - _ptrc_glGetBufferPointerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLvoid **))IntGetProcAddress("glGetBufferPointerv"); + _ptrc_glGetBufferPointerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, void **))IntGetProcAddress("glGetBufferPointerv"); if(!_ptrc_glGetBufferPointerv) numFailed++; - _ptrc_glGetBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, GLvoid *))IntGetProcAddress("glGetBufferSubData"); + _ptrc_glGetBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, void *))IntGetProcAddress("glGetBufferSubData"); if(!_ptrc_glGetBufferSubData) numFailed++; _ptrc_glGetQueryObjectiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetQueryObjectiv"); if(!_ptrc_glGetQueryObjectiv) numFailed++; @@ -1830,7 +1822,7 @@ static int Load_Version_3_3() if(!_ptrc_glBlendEquationSeparate) numFailed++; _ptrc_glCompileShader = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glCompileShader"); if(!_ptrc_glCompileShader) numFailed++; - _ptrc_glCreateProgram = (GLuint (CODEGEN_FUNCPTR *)())IntGetProcAddress("glCreateProgram"); + _ptrc_glCreateProgram = (GLuint (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glCreateProgram"); if(!_ptrc_glCreateProgram) numFailed++; _ptrc_glCreateShader = (GLuint (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glCreateShader"); if(!_ptrc_glCreateShader) numFailed++; @@ -1870,7 +1862,7 @@ static int Load_Version_3_3() if(!_ptrc_glGetUniformfv) numFailed++; _ptrc_glGetUniformiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint *))IntGetProcAddress("glGetUniformiv"); if(!_ptrc_glGetUniformiv) numFailed++; - _ptrc_glGetVertexAttribPointerv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLvoid **))IntGetProcAddress("glGetVertexAttribPointerv"); + _ptrc_glGetVertexAttribPointerv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, void **))IntGetProcAddress("glGetVertexAttribPointerv"); if(!_ptrc_glGetVertexAttribPointerv) numFailed++; _ptrc_glGetVertexAttribdv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLdouble *))IntGetProcAddress("glGetVertexAttribdv"); if(!_ptrc_glGetVertexAttribdv) numFailed++; @@ -2006,7 +1998,7 @@ static int Load_Version_3_3() if(!_ptrc_glVertexAttrib4uiv) numFailed++; _ptrc_glVertexAttrib4usv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress("glVertexAttrib4usv"); if(!_ptrc_glVertexAttrib4usv) numFailed++; - _ptrc_glVertexAttribPointer = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *))IntGetProcAddress("glVertexAttribPointer"); + _ptrc_glVertexAttribPointer = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void *))IntGetProcAddress("glVertexAttribPointer"); if(!_ptrc_glVertexAttribPointer) numFailed++; _ptrc_glUniformMatrix2x3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix2x3fv"); if(!_ptrc_glUniformMatrix2x3fv) numFailed++; @@ -2062,9 +2054,9 @@ static int Load_Version_3_3() if(!_ptrc_glDisablei) numFailed++; _ptrc_glEnablei = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glEnablei"); if(!_ptrc_glEnablei) numFailed++; - _ptrc_glEndConditionalRender = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glEndConditionalRender"); + _ptrc_glEndConditionalRender = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glEndConditionalRender"); if(!_ptrc_glEndConditionalRender) numFailed++; - _ptrc_glEndTransformFeedback = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glEndTransformFeedback"); + _ptrc_glEndTransformFeedback = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glEndTransformFeedback"); if(!_ptrc_glEndTransformFeedback) numFailed++; _ptrc_glFlushMappedBufferRange = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr))IntGetProcAddress("glFlushMappedBufferRange"); if(!_ptrc_glFlushMappedBufferRange) numFailed++; @@ -2186,13 +2178,13 @@ static int Load_Version_3_3() if(!_ptrc_glVertexAttribI4uiv) numFailed++; _ptrc_glVertexAttribI4usv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress("glVertexAttribI4usv"); if(!_ptrc_glVertexAttribI4usv) numFailed++; - _ptrc_glVertexAttribIPointer = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glVertexAttribIPointer"); + _ptrc_glVertexAttribIPointer = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLenum, GLsizei, const void *))IntGetProcAddress("glVertexAttribIPointer"); if(!_ptrc_glVertexAttribIPointer) numFailed++; _ptrc_glCopyBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr))IntGetProcAddress("glCopyBufferSubData"); if(!_ptrc_glCopyBufferSubData) numFailed++; _ptrc_glDrawArraysInstanced = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLsizei, GLsizei))IntGetProcAddress("glDrawArraysInstanced"); if(!_ptrc_glDrawArraysInstanced) numFailed++; - _ptrc_glDrawElementsInstanced = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei))IntGetProcAddress("glDrawElementsInstanced"); + _ptrc_glDrawElementsInstanced = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const void *, GLsizei))IntGetProcAddress("glDrawElementsInstanced"); if(!_ptrc_glDrawElementsInstanced) numFailed++; _ptrc_glGetActiveUniformBlockName = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetActiveUniformBlockName"); if(!_ptrc_glGetActiveUniformBlockName) numFailed++; @@ -2216,11 +2208,11 @@ static int Load_Version_3_3() if(!_ptrc_glClientWaitSync) numFailed++; _ptrc_glDeleteSync = (void (CODEGEN_FUNCPTR *)(GLsync))IntGetProcAddress("glDeleteSync"); if(!_ptrc_glDeleteSync) numFailed++; - _ptrc_glDrawElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLint))IntGetProcAddress("glDrawElementsBaseVertex"); + _ptrc_glDrawElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const void *, GLint))IntGetProcAddress("glDrawElementsBaseVertex"); if(!_ptrc_glDrawElementsBaseVertex) numFailed++; - _ptrc_glDrawElementsInstancedBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint))IntGetProcAddress("glDrawElementsInstancedBaseVertex"); + _ptrc_glDrawElementsInstancedBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const void *, GLsizei, GLint))IntGetProcAddress("glDrawElementsInstancedBaseVertex"); if(!_ptrc_glDrawElementsInstancedBaseVertex) numFailed++; - _ptrc_glDrawRangeElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint))IntGetProcAddress("glDrawRangeElementsBaseVertex"); + _ptrc_glDrawRangeElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const void *, GLint))IntGetProcAddress("glDrawRangeElementsBaseVertex"); if(!_ptrc_glDrawRangeElementsBaseVertex) numFailed++; _ptrc_glFenceSync = (GLsync (CODEGEN_FUNCPTR *)(GLenum, GLbitfield))IntGetProcAddress("glFenceSync"); if(!_ptrc_glFenceSync) numFailed++; @@ -2238,15 +2230,15 @@ static int Load_Version_3_3() if(!_ptrc_glGetSynciv) numFailed++; _ptrc_glIsSync = (GLboolean (CODEGEN_FUNCPTR *)(GLsync))IntGetProcAddress("glIsSync"); if(!_ptrc_glIsSync) numFailed++; - _ptrc_glMultiDrawElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *))IntGetProcAddress("glMultiDrawElementsBaseVertex"); + _ptrc_glMultiDrawElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const void *const*, GLsizei, const GLint *))IntGetProcAddress("glMultiDrawElementsBaseVertex"); if(!_ptrc_glMultiDrawElementsBaseVertex) numFailed++; _ptrc_glProvokingVertex = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glProvokingVertex"); if(!_ptrc_glProvokingVertex) numFailed++; _ptrc_glSampleMaski = (void (CODEGEN_FUNCPTR *)(GLuint, GLbitfield))IntGetProcAddress("glSampleMaski"); if(!_ptrc_glSampleMaski) numFailed++; - _ptrc_glTexImage2DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean))IntGetProcAddress("glTexImage2DMultisample"); + _ptrc_glTexImage2DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLboolean))IntGetProcAddress("glTexImage2DMultisample"); if(!_ptrc_glTexImage2DMultisample) numFailed++; - _ptrc_glTexImage3DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean))IntGetProcAddress("glTexImage3DMultisample"); + _ptrc_glTexImage3DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei, GLboolean))IntGetProcAddress("glTexImage3DMultisample"); if(!_ptrc_glTexImage3DMultisample) numFailed++; _ptrc_glWaitSync = (void (CODEGEN_FUNCPTR *)(GLsync, GLbitfield, GLuint64))IntGetProcAddress("glWaitSync"); if(!_ptrc_glWaitSync) numFailed++; @@ -2309,7 +2301,7 @@ static int Load_Version_3_3() return numFailed; } -typedef int (*PFN_LOADFUNCPOINTERS)(); +typedef int (*PFN_LOADFUNCPOINTERS)(void); typedef struct ogl_StrToExtMap_s { char *extensionName; @@ -2317,7 +2309,7 @@ typedef struct ogl_StrToExtMap_s PFN_LOADFUNCPOINTERS LoadExtension; } ogl_StrToExtMap; -static ogl_StrToExtMap ExtensionMap[7] = { +static ogl_StrToExtMap ExtensionMap[9] = { {"GL_ARB_texture_compression", &ogl_ext_ARB_texture_compression, Load_ARB_texture_compression}, {"GL_EXT_texture_compression_s3tc", &ogl_ext_EXT_texture_compression_s3tc, NULL}, {"GL_ARB_buffer_storage", &ogl_ext_ARB_buffer_storage, Load_ARB_buffer_storage}, @@ -2325,9 +2317,11 @@ static ogl_StrToExtMap ExtensionMap[7] = { {"GL_EXT_texture_sRGB", &ogl_ext_EXT_texture_sRGB, NULL}, {"GL_EXT_texture_filter_anisotropic", &ogl_ext_EXT_texture_filter_anisotropic, NULL}, {"GL_EXT_framebuffer_object", &ogl_ext_EXT_framebuffer_object, Load_EXT_framebuffer_object}, + {"GL_APPLE_client_storage", &ogl_ext_APPLE_client_storage, NULL}, + {"GL_ARB_texture_rectangle", &ogl_ext_ARB_texture_rectangle, NULL}, }; -static int g_extensionMapSize = 7; +static int g_extensionMapSize = 9; static ogl_StrToExtMap *FindExtEntry(const char *extensionName) { @@ -2342,7 +2336,7 @@ static ogl_StrToExtMap *FindExtEntry(const char *extensionName) return NULL; } -static void ClearExtensionVars() +static void ClearExtensionVars(void) { ogl_ext_ARB_texture_compression = ogl_LOAD_FAILED; ogl_ext_EXT_texture_compression_s3tc = ogl_LOAD_FAILED; @@ -2351,6 +2345,8 @@ static void ClearExtensionVars() ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; ogl_ext_EXT_framebuffer_object = ogl_LOAD_FAILED; + ogl_ext_APPLE_client_storage = ogl_LOAD_FAILED; + ogl_ext_ARB_texture_rectangle = ogl_LOAD_FAILED; } @@ -2380,7 +2376,7 @@ static void LoadExtByName(const char *extensionName) } -static void ProcExtsFromExtList() +static void ProcExtsFromExtList(void) { GLint iLoop; GLint iNumExtensions = 0; @@ -2415,22 +2411,22 @@ int ogl_LoadFunctions() static int g_major_version = 0; static int g_minor_version = 0; -static void GetGLVersion() +static void GetGLVersion(void) { glGetIntegerv(GL_MAJOR_VERSION, &g_major_version); glGetIntegerv(GL_MINOR_VERSION, &g_minor_version); } -int ogl_GetMajorVersion() +int ogl_GetMajorVersion(void) { if(g_major_version == 0) GetGLVersion(); return g_major_version; } -int ogl_GetMinorVersion() +int ogl_GetMinorVersion(void) { - if(g_major_version == 0) //Yes, check the major version to get the minor one. + if(g_major_version == 0) /*Yes, check the major version to get the minor one.*/ GetGLVersion(); return g_minor_version; } @@ -2439,10 +2435,10 @@ int ogl_IsVersionGEQ(int majorVersion, int minorVersion) { if(g_major_version == 0) GetGLVersion(); - - if(majorVersion > g_major_version) return 1; - if(majorVersion < g_major_version) return 0; - if(minorVersion >= g_minor_version) return 1; + + if(majorVersion < g_major_version) return 1; + if(majorVersion > g_major_version) return 0; + if(minorVersion <= g_minor_version) return 1; return 0; } diff --git a/src/gl/system/gl_load.h b/src/gl/system/gl_load.h index e5af1a23c..3360b8777 100644 --- a/src/gl/system/gl_load.h +++ b/src/gl/system/gl_load.h @@ -160,6 +160,8 @@ extern int ogl_ext_ARB_shader_storage_buffer_object; extern int ogl_ext_EXT_texture_sRGB; extern int ogl_ext_EXT_texture_filter_anisotropic; extern int ogl_ext_EXT_framebuffer_object; +extern int ogl_ext_APPLE_client_storage; +extern int ogl_ext_ARB_texture_rectangle; #define GL_COMPRESSED_ALPHA_ARB 0x84E9 #define GL_COMPRESSED_INTENSITY_ARB 0x84EC @@ -278,6 +280,13 @@ extern int ogl_ext_EXT_framebuffer_object; #define GL_STENCIL_INDEX4_EXT 0x8D47 #define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 + +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 + #define GL_2D 0x0600 #define GL_2_BYTES 0x1407 #define GL_3D 0x0601 @@ -949,7 +958,6 @@ extern int ogl_ext_EXT_framebuffer_object; #define GL_BLEND_COLOR 0x8005 #define GL_BLEND_DST_ALPHA 0x80CA #define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_EQUATION 0x8009 #define GL_BLEND_SRC_ALPHA 0x80CB #define GL_BLEND_SRC_RGB 0x80C9 #define GL_COLOR_SUM 0x8458 @@ -1183,8 +1191,24 @@ extern int ogl_ext_EXT_framebuffer_object; #define GL_COLOR_ATTACHMENT13 0x8CED #define GL_COLOR_ATTACHMENT14 0x8CEE #define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 #define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD #define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF #define GL_COLOR_ATTACHMENT4 0x8CE4 #define GL_COLOR_ATTACHMENT5 0x8CE5 #define GL_COLOR_ATTACHMENT6 0x8CE6 @@ -1384,9 +1408,11 @@ extern int ogl_ext_EXT_framebuffer_object; #define GL_INT_SAMPLER_BUFFER 0x8DD0 #define GL_INVALID_INDEX 0xFFFFFFFF #define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 #define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E #define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 #define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C #define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 #define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B #define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 @@ -1420,6 +1446,7 @@ extern int ogl_ext_EXT_framebuffer_object; #define GL_UNIFORM_BLOCK_INDEX 0x8A3A #define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 #define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 #define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 #define GL_UNIFORM_BUFFER 0x8A11 #define GL_UNIFORM_BUFFER_BINDING 0x8A28 @@ -1519,32 +1546,32 @@ extern int ogl_ext_EXT_framebuffer_object; #ifndef GL_ARB_texture_compression #define GL_ARB_texture_compression 1 -extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1DARB)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data); #define glCompressedTexImage1DARB _ptrc_glCompressedTexImage1DARB -extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data); #define glCompressedTexImage2DARB _ptrc_glCompressedTexImage2DARB -extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data); #define glCompressedTexImage3DARB _ptrc_glCompressedTexImage3DARB -extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1DARB)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1DARB)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data); #define glCompressedTexSubImage1DARB _ptrc_glCompressedTexSubImage1DARB -extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2DARB)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data); #define glCompressedTexSubImage2DARB _ptrc_glCompressedTexSubImage2DARB -extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3DARB)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data); #define glCompressedTexSubImage3DARB _ptrc_glCompressedTexSubImage3DARB -extern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImageARB)(GLenum, GLint, GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImageARB)(GLenum target, GLint level, void * img); #define glGetCompressedTexImageARB _ptrc_glGetCompressedTexImageARB #endif /*GL_ARB_texture_compression*/ #ifndef GL_ARB_buffer_storage #define GL_ARB_buffer_storage 1 -extern void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum, GLsizeiptr, const void *, GLbitfield); +extern void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum target, GLsizeiptr size, const void * data, GLbitfield flags); #define glBufferStorage _ptrc_glBufferStorage #endif /*GL_ARB_buffer_storage*/ #ifndef GL_ARB_shader_storage_buffer_object #define GL_ARB_shader_storage_buffer_object 1 -extern void (CODEGEN_FUNCPTR *_ptrc_glShaderStorageBlockBinding)(GLuint, GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glShaderStorageBlockBinding)(GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); #define glShaderStorageBlockBinding _ptrc_glShaderStorageBlockBinding #endif /*GL_ARB_shader_storage_buffer_object*/ @@ -1552,1440 +1579,1442 @@ extern void (CODEGEN_FUNCPTR *_ptrc_glShaderStorageBlockBinding)(GLuint, GLuint, #ifndef GL_EXT_framebuffer_object #define GL_EXT_framebuffer_object 1 -extern void (CODEGEN_FUNCPTR *_ptrc_glBindFramebufferEXT)(GLenum, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFramebufferEXT)(GLenum target, GLuint framebuffer); #define glBindFramebufferEXT _ptrc_glBindFramebufferEXT -extern void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbufferEXT)(GLenum, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbufferEXT)(GLenum target, GLuint renderbuffer); #define glBindRenderbufferEXT _ptrc_glBindRenderbufferEXT -extern GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatusEXT)(GLenum); +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatusEXT)(GLenum target); #define glCheckFramebufferStatusEXT _ptrc_glCheckFramebufferStatusEXT -extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffersEXT)(GLsizei, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffersEXT)(GLsizei n, const GLuint * framebuffers); #define glDeleteFramebuffersEXT _ptrc_glDeleteFramebuffersEXT -extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffersEXT)(GLsizei, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffersEXT)(GLsizei n, const GLuint * renderbuffers); #define glDeleteRenderbuffersEXT _ptrc_glDeleteRenderbuffersEXT -extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbufferEXT)(GLenum, GLenum, GLenum, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbufferEXT)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); #define glFramebufferRenderbufferEXT _ptrc_glFramebufferRenderbufferEXT -extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1DEXT)(GLenum, GLenum, GLenum, GLuint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); #define glFramebufferTexture1DEXT _ptrc_glFramebufferTexture1DEXT -extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2DEXT)(GLenum, GLenum, GLenum, GLuint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); #define glFramebufferTexture2DEXT _ptrc_glFramebufferTexture2DEXT -extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3DEXT)(GLenum, GLenum, GLenum, GLuint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); #define glFramebufferTexture3DEXT _ptrc_glFramebufferTexture3DEXT -extern void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffersEXT)(GLsizei, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffersEXT)(GLsizei n, GLuint * framebuffers); #define glGenFramebuffersEXT _ptrc_glGenFramebuffersEXT -extern void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffersEXT)(GLsizei, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffersEXT)(GLsizei n, GLuint * renderbuffers); #define glGenRenderbuffersEXT _ptrc_glGenRenderbuffersEXT -extern void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmapEXT)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmapEXT)(GLenum target); #define glGenerateMipmapEXT _ptrc_glGenerateMipmapEXT -extern void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameterivEXT)(GLenum, GLenum, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameterivEXT)(GLenum target, GLenum attachment, GLenum pname, GLint * params); #define glGetFramebufferAttachmentParameterivEXT _ptrc_glGetFramebufferAttachmentParameterivEXT -extern void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameterivEXT)(GLenum, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameterivEXT)(GLenum target, GLenum pname, GLint * params); #define glGetRenderbufferParameterivEXT _ptrc_glGetRenderbufferParameterivEXT -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebufferEXT)(GLuint); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebufferEXT)(GLuint framebuffer); #define glIsFramebufferEXT _ptrc_glIsFramebufferEXT -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbufferEXT)(GLuint); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbufferEXT)(GLuint renderbuffer); #define glIsRenderbufferEXT _ptrc_glIsRenderbufferEXT -extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageEXT)(GLenum, GLenum, GLsizei, GLsizei); +extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); #define glRenderbufferStorageEXT _ptrc_glRenderbufferStorageEXT #endif /*GL_EXT_framebuffer_object*/ -extern void (CODEGEN_FUNCPTR *_ptrc_glAccum)(GLenum, GLfloat); + + +extern void (CODEGEN_FUNCPTR *_ptrc_glAccum)(GLenum op, GLfloat value); #define glAccum _ptrc_glAccum -extern void (CODEGEN_FUNCPTR *_ptrc_glAlphaFunc)(GLenum, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glAlphaFunc)(GLenum func, GLfloat ref); #define glAlphaFunc _ptrc_glAlphaFunc -extern void (CODEGEN_FUNCPTR *_ptrc_glBegin)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glBegin)(GLenum mode); #define glBegin _ptrc_glBegin -extern void (CODEGEN_FUNCPTR *_ptrc_glBitmap)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glBitmap)(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap); #define glBitmap _ptrc_glBitmap -extern void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum sfactor, GLenum dfactor); #define glBlendFunc _ptrc_glBlendFunc -extern void (CODEGEN_FUNCPTR *_ptrc_glCallList)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glCallList)(GLuint list); #define glCallList _ptrc_glCallList -extern void (CODEGEN_FUNCPTR *_ptrc_glCallLists)(GLsizei, GLenum, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glCallLists)(GLsizei n, GLenum type, const void * lists); #define glCallLists _ptrc_glCallLists -extern void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield); +extern void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield mask); #define glClear _ptrc_glClear -extern void (CODEGEN_FUNCPTR *_ptrc_glClearAccum)(GLfloat, GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glClearAccum)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #define glClearAccum _ptrc_glClearAccum -extern void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #define glClearColor _ptrc_glClearColor -extern void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble depth); #define glClearDepth _ptrc_glClearDepth -extern void (CODEGEN_FUNCPTR *_ptrc_glClearIndex)(GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glClearIndex)(GLfloat c); #define glClearIndex _ptrc_glClearIndex -extern void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint s); #define glClearStencil _ptrc_glClearStencil -extern void (CODEGEN_FUNCPTR *_ptrc_glClipPlane)(GLenum, const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glClipPlane)(GLenum plane, const GLdouble * equation); #define glClipPlane _ptrc_glClipPlane -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3b)(GLbyte, GLbyte, GLbyte); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3b)(GLbyte red, GLbyte green, GLbyte blue); #define glColor3b _ptrc_glColor3b -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3bv)(const GLbyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3bv)(const GLbyte * v); #define glColor3bv _ptrc_glColor3bv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3d)(GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3d)(GLdouble red, GLdouble green, GLdouble blue); #define glColor3d _ptrc_glColor3d -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3dv)(const GLdouble * v); #define glColor3dv _ptrc_glColor3dv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3f)(GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3f)(GLfloat red, GLfloat green, GLfloat blue); #define glColor3f _ptrc_glColor3f -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3fv)(const GLfloat * v); #define glColor3fv _ptrc_glColor3fv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3i)(GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3i)(GLint red, GLint green, GLint blue); #define glColor3i _ptrc_glColor3i -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3iv)(const GLint * v); #define glColor3iv _ptrc_glColor3iv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3s)(GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3s)(GLshort red, GLshort green, GLshort blue); #define glColor3s _ptrc_glColor3s -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3sv)(const GLshort * v); #define glColor3sv _ptrc_glColor3sv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3ub)(GLubyte, GLubyte, GLubyte); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3ub)(GLubyte red, GLubyte green, GLubyte blue); #define glColor3ub _ptrc_glColor3ub -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3ubv)(const GLubyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3ubv)(const GLubyte * v); #define glColor3ubv _ptrc_glColor3ubv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3ui)(GLuint, GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3ui)(GLuint red, GLuint green, GLuint blue); #define glColor3ui _ptrc_glColor3ui -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3uiv)(const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3uiv)(const GLuint * v); #define glColor3uiv _ptrc_glColor3uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3us)(GLushort, GLushort, GLushort); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3us)(GLushort red, GLushort green, GLushort blue); #define glColor3us _ptrc_glColor3us -extern void (CODEGEN_FUNCPTR *_ptrc_glColor3usv)(const GLushort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3usv)(const GLushort * v); #define glColor3usv _ptrc_glColor3usv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4b)(GLbyte, GLbyte, GLbyte, GLbyte); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4b)(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); #define glColor4b _ptrc_glColor4b -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4bv)(const GLbyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4bv)(const GLbyte * v); #define glColor4bv _ptrc_glColor4bv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4d)(GLdouble, GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4d)(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); #define glColor4d _ptrc_glColor4d -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4dv)(const GLdouble * v); #define glColor4dv _ptrc_glColor4dv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4f)(GLfloat, GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #define glColor4f _ptrc_glColor4f -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4fv)(const GLfloat * v); #define glColor4fv _ptrc_glColor4fv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4i)(GLint, GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4i)(GLint red, GLint green, GLint blue, GLint alpha); #define glColor4i _ptrc_glColor4i -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4iv)(const GLint * v); #define glColor4iv _ptrc_glColor4iv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4s)(GLshort, GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4s)(GLshort red, GLshort green, GLshort blue, GLshort alpha); #define glColor4s _ptrc_glColor4s -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4sv)(const GLshort * v); #define glColor4sv _ptrc_glColor4sv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4ub)(GLubyte, GLubyte, GLubyte, GLubyte); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); #define glColor4ub _ptrc_glColor4ub -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4ubv)(const GLubyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4ubv)(const GLubyte * v); #define glColor4ubv _ptrc_glColor4ubv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4ui)(GLuint, GLuint, GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4ui)(GLuint red, GLuint green, GLuint blue, GLuint alpha); #define glColor4ui _ptrc_glColor4ui -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4uiv)(const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4uiv)(const GLuint * v); #define glColor4uiv _ptrc_glColor4uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4us)(GLushort, GLushort, GLushort, GLushort); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4us)(GLushort red, GLushort green, GLushort blue, GLushort alpha); #define glColor4us _ptrc_glColor4us -extern void (CODEGEN_FUNCPTR *_ptrc_glColor4usv)(const GLushort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4usv)(const GLushort * v); #define glColor4usv _ptrc_glColor4usv -extern void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean); +extern void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); #define glColorMask _ptrc_glColorMask -extern void (CODEGEN_FUNCPTR *_ptrc_glColorMaterial)(GLenum, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glColorMaterial)(GLenum face, GLenum mode); #define glColorMaterial _ptrc_glColorMaterial -extern void (CODEGEN_FUNCPTR *_ptrc_glCopyPixels)(GLint, GLint, GLsizei, GLsizei, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); #define glCopyPixels _ptrc_glCopyPixels -extern void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum mode); #define glCullFace _ptrc_glCullFace -extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteLists)(GLuint, GLsizei); +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteLists)(GLuint list, GLsizei range); #define glDeleteLists _ptrc_glDeleteLists -extern void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum func); #define glDepthFunc _ptrc_glDepthFunc -extern void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean); +extern void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean flag); #define glDepthMask _ptrc_glDepthMask -extern void (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble ren_near, GLdouble ren_far); #define glDepthRange _ptrc_glDepthRange -extern void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum cap); #define glDisable _ptrc_glDisable -extern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum buf); #define glDrawBuffer _ptrc_glDrawBuffer -extern void (CODEGEN_FUNCPTR *_ptrc_glDrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawPixels)(GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels); #define glDrawPixels _ptrc_glDrawPixels -extern void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlag)(GLboolean); +extern void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlag)(GLboolean flag); #define glEdgeFlag _ptrc_glEdgeFlag -extern void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagv)(const GLboolean *); +extern void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagv)(const GLboolean * flag); #define glEdgeFlagv _ptrc_glEdgeFlagv -extern void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum cap); #define glEnable _ptrc_glEnable -extern void (CODEGEN_FUNCPTR *_ptrc_glEnd)(); +extern void (CODEGEN_FUNCPTR *_ptrc_glEnd)(void); #define glEnd _ptrc_glEnd -extern void (CODEGEN_FUNCPTR *_ptrc_glEndList)(); +extern void (CODEGEN_FUNCPTR *_ptrc_glEndList)(void); #define glEndList _ptrc_glEndList -extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1d)(GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1d)(GLdouble u); #define glEvalCoord1d _ptrc_glEvalCoord1d -extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1dv)(const GLdouble * u); #define glEvalCoord1dv _ptrc_glEvalCoord1dv -extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1f)(GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1f)(GLfloat u); #define glEvalCoord1f _ptrc_glEvalCoord1f -extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1fv)(const GLfloat * u); #define glEvalCoord1fv _ptrc_glEvalCoord1fv -extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2d)(GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2d)(GLdouble u, GLdouble v); #define glEvalCoord2d _ptrc_glEvalCoord2d -extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2dv)(const GLdouble * u); #define glEvalCoord2dv _ptrc_glEvalCoord2dv -extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2f)(GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2f)(GLfloat u, GLfloat v); #define glEvalCoord2f _ptrc_glEvalCoord2f -extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2fv)(const GLfloat * u); #define glEvalCoord2fv _ptrc_glEvalCoord2fv -extern void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh1)(GLenum, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh1)(GLenum mode, GLint i1, GLint i2); #define glEvalMesh1 _ptrc_glEvalMesh1 -extern void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh2)(GLenum, GLint, GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh2)(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); #define glEvalMesh2 _ptrc_glEvalMesh2 -extern void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint1)(GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint1)(GLint i); #define glEvalPoint1 _ptrc_glEvalPoint1 -extern void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint2)(GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint2)(GLint i, GLint j); #define glEvalPoint2 _ptrc_glEvalPoint2 -extern void (CODEGEN_FUNCPTR *_ptrc_glFeedbackBuffer)(GLsizei, GLenum, GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glFeedbackBuffer)(GLsizei size, GLenum type, GLfloat * buffer); #define glFeedbackBuffer _ptrc_glFeedbackBuffer -extern void (CODEGEN_FUNCPTR *_ptrc_glFinish)(); +extern void (CODEGEN_FUNCPTR *_ptrc_glFinish)(void); #define glFinish _ptrc_glFinish -extern void (CODEGEN_FUNCPTR *_ptrc_glFlush)(); +extern void (CODEGEN_FUNCPTR *_ptrc_glFlush)(void); #define glFlush _ptrc_glFlush -extern void (CODEGEN_FUNCPTR *_ptrc_glFogf)(GLenum, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glFogf)(GLenum pname, GLfloat param); #define glFogf _ptrc_glFogf -extern void (CODEGEN_FUNCPTR *_ptrc_glFogfv)(GLenum, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glFogfv)(GLenum pname, const GLfloat * params); #define glFogfv _ptrc_glFogfv -extern void (CODEGEN_FUNCPTR *_ptrc_glFogi)(GLenum, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glFogi)(GLenum pname, GLint param); #define glFogi _ptrc_glFogi -extern void (CODEGEN_FUNCPTR *_ptrc_glFogiv)(GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glFogiv)(GLenum pname, const GLint * params); #define glFogiv _ptrc_glFogiv -extern void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum mode); #define glFrontFace _ptrc_glFrontFace -extern void (CODEGEN_FUNCPTR *_ptrc_glFrustum)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glFrustum)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); #define glFrustum _ptrc_glFrustum -extern GLuint (CODEGEN_FUNCPTR *_ptrc_glGenLists)(GLsizei); +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glGenLists)(GLsizei range); #define glGenLists _ptrc_glGenLists -extern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum, GLboolean *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum pname, GLboolean * data); #define glGetBooleanv _ptrc_glGetBooleanv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetClipPlane)(GLenum, GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetClipPlane)(GLenum plane, GLdouble * equation); #define glGetClipPlane _ptrc_glGetClipPlane -extern void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum, GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum pname, GLdouble * data); #define glGetDoublev _ptrc_glGetDoublev -extern GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)(); +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)(void); #define glGetError _ptrc_glGetError -extern void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum, GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum pname, GLfloat * data); #define glGetFloatv _ptrc_glGetFloatv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum pname, GLint * data); #define glGetIntegerv _ptrc_glGetIntegerv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetLightfv)(GLenum, GLenum, GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetLightfv)(GLenum light, GLenum pname, GLfloat * params); #define glGetLightfv _ptrc_glGetLightfv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetLightiv)(GLenum, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetLightiv)(GLenum light, GLenum pname, GLint * params); #define glGetLightiv _ptrc_glGetLightiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetMapdv)(GLenum, GLenum, GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMapdv)(GLenum target, GLenum query, GLdouble * v); #define glGetMapdv _ptrc_glGetMapdv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetMapfv)(GLenum, GLenum, GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMapfv)(GLenum target, GLenum query, GLfloat * v); #define glGetMapfv _ptrc_glGetMapfv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetMapiv)(GLenum, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMapiv)(GLenum target, GLenum query, GLint * v); #define glGetMapiv _ptrc_glGetMapiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialfv)(GLenum, GLenum, GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialfv)(GLenum face, GLenum pname, GLfloat * params); #define glGetMaterialfv _ptrc_glGetMaterialfv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialiv)(GLenum, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialiv)(GLenum face, GLenum pname, GLint * params); #define glGetMaterialiv _ptrc_glGetMaterialiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapfv)(GLenum, GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapfv)(GLenum map, GLfloat * values); #define glGetPixelMapfv _ptrc_glGetPixelMapfv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapuiv)(GLenum, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapuiv)(GLenum map, GLuint * values); #define glGetPixelMapuiv _ptrc_glGetPixelMapuiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapusv)(GLenum, GLushort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapusv)(GLenum map, GLushort * values); #define glGetPixelMapusv _ptrc_glGetPixelMapusv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetPolygonStipple)(GLubyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPolygonStipple)(GLubyte * mask); #define glGetPolygonStipple _ptrc_glGetPolygonStipple -extern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum); +extern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum name); #define glGetString _ptrc_glGetString -extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnvfv)(GLenum, GLenum, GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnvfv)(GLenum target, GLenum pname, GLfloat * params); #define glGetTexEnvfv _ptrc_glGetTexEnvfv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnviv)(GLenum, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnviv)(GLenum target, GLenum pname, GLint * params); #define glGetTexEnviv _ptrc_glGetTexEnviv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexGendv)(GLenum, GLenum, GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexGendv)(GLenum coord, GLenum pname, GLdouble * params); #define glGetTexGendv _ptrc_glGetTexGendv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexGenfv)(GLenum, GLenum, GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexGenfv)(GLenum coord, GLenum pname, GLfloat * params); #define glGetTexGenfv _ptrc_glGetTexGenfv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexGeniv)(GLenum, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexGeniv)(GLenum coord, GLenum pname, GLint * params); #define glGetTexGeniv _ptrc_glGetTexGeniv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum target, GLint level, GLenum format, GLenum type, void * pixels); #define glGetTexImage _ptrc_glGetTexImage -extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum target, GLint level, GLenum pname, GLfloat * params); #define glGetTexLevelParameterfv _ptrc_glGetTexLevelParameterfv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint * params); #define glGetTexLevelParameteriv _ptrc_glGetTexLevelParameteriv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum, GLenum, GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat * params); #define glGetTexParameterfv _ptrc_glGetTexParameterfv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum target, GLenum pname, GLint * params); #define glGetTexParameteriv _ptrc_glGetTexParameteriv -extern void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum target, GLenum mode); #define glHint _ptrc_glHint -extern void (CODEGEN_FUNCPTR *_ptrc_glIndexMask)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexMask)(GLuint mask); #define glIndexMask _ptrc_glIndexMask -extern void (CODEGEN_FUNCPTR *_ptrc_glIndexd)(GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexd)(GLdouble c); #define glIndexd _ptrc_glIndexd -extern void (CODEGEN_FUNCPTR *_ptrc_glIndexdv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexdv)(const GLdouble * c); #define glIndexdv _ptrc_glIndexdv -extern void (CODEGEN_FUNCPTR *_ptrc_glIndexf)(GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexf)(GLfloat c); #define glIndexf _ptrc_glIndexf -extern void (CODEGEN_FUNCPTR *_ptrc_glIndexfv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexfv)(const GLfloat * c); #define glIndexfv _ptrc_glIndexfv -extern void (CODEGEN_FUNCPTR *_ptrc_glIndexi)(GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexi)(GLint c); #define glIndexi _ptrc_glIndexi -extern void (CODEGEN_FUNCPTR *_ptrc_glIndexiv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexiv)(const GLint * c); #define glIndexiv _ptrc_glIndexiv -extern void (CODEGEN_FUNCPTR *_ptrc_glIndexs)(GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexs)(GLshort c); #define glIndexs _ptrc_glIndexs -extern void (CODEGEN_FUNCPTR *_ptrc_glIndexsv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexsv)(const GLshort * c); #define glIndexsv _ptrc_glIndexsv -extern void (CODEGEN_FUNCPTR *_ptrc_glInitNames)(); +extern void (CODEGEN_FUNCPTR *_ptrc_glInitNames)(void); #define glInitNames _ptrc_glInitNames -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum cap); #define glIsEnabled _ptrc_glIsEnabled -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsList)(GLuint); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsList)(GLuint list); #define glIsList _ptrc_glIsList -extern void (CODEGEN_FUNCPTR *_ptrc_glLightModelf)(GLenum, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glLightModelf)(GLenum pname, GLfloat param); #define glLightModelf _ptrc_glLightModelf -extern void (CODEGEN_FUNCPTR *_ptrc_glLightModelfv)(GLenum, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glLightModelfv)(GLenum pname, const GLfloat * params); #define glLightModelfv _ptrc_glLightModelfv -extern void (CODEGEN_FUNCPTR *_ptrc_glLightModeli)(GLenum, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glLightModeli)(GLenum pname, GLint param); #define glLightModeli _ptrc_glLightModeli -extern void (CODEGEN_FUNCPTR *_ptrc_glLightModeliv)(GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glLightModeliv)(GLenum pname, const GLint * params); #define glLightModeliv _ptrc_glLightModeliv -extern void (CODEGEN_FUNCPTR *_ptrc_glLightf)(GLenum, GLenum, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glLightf)(GLenum light, GLenum pname, GLfloat param); #define glLightf _ptrc_glLightf -extern void (CODEGEN_FUNCPTR *_ptrc_glLightfv)(GLenum, GLenum, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glLightfv)(GLenum light, GLenum pname, const GLfloat * params); #define glLightfv _ptrc_glLightfv -extern void (CODEGEN_FUNCPTR *_ptrc_glLighti)(GLenum, GLenum, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glLighti)(GLenum light, GLenum pname, GLint param); #define glLighti _ptrc_glLighti -extern void (CODEGEN_FUNCPTR *_ptrc_glLightiv)(GLenum, GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glLightiv)(GLenum light, GLenum pname, const GLint * params); #define glLightiv _ptrc_glLightiv -extern void (CODEGEN_FUNCPTR *_ptrc_glLineStipple)(GLint, GLushort); +extern void (CODEGEN_FUNCPTR *_ptrc_glLineStipple)(GLint factor, GLushort pattern); #define glLineStipple _ptrc_glLineStipple -extern void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat width); #define glLineWidth _ptrc_glLineWidth -extern void (CODEGEN_FUNCPTR *_ptrc_glListBase)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glListBase)(GLuint base); #define glListBase _ptrc_glListBase -extern void (CODEGEN_FUNCPTR *_ptrc_glLoadIdentity)(); +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadIdentity)(void); #define glLoadIdentity _ptrc_glLoadIdentity -extern void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixd)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixd)(const GLdouble * m); #define glLoadMatrixd _ptrc_glLoadMatrixd -extern void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixf)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixf)(const GLfloat * m); #define glLoadMatrixf _ptrc_glLoadMatrixf -extern void (CODEGEN_FUNCPTR *_ptrc_glLoadName)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadName)(GLuint name); #define glLoadName _ptrc_glLoadName -extern void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum opcode); #define glLogicOp _ptrc_glLogicOp -extern void (CODEGEN_FUNCPTR *_ptrc_glMap1d)(GLenum, GLdouble, GLdouble, GLint, GLint, const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMap1d)(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points); #define glMap1d _ptrc_glMap1d -extern void (CODEGEN_FUNCPTR *_ptrc_glMap1f)(GLenum, GLfloat, GLfloat, GLint, GLint, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMap1f)(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points); #define glMap1f _ptrc_glMap1f -extern void (CODEGEN_FUNCPTR *_ptrc_glMap2d)(GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMap2d)(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points); #define glMap2d _ptrc_glMap2d -extern void (CODEGEN_FUNCPTR *_ptrc_glMap2f)(GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMap2f)(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points); #define glMap2f _ptrc_glMap2f -extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1d)(GLint, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1d)(GLint un, GLdouble u1, GLdouble u2); #define glMapGrid1d _ptrc_glMapGrid1d -extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1f)(GLint, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1f)(GLint un, GLfloat u1, GLfloat u2); #define glMapGrid1f _ptrc_glMapGrid1f -extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2d)(GLint, GLdouble, GLdouble, GLint, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2d)(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); #define glMapGrid2d _ptrc_glMapGrid2d -extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2f)(GLint, GLfloat, GLfloat, GLint, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2f)(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); #define glMapGrid2f _ptrc_glMapGrid2f -extern void (CODEGEN_FUNCPTR *_ptrc_glMaterialf)(GLenum, GLenum, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glMaterialf)(GLenum face, GLenum pname, GLfloat param); #define glMaterialf _ptrc_glMaterialf -extern void (CODEGEN_FUNCPTR *_ptrc_glMaterialfv)(GLenum, GLenum, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMaterialfv)(GLenum face, GLenum pname, const GLfloat * params); #define glMaterialfv _ptrc_glMaterialfv -extern void (CODEGEN_FUNCPTR *_ptrc_glMateriali)(GLenum, GLenum, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glMateriali)(GLenum face, GLenum pname, GLint param); #define glMateriali _ptrc_glMateriali -extern void (CODEGEN_FUNCPTR *_ptrc_glMaterialiv)(GLenum, GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMaterialiv)(GLenum face, GLenum pname, const GLint * params); #define glMaterialiv _ptrc_glMaterialiv -extern void (CODEGEN_FUNCPTR *_ptrc_glMatrixMode)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glMatrixMode)(GLenum mode); #define glMatrixMode _ptrc_glMatrixMode -extern void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixd)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixd)(const GLdouble * m); #define glMultMatrixd _ptrc_glMultMatrixd -extern void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixf)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixf)(const GLfloat * m); #define glMultMatrixf _ptrc_glMultMatrixf -extern void (CODEGEN_FUNCPTR *_ptrc_glNewList)(GLuint, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glNewList)(GLuint list, GLenum mode); #define glNewList _ptrc_glNewList -extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3b)(GLbyte, GLbyte, GLbyte); +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3b)(GLbyte nx, GLbyte ny, GLbyte nz); #define glNormal3b _ptrc_glNormal3b -extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3bv)(const GLbyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3bv)(const GLbyte * v); #define glNormal3bv _ptrc_glNormal3bv -extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3d)(GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3d)(GLdouble nx, GLdouble ny, GLdouble nz); #define glNormal3d _ptrc_glNormal3d -extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3dv)(const GLdouble * v); #define glNormal3dv _ptrc_glNormal3dv -extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3f)(GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3f)(GLfloat nx, GLfloat ny, GLfloat nz); #define glNormal3f _ptrc_glNormal3f -extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3fv)(const GLfloat * v); #define glNormal3fv _ptrc_glNormal3fv -extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3i)(GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3i)(GLint nx, GLint ny, GLint nz); #define glNormal3i _ptrc_glNormal3i -extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3iv)(const GLint * v); #define glNormal3iv _ptrc_glNormal3iv -extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3s)(GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3s)(GLshort nx, GLshort ny, GLshort nz); #define glNormal3s _ptrc_glNormal3s -extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3sv)(const GLshort * v); #define glNormal3sv _ptrc_glNormal3sv -extern void (CODEGEN_FUNCPTR *_ptrc_glOrtho)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glOrtho)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); #define glOrtho _ptrc_glOrtho -extern void (CODEGEN_FUNCPTR *_ptrc_glPassThrough)(GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glPassThrough)(GLfloat token); #define glPassThrough _ptrc_glPassThrough -extern void (CODEGEN_FUNCPTR *_ptrc_glPixelMapfv)(GLenum, GLsizei, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelMapfv)(GLenum map, GLsizei mapsize, const GLfloat * values); #define glPixelMapfv _ptrc_glPixelMapfv -extern void (CODEGEN_FUNCPTR *_ptrc_glPixelMapuiv)(GLenum, GLsizei, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelMapuiv)(GLenum map, GLsizei mapsize, const GLuint * values); #define glPixelMapuiv _ptrc_glPixelMapuiv -extern void (CODEGEN_FUNCPTR *_ptrc_glPixelMapusv)(GLenum, GLsizei, const GLushort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelMapusv)(GLenum map, GLsizei mapsize, const GLushort * values); #define glPixelMapusv _ptrc_glPixelMapusv -extern void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum pname, GLfloat param); #define glPixelStoref _ptrc_glPixelStoref -extern void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum pname, GLint param); #define glPixelStorei _ptrc_glPixelStorei -extern void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferf)(GLenum, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferf)(GLenum pname, GLfloat param); #define glPixelTransferf _ptrc_glPixelTransferf -extern void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferi)(GLenum, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferi)(GLenum pname, GLint param); #define glPixelTransferi _ptrc_glPixelTransferi -extern void (CODEGEN_FUNCPTR *_ptrc_glPixelZoom)(GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelZoom)(GLfloat xfactor, GLfloat yfactor); #define glPixelZoom _ptrc_glPixelZoom -extern void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat size); #define glPointSize _ptrc_glPointSize -extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum face, GLenum mode); #define glPolygonMode _ptrc_glPolygonMode -extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonStipple)(const GLubyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonStipple)(const GLubyte * mask); #define glPolygonStipple _ptrc_glPolygonStipple -extern void (CODEGEN_FUNCPTR *_ptrc_glPopAttrib)(); +extern void (CODEGEN_FUNCPTR *_ptrc_glPopAttrib)(void); #define glPopAttrib _ptrc_glPopAttrib -extern void (CODEGEN_FUNCPTR *_ptrc_glPopMatrix)(); +extern void (CODEGEN_FUNCPTR *_ptrc_glPopMatrix)(void); #define glPopMatrix _ptrc_glPopMatrix -extern void (CODEGEN_FUNCPTR *_ptrc_glPopName)(); +extern void (CODEGEN_FUNCPTR *_ptrc_glPopName)(void); #define glPopName _ptrc_glPopName -extern void (CODEGEN_FUNCPTR *_ptrc_glPushAttrib)(GLbitfield); +extern void (CODEGEN_FUNCPTR *_ptrc_glPushAttrib)(GLbitfield mask); #define glPushAttrib _ptrc_glPushAttrib -extern void (CODEGEN_FUNCPTR *_ptrc_glPushMatrix)(); +extern void (CODEGEN_FUNCPTR *_ptrc_glPushMatrix)(void); #define glPushMatrix _ptrc_glPushMatrix -extern void (CODEGEN_FUNCPTR *_ptrc_glPushName)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glPushName)(GLuint name); #define glPushName _ptrc_glPushName -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2d)(GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2d)(GLdouble x, GLdouble y); #define glRasterPos2d _ptrc_glRasterPos2d -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2dv)(const GLdouble * v); #define glRasterPos2dv _ptrc_glRasterPos2dv -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2f)(GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2f)(GLfloat x, GLfloat y); #define glRasterPos2f _ptrc_glRasterPos2f -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2fv)(const GLfloat * v); #define glRasterPos2fv _ptrc_glRasterPos2fv -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2i)(GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2i)(GLint x, GLint y); #define glRasterPos2i _ptrc_glRasterPos2i -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2iv)(const GLint * v); #define glRasterPos2iv _ptrc_glRasterPos2iv -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2s)(GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2s)(GLshort x, GLshort y); #define glRasterPos2s _ptrc_glRasterPos2s -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2sv)(const GLshort * v); #define glRasterPos2sv _ptrc_glRasterPos2sv -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3d)(GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3d)(GLdouble x, GLdouble y, GLdouble z); #define glRasterPos3d _ptrc_glRasterPos3d -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3dv)(const GLdouble * v); #define glRasterPos3dv _ptrc_glRasterPos3dv -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3f)(GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3f)(GLfloat x, GLfloat y, GLfloat z); #define glRasterPos3f _ptrc_glRasterPos3f -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3fv)(const GLfloat * v); #define glRasterPos3fv _ptrc_glRasterPos3fv -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3i)(GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3i)(GLint x, GLint y, GLint z); #define glRasterPos3i _ptrc_glRasterPos3i -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3iv)(const GLint * v); #define glRasterPos3iv _ptrc_glRasterPos3iv -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3s)(GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3s)(GLshort x, GLshort y, GLshort z); #define glRasterPos3s _ptrc_glRasterPos3s -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3sv)(const GLshort * v); #define glRasterPos3sv _ptrc_glRasterPos3sv -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4d)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); #define glRasterPos4d _ptrc_glRasterPos4d -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4dv)(const GLdouble * v); #define glRasterPos4dv _ptrc_glRasterPos4dv -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4f)(GLfloat, GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); #define glRasterPos4f _ptrc_glRasterPos4f -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4fv)(const GLfloat * v); #define glRasterPos4fv _ptrc_glRasterPos4fv -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4i)(GLint, GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4i)(GLint x, GLint y, GLint z, GLint w); #define glRasterPos4i _ptrc_glRasterPos4i -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4iv)(const GLint * v); #define glRasterPos4iv _ptrc_glRasterPos4iv -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4s)(GLshort, GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4s)(GLshort x, GLshort y, GLshort z, GLshort w); #define glRasterPos4s _ptrc_glRasterPos4s -extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4sv)(const GLshort * v); #define glRasterPos4sv _ptrc_glRasterPos4sv -extern void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum src); #define glReadBuffer _ptrc_glReadBuffer -extern void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels); #define glReadPixels _ptrc_glReadPixels -extern void (CODEGEN_FUNCPTR *_ptrc_glRectd)(GLdouble, GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glRectd)(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); #define glRectd _ptrc_glRectd -extern void (CODEGEN_FUNCPTR *_ptrc_glRectdv)(const GLdouble *, const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRectdv)(const GLdouble * v1, const GLdouble * v2); #define glRectdv _ptrc_glRectdv -extern void (CODEGEN_FUNCPTR *_ptrc_glRectf)(GLfloat, GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glRectf)(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); #define glRectf _ptrc_glRectf -extern void (CODEGEN_FUNCPTR *_ptrc_glRectfv)(const GLfloat *, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRectfv)(const GLfloat * v1, const GLfloat * v2); #define glRectfv _ptrc_glRectfv -extern void (CODEGEN_FUNCPTR *_ptrc_glRecti)(GLint, GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glRecti)(GLint x1, GLint y1, GLint x2, GLint y2); #define glRecti _ptrc_glRecti -extern void (CODEGEN_FUNCPTR *_ptrc_glRectiv)(const GLint *, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRectiv)(const GLint * v1, const GLint * v2); #define glRectiv _ptrc_glRectiv -extern void (CODEGEN_FUNCPTR *_ptrc_glRects)(GLshort, GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glRects)(GLshort x1, GLshort y1, GLshort x2, GLshort y2); #define glRects _ptrc_glRects -extern void (CODEGEN_FUNCPTR *_ptrc_glRectsv)(const GLshort *, const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glRectsv)(const GLshort * v1, const GLshort * v2); #define glRectsv _ptrc_glRectsv -extern GLint (CODEGEN_FUNCPTR *_ptrc_glRenderMode)(GLenum); +extern GLint (CODEGEN_FUNCPTR *_ptrc_glRenderMode)(GLenum mode); #define glRenderMode _ptrc_glRenderMode -extern void (CODEGEN_FUNCPTR *_ptrc_glRotated)(GLdouble, GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glRotated)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); #define glRotated _ptrc_glRotated -extern void (CODEGEN_FUNCPTR *_ptrc_glRotatef)(GLfloat, GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glRotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); #define glRotatef _ptrc_glRotatef -extern void (CODEGEN_FUNCPTR *_ptrc_glScaled)(GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glScaled)(GLdouble x, GLdouble y, GLdouble z); #define glScaled _ptrc_glScaled -extern void (CODEGEN_FUNCPTR *_ptrc_glScalef)(GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glScalef)(GLfloat x, GLfloat y, GLfloat z); #define glScalef _ptrc_glScalef -extern void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint, GLint, GLsizei, GLsizei); +extern void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint x, GLint y, GLsizei width, GLsizei height); #define glScissor _ptrc_glScissor -extern void (CODEGEN_FUNCPTR *_ptrc_glSelectBuffer)(GLsizei, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glSelectBuffer)(GLsizei size, GLuint * buffer); #define glSelectBuffer _ptrc_glSelectBuffer -extern void (CODEGEN_FUNCPTR *_ptrc_glShadeModel)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glShadeModel)(GLenum mode); #define glShadeModel _ptrc_glShadeModel -extern void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum, GLint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum func, GLint ref, GLuint mask); #define glStencilFunc _ptrc_glStencilFunc -extern void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint mask); #define glStencilMask _ptrc_glStencilMask -extern void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum, GLenum, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass); #define glStencilOp _ptrc_glStencilOp -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1d)(GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1d)(GLdouble s); #define glTexCoord1d _ptrc_glTexCoord1d -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1dv)(const GLdouble * v); #define glTexCoord1dv _ptrc_glTexCoord1dv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1f)(GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1f)(GLfloat s); #define glTexCoord1f _ptrc_glTexCoord1f -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1fv)(const GLfloat * v); #define glTexCoord1fv _ptrc_glTexCoord1fv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1i)(GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1i)(GLint s); #define glTexCoord1i _ptrc_glTexCoord1i -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1iv)(const GLint * v); #define glTexCoord1iv _ptrc_glTexCoord1iv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1s)(GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1s)(GLshort s); #define glTexCoord1s _ptrc_glTexCoord1s -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1sv)(const GLshort * v); #define glTexCoord1sv _ptrc_glTexCoord1sv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2d)(GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2d)(GLdouble s, GLdouble t); #define glTexCoord2d _ptrc_glTexCoord2d -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2dv)(const GLdouble * v); #define glTexCoord2dv _ptrc_glTexCoord2dv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2f)(GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2f)(GLfloat s, GLfloat t); #define glTexCoord2f _ptrc_glTexCoord2f -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2fv)(const GLfloat * v); #define glTexCoord2fv _ptrc_glTexCoord2fv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2i)(GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2i)(GLint s, GLint t); #define glTexCoord2i _ptrc_glTexCoord2i -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2iv)(const GLint * v); #define glTexCoord2iv _ptrc_glTexCoord2iv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2s)(GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2s)(GLshort s, GLshort t); #define glTexCoord2s _ptrc_glTexCoord2s -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2sv)(const GLshort * v); #define glTexCoord2sv _ptrc_glTexCoord2sv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3d)(GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3d)(GLdouble s, GLdouble t, GLdouble r); #define glTexCoord3d _ptrc_glTexCoord3d -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3dv)(const GLdouble * v); #define glTexCoord3dv _ptrc_glTexCoord3dv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3f)(GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3f)(GLfloat s, GLfloat t, GLfloat r); #define glTexCoord3f _ptrc_glTexCoord3f -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3fv)(const GLfloat * v); #define glTexCoord3fv _ptrc_glTexCoord3fv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3i)(GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3i)(GLint s, GLint t, GLint r); #define glTexCoord3i _ptrc_glTexCoord3i -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3iv)(const GLint * v); #define glTexCoord3iv _ptrc_glTexCoord3iv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3s)(GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3s)(GLshort s, GLshort t, GLshort r); #define glTexCoord3s _ptrc_glTexCoord3s -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3sv)(const GLshort * v); #define glTexCoord3sv _ptrc_glTexCoord3sv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4d)(GLdouble, GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4d)(GLdouble s, GLdouble t, GLdouble r, GLdouble q); #define glTexCoord4d _ptrc_glTexCoord4d -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4dv)(const GLdouble * v); #define glTexCoord4dv _ptrc_glTexCoord4dv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4f)(GLfloat, GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4f)(GLfloat s, GLfloat t, GLfloat r, GLfloat q); #define glTexCoord4f _ptrc_glTexCoord4f -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4fv)(const GLfloat * v); #define glTexCoord4fv _ptrc_glTexCoord4fv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4i)(GLint, GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4i)(GLint s, GLint t, GLint r, GLint q); #define glTexCoord4i _ptrc_glTexCoord4i -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4iv)(const GLint * v); #define glTexCoord4iv _ptrc_glTexCoord4iv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4s)(GLshort, GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4s)(GLshort s, GLshort t, GLshort r, GLshort q); #define glTexCoord4s _ptrc_glTexCoord4s -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4sv)(const GLshort * v); #define glTexCoord4sv _ptrc_glTexCoord4sv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnvf)(GLenum, GLenum, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnvf)(GLenum target, GLenum pname, GLfloat param); #define glTexEnvf _ptrc_glTexEnvf -extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnvfv)(GLenum, GLenum, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnvfv)(GLenum target, GLenum pname, const GLfloat * params); #define glTexEnvfv _ptrc_glTexEnvfv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnvi)(GLenum, GLenum, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnvi)(GLenum target, GLenum pname, GLint param); #define glTexEnvi _ptrc_glTexEnvi -extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnviv)(GLenum, GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnviv)(GLenum target, GLenum pname, const GLint * params); #define glTexEnviv _ptrc_glTexEnviv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexGend)(GLenum, GLenum, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGend)(GLenum coord, GLenum pname, GLdouble param); #define glTexGend _ptrc_glTexGend -extern void (CODEGEN_FUNCPTR *_ptrc_glTexGendv)(GLenum, GLenum, const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGendv)(GLenum coord, GLenum pname, const GLdouble * params); #define glTexGendv _ptrc_glTexGendv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexGenf)(GLenum, GLenum, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGenf)(GLenum coord, GLenum pname, GLfloat param); #define glTexGenf _ptrc_glTexGenf -extern void (CODEGEN_FUNCPTR *_ptrc_glTexGenfv)(GLenum, GLenum, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGenfv)(GLenum coord, GLenum pname, const GLfloat * params); #define glTexGenfv _ptrc_glTexGenfv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexGeni)(GLenum, GLenum, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGeni)(GLenum coord, GLenum pname, GLint param); #define glTexGeni _ptrc_glTexGeni -extern void (CODEGEN_FUNCPTR *_ptrc_glTexGeniv)(GLenum, GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGeniv)(GLenum coord, GLenum pname, const GLint * params); #define glTexGeniv _ptrc_glTexGeniv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void * pixels); #define glTexImage1D _ptrc_glTexImage1D -extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels); #define glTexImage2D _ptrc_glTexImage2D -extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum, GLenum, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum target, GLenum pname, GLfloat param); #define glTexParameterf _ptrc_glTexParameterf -extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum, GLenum, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum target, GLenum pname, const GLfloat * params); #define glTexParameterfv _ptrc_glTexParameterfv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum, GLenum, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum target, GLenum pname, GLint param); #define glTexParameteri _ptrc_glTexParameteri -extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum, GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum target, GLenum pname, const GLint * params); #define glTexParameteriv _ptrc_glTexParameteriv -extern void (CODEGEN_FUNCPTR *_ptrc_glTranslated)(GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glTranslated)(GLdouble x, GLdouble y, GLdouble z); #define glTranslated _ptrc_glTranslated -extern void (CODEGEN_FUNCPTR *_ptrc_glTranslatef)(GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glTranslatef)(GLfloat x, GLfloat y, GLfloat z); #define glTranslatef _ptrc_glTranslatef -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2d)(GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2d)(GLdouble x, GLdouble y); #define glVertex2d _ptrc_glVertex2d -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2dv)(const GLdouble * v); #define glVertex2dv _ptrc_glVertex2dv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2f)(GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2f)(GLfloat x, GLfloat y); #define glVertex2f _ptrc_glVertex2f -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2fv)(const GLfloat * v); #define glVertex2fv _ptrc_glVertex2fv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2i)(GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2i)(GLint x, GLint y); #define glVertex2i _ptrc_glVertex2i -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2iv)(const GLint * v); #define glVertex2iv _ptrc_glVertex2iv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2s)(GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2s)(GLshort x, GLshort y); #define glVertex2s _ptrc_glVertex2s -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2sv)(const GLshort * v); #define glVertex2sv _ptrc_glVertex2sv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3d)(GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3d)(GLdouble x, GLdouble y, GLdouble z); #define glVertex3d _ptrc_glVertex3d -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3dv)(const GLdouble * v); #define glVertex3dv _ptrc_glVertex3dv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3f)(GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3f)(GLfloat x, GLfloat y, GLfloat z); #define glVertex3f _ptrc_glVertex3f -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3fv)(const GLfloat * v); #define glVertex3fv _ptrc_glVertex3fv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3i)(GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3i)(GLint x, GLint y, GLint z); #define glVertex3i _ptrc_glVertex3i -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3iv)(const GLint * v); #define glVertex3iv _ptrc_glVertex3iv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3s)(GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3s)(GLshort x, GLshort y, GLshort z); #define glVertex3s _ptrc_glVertex3s -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3sv)(const GLshort * v); #define glVertex3sv _ptrc_glVertex3sv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4d)(GLdouble, GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4d)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); #define glVertex4d _ptrc_glVertex4d -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4dv)(const GLdouble * v); #define glVertex4dv _ptrc_glVertex4dv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4f)(GLfloat, GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); #define glVertex4f _ptrc_glVertex4f -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4fv)(const GLfloat * v); #define glVertex4fv _ptrc_glVertex4fv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4i)(GLint, GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4i)(GLint x, GLint y, GLint z, GLint w); #define glVertex4i _ptrc_glVertex4i -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4iv)(const GLint * v); #define glVertex4iv _ptrc_glVertex4iv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4s)(GLshort, GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4s)(GLshort x, GLshort y, GLshort z, GLshort w); #define glVertex4s _ptrc_glVertex4s -extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4sv)(const GLshort * v); #define glVertex4sv _ptrc_glVertex4sv -extern void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint, GLint, GLsizei, GLsizei); +extern void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint x, GLint y, GLsizei width, GLsizei height); #define glViewport _ptrc_glViewport -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glAreTexturesResident)(GLsizei, const GLuint *, GLboolean *); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glAreTexturesResident)(GLsizei n, const GLuint * textures, GLboolean * residences); #define glAreTexturesResident _ptrc_glAreTexturesResident -extern void (CODEGEN_FUNCPTR *_ptrc_glArrayElement)(GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glArrayElement)(GLint i); #define glArrayElement _ptrc_glArrayElement -extern void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum target, GLuint texture); #define glBindTexture _ptrc_glBindTexture -extern void (CODEGEN_FUNCPTR *_ptrc_glColorPointer)(GLint, GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glColorPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer); #define glColorPointer _ptrc_glColorPointer -extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); #define glCopyTexImage1D _ptrc_glCopyTexImage1D -extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); #define glCopyTexImage2D _ptrc_glCopyTexImage2D -extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei); +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); #define glCopyTexSubImage1D _ptrc_glCopyTexSubImage1D -extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); #define glCopyTexSubImage2D _ptrc_glCopyTexSubImage2D -extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei n, const GLuint * textures); #define glDeleteTextures _ptrc_glDeleteTextures -extern void (CODEGEN_FUNCPTR *_ptrc_glDisableClientState)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glDisableClientState)(GLenum ren_array); #define glDisableClientState _ptrc_glDisableClientState -extern void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum, GLint, GLsizei); +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum mode, GLint first, GLsizei count); #define glDrawArrays _ptrc_glDrawArrays -extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum, GLsizei, GLenum, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum mode, GLsizei count, GLenum type, const void * indices); #define glDrawElements _ptrc_glDrawElements -extern void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagPointer)(GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagPointer)(GLsizei stride, const void * pointer); #define glEdgeFlagPointer _ptrc_glEdgeFlagPointer -extern void (CODEGEN_FUNCPTR *_ptrc_glEnableClientState)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glEnableClientState)(GLenum ren_array); #define glEnableClientState _ptrc_glEnableClientState -extern void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei n, GLuint * textures); #define glGenTextures _ptrc_glGenTextures -extern void (CODEGEN_FUNCPTR *_ptrc_glGetPointerv)(GLenum, GLvoid **); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPointerv)(GLenum pname, void ** params); #define glGetPointerv _ptrc_glGetPointerv -extern void (CODEGEN_FUNCPTR *_ptrc_glIndexPointer)(GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexPointer)(GLenum type, GLsizei stride, const void * pointer); #define glIndexPointer _ptrc_glIndexPointer -extern void (CODEGEN_FUNCPTR *_ptrc_glIndexub)(GLubyte); +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexub)(GLubyte c); #define glIndexub _ptrc_glIndexub -extern void (CODEGEN_FUNCPTR *_ptrc_glIndexubv)(const GLubyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexubv)(const GLubyte * c); #define glIndexubv _ptrc_glIndexubv -extern void (CODEGEN_FUNCPTR *_ptrc_glInterleavedArrays)(GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glInterleavedArrays)(GLenum format, GLsizei stride, const void * pointer); #define glInterleavedArrays _ptrc_glInterleavedArrays -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint texture); #define glIsTexture _ptrc_glIsTexture -extern void (CODEGEN_FUNCPTR *_ptrc_glNormalPointer)(GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glNormalPointer)(GLenum type, GLsizei stride, const void * pointer); #define glNormalPointer _ptrc_glNormalPointer -extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat factor, GLfloat units); #define glPolygonOffset _ptrc_glPolygonOffset -extern void (CODEGEN_FUNCPTR *_ptrc_glPopClientAttrib)(); +extern void (CODEGEN_FUNCPTR *_ptrc_glPopClientAttrib)(void); #define glPopClientAttrib _ptrc_glPopClientAttrib -extern void (CODEGEN_FUNCPTR *_ptrc_glPrioritizeTextures)(GLsizei, const GLuint *, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glPrioritizeTextures)(GLsizei n, const GLuint * textures, const GLfloat * priorities); #define glPrioritizeTextures _ptrc_glPrioritizeTextures -extern void (CODEGEN_FUNCPTR *_ptrc_glPushClientAttrib)(GLbitfield); +extern void (CODEGEN_FUNCPTR *_ptrc_glPushClientAttrib)(GLbitfield mask); #define glPushClientAttrib _ptrc_glPushClientAttrib -extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoordPointer)(GLint, GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer); #define glTexCoordPointer _ptrc_glTexCoordPointer -extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels); #define glTexSubImage1D _ptrc_glTexSubImage1D -extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels); #define glTexSubImage2D _ptrc_glTexSubImage2D -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexPointer)(GLint, GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer); #define glVertexPointer _ptrc_glVertexPointer -extern void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat); -#define glBlendColor _ptrc_glBlendColor -extern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum); -#define glBlendEquation _ptrc_glBlendEquation -extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #define glCopyTexSubImage3D _ptrc_glCopyTexSubImage3D -extern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices); #define glDrawRangeElements _ptrc_glDrawRangeElements -extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels); #define glTexImage3D _ptrc_glTexImage3D -extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels); #define glTexSubImage3D _ptrc_glTexSubImage3D -extern void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum texture); #define glActiveTexture _ptrc_glActiveTexture -extern void (CODEGEN_FUNCPTR *_ptrc_glClientActiveTexture)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glClientActiveTexture)(GLenum texture); #define glClientActiveTexture _ptrc_glClientActiveTexture -extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data); #define glCompressedTexImage1D _ptrc_glCompressedTexImage1D -extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data); #define glCompressedTexImage2D _ptrc_glCompressedTexImage2D -extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data); #define glCompressedTexImage3D _ptrc_glCompressedTexImage3D -extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data); #define glCompressedTexSubImage1D _ptrc_glCompressedTexSubImage1D -extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data); #define glCompressedTexSubImage2D _ptrc_glCompressedTexSubImage2D -extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data); #define glCompressedTexSubImage3D _ptrc_glCompressedTexSubImage3D -extern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum, GLint, GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum target, GLint level, void * img); #define glGetCompressedTexImage _ptrc_glGetCompressedTexImage -extern void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixd)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixd)(const GLdouble * m); #define glLoadTransposeMatrixd _ptrc_glLoadTransposeMatrixd -extern void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixf)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixf)(const GLfloat * m); #define glLoadTransposeMatrixf _ptrc_glLoadTransposeMatrixf -extern void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixd)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixd)(const GLdouble * m); #define glMultTransposeMatrixd _ptrc_glMultTransposeMatrixd -extern void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixf)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixf)(const GLfloat * m); #define glMultTransposeMatrixf _ptrc_glMultTransposeMatrixf -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1d)(GLenum, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1d)(GLenum target, GLdouble s); #define glMultiTexCoord1d _ptrc_glMultiTexCoord1d -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1dv)(GLenum, const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1dv)(GLenum target, const GLdouble * v); #define glMultiTexCoord1dv _ptrc_glMultiTexCoord1dv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1f)(GLenum, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1f)(GLenum target, GLfloat s); #define glMultiTexCoord1f _ptrc_glMultiTexCoord1f -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1fv)(GLenum, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1fv)(GLenum target, const GLfloat * v); #define glMultiTexCoord1fv _ptrc_glMultiTexCoord1fv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1i)(GLenum, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1i)(GLenum target, GLint s); #define glMultiTexCoord1i _ptrc_glMultiTexCoord1i -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1iv)(GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1iv)(GLenum target, const GLint * v); #define glMultiTexCoord1iv _ptrc_glMultiTexCoord1iv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1s)(GLenum, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1s)(GLenum target, GLshort s); #define glMultiTexCoord1s _ptrc_glMultiTexCoord1s -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1sv)(GLenum, const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1sv)(GLenum target, const GLshort * v); #define glMultiTexCoord1sv _ptrc_glMultiTexCoord1sv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2d)(GLenum, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2d)(GLenum target, GLdouble s, GLdouble t); #define glMultiTexCoord2d _ptrc_glMultiTexCoord2d -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2dv)(GLenum, const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2dv)(GLenum target, const GLdouble * v); #define glMultiTexCoord2dv _ptrc_glMultiTexCoord2dv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2f)(GLenum, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2f)(GLenum target, GLfloat s, GLfloat t); #define glMultiTexCoord2f _ptrc_glMultiTexCoord2f -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2fv)(GLenum, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2fv)(GLenum target, const GLfloat * v); #define glMultiTexCoord2fv _ptrc_glMultiTexCoord2fv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2i)(GLenum, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2i)(GLenum target, GLint s, GLint t); #define glMultiTexCoord2i _ptrc_glMultiTexCoord2i -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2iv)(GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2iv)(GLenum target, const GLint * v); #define glMultiTexCoord2iv _ptrc_glMultiTexCoord2iv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2s)(GLenum, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2s)(GLenum target, GLshort s, GLshort t); #define glMultiTexCoord2s _ptrc_glMultiTexCoord2s -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2sv)(GLenum, const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2sv)(GLenum target, const GLshort * v); #define glMultiTexCoord2sv _ptrc_glMultiTexCoord2sv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3d)(GLenum, GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3d)(GLenum target, GLdouble s, GLdouble t, GLdouble r); #define glMultiTexCoord3d _ptrc_glMultiTexCoord3d -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3dv)(GLenum, const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3dv)(GLenum target, const GLdouble * v); #define glMultiTexCoord3dv _ptrc_glMultiTexCoord3dv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3f)(GLenum, GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3f)(GLenum target, GLfloat s, GLfloat t, GLfloat r); #define glMultiTexCoord3f _ptrc_glMultiTexCoord3f -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3fv)(GLenum, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3fv)(GLenum target, const GLfloat * v); #define glMultiTexCoord3fv _ptrc_glMultiTexCoord3fv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3i)(GLenum, GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3i)(GLenum target, GLint s, GLint t, GLint r); #define glMultiTexCoord3i _ptrc_glMultiTexCoord3i -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3iv)(GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3iv)(GLenum target, const GLint * v); #define glMultiTexCoord3iv _ptrc_glMultiTexCoord3iv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3s)(GLenum, GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3s)(GLenum target, GLshort s, GLshort t, GLshort r); #define glMultiTexCoord3s _ptrc_glMultiTexCoord3s -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3sv)(GLenum, const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3sv)(GLenum target, const GLshort * v); #define glMultiTexCoord3sv _ptrc_glMultiTexCoord3sv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4d)(GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4d)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); #define glMultiTexCoord4d _ptrc_glMultiTexCoord4d -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4dv)(GLenum, const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4dv)(GLenum target, const GLdouble * v); #define glMultiTexCoord4dv _ptrc_glMultiTexCoord4dv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4f)(GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4f)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); #define glMultiTexCoord4f _ptrc_glMultiTexCoord4f -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4fv)(GLenum, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4fv)(GLenum target, const GLfloat * v); #define glMultiTexCoord4fv _ptrc_glMultiTexCoord4fv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4i)(GLenum, GLint, GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4i)(GLenum target, GLint s, GLint t, GLint r, GLint q); #define glMultiTexCoord4i _ptrc_glMultiTexCoord4i -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4iv)(GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4iv)(GLenum target, const GLint * v); #define glMultiTexCoord4iv _ptrc_glMultiTexCoord4iv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4s)(GLenum, GLshort, GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4s)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); #define glMultiTexCoord4s _ptrc_glMultiTexCoord4s -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4sv)(GLenum, const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4sv)(GLenum target, const GLshort * v); #define glMultiTexCoord4sv _ptrc_glMultiTexCoord4sv -extern void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat, GLboolean); +extern void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat value, GLboolean invert); #define glSampleCoverage _ptrc_glSampleCoverage -extern void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#define glBlendColor _ptrc_glBlendColor +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum mode); +#define glBlendEquation _ptrc_glBlendEquation +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #define glBlendFuncSeparate _ptrc_glBlendFuncSeparate -extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordPointer)(GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordPointer)(GLenum type, GLsizei stride, const void * pointer); #define glFogCoordPointer _ptrc_glFogCoordPointer -extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordd)(GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordd)(GLdouble coord); #define glFogCoordd _ptrc_glFogCoordd -extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoorddv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoorddv)(const GLdouble * coord); #define glFogCoorddv _ptrc_glFogCoorddv -extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordf)(GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordf)(GLfloat coord); #define glFogCoordf _ptrc_glFogCoordf -extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordfv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordfv)(const GLfloat * coord); #define glFogCoordfv _ptrc_glFogCoordfv -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum, const GLint *, const GLsizei *, GLsizei); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei drawcount); #define glMultiDrawArrays _ptrc_glMultiDrawArrays -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount); #define glMultiDrawElements _ptrc_glMultiDrawElements -extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum pname, GLfloat param); #define glPointParameterf _ptrc_glPointParameterf -extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum pname, const GLfloat * params); #define glPointParameterfv _ptrc_glPointParameterfv -extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum pname, GLint param); #define glPointParameteri _ptrc_glPointParameteri -extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum pname, const GLint * params); #define glPointParameteriv _ptrc_glPointParameteriv -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3b)(GLbyte, GLbyte, GLbyte); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3b)(GLbyte red, GLbyte green, GLbyte blue); #define glSecondaryColor3b _ptrc_glSecondaryColor3b -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3bv)(const GLbyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3bv)(const GLbyte * v); #define glSecondaryColor3bv _ptrc_glSecondaryColor3bv -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3d)(GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3d)(GLdouble red, GLdouble green, GLdouble blue); #define glSecondaryColor3d _ptrc_glSecondaryColor3d -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3dv)(const GLdouble * v); #define glSecondaryColor3dv _ptrc_glSecondaryColor3dv -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3f)(GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3f)(GLfloat red, GLfloat green, GLfloat blue); #define glSecondaryColor3f _ptrc_glSecondaryColor3f -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3fv)(const GLfloat * v); #define glSecondaryColor3fv _ptrc_glSecondaryColor3fv -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3i)(GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3i)(GLint red, GLint green, GLint blue); #define glSecondaryColor3i _ptrc_glSecondaryColor3i -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3iv)(const GLint * v); #define glSecondaryColor3iv _ptrc_glSecondaryColor3iv -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3s)(GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3s)(GLshort red, GLshort green, GLshort blue); #define glSecondaryColor3s _ptrc_glSecondaryColor3s -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3sv)(const GLshort * v); #define glSecondaryColor3sv _ptrc_glSecondaryColor3sv -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ub)(GLubyte, GLubyte, GLubyte); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ub)(GLubyte red, GLubyte green, GLubyte blue); #define glSecondaryColor3ub _ptrc_glSecondaryColor3ub -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ubv)(const GLubyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ubv)(const GLubyte * v); #define glSecondaryColor3ubv _ptrc_glSecondaryColor3ubv -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ui)(GLuint, GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ui)(GLuint red, GLuint green, GLuint blue); #define glSecondaryColor3ui _ptrc_glSecondaryColor3ui -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3uiv)(const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3uiv)(const GLuint * v); #define glSecondaryColor3uiv _ptrc_glSecondaryColor3uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3us)(GLushort, GLushort, GLushort); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3us)(GLushort red, GLushort green, GLushort blue); #define glSecondaryColor3us _ptrc_glSecondaryColor3us -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3usv)(const GLushort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3usv)(const GLushort * v); #define glSecondaryColor3usv _ptrc_glSecondaryColor3usv -extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColorPointer)(GLint, GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColorPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer); #define glSecondaryColorPointer _ptrc_glSecondaryColorPointer -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2d)(GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2d)(GLdouble x, GLdouble y); #define glWindowPos2d _ptrc_glWindowPos2d -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2dv)(const GLdouble * v); #define glWindowPos2dv _ptrc_glWindowPos2dv -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2f)(GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2f)(GLfloat x, GLfloat y); #define glWindowPos2f _ptrc_glWindowPos2f -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2fv)(const GLfloat * v); #define glWindowPos2fv _ptrc_glWindowPos2fv -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2i)(GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2i)(GLint x, GLint y); #define glWindowPos2i _ptrc_glWindowPos2i -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2iv)(const GLint * v); #define glWindowPos2iv _ptrc_glWindowPos2iv -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2s)(GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2s)(GLshort x, GLshort y); #define glWindowPos2s _ptrc_glWindowPos2s -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2sv)(const GLshort * v); #define glWindowPos2sv _ptrc_glWindowPos2sv -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3d)(GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3d)(GLdouble x, GLdouble y, GLdouble z); #define glWindowPos3d _ptrc_glWindowPos3d -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3dv)(const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3dv)(const GLdouble * v); #define glWindowPos3dv _ptrc_glWindowPos3dv -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3f)(GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3f)(GLfloat x, GLfloat y, GLfloat z); #define glWindowPos3f _ptrc_glWindowPos3f -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3fv)(const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3fv)(const GLfloat * v); #define glWindowPos3fv _ptrc_glWindowPos3fv -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3i)(GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3i)(GLint x, GLint y, GLint z); #define glWindowPos3i _ptrc_glWindowPos3i -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3iv)(const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3iv)(const GLint * v); #define glWindowPos3iv _ptrc_glWindowPos3iv -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3s)(GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3s)(GLshort x, GLshort y, GLshort z); #define glWindowPos3s _ptrc_glWindowPos3s -extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3sv)(const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3sv)(const GLshort * v); #define glWindowPos3sv _ptrc_glWindowPos3sv -extern void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum target, GLuint id); #define glBeginQuery _ptrc_glBeginQuery -extern void (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum target, GLuint buffer); #define glBindBuffer _ptrc_glBindBuffer -extern void (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum, GLsizeiptr, const GLvoid *, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum target, GLsizeiptr size, const void * data, GLenum usage); #define glBufferData _ptrc_glBufferData -extern void (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data); #define glBufferSubData _ptrc_glBufferSubData -extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei n, const GLuint * buffers); #define glDeleteBuffers _ptrc_glDeleteBuffers -extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei n, const GLuint * ids); #define glDeleteQueries _ptrc_glDeleteQueries -extern void (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum target); #define glEndQuery _ptrc_glEndQuery -extern void (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei n, GLuint * buffers); #define glGenBuffers _ptrc_glGenBuffers -extern void (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei n, GLuint * ids); #define glGenQueries _ptrc_glGenQueries -extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum target, GLenum pname, GLint * params); #define glGetBufferParameteriv _ptrc_glGetBufferParameteriv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum, GLenum, GLvoid **); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum target, GLenum pname, void ** params); #define glGetBufferPointerv _ptrc_glGetBufferPointerv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum, GLintptr, GLsizeiptr, GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, void * data); #define glGetBufferSubData _ptrc_glGetBufferSubData -extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint id, GLenum pname, GLint * params); #define glGetQueryObjectiv _ptrc_glGetQueryObjectiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint, GLenum, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint id, GLenum pname, GLuint * params); #define glGetQueryObjectuiv _ptrc_glGetQueryObjectuiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum target, GLenum pname, GLint * params); #define glGetQueryiv _ptrc_glGetQueryiv -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint buffer); #define glIsBuffer _ptrc_glIsBuffer -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint id); #define glIsQuery _ptrc_glIsQuery -extern void * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum, GLenum); +extern void * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum target, GLenum access); #define glMapBuffer _ptrc_glMapBuffer -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum target); #define glUnmapBuffer _ptrc_glUnmapBuffer -extern void (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint program, GLuint shader); #define glAttachShader _ptrc_glAttachShader -extern void (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint, GLuint, const GLchar *); +extern void (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint program, GLuint index, const GLchar * name); #define glBindAttribLocation _ptrc_glBindAttribLocation -extern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha); #define glBlendEquationSeparate _ptrc_glBlendEquationSeparate -extern void (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint shader); #define glCompileShader _ptrc_glCompileShader -extern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)(); +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)(void); #define glCreateProgram _ptrc_glCreateProgram -extern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum); +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum type); #define glCreateShader _ptrc_glCreateShader -extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint program); #define glDeleteProgram _ptrc_glDeleteProgram -extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint shader); #define glDeleteShader _ptrc_glDeleteShader -extern void (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint program, GLuint shader); #define glDetachShader _ptrc_glDetachShader -extern void (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint index); #define glDisableVertexAttribArray _ptrc_glDisableVertexAttribArray -extern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei, const GLenum *); +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei n, const GLenum * bufs); #define glDrawBuffers _ptrc_glDrawBuffers -extern void (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint index); #define glEnableVertexAttribArray _ptrc_glEnableVertexAttribArray -extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); #define glGetActiveAttrib _ptrc_glGetActiveAttrib -extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); #define glGetActiveUniform _ptrc_glGetActiveUniform -extern void (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint, GLsizei, GLsizei *, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders); #define glGetAttachedShaders _ptrc_glGetAttachedShaders -extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint, const GLchar *); +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint program, const GLchar * name); #define glGetAttribLocation _ptrc_glGetAttribLocation -extern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog); #define glGetProgramInfoLog _ptrc_glGetProgramInfoLog -extern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint program, GLenum pname, GLint * params); #define glGetProgramiv _ptrc_glGetProgramiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog); #define glGetShaderInfoLog _ptrc_glGetShaderInfoLog -extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint, GLsizei, GLsizei *, GLchar *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source); #define glGetShaderSource _ptrc_glGetShaderSource -extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint shader, GLenum pname, GLint * params); #define glGetShaderiv _ptrc_glGetShaderiv -extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint, const GLchar *); +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint program, const GLchar * name); #define glGetUniformLocation _ptrc_glGetUniformLocation -extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint, GLint, GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint program, GLint location, GLfloat * params); #define glGetUniformfv _ptrc_glGetUniformfv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint, GLint, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint program, GLint location, GLint * params); #define glGetUniformiv _ptrc_glGetUniformiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint, GLenum, GLvoid **); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint index, GLenum pname, void ** pointer); #define glGetVertexAttribPointerv _ptrc_glGetVertexAttribPointerv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint, GLenum, GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint index, GLenum pname, GLdouble * params); #define glGetVertexAttribdv _ptrc_glGetVertexAttribdv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint, GLenum, GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat * params); #define glGetVertexAttribfv _ptrc_glGetVertexAttribfv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint index, GLenum pname, GLint * params); #define glGetVertexAttribiv _ptrc_glGetVertexAttribiv -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint program); #define glIsProgram _ptrc_glIsProgram -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint shader); #define glIsShader _ptrc_glIsShader -extern void (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint program); #define glLinkProgram _ptrc_glLinkProgram -extern void (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint, GLsizei, const GLchar *const*, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length); #define glShaderSource _ptrc_glShaderSource -extern void (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask); #define glStencilFuncSeparate _ptrc_glStencilFuncSeparate -extern void (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum face, GLuint mask); #define glStencilMaskSeparate _ptrc_glStencilMaskSeparate -extern void (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); #define glStencilOpSeparate _ptrc_glStencilOpSeparate -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint location, GLfloat v0); #define glUniform1f _ptrc_glUniform1f -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint, GLsizei, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint location, GLsizei count, const GLfloat * value); #define glUniform1fv _ptrc_glUniform1fv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint location, GLint v0); #define glUniform1i _ptrc_glUniform1i -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint, GLsizei, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint location, GLsizei count, const GLint * value); #define glUniform1iv _ptrc_glUniform1iv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint location, GLfloat v0, GLfloat v1); #define glUniform2f _ptrc_glUniform2f -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint, GLsizei, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint location, GLsizei count, const GLfloat * value); #define glUniform2fv _ptrc_glUniform2fv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint location, GLint v0, GLint v1); #define glUniform2i _ptrc_glUniform2i -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint, GLsizei, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint location, GLsizei count, const GLint * value); #define glUniform2iv _ptrc_glUniform2iv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint, GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); #define glUniform3f _ptrc_glUniform3f -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint, GLsizei, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint location, GLsizei count, const GLfloat * value); #define glUniform3fv _ptrc_glUniform3fv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint, GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint location, GLint v0, GLint v1, GLint v2); #define glUniform3i _ptrc_glUniform3i -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint, GLsizei, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint location, GLsizei count, const GLint * value); #define glUniform3iv _ptrc_glUniform3iv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); #define glUniform4f _ptrc_glUniform4f -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint, GLsizei, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint location, GLsizei count, const GLfloat * value); #define glUniform4fv _ptrc_glUniform4fv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint, GLint, GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); #define glUniform4i _ptrc_glUniform4i -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint, GLsizei, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint location, GLsizei count, const GLint * value); #define glUniform4iv _ptrc_glUniform4iv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); #define glUniformMatrix2fv _ptrc_glUniformMatrix2fv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); #define glUniformMatrix3fv _ptrc_glUniformMatrix3fv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); #define glUniformMatrix4fv _ptrc_glUniformMatrix4fv -extern void (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint program); #define glUseProgram _ptrc_glUseProgram -extern void (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint program); #define glValidateProgram _ptrc_glValidateProgram -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint index, GLdouble x); #define glVertexAttrib1d _ptrc_glVertexAttrib1d -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint, const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint index, const GLdouble * v); #define glVertexAttrib1dv _ptrc_glVertexAttrib1dv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint index, GLfloat x); #define glVertexAttrib1f _ptrc_glVertexAttrib1f -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint index, const GLfloat * v); #define glVertexAttrib1fv _ptrc_glVertexAttrib1fv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint index, GLshort x); #define glVertexAttrib1s _ptrc_glVertexAttrib1s -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint, const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint index, const GLshort * v); #define glVertexAttrib1sv _ptrc_glVertexAttrib1sv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint index, GLdouble x, GLdouble y); #define glVertexAttrib2d _ptrc_glVertexAttrib2d -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint, const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint index, const GLdouble * v); #define glVertexAttrib2dv _ptrc_glVertexAttrib2dv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint index, GLfloat x, GLfloat y); #define glVertexAttrib2f _ptrc_glVertexAttrib2f -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint index, const GLfloat * v); #define glVertexAttrib2fv _ptrc_glVertexAttrib2fv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint index, GLshort x, GLshort y); #define glVertexAttrib2s _ptrc_glVertexAttrib2s -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint, const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint index, const GLshort * v); #define glVertexAttrib2sv _ptrc_glVertexAttrib2sv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint, GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint index, GLdouble x, GLdouble y, GLdouble z); #define glVertexAttrib3d _ptrc_glVertexAttrib3d -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint, const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint index, const GLdouble * v); #define glVertexAttrib3dv _ptrc_glVertexAttrib3dv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint index, GLfloat x, GLfloat y, GLfloat z); #define glVertexAttrib3f _ptrc_glVertexAttrib3f -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint index, const GLfloat * v); #define glVertexAttrib3fv _ptrc_glVertexAttrib3fv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint, GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint index, GLshort x, GLshort y, GLshort z); #define glVertexAttrib3s _ptrc_glVertexAttrib3s -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint, const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint index, const GLshort * v); #define glVertexAttrib3sv _ptrc_glVertexAttrib3sv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint, const GLbyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint index, const GLbyte * v); #define glVertexAttrib4Nbv _ptrc_glVertexAttrib4Nbv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint index, const GLint * v); #define glVertexAttrib4Niv _ptrc_glVertexAttrib4Niv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint, const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint index, const GLshort * v); #define glVertexAttrib4Nsv _ptrc_glVertexAttrib4Nsv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); #define glVertexAttrib4Nub _ptrc_glVertexAttrib4Nub -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint, const GLubyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint index, const GLubyte * v); #define glVertexAttrib4Nubv _ptrc_glVertexAttrib4Nubv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint index, const GLuint * v); #define glVertexAttrib4Nuiv _ptrc_glVertexAttrib4Nuiv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint, const GLushort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint index, const GLushort * v); #define glVertexAttrib4Nusv _ptrc_glVertexAttrib4Nusv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint, const GLbyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint index, const GLbyte * v); #define glVertexAttrib4bv _ptrc_glVertexAttrib4bv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); #define glVertexAttrib4d _ptrc_glVertexAttrib4d -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint, const GLdouble *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint index, const GLdouble * v); #define glVertexAttrib4dv _ptrc_glVertexAttrib4dv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); #define glVertexAttrib4f _ptrc_glVertexAttrib4f -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint index, const GLfloat * v); #define glVertexAttrib4fv _ptrc_glVertexAttrib4fv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint index, const GLint * v); #define glVertexAttrib4iv _ptrc_glVertexAttrib4iv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint, GLshort, GLshort, GLshort, GLshort); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); #define glVertexAttrib4s _ptrc_glVertexAttrib4s -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint, const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint index, const GLshort * v); #define glVertexAttrib4sv _ptrc_glVertexAttrib4sv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint, const GLubyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint index, const GLubyte * v); #define glVertexAttrib4ubv _ptrc_glVertexAttrib4ubv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint index, const GLuint * v); #define glVertexAttrib4uiv _ptrc_glVertexAttrib4uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint, const GLushort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint index, const GLushort * v); #define glVertexAttrib4usv _ptrc_glVertexAttrib4usv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer); #define glVertexAttribPointer _ptrc_glVertexAttribPointer -extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); #define glUniformMatrix2x3fv _ptrc_glUniformMatrix2x3fv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); #define glUniformMatrix2x4fv _ptrc_glUniformMatrix2x4fv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); #define glUniformMatrix3x2fv _ptrc_glUniformMatrix3x2fv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); #define glUniformMatrix3x4fv _ptrc_glUniformMatrix3x4fv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); #define glUniformMatrix4x2fv _ptrc_glUniformMatrix4x2fv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); #define glUniformMatrix4x3fv _ptrc_glUniformMatrix4x3fv -extern void (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint id, GLenum mode); #define glBeginConditionalRender _ptrc_glBeginConditionalRender -extern void (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum primitiveMode); #define glBeginTransformFeedback _ptrc_glBeginTransformFeedback -extern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum, GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum target, GLuint index, GLuint buffer); #define glBindBufferBase _ptrc_glBindBufferBase -extern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr); +extern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); #define glBindBufferRange _ptrc_glBindBufferRange -extern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint, GLuint, const GLchar *); +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint program, GLuint color, const GLchar * name); #define glBindFragDataLocation _ptrc_glBindFragDataLocation -extern void (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum target, GLuint framebuffer); #define glBindFramebuffer _ptrc_glBindFramebuffer -extern void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum target, GLuint renderbuffer); #define glBindRenderbuffer _ptrc_glBindRenderbuffer -extern void (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint ren_array); #define glBindVertexArray _ptrc_glBindVertexArray -extern void (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #define glBlitFramebuffer _ptrc_glBlitFramebuffer -extern GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum); +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum target); #define glCheckFramebufferStatus _ptrc_glCheckFramebufferStatus -extern void (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum target, GLenum clamp); #define glClampColor _ptrc_glClampColor -extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum, GLint, GLfloat, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); #define glClearBufferfi _ptrc_glClearBufferfi -extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum, GLint, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum buffer, GLint drawbuffer, const GLfloat * value); #define glClearBufferfv _ptrc_glClearBufferfv -extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum, GLint, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum buffer, GLint drawbuffer, const GLint * value); #define glClearBufferiv _ptrc_glClearBufferiv -extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum, GLint, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum buffer, GLint drawbuffer, const GLuint * value); #define glClearBufferuiv _ptrc_glClearBufferuiv -extern void (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean); +extern void (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); #define glColorMaski _ptrc_glColorMaski -extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei n, const GLuint * framebuffers); #define glDeleteFramebuffers _ptrc_glDeleteFramebuffers -extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei n, const GLuint * renderbuffers); #define glDeleteRenderbuffers _ptrc_glDeleteRenderbuffers -extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei n, const GLuint * arrays); #define glDeleteVertexArrays _ptrc_glDeleteVertexArrays -extern void (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum target, GLuint index); #define glDisablei _ptrc_glDisablei -extern void (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum target, GLuint index); #define glEnablei _ptrc_glEnablei -extern void (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)(); +extern void (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)(void); #define glEndConditionalRender _ptrc_glEndConditionalRender -extern void (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)(); +extern void (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)(void); #define glEndTransformFeedback _ptrc_glEndTransformFeedback -extern void (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr); +extern void (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length); #define glFlushMappedBufferRange _ptrc_glFlushMappedBufferRange -extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); #define glFramebufferRenderbuffer _ptrc_glFramebufferRenderbuffer -extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum, GLenum, GLenum, GLuint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); #define glFramebufferTexture1D _ptrc_glFramebufferTexture1D -extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); #define glFramebufferTexture2D _ptrc_glFramebufferTexture2D -extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum, GLenum, GLenum, GLuint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); #define glFramebufferTexture3D _ptrc_glFramebufferTexture3D -extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum, GLenum, GLuint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); #define glFramebufferTextureLayer _ptrc_glFramebufferTextureLayer -extern void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei n, GLuint * framebuffers); #define glGenFramebuffers _ptrc_glGenFramebuffers -extern void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei n, GLuint * renderbuffers); #define glGenRenderbuffers _ptrc_glGenRenderbuffers -extern void (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei n, GLuint * arrays); #define glGenVertexArrays _ptrc_glGenVertexArrays -extern void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum target); #define glGenerateMipmap _ptrc_glGenerateMipmap -extern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum, GLuint, GLboolean *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum target, GLuint index, GLboolean * data); #define glGetBooleani_v _ptrc_glGetBooleani_v -extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint, const GLchar *); +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint program, const GLchar * name); #define glGetFragDataLocation _ptrc_glGetFragDataLocation -extern void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint * params); #define glGetFramebufferAttachmentParameteriv _ptrc_glGetFramebufferAttachmentParameteriv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum, GLuint, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum target, GLuint index, GLint * data); #define glGetIntegeri_v _ptrc_glGetIntegeri_v -extern void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint * params); #define glGetRenderbufferParameteriv _ptrc_glGetRenderbufferParameteriv -extern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum, GLuint); +extern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum name, GLuint index); #define glGetStringi _ptrc_glGetStringi -extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum target, GLenum pname, GLint * params); #define glGetTexParameterIiv _ptrc_glGetTexParameterIiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum, GLenum, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum target, GLenum pname, GLuint * params); #define glGetTexParameterIuiv _ptrc_glGetTexParameterIuiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name); #define glGetTransformFeedbackVarying _ptrc_glGetTransformFeedbackVarying -extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint, GLint, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint program, GLint location, GLuint * params); #define glGetUniformuiv _ptrc_glGetUniformuiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint index, GLenum pname, GLint * params); #define glGetVertexAttribIiv _ptrc_glGetVertexAttribIiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint, GLenum, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint index, GLenum pname, GLuint * params); #define glGetVertexAttribIuiv _ptrc_glGetVertexAttribIuiv -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum, GLuint); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum target, GLuint index); #define glIsEnabledi _ptrc_glIsEnabledi -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint framebuffer); #define glIsFramebuffer _ptrc_glIsFramebuffer -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint renderbuffer); #define glIsRenderbuffer _ptrc_glIsRenderbuffer -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint ren_array); #define glIsVertexArray _ptrc_glIsVertexArray -extern void * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield); +extern void * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); #define glMapBufferRange _ptrc_glMapBufferRange -extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei); +extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); #define glRenderbufferStorage _ptrc_glRenderbufferStorage -extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum, GLsizei, GLenum, GLsizei, GLsizei); +extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #define glRenderbufferStorageMultisample _ptrc_glRenderbufferStorageMultisample -extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum, GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum target, GLenum pname, const GLint * params); #define glTexParameterIiv _ptrc_glTexParameterIiv -extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum, GLenum, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum target, GLenum pname, const GLuint * params); #define glTexParameterIuiv _ptrc_glTexParameterIuiv -extern void (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint, GLsizei, const GLchar *const*, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode); #define glTransformFeedbackVaryings _ptrc_glTransformFeedbackVaryings -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint location, GLuint v0); #define glUniform1ui _ptrc_glUniform1ui -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint, GLsizei, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint location, GLsizei count, const GLuint * value); #define glUniform1uiv _ptrc_glUniform1uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint, GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint location, GLuint v0, GLuint v1); #define glUniform2ui _ptrc_glUniform2ui -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint, GLsizei, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint location, GLsizei count, const GLuint * value); #define glUniform2uiv _ptrc_glUniform2uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint, GLuint, GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint location, GLuint v0, GLuint v1, GLuint v2); #define glUniform3ui _ptrc_glUniform3ui -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint, GLsizei, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint location, GLsizei count, const GLuint * value); #define glUniform3uiv _ptrc_glUniform3uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint, GLuint, GLuint, GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); #define glUniform4ui _ptrc_glUniform4ui -extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint, GLsizei, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint location, GLsizei count, const GLuint * value); #define glUniform4uiv _ptrc_glUniform4uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint index, GLint x); #define glVertexAttribI1i _ptrc_glVertexAttribI1i -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint index, const GLint * v); #define glVertexAttribI1iv _ptrc_glVertexAttribI1iv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint index, GLuint x); #define glVertexAttribI1ui _ptrc_glVertexAttribI1ui -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint index, const GLuint * v); #define glVertexAttribI1uiv _ptrc_glVertexAttribI1uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint index, GLint x, GLint y); #define glVertexAttribI2i _ptrc_glVertexAttribI2i -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint index, const GLint * v); #define glVertexAttribI2iv _ptrc_glVertexAttribI2iv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint, GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint index, GLuint x, GLuint y); #define glVertexAttribI2ui _ptrc_glVertexAttribI2ui -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint index, const GLuint * v); #define glVertexAttribI2uiv _ptrc_glVertexAttribI2uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint, GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint index, GLint x, GLint y, GLint z); #define glVertexAttribI3i _ptrc_glVertexAttribI3i -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint index, const GLint * v); #define glVertexAttribI3iv _ptrc_glVertexAttribI3iv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint, GLuint, GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint index, GLuint x, GLuint y, GLuint z); #define glVertexAttribI3ui _ptrc_glVertexAttribI3ui -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint index, const GLuint * v); #define glVertexAttribI3uiv _ptrc_glVertexAttribI3uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint, const GLbyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint index, const GLbyte * v); #define glVertexAttribI4bv _ptrc_glVertexAttribI4bv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint, GLint, GLint, GLint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint index, GLint x, GLint y, GLint z, GLint w); #define glVertexAttribI4i _ptrc_glVertexAttribI4i -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint index, const GLint * v); #define glVertexAttribI4iv _ptrc_glVertexAttribI4iv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint, const GLshort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint index, const GLshort * v); #define glVertexAttribI4sv _ptrc_glVertexAttribI4sv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint, const GLubyte *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint index, const GLubyte * v); #define glVertexAttribI4ubv _ptrc_glVertexAttribI4ubv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint, GLuint, GLuint, GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); #define glVertexAttribI4ui _ptrc_glVertexAttribI4ui -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint index, const GLuint * v); #define glVertexAttribI4uiv _ptrc_glVertexAttribI4uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint, const GLushort *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint index, const GLushort * v); #define glVertexAttribI4usv _ptrc_glVertexAttribI4usv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint, GLint, GLenum, GLsizei, const GLvoid *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer); #define glVertexAttribIPointer _ptrc_glVertexAttribIPointer -extern void (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr); +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); #define glCopyBufferSubData _ptrc_glCopyBufferSubData -extern void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum, GLint, GLsizei, GLsizei); +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount); #define glDrawArraysInstanced _ptrc_glDrawArraysInstanced -extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei); +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount); #define glDrawElementsInstanced _ptrc_glDrawElementsInstanced -extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName); #define glGetActiveUniformBlockName _ptrc_glGetActiveUniformBlockName -extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint, GLuint, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params); #define glGetActiveUniformBlockiv _ptrc_glGetActiveUniformBlockiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformName); #define glGetActiveUniformName _ptrc_glGetActiveUniformName -extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint, GLsizei, const GLuint *, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params); #define glGetActiveUniformsiv _ptrc_glGetActiveUniformsiv -extern GLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint, const GLchar *); +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint program, const GLchar * uniformBlockName); #define glGetUniformBlockIndex _ptrc_glGetUniformBlockIndex -extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint, GLsizei, const GLchar *const*, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices); #define glGetUniformIndices _ptrc_glGetUniformIndices -extern void (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint index); #define glPrimitiveRestartIndex _ptrc_glPrimitiveRestartIndex -extern void (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum, GLenum, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum target, GLenum internalformat, GLuint buffer); #define glTexBuffer _ptrc_glTexBuffer -extern void (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint, GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); #define glUniformBlockBinding _ptrc_glUniformBlockBinding -extern GLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync, GLbitfield, GLuint64); +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout); #define glClientWaitSync _ptrc_glClientWaitSync -extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync); +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync sync); #define glDeleteSync _ptrc_glDeleteSync -extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex); #define glDrawElementsBaseVertex _ptrc_glDrawElementsBaseVertex -extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex); #define glDrawElementsInstancedBaseVertex _ptrc_glDrawElementsInstancedBaseVertex -extern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex); #define glDrawRangeElementsBaseVertex _ptrc_glDrawRangeElementsBaseVertex -extern GLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum, GLbitfield); +extern GLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum condition, GLbitfield flags); #define glFenceSync _ptrc_glFenceSync -extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum, GLenum, GLuint, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum target, GLenum attachment, GLuint texture, GLint level); #define glFramebufferTexture _ptrc_glFramebufferTexture -extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum, GLenum, GLint64 *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum target, GLenum pname, GLint64 * params); #define glGetBufferParameteri64v _ptrc_glGetBufferParameteri64v -extern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum, GLuint, GLint64 *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum target, GLuint index, GLint64 * data); #define glGetInteger64i_v _ptrc_glGetInteger64i_v -extern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum, GLint64 *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum pname, GLint64 * data); #define glGetInteger64v _ptrc_glGetInteger64v -extern void (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum, GLuint, GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum pname, GLuint index, GLfloat * val); #define glGetMultisamplefv _ptrc_glGetMultisamplefv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync, GLenum, GLsizei, GLsizei *, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values); #define glGetSynciv _ptrc_glGetSynciv -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync sync); #define glIsSync _ptrc_glIsSync -extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex); #define glMultiDrawElementsBaseVertex _ptrc_glMultiDrawElementsBaseVertex -extern void (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum mode); #define glProvokingVertex _ptrc_glProvokingVertex -extern void (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint, GLbitfield); +extern void (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint maskNumber, GLbitfield mask); #define glSampleMaski _ptrc_glSampleMaski -extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); #define glTexImage2DMultisample _ptrc_glTexImage2DMultisample -extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean); +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); #define glTexImage3DMultisample _ptrc_glTexImage3DMultisample -extern void (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync, GLbitfield, GLuint64); +extern void (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout); #define glWaitSync _ptrc_glWaitSync -extern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint, GLuint, GLuint, const GLchar *); +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name); #define glBindFragDataLocationIndexed _ptrc_glBindFragDataLocationIndexed -extern void (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint unit, GLuint sampler); #define glBindSampler _ptrc_glBindSampler -extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei count, const GLuint * samplers); #define glDeleteSamplers _ptrc_glDeleteSamplers -extern void (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei count, GLuint * samplers); #define glGenSamplers _ptrc_glGenSamplers -extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint, const GLchar *); +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint program, const GLchar * name); #define glGetFragDataIndex _ptrc_glGetFragDataIndex -extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint, GLenum, GLint64 *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint id, GLenum pname, GLint64 * params); #define glGetQueryObjecti64v _ptrc_glGetQueryObjecti64v -extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint, GLenum, GLuint64 *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint id, GLenum pname, GLuint64 * params); #define glGetQueryObjectui64v _ptrc_glGetQueryObjectui64v -extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint sampler, GLenum pname, GLint * params); #define glGetSamplerParameterIiv _ptrc_glGetSamplerParameterIiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint, GLenum, GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint sampler, GLenum pname, GLuint * params); #define glGetSamplerParameterIuiv _ptrc_glGetSamplerParameterIuiv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint, GLenum, GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint sampler, GLenum pname, GLfloat * params); #define glGetSamplerParameterfv _ptrc_glGetSamplerParameterfv -extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint, GLenum, GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint sampler, GLenum pname, GLint * params); #define glGetSamplerParameteriv _ptrc_glGetSamplerParameteriv -extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint); +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint sampler); #define glIsSampler _ptrc_glIsSampler -extern void (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint, GLenum); +extern void (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint id, GLenum target); #define glQueryCounter _ptrc_glQueryCounter -extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint, GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint sampler, GLenum pname, const GLint * param); #define glSamplerParameterIiv _ptrc_glSamplerParameterIiv -extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint, GLenum, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint sampler, GLenum pname, const GLuint * param); #define glSamplerParameterIuiv _ptrc_glSamplerParameterIuiv -extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint, GLenum, GLfloat); +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint sampler, GLenum pname, GLfloat param); #define glSamplerParameterf _ptrc_glSamplerParameterf -extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint, GLenum, const GLfloat *); +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint sampler, GLenum pname, const GLfloat * param); #define glSamplerParameterfv _ptrc_glSamplerParameterfv -extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint, GLenum, GLint); +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint sampler, GLenum pname, GLint param); #define glSamplerParameteri _ptrc_glSamplerParameteri -extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint, GLenum, const GLint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint sampler, GLenum pname, const GLint * param); #define glSamplerParameteriv _ptrc_glSamplerParameteriv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint index, GLuint divisor); #define glVertexAttribDivisor _ptrc_glVertexAttribDivisor -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint, GLenum, GLboolean, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value); #define glVertexAttribP1ui _ptrc_glVertexAttribP1ui -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint, GLenum, GLboolean, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); #define glVertexAttribP1uiv _ptrc_glVertexAttribP1uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint, GLenum, GLboolean, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value); #define glVertexAttribP2ui _ptrc_glVertexAttribP2ui -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint, GLenum, GLboolean, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); #define glVertexAttribP2uiv _ptrc_glVertexAttribP2uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint, GLenum, GLboolean, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value); #define glVertexAttribP3ui _ptrc_glVertexAttribP3ui -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint, GLenum, GLboolean, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); #define glVertexAttribP3uiv _ptrc_glVertexAttribP3uiv -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint, GLenum, GLboolean, GLuint); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value); #define glVertexAttribP4ui _ptrc_glVertexAttribP4ui -extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint, GLenum, GLboolean, const GLuint *); +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); #define glVertexAttribP4uiv _ptrc_glVertexAttribP4uiv enum ogl_LoadStatus @@ -2996,12 +3025,12 @@ enum ogl_LoadStatus int ogl_LoadFunctions(); -int ogl_GetMinorVersion(); -int ogl_GetMajorVersion(); +int ogl_GetMinorVersion(void); +int ogl_GetMajorVersion(void); int ogl_IsVersionGEQ(int majorVersion, int minorVersion); #ifdef __cplusplus } #endif /*__cplusplus*/ -#endif //POINTER_C_GENERATED_HEADER_OPENGL_H +#endif /*POINTER_C_GENERATED_HEADER_OPENGL_H*/ From 3816b469386578e776666977db69da18ac18b68b Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 30 Apr 2016 11:53:31 +0300 Subject: [PATCH 0538/1509] Fixed compilation of OS X with native backend TODO: check Linux build --- src/gl/system/gl_system.h | 3 -- src/posix/cocoa/i_video.mm | 41 ++++------------ src/posix/cocoa/sdlglvideo.h | 90 ++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 34 deletions(-) create mode 100644 src/posix/cocoa/sdlglvideo.h diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h index e9e3c5357..e5abe2ec5 100644 --- a/src/gl/system/gl_system.h +++ b/src/gl/system/gl_system.h @@ -86,9 +86,6 @@ template inline T max( T a, T b) { return (((a)>(b)) ? (a) : (b)); } #define _access(a,b) access(a,b) #endif -#ifndef _WIN32 -#include -#endif #ifdef LoadMenu diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 702b9a61b..d9505afa6 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -373,16 +373,7 @@ private: // --------------------------------------------------------------------------- -struct CapabilityChecker -{ - CapabilityChecker(); -}; - - -// --------------------------------------------------------------------------- - - -class CocoaOpenGLFrameBuffer : public OpenGLFrameBuffer, private CapabilityChecker, private NonCopyable +class CocoaOpenGLFrameBuffer : public OpenGLFrameBuffer, private NonCopyable { typedef OpenGLFrameBuffer Super; @@ -1164,12 +1155,14 @@ SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool , m_lock(-1) , m_isUpdatePending(false) , m_supportsGamma(true) -, m_gammaTexture(GAMMA_TABLE_SIZE, 1, false, false, true, true) +, m_gammaProgram("gamma_correction") +, m_gammaTexture(GAMMA_TABLE_SIZE, 1, true) { } SDLGLFB::SDLGLFB() -: m_gammaTexture(0, 0, false, false, false, false) +: m_gammaProgram(nullptr) +, m_gammaTexture(0, 0, false) { } @@ -1393,7 +1386,7 @@ bool BoundTextureSaveAsPNG(const GLenum target, const char* const path) RenderTarget::RenderTarget(const GLsizei width, const GLsizei height) : m_ID(0) , m_oldID(0) -, m_texture(width, height, false, false, true, true) +, m_texture(width, height, true) { glGenFramebuffersEXT(1, &m_ID); @@ -1439,20 +1432,6 @@ GLuint RenderTarget::GetBoundID() // --------------------------------------------------------------------------- -CapabilityChecker::CapabilityChecker() -{ - if (!(gl.flags & RFL_FRAMEBUFFER)) - { - I_FatalError( - "The graphics hardware in your system does not support Frame Buffer Object (FBO).\n" - "It is required to run this version of " GAMENAME ".\n"); - } -} - - -// --------------------------------------------------------------------------- - - CocoaOpenGLFrameBuffer::CocoaOpenGLFrameBuffer(void* hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : OpenGLFrameBuffer(hMonitor, width, height, bits, refreshHz, fullscreen) , m_renderTarget(width, height) @@ -1525,8 +1504,8 @@ void CocoaOpenGLFrameBuffer::DrawRenderTarget() { m_renderTarget.Unbind(); - m_renderTarget.GetColorTexture().Bind(0, 0); - m_gammaTexture.Bind(1, 0); + m_renderTarget.GetColorTexture().Bind(0, 0, 0); + m_gammaTexture.Bind(1, 0, 0); if (rbOpts.dirty) { @@ -1540,7 +1519,7 @@ void CocoaOpenGLFrameBuffer::DrawRenderTarget() glViewport(rbOpts.shiftX, rbOpts.shiftY, rbOpts.width, rbOpts.height); - m_gammaProgram.Bind(0.0f); + m_gammaProgram.Bind(); BoundTextureDraw2D(Width, Height); glViewport(0, 0, Width, Height); @@ -1550,7 +1529,7 @@ void CocoaOpenGLFrameBuffer::DrawRenderTarget() void CocoaOpenGLFrameBuffer::SetSmoothPicture(const bool smooth) { FHardwareTexture& texture = m_renderTarget.GetColorTexture(); - texture.Bind(0, 0); + texture.Bind(0, 0, 0); BoundTextureSetFilter(GL_TEXTURE_2D, smooth ? GL_LINEAR : GL_NEAREST); } diff --git a/src/posix/cocoa/sdlglvideo.h b/src/posix/cocoa/sdlglvideo.h new file mode 100644 index 000000000..2199ef420 --- /dev/null +++ b/src/posix/cocoa/sdlglvideo.h @@ -0,0 +1,90 @@ +/* + ** sdlglvideo.h + ** + **--------------------------------------------------------------------------- + ** Copyright 2012-2014 Alexey Lysiuk + ** All rights reserved. + ** + ** Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions + ** are met: + ** + ** 1. Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** 2. Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in the + ** documentation and/or other materials provided with the distribution. + ** 3. The name of the author may not be used to endorse or promote products + ** derived from this software without specific prior written permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + **--------------------------------------------------------------------------- + ** + */ + + +// IMPORTANT NOTE! +// This file was intentially named sdlglvideo.h but it has nothing with SDL +// The name was selected to avoid spreding of changes over the project +// The same applies to SDLGLFB class +// See gl/system/gl_framebuffer.h for details about its usage + + +#ifndef COCOA_SDLGLVIDEO_H_INCLUDED +#define COCOA_SDLGLVIDEO_H_INCLUDED + +#include "v_video.h" + +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_hwtexture.h" + + +class SDLGLFB : public DFrameBuffer +{ +public: + // This must have the same parameters as the Windows version, even if they are not used! + SDLGLFB(void *hMonitor, int width, int height, int, int, bool fullscreen); + ~SDLGLFB(); + + virtual bool Lock(bool buffered = true); + virtual void Unlock(); + virtual bool IsLocked(); + + virtual bool IsFullscreen(); + virtual void SetVSync(bool vsync); + + int GetTrueHeight() { return GetHeight(); } + +protected: + int m_lock; + bool m_isUpdatePending; + + bool m_supportsGamma; + + FShader m_gammaProgram; + FHardwareTexture m_gammaTexture; + + static const size_t GAMMA_TABLE_SIZE = 256; + uint32_t m_gammaTable[GAMMA_TABLE_SIZE]; + + + SDLGLFB(); + + void InitializeState(); + + bool CanUpdate(); + void SwapBuffers(); + + void SetGammaTable(WORD* table); +}; + +#endif // COCOA_SDLGLVIDEO_H_INCLUDED From 893d0c8915203ce4d25766872fbe508fea024706 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 30 Apr 2016 13:33:54 +0300 Subject: [PATCH 0539/1509] Added old method to collect extensions This required manual changes in generated file gl_load.c --- src/gl/system/gl_interface.cpp | 31 +++++++++++++++++++--- src/gl/system/gl_load.c | 48 +++++++++++++++++++++++++++++++--- 2 files changed, 73 insertions(+), 6 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index c09038bf8..a5dbf0533 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -66,10 +66,35 @@ static void CollectExtensions() int max = 0; glGetIntegerv(GL_NUM_EXTENSIONS, &max); - for(int i = 0; i < max; i++) + if (0 == max) { - extension = (const char*)glGetStringi(GL_EXTENSIONS, i); - m_Extensions.Push(FString(extension)); + // Try old method to collect extensions + const char *supported = (char *)glGetString(GL_EXTENSIONS); + + if (nullptr != supported) + { + char *extensions = new char[strlen(supported) + 1]; + strcpy(extensions, supported); + + char *extension = strtok(extensions, " "); + + while (extension) + { + m_Extensions.Push(FString(extension)); + extension = strtok(nullptr, " "); + } + + delete [] extensions; + } + } + else + { + // Use modern method to collect extensions + for (int i = 0; i < max; i++) + { + extension = (const char*)glGetStringi(GL_EXTENSIONS, i); + m_Extensions.Push(FString(extension)); + } } } diff --git a/src/gl/system/gl_load.c b/src/gl/system/gl_load.c index a6b7df013..d3de767c3 100644 --- a/src/gl/system/gl_load.c +++ b/src/gl/system/gl_load.c @@ -2375,8 +2375,41 @@ static void LoadExtByName(const char *extensionName) } } +static void ProcExtsFromExtString(const char *strExtList) +{ + size_t iExtListLen = strlen(strExtList); + const char *strExtListEnd = strExtList + iExtListLen; + const char *strCurrPos = strExtList; + char strWorkBuff[256]; -static void ProcExtsFromExtList(void) + while(*strCurrPos) + { + /*Get the extension at our position.*/ + int iStrLen = 0; + const char *strEndStr = strchr(strCurrPos, ' '); + int iStop = 0; + if(strEndStr == NULL) + { + strEndStr = strExtListEnd; + iStop = 1; + } + + iStrLen = (int)((ptrdiff_t)strEndStr - (ptrdiff_t)strCurrPos); + + if(iStrLen > 255) + return; + + strncpy(strWorkBuff, strCurrPos, iStrLen); + strWorkBuff[iStrLen] = '\0'; + + LoadExtByName(strWorkBuff); + + strCurrPos = strEndStr + 1; + if(iStop) break; + } +} + +static int ProcExtsFromExtList(void) { GLint iLoop; GLint iNumExtensions = 0; @@ -2387,6 +2420,8 @@ static void ProcExtsFromExtList(void) const char *strExtensionName = (const char *)_ptrc_glGetStringi(GL_EXTENSIONS, iLoop); LoadExtByName(strExtensionName); } + + return iNumExtensions; } int ogl_LoadFunctions() @@ -2398,8 +2433,15 @@ int ogl_LoadFunctions() if(!_ptrc_glGetIntegerv) return ogl_LOAD_FAILED; _ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi"); if(!_ptrc_glGetStringi) return ogl_LOAD_FAILED; - - ProcExtsFromExtList(); + + if (0 == ProcExtsFromExtList()) + { + _ptrc_glGetString = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGetString"); + if(!_ptrc_glGetString) return ogl_LOAD_FAILED; + + ProcExtsFromExtString((const char *)_ptrc_glGetString(GL_EXTENSIONS)); + } + numFailed = Load_Version_3_3(); if(numFailed == 0) From 8fa5fb6a9548cd6aa2f9ff6289617ff339b19cff Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 30 Apr 2016 13:35:03 +0300 Subject: [PATCH 0540/1509] Disabled gamma shader in OS X native backend --- src/posix/cocoa/i_video.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index d9505afa6..446585bd0 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -1437,7 +1437,7 @@ CocoaOpenGLFrameBuffer::CocoaOpenGLFrameBuffer(void* hMonitor, int width, int he , m_renderTarget(width, height) { SetSmoothPicture(gl_smooth_rendered); - +/* // Setup uniform samplers for gamma correction shader m_gammaProgram.Load("GammaCorrection", "shaders/glsl/main.vp", @@ -1449,7 +1449,7 @@ CocoaOpenGLFrameBuffer::CocoaOpenGLFrameBuffer(void* hMonitor, int width, int he glUniform1i(glGetUniformLocation(program, "backbuffer"), 0); glUniform1i(glGetUniformLocation(program, "gammaTable"), 1); glUseProgram(0); - +*/ // Fill render target with black color m_renderTarget.Bind(); @@ -1519,7 +1519,7 @@ void CocoaOpenGLFrameBuffer::DrawRenderTarget() glViewport(rbOpts.shiftX, rbOpts.shiftY, rbOpts.width, rbOpts.height); - m_gammaProgram.Bind(); + //m_gammaProgram.Bind(); BoundTextureDraw2D(Width, Height); glViewport(0, 0, Width, Height); From 461c97d25b3b7e98cc5c69d5f8ba2d295263e6fb Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 30 Apr 2016 16:28:19 +0300 Subject: [PATCH 0541/1509] Fixed remaining issue with shader patching for old OpenGL --- src/gl/shaders/gl_shader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index ea8f5aa92..1d5afd359 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -75,6 +75,7 @@ void PatchCommon(FString &code) void PatchVertShader(FString &code) { PatchCommon(code); + code.Substitute("in vec", "attribute vec"); code.Substitute("out vec", "varying vec"); code.Substitute("gl_ClipDistance", "//"); } From 6757447f1bfe21288b9754583c7f7256836cc9ce Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 30 Apr 2016 16:28:35 +0300 Subject: [PATCH 0542/1509] Enabled printing of OpenGL startup log on all platforms --- src/gl/system/gl_framebuffer.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index ca8a5dc32..4a05c2d17 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -130,12 +130,9 @@ void OpenGLFrameBuffer::InitializeState() if (first) { first=false; - // [BB] For some reason this crashes, if compiled with MinGW and optimization. Has to be investigated. -#ifdef _MSC_VER gl_PrintStartupLog(); -#endif - } + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glDepthFunc(GL_LESS); From 32412c7f754efc20f536517feb11534a89655378 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 30 Apr 2016 16:28:50 +0300 Subject: [PATCH 0543/1509] Disabled printing of junk values for unsupported extensions in OpenGL startup log on OS X --- src/gl/system/gl_interface.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index a5dbf0533..a13c1233c 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -238,10 +238,14 @@ void gl_LoadExtensions() int v; glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); gl.maxuniforms = v; + +#ifndef __APPLE__ + // GL_ARB_uniform_buffer_object extention is not supported on OS X glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); gl.maxuniformblock = v; glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v); gl.uniformblockalignment = v; +#endif // !__APPLE__ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -293,17 +297,25 @@ void gl_PrintStartupLog() Printf ("Max. fragment uniforms: %d\n", v); glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &v); Printf ("Max. vertex uniforms: %d\n", v); + +#ifndef __APPLE__ + // GL_ARB_uniform_buffer_object extention is not supported on OS X glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); Printf ("Max. uniform block size: %d\n", v); glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v); Printf ("Uniform block alignment: %d\n", v); +#endif // !__APPLE__ glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); Printf ("Max. varying: %d\n", v); + +#ifndef __APPLE__ + // ARB_shader_storage_buffer_object extention is not supported on OS X glGetIntegerv(GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS, &v); Printf("Max. combined shader storage blocks: %d\n", v); glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &v); Printf("Max. vertex shader storage blocks: %d\n", v); +#endif // !__APPLE__ // For shader-less, the special alphatexture translation must be changed to actually set the alpha, because it won't get translated by a shader. if (gl.glslversion == 0) From 4400d0cfcc4df9ca11d49f0ec495b580d4c53d02 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 30 Apr 2016 16:29:22 +0300 Subject: [PATCH 0544/1509] Fixed restoration of previously bound FBO --- src/gl/renderer/gl_renderer.cpp | 4 +++- src/gl/renderer/gl_renderer.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index e3b9b0a8b..9e8212c0b 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -122,6 +122,7 @@ void FGLRenderer::Initialize() else mLights = NULL; gl_RenderState.SetVertexBuffer(mVBO); mFBID = 0; + mOldFBID = 0; SetupLevel(); mShaderManager = new FShaderManager; @@ -237,6 +238,7 @@ void FGLRenderer::FlushTextures() bool FGLRenderer::StartOffscreen() { if (mFBID == 0) glGenFramebuffers(1, &mFBID); + glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &mOldFBID); glBindFramebuffer(GL_FRAMEBUFFER, mFBID); return true; } @@ -249,7 +251,7 @@ bool FGLRenderer::StartOffscreen() void FGLRenderer::EndOffscreen() { - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, mOldFBID); } //=========================================================================== diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 52ce5b2fa..a78b8c5dc 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -71,6 +71,7 @@ public: int gl_spriteindex; unsigned int mFBID; unsigned int mVAOID; + int mOldFBID; FTexture *gllight; FTexture *glpart2; From 50ab301bd8646e56e22b8465ad56d74c59eee3cf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Apr 2016 16:23:32 +0200 Subject: [PATCH 0545/1509] - fixed: If we want to support pre-GL3 hardware, we may not require the presence of glGetStringi. --- src/gl/system/gl_interface.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index c09038bf8..a5dbf0533 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -66,10 +66,35 @@ static void CollectExtensions() int max = 0; glGetIntegerv(GL_NUM_EXTENSIONS, &max); - for(int i = 0; i < max; i++) + if (0 == max) { - extension = (const char*)glGetStringi(GL_EXTENSIONS, i); - m_Extensions.Push(FString(extension)); + // Try old method to collect extensions + const char *supported = (char *)glGetString(GL_EXTENSIONS); + + if (nullptr != supported) + { + char *extensions = new char[strlen(supported) + 1]; + strcpy(extensions, supported); + + char *extension = strtok(extensions, " "); + + while (extension) + { + m_Extensions.Push(FString(extension)); + extension = strtok(nullptr, " "); + } + + delete [] extensions; + } + } + else + { + // Use modern method to collect extensions + for (int i = 0; i < max; i++) + { + extension = (const char*)glGetStringi(GL_EXTENSIONS, i); + m_Extensions.Push(FString(extension)); + } } } From c29e96d369f6479f5ffb90a59fc0f9f93f680895 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Apr 2016 16:31:09 +0200 Subject: [PATCH 0546/1509] - print buffer info only if the buffer type is used. - removed some GL specs that are not informative in GZDoom's context. --- src/gl/system/gl_interface.cpp | 52 +++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index a5dbf0533..19f6134c3 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -236,12 +236,23 @@ void gl_LoadExtensions() } int v; - glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); - gl.maxuniforms = v; - glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); - gl.maxuniformblock = v; - glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v); - gl.uniformblockalignment = v; + + if (gl.lightmethod != LM_SOFTWARE && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + { + glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); + gl.maxuniforms = v; + glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); + gl.maxuniformblock = v; + glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v); + gl.uniformblockalignment = v; + } + else + { + gl.maxuniforms = 0; + gl.maxuniformblock = 0; + gl.uniformblockalignment = 0; + } + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -289,21 +300,24 @@ void gl_PrintStartupLog() Printf("\nMax. texture size: %d\n", v); glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &v); Printf ("Max. texture units: %d\n", v); - glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); - Printf ("Max. fragment uniforms: %d\n", v); - glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &v); - Printf ("Max. vertex uniforms: %d\n", v); - glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); - Printf ("Max. uniform block size: %d\n", v); - glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v); - Printf ("Uniform block alignment: %d\n", v); - glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); Printf ("Max. varying: %d\n", v); - glGetIntegerv(GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS, &v); - Printf("Max. combined shader storage blocks: %d\n", v); - glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &v); - Printf("Max. vertex shader storage blocks: %d\n", v); + + if (gl.lightmethod != LM_SOFTWARE && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + { + glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); + Printf ("Max. uniform block size: %d\n", v); + glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v); + Printf ("Uniform block alignment: %d\n", v); + } + + if (gl.flags & RFL_SHADER_STORAGE_BUFFER) + { + glGetIntegerv(GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS, &v); + Printf("Max. combined shader storage blocks: %d\n", v); + glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &v); + Printf("Max. vertex shader storage blocks: %d\n", v); + } // For shader-less, the special alphatexture translation must be changed to actually set the alpha, because it won't get translated by a shader. if (gl.glslversion == 0) From d84e0792829566a9ecdf946090cb370d0149cb64 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Apr 2016 16:57:53 +0200 Subject: [PATCH 0547/1509] - render partial sprites oon the back side of a portal for actors in front of it. This is needed because the stencil will clip away those parts. --- src/gl/data/gl_data.h | 3 +- src/gl/data/gl_portaldata.cpp | 8 ++++- src/gl/scene/gl_portal.cpp | 13 +++++--- src/gl/scene/gl_portal.h | 6 ++-- src/gl/scene/gl_scene.cpp | 1 + src/gl/scene/gl_sprite.cpp | 58 ++++++++++++++++++++++++++++++++--- src/gl/scene/gl_wall.h | 2 +- 7 files changed, 78 insertions(+), 13 deletions(-) diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index 1e93f9a28..3e43408dd 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -59,7 +59,8 @@ struct FGLLinePortal // defines the complete span of this portal vertex_t *v1, *v2; // vertices, from v1 to v2 DVector2 delta; // precalculated v2 - v1 for side checking - FLinePortal *reference; // one of the associated line portals, for retrieving translation info etc. + TArray lines; + int validcount = 0; }; extern TArray portals; diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 0262f964b..2635c9a2e 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -443,7 +443,12 @@ void gl_InitPortals() tempindex[i] = glLinePortals.Size(); line_t *pSrcLine = linePortals[i].mOrigin; line_t *pLine = linePortals[i].mDestination; - FGLLinePortal glport = { pLine->v1, pLine->v2, {0, 0}, &linePortals[i] }; + FGLLinePortal glport; + + glport.v1 = pLine->v1; + glport.v2 = pLine->v2; + glport.delta = { 0, 0 }; + glport.lines.Push(&linePortals[i]); glLinePortals.Push(glport); // We cannot do this grouping for non-linked portals because they can be changed at run time. @@ -474,6 +479,7 @@ void gl_InitPortals() tempindex[j] = tempindex[i]; if (pLine->v1 == pLine2->v2) glLinePortals[tempindex[i]].v1 = pLine2->v1; else glLinePortals[tempindex[i]].v2 = pLine2->v2; + glLinePortals[tempindex[i]].lines.Push(&linePortals[j]); } } } diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index be25409e2..e4603cd1e 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -102,7 +102,7 @@ UniqueList UniqueHorizons; UniqueList UniquePlaneMirrors; UniqueList UniqueLineToLines; - +void gl_RenderActorsInPortal(FGLLinePortal *glport); //========================================================================== // @@ -1003,7 +1003,7 @@ void GLLineToLinePortal::DrawContents() GLRenderer->mClipPortal = this; - line_t *origin = glport->reference->mOrigin; + line_t *origin = glport->lines[0]->mOrigin; P_TranslatePortalXY(origin, ViewPos.X, ViewPos.Y); P_TranslatePortalAngle(origin, ViewAngle); P_TranslatePortalZ(origin, ViewPos.Z); @@ -1038,17 +1038,22 @@ void GLLineToLinePortal::DrawContents() currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7); } - GLRenderer->mViewActor = NULL; + GLRenderer->mViewActor = nullptr; GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); ClearClipper(); - gl_RenderState.SetClipLine(glport->reference->mDestination); + gl_RenderState.SetClipLine(glport->lines[0]->mDestination); gl_RenderState.EnableClipLine(true); GLRenderer->DrawScene(); gl_RenderState.EnableClipLine(false); RestoreMapSection(); } +void GLLineToLinePortal::RenderAttached() +{ + gl_RenderActorsInPortal(glport); +} + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 2962a4be1..c8afee2a6 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -169,6 +169,7 @@ public: virtual int ClipSubsector(subsector_t *sub) { return PClip_Inside; } virtual int ClipPoint(const DVector2 &pos) { return PClip_Inside; } virtual line_t *ClipLine() { return NULL; } + virtual void RenderAttached() {} static void BeginScene(); static void StartFrame(); @@ -194,10 +195,10 @@ struct GLLinePortal : public GLPortal GLLinePortal(FGLLinePortal *line) { - if (line->reference->mType != PORTT_LINKED) + if (line->lines[0]->mType != PORTT_LINKED) { // For non-linked portals we must check the actual linedef. - line_t *lline = line->reference->mDestination; + line_t *lline = line->lines[0]->mDestination; v1 = lline->v1; v2 = lline->v2; } @@ -258,6 +259,7 @@ protected: virtual void * GetSource() const { return glport; } virtual const char *GetName(); virtual line_t *ClipLine() { return line(); } + virtual void RenderAttached(); public: diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 1b6b8e87f..23c7a6318 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -308,6 +308,7 @@ void FGLRenderer::CreateScene() R_SetView(); validcount++; // used for processing sidedefs only once by the renderer. gl_RenderBSPNode (nodes + numnodes - 1); + if (GLRenderer->mCurrentPortal != NULL) GLRenderer->mCurrentPortal->RenderAttached(); Bsp.Unclock(); // And now the crappy hacks that have to be done to avoid rendering anomalies: diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 63a4f9c8c..8e36c766e 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -521,7 +521,7 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingp // //========================================================================== -void GLSprite::Process(AActor* thing, sector_t * sector, bool thruportal) +void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) { sector_t rs; sector_t * rendersector; @@ -552,7 +552,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, bool thruportal) // [RH] Interpolate the sprite's position to make it look smooth DVector3 thingpos = thing->InterpolatedPosition(r_TicFracF); - if (thruportal) thingpos += Displacements.getOffset(thing->Sector->PortalGroup, sector->PortalGroup); + if (thruportal == 1) thingpos += Displacements.getOffset(thing->Sector->PortalGroup, sector->PortalGroup); // Too close to the camera. This doesn't look good if it is a sprite. if (fabs(thingpos.X - ViewPos.X) < 2 && fabs(thingpos.Y - ViewPos.Y) < 2) @@ -581,7 +581,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, bool thruportal) thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again. } - if (GLRenderer->mClipPortal) + if (thruportal != 2 && GLRenderer->mClipPortal) { int clipres = GLRenderer->mClipPortal->ClipPoint(thingpos); if (clipres == GLPortal::PClip_InFront) return; @@ -601,7 +601,6 @@ void GLSprite::Process(AActor* thing, sector_t * sector, bool thruportal) topclip = rendersector->PortalBlocksMovement(sector_t::ceiling) ? LARGE_VALUE : rendersector->GetPortalPlaneZ(sector_t::ceiling); bottomclip = rendersector->PortalBlocksMovement(sector_t::floor) ? -LARGE_VALUE : rendersector->GetPortalPlaneZ(sector_t::floor); - x = thingpos.X; z = thingpos.Z - thing->Floorclip; y = thingpos.Y; @@ -1019,5 +1018,56 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s rendered_sprites++; } +//========================================================================== +// +// +// +//========================================================================== +void gl_RenderActorsInPortal(FGLLinePortal *glport) +{ + TMap processcheck; + if (glport->validcount == validcount) return; // only process once per frame + glport->validcount = validcount; + for (auto port : glport->lines) + { + line_t *line = port->mOrigin; + if (line->isLinePortal()) // only crossable ones + { + FLinePortal *port2 = port->mDestination->getPortal(); + // process only if the other side links back to this one. + if (port2 != nullptr && port->mDestination == port2->mOrigin && port->mOrigin == port2->mDestination) + { + for (portnode_t *node = port->render_thinglist; node != nullptr; node = node->m_snext) + { + AActor *th = node->m_thing; + + // process each actor only once per portal. + bool *check = processcheck.CheckKey(th); + if (check && *check) continue; + processcheck[th] = true; + + DAngle savedangle = th->Angles.Yaw; + DVector3 savedpos = th->Pos(); + DVector3 newpos = savedpos; + sector_t fakesector; + + P_TranslatePortalXY(line, newpos.X, newpos.Y); + P_TranslatePortalZ(line, newpos.Z); + P_TranslatePortalAngle(line, th->Angles.Yaw); + th->SetXYZ(newpos); + th->Prev += newpos - savedpos; + + GLSprite spr; + th->fillcolor = 0xff0000ff; + spr.Process(th, gl_FakeFlat(th->Sector, &fakesector, false), 2); + th->fillcolor = 0xffffffff; + th->Angles.Yaw = savedangle; + th->SetXYZ(savedpos); + th->Prev -= newpos - savedpos; + } + } + } + } +} \ No newline at end of file diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index c3b7f5de2..7872a37cb 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -359,7 +359,7 @@ public: void Draw(int pass); void PutSprite(bool translucent); - void Process(AActor* thing,sector_t * sector, bool thruportal = false); + void Process(AActor* thing,sector_t * sector, int thruportal = false); void ProcessParticle (particle_t *particle, sector_t *sector);//, int shade, int fakeside) void SetThingColor(PalEntry); From ca95371a2791ed0b6212c6e6460be36003ada6cc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Apr 2016 17:16:16 +0200 Subject: [PATCH 0548/1509] - fixed: gl_load.c did not handle the GL 2.x fallback for the lack of glGetStringi correctly, if that function was missing it just crashed. --- src/gl/system/gl_load.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gl/system/gl_load.c b/src/gl/system/gl_load.c index d3de767c3..9b89f2880 100644 --- a/src/gl/system/gl_load.c +++ b/src/gl/system/gl_load.c @@ -2413,6 +2413,9 @@ static int ProcExtsFromExtList(void) { GLint iLoop; GLint iNumExtensions = 0; + + if (_ptrc_glGetStringi == NULL) return 0; + _ptrc_glGetIntegerv(GL_NUM_EXTENSIONS, &iNumExtensions); for(iLoop = 0; iLoop < iNumExtensions; iLoop++) @@ -2432,8 +2435,7 @@ int ogl_LoadFunctions() _ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress("glGetIntegerv"); if(!_ptrc_glGetIntegerv) return ogl_LOAD_FAILED; _ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi"); - if(!_ptrc_glGetStringi) return ogl_LOAD_FAILED; - + if (0 == ProcExtsFromExtList()) { _ptrc_glGetString = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGetString"); From 51991ef22d3a510a2faf13687ae79ed1b1621535 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Apr 2016 23:18:37 +0200 Subject: [PATCH 0549/1509] * - render partial sprites on the front side of a portal for actors behind it. --- src/gl/scene/gl_wall.h | 1 + src/gl/scene/gl_walls.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 7872a37cb..0d8096e76 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -376,5 +376,6 @@ inline float Dist2(float x1,float y1,float x2,float y2) void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t *subsec); void gl_SetDynSpriteLight(AActor *actor, particle_t *particle); +void gl_RenderActorsInPortal(FGLLinePortal *glport); #endif diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 86fd36774..e337f1873 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -214,7 +214,15 @@ void GLWall::PutPortal(int ptype) case PORTALTYPE_LINETOLINE: portal=GLPortal::FindPortal(lineportal); - if (!portal) portal=new GLLineToLinePortal(lineportal); + if (!portal) + { + line_t *otherside = lineportal->lines[0]->mDestination; + if (otherside != NULL) + { + gl_RenderActorsInPortal(linePortalToGL[otherside->portalindex]); + } + portal = new GLLineToLinePortal(lineportal); + } portal->AddLine(this); break; From b320787102ab0ef6502517f595a6fdeccf851366 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 30 Apr 2016 15:52:39 -0400 Subject: [PATCH 0550/1509] Implement new CVAR gl_billboard_faces_camera, which orients sprites toward camera, rather than along view direction. # Conflicts: # gz3doom/GZ3DoomRiftMonitor1.bat # src/gl/scene/gl_sprite.cpp # src/gl/scene/gl_stereo3d.cpp --- src/gl/scene/gl_sprite.cpp | 42 ++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 8e36c766e..bc633e741 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -73,6 +73,7 @@ CVAR(Float, gl_sclipthreshold, 10.0, CVAR_ARCHIVE) CVAR(Float, gl_sclipfactor, 1.8, CVAR_ARCHIVE) CVAR(Int, gl_particles_style, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // 0 = square, 1 = round, 2 = smooth CVAR(Int, gl_billboard_mode, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, gl_billboard_faces_camera, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, gl_billboard_particles, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Int, gl_enhanced_nv_stealth, 3, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CUSTOM_CVAR(Int, gl_fuzztype, 0, CVAR_ARCHIVE) @@ -262,6 +263,8 @@ void GLSprite::Draw(int pass) //&& GLRenderer->mViewActor != NULL && (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD)))); + const bool drawBillboardFacingCamera = gl_billboard_faces_camera; + gl_RenderState.Apply(); Vector v1; @@ -269,11 +272,9 @@ void GLSprite::Draw(int pass) Vector v3; Vector v4; - if (drawWithXYBillboard) + if (drawWithXYBillboard || drawBillboardFacingCamera) { - // Rotate the sprite about the vector starting at the center of the sprite - // triangle strip and with direction orthogonal to where the player is looking - // in the x/y plane. + // Compute center of sprite float xcenter = (x1 + x2)*0.5; float ycenter = (y1 + y2)*0.5; float zcenter = (z1 + z2)*0.5; @@ -281,17 +282,40 @@ void GLSprite::Draw(int pass) Matrix3x4 mat; mat.MakeIdentity(); - mat.Translate(xcenter, zcenter, ycenter); - mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); - mat.Translate(-xcenter, -zcenter, -ycenter); + + if (drawWithXYBillboard) + { + // Rotate the sprite about the vector starting at the center of the sprite + // triangle strip and with direction orthogonal to where the player is looking + // in the x/y plane. + mat.Translate(xcenter, zcenter, ycenter); + mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); + mat.Translate(-xcenter, -zcenter, -ycenter); + } + + if (drawBillboardFacingCamera) { + // [CMB] Rotate relative to camera XY position, not just camera direction, + // which is nicer in VR + float xrel = xcenter - FIXED2FLOAT(GLRenderer->mViewActor->X()); + float yrel = ycenter - FIXED2FLOAT(GLRenderer->mViewActor->Y()); + float zrel = zcenter - FIXED2FLOAT(GLRenderer->mViewActor->Z()); + + float absAngleDeg = RAD2DEG(atan2(-yrel, xrel)); + float counterRotationDeg = 270. - float(GLRenderer->mAngles.Yaw); // counteracts existing sprite rotation + float relAngleDeg = counterRotationDeg + absAngleDeg; + + mat.Translate(xcenter, zcenter, ycenter); + mat.Rotate(0, 1, 0, relAngleDeg); + mat.Translate(-xcenter, -zcenter, -ycenter); + } + v1 = mat * Vector(x1, z1, y1); v2 = mat * Vector(x2, z1, y2); v3 = mat * Vector(x1, z2, y1); v4 = mat * Vector(x2, z2, y2); } - else + else { - v1 = Vector(x1, z1, y1); v2 = Vector(x2, z1, y2); v3 = Vector(x1, z2, y1); From 5a3300530334766a98f5c70cff1e5fa8c46df44c Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 30 Apr 2016 16:08:13 -0400 Subject: [PATCH 0551/1509] Reorder two billboard rotations, so they work together correctly. Fixes #126 # Conflicts: # src/gl/scene/gl_sprite.cpp --- src/gl/scene/gl_sprite.cpp | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index bc633e741..4fac67959 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -282,39 +282,35 @@ void GLSprite::Draw(int pass) Matrix3x4 mat; mat.MakeIdentity(); + mat.Translate(xcenter, zcenter, ycenter); // move to sprite center + + // Order of rotations matters. Perform yaw rotation (Y, face camera) before pitch (X, tilt up/down). + if (drawBillboardFacingCamera) { + // [CMB] Rotate relative to camera XY position, not just camera direction, + // which is nicer in VR + float xrel = xcenter - FIXED2FLOAT(GLRenderer->mViewActor->X()); + float yrel = ycenter - FIXED2FLOAT(GLRenderer->mViewActor->Y()); + float absAngleDeg = RAD2DEG(atan2(-yrel, xrel)); + float counterRotationDeg = 270. - float(GLRenderer->mAngles.Yaw); // counteracts existing sprite rotation + float relAngleDeg = counterRotationDeg + absAngleDeg; + + mat.Rotate(0, 1, 0, relAngleDeg); + } if (drawWithXYBillboard) { // Rotate the sprite about the vector starting at the center of the sprite // triangle strip and with direction orthogonal to where the player is looking // in the x/y plane. - mat.Translate(xcenter, zcenter, ycenter); mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); - mat.Translate(-xcenter, -zcenter, -ycenter); } - - if (drawBillboardFacingCamera) { - // [CMB] Rotate relative to camera XY position, not just camera direction, - // which is nicer in VR - float xrel = xcenter - FIXED2FLOAT(GLRenderer->mViewActor->X()); - float yrel = ycenter - FIXED2FLOAT(GLRenderer->mViewActor->Y()); - float zrel = zcenter - FIXED2FLOAT(GLRenderer->mViewActor->Z()); - - float absAngleDeg = RAD2DEG(atan2(-yrel, xrel)); - float counterRotationDeg = 270. - float(GLRenderer->mAngles.Yaw); // counteracts existing sprite rotation - float relAngleDeg = counterRotationDeg + absAngleDeg; - - mat.Translate(xcenter, zcenter, ycenter); - mat.Rotate(0, 1, 0, relAngleDeg); - mat.Translate(-xcenter, -zcenter, -ycenter); - } - + mat.Translate(-xcenter, -zcenter, -ycenter); // retreat from sprite center v1 = mat * Vector(x1, z1, y1); v2 = mat * Vector(x2, z1, y2); v3 = mat * Vector(x1, z2, y1); v4 = mat * Vector(x2, z2, y2); } - else + else // traditional "Y" billboard mode { v1 = Vector(x1, z1, y1); v2 = Vector(x2, z1, y2); From ed6cf6cf1e8ab11d2d0ed2ba133fc614c0e492ac Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 30 Apr 2016 16:23:31 -0400 Subject: [PATCH 0552/1509] Add menu option for new "sprites face camera" mode. # Conflicts: # wadsrc/static/menudef.z --- wadsrc/static/menudef.z | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index ddaf82e7d..3c2541fd7 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -184,6 +184,7 @@ OptionMenu "GLPrefOptions" Option "$GLPREFMNU_SPRBLEND", gl_sprite_blend, "OnOff" Option "$GLPREFMNU_FUZZSTYLE", gl_fuzztype, "FuzzStyle" Option "$GLPREFMNU_SPRBILLBOARD", gl_billboard_mode, "BillboardModes" + Option "$GLPREFMNU_SPRBFACCAMRA", gl_billboard_faces_camera, "OnOff" Option "$GLPREFMNU_PARTICLESTYLE", gl_particles_style, "Particles" Slider "$GLPREFMNU_AMBLIGHT", gl_light_ambient, 1.0, 255.0, 5.0 Option "$GLPREFMNU_RENDERQUALITY", gl_render_precise, "Precision" From c4590a2615a1ec96c7981b7f7629b56fd49ff34d Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 30 Apr 2016 17:03:41 -0400 Subject: [PATCH 0553/1509] Fix locale string for "sprite billboard faces camera" menu option. --- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.z | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 815ebd088..bc8c989af 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2607,6 +2607,7 @@ GLPREFMNU_SPRCLIP = "Adjust sprite clipping"; GLPREFMNU_SPRBLEND = "Smooth sprite edges"; GLPREFMNU_FUZZSTYLE = "Fuzz Style"; GLPREFMNU_SPRBILLBOARD = "Sprite billboard"; +GLPREFMNU_SPRBILLFACECAMERA = "Sprites face camera"; GLPREFMNU_PARTICLESTYLE = "Particle style"; GLPREFMNU_AMBLIGHT = "Ambient light level"; GLPREFMNU_RENDERQUALITY = "Rendering quality"; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 3c2541fd7..7f7791954 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -184,7 +184,7 @@ OptionMenu "GLPrefOptions" Option "$GLPREFMNU_SPRBLEND", gl_sprite_blend, "OnOff" Option "$GLPREFMNU_FUZZSTYLE", gl_fuzztype, "FuzzStyle" Option "$GLPREFMNU_SPRBILLBOARD", gl_billboard_mode, "BillboardModes" - Option "$GLPREFMNU_SPRBFACCAMRA", gl_billboard_faces_camera, "OnOff" + Option "$GLPREFMNU_SPRBILLFACECAMERA", gl_billboard_faces_camera, "OnOff" Option "$GLPREFMNU_PARTICLESTYLE", gl_particles_style, "Particles" Slider "$GLPREFMNU_AMBLIGHT", gl_light_ambient, 1.0, 255.0, 5.0 Option "$GLPREFMNU_RENDERQUALITY", gl_render_precise, "Precision" From 6d95c9d54468d69584a516e965f278571ab4ea35 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 30 Apr 2016 17:27:18 -0400 Subject: [PATCH 0554/1509] Fix floating point update for camera facing billboard mode. --- src/gl/scene/gl_sprite.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 4fac67959..70669fb33 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -278,7 +278,6 @@ void GLSprite::Draw(int pass) float xcenter = (x1 + x2)*0.5; float ycenter = (y1 + y2)*0.5; float zcenter = (z1 + z2)*0.5; - float angleRad = (270. - GLRenderer->mAngles.Yaw).Radians(); Matrix3x4 mat; mat.MakeIdentity(); @@ -288,10 +287,10 @@ void GLSprite::Draw(int pass) if (drawBillboardFacingCamera) { // [CMB] Rotate relative to camera XY position, not just camera direction, // which is nicer in VR - float xrel = xcenter - FIXED2FLOAT(GLRenderer->mViewActor->X()); - float yrel = ycenter - FIXED2FLOAT(GLRenderer->mViewActor->Y()); + float xrel = xcenter - GLRenderer->mViewActor->X(); + float yrel = ycenter - GLRenderer->mViewActor->Y(); float absAngleDeg = RAD2DEG(atan2(-yrel, xrel)); - float counterRotationDeg = 270. - float(GLRenderer->mAngles.Yaw); // counteracts existing sprite rotation + float counterRotationDeg = 270. - GLRenderer->mAngles.Yaw.Degrees; // counteracts existing sprite rotation float relAngleDeg = counterRotationDeg + absAngleDeg; mat.Rotate(0, 1, 0, relAngleDeg); @@ -302,6 +301,8 @@ void GLSprite::Draw(int pass) // Rotate the sprite about the vector starting at the center of the sprite // triangle strip and with direction orthogonal to where the player is looking // in the x/y plane. + float angleRad = (270. - GLRenderer->mAngles.Yaw).Radians(); + mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); } mat.Translate(-xcenter, -zcenter, -ycenter); // retreat from sprite center From 138c6ea25e7b6c49336249f5a07cd9e382ca6fac Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 1 May 2016 11:45:57 +0300 Subject: [PATCH 0555/1509] Fixed black screen issue in OS X native backend There was inconsistency with global render state --- src/posix/cocoa/i_video.mm | 50 ++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 446585bd0..726733b05 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -58,6 +58,8 @@ #include "v_video.h" #include "version.h" +#include "gl/system/gl_system.h" +#include "gl/data/gl_vertexbuffer.h" #include "gl/renderer/gl_renderer.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_interface.h" @@ -1278,36 +1280,30 @@ void BoundTextureSetFilter(const GLenum target, const GLint filter) void BoundTextureDraw2D(const GLsizei width, const GLsizei height) { - const bool flipX = width < 0; - const bool flipY = height < 0; + gl_RenderState.SetTextureMode(TM_OPAQUE); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_RenderState.ResetColor(); + gl_RenderState.Apply(); - const float u0 = flipX ? 1.0f : 0.0f; - const float v0 = flipY ? 1.0f : 0.0f; - const float u1 = flipX ? 0.0f : 1.0f; - const float v1 = flipY ? 0.0f : 1.0f; + static const float x = 0.f; + static const float y = 0.f; + const float w = float(width); + const float h = float(height); - const float x1 = 0.0f; - const float y1 = 0.0f; - const float x2 = abs(width ); - const float y2 = abs(height); + static const float u1 = 0.f; + static const float v1 = 1.f; + static const float u2 = 1.f; + static const float v2 = 0.f; - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); + FFlatVertexBuffer* const vbo = GLRenderer->mVBO; + FFlatVertex* ptr = vbo->GetBuffer(); - glBegin(GL_QUADS); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glTexCoord2f(u0, v1); - glVertex2f(x1, y1); - glTexCoord2f(u1, v1); - glVertex2f(x2, y1); - glTexCoord2f(u1, v0); - glVertex2f(x2, y2); - glTexCoord2f(u0, v0); - glVertex2f(x1, y2); - glEnd(); + ptr->Set(x, y, 0, u1, v1); ++ptr; + ptr->Set(x, y + h, 0, u1, v2); ++ptr; + ptr->Set(x + w, y, 0, u2, v1); ++ptr; + ptr->Set(x + w, y + h, 0, u2, v2); ++ptr; - glEnable(GL_ALPHA_TEST); - glEnable(GL_BLEND); + vbo->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } bool BoundTextureSaveAsPNG(const GLenum target, const char* const path) @@ -1504,8 +1500,8 @@ void CocoaOpenGLFrameBuffer::DrawRenderTarget() { m_renderTarget.Unbind(); - m_renderTarget.GetColorTexture().Bind(0, 0, 0); - m_gammaTexture.Bind(1, 0, 0); + m_renderTarget.GetColorTexture().Bind(0, 0, false); + m_gammaTexture.Bind(1, 0, false); if (rbOpts.dirty) { From 1deb9742de264c29005746f61adb19d5175cc4ba Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 1 May 2016 11:46:49 +0300 Subject: [PATCH 0556/1509] Do not call UBO functions when no extension available --- src/gl/shaders/gl_shader.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 1d5afd359..d41adcbe7 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -294,8 +294,11 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * modelmatrix_index = glGetUniformLocation(hShader, "ModelMatrix"); texturematrix_index = glGetUniformLocation(hShader, "TextureMatrix"); - int tempindex = glGetUniformBlockIndex(hShader, "LightBufferUBO"); - if (tempindex != -1) glUniformBlockBinding(hShader, tempindex, LIGHTBUF_BINDINGPOINT); + if (LM_SOFTWARE != gl.lightmethod) + { + int tempindex = glGetUniformBlockIndex(hShader, "LightBufferUBO"); + if (tempindex != -1) glUniformBlockBinding(hShader, tempindex, LIGHTBUF_BINDINGPOINT); + } glUseProgram(hShader); @@ -304,7 +307,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * { char stringbuf[20]; mysnprintf(stringbuf, 20, "texture%d", i); - tempindex = glGetUniformLocation(hShader, stringbuf); + int tempindex = glGetUniformLocation(hShader, stringbuf); if (tempindex > 0) glUniform1i(tempindex, i - 1); } From 24526f7da5f1e80acc8f932a7d9a116515b96933 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 1 May 2016 11:56:45 +0200 Subject: [PATCH 0557/1509] - made adjustments to floating point bounding boxes for nodes and changes to the WarpBuffer function. --- src/gl/scene/gl_clipper.cpp | 31 +++++-------------------------- src/gl/scene/gl_clipper.h | 3 +-- src/gl/textures/gl_material.cpp | 5 +---- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/src/gl/scene/gl_clipper.cpp b/src/gl/scene/gl_clipper.cpp index e7cb14b26..a523b27fd 100644 --- a/src/gl/scene/gl_clipper.cpp +++ b/src/gl/scene/gl_clipper.cpp @@ -396,27 +396,6 @@ void R_SetView() viewy = FLOAT2FIXED(ViewPos.Y); } -angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y) -{ - double vecx = double(x-viewx); - double vecy = double(y-viewy); - - if (vecx == 0 && vecy == 0) - { - return 0; - } - else - { - double result = vecy / (fabs(vecx) + fabs(vecy)); - if (vecx < 0) - { - result = 2.f - result; - } - return xs_Fix<30>::ToFix(result); - } -} - - angle_t R_PointToPseudoAngle(double x, double y) { double vecx = x - ViewPos.X; @@ -447,7 +426,7 @@ angle_t R_PointToPseudoAngle(double x, double y) // if some part of the bbox might be visible. // //----------------------------------------------------------------------------- - static const int checkcoord[12][4] = // killough -- static const + static const BYTE checkcoord[12][4] = // killough -- static const { {3,0,2,1}, {3,0,2,0}, @@ -462,17 +441,17 @@ angle_t R_PointToPseudoAngle(double x, double y) {2,1,3,0} }; -bool Clipper::CheckBox(const fixed_t *bspcoord) +bool Clipper::CheckBox(const float *bspcoord) { angle_t angle1, angle2; int boxpos; - const int* check; + const BYTE* check; // Find the corners of the box // that define the edges from current viewpoint. - boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT ] ? 1 : 2) + - (viewy >= bspcoord[BOXTOP ] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); + boxpos = (ViewPos.X <= bspcoord[BOXLEFT] ? 0 : ViewPos.X < bspcoord[BOXRIGHT ] ? 1 : 2) + + (ViewPos.Y >= bspcoord[BOXTOP ] ? 0 : ViewPos.Y > bspcoord[BOXBOTTOM] ? 4 : 8); if (boxpos == 5) return true; diff --git a/src/gl/scene/gl_clipper.h b/src/gl/scene/gl_clipper.h index 977107e61..d09a82147 100644 --- a/src/gl/scene/gl_clipper.h +++ b/src/gl/scene/gl_clipper.h @@ -129,13 +129,12 @@ public: SafeRemoveClipRange(AngleToPseudo(startangle), AngleToPseudo(endangle)); } - bool CheckBox(const fixed_t *bspcoord); + bool CheckBox(const float *bspcoord); }; extern Clipper clipper; -angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y); angle_t R_PointToPseudoAngle(double x, double y); void R_SetView(); diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index a900a1e45..5ab7a8242 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -315,10 +315,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla // need to do software warping FWarpTexture *wt = static_cast(tex); unsigned char *warpbuffer = new unsigned char[w*h*4]; - if (tex->bWarped != 2) - WarpBufferType1((DWORD*)warpbuffer, (const DWORD*)buffer, w, h, wt->WidthOffsetMultiplier, wt->HeightOffsetMultiplier, r_FrameTime, wt->Speed); - else - WarpBufferType2((DWORD*)warpbuffer, (const DWORD*)buffer, w, h, wt->WidthOffsetMultiplier, wt->HeightOffsetMultiplier, r_FrameTime, wt->Speed); + WarpBuffer((DWORD*)warpbuffer, (const DWORD*)buffer, w, h, wt->WidthOffsetMultiplier, wt->HeightOffsetMultiplier, r_FrameTime, wt->Speed, tex->bWarped); delete[] buffer; buffer = warpbuffer; wt->GenTime = r_FrameTime; From 47064e24c97af7f1afdabaf6ba8962bdcdcb0854 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 1 May 2016 12:01:44 +0200 Subject: [PATCH 0558/1509] - only bind the uniform buffer if it is actually going to be used. No need to check if we are use a shader storage buffer. --- src/gl/shaders/gl_shader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index d41adcbe7..395319734 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -294,7 +294,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * modelmatrix_index = glGetUniformLocation(hShader, "ModelMatrix"); texturematrix_index = glGetUniformLocation(hShader, "TextureMatrix"); - if (LM_SOFTWARE != gl.lightmethod) + if (LM_SOFTWARE != gl.lightmethod && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) { int tempindex = glGetUniformBlockIndex(hShader, "LightBufferUBO"); if (tempindex != -1) glUniformBlockBinding(hShader, tempindex, LIGHTBUF_BINDINGPOINT); From 4fb17561bc2fecc21d2f01f851b659ca75cd05c2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 1 May 2016 12:39:08 +0200 Subject: [PATCH 0559/1509] - optimize VSMatrix::Translate. - use FVector3 for sprite rotations. --- src/gl/data/gl_matrix.cpp | 17 ++++++----------- src/gl/scene/gl_sprite.cpp | 24 ++++++++++++------------ src/gl/utility/gl_geometric.h | 10 ++++++++++ 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/gl/data/gl_matrix.cpp b/src/gl/data/gl_matrix.cpp index a16dc770f..bc0f4129f 100644 --- a/src/gl/data/gl_matrix.cpp +++ b/src/gl/data/gl_matrix.cpp @@ -121,22 +121,17 @@ VSMatrix::loadMatrix(const float *aMatrix) #endif -// gl Translate implementation with matrix selection +// gl Translate implementation void VSMatrix::translate(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) { - FLOATTYPE mat[16]; - - setIdentityMatrix(mat); - mat[12] = x; - mat[13] = y; - mat[14] = z; - - multMatrix(mat); + mMatrix[12] = mMatrix[0] * x + mMatrix[4] * y + mMatrix[8] * z + mMatrix[12]; + mMatrix[13] = mMatrix[1] * x + mMatrix[5] * y + mMatrix[9] * z + mMatrix[13]; + mMatrix[14] = mMatrix[2] * x + mMatrix[6] * y + mMatrix[10] * z + mMatrix[14]; } -// gl Scale implementation with matrix selection +// gl Scale implementation void VSMatrix::scale(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) { @@ -146,7 +141,7 @@ VSMatrix::scale(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) } -// gl Rotate implementation with matrix selection +// gl Rotate implementation void VSMatrix::rotate(FLOATTYPE angle, FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) { diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 70669fb33..3f90b251e 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -267,10 +267,10 @@ void GLSprite::Draw(int pass) gl_RenderState.Apply(); - Vector v1; - Vector v2; - Vector v3; - Vector v4; + FVector3 v1; + FVector3 v2; + FVector3 v3; + FVector3 v4; if (drawWithXYBillboard || drawBillboardFacingCamera) { @@ -306,17 +306,17 @@ void GLSprite::Draw(int pass) mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); } mat.Translate(-xcenter, -zcenter, -ycenter); // retreat from sprite center - v1 = mat * Vector(x1, z1, y1); - v2 = mat * Vector(x2, z1, y2); - v3 = mat * Vector(x1, z2, y1); - v4 = mat * Vector(x2, z2, y2); + v1 = mat * FVector3(x1, z1, y1); + v2 = mat * FVector3(x2, z1, y2); + v3 = mat * FVector3(x1, z2, y1); + v4 = mat * FVector3(x2, z2, y2); } else // traditional "Y" billboard mode { - v1 = Vector(x1, z1, y1); - v2 = Vector(x2, z1, y2); - v3 = Vector(x1, z2, y1); - v4 = Vector(x2, z2, y2); + v1 = FVector3(x1, z1, y1); + v2 = FVector3(x2, z1, y2); + v3 = FVector3(x1, z2, y1); + v4 = FVector3(x2, z2, y2); } FFlatVertex *ptr; diff --git a/src/gl/utility/gl_geometric.h b/src/gl/utility/gl_geometric.h index 3691d7740..f1053c430 100644 --- a/src/gl/utility/gl_geometric.h +++ b/src/gl/utility/gl_geometric.h @@ -239,6 +239,16 @@ public: return result; } + FVector3 operator *(const FVector3 &vec) + { + FVector3 result; + + result.X = vec.X*m[0][0] + vec.Y*m[0][1] + vec.Z*m[0][2] + m[0][3]; + result.Y = vec.X*m[1][0] + vec.Y*m[1][1] + vec.Z*m[1][2] + m[1][3]; + result.Z = vec.X*m[2][0] + vec.Y*m[2][1] + vec.Z*m[2][2] + m[2][3]; + return result; + } + void MultiplyVector(float *f3 , float *f3o) { float x = f3[0] * m[0][0] + f3[1] * m[0][1] + f3[2] * m[0][2] + m[0][3]; From 50ba1ecde8298abb6af43c140ed92ee514e35716 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 1 May 2016 13:09:13 +0200 Subject: [PATCH 0560/1509] - add menu patching for GL 2.x mode. - use stdint types in model code, because we have to start somewhere with the transition. --- src/gl/compatibility/gl_20.cpp | 51 ++++++++++++++++++++++++++++++++- src/gl/models/gl_models.cpp | 4 +-- src/gl/models/gl_models_md3.cpp | 48 +++++++++++++++---------------- src/gl/system/gl_interface.cpp | 5 ++-- 4 files changed, 78 insertions(+), 30 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index d0de0589c..7e8ad093a 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -53,6 +53,54 @@ #include "gl/renderer/gl_renderstate.h" #include "gl/scene/gl_drawinfo.h" + +//========================================================================== +// +// Do some tinkering with the menus so that certain options only appear +// when they are actually valid. +// +//========================================================================== + +void gl_PatchMenu() +{ + if (gl.compatibility == CMPT_GL2) + { + // Radial fog and Doom lighting are not available in SM < 4 cards + // The way they are implemented does not work well on older hardware. + + FOptionValues **opt = OptionValues.CheckKey("LightingModes"); + if (opt != NULL) + { + for(int i = (*opt)->mValues.Size()-1; i>=0; i--) + { + // Delete 'Doom' lighting mode + if ((*opt)->mValues[i].Value == 2.0 || (*opt)->mValues[i].Value == 8.0) + { + (*opt)->mValues.Delete(i); + } + } + } + + opt = OptionValues.CheckKey("FogMode"); + if (opt != NULL) + { + for(int i = (*opt)->mValues.Size()-1; i>=0; i--) + { + // Delete 'Radial' fog mode + if ((*opt)->mValues[i].Value == 2.0) + { + (*opt)->mValues.Delete(i); + } + } + } + + // disable features that don't work without shaders. + if (gl_lightmode == 2 || gl_lightmode == 8) gl_lightmode = 3; + if (gl_fogmode == 2) gl_fogmode = 1; + } +} + + //========================================================================== // // @@ -499,4 +547,5 @@ void FGLRenderer::RenderMultipassStuff() gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); } else gl_lights = false; -} \ No newline at end of file +} + diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 4db7a5f66..dc937ea40 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -325,8 +325,8 @@ FTexture * LoadSkin(const char * path, const char * fn) static int ModelFrameHash(FSpriteModelFrame * smf) { - const DWORD *table = GetCRCTable (); - DWORD hash = 0xffffffff; + const uint32_t *table = GetCRCTable (); + uint32_t hash = 0xffffffff; const char * s = (const char *)(&smf->type); // this uses type, sprite and frame for hashing const char * se= (const char *)(&smf->hashnext); diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index 7e8a4845e..024f8ac81 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -77,45 +77,45 @@ static void UnpackVector(unsigned short packed, float & nx, float & ny, float & #pragma pack(4) struct md3_header_t { - DWORD Magic; - DWORD Version; + uint32_t Magic; + uint32_t Version; char Name[MAX_QPATH]; - DWORD Flags; - DWORD Num_Frames; - DWORD Num_Tags; - DWORD Num_Surfaces; - DWORD Num_Skins; - DWORD Ofs_Frames; - DWORD Ofs_Tags; - DWORD Ofs_Surfaces; - DWORD Ofs_Eof; + uint32_t Flags; + uint32_t Num_Frames; + uint32_t Num_Tags; + uint32_t Num_Surfaces; + uint32_t Num_Skins; + uint32_t Ofs_Frames; + uint32_t Ofs_Tags; + uint32_t Ofs_Surfaces; + uint32_t Ofs_Eof; }; struct md3_surface_t { - DWORD Magic; + uint32_t Magic; char Name[MAX_QPATH]; - DWORD Flags; - DWORD Num_Frames; - DWORD Num_Shaders; - DWORD Num_Verts; - DWORD Num_Triangles; - DWORD Ofs_Triangles; - DWORD Ofs_Shaders; - DWORD Ofs_Texcoord; - DWORD Ofs_XYZNormal; - DWORD Ofs_End; + uint32_t Flags; + uint32_t Num_Frames; + uint32_t Num_Shaders; + uint32_t Num_Verts; + uint32_t Num_Triangles; + uint32_t Ofs_Triangles; + uint32_t Ofs_Shaders; + uint32_t Ofs_Texcoord; + uint32_t Ofs_XYZNormal; + uint32_t Ofs_End; }; struct md3_triangle_t { - DWORD vt_index[3]; + uint32_t vt_index[3]; }; struct md3_shader_t { char Name[MAX_QPATH]; - DWORD index; + uint32_t index; }; struct md3_texcoord_t diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 19f6134c3..e6e802e5c 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -47,12 +47,10 @@ #include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" +void gl_PatchMenu(); static TArray m_Extensions; - RenderContext gl; -int occlusion_type=0; - //========================================================================== // // @@ -273,6 +271,7 @@ void gl_LoadExtensions() FUDGE_FUNC(glDeleteRenderbuffers, EXT); FUDGE_FUNC(glRenderbufferStorage, EXT); FUDGE_FUNC(glBindRenderbuffer, EXT); + gl_PatchMenu(); } //========================================================================== From 26acf8e994517ca078253bdce106753407832b2b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 1 May 2016 17:43:30 +0200 Subject: [PATCH 0561/1509] - fixed conditions for menu patching. --- src/gl/compatibility/gl_20.cpp | 3 ++- src/gl/scene/gl_scene.cpp | 2 +- src/gl/stereo3d/scoped_view_shifter.cpp | 2 +- src/gl/stereo3d/scoped_view_shifter.h | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 7e8ad093a..e059a3563 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -37,6 +37,7 @@ ** */ #include "gl/system/gl_system.h" +#include "menu/menu.h" #include "tarray.h" #include "doomtype.h" #include "m_argv.h" @@ -63,7 +64,7 @@ void gl_PatchMenu() { - if (gl.compatibility == CMPT_GL2) + if (gl.glslversion == 0) { // Radial fog and Doom lighting are not available in SM < 4 cards // The way they are implemented does not work well on older hardware. diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 23c7a6318..60227ccae 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -836,7 +836,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo SetProjection( eye->GetProjection(fov, ratio, fovratio) ); // SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper SetViewAngle(ViewAngle); - // Stereo mode specific viewpoint adjustment - temporarily shifts global viewx, viewy, viewz + // Stereo mode specific viewpoint adjustment - temporarily shifts global ViewPos eye->GetViewShift(GLRenderer->mAngles.Yaw.Degrees, viewShift); s3d::ScopedViewShifter viewShifter(viewShift); SetViewMatrix(ViewPos.X, ViewPos.Y, ViewPos.Z, false, false); diff --git a/src/gl/stereo3d/scoped_view_shifter.cpp b/src/gl/stereo3d/scoped_view_shifter.cpp index 5ecf1b0ab..f4274ed95 100644 --- a/src/gl/stereo3d/scoped_view_shifter.cpp +++ b/src/gl/stereo3d/scoped_view_shifter.cpp @@ -1,6 +1,6 @@ /* ** scoped_view_shifter.cpp -** Stack-scoped class for temporarily changing player viewpoint global variables viewx, viewy, viewz. +** Stack-scoped class for temporarily changing camera viewpoint ** Used for stereoscopic 3D. ** **--------------------------------------------------------------------------- diff --git a/src/gl/stereo3d/scoped_view_shifter.h b/src/gl/stereo3d/scoped_view_shifter.h index 8e31cecdf..8e39d533b 100644 --- a/src/gl/stereo3d/scoped_view_shifter.h +++ b/src/gl/stereo3d/scoped_view_shifter.h @@ -1,6 +1,6 @@ /* ** scoped_view_shifter.h -** Stack-scoped class for temporarily changing player viewpoint global variables viewx, viewy, viewz. +** Stack-scoped class for temporarily changing camera viewpoint ** Used for stereoscopic 3D. ** **--------------------------------------------------------------------------- @@ -43,7 +43,7 @@ namespace s3d { /** - * Temporarily shift viewx, viewy, viewz + * Temporarily shift */ class ScopedViewShifter { From 980a31075521762a1a17925c59a9127cb39c0317 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Sun, 1 May 2016 14:08:09 -0500 Subject: [PATCH 0562/1509] GZDoom Roll Submission --- src/gl/scene/gl_sprite.cpp | 98 +++++++++++++++++++++++++++++++++----- 1 file changed, 85 insertions(+), 13 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 3f90b251e..a596380a6 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -264,7 +264,8 @@ void GLSprite::Draw(int pass) && (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD)))); const bool drawBillboardFacingCamera = gl_billboard_faces_camera; - + // [Nash] has +ROLLSPRITE + const bool drawRollSpriteActor = (actor != NULL && actor->renderflags & RF_ROLLSPRITE); gl_RenderState.Apply(); FVector3 v1; @@ -272,7 +273,15 @@ void GLSprite::Draw(int pass) FVector3 v3; FVector3 v4; - if (drawWithXYBillboard || drawBillboardFacingCamera) + // [fgsfds] check sprite type mask + DWORD spritetype = (DWORD)-1; + if (actor != NULL) spritetype = actor->renderflags & RF_SPRITETYPEMASK; + + // [Nash] is a flat sprite + const bool isFlatSprite = (actor != NULL) && (spritetype == RF_WALLSPRITE || spritetype == RF_FLATSPRITE || spritetype == RF_PITCHFLATSPRITE); + + // [Nash] check for special sprite drawing modes + if (drawWithXYBillboard || drawBillboardFacingCamera || drawRollSpriteActor || isFlatSprite) { // Compute center of sprite float xcenter = (x1 + x2)*0.5; @@ -284,7 +293,8 @@ void GLSprite::Draw(int pass) mat.Translate(xcenter, zcenter, ycenter); // move to sprite center // Order of rotations matters. Perform yaw rotation (Y, face camera) before pitch (X, tilt up/down). - if (drawBillboardFacingCamera) { + if (drawBillboardFacingCamera) + { // [CMB] Rotate relative to camera XY position, not just camera direction, // which is nicer in VR float xrel = xcenter - GLRenderer->mViewActor->X(); @@ -296,13 +306,64 @@ void GLSprite::Draw(int pass) mat.Rotate(0, 1, 0, relAngleDeg); } - if (drawWithXYBillboard) + // [fgsfds] calculate yaw vectors + float yawvecX = 0, yawvecY = 0, FlatAngle = 0, rollDegrees = 0; + float angleRad = (270. - GLRenderer->mAngles.Yaw).Radians(); + if (actor) rollDegrees = actor->Angles.Roll.Degrees; + if (isFlatSprite) + { + yawvecX = actor->Angles.Yaw.Cos(); + yawvecY = actor->Angles.Yaw.Sin(); + FlatAngle = actor->FlatAngle.Degrees; + } + + // [MC] This is the only thing that I changed in Nash's submission which + // was constantly applying roll to everything. That was wrong. Flat sprites + // with roll literally look like paper thing space ships trying to swerve. + // However, it does well with wall sprites. + // Also, renamed FLOORSPRITE to FLATSPRITE because that's technically incorrect. + // I plan on adding proper FLOORSPRITEs which can actually curve along sloped + // 3D floors later... if possible. + + // Here we need some form of priority in order to work. + if (spritetype == RF_PITCHFLATSPRITE) + { + float pitchDegrees = actor->Angles.Pitch.Degrees; + mat.Rotate(0, 1, 0, -FlatAngle); + if (drawRollSpriteActor) + { + mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); + } + mat.Rotate(-yawvecY, 0, yawvecX, pitchDegrees); + } + else if (spritetype == RF_FLATSPRITE) + { // [fgsfds] rotate the sprite so it faces upwards/downwards + mat.Rotate(-yawvecY, 0, yawvecX, -90.f); + if (drawRollSpriteActor) + mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); + } + // [fgsfds] Rotate the sprite about the sight vector (roll) + else if (spritetype == RF_WALLSPRITE) + { + mat.Rotate(0, 1, 0, -FlatAngle); + if (drawRollSpriteActor) + mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); + } + else if (drawRollSpriteActor) + { + if (drawWithXYBillboard) + { + mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); + } + mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees); + } + + // apply the transform + else if (drawWithXYBillboard) { // Rotate the sprite about the vector starting at the center of the sprite // triangle strip and with direction orthogonal to where the player is looking // in the x/y plane. - float angleRad = (270. - GLRenderer->mAngles.Yaw).Radians(); - mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); } mat.Translate(-xcenter, -zcenter, -ycenter); // retreat from sprite center @@ -623,16 +684,25 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) bottomclip = rendersector->PortalBlocksMovement(sector_t::floor) ? -LARGE_VALUE : rendersector->GetPortalPlaneZ(sector_t::floor); x = thingpos.X; - z = thingpos.Z - thing->Floorclip; y = thingpos.Y; - // [RH] Make floatbobbing a renderer-only effect. - if (thing->flags2 & MF2_FLOATBOB) + DWORD spritetype = thing->renderflags & RF_SPRITETYPEMASK; + + switch (spritetype) { - float fz = thing->GetBobOffset(r_TicFracF); - z += fz; + case RF_FLATSPRITE: + case RF_PITCHFLATSPRITE: + z = thingpos.Z; + default: + z = thingpos.Z - thing->Floorclip; + // [RH] Make floatbobbing a renderer-only effect. + if (thing->flags2 & MF2_FLOATBOB) + { + float fz = thing->GetBobOffset(r_TicFracF); + z += fz; + } + break; } - modelframe = gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED)); if (!modelframe) { @@ -677,7 +747,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) float viewvecX; float viewvecY; - switch (thing->renderflags & RF_SPRITETYPEMASK) + switch (spritetype) { case RF_FACESPRITE: viewvecX = GLRenderer->mViewVector.X; @@ -689,6 +759,8 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) y2 = y + viewvecX*rightfac; break; + case RF_FLATSPRITE: + case RF_PITCHFLATSPRITE: case RF_WALLSPRITE: viewvecX = thing->Angles.Yaw.Cos(); viewvecY = thing->Angles.Yaw.Sin(); From f2f3fa6d090af6531a3e94976566fa001bb26146 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 2 May 2016 00:13:00 +0200 Subject: [PATCH 0563/1509] - parched the texture precaching so that it compiles and works again. The real work will come later. --- src/gl/scene/gl_scene.cpp | 81 ++++++++++++++++++++++++++++++++ src/gl/system/gl_framebuffer.cpp | 30 ------------ src/gl/system/gl_framebuffer.h | 1 - 3 files changed, 81 insertions(+), 31 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 60227ccae..a658982bc 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -74,6 +74,7 @@ #include "gl/stereo3d/gl_stereo3d.h" #include "gl/stereo3d/scoped_view_shifter.h" #include "gl/textures/gl_material.h" +#include "gl/textures/gl_skyboxtexture.h" #include "gl/utility/gl_clock.h" #include "gl/utility/gl_convert.h" #include "gl/utility/gl_templates.h" @@ -978,6 +979,7 @@ struct FGLInterface : public FRenderer { bool UsesColormap() const; void PrecacheTexture(FTexture *tex, int cache); + void Precache(BYTE *texhitlist, TMap &actorhitlist); void RenderView(player_t *player); void WriteSavePic (player_t *player, FILE *file, int width, int height); void StateChanged(AActor *actor); @@ -1028,6 +1030,85 @@ void FGLInterface::PrecacheTexture(FTexture *tex, int cache) } } +void FGLInterface::Precache(BYTE *texhitlist, TMap &actorhitlist) +{ + BYTE *spritelist = new BYTE[sprites.Size()]; + TMap::Iterator it(actorhitlist); + TMap::Pair *pair; + + // this isn't done by the main code so it needs to be done here first: + // check skybox textures and mark the separate faces as used + for (int i = 0; igl_info.bSkybox) + { + FSkyBox *sb = static_cast(tex); + for (int i = 0; i<6; i++) + { + if (sb->faces[i]) + { + int index = sb->faces[i]->id.GetIndex(); + texhitlist[index] |= FTextureManager::HIT_Flat; + } + } + } + } + } + + + + + + memset(spritelist, 0, sprites.Size()); + + while (it.NextPair(pair)) + { + PClassActor *cls = pair->Key; + + for (int i = 0; i < cls->NumOwnedStates; i++) + { + spritelist[cls->OwnedStates[i].sprite] = true; + } + } + + // Precache textures (and sprites). + + for (int i = (int)(sprites.Size() - 1); i >= 0; i--) + { + if (spritelist[i]) + { + int j, k; + for (j = 0; j < sprites[i].numframes; j++) + { + const spriteframe_t *frame = &SpriteFrames[sprites[i].spriteframes + j]; + + for (k = 0; k < 16; k++) + { + FTextureID pic = frame->Texture[k]; + if (pic.isValid()) + { + texhitlist[pic.GetIndex()] = FTextureManager::HIT_Sprite; + } + } + } + } + } + delete[] spritelist; + + TexMan.precacheTime = I_FPSTime(); + + int cnt = TexMan.NumTextures(); + for (int i = cnt - 1; i >= 0; i--) + { + PrecacheTexture(TexMan.ByIndex(i), texhitlist[i]); + } +} + + //========================================================================== // // DFrameBuffer :: StateChanged diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 4a05c2d17..818084706 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -322,36 +322,6 @@ int OpenGLFrameBuffer::GetPageCount() } -void OpenGLFrameBuffer::GetHitlist(BYTE *hitlist) -{ - Super::GetHitlist(hitlist); - - // check skybox textures and mark the separate faces as used - for(int i=0;igl_info.bSkybox) - { - FSkyBox *sb = static_cast(tex); - for(int i=0;i<6;i++) - { - if (sb->faces[i]) - { - int index = sb->faces[i]->id.GetIndex(); - hitlist[index] |= FTextureManager::HIT_Flat; - } - } - } - } - } - - - // check model skins -} - //========================================================================== // // DFrameBuffer :: CreatePalette diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index 9c87e9dc8..ad25851af 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -46,7 +46,6 @@ public: void GetFlash(PalEntry &rgb, int &amount); int GetPageCount(); bool Begin2D(bool copy3d); - void GetHitlist(BYTE *hitlist); void GameRestart(); // Retrieves a buffer containing image data for a screenshot. From a163220e8c25b3eb5bbba85c0740d73cff3f09f4 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Sun, 1 May 2016 17:30:30 -0500 Subject: [PATCH 0564/1509] Removed FlatAngle. --- src/gl/scene/gl_sprite.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index a596380a6..a99eb5b82 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -307,14 +307,13 @@ void GLSprite::Draw(int pass) } // [fgsfds] calculate yaw vectors - float yawvecX = 0, yawvecY = 0, FlatAngle = 0, rollDegrees = 0; + float yawvecX = 0, yawvecY = 0, rollDegrees = 0; float angleRad = (270. - GLRenderer->mAngles.Yaw).Radians(); if (actor) rollDegrees = actor->Angles.Roll.Degrees; if (isFlatSprite) { yawvecX = actor->Angles.Yaw.Cos(); yawvecY = actor->Angles.Yaw.Sin(); - FlatAngle = actor->FlatAngle.Degrees; } // [MC] This is the only thing that I changed in Nash's submission which @@ -329,7 +328,7 @@ void GLSprite::Draw(int pass) if (spritetype == RF_PITCHFLATSPRITE) { float pitchDegrees = actor->Angles.Pitch.Degrees; - mat.Rotate(0, 1, 0, -FlatAngle); + mat.Rotate(0, 1, 0, 0); if (drawRollSpriteActor) { mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); @@ -345,7 +344,7 @@ void GLSprite::Draw(int pass) // [fgsfds] Rotate the sprite about the sight vector (roll) else if (spritetype == RF_WALLSPRITE) { - mat.Rotate(0, 1, 0, -FlatAngle); + mat.Rotate(0, 1, 0, 0); if (drawRollSpriteActor) mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); } From 44b019413c43c1fd814fd266caf652207af40fcf Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 1 May 2016 16:59:17 +0300 Subject: [PATCH 0565/1509] Implemented gamma correction in OS X native backend using shader effect --- src/gl/renderer/gl_renderstate.h | 1 + src/gl/shaders/gl_shader.cpp | 1 + src/posix/cocoa/i_video.mm | 30 +++++++------------ src/posix/cocoa/sdlglvideo.h | 3 +- wadsrc/static/shaders/glsl/gammacorrection.fp | 24 +++++++++++++++ 5 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 wadsrc/static/shaders/glsl/gammacorrection.fp diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 829edeec0..cebbb9570 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -37,6 +37,7 @@ enum EEffect EFF_SPHEREMAP, EFF_BURN, EFF_STENCIL, + EFF_GAMMACORRECTION, MAX_EFFECTS }; diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 395319734..551707398 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -433,6 +433,7 @@ static const FEffectShader effectshaders[]= { "spheremap", "shaders/glsl/main.vp", "shaders/glsl/main.fp", "shaders/glsl/func_normal.fp", "#define SPHEREMAP\n#define NO_ALPHATEST\n" }, { "burn", "shaders/glsl/main.vp", "shaders/glsl/burn.fp", NULL, "#define SIMPLE\n#define NO_ALPHATEST\n" }, { "stencil", "shaders/glsl/main.vp", "shaders/glsl/stencil.fp", NULL, "#define SIMPLE\n#define NO_ALPHATEST\n" }, + { "gammacorrection", "shaders/glsl/main.vp", "shaders/glsl/gammacorrection.fp", NULL, "#define SIMPLE\n" }, }; diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 726733b05..fc415535f 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -63,6 +63,7 @@ #include "gl/renderer/gl_renderer.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_interface.h" +#include "gl/textures/gl_samplers.h" #include "gl/utility/gl_clock.h" #undef Class @@ -1156,15 +1157,12 @@ SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool : DFrameBuffer(width, height) , m_lock(-1) , m_isUpdatePending(false) -, m_supportsGamma(true) -, m_gammaProgram("gamma_correction") , m_gammaTexture(GAMMA_TABLE_SIZE, 1, true) { } SDLGLFB::SDLGLFB() -: m_gammaProgram(nullptr) -, m_gammaTexture(0, 0, false) +: m_gammaTexture(0, 0, false) { } @@ -1262,7 +1260,9 @@ void SDLGLFB::SetGammaTable(WORD* table) m_gammaTexture.CreateTexture( reinterpret_cast(m_gammaTable), - GAMMA_TABLE_SIZE, 1, false, 1, 0); + GAMMA_TABLE_SIZE, 1, 1, false, 0); + + GLRenderer->mSamplerManager->Bind(1, CLAMP_NOFILTER, -1); } @@ -1280,6 +1280,7 @@ void BoundTextureSetFilter(const GLenum target, const GLint filter) void BoundTextureDraw2D(const GLsizei width, const GLsizei height) { + gl_RenderState.SetEffect(EFF_GAMMACORRECTION); gl_RenderState.SetTextureMode(TM_OPAQUE); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.ResetColor(); @@ -1304,6 +1305,8 @@ void BoundTextureDraw2D(const GLsizei width, const GLsizei height) ptr->Set(x + w, y + h, 0, u2, v2); ++ptr; vbo->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + + gl_RenderState.SetEffect(EFF_NONE); } bool BoundTextureSaveAsPNG(const GLenum target, const char* const path) @@ -1387,7 +1390,7 @@ RenderTarget::RenderTarget(const GLsizei width, const GLsizei height) glGenFramebuffersEXT(1, &m_ID); Bind(); - m_texture.CreateTexture(NULL, width, height, false, 0, 0); + m_texture.CreateTexture(NULL, width, height, 0, false, 0); m_texture.BindToFrameBuffer(); Unbind(); } @@ -1433,19 +1436,7 @@ CocoaOpenGLFrameBuffer::CocoaOpenGLFrameBuffer(void* hMonitor, int width, int he , m_renderTarget(width, height) { SetSmoothPicture(gl_smooth_rendered); -/* - // Setup uniform samplers for gamma correction shader - m_gammaProgram.Load("GammaCorrection", "shaders/glsl/main.vp", - "shaders/glsl/gamma_correction.fp", NULL, ""); - - const GLuint program = m_gammaProgram.GetHandle(); - - glUseProgram(program); - glUniform1i(glGetUniformLocation(program, "backbuffer"), 0); - glUniform1i(glGetUniformLocation(program, "gammaTable"), 1); - glUseProgram(0); -*/ // Fill render target with black color m_renderTarget.Bind(); @@ -1515,7 +1506,6 @@ void CocoaOpenGLFrameBuffer::DrawRenderTarget() glViewport(rbOpts.shiftX, rbOpts.shiftY, rbOpts.width, rbOpts.height); - //m_gammaProgram.Bind(); BoundTextureDraw2D(Width, Height); glViewport(0, 0, Width, Height); @@ -1525,7 +1515,7 @@ void CocoaOpenGLFrameBuffer::DrawRenderTarget() void CocoaOpenGLFrameBuffer::SetSmoothPicture(const bool smooth) { FHardwareTexture& texture = m_renderTarget.GetColorTexture(); - texture.Bind(0, 0, 0); + texture.Bind(0, 0, false); BoundTextureSetFilter(GL_TEXTURE_2D, smooth ? GL_LINEAR : GL_NEAREST); } diff --git a/src/posix/cocoa/sdlglvideo.h b/src/posix/cocoa/sdlglvideo.h index 2199ef420..aac8992d9 100644 --- a/src/posix/cocoa/sdlglvideo.h +++ b/src/posix/cocoa/sdlglvideo.h @@ -68,9 +68,8 @@ protected: int m_lock; bool m_isUpdatePending; - bool m_supportsGamma; + static const bool m_supportsGamma = true; - FShader m_gammaProgram; FHardwareTexture m_gammaTexture; static const size_t GAMMA_TABLE_SIZE = 256; diff --git a/wadsrc/static/shaders/glsl/gammacorrection.fp b/wadsrc/static/shaders/glsl/gammacorrection.fp new file mode 100644 index 000000000..f8c2cf6a3 --- /dev/null +++ b/wadsrc/static/shaders/glsl/gammacorrection.fp @@ -0,0 +1,24 @@ +uniform sampler2D tex; +uniform sampler2D texture2; + +in vec4 vTexCoord; + +void applyGamma(int channel) +{ + vec4 color = texture(texture2, vec2(FragColor[channel], 0.0)); + FragColor[channel] = color[channel]; +} + +void main() +{ + FragColor = texture(tex, vTexCoord.st); + +// /* DEBUG */ if (vTexCoord.x > 0.5) + { + applyGamma(0); + applyGamma(1); + applyGamma(2); + } + + FragColor.a = 1.0; +} From 333560086de84cddacccff034afb887d76dc728b Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 2 May 2016 10:35:38 +0300 Subject: [PATCH 0566/1509] Calculate color values for gamma correction directly in shader Gamma table texture is no longer needed --- src/posix/cocoa/i_video.mm | 32 +++---------------- src/posix/cocoa/sdlglvideo.h | 6 ---- wadsrc/static/shaders/glsl/gammacorrection.fp | 30 +++++++++-------- 3 files changed, 21 insertions(+), 47 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index fc415535f..069239b48 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -1150,19 +1150,14 @@ void CocoaFrameBuffer::Flip() // --------------------------------------------------------------------------- -static const uint32_t GAMMA_TABLE_ALPHA = 0xFF000000; - - SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool fullscreen) : DFrameBuffer(width, height) , m_lock(-1) , m_isUpdatePending(false) -, m_gammaTexture(GAMMA_TABLE_SIZE, 1, true) { } SDLGLFB::SDLGLFB() -: m_gammaTexture(0, 0, false) { } @@ -1243,26 +1238,6 @@ void SDLGLFB::SwapBuffers() void SDLGLFB::SetGammaTable(WORD* table) { - const WORD* const red = &table[ 0]; - const WORD* const green = &table[256]; - const WORD* const blue = &table[512]; - - for (size_t i = 0; i < GAMMA_TABLE_SIZE; ++i) - { - // Convert 16 bits colors to 8 bits by dividing on 256 - - const uint32_t r = red[i] >> 8; - const uint32_t g = green[i] >> 8; - const uint32_t b = blue[i] >> 8; - - m_gammaTable[i] = GAMMA_TABLE_ALPHA + (b << 16) + (g << 8) + r; - } - - m_gammaTexture.CreateTexture( - reinterpret_cast(m_gammaTable), - GAMMA_TABLE_SIZE, 1, 1, false, 0); - - GLRenderer->mSamplerManager->Bind(1, CLAMP_NOFILTER, -1); } @@ -1278,12 +1253,15 @@ void BoundTextureSetFilter(const GLenum target, const GLint filter) glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } +EXTERN_CVAR(Float, vid_brightness) +EXTERN_CVAR(Float, vid_contrast) + void BoundTextureDraw2D(const GLsizei width, const GLsizei height) { gl_RenderState.SetEffect(EFF_GAMMACORRECTION); gl_RenderState.SetTextureMode(TM_OPAQUE); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); - gl_RenderState.ResetColor(); + gl_RenderState.SetColor(Gamma, vid_contrast, vid_brightness); gl_RenderState.Apply(); static const float x = 0.f; @@ -1490,9 +1468,7 @@ void CocoaOpenGLFrameBuffer::GetScreenshotBuffer(const BYTE*& buffer, int& pitch void CocoaOpenGLFrameBuffer::DrawRenderTarget() { m_renderTarget.Unbind(); - m_renderTarget.GetColorTexture().Bind(0, 0, false); - m_gammaTexture.Bind(1, 0, false); if (rbOpts.dirty) { diff --git a/src/posix/cocoa/sdlglvideo.h b/src/posix/cocoa/sdlglvideo.h index aac8992d9..439b4d5ce 100644 --- a/src/posix/cocoa/sdlglvideo.h +++ b/src/posix/cocoa/sdlglvideo.h @@ -70,12 +70,6 @@ protected: static const bool m_supportsGamma = true; - FHardwareTexture m_gammaTexture; - - static const size_t GAMMA_TABLE_SIZE = 256; - uint32_t m_gammaTable[GAMMA_TABLE_SIZE]; - - SDLGLFB(); void InitializeState(); diff --git a/wadsrc/static/shaders/glsl/gammacorrection.fp b/wadsrc/static/shaders/glsl/gammacorrection.fp index f8c2cf6a3..1deb1a600 100644 --- a/wadsrc/static/shaders/glsl/gammacorrection.fp +++ b/wadsrc/static/shaders/glsl/gammacorrection.fp @@ -1,24 +1,28 @@ uniform sampler2D tex; -uniform sampler2D texture2; in vec4 vTexCoord; - -void applyGamma(int channel) -{ - vec4 color = texture(texture2, vec2(FragColor[channel], 0.0)); - FragColor[channel] = color[channel]; -} +in vec4 vColor; void main() { - FragColor = texture(tex, vTexCoord.st); + vec3 color = texture(tex, vTexCoord.st).rgb; // /* DEBUG */ if (vTexCoord.x > 0.5) { - applyGamma(0); - applyGamma(1); - applyGamma(2); + // Apply contrast + float contrast = clamp(vColor.y, 0.1, 3.0); + color = color.rgb * contrast - (contrast - 1.0) * 0.5; + + // Apply gamma + float gamma = clamp(vColor.x, 0.1, 4.0); + color = sign(color) * pow(abs(color), vec3(1.0 / gamma)); + + // Apply brightness + float brightness = clamp(vColor.z, -0.8, 0.8); + color += brightness * 0.5; + + color = clamp(color, 0.0, 1.0); } - - FragColor.a = 1.0; + + FragColor = vec4(color, 1.0); } From 4c4b97316ec345c12a8900b7ad5c0def828b50d1 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 2 May 2016 13:02:55 +0300 Subject: [PATCH 0567/1509] Fixed inconsistent texture wrapping Sampler state needs to be reseted when hardware texture resources are released --- src/gl/textures/gl_material.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 5ab7a8242..74cdcd725 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -173,6 +173,8 @@ void FGLTexture::Clean(bool all) delete mHwTexture; mHwTexture = NULL; } + + lastSampler = 253; } } From 673dab7f23c933146d460187f9f4f5b54b59bd0c Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Mon, 2 May 2016 06:29:19 -0500 Subject: [PATCH 0568/1509] Removed PITCHFLATSPRITE. FLATSPRITE now encompasses the behavior. --- src/gl/scene/gl_sprite.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index a99eb5b82..abefe6191 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -325,7 +325,7 @@ void GLSprite::Draw(int pass) // 3D floors later... if possible. // Here we need some form of priority in order to work. - if (spritetype == RF_PITCHFLATSPRITE) + if (spritetype == RF_FLATSPRITE) { float pitchDegrees = actor->Angles.Pitch.Degrees; mat.Rotate(0, 1, 0, 0); @@ -335,12 +335,6 @@ void GLSprite::Draw(int pass) } mat.Rotate(-yawvecY, 0, yawvecX, pitchDegrees); } - else if (spritetype == RF_FLATSPRITE) - { // [fgsfds] rotate the sprite so it faces upwards/downwards - mat.Rotate(-yawvecY, 0, yawvecX, -90.f); - if (drawRollSpriteActor) - mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); - } // [fgsfds] Rotate the sprite about the sight vector (roll) else if (spritetype == RF_WALLSPRITE) { From f9022f3054ee5fcfdf1eb7935f53d9e32c457e0b Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 2 May 2016 16:13:54 +0300 Subject: [PATCH 0569/1509] Fixed compilation of gamma correction shader with particular OpenGL setup --- wadsrc/static/shaders/glsl/gammacorrection.fp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wadsrc/static/shaders/glsl/gammacorrection.fp b/wadsrc/static/shaders/glsl/gammacorrection.fp index 1deb1a600..fe40ac680 100644 --- a/wadsrc/static/shaders/glsl/gammacorrection.fp +++ b/wadsrc/static/shaders/glsl/gammacorrection.fp @@ -3,6 +3,8 @@ uniform sampler2D tex; in vec4 vTexCoord; in vec4 vColor; +out vec4 FragColor; + void main() { vec3 color = texture(tex, vTexCoord.st).rgb; From 9ec3093a3429a5c483c3a3165ca23e519631af9d Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Mon, 2 May 2016 08:52:44 -0500 Subject: [PATCH 0570/1509] Fixed some missed cases. --- src/gl/scene/gl_sprite.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index abefe6191..52c9f6aa9 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -278,7 +278,7 @@ void GLSprite::Draw(int pass) if (actor != NULL) spritetype = actor->renderflags & RF_SPRITETYPEMASK; // [Nash] is a flat sprite - const bool isFlatSprite = (actor != NULL) && (spritetype == RF_WALLSPRITE || spritetype == RF_FLATSPRITE || spritetype == RF_PITCHFLATSPRITE); + const bool isFlatSprite = (actor != NULL) && (spritetype == RF_WALLSPRITE || spritetype == RF_FLATSPRITE); // [Nash] check for special sprite drawing modes if (drawWithXYBillboard || drawBillboardFacingCamera || drawRollSpriteActor || isFlatSprite) @@ -684,7 +684,6 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) switch (spritetype) { case RF_FLATSPRITE: - case RF_PITCHFLATSPRITE: z = thingpos.Z; default: z = thingpos.Z - thing->Floorclip; @@ -753,7 +752,6 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) break; case RF_FLATSPRITE: - case RF_PITCHFLATSPRITE: case RF_WALLSPRITE: viewvecX = thing->Angles.Yaw.Cos(); viewvecY = thing->Angles.Yaw.Sin(); From 16bea6cf1fdc59dc8a724571477d20597e43cbb3 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Mon, 2 May 2016 10:46:44 -0500 Subject: [PATCH 0571/1509] - Fixed: Roll must orient the rotation based on pitch, not the other way around. --- src/gl/scene/gl_sprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 52c9f6aa9..2301fc7ba 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -329,11 +329,11 @@ void GLSprite::Draw(int pass) { float pitchDegrees = actor->Angles.Pitch.Degrees; mat.Rotate(0, 1, 0, 0); + mat.Rotate(-yawvecY, 0, yawvecX, pitchDegrees); if (drawRollSpriteActor) { mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); } - mat.Rotate(-yawvecY, 0, yawvecX, pitchDegrees); } // [fgsfds] Rotate the sprite about the sight vector (roll) else if (spritetype == RF_WALLSPRITE) From ec037bfd1a6d1725fdfcf7fe9badfcffcac79a8e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 2 May 2016 19:47:27 +0200 Subject: [PATCH 0572/1509] - fixed: The check for one-way portals in the renderer was incomplete. --- src/gl/scene/gl_walls.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index e337f1873..ae7cb70c8 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -217,7 +217,7 @@ void GLWall::PutPortal(int ptype) if (!portal) { line_t *otherside = lineportal->lines[0]->mDestination; - if (otherside != NULL) + if (otherside != NULL && otherside->portalindex < linePortals.Size()) { gl_RenderActorsInPortal(linePortalToGL[otherside->portalindex]); } From 6f2b0a62939aa76acf0c671e070c966a82113f22 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 May 2016 01:00:52 +0200 Subject: [PATCH 0573/1509] - rewrote texture caching so that not the base texture but the actually used translations for sprites get precached. --- src/gl/scene/gl_scene.cpp | 61 ++++++++++++++++++++++++-------- src/gl/textures/gl_hwtexture.cpp | 23 ++++++++++++ src/gl/textures/gl_hwtexture.h | 2 ++ src/gl/textures/gl_material.cpp | 33 +++++++++++++++-- src/gl/textures/gl_material.h | 3 ++ src/gl/textures/gl_texture.cpp | 41 --------------------- src/textures/textures.h | 5 --- 7 files changed, 104 insertions(+), 64 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index a658982bc..a87e522d3 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -73,6 +73,7 @@ #include "gl/shaders/gl_shader.h" #include "gl/stereo3d/gl_stereo3d.h" #include "gl/stereo3d/scoped_view_shifter.h" +#include "gl/textures/gl_translate.h" #include "gl/textures/gl_material.h" #include "gl/textures/gl_skyboxtexture.h" #include "gl/utility/gl_clock.h" @@ -979,6 +980,7 @@ struct FGLInterface : public FRenderer { bool UsesColormap() const; void PrecacheTexture(FTexture *tex, int cache); + void PrecacheSprite(FTexture *tex, SpriteHits &hits); void Precache(BYTE *texhitlist, TMap &actorhitlist); void RenderView(player_t *player); void WriteSavePic (player_t *player, FILE *file, int width, int height); @@ -1021,20 +1023,54 @@ void FGLInterface::PrecacheTexture(FTexture *tex, int cache) { if (cache) { - tex->PrecacheGL(cache); + if (gl_precache) + { + if (cache & (FTextureManager::HIT_Wall | FTextureManager::HIT_Flat | FTextureManager::HIT_Sky)) + { + FMaterial * gltex = FMaterial::ValidateTexture(tex, false); + if (gltex) gltex->Precache(); + } + } } else { - tex->UncacheGL(); + if (tex->gl_info.Material[0]) tex->gl_info.Material[0]->Clean(true); } } } +//========================================================================== +// +// DFrameBuffer :: PrecacheSprite +// +//========================================================================== + +void FGLInterface::PrecacheSprite(FTexture *tex, SpriteHits &hits) +{ + if (hits.CountUsed() == 0) + { + if (tex->gl_info.Material[1]) tex->gl_info.Material[1]->Clean(true); + } + else + { + FMaterial * gltex = FMaterial::ValidateTexture(tex, true); + if (gltex) gltex->PrecacheList(hits); + } +} + +//========================================================================== +// +// DFrameBuffer :: Precache +// +//========================================================================== + void FGLInterface::Precache(BYTE *texhitlist, TMap &actorhitlist) { - BYTE *spritelist = new BYTE[sprites.Size()]; + SpriteHits *spritelist = new SpriteHits[sprites.Size()]; + SpriteHits **spritehitlist = new SpriteHits*[TexMan.NumTextures()]; TMap::Iterator it(actorhitlist); TMap::Pair *pair; + memset(spritehitlist, 0, sizeof(SpriteHits**) * TexMan.NumTextures()); // this isn't done by the main code so it needs to be done here first: // check skybox textures and mark the separate faces as used @@ -1059,19 +1095,14 @@ void FGLInterface::Precache(BYTE *texhitlist, TMap &actorhit } } - - - - - memset(spritelist, 0, sprites.Size()); - while (it.NextPair(pair)) { PClassActor *cls = pair->Key; + int gltrans = GLTranslationPalette::GetInternalTranslation(GetDefaultByType(cls)->Translation); for (int i = 0; i < cls->NumOwnedStates; i++) { - spritelist[cls->OwnedStates[i].sprite] = true; + spritelist[cls->OwnedStates[i].sprite].Insert(gltrans, true); } } @@ -1079,7 +1110,7 @@ void FGLInterface::Precache(BYTE *texhitlist, TMap &actorhit for (int i = (int)(sprites.Size() - 1); i >= 0; i--) { - if (spritelist[i]) + if (spritelist[i].CountUsed()) { int j, k; for (j = 0; j < sprites[i].numframes; j++) @@ -1091,21 +1122,21 @@ void FGLInterface::Precache(BYTE *texhitlist, TMap &actorhit FTextureID pic = frame->Texture[k]; if (pic.isValid()) { - texhitlist[pic.GetIndex()] = FTextureManager::HIT_Sprite; + spritehitlist[pic.GetIndex()] = &spritelist[i]; } } } } } - delete[] spritelist; - - TexMan.precacheTime = I_FPSTime(); int cnt = TexMan.NumTextures(); for (int i = cnt - 1; i >= 0; i--) { PrecacheTexture(TexMan.ByIndex(i), texhitlist[i]); + if (spritehitlist[i] != nullptr) PrecacheSprite(TexMan.ByIndex(i), *spritehitlist[i]); } + delete[] spritehitlist; + delete[] spritelist; } diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 02ed64290..b964b030e 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -306,6 +306,29 @@ void FHardwareTexture::Clean(bool all) if (glDepthID != 0) glDeleteRenderbuffers(1, &glDepthID); } +//=========================================================================== +// +// Deletes all allocated resources and considers translations +// This will only be called for sprites +// +//=========================================================================== + +void FHardwareTexture::CleanUnused(SpriteHits &usedtranslations) +{ + if (usedtranslations.CheckKey(0) != nullptr) + { + glDefTex.Delete(); + } + for (int i = glTex_Translated.Size()-1; i>= 0; i--) + { + if (usedtranslations.CheckKey(glTex_Translated[i].translation) != nullptr) + { + glTex_Translated[i].Delete(); + glTex_Translated.Delete(i); + } + } +} + //=========================================================================== // // Destroys the texture diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h index 7fa0f0580..6b01fb437 100644 --- a/src/gl/textures/gl_hwtexture.h +++ b/src/gl/textures/gl_hwtexture.h @@ -13,6 +13,7 @@ class FCanvasTexture; class AActor; +typedef TMap SpriteHits; // For error catching while changing parameters. enum EInvalid @@ -79,6 +80,7 @@ public: unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation); void Clean(bool all); + void CleanUnused(SpriteHits &usedtranslations); }; #endif diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 74cdcd725..5207ea00d 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -91,6 +91,7 @@ FGLTexture::FGLTexture(FTexture * tx, bool expandpatches) bIsTransparent = -1; bExpandFlag = expandpatches; lastSampler = 254; + lastTranslation = -1; tex->gl_info.SystemTexture[expandpatches] = this; } @@ -165,16 +166,28 @@ unsigned char *FGLTexture::LoadHiresTexture(FTexture *tex, int *width, int *heig void FGLTexture::Clean(bool all) { - if (mHwTexture) + if (mHwTexture != nullptr) { if (!all) mHwTexture->Clean(false); else { delete mHwTexture; - mHwTexture = NULL; + mHwTexture = nullptr; } lastSampler = 253; + lastTranslation = -1; + } +} + + +void FGLTexture::CleanUnused(SpriteHits &usedtranslations) +{ + if (mHwTexture != nullptr) + { + mHwTexture->CleanUnused(usedtranslations); + lastSampler = 253; + lastTranslation = -1; } } @@ -334,8 +347,9 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla } if (!needmipmap) clampmode = CLAMP_XY_NOMIP; if (tex->bHasCanvas) static_cast(tex)->NeedUpdate(); - if (lastSampler != clampmode) + if (lastSampler != clampmode || lastTranslation != translation) lastSampler = GLRenderer->mSamplerManager->Bind(texunit, clampmode, lastSampler); + lastTranslation = translation; return hwtex; } return NULL; @@ -710,6 +724,19 @@ void FMaterial::Precache() Bind(0, 0); } +//=========================================================================== +// +// +// +//=========================================================================== +void FMaterial::PrecacheList(SpriteHits &translations) +{ + if (mBaseLayer != nullptr) mBaseLayer->CleanUnused(translations); + SpriteHits::Iterator it(translations); + SpriteHits::Pair *pair; + while(it.NextPair(pair)) Bind(0, pair->Key); +} + //=========================================================================== // // Retrieve texture coordinate info for per-wall scaling diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 79e5f52e2..dea0d4cf5 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -66,6 +66,7 @@ private: bool bHasColorkey; // only for hires bool bExpandFlag; BYTE lastSampler; + int lastTranslation; unsigned char * LoadHiresTexture(FTexture *hirescheck, int *width, int *height); @@ -80,6 +81,7 @@ public: unsigned char * CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded = true, bool alphatrans = false); void Clean(bool all); + void CleanUnused(SpriteHits &usedtranslations); int Dump(int i); }; @@ -127,6 +129,7 @@ public: FMaterial(FTexture *tex, bool forceexpand); ~FMaterial(); void Precache(); + void PrecacheList(SpriteHits &translations); bool isMasked() const { return !!mBaseLayer->tex->bMasked; diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 50671e4bd..f33fed6a3 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -240,7 +240,6 @@ FTexture::MiscGLInfo::MiscGLInfo() throw() mIsTransparent = -1; shaderspeed = 1.f; shaderindex = 0; - precacheTime = 0; Material[1] = Material[0] = NULL; SystemTexture[1] = SystemTexture[0] = NULL; @@ -310,46 +309,6 @@ void FTexture::CreateDefaultBrightmap() } -//========================================================================== -// -// Precaches a GL texture -// -//========================================================================== - -void FTexture::PrecacheGL(int cache) -{ - if (gl_precache) - { - if (cache & (FTextureManager::HIT_Wall | FTextureManager::HIT_Flat | FTextureManager::HIT_Sky)) - { - FMaterial * gltex = FMaterial::ValidateTexture(this, false); - if (gltex) gltex->Precache(); - } - if (cache & FTextureManager::HIT_Sprite) - { - FMaterial * gltex = FMaterial::ValidateTexture(this, true); - if (gltex) gltex->Precache(); - } - gl_info.precacheTime = TexMan.precacheTime; - } -} - -//========================================================================== -// -// Precaches a GL texture -// -//========================================================================== - -void FTexture::UncacheGL() -{ - if (gl_info.precacheTime != TexMan.precacheTime) - { - if (gl_info.Material[0]) gl_info.Material[0]->Clean(true); - if (gl_info.Material[1]) gl_info.Material[1]->Clean(true); - gl_info.precacheTime = 0; - } -} - //========================================================================== // // Calculates glow color for a texture diff --git a/src/textures/textures.h b/src/textures/textures.h index 91246c0fe..a3fd822fd 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -310,7 +310,6 @@ public: FloatRect *areas; int areacount; int shaderindex; - unsigned int precacheTime; float shaderspeed; int mIsTransparent:2; bool bGlowing:1; // Texture glows @@ -328,8 +327,6 @@ public: }; MiscGLInfo gl_info; - virtual void PrecacheGL(int cache); - virtual void UncacheGL(); void GetGlowColor(float *data); PalEntry GetSkyCapColor(bool bottom); bool isGlowing() { return gl_info.bGlowing; } @@ -458,8 +455,6 @@ public: FSwitchDef *FindSwitch (FTextureID texture); FDoorAnimation *FindAnimatedDoor (FTextureID picnum); - unsigned int precacheTime; - private: // texture counting From 942138b307672f552f6137bdcde196a749c2c637 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 May 2016 11:27:52 +0200 Subject: [PATCH 0574/1509] - undid some leftover texture state checks from the first attempt to handle this without sampler objects. This code was written under the assumption that the glGenerateMipmap function does not exist. But all supported hardware has this function through the GL_EXT_framebuffer_object extension. --- src/gl/textures/gl_material.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 5207ea00d..ee51bb2b9 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -300,7 +300,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla translation = GLTranslationPalette::GetInternalTranslation(translation); } - bool needmipmap = (clampmode <= CLAMP_XY) || !(gl.flags & RFL_SAMPLER_OBJECTS); + bool needmipmap = (clampmode <= CLAMP_XY); FHardwareTexture *hwtex = CreateHwTexture(); @@ -345,7 +345,6 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla } delete[] buffer; } - if (!needmipmap) clampmode = CLAMP_XY_NOMIP; if (tex->bHasCanvas) static_cast(tex)->NeedUpdate(); if (lastSampler != clampmode || lastTranslation != translation) lastSampler = GLRenderer->mSamplerManager->Bind(texunit, clampmode, lastSampler); From 4d7be0e20e0b400963661e487924407aa11074fc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 May 2016 13:10:00 +0200 Subject: [PATCH 0575/1509] - added software interpolation as a fallback for models. This is not tested yet so no guarantees! --- src/gl/data/gl_vertexbuffer.h | 7 +- src/gl/models/gl_models.cpp | 135 +++++++++++++++++++++---------- src/gl/models/gl_models_md2.cpp | 4 +- src/gl/models/gl_models_md3.cpp | 14 ++-- src/gl/models/gl_voxels.cpp | 4 +- src/gl/renderer/gl_renderstate.h | 5 ++ 6 files changed, 112 insertions(+), 57 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index c56cadcba..b88cc6ca1 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -197,11 +197,12 @@ struct FModelVertex class FModelVertexBuffer : public FVertexBuffer { int mIndexFrame[2]; - unsigned int ibo_id; + FModelVertex *vbo_ptr; + uint32_t ibo_id; public: - FModelVertexBuffer(bool needindex); + FModelVertexBuffer(bool needindex, bool singleframe); ~FModelVertexBuffer(); FModelVertex *LockVertexBuffer(unsigned int size); @@ -210,7 +211,7 @@ public: unsigned int *LockIndexBuffer(unsigned int size); void UnlockIndexBuffer(); - unsigned int SetupFrame(unsigned int frame1, unsigned int frame2); + unsigned int SetupFrame(unsigned int frame1, unsigned int frame2, unsigned int size); void BindVBO(); }; diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index dc937ea40..6b586706a 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -111,16 +111,22 @@ void gl_FlushModels() //=========================================================================== // +// Uses a hardware buffer if either single frame (i.e. no interpolation needed) +// or shading is available (interpolation is done by the vertex shader) // +// If interpolation has to be done on the CPU side this will fall back +// to CPU-side arrays. // //=========================================================================== -FModelVertexBuffer::FModelVertexBuffer(bool needindex) +FModelVertexBuffer::FModelVertexBuffer(bool needindex, bool singleframe) + : FVertexBuffer(singleframe || gl.glslversion > 0) { + vbo_ptr = nullptr; ibo_id = 0; if (needindex) { - glGenBuffers(1, &ibo_id); + glGenBuffers(1, &ibo_id); // The index buffer can always be a real buffer. } } @@ -161,6 +167,10 @@ FModelVertexBuffer::~FModelVertexBuffer() { glDeleteBuffers(1, &ibo_id); } + if (vbo_ptr != nullptr) + { + delete[] vbo_ptr; + } } //=========================================================================== @@ -171,9 +181,19 @@ FModelVertexBuffer::~FModelVertexBuffer() FModelVertex *FModelVertexBuffer::LockVertexBuffer(unsigned int size) { - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBufferData(GL_ARRAY_BUFFER, size * sizeof(FModelVertex), NULL, GL_STATIC_DRAW); - return (FModelVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, size * sizeof(FModelVertex), GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_BUFFER_BIT); + if (vbo_id > 0) + { + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferData(GL_ARRAY_BUFFER, size * sizeof(FModelVertex), nullptr, GL_STATIC_DRAW); + return (FModelVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, size * sizeof(FModelVertex), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + } + else + { + if (vbo_ptr != nullptr) delete[] vbo_ptr; + vbo_ptr = new FModelVertex[size]; + memset(vbo_ptr, 0, size * sizeof(FModelVertex)); + return vbo_ptr; + } } //=========================================================================== @@ -184,8 +204,11 @@ FModelVertex *FModelVertexBuffer::LockVertexBuffer(unsigned int size) void FModelVertexBuffer::UnlockVertexBuffer() { - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glUnmapBuffer(GL_ARRAY_BUFFER); + if (vbo_id > 0) + { + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glUnmapBuffer(GL_ARRAY_BUFFER); + } } //=========================================================================== @@ -204,7 +227,7 @@ unsigned int *FModelVertexBuffer::LockIndexBuffer(unsigned int size) } else { - return NULL; + return nullptr; } } @@ -216,8 +239,11 @@ unsigned int *FModelVertexBuffer::LockIndexBuffer(unsigned int size) void FModelVertexBuffer::UnlockIndexBuffer() { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); - glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); + if (ibo_id > 0) + { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); + glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); + } } @@ -227,21 +253,44 @@ void FModelVertexBuffer::UnlockIndexBuffer() // This must be called after gl_RenderState.Apply! // //=========================================================================== +static TArray iBuffer; -unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int frame2) +unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int frame2, unsigned int size) { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - if (gl.glslversion > 0) + if (vbo_id > 0) { - glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].x); - glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].u); - glVertexAttribPointer(VATTR_VERTEX2, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame2].x); + if (gl.glslversion > 0) + { + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].x); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].u); + glVertexAttribPointer(VATTR_VERTEX2, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame2].x); + } + else + { + // only used for single frame models so there is no vertex2 here, which has no use without a shader. + glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].u); + } + } + else if (frame1 == frame2 || size == 0 || gl_RenderState.GetInterpolationFactor() == 0.f) + { + glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &vbo_ptr[frame1].x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FModelVertex), &vbo_ptr[frame1].u); } else { - // only used for single frame models so there is no vertex2 here, which has no use without a shader. - glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].x); - glTexCoordPointer(2, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].u); + // must interpolate + iBuffer.Resize(size); + glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &iBuffer[0].x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FModelVertex), &vbo_ptr[frame1].u); + float frac = gl_RenderState.GetInterpolationFactor(); + for (unsigned i = 0; i < size; i++) + { + iBuffer[i].x = vbo_ptr[frame1].x * (1.f - frac) + vbo_ptr[frame2].x * frac; + iBuffer[i].y = vbo_ptr[frame1].y * (1.f - frac) + vbo_ptr[frame2].y * frac; + iBuffer[i].z = vbo_ptr[frame1].z * (1.f - frac) + vbo_ptr[frame2].z * frac; + } } return frame1; } @@ -254,7 +303,7 @@ unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int fr FModel::~FModel() { - if (mVBuf != NULL) delete mVBuf; + if (mVBuf != nullptr) delete mVBuf; } @@ -266,8 +315,8 @@ static int * SpriteModelHash; static void DeleteModelHash() { - if (SpriteModelHash != NULL) delete [] SpriteModelHash; - SpriteModelHash = NULL; + if (SpriteModelHash != nullptr) delete [] SpriteModelHash; + SpriteModelHash = nullptr; } //=========================================================================== @@ -283,7 +332,7 @@ static int FindGFXFile(FString & fn) int slash = fn.LastIndexOf('/'); if (dot > slash) fn.Truncate(dot); - static const char * extensions[] = { ".png", ".jpg", ".tga", ".pcx", NULL }; + static const char * extensions[] = { ".png", ".jpg", ".tga", ".pcx", nullptr }; for (const char ** extp=extensions; *extp; extp++) { @@ -313,7 +362,7 @@ FTexture * LoadSkin(const char * path, const char * fn) } else { - return NULL; + return nullptr; } } @@ -346,7 +395,7 @@ static int ModelFrameHash(FSpriteModelFrame * smf) static FModel * FindModel(const char * path, const char * modelfile) { - FModel * model = NULL; + FModel * model = nullptr; FString fullname; fullname.Format("%s%s", path, modelfile); @@ -355,7 +404,7 @@ static FModel * FindModel(const char * path, const char * modelfile) if (lump<0) { Printf("FindModel: '%s' not found\n", fullname.GetChars()); - return NULL; + return nullptr; } for(int i = 0; i< (int)Models.Size(); i++) @@ -380,26 +429,26 @@ static FModel * FindModel(const char * path, const char * modelfile) model = new FMD3Model; } - if (model != NULL) + if (model != nullptr) { if (!model->Load(path, lump, buffer, len)) { delete model; - return NULL; + return nullptr; } } else { // try loading as a voxel FVoxel *voxel = R_LoadKVX(lump); - if (voxel != NULL) + if (voxel != nullptr) { model = new FVoxelModel(voxel, true); } else { Printf("LoadModel: Unknown model format in '%s'\n", fullname.GetChars()); - return NULL; + return nullptr; } } // The vertex buffer cannot be initialized here because this gets called before OpenGL is initialized @@ -486,7 +535,7 @@ void gl_InitModels() smf.xscale=smf.yscale=smf.zscale=1.f; smf.type = PClass::FindClass(sc.String); - if (!smf.type || smf.type->Defaults == NULL) + if (!smf.type || smf.type->Defaults == nullptr) { sc.ScriptError("MODELDEF: Unknown actor type '%s'\n", sc.String); } @@ -631,12 +680,12 @@ void gl_InitModels() FixPathSeperator(sc.String); if (sc.Compare("")) { - smf.skins[index]=NULL; + smf.skins[index]=nullptr; } else { smf.skins[index]=LoadSkin(path.GetChars(), sc.String); - if (smf.skins[index] == NULL) + if (smf.skins[index] == nullptr) { Printf("Skin '%s' not found in '%s'\n", sc.String, smf.type->TypeName.GetChars()); @@ -678,7 +727,7 @@ void gl_InitModels() if (isframe) { sc.MustGetString(); - if (smf.models[index]!=NULL) + if (smf.models[index]!=nullptr) { smf.modelframes[index] = smf.models[index]->FindFrame(sc.String); if (smf.modelframes[index]==-1) sc.ScriptError("Unknown frame '%s' in %s", sc.String, smf.type->TypeName.GetChars()); @@ -765,7 +814,7 @@ FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame, if (frame < sprdef->numframes) { spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + frame]; - if (sprframe->Voxel != NULL) + if (sprframe->Voxel != nullptr) { int index = sprframe->Voxel->VoxeldefIndex; if (dropped && sprframe->Voxel->DroppedSpin !=sprframe->Voxel->PlacedSpin) index++; @@ -773,7 +822,7 @@ FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame, } } } - return NULL; + return nullptr; } @@ -792,7 +841,7 @@ void gl_RenderFrameModels( const FSpriteModelFrame *smf, { // [BB] Frame interpolation: Find the FSpriteModelFrame smfNext which follows after smf in the animation // and the scalar value inter ( element of [0,1) ), both necessary to determine the interpolated frame. - FSpriteModelFrame * smfNext = NULL; + FSpriteModelFrame * smfNext = nullptr; double inter = 0.; if( gl_interpolate_model_frames && !(smf->flags & MDL_NOINTERPOLATION) ) { @@ -841,7 +890,7 @@ void gl_RenderFrameModels( const FSpriteModelFrame *smf, { FModel * mdl = smf->models[i]; - if (mdl!=NULL) + if (mdl!=nullptr) { mdl->BuildVertexBuffer(); gl_RenderState.SetVertexBuffer(mdl->mVBuf); @@ -949,12 +998,12 @@ void gl_RenderModel(GLSprite * spr) gl_RenderState.mModelMatrix.rotate(-smf->rolloffset, 1, 0, 0); // consider the pixel stretching. For non-voxels this must be factored out here - float stretch = (smf->models[0] != NULL ? smf->models[0]->getAspectFactor() : 1.f) / glset.pixelstretch; + float stretch = (smf->models[0] != nullptr ? smf->models[0]->getAspectFactor() : 1.f) / glset.pixelstretch; gl_RenderState.mModelMatrix.scale(1, stretch, 1); gl_RenderState.EnableModelMatrix(true); - gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, spr->actor->GetClass(), NULL, translation ); + gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, spr->actor->GetClass(), nullptr, translation ); gl_RenderState.EnableModelMatrix(false); glDepthFunc(GL_LESS); @@ -975,7 +1024,7 @@ void gl_RenderHUDModel(pspdef_t *psp, float ofsX, float ofsY) FSpriteModelFrame *smf = gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->state->sprite, psp->state->GetFrame(), false); // [BB] No model found for this sprite, so we can't render anything. - if ( smf == NULL ) + if ( smf == nullptr ) return; glDepthFunc(GL_LEQUAL); @@ -1012,7 +1061,7 @@ void gl_RenderHUDModel(pspdef_t *psp, float ofsX, float ofsY) gl_RenderState.mViewMatrix.rotate(-smf->rolloffset, 1, 0, 0); gl_RenderState.ApplyMatrices(); - gl_RenderFrameModels( smf, psp->state, psp->tics, playermo->player->ReadyWeapon->GetClass(), NULL, 0 ); + gl_RenderFrameModels( smf, psp->state, psp->tics, playermo->player->ReadyWeapon->GetClass(), nullptr, 0 ); glDepthFunc(GL_LESS); if (!( playermo->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) @@ -1027,11 +1076,11 @@ void gl_RenderHUDModel(pspdef_t *psp, float ofsX, float ofsY) bool gl_IsHUDModelForPlayerAvailable (player_t * player) { - if ( (player == NULL) || (player->ReadyWeapon == NULL) || (player->psprites[0].state == NULL) ) + if ( (player == nullptr) || (player->ReadyWeapon == nullptr) || (player->psprites[0].state == nullptr) ) return false; FState* state = player->psprites[0].state; FSpriteModelFrame *smf = gl_FindModelFrame(player->ReadyWeapon->GetClass(), state->sprite, state->GetFrame(), false); - return ( smf != NULL ); + return ( smf != nullptr ); } diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index 7a27e12dc..b0713ce44 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -304,7 +304,7 @@ void FDMDModel::BuildVertexBuffer() int VertexBufferSize = info.numFrames * lodInfo[0].numTriangles * 3; unsigned int vindex = 0; - mVBuf = new FModelVertexBuffer(false); + mVBuf = new FModelVertexBuffer(false, info.numFrames == 1); FModelVertex *vertptr = mVBuf->LockVertexBuffer(VertexBufferSize); for (int i = 0; i < info.numFrames; i++) @@ -375,7 +375,7 @@ void FDMDModel::RenderFrame(FTexture * skin, int frameno, int frameno2, double i gl_RenderState.SetInterpolationFactor((float)inter); gl_RenderState.Apply(); - mVBuf->SetupFrame(frames[frameno].vindex, frames[frameno2].vindex); + mVBuf->SetupFrame(frames[frameno].vindex, frames[frameno2].vindex, lodInfo[0].numTriangles * 3); glDrawArrays(GL_TRIANGLES, 0, lodInfo[0].numTriangles * 3); gl_RenderState.SetInterpolationFactor(0.f); } diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index 024f8ac81..1a49d9691 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -186,7 +186,7 @@ bool FMD3Model::Load(const char * path, int lumpnum, const char * buffer, int le // [BB] According to the MD3 spec, Name is supposed to include the full path. s->skins[i] = LoadSkin("", shader[i].Name); // [BB] Fall back and check if Name is relative. - if (s->skins[i] == NULL) + if (s->skins[i] == nullptr) s->skins[i] = LoadSkin(path, shader[i].Name); } } @@ -255,7 +255,7 @@ void FMD3Model::LoadGeometry() void FMD3Model::BuildVertexBuffer() { - if (mVBuf == NULL) + if (mVBuf == nullptr) { LoadGeometry(); @@ -269,11 +269,11 @@ void FMD3Model::BuildVertexBuffer() ibufsize += 3 * surf->numTriangles; } - mVBuf = new FModelVertexBuffer(true); + mVBuf = new FModelVertexBuffer(true, numFrames == 1); FModelVertex *vertptr = mVBuf->LockVertexBuffer(vbufsize); unsigned int *indxptr = mVBuf->LockIndexBuffer(ibufsize); - assert(vertptr != NULL && indxptr != NULL); + assert(vertptr != nullptr && indxptr != nullptr); unsigned int vindex = 0, iindex = 0; @@ -354,7 +354,7 @@ void FMD3Model::RenderFrame(FTexture * skin, int frameno, int frameno2, double i gl_RenderState.SetMaterial(tex, CLAMP_NONE, translation, -1, false); gl_RenderState.Apply(); - mVBuf->SetupFrame(surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices); + mVBuf->SetupFrame(surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices, surf->numVertices); glDrawElements(GL_TRIANGLES, surf->numTriangles * 3, GL_UNSIGNED_INT, (void*)(intptr_t)(surf->iindex * sizeof(unsigned int))); } gl_RenderState.SetInterpolationFactor(0.f); @@ -370,6 +370,6 @@ FMD3Model::~FMD3Model() { if (frames) delete [] frames; if (surfaces) delete [] surfaces; - frames = NULL; - surfaces = NULL; + frames = nullptr; + surfaces = nullptr; } diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 3a34117b9..2fdb8e162 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -378,7 +378,7 @@ void FVoxelModel::BuildVertexBuffer() { Initialize(); - mVBuf = new FModelVertexBuffer(true); + mVBuf = new FModelVertexBuffer(true, true); FModelVertex *vertptr = mVBuf->LockVertexBuffer(mVertices.Size()); unsigned int *indxptr = mVBuf->LockIndexBuffer(mIndices.Size()); @@ -443,7 +443,7 @@ void FVoxelModel::RenderFrame(FTexture * skin, int frame, int frame2, double int gl_RenderState.SetMaterial(tex, CLAMP_NOFILTER, translation, -1, false); gl_RenderState.Apply(); - mVBuf->SetupFrame(0, 0); + mVBuf->SetupFrame(0, 0, 0); glDrawElements(GL_TRIANGLES, mNumIndices, GL_UNSIGNED_INT, (void*)(intptr_t)0); } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index cebbb9570..0172488eb 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -439,6 +439,11 @@ public: mInterpolationFactor = fac; } + float GetInterpolationFactor() + { + return mInterpolationFactor; + } + // Backwards compatibility crap follows void ApplyFixedFunction(); void DrawColormapOverlay(); From 0e14f00b51aee74c2aec6c9e48ecd4289a4e3abd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 May 2016 13:39:41 +0200 Subject: [PATCH 0576/1509] - fixed caching of texture sampler state for old hardware. - fixed handling of CLAMP_XY_NOMIP sampler mode. This cannot be lumped together with CLAMP_XY because it has different mipmap requirements. --- src/gl/system/gl_interface.cpp | 2 +- src/gl/textures/gl_material.cpp | 3 ++- src/gl/textures/gl_samplers.cpp | 36 +++++++++++++++++---------------- src/gl/textures/gl_samplers.h | 1 - 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index e6e802e5c..7d091ebb6 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -168,7 +168,7 @@ void gl_LoadExtensions() gl.vendorstring = (char*)glGetString(GL_VENDOR); gl.lightmethod = LM_SOFTWARE; - if (gl.version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) + if ((gl.version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) && !Args->CheckParm("-nosampler")) { gl.flags |= RFL_SAMPLER_OBJECTS; } diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index ee51bb2b9..6a579b0d5 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -346,7 +346,8 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla delete[] buffer; } if (tex->bHasCanvas) static_cast(tex)->NeedUpdate(); - if (lastSampler != clampmode || lastTranslation != translation) + if (translation != lastTranslation) lastSampler = 254; + if (lastSampler != clampmode) lastSampler = GLRenderer->mSamplerManager->Bind(texunit, clampmode, lastSampler); lastTranslation = translation; return hwtex; diff --git a/src/gl/textures/gl_samplers.cpp b/src/gl/textures/gl_samplers.cpp index db0193c69..cee2fd894 100644 --- a/src/gl/textures/gl_samplers.cpp +++ b/src/gl/textures/gl_samplers.cpp @@ -86,7 +86,6 @@ void FSamplerManager::UnbindAll() { for (int i = 0; i < FHardwareTexture::MAX_TEXTURES; i++) { - mLastBound[i] = 0; glBindSampler(i, 0); } } @@ -97,12 +96,8 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval) if (gl.flags & RFL_SAMPLER_OBJECTS) { unsigned int samp = mSamplers[num]; - //if (samp != mLastBound[texunit]) - { - glBindSampler(texunit, samp); - mLastBound[texunit] = samp; - return 255; - } + glBindSampler(texunit, samp); + return 255; } else { @@ -112,7 +107,7 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval) case CLAMP_NONE: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - if (lastval > CLAMP_XY_NOMIP) + if (lastval >= CLAMP_XY_NOMIP) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); @@ -123,7 +118,7 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval) case CLAMP_X: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - if (lastval > CLAMP_XY_NOMIP) + if (lastval >= CLAMP_XY_NOMIP) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); @@ -134,7 +129,18 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval) case CLAMP_Y: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - if (lastval > CLAMP_XY_NOMIP) + if (lastval >= CLAMP_XY_NOMIP) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + } + break; + + case CLAMP_XY: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + if (lastval >= CLAMP_XY_NOMIP) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); @@ -143,15 +149,11 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval) break; case CLAMP_XY_NOMIP: - case CLAMP_XY: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - if (lastval > CLAMP_XY_NOMIP) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); - } + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1); break; case CLAMP_NOFILTER: diff --git a/src/gl/textures/gl_samplers.h b/src/gl/textures/gl_samplers.h index daba65d45..b74d49a33 100644 --- a/src/gl/textures/gl_samplers.h +++ b/src/gl/textures/gl_samplers.h @@ -8,7 +8,6 @@ class FSamplerManager // We need 6 different samplers: 4 for the different clamping modes, // one for 2D-textures and one for voxel textures unsigned int mSamplers[7]; - unsigned int mLastBound[FHardwareTexture::MAX_TEXTURES]; void UnbindAll(); From f7fda94ec9d2e9aa7b49549411062f95c90df7c5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 May 2016 15:45:21 +0200 Subject: [PATCH 0577/1509] - changed model data to store models and textures by index instead of by pointer. The indices are needed for efficient precaching and actual changes to the logic are minor so that this was the best option overall. --- src/gl/models/gl_models.cpp | 87 +++++++++++++++------------------ src/gl/models/gl_models.h | 32 +++++++++--- src/gl/models/gl_models_md2.cpp | 8 +-- src/gl/models/gl_models_md3.cpp | 8 +-- src/gl/models/gl_voxels.cpp | 3 +- 5 files changed, 73 insertions(+), 65 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 6b586706a..88c179567 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -73,32 +73,17 @@ EXTERN_CVAR(Int, gl_fogmode) extern TDeletingArray Voxels; extern TDeletingArray VoxelDefs; - -class DeletingModelArray : public TArray -{ -public: - -#if 1 - ~DeletingModelArray() - { - for(unsigned i=0;i= 0; i--) { Models[i]->BuildVertexBuffer(); } + */ } void gl_FlushModels() @@ -327,6 +312,9 @@ static void DeleteModelHash() static int FindGFXFile(FString & fn) { + int lump = Wads.CheckNumForFullName(fn); // if we find something that matches the name plus the extension, return it and do not enter the substitution logic below. + if (lump != -1) return lump; + int best = -1; int dot = fn.LastIndexOf('.'); int slash = fn.LastIndexOf('/'); @@ -349,7 +337,7 @@ static int FindGFXFile(FString & fn) // //=========================================================================== -FTexture * LoadSkin(const char * path, const char * fn) +FTextureID LoadSkin(const char * path, const char * fn) { FString buffer; @@ -358,11 +346,11 @@ FTexture * LoadSkin(const char * path, const char * fn) int texlump = FindGFXFile(buffer); if (texlump>=0) { - return TexMan.FindTexture(Wads.GetLumpFullName(texlump), FTexture::TEX_Any, FTextureManager::TEXMAN_TryAny); + return TexMan.CheckForTexture(Wads.GetLumpFullName(texlump), FTexture::TEX_Any, FTextureManager::TEXMAN_TryAny); } else { - return nullptr; + return FNullTextureID(); } } @@ -393,7 +381,7 @@ static int ModelFrameHash(FSpriteModelFrame * smf) // //=========================================================================== -static FModel * FindModel(const char * path, const char * modelfile) +static unsigned FindModel(const char * path, const char * modelfile) { FModel * model = nullptr; FString fullname; @@ -404,12 +392,12 @@ static FModel * FindModel(const char * path, const char * modelfile) if (lump<0) { Printf("FindModel: '%s' not found\n", fullname.GetChars()); - return nullptr; + return -1; } - for(int i = 0; i< (int)Models.Size(); i++) + for(unsigned i = 0; i< Models.Size(); i++) { - if (!Models[i]->mFileName.CompareNoCase(fullname)) return Models[i]; + if (!Models[i]->mFileName.CompareNoCase(fullname)) return i; } int len = Wads.LumpLength(lump); @@ -434,7 +422,7 @@ static FModel * FindModel(const char * path, const char * modelfile) if (!model->Load(path, lump, buffer, len)) { delete model; - return nullptr; + return -1; } } else @@ -448,13 +436,12 @@ static FModel * FindModel(const char * path, const char * modelfile) else { Printf("LoadModel: Unknown model format in '%s'\n", fullname.GetChars()); - return nullptr; + return -1; } } // The vertex buffer cannot be initialized here because this gets called before OpenGL is initialized model->mFileName = fullname; - Models.Push(model); - return model; + return Models.Push(model); } //=========================================================================== @@ -493,8 +480,9 @@ void gl_InitModels() { FVoxelModel *md = (FVoxelModel*)Models[VoxelDefs[i]->Voxel->VoxelIndex]; memset(&smf, 0, sizeof(smf)); - smf.models[0] = md; - smf.skins[0] = md->GetPaletteTexture(); + smf.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1; + smf.modelIDs[0] = VoxelDefs[i]->Voxel->VoxelIndex; + smf.skinIDs[0] = md->GetPaletteTexture(); smf.xscale = smf.yscale = smf.zscale = VoxelDefs[i]->Scale; smf.angleoffset = VoxelDefs[i]->AngleOffset.Degrees; if (VoxelDefs[i]->PlacedSpin != 0) @@ -523,6 +511,7 @@ void gl_InitModels() } memset(&smf, 0, sizeof(smf)); + smf.modelIDs[0] = smf.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1; while ((Lump = Wads.FindLump("MODELDEF", &lastLump)) != -1) { FScanner sc(Lump); @@ -532,6 +521,7 @@ void gl_InitModels() { sc.MustGetString(); memset(&smf, 0, sizeof(smf)); + smf.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1; smf.xscale=smf.yscale=smf.zscale=1.f; smf.type = PClass::FindClass(sc.String); @@ -554,15 +544,15 @@ void gl_InitModels() else if (sc.Compare("model")) { sc.MustGetNumber(); - index=sc.Number; - if (index<0 || index>=MAX_MODELS_PER_FRAME) + index = sc.Number; + if (index < 0 || index >= MAX_MODELS_PER_FRAME) { sc.ScriptError("Too many models in %s", smf.type->TypeName.GetChars()); } sc.MustGetString(); FixPathSeperator(sc.String); - smf.models[index] = FindModel(path.GetChars(), sc.String); - if (!smf.models[index]) + smf.modelIDs[index] = FindModel(path.GetChars(), sc.String); + if (smf.modelIDs[index] == -1) { Printf("%s: model not found in %s\n", sc.String, path.GetChars()); } @@ -570,11 +560,11 @@ void gl_InitModels() else if (sc.Compare("scale")) { sc.MustGetFloat(); - smf.xscale=sc.Float; + smf.xscale = sc.Float; sc.MustGetFloat(); - smf.yscale=sc.Float; + smf.yscale = sc.Float; sc.MustGetFloat(); - smf.zscale=sc.Float; + smf.zscale = sc.Float; } // [BB] Added zoffset reading. // Now it must be considered deprecated. @@ -680,12 +670,12 @@ void gl_InitModels() FixPathSeperator(sc.String); if (sc.Compare("")) { - smf.skins[index]=nullptr; + smf.skinIDs[index]=FNullTextureID(); } else { - smf.skins[index]=LoadSkin(path.GetChars(), sc.String); - if (smf.skins[index] == nullptr) + smf.skinIDs[index] = LoadSkin(path.GetChars(), sc.String); + if (!smf.skinIDs[index].isValid()) { Printf("Skin '%s' not found in '%s'\n", sc.String, smf.type->TypeName.GetChars()); @@ -727,9 +717,10 @@ void gl_InitModels() if (isframe) { sc.MustGetString(); - if (smf.models[index]!=nullptr) + if (smf.modelIDs[index] != -1) { - smf.modelframes[index] = smf.models[index]->FindFrame(sc.String); + FModel *model = Models[smf.modelIDs[index]]; + smf.modelframes[index] = model->FindFrame(sc.String); if (smf.modelframes[index]==-1) sc.ScriptError("Unknown frame '%s' in %s", sc.String, smf.type->TypeName.GetChars()); } else smf.modelframes[index] = -1; @@ -888,17 +879,17 @@ void gl_RenderFrameModels( const FSpriteModelFrame *smf, for(int i=0; imodels[i]; - - if (mdl!=nullptr) + if (smf->modelIDs[i] != -1) { + FModel * mdl = Models[smf->modelIDs[i]]; + FTexture *tex = smf->skinIDs[i].isValid()? TexMan(smf->skinIDs[i]) : nullptr; mdl->BuildVertexBuffer(); gl_RenderState.SetVertexBuffer(mdl->mVBuf); if ( smfNext && smf->modelframes[i] != smfNext->modelframes[i] ) - mdl->RenderFrame(smf->skins[i], smf->modelframes[i], smfNext->modelframes[i], inter, translation); + mdl->RenderFrame(tex, smf->modelframes[i], smfNext->modelframes[i], inter, translation); else - mdl->RenderFrame(smf->skins[i], smf->modelframes[i], smf->modelframes[i], 0.f, translation); + mdl->RenderFrame(tex, smf->modelframes[i], smf->modelframes[i], 0.f, translation); gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); } @@ -998,7 +989,7 @@ void gl_RenderModel(GLSprite * spr) gl_RenderState.mModelMatrix.rotate(-smf->rolloffset, 1, 0, 0); // consider the pixel stretching. For non-voxels this must be factored out here - float stretch = (smf->models[0] != nullptr ? smf->models[0]->getAspectFactor() : 1.f) / glset.pixelstretch; + float stretch = (smf->modelIDs[0] != -1 ? Models[smf->modelIDs[0]]->getAspectFactor() : 1.f) / glset.pixelstretch; gl_RenderState.mModelMatrix.scale(1, stretch, 1); diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index a99f81322..70379a3d2 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -1,6 +1,7 @@ #ifndef __GL_MODELS_H_ #define __GL_MODELS_H_ +#include "tarray.h" #include "gl/utility/gl_geometric.h" #include "gl/data/gl_vertexbuffer.h" #include "p_pspr.h" @@ -16,7 +17,7 @@ enum { VX, VZ, VY }; #define MD3_MAGIC 0x33504449 #define NUMVERTEXNORMALS 162 -FTexture * LoadSkin(const char * path, const char * fn); +FTextureID LoadSkin(const char * path, const char * fn); class FModel @@ -124,7 +125,7 @@ protected: int mLumpNum; DMDHeader header; DMDInfo info; - FTexture ** skins; + FTextureID * skins; ModelFrame * frames; bool allowTexComp; // Allow texture compression with this. @@ -201,7 +202,7 @@ class FMD3Model : public FModel int numTriangles; int numSkins; - FTexture ** skins; + FTextureID * skins; MD3Triangle * tris; MD3TexCoord * texcoords; MD3Vertex * vertices; @@ -295,7 +296,7 @@ class FVoxelModel : public FModel protected: FVoxel *mVoxel; bool mOwningVoxel; // if created through MODELDEF deleting this object must also delete the voxel object - FTexture *mPalette; + FTextureID mPalette; unsigned int mNumIndices; TArray mVertices; TArray mIndices; @@ -311,7 +312,7 @@ public: void Initialize(); virtual int FindFrame(const char * name); virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); - FTexture *GetPaletteTexture() const { return mPalette; } + FTextureID GetPaletteTexture() const { return mPalette; } void BuildVertexBuffer(); float getAspectFactor(); }; @@ -338,8 +339,8 @@ enum struct FSpriteModelFrame { - FModel * models[MAX_MODELS_PER_FRAME]; - FTexture * skins[MAX_MODELS_PER_FRAME]; + int modelIDs[MAX_MODELS_PER_FRAME]; + FTextureID skinIDs[MAX_MODELS_PER_FRAME]; int modelframes[MAX_MODELS_PER_FRAME]; float xscale, yscale, zscale; // [BB] Added zoffset, rotation parameters and flags. @@ -368,4 +369,21 @@ void gl_RenderModel(GLSprite * spr); void gl_RenderHUDModel(pspdef_t *psp, float ofsx, float ofsy); bool gl_IsHUDModelForPlayerAvailable (player_t * player); + +class DeletingModelArray : public TArray +{ +public: + + ~DeletingModelArray() + { + for (unsigned i = 0; iOfs_Shaders)); - s->skins = new FTexture *[s->numSkins]; + s->skins = new FTextureID[s->numSkins]; for (int i = 0; i < s->numSkins; i++) { // [BB] According to the MD3 spec, Name is supposed to include the full path. s->skins[i] = LoadSkin("", shader[i].Name); // [BB] Fall back and check if Name is relative. - if (s->skins[i] == nullptr) + if (!s->skins[i].isValid()) s->skins[i] = LoadSkin(path, shader[i].Name); } } @@ -344,8 +344,8 @@ void FMD3Model::RenderFrame(FTexture * skin, int frameno, int frameno2, double i FTexture *surfaceSkin = skin; if (!surfaceSkin) { - if (surf->numSkins==0) return; - surfaceSkin = surf->skins[0]; + if (surf->numSkins==0 || !surf->skins[0].isValid()) return; + surfaceSkin = TexMan(surf->skins[0]); if (!surfaceSkin) return; } diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 2fdb8e162..babb62d10 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -213,7 +213,7 @@ FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned) { mVoxel = voxel; mOwningVoxel = owned; - mPalette = new FVoxelTexture(voxel); + mPalette = TexMan.AddTexture(new FVoxelTexture(voxel)); } //=========================================================================== @@ -224,7 +224,6 @@ FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned) FVoxelModel::~FVoxelModel() { - delete mPalette; if (mOwningVoxel) delete mVoxel; } From 534500f36d5c87e3262cd289d73abbc39713610e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 May 2016 16:49:10 +0200 Subject: [PATCH 0578/1509] - fixed software-based model interpolation. --- src/gl/models/gl_models.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 88c179567..e2187c59c 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -272,9 +272,9 @@ unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int fr float frac = gl_RenderState.GetInterpolationFactor(); for (unsigned i = 0; i < size; i++) { - iBuffer[i].x = vbo_ptr[frame1].x * (1.f - frac) + vbo_ptr[frame2].x * frac; - iBuffer[i].y = vbo_ptr[frame1].y * (1.f - frac) + vbo_ptr[frame2].y * frac; - iBuffer[i].z = vbo_ptr[frame1].z * (1.f - frac) + vbo_ptr[frame2].z * frac; + iBuffer[i].x = vbo_ptr[frame1 + i].x * (1.f - frac) + vbo_ptr[frame2 + i].x * frac; + iBuffer[i].y = vbo_ptr[frame1 + i].y * (1.f - frac) + vbo_ptr[frame2 + i].y * frac; + iBuffer[i].z = vbo_ptr[frame1 + i].z * (1.f - frac) + vbo_ptr[frame2 + i].z * frac; } } return frame1; From b6af4677f362869250c1092e892db568a7b2809a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 May 2016 18:14:16 +0200 Subject: [PATCH 0579/1509] - implemented model precaching. --- src/gl/models/gl_models.h | 5 ++ src/gl/models/gl_models_md2.cpp | 15 +++++ src/gl/models/gl_models_md3.cpp | 21 +++++++ src/gl/models/gl_voxels.cpp | 11 ++++ src/gl/scene/gl_scene.cpp | 106 +++++++++++++++++++++++--------- 5 files changed, 129 insertions(+), 29 deletions(-) diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 70379a3d2..33fa00736 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -34,6 +34,7 @@ public: virtual int FindFrame(const char * name) = 0; virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0; virtual void BuildVertexBuffer() = 0; + virtual void AddSkins(BYTE *hitlist) = 0; void DestroyVertexBuffer() { delete mVBuf; @@ -155,6 +156,8 @@ public: virtual int FindFrame(const char * name); virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); virtual void LoadGeometry(); + virtual void AddSkins(BYTE *hitlist); + void UnloadGeometry(); void BuildVertexBuffer(); @@ -260,6 +263,7 @@ public: virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); void LoadGeometry(); void BuildVertexBuffer(); + virtual void AddSkins(BYTE *hitlist); }; struct FVoxelVertexHash @@ -312,6 +316,7 @@ public: void Initialize(); virtual int FindFrame(const char * name); virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); + virtual void AddSkins(BYTE *hitlist); FTextureID GetPaletteTexture() const { return mPalette; } void BuildVertexBuffer(); float getAspectFactor(); diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index c45569df9..c0bd155fb 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -336,7 +336,22 @@ void FDMDModel::BuildVertexBuffer() } } +//=========================================================================== +// +// for skin precaching +// +//=========================================================================== +void FDMDModel::AddSkins(BYTE *hitlist) +{ + for (int i = 0; i < info.numSkins; i++) + { + if (skins[i].isValid()) + { + hitlist[skins[i].GetIndex()] |= FTexture::TEX_Flat; + } + } +} //=========================================================================== // diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index 3da5bd1c0..267e85c91 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -309,6 +309,27 @@ void FMD3Model::BuildVertexBuffer() } +//=========================================================================== +// +// for skin precaching +// +//=========================================================================== + +void FMD3Model::AddSkins(BYTE *hitlist) +{ + for (int i = 0; i < numSurfaces; i++) + { + MD3Surface * surf = &surfaces[i]; + for (int j = 0; j < surf->numSkins; j++) + { + if (surf->skins[j].isValid()) + { + hitlist[surf->skins[j].GetIndex()] |= FTexture::TEX_Flat; + } + } + } +} + //=========================================================================== // // diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index babb62d10..ec7f0573b 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -397,6 +397,17 @@ void FVoxelModel::BuildVertexBuffer() } +//=========================================================================== +// +// for skin precaching +// +//=========================================================================== + +void FVoxelModel::AddSkins(BYTE *hitlist) +{ + hitlist[mPalette.GetIndex()] |= FTexture::TEX_Flat; +} + //=========================================================================== // // diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index a87e522d3..44368775a 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -1019,23 +1019,10 @@ bool FGLInterface::UsesColormap() const void FGLInterface::PrecacheTexture(FTexture *tex, int cache) { - if (tex != NULL) + if (cache & (FTextureManager::HIT_Wall | FTextureManager::HIT_Flat | FTextureManager::HIT_Sky)) { - if (cache) - { - if (gl_precache) - { - if (cache & (FTextureManager::HIT_Wall | FTextureManager::HIT_Flat | FTextureManager::HIT_Sky)) - { - FMaterial * gltex = FMaterial::ValidateTexture(tex, false); - if (gltex) gltex->Precache(); - } - } - } - else - { - if (tex->gl_info.Material[0]) tex->gl_info.Material[0]->Clean(true); - } + FMaterial * gltex = FMaterial::ValidateTexture(tex, false); + if (gltex) gltex->Precache(); } } @@ -1047,15 +1034,8 @@ void FGLInterface::PrecacheTexture(FTexture *tex, int cache) void FGLInterface::PrecacheSprite(FTexture *tex, SpriteHits &hits) { - if (hits.CountUsed() == 0) - { - if (tex->gl_info.Material[1]) tex->gl_info.Material[1]->Clean(true); - } - else - { - FMaterial * gltex = FMaterial::ValidateTexture(tex, true); - if (gltex) gltex->PrecacheList(hits); - } + FMaterial * gltex = FMaterial::ValidateTexture(tex, true); + if (gltex) gltex->PrecacheList(hits); } //========================================================================== @@ -1070,6 +1050,8 @@ void FGLInterface::Precache(BYTE *texhitlist, TMap &actorhit SpriteHits **spritehitlist = new SpriteHits*[TexMan.NumTextures()]; TMap::Iterator it(actorhitlist); TMap::Pair *pair; + BYTE *modellist = new BYTE[Models.Size()]; + memset(modellist, 0, Models.Size()); memset(spritehitlist, 0, sizeof(SpriteHits**) * TexMan.NumTextures()); // this isn't done by the main code so it needs to be done here first: @@ -1095,6 +1077,9 @@ void FGLInterface::Precache(BYTE *texhitlist, TMap &actorhit } } + // Check all used actors. + // 1. mark all sprites associated with its states + // 2. mark all model data and skins associated with its states while (it.NextPair(pair)) { PClassActor *cls = pair->Key; @@ -1103,11 +1088,29 @@ void FGLInterface::Precache(BYTE *texhitlist, TMap &actorhit for (int i = 0; i < cls->NumOwnedStates; i++) { spritelist[cls->OwnedStates[i].sprite].Insert(gltrans, true); + FSpriteModelFrame * smf = gl_FindModelFrame(cls, cls->OwnedStates[i].sprite, cls->OwnedStates[i].Frame, false); + if (smf != NULL) + { + for (int i = 0; i < MAX_MODELS_PER_FRAME; i++) + { + if (smf->skinIDs[i].isValid()) + { + texhitlist[smf->skinIDs[i].GetIndex()] |= FTexture::TEX_Flat; + } + else if (smf->modelIDs[i] != -1) + { + Models[smf->modelIDs[i]]->AddSkins(texhitlist); + } + if (smf->modelIDs[i] != -1) + { + modellist[smf->modelIDs[i]] = 1; + } + } + } } } - // Precache textures (and sprites). - + // mark all sprite textures belonging to the marked sprites. for (int i = (int)(sprites.Size() - 1); i >= 0; i--) { if (spritelist[i].CountUsed()) @@ -1129,14 +1132,59 @@ void FGLInterface::Precache(BYTE *texhitlist, TMap &actorhit } } + // delete everything unused before creating any new resources to avoid memory usage peaks. + + // delete unused models + for (unsigned i = 0; i < Models.Size(); i++) + { + if (!modellist[i]) Models[i]->DestroyVertexBuffer(); + } + + // delete unused textures int cnt = TexMan.NumTextures(); for (int i = cnt - 1; i >= 0; i--) { - PrecacheTexture(TexMan.ByIndex(i), texhitlist[i]); - if (spritehitlist[i] != nullptr) PrecacheSprite(TexMan.ByIndex(i), *spritehitlist[i]); + FTexture *tex = TexMan.ByIndex(i); + if (tex != nullptr) + { + if (!texhitlist[i]) + { + if (tex->gl_info.Material[0]) tex->gl_info.Material[0]->Clean(true); + } + if (spritehitlist[i] == nullptr || (*spritehitlist[i]).CountUsed() == 0) + { + if (tex->gl_info.Material[1]) tex->gl_info.Material[1]->Clean(true); + } + } } + + if (gl_precache) + { + // cache all used textures + for (int i = cnt - 1; i >= 0; i--) + { + FTexture *tex = TexMan.ByIndex(i); + if (tex != nullptr) + { + PrecacheTexture(tex, texhitlist[i]); + if (spritehitlist[i] != nullptr && (*spritehitlist[i]).CountUsed() > 0) + { + PrecacheSprite(tex, *spritehitlist[i]); + } + } + } + + // cache all used models + for (unsigned i = 0; i < Models.Size(); i++) + { + if (modellist[i]) + Models[i]->BuildVertexBuffer(); + } + } + delete[] spritehitlist; delete[] spritelist; + delete[] modellist; } From 0f8f08edfd5c9657f5429ad332ad57fe2ec4a53e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 May 2016 19:24:28 +0200 Subject: [PATCH 0580/1509] - fixed: camera facing sprites need to orient themselves toward the actual camera position, not the view actor (which may be invalid or in a completely different part of the map if a portal is being rendered.) --- src/gl/scene/gl_sprite.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 3f90b251e..c85de8a0d 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -287,8 +287,8 @@ void GLSprite::Draw(int pass) if (drawBillboardFacingCamera) { // [CMB] Rotate relative to camera XY position, not just camera direction, // which is nicer in VR - float xrel = xcenter - GLRenderer->mViewActor->X(); - float yrel = ycenter - GLRenderer->mViewActor->Y(); + float xrel = xcenter - ViewPos.X; + float yrel = ycenter - ViewPos.Y; float absAngleDeg = RAD2DEG(atan2(-yrel, xrel)); float counterRotationDeg = 270. - GLRenderer->mAngles.Yaw.Degrees; // counteracts existing sprite rotation float relAngleDeg = counterRotationDeg + absAngleDeg; From 0a943719748a4b672628211313f7b7fd53885abf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 May 2016 23:28:42 +0200 Subject: [PATCH 0581/1509] - reinstated old code for rendering fog boundaries and mirrot surfaces without shaders. - added code for filling the render list for textured dynamic lights. This is not yet active because no code is present to handle this data. --- src/gl/compatibility/gl_20.cpp | 92 +++++++++++++++++++++++++++++++++- src/gl/scene/gl_wall.h | 3 ++ src/gl/scene/gl_walls.cpp | 5 ++ src/gl/scene/gl_walls_draw.cpp | 44 ++++++++++------ src/gl/system/gl_load.c | 2 + 5 files changed, 130 insertions(+), 16 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index e059a3563..1dac5ac38 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -49,6 +49,7 @@ #include "gl/dynlights/gl_dynlight.h" #include "gl/utility/gl_geometric.h" #include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_renderstate.h" @@ -452,7 +453,7 @@ bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, bool gl_SetupLightTexture() { - if (GLRenderer->gllight == NULL) return false; + if (GLRenderer->gllight == nullptr) return false; FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight, false); pat->Bind(CLAMP_XY, 0); return true; @@ -464,6 +465,95 @@ bool gl_SetupLightTexture() // //========================================================================== +bool GLWall::PutWallCompat(int passflag) +{ + static int list_indices[2][2] = + { { GLLDL_WALLS_PLAIN, GLLDL_WALLS_FOG },{ GLLDL_WALLS_MASKED, GLLDL_WALLS_FOGMASKED } }; + + // are lights possible? + if (gl_fixedcolormap != CM_DEFAULT || !gl_lights || seg->sidedef == nullptr || type == RENDERWALL_M2SNF || !gltexture) return false; + + // multipassing these is problematic. + if ((flags&GLWF_SKYHACK && type == RENDERWALL_M2S)) return false; + + // Any lights affecting this wall? + if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + if (seg->sidedef->lighthead == nullptr) return false; + } + else if (sub) + { + if (sub->lighthead != nullptr) return false; + } + + bool foggy = (!gl_isBlack(Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE); + bool masked = passflag == 2 && gltexture->isMasked(); + + int list = list_indices[masked][foggy]; + if (list == GLLDL_WALLS_PLAIN) + { + if (gltexture->tex->gl_info.Brightmap && gl.glslversion >= 0.f) list = GLLDL_WALLS_BRIGHT; + //if (flags & GLWF_GLOW) list = GLLDL_WALLS_BRIGHT; + } + gl_drawinfo->dldrawlists[list].AddWall(this); + return true; + +} + +//========================================================================== +// +// Fog boundary without any shader support +// +//========================================================================== + +void GLWall::RenderFogBoundaryCompat() +{ + // without shaders some approximation is needed. This won't look as good + // as the shader version but it's an acceptable compromise. + float fogdensity = gl_GetFogDensity(lightlevel, Colormap.FadeColor); + + float dist1 = Dist2(ViewPos.X, ViewPos.Y, glseg.x1, glseg.y1); + float dist2 = Dist2(ViewPos.X, ViewPos.Y, glseg.x2, glseg.y2); + + // these values were determined by trial and error and are scale dependent! + float fogd1 = (0.95f - exp(-fogdensity*dist1 / 62500.f)) * 1.05f; + float fogd2 = (0.95f - exp(-fogdensity*dist2 / 62500.f)) * 1.05f; + + float fc[4] = { Colormap.FadeColor.r / 255.0f,Colormap.FadeColor.g / 255.0f,Colormap.FadeColor.b / 255.0f,fogd2 }; + + gl_RenderState.EnableTexture(false); + gl_RenderState.EnableFog(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0); + gl_RenderState.Apply(); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); + glDepthFunc(GL_LEQUAL); + glColor4f(fc[0], fc[1], fc[2], fogd1); + glBegin(GL_TRIANGLE_FAN); + glTexCoord2f(lolft.u, lolft.v); + glVertex3f(glseg.x1, zbottom[0], glseg.y1); + glTexCoord2f(uplft.u, uplft.v); + glVertex3f(glseg.x1, ztop[0], glseg.y1); + glColor4f(fc[0], fc[1], fc[2], fogd2); + glTexCoord2f(uprgt.u, uprgt.v); + glVertex3f(glseg.x2, ztop[1], glseg.y2); + glTexCoord2f(lorgt.u, lorgt.v); + glVertex3f(glseg.x2, zbottom[1], glseg.y2); + glEnd(); + glDepthFunc(GL_LESS); + glPolygonOffset(0.0f, 0.0f); + glDisable(GL_POLYGON_OFFSET_FILL); + gl_RenderState.EnableFog(true); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f); + gl_RenderState.EnableTexture(true); +} + +//========================================================================== +// +// +// +//========================================================================== + void FGLRenderer::RenderMultipassStuff() { return; diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 0d8096e76..fdf78ee6f 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -171,10 +171,13 @@ public: private: void CheckGlowing(); + bool PutWallCompat(int passflag); void PutWall(bool translucent); void PutPortal(int ptype); void CheckTexturePosition(); + void RenderFogBoundaryCompat(); + void Put3DWall(lightlist_t * lightlist, bool translucent); void SplitWallComplex(sector_t * frontsector, bool translucent, float maplightbottomleft, float maplightbottomright); void SplitWall(sector_t * frontsector, bool translucent); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index ae7cb70c8..906f7f3e1 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -139,6 +139,11 @@ void GLWall::PutWall(bool translucent) } else { + if (gl.lightmethod == LM_SOFTWARE && !translucent) + { + // This is not yet ready. + //if (PutWallCompat(passflag[type])) return; + } bool masked; diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 8fe9d948e..9fe120ae2 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -228,16 +228,23 @@ void GLWall::RenderFogBoundary() { if (gl_fogmode && gl_fixedcolormap == 0) { - int rel = rellight + getExtraLight(); - gl_SetFog(lightlevel, rel, &Colormap, false); - gl_RenderState.SetEffect(EFF_FOGBOUNDARY); - gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(-1.0f, -128.0f); - RenderWall(RWF_BLANK); - glPolygonOffset(0.0f, 0.0f); - glDisable(GL_POLYGON_OFFSET_FILL); - gl_RenderState.SetEffect(EFF_NONE); + if (gl.glslversion > 0.f) + { + int rel = rellight + getExtraLight(); + gl_SetFog(lightlevel, rel, &Colormap, false); + gl_RenderState.SetEffect(EFF_FOGBOUNDARY); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); + RenderWall(RWF_BLANK); + glPolygonOffset(0.0f, 0.0f); + glDisable(GL_POLYGON_OFFSET_FILL); + gl_RenderState.SetEffect(EFF_NONE); + } + else + { + RenderFogBoundaryCompat(); + } } } @@ -255,12 +262,19 @@ void GLWall::RenderMirrorSurface() Vector v(glseg.y2-glseg.y1, 0 ,-glseg.x2+glseg.x1); v.Normalize(); - // we use texture coordinates and texture matrix to pass the normal stuff to the shader so that the default vertex buffer format can be used as is. - lolft.u = lorgt.u = uplft.u = uprgt.u = v.X(); - lolft.v = lorgt.v = uplft.v = uprgt.v = v.Z(); + if (gl.glslversion >= 0.f) + { + // we use texture coordinates and texture matrix to pass the normal stuff to the shader so that the default vertex buffer format can be used as is. + lolft.u = lorgt.u = uplft.u = uprgt.u = v.X(); + lolft.v = lorgt.v = uplft.v = uprgt.v = v.Z(); - gl_RenderState.EnableTextureMatrix(true); - gl_RenderState.mTextureMatrix.computeNormalMatrix(gl_RenderState.mViewMatrix); + gl_RenderState.EnableTextureMatrix(true); + gl_RenderState.mTextureMatrix.computeNormalMatrix(gl_RenderState.mViewMatrix); + } + else + { + glNormal3fv(&v[0]); + } // Use sphere mapping for this gl_RenderState.SetEffect(EFF_SPHEREMAP); diff --git a/src/gl/system/gl_load.c b/src/gl/system/gl_load.c index 9b89f2880..aed4e0ff8 100644 --- a/src/gl/system/gl_load.c +++ b/src/gl/system/gl_load.c @@ -42,6 +42,8 @@ static void* SunGetProcAddress (const GLubyte* name) #if defined(_WIN32) #ifdef _MSC_VER +// disable inlining here because it creates an incredible amount of bloat in this file. +#pragma inline_depth(0) #pragma warning(disable: 4055) #pragma warning(disable: 4054) #pragma warning(disable: 4996) From ab8a64743320413e70b85a40b098814fc18fc598 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 May 2016 11:33:18 +0200 Subject: [PATCH 0582/1509] - fixed the disabled visibility rules check for dynamic lights by doing the actual check in the light's Tick() method and letting the renderer only use the result. --- src/gl/compatibility/gl_20.cpp | 2 +- src/gl/dynlights/a_dynlight.cpp | 2 + src/gl/dynlights/gl_dynlight.h | 1 + src/gl/scene/gl_spritelight.cpp | 85 ++++++++++++++++----------------- 4 files changed, 44 insertions(+), 46 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 1dac5ac38..025ae3038 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -392,7 +392,7 @@ bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, { return false; } - if (light->owned && light->target != NULL && !light->target->IsVisibleToPlayer()) + if (!light->visibletoplayer) { return false; } diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 36382ce36..5458f0479 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -160,6 +160,7 @@ void ADynamicLight::BeginPlay() m_Radius[0] = args[LIGHT_INTENSITY]; m_Radius[1] = args[LIGHT_SECONDARY_INTENSITY]; + visibletoplayer = true; } //========================================================================== @@ -237,6 +238,7 @@ void ADynamicLight::Tick() return; } if (target->flags & MF_UNMORPHED) return; + visibletoplayer = target->IsVisibleToPlayer(); // cache this value for the renderer to speed up calculations. } // Don't bother if the light won't be shown diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index 5759d4cb8..513245be5 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -116,6 +116,7 @@ public: bool owned; bool halo; BYTE color2[3]; + bool visibletoplayer; int bufferindex; // intermediate texture coordinate data diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index dfc3a6294..b25fc30f0 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -75,57 +75,52 @@ void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t * while (node) { light=node->lightsource; - //if (!light->owned || light->target == NULL || light->target->IsVisibleToPlayer()) + if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) { - if (!(light->flags2&MF2_DORMANT) && - (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) + float dist; + + // This is a performance critical section of code where we cannot afford to let the compiler decide whether to inline the function or not. + // This will do the calculations explicitly rather than calling one of AActor's utility functions. + if (Displacements.size > 0) { - float dist; + int fromgroup = light->Sector->PortalGroup; + int togroup = subsec->sector->PortalGroup; + if (fromgroup == togroup || fromgroup == 0 || togroup == 0) goto direct; - // This is a performance critical section of code where we cannot afford to let the compiler decide whether to inline the function or not. - // This will do the calculations explicitly rather than calling one of AActor's utility functions. - if (Displacements.size > 0) + DVector2 offset = Displacements.getOffset(fromgroup, togroup); + dist = FVector3(x - light->X() - offset.X, y - light->Y() - offset.Y, z - light->Z()).LengthSquared(); + } + else + { + direct: + dist = FVector3(x - light->X(), y - light->Y(), z - light->Z()).LengthSquared(); + } + + radius = light->GetRadius() * gl_lights_size; + + if (dist < radius * radius) + { + dist = sqrtf(dist); // only calculate the square root if we really need it. + + frac = 1.0f - (dist / radius); + + if (frac > 0) { - int fromgroup = light->Sector->PortalGroup; - int togroup = subsec->sector->PortalGroup; - if (fromgroup == togroup || fromgroup == 0 || togroup == 0) goto direct; - - DVector2 offset = Displacements.getOffset(fromgroup, togroup); - dist = FVector3(x - light->X() - offset.X, y - light->Y() - offset.Y, z - light->Z()).LengthSquared(); - } - else - { - direct: - dist = FVector3(x - light->X(), y - light->Y(), z - light->Z()).LengthSquared(); - } - // This is to avoid calling the software-implemented sqrt function which gets used by FVector3::Length(). - // With fast math on in this module this call will be mapped to a machine instruction on most platforms. - dist = sqrtf(dist); - - radius = light->GetRadius() * gl_lights_size; - - if (dist < radius) - { - frac = 1.0f - (dist / radius); - - if (frac > 0) + lr = light->GetRed() / 255.0f * gl_lights_intensity; + lg = light->GetGreen() / 255.0f * gl_lights_intensity; + lb = light->GetBlue() / 255.0f * gl_lights_intensity; + if (light->IsSubtractive()) { - lr = light->GetRed() / 255.0f * gl_lights_intensity; - lg = light->GetGreen() / 255.0f * gl_lights_intensity; - lb = light->GetBlue() / 255.0f * gl_lights_intensity; - if (light->IsSubtractive()) - { - float bright = FVector3(lr, lg, lb).Length(); - FVector3 lightColor(lr, lg, lb); - lr = (bright - lr) * -1; - lg = (bright - lg) * -1; - lb = (bright - lb) * -1; - } - - out[0] += lr * frac; - out[1] += lg * frac; - out[2] += lb * frac; + float bright = FVector3(lr, lg, lb).Length(); + FVector3 lightColor(lr, lg, lb); + lr = (bright - lr) * -1; + lg = (bright - lg) * -1; + lb = (bright - lb) * -1; } + + out[0] += lr * frac; + out[1] += lg * frac; + out[2] += lb * frac; } } } From fd8a59bd249f936a702765a0025b4869e3bfc172 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 May 2016 12:23:40 +0200 Subject: [PATCH 0583/1509] - fixed: INHERITACTORPITCH was inverted. - changed PITCHFORMOMENTUM to do nothing for very small velocities. --- src/gl/models/gl_models.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index e2187c59c..22a4913a7 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -933,16 +933,19 @@ void gl_RenderModel(GLSprite * spr) const double x = spr->actor->Vel.X; const double y = spr->actor->Vel.Y; const double z = spr->actor->Vel.Z; - - // [BB] Calculate the pitch using spherical coordinates. - if(z || x || y) pitch = float(atan( z/sqrt(x*x+y*y) ) / M_PI * 180); - - // Correcting pitch if model is moving backwards - if(x || y) + + if (spr->actor->Vel.LengthSquared() > EQUAL_EPSILON) { - if((x * cos(angle * M_PI / 180) + y * sin(angle * M_PI / 180)) / sqrt(x * x + y * y) < 0) pitch *= -1; + // [BB] Calculate the pitch using spherical coordinates. + if (z || x || y) pitch = float(atan(z / sqrt(x*x + y*y)) / M_PI * 180); + + // Correcting pitch if model is moving backwards + if (fabs(x) > EQUAL_EPSILON || fabs(y) > EQUAL_EPSILON) + { + if ((x * cos(angle * M_PI / 180) + y * sin(angle * M_PI / 180)) / sqrt(x * x + y * y) < 0) pitch *= -1; + } + else pitch = fabs(pitch); } - else pitch = fabs(pitch); } if( smf->flags & MDL_ROTATING ) @@ -964,7 +967,7 @@ void gl_RenderModel(GLSprite * spr) // Applying model transformations: // 1) Applying actor angle, pitch and roll to the model gl_RenderState.mModelMatrix.rotate(-angle, 0, 1, 0); - gl_RenderState.mModelMatrix.rotate(pitch, 0, 0, 1); + gl_RenderState.mModelMatrix.rotate(-pitch, 0, 0, 1); gl_RenderState.mModelMatrix.rotate(-roll, 1, 0, 0); // 2) Applying Doomsday like rotation of the weapon pickup models From 54571beacad6974597c581e1f446f4e1561aace6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 May 2016 12:28:35 +0200 Subject: [PATCH 0584/1509] - reset the path to "" before a model definition is parsed. --- src/gl/models/gl_models.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 22a4913a7..22cc7479f 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -519,6 +519,7 @@ void gl_InitModels() { if (sc.Compare("model")) { + path = ""; sc.MustGetString(); memset(&smf, 0, sizeof(smf)); smf.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1; From 9f91fa8f4377a55b5837584f64f2f9820992851b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 May 2016 13:47:40 +0200 Subject: [PATCH 0585/1509] - make the warp2 shader's formula match the software renderer's. This fixes some jerkiness with vertical scrollers due to a bad sine period and makes the overall appearance of the effect what it was originally supposed to be. The old warp2 shader was not created by replicating the formula but by trial and error until it looked close enough. A version of the old warp2 shader with a fixed sine period is still available as a custom hardware shader. --- wadsrc/static/shaders/glsl/func_warp2.fp | 7 +++---- wadsrc/static/shaders/glsl/func_warp3.fp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 wadsrc/static/shaders/glsl/func_warp3.fp diff --git a/wadsrc/static/shaders/glsl/func_warp2.fp b/wadsrc/static/shaders/glsl/func_warp2.fp index 7cc5e7ebb..ee712593d 100644 --- a/wadsrc/static/shaders/glsl/func_warp2.fp +++ b/wadsrc/static/shaders/glsl/func_warp2.fp @@ -7,11 +7,10 @@ vec4 ProcessTexel() const float pi = 3.14159265358979323846; vec2 offset = vec2(0.0,0.0); - float siny = sin(pi * 2.0 * (texCoord.y * 2.2 + timer * 0.75)) * 0.03; - offset.y = siny + sin(pi * 2.0 * (texCoord.x * 0.75 + timer * 0.75)) * 0.03; - offset.x = siny + sin(pi * 2.0 * (texCoord.x * 1.1 + timer * 0.45)) * 0.02; + offset.y = 0.5 + sin(pi * 2.0 * (texCoord.y + timer * 0.61 + 900.0/8192.0)) + sin(pi * 2.0 * (texCoord.x * 2.0 + timer * 0.36 + 300.0/8192.0)); + offset.x = 0.5 + sin(pi * 2.0 * (texCoord.y + timer * 0.49 + 700.0/8192.0)) + sin(pi * 2.0 * (texCoord.x * 2.0 + timer * 0.49 + 1200.0/8192.0)); - texCoord += offset; + texCoord += offset * 0.025; return getTexel(texCoord); } diff --git a/wadsrc/static/shaders/glsl/func_warp3.fp b/wadsrc/static/shaders/glsl/func_warp3.fp new file mode 100644 index 000000000..a81969ca6 --- /dev/null +++ b/wadsrc/static/shaders/glsl/func_warp3.fp @@ -0,0 +1,18 @@ +uniform float timer; + +vec4 ProcessTexel() +{ + vec2 texCoord = vTexCoord.st; + + const float pi = 3.14159265358979323846; + vec2 offset = vec2(0.0,0.0); + + float siny = sin(pi * 2.0 * (texCoord.y * 2.0 + timer * 0.75)) * 0.03; + offset.y = siny + sin(pi * 2.0 * (texCoord.x + timer * 0.75)) * 0.03; + offset.x = siny + sin(pi * 2.0 * (texCoord.x + timer * 0.45)) * 0.02; + + texCoord += offset; + + return getTexel(texCoord); +} + From 5f095082c0bdc5390ef31224577f0880930cbca3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 May 2016 14:10:06 +0200 Subject: [PATCH 0586/1509] - fixed: The 2D drawing code incorrectly set the shader override to disable all special effects. --- src/gl/renderer/gl_renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index d638feaf3..7002e6b10 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -350,7 +350,7 @@ void FGLRenderer::DrawTexture(FTexture *img, DrawParms &parms) if (pal) translation = -pal->GetIndex(); } } - gl_RenderState.SetMaterial(gltex, CLAMP_XY_NOMIP, translation, 0, !!(parms.style.Flags & STYLEF_RedIsAlpha)); + gl_RenderState.SetMaterial(gltex, CLAMP_XY_NOMIP, translation, -1, !!(parms.style.Flags & STYLEF_RedIsAlpha)); u1 = gltex->GetUL(); v1 = gltex->GetVT(); From bdb7594e60812155d89d6887ca426198bec98750 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 May 2016 14:25:58 +0200 Subject: [PATCH 0587/1509] - fixed: Incomplete model definitions flagged the actor as having a model, which could cause a crash. --- src/gl/models/gl_models.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 22cc7479f..bcf1d4f6a 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -530,7 +530,6 @@ void gl_InitModels() { sc.ScriptError("MODELDEF: Unknown actor type '%s'\n", sc.String); } - GetDefaultByType(smf.type)->hasmodel=true; sc.MustGetStringName("{"); while (!sc.CheckString("}")) { @@ -744,6 +743,7 @@ void gl_InitModels() if (map[c]) continue; smf.frame=c; SpriteModelFrames.Push(smf); + GetDefaultByType(smf.type)->hasmodel = true; map[c]=1; } } From 3334b28a02da663b904280de951b3a158c75aace Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 May 2016 14:30:10 +0200 Subject: [PATCH 0588/1509] - don't let the light go completely black with software-emulated lighting. --- wadsrc/static/shaders/glsl/main.fp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index af5b30a03..0afcb9813 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -134,7 +134,7 @@ float R_DoomLightingEquation(float light, float dist) /* L in the range 0 to 63 */ float L = light * 63.0/31.0; - float min_L = clamp(36.0/31.0 - L, 0.0, 1.0); + float min_L = clamp(36.0/31.0 - L, 0.03, 1.0); // Fix objects getting totally black when close. if (dist < 0.0001) From 317730584fafd63edac3b765d014741f33b1534f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 May 2016 14:39:31 +0200 Subject: [PATCH 0589/1509] - GZDoom still needs this. --- src/p_lnspec.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index c7d801cbb..103ac1264 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -75,6 +75,9 @@ */ static const BYTE ChangeMap[8] = { 0, 1, 5, 3, 7, 2, 6, 0 }; +int LS_Sector_SetPlaneReflection(line_t *ln, AActor *it, bool backSide, int arg0, int arg1, int arg2, int arg3, int arg4); +int LS_SetGlobalFogParameter(line_t *ln, AActor *it, bool backSide, int arg0, int arg1, int arg2, int arg3, int arg4); + #define FUNC(a) static int a (line_t *ln, AActor *it, bool backSide, \ int arg0, int arg1, int arg2, int arg3, int arg4) @@ -3441,9 +3444,9 @@ static lnSpecFunc LineSpecials[] = /* 154 */ LS_Teleport_NoStop, /* 155 */ LS_NOP, /* 156 */ LS_NOP, - /* 157 */ LS_NOP, // SetGlobalFogParameter + /* 157 */ LS_SetGlobalFogParameter, /* 158 */ LS_FS_Execute, - /* 159 */ LS_NOP, // Sector_SetPlaneReflection + /* 159 */ LS_Sector_SetPlaneReflection, /* 160 */ LS_NOP, // Sector_Set3DFloor /* 161 */ LS_NOP, // Sector_SetContents /* 162 */ LS_NOP, // Reserved Doom64 branch From 7b65e6d424f67551c976ef6d6e5d8e24a5954f7b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 May 2016 19:16:07 +0200 Subject: [PATCH 0590/1509] - use glMapBuffer instead of glMapBufferRange on older hardware. --- src/gl/models/gl_models.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index bcf1d4f6a..c87cb52c2 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -170,7 +170,10 @@ FModelVertex *FModelVertexBuffer::LockVertexBuffer(unsigned int size) { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glBufferData(GL_ARRAY_BUFFER, size * sizeof(FModelVertex), nullptr, GL_STATIC_DRAW); - return (FModelVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, size * sizeof(FModelVertex), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + if (gl.version >= 3.0) + return (FModelVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, size * sizeof(FModelVertex), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + else + return (FModelVertex*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); } else { @@ -208,7 +211,10 @@ unsigned int *FModelVertexBuffer::LockIndexBuffer(unsigned int size) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); glBufferData(GL_ELEMENT_ARRAY_BUFFER, size * sizeof(unsigned int), NULL, GL_STATIC_DRAW); - return (unsigned int*)glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, size * sizeof(unsigned int), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + if (gl.version >= 3.0) + return (unsigned int*)glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, size * sizeof(unsigned int), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + else + return (unsigned int*)glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); } else { From 8817f891923a9d675e9fa964710083770b827396 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 May 2016 20:31:21 +0200 Subject: [PATCH 0591/1509] - do not clip the first frame of very slow projectiles. --- src/gl/scene/gl_sprite.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index c85de8a0d..97e041497 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -596,8 +596,12 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) { if (!(thing->flags7 & MF7_FLYCHEAT) && thing->target == GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) { - double clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius * 2); - if ((thingpos - ViewPos).LengthSquared() < clipdist * clipdist) return; + double speed = thing->Vel.Length(); + if (speed >= thing->target->radius / 2) + { + double clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius * 2); + if ((thingpos - ViewPos).LengthSquared() < clipdist * clipdist) return; + } } thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again. } From ec7b4b1ba4bf8ac54ec50ff22752b23d82d4dc71 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 May 2016 22:14:39 +0200 Subject: [PATCH 0592/1509] - initial work on textured dynamic light processing. --- src/gl/compatibility/gl_20.cpp | 25 +++++++++++++++++-------- src/gl/renderer/gl_renderer.cpp | 3 ++- src/gl/scene/gl_walls.cpp | 2 +- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 025ae3038..15d52c48a 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -556,7 +556,6 @@ void GLWall::RenderFogBoundaryCompat() void FGLRenderer::RenderMultipassStuff() { - return; // First pass: empty background with sector light only // Part 1: solid geometry. This is set up so that there are no transparent parts @@ -565,25 +564,28 @@ void FGLRenderer::RenderMultipassStuff() gl_RenderState.EnableTexture(false); gl_RenderState.EnableBrightmap(false); gl_RenderState.Apply(); - gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_BASE); - gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_BASE); + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_PLAIN); // Part 2: masked geometry. This is set up so that only pixels with alpha>0.5 will show // This creates a blank surface that only fills the nontransparent parts of the texture gl_RenderState.EnableTexture(true); gl_RenderState.SetTextureMode(TM_MASK); gl_RenderState.EnableBrightmap(true); - gl_drawinfo->dldrawlists[GLLDL_WALLS_BRIGHT].DrawWalls(GLPASS_BASE_MASKED); - gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_BASE_MASKED); - gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_BASE_MASKED); - gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_BASE_MASKED); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); + gl_drawinfo->dldrawlists[GLLDL_WALLS_BRIGHT].DrawWalls(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_PLAIN); // Part 3: The base of fogged surfaces, including the texture gl_RenderState.EnableBrightmap(false); gl_RenderState.SetTextureMode(TM_MODULATE); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0); gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(GLPASS_PLAIN); - gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(GLPASS_PLAIN); gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(GLPASS_PLAIN); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(GLPASS_PLAIN); gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(GLPASS_PLAIN); // second pass: draw lights @@ -638,5 +640,12 @@ void FGLRenderer::RenderMultipassStuff() gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); } else gl_lights = false; + + glDepthFunc(GL_LESS); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_RenderState.EnableFog(true); + gl_RenderState.BlendFunc(GL_ONE, GL_ZERO); + glDepthMask(true); + } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 7002e6b10..0a0049426 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -95,7 +95,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mSkyVBO = NULL; gl_spriteindex = 0; mShaderManager = NULL; - glpart2 = glpart = mirrortexture = NULL; + gllight = glpart2 = glpart = mirrortexture = NULL; mLights = NULL; } @@ -112,6 +112,7 @@ void FGLRenderer::Initialize() } else mVAOID = 0; + gllight = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/gllight.png"), FTexture::TEX_MiscPatch); glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch); glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch); mirrortexture = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/mirror.png"), FTexture::TEX_MiscPatch); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 906f7f3e1..237c037d6 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -142,7 +142,7 @@ void GLWall::PutWall(bool translucent) if (gl.lightmethod == LM_SOFTWARE && !translucent) { // This is not yet ready. - //if (PutWallCompat(passflag[type])) return; + if (PutWallCompat(passflag[type])) return; } bool masked; From 4412f99b385151c6ce5edf7f8cfbca7e1780c836 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 May 2016 23:07:16 +0200 Subject: [PATCH 0593/1509] - added the flat dispatcher for textured lighting. --- src/gl/compatibility/gl_20.cpp | 27 +++++++++++++++++++++++++++ src/gl/scene/gl_flats.cpp | 4 ++++ src/gl/scene/gl_wall.h | 1 + 3 files changed, 32 insertions(+) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 15d52c48a..ecbc32831 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -500,6 +500,33 @@ bool GLWall::PutWallCompat(int passflag) } +//========================================================================== +// +// +// +//========================================================================== + +bool GLFlat::PutFlatCompat(bool fog) +{ + // are lights possible? + if (gl_fixedcolormap != CM_DEFAULT || !gl_lights || !gltexture || renderstyle != STYLE_Translucent || alpha < 1.f - FLT_EPSILON || sector->lighthead == NULL) return false; + + static int list_indices[2][2] = + { { GLLDL_FLATS_PLAIN, GLLDL_FLATS_FOG },{ GLLDL_FLATS_MASKED, GLLDL_FLATS_FOGMASKED } }; + + bool masked = gltexture->isMasked() && ((renderflags&SSRF_RENDER3DPLANES) || stack); + bool foggy = gl_CheckFog(&Colormap, lightlevel) || level.flags&LEVEL_HASFADETABLE; + + + int list = list_indices[masked][foggy]; + if (list == GLLDL_FLATS_PLAIN) + { + if (gltexture->tex->gl_info.Brightmap && gl.glslversion >= 0.f) list = GLLDL_FLATS_BRIGHT; + } + gl_drawinfo->dldrawlists[list].AddFlat(this); +} + + //========================================================================== // // Fog boundary without any shader support diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 7406bb20e..6b6f0e4a9 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -463,6 +463,10 @@ inline void GLFlat::PutFlat(bool fog) { Colormap.Clear(); } + if (gl.lightmethod == LM_SOFTWARE) + { + if (PutFlatCompat(fog)) return; + } if (renderstyle!=STYLE_Translucent || alpha < 1.f - FLT_EPSILON || fog || gltexture == NULL) { // translucent 3D floors go into the regular translucent list, translucent portals go into the translucent border list. diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index fdf78ee6f..cb443cd2a 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -304,6 +304,7 @@ public: void ProcessLights(bool istrans); void PutFlat(bool fog = false); + bool PutFlatCompat(bool fog); void Process(sector_t * model, int whichplane, bool notexture); void SetFrom3DFloor(F3DFloor *rover, bool top, bool underside); void ProcessSector(sector_t * frontsector); From c9d4c6803960b7ddd7905a3066d941a78e961673 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 5 May 2016 00:24:47 +0200 Subject: [PATCH 0594/1509] - added dynamic light drawer for flats. --- src/gl/compatibility/gl_20.cpp | 91 ++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index ecbc32831..e69ce961e 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -54,6 +54,7 @@ #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_renderstate.h" #include "gl/scene/gl_drawinfo.h" +#include "gl/data/gl_vertexbuffer.h" //========================================================================== @@ -376,6 +377,7 @@ void FRenderState::DrawColormapOverlay() // Sets up the parameters to render one dynamic light onto one plane // //========================================================================== + bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, float & scale, int desaturation, bool checkside, bool forceadditive) { @@ -575,6 +577,95 @@ void GLWall::RenderFogBoundaryCompat() gl_RenderState.EnableTexture(true); } +//========================================================================== +// +// Flats +// +//========================================================================== +enum +{ + LIGHTPASS_MULT, + LIGHTPASS_ADD, + LIGHTPASS_FOG +}; + +void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) +{ + Plane p; + Vector nearPt, up, right, t1; + float scale; + unsigned int k; + seg_t *v; + + FLightNode * node = sub->lighthead; + gl_RenderState.Apply(); + while (node) + { + ADynamicLight * light = node->lightsource; + + if (light->flags2&MF2_DORMANT) + { + node = node->nextLight; + continue; + } + switch (pass) + { + case LIGHTPASS_MULT: + if (light->IsAdditive()) + { + node = node->nextLight; + continue; + } + break; + + case LIGHTPASS_ADD: + if (!light->IsAdditive()) + { + node = node->nextLight; + continue; + } + break; + + default: + break; + } + + + // we must do the side check here because gl_SetupLight needs the correct plane orientation + // which we don't have for Legacy-style 3D-floors + double planeh = plane.plane.ZatPoint(light); + if (gl_lights_checkside && ((planehZ() && ceiling) || (planeh>light->Z() && !ceiling))) + { + node = node->nextLight; + continue; + } + + p.Set(plane.plane); + if (!gl_SetupLight(sub->sector->PortalGroup, p, light, nearPt, up, right, scale, CM_DEFAULT, false, foggy)) + { + node = node->nextLight; + continue; + } + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (unsigned int k = 0; k < sub->numlines; k++) + { + vertex_t *vt = sub->firstline[k].v1; + ptr->x = vt->fX(); + ptr->z = plane.plane.ZatPoint(vt) + dz; + ptr->y = vt->fY(); + t1.Set(ptr->x, ptr->z, ptr->y); + Vector nearToVert = t1 - nearPt; + + ptr->u = (nearToVert.Dot(right) * scale) + 0.5f; + ptr->v = (nearToVert.Dot(up) * scale) + 0.5f; + ptr++; + } + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + node = node->nextLight; + } +} + //========================================================================== // // From 0b2821d696dba4cd12a518d7469a4bb216b7511f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 5 May 2016 10:28:21 +0200 Subject: [PATCH 0595/1509] - added dynamic light rendering with textures on flats --- src/gl/compatibility/gl_20.cpp | 77 ++++++++++++++++++++-------------- src/gl/scene/gl_flats.cpp | 5 +++ src/gl/scene/gl_wall.h | 7 +++- 3 files changed, 56 insertions(+), 33 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index e69ce961e..5c7c983d3 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -582,20 +582,12 @@ void GLWall::RenderFogBoundaryCompat() // Flats // //========================================================================== -enum -{ - LIGHTPASS_MULT, - LIGHTPASS_ADD, - LIGHTPASS_FOG -}; void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) { Plane p; Vector nearPt, up, right, t1; float scale; - unsigned int k; - seg_t *v; FLightNode * node = sub->lighthead; gl_RenderState.Apply(); @@ -603,33 +595,13 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) { ADynamicLight * light = node->lightsource; - if (light->flags2&MF2_DORMANT) + if (light->flags2&MF2_DORMANT || + (pass == GLPASS_LIGHTTEX && light->IsAdditive()) || + (pass == GLPASS_LIGHTTEX_ADDITIVE && !light->IsAdditive())) { node = node->nextLight; continue; } - switch (pass) - { - case LIGHTPASS_MULT: - if (light->IsAdditive()) - { - node = node->nextLight; - continue; - } - break; - - case LIGHTPASS_ADD: - if (!light->IsAdditive()) - { - node = node->nextLight; - continue; - } - break; - - default: - break; - } - // we must do the side check here because gl_SetupLight needs the correct plane orientation // which we don't have for Legacy-style 3D-floors @@ -666,6 +638,49 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) } } +//========================================================================== +// +// +// +//========================================================================== + +void GLFlat::DrawLightsCompat(int pass) +{ + gl_RenderState.Apply(); + if (sub) + { + // This represents a single subsector + DrawSubsectorLights(sub, pass); + } + else + { + // Draw the subsectors belonging to this sector + for (int i = 0; isubsectorcount; i++) + { + subsector_t * sub = sector->subsectors[i]; + if (gl_drawinfo->ss_renderflags[sub - subsectors] & renderflags) + { + DrawSubsectorLights(sub, pass); + } + } + + // Draw the subsectors assigned to it due to missing textures + if (!(renderflags&SSRF_RENDER3DPLANES)) + { + gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR) ? + gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) : + gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum); + + while (node) + { + DrawSubsectorLights(sub, pass); + node = node->next; + } + } + } +} + + //========================================================================== // // diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 6b6f0e4a9..850a93615 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -443,6 +443,11 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG } if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); break; + + case GLPASS_LIGHTTEX: + case GLPASS_LIGHTTEX_ADDITIVE: + DrawLightsCompat(pass); + break; } } diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index cb443cd2a..3bdcbd6ce 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -296,15 +296,18 @@ public: int dynlightindex; + // compatibility fallback stuff. + void DrawSubsectorLights(subsector_t * sub, int pass); + void DrawLightsCompat(int pass); + bool PutFlatCompat(bool fog); + void SetupSubsectorLights(int pass, subsector_t * sub, int *dli = NULL); void DrawSubsector(subsector_t * sub); - void DrawSubsectorLights(subsector_t * sub, int pass); void DrawSkyboxSector(int pass, bool processlights); void DrawSubsectors(int pass, bool processlights, bool istrans); void ProcessLights(bool istrans); void PutFlat(bool fog = false); - bool PutFlatCompat(bool fog); void Process(sector_t * model, int whichplane, bool notexture); void SetFrom3DFloor(F3DFloor *rover, bool top, bool underside); void ProcessSector(sector_t * frontsector); From 51baa7d137486bf07c40017e471aa4340c2857e1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 5 May 2016 11:32:21 +0200 Subject: [PATCH 0596/1509] - added code to calculate light texture coordinates on walls. --- src/gl/compatibility/gl_20.cpp | 58 ++++++++++++++++++++++++++++++++-- src/gl/scene/gl_wall.h | 3 +- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 5c7c983d3..96cd88fd8 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -379,7 +379,7 @@ void FRenderState::DrawColormapOverlay() //========================================================================== bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, - float & scale, int desaturation, bool checkside, bool forceadditive) + float & scale, int desaturation, bool checkside, bool additive) { Vector fn, pos; @@ -416,7 +416,7 @@ bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, #endif float cs = 1.0f - (dist / radius); - if (gl_lights_additive || light->flags4&MF4_ADDITIVE || forceadditive) cs *= 0.2f; // otherwise the light gets too strong. + if (additive) cs *= 0.2f; // otherwise the light gets too strong. float r = light->GetRed() / 255.0f * cs * gl_lights_intensity; float g = light->GetGreen() / 255.0f * cs * gl_lights_intensity; float b = light->GetBlue() / 255.0f * cs * gl_lights_intensity; @@ -613,7 +613,7 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) } p.Set(plane.plane); - if (!gl_SetupLight(sub->sector->PortalGroup, p, light, nearPt, up, right, scale, CM_DEFAULT, false, foggy)) + if (!gl_SetupLight(sub->sector->PortalGroup, p, light, nearPt, up, right, scale, CM_DEFAULT, false, pass == GLPASS_LIGHTTEX_ADDITIVE)) { node = node->nextLight; continue; @@ -681,6 +681,58 @@ void GLFlat::DrawLightsCompat(int pass) } +//========================================================================== +// +// Sets up the texture coordinates for one light to be rendered +// +//========================================================================== +bool GLWall::PrepareLight(texcoord * tcs, ADynamicLight * light, int pass) +{ + float vtx[] = { glseg.x1,zbottom[0],glseg.y1, glseg.x1,ztop[0],glseg.y1, glseg.x2,ztop[1],glseg.y2, glseg.x2,zbottom[1],glseg.y2 }; + Plane p; + Vector nearPt, up, right; + float scale; + + p.Init(vtx, 4); + + if (!p.ValidNormal()) + { + return false; + } + + if (!gl_SetupLight(seg->frontsector->PortalGroup, p, light, nearPt, up, right, scale, CM_DEFAULT, true, pass == GLPASS_LIGHTTEX_ADDITIVE)) + { + return false; + } + + if (tcs != NULL) + { + Vector t1; + int outcnt[4] = { 0,0,0,0 }; + + for (int i = 0; i<4; i++) + { + t1.Set(&vtx[i * 3]); + Vector nearToVert = t1 - nearPt; + tcs[i].u = (nearToVert.Dot(right) * scale) + 0.5f; + tcs[i].v = (nearToVert.Dot(up) * scale) + 0.5f; + + // quick check whether the light touches this polygon + if (tcs[i].u<0) outcnt[0]++; + if (tcs[i].u>1) outcnt[1]++; + if (tcs[i].v<0) outcnt[2]++; + if (tcs[i].v>1) outcnt[3]++; + + } + // The light doesn't touch this polygon + if (outcnt[0] == 4 || outcnt[1] == 4 || outcnt[2] == 4 || outcnt[3] == 4) return false; + } + + draw_dlight++; + return true; +} + + //========================================================================== // // diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 3bdcbd6ce..cfd8ae361 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -183,7 +183,7 @@ private: void SplitWall(sector_t * frontsector, bool translucent); void SetupLights(); - bool PrepareLight(texcoord * tcs, ADynamicLight * light); + bool PrepareLight(texcoord * tcs, ADynamicLight * light, int pass); void RenderWall(int textured, unsigned int *store = NULL); void RenderTextured(int rflags); @@ -288,7 +288,6 @@ public: GLSectorPlane plane; int lightlevel; bool stack; - bool foggy; bool ceiling; BYTE renderflags; int vboindex; From 2b92048a5b1185cfe73d97f444284100cf0ec1fa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 5 May 2016 11:48:39 +0200 Subject: [PATCH 0597/1509] - renamed the texture coord variables in GLWall. It makes no sense having them organized differently in this struct than what the rendering code needs. This saves one redundant copy operation and a function-local static variable. --- src/gl/compatibility/gl_20.cpp | 9 +-- src/gl/scene/gl_drawinfo.cpp | 10 +-- src/gl/scene/gl_vertex.cpp | 40 ++++++------ src/gl/scene/gl_wall.h | 17 ++++-- src/gl/scene/gl_walls.cpp | 108 ++++++++++++++++----------------- src/gl/scene/gl_walls_draw.cpp | 26 +++----- 6 files changed, 106 insertions(+), 104 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 96cd88fd8..6df940b77 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -526,6 +526,7 @@ bool GLFlat::PutFlatCompat(bool fog) if (gltexture->tex->gl_info.Brightmap && gl.glslversion >= 0.f) list = GLLDL_FLATS_BRIGHT; } gl_drawinfo->dldrawlists[list].AddFlat(this); + return true; } @@ -559,14 +560,14 @@ void GLWall::RenderFogBoundaryCompat() glDepthFunc(GL_LEQUAL); glColor4f(fc[0], fc[1], fc[2], fogd1); glBegin(GL_TRIANGLE_FAN); - glTexCoord2f(lolft.u, lolft.v); + glTexCoord2f(tcs[LOLFT].u, tcs[LOLFT].v); glVertex3f(glseg.x1, zbottom[0], glseg.y1); - glTexCoord2f(uplft.u, uplft.v); + glTexCoord2f(tcs[UPLFT].u, tcs[UPLFT].v); glVertex3f(glseg.x1, ztop[0], glseg.y1); glColor4f(fc[0], fc[1], fc[2], fogd2); - glTexCoord2f(uprgt.u, uprgt.v); + glTexCoord2f(tcs[UPRGT].u, tcs[UPRGT].v); glVertex3f(glseg.x2, ztop[1], glseg.y2); - glTexCoord2f(lorgt.u, lorgt.v); + glTexCoord2f(tcs[LORGT].u, tcs[LORGT].v); glVertex3f(glseg.x2, zbottom[1], glseg.y2); glEnd(); glDepthFunc(GL_LESS); diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index a444dbe62..0dc8efd84 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -326,7 +326,7 @@ void GLDrawList::SortWallIntoPlane(SortNode * head,SortNode * sort) GLWall * ws1; ws1=&walls[walls.Size()-1]; ws=&walls[drawitems[sort->itemindex].index]; // may have been reallocated! - float newtexv = ws->uplft.v + ((ws->lolft.v - ws->uplft.v) / (ws->zbottom[0] - ws->ztop[0])) * (fh->z - ws->ztop[0]); + float newtexv = ws->tcs[GLWall::UPLFT].v + ((ws->tcs[GLWall::LOLFT].v - ws->tcs[GLWall::UPLFT].v) / (ws->zbottom[0] - ws->ztop[0])) * (fh->z - ws->ztop[0]); // I make the very big assumption here that translucent walls in sloped sectors // and 3D-floors never coexist in the same level. If that were the case this @@ -334,12 +334,12 @@ void GLDrawList::SortWallIntoPlane(SortNode * head,SortNode * sort) if (!ceiling) { ws->ztop[1] = ws1->zbottom[1] = ws->ztop[0] = ws1->zbottom[0] = fh->z; - ws->uprgt.v = ws1->lorgt.v = ws->uplft.v = ws1->lolft.v = newtexv; + ws->tcs[GLWall::UPRGT].v = ws1->tcs[GLWall::LORGT].v = ws->tcs[GLWall::UPLFT].v = ws1->tcs[GLWall::LOLFT].v = newtexv; } else { ws1->ztop[1] = ws->zbottom[1] = ws1->ztop[0] = ws->zbottom[0] = fh->z; - ws1->uplft.v = ws->lolft.v = ws1->uprgt.v = ws->lorgt.v=newtexv; + ws1->tcs[GLWall::UPLFT].v = ws->tcs[GLWall::LOLFT].v = ws1->tcs[GLWall::UPRGT].v = ws->tcs[GLWall::LORGT].v=newtexv; } } @@ -462,7 +462,7 @@ void GLDrawList::SortWallIntoWall(SortNode * head,SortNode * sort) float ix=(float)(ws->glseg.x1+r*(ws->glseg.x2-ws->glseg.x1)); float iy=(float)(ws->glseg.y1+r*(ws->glseg.y2-ws->glseg.y1)); - float iu=(float)(ws->uplft.u + r * (ws->uprgt.u - ws->uplft.u)); + float iu=(float)(ws->tcs[GLWall::UPLFT].u + r * (ws->tcs[GLWall::UPRGT].u - ws->tcs[GLWall::UPLFT].u)); float izt=(float)(ws->ztop[0]+r*(ws->ztop[1]-ws->ztop[0])); float izb=(float)(ws->zbottom[0]+r*(ws->zbottom[1]-ws->zbottom[0])); @@ -475,7 +475,7 @@ void GLDrawList::SortWallIntoWall(SortNode * head,SortNode * sort) ws1->glseg.y1=ws->glseg.y2=iy; ws1->ztop[0]=ws->ztop[1]=izt; ws1->zbottom[0]=ws->zbottom[1]=izb; - ws1->lolft.u = ws1->uplft.u = ws->lorgt.u = ws->uprgt.u = iu; + ws1->tcs[GLWall::LOLFT].u = ws1->tcs[GLWall::UPLFT].u = ws->tcs[GLWall::LORGT].u = ws->tcs[GLWall::UPRGT].u = iu; SortNode * sort2=SortNodes.GetNew(); memset(sort2,0,sizeof(SortNode)); diff --git a/src/gl/scene/gl_vertex.cpp b/src/gl/scene/gl_vertex.cpp index 3c41f52bd..27ad8e059 100644 --- a/src/gl/scene/gl_vertex.cpp +++ b/src/gl/scene/gl_vertex.cpp @@ -61,14 +61,14 @@ EXTERN_CVAR(Bool, gl_seamless) // //========================================================================== -void GLWall::SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr) +void GLWall::SplitUpperEdge(FFlatVertex *&ptr) { if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; side_t *sidedef = seg->sidedef; float polyw = glseg.fracright - glseg.fracleft; - float facu = (tcs[2].u - tcs[1].u) / polyw; - float facv = (tcs[2].v - tcs[1].v) / polyw; + float facu = (tcs[UPRGT].u - tcs[UPLFT].u) / polyw; + float facv = (tcs[UPRGT].v - tcs[UPLFT].v) / polyw; float fact = (ztop[1] - ztop[0]) / polyw; float facc = (zceil[1] - zceil[0]) / polyw; float facf = (zfloor[1] - zfloor[0]) / polyw; @@ -85,8 +85,8 @@ void GLWall::SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr) ptr->x = cseg->v2->fX(); ptr->y = cseg->v2->fY(); ptr->z = ztop[0] + fact * fracfac; - ptr->u = tcs[1].u + facu * fracfac; - ptr->v = tcs[1].v + facv * fracfac; + ptr->u = tcs[UPLFT].u + facu * fracfac; + ptr->v = tcs[UPLFT].v + facv * fracfac; ptr++; } } @@ -97,14 +97,14 @@ void GLWall::SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr) // //========================================================================== -void GLWall::SplitLowerEdge(texcoord * tcs, FFlatVertex *&ptr) +void GLWall::SplitLowerEdge(FFlatVertex *&ptr) { if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; side_t *sidedef = seg->sidedef; float polyw = glseg.fracright - glseg.fracleft; - float facu = (tcs[3].u - tcs[0].u) / polyw; - float facv = (tcs[3].v - tcs[0].v) / polyw; + float facu = (tcs[LORGT].u - tcs[LOLFT].u) / polyw; + float facv = (tcs[LORGT].v - tcs[LOLFT].v) / polyw; float facb = (zbottom[1] - zbottom[0]) / polyw; float facc = (zceil[1] - zceil[0]) / polyw; float facf = (zfloor[1] - zfloor[0]) / polyw; @@ -121,8 +121,8 @@ void GLWall::SplitLowerEdge(texcoord * tcs, FFlatVertex *&ptr) ptr->x = cseg->v2->fX(); ptr->y = cseg->v2->fY(); ptr->z = zbottom[0] + facb * fracfac; - ptr->u = tcs[0].u + facu * fracfac; - ptr->v = tcs[0].v + facv * fracfac; + ptr->u = tcs[LOLFT].u + facu * fracfac; + ptr->v = tcs[LOLFT].v + facv * fracfac; ptr++; } } @@ -133,7 +133,7 @@ void GLWall::SplitLowerEdge(texcoord * tcs, FFlatVertex *&ptr) // //========================================================================== -void GLWall::SplitLeftEdge(texcoord * tcs, FFlatVertex *&ptr) +void GLWall::SplitLeftEdge(FFlatVertex *&ptr) { if (vertexes[0] == NULL) return; @@ -144,8 +144,8 @@ void GLWall::SplitLeftEdge(texcoord * tcs, FFlatVertex *&ptr) int i = 0; float polyh1 = ztop[0] - zbottom[0]; - float factv1 = polyh1 ? (tcs[1].v - tcs[0].v) / polyh1 : 0; - float factu1 = polyh1 ? (tcs[1].u - tcs[0].u) / polyh1 : 0; + float factv1 = polyh1 ? (tcs[UPLFT].v - tcs[LOLFT].v) / polyh1 : 0; + float factu1 = polyh1 ? (tcs[UPLFT].u - tcs[LOLFT].u) / polyh1 : 0; while (inumheights && vi->heightlist[i] <= zbottom[0]) i++; while (inumheights && vi->heightlist[i] < ztop[0]) @@ -153,8 +153,8 @@ void GLWall::SplitLeftEdge(texcoord * tcs, FFlatVertex *&ptr) ptr->x = glseg.x1; ptr->y = glseg.y1; ptr->z = vi->heightlist[i]; - ptr->u = factu1*(vi->heightlist[i] - ztop[0]) + tcs[1].u; - ptr->v = factv1*(vi->heightlist[i] - ztop[0]) + tcs[1].v; + ptr->u = factu1*(vi->heightlist[i] - ztop[0]) + tcs[UPLFT].u; + ptr->v = factv1*(vi->heightlist[i] - ztop[0]) + tcs[UPLFT].v; ptr++; i++; } @@ -167,7 +167,7 @@ void GLWall::SplitLeftEdge(texcoord * tcs, FFlatVertex *&ptr) // //========================================================================== -void GLWall::SplitRightEdge(texcoord * tcs, FFlatVertex *&ptr) +void GLWall::SplitRightEdge(FFlatVertex *&ptr) { if (vertexes[1] == NULL) return; @@ -178,8 +178,8 @@ void GLWall::SplitRightEdge(texcoord * tcs, FFlatVertex *&ptr) int i = vi->numheights - 1; float polyh2 = ztop[1] - zbottom[1]; - float factv2 = polyh2 ? (tcs[2].v - tcs[3].v) / polyh2 : 0; - float factu2 = polyh2 ? (tcs[2].u - tcs[3].u) / polyh2 : 0; + float factv2 = polyh2 ? (tcs[UPRGT].v - tcs[LORGT].v) / polyh2 : 0; + float factu2 = polyh2 ? (tcs[UPRGT].u - tcs[LORGT].u) / polyh2 : 0; while (i>0 && vi->heightlist[i] >= ztop[1]) i--; while (i>0 && vi->heightlist[i] > zbottom[1]) @@ -187,8 +187,8 @@ void GLWall::SplitRightEdge(texcoord * tcs, FFlatVertex *&ptr) ptr->x = glseg.x2; ptr->y = glseg.y2; ptr->z = vi->heightlist[i]; - ptr->u = factu2*(vi->heightlist[i] - ztop[1]) + tcs[2].u; - ptr->v = factv2*(vi->heightlist[i] - ztop[1]) + tcs[2].v; + ptr->u = factu2*(vi->heightlist[i] - ztop[1]) + tcs[UPRGT].u; + ptr->v = factv2*(vi->heightlist[i] - ztop[1]) + tcs[UPRGT].v; ptr++; i--; } diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index cfd8ae361..97c8217b7 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -119,6 +119,13 @@ public: RWF_NORENDER = 8, }; + enum + { + LOLFT, + UPLFT, + UPRGT, + LORGT, + }; friend struct GLDrawList; friend class GLPortal; @@ -126,7 +133,7 @@ public: GLSeg glseg; vertex_t * vertexes[2]; // required for polygon splitting float ztop[2],zbottom[2]; - texcoord uplft, uprgt, lolft, lorgt; + texcoord tcs[4]; float alpha; FMaterial *gltexture; @@ -236,10 +243,10 @@ private: void RenderMirrorSurface(); void RenderTranslucentWall(); - void SplitLeftEdge(texcoord * tcs, FFlatVertex *&ptr); - void SplitRightEdge(texcoord * tcs, FFlatVertex *&ptr); - void SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr); - void SplitLowerEdge(texcoord * tcs, FFlatVertex *&ptr); + void SplitLeftEdge (FFlatVertex *&ptr); + void SplitRightEdge(FFlatVertex *&ptr); + void SplitUpperEdge(FFlatVertex *&ptr); + void SplitLowerEdge(FFlatVertex *&ptr); public: diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 237c037d6..edd85e1df 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -297,10 +297,10 @@ void GLWall::SplitWallComplex(sector_t * frontsector, bool translucent, float ma copyWall1.ztop[1] = copyWall2.ztop[0] = ztop[0] + coeff * (ztop[1] - ztop[0]); copyWall1.zbottom[1] = copyWall2.zbottom[0] = zbottom[0] + coeff * (zbottom[1] - zbottom[0]); copyWall1.glseg.fracright = copyWall2.glseg.fracleft = glseg.fracleft + coeff * (glseg.fracright - glseg.fracleft); - copyWall1.uprgt.u = copyWall2.uplft.u = uplft.u + coeff * (uprgt.u - uplft.u); - copyWall1.uprgt.v = copyWall2.uplft.v = uplft.v + coeff * (uprgt.v - uplft.v); - copyWall1.lorgt.u = copyWall2.lolft.u = lolft.u + coeff * (lorgt.u - lolft.u); - copyWall1.lorgt.v = copyWall2.lolft.v = lolft.v + coeff * (lorgt.v - lolft.v); + copyWall1.tcs[UPRGT].u = copyWall2.tcs[UPLFT].u = tcs[UPLFT].u + coeff * (tcs[UPRGT].u - tcs[UPLFT].u); + copyWall1.tcs[UPRGT].v = copyWall2.tcs[UPLFT].v = tcs[UPLFT].v + coeff * (tcs[UPRGT].v - tcs[UPLFT].v); + copyWall1.tcs[LORGT].u = copyWall2.tcs[LOLFT].u = tcs[LOLFT].u + coeff * (tcs[LORGT].u - tcs[LOLFT].u); + copyWall1.tcs[LORGT].v = copyWall2.tcs[LOLFT].v = tcs[LOLFT].v + coeff * (tcs[LORGT].v - tcs[LOLFT].v); copyWall1.SplitWall(frontsector, translucent); copyWall2.SplitWall(frontsector, translucent); @@ -338,10 +338,10 @@ void GLWall::SplitWallComplex(sector_t * frontsector, bool translucent, float ma copyWall1.ztop[1] = copyWall2.ztop[0] = ztop[0] + coeff * (ztop[1] - ztop[0]); copyWall1.zbottom[1] = copyWall2.zbottom[0] = zbottom[0] + coeff * (zbottom[1] - zbottom[0]); copyWall1.glseg.fracright = copyWall2.glseg.fracleft = glseg.fracleft + coeff * (glseg.fracright - glseg.fracleft); - copyWall1.uprgt.u = copyWall2.uplft.u = uplft.u + coeff * (uprgt.u - uplft.u); - copyWall1.uprgt.v = copyWall2.uplft.v = uplft.v + coeff * (uprgt.v - uplft.v); - copyWall1.lorgt.u = copyWall2.lolft.u = lolft.u + coeff * (lorgt.u - lolft.u); - copyWall1.lorgt.v = copyWall2.lolft.v = lolft.v + coeff * (lorgt.v - lolft.v); + copyWall1.tcs[UPRGT].u = copyWall2.tcs[UPLFT].u = tcs[UPLFT].u + coeff * (tcs[UPRGT].u - tcs[UPLFT].u); + copyWall1.tcs[UPRGT].v = copyWall2.tcs[UPLFT].v = tcs[UPLFT].v + coeff * (tcs[UPRGT].v - tcs[UPLFT].v); + copyWall1.tcs[LORGT].u = copyWall2.tcs[LOLFT].u = tcs[LOLFT].u + coeff * (tcs[LORGT].u - tcs[LOLFT].u); + copyWall1.tcs[LORGT].v = copyWall2.tcs[LOLFT].v = tcs[LOLFT].v + coeff * (tcs[LORGT].v - tcs[LOLFT].v); copyWall1.SplitWall(frontsector, translucent); copyWall2.SplitWall(frontsector, translucent); @@ -432,10 +432,10 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) flags |= GLWF_NOSPLITUPPER; ztop[0]=copyWall1.zbottom[0]=maplightbottomleft; ztop[1]=copyWall1.zbottom[1]=maplightbottomright; - uplft.v=copyWall1.lolft.v=copyWall1.uplft.v+ - (maplightbottomleft-copyWall1.ztop[0])*(copyWall1.lolft.v-copyWall1.uplft.v)/(zbottom[0]-copyWall1.ztop[0]); - uprgt.v=copyWall1.lorgt.v=copyWall1.uprgt.v+ - (maplightbottomright-copyWall1.ztop[1])*(copyWall1.lorgt.v-copyWall1.uprgt.v)/(zbottom[1]-copyWall1.ztop[1]); + tcs[UPLFT].v=copyWall1.tcs[LOLFT].v=copyWall1.tcs[UPLFT].v+ + (maplightbottomleft-copyWall1.ztop[0])*(copyWall1.tcs[LOLFT].v-copyWall1.tcs[UPLFT].v)/(zbottom[0]-copyWall1.ztop[0]); + tcs[UPRGT].v=copyWall1.tcs[LORGT].v=copyWall1.tcs[UPRGT].v+ + (maplightbottomright-copyWall1.ztop[1])*(copyWall1.tcs[LORGT].v-copyWall1.tcs[UPRGT].v)/(zbottom[1]-copyWall1.ztop[1]); copyWall1.Put3DWall(&lightlist[i], translucent); } if (ztop[0]==zbottom[0] && ztop[1]==zbottom[1]) @@ -574,8 +574,8 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto if (tci) { - uplft.v = tci->FloatToTexV(-ztop[0] + texturetop); - lolft.v = tci->FloatToTexV(-zbottom[0] + texturetop); + tcs[UPLFT].v = tci->FloatToTexV(-ztop[0] + texturetop); + tcs[LOLFT].v = tci->FloatToTexV(-zbottom[0] + texturetop); } } else @@ -595,7 +595,7 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto if (tci) { - lolft.v = uplft.v = tci->FloatToTexV(-ztop[0] + texturetop); + tcs[LOLFT].v = tcs[UPLFT].v = tci->FloatToTexV(-ztop[0] + texturetop); } } @@ -612,8 +612,8 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto if (tci) { - uprgt.v = tci->FloatToTexV(-ztop[1] + texturetop); - lorgt.v = tci->FloatToTexV(-zbottom[1] + texturetop); + tcs[UPRGT].v = tci->FloatToTexV(-ztop[1] + texturetop); + tcs[LORGT].v = tci->FloatToTexV(-zbottom[1] + texturetop); } } else @@ -632,12 +632,12 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto zbottom[1] = ztop[1] = inter_y; if (tci) { - lorgt.v = uprgt.v = tci->FloatToTexV(-ztop[1] + texturetop); + tcs[LORGT].v = tcs[UPRGT].v = tci->FloatToTexV(-ztop[1] + texturetop); } } - uplft.u = lolft.u = l_ul + texlength * glseg.fracleft; - uprgt.u = lorgt.u = l_ul + texlength * glseg.fracright; + tcs[UPLFT].u = tcs[LOLFT].u = l_ul + texlength * glseg.fracleft; + tcs[UPRGT].u = tcs[LORGT].u = l_ul + texlength * glseg.fracright; if (gltexture != NULL) { @@ -646,15 +646,15 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto else if (flags & GLT_CLAMPY) { // for negative scales we can get negative coordinates here. - normalize = (uplft.v > lolft.v || uprgt.v > lorgt.v); + normalize = (tcs[UPLFT].v > tcs[LOLFT].v || tcs[UPRGT].v > tcs[LORGT].v); } if (normalize) { // we have to shift the y-coordinate from [-1..0] to [0..1] when using texture clamping with a negative scale - uplft.v += 1.f; - uprgt.v += 1.f; - lolft.v += 1.f; - lorgt.v += 1.f; + tcs[UPLFT].v += 1.f; + tcs[UPRGT].v += 1.f; + tcs[LOLFT].v += 1.f; + tcs[LORGT].v += 1.f; } } @@ -675,21 +675,21 @@ void GLWall::CheckTexturePosition() // clamp texture coordinates to a reasonable range. // Extremely large values can cause visual problems - if (uplft.v < uprgt.v) + if (tcs[UPLFT].v < tcs[UPRGT].v) { - sub = float(xs_FloorToInt(uplft.v)); + sub = float(xs_FloorToInt(tcs[UPLFT].v)); } else { - sub = float(xs_FloorToInt(uprgt.v)); + sub = float(xs_FloorToInt(tcs[UPRGT].v)); } - uplft.v -= sub; - uprgt.v -= sub; - lolft.v -= sub; - lorgt.v -= sub; + tcs[UPLFT].v -= sub; + tcs[UPRGT].v -= sub; + tcs[LOLFT].v -= sub; + tcs[LORGT].v -= sub; - if ((uplft.v == 0.f && uprgt.v == 0.f && lolft.v <= 1.f && lorgt.v <= 1.f) || - (uplft.v >= 0.f && uprgt.v >= 0.f && lolft.v == 1.f && lorgt.v == 1.f)) + if ((tcs[UPLFT].v == 0.f && tcs[UPRGT].v == 0.f && tcs[LOLFT].v <= 1.f && tcs[LORGT].v <= 1.f) || + (tcs[UPLFT].v >= 0.f && tcs[UPRGT].v >= 0.f && tcs[LOLFT].v == 1.f && tcs[LORGT].v == 1.f)) { flags |= GLT_CLAMPY; } @@ -698,13 +698,13 @@ void GLWall::CheckTexturePosition() // This intentionally only tests the seg's frontsector. if (seg->frontsector->special == GLSector_Skybox) { - sub = (float)xs_FloorToInt(uplft.u); - uplft.u -= sub; - uprgt.u -= sub; - lolft.u -= sub; - lorgt.u -= sub; - if ((uplft.u == 0.f && lolft.u == 0.f && uprgt.u <= 1.f && lorgt.u <= 1.f) || - (uplft.u >= 0.f && lolft.u >= 0.f && uprgt.u == 1.f && lorgt.u == 1.f)) + sub = (float)xs_FloorToInt(tcs[UPLFT].u); + tcs[UPLFT].u -= sub; + tcs[UPRGT].u -= sub; + tcs[LOLFT].u -= sub; + tcs[LORGT].u -= sub; + if ((tcs[UPLFT].u == 0.f && tcs[LOLFT].u == 0.f && tcs[UPRGT].u <= 1.f && tcs[LORGT].u <= 1.f) || + (tcs[UPLFT].u >= 0.f && tcs[LOLFT].u >= 0.f && tcs[UPRGT].u == 1.f && tcs[LORGT].u == 1.f)) { flags |= GLT_CLAMPX; } @@ -1039,10 +1039,10 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // split the poly! GLWall split; int i,t=0; - float v_factor=(zbottom[0]-ztop[0])/(lolft.v-uplft.v); + float v_factor=(zbottom[0]-ztop[0])/(tcs[LOLFT].v-tcs[UPLFT].v); // only split the vertical area of the polygon that does not contain slopes. - float splittopv = MAX(uplft.v, uprgt.v); - float splitbotv = MIN(lolft.v, lorgt.v); + float splittopv = MAX(tcs[UPLFT].v, tcs[UPRGT].v); + float splitbotv = MIN(tcs[LOLFT].v, tcs[LORGT].v); // this is split vertically into sections. for(i=0;isplittopv) { - split.ztop[0]=split.ztop[1]= ztop[0]+v_factor*(splitrect[i].top-uplft.v); - split.uplft.v=split.uprgt.v=splitrect[i].top; + split.ztop[0]=split.ztop[1]= ztop[0]+v_factor*(splitrect[i].top-tcs[UPLFT].v); + split.tcs[UPLFT].v=split.tcs[UPRGT].v=splitrect[i].top; } // the bottom line of the current segment is inside the splittable area // use the splitrect's bottom as bottom of this segment // if not use the bottom of the remaining polygon if (splitbot<=splitbotv) { - split.zbottom[0]=split.zbottom[1]=ztop[0]+v_factor*(splitbot-uplft.v); - split.lolft.v=split.lorgt.v=splitbot; + split.zbottom[0]=split.zbottom[1]=ztop[0]+v_factor*(splitbot-tcs[UPLFT].v); + split.tcs[LOLFT].v=split.tcs[LORGT].v=splitbot; } // // @@ -1166,8 +1166,8 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, texlength = tci.FloatToTexU(seg->sidedef->TexelLength); - uplft.u = lolft.u = ul + texlength * glseg.fracleft; - uprgt.u = lorgt.u = ul + texlength * glseg.fracright; + tcs[UPLFT].u = tcs[LOLFT].u = ul + texlength * glseg.fracleft; + tcs[UPRGT].u = tcs[LORGT].u = ul + texlength * glseg.fracright; float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? @@ -1175,10 +1175,10 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, to += rowoffset + rover->top.model->GetPlaneTexZ(rover->top.isceiling); - uplft.v = tci.FloatToTexV(to - ff_topleft); - uprgt.v = tci.FloatToTexV(to - ff_topright); - lolft.v = tci.FloatToTexV(to - ff_bottomleft); - lorgt.v = tci.FloatToTexV(to - ff_bottomright); + tcs[UPLFT].v = tci.FloatToTexV(to - ff_topleft); + tcs[UPRGT].v = tci.FloatToTexV(to - ff_topright); + tcs[LOLFT].v = tci.FloatToTexV(to - ff_bottomleft); + tcs[LORGT].v = tci.FloatToTexV(to - ff_bottomright); type = RENDERWALL_FFBLOCK; CheckTexturePosition(); } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 9fe120ae2..319330342 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -175,14 +175,8 @@ void GLWall::SetupLights() void GLWall::RenderWall(int textured, unsigned int *store) { - static texcoord tcs[4]; // making this variable static saves us a relatively costly stack integrity check. bool split = (gl_seamless && !(textured&RWF_NOSPLIT) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT)); - tcs[0]=lolft; - tcs[1]=uplft; - tcs[2]=uprgt; - tcs[3]=lorgt; - if (!(textured & RWF_NORENDER)) { gl_RenderState.Apply(); @@ -193,18 +187,18 @@ void GLWall::RenderWall(int textured, unsigned int *store) FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); unsigned int count, offset; - ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[0].u, tcs[0].v); + ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v); ptr++; - if (split && glseg.fracleft == 0) SplitLeftEdge(tcs, ptr); - ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[1].u, tcs[1].v); + if (split && glseg.fracleft == 0) SplitLeftEdge(ptr); + ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v); ptr++; - if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs, ptr); - ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[2].u, tcs[2].v); + if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(ptr); + ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v); ptr++; - if (split && glseg.fracright == 1) SplitRightEdge(tcs, ptr); - ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[3].u, tcs[3].v); + if (split && glseg.fracright == 1) SplitRightEdge(ptr); + ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v); ptr++; - if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, ptr); + if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(ptr); count = GLRenderer->mVBO->GetCount(ptr, &offset); if (!(textured & RWF_NORENDER)) { @@ -265,8 +259,8 @@ void GLWall::RenderMirrorSurface() if (gl.glslversion >= 0.f) { // we use texture coordinates and texture matrix to pass the normal stuff to the shader so that the default vertex buffer format can be used as is. - lolft.u = lorgt.u = uplft.u = uprgt.u = v.X(); - lolft.v = lorgt.v = uplft.v = uprgt.v = v.Z(); + tcs[LOLFT].u = tcs[LORGT].u = tcs[UPLFT].u = tcs[UPRGT].u = v.X(); + tcs[LOLFT].v = tcs[LORGT].v = tcs[UPLFT].v = tcs[UPRGT].v = v.Z(); gl_RenderState.EnableTextureMatrix(true); gl_RenderState.mTextureMatrix.computeNormalMatrix(gl_RenderState.mViewMatrix); From d61ec05c0f744d4eb68742b4a451b0648ea8fcbf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 5 May 2016 12:18:09 +0200 Subject: [PATCH 0598/1509] - draw texture based dynamic lights on walls. --- src/gl/compatibility/gl_20.cpp | 76 +++++++++++++++++++++++++++------- src/gl/scene/gl_drawinfo.h | 1 + src/gl/scene/gl_wall.h | 3 +- src/gl/scene/gl_walls_draw.cpp | 5 +++ 4 files changed, 70 insertions(+), 15 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 6df940b77..2224dd9f4 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -68,8 +68,7 @@ void gl_PatchMenu() { if (gl.glslversion == 0) { - // Radial fog and Doom lighting are not available in SM < 4 cards - // The way they are implemented does not work well on older hardware. + // Radial fog and Doom lighting are not available without full shader support. FOptionValues **opt = OptionValues.CheckKey("LightingModes"); if (opt != NULL) @@ -443,7 +442,7 @@ bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, g = (g*(32 - desaturation) + gray*desaturation) / 32; b = (b*(32 - desaturation) + gray*desaturation) / 32; } - glColor3f(r, g, b); + gl_RenderState.SetColor(r, g, b); return true; } @@ -457,7 +456,7 @@ bool gl_SetupLightTexture() { if (GLRenderer->gllight == nullptr) return false; FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight, false); - pat->Bind(CLAMP_XY, 0); + pat->Bind(CLAMP_XY_NOMIP, 0); return true; } @@ -488,7 +487,7 @@ bool GLWall::PutWallCompat(int passflag) if (sub->lighthead != nullptr) return false; } - bool foggy = (!gl_isBlack(Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE); + bool foggy = !gl_isBlack(Colormap.FadeColor) || (level.flags&LEVEL_HASFADETABLE) || gl_lights_additive; bool masked = passflag == 2 && gltexture->isMasked(); int list = list_indices[masked][foggy]; @@ -517,7 +516,7 @@ bool GLFlat::PutFlatCompat(bool fog) { { GLLDL_FLATS_PLAIN, GLLDL_FLATS_FOG },{ GLLDL_FLATS_MASKED, GLLDL_FLATS_FOGMASKED } }; bool masked = gltexture->isMasked() && ((renderflags&SSRF_RENDER3DPLANES) || stack); - bool foggy = gl_CheckFog(&Colormap, lightlevel) || level.flags&LEVEL_HASFADETABLE; + bool foggy = gl_CheckFog(&Colormap, lightlevel) || (level.flags&LEVEL_HASFADETABLE) || gl_lights_additive; int list = list_indices[masked][foggy]; @@ -591,7 +590,6 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) float scale; FLightNode * node = sub->lighthead; - gl_RenderState.Apply(); while (node) { ADynamicLight * light = node->lightsource; @@ -614,11 +612,12 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) } p.Set(plane.plane); - if (!gl_SetupLight(sub->sector->PortalGroup, p, light, nearPt, up, right, scale, CM_DEFAULT, false, pass == GLPASS_LIGHTTEX_ADDITIVE)) + if (!gl_SetupLight(sub->sector->PortalGroup, p, light, nearPt, up, right, scale, CM_DEFAULT, false, pass != GLPASS_LIGHTTEX)) { node = node->nextLight; continue; } + gl_RenderState.Apply(); FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); for (unsigned int k = 0; k < sub->numlines; k++) @@ -687,7 +686,7 @@ void GLFlat::DrawLightsCompat(int pass) // Sets up the texture coordinates for one light to be rendered // //========================================================================== -bool GLWall::PrepareLight(texcoord * tcs, ADynamicLight * light, int pass) +bool GLWall::PrepareLight(ADynamicLight * light, int pass) { float vtx[] = { glseg.x1,zbottom[0],glseg.y1, glseg.x1,ztop[0],glseg.y1, glseg.x2,ztop[1],glseg.y2, glseg.x2,zbottom[1],glseg.y2 }; Plane p; @@ -701,7 +700,7 @@ bool GLWall::PrepareLight(texcoord * tcs, ADynamicLight * light, int pass) return false; } - if (!gl_SetupLight(seg->frontsector->PortalGroup, p, light, nearPt, up, right, scale, CM_DEFAULT, true, pass == GLPASS_LIGHTTEX_ADDITIVE)) + if (!gl_SetupLight(seg->frontsector->PortalGroup, p, light, nearPt, up, right, scale, CM_DEFAULT, true, pass != GLPASS_LIGHTTEX)) { return false; } @@ -734,6 +733,55 @@ bool GLWall::PrepareLight(texcoord * tcs, ADynamicLight * light, int pass) } +void GLWall::RenderLightsCompat(int pass) +{ + FLightNode * node; + + // black fog is diminishing light and should affect lights less than the rest! + if (pass == GLPASS_LIGHTTEX) gl_SetFog((255 + lightlevel) >> 1, 0, NULL, false); + else gl_SetFog(lightlevel, 0, &Colormap, true); + + if (seg->sidedef == NULL) + { + return; + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + // Iterate through all dynamic lights which touch this wall and render them + node = seg->sidedef->lighthead; + } + else if (sub) + { + // To avoid constant rechecking for polyobjects use the subsector's lightlist instead + node = sub->lighthead; + } + else + { + return; + } + + texcoord save[4]; + memcpy(save, tcs, sizeof(tcs)); + while (node) + { + ADynamicLight * light = node->lightsource; + + if (light->flags2&MF2_DORMANT || + (pass == GLPASS_LIGHTTEX && light->IsAdditive()) || + (pass == GLPASS_LIGHTTEX_ADDITIVE && !light->IsAdditive())) + { + node = node->nextLight; + continue; + } + if (PrepareLight(light, pass)) + { + RenderWall(RWF_TEXTURED, NULL); + } + node = node->nextLight; + } + memcpy(tcs, save, sizeof(tcs)); +} + //========================================================================== // // @@ -820,10 +868,10 @@ void FGLRenderer::RenderMultipassStuff() gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); - gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE); - gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE); - gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); - gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(GLPASS_LIGHTTEX_FOGGY); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(GLPASS_LIGHTTEX_FOGGY); + gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(GLPASS_LIGHTTEX_FOGGY); + gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(GLPASS_LIGHTTEX_FOGGY); } else gl_lights = false; diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index 744ffeef4..124440eee 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -61,6 +61,7 @@ enum Drawpasses GLPASS_LIGHTTEX, // lighttexture pass GLPASS_TEXONLY, // finishing texture pass GLPASS_LIGHTTEX_ADDITIVE, // lighttexture pass (additive) + GLPASS_LIGHTTEX_FOGGY, // lighttexture pass on foggy surfaces (forces all lights to be additive) }; diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 97c8217b7..fdeb99ed0 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -184,13 +184,14 @@ private: void CheckTexturePosition(); void RenderFogBoundaryCompat(); + void RenderLightsCompat(int pass); void Put3DWall(lightlist_t * lightlist, bool translucent); void SplitWallComplex(sector_t * frontsector, bool translucent, float maplightbottomleft, float maplightbottomright); void SplitWall(sector_t * frontsector, bool translucent); void SetupLights(); - bool PrepareLight(texcoord * tcs, ADynamicLight * light, int pass); + bool PrepareLight(ADynamicLight * light, int pass); void RenderWall(int textured, unsigned int *store = NULL); void RenderTextured(int rflags); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 319330342..4fd586388 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -442,5 +442,10 @@ void GLWall::Draw(int pass) RenderTranslucentWall(); break; } + + case GLPASS_LIGHTTEX: + case GLPASS_LIGHTTEX_ADDITIVE: + RenderLightsCompat(pass); + break; } } From 6753cddce13b22c50210394c607fe5d2482bba11 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 8 May 2016 09:22:38 +0200 Subject: [PATCH 0599/1509] - fixed: The HUD weapon drawer partially took the render state from the previous things that got rendered. Especially the blend mode could be randomly set to different values. --- src/gl/scene/gl_weapon.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 171692497..f1cd5e38b 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -353,6 +353,9 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) // now draw the different layers of the weapon gl_RenderState.EnableBrightmap(true); gl_RenderState.SetObjectColor(ThingColor); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); + gl_RenderState.BlendEquation(GL_FUNC_ADD); if (statebright[0] || statebright[1]) { // brighten the weapon to reduce the difference between From b90173ed21bc5caece2eec530c3c5a37c64618a9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 8 May 2016 09:34:22 +0200 Subject: [PATCH 0600/1509] - fixed: ADynamicLight::visibletoplayer was not initialized for placed lights when restoring a savegame. --- src/gl/dynlights/a_dynlight.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 5458f0479..ef96fdd3e 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -48,6 +48,7 @@ #include "doomdata.h" #include "r_utility.h" #include "portal.h" +#include "doomstat.h" #include "gl/renderer/gl_renderer.h" @@ -143,8 +144,13 @@ void ADynamicLight::Serialize(FArchive &arc) arc << m_Radius[0] << m_Radius[1]; if (lighttype == PulseLight) arc << m_lastUpdate << m_cycler; - if (arc.IsLoading()) LinkLight(); - + if (arc.IsLoading()) + { + // The default constructor which is used for creating objects before deserialization will not set this variable. + // It needs to be true for all placed lights. + visibletoplayer = true; + LinkLight(); + } } From d5eb1008a43548353d15c2c8cdee5993a5f73477 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 8 May 2016 22:07:18 +0200 Subject: [PATCH 0601/1509] - implemented texture overlay pass for textured dynamic lights. --- src/gl/scene/gl_flats.cpp | 6 ++++++ src/gl/scene/gl_walls_draw.cpp | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 850a93615..b32139957 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -448,6 +448,12 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG case GLPASS_LIGHTTEX_ADDITIVE: DrawLightsCompat(pass); break; + + case GLPASS_TEXONLY: + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); + gl_SetPlaneTextureRotation(&plane, gltexture); + DrawSubsectors(pass, false, false); + } } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 4fd586388..7bdf5c4dc 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -447,5 +447,10 @@ void GLWall::Draw(int pass) case GLPASS_LIGHTTEX_ADDITIVE: RenderLightsCompat(pass); break; + + case GLPASS_TEXONLY: + gl_RenderState.SetMaterial(gltexture, flags & 3, 0, -1, false); + RenderWall(RWF_TEXTURED); + break; } } From 15c711f2a16b75ec8d1dffc57022a41f4dfeceac Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 9 May 2016 00:58:55 +0200 Subject: [PATCH 0602/1509] - added a missing break in the wall draw dispatcher. --- src/gl/scene/gl_flats.cpp | 2 +- src/gl/scene/gl_walls_draw.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index b32139957..cbc5d3451 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -453,7 +453,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); gl_SetPlaneTextureRotation(&plane, gltexture); DrawSubsectors(pass, false, false); - + break; } } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 7bdf5c4dc..a7cd23d42 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -442,6 +442,7 @@ void GLWall::Draw(int pass) RenderTranslucentWall(); break; } + break; case GLPASS_LIGHTTEX: case GLPASS_LIGHTTEX_ADDITIVE: From 0cc57c614103a93862400c667ae6ee16a0f0d1bb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 May 2016 20:50:01 +0200 Subject: [PATCH 0603/1509] - fixed: BoundTextureDraw2D must reset the texture mode. --- src/posix/cocoa/i_video.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 069239b48..2c04c53a6 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -1285,6 +1285,7 @@ void BoundTextureDraw2D(const GLsizei width, const GLsizei height) vbo->RenderCurrent(ptr, GL_TRIANGLE_STRIP); gl_RenderState.SetEffect(EFF_NONE); + gl_RenderState.SetTextureMode(TM_MODULATE); } bool BoundTextureSaveAsPNG(const GLenum target, const char* const path) From 15933f9c728758363a1b023a541c77795a0714c3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 May 2016 20:51:23 +0200 Subject: [PATCH 0604/1509] - fixed: Texture precaching for sprites had some inverted logic and deleted everything that was still required. --- src/gl/textures/gl_hwtexture.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index b964b030e..7d9d754fd 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -315,13 +315,13 @@ void FHardwareTexture::Clean(bool all) void FHardwareTexture::CleanUnused(SpriteHits &usedtranslations) { - if (usedtranslations.CheckKey(0) != nullptr) + if (usedtranslations.CheckKey(0) == nullptr) { glDefTex.Delete(); } for (int i = glTex_Translated.Size()-1; i>= 0; i--) { - if (usedtranslations.CheckKey(glTex_Translated[i].translation) != nullptr) + if (usedtranslations.CheckKey(glTex_Translated[i].translation) == nullptr) { glTex_Translated[i].Delete(); glTex_Translated.Delete(i); From 616f84209b3102a864be98959cb4ac9a5518a0b9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 12 May 2016 20:23:18 +0200 Subject: [PATCH 0605/1509] - let gl_draw_sync default to false. No need to waste valuable processing time if we can let the GPU run in parallel with the code that generates the next frame. --- src/gl/system/gl_framebuffer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 818084706..108f4f727 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -164,8 +164,7 @@ void OpenGLFrameBuffer::InitializeState() // //========================================================================== -// Testing only for now. -CVAR(Bool, gl_draw_sync, true, 0) //false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Bool, gl_draw_sync, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) void OpenGLFrameBuffer::Update() { From 99bfc64af6c89c85f2ced7515ff65c91a4c51218 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 12 May 2016 23:41:06 +0200 Subject: [PATCH 0606/1509] - another failed attempt to use GL_CLIP_PLANE. Leave it in because it's closer to what is needed than the old code. --- src/gl/renderer/gl_renderstate.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 15a575e79..865053b41 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -342,21 +342,28 @@ void FRenderState::SetClipHeight(float height, float direction) { mClipHeight = height; mClipHeightDirection = direction; +#if 1 + // This still doesn't work... :( + if (gl.glslversion < 1.3f) return; +#endif if (direction != 0.f) { - if (gl.glslversion >= 1.3f) glEnable(GL_CLIP_DISTANCE0); - else + /* + if (gl.glslversion < 1.3f) { - // This does not work. Need someone who understands how glClipPlane works... - //glEnable(GL_CLIP_PLANE0); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadMatrixf(mViewMatrix.get()); // Plane mirrors never are slopes. - //double d[4] = { 0, direction, 0, -direction * height }; - //glClipPlane(GL_CLIP_PLANE0, d); + double d[4] = { 0, direction, 0, -direction * height }; + glClipPlane(GL_CLIP_PLANE0, d); + glPopMatrix(); } + */ + glEnable(GL_CLIP_DISTANCE0); } else { - if (gl.glslversion >= 1.3f) glDisable(GL_CLIP_DISTANCE0); - //else glDisable(GL_CLIP_PLANE0); + glDisable(GL_CLIP_DISTANCE0); // GL_CLIP_PLANE0 is the same value so no need to make a distinction } } From 52e19c59b350bad2ebdb60ed91eaf4afc05234dd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 13 May 2016 20:33:54 +0200 Subject: [PATCH 0607/1509] Revert "- let gl_draw_sync default to false." This reverts commit 616f84209b3102a864be98959cb4ac9a5518a0b9. Now I remember why this is not active: This is causing some problems with interpolated plane heights. Since there is no synchronization with the vertex buffer, the next frame will reset all plane coordinates before the GPU can use them. This will require some rethinking about when to update the buffer - it cannot be done in the render data setup loop. --- src/gl/system/gl_framebuffer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 108f4f727..818084706 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -164,7 +164,8 @@ void OpenGLFrameBuffer::InitializeState() // //========================================================================== -CVAR(Bool, gl_draw_sync, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +// Testing only for now. +CVAR(Bool, gl_draw_sync, true, 0) //false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) void OpenGLFrameBuffer::Update() { From 362e21a6b32e3aa1b773afcf9dd8fb4a28a34722 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 17 May 2016 09:12:26 +0200 Subject: [PATCH 0608/1509] - fixed: The pitch negation required for INHERITACTORPITCH was also applied to the one from PITCHFROMMOMENTUM. --- src/gl/models/gl_models.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index c87cb52c2..a79e5ba7c 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -963,7 +963,7 @@ void gl_RenderModel(GLSprite * spr) // Added MDL_INHERITACTORPITCH and MDL_INHERITACTORROLL flags processing. // If both flags MDL_INHERITACTORPITCH and MDL_PITCHFROMMOMENTUM are set, the pitch sums up the actor pitch and the momentum vector pitch. - if(smf->flags & MDL_INHERITACTORPITCH) pitch += spr->actor->Angles.Pitch.Degrees; + if(smf->flags & MDL_INHERITACTORPITCH) pitch -= spr->actor->Angles.Pitch.Degrees; if(smf->flags & MDL_INHERITACTORROLL) roll += spr->actor->Angles.Roll.Degrees; gl_RenderState.mModelMatrix.loadIdentity(); @@ -974,7 +974,7 @@ void gl_RenderModel(GLSprite * spr) // Applying model transformations: // 1) Applying actor angle, pitch and roll to the model gl_RenderState.mModelMatrix.rotate(-angle, 0, 1, 0); - gl_RenderState.mModelMatrix.rotate(-pitch, 0, 0, 1); + gl_RenderState.mModelMatrix.rotate(pitch, 0, 0, 1); gl_RenderState.mModelMatrix.rotate(-roll, 1, 0, 0); // 2) Applying Doomsday like rotation of the weapon pickup models From 13da14e91566132476ceb4548e95766265efd0e6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 18 May 2016 22:20:18 +0200 Subject: [PATCH 0609/1509] - disable dynamic lights on additively blended surfaces because it doesn't look good at all. --- src/gl/scene/gl_flats.cpp | 2 ++ src/gl/scene/gl_walls_draw.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index cbc5d3451..5164e0676 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -120,6 +120,8 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli) { Plane p; + if (renderstyle == STYLE_Add) return; // no lights on additively blended surfaces. + if (dli != NULL && *dli != -1) { gl_RenderState.ApplyLightIndex(GLRenderer->mLights->GetIndex(*dli)); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index a7cd23d42..20d170977 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -73,6 +73,8 @@ FDynLightData lightdata; void GLWall::SetupLights() { + if (RenderStyle == STYLE_Add) return; // no lights on additively blended surfaces. + // check for wall types which cannot have dynamic lights on them (portal types never get here so they don't need to be checked.) switch (type) { From 5017a192eb6ba3717e416730e1ae124e59411f9f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 19 May 2016 12:22:39 +0200 Subject: [PATCH 0610/1509] - fixed: The texture matrix was not reset after drawing the texture pass for multipass textured dynamic lights. --- src/gl/scene/gl_flats.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 5164e0676..d7c47c618 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -455,6 +455,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); gl_SetPlaneTextureRotation(&plane, gltexture); DrawSubsectors(pass, false, false); + gl_RenderState.EnableTextureMatrix(false); break; } } From 6e53c1bd12019c63715987c0a76c79e868a05401 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 28 May 2016 20:40:33 +0200 Subject: [PATCH 0611/1509] Change render target output from PAL8 to BGRA8 --- src/basictypes.h | 6 + src/f_wipe.cpp | 17 +- src/m_misc.cpp | 2 + src/r_draw.cpp | 1106 ++++++++++++++++++++++++++++++-- src/r_draw.h | 12 +- src/r_drawt.cpp | 397 ++++++++++-- src/r_main.cpp | 8 +- src/r_main.h | 28 + src/r_plane.cpp | 24 +- src/r_segs.cpp | 107 ++- src/r_swrenderer.cpp | 4 + src/r_things.cpp | 73 ++- src/textures/canvastexture.cpp | 5 + src/v_draw.cpp | 45 +- src/v_video.cpp | 52 +- src/v_video.h | 14 +- src/win32/fb_d3d9.cpp | 38 +- src/win32/fb_ddraw.cpp | 10 +- src/win32/win32iface.h | 4 +- src/win32/win32video.cpp | 13 + 20 files changed, 1785 insertions(+), 180 deletions(-) diff --git a/src/basictypes.h b/src/basictypes.h index ff2cd972e..45e33a4a7 100644 --- a/src/basictypes.h +++ b/src/basictypes.h @@ -66,6 +66,12 @@ union QWORD_UNION typedef SDWORD fixed_t; typedef DWORD dsfixed_t; // fixedpt used by span drawer +#ifndef PALETTEOUTPUT +typedef uint32_t canvas_pixel_t; +#else +typedef BYTE canvas_pixel_t; +#endif + #define FIXED_MAX (signed)(0x7fffffff) #define FIXED_MIN (signed)(0x80000000) diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index a3ceb8d50..c6f20cadb 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -77,8 +77,10 @@ bool wipe_initMelt (int ticks) { int i, r; +#ifdef PALETTEOUTPUT // copy start screen to main screen screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start); +#endif // makes this wipe faster (in theory) // to have stuff in column-major format @@ -271,7 +273,8 @@ bool wipe_doBurn (int ticks) // Draw the screen int xstep, ystep, firex, firey; int x, y; - BYTE *to, *fromold, *fromnew; + canvas_pixel_t *to; + BYTE *fromold, *fromnew; const int SHIFT = 16; xstep = (FIREWIDTH << SHIFT) / SCREENWIDTH; @@ -298,6 +301,9 @@ bool wipe_doBurn (int ticks) } else { +#ifndef PALETTEOUTPUT + // TO DO: RGB32k.All +#else int bglevel = 64-fglevel; DWORD *fg2rgb = Col2RGB8[fglevel]; DWORD *bg2rgb = Col2RGB8[bglevel]; @@ -305,6 +311,7 @@ bool wipe_doBurn (int ticks) DWORD bg = bg2rgb[fromold[x]]; fg = (fg+bg) | 0x1f07c1f; to[x] = RGB32k.All[fg & (fg>>15)]; +#endif done = false; } } @@ -335,7 +342,9 @@ bool wipe_doFade (int ticks) fade += ticks * 2; if (fade > 64) { +#ifdef PALETTEOUTPUT screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_end); +#endif return true; } else @@ -346,7 +355,7 @@ bool wipe_doFade (int ticks) DWORD *bg2rgb = Col2RGB8[bglevel]; BYTE *fromnew = (BYTE *)wipe_scr_end; BYTE *fromold = (BYTE *)wipe_scr_start; - BYTE *to = screen->GetBuffer(); + canvas_pixel_t *to = screen->GetBuffer(); for (y = 0; y < SCREENHEIGHT; y++) { @@ -387,7 +396,9 @@ bool wipe_StartScreen (int type) if (CurrentWipeType) { wipe_scr_start = new short[SCREENWIDTH * SCREENHEIGHT / 2]; +#ifdef PALETTEOUTPUT screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start); +#endif return true; } return false; @@ -398,8 +409,10 @@ void wipe_EndScreen (void) if (CurrentWipeType) { wipe_scr_end = new short[SCREENWIDTH * SCREENHEIGHT / 2]; +#ifdef PALETTEOUTPUT screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_end); screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start); // restore start scr. +#endif // Initialize the wipe (*wipes[(CurrentWipeType-1)*3])(0); } diff --git a/src/m_misc.cpp b/src/m_misc.cpp index 87f61f253..79416c31d 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -655,6 +655,7 @@ static bool FindFreeName (FString &fullname, const char *extension) void M_ScreenShot (const char *filename) { +#ifdef PALETTEOUTPUT FILE *file; FString autoname; bool writepcx = (stricmp (screenshot_type, "pcx") == 0); // PNG is the default @@ -743,6 +744,7 @@ void M_ScreenShot (const char *filename) Printf ("Could not create screenshot.\n"); } } +#endif } CCMD (screenshot) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 80b91ed2d..044910008 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -42,6 +42,9 @@ #include "gi.h" #include "stats.h" #include "x86.h" +#ifndef NO_SSE +#include +#endif #undef RANGECHECK @@ -61,7 +64,7 @@ extern int ST_Y; BYTE* viewimage; extern "C" { int ylookup[MAXHEIGHT]; -BYTE *dc_destorg; +canvas_pixel_t *dc_destorg; } int scaledviewwidth; @@ -90,6 +93,7 @@ extern "C" { int dc_pitch=0xABadCafe; // [RH] Distance between rows lighttable_t* dc_colormap; +fixed_t dc_light; int dc_x; int dc_yl; int dc_yh; @@ -103,12 +107,13 @@ DWORD *dc_destblend; // blending lookups // first pixel in a column (possibly virtual) const BYTE* dc_source; -BYTE* dc_dest; +canvas_pixel_t* dc_dest; int dc_count; DWORD vplce[4]; DWORD vince[4]; BYTE* palookupoffse[4]; +fixed_t palookuplight[4]; const BYTE* bufplce[4]; // just for profiling @@ -180,7 +185,7 @@ void R_InitShadeMaps() void R_DrawColumnP_C (void) { int count; - BYTE* dest; + canvas_pixel_t* dest; fixed_t frac; fixed_t fracstep; @@ -193,6 +198,10 @@ void R_DrawColumnP_C (void) // Framebuffer destination address. dest = dc_dest; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); +#endif + // Determine scaling, // which is the only mapping to be done. fracstep = dc_iscale; @@ -212,7 +221,11 @@ void R_DrawColumnP_C (void) { // Re-map color indices from wall texture column // using a lighting/special effects LUT. - *dest = colormap[source[frac>>FRACBITS]]; +#ifndef PALETTEOUTPUT + *dest = shade_pal_index(colormap[source[frac>>FRACBITS]], light); +#else + *dest = colormap[source[frac >> FRACBITS]]; +#endif dest += pitch; frac += fracstep; @@ -226,7 +239,7 @@ void R_DrawColumnP_C (void) void R_FillColumnP (void) { int count; - BYTE* dest; + canvas_pixel_t* dest; count = dc_count; @@ -235,13 +248,21 @@ void R_FillColumnP (void) dest = dc_dest; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); +#endif + { int pitch = dc_pitch; BYTE color = dc_color; do { +#ifndef PALETTEOUTPUT + *dest = shade_pal_index(color, light); +#else *dest = color; +#endif dest += pitch; } while (--count); } @@ -250,19 +271,39 @@ void R_FillColumnP (void) void R_FillAddColumn (void) { int count; - BYTE *dest; + canvas_pixel_t *dest; count = dc_count; if (count <= 0) return; dest = dc_dest; + int pitch = dc_pitch; + +#ifndef PALETTEOUTPUT + uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; + uint32_t fg_green = (dc_srccolor >> 2) & 0xf8; + uint32_t fg_blue = (dc_srccolor << 3) & 0xf8; + + do + { + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red + 1) / 2; + uint32_t green = (fg_green + bg_green + 1) / 2; + uint32_t blue = (fg_blue + bg_blue + 1) / 2; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--count); +#else DWORD *bg2rgb; DWORD fg; bg2rgb = dc_destblend; fg = dc_srccolor; - int pitch = dc_pitch; do { @@ -271,25 +312,45 @@ void R_FillAddColumn (void) *dest = RGB32k.All[bg & (bg>>15)]; dest += pitch; } while (--count); - +#endif } void R_FillAddClampColumn (void) { int count; - BYTE *dest; + canvas_pixel_t *dest; count = dc_count; if (count <= 0) return; dest = dc_dest; + int pitch = dc_pitch; + +#ifndef PALETTEOUTPUT + uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; + uint32_t fg_green = (dc_srccolor >> 2) & 0xf8; + uint32_t fg_blue = (dc_srccolor << 3) & 0xf8; + + do + { + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--count); +#else DWORD *bg2rgb; DWORD fg; bg2rgb = dc_destblend; fg = dc_srccolor; - int pitch = dc_pitch; do { @@ -304,25 +365,45 @@ void R_FillAddClampColumn (void) *dest = RGB32k.All[a & (a>>15)]; dest += pitch; } while (--count); - +#endif } void R_FillSubClampColumn (void) { int count; - BYTE *dest; + canvas_pixel_t *dest; count = dc_count; if (count <= 0) return; dest = dc_dest; + int pitch = dc_pitch; + +#ifndef PALETTEOUTPUT + uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; + uint32_t fg_green = (dc_srccolor >> 2) & 0xf8; + uint32_t fg_blue = (dc_srccolor << 3) & 0xf8; + + do + { + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 255; + uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 255; + uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 255; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--count); +#else DWORD *bg2rgb; DWORD fg; bg2rgb = dc_destblend; fg = dc_srccolor | 0x40100400; - int pitch = dc_pitch; do { @@ -336,25 +417,45 @@ void R_FillSubClampColumn (void) *dest = RGB32k.All[a & (a>>15)]; dest += pitch; } while (--count); - +#endif } void R_FillRevSubClampColumn (void) { int count; - BYTE *dest; + canvas_pixel_t *dest; count = dc_count; if (count <= 0) return; dest = dc_dest; + int pitch = dc_pitch; + +#ifndef PALETTEOUTPUT + uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; + uint32_t fg_green = (dc_srccolor >> 2) & 0xf8; + uint32_t fg_blue = (dc_srccolor << 3) & 0xf8; + + do + { + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 255; + uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 255; + uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 255; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--count); +#else DWORD *bg2rgb; DWORD fg; bg2rgb = dc_destblend; fg = dc_srccolor; - int pitch = dc_pitch; do { @@ -368,7 +469,7 @@ void R_FillRevSubClampColumn (void) *dest = RGB32k.All[a & (a>>15)]; dest += pitch; } while (--count); - +#endif } // @@ -421,7 +522,7 @@ void R_InitFuzzTable (int fuzzoff) void R_DrawFuzzColumnP_C (void) { int count; - BYTE *dest; + canvas_pixel_t *dest; // Adjust borders. Low... if (dc_yl == 0) @@ -441,6 +542,85 @@ void R_DrawFuzzColumnP_C (void) dest = ylookup[dc_yl] + dc_x + dc_destorg; +#ifndef PALETTEOUTPUT + + // Note: this implementation assumes this function is only used for the pinky shadow effect (i.e. no other fancy colormap than black) + // I'm not sure if this is really always the case or not. + + { + // [RH] Make local copies of global vars to try and improve + // the optimizations made by the compiler. + int pitch = dc_pitch; + int fuzz = fuzzpos; + int cnt; + + // [RH] Split this into three separate loops to minimize + // the number of times fuzzpos needs to be clamped. + if (fuzz) + { + cnt = MIN(FUZZTABLE - fuzz, count); + count -= cnt; + do + { + uint32_t bg = dest[fuzzoffset[fuzz++]]; + uint32_t bg_red = (bg >> 16) & 0xff; + uint32_t bg_green = (bg >> 8) & 0xff; + uint32_t bg_blue = (bg) & 0xff; + + uint32_t red = bg_red * 3 / 4; + uint32_t green = bg_green * 3 / 4; + uint32_t blue = bg_blue * 3 / 4; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--cnt); + } + if (fuzz == FUZZTABLE || count > 0) + { + while (count >= FUZZTABLE) + { + fuzz = 0; + cnt = FUZZTABLE; + count -= FUZZTABLE; + do + { + uint32_t bg = dest[fuzzoffset[fuzz++]]; + uint32_t bg_red = (bg >> 16) & 0xff; + uint32_t bg_green = (bg >> 8) & 0xff; + uint32_t bg_blue = (bg) & 0xff; + + uint32_t red = bg_red * 3 / 4; + uint32_t green = bg_green * 3 / 4; + uint32_t blue = bg_blue * 3 / 4; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--cnt); + } + fuzz = 0; + if (count > 0) + { + do + { + uint32_t bg = dest[fuzzoffset[fuzz++]]; + uint32_t bg_red = (bg >> 16) & 0xff; + uint32_t bg_green = (bg >> 8) & 0xff; + uint32_t bg_blue = (bg) & 0xff; + + uint32_t red = bg_red * 3 / 4; + uint32_t green = bg_green * 3 / 4; + uint32_t blue = bg_blue * 3 / 4; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--count); + } + } + fuzzpos = fuzz; + } + +#else + // colormap #6 is used for shading (of 0-31, a bit brighter than average) { // [RH] Make local copies of global vars to try and improve @@ -487,6 +667,7 @@ void R_DrawFuzzColumnP_C (void) } fuzzpos = fuzz; } +#endif } #endif @@ -539,7 +720,7 @@ algorithm that uses RGB tables. void R_DrawAddColumnP_C (void) { int count; - BYTE *dest; + canvas_pixel_t *dest; fixed_t frac; fixed_t fracstep; @@ -552,6 +733,34 @@ void R_DrawAddColumnP_C (void) fracstep = dc_iscale; frac = dc_texturefrac; +#ifndef PALETTEOUTPUT + { + const BYTE *source = dc_source; + int pitch = dc_pitch; + BYTE *colormap = dc_colormap; + + do + { + uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], 0); + + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } +#else { DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; @@ -572,6 +781,7 @@ void R_DrawAddColumnP_C (void) frac += fracstep; } while (--count); } +#endif } // @@ -585,7 +795,7 @@ void R_DrawAddColumnP_C (void) void R_DrawTranslatedColumnP_C (void) { int count; - BYTE* dest; + canvas_pixel_t* dest; fixed_t frac; fixed_t fracstep; @@ -593,6 +803,10 @@ void R_DrawTranslatedColumnP_C (void) if (count <= 0) return; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); +#endif + dest = dc_dest; fracstep = dc_iscale; @@ -607,7 +821,11 @@ void R_DrawTranslatedColumnP_C (void) do { +#ifndef PALETTEOUTPUT + *dest = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); +#else *dest = colormap[translation[source[frac>>FRACBITS]]]; +#endif dest += pitch; frac += fracstep; @@ -619,7 +837,7 @@ void R_DrawTranslatedColumnP_C (void) void R_DrawTlatedAddColumnP_C (void) { int count; - BYTE *dest; + canvas_pixel_t *dest; fixed_t frac; fixed_t fracstep; @@ -627,11 +845,44 @@ void R_DrawTlatedAddColumnP_C (void) if (count <= 0) return; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); +#endif + dest = dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; +#ifndef PALETTEOUTPUT + { + BYTE *translation = dc_translation; + BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; + int pitch = dc_pitch; + + do + { + uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); + + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } +#else { DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; @@ -647,12 +898,13 @@ void R_DrawTlatedAddColumnP_C (void) fg = fg2rgb[fg]; bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg>>15)]; + fg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg >> 15)]; dest += pitch; frac += fracstep; } while (--count); } +#endif } // Draw a column whose "color" values are actually translucency @@ -660,7 +912,7 @@ void R_DrawTlatedAddColumnP_C (void) void R_DrawShadedColumnP_C (void) { int count; - BYTE *dest; + canvas_pixel_t *dest; fixed_t frac, fracstep; count = dc_count; @@ -673,6 +925,36 @@ void R_DrawShadedColumnP_C (void) fracstep = dc_iscale; frac = dc_texturefrac; +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + { + const BYTE *source = dc_source; + BYTE *colormap = dc_colormap; + int pitch = dc_pitch; + + do + { + DWORD alpha = clamp(colormap[source[frac >> FRACBITS]], 0, 64); + DWORD inv_alpha = 64 - alpha; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; + uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; + uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } +#else { const BYTE *source = dc_source; BYTE *colormap = dc_colormap; @@ -690,13 +972,14 @@ void R_DrawShadedColumnP_C (void) frac += fracstep; } while (--count); } +#endif } // Add source to destination, clamping it to white void R_DrawAddClampColumnP_C () { int count; - BYTE *dest; + canvas_pixel_t *dest; fixed_t frac; fixed_t fracstep; @@ -709,6 +992,34 @@ void R_DrawAddClampColumnP_C () fracstep = dc_iscale; frac = dc_texturefrac; +#ifndef PALETTEOUTPUT + { + const BYTE *source = dc_source; + BYTE *colormap = dc_colormap; + int pitch = dc_pitch; + uint32_t light = calc_light_multiplier(dc_light); + + do + { + uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } +#else { BYTE *colormap = dc_colormap; const BYTE *source = dc_source; @@ -731,13 +1042,14 @@ void R_DrawAddClampColumnP_C () frac += fracstep; } while (--count); } +#endif } // Add translated source to destination, clamping it to white void R_DrawAddClampTranslatedColumnP_C () { int count; - BYTE *dest; + canvas_pixel_t *dest; fixed_t frac; fixed_t fracstep; @@ -750,6 +1062,35 @@ void R_DrawAddClampTranslatedColumnP_C () fracstep = dc_iscale; frac = dc_texturefrac; +#ifndef PALETTEOUTPUT + { + BYTE *translation = dc_translation; + BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; + int pitch = dc_pitch; + uint32_t light = calc_light_multiplier(dc_light); + + do + { + uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } +#else { BYTE *translation = dc_translation; BYTE *colormap = dc_colormap; @@ -773,13 +1114,14 @@ void R_DrawAddClampTranslatedColumnP_C () frac += fracstep; } while (--count); } +#endif } // Subtract destination from source, clamping it to black void R_DrawSubClampColumnP_C () { int count; - BYTE *dest; + canvas_pixel_t *dest; fixed_t frac; fixed_t fracstep; @@ -792,6 +1134,34 @@ void R_DrawSubClampColumnP_C () fracstep = dc_iscale; frac = dc_texturefrac; +#ifndef PALETTEOUTPUT + { + BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; + int pitch = dc_pitch; + uint32_t light = calc_light_multiplier(dc_light); + + do + { + uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } +#else { BYTE *colormap = dc_colormap; const BYTE *source = dc_source; @@ -813,13 +1183,14 @@ void R_DrawSubClampColumnP_C () frac += fracstep; } while (--count); } +#endif } // Subtract destination from source, clamping it to black void R_DrawSubClampTranslatedColumnP_C () { int count; - BYTE *dest; + canvas_pixel_t *dest; fixed_t frac; fixed_t fracstep; @@ -832,6 +1203,35 @@ void R_DrawSubClampTranslatedColumnP_C () fracstep = dc_iscale; frac = dc_texturefrac; +#ifndef PALETTEOUTPUT + { + BYTE *translation = dc_translation; + BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; + int pitch = dc_pitch; + uint32_t light = calc_light_multiplier(dc_light); + + do + { + uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } +#else { BYTE *translation = dc_translation; BYTE *colormap = dc_colormap; @@ -854,13 +1254,14 @@ void R_DrawSubClampTranslatedColumnP_C () frac += fracstep; } while (--count); } +#endif } // Subtract source from destination, clamping it to black void R_DrawRevSubClampColumnP_C () { int count; - BYTE *dest; + canvas_pixel_t *dest; fixed_t frac; fixed_t fracstep; @@ -873,6 +1274,34 @@ void R_DrawRevSubClampColumnP_C () fracstep = dc_iscale; frac = dc_texturefrac; +#ifndef PALETTEOUTPUT + { + BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; + int pitch = dc_pitch; + uint32_t light = calc_light_multiplier(dc_light); + + do + { + uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } +#else { BYTE *colormap = dc_colormap; const BYTE *source = dc_source; @@ -894,13 +1323,14 @@ void R_DrawRevSubClampColumnP_C () frac += fracstep; } while (--count); } +#endif } // Subtract source from destination, clamping it to black void R_DrawRevSubClampTranslatedColumnP_C () { int count; - BYTE *dest; + canvas_pixel_t *dest; fixed_t frac; fixed_t fracstep; @@ -913,6 +1343,35 @@ void R_DrawRevSubClampTranslatedColumnP_C () fracstep = dc_iscale; frac = dc_texturefrac; +#ifndef PALETTEOUTPUT + { + BYTE *translation = dc_translation; + BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; + int pitch = dc_pitch; + uint32_t light = calc_light_multiplier(dc_light); + + do + { + uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } +#else { BYTE *translation = dc_translation; BYTE *colormap = dc_colormap; @@ -935,6 +1394,7 @@ void R_DrawRevSubClampTranslatedColumnP_C () frac += fracstep; } while (--count); } +#endif } @@ -967,6 +1427,7 @@ int ds_x1; int ds_x2; lighttable_t* ds_colormap; +//dsfixed_t ds_light; dsfixed_t ds_xfrac; dsfixed_t ds_yfrac; @@ -1019,6 +1480,7 @@ void R_SetSpanSource(const BYTE *pixels) void R_SetSpanColormap(BYTE *colormap) { ds_colormap = colormap; + ds_light = 0; #ifdef X86_ASM if (ds_colormap != ds_curcolormap) { @@ -1062,7 +1524,7 @@ void R_DrawSpanP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - BYTE* dest; + canvas_pixel_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -1087,9 +1549,64 @@ void R_DrawSpanP_C (void) xstep = ds_xstep; ystep = ds_ystep; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(ds_light); +#endif + if (ds_xbits == 6 && ds_ybits == 6) { // 64x64 is the most common case by far, so special case it. + +#ifndef PALETTEOUTPUT +#ifndef NO_SSE + __m128i mlight = _mm_set_epi16(256, light, light, light, 256, light, light, light); + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + + int sse_count = count / 4; + count -= sse_count * 4; + while (sse_count--) + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p0 = colormap[source[spot]]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p1 = colormap[source[spot]]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p2 = colormap[source[spot]]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p3 = colormap[source[spot]]; + xfrac += xstep; + yfrac += ystep; + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + __m128i fg = _mm_set_epi32(palette[p0], palette[p1], palette[p2], palette[p3]); + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + fg_hi = _mm_mullo_epi16(fg_hi, mlight); + fg_hi = _mm_srli_epi16(fg_hi, 8); + fg_lo = _mm_mullo_epi16(fg_lo, mlight); + fg_lo = _mm_srli_epi16(fg_lo, 8); + fg = _mm_packus_epi16(fg_hi, fg_lo); + _mm_storeu_si128((__m128i*)dest, fg); + + // Next step in u,v. + dest += 4; + } + if (count == 0) + return; +#endif +#endif + do { // Current texture index in u,v. @@ -1097,7 +1614,11 @@ void R_DrawSpanP_C (void) // Lookup pixel from flat texture tile, // re-index using light/colormap. +#ifndef PALETTEOUTPUT + *dest++ = shade_pal_index(colormap[source[spot]], light); +#else *dest++ = colormap[source[spot]]; +#endif // Next step in u,v. xfrac += xstep; @@ -1117,7 +1638,11 @@ void R_DrawSpanP_C (void) // Lookup pixel from flat texture tile, // re-index using light/colormap. +#ifndef PALETTEOUTPUT + *dest++ = shade_pal_index(colormap[source[spot]], light); +#else *dest++ = colormap[source[spot]]; +#endif // Next step in u,v. xfrac += xstep; @@ -1133,12 +1658,16 @@ void R_DrawSpanMaskedP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - BYTE* dest; + canvas_pixel_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; int spot; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(ds_light); +#endif + xfrac = ds_xfrac; yfrac = ds_yfrac; @@ -1160,7 +1689,11 @@ void R_DrawSpanMaskedP_C (void) texdata = source[spot]; if (texdata != 0) { +#ifndef PALETTEOUTPUT + *dest = shade_pal_index(colormap[texdata], light); +#else *dest = colormap[texdata]; +#endif } dest++; xfrac += xstep; @@ -1180,7 +1713,11 @@ void R_DrawSpanMaskedP_C (void) texdata = source[spot]; if (texdata != 0) { +#ifndef PALETTEOUTPUT + *dest = shade_pal_index(colormap[texdata], light); +#else *dest = colormap[texdata]; +#endif } dest++; xfrac += xstep; @@ -1196,7 +1733,7 @@ void R_DrawSpanTranslucentP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - BYTE* dest; + canvas_pixel_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -1214,9 +1751,35 @@ void R_DrawSpanTranslucentP_C (void) xstep = ds_xstep; ystep = ds_ystep; + uint32_t light = calc_light_multiplier(ds_light); + if (ds_xbits == 6 && ds_ybits == 6) { // 64x64 is the most common case by far, so special case it. +#ifndef PALETTEOUTPUT + do + { + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + + uint32_t fg = shade_pal_index(colormap[source[spot]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red + 1) / 2; + uint32_t green = (fg_green + bg_green + 1) / 2; + uint32_t blue = (fg_blue + bg_blue + 1) / 2; + + *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; + + xfrac += xstep; + yfrac += ystep; + } while (--count); +#else do { spot = ((xfrac>>(32-6-6))&(63*64)) + (yfrac>>(32-6)); @@ -1229,9 +1792,37 @@ void R_DrawSpanTranslucentP_C (void) xfrac += xstep; yfrac += ystep; } while (--count); +#endif } else { +#ifndef PALETTEOUTPUT + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + do + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + + uint32_t fg = shade_pal_index(colormap[source[spot]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red + 1) / 2; + uint32_t green = (fg_green + bg_green + 1) / 2; + uint32_t blue = (fg_blue + bg_blue + 1) / 2; + + *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; + + xfrac += xstep; + yfrac += ystep; + } while (--count); +#else BYTE yshift = 32 - ds_ybits; BYTE xshift = yshift - ds_xbits; int xmask = ((1 << ds_xbits) - 1) << ds_ybits; @@ -1247,6 +1838,7 @@ void R_DrawSpanTranslucentP_C (void) xfrac += xstep; yfrac += ystep; } while (--count); +#endif } } @@ -1256,7 +1848,7 @@ void R_DrawSpanMaskedTranslucentP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - BYTE* dest; + canvas_pixel_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -1264,6 +1856,8 @@ void R_DrawSpanMaskedTranslucentP_C (void) DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; + uint32_t light = calc_light_multiplier(ds_light); + xfrac = ds_xfrac; yfrac = ds_yfrac; @@ -1285,12 +1879,29 @@ void R_DrawSpanMaskedTranslucentP_C (void) texdata = source[spot]; if (texdata != 0) { +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(colormap[texdata], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red + 1) / 2; + uint32_t green = (fg_green + bg_green + 1) / 2; + uint32_t blue = (fg_blue + bg_blue + 1) / 2; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; +#else DWORD fg = colormap[texdata]; DWORD bg = *dest; fg = fg2rgb[fg]; bg = bg2rgb[bg]; fg = (fg+bg) | 0x1f07c1f; *dest = RGB32k.All[fg & (fg>>15)]; +#endif } dest++; xfrac += xstep; @@ -1310,12 +1921,29 @@ void R_DrawSpanMaskedTranslucentP_C (void) texdata = source[spot]; if (texdata != 0) { +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(colormap[texdata], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red + 1) / 2; + uint32_t green = (fg_green + bg_green + 1) / 2; + uint32_t blue = (fg_blue + bg_blue + 1) / 2; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; +#else DWORD fg = colormap[texdata]; DWORD bg = *dest; fg = fg2rgb[fg]; bg = bg2rgb[bg]; fg = (fg+bg) | 0x1f07c1f; *dest = RGB32k.All[fg & (fg>>15)]; +#endif } dest++; xfrac += xstep; @@ -1330,7 +1958,7 @@ void R_DrawSpanAddClampP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - BYTE* dest; + canvas_pixel_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -1338,6 +1966,8 @@ void R_DrawSpanAddClampP_C (void) DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; + uint32_t light = calc_light_multiplier(ds_light); + xfrac = ds_xfrac; yfrac = ds_yfrac; @@ -1354,6 +1984,23 @@ void R_DrawSpanAddClampP_C (void) do { spot = ((xfrac>>(32-6-6))&(63*64)) + (yfrac>>(32-6)); + +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(colormap[source[spot]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; +#else DWORD a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; DWORD b = a; @@ -1363,6 +2010,8 @@ void R_DrawSpanAddClampP_C (void) b = b - (b >> 5); a |= b; *dest++ = RGB32k.All[a & (a>>15)]; +#endif + xfrac += xstep; yfrac += ystep; } while (--count); @@ -1375,6 +2024,23 @@ void R_DrawSpanAddClampP_C (void) do { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(colormap[source[spot]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; +#else DWORD a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; DWORD b = a; @@ -1384,6 +2050,8 @@ void R_DrawSpanAddClampP_C (void) b = b - (b >> 5); a |= b; *dest++ = RGB32k.All[a & (a>>15)]; +#endif + xfrac += xstep; yfrac += ystep; } while (--count); @@ -1396,7 +2064,7 @@ void R_DrawSpanMaskedAddClampP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - BYTE* dest; + canvas_pixel_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -1404,6 +2072,8 @@ void R_DrawSpanMaskedAddClampP_C (void) DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; + uint32_t light = calc_light_multiplier(ds_light); + xfrac = ds_xfrac; yfrac = ds_yfrac; @@ -1425,6 +2095,22 @@ void R_DrawSpanMaskedAddClampP_C (void) texdata = source[spot]; if (texdata != 0) { +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(colormap[texdata], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red + 1) / 2; + uint32_t green = (fg_green + bg_green + 1) / 2; + uint32_t blue = (fg_blue + bg_blue + 1) / 2; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; +#else DWORD a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; DWORD b = a; @@ -1434,6 +2120,7 @@ void R_DrawSpanMaskedAddClampP_C (void) b = b - (b >> 5); a |= b; *dest = RGB32k.All[a & (a>>15)]; +#endif } dest++; xfrac += xstep; @@ -1453,6 +2140,22 @@ void R_DrawSpanMaskedAddClampP_C (void) texdata = source[spot]; if (texdata != 0) { +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(colormap[texdata], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red + 1) / 2; + uint32_t green = (fg_green + bg_green + 1) / 2; + uint32_t blue = (fg_blue + bg_blue + 1) / 2; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; +#else DWORD a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; DWORD b = a; @@ -1462,6 +2165,7 @@ void R_DrawSpanMaskedAddClampP_C (void) b = b - (b >> 5); a |= b; *dest = RGB32k.All[a & (a>>15)]; +#endif } dest++; xfrac += xstep; @@ -1473,7 +2177,16 @@ void R_DrawSpanMaskedAddClampP_C (void) // [RH] Just fill a span with a color void R_FillSpan (void) { - memset (ylookup[ds_y] + ds_x1 + dc_destorg, ds_color, ds_x2 - ds_x1 + 1); +#ifndef PALETTEOUTPUT + canvas_pixel_t *dest = ylookup[ds_y] + ds_x1 + dc_destorg; + int count = (ds_x2 - ds_x1 + 1); + uint32_t light = calc_light_multiplier(ds_light); + uint32_t color = shade_pal_index(ds_color, light); + for (int i = 0; i < count; i++) + dest[i] = color; +#else + memset (ylookup[ds_y] + ds_x1 + dc_destorg, ds_color, (ds_x2 - ds_x1 + 1) * sizeof(canvas_pixel_t)); +#endif } // Draw a voxel slab @@ -1492,7 +2205,7 @@ extern "C" void R_SetupDrawSlabC(const BYTE *colormap) slabcolormap = colormap; } -extern "C" void R_DrawSlabC(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p) +extern "C" void R_DrawSlabC(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, canvas_pixel_t *p) { int x; const BYTE *colormap = slabcolormap; @@ -1666,13 +2379,21 @@ DWORD vlinec1 () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - BYTE *dest = dc_dest; + canvas_pixel_t *dest = dc_dest; int bits = vlinebits; int pitch = dc_pitch; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); +#endif + do { - *dest = colormap[source[frac>>bits]]; +#ifndef PALETTEOUTPUT + *dest = shade_pal_index(colormap[source[frac>>bits]], light); +#else + *dest = colormap[source[frac >> bits]]; +#endif frac += fracstep; dest += pitch; } while (--count); @@ -1682,19 +2403,83 @@ DWORD vlinec1 () void vlinec4 () { - BYTE *dest = dc_dest; + canvas_pixel_t *dest = dc_dest; int count = dc_count; int bits = vlinebits; DWORD place; +#ifndef PALETTEOUTPUT + uint32_t light0 = calc_light_multiplier(palookuplight[0]); + uint32_t light1 = calc_light_multiplier(palookuplight[1]); + uint32_t light2 = calc_light_multiplier(palookuplight[2]); + uint32_t light3 = calc_light_multiplier(palookuplight[3]); +#ifndef NO_SSE + __m128i mlight_hi = _mm_set_epi16(256, light0, light0, light0, 256, light1, light1, light1); + __m128i mlight_lo = _mm_set_epi16(256, light2, light2, light2, 256, light3, light3, light3); + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; +#endif +#endif + do { +#ifndef PALETTEOUTPUT +#ifndef NO_SSE + + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; + + BYTE p0 = palookupoffse[0][bufplce[0][place0 >> bits]]; + BYTE p1 = palookupoffse[1][bufplce[1][place1 >> bits]]; + BYTE p2 = palookupoffse[2][bufplce[2][place2 >> bits]]; + BYTE p3 = palookupoffse[3][bufplce[3][place3 >> bits]]; + + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; + + __m128i fg = _mm_set_epi32(palette[p0], palette[p1], palette[p2], palette[p3]); + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + fg_hi = _mm_mullo_epi16(fg_hi, mlight_hi); + fg_hi = _mm_srli_epi16(fg_hi, 8); + fg_lo = _mm_mullo_epi16(fg_lo, mlight_lo); + fg_lo = _mm_srli_epi16(fg_lo, 8); + fg = _mm_packus_epi16(fg_hi, fg_lo); + _mm_storeu_si128((__m128i*)dest, fg); + +#else + dest[0] = shade_pal_index(palookupoffse[0][bufplce[0][(place = vplce[0]) >> bits]], light0); vplce[0] = place + vince[0]; + dest[1] = shade_pal_index(palookupoffse[1][bufplce[1][(place = vplce[1]) >> bits]], light1); vplce[1] = place + vince[1]; + dest[2] = shade_pal_index(palookupoffse[2][bufplce[2][(place = vplce[2]) >> bits]], light2); vplce[2] = place + vince[2]; + dest[3] = shade_pal_index(palookupoffse[3][bufplce[3][(place = vplce[3]) >> bits]], light3); vplce[3] = place + vince[3]; +#endif +#else dest[0] = palookupoffse[0][bufplce[0][(place=vplce[0])>>bits]]; vplce[0] = place+vince[0]; dest[1] = palookupoffse[1][bufplce[1][(place=vplce[1])>>bits]]; vplce[1] = place+vince[1]; dest[2] = palookupoffse[2][bufplce[2][(place=vplce[2])>>bits]]; vplce[2] = place+vince[2]; dest[3] = palookupoffse[3][bufplce[3][(place=vplce[3])>>bits]]; vplce[3] = place+vince[3]; +#endif dest += dc_pitch; } while (--count); + +#ifndef PALETTEOUTPUT +#ifndef NO_SSE + // Is this needed? Global variables makes it tricky to know.. + vplce[0] = local_vplce[0]; + vplce[1] = local_vplce[1]; + vplce[2] = local_vplce[2]; + vplce[3] = local_vplce[3]; + vince[0] = local_vince[0]; + vince[1] = local_vince[1]; + vince[2] = local_vince[2]; + vince[3] = local_vince[3]; +#endif +#endif } #endif @@ -1717,16 +2502,24 @@ DWORD mvlinec1 () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - BYTE *dest = dc_dest; + canvas_pixel_t *dest = dc_dest; int bits = mvlinebits; int pitch = dc_pitch; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); +#endif + do { BYTE pix = source[frac>>bits]; if (pix != 0) { +#ifndef PALETTEOUTPUT + *dest = shade_pal_index(colormap[pix], light); +#else *dest = colormap[pix]; +#endif } frac += fracstep; dest += pitch; @@ -1737,19 +2530,33 @@ DWORD mvlinec1 () void mvlinec4 () { - BYTE *dest = dc_dest; + canvas_pixel_t *dest = dc_dest; int count = dc_count; int bits = mvlinebits; DWORD place; +#ifndef PALETTEOUTPUT + uint32_t light0 = calc_light_multiplier(palookuplight[0]); + uint32_t light1 = calc_light_multiplier(palookuplight[1]); + uint32_t light2 = calc_light_multiplier(palookuplight[2]); + uint32_t light3 = calc_light_multiplier(palookuplight[3]); +#endif + do { BYTE pix; +#ifndef PALETTEOUTPUT + pix = bufplce[0][(place = vplce[0]) >> bits]; if (pix) dest[0] = shade_pal_index(palookupoffse[0][pix], light0); vplce[0] = place + vince[0]; + pix = bufplce[1][(place = vplce[1]) >> bits]; if (pix) dest[1] = shade_pal_index(palookupoffse[1][pix], light1); vplce[1] = place + vince[1]; + pix = bufplce[2][(place = vplce[2]) >> bits]; if (pix) dest[2] = shade_pal_index(palookupoffse[2][pix], light2); vplce[2] = place + vince[2]; + pix = bufplce[3][(place = vplce[3]) >> bits]; if (pix) dest[3] = shade_pal_index(palookupoffse[3][pix], light3); vplce[3] = place + vince[3]; +#else pix = bufplce[0][(place=vplce[0])>>bits]; if(pix) dest[0] = palookupoffse[0][pix]; vplce[0] = place+vince[0]; pix = bufplce[1][(place=vplce[1])>>bits]; if(pix) dest[1] = palookupoffse[1][pix]; vplce[1] = place+vince[1]; pix = bufplce[2][(place=vplce[2])>>bits]; if(pix) dest[2] = palookupoffse[2][pix]; vplce[2] = place+vince[2]; pix = bufplce[3][(place=vplce[3])>>bits]; if(pix) dest[3] = palookupoffse[3][pix]; vplce[3] = place+vince[3]; +#endif dest += dc_pitch; } while (--count); } @@ -1763,7 +2570,11 @@ extern int wallshade; static void R_DrawFogBoundarySection (int y, int y2, int x1) { BYTE *colormap = dc_colormap; - BYTE *dest = ylookup[y] + dc_destorg; + canvas_pixel_t *dest = ylookup[y] + dc_destorg; + +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); +#endif for (; y < y2; ++y) { @@ -1771,7 +2582,11 @@ static void R_DrawFogBoundarySection (int y, int y2, int x1) int x = x1; do { +#ifndef PALETTEOUTPUT + dest[x] = shade_pal_index(colormap[dest[x]], light); +#else dest[x] = colormap[dest[x]]; +#endif } while (++x <= x2); dest += dc_pitch; } @@ -1781,10 +2596,19 @@ static void R_DrawFogBoundaryLine (int y, int x) { int x2 = spanend[y]; BYTE *colormap = dc_colormap; - BYTE *dest = ylookup[y] + dc_destorg; + canvas_pixel_t *dest = ylookup[y] + dc_destorg; + +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); +#endif + do { +#ifndef PALETTEOUTPUT + dest[x] = shade_pal_index(colormap[dest[x]], light); +#else dest[x] = colormap[dest[x]]; +#endif } while (++x <= x2); } @@ -1809,6 +2633,7 @@ void R_DrawFogBoundary (int x1, int x2, short *uclip, short *dclip) } dc_colormap = basecolormapdata + (rcolormap << COLORMAPSHIFT); + dc_light = 0; for (--x; x >= x1; --x) { @@ -1834,6 +2659,7 @@ void R_DrawFogBoundary (int x1, int x2, short *uclip, short *dclip) } rcolormap = lcolormap; dc_colormap = basecolormapdata + (lcolormap << COLORMAPSHIFT); + dc_light = 0; } else { @@ -1891,15 +2717,37 @@ fixed_t tmvline1_add () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - BYTE *dest = dc_dest; + canvas_pixel_t *dest = dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; + uint32_t light = calc_light_multiplier(dc_light); + do { +#ifndef PALETTEOUTPUT + BYTE pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t fg = shade_pal_index(colormap[pix], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + } +#else BYTE pix = source[frac>>bits]; if (pix != 0) { @@ -1908,6 +2756,7 @@ fixed_t tmvline1_add () fg = (fg+bg) | 0x1f07c1f; *dest = RGB32k.All[fg & (fg>>15)]; } +#endif frac += fracstep; dest += pitch; } while (--count); @@ -1917,13 +2766,19 @@ fixed_t tmvline1_add () void tmvline4_add () { - BYTE *dest = dc_dest; + canvas_pixel_t *dest = dc_dest; int count = dc_count; int bits = tmvlinebits; DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; + uint32_t light[4]; + light[0] = calc_light_multiplier(palookuplight[0]); + light[1] = calc_light_multiplier(palookuplight[1]); + light[2] = calc_light_multiplier(palookuplight[2]); + light[3] = calc_light_multiplier(palookuplight[3]); + do { for (int i = 0; i < 4; ++i) @@ -1931,10 +2786,27 @@ void tmvline4_add () BYTE pix = bufplce[i][vplce[i] >> bits]; if (pix != 0) { +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(palookupoffse[i][pix], light[i]); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; +#else DWORD fg = fg2rgb[palookupoffse[i][pix]]; DWORD bg = bg2rgb[dest[i]]; fg = (fg+bg) | 0x1f07c1f; dest[i] = RGB32k.All[fg & (fg>>15)]; +#endif } vplce[i] += vince[i]; } @@ -1949,18 +2821,36 @@ fixed_t tmvline1_addclamp () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - BYTE *dest = dc_dest; + canvas_pixel_t *dest = dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; + uint32_t light = calc_light_multiplier(dc_light); + do { BYTE pix = source[frac>>bits]; if (pix != 0) { +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(colormap[pix], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; +#else DWORD a = fg2rgb[colormap[pix]] + bg2rgb[*dest]; DWORD b = a; @@ -1970,6 +2860,7 @@ fixed_t tmvline1_addclamp () b = b - (b >> 5); a |= b; *dest = RGB32k.All[a & (a>>15)]; +#endif } frac += fracstep; dest += pitch; @@ -1980,13 +2871,19 @@ fixed_t tmvline1_addclamp () void tmvline4_addclamp () { - BYTE *dest = dc_dest; + canvas_pixel_t *dest = dc_dest; int count = dc_count; int bits = tmvlinebits; DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; + uint32_t light[4]; + light[0] = calc_light_multiplier(palookuplight[0]); + light[1] = calc_light_multiplier(palookuplight[1]); + light[2] = calc_light_multiplier(palookuplight[2]); + light[3] = calc_light_multiplier(palookuplight[3]); + do { for (int i = 0; i < 4; ++i) @@ -1994,6 +2891,22 @@ void tmvline4_addclamp () BYTE pix = bufplce[i][vplce[i] >> bits]; if (pix != 0) { +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(palookupoffse[i][pix], light[i]); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; +#else DWORD a = fg2rgb[palookupoffse[i][pix]] + bg2rgb[dest[i]]; DWORD b = a; @@ -2003,6 +2916,7 @@ void tmvline4_addclamp () b = b - (b >> 5); a |= b; dest[i] = RGB32k.All[a & (a>>15)]; +#endif } vplce[i] += vince[i]; } @@ -2017,18 +2931,36 @@ fixed_t tmvline1_subclamp () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - BYTE *dest = dc_dest; + canvas_pixel_t *dest = dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; + uint32_t light = calc_light_multiplier(dc_light); + do { BYTE pix = source[frac>>bits]; if (pix != 0) { +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(colormap[pix], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; +#else DWORD a = (fg2rgb[colormap[pix]] | 0x40100400) - bg2rgb[*dest]; DWORD b = a; @@ -2037,6 +2969,7 @@ fixed_t tmvline1_subclamp () a &= b; a |= 0x01f07c1f; *dest = RGB32k.All[a & (a>>15)]; +#endif } frac += fracstep; dest += pitch; @@ -2047,13 +2980,19 @@ fixed_t tmvline1_subclamp () void tmvline4_subclamp () { - BYTE *dest = dc_dest; + canvas_pixel_t *dest = dc_dest; int count = dc_count; int bits = tmvlinebits; DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; + uint32_t light[4]; + light[0] = calc_light_multiplier(palookuplight[0]); + light[1] = calc_light_multiplier(palookuplight[1]); + light[2] = calc_light_multiplier(palookuplight[2]); + light[3] = calc_light_multiplier(palookuplight[3]); + do { for (int i = 0; i < 4; ++i) @@ -2061,6 +3000,22 @@ void tmvline4_subclamp () BYTE pix = bufplce[i][vplce[i] >> bits]; if (pix != 0) { +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(palookupoffse[i][pix], light[i]); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; +#else DWORD a = (fg2rgb[palookupoffse[i][pix]] | 0x40100400) - bg2rgb[dest[i]]; DWORD b = a; @@ -2069,6 +3024,7 @@ void tmvline4_subclamp () a &= b; a |= 0x01f07c1f; dest[i] = RGB32k.All[a & (a>>15)]; +#endif } vplce[i] += vince[i]; } @@ -2083,18 +3039,36 @@ fixed_t tmvline1_revsubclamp () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - BYTE *dest = dc_dest; + canvas_pixel_t *dest = dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; + uint32_t light = calc_light_multiplier(dc_light); + do { BYTE pix = source[frac>>bits]; if (pix != 0) { +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(colormap[pix], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; +#else DWORD a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[pix]]; DWORD b = a; @@ -2103,6 +3077,7 @@ fixed_t tmvline1_revsubclamp () a &= b; a |= 0x01f07c1f; *dest = RGB32k.All[a & (a>>15)]; +#endif } frac += fracstep; dest += pitch; @@ -2113,13 +3088,19 @@ fixed_t tmvline1_revsubclamp () void tmvline4_revsubclamp () { - BYTE *dest = dc_dest; + canvas_pixel_t *dest = dc_dest; int count = dc_count; int bits = tmvlinebits; DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; + uint32_t light[4]; + light[0] = calc_light_multiplier(palookuplight[0]); + light[1] = calc_light_multiplier(palookuplight[1]); + light[2] = calc_light_multiplier(palookuplight[2]); + light[3] = calc_light_multiplier(palookuplight[3]); + do { for (int i = 0; i < 4; ++i) @@ -2127,6 +3108,22 @@ void tmvline4_revsubclamp () BYTE pix = bufplce[i][vplce[i] >> bits]; if (pix != 0) { +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(palookupoffse[i][pix], light[i]); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; +#else DWORD a = (bg2rgb[dest[i]] | 0x40100400) - fg2rgb[palookupoffse[i][pix]]; DWORD b = a; @@ -2135,6 +3132,7 @@ void tmvline4_revsubclamp () a &= b; a |= 0x01f07c1f; dest[i] = RGB32k.All[a & (a>>15)]; +#endif } vplce[i] += vince[i]; } @@ -2418,6 +3416,7 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, { dc_colormap += fixedlightlev; } + dc_light = 0; return r_columnmethod ? DoDraw1 : DoDraw0; } @@ -2443,6 +3442,7 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, dc_srccolor = ((((r*x)>>4)<<20) | ((g*x)>>4) | ((((b)*x)>>4)<<10)) & 0x3feffbff; hcolfunc_pre = R_FillColumnHorizP; dc_colormap = identitymap; + dc_light = 0; } if (!R_SetBlendFunc (style.BlendOp, fglevel, bglevel, style.Flags)) diff --git a/src/r_draw.h b/src/r_draw.h index cb2f68f33..6f7a91154 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -30,6 +30,7 @@ extern "C" int ylookup[MAXHEIGHT]; extern "C" int dc_pitch; // [RH] Distance between rows extern "C" lighttable_t*dc_colormap; +extern "C" fixed_t dc_light; extern "C" int dc_x; extern "C" int dc_yl; extern "C" int dc_yh; @@ -44,16 +45,17 @@ extern "C" DWORD *dc_destblend; // first pixel in a column extern "C" const BYTE* dc_source; -extern "C" BYTE *dc_dest, *dc_destorg; +extern "C" canvas_pixel_t *dc_dest, *dc_destorg; extern "C" int dc_count; extern "C" DWORD vplce[4]; extern "C" DWORD vince[4]; extern "C" BYTE* palookupoffse[4]; +extern "C" fixed_t palookuplight[4]; extern "C" const BYTE* bufplce[4]; // [RH] Temporary buffer for column drawing -extern "C" BYTE *dc_temp; +extern "C" canvas_pixel_t *dc_temp; extern "C" unsigned int dc_tspans[4][MAXHEIGHT]; extern "C" unsigned int *dc_ctspan[4]; extern "C" unsigned int horizspans[4]; @@ -184,7 +186,7 @@ extern void (*rt_map4cols)(int sx, int yl, int yh); void rt_draw4cols (int sx); // [RH] Preps the temporary horizontal buffer. -void rt_initcols (BYTE *buffer=NULL); +void rt_initcols (canvas_pixel_t *buffer=NULL); void R_DrawFogBoundary (int x1, int x2, short *uclip, short *dclip); @@ -231,13 +233,15 @@ void R_FillSpan (void); #endif extern "C" void R_SetupDrawSlab(const BYTE *colormap); -extern "C" void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); +extern "C" void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, canvas_pixel_t *p); extern "C" int ds_y; extern "C" int ds_x1; extern "C" int ds_x2; extern "C" lighttable_t* ds_colormap; +//extern "C" dsfixed_t ds_light; +#define ds_light dc_light extern "C" dsfixed_t ds_xfrac; extern "C" dsfixed_t ds_yfrac; diff --git a/src/r_drawt.cpp b/src/r_drawt.cpp index e8faff0ce..f5fc027b5 100644 --- a/src/r_drawt.cpp +++ b/src/r_drawt.cpp @@ -57,8 +57,8 @@ // dc_ctspan is advanced while drawing into dc_temp. // horizspan is advanced up to dc_ctspan when drawing from dc_temp to the screen. -BYTE dc_tempbuff[MAXHEIGHT*4]; -BYTE *dc_temp; +canvas_pixel_t dc_tempbuff[MAXHEIGHT*4]; +canvas_pixel_t *dc_temp; unsigned int dc_tspans[4][MAXHEIGHT]; unsigned int *dc_ctspan[4]; unsigned int *horizspan[4]; @@ -73,8 +73,8 @@ extern "C" void R_SetupAddClampCol(); // Copies one span at hx to the screen at sx. void rt_copy1col_c (int hx, int sx, int yl, int yh) { - BYTE *source; - BYTE *dest; + canvas_pixel_t *source; + canvas_pixel_t *dest; int count; int pitch; @@ -114,6 +114,13 @@ void rt_copy1col_c (int hx, int sx, int yl, int yh) // Copies all four spans to the screen starting at sx. void rt_copy4cols_c (int sx, int yl, int yh) { +#ifndef PALETTEOUTPUT + // To do: we could do this with SSE using __m128i + rt_copy1col_c(0, sx, yl, yh); + rt_copy1col_c(1, sx + 1, yl, yh); + rt_copy1col_c(2, sx + 2, yl, yh); + rt_copy1col_c(3, sx + 3, yl, yh); +#else int *source; int *dest; int count; @@ -142,14 +149,15 @@ void rt_copy4cols_c (int sx, int yl, int yh) source += 8/sizeof(int); dest += pitch*2; } while (--count); +#endif } // Maps one span at hx to the screen at sx. void rt_map1col_c (int hx, int sx, int yl, int yh) { BYTE *colormap; - BYTE *source; - BYTE *dest; + canvas_pixel_t *source; + canvas_pixel_t *dest; int count; int pitch; @@ -158,13 +166,21 @@ void rt_map1col_c (int hx, int sx, int yl, int yh) return; count++; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); +#endif + colormap = dc_colormap; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4 + hx]; pitch = dc_pitch; if (count & 1) { +#ifndef PALETTEOUTPUT + *dest = shade_pal_index(colormap[*source], light); +#else *dest = colormap[*source]; +#endif source += 4; dest += pitch; } @@ -172,8 +188,13 @@ void rt_map1col_c (int hx, int sx, int yl, int yh) return; do { +#ifndef PALETTEOUTPUT + dest[0] = shade_pal_index(colormap[source[0]], light); + dest[pitch] = shade_pal_index(colormap[source[4]], light); +#else dest[0] = colormap[source[0]]; dest[pitch] = colormap[source[4]]; +#endif source += 8; dest += pitch*2; } while (--count); @@ -183,8 +204,8 @@ void rt_map1col_c (int hx, int sx, int yl, int yh) void rt_map4cols_c (int sx, int yl, int yh) { BYTE *colormap; - BYTE *source; - BYTE *dest; + canvas_pixel_t *source; + canvas_pixel_t *dest; int count; int pitch; @@ -193,16 +214,27 @@ void rt_map4cols_c (int sx, int yl, int yh) return; count++; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); +#endif + colormap = dc_colormap; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4]; pitch = dc_pitch; if (count & 1) { +#ifndef PALETTEOUTPUT + dest[0] = shade_pal_index(colormap[source[0]], light); + dest[1] = shade_pal_index(colormap[source[1]], light); + dest[2] = shade_pal_index(colormap[source[2]], light); + dest[3] = shade_pal_index(colormap[source[3]], light); +#else dest[0] = colormap[source[0]]; dest[1] = colormap[source[1]]; dest[2] = colormap[source[2]]; dest[3] = colormap[source[3]]; +#endif source += 4; dest += pitch; } @@ -210,6 +242,16 @@ void rt_map4cols_c (int sx, int yl, int yh) return; do { +#ifndef PALETTEOUTPUT + dest[0] = shade_pal_index(colormap[source[0]], light); + dest[1] = shade_pal_index(colormap[source[1]], light); + dest[2] = shade_pal_index(colormap[source[2]], light); + dest[3] = shade_pal_index(colormap[source[3]], light); + dest[pitch] = shade_pal_index(colormap[source[4]], light); + dest[pitch + 1] = shade_pal_index(colormap[source[5]], light); + dest[pitch + 2] = shade_pal_index(colormap[source[6]], light); + dest[pitch + 3] = shade_pal_index(colormap[source[7]], light); +#else dest[0] = colormap[source[0]]; dest[1] = colormap[source[1]]; dest[2] = colormap[source[2]]; @@ -218,6 +260,7 @@ void rt_map4cols_c (int sx, int yl, int yh) dest[pitch+1] = colormap[source[5]]; dest[pitch+2] = colormap[source[6]]; dest[pitch+3] = colormap[source[7]]; +#endif source += 8; dest += pitch*2; } while (--count); @@ -227,7 +270,7 @@ void rt_map4cols_c (int sx, int yl, int yh) void rt_Translate1col(const BYTE *translation, int hx, int yl, int yh) { int count = yh - yl + 1; - BYTE *source = &dc_temp[yl*4 + hx]; + canvas_pixel_t *source = &dc_temp[yl*4 + hx]; // Things we do to hit the compiler's optimizer with a clue bat: // 1. Parallelism is explicitly spelled out by using a separate @@ -274,7 +317,7 @@ void rt_Translate1col(const BYTE *translation, int hx, int yl, int yh) void rt_Translate4cols(const BYTE *translation, int yl, int yh) { int count = yh - yl + 1; - BYTE *source = &dc_temp[yl*4]; + canvas_pixel_t *source = &dc_temp[yl*4]; int c0, c1; BYTE b0, b1; @@ -330,8 +373,8 @@ void rt_tlate4cols (int sx, int yl, int yh) void rt_add1col (int hx, int sx, int yl, int yh) { BYTE *colormap; - BYTE *source; - BYTE *dest; + canvas_pixel_t *source; + canvas_pixel_t *dest; int count; int pitch; @@ -340,13 +383,36 @@ void rt_add1col (int hx, int sx, int yl, int yh) return; count++; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4 + hx]; pitch = dc_pitch; colormap = dc_colormap; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); + + do { + uint32_t fg = shade_pal_index(colormap[*source], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + + source += 4; + dest += pitch; + } while (--count); +#else + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; do { DWORD fg = colormap[*source]; DWORD bg = *dest; @@ -358,14 +424,15 @@ void rt_add1col (int hx, int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); +#endif } // Adds all four spans to the screen starting at sx without clamping. void rt_add4cols_c (int sx, int yl, int yh) { BYTE *colormap; - BYTE *source; - BYTE *dest; + canvas_pixel_t *source; + canvas_pixel_t *dest; int count; int pitch; @@ -374,13 +441,40 @@ void rt_add4cols_c (int sx, int yl, int yh) return; count++; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4]; pitch = dc_pitch; colormap = dc_colormap; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); + + do { + for (int i = 0; i < 4; i++) + { + uint32_t fg = shade_pal_index(colormap[source[i]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + + source += 4; + dest += pitch; + } while (--count); +#else + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + do { DWORD fg = colormap[source[0]]; DWORD bg = dest[0]; @@ -414,6 +508,7 @@ void rt_add4cols_c (int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); +#endif } // Translates and adds one span at hx to the screen at sx without clamping. @@ -433,10 +528,9 @@ void rt_tlateadd4cols (int sx, int yl, int yh) // Shades one span at hx to the screen at sx. void rt_shaded1col (int hx, int sx, int yl, int yh) { - DWORD *fgstart; BYTE *colormap; - BYTE *source; - BYTE *dest; + canvas_pixel_t *source; + canvas_pixel_t *dest; int count; int pitch; @@ -445,12 +539,37 @@ void rt_shaded1col (int hx, int sx, int yl, int yh) return; count++; - fgstart = &Col2RGB8[0][dc_color]; colormap = dc_colormap; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4 + hx]; pitch = dc_pitch; +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + do { + uint32_t alpha = colormap[*source]; + uint32_t inv_alpha = 64 - alpha; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; + uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; + uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + source += 4; + dest += pitch; + } while (--count); +#else + DWORD *fgstart; + fgstart = &Col2RGB8[0][dc_color]; + do { DWORD val = colormap[*source]; DWORD fg = fgstart[val<<8]; @@ -459,15 +578,15 @@ void rt_shaded1col (int hx, int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); +#endif } // Shades all four spans to the screen starting at sx. void rt_shaded4cols_c (int sx, int yl, int yh) { - DWORD *fgstart; BYTE *colormap; - BYTE *source; - BYTE *dest; + canvas_pixel_t *source; + canvas_pixel_t *dest; int count; int pitch; @@ -476,12 +595,40 @@ void rt_shaded4cols_c (int sx, int yl, int yh) return; count++; - fgstart = &Col2RGB8[0][dc_color]; colormap = dc_colormap; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4]; pitch = dc_pitch; +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + do { + for (int i = 0; i < 4; i++) + { + uint32_t alpha = colormap[source[i]]; + uint32_t inv_alpha = 64 - alpha; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; + uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; + uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + source += 4; + dest += pitch; + } while (--count); +#else + DWORD *fgstart; + fgstart = &Col2RGB8[0][dc_color]; + do { DWORD val; @@ -504,14 +651,15 @@ void rt_shaded4cols_c (int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); +#endif } // Adds one span at hx to the screen at sx with clamping. void rt_addclamp1col (int hx, int sx, int yl, int yh) { BYTE *colormap; - BYTE *source; - BYTE *dest; + canvas_pixel_t *source; + canvas_pixel_t *dest; int count; int pitch; @@ -520,13 +668,36 @@ void rt_addclamp1col (int hx, int sx, int yl, int yh) return; count++; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4 + hx]; pitch = dc_pitch; colormap = dc_colormap; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); + + do { + uint32_t fg = shade_pal_index(colormap[*source], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + source += 4; + dest += pitch; + } while (--count); +#else + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + do { DWORD a = fg2rgb[colormap[*source]] + bg2rgb[*dest]; DWORD b = a; @@ -540,14 +711,15 @@ void rt_addclamp1col (int hx, int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); +#endif } // Adds all four spans to the screen starting at sx with clamping. void rt_addclamp4cols_c (int sx, int yl, int yh) { BYTE *colormap; - BYTE *source; - BYTE *dest; + canvas_pixel_t *source; + canvas_pixel_t *dest; int count; int pitch; @@ -556,13 +728,39 @@ void rt_addclamp4cols_c (int sx, int yl, int yh) return; count++; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4]; pitch = dc_pitch; colormap = dc_colormap; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); + + do { + for (int i = 0; i < 4; i++) + { + uint32_t fg = shade_pal_index(colormap[source[i]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + source += 4; + dest += pitch; + } while (--count); +#else + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + do { DWORD a = fg2rgb[colormap[source[0]]] + bg2rgb[dest[0]]; DWORD b = a; @@ -604,6 +802,7 @@ void rt_addclamp4cols_c (int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); +#endif } // Translates and adds one span at hx to the screen at sx with clamping. @@ -624,8 +823,8 @@ void rt_tlateaddclamp4cols (int sx, int yl, int yh) void rt_subclamp1col (int hx, int sx, int yl, int yh) { BYTE *colormap; - BYTE *source; - BYTE *dest; + canvas_pixel_t *source; + canvas_pixel_t *dest; int count; int pitch; @@ -634,13 +833,35 @@ void rt_subclamp1col (int hx, int sx, int yl, int yh) return; count++; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4 + hx]; pitch = dc_pitch; colormap = dc_colormap; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); + + do { + uint32_t fg = shade_pal_index(colormap[*source], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + source += 4; + dest += pitch; + } while (--count); +#else + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; do { DWORD a = (fg2rgb[colormap[*source]] | 0x40100400) - bg2rgb[*dest]; DWORD b = a; @@ -653,14 +874,15 @@ void rt_subclamp1col (int hx, int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); +#endif } // Subtracts all four spans to the screen starting at sx with clamping. void rt_subclamp4cols (int sx, int yl, int yh) { BYTE *colormap; - BYTE *source; - BYTE *dest; + canvas_pixel_t *source; + canvas_pixel_t *dest; int count; int pitch; @@ -669,13 +891,39 @@ void rt_subclamp4cols (int sx, int yl, int yh) return; count++; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4]; pitch = dc_pitch; colormap = dc_colormap; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); + + do { + for (int i = 0; i < 4; i++) + { + uint32_t fg = shade_pal_index(colormap[source[i]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + + source += 4; + dest += pitch; + } while (--count); +#else + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; do { DWORD a = (fg2rgb[colormap[source[0]]] | 0x40100400) - bg2rgb[dest[0]]; DWORD b = a; @@ -713,6 +961,7 @@ void rt_subclamp4cols (int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); +#endif } // Translates and subtracts one span at hx to the screen at sx with clamping. @@ -733,8 +982,8 @@ void rt_tlatesubclamp4cols (int sx, int yl, int yh) void rt_revsubclamp1col (int hx, int sx, int yl, int yh) { BYTE *colormap; - BYTE *source; - BYTE *dest; + canvas_pixel_t *source; + canvas_pixel_t *dest; int count; int pitch; @@ -750,6 +999,28 @@ void rt_revsubclamp1col (int hx, int sx, int yl, int yh) pitch = dc_pitch; colormap = dc_colormap; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); + + do { + uint32_t fg = shade_pal_index(colormap[*source], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + source += 4; + dest += pitch; + } while (--count); +#else do { DWORD a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[*source]]; DWORD b = a; @@ -762,14 +1033,15 @@ void rt_revsubclamp1col (int hx, int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); +#endif } // Subtracts all four spans from the screen starting at sx with clamping. void rt_revsubclamp4cols (int sx, int yl, int yh) { BYTE *colormap; - BYTE *source; - BYTE *dest; + canvas_pixel_t *source; + canvas_pixel_t *dest; int count; int pitch; @@ -785,6 +1057,32 @@ void rt_revsubclamp4cols (int sx, int yl, int yh) pitch = dc_pitch; colormap = dc_colormap; +#ifndef PALETTEOUTPUT + uint32_t light = calc_light_multiplier(dc_light); + + do { + for (int i = 0; i < 4; i++) + { + uint32_t fg = shade_pal_index(colormap[source[i]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + + source += 4; + dest += pitch; + } while (--count); +#else do { DWORD a = (bg2rgb[dest[0]] | 0x40100400) - fg2rgb[colormap[source[0]]]; DWORD b = a; @@ -822,6 +1120,7 @@ void rt_revsubclamp4cols (int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); +#endif } // Translates and subtracts one span at hx from the screen at sx with clamping. @@ -1002,7 +1301,7 @@ void rt_draw4cols (int sx) // Before each pass through a rendering loop that uses these routines, // call this function to set up the span pointers. -void rt_initcols (BYTE *buff) +void rt_initcols (canvas_pixel_t *buff) { int y; @@ -1016,7 +1315,7 @@ void rt_initcols (BYTE *buff) void R_DrawColumnHorizP_C (void) { int count = dc_count; - BYTE *dest; + canvas_pixel_t *dest; fixed_t fracstep; fixed_t frac; @@ -1077,7 +1376,7 @@ void R_FillColumnHorizP (void) { int count = dc_count; BYTE color = dc_color; - BYTE *dest; + canvas_pixel_t *dest; if (count <= 0) return; diff --git a/src/r_main.cpp b/src/r_main.cpp index ce4841a2e..04e798981 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -578,7 +578,7 @@ void R_HighlightPortal (PortalDrawseg* pds) BYTE color = (BYTE)BestColor((DWORD *)GPalette.BaseColors, 255, 0, 0, 0, 255); - BYTE* pixels = RenderTarget->GetBuffer(); + canvas_pixel_t* pixels = RenderTarget->GetBuffer(); // top edge for (int x = pds->x1; x < pds->x2; x++) { @@ -623,7 +623,7 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) int Ytop = pds->ceilingclip[x-pds->x1]; int Ybottom = pds->floorclip[x-pds->x1]; - BYTE *dest = RenderTarget->GetBuffer() + x + Ytop * spacing; + canvas_pixel_t *dest = RenderTarget->GetBuffer() + x + Ytop * spacing; for (int y = Ytop; y <= Ybottom; y++) { @@ -794,10 +794,10 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) void R_SetupBuffer () { - static BYTE *lastbuff = NULL; + static canvas_pixel_t *lastbuff = NULL; int pitch = RenderTarget->GetPitch(); - BYTE *lineptr = RenderTarget->GetBuffer() + viewwindowy*pitch + viewwindowx; + canvas_pixel_t *lineptr = RenderTarget->GetBuffer() + viewwindowy*pitch + viewwindowx; if (dc_pitch != pitch || lineptr != lastbuff) { diff --git a/src/r_main.h b/src/r_main.h index 24103393d..37a41a763 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -82,6 +82,34 @@ extern bool r_dontmaplines; // Change R_CalcTiltedLighting() when this changes. #define GETPALOOKUP(vis,shade) (clamp (((shade)-FLOAT2FIXED(MIN(MAXLIGHTVIS,double(vis))))>>FRACBITS, 0, NUMCOLORMAPS-1)) +// Calculate the light multiplier for ds_light +// This is used instead of GETPALOOKUP when ds_colormap+dc_colormap is set to the base colormap +#define LIGHTSCALE(vis,shade) ((shade)-FLOAT2FIXED(MIN(MAXLIGHTVIS,double(vis)))) + +#ifndef PALETTEOUTPUT + +// calculates the light constant passed to the shade_pal_index function +inline uint32_t calc_light_multiplier(dsfixed_t light) +{ + // the 0.70 multiplier shouldn't be needed - maybe the palette shades in doom weren't linear? + return (uint32_t)clamp((1.0 - FIXED2DBL(light) / MAXLIGHTVIS * 0.70) * 256 + 0.5, 0.0, 256.0); +} + +// Calculates a ARGB8 color for the given palette index and light multiplier +inline uint32_t shade_pal_index(uint32_t index, uint32_t light) +{ + const PalEntry &color = GPalette.BaseColors[index]; + uint32_t red = color.r; + uint32_t green = color.g; + uint32_t blue = color.b; + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; + return 0xff000000 | (red << 16) | (green << 8) | blue; +} + +#endif + extern double GlobVis; void R_SetVisibility(double visibility); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index d749319e3..b385302e5 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -227,8 +227,14 @@ void R_MapPlane (int y, int x1) if (plane_shade) { // Determine lighting based on the span's distance from the viewer. +#ifndef PALETTEOUTPUT + ds_colormap = basecolormap->Maps; + ds_light = LIGHTSCALE(GlobVis * fabs(CenterY - y), planeshade); +#else ds_colormap = basecolormap->Maps + (GETPALOOKUP ( GlobVis * fabs(CenterY - y), planeshade) << COLORMAPSHIFT); + ds_light = 0; +#endif } #ifdef X86_ASM @@ -360,7 +366,7 @@ void R_MapTiltedPlane (int y, int x1) int x2 = spanend[y]; int width = x2 - x1; double iz, uz, vz; - BYTE *fb; + canvas_pixel_t *fb; DWORD u, v; int i; @@ -393,6 +399,7 @@ void R_MapTiltedPlane (int y, int x1) u = SQWORD(uz*z) + pviewx; v = SQWORD(vz*z) + pviewy; ds_colormap = tiltlighting[i]; + ds_light = 0; fb[i++] = ds_colormap[ds_source[(v >> vshift) | ((u >> ushift) & umask)]]; iz += plane_sz[0]; uz += plane_su[0]; @@ -486,7 +493,16 @@ void R_MapTiltedPlane (int y, int x1) void R_MapColoredPlane (int y, int x1) { - memset (ylookup[y] + x1 + dc_destorg, ds_color, spanend[y] - x1 + 1); +#ifndef PALETTEOUTPUT + canvas_pixel_t *dest = ylookup[y] + x1 + dc_destorg; + int count = (spanend[y] - x1 + 1); + uint32_t light = calc_light_multiplier(ds_light); + uint32_t color = shade_pal_index(ds_color, light); + for (int i = 0; i < count; i++) + dest[i] = color; +#else + memset (ylookup[y] + x1 + dc_destorg, ds_color, (spanend[y] - x1 + 1) * sizeof(canvas_pixel_t)); +#endif } //========================================================================== @@ -1462,11 +1478,13 @@ void R_DrawSkyPlane (visplane_t *pl) if (fixedcolormap) { dc_colormap = fixedcolormap; + dc_light = 0; } else { fakefixed = true; fixedcolormap = dc_colormap = NormalLight.Maps; + dc_light = 0; } R_DrawSky (pl); @@ -1547,6 +1565,7 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t planeheight = fabs(pl->height.Zat0() - ViewPos.Z); GlobVis = r_FloorVisibility / planeheight; + ds_light = 0; if (fixedlightlev >= 0) ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false; else if (fixedcolormap) @@ -1707,6 +1726,7 @@ void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t if (pl->height.fC() > 0) planelightfloat = -planelightfloat; + ds_light = 0; if (fixedlightlev >= 0) ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false; else if (fixedcolormap) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 4eb3cb440..1cdb78555 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -178,6 +178,7 @@ static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FText if (fixedcolormap == NULL && fixedlightlev < 0) { dc_colormap = basecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + dc_light = 0; } dc_iscale = xs_Fix<16>::ToFix(MaskedSWall[dc_x] * MaskedScaleY); @@ -316,6 +317,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) dc_colormap = basecolormap->Maps + fixedlightlev; else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; + dc_light = 0; // find positioning texheight = tex->GetScaledHeightDouble(); @@ -633,6 +635,7 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) dc_colormap = basecolormap->Maps + fixedlightlev; else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; + dc_light = 0; WallC.sz1 = ds->sz1; WallC.sz2 = ds->sz2; @@ -1066,10 +1069,11 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2) } // prevlineasm1 is like vlineasm1 but skips the loop if only drawing one pixel -inline fixed_t prevline1 (fixed_t vince, BYTE *colormap, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest) +inline fixed_t prevline1 (fixed_t vince, BYTE *colormap, fixed_t light, int count, fixed_t vplce, const BYTE *bufplce, canvas_pixel_t *dest) { dc_iscale = vince; dc_colormap = colormap; + dc_light = light; dc_count = count; dc_texturefrac = vplce; dc_source = bufplce; @@ -1117,6 +1121,10 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l palookupoffse[1] = dc_colormap; palookupoffse[2] = dc_colormap; palookupoffse[3] = dc_colormap; + palookuplight[0] = 0; + palookuplight[1] = 0; + palookuplight[2] = 0; + palookuplight[3] = 0; } for(; (x < x2) && (x & 3); ++x) @@ -1130,7 +1138,13 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l if (!fixed) { // calculate lighting +#ifndef PALETTEOUTPUT + dc_colormap = basecolormapdata; + dc_light = LIGHTSCALE(light, wallshade); +#else dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); + dc_light = 0; +#endif } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1170,7 +1184,13 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l for (z = 0; z < 4; ++z) { light += rw_lightstep; - palookupoffse[z] = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); +#ifndef PALETTEOUTPUT + palookupoffse[z] = basecolormapdata; + palookuplight[z] = LIGHTSCALE(light, wallshade); +#else + palookupoffse[z] = basecolormapdata + (GETPALOOKUP(12/*light*/, wallshade) << COLORMAPSHIFT); + palookuplight[z] = 0; +#endif } } @@ -1183,7 +1203,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l { if (!(bad & 1)) { - prevline1(vince[z],palookupoffse[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+x+z+dc_destorg); + prevline1(vince[z],palookupoffse[z],palookuplight[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+x+z+dc_destorg); } bad >>= 1; } @@ -1194,7 +1214,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l { if (u4 > y1ve[z]) { - vplce[z] = prevline1(vince[z],palookupoffse[z],u4-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+x+z+dc_destorg); + vplce[z] = prevline1(vince[z],palookupoffse[z], palookuplight[z],u4-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+x+z+dc_destorg); } } @@ -1205,12 +1225,12 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l dovline4(); } - BYTE *i = x+ylookup[d4]+dc_destorg; + canvas_pixel_t *i = x+ylookup[d4]+dc_destorg; for (z = 0; z < 4; ++z) { if (y2ve[z] > d4) { - prevline1(vince[z],palookupoffse[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z); + prevline1(vince[z],palookupoffse[0],palookuplight[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z); } } } @@ -1225,7 +1245,13 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l if (!fixed) { // calculate lighting +#ifndef PALETTEOUTPUT + dc_colormap = basecolormapdata; + dc_light = LIGHTSCALE(light, wallshade); +#else dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); + dc_light = 0; +#endif } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1416,10 +1442,11 @@ static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *d } } -inline fixed_t mvline1 (fixed_t vince, BYTE *colormap, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest) +inline fixed_t mvline1 (fixed_t vince, BYTE *colormap, int count, fixed_t vplce, const BYTE *bufplce, canvas_pixel_t *dest) { dc_iscale = vince; dc_colormap = colormap; + dc_light = 0; dc_count = count; dc_texturefrac = vplce; dc_source = bufplce; @@ -1431,7 +1458,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) { int x, fracbits; - BYTE *p; + canvas_pixel_t *p; int y1ve[4], y2ve[4], u4, d4, startx, dax, z; char bad; float light = rw_light - rw_lightstep; @@ -1471,7 +1498,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ palookupoffse[3] = dc_colormap; } - for(; (x < x2) && ((size_t)p & 3); ++x, ++p) + for(; (x < x2) && (((size_t)p/sizeof(canvas_pixel_t)) & 3); ++x, ++p) { light += rw_lightstep; y1ve[0] = uwal[x];//max(uwal[x],umost[x]); @@ -1481,6 +1508,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ if (!fixed) { // calculate lighting dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); + dc_light = 0; } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1553,7 +1581,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ domvline4(); } - BYTE *i = p+ylookup[d4]; + canvas_pixel_t *i = p+ylookup[d4]; for (z = 0; z < 4; ++z) { if (y2ve[z] > d4) @@ -1572,6 +1600,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ if (!fixed) { // calculate lighting dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); + dc_light = 0; } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1589,10 +1618,11 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ NetUpdate (); } -inline void preptmvline1 (fixed_t vince, BYTE *colormap, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest) +inline void preptmvline1 (fixed_t vince, BYTE *colormap, fixed_t light, int count, fixed_t vplce, const BYTE *bufplce, canvas_pixel_t *dest) { dc_iscale = vince; dc_colormap = colormap; + dc_light = light; dc_count = count; dc_texturefrac = vplce; dc_source = bufplce; @@ -1605,7 +1635,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f fixed_t (*tmvline1)(); void (*tmvline4)(); int x, fracbits; - BYTE *p; + canvas_pixel_t *p; int y1ve[4], y2ve[4], u4, d4, startx, dax, z; char bad; float light = rw_light - rw_lightstep; @@ -1645,9 +1675,13 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f palookupoffse[1] = dc_colormap; palookupoffse[2] = dc_colormap; palookupoffse[3] = dc_colormap; + palookuplight[0] = 0; + palookuplight[1] = 0; + palookuplight[2] = 0; + palookuplight[3] = 0; } - for(; (x < x2) && ((size_t)p & 3); ++x, ++p) + for(; (x < x2) && (((size_t)p / sizeof(canvas_pixel_t)) & 3); ++x, ++p) { light += rw_lightstep; y1ve[0] = uwal[x];//max(uwal[x],umost[x]); @@ -1656,7 +1690,13 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f if (!fixed) { // calculate lighting +#ifndef PALETTEOUTPUT + dc_colormap = basecolormapdata; + dc_light = LIGHTSCALE(light, wallshade); +#else dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); + dc_light = 0; +#endif } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1694,7 +1734,12 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f for (z = 0; z < 4; ++z) { light += rw_lightstep; +#ifndef PALETTEOUTPUT + palookupoffse[z] = basecolormapdata; + palookuplight[z] = LIGHTSCALE(light, wallshade); +#else palookupoffse[z] = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); +#endif } } @@ -1707,7 +1752,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f { if (!(bad & 1)) { - preptmvline1(vince[z],palookupoffse[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+p+z); + preptmvline1(vince[z],palookupoffse[z],palookuplight[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+p+z); tmvline1(); } bad >>= 1; @@ -1719,7 +1764,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f { if (u4 > y1ve[z]) { - preptmvline1(vince[z],palookupoffse[z],u4-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+p+z); + preptmvline1(vince[z],palookupoffse[z],palookuplight[z],u4-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+p+z); vplce[z] = tmvline1(); } } @@ -1731,12 +1776,12 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f tmvline4(); } - BYTE *i = p+ylookup[d4]; + canvas_pixel_t *i = p+ylookup[d4]; for (z = 0; z < 4; ++z) { if (y2ve[z] > d4) { - preptmvline1(vince[z],palookupoffse[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z); + preptmvline1(vince[z],palookupoffse[0],palookuplight[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z); tmvline1(); } } @@ -1750,7 +1795,13 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f if (!fixed) { // calculate lighting - dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); +#ifndef PALETTEOUTPUT + dc_colormap = basecolormapdata; + dc_light = LIGHTSCALE(light, wallshade); +#else + dc_colormap = basecolormapdata + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); + dc_light = 0; +#endif } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1791,6 +1842,7 @@ void R_RenderSegLoop () dc_colormap = basecolormap->Maps + fixedlightlev; else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; + dc_light = 0; // clip wall to the floor and ceiling for (x = x1; x < x2; ++x) @@ -3194,6 +3246,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, dc_colormap = usecolormap->Maps; else calclighting = true; + dc_light = 0; // Draw it if (decal->RenderFlags & RF_YFLIP) @@ -3242,7 +3295,13 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting +#ifndef PALETTEOUTPUT + dc_colormap = usecolormap->Maps; + dc_light = LIGHTSCALE(rw_light, wallshade); +#else dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + dc_light = 0; +#endif } R_WallSpriteColumn (R_DrawMaskedColumn); dc_x++; @@ -3252,7 +3311,13 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting +#ifndef PALETTEOUTPUT + dc_colormap = usecolormap->Maps; + dc_light = LIGHTSCALE(rw_light, wallshade); +#else dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + dc_light = 0; +#endif } rt_initcols(); for (int zz = 4; zz; --zz) @@ -3267,7 +3332,13 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting +#ifndef PALETTEOUTPUT + dc_colormap = usecolormap->Maps; + dc_light = LIGHTSCALE(rw_light, wallshade); +#else dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + dc_light = 0; +#endif } R_WallSpriteColumn (R_DrawMaskedColumn); dc_x++; diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 07edf25e9..433007acb 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -182,6 +182,7 @@ void FSoftwareRenderer::RemapVoxels() void FSoftwareRenderer::WriteSavePic (player_t *player, FILE *file, int width, int height) { +#ifdef PALETTEOUTPUT DCanvas *pic = new DSimpleCanvas (width, height); PalEntry palette[256]; @@ -195,6 +196,7 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FILE *file, int width, i pic->Destroy(); pic->ObjectFlags |= OF_YesReallyDelete; delete pic; +#endif } //=========================================================================== @@ -311,6 +313,7 @@ void FSoftwareRenderer::CopyStackedViewParameters() void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov) { +#ifdef PALETTEOUTPUT BYTE *Pixels = const_cast(tex->GetPixels()); DSimpleCanvas *Canvas = tex->GetCanvas(); @@ -334,6 +337,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin tex->SetUpdated(); fixedcolormap = savecolormap; realfixedcolormap = savecm; +#endif } //========================================================================== diff --git a/src/r_things.cpp b/src/r_things.cpp index 427e61b06..0e55b45f9 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -132,7 +132,7 @@ EXTERN_CVAR (Bool, r_drawvoxels) // int OffscreenBufferWidth, OffscreenBufferHeight; -BYTE *OffscreenColorBuffer; +canvas_pixel_t *OffscreenColorBuffer; FCoverageBuffer *OffscreenCoverageBuffer; // @@ -408,6 +408,7 @@ void R_DrawVisSprite (vissprite_t *vis) fixed_t centeryfrac = FLOAT2FIXED(CenterY); dc_colormap = vis->Style.colormap; + dc_light = 0; mode = R_SetPatchStyle (vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor); @@ -544,6 +545,7 @@ void R_DrawWallSprite(vissprite_t *spr) dc_colormap = usecolormap->Maps; else calclighting = true; + dc_light = 0; // Draw it WallSpriteTile = spr->pic; @@ -592,7 +594,13 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting +#ifndef PALETTEOUTPUT + dc_colormap = usecolormap->Maps; + dc_light = LIGHTSCALE(rw_light, shade); +#else dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); + dc_light = FLOAT2FIXED(MAXLIGHTVIS); +#endif } if (!R_ClipSpriteColumnWithPortals(spr)) R_WallSpriteColumn(R_DrawMaskedColumn); @@ -603,7 +611,13 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting +#ifndef PALETTEOUTPUT + dc_colormap = usecolormap->Maps; + dc_light = LIGHTSCALE(rw_light, shade); +#else dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); + dc_light = FLOAT2FIXED(MAXLIGHTVIS); +#endif } rt_initcols(); for (int zz = 4; zz; --zz) @@ -619,7 +633,13 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting +#ifndef PALETTEOUTPUT + dc_colormap = usecolormap->Maps; + dc_light = LIGHTSCALE(rw_light, shade); +#else dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); + dc_light = FLOAT2FIXED(MAXLIGHTVIS); +#endif } if (!R_ClipSpriteColumnWithPortals(spr)) R_WallSpriteColumn(R_DrawMaskedColumn); @@ -654,6 +674,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop // Do setup for blending. dc_colormap = spr->Style.colormap; + dc_light = 0; mode = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); if (mode == DontDraw) @@ -2598,10 +2619,8 @@ static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) void R_DrawParticle (vissprite_t *vis) { - DWORD *bg2rgb; int spacing; - BYTE *dest; - DWORD fg; + canvas_pixel_t *dest; BYTE color = vis->Style.colormap[vis->startfrac]; int yl = vis->y1; int ycount = vis->y2 - yl + 1; @@ -2610,6 +2629,47 @@ void R_DrawParticle (vissprite_t *vis) R_DrawMaskedSegsBehindParticle (vis); +#ifndef PALETTEOUTPUT + uint32_t fg = shade_pal_index(color, calc_light_multiplier(0)); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + // vis->renderflags holds translucency level (0-255) + fixed_t fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff; + uint32_t alpha = fglevel * 256 / FRACUNIT; + uint32_t inv_alpha = 256 - alpha; + + fg_red *= alpha; + fg_green *= alpha; + fg_blue *= alpha; + + spacing = RenderTarget->GetPitch(); + + for (int x = x1; x < (x1 + countbase); x++) + { + dc_x = x; + if (R_ClipSpriteColumnWithPortals(vis)) + continue; + dest = ylookup[yl] + x + dc_destorg; + for (int y = 0; y < ycount; y++) + { + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red * alpha) / 256; + uint32_t green = (fg_green + bg_green * alpha) / 256; + uint32_t blue = (fg_blue + bg_blue * alpha) / 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += spacing; + } + } +#else + DWORD *bg2rgb; + DWORD fg; + // vis->renderflags holds translucency level (0-255) { fixed_t fglevel, bglevel; @@ -2659,6 +2719,7 @@ void R_DrawParticle (vissprite_t *vis) dest += spacing; } } +#endif } extern double BaseYaspectMul;; @@ -3189,12 +3250,12 @@ void R_CheckOffscreenBuffer(int width, int height, bool spansonly) { if (OffscreenColorBuffer == NULL) { - OffscreenColorBuffer = new BYTE[width * height]; + OffscreenColorBuffer = new canvas_pixel_t[width * height]; } else if (OffscreenBufferWidth != width || OffscreenBufferHeight != height) { delete[] OffscreenColorBuffer; - OffscreenColorBuffer = new BYTE[width * height]; + OffscreenColorBuffer = new canvas_pixel_t[width * height]; } } OffscreenBufferWidth = width; diff --git a/src/textures/canvastexture.cpp b/src/textures/canvastexture.cpp index 062c3af1d..7388c1306 100644 --- a/src/textures/canvastexture.cpp +++ b/src/textures/canvastexture.cpp @@ -106,6 +106,10 @@ void FCanvasTexture::MakeTexture () Canvas = new DSimpleCanvas (Width, Height); Canvas->Lock (); GC::AddSoftRoot(Canvas); +#ifndef PALETTEOUTPUT + Pixels = new BYTE[Width*Height]; + bPixelsAllocated = true; +#else if (Width != Height || Width != Canvas->GetPitch()) { Pixels = new BYTE[Width*Height]; @@ -116,6 +120,7 @@ void FCanvasTexture::MakeTexture () Pixels = Canvas->GetBuffer(); bPixelsAllocated = false; } +#endif // Draw a special "unrendered" initial texture into the buffer. memset (Pixels, 0, Width*Height/2); memset (Pixels+Width*Height/2, 255, Width*Height/2); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index c7b62b0a6..fd14b5e0a 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -166,16 +166,18 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) if (translation != NULL) { dc_colormap = (lighttable_t *)translation; + dc_light = 0; } else { dc_colormap = identitymap; + dc_light = 0; } fixedcolormap = dc_colormap; ESPSResult mode = R_SetPatchStyle (parms.style, parms.Alpha, 0, parms.fillcolor); - BYTE *destorgsave = dc_destorg; + canvas_pixel_t *destorgsave = dc_destorg; dc_destorg = screen->GetBuffer(); if (dc_destorg == NULL) { @@ -1015,13 +1017,32 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) oldyyshifted = yy * GetPitch(); } - BYTE *spot = GetBuffer() + oldyyshifted + xx; +#ifndef PALETTEOUTPUT + canvas_pixel_t *spot = GetBuffer() + oldyyshifted + xx; + + uint32_t fg = shade_pal_index(basecolor, calc_light_multiplier(0)); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*spot >> 16) & 0xff; + uint32_t bg_green = (*spot >> 8) & 0xff; + uint32_t bg_blue = (*spot) & 0xff; + + uint32_t red = (fg_red + bg_red + 1) / 2; + uint32_t green = (fg_green + bg_green + 1) / 2; + uint32_t blue = (fg_blue + bg_blue + 1) / 2; + + *spot = 0xff000000 | (red << 16) | (green << 8) | blue; +#else + canvas_pixel_t *spot = GetBuffer() + oldyyshifted + xx; DWORD *bg2rgb = Col2RGB8[1+level]; DWORD *fg2rgb = Col2RGB8[63-level]; DWORD fg = fg2rgb[basecolor]; DWORD bg = bg2rgb[*spot]; bg = (fg+bg) | 0x1f07c1f; *spot = RGB32k.All[bg&(bg>>15)]; +#endif } void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 realcolor) @@ -1069,7 +1090,7 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real } else if (deltaX == 0) { // vertical line - BYTE *spot = GetBuffer() + y0*GetPitch() + x0; + canvas_pixel_t *spot = GetBuffer() + y0*GetPitch() + x0; int pitch = GetPitch (); do { @@ -1079,7 +1100,7 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real } else if (deltaX == deltaY) { // diagonal line. - BYTE *spot = GetBuffer() + y0*GetPitch() + x0; + canvas_pixel_t *spot = GetBuffer() + y0*GetPitch() + x0; int advance = GetPitch() + xDir; do { @@ -1205,7 +1226,7 @@ void DCanvas::DrawPixel(int x, int y, int palColor, uint32 realcolor) void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uint32 color) { int x, y; - BYTE *dest; + canvas_pixel_t *dest; if (left == right || top == bottom) { @@ -1426,11 +1447,11 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, // V_DrawBlock // Draw a linear block of pixels into the view buffer. // -void DCanvas::DrawBlock (int x, int y, int _width, int _height, const BYTE *src) const +void DCanvas::DrawBlock (int x, int y, int _width, int _height, const canvas_pixel_t *src) const { int srcpitch = _width; int destpitch; - BYTE *dest; + canvas_pixel_t *dest; if (ClipBox (x, y, _width, _height, src, srcpitch)) { @@ -1442,7 +1463,7 @@ void DCanvas::DrawBlock (int x, int y, int _width, int _height, const BYTE *src) do { - memcpy (dest, src, _width); + memcpy (dest, src, _width * sizeof(canvas_pixel_t)); src += srcpitch; dest += destpitch; } while (--_height); @@ -1452,9 +1473,9 @@ void DCanvas::DrawBlock (int x, int y, int _width, int _height, const BYTE *src) // V_GetBlock // Gets a linear block of pixels from the view buffer. // -void DCanvas::GetBlock (int x, int y, int _width, int _height, BYTE *dest) const +void DCanvas::GetBlock (int x, int y, int _width, int _height, canvas_pixel_t *dest) const { - const BYTE *src; + const canvas_pixel_t *src; #ifdef RANGECHECK if (x<0 @@ -1470,14 +1491,14 @@ void DCanvas::GetBlock (int x, int y, int _width, int _height, BYTE *dest) const while (_height--) { - memcpy (dest, src, _width); + memcpy (dest, src, _width * sizeof(canvas_pixel_t)); src += Pitch; dest += _width; } } // Returns true if the box was completely clipped. False otherwise. -bool DCanvas::ClipBox (int &x, int &y, int &w, int &h, const BYTE *&src, const int srcpitch) const +bool DCanvas::ClipBox (int &x, int &y, int &w, int &h, const canvas_pixel_t *&src, const int srcpitch) const { if (x >= Width || y >= Height || x+w <= 0 || y+h <= 0) { // Completely clipped off screen diff --git a/src/v_video.cpp b/src/v_video.cpp index 01a73950b..b6a626753 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -343,10 +343,8 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) if (damount == 0.f) return; - DWORD *bg2rgb; - DWORD fg; int gap; - BYTE *spot; + canvas_pixel_t *spot; int x, y; if (x1 >= Width || y1 >= Height) @@ -366,6 +364,43 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) return; } + spot = Buffer + x1 + y1*Pitch; + gap = Pitch - w; + +#ifndef PALETTEOUTPUT + uint32_t fg = color.d; + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t alpha = (uint32_t)clamp(damount * 256 + 0.5f, 0.0f, 256.0f); + uint32_t inv_alpha = 256 - alpha; + + fg_red *= alpha; + fg_green *= alpha; + fg_blue *= alpha; + + for (y = h; y != 0; y--) + { + for (x = w; x != 0; x--) + { + uint32_t bg_red = (*spot >> 16) & 0xff; + uint32_t bg_green = (*spot >> 8) & 0xff; + uint32_t bg_blue = (*spot) & 0xff; + + uint32_t red = (fg_red + bg_red * inv_alpha) / 256; + uint32_t green = (fg_green + bg_green * inv_alpha) / 256; + uint32_t blue = (fg_blue + bg_blue * inv_alpha) / 256; + + *spot = 0xff000000 | (red << 16) | (green << 8) | blue; + spot++; + } + spot += gap; + } +#else + DWORD *bg2rgb; + DWORD fg; + { int amount; @@ -377,8 +412,6 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) (((color.b * amount) >> 4) << 10); } - spot = Buffer + x1 + y1*Pitch; - gap = Pitch - w; for (y = h; y != 0; y--) { for (x = w; x != 0; x--) @@ -392,6 +425,7 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) } spot += gap; } +#endif } //========================================================================== @@ -403,7 +437,7 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) // //========================================================================== -void DCanvas::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type) +void DCanvas::GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSType &color_type) { Lock(true); buffer = GetBuffer(); @@ -759,8 +793,8 @@ DSimpleCanvas::DSimpleCanvas (int width, int height) Pitch = width + MAX(0, CPU.DataL1LineSize - 8); } } - MemBuffer = new BYTE[Pitch * height]; - memset (MemBuffer, 0, Pitch * height); + MemBuffer = new canvas_pixel_t[Pitch * height]; + memset (MemBuffer, 0, Pitch * height * sizeof(canvas_pixel_t)); } //========================================================================== @@ -879,7 +913,7 @@ void DFrameBuffer::DrawRateStuff () { int i = I_GetTime(false); int tics = i - LastTic; - BYTE *buffer = GetBuffer(); + canvas_pixel_t *buffer = GetBuffer(); LastTic = i; if (tics > 20) tics = 20; diff --git a/src/v_video.h b/src/v_video.h index fa1ce83df..27c09ee36 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -189,7 +189,7 @@ public: virtual ~DCanvas (); // Member variable access - inline BYTE *GetBuffer () const { return Buffer; } + inline canvas_pixel_t *GetBuffer () const { return Buffer; } inline int GetWidth () const { return Width; } inline int GetHeight () const { return Height; } inline int GetPitch () const { return Pitch; } @@ -202,10 +202,10 @@ public: virtual bool IsLocked () { return Buffer != NULL; } // Returns true if the surface is locked // Draw a linear block of pixels into the canvas - virtual void DrawBlock (int x, int y, int width, int height, const BYTE *src) const; + virtual void DrawBlock (int x, int y, int width, int height, const canvas_pixel_t *src) const; // Reads a linear block of pixels into the view buffer. - virtual void GetBlock (int x, int y, int width, int height, BYTE *dest) const; + virtual void GetBlock (int x, int y, int width, int height, canvas_pixel_t *dest) const; // Dim the entire canvas for the menus virtual void Dim (PalEntry color = 0); @@ -237,7 +237,7 @@ public: // Retrieves a buffer containing image data for a screenshot. // Hint: Pitch can be negative for upside-down images, in which case buffer // points to the last row in the buffer, which will be the first row output. - virtual void GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type); + virtual void GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSType &color_type); // Releases the screenshot buffer. virtual void ReleaseScreenshotBuffer(); @@ -262,13 +262,13 @@ public: void DrawChar (FFont *font, int normalcolor, int x, int y, BYTE character, int tag_first, ...); protected: - BYTE *Buffer; + canvas_pixel_t *Buffer; int Width; int Height; int Pitch; int LockCount; - bool ClipBox (int &left, int &top, int &width, int &height, const BYTE *&src, const int srcpitch) const; + bool ClipBox (int &left, int &top, int &width, int &height, const canvas_pixel_t *&src, const int srcpitch) const; void DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags) = delete; virtual void DrawTextureParms(FTexture *img, DrawParms &parms); bool ParseDrawTextureTags (FTexture *img, double x, double y, uint32 tag, va_list tags, DrawParms *parms, bool fortext) const; @@ -297,7 +297,7 @@ public: void Unlock (); protected: - BYTE *MemBuffer; + canvas_pixel_t *MemBuffer; DSimpleCanvas() {} }; diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index efdced151..14a78d4cd 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -765,14 +765,20 @@ void D3DFB::KillNativeTexs() bool D3DFB::CreateFBTexture () { - if (FAILED(D3DDevice->CreateTexture(Width, Height, 1, D3DUSAGE_DYNAMIC, D3DFMT_L8, D3DPOOL_DEFAULT, &FBTexture, NULL))) +#ifndef PALETTEOUTPUT + D3DFORMAT FBFormat = D3DFMT_A8R8G8B8; +#else + D3DFORMAT FBFormat = D3DFMT_L8; +#endif + + if (FAILED(D3DDevice->CreateTexture(Width, Height, 1, D3DUSAGE_DYNAMIC, FBFormat, D3DPOOL_DEFAULT, &FBTexture, NULL))) { int pow2width, pow2height, i; for (i = 1; i < Width; i <<= 1) {} pow2width = i; for (i = 1; i < Height; i <<= 1) {} pow2height = i; - if (FAILED(D3DDevice->CreateTexture(pow2width, pow2height, 1, D3DUSAGE_DYNAMIC, D3DFMT_L8, D3DPOOL_DEFAULT, &FBTexture, NULL))) + if (FAILED(D3DDevice->CreateTexture(pow2width, pow2height, 1, D3DUSAGE_DYNAMIC, FBFormat, D3DPOOL_DEFAULT, &FBTexture, NULL))) { return false; } @@ -1304,18 +1310,18 @@ void D3DFB::Draw3DPart(bool copy3d) SUCCEEDED(FBTexture->LockRect (0, &lockrect, NULL, D3DLOCK_DISCARD))) || SUCCEEDED(FBTexture->LockRect (0, &lockrect, &texrect, 0))) { - if (lockrect.Pitch == Pitch && Pitch == Width) + if (lockrect.Pitch == Pitch * sizeof(canvas_pixel_t) && Pitch == Width) { - memcpy (lockrect.pBits, MemBuffer, Width * Height); + memcpy (lockrect.pBits, MemBuffer, Width * Height * sizeof(canvas_pixel_t)); } else { - BYTE *dest = (BYTE *)lockrect.pBits; - BYTE *src = MemBuffer; + canvas_pixel_t *dest = (canvas_pixel_t *)lockrect.pBits; + canvas_pixel_t *src = MemBuffer; for (int y = 0; y < Height; y++) { - memcpy (dest, src, Width); - dest += lockrect.Pitch; + memcpy (dest, src, Width * sizeof(canvas_pixel_t)); + dest = reinterpret_cast(reinterpret_cast(dest) + lockrect.Pitch); src += Pitch; } } @@ -1349,7 +1355,11 @@ void D3DFB::Draw3DPart(bool copy3d) memset(Constant, 0, sizeof(Constant)); SetAlphaBlend(D3DBLENDOP(0)); EnableAlphaTest(FALSE); +#ifndef PALETTEOUTPUT + SetPixelShader(Shaders[SHADER_NormalColor]); +#else SetPixelShader(Shaders[SHADER_NormalColorPal]); +#endif if (copy3d) { FBVERTEX verts[4]; @@ -1367,7 +1377,11 @@ void D3DFB::Draw3DPart(bool copy3d) realfixedcolormap->ColorizeStart[1]/2, realfixedcolormap->ColorizeStart[2]/2, 0); color1 = D3DCOLOR_COLORVALUE(realfixedcolormap->ColorizeEnd[0]/2, realfixedcolormap->ColorizeEnd[1]/2, realfixedcolormap->ColorizeEnd[2]/2, 1); +#ifndef PALETTEOUTPUT + SetPixelShader(Shaders[SHADER_SpecialColormap]); +#else SetPixelShader(Shaders[SHADER_SpecialColormapPal]); +#endif } } else @@ -1378,7 +1392,11 @@ void D3DFB::Draw3DPart(bool copy3d) CalcFullscreenCoords(verts, Accel2D, false, color0, color1); D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX)); } +#ifndef PALETTEOUTPUT + SetPixelShader(Shaders[SHADER_NormalColor]); +#else SetPixelShader(Shaders[SHADER_NormalColorPal]); +#endif } //========================================================================== @@ -1707,7 +1725,7 @@ void D3DFB::SetBlendingRect(int x1, int y1, int x2, int y2) // //========================================================================== -void D3DFB::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type) +void D3DFB::GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSType &color_type) { D3DLOCKED_RECT lrect; @@ -1733,7 +1751,7 @@ void D3DFB::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_ } else { - buffer = (const BYTE *)lrect.pBits; + buffer = (const canvas_pixel_t *)lrect.pBits; pitch = lrect.Pitch; color_type = SS_BGRA; } diff --git a/src/win32/fb_ddraw.cpp b/src/win32/fb_ddraw.cpp index 7cc603786..9be571f98 100644 --- a/src/win32/fb_ddraw.cpp +++ b/src/win32/fb_ddraw.cpp @@ -32,7 +32,6 @@ ** */ - // HEADER FILES ------------------------------------------------------------ #define DIRECTDRAW_VERSION 0x0300 @@ -61,7 +60,9 @@ // TYPES ------------------------------------------------------------------- +#ifdef USE_OBSOLETE_DDRAW IMPLEMENT_CLASS(DDrawFB) +#endif // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- @@ -119,6 +120,8 @@ cycle_t BlitCycles; // CODE -------------------------------------------------------------------- +#ifdef USE_OBSOLETE_DDRAW + DDrawFB::DDrawFB (int width, int height, bool fullscreen) : BaseWinFB (width, height) { @@ -996,8 +999,8 @@ DDrawFB::LockSurfRes DDrawFB::LockSurf (LPRECT lockrect, LPDIRECTDRAWSURFACE toL LOG1 ("Final result after restoration attempts: %08lx\n", hr); return NoGood; } - Buffer = (BYTE *)desc.lpSurface; - Pitch = desc.lPitch; + Buffer = (canvas_pixel_t *)desc.lpSurface; + Pitch = desc.lPitch / sizeof(canvas_pixel_t); BufferingNow = false; return wasLost ? GoodWasLost : Good; } @@ -1327,6 +1330,7 @@ void DDrawFB::Blank () PrimarySurf->Blt (NULL, NULL, NULL, DDBLT_COLORFILL, &blitFX); } } +#endif ADD_STAT (blit) { diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index 9b2754eae..73a2c6966 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -142,6 +142,7 @@ protected: BaseWinFB() {} }; +#ifdef USE_OBSOLETE_DDRAW class DDrawFB : public BaseWinFB { DECLARE_CLASS(DDrawFB, BaseWinFB) @@ -223,6 +224,7 @@ private: DDrawFB() {} }; +#endif class D3DFB : public BaseWinFB { @@ -250,7 +252,7 @@ public: bool PaintToWindow (); void SetVSync (bool vsync); void NewRefreshRate(); - void GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type); + void GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSType &color_type); void ReleaseScreenshotBuffer(); void SetBlendingRect (int x1, int y1, int x2, int y2); bool Begin2D (bool copy3d); diff --git a/src/win32/win32video.cpp b/src/win32/win32video.cpp index 29bb905fb..3f3645d0b 100644 --- a/src/win32/win32video.cpp +++ b/src/win32/win32video.cpp @@ -221,8 +221,15 @@ bool Win32Video::InitD3D9 () // Enumerate available display modes. FreeModes (); +#ifndef PALETTEOUTPUT // To do: remove this again (AddD3DModes fails when there are too many modes available for videomenu to display) + AddMode(1920, 1080, 8, 1440, 0); // 1080p + AddMode(1920*2, 1080*2, 8, 1440, 0); // 4k + AddMode(2560, 1440, 8, 1440, 0); // 27" classic + AddMode(2560*2, 1440*2, 8, 1440*2, 0); // 5k +#else AddD3DModes (m_Adapter, D3DFMT_X8R8G8B8); AddD3DModes (m_Adapter, D3DFMT_R5G6B5); +#endif if (Args->CheckParm ("-2")) { // Force all modes to be pixel-doubled. ScaleModes (1); @@ -660,6 +667,10 @@ DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool fullscr flashAmount = 0; } +#ifndef USE_OBSOLETE_DDRAW + fb = new D3DFB(m_Adapter, width, height, fullscreen); + LOG1("New fb created @ %p\n", fb); +#else if (D3D != NULL) { fb = new D3DFB (m_Adapter, width, height, fullscreen); @@ -668,6 +679,7 @@ DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool fullscr { fb = new DDrawFB (width, height, fullscreen); } + LOG1 ("New fb created @ %p\n", fb); // If we could not create the framebuffer, try again with slightly @@ -729,6 +741,7 @@ DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool fullscr fb = static_cast(CreateFrameBuffer (width, height, fullscreen, NULL)); } retry = 0; +#endif fb->SetFlash (flashColor, flashAmount); return fb; From 8aabc26cd94018238ed606b81b3d49fabbe429fd Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 30 May 2016 05:52:15 +0200 Subject: [PATCH 0612/1509] Created standalone rgba drawing functions --- src/CMakeLists.txt | 1 + src/r_draw.cpp | 2470 ++++++++++++++++++++++++++++++------------ src/r_draw.h | 165 ++- src/r_drawt.cpp | 332 +----- src/r_drawt_rgba.cpp | 883 +++++++++++++++ src/r_main.cpp | 4 +- src/r_plane.cpp | 11 +- src/r_plane.h | 4 + src/r_segs.cpp | 4 +- src/r_things.cpp | 97 +- src/r_things.h | 5 +- src/v_draw.cpp | 2 +- 12 files changed, 2896 insertions(+), 1082 deletions(-) create mode 100644 src/r_drawt_rgba.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 84d6f06b9..c90756b5d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -883,6 +883,7 @@ set( FASTMATH_PCH_SOURCES r_bsp.cpp r_draw.cpp r_drawt.cpp + r_drawt_rgba.cpp r_main.cpp r_plane.cpp r_segs.cpp diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 044910008..d2b694f05 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -38,6 +38,7 @@ #include "r_data/r_translate.h" #include "v_palette.h" #include "r_data/colormaps.h" +#include "r_plane.h" #include "gi.h" #include "stats.h" @@ -73,6 +74,19 @@ int scaledviewwidth; // screen depth and asm/no asm. void (*R_DrawColumnHoriz)(void); void (*R_DrawColumn)(void); +void (*R_FillColumn)(void); +void (*R_FillAddColumn)(void); +void (*R_FillAddClampColumn)(void); +void (*R_FillSubClampColumn)(void); +void (*R_FillRevSubClampColumn)(void); +void (*R_DrawAddColumn)(void); +void (*R_DrawTlatedAddColumn)(void); +void (*R_DrawAddClampColumn)(void); +void (*R_DrawAddClampTranslatedColumn)(void); +void (*R_DrawSubClampColumn)(void); +void (*R_DrawSubClampTranslatedColumn)(void); +void (*R_DrawRevSubClampColumn)(void); +void (*R_DrawRevSubClampTranslatedColumn)(void); void (*R_DrawFuzzColumn)(void); void (*R_DrawTranslatedColumn)(void); void (*R_DrawShadedColumn)(void); @@ -82,7 +96,44 @@ void (*R_DrawSpanTranslucent)(void); void (*R_DrawSpanMaskedTranslucent)(void); void (*R_DrawSpanAddClamp)(void); void (*R_DrawSpanMaskedAddClamp)(void); -void (*rt_map4cols)(int,int,int); +void (*R_FillSpan)(void); +void (*R_FillColumnHoriz)(void); +void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); +void (*R_MapColoredPlane)(int y, int x1); +void (*R_DrawParticle)(vissprite_t *); +fixed_t (*tmvline1_add)(); +void (*tmvline4_add)(); +fixed_t (*tmvline1_addclamp)(); +void (*tmvline4_addclamp)(); +fixed_t (*tmvline1_subclamp)(); +void (*tmvline4_subclamp)(); +fixed_t (*tmvline1_revsubclamp)(); +void (*tmvline4_revsubclamp)(); +void (*rt_copy1col)(int hx, int sx, int yl, int yh); +void (*rt_copy4cols)(int sx, int yl, int yh); +void (*rt_shaded1col)(int hx, int sx, int yl, int yh); +void (*rt_shaded4cols)(int sx, int yl, int yh); +void (*rt_map1col)(int hx, int sx, int yl, int yh); +void (*rt_add1col)(int hx, int sx, int yl, int yh); +void (*rt_addclamp1col)(int hx, int sx, int yl, int yh); +void (*rt_subclamp1col)(int hx, int sx, int yl, int yh); +void (*rt_revsubclamp1col)(int hx, int sx, int yl, int yh); +void (*rt_tlate1col)(int hx, int sx, int yl, int yh); +void (*rt_tlateadd1col)(int hx, int sx, int yl, int yh); +void (*rt_tlateaddclamp1col)(int hx, int sx, int yl, int yh); +void (*rt_tlatesubclamp1col)(int hx, int sx, int yl, int yh); +void (*rt_tlaterevsubclamp1col)(int hx, int sx, int yl, int yh); +void (*rt_map4cols)(int sx, int yl, int yh); +void (*rt_add4cols)(int sx, int yl, int yh); +void (*rt_addclamp4cols)(int sx, int yl, int yh); +void (*rt_subclamp4cols)(int sx, int yl, int yh); +void (*rt_revsubclamp4cols)(int sx, int yl, int yh); +void (*rt_tlate4cols)(int sx, int yl, int yh); +void (*rt_tlateadd4cols)(int sx, int yl, int yh); +void (*rt_tlateaddclamp4cols)(int sx, int yl, int yh); +void (*rt_tlatesubclamp4cols)(int sx, int yl, int yh); +void (*rt_tlaterevsubclamp4cols)(int sx, int yl, int yh); +void (*rt_initcols)(canvas_pixel_t *buffer); // // R_DrawColumn @@ -198,10 +249,6 @@ void R_DrawColumnP_C (void) // Framebuffer destination address. dest = dc_dest; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); -#endif - // Determine scaling, // which is the only mapping to be done. fracstep = dc_iscale; @@ -221,11 +268,7 @@ void R_DrawColumnP_C (void) { // Re-map color indices from wall texture column // using a lighting/special effects LUT. -#ifndef PALETTEOUTPUT - *dest = shade_pal_index(colormap[source[frac>>FRACBITS]], light); -#else *dest = colormap[source[frac >> FRACBITS]]; -#endif dest += pitch; frac += fracstep; @@ -235,8 +278,78 @@ void R_DrawColumnP_C (void) } #endif +void R_DrawColumnP_RGBA_C() +{ + int count; + canvas_pixel_t* dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + + // Zero length, column does not exceed a pixel. + if (count <= 0) + return; + + // Framebuffer destination address. + dest = dc_dest; + + uint32_t light = calc_light_multiplier(dc_light); + + // Determine scaling, + // which is the only mapping to be done. + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + // [RH] Get local copies of these variables so that the compiler + // has a better chance of optimizing this well. + BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; + int pitch = dc_pitch; + + // Inner loop that does the actual texture mapping, + // e.g. a DDA-lile scaling. + // This is as fast as it gets. + do + { + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + *dest = shade_pal_index(colormap[source[frac >> FRACBITS]], light); + + dest += pitch; + frac += fracstep; + + } while (--count); + } +} + // [RH] Just fills a column with a color -void R_FillColumnP (void) +void R_FillColumnP_C (void) +{ + int count; + canvas_pixel_t* dest; + + count = dc_count; + + if (count <= 0) + return; + + dest = dc_dest; + + { + int pitch = dc_pitch; + BYTE color = dc_color; + + do + { + *dest = color; + dest += pitch; + } while (--count); + } +} + +void R_FillColumnP_RGBA() { int count; canvas_pixel_t* dest; @@ -248,9 +361,7 @@ void R_FillColumnP (void) dest = dc_dest; -#ifndef PALETTEOUTPUT uint32_t light = calc_light_multiplier(dc_light); -#endif { int pitch = dc_pitch; @@ -258,17 +369,40 @@ void R_FillColumnP (void) do { -#ifndef PALETTEOUTPUT *dest = shade_pal_index(color, light); -#else - *dest = color; -#endif dest += pitch; } while (--count); } } -void R_FillAddColumn (void) +void R_FillAddColumn_C (void) +{ + int count; + canvas_pixel_t *dest; + + count = dc_count; + if (count <= 0) + return; + + dest = dc_dest; + int pitch = dc_pitch; + + DWORD *bg2rgb; + DWORD fg; + + bg2rgb = dc_destblend; + fg = dc_srccolor; + + do + { + DWORD bg; + bg = (fg + bg2rgb[*dest]) | 0x1f07c1f; + *dest = RGB32k.All[bg & (bg>>15)]; + dest += pitch; + } while (--count); +} + +void R_FillAddColumn_RGBA_C() { int count; canvas_pixel_t *dest; @@ -280,7 +414,6 @@ void R_FillAddColumn (void) dest = dc_dest; int pitch = dc_pitch; -#ifndef PALETTEOUTPUT uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; uint32_t fg_green = (dc_srccolor >> 2) & 0xf8; uint32_t fg_blue = (dc_srccolor << 3) & 0xf8; @@ -298,24 +431,9 @@ void R_FillAddColumn (void) *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; } while (--count); -#else - DWORD *bg2rgb; - DWORD fg; - - bg2rgb = dc_destblend; - fg = dc_srccolor; - - do - { - DWORD bg; - bg = (fg + bg2rgb[*dest]) | 0x1f07c1f; - *dest = RGB32k.All[bg & (bg>>15)]; - dest += pitch; - } while (--count); -#endif } -void R_FillAddClampColumn (void) +void R_FillAddClampColumn_C (void) { int count; canvas_pixel_t *dest; @@ -327,25 +445,6 @@ void R_FillAddClampColumn (void) dest = dc_dest; int pitch = dc_pitch; -#ifndef PALETTEOUTPUT - uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; - uint32_t fg_green = (dc_srccolor >> 2) & 0xf8; - uint32_t fg_blue = (dc_srccolor << 3) & 0xf8; - - do - { - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--count); -#else DWORD *bg2rgb; DWORD fg; @@ -365,10 +464,9 @@ void R_FillAddClampColumn (void) *dest = RGB32k.All[a & (a>>15)]; dest += pitch; } while (--count); -#endif } -void R_FillSubClampColumn (void) +void R_FillAddClampColumn_RGBA() { int count; canvas_pixel_t *dest; @@ -380,7 +478,6 @@ void R_FillSubClampColumn (void) dest = dc_dest; int pitch = dc_pitch; -#ifndef PALETTEOUTPUT uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; uint32_t fg_green = (dc_srccolor >> 2) & 0xf8; uint32_t fg_blue = (dc_srccolor << 3) & 0xf8; @@ -391,14 +488,27 @@ void R_FillSubClampColumn (void) uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 255; - uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 255; - uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 255; + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; } while (--count); -#else +} + +void R_FillSubClampColumn_C (void) +{ + int count; + canvas_pixel_t *dest; + + count = dc_count; + if (count <= 0) + return; + + dest = dc_dest; + int pitch = dc_pitch; + DWORD *bg2rgb; DWORD fg; @@ -417,10 +527,9 @@ void R_FillSubClampColumn (void) *dest = RGB32k.All[a & (a>>15)]; dest += pitch; } while (--count); -#endif } -void R_FillRevSubClampColumn (void) +void R_FillSubClampColumn_RGBA() { int count; canvas_pixel_t *dest; @@ -432,7 +541,6 @@ void R_FillRevSubClampColumn (void) dest = dc_dest; int pitch = dc_pitch; -#ifndef PALETTEOUTPUT uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; uint32_t fg_green = (dc_srccolor >> 2) & 0xf8; uint32_t fg_blue = (dc_srccolor << 3) & 0xf8; @@ -443,14 +551,27 @@ void R_FillRevSubClampColumn (void) uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 255; - uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 255; - uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 255; + uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 255; + uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 255; + uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 255; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; } while (--count); -#else +} + +void R_FillRevSubClampColumn_C (void) +{ + int count; + canvas_pixel_t *dest; + + count = dc_count; + if (count <= 0) + return; + + dest = dc_dest; + int pitch = dc_pitch; + DWORD *bg2rgb; DWORD fg; @@ -469,7 +590,37 @@ void R_FillRevSubClampColumn (void) *dest = RGB32k.All[a & (a>>15)]; dest += pitch; } while (--count); -#endif +} + +void R_FillRevSubClampColumn_RGBA() +{ + int count; + canvas_pixel_t *dest; + + count = dc_count; + if (count <= 0) + return; + + dest = dc_dest; + int pitch = dc_pitch; + + uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; + uint32_t fg_green = (dc_srccolor >> 2) & 0xf8; + uint32_t fg_blue = (dc_srccolor << 3) & 0xf8; + + do + { + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 255; + uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 255; + uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 255; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--count); } // @@ -542,7 +693,77 @@ void R_DrawFuzzColumnP_C (void) dest = ylookup[dc_yl] + dc_x + dc_destorg; -#ifndef PALETTEOUTPUT + // colormap #6 is used for shading (of 0-31, a bit brighter than average) + { + // [RH] Make local copies of global vars to try and improve + // the optimizations made by the compiler. + int pitch = dc_pitch; + int fuzz = fuzzpos; + int cnt; + BYTE *map = &NormalLight.Maps[6*256]; + + // [RH] Split this into three separate loops to minimize + // the number of times fuzzpos needs to be clamped. + if (fuzz) + { + cnt = MIN(FUZZTABLE-fuzz,count); + count -= cnt; + do + { + *dest = map[dest[fuzzoffset[fuzz++]]]; + dest += pitch; + } while (--cnt); + } + if (fuzz == FUZZTABLE || count > 0) + { + while (count >= FUZZTABLE) + { + fuzz = 0; + cnt = FUZZTABLE; + count -= FUZZTABLE; + do + { + *dest = map[dest[fuzzoffset[fuzz++]]]; + dest += pitch; + } while (--cnt); + } + fuzz = 0; + if (count > 0) + { + do + { + *dest = map[dest[fuzzoffset[fuzz++]]]; + dest += pitch; + } while (--count); + } + } + fuzzpos = fuzz; + } +} +#endif + +void R_DrawFuzzColumnP_RGBA_C() +{ + int count; + canvas_pixel_t *dest; + + // Adjust borders. Low... + if (dc_yl == 0) + dc_yl = 1; + + // .. and high. + if (dc_yh > fuzzviewheight) + dc_yh = fuzzviewheight; + + count = dc_yh - dc_yl; + + // Zero length. + if (count < 0) + return; + + count++; + + dest = ylookup[dc_yl] + dc_x + dc_destorg; // Note: this implementation assumes this function is only used for the pinky shadow effect (i.e. no other fancy colormap than black) // I'm not sure if this is really always the case or not. @@ -618,58 +839,7 @@ void R_DrawFuzzColumnP_C (void) } fuzzpos = fuzz; } - -#else - - // colormap #6 is used for shading (of 0-31, a bit brighter than average) - { - // [RH] Make local copies of global vars to try and improve - // the optimizations made by the compiler. - int pitch = dc_pitch; - int fuzz = fuzzpos; - int cnt; - BYTE *map = &NormalLight.Maps[6*256]; - - // [RH] Split this into three separate loops to minimize - // the number of times fuzzpos needs to be clamped. - if (fuzz) - { - cnt = MIN(FUZZTABLE-fuzz,count); - count -= cnt; - do - { - *dest = map[dest[fuzzoffset[fuzz++]]]; - dest += pitch; - } while (--cnt); - } - if (fuzz == FUZZTABLE || count > 0) - { - while (count >= FUZZTABLE) - { - fuzz = 0; - cnt = FUZZTABLE; - count -= FUZZTABLE; - do - { - *dest = map[dest[fuzzoffset[fuzz++]]]; - dest += pitch; - } while (--cnt); - } - fuzz = 0; - if (count > 0) - { - do - { - *dest = map[dest[fuzzoffset[fuzz++]]]; - dest += pitch; - } while (--count); - } - } - fuzzpos = fuzz; - } -#endif -} -#endif +} // // R_DrawTranlucentColumn @@ -733,7 +903,44 @@ void R_DrawAddColumnP_C (void) fracstep = dc_iscale; frac = dc_texturefrac; -#ifndef PALETTEOUTPUT + { + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; + int pitch = dc_pitch; + + do + { + DWORD fg = colormap[source[frac>>FRACBITS]]; + DWORD bg = *dest; + + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg+bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg>>15)]; + dest += pitch; + frac += fracstep; + } while (--count); + } +} + +void R_DrawAddColumnP_RGBA_C() +{ + int count; + canvas_pixel_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + { const BYTE *source = dc_source; int pitch = dc_pitch; @@ -760,28 +967,6 @@ void R_DrawAddColumnP_C (void) frac += fracstep; } while (--count); } -#else - { - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; - BYTE *colormap = dc_colormap; - const BYTE *source = dc_source; - int pitch = dc_pitch; - - do - { - DWORD fg = colormap[source[frac>>FRACBITS]]; - DWORD bg = *dest; - - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg>>15)]; - dest += pitch; - frac += fracstep; - } while (--count); - } -#endif } // @@ -803,9 +988,39 @@ void R_DrawTranslatedColumnP_C (void) if (count <= 0) return; -#ifndef PALETTEOUTPUT + dest = dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + // [RH] Local copies of global vars to improve compiler optimizations + BYTE *colormap = dc_colormap; + BYTE *translation = dc_translation; + const BYTE *source = dc_source; + int pitch = dc_pitch; + + do + { + *dest = colormap[translation[source[frac>>FRACBITS]]]; + dest += pitch; + frac += fracstep; + } while (--count); + } +} + +void R_DrawTranslatedColumnP_RGBA_C() +{ + int count; + canvas_pixel_t* dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + uint32_t light = calc_light_multiplier(dc_light); -#endif dest = dc_dest; @@ -821,20 +1036,54 @@ void R_DrawTranslatedColumnP_C (void) do { -#ifndef PALETTEOUTPUT *dest = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); -#else - *dest = colormap[translation[source[frac>>FRACBITS]]]; -#endif dest += pitch; - frac += fracstep; } while (--count); } } // Draw a column that is both translated and translucent -void R_DrawTlatedAddColumnP_C (void) +void R_DrawTlatedAddColumnP_C() +{ + int count; + canvas_pixel_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + BYTE *translation = dc_translation; + BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; + int pitch = dc_pitch; + + do + { + DWORD fg = colormap[translation[source[frac>>FRACBITS]]]; + DWORD bg = *dest; + + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); + } +} + +void R_DrawTlatedAddColumnP_RGBA_C() { int count; canvas_pixel_t *dest; @@ -845,16 +1094,13 @@ void R_DrawTlatedAddColumnP_C (void) if (count <= 0) return; -#ifndef PALETTEOUTPUT uint32_t light = calc_light_multiplier(dc_light); -#endif dest = dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; -#ifndef PALETTEOUTPUT { BYTE *translation = dc_translation; BYTE *colormap = dc_colormap; @@ -882,29 +1128,6 @@ void R_DrawTlatedAddColumnP_C (void) frac += fracstep; } while (--count); } -#else - { - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; - BYTE *translation = dc_translation; - BYTE *colormap = dc_colormap; - const BYTE *source = dc_source; - int pitch = dc_pitch; - - do - { - DWORD fg = colormap[translation[source[frac>>FRACBITS]]]; - DWORD bg = *dest; - - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg >> 15)]; - dest += pitch; - frac += fracstep; - } while (--count); - } -#endif } // Draw a column whose "color" values are actually translucency @@ -925,7 +1148,41 @@ void R_DrawShadedColumnP_C (void) fracstep = dc_iscale; frac = dc_texturefrac; -#ifndef PALETTEOUTPUT + { + const BYTE *source = dc_source; + BYTE *colormap = dc_colormap; + int pitch = dc_pitch; + DWORD *fgstart = &Col2RGB8[0][dc_color]; + + do + { + DWORD val = colormap[source[frac>>FRACBITS]]; + DWORD fg = fgstart[val<<8]; + val = (Col2RGB8[64-val][*dest] + fg) | 0x1f07c1f; + *dest = RGB32k.All[val & (val>>15)]; + + dest += pitch; + frac += fracstep; + } while (--count); + } +} + +void R_DrawShadedColumnP_RGBA_C() +{ + int count; + canvas_pixel_t *dest; + fixed_t frac, fracstep; + + count = dc_count; + + if (count <= 0) + return; + + dest = dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; @@ -954,26 +1211,7 @@ void R_DrawShadedColumnP_C (void) frac += fracstep; } while (--count); } -#else - { - const BYTE *source = dc_source; - BYTE *colormap = dc_colormap; - int pitch = dc_pitch; - DWORD *fgstart = &Col2RGB8[0][dc_color]; - - do - { - DWORD val = colormap[source[frac>>FRACBITS]]; - DWORD fg = fgstart[val<<8]; - val = (Col2RGB8[64-val][*dest] + fg) | 0x1f07c1f; - *dest = RGB32k.All[val & (val>>15)]; - - dest += pitch; - frac += fracstep; - } while (--count); - } -#endif -} +} // Add source to destination, clamping it to white void R_DrawAddClampColumnP_C () @@ -992,7 +1230,6 @@ void R_DrawAddClampColumnP_C () fracstep = dc_iscale; frac = dc_texturefrac; -#ifndef PALETTEOUTPUT { const BYTE *source = dc_source; BYTE *colormap = dc_colormap; @@ -1019,30 +1256,50 @@ void R_DrawAddClampColumnP_C () frac += fracstep; } while (--count); } -#else +} + +void R_DrawAddClampColumnP_RGBA_C() +{ + int count; + canvas_pixel_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + { - BYTE *colormap = dc_colormap; const BYTE *source = dc_source; + BYTE *colormap = dc_colormap; int pitch = dc_pitch; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; + uint32_t light = calc_light_multiplier(dc_light); do { - DWORD a = fg2rgb[colormap[source[frac>>FRACBITS]]] + bg2rgb[*dest]; - DWORD b = a; + uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[a & (a>>15)]; + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; frac += fracstep; } while (--count); } -#endif } // Add translated source to destination, clamping it to white @@ -1062,35 +1319,6 @@ void R_DrawAddClampTranslatedColumnP_C () fracstep = dc_iscale; frac = dc_texturefrac; -#ifndef PALETTEOUTPUT - { - BYTE *translation = dc_translation; - BYTE *colormap = dc_colormap; - const BYTE *source = dc_source; - int pitch = dc_pitch; - uint32_t light = calc_light_multiplier(dc_light); - - do - { - uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } -#else { BYTE *translation = dc_translation; BYTE *colormap = dc_colormap; @@ -1114,7 +1342,51 @@ void R_DrawAddClampTranslatedColumnP_C () frac += fracstep; } while (--count); } -#endif +} + +void R_DrawAddClampTranslatedColumnP_RGBA_C() +{ + int count; + canvas_pixel_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + BYTE *translation = dc_translation; + BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; + int pitch = dc_pitch; + uint32_t light = calc_light_multiplier(dc_light); + + do + { + uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } } // Subtract destination from source, clamping it to black @@ -1134,7 +1406,45 @@ void R_DrawSubClampColumnP_C () fracstep = dc_iscale; frac = dc_texturefrac; -#ifndef PALETTEOUTPUT + { + BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; + int pitch = dc_pitch; + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + + do + { + DWORD a = (fg2rgb[colormap[source[frac>>FRACBITS]]] | 0x40100400) - bg2rgb[*dest]; + DWORD b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a>>15)]; + dest += pitch; + frac += fracstep; + } while (--count); + } +} + +void R_DrawSubClampColumnP_RGBA_C() +{ + int count; + canvas_pixel_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + { BYTE *colormap = dc_colormap; const BYTE *source = dc_source; @@ -1161,29 +1471,6 @@ void R_DrawSubClampColumnP_C () frac += fracstep; } while (--count); } -#else - { - BYTE *colormap = dc_colormap; - const BYTE *source = dc_source; - int pitch = dc_pitch; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; - - do - { - DWORD a = (fg2rgb[colormap[source[frac>>FRACBITS]]] | 0x40100400) - bg2rgb[*dest]; - DWORD b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a>>15)]; - dest += pitch; - frac += fracstep; - } while (--count); - } -#endif } // Subtract destination from source, clamping it to black @@ -1203,35 +1490,6 @@ void R_DrawSubClampTranslatedColumnP_C () fracstep = dc_iscale; frac = dc_texturefrac; -#ifndef PALETTEOUTPUT - { - BYTE *translation = dc_translation; - BYTE *colormap = dc_colormap; - const BYTE *source = dc_source; - int pitch = dc_pitch; - uint32_t light = calc_light_multiplier(dc_light); - - do - { - uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } -#else { BYTE *translation = dc_translation; BYTE *colormap = dc_colormap; @@ -1254,7 +1512,51 @@ void R_DrawSubClampTranslatedColumnP_C () frac += fracstep; } while (--count); } -#endif +} + +void R_DrawSubClampTranslatedColumnP_RGBA_C() +{ + int count; + canvas_pixel_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + BYTE *translation = dc_translation; + BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; + int pitch = dc_pitch; + uint32_t light = calc_light_multiplier(dc_light); + + do + { + uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } } // Subtract source from destination, clamping it to black @@ -1274,7 +1576,45 @@ void R_DrawRevSubClampColumnP_C () fracstep = dc_iscale; frac = dc_texturefrac; -#ifndef PALETTEOUTPUT + { + BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; + int pitch = dc_pitch; + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + + do + { + DWORD a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[source[frac>>FRACBITS]]]; + DWORD b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a>>15)]; + dest += pitch; + frac += fracstep; + } while (--count); + } +} + +void R_DrawRevSubClampColumnP_RGBA_C() +{ + int count; + canvas_pixel_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + { BYTE *colormap = dc_colormap; const BYTE *source = dc_source; @@ -1301,29 +1641,6 @@ void R_DrawRevSubClampColumnP_C () frac += fracstep; } while (--count); } -#else - { - BYTE *colormap = dc_colormap; - const BYTE *source = dc_source; - int pitch = dc_pitch; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; - - do - { - DWORD a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[source[frac>>FRACBITS]]]; - DWORD b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a>>15)]; - dest += pitch; - frac += fracstep; - } while (--count); - } -#endif } // Subtract source from destination, clamping it to black @@ -1343,7 +1660,46 @@ void R_DrawRevSubClampTranslatedColumnP_C () fracstep = dc_iscale; frac = dc_texturefrac; -#ifndef PALETTEOUTPUT + { + BYTE *translation = dc_translation; + BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; + int pitch = dc_pitch; + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + + do + { + DWORD a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[translation[source[frac>>FRACBITS]]]]; + DWORD b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[(a>>15) & a]; + dest += pitch; + frac += fracstep; + } while (--count); + } +} + +void R_DrawRevSubClampTranslatedColumnP_RGBA_C() +{ + int count; + canvas_pixel_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + { BYTE *translation = dc_translation; BYTE *colormap = dc_colormap; @@ -1371,34 +1727,9 @@ void R_DrawRevSubClampTranslatedColumnP_C () frac += fracstep; } while (--count); } -#else - { - BYTE *translation = dc_translation; - BYTE *colormap = dc_colormap; - const BYTE *source = dc_source; - int pitch = dc_pitch; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; - - do - { - DWORD a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[translation[source[frac>>FRACBITS]]]]; - DWORD b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[(a>>15) & a]; - dest += pitch; - frac += fracstep; - } while (--count); - } -#endif } - // // R_DrawSpan // With DOOM style restrictions on view orientation, @@ -1549,15 +1880,84 @@ void R_DrawSpanP_C (void) xstep = ds_xstep; ystep = ds_ystep; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(ds_light); + if (ds_xbits == 6 && ds_ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + + do + { + // Current texture index in u,v. + spot = ((xfrac>>(32-6-6))&(63*64)) + (yfrac>>(32-6)); + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + *dest++ = colormap[source[spot]]; + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + + do + { + // Current texture index in u,v. + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + *dest++ = colormap[source[spot]]; + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } +} #endif +void R_DrawSpanP_RGBA_C() +{ + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + canvas_pixel_t* dest; + const BYTE* source = ds_source; + const BYTE* colormap = ds_colormap; + int count; + int spot; + +#ifdef RANGECHECK + if (ds_x2 < ds_x1 || ds_x1 < 0 + || ds_x2 >= screen->width || ds_y > screen->height) + { + I_Error("R_DrawSpan: %i to %i at %i", ds_x1, ds_x2, ds_y); + } + // dscount++; +#endif + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + + dest = ylookup[ds_y] + ds_x1 + dc_destorg; + + count = ds_x2 - ds_x1 + 1; + + xstep = ds_xstep; + ystep = ds_ystep; + + uint32_t light = calc_light_multiplier(ds_light); + if (ds_xbits == 6 && ds_ybits == 6) { // 64x64 is the most common case by far, so special case it. -#ifndef PALETTEOUTPUT #ifndef NO_SSE __m128i mlight = _mm_set_epi16(256, light, light, light, 256, light, light, light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; @@ -1589,14 +1989,14 @@ void R_DrawSpanP_C (void) // Lookup pixel from flat texture tile, // re-index using light/colormap. - __m128i fg = _mm_set_epi32(palette[p0], palette[p1], palette[p2], palette[p3]); + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); fg_hi = _mm_mullo_epi16(fg_hi, mlight); fg_hi = _mm_srli_epi16(fg_hi, 8); fg_lo = _mm_mullo_epi16(fg_lo, mlight); fg_lo = _mm_srli_epi16(fg_lo, 8); - fg = _mm_packus_epi16(fg_hi, fg_lo); + fg = _mm_packus_epi16(fg_lo, fg_hi); _mm_storeu_si128((__m128i*)dest, fg); // Next step in u,v. @@ -1604,21 +2004,16 @@ void R_DrawSpanP_C (void) } if (count == 0) return; -#endif #endif do { // Current texture index in u,v. - spot = ((xfrac>>(32-6-6))&(63*64)) + (yfrac>>(32-6)); + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); // Lookup pixel from flat texture tile, // re-index using light/colormap. -#ifndef PALETTEOUTPUT *dest++ = shade_pal_index(colormap[source[spot]], light); -#else - *dest++ = colormap[source[spot]]; -#endif // Next step in u,v. xfrac += xstep; @@ -1638,11 +2033,7 @@ void R_DrawSpanP_C (void) // Lookup pixel from flat texture tile, // re-index using light/colormap. -#ifndef PALETTEOUTPUT *dest++ = shade_pal_index(colormap[source[spot]], light); -#else - *dest++ = colormap[source[spot]]; -#endif // Next step in u,v. xfrac += xstep; @@ -1651,6 +2042,8 @@ void R_DrawSpanP_C (void) } } +#ifndef X86_ASM + // [RH] Draw a span with holes void R_DrawSpanMaskedP_C (void) { @@ -1664,10 +2057,6 @@ void R_DrawSpanMaskedP_C (void) int count; int spot; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(ds_light); -#endif - xfrac = ds_xfrac; yfrac = ds_yfrac; @@ -1689,11 +2078,7 @@ void R_DrawSpanMaskedP_C (void) texdata = source[spot]; if (texdata != 0) { -#ifndef PALETTEOUTPUT - *dest = shade_pal_index(colormap[texdata], light); -#else *dest = colormap[texdata]; -#endif } dest++; xfrac += xstep; @@ -1713,11 +2098,7 @@ void R_DrawSpanMaskedP_C (void) texdata = source[spot]; if (texdata != 0) { -#ifndef PALETTEOUTPUT - *dest = shade_pal_index(colormap[texdata], light); -#else *dest = colormap[texdata]; -#endif } dest++; xfrac += xstep; @@ -1727,6 +2108,71 @@ void R_DrawSpanMaskedP_C (void) } #endif +void R_DrawSpanMaskedP_RGBA_C() +{ + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + canvas_pixel_t* dest; + const BYTE* source = ds_source; + const BYTE* colormap = ds_colormap; + int count; + int spot; + + uint32_t light = calc_light_multiplier(ds_light); + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + + dest = ylookup[ds_y] + ds_x1 + dc_destorg; + + count = ds_x2 - ds_x1 + 1; + + xstep = ds_xstep; + ystep = ds_ystep; + + if (ds_xbits == 6 && ds_ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + BYTE texdata; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + texdata = source[spot]; + if (texdata != 0) + { + *dest = shade_pal_index(colormap[texdata], light); + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + do + { + BYTE texdata; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + texdata = source[spot]; + if (texdata != 0) + { + *dest = shade_pal_index(colormap[texdata], light); + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } +} + + void R_DrawSpanTranslucentP_C (void) { dsfixed_t xfrac; @@ -1756,7 +2202,68 @@ void R_DrawSpanTranslucentP_C (void) if (ds_xbits == 6 && ds_ybits == 6) { // 64x64 is the most common case by far, so special case it. -#ifndef PALETTEOUTPUT + do + { + spot = ((xfrac>>(32-6-6))&(63*64)) + (yfrac>>(32-6)); + DWORD fg = colormap[source[spot]]; + DWORD bg = *dest; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg+bg) | 0x1f07c1f; + *dest++ = RGB32k.All[fg & (fg>>15)]; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + do + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + DWORD fg = colormap[source[spot]]; + DWORD bg = *dest; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg+bg) | 0x1f07c1f; + *dest++ = RGB32k.All[fg & (fg>>15)]; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } +} + +void R_DrawSpanTranslucentP_RGBA_C() +{ + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + canvas_pixel_t* dest; + const BYTE* source = ds_source; + const BYTE* colormap = ds_colormap; + int count; + int spot; + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + + dest = ylookup[ds_y] + ds_x1 + dc_destorg; + + count = ds_x2 - ds_x1 + 1; + + xstep = ds_xstep; + ystep = ds_ystep; + + uint32_t light = calc_light_multiplier(ds_light); + + if (ds_xbits == 6 && ds_ybits == 6) + { + // 64x64 is the most common case by far, so special case it. do { spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); @@ -1779,24 +2286,9 @@ void R_DrawSpanTranslucentP_C (void) xfrac += xstep; yfrac += ystep; } while (--count); -#else - do - { - spot = ((xfrac>>(32-6-6))&(63*64)) + (yfrac>>(32-6)); - DWORD fg = colormap[source[spot]]; - DWORD bg = *dest; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - *dest++ = RGB32k.All[fg & (fg>>15)]; - xfrac += xstep; - yfrac += ystep; - } while (--count); -#endif } else { -#ifndef PALETTEOUTPUT BYTE yshift = 32 - ds_ybits; BYTE xshift = yshift - ds_xbits; int xmask = ((1 << ds_xbits) - 1) << ds_ybits; @@ -1822,23 +2314,6 @@ void R_DrawSpanTranslucentP_C (void) xfrac += xstep; yfrac += ystep; } while (--count); -#else - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; - do - { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - DWORD fg = colormap[source[spot]]; - DWORD bg = *dest; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - *dest++ = RGB32k.All[fg & (fg>>15)]; - xfrac += xstep; - yfrac += ystep; - } while (--count); -#endif } } @@ -1879,29 +2354,12 @@ void R_DrawSpanMaskedTranslucentP_C (void) texdata = source[spot]; if (texdata != 0) { -#ifndef PALETTEOUTPUT - uint32_t fg = shade_pal_index(colormap[texdata], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; -#else DWORD fg = colormap[texdata]; DWORD bg = *dest; fg = fg2rgb[fg]; bg = bg2rgb[bg]; fg = (fg+bg) | 0x1f07c1f; *dest = RGB32k.All[fg & (fg>>15)]; -#endif } dest++; xfrac += xstep; @@ -1921,29 +2379,12 @@ void R_DrawSpanMaskedTranslucentP_C (void) texdata = source[spot]; if (texdata != 0) { -#ifndef PALETTEOUTPUT - uint32_t fg = shade_pal_index(colormap[texdata], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; -#else DWORD fg = colormap[texdata]; DWORD bg = *dest; fg = fg2rgb[fg]; bg = bg2rgb[bg]; fg = (fg+bg) | 0x1f07c1f; *dest = RGB32k.All[fg & (fg>>15)]; -#endif } dest++; xfrac += xstep; @@ -1952,7 +2393,7 @@ void R_DrawSpanMaskedTranslucentP_C (void) } } -void R_DrawSpanAddClampP_C (void) +void R_DrawSpanMaskedTranslucentP_RGBA_C() { dsfixed_t xfrac; dsfixed_t yfrac; @@ -1978,6 +2419,96 @@ void R_DrawSpanAddClampP_C (void) xstep = ds_xstep; ystep = ds_ystep; + if (ds_xbits == 6 && ds_ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + BYTE texdata; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t fg = shade_pal_index(colormap[texdata], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red + 1) / 2; + uint32_t green = (fg_green + bg_green + 1) / 2; + uint32_t blue = (fg_blue + bg_blue + 1) / 2; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + do + { + BYTE texdata; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t fg = shade_pal_index(colormap[texdata], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red + 1) / 2; + uint32_t green = (fg_green + bg_green + 1) / 2; + uint32_t blue = (fg_blue + bg_blue + 1) / 2; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } +} + +void R_DrawSpanAddClampP_C (void) +{ + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + canvas_pixel_t* dest; + const BYTE* source = ds_source; + const BYTE* colormap = ds_colormap; + int count; + int spot; + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + + dest = ylookup[ds_y] + ds_x1 + dc_destorg; + + count = ds_x2 - ds_x1 + 1; + + xstep = ds_xstep; + ystep = ds_ystep; + if (ds_xbits == 6 && ds_ybits == 6) { // 64x64 is the most common case by far, so special case it. @@ -1985,22 +2516,6 @@ void R_DrawSpanAddClampP_C (void) { spot = ((xfrac>>(32-6-6))&(63*64)) + (yfrac>>(32-6)); -#ifndef PALETTEOUTPUT - uint32_t fg = shade_pal_index(colormap[source[spot]], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); - - *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; -#else DWORD a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; DWORD b = a; @@ -2010,7 +2525,6 @@ void R_DrawSpanAddClampP_C (void) b = b - (b >> 5); a |= b; *dest++ = RGB32k.All[a & (a>>15)]; -#endif xfrac += xstep; yfrac += ystep; @@ -2025,7 +2539,55 @@ void R_DrawSpanAddClampP_C (void) { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); -#ifndef PALETTEOUTPUT + DWORD a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; + DWORD b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest++ = RGB32k.All[a & (a>>15)]; + + xfrac += xstep; + yfrac += ystep; + } while (--count); + } +} + +void R_DrawSpanAddClampP_RGBA_C() +{ + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + canvas_pixel_t* dest; + const BYTE* source = ds_source; + const BYTE* colormap = ds_colormap; + int count; + int spot; + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + + uint32_t light = calc_light_multiplier(ds_light); + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + + dest = ylookup[ds_y] + ds_x1 + dc_destorg; + + count = ds_x2 - ds_x1 + 1; + + xstep = ds_xstep; + ystep = ds_ystep; + + if (ds_xbits == 6 && ds_ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t fg = shade_pal_index(colormap[source[spot]], light); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; @@ -2040,17 +2602,34 @@ void R_DrawSpanAddClampP_C (void) uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; -#else - DWORD a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; - DWORD b = a; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest++ = RGB32k.All[a & (a>>15)]; -#endif + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + do + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + + uint32_t fg = shade_pal_index(colormap[source[spot]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; xfrac += xstep; yfrac += ystep; @@ -2095,22 +2674,6 @@ void R_DrawSpanMaskedAddClampP_C (void) texdata = source[spot]; if (texdata != 0) { -#ifndef PALETTEOUTPUT - uint32_t fg = shade_pal_index(colormap[texdata], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; -#else DWORD a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; DWORD b = a; @@ -2120,7 +2683,6 @@ void R_DrawSpanMaskedAddClampP_C (void) b = b - (b >> 5); a |= b; *dest = RGB32k.All[a & (a>>15)]; -#endif } dest++; xfrac += xstep; @@ -2140,7 +2702,60 @@ void R_DrawSpanMaskedAddClampP_C (void) texdata = source[spot]; if (texdata != 0) { -#ifndef PALETTEOUTPUT + DWORD a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; + DWORD b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a>>15)]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } +} + +void R_DrawSpanMaskedAddClampP_RGBA_C() +{ + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + canvas_pixel_t* dest; + const BYTE* source = ds_source; + const BYTE* colormap = ds_colormap; + int count; + int spot; + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + + uint32_t light = calc_light_multiplier(ds_light); + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + + dest = ylookup[ds_y] + ds_x1 + dc_destorg; + + count = ds_x2 - ds_x1 + 1; + + xstep = ds_xstep; + ystep = ds_ystep; + + if (ds_xbits == 6 && ds_ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + BYTE texdata; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + texdata = source[spot]; + if (texdata != 0) + { uint32_t fg = shade_pal_index(colormap[texdata], light); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; @@ -2155,17 +2770,39 @@ void R_DrawSpanMaskedAddClampP_C (void) uint32_t blue = (fg_blue + bg_blue + 1) / 2; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; -#else - DWORD a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; - DWORD b = a; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + do + { + BYTE texdata; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[a & (a>>15)]; -#endif + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t fg = shade_pal_index(colormap[texdata], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red + 1) / 2; + uint32_t green = (fg_green + bg_green + 1) / 2; + uint32_t blue = (fg_blue + bg_blue + 1) / 2; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; } dest++; xfrac += xstep; @@ -2175,18 +2812,19 @@ void R_DrawSpanMaskedAddClampP_C (void) } // [RH] Just fill a span with a color -void R_FillSpan (void) +void R_FillSpan_C (void) +{ + memset (ylookup[ds_y] + ds_x1 + dc_destorg, ds_color, (ds_x2 - ds_x1 + 1)); +} + +void R_FillSpan_RGBA() { -#ifndef PALETTEOUTPUT canvas_pixel_t *dest = ylookup[ds_y] + ds_x1 + dc_destorg; int count = (ds_x2 - ds_x1 + 1); uint32_t light = calc_light_multiplier(ds_light); uint32_t color = shade_pal_index(ds_color, light); for (int i = 0; i < count; i++) dest[i] = color; -#else - memset (ylookup[ds_y] + ds_x1 + dc_destorg, ds_color, (ds_x2 - ds_x1 + 1) * sizeof(canvas_pixel_t)); -#endif } // Draw a voxel slab @@ -2383,17 +3021,33 @@ DWORD vlinec1 () int bits = vlinebits; int pitch = dc_pitch; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); + do + { + *dest = colormap[source[frac >> bits]]; + frac += fracstep; + dest += pitch; + } while (--count); + + return frac; +} #endif +DWORD vlinec1_RGBA() +{ + DWORD fracstep = dc_iscale; + DWORD frac = dc_texturefrac; + BYTE *colormap = dc_colormap; + int count = dc_count; + const BYTE *source = dc_source; + canvas_pixel_t *dest = dc_dest; + int bits = vlinebits; + int pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + do { -#ifndef PALETTEOUTPUT - *dest = shade_pal_index(colormap[source[frac>>bits]], light); -#else - *dest = colormap[source[frac >> bits]]; -#endif + *dest = shade_pal_index(colormap[source[frac >> bits]], light); frac += fracstep; dest += pitch; } while (--count); @@ -2401,6 +3055,7 @@ DWORD vlinec1 () return frac; } +#if !defined(X86_ASM) void vlinec4 () { canvas_pixel_t *dest = dc_dest; @@ -2408,23 +3063,37 @@ void vlinec4 () int bits = vlinebits; DWORD place; -#ifndef PALETTEOUTPUT + do + { + dest[0] = palookupoffse[0][bufplce[0][(place=vplce[0])>>bits]]; vplce[0] = place+vince[0]; + dest[1] = palookupoffse[1][bufplce[1][(place=vplce[1])>>bits]]; vplce[1] = place+vince[1]; + dest[2] = palookupoffse[2][bufplce[2][(place=vplce[2])>>bits]]; vplce[2] = place+vince[2]; + dest[3] = palookupoffse[3][bufplce[3][(place=vplce[3])>>bits]]; vplce[3] = place+vince[3]; + dest += dc_pitch; + } while (--count); +} +#endif + +void vlinec4_RGBA() +{ + canvas_pixel_t *dest = dc_dest; + int count = dc_count; + int bits = vlinebits; + uint32_t light0 = calc_light_multiplier(palookuplight[0]); uint32_t light1 = calc_light_multiplier(palookuplight[1]); uint32_t light2 = calc_light_multiplier(palookuplight[2]); uint32_t light3 = calc_light_multiplier(palookuplight[3]); #ifndef NO_SSE - __m128i mlight_hi = _mm_set_epi16(256, light0, light0, light0, 256, light1, light1, light1); - __m128i mlight_lo = _mm_set_epi16(256, light2, light2, light2, 256, light3, light3, light3); + __m128i mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); + __m128i mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); uint32_t *palette = (uint32_t*)GPalette.BaseColors; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; -#endif #endif do { -#ifndef PALETTEOUTPUT #ifndef NO_SSE DWORD place0 = local_vplce[0]; @@ -2442,14 +3111,14 @@ void vlinec4 () local_vplce[2] = place2 + local_vince[2]; local_vplce[3] = place3 + local_vince[3]; - __m128i fg = _mm_set_epi32(palette[p0], palette[p1], palette[p2], palette[p3]); + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); fg_hi = _mm_mullo_epi16(fg_hi, mlight_hi); fg_hi = _mm_srli_epi16(fg_hi, 8); fg_lo = _mm_mullo_epi16(fg_lo, mlight_lo); fg_lo = _mm_srli_epi16(fg_lo, 8); - fg = _mm_packus_epi16(fg_hi, fg_lo); + fg = _mm_packus_epi16(fg_lo, fg_hi); _mm_storeu_si128((__m128i*)dest, fg); #else @@ -2457,17 +3126,10 @@ void vlinec4 () dest[1] = shade_pal_index(palookupoffse[1][bufplce[1][(place = vplce[1]) >> bits]], light1); vplce[1] = place + vince[1]; dest[2] = shade_pal_index(palookupoffse[2][bufplce[2][(place = vplce[2]) >> bits]], light2); vplce[2] = place + vince[2]; dest[3] = shade_pal_index(palookupoffse[3][bufplce[3][(place = vplce[3]) >> bits]], light3); vplce[3] = place + vince[3]; -#endif -#else - dest[0] = palookupoffse[0][bufplce[0][(place=vplce[0])>>bits]]; vplce[0] = place+vince[0]; - dest[1] = palookupoffse[1][bufplce[1][(place=vplce[1])>>bits]]; vplce[1] = place+vince[1]; - dest[2] = palookupoffse[2][bufplce[2][(place=vplce[2])>>bits]]; vplce[2] = place+vince[2]; - dest[3] = palookupoffse[3][bufplce[3][(place=vplce[3])>>bits]]; vplce[3] = place+vince[3]; #endif dest += dc_pitch; } while (--count); -#ifndef PALETTEOUTPUT #ifndef NO_SSE // Is this needed? Global variables makes it tricky to know.. vplce[0] = local_vplce[0]; @@ -2479,9 +3141,7 @@ void vlinec4 () vince[2] = local_vince[2]; vince[3] = local_vince[3]; #endif -#endif } -#endif void setupmvline (int fracbits) { @@ -2506,20 +3166,40 @@ DWORD mvlinec1 () int bits = mvlinebits; int pitch = dc_pitch; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); -#endif - do { BYTE pix = source[frac>>bits]; if (pix != 0) { -#ifndef PALETTEOUTPUT - *dest = shade_pal_index(colormap[pix], light); -#else *dest = colormap[pix]; + } + frac += fracstep; + dest += pitch; + } while (--count); + + return frac; +} #endif + +DWORD mvlinec1_RGBA() +{ + DWORD fracstep = dc_iscale; + DWORD frac = dc_texturefrac; + BYTE *colormap = dc_colormap; + int count = dc_count; + const BYTE *source = dc_source; + canvas_pixel_t *dest = dc_dest; + int bits = mvlinebits; + int pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + + do + { + BYTE pix = source[frac >> bits]; + if (pix != 0) + { + *dest = shade_pal_index(colormap[pix], light); } frac += fracstep; dest += pitch; @@ -2528,6 +3208,7 @@ DWORD mvlinec1 () return frac; } +#if !defined(X86_ASM) void mvlinec4 () { canvas_pixel_t *dest = dc_dest; @@ -2535,33 +3216,42 @@ void mvlinec4 () int bits = mvlinebits; DWORD place; -#ifndef PALETTEOUTPUT - uint32_t light0 = calc_light_multiplier(palookuplight[0]); - uint32_t light1 = calc_light_multiplier(palookuplight[1]); - uint32_t light2 = calc_light_multiplier(palookuplight[2]); - uint32_t light3 = calc_light_multiplier(palookuplight[3]); -#endif - do { BYTE pix; - -#ifndef PALETTEOUTPUT - pix = bufplce[0][(place = vplce[0]) >> bits]; if (pix) dest[0] = shade_pal_index(palookupoffse[0][pix], light0); vplce[0] = place + vince[0]; - pix = bufplce[1][(place = vplce[1]) >> bits]; if (pix) dest[1] = shade_pal_index(palookupoffse[1][pix], light1); vplce[1] = place + vince[1]; - pix = bufplce[2][(place = vplce[2]) >> bits]; if (pix) dest[2] = shade_pal_index(palookupoffse[2][pix], light2); vplce[2] = place + vince[2]; - pix = bufplce[3][(place = vplce[3]) >> bits]; if (pix) dest[3] = shade_pal_index(palookupoffse[3][pix], light3); vplce[3] = place + vince[3]; -#else pix = bufplce[0][(place=vplce[0])>>bits]; if(pix) dest[0] = palookupoffse[0][pix]; vplce[0] = place+vince[0]; pix = bufplce[1][(place=vplce[1])>>bits]; if(pix) dest[1] = palookupoffse[1][pix]; vplce[1] = place+vince[1]; pix = bufplce[2][(place=vplce[2])>>bits]; if(pix) dest[2] = palookupoffse[2][pix]; vplce[2] = place+vince[2]; pix = bufplce[3][(place=vplce[3])>>bits]; if(pix) dest[3] = palookupoffse[3][pix]; vplce[3] = place+vince[3]; -#endif dest += dc_pitch; } while (--count); } #endif +void mvlinec4_RGBA() +{ + canvas_pixel_t *dest = dc_dest; + int count = dc_count; + int bits = mvlinebits; + DWORD place; + + uint32_t light0 = calc_light_multiplier(palookuplight[0]); + uint32_t light1 = calc_light_multiplier(palookuplight[1]); + uint32_t light2 = calc_light_multiplier(palookuplight[2]); + uint32_t light3 = calc_light_multiplier(palookuplight[3]); + + do + { + BYTE pix; + pix = bufplce[0][(place = vplce[0]) >> bits]; if (pix) dest[0] = shade_pal_index(palookupoffse[0][pix], light0); vplce[0] = place + vince[0]; + pix = bufplce[1][(place = vplce[1]) >> bits]; if (pix) dest[1] = shade_pal_index(palookupoffse[1][pix], light1); vplce[1] = place + vince[1]; + pix = bufplce[2][(place = vplce[2]) >> bits]; if (pix) dest[2] = shade_pal_index(palookupoffse[2][pix], light2); vplce[2] = place + vince[2]; + pix = bufplce[3][(place = vplce[3]) >> bits]; if (pix) dest[3] = shade_pal_index(palookupoffse[3][pix], light3); vplce[3] = place + vince[3]; + dest += dc_pitch; + } while (--count); +} + + extern "C" short spanend[MAXHEIGHT]; extern float rw_light; extern float rw_lightstep; @@ -2572,21 +3262,13 @@ static void R_DrawFogBoundarySection (int y, int y2, int x1) BYTE *colormap = dc_colormap; canvas_pixel_t *dest = ylookup[y] + dc_destorg; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); -#endif - for (; y < y2; ++y) { int x2 = spanend[y]; int x = x1; do { -#ifndef PALETTEOUTPUT - dest[x] = shade_pal_index(colormap[dest[x]], light); -#else dest[x] = colormap[dest[x]]; -#endif } while (++x <= x2); dest += dc_pitch; } @@ -2598,21 +3280,13 @@ static void R_DrawFogBoundaryLine (int y, int x) BYTE *colormap = dc_colormap; canvas_pixel_t *dest = ylookup[y] + dc_destorg; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); -#endif - do { -#ifndef PALETTEOUTPUT - dest[x] = shade_pal_index(colormap[dest[x]], light); -#else dest[x] = colormap[dest[x]]; -#endif } while (++x <= x2); } -void R_DrawFogBoundary (int x1, int x2, short *uclip, short *dclip) +void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip) { // This is essentially the same as R_MapVisPlane but with an extra step // to create new horizontal spans whenever the light changes enough that @@ -2703,6 +3377,133 @@ void R_DrawFogBoundary (int x1, int x2, short *uclip, short *dclip) } } +static void R_DrawFogBoundarySection_RGBA(int y, int y2, int x1) +{ + BYTE *colormap = dc_colormap; + canvas_pixel_t *dest = ylookup[y] + dc_destorg; + + uint32_t light = calc_light_multiplier(dc_light); + + for (; y < y2; ++y) + { + int x2 = spanend[y]; + int x = x1; + do + { + dest[x] = shade_pal_index(colormap[dest[x]], light); + } while (++x <= x2); + dest += dc_pitch; + } +} + +static void R_DrawFogBoundaryLine_RGBA(int y, int x) +{ + int x2 = spanend[y]; + BYTE *colormap = dc_colormap; + canvas_pixel_t *dest = ylookup[y] + dc_destorg; + + uint32_t light = calc_light_multiplier(dc_light); + + do + { + dest[x] = shade_pal_index(colormap[dest[x]], light); + } while (++x <= x2); +} + +void R_DrawFogBoundary_RGBA(int x1, int x2, short *uclip, short *dclip) +{ + // To do: we do not need to create new spans when using rgba output - instead we should calculate light on a per pixel basis + + // This is essentially the same as R_MapVisPlane but with an extra step + // to create new horizontal spans whenever the light changes enough that + // we need to use a new colormap. + + double lightstep = rw_lightstep; + double light = rw_light + rw_lightstep*(x2 - x1 - 1); + int x = x2 - 1; + int t2 = uclip[x]; + int b2 = dclip[x]; + int rcolormap = GETPALOOKUP(light, wallshade); + int lcolormap; + BYTE *basecolormapdata = basecolormap->Maps; + + if (b2 > t2) + { + clearbufshort(spanend + t2, b2 - t2, x); + } + + dc_colormap = basecolormapdata + (rcolormap << COLORMAPSHIFT); + dc_light = 0; + + for (--x; x >= x1; --x) + { + int t1 = uclip[x]; + int b1 = dclip[x]; + const int xr = x + 1; + int stop; + + light -= rw_lightstep; + lcolormap = GETPALOOKUP(light, wallshade); + if (lcolormap != rcolormap) + { + if (t2 < b2 && rcolormap != 0) + { // Colormap 0 is always the identity map, so rendering it is + // just a waste of time. + R_DrawFogBoundarySection_RGBA(t2, b2, xr); + } + if (t1 < t2) t2 = t1; + if (b1 > b2) b2 = b1; + if (t2 < b2) + { + clearbufshort(spanend + t2, b2 - t2, x); + } + rcolormap = lcolormap; + dc_colormap = basecolormapdata + (lcolormap << COLORMAPSHIFT); + dc_light = 0; + } + else + { + if (dc_colormap != basecolormapdata) + { + stop = MIN(t1, b2); + while (t2 < stop) + { + R_DrawFogBoundaryLine_RGBA(t2++, xr); + } + stop = MAX(b1, t2); + while (b2 > stop) + { + R_DrawFogBoundaryLine_RGBA(--b2, xr); + } + } + else + { + t2 = MAX(t2, MIN(t1, b2)); + b2 = MIN(b2, MAX(b1, t2)); + } + + stop = MIN(t2, b1); + while (t1 < stop) + { + spanend[t1++] = x; + } + stop = MAX(b2, t2); + while (b1 > stop) + { + spanend[--b1] = x; + } + } + + t2 = uclip[x]; + b2 = dclip[x]; + } + if (t2 < b2 && rcolormap != 0) + { + R_DrawFogBoundarySection_RGBA(t2, b2, x1); + } +} + + int tmvlinebits; void setuptmvline (int bits) @@ -2710,7 +3511,40 @@ void setuptmvline (int bits) tmvlinebits = bits; } -fixed_t tmvline1_add () +fixed_t tmvline1_add_C () +{ + DWORD fracstep = dc_iscale; + DWORD frac = dc_texturefrac; + BYTE *colormap = dc_colormap; + int count = dc_count; + const BYTE *source = dc_source; + canvas_pixel_t *dest = dc_dest; + int bits = tmvlinebits; + int pitch = dc_pitch; + + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + + uint32_t light = calc_light_multiplier(dc_light); + + do + { + BYTE pix = source[frac>>bits]; + if (pix != 0) + { + DWORD fg = fg2rgb[colormap[pix]]; + DWORD bg = bg2rgb[*dest]; + fg = (fg+bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg>>15)]; + } + frac += fracstep; + dest += pitch; + } while (--count); + + return frac; +} + +fixed_t tmvline1_add_RGBA() { DWORD fracstep = dc_iscale; DWORD frac = dc_texturefrac; @@ -2728,7 +3562,6 @@ fixed_t tmvline1_add () do { -#ifndef PALETTEOUTPUT BYTE pix = source[frac >> bits]; if (pix != 0) { @@ -2747,16 +3580,6 @@ fixed_t tmvline1_add () *dest = 0xff000000 | (red << 16) | (green << 8) | blue; } -#else - BYTE pix = source[frac>>bits]; - if (pix != 0) - { - DWORD fg = fg2rgb[colormap[pix]]; - DWORD bg = bg2rgb[*dest]; - fg = (fg+bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg>>15)]; - } -#endif frac += fracstep; dest += pitch; } while (--count); @@ -2764,7 +3587,40 @@ fixed_t tmvline1_add () return frac; } -void tmvline4_add () +void tmvline4_add_C () +{ + canvas_pixel_t *dest = dc_dest; + int count = dc_count; + int bits = tmvlinebits; + + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + + uint32_t light[4]; + light[0] = calc_light_multiplier(palookuplight[0]); + light[1] = calc_light_multiplier(palookuplight[1]); + light[2] = calc_light_multiplier(palookuplight[2]); + light[3] = calc_light_multiplier(palookuplight[3]); + + do + { + for (int i = 0; i < 4; ++i) + { + BYTE pix = bufplce[i][vplce[i] >> bits]; + if (pix != 0) + { + DWORD fg = fg2rgb[palookupoffse[i][pix]]; + DWORD bg = bg2rgb[dest[i]]; + fg = (fg+bg) | 0x1f07c1f; + dest[i] = RGB32k.All[fg & (fg>>15)]; + } + vplce[i] += vince[i]; + } + dest += dc_pitch; + } while (--count); +} + +void tmvline4_add_RGBA() { canvas_pixel_t *dest = dc_dest; int count = dc_count; @@ -2786,7 +3642,6 @@ void tmvline4_add () BYTE pix = bufplce[i][vplce[i] >> bits]; if (pix != 0) { -#ifndef PALETTEOUTPUT uint32_t fg = shade_pal_index(palookupoffse[i][pix], light[i]); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; @@ -2801,12 +3656,6 @@ void tmvline4_add () uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; -#else - DWORD fg = fg2rgb[palookupoffse[i][pix]]; - DWORD bg = bg2rgb[dest[i]]; - fg = (fg+bg) | 0x1f07c1f; - dest[i] = RGB32k.All[fg & (fg>>15)]; -#endif } vplce[i] += vince[i]; } @@ -2814,7 +3663,7 @@ void tmvline4_add () } while (--count); } -fixed_t tmvline1_addclamp () +fixed_t tmvline1_addclamp_C () { DWORD fracstep = dc_iscale; DWORD frac = dc_texturefrac; @@ -2835,7 +3684,44 @@ fixed_t tmvline1_addclamp () BYTE pix = source[frac>>bits]; if (pix != 0) { -#ifndef PALETTEOUTPUT + DWORD a = fg2rgb[colormap[pix]] + bg2rgb[*dest]; + DWORD b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a>>15)]; + } + frac += fracstep; + dest += pitch; + } while (--count); + + return frac; +} + +fixed_t tmvline1_addclamp_RGBA() +{ + DWORD fracstep = dc_iscale; + DWORD frac = dc_texturefrac; + BYTE *colormap = dc_colormap; + int count = dc_count; + const BYTE *source = dc_source; + canvas_pixel_t *dest = dc_dest; + int bits = tmvlinebits; + int pitch = dc_pitch; + + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + + uint32_t light = calc_light_multiplier(dc_light); + + do + { + BYTE pix = source[frac >> bits]; + if (pix != 0) + { uint32_t fg = shade_pal_index(colormap[pix], light); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; @@ -2850,17 +3736,6 @@ fixed_t tmvline1_addclamp () uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); *dest = 0xff000000 | (red << 16) | (green << 8) | blue; -#else - DWORD a = fg2rgb[colormap[pix]] + bg2rgb[*dest]; - DWORD b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[a & (a>>15)]; -#endif } frac += fracstep; dest += pitch; @@ -2869,7 +3744,7 @@ fixed_t tmvline1_addclamp () return frac; } -void tmvline4_addclamp () +void tmvline4_addclamp_C () { canvas_pixel_t *dest = dc_dest; int count = dc_count; @@ -2878,6 +3753,35 @@ void tmvline4_addclamp () DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; + do + { + for (int i = 0; i < 4; ++i) + { + BYTE pix = bufplce[i][vplce[i] >> bits]; + if (pix != 0) + { + DWORD a = fg2rgb[palookupoffse[i][pix]] + bg2rgb[dest[i]]; + DWORD b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + dest[i] = RGB32k.All[a & (a>>15)]; + } + vplce[i] += vince[i]; + } + dest += dc_pitch; + } while (--count); +} + +void tmvline4_addclamp_RGBA() +{ + canvas_pixel_t *dest = dc_dest; + int count = dc_count; + int bits = tmvlinebits; + uint32_t light[4]; light[0] = calc_light_multiplier(palookuplight[0]); light[1] = calc_light_multiplier(palookuplight[1]); @@ -2891,7 +3795,6 @@ void tmvline4_addclamp () BYTE pix = bufplce[i][vplce[i] >> bits]; if (pix != 0) { -#ifndef PALETTEOUTPUT uint32_t fg = shade_pal_index(palookupoffse[i][pix], light[i]); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; @@ -2906,17 +3809,6 @@ void tmvline4_addclamp () uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; -#else - DWORD a = fg2rgb[palookupoffse[i][pix]] + bg2rgb[dest[i]]; - DWORD b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[i] = RGB32k.All[a & (a>>15)]; -#endif } vplce[i] += vince[i]; } @@ -2924,7 +3816,7 @@ void tmvline4_addclamp () } while (--count); } -fixed_t tmvline1_subclamp () +fixed_t tmvline1_subclamp_C () { DWORD fracstep = dc_iscale; DWORD frac = dc_texturefrac; @@ -2938,14 +3830,45 @@ fixed_t tmvline1_subclamp () DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; - uint32_t light = calc_light_multiplier(dc_light); - do { BYTE pix = source[frac>>bits]; if (pix != 0) { -#ifndef PALETTEOUTPUT + DWORD a = (fg2rgb[colormap[pix]] | 0x40100400) - bg2rgb[*dest]; + DWORD b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a>>15)]; + } + frac += fracstep; + dest += pitch; + } while (--count); + + return frac; +} + +fixed_t tmvline1_subclamp_RGBA() +{ + DWORD fracstep = dc_iscale; + DWORD frac = dc_texturefrac; + BYTE *colormap = dc_colormap; + int count = dc_count; + const BYTE *source = dc_source; + canvas_pixel_t *dest = dc_dest; + int bits = tmvlinebits; + int pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + + do + { + BYTE pix = source[frac >> bits]; + if (pix != 0) + { uint32_t fg = shade_pal_index(colormap[pix], light); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; @@ -2960,16 +3883,6 @@ fixed_t tmvline1_subclamp () uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; -#else - DWORD a = (fg2rgb[colormap[pix]] | 0x40100400) - bg2rgb[*dest]; - DWORD b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a>>15)]; -#endif } frac += fracstep; dest += pitch; @@ -2978,7 +3891,7 @@ fixed_t tmvline1_subclamp () return frac; } -void tmvline4_subclamp () +void tmvline4_subclamp_C () { canvas_pixel_t *dest = dc_dest; int count = dc_count; @@ -2987,6 +3900,34 @@ void tmvline4_subclamp () DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; + do + { + for (int i = 0; i < 4; ++i) + { + BYTE pix = bufplce[i][vplce[i] >> bits]; + if (pix != 0) + { + DWORD a = (fg2rgb[palookupoffse[i][pix]] | 0x40100400) - bg2rgb[dest[i]]; + DWORD b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[i] = RGB32k.All[a & (a>>15)]; + } + vplce[i] += vince[i]; + } + dest += dc_pitch; + } while (--count); +} + +void tmvline4_subclamp_RGBA() +{ + canvas_pixel_t *dest = dc_dest; + int count = dc_count; + int bits = tmvlinebits; + uint32_t light[4]; light[0] = calc_light_multiplier(palookuplight[0]); light[1] = calc_light_multiplier(palookuplight[1]); @@ -3000,7 +3941,6 @@ void tmvline4_subclamp () BYTE pix = bufplce[i][vplce[i] >> bits]; if (pix != 0) { -#ifndef PALETTEOUTPUT uint32_t fg = shade_pal_index(palookupoffse[i][pix], light[i]); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; @@ -3015,16 +3955,6 @@ void tmvline4_subclamp () uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; -#else - DWORD a = (fg2rgb[palookupoffse[i][pix]] | 0x40100400) - bg2rgb[dest[i]]; - DWORD b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[i] = RGB32k.All[a & (a>>15)]; -#endif } vplce[i] += vince[i]; } @@ -3032,7 +3962,7 @@ void tmvline4_subclamp () } while (--count); } -fixed_t tmvline1_revsubclamp () +fixed_t tmvline1_revsubclamp_C () { DWORD fracstep = dc_iscale; DWORD frac = dc_texturefrac; @@ -3046,14 +3976,45 @@ fixed_t tmvline1_revsubclamp () DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; - uint32_t light = calc_light_multiplier(dc_light); - do { BYTE pix = source[frac>>bits]; if (pix != 0) { -#ifndef PALETTEOUTPUT + DWORD a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[pix]]; + DWORD b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a>>15)]; + } + frac += fracstep; + dest += pitch; + } while (--count); + + return frac; +} + +fixed_t tmvline1_revsubclamp_RGBA() +{ + DWORD fracstep = dc_iscale; + DWORD frac = dc_texturefrac; + BYTE *colormap = dc_colormap; + int count = dc_count; + const BYTE *source = dc_source; + canvas_pixel_t *dest = dc_dest; + int bits = tmvlinebits; + int pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + + do + { + BYTE pix = source[frac >> bits]; + if (pix != 0) + { uint32_t fg = shade_pal_index(colormap[pix], light); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; @@ -3068,16 +4029,6 @@ fixed_t tmvline1_revsubclamp () uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; -#else - DWORD a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[pix]]; - DWORD b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a>>15)]; -#endif } frac += fracstep; dest += pitch; @@ -3086,7 +4037,38 @@ fixed_t tmvline1_revsubclamp () return frac; } -void tmvline4_revsubclamp () +void tmvline4_revsubclamp_C () +{ + canvas_pixel_t *dest = dc_dest; + int count = dc_count; + int bits = tmvlinebits; + + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + + do + { + for (int i = 0; i < 4; ++i) + { + BYTE pix = bufplce[i][vplce[i] >> bits]; + if (pix != 0) + { + DWORD a = (bg2rgb[dest[i]] | 0x40100400) - fg2rgb[palookupoffse[i][pix]]; + DWORD b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[i] = RGB32k.All[a & (a>>15)]; + } + vplce[i] += vince[i]; + } + dest += dc_pitch; + } while (--count); +} + +void tmvline4_revsubclamp_RGBA() { canvas_pixel_t *dest = dc_dest; int count = dc_count; @@ -3108,7 +4090,6 @@ void tmvline4_revsubclamp () BYTE pix = bufplce[i][vplce[i] >> bits]; if (pix != 0) { -#ifndef PALETTEOUTPUT uint32_t fg = shade_pal_index(palookupoffse[i][pix], light[i]); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; @@ -3123,16 +4104,6 @@ void tmvline4_revsubclamp () uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; -#else - DWORD a = (bg2rgb[dest[i]] | 0x40100400) - fg2rgb[palookupoffse[i][pix]]; - DWORD b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[i] = RGB32k.All[a & (a>>15)]; -#endif } vplce[i] += vince[i]; } @@ -3164,6 +4135,85 @@ const BYTE *R_GetColumn (FTexture *tex, int col) // [RH] Initialize the column drawer pointers void R_InitColumnDrawers () { +#ifndef PALETTEOUTPUT + + R_DrawColumnHoriz = R_DrawColumnHorizP_RGBA_C; + R_DrawColumn = R_DrawColumnP_RGBA_C; + R_DrawFuzzColumn = R_DrawFuzzColumnP_RGBA_C; + R_DrawTranslatedColumn = R_DrawTranslatedColumnP_RGBA_C; + R_DrawShadedColumn = R_DrawShadedColumnP_RGBA_C; + R_DrawSpan = R_DrawSpanP_RGBA_C; + R_DrawSpanMasked = R_DrawSpanMaskedP_RGBA_C; + rt_map4cols = rt_map4cols_RGBA_c; + + R_DrawSpanTranslucent = R_DrawSpanTranslucentP_RGBA_C; + R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucentP_RGBA_C; + R_DrawSpanAddClamp = R_DrawSpanAddClampP_RGBA_C; + R_DrawSpanMaskedAddClamp = R_DrawSpanMaskedAddClampP_RGBA_C; + R_FillColumn = R_FillColumnP_RGBA; + R_FillAddColumn = R_FillAddColumn_RGBA_C; + R_FillAddClampColumn = R_FillAddClampColumn_RGBA; + R_FillSubClampColumn = R_FillSubClampColumn_RGBA; + R_FillRevSubClampColumn = R_FillRevSubClampColumn_RGBA; + R_DrawAddColumn = R_DrawAddColumnP_RGBA_C; + R_DrawTlatedAddColumn = R_DrawTlatedAddColumnP_RGBA_C; + R_DrawAddClampColumn = R_DrawAddClampColumnP_RGBA_C; + R_DrawAddClampTranslatedColumn = R_DrawAddClampTranslatedColumnP_RGBA_C; + R_DrawSubClampColumn = R_DrawSubClampColumnP_RGBA_C; + R_DrawSubClampTranslatedColumn = R_DrawSubClampTranslatedColumnP_RGBA_C; + R_DrawRevSubClampColumn = R_DrawRevSubClampColumnP_RGBA_C; + R_DrawRevSubClampTranslatedColumn = R_DrawRevSubClampTranslatedColumnP_RGBA_C; + R_FillSpan = R_FillSpan_RGBA; + R_DrawFogBoundary = R_DrawFogBoundary_RGBA; + R_FillColumnHoriz = R_FillColumnHorizP_RGBA_C; + + R_DrawFogBoundary = R_DrawFogBoundary_RGBA; + R_MapColoredPlane = R_MapColoredPlane_RGBA; + R_DrawParticle = R_DrawParticle_RGBA; + + tmvline1_add = tmvline1_add_RGBA; + tmvline4_add = tmvline4_add_RGBA; + tmvline1_addclamp = tmvline1_addclamp_RGBA; + tmvline4_addclamp = tmvline4_addclamp_RGBA; + tmvline1_subclamp = tmvline1_subclamp_RGBA; + tmvline4_subclamp = tmvline4_subclamp_RGBA; + tmvline1_revsubclamp = tmvline1_revsubclamp_RGBA; + tmvline4_revsubclamp = tmvline4_revsubclamp_RGBA; + + rt_copy1col = rt_copy1col_RGBA_c; + rt_copy4cols = rt_copy4cols_RGBA_c; + rt_map1col = rt_map1col_RGBA_c; + rt_shaded4cols = rt_shaded4cols_RGBA_c; + rt_add4cols = rt_add4cols_RGBA_c; + rt_addclamp4cols = rt_addclamp4cols_RGBA_c; + rt_shaded1col = rt_shaded1col_RGBA_c; + rt_add1col = rt_add1col_RGBA_c; + rt_addclamp1col = rt_addclamp1col_RGBA_c; + rt_subclamp1col = rt_subclamp1col_RGBA_c; + rt_revsubclamp1col = rt_revsubclamp1col_RGBA_c; + rt_tlate1col = rt_tlate1col_RGBA_c; + rt_tlateadd1col = rt_tlateadd1col_RGBA_c; + rt_tlateaddclamp1col = rt_tlateaddclamp1col_RGBA_c; + rt_tlatesubclamp1col = rt_tlatesubclamp1col_RGBA_c; + rt_tlaterevsubclamp1col = rt_tlaterevsubclamp1col_RGBA_c; + rt_map4cols = rt_map4cols_RGBA_c; + rt_subclamp4cols = rt_subclamp4cols_RGBA_c; + rt_revsubclamp4cols = rt_revsubclamp4cols_RGBA_c; + rt_tlate4cols = rt_tlate4cols_RGBA_c; + rt_tlateadd4cols = rt_tlateadd4cols_RGBA_c; + rt_tlateaddclamp4cols = rt_tlateaddclamp4cols_RGBA_c; + rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_RGBA_c; + rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_RGBA_c; + rt_initcols = rt_initcols_rgba; + + dovline1 = vlinec1_RGBA; + doprevline1 = vlinec1_RGBA; + dovline4 = vlinec4_RGBA; + domvline1 = mvlinec1_RGBA; + domvline4 = mvlinec4_RGBA; + +#else + #ifdef X86_ASM R_DrawColumn = R_DrawColumnP_ASM; R_DrawColumnHoriz = R_DrawColumnHorizP_ASM; @@ -3194,6 +4244,72 @@ void R_InitColumnDrawers () R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucentP_C; R_DrawSpanAddClamp = R_DrawSpanAddClampP_C; R_DrawSpanMaskedAddClamp = R_DrawSpanMaskedAddClampP_C; + R_FillColumn = R_FillColumnP_C; + R_FillAddColumn = R_FillAddColumn_C; + R_FillAddClampColumn = R_FillAddClampColumn_C; + R_FillSubClampColumn = R_FillSubClampColumn_C; + R_FillRevSubClampColumn = R_FillRevSubClampColumn_C; + R_DrawAddColumn = R_DrawAddColumnP_C; + R_DrawTlatedAddColumn = R_DrawTlatedAddColumnP_C; + R_DrawAddClampColumn = R_DrawAddClampColumnP_C; + R_DrawAddClampTranslatedColumn = R_DrawAddClampTranslatedColumnP_C; + R_DrawSubClampColumn = R_DrawSubClampColumnP_C; + R_DrawSubClampTranslatedColumn = R_DrawSubClampTranslatedColumnP_C; + R_DrawRevSubClampColumn = R_DrawRevSubClampColumnP_C; + R_DrawRevSubClampTranslatedColumn = R_DrawRevSubClampTranslatedColumnP_C; + R_FillSpan = R_FillSpan_C; + R_DrawFogBoundary = R_DrawFogBoundary_C; + R_FillColumnHoriz = R_FillColumnHorizP_C; + + R_DrawFogBoundary = R_DrawFogBoundary_C; + R_MapColoredPlane = R_MapColoredPlane_C; + R_DrawParticle = R_DrawParticle_C; + + tmvline1_add = tmvline1_add_C; + tmvline4_add = tmvline4_add_C; + tmvline1_addclamp = tmvline1_addclamp_C; + tmvline4_addclamp = tmvline4_addclamp_C; + tmvline1_subclamp = tmvline1_subclamp_C; + tmvline4_subclamp = tmvline4_subclamp_C; + tmvline1_revsubclamp = tmvline1_revsubclamp_C; + tmvline4_revsubclamp = tmvline4_revsubclamp_C; + +#ifdef X86_ASM + rt_copy1col = rt_copy1col_asm; + rt_copy4cols = rt_copy4cols_asm; + rt_map1col = rt_map1col_asm; + rt_shaded4cols = rt_shaded4cols_asm; + rt_add4cols = rt_add4cols_asm; + rt_addclamp4cols = rt_addclamp4cols_asm; +#else + rt_copy1col = rt_copy1col_c; + rt_copy4cols = rt_copy4cols_c; + rt_map1col = rt_map1col_c; + rt_shaded4cols = rt_shaded4cols_c; + rt_add4cols = rt_add4cols_c; + rt_addclamp4cols = rt_addclamp4cols_c; +#endif + rt_shaded1col = rt_shaded1col_c; + rt_add1col = rt_add1col_c; + rt_addclamp1col = rt_addclamp1col_c; + rt_subclamp1col = rt_subclamp1col_c; + rt_revsubclamp1col = rt_revsubclamp1col_c; + rt_tlate1col = rt_tlate1col_c; + rt_tlateadd1col = rt_tlateadd1col_c; + rt_tlateaddclamp1col = rt_tlateaddclamp1col_c; + rt_tlatesubclamp1col = rt_tlatesubclamp1col_c; + rt_tlaterevsubclamp1col = rt_tlaterevsubclamp1col_c; + rt_map4cols = rt_map4cols_c; + rt_subclamp4cols = rt_subclamp4cols_c; + rt_revsubclamp4cols = rt_revsubclamp4cols_c; + rt_tlate4cols = rt_tlate4cols_c; + rt_tlateadd4cols = rt_tlateadd4cols_c; + rt_tlateaddclamp4cols = rt_tlateaddclamp4cols_c; + rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_c; + rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_c; + rt_initcols = rt_initcols_pal; + +#endif } // [RH] Choose column drawers in a single place @@ -3211,7 +4327,7 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) { if (flags & STYLEF_ColorIsFixed) { - colfunc = R_FillColumnP; + colfunc = R_FillColumn; hcolfunc_post1 = rt_copy1col; hcolfunc_post4 = rt_copy4cols; } @@ -3261,13 +4377,13 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) } else if (dc_translation == NULL) { - colfunc = R_DrawAddColumnP_C; + colfunc = R_DrawAddColumn; hcolfunc_post1 = rt_add1col; hcolfunc_post4 = rt_add4cols; } else { - colfunc = R_DrawTlatedAddColumnP_C; + colfunc = R_DrawTlatedAddColumn; hcolfunc_post1 = rt_tlateadd1col; hcolfunc_post4 = rt_tlateadd4cols; } @@ -3282,13 +4398,13 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) } else if (dc_translation == NULL) { - colfunc = R_DrawAddClampColumnP_C; + colfunc = R_DrawAddClampColumn; hcolfunc_post1 = rt_addclamp1col; hcolfunc_post4 = rt_addclamp4cols; } else { - colfunc = R_DrawAddClampTranslatedColumnP_C; + colfunc = R_DrawAddClampTranslatedColumn; hcolfunc_post1 = rt_tlateaddclamp1col; hcolfunc_post4 = rt_tlateaddclamp4cols; } @@ -3304,13 +4420,13 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) } else if (dc_translation == NULL) { - colfunc = R_DrawSubClampColumnP_C; + colfunc = R_DrawSubClampColumn; hcolfunc_post1 = rt_subclamp1col; hcolfunc_post4 = rt_subclamp4cols; } else { - colfunc = R_DrawSubClampTranslatedColumnP_C; + colfunc = R_DrawSubClampTranslatedColumn; hcolfunc_post1 = rt_tlatesubclamp1col; hcolfunc_post4 = rt_tlatesubclamp4cols; } @@ -3329,13 +4445,13 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) } else if (dc_translation == NULL) { - colfunc = R_DrawRevSubClampColumnP_C; + colfunc = R_DrawRevSubClampColumn; hcolfunc_post1 = rt_revsubclamp1col; hcolfunc_post4 = rt_revsubclamp4cols; } else { - colfunc = R_DrawRevSubClampTranslatedColumnP_C; + colfunc = R_DrawRevSubClampTranslatedColumn; hcolfunc_post1 = rt_tlaterevsubclamp1col; hcolfunc_post4 = rt_tlaterevsubclamp4cols; } @@ -3440,7 +4556,7 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, // dc_srccolor is used by the R_Fill* routines. It is premultiplied // with the alpha. dc_srccolor = ((((r*x)>>4)<<20) | ((g*x)>>4) | ((((b)*x)>>4)<<10)) & 0x3feffbff; - hcolfunc_pre = R_FillColumnHorizP; + hcolfunc_pre = R_FillColumnHoriz; dc_colormap = identitymap; dc_light = 0; } @@ -3459,25 +4575,25 @@ void R_FinishSetPatchStyle () bool R_GetTransMaskDrawers (fixed_t (**tmvline1)(), void (**tmvline4)()) { - if (colfunc == R_DrawAddColumnP_C) + if (colfunc == R_DrawAddColumn) { *tmvline1 = tmvline1_add; *tmvline4 = tmvline4_add; return true; } - if (colfunc == R_DrawAddClampColumnP_C) + if (colfunc == R_DrawAddClampColumn) { *tmvline1 = tmvline1_addclamp; *tmvline4 = tmvline4_addclamp; return true; } - if (colfunc == R_DrawSubClampColumnP_C) + if (colfunc == R_DrawSubClampColumn) { *tmvline1 = tmvline1_subclamp; *tmvline4 = tmvline4_subclamp; return true; } - if (colfunc == R_DrawRevSubClampColumnP_C) + if (colfunc == R_DrawRevSubClampColumn) { *tmvline1 = tmvline1_revsubclamp; *tmvline4 = tmvline4_revsubclamp; diff --git a/src/r_draw.h b/src/r_draw.h index 6f7a91154..17698c360 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -127,33 +127,33 @@ extern "C" void rt_copy1col_c (int hx, int sx, int yl, int yh); void rt_copy4cols_c (int sx, int yl, int yh); -void rt_shaded1col (int hx, int sx, int yl, int yh); +void rt_shaded1col_c (int hx, int sx, int yl, int yh); void rt_shaded4cols_c (int sx, int yl, int yh); void rt_shaded4cols_asm (int sx, int yl, int yh); void rt_map1col_c (int hx, int sx, int yl, int yh); -void rt_add1col (int hx, int sx, int yl, int yh); -void rt_addclamp1col (int hx, int sx, int yl, int yh); -void rt_subclamp1col (int hx, int sx, int yl, int yh); -void rt_revsubclamp1col (int hx, int sx, int yl, int yh); +void rt_add1col_c (int hx, int sx, int yl, int yh); +void rt_addclamp1col_c (int hx, int sx, int yl, int yh); +void rt_subclamp1col_c (int hx, int sx, int yl, int yh); +void rt_revsubclamp1col_c (int hx, int sx, int yl, int yh); -void rt_tlate1col (int hx, int sx, int yl, int yh); -void rt_tlateadd1col (int hx, int sx, int yl, int yh); -void rt_tlateaddclamp1col (int hx, int sx, int yl, int yh); -void rt_tlatesubclamp1col (int hx, int sx, int yl, int yh); -void rt_tlaterevsubclamp1col (int hx, int sx, int yl, int yh); +void rt_tlate1col_c (int hx, int sx, int yl, int yh); +void rt_tlateadd1col_c (int hx, int sx, int yl, int yh); +void rt_tlateaddclamp1col_c (int hx, int sx, int yl, int yh); +void rt_tlatesubclamp1col_c (int hx, int sx, int yl, int yh); +void rt_tlaterevsubclamp1col_c (int hx, int sx, int yl, int yh); void rt_map4cols_c (int sx, int yl, int yh); void rt_add4cols_c (int sx, int yl, int yh); void rt_addclamp4cols_c (int sx, int yl, int yh); -void rt_subclamp4cols (int sx, int yl, int yh); -void rt_revsubclamp4cols (int sx, int yl, int yh); +void rt_subclamp4cols_c (int sx, int yl, int yh); +void rt_revsubclamp4cols_c (int sx, int yl, int yh); -void rt_tlate4cols (int sx, int yl, int yh); -void rt_tlateadd4cols (int sx, int yl, int yh); -void rt_tlateaddclamp4cols (int sx, int yl, int yh); -void rt_tlatesubclamp4cols (int sx, int yl, int yh); -void rt_tlaterevsubclamp4cols (int sx, int yl, int yh); +void rt_tlate4cols_c (int sx, int yl, int yh); +void rt_tlateadd4cols_c (int sx, int yl, int yh); +void rt_tlateaddclamp4cols_c (int sx, int yl, int yh); +void rt_tlatesubclamp4cols_c (int sx, int yl, int yh); +void rt_tlaterevsubclamp4cols_c (int sx, int yl, int yh); void rt_copy1col_asm (int hx, int sx, int yl, int yh); void rt_map1col_asm (int hx, int sx, int yl, int yh); @@ -163,32 +163,83 @@ void rt_map4cols_asm1 (int sx, int yl, int yh); void rt_map4cols_asm2 (int sx, int yl, int yh); void rt_add4cols_asm (int sx, int yl, int yh); void rt_addclamp4cols_asm (int sx, int yl, int yh); + +/// + +void rt_copy1col_RGBA_c (int hx, int sx, int yl, int yh); +void rt_copy4cols_RGBA_c (int sx, int yl, int yh); + +void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh); +void rt_shaded4cols_RGBA_c (int sx, int yl, int yh); + +void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh); +void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh); +void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh); +void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh); +void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh); + +void rt_tlate1col_RGBA_c (int hx, int sx, int yl, int yh); +void rt_tlateadd1col_RGBA_c (int hx, int sx, int yl, int yh); +void rt_tlateaddclamp1col_RGBA_c (int hx, int sx, int yl, int yh); +void rt_tlatesubclamp1col_RGBA_c (int hx, int sx, int yl, int yh); +void rt_tlaterevsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh); + +void rt_map4cols_RGBA_c (int sx, int yl, int yh); +void rt_add4cols_RGBA_c (int sx, int yl, int yh); +void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh); +void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh); +void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh); + +void rt_tlate4cols_RGBA_c (int sx, int yl, int yh); +void rt_tlateadd4cols_RGBA_c (int sx, int yl, int yh); +void rt_tlateaddclamp4cols_RGBA_c (int sx, int yl, int yh); +void rt_tlatesubclamp4cols_RGBA_c (int sx, int yl, int yh); +void rt_tlaterevsubclamp4cols_RGBA_c (int sx, int yl, int yh); + } -extern void (*rt_map4cols)(int sx, int yl, int yh); +extern void (*rt_copy1col)(int hx, int sx, int yl, int yh); +extern void (*rt_copy4cols)(int sx, int yl, int yh); -#ifdef X86_ASM -#define rt_copy1col rt_copy1col_asm -#define rt_copy4cols rt_copy4cols_asm -#define rt_map1col rt_map1col_asm -#define rt_shaded4cols rt_shaded4cols_asm -#define rt_add4cols rt_add4cols_asm -#define rt_addclamp4cols rt_addclamp4cols_asm -#else -#define rt_copy1col rt_copy1col_c -#define rt_copy4cols rt_copy4cols_c -#define rt_map1col rt_map1col_c -#define rt_shaded4cols rt_shaded4cols_c -#define rt_add4cols rt_add4cols_c -#define rt_addclamp4cols rt_addclamp4cols_c -#endif +extern void (*rt_shaded1col)(int hx, int sx, int yl, int yh); +extern void (*rt_shaded4cols)(int sx, int yl, int yh); + +extern void (*rt_map1col)(int hx, int sx, int yl, int yh); +extern void (*rt_add1col)(int hx, int sx, int yl, int yh); +extern void (*rt_addclamp1col)(int hx, int sx, int yl, int yh); +extern void (*rt_subclamp1col)(int hx, int sx, int yl, int yh); +extern void (*rt_revsubclamp1col)(int hx, int sx, int yl, int yh); + +extern void (*rt_tlate1col)(int hx, int sx, int yl, int yh); +extern void (*rt_tlateadd1col)(int hx, int sx, int yl, int yh); +extern void (*rt_tlateaddclamp1col)(int hx, int sx, int yl, int yh); +extern void (*rt_tlatesubclamp1col)(int hx, int sx, int yl, int yh); +extern void (*rt_tlaterevsubclamp1col)(int hx, int sx, int yl, int yh); + +extern void (*rt_map4cols)(int sx, int yl, int yh); +extern void (*rt_add4cols)(int sx, int yl, int yh); +extern void (*rt_addclamp4cols)(int sx, int yl, int yh); +extern void (*rt_subclamp4cols)(int sx, int yl, int yh); +extern void (*rt_revsubclamp4cols)(int sx, int yl, int yh); + +extern void (*rt_tlate4cols)(int sx, int yl, int yh); +extern void (*rt_tlateadd4cols)(int sx, int yl, int yh); +extern void (*rt_tlateaddclamp4cols)(int sx, int yl, int yh); +extern void (*rt_tlatesubclamp4cols)(int sx, int yl, int yh); +extern void (*rt_tlaterevsubclamp4cols)(int sx, int yl, int yh); + +extern void (*rt_initcols)(canvas_pixel_t *buffer); void rt_draw4cols (int sx); // [RH] Preps the temporary horizontal buffer. -void rt_initcols (canvas_pixel_t *buffer=NULL); +void rt_initcols_pal (canvas_pixel_t *buffer); +void rt_initcols_rgba (canvas_pixel_t *buffer); -void R_DrawFogBoundary (int x1, int x2, short *uclip, short *dclip); + +extern void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); + +void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip); #ifdef X86_ASM @@ -212,6 +263,14 @@ void R_DrawShadedColumnP_C (void); void R_DrawSpanP_C (void); void R_DrawSpanMaskedP_C (void); +void R_DrawColumnHorizP_RGBA_C (void); +void R_DrawColumnP_RGBA_C (void); +void R_DrawFuzzColumnP_RGBA_C (void); +void R_DrawTranslatedColumnP_RGBA_C (void); +void R_DrawShadedColumnP_RGBA_C (void); +void R_DrawSpanP_RGBA_C (void); +void R_DrawSpanMaskedP_RGBA_C (void); + #endif void R_DrawSpanTranslucentP_C (void); @@ -220,9 +279,30 @@ void R_DrawSpanMaskedTranslucentP_C (void); void R_DrawTlatedLucentColumnP_C (void); #define R_DrawTlatedLucentColumn R_DrawTlatedLucentColumnP_C -void R_FillColumnP (void); -void R_FillColumnHorizP (void); -void R_FillSpan (void); +extern void(*R_FillColumn)(void); +extern void(*R_FillAddColumn)(void); +extern void(*R_FillAddClampColumn)(void); +extern void(*R_FillSubClampColumn)(void); +extern void(*R_FillRevSubClampColumn)(void); +extern void(*R_DrawAddColumn)(void); +extern void(*R_DrawTlatedAddColumn)(void); +extern void(*R_DrawAddClampColumn)(void); +extern void(*R_DrawAddClampTranslatedColumn)(void); +extern void(*R_DrawSubClampColumn)(void); +extern void(*R_DrawSubClampTranslatedColumn)(void); +extern void(*R_DrawRevSubClampColumn)(void); +extern void(*R_DrawRevSubClampTranslatedColumn)(void); + +extern void(*R_FillSpan)(void); +extern void(*R_FillColumnHoriz)(void); + +void R_FillColumnP_C (void); + +void R_FillColumnHorizP_C (void); +void R_FillSpan_C (void); + +void R_FillColumnHorizP_RGBA_C(void); +void R_FillSpan_RGBA_C(void); #ifdef X86_ASM #define R_SetupDrawSlab R_SetupDrawSlabA @@ -282,6 +362,15 @@ inline ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translati // style was STYLE_Shade void R_FinishSetPatchStyle (); +extern fixed_t(*tmvline1_add)(); +extern void(*tmvline4_add)(); +extern fixed_t(*tmvline1_addclamp)(); +extern void(*tmvline4_addclamp)(); +extern fixed_t(*tmvline1_subclamp)(); +extern void(*tmvline4_subclamp)(); +extern fixed_t(*tmvline1_revsubclamp)(); +extern void(*tmvline4_revsubclamp)(); + // transmaskwallscan calls this to find out what column drawers to use bool R_GetTransMaskDrawers (fixed_t (**tmvline1)(), void (**tmvline4)()); diff --git a/src/r_drawt.cpp b/src/r_drawt.cpp index f5fc027b5..9520f59b3 100644 --- a/src/r_drawt.cpp +++ b/src/r_drawt.cpp @@ -114,13 +114,6 @@ void rt_copy1col_c (int hx, int sx, int yl, int yh) // Copies all four spans to the screen starting at sx. void rt_copy4cols_c (int sx, int yl, int yh) { -#ifndef PALETTEOUTPUT - // To do: we could do this with SSE using __m128i - rt_copy1col_c(0, sx, yl, yh); - rt_copy1col_c(1, sx + 1, yl, yh); - rt_copy1col_c(2, sx + 2, yl, yh); - rt_copy1col_c(3, sx + 3, yl, yh); -#else int *source; int *dest; int count; @@ -149,7 +142,6 @@ void rt_copy4cols_c (int sx, int yl, int yh) source += 8/sizeof(int); dest += pitch*2; } while (--count); -#endif } // Maps one span at hx to the screen at sx. @@ -166,21 +158,13 @@ void rt_map1col_c (int hx, int sx, int yl, int yh) return; count++; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); -#endif - colormap = dc_colormap; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4 + hx]; pitch = dc_pitch; if (count & 1) { -#ifndef PALETTEOUTPUT - *dest = shade_pal_index(colormap[*source], light); -#else *dest = colormap[*source]; -#endif source += 4; dest += pitch; } @@ -188,13 +172,8 @@ void rt_map1col_c (int hx, int sx, int yl, int yh) return; do { -#ifndef PALETTEOUTPUT - dest[0] = shade_pal_index(colormap[source[0]], light); - dest[pitch] = shade_pal_index(colormap[source[4]], light); -#else dest[0] = colormap[source[0]]; dest[pitch] = colormap[source[4]]; -#endif source += 8; dest += pitch*2; } while (--count); @@ -214,27 +193,16 @@ void rt_map4cols_c (int sx, int yl, int yh) return; count++; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); -#endif - colormap = dc_colormap; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4]; pitch = dc_pitch; if (count & 1) { -#ifndef PALETTEOUTPUT - dest[0] = shade_pal_index(colormap[source[0]], light); - dest[1] = shade_pal_index(colormap[source[1]], light); - dest[2] = shade_pal_index(colormap[source[2]], light); - dest[3] = shade_pal_index(colormap[source[3]], light); -#else dest[0] = colormap[source[0]]; dest[1] = colormap[source[1]]; dest[2] = colormap[source[2]]; dest[3] = colormap[source[3]]; -#endif source += 4; dest += pitch; } @@ -242,16 +210,6 @@ void rt_map4cols_c (int sx, int yl, int yh) return; do { -#ifndef PALETTEOUTPUT - dest[0] = shade_pal_index(colormap[source[0]], light); - dest[1] = shade_pal_index(colormap[source[1]], light); - dest[2] = shade_pal_index(colormap[source[2]], light); - dest[3] = shade_pal_index(colormap[source[3]], light); - dest[pitch] = shade_pal_index(colormap[source[4]], light); - dest[pitch + 1] = shade_pal_index(colormap[source[5]], light); - dest[pitch + 2] = shade_pal_index(colormap[source[6]], light); - dest[pitch + 3] = shade_pal_index(colormap[source[7]], light); -#else dest[0] = colormap[source[0]]; dest[1] = colormap[source[1]]; dest[2] = colormap[source[2]]; @@ -260,7 +218,6 @@ void rt_map4cols_c (int sx, int yl, int yh) dest[pitch+1] = colormap[source[5]]; dest[pitch+2] = colormap[source[6]]; dest[pitch+3] = colormap[source[7]]; -#endif source += 8; dest += pitch*2; } while (--count); @@ -356,21 +313,21 @@ void rt_Translate4cols(const BYTE *translation, int yl, int yh) } // Translates one span at hx to the screen at sx. -void rt_tlate1col (int hx, int sx, int yl, int yh) +void rt_tlate1col_c (int hx, int sx, int yl, int yh) { rt_Translate1col(dc_translation, hx, yl, yh); rt_map1col(hx, sx, yl, yh); } // Translates all four spans to the screen starting at sx. -void rt_tlate4cols (int sx, int yl, int yh) +void rt_tlate4cols_c (int sx, int yl, int yh) { rt_Translate4cols(dc_translation, yl, yh); rt_map4cols(sx, yl, yh); } // Adds one span at hx to the screen at sx without clamping. -void rt_add1col (int hx, int sx, int yl, int yh) +void rt_add1col_c (int hx, int sx, int yl, int yh) { BYTE *colormap; canvas_pixel_t *source; @@ -388,29 +345,6 @@ void rt_add1col (int hx, int sx, int yl, int yh) pitch = dc_pitch; colormap = dc_colormap; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); - - do { - uint32_t fg = shade_pal_index(colormap[*source], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - - source += 4; - dest += pitch; - } while (--count); -#else DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; do { @@ -424,7 +358,6 @@ void rt_add1col (int hx, int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); -#endif } // Adds all four spans to the screen starting at sx without clamping. @@ -446,32 +379,6 @@ void rt_add4cols_c (int sx, int yl, int yh) pitch = dc_pitch; colormap = dc_colormap; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); - - do { - for (int i = 0; i < 4; i++) - { - uint32_t fg = shade_pal_index(colormap[source[i]], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - - source += 4; - dest += pitch; - } while (--count); -#else DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; @@ -508,25 +415,24 @@ void rt_add4cols_c (int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); -#endif } // Translates and adds one span at hx to the screen at sx without clamping. -void rt_tlateadd1col (int hx, int sx, int yl, int yh) +void rt_tlateadd1col_c (int hx, int sx, int yl, int yh) { rt_Translate1col(dc_translation, hx, yl, yh); rt_add1col(hx, sx, yl, yh); } // Translates and adds all four spans to the screen starting at sx without clamping. -void rt_tlateadd4cols (int sx, int yl, int yh) +void rt_tlateadd4cols_c (int sx, int yl, int yh) { rt_Translate4cols(dc_translation, yl, yh); rt_add4cols(sx, yl, yh); } // Shades one span at hx to the screen at sx. -void rt_shaded1col (int hx, int sx, int yl, int yh) +void rt_shaded1col_c (int hx, int sx, int yl, int yh) { BYTE *colormap; canvas_pixel_t *source; @@ -544,29 +450,6 @@ void rt_shaded1col (int hx, int sx, int yl, int yh) source = &dc_temp[yl*4 + hx]; pitch = dc_pitch; -#ifndef PALETTEOUTPUT - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - do { - uint32_t alpha = colormap[*source]; - uint32_t inv_alpha = 64 - alpha; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; - uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; - uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += 4; - dest += pitch; - } while (--count); -#else DWORD *fgstart; fgstart = &Col2RGB8[0][dc_color]; @@ -578,7 +461,6 @@ void rt_shaded1col (int hx, int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); -#endif } // Shades all four spans to the screen starting at sx. @@ -600,32 +482,6 @@ void rt_shaded4cols_c (int sx, int yl, int yh) source = &dc_temp[yl*4]; pitch = dc_pitch; -#ifndef PALETTEOUTPUT - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - do { - for (int i = 0; i < 4; i++) - { - uint32_t alpha = colormap[source[i]]; - uint32_t inv_alpha = 64 - alpha; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; - uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; - uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - source += 4; - dest += pitch; - } while (--count); -#else DWORD *fgstart; fgstart = &Col2RGB8[0][dc_color]; @@ -651,11 +507,10 @@ void rt_shaded4cols_c (int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); -#endif } // Adds one span at hx to the screen at sx with clamping. -void rt_addclamp1col (int hx, int sx, int yl, int yh) +void rt_addclamp1col_c (int hx, int sx, int yl, int yh) { BYTE *colormap; canvas_pixel_t *source; @@ -673,28 +528,6 @@ void rt_addclamp1col (int hx, int sx, int yl, int yh) pitch = dc_pitch; colormap = dc_colormap; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); - - do { - uint32_t fg = shade_pal_index(colormap[*source], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += 4; - dest += pitch; - } while (--count); -#else DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; @@ -711,7 +544,6 @@ void rt_addclamp1col (int hx, int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); -#endif } // Adds all four spans to the screen starting at sx with clamping. @@ -733,31 +565,6 @@ void rt_addclamp4cols_c (int sx, int yl, int yh) pitch = dc_pitch; colormap = dc_colormap; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); - - do { - for (int i = 0; i < 4; i++) - { - uint32_t fg = shade_pal_index(colormap[source[i]], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - source += 4; - dest += pitch; - } while (--count); -#else DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; @@ -802,25 +609,24 @@ void rt_addclamp4cols_c (int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); -#endif } // Translates and adds one span at hx to the screen at sx with clamping. -void rt_tlateaddclamp1col (int hx, int sx, int yl, int yh) +void rt_tlateaddclamp1col_c (int hx, int sx, int yl, int yh) { rt_Translate1col(dc_translation, hx, yl, yh); rt_addclamp1col(hx, sx, yl, yh); } // Translates and adds all four spans to the screen starting at sx with clamping. -void rt_tlateaddclamp4cols (int sx, int yl, int yh) +void rt_tlateaddclamp4cols_c (int sx, int yl, int yh) { rt_Translate4cols(dc_translation, yl, yh); rt_addclamp4cols(sx, yl, yh); } // Subtracts one span at hx to the screen at sx with clamping. -void rt_subclamp1col (int hx, int sx, int yl, int yh) +void rt_subclamp1col_c (int hx, int sx, int yl, int yh) { BYTE *colormap; canvas_pixel_t *source; @@ -838,28 +644,6 @@ void rt_subclamp1col (int hx, int sx, int yl, int yh) pitch = dc_pitch; colormap = dc_colormap; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); - - do { - uint32_t fg = shade_pal_index(colormap[*source], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += 4; - dest += pitch; - } while (--count); -#else DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; do { @@ -874,11 +658,10 @@ void rt_subclamp1col (int hx, int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); -#endif } // Subtracts all four spans to the screen starting at sx with clamping. -void rt_subclamp4cols (int sx, int yl, int yh) +void rt_subclamp4cols_c (int sx, int yl, int yh) { BYTE *colormap; canvas_pixel_t *source; @@ -896,32 +679,6 @@ void rt_subclamp4cols (int sx, int yl, int yh) pitch = dc_pitch; colormap = dc_colormap; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); - - do { - for (int i = 0; i < 4; i++) - { - uint32_t fg = shade_pal_index(colormap[source[i]], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - - source += 4; - dest += pitch; - } while (--count); -#else DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; do { @@ -961,25 +718,24 @@ void rt_subclamp4cols (int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); -#endif } // Translates and subtracts one span at hx to the screen at sx with clamping. -void rt_tlatesubclamp1col (int hx, int sx, int yl, int yh) +void rt_tlatesubclamp1col_c (int hx, int sx, int yl, int yh) { rt_Translate1col(dc_translation, hx, yl, yh); rt_subclamp1col(hx, sx, yl, yh); } // Translates and subtracts all four spans to the screen starting at sx with clamping. -void rt_tlatesubclamp4cols (int sx, int yl, int yh) +void rt_tlatesubclamp4cols_c (int sx, int yl, int yh) { rt_Translate4cols(dc_translation, yl, yh); rt_subclamp4cols(sx, yl, yh); } // Subtracts one span at hx from the screen at sx with clamping. -void rt_revsubclamp1col (int hx, int sx, int yl, int yh) +void rt_revsubclamp1col_c (int hx, int sx, int yl, int yh) { BYTE *colormap; canvas_pixel_t *source; @@ -999,28 +755,6 @@ void rt_revsubclamp1col (int hx, int sx, int yl, int yh) pitch = dc_pitch; colormap = dc_colormap; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); - - do { - uint32_t fg = shade_pal_index(colormap[*source], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += 4; - dest += pitch; - } while (--count); -#else do { DWORD a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[*source]]; DWORD b = a; @@ -1033,11 +767,10 @@ void rt_revsubclamp1col (int hx, int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); -#endif } // Subtracts all four spans from the screen starting at sx with clamping. -void rt_revsubclamp4cols (int sx, int yl, int yh) +void rt_revsubclamp4cols_c (int sx, int yl, int yh) { BYTE *colormap; canvas_pixel_t *source; @@ -1057,32 +790,6 @@ void rt_revsubclamp4cols (int sx, int yl, int yh) pitch = dc_pitch; colormap = dc_colormap; -#ifndef PALETTEOUTPUT - uint32_t light = calc_light_multiplier(dc_light); - - do { - for (int i = 0; i < 4; i++) - { - uint32_t fg = shade_pal_index(colormap[source[i]], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - - source += 4; - dest += pitch; - } while (--count); -#else do { DWORD a = (bg2rgb[dest[0]] | 0x40100400) - fg2rgb[colormap[source[0]]]; DWORD b = a; @@ -1120,18 +827,17 @@ void rt_revsubclamp4cols (int sx, int yl, int yh) source += 4; dest += pitch; } while (--count); -#endif } // Translates and subtracts one span at hx from the screen at sx with clamping. -void rt_tlaterevsubclamp1col (int hx, int sx, int yl, int yh) +void rt_tlaterevsubclamp1col_c (int hx, int sx, int yl, int yh) { rt_Translate1col(dc_translation, hx, yl, yh); rt_revsubclamp1col(hx, sx, yl, yh); } // Translates and subtracts all four spans from the screen starting at sx with clamping. -void rt_tlaterevsubclamp4cols (int sx, int yl, int yh) +void rt_tlaterevsubclamp4cols_c (int sx, int yl, int yh) { rt_Translate4cols(dc_translation, yl, yh); rt_revsubclamp4cols(sx, yl, yh); @@ -1301,7 +1007,7 @@ void rt_draw4cols (int sx) // Before each pass through a rendering loop that uses these routines, // call this function to set up the span pointers. -void rt_initcols (canvas_pixel_t *buff) +void rt_initcols_pal (canvas_pixel_t *buff) { int y; @@ -1372,7 +1078,7 @@ void R_DrawColumnHorizP_C (void) } // [RH] Just fills a column with a given color -void R_FillColumnHorizP (void) +void R_FillColumnHorizP_C (void) { int count = dc_count; BYTE color = dc_color; diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp new file mode 100644 index 000000000..e8111be8f --- /dev/null +++ b/src/r_drawt_rgba.cpp @@ -0,0 +1,883 @@ +/* +** r_drawt_rgba.cpp +** Faster column drawers for modern processors, true color edition +** +**--------------------------------------------------------------------------- +** Copyright 1998-2006 Randy Heit +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** True color versions of the similar functions in r_drawt.cpp +** Please see r_drawt.cpp for a description of the globals used. +*/ + +#include "templates.h" +#include "doomtype.h" +#include "doomdef.h" +#include "r_defs.h" +#include "r_draw.h" +#include "r_main.h" +#include "r_things.h" +#include "v_video.h" + +canvas_pixel_t dc_temp_rgbabuff_rgba[MAXHEIGHT*4]; +canvas_pixel_t *dc_temp_rgba; + +// Defined in r_draw_t.cpp: +extern unsigned int dc_tspans[4][MAXHEIGHT]; +extern unsigned int *dc_ctspan[4]; +extern unsigned int *horizspan[4]; + +// Copies one span at hx to the screen at sx. +void rt_copy1col_RGBA_c (int hx, int sx, int yl, int yh) +{ + canvas_pixel_t *source; + canvas_pixel_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + dc_destorg; + source = &dc_temp_rgba[yl*4 + hx]; + pitch = dc_pitch; + + if (count & 1) { + *dest = *source; + source += 4; + dest += pitch; + } + if (count & 2) { + dest[0] = source[0]; + dest[pitch] = source[4]; + source += 8; + dest += pitch*2; + } + if (!(count >>= 2)) + return; + + do { + dest[0] = source[0]; + dest[pitch] = source[4]; + dest[pitch*2] = source[8]; + dest[pitch*3] = source[12]; + source += 16; + dest += pitch*4; + } while (--count); +} + +// Copies all four spans to the screen starting at sx. +void rt_copy4cols_RGBA_c (int sx, int yl, int yh) +{ + // To do: we could do this with SSE using __m128i + rt_copy1col_RGBA_c(0, sx, yl, yh); + rt_copy1col_RGBA_c(1, sx + 1, yl, yh); + rt_copy1col_RGBA_c(2, sx + 2, yl, yh); + rt_copy1col_RGBA_c(3, sx + 3, yl, yh); +} + +// Maps one span at hx to the screen at sx. +void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh) +{ + BYTE *colormap; + canvas_pixel_t *source; + canvas_pixel_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + uint32_t light = calc_light_multiplier(dc_light); + + colormap = dc_colormap; + dest = ylookup[yl] + sx + dc_destorg; + source = &dc_temp_rgba[yl*4 + hx]; + pitch = dc_pitch; + + if (count & 1) { + *dest = shade_pal_index(colormap[*source], light); + source += 4; + dest += pitch; + } + if (!(count >>= 1)) + return; + + do { + dest[0] = shade_pal_index(colormap[source[0]], light); + dest[pitch] = shade_pal_index(colormap[source[4]], light); + source += 8; + dest += pitch*2; + } while (--count); +} + +// Maps all four spans to the screen starting at sx. +void rt_map4cols_RGBA_c (int sx, int yl, int yh) +{ + BYTE *colormap; + canvas_pixel_t *source; + canvas_pixel_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + uint32_t light = calc_light_multiplier(dc_light); + + colormap = dc_colormap; + dest = ylookup[yl] + sx + dc_destorg; + source = &dc_temp_rgba[yl*4]; + pitch = dc_pitch; + + if (count & 1) { + dest[0] = shade_pal_index(colormap[source[0]], light); + dest[1] = shade_pal_index(colormap[source[1]], light); + dest[2] = shade_pal_index(colormap[source[2]], light); + dest[3] = shade_pal_index(colormap[source[3]], light); + source += 4; + dest += pitch; + } + if (!(count >>= 1)) + return; + + do { + dest[0] = shade_pal_index(colormap[source[0]], light); + dest[1] = shade_pal_index(colormap[source[1]], light); + dest[2] = shade_pal_index(colormap[source[2]], light); + dest[3] = shade_pal_index(colormap[source[3]], light); + dest[pitch] = shade_pal_index(colormap[source[4]], light); + dest[pitch + 1] = shade_pal_index(colormap[source[5]], light); + dest[pitch + 2] = shade_pal_index(colormap[source[6]], light); + dest[pitch + 3] = shade_pal_index(colormap[source[7]], light); + source += 8; + dest += pitch*2; + } while (--count); +} + +void rt_Translate1col_RGBA_c(const BYTE *translation, int hx, int yl, int yh) +{ + int count = yh - yl + 1; + canvas_pixel_t *source = &dc_temp_rgba[yl*4 + hx]; + + // Things we do to hit the compiler's optimizer with a clue bat: + // 1. Parallelism is explicitly spelled out by using a separate + // C instruction for each assembly instruction. GCC lets me + // have four temporaries, but VC++ spills to the stack with + // more than two. Two is probably optimal, anyway. + // 2. The results of the translation lookups are explicitly + // stored in byte-sized variables. This causes the VC++ code + // to use byte mov instructions in most cases; for apparently + // random reasons, it will use movzx for some places. GCC + // ignores this and uses movzx always. + + // Do 8 rows at a time. + for (int count8 = count >> 3; count8; --count8) + { + int c0, c1; + BYTE b0, b1; + + c0 = source[0]; c1 = source[4]; + b0 = translation[c0]; b1 = translation[c1]; + source[0] = b0; source[4] = b1; + + c0 = source[8]; c1 = source[12]; + b0 = translation[c0]; b1 = translation[c1]; + source[8] = b0; source[12] = b1; + + c0 = source[16]; c1 = source[20]; + b0 = translation[c0]; b1 = translation[c1]; + source[16] = b0; source[20] = b1; + + c0 = source[24]; c1 = source[28]; + b0 = translation[c0]; b1 = translation[c1]; + source[24] = b0; source[28] = b1; + + source += 32; + } + // Finish by doing 1 row at a time. + for (count &= 7; count; --count, source += 4) + { + source[0] = translation[source[0]]; + } +} + +void rt_Translate4cols_RGBA_c(const BYTE *translation, int yl, int yh) +{ + int count = yh - yl + 1; + canvas_pixel_t *source = &dc_temp_rgba[yl*4]; + int c0, c1; + BYTE b0, b1; + + // Do 2 rows at a time. + for (int count8 = count >> 1; count8; --count8) + { + c0 = source[0]; c1 = source[1]; + b0 = translation[c0]; b1 = translation[c1]; + source[0] = b0; source[1] = b1; + + c0 = source[2]; c1 = source[3]; + b0 = translation[c0]; b1 = translation[c1]; + source[2] = b0; source[3] = b1; + + c0 = source[4]; c1 = source[5]; + b0 = translation[c0]; b1 = translation[c1]; + source[4] = b0; source[5] = b1; + + c0 = source[6]; c1 = source[7]; + b0 = translation[c0]; b1 = translation[c1]; + source[6] = b0; source[7] = b1; + + source += 8; + } + // Do the final row if count was odd. + if (count & 1) + { + c0 = source[0]; c1 = source[1]; + b0 = translation[c0]; b1 = translation[c1]; + source[0] = b0; source[1] = b1; + + c0 = source[2]; c1 = source[3]; + b0 = translation[c0]; b1 = translation[c1]; + source[2] = b0; source[3] = b1; + } +} + +// Translates one span at hx to the screen at sx. +void rt_tlate1col_RGBA_c (int hx, int sx, int yl, int yh) +{ + rt_Translate1col_RGBA_c(dc_translation, hx, yl, yh); + rt_map1col(hx, sx, yl, yh); +} + +// Translates all four spans to the screen starting at sx. +void rt_tlate4cols_RGBA_c (int sx, int yl, int yh) +{ + rt_Translate4cols_RGBA_c(dc_translation, yl, yh); + rt_map4cols(sx, yl, yh); +} + +// Adds one span at hx to the screen at sx without clamping. +void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh) +{ + BYTE *colormap; + canvas_pixel_t *source; + canvas_pixel_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + dc_destorg; + source = &dc_temp_rgba[yl*4 + hx]; + pitch = dc_pitch; + colormap = dc_colormap; + + uint32_t light = calc_light_multiplier(dc_light); + + do { + uint32_t fg = shade_pal_index(colormap[*source], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + + source += 4; + dest += pitch; + } while (--count); +} + +// Adds all four spans to the screen starting at sx without clamping. +void rt_add4cols_RGBA_c (int sx, int yl, int yh) +{ + BYTE *colormap; + canvas_pixel_t *source; + canvas_pixel_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + dc_destorg; + source = &dc_temp_rgba[yl*4]; + pitch = dc_pitch; + colormap = dc_colormap; + + uint32_t light = calc_light_multiplier(dc_light); + + do { + for (int i = 0; i < 4; i++) + { + uint32_t fg = shade_pal_index(colormap[source[i]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + + source += 4; + dest += pitch; + } while (--count); +} + +// Translates and adds one span at hx to the screen at sx without clamping. +void rt_tlateadd1col_RGBA_c (int hx, int sx, int yl, int yh) +{ + rt_Translate1col_RGBA_c(dc_translation, hx, yl, yh); + rt_add1col(hx, sx, yl, yh); +} + +// Translates and adds all four spans to the screen starting at sx without clamping. +void rt_tlateadd4cols_RGBA_c(int sx, int yl, int yh) +{ + rt_Translate4cols_RGBA_c(dc_translation, yl, yh); + rt_add4cols(sx, yl, yh); +} + +// Shades one span at hx to the screen at sx. +void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh) +{ + BYTE *colormap; + canvas_pixel_t *source; + canvas_pixel_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + colormap = dc_colormap; + dest = ylookup[yl] + sx + dc_destorg; + source = &dc_temp_rgba[yl*4 + hx]; + pitch = dc_pitch; + + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + do { + uint32_t alpha = colormap[*source]; + uint32_t inv_alpha = 64 - alpha; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; + uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; + uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + source += 4; + dest += pitch; + } while (--count); +} + +// Shades all four spans to the screen starting at sx. +void rt_shaded4cols_RGBA_c (int sx, int yl, int yh) +{ + BYTE *colormap; + canvas_pixel_t *source; + canvas_pixel_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + colormap = dc_colormap; + dest = ylookup[yl] + sx + dc_destorg; + source = &dc_temp_rgba[yl*4]; + pitch = dc_pitch; + + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + do { + for (int i = 0; i < 4; i++) + { + uint32_t alpha = colormap[source[i]]; + uint32_t inv_alpha = 64 - alpha; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; + uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; + uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + source += 4; + dest += pitch; + } while (--count); +} + +// Adds one span at hx to the screen at sx with clamping. +void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh) +{ + BYTE *colormap; + canvas_pixel_t *source; + canvas_pixel_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + dc_destorg; + source = &dc_temp_rgba[yl*4 + hx]; + pitch = dc_pitch; + colormap = dc_colormap; + + uint32_t light = calc_light_multiplier(dc_light); + + do { + uint32_t fg = shade_pal_index(colormap[*source], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + source += 4; + dest += pitch; + } while (--count); +} + +// Adds all four spans to the screen starting at sx with clamping. +void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh) +{ + BYTE *colormap; + canvas_pixel_t *source; + canvas_pixel_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + dc_destorg; + source = &dc_temp_rgba[yl*4]; + pitch = dc_pitch; + colormap = dc_colormap; + + uint32_t light = calc_light_multiplier(dc_light); + + do { + for (int i = 0; i < 4; i++) + { + uint32_t fg = shade_pal_index(colormap[source[i]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + source += 4; + dest += pitch; + } while (--count); +} + +// Translates and adds one span at hx to the screen at sx with clamping. +void rt_tlateaddclamp1col_RGBA_c (int hx, int sx, int yl, int yh) +{ + rt_Translate1col_RGBA_c(dc_translation, hx, yl, yh); + rt_addclamp1col_RGBA_c(hx, sx, yl, yh); +} + +// Translates and adds all four spans to the screen starting at sx with clamping. +void rt_tlateaddclamp4cols_RGBA_c (int sx, int yl, int yh) +{ + rt_Translate4cols_RGBA_c(dc_translation, yl, yh); + rt_addclamp4cols(sx, yl, yh); +} + +// Subtracts one span at hx to the screen at sx with clamping. +void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh) +{ + BYTE *colormap; + canvas_pixel_t *source; + canvas_pixel_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + dc_destorg; + source = &dc_temp_rgba[yl*4 + hx]; + pitch = dc_pitch; + colormap = dc_colormap; + + uint32_t light = calc_light_multiplier(dc_light); + + do { + uint32_t fg = shade_pal_index(colormap[*source], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + source += 4; + dest += pitch; + } while (--count); +} + +// Subtracts all four spans to the screen starting at sx with clamping. +void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh) +{ + BYTE *colormap; + canvas_pixel_t *source; + canvas_pixel_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + dc_destorg; + source = &dc_temp_rgba[yl*4]; + pitch = dc_pitch; + colormap = dc_colormap; + + uint32_t light = calc_light_multiplier(dc_light); + + do { + for (int i = 0; i < 4; i++) + { + uint32_t fg = shade_pal_index(colormap[source[i]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + + source += 4; + dest += pitch; + } while (--count); +} + +// Translates and subtracts one span at hx to the screen at sx with clamping. +void rt_tlatesubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) +{ + rt_Translate1col_RGBA_c(dc_translation, hx, yl, yh); + rt_subclamp1col_RGBA_c(hx, sx, yl, yh); +} + +// Translates and subtracts all four spans to the screen starting at sx with clamping. +void rt_tlatesubclamp4cols_RGBA_c (int sx, int yl, int yh) +{ + rt_Translate4cols_RGBA_c(dc_translation, yl, yh); + rt_subclamp4cols_RGBA_c(sx, yl, yh); +} + +// Subtracts one span at hx from the screen at sx with clamping. +void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) +{ + BYTE *colormap; + canvas_pixel_t *source; + canvas_pixel_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + dest = ylookup[yl] + sx + dc_destorg; + source = &dc_temp_rgba[yl*4 + hx]; + pitch = dc_pitch; + colormap = dc_colormap; + + uint32_t light = calc_light_multiplier(dc_light); + + do { + uint32_t fg = shade_pal_index(colormap[*source], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + source += 4; + dest += pitch; + } while (--count); +} + +// Subtracts all four spans from the screen starting at sx with clamping. +void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh) +{ + BYTE *colormap; + canvas_pixel_t *source; + canvas_pixel_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; + dest = ylookup[yl] + sx + dc_destorg; + source = &dc_temp_rgba[yl*4]; + pitch = dc_pitch; + colormap = dc_colormap; + + uint32_t light = calc_light_multiplier(dc_light); + + do { + for (int i = 0; i < 4; i++) + { + uint32_t fg = shade_pal_index(colormap[source[i]], light); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; + uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; + uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + + source += 4; + dest += pitch; + } while (--count); +} + +// Translates and subtracts one span at hx from the screen at sx with clamping. +void rt_tlaterevsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) +{ + rt_Translate1col_RGBA_c(dc_translation, hx, yl, yh); + rt_revsubclamp1col_RGBA_c(hx, sx, yl, yh); +} + +// Translates and subtracts all four spans from the screen starting at sx with clamping. +void rt_tlaterevsubclamp4cols_RGBA_c (int sx, int yl, int yh) +{ + rt_Translate4cols_RGBA_c(dc_translation, yl, yh); + rt_revsubclamp4cols_RGBA_c(sx, yl, yh); +} + +// Before each pass through a rendering loop that uses these routines, +// call this function to set up the span pointers. +void rt_initcols_rgba (canvas_pixel_t *buff) +{ + int y; + + dc_temp_rgba = buff == NULL ? dc_temp_rgbabuff_rgba : buff; + for (y = 3; y >= 0; y--) + horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0]; +} + +// Stretches a column into a temporary buffer which is later +// drawn to the screen along with up to three other columns. +void R_DrawColumnHorizP_RGBA_C (void) +{ + int count = dc_count; + canvas_pixel_t *dest; + fixed_t fracstep; + fixed_t frac; + + if (count <= 0) + return; + + { + int x = dc_x & 3; + unsigned int **span; + + span = &dc_ctspan[x]; + (*span)[0] = dc_yl; + (*span)[1] = dc_yh; + *span += 2; + dest = &dc_temp_rgba[x + 4*dc_yl]; + } + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + const BYTE *source = dc_source; + + if (count & 1) { + *dest = source[frac>>FRACBITS]; dest += 4; frac += fracstep; + } + if (count & 2) { + dest[0] = source[frac>>FRACBITS]; frac += fracstep; + dest[4] = source[frac>>FRACBITS]; frac += fracstep; + dest += 8; + } + if (count & 4) { + dest[0] = source[frac>>FRACBITS]; frac += fracstep; + dest[4] = source[frac>>FRACBITS]; frac += fracstep; + dest[8] = source[frac>>FRACBITS]; frac += fracstep; + dest[12]= source[frac>>FRACBITS]; frac += fracstep; + dest += 16; + } + count >>= 3; + if (!count) return; + + do + { + dest[0] = source[frac>>FRACBITS]; frac += fracstep; + dest[4] = source[frac>>FRACBITS]; frac += fracstep; + dest[8] = source[frac>>FRACBITS]; frac += fracstep; + dest[12]= source[frac>>FRACBITS]; frac += fracstep; + dest[16]= source[frac>>FRACBITS]; frac += fracstep; + dest[20]= source[frac>>FRACBITS]; frac += fracstep; + dest[24]= source[frac>>FRACBITS]; frac += fracstep; + dest[28]= source[frac>>FRACBITS]; frac += fracstep; + dest += 32; + } while (--count); + } +} + +// [RH] Just fills a column with a given color +void R_FillColumnHorizP_RGBA_C (void) +{ + int count = dc_count; + BYTE color = dc_color; + canvas_pixel_t *dest; + + if (count <= 0) + return; + + { + int x = dc_x & 3; + unsigned int **span = &dc_ctspan[x]; + + (*span)[0] = dc_yl; + (*span)[1] = dc_yh; + *span += 2; + dest = &dc_temp_rgba[x + 4*dc_yl]; + } + + if (count & 1) { + *dest = color; + dest += 4; + } + if (!(count >>= 1)) + return; + do { + dest[0] = color; dest[4] = color; + dest += 8; + } while (--count); +} diff --git a/src/r_main.cpp b/src/r_main.cpp index 04e798981..b7723d07d 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -847,10 +847,10 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) // [RH] Show off segs if r_drawflat is 1 if (r_drawflat) { - hcolfunc_pre = R_FillColumnHorizP; + hcolfunc_pre = R_FillColumnHoriz; hcolfunc_post1 = rt_copy1col; hcolfunc_post4 = rt_copy4cols; - colfunc = R_FillColumnP; + colfunc = R_FillColumn; spanfunc = R_FillSpan; } else diff --git a/src/r_plane.cpp b/src/r_plane.cpp index b385302e5..c8258a1ba 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -491,18 +491,19 @@ void R_MapTiltedPlane (int y, int x1) // //========================================================================== -void R_MapColoredPlane (int y, int x1) +void R_MapColoredPlane_C (int y, int x1) +{ + memset (ylookup[y] + x1 + dc_destorg, ds_color, (spanend[y] - x1 + 1)); +} + +void R_MapColoredPlane_RGBA(int y, int x1) { -#ifndef PALETTEOUTPUT canvas_pixel_t *dest = ylookup[y] + x1 + dc_destorg; int count = (spanend[y] - x1 + 1); uint32_t light = calc_light_multiplier(ds_light); uint32_t color = shade_pal_index(ds_color, light); for (int i = 0; i < count; i++) dest[i] = color; -#else - memset (ylookup[y] + x1 + dc_destorg, ds_color, (spanend[y] - x1 + 1) * sizeof(canvas_pixel_t)); -#endif } //========================================================================== diff --git a/src/r_plane.h b/src/r_plane.h index d4db3dc09..ac63501e3 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -93,6 +93,10 @@ void R_DrawNormalPlane (visplane_t *pl, double xscale, double yscale, fixed_t al void R_DrawTiltedPlane (visplane_t *pl, double xscale, double yscale, fixed_t alpha, bool additive, bool masked); void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1)); +extern void(*R_MapColoredPlane)(int y, int x1); +void R_MapColoredPlane_C(int y, int x1); +void R_MapColoredPlane_RGBA(int y, int x1); + visplane_t *R_FindPlane ( const secplane_t &height, FTextureID picnum, diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 1cdb78555..fb27a99de 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -463,7 +463,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) while (dc_x < stop) { - rt_initcols(); + rt_initcols(nullptr); BlastMaskedColumn (R_DrawMaskedColumnHoriz, tex); dc_x++; BlastMaskedColumn (R_DrawMaskedColumnHoriz, tex); dc_x++; BlastMaskedColumn (R_DrawMaskedColumnHoriz, tex); dc_x++; @@ -3319,7 +3319,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, dc_light = 0; #endif } - rt_initcols(); + rt_initcols(nullptr); for (int zz = 4; zz; --zz) { R_WallSpriteColumn (R_DrawMaskedColumnHoriz); diff --git a/src/r_things.cpp b/src/r_things.cpp index 0e55b45f9..a6f6aea28 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -470,7 +470,7 @@ void R_DrawVisSprite (vissprite_t *vis) while (dc_x < stop4) { - rt_initcols(); + rt_initcols(nullptr); for (int zz = 4; zz; --zz) { pixels = tex->GetColumn (frac >> FRACBITS, &spans); @@ -619,7 +619,7 @@ void R_DrawWallSprite(vissprite_t *spr) dc_light = FLOAT2FIXED(MAXLIGHTVIS); #endif } - rt_initcols(); + rt_initcols(nullptr); for (int zz = 4; zz; --zz) { if (!R_ClipSpriteColumnWithPortals(spr)) @@ -681,7 +681,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop { return; } - if (colfunc == fuzzcolfunc || colfunc == R_FillColumnP) + if (colfunc == fuzzcolfunc || colfunc == R_FillColumn) { flags = DVF_OFFSCREEN | DVF_SPANSONLY; } @@ -2617,7 +2617,7 @@ static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) } } -void R_DrawParticle (vissprite_t *vis) +void R_DrawParticle_C (vissprite_t *vis) { int spacing; canvas_pixel_t *dest; @@ -2629,44 +2629,6 @@ void R_DrawParticle (vissprite_t *vis) R_DrawMaskedSegsBehindParticle (vis); -#ifndef PALETTEOUTPUT - uint32_t fg = shade_pal_index(color, calc_light_multiplier(0)); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - // vis->renderflags holds translucency level (0-255) - fixed_t fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff; - uint32_t alpha = fglevel * 256 / FRACUNIT; - uint32_t inv_alpha = 256 - alpha; - - fg_red *= alpha; - fg_green *= alpha; - fg_blue *= alpha; - - spacing = RenderTarget->GetPitch(); - - for (int x = x1; x < (x1 + countbase); x++) - { - dc_x = x; - if (R_ClipSpriteColumnWithPortals(vis)) - continue; - dest = ylookup[yl] + x + dc_destorg; - for (int y = 0; y < ycount; y++) - { - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red + bg_red * alpha) / 256; - uint32_t green = (fg_green + bg_green * alpha) / 256; - uint32_t blue = (fg_blue + bg_blue * alpha) / 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += spacing; - } - } -#else DWORD *bg2rgb; DWORD fg; @@ -2719,7 +2681,56 @@ void R_DrawParticle (vissprite_t *vis) dest += spacing; } } -#endif +} + +void R_DrawParticle_RGBA(vissprite_t *vis) +{ + int spacing; + canvas_pixel_t *dest; + BYTE color = vis->Style.colormap[vis->startfrac]; + int yl = vis->y1; + int ycount = vis->y2 - yl + 1; + int x1 = vis->x1; + int countbase = vis->x2 - x1; + + R_DrawMaskedSegsBehindParticle(vis); + + uint32_t fg = shade_pal_index(color, calc_light_multiplier(0)); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + // vis->renderflags holds translucency level (0-255) + fixed_t fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff; + uint32_t alpha = fglevel * 256 / FRACUNIT; + uint32_t inv_alpha = 256 - alpha; + + fg_red *= alpha; + fg_green *= alpha; + fg_blue *= alpha; + + spacing = RenderTarget->GetPitch(); + + for (int x = x1; x < (x1 + countbase); x++) + { + dc_x = x; + if (R_ClipSpriteColumnWithPortals(vis)) + continue; + dest = ylookup[yl] + x + dc_destorg; + for (int y = 0; y < ycount; y++) + { + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red * alpha) / 256; + uint32_t green = (fg_green + bg_green * alpha) / 256; + uint32_t blue = (fg_blue + bg_blue * alpha) / 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += spacing; + } + } } extern double BaseYaspectMul;; diff --git a/src/r_things.h b/src/r_things.h index 1cf9b0200..057b7cfe2 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -97,7 +97,10 @@ struct vissprite_t struct particle_t; -void R_DrawParticle (vissprite_t *); +extern void(*R_DrawParticle)(vissprite_t *); +void R_DrawParticle_C (vissprite_t *); +void R_DrawParticle_RGBA (vissprite_t *); + void R_ProjectParticle (particle_t *, const sector_t *sector, int shade, int fakeside); extern int MaxVisSprites; diff --git a/src/v_draw.cpp b/src/v_draw.cpp index fd14b5e0a..8853fc947 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -300,7 +300,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) while (dc_x < stop4) { - rt_initcols(); + rt_initcols(nullptr); for (int zz = 4; zz; --zz) { pixels = img->GetColumn(frac >> FRACBITS, spanptr); From 7080180d478ae7158e4f2b8d1821089105764c8f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 30 May 2016 13:32:24 +0200 Subject: [PATCH 0613/1509] Added menu option for toggling true color output on and off --- src/r_draw.cpp | 327 ++++++++++++++++++------------------- src/r_main.cpp | 1 + src/win32/fb_d3d9.cpp | 79 +++++---- src/win32/win32iface.h | 1 + wadsrc/static/language.enu | 1 + wadsrc/static/menudef.txt | 1 + 6 files changed, 216 insertions(+), 194 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index d2b694f05..83a4472f3 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -178,7 +178,7 @@ FDynamicColormap ShadeFakeColormap[16]; BYTE identitymap[256]; EXTERN_CVAR (Int, r_columnmethod) - +EXTERN_CVAR (Bool, r_swtruecolor) void R_InitShadeMaps() { @@ -4135,181 +4135,180 @@ const BYTE *R_GetColumn (FTexture *tex, int col) // [RH] Initialize the column drawer pointers void R_InitColumnDrawers () { -#ifndef PALETTEOUTPUT - - R_DrawColumnHoriz = R_DrawColumnHorizP_RGBA_C; - R_DrawColumn = R_DrawColumnP_RGBA_C; - R_DrawFuzzColumn = R_DrawFuzzColumnP_RGBA_C; - R_DrawTranslatedColumn = R_DrawTranslatedColumnP_RGBA_C; - R_DrawShadedColumn = R_DrawShadedColumnP_RGBA_C; - R_DrawSpan = R_DrawSpanP_RGBA_C; - R_DrawSpanMasked = R_DrawSpanMaskedP_RGBA_C; - rt_map4cols = rt_map4cols_RGBA_c; - - R_DrawSpanTranslucent = R_DrawSpanTranslucentP_RGBA_C; - R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucentP_RGBA_C; - R_DrawSpanAddClamp = R_DrawSpanAddClampP_RGBA_C; - R_DrawSpanMaskedAddClamp = R_DrawSpanMaskedAddClampP_RGBA_C; - R_FillColumn = R_FillColumnP_RGBA; - R_FillAddColumn = R_FillAddColumn_RGBA_C; - R_FillAddClampColumn = R_FillAddClampColumn_RGBA; - R_FillSubClampColumn = R_FillSubClampColumn_RGBA; - R_FillRevSubClampColumn = R_FillRevSubClampColumn_RGBA; - R_DrawAddColumn = R_DrawAddColumnP_RGBA_C; - R_DrawTlatedAddColumn = R_DrawTlatedAddColumnP_RGBA_C; - R_DrawAddClampColumn = R_DrawAddClampColumnP_RGBA_C; - R_DrawAddClampTranslatedColumn = R_DrawAddClampTranslatedColumnP_RGBA_C; - R_DrawSubClampColumn = R_DrawSubClampColumnP_RGBA_C; - R_DrawSubClampTranslatedColumn = R_DrawSubClampTranslatedColumnP_RGBA_C; - R_DrawRevSubClampColumn = R_DrawRevSubClampColumnP_RGBA_C; - R_DrawRevSubClampTranslatedColumn = R_DrawRevSubClampTranslatedColumnP_RGBA_C; - R_FillSpan = R_FillSpan_RGBA; - R_DrawFogBoundary = R_DrawFogBoundary_RGBA; - R_FillColumnHoriz = R_FillColumnHorizP_RGBA_C; - - R_DrawFogBoundary = R_DrawFogBoundary_RGBA; - R_MapColoredPlane = R_MapColoredPlane_RGBA; - R_DrawParticle = R_DrawParticle_RGBA; - - tmvline1_add = tmvline1_add_RGBA; - tmvline4_add = tmvline4_add_RGBA; - tmvline1_addclamp = tmvline1_addclamp_RGBA; - tmvline4_addclamp = tmvline4_addclamp_RGBA; - tmvline1_subclamp = tmvline1_subclamp_RGBA; - tmvline4_subclamp = tmvline4_subclamp_RGBA; - tmvline1_revsubclamp = tmvline1_revsubclamp_RGBA; - tmvline4_revsubclamp = tmvline4_revsubclamp_RGBA; - - rt_copy1col = rt_copy1col_RGBA_c; - rt_copy4cols = rt_copy4cols_RGBA_c; - rt_map1col = rt_map1col_RGBA_c; - rt_shaded4cols = rt_shaded4cols_RGBA_c; - rt_add4cols = rt_add4cols_RGBA_c; - rt_addclamp4cols = rt_addclamp4cols_RGBA_c; - rt_shaded1col = rt_shaded1col_RGBA_c; - rt_add1col = rt_add1col_RGBA_c; - rt_addclamp1col = rt_addclamp1col_RGBA_c; - rt_subclamp1col = rt_subclamp1col_RGBA_c; - rt_revsubclamp1col = rt_revsubclamp1col_RGBA_c; - rt_tlate1col = rt_tlate1col_RGBA_c; - rt_tlateadd1col = rt_tlateadd1col_RGBA_c; - rt_tlateaddclamp1col = rt_tlateaddclamp1col_RGBA_c; - rt_tlatesubclamp1col = rt_tlatesubclamp1col_RGBA_c; - rt_tlaterevsubclamp1col = rt_tlaterevsubclamp1col_RGBA_c; - rt_map4cols = rt_map4cols_RGBA_c; - rt_subclamp4cols = rt_subclamp4cols_RGBA_c; - rt_revsubclamp4cols = rt_revsubclamp4cols_RGBA_c; - rt_tlate4cols = rt_tlate4cols_RGBA_c; - rt_tlateadd4cols = rt_tlateadd4cols_RGBA_c; - rt_tlateaddclamp4cols = rt_tlateaddclamp4cols_RGBA_c; - rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_RGBA_c; - rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_RGBA_c; - rt_initcols = rt_initcols_rgba; - - dovline1 = vlinec1_RGBA; - doprevline1 = vlinec1_RGBA; - dovline4 = vlinec4_RGBA; - domvline1 = mvlinec1_RGBA; - domvline4 = mvlinec4_RGBA; - -#else - -#ifdef X86_ASM - R_DrawColumn = R_DrawColumnP_ASM; - R_DrawColumnHoriz = R_DrawColumnHorizP_ASM; - R_DrawFuzzColumn = R_DrawFuzzColumnP_ASM; - R_DrawTranslatedColumn = R_DrawTranslatedColumnP_C; - R_DrawShadedColumn = R_DrawShadedColumnP_C; - R_DrawSpan = R_DrawSpanP_ASM; - R_DrawSpanMasked = R_DrawSpanMaskedP_ASM; - if (CPU.Family <= 5) + if (r_swtruecolor) { - rt_map4cols = rt_map4cols_asm2; + R_DrawColumnHoriz = R_DrawColumnHorizP_RGBA_C; + R_DrawColumn = R_DrawColumnP_RGBA_C; + R_DrawFuzzColumn = R_DrawFuzzColumnP_RGBA_C; + R_DrawTranslatedColumn = R_DrawTranslatedColumnP_RGBA_C; + R_DrawShadedColumn = R_DrawShadedColumnP_RGBA_C; + R_DrawSpan = R_DrawSpanP_RGBA_C; + R_DrawSpanMasked = R_DrawSpanMaskedP_RGBA_C; + rt_map4cols = rt_map4cols_RGBA_c; + + R_DrawSpanTranslucent = R_DrawSpanTranslucentP_RGBA_C; + R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucentP_RGBA_C; + R_DrawSpanAddClamp = R_DrawSpanAddClampP_RGBA_C; + R_DrawSpanMaskedAddClamp = R_DrawSpanMaskedAddClampP_RGBA_C; + R_FillColumn = R_FillColumnP_RGBA; + R_FillAddColumn = R_FillAddColumn_RGBA_C; + R_FillAddClampColumn = R_FillAddClampColumn_RGBA; + R_FillSubClampColumn = R_FillSubClampColumn_RGBA; + R_FillRevSubClampColumn = R_FillRevSubClampColumn_RGBA; + R_DrawAddColumn = R_DrawAddColumnP_RGBA_C; + R_DrawTlatedAddColumn = R_DrawTlatedAddColumnP_RGBA_C; + R_DrawAddClampColumn = R_DrawAddClampColumnP_RGBA_C; + R_DrawAddClampTranslatedColumn = R_DrawAddClampTranslatedColumnP_RGBA_C; + R_DrawSubClampColumn = R_DrawSubClampColumnP_RGBA_C; + R_DrawSubClampTranslatedColumn = R_DrawSubClampTranslatedColumnP_RGBA_C; + R_DrawRevSubClampColumn = R_DrawRevSubClampColumnP_RGBA_C; + R_DrawRevSubClampTranslatedColumn = R_DrawRevSubClampTranslatedColumnP_RGBA_C; + R_FillSpan = R_FillSpan_RGBA; + R_DrawFogBoundary = R_DrawFogBoundary_RGBA; + R_FillColumnHoriz = R_FillColumnHorizP_RGBA_C; + + R_DrawFogBoundary = R_DrawFogBoundary_RGBA; + R_MapColoredPlane = R_MapColoredPlane_RGBA; + R_DrawParticle = R_DrawParticle_RGBA; + + tmvline1_add = tmvline1_add_RGBA; + tmvline4_add = tmvline4_add_RGBA; + tmvline1_addclamp = tmvline1_addclamp_RGBA; + tmvline4_addclamp = tmvline4_addclamp_RGBA; + tmvline1_subclamp = tmvline1_subclamp_RGBA; + tmvline4_subclamp = tmvline4_subclamp_RGBA; + tmvline1_revsubclamp = tmvline1_revsubclamp_RGBA; + tmvline4_revsubclamp = tmvline4_revsubclamp_RGBA; + + rt_copy1col = rt_copy1col_RGBA_c; + rt_copy4cols = rt_copy4cols_RGBA_c; + rt_map1col = rt_map1col_RGBA_c; + rt_shaded4cols = rt_shaded4cols_RGBA_c; + rt_add4cols = rt_add4cols_RGBA_c; + rt_addclamp4cols = rt_addclamp4cols_RGBA_c; + rt_shaded1col = rt_shaded1col_RGBA_c; + rt_add1col = rt_add1col_RGBA_c; + rt_addclamp1col = rt_addclamp1col_RGBA_c; + rt_subclamp1col = rt_subclamp1col_RGBA_c; + rt_revsubclamp1col = rt_revsubclamp1col_RGBA_c; + rt_tlate1col = rt_tlate1col_RGBA_c; + rt_tlateadd1col = rt_tlateadd1col_RGBA_c; + rt_tlateaddclamp1col = rt_tlateaddclamp1col_RGBA_c; + rt_tlatesubclamp1col = rt_tlatesubclamp1col_RGBA_c; + rt_tlaterevsubclamp1col = rt_tlaterevsubclamp1col_RGBA_c; + rt_map4cols = rt_map4cols_RGBA_c; + rt_subclamp4cols = rt_subclamp4cols_RGBA_c; + rt_revsubclamp4cols = rt_revsubclamp4cols_RGBA_c; + rt_tlate4cols = rt_tlate4cols_RGBA_c; + rt_tlateadd4cols = rt_tlateadd4cols_RGBA_c; + rt_tlateaddclamp4cols = rt_tlateaddclamp4cols_RGBA_c; + rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_RGBA_c; + rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_RGBA_c; + rt_initcols = rt_initcols_rgba; + + dovline1 = vlinec1_RGBA; + doprevline1 = vlinec1_RGBA; + dovline4 = vlinec4_RGBA; + domvline1 = mvlinec1_RGBA; + domvline4 = mvlinec4_RGBA; } else { - rt_map4cols = rt_map4cols_asm1; - } +#ifdef X86_ASM + R_DrawColumn = R_DrawColumnP_ASM; + R_DrawColumnHoriz = R_DrawColumnHorizP_ASM; + R_DrawFuzzColumn = R_DrawFuzzColumnP_ASM; + R_DrawTranslatedColumn = R_DrawTranslatedColumnP_C; + R_DrawShadedColumn = R_DrawShadedColumnP_C; + R_DrawSpan = R_DrawSpanP_ASM; + R_DrawSpanMasked = R_DrawSpanMaskedP_ASM; + if (CPU.Family <= 5) + { + rt_map4cols = rt_map4cols_asm2; + } + else + { + rt_map4cols = rt_map4cols_asm1; + } #else - R_DrawColumnHoriz = R_DrawColumnHorizP_C; - R_DrawColumn = R_DrawColumnP_C; - R_DrawFuzzColumn = R_DrawFuzzColumnP_C; - R_DrawTranslatedColumn = R_DrawTranslatedColumnP_C; - R_DrawShadedColumn = R_DrawShadedColumnP_C; - R_DrawSpan = R_DrawSpanP_C; - R_DrawSpanMasked = R_DrawSpanMaskedP_C; - rt_map4cols = rt_map4cols_c; + R_DrawColumnHoriz = R_DrawColumnHorizP_C; + R_DrawColumn = R_DrawColumnP_C; + R_DrawFuzzColumn = R_DrawFuzzColumnP_C; + R_DrawTranslatedColumn = R_DrawTranslatedColumnP_C; + R_DrawShadedColumn = R_DrawShadedColumnP_C; + R_DrawSpan = R_DrawSpanP_C; + R_DrawSpanMasked = R_DrawSpanMaskedP_C; + rt_map4cols = rt_map4cols_c; #endif - R_DrawSpanTranslucent = R_DrawSpanTranslucentP_C; - R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucentP_C; - R_DrawSpanAddClamp = R_DrawSpanAddClampP_C; - R_DrawSpanMaskedAddClamp = R_DrawSpanMaskedAddClampP_C; - R_FillColumn = R_FillColumnP_C; - R_FillAddColumn = R_FillAddColumn_C; - R_FillAddClampColumn = R_FillAddClampColumn_C; - R_FillSubClampColumn = R_FillSubClampColumn_C; - R_FillRevSubClampColumn = R_FillRevSubClampColumn_C; - R_DrawAddColumn = R_DrawAddColumnP_C; - R_DrawTlatedAddColumn = R_DrawTlatedAddColumnP_C; - R_DrawAddClampColumn = R_DrawAddClampColumnP_C; - R_DrawAddClampTranslatedColumn = R_DrawAddClampTranslatedColumnP_C; - R_DrawSubClampColumn = R_DrawSubClampColumnP_C; - R_DrawSubClampTranslatedColumn = R_DrawSubClampTranslatedColumnP_C; - R_DrawRevSubClampColumn = R_DrawRevSubClampColumnP_C; - R_DrawRevSubClampTranslatedColumn = R_DrawRevSubClampTranslatedColumnP_C; - R_FillSpan = R_FillSpan_C; - R_DrawFogBoundary = R_DrawFogBoundary_C; - R_FillColumnHoriz = R_FillColumnHorizP_C; + R_DrawSpanTranslucent = R_DrawSpanTranslucentP_C; + R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucentP_C; + R_DrawSpanAddClamp = R_DrawSpanAddClampP_C; + R_DrawSpanMaskedAddClamp = R_DrawSpanMaskedAddClampP_C; + R_FillColumn = R_FillColumnP_C; + R_FillAddColumn = R_FillAddColumn_C; + R_FillAddClampColumn = R_FillAddClampColumn_C; + R_FillSubClampColumn = R_FillSubClampColumn_C; + R_FillRevSubClampColumn = R_FillRevSubClampColumn_C; + R_DrawAddColumn = R_DrawAddColumnP_C; + R_DrawTlatedAddColumn = R_DrawTlatedAddColumnP_C; + R_DrawAddClampColumn = R_DrawAddClampColumnP_C; + R_DrawAddClampTranslatedColumn = R_DrawAddClampTranslatedColumnP_C; + R_DrawSubClampColumn = R_DrawSubClampColumnP_C; + R_DrawSubClampTranslatedColumn = R_DrawSubClampTranslatedColumnP_C; + R_DrawRevSubClampColumn = R_DrawRevSubClampColumnP_C; + R_DrawRevSubClampTranslatedColumn = R_DrawRevSubClampTranslatedColumnP_C; + R_FillSpan = R_FillSpan_C; + R_DrawFogBoundary = R_DrawFogBoundary_C; + R_FillColumnHoriz = R_FillColumnHorizP_C; - R_DrawFogBoundary = R_DrawFogBoundary_C; - R_MapColoredPlane = R_MapColoredPlane_C; - R_DrawParticle = R_DrawParticle_C; + R_DrawFogBoundary = R_DrawFogBoundary_C; + R_MapColoredPlane = R_MapColoredPlane_C; + R_DrawParticle = R_DrawParticle_C; - tmvline1_add = tmvline1_add_C; - tmvline4_add = tmvline4_add_C; - tmvline1_addclamp = tmvline1_addclamp_C; - tmvline4_addclamp = tmvline4_addclamp_C; - tmvline1_subclamp = tmvline1_subclamp_C; - tmvline4_subclamp = tmvline4_subclamp_C; - tmvline1_revsubclamp = tmvline1_revsubclamp_C; - tmvline4_revsubclamp = tmvline4_revsubclamp_C; + tmvline1_add = tmvline1_add_C; + tmvline4_add = tmvline4_add_C; + tmvline1_addclamp = tmvline1_addclamp_C; + tmvline4_addclamp = tmvline4_addclamp_C; + tmvline1_subclamp = tmvline1_subclamp_C; + tmvline4_subclamp = tmvline4_subclamp_C; + tmvline1_revsubclamp = tmvline1_revsubclamp_C; + tmvline4_revsubclamp = tmvline4_revsubclamp_C; #ifdef X86_ASM - rt_copy1col = rt_copy1col_asm; - rt_copy4cols = rt_copy4cols_asm; - rt_map1col = rt_map1col_asm; - rt_shaded4cols = rt_shaded4cols_asm; - rt_add4cols = rt_add4cols_asm; - rt_addclamp4cols = rt_addclamp4cols_asm; + rt_copy1col = rt_copy1col_asm; + rt_copy4cols = rt_copy4cols_asm; + rt_map1col = rt_map1col_asm; + rt_shaded4cols = rt_shaded4cols_asm; + rt_add4cols = rt_add4cols_asm; + rt_addclamp4cols = rt_addclamp4cols_asm; #else - rt_copy1col = rt_copy1col_c; - rt_copy4cols = rt_copy4cols_c; - rt_map1col = rt_map1col_c; - rt_shaded4cols = rt_shaded4cols_c; - rt_add4cols = rt_add4cols_c; - rt_addclamp4cols = rt_addclamp4cols_c; -#endif - rt_shaded1col = rt_shaded1col_c; - rt_add1col = rt_add1col_c; - rt_addclamp1col = rt_addclamp1col_c; - rt_subclamp1col = rt_subclamp1col_c; - rt_revsubclamp1col = rt_revsubclamp1col_c; - rt_tlate1col = rt_tlate1col_c; - rt_tlateadd1col = rt_tlateadd1col_c; - rt_tlateaddclamp1col = rt_tlateaddclamp1col_c; - rt_tlatesubclamp1col = rt_tlatesubclamp1col_c; - rt_tlaterevsubclamp1col = rt_tlaterevsubclamp1col_c; - rt_map4cols = rt_map4cols_c; - rt_subclamp4cols = rt_subclamp4cols_c; - rt_revsubclamp4cols = rt_revsubclamp4cols_c; - rt_tlate4cols = rt_tlate4cols_c; - rt_tlateadd4cols = rt_tlateadd4cols_c; - rt_tlateaddclamp4cols = rt_tlateaddclamp4cols_c; - rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_c; - rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_c; - rt_initcols = rt_initcols_pal; - + rt_copy1col = rt_copy1col_c; + rt_copy4cols = rt_copy4cols_c; + rt_map1col = rt_map1col_c; + rt_shaded4cols = rt_shaded4cols_c; + rt_add4cols = rt_add4cols_c; + rt_addclamp4cols = rt_addclamp4cols_c; #endif + rt_shaded1col = rt_shaded1col_c; + rt_add1col = rt_add1col_c; + rt_addclamp1col = rt_addclamp1col_c; + rt_subclamp1col = rt_subclamp1col_c; + rt_revsubclamp1col = rt_revsubclamp1col_c; + rt_tlate1col = rt_tlate1col_c; + rt_tlateadd1col = rt_tlateadd1col_c; + rt_tlateaddclamp1col = rt_tlateaddclamp1col_c; + rt_tlatesubclamp1col = rt_tlatesubclamp1col_c; + rt_tlaterevsubclamp1col = rt_tlaterevsubclamp1col_c; + rt_map4cols = rt_map4cols_c; + rt_subclamp4cols = rt_subclamp4cols_c; + rt_revsubclamp4cols = rt_revsubclamp4cols_c; + rt_tlate4cols = rt_tlate4cols_c; + rt_tlateadd4cols = rt_tlateadd4cols_c; + rt_tlateaddclamp4cols = rt_tlateaddclamp4cols_c; + rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_c; + rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_c; + rt_initcols = rt_initcols_pal; + } } // [RH] Choose column drawers in a single place diff --git a/src/r_main.cpp b/src/r_main.cpp index b7723d07d..d85cd62a0 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -103,6 +103,7 @@ bool r_dontmaplines; CVAR (String, r_viewsize, "", CVAR_NOSET) CVAR (Bool, r_shadercolormaps, true, CVAR_ARCHIVE) +CVAR (Bool, r_swtruecolor, false, CVAR_ARCHIVE) double r_BaseVisibility; double r_WallVisibility; diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 14a78d4cd..0cc9045ee 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -187,6 +187,7 @@ EXTERN_CVAR (Float, Gamma) EXTERN_CVAR (Bool, vid_vsync) EXTERN_CVAR (Float, transsouls) EXTERN_CVAR (Int, vid_refreshrate) +EXTERN_CVAR (Bool, r_swtruecolor) extern IDirect3D9 *D3D; @@ -765,11 +766,7 @@ void D3DFB::KillNativeTexs() bool D3DFB::CreateFBTexture () { -#ifndef PALETTEOUTPUT - D3DFORMAT FBFormat = D3DFMT_A8R8G8B8; -#else - D3DFORMAT FBFormat = D3DFMT_L8; -#endif + FBFormat = r_swtruecolor ? D3DFMT_A8R8G8B8 : D3DFMT_L8; if (FAILED(D3DDevice->CreateTexture(Width, Height, 1, D3DUSAGE_DYNAMIC, FBFormat, D3DPOOL_DEFAULT, &FBTexture, NULL))) { @@ -1310,20 +1307,45 @@ void D3DFB::Draw3DPart(bool copy3d) SUCCEEDED(FBTexture->LockRect (0, &lockrect, NULL, D3DLOCK_DISCARD))) || SUCCEEDED(FBTexture->LockRect (0, &lockrect, &texrect, 0))) { - if (lockrect.Pitch == Pitch * sizeof(canvas_pixel_t) && Pitch == Width) + if (r_swtruecolor && FBFormat == D3DFMT_A8R8G8B8) { - memcpy (lockrect.pBits, MemBuffer, Width * Height * sizeof(canvas_pixel_t)); + if (lockrect.Pitch == Pitch * sizeof(uint32_t) && Pitch == Width) + { + memcpy(lockrect.pBits, MemBuffer, Width * Height * sizeof(uint32_t)); + } + else + { + uint32_t *dest = (uint32_t *)lockrect.pBits; + uint32_t *src = MemBuffer; + for (int y = 0; y < Height; y++) + { + memcpy(dest, src, Width * sizeof(uint32_t)); + dest = reinterpret_cast(reinterpret_cast(dest) + lockrect.Pitch); + src += Pitch; + } + } + } + else if (!r_swtruecolor && FBFormat == D3DFMT_L8) + { + if (lockrect.Pitch == Pitch && Pitch == Width) + { + memcpy(lockrect.pBits, MemBuffer, Width * Height); + } + else + { + BYTE *dest = (BYTE *)lockrect.pBits; + BYTE *src = (BYTE *)MemBuffer; + for (int y = 0; y < Height; y++) + { + memcpy(dest, src, Width); + dest = reinterpret_cast(reinterpret_cast(dest) + lockrect.Pitch); + src += Pitch; + } + } } else { - canvas_pixel_t *dest = (canvas_pixel_t *)lockrect.pBits; - canvas_pixel_t *src = MemBuffer; - for (int y = 0; y < Height; y++) - { - memcpy (dest, src, Width * sizeof(canvas_pixel_t)); - dest = reinterpret_cast(reinterpret_cast(dest) + lockrect.Pitch); - src += Pitch; - } + memset(lockrect.pBits, 0, lockrect.Pitch * Height); } FBTexture->UnlockRect (0); } @@ -1355,11 +1377,10 @@ void D3DFB::Draw3DPart(bool copy3d) memset(Constant, 0, sizeof(Constant)); SetAlphaBlend(D3DBLENDOP(0)); EnableAlphaTest(FALSE); -#ifndef PALETTEOUTPUT - SetPixelShader(Shaders[SHADER_NormalColor]); -#else - SetPixelShader(Shaders[SHADER_NormalColorPal]); -#endif + if (r_swtruecolor) + SetPixelShader(Shaders[SHADER_NormalColor]); + else + SetPixelShader(Shaders[SHADER_NormalColorPal]); if (copy3d) { FBVERTEX verts[4]; @@ -1377,11 +1398,10 @@ void D3DFB::Draw3DPart(bool copy3d) realfixedcolormap->ColorizeStart[1]/2, realfixedcolormap->ColorizeStart[2]/2, 0); color1 = D3DCOLOR_COLORVALUE(realfixedcolormap->ColorizeEnd[0]/2, realfixedcolormap->ColorizeEnd[1]/2, realfixedcolormap->ColorizeEnd[2]/2, 1); -#ifndef PALETTEOUTPUT - SetPixelShader(Shaders[SHADER_SpecialColormap]); -#else - SetPixelShader(Shaders[SHADER_SpecialColormapPal]); -#endif + if (r_swtruecolor) + SetPixelShader(Shaders[SHADER_SpecialColormap]); + else + SetPixelShader(Shaders[SHADER_SpecialColormapPal]); } } else @@ -1392,11 +1412,10 @@ void D3DFB::Draw3DPart(bool copy3d) CalcFullscreenCoords(verts, Accel2D, false, color0, color1); D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX)); } -#ifndef PALETTEOUTPUT - SetPixelShader(Shaders[SHADER_NormalColor]); -#else - SetPixelShader(Shaders[SHADER_NormalColorPal]); -#endif + if (r_swtruecolor) + SetPixelShader(Shaders[SHADER_NormalColor]); + else + SetPixelShader(Shaders[SHADER_NormalColorPal]); } //========================================================================== diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index 73a2c6966..d26765100 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -424,6 +424,7 @@ private: bool NeedPalUpdate; bool NeedGammaUpdate; int FBWidth, FBHeight; + D3DFORMAT FBFormat; bool VSync; RECT BlendingRect; int In2D; diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 62761a417..001172185 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1780,6 +1780,7 @@ DSPLYMNU_BRIGHTNESS = "Brightness"; DSPLYMNU_VSYNC = "Vertical Sync"; DSPLYMNU_CAPFPS = "Rendering Interpolation"; DSPLYMNU_COLUMNMETHOD = "Column render mode"; +DSPLYMNU_TRUECOLOR = "True color output"; DSPLYMNU_WIPETYPE = "Screen wipe style"; DSPLYMNU_SHOWENDOOM = "Show ENDOOM screen"; DSPLYMNU_PALLETEHACK = "DirectDraw palette hack"; // Not used diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index ff395ff2a..93e33ce79 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -661,6 +661,7 @@ OptionMenu "VideoOptions" Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff" Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn" Option "$DSPLYMNU_COLUMNMETHOD", "r_columnmethod", "ColumnMethods" + Option "$DSPLYMNU_TRUECOLOR", "r_swtruecolor", "OnOff" StaticText " " Option "$DSPLYMNU_WIPETYPE", "wipetype", "Wipes" From 20b7743ec39088186e49142146d40c43e0cccae5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 31 May 2016 01:49:39 +0200 Subject: [PATCH 0614/1509] Added R_SetColorMapLight and R_SetDSColorMapLight --- src/f_wipe.cpp | 37 +++++++------ src/r_draw.cpp | 27 ++++++++++ src/r_draw.h | 6 +++ src/r_main.h | 4 -- src/r_plane.cpp | 9 +--- src/r_segs.cpp | 90 ++++++++++--------------------- src/r_things.cpp | 24 ++------- src/textures/canvastexture.cpp | 9 ++-- src/v_draw.cpp | 49 +++++++++-------- src/v_video.cpp | 98 ++++++++++++++++++---------------- 10 files changed, 166 insertions(+), 187 deletions(-) diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index c6f20cadb..a86f93fc4 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -33,6 +33,8 @@ // SCREEN WIPE PACKAGE // +EXTERN_CVAR(Bool, r_swtruecolor) + static int CurrentWipeType; static short *wipe_scr_start; @@ -77,10 +79,8 @@ bool wipe_initMelt (int ticks) { int i, r; -#ifdef PALETTEOUTPUT // copy start screen to main screen - screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start); -#endif + screen->DrawBlock(0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_start); // makes this wipe faster (in theory) // to have stuff in column-major format @@ -301,9 +301,6 @@ bool wipe_doBurn (int ticks) } else { -#ifndef PALETTEOUTPUT - // TO DO: RGB32k.All -#else int bglevel = 64-fglevel; DWORD *fg2rgb = Col2RGB8[fglevel]; DWORD *bg2rgb = Col2RGB8[bglevel]; @@ -311,7 +308,6 @@ bool wipe_doBurn (int ticks) DWORD bg = bg2rgb[fromold[x]]; fg = (fg+bg) | 0x1f07c1f; to[x] = RGB32k.All[fg & (fg>>15)]; -#endif done = false; } } @@ -342,9 +338,7 @@ bool wipe_doFade (int ticks) fade += ticks * 2; if (fade > 64) { -#ifdef PALETTEOUTPUT - screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_end); -#endif + screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_end); return true; } else @@ -391,14 +385,15 @@ static bool (*wipes[])(int) = // Returns true if the wipe should be performed. bool wipe_StartScreen (int type) { + if (r_swtruecolor) + return false; + CurrentWipeType = clamp(type, 0, wipe_NUMWIPES - 1); if (CurrentWipeType) { wipe_scr_start = new short[SCREENWIDTH * SCREENHEIGHT / 2]; -#ifdef PALETTEOUTPUT - screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start); -#endif + screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_start); return true; } return false; @@ -406,13 +401,15 @@ bool wipe_StartScreen (int type) void wipe_EndScreen (void) { + if (r_swtruecolor) + return; + if (CurrentWipeType) { wipe_scr_end = new short[SCREENWIDTH * SCREENHEIGHT / 2]; -#ifdef PALETTEOUTPUT - screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_end); - screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start); // restore start scr. -#endif + screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_end); + screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_start); // restore start scr. + // Initialize the wipe (*wipes[(CurrentWipeType-1)*3])(0); } @@ -423,6 +420,9 @@ bool wipe_ScreenWipe (int ticks) { bool rc; + if (r_swtruecolor) + return true; + if (CurrentWipeType == wipe_None) return true; @@ -436,6 +436,9 @@ bool wipe_ScreenWipe (int ticks) // Final things for the wipe void wipe_Cleanup() { + if (r_swtruecolor) + return; + if (wipe_scr_start != NULL) { delete[] wipe_scr_start; diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 83a4472f3..cd34a71b4 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -4601,3 +4601,30 @@ bool R_GetTransMaskDrawers (fixed_t (**tmvline1)(), void (**tmvline4)()) return false; } +void R_SetColorMapLight(BYTE *basecolormapdata, float light, int shade) +{ + if (r_swtruecolor) + { + dc_colormap = basecolormapdata; + dc_light = LIGHTSCALE(light, shade); + } + else + { + dc_colormap = basecolormapdata + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); + dc_light = 0; + } +} + +void R_SetDSColorMapLight(BYTE *basecolormapdata, float light, int shade) +{ + if (r_swtruecolor) + { + ds_colormap = basecolormapdata; + ds_light = LIGHTSCALE(light, shade); + } + else + { + ds_colormap = basecolormapdata + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); + ds_light = 0; + } +} diff --git a/src/r_draw.h b/src/r_draw.h index 17698c360..db109dbee 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -386,4 +386,10 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ // transmaskwallscan is like maskwallscan, but it can also blend to the background void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); +// Sets dc_colormap and dc_light to their appropriate values depending on the output format (pal vs true color) +void R_SetColorMapLight(BYTE *base_colormap, float light, int shade); + +// Same as R_SetColorMapLight, but for ds_colormap and ds_light +void R_SetDSColorMapLight(BYTE *base_colormap, float light, int shade); + #endif diff --git a/src/r_main.h b/src/r_main.h index 37a41a763..c1034ea3e 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -86,8 +86,6 @@ extern bool r_dontmaplines; // This is used instead of GETPALOOKUP when ds_colormap+dc_colormap is set to the base colormap #define LIGHTSCALE(vis,shade) ((shade)-FLOAT2FIXED(MIN(MAXLIGHTVIS,double(vis)))) -#ifndef PALETTEOUTPUT - // calculates the light constant passed to the shade_pal_index function inline uint32_t calc_light_multiplier(dsfixed_t light) { @@ -108,8 +106,6 @@ inline uint32_t shade_pal_index(uint32_t index, uint32_t light) return 0xff000000 | (red << 16) | (green << 8) | blue; } -#endif - extern double GlobVis; void R_SetVisibility(double visibility); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index c8258a1ba..8d0c882ba 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -227,14 +227,7 @@ void R_MapPlane (int y, int x1) if (plane_shade) { // Determine lighting based on the span's distance from the viewer. -#ifndef PALETTEOUTPUT - ds_colormap = basecolormap->Maps; - ds_light = LIGHTSCALE(GlobVis * fabs(CenterY - y), planeshade); -#else - ds_colormap = basecolormap->Maps + (GETPALOOKUP ( - GlobVis * fabs(CenterY - y), planeshade) << COLORMAPSHIFT); - ds_light = 0; -#endif + R_SetDSColorMapLight(basecolormap->Maps, GlobVis * fabs(CenterY - y), planeshade); } #ifdef X86_ASM diff --git a/src/r_segs.cpp b/src/r_segs.cpp index fb27a99de..548cd994f 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -61,6 +61,8 @@ CVAR(Bool, r_np2, true, 0) //CVAR (Int, ty, 8, 0) //CVAR (Int, tx, 8, 0) +EXTERN_CVAR(Bool, r_swtruecolor) + #define HEIGHTBITS 12 #define HEIGHTSHIFT (FRACBITS-HEIGHTBITS) @@ -1138,13 +1140,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l if (!fixed) { // calculate lighting -#ifndef PALETTEOUTPUT - dc_colormap = basecolormapdata; - dc_light = LIGHTSCALE(light, wallshade); -#else - dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); - dc_light = 0; -#endif + R_SetColorMapLight(basecolormapdata, light, wallshade); } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1184,13 +1180,16 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l for (z = 0; z < 4; ++z) { light += rw_lightstep; -#ifndef PALETTEOUTPUT - palookupoffse[z] = basecolormapdata; - palookuplight[z] = LIGHTSCALE(light, wallshade); -#else - palookupoffse[z] = basecolormapdata + (GETPALOOKUP(12/*light*/, wallshade) << COLORMAPSHIFT); - palookuplight[z] = 0; -#endif + if (r_swtruecolor) + { + palookupoffse[z] = basecolormapdata; + palookuplight[z] = LIGHTSCALE(light, wallshade); + } + else + { + palookupoffse[z] = basecolormapdata + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); + palookuplight[z] = 0; + } } } @@ -1245,13 +1244,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l if (!fixed) { // calculate lighting -#ifndef PALETTEOUTPUT - dc_colormap = basecolormapdata; - dc_light = LIGHTSCALE(light, wallshade); -#else - dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); - dc_light = 0; -#endif + R_SetColorMapLight(basecolormapdata, light, wallshade); } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1690,13 +1683,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f if (!fixed) { // calculate lighting -#ifndef PALETTEOUTPUT - dc_colormap = basecolormapdata; - dc_light = LIGHTSCALE(light, wallshade); -#else - dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); - dc_light = 0; -#endif + R_SetColorMapLight(basecolormapdata, light, wallshade); } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1734,12 +1721,15 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f for (z = 0; z < 4; ++z) { light += rw_lightstep; -#ifndef PALETTEOUTPUT - palookupoffse[z] = basecolormapdata; - palookuplight[z] = LIGHTSCALE(light, wallshade); -#else - palookupoffse[z] = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); -#endif + if (r_swtruecolor) + { + palookupoffse[z] = basecolormapdata; + palookuplight[z] = LIGHTSCALE(light, wallshade); + } + else + { + palookupoffse[z] = basecolormapdata + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); + } } } @@ -1795,13 +1785,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f if (!fixed) { // calculate lighting -#ifndef PALETTEOUTPUT - dc_colormap = basecolormapdata; - dc_light = LIGHTSCALE(light, wallshade); -#else - dc_colormap = basecolormapdata + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); - dc_light = 0; -#endif + R_SetColorMapLight(basecolormapdata, light, wallshade); } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -3295,13 +3279,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting -#ifndef PALETTEOUTPUT - dc_colormap = usecolormap->Maps; - dc_light = LIGHTSCALE(rw_light, wallshade); -#else - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); - dc_light = 0; -#endif + R_SetColorMapLight(usecolormap->Maps, rw_light, wallshade); } R_WallSpriteColumn (R_DrawMaskedColumn); dc_x++; @@ -3311,13 +3289,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting -#ifndef PALETTEOUTPUT - dc_colormap = usecolormap->Maps; - dc_light = LIGHTSCALE(rw_light, wallshade); -#else - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); - dc_light = 0; -#endif + R_SetColorMapLight(usecolormap->Maps, rw_light, wallshade); } rt_initcols(nullptr); for (int zz = 4; zz; --zz) @@ -3332,13 +3304,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting -#ifndef PALETTEOUTPUT - dc_colormap = usecolormap->Maps; - dc_light = LIGHTSCALE(rw_light, wallshade); -#else - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); - dc_light = 0; -#endif + R_SetColorMapLight(usecolormap->Maps, rw_light, wallshade); } R_WallSpriteColumn (R_DrawMaskedColumn); dc_x++; diff --git a/src/r_things.cpp b/src/r_things.cpp index a6f6aea28..22538bd40 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -594,13 +594,7 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting -#ifndef PALETTEOUTPUT - dc_colormap = usecolormap->Maps; - dc_light = LIGHTSCALE(rw_light, shade); -#else - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); - dc_light = FLOAT2FIXED(MAXLIGHTVIS); -#endif + R_SetColorMapLight(usecolormap->Maps, rw_light, shade); } if (!R_ClipSpriteColumnWithPortals(spr)) R_WallSpriteColumn(R_DrawMaskedColumn); @@ -611,13 +605,7 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting -#ifndef PALETTEOUTPUT - dc_colormap = usecolormap->Maps; - dc_light = LIGHTSCALE(rw_light, shade); -#else - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); - dc_light = FLOAT2FIXED(MAXLIGHTVIS); -#endif + R_SetColorMapLight(usecolormap->Maps, rw_light, shade); } rt_initcols(nullptr); for (int zz = 4; zz; --zz) @@ -633,13 +621,7 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting -#ifndef PALETTEOUTPUT - dc_colormap = usecolormap->Maps; - dc_light = LIGHTSCALE(rw_light, shade); -#else - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); - dc_light = FLOAT2FIXED(MAXLIGHTVIS); -#endif + R_SetColorMapLight(usecolormap->Maps, rw_light, shade); } if (!R_ClipSpriteColumnWithPortals(spr)) R_WallSpriteColumn(R_DrawMaskedColumn); diff --git a/src/textures/canvastexture.cpp b/src/textures/canvastexture.cpp index 7388c1306..d1f70439f 100644 --- a/src/textures/canvastexture.cpp +++ b/src/textures/canvastexture.cpp @@ -106,10 +106,7 @@ void FCanvasTexture::MakeTexture () Canvas = new DSimpleCanvas (Width, Height); Canvas->Lock (); GC::AddSoftRoot(Canvas); -#ifndef PALETTEOUTPUT - Pixels = new BYTE[Width*Height]; - bPixelsAllocated = true; -#else + if (Width != Height || Width != Canvas->GetPitch()) { Pixels = new BYTE[Width*Height]; @@ -117,10 +114,10 @@ void FCanvasTexture::MakeTexture () } else { - Pixels = Canvas->GetBuffer(); + Pixels = (BYTE*)Canvas->GetBuffer(); bPixelsAllocated = false; } -#endif + // Draw a special "unrendered" initial texture into the buffer. memset (Pixels, 0, Width*Height/2); memset (Pixels+Width*Height/2, 255, Width*Height/2); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 8853fc947..984375f25 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -77,6 +77,8 @@ extern "C" short spanend[MAXHEIGHT]; CVAR (Bool, hud_scale, false, CVAR_ARCHIVE); +EXTERN_CVAR(Bool, r_swtruecolor) + // For routines that take RGB colors, cache the previous lookup in case there // are several repetitions with the same color. static int LastPal = -1; @@ -1017,32 +1019,35 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) oldyyshifted = yy * GetPitch(); } -#ifndef PALETTEOUTPUT - canvas_pixel_t *spot = GetBuffer() + oldyyshifted + xx; + if (r_swtruecolor) + { + canvas_pixel_t *spot = GetBuffer() + oldyyshifted + xx; - uint32_t fg = shade_pal_index(basecolor, calc_light_multiplier(0)); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; + uint32_t fg = shade_pal_index(basecolor, calc_light_multiplier(0)); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; - uint32_t bg_red = (*spot >> 16) & 0xff; - uint32_t bg_green = (*spot >> 8) & 0xff; - uint32_t bg_blue = (*spot) & 0xff; + uint32_t bg_red = (*spot >> 16) & 0xff; + uint32_t bg_green = (*spot >> 8) & 0xff; + uint32_t bg_blue = (*spot) & 0xff; - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; + uint32_t red = (fg_red + bg_red + 1) / 2; + uint32_t green = (fg_green + bg_green + 1) / 2; + uint32_t blue = (fg_blue + bg_blue + 1) / 2; - *spot = 0xff000000 | (red << 16) | (green << 8) | blue; -#else - canvas_pixel_t *spot = GetBuffer() + oldyyshifted + xx; - DWORD *bg2rgb = Col2RGB8[1+level]; - DWORD *fg2rgb = Col2RGB8[63-level]; - DWORD fg = fg2rgb[basecolor]; - DWORD bg = bg2rgb[*spot]; - bg = (fg+bg) | 0x1f07c1f; - *spot = RGB32k.All[bg&(bg>>15)]; -#endif + *spot = 0xff000000 | (red << 16) | (green << 8) | blue; + } + else + { + canvas_pixel_t *spot = GetBuffer() + oldyyshifted + xx; + DWORD *bg2rgb = Col2RGB8[1+level]; + DWORD *fg2rgb = Col2RGB8[63-level]; + DWORD fg = fg2rgb[basecolor]; + DWORD bg = bg2rgb[*spot]; + bg = (fg+bg) | 0x1f07c1f; + *spot = RGB32k.All[bg&(bg>>15)]; + } } void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 realcolor) diff --git a/src/v_video.cpp b/src/v_video.cpp index b6a626753..2fb46e88a 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -65,6 +65,7 @@ #include "menu/menu.h" #include "r_data/voxels.h" +EXTERN_CVAR(Bool, r_swtruecolor) FRenderer *Renderer; @@ -367,65 +368,68 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) spot = Buffer + x1 + y1*Pitch; gap = Pitch - w; -#ifndef PALETTEOUTPUT - uint32_t fg = color.d; - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t alpha = (uint32_t)clamp(damount * 256 + 0.5f, 0.0f, 256.0f); - uint32_t inv_alpha = 256 - alpha; - - fg_red *= alpha; - fg_green *= alpha; - fg_blue *= alpha; - - for (y = h; y != 0; y--) + if (r_swtruecolor) { - for (x = w; x != 0; x--) + uint32_t fg = color.d; + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t alpha = (uint32_t)clamp(damount * 256 + 0.5f, 0.0f, 256.0f); + uint32_t inv_alpha = 256 - alpha; + + fg_red *= alpha; + fg_green *= alpha; + fg_blue *= alpha; + + for (y = h; y != 0; y--) { - uint32_t bg_red = (*spot >> 16) & 0xff; - uint32_t bg_green = (*spot >> 8) & 0xff; - uint32_t bg_blue = (*spot) & 0xff; + for (x = w; x != 0; x--) + { + uint32_t bg_red = (*spot >> 16) & 0xff; + uint32_t bg_green = (*spot >> 8) & 0xff; + uint32_t bg_blue = (*spot) & 0xff; - uint32_t red = (fg_red + bg_red * inv_alpha) / 256; - uint32_t green = (fg_green + bg_green * inv_alpha) / 256; - uint32_t blue = (fg_blue + bg_blue * inv_alpha) / 256; + uint32_t red = (fg_red + bg_red * inv_alpha) / 256; + uint32_t green = (fg_green + bg_green * inv_alpha) / 256; + uint32_t blue = (fg_blue + bg_blue * inv_alpha) / 256; - *spot = 0xff000000 | (red << 16) | (green << 8) | blue; - spot++; + *spot = 0xff000000 | (red << 16) | (green << 8) | blue; + spot++; + } + spot += gap; } - spot += gap; } -#else - DWORD *bg2rgb; - DWORD fg; - + else { - int amount; + DWORD *bg2rgb; + DWORD fg; - amount = (int)(damount * 64); - bg2rgb = Col2RGB8[64-amount]; - - fg = (((color.r * amount) >> 4) << 20) | - ((color.g * amount) >> 4) | - (((color.b * amount) >> 4) << 10); - } - - for (y = h; y != 0; y--) - { - for (x = w; x != 0; x--) { - DWORD bg; + int amount; - bg = bg2rgb[(*spot)&0xff]; - bg = (fg+bg) | 0x1f07c1f; - *spot = RGB32k.All[bg&(bg>>15)]; - spot++; + amount = (int)(damount * 64); + bg2rgb = Col2RGB8[64-amount]; + + fg = (((color.r * amount) >> 4) << 20) | + ((color.g * amount) >> 4) | + (((color.b * amount) >> 4) << 10); + } + + for (y = h; y != 0; y--) + { + for (x = w; x != 0; x--) + { + DWORD bg; + + bg = bg2rgb[(*spot)&0xff]; + bg = (fg+bg) | 0x1f07c1f; + *spot = RGB32k.All[bg&(bg>>15)]; + spot++; + } + spot += gap; } - spot += gap; } -#endif } //========================================================================== From 045bad1b5287d75f2c9f3d84e4a6cc2975499c18 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 31 May 2016 05:31:32 +0200 Subject: [PATCH 0615/1509] Removed the need for the pixel_canvas_t typedef --- src/basictypes.h | 6 -- src/f_wipe.cpp | 14 +-- src/m_misc.cpp | 2 - src/r_draw.cpp | 234 ++++++++++++++++++++--------------------- src/r_draw.h | 12 +-- src/r_drawt.cpp | 71 +++++++------ src/r_drawt_rgba.cpp | 94 ++++++++--------- src/r_main.cpp | 34 ++++-- src/r_plane.cpp | 130 ++++++++++++++++++++++- src/r_plane.h | 4 + src/r_segs.cpp | 93 ++++++++++------ src/r_things.cpp | 23 ++-- src/v_draw.cpp | 112 +++++++++++++++----- src/v_video.cpp | 35 ++++-- src/v_video.h | 14 +-- src/win32/fb_d3d9.cpp | 6 +- src/win32/fb_ddraw.cpp | 4 +- src/win32/win32iface.h | 2 +- 18 files changed, 561 insertions(+), 329 deletions(-) diff --git a/src/basictypes.h b/src/basictypes.h index 45e33a4a7..ff2cd972e 100644 --- a/src/basictypes.h +++ b/src/basictypes.h @@ -66,12 +66,6 @@ union QWORD_UNION typedef SDWORD fixed_t; typedef DWORD dsfixed_t; // fixedpt used by span drawer -#ifndef PALETTEOUTPUT -typedef uint32_t canvas_pixel_t; -#else -typedef BYTE canvas_pixel_t; -#endif - #define FIXED_MAX (signed)(0x7fffffff) #define FIXED_MIN (signed)(0x80000000) diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index a86f93fc4..7e1ec678e 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -80,7 +80,7 @@ bool wipe_initMelt (int ticks) int i, r; // copy start screen to main screen - screen->DrawBlock(0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_start); + screen->DrawBlock(0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start); // makes this wipe faster (in theory) // to have stuff in column-major format @@ -273,7 +273,7 @@ bool wipe_doBurn (int ticks) // Draw the screen int xstep, ystep, firex, firey; int x, y; - canvas_pixel_t *to; + BYTE *to; BYTE *fromold, *fromnew; const int SHIFT = 16; @@ -338,7 +338,7 @@ bool wipe_doFade (int ticks) fade += ticks * 2; if (fade > 64) { - screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_end); + screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_end); return true; } else @@ -349,7 +349,7 @@ bool wipe_doFade (int ticks) DWORD *bg2rgb = Col2RGB8[bglevel]; BYTE *fromnew = (BYTE *)wipe_scr_end; BYTE *fromold = (BYTE *)wipe_scr_start; - canvas_pixel_t *to = screen->GetBuffer(); + BYTE *to = screen->GetBuffer(); for (y = 0; y < SCREENHEIGHT; y++) { @@ -393,7 +393,7 @@ bool wipe_StartScreen (int type) if (CurrentWipeType) { wipe_scr_start = new short[SCREENWIDTH * SCREENHEIGHT / 2]; - screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_start); + screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start); return true; } return false; @@ -407,8 +407,8 @@ void wipe_EndScreen (void) if (CurrentWipeType) { wipe_scr_end = new short[SCREENWIDTH * SCREENHEIGHT / 2]; - screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_end); - screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_start); // restore start scr. + screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_end); + screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start); // restore start scr. // Initialize the wipe (*wipes[(CurrentWipeType-1)*3])(0); diff --git a/src/m_misc.cpp b/src/m_misc.cpp index 79416c31d..87f61f253 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -655,7 +655,6 @@ static bool FindFreeName (FString &fullname, const char *extension) void M_ScreenShot (const char *filename) { -#ifdef PALETTEOUTPUT FILE *file; FString autoname; bool writepcx = (stricmp (screenshot_type, "pcx") == 0); // PNG is the default @@ -744,7 +743,6 @@ void M_ScreenShot (const char *filename) Printf ("Could not create screenshot.\n"); } } -#endif } CCMD (screenshot) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index cd34a71b4..f939406bb 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -65,7 +65,7 @@ extern int ST_Y; BYTE* viewimage; extern "C" { int ylookup[MAXHEIGHT]; -canvas_pixel_t *dc_destorg; +BYTE* dc_destorg; } int scaledviewwidth; @@ -99,6 +99,7 @@ void (*R_DrawSpanMaskedAddClamp)(void); void (*R_FillSpan)(void); void (*R_FillColumnHoriz)(void); void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); +void (*R_MapTiltedPlane)(int y, int x1); void (*R_MapColoredPlane)(int y, int x1); void (*R_DrawParticle)(vissprite_t *); fixed_t (*tmvline1_add)(); @@ -133,7 +134,7 @@ void (*rt_tlateadd4cols)(int sx, int yl, int yh); void (*rt_tlateaddclamp4cols)(int sx, int yl, int yh); void (*rt_tlatesubclamp4cols)(int sx, int yl, int yh); void (*rt_tlaterevsubclamp4cols)(int sx, int yl, int yh); -void (*rt_initcols)(canvas_pixel_t *buffer); +void (*rt_initcols)(BYTE *buffer); // // R_DrawColumn @@ -158,7 +159,7 @@ DWORD *dc_destblend; // blending lookups // first pixel in a column (possibly virtual) const BYTE* dc_source; -canvas_pixel_t* dc_dest; +BYTE* dc_dest; int dc_count; DWORD vplce[4]; @@ -236,7 +237,7 @@ void R_InitShadeMaps() void R_DrawColumnP_C (void) { int count; - canvas_pixel_t* dest; + BYTE* dest; fixed_t frac; fixed_t fracstep; @@ -281,7 +282,7 @@ void R_DrawColumnP_C (void) void R_DrawColumnP_RGBA_C() { int count; - canvas_pixel_t* dest; + uint32_t* dest; fixed_t frac; fixed_t fracstep; @@ -292,7 +293,7 @@ void R_DrawColumnP_RGBA_C() return; // Framebuffer destination address. - dest = dc_dest; + dest = (uint32_t*)dc_dest; uint32_t light = calc_light_multiplier(dc_light); @@ -328,7 +329,7 @@ void R_DrawColumnP_RGBA_C() void R_FillColumnP_C (void) { int count; - canvas_pixel_t* dest; + BYTE* dest; count = dc_count; @@ -352,14 +353,14 @@ void R_FillColumnP_C (void) void R_FillColumnP_RGBA() { int count; - canvas_pixel_t* dest; + uint32_t* dest; count = dc_count; if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; uint32_t light = calc_light_multiplier(dc_light); @@ -378,7 +379,7 @@ void R_FillColumnP_RGBA() void R_FillAddColumn_C (void) { int count; - canvas_pixel_t *dest; + BYTE *dest; count = dc_count; if (count <= 0) @@ -405,13 +406,13 @@ void R_FillAddColumn_C (void) void R_FillAddColumn_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; count = dc_count; if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; int pitch = dc_pitch; uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; @@ -436,7 +437,7 @@ void R_FillAddColumn_RGBA_C() void R_FillAddClampColumn_C (void) { int count; - canvas_pixel_t *dest; + BYTE *dest; count = dc_count; if (count <= 0) @@ -469,13 +470,13 @@ void R_FillAddClampColumn_C (void) void R_FillAddClampColumn_RGBA() { int count; - canvas_pixel_t *dest; + uint32_t *dest; count = dc_count; if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; int pitch = dc_pitch; uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; @@ -500,7 +501,7 @@ void R_FillAddClampColumn_RGBA() void R_FillSubClampColumn_C (void) { int count; - canvas_pixel_t *dest; + BYTE *dest; count = dc_count; if (count <= 0) @@ -532,13 +533,13 @@ void R_FillSubClampColumn_C (void) void R_FillSubClampColumn_RGBA() { int count; - canvas_pixel_t *dest; + uint32_t *dest; count = dc_count; if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; int pitch = dc_pitch; uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; @@ -563,7 +564,7 @@ void R_FillSubClampColumn_RGBA() void R_FillRevSubClampColumn_C (void) { int count; - canvas_pixel_t *dest; + BYTE *dest; count = dc_count; if (count <= 0) @@ -595,13 +596,13 @@ void R_FillRevSubClampColumn_C (void) void R_FillRevSubClampColumn_RGBA() { int count; - canvas_pixel_t *dest; + uint32_t *dest; count = dc_count; if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; int pitch = dc_pitch; uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; @@ -673,7 +674,7 @@ void R_InitFuzzTable (int fuzzoff) void R_DrawFuzzColumnP_C (void) { int count; - canvas_pixel_t *dest; + BYTE *dest; // Adjust borders. Low... if (dc_yl == 0) @@ -745,7 +746,7 @@ void R_DrawFuzzColumnP_C (void) void R_DrawFuzzColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; // Adjust borders. Low... if (dc_yl == 0) @@ -763,7 +764,7 @@ void R_DrawFuzzColumnP_RGBA_C() count++; - dest = ylookup[dc_yl] + dc_x + dc_destorg; + dest = ylookup[dc_yl] + dc_x + (uint32_t*)dc_destorg; // Note: this implementation assumes this function is only used for the pinky shadow effect (i.e. no other fancy colormap than black) // I'm not sure if this is really always the case or not. @@ -890,7 +891,7 @@ algorithm that uses RGB tables. void R_DrawAddColumnP_C (void) { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -928,7 +929,7 @@ void R_DrawAddColumnP_C (void) void R_DrawAddColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -936,7 +937,7 @@ void R_DrawAddColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -980,7 +981,7 @@ void R_DrawAddColumnP_RGBA_C() void R_DrawTranslatedColumnP_C (void) { int count; - canvas_pixel_t* dest; + BYTE* dest; fixed_t frac; fixed_t fracstep; @@ -1012,7 +1013,7 @@ void R_DrawTranslatedColumnP_C (void) void R_DrawTranslatedColumnP_RGBA_C() { int count; - canvas_pixel_t* dest; + uint32_t* dest; fixed_t frac; fixed_t fracstep; @@ -1022,7 +1023,7 @@ void R_DrawTranslatedColumnP_RGBA_C() uint32_t light = calc_light_multiplier(dc_light); - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1047,7 +1048,7 @@ void R_DrawTranslatedColumnP_RGBA_C() void R_DrawTlatedAddColumnP_C() { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -1086,7 +1087,7 @@ void R_DrawTlatedAddColumnP_C() void R_DrawTlatedAddColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -1096,7 +1097,7 @@ void R_DrawTlatedAddColumnP_RGBA_C() uint32_t light = calc_light_multiplier(dc_light); - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1135,7 +1136,7 @@ void R_DrawTlatedAddColumnP_RGBA_C() void R_DrawShadedColumnP_C (void) { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac, fracstep; count = dc_count; @@ -1170,7 +1171,7 @@ void R_DrawShadedColumnP_C (void) void R_DrawShadedColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac, fracstep; count = dc_count; @@ -1178,7 +1179,7 @@ void R_DrawShadedColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1217,7 +1218,7 @@ void R_DrawShadedColumnP_RGBA_C() void R_DrawAddClampColumnP_C () { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -1234,24 +1235,20 @@ void R_DrawAddClampColumnP_C () const BYTE *source = dc_source; BYTE *colormap = dc_colormap; int pitch = dc_pitch; - uint32_t light = calc_light_multiplier(dc_light); + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; do { - uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; + DWORD a = fg2rgb[colormap[source[frac >> FRACBITS]]] + bg2rgb[*dest]; + DWORD b = a; - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a >> 15)]; dest += pitch; frac += fracstep; } while (--count); @@ -1261,7 +1258,7 @@ void R_DrawAddClampColumnP_C () void R_DrawAddClampColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -1269,7 +1266,7 @@ void R_DrawAddClampColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1306,7 +1303,7 @@ void R_DrawAddClampColumnP_RGBA_C() void R_DrawAddClampTranslatedColumnP_C () { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -1347,7 +1344,7 @@ void R_DrawAddClampTranslatedColumnP_C () void R_DrawAddClampTranslatedColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -1355,7 +1352,7 @@ void R_DrawAddClampTranslatedColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1393,7 +1390,7 @@ void R_DrawAddClampTranslatedColumnP_RGBA_C() void R_DrawSubClampColumnP_C () { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -1432,7 +1429,7 @@ void R_DrawSubClampColumnP_C () void R_DrawSubClampColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -1440,7 +1437,7 @@ void R_DrawSubClampColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1477,7 +1474,7 @@ void R_DrawSubClampColumnP_RGBA_C() void R_DrawSubClampTranslatedColumnP_C () { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -1517,7 +1514,7 @@ void R_DrawSubClampTranslatedColumnP_C () void R_DrawSubClampTranslatedColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -1525,7 +1522,7 @@ void R_DrawSubClampTranslatedColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1563,7 +1560,7 @@ void R_DrawSubClampTranslatedColumnP_RGBA_C() void R_DrawRevSubClampColumnP_C () { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -1602,7 +1599,7 @@ void R_DrawRevSubClampColumnP_C () void R_DrawRevSubClampColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -1610,7 +1607,7 @@ void R_DrawRevSubClampColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1647,7 +1644,7 @@ void R_DrawRevSubClampColumnP_RGBA_C() void R_DrawRevSubClampTranslatedColumnP_C () { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -1687,7 +1684,7 @@ void R_DrawRevSubClampTranslatedColumnP_C () void R_DrawRevSubClampTranslatedColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -1695,7 +1692,7 @@ void R_DrawRevSubClampTranslatedColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1855,7 +1852,7 @@ void R_DrawSpanP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + BYTE* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -1927,7 +1924,7 @@ void R_DrawSpanP_RGBA_C() dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + uint32_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -1945,7 +1942,7 @@ void R_DrawSpanP_RGBA_C() xfrac = ds_xfrac; yfrac = ds_yfrac; - dest = ylookup[ds_y] + ds_x1 + dc_destorg; + dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; count = ds_x2 - ds_x1 + 1; @@ -2051,7 +2048,7 @@ void R_DrawSpanMaskedP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + BYTE* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2114,7 +2111,7 @@ void R_DrawSpanMaskedP_RGBA_C() dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + uint32_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2125,7 +2122,7 @@ void R_DrawSpanMaskedP_RGBA_C() xfrac = ds_xfrac; yfrac = ds_yfrac; - dest = ylookup[ds_y] + ds_x1 + dc_destorg; + dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; count = ds_x2 - ds_x1 + 1; @@ -2179,7 +2176,7 @@ void R_DrawSpanTranslucentP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + BYTE* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2241,7 +2238,7 @@ void R_DrawSpanTranslucentP_RGBA_C() dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + uint32_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2252,7 +2249,7 @@ void R_DrawSpanTranslucentP_RGBA_C() xfrac = ds_xfrac; yfrac = ds_yfrac; - dest = ylookup[ds_y] + ds_x1 + dc_destorg; + dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; count = ds_x2 - ds_x1 + 1; @@ -2323,7 +2320,7 @@ void R_DrawSpanMaskedTranslucentP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + BYTE* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2399,7 +2396,7 @@ void R_DrawSpanMaskedTranslucentP_RGBA_C() dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + uint32_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2412,7 +2409,7 @@ void R_DrawSpanMaskedTranslucentP_RGBA_C() xfrac = ds_xfrac; yfrac = ds_yfrac; - dest = ylookup[ds_y] + ds_x1 + dc_destorg; + dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; count = ds_x2 - ds_x1 + 1; @@ -2491,7 +2488,7 @@ void R_DrawSpanAddClampP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + BYTE* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2561,7 +2558,7 @@ void R_DrawSpanAddClampP_RGBA_C() dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + uint32_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2574,7 +2571,7 @@ void R_DrawSpanAddClampP_RGBA_C() xfrac = ds_xfrac; yfrac = ds_yfrac; - dest = ylookup[ds_y] + ds_x1 + dc_destorg; + dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; count = ds_x2 - ds_x1 + 1; @@ -2643,7 +2640,7 @@ void R_DrawSpanMaskedAddClampP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + BYTE* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2725,7 +2722,7 @@ void R_DrawSpanMaskedAddClampP_RGBA_C() dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + uint32_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2738,7 +2735,7 @@ void R_DrawSpanMaskedAddClampP_RGBA_C() xfrac = ds_xfrac; yfrac = ds_yfrac; - dest = ylookup[ds_y] + ds_x1 + dc_destorg; + dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; count = ds_x2 - ds_x1 + 1; @@ -2819,7 +2816,7 @@ void R_FillSpan_C (void) void R_FillSpan_RGBA() { - canvas_pixel_t *dest = ylookup[ds_y] + ds_x1 + dc_destorg; + uint32_t *dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; int count = (ds_x2 - ds_x1 + 1); uint32_t light = calc_light_multiplier(ds_light); uint32_t color = shade_pal_index(ds_color, light); @@ -2843,7 +2840,7 @@ extern "C" void R_SetupDrawSlabC(const BYTE *colormap) slabcolormap = colormap; } -extern "C" void R_DrawSlabC(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, canvas_pixel_t *p) +extern "C" void R_DrawSlabC(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p) { int x; const BYTE *colormap = slabcolormap; @@ -3017,7 +3014,7 @@ DWORD vlinec1 () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int bits = vlinebits; int pitch = dc_pitch; @@ -3039,7 +3036,7 @@ DWORD vlinec1_RGBA() BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int bits = vlinebits; int pitch = dc_pitch; @@ -3058,7 +3055,7 @@ DWORD vlinec1_RGBA() #if !defined(X86_ASM) void vlinec4 () { - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int count = dc_count; int bits = vlinebits; DWORD place; @@ -3076,7 +3073,7 @@ void vlinec4 () void vlinec4_RGBA() { - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int count = dc_count; int bits = vlinebits; @@ -3162,7 +3159,7 @@ DWORD mvlinec1 () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int bits = mvlinebits; int pitch = dc_pitch; @@ -3188,7 +3185,7 @@ DWORD mvlinec1_RGBA() BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int bits = mvlinebits; int pitch = dc_pitch; @@ -3211,7 +3208,7 @@ DWORD mvlinec1_RGBA() #if !defined(X86_ASM) void mvlinec4 () { - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int count = dc_count; int bits = mvlinebits; DWORD place; @@ -3230,7 +3227,7 @@ void mvlinec4 () void mvlinec4_RGBA() { - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int count = dc_count; int bits = mvlinebits; DWORD place; @@ -3260,7 +3257,7 @@ extern int wallshade; static void R_DrawFogBoundarySection (int y, int y2, int x1) { BYTE *colormap = dc_colormap; - canvas_pixel_t *dest = ylookup[y] + dc_destorg; + BYTE *dest = ylookup[y] + dc_destorg; for (; y < y2; ++y) { @@ -3278,7 +3275,7 @@ static void R_DrawFogBoundaryLine (int y, int x) { int x2 = spanend[y]; BYTE *colormap = dc_colormap; - canvas_pixel_t *dest = ylookup[y] + dc_destorg; + BYTE *dest = ylookup[y] + dc_destorg; do { @@ -3380,7 +3377,7 @@ void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip) static void R_DrawFogBoundarySection_RGBA(int y, int y2, int x1) { BYTE *colormap = dc_colormap; - canvas_pixel_t *dest = ylookup[y] + dc_destorg; + uint32_t *dest = ylookup[y] + (uint32_t*)dc_destorg; uint32_t light = calc_light_multiplier(dc_light); @@ -3400,7 +3397,7 @@ static void R_DrawFogBoundaryLine_RGBA(int y, int x) { int x2 = spanend[y]; BYTE *colormap = dc_colormap; - canvas_pixel_t *dest = ylookup[y] + dc_destorg; + uint32_t *dest = ylookup[y] + (uint32_t*)dc_destorg; uint32_t light = calc_light_multiplier(dc_light); @@ -3518,7 +3515,7 @@ fixed_t tmvline1_add_C () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -3551,7 +3548,7 @@ fixed_t tmvline1_add_RGBA() BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -3589,7 +3586,7 @@ fixed_t tmvline1_add_RGBA() void tmvline4_add_C () { - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int count = dc_count; int bits = tmvlinebits; @@ -3622,13 +3619,10 @@ void tmvline4_add_C () void tmvline4_add_RGBA() { - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int count = dc_count; int bits = tmvlinebits; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; - uint32_t light[4]; light[0] = calc_light_multiplier(palookuplight[0]); light[1] = calc_light_multiplier(palookuplight[1]); @@ -3670,7 +3664,7 @@ fixed_t tmvline1_addclamp_C () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -3708,7 +3702,7 @@ fixed_t tmvline1_addclamp_RGBA() BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -3746,7 +3740,7 @@ fixed_t tmvline1_addclamp_RGBA() void tmvline4_addclamp_C () { - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int count = dc_count; int bits = tmvlinebits; @@ -3778,7 +3772,7 @@ void tmvline4_addclamp_C () void tmvline4_addclamp_RGBA() { - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int count = dc_count; int bits = tmvlinebits; @@ -3823,7 +3817,7 @@ fixed_t tmvline1_subclamp_C () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -3858,7 +3852,7 @@ fixed_t tmvline1_subclamp_RGBA() BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -3893,7 +3887,7 @@ fixed_t tmvline1_subclamp_RGBA() void tmvline4_subclamp_C () { - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int count = dc_count; int bits = tmvlinebits; @@ -3924,7 +3918,7 @@ void tmvline4_subclamp_C () void tmvline4_subclamp_RGBA() { - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int count = dc_count; int bits = tmvlinebits; @@ -3969,7 +3963,7 @@ fixed_t tmvline1_revsubclamp_C () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -4004,7 +3998,7 @@ fixed_t tmvline1_revsubclamp_RGBA() BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -4039,7 +4033,7 @@ fixed_t tmvline1_revsubclamp_RGBA() void tmvline4_revsubclamp_C () { - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int count = dc_count; int bits = tmvlinebits; @@ -4070,7 +4064,7 @@ void tmvline4_revsubclamp_C () void tmvline4_revsubclamp_RGBA() { - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int count = dc_count; int bits = tmvlinebits; @@ -4168,6 +4162,7 @@ void R_InitColumnDrawers () R_FillColumnHoriz = R_FillColumnHorizP_RGBA_C; R_DrawFogBoundary = R_DrawFogBoundary_RGBA; + R_MapTiltedPlane = R_MapColoredPlane_RGBA; R_MapColoredPlane = R_MapColoredPlane_RGBA; R_DrawParticle = R_DrawParticle_RGBA; @@ -4262,6 +4257,7 @@ void R_InitColumnDrawers () R_FillColumnHoriz = R_FillColumnHorizP_C; R_DrawFogBoundary = R_DrawFogBoundary_C; + R_MapTiltedPlane = R_MapColoredPlane_C; R_MapColoredPlane = R_MapColoredPlane_C; R_DrawParticle = R_DrawParticle_C; diff --git a/src/r_draw.h b/src/r_draw.h index db109dbee..2348914b6 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -45,7 +45,7 @@ extern "C" DWORD *dc_destblend; // first pixel in a column extern "C" const BYTE* dc_source; -extern "C" canvas_pixel_t *dc_dest, *dc_destorg; +extern "C" BYTE* dc_dest, *dc_destorg; extern "C" int dc_count; extern "C" DWORD vplce[4]; @@ -55,7 +55,7 @@ extern "C" fixed_t palookuplight[4]; extern "C" const BYTE* bufplce[4]; // [RH] Temporary buffer for column drawing -extern "C" canvas_pixel_t *dc_temp; +extern "C" BYTE *dc_temp; extern "C" unsigned int dc_tspans[4][MAXHEIGHT]; extern "C" unsigned int *dc_ctspan[4]; extern "C" unsigned int horizspans[4]; @@ -228,13 +228,13 @@ extern void (*rt_tlateaddclamp4cols)(int sx, int yl, int yh); extern void (*rt_tlatesubclamp4cols)(int sx, int yl, int yh); extern void (*rt_tlaterevsubclamp4cols)(int sx, int yl, int yh); -extern void (*rt_initcols)(canvas_pixel_t *buffer); +extern void (*rt_initcols)(BYTE *buffer); void rt_draw4cols (int sx); // [RH] Preps the temporary horizontal buffer. -void rt_initcols_pal (canvas_pixel_t *buffer); -void rt_initcols_rgba (canvas_pixel_t *buffer); +void rt_initcols_pal (BYTE *buffer); +void rt_initcols_rgba (BYTE *buffer); extern void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); @@ -313,7 +313,7 @@ void R_FillSpan_RGBA_C(void); #endif extern "C" void R_SetupDrawSlab(const BYTE *colormap); -extern "C" void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, canvas_pixel_t *p); +extern "C" void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); extern "C" int ds_y; extern "C" int ds_x1; diff --git a/src/r_drawt.cpp b/src/r_drawt.cpp index 9520f59b3..485ed7ab3 100644 --- a/src/r_drawt.cpp +++ b/src/r_drawt.cpp @@ -47,6 +47,8 @@ #include "r_things.h" #include "v_video.h" +EXTERN_CVAR(Bool, r_swtruecolor) + // I should have commented this stuff better. // // dc_temp is the buffer R_DrawColumnHoriz writes into. @@ -57,8 +59,8 @@ // dc_ctspan is advanced while drawing into dc_temp. // horizspan is advanced up to dc_ctspan when drawing from dc_temp to the screen. -canvas_pixel_t dc_tempbuff[MAXHEIGHT*4]; -canvas_pixel_t *dc_temp; +BYTE dc_tempbuff[MAXHEIGHT*4]; +BYTE *dc_temp; unsigned int dc_tspans[4][MAXHEIGHT]; unsigned int *dc_ctspan[4]; unsigned int *horizspan[4]; @@ -73,8 +75,8 @@ extern "C" void R_SetupAddClampCol(); // Copies one span at hx to the screen at sx. void rt_copy1col_c (int hx, int sx, int yl, int yh) { - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; int pitch; @@ -148,8 +150,8 @@ void rt_copy4cols_c (int sx, int yl, int yh) void rt_map1col_c (int hx, int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; int pitch; @@ -183,8 +185,8 @@ void rt_map1col_c (int hx, int sx, int yl, int yh) void rt_map4cols_c (int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; int pitch; @@ -227,7 +229,7 @@ void rt_map4cols_c (int sx, int yl, int yh) void rt_Translate1col(const BYTE *translation, int hx, int yl, int yh) { int count = yh - yl + 1; - canvas_pixel_t *source = &dc_temp[yl*4 + hx]; + BYTE *source = &dc_temp[yl*4 + hx]; // Things we do to hit the compiler's optimizer with a clue bat: // 1. Parallelism is explicitly spelled out by using a separate @@ -274,7 +276,7 @@ void rt_Translate1col(const BYTE *translation, int hx, int yl, int yh) void rt_Translate4cols(const BYTE *translation, int yl, int yh) { int count = yh - yl + 1; - canvas_pixel_t *source = &dc_temp[yl*4]; + BYTE *source = &dc_temp[yl*4]; int c0, c1; BYTE b0, b1; @@ -330,8 +332,8 @@ void rt_tlate4cols_c (int sx, int yl, int yh) void rt_add1col_c (int hx, int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; int pitch; @@ -364,8 +366,8 @@ void rt_add1col_c (int hx, int sx, int yl, int yh) void rt_add4cols_c (int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; int pitch; @@ -435,8 +437,8 @@ void rt_tlateadd4cols_c (int sx, int yl, int yh) void rt_shaded1col_c (int hx, int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; int pitch; @@ -467,8 +469,8 @@ void rt_shaded1col_c (int hx, int sx, int yl, int yh) void rt_shaded4cols_c (int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; int pitch; @@ -513,8 +515,8 @@ void rt_shaded4cols_c (int sx, int yl, int yh) void rt_addclamp1col_c (int hx, int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; int pitch; @@ -550,8 +552,8 @@ void rt_addclamp1col_c (int hx, int sx, int yl, int yh) void rt_addclamp4cols_c (int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; int pitch; @@ -629,8 +631,8 @@ void rt_tlateaddclamp4cols_c (int sx, int yl, int yh) void rt_subclamp1col_c (int hx, int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; int pitch; @@ -664,8 +666,8 @@ void rt_subclamp1col_c (int hx, int sx, int yl, int yh) void rt_subclamp4cols_c (int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; int pitch; @@ -738,8 +740,8 @@ void rt_tlatesubclamp4cols_c (int sx, int yl, int yh) void rt_revsubclamp1col_c (int hx, int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; int pitch; @@ -773,8 +775,8 @@ void rt_revsubclamp1col_c (int hx, int sx, int yl, int yh) void rt_revsubclamp4cols_c (int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; int pitch; @@ -1007,7 +1009,7 @@ void rt_draw4cols (int sx) // Before each pass through a rendering loop that uses these routines, // call this function to set up the span pointers. -void rt_initcols_pal (canvas_pixel_t *buff) +void rt_initcols_pal (BYTE *buff) { int y; @@ -1021,7 +1023,7 @@ void rt_initcols_pal (canvas_pixel_t *buff) void R_DrawColumnHorizP_C (void) { int count = dc_count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t fracstep; fixed_t frac; @@ -1082,7 +1084,7 @@ void R_FillColumnHorizP_C (void) { int count = dc_count; BYTE color = dc_color; - canvas_pixel_t *dest; + BYTE *dest; if (count <= 0) return; @@ -1113,6 +1115,7 @@ void R_FillColumnHorizP_C (void) void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span) { + int pixelsize = r_swtruecolor ? 4 : 1; const fixed_t texturemid = FLOAT2FIXED(dc_texturemid); while (span->Length != 0) { @@ -1182,7 +1185,7 @@ void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span) } } dc_source = column + top; - dc_dest = ylookup[dc_yl] + dc_x + dc_destorg; + dc_dest = (ylookup[dc_yl] + dc_x) * pixelsize + dc_destorg; dc_count = dc_yh - dc_yl + 1; hcolfunc_pre (); } diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index e8111be8f..872cb4b89 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -43,8 +43,8 @@ #include "r_things.h" #include "v_video.h" -canvas_pixel_t dc_temp_rgbabuff_rgba[MAXHEIGHT*4]; -canvas_pixel_t *dc_temp_rgba; +uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT*4]; +uint32_t *dc_temp_rgba; // Defined in r_draw_t.cpp: extern unsigned int dc_tspans[4][MAXHEIGHT]; @@ -54,8 +54,8 @@ extern unsigned int *horizspan[4]; // Copies one span at hx to the screen at sx. void rt_copy1col_RGBA_c (int hx, int sx, int yl, int yh) { - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -64,7 +64,7 @@ void rt_copy1col_RGBA_c (int hx, int sx, int yl, int yh) return; count++; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; @@ -106,8 +106,8 @@ void rt_copy4cols_RGBA_c (int sx, int yl, int yh) void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -119,7 +119,7 @@ void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh) uint32_t light = calc_light_multiplier(dc_light); colormap = dc_colormap; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; @@ -143,8 +143,8 @@ void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh) void rt_map4cols_RGBA_c (int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -156,7 +156,7 @@ void rt_map4cols_RGBA_c (int sx, int yl, int yh) uint32_t light = calc_light_multiplier(dc_light); colormap = dc_colormap; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; @@ -188,7 +188,7 @@ void rt_map4cols_RGBA_c (int sx, int yl, int yh) void rt_Translate1col_RGBA_c(const BYTE *translation, int hx, int yl, int yh) { int count = yh - yl + 1; - canvas_pixel_t *source = &dc_temp_rgba[yl*4 + hx]; + uint32_t *source = &dc_temp_rgba[yl*4 + hx]; // Things we do to hit the compiler's optimizer with a clue bat: // 1. Parallelism is explicitly spelled out by using a separate @@ -235,7 +235,7 @@ void rt_Translate1col_RGBA_c(const BYTE *translation, int hx, int yl, int yh) void rt_Translate4cols_RGBA_c(const BYTE *translation, int yl, int yh) { int count = yh - yl + 1; - canvas_pixel_t *source = &dc_temp_rgba[yl*4]; + uint32_t *source = &dc_temp_rgba[yl*4]; int c0, c1; BYTE b0, b1; @@ -291,8 +291,8 @@ void rt_tlate4cols_RGBA_c (int sx, int yl, int yh) void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -301,7 +301,7 @@ void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh) return; count++; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; colormap = dc_colormap; @@ -333,8 +333,8 @@ void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh) void rt_add4cols_RGBA_c (int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -343,7 +343,7 @@ void rt_add4cols_RGBA_c (int sx, int yl, int yh) return; count++; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; colormap = dc_colormap; @@ -392,8 +392,8 @@ void rt_tlateadd4cols_RGBA_c(int sx, int yl, int yh) void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -403,7 +403,7 @@ void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh) count++; colormap = dc_colormap; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; @@ -434,8 +434,8 @@ void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh) void rt_shaded4cols_RGBA_c (int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -445,7 +445,7 @@ void rt_shaded4cols_RGBA_c (int sx, int yl, int yh) count++; colormap = dc_colormap; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; @@ -479,8 +479,8 @@ void rt_shaded4cols_RGBA_c (int sx, int yl, int yh) void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -489,7 +489,7 @@ void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh) return; count++; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; colormap = dc_colormap; @@ -520,8 +520,8 @@ void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh) void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -530,7 +530,7 @@ void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh) return; count++; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; colormap = dc_colormap; @@ -578,8 +578,8 @@ void rt_tlateaddclamp4cols_RGBA_c (int sx, int yl, int yh) void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -588,7 +588,7 @@ void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh) return; count++; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; colormap = dc_colormap; @@ -619,8 +619,8 @@ void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh) void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -629,7 +629,7 @@ void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh) return; count++; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; colormap = dc_colormap; @@ -678,8 +678,8 @@ void rt_tlatesubclamp4cols_RGBA_c (int sx, int yl, int yh) void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -690,7 +690,7 @@ void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; colormap = dc_colormap; @@ -721,8 +721,8 @@ void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -733,7 +733,7 @@ void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh) DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; colormap = dc_colormap; @@ -780,11 +780,11 @@ void rt_tlaterevsubclamp4cols_RGBA_c (int sx, int yl, int yh) // Before each pass through a rendering loop that uses these routines, // call this function to set up the span pointers. -void rt_initcols_rgba (canvas_pixel_t *buff) +void rt_initcols_rgba (BYTE *buff) { int y; - dc_temp_rgba = buff == NULL ? dc_temp_rgbabuff_rgba : buff; + dc_temp_rgba = buff == NULL ? dc_temp_rgbabuff_rgba : (uint32_t*)buff; for (y = 3; y >= 0; y--) horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0]; } @@ -794,7 +794,7 @@ void rt_initcols_rgba (canvas_pixel_t *buff) void R_DrawColumnHorizP_RGBA_C (void) { int count = dc_count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t fracstep; fixed_t frac; @@ -855,7 +855,7 @@ void R_FillColumnHorizP_RGBA_C (void) { int count = dc_count; BYTE color = dc_color; - canvas_pixel_t *dest; + uint32_t *dest; if (count <= 0) return; diff --git a/src/r_main.cpp b/src/r_main.cpp index d85cd62a0..9dc61eea3 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -577,9 +577,12 @@ void R_HighlightPortal (PortalDrawseg* pds) // [ZZ] NO OVERFLOW CHECKS HERE // I believe it won't break. if it does, blame me. :( + if (r_swtruecolor) // Assuming this is just a debug function + return; + BYTE color = (BYTE)BestColor((DWORD *)GPalette.BaseColors, 255, 0, 0, 0, 255); - canvas_pixel_t* pixels = RenderTarget->GetBuffer(); + BYTE* pixels = RenderTarget->GetBuffer(); // top edge for (int x = pds->x1; x < pds->x2; x++) { @@ -624,12 +627,26 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) int Ytop = pds->ceilingclip[x-pds->x1]; int Ybottom = pds->floorclip[x-pds->x1]; - canvas_pixel_t *dest = RenderTarget->GetBuffer() + x + Ytop * spacing; - - for (int y = Ytop; y <= Ybottom; y++) + if (r_swtruecolor) { - *dest = color; - dest += spacing; + uint32_t *dest = (uint32_t*)RenderTarget->GetBuffer() + x + Ytop * spacing; + + uint32_t c = GPalette.BaseColors[color].d; + for (int y = Ytop; y <= Ybottom; y++) + { + *dest = c; + dest += spacing; + } + } + else + { + BYTE *dest = RenderTarget->GetBuffer() + x + Ytop * spacing; + + for (int y = Ytop; y <= Ybottom; y++) + { + *dest = color; + dest += spacing; + } } } @@ -795,10 +812,11 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) void R_SetupBuffer () { - static canvas_pixel_t *lastbuff = NULL; + static BYTE *lastbuff = NULL; int pitch = RenderTarget->GetPitch(); - canvas_pixel_t *lineptr = RenderTarget->GetBuffer() + viewwindowy*pitch + viewwindowx; + int pixelsize = r_swtruecolor ? 4 : 1; + BYTE *lineptr = RenderTarget->GetBuffer() + (viewwindowy*pitch + viewwindowx) * pixelsize; if (dc_pitch != pitch || lineptr != lastbuff) { diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 8d0c882ba..a71590c9d 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -354,12 +354,12 @@ void R_CalcTiltedLighting (double lval, double lend, int width) // //========================================================================== -void R_MapTiltedPlane (int y, int x1) +void R_MapTiltedPlane_C (int y, int x1) { int x2 = spanend[y]; int width = x2 - x1; double iz, uz, vz; - canvas_pixel_t *fb; + BYTE *fb; DWORD u, v; int i; @@ -478,6 +478,130 @@ void R_MapTiltedPlane (int y, int x1) #endif } +void R_MapTiltedPlane_RGBA (int y, int x1) +{ + int x2 = spanend[y]; + int width = x2 - x1; + double iz, uz, vz; + uint32_t *fb; + DWORD u, v; + int i; + + iz = plane_sz[2] + plane_sz[1]*(centery-y) + plane_sz[0]*(x1-centerx); + + // Lighting is simple. It's just linear interpolation from start to end + if (plane_shade) + { + uz = (iz + plane_sz[0]*width) * planelightfloat; + vz = iz * planelightfloat; + R_CalcTiltedLighting (vz, uz, width); + } + + uz = plane_su[2] + plane_su[1]*(centery-y) + plane_su[0]*(x1-centerx); + vz = plane_sv[2] + plane_sv[1]*(centery-y) + plane_sv[0]*(x1-centerx); + + fb = ylookup[y] + x1 + (uint32_t*)dc_destorg; + + BYTE vshift = 32 - ds_ybits; + BYTE ushift = vshift - ds_xbits; + int umask = ((1 << ds_xbits) - 1) << ds_ybits; + +#if 0 // The "perfect" reference version of this routine. Pretty slow. + // Use it only to see how things are supposed to look. + i = 0; + do + { + double z = 1.f/iz; + + u = SQWORD(uz*z) + pviewx; + v = SQWORD(vz*z) + pviewy; + ds_colormap = tiltlighting[i]; + ds_light = 0; + fb[i++] = ds_colormap[ds_source[(v >> vshift) | ((u >> ushift) & umask)]]; + iz += plane_sz[0]; + uz += plane_su[0]; + vz += plane_sv[0]; + } while (--width >= 0); +#else +//#define SPANSIZE 32 +//#define INVSPAN 0.03125f +//#define SPANSIZE 8 +//#define INVSPAN 0.125f +#define SPANSIZE 16 +#define INVSPAN 0.0625f + + double startz = 1.f/iz; + double startu = uz*startz; + double startv = vz*startz; + double izstep, uzstep, vzstep; + + izstep = plane_sz[0] * SPANSIZE; + uzstep = plane_su[0] * SPANSIZE; + vzstep = plane_sv[0] * SPANSIZE; + x1 = 0; + width++; + + while (width >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + double endz = 1.f/iz; + double endu = uz*endz; + double endv = vz*endz; + DWORD stepu = SQWORD((endu - startu) * INVSPAN); + DWORD stepv = SQWORD((endv - startv) * INVSPAN); + u = SQWORD(startu) + pviewx; + v = SQWORD(startv) + pviewy; + + for (i = SPANSIZE-1; i >= 0; i--) + { + fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); + x1++; + u += stepu; + v += stepv; + } + startu = endu; + startv = endv; + width -= SPANSIZE; + } + if (width > 0) + { + if (width == 1) + { + u = SQWORD(startu); + v = SQWORD(startv); + fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); + } + else + { + double left = width; + iz += plane_sz[0] * left; + uz += plane_su[0] * left; + vz += plane_sv[0] * left; + + double endz = 1.f/iz; + double endu = uz*endz; + double endv = vz*endz; + left = 1.f/left; + DWORD stepu = SQWORD((endu - startu) * left); + DWORD stepv = SQWORD((endv - startv) * left); + u = SQWORD(startu) + pviewx; + v = SQWORD(startv) + pviewy; + + for (; width != 0; width--) + { + fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); + x1++; + u += stepu; + v += stepv; + } + } + } +#endif +} + //========================================================================== // // R_MapColoredPlane @@ -491,7 +615,7 @@ void R_MapColoredPlane_C (int y, int x1) void R_MapColoredPlane_RGBA(int y, int x1) { - canvas_pixel_t *dest = ylookup[y] + x1 + dc_destorg; + uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg; int count = (spanend[y] - x1 + 1); uint32_t light = calc_light_multiplier(ds_light); uint32_t color = shade_pal_index(ds_color, light); diff --git a/src/r_plane.h b/src/r_plane.h index ac63501e3..7505ac995 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -94,6 +94,10 @@ void R_DrawTiltedPlane (visplane_t *pl, double xscale, double yscale, fixed_t al void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1)); extern void(*R_MapColoredPlane)(int y, int x1); +extern void(*R_MapTiltedPlane)(int y, int x1); + +void R_MapTiltedPlane_C(int y, int x1); +void R_MapTiltedPlane_RGBA(int y, int x); void R_MapColoredPlane_C(int y, int x1); void R_MapColoredPlane_RGBA(int y, int x1); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 548cd994f..8c71f0fb7 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1071,7 +1071,7 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2) } // prevlineasm1 is like vlineasm1 but skips the loop if only drawing one pixel -inline fixed_t prevline1 (fixed_t vince, BYTE *colormap, fixed_t light, int count, fixed_t vplce, const BYTE *bufplce, canvas_pixel_t *dest) +inline fixed_t prevline1 (fixed_t vince, BYTE *colormap, fixed_t light, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest) { dc_iscale = vince; dc_colormap = colormap; @@ -1107,6 +1107,8 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l //extern cycle_t WallScanCycles; //clock (WallScanCycles); + int pixelsize = r_swtruecolor ? 4 : 1; + rw_pic->GetHeight(); // Make sure texture size is loaded fracbits = 32 - rw_pic->HeightBits; setupvline(fracbits); @@ -1144,7 +1146,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); - dc_dest = ylookup[y1ve[0]] + x + dc_destorg; + dc_dest = (ylookup[y1ve[0]] + x)*pixelsize + dc_destorg; dc_count = y2ve[0] - y1ve[0]; iscale = swal[x] * yrepeat; dc_iscale = xs_ToFixed(fracbits, iscale); @@ -1202,7 +1204,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l { if (!(bad & 1)) { - prevline1(vince[z],palookupoffse[z],palookuplight[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+x+z+dc_destorg); + prevline1(vince[z],palookupoffse[z],palookuplight[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+x+z)*pixelsize+dc_destorg); } bad >>= 1; } @@ -1213,23 +1215,23 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l { if (u4 > y1ve[z]) { - vplce[z] = prevline1(vince[z],palookupoffse[z], palookuplight[z],u4-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+x+z+dc_destorg); + vplce[z] = prevline1(vince[z],palookupoffse[z], palookuplight[z],u4-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+x+z)*pixelsize+dc_destorg); } } if (d4 > u4) { dc_count = d4-u4; - dc_dest = ylookup[u4]+x+dc_destorg; + dc_dest = (ylookup[u4]+x)*pixelsize+dc_destorg; dovline4(); } - canvas_pixel_t *i = x+ylookup[d4]+dc_destorg; + BYTE *i = (x+ylookup[d4])*pixelsize+dc_destorg; for (z = 0; z < 4; ++z) { if (y2ve[z] > d4) { - prevline1(vince[z],palookupoffse[0],palookuplight[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z); + prevline1(vince[z],palookupoffse[0],palookuplight[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z*pixelsize); } } } @@ -1248,7 +1250,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); - dc_dest = ylookup[y1ve[0]] + x + dc_destorg; + dc_dest = (ylookup[y1ve[0]] + x) * pixelsize + dc_destorg; dc_count = y2ve[0] - y1ve[0]; iscale = swal[x] * yrepeat; dc_iscale = xs_ToFixed(fracbits, iscale); @@ -1435,7 +1437,7 @@ static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *d } } -inline fixed_t mvline1 (fixed_t vince, BYTE *colormap, int count, fixed_t vplce, const BYTE *bufplce, canvas_pixel_t *dest) +inline fixed_t mvline1 (fixed_t vince, BYTE *colormap, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest) { dc_iscale = vince; dc_colormap = colormap; @@ -1451,7 +1453,8 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) { int x, fracbits; - canvas_pixel_t *p; + BYTE *pixel; + int pixelsize, pixelshift; int y1ve[4], y2ve[4], u4, d4, startx, dax, z; char bad; float light = rw_light - rw_lightstep; @@ -1473,6 +1476,9 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ //extern cycle_t WallScanCycles; //clock (WallScanCycles); + pixelsize = r_swtruecolor ? 4 : 1; + pixelshift = r_swtruecolor ? 2 : 0; + rw_pic->GetHeight(); // Make sure texture size is loaded fracbits = 32- rw_pic->HeightBits; setupmvline(fracbits); @@ -1480,7 +1486,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ basecolormapdata = basecolormap->Maps; x = startx = x1; - p = x + dc_destorg; + pixel = x * pixelsize + dc_destorg; bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); if (fixed) @@ -1489,9 +1495,13 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ palookupoffse[1] = dc_colormap; palookupoffse[2] = dc_colormap; palookupoffse[3] = dc_colormap; + palookuplight[0] = 0; + palookuplight[1] = 0; + palookuplight[2] = 0; + palookuplight[3] = 0; } - for(; (x < x2) && (((size_t)p/sizeof(canvas_pixel_t)) & 3); ++x, ++p) + for(; (x < x2) && (((size_t)pixel >> pixelshift) & 3); ++x, pixel += pixelsize) { light += rw_lightstep; y1ve[0] = uwal[x];//max(uwal[x],umost[x]); @@ -1505,7 +1515,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); - dc_dest = ylookup[y1ve[0]] + p; + dc_dest = ylookup[y1ve[0]] * pixelsize + pixel; dc_count = y2ve[0] - y1ve[0]; iscale = swal[x] * yrepeat; dc_iscale = xs_ToFixed(fracbits, iscale); @@ -1514,7 +1524,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ domvline1(); } - for(; x < x2-3; x += 4, p+= 4) + for(; x < x2-3; x += 4, pixel += 4 * pixelsize) { bad = 0; for (z = 3, dax = x+3; z >= 0; --z, --dax) @@ -1539,7 +1549,16 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ for (z = 0; z < 4; ++z) { light += rw_lightstep; - palookupoffse[z] = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); + if (r_swtruecolor) + { + palookupoffse[z] = basecolormapdata; + palookuplight[z] = LIGHTSCALE(light, wallshade); + } + else + { + palookupoffse[z] = basecolormapdata + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); + palookuplight[z] = 0; + } } } @@ -1552,7 +1571,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ { if (!(bad & 1)) { - mvline1(vince[z],palookupoffse[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+p+z); + mvline1(vince[z],palookupoffse[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel); } bad >>= 1; } @@ -1563,27 +1582,27 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ { if (u4 > y1ve[z]) { - vplce[z] = mvline1(vince[z],palookupoffse[z],u4-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+p+z); + vplce[z] = mvline1(vince[z],palookupoffse[z],u4-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel); } } if (d4 > u4) { dc_count = d4-u4; - dc_dest = ylookup[u4]+p; + dc_dest = ylookup[u4]*pixelsize+pixel; domvline4(); } - canvas_pixel_t *i = p+ylookup[d4]; + BYTE *i = pixel+ylookup[d4]*pixelsize; for (z = 0; z < 4; ++z) { if (y2ve[z] > d4) { - mvline1(vince[z],palookupoffse[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z); + mvline1(vince[z],palookupoffse[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z*pixelsize); } } } - for(; x < x2; ++x, ++p) + for(; x < x2; ++x, pixel += pixelsize) { light += rw_lightstep; y1ve[0] = uwal[x]; @@ -1597,7 +1616,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); - dc_dest = ylookup[y1ve[0]] + p; + dc_dest = ylookup[y1ve[0]]*pixelsize + pixel; dc_count = y2ve[0] - y1ve[0]; iscale = swal[x] * yrepeat; dc_iscale = xs_ToFixed(fracbits, iscale); @@ -1611,7 +1630,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ NetUpdate (); } -inline void preptmvline1 (fixed_t vince, BYTE *colormap, fixed_t light, int count, fixed_t vplce, const BYTE *bufplce, canvas_pixel_t *dest) +inline void preptmvline1 (fixed_t vince, BYTE *colormap, fixed_t light, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest) { dc_iscale = vince; dc_colormap = colormap; @@ -1628,7 +1647,8 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f fixed_t (*tmvline1)(); void (*tmvline4)(); int x, fracbits; - canvas_pixel_t *p; + BYTE *pixel; + int pixelsize, pixelshift; int y1ve[4], y2ve[4], u4, d4, startx, dax, z; char bad; float light = rw_light - rw_lightstep; @@ -1651,6 +1671,9 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f //extern cycle_t WallScanCycles; //clock (WallScanCycles); + pixelsize = r_swtruecolor ? 4 : 1; + pixelshift = r_swtruecolor ? 2 : 0; + rw_pic->GetHeight(); // Make sure texture size is loaded fracbits = 32 - rw_pic->HeightBits; setuptmvline(fracbits); @@ -1659,7 +1682,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f fixed_t centeryfrac = FLOAT2FIXED(CenterY); x = startx = x1; - p = x + dc_destorg; + pixel = x * pixelsize + dc_destorg; bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); if (fixed) @@ -1674,7 +1697,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f palookuplight[3] = 0; } - for(; (x < x2) && (((size_t)p / sizeof(canvas_pixel_t)) & 3); ++x, ++p) + for(; (x < x2) && (((size_t)pixel >> pixelshift) & 3); ++x, pixel += pixelsize) { light += rw_lightstep; y1ve[0] = uwal[x];//max(uwal[x],umost[x]); @@ -1687,7 +1710,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); - dc_dest = ylookup[y1ve[0]] + p; + dc_dest = ylookup[y1ve[0]] * pixelsize + pixel; dc_count = y2ve[0] - y1ve[0]; iscale = swal[x] * yrepeat; dc_iscale = xs_ToFixed(fracbits, iscale); @@ -1696,7 +1719,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f tmvline1(); } - for(; x < x2-3; x += 4, p+= 4) + for(; x < x2-3; x += 4, pixel += 4 * pixelsize) { bad = 0; for (z = 3, dax = x+3; z >= 0; --z, --dax) @@ -1742,7 +1765,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f { if (!(bad & 1)) { - preptmvline1(vince[z],palookupoffse[z],palookuplight[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+p+z); + preptmvline1(vince[z],palookupoffse[z],palookuplight[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel); tmvline1(); } bad >>= 1; @@ -1754,7 +1777,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f { if (u4 > y1ve[z]) { - preptmvline1(vince[z],palookupoffse[z],palookuplight[z],u4-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+p+z); + preptmvline1(vince[z],palookupoffse[z],palookuplight[z],u4-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel); vplce[z] = tmvline1(); } } @@ -1762,21 +1785,21 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f if (d4 > u4) { dc_count = d4-u4; - dc_dest = ylookup[u4]+p; + dc_dest = ylookup[u4]*pixelsize+pixel; tmvline4(); } - canvas_pixel_t *i = p+ylookup[d4]; + BYTE *i = pixel+ylookup[d4]*pixelsize; for (z = 0; z < 4; ++z) { if (y2ve[z] > d4) { - preptmvline1(vince[z],palookupoffse[0],palookuplight[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z); + preptmvline1(vince[z],palookupoffse[0],palookuplight[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z*pixelsize); tmvline1(); } } } - for(; x < x2; ++x, ++p) + for(; x < x2; ++x, pixel += pixelsize) { light += rw_lightstep; y1ve[0] = uwal[x]; @@ -1789,7 +1812,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); - dc_dest = ylookup[y1ve[0]] + p; + dc_dest = ylookup[y1ve[0]] * pixelsize + pixel; dc_count = y2ve[0] - y1ve[0]; iscale = swal[x] * yrepeat; dc_iscale = xs_ToFixed(fracbits, iscale); diff --git a/src/r_things.cpp b/src/r_things.cpp index 22538bd40..2abcc0e12 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -98,6 +98,7 @@ EXTERN_CVAR (Bool, st_scale) EXTERN_CVAR(Bool, r_shadercolormaps) EXTERN_CVAR(Int, r_drawfuzz) EXTERN_CVAR(Bool, r_deathcamera); +EXTERN_CVAR(Bool, r_swtruecolor) // // Sprite rotation 0 is facing the viewer, @@ -132,7 +133,7 @@ EXTERN_CVAR (Bool, r_drawvoxels) // int OffscreenBufferWidth, OffscreenBufferHeight; -canvas_pixel_t *OffscreenColorBuffer; +BYTE *OffscreenColorBuffer; FCoverageBuffer *OffscreenCoverageBuffer; // @@ -244,6 +245,7 @@ bool sprflipvert; void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span) { + int pixelsize = r_swtruecolor ? 4 : 1; const fixed_t centeryfrac = FLOAT2FIXED(CenterY); const fixed_t texturemid = FLOAT2FIXED(dc_texturemid); while (span->Length != 0) @@ -314,7 +316,7 @@ void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span) } } dc_source = column + top; - dc_dest = ylookup[dc_yl] + dc_x + dc_destorg; + dc_dest = (ylookup[dc_yl] + dc_x) * pixelsize + dc_destorg; dc_count = dc_yh - dc_yl + 1; colfunc (); } @@ -688,6 +690,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop // Blend the voxel, if that's what we need to do. if ((flags & ~DVF_MIRRORED) != 0) { + int pixelsize = r_swtruecolor ? 4 : 1; for (int x = 0; x < viewwidth; ++x) { if (!(flags & DVF_SPANSONLY) && (x & 3) == 0) @@ -702,7 +705,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop dc_yl = span->Start; dc_yh = span->Stop - 1; dc_count = span->Stop - span->Start; - dc_dest = ylookup[span->Start] + x + dc_destorg; + dc_dest = (ylookup[span->Start] + x) * pixelsize + dc_destorg; colfunc(); } else @@ -2602,7 +2605,7 @@ static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) void R_DrawParticle_C (vissprite_t *vis) { int spacing; - canvas_pixel_t *dest; + BYTE *dest; BYTE color = vis->Style.colormap[vis->startfrac]; int yl = vis->y1; int ycount = vis->y2 - yl + 1; @@ -2668,7 +2671,7 @@ void R_DrawParticle_C (vissprite_t *vis) void R_DrawParticle_RGBA(vissprite_t *vis) { int spacing; - canvas_pixel_t *dest; + uint32_t *dest; BYTE color = vis->Style.colormap[vis->startfrac]; int yl = vis->y1; int ycount = vis->y2 - yl + 1; @@ -2698,7 +2701,7 @@ void R_DrawParticle_RGBA(vissprite_t *vis) dc_x = x; if (R_ClipSpriteColumnWithPortals(vis)) continue; - dest = ylookup[yl] + x + dc_destorg; + dest = ylookup[yl] + x + (uint32_t*)dc_destorg; for (int y = 0; y < ycount; y++) { uint32_t bg_red = (*dest >> 16) & 0xff; @@ -2759,6 +2762,8 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, R_SetupDrawSlab(colormap); + int pixelsize = r_swtruecolor ? 4 : 1; + // Select mip level i = abs(DMulScale6(dasprx - globalposx, cosang, daspry - globalposy, sinang)); i = DivScale6(i, MIN(daxscale, dayscale)); @@ -3012,7 +3017,7 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, if (!(flags & DVF_OFFSCREEN)) { // Draw directly to the screen. - R_DrawSlab(xxr - xxl, yplc[xxl], z2 - z1, yinc, col, ylookup[z1] + lxt + xxl + dc_destorg); + R_DrawSlab(xxr - xxl, yplc[xxl], z2 - z1, yinc, col, (ylookup[z1] + lxt + xxl) * pixelsize + dc_destorg); } else { @@ -3243,12 +3248,12 @@ void R_CheckOffscreenBuffer(int width, int height, bool spansonly) { if (OffscreenColorBuffer == NULL) { - OffscreenColorBuffer = new canvas_pixel_t[width * height]; + OffscreenColorBuffer = new BYTE[width * height * 4]; } else if (OffscreenBufferWidth != width || OffscreenBufferHeight != height) { delete[] OffscreenColorBuffer; - OffscreenColorBuffer = new canvas_pixel_t[width * height]; + OffscreenColorBuffer = new BYTE[width * height * 4]; } } OffscreenBufferWidth = width; diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 984375f25..ed6571ad3 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -179,7 +179,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) fixedcolormap = dc_colormap; ESPSResult mode = R_SetPatchStyle (parms.style, parms.Alpha, 0, parms.fillcolor); - canvas_pixel_t *destorgsave = dc_destorg; + BYTE *destorgsave = dc_destorg; dc_destorg = screen->GetBuffer(); if (dc_destorg == NULL) { @@ -1021,7 +1021,7 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) if (r_swtruecolor) { - canvas_pixel_t *spot = GetBuffer() + oldyyshifted + xx; + uint32_t *spot = (uint32_t*)GetBuffer() + oldyyshifted + xx; uint32_t fg = shade_pal_index(basecolor, calc_light_multiplier(0)); uint32_t fg_red = (fg >> 16) & 0xff; @@ -1040,7 +1040,7 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) } else { - canvas_pixel_t *spot = GetBuffer() + oldyyshifted + xx; + BYTE *spot = GetBuffer() + oldyyshifted + xx; DWORD *bg2rgb = Col2RGB8[1+level]; DWORD *fg2rgb = Col2RGB8[63-level]; DWORD fg = fg2rgb[basecolor]; @@ -1091,27 +1091,62 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real { swapvalues (x0, x1); } - memset (GetBuffer() + y0*GetPitch() + x0, palColor, deltaX+1); + if (r_swtruecolor) + { + uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0; + for (int i = 0; i <= deltaX; i++) + spot[i] = palColor; + } + else + { + memset (GetBuffer() + y0*GetPitch() + x0, palColor, deltaX+1); + } } else if (deltaX == 0) { // vertical line - canvas_pixel_t *spot = GetBuffer() + y0*GetPitch() + x0; - int pitch = GetPitch (); - do + if (r_swtruecolor) { - *spot = palColor; - spot += pitch; - } while (--deltaY != 0); + uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0; + int pitch = GetPitch(); + do + { + *spot = palColor; + spot += pitch; + } while (--deltaY != 0); + } + else + { + BYTE *spot = GetBuffer() + y0*GetPitch() + x0; + int pitch = GetPitch(); + do + { + *spot = palColor; + spot += pitch; + } while (--deltaY != 0); + } } else if (deltaX == deltaY) { // diagonal line. - canvas_pixel_t *spot = GetBuffer() + y0*GetPitch() + x0; - int advance = GetPitch() + xDir; - do + if (r_swtruecolor) { - *spot = palColor; - spot += advance; - } while (--deltaY != 0); + uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0; + int advance = GetPitch() + xDir; + do + { + *spot = palColor; + spot += advance; + } while (--deltaY != 0); + } + else + { + BYTE *spot = GetBuffer() + y0*GetPitch() + x0; + int advance = GetPitch() + xDir; + do + { + *spot = palColor; + spot += advance; + } while (--deltaY != 0); + } } else { @@ -1231,7 +1266,6 @@ void DCanvas::DrawPixel(int x, int y, int palColor, uint32 realcolor) void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uint32 color) { int x, y; - canvas_pixel_t *dest; if (left == right || top == bottom) { @@ -1261,12 +1295,26 @@ void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uin palcolor = PalFromRGB(color); } - dest = Buffer + top * Pitch + left; - x = right - left; - for (y = top; y < bottom; y++) + if (r_swtruecolor) { - memset(dest, palcolor, x); - dest += Pitch; + uint32_t *dest = (uint32_t*)Buffer + top * Pitch + left; + x = right - left; + for (y = top; y < bottom; y++) + { + for (int i = 0; i < x; i++) + dest[i] = palcolor; + dest += Pitch; + } + } + else + { + BYTE *dest = Buffer + top * Pitch + left; + x = right - left; + for (y = top; y < bottom; y++) + { + memset(dest, palcolor, x); + dest += Pitch; + } } } @@ -1452,11 +1500,14 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, // V_DrawBlock // Draw a linear block of pixels into the view buffer. // -void DCanvas::DrawBlock (int x, int y, int _width, int _height, const canvas_pixel_t *src) const +void DCanvas::DrawBlock (int x, int y, int _width, int _height, const BYTE *src) const { + if (r_swtruecolor) + return; + int srcpitch = _width; int destpitch; - canvas_pixel_t *dest; + BYTE *dest; if (ClipBox (x, y, _width, _height, src, srcpitch)) { @@ -1468,7 +1519,7 @@ void DCanvas::DrawBlock (int x, int y, int _width, int _height, const canvas_pix do { - memcpy (dest, src, _width * sizeof(canvas_pixel_t)); + memcpy (dest, src, _width); src += srcpitch; dest += destpitch; } while (--_height); @@ -1478,9 +1529,12 @@ void DCanvas::DrawBlock (int x, int y, int _width, int _height, const canvas_pix // V_GetBlock // Gets a linear block of pixels from the view buffer. // -void DCanvas::GetBlock (int x, int y, int _width, int _height, canvas_pixel_t *dest) const +void DCanvas::GetBlock (int x, int y, int _width, int _height, BYTE *dest) const { - const canvas_pixel_t *src; + if (r_swtruecolor) + return; + + const BYTE *src; #ifdef RANGECHECK if (x<0 @@ -1496,14 +1550,14 @@ void DCanvas::GetBlock (int x, int y, int _width, int _height, canvas_pixel_t *d while (_height--) { - memcpy (dest, src, _width * sizeof(canvas_pixel_t)); + memcpy (dest, src, _width); src += Pitch; dest += _width; } } // Returns true if the box was completely clipped. False otherwise. -bool DCanvas::ClipBox (int &x, int &y, int &w, int &h, const canvas_pixel_t *&src, const int srcpitch) const +bool DCanvas::ClipBox (int &x, int &y, int &w, int &h, const BYTE *&src, const int srcpitch) const { if (x >= Width || y >= Height || x+w <= 0 || y+h <= 0) { // Completely clipped off screen diff --git a/src/v_video.cpp b/src/v_video.cpp index 2fb46e88a..01043b8bc 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -345,7 +345,6 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) return; int gap; - canvas_pixel_t *spot; int x, y; if (x1 >= Width || y1 >= Height) @@ -365,11 +364,12 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) return; } - spot = Buffer + x1 + y1*Pitch; gap = Pitch - w; if (r_swtruecolor) { + uint32_t *spot = (uint32_t*)Buffer + x1 + y1*Pitch; + uint32_t fg = color.d; uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; @@ -402,6 +402,8 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) } else { + BYTE *spot = Buffer + x1 + y1*Pitch; + DWORD *bg2rgb; DWORD fg; @@ -441,12 +443,12 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) // //========================================================================== -void DCanvas::GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSType &color_type) +void DCanvas::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type) { Lock(true); buffer = GetBuffer(); pitch = GetPitch(); - color_type = SS_PAL; + color_type = r_swtruecolor ? SS_BGRA : SS_PAL; } //========================================================================== @@ -797,8 +799,8 @@ DSimpleCanvas::DSimpleCanvas (int width, int height) Pitch = width + MAX(0, CPU.DataL1LineSize - 8); } } - MemBuffer = new canvas_pixel_t[Pitch * height]; - memset (MemBuffer, 0, Pitch * height * sizeof(canvas_pixel_t)); + MemBuffer = new BYTE[Pitch * height * 4]; + memset (MemBuffer, 0, Pitch * height * 4); } //========================================================================== @@ -917,7 +919,7 @@ void DFrameBuffer::DrawRateStuff () { int i = I_GetTime(false); int tics = i - LastTic; - canvas_pixel_t *buffer = GetBuffer(); + BYTE *buffer = GetBuffer(); LastTic = i; if (tics > 20) tics = 20; @@ -925,10 +927,21 @@ void DFrameBuffer::DrawRateStuff () // Buffer can be NULL if we're doing hardware accelerated 2D if (buffer != NULL) { - buffer += (GetHeight()-1) * GetPitch(); - - for (i = 0; i < tics*2; i += 2) buffer[i] = 0xff; - for ( ; i < 20*2; i += 2) buffer[i] = 0x00; + if (r_swtruecolor) + { + uint32_t *buffer32 = (uint32_t*)buffer; + buffer32 += (GetHeight() - 1) * GetPitch(); + + for (i = 0; i < tics * 2; i += 2) buffer32[i] = 0xffffffff; + for (; i < 20 * 2; i += 2) buffer32[i] = 0xff000000; + } + else + { + buffer += (GetHeight() - 1) * GetPitch(); + + for (i = 0; i < tics * 2; i += 2) buffer[i] = 0xff; + for (; i < 20 * 2; i += 2) buffer[i] = 0x00; + } } else { diff --git a/src/v_video.h b/src/v_video.h index 27c09ee36..fa1ce83df 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -189,7 +189,7 @@ public: virtual ~DCanvas (); // Member variable access - inline canvas_pixel_t *GetBuffer () const { return Buffer; } + inline BYTE *GetBuffer () const { return Buffer; } inline int GetWidth () const { return Width; } inline int GetHeight () const { return Height; } inline int GetPitch () const { return Pitch; } @@ -202,10 +202,10 @@ public: virtual bool IsLocked () { return Buffer != NULL; } // Returns true if the surface is locked // Draw a linear block of pixels into the canvas - virtual void DrawBlock (int x, int y, int width, int height, const canvas_pixel_t *src) const; + virtual void DrawBlock (int x, int y, int width, int height, const BYTE *src) const; // Reads a linear block of pixels into the view buffer. - virtual void GetBlock (int x, int y, int width, int height, canvas_pixel_t *dest) const; + virtual void GetBlock (int x, int y, int width, int height, BYTE *dest) const; // Dim the entire canvas for the menus virtual void Dim (PalEntry color = 0); @@ -237,7 +237,7 @@ public: // Retrieves a buffer containing image data for a screenshot. // Hint: Pitch can be negative for upside-down images, in which case buffer // points to the last row in the buffer, which will be the first row output. - virtual void GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSType &color_type); + virtual void GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type); // Releases the screenshot buffer. virtual void ReleaseScreenshotBuffer(); @@ -262,13 +262,13 @@ public: void DrawChar (FFont *font, int normalcolor, int x, int y, BYTE character, int tag_first, ...); protected: - canvas_pixel_t *Buffer; + BYTE *Buffer; int Width; int Height; int Pitch; int LockCount; - bool ClipBox (int &left, int &top, int &width, int &height, const canvas_pixel_t *&src, const int srcpitch) const; + bool ClipBox (int &left, int &top, int &width, int &height, const BYTE *&src, const int srcpitch) const; void DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags) = delete; virtual void DrawTextureParms(FTexture *img, DrawParms &parms); bool ParseDrawTextureTags (FTexture *img, double x, double y, uint32 tag, va_list tags, DrawParms *parms, bool fortext) const; @@ -297,7 +297,7 @@ public: void Unlock (); protected: - canvas_pixel_t *MemBuffer; + BYTE *MemBuffer; DSimpleCanvas() {} }; diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 0cc9045ee..0cd847b97 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -1316,7 +1316,7 @@ void D3DFB::Draw3DPart(bool copy3d) else { uint32_t *dest = (uint32_t *)lockrect.pBits; - uint32_t *src = MemBuffer; + uint32_t *src = (uint32_t*)MemBuffer; for (int y = 0; y < Height; y++) { memcpy(dest, src, Width * sizeof(uint32_t)); @@ -1744,7 +1744,7 @@ void D3DFB::SetBlendingRect(int x1, int y1, int x2, int y2) // //========================================================================== -void D3DFB::GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSType &color_type) +void D3DFB::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type) { D3DLOCKED_RECT lrect; @@ -1770,7 +1770,7 @@ void D3DFB::GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSTy } else { - buffer = (const canvas_pixel_t *)lrect.pBits; + buffer = (const BYTE *)lrect.pBits; pitch = lrect.Pitch; color_type = SS_BGRA; } diff --git a/src/win32/fb_ddraw.cpp b/src/win32/fb_ddraw.cpp index 9be571f98..fbdf035a3 100644 --- a/src/win32/fb_ddraw.cpp +++ b/src/win32/fb_ddraw.cpp @@ -999,8 +999,8 @@ DDrawFB::LockSurfRes DDrawFB::LockSurf (LPRECT lockrect, LPDIRECTDRAWSURFACE toL LOG1 ("Final result after restoration attempts: %08lx\n", hr); return NoGood; } - Buffer = (canvas_pixel_t *)desc.lpSurface; - Pitch = desc.lPitch / sizeof(canvas_pixel_t); + Buffer = (BYTE *)desc.lpSurface; + Pitch = desc.lPitch; BufferingNow = false; return wasLost ? GoodWasLost : Good; } diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index d26765100..0b3333d63 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -252,7 +252,7 @@ public: bool PaintToWindow (); void SetVSync (bool vsync); void NewRefreshRate(); - void GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSType &color_type); + void GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type); void ReleaseScreenshotBuffer(); void SetBlendingRect (int x1, int y1, int x2, int y2); bool Begin2D (bool copy3d); From 05220a713320b0b14525baad647f8ace577e19ee Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 31 May 2016 09:36:18 +0200 Subject: [PATCH 0616/1509] Added IsBgra() to DCanvas Changed SWRender output format to be decided by IsBgra() --- src/f_wipe.cpp | 10 ++++----- src/posix/cocoa/i_video.mm | 10 +++++---- src/posix/hardware.h | 2 +- src/posix/sdl/hardware.cpp | 5 ++++- src/posix/sdl/sdlvideo.cpp | 6 +++--- src/posix/sdl/sdlvideo.h | 2 +- src/r_draw.cpp | 39 +++++++++++++++++++++++++++++++++- src/r_drawt.cpp | 2 -- src/r_main.cpp | 28 ++++++++++++++---------- src/r_main.h | 2 ++ src/r_segs.cpp | 2 -- src/r_swrenderer.cpp | 12 ++++++----- src/r_things.cpp | 1 - src/textures/canvastexture.cpp | 2 +- src/v_draw.cpp | 16 ++++++-------- src/v_video.cpp | 26 +++++++++++------------ src/v_video.h | 8 ++++--- src/win32/fb_d3d9.cpp | 17 +++++++-------- src/win32/fb_ddraw.cpp | 7 +----- src/win32/hardware.cpp | 5 ++++- src/win32/hardware.h | 2 +- src/win32/win32iface.h | 8 +++---- src/win32/win32video.cpp | 21 ++++++++++-------- wadsrc/static/menudef.txt | 2 +- 24 files changed, 139 insertions(+), 96 deletions(-) diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index 7e1ec678e..84b6036e4 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -33,8 +33,6 @@ // SCREEN WIPE PACKAGE // -EXTERN_CVAR(Bool, r_swtruecolor) - static int CurrentWipeType; static short *wipe_scr_start; @@ -385,7 +383,7 @@ static bool (*wipes[])(int) = // Returns true if the wipe should be performed. bool wipe_StartScreen (int type) { - if (r_swtruecolor) + if (screen->IsBgra()) return false; CurrentWipeType = clamp(type, 0, wipe_NUMWIPES - 1); @@ -401,7 +399,7 @@ bool wipe_StartScreen (int type) void wipe_EndScreen (void) { - if (r_swtruecolor) + if (screen->IsBgra()) return; if (CurrentWipeType) @@ -420,7 +418,7 @@ bool wipe_ScreenWipe (int ticks) { bool rc; - if (r_swtruecolor) + if (screen->IsBgra()) return true; if (CurrentWipeType == wipe_None) @@ -436,7 +434,7 @@ bool wipe_ScreenWipe (int ticks) // Final things for the wipe void wipe_Cleanup() { - if (r_swtruecolor) + if (screen->IsBgra()) return; if (wipe_scr_start != NULL) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 5e073daf3..c97460a02 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -96,6 +96,8 @@ EXTERN_CVAR(Bool, ticker ) EXTERN_CVAR(Bool, vid_vsync) EXTERN_CVAR(Bool, vid_hidpi) +CVAR(Bool, swtruecolor, false, CVAR_ARCHIVE) + CUSTOM_CVAR(Bool, fullscreen, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { extern int NewWidth, NewHeight, NewBits, DisplayBits; @@ -199,7 +201,7 @@ public: virtual EDisplayType GetDisplayType() { return DISPLAY_Both; } virtual void SetWindowedScale(float scale); - virtual DFrameBuffer* CreateFrameBuffer(int width, int height, bool fs, DFrameBuffer* old); + virtual DFrameBuffer* CreateFrameBuffer(int width, int height, bool bgra, bool fs, DFrameBuffer* old); virtual void StartModeIterator(int bits, bool fullscreen); virtual bool NextMode(int* width, int* height, bool* letterbox); @@ -518,7 +520,7 @@ bool CocoaVideo::NextMode(int* const width, int* const height, bool* const lette return false; } -DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, const bool fullscreen, DFrameBuffer* const old) +DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, const bool bgra, const bool fullscreen, DFrameBuffer* const old) { PalEntry flashColor = 0; int flashAmount = 0; @@ -762,7 +764,7 @@ CocoaVideo* CocoaVideo::GetInstance() CocoaFrameBuffer::CocoaFrameBuffer(int width, int height, bool fullscreen) -: DFrameBuffer(width, height) +: DFrameBuffer(width, height, false) , m_needPaletteUpdate(false) , m_gamma(0.0f) , m_needGammaUpdate(false) @@ -1064,7 +1066,7 @@ void I_CreateRenderer() DFrameBuffer* I_SetMode(int &width, int &height, DFrameBuffer* old) { - return Video->CreateFrameBuffer(width, height, fullscreen, old); + return Video->CreateFrameBuffer(width, height, swtruecolor, fullscreen, old); } bool I_CheckResolution(const int width, const int height, const int bits) diff --git a/src/posix/hardware.h b/src/posix/hardware.h index 618941fe5..3c06cb6c6 100644 --- a/src/posix/hardware.h +++ b/src/posix/hardware.h @@ -74,7 +74,7 @@ class IVideo virtual EDisplayType GetDisplayType () = 0; virtual void SetWindowedScale (float scale) = 0; - virtual DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old) = 0; + virtual DFrameBuffer *CreateFrameBuffer (int width, int height, bool bgra, bool fs, DFrameBuffer *old) = 0; virtual void StartModeIterator (int bits, bool fs) = 0; virtual bool NextMode (int *width, int *height, bool *letterbox) = 0; diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 6142eb1d8..52bca35e7 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -51,6 +51,7 @@ EXTERN_CVAR (Bool, ticker) EXTERN_CVAR (Bool, fullscreen) +EXTERN_CVAR (Bool, swtruecolor) EXTERN_CVAR (Float, vid_winscale) IVideo *Video; @@ -128,7 +129,7 @@ DFrameBuffer *I_SetMode (int &width, int &height, DFrameBuffer *old) fs = fullscreen; break; } - DFrameBuffer *res = Video->CreateFrameBuffer (width, height, fs, old); + DFrameBuffer *res = Video->CreateFrameBuffer (width, height, swtruecolor, fs, old); /* Right now, CreateFrameBuffer cannot return NULL if (res == NULL) @@ -280,6 +281,8 @@ CUSTOM_CVAR (Int, vid_maxfps, 200, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) } } +CVAR (Bool, swtruecolor, false, CVAR_ARCHIVE) + extern int NewWidth, NewHeight, NewBits, DisplayBits; CUSTOM_CVAR (Bool, fullscreen, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp index 04c3a3f2e..b050097be 100644 --- a/src/posix/sdl/sdlvideo.cpp +++ b/src/posix/sdl/sdlvideo.cpp @@ -257,7 +257,7 @@ bool SDLVideo::NextMode (int *width, int *height, bool *letterbox) return false; } -DFrameBuffer *SDLVideo::CreateFrameBuffer (int width, int height, bool fullscreen, DFrameBuffer *old) +DFrameBuffer *SDLVideo::CreateFrameBuffer (int width, int height, bool bgra, bool fullscreen, DFrameBuffer *old) { static int retry = 0; static int owidth, oheight; @@ -335,7 +335,7 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer (int width, int height, bool fullscree } ++retry; - fb = static_cast(CreateFrameBuffer (width, height, fullscreen, NULL)); + fb = static_cast(CreateFrameBuffer (width, height, bgra, fullscreen, NULL)); } retry = 0; @@ -351,7 +351,7 @@ void SDLVideo::SetWindowedScale (float scale) // FrameBuffer implementation ----------------------------------------------- SDLFB::SDLFB (int width, int height, bool fullscreen, SDL_Window *oldwin) - : DFrameBuffer (width, height) + : DFrameBuffer (width, height, false) { int i; diff --git a/src/posix/sdl/sdlvideo.h b/src/posix/sdl/sdlvideo.h index 072167b5a..385733bc1 100644 --- a/src/posix/sdl/sdlvideo.h +++ b/src/posix/sdl/sdlvideo.h @@ -10,7 +10,7 @@ class SDLVideo : public IVideo EDisplayType GetDisplayType () { return DISPLAY_Both; } void SetWindowedScale (float scale); - DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old); + DFrameBuffer *CreateFrameBuffer (int width, int height, bool bgra, bool fs, DFrameBuffer *old); void StartModeIterator (int bits, bool fs); bool NextMode (int *width, int *height, bool *letterbox); diff --git a/src/r_draw.cpp b/src/r_draw.cpp index f939406bb..82169ec6f 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -179,7 +179,6 @@ FDynamicColormap ShadeFakeColormap[16]; BYTE identitymap[256]; EXTERN_CVAR (Int, r_columnmethod) -EXTERN_CVAR (Bool, r_swtruecolor) void R_InitShadeMaps() { @@ -4129,6 +4128,14 @@ const BYTE *R_GetColumn (FTexture *tex, int col) // [RH] Initialize the column drawer pointers void R_InitColumnDrawers () { + // Save a copy when switching to true color mode as the assembly palette drawers might change them + static bool pointers_saved = false; + static DWORD(*dovline1_saved)(); + static DWORD(*doprevline1_saved)(); + static DWORD(*domvline1_saved)(); + static void(*dovline4_saved)(); + static void(*domvline4_saved)(); + if (r_swtruecolor) { R_DrawColumnHoriz = R_DrawColumnHorizP_RGBA_C; @@ -4201,6 +4208,16 @@ void R_InitColumnDrawers () rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_RGBA_c; rt_initcols = rt_initcols_rgba; + if (!pointers_saved) + { + pointers_saved = true; + dovline1_saved = dovline1; + doprevline1_saved = doprevline1; + domvline1_saved = domvline1; + dovline4_saved = dovline4; + domvline4_saved = domvline4; + } + dovline1 = vlinec1_RGBA; doprevline1 = vlinec1_RGBA; dovline4 = vlinec4_RGBA; @@ -4304,7 +4321,27 @@ void R_InitColumnDrawers () rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_c; rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_c; rt_initcols = rt_initcols_pal; + + if (pointers_saved) + { + pointers_saved = false; + dovline1 = dovline1_saved; + doprevline1 = doprevline1_saved; + domvline1 = domvline1_saved; + dovline4 = dovline4_saved; + domvline4 = domvline4_saved; + } } + + colfunc = basecolfunc = R_DrawColumn; + fuzzcolfunc = R_DrawFuzzColumn; + transcolfunc = R_DrawTranslatedColumn; + spanfunc = R_DrawSpan; + + // [RH] Horizontal column drawers + hcolfunc_pre = R_DrawColumnHoriz; + hcolfunc_post1 = rt_map1col; + hcolfunc_post4 = rt_map4cols; } // [RH] Choose column drawers in a single place diff --git a/src/r_drawt.cpp b/src/r_drawt.cpp index 485ed7ab3..e47590c72 100644 --- a/src/r_drawt.cpp +++ b/src/r_drawt.cpp @@ -47,8 +47,6 @@ #include "r_things.h" #include "v_video.h" -EXTERN_CVAR(Bool, r_swtruecolor) - // I should have commented this stuff better. // // dc_temp is the buffer R_DrawColumnHoriz writes into. diff --git a/src/r_main.cpp b/src/r_main.cpp index 9dc61eea3..aec8310d5 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -103,7 +103,8 @@ bool r_dontmaplines; CVAR (String, r_viewsize, "", CVAR_NOSET) CVAR (Bool, r_shadercolormaps, true, CVAR_ARCHIVE) -CVAR (Bool, r_swtruecolor, false, CVAR_ARCHIVE) + +bool r_swtruecolor; double r_BaseVisibility; double r_WallVisibility; @@ -398,16 +399,6 @@ void R_InitRenderer() R_InitPlanes (); R_InitShadeMaps(); R_InitColumnDrawers (); - - colfunc = basecolfunc = R_DrawColumn; - fuzzcolfunc = R_DrawFuzzColumn; - transcolfunc = R_DrawTranslatedColumn; - spanfunc = R_DrawSpan; - - // [RH] Horizontal column drawers - hcolfunc_pre = R_DrawColumnHoriz; - hcolfunc_post1 = rt_map1col; - hcolfunc_post4 = rt_map4cols; } //========================================================================== @@ -962,6 +953,13 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines) { const bool savedviewactive = viewactive; + const bool savedoutputformat = r_swtruecolor; + + if (r_swtruecolor != canvas->IsBgra()) + { + r_swtruecolor = canvas->IsBgra(); + R_InitColumnDrawers(); + } viewwidth = width; RenderTarget = canvas; @@ -980,7 +978,15 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas, screen->Lock (true); R_SetupBuffer (); screen->Unlock (); + viewactive = savedviewactive; + r_swtruecolor = savedoutputformat; + + if (r_swtruecolor != canvas->IsBgra()) + { + r_swtruecolor = canvas->IsBgra(); + R_InitColumnDrawers(); + } } //========================================================================== diff --git a/src/r_main.h b/src/r_main.h index c1034ea3e..765635e5d 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -106,6 +106,8 @@ inline uint32_t shade_pal_index(uint32_t index, uint32_t light) return 0xff000000 | (red << 16) | (green << 8) | blue; } +extern bool r_swtruecolor; + extern double GlobVis; void R_SetVisibility(double visibility); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 8c71f0fb7..cab97adfc 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -61,8 +61,6 @@ CVAR(Bool, r_np2, true, 0) //CVAR (Int, ty, 8, 0) //CVAR (Int, tx, 8, 0) -EXTERN_CVAR(Bool, r_swtruecolor) - #define HEIGHTBITS 12 #define HEIGHTSHIFT (FRACBITS-HEIGHTBITS) diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 433007acb..15e2fda8f 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -155,6 +155,12 @@ void FSoftwareRenderer::Precache(BYTE *texhitlist, TMap &act void FSoftwareRenderer::RenderView(player_t *player) { + if (r_swtruecolor != screen->IsBgra()) + { + r_swtruecolor = screen->IsBgra(); + R_InitColumnDrawers(); + } + R_RenderActorView (player->mo); // [RH] Let cameras draw onto textures that were visible this frame. FCanvasTextureInfo::UpdateAll (); @@ -182,8 +188,7 @@ void FSoftwareRenderer::RemapVoxels() void FSoftwareRenderer::WriteSavePic (player_t *player, FILE *file, int width, int height) { -#ifdef PALETTEOUTPUT - DCanvas *pic = new DSimpleCanvas (width, height); + DCanvas *pic = new DSimpleCanvas (width, height, false); PalEntry palette[256]; // Take a snapshot of the player's view @@ -196,7 +201,6 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FILE *file, int width, i pic->Destroy(); pic->ObjectFlags |= OF_YesReallyDelete; delete pic; -#endif } //=========================================================================== @@ -313,7 +317,6 @@ void FSoftwareRenderer::CopyStackedViewParameters() void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov) { -#ifdef PALETTEOUTPUT BYTE *Pixels = const_cast(tex->GetPixels()); DSimpleCanvas *Canvas = tex->GetCanvas(); @@ -337,7 +340,6 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin tex->SetUpdated(); fixedcolormap = savecolormap; realfixedcolormap = savecm; -#endif } //========================================================================== diff --git a/src/r_things.cpp b/src/r_things.cpp index 2abcc0e12..f52c80376 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -98,7 +98,6 @@ EXTERN_CVAR (Bool, st_scale) EXTERN_CVAR(Bool, r_shadercolormaps) EXTERN_CVAR(Int, r_drawfuzz) EXTERN_CVAR(Bool, r_deathcamera); -EXTERN_CVAR(Bool, r_swtruecolor) // // Sprite rotation 0 is facing the viewer, diff --git a/src/textures/canvastexture.cpp b/src/textures/canvastexture.cpp index d1f70439f..7242149a4 100644 --- a/src/textures/canvastexture.cpp +++ b/src/textures/canvastexture.cpp @@ -103,7 +103,7 @@ const BYTE *FCanvasTexture::GetPixels () void FCanvasTexture::MakeTexture () { - Canvas = new DSimpleCanvas (Width, Height); + Canvas = new DSimpleCanvas (Width, Height, false); Canvas->Lock (); GC::AddSoftRoot(Canvas); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index ed6571ad3..b4f1ad4b5 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -77,8 +77,6 @@ extern "C" short spanend[MAXHEIGHT]; CVAR (Bool, hud_scale, false, CVAR_ARCHIVE); -EXTERN_CVAR(Bool, r_swtruecolor) - // For routines that take RGB colors, cache the previous lookup in case there // are several repetitions with the same color. static int LastPal = -1; @@ -1019,7 +1017,7 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) oldyyshifted = yy * GetPitch(); } - if (r_swtruecolor) + if (IsBgra()) { uint32_t *spot = (uint32_t*)GetBuffer() + oldyyshifted + xx; @@ -1091,7 +1089,7 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real { swapvalues (x0, x1); } - if (r_swtruecolor) + if (IsBgra()) { uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0; for (int i = 0; i <= deltaX; i++) @@ -1104,7 +1102,7 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real } else if (deltaX == 0) { // vertical line - if (r_swtruecolor) + if (IsBgra()) { uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0; int pitch = GetPitch(); @@ -1127,7 +1125,7 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real } else if (deltaX == deltaY) { // diagonal line. - if (r_swtruecolor) + if (IsBgra()) { uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0; int advance = GetPitch() + xDir; @@ -1295,7 +1293,7 @@ void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uin palcolor = PalFromRGB(color); } - if (r_swtruecolor) + if (IsBgra()) { uint32_t *dest = (uint32_t*)Buffer + top * Pitch + left; x = right - left; @@ -1502,7 +1500,7 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, // void DCanvas::DrawBlock (int x, int y, int _width, int _height, const BYTE *src) const { - if (r_swtruecolor) + if (IsBgra()) return; int srcpitch = _width; @@ -1531,7 +1529,7 @@ void DCanvas::DrawBlock (int x, int y, int _width, int _height, const BYTE *src) // void DCanvas::GetBlock (int x, int y, int _width, int _height, BYTE *dest) const { - if (r_swtruecolor) + if (IsBgra()) return; const BYTE *src; diff --git a/src/v_video.cpp b/src/v_video.cpp index 01043b8bc..bc99edbf1 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -65,8 +65,6 @@ #include "menu/menu.h" #include "r_data/voxels.h" -EXTERN_CVAR(Bool, r_swtruecolor) - FRenderer *Renderer; IMPLEMENT_ABSTRACT_CLASS (DCanvas) @@ -83,7 +81,7 @@ class DDummyFrameBuffer : public DFrameBuffer DECLARE_CLASS (DDummyFrameBuffer, DFrameBuffer); public: DDummyFrameBuffer (int width, int height) - : DFrameBuffer (0, 0) + : DFrameBuffer (0, 0, false) { Width = width; Height = height; @@ -208,13 +206,14 @@ DCanvas *DCanvas::CanvasChain = NULL; // //========================================================================== -DCanvas::DCanvas (int _width, int _height) +DCanvas::DCanvas (int _width, int _height, bool _bgra) { // Init member vars Buffer = NULL; LockCount = 0; Width = _width; Height = _height; + Bgra = _bgra; // Add to list of active canvases Next = CanvasChain; @@ -366,7 +365,7 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) gap = Pitch - w; - if (r_swtruecolor) + if (IsBgra()) { uint32_t *spot = (uint32_t*)Buffer + x1 + y1*Pitch; @@ -448,7 +447,7 @@ void DCanvas::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &colo Lock(true); buffer = GetBuffer(); pitch = GetPitch(); - color_type = r_swtruecolor ? SS_BGRA : SS_PAL; + color_type = IsBgra() ? SS_BGRA : SS_PAL; } //========================================================================== @@ -761,8 +760,8 @@ void DCanvas::CalcGamma (float gamma, BYTE gammalookup[256]) // //========================================================================== -DSimpleCanvas::DSimpleCanvas (int width, int height) - : DCanvas (width, height) +DSimpleCanvas::DSimpleCanvas (int width, int height, bool bgra) + : DCanvas (width, height, bgra) { // Making the pitch a power of 2 is very bad for performance // Try to maximize the number of cache lines that can be filled @@ -799,8 +798,9 @@ DSimpleCanvas::DSimpleCanvas (int width, int height) Pitch = width + MAX(0, CPU.DataL1LineSize - 8); } } - MemBuffer = new BYTE[Pitch * height * 4]; - memset (MemBuffer, 0, Pitch * height * 4); + int bytes_per_pixel = bgra ? 4 : 1; + MemBuffer = new BYTE[Pitch * height * bytes_per_pixel]; + memset (MemBuffer, 0, Pitch * height * bytes_per_pixel); } //========================================================================== @@ -869,8 +869,8 @@ void DSimpleCanvas::Unlock () // //========================================================================== -DFrameBuffer::DFrameBuffer (int width, int height) - : DSimpleCanvas (width, height) +DFrameBuffer::DFrameBuffer (int width, int height, bool bgra) + : DSimpleCanvas (width, height, bgra) { LastMS = LastSec = FrameCount = LastCount = LastTic = 0; Accel2D = false; @@ -927,7 +927,7 @@ void DFrameBuffer::DrawRateStuff () // Buffer can be NULL if we're doing hardware accelerated 2D if (buffer != NULL) { - if (r_swtruecolor) + if (IsBgra()) { uint32_t *buffer32 = (uint32_t*)buffer; buffer32 += (GetHeight() - 1) * GetPitch(); diff --git a/src/v_video.h b/src/v_video.h index fa1ce83df..120beff9a 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -185,7 +185,7 @@ class DCanvas : public DObject { DECLARE_ABSTRACT_CLASS (DCanvas, DObject) public: - DCanvas (int width, int height); + DCanvas (int width, int height, bool bgra); virtual ~DCanvas (); // Member variable access @@ -193,6 +193,7 @@ public: inline int GetWidth () const { return Width; } inline int GetHeight () const { return Height; } inline int GetPitch () const { return Pitch; } + inline bool IsBgra() const { return Bgra; } virtual bool IsValid (); @@ -267,6 +268,7 @@ protected: int Height; int Pitch; int LockCount; + bool Bgra; bool ClipBox (int &left, int &top, int &width, int &height, const BYTE *&src, const int srcpitch) const; void DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags) = delete; @@ -289,7 +291,7 @@ class DSimpleCanvas : public DCanvas { DECLARE_CLASS (DSimpleCanvas, DCanvas) public: - DSimpleCanvas (int width, int height); + DSimpleCanvas (int width, int height, bool bgra); ~DSimpleCanvas (); bool IsValid (); @@ -327,7 +329,7 @@ class DFrameBuffer : public DSimpleCanvas { DECLARE_ABSTRACT_CLASS (DFrameBuffer, DSimpleCanvas) public: - DFrameBuffer (int width, int height); + DFrameBuffer (int width, int height, bool bgra); // Force the surface to use buffered output if true is passed. virtual bool Lock (bool buffered) = 0; diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 0cd847b97..fd84e3bbb 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -187,7 +187,6 @@ EXTERN_CVAR (Float, Gamma) EXTERN_CVAR (Bool, vid_vsync) EXTERN_CVAR (Float, transsouls) EXTERN_CVAR (Int, vid_refreshrate) -EXTERN_CVAR (Bool, r_swtruecolor) extern IDirect3D9 *D3D; @@ -243,8 +242,8 @@ CVAR(Bool, vid_hwaalines, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // //========================================================================== -D3DFB::D3DFB (UINT adapter, int width, int height, bool fullscreen) - : BaseWinFB (width, height) +D3DFB::D3DFB (UINT adapter, int width, int height, bool bgra, bool fullscreen) + : BaseWinFB (width, height, bgra) { D3DPRESENT_PARAMETERS d3dpp; @@ -766,7 +765,7 @@ void D3DFB::KillNativeTexs() bool D3DFB::CreateFBTexture () { - FBFormat = r_swtruecolor ? D3DFMT_A8R8G8B8 : D3DFMT_L8; + FBFormat = IsBgra() ? D3DFMT_A8R8G8B8 : D3DFMT_L8; if (FAILED(D3DDevice->CreateTexture(Width, Height, 1, D3DUSAGE_DYNAMIC, FBFormat, D3DPOOL_DEFAULT, &FBTexture, NULL))) { @@ -1307,7 +1306,7 @@ void D3DFB::Draw3DPart(bool copy3d) SUCCEEDED(FBTexture->LockRect (0, &lockrect, NULL, D3DLOCK_DISCARD))) || SUCCEEDED(FBTexture->LockRect (0, &lockrect, &texrect, 0))) { - if (r_swtruecolor && FBFormat == D3DFMT_A8R8G8B8) + if (IsBgra() && FBFormat == D3DFMT_A8R8G8B8) { if (lockrect.Pitch == Pitch * sizeof(uint32_t) && Pitch == Width) { @@ -1325,7 +1324,7 @@ void D3DFB::Draw3DPart(bool copy3d) } } } - else if (!r_swtruecolor && FBFormat == D3DFMT_L8) + else if (!IsBgra() && FBFormat == D3DFMT_L8) { if (lockrect.Pitch == Pitch && Pitch == Width) { @@ -1377,7 +1376,7 @@ void D3DFB::Draw3DPart(bool copy3d) memset(Constant, 0, sizeof(Constant)); SetAlphaBlend(D3DBLENDOP(0)); EnableAlphaTest(FALSE); - if (r_swtruecolor) + if (IsBgra()) SetPixelShader(Shaders[SHADER_NormalColor]); else SetPixelShader(Shaders[SHADER_NormalColorPal]); @@ -1398,7 +1397,7 @@ void D3DFB::Draw3DPart(bool copy3d) realfixedcolormap->ColorizeStart[1]/2, realfixedcolormap->ColorizeStart[2]/2, 0); color1 = D3DCOLOR_COLORVALUE(realfixedcolormap->ColorizeEnd[0]/2, realfixedcolormap->ColorizeEnd[1]/2, realfixedcolormap->ColorizeEnd[2]/2, 1); - if (r_swtruecolor) + if (IsBgra()) SetPixelShader(Shaders[SHADER_SpecialColormap]); else SetPixelShader(Shaders[SHADER_SpecialColormapPal]); @@ -1412,7 +1411,7 @@ void D3DFB::Draw3DPart(bool copy3d) CalcFullscreenCoords(verts, Accel2D, false, color0, color1); D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX)); } - if (r_swtruecolor) + if (IsBgra()) SetPixelShader(Shaders[SHADER_NormalColor]); else SetPixelShader(Shaders[SHADER_NormalColorPal]); diff --git a/src/win32/fb_ddraw.cpp b/src/win32/fb_ddraw.cpp index fbdf035a3..5637e9695 100644 --- a/src/win32/fb_ddraw.cpp +++ b/src/win32/fb_ddraw.cpp @@ -60,9 +60,7 @@ // TYPES ------------------------------------------------------------------- -#ifdef USE_OBSOLETE_DDRAW IMPLEMENT_CLASS(DDrawFB) -#endif // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- @@ -120,10 +118,8 @@ cycle_t BlitCycles; // CODE -------------------------------------------------------------------- -#ifdef USE_OBSOLETE_DDRAW - DDrawFB::DDrawFB (int width, int height, bool fullscreen) - : BaseWinFB (width, height) + : BaseWinFB (width, height, false) { int i; @@ -1330,7 +1326,6 @@ void DDrawFB::Blank () PrimarySurf->Blt (NULL, NULL, NULL, DDBLT_COLORFILL, &blitFX); } } -#endif ADD_STAT (blit) { diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 8cc770556..8856924c0 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -51,6 +51,7 @@ EXTERN_CVAR (Bool, ticker) EXTERN_CVAR (Bool, fullscreen) +EXTERN_CVAR (Bool, swtruecolor) EXTERN_CVAR (Float, vid_winscale) CVAR(Int, win_x, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) @@ -146,7 +147,7 @@ DFrameBuffer *I_SetMode (int &width, int &height, DFrameBuffer *old) } break; } - DFrameBuffer *res = Video->CreateFrameBuffer (width, height, fs, old); + DFrameBuffer *res = Video->CreateFrameBuffer (width, height, swtruecolor, fs, old); /* Right now, CreateFrameBuffer cannot return NULL if (res == NULL) @@ -310,6 +311,8 @@ void I_RestoreWindowedPos () MoveWindow (Window, winx, winy, winw, winh, TRUE); } +CVAR (Bool, swtruecolor, false, CVAR_ARCHIVE) + extern int NewWidth, NewHeight, NewBits, DisplayBits; CUSTOM_CVAR (Bool, fullscreen, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) diff --git a/src/win32/hardware.h b/src/win32/hardware.h index b2bafef32..184eeccf5 100644 --- a/src/win32/hardware.h +++ b/src/win32/hardware.h @@ -45,7 +45,7 @@ class IVideo virtual EDisplayType GetDisplayType () = 0; virtual void SetWindowedScale (float scale) = 0; - virtual DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old) = 0; + virtual DFrameBuffer *CreateFrameBuffer (int width, int height, bool bgra, bool fs, DFrameBuffer *old) = 0; virtual void StartModeIterator (int bits, bool fs) = 0; virtual bool NextMode (int *width, int *height, bool *letterbox) = 0; diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index 0b3333d63..d30475eb3 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -70,7 +70,7 @@ class Win32Video : public IVideo EDisplayType GetDisplayType () { return DISPLAY_Both; } void SetWindowedScale (float scale); - DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old); + DFrameBuffer *CreateFrameBuffer (int width, int height, bool bgra, bool fs, DFrameBuffer *old); void StartModeIterator (int bits, bool fs); bool NextMode (int *width, int *height, bool *letterbox); @@ -121,7 +121,7 @@ class BaseWinFB : public DFrameBuffer { DECLARE_ABSTRACT_CLASS(BaseWinFB, DFrameBuffer) public: - BaseWinFB (int width, int height) : DFrameBuffer (width, height), Windowed (true) {} + BaseWinFB (int width, int height, bool bgra) : DFrameBuffer (width, height, bgra), Windowed (true) {} bool IsFullscreen () { return !Windowed; } virtual void Blank () = 0; @@ -142,7 +142,6 @@ protected: BaseWinFB() {} }; -#ifdef USE_OBSOLETE_DDRAW class DDrawFB : public BaseWinFB { DECLARE_CLASS(DDrawFB, BaseWinFB) @@ -224,13 +223,12 @@ private: DDrawFB() {} }; -#endif class D3DFB : public BaseWinFB { DECLARE_CLASS(D3DFB, BaseWinFB) public: - D3DFB (UINT adapter, int width, int height, bool fullscreen); + D3DFB (UINT adapter, int width, int height, bool bgra, bool fullscreen); ~D3DFB (); bool IsValid (); diff --git a/src/win32/win32video.cpp b/src/win32/win32video.cpp index 3f3645d0b..5b2d5ef20 100644 --- a/src/win32/win32video.cpp +++ b/src/win32/win32video.cpp @@ -222,6 +222,13 @@ bool Win32Video::InitD3D9 () // Enumerate available display modes. FreeModes (); #ifndef PALETTEOUTPUT // To do: remove this again (AddD3DModes fails when there are too many modes available for videomenu to display) + + AddMode(320, 200, 8, 200, 0); + AddMode(320, 240, 8, 240, 0); + AddMode(640, 480, 8, 480, 0); + AddMode(800, 600, 8, 600, 0); + AddMode(1024, 768, 8, 768, 0); + AddMode(1920, 1080, 8, 1440, 0); // 1080p AddMode(1920*2, 1080*2, 8, 1440, 0); // 4k AddMode(2560, 1440, 8, 1440, 0); // 27" classic @@ -636,7 +643,7 @@ bool Win32Video::NextMode (int *width, int *height, bool *letterbox) return false; } -DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool fullscreen, DFrameBuffer *old) +DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool bgra, bool fullscreen, DFrameBuffer *old) { static int retry = 0; static int owidth, oheight; @@ -652,7 +659,8 @@ DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool fullscr BaseWinFB *fb = static_cast (old); if (fb->Width == width && fb->Height == height && - fb->Windowed == !fullscreen) + fb->Windowed == !fullscreen && + fb->Bgra == bgra) { return old; } @@ -667,13 +675,9 @@ DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool fullscr flashAmount = 0; } -#ifndef USE_OBSOLETE_DDRAW - fb = new D3DFB(m_Adapter, width, height, fullscreen); - LOG1("New fb created @ %p\n", fb); -#else if (D3D != NULL) { - fb = new D3DFB (m_Adapter, width, height, fullscreen); + fb = new D3DFB (m_Adapter, width, height, bgra, fullscreen); } else { @@ -738,10 +742,9 @@ DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool fullscr } ++retry; - fb = static_cast(CreateFrameBuffer (width, height, fullscreen, NULL)); + fb = static_cast(CreateFrameBuffer (width, height, bgra, fullscreen, NULL)); } retry = 0; -#endif fb->SetFlash (flashColor, flashAmount); return fb; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 93e33ce79..3c712de96 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -661,7 +661,7 @@ OptionMenu "VideoOptions" Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff" Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn" Option "$DSPLYMNU_COLUMNMETHOD", "r_columnmethod", "ColumnMethods" - Option "$DSPLYMNU_TRUECOLOR", "r_swtruecolor", "OnOff" + Option "$DSPLYMNU_TRUECOLOR", "swtruecolor", "OnOff" StaticText " " Option "$DSPLYMNU_WIPETYPE", "wipetype", "Wipes" From e929eec80f688f2afbd4a27ade847282aad9622d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 1 Jun 2016 05:28:14 +0200 Subject: [PATCH 0617/1509] Make x86 asm aware of swtruecolor --- src/doomtype.h | 5 + src/r_draw.cpp | 243 +++++++++++++++++++++++++++++++++------ src/r_draw.h | 1 + src/r_drawt.cpp | 25 ++-- src/r_plane.cpp | 41 ++++--- src/win32/win32video.cpp | 4 +- 6 files changed, 256 insertions(+), 63 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index 39c59751d..9fca870d3 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -99,6 +99,11 @@ typedef TMap FClassMap; #endif +// Only use SSE intrinsics on Intel architecture +#if !defined(_M_IX86) && !defined(__i386__) && !defined(_M_X64) && !defined(__amd64__) +#define NO_SSE +#endif + #if defined(_MSC_VER) #define NOVTABLE __declspec(novtable) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 82169ec6f..d7b740973 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -1789,7 +1789,7 @@ void R_SetSpanSource(const BYTE *pixels) { ds_source = pixels; #ifdef X86_ASM - if (ds_cursource != ds_source) + if (!r_swtruecolor && ds_cursource != ds_source) { R_SetSpanSource_ASM(pixels); } @@ -1809,7 +1809,7 @@ void R_SetSpanColormap(BYTE *colormap) ds_colormap = colormap; ds_light = 0; #ifdef X86_ASM - if (ds_colormap != ds_curcolormap) + if (!r_swtruecolor && ds_colormap != ds_curcolormap) { R_SetSpanColormap_ASM (ds_colormap); } @@ -1838,7 +1838,8 @@ void R_SetupSpanBits(FTexture *tex) ds_ybits--; } #ifdef X86_ASM - R_SetSpanSize_ASM (ds_xbits, ds_ybits); + if (!r_swtruecolor) + R_SetSpanSize_ASM (ds_xbits, ds_ybits); #endif } @@ -1954,7 +1955,80 @@ void R_DrawSpanP_RGBA_C() { // 64x64 is the most common case by far, so special case it. + do + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + *dest++ = shade_pal_index(colormap[source[spot]], light); + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + + do + { + // Current texture index in u,v. + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + *dest++ = shade_pal_index(colormap[source[spot]], light); + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } +} + #ifndef NO_SSE +void R_DrawSpanP_RGBA_SSE() +{ + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + uint32_t* dest; + const BYTE* source = ds_source; + const BYTE* colormap = ds_colormap; + int count; + int spot; + +#ifdef RANGECHECK + if (ds_x2 < ds_x1 || ds_x1 < 0 + || ds_x2 >= screen->width || ds_y > screen->height) + { + I_Error("R_DrawSpan: %i to %i at %i", ds_x1, ds_x2, ds_y); + } + // dscount++; +#endif + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + + dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + + count = ds_x2 - ds_x1 + 1; + + xstep = ds_xstep; + ystep = ds_ystep; + + uint32_t light = calc_light_multiplier(ds_light); + + if (ds_xbits == 6 && ds_ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + __m128i mlight = _mm_set_epi16(256, light, light, light, 256, light, light, light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; @@ -2000,7 +2074,6 @@ void R_DrawSpanP_RGBA_C() } if (count == 0) return; -#endif do { @@ -2037,6 +2110,7 @@ void R_DrawSpanP_RGBA_C() } while (--count); } } +#endif #ifndef X86_ASM @@ -2971,6 +3045,12 @@ void (*domvline4)() = mvlineasm4; void setupvline (int fracbits) { + if (r_swtruecolor) + { + vlinebits = fracbits; + return; + } + #ifdef X86_ASM if (CPU.Family <= 5) { @@ -3075,23 +3155,43 @@ void vlinec4_RGBA() uint32_t *dest = (uint32_t*)dc_dest; int count = dc_count; int bits = vlinebits; + DWORD place; uint32_t light0 = calc_light_multiplier(palookuplight[0]); uint32_t light1 = calc_light_multiplier(palookuplight[1]); uint32_t light2 = calc_light_multiplier(palookuplight[2]); uint32_t light3 = calc_light_multiplier(palookuplight[3]); + + do + { + dest[0] = shade_pal_index(palookupoffse[0][bufplce[0][(place = vplce[0]) >> bits]], light0); vplce[0] = place + vince[0]; + dest[1] = shade_pal_index(palookupoffse[1][bufplce[1][(place = vplce[1]) >> bits]], light1); vplce[1] = place + vince[1]; + dest[2] = shade_pal_index(palookupoffse[2][bufplce[2][(place = vplce[2]) >> bits]], light2); vplce[2] = place + vince[2]; + dest[3] = shade_pal_index(palookupoffse[3][bufplce[3][(place = vplce[3]) >> bits]], light3); vplce[3] = place + vince[3]; + dest += dc_pitch; + } while (--count); +} + #ifndef NO_SSE +void vlinec4_RGBA_SSE() +{ + uint32_t *dest = (uint32_t*)dc_dest; + int count = dc_count; + int bits = vlinebits; + + uint32_t light0 = calc_light_multiplier(palookuplight[0]); + uint32_t light1 = calc_light_multiplier(palookuplight[1]); + uint32_t light2 = calc_light_multiplier(palookuplight[2]); + uint32_t light3 = calc_light_multiplier(palookuplight[3]); + __m128i mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); __m128i mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); uint32_t *palette = (uint32_t*)GPalette.BaseColors; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; -#endif do { -#ifndef NO_SSE - DWORD place0 = local_vplce[0]; DWORD place1 = local_vplce[1]; DWORD place2 = local_vplce[2]; @@ -3116,17 +3216,9 @@ void vlinec4_RGBA() fg_lo = _mm_srli_epi16(fg_lo, 8); fg = _mm_packus_epi16(fg_lo, fg_hi); _mm_storeu_si128((__m128i*)dest, fg); - -#else - dest[0] = shade_pal_index(palookupoffse[0][bufplce[0][(place = vplce[0]) >> bits]], light0); vplce[0] = place + vince[0]; - dest[1] = shade_pal_index(palookupoffse[1][bufplce[1][(place = vplce[1]) >> bits]], light1); vplce[1] = place + vince[1]; - dest[2] = shade_pal_index(palookupoffse[2][bufplce[2][(place = vplce[2]) >> bits]], light2); vplce[2] = place + vince[2]; - dest[3] = shade_pal_index(palookupoffse[3][bufplce[3][(place = vplce[3]) >> bits]], light3); vplce[3] = place + vince[3]; -#endif dest += dc_pitch; } while (--count); -#ifndef NO_SSE // Is this needed? Global variables makes it tricky to know.. vplce[0] = local_vplce[0]; vplce[1] = local_vplce[1]; @@ -3136,18 +3228,25 @@ void vlinec4_RGBA() vince[1] = local_vince[1]; vince[2] = local_vince[2]; vince[3] = local_vince[3]; -#endif } +#endif void setupmvline (int fracbits) { + if (!r_swtruecolor) + { #if defined(X86_ASM) - setupmvlineasm (fracbits); - domvline1 = mvlineasm1; - domvline4 = mvlineasm4; + setupmvlineasm(fracbits); + domvline1 = mvlineasm1; + domvline4 = mvlineasm4; #else - mvlinebits = fracbits; + mvlinebits = fracbits; #endif + } + else + { + mvlinebits = fracbits; + } } #if !defined(X86_ASM) @@ -3247,6 +3346,73 @@ void mvlinec4_RGBA() } while (--count); } +#ifndef NO_SSE +void mvlinec4_RGBA_SSE() +{ + uint32_t *dest = (uint32_t*)dc_dest; + int count = dc_count; + int bits = vlinebits; + + uint32_t light0 = calc_light_multiplier(palookuplight[0]); + uint32_t light1 = calc_light_multiplier(palookuplight[1]); + uint32_t light2 = calc_light_multiplier(palookuplight[2]); + uint32_t light3 = calc_light_multiplier(palookuplight[3]); + + __m128i mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); + __m128i mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; + + BYTE pix0 = bufplce[0][place0 >> bits]; + BYTE pix1 = bufplce[1][place1 >> bits]; + BYTE pix2 = bufplce[2][place2 >> bits]; + BYTE pix3 = bufplce[3][place3 >> bits]; + + // movemask = !(pix == 0) + __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); + + BYTE p0 = palookupoffse[0][pix0]; + BYTE p1 = palookupoffse[1][pix1]; + BYTE p2 = palookupoffse[2][pix2]; + BYTE p3 = palookupoffse[3][pix3]; + + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + fg_hi = _mm_mullo_epi16(fg_hi, mlight_hi); + fg_hi = _mm_srli_epi16(fg_hi, 8); + fg_lo = _mm_mullo_epi16(fg_lo, mlight_lo); + fg_lo = _mm_srli_epi16(fg_lo, 8); + fg = _mm_packus_epi16(fg_lo, fg_hi); + _mm_maskmoveu_si128(fg, movemask, (char*)dest); + dest += dc_pitch; + } while (--count); + + // Is this needed? Global variables makes it tricky to know.. + vplce[0] = local_vplce[0]; + vplce[1] = local_vplce[1]; + vplce[2] = local_vplce[2]; + vplce[3] = local_vplce[3]; + vince[0] = local_vince[0]; + vince[1] = local_vince[1]; + vince[2] = local_vince[2]; + vince[3] = local_vince[3]; +} +#endif + extern "C" short spanend[MAXHEIGHT]; extern float rw_light; @@ -4138,14 +4304,28 @@ void R_InitColumnDrawers () if (r_swtruecolor) { + if (!pointers_saved) + { + pointers_saved = true; + dovline1_saved = dovline1; + doprevline1_saved = doprevline1; + domvline1_saved = domvline1; + dovline4_saved = dovline4; + domvline4_saved = domvline4; + } + R_DrawColumnHoriz = R_DrawColumnHorizP_RGBA_C; R_DrawColumn = R_DrawColumnP_RGBA_C; R_DrawFuzzColumn = R_DrawFuzzColumnP_RGBA_C; R_DrawTranslatedColumn = R_DrawTranslatedColumnP_RGBA_C; R_DrawShadedColumn = R_DrawShadedColumnP_RGBA_C; - R_DrawSpan = R_DrawSpanP_RGBA_C; R_DrawSpanMasked = R_DrawSpanMaskedP_RGBA_C; rt_map4cols = rt_map4cols_RGBA_c; +#ifndef NO_SSE + R_DrawSpan = R_DrawSpanP_RGBA_SSE; +#else + R_DrawSpan = R_DrawSpanP_RGBA_C; +#endif R_DrawSpanTranslucent = R_DrawSpanTranslucentP_RGBA_C; R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucentP_RGBA_C; @@ -4208,21 +4388,18 @@ void R_InitColumnDrawers () rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_RGBA_c; rt_initcols = rt_initcols_rgba; - if (!pointers_saved) - { - pointers_saved = true; - dovline1_saved = dovline1; - doprevline1_saved = doprevline1; - domvline1_saved = domvline1; - dovline4_saved = dovline4; - domvline4_saved = domvline4; - } - dovline1 = vlinec1_RGBA; doprevline1 = vlinec1_RGBA; - dovline4 = vlinec4_RGBA; domvline1 = mvlinec1_RGBA; - domvline4 = mvlinec4_RGBA; + +#ifndef NO_SSE + dovline4 = vlinec4_RGBA_SSE; + domvline4 = mvlinec4_RGBA_SSE; +#else + dovline4 = vlinec4_RGBA; + domvline4 = mvlinec4_RGBA; +#endif + } else { diff --git a/src/r_draw.h b/src/r_draw.h index 2348914b6..d5007c885 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -269,6 +269,7 @@ void R_DrawFuzzColumnP_RGBA_C (void); void R_DrawTranslatedColumnP_RGBA_C (void); void R_DrawShadedColumnP_RGBA_C (void); void R_DrawSpanP_RGBA_C (void); +void R_DrawSpanP_RGBA_SSE (void); void R_DrawSpanMaskedP_RGBA_C (void); #endif diff --git a/src/r_drawt.cpp b/src/r_drawt.cpp index e47590c72..ca6862ed6 100644 --- a/src/r_drawt.cpp +++ b/src/r_drawt.cpp @@ -860,18 +860,21 @@ void rt_draw4cols (int sx) } #ifdef X86_ASM - // Setup assembly routines for changed colormaps or other parameters. - if (hcolfunc_post4 == rt_shaded4cols) + if (!r_swtruecolor) { - R_SetupShadedCol(); - } - else if (hcolfunc_post4 == rt_addclamp4cols || hcolfunc_post4 == rt_tlateaddclamp4cols) - { - R_SetupAddClampCol(); - } - else if (hcolfunc_post4 == rt_add4cols || hcolfunc_post4 == rt_tlateadd4cols) - { - R_SetupAddCol(); + // Setup assembly routines for changed colormaps or other parameters. + if (hcolfunc_post4 == rt_shaded4cols) + { + R_SetupShadedCol(); + } + else if (hcolfunc_post4 == rt_addclamp4cols || hcolfunc_post4 == rt_tlateaddclamp4cols) + { + R_SetupAddClampCol(); + } + else if (hcolfunc_post4 == rt_add4cols || hcolfunc_post4 == rt_tlateadd4cols) + { + R_SetupAddCol(); + } } #endif diff --git a/src/r_plane.cpp b/src/r_plane.cpp index a71590c9d..40e14c020 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -231,7 +231,7 @@ void R_MapPlane (int y, int x1) } #ifdef X86_ASM - if (ds_colormap != ds_curcolormap) + if (!r_swtruecolor && ds_colormap != ds_curcolormap) R_SetSpanColormap_ASM (ds_colormap); #endif @@ -1620,7 +1620,7 @@ void R_DrawSkyPlane (visplane_t *pl) void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked) { #ifdef X86_ASM - if (ds_source != ds_cursource) + if (!r_swtruecolor && ds_source != ds_cursource) { R_SetSpanSource_ASM (ds_source); } @@ -1747,7 +1747,7 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t // //========================================================================== -void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked) +void R_DrawTiltedPlane(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked) { static const float ifloatpow2[16] = { @@ -1782,7 +1782,7 @@ void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t // p is the texture origin in view space // Don't add in the offsets at this stage, because doing so can result in // errors if the flat is rotated. - ang = M_PI*3/2 - ViewAngle.Radians(); + ang = M_PI * 3 / 2 - ViewAngle.Radians(); cosine = cos(ang), sine = sin(ang); p[0] = ViewPos.X * cosine - ViewPos.Y * sine; p[2] = ViewPos.X * sine + ViewPos.Y * cosine; @@ -1793,25 +1793,25 @@ void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t cosine = cos(ang), sine = sin(ang); m[0] = yscale * cosine; m[2] = yscale * sine; -// m[1] = pl->height.ZatPointF (0, iyscale) - pl->height.ZatPointF (0,0)); -// VectorScale2 (m, 64.f/VectorLength(m)); + // m[1] = pl->height.ZatPointF (0, iyscale) - pl->height.ZatPointF (0,0)); + // VectorScale2 (m, 64.f/VectorLength(m)); - // n is the u direction vector in view space + // n is the u direction vector in view space #if 0 //let's use the sin/cosine we already know instead of computing new ones - ang += M_PI/2 - n[0] = -xscale * cos(ang); + ang += M_PI / 2 + n[0] = -xscale * cos(ang); n[2] = -xscale * sin(ang); #else n[0] = xscale * sine; n[2] = -xscale * cosine; #endif -// n[1] = pl->height.ZatPointF (ixscale, 0) - pl->height.ZatPointF (0,0)); -// VectorScale2 (n, 64.f/VectorLength(n)); + // n[1] = pl->height.ZatPointF (ixscale, 0) - pl->height.ZatPointF (0,0)); + // VectorScale2 (n, 64.f/VectorLength(n)); - // This code keeps the texture coordinates constant across the x,y plane no matter - // how much you slope the surface. Use the commented-out code above instead to keep - // the textures a constant size across the surface's plane instead. + // This code keeps the texture coordinates constant across the x,y plane no matter + // how much you slope the surface. Use the commented-out code above instead to keep + // the textures a constant size across the surface's plane instead. cosine = cos(planeang), sine = sin(planeang); m[1] = pl->height.ZatPoint(ViewPos.X + yscale * sine, ViewPos.Y + yscale * cosine) - zeroheight; n[1] = pl->height.ZatPoint(ViewPos.X - xscale * cosine, ViewPos.Y + xscale * sine) - zeroheight; @@ -1861,9 +1861,16 @@ void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t } #if defined(X86_ASM) - if (ds_source != ds_curtiltedsource) - R_SetTiltedSpanSource_ASM (ds_source); - R_MapVisPlane (pl, R_DrawTiltedPlane_ASM); + if (!r_swtruecolor) + { + if (ds_source != ds_curtiltedsource) + R_SetTiltedSpanSource_ASM(ds_source); + R_MapVisPlane(pl, R_DrawTiltedPlane_ASM); + } + else + { + R_MapVisPlane(pl, R_MapTiltedPlane); + } #else R_MapVisPlane (pl, R_MapTiltedPlane); #endif diff --git a/src/win32/win32video.cpp b/src/win32/win32video.cpp index 5b2d5ef20..a180a35ea 100644 --- a/src/win32/win32video.cpp +++ b/src/win32/win32video.cpp @@ -229,8 +229,8 @@ bool Win32Video::InitD3D9 () AddMode(800, 600, 8, 600, 0); AddMode(1024, 768, 8, 768, 0); - AddMode(1920, 1080, 8, 1440, 0); // 1080p - AddMode(1920*2, 1080*2, 8, 1440, 0); // 4k + AddMode(1920, 1080, 8, 1080, 0); // 1080p + AddMode(1920*2, 1080*2, 8, 1080*2, 0); // 4k AddMode(2560, 1440, 8, 1440, 0); // 27" classic AddMode(2560*2, 1440*2, 8, 1440*2, 0); // 5k #else From b9d7a98aeceac8987917db03c9eecce50b1b4abd Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 1 Jun 2016 06:02:37 +0200 Subject: [PATCH 0618/1509] Change swtruecolor cvar to take effect immediately --- src/posix/cocoa/i_video.mm | 11 ++++++++++- src/posix/sdl/hardware.cpp | 12 ++++++++++-- src/win32/hardware.cpp | 12 ++++++++++-- src/win32/win32video.cpp | 14 -------------- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index c97460a02..c2eb58c6d 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -96,7 +96,16 @@ EXTERN_CVAR(Bool, ticker ) EXTERN_CVAR(Bool, vid_vsync) EXTERN_CVAR(Bool, vid_hidpi) -CVAR(Bool, swtruecolor, false, CVAR_ARCHIVE) +CUSTOM_CVAR(Bool, swtruecolor, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + // Strictly speaking this doesn't require a mode switch, but it is the easiest + // way to force a CreateFramebuffer call without a lot of refactoring. + extern int NewWidth, NewHeight, NewBits, DisplayBits; + NewWidth = screen->GetWidth(); + NewHeight = screen->GetHeight(); + NewBits = DisplayBits; + setmodeneeded = true; +} CUSTOM_CVAR(Bool, fullscreen, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 52bca35e7..9de4d03a4 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -281,10 +281,18 @@ CUSTOM_CVAR (Int, vid_maxfps, 200, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) } } -CVAR (Bool, swtruecolor, false, CVAR_ARCHIVE) - extern int NewWidth, NewHeight, NewBits, DisplayBits; +CUSTOM_CVAR(Bool, swtruecolor, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +{ + // Strictly speaking this doesn't require a mode switch, but it is the easiest + // way to force a CreateFramebuffer call without a lot of refactoring. + NewWidth = screen->GetWidth(); + NewHeight = screen->GetHeight(); + NewBits = DisplayBits; + setmodeneeded = true; +} + CUSTOM_CVAR (Bool, fullscreen, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) { NewWidth = screen->GetWidth(); diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 8856924c0..49c970457 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -311,10 +311,18 @@ void I_RestoreWindowedPos () MoveWindow (Window, winx, winy, winw, winh, TRUE); } -CVAR (Bool, swtruecolor, false, CVAR_ARCHIVE) - extern int NewWidth, NewHeight, NewBits, DisplayBits; +CUSTOM_CVAR(Bool, swtruecolor, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +{ + // Strictly speaking this doesn't require a mode switch, but it is the easiest + // way to force a CreateFramebuffer call without a lot of refactoring. + NewWidth = screen->GetWidth(); + NewHeight = screen->GetHeight(); + NewBits = DisplayBits; + setmodeneeded = true; +} + CUSTOM_CVAR (Bool, fullscreen, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) { NewWidth = screen->GetWidth(); diff --git a/src/win32/win32video.cpp b/src/win32/win32video.cpp index a180a35ea..74b10ef07 100644 --- a/src/win32/win32video.cpp +++ b/src/win32/win32video.cpp @@ -221,22 +221,8 @@ bool Win32Video::InitD3D9 () // Enumerate available display modes. FreeModes (); -#ifndef PALETTEOUTPUT // To do: remove this again (AddD3DModes fails when there are too many modes available for videomenu to display) - - AddMode(320, 200, 8, 200, 0); - AddMode(320, 240, 8, 240, 0); - AddMode(640, 480, 8, 480, 0); - AddMode(800, 600, 8, 600, 0); - AddMode(1024, 768, 8, 768, 0); - - AddMode(1920, 1080, 8, 1080, 0); // 1080p - AddMode(1920*2, 1080*2, 8, 1080*2, 0); // 4k - AddMode(2560, 1440, 8, 1440, 0); // 27" classic - AddMode(2560*2, 1440*2, 8, 1440*2, 0); // 5k -#else AddD3DModes (m_Adapter, D3DFMT_X8R8G8B8); AddD3DModes (m_Adapter, D3DFMT_R5G6B5); -#endif if (Args->CheckParm ("-2")) { // Force all modes to be pixel-doubled. ScaleModes (1); From 4f635983fcf791b52535b9c597bdc4e823fef635 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 1 Jun 2016 08:54:39 +0200 Subject: [PATCH 0619/1509] Add bgra support to OS X target --- src/posix/cocoa/i_video.mm | 30 +++++++++++++++++++++--------- src/r_main.cpp | 1 - src/r_swrenderer.cpp | 1 + src/v_draw.cpp | 6 ++++++ 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index c2eb58c6d..425fe5887 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -249,7 +249,7 @@ private: class CocoaFrameBuffer : public DFrameBuffer { public: - CocoaFrameBuffer(int width, int height, bool fullscreen); + CocoaFrameBuffer(int width, int height, bool bgra, bool fullscreen); ~CocoaFrameBuffer(); virtual bool Lock(bool buffer); @@ -536,7 +536,7 @@ DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, c if (NULL != old) { - if (width == m_width && height == m_height) + if (width == m_width && height == m_height && bgra == old->IsBgra()) { SetMode(width, height, fullscreen, vid_hidpi); return old; @@ -553,7 +553,7 @@ DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, c delete old; } - CocoaFrameBuffer* fb = new CocoaFrameBuffer(width, height, fullscreen); + CocoaFrameBuffer* fb = new CocoaFrameBuffer(width, height, bgra, fullscreen); fb->SetFlash(flashColor, flashAmount); SetMode(width, height, fullscreen, vid_hidpi); @@ -772,8 +772,8 @@ CocoaVideo* CocoaVideo::GetInstance() } -CocoaFrameBuffer::CocoaFrameBuffer(int width, int height, bool fullscreen) -: DFrameBuffer(width, height, false) +CocoaFrameBuffer::CocoaFrameBuffer(int width, int height, bool bgra, bool fullscreen) +: DFrameBuffer(width, height, bgra) , m_needPaletteUpdate(false) , m_gamma(0.0f) , m_needGammaUpdate(false) @@ -867,8 +867,18 @@ void CocoaFrameBuffer::Update() FlipCycles.Reset(); BlitCycles.Clock(); - GPfx.Convert(MemBuffer, Pitch, m_pixelBuffer, Width * BYTES_PER_PIXEL, - Width, Height, FRACUNIT, FRACUNIT, 0, 0); + if (IsBgra()) + { + for (int y = 0; y < Height; y++) + { + memcpy((uint32_t*)m_pixelBuffer + y * Width, (uint32_t*)MemBuffer + y * Pitch, Width * BYTES_PER_PIXEL); + } + } + else + { + GPfx.Convert(MemBuffer, Pitch, m_pixelBuffer, Width * BYTES_PER_PIXEL, + Width, Height, FRACUNIT, FRACUNIT, 0, 0); + } FlipCycles.Clock(); Flip(); @@ -1000,8 +1010,10 @@ void CocoaFrameBuffer::Flip() static const GLenum format = GL_ABGR_EXT; #endif // __LITTLE_ENDIAN__ - glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, - Width, Height, 0, format, GL_UNSIGNED_BYTE, m_pixelBuffer); + if (IsBgra()) + glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, Width, Height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, m_pixelBuffer); + else + glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, Width, Height, 0, format, GL_UNSIGNED_BYTE, m_pixelBuffer); glBegin(GL_QUADS); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); diff --git a/src/r_main.cpp b/src/r_main.cpp index aec8310d5..aaf8fc532 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -984,7 +984,6 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas, if (r_swtruecolor != canvas->IsBgra()) { - r_swtruecolor = canvas->IsBgra(); R_InitColumnDrawers(); } } diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 15e2fda8f..ee6ac5fed 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -58,6 +58,7 @@ void R_InitRenderer(); void FSoftwareRenderer::Init() { + r_swtruecolor = screen->IsBgra(); R_InitRenderer(); } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index b4f1ad4b5..57fac3cda 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -129,6 +129,12 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH]; const BYTE *translation = NULL; + if (r_swtruecolor != IsBgra()) + { + r_swtruecolor = IsBgra(); + R_InitColumnDrawers(); + } + if (parms.masked) { spanptr = &spans; From 47f32d03cd2d0b8966361b49acb5d0b6de40b94b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 2 Jun 2016 14:49:03 +0200 Subject: [PATCH 0620/1509] Fixed some light and blending functions for the true color mode --- src/r_draw.cpp | 283 +++++++++++++++++++++++++------------------ src/r_draw.h | 2 + src/r_drawt_rgba.cpp | 76 +++++++----- src/r_main.h | 13 +- src/r_plane.cpp | 48 ++++++-- src/r_segs.cpp | 41 +++---- src/r_things.cpp | 13 +- src/v_draw.cpp | 6 +- 8 files changed, 284 insertions(+), 198 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index d7b740973..5a314e640 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -155,6 +155,8 @@ int dc_color; // [RH] Color for column filler DWORD dc_srccolor; DWORD *dc_srcblend; // [RH] Source and destination DWORD *dc_destblend; // blending lookups +fixed_t dc_srcalpha; // Alpha value used by dc_srcblend +fixed_t dc_destalpha; // Alpha value used by dc_destblend // first pixel in a column (possibly virtual) const BYTE* dc_source; @@ -414,9 +416,10 @@ void R_FillAddColumn_RGBA_C() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; - uint32_t fg_green = (dc_srccolor >> 2) & 0xf8; - uint32_t fg_blue = (dc_srccolor << 3) & 0xf8; + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg_red = (fg >> 24) & 0xff; + uint32_t fg_green = (fg >> 16) & 0xff; + uint32_t fg_blue = fg & 0xff; do { @@ -478,9 +481,10 @@ void R_FillAddClampColumn_RGBA() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; - uint32_t fg_green = (dc_srccolor >> 2) & 0xf8; - uint32_t fg_blue = (dc_srccolor << 3) & 0xf8; + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg_red = (fg >> 24) & 0xff; + uint32_t fg_green = (fg >> 16) & 0xff; + uint32_t fg_blue = fg & 0xff; do { @@ -541,9 +545,10 @@ void R_FillSubClampColumn_RGBA() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; - uint32_t fg_green = (dc_srccolor >> 2) & 0xf8; - uint32_t fg_blue = (dc_srccolor << 3) & 0xf8; + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg_red = (fg >> 24) & 0xff; + uint32_t fg_green = (fg >> 16) & 0xff; + uint32_t fg_blue = fg & 0xff; do { @@ -604,9 +609,10 @@ void R_FillRevSubClampColumn_RGBA() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; - uint32_t fg_green = (dc_srccolor >> 2) & 0xf8; - uint32_t fg_blue = (dc_srccolor << 3) & 0xf8; + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg_red = (fg >> 24) & 0xff; + uint32_t fg_green = (fg >> 16) & 0xff; + uint32_t fg_blue = fg & 0xff; do { @@ -946,6 +952,9 @@ void R_DrawAddColumnP_RGBA_C() int pitch = dc_pitch; BYTE *colormap = dc_colormap; + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], 0); @@ -958,9 +967,9 @@ void R_DrawAddColumnP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -1107,6 +1116,9 @@ void R_DrawTlatedAddColumnP_RGBA_C() const BYTE *source = dc_source; int pitch = dc_pitch; + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); @@ -1119,9 +1131,9 @@ void R_DrawTlatedAddColumnP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -1276,6 +1288,9 @@ void R_DrawAddClampColumnP_RGBA_C() int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light); @@ -1287,9 +1302,9 @@ void R_DrawAddClampColumnP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -1363,6 +1378,9 @@ void R_DrawAddClampTranslatedColumnP_RGBA_C() int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); @@ -1374,9 +1392,9 @@ void R_DrawAddClampTranslatedColumnP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -1447,6 +1465,9 @@ void R_DrawSubClampColumnP_RGBA_C() int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light); @@ -1458,9 +1479,9 @@ void R_DrawSubClampColumnP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -1533,6 +1554,9 @@ void R_DrawSubClampTranslatedColumnP_RGBA_C() int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); @@ -1544,9 +1568,9 @@ void R_DrawSubClampTranslatedColumnP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -1616,6 +1640,8 @@ void R_DrawRevSubClampColumnP_RGBA_C() const BYTE *source = dc_source; int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { @@ -1628,9 +1654,9 @@ void R_DrawRevSubClampColumnP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; + uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -1703,6 +1729,9 @@ void R_DrawRevSubClampTranslatedColumnP_RGBA_C() int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); @@ -1714,9 +1743,9 @@ void R_DrawRevSubClampTranslatedColumnP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; + uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -1806,8 +1835,7 @@ void R_SetSpanSource(const BYTE *pixels) void R_SetSpanColormap(BYTE *colormap) { - ds_colormap = colormap; - ds_light = 0; + R_SetDSColorMapLight(colormap, 0, 0); #ifdef X86_ASM if (!r_swtruecolor && ds_colormap != ds_curcolormap) { @@ -2316,8 +2344,6 @@ void R_DrawSpanTranslucentP_RGBA_C() const BYTE* colormap = ds_colormap; int count; int spot; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; xfrac = ds_xfrac; yfrac = ds_yfrac; @@ -2331,6 +2357,9 @@ void R_DrawSpanTranslucentP_RGBA_C() uint32_t light = calc_light_multiplier(ds_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + if (ds_xbits == 6 && ds_ybits == 6) { // 64x64 is the most common case by far, so special case it. @@ -2347,9 +2376,9 @@ void R_DrawSpanTranslucentP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; + uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; + uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; + uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; @@ -2375,9 +2404,9 @@ void R_DrawSpanTranslucentP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; + uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; + uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; + uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; @@ -2474,11 +2503,12 @@ void R_DrawSpanMaskedTranslucentP_RGBA_C() const BYTE* colormap = ds_colormap; int count; int spot; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; uint32_t light = calc_light_multiplier(ds_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + xfrac = ds_xfrac; yfrac = ds_yfrac; @@ -2509,9 +2539,9 @@ void R_DrawSpanMaskedTranslucentP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; + uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; + uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; + uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -2542,9 +2572,9 @@ void R_DrawSpanMaskedTranslucentP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; + uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; + uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; + uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -2636,11 +2666,12 @@ void R_DrawSpanAddClampP_RGBA_C() const BYTE* colormap = ds_colormap; int count; int spot; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; uint32_t light = calc_light_multiplier(ds_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + xfrac = ds_xfrac; yfrac = ds_yfrac; @@ -2667,9 +2698,9 @@ void R_DrawSpanAddClampP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; @@ -2695,9 +2726,9 @@ void R_DrawSpanAddClampP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; @@ -2800,11 +2831,12 @@ void R_DrawSpanMaskedAddClampP_RGBA_C() const BYTE* colormap = ds_colormap; int count; int spot; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; uint32_t light = calc_light_multiplier(ds_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + xfrac = ds_xfrac; yfrac = ds_yfrac; @@ -2835,9 +2867,9 @@ void R_DrawSpanMaskedAddClampP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; + uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; + uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; + uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -2868,9 +2900,9 @@ void R_DrawSpanMaskedAddClampP_RGBA_C() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; + uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; + uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; + uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -3468,8 +3500,7 @@ void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip) clearbufshort (spanend+t2, b2-t2, x); } - dc_colormap = basecolormapdata + (rcolormap << COLORMAPSHIFT); - dc_light = 0; + R_SetColorMapLight(basecolormapdata, (float)light, wallshade); for (--x; x >= x1; --x) { @@ -3494,8 +3525,7 @@ void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip) clearbufshort (spanend+t2, b2-t2, x); } rcolormap = lcolormap; - dc_colormap = basecolormapdata + (lcolormap << COLORMAPSHIFT); - dc_light = 0; + R_SetColorMapLight(basecolormapdata, (float)light, wallshade); } else { @@ -3594,8 +3624,7 @@ void R_DrawFogBoundary_RGBA(int x1, int x2, short *uclip, short *dclip) clearbufshort(spanend + t2, b2 - t2, x); } - dc_colormap = basecolormapdata + (rcolormap << COLORMAPSHIFT); - dc_light = 0; + R_SetColorMapLight(basecolormapdata, (float)light, wallshade); for (--x; x >= x1; --x) { @@ -3620,8 +3649,7 @@ void R_DrawFogBoundary_RGBA(int x1, int x2, short *uclip, short *dclip) clearbufshort(spanend + t2, b2 - t2, x); } rcolormap = lcolormap; - dc_colormap = basecolormapdata + (lcolormap << COLORMAPSHIFT); - dc_light = 0; + R_SetColorMapLight(basecolormapdata, (float)light, wallshade); } else { @@ -3717,11 +3745,11 @@ fixed_t tmvline1_add_RGBA() int bits = tmvlinebits; int pitch = dc_pitch; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; - uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { BYTE pix = source[frac >> bits]; @@ -3736,9 +3764,9 @@ fixed_t tmvline1_add_RGBA() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); *dest = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -3794,6 +3822,9 @@ void tmvline4_add_RGBA() light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { for (int i = 0; i < 4; ++i) @@ -3810,9 +3841,9 @@ void tmvline4_add_RGBA() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -3871,11 +3902,11 @@ fixed_t tmvline1_addclamp_RGBA() int bits = tmvlinebits; int pitch = dc_pitch; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; - uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { BYTE pix = source[frac >> bits]; @@ -3890,9 +3921,9 @@ fixed_t tmvline1_addclamp_RGBA() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); *dest = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -3947,6 +3978,9 @@ void tmvline4_addclamp_RGBA() light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { for (int i = 0; i < 4; ++i) @@ -3963,9 +3997,9 @@ void tmvline4_addclamp_RGBA() uint32_t bg_green = (dest[i] >> 8) & 0xff; uint32_t bg_blue = (dest[i]) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -4023,6 +4057,9 @@ fixed_t tmvline1_subclamp_RGBA() uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { BYTE pix = source[frac >> bits]; @@ -4037,9 +4074,9 @@ fixed_t tmvline1_subclamp_RGBA() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -4093,6 +4130,9 @@ void tmvline4_subclamp_RGBA() light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { for (int i = 0; i < 4; ++i) @@ -4109,9 +4149,9 @@ void tmvline4_subclamp_RGBA() uint32_t bg_green = (dest[i] >> 8) & 0xff; uint32_t bg_blue = (dest[i]) & 0xff; - uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -4169,6 +4209,9 @@ fixed_t tmvline1_revsubclamp_RGBA() uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { BYTE pix = source[frac >> bits]; @@ -4183,9 +4226,9 @@ fixed_t tmvline1_revsubclamp_RGBA() uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; + uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -4233,15 +4276,15 @@ void tmvline4_revsubclamp_RGBA() int count = dc_count; int bits = tmvlinebits; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; - uint32_t light[4]; light[0] = calc_light_multiplier(palookuplight[0]); light[1] = calc_light_multiplier(palookuplight[1]); light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { for (int i = 0; i < 4; ++i) @@ -4258,9 +4301,9 @@ void tmvline4_revsubclamp_RGBA() uint32_t bg_green = (dest[i] >> 8) & 0xff; uint32_t bg_blue = (dest[i]) & 0xff; - uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; + uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -4558,16 +4601,22 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) { dc_srcblend = Col2RGB8_Inverse[fglevel>>10]; dc_destblend = Col2RGB8_LessPrecision[bglevel>>10]; + dc_srcalpha = fglevel; + dc_destalpha = bglevel; } else if (op == STYLEOP_Add && fglevel + bglevel <= FRACUNIT) { dc_srcblend = Col2RGB8[fglevel>>10]; dc_destblend = Col2RGB8[bglevel>>10]; + dc_srcalpha = fglevel; + dc_destalpha = bglevel; } else { dc_srcblend = Col2RGB8_LessPrecision[fglevel>>10]; dc_destblend = Col2RGB8_LessPrecision[bglevel>>10]; + dc_srcalpha = fglevel; + dc_destalpha = bglevel; } switch (op) { @@ -4736,12 +4785,15 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, hcolfunc_post1 = rt_shaded1col; hcolfunc_post4 = rt_shaded4cols; dc_color = fixedcolormap ? fixedcolormap[APART(color)] : basecolormap->Maps[APART(color)]; - dc_colormap = (basecolormap = &ShadeFakeColormap[16-alpha])->Maps; + lighttable_t *colormap = (basecolormap = &ShadeFakeColormap[16-alpha])->Maps; if (fixedlightlev >= 0 && fixedcolormap == NULL) { - dc_colormap += fixedlightlev; + R_SetColorMapLight(colormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + } + else + { + R_SetColorMapLight(colormap, 0, 0); } - dc_light = 0; return r_columnmethod ? DoDraw1 : DoDraw0; } @@ -4766,8 +4818,7 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, // with the alpha. dc_srccolor = ((((r*x)>>4)<<20) | ((g*x)>>4) | ((((b)*x)>>4)<<10)) & 0x3feffbff; hcolfunc_pre = R_FillColumnHoriz; - dc_colormap = identitymap; - dc_light = 0; + R_SetColorMapLight(identitymap, 0, 0); } if (!R_SetBlendFunc (style.BlendOp, fglevel, bglevel, style.Flags)) diff --git a/src/r_draw.h b/src/r_draw.h index d5007c885..f60b2299e 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -41,6 +41,8 @@ extern "C" int dc_color; // [RH] For flat colors (no texturing) extern "C" DWORD dc_srccolor; extern "C" DWORD *dc_srcblend; extern "C" DWORD *dc_destblend; +extern "C" fixed_t dc_srcalpha; +extern "C" fixed_t dc_destalpha; // first pixel in a column extern "C" const BYTE* dc_source; diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 872cb4b89..1725b80e4 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -308,6 +308,9 @@ void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh) uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { uint32_t fg = shade_pal_index(colormap[*source], light); uint32_t fg_red = (fg >> 16) & 0xff; @@ -318,9 +321,9 @@ void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh) uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); *dest = 0xff000000 | (red << 16) | (green << 8) | blue; @@ -350,6 +353,9 @@ void rt_add4cols_RGBA_c (int sx, int yl, int yh) uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { for (int i = 0; i < 4; i++) { @@ -362,9 +368,9 @@ void rt_add4cols_RGBA_c (int sx, int yl, int yh) uint32_t bg_green = (dest[i] >> 8) & 0xff; uint32_t bg_blue = (dest[i]) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -496,6 +502,9 @@ void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh) uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { uint32_t fg = shade_pal_index(colormap[*source], light); uint32_t fg_red = (fg >> 16) & 0xff; @@ -506,9 +515,9 @@ void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh) uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); *dest = 0xff000000 | (red << 16) | (green << 8) | blue; source += 4; @@ -537,6 +546,9 @@ void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh) uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { for (int i = 0; i < 4; i++) { @@ -549,9 +561,9 @@ void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh) uint32_t bg_green = (dest[i] >> 8) & 0xff; uint32_t bg_blue = (dest[i]) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -595,6 +607,9 @@ void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh) uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { uint32_t fg = shade_pal_index(colormap[*source], light); uint32_t fg_red = (fg >> 16) & 0xff; @@ -605,9 +620,9 @@ void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh) uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; source += 4; @@ -636,6 +651,9 @@ void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh) uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { for (int i = 0; i < 4; i++) { @@ -648,9 +666,9 @@ void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh) uint32_t bg_green = (dest[i] >> 8) & 0xff; uint32_t bg_blue = (dest[i]) & 0xff; - uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 256; + uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -688,8 +706,6 @@ void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) return; count++; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; @@ -697,6 +713,9 @@ void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { uint32_t fg = shade_pal_index(colormap[*source], light); uint32_t fg_red = (fg >> 16) & 0xff; @@ -707,9 +726,9 @@ void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; + uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; source += 4; @@ -731,8 +750,6 @@ void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh) return; count++; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; @@ -740,6 +757,9 @@ void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh) uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + do { for (int i = 0; i < 4; i++) { @@ -752,9 +772,9 @@ void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh) uint32_t bg_green = (dest[i] >> 8) & 0xff; uint32_t bg_blue = (dest[i]) & 0xff; - uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 256; - uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 256; - uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 256; + uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } diff --git a/src/r_main.h b/src/r_main.h index 765635e5d..e8be3c1a3 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -82,15 +82,18 @@ extern bool r_dontmaplines; // Change R_CalcTiltedLighting() when this changes. #define GETPALOOKUP(vis,shade) (clamp (((shade)-FLOAT2FIXED(MIN(MAXLIGHTVIS,double(vis))))>>FRACBITS, 0, NUMCOLORMAPS-1)) -// Calculate the light multiplier for ds_light -// This is used instead of GETPALOOKUP when ds_colormap+dc_colormap is set to the base colormap -#define LIGHTSCALE(vis,shade) ((shade)-FLOAT2FIXED(MIN(MAXLIGHTVIS,double(vis)))) +// Calculate the light multiplier for dc_light/ds_light +// This is used instead of GETPALOOKUP when ds_colormap/dc_colormap is set to the base colormap +// Returns a value between 0 and 1 in fixed point +#define LIGHTSCALE(vis,shade) FLOAT2FIXED(clamp((FIXED2DBL(shade) - (MIN(MAXLIGHTVIS,double(vis)))) / NUMCOLORMAPS, 0.0, (NUMCOLORMAPS-1)/(double)NUMCOLORMAPS)) + +// Converts fixedlightlev into a shade value +#define FIXEDLIGHT2SHADE(lightlev) (((lightlev) >> COLORMAPSHIFT) << FRACBITS) // calculates the light constant passed to the shade_pal_index function inline uint32_t calc_light_multiplier(dsfixed_t light) { - // the 0.70 multiplier shouldn't be needed - maybe the palette shades in doom weren't linear? - return (uint32_t)clamp((1.0 - FIXED2DBL(light) / MAXLIGHTVIS * 0.70) * 256 + 0.5, 0.0, 256.0); + return 256 - (light >> (FRACBITS - 8)); } // Calculates a ARGB8 color for the given palette index and light multiplier diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 40e14c020..9805ab200 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -391,8 +391,7 @@ void R_MapTiltedPlane_C (int y, int x1) u = SQWORD(uz*z) + pviewx; v = SQWORD(vz*z) + pviewy; - ds_colormap = tiltlighting[i]; - ds_light = 0; + R_SetDSColorMapLight(tiltlighting[i], 0, 0); fb[i++] = ds_colormap[ds_source[(v >> vshift) | ((u >> ushift) & umask)]]; iz += plane_sz[0]; uz += plane_su[0]; @@ -515,8 +514,7 @@ void R_MapTiltedPlane_RGBA (int y, int x1) u = SQWORD(uz*z) + pviewx; v = SQWORD(vz*z) + pviewy; - ds_colormap = tiltlighting[i]; - ds_light = 0; + R_SetDSColorMapLight(tiltlighting[i], 0, 0); fb[i++] = ds_colormap[ds_source[(v >> vshift) | ((u >> ushift) & umask)]]; iz += plane_sz[0]; uz += plane_su[0]; @@ -1595,14 +1593,13 @@ void R_DrawSkyPlane (visplane_t *pl) bool fakefixed = false; if (fixedcolormap) { - dc_colormap = fixedcolormap; - dc_light = 0; + R_SetColorMapLight(fixedcolormap, 0, 0); } else { fakefixed = true; - fixedcolormap = dc_colormap = NormalLight.Maps; - dc_light = 0; + fixedcolormap = NormalLight.Maps; + R_SetColorMapLight(fixedcolormap, 0, 0); } R_DrawSky (pl); @@ -1685,11 +1682,19 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t GlobVis = r_FloorVisibility / planeheight; ds_light = 0; if (fixedlightlev >= 0) - ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false; + { + R_SetDSColorMapLight(basecolormap->Maps, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + plane_shade = false; + } else if (fixedcolormap) - ds_colormap = fixedcolormap, plane_shade = false; + { + R_SetDSColorMapLight(fixedcolormap, 0, 0); + plane_shade = false; + } else + { plane_shade = true; + } if (spanfunc != R_FillSpan) { @@ -1702,12 +1707,16 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t spanfunc = R_DrawSpanMaskedTranslucent; dc_srcblend = Col2RGB8[alpha>>10]; dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE - alpha; } else { spanfunc = R_DrawSpanMaskedAddClamp; dc_srcblend = Col2RGB8_LessPrecision[alpha>>10]; dc_destblend = Col2RGB8_LessPrecision[FRACUNIT>>10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE - alpha; } } else @@ -1724,12 +1733,16 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t spanfunc = R_DrawSpanTranslucent; dc_srcblend = Col2RGB8[alpha>>10]; dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE - alpha; } else { spanfunc = R_DrawSpanAddClamp; dc_srcblend = Col2RGB8_LessPrecision[alpha>>10]; dc_destblend = Col2RGB8_LessPrecision[FRACUNIT>>10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE - alpha; } } else @@ -1846,11 +1859,20 @@ void R_DrawTiltedPlane(visplane_t *pl, double _xscale, double _yscale, fixed_t a ds_light = 0; if (fixedlightlev >= 0) - ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false; + { + R_SetDSColorMapLight(basecolormap->Maps, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + plane_shade = false; + } else if (fixedcolormap) - ds_colormap = fixedcolormap, plane_shade = false; + { + R_SetDSColorMapLight(fixedcolormap, 0, 0); + plane_shade = false; + } else - ds_colormap = basecolormap->Maps, plane_shade = true; + { + R_SetDSColorMapLight(basecolormap->Maps, 0, 0); + plane_shade = true; + } if (!plane_shade) { diff --git a/src/r_segs.cpp b/src/r_segs.cpp index cab97adfc..43590247e 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -177,8 +177,7 @@ static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FText // calculate lighting if (fixedcolormap == NULL && fixedlightlev < 0) { - dc_colormap = basecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); - dc_light = 0; + R_SetColorMapLight(basecolormap->Maps, rw_light, wallshade); } dc_iscale = xs_Fix<16>::ToFix(MaskedSWall[dc_x] * MaskedScaleY); @@ -314,10 +313,9 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) rw_scalestep = ds->iscalestep; if (fixedlightlev >= 0) - dc_colormap = basecolormap->Maps + fixedlightlev; + R_SetColorMapLight(basecolormap->Maps, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; - dc_light = 0; + R_SetColorMapLight(fixedcolormap, 0, 0); // find positioning texheight = tex->GetScaledHeightDouble(); @@ -632,10 +630,9 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) } if (fixedlightlev >= 0) - dc_colormap = basecolormap->Maps + fixedlightlev; + R_SetColorMapLight(basecolormap->Maps, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; - dc_light = 0; + R_SetColorMapLight(fixedcolormap, 0, 0); WallC.sz1 = ds->sz1; WallC.sz2 = ds->sz2; @@ -1435,11 +1432,11 @@ static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *d } } -inline fixed_t mvline1 (fixed_t vince, BYTE *colormap, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest) +inline fixed_t mvline1 (fixed_t vince, BYTE *colormap, fixed_t light, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest) { dc_iscale = vince; dc_colormap = colormap; - dc_light = 0; + dc_light = light; dc_count = count; dc_texturefrac = vplce; dc_source = bufplce; @@ -1508,8 +1505,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ if (!fixed) { // calculate lighting - dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); - dc_light = 0; + R_SetColorMapLight(basecolormapdata, light, wallshade); } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1569,7 +1565,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ { if (!(bad & 1)) { - mvline1(vince[z],palookupoffse[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel); + mvline1(vince[z],palookupoffse[z],palookuplight[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel); } bad >>= 1; } @@ -1580,7 +1576,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ { if (u4 > y1ve[z]) { - vplce[z] = mvline1(vince[z],palookupoffse[z],u4-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel); + vplce[z] = mvline1(vince[z],palookupoffse[z],palookuplight[z],u4-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel); } } @@ -1596,7 +1592,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ { if (y2ve[z] > d4) { - mvline1(vince[z],palookupoffse[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z*pixelsize); + mvline1(vince[z],palookupoffse[0],palookuplight[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z*pixelsize); } } } @@ -1609,8 +1605,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ if (!fixed) { // calculate lighting - dc_colormap = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); - dc_light = 0; + R_SetColorMapLight(basecolormapdata, light, wallshade); } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1844,10 +1839,9 @@ void R_RenderSegLoop () fixed_t xoffset = rw_offset; if (fixedlightlev >= 0) - dc_colormap = basecolormap->Maps + fixedlightlev; + R_SetColorMapLight(basecolormap->Maps, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; - dc_light = 0; + R_SetColorMapLight(fixedcolormap, 0, 0); // clip wall to the floor and ceiling for (x = x1; x < x2; ++x) @@ -3244,14 +3238,13 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rw_light = rw_lightleft + (x1 - WallC.sx1) * rw_lightstep; if (fixedlightlev >= 0) - dc_colormap = usecolormap->Maps + fixedlightlev; + R_SetColorMapLight(usecolormap->Maps, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT)) - dc_colormap = usecolormap->Maps; + R_SetColorMapLight(usecolormap->Maps, 0, 0); else calclighting = true; - dc_light = 0; // Draw it if (decal->RenderFlags & RF_YFLIP) diff --git a/src/r_things.cpp b/src/r_things.cpp index f52c80376..98557817d 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -408,8 +408,7 @@ void R_DrawVisSprite (vissprite_t *vis) } fixed_t centeryfrac = FLOAT2FIXED(CenterY); - dc_colormap = vis->Style.colormap; - dc_light = 0; + R_SetColorMapLight(vis->Style.colormap, 0, 0); mode = R_SetPatchStyle (vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor); @@ -539,14 +538,13 @@ void R_DrawWallSprite(vissprite_t *spr) rw_lightstep = float((GlobVis / spr->wallc.sz2 - rw_lightleft) / (spr->wallc.sx2 - spr->wallc.sx1)); rw_light = rw_lightleft + (x1 - spr->wallc.sx1) * rw_lightstep; if (fixedlightlev >= 0) - dc_colormap = usecolormap->Maps + fixedlightlev; + R_SetColorMapLight(usecolormap->Maps, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) - dc_colormap = usecolormap->Maps; + R_SetColorMapLight(usecolormap->Maps, 0, 0); else calclighting = true; - dc_light = 0; // Draw it WallSpriteTile = spr->pic; @@ -656,8 +654,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop int flags = 0; // Do setup for blending. - dc_colormap = spr->Style.colormap; - dc_light = 0; + R_SetColorMapLight(spr->Style.colormap, 0, 0); mode = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); if (mode == DontDraw) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 57fac3cda..ff0427b34 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -171,13 +171,11 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) if (translation != NULL) { - dc_colormap = (lighttable_t *)translation; - dc_light = 0; + R_SetColorMapLight((lighttable_t *)translation, 0, 0); } else { - dc_colormap = identitymap; - dc_light = 0; + R_SetColorMapLight(identitymap, 0, 0); } fixedcolormap = dc_colormap; From 41537a50ab9f9aeb5f07e121ed8d1396dd7d261a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 2 Jun 2016 16:52:41 +0200 Subject: [PATCH 0621/1509] Fix true color light calculation bug for decals --- src/r_draw.cpp | 8 ++++---- src/r_drawt_rgba.cpp | 4 ++-- src/r_things.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 5a314e640..c190c1e73 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -416,7 +416,7 @@ void R_FillAddColumn_RGBA_C() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -481,7 +481,7 @@ void R_FillAddClampColumn_RGBA() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -545,7 +545,7 @@ void R_FillSubClampColumn_RGBA() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -609,7 +609,7 @@ void R_FillRevSubClampColumn_RGBA() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 1725b80e4..60520783d 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -413,7 +413,7 @@ void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh) source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -455,7 +455,7 @@ void rt_shaded4cols_RGBA_c (int sx, int yl, int yh) source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; diff --git a/src/r_things.cpp b/src/r_things.cpp index 98557817d..3fcefe038 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -416,7 +416,7 @@ void R_DrawVisSprite (vissprite_t *vis) { // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but // it is the brightest one. We need to get back to the proper light level for // this sprite. - dc_colormap += vis->ColormapNum << COLORMAPSHIFT; + R_SetColorMapLight(dc_colormap, 0, vis->ColormapNum << FRACBITS); } if (mode != DontDraw) @@ -2704,9 +2704,9 @@ void R_DrawParticle_RGBA(vissprite_t *vis) uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = (fg_red + bg_red * alpha) / 256; - uint32_t green = (fg_green + bg_green * alpha) / 256; - uint32_t blue = (fg_blue + bg_blue * alpha) / 256; + uint32_t red = (fg_red + bg_red * inv_alpha) / 256; + uint32_t green = (fg_green + bg_green * inv_alpha) / 256; + uint32_t blue = (fg_blue + bg_blue * inv_alpha) / 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += spacing; From 672b80898b720c03ea10367259cc7b524cc4bead Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 2 Jun 2016 19:26:27 +0200 Subject: [PATCH 0622/1509] Moved ColormapNum to visstyle_t and changed colormap to BaseColormap --- src/g_shared/a_artifacts.cpp | 3 +- src/r_defs.h | 3 +- src/r_things.cpp | 115 ++++++++++++++++++++--------------- src/r_things.h | 1 - 4 files changed, 70 insertions(+), 52 deletions(-) diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index d36cdfe65..777d6824a 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -737,7 +737,8 @@ int APowerInvisibility::AlterWeaponSprite (visstyle_t *vis) if ((vis->Alpha < 0.25f && special1 > 0) || (vis->Alpha == 0)) { vis->Alpha = clamp((1.f - float(Strength/100)), 0.f, 1.f); - vis->colormap = SpecialColormaps[INVERSECOLORMAP].Colormap; + vis->BaseColormap = SpecialColormaps[INVERSECOLORMAP].Colormap; + vis->ColormapNum = 0; } return -1; // This item is valid so another one shouldn't reset the translucency } diff --git a/src/r_defs.h b/src/r_defs.h index f27ac2716..8a247a5c0 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1401,7 +1401,8 @@ typedef BYTE lighttable_t; // This could be wider for >8 bit display. // This encapsulates the fields of vissprite_t that can be altered by AlterWeaponSprite struct visstyle_t { - lighttable_t *colormap; + int ColormapNum; // Which colormap is rendered + lighttable_t *BaseColormap; // Base colormap used together with ColormapNum float Alpha; FRenderStyle RenderStyle; }; diff --git a/src/r_things.cpp b/src/r_things.cpp index 3fcefe038..6f8038148 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -408,7 +408,7 @@ void R_DrawVisSprite (vissprite_t *vis) } fixed_t centeryfrac = FLOAT2FIXED(CenterY); - R_SetColorMapLight(vis->Style.colormap, 0, 0); + R_SetColorMapLight(vis->Style.BaseColormap, 0, vis->Style.ColormapNum << FRACBITS); mode = R_SetPatchStyle (vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor); @@ -416,7 +416,7 @@ void R_DrawVisSprite (vissprite_t *vis) { // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but // it is the brightest one. We need to get back to the proper light level for // this sprite. - R_SetColorMapLight(dc_colormap, 0, vis->ColormapNum << FRACBITS); + R_SetColorMapLight(dc_colormap, 0, vis->Style.ColormapNum << FRACBITS); } if (mode != DontDraw) @@ -654,7 +654,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop int flags = 0; // Do setup for blending. - R_SetColorMapLight(spr->Style.colormap, 0, 0); + R_SetColorMapLight(spr->Style.BaseColormap, 0, spr->Style.ColormapNum << FRACBITS); mode = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); if (mode == DontDraw) @@ -680,7 +680,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop // Render the voxel, either directly to the screen or offscreen. R_DrawVoxel(spr->pa.vpos, spr->pa.vang, spr->gpos, spr->Angle, - spr->xscale, FLOAT2FIXED(spr->yscale), spr->voxel, spr->Style.colormap, cliptop, clipbot, + spr->xscale, FLOAT2FIXED(spr->yscale), spr->voxel, spr->Style.BaseColormap + (spr->Style.ColormapNum << COLORMAPSHIFT), cliptop, clipbot, minslabz, maxslabz, flags); // Blend the voxel, if that's what we need to do. @@ -1058,7 +1058,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor vis->Style.Alpha = float(thing->Alpha); vis->fakefloor = fakefloor; vis->fakeceiling = fakeceiling; - vis->ColormapNum = 0; + vis->Style.ColormapNum = 0; vis->bInMirror = MirrorFlags & RF_XFLIP; vis->bSplitSprite = false; @@ -1110,7 +1110,8 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor // get light level if (fixedcolormap != NULL) { // fixed map - vis->Style.colormap = fixedcolormap; + vis->Style.BaseColormap = fixedcolormap; + vis->Style.ColormapNum = 0; } else { @@ -1120,17 +1121,19 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor } if (fixedlightlev >= 0) { - vis->Style.colormap = mybasecolormap->Maps + fixedlightlev; + vis->Style.BaseColormap = mybasecolormap->Maps; + vis->Style.ColormapNum = fixedlightlev >> COLORMAPSHIFT; } else if (!foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) { // full bright - vis->Style.colormap = mybasecolormap->Maps; + vis->Style.BaseColormap = mybasecolormap->Maps; + vis->Style.ColormapNum = 0; } else { // diminished light - vis->ColormapNum = GETPALOOKUP( + vis->Style.ColormapNum = GETPALOOKUP( r_SpriteVisibility / MAX(tz, MINZ), spriteshade); - vis->Style.colormap = mybasecolormap->Maps + (vis->ColormapNum << COLORMAPSHIFT); + vis->Style.BaseColormap = mybasecolormap->Maps; } } } @@ -1199,14 +1202,13 @@ static void R_ProjectWallSprite(AActor *thing, const DVector3 &pos, FTextureID p vis->Style.Alpha = float(thing->Alpha); vis->fakefloor = NULL; vis->fakeceiling = NULL; - vis->ColormapNum = 0; vis->bInMirror = MirrorFlags & RF_XFLIP; vis->pic = pic; vis->bIsVoxel = false; vis->bWallSprite = true; - vis->ColormapNum = GETPALOOKUP( + vis->Style.ColormapNum = GETPALOOKUP( r_SpriteVisibility / MAX(tz, MINZ), spriteshade); - vis->Style.colormap = basecolormap->Maps + (vis->ColormapNum << COLORMAPSHIFT); + vis->Style.BaseColormap = basecolormap->Maps; vis->wallc = wallc; } @@ -1376,7 +1378,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double vis->yscale = float(pspriteyscale / tex->Scale.Y); vis->Translation = 0; // [RH] Use default colors vis->pic = tex; - vis->ColormapNum = 0; + vis->Style.ColormapNum = 0; if (flip) { @@ -1426,7 +1428,8 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double if (realfixedcolormap != NULL) { // fixed color - vis->Style.colormap = realfixedcolormap->Colormap; + vis->Style.BaseColormap = realfixedcolormap->Colormap; + vis->Style.ColormapNum = 0; } else { @@ -1436,35 +1439,39 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double } if (fixedlightlev >= 0) { - vis->Style.colormap = mybasecolormap->Maps + fixedlightlev; + vis->Style.BaseColormap = mybasecolormap->Maps; + vis->Style.ColormapNum = fixedlightlev >> COLORMAPSHIFT; } else if (!foggy && psp->state->GetFullbright()) { // full bright - vis->Style.colormap = mybasecolormap->Maps; // [RH] use basecolormap + vis->Style.BaseColormap = mybasecolormap->Maps; // [RH] use basecolormap + vis->Style.ColormapNum = 0; } else { // local light - vis->Style.colormap = mybasecolormap->Maps + (GETPALOOKUP (0, spriteshade) << COLORMAPSHIFT); + vis->Style.BaseColormap = mybasecolormap->Maps; + vis->Style.ColormapNum = GETPALOOKUP(0, spriteshade); } } if (camera->Inventory != NULL) { - lighttable_t *oldcolormap = vis->Style.colormap; + BYTE oldcolormapnum = vis->Style.ColormapNum; + lighttable_t *oldcolormap = vis->Style.BaseColormap; camera->Inventory->AlterWeaponSprite (&vis->Style); - if (vis->Style.colormap != oldcolormap) + if (vis->Style.BaseColormap != oldcolormap || vis->Style.ColormapNum != oldcolormapnum) { // The colormap has changed. Is it one we can easily identify? // If not, then don't bother trying to identify it for // hardware accelerated drawing. - if (vis->Style.colormap < SpecialColormaps[0].Colormap || - vis->Style.colormap > SpecialColormaps.Last().Colormap) + if (vis->Style.BaseColormap < SpecialColormaps[0].Colormap || + vis->Style.BaseColormap > SpecialColormaps.Last().Colormap) { noaccel = true; } // Has the basecolormap changed? If so, we can't hardware accelerate it, // since we don't know what it is anymore. - else if (vis->Style.colormap < mybasecolormap->Maps || - vis->Style.colormap >= mybasecolormap->Maps + NUMCOLORMAPS*256) + else if (vis->Style.BaseColormap < mybasecolormap->Maps || + vis->Style.BaseColormap >= mybasecolormap->Maps + NUMCOLORMAPS*256) { noaccel = true; } @@ -1472,8 +1479,8 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double } // If we're drawing with a special colormap, but shaders for them are disabled, do // not accelerate. - if (!r_shadercolormaps && (vis->Style.colormap >= SpecialColormaps[0].Colormap && - vis->Style.colormap <= SpecialColormaps.Last().Colormap)) + if (!r_shadercolormaps && (vis->Style.BaseColormap >= SpecialColormaps[0].Colormap && + vis->Style.BaseColormap <= SpecialColormaps.Last().Colormap)) { noaccel = true; } @@ -1495,7 +1502,8 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double else { colormap_to_use = basecolormap; - vis->Style.colormap = basecolormap->Maps; + vis->Style.BaseColormap = basecolormap->Maps; + vis->Style.ColormapNum = 0; vis->Style.RenderStyle = STYLE_Normal; } @@ -1641,18 +1649,18 @@ void R_DrawRemainingPlayerSprites() FColormapStyle colormapstyle; bool usecolormapstyle = false; - if (vis->Style.colormap >= SpecialColormaps[0].Colormap && - vis->Style.colormap < SpecialColormaps[SpecialColormaps.Size()].Colormap) + if (vis->Style.BaseColormap >= SpecialColormaps[0].Colormap && + vis->Style.BaseColormap < SpecialColormaps[SpecialColormaps.Size()].Colormap) { // Yuck! There needs to be a better way to store colormaps in the vissprite... :( - ptrdiff_t specialmap = (vis->Style.colormap - SpecialColormaps[0].Colormap) / sizeof(FSpecialColormap); + ptrdiff_t specialmap = (vis->Style.BaseColormap - SpecialColormaps[0].Colormap) / sizeof(FSpecialColormap) + vis->Style.ColormapNum; special = &SpecialColormaps[specialmap]; } else if (colormap->Color == PalEntry(255,255,255) && colormap->Desaturate == 0) { overlay = colormap->Fade; - overlay.a = BYTE(((vis->Style.colormap - colormap->Maps) >> 8) * 255 / NUMCOLORMAPS); + overlay.a = BYTE(vis->Style.ColormapNum * 255 / NUMCOLORMAPS); } else { @@ -1660,7 +1668,7 @@ void R_DrawRemainingPlayerSprites() colormapstyle.Color = colormap->Color; colormapstyle.Fade = colormap->Fade; colormapstyle.Desaturate = colormap->Desaturate; - colormapstyle.FadeLevel = ((vis->Style.colormap - colormap->Maps) >> 8) / float(NUMCOLORMAPS); + colormapstyle.FadeLevel = vis->Style.ColormapNum / float(NUMCOLORMAPS); } screen->DrawTexture(vis->pic, viewwindowx + VisPSpritesX1[i], @@ -1904,7 +1912,8 @@ void R_DrawSprite (vissprite_t *spr) int r1, r2; short topclip, botclip; short *clip1, *clip2; - lighttable_t *colormap = spr->Style.colormap; + lighttable_t *colormap = spr->Style.BaseColormap; + int colormapnum = spr->Style.ColormapNum; F3DFloor *rover; FDynamicColormap *mybasecolormap; @@ -2001,17 +2010,19 @@ void R_DrawSprite (vissprite_t *spr) } if (fixedlightlev >= 0) { - spr->Style.colormap = mybasecolormap->Maps + fixedlightlev; + spr->Style.BaseColormap = mybasecolormap->Maps; + spr->Style.ColormapNum = fixedlightlev >> COLORMAPSHIFT; } else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) { // full bright - spr->Style.colormap = mybasecolormap->Maps; + spr->Style.BaseColormap = mybasecolormap->Maps; + spr->Style.ColormapNum = 0; } else { // diminished light spriteshade = LIGHT2SHADE(sec->lightlevel + r_actualextralight); - spr->Style.colormap = mybasecolormap->Maps + (GETPALOOKUP ( - r_SpriteVisibility / MAX(MINZ, (double)spr->depth), spriteshade) << COLORMAPSHIFT); + spr->Style.BaseColormap = mybasecolormap->Maps; + spr->Style.ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(MINZ, (double)spr->depth), spriteshade); } } } @@ -2159,7 +2170,8 @@ void R_DrawSprite (vissprite_t *spr) if (topclip >= botclip) { - spr->Style.colormap = colormap; + spr->Style.BaseColormap = colormap; + spr->Style.ColormapNum = colormapnum; return; } @@ -2289,7 +2301,8 @@ void R_DrawSprite (vissprite_t *spr) } if (i == x2) { - spr->Style.colormap = colormap; + spr->Style.BaseColormap = colormap; + spr->Style.ColormapNum = colormapnum; return; } } @@ -2307,7 +2320,8 @@ void R_DrawSprite (vissprite_t *spr) int maxvoxely = spr->gzb > hzb ? INT_MAX : xs_RoundToInt((spr->gzt - hzb) / spr->yscale); R_DrawVisVoxel(spr, minvoxely, maxvoxely, cliptop, clipbot); } - spr->Style.colormap = colormap; + spr->Style.BaseColormap = colormap; + spr->Style.ColormapNum = colormapnum; } // kg3D: @@ -2551,25 +2565,28 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, vis->renderflags = particle->trans; vis->FakeFlatStat = fakeside; vis->floorclip = 0; - vis->ColormapNum = 0; + vis->Style.ColormapNum = 0; if (fixedlightlev >= 0) { - vis->Style.colormap = map + fixedlightlev; + vis->Style.BaseColormap = map; + vis->Style.ColormapNum = fixedlightlev >> COLORMAPSHIFT; } else if (fixedcolormap) { - vis->Style.colormap = fixedcolormap; + vis->Style.BaseColormap = fixedcolormap; + vis->Style.ColormapNum = 0; } else if (particle->bright) { - vis->Style.colormap = map; + vis->Style.BaseColormap = map; + vis->Style.ColormapNum = 0; } else { // Particles are slightly more visible than regular sprites. - vis->ColormapNum = GETPALOOKUP(tiz * r_SpriteVisibility * 0.5, shade); - vis->Style.colormap = map + (vis->ColormapNum << COLORMAPSHIFT); + vis->Style.ColormapNum = GETPALOOKUP(tiz * r_SpriteVisibility * 0.5, shade); + vis->Style.BaseColormap = map; } } @@ -2602,7 +2619,7 @@ void R_DrawParticle_C (vissprite_t *vis) { int spacing; BYTE *dest; - BYTE color = vis->Style.colormap[vis->startfrac]; + BYTE color = vis->Style.BaseColormap[(vis->Style.ColormapNum << COLORMAPSHIFT) + vis->startfrac]; int yl = vis->y1; int ycount = vis->y2 - yl + 1; int x1 = vis->x1; @@ -2668,7 +2685,7 @@ void R_DrawParticle_RGBA(vissprite_t *vis) { int spacing; uint32_t *dest; - BYTE color = vis->Style.colormap[vis->startfrac]; + BYTE color = vis->Style.BaseColormap[vis->startfrac]; int yl = vis->y1; int ycount = vis->y2 - yl + 1; int x1 = vis->x1; @@ -2676,7 +2693,7 @@ void R_DrawParticle_RGBA(vissprite_t *vis) R_DrawMaskedSegsBehindParticle(vis); - uint32_t fg = shade_pal_index(color, calc_light_multiplier(0)); + uint32_t fg = shade_pal_index(color, calc_light_multiplier(LIGHTSCALE(0, vis->Style.ColormapNum << FRACBITS))); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; diff --git a/src/r_things.h b/src/r_things.h index 057b7cfe2..785729b09 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -86,7 +86,6 @@ struct vissprite_t BYTE bSplitSprite:1; // [RH] Sprite was split by a drawseg BYTE bInMirror:1; // [RH] Sprite is "inside" a mirror BYTE FakeFlatStat; // [RH] which side of fake/floor ceiling sprite is on - BYTE ColormapNum; // Which colormap is rendered (needed for shaded drawer) short renderflags; DWORD Translation; // [RH] for color translation visstyle_t Style; From 02a39ef4576204463474a71beef359848cac032d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 2 Jun 2016 20:05:08 +0200 Subject: [PATCH 0623/1509] Added bgra support to SDL target --- src/posix/sdl/sdlvideo.cpp | 46 ++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp index b050097be..26121aa71 100644 --- a/src/posix/sdl/sdlvideo.cpp +++ b/src/posix/sdl/sdlvideo.cpp @@ -28,7 +28,7 @@ class SDLFB : public DFrameBuffer { DECLARE_CLASS(SDLFB, DFrameBuffer) public: - SDLFB (int width, int height, bool fullscreen, SDL_Window *oldwin); + SDLFB (int width, int height, bool bgra, bool fullscreen, SDL_Window *oldwin); ~SDLFB (); bool Lock (bool buffer); @@ -271,7 +271,8 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer (int width, int height, bool bgra, boo { // Reuse the old framebuffer if its attributes are the same SDLFB *fb = static_cast (old); if (fb->Width == width && - fb->Height == height) + fb->Height == height && + fb->Bgra == bgra) { bool fsnow = (SDL_GetWindowFlags (fb->Screen) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0; @@ -296,7 +297,7 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer (int width, int height, bool bgra, boo flashAmount = 0; } - SDLFB *fb = new SDLFB (width, height, fullscreen, oldwin); + SDLFB *fb = new SDLFB (width, height, bgra, fullscreen, oldwin); // If we could not create the framebuffer, try again with slightly // different parameters in this order: @@ -350,8 +351,8 @@ void SDLVideo::SetWindowedScale (float scale) // FrameBuffer implementation ----------------------------------------------- -SDLFB::SDLFB (int width, int height, bool fullscreen, SDL_Window *oldwin) - : DFrameBuffer (width, height, false) +SDLFB::SDLFB (int width, int height, bool bgra, bool fullscreen, SDL_Window *oldwin) + : DFrameBuffer (width, height, bgra) { int i; @@ -494,7 +495,21 @@ void SDLFB::Update () pitch = Surface->pitch; } - if (NotPaletted) + if (Bgra) + { + if (pitch == Pitch * 4) + { + memcpy(pixels, MemBuffer, Width*Height*4); + } + else + { + for (int y = 0; y < Height; ++y) + { + memcpy((BYTE *)pixels + y*pitch, MemBuffer + y*Pitch*4, Width*4); + } + } + } + else if (NotPaletted) { GPfx.Convert (MemBuffer, Pitch, pixels, pitch, Width, Height, @@ -674,13 +689,20 @@ void SDLFB::ResetSDLRenderer () SDL_SetRenderDrawColor(Renderer, 0, 0, 0, 255); Uint32 fmt; - switch(vid_displaybits) + if (Bgra) { - default: fmt = SDL_PIXELFORMAT_ARGB8888; break; - case 30: fmt = SDL_PIXELFORMAT_ARGB2101010; break; - case 24: fmt = SDL_PIXELFORMAT_RGB888; break; - case 16: fmt = SDL_PIXELFORMAT_RGB565; break; - case 15: fmt = SDL_PIXELFORMAT_ARGB1555; break; + fmt = SDL_PIXELFORMAT_ARGB8888; + } + else + { + switch (vid_displaybits) + { + default: fmt = SDL_PIXELFORMAT_ARGB8888; break; + case 30: fmt = SDL_PIXELFORMAT_ARGB2101010; break; + case 24: fmt = SDL_PIXELFORMAT_RGB888; break; + case 16: fmt = SDL_PIXELFORMAT_RGB565; break; + case 15: fmt = SDL_PIXELFORMAT_ARGB1555; break; + } } Texture = SDL_CreateTexture (Renderer, fmt, SDL_TEXTUREACCESS_STREAMING, Width, Height); From 7142faf41d8cd250a19cd86af9becd0ae2d79e32 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 2 Jun 2016 21:39:44 +0200 Subject: [PATCH 0624/1509] Minor compile error fixes when X86_ASM is defined --- src/r_draw.cpp | 6 +++--- src/r_draw.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index c190c1e73..2c2c67ad6 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -3025,9 +3025,11 @@ extern "C" void R_DrawSlabC(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *v // wallscan stuff, in C +static int vlinebits; +static int mvlinebits; + #ifndef X86_ASM static DWORD vlinec1 (); -static int vlinebits; DWORD (*dovline1)() = vlinec1; DWORD (*doprevline1)() = vlinec1; @@ -3043,7 +3045,6 @@ void (*dovline4)() = vlinec4; static DWORD mvlinec1(); static void mvlinec4(); -static int mvlinebits; DWORD (*domvline1)() = mvlinec1; void (*domvline4)() = mvlinec4; @@ -4532,7 +4533,6 @@ void R_InitColumnDrawers () rt_tlateaddclamp1col = rt_tlateaddclamp1col_c; rt_tlatesubclamp1col = rt_tlatesubclamp1col_c; rt_tlaterevsubclamp1col = rt_tlaterevsubclamp1col_c; - rt_map4cols = rt_map4cols_c; rt_subclamp4cols = rt_subclamp4cols_c; rt_revsubclamp4cols = rt_revsubclamp4cols_c; rt_tlate4cols = rt_tlate4cols_c; diff --git a/src/r_draw.h b/src/r_draw.h index f60b2299e..fcaedff47 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -265,6 +265,8 @@ void R_DrawShadedColumnP_C (void); void R_DrawSpanP_C (void); void R_DrawSpanMaskedP_C (void); +#endif + void R_DrawColumnHorizP_RGBA_C (void); void R_DrawColumnP_RGBA_C (void); void R_DrawFuzzColumnP_RGBA_C (void); @@ -274,8 +276,6 @@ void R_DrawSpanP_RGBA_C (void); void R_DrawSpanP_RGBA_SSE (void); void R_DrawSpanMaskedP_RGBA_C (void); -#endif - void R_DrawSpanTranslucentP_C (void); void R_DrawSpanMaskedTranslucentP_C (void); From 6160675e080355f35206af2164306a29be3af4be Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 3 Jun 2016 12:42:08 +0200 Subject: [PATCH 0625/1509] Added a few more SSE drawers --- src/r_draw.cpp | 17 ++- src/r_draw.h | 4 + src/r_drawt_rgba.cpp | 273 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 289 insertions(+), 5 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 2c2c67ad6..aed4bbeea 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -4364,7 +4364,6 @@ void R_InitColumnDrawers () R_DrawTranslatedColumn = R_DrawTranslatedColumnP_RGBA_C; R_DrawShadedColumn = R_DrawShadedColumnP_RGBA_C; R_DrawSpanMasked = R_DrawSpanMaskedP_RGBA_C; - rt_map4cols = rt_map4cols_RGBA_c; #ifndef NO_SSE R_DrawSpan = R_DrawSpanP_RGBA_SSE; #else @@ -4409,9 +4408,6 @@ void R_InitColumnDrawers () rt_copy1col = rt_copy1col_RGBA_c; rt_copy4cols = rt_copy4cols_RGBA_c; rt_map1col = rt_map1col_RGBA_c; - rt_shaded4cols = rt_shaded4cols_RGBA_c; - rt_add4cols = rt_add4cols_RGBA_c; - rt_addclamp4cols = rt_addclamp4cols_RGBA_c; rt_shaded1col = rt_shaded1col_RGBA_c; rt_add1col = rt_add1col_RGBA_c; rt_addclamp1col = rt_addclamp1col_RGBA_c; @@ -4422,7 +4418,6 @@ void R_InitColumnDrawers () rt_tlateaddclamp1col = rt_tlateaddclamp1col_RGBA_c; rt_tlatesubclamp1col = rt_tlatesubclamp1col_RGBA_c; rt_tlaterevsubclamp1col = rt_tlaterevsubclamp1col_RGBA_c; - rt_map4cols = rt_map4cols_RGBA_c; rt_subclamp4cols = rt_subclamp4cols_RGBA_c; rt_revsubclamp4cols = rt_revsubclamp4cols_RGBA_c; rt_tlate4cols = rt_tlate4cols_RGBA_c; @@ -4432,6 +4427,18 @@ void R_InitColumnDrawers () rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_RGBA_c; rt_initcols = rt_initcols_rgba; +#ifndef NO_SSE + rt_map4cols = rt_map4cols_RGBA_SSE; + rt_add4cols = rt_add4cols_RGBA_SSE; + rt_addclamp4cols = rt_addclamp4cols_RGBA_SSE; + rt_shaded4cols = rt_shaded4cols_RGBA_SSE; +#else + rt_map4cols = rt_map4cols_RGBA_c; + rt_add4cols = rt_add4cols_RGBA_c; + rt_addclamp4cols = rt_addclamp4cols_RGBA_c; + rt_shaded4cols = rt_shaded4cols_RGBA_c; +#endif + dovline1 = vlinec1_RGBA; doprevline1 = vlinec1_RGBA; domvline1 = mvlinec1_RGBA; diff --git a/src/r_draw.h b/src/r_draw.h index fcaedff47..27a985dcb 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -173,6 +173,7 @@ void rt_copy4cols_RGBA_c (int sx, int yl, int yh); void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh); void rt_shaded4cols_RGBA_c (int sx, int yl, int yh); +void rt_shaded4cols_RGBA_SSE (int sx, int yl, int yh); void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh); void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh); @@ -187,8 +188,11 @@ void rt_tlatesubclamp1col_RGBA_c (int hx, int sx, int yl, int yh); void rt_tlaterevsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh); void rt_map4cols_RGBA_c (int sx, int yl, int yh); +void rt_map4cols_RGBA_SSE (int sx, int yl, int yh); void rt_add4cols_RGBA_c (int sx, int yl, int yh); +void rt_add4cols_RGBA_SSE (int sx, int yl, int yh); void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh); +void rt_addclamp4cols_RGBA_SSE (int sx, int yl, int yh); void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh); void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh); diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 60520783d..d390fc54d 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -42,6 +42,9 @@ #include "r_main.h" #include "r_things.h" #include "v_video.h" +#ifndef NO_SSE +#include +#endif uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT*4]; uint32_t *dc_temp_rgba; @@ -185,6 +188,98 @@ void rt_map4cols_RGBA_c (int sx, int yl, int yh) } while (--count); } +// Maps all four spans to the screen starting at sx. +void rt_map4cols_RGBA_SSE(int sx, int yl, int yh) +{ + BYTE *colormap; + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + uint32_t light = calc_light_multiplier(dc_light); + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + + colormap = dc_colormap; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &dc_temp_rgba[yl * 4]; + pitch = dc_pitch; + + __m128i mlight = _mm_set_epi16(256, light, light, light, 256, light, light, light); + + if (count & 1) { + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + fg_hi = _mm_mullo_epi16(fg_hi, mlight); + fg_hi = _mm_srli_epi16(fg_hi, 8); + fg_lo = _mm_mullo_epi16(fg_lo, mlight); + fg_lo = _mm_srli_epi16(fg_lo, 8); + + fg = _mm_packus_epi16(fg_lo, fg_hi); + _mm_storeu_si128((__m128i*)dest, fg); + + source += 4; + dest += pitch; + } + if (!(count >>= 1)) + return; + + do { + // shade_pal_index 0-3 + { + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + fg_hi = _mm_mullo_epi16(fg_hi, mlight); + fg_hi = _mm_srli_epi16(fg_hi, 8); + fg_lo = _mm_mullo_epi16(fg_lo, mlight); + fg_lo = _mm_srli_epi16(fg_lo, 8); + + fg = _mm_packus_epi16(fg_lo, fg_hi); + _mm_storeu_si128((__m128i*)dest, fg); + } + + // shade_pal_index 4-7 (pitch) + { + uint32_t p0 = colormap[source[4]]; + uint32_t p1 = colormap[source[5]]; + uint32_t p2 = colormap[source[6]]; + uint32_t p3 = colormap[source[7]]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + fg_hi = _mm_mullo_epi16(fg_hi, mlight); + fg_hi = _mm_srli_epi16(fg_hi, 8); + fg_lo = _mm_mullo_epi16(fg_lo, mlight); + fg_lo = _mm_srli_epi16(fg_lo, 8); + + fg = _mm_packus_epi16(fg_lo, fg_hi); + _mm_storeu_si128((__m128i*)(dest + pitch), fg); + } + + source += 8; + dest += pitch * 2; + } while (--count); +} + void rt_Translate1col_RGBA_c(const BYTE *translation, int hx, int yl, int yh) { int count = yh - yl + 1; @@ -380,6 +475,69 @@ void rt_add4cols_RGBA_c (int sx, int yl, int yh) } while (--count); } +// Adds all four spans to the screen starting at sx without clamping. +#ifndef NO_SSE +void rt_add4cols_RGBA_SSE(int sx, int yl, int yh) +{ + BYTE *colormap; + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &dc_temp_rgba[yl * 4]; + pitch = dc_pitch; + colormap = dc_colormap; + + uint32_t light = calc_light_multiplier(dc_light); + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + __m128i mlight = _mm_set_epi16(256, light, light, light, 256, light, light, light); + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + fg_hi = _mm_mullo_epi16(fg_hi, mlight); + fg_hi = _mm_srli_epi16(fg_hi, 8); + fg_lo = _mm_mullo_epi16(fg_lo, mlight); + fg_lo = _mm_srli_epi16(fg_lo, 8); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += 4; + dest += pitch; + } while (--count); +} +#endif + // Translates and adds one span at hx to the screen at sx without clamping. void rt_tlateadd1col_RGBA_c (int hx, int sx, int yl, int yh) { @@ -481,6 +639,58 @@ void rt_shaded4cols_RGBA_c (int sx, int yl, int yh) } while (--count); } +// Shades all four spans to the screen starting at sx. +#ifndef NO_SSE +void rt_shaded4cols_RGBA_SSE(int sx, int yl, int yh) +{ + BYTE *colormap; + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + colormap = dc_colormap; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &dc_temp_rgba[yl * 4]; + pitch = dc_pitch; + + __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(shade_pal_index(dc_color, calc_light_multiplier(dc_light))), _mm_setzero_si128()); + __m128i alpha_one = _mm_set1_epi16(64); + + do { + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; + + __m128i alpha_hi = _mm_set_epi16(64, p3, p3, p3, 64, p2, p2, p2); + __m128i alpha_lo = _mm_set_epi16(64, p1, p1, p1, 64, p0, p0, p0); + __m128i inv_alpha_hi = _mm_subs_epu16(alpha_one, alpha_hi); + __m128i inv_alpha_lo = _mm_subs_epu16(alpha_one, alpha_lo); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * alpha + bg_red * inv_alpha) / 64: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg, alpha_hi), _mm_mullo_epi16(bg_hi, inv_alpha_hi)), 6); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg, alpha_lo), _mm_mullo_epi16(bg_lo, inv_alpha_lo)), 6); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += 4; + dest += pitch; + } while (--count); +} +#endif + // Adds one span at hx to the screen at sx with clamping. void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh) { @@ -572,6 +782,69 @@ void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh) } while (--count); } +// Adds all four spans to the screen starting at sx with clamping. +#ifndef NO_SSE +void rt_addclamp4cols_RGBA_SSE(int sx, int yl, int yh) +{ + BYTE *colormap; + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &dc_temp_rgba[yl * 4]; + pitch = dc_pitch; + colormap = dc_colormap; + + uint32_t light = calc_light_multiplier(dc_light); + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + __m128i mlight = _mm_set_epi16(256, light, light, light, 256, light, light, light); + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + fg_hi = _mm_mullo_epi16(fg_hi, mlight); + fg_hi = _mm_srli_epi16(fg_hi, 8); + fg_lo = _mm_mullo_epi16(fg_lo, mlight); + fg_lo = _mm_srli_epi16(fg_lo, 8); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += 4; + dest += pitch; + } while (--count); +} +#endif + // Translates and adds one span at hx to the screen at sx with clamping. void rt_tlateaddclamp1col_RGBA_c (int hx, int sx, int yl, int yh) { From 373b59b94fa93b78527c50a0af9aea84e09a569b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 3 Jun 2016 14:06:44 +0200 Subject: [PATCH 0626/1509] Fix dovline4 being a define on X64_ASM --- src/r_draw.cpp | 2 +- src/r_draw.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index aed4bbeea..ccaa864e6 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -3036,8 +3036,8 @@ DWORD (*doprevline1)() = vlinec1; #ifdef X64_ASM extern "C" void vlinetallasm4(); -#define dovline4 vlinetallasm4 extern "C" void setupvlinetallasm (int); +void (*dovline4)() = vlinetallasm4; #else static void vlinec4 (); void (*dovline4)() = vlinec4; diff --git a/src/r_draw.h b/src/r_draw.h index 27a985dcb..2eefff9bd 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -71,12 +71,7 @@ extern void (*R_DrawColumn)(void); extern DWORD (*dovline1) (); extern DWORD (*doprevline1) (); -#ifdef X64_ASM -#define dovline4 vlinetallasm4 -extern "C" void vlinetallasm4(); -#else extern void (*dovline4) (); -#endif extern void setupvline (int); extern DWORD (*domvline1) (); From af02bafdeb4a96e091f6ff8608d3d82278bf7c3e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 3 Jun 2016 22:57:36 +0200 Subject: [PATCH 0627/1509] Fixed missing some columns in transparency rendering --- src/r_draw.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index ccaa864e6..ec0645fd2 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -952,12 +952,14 @@ void R_DrawAddColumnP_RGBA_C() int pitch = dc_pitch; BYTE *colormap = dc_colormap; + uint32_t light = calc_light_multiplier(dc_light); + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], 0); + uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; From 56ce6abbc211724f66d1bfaba336ab71f597b03a Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 5 Jun 2016 12:38:23 +0300 Subject: [PATCH 0628/1509] Fixed splitting of walls in compatibility renderer Any wall adjacent to 3D floor sector were not rendered at all --- src/gl/scene/gl_walls.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index edd85e1df..1abbb2e5f 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -395,25 +395,25 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) continue; } - if (gl.glslversion >= 1.3f) + // check for an intersection with the upper and lower planes of the wall segment + if ((maplightbottomleftztop[1]) || + (maplightbottomleft > ztop[0] && maplightbottomright < ztop[1]) || + (maplightbottomleftzbottom[1]) || + (maplightbottomleft > zbottom[0] && maplightbottomright < zbottom[1])) { - // check for an intersection with the upper and lower planes of the wall segment - if ((maplightbottomleftztop[1]) || - (maplightbottomleft > ztop[0] && maplightbottomright < ztop[1]) || - (maplightbottomleftzbottom[1]) || - (maplightbottomleft > zbottom[0] && maplightbottomright < zbottom[1])) + if (gl.glslversion >= 1.3f) { // Use hardware clipping if this cannot be done cleanly. this->lightlist = &lightlist; PutWall(translucent); - goto out; } - } - else - { - // crappy fallback if no clip planes available - SplitWallComplex(frontsector, translucent, maplightbottomleft, maplightbottomright); - return; + else + { + // crappy fallback if no clip planes available + SplitWallComplex(frontsector, translucent, maplightbottomleft, maplightbottomright); + } + + goto out; } // 3D floor is completely within this light From 0c8c9e0aeace39987a44183ff16670e5ea967007 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 5 Jun 2016 14:08:03 +0200 Subject: [PATCH 0629/1509] Added FDynamicColormap support to true color mode --- src/g_level.cpp | 2 +- src/g_shared/a_artifacts.cpp | 2 +- src/r_data/colormaps.cpp | 20 +- src/r_data/colormaps.h | 25 +- src/r_defs.h | 3 +- src/r_draw.cpp | 592 ++++++++++++++++++++++++----------- src/r_draw.h | 19 +- src/r_drawt_rgba.cpp | 427 +++++++++++++++---------- src/r_main.cpp | 8 +- src/r_main.h | 141 ++++++++- src/r_plane.cpp | 12 +- src/r_segs.cpp | 45 ++- src/r_swrenderer.cpp | 2 +- src/r_things.cpp | 79 +++-- src/r_utility.cpp | 4 +- src/v_draw.cpp | 13 +- 16 files changed, 937 insertions(+), 457 deletions(-) diff --git a/src/g_level.cpp b/src/g_level.cpp index 141932c22..d27747ccb 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1307,7 +1307,7 @@ void G_InitLevelLocals () level_info_t *info; BaseBlendA = 0.0f; // Remove underwater blend effect, if any - NormalLight.Maps = realcolormaps; + NormalLight.Maps = realcolormaps.Maps; // [BB] Instead of just setting the color, we also have to reset Desaturate and build the lights. NormalLight.ChangeColor (PalEntry (255, 255, 255), 0); diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 777d6824a..305260ebf 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -737,7 +737,7 @@ int APowerInvisibility::AlterWeaponSprite (visstyle_t *vis) if ((vis->Alpha < 0.25f && special1 > 0) || (vis->Alpha == 0)) { vis->Alpha = clamp((1.f - float(Strength/100)), 0.f, 1.f); - vis->BaseColormap = SpecialColormaps[INVERSECOLORMAP].Colormap; + vis->BaseColormap = &SpecialColormaps[INVERSECOLORMAP]; vis->ColormapNum = 0; } return -1; // This item is valid so another one shouldn't reset the translucency diff --git a/src/r_data/colormaps.cpp b/src/r_data/colormaps.cpp index b46342463..ffaaa38ac 100644 --- a/src/r_data/colormaps.cpp +++ b/src/r_data/colormaps.cpp @@ -71,7 +71,7 @@ struct FakeCmap }; TArray fakecmaps; -BYTE *realcolormaps; +FColormap realcolormaps; size_t numfakecmaps; @@ -408,7 +408,7 @@ void R_SetDefaultColormap (const char *name) foo.Color = 0xFFFFFF; foo.Fade = 0; - foo.Maps = realcolormaps; + foo.Maps = realcolormaps.Maps; foo.Desaturate = 0; foo.Next = NULL; foo.BuildLights (); @@ -430,7 +430,7 @@ void R_SetDefaultColormap (const char *name) remap[0] = 0; for (i = 0; i < NUMCOLORMAPS; ++i) { - BYTE *map2 = &realcolormaps[i*256]; + BYTE *map2 = &realcolormaps.Maps[i*256]; lumpr.Read (map, 256); for (j = 0; j < 256; ++j) { @@ -454,11 +454,7 @@ void R_DeinitColormaps () { SpecialColormaps.Clear(); fakecmaps.Clear(); - if (realcolormaps != NULL) - { - delete[] realcolormaps; - realcolormaps = NULL; - } + delete[] realcolormaps.Maps; FreeSpecialLights(); } @@ -501,7 +497,7 @@ void R_InitColormaps () } } } - realcolormaps = new BYTE[256*NUMCOLORMAPS*fakecmaps.Size()]; + realcolormaps.Maps = new BYTE[256*NUMCOLORMAPS*fakecmaps.Size()]; R_SetDefaultColormap ("COLORMAP"); if (fakecmaps.Size() > 1) @@ -523,7 +519,7 @@ void R_InitColormaps () { int k, r, g, b; FWadLump lump = Wads.OpenLumpNum (fakecmaps[j].lump); - BYTE *const map = realcolormaps + NUMCOLORMAPS*256*j; + BYTE *const map = realcolormaps.Maps + NUMCOLORMAPS*256*j; for (k = 0; k < NUMCOLORMAPS; ++k) { @@ -550,8 +546,8 @@ void R_InitColormaps () } NormalLight.Color = PalEntry (255, 255, 255); NormalLight.Fade = 0; - NormalLight.Maps = realcolormaps; - NormalLightHasFixedLights = R_CheckForFixedLights(realcolormaps); + NormalLight.Maps = realcolormaps.Maps; + NormalLightHasFixedLights = R_CheckForFixedLights(realcolormaps.Maps); numfakecmaps = fakecmaps.Size(); // build default special maps (e.g. invulnerability) diff --git a/src/r_data/colormaps.h b/src/r_data/colormaps.h index 0764191a3..bda6a5ea4 100644 --- a/src/r_data/colormaps.h +++ b/src/r_data/colormaps.h @@ -1,18 +1,26 @@ #ifndef __RES_CMAP_H #define __RES_CMAP_H +struct FColormap; + void R_InitColormaps (); void R_DeinitColormaps (); DWORD R_ColormapNumForName(const char *name); // killough 4/4/98 void R_SetDefaultColormap (const char *name); // [RH] change normal fadetable DWORD R_BlendForColormap (DWORD map); // [RH] return calculated blend for a colormap -extern BYTE *realcolormaps; // [RH] make the colormaps externally visible +extern FColormap realcolormaps; // [RH] make the colormaps externally visible extern size_t numfakecmaps; +struct FColormap +{ + BYTE *Maps = nullptr; + PalEntry Color = 0xffffffff; + PalEntry Fade = 0xff000000; + int Desaturate = 0; +}; - -struct FDynamicColormap +struct FDynamicColormap : FColormap { void ChangeFade (PalEntry fadecolor); void ChangeColor (PalEntry lightcolor, int desaturate); @@ -20,10 +28,6 @@ struct FDynamicColormap void BuildLights (); static void RebuildAllLights(); - BYTE *Maps; - PalEntry Color; - PalEntry Fade; - int Desaturate; FDynamicColormap *Next; }; @@ -43,8 +47,13 @@ enum }; -struct FSpecialColormap +struct FSpecialColormap : FColormap { + FSpecialColormap() + { + Maps = Colormap; + } + float ColorizeStart[3]; float ColorizeEnd[3]; BYTE Colormap[256]; diff --git a/src/r_defs.h b/src/r_defs.h index 8a247a5c0..c0f878664 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1397,12 +1397,13 @@ struct FMiniBSP // typedef BYTE lighttable_t; // This could be wider for >8 bit display. +struct FColormap; // This encapsulates the fields of vissprite_t that can be altered by AlterWeaponSprite struct visstyle_t { int ColormapNum; // Which colormap is rendered - lighttable_t *BaseColormap; // Base colormap used together with ColormapNum + FColormap *BaseColormap; // Base colormap used together with ColormapNum float Alpha; FRenderStyle RenderStyle; }; diff --git a/src/r_draw.cpp b/src/r_draw.cpp index ec0645fd2..2e21c7038 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -145,6 +145,8 @@ extern "C" { int dc_pitch=0xABadCafe; // [RH] Distance between rows lighttable_t* dc_colormap; +FColormap *dc_fcolormap; +ShadeConstants dc_shade_constants; fixed_t dc_light; int dc_x; int dc_yl; @@ -179,6 +181,7 @@ BYTE *dc_translation; BYTE shadetables[NUMCOLORMAPS*16*256]; FDynamicColormap ShadeFakeColormap[16]; BYTE identitymap[256]; +FDynamicColormap identitycolormap; EXTERN_CVAR (Int, r_columnmethod) @@ -219,6 +222,10 @@ void R_InitShadeMaps() { identitymap[i] = i; } + identitycolormap.Color = ~0u; + identitycolormap.Desaturate = 0; + identitycolormap.Next = NULL; + identitycolormap.Maps = identitymap; } /************************************/ @@ -297,6 +304,7 @@ void R_DrawColumnP_RGBA_C() dest = (uint32_t*)dc_dest; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; // Determine scaling, // which is the only mapping to be done. @@ -315,9 +323,7 @@ void R_DrawColumnP_RGBA_C() // This is as fast as it gets. do { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - *dest = shade_pal_index(colormap[source[frac >> FRACBITS]], light); + *dest = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); dest += pitch; frac += fracstep; @@ -371,7 +377,7 @@ void R_FillColumnP_RGBA() do { - *dest = shade_pal_index(color, light); + *dest = shade_pal_index_simple(color, light); dest += pitch; } while (--count); } @@ -416,7 +422,7 @@ void R_FillAddColumn_RGBA_C() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -481,7 +487,7 @@ void R_FillAddClampColumn_RGBA() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -545,7 +551,7 @@ void R_FillSubClampColumn_RGBA() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -609,7 +615,7 @@ void R_FillRevSubClampColumn_RGBA() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -953,13 +959,14 @@ void R_DrawAddColumnP_RGBA_C() BYTE *colormap = dc_colormap; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light); + uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; @@ -1032,6 +1039,7 @@ void R_DrawTranslatedColumnP_RGBA_C() return; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; dest = (uint32_t*)dc_dest; @@ -1040,14 +1048,13 @@ void R_DrawTranslatedColumnP_RGBA_C() { // [RH] Local copies of global vars to improve compiler optimizations - BYTE *colormap = dc_colormap; BYTE *translation = dc_translation; const BYTE *source = dc_source; int pitch = dc_pitch; do { - *dest = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); + *dest = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); dest += pitch; frac += fracstep; } while (--count); @@ -1106,6 +1113,7 @@ void R_DrawTlatedAddColumnP_RGBA_C() return; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; dest = (uint32_t*)dc_dest; @@ -1114,7 +1122,6 @@ void R_DrawTlatedAddColumnP_RGBA_C() { BYTE *translation = dc_translation; - BYTE *colormap = dc_colormap; const BYTE *source = dc_source; int pitch = dc_pitch; @@ -1123,7 +1130,7 @@ void R_DrawTlatedAddColumnP_RGBA_C() do { - uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); + uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; @@ -1197,7 +1204,7 @@ void R_DrawShadedColumnP_RGBA_C() fracstep = dc_iscale; frac = dc_texturefrac; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -1286,16 +1293,16 @@ void R_DrawAddClampColumnP_RGBA_C() { const BYTE *source = dc_source; - BYTE *colormap = dc_colormap; int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light); + uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -1375,17 +1382,17 @@ void R_DrawAddClampTranslatedColumnP_RGBA_C() { BYTE *translation = dc_translation; - BYTE *colormap = dc_colormap; const BYTE *source = dc_source; int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); + uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -1462,17 +1469,17 @@ void R_DrawSubClampColumnP_RGBA_C() frac = dc_texturefrac; { - BYTE *colormap = dc_colormap; const BYTE *source = dc_source; int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light); + uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -1551,17 +1558,17 @@ void R_DrawSubClampTranslatedColumnP_RGBA_C() { BYTE *translation = dc_translation; - BYTE *colormap = dc_colormap; const BYTE *source = dc_source; int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); + uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -1638,16 +1645,16 @@ void R_DrawRevSubClampColumnP_RGBA_C() frac = dc_texturefrac; { - BYTE *colormap = dc_colormap; const BYTE *source = dc_source; int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light); + uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -1726,17 +1733,17 @@ void R_DrawRevSubClampTranslatedColumnP_RGBA_C() { BYTE *translation = dc_translation; - BYTE *colormap = dc_colormap; const BYTE *source = dc_source; int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(colormap[translation[source[frac >> FRACBITS]]], light); + uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -1784,8 +1791,10 @@ int ds_y; int ds_x1; int ds_x2; +FColormap* ds_fcolormap; lighttable_t* ds_colormap; -//dsfixed_t ds_light; +ShadeConstants ds_shade_constants; +dsfixed_t ds_light; dsfixed_t ds_xfrac; dsfixed_t ds_yfrac; @@ -1835,9 +1844,9 @@ void R_SetSpanSource(const BYTE *pixels) // //========================================================================== -void R_SetSpanColormap(BYTE *colormap) +void R_SetSpanColormap(FDynamicColormap *colormap, int shade) { - R_SetDSColorMapLight(colormap, 0, 0); + R_SetDSColorMapLight(colormap, 0, shade); #ifdef X86_ASM if (!r_swtruecolor && ds_colormap != ds_curcolormap) { @@ -1956,7 +1965,6 @@ void R_DrawSpanP_RGBA_C() dsfixed_t ystep; uint32_t* dest; const BYTE* source = ds_source; - const BYTE* colormap = ds_colormap; int count; int spot; @@ -1980,6 +1988,7 @@ void R_DrawSpanP_RGBA_C() ystep = ds_ystep; uint32_t light = calc_light_multiplier(ds_light); + ShadeConstants shade_constants = ds_shade_constants; if (ds_xbits == 6 && ds_ybits == 6) { @@ -1990,9 +1999,8 @@ void R_DrawSpanP_RGBA_C() // Current texture index in u,v. spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - *dest++ = shade_pal_index(colormap[source[spot]], light); + // Lookup pixel from flat texture tile + *dest++ = shade_pal_index(source[spot], light, shade_constants); // Next step in u,v. xfrac += xstep; @@ -2010,9 +2018,8 @@ void R_DrawSpanP_RGBA_C() // Current texture index in u,v. spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - *dest++ = shade_pal_index(colormap[source[spot]], light); + // Lookup pixel from flat texture tile + *dest++ = shade_pal_index(source[spot], light, shade_constants); // Next step in u,v. xfrac += xstep; @@ -2030,7 +2037,6 @@ void R_DrawSpanP_RGBA_SSE() dsfixed_t ystep; uint32_t* dest; const BYTE* source = ds_source; - const BYTE* colormap = ds_colormap; int count; int spot; @@ -2054,54 +2060,92 @@ void R_DrawSpanP_RGBA_SSE() ystep = ds_ystep; uint32_t light = calc_light_multiplier(ds_light); + ShadeConstants shade_constants = ds_shade_constants; if (ds_xbits == 6 && ds_ybits == 6) { // 64x64 is the most common case by far, so special case it. - __m128i mlight = _mm_set_epi16(256, light, light, light, 256, light, light, light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; int sse_count = count / 4; count -= sse_count * 4; - while (sse_count--) + + if (shade_constants.simple_shade) { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p0 = colormap[source[spot]]; - xfrac += xstep; - yfrac += ystep; + SSE_SHADE_SIMPLE_INIT(light); - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p1 = colormap[source[spot]]; - xfrac += xstep; - yfrac += ystep; + while (sse_count--) + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p0 = source[spot]; + xfrac += xstep; + yfrac += ystep; - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p2 = colormap[source[spot]]; - xfrac += xstep; - yfrac += ystep; + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p1 = source[spot]; + xfrac += xstep; + yfrac += ystep; - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p3 = colormap[source[spot]]; - xfrac += xstep; - yfrac += ystep; + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p2 = source[spot]; + xfrac += xstep; + yfrac += ystep; - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - fg_hi = _mm_mullo_epi16(fg_hi, mlight); - fg_hi = _mm_srli_epi16(fg_hi, 8); - fg_lo = _mm_mullo_epi16(fg_lo, mlight); - fg_lo = _mm_srli_epi16(fg_lo, 8); - fg = _mm_packus_epi16(fg_lo, fg_hi); - _mm_storeu_si128((__m128i*)dest, fg); + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p3 = source[spot]; + xfrac += xstep; + yfrac += ystep; - // Next step in u,v. - dest += 4; + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + + // Next step in u,v. + dest += 4; + } } + else + { + SSE_SHADE_INIT(light, shade_constants); + + while (sse_count--) + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p0 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p1 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p2 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p3 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + + // Next step in u,v. + dest += 4; + } + } + if (count == 0) return; @@ -2110,9 +2154,8 @@ void R_DrawSpanP_RGBA_SSE() // Current texture index in u,v. spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - *dest++ = shade_pal_index(colormap[source[spot]], light); + // Lookup pixel from flat texture tile + *dest++ = shade_pal_index(source[spot], light, shade_constants); // Next step in u,v. xfrac += xstep; @@ -2130,9 +2173,8 @@ void R_DrawSpanP_RGBA_SSE() // Current texture index in u,v. spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - *dest++ = shade_pal_index(colormap[source[spot]], light); + // Lookup pixel from flat texture tile + *dest++ = shade_pal_index(source[spot], light, shade_constants); // Next step in u,v. xfrac += xstep; @@ -2221,6 +2263,7 @@ void R_DrawSpanMaskedP_RGBA_C() int spot; uint32_t light = calc_light_multiplier(ds_light); + ShadeConstants shade_constants = ds_shade_constants; xfrac = ds_xfrac; yfrac = ds_yfrac; @@ -2243,7 +2286,7 @@ void R_DrawSpanMaskedP_RGBA_C() texdata = source[spot]; if (texdata != 0) { - *dest = shade_pal_index(colormap[texdata], light); + *dest = shade_pal_index(texdata, light, shade_constants); } dest++; xfrac += xstep; @@ -2263,7 +2306,7 @@ void R_DrawSpanMaskedP_RGBA_C() texdata = source[spot]; if (texdata != 0) { - *dest = shade_pal_index(colormap[texdata], light); + *dest = shade_pal_index(texdata, light, shade_constants); } dest++; xfrac += xstep; @@ -2343,7 +2386,6 @@ void R_DrawSpanTranslucentP_RGBA_C() dsfixed_t ystep; uint32_t* dest; const BYTE* source = ds_source; - const BYTE* colormap = ds_colormap; int count; int spot; @@ -2358,6 +2400,7 @@ void R_DrawSpanTranslucentP_RGBA_C() ystep = ds_ystep; uint32_t light = calc_light_multiplier(ds_light); + ShadeConstants shade_constants = ds_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -2369,7 +2412,7 @@ void R_DrawSpanTranslucentP_RGBA_C() { spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t fg = shade_pal_index(colormap[source[spot]], light); + uint32_t fg = shade_pal_index(source[spot], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -2397,7 +2440,7 @@ void R_DrawSpanTranslucentP_RGBA_C() { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t fg = shade_pal_index(colormap[source[spot]], light); + uint32_t fg = shade_pal_index(source[spot], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -2502,11 +2545,11 @@ void R_DrawSpanMaskedTranslucentP_RGBA_C() dsfixed_t ystep; uint32_t* dest; const BYTE* source = ds_source; - const BYTE* colormap = ds_colormap; int count; int spot; uint32_t light = calc_light_multiplier(ds_light); + ShadeConstants shade_constants = ds_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -2532,7 +2575,7 @@ void R_DrawSpanMaskedTranslucentP_RGBA_C() texdata = source[spot]; if (texdata != 0) { - uint32_t fg = shade_pal_index(colormap[texdata], light); + uint32_t fg = shade_pal_index(texdata, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -2565,7 +2608,7 @@ void R_DrawSpanMaskedTranslucentP_RGBA_C() texdata = source[spot]; if (texdata != 0) { - uint32_t fg = shade_pal_index(colormap[texdata], light); + uint32_t fg = shade_pal_index(texdata, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -2665,11 +2708,11 @@ void R_DrawSpanAddClampP_RGBA_C() dsfixed_t ystep; uint32_t* dest; const BYTE* source = ds_source; - const BYTE* colormap = ds_colormap; int count; int spot; uint32_t light = calc_light_multiplier(ds_light); + ShadeConstants shade_constants = ds_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -2691,7 +2734,7 @@ void R_DrawSpanAddClampP_RGBA_C() { spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t fg = shade_pal_index(colormap[source[spot]], light); + uint32_t fg = shade_pal_index(source[spot], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -2719,7 +2762,7 @@ void R_DrawSpanAddClampP_RGBA_C() { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t fg = shade_pal_index(colormap[source[spot]], light); + uint32_t fg = shade_pal_index(source[spot], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -2830,11 +2873,11 @@ void R_DrawSpanMaskedAddClampP_RGBA_C() dsfixed_t ystep; uint32_t* dest; const BYTE* source = ds_source; - const BYTE* colormap = ds_colormap; int count; int spot; uint32_t light = calc_light_multiplier(ds_light); + ShadeConstants shade_constants = ds_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -2860,7 +2903,7 @@ void R_DrawSpanMaskedAddClampP_RGBA_C() texdata = source[spot]; if (texdata != 0) { - uint32_t fg = shade_pal_index(colormap[texdata], light); + uint32_t fg = shade_pal_index(texdata, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -2893,7 +2936,7 @@ void R_DrawSpanMaskedAddClampP_RGBA_C() texdata = source[spot]; if (texdata != 0) { - uint32_t fg = shade_pal_index(colormap[texdata], light); + uint32_t fg = shade_pal_index(texdata, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -2926,7 +2969,7 @@ void R_FillSpan_RGBA() uint32_t *dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; int count = (ds_x2 - ds_x1 + 1); uint32_t light = calc_light_multiplier(ds_light); - uint32_t color = shade_pal_index(ds_color, light); + uint32_t color = shade_pal_index_simple(ds_color, light); for (int i = 0; i < count; i++) dest[i] = color; } @@ -3147,7 +3190,6 @@ DWORD vlinec1_RGBA() { DWORD fracstep = dc_iscale; DWORD frac = dc_texturefrac; - BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; uint32_t *dest = (uint32_t*)dc_dest; @@ -3155,10 +3197,11 @@ DWORD vlinec1_RGBA() int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; do { - *dest = shade_pal_index(colormap[source[frac >> bits]], light); + *dest = shade_pal_index(source[frac >> bits], light, shade_constants); frac += fracstep; dest += pitch; } while (--count); @@ -3197,12 +3240,14 @@ void vlinec4_RGBA() uint32_t light2 = calc_light_multiplier(palookuplight[2]); uint32_t light3 = calc_light_multiplier(palookuplight[3]); + ShadeConstants shade_constants = dc_shade_constants; + do { - dest[0] = shade_pal_index(palookupoffse[0][bufplce[0][(place = vplce[0]) >> bits]], light0); vplce[0] = place + vince[0]; - dest[1] = shade_pal_index(palookupoffse[1][bufplce[1][(place = vplce[1]) >> bits]], light1); vplce[1] = place + vince[1]; - dest[2] = shade_pal_index(palookupoffse[2][bufplce[2][(place = vplce[2]) >> bits]], light2); vplce[2] = place + vince[2]; - dest[3] = shade_pal_index(palookupoffse[3][bufplce[3][(place = vplce[3]) >> bits]], light3); vplce[3] = place + vince[3]; + dest[0] = shade_pal_index(bufplce[0][(place = vplce[0]) >> bits], light0, shade_constants); vplce[0] = place + vince[0]; + dest[1] = shade_pal_index(bufplce[1][(place = vplce[1]) >> bits], light1, shade_constants); vplce[1] = place + vince[1]; + dest[2] = shade_pal_index(bufplce[2][(place = vplce[2]) >> bits], light2, shade_constants); vplce[2] = place + vince[2]; + dest[3] = shade_pal_index(bufplce[3][(place = vplce[3]) >> bits], light3, shade_constants); vplce[3] = place + vince[3]; dest += dc_pitch; } while (--count); } @@ -3219,40 +3264,64 @@ void vlinec4_RGBA_SSE() uint32_t light2 = calc_light_multiplier(palookuplight[2]); uint32_t light3 = calc_light_multiplier(palookuplight[3]); - __m128i mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); - __m128i mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); + ShadeConstants shade_constants = dc_shade_constants; + uint32_t *palette = (uint32_t*)GPalette.BaseColors; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - do + if (shade_constants.simple_shade) { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; + SSE_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; - BYTE p0 = palookupoffse[0][bufplce[0][place0 >> bits]]; - BYTE p1 = palookupoffse[1][bufplce[1][place1 >> bits]]; - BYTE p2 = palookupoffse[2][bufplce[2][place2 >> bits]]; - BYTE p3 = palookupoffse[3][bufplce[3][place3 >> bits]]; + BYTE p0 = bufplce[0][place0 >> bits]; + BYTE p1 = bufplce[1][place1 >> bits]; + BYTE p2 = bufplce[2][place2 >> bits]; + BYTE p3 = bufplce[3][place3 >> bits]; - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - fg_hi = _mm_mullo_epi16(fg_hi, mlight_hi); - fg_hi = _mm_srli_epi16(fg_hi, 8); - fg_lo = _mm_mullo_epi16(fg_lo, mlight_lo); - fg_lo = _mm_srli_epi16(fg_lo, 8); - fg = _mm_packus_epi16(fg_lo, fg_hi); - _mm_storeu_si128((__m128i*)dest, fg); - dest += dc_pitch; - } while (--count); + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += dc_pitch; + } while (--count); + } + else + { + SSE_SHADE_INIT4(light3, light2, light1, light0, shade_constants); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; + + BYTE p0 = bufplce[0][place0 >> bits]; + BYTE p1 = bufplce[1][place1 >> bits]; + BYTE p2 = bufplce[2][place2 >> bits]; + BYTE p3 = bufplce[3][place3 >> bits]; + + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + dest += dc_pitch; + } while (--count); + } // Is this needed? Global variables makes it tricky to know.. vplce[0] = local_vplce[0]; @@ -3323,13 +3392,14 @@ DWORD mvlinec1_RGBA() int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; do { BYTE pix = source[frac >> bits]; if (pix != 0) { - *dest = shade_pal_index(colormap[pix], light); + *dest = shade_pal_index(pix, light, shade_constants); } frac += fracstep; dest += pitch; @@ -3370,13 +3440,15 @@ void mvlinec4_RGBA() uint32_t light2 = calc_light_multiplier(palookuplight[2]); uint32_t light3 = calc_light_multiplier(palookuplight[3]); + ShadeConstants shade_constants = dc_shade_constants; + do { BYTE pix; - pix = bufplce[0][(place = vplce[0]) >> bits]; if (pix) dest[0] = shade_pal_index(palookupoffse[0][pix], light0); vplce[0] = place + vince[0]; - pix = bufplce[1][(place = vplce[1]) >> bits]; if (pix) dest[1] = shade_pal_index(palookupoffse[1][pix], light1); vplce[1] = place + vince[1]; - pix = bufplce[2][(place = vplce[2]) >> bits]; if (pix) dest[2] = shade_pal_index(palookupoffse[2][pix], light2); vplce[2] = place + vince[2]; - pix = bufplce[3][(place = vplce[3]) >> bits]; if (pix) dest[3] = shade_pal_index(palookupoffse[3][pix], light3); vplce[3] = place + vince[3]; + pix = bufplce[0][(place = vplce[0]) >> bits]; if (pix) dest[0] = shade_pal_index(pix, light0, shade_constants); vplce[0] = place + vince[0]; + pix = bufplce[1][(place = vplce[1]) >> bits]; if (pix) dest[1] = shade_pal_index(pix, light1, shade_constants); vplce[1] = place + vince[1]; + pix = bufplce[2][(place = vplce[2]) >> bits]; if (pix) dest[2] = shade_pal_index(pix, light2, shade_constants); vplce[2] = place + vince[2]; + pix = bufplce[3][(place = vplce[3]) >> bits]; if (pix) dest[3] = shade_pal_index(pix, light3, shade_constants); vplce[3] = place + vince[3]; dest += dc_pitch; } while (--count); } @@ -3393,48 +3465,70 @@ void mvlinec4_RGBA_SSE() uint32_t light2 = calc_light_multiplier(palookuplight[2]); uint32_t light3 = calc_light_multiplier(palookuplight[3]); - __m128i mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); - __m128i mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); + ShadeConstants shade_constants = dc_shade_constants; + uint32_t *palette = (uint32_t*)GPalette.BaseColors; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - do + if (shade_constants.simple_shade) { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; + SSE_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; - BYTE pix0 = bufplce[0][place0 >> bits]; - BYTE pix1 = bufplce[1][place1 >> bits]; - BYTE pix2 = bufplce[2][place2 >> bits]; - BYTE pix3 = bufplce[3][place3 >> bits]; + BYTE pix0 = bufplce[0][place0 >> bits]; + BYTE pix1 = bufplce[1][place1 >> bits]; + BYTE pix2 = bufplce[2][place2 >> bits]; + BYTE pix3 = bufplce[3][place3 >> bits]; - // movemask = !(pix == 0) - __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); + // movemask = !(pix == 0) + __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); - BYTE p0 = palookupoffse[0][pix0]; - BYTE p1 = palookupoffse[1][pix1]; - BYTE p2 = palookupoffse[2][pix2]; - BYTE p3 = palookupoffse[3][pix3]; + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; + __m128i fg = _mm_set_epi32(palette[pix3], palette[pix2], palette[pix1], palette[pix0]); + SSE_SHADE_SIMPLE(fg); + _mm_maskmoveu_si128(fg, movemask, (char*)dest); + dest += dc_pitch; + } while (--count); + } + else + { + SSE_SHADE_INIT4(light3, light2, light1, light0, shade_constants); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - fg_hi = _mm_mullo_epi16(fg_hi, mlight_hi); - fg_hi = _mm_srli_epi16(fg_hi, 8); - fg_lo = _mm_mullo_epi16(fg_lo, mlight_lo); - fg_lo = _mm_srli_epi16(fg_lo, 8); - fg = _mm_packus_epi16(fg_lo, fg_hi); - _mm_maskmoveu_si128(fg, movemask, (char*)dest); - dest += dc_pitch; - } while (--count); + BYTE pix0 = bufplce[0][place0 >> bits]; + BYTE pix1 = bufplce[1][place1 >> bits]; + BYTE pix2 = bufplce[2][place2 >> bits]; + BYTE pix3 = bufplce[3][place3 >> bits]; + + // movemask = !(pix == 0) + __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); + + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; + + __m128i fg = _mm_set_epi32(palette[pix3], palette[pix2], palette[pix1], palette[pix0]); + SSE_SHADE(fg, shade_constants); + _mm_maskmoveu_si128(fg, movemask, (char*)dest); + dest += dc_pitch; + } while (--count); + } // Is this needed? Global variables makes it tricky to know.. vplce[0] = local_vplce[0]; @@ -3503,7 +3597,7 @@ void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip) clearbufshort (spanend+t2, b2-t2, x); } - R_SetColorMapLight(basecolormapdata, (float)light, wallshade); + R_SetColorMapLight(basecolormap, (float)light, wallshade); for (--x; x >= x1; --x) { @@ -3528,7 +3622,7 @@ void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip) clearbufshort (spanend+t2, b2-t2, x); } rcolormap = lcolormap; - R_SetColorMapLight(basecolormapdata, (float)light, wallshade); + R_SetColorMapLight(basecolormap, (float)light, wallshade); } else { @@ -3578,6 +3672,7 @@ static void R_DrawFogBoundarySection_RGBA(int y, int y2, int x1) uint32_t *dest = ylookup[y] + (uint32_t*)dc_destorg; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants constants = dc_shade_constants; for (; y < y2; ++y) { @@ -3585,7 +3680,37 @@ static void R_DrawFogBoundarySection_RGBA(int y, int y2, int x1) int x = x1; do { - dest[x] = shade_pal_index(colormap[dest[x]], light); + uint32_t red = (dest[x] >> 16) & 0xff; + uint32_t green = (dest[x] >> 8) & 0xff; + uint32_t blue = dest[x] & 0xff; + + if (constants.simple_shade) + { + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; + } + else + { + uint32_t inv_light = 256 - light; + uint32_t inv_desaturate = 256 - constants.desaturate; + + uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; + + red = (red * inv_desaturate + intensity) / 256; + green = (green * inv_desaturate + intensity) / 256; + blue = (blue * inv_desaturate + intensity) / 256; + + red = (constants.fade_red * inv_light + red * light) / 256; + green = (constants.fade_green * inv_light + green * light) / 256; + blue = (constants.fade_blue * inv_light + blue * light) / 256; + + red = (red * constants.light_red) / 256; + green = (green * constants.light_green) / 256; + blue = (blue * constants.light_blue) / 256; + } + + dest[x] = 0xff000000 | (red << 16) | (green << 8) | blue; } while (++x <= x2); dest += dc_pitch; } @@ -3598,10 +3723,41 @@ static void R_DrawFogBoundaryLine_RGBA(int y, int x) uint32_t *dest = ylookup[y] + (uint32_t*)dc_destorg; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants constants = dc_shade_constants; do { - dest[x] = shade_pal_index(colormap[dest[x]], light); + uint32_t red = (dest[x] >> 16) & 0xff; + uint32_t green = (dest[x] >> 8) & 0xff; + uint32_t blue = dest[x] & 0xff; + + if (constants.simple_shade) + { + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; + } + else + { + uint32_t inv_light = 256 - light; + uint32_t inv_desaturate = 256 - constants.desaturate; + + uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; + + red = (red * inv_desaturate + intensity) / 256; + green = (green * inv_desaturate + intensity) / 256; + blue = (blue * inv_desaturate + intensity) / 256; + + red = (constants.fade_red * inv_light + red * light) / 256; + green = (constants.fade_green * inv_light + green * light) / 256; + blue = (constants.fade_blue * inv_light + blue * light) / 256; + + red = (red * constants.light_red) / 256; + green = (green * constants.light_green) / 256; + blue = (blue * constants.light_blue) / 256; + } + + dest[x] = 0xff000000 | (red << 16) | (green << 8) | blue; } while (++x <= x2); } @@ -3627,7 +3783,9 @@ void R_DrawFogBoundary_RGBA(int x1, int x2, short *uclip, short *dclip) clearbufshort(spanend + t2, b2 - t2, x); } - R_SetColorMapLight(basecolormapdata, (float)light, wallshade); + R_SetColorMapLight(basecolormap, (float)light, wallshade); + + BYTE *fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); for (--x; x >= x1; --x) { @@ -3652,11 +3810,12 @@ void R_DrawFogBoundary_RGBA(int x1, int x2, short *uclip, short *dclip) clearbufshort(spanend + t2, b2 - t2, x); } rcolormap = lcolormap; - R_SetColorMapLight(basecolormapdata, (float)light, wallshade); + R_SetColorMapLight(basecolormap, (float)light, wallshade); + fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); } else { - if (dc_colormap != basecolormapdata) + if (fake_dc_colormap != basecolormapdata) { stop = MIN(t1, b2); while (t2 < stop) @@ -3741,7 +3900,6 @@ fixed_t tmvline1_add_RGBA() { DWORD fracstep = dc_iscale; DWORD frac = dc_texturefrac; - BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; uint32_t *dest = (uint32_t*)dc_dest; @@ -3749,6 +3907,7 @@ fixed_t tmvline1_add_RGBA() int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -3758,7 +3917,7 @@ fixed_t tmvline1_add_RGBA() BYTE pix = source[frac >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(colormap[pix], light); + uint32_t fg = shade_pal_index(pix, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -3825,6 +3984,8 @@ void tmvline4_add_RGBA() light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); + ShadeConstants shade_constants = dc_shade_constants; + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -3835,7 +3996,7 @@ void tmvline4_add_RGBA() BYTE pix = bufplce[i][vplce[i] >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(palookupoffse[i][pix], light[i]); + uint32_t fg = shade_pal_index(pix, light[i], shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -3898,7 +4059,6 @@ fixed_t tmvline1_addclamp_RGBA() { DWORD fracstep = dc_iscale; DWORD frac = dc_texturefrac; - BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; uint32_t *dest = (uint32_t*)dc_dest; @@ -3906,6 +4066,7 @@ fixed_t tmvline1_addclamp_RGBA() int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -3915,7 +4076,7 @@ fixed_t tmvline1_addclamp_RGBA() BYTE pix = source[frac >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(colormap[pix], light); + uint32_t fg = shade_pal_index(pix, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -3981,6 +4142,8 @@ void tmvline4_addclamp_RGBA() light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); + ShadeConstants shade_constants = dc_shade_constants; + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -3991,7 +4154,7 @@ void tmvline4_addclamp_RGBA() BYTE pix = bufplce[i][vplce[i] >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(palookupoffse[i][pix], light[i]); + uint32_t fg = shade_pal_index(pix, light[i], shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -4059,6 +4222,7 @@ fixed_t tmvline1_subclamp_RGBA() int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -4068,7 +4232,7 @@ fixed_t tmvline1_subclamp_RGBA() BYTE pix = source[frac >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(colormap[pix], light); + uint32_t fg = shade_pal_index(pix, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -4133,6 +4297,8 @@ void tmvline4_subclamp_RGBA() light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); + ShadeConstants shade_constants = dc_shade_constants; + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -4143,7 +4309,7 @@ void tmvline4_subclamp_RGBA() BYTE pix = bufplce[i][vplce[i] >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(palookupoffse[i][pix], light[i]); + uint32_t fg = shade_pal_index(pix, light[i], shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -4211,6 +4377,7 @@ fixed_t tmvline1_revsubclamp_RGBA() int pitch = dc_pitch; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -4220,7 +4387,7 @@ fixed_t tmvline1_revsubclamp_RGBA() BYTE pix = source[frac >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(colormap[pix], light); + uint32_t fg = shade_pal_index(pix, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -4285,6 +4452,8 @@ void tmvline4_revsubclamp_RGBA() light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); + ShadeConstants shade_constants = dc_shade_constants; + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -4295,7 +4464,7 @@ void tmvline4_revsubclamp_RGBA() BYTE pix = bufplce[i][vplce[i] >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(palookupoffse[i][pix], light[i]); + uint32_t fg = shade_pal_index(pix, light[i], shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -4793,15 +4962,15 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, colfunc = R_DrawShadedColumn; hcolfunc_post1 = rt_shaded1col; hcolfunc_post4 = rt_shaded4cols; - dc_color = fixedcolormap ? fixedcolormap[APART(color)] : basecolormap->Maps[APART(color)]; - lighttable_t *colormap = (basecolormap = &ShadeFakeColormap[16-alpha])->Maps; + dc_color = fixedcolormap ? fixedcolormap->Maps[APART(color)] : basecolormap->Maps[APART(color)]; + basecolormap = &ShadeFakeColormap[16-alpha]; if (fixedlightlev >= 0 && fixedcolormap == NULL) { - R_SetColorMapLight(colormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); } else { - R_SetColorMapLight(colormap, 0, 0); + R_SetColorMapLight(basecolormap, 0, 0); } return r_columnmethod ? DoDraw1 : DoDraw0; } @@ -4827,7 +4996,7 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, // with the alpha. dc_srccolor = ((((r*x)>>4)<<20) | ((g*x)>>4) | ((((b)*x)>>4)<<10)) & 0x3feffbff; hcolfunc_pre = R_FillColumnHoriz; - R_SetColorMapLight(identitymap, 0, 0); + R_SetColorMapLight(&identitycolormap, 0, 0); } if (!R_SetBlendFunc (style.BlendOp, fglevel, bglevel, style.Flags)) @@ -4871,30 +5040,77 @@ bool R_GetTransMaskDrawers (fixed_t (**tmvline1)(), void (**tmvline4)()) return false; } -void R_SetColorMapLight(BYTE *basecolormapdata, float light, int shade) +void R_SetTranslationMap(lighttable_t *translation) { + dc_fcolormap = nullptr; + dc_shade_constants.light_red = 256; + dc_shade_constants.light_green = 256; + dc_shade_constants.light_blue = 256; + dc_shade_constants.light_alpha = 256; + dc_shade_constants.fade_red = 0; + dc_shade_constants.fade_green = 0; + dc_shade_constants.fade_blue = 0; + dc_shade_constants.fade_alpha = 256; + dc_shade_constants.desaturate = 0; + dc_shade_constants.simple_shade = true; if (r_swtruecolor) { - dc_colormap = basecolormapdata; - dc_light = LIGHTSCALE(light, shade); + dc_colormap = translation; + dc_light = 0; } else { - dc_colormap = basecolormapdata + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); + dc_colormap = translation; dc_light = 0; } } -void R_SetDSColorMapLight(BYTE *basecolormapdata, float light, int shade) +void R_SetColorMapLight(FColormap *base_colormap, float light, int shade) { + dc_fcolormap = base_colormap; + dc_shade_constants.light_red = dc_fcolormap->Color.r * 256 / 255; + dc_shade_constants.light_green = dc_fcolormap->Color.g * 256 / 255; + dc_shade_constants.light_blue = dc_fcolormap->Color.b * 256 / 255; + dc_shade_constants.light_alpha = dc_fcolormap->Color.a * 256 / 255; + dc_shade_constants.fade_red = dc_fcolormap->Fade.r; + dc_shade_constants.fade_green = dc_fcolormap->Fade.g; + dc_shade_constants.fade_blue = dc_fcolormap->Fade.b; + dc_shade_constants.fade_alpha = dc_fcolormap->Fade.a; + dc_shade_constants.desaturate = MIN(std::abs(dc_fcolormap->Desaturate), 255) * 255 / 256; + dc_shade_constants.simple_shade = (dc_fcolormap->Color.d == 0x00ffffff && dc_fcolormap->Fade.d == 0x00000000 && dc_fcolormap->Desaturate == 0); if (r_swtruecolor) { - ds_colormap = basecolormapdata; + dc_colormap = base_colormap->Maps; + dc_light = LIGHTSCALE(light, shade); + } + else + { + dc_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); + dc_light = 0; + } +} + +void R_SetDSColorMapLight(FColormap *base_colormap, float light, int shade) +{ + ds_fcolormap = base_colormap; + ds_shade_constants.light_red = ds_fcolormap->Color.r * 256 / 255; + ds_shade_constants.light_green = ds_fcolormap->Color.g * 256 / 255; + ds_shade_constants.light_blue = ds_fcolormap->Color.b * 256 / 255; + ds_shade_constants.light_alpha = ds_fcolormap->Color.a * 256 / 255; + ds_shade_constants.fade_red = ds_fcolormap->Fade.r; + ds_shade_constants.fade_green = ds_fcolormap->Fade.g; + ds_shade_constants.fade_blue = ds_fcolormap->Fade.b; + ds_shade_constants.fade_alpha = ds_fcolormap->Fade.a; + ds_shade_constants.desaturate = MIN(std::abs(ds_fcolormap->Desaturate), 255) * 255 / 256; + ds_shade_constants.simple_shade = (ds_fcolormap->Color.d == 0x00ffffff && ds_fcolormap->Fade.d == 0x00000000 && ds_fcolormap->Desaturate == 0); + if (r_swtruecolor) + { + ds_colormap = base_colormap->Maps; ds_light = LIGHTSCALE(light, shade); } else { - ds_colormap = basecolormapdata + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); + ds_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); ds_light = 0; } } diff --git a/src/r_draw.h b/src/r_draw.h index 2eefff9bd..cc3b10935 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -25,11 +25,16 @@ #include "r_defs.h" +struct FColormap; +struct ShadeConstants; + extern "C" int ylookup[MAXHEIGHT]; extern "C" int dc_pitch; // [RH] Distance between rows extern "C" lighttable_t*dc_colormap; +extern "C" FColormap *dc_fcolormap; +extern "C" ShadeConstants dc_shade_constants; extern "C" fixed_t dc_light; extern "C" int dc_x; extern "C" int dc_yl; @@ -93,7 +98,7 @@ extern void (*R_DrawTranslatedColumn)(void); // Span drawing for rows, floor/ceiling. No Spectre effect needed. extern void (*R_DrawSpan)(void); void R_SetupSpanBits(FTexture *tex); -void R_SetSpanColormap(BYTE *colormap); +void R_SetSpanColormap(FDynamicColormap *colormap, int shade); void R_SetSpanSource(const BYTE *pixels); // Span drawing for masked textures. @@ -321,9 +326,10 @@ extern "C" int ds_y; extern "C" int ds_x1; extern "C" int ds_x2; +extern "C" FColormap* ds_fcolormap; extern "C" lighttable_t* ds_colormap; -//extern "C" dsfixed_t ds_light; -#define ds_light dc_light +extern "C" ShadeConstants ds_shade_constants; +extern "C" dsfixed_t ds_light; extern "C" dsfixed_t ds_xfrac; extern "C" dsfixed_t ds_yfrac; @@ -341,6 +347,7 @@ extern "C" int ds_color; // [RH] For flat color (no texturing) extern BYTE shadetables[/*NUMCOLORMAPS*16*256*/]; extern FDynamicColormap ShadeFakeColormap[16]; extern BYTE identitymap[256]; +extern FDynamicColormap identitycolormap; extern BYTE *dc_translation; // [RH] Added for muliresolution support @@ -389,9 +396,11 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); // Sets dc_colormap and dc_light to their appropriate values depending on the output format (pal vs true color) -void R_SetColorMapLight(BYTE *base_colormap, float light, int shade); +void R_SetColorMapLight(FColormap *base_colormap, float light, int shade); // Same as R_SetColorMapLight, but for ds_colormap and ds_light -void R_SetDSColorMapLight(BYTE *base_colormap, float light, int shade); +void R_SetDSColorMapLight(FColormap *base_colormap, float light, int shade); + +void R_SetTranslationMap(lighttable_t *translation); #endif diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index d390fc54d..ff5c0d82f 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -108,7 +108,6 @@ void rt_copy4cols_RGBA_c (int sx, int yl, int yh) // Maps one span at hx to the screen at sx. void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh) { - BYTE *colormap; uint32_t *source; uint32_t *dest; int count; @@ -120,14 +119,14 @@ void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh) count++; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; - colormap = dc_colormap; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; if (count & 1) { - *dest = shade_pal_index(colormap[*source], light); + *dest = shade_pal_index(*source, light, shade_constants); source += 4; dest += pitch; } @@ -135,8 +134,8 @@ void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh) return; do { - dest[0] = shade_pal_index(colormap[source[0]], light); - dest[pitch] = shade_pal_index(colormap[source[4]], light); + dest[0] = shade_pal_index(source[0], light, shade_constants); + dest[pitch] = shade_pal_index(source[4], light, shade_constants); source += 8; dest += pitch*2; } while (--count); @@ -145,7 +144,6 @@ void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh) // Maps all four spans to the screen starting at sx. void rt_map4cols_RGBA_c (int sx, int yl, int yh) { - BYTE *colormap; uint32_t *source; uint32_t *dest; int count; @@ -157,17 +155,17 @@ void rt_map4cols_RGBA_c (int sx, int yl, int yh) count++; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; - colormap = dc_colormap; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; if (count & 1) { - dest[0] = shade_pal_index(colormap[source[0]], light); - dest[1] = shade_pal_index(colormap[source[1]], light); - dest[2] = shade_pal_index(colormap[source[2]], light); - dest[3] = shade_pal_index(colormap[source[3]], light); + dest[0] = shade_pal_index(source[0], light, shade_constants); + dest[1] = shade_pal_index(source[1], light, shade_constants); + dest[2] = shade_pal_index(source[2], light, shade_constants); + dest[3] = shade_pal_index(source[3], light, shade_constants); source += 4; dest += pitch; } @@ -175,14 +173,14 @@ void rt_map4cols_RGBA_c (int sx, int yl, int yh) return; do { - dest[0] = shade_pal_index(colormap[source[0]], light); - dest[1] = shade_pal_index(colormap[source[1]], light); - dest[2] = shade_pal_index(colormap[source[2]], light); - dest[3] = shade_pal_index(colormap[source[3]], light); - dest[pitch] = shade_pal_index(colormap[source[4]], light); - dest[pitch + 1] = shade_pal_index(colormap[source[5]], light); - dest[pitch + 2] = shade_pal_index(colormap[source[6]], light); - dest[pitch + 3] = shade_pal_index(colormap[source[7]], light); + dest[0] = shade_pal_index(source[0], light, shade_constants); + dest[1] = shade_pal_index(source[1], light, shade_constants); + dest[2] = shade_pal_index(source[2], light, shade_constants); + dest[3] = shade_pal_index(source[3], light, shade_constants); + dest[pitch] = shade_pal_index(source[4], light, shade_constants); + dest[pitch + 1] = shade_pal_index(source[5], light, shade_constants); + dest[pitch + 2] = shade_pal_index(source[6], light, shade_constants); + dest[pitch + 3] = shade_pal_index(source[7], light, shade_constants); source += 8; dest += pitch*2; } while (--count); @@ -191,7 +189,6 @@ void rt_map4cols_RGBA_c (int sx, int yl, int yh) // Maps all four spans to the screen starting at sx. void rt_map4cols_RGBA_SSE(int sx, int yl, int yh) { - BYTE *colormap; uint32_t *source; uint32_t *dest; int count; @@ -202,82 +199,114 @@ void rt_map4cols_RGBA_SSE(int sx, int yl, int yh) return; count++; + ShadeConstants shade_constants = dc_shade_constants; uint32_t light = calc_light_multiplier(dc_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; - colormap = dc_colormap; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl * 4]; pitch = dc_pitch; - __m128i mlight = _mm_set_epi16(256, light, light, light, 256, light, light, light); + if (shade_constants.simple_shade) + { + SSE_SHADE_SIMPLE_INIT(light); - if (count & 1) { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - fg_hi = _mm_mullo_epi16(fg_hi, mlight); - fg_hi = _mm_srli_epi16(fg_hi, 8); - fg_lo = _mm_mullo_epi16(fg_lo, mlight); - fg_lo = _mm_srli_epi16(fg_lo, 8); - - fg = _mm_packus_epi16(fg_lo, fg_hi); - _mm_storeu_si128((__m128i*)dest, fg); - - source += 4; - dest += pitch; - } - if (!(count >>= 1)) - return; - - do { - // shade_pal_index 0-3 - { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; + if (count & 1) { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + // shade_pal_index: __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - fg_hi = _mm_mullo_epi16(fg_hi, mlight); - fg_hi = _mm_srli_epi16(fg_hi, 8); - fg_lo = _mm_mullo_epi16(fg_lo, mlight); - fg_lo = _mm_srli_epi16(fg_lo, 8); - - fg = _mm_packus_epi16(fg_lo, fg_hi); + SSE_SHADE_SIMPLE(fg); _mm_storeu_si128((__m128i*)dest, fg); + + source += 4; + dest += pitch; } + if (!(count >>= 1)) + return; - // shade_pal_index 4-7 (pitch) - { - uint32_t p0 = colormap[source[4]]; - uint32_t p1 = colormap[source[5]]; - uint32_t p2 = colormap[source[6]]; - uint32_t p3 = colormap[source[7]]; + do { + // shade_pal_index 0-3 + { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + } + + // shade_pal_index 4-7 (pitch) + { + uint32_t p0 = source[4]; + uint32_t p1 = source[5]; + uint32_t p2 = source[6]; + uint32_t p3 = source[7]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)(dest + pitch), fg); + } + + source += 8; + dest += pitch * 2; + } while (--count); + } + else + { + SSE_SHADE_INIT(light, shade_constants); + + if (count & 1) { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - fg_hi = _mm_mullo_epi16(fg_hi, mlight); - fg_hi = _mm_srli_epi16(fg_hi, 8); - fg_lo = _mm_mullo_epi16(fg_lo, mlight); - fg_lo = _mm_srli_epi16(fg_lo, 8); + SSE_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); - fg = _mm_packus_epi16(fg_lo, fg_hi); - _mm_storeu_si128((__m128i*)(dest + pitch), fg); + source += 4; + dest += pitch; } + if (!(count >>= 1)) + return; - source += 8; - dest += pitch * 2; - } while (--count); + do { + // shade_pal_index 0-3 + { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + } + + // shade_pal_index 4-7 (pitch) + { + uint32_t p0 = source[4]; + uint32_t p1 = source[5]; + uint32_t p2 = source[6]; + uint32_t p3 = source[7]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)(dest + pitch), fg); + } + + source += 8; + dest += pitch * 2; + } while (--count); + } } void rt_Translate1col_RGBA_c(const BYTE *translation, int hx, int yl, int yh) @@ -385,7 +414,6 @@ void rt_tlate4cols_RGBA_c (int sx, int yl, int yh) // Adds one span at hx to the screen at sx without clamping. void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh) { - BYTE *colormap; uint32_t *source; uint32_t *dest; int count; @@ -399,15 +427,15 @@ void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh) dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; - colormap = dc_colormap; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(colormap[*source], light); + uint32_t fg = shade_pal_index(*source, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -430,7 +458,6 @@ void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh) // Adds all four spans to the screen starting at sx without clamping. void rt_add4cols_RGBA_c (int sx, int yl, int yh) { - BYTE *colormap; uint32_t *source; uint32_t *dest; int count; @@ -444,9 +471,9 @@ void rt_add4cols_RGBA_c (int sx, int yl, int yh) dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; - colormap = dc_colormap; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -454,7 +481,7 @@ void rt_add4cols_RGBA_c (int sx, int yl, int yh) do { for (int i = 0; i < 4; i++) { - uint32_t fg = shade_pal_index(colormap[source[i]], light); + uint32_t fg = shade_pal_index(source[i], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -479,7 +506,6 @@ void rt_add4cols_RGBA_c (int sx, int yl, int yh) #ifndef NO_SSE void rt_add4cols_RGBA_SSE(int sx, int yl, int yh) { - BYTE *colormap; uint32_t *source; uint32_t *dest; int count; @@ -493,7 +519,6 @@ void rt_add4cols_RGBA_SSE(int sx, int yl, int yh) dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl * 4]; pitch = dc_pitch; - colormap = dc_colormap; uint32_t light = calc_light_multiplier(dc_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; @@ -501,40 +526,80 @@ void rt_add4cols_RGBA_SSE(int sx, int yl, int yh) uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - __m128i mlight = _mm_set_epi16(256, light, light, light, 256, light, light, light); - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + ShadeConstants shade_constants = dc_shade_constants; - do { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; + if (shade_constants.simple_shade) + { + SSE_SHADE_SIMPLE_INIT(light); - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - fg_hi = _mm_mullo_epi16(fg_hi, mlight); - fg_hi = _mm_srli_epi16(fg_hi, 8); - fg_lo = _mm_mullo_epi16(fg_lo, mlight); - fg_lo = _mm_srli_epi16(fg_lo, 8); + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + do { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; - // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE_SIMPLE(fg); - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - source += 4; - dest += pitch; - } while (--count); + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += 4; + dest += pitch; + } while (--count); + } + else + { + SSE_SHADE_INIT(light, shade_constants); + + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE(fg, shade_constants); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += 4; + dest += pitch; + } while (--count); + } } #endif @@ -571,7 +636,7 @@ void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh) source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -613,7 +678,7 @@ void rt_shaded4cols_RGBA_c (int sx, int yl, int yh) source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -659,7 +724,7 @@ void rt_shaded4cols_RGBA_SSE(int sx, int yl, int yh) source = &dc_temp_rgba[yl * 4]; pitch = dc_pitch; - __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(shade_pal_index(dc_color, calc_light_multiplier(dc_light))), _mm_setzero_si128()); + __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light))), _mm_setzero_si128()); __m128i alpha_one = _mm_set1_epi16(64); do { @@ -694,7 +759,6 @@ void rt_shaded4cols_RGBA_SSE(int sx, int yl, int yh) // Adds one span at hx to the screen at sx with clamping. void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh) { - BYTE *colormap; uint32_t *source; uint32_t *dest; int count; @@ -708,15 +772,15 @@ void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh) dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; - colormap = dc_colormap; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(colormap[*source], light); + uint32_t fg = shade_pal_index(*source, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -738,7 +802,6 @@ void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh) // Adds all four spans to the screen starting at sx with clamping. void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh) { - BYTE *colormap; uint32_t *source; uint32_t *dest; int count; @@ -752,9 +815,9 @@ void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh) dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; - colormap = dc_colormap; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -762,7 +825,7 @@ void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh) do { for (int i = 0; i < 4; i++) { - uint32_t fg = shade_pal_index(colormap[source[i]], light); + uint32_t fg = shade_pal_index(source[i], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -786,7 +849,6 @@ void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh) #ifndef NO_SSE void rt_addclamp4cols_RGBA_SSE(int sx, int yl, int yh) { - BYTE *colormap; uint32_t *source; uint32_t *dest; int count; @@ -800,7 +862,6 @@ void rt_addclamp4cols_RGBA_SSE(int sx, int yl, int yh) dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl * 4]; pitch = dc_pitch; - colormap = dc_colormap; uint32_t light = calc_light_multiplier(dc_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; @@ -808,40 +869,80 @@ void rt_addclamp4cols_RGBA_SSE(int sx, int yl, int yh) uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - __m128i mlight = _mm_set_epi16(256, light, light, light, 256, light, light, light); - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + ShadeConstants shade_constants = dc_shade_constants; - do { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; + if (shade_constants.simple_shade) + { + SSE_SHADE_SIMPLE_INIT(light); - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - fg_hi = _mm_mullo_epi16(fg_hi, mlight); - fg_hi = _mm_srli_epi16(fg_hi, 8); - fg_lo = _mm_mullo_epi16(fg_lo, mlight); - fg_lo = _mm_srli_epi16(fg_lo, 8); + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + do { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; - // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE_SIMPLE(fg); - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - source += 4; - dest += pitch; - } while (--count); + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += 4; + dest += pitch; + } while (--count); + } + else + { + SSE_SHADE_INIT(light, shade_constants); + + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE(fg, shade_constants); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += 4; + dest += pitch; + } while (--count); + } } #endif @@ -862,7 +963,6 @@ void rt_tlateaddclamp4cols_RGBA_c (int sx, int yl, int yh) // Subtracts one span at hx to the screen at sx with clamping. void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh) { - BYTE *colormap; uint32_t *source; uint32_t *dest; int count; @@ -876,15 +976,15 @@ void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh) dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; - colormap = dc_colormap; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(colormap[*source], light); + uint32_t fg = shade_pal_index(*source, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -906,7 +1006,6 @@ void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh) // Subtracts all four spans to the screen starting at sx with clamping. void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh) { - BYTE *colormap; uint32_t *source; uint32_t *dest; int count; @@ -920,9 +1019,9 @@ void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh) dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; - colormap = dc_colormap; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -930,7 +1029,7 @@ void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh) do { for (int i = 0; i < 4; i++) { - uint32_t fg = shade_pal_index(colormap[source[i]], light); + uint32_t fg = shade_pal_index(source[i], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -968,7 +1067,6 @@ void rt_tlatesubclamp4cols_RGBA_c (int sx, int yl, int yh) // Subtracts one span at hx from the screen at sx with clamping. void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) { - BYTE *colormap; uint32_t *source; uint32_t *dest; int count; @@ -982,15 +1080,15 @@ void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; - colormap = dc_colormap; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(colormap[*source], light); + uint32_t fg = shade_pal_index(*source, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -1012,7 +1110,6 @@ void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) // Subtracts all four spans from the screen starting at sx with clamping. void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh) { - BYTE *colormap; uint32_t *source; uint32_t *dest; int count; @@ -1026,9 +1123,9 @@ void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh) dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; - colormap = dc_colormap; uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -1036,7 +1133,7 @@ void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh) do { for (int i = 0; i < 4; i++) { - uint32_t fg = shade_pal_index(colormap[source[i]], light); + uint32_t fg = shade_pal_index(source[i], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; diff --git a/src/r_main.cpp b/src/r_main.cpp index aaf8fc532..a795f8016 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -119,7 +119,7 @@ double FocalLengthX; double FocalLengthY; FDynamicColormap*basecolormap; // [RH] colormap currently drawing with int fixedlightlev; -lighttable_t *fixedcolormap; +FColormap *fixedcolormap; FSpecialColormap *realfixedcolormap; double WallTMapScale2; @@ -464,11 +464,11 @@ void R_SetupColormap(player_t *player) // Render everything fullbright. The copy to video memory will // apply the special colormap, so it won't be restricted to the // palette. - fixedcolormap = realcolormaps; + fixedcolormap = &realcolormaps; } else { - fixedcolormap = SpecialColormaps[player->fixedcolormap].Colormap; + fixedcolormap = &SpecialColormaps[player->fixedcolormap]; } } else if (player->fixedlightlevel >= 0 && player->fixedlightlevel < NUMCOLORMAPS) @@ -479,7 +479,7 @@ void R_SetupColormap(player_t *player) // [RH] Inverse light for shooting the Sigil if (fixedcolormap == NULL && extralight == INT_MIN) { - fixedcolormap = SpecialColormaps[INVERSECOLORMAP].Colormap; + fixedcolormap = &SpecialColormaps[INVERSECOLORMAP]; extralight = 0; } } diff --git a/src/r_main.h b/src/r_main.h index e8be3c1a3..0db704df1 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -90,25 +90,162 @@ extern bool r_dontmaplines; // Converts fixedlightlev into a shade value #define FIXEDLIGHT2SHADE(lightlev) (((lightlev) >> COLORMAPSHIFT) << FRACBITS) +struct ShadeConstants +{ + uint16_t light_alpha; + uint16_t light_red; + uint16_t light_green; + uint16_t light_blue; + uint16_t fade_alpha; + uint16_t fade_red; + uint16_t fade_green; + uint16_t fade_blue; + uint16_t desaturate; + bool simple_shade; +}; + // calculates the light constant passed to the shade_pal_index function inline uint32_t calc_light_multiplier(dsfixed_t light) { return 256 - (light >> (FRACBITS - 8)); } +// Give the compiler a strong hint we want these functions inlined: +#ifndef FORCEINLINE +#if defined(_MSC_VER) +#define FORCEINLINE __forceinline +#elif defined(__GNUC__) +#define FORCEINLINE __attribute__((always_inline)) +#else +#define FORCEINLINE inline +#endif +#endif + // Calculates a ARGB8 color for the given palette index and light multiplier -inline uint32_t shade_pal_index(uint32_t index, uint32_t light) +FORCEINLINE uint32_t shade_pal_index_simple(uint32_t index, uint32_t light) { const PalEntry &color = GPalette.BaseColors[index]; uint32_t red = color.r; uint32_t green = color.g; uint32_t blue = color.b; + red = red * light / 256; green = green * light / 256; blue = blue * light / 256; + return 0xff000000 | (red << 16) | (green << 8) | blue; } +// Calculates a ARGB8 color for the given palette index, light multiplier and dynamic colormap +FORCEINLINE uint32_t shade_pal_index(uint32_t index, uint32_t light, const ShadeConstants &constants) +{ + const PalEntry &color = GPalette.BaseColors[index]; + uint32_t red = color.r; + uint32_t green = color.g; + uint32_t blue = color.b; + if (constants.simple_shade) + { + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; + } + else + { + uint32_t inv_light = 256 - light; + uint32_t inv_desaturate = 256 - constants.desaturate; + + uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; + + red = (red * inv_desaturate + intensity) / 256; + green = (green * inv_desaturate + intensity) / 256; + blue = (blue * inv_desaturate + intensity) / 256; + + red = (constants.fade_red * inv_light + red * light) / 256; + green = (constants.fade_green * inv_light + green * light) / 256; + blue = (constants.fade_blue * inv_light + blue * light) / 256; + + red = (red * constants.light_red) / 256; + green = (green * constants.light_green) / 256; + blue = (blue * constants.light_blue) / 256; + } + return 0xff000000 | (red << 16) | (green << 8) | blue; +} + +// Calculate constants for a simple shade +#define SSE_SHADE_SIMPLE_INIT(light) \ + __m128i mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ + __m128i mlight_lo = mlight_hi; + +// Calculate constants for a simple shade with different light levels for each pixel +#define SSE_SHADE_SIMPLE_INIT4(light3, light2, light1, light0) \ + __m128i mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); \ + __m128i mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); + +// Simple shade 4 pixels +#define SSE_SHADE_SIMPLE(fg) { \ + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); \ + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); \ + fg_hi = _mm_mullo_epi16(fg_hi, mlight_hi); \ + fg_hi = _mm_srli_epi16(fg_hi, 8); \ + fg_lo = _mm_mullo_epi16(fg_lo, mlight_lo); \ + fg_lo = _mm_srli_epi16(fg_lo, 8); \ + fg = _mm_packus_epi16(fg_lo, fg_hi); \ +} + +// Calculate constants for a complex shade +#define SSE_SHADE_INIT(light, shade_constants) \ + __m128i mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ + __m128i mlight_lo = mlight_hi; \ + __m128i color = _mm_set_epi16( \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ + __m128i fade = _mm_set_epi16( \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ + __m128i fade_amount_hi = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_hi)); \ + __m128i fade_amount_lo = fade_amount_hi; \ + __m128i inv_desaturate = _mm_set1_epi16(256 - shade_constants.desaturate); \ + +// Calculate constants for a complex shade with different light levels for each pixel +#define SSE_SHADE_INIT4(light3, light2, light1, light0, shade_constants) \ + __m128i mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); \ + __m128i mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); \ + __m128i color = _mm_set_epi16( \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ + __m128i fade = _mm_set_epi16( \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ + __m128i fade_amount_hi = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_hi)); \ + __m128i fade_amount_lo = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_lo)); \ + __m128i inv_desaturate = _mm_set1_epi16(256 - shade_constants.desaturate); \ + +// Complex shade 4 pixels +#define SSE_SHADE(fg, shade_constants) { \ + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); \ + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); \ + \ + __m128i intensity_hi = _mm_mullo_epi16(fg_hi, _mm_set_epi16(0, 77, 143, 37, 0, 77, 143, 37)); \ + uint16_t intensity_hi0 = ((intensity_hi.m128i_u16[2] + intensity_hi.m128i_u16[1] + intensity_hi.m128i_u16[0]) >> 8) * shade_constants.desaturate; \ + uint16_t intensity_hi1 = ((intensity_hi.m128i_u16[6] + intensity_hi.m128i_u16[5] + intensity_hi.m128i_u16[4]) >> 8) * shade_constants.desaturate; \ + intensity_hi = _mm_set_epi16(intensity_hi1, intensity_hi1, intensity_hi1, intensity_hi1, intensity_hi0, intensity_hi0, intensity_hi0, intensity_hi0); \ + \ + fg_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, inv_desaturate), intensity_hi), 8); \ + fg_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mlight_hi), fade_amount_hi), 8); \ + fg_hi = _mm_srli_epi16(_mm_mullo_epi16(fg_hi, color), 8); \ + \ + __m128i intensity_lo = _mm_mullo_epi16(fg_lo, _mm_set_epi16(0, 77, 143, 37, 0, 77, 143, 37)); \ + uint16_t intensity_lo0 = ((intensity_lo.m128i_u16[2] + intensity_lo.m128i_u16[1] + intensity_lo.m128i_u16[0]) >> 8) * shade_constants.desaturate; \ + uint16_t intensity_lo1 = ((intensity_lo.m128i_u16[6] + intensity_lo.m128i_u16[5] + intensity_lo.m128i_u16[4]) >> 8) * shade_constants.desaturate; \ + intensity_lo = _mm_set_epi16(intensity_lo1, intensity_lo1, intensity_lo1, intensity_lo1, intensity_lo0, intensity_lo0, intensity_lo0, intensity_lo0); \ + \ + fg_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, inv_desaturate), intensity_lo), 8); \ + fg_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mlight_lo), fade_amount_lo), 8); \ + fg_lo = _mm_srli_epi16(_mm_mullo_epi16(fg_lo, color), 8); \ + \ + fg = _mm_packus_epi16(fg_lo, fg_hi); \ +} + extern bool r_swtruecolor; extern double GlobVis; @@ -125,7 +262,7 @@ extern double r_SpriteVisibility; extern int r_actualextralight; extern bool foggy; extern int fixedlightlev; -extern lighttable_t* fixedcolormap; +extern FColormap* fixedcolormap; extern FSpecialColormap*realfixedcolormap; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 9805ab200..26d579d6d 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -227,7 +227,7 @@ void R_MapPlane (int y, int x1) if (plane_shade) { // Determine lighting based on the span's distance from the viewer. - R_SetDSColorMapLight(basecolormap->Maps, GlobVis * fabs(CenterY - y), planeshade); + R_SetDSColorMapLight(basecolormap, GlobVis * fabs(CenterY - y), planeshade); } #ifdef X86_ASM @@ -616,7 +616,7 @@ void R_MapColoredPlane_RGBA(int y, int x1) uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg; int count = (spanend[y] - x1 + 1); uint32_t light = calc_light_multiplier(ds_light); - uint32_t color = shade_pal_index(ds_color, light); + uint32_t color = shade_pal_index_simple(ds_color, light); for (int i = 0; i < count; i++) dest[i] = color; } @@ -1598,7 +1598,7 @@ void R_DrawSkyPlane (visplane_t *pl) else { fakefixed = true; - fixedcolormap = NormalLight.Maps; + fixedcolormap = &NormalLight; R_SetColorMapLight(fixedcolormap, 0, 0); } @@ -1683,7 +1683,7 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t ds_light = 0; if (fixedlightlev >= 0) { - R_SetDSColorMapLight(basecolormap->Maps, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); plane_shade = false; } else if (fixedcolormap) @@ -1860,7 +1860,7 @@ void R_DrawTiltedPlane(visplane_t *pl, double _xscale, double _yscale, fixed_t a ds_light = 0; if (fixedlightlev >= 0) { - R_SetDSColorMapLight(basecolormap->Maps, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); plane_shade = false; } else if (fixedcolormap) @@ -1870,7 +1870,7 @@ void R_DrawTiltedPlane(visplane_t *pl, double _xscale, double _yscale, fixed_t a } else { - R_SetDSColorMapLight(basecolormap->Maps, 0, 0); + R_SetDSColorMapLight(basecolormap, 0, 0); plane_shade = true; } diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 43590247e..bd2c7d22b 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -177,7 +177,7 @@ static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FText // calculate lighting if (fixedcolormap == NULL && fixedlightlev < 0) { - R_SetColorMapLight(basecolormap->Maps, rw_light, wallshade); + R_SetColorMapLight(basecolormap, rw_light, wallshade); } dc_iscale = xs_Fix<16>::ToFix(MaskedSWall[dc_x] * MaskedScaleY); @@ -313,7 +313,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) rw_scalestep = ds->iscalestep; if (fixedlightlev >= 0) - R_SetColorMapLight(basecolormap->Maps, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); @@ -630,7 +630,7 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) } if (fixedlightlev >= 0) - R_SetColorMapLight(basecolormap->Maps, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); @@ -1126,6 +1126,11 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l palookuplight[3] = 0; } + if (fixedcolormap) + R_SetColorMapLight(fixedcolormap, 0, 0); + else + R_SetColorMapLight(basecolormap, 0, 0); + for(; (x < x2) && (x & 3); ++x) { light += rw_lightstep; @@ -1137,7 +1142,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l if (!fixed) { // calculate lighting - R_SetColorMapLight(basecolormapdata, light, wallshade); + R_SetColorMapLight(basecolormap, light, wallshade); } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1241,7 +1246,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l if (!fixed) { // calculate lighting - R_SetColorMapLight(basecolormapdata, light, wallshade); + R_SetColorMapLight(basecolormap, light, wallshade); } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1496,6 +1501,11 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ palookuplight[3] = 0; } + if (fixedcolormap) + R_SetColorMapLight(fixedcolormap, 0, 0); + else + R_SetColorMapLight(basecolormap, 0, 0); + for(; (x < x2) && (((size_t)pixel >> pixelshift) & 3); ++x, pixel += pixelsize) { light += rw_lightstep; @@ -1505,7 +1515,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ if (!fixed) { // calculate lighting - R_SetColorMapLight(basecolormapdata, light, wallshade); + R_SetColorMapLight(basecolormap, light, wallshade); } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1605,7 +1615,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ if (!fixed) { // calculate lighting - R_SetColorMapLight(basecolormapdata, light, wallshade); + R_SetColorMapLight(basecolormap, light, wallshade); } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1690,6 +1700,11 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f palookuplight[3] = 0; } + if (fixedcolormap) + R_SetColorMapLight(fixedcolormap, 0, 0); + else + R_SetColorMapLight(basecolormap, 0, 0); + for(; (x < x2) && (((size_t)pixel >> pixelshift) & 3); ++x, pixel += pixelsize) { light += rw_lightstep; @@ -1699,7 +1714,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f if (!fixed) { // calculate lighting - R_SetColorMapLight(basecolormapdata, light, wallshade); + R_SetColorMapLight(basecolormap, light, wallshade); } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1801,7 +1816,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f if (!fixed) { // calculate lighting - R_SetColorMapLight(basecolormapdata, light, wallshade); + R_SetColorMapLight(basecolormap, light, wallshade); } dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); @@ -1839,7 +1854,7 @@ void R_RenderSegLoop () fixed_t xoffset = rw_offset; if (fixedlightlev >= 0) - R_SetColorMapLight(basecolormap->Maps, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); @@ -3238,11 +3253,11 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rw_light = rw_lightleft + (x1 - WallC.sx1) * rw_lightstep; if (fixedlightlev >= 0) - R_SetColorMapLight(usecolormap->Maps, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetColorMapLight(usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT)) - R_SetColorMapLight(usecolormap->Maps, 0, 0); + R_SetColorMapLight(usecolormap, 0, 0); else calclighting = true; @@ -3293,7 +3308,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap->Maps, rw_light, wallshade); + R_SetColorMapLight(usecolormap, rw_light, wallshade); } R_WallSpriteColumn (R_DrawMaskedColumn); dc_x++; @@ -3303,7 +3318,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap->Maps, rw_light, wallshade); + R_SetColorMapLight(usecolormap, rw_light, wallshade); } rt_initcols(nullptr); for (int zz = 4; zz; --zz) @@ -3318,7 +3333,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap->Maps, rw_light, wallshade); + R_SetColorMapLight(usecolormap, rw_light, wallshade); } R_WallSpriteColumn (R_DrawMaskedColumn); dc_x++; diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index ee6ac5fed..645741a2a 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -323,7 +323,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin // curse Doom's overuse of global variables in the renderer. // These get clobbered by rendering to a camera texture but they need to be preserved so the final rendering can be done with the correct palette. - unsigned char *savecolormap = fixedcolormap; + FColormap *savecolormap = fixedcolormap; FSpecialColormap *savecm = realfixedcolormap; DAngle savedfov = FieldOfView; diff --git a/src/r_things.cpp b/src/r_things.cpp index 6f8038148..c132cc2fd 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -416,7 +416,7 @@ void R_DrawVisSprite (vissprite_t *vis) { // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but // it is the brightest one. We need to get back to the proper light level for // this sprite. - R_SetColorMapLight(dc_colormap, 0, vis->Style.ColormapNum << FRACBITS); + R_SetColorMapLight(dc_fcolormap, 0, vis->Style.ColormapNum << FRACBITS); } if (mode != DontDraw) @@ -538,11 +538,11 @@ void R_DrawWallSprite(vissprite_t *spr) rw_lightstep = float((GlobVis / spr->wallc.sz2 - rw_lightleft) / (spr->wallc.sx2 - spr->wallc.sx1)); rw_light = rw_lightleft + (x1 - spr->wallc.sx1) * rw_lightstep; if (fixedlightlev >= 0) - R_SetColorMapLight(usecolormap->Maps, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetColorMapLight(usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) - R_SetColorMapLight(usecolormap->Maps, 0, 0); + R_SetColorMapLight(usecolormap, 0, 0); else calclighting = true; @@ -593,7 +593,7 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap->Maps, rw_light, shade); + R_SetColorMapLight(usecolormap, rw_light, shade); } if (!R_ClipSpriteColumnWithPortals(spr)) R_WallSpriteColumn(R_DrawMaskedColumn); @@ -604,7 +604,7 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap->Maps, rw_light, shade); + R_SetColorMapLight(usecolormap, rw_light, shade); } rt_initcols(nullptr); for (int zz = 4; zz; --zz) @@ -620,7 +620,7 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap->Maps, rw_light, shade); + R_SetColorMapLight(usecolormap, rw_light, shade); } if (!R_ClipSpriteColumnWithPortals(spr)) R_WallSpriteColumn(R_DrawMaskedColumn); @@ -680,7 +680,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop // Render the voxel, either directly to the screen or offscreen. R_DrawVoxel(spr->pa.vpos, spr->pa.vang, spr->gpos, spr->Angle, - spr->xscale, FLOAT2FIXED(spr->yscale), spr->voxel, spr->Style.BaseColormap + (spr->Style.ColormapNum << COLORMAPSHIFT), cliptop, clipbot, + spr->xscale, FLOAT2FIXED(spr->yscale), spr->voxel, spr->Style.BaseColormap->Maps + (spr->Style.ColormapNum << COLORMAPSHIFT), cliptop, clipbot, minslabz, maxslabz, flags); // Blend the voxel, if that's what we need to do. @@ -1121,19 +1121,19 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor } if (fixedlightlev >= 0) { - vis->Style.BaseColormap = mybasecolormap->Maps; + vis->Style.BaseColormap = mybasecolormap; vis->Style.ColormapNum = fixedlightlev >> COLORMAPSHIFT; } else if (!foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) { // full bright - vis->Style.BaseColormap = mybasecolormap->Maps; + vis->Style.BaseColormap = mybasecolormap; vis->Style.ColormapNum = 0; } else { // diminished light vis->Style.ColormapNum = GETPALOOKUP( r_SpriteVisibility / MAX(tz, MINZ), spriteshade); - vis->Style.BaseColormap = mybasecolormap->Maps; + vis->Style.BaseColormap = mybasecolormap; } } } @@ -1208,7 +1208,7 @@ static void R_ProjectWallSprite(AActor *thing, const DVector3 &pos, FTextureID p vis->bWallSprite = true; vis->Style.ColormapNum = GETPALOOKUP( r_SpriteVisibility / MAX(tz, MINZ), spriteshade); - vis->Style.BaseColormap = basecolormap->Maps; + vis->Style.BaseColormap = basecolormap; vis->wallc = wallc; } @@ -1428,7 +1428,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double if (realfixedcolormap != NULL) { // fixed color - vis->Style.BaseColormap = realfixedcolormap->Colormap; + vis->Style.BaseColormap = realfixedcolormap; vis->Style.ColormapNum = 0; } else @@ -1439,39 +1439,38 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double } if (fixedlightlev >= 0) { - vis->Style.BaseColormap = mybasecolormap->Maps; + vis->Style.BaseColormap = mybasecolormap; vis->Style.ColormapNum = fixedlightlev >> COLORMAPSHIFT; } else if (!foggy && psp->state->GetFullbright()) { // full bright - vis->Style.BaseColormap = mybasecolormap->Maps; // [RH] use basecolormap + vis->Style.BaseColormap = mybasecolormap; // [RH] use basecolormap vis->Style.ColormapNum = 0; } else { // local light - vis->Style.BaseColormap = mybasecolormap->Maps; + vis->Style.BaseColormap = mybasecolormap; vis->Style.ColormapNum = GETPALOOKUP(0, spriteshade); } } if (camera->Inventory != NULL) { BYTE oldcolormapnum = vis->Style.ColormapNum; - lighttable_t *oldcolormap = vis->Style.BaseColormap; + FColormap *oldcolormap = vis->Style.BaseColormap; camera->Inventory->AlterWeaponSprite (&vis->Style); if (vis->Style.BaseColormap != oldcolormap || vis->Style.ColormapNum != oldcolormapnum) { // The colormap has changed. Is it one we can easily identify? // If not, then don't bother trying to identify it for // hardware accelerated drawing. - if (vis->Style.BaseColormap < SpecialColormaps[0].Colormap || - vis->Style.BaseColormap > SpecialColormaps.Last().Colormap) + if (vis->Style.BaseColormap < &SpecialColormaps[0] || + vis->Style.BaseColormap > &SpecialColormaps.Last()) { noaccel = true; } // Has the basecolormap changed? If so, we can't hardware accelerate it, // since we don't know what it is anymore. - else if (vis->Style.BaseColormap < mybasecolormap->Maps || - vis->Style.BaseColormap >= mybasecolormap->Maps + NUMCOLORMAPS*256) + else if (vis->Style.BaseColormap != mybasecolormap) { noaccel = true; } @@ -1479,13 +1478,13 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double } // If we're drawing with a special colormap, but shaders for them are disabled, do // not accelerate. - if (!r_shadercolormaps && (vis->Style.BaseColormap >= SpecialColormaps[0].Colormap && - vis->Style.BaseColormap <= SpecialColormaps.Last().Colormap)) + if (!r_shadercolormaps && (vis->Style.BaseColormap >= &SpecialColormaps[0] && + vis->Style.BaseColormap <= &SpecialColormaps.Last())) { noaccel = true; } // If drawing with a BOOM colormap, disable acceleration. - if (mybasecolormap == &NormalLight && NormalLight.Maps != realcolormaps) + if (mybasecolormap == &NormalLight && NormalLight.Maps != realcolormaps.Maps) { noaccel = true; } @@ -1502,7 +1501,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double else { colormap_to_use = basecolormap; - vis->Style.BaseColormap = basecolormap->Maps; + vis->Style.BaseColormap = basecolormap; vis->Style.ColormapNum = 0; vis->Style.RenderStyle = STYLE_Normal; } @@ -1649,12 +1648,10 @@ void R_DrawRemainingPlayerSprites() FColormapStyle colormapstyle; bool usecolormapstyle = false; - if (vis->Style.BaseColormap >= SpecialColormaps[0].Colormap && - vis->Style.BaseColormap < SpecialColormaps[SpecialColormaps.Size()].Colormap) + if (vis->Style.BaseColormap >= &SpecialColormaps[0] && + vis->Style.BaseColormap < &SpecialColormaps[SpecialColormaps.Size()]) { - // Yuck! There needs to be a better way to store colormaps in the vissprite... :( - ptrdiff_t specialmap = (vis->Style.BaseColormap - SpecialColormaps[0].Colormap) / sizeof(FSpecialColormap) + vis->Style.ColormapNum; - special = &SpecialColormaps[specialmap]; + special = static_cast(vis->Style.BaseColormap); } else if (colormap->Color == PalEntry(255,255,255) && colormap->Desaturate == 0) @@ -1912,7 +1909,7 @@ void R_DrawSprite (vissprite_t *spr) int r1, r2; short topclip, botclip; short *clip1, *clip2; - lighttable_t *colormap = spr->Style.BaseColormap; + FColormap *colormap = spr->Style.BaseColormap; int colormapnum = spr->Style.ColormapNum; F3DFloor *rover; FDynamicColormap *mybasecolormap; @@ -2010,18 +2007,18 @@ void R_DrawSprite (vissprite_t *spr) } if (fixedlightlev >= 0) { - spr->Style.BaseColormap = mybasecolormap->Maps; + spr->Style.BaseColormap = mybasecolormap; spr->Style.ColormapNum = fixedlightlev >> COLORMAPSHIFT; } else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) { // full bright - spr->Style.BaseColormap = mybasecolormap->Maps; + spr->Style.BaseColormap = mybasecolormap; spr->Style.ColormapNum = 0; } else { // diminished light spriteshade = LIGHT2SHADE(sec->lightlevel + r_actualextralight); - spr->Style.BaseColormap = mybasecolormap->Maps; + spr->Style.BaseColormap = mybasecolormap; spr->Style.ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(MINZ, (double)spr->depth), spriteshade); } } @@ -2438,7 +2435,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, int x1, x2, y1, y2; vissprite_t* vis; sector_t* heightsec = NULL; - BYTE* map; + FColormap* map; // [ZZ] Particle not visible through the portal plane if (CurrentPortal && !!P_PointOnLineSide(particle->Pos, CurrentPortal->dst)) @@ -2511,7 +2508,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, botplane = &heightsec->ceilingplane; toppic = sector->GetTexture(sector_t::ceiling); botpic = heightsec->GetTexture(sector_t::ceiling); - map = heightsec->ColorMap->Maps; + map = heightsec->ColorMap; } else if (fakeside == FAKED_BelowFloor) { @@ -2519,7 +2516,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, botplane = §or->floorplane; toppic = heightsec->GetTexture(sector_t::floor); botpic = sector->GetTexture(sector_t::floor); - map = heightsec->ColorMap->Maps; + map = heightsec->ColorMap; } else { @@ -2527,7 +2524,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, botplane = &heightsec->floorplane; toppic = heightsec->GetTexture(sector_t::ceiling); botpic = heightsec->GetTexture(sector_t::floor); - map = sector->ColorMap->Maps; + map = sector->ColorMap; } } else @@ -2536,7 +2533,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, botplane = §or->floorplane; toppic = sector->GetTexture(sector_t::ceiling); botpic = sector->GetTexture(sector_t::floor); - map = sector->ColorMap->Maps; + map = sector->ColorMap; } if (botpic != skyflatnum && particle->Pos.Z < botplane->ZatPoint (particle->Pos)) @@ -2619,7 +2616,7 @@ void R_DrawParticle_C (vissprite_t *vis) { int spacing; BYTE *dest; - BYTE color = vis->Style.BaseColormap[(vis->Style.ColormapNum << COLORMAPSHIFT) + vis->startfrac]; + BYTE color = vis->Style.BaseColormap->Maps[(vis->Style.ColormapNum << COLORMAPSHIFT) + vis->startfrac]; int yl = vis->y1; int ycount = vis->y2 - yl + 1; int x1 = vis->x1; @@ -2685,7 +2682,7 @@ void R_DrawParticle_RGBA(vissprite_t *vis) { int spacing; uint32_t *dest; - BYTE color = vis->Style.BaseColormap[vis->startfrac]; + BYTE color = vis->Style.BaseColormap->Maps[vis->startfrac]; int yl = vis->y1; int ycount = vis->y2 - yl + 1; int x1 = vis->x1; @@ -2693,7 +2690,7 @@ void R_DrawParticle_RGBA(vissprite_t *vis) R_DrawMaskedSegsBehindParticle(vis); - uint32_t fg = shade_pal_index(color, calc_light_multiplier(LIGHTSCALE(0, vis->Style.ColormapNum << FRACBITS))); + uint32_t fg = shade_pal_index_simple(color, calc_light_multiplier(LIGHTSCALE(0, vis->Style.ColormapNum << FRACBITS))); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 71d3f2376..efc901ca5 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -889,11 +889,11 @@ void R_SetupFrame (AActor *actor) BaseBlendG = GPART(newblend); BaseBlendB = BPART(newblend); BaseBlendA = APART(newblend) / 255.f; - NormalLight.Maps = realcolormaps; + NormalLight.Maps = realcolormaps.Maps; } else { - NormalLight.Maps = realcolormaps + NUMCOLORMAPS*256*newblend; + NormalLight.Maps = realcolormaps.Maps + NUMCOLORMAPS*256*newblend; BaseBlendR = BaseBlendG = BaseBlendB = 0; BaseBlendA = 0.f; } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index ff0427b34..c2dbf31c5 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -171,14 +171,14 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) if (translation != NULL) { - R_SetColorMapLight((lighttable_t *)translation, 0, 0); + R_SetTranslationMap((lighttable_t *)translation); } else { - R_SetColorMapLight(identitymap, 0, 0); + R_SetTranslationMap(identitymap); } - fixedcolormap = dc_colormap; + fixedcolormap = dc_fcolormap; ESPSResult mode = R_SetPatchStyle (parms.style, parms.Alpha, 0, parms.fillcolor); BYTE *destorgsave = dc_destorg; @@ -1025,7 +1025,7 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) { uint32_t *spot = (uint32_t*)GetBuffer() + oldyyshifted + xx; - uint32_t fg = shade_pal_index(basecolor, calc_light_multiplier(0)); + uint32_t fg = shade_pal_index_simple(basecolor, calc_light_multiplier(0)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -1394,7 +1394,10 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, // Setup constant texture mapping parameters. R_SetupSpanBits(tex); - R_SetSpanColormap(colormap != NULL ? &colormap->Maps[clamp(shade >> FRACBITS, 0, NUMCOLORMAPS-1) * 256] : identitymap); + if (colormap) + R_SetSpanColormap(colormap, clamp(shade >> FRACBITS, 0, NUMCOLORMAPS - 1)); + else + R_SetSpanColormap(&identitycolormap, 0); R_SetSpanSource(tex->GetPixels()); scalex = double(1u << (32 - ds_xbits)) / scalex; scaley = double(1u << (32 - ds_ybits)) / scaley; From c058ab9cc9ac17a23a86964387e9f138359935f1 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 5 Jun 2016 17:34:51 +0200 Subject: [PATCH 0630/1509] Fixed non-standard __m128i usage in SSE_SHADE --- src/r_main.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/r_main.h b/src/r_main.h index 0db704df1..5266fb52c 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -226,8 +226,8 @@ FORCEINLINE uint32_t shade_pal_index(uint32_t index, uint32_t light, const Shade __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); \ \ __m128i intensity_hi = _mm_mullo_epi16(fg_hi, _mm_set_epi16(0, 77, 143, 37, 0, 77, 143, 37)); \ - uint16_t intensity_hi0 = ((intensity_hi.m128i_u16[2] + intensity_hi.m128i_u16[1] + intensity_hi.m128i_u16[0]) >> 8) * shade_constants.desaturate; \ - uint16_t intensity_hi1 = ((intensity_hi.m128i_u16[6] + intensity_hi.m128i_u16[5] + intensity_hi.m128i_u16[4]) >> 8) * shade_constants.desaturate; \ + uint16_t intensity_hi0 = ((_mm_extract_epi16(intensity_hi, 2) + _mm_extract_epi16(intensity_hi, 1) + _mm_extract_epi16(intensity_hi, 0)) >> 8) * shade_constants.desaturate; \ + uint16_t intensity_hi1 = ((_mm_extract_epi16(intensity_hi, 6) + _mm_extract_epi16(intensity_hi, 5) + _mm_extract_epi16(intensity_hi, 4)) >> 8) * shade_constants.desaturate; \ intensity_hi = _mm_set_epi16(intensity_hi1, intensity_hi1, intensity_hi1, intensity_hi1, intensity_hi0, intensity_hi0, intensity_hi0, intensity_hi0); \ \ fg_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, inv_desaturate), intensity_hi), 8); \ @@ -235,8 +235,8 @@ FORCEINLINE uint32_t shade_pal_index(uint32_t index, uint32_t light, const Shade fg_hi = _mm_srli_epi16(_mm_mullo_epi16(fg_hi, color), 8); \ \ __m128i intensity_lo = _mm_mullo_epi16(fg_lo, _mm_set_epi16(0, 77, 143, 37, 0, 77, 143, 37)); \ - uint16_t intensity_lo0 = ((intensity_lo.m128i_u16[2] + intensity_lo.m128i_u16[1] + intensity_lo.m128i_u16[0]) >> 8) * shade_constants.desaturate; \ - uint16_t intensity_lo1 = ((intensity_lo.m128i_u16[6] + intensity_lo.m128i_u16[5] + intensity_lo.m128i_u16[4]) >> 8) * shade_constants.desaturate; \ + uint16_t intensity_lo0 = ((_mm_extract_epi16(intensity_lo, 2) + _mm_extract_epi16(intensity_lo, 1) + _mm_extract_epi16(intensity_lo, 0)) >> 8) * shade_constants.desaturate; \ + uint16_t intensity_lo1 = ((_mm_extract_epi16(intensity_lo, 6) + _mm_extract_epi16(intensity_lo, 5) + _mm_extract_epi16(intensity_lo, 4)) >> 8) * shade_constants.desaturate; \ intensity_lo = _mm_set_epi16(intensity_lo1, intensity_lo1, intensity_lo1, intensity_lo1, intensity_lo0, intensity_lo0, intensity_lo0, intensity_lo0); \ \ fg_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, inv_desaturate), intensity_lo), 8); \ From c176d38b7e8992f006a99950a249848ba0a0f039 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 5 Jun 2016 19:41:08 +0300 Subject: [PATCH 0631/1509] Fixed compilation with Clang --- src/r_draw.cpp | 4 ++-- src/r_main.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 2e21c7038..e809342e9 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -5076,7 +5076,7 @@ void R_SetColorMapLight(FColormap *base_colormap, float light, int shade) dc_shade_constants.fade_green = dc_fcolormap->Fade.g; dc_shade_constants.fade_blue = dc_fcolormap->Fade.b; dc_shade_constants.fade_alpha = dc_fcolormap->Fade.a; - dc_shade_constants.desaturate = MIN(std::abs(dc_fcolormap->Desaturate), 255) * 255 / 256; + dc_shade_constants.desaturate = MIN(abs(dc_fcolormap->Desaturate), 255) * 255 / 256; dc_shade_constants.simple_shade = (dc_fcolormap->Color.d == 0x00ffffff && dc_fcolormap->Fade.d == 0x00000000 && dc_fcolormap->Desaturate == 0); if (r_swtruecolor) { @@ -5101,7 +5101,7 @@ void R_SetDSColorMapLight(FColormap *base_colormap, float light, int shade) ds_shade_constants.fade_green = ds_fcolormap->Fade.g; ds_shade_constants.fade_blue = ds_fcolormap->Fade.b; ds_shade_constants.fade_alpha = ds_fcolormap->Fade.a; - ds_shade_constants.desaturate = MIN(std::abs(ds_fcolormap->Desaturate), 255) * 255 / 256; + ds_shade_constants.desaturate = MIN(abs(ds_fcolormap->Desaturate), 255) * 255 / 256; ds_shade_constants.simple_shade = (ds_fcolormap->Color.d == 0x00ffffff && ds_fcolormap->Fade.d == 0x00000000 && ds_fcolormap->Desaturate == 0); if (r_swtruecolor) { diff --git a/src/r_main.h b/src/r_main.h index 5266fb52c..5d4ff1174 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -115,7 +115,7 @@ inline uint32_t calc_light_multiplier(dsfixed_t light) #if defined(_MSC_VER) #define FORCEINLINE __forceinline #elif defined(__GNUC__) -#define FORCEINLINE __attribute__((always_inline)) +#define FORCEINLINE __attribute__((always_inline)) inline #else #define FORCEINLINE inline #endif From e58c6de7d68cb6c901a85a676bcae2243c524d51 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Sun, 5 Jun 2016 15:14:40 -0500 Subject: [PATCH 0632/1509] DONTFLIP flag prevents the backside from flipping over. --- src/gl/scene/gl_sprite.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 2301fc7ba..37d9ebd82 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -279,6 +279,7 @@ void GLSprite::Draw(int pass) // [Nash] is a flat sprite const bool isFlatSprite = (actor != NULL) && (spritetype == RF_WALLSPRITE || spritetype == RF_FLATSPRITE); + const bool dontFlip = (actor != nullptr) && (actor->renderflags & RF_DONTFLIP); // [Nash] check for special sprite drawing modes if (drawWithXYBillboard || drawBillboardFacingCamera || drawRollSpriteActor || isFlatSprite) @@ -327,8 +328,12 @@ void GLSprite::Draw(int pass) // Here we need some form of priority in order to work. if (spritetype == RF_FLATSPRITE) { + DVector3 diff = actor->Vec3To(GLRenderer->mViewActor); + DAngle angto = diff.Angle(); + angto = deltaangle(actor->Angles.Yaw, angto); + float pitchDegrees = actor->Angles.Pitch.Degrees; - mat.Rotate(0, 1, 0, 0); + mat.Rotate(0, 1, 0, (!dontFlip || (fabs(angto) < 90.)) ? 0 : 180); mat.Rotate(-yawvecY, 0, yawvecX, pitchDegrees); if (drawRollSpriteActor) { From b2d2389343cbd2ac8247a321cf229a22bb14956d Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Sun, 5 Jun 2016 15:21:19 -0500 Subject: [PATCH 0633/1509] Fixed: Slanted flat + roll sprites didn't take DONTFLIP into account. --- src/gl/scene/gl_sprite.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 37d9ebd82..fb6d6b411 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -333,11 +333,12 @@ void GLSprite::Draw(int pass) angto = deltaangle(actor->Angles.Yaw, angto); float pitchDegrees = actor->Angles.Pitch.Degrees; - mat.Rotate(0, 1, 0, (!dontFlip || (fabs(angto) < 90.)) ? 0 : 180); - mat.Rotate(-yawvecY, 0, yawvecX, pitchDegrees); + bool noFlipSprite = (!dontFlip || (fabs(angto) < 90.)); + mat.Rotate(0, 1, 0, (noFlipSprite) ? 0 : 180); + mat.Rotate(-yawvecY, 0, yawvecX, (noFlipSprite) ? -pitchDegrees : pitchDegrees); if (drawRollSpriteActor) { - mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); + mat.Rotate(yawvecX, 0, yawvecY, (noFlipSprite) ? -rollDegrees : rollDegrees); } } // [fgsfds] Rotate the sprite about the sight vector (roll) From c5fcfb664f210996eadc22e20c036b50b4064abb Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 7 Jun 2016 00:55:52 +0200 Subject: [PATCH 0634/1509] Changed rgba renderer to use a command queue system for its drawers --- src/CMakeLists.txt | 1 + src/r_draw.cpp | 2273 +-------------------------- src/r_draw.h | 95 +- src/r_draw_rgba.cpp | 3492 ++++++++++++++++++++++++++++++++++++++++++ src/r_drawt.cpp | 8 + src/r_drawt_rgba.cpp | 2633 ++++++++++++++++++------------- src/r_main.cpp | 2 + src/r_swrenderer.cpp | 1 + src/r_things.cpp | 5 +- 9 files changed, 5189 insertions(+), 3321 deletions(-) create mode 100644 src/r_draw_rgba.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c90756b5d..75cf27cad 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -882,6 +882,7 @@ set( FASTMATH_PCH_SOURCES r_3dfloors.cpp r_bsp.cpp r_draw.cpp + r_draw_rgba.cpp r_drawt.cpp r_drawt_rgba.cpp r_main.cpp diff --git a/src/r_draw.cpp b/src/r_draw.cpp index e809342e9..984a74f3f 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -43,9 +43,6 @@ #include "gi.h" #include "stats.h" #include "x86.h" -#ifndef NO_SSE -#include -#endif #undef RANGECHECK @@ -135,6 +132,7 @@ void (*rt_tlateaddclamp4cols)(int sx, int yl, int yh); void (*rt_tlatesubclamp4cols)(int sx, int yl, int yh); void (*rt_tlaterevsubclamp4cols)(int sx, int yl, int yh); void (*rt_initcols)(BYTE *buffer); +void (*rt_span_coverage)(int x, int start, int stop); // // R_DrawColumn @@ -287,51 +285,6 @@ void R_DrawColumnP_C (void) } #endif -void R_DrawColumnP_RGBA_C() -{ - int count; - uint32_t* dest; - fixed_t frac; - fixed_t fracstep; - - count = dc_count; - - // Zero length, column does not exceed a pixel. - if (count <= 0) - return; - - // Framebuffer destination address. - dest = (uint32_t*)dc_dest; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - // Determine scaling, - // which is the only mapping to be done. - fracstep = dc_iscale; - frac = dc_texturefrac; - - { - // [RH] Get local copies of these variables so that the compiler - // has a better chance of optimizing this well. - BYTE *colormap = dc_colormap; - const BYTE *source = dc_source; - int pitch = dc_pitch; - - // Inner loop that does the actual texture mapping, - // e.g. a DDA-lile scaling. - // This is as fast as it gets. - do - { - *dest = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); - - dest += pitch; - frac += fracstep; - - } while (--count); - } -} - // [RH] Just fills a column with a color void R_FillColumnP_C (void) { @@ -357,32 +310,6 @@ void R_FillColumnP_C (void) } } -void R_FillColumnP_RGBA() -{ - int count; - uint32_t* dest; - - count = dc_count; - - if (count <= 0) - return; - - dest = (uint32_t*)dc_dest; - - uint32_t light = calc_light_multiplier(dc_light); - - { - int pitch = dc_pitch; - BYTE color = dc_color; - - do - { - *dest = shade_pal_index_simple(color, light); - dest += pitch; - } while (--count); - } -} - void R_FillAddColumn_C (void) { int count; @@ -410,38 +337,6 @@ void R_FillAddColumn_C (void) } while (--count); } -void R_FillAddColumn_RGBA_C() -{ - int count; - uint32_t *dest; - - count = dc_count; - if (count <= 0) - return; - - dest = (uint32_t*)dc_dest; - int pitch = dc_pitch; - - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); - uint32_t fg_red = (fg >> 24) & 0xff; - uint32_t fg_green = (fg >> 16) & 0xff; - uint32_t fg_blue = fg & 0xff; - - do - { - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--count); -} - void R_FillAddClampColumn_C (void) { int count; @@ -475,38 +370,6 @@ void R_FillAddClampColumn_C (void) } while (--count); } -void R_FillAddClampColumn_RGBA() -{ - int count; - uint32_t *dest; - - count = dc_count; - if (count <= 0) - return; - - dest = (uint32_t*)dc_dest; - int pitch = dc_pitch; - - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); - uint32_t fg_red = (fg >> 24) & 0xff; - uint32_t fg_green = (fg >> 16) & 0xff; - uint32_t fg_blue = fg & 0xff; - - do - { - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--count); -} - void R_FillSubClampColumn_C (void) { int count; @@ -539,38 +402,6 @@ void R_FillSubClampColumn_C (void) } while (--count); } -void R_FillSubClampColumn_RGBA() -{ - int count; - uint32_t *dest; - - count = dc_count; - if (count <= 0) - return; - - dest = (uint32_t*)dc_dest; - int pitch = dc_pitch; - - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); - uint32_t fg_red = (fg >> 24) & 0xff; - uint32_t fg_green = (fg >> 16) & 0xff; - uint32_t fg_blue = fg & 0xff; - - do - { - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 255; - uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 255; - uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 255; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--count); -} - void R_FillRevSubClampColumn_C (void) { int count; @@ -603,42 +434,9 @@ void R_FillRevSubClampColumn_C (void) } while (--count); } -void R_FillRevSubClampColumn_RGBA() -{ - int count; - uint32_t *dest; - - count = dc_count; - if (count <= 0) - return; - - dest = (uint32_t*)dc_dest; - int pitch = dc_pitch; - - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); - uint32_t fg_red = (fg >> 24) & 0xff; - uint32_t fg_green = (fg >> 16) & 0xff; - uint32_t fg_blue = fg & 0xff; - - do - { - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 255; - uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 255; - uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 255; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--count); -} - // // Spectre/Invisibility. // -#define FUZZTABLE 50 extern "C" { @@ -754,105 +552,6 @@ void R_DrawFuzzColumnP_C (void) } #endif -void R_DrawFuzzColumnP_RGBA_C() -{ - int count; - uint32_t *dest; - - // Adjust borders. Low... - if (dc_yl == 0) - dc_yl = 1; - - // .. and high. - if (dc_yh > fuzzviewheight) - dc_yh = fuzzviewheight; - - count = dc_yh - dc_yl; - - // Zero length. - if (count < 0) - return; - - count++; - - dest = ylookup[dc_yl] + dc_x + (uint32_t*)dc_destorg; - - // Note: this implementation assumes this function is only used for the pinky shadow effect (i.e. no other fancy colormap than black) - // I'm not sure if this is really always the case or not. - - { - // [RH] Make local copies of global vars to try and improve - // the optimizations made by the compiler. - int pitch = dc_pitch; - int fuzz = fuzzpos; - int cnt; - - // [RH] Split this into three separate loops to minimize - // the number of times fuzzpos needs to be clamped. - if (fuzz) - { - cnt = MIN(FUZZTABLE - fuzz, count); - count -= cnt; - do - { - uint32_t bg = dest[fuzzoffset[fuzz++]]; - uint32_t bg_red = (bg >> 16) & 0xff; - uint32_t bg_green = (bg >> 8) & 0xff; - uint32_t bg_blue = (bg) & 0xff; - - uint32_t red = bg_red * 3 / 4; - uint32_t green = bg_green * 3 / 4; - uint32_t blue = bg_blue * 3 / 4; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--cnt); - } - if (fuzz == FUZZTABLE || count > 0) - { - while (count >= FUZZTABLE) - { - fuzz = 0; - cnt = FUZZTABLE; - count -= FUZZTABLE; - do - { - uint32_t bg = dest[fuzzoffset[fuzz++]]; - uint32_t bg_red = (bg >> 16) & 0xff; - uint32_t bg_green = (bg >> 8) & 0xff; - uint32_t bg_blue = (bg) & 0xff; - - uint32_t red = bg_red * 3 / 4; - uint32_t green = bg_green * 3 / 4; - uint32_t blue = bg_blue * 3 / 4; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--cnt); - } - fuzz = 0; - if (count > 0) - { - do - { - uint32_t bg = dest[fuzzoffset[fuzz++]]; - uint32_t bg_red = (bg >> 16) & 0xff; - uint32_t bg_green = (bg >> 8) & 0xff; - uint32_t bg_blue = (bg) & 0xff; - - uint32_t red = bg_red * 3 / 4; - uint32_t green = bg_green * 3 / 4; - uint32_t blue = bg_blue * 3 / 4; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--count); - } - } - fuzzpos = fuzz; - } -} - // // R_DrawTranlucentColumn // @@ -937,56 +636,6 @@ void R_DrawAddColumnP_C (void) } } -void R_DrawAddColumnP_RGBA_C() -{ - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = dc_count; - if (count <= 0) - return; - - dest = (uint32_t*)dc_dest; - - fracstep = dc_iscale; - frac = dc_texturefrac; - - { - const BYTE *source = dc_source; - int pitch = dc_pitch; - BYTE *colormap = dc_colormap; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); - - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } -} - // // R_DrawTranslatedColumn // Used to draw player sprites with the green colorramp mapped to others. @@ -1027,40 +676,6 @@ void R_DrawTranslatedColumnP_C (void) } } -void R_DrawTranslatedColumnP_RGBA_C() -{ - int count; - uint32_t* dest; - fixed_t frac; - fixed_t fracstep; - - count = dc_count; - if (count <= 0) - return; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - dest = (uint32_t*)dc_dest; - - fracstep = dc_iscale; - frac = dc_texturefrac; - - { - // [RH] Local copies of global vars to improve compiler optimizations - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch; - - do - { - *dest = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); - dest += pitch; - frac += fracstep; - } while (--count); - } -} - // Draw a column that is both translated and translucent void R_DrawTlatedAddColumnP_C() { @@ -1101,56 +716,6 @@ void R_DrawTlatedAddColumnP_C() } } -void R_DrawTlatedAddColumnP_RGBA_C() -{ - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = dc_count; - if (count <= 0) - return; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - dest = (uint32_t*)dc_dest; - - fracstep = dc_iscale; - frac = dc_texturefrac; - - { - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); - - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } -} - // Draw a column whose "color" values are actually translucency // levels for a base color stored in dc_color. void R_DrawShadedColumnP_C (void) @@ -1188,52 +753,6 @@ void R_DrawShadedColumnP_C (void) } } -void R_DrawShadedColumnP_RGBA_C() -{ - int count; - uint32_t *dest; - fixed_t frac, fracstep; - - count = dc_count; - - if (count <= 0) - return; - - dest = (uint32_t*)dc_dest; - - fracstep = dc_iscale; - frac = dc_texturefrac; - - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - { - const BYTE *source = dc_source; - BYTE *colormap = dc_colormap; - int pitch = dc_pitch; - - do - { - DWORD alpha = clamp(colormap[source[frac >> FRACBITS]], 0, 64); - DWORD inv_alpha = 64 - alpha; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; - uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; - uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } -} - // Add source to destination, clamping it to white void R_DrawAddClampColumnP_C () { @@ -1275,53 +794,6 @@ void R_DrawAddClampColumnP_C () } } -void R_DrawAddClampColumnP_RGBA_C() -{ - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = dc_count; - if (count <= 0) - return; - - dest = (uint32_t*)dc_dest; - - fracstep = dc_iscale; - frac = dc_texturefrac; - - { - const BYTE *source = dc_source; - int pitch = dc_pitch; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } -} - // Add translated source to destination, clamping it to white void R_DrawAddClampTranslatedColumnP_C () { @@ -1364,54 +836,6 @@ void R_DrawAddClampTranslatedColumnP_C () } } -void R_DrawAddClampTranslatedColumnP_RGBA_C() -{ - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = dc_count; - if (count <= 0) - return; - - dest = (uint32_t*)dc_dest; - - fracstep = dc_iscale; - frac = dc_texturefrac; - - { - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } -} - // Subtract destination from source, clamping it to black void R_DrawSubClampColumnP_C () { @@ -1452,53 +876,6 @@ void R_DrawSubClampColumnP_C () } } -void R_DrawSubClampColumnP_RGBA_C() -{ - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = dc_count; - if (count <= 0) - return; - - dest = (uint32_t*)dc_dest; - - fracstep = dc_iscale; - frac = dc_texturefrac; - - { - const BYTE *source = dc_source; - int pitch = dc_pitch; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } -} - // Subtract destination from source, clamping it to black void R_DrawSubClampTranslatedColumnP_C () { @@ -1540,54 +917,6 @@ void R_DrawSubClampTranslatedColumnP_C () } } -void R_DrawSubClampTranslatedColumnP_RGBA_C() -{ - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = dc_count; - if (count <= 0) - return; - - dest = (uint32_t*)dc_dest; - - fracstep = dc_iscale; - frac = dc_texturefrac; - - { - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } -} - // Subtract source from destination, clamping it to black void R_DrawRevSubClampColumnP_C () { @@ -1628,52 +957,6 @@ void R_DrawRevSubClampColumnP_C () } } -void R_DrawRevSubClampColumnP_RGBA_C() -{ - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = dc_count; - if (count <= 0) - return; - - dest = (uint32_t*)dc_dest; - - fracstep = dc_iscale; - frac = dc_texturefrac; - - { - const BYTE *source = dc_source; - int pitch = dc_pitch; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } -} - // Subtract source from destination, clamping it to black void R_DrawRevSubClampTranslatedColumnP_C () { @@ -1715,55 +998,6 @@ void R_DrawRevSubClampTranslatedColumnP_C () } } -void R_DrawRevSubClampTranslatedColumnP_RGBA_C() -{ - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = dc_count; - if (count <= 0) - return; - - dest = (uint32_t*)dc_dest; - - fracstep = dc_iscale; - frac = dc_texturefrac; - - { - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } -} - - // // R_DrawSpan // With DOOM style restrictions on view orientation, @@ -1957,233 +1191,6 @@ void R_DrawSpanP_C (void) } #endif -void R_DrawSpanP_RGBA_C() -{ - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const BYTE* source = ds_source; - int count; - int spot; - -#ifdef RANGECHECK - if (ds_x2 < ds_x1 || ds_x1 < 0 - || ds_x2 >= screen->width || ds_y > screen->height) - { - I_Error("R_DrawSpan: %i to %i at %i", ds_x1, ds_x2, ds_y); - } - // dscount++; -#endif - - xfrac = ds_xfrac; - yfrac = ds_yfrac; - - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; - - count = ds_x2 - ds_x1 + 1; - - xstep = ds_xstep; - ystep = ds_ystep; - - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; - - if (ds_xbits == 6 && ds_ybits == 6) - { - // 64x64 is the most common case by far, so special case it. - - do - { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - - // Lookup pixel from flat texture tile - *dest++ = shade_pal_index(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - else - { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; - - do - { - // Current texture index in u,v. - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - - // Lookup pixel from flat texture tile - *dest++ = shade_pal_index(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); - } -} - -#ifndef NO_SSE -void R_DrawSpanP_RGBA_SSE() -{ - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const BYTE* source = ds_source; - int count; - int spot; - -#ifdef RANGECHECK - if (ds_x2 < ds_x1 || ds_x1 < 0 - || ds_x2 >= screen->width || ds_y > screen->height) - { - I_Error("R_DrawSpan: %i to %i at %i", ds_x1, ds_x2, ds_y); - } - // dscount++; -#endif - - xfrac = ds_xfrac; - yfrac = ds_yfrac; - - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; - - count = ds_x2 - ds_x1 + 1; - - xstep = ds_xstep; - ystep = ds_ystep; - - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; - - if (ds_xbits == 6 && ds_ybits == 6) - { - // 64x64 is the most common case by far, so special case it. - - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - - int sse_count = count / 4; - count -= sse_count * 4; - - if (shade_constants.simple_shade) - { - SSE_SHADE_SIMPLE_INIT(light); - - while (sse_count--) - { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p0 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p1 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p2 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p3 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - - // Next step in u,v. - dest += 4; - } - } - else - { - SSE_SHADE_INIT(light, shade_constants); - - while (sse_count--) - { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p0 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p1 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p2 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p3 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - - // Next step in u,v. - dest += 4; - } - } - - if (count == 0) - return; - - do - { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - - // Lookup pixel from flat texture tile - *dest++ = shade_pal_index(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - else - { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; - - do - { - // Current texture index in u,v. - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - - // Lookup pixel from flat texture tile - *dest++ = shade_pal_index(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); - } -} -#endif - #ifndef X86_ASM // [RH] Draw a span with holes @@ -2250,72 +1257,6 @@ void R_DrawSpanMaskedP_C (void) } #endif -void R_DrawSpanMaskedP_RGBA_C() -{ - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const BYTE* source = ds_source; - const BYTE* colormap = ds_colormap; - int count; - int spot; - - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; - - xfrac = ds_xfrac; - yfrac = ds_yfrac; - - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; - - count = ds_x2 - ds_x1 + 1; - - xstep = ds_xstep; - ystep = ds_ystep; - - if (ds_xbits == 6 && ds_ybits == 6) - { - // 64x64 is the most common case by far, so special case it. - do - { - BYTE texdata; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - texdata = source[spot]; - if (texdata != 0) - { - *dest = shade_pal_index(texdata, light, shade_constants); - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - else - { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; - do - { - BYTE texdata; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - texdata = source[spot]; - if (texdata != 0) - { - *dest = shade_pal_index(texdata, light, shade_constants); - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); - } -} - - void R_DrawSpanTranslucentP_C (void) { dsfixed_t xfrac; @@ -2378,89 +1319,6 @@ void R_DrawSpanTranslucentP_C (void) } } -void R_DrawSpanTranslucentP_RGBA_C() -{ - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const BYTE* source = ds_source; - int count; - int spot; - - xfrac = ds_xfrac; - yfrac = ds_yfrac; - - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; - - count = ds_x2 - ds_x1 + 1; - - xstep = ds_xstep; - ystep = ds_ystep; - - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - if (ds_xbits == 6 && ds_ybits == 6) - { - // 64x64 is the most common case by far, so special case it. - do - { - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - - uint32_t fg = shade_pal_index(source[spot], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; - uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; - uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; - - *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; - - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - else - { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; - do - { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - - uint32_t fg = shade_pal_index(source[spot], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; - uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; - uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; - - *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; - - xfrac += xstep; - yfrac += ystep; - } while (--count); - } -} - void R_DrawSpanMaskedTranslucentP_C (void) { dsfixed_t xfrac; @@ -2537,99 +1395,6 @@ void R_DrawSpanMaskedTranslucentP_C (void) } } -void R_DrawSpanMaskedTranslucentP_RGBA_C() -{ - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const BYTE* source = ds_source; - int count; - int spot; - - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - xfrac = ds_xfrac; - yfrac = ds_yfrac; - - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; - - count = ds_x2 - ds_x1 + 1; - - xstep = ds_xstep; - ystep = ds_ystep; - - if (ds_xbits == 6 && ds_ybits == 6) - { - // 64x64 is the most common case by far, so special case it. - do - { - BYTE texdata; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - texdata = source[spot]; - if (texdata != 0) - { - uint32_t fg = shade_pal_index(texdata, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; - uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; - uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - else - { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; - do - { - BYTE texdata; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - texdata = source[spot]; - if (texdata != 0) - { - uint32_t fg = shade_pal_index(texdata, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; - uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; - uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); - } -} - void R_DrawSpanAddClampP_C (void) { dsfixed_t xfrac; @@ -2700,88 +1465,6 @@ void R_DrawSpanAddClampP_C (void) } } -void R_DrawSpanAddClampP_RGBA_C() -{ - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const BYTE* source = ds_source; - int count; - int spot; - - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - xfrac = ds_xfrac; - yfrac = ds_yfrac; - - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; - - count = ds_x2 - ds_x1 + 1; - - xstep = ds_xstep; - ystep = ds_ystep; - - if (ds_xbits == 6 && ds_ybits == 6) - { - // 64x64 is the most common case by far, so special case it. - do - { - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - - uint32_t fg = shade_pal_index(source[spot], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; - - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - else - { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; - do - { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - - uint32_t fg = shade_pal_index(source[spot], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; - - xfrac += xstep; - yfrac += ystep; - } while (--count); - } -} void R_DrawSpanMaskedAddClampP_C (void) { @@ -2865,114 +1548,12 @@ void R_DrawSpanMaskedAddClampP_C (void) } } -void R_DrawSpanMaskedAddClampP_RGBA_C() -{ - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const BYTE* source = ds_source; - int count; - int spot; - - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - xfrac = ds_xfrac; - yfrac = ds_yfrac; - - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; - - count = ds_x2 - ds_x1 + 1; - - xstep = ds_xstep; - ystep = ds_ystep; - - if (ds_xbits == 6 && ds_ybits == 6) - { - // 64x64 is the most common case by far, so special case it. - do - { - BYTE texdata; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - texdata = source[spot]; - if (texdata != 0) - { - uint32_t fg = shade_pal_index(texdata, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; - uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; - uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - else - { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; - do - { - BYTE texdata; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - texdata = source[spot]; - if (texdata != 0) - { - uint32_t fg = shade_pal_index(texdata, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; - uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; - uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); - } -} - // [RH] Just fill a span with a color void R_FillSpan_C (void) { memset (ylookup[ds_y] + ds_x1 + dc_destorg, ds_color, (ds_x2 - ds_x1 + 1)); } -void R_FillSpan_RGBA() -{ - uint32_t *dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; - int count = (ds_x2 - ds_x1 + 1); - uint32_t light = calc_light_multiplier(ds_light); - uint32_t color = shade_pal_index_simple(ds_color, light); - for (int i = 0; i < count; i++) - dest[i] = color; -} // Draw a voxel slab // @@ -3070,8 +1651,8 @@ extern "C" void R_DrawSlabC(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *v // wallscan stuff, in C -static int vlinebits; -static int mvlinebits; +int vlinebits; +int mvlinebits; #ifndef X86_ASM static DWORD vlinec1 (); @@ -3186,29 +1767,6 @@ DWORD vlinec1 () } #endif -DWORD vlinec1_RGBA() -{ - DWORD fracstep = dc_iscale; - DWORD frac = dc_texturefrac; - int count = dc_count; - const BYTE *source = dc_source; - uint32_t *dest = (uint32_t*)dc_dest; - int bits = vlinebits; - int pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - do - { - *dest = shade_pal_index(source[frac >> bits], light, shade_constants); - frac += fracstep; - dest += pitch; - } while (--count); - - return frac; -} - #if !defined(X86_ASM) void vlinec4 () { @@ -3228,113 +1786,6 @@ void vlinec4 () } #endif -void vlinec4_RGBA() -{ - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; - int bits = vlinebits; - DWORD place; - - uint32_t light0 = calc_light_multiplier(palookuplight[0]); - uint32_t light1 = calc_light_multiplier(palookuplight[1]); - uint32_t light2 = calc_light_multiplier(palookuplight[2]); - uint32_t light3 = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = dc_shade_constants; - - do - { - dest[0] = shade_pal_index(bufplce[0][(place = vplce[0]) >> bits], light0, shade_constants); vplce[0] = place + vince[0]; - dest[1] = shade_pal_index(bufplce[1][(place = vplce[1]) >> bits], light1, shade_constants); vplce[1] = place + vince[1]; - dest[2] = shade_pal_index(bufplce[2][(place = vplce[2]) >> bits], light2, shade_constants); vplce[2] = place + vince[2]; - dest[3] = shade_pal_index(bufplce[3][(place = vplce[3]) >> bits], light3, shade_constants); vplce[3] = place + vince[3]; - dest += dc_pitch; - } while (--count); -} - -#ifndef NO_SSE -void vlinec4_RGBA_SSE() -{ - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; - int bits = vlinebits; - - uint32_t light0 = calc_light_multiplier(palookuplight[0]); - uint32_t light1 = calc_light_multiplier(palookuplight[1]); - uint32_t light2 = calc_light_multiplier(palookuplight[2]); - uint32_t light3 = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - - if (shade_constants.simple_shade) - { - SSE_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); - do - { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; - - BYTE p0 = bufplce[0][place0 >> bits]; - BYTE p1 = bufplce[1][place1 >> bits]; - BYTE p2 = bufplce[2][place2 >> bits]; - BYTE p3 = bufplce[3][place3 >> bits]; - - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; - - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += dc_pitch; - } while (--count); - } - else - { - SSE_SHADE_INIT4(light3, light2, light1, light0, shade_constants); - do - { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; - - BYTE p0 = bufplce[0][place0 >> bits]; - BYTE p1 = bufplce[1][place1 >> bits]; - BYTE p2 = bufplce[2][place2 >> bits]; - BYTE p3 = bufplce[3][place3 >> bits]; - - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; - - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - dest += dc_pitch; - } while (--count); - } - - // Is this needed? Global variables makes it tricky to know.. - vplce[0] = local_vplce[0]; - vplce[1] = local_vplce[1]; - vplce[2] = local_vplce[2]; - vplce[3] = local_vplce[3]; - vince[0] = local_vince[0]; - vince[1] = local_vince[1]; - vince[2] = local_vince[2]; - vince[3] = local_vince[3]; -} -#endif - void setupmvline (int fracbits) { if (!r_swtruecolor) @@ -3380,34 +1831,6 @@ DWORD mvlinec1 () } #endif -DWORD mvlinec1_RGBA() -{ - DWORD fracstep = dc_iscale; - DWORD frac = dc_texturefrac; - BYTE *colormap = dc_colormap; - int count = dc_count; - const BYTE *source = dc_source; - uint32_t *dest = (uint32_t*)dc_dest; - int bits = mvlinebits; - int pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - do - { - BYTE pix = source[frac >> bits]; - if (pix != 0) - { - *dest = shade_pal_index(pix, light, shade_constants); - } - frac += fracstep; - dest += pitch; - } while (--count); - - return frac; -} - #if !defined(X86_ASM) void mvlinec4 () { @@ -3428,121 +1851,6 @@ void mvlinec4 () } #endif -void mvlinec4_RGBA() -{ - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; - int bits = mvlinebits; - DWORD place; - - uint32_t light0 = calc_light_multiplier(palookuplight[0]); - uint32_t light1 = calc_light_multiplier(palookuplight[1]); - uint32_t light2 = calc_light_multiplier(palookuplight[2]); - uint32_t light3 = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = dc_shade_constants; - - do - { - BYTE pix; - pix = bufplce[0][(place = vplce[0]) >> bits]; if (pix) dest[0] = shade_pal_index(pix, light0, shade_constants); vplce[0] = place + vince[0]; - pix = bufplce[1][(place = vplce[1]) >> bits]; if (pix) dest[1] = shade_pal_index(pix, light1, shade_constants); vplce[1] = place + vince[1]; - pix = bufplce[2][(place = vplce[2]) >> bits]; if (pix) dest[2] = shade_pal_index(pix, light2, shade_constants); vplce[2] = place + vince[2]; - pix = bufplce[3][(place = vplce[3]) >> bits]; if (pix) dest[3] = shade_pal_index(pix, light3, shade_constants); vplce[3] = place + vince[3]; - dest += dc_pitch; - } while (--count); -} - -#ifndef NO_SSE -void mvlinec4_RGBA_SSE() -{ - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; - int bits = vlinebits; - - uint32_t light0 = calc_light_multiplier(palookuplight[0]); - uint32_t light1 = calc_light_multiplier(palookuplight[1]); - uint32_t light2 = calc_light_multiplier(palookuplight[2]); - uint32_t light3 = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - - if (shade_constants.simple_shade) - { - SSE_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); - do - { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; - - BYTE pix0 = bufplce[0][place0 >> bits]; - BYTE pix1 = bufplce[1][place1 >> bits]; - BYTE pix2 = bufplce[2][place2 >> bits]; - BYTE pix3 = bufplce[3][place3 >> bits]; - - // movemask = !(pix == 0) - __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); - - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; - - __m128i fg = _mm_set_epi32(palette[pix3], palette[pix2], palette[pix1], palette[pix0]); - SSE_SHADE_SIMPLE(fg); - _mm_maskmoveu_si128(fg, movemask, (char*)dest); - dest += dc_pitch; - } while (--count); - } - else - { - SSE_SHADE_INIT4(light3, light2, light1, light0, shade_constants); - do - { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; - - BYTE pix0 = bufplce[0][place0 >> bits]; - BYTE pix1 = bufplce[1][place1 >> bits]; - BYTE pix2 = bufplce[2][place2 >> bits]; - BYTE pix3 = bufplce[3][place3 >> bits]; - - // movemask = !(pix == 0) - __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); - - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; - - __m128i fg = _mm_set_epi32(palette[pix3], palette[pix2], palette[pix1], palette[pix0]); - SSE_SHADE(fg, shade_constants); - _mm_maskmoveu_si128(fg, movemask, (char*)dest); - dest += dc_pitch; - } while (--count); - } - - // Is this needed? Global variables makes it tricky to know.. - vplce[0] = local_vplce[0]; - vplce[1] = local_vplce[1]; - vplce[2] = local_vplce[2]; - vplce[3] = local_vplce[3]; - vince[0] = local_vince[0]; - vince[1] = local_vince[1]; - vince[2] = local_vince[2]; - vince[3] = local_vince[3]; -} -#endif - - extern "C" short spanend[MAXHEIGHT]; extern float rw_light; extern float rw_lightstep; @@ -3666,196 +1974,6 @@ void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip) } } -static void R_DrawFogBoundarySection_RGBA(int y, int y2, int x1) -{ - BYTE *colormap = dc_colormap; - uint32_t *dest = ylookup[y] + (uint32_t*)dc_destorg; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants constants = dc_shade_constants; - - for (; y < y2; ++y) - { - int x2 = spanend[y]; - int x = x1; - do - { - uint32_t red = (dest[x] >> 16) & 0xff; - uint32_t green = (dest[x] >> 8) & 0xff; - uint32_t blue = dest[x] & 0xff; - - if (constants.simple_shade) - { - red = red * light / 256; - green = green * light / 256; - blue = blue * light / 256; - } - else - { - uint32_t inv_light = 256 - light; - uint32_t inv_desaturate = 256 - constants.desaturate; - - uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; - - red = (red * inv_desaturate + intensity) / 256; - green = (green * inv_desaturate + intensity) / 256; - blue = (blue * inv_desaturate + intensity) / 256; - - red = (constants.fade_red * inv_light + red * light) / 256; - green = (constants.fade_green * inv_light + green * light) / 256; - blue = (constants.fade_blue * inv_light + blue * light) / 256; - - red = (red * constants.light_red) / 256; - green = (green * constants.light_green) / 256; - blue = (blue * constants.light_blue) / 256; - } - - dest[x] = 0xff000000 | (red << 16) | (green << 8) | blue; - } while (++x <= x2); - dest += dc_pitch; - } -} - -static void R_DrawFogBoundaryLine_RGBA(int y, int x) -{ - int x2 = spanend[y]; - BYTE *colormap = dc_colormap; - uint32_t *dest = ylookup[y] + (uint32_t*)dc_destorg; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants constants = dc_shade_constants; - - do - { - uint32_t red = (dest[x] >> 16) & 0xff; - uint32_t green = (dest[x] >> 8) & 0xff; - uint32_t blue = dest[x] & 0xff; - - if (constants.simple_shade) - { - red = red * light / 256; - green = green * light / 256; - blue = blue * light / 256; - } - else - { - uint32_t inv_light = 256 - light; - uint32_t inv_desaturate = 256 - constants.desaturate; - - uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; - - red = (red * inv_desaturate + intensity) / 256; - green = (green * inv_desaturate + intensity) / 256; - blue = (blue * inv_desaturate + intensity) / 256; - - red = (constants.fade_red * inv_light + red * light) / 256; - green = (constants.fade_green * inv_light + green * light) / 256; - blue = (constants.fade_blue * inv_light + blue * light) / 256; - - red = (red * constants.light_red) / 256; - green = (green * constants.light_green) / 256; - blue = (blue * constants.light_blue) / 256; - } - - dest[x] = 0xff000000 | (red << 16) | (green << 8) | blue; - } while (++x <= x2); -} - -void R_DrawFogBoundary_RGBA(int x1, int x2, short *uclip, short *dclip) -{ - // To do: we do not need to create new spans when using rgba output - instead we should calculate light on a per pixel basis - - // This is essentially the same as R_MapVisPlane but with an extra step - // to create new horizontal spans whenever the light changes enough that - // we need to use a new colormap. - - double lightstep = rw_lightstep; - double light = rw_light + rw_lightstep*(x2 - x1 - 1); - int x = x2 - 1; - int t2 = uclip[x]; - int b2 = dclip[x]; - int rcolormap = GETPALOOKUP(light, wallshade); - int lcolormap; - BYTE *basecolormapdata = basecolormap->Maps; - - if (b2 > t2) - { - clearbufshort(spanend + t2, b2 - t2, x); - } - - R_SetColorMapLight(basecolormap, (float)light, wallshade); - - BYTE *fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); - - for (--x; x >= x1; --x) - { - int t1 = uclip[x]; - int b1 = dclip[x]; - const int xr = x + 1; - int stop; - - light -= rw_lightstep; - lcolormap = GETPALOOKUP(light, wallshade); - if (lcolormap != rcolormap) - { - if (t2 < b2 && rcolormap != 0) - { // Colormap 0 is always the identity map, so rendering it is - // just a waste of time. - R_DrawFogBoundarySection_RGBA(t2, b2, xr); - } - if (t1 < t2) t2 = t1; - if (b1 > b2) b2 = b1; - if (t2 < b2) - { - clearbufshort(spanend + t2, b2 - t2, x); - } - rcolormap = lcolormap; - R_SetColorMapLight(basecolormap, (float)light, wallshade); - fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); - } - else - { - if (fake_dc_colormap != basecolormapdata) - { - stop = MIN(t1, b2); - while (t2 < stop) - { - R_DrawFogBoundaryLine_RGBA(t2++, xr); - } - stop = MAX(b1, t2); - while (b2 > stop) - { - R_DrawFogBoundaryLine_RGBA(--b2, xr); - } - } - else - { - t2 = MAX(t2, MIN(t1, b2)); - b2 = MIN(b2, MAX(b1, t2)); - } - - stop = MIN(t2, b1); - while (t1 < stop) - { - spanend[t1++] = x; - } - stop = MAX(b2, t2); - while (b1 > stop) - { - spanend[--b1] = x; - } - } - - t2 = uclip[x]; - b2 = dclip[x]; - } - if (t2 < b2 && rcolormap != 0) - { - R_DrawFogBoundarySection_RGBA(t2, b2, x1); - } -} - - int tmvlinebits; void setuptmvline (int bits) @@ -3896,49 +2014,6 @@ fixed_t tmvline1_add_C () return frac; } -fixed_t tmvline1_add_RGBA() -{ - DWORD fracstep = dc_iscale; - DWORD frac = dc_texturefrac; - int count = dc_count; - const BYTE *source = dc_source; - uint32_t *dest = (uint32_t*)dc_dest; - int bits = tmvlinebits; - int pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - BYTE pix = source[frac >> bits]; - if (pix != 0) - { - uint32_t fg = shade_pal_index(pix, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } - frac += fracstep; - dest += pitch; - } while (--count); - - return frac; -} - void tmvline4_add_C () { BYTE *dest = dc_dest; @@ -3972,51 +2047,6 @@ void tmvline4_add_C () } while (--count); } -void tmvline4_add_RGBA() -{ - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; - int bits = tmvlinebits; - - uint32_t light[4]; - light[0] = calc_light_multiplier(palookuplight[0]); - light[1] = calc_light_multiplier(palookuplight[1]); - light[2] = calc_light_multiplier(palookuplight[2]); - light[3] = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - for (int i = 0; i < 4; ++i) - { - BYTE pix = bufplce[i][vplce[i] >> bits]; - if (pix != 0) - { - uint32_t fg = shade_pal_index(pix, light[i], shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - vplce[i] += vince[i]; - } - dest += dc_pitch; - } while (--count); -} - fixed_t tmvline1_addclamp_C () { DWORD fracstep = dc_iscale; @@ -4055,49 +2085,6 @@ fixed_t tmvline1_addclamp_C () return frac; } -fixed_t tmvline1_addclamp_RGBA() -{ - DWORD fracstep = dc_iscale; - DWORD frac = dc_texturefrac; - int count = dc_count; - const BYTE *source = dc_source; - uint32_t *dest = (uint32_t*)dc_dest; - int bits = tmvlinebits; - int pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - BYTE pix = source[frac >> bits]; - if (pix != 0) - { - uint32_t fg = shade_pal_index(pix, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } - frac += fracstep; - dest += pitch; - } while (--count); - - return frac; -} - void tmvline4_addclamp_C () { BYTE *dest = dc_dest; @@ -4130,51 +2117,6 @@ void tmvline4_addclamp_C () } while (--count); } -void tmvline4_addclamp_RGBA() -{ - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; - int bits = tmvlinebits; - - uint32_t light[4]; - light[0] = calc_light_multiplier(palookuplight[0]); - light[1] = calc_light_multiplier(palookuplight[1]); - light[2] = calc_light_multiplier(palookuplight[2]); - light[3] = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - for (int i = 0; i < 4; ++i) - { - BYTE pix = bufplce[i][vplce[i] >> bits]; - if (pix != 0) - { - uint32_t fg = shade_pal_index(pix, light[i], shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - vplce[i] += vince[i]; - } - dest += dc_pitch; - } while (--count); -} - fixed_t tmvline1_subclamp_C () { DWORD fracstep = dc_iscale; @@ -4210,50 +2152,6 @@ fixed_t tmvline1_subclamp_C () return frac; } -fixed_t tmvline1_subclamp_RGBA() -{ - DWORD fracstep = dc_iscale; - DWORD frac = dc_texturefrac; - BYTE *colormap = dc_colormap; - int count = dc_count; - const BYTE *source = dc_source; - uint32_t *dest = (uint32_t*)dc_dest; - int bits = tmvlinebits; - int pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - BYTE pix = source[frac >> bits]; - if (pix != 0) - { - uint32_t fg = shade_pal_index(pix, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } - frac += fracstep; - dest += pitch; - } while (--count); - - return frac; -} - void tmvline4_subclamp_C () { BYTE *dest = dc_dest; @@ -4285,51 +2183,6 @@ void tmvline4_subclamp_C () } while (--count); } -void tmvline4_subclamp_RGBA() -{ - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; - int bits = tmvlinebits; - - uint32_t light[4]; - light[0] = calc_light_multiplier(palookuplight[0]); - light[1] = calc_light_multiplier(palookuplight[1]); - light[2] = calc_light_multiplier(palookuplight[2]); - light[3] = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - for (int i = 0; i < 4; ++i) - { - BYTE pix = bufplce[i][vplce[i] >> bits]; - if (pix != 0) - { - uint32_t fg = shade_pal_index(pix, light[i], shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - vplce[i] += vince[i]; - } - dest += dc_pitch; - } while (--count); -} - fixed_t tmvline1_revsubclamp_C () { DWORD fracstep = dc_iscale; @@ -4365,50 +2218,6 @@ fixed_t tmvline1_revsubclamp_C () return frac; } -fixed_t tmvline1_revsubclamp_RGBA() -{ - DWORD fracstep = dc_iscale; - DWORD frac = dc_texturefrac; - BYTE *colormap = dc_colormap; - int count = dc_count; - const BYTE *source = dc_source; - uint32_t *dest = (uint32_t*)dc_dest; - int bits = tmvlinebits; - int pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - BYTE pix = source[frac >> bits]; - if (pix != 0) - { - uint32_t fg = shade_pal_index(pix, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } - frac += fracstep; - dest += pitch; - } while (--count); - - return frac; -} - void tmvline4_revsubclamp_C () { BYTE *dest = dc_dest; @@ -4440,52 +2249,6 @@ void tmvline4_revsubclamp_C () } while (--count); } -void tmvline4_revsubclamp_RGBA() -{ - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; - int bits = tmvlinebits; - - uint32_t light[4]; - light[0] = calc_light_multiplier(palookuplight[0]); - light[1] = calc_light_multiplier(palookuplight[1]); - light[2] = calc_light_multiplier(palookuplight[2]); - light[3] = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do - { - for (int i = 0; i < 4; ++i) - { - BYTE pix = bufplce[i][vplce[i] >> bits]; - if (pix != 0) - { - uint32_t fg = shade_pal_index(pix, light[i], shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - vplce[i] += vince[i]; - } - dest += dc_pitch; - } while (--count); -} - - //========================================================================== // // R_GetColumn @@ -4535,11 +2298,7 @@ void R_InitColumnDrawers () R_DrawTranslatedColumn = R_DrawTranslatedColumnP_RGBA_C; R_DrawShadedColumn = R_DrawShadedColumnP_RGBA_C; R_DrawSpanMasked = R_DrawSpanMaskedP_RGBA_C; -#ifndef NO_SSE - R_DrawSpan = R_DrawSpanP_RGBA_SSE; -#else - R_DrawSpan = R_DrawSpanP_RGBA_C; -#endif + R_DrawSpan = R_DrawSpanP_RGBA_C; R_DrawSpanTranslucent = R_DrawSpanTranslucentP_RGBA_C; R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucentP_RGBA_C; @@ -4579,9 +2338,13 @@ void R_InitColumnDrawers () rt_copy1col = rt_copy1col_RGBA_c; rt_copy4cols = rt_copy4cols_RGBA_c; rt_map1col = rt_map1col_RGBA_c; + rt_map4cols = rt_map4cols_RGBA_c; rt_shaded1col = rt_shaded1col_RGBA_c; + rt_shaded4cols = rt_shaded4cols_RGBA_c; rt_add1col = rt_add1col_RGBA_c; + rt_add4cols = rt_add4cols_RGBA_c; rt_addclamp1col = rt_addclamp1col_RGBA_c; + rt_addclamp4cols = rt_addclamp4cols_RGBA_c; rt_subclamp1col = rt_subclamp1col_RGBA_c; rt_revsubclamp1col = rt_revsubclamp1col_RGBA_c; rt_tlate1col = rt_tlate1col_RGBA_c; @@ -4597,31 +2360,14 @@ void R_InitColumnDrawers () rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_RGBA_c; rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_RGBA_c; rt_initcols = rt_initcols_rgba; - -#ifndef NO_SSE - rt_map4cols = rt_map4cols_RGBA_SSE; - rt_add4cols = rt_add4cols_RGBA_SSE; - rt_addclamp4cols = rt_addclamp4cols_RGBA_SSE; - rt_shaded4cols = rt_shaded4cols_RGBA_SSE; -#else - rt_map4cols = rt_map4cols_RGBA_c; - rt_add4cols = rt_add4cols_RGBA_c; - rt_addclamp4cols = rt_addclamp4cols_RGBA_c; - rt_shaded4cols = rt_shaded4cols_RGBA_c; -#endif + rt_span_coverage = rt_span_coverage_rgba; dovline1 = vlinec1_RGBA; doprevline1 = vlinec1_RGBA; domvline1 = mvlinec1_RGBA; -#ifndef NO_SSE - dovline4 = vlinec4_RGBA_SSE; - domvline4 = mvlinec4_RGBA_SSE; -#else dovline4 = vlinec4_RGBA; domvline4 = mvlinec4_RGBA; -#endif - } else { @@ -4719,6 +2465,7 @@ void R_InitColumnDrawers () rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_c; rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_c; rt_initcols = rt_initcols_pal; + rt_span_coverage = rt_span_coverage_pal; if (pointers_saved) { diff --git a/src/r_draw.h b/src/r_draw.h index cc3b10935..98be57c51 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -24,6 +24,13 @@ #define __R_DRAW__ #include "r_defs.h" +#include + +// Spectre/Invisibility. +#define FUZZTABLE 50 +extern "C" int fuzzoffset[FUZZTABLE + 1]; // [RH] +1 for the assembly routine +extern "C" int fuzzpos; +extern "C" int fuzzviewheight; struct FColormap; struct ShadeConstants; @@ -173,7 +180,6 @@ void rt_copy4cols_RGBA_c (int sx, int yl, int yh); void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh); void rt_shaded4cols_RGBA_c (int sx, int yl, int yh); -void rt_shaded4cols_RGBA_SSE (int sx, int yl, int yh); void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh); void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh); @@ -188,11 +194,8 @@ void rt_tlatesubclamp1col_RGBA_c (int hx, int sx, int yl, int yh); void rt_tlaterevsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh); void rt_map4cols_RGBA_c (int sx, int yl, int yh); -void rt_map4cols_RGBA_SSE (int sx, int yl, int yh); void rt_add4cols_RGBA_c (int sx, int yl, int yh); -void rt_add4cols_RGBA_SSE (int sx, int yl, int yh); void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh); -void rt_addclamp4cols_RGBA_SSE (int sx, int yl, int yh); void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh); void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh); @@ -235,6 +238,7 @@ extern void (*rt_tlatesubclamp4cols)(int sx, int yl, int yh); extern void (*rt_tlaterevsubclamp4cols)(int sx, int yl, int yh); extern void (*rt_initcols)(BYTE *buffer); +extern void (*rt_span_coverage)(int x, int start, int stop); void rt_draw4cols (int sx); @@ -242,6 +246,8 @@ void rt_draw4cols (int sx); void rt_initcols_pal (BYTE *buffer); void rt_initcols_rgba (BYTE *buffer); +void rt_span_coverage_pal(int x, int start, int stop); +void rt_span_coverage_rgba(int x, int start, int stop); extern void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); @@ -277,9 +283,40 @@ void R_DrawFuzzColumnP_RGBA_C (void); void R_DrawTranslatedColumnP_RGBA_C (void); void R_DrawShadedColumnP_RGBA_C (void); void R_DrawSpanP_RGBA_C (void); -void R_DrawSpanP_RGBA_SSE (void); void R_DrawSpanMaskedP_RGBA_C (void); +void R_DrawSpanTranslucentP_RGBA_C(); +void R_DrawSpanMaskedTranslucentP_RGBA_C(); +void R_DrawSpanAddClampP_RGBA_C(); +void R_DrawSpanMaskedAddClampP_RGBA_C(); +void R_FillColumnP_RGBA(); +void R_FillAddColumn_RGBA_C(); +void R_FillAddClampColumn_RGBA(); +void R_FillSubClampColumn_RGBA(); +void R_FillRevSubClampColumn_RGBA(); +void R_DrawAddColumnP_RGBA_C(); +void R_DrawTlatedAddColumnP_RGBA_C(); +void R_DrawAddClampColumnP_RGBA_C(); +void R_DrawAddClampTranslatedColumnP_RGBA_C(); +void R_DrawSubClampColumnP_RGBA_C(); +void R_DrawSubClampTranslatedColumnP_RGBA_C(); +void R_DrawRevSubClampColumnP_RGBA_C(); +void R_DrawRevSubClampTranslatedColumnP_RGBA_C(); +void R_FillSpan_RGBA(); +void R_DrawFogBoundary_RGBA(int x1, int x2, short *uclip, short *dclip); +fixed_t tmvline1_add_RGBA(); +void tmvline4_add_RGBA(); +fixed_t tmvline1_addclamp_RGBA(); +void tmvline4_addclamp_RGBA(); +fixed_t tmvline1_subclamp_RGBA(); +void tmvline4_subclamp_RGBA(); +fixed_t tmvline1_revsubclamp_RGBA(); +void tmvline4_revsubclamp_RGBA(); +DWORD vlinec1_RGBA(); +void vlinec4_RGBA(); +DWORD mvlinec1_RGBA(); +void mvlinec4_RGBA(); + void R_DrawSpanTranslucentP_C (void); void R_DrawSpanMaskedTranslucentP_C (void); @@ -403,4 +440,52 @@ void R_SetDSColorMapLight(FColormap *base_colormap, float light, int shade); void R_SetTranslationMap(lighttable_t *translation); +// Wait until all drawers finished executing +void R_FinishDrawerCommands(); + +class DrawerThread +{ +public: + int core = 0; + int num_cores = 1; + + uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT * 4]; + uint32_t *dc_temp_rgba; +}; + +class DrawerCommand +{ +public: + virtual void Execute(DrawerThread *thread) = 0; +}; + +class DrawerCommandQueue +{ + enum { memorypool_size = 4 * 1024 * 1024 }; + char memorypool[memorypool_size]; + size_t memorypool_pos = 0; + + std::vector commands; + + static DrawerCommandQueue *Instance(); + +public: + // Allocate memory valid for the duration of a command execution + static void* AllocMemory(size_t size); + + // Queue command to be executed by drawer worker threads + template + static void QueueCommand(Types &&... args) + { + void *ptr = AllocMemory(sizeof(T)); + T *command = new (ptr)T(std::forward(args)...); + if (!command) + return; + Instance()->commands.push_back(command); + } + + // Wait until all worker threads finished executing commands + static void Finish(); +}; + #endif diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp new file mode 100644 index 000000000..9e61bb427 --- /dev/null +++ b/src/r_draw_rgba.cpp @@ -0,0 +1,3492 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id:$ +// +// Copyright (C) 1993-1996 by id Software, Inc. +// +// This source is available for distribution and/or modification +// only under the terms of the DOOM Source Code License as +// published by id Software. All rights reserved. +// +// The source is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License +// for more details. +// +// $Log:$ +// +// DESCRIPTION: +// True color span/column drawing functions. +// +//----------------------------------------------------------------------------- + +#include + +#include "templates.h" +#include "doomdef.h" +#include "i_system.h" +#include "w_wad.h" +#include "r_local.h" +#include "v_video.h" +#include "doomstat.h" +#include "st_stuff.h" +#include "g_game.h" +#include "g_level.h" +#include "r_data/r_translate.h" +#include "v_palette.h" +#include "r_data/colormaps.h" +#include "r_plane.h" + +#include "gi.h" +#include "stats.h" +#include "x86.h" +#ifndef NO_SSE +#include +#endif +#include + +extern int vlinebits; +extern int mvlinebits; +extern int tmvlinebits; + +extern "C" short spanend[MAXHEIGHT]; +extern float rw_light; +extern float rw_lightstep; +extern int wallshade; + +///////////////////////////////////////////////////////////////////////////// + +DrawerCommandQueue *DrawerCommandQueue::Instance() +{ + static DrawerCommandQueue queue; + return &queue; +} + +void* DrawerCommandQueue::AllocMemory(size_t size) +{ + // Make sure allocations remain 16-byte aligned + size = (size + 15) / 16 * 16; + + auto queue = Instance(); + if (queue->memorypool_pos + size > memorypool_size) + return nullptr; + + void *data = queue->memorypool + queue->memorypool_pos; + queue->memorypool_pos += size; + return data; +} + +void DrawerCommandQueue::Finish() +{ + auto queue = Instance(); + + DrawerThread thread; + + size_t size = queue->commands.size(); + for (size_t i = 0; i < size; i++) + { + auto &command = queue->commands[i]; + command->Execute(&thread); + } + + for (auto &command : queue->commands) + command->~DrawerCommand(); + queue->commands.clear(); + queue->memorypool_pos = 0; +} + +///////////////////////////////////////////////////////////////////////////// + +class DrawColumnRGBACommand : public DrawerCommand +{ + int dc_count; + BYTE *dc_dest; + fixed_t dc_texturefrac; + fixed_t dc_iscale; + fixed_t dc_light; + const BYTE *dc_source; + int dc_pitch; + ShadeConstants dc_shade_constants; + +public: + DrawColumnRGBACommand() + { + dc_count = ::dc_count; + dc_dest = ::dc_dest; + dc_texturefrac = ::dc_texturefrac; + dc_iscale = ::dc_iscale; + dc_light = ::dc_light; + dc_source = ::dc_source; + dc_pitch = ::dc_pitch; + dc_shade_constants = ::dc_shade_constants; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t* dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + + // Zero length, column does not exceed a pixel. + if (count <= 0) + return; + + // Framebuffer destination address. + dest = (uint32_t*)dc_dest; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + // Determine scaling, + // which is the only mapping to be done. + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + // [RH] Get local copies of these variables so that the compiler + // has a better chance of optimizing this well. + const BYTE *source = dc_source; + int pitch = dc_pitch; + + // Inner loop that does the actual texture mapping, + // e.g. a DDA-lile scaling. + // This is as fast as it gets. + do + { + *dest = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); + + dest += pitch; + frac += fracstep; + + } while (--count); + } + } +}; + +class FillColumnRGBACommand : public DrawerCommand +{ + int dc_count; + BYTE *dc_dest; + fixed_t dc_light; + int dc_pitch; + int dc_color; + +public: + FillColumnRGBACommand() + { + dc_count = ::dc_count; + dc_dest = ::dc_dest; + dc_light = ::dc_light; + dc_pitch = ::dc_pitch; + dc_color = ::dc_color; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t* dest; + + count = dc_count; + + if (count <= 0) + return; + + dest = (uint32_t*)dc_dest; + + uint32_t light = calc_light_multiplier(dc_light); + + { + int pitch = dc_pitch; + BYTE color = dc_color; + + do + { + *dest = shade_pal_index_simple(color, light); + dest += pitch; + } while (--count); + } + } +}; + +class FillAddColumnRGBACommand : public DrawerCommand +{ + int dc_count; + BYTE *dc_dest; + int dc_pitch; + fixed_t dc_light; + int dc_color; + +public: + FillAddColumnRGBACommand() + { + dc_count = ::dc_count; + dc_dest = ::dc_dest; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_color = ::dc_color; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t *dest; + + count = dc_count; + if (count <= 0) + return; + + dest = (uint32_t*)dc_dest; + int pitch = dc_pitch; + + uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg_red = (fg >> 24) & 0xff; + uint32_t fg_green = (fg >> 16) & 0xff; + uint32_t fg_blue = fg & 0xff; + + do + { + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red + 1) / 2; + uint32_t green = (fg_green + bg_green + 1) / 2; + uint32_t blue = (fg_blue + bg_blue + 1) / 2; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--count); + } +}; + +class FillAddClampColumnRGBACommand : public DrawerCommand +{ + int dc_count; + BYTE *dc_dest; + int dc_pitch; + fixed_t dc_light; + int dc_color; + +public: + FillAddClampColumnRGBACommand() + { + dc_count = ::dc_count; + dc_dest = ::dc_dest; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_color = ::dc_color; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t *dest; + + count = dc_count; + if (count <= 0) + return; + + dest = (uint32_t*)dc_dest; + int pitch = dc_pitch; + + uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg_red = (fg >> 24) & 0xff; + uint32_t fg_green = (fg >> 16) & 0xff; + uint32_t fg_blue = fg & 0xff; + + do + { + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(fg_red + bg_red, 0, 255); + uint32_t green = clamp(fg_green + bg_green, 0, 255); + uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--count); + } +}; + +class FillSubClampColumnRGBACommand : public DrawerCommand +{ + int dc_count; + BYTE *dc_dest; + int dc_pitch; + int dc_color; + fixed_t dc_light; + +public: + FillSubClampColumnRGBACommand() + { + dc_count = ::dc_count; + dc_dest = ::dc_dest; + dc_pitch = ::dc_pitch; + dc_color = ::dc_color; + dc_light = ::dc_light; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t *dest; + + count = dc_count; + if (count <= 0) + return; + + dest = (uint32_t*)dc_dest; + int pitch = dc_pitch; + + uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg_red = (fg >> 24) & 0xff; + uint32_t fg_green = (fg >> 16) & 0xff; + uint32_t fg_blue = fg & 0xff; + + do + { + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 255; + uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 255; + uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 255; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--count); + } +}; + +class FillRevSubClampColumnRGBACommand : public DrawerCommand +{ + int dc_count; + BYTE *dc_dest; + int dc_pitch; + int dc_color; + fixed_t dc_light; + +public: + FillRevSubClampColumnRGBACommand() + { + dc_count = ::dc_count; + dc_dest = ::dc_dest; + dc_pitch = ::dc_pitch; + dc_color = ::dc_color; + dc_light = ::dc_light; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t *dest; + + count = dc_count; + if (count <= 0) + return; + + dest = (uint32_t*)dc_dest; + int pitch = dc_pitch; + + uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg_red = (fg >> 24) & 0xff; + uint32_t fg_green = (fg >> 16) & 0xff; + uint32_t fg_blue = fg & 0xff; + + do + { + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 255; + uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 255; + uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 255; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--count); + } +}; + +class DrawFuzzColumnRGBACommand : public DrawerCommand +{ + int dc_x; + int dc_yl; + int dc_yh; + BYTE *dc_destorg; + int dc_pitch; + int fuzzpos; + int fuzzviewheight; + +public: + DrawFuzzColumnRGBACommand() + { + dc_x = ::dc_x; + dc_yl = ::dc_yl; + dc_yh = ::dc_yh; + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + fuzzpos = ::fuzzpos; + fuzzviewheight = ::fuzzviewheight; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t *dest; + + // Adjust borders. Low... + if (dc_yl == 0) + dc_yl = 1; + + // .. and high. + if (dc_yh > fuzzviewheight) + dc_yh = fuzzviewheight; + + count = dc_yh - dc_yl; + + // Zero length. + if (count < 0) + return; + + count++; + + dest = ylookup[dc_yl] + dc_x + (uint32_t*)dc_destorg; + + // Note: this implementation assumes this function is only used for the pinky shadow effect (i.e. no other fancy colormap than black) + // I'm not sure if this is really always the case or not. + + { + // [RH] Make local copies of global vars to try and improve + // the optimizations made by the compiler. + int pitch = dc_pitch; + int fuzz = fuzzpos; + int cnt; + + // [RH] Split this into three separate loops to minimize + // the number of times fuzzpos needs to be clamped. + if (fuzz) + { + cnt = MIN(FUZZTABLE - fuzz, count); + count -= cnt; + do + { + uint32_t bg = dest[fuzzoffset[fuzz++]]; + uint32_t bg_red = (bg >> 16) & 0xff; + uint32_t bg_green = (bg >> 8) & 0xff; + uint32_t bg_blue = (bg) & 0xff; + + uint32_t red = bg_red * 3 / 4; + uint32_t green = bg_green * 3 / 4; + uint32_t blue = bg_blue * 3 / 4; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--cnt); + } + if (fuzz == FUZZTABLE || count > 0) + { + while (count >= FUZZTABLE) + { + fuzz = 0; + cnt = FUZZTABLE; + count -= FUZZTABLE; + do + { + uint32_t bg = dest[fuzzoffset[fuzz++]]; + uint32_t bg_red = (bg >> 16) & 0xff; + uint32_t bg_green = (bg >> 8) & 0xff; + uint32_t bg_blue = (bg) & 0xff; + + uint32_t red = bg_red * 3 / 4; + uint32_t green = bg_green * 3 / 4; + uint32_t blue = bg_blue * 3 / 4; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--cnt); + } + fuzz = 0; + if (count > 0) + { + do + { + uint32_t bg = dest[fuzzoffset[fuzz++]]; + uint32_t bg_red = (bg >> 16) & 0xff; + uint32_t bg_green = (bg >> 8) & 0xff; + uint32_t bg_blue = (bg) & 0xff; + + uint32_t red = bg_red * 3 / 4; + uint32_t green = bg_green * 3 / 4; + uint32_t blue = bg_blue * 3 / 4; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } while (--count); + } + } + fuzzpos = fuzz; + } + } +}; + +class DrawAddColumnRGBACommand : public DrawerCommand +{ + int dc_count; + BYTE *dc_dest; + fixed_t dc_iscale; + fixed_t dc_texturefrac; + const BYTE *dc_source; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + +public: + DrawAddColumnRGBACommand() + { + dc_count = ::dc_count; + dc_dest = ::dc_dest; + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_source = ::dc_source; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = (uint32_t*)dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + const BYTE *source = dc_source; + int pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); + + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } + } +}; + +class DrawTranslatedColumnRGBACommand : public DrawerCommand +{ + int dc_count; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + BYTE *dc_dest; + fixed_t dc_iscale; + fixed_t dc_texturefrac; + BYTE *dc_translation; + const BYTE *dc_source; + int dc_pitch; + +public: + DrawTranslatedColumnRGBACommand() + { + dc_count = ::dc_count; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_dest = ::dc_dest; + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_translation = ::dc_translation; + dc_source = ::dc_source; + dc_pitch = ::dc_pitch; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t* dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + dest = (uint32_t*)dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + // [RH] Local copies of global vars to improve compiler optimizations + BYTE *translation = dc_translation; + const BYTE *source = dc_source; + int pitch = dc_pitch; + + do + { + *dest = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); + dest += pitch; + frac += fracstep; + } while (--count); + } + } +}; + +class DrawTlatedAddColumnRGBACommand : public DrawerCommand +{ + int dc_count; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + BYTE *dc_dest; + fixed_t dc_iscale; + fixed_t dc_texturefrac; + BYTE *dc_translation; + const BYTE *dc_source; + int dc_pitch; + +public: + DrawTlatedAddColumnRGBACommand() + { + dc_count = ::dc_count; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_dest = ::dc_dest; + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_translation = ::dc_translation; + dc_source = ::dc_source; + dc_pitch = ::dc_pitch; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + dest = (uint32_t*)dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + BYTE *translation = dc_translation; + const BYTE *source = dc_source; + int pitch = dc_pitch; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); + + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } + } +}; + +class DrawShadedColumnRGBACommand : public DrawerCommand +{ +private: + int dc_count; + BYTE *dc_dest; + fixed_t dc_iscale; + fixed_t dc_texturefrac; + fixed_t dc_light; + const BYTE *dc_source; + lighttable_t *dc_colormap; + int dc_color; + int dc_pitch; + +public: + DrawShadedColumnRGBACommand() + { + dc_count = ::dc_count; + dc_dest = ::dc_dest; + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_light = ::dc_light; + dc_source = ::dc_source; + dc_colormap = ::dc_colormap; + dc_color = ::dc_color; + dc_pitch = ::dc_pitch; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t *dest; + fixed_t frac, fracstep; + + count = dc_count; + + if (count <= 0) + return; + + dest = (uint32_t*)dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + + uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + { + const BYTE *source = dc_source; + BYTE *colormap = dc_colormap; + int pitch = dc_pitch; + + do + { + DWORD alpha = clamp(colormap[source[frac >> FRACBITS]], 0, 64); + DWORD inv_alpha = 64 - alpha; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; + uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; + uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } + } +}; + +class DrawAddClampColumnRGBACommand : public DrawerCommand +{ + int dc_count; + BYTE *dc_dest; + fixed_t dc_iscale; + fixed_t dc_texturefrac; + const BYTE *dc_source; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + +public: + DrawAddClampColumnRGBACommand() + { + dc_count = ::dc_count; + dc_dest = ::dc_dest; + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_source = ::dc_source; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = (uint32_t*)dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + const BYTE *source = dc_source; + int pitch = dc_pitch; + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } + } +}; + +class DrawAddClampTranslatedColumnRGBACommand : public DrawerCommand +{ + int dc_count; + BYTE *dc_dest; + fixed_t dc_iscale; + fixed_t dc_texturefrac; + BYTE *dc_translation; + const BYTE *dc_source; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + +public: + DrawAddClampTranslatedColumnRGBACommand() + { + dc_count = ::dc_count; + dc_dest = ::dc_dest; + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_translation = ::dc_translation; + dc_source = ::dc_source; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = (uint32_t*)dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + BYTE *translation = dc_translation; + const BYTE *source = dc_source; + int pitch = dc_pitch; + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } + } +}; + +class DrawSubClampColumnRGBACommand : public DrawerCommand +{ + int dc_count; + BYTE *dc_dest; + fixed_t dc_iscale; + fixed_t dc_texturefrac; + const BYTE *dc_source; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + +public: + DrawSubClampColumnRGBACommand() + { + dc_count = ::dc_count; + dc_dest = ::dc_dest; + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_source = ::dc_source; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = (uint32_t*)dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + const BYTE *source = dc_source; + int pitch = dc_pitch; + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } + } +}; + +class DrawSubClampTranslatedColumnRGBACommand : public DrawerCommand +{ + int dc_count; + BYTE *dc_dest; + fixed_t dc_iscale; + fixed_t dc_texturefrac; + const BYTE *dc_source; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + BYTE *dc_translation; + +public: + DrawSubClampTranslatedColumnRGBACommand() + { + dc_count = ::dc_count; + dc_dest = ::dc_dest; + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_source = ::dc_source; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + dc_translation = ::dc_translation; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = (uint32_t*)dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + BYTE *translation = dc_translation; + const BYTE *source = dc_source; + int pitch = dc_pitch; + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } + } +}; + +class DrawRevSubClampColumnRGBACommand : public DrawerCommand +{ + int dc_count; + BYTE *dc_dest; + fixed_t dc_iscale; + fixed_t dc_texturefrac; + const BYTE *dc_source; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + +public: + DrawRevSubClampColumnRGBACommand() + { + dc_count = ::dc_count; + dc_dest = ::dc_dest; + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_source = ::dc_source; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = (uint32_t*)dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + const BYTE *source = dc_source; + int pitch = dc_pitch; + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } + } +}; + +class DrawRevSubClampTranslatedColumnRGBACommand : public DrawerCommand +{ + int dc_count; + BYTE *dc_dest; + fixed_t dc_iscale; + fixed_t dc_texturefrac; + const BYTE *dc_source; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + BYTE *dc_translation; + +public: + DrawRevSubClampTranslatedColumnRGBACommand() + { + dc_count = ::dc_count; + dc_dest = ::dc_dest; + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_source = ::dc_source; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + dc_translation = ::dc_translation; + } + + void Execute(DrawerThread *thread) override + { + int count; + uint32_t *dest; + fixed_t frac; + fixed_t fracstep; + + count = dc_count; + if (count <= 0) + return; + + dest = (uint32_t*)dc_dest; + + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + BYTE *translation = dc_translation; + const BYTE *source = dc_source; + int pitch = dc_pitch; + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + frac += fracstep; + } while (--count); + } + } +}; + +class DrawSpanRGBACommand : public DrawerCommand +{ + const BYTE *ds_source; + fixed_t ds_xfrac; + fixed_t ds_yfrac; + fixed_t ds_xstep; + fixed_t ds_ystep; + int ds_x1; + int ds_x2; + int ds_y; + int ds_xbits; + int ds_ybits; + BYTE *dc_destorg; + fixed_t ds_light; + ShadeConstants ds_shade_constants; + +public: + DrawSpanRGBACommand() + { + ds_source = ::ds_source; + ds_xfrac = ::ds_xfrac; + ds_yfrac = ::ds_yfrac; + ds_xstep = ::ds_xstep; + ds_ystep = ::ds_ystep; + ds_x1 = ::ds_x1; + ds_x2 = ::ds_x2; + ds_y = ::ds_y; + ds_xbits = ::ds_xbits; + ds_ybits = ::ds_ybits; + dc_destorg = ::dc_destorg; + ds_light = ::ds_light; + ds_shade_constants = ::ds_shade_constants; + } + +#ifdef NO_SSE + void Execute(DrawerThread *thread) override + { + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + uint32_t* dest; + const BYTE* source = ds_source; + int count; + int spot; + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + + dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + + count = ds_x2 - ds_x1 + 1; + + xstep = ds_xstep; + ystep = ds_ystep; + + uint32_t light = calc_light_multiplier(ds_light); + ShadeConstants shade_constants = ds_shade_constants; + + if (ds_xbits == 6 && ds_ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + + do + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + + // Lookup pixel from flat texture tile + *dest++ = shade_pal_index(source[spot], light, shade_constants); + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + + do + { + // Current texture index in u,v. + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + + // Lookup pixel from flat texture tile + *dest++ = shade_pal_index(source[spot], light, shade_constants); + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + } +#else + void Execute(DrawerThread *thread) override + { + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + uint32_t* dest; + const BYTE* source = ds_source; + int count; + int spot; + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + + dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + + count = ds_x2 - ds_x1 + 1; + + xstep = ds_xstep; + ystep = ds_ystep; + + uint32_t light = calc_light_multiplier(ds_light); + ShadeConstants shade_constants = ds_shade_constants; + + if (ds_xbits == 6 && ds_ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + + int sse_count = count / 4; + count -= sse_count * 4; + + if (shade_constants.simple_shade) + { + SSE_SHADE_SIMPLE_INIT(light); + + while (sse_count--) + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p0 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p1 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p2 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p3 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + + // Next step in u,v. + dest += 4; + } + } + else + { + SSE_SHADE_INIT(light, shade_constants); + + while (sse_count--) + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p0 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p1 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p2 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p3 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + + // Next step in u,v. + dest += 4; + } + } + + if (count == 0) + return; + + do + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + + // Lookup pixel from flat texture tile + *dest++ = shade_pal_index(source[spot], light, shade_constants); + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + + do + { + // Current texture index in u,v. + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + + // Lookup pixel from flat texture tile + *dest++ = shade_pal_index(source[spot], light, shade_constants); + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + } +#endif +}; + +class DrawSpanMaskedRGBACommand : public DrawerCommand +{ + const BYTE *ds_source; + fixed_t ds_light; + ShadeConstants ds_shade_constants; + fixed_t ds_xfrac; + fixed_t ds_yfrac; + BYTE *dc_destorg; + int ds_x1; + int ds_y1; + int ds_y; + fixed_t ds_xstep; + fixed_t ds_ystep; + int ds_xbits; + int ds_ybits; + +public: + DrawSpanMaskedRGBACommand() + { + ds_source = ::ds_source; + ds_light = ::ds_light; + ds_shade_constants = ::ds_shade_constants; + ds_xfrac = ::ds_xfrac; + ds_yfrac = ::ds_yfrac; + dc_destorg = ::dc_destorg; + ds_x1 = ::ds_x1; + ds_x2 = ::ds_x2; + ds_y = ::ds_y; + ds_xstep = ::ds_xstep; + ds_ystep = ::ds_ystep; + ds_xbits = ::ds_xbits; + ds_ybits = ::ds_ybits; + } + + void Execute(DrawerThread *thread) override + { + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + uint32_t* dest; + const BYTE* source = ds_source; + int count; + int spot; + + uint32_t light = calc_light_multiplier(ds_light); + ShadeConstants shade_constants = ds_shade_constants; + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + + dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + + count = ds_x2 - ds_x1 + 1; + + xstep = ds_xstep; + ystep = ds_ystep; + + if (ds_xbits == 6 && ds_ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + BYTE texdata; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + texdata = source[spot]; + if (texdata != 0) + { + *dest = shade_pal_index(texdata, light, shade_constants); + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + do + { + BYTE texdata; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + texdata = source[spot]; + if (texdata != 0) + { + *dest = shade_pal_index(texdata, light, shade_constants); + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + } +}; + +class DrawSpanTranslucentRGBACommand : public DrawerCommand +{ + const BYTE *ds_source; + fixed_t ds_light; + ShadeConstants ds_shade_constants; + fixed_t ds_xfrac; + fixed_t ds_yfrac; + BYTE *dc_destorg; + int ds_x1; + int ds_y1; + int ds_y; + fixed_t ds_xstep; + fixed_t ds_ystep; + int ds_xbits; + int ds_ybits; + +public: + DrawSpanTranslucentRGBACommand() + { + ds_source = ::ds_source; + ds_light = ::ds_light; + ds_shade_constants = ::ds_shade_constants; + ds_xfrac = ::ds_xfrac; + ds_yfrac = ::ds_yfrac; + dc_destorg = ::dc_destorg; + ds_x1 = ::ds_x1; + ds_x2 = ::ds_x2; + ds_y = ::ds_y; + ds_xstep = ::ds_xstep; + ds_ystep = ::ds_ystep; + ds_xbits = ::ds_xbits; + ds_ybits = ::ds_ybits; + } + + void Execute(DrawerThread *thread) override + { + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + uint32_t* dest; + const BYTE* source = ds_source; + int count; + int spot; + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + + dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + + count = ds_x2 - ds_x1 + 1; + + xstep = ds_xstep; + ystep = ds_ystep; + + uint32_t light = calc_light_multiplier(ds_light); + ShadeConstants shade_constants = ds_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + if (ds_xbits == 6 && ds_ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + + uint32_t fg = shade_pal_index(source[spot], light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; + uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; + uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; + + *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; + + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + do + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + + uint32_t fg = shade_pal_index(source[spot], light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; + uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; + uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; + + *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; + + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + } +}; + +class DrawSpanMaskedTranslucentRGBACommand : public DrawerCommand +{ + const BYTE *ds_source; + fixed_t ds_light; + ShadeConstants ds_shade_constants; + fixed_t ds_xfrac; + fixed_t ds_yfrac; + BYTE *dc_destorg; + int ds_x1; + int ds_y1; + int ds_y; + fixed_t ds_xstep; + fixed_t ds_ystep; + int ds_xbits; + int ds_ybits; + +public: + DrawSpanMaskedTranslucentRGBACommand() + { + ds_source = ::ds_source; + ds_light = ::ds_light; + ds_shade_constants = ::ds_shade_constants; + ds_xfrac = ::ds_xfrac; + ds_yfrac = ::ds_yfrac; + dc_destorg = ::dc_destorg; + ds_x1 = ::ds_x1; + ds_x2 = ::ds_x2; + ds_y = ::ds_y; + ds_xstep = ::ds_xstep; + ds_ystep = ::ds_ystep; + ds_xbits = ::ds_xbits; + ds_ybits = ::ds_ybits; + } + + void Execute(DrawerThread *thread) override + { + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + uint32_t* dest; + const BYTE* source = ds_source; + int count; + int spot; + + uint32_t light = calc_light_multiplier(ds_light); + ShadeConstants shade_constants = ds_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + + dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + + count = ds_x2 - ds_x1 + 1; + + xstep = ds_xstep; + ystep = ds_ystep; + + if (ds_xbits == 6 && ds_ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + BYTE texdata; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t fg = shade_pal_index(texdata, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; + uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; + uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + do + { + BYTE texdata; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t fg = shade_pal_index(texdata, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; + uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; + uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + } +}; + +class DrawSpanAddClampRGBACommand : public DrawerCommand +{ + const BYTE *ds_source; + fixed_t ds_light; + ShadeConstants ds_shade_constants; + fixed_t ds_xfrac; + fixed_t ds_yfrac; + BYTE *dc_destorg; + int ds_x1; + int ds_y1; + int ds_y; + fixed_t ds_xstep; + fixed_t ds_ystep; + int ds_xbits; + int ds_ybits; + +public: + DrawSpanAddClampRGBACommand() + { + ds_source = ::ds_source; + ds_light = ::ds_light; + ds_shade_constants = ::ds_shade_constants; + ds_xfrac = ::ds_xfrac; + ds_yfrac = ::ds_yfrac; + dc_destorg = ::dc_destorg; + ds_x1 = ::ds_x1; + ds_x2 = ::ds_x2; + ds_y = ::ds_y; + ds_xstep = ::ds_xstep; + ds_ystep = ::ds_ystep; + ds_xbits = ::ds_xbits; + ds_ybits = ::ds_ybits; + } + + void Execute(DrawerThread *thread) override + { + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + uint32_t* dest; + const BYTE* source = ds_source; + int count; + int spot; + + uint32_t light = calc_light_multiplier(ds_light); + ShadeConstants shade_constants = ds_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + + dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + + count = ds_x2 - ds_x1 + 1; + + xstep = ds_xstep; + ystep = ds_ystep; + + if (ds_xbits == 6 && ds_ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + + uint32_t fg = shade_pal_index(source[spot], light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; + + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + do + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + + uint32_t fg = shade_pal_index(source[spot], light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; + + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + } +}; + +class DrawSpanMaskedAddClampRGBACommand : public DrawerCommand +{ + const BYTE *ds_source; + fixed_t ds_light; + ShadeConstants ds_shade_constants; + fixed_t ds_xfrac; + fixed_t ds_yfrac; + BYTE *dc_destorg; + int ds_x1; + int ds_y1; + int ds_y; + fixed_t ds_xstep; + fixed_t ds_ystep; + int ds_xbits; + int ds_ybits; + +public: + DrawSpanMaskedAddClampRGBACommand() + { + ds_source = ::ds_source; + ds_light = ::ds_light; + ds_shade_constants = ::ds_shade_constants; + ds_xfrac = ::ds_xfrac; + ds_yfrac = ::ds_yfrac; + dc_destorg = ::dc_destorg; + ds_x1 = ::ds_x1; + ds_x2 = ::ds_x2; + ds_y = ::ds_y; + ds_xstep = ::ds_xstep; + ds_ystep = ::ds_ystep; + ds_xbits = ::ds_xbits; + ds_ybits = ::ds_ybits; + } + + void Execute(DrawerThread *thread) override + { + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + uint32_t* dest; + const BYTE* source = ds_source; + int count; + int spot; + + uint32_t light = calc_light_multiplier(ds_light); + ShadeConstants shade_constants = ds_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + + dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + + count = ds_x2 - ds_x1 + 1; + + xstep = ds_xstep; + ystep = ds_ystep; + + if (ds_xbits == 6 && ds_ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + BYTE texdata; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t fg = shade_pal_index(texdata, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; + uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; + uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - ds_ybits; + BYTE xshift = yshift - ds_xbits; + int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + do + { + BYTE texdata; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t fg = shade_pal_index(texdata, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = (fg) & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; + uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; + uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + } +}; + +class FillSpanRGBACommand : public DrawerCommand +{ + int ds_x1; + int ds_x2; + int ds_y; + BYTE *dc_destorg; + fixed_t ds_light; + int ds_color; + +public: + FillSpanRGBACommand() + { + ds_x1 = ::ds_x1; + ds_x2 = ::ds_x2; + ds_y = ::ds_y; + dc_destorg = ::dc_destorg; + ds_light = ::ds_light; + ds_color = ::ds_color; + } + + void Execute(DrawerThread *thread) override + { + uint32_t *dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + int count = (ds_x2 - ds_x1 + 1); + uint32_t light = calc_light_multiplier(ds_light); + uint32_t color = shade_pal_index_simple(ds_color, light); + for (int i = 0; i < count; i++) + dest[i] = color; + } +}; + +class Vlinec1RGBACommand : public DrawerCommand +{ + fixed_t dc_iscale; + fixed_t dc_texturefrac; + int dc_count; + const BYTE *dc_source; + BYTE *dc_dest; + int vlinebits; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + +public: + Vlinec1RGBACommand() + { + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_count = ::dc_count; + dc_source = ::dc_source; + dc_dest = ::dc_dest; + vlinebits = ::vlinebits; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + } + + void Execute(DrawerThread *thread) override + { + DWORD fracstep = dc_iscale; + DWORD frac = dc_texturefrac; + int count = dc_count; + const BYTE *source = dc_source; + uint32_t *dest = (uint32_t*)dc_dest; + int bits = vlinebits; + int pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + do + { + *dest = shade_pal_index(source[frac >> bits], light, shade_constants); + frac += fracstep; + dest += pitch; + } while (--count); + } +}; + +class Vlinec4RGBACommand : public DrawerCommand +{ + BYTE *dc_dest; + int dc_count; + int dc_pitch; + ShadeConstants dc_shade_constants; + int vlinebits; + fixed_t palookuplight[4]; + DWORD vplce[4]; + DWORD vince[4]; + const BYTE *bufplce[4]; + +public: + Vlinec4RGBACommand() + { + dc_dest = ::dc_dest; + dc_count = ::dc_count; + dc_pitch = ::dc_pitch; + dc_shade_constants = ::dc_shade_constants; + vlinebits = ::vlinebits; + for (int i = 0; i < 4; i++) + { + palookuplight[i] = ::palookuplight[i]; + vplce[i] = ::vplce[i]; + vince[i] = ::vince[i]; + bufplce[i] = ::bufplce[i]; + } + } + +#ifdef NO_SSE + void Execute(DrawerThread *thread) override + { + uint32_t *dest = (uint32_t*)dc_dest; + int count = dc_count; + int bits = vlinebits; + DWORD place; + + uint32_t light0 = calc_light_multiplier(palookuplight[0]); + uint32_t light1 = calc_light_multiplier(palookuplight[1]); + uint32_t light2 = calc_light_multiplier(palookuplight[2]); + uint32_t light3 = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = dc_shade_constants; + + do + { + dest[0] = shade_pal_index(bufplce[0][(place = vplce[0]) >> bits], light0, shade_constants); vplce[0] = place + vince[0]; + dest[1] = shade_pal_index(bufplce[1][(place = vplce[1]) >> bits], light1, shade_constants); vplce[1] = place + vince[1]; + dest[2] = shade_pal_index(bufplce[2][(place = vplce[2]) >> bits], light2, shade_constants); vplce[2] = place + vince[2]; + dest[3] = shade_pal_index(bufplce[3][(place = vplce[3]) >> bits], light3, shade_constants); vplce[3] = place + vince[3]; + dest += dc_pitch; + } while (--count); + } +#else + void Execute(DrawerThread *thread) override + { + uint32_t *dest = (uint32_t*)dc_dest; + int count = dc_count; + int bits = vlinebits; + + uint32_t light0 = calc_light_multiplier(palookuplight[0]); + uint32_t light1 = calc_light_multiplier(palookuplight[1]); + uint32_t light2 = calc_light_multiplier(palookuplight[2]); + uint32_t light3 = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + + if (shade_constants.simple_shade) + { + SSE_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; + + BYTE p0 = bufplce[0][place0 >> bits]; + BYTE p1 = bufplce[1][place1 >> bits]; + BYTE p2 = bufplce[2][place2 >> bits]; + BYTE p3 = bufplce[3][place3 >> bits]; + + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += dc_pitch; + } while (--count); + } + else + { + SSE_SHADE_INIT4(light3, light2, light1, light0, shade_constants); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; + + BYTE p0 = bufplce[0][place0 >> bits]; + BYTE p1 = bufplce[1][place1 >> bits]; + BYTE p2 = bufplce[2][place2 >> bits]; + BYTE p3 = bufplce[3][place3 >> bits]; + + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + dest += dc_pitch; + } while (--count); + } + } +#endif +}; + +class Mvlinec1RGBACommand : public DrawerCommand +{ + fixed_t dc_iscale; + fixed_t dc_texturefrac; + int dc_count; + const BYTE *dc_source; + BYTE *dc_dest; + int mvlinebits; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + +public: + Mvlinec1RGBACommand() + { + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_count = ::dc_count; + dc_source = ::dc_source; + dc_dest = ::dc_dest; + mvlinebits = ::mvlinebits; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + } + + void Execute(DrawerThread *thread) override + { + DWORD fracstep = dc_iscale; + DWORD frac = dc_texturefrac; + int count = dc_count; + const BYTE *source = dc_source; + uint32_t *dest = (uint32_t*)dc_dest; + int bits = mvlinebits; + int pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + do + { + BYTE pix = source[frac >> bits]; + if (pix != 0) + { + *dest = shade_pal_index(pix, light, shade_constants); + } + frac += fracstep; + dest += pitch; + } while (--count); + } +}; + +class Mvlinec4RGBACommand : public DrawerCommand +{ + BYTE *dc_dest; + int dc_count; + int dc_pitch; + ShadeConstants dc_shade_constants; + int mvlinebits; + fixed_t palookuplight[4]; + DWORD vplce[4]; + DWORD vince[4]; + const BYTE *bufplce[4]; + +public: + Mvlinec4RGBACommand() + { + dc_dest = ::dc_dest; + dc_count = ::dc_count; + dc_pitch = ::dc_pitch; + dc_shade_constants = ::dc_shade_constants; + mvlinebits = ::mvlinebits; + for (int i = 0; i < 4; i++) + { + palookuplight[i] = ::palookuplight[i]; + vplce[i] = ::vplce[i]; + vince[i] = ::vince[i]; + bufplce[i] = ::bufplce[i]; + } + } + +#ifdef NO_SSE + void Execute(DrawerThread *thread) override + { + uint32_t *dest = (uint32_t*)dc_dest; + int count = dc_count; + int bits = mvlinebits; + DWORD place; + + uint32_t light0 = calc_light_multiplier(palookuplight[0]); + uint32_t light1 = calc_light_multiplier(palookuplight[1]); + uint32_t light2 = calc_light_multiplier(palookuplight[2]); + uint32_t light3 = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = dc_shade_constants; + + do + { + BYTE pix; + pix = bufplce[0][(place = vplce[0]) >> bits]; if (pix) dest[0] = shade_pal_index(pix, light0, shade_constants); vplce[0] = place + vince[0]; + pix = bufplce[1][(place = vplce[1]) >> bits]; if (pix) dest[1] = shade_pal_index(pix, light1, shade_constants); vplce[1] = place + vince[1]; + pix = bufplce[2][(place = vplce[2]) >> bits]; if (pix) dest[2] = shade_pal_index(pix, light2, shade_constants); vplce[2] = place + vince[2]; + pix = bufplce[3][(place = vplce[3]) >> bits]; if (pix) dest[3] = shade_pal_index(pix, light3, shade_constants); vplce[3] = place + vince[3]; + dest += dc_pitch; + } while (--count); + } +#else + void Execute(DrawerThread *thread) override + { + uint32_t *dest = (uint32_t*)dc_dest; + int count = dc_count; + int bits = mvlinebits; + + uint32_t light0 = calc_light_multiplier(palookuplight[0]); + uint32_t light1 = calc_light_multiplier(palookuplight[1]); + uint32_t light2 = calc_light_multiplier(palookuplight[2]); + uint32_t light3 = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + + if (shade_constants.simple_shade) + { + SSE_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; + + BYTE pix0 = bufplce[0][place0 >> bits]; + BYTE pix1 = bufplce[1][place1 >> bits]; + BYTE pix2 = bufplce[2][place2 >> bits]; + BYTE pix3 = bufplce[3][place3 >> bits]; + + // movemask = !(pix == 0) + __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); + + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; + + __m128i fg = _mm_set_epi32(palette[pix3], palette[pix2], palette[pix1], palette[pix0]); + SSE_SHADE_SIMPLE(fg); + _mm_maskmoveu_si128(fg, movemask, (char*)dest); + dest += dc_pitch; + } while (--count); + } + else + { + SSE_SHADE_INIT4(light3, light2, light1, light0, shade_constants); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; + + BYTE pix0 = bufplce[0][place0 >> bits]; + BYTE pix1 = bufplce[1][place1 >> bits]; + BYTE pix2 = bufplce[2][place2 >> bits]; + BYTE pix3 = bufplce[3][place3 >> bits]; + + // movemask = !(pix == 0) + __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); + + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; + + __m128i fg = _mm_set_epi32(palette[pix3], palette[pix2], palette[pix1], palette[pix0]); + SSE_SHADE(fg, shade_constants); + _mm_maskmoveu_si128(fg, movemask, (char*)dest); + dest += dc_pitch; + } while (--count); + } + } +#endif +}; + +class Tmvline1AddRGBACommand : public DrawerCommand +{ + fixed_t dc_iscale; + fixed_t dc_texturefrac; + int dc_count; + const BYTE *dc_source; + BYTE *dc_dest; + int tmvlinebits; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + +public: + Tmvline1AddRGBACommand() + { + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_count = ::dc_count; + dc_source = ::dc_source; + dc_dest = ::dc_dest; + tmvlinebits = ::tmvlinebits; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + } + + void Execute(DrawerThread *thread) override + { + DWORD fracstep = dc_iscale; + DWORD frac = dc_texturefrac; + int count = dc_count; + const BYTE *source = dc_source; + uint32_t *dest = (uint32_t*)dc_dest; + int bits = tmvlinebits; + int pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + BYTE pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t fg = shade_pal_index(pix, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + } + frac += fracstep; + dest += pitch; + } while (--count); + } +}; + +class Tmvline4AddRGBACommand : public DrawerCommand +{ + BYTE *dc_dest; + int dc_count; + int dc_pitch; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + int tmvlinebits; + fixed_t palookuplight[4]; + DWORD vplce[4]; + DWORD vince[4]; + const BYTE *bufplce[4]; + +public: + Tmvline4AddRGBACommand() + { + dc_dest = ::dc_dest; + dc_count = ::dc_count; + dc_pitch = ::dc_pitch; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + tmvlinebits = ::tmvlinebits; + for (int i = 0; i < 4; i++) + { + palookuplight[i] = ::palookuplight[i]; + vplce[i] = ::vplce[i]; + vince[i] = ::vince[i]; + bufplce[i] = ::bufplce[i]; + } + } + + void Execute(DrawerThread *thread) override + { + uint32_t *dest = (uint32_t*)dc_dest; + int count = dc_count; + int bits = tmvlinebits; + + uint32_t light[4]; + light[0] = calc_light_multiplier(palookuplight[0]); + light[1] = calc_light_multiplier(palookuplight[1]); + light[2] = calc_light_multiplier(palookuplight[2]); + light[3] = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + for (int i = 0; i < 4; ++i) + { + BYTE pix = bufplce[i][vplce[i] >> bits]; + if (pix != 0) + { + uint32_t fg = shade_pal_index(pix, light[i], shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + vplce[i] += vince[i]; + } + dest += dc_pitch; + } while (--count); + } +}; + +class Tmvline1AddClampRGBACommand : public DrawerCommand +{ + fixed_t dc_iscale; + fixed_t dc_texturefrac; + int dc_count; + const BYTE *dc_source; + BYTE *dc_dest; + int tmvlinebits; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + +public: + Tmvline1AddClampRGBACommand() + { + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_count = ::dc_count; + dc_source = ::dc_source; + dc_dest = ::dc_dest; + tmvlinebits = ::tmvlinebits; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + } + + void Execute(DrawerThread *thread) override + { + DWORD fracstep = dc_iscale; + DWORD frac = dc_texturefrac; + int count = dc_count; + const BYTE *source = dc_source; + uint32_t *dest = (uint32_t*)dc_dest; + int bits = tmvlinebits; + int pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + BYTE pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t fg = shade_pal_index(pix, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + } + frac += fracstep; + dest += pitch; + } while (--count); + } +}; + +class Tmvline4AddClampRGBACommand : public DrawerCommand +{ + BYTE *dc_dest; + int dc_count; + int dc_pitch; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + int tmvlinebits; + fixed_t palookuplight[4]; + DWORD vplce[4]; + DWORD vince[4]; + const BYTE *bufplce[4]; + +public: + Tmvline4AddClampRGBACommand() + { + dc_dest = ::dc_dest; + dc_count = ::dc_count; + dc_pitch = ::dc_pitch; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + tmvlinebits = ::tmvlinebits; + for (int i = 0; i < 4; i++) + { + palookuplight[i] = ::palookuplight[i]; + vplce[i] = ::vplce[i]; + vince[i] = ::vince[i]; + bufplce[i] = ::bufplce[i]; + } + } + + void Execute(DrawerThread *thread) override + { + uint32_t *dest = (uint32_t*)dc_dest; + int count = dc_count; + int bits = tmvlinebits; + + uint32_t light[4]; + light[0] = calc_light_multiplier(palookuplight[0]); + light[1] = calc_light_multiplier(palookuplight[1]); + light[2] = calc_light_multiplier(palookuplight[2]); + light[3] = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + for (int i = 0; i < 4; ++i) + { + BYTE pix = bufplce[i][vplce[i] >> bits]; + if (pix != 0) + { + uint32_t fg = shade_pal_index(pix, light[i], shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + vplce[i] += vince[i]; + } + dest += dc_pitch; + } while (--count); + } +}; + +class Tmvline1SubClampRGBACommand : public DrawerCommand +{ + fixed_t dc_iscale; + fixed_t dc_texturefrac; + int dc_count; + const BYTE *dc_source; + BYTE *dc_dest; + int tmvlinebits; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + +public: + Tmvline1SubClampRGBACommand() + { + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_count = ::dc_count; + dc_source = ::dc_source; + dc_dest = ::dc_dest; + tmvlinebits = ::tmvlinebits; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + } + + void Execute(DrawerThread *thread) override + { + DWORD fracstep = dc_iscale; + DWORD frac = dc_texturefrac; + int count = dc_count; + const BYTE *source = dc_source; + uint32_t *dest = (uint32_t*)dc_dest; + int bits = tmvlinebits; + int pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + BYTE pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t fg = shade_pal_index(pix, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + } + frac += fracstep; + dest += pitch; + } while (--count); + } +}; + +class Tmvline4SubClampRGBACommand : public DrawerCommand +{ + BYTE *dc_dest; + int dc_count; + int dc_pitch; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + int tmvlinebits; + fixed_t palookuplight[4]; + DWORD vplce[4]; + DWORD vince[4]; + const BYTE *bufplce[4]; + +public: + Tmvline4SubClampRGBACommand() + { + dc_dest = ::dc_dest; + dc_count = ::dc_count; + dc_pitch = ::dc_pitch; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + tmvlinebits = ::tmvlinebits; + for (int i = 0; i < 4; i++) + { + palookuplight[i] = ::palookuplight[i]; + vplce[i] = ::vplce[i]; + vince[i] = ::vince[i]; + bufplce[i] = ::bufplce[i]; + } + } + + void Execute(DrawerThread *thread) override + { + uint32_t *dest = (uint32_t*)dc_dest; + int count = dc_count; + int bits = tmvlinebits; + + uint32_t light[4]; + light[0] = calc_light_multiplier(palookuplight[0]); + light[1] = calc_light_multiplier(palookuplight[1]); + light[2] = calc_light_multiplier(palookuplight[2]); + light[3] = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + for (int i = 0; i < 4; ++i) + { + BYTE pix = bufplce[i][vplce[i] >> bits]; + if (pix != 0) + { + uint32_t fg = shade_pal_index(pix, light[i], shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + vplce[i] += vince[i]; + } + dest += dc_pitch; + } while (--count); + } +}; + +class Tmvline1RevSubClampRGBACommand : public DrawerCommand +{ + fixed_t dc_iscale; + fixed_t dc_texturefrac; + int dc_count; + const BYTE *dc_source; + BYTE *dc_dest; + int tmvlinebits; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + +public: + Tmvline1RevSubClampRGBACommand() + { + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_count = ::dc_count; + dc_source = ::dc_source; + dc_dest = ::dc_dest; + tmvlinebits = ::tmvlinebits; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + } + + void Execute(DrawerThread *thread) override + { + DWORD fracstep = dc_iscale; + DWORD frac = dc_texturefrac; + int count = dc_count; + const BYTE *source = dc_source; + uint32_t *dest = (uint32_t*)dc_dest; + int bits = tmvlinebits; + int pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + BYTE pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t fg = shade_pal_index(pix, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + } + frac += fracstep; + dest += pitch; + } while (--count); + } +}; + +class Tmvline4RevSubClampRGBACommand : public DrawerCommand +{ + BYTE *dc_dest; + int dc_count; + int dc_pitch; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + int tmvlinebits; + fixed_t palookuplight[4]; + DWORD vplce[4]; + DWORD vince[4]; + const BYTE *bufplce[4]; + +public: + Tmvline4RevSubClampRGBACommand() + { + dc_dest = ::dc_dest; + dc_count = ::dc_count; + dc_pitch = ::dc_pitch; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + tmvlinebits = ::tmvlinebits; + for (int i = 0; i < 4; i++) + { + palookuplight[i] = ::palookuplight[i]; + vplce[i] = ::vplce[i]; + vince[i] = ::vince[i]; + bufplce[i] = ::bufplce[i]; + } + } + + void Execute(DrawerThread *thread) override + { + uint32_t *dest = (uint32_t*)dc_dest; + int count = dc_count; + int bits = tmvlinebits; + + uint32_t light[4]; + light[0] = calc_light_multiplier(palookuplight[0]); + light[1] = calc_light_multiplier(palookuplight[1]); + light[2] = calc_light_multiplier(palookuplight[2]); + light[3] = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do + { + for (int i = 0; i < 4; ++i) + { + BYTE pix = bufplce[i][vplce[i] >> bits]; + if (pix != 0) + { + uint32_t fg = shade_pal_index(pix, light[i], shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + vplce[i] += vince[i]; + } + dest += dc_pitch; + } while (--count); + } +}; + +class DrawFogBoundaryLineRGBACommand : public DrawerCommand +{ + int _y; + int _x; + int _x2; + BYTE *dc_destorg; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + +public: + DrawFogBoundaryLineRGBACommand(int y, int x, int x2) + { + _y = y; + _x = x; + _x2 = x2; + + dc_destorg = ::dc_destorg; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + } + + void Execute(DrawerThread *thread) override + { + int y = _y; + int x = _x; + int x2 = _x2; + + uint32_t *dest = ylookup[y] + (uint32_t*)dc_destorg; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants constants = dc_shade_constants; + + do + { + uint32_t red = (dest[x] >> 16) & 0xff; + uint32_t green = (dest[x] >> 8) & 0xff; + uint32_t blue = dest[x] & 0xff; + + if (constants.simple_shade) + { + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; + } + else + { + uint32_t inv_light = 256 - light; + uint32_t inv_desaturate = 256 - constants.desaturate; + + uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; + + red = (red * inv_desaturate + intensity) / 256; + green = (green * inv_desaturate + intensity) / 256; + blue = (blue * inv_desaturate + intensity) / 256; + + red = (constants.fade_red * inv_light + red * light) / 256; + green = (constants.fade_green * inv_light + green * light) / 256; + blue = (constants.fade_blue * inv_light + blue * light) / 256; + + red = (red * constants.light_red) / 256; + green = (green * constants.light_green) / 256; + blue = (blue * constants.light_blue) / 256; + } + + dest[x] = 0xff000000 | (red << 16) | (green << 8) | blue; + } while (++x <= x2); + } +}; + +///////////////////////////////////////////////////////////////////////////// + +void R_FinishDrawerCommands() +{ + DrawerCommandQueue::Finish(); +} + +void R_DrawColumnP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_FillColumnP_RGBA() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_FillAddColumn_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_FillAddClampColumn_RGBA() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_FillSubClampColumn_RGBA() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_FillRevSubClampColumn_RGBA() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawFuzzColumnP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); + fuzzpos = (fuzzpos + dc_yh - dc_yl) % FUZZTABLE; +} + +void R_DrawAddColumnP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawTranslatedColumnP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawTlatedAddColumnP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawShadedColumnP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawAddClampColumnP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawAddClampTranslatedColumnP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawSubClampColumnP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawSubClampTranslatedColumnP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawRevSubClampColumnP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawRevSubClampTranslatedColumnP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawSpanP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawSpanMaskedP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawSpanTranslucentP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawSpanMaskedTranslucentP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawSpanAddClampP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawSpanMaskedAddClampP_RGBA_C() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_FillSpan_RGBA() +{ + DrawerCommandQueue::QueueCommand(); +} + +DWORD vlinec1_RGBA() +{ + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; +} + +void vlinec4_RGBA() +{ + DrawerCommandQueue::QueueCommand(); +} + +DWORD mvlinec1_RGBA() +{ + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; +} + +void mvlinec4_RGBA() +{ + DrawerCommandQueue::QueueCommand(); +} + +fixed_t tmvline1_add_RGBA() +{ + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; +} + +void tmvline4_add_RGBA() +{ + DrawerCommandQueue::QueueCommand(); +} + +fixed_t tmvline1_addclamp_RGBA() +{ + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; +} + +void tmvline4_addclamp_RGBA() +{ + DrawerCommandQueue::QueueCommand(); +} + +fixed_t tmvline1_subclamp_RGBA() +{ + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; +} + +void tmvline4_subclamp_RGBA() +{ + DrawerCommandQueue::QueueCommand(); +} + +fixed_t tmvline1_revsubclamp_RGBA() +{ + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; +} + +void tmvline4_revsubclamp_RGBA() +{ + DrawerCommandQueue::QueueCommand(); +} + +void R_DrawFogBoundarySection_RGBA(int y, int y2, int x1) +{ + for (; y < y2; ++y) + { + int x2 = spanend[y]; + DrawerCommandQueue::QueueCommand(y, x1, x2); + } +} + +void R_DrawFogBoundary_RGBA(int x1, int x2, short *uclip, short *dclip) +{ + // To do: we do not need to create new spans when using rgba output - instead we should calculate light on a per pixel basis + + // This is essentially the same as R_MapVisPlane but with an extra step + // to create new horizontal spans whenever the light changes enough that + // we need to use a new colormap. + + double lightstep = rw_lightstep; + double light = rw_light + rw_lightstep*(x2 - x1 - 1); + int x = x2 - 1; + int t2 = uclip[x]; + int b2 = dclip[x]; + int rcolormap = GETPALOOKUP(light, wallshade); + int lcolormap; + BYTE *basecolormapdata = basecolormap->Maps; + + if (b2 > t2) + { + clearbufshort(spanend + t2, b2 - t2, x); + } + + R_SetColorMapLight(basecolormap, (float)light, wallshade); + + BYTE *fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); + + for (--x; x >= x1; --x) + { + int t1 = uclip[x]; + int b1 = dclip[x]; + const int xr = x + 1; + int stop; + + light -= rw_lightstep; + lcolormap = GETPALOOKUP(light, wallshade); + if (lcolormap != rcolormap) + { + if (t2 < b2 && rcolormap != 0) + { // Colormap 0 is always the identity map, so rendering it is + // just a waste of time. + R_DrawFogBoundarySection_RGBA(t2, b2, xr); + } + if (t1 < t2) t2 = t1; + if (b1 > b2) b2 = b1; + if (t2 < b2) + { + clearbufshort(spanend + t2, b2 - t2, x); + } + rcolormap = lcolormap; + R_SetColorMapLight(basecolormap, (float)light, wallshade); + fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); + } + else + { + if (fake_dc_colormap != basecolormapdata) + { + stop = MIN(t1, b2); + while (t2 < stop) + { + int y = t2++; + DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); + } + stop = MAX(b1, t2); + while (b2 > stop) + { + int y = --b2; + DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); + } + } + else + { + t2 = MAX(t2, MIN(t1, b2)); + b2 = MIN(b2, MAX(b1, t2)); + } + + stop = MIN(t2, b1); + while (t1 < stop) + { + spanend[t1++] = x; + } + stop = MAX(b2, t2); + while (b1 > stop) + { + spanend[--b1] = x; + } + } + + t2 = uclip[x]; + b2 = dclip[x]; + } + if (t2 < b2 && rcolormap != 0) + { + R_DrawFogBoundarySection_RGBA(t2, b2, x1); + } +} diff --git a/src/r_drawt.cpp b/src/r_drawt.cpp index ca6862ed6..c829c2dc4 100644 --- a/src/r_drawt.cpp +++ b/src/r_drawt.cpp @@ -1019,6 +1019,14 @@ void rt_initcols_pal (BYTE *buff) horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0]; } +void rt_span_coverage_pal(int x, int start, int stop) +{ + unsigned int **tspan = &dc_ctspan[x & 3]; + (*tspan)[0] = start; + (*tspan)[1] = stop; + *tspan += 2; +} + // Stretches a column into a temporary buffer which is later // drawn to the screen along with up to three other columns. void R_DrawColumnHorizP_C (void) diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index ff5c0d82f..bbf68a795 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -46,53 +46,1560 @@ #include #endif -uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT*4]; -uint32_t *dc_temp_rgba; - -// Defined in r_draw_t.cpp: extern unsigned int dc_tspans[4][MAXHEIGHT]; extern unsigned int *dc_ctspan[4]; extern unsigned int *horizspan[4]; +///////////////////////////////////////////////////////////////////////////// + +class RtCopy1colRGBACommand : public DrawerCommand +{ + int hx; + int sx; + int yl; + int yh; + BYTE *dc_destorg; + int dc_pitch; + +public: + RtCopy1colRGBACommand(int hx, int sx, int yl, int yh) + { + this->hx = hx; + this->sx = sx; + this->yl = yl; + this->yh = yh; + + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + } + + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4 + hx]; + pitch = dc_pitch; + + if (count & 1) { + *dest = *source; + source += 4; + dest += pitch; + } + if (count & 2) { + dest[0] = source[0]; + dest[pitch] = source[4]; + source += 8; + dest += pitch * 2; + } + if (!(count >>= 2)) + return; + + do { + dest[0] = source[0]; + dest[pitch] = source[4]; + dest[pitch * 2] = source[8]; + dest[pitch * 3] = source[12]; + source += 16; + dest += pitch * 4; + } while (--count); + } +}; + +class RtMap1colRGBACommand : public DrawerCommand +{ + int hx; + int sx; + int yl; + int yh; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + BYTE *dc_destorg; + int dc_pitch; + +public: + RtMap1colRGBACommand(int hx, int sx, int yl, int yh) + { + this->hx = hx; + this->sx = sx; + this->yl = yl; + this->yh = yh; + + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + } + + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4 + hx]; + pitch = dc_pitch; + + if (count & 1) { + *dest = shade_pal_index(*source, light, shade_constants); + source += 4; + dest += pitch; + } + if (!(count >>= 1)) + return; + + do { + dest[0] = shade_pal_index(source[0], light, shade_constants); + dest[pitch] = shade_pal_index(source[4], light, shade_constants); + source += 8; + dest += pitch * 2; + } while (--count); + } +}; + +class RtMap4colsRGBACommand : public DrawerCommand +{ + int sx; + int yl; + int yh; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + BYTE *dc_destorg; + int dc_pitch; + +public: + RtMap4colsRGBACommand(int sx, int yl, int yh) + { + this->sx = sx; + this->yl = yl; + this->yh = yh; + + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + } + +#ifdef NO_SSE + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4]; + pitch = dc_pitch; + + if (count & 1) { + dest[0] = shade_pal_index(source[0], light, shade_constants); + dest[1] = shade_pal_index(source[1], light, shade_constants); + dest[2] = shade_pal_index(source[2], light, shade_constants); + dest[3] = shade_pal_index(source[3], light, shade_constants); + source += 4; + dest += pitch; + } + if (!(count >>= 1)) + return; + + do { + dest[0] = shade_pal_index(source[0], light, shade_constants); + dest[1] = shade_pal_index(source[1], light, shade_constants); + dest[2] = shade_pal_index(source[2], light, shade_constants); + dest[3] = shade_pal_index(source[3], light, shade_constants); + dest[pitch] = shade_pal_index(source[4], light, shade_constants); + dest[pitch + 1] = shade_pal_index(source[5], light, shade_constants); + dest[pitch + 2] = shade_pal_index(source[6], light, shade_constants); + dest[pitch + 3] = shade_pal_index(source[7], light, shade_constants); + source += 8; + dest += pitch * 2; + } while (--count); + } +#else + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(dc_light); + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4]; + pitch = dc_pitch; + + if (shade_constants.simple_shade) + { + SSE_SHADE_SIMPLE_INIT(light); + + if (count & 1) { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + + source += 4; + dest += pitch; + } + if (!(count >>= 1)) + return; + + do { + // shade_pal_index 0-3 + { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + } + + // shade_pal_index 4-7 (pitch) + { + uint32_t p0 = source[4]; + uint32_t p1 = source[5]; + uint32_t p2 = source[6]; + uint32_t p3 = source[7]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)(dest + pitch), fg); + } + + source += 8; + dest += pitch * 2; + } while (--count); + } + else + { + SSE_SHADE_INIT(light, shade_constants); + + if (count & 1) { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + + source += 4; + dest += pitch; + } + if (!(count >>= 1)) + return; + + do { + // shade_pal_index 0-3 + { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + } + + // shade_pal_index 4-7 (pitch) + { + uint32_t p0 = source[4]; + uint32_t p1 = source[5]; + uint32_t p2 = source[6]; + uint32_t p3 = source[7]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)(dest + pitch), fg); + } + + source += 8; + dest += pitch * 2; + } while (--count); + } + } +#endif +}; + +class RtTranslate1colRGBACommand : public DrawerCommand +{ + const BYTE *translation; + int hx; + int yl; + int yh; + +public: + RtTranslate1colRGBACommand(const BYTE *translation, int hx, int yl, int yh) + { + this->translation = translation; + this->hx = hx; + this->yl = yl; + this->yh = yh; + } + + void Execute(DrawerThread *thread) override + { + int count = yh - yl + 1; + uint32_t *source = &thread->dc_temp_rgba[yl*4 + hx]; + + // Things we do to hit the compiler's optimizer with a clue bat: + // 1. Parallelism is explicitly spelled out by using a separate + // C instruction for each assembly instruction. GCC lets me + // have four temporaries, but VC++ spills to the stack with + // more than two. Two is probably optimal, anyway. + // 2. The results of the translation lookups are explicitly + // stored in byte-sized variables. This causes the VC++ code + // to use byte mov instructions in most cases; for apparently + // random reasons, it will use movzx for some places. GCC + // ignores this and uses movzx always. + + // Do 8 rows at a time. + for (int count8 = count >> 3; count8; --count8) + { + int c0, c1; + BYTE b0, b1; + + c0 = source[0]; c1 = source[4]; + b0 = translation[c0]; b1 = translation[c1]; + source[0] = b0; source[4] = b1; + + c0 = source[8]; c1 = source[12]; + b0 = translation[c0]; b1 = translation[c1]; + source[8] = b0; source[12] = b1; + + c0 = source[16]; c1 = source[20]; + b0 = translation[c0]; b1 = translation[c1]; + source[16] = b0; source[20] = b1; + + c0 = source[24]; c1 = source[28]; + b0 = translation[c0]; b1 = translation[c1]; + source[24] = b0; source[28] = b1; + + source += 32; + } + // Finish by doing 1 row at a time. + for (count &= 7; count; --count, source += 4) + { + source[0] = translation[source[0]]; + } + } +}; + +class RtTranslate4colsRGBACommand : public DrawerCommand +{ + const BYTE *translation; + int yl; + int yh; + +public: + RtTranslate4colsRGBACommand(const BYTE *translation, int yl, int yh) + { + this->translation = translation; + this->yl = yl; + this->yh = yh; + } + + void Execute(DrawerThread *thread) override + { + int count = yh - yl + 1; + uint32_t *source = &thread->dc_temp_rgba[yl*4]; + int c0, c1; + BYTE b0, b1; + + // Do 2 rows at a time. + for (int count8 = count >> 1; count8; --count8) + { + c0 = source[0]; c1 = source[1]; + b0 = translation[c0]; b1 = translation[c1]; + source[0] = b0; source[1] = b1; + + c0 = source[2]; c1 = source[3]; + b0 = translation[c0]; b1 = translation[c1]; + source[2] = b0; source[3] = b1; + + c0 = source[4]; c1 = source[5]; + b0 = translation[c0]; b1 = translation[c1]; + source[4] = b0; source[5] = b1; + + c0 = source[6]; c1 = source[7]; + b0 = translation[c0]; b1 = translation[c1]; + source[6] = b0; source[7] = b1; + + source += 8; + } + // Do the final row if count was odd. + if (count & 1) + { + c0 = source[0]; c1 = source[1]; + b0 = translation[c0]; b1 = translation[c1]; + source[0] = b0; source[1] = b1; + + c0 = source[2]; c1 = source[3]; + b0 = translation[c0]; b1 = translation[c1]; + source[2] = b0; source[3] = b1; + } + } +}; + +class RtAdd1colRGBACommand : public DrawerCommand +{ + int hx; + int sx; + int yl; + int yh; + BYTE *dc_destorg; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + +public: + RtAdd1colRGBACommand(int hx, int sx, int yl, int yh) + { + this->hx = hx; + this->sx = sx; + this->yl = yl; + this->yh = yh; + + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + } + + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4 + hx]; + pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do { + uint32_t fg = shade_pal_index(*source, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + + source += 4; + dest += pitch; + } while (--count); + } +}; + +class RtAdd4colsRGBACommand : public DrawerCommand +{ + int sx; + int yl; + int yh; + BYTE *dc_destorg; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + +public: + RtAdd4colsRGBACommand(int sx, int yl, int yh) + { + this->sx = sx; + this->yl = yl; + this->yh = yh; + + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + } + +#ifdef NO_SSE + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4]; + pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do { + for (int i = 0; i < 4; i++) + { + uint32_t fg = shade_pal_index(source[i], light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + + source += 4; + dest += pitch; + } while (--count); + } +#else + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4]; + pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + ShadeConstants shade_constants = dc_shade_constants; + + if (shade_constants.simple_shade) + { + SSE_SHADE_SIMPLE_INIT(light); + + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE_SIMPLE(fg); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += 4; + dest += pitch; + } while (--count); + } + else + { + SSE_SHADE_INIT(light, shade_constants); + + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE(fg, shade_constants); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += 4; + dest += pitch; + } while (--count); + } + } +#endif +}; + +class RtShaded1colRGBACommand : public DrawerCommand +{ + int hx; + int sx; + int yl; + int yh; + lighttable_t *dc_colormap; + BYTE *dc_destorg; + int dc_pitch; + int dc_color; + fixed_t dc_light; + +public: + RtShaded1colRGBACommand(int hx, int sx, int yl, int yh) + { + this->hx = hx; + this->sx = sx; + this->yl = yl; + this->yh = yh; + + dc_colormap = ::dc_colormap; + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + dc_color = ::dc_color; + dc_light = ::dc_light; + } + + void Execute(DrawerThread *thread) override + { + BYTE *colormap; + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + colormap = dc_colormap; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4 + hx]; + pitch = dc_pitch; + + uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + do { + uint32_t alpha = colormap[*source]; + uint32_t inv_alpha = 64 - alpha; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; + uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; + uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + source += 4; + dest += pitch; + } while (--count); + } +}; + +class RtShaded4colsRGBACommand : public DrawerCommand +{ + int sx; + int yl; + int yh; + lighttable_t *dc_colormap; + int dc_color; + BYTE *dc_destorg; + int dc_pitch; + fixed_t dc_light; + +public: + RtShaded4colsRGBACommand(int sx, int yl, int yh) + { + this->sx = sx; + this->yl = yl; + this->yh = yh; + + dc_colormap = ::dc_colormap; + dc_color = ::dc_color; + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + } + +#ifdef NO_SSE + void Execute(DrawerThread *thread) override + { + BYTE *colormap; + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + colormap = dc_colormap; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4]; + pitch = dc_pitch; + + uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + do { + for (int i = 0; i < 4; i++) + { + uint32_t alpha = colormap[source[i]]; + uint32_t inv_alpha = 64 - alpha; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; + uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; + uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + source += 4; + dest += pitch; + } while (--count); + } +#else + void Execute(DrawerThread *thread) override + { + BYTE *colormap; + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + colormap = dc_colormap; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4]; + pitch = dc_pitch; + + __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light))), _mm_setzero_si128()); + __m128i alpha_one = _mm_set1_epi16(64); + + do { + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; + + __m128i alpha_hi = _mm_set_epi16(64, p3, p3, p3, 64, p2, p2, p2); + __m128i alpha_lo = _mm_set_epi16(64, p1, p1, p1, 64, p0, p0, p0); + __m128i inv_alpha_hi = _mm_subs_epu16(alpha_one, alpha_hi); + __m128i inv_alpha_lo = _mm_subs_epu16(alpha_one, alpha_lo); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * alpha + bg_red * inv_alpha) / 64: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg, alpha_hi), _mm_mullo_epi16(bg_hi, inv_alpha_hi)), 6); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg, alpha_lo), _mm_mullo_epi16(bg_lo, inv_alpha_lo)), 6); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += 4; + dest += pitch; + } while (--count); + } +#endif +}; + +class RtAddClamp1colRGBACommand : public DrawerCommand +{ + int hx; + int sx; + int yl; + int yh; + BYTE *dc_destorg; + int dc_pitch; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + +public: + RtAddClamp1colRGBACommand(int hx, int sx, int yl, int yh) + { + this->hx = hx; + this->sx = sx; + this->yl = yl; + this->yh = yh; + + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_shade_constants = ::dc_shade_constants; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + } + + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4 + hx]; + pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do { + uint32_t fg = shade_pal_index(*source, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + source += 4; + dest += pitch; + } while (--count); + } +}; + +class RtAddClamp4colsRGBACommand : public DrawerCommand +{ + int sx; + int yl; + int yh; + BYTE *dc_destorg; + int dc_pitch; + fixed_t dc_light; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + ShadeConstants dc_shade_constants; + +public: + RtAddClamp4colsRGBACommand(int sx, int yl, int yh) + { + this->sx = sx; + this->yl = yl; + this->yh = yh; + + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + dc_shade_constants = ::dc_shade_constants; + } + +#ifdef NO_SSE + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4]; + pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do { + for (int i = 0; i < 4; i++) + { + uint32_t fg = shade_pal_index(source[i], light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + source += 4; + dest += pitch; + } while (--count); + } +#else + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4]; + pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + ShadeConstants shade_constants = dc_shade_constants; + + if (shade_constants.simple_shade) + { + SSE_SHADE_SIMPLE_INIT(light); + + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE_SIMPLE(fg); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += 4; + dest += pitch; + } while (--count); + } + else + { + SSE_SHADE_INIT(light, shade_constants); + + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + SSE_SHADE(fg, shade_constants); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += 4; + dest += pitch; + } while (--count); + } + } +#endif +}; + +class RtSubClamp1colRGBACommand : public DrawerCommand +{ + int hx; + int sx; + int yl; + int yh; + BYTE *dc_destorg; + int dc_pitch; + fixed_t dc_light; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + ShadeConstants dc_shade_constants; + +public: + RtSubClamp1colRGBACommand(int hx, int sx, int yl, int yh) + { + this->hx = hx; + this->sx = sx; + this->yl = yl; + this->yh = yh; + + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + dc_shade_constants = ::dc_shade_constants; + } + + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4 + hx]; + pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do { + uint32_t fg = shade_pal_index(*source, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + source += 4; + dest += pitch; + } while (--count); + } +}; + +class RtSubClamp4colsRGBACommand : public DrawerCommand +{ + int sx; + int yl; + int yh; + BYTE *dc_destorg; + int dc_pitch; + fixed_t dc_light; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + ShadeConstants dc_shade_constants; + +public: + RtSubClamp4colsRGBACommand(int sx, int yl, int yh) + { + this->sx = sx; + this->yl = yl; + this->yh = yh; + + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + dc_shade_constants = ::dc_shade_constants; + } + + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4]; + pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do { + for (int i = 0; i < 4; i++) + { + uint32_t fg = shade_pal_index(source[i], light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + + source += 4; + dest += pitch; + } while (--count); + } +}; + +class RtRevSubClamp1colRGBACommand : public DrawerCommand +{ + int hx; + int sx; + int yl; + int yh; + BYTE *dc_destorg; + int dc_pitch; + fixed_t dc_light; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + ShadeConstants dc_shade_constants; + +public: + RtRevSubClamp1colRGBACommand(int hx, int sx, int yl, int yh) + { + this->hx = hx; + this->sx = sx; + this->yl = yl; + this->yh = yh; + + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + dc_shade_constants = ::dc_shade_constants; + } + + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4 + hx]; + pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do { + uint32_t fg = shade_pal_index(*source, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + source += 4; + dest += pitch; + } while (--count); + } +}; + +class RtRevSubClamp4colsRGBACommand : public DrawerCommand +{ + int sx; + int yl; + int yh; + BYTE *dc_destorg; + int dc_pitch; + fixed_t dc_light; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + ShadeConstants dc_shade_constants; + +public: + RtRevSubClamp4colsRGBACommand(int sx, int yl, int yh) + { + this->sx = sx; + this->yl = yl; + this->yh = yh; + + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + dc_light = ::dc_light; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; + dc_shade_constants = ::dc_shade_constants; + } + + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + + count = yh - yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; + source = &thread->dc_temp_rgba[yl * 4]; + pitch = dc_pitch; + + uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = dc_shade_constants; + + uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + + do { + for (int i = 0; i < 4; i++) + { + uint32_t fg = shade_pal_index(source[i], light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + + source += 4; + dest += pitch; + } while (--count); + } +}; + +class RtInitColsRGBACommand : public DrawerCommand +{ + BYTE *buff; + +public: + RtInitColsRGBACommand(BYTE *buff) + { + this->buff = buff; + } + + void Execute(DrawerThread *thread) override + { + thread->dc_temp_rgba = buff == NULL ? thread->dc_temp_rgbabuff_rgba : (uint32_t*)buff; + } +}; + +class DrawColumnHorizRGBACommand : public DrawerCommand +{ + int dc_count; + fixed_t dc_iscale; + fixed_t dc_texturefrac; + const BYTE *dc_source; + int dc_x; + int dc_yl; + int dc_yh; + +public: + DrawColumnHorizRGBACommand() + { + dc_count = ::dc_count; + dc_iscale = ::dc_iscale; + dc_texturefrac = ::dc_texturefrac; + dc_source = ::dc_source; + dc_x = ::dc_x; + dc_yl = ::dc_yl; + dc_yh = ::dc_yh; + } + + void Execute(DrawerThread *thread) override + { + int count = dc_count; + uint32_t *dest; + fixed_t fracstep; + fixed_t frac; + + if (count <= 0) + return; + + { + int x = dc_x & 3; + dest = &thread->dc_temp_rgba[x + 4 * dc_yl]; + } + fracstep = dc_iscale; + frac = dc_texturefrac; + + { + const BYTE *source = dc_source; + + if (count & 1) { + *dest = source[frac >> FRACBITS]; dest += 4; frac += fracstep; + } + if (count & 2) { + dest[0] = source[frac >> FRACBITS]; frac += fracstep; + dest[4] = source[frac >> FRACBITS]; frac += fracstep; + dest += 8; + } + if (count & 4) { + dest[0] = source[frac >> FRACBITS]; frac += fracstep; + dest[4] = source[frac >> FRACBITS]; frac += fracstep; + dest[8] = source[frac >> FRACBITS]; frac += fracstep; + dest[12] = source[frac >> FRACBITS]; frac += fracstep; + dest += 16; + } + count >>= 3; + if (!count) return; + + do + { + dest[0] = source[frac >> FRACBITS]; frac += fracstep; + dest[4] = source[frac >> FRACBITS]; frac += fracstep; + dest[8] = source[frac >> FRACBITS]; frac += fracstep; + dest[12] = source[frac >> FRACBITS]; frac += fracstep; + dest[16] = source[frac >> FRACBITS]; frac += fracstep; + dest[20] = source[frac >> FRACBITS]; frac += fracstep; + dest[24] = source[frac >> FRACBITS]; frac += fracstep; + dest[28] = source[frac >> FRACBITS]; frac += fracstep; + dest += 32; + } while (--count); + } + } +}; + +class FillColumnHorizRGBACommand : public DrawerCommand +{ + int dc_x; + int dc_yl; + int dc_yh; + int dc_count; + int dc_color; + +public: + FillColumnHorizRGBACommand() + { + dc_x = ::dc_x; + dc_count = ::dc_count; + dc_color = ::dc_color; + dc_yl = ::dc_yl; + dc_yh = ::dc_yh; + } + + void Execute(DrawerThread *thread) override + { + int count = dc_count; + int color = dc_color; + uint32_t *dest; + + if (count <= 0) + return; + + { + int x = dc_x & 3; + dest = &thread->dc_temp_rgba[x + 4 * dc_yl]; + } + + if (count & 1) { + *dest = color; + dest += 4; + } + if (!(count >>= 1)) + return; + do { + dest[0] = color; dest[4] = color; + dest += 8; + } while (--count); + } +}; + +///////////////////////////////////////////////////////////////////////////// + // Copies one span at hx to the screen at sx. void rt_copy1col_RGBA_c (int hx, int sx, int yl, int yh) { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh-yl; - if (count < 0) - return; - count++; - - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl*4 + hx]; - pitch = dc_pitch; - - if (count & 1) { - *dest = *source; - source += 4; - dest += pitch; - } - if (count & 2) { - dest[0] = source[0]; - dest[pitch] = source[4]; - source += 8; - dest += pitch*2; - } - if (!(count >>= 2)) - return; - - do { - dest[0] = source[0]; - dest[pitch] = source[4]; - dest[pitch*2] = source[8]; - dest[pitch*3] = source[12]; - source += 16; - dest += pitch*4; - } while (--count); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Copies all four spans to the screen starting at sx. @@ -108,293 +1615,23 @@ void rt_copy4cols_RGBA_c (int sx, int yl, int yh) // Maps one span at hx to the screen at sx. void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh) { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh-yl; - if (count < 0) - return; - count++; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl*4 + hx]; - pitch = dc_pitch; - - if (count & 1) { - *dest = shade_pal_index(*source, light, shade_constants); - source += 4; - dest += pitch; - } - if (!(count >>= 1)) - return; - - do { - dest[0] = shade_pal_index(source[0], light, shade_constants); - dest[pitch] = shade_pal_index(source[4], light, shade_constants); - source += 8; - dest += pitch*2; - } while (--count); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Maps all four spans to the screen starting at sx. void rt_map4cols_RGBA_c (int sx, int yl, int yh) { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh-yl; - if (count < 0) - return; - count++; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl*4]; - pitch = dc_pitch; - - if (count & 1) { - dest[0] = shade_pal_index(source[0], light, shade_constants); - dest[1] = shade_pal_index(source[1], light, shade_constants); - dest[2] = shade_pal_index(source[2], light, shade_constants); - dest[3] = shade_pal_index(source[3], light, shade_constants); - source += 4; - dest += pitch; - } - if (!(count >>= 1)) - return; - - do { - dest[0] = shade_pal_index(source[0], light, shade_constants); - dest[1] = shade_pal_index(source[1], light, shade_constants); - dest[2] = shade_pal_index(source[2], light, shade_constants); - dest[3] = shade_pal_index(source[3], light, shade_constants); - dest[pitch] = shade_pal_index(source[4], light, shade_constants); - dest[pitch + 1] = shade_pal_index(source[5], light, shade_constants); - dest[pitch + 2] = shade_pal_index(source[6], light, shade_constants); - dest[pitch + 3] = shade_pal_index(source[7], light, shade_constants); - source += 8; - dest += pitch*2; - } while (--count); -} - -// Maps all four spans to the screen starting at sx. -void rt_map4cols_RGBA_SSE(int sx, int yl, int yh) -{ - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh - yl; - if (count < 0) - return; - count++; - - ShadeConstants shade_constants = dc_shade_constants; - uint32_t light = calc_light_multiplier(dc_light); - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl * 4]; - pitch = dc_pitch; - - if (shade_constants.simple_shade) - { - SSE_SHADE_SIMPLE_INIT(light); - - if (count & 1) { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - - source += 4; - dest += pitch; - } - if (!(count >>= 1)) - return; - - do { - // shade_pal_index 0-3 - { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - } - - // shade_pal_index 4-7 (pitch) - { - uint32_t p0 = source[4]; - uint32_t p1 = source[5]; - uint32_t p2 = source[6]; - uint32_t p3 = source[7]; - - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)(dest + pitch), fg); - } - - source += 8; - dest += pitch * 2; - } while (--count); - } - else - { - SSE_SHADE_INIT(light, shade_constants); - - if (count & 1) { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - - source += 4; - dest += pitch; - } - if (!(count >>= 1)) - return; - - do { - // shade_pal_index 0-3 - { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - } - - // shade_pal_index 4-7 (pitch) - { - uint32_t p0 = source[4]; - uint32_t p1 = source[5]; - uint32_t p2 = source[6]; - uint32_t p3 = source[7]; - - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)(dest + pitch), fg); - } - - source += 8; - dest += pitch * 2; - } while (--count); - } + DrawerCommandQueue::QueueCommand(sx, yl, yh); } void rt_Translate1col_RGBA_c(const BYTE *translation, int hx, int yl, int yh) { - int count = yh - yl + 1; - uint32_t *source = &dc_temp_rgba[yl*4 + hx]; - - // Things we do to hit the compiler's optimizer with a clue bat: - // 1. Parallelism is explicitly spelled out by using a separate - // C instruction for each assembly instruction. GCC lets me - // have four temporaries, but VC++ spills to the stack with - // more than two. Two is probably optimal, anyway. - // 2. The results of the translation lookups are explicitly - // stored in byte-sized variables. This causes the VC++ code - // to use byte mov instructions in most cases; for apparently - // random reasons, it will use movzx for some places. GCC - // ignores this and uses movzx always. - - // Do 8 rows at a time. - for (int count8 = count >> 3; count8; --count8) - { - int c0, c1; - BYTE b0, b1; - - c0 = source[0]; c1 = source[4]; - b0 = translation[c0]; b1 = translation[c1]; - source[0] = b0; source[4] = b1; - - c0 = source[8]; c1 = source[12]; - b0 = translation[c0]; b1 = translation[c1]; - source[8] = b0; source[12] = b1; - - c0 = source[16]; c1 = source[20]; - b0 = translation[c0]; b1 = translation[c1]; - source[16] = b0; source[20] = b1; - - c0 = source[24]; c1 = source[28]; - b0 = translation[c0]; b1 = translation[c1]; - source[24] = b0; source[28] = b1; - - source += 32; - } - // Finish by doing 1 row at a time. - for (count &= 7; count; --count, source += 4) - { - source[0] = translation[source[0]]; - } + DrawerCommandQueue::QueueCommand(translation, hx, yl, yh); } void rt_Translate4cols_RGBA_c(const BYTE *translation, int yl, int yh) { - int count = yh - yl + 1; - uint32_t *source = &dc_temp_rgba[yl*4]; - int c0, c1; - BYTE b0, b1; - - // Do 2 rows at a time. - for (int count8 = count >> 1; count8; --count8) - { - c0 = source[0]; c1 = source[1]; - b0 = translation[c0]; b1 = translation[c1]; - source[0] = b0; source[1] = b1; - - c0 = source[2]; c1 = source[3]; - b0 = translation[c0]; b1 = translation[c1]; - source[2] = b0; source[3] = b1; - - c0 = source[4]; c1 = source[5]; - b0 = translation[c0]; b1 = translation[c1]; - source[4] = b0; source[5] = b1; - - c0 = source[6]; c1 = source[7]; - b0 = translation[c0]; b1 = translation[c1]; - source[6] = b0; source[7] = b1; - - source += 8; - } - // Do the final row if count was odd. - if (count & 1) - { - c0 = source[0]; c1 = source[1]; - b0 = translation[c0]; b1 = translation[c1]; - source[0] = b0; source[1] = b1; - - c0 = source[2]; c1 = source[3]; - b0 = translation[c0]; b1 = translation[c1]; - source[2] = b0; source[3] = b1; - } + DrawerCommandQueue::QueueCommand(translation, yl, yh); } // Translates one span at hx to the screen at sx. @@ -414,195 +1651,15 @@ void rt_tlate4cols_RGBA_c (int sx, int yl, int yh) // Adds one span at hx to the screen at sx without clamping. void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh) { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh-yl; - if (count < 0) - return; - count++; - - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl*4 + hx]; - pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do { - uint32_t fg = shade_pal_index(*source, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - - source += 4; - dest += pitch; - } while (--count); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Adds all four spans to the screen starting at sx without clamping. void rt_add4cols_RGBA_c (int sx, int yl, int yh) { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh-yl; - if (count < 0) - return; - count++; - - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl*4]; - pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do { - for (int i = 0; i < 4; i++) - { - uint32_t fg = shade_pal_index(source[i], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - - source += 4; - dest += pitch; - } while (--count); + DrawerCommandQueue::QueueCommand(sx, yl, yh); } -// Adds all four spans to the screen starting at sx without clamping. -#ifndef NO_SSE -void rt_add4cols_RGBA_SSE(int sx, int yl, int yh) -{ - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh - yl; - if (count < 0) - return; - count++; - - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl * 4]; - pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - ShadeConstants shade_constants = dc_shade_constants; - - if (shade_constants.simple_shade) - { - SSE_SHADE_SIMPLE_INIT(light); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE_SIMPLE(fg); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += 4; - dest += pitch; - } while (--count); - } - else - { - SSE_SHADE_INIT(light, shade_constants); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE(fg, shade_constants); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += 4; - dest += pitch; - } while (--count); - } -} -#endif - // Translates and adds one span at hx to the screen at sx without clamping. void rt_tlateadd1col_RGBA_c (int hx, int sx, int yl, int yh) { @@ -620,332 +1677,27 @@ void rt_tlateadd4cols_RGBA_c(int sx, int yl, int yh) // Shades one span at hx to the screen at sx. void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh) { - BYTE *colormap; - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh-yl; - if (count < 0) - return; - count++; - - colormap = dc_colormap; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl*4 + hx]; - pitch = dc_pitch; - - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - do { - uint32_t alpha = colormap[*source]; - uint32_t inv_alpha = 64 - alpha; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; - uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; - uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += 4; - dest += pitch; - } while (--count); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Shades all four spans to the screen starting at sx. void rt_shaded4cols_RGBA_c (int sx, int yl, int yh) { - BYTE *colormap; - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh-yl; - if (count < 0) - return; - count++; - - colormap = dc_colormap; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl*4]; - pitch = dc_pitch; - - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - do { - for (int i = 0; i < 4; i++) - { - uint32_t alpha = colormap[source[i]]; - uint32_t inv_alpha = 64 - alpha; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; - uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; - uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - source += 4; - dest += pitch; - } while (--count); + DrawerCommandQueue::QueueCommand(sx, yl, yh); } -// Shades all four spans to the screen starting at sx. -#ifndef NO_SSE -void rt_shaded4cols_RGBA_SSE(int sx, int yl, int yh) -{ - BYTE *colormap; - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh - yl; - if (count < 0) - return; - count++; - - colormap = dc_colormap; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl * 4]; - pitch = dc_pitch; - - __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light))), _mm_setzero_si128()); - __m128i alpha_one = _mm_set1_epi16(64); - - do { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - __m128i alpha_hi = _mm_set_epi16(64, p3, p3, p3, 64, p2, p2, p2); - __m128i alpha_lo = _mm_set_epi16(64, p1, p1, p1, 64, p0, p0, p0); - __m128i inv_alpha_hi = _mm_subs_epu16(alpha_one, alpha_hi); - __m128i inv_alpha_lo = _mm_subs_epu16(alpha_one, alpha_lo); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * alpha + bg_red * inv_alpha) / 64: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg, alpha_hi), _mm_mullo_epi16(bg_hi, inv_alpha_hi)), 6); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg, alpha_lo), _mm_mullo_epi16(bg_lo, inv_alpha_lo)), 6); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += 4; - dest += pitch; - } while (--count); -} -#endif - // Adds one span at hx to the screen at sx with clamping. void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh) { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh-yl; - if (count < 0) - return; - count++; - - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl*4 + hx]; - pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do { - uint32_t fg = shade_pal_index(*source, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += 4; - dest += pitch; - } while (--count); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Adds all four spans to the screen starting at sx with clamping. void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh) { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh-yl; - if (count < 0) - return; - count++; - - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl*4]; - pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do { - for (int i = 0; i < 4; i++) - { - uint32_t fg = shade_pal_index(source[i], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - source += 4; - dest += pitch; - } while (--count); + DrawerCommandQueue::QueueCommand(sx, yl, yh); } -// Adds all four spans to the screen starting at sx with clamping. -#ifndef NO_SSE -void rt_addclamp4cols_RGBA_SSE(int sx, int yl, int yh) -{ - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh - yl; - if (count < 0) - return; - count++; - - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl * 4]; - pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - ShadeConstants shade_constants = dc_shade_constants; - - if (shade_constants.simple_shade) - { - SSE_SHADE_SIMPLE_INIT(light); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE_SIMPLE(fg); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += 4; - dest += pitch; - } while (--count); - } - else - { - SSE_SHADE_INIT(light, shade_constants); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE(fg, shade_constants); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += 4; - dest += pitch; - } while (--count); - } -} -#endif - // Translates and adds one span at hx to the screen at sx with clamping. void rt_tlateaddclamp1col_RGBA_c (int hx, int sx, int yl, int yh) { @@ -963,91 +1715,13 @@ void rt_tlateaddclamp4cols_RGBA_c (int sx, int yl, int yh) // Subtracts one span at hx to the screen at sx with clamping. void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh) { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh-yl; - if (count < 0) - return; - count++; - - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl*4 + hx]; - pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do { - uint32_t fg = shade_pal_index(*source, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += 4; - dest += pitch; - } while (--count); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Subtracts all four spans to the screen starting at sx with clamping. void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh) { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh-yl; - if (count < 0) - return; - count++; - - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl*4]; - pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do { - for (int i = 0; i < 4; i++) - { - uint32_t fg = shade_pal_index(source[i], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - - source += 4; - dest += pitch; - } while (--count); + DrawerCommandQueue::QueueCommand(sx, yl, yh); } // Translates and subtracts one span at hx to the screen at sx with clamping. @@ -1067,91 +1741,13 @@ void rt_tlatesubclamp4cols_RGBA_c (int sx, int yl, int yh) // Subtracts one span at hx from the screen at sx with clamping. void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh-yl; - if (count < 0) - return; - count++; - - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl*4 + hx]; - pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do { - uint32_t fg = shade_pal_index(*source, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += 4; - dest += pitch; - } while (--count); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Subtracts all four spans from the screen starting at sx with clamping. void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh) { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - - count = yh-yl; - if (count < 0) - return; - count++; - - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &dc_temp_rgba[yl*4]; - pitch = dc_pitch; - - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); - - do { - for (int i = 0; i < 4; i++) - { - uint32_t fg = shade_pal_index(source[i], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - - source += 4; - dest += pitch; - } while (--count); + DrawerCommandQueue::QueueCommand(sx, yl, yh); } // Translates and subtracts one span at hx from the screen at sx with clamping. @@ -1172,102 +1768,41 @@ void rt_tlaterevsubclamp4cols_RGBA_c (int sx, int yl, int yh) // call this function to set up the span pointers. void rt_initcols_rgba (BYTE *buff) { - int y; - - dc_temp_rgba = buff == NULL ? dc_temp_rgbabuff_rgba : (uint32_t*)buff; - for (y = 3; y >= 0; y--) + for (int y = 3; y >= 0; y--) horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0]; + + DrawerCommandQueue::QueueCommand(buff); +} + +void rt_span_coverage_rgba(int x, int start, int stop) +{ + unsigned int **tspan = &dc_ctspan[x & 3]; + (*tspan)[0] = start; + (*tspan)[1] = stop; + *tspan += 2; } // Stretches a column into a temporary buffer which is later // drawn to the screen along with up to three other columns. void R_DrawColumnHorizP_RGBA_C (void) { - int count = dc_count; - uint32_t *dest; - fixed_t fracstep; - fixed_t frac; + int x = dc_x & 3; + unsigned int **span = &dc_ctspan[x]; + (*span)[0] = dc_yl; + (*span)[1] = dc_yh; + *span += 2; - if (count <= 0) - return; - - { - int x = dc_x & 3; - unsigned int **span; - - span = &dc_ctspan[x]; - (*span)[0] = dc_yl; - (*span)[1] = dc_yh; - *span += 2; - dest = &dc_temp_rgba[x + 4*dc_yl]; - } - fracstep = dc_iscale; - frac = dc_texturefrac; - - { - const BYTE *source = dc_source; - - if (count & 1) { - *dest = source[frac>>FRACBITS]; dest += 4; frac += fracstep; - } - if (count & 2) { - dest[0] = source[frac>>FRACBITS]; frac += fracstep; - dest[4] = source[frac>>FRACBITS]; frac += fracstep; - dest += 8; - } - if (count & 4) { - dest[0] = source[frac>>FRACBITS]; frac += fracstep; - dest[4] = source[frac>>FRACBITS]; frac += fracstep; - dest[8] = source[frac>>FRACBITS]; frac += fracstep; - dest[12]= source[frac>>FRACBITS]; frac += fracstep; - dest += 16; - } - count >>= 3; - if (!count) return; - - do - { - dest[0] = source[frac>>FRACBITS]; frac += fracstep; - dest[4] = source[frac>>FRACBITS]; frac += fracstep; - dest[8] = source[frac>>FRACBITS]; frac += fracstep; - dest[12]= source[frac>>FRACBITS]; frac += fracstep; - dest[16]= source[frac>>FRACBITS]; frac += fracstep; - dest[20]= source[frac>>FRACBITS]; frac += fracstep; - dest[24]= source[frac>>FRACBITS]; frac += fracstep; - dest[28]= source[frac>>FRACBITS]; frac += fracstep; - dest += 32; - } while (--count); - } + DrawerCommandQueue::QueueCommand(); } // [RH] Just fills a column with a given color void R_FillColumnHorizP_RGBA_C (void) { - int count = dc_count; - BYTE color = dc_color; - uint32_t *dest; + int x = dc_x & 3; + unsigned int **span = &dc_ctspan[x]; + (*span)[0] = dc_yl; + (*span)[1] = dc_yh; + *span += 2; - if (count <= 0) - return; - - { - int x = dc_x & 3; - unsigned int **span = &dc_ctspan[x]; - - (*span)[0] = dc_yl; - (*span)[1] = dc_yh; - *span += 2; - dest = &dc_temp_rgba[x + 4*dc_yl]; - } - - if (count & 1) { - *dest = color; - dest += 4; - } - if (!(count >>= 1)) - return; - do { - dest[0] = color; dest[4] = color; - dest += 8; - } while (--count); + DrawerCommandQueue::QueueCommand(); } diff --git a/src/r_main.cpp b/src/r_main.cpp index a795f8016..348c70120 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -979,6 +979,8 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas, R_SetupBuffer (); screen->Unlock (); + R_FinishDrawerCommands(); + viewactive = savedviewactive; r_swtruecolor = savedoutputformat; diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 645741a2a..62190b606 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -165,6 +165,7 @@ void FSoftwareRenderer::RenderView(player_t *player) R_RenderActorView (player->mo); // [RH] Let cameras draw onto textures that were visible this frame. FCanvasTextureInfo::UpdateAll (); + R_FinishDrawerCommands(); } //========================================================================== diff --git a/src/r_things.cpp b/src/r_things.cpp index c132cc2fd..b3a2daefe 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -706,10 +706,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop } else { - unsigned int **tspan = &dc_ctspan[x & 3]; - (*tspan)[0] = span->Start; - (*tspan)[1] = span->Stop - 1; - *tspan += 2; + rt_span_coverage(x, span->Start, span->Stop - 1); } } if (!(flags & DVF_SPANSONLY) && (x & 3) == 3) From c452d0257380799e6b2d89e6177380ae2a948235 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 7 Jun 2016 15:25:11 +0200 Subject: [PATCH 0635/1509] Added multicore rendering to true color drawers --- src/r_draw.h | 60 ++++- src/r_draw_rgba.cpp | 535 ++++++++++++++++++++++++++++++------------- src/r_drawt_rgba.cpp | 308 +++++++++++++------------ 3 files changed, 603 insertions(+), 300 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index 98be57c51..bf73c9dfb 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -25,6 +25,9 @@ #include "r_defs.h" #include +#include +#include +#include // Spectre/Invisibility. #define FUZZTABLE 50 @@ -74,7 +77,6 @@ extern "C" unsigned int dc_tspans[4][MAXHEIGHT]; extern "C" unsigned int *dc_ctspan[4]; extern "C" unsigned int horizspans[4]; - // [RH] Pointers to the different column and span drawers... // The span blitting interface. @@ -443,19 +445,58 @@ void R_SetTranslationMap(lighttable_t *translation); // Wait until all drawers finished executing void R_FinishDrawerCommands(); +class DrawerCommandQueue; + class DrawerThread { public: + std::thread thread; + + // Thread line index of this thread int core = 0; + + // Number of active threads int num_cores = 1; uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT * 4]; uint32_t *dc_temp_rgba; + + // Checks if a line is rendered by this thread + bool line_skipped_by_thread(int line) + { + return line % num_cores != core; + } + + // The number of lines to skip to reach the first line to be rendered by this thread + int skipped_by_thread(int first_line) + { + return (num_cores - (first_line - core) % num_cores) % num_cores; + } + + // The number of lines to be rendered by this thread + int count_for_thread(int first_line, int count) + { + return (count - skipped_by_thread(first_line) + num_cores - 1) / num_cores; + } + + // Calculate the dest address for the first line to be rendered by this thread + uint32_t *dest_for_thread(int first_line, int pitch, uint32_t *dest) + { + return dest + skipped_by_thread(first_line) * pitch; + } }; class DrawerCommand { +protected: + int dc_dest_y; + public: + DrawerCommand() + { + dc_dest_y = static_cast((dc_dest - dc_destorg) / (dc_pitch * 4)); + } + virtual void Execute(DrawerThread *thread) = 0; }; @@ -467,8 +508,25 @@ class DrawerCommandQueue std::vector commands; + std::vector threads; + + std::mutex start_mutex; + std::condition_variable start_condition; + std::vector active_commands; + bool shutdown_flag = false; + int run_id = 0; + + std::mutex end_mutex; + std::condition_variable end_condition; + int finished_threads = 0; + + void StartThreads(); + void StopThreads(); + static DrawerCommandQueue *Instance(); + ~DrawerCommandQueue(); + public: // Allocate memory valid for the duration of a command execution static void* AllocMemory(size_t size); diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 9e61bb427..489716e1f 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -63,6 +63,11 @@ DrawerCommandQueue *DrawerCommandQueue::Instance() return &queue; } +DrawerCommandQueue::~DrawerCommandQueue() +{ + StopThreads(); +} + void* DrawerCommandQueue::AllocMemory(size_t size) { // Make sure allocations remain 16-byte aligned @@ -81,19 +86,102 @@ void DrawerCommandQueue::Finish() { auto queue = Instance(); - DrawerThread thread; + // Give worker threads something to do: - size_t size = queue->commands.size(); + std::unique_lock start_lock(queue->start_mutex); + queue->active_commands.swap(queue->commands); + queue->run_id++; + start_lock.unlock(); + + queue->StartThreads(); + queue->start_condition.notify_all(); + + // Do one thread ourselves: + + DrawerThread thread; + thread.core = 0; + thread.num_cores = queue->threads.size() + 1; + + size_t size = queue->active_commands.size(); for (size_t i = 0; i < size; i++) { - auto &command = queue->commands[i]; + auto &command = queue->active_commands[i]; command->Execute(&thread); } - for (auto &command : queue->commands) + // Wait for everyone to finish: + + std::unique_lock end_lock(queue->end_mutex); + queue->end_condition.wait(end_lock, [&]() { return queue->finished_threads == queue->threads.size(); }); + + // Clean up batch: + + for (auto &command : queue->active_commands) command->~DrawerCommand(); - queue->commands.clear(); + queue->active_commands.clear(); queue->memorypool_pos = 0; + queue->finished_threads = 0; +} + +void DrawerCommandQueue::StartThreads() +{ + if (!threads.empty()) + return; + + int num_threads = std::thread::hardware_concurrency(); + if (num_threads == 0) + num_threads = 4; + + threads.resize(num_threads - 1); + + for (int i = 0; i < num_threads - 1; i++) + { + DrawerCommandQueue *queue = this; + DrawerThread *thread = &threads[i]; + thread->core = i + 1; + thread->num_cores = num_threads; + thread->thread = std::thread([=]() + { + int run_id = 0; + while (true) + { + // Wait until we are signalled to run: + std::unique_lock start_lock(queue->start_mutex); + queue->start_condition.wait(start_lock, [&]() { return queue->run_id != run_id || queue->shutdown_flag; }); + if (queue->shutdown_flag) + break; + run_id = queue->run_id; + start_lock.unlock(); + + // Do the work: + size_t size = queue->active_commands.size(); + for (size_t i = 0; i < size; i++) + { + auto &command = queue->active_commands[i]; + command->Execute(thread); + } + + // Notify main thread that we finished: + std::unique_lock end_lock(queue->end_mutex); + queue->finished_threads++; + end_lock.unlock(); + queue->end_condition.notify_all(); + } + }); + } +} + +void DrawerCommandQueue::StopThreads() +{ + std::unique_lock lock(start_mutex); + shutdown_flag = true; + lock.unlock(); + start_condition.notify_all(); + for (auto &thread : threads) + thread.thread.join(); + threads.clear(); + lock.lock(); + shutdown_flag = false; } ///////////////////////////////////////////////////////////////////////////// @@ -129,28 +217,28 @@ public: fixed_t frac; fixed_t fracstep; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); // Zero length, column does not exceed a pixel. if (count <= 0) return; // Framebuffer destination address. - dest = (uint32_t*)dc_dest; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; // Determine scaling, // which is the only mapping to be done. - fracstep = dc_iscale; - frac = dc_texturefrac; + fracstep = dc_iscale * thread->num_cores; + frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); { // [RH] Get local copies of these variables so that the compiler // has a better chance of optimizing this well. const BYTE *source = dc_source; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; // Inner loop that does the actual texture mapping, // e.g. a DDA-lile scaling. @@ -190,17 +278,17 @@ public: int count; uint32_t* dest; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; - dest = (uint32_t*)dc_dest; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); uint32_t light = calc_light_multiplier(dc_light); { - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; BYTE color = dc_color; do @@ -235,12 +323,12 @@ public: int count; uint32_t *dest; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; - dest = (uint32_t*)dc_dest; - int pitch = dc_pitch; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + int pitch = dc_pitch * thread->num_cores; uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; @@ -286,12 +374,12 @@ public: int count; uint32_t *dest; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; - dest = (uint32_t*)dc_dest; - int pitch = dc_pitch; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + int pitch = dc_pitch * thread->num_cores; uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; @@ -337,12 +425,12 @@ public: int count; uint32_t *dest; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; - dest = (uint32_t*)dc_dest; - int pitch = dc_pitch; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + int pitch = dc_pitch * thread->num_cores; uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; @@ -388,12 +476,12 @@ public: int count; uint32_t *dest; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; - dest = (uint32_t*)dc_dest; - int pitch = dc_pitch; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + int pitch = dc_pitch * thread->num_cores; uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; @@ -451,15 +539,13 @@ public: if (dc_yh > fuzzviewheight) dc_yh = fuzzviewheight; - count = dc_yh - dc_yl; + count = thread->count_for_thread(dc_yl, dc_yh - dc_yl + 1); // Zero length. - if (count < 0) + if (count <= 0) return; - count++; - - dest = ylookup[dc_yl] + dc_x + (uint32_t*)dc_destorg; + dest = thread->dest_for_thread(dc_yl, dc_pitch, ylookup[dc_yl] + dc_x + (uint32_t*)dc_destorg); // Note: this implementation assumes this function is only used for the pinky shadow effect (i.e. no other fancy colormap than black) // I'm not sure if this is really always the case or not. @@ -467,7 +553,7 @@ public: { // [RH] Make local copies of global vars to try and improve // the optimizations made by the compiler. - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; int fuzz = fuzzpos; int cnt; @@ -573,18 +659,18 @@ public: fixed_t frac; fixed_t fracstep; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; - dest = (uint32_t*)dc_dest; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - fracstep = dc_iscale; - frac = dc_texturefrac; + fracstep = dc_iscale * thread->num_cores; + frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); { const BYTE *source = dc_source; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -649,23 +735,23 @@ public: fixed_t frac; fixed_t fracstep; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; - dest = (uint32_t*)dc_dest; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - fracstep = dc_iscale; - frac = dc_texturefrac; + fracstep = dc_iscale * thread->num_cores; + frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); { // [RH] Local copies of global vars to improve compiler optimizations BYTE *translation = dc_translation; const BYTE *source = dc_source; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; do { @@ -710,22 +796,22 @@ public: fixed_t frac; fixed_t fracstep; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; - dest = (uint32_t*)dc_dest; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - fracstep = dc_iscale; - frac = dc_texturefrac; + fracstep = dc_iscale * thread->num_cores; + frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); { BYTE *translation = dc_translation; const BYTE *source = dc_source; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -787,15 +873,15 @@ public: uint32_t *dest; fixed_t frac, fracstep; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; - dest = (uint32_t*)dc_dest; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - fracstep = dc_iscale; - frac = dc_texturefrac; + fracstep = dc_iscale * thread->num_cores; + frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 16) & 0xff; @@ -805,7 +891,7 @@ public: { const BYTE *source = dc_source; BYTE *colormap = dc_colormap; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; do { @@ -863,18 +949,18 @@ public: fixed_t frac; fixed_t fracstep; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; - dest = (uint32_t*)dc_dest; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - fracstep = dc_iscale; - frac = dc_texturefrac; + fracstep = dc_iscale * thread->num_cores; + frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); { const BYTE *source = dc_source; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -941,19 +1027,19 @@ public: fixed_t frac; fixed_t fracstep; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; - dest = (uint32_t*)dc_dest; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - fracstep = dc_iscale; - frac = dc_texturefrac; + fracstep = dc_iscale * thread->num_cores; + frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); { BYTE *translation = dc_translation; const BYTE *source = dc_source; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -1018,18 +1104,18 @@ public: fixed_t frac; fixed_t fracstep; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; - dest = (uint32_t*)dc_dest; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - fracstep = dc_iscale; - frac = dc_texturefrac; + fracstep = dc_iscale * thread->num_cores; + frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); { const BYTE *source = dc_source; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -1096,19 +1182,19 @@ public: fixed_t frac; fixed_t fracstep; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; - dest = (uint32_t*)dc_dest; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - fracstep = dc_iscale; - frac = dc_texturefrac; + fracstep = dc_iscale * thread->num_cores; + frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); { BYTE *translation = dc_translation; const BYTE *source = dc_source; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -1173,18 +1259,18 @@ public: fixed_t frac; fixed_t fracstep; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; - dest = (uint32_t*)dc_dest; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - fracstep = dc_iscale; - frac = dc_texturefrac; + fracstep = dc_iscale * thread->num_cores; + frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); { const BYTE *source = dc_source; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); @@ -1250,19 +1336,19 @@ public: fixed_t frac; fixed_t fracstep; - count = dc_count; + count = thread->count_for_thread(dc_dest_y, dc_count); if (count <= 0) return; - dest = (uint32_t*)dc_dest; + dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - fracstep = dc_iscale; - frac = dc_texturefrac; + fracstep = dc_iscale * thread->num_cores; + frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); { BYTE *translation = dc_translation; const BYTE *source = dc_source; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -1329,6 +1415,9 @@ public: #ifdef NO_SSE void Execute(DrawerThread *thread) override { + if (thread->line_skipped_by_thread(ds_y)) + return; + dsfixed_t xfrac; dsfixed_t yfrac; dsfixed_t xstep; @@ -1391,6 +1480,9 @@ public: #else void Execute(DrawerThread *thread) override { + if (thread->line_skipped_by_thread(ds_y)) + return; + dsfixed_t xfrac; dsfixed_t yfrac; dsfixed_t xstep; @@ -1572,6 +1664,9 @@ public: void Execute(DrawerThread *thread) override { + if (thread->line_skipped_by_thread(ds_y)) + return; + dsfixed_t xfrac; dsfixed_t yfrac; dsfixed_t xstep; @@ -1671,6 +1766,9 @@ public: void Execute(DrawerThread *thread) override { + if (thread->line_skipped_by_thread(ds_y)) + return; + dsfixed_t xfrac; dsfixed_t yfrac; dsfixed_t xstep; @@ -1789,6 +1887,9 @@ public: void Execute(DrawerThread *thread) override { + if (thread->line_skipped_by_thread(ds_y)) + return; + dsfixed_t xfrac; dsfixed_t yfrac; dsfixed_t xstep; @@ -1917,6 +2018,9 @@ public: void Execute(DrawerThread *thread) override { + if (thread->line_skipped_by_thread(ds_y)) + return; + dsfixed_t xfrac; dsfixed_t yfrac; dsfixed_t xstep; @@ -2035,6 +2139,9 @@ public: void Execute(DrawerThread *thread) override { + if (thread->line_skipped_by_thread(ds_y)) + return; + dsfixed_t xfrac; dsfixed_t yfrac; dsfixed_t xstep; @@ -2149,6 +2256,9 @@ public: void Execute(DrawerThread *thread) override { + if (thread->line_skipped_by_thread(ds_y)) + return; + uint32_t *dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; int count = (ds_x2 - ds_x1 + 1); uint32_t light = calc_light_multiplier(ds_light); @@ -2186,13 +2296,16 @@ public: void Execute(DrawerThread *thread) override { - DWORD fracstep = dc_iscale; - DWORD frac = dc_texturefrac; - int count = dc_count; + int count = thread->count_for_thread(dc_dest_y, dc_count); + if (count <= 0) + return; + + DWORD fracstep = dc_iscale * thread->num_cores; + DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); const BYTE *source = dc_source; - uint32_t *dest = (uint32_t*)dc_dest; + uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); int bits = vlinebits; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -2238,8 +2351,12 @@ public: #ifdef NO_SSE void Execute(DrawerThread *thread) override { - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; + int count = thread->count_for_thread(dc_dest_y, dc_count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + int pitch = dc_pitch * thread->num_cores; int bits = vlinebits; DWORD place; @@ -2250,21 +2367,34 @@ public: ShadeConstants shade_constants = dc_shade_constants; + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(dc_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } + do { - dest[0] = shade_pal_index(bufplce[0][(place = vplce[0]) >> bits], light0, shade_constants); vplce[0] = place + vince[0]; - dest[1] = shade_pal_index(bufplce[1][(place = vplce[1]) >> bits], light1, shade_constants); vplce[1] = place + vince[1]; - dest[2] = shade_pal_index(bufplce[2][(place = vplce[2]) >> bits], light2, shade_constants); vplce[2] = place + vince[2]; - dest[3] = shade_pal_index(bufplce[3][(place = vplce[3]) >> bits], light3, shade_constants); vplce[3] = place + vince[3]; - dest += dc_pitch; + dest[0] = shade_pal_index(bufplce[0][(place = local_vplce[0]) >> bits], light0, shade_constants); local_vplce[0] = place + local_vince[0]; + dest[1] = shade_pal_index(bufplce[1][(place = local_vplce[1]) >> bits], light1, shade_constants); local_vplce[1] = place + local_vince[1]; + dest[2] = shade_pal_index(bufplce[2][(place = local_vplce[2]) >> bits], light2, shade_constants); local_vplce[2] = place + local_vince[2]; + dest[3] = shade_pal_index(bufplce[3][(place = local_vplce[3]) >> bits], light3, shade_constants); local_vplce[3] = place + local_vince[3]; + dest += pitch; } while (--count); } #else void Execute(DrawerThread *thread) override { - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; + int count = thread->count_for_thread(dc_dest_y, dc_count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); int bits = vlinebits; + int pitch = dc_pitch * thread->num_cores; uint32_t light0 = calc_light_multiplier(palookuplight[0]); uint32_t light1 = calc_light_multiplier(palookuplight[1]); @@ -2276,6 +2406,12 @@ public: uint32_t *palette = (uint32_t*)GPalette.BaseColors; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(dc_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } if (shade_constants.simple_shade) { @@ -2300,7 +2436,7 @@ public: __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); SSE_SHADE_SIMPLE(fg); _mm_storeu_si128((__m128i*)dest, fg); - dest += dc_pitch; + dest += pitch; } while (--count); } else @@ -2326,7 +2462,7 @@ public: __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); SSE_SHADE(fg, shade_constants); _mm_storeu_si128((__m128i*)dest, fg); - dest += dc_pitch; + dest += pitch; } while (--count); } } @@ -2361,13 +2497,16 @@ public: void Execute(DrawerThread *thread) override { - DWORD fracstep = dc_iscale; - DWORD frac = dc_texturefrac; - int count = dc_count; + int count = thread->count_for_thread(dc_dest_y, dc_count); + if (count <= 0) + return; + + DWORD fracstep = dc_iscale * thread->num_cores; + DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); const BYTE *source = dc_source; - uint32_t *dest = (uint32_t*)dc_dest; + uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); int bits = mvlinebits; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -2417,8 +2556,12 @@ public: #ifdef NO_SSE void Execute(DrawerThread *thread) override { - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; + int count = thread->count_for_thread(dc_dest_y, dc_count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + int pitch = dc_pitch * thread->num_cores; int bits = mvlinebits; DWORD place; @@ -2429,21 +2572,34 @@ public: ShadeConstants shade_constants = dc_shade_constants; + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(dc_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } + do { BYTE pix; - pix = bufplce[0][(place = vplce[0]) >> bits]; if (pix) dest[0] = shade_pal_index(pix, light0, shade_constants); vplce[0] = place + vince[0]; - pix = bufplce[1][(place = vplce[1]) >> bits]; if (pix) dest[1] = shade_pal_index(pix, light1, shade_constants); vplce[1] = place + vince[1]; - pix = bufplce[2][(place = vplce[2]) >> bits]; if (pix) dest[2] = shade_pal_index(pix, light2, shade_constants); vplce[2] = place + vince[2]; - pix = bufplce[3][(place = vplce[3]) >> bits]; if (pix) dest[3] = shade_pal_index(pix, light3, shade_constants); vplce[3] = place + vince[3]; - dest += dc_pitch; + pix = bufplce[0][(place = local_vplce[0]) >> bits]; if (pix) dest[0] = shade_pal_index(pix, light0, shade_constants); local_vplce[0] = place + local_vince[0]; + pix = bufplce[1][(place = local_vplce[1]) >> bits]; if (pix) dest[1] = shade_pal_index(pix, light1, shade_constants); local_vplce[1] = place + local_vince[1]; + pix = bufplce[2][(place = local_vplce[2]) >> bits]; if (pix) dest[2] = shade_pal_index(pix, light2, shade_constants); local_vplce[2] = place + local_vince[2]; + pix = bufplce[3][(place = local_vplce[3]) >> bits]; if (pix) dest[3] = shade_pal_index(pix, light3, shade_constants); local_vplce[3] = place + local_vince[3]; + dest += pitch; } while (--count); } #else void Execute(DrawerThread *thread) override { - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; + int count = thread->count_for_thread(dc_dest_y, dc_count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + int pitch = dc_pitch * thread->num_cores; int bits = mvlinebits; uint32_t light0 = calc_light_multiplier(palookuplight[0]); @@ -2456,6 +2612,12 @@ public: uint32_t *palette = (uint32_t*)GPalette.BaseColors; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(dc_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } if (shade_constants.simple_shade) { @@ -2483,7 +2645,7 @@ public: __m128i fg = _mm_set_epi32(palette[pix3], palette[pix2], palette[pix1], palette[pix0]); SSE_SHADE_SIMPLE(fg); _mm_maskmoveu_si128(fg, movemask, (char*)dest); - dest += dc_pitch; + dest += pitch; } while (--count); } else @@ -2512,7 +2674,7 @@ public: __m128i fg = _mm_set_epi32(palette[pix3], palette[pix2], palette[pix1], palette[pix0]); SSE_SHADE(fg, shade_constants); _mm_maskmoveu_si128(fg, movemask, (char*)dest); - dest += dc_pitch; + dest += pitch; } while (--count); } } @@ -2551,13 +2713,16 @@ public: void Execute(DrawerThread *thread) override { - DWORD fracstep = dc_iscale; - DWORD frac = dc_texturefrac; - int count = dc_count; + int count = thread->count_for_thread(dc_dest_y, dc_count); + if (count <= 0) + return; + + DWORD fracstep = dc_iscale * thread->num_cores; + DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); const BYTE *source = dc_source; - uint32_t *dest = (uint32_t*)dc_dest; + uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); int bits = tmvlinebits; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -2626,8 +2791,12 @@ public: void Execute(DrawerThread *thread) override { - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; + int count = thread->count_for_thread(dc_dest_y, dc_count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + int pitch = dc_pitch * thread->num_cores; int bits = tmvlinebits; uint32_t light[4]; @@ -2641,11 +2810,20 @@ public: uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(dc_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } + do { for (int i = 0; i < 4; ++i) { - BYTE pix = bufplce[i][vplce[i] >> bits]; + BYTE pix = bufplce[i][local_vplce[i] >> bits]; if (pix != 0) { uint32_t fg = shade_pal_index(pix, light[i], shade_constants); @@ -2663,9 +2841,9 @@ public: dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } - vplce[i] += vince[i]; + local_vplce[i] += local_vince[i]; } - dest += dc_pitch; + dest += pitch; } while (--count); } }; @@ -2702,13 +2880,16 @@ public: void Execute(DrawerThread *thread) override { - DWORD fracstep = dc_iscale; - DWORD frac = dc_texturefrac; - int count = dc_count; + int count = thread->count_for_thread(dc_dest_y, dc_count); + if (count <= 0) + return; + + DWORD fracstep = dc_iscale * thread->num_cores; + DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); const BYTE *source = dc_source; - uint32_t *dest = (uint32_t*)dc_dest; + uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); int bits = tmvlinebits; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -2777,8 +2958,12 @@ public: void Execute(DrawerThread *thread) override { - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; + int count = thread->count_for_thread(dc_dest_y, dc_count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + int pitch = dc_pitch * thread->num_cores; int bits = tmvlinebits; uint32_t light[4]; @@ -2792,11 +2977,20 @@ public: uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(dc_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } + do { for (int i = 0; i < 4; ++i) { - BYTE pix = bufplce[i][vplce[i] >> bits]; + BYTE pix = bufplce[i][local_vplce[i] >> bits]; if (pix != 0) { uint32_t fg = shade_pal_index(pix, light[i], shade_constants); @@ -2814,9 +3008,9 @@ public: dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } - vplce[i] += vince[i]; + local_vplce[i] += local_vince[i]; } - dest += dc_pitch; + dest += pitch; } while (--count); } }; @@ -2853,13 +3047,16 @@ public: void Execute(DrawerThread *thread) override { - DWORD fracstep = dc_iscale; - DWORD frac = dc_texturefrac; - int count = dc_count; + int count = thread->count_for_thread(dc_dest_y, dc_count); + if (count <= 0) + return; + + DWORD fracstep = dc_iscale * thread->num_cores; + DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); const BYTE *source = dc_source; - uint32_t *dest = (uint32_t*)dc_dest; + uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); int bits = tmvlinebits; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -2928,8 +3125,12 @@ public: void Execute(DrawerThread *thread) override { - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; + int count = thread->count_for_thread(dc_dest_y, dc_count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + int pitch = dc_pitch * thread->num_cores; int bits = tmvlinebits; uint32_t light[4]; @@ -2943,11 +3144,20 @@ public: uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(dc_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } + do { for (int i = 0; i < 4; ++i) { - BYTE pix = bufplce[i][vplce[i] >> bits]; + BYTE pix = bufplce[i][local_vplce[i] >> bits]; if (pix != 0) { uint32_t fg = shade_pal_index(pix, light[i], shade_constants); @@ -2965,9 +3175,9 @@ public: dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } - vplce[i] += vince[i]; + local_vplce[i] += local_vince[i]; } - dest += dc_pitch; + dest += pitch; } while (--count); } }; @@ -3004,13 +3214,16 @@ public: void Execute(DrawerThread *thread) override { - DWORD fracstep = dc_iscale; - DWORD frac = dc_texturefrac; - int count = dc_count; + int count = thread->count_for_thread(dc_dest_y, dc_count); + if (count <= 0) + return; + + DWORD fracstep = dc_iscale * thread->num_cores; + DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); const BYTE *source = dc_source; - uint32_t *dest = (uint32_t*)dc_dest; + uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); int bits = tmvlinebits; - int pitch = dc_pitch; + int pitch = dc_pitch * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -3079,8 +3292,12 @@ public: void Execute(DrawerThread *thread) override { - uint32_t *dest = (uint32_t*)dc_dest; - int count = dc_count; + int count = thread->count_for_thread(dc_dest_y, dc_count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + int pitch = dc_pitch * thread->num_cores; int bits = tmvlinebits; uint32_t light[4]; @@ -3094,11 +3311,20 @@ public: uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(dc_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } + do { for (int i = 0; i < 4; ++i) { - BYTE pix = bufplce[i][vplce[i] >> bits]; + BYTE pix = bufplce[i][local_vplce[i] >> bits]; if (pix != 0) { uint32_t fg = shade_pal_index(pix, light[i], shade_constants); @@ -3116,9 +3342,9 @@ public: dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } - vplce[i] += vince[i]; + local_vplce[i] += local_vince[i]; } - dest += dc_pitch; + dest += pitch; } while (--count); } }; @@ -3146,6 +3372,9 @@ public: void Execute(DrawerThread *thread) override { + if (thread->line_skipped_by_thread(_y)) + return; + int y = _y; int x = _x; int x2 = _x2; diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index bbf68a795..c2caec0c2 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -78,26 +78,26 @@ public: uint32_t *source; uint32_t *dest; int count; - int pitch; + int pitch, sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, (yh - yl + 1)); + if (count <= 0) return; - count++; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4 + hx]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = thread->num_cores * 4; if (count & 1) { *dest = *source; - source += 4; + source += sincr; dest += pitch; } if (count & 2) { dest[0] = source[0]; - dest[pitch] = source[4]; - source += 8; + dest[pitch] = source[sincr]; + source += sincr * 2; dest += pitch * 2; } if (!(count >>= 2)) @@ -105,10 +105,10 @@ public: do { dest[0] = source[0]; - dest[pitch] = source[4]; - dest[pitch * 2] = source[8]; - dest[pitch * 3] = source[12]; - source += 16; + dest[pitch] = source[sincr]; + dest[pitch * 2] = source[sincr * 2]; + dest[pitch * 3] = source[sincr * 3]; + source += sincr * 4; dest += pitch * 4; } while (--count); } @@ -145,22 +145,23 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4 + hx]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = thread->num_cores * 4; if (count & 1) { *dest = shade_pal_index(*source, light, shade_constants); - source += 4; + source += sincr; dest += pitch; } if (!(count >>= 1)) @@ -168,8 +169,8 @@ public: do { dest[0] = shade_pal_index(source[0], light, shade_constants); - dest[pitch] = shade_pal_index(source[4], light, shade_constants); - source += 8; + dest[pitch] = shade_pal_index(source[sincr], light, shade_constants); + source += sincr * 2; dest += pitch * 2; } while (--count); } @@ -205,25 +206,26 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = thread->num_cores * 4; if (count & 1) { dest[0] = shade_pal_index(source[0], light, shade_constants); dest[1] = shade_pal_index(source[1], light, shade_constants); dest[2] = shade_pal_index(source[2], light, shade_constants); dest[3] = shade_pal_index(source[3], light, shade_constants); - source += 4; + source += sincr; dest += pitch; } if (!(count >>= 1)) @@ -234,11 +236,11 @@ public: dest[1] = shade_pal_index(source[1], light, shade_constants); dest[2] = shade_pal_index(source[2], light, shade_constants); dest[3] = shade_pal_index(source[3], light, shade_constants); - dest[pitch] = shade_pal_index(source[4], light, shade_constants); - dest[pitch + 1] = shade_pal_index(source[5], light, shade_constants); - dest[pitch + 2] = shade_pal_index(source[6], light, shade_constants); - dest[pitch + 3] = shade_pal_index(source[7], light, shade_constants); - source += 8; + dest[pitch] = shade_pal_index(source[sincr], light, shade_constants); + dest[pitch + 1] = shade_pal_index(source[sincr + 1], light, shade_constants); + dest[pitch + 2] = shade_pal_index(source[sincr + 2], light, shade_constants); + dest[pitch + 3] = shade_pal_index(source[sincr + 3], light, shade_constants); + source += sincr * 2; dest += pitch * 2; } while (--count); } @@ -249,19 +251,20 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; ShadeConstants shade_constants = dc_shade_constants; uint32_t light = calc_light_multiplier(dc_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = thread->num_cores * 4; if (shade_constants.simple_shade) { @@ -278,7 +281,7 @@ public: SSE_SHADE_SIMPLE(fg); _mm_storeu_si128((__m128i*)dest, fg); - source += 4; + source += sincr; dest += pitch; } if (!(count >>= 1)) @@ -299,17 +302,17 @@ public: // shade_pal_index 4-7 (pitch) { - uint32_t p0 = source[4]; - uint32_t p1 = source[5]; - uint32_t p2 = source[6]; - uint32_t p3 = source[7]; + uint32_t p0 = source[sincr]; + uint32_t p1 = source[sincr + 1]; + uint32_t p2 = source[sincr + 2]; + uint32_t p3 = source[sincr + 3]; __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); SSE_SHADE_SIMPLE(fg); _mm_storeu_si128((__m128i*)(dest + pitch), fg); } - source += 8; + source += sincr * 2; dest += pitch * 2; } while (--count); } @@ -328,7 +331,7 @@ public: SSE_SHADE(fg, shade_constants); _mm_storeu_si128((__m128i*)dest, fg); - source += 4; + source += sincr; dest += pitch; } if (!(count >>= 1)) @@ -349,17 +352,17 @@ public: // shade_pal_index 4-7 (pitch) { - uint32_t p0 = source[4]; - uint32_t p1 = source[5]; - uint32_t p2 = source[6]; - uint32_t p3 = source[7]; + uint32_t p0 = source[sincr]; + uint32_t p1 = source[sincr + 1]; + uint32_t p2 = source[sincr + 2]; + uint32_t p3 = source[sincr + 3]; __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); SSE_SHADE(fg, shade_constants); _mm_storeu_si128((__m128i*)(dest + pitch), fg); } - source += 8; + source += sincr * 2; dest += pitch * 2; } while (--count); } @@ -522,15 +525,16 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4 + hx]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = 4 * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -554,7 +558,7 @@ public: *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += 4; + source += sincr; dest += pitch; } while (--count); } @@ -590,15 +594,16 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = 4 * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -625,7 +630,7 @@ public: dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } - source += 4; + source += sincr; dest += pitch; } while (--count); } @@ -636,15 +641,16 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = 4 * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; @@ -686,7 +692,7 @@ public: __m128i color = _mm_packus_epi16(color_lo, color_hi); _mm_storeu_si128((__m128i*)dest, color); - source += 4; + source += sincr; dest += pitch; } while (--count); } @@ -722,7 +728,7 @@ public: __m128i color = _mm_packus_epi16(color_lo, color_hi); _mm_storeu_si128((__m128i*)dest, color); - source += 4; + source += sincr; dest += pitch; } while (--count); } @@ -764,16 +770,17 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; colormap = dc_colormap; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4 + hx]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = 4 * thread->num_cores; uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 16) & 0xff; @@ -793,7 +800,7 @@ public: uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += 4; + source += sincr; dest += pitch; } while (--count); } @@ -832,16 +839,17 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; colormap = dc_colormap; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = 4 * thread->num_cores; uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 16) & 0xff; @@ -864,7 +872,7 @@ public: dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } - source += 4; + source += sincr; dest += pitch; } while (--count); } @@ -876,16 +884,17 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; colormap = dc_colormap; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = 4 * thread->num_cores; __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light))), _mm_setzero_si128()); __m128i alpha_one = _mm_set1_epi16(64); @@ -913,7 +922,7 @@ public: __m128i color = _mm_packus_epi16(color_lo, color_hi); _mm_storeu_si128((__m128i*)dest, color); - source += 4; + source += sincr; dest += pitch; } while (--count); } @@ -955,15 +964,16 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4 + hx]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = 4 * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -986,7 +996,7 @@ public: uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += 4; + source += sincr; dest += pitch; } while (--count); } @@ -1026,15 +1036,16 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = 4 * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -1060,7 +1071,7 @@ public: dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } - source += 4; + source += sincr; dest += pitch; } while (--count); } @@ -1071,15 +1082,16 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = 4 * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; @@ -1121,7 +1133,7 @@ public: __m128i color = _mm_packus_epi16(color_lo, color_hi); _mm_storeu_si128((__m128i*)dest, color); - source += 4; + source += sincr; dest += pitch; } while (--count); } @@ -1157,7 +1169,7 @@ public: __m128i color = _mm_packus_epi16(color_lo, color_hi); _mm_storeu_si128((__m128i*)dest, color); - source += 4; + source += sincr; dest += pitch; } while (--count); } @@ -1200,15 +1212,16 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4 + hx]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = 4 * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -1231,7 +1244,7 @@ public: uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += 4; + source += sincr; dest += pitch; } while (--count); } @@ -1270,15 +1283,16 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = 4 * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -1305,7 +1319,7 @@ public: dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } - source += 4; + source += sincr; dest += pitch; } while (--count); } @@ -1346,15 +1360,16 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4 + hx]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = 4 * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -1377,7 +1392,7 @@ public: uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += 4; + source += sincr; dest += pitch; } while (--count); } @@ -1416,15 +1431,16 @@ public: uint32_t *dest; int count; int pitch; + int sincr; - count = yh - yl; - if (count < 0) + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) return; - count++; - dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; - source = &thread->dc_temp_rgba[yl * 4]; - pitch = dc_pitch; + dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = dc_pitch * thread->num_cores; + sincr = 4 * thread->num_cores; uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; @@ -1451,7 +1467,7 @@ public: dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; } - source += 4; + source += sincr; dest += pitch; } while (--count); } From c59db95cc87543e648f64a19d37f78f2a6656d4d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 9 Jun 2016 23:12:38 +0200 Subject: [PATCH 0636/1509] Rewrote wallscan to fix buffer overruns and code duplication. --- src/r_segs.cpp | 910 +++++++++++++++---------------------------------- 1 file changed, 283 insertions(+), 627 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index bd2c7d22b..5aa7c29a2 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1065,53 +1065,149 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2) return; } -// prevlineasm1 is like vlineasm1 but skips the loop if only drawing one pixel -inline fixed_t prevline1 (fixed_t vince, BYTE *colormap, fixed_t light, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest) +// Draw a column with support for non-power-of-two ranges +uint32_t wallscan_drawcol1(int x, int y1, int y2, uint32_t uv_start, uint32_t uv_step, uint32_t uv_max, const BYTE *source, DWORD(*draw1column)()) { - dc_iscale = vince; - dc_colormap = colormap; - dc_light = light; - dc_count = count; - dc_texturefrac = vplce; - dc_source = bufplce; - dc_dest = dest; - return doprevline1 (); + int pixelsize = r_swtruecolor ? 4 : 1; + if (uv_max == 0) // power of two + { + int count = y2 - y1; + if (count > 0) + { + dc_source = source; + dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; + dc_count = y2 - y1; + dc_iscale = uv_step; + dc_texturefrac = uv_start; + draw1column(); + } + return uv_start + uv_step * (uint32_t)count; + } + else + { + uint32_t uv_pos = uv_start; + + int left = y2 - y1; + while (left > 0) + { + int next_uv_wrap = (uv_max - uv_pos + uv_step - 1) / uv_step; + int count = MIN(left, next_uv_wrap); + + if (count > 0) + { + dc_source = source; + dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; + dc_count = count; + dc_iscale = uv_step; + dc_texturefrac = uv_pos; + draw1column(); + } + + left -= count; + uv_pos += uv_step * count; + if (uv_pos >= uv_max) + uv_pos -= uv_max; + } + + return uv_pos; + } } -void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, - double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) +// Draw four columns with support for non-power-of-two ranges +void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_step, uint32_t uv_max, const BYTE **source, void(*draw4columns)()) { - int x, fracbits; - int y1ve[4], y2ve[4], u4, d4, z; - char bad; - float light = rw_light - rw_lightstep; - SDWORD xoffset; - BYTE *basecolormapdata; - double iscale; - - // This function also gets used to draw skies. Unlike BUILD, skies are - // drawn by visplane instead of by bunch, so these checks are invalid. - //if ((uwal[x1] > viewheight) && (uwal[x2] > viewheight)) return; - //if ((dwal[x1] < 0) && (dwal[x2] < 0)) return; - - if (rw_pic->UseType == FTexture::TEX_Null) - { - return; - } - -//extern cycle_t WallScanCycles; -//clock (WallScanCycles); - int pixelsize = r_swtruecolor ? 4 : 1; + if (uv_max == 0) // power of two, no wrap handling needed + { + for (int i = 0; i < 4; i++) + { + bufplce[i] = source[i]; + vplce[i] = uv_pos[i]; + vince[i] = uv_step[i]; + uv_pos[i] += uv_step[i] * (y2 - y1); + } + dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; + dc_count = y2 - y1; + draw4columns(); + } + else + { + dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; + for (int i = 0; i < 4; i++) + bufplce[i] = source[i]; - rw_pic->GetHeight(); // Make sure texture size is loaded - fracbits = 32 - rw_pic->HeightBits; - setupvline(fracbits); - xoffset = rw_offset; - basecolormapdata = basecolormap->Maps; + int left = y2 - y1; + while (left > 0) + { + // Find which column wraps first + int count = left; + for (int i = 0; i < 4; i++) + { + int next_uv_wrap = (uv_max - uv_pos[i] + uv_step[i] - 1) / uv_step[i]; + count = MIN(next_uv_wrap, count); + } - x = x1; - //while ((umost[x] > dmost[x]) && (x < x2)) x++; + // Draw until that column wraps + if (count > 0) + { + for (int i = 0; i < 4; i++) + { + vplce[i] = uv_pos[i]; + vince[i] = uv_step[i]; + } + dc_count = count; + draw4columns(); + } + + // Wrap the uv position + for (int i = 0; i < 4; i++) + { + uv_pos[i] += uv_step[i] * count; + if (uv_pos[i] >= uv_max) + uv_pos[i] -= uv_max; + } + + left -= count; + } + } +} + +// Calculates a wrapped uv start position value for a column +void calc_uv_start_and_step(int y1, float swal, double yrepeat, uint32_t uv_height, int fracbits, uint32_t &uv_start_out, uint32_t &uv_step_out) +{ + double uv_stepd = swal * yrepeat; + + // Find start uv in [0-uv_height[ range. + // Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range. + double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / uv_height; + v = v - std::floor(v); + v *= uv_height; + v *= (1 << fracbits); + + uv_start_out = (uint32_t)v; + uv_step_out = xs_ToFixed(fracbits, uv_stepd); +} + +typedef DWORD(*Draw1ColumnFuncPtr)(); +typedef void(*Draw4ColumnsFuncPtr)(); + +void wallscan_any( + int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, + const BYTE *(*getcol)(FTexture *tex, int x), + void(setupwallscan(int bits,Draw1ColumnFuncPtr &draw1, Draw4ColumnsFuncPtr &draw2))) +{ + if (rw_pic->UseType == FTexture::TEX_Null) + return; + + uint32_t uv_height = rw_pic->GetHeight(); + uint32_t fracbits = 32 - rw_pic->HeightBits; + uint32_t uv_max = uv_height << fracbits; + + DWORD(*draw1column)(); + void(*draw4columns)(); + setupwallscan(fracbits, draw1column, draw4columns); + + fixed_t xoffset = rw_offset; bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); if (fixed) @@ -1131,139 +1227,190 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l else R_SetColorMapLight(basecolormap, 0, 0); - for(; (x < x2) && (x & 3); ++x) + float light = rw_light; + + // Calculate where 4 column alignment begins and ends: + int aligned_x1 = clamp((x1 + 3) / 4 * 4, x1, x2); + int aligned_x2 = clamp(x2 / 4 * 4, x1, x2); + + // First unaligned columns: + for (int x = x1; x < aligned_x1; x++, light += rw_lightstep) { - light += rw_lightstep; - y1ve[0] = uwal[x];//max(uwal[x],umost[x]); - y2ve[0] = dwal[x];//min(dwal[x],dmost[x]); - if (y2ve[0] <= y1ve[0]) continue; - assert (y1ve[0] < viewheight); - assert (y2ve[0] <= viewheight); + int y1 = uwal[x]; + int y2 = dwal[x]; + if (y2 <= y1) + continue; if (!fixed) - { // calculate lighting R_SetColorMapLight(basecolormap, light, wallshade); - } - dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); - dc_dest = (ylookup[y1ve[0]] + x)*pixelsize + dc_destorg; - dc_count = y2ve[0] - y1ve[0]; - iscale = swal[x] * yrepeat; - dc_iscale = xs_ToFixed(fracbits, iscale); - dc_texturefrac = xs_ToFixed(fracbits, dc_texturemid + iscale * (y1ve[0] - CenterY + 0.5)); + const BYTE *source = getcol(rw_pic, (lwal[x] + xoffset) >> FRACBITS); - dovline1(); + uint32_t uv_start, uv_step; + calc_uv_start_and_step(y1, swal[x], yrepeat, uv_height, fracbits, uv_start, uv_step); + + wallscan_drawcol1(x, y1, y2, uv_start, uv_step, uv_max, source, draw1column); } - for(; x < x2-3; x += 4) + // The aligned columns + for (int x = aligned_x1; x < aligned_x2; x += 4) { - bad = 0; - for (z = 3; z>= 0; --z) - { - y1ve[z] = uwal[x+z];//max(uwal[x+z],umost[x+z]); - y2ve[z] = dwal[x+z];//min(dwal[x+z],dmost[x+z])-1; - if (y2ve[z] <= y1ve[z]) { bad += 1<> FRACBITS); - iscale = swal[x + z] * yrepeat; - vince[z] = xs_ToFixed(fracbits, iscale); - vplce[z] = xs_ToFixed(fracbits, dc_texturemid + iscale * (y1ve[z] - CenterY + 0.5)); - } - if (bad == 15) + const BYTE *source[4]; + for (int i = 0; i < 4; i++) + source[i] = getcol(rw_pic, (lwal[x + i] + xoffset) >> FRACBITS); + + float lights[4]; + for (int i = 0; i < 4; i++) { - light += rw_lightstep * 4; + lights[i] = light; + light += rw_lightstep; + } + + uint32_t uv_pos[4], uv_step[4]; + for (int i = 0; i < 4; i++) + calc_uv_start_and_step(y1[i], swal[x + i], yrepeat, uv_height, fracbits, uv_pos[i], uv_step[i]); + + // Figure out where we vertically can start and stop drawing 4 columns in one go + int middle_y1 = y1[0]; + int middle_y2 = y2[0]; + for (int i = 1; i < 4; i++) + { + middle_y1 = MAX(y1[i], middle_y1); + middle_y2 = MIN(y2[i], middle_y2); + } + + // If we got an empty column in our set we cannot draw 4 columns in one go: + bool empty_column_in_set = false; + for (int i = 0; i < 4; i++) + { + if (y2[i] <= y1[i]) + empty_column_in_set = true; + } + + if (empty_column_in_set || middle_y2 <= middle_y1) + { + for (int i = 0; i < 4; i++) + { + if (!fixed) + R_SetColorMapLight(basecolormap, lights[i], wallshade); + wallscan_drawcol1(x + i, y1[i], y2[i], uv_pos[i], uv_step[i], uv_max, source[i], draw1column); + } continue; } + // Draw the first rows where not all 4 columns are active + for (int i = 0; i < 4; i++) + { + if (!fixed) + R_SetColorMapLight(basecolormap, lights[i], wallshade); + + if (y1[i] < middle_y1) + uv_pos[i] = wallscan_drawcol1(x + i, y1[i], middle_y1, uv_pos[i], uv_step[i], uv_max, source[i], draw1column); + } + + // Draw the area where all 4 columns are active if (!fixed) { - for (z = 0; z < 4; ++z) + for (int i = 0; i < 4; i++) { - light += rw_lightstep; if (r_swtruecolor) { - palookupoffse[z] = basecolormapdata; - palookuplight[z] = LIGHTSCALE(light, wallshade); + palookupoffse[i] = basecolormap->Maps; + palookuplight[i] = LIGHTSCALE(lights[i], wallshade); } else { - palookupoffse[z] = basecolormapdata + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); - palookuplight[z] = 0; + palookupoffse[i] = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); + palookuplight[i] = 0; } } } + wallscan_drawcol4(x, middle_y1, middle_y2, uv_pos, uv_step, uv_max, source, draw4columns); - u4 = MAX(MAX(y1ve[0],y1ve[1]),MAX(y1ve[2],y1ve[3])); - d4 = MIN(MIN(y2ve[0],y2ve[1]),MIN(y2ve[2],y2ve[3])); - - if ((bad != 0) || (u4 >= d4)) + // Draw the last rows where not all 4 columns are active + for (int i = 0; i < 4; i++) { - for (z = 0; z < 4; ++z) - { - if (!(bad & 1)) - { - prevline1(vince[z],palookupoffse[z],palookuplight[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+x+z)*pixelsize+dc_destorg); - } - bad >>= 1; - } - continue; - } + if (!fixed) + R_SetColorMapLight(basecolormap, lights[i], wallshade); - for (z = 0; z < 4; ++z) - { - if (u4 > y1ve[z]) - { - vplce[z] = prevline1(vince[z],palookupoffse[z], palookuplight[z],u4-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+x+z)*pixelsize+dc_destorg); - } - } - - if (d4 > u4) - { - dc_count = d4-u4; - dc_dest = (ylookup[u4]+x)*pixelsize+dc_destorg; - dovline4(); - } - - BYTE *i = (x+ylookup[d4])*pixelsize+dc_destorg; - for (z = 0; z < 4; ++z) - { - if (y2ve[z] > d4) - { - prevline1(vince[z],palookupoffse[0],palookuplight[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z*pixelsize); - } + if (middle_y2 < y2[i]) + uv_pos[i] = wallscan_drawcol1(x + i, middle_y2, y2[i], uv_pos[i], uv_step[i], uv_max, source[i], draw1column); } } - for(;x> FRACBITS); - dc_dest = (ylookup[y1ve[0]] + x) * pixelsize + dc_destorg; - dc_count = y2ve[0] - y1ve[0]; - iscale = swal[x] * yrepeat; - dc_iscale = xs_ToFixed(fracbits, iscale); - dc_texturefrac = xs_ToFixed(fracbits, dc_texturemid + iscale * (y1ve[0] - CenterY + 0.5)); + const BYTE *source = getcol(rw_pic, (lwal[x] + xoffset) >> FRACBITS); - dovline1(); + uint32_t uv_start, uv_step; + calc_uv_start_and_step(y1, swal[x], yrepeat, uv_height, fracbits, uv_start, uv_step); + + wallscan_drawcol1(x, y1, y2, uv_start, uv_step, uv_max, source, draw1column); } -//unclock (WallScanCycles); - NetUpdate (); } +void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) +{ + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + { + setupvline(bits); + line1 = dovline1; + line4 = dovline4; + }); +} + +void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) +{ + if (!rw_pic->bMasked) // Textures that aren't masked can use the faster wallscan. + { + wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); + } + else + { + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + { + setupmvline(bits); + line1 = domvline1; + line4 = domvline4; + }); + } +} + +void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) +{ + static fixed_t(*tmvline1)(); + static void(*tmvline4)(); + if (!R_GetTransMaskDrawers(&tmvline1, &tmvline4)) + { + // The current translucency is unsupported, so draw with regular maskwallscan instead. + maskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); + } + else + { + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + { + setuptmvline(bits); + line1 = reinterpret_cast(tmvline1); + line4 = tmvline4; + }); + } +} + void wallscan_striped (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) { FDynamicColormap *startcolormap = basecolormap; @@ -1331,507 +1478,16 @@ static void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, } } -//============================================================================= -// -// wallscan_np2 -// -// This is a wrapper around wallscan that helps it tile textures whose heights -// are not powers of 2. It divides the wall into texture-sized strips and calls -// wallscan for each of those. Since only one repetition of the texture fits -// in each strip, wallscan will not tile. -// -//============================================================================= - +// wallscan now tiles with non-power-of-two textures - this function is therefore not needed anymore.. void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, bool mask) { - if (!r_np2) - { - call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, mask); - } - else - { - short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; - short *up, *down; - double texheight = rw_pic->GetHeight(); - double partition; - double scaledtexheight = texheight / yrepeat; - - if (yrepeat >= 0) - { // normal orientation: draw strips from top to bottom - partition = top - fmod(top - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); - if (partition == top) - { - partition -= scaledtexheight; - } - up = uwal; - down = most1; - dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; - while (partition > bot) - { - int j = OWallMost(most3, partition - ViewPos.Z, &WallC); - if (j != 3) - { - for (int j = x1; j < x2; ++j) - { - down[j] = clamp(most3[j], up[j], dwal[j]); - } - call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); - up = down; - down = (down == most1) ? most2 : most1; - } - partition -= scaledtexheight; - dc_texturemid -= texheight; - } - call_wallscan(x1, x2, up, dwal, swal, lwal, yrepeat, mask); - } - else - { // upside down: draw strips from bottom to top - partition = bot - fmod(bot - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); - up = most1; - down = dwal; - dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; - while (partition < top) - { - int j = OWallMost(most3, partition - ViewPos.Z, &WallC); - if (j != 12) - { - for (int j = x1; j < x2; ++j) - { - up[j] = clamp(most3[j], uwal[j], down[j]); - } - call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); - down = up; - up = (up == most1) ? most2 : most1; - } - partition -= scaledtexheight; - dc_texturemid -= texheight; - } - call_wallscan(x1, x2, uwal, down, swal, lwal, yrepeat, mask); - } - } + call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, mask); } +// wallscan now tiles with non-power-of-two textures - this function is therefore not needed anymore.. static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) { - if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) - { - double frontcz1 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v1); - double frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1); - double frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2); - double frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2); - double top = MAX(frontcz1, frontcz2); - double bot = MIN(frontfz1, frontfz2); - if (fake3D & FAKE3D_CLIPTOP) - { - top = MIN(top, sclipTop); - } - if (fake3D & FAKE3D_CLIPBOTTOM) - { - bot = MAX(bot, sclipBottom); - } - wallscan_np2(x1, x2, uwal, dwal, swal, lwal, yrepeat, top, bot, true); - } - else - { - call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, true); - } -} - -inline fixed_t mvline1 (fixed_t vince, BYTE *colormap, fixed_t light, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest) -{ - dc_iscale = vince; - dc_colormap = colormap; - dc_light = light; - dc_count = count; - dc_texturefrac = vplce; - dc_source = bufplce; - dc_dest = dest; - return domvline1 (); -} - -void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, - double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) -{ - int x, fracbits; - BYTE *pixel; - int pixelsize, pixelshift; - int y1ve[4], y2ve[4], u4, d4, startx, dax, z; - char bad; - float light = rw_light - rw_lightstep; - SDWORD xoffset; - BYTE *basecolormapdata; - double iscale; - - if (rw_pic->UseType == FTexture::TEX_Null) - { - return; - } - - if (!rw_pic->bMasked) - { // Textures that aren't masked can use the faster wallscan. - wallscan (x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); - return; - } - -//extern cycle_t WallScanCycles; -//clock (WallScanCycles); - - pixelsize = r_swtruecolor ? 4 : 1; - pixelshift = r_swtruecolor ? 2 : 0; - - rw_pic->GetHeight(); // Make sure texture size is loaded - fracbits = 32- rw_pic->HeightBits; - setupmvline(fracbits); - xoffset = rw_offset; - basecolormapdata = basecolormap->Maps; - - x = startx = x1; - pixel = x * pixelsize + dc_destorg; - - bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); - if (fixed) - { - palookupoffse[0] = dc_colormap; - palookupoffse[1] = dc_colormap; - palookupoffse[2] = dc_colormap; - palookupoffse[3] = dc_colormap; - palookuplight[0] = 0; - palookuplight[1] = 0; - palookuplight[2] = 0; - palookuplight[3] = 0; - } - - if (fixedcolormap) - R_SetColorMapLight(fixedcolormap, 0, 0); - else - R_SetColorMapLight(basecolormap, 0, 0); - - for(; (x < x2) && (((size_t)pixel >> pixelshift) & 3); ++x, pixel += pixelsize) - { - light += rw_lightstep; - y1ve[0] = uwal[x];//max(uwal[x],umost[x]); - y2ve[0] = dwal[x];//min(dwal[x],dmost[x]); - if (y2ve[0] <= y1ve[0]) continue; - - if (!fixed) - { // calculate lighting - R_SetColorMapLight(basecolormap, light, wallshade); - } - - dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); - dc_dest = ylookup[y1ve[0]] * pixelsize + pixel; - dc_count = y2ve[0] - y1ve[0]; - iscale = swal[x] * yrepeat; - dc_iscale = xs_ToFixed(fracbits, iscale); - dc_texturefrac = xs_ToFixed(fracbits, dc_texturemid + iscale * (y1ve[0] - CenterY + 0.5)); - - domvline1(); - } - - for(; x < x2-3; x += 4, pixel += 4 * pixelsize) - { - bad = 0; - for (z = 3, dax = x+3; z >= 0; --z, --dax) - { - y1ve[z] = uwal[dax]; - y2ve[z] = dwal[dax]; - if (y2ve[z] <= y1ve[z]) { bad += 1<> FRACBITS); - iscale = swal[dax] * yrepeat; - vince[z] = xs_ToFixed(fracbits, iscale); - vplce[z] = xs_ToFixed(fracbits, dc_texturemid + iscale * (y1ve[z] - CenterY + 0.5)); - } - if (bad == 15) - { - light += rw_lightstep * 4; - continue; - } - - if (!fixed) - { - for (z = 0; z < 4; ++z) - { - light += rw_lightstep; - if (r_swtruecolor) - { - palookupoffse[z] = basecolormapdata; - palookuplight[z] = LIGHTSCALE(light, wallshade); - } - else - { - palookupoffse[z] = basecolormapdata + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); - palookuplight[z] = 0; - } - } - } - - u4 = MAX(MAX(y1ve[0],y1ve[1]),MAX(y1ve[2],y1ve[3])); - d4 = MIN(MIN(y2ve[0],y2ve[1]),MIN(y2ve[2],y2ve[3])); - - if ((bad != 0) || (u4 >= d4)) - { - for (z = 0; z < 4; ++z) - { - if (!(bad & 1)) - { - mvline1(vince[z],palookupoffse[z],palookuplight[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel); - } - bad >>= 1; - } - continue; - } - - for (z = 0; z < 4; ++z) - { - if (u4 > y1ve[z]) - { - vplce[z] = mvline1(vince[z],palookupoffse[z],palookuplight[z],u4-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel); - } - } - - if (d4 > u4) - { - dc_count = d4-u4; - dc_dest = ylookup[u4]*pixelsize+pixel; - domvline4(); - } - - BYTE *i = pixel+ylookup[d4]*pixelsize; - for (z = 0; z < 4; ++z) - { - if (y2ve[z] > d4) - { - mvline1(vince[z],palookupoffse[0],palookuplight[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z*pixelsize); - } - } - } - for(; x < x2; ++x, pixel += pixelsize) - { - light += rw_lightstep; - y1ve[0] = uwal[x]; - y2ve[0] = dwal[x]; - if (y2ve[0] <= y1ve[0]) continue; - - if (!fixed) - { // calculate lighting - R_SetColorMapLight(basecolormap, light, wallshade); - } - - dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); - dc_dest = ylookup[y1ve[0]]*pixelsize + pixel; - dc_count = y2ve[0] - y1ve[0]; - iscale = swal[x] * yrepeat; - dc_iscale = xs_ToFixed(fracbits, iscale); - dc_texturefrac = xs_ToFixed(fracbits, dc_texturemid + iscale * (y1ve[0] - CenterY + 0.5)); - - domvline1(); - } - -//unclock(WallScanCycles); - - NetUpdate (); -} - -inline void preptmvline1 (fixed_t vince, BYTE *colormap, fixed_t light, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest) -{ - dc_iscale = vince; - dc_colormap = colormap; - dc_light = light; - dc_count = count; - dc_texturefrac = vplce; - dc_source = bufplce; - dc_dest = dest; -} - -void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, - double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) -{ - fixed_t (*tmvline1)(); - void (*tmvline4)(); - int x, fracbits; - BYTE *pixel; - int pixelsize, pixelshift; - int y1ve[4], y2ve[4], u4, d4, startx, dax, z; - char bad; - float light = rw_light - rw_lightstep; - SDWORD xoffset; - BYTE *basecolormapdata; - double iscale; - - if (rw_pic->UseType == FTexture::TEX_Null) - { - return; - } - - if (!R_GetTransMaskDrawers (&tmvline1, &tmvline4)) - { - // The current translucency is unsupported, so draw with regular maskwallscan instead. - maskwallscan (x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); - return; - } - -//extern cycle_t WallScanCycles; -//clock (WallScanCycles); - - pixelsize = r_swtruecolor ? 4 : 1; - pixelshift = r_swtruecolor ? 2 : 0; - - rw_pic->GetHeight(); // Make sure texture size is loaded - fracbits = 32 - rw_pic->HeightBits; - setuptmvline(fracbits); - xoffset = rw_offset; - basecolormapdata = basecolormap->Maps; - fixed_t centeryfrac = FLOAT2FIXED(CenterY); - - x = startx = x1; - pixel = x * pixelsize + dc_destorg; - - bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); - if (fixed) - { - palookupoffse[0] = dc_colormap; - palookupoffse[1] = dc_colormap; - palookupoffse[2] = dc_colormap; - palookupoffse[3] = dc_colormap; - palookuplight[0] = 0; - palookuplight[1] = 0; - palookuplight[2] = 0; - palookuplight[3] = 0; - } - - if (fixedcolormap) - R_SetColorMapLight(fixedcolormap, 0, 0); - else - R_SetColorMapLight(basecolormap, 0, 0); - - for(; (x < x2) && (((size_t)pixel >> pixelshift) & 3); ++x, pixel += pixelsize) - { - light += rw_lightstep; - y1ve[0] = uwal[x];//max(uwal[x],umost[x]); - y2ve[0] = dwal[x];//min(dwal[x],dmost[x]); - if (y2ve[0] <= y1ve[0]) continue; - - if (!fixed) - { // calculate lighting - R_SetColorMapLight(basecolormap, light, wallshade); - } - - dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); - dc_dest = ylookup[y1ve[0]] * pixelsize + pixel; - dc_count = y2ve[0] - y1ve[0]; - iscale = swal[x] * yrepeat; - dc_iscale = xs_ToFixed(fracbits, iscale); - dc_texturefrac = xs_ToFixed(fracbits, dc_texturemid + iscale * (y1ve[0] - CenterY + 0.5)); - - tmvline1(); - } - - for(; x < x2-3; x += 4, pixel += 4 * pixelsize) - { - bad = 0; - for (z = 3, dax = x+3; z >= 0; --z, --dax) - { - y1ve[z] = uwal[dax]; - y2ve[z] = dwal[dax]; - if (y2ve[z] <= y1ve[z]) { bad += 1<> FRACBITS); - iscale = swal[dax] * yrepeat; - vince[z] = xs_ToFixed(fracbits, iscale); - vplce[z] = xs_ToFixed(fracbits, dc_texturemid + vince[z] * (y1ve[z] - CenterY + 0.5)); - } - if (bad == 15) - { - light += rw_lightstep * 4; - continue; - } - - if (!fixed) - { - for (z = 0; z < 4; ++z) - { - light += rw_lightstep; - if (r_swtruecolor) - { - palookupoffse[z] = basecolormapdata; - palookuplight[z] = LIGHTSCALE(light, wallshade); - } - else - { - palookupoffse[z] = basecolormapdata + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); - } - } - } - - u4 = MAX(MAX(y1ve[0],y1ve[1]),MAX(y1ve[2],y1ve[3])); - d4 = MIN(MIN(y2ve[0],y2ve[1]),MIN(y2ve[2],y2ve[3])); - - if ((bad != 0) || (u4 >= d4)) - { - for (z = 0; z < 4; ++z) - { - if (!(bad & 1)) - { - preptmvline1(vince[z],palookupoffse[z],palookuplight[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel); - tmvline1(); - } - bad >>= 1; - } - continue; - } - - for (z = 0; z < 4; ++z) - { - if (u4 > y1ve[z]) - { - preptmvline1(vince[z],palookupoffse[z],palookuplight[z],u4-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel); - vplce[z] = tmvline1(); - } - } - - if (d4 > u4) - { - dc_count = d4-u4; - dc_dest = ylookup[u4]*pixelsize+pixel; - tmvline4(); - } - - BYTE *i = pixel+ylookup[d4]*pixelsize; - for (z = 0; z < 4; ++z) - { - if (y2ve[z] > d4) - { - preptmvline1(vince[z],palookupoffse[0],palookuplight[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z*pixelsize); - tmvline1(); - } - } - } - for(; x < x2; ++x, pixel += pixelsize) - { - light += rw_lightstep; - y1ve[0] = uwal[x]; - y2ve[0] = dwal[x]; - if (y2ve[0] <= y1ve[0]) continue; - - if (!fixed) - { // calculate lighting - R_SetColorMapLight(basecolormap, light, wallshade); - } - - dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); - dc_dest = ylookup[y1ve[0]] * pixelsize + pixel; - dc_count = y2ve[0] - y1ve[0]; - iscale = swal[x] * yrepeat; - dc_iscale = xs_ToFixed(fracbits, iscale); - dc_texturefrac = xs_ToFixed(fracbits, dc_texturemid + iscale * (y1ve[0] - CenterY + 0.5)); - - tmvline1(); - } - -//unclock(WallScanCycles); - - NetUpdate (); + call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, true); } // From 05b6fe6174147ceef8c64ad83a1eab2736080c3e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 10 Jun 2016 13:50:34 +0200 Subject: [PATCH 0637/1509] Added true color texture support for walls and floors --- src/r_draw.cpp | 7 +- src/r_draw.h | 22 ++- src/r_draw_rgba.cpp | 303 +++++++++++++++++++----------------- src/r_main.h | 46 ++++++ src/r_plane.cpp | 104 +++++++++---- src/r_segs.cpp | 4 + src/textures/pngtexture.cpp | 162 ++++++++++++++++++- src/textures/texture.cpp | 28 ++++ src/textures/textures.h | 12 +- 9 files changed, 508 insertions(+), 180 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 984a74f3f..2710b9992 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -2265,9 +2265,12 @@ const BYTE *R_GetColumn (FTexture *tex, int col) { col = width + (col % width); } - return tex->GetColumn (col, NULL); -} + if (r_swtruecolor) + return (const BYTE *)tex->GetColumnBgra(col, NULL); + else + return tex->GetColumn(col, NULL); +} // [RH] Initialize the column drawer pointers void R_InitColumnDrawers () diff --git a/src/r_draw.h b/src/r_draw.h index bf73c9dfb..3f97a7a65 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -520,6 +520,9 @@ class DrawerCommandQueue std::condition_variable end_condition; int finished_threads = 0; + bool no_threading = false; + DrawerThread single_core_thread; + void StartThreads(); void StopThreads(); @@ -535,11 +538,20 @@ public: template static void QueueCommand(Types &&... args) { - void *ptr = AllocMemory(sizeof(T)); - T *command = new (ptr)T(std::forward(args)...); - if (!command) - return; - Instance()->commands.push_back(command); + auto queue = Instance(); + if (queue->no_threading) + { + T command(std::forward(args)...); + command.Execute(&queue->single_core_thread); + } + else + { + void *ptr = AllocMemory(sizeof(T)); + if (!ptr) + return; + T *command = new (ptr)T(std::forward(args)...); + queue->commands.push_back(command); + } } // Wait until all worker threads finished executing commands diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 489716e1f..528c3c986 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -85,6 +85,8 @@ void* DrawerCommandQueue::AllocMemory(size_t size) void DrawerCommandQueue::Finish() { auto queue = Instance(); + if (queue->commands.empty()) + return; // Give worker threads something to do: @@ -190,8 +192,8 @@ class DrawColumnRGBACommand : public DrawerCommand { int dc_count; BYTE *dc_dest; - fixed_t dc_texturefrac; - fixed_t dc_iscale; + DWORD dc_texturefrac; + DWORD dc_iscale; fixed_t dc_light; const BYTE *dc_source; int dc_pitch; @@ -628,8 +630,8 @@ class DrawAddColumnRGBACommand : public DrawerCommand { int dc_count; BYTE *dc_dest; - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; const BYTE *dc_source; int dc_pitch; fixed_t dc_light; @@ -708,8 +710,8 @@ class DrawTranslatedColumnRGBACommand : public DrawerCommand fixed_t dc_light; ShadeConstants dc_shade_constants; BYTE *dc_dest; - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; BYTE *dc_translation; const BYTE *dc_source; int dc_pitch; @@ -769,8 +771,8 @@ class DrawTlatedAddColumnRGBACommand : public DrawerCommand fixed_t dc_light; ShadeConstants dc_shade_constants; BYTE *dc_dest; - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; BYTE *dc_translation; const BYTE *dc_source; int dc_pitch; @@ -845,8 +847,8 @@ class DrawShadedColumnRGBACommand : public DrawerCommand private: int dc_count; BYTE *dc_dest; - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; fixed_t dc_light; const BYTE *dc_source; lighttable_t *dc_colormap; @@ -918,8 +920,8 @@ class DrawAddClampColumnRGBACommand : public DrawerCommand { int dc_count; BYTE *dc_dest; - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; const BYTE *dc_source; int dc_pitch; fixed_t dc_light; @@ -994,8 +996,8 @@ class DrawAddClampTranslatedColumnRGBACommand : public DrawerCommand { int dc_count; BYTE *dc_dest; - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; BYTE *dc_translation; const BYTE *dc_source; int dc_pitch; @@ -1073,8 +1075,8 @@ class DrawSubClampColumnRGBACommand : public DrawerCommand { int dc_count; BYTE *dc_dest; - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; const BYTE *dc_source; int dc_pitch; fixed_t dc_light; @@ -1149,8 +1151,8 @@ class DrawSubClampTranslatedColumnRGBACommand : public DrawerCommand { int dc_count; BYTE *dc_dest; - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; const BYTE *dc_source; int dc_pitch; fixed_t dc_light; @@ -1228,8 +1230,8 @@ class DrawRevSubClampColumnRGBACommand : public DrawerCommand { int dc_count; BYTE *dc_dest; - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; const BYTE *dc_source; int dc_pitch; fixed_t dc_light; @@ -1303,8 +1305,8 @@ class DrawRevSubClampTranslatedColumnRGBACommand : public DrawerCommand { int dc_count; BYTE *dc_dest; - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; const BYTE *dc_source; int dc_pitch; fixed_t dc_light; @@ -1380,7 +1382,7 @@ public: class DrawSpanRGBACommand : public DrawerCommand { - const BYTE *ds_source; + const uint32_t *ds_source; fixed_t ds_xfrac; fixed_t ds_yfrac; fixed_t ds_xstep; @@ -1397,7 +1399,7 @@ class DrawSpanRGBACommand : public DrawerCommand public: DrawSpanRGBACommand() { - ds_source = ::ds_source; + ds_source = (const uint32_t*)::ds_source; ds_xfrac = ::ds_xfrac; ds_yfrac = ::ds_yfrac; ds_xstep = ::ds_xstep; @@ -1423,7 +1425,7 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const BYTE* source = ds_source; + const uint32_t* source = ds_source; int count; int spot; @@ -1450,7 +1452,7 @@ public: spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); // Lookup pixel from flat texture tile - *dest++ = shade_pal_index(source[spot], light, shade_constants); + *dest++ = shade_bgra(source[spot], light, shade_constants); // Next step in u,v. xfrac += xstep; @@ -1469,7 +1471,7 @@ public: spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); // Lookup pixel from flat texture tile - *dest++ = shade_pal_index(source[spot], light, shade_constants); + *dest++ = shade_bgra(source[spot], light, shade_constants); // Next step in u,v. xfrac += xstep; @@ -1488,7 +1490,7 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const BYTE* source = ds_source; + const uint32_t* source = ds_source; int count; int spot; @@ -1598,7 +1600,7 @@ public: spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); // Lookup pixel from flat texture tile - *dest++ = shade_pal_index(source[spot], light, shade_constants); + *dest++ = shade_bgra(source[spot], light, shade_constants); // Next step in u,v. xfrac += xstep; @@ -1617,7 +1619,7 @@ public: spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); // Lookup pixel from flat texture tile - *dest++ = shade_pal_index(source[spot], light, shade_constants); + *dest++ = shade_bgra(source[spot], light, shade_constants); // Next step in u,v. xfrac += xstep; @@ -1630,7 +1632,7 @@ public: class DrawSpanMaskedRGBACommand : public DrawerCommand { - const BYTE *ds_source; + const uint32_t *ds_source; fixed_t ds_light; ShadeConstants ds_shade_constants; fixed_t ds_xfrac; @@ -1647,7 +1649,7 @@ class DrawSpanMaskedRGBACommand : public DrawerCommand public: DrawSpanMaskedRGBACommand() { - ds_source = ::ds_source; + ds_source = (const uint32_t*)::ds_source; ds_light = ::ds_light; ds_shade_constants = ::ds_shade_constants; ds_xfrac = ::ds_xfrac; @@ -1672,7 +1674,7 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const BYTE* source = ds_source; + const uint32_t* source = ds_source; int count; int spot; @@ -1694,13 +1696,13 @@ public: // 64x64 is the most common case by far, so special case it. do { - BYTE texdata; + uint32_t texdata; spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); texdata = source[spot]; if (texdata != 0) { - *dest = shade_pal_index(texdata, light, shade_constants); + *dest = shade_bgra(texdata, light, shade_constants); } dest++; xfrac += xstep; @@ -1714,13 +1716,13 @@ public: int xmask = ((1 << ds_xbits) - 1) << ds_ybits; do { - BYTE texdata; + uint32_t texdata; spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); texdata = source[spot]; if (texdata != 0) { - *dest = shade_pal_index(texdata, light, shade_constants); + *dest = shade_bgra(texdata, light, shade_constants); } dest++; xfrac += xstep; @@ -1732,7 +1734,7 @@ public: class DrawSpanTranslucentRGBACommand : public DrawerCommand { - const BYTE *ds_source; + const uint32_t *ds_source; fixed_t ds_light; ShadeConstants ds_shade_constants; fixed_t ds_xfrac; @@ -1749,7 +1751,7 @@ class DrawSpanTranslucentRGBACommand : public DrawerCommand public: DrawSpanTranslucentRGBACommand() { - ds_source = ::ds_source; + ds_source = (const uint32_t *)::ds_source; ds_light = ::ds_light; ds_shade_constants = ::ds_shade_constants; ds_xfrac = ::ds_xfrac; @@ -1774,7 +1776,7 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const BYTE* source = ds_source; + const uint32_t* source = ds_source; int count; int spot; @@ -1801,7 +1803,7 @@ public: { spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t fg = shade_pal_index(source[spot], light, shade_constants); + uint32_t fg = shade_bgra(source[spot], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -1829,7 +1831,7 @@ public: { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t fg = shade_pal_index(source[spot], light, shade_constants); + uint32_t fg = shade_bgra(source[spot], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -1853,7 +1855,7 @@ public: class DrawSpanMaskedTranslucentRGBACommand : public DrawerCommand { - const BYTE *ds_source; + const uint32_t *ds_source; fixed_t ds_light; ShadeConstants ds_shade_constants; fixed_t ds_xfrac; @@ -1870,7 +1872,7 @@ class DrawSpanMaskedTranslucentRGBACommand : public DrawerCommand public: DrawSpanMaskedTranslucentRGBACommand() { - ds_source = ::ds_source; + ds_source = (const uint32_t*)::ds_source; ds_light = ::ds_light; ds_shade_constants = ::ds_shade_constants; ds_xfrac = ::ds_xfrac; @@ -1895,7 +1897,7 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const BYTE* source = ds_source; + const uint32_t* source = ds_source; int count; int spot; @@ -1920,13 +1922,13 @@ public: // 64x64 is the most common case by far, so special case it. do { - BYTE texdata; + uint32_t texdata; spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); texdata = source[spot]; if (texdata != 0) { - uint32_t fg = shade_pal_index(texdata, light, shade_constants); + uint32_t fg = shade_bgra(texdata, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -1953,13 +1955,13 @@ public: int xmask = ((1 << ds_xbits) - 1) << ds_ybits; do { - BYTE texdata; + uint32_t texdata; spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); texdata = source[spot]; if (texdata != 0) { - uint32_t fg = shade_pal_index(texdata, light, shade_constants); + uint32_t fg = shade_bgra(texdata, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -1984,7 +1986,7 @@ public: class DrawSpanAddClampRGBACommand : public DrawerCommand { - const BYTE *ds_source; + const uint32_t *ds_source; fixed_t ds_light; ShadeConstants ds_shade_constants; fixed_t ds_xfrac; @@ -2001,7 +2003,7 @@ class DrawSpanAddClampRGBACommand : public DrawerCommand public: DrawSpanAddClampRGBACommand() { - ds_source = ::ds_source; + ds_source = (const uint32_t*)::ds_source; ds_light = ::ds_light; ds_shade_constants = ::ds_shade_constants; ds_xfrac = ::ds_xfrac; @@ -2026,7 +2028,7 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const BYTE* source = ds_source; + const uint32_t* source = ds_source; int count; int spot; @@ -2053,7 +2055,7 @@ public: { spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t fg = shade_pal_index(source[spot], light, shade_constants); + uint32_t fg = shade_bgra(source[spot], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -2081,7 +2083,7 @@ public: { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t fg = shade_pal_index(source[spot], light, shade_constants); + uint32_t fg = shade_bgra(source[spot], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -2105,7 +2107,7 @@ public: class DrawSpanMaskedAddClampRGBACommand : public DrawerCommand { - const BYTE *ds_source; + const uint32_t *ds_source; fixed_t ds_light; ShadeConstants ds_shade_constants; fixed_t ds_xfrac; @@ -2122,7 +2124,7 @@ class DrawSpanMaskedAddClampRGBACommand : public DrawerCommand public: DrawSpanMaskedAddClampRGBACommand() { - ds_source = ::ds_source; + ds_source = (const uint32_t*)::ds_source; ds_light = ::ds_light; ds_shade_constants = ::ds_shade_constants; ds_xfrac = ::ds_xfrac; @@ -2147,7 +2149,7 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const BYTE* source = ds_source; + const uint32_t* source = ds_source; int count; int spot; @@ -2172,13 +2174,13 @@ public: // 64x64 is the most common case by far, so special case it. do { - BYTE texdata; + uint32_t texdata; spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); texdata = source[spot]; if (texdata != 0) { - uint32_t fg = shade_pal_index(texdata, light, shade_constants); + uint32_t fg = shade_bgra(texdata, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -2205,13 +2207,13 @@ public: int xmask = ((1 << ds_xbits) - 1) << ds_ybits; do { - BYTE texdata; + uint32_t texdata; spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); texdata = source[spot]; if (texdata != 0) { - uint32_t fg = shade_pal_index(texdata, light, shade_constants); + uint32_t fg = shade_bgra(texdata, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = (fg) & 0xff; @@ -2270,8 +2272,8 @@ public: class Vlinec1RGBACommand : public DrawerCommand { - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; int dc_count; const BYTE *dc_source; BYTE *dc_dest; @@ -2302,7 +2304,7 @@ public: DWORD fracstep = dc_iscale * thread->num_cores; DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const BYTE *source = dc_source; + const uint32 *source = (const uint32 *)dc_source; uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); int bits = vlinebits; int pitch = dc_pitch * thread->num_cores; @@ -2312,7 +2314,7 @@ public: do { - *dest = shade_pal_index(source[frac >> bits], light, shade_constants); + *dest = shade_bgra(source[frac >> bits], light, shade_constants); frac += fracstep; dest += pitch; } while (--count); @@ -2329,7 +2331,7 @@ class Vlinec4RGBACommand : public DrawerCommand fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; - const BYTE *bufplce[4]; + const uint32 *bufplce[4]; public: Vlinec4RGBACommand() @@ -2344,7 +2346,7 @@ public: palookuplight[i] = ::palookuplight[i]; vplce[i] = ::vplce[i]; vince[i] = ::vince[i]; - bufplce[i] = ::bufplce[i]; + bufplce[i] = (const uint32 *)::bufplce[i]; } } @@ -2378,10 +2380,10 @@ public: do { - dest[0] = shade_pal_index(bufplce[0][(place = local_vplce[0]) >> bits], light0, shade_constants); local_vplce[0] = place + local_vince[0]; - dest[1] = shade_pal_index(bufplce[1][(place = local_vplce[1]) >> bits], light1, shade_constants); local_vplce[1] = place + local_vince[1]; - dest[2] = shade_pal_index(bufplce[2][(place = local_vplce[2]) >> bits], light2, shade_constants); local_vplce[2] = place + local_vince[2]; - dest[3] = shade_pal_index(bufplce[3][(place = local_vplce[3]) >> bits], light3, shade_constants); local_vplce[3] = place + local_vince[3]; + dest[0] = shade_bgra(bufplce[0][(place = local_vplce[0]) >> bits], light0, shade_constants); local_vplce[0] = place + local_vince[0]; + dest[1] = shade_bgra(bufplce[1][(place = local_vplce[1]) >> bits], light1, shade_constants); local_vplce[1] = place + local_vince[1]; + dest[2] = shade_bgra(bufplce[2][(place = local_vplce[2]) >> bits], light2, shade_constants); local_vplce[2] = place + local_vince[2]; + dest[3] = shade_bgra(bufplce[3][(place = local_vplce[3]) >> bits], light3, shade_constants); local_vplce[3] = place + local_vince[3]; dest += pitch; } while (--count); } @@ -2403,7 +2405,6 @@ public: ShadeConstants shade_constants = dc_shade_constants; - uint32_t *palette = (uint32_t*)GPalette.BaseColors; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; int skipped = thread->skipped_by_thread(dc_dest_y); @@ -2423,17 +2424,17 @@ public: DWORD place2 = local_vplce[2]; DWORD place3 = local_vplce[3]; - BYTE p0 = bufplce[0][place0 >> bits]; - BYTE p1 = bufplce[1][place1 >> bits]; - BYTE p2 = bufplce[2][place2 >> bits]; - BYTE p3 = bufplce[3][place3 >> bits]; + uint32_t p0 = bufplce[0][place0 >> bits]; + uint32_t p1 = bufplce[1][place1 >> bits]; + uint32_t p2 = bufplce[2][place2 >> bits]; + uint32_t p3 = bufplce[3][place3 >> bits]; local_vplce[0] = place0 + local_vince[0]; local_vplce[1] = place1 + local_vince[1]; local_vplce[2] = place2 + local_vince[2]; local_vplce[3] = place3 + local_vince[3]; - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); SSE_SHADE_SIMPLE(fg); _mm_storeu_si128((__m128i*)dest, fg); dest += pitch; @@ -2449,17 +2450,17 @@ public: DWORD place2 = local_vplce[2]; DWORD place3 = local_vplce[3]; - BYTE p0 = bufplce[0][place0 >> bits]; - BYTE p1 = bufplce[1][place1 >> bits]; - BYTE p2 = bufplce[2][place2 >> bits]; - BYTE p3 = bufplce[3][place3 >> bits]; + uint32_t p0 = bufplce[0][place0 >> bits]; + uint32_t p1 = bufplce[1][place1 >> bits]; + uint32_t p2 = bufplce[2][place2 >> bits]; + uint32_t p3 = bufplce[3][place3 >> bits]; local_vplce[0] = place0 + local_vince[0]; local_vplce[1] = place1 + local_vince[1]; local_vplce[2] = place2 + local_vince[2]; local_vplce[3] = place3 + local_vince[3]; - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); SSE_SHADE(fg, shade_constants); _mm_storeu_si128((__m128i*)dest, fg); dest += pitch; @@ -2471,8 +2472,8 @@ public: class Mvlinec1RGBACommand : public DrawerCommand { - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; int dc_count; const BYTE *dc_source; BYTE *dc_dest; @@ -2503,7 +2504,7 @@ public: DWORD fracstep = dc_iscale * thread->num_cores; DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const BYTE *source = dc_source; + const uint32 *source = (const uint32 *)dc_source; uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); int bits = mvlinebits; int pitch = dc_pitch * thread->num_cores; @@ -2513,10 +2514,10 @@ public: do { - BYTE pix = source[frac >> bits]; + uint32_t pix = source[frac >> bits]; if (pix != 0) { - *dest = shade_pal_index(pix, light, shade_constants); + *dest = shade_bgra(pix, light, shade_constants); } frac += fracstep; dest += pitch; @@ -2534,7 +2535,7 @@ class Mvlinec4RGBACommand : public DrawerCommand fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; - const BYTE *bufplce[4]; + const uint32 *bufplce[4]; public: Mvlinec4RGBACommand() @@ -2549,7 +2550,7 @@ public: palookuplight[i] = ::palookuplight[i]; vplce[i] = ::vplce[i]; vince[i] = ::vince[i]; - bufplce[i] = ::bufplce[i]; + bufplce[i] = (const uint32 *)::bufplce[i]; } } @@ -2583,11 +2584,11 @@ public: do { - BYTE pix; - pix = bufplce[0][(place = local_vplce[0]) >> bits]; if (pix) dest[0] = shade_pal_index(pix, light0, shade_constants); local_vplce[0] = place + local_vince[0]; - pix = bufplce[1][(place = local_vplce[1]) >> bits]; if (pix) dest[1] = shade_pal_index(pix, light1, shade_constants); local_vplce[1] = place + local_vince[1]; - pix = bufplce[2][(place = local_vplce[2]) >> bits]; if (pix) dest[2] = shade_pal_index(pix, light2, shade_constants); local_vplce[2] = place + local_vince[2]; - pix = bufplce[3][(place = local_vplce[3]) >> bits]; if (pix) dest[3] = shade_pal_index(pix, light3, shade_constants); local_vplce[3] = place + local_vince[3]; + uint32_t pix; + pix = bufplce[0][(place = local_vplce[0]) >> bits]; if (pix) dest[0] = shade_bgra(pix, light0, shade_constants); local_vplce[0] = place + local_vince[0]; + pix = bufplce[1][(place = local_vplce[1]) >> bits]; if (pix) dest[1] = shade_bgra(pix, light1, shade_constants); local_vplce[1] = place + local_vince[1]; + pix = bufplce[2][(place = local_vplce[2]) >> bits]; if (pix) dest[2] = shade_bgra(pix, light2, shade_constants); local_vplce[2] = place + local_vince[2]; + pix = bufplce[3][(place = local_vplce[3]) >> bits]; if (pix) dest[3] = shade_bgra(pix, light3, shade_constants); local_vplce[3] = place + local_vince[3]; dest += pitch; } while (--count); } @@ -2609,7 +2610,6 @@ public: ShadeConstants shade_constants = dc_shade_constants; - uint32_t *palette = (uint32_t*)GPalette.BaseColors; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; int skipped = thread->skipped_by_thread(dc_dest_y); @@ -2629,10 +2629,10 @@ public: DWORD place2 = local_vplce[2]; DWORD place3 = local_vplce[3]; - BYTE pix0 = bufplce[0][place0 >> bits]; - BYTE pix1 = bufplce[1][place1 >> bits]; - BYTE pix2 = bufplce[2][place2 >> bits]; - BYTE pix3 = bufplce[3][place3 >> bits]; + uint32_t pix0 = bufplce[0][place0 >> bits]; + uint32_t pix1 = bufplce[1][place1 >> bits]; + uint32_t pix2 = bufplce[2][place2 >> bits]; + uint32_t pix3 = bufplce[3][place3 >> bits]; // movemask = !(pix == 0) __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); @@ -2642,7 +2642,7 @@ public: local_vplce[2] = place2 + local_vince[2]; local_vplce[3] = place3 + local_vince[3]; - __m128i fg = _mm_set_epi32(palette[pix3], palette[pix2], palette[pix1], palette[pix0]); + __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); SSE_SHADE_SIMPLE(fg); _mm_maskmoveu_si128(fg, movemask, (char*)dest); dest += pitch; @@ -2658,10 +2658,10 @@ public: DWORD place2 = local_vplce[2]; DWORD place3 = local_vplce[3]; - BYTE pix0 = bufplce[0][place0 >> bits]; - BYTE pix1 = bufplce[1][place1 >> bits]; - BYTE pix2 = bufplce[2][place2 >> bits]; - BYTE pix3 = bufplce[3][place3 >> bits]; + uint32_t pix0 = bufplce[0][place0 >> bits]; + uint32_t pix1 = bufplce[1][place1 >> bits]; + uint32_t pix2 = bufplce[2][place2 >> bits]; + uint32_t pix3 = bufplce[3][place3 >> bits]; // movemask = !(pix == 0) __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); @@ -2671,7 +2671,7 @@ public: local_vplce[2] = place2 + local_vince[2]; local_vplce[3] = place3 + local_vince[3]; - __m128i fg = _mm_set_epi32(palette[pix3], palette[pix2], palette[pix1], palette[pix0]); + __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); SSE_SHADE(fg, shade_constants); _mm_maskmoveu_si128(fg, movemask, (char*)dest); dest += pitch; @@ -2683,8 +2683,8 @@ public: class Tmvline1AddRGBACommand : public DrawerCommand { - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; int dc_count; const BYTE *dc_source; BYTE *dc_dest; @@ -2719,7 +2719,7 @@ public: DWORD fracstep = dc_iscale * thread->num_cores; DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const BYTE *source = dc_source; + const uint32 *source = (const uint32 *)dc_source; uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); int bits = tmvlinebits; int pitch = dc_pitch * thread->num_cores; @@ -2732,10 +2732,10 @@ public: do { - BYTE pix = source[frac >> bits]; + uint32_t pix = source[frac >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(pix, light, shade_constants); + uint32_t fg = shade_bgra(pix, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -2768,7 +2768,7 @@ class Tmvline4AddRGBACommand : public DrawerCommand fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; - const BYTE *bufplce[4]; + const uint32 *bufplce[4]; public: Tmvline4AddRGBACommand() @@ -2785,7 +2785,7 @@ public: palookuplight[i] = ::palookuplight[i]; vplce[i] = ::vplce[i]; vince[i] = ::vince[i]; - bufplce[i] = ::bufplce[i]; + bufplce[i] = (const uint32 *)::bufplce[i]; } } @@ -2823,10 +2823,10 @@ public: { for (int i = 0; i < 4; ++i) { - BYTE pix = bufplce[i][local_vplce[i] >> bits]; + uint32_t pix = bufplce[i][local_vplce[i] >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(pix, light[i], shade_constants); + uint32_t fg = shade_bgra(pix, light[i], shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -2850,8 +2850,8 @@ public: class Tmvline1AddClampRGBACommand : public DrawerCommand { - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; int dc_count; const BYTE *dc_source; BYTE *dc_dest; @@ -2886,7 +2886,7 @@ public: DWORD fracstep = dc_iscale * thread->num_cores; DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const BYTE *source = dc_source; + const uint32 *source = (const uint32 *)dc_source; uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); int bits = tmvlinebits; int pitch = dc_pitch * thread->num_cores; @@ -2899,10 +2899,10 @@ public: do { - BYTE pix = source[frac >> bits]; + uint32_t pix = source[frac >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(pix, light, shade_constants); + uint32_t fg = shade_bgra(pix, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -2935,7 +2935,7 @@ class Tmvline4AddClampRGBACommand : public DrawerCommand fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; - const BYTE *bufplce[4]; + const uint32 *bufplce[4]; public: Tmvline4AddClampRGBACommand() @@ -2952,7 +2952,7 @@ public: palookuplight[i] = ::palookuplight[i]; vplce[i] = ::vplce[i]; vince[i] = ::vince[i]; - bufplce[i] = ::bufplce[i]; + bufplce[i] = (const uint32 *)::bufplce[i]; } } @@ -2990,10 +2990,10 @@ public: { for (int i = 0; i < 4; ++i) { - BYTE pix = bufplce[i][local_vplce[i] >> bits]; + uint32_t pix = bufplce[i][local_vplce[i] >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(pix, light[i], shade_constants); + uint32_t fg = shade_bgra(pix, light[i], shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -3017,8 +3017,8 @@ public: class Tmvline1SubClampRGBACommand : public DrawerCommand { - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; int dc_count; const BYTE *dc_source; BYTE *dc_dest; @@ -3053,7 +3053,7 @@ public: DWORD fracstep = dc_iscale * thread->num_cores; DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const BYTE *source = dc_source; + const uint32 *source = (const uint32 *)dc_source; uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); int bits = tmvlinebits; int pitch = dc_pitch * thread->num_cores; @@ -3066,10 +3066,10 @@ public: do { - BYTE pix = source[frac >> bits]; + uint32_t pix = source[frac >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(pix, light, shade_constants); + uint32_t fg = shade_bgra(pix, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -3102,7 +3102,7 @@ class Tmvline4SubClampRGBACommand : public DrawerCommand fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; - const BYTE *bufplce[4]; + const uint32 *bufplce[4]; public: Tmvline4SubClampRGBACommand() @@ -3119,7 +3119,7 @@ public: palookuplight[i] = ::palookuplight[i]; vplce[i] = ::vplce[i]; vince[i] = ::vince[i]; - bufplce[i] = ::bufplce[i]; + bufplce[i] = (const uint32 *)::bufplce[i]; } } @@ -3157,10 +3157,10 @@ public: { for (int i = 0; i < 4; ++i) { - BYTE pix = bufplce[i][local_vplce[i] >> bits]; + uint32_t pix = bufplce[i][local_vplce[i] >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(pix, light[i], shade_constants); + uint32_t fg = shade_bgra(pix, light[i], shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -3184,8 +3184,8 @@ public: class Tmvline1RevSubClampRGBACommand : public DrawerCommand { - fixed_t dc_iscale; - fixed_t dc_texturefrac; + DWORD dc_iscale; + DWORD dc_texturefrac; int dc_count; const BYTE *dc_source; BYTE *dc_dest; @@ -3220,7 +3220,7 @@ public: DWORD fracstep = dc_iscale * thread->num_cores; DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const BYTE *source = dc_source; + const uint32 *source = (const uint32 *)dc_source; uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); int bits = tmvlinebits; int pitch = dc_pitch * thread->num_cores; @@ -3233,10 +3233,10 @@ public: do { - BYTE pix = source[frac >> bits]; + uint32_t pix = source[frac >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(pix, light, shade_constants); + uint32_t fg = shade_bgra(pix, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -3269,7 +3269,7 @@ class Tmvline4RevSubClampRGBACommand : public DrawerCommand fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; - const BYTE *bufplce[4]; + const uint32 *bufplce[4]; public: Tmvline4RevSubClampRGBACommand() @@ -3286,7 +3286,7 @@ public: palookuplight[i] = ::palookuplight[i]; vplce[i] = ::vplce[i]; vince[i] = ::vince[i]; - bufplce[i] = ::bufplce[i]; + bufplce[i] = (const uint32 *)::bufplce[i]; } } @@ -3324,10 +3324,10 @@ public: { for (int i = 0; i < 4; ++i) { - BYTE pix = bufplce[i][local_vplce[i] >> bits]; + uint32_t pix = bufplce[i][local_vplce[i] >> bits]; if (pix != 0) { - uint32_t fg = shade_pal_index(pix, light[i], shade_constants); + uint32_t fg = shade_bgra(pix, light[i], shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -3549,8 +3549,17 @@ void R_FillSpan_RGBA() DrawerCommandQueue::QueueCommand(); } +extern FTexture *rw_pic; // For the asserts below + DWORD vlinec1_RGBA() { + DWORD fracstep = dc_iscale; + DWORD frac = dc_texturefrac; + DWORD height = rw_pic->GetHeight(); + assert((frac >> vlinebits) < height); + frac += dc_count * fracstep; + assert((frac >> vlinebits) <= height); + DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } @@ -3558,6 +3567,8 @@ DWORD vlinec1_RGBA() void vlinec4_RGBA() { DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) + vplce[i] += vince[i] * dc_count; } DWORD mvlinec1_RGBA() @@ -3569,6 +3580,8 @@ DWORD mvlinec1_RGBA() void mvlinec4_RGBA() { DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) + vplce[i] += vince[i] * dc_count; } fixed_t tmvline1_add_RGBA() @@ -3580,6 +3593,8 @@ fixed_t tmvline1_add_RGBA() void tmvline4_add_RGBA() { DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) + vplce[i] += vince[i] * dc_count; } fixed_t tmvline1_addclamp_RGBA() @@ -3591,6 +3606,8 @@ fixed_t tmvline1_addclamp_RGBA() void tmvline4_addclamp_RGBA() { DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) + vplce[i] += vince[i] * dc_count; } fixed_t tmvline1_subclamp_RGBA() @@ -3602,6 +3619,8 @@ fixed_t tmvline1_subclamp_RGBA() void tmvline4_subclamp_RGBA() { DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) + vplce[i] += vince[i] * dc_count; } fixed_t tmvline1_revsubclamp_RGBA() @@ -3613,6 +3632,8 @@ fixed_t tmvline1_revsubclamp_RGBA() void tmvline4_revsubclamp_RGBA() { DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) + vplce[i] += vince[i] * dc_count; } void R_DrawFogBoundarySection_RGBA(int y, int y2, int x1) diff --git a/src/r_main.h b/src/r_main.h index 5d4ff1174..6d0e2a21f 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -136,6 +136,19 @@ FORCEINLINE uint32_t shade_pal_index_simple(uint32_t index, uint32_t light) return 0xff000000 | (red << 16) | (green << 8) | blue; } +FORCEINLINE uint32_t shade_bgra_simple(uint32_t color, uint32_t light) +{ + uint32_t red = (color >> 16) & 0xff; + uint32_t green = (color >> 8) & 0xff; + uint32_t blue = color & 0xff; + + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; + + return 0xff000000 | (red << 16) | (green << 8) | blue; +} + // Calculates a ARGB8 color for the given palette index, light multiplier and dynamic colormap FORCEINLINE uint32_t shade_pal_index(uint32_t index, uint32_t light, const ShadeConstants &constants) { @@ -171,6 +184,39 @@ FORCEINLINE uint32_t shade_pal_index(uint32_t index, uint32_t light, const Shade return 0xff000000 | (red << 16) | (green << 8) | blue; } +FORCEINLINE uint32_t shade_bgra(uint32_t color, uint32_t light, const ShadeConstants &constants) +{ + uint32_t red = (color >> 16) & 0xff; + uint32_t green = (color >> 8) & 0xff; + uint32_t blue = color & 0xff; + if (constants.simple_shade) + { + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; + } + else + { + uint32_t inv_light = 256 - light; + uint32_t inv_desaturate = 256 - constants.desaturate; + + uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; + + red = (red * inv_desaturate + intensity) / 256; + green = (green * inv_desaturate + intensity) / 256; + blue = (blue * inv_desaturate + intensity) / 256; + + red = (constants.fade_red * inv_light + red * light) / 256; + green = (constants.fade_green * inv_light + green * light) / 256; + blue = (constants.fade_blue * inv_light + blue * light) / 256; + + red = (red * constants.light_red) / 256; + green = (green * constants.light_green) / 256; + blue = (blue * constants.light_blue) / 256; + } + return 0xff000000 | (red << 16) | (green << 8) | blue; +} + // Calculate constants for a simple shade #define SSE_SHADE_SIMPLE_INIT(light) \ __m128i mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 26d579d6d..05fce79a6 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -973,15 +973,22 @@ extern FTexture *rw_pic; // Allow for layer skies up to 512 pixels tall. This is overkill, // since the most anyone can ever see of the sky is 500 pixels. // We need 4 skybufs because wallscan can draw up to 4 columns at a time. +// Need two versions - one for true color and one for palette static BYTE skybuf[4][512]; +static uint32_t skybuf_bgra[4][512]; static DWORD lastskycol[4]; +static DWORD lastskycol_bgra[4]; static int skycolplace; +static int skycolplace_bgra; // Get a column of sky when there is only one sky texture. static const BYTE *R_GetOneSkyColumn (FTexture *fronttex, int x) { angle_t column = (skyangle + xtoviewangle[x]) ^ skyflip; - return fronttex->GetColumn((UMulScale16(column, frontcyl) + frontpos) >> FRACBITS, NULL); + if (!r_swtruecolor) + return fronttex->GetColumn((UMulScale16(column, frontcyl) + frontpos) >> FRACBITS, NULL); + else + return (const BYTE *)fronttex->GetColumnBgra((UMulScale16(column, frontcyl) + frontpos) >> FRACBITS, NULL); } // Get a column of sky when there are two overlapping sky textures @@ -996,38 +1003,77 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) DWORD skycol = (angle1 << 16) | angle2; int i; - for (i = 0; i < 4; ++i) + if (!r_swtruecolor) { - if (lastskycol[i] == skycol) + for (i = 0; i < 4; ++i) { - return skybuf[i]; + if (lastskycol[i] == skycol) + { + return skybuf[i]; + } } + + lastskycol[skycolplace] = skycol; + BYTE *composite = skybuf[skycolplace]; + skycolplace = (skycolplace + 1) & 3; + + // The ordering of the following code has been tuned to allow VC++ to optimize + // it well. In particular, this arrangement lets it keep count in a register + // instead of on the stack. + const BYTE *front = fronttex->GetColumn(angle1, NULL); + const BYTE *back = backskytex->GetColumn(angle2, NULL); + + int count = MIN(512, MIN(backskytex->GetHeight(), fronttex->GetHeight())); + i = 0; + do + { + if (front[i]) + { + composite[i] = front[i]; + } + else + { + composite[i] = back[i]; + } + } while (++i, --count); + return composite; } - - lastskycol[skycolplace] = skycol; - BYTE *composite = skybuf[skycolplace]; - skycolplace = (skycolplace + 1) & 3; - - // The ordering of the following code has been tuned to allow VC++ to optimize - // it well. In particular, this arrangement lets it keep count in a register - // instead of on the stack. - const BYTE *front = fronttex->GetColumn (angle1, NULL); - const BYTE *back = backskytex->GetColumn (angle2, NULL); - - int count = MIN (512, MIN (backskytex->GetHeight(), fronttex->GetHeight())); - i = 0; - do + else { - if (front[i]) + return R_GetOneSkyColumn(fronttex, x); + for (i = 0; i < 4; ++i) { - composite[i] = front[i]; + if (lastskycol_bgra[i] == skycol) + { + return (BYTE*)(skybuf_bgra[i]); + } } - else + + lastskycol_bgra[skycolplace_bgra] = skycol; + uint32_t *composite = skybuf_bgra[skycolplace_bgra]; + skycolplace_bgra = (skycolplace_bgra + 1) & 3; + + // The ordering of the following code has been tuned to allow VC++ to optimize + // it well. In particular, this arrangement lets it keep count in a register + // instead of on the stack. + const uint32_t *front = (const uint32_t *)fronttex->GetColumnBgra(angle1, NULL); + const uint32_t *back = (const uint32_t *)backskytex->GetColumnBgra(angle2, NULL); + + int count = MIN(512, MIN(backskytex->GetHeight(), fronttex->GetHeight())); + i = 0; + do { - composite[i] = back[i]; - } - } while (++i, --count); - return composite; + if (front[i]) + { + composite[i] = front[i]; + } + else + { + composite[i] = back[i]; + } + } while (++i, --count); + return (BYTE*)composite; + } } static void R_DrawSky (visplane_t *pl) @@ -1062,6 +1108,7 @@ static void R_DrawSky (visplane_t *pl) for (x = 0; x < 4; ++x) { lastskycol[x] = 0xffffffff; + lastskycol_bgra[x] = 0xffffffff; } rw_pic = frontskytex; @@ -1075,6 +1122,7 @@ static void R_DrawSky (visplane_t *pl) for (x = 0; x < 4; ++x) { lastskycol[x] = 0xffffffff; + lastskycol_bgra[x] = 0xffffffff; } wallscan (pl->left, pl->right, (short *)pl->top, (short *)pl->bottom, swall, lwall, frontyScale, backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns); @@ -1112,6 +1160,7 @@ static void R_DrawSkyStriped (visplane_t *pl) for (x = 0; x < 4; ++x) { lastskycol[x] = 0xffffffff; + lastskycol_bgra[x] = 0xffffffff; } wallscan (pl->left, pl->right, top, bot, swall, lwall, rw_pic->Scale.Y, backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns); @@ -1230,7 +1279,10 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske R_SetupSpanBits(tex); double xscale = pl->xform.xScale * tex->Scale.X; double yscale = pl->xform.yScale * tex->Scale.Y; - ds_source = tex->GetPixels (); + if (r_swtruecolor) + ds_source = (const BYTE*)tex->GetPixelsBgra(); + else + ds_source = tex->GetPixels(); basecolormap = pl->colormap; planeshade = LIGHT2SHADE(pl->lightlevel); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 5aa7c29a2..87ce48ec4 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1092,6 +1092,8 @@ uint32_t wallscan_drawcol1(int x, int y1, int y2, uint32_t uv_start, uint32_t uv { int next_uv_wrap = (uv_max - uv_pos + uv_step - 1) / uv_step; int count = MIN(left, next_uv_wrap); + if (count <= 0) + break; // This should never happen, but it does.. if (count > 0) { @@ -1146,6 +1148,8 @@ void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_ste int next_uv_wrap = (uv_max - uv_pos[i] + uv_step[i] - 1) / uv_step[i]; count = MIN(next_uv_wrap, count); } + if (count <= 0) + break; // This should never happen, but it does.. // Draw until that column wraps if (count > 0) diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index e47fa62c0..95f7aca75 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -41,6 +41,7 @@ #include "bitmap.h" #include "v_palette.h" #include "textures/textures.h" +#include //========================================================================== // @@ -56,6 +57,7 @@ public: const BYTE *GetColumn (unsigned int column, const Span **spans_out); const BYTE *GetPixels (); + const uint32_t *GetPixelsBgra (); void Unload (); FTextureFormat GetFormat (); int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); @@ -65,6 +67,7 @@ protected: FString SourceFile; BYTE *Pixels; + std::vector PixelsBgra; Span **Spans; BYTE BitDepth; @@ -73,11 +76,13 @@ protected: bool HaveTrans; WORD NonPaletteTrans[3]; + std::vector PngPalette; BYTE *PaletteMap; int PaletteSize; DWORD StartOfIDAT; void MakeTexture (); + void MakeTextureBgra (); friend class FTexture; }; @@ -266,6 +271,12 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename { lump.Seek (len - PaletteSize * 3, SEEK_CUR); } + for (i = 0; i < PaletteSize; i++) + { + PngPalette.push_back(p.pngpal[i][0]); + PngPalette.push_back(p.pngpal[i][1]); + PngPalette.push_back(p.pngpal[i][2]); + } for (i = PaletteSize - 1; i >= 0; --i) { p.palette[i] = MAKERGB(p.pngpal[i][0], p.pngpal[i][1], p.pngpal[i][2]); @@ -369,11 +380,9 @@ FPNGTexture::~FPNGTexture () void FPNGTexture::Unload () { - if (Pixels != NULL) - { - delete[] Pixels; - Pixels = NULL; - } + delete[] Pixels; + Pixels = NULL; + PixelsBgra.clear(); } //========================================================================== @@ -446,6 +455,16 @@ const BYTE *FPNGTexture::GetPixels () return Pixels; } +const uint32_t *FPNGTexture::GetPixelsBgra() +{ + if (PixelsBgra.empty()) + { + MakeTextureBgra(); + } + return PixelsBgra.data(); +} + + //========================================================================== // // @@ -602,6 +621,139 @@ void FPNGTexture::MakeTexture () delete lump; } +void FPNGTexture::MakeTextureBgra () +{ + FileReader *lump; + + if (SourceLump >= 0) + { + lump = new FWadLump(Wads.OpenLumpNum(SourceLump)); + } + else + { + lump = new FileReader(SourceFile.GetChars()); + } + + PixelsBgra.resize(Width * Height, 0xffff0000); + if (StartOfIDAT != 0) + { + DWORD len, id; + lump->Seek (StartOfIDAT, SEEK_SET); + lump->Read(&len, 4); + lump->Read(&id, 4); + + if (ColorType == 0 || ColorType == 3) /* Grayscale and paletted */ + { + std::vector src(Width*Height); + M_ReadIDAT (lump, src.data(), Width, Height, Width, BitDepth, ColorType, Interlace, BigLong((unsigned int)len)); + + if (!PngPalette.empty()) + { + for (int x = 0; x < Width; x++) + { + for (int y = 0; y < Height; y++) + { + uint32_t r = PngPalette[src[x + y * Width] * 3 + 0]; + uint32_t g = PngPalette[src[x + y * Width] * 3 + 1]; + uint32_t b = PngPalette[src[x + y * Width] * 3 + 2]; + PixelsBgra[x * Height + y] = 0xff000000 | (r << 16) | (g << 8) | b; + } + } + } + else + { + for (int x = 0; x < Width; x++) + { + for (int y = 0; y < Height; y++) + { + uint32_t gray = src[x + y * Width]; + PixelsBgra[x * Height + y] = 0xff000000 | (gray << 16) | (gray << 8) | gray; + } + } + } + } + else /* RGB and/or Alpha present */ + { + int bytesPerPixel = ColorType == 2 ? 3 : ColorType == 4 ? 2 : 4; + BYTE *tempix = new BYTE[Width * Height * bytesPerPixel]; + BYTE *in; + uint32_t *out; + int x, y, pitch, backstep; + + M_ReadIDAT (lump, tempix, Width, Height, Width*bytesPerPixel, BitDepth, ColorType, Interlace, BigLong((unsigned int)len)); + in = tempix; + out = PixelsBgra.data(); + + // Convert from source format to paletted, column-major. + // Formats with alpha maps are reduced to only 1 bit of alpha. + switch (ColorType) + { + case 2: // RGB + pitch = Width * 3; + backstep = Height * pitch - 3; + for (x = Width; x > 0; --x) + { + for (y = Height; y > 0; --y) + { + if (!HaveTrans) + { + *out++ = 0xff000000 | (((uint32_t)in[0]) << 16) | (((uint32_t)in[1]) << 8) | ((uint32_t)in[2]); + } + else + { + if (in[0] == NonPaletteTrans[0] && + in[1] == NonPaletteTrans[1] && + in[2] == NonPaletteTrans[2]) + { + *out++ = 0; + } + else + { + *out++ = 0xff000000 | (((uint32_t)in[0]) << 16) | (((uint32_t)in[1]) << 8) | ((uint32_t)in[2]); + } + } + in += pitch; + } + in -= backstep; + } + break; + + case 4: // Grayscale + Alpha + pitch = Width * 2; + backstep = Height * pitch - 2; + for (x = Width; x > 0; --x) + { + for (y = Height; y > 0; --y) + { + uint32_t alpha = in[1]; + uint32_t gray = in[0]; + *out++ = (alpha << 24) | (gray << 16) | (gray << 8) | gray; + in += pitch; + } + in -= backstep; + } + break; + + case 6: // RGB + Alpha + pitch = Width * 4; + backstep = Height * pitch - 4; + for (x = Width; x > 0; --x) + { + for (y = Height; y > 0; --y) + { + *out++ = (((uint32_t)in[3]) << 24) | (((uint32_t)in[0]) << 16) | (((uint32_t)in[1]) << 8) | ((uint32_t)in[2]); + in += pitch; + } + in -= backstep; + } + break; + } + delete[] tempix; + } + } + delete lump; +} + //=========================================================================== // // FPNGTexture::CopyTrueColorPixels diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 7b90c295f..1869491b1 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -45,6 +45,7 @@ #include "v_video.h" #include "m_fixed.h" #include "textures/textures.h" +#include "v_palette.h" typedef bool (*CheckFunc)(FileReader & file); typedef FTexture * (*CreateFunc)(FileReader & file, int lumpnum); @@ -175,6 +176,33 @@ FTexture::~FTexture () KillNative(); } +const uint32_t *FTexture::GetColumnBgra(unsigned int column, const Span **spans_out) +{ + const uint32_t *pixels = GetPixelsBgra(); + + column %= Width; + if (column < 0) + column += Width; + + if (spans_out != nullptr) + GetColumn(column, spans_out); + return pixels + column * Height; +} + +const uint32_t *FTexture::GetPixelsBgra() +{ + if (BgraPixels.empty()) + { + const BYTE *indices = GetPixels(); + BgraPixels.resize(Width * Height); + for (int i = 0; i < Width * Height; i++) + { + BgraPixels[i] = GPalette.BaseColors[indices[i]].d; + } + } + return BgraPixels.data(); +} + bool FTexture::CheckModified () { return false; diff --git a/src/textures/textures.h b/src/textures/textures.h index 14667093c..0d066eff5 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -3,6 +3,7 @@ #include "doomtype.h" #include "vectors.h" +#include class FBitmap; struct FRemapTable; @@ -175,9 +176,15 @@ public: // Returns a single column of the texture virtual const BYTE *GetColumn (unsigned int column, const Span **spans_out) = 0; + // Returns a single column of the texture, in BGRA8 format + virtual const uint32_t *GetColumnBgra(unsigned int column, const Span **spans_out); + // Returns the whole texture, stored in column-major order virtual const BYTE *GetPixels () = 0; - + + // Returns the whole texture, stored in column-major order, in BGRA8 format + virtual const uint32_t *GetPixelsBgra(); + virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL); int CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, FRemapTable *remap, FCopyInfo *inf = NULL); virtual bool UseBasePalette(); @@ -262,6 +269,9 @@ protected: Rotations = other->Rotations; } +private: + std::vector BgraPixels; + public: static void FlipSquareBlock (BYTE *block, int x, int y); static void FlipSquareBlockRemap (BYTE *block, int x, int y, const BYTE *remap); From 24f846f702bb6f8fb57a4a6370f33267442e385c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 10 Jun 2016 14:25:56 +0200 Subject: [PATCH 0638/1509] Bug fixes --- src/r_draw_rgba.cpp | 6 ++---- src/r_main.h | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 528c3c986..fa632cb5d 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -1511,8 +1511,6 @@ public: { // 64x64 is the most common case by far, so special case it. - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - int sse_count = count / 4; count -= sse_count * 4; @@ -1545,7 +1543,7 @@ public: // Lookup pixel from flat texture tile, // re-index using light/colormap. - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); SSE_SHADE_SIMPLE(fg); _mm_storeu_si128((__m128i*)dest, fg); @@ -1582,7 +1580,7 @@ public: // Lookup pixel from flat texture tile, // re-index using light/colormap. - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); SSE_SHADE(fg, shade_constants); _mm_storeu_si128((__m128i*)dest, fg); diff --git a/src/r_main.h b/src/r_main.h index 6d0e2a21f..d71d44fe1 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -217,6 +217,27 @@ FORCEINLINE uint32_t shade_bgra(uint32_t color, uint32_t light, const ShadeConst return 0xff000000 | (red << 16) | (green << 8) | blue; } +FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) +{ + uint32_t fg_alpha = (fg >> 24) & 0xff; + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t alpha = fg_alpha + (fg_alpha >> 7); // 255 -> 256 + uint32_t inv_alpha = 256 - alpha; + + uint32_t bg_red = (bg >> 16) & 0xff; + uint32_t bg_green = (bg >> 8) & 0xff; + uint32_t bg_blue = bg & 0xff; + + uint32_t red = ((fg_red * alpha) + (bg_red * inv_alpha)) / 256; + uint32_t green = ((fg_green * alpha) + (bg_green * inv_alpha)) / 256; + uint32_t blue = ((fg_blue * alpha) + (bg_blue * inv_alpha)) / 256; + + return 0xff000000 | (red << 16) | (green << 8) | blue; +} + // Calculate constants for a simple shade #define SSE_SHADE_SIMPLE_INIT(light) \ __m128i mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ From 6c70eaea2f46cdd2625ad0b51bbcc194ac3200e8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 10 Jun 2016 15:56:50 +0200 Subject: [PATCH 0639/1509] Add jpeg bgra support --- src/textures/jpegtexture.cpp | 116 +++++++++++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 5 deletions(-) diff --git a/src/textures/jpegtexture.cpp b/src/textures/jpegtexture.cpp index 225396598..a37eff6c3 100644 --- a/src/textures/jpegtexture.cpp +++ b/src/textures/jpegtexture.cpp @@ -187,6 +187,7 @@ public: const BYTE *GetColumn (unsigned int column, const Span **spans_out); const BYTE *GetPixels (); + const uint32_t *GetPixelsBgra (); void Unload (); FTextureFormat GetFormat (); int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); @@ -195,9 +196,11 @@ public: protected: BYTE *Pixels; + std::vector PixelsBgra; Span DummySpans[2]; void MakeTexture (); + void MakeTextureBgra (); friend class FTexture; }; @@ -295,11 +298,9 @@ FJPEGTexture::~FJPEGTexture () void FJPEGTexture::Unload () { - if (Pixels != NULL) - { - delete[] Pixels; - Pixels = NULL; - } + delete[] Pixels; + Pixels = NULL; + PixelsBgra.clear(); } //========================================================================== @@ -358,6 +359,15 @@ const BYTE *FJPEGTexture::GetPixels () return Pixels; } +const uint32_t *FJPEGTexture::GetPixelsBgra() +{ + if (PixelsBgra.empty()) + { + MakeTextureBgra(); + } + return PixelsBgra.data(); +} + //========================================================================== // // @@ -457,6 +467,102 @@ void FJPEGTexture::MakeTexture () } } +void FJPEGTexture::MakeTextureBgra() +{ + FWadLump lump = Wads.OpenLumpNum(SourceLump); + JSAMPLE *buff = NULL; + + jpeg_decompress_struct cinfo; + jpeg_error_mgr jerr; + + PixelsBgra.resize(Width * Height, 0xffba0000); + + cinfo.err = jpeg_std_error(&jerr); + cinfo.err->output_message = JPEG_OutputMessage; + cinfo.err->error_exit = JPEG_ErrorExit; + jpeg_create_decompress(&cinfo); + try + { + FLumpSourceMgr sourcemgr(&lump, &cinfo); + jpeg_read_header(&cinfo, TRUE); + if (!((cinfo.out_color_space == JCS_RGB && cinfo.num_components == 3) || + (cinfo.out_color_space == JCS_CMYK && cinfo.num_components == 4) || + (cinfo.out_color_space == JCS_GRAYSCALE && cinfo.num_components == 1))) + { + Printf(TEXTCOLOR_ORANGE "Unsupported color format\n"); + throw - 1; + } + + jpeg_start_decompress(&cinfo); + + int y = 0; + buff = new BYTE[cinfo.output_width * cinfo.output_components]; + + while (cinfo.output_scanline < cinfo.output_height) + { + int num_scanlines = jpeg_read_scanlines(&cinfo, &buff, 1); + BYTE *in = buff; + uint32_t *out = PixelsBgra.data() + y; + switch (cinfo.out_color_space) + { + case JCS_RGB: + for (int x = Width; x > 0; --x) + { + uint32_t r = in[0]; + uint32_t g = in[1]; + uint32_t b = in[2]; + *out = 0xff000000 | (r << 16) | (g << 8) | b; + out += Height; + in += 3; + } + break; + + case JCS_GRAYSCALE: + for (int x = Width; x > 0; --x) + { + uint32_t gray = in[0]; + *out = 0xff000000 | (gray << 16) | (gray << 8) | gray; + out += Height; + in += 1; + } + break; + + case JCS_CMYK: + // What are you doing using a CMYK image? :) + for (int x = Width; x > 0; --x) + { + // To be precise, these calculations should use 255, but + // 256 is much faster and virtually indistinguishable. + uint32_t r = in[3] - (((256 - in[0])*in[3]) >> 8); + uint32_t g = in[3] - (((256 - in[1])*in[3]) >> 8); + uint32_t b = in[3] - (((256 - in[2])*in[3]) >> 8); + *out = 0xff000000 | (r << 16) | (g << 8) | b; + out += Height; + in += 4; + } + break; + + default: + // The other colorspaces were considered above and discarded, + // but GCC will complain without a default for them here. + break; + } + y++; + } + jpeg_finish_decompress(&cinfo); + jpeg_destroy_decompress(&cinfo); + } + catch (int) + { + Printf(TEXTCOLOR_ORANGE " in texture %s\n", Name.GetChars()); + jpeg_destroy_decompress(&cinfo); + } + if (buff != NULL) + { + delete[] buff; + } +} + //=========================================================================== // From 103a6baac54d7d874021ad94f40098cc66d787dc Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 10 Jun 2016 15:57:31 +0200 Subject: [PATCH 0640/1509] Support for drawing in multiple passes --- src/r_draw.h | 17 +++++-- src/r_draw_rgba.cpp | 105 +++++++++++++++++++++++++++++++++++++++---- src/r_drawt_rgba.cpp | 62 +++++++++++++------------ 3 files changed, 141 insertions(+), 43 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index 3f97a7a65..409b7c01b 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -458,25 +458,34 @@ public: // Number of active threads int num_cores = 1; + // Range of rows processed this pass + int pass_start_y = 0; + int pass_end_y = 300; + uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT * 4]; uint32_t *dc_temp_rgba; // Checks if a line is rendered by this thread bool line_skipped_by_thread(int line) { - return line % num_cores != core; + return line < pass_start_y || line >= pass_end_y || line % num_cores != core; } // The number of lines to skip to reach the first line to be rendered by this thread int skipped_by_thread(int first_line) { - return (num_cores - (first_line - core) % num_cores) % num_cores; + int pass_skip = MAX(pass_start_y - first_line, 0); + int core_skip = (num_cores - (first_line + pass_skip - core) % num_cores) % num_cores; + return pass_skip + core_skip; } // The number of lines to be rendered by this thread int count_for_thread(int first_line, int count) { - return (count - skipped_by_thread(first_line) + num_cores - 1) / num_cores; + int lines_until_pass_end = MAX(pass_end_y - first_line, 0); + count = MIN(count, lines_until_pass_end); + int c = (count - skipped_by_thread(first_line) + num_cores - 1) / num_cores; + return MAX(c, 0); } // Calculate the dest address for the first line to be rendered by this thread @@ -522,6 +531,8 @@ class DrawerCommandQueue bool no_threading = false; DrawerThread single_core_thread; + int num_passes = 2; + int rows_in_pass = 540; void StartThreads(); void StopThreads(); diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index fa632cb5d..b81ee4cca 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -104,11 +104,19 @@ void DrawerCommandQueue::Finish() thread.core = 0; thread.num_cores = queue->threads.size() + 1; - size_t size = queue->active_commands.size(); - for (size_t i = 0; i < size; i++) + for (int pass = 0; pass < queue->num_passes; pass++) { - auto &command = queue->active_commands[i]; - command->Execute(&thread); + thread.pass_start_y = pass * queue->rows_in_pass; + thread.pass_end_y = (pass + 1) * queue->rows_in_pass; + if (pass + 1 == queue->num_passes) + thread.pass_end_y = MAX(thread.pass_end_y, MAXHEIGHT); + + size_t size = queue->active_commands.size(); + for (size_t i = 0; i < size; i++) + { + auto &command = queue->active_commands[i]; + command->Execute(&thread); + } } // Wait for everyone to finish: @@ -156,11 +164,19 @@ void DrawerCommandQueue::StartThreads() start_lock.unlock(); // Do the work: - size_t size = queue->active_commands.size(); - for (size_t i = 0; i < size; i++) + for (int pass = 0; pass < queue->num_passes; pass++) { - auto &command = queue->active_commands[i]; - command->Execute(thread); + thread->pass_start_y = pass * queue->rows_in_pass; + thread->pass_end_y = (pass + 1) * queue->rows_in_pass; + if (pass + 1 == queue->num_passes) + thread->pass_end_y = MAX(thread->pass_end_y, MAXHEIGHT); + + size_t size = queue->active_commands.size(); + for (size_t i = 0; i < size; i++) + { + auto &command = queue->active_commands[i]; + command->Execute(thread); + } } // Notify main thread that we finished: @@ -1611,6 +1627,79 @@ public: BYTE xshift = yshift - ds_xbits; int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + int sse_count = count / 4; + count -= sse_count * 4; + + if (shade_constants.simple_shade) + { + SSE_SHADE_SIMPLE_INIT(light); + + while (sse_count--) + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p0 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p1 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p2 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p3 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + // Lookup pixel from flat texture tile + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); + SSE_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += 4; + } + } + else + { + SSE_SHADE_INIT(light, shade_constants); + + while (sse_count--) + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p0 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p1 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p2 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p3 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + // Lookup pixel from flat texture tile + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); + SSE_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + dest += 4; + } + } + + if (count == 0) + return; + do { // Current texture index in u,v. diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index c2caec0c2..28c86d3f5 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -1528,40 +1528,38 @@ public: fracstep = dc_iscale; frac = dc_texturefrac; - { - const BYTE *source = dc_source; + const BYTE *source = dc_source; - if (count & 1) { - *dest = source[frac >> FRACBITS]; dest += 4; frac += fracstep; - } - if (count & 2) { - dest[0] = source[frac >> FRACBITS]; frac += fracstep; - dest[4] = source[frac >> FRACBITS]; frac += fracstep; - dest += 8; - } - if (count & 4) { - dest[0] = source[frac >> FRACBITS]; frac += fracstep; - dest[4] = source[frac >> FRACBITS]; frac += fracstep; - dest[8] = source[frac >> FRACBITS]; frac += fracstep; - dest[12] = source[frac >> FRACBITS]; frac += fracstep; - dest += 16; - } - count >>= 3; - if (!count) return; - - do - { - dest[0] = source[frac >> FRACBITS]; frac += fracstep; - dest[4] = source[frac >> FRACBITS]; frac += fracstep; - dest[8] = source[frac >> FRACBITS]; frac += fracstep; - dest[12] = source[frac >> FRACBITS]; frac += fracstep; - dest[16] = source[frac >> FRACBITS]; frac += fracstep; - dest[20] = source[frac >> FRACBITS]; frac += fracstep; - dest[24] = source[frac >> FRACBITS]; frac += fracstep; - dest[28] = source[frac >> FRACBITS]; frac += fracstep; - dest += 32; - } while (--count); + if (count & 1) { + *dest = source[frac >> FRACBITS]; dest += 4; frac += fracstep; } + if (count & 2) { + dest[0] = source[frac >> FRACBITS]; frac += fracstep; + dest[4] = source[frac >> FRACBITS]; frac += fracstep; + dest += 8; + } + if (count & 4) { + dest[0] = source[frac >> FRACBITS]; frac += fracstep; + dest[4] = source[frac >> FRACBITS]; frac += fracstep; + dest[8] = source[frac >> FRACBITS]; frac += fracstep; + dest[12] = source[frac >> FRACBITS]; frac += fracstep; + dest += 16; + } + count >>= 3; + if (!count) return; + + do + { + dest[0] = source[frac >> FRACBITS]; frac += fracstep; + dest[4] = source[frac >> FRACBITS]; frac += fracstep; + dest[8] = source[frac >> FRACBITS]; frac += fracstep; + dest[12] = source[frac >> FRACBITS]; frac += fracstep; + dest[16] = source[frac >> FRACBITS]; frac += fracstep; + dest[20] = source[frac >> FRACBITS]; frac += fracstep; + dest[24] = source[frac >> FRACBITS]; frac += fracstep; + dest[28] = source[frac >> FRACBITS]; frac += fracstep; + dest += 32; + } while (--count); } }; From 27156eb60ad4d12e32ea24cf90437483c2373818 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 10 Jun 2016 16:32:47 +0200 Subject: [PATCH 0641/1509] Linux compile fixes and missing variable declarations --- src/r_draw.h | 5 +++-- src/r_draw_rgba.cpp | 5 +++++ src/r_segs.cpp | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index 409b7c01b..37a0e6778 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -28,6 +28,7 @@ #include #include #include +#include // Spectre/Invisibility. #define FUZZTABLE 50 @@ -460,7 +461,7 @@ public: // Range of rows processed this pass int pass_start_y = 0; - int pass_end_y = 300; + int pass_end_y = MAXHEIGHT; uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT * 4]; uint32_t *dc_temp_rgba; @@ -527,7 +528,7 @@ class DrawerCommandQueue std::mutex end_mutex; std::condition_variable end_condition; - int finished_threads = 0; + size_t finished_threads = 0; bool no_threading = false; DrawerThread single_core_thread; diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index b81ee4cca..e2dbd443a 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -1726,6 +1726,7 @@ class DrawSpanMaskedRGBACommand : public DrawerCommand fixed_t ds_yfrac; BYTE *dc_destorg; int ds_x1; + int ds_x2; int ds_y1; int ds_y; fixed_t ds_xstep; @@ -1828,6 +1829,7 @@ class DrawSpanTranslucentRGBACommand : public DrawerCommand fixed_t ds_yfrac; BYTE *dc_destorg; int ds_x1; + int ds_x2; int ds_y1; int ds_y; fixed_t ds_xstep; @@ -1949,6 +1951,7 @@ class DrawSpanMaskedTranslucentRGBACommand : public DrawerCommand fixed_t ds_yfrac; BYTE *dc_destorg; int ds_x1; + int ds_x2; int ds_y1; int ds_y; fixed_t ds_xstep; @@ -2080,6 +2083,7 @@ class DrawSpanAddClampRGBACommand : public DrawerCommand fixed_t ds_yfrac; BYTE *dc_destorg; int ds_x1; + int ds_x2; int ds_y1; int ds_y; fixed_t ds_xstep; @@ -2201,6 +2205,7 @@ class DrawSpanMaskedAddClampRGBACommand : public DrawerCommand fixed_t ds_yfrac; BYTE *dc_destorg; int ds_x1; + int ds_x2; int ds_y1; int ds_y; fixed_t ds_xstep; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 87ce48ec4..c1d1ad744 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1184,7 +1184,7 @@ void calc_uv_start_and_step(int y1, float swal, double yrepeat, uint32_t uv_heig // Find start uv in [0-uv_height[ range. // Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range. double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / uv_height; - v = v - std::floor(v); + v = v - floor(v); v *= uv_height; v *= (1 << fracbits); From ffcfe0b54f19420b51284abcbfbec09f3aee9074 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 10 Jun 2016 17:08:45 +0200 Subject: [PATCH 0642/1509] Fix warning --- src/textures/texture.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 1869491b1..d50081062 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -181,8 +181,6 @@ const uint32_t *FTexture::GetColumnBgra(unsigned int column, const Span **spans_ const uint32_t *pixels = GetPixelsBgra(); column %= Width; - if (column < 0) - column += Width; if (spans_out != nullptr) GetColumn(column, spans_out); From 07571da98ccad2fd2c360c4b73ba989a902f184b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 10 Jun 2016 18:43:49 +0200 Subject: [PATCH 0643/1509] Improved how threaded rendering is handled --- src/r_draw.h | 16 ++++++++++++---- src/r_draw_rgba.cpp | 24 ++++++++++++++++++++++-- src/r_main.cpp | 4 +++- src/r_swrenderer.cpp | 3 ++- 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index 37a0e6778..d192dc5e4 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -443,8 +443,11 @@ void R_SetDSColorMapLight(FColormap *base_colormap, float light, int shade); void R_SetTranslationMap(lighttable_t *translation); +// Redirect drawer commands to worker threads +void R_BeginDrawerCommands(); + // Wait until all drawers finished executing -void R_FinishDrawerCommands(); +void R_EndDrawerCommands(); class DrawerCommandQueue; @@ -530,13 +533,14 @@ class DrawerCommandQueue std::condition_variable end_condition; size_t finished_threads = 0; - bool no_threading = false; + int threaded_render = 0; DrawerThread single_core_thread; int num_passes = 2; int rows_in_pass = 540; void StartThreads(); void StopThreads(); + void Finish(); static DrawerCommandQueue *Instance(); @@ -551,7 +555,7 @@ public: static void QueueCommand(Types &&... args) { auto queue = Instance(); - if (queue->no_threading) + if (queue->threaded_render == 0) { T command(std::forward(args)...); command.Execute(&queue->single_core_thread); @@ -565,9 +569,13 @@ public: queue->commands.push_back(command); } } + + // Redirects all drawing commands to worker threads until Finish is called + // Begin/End blocks can be nested. + static void Begin(); // Wait until all worker threads finished executing commands - static void Finish(); + static void End(); }; #endif diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index e2dbd443a..23ab106a6 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -82,6 +82,21 @@ void* DrawerCommandQueue::AllocMemory(size_t size) return data; } +void DrawerCommandQueue::Begin() +{ + auto queue = Instance(); + queue->Finish(); + queue->threaded_render++; +} + +void DrawerCommandQueue::End() +{ + auto queue = Instance(); + queue->Finish(); + if (queue->threaded_render > 0) + queue->threaded_render--; +} + void DrawerCommandQueue::Finish() { auto queue = Instance(); @@ -3515,9 +3530,14 @@ public: ///////////////////////////////////////////////////////////////////////////// -void R_FinishDrawerCommands() +void R_BeginDrawerCommands() { - DrawerCommandQueue::Finish(); + DrawerCommandQueue::Begin(); +} + +void R_EndDrawerCommands() +{ + DrawerCommandQueue::End(); } void R_DrawColumnP_RGBA_C() diff --git a/src/r_main.cpp b/src/r_main.cpp index 348c70120..c1b78303b 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -960,6 +960,8 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas, r_swtruecolor = canvas->IsBgra(); R_InitColumnDrawers(); } + + R_BeginDrawerCommands(); viewwidth = width; RenderTarget = canvas; @@ -979,7 +981,7 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas, R_SetupBuffer (); screen->Unlock (); - R_FinishDrawerCommands(); + R_EndDrawerCommands(); viewactive = savedviewactive; r_swtruecolor = savedoutputformat; diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 62190b606..11f879c38 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -162,10 +162,11 @@ void FSoftwareRenderer::RenderView(player_t *player) R_InitColumnDrawers(); } + R_BeginDrawerCommands(); R_RenderActorView (player->mo); // [RH] Let cameras draw onto textures that were visible this frame. FCanvasTextureInfo::UpdateAll (); - R_FinishDrawerCommands(); + R_EndDrawerCommands(); } //========================================================================== From d5331e60951bbd4509ce1e2f5be13239c58a04d6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 10 Jun 2016 22:22:40 +0200 Subject: [PATCH 0644/1509] Wallscan fix --- src/r_draw_rgba.cpp | 8 +++---- src/r_segs.cpp | 53 ++++++++++++++++++++++----------------------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 23ab106a6..e3a64dd7a 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -3661,16 +3661,16 @@ void R_FillSpan_RGBA() DrawerCommandQueue::QueueCommand(); } -extern FTexture *rw_pic; // For the asserts below +//extern FTexture *rw_pic; // For the asserts below DWORD vlinec1_RGBA() { - DWORD fracstep = dc_iscale; + /*DWORD fracstep = dc_iscale; DWORD frac = dc_texturefrac; DWORD height = rw_pic->GetHeight(); assert((frac >> vlinebits) < height); - frac += dc_count * fracstep; - assert((frac >> vlinebits) <= height); + frac += (dc_count-1) * fracstep; + assert((frac >> vlinebits) <= height);*/ DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index c1d1ad744..451ddf986 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1087,23 +1087,21 @@ uint32_t wallscan_drawcol1(int x, int y1, int y2, uint32_t uv_start, uint32_t uv { uint32_t uv_pos = uv_start; - int left = y2 - y1; + uint32_t left = y2 - y1; while (left > 0) { - int next_uv_wrap = (uv_max - uv_pos + uv_step - 1) / uv_step; - int count = MIN(left, next_uv_wrap); - if (count <= 0) - break; // This should never happen, but it does.. + uint32_t available = uv_max - uv_pos; + uint32_t next_uv_wrap = available / uv_step; + if (available % uv_step != 0) + next_uv_wrap++; + uint32_t count = MIN(left, next_uv_wrap); - if (count > 0) - { - dc_source = source; - dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; - dc_count = count; - dc_iscale = uv_step; - dc_texturefrac = uv_pos; - draw1column(); - } + dc_source = source; + dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; + dc_count = count; + dc_iscale = uv_step; + dc_texturefrac = uv_pos; + draw1column(); left -= count; uv_pos += uv_step * count; @@ -1138,30 +1136,28 @@ void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_ste for (int i = 0; i < 4; i++) bufplce[i] = source[i]; - int left = y2 - y1; + uint32_t left = y2 - y1; while (left > 0) { // Find which column wraps first - int count = left; + uint32_t count = left; for (int i = 0; i < 4; i++) { - int next_uv_wrap = (uv_max - uv_pos[i] + uv_step[i] - 1) / uv_step[i]; + uint32_t available = uv_max - uv_pos[i]; + uint32_t next_uv_wrap = available / uv_step[i]; + if (available % uv_step[i] != 0) + next_uv_wrap++; count = MIN(next_uv_wrap, count); } - if (count <= 0) - break; // This should never happen, but it does.. // Draw until that column wraps - if (count > 0) + for (int i = 0; i < 4; i++) { - for (int i = 0; i < 4; i++) - { - vplce[i] = uv_pos[i]; - vince[i] = uv_step[i]; - } - dc_count = count; - draw4columns(); + vplce[i] = uv_pos[i]; + vince[i] = uv_step[i]; } + dc_count = count; + draw4columns(); // Wrap the uv position for (int i = 0; i < 4; i++) @@ -1299,6 +1295,9 @@ void wallscan_any( { for (int i = 0; i < 4; i++) { + if (y2[i] <= y1[i]) + continue; + if (!fixed) R_SetColorMapLight(basecolormap, lights[i], wallshade); wallscan_drawcol1(x + i, y1[i], y2[i], uv_pos[i], uv_step[i], uv_max, source[i], draw1column); From a6d696bbfd45c30bd7162ab948cdf4ba36fa170e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 11 Jun 2016 00:50:36 +0200 Subject: [PATCH 0645/1509] Undo removal of wallscan_np2 and wallscan_np2_ds --- src/r_segs.cpp | 131 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 115 insertions(+), 16 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 451ddf986..ad242b2f9 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1072,16 +1072,17 @@ uint32_t wallscan_drawcol1(int x, int y1, int y2, uint32_t uv_start, uint32_t uv if (uv_max == 0) // power of two { int count = y2 - y1; - if (count > 0) - { - dc_source = source; - dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; - dc_count = y2 - y1; - dc_iscale = uv_step; - dc_texturefrac = uv_start; - draw1column(); - } - return uv_start + uv_step * (uint32_t)count; + + dc_source = source; + dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; + dc_count = count; + dc_iscale = uv_step; + dc_texturefrac = uv_start; + draw1column(); + + uint64_t step64 = uv_step; + uint64_t pos64 = uv_start; + return (uint32_t)(pos64 + step64 * count); } else { @@ -1119,15 +1120,19 @@ void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_ste int pixelsize = r_swtruecolor ? 4 : 1; if (uv_max == 0) // power of two, no wrap handling needed { + int count = y2 - y1; for (int i = 0; i < 4; i++) { bufplce[i] = source[i]; vplce[i] = uv_pos[i]; vince[i] = uv_step[i]; - uv_pos[i] += uv_step[i] * (y2 - y1); + + uint64_t step64 = uv_step[i]; + uint64_t pos64 = uv_pos[i]; + uv_pos[i] = (uint32_t)(pos64 + step64 * count); } dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; - dc_count = y2 - y1; + dc_count = count; draw4columns(); } else @@ -1481,16 +1486,110 @@ static void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, } } -// wallscan now tiles with non-power-of-two textures - this function is therefore not needed anymore.. +//============================================================================= +// +// wallscan_np2 +// +// This is a wrapper around wallscan that helps it tile textures whose heights +// are not powers of 2. It divides the wall into texture-sized strips and calls +// wallscan for each of those. Since only one repetition of the texture fits +// in each strip, wallscan will not tile. +// +//============================================================================= + void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, bool mask) { - call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, mask); + if (!r_np2) + { + call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, mask); + } + else + { + short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; + short *up, *down; + double texheight = rw_pic->GetHeight(); + double partition; + double scaledtexheight = texheight / yrepeat; + + if (yrepeat >= 0) + { // normal orientation: draw strips from top to bottom + partition = top - fmod(top - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); + if (partition == top) + { + partition -= scaledtexheight; + } + up = uwal; + down = most1; + dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; + while (partition > bot) + { + int j = OWallMost(most3, partition - ViewPos.Z, &WallC); + if (j != 3) + { + for (int j = x1; j < x2; ++j) + { + down[j] = clamp(most3[j], up[j], dwal[j]); + } + call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); + up = down; + down = (down == most1) ? most2 : most1; + } + partition -= scaledtexheight; + dc_texturemid -= texheight; + } + call_wallscan(x1, x2, up, dwal, swal, lwal, yrepeat, mask); + } + else + { // upside down: draw strips from bottom to top + partition = bot - fmod(bot - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); + up = most1; + down = dwal; + dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; + while (partition < top) + { + int j = OWallMost(most3, partition - ViewPos.Z, &WallC); + if (j != 12) + { + for (int j = x1; j < x2; ++j) + { + up[j] = clamp(most3[j], uwal[j], down[j]); + } + call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); + down = up; + up = (up == most1) ? most2 : most1; + } + partition -= scaledtexheight; + dc_texturemid -= texheight; + } + call_wallscan(x1, x2, uwal, down, swal, lwal, yrepeat, mask); + } + } } -// wallscan now tiles with non-power-of-two textures - this function is therefore not needed anymore.. static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) { - call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, true); + if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) + { + double frontcz1 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v1); + double frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1); + double frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2); + double frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2); + double top = MAX(frontcz1, frontcz2); + double bot = MIN(frontfz1, frontfz2); + if (fake3D & FAKE3D_CLIPTOP) + { + top = MIN(top, sclipTop); + } + if (fake3D & FAKE3D_CLIPBOTTOM) + { + bot = MAX(bot, sclipBottom); + } + wallscan_np2(x1, x2, uwal, dwal, swal, lwal, yrepeat, top, bot, true); + } + else + { + call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, true); + } } // From 5ae8e9e8c2a68fb55aab598ba46ad86762fc8806 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 11 Jun 2016 16:17:30 +0200 Subject: [PATCH 0646/1509] Fix missing colormap lookup --- src/r_draw.cpp | 69 +++++++++++++-------------- src/r_draw_rgba.cpp | 28 ++++++----- src/r_drawt_rgba.cpp | 108 +++++++++++++++++++++++++------------------ 3 files changed, 106 insertions(+), 99 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 2710b9992..70b3893f4 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -2793,24 +2793,19 @@ bool R_GetTransMaskDrawers (fixed_t (**tmvline1)(), void (**tmvline4)()) void R_SetTranslationMap(lighttable_t *translation) { dc_fcolormap = nullptr; - dc_shade_constants.light_red = 256; - dc_shade_constants.light_green = 256; - dc_shade_constants.light_blue = 256; - dc_shade_constants.light_alpha = 256; - dc_shade_constants.fade_red = 0; - dc_shade_constants.fade_green = 0; - dc_shade_constants.fade_blue = 0; - dc_shade_constants.fade_alpha = 256; - dc_shade_constants.desaturate = 0; - dc_shade_constants.simple_shade = true; + dc_colormap = translation; if (r_swtruecolor) { - dc_colormap = translation; - dc_light = 0; - } - else - { - dc_colormap = translation; + dc_shade_constants.light_red = 256; + dc_shade_constants.light_green = 256; + dc_shade_constants.light_blue = 256; + dc_shade_constants.light_alpha = 256; + dc_shade_constants.fade_red = 0; + dc_shade_constants.fade_green = 0; + dc_shade_constants.fade_blue = 0; + dc_shade_constants.fade_alpha = 256; + dc_shade_constants.desaturate = 0; + dc_shade_constants.simple_shade = true; dc_light = 0; } } @@ -2818,49 +2813,47 @@ void R_SetTranslationMap(lighttable_t *translation) void R_SetColorMapLight(FColormap *base_colormap, float light, int shade) { dc_fcolormap = base_colormap; - dc_shade_constants.light_red = dc_fcolormap->Color.r * 256 / 255; - dc_shade_constants.light_green = dc_fcolormap->Color.g * 256 / 255; - dc_shade_constants.light_blue = dc_fcolormap->Color.b * 256 / 255; - dc_shade_constants.light_alpha = dc_fcolormap->Color.a * 256 / 255; - dc_shade_constants.fade_red = dc_fcolormap->Fade.r; - dc_shade_constants.fade_green = dc_fcolormap->Fade.g; - dc_shade_constants.fade_blue = dc_fcolormap->Fade.b; - dc_shade_constants.fade_alpha = dc_fcolormap->Fade.a; - dc_shade_constants.desaturate = MIN(abs(dc_fcolormap->Desaturate), 255) * 255 / 256; - dc_shade_constants.simple_shade = (dc_fcolormap->Color.d == 0x00ffffff && dc_fcolormap->Fade.d == 0x00000000 && dc_fcolormap->Desaturate == 0); if (r_swtruecolor) { + dc_shade_constants.light_red = dc_fcolormap->Color.r * 256 / 255; + dc_shade_constants.light_green = dc_fcolormap->Color.g * 256 / 255; + dc_shade_constants.light_blue = dc_fcolormap->Color.b * 256 / 255; + dc_shade_constants.light_alpha = dc_fcolormap->Color.a * 256 / 255; + dc_shade_constants.fade_red = dc_fcolormap->Fade.r; + dc_shade_constants.fade_green = dc_fcolormap->Fade.g; + dc_shade_constants.fade_blue = dc_fcolormap->Fade.b; + dc_shade_constants.fade_alpha = dc_fcolormap->Fade.a; + dc_shade_constants.desaturate = MIN(abs(dc_fcolormap->Desaturate), 255) * 255 / 256; + dc_shade_constants.simple_shade = (dc_fcolormap->Color.d == 0x00ffffff && dc_fcolormap->Fade.d == 0x00000000 && dc_fcolormap->Desaturate == 0); dc_colormap = base_colormap->Maps; dc_light = LIGHTSCALE(light, shade); } else { dc_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); - dc_light = 0; } } void R_SetDSColorMapLight(FColormap *base_colormap, float light, int shade) { ds_fcolormap = base_colormap; - ds_shade_constants.light_red = ds_fcolormap->Color.r * 256 / 255; - ds_shade_constants.light_green = ds_fcolormap->Color.g * 256 / 255; - ds_shade_constants.light_blue = ds_fcolormap->Color.b * 256 / 255; - ds_shade_constants.light_alpha = ds_fcolormap->Color.a * 256 / 255; - ds_shade_constants.fade_red = ds_fcolormap->Fade.r; - ds_shade_constants.fade_green = ds_fcolormap->Fade.g; - ds_shade_constants.fade_blue = ds_fcolormap->Fade.b; - ds_shade_constants.fade_alpha = ds_fcolormap->Fade.a; - ds_shade_constants.desaturate = MIN(abs(ds_fcolormap->Desaturate), 255) * 255 / 256; - ds_shade_constants.simple_shade = (ds_fcolormap->Color.d == 0x00ffffff && ds_fcolormap->Fade.d == 0x00000000 && ds_fcolormap->Desaturate == 0); if (r_swtruecolor) { + ds_shade_constants.light_red = ds_fcolormap->Color.r * 256 / 255; + ds_shade_constants.light_green = ds_fcolormap->Color.g * 256 / 255; + ds_shade_constants.light_blue = ds_fcolormap->Color.b * 256 / 255; + ds_shade_constants.light_alpha = ds_fcolormap->Color.a * 256 / 255; + ds_shade_constants.fade_red = ds_fcolormap->Fade.r; + ds_shade_constants.fade_green = ds_fcolormap->Fade.g; + ds_shade_constants.fade_blue = ds_fcolormap->Fade.b; + ds_shade_constants.fade_alpha = ds_fcolormap->Fade.a; + ds_shade_constants.desaturate = MIN(abs(ds_fcolormap->Desaturate), 255) * 255 / 256; + ds_shade_constants.simple_shade = (ds_fcolormap->Color.d == 0x00ffffff && ds_fcolormap->Fade.d == 0x00000000 && ds_fcolormap->Desaturate == 0); ds_colormap = base_colormap->Maps; ds_light = LIGHTSCALE(light, shade); } else { ds_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); - ds_light = 0; } } diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index e3a64dd7a..979dc0743 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -229,6 +229,7 @@ class DrawColumnRGBACommand : public DrawerCommand const BYTE *dc_source; int dc_pitch; ShadeConstants dc_shade_constants; + BYTE *dc_colormap; public: DrawColumnRGBACommand() @@ -241,6 +242,7 @@ public: dc_source = ::dc_source; dc_pitch = ::dc_pitch; dc_shade_constants = ::dc_shade_constants; + dc_colormap = ::dc_colormap; } void Execute(DrawerThread *thread) override @@ -267,24 +269,20 @@ public: fracstep = dc_iscale * thread->num_cores; frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + // [RH] Get local copies of these variables so that the compiler + // has a better chance of optimizing this well. + const BYTE *source = dc_source; + int pitch = dc_pitch * thread->num_cores; + BYTE *colormap = dc_colormap; + + do { - // [RH] Get local copies of these variables so that the compiler - // has a better chance of optimizing this well. - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; + *dest = shade_pal_index(colormap[source[frac >> FRACBITS]], light, shade_constants); - // Inner loop that does the actual texture mapping, - // e.g. a DDA-lile scaling. - // This is as fast as it gets. - do - { - *dest = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); + dest += pitch; + frac += fracstep; - dest += pitch; - frac += fracstep; - - } while (--count); - } + } while (--count); } }; diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 28c86d3f5..5f0fc4156 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -90,13 +90,13 @@ public: sincr = thread->num_cores * 4; if (count & 1) { - *dest = *source; + *dest = GPalette.BaseColors[*source]; source += sincr; dest += pitch; } if (count & 2) { - dest[0] = source[0]; - dest[pitch] = source[sincr]; + dest[0] = GPalette.BaseColors[source[0]]; + dest[pitch] = GPalette.BaseColors[source[sincr]]; source += sincr * 2; dest += pitch * 2; } @@ -104,10 +104,10 @@ public: return; do { - dest[0] = source[0]; - dest[pitch] = source[sincr]; - dest[pitch * 2] = source[sincr * 2]; - dest[pitch * 3] = source[sincr * 3]; + dest[0] = GPalette.BaseColors[source[0]]; + dest[pitch] = GPalette.BaseColors[source[sincr]]; + dest[pitch * 2] = GPalette.BaseColors[source[sincr * 2]]; + dest[pitch * 3] = GPalette.BaseColors[source[sincr * 3]]; source += sincr * 4; dest += pitch * 4; } while (--count); @@ -124,6 +124,7 @@ class RtMap1colRGBACommand : public DrawerCommand ShadeConstants dc_shade_constants; BYTE *dc_destorg; int dc_pitch; + BYTE *dc_colormap; public: RtMap1colRGBACommand(int hx, int sx, int yl, int yh) @@ -137,6 +138,7 @@ public: dc_shade_constants = ::dc_shade_constants; dc_destorg = ::dc_destorg; dc_pitch = ::dc_pitch; + dc_colormap = ::dc_colormap; } void Execute(DrawerThread *thread) override @@ -158,9 +160,11 @@ public: source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; pitch = dc_pitch * thread->num_cores; sincr = thread->num_cores * 4; + + BYTE *colormap = dc_colormap; if (count & 1) { - *dest = shade_pal_index(*source, light, shade_constants); + *dest = shade_pal_index(colormap[*source], light, shade_constants); source += sincr; dest += pitch; } @@ -168,8 +172,8 @@ public: return; do { - dest[0] = shade_pal_index(source[0], light, shade_constants); - dest[pitch] = shade_pal_index(source[sincr], light, shade_constants); + dest[0] = shade_pal_index(colormap[source[0]], light, shade_constants); + dest[pitch] = shade_pal_index(colormap[source[sincr]], light, shade_constants); source += sincr * 2; dest += pitch * 2; } while (--count); @@ -185,6 +189,7 @@ class RtMap4colsRGBACommand : public DrawerCommand ShadeConstants dc_shade_constants; BYTE *dc_destorg; int dc_pitch; + BYTE *colormap; public: RtMap4colsRGBACommand(int sx, int yl, int yh) @@ -197,6 +202,7 @@ public: dc_shade_constants = ::dc_shade_constants; dc_destorg = ::dc_destorg; dc_pitch = ::dc_pitch; + dc_colormap = ::dc_colormap; } #ifdef NO_SSE @@ -219,12 +225,14 @@ public: source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; pitch = dc_pitch * thread->num_cores; sincr = thread->num_cores * 4; + + BYTE *colormap = dc_colormap; if (count & 1) { - dest[0] = shade_pal_index(source[0], light, shade_constants); - dest[1] = shade_pal_index(source[1], light, shade_constants); - dest[2] = shade_pal_index(source[2], light, shade_constants); - dest[3] = shade_pal_index(source[3], light, shade_constants); + dest[0] = shade_pal_index(colormap[source[0]], light, shade_constants); + dest[1] = shade_pal_index(colormap[source[1]], light, shade_constants); + dest[2] = shade_pal_index(colormap[source[2]], light, shade_constants); + dest[3] = shade_pal_index(colormap[source[3]], light, shade_constants); source += sincr; dest += pitch; } @@ -232,14 +240,14 @@ public: return; do { - dest[0] = shade_pal_index(source[0], light, shade_constants); - dest[1] = shade_pal_index(source[1], light, shade_constants); - dest[2] = shade_pal_index(source[2], light, shade_constants); - dest[3] = shade_pal_index(source[3], light, shade_constants); - dest[pitch] = shade_pal_index(source[sincr], light, shade_constants); - dest[pitch + 1] = shade_pal_index(source[sincr + 1], light, shade_constants); - dest[pitch + 2] = shade_pal_index(source[sincr + 2], light, shade_constants); - dest[pitch + 3] = shade_pal_index(source[sincr + 3], light, shade_constants); + dest[0] = shade_pal_index(colormap[source[0]], light, shade_constants); + dest[1] = shade_pal_index(colormap[source[1]], light, shade_constants); + dest[2] = shade_pal_index(colormap[source[2]], light, shade_constants); + dest[3] = shade_pal_index(colormap[source[3]], light, shade_constants); + dest[pitch] = shade_pal_index(colormap[source[sincr]], light, shade_constants); + dest[pitch + 1] = shade_pal_index(colormap[source[sincr + 1]], light, shade_constants); + dest[pitch + 2] = shade_pal_index(colormap[source[sincr + 2]], light, shade_constants); + dest[pitch + 3] = shade_pal_index(colormap[source[sincr + 3]], light, shade_constants); source += sincr * 2; dest += pitch * 2; } while (--count); @@ -265,16 +273,18 @@ public: source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; pitch = dc_pitch * thread->num_cores; sincr = thread->num_cores * 4; + + BYTE *colormap = dc_colormap; if (shade_constants.simple_shade) { SSE_SHADE_SIMPLE_INIT(light); if (count & 1) { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; // shade_pal_index: __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); @@ -290,10 +300,10 @@ public: do { // shade_pal_index 0-3 { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); SSE_SHADE_SIMPLE(fg); @@ -302,10 +312,10 @@ public: // shade_pal_index 4-7 (pitch) { - uint32_t p0 = source[sincr]; - uint32_t p1 = source[sincr + 1]; - uint32_t p2 = source[sincr + 2]; - uint32_t p3 = source[sincr + 3]; + uint32_t p0 = colormap[source[sincr]]; + uint32_t p1 = colormap[source[sincr + 1]]; + uint32_t p2 = colormap[source[sincr + 2]]; + uint32_t p3 = colormap[source[sincr + 3]]; __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); SSE_SHADE_SIMPLE(fg); @@ -321,10 +331,10 @@ public: SSE_SHADE_INIT(light, shade_constants); if (count & 1) { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; // shade_pal_index: __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); @@ -340,10 +350,10 @@ public: do { // shade_pal_index 0-3 { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); SSE_SHADE(fg, shade_constants); @@ -352,10 +362,10 @@ public: // shade_pal_index 4-7 (pitch) { - uint32_t p0 = source[sincr]; - uint32_t p1 = source[sincr + 1]; - uint32_t p2 = source[sincr + 2]; - uint32_t p3 = source[sincr + 3]; + uint32_t p0 = colormap[source[sincr]]; + uint32_t p1 = colormap[source[sincr + 1]]; + uint32_t p2 = colormap[source[sincr + 2]]; + uint32_t p3 = colormap[source[sincr + 3]]; __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); SSE_SHADE(fg, shade_constants); @@ -1800,6 +1810,9 @@ void rt_span_coverage_rgba(int x, int start, int stop) // drawn to the screen along with up to three other columns. void R_DrawColumnHorizP_RGBA_C (void) { + if (dc_count <= 0) + return; + int x = dc_x & 3; unsigned int **span = &dc_ctspan[x]; (*span)[0] = dc_yl; @@ -1812,6 +1825,9 @@ void R_DrawColumnHorizP_RGBA_C (void) // [RH] Just fills a column with a given color void R_FillColumnHorizP_RGBA_C (void) { + if (dc_count <= 0) + return; + int x = dc_x & 3; unsigned int **span = &dc_ctspan[x]; (*span)[0] = dc_yl; From 40b76dc9b0cd8d59c0f2c597cc4a690cb78ab89e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 11 Jun 2016 18:41:56 +0200 Subject: [PATCH 0647/1509] Apply gamma when using true color output on Linux and Mac --- src/posix/cocoa/i_video.mm | 5 +-- src/posix/sdl/sdlvideo.cpp | 12 +------ src/v_video.cpp | 67 ++++++++++++++++++++++++++++++++++++-- src/v_video.h | 1 + 4 files changed, 68 insertions(+), 17 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 425fe5887..ddfccaa57 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -869,10 +869,7 @@ void CocoaFrameBuffer::Update() if (IsBgra()) { - for (int y = 0; y < Height; y++) - { - memcpy((uint32_t*)m_pixelBuffer + y * Width, (uint32_t*)MemBuffer + y * Pitch, Width * BYTES_PER_PIXEL); - } + CopyWithGammaBgra(m_pixelBuffer, Width * BYTES_PER_PIXEL, m_gammaTable[0], m_gammaTable[1], m_gammaTable[2], m_flashColor, m_flashAmount); } else { diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp index 26121aa71..56b883978 100644 --- a/src/posix/sdl/sdlvideo.cpp +++ b/src/posix/sdl/sdlvideo.cpp @@ -497,17 +497,7 @@ void SDLFB::Update () if (Bgra) { - if (pitch == Pitch * 4) - { - memcpy(pixels, MemBuffer, Width*Height*4); - } - else - { - for (int y = 0; y < Height; ++y) - { - memcpy((BYTE *)pixels + y*pitch, MemBuffer + y*Pitch*4, Width*4); - } - } + CopyWithGammaBgra(pixels, pitch, GammaTable[0], GammaTable[1], GammaTable[2], Flash, FlashAmount); } else if (NotPaletted) { diff --git a/src/v_video.cpp b/src/v_video.cpp index bc99edbf1..e58638121 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -742,13 +742,12 @@ void DCanvas::CalcGamma (float gamma, BYTE gammalookup[256]) // I found this formula on the web at // , // but that page no longer exits. - double invgamma = 1.f / gamma; int i; for (i = 0; i < 256; i++) { - gammalookup[i] = (BYTE)(255.0 * pow (i / 255.0, invgamma)); + gammalookup[i] = (BYTE)(255.0 * pow (i / 255.0, invgamma) + 0.5); } } @@ -876,6 +875,70 @@ DFrameBuffer::DFrameBuffer (int width, int height, bool bgra) Accel2D = false; } +//========================================================================== +// +// DFrameBuffer :: PostprocessBgra +// +// Copies data to destination buffer while performing gamma and flash. +// This is only needed if a target cannot do this with shaders. +// +//========================================================================== + +void DFrameBuffer::CopyWithGammaBgra(void *output, int pitch, const BYTE *gammared, const BYTE *gammagreen, const BYTE *gammablue, PalEntry flash, int flash_amount) +{ + const BYTE *gammatables[3] = { gammared, gammagreen, gammablue }; + + if (flash_amount > 0) + { + uint16_t inv_flash_amount = 256 - flash_amount; + uint16_t flash_red = flash.r * flash_amount; + uint16_t flash_green = flash.g * flash_amount; + uint16_t flash_blue = flash.b * flash_amount; + + for (int y = 0; y < Height; y++) + { + BYTE *dest = (BYTE*)output + y * pitch; + BYTE *src = MemBuffer + y * Pitch * 4; + for (int x = 0; x < Width; x++) + { + uint16_t fg_red = src[2]; + uint16_t fg_green = src[1]; + uint16_t fg_blue = src[0]; + uint16_t red = (fg_red * inv_flash_amount + flash_red) >> 8; + uint16_t green = (fg_green * inv_flash_amount + flash_green) >> 8; + uint16_t blue = (fg_blue * inv_flash_amount + flash_blue) >> 8; + + dest[0] = gammatables[2][blue]; + dest[1] = gammatables[1][green]; + dest[2] = gammatables[0][red]; + dest[3] = 0xff; + + dest += 4; + src += 4; + } + } + } + else + { + for (int y = 0; y < Height; y++) + { + BYTE *dest = (BYTE*)output + y * pitch; + BYTE *src = MemBuffer + y * Pitch * 4; + for (int x = 0; x < Width; x++) + { + dest[0] = gammatables[2][src[0]]; + dest[1] = gammatables[1][src[1]]; + dest[2] = gammatables[0][src[2]]; + dest[3] = 0xff; + + dest += 4; + src += 4; + } + } + } +} + + //========================================================================== // // DFrameBuffer :: DrawRateStuff diff --git a/src/v_video.h b/src/v_video.h index 120beff9a..19213bd26 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -420,6 +420,7 @@ public: protected: void DrawRateStuff (); void CopyFromBuff (BYTE *src, int srcPitch, int width, int height, BYTE *dest); + void CopyWithGammaBgra(void *output, int pitch, const BYTE *gammared, const BYTE *gammagreen, const BYTE *gammablue, PalEntry flash, int flash_amount); DFrameBuffer () {} From 42efc7334e5e5dc0419b020b4db36777bc647be4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 12 Jun 2016 00:50:43 +0200 Subject: [PATCH 0648/1509] Fix missing particles in true color mode --- src/r_draw.h | 7 +++++-- src/r_draw_rgba.cpp | 5 +++++ src/r_things.cpp | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index d192dc5e4..55ad8a0ca 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -570,12 +570,15 @@ public: } } - // Redirects all drawing commands to worker threads until Finish is called + // Redirects all drawing commands to worker threads until End is called // Begin/End blocks can be nested. static void Begin(); - // Wait until all worker threads finished executing commands + // End redirection and wait until all worker threads finished executing static void End(); + + // Waits until all worker threads finished executing + static void WaitForWorkers(); }; #endif diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 979dc0743..af8487964 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -97,6 +97,11 @@ void DrawerCommandQueue::End() queue->threaded_render--; } +void DrawerCommandQueue::WaitForWorkers() +{ + Instance()->Finish(); +} + void DrawerCommandQueue::Finish() { auto queue = Instance(); diff --git a/src/r_things.cpp b/src/r_things.cpp index 933d50e46..0c5e17b7c 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2686,6 +2686,8 @@ void R_DrawParticle_RGBA(vissprite_t *vis) int countbase = vis->x2 - x1; R_DrawMaskedSegsBehindParticle(vis); + + DrawerCommandQueue::WaitForWorkers(); uint32_t fg = shade_pal_index_simple(color, calc_light_multiplier(LIGHTSCALE(0, vis->Style.ColormapNum << FRACBITS))); uint32_t fg_red = (fg >> 16) & 0xff; From 350857a9f6b2e6aa0a0da9f6eb27c2b05066c80e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 12 Jun 2016 19:19:44 +0200 Subject: [PATCH 0649/1509] Fixed fuzz effect when using multiple cores --- src/r_draw_rgba.cpp | 89 ++++++++++++--------------------------------- 1 file changed, 23 insertions(+), 66 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index af8487964..a5d924dfa 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -583,79 +583,36 @@ public: dest = thread->dest_for_thread(dc_yl, dc_pitch, ylookup[dc_yl] + dc_x + (uint32_t*)dc_destorg); - // Note: this implementation assumes this function is only used for the pinky shadow effect (i.e. no other fancy colormap than black) - // I'm not sure if this is really always the case or not. + int pitch = dc_pitch * thread->num_cores; + int fuzzstep = thread->num_cores; + int fuzz = (fuzzpos + thread->skipped_by_thread(dc_yl)) % FUZZTABLE; + while (count > 0) { - // [RH] Make local copies of global vars to try and improve - // the optimizations made by the compiler. - int pitch = dc_pitch * thread->num_cores; - int fuzz = fuzzpos; - int cnt; + int available = (FUZZTABLE - fuzz); + int next_wrap = available / fuzzstep; + if (available % fuzzstep != 0) + next_wrap++; - // [RH] Split this into three separate loops to minimize - // the number of times fuzzpos needs to be clamped. - if (fuzz) + int cnt = MIN(count, next_wrap); + count -= cnt; + do { - cnt = MIN(FUZZTABLE - fuzz, count); - count -= cnt; - do - { - uint32_t bg = dest[fuzzoffset[fuzz++]]; - uint32_t bg_red = (bg >> 16) & 0xff; - uint32_t bg_green = (bg >> 8) & 0xff; - uint32_t bg_blue = (bg) & 0xff; + uint32_t bg = dest[fuzzoffset[fuzz]]; + uint32_t bg_red = (bg >> 16) & 0xff; + uint32_t bg_green = (bg >> 8) & 0xff; + uint32_t bg_blue = (bg) & 0xff; - uint32_t red = bg_red * 3 / 4; - uint32_t green = bg_green * 3 / 4; - uint32_t blue = bg_blue * 3 / 4; + uint32_t red = bg_red * 3 / 4; + uint32_t green = bg_green * 3 / 4; + uint32_t blue = bg_blue * 3 / 4; - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--cnt); - } - if (fuzz == FUZZTABLE || count > 0) - { - while (count >= FUZZTABLE) - { - fuzz = 0; - cnt = FUZZTABLE; - count -= FUZZTABLE; - do - { - uint32_t bg = dest[fuzzoffset[fuzz++]]; - uint32_t bg_red = (bg >> 16) & 0xff; - uint32_t bg_green = (bg >> 8) & 0xff; - uint32_t bg_blue = (bg) & 0xff; + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + fuzz += fuzzstep; + } while (--cnt); - uint32_t red = bg_red * 3 / 4; - uint32_t green = bg_green * 3 / 4; - uint32_t blue = bg_blue * 3 / 4; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--cnt); - } - fuzz = 0; - if (count > 0) - { - do - { - uint32_t bg = dest[fuzzoffset[fuzz++]]; - uint32_t bg_red = (bg >> 16) & 0xff; - uint32_t bg_green = (bg >> 8) & 0xff; - uint32_t bg_blue = (bg) & 0xff; - - uint32_t red = bg_red * 3 / 4; - uint32_t green = bg_green * 3 / 4; - uint32_t blue = bg_blue * 3 / 4; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--count); - } - } - fuzzpos = fuzz; + fuzz %= FUZZTABLE; } } }; From 0f0859b0b2d8f82c89ea1674b6ecc999934ae659 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 12 Jun 2016 22:54:23 +0200 Subject: [PATCH 0650/1509] Special colormap support for when no hw accel is available --- src/r_draw.h | 18 +++++ src/r_draw_rgba.cpp | 152 +++++++++++++++++++++++++++++++++++++++++++ src/r_main.cpp | 4 +- src/r_swrenderer.cpp | 8 +++ src/r_things.cpp | 2 +- 5 files changed, 181 insertions(+), 3 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index 55ad8a0ca..d09d0ab89 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -581,4 +581,22 @@ public: static void WaitForWorkers(); }; +class ApplySpecialColormapRGBACommand : public DrawerCommand +{ + BYTE *buffer; + int pitch; + int width; + int height; + int start_red; + int start_green; + int start_blue; + int end_red; + int end_green; + int end_blue; + +public: + ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen); + void Execute(DrawerThread *thread) override; +}; + #endif diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index a5d924dfa..d5c275d0e 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -3488,6 +3488,158 @@ public: } }; +ApplySpecialColormapRGBACommand::ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen) +{ + buffer = screen->GetBuffer(); + pitch = screen->GetPitch(); + width = screen->GetWidth(); + height = screen->GetHeight(); + + start_red = (int)(colormap->ColorizeStart[0] * 255); + start_green = (int)(colormap->ColorizeStart[1] * 255); + start_blue = (int)(colormap->ColorizeStart[2] * 255); + end_red = (int)(colormap->ColorizeEnd[0] * 255); + end_green = (int)(colormap->ColorizeEnd[1] * 255); + end_blue = (int)(colormap->ColorizeEnd[2] * 255); +} + +#ifdef NO_SSE +void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) +{ + int y = thread->skipped_by_thread(0); + int count = thread->count_for_thread(0, height); + while (count > 0) + { + BYTE *pixels = buffer + y * pitch * 4; + for (int x = 0; x < width; x++) + { + int fg_red = pixels[2]; + int fg_green = pixels[1]; + int fg_blue = pixels[0]; + + int gray = (fg_red * 77 + fg_green * 143 + fg_blue * 37) >> 8; + gray += (gray >> 7); // gray*=256/255 + int inv_gray = 256 - gray; + + int red = clamp((start_red * inv_gray + end_red * gray) >> 8, 0, 255); + int green = clamp((start_green * inv_gray + end_green * gray) >> 8, 0, 255); + int blue = clamp((start_blue * inv_gray + end_blue * gray) >> 8, 0, 255); + + pixels[0] = (BYTE)blue; + pixels[1] = (BYTE)green; + pixels[2] = (BYTE)red; + pixels[3] = 0xff; + + pixels += 4; + } + y += thread->num_cores; + count--; + } +} +#else +void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) +{ + int y = thread->skipped_by_thread(0); + int count = thread->count_for_thread(0, height); + __m128i gray_weight = _mm_set_epi16(256, 77, 143, 37, 256, 77, 143, 37); + __m128i start_end = _mm_set_epi16(255, start_red, start_green, start_blue, 255, end_red, end_green, end_blue); + while (count > 0) + { + BYTE *pixels = buffer + y * pitch * 4; + int sse_length = width / 4; + for (int x = 0; x < sse_length; x++) + { + // Unpack to integers: + __m128i p = _mm_loadu_si128((const __m128i*)pixels); + + __m128i p16_0 = _mm_unpacklo_epi8(p, _mm_setzero_si128()); + __m128i p16_1 = _mm_unpackhi_epi8(p, _mm_setzero_si128()); + + // Add gray weighting to colors + __m128i mullo0 = _mm_mullo_epi16(p16_0, gray_weight); + __m128i mullo1 = _mm_mullo_epi16(p16_1, gray_weight); + __m128i p32_0 = _mm_unpacklo_epi16(mullo0, _mm_setzero_si128()); + __m128i p32_1 = _mm_unpackhi_epi16(mullo0, _mm_setzero_si128()); + __m128i p32_2 = _mm_unpacklo_epi16(mullo1, _mm_setzero_si128()); + __m128i p32_3 = _mm_unpackhi_epi16(mullo1, _mm_setzero_si128()); + + // Transpose to get color components in individual vectors: + __m128 tmpx = _mm_castsi128_ps(p32_0); + __m128 tmpy = _mm_castsi128_ps(p32_1); + __m128 tmpz = _mm_castsi128_ps(p32_2); + __m128 tmpw = _mm_castsi128_ps(p32_3); + _MM_TRANSPOSE4_PS(tmpx, tmpy, tmpz, tmpw); + __m128i blue = _mm_castps_si128(tmpx); + __m128i green = _mm_castps_si128(tmpy); + __m128i red = _mm_castps_si128(tmpz); + __m128i alpha = _mm_castps_si128(tmpw); + + // Calculate gray and 256-gray values: + __m128i gray = _mm_srli_epi32(_mm_add_epi32(_mm_add_epi32(red, green), blue), 8); + __m128i inv_gray = _mm_sub_epi32(_mm_set1_epi32(256), gray); + + // p32 = start * inv_gray + end * gray: + __m128i gray0 = _mm_shuffle_epi32(gray, _MM_SHUFFLE(0, 0, 0, 0)); + __m128i gray1 = _mm_shuffle_epi32(gray, _MM_SHUFFLE(1, 1, 1, 1)); + __m128i gray2 = _mm_shuffle_epi32(gray, _MM_SHUFFLE(2, 2, 2, 2)); + __m128i gray3 = _mm_shuffle_epi32(gray, _MM_SHUFFLE(3, 3, 3, 3)); + __m128i inv_gray0 = _mm_shuffle_epi32(inv_gray, _MM_SHUFFLE(0, 0, 0, 0)); + __m128i inv_gray1 = _mm_shuffle_epi32(inv_gray, _MM_SHUFFLE(1, 1, 1, 1)); + __m128i inv_gray2 = _mm_shuffle_epi32(inv_gray, _MM_SHUFFLE(2, 2, 2, 2)); + __m128i inv_gray3 = _mm_shuffle_epi32(inv_gray, _MM_SHUFFLE(3, 3, 3, 3)); + __m128i gray16_0 = _mm_packs_epi32(gray0, inv_gray0); + __m128i gray16_1 = _mm_packs_epi32(gray1, inv_gray1); + __m128i gray16_2 = _mm_packs_epi32(gray2, inv_gray2); + __m128i gray16_3 = _mm_packs_epi32(gray3, inv_gray3); + __m128i gray16_0_mullo = _mm_mullo_epi16(gray16_0, start_end); + __m128i gray16_1_mullo = _mm_mullo_epi16(gray16_1, start_end); + __m128i gray16_2_mullo = _mm_mullo_epi16(gray16_2, start_end); + __m128i gray16_3_mullo = _mm_mullo_epi16(gray16_3, start_end); + __m128i gray16_0_mulhi = _mm_mulhi_epi16(gray16_0, start_end); + __m128i gray16_1_mulhi = _mm_mulhi_epi16(gray16_1, start_end); + __m128i gray16_2_mulhi = _mm_mulhi_epi16(gray16_2, start_end); + __m128i gray16_3_mulhi = _mm_mulhi_epi16(gray16_3, start_end); + p32_0 = _mm_srli_epi32(_mm_add_epi32(_mm_unpacklo_epi16(gray16_0_mullo, gray16_0_mulhi), _mm_unpackhi_epi16(gray16_0_mullo, gray16_0_mulhi)), 8); + p32_1 = _mm_srli_epi32(_mm_add_epi32(_mm_unpacklo_epi16(gray16_1_mullo, gray16_1_mulhi), _mm_unpackhi_epi16(gray16_1_mullo, gray16_1_mulhi)), 8); + p32_2 = _mm_srli_epi32(_mm_add_epi32(_mm_unpacklo_epi16(gray16_2_mullo, gray16_2_mulhi), _mm_unpackhi_epi16(gray16_2_mullo, gray16_2_mulhi)), 8); + p32_3 = _mm_srli_epi32(_mm_add_epi32(_mm_unpacklo_epi16(gray16_3_mullo, gray16_3_mulhi), _mm_unpackhi_epi16(gray16_3_mullo, gray16_3_mulhi)), 8); + + p16_0 = _mm_packs_epi32(p32_0, p32_1); + p16_1 = _mm_packs_epi32(p32_2, p32_3); + p = _mm_packus_epi16(p16_0, p16_1); + + _mm_storeu_si128((__m128i*)pixels, p); + pixels += 16; + } + + for (int x = sse_length * 4; x < width; x++) + { + int fg_red = pixels[2]; + int fg_green = pixels[1]; + int fg_blue = pixels[0]; + + int gray = (fg_red * 77 + fg_green * 143 + fg_blue * 37) >> 8; + gray += (gray >> 7); // gray*=256/255 + int inv_gray = 256 - gray; + + int red = clamp((start_red * inv_gray + end_red * gray) >> 8, 0, 255); + int green = clamp((start_green * inv_gray + end_green * gray) >> 8, 0, 255); + int blue = clamp((start_blue * inv_gray + end_blue * gray) >> 8, 0, 255); + + pixels[0] = (BYTE)blue; + pixels[1] = (BYTE)green; + pixels[2] = (BYTE)red; + pixels[3] = 0xff; + + pixels += 4; + } + + y += thread->num_cores; + count--; + } +} +#endif + ///////////////////////////////////////////////////////////////////////////// void R_BeginDrawerCommands() diff --git a/src/r_main.cpp b/src/r_main.cpp index c1b78303b..2eb0ce141 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -459,7 +459,7 @@ void R_SetupColormap(player_t *player) if (player->fixedcolormap >= 0 && player->fixedcolormap < (int)SpecialColormaps.Size()) { realfixedcolormap = &SpecialColormaps[player->fixedcolormap]; - if (RenderTarget == screen && (DFrameBuffer *)screen->Accel2D && r_shadercolormaps) + if (RenderTarget == screen && (r_swtruecolor || ((DFrameBuffer *)screen->Accel2D && r_shadercolormaps))) { // Render everything fullbright. The copy to video memory will // apply the special colormap, so it won't be restricted to the @@ -935,7 +935,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) // If we don't want shadered colormaps, NULL it now so that the // copy to the screen does not use a special colormap shader. - if (!r_shadercolormaps) + if (!r_shadercolormaps && !r_swtruecolor) { realfixedcolormap = NULL; } diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 11f879c38..c4558bf7c 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -43,6 +43,7 @@ #include "textures/textures.h" #include "r_data/voxels.h" +EXTERN_CVAR(Bool, r_shadercolormaps) class FArchive; void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, int trueratio); @@ -166,6 +167,13 @@ void FSoftwareRenderer::RenderView(player_t *player) R_RenderActorView (player->mo); // [RH] Let cameras draw onto textures that were visible this frame. FCanvasTextureInfo::UpdateAll (); + + // Apply special colormap if the target cannot do it + if (realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D)) + { + DrawerCommandQueue::QueueCommand(realfixedcolormap, screen); + } + R_EndDrawerCommands(); } diff --git a/src/r_things.cpp b/src/r_things.cpp index 0c5e17b7c..2dc0bdb6c 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1423,7 +1423,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double } } - if (realfixedcolormap != NULL) + if (realfixedcolormap != NULL && (!r_swtruecolor || (r_shadercolormaps && screen->Accel2D))) { // fixed color vis->Style.BaseColormap = realfixedcolormap; vis->Style.ColormapNum = 0; From cc10c2a97045010453c610e68e4a66cef6e36dd9 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 13 Jun 2016 03:16:48 +0200 Subject: [PATCH 0651/1509] Fix cameras and kdizd intro for true color mode --- src/r_main.cpp | 4 +-- src/r_swrenderer.cpp | 35 +++++++++++++++++++----- src/textures/canvastexture.cpp | 49 ++++++++++++++++++++++++++++++++-- src/textures/texture.cpp | 36 +++++++++++++++++++++++++ src/textures/textures.h | 18 +++++++++---- 5 files changed, 126 insertions(+), 16 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index 2eb0ce141..4e5ff1dbd 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -974,6 +974,8 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas, R_RenderActorView (actor, dontmaplines); + R_EndDrawerCommands(); + RenderTarget = screen; bRenderingToCanvas = false; R_ExecuteSetViewSize (); @@ -981,8 +983,6 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas, R_SetupBuffer (); screen->Unlock (); - R_EndDrawerCommands(); - viewactive = savedviewactive; r_swtruecolor = savedoutputformat; diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index c4558bf7c..556323df5 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -87,11 +87,17 @@ void FSoftwareRenderer::PrecacheTexture(FTexture *tex, int cache) if (cache & FTextureManager::HIT_Columnmode) { const FTexture::Span *spanp; - tex->GetColumn(0, &spanp); + /*if (r_swtruecolor) + tex->GetColumnBgra(0, &spanp); + else*/ + tex->GetColumn(0, &spanp); } else if (cache != 0) { - tex->GetPixels (); + if (r_swtruecolor) + tex->GetPixels(); + else + tex->GetPixels (); } else { @@ -328,8 +334,8 @@ void FSoftwareRenderer::CopyStackedViewParameters() void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov) { - BYTE *Pixels = const_cast(tex->GetPixels()); - DSimpleCanvas *Canvas = tex->GetCanvas(); + BYTE *Pixels = r_swtruecolor ? (BYTE*)tex->GetPixelsBgra() : (BYTE*)tex->GetPixels(); + DSimpleCanvas *Canvas = r_swtruecolor ? tex->GetCanvasBgra() : tex->GetCanvas(); // curse Doom's overuse of global variables in the renderer. // These get clobbered by rendering to a camera texture but they need to be preserved so the final rendering can be done with the correct palette. @@ -340,13 +346,28 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin R_SetFOV ((double)fov); R_RenderViewToCanvas (viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate); R_SetFOV (savedfov); - if (Pixels == Canvas->GetBuffer()) + + if (Canvas->IsBgra()) { - FTexture::FlipSquareBlockRemap (Pixels, tex->GetWidth(), tex->GetHeight(), GPalette.Remap); + if (Pixels == Canvas->GetBuffer()) + { + FTexture::FlipSquareBlockBgra((uint32_t*)Pixels, tex->GetWidth(), tex->GetHeight()); + } + else + { + FTexture::FlipNonSquareBlockBgra((uint32_t*)Pixels, (const uint32_t*)Canvas->GetBuffer(), tex->GetWidth(), tex->GetHeight(), Canvas->GetPitch()); + } } else { - FTexture::FlipNonSquareBlockRemap (Pixels, Canvas->GetBuffer(), tex->GetWidth(), tex->GetHeight(), Canvas->GetPitch(), GPalette.Remap); + if (Pixels == Canvas->GetBuffer()) + { + FTexture::FlipSquareBlockRemap(Pixels, tex->GetWidth(), tex->GetHeight(), GPalette.Remap); + } + else + { + FTexture::FlipNonSquareBlockRemap(Pixels, Canvas->GetBuffer(), tex->GetWidth(), tex->GetHeight(), Canvas->GetPitch(), GPalette.Remap); + } } tex->SetUpdated(); fixedcolormap = savecolormap; diff --git a/src/textures/canvastexture.cpp b/src/textures/canvastexture.cpp index 7242149a4..a72546d78 100644 --- a/src/textures/canvastexture.cpp +++ b/src/textures/canvastexture.cpp @@ -53,7 +53,6 @@ FCanvasTexture::FCanvasTexture (const char *name, int width, int height) DummySpans[1].TopOffset = 0; DummySpans[1].Length = 0; UseType = TEX_Wall; - Canvas = NULL; bNeedsUpdate = true; bDidUpdate = false; bHasCanvas = true; @@ -101,6 +100,16 @@ const BYTE *FCanvasTexture::GetPixels () return Pixels; } +const uint32_t *FCanvasTexture::GetPixelsBgra() +{ + bNeedsUpdate = true; + if (CanvasBgra == NULL) + { + MakeTextureBgra(); + } + return PixelsBgra; +} + void FCanvasTexture::MakeTexture () { Canvas = new DSimpleCanvas (Width, Height, false); @@ -123,21 +132,57 @@ void FCanvasTexture::MakeTexture () memset (Pixels+Width*Height/2, 255, Width*Height/2); } +void FCanvasTexture::MakeTextureBgra() +{ + CanvasBgra = new DSimpleCanvas(Width, Height, true); + CanvasBgra->Lock(); + GC::AddSoftRoot(CanvasBgra); + + if (Width != Height || Width != CanvasBgra->GetPitch()) + { + PixelsBgra = new uint32_t[Width*Height]; + bPixelsAllocatedBgra = true; + } + else + { + PixelsBgra = (uint32_t*)CanvasBgra->GetBuffer(); + bPixelsAllocatedBgra = false; + } + + // Draw a special "unrendered" initial texture into the buffer. + memset(PixelsBgra, 0, Width*Height / 2 * 4); + memset(PixelsBgra + Width*Height / 2, 255, Width*Height / 2 * 4); +} + void FCanvasTexture::Unload () { if (bPixelsAllocated) { - if (Pixels != NULL) delete [] Pixels; + if (Pixels != NULL) delete[] Pixels; bPixelsAllocated = false; Pixels = NULL; } + if (bPixelsAllocatedBgra) + { + if (PixelsBgra != NULL) delete[] PixelsBgra; + bPixelsAllocatedBgra = false; + PixelsBgra = NULL; + } + if (Canvas != NULL) { GC::DelSoftRoot(Canvas); Canvas->Destroy(); Canvas = NULL; } + + if (CanvasBgra != NULL) + { + GC::DelSoftRoot(CanvasBgra); + CanvasBgra->Destroy(); + CanvasBgra = NULL; + } } bool FCanvasTexture::CheckModified () diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index d50081062..28a3b9333 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -410,6 +410,29 @@ void FTexture::FlipSquareBlock (BYTE *block, int x, int y) } } +void FTexture::FlipSquareBlockBgra(uint32_t *block, int x, int y) +{ + int i, j; + + if (x != y) return; + + for (i = 0; i < x; ++i) + { + uint32_t *corner = block + x*i + i; + int count = x - i; + if (count & 1) + { + count--; + swapvalues(corner[count], corner[count*x]); + } + for (j = 0; j < count; j += 2) + { + swapvalues(corner[j], corner[j*x]); + swapvalues(corner[j + 1], corner[(j + 1)*x]); + } + } +} + void FTexture::FlipSquareBlockRemap (BYTE *block, int x, int y, const BYTE *remap) { int i, j; @@ -453,6 +476,19 @@ void FTexture::FlipNonSquareBlock (BYTE *dst, const BYTE *src, int x, int y, int } } +void FTexture::FlipNonSquareBlockBgra(uint32_t *dst, const uint32_t *src, int x, int y, int srcpitch) +{ + int i, j; + + for (i = 0; i < x; ++i) + { + for (j = 0; j < y; ++j) + { + dst[i*y + j] = src[i + j*srcpitch]; + } + } +} + void FTexture::FlipNonSquareBlockRemap (BYTE *dst, const BYTE *src, int x, int y, int srcpitch, const BYTE *remap) { int i, j; diff --git a/src/textures/textures.h b/src/textures/textures.h index 0d066eff5..872c83b1a 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -274,8 +274,10 @@ private: public: static void FlipSquareBlock (BYTE *block, int x, int y); + static void FlipSquareBlockBgra (uint32_t *block, int x, int y); static void FlipSquareBlockRemap (BYTE *block, int x, int y, const BYTE *remap); static void FlipNonSquareBlock (BYTE *blockto, const BYTE *blockfrom, int x, int y, int srcpitch); + static void FlipNonSquareBlockBgra (uint32_t *blockto, const uint32_t *blockfrom, int x, int y, int srcpitch); static void FlipNonSquareBlockRemap (BYTE *blockto, const BYTE *blockfrom, int x, int y, int srcpitch, const BYTE *remap); friend class D3DTex; @@ -518,21 +520,27 @@ public: const BYTE *GetColumn (unsigned int column, const Span **spans_out); const BYTE *GetPixels (); + const uint32_t *GetPixelsBgra() override; void Unload (); bool CheckModified (); void NeedUpdate() { bNeedsUpdate=true; } void SetUpdated() { bNeedsUpdate = false; bDidUpdate = true; bFirstUpdate = false; } DSimpleCanvas *GetCanvas() { return Canvas; } + DSimpleCanvas *GetCanvasBgra() { return CanvasBgra; } void MakeTexture (); + void MakeTextureBgra (); protected: - DSimpleCanvas *Canvas; - BYTE *Pixels; + DSimpleCanvas *Canvas = nullptr; + DSimpleCanvas *CanvasBgra = nullptr; + BYTE *Pixels = nullptr; + uint32_t *PixelsBgra = nullptr; Span DummySpans[2]; - bool bNeedsUpdate; - bool bDidUpdate; - bool bPixelsAllocated; + bool bNeedsUpdate = true; + bool bDidUpdate = false; + bool bPixelsAllocated = false; + bool bPixelsAllocatedBgra = false; public: bool bFirstUpdate; From e31331bed265925a2e03d66658863e9c26f2ca26 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 13 Jun 2016 19:09:48 +0200 Subject: [PATCH 0652/1509] Sloped plane adjustments --- src/r_draw.cpp | 4 +- src/r_plane.cpp | 126 +++++------------------------------------------- 2 files changed, 14 insertions(+), 116 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 70b3893f4..ec7313c4f 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -2325,7 +2325,7 @@ void R_InitColumnDrawers () R_FillColumnHoriz = R_FillColumnHorizP_RGBA_C; R_DrawFogBoundary = R_DrawFogBoundary_RGBA; - R_MapTiltedPlane = R_MapColoredPlane_RGBA; + R_MapTiltedPlane = R_MapTiltedPlane_RGBA; R_MapColoredPlane = R_MapColoredPlane_RGBA; R_DrawParticle = R_DrawParticle_RGBA; @@ -2422,7 +2422,7 @@ void R_InitColumnDrawers () R_FillColumnHoriz = R_FillColumnHorizP_C; R_DrawFogBoundary = R_DrawFogBoundary_C; - R_MapTiltedPlane = R_MapColoredPlane_C; + R_MapTiltedPlane = R_MapTiltedPlane_C; R_MapColoredPlane = R_MapColoredPlane_C; R_DrawParticle = R_DrawParticle_C; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 05fce79a6..1cde16071 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -480,124 +480,22 @@ void R_MapTiltedPlane_C (int y, int x1) void R_MapTiltedPlane_RGBA (int y, int x1) { int x2 = spanend[y]; - int width = x2 - x1; - double iz, uz, vz; - uint32_t *fb; - DWORD u, v; - int i; - iz = plane_sz[2] + plane_sz[1]*(centery-y) + plane_sz[0]*(x1-centerx); + // Slopes are broken currently in master. + // Until R_DrawTiltedPlane is fixed we are just going to fill with a solid color. - // Lighting is simple. It's just linear interpolation from start to end - if (plane_shade) + uint32_t *source = (uint32_t*)ds_source; + int source_width = 1 << ds_xbits; + int source_height = 1 << ds_ybits; + + uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg; + + int count = x2 - x1 + 1; + while (count > 0) { - uz = (iz + plane_sz[0]*width) * planelightfloat; - vz = iz * planelightfloat; - R_CalcTiltedLighting (vz, uz, width); + *(dest++) = source[0]; + count--; } - - uz = plane_su[2] + plane_su[1]*(centery-y) + plane_su[0]*(x1-centerx); - vz = plane_sv[2] + plane_sv[1]*(centery-y) + plane_sv[0]*(x1-centerx); - - fb = ylookup[y] + x1 + (uint32_t*)dc_destorg; - - BYTE vshift = 32 - ds_ybits; - BYTE ushift = vshift - ds_xbits; - int umask = ((1 << ds_xbits) - 1) << ds_ybits; - -#if 0 // The "perfect" reference version of this routine. Pretty slow. - // Use it only to see how things are supposed to look. - i = 0; - do - { - double z = 1.f/iz; - - u = SQWORD(uz*z) + pviewx; - v = SQWORD(vz*z) + pviewy; - R_SetDSColorMapLight(tiltlighting[i], 0, 0); - fb[i++] = ds_colormap[ds_source[(v >> vshift) | ((u >> ushift) & umask)]]; - iz += plane_sz[0]; - uz += plane_su[0]; - vz += plane_sv[0]; - } while (--width >= 0); -#else -//#define SPANSIZE 32 -//#define INVSPAN 0.03125f -//#define SPANSIZE 8 -//#define INVSPAN 0.125f -#define SPANSIZE 16 -#define INVSPAN 0.0625f - - double startz = 1.f/iz; - double startu = uz*startz; - double startv = vz*startz; - double izstep, uzstep, vzstep; - - izstep = plane_sz[0] * SPANSIZE; - uzstep = plane_su[0] * SPANSIZE; - vzstep = plane_sv[0] * SPANSIZE; - x1 = 0; - width++; - - while (width >= SPANSIZE) - { - iz += izstep; - uz += uzstep; - vz += vzstep; - - double endz = 1.f/iz; - double endu = uz*endz; - double endv = vz*endz; - DWORD stepu = SQWORD((endu - startu) * INVSPAN); - DWORD stepv = SQWORD((endv - startv) * INVSPAN); - u = SQWORD(startu) + pviewx; - v = SQWORD(startv) + pviewy; - - for (i = SPANSIZE-1; i >= 0; i--) - { - fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); - x1++; - u += stepu; - v += stepv; - } - startu = endu; - startv = endv; - width -= SPANSIZE; - } - if (width > 0) - { - if (width == 1) - { - u = SQWORD(startu); - v = SQWORD(startv); - fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); - } - else - { - double left = width; - iz += plane_sz[0] * left; - uz += plane_su[0] * left; - vz += plane_sv[0] * left; - - double endz = 1.f/iz; - double endu = uz*endz; - double endv = vz*endz; - left = 1.f/left; - DWORD stepu = SQWORD((endu - startu) * left); - DWORD stepv = SQWORD((endv - startv) * left); - u = SQWORD(startu) + pviewx; - v = SQWORD(startv) + pviewy; - - for (; width != 0; width--) - { - fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); - x1++; - u += stepu; - v += stepv; - } - } - } -#endif } //========================================================================== From 3ce2d8365dd6a91c068a20b0caf4b683634ceba3 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 13 Jun 2016 20:01:31 +0200 Subject: [PATCH 0653/1509] Fix HUD colors when hw2d is off --- src/r_draw_rgba.cpp | 9 ++++++--- src/r_drawt_rgba.cpp | 19 +++++++++++++------ src/v_draw.cpp | 13 +++++++++---- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index d5c275d0e..7e9f85117 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -325,11 +325,11 @@ public: { int pitch = dc_pitch * thread->num_cores; - BYTE color = dc_color; + uint32_t color = shade_pal_index_simple(dc_color, light); do { - *dest = shade_pal_index_simple(color, light); + *dest = color; dest += pitch; } while (--count); } @@ -629,6 +629,7 @@ class DrawAddColumnRGBACommand : public DrawerCommand ShadeConstants dc_shade_constants; fixed_t dc_srcalpha; fixed_t dc_destalpha; + BYTE *dc_colormap; public: DrawAddColumnRGBACommand() @@ -643,6 +644,7 @@ public: dc_shade_constants = ::dc_shade_constants; dc_srcalpha = ::dc_srcalpha; dc_destalpha = ::dc_destalpha; + dc_colormap = ::dc_colormap; } void Execute(DrawerThread *thread) override @@ -667,13 +669,14 @@ public: uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; + BYTE *colormap = dc_colormap; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); + uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 5f0fc4156..cd124ac63 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -512,6 +512,7 @@ class RtAdd1colRGBACommand : public DrawerCommand ShadeConstants dc_shade_constants; fixed_t dc_srcalpha; fixed_t dc_destalpha; + BYTE *dc_colormap; public: RtAdd1colRGBACommand(int hx, int sx, int yl, int yh) @@ -527,6 +528,7 @@ public: dc_shade_constants = ::dc_shade_constants; dc_srcalpha = ::dc_srcalpha; dc_destalpha = ::dc_destalpha; + dc_colormap = ::dc_colormap; } void Execute(DrawerThread *thread) override @@ -548,12 +550,13 @@ public: uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; + BYTE *colormap = dc_colormap; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(*source, light, shade_constants); + uint32_t fg = shade_pal_index(colormap[*source], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -583,6 +586,7 @@ class RtAdd4colsRGBACommand : public DrawerCommand int dc_pitch; fixed_t dc_light; ShadeConstants dc_shade_constants; + BYTE *dc_colormap; public: RtAdd4colsRGBACommand(int sx, int yl, int yh) @@ -595,6 +599,7 @@ public: dc_pitch = ::dc_pitch; dc_light = ::dc_light; dc_shade_constants = ::dc_shade_constants; + dc_colormap = ::dc_colormap; } #ifdef NO_SSE @@ -617,6 +622,7 @@ public: uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; + BYTE *colormap = dc_colormap; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -624,7 +630,7 @@ public: do { for (int i = 0; i < 4; i++) { - uint32_t fg = shade_pal_index(source[i], light, shade_constants); + uint32_t fg = shade_pal_index(colormap[source[i]], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -664,6 +670,7 @@ public: uint32_t light = calc_light_multiplier(dc_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; + BYTE *colormap = dc_colormap; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -678,10 +685,10 @@ public: __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; // shade_pal_index: __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index c2dbf31c5..d03853c11 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -1095,9 +1095,10 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real } if (IsBgra()) { + uint32_t fillColor = GPalette.BaseColors[palColor].d; uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0; for (int i = 0; i <= deltaX; i++) - spot[i] = palColor; + spot[i] = fillColor; } else { @@ -1108,11 +1109,12 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real { // vertical line if (IsBgra()) { + uint32_t fillColor = GPalette.BaseColors[palColor].d; uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0; int pitch = GetPitch(); do { - *spot = palColor; + *spot = fillColor; spot += pitch; } while (--deltaY != 0); } @@ -1131,11 +1133,12 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real { // diagonal line. if (IsBgra()) { + uint32_t fillColor = GPalette.BaseColors[palColor].d; uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0; int advance = GetPitch() + xDir; do { - *spot = palColor; + *spot = fillColor; spot += advance; } while (--deltaY != 0); } @@ -1299,12 +1302,14 @@ void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uin if (IsBgra()) { + uint32_t fill_color = GPalette.BaseColors[palcolor]; + uint32_t *dest = (uint32_t*)Buffer + top * Pitch + left; x = right - left; for (y = top; y < bottom; y++) { for (int i = 0; i < x; i++) - dest[i] = palcolor; + dest[i] = fill_color; dest += Pitch; } } From 8ba6a4f17501e34db5b644567fcd40e06502017c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 13 Jun 2016 21:39:55 +0200 Subject: [PATCH 0654/1509] Precache, Unload and FillSimplePoly bug fix --- src/g_strife/strife_sbar.cpp | 5 ----- src/menu/playerdisplay.cpp | 5 ----- src/r_swrenderer.cpp | 4 ++-- src/textures/automaptexture.cpp | 1 + src/textures/buildtexture.cpp | 12 ------------ src/textures/canvastexture.cpp | 2 ++ src/textures/ddstexture.cpp | 1 + src/textures/flattexture.cpp | 1 + src/textures/imgztexture.cpp | 1 + src/textures/jpegtexture.cpp | 3 +-- src/textures/multipatchtexture.cpp | 1 + src/textures/patchtexture.cpp | 1 + src/textures/pcxtexture.cpp | 1 + src/textures/pngtexture.cpp | 3 +-- src/textures/rawpagetexture.cpp | 1 + src/textures/texture.cpp | 20 ++++++++++++-------- src/textures/textures.h | 6 ++---- src/textures/tgatexture.cpp | 1 + src/textures/warptexture.cpp | 1 + src/v_draw.cpp | 2 +- src/v_font.cpp | 2 ++ src/v_video.cpp | 11 ----------- 22 files changed, 33 insertions(+), 52 deletions(-) diff --git a/src/g_strife/strife_sbar.cpp b/src/g_strife/strife_sbar.cpp index bcdf624d7..eb3fa2608 100644 --- a/src/g_strife/strife_sbar.cpp +++ b/src/g_strife/strife_sbar.cpp @@ -35,7 +35,6 @@ public: const BYTE *GetColumn (unsigned int column, const Span **spans_out); const BYTE *GetPixels (); bool CheckModified (); - void Unload (); void SetVial (int level); @@ -90,10 +89,6 @@ bool FHealthBar::CheckModified () return NeedRefresh; } -void FHealthBar::Unload () -{ -} - const BYTE *FHealthBar::GetColumn (unsigned int column, const Span **spans_out) { if (NeedRefresh) diff --git a/src/menu/playerdisplay.cpp b/src/menu/playerdisplay.cpp index c3d11a43a..16671975a 100644 --- a/src/menu/playerdisplay.cpp +++ b/src/menu/playerdisplay.cpp @@ -78,7 +78,6 @@ public: const BYTE *GetColumn(unsigned int column, const Span **spans_out); const BYTE *GetPixels(); - void Unload(); bool CheckModified(); protected: @@ -212,10 +211,6 @@ bool FBackdropTexture::CheckModified() return LastRenderTic != gametic; } -void FBackdropTexture::Unload() -{ -} - //============================================================================= // // diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 556323df5..5be41660e 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -87,9 +87,9 @@ void FSoftwareRenderer::PrecacheTexture(FTexture *tex, int cache) if (cache & FTextureManager::HIT_Columnmode) { const FTexture::Span *spanp; - /*if (r_swtruecolor) + if (r_swtruecolor) tex->GetColumnBgra(0, &spanp); - else*/ + else tex->GetColumn(0, &spanp); } else if (cache != 0) diff --git a/src/textures/automaptexture.cpp b/src/textures/automaptexture.cpp index 67d68b9fe..9aac379ef 100644 --- a/src/textures/automaptexture.cpp +++ b/src/textures/automaptexture.cpp @@ -122,6 +122,7 @@ void FAutomapTexture::Unload () delete[] Pixels; Pixels = NULL; } + FTexture::Unload(); } //========================================================================== diff --git a/src/textures/buildtexture.cpp b/src/textures/buildtexture.cpp index bfcc6333d..1155dacc4 100644 --- a/src/textures/buildtexture.cpp +++ b/src/textures/buildtexture.cpp @@ -56,7 +56,6 @@ public: const BYTE *GetColumn (unsigned int column, const Span **spans_out); const BYTE *GetPixels (); - void Unload (); protected: const BYTE *Pixels; @@ -103,17 +102,6 @@ FBuildTexture::~FBuildTexture () // //========================================================================== -void FBuildTexture::Unload () -{ - // Nothing to do, since the pixels are accessed from memory-mapped files directly -} - -//========================================================================== -// -// -// -//========================================================================== - const BYTE *FBuildTexture::GetPixels () { return Pixels; diff --git a/src/textures/canvastexture.cpp b/src/textures/canvastexture.cpp index a72546d78..109d927ab 100644 --- a/src/textures/canvastexture.cpp +++ b/src/textures/canvastexture.cpp @@ -183,6 +183,8 @@ void FCanvasTexture::Unload () CanvasBgra->Destroy(); CanvasBgra = NULL; } + + FTexture::Unload(); } bool FCanvasTexture::CheckModified () diff --git a/src/textures/ddstexture.cpp b/src/textures/ddstexture.cpp index 31e748022..fb4de34c5 100644 --- a/src/textures/ddstexture.cpp +++ b/src/textures/ddstexture.cpp @@ -401,6 +401,7 @@ void FDDSTexture::Unload () delete[] Pixels; Pixels = NULL; } + FTexture::Unload(); } //========================================================================== diff --git a/src/textures/flattexture.cpp b/src/textures/flattexture.cpp index 840d53aaf..08e0d1221 100644 --- a/src/textures/flattexture.cpp +++ b/src/textures/flattexture.cpp @@ -138,6 +138,7 @@ void FFlatTexture::Unload () delete[] Pixels; Pixels = NULL; } + FTexture::Unload(); } //========================================================================== diff --git a/src/textures/imgztexture.cpp b/src/textures/imgztexture.cpp index 1c262d707..04932d4bf 100644 --- a/src/textures/imgztexture.cpp +++ b/src/textures/imgztexture.cpp @@ -142,6 +142,7 @@ void FIMGZTexture::Unload () delete[] Pixels; Pixels = NULL; } + FTexture::Unload(); } //========================================================================== diff --git a/src/textures/jpegtexture.cpp b/src/textures/jpegtexture.cpp index a37eff6c3..3b5359846 100644 --- a/src/textures/jpegtexture.cpp +++ b/src/textures/jpegtexture.cpp @@ -196,7 +196,6 @@ public: protected: BYTE *Pixels; - std::vector PixelsBgra; Span DummySpans[2]; void MakeTexture (); @@ -300,7 +299,7 @@ void FJPEGTexture::Unload () { delete[] Pixels; Pixels = NULL; - PixelsBgra.clear(); + FTexture::Unload(); } //========================================================================== diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index b0db481a8..6ae45c785 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -362,6 +362,7 @@ void FMultiPatchTexture::Unload () delete[] Pixels; Pixels = NULL; } + FTexture::Unload(); } //========================================================================== diff --git a/src/textures/patchtexture.cpp b/src/textures/patchtexture.cpp index 423ce4deb..8388515c0 100644 --- a/src/textures/patchtexture.cpp +++ b/src/textures/patchtexture.cpp @@ -184,6 +184,7 @@ void FPatchTexture::Unload () delete[] Pixels; Pixels = NULL; } + FTexture::Unload(); } //========================================================================== diff --git a/src/textures/pcxtexture.cpp b/src/textures/pcxtexture.cpp index 0ec5d2933..42a13b85a 100644 --- a/src/textures/pcxtexture.cpp +++ b/src/textures/pcxtexture.cpp @@ -191,6 +191,7 @@ void FPCXTexture::Unload () delete[] Pixels; Pixels = NULL; } + FTexture::Unload(); } //========================================================================== diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index 95f7aca75..206797a34 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -67,7 +67,6 @@ protected: FString SourceFile; BYTE *Pixels; - std::vector PixelsBgra; Span **Spans; BYTE BitDepth; @@ -382,7 +381,7 @@ void FPNGTexture::Unload () { delete[] Pixels; Pixels = NULL; - PixelsBgra.clear(); + FTexture::Unload(); } //========================================================================== diff --git a/src/textures/rawpagetexture.cpp b/src/textures/rawpagetexture.cpp index 1402f8844..69313fd1c 100644 --- a/src/textures/rawpagetexture.cpp +++ b/src/textures/rawpagetexture.cpp @@ -206,6 +206,7 @@ void FRawPageTexture::Unload () delete[] Pixels; Pixels = NULL; } + FTexture::Unload(); } //========================================================================== diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 28a3b9333..0030719cb 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -176,6 +176,11 @@ FTexture::~FTexture () KillNative(); } +void FTexture::Unload() +{ + PixelsBgra = std::vector(); +} + const uint32_t *FTexture::GetColumnBgra(unsigned int column, const Span **spans_out) { const uint32_t *pixels = GetPixelsBgra(); @@ -189,16 +194,19 @@ const uint32_t *FTexture::GetColumnBgra(unsigned int column, const Span **spans_ const uint32_t *FTexture::GetPixelsBgra() { - if (BgraPixels.empty()) + if (PixelsBgra.empty()) { + GetColumn(0, nullptr); const BYTE *indices = GetPixels(); - BgraPixels.resize(Width * Height); + if (indices == nullptr) + return nullptr; + PixelsBgra.resize(Width * Height); for (int i = 0; i < Width * Height; i++) { - BgraPixels[i] = GPalette.BaseColors[indices[i]].d; + PixelsBgra[i] = GPalette.BaseColors[indices[i]].d; } } - return BgraPixels.data(); + return PixelsBgra.data(); } bool FTexture::CheckModified () @@ -642,10 +650,6 @@ FDummyTexture::FDummyTexture () UseType = TEX_Null; } -void FDummyTexture::Unload () -{ -} - void FDummyTexture::SetSize (int width, int height) { Width = width; diff --git a/src/textures/textures.h b/src/textures/textures.h index 872c83b1a..38d1ef487 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -192,7 +192,7 @@ public: virtual FTexture *GetRedirect(bool wantwarped); virtual FTexture *GetRawTexture(); // for FMultiPatchTexture to override - virtual void Unload () = 0; + virtual void Unload (); // Returns the native pixel format for this image virtual FTextureFormat GetFormat(); @@ -269,8 +269,7 @@ protected: Rotations = other->Rotations; } -private: - std::vector BgraPixels; + std::vector PixelsBgra; public: static void FlipSquareBlock (BYTE *block, int x, int y); @@ -472,7 +471,6 @@ public: FDummyTexture (); const BYTE *GetColumn (unsigned int column, const Span **spans_out); const BYTE *GetPixels (); - void Unload (); void SetSize (int width, int height); }; diff --git a/src/textures/tgatexture.cpp b/src/textures/tgatexture.cpp index b208a51a3..5e76a63b2 100644 --- a/src/textures/tgatexture.cpp +++ b/src/textures/tgatexture.cpp @@ -181,6 +181,7 @@ void FTGATexture::Unload () delete[] Pixels; Pixels = NULL; } + FTexture::Unload(); } //========================================================================== diff --git a/src/textures/warptexture.cpp b/src/textures/warptexture.cpp index a8a2ddb9e..b6977dd77 100644 --- a/src/textures/warptexture.cpp +++ b/src/textures/warptexture.cpp @@ -74,6 +74,7 @@ void FWarpTexture::Unload () Spans = NULL; } SourcePic->Unload (); + FTexture::Unload(); } bool FWarpTexture::CheckModified () diff --git a/src/v_draw.cpp b/src/v_draw.cpp index d03853c11..02ba591b6 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -1403,7 +1403,7 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, R_SetSpanColormap(colormap, clamp(shade >> FRACBITS, 0, NUMCOLORMAPS - 1)); else R_SetSpanColormap(&identitycolormap, 0); - R_SetSpanSource(tex->GetPixels()); + R_SetSpanSource(r_swtruecolor ? (const BYTE*)tex->GetPixelsBgra() : tex->GetPixels()); scalex = double(1u << (32 - ds_xbits)) / scalex; scaley = double(1u << (32 - ds_ybits)) / scaley; ds_xstep = xs_RoundToInt(cosrot * scalex); diff --git a/src/v_font.cpp b/src/v_font.cpp index 052074d11..ef9b69dd1 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -1662,6 +1662,7 @@ void FFontChar1::Unload () delete[] Pixels; Pixels = NULL; } + FTexture::Unload(); } //========================================================================== @@ -1723,6 +1724,7 @@ void FFontChar2::Unload () delete[] Pixels; Pixels = NULL; } + FTexture::Unload(); } //========================================================================== diff --git a/src/v_video.cpp b/src/v_video.cpp index e58638121..2cf04a29d 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -117,7 +117,6 @@ public: const BYTE *GetColumn(unsigned int column, const Span **spans_out); const BYTE *GetPixels(); - void Unload(); bool CheckModified(); void SetTranslation(int num); @@ -1076,16 +1075,6 @@ void FPaletteTester::SetTranslation(int num) } } -//========================================================================== -// -// FPaletteTester :: Unload -// -//========================================================================== - -void FPaletteTester::Unload() -{ -} - //========================================================================== // // FPaletteTester :: GetColumn From 69b2fa72e86b180351a70a95243c1b7484f8cec9 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 13 Jun 2016 23:10:54 +0200 Subject: [PATCH 0655/1509] Moved RGBA draw stuff to its own header file --- src/r_draw.cpp | 91 +++++++------- src/r_draw.h | 239 ------------------------------------- src/r_draw_rgba.cpp | 39 +++--- src/r_draw_rgba.h | 276 +++++++++++++++++++++++++++++++++++++++++++ src/r_drawt_rgba.cpp | 95 +++++++-------- src/r_main.cpp | 1 + src/r_swrenderer.cpp | 1 + src/r_things.cpp | 1 + 8 files changed, 393 insertions(+), 350 deletions(-) create mode 100644 src/r_draw_rgba.h diff --git a/src/r_draw.cpp b/src/r_draw.cpp index ec7313c4f..552e5ff13 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -39,6 +39,7 @@ #include "v_palette.h" #include "r_data/colormaps.h" #include "r_plane.h" +#include "r_draw_rgba.h" #include "gi.h" #include "stats.h" @@ -2295,34 +2296,34 @@ void R_InitColumnDrawers () domvline4_saved = domvline4; } - R_DrawColumnHoriz = R_DrawColumnHorizP_RGBA_C; - R_DrawColumn = R_DrawColumnP_RGBA_C; - R_DrawFuzzColumn = R_DrawFuzzColumnP_RGBA_C; - R_DrawTranslatedColumn = R_DrawTranslatedColumnP_RGBA_C; - R_DrawShadedColumn = R_DrawShadedColumnP_RGBA_C; - R_DrawSpanMasked = R_DrawSpanMaskedP_RGBA_C; - R_DrawSpan = R_DrawSpanP_RGBA_C; + R_DrawColumnHoriz = R_DrawColumnHorizP_RGBA; + R_DrawColumn = R_DrawColumnP_RGBA; + R_DrawFuzzColumn = R_DrawFuzzColumnP_RGBA; + R_DrawTranslatedColumn = R_DrawTranslatedColumnP_RGBA; + R_DrawShadedColumn = R_DrawShadedColumnP_RGBA; + R_DrawSpanMasked = R_DrawSpanMaskedP_RGBA; + R_DrawSpan = R_DrawSpanP_RGBA; - R_DrawSpanTranslucent = R_DrawSpanTranslucentP_RGBA_C; - R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucentP_RGBA_C; - R_DrawSpanAddClamp = R_DrawSpanAddClampP_RGBA_C; - R_DrawSpanMaskedAddClamp = R_DrawSpanMaskedAddClampP_RGBA_C; + R_DrawSpanTranslucent = R_DrawSpanTranslucentP_RGBA; + R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucentP_RGBA; + R_DrawSpanAddClamp = R_DrawSpanAddClampP_RGBA; + R_DrawSpanMaskedAddClamp = R_DrawSpanMaskedAddClampP_RGBA; R_FillColumn = R_FillColumnP_RGBA; - R_FillAddColumn = R_FillAddColumn_RGBA_C; + R_FillAddColumn = R_FillAddColumn_RGBA; R_FillAddClampColumn = R_FillAddClampColumn_RGBA; R_FillSubClampColumn = R_FillSubClampColumn_RGBA; R_FillRevSubClampColumn = R_FillRevSubClampColumn_RGBA; - R_DrawAddColumn = R_DrawAddColumnP_RGBA_C; - R_DrawTlatedAddColumn = R_DrawTlatedAddColumnP_RGBA_C; - R_DrawAddClampColumn = R_DrawAddClampColumnP_RGBA_C; - R_DrawAddClampTranslatedColumn = R_DrawAddClampTranslatedColumnP_RGBA_C; - R_DrawSubClampColumn = R_DrawSubClampColumnP_RGBA_C; - R_DrawSubClampTranslatedColumn = R_DrawSubClampTranslatedColumnP_RGBA_C; - R_DrawRevSubClampColumn = R_DrawRevSubClampColumnP_RGBA_C; - R_DrawRevSubClampTranslatedColumn = R_DrawRevSubClampTranslatedColumnP_RGBA_C; + R_DrawAddColumn = R_DrawAddColumnP_RGBA; + R_DrawTlatedAddColumn = R_DrawTlatedAddColumnP_RGBA; + R_DrawAddClampColumn = R_DrawAddClampColumnP_RGBA; + R_DrawAddClampTranslatedColumn = R_DrawAddClampTranslatedColumnP_RGBA; + R_DrawSubClampColumn = R_DrawSubClampColumnP_RGBA; + R_DrawSubClampTranslatedColumn = R_DrawSubClampTranslatedColumnP_RGBA; + R_DrawRevSubClampColumn = R_DrawRevSubClampColumnP_RGBA; + R_DrawRevSubClampTranslatedColumn = R_DrawRevSubClampTranslatedColumnP_RGBA; R_FillSpan = R_FillSpan_RGBA; R_DrawFogBoundary = R_DrawFogBoundary_RGBA; - R_FillColumnHoriz = R_FillColumnHorizP_RGBA_C; + R_FillColumnHoriz = R_FillColumnHorizP_RGBA; R_DrawFogBoundary = R_DrawFogBoundary_RGBA; R_MapTiltedPlane = R_MapTiltedPlane_RGBA; @@ -2338,30 +2339,30 @@ void R_InitColumnDrawers () tmvline1_revsubclamp = tmvline1_revsubclamp_RGBA; tmvline4_revsubclamp = tmvline4_revsubclamp_RGBA; - rt_copy1col = rt_copy1col_RGBA_c; - rt_copy4cols = rt_copy4cols_RGBA_c; - rt_map1col = rt_map1col_RGBA_c; - rt_map4cols = rt_map4cols_RGBA_c; - rt_shaded1col = rt_shaded1col_RGBA_c; - rt_shaded4cols = rt_shaded4cols_RGBA_c; - rt_add1col = rt_add1col_RGBA_c; - rt_add4cols = rt_add4cols_RGBA_c; - rt_addclamp1col = rt_addclamp1col_RGBA_c; - rt_addclamp4cols = rt_addclamp4cols_RGBA_c; - rt_subclamp1col = rt_subclamp1col_RGBA_c; - rt_revsubclamp1col = rt_revsubclamp1col_RGBA_c; - rt_tlate1col = rt_tlate1col_RGBA_c; - rt_tlateadd1col = rt_tlateadd1col_RGBA_c; - rt_tlateaddclamp1col = rt_tlateaddclamp1col_RGBA_c; - rt_tlatesubclamp1col = rt_tlatesubclamp1col_RGBA_c; - rt_tlaterevsubclamp1col = rt_tlaterevsubclamp1col_RGBA_c; - rt_subclamp4cols = rt_subclamp4cols_RGBA_c; - rt_revsubclamp4cols = rt_revsubclamp4cols_RGBA_c; - rt_tlate4cols = rt_tlate4cols_RGBA_c; - rt_tlateadd4cols = rt_tlateadd4cols_RGBA_c; - rt_tlateaddclamp4cols = rt_tlateaddclamp4cols_RGBA_c; - rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_RGBA_c; - rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_RGBA_c; + rt_copy1col = rt_copy1col_RGBA; + rt_copy4cols = rt_copy4cols_RGBA; + rt_map1col = rt_map1col_RGBA; + rt_map4cols = rt_map4cols_RGBA; + rt_shaded1col = rt_shaded1col_RGBA; + rt_shaded4cols = rt_shaded4cols_RGBA; + rt_add1col = rt_add1col_RGBA; + rt_add4cols = rt_add4cols_RGBA; + rt_addclamp1col = rt_addclamp1col_RGBA; + rt_addclamp4cols = rt_addclamp4cols_RGBA; + rt_subclamp1col = rt_subclamp1col_RGBA; + rt_revsubclamp1col = rt_revsubclamp1col_RGBA; + rt_tlate1col = rt_tlate1col_RGBA; + rt_tlateadd1col = rt_tlateadd1col_RGBA; + rt_tlateaddclamp1col = rt_tlateaddclamp1col_RGBA; + rt_tlatesubclamp1col = rt_tlatesubclamp1col_RGBA; + rt_tlaterevsubclamp1col = rt_tlaterevsubclamp1col_RGBA; + rt_subclamp4cols = rt_subclamp4cols_RGBA; + rt_revsubclamp4cols = rt_revsubclamp4cols_RGBA; + rt_tlate4cols = rt_tlate4cols_RGBA; + rt_tlateadd4cols = rt_tlateadd4cols_RGBA; + rt_tlateaddclamp4cols = rt_tlateaddclamp4cols_RGBA; + rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_RGBA; + rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_RGBA; rt_initcols = rt_initcols_rgba; rt_span_coverage = rt_span_coverage_rgba; diff --git a/src/r_draw.h b/src/r_draw.h index d09d0ab89..cea05e469 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -24,11 +24,6 @@ #define __R_DRAW__ #include "r_defs.h" -#include -#include -#include -#include -#include // Spectre/Invisibility. #define FUZZTABLE 50 @@ -175,39 +170,6 @@ void rt_map4cols_asm1 (int sx, int yl, int yh); void rt_map4cols_asm2 (int sx, int yl, int yh); void rt_add4cols_asm (int sx, int yl, int yh); void rt_addclamp4cols_asm (int sx, int yl, int yh); - -/// - -void rt_copy1col_RGBA_c (int hx, int sx, int yl, int yh); -void rt_copy4cols_RGBA_c (int sx, int yl, int yh); - -void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh); -void rt_shaded4cols_RGBA_c (int sx, int yl, int yh); - -void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh); -void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh); -void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh); -void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh); -void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh); - -void rt_tlate1col_RGBA_c (int hx, int sx, int yl, int yh); -void rt_tlateadd1col_RGBA_c (int hx, int sx, int yl, int yh); -void rt_tlateaddclamp1col_RGBA_c (int hx, int sx, int yl, int yh); -void rt_tlatesubclamp1col_RGBA_c (int hx, int sx, int yl, int yh); -void rt_tlaterevsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh); - -void rt_map4cols_RGBA_c (int sx, int yl, int yh); -void rt_add4cols_RGBA_c (int sx, int yl, int yh); -void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh); -void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh); -void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh); - -void rt_tlate4cols_RGBA_c (int sx, int yl, int yh); -void rt_tlateadd4cols_RGBA_c (int sx, int yl, int yh); -void rt_tlateaddclamp4cols_RGBA_c (int sx, int yl, int yh); -void rt_tlatesubclamp4cols_RGBA_c (int sx, int yl, int yh); -void rt_tlaterevsubclamp4cols_RGBA_c (int sx, int yl, int yh); - } extern void (*rt_copy1col)(int hx, int sx, int yl, int yh); @@ -247,10 +209,8 @@ void rt_draw4cols (int sx); // [RH] Preps the temporary horizontal buffer. void rt_initcols_pal (BYTE *buffer); -void rt_initcols_rgba (BYTE *buffer); void rt_span_coverage_pal(int x, int start, int stop); -void rt_span_coverage_rgba(int x, int start, int stop); extern void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); @@ -280,46 +240,6 @@ void R_DrawSpanMaskedP_C (void); #endif -void R_DrawColumnHorizP_RGBA_C (void); -void R_DrawColumnP_RGBA_C (void); -void R_DrawFuzzColumnP_RGBA_C (void); -void R_DrawTranslatedColumnP_RGBA_C (void); -void R_DrawShadedColumnP_RGBA_C (void); -void R_DrawSpanP_RGBA_C (void); -void R_DrawSpanMaskedP_RGBA_C (void); - -void R_DrawSpanTranslucentP_RGBA_C(); -void R_DrawSpanMaskedTranslucentP_RGBA_C(); -void R_DrawSpanAddClampP_RGBA_C(); -void R_DrawSpanMaskedAddClampP_RGBA_C(); -void R_FillColumnP_RGBA(); -void R_FillAddColumn_RGBA_C(); -void R_FillAddClampColumn_RGBA(); -void R_FillSubClampColumn_RGBA(); -void R_FillRevSubClampColumn_RGBA(); -void R_DrawAddColumnP_RGBA_C(); -void R_DrawTlatedAddColumnP_RGBA_C(); -void R_DrawAddClampColumnP_RGBA_C(); -void R_DrawAddClampTranslatedColumnP_RGBA_C(); -void R_DrawSubClampColumnP_RGBA_C(); -void R_DrawSubClampTranslatedColumnP_RGBA_C(); -void R_DrawRevSubClampColumnP_RGBA_C(); -void R_DrawRevSubClampTranslatedColumnP_RGBA_C(); -void R_FillSpan_RGBA(); -void R_DrawFogBoundary_RGBA(int x1, int x2, short *uclip, short *dclip); -fixed_t tmvline1_add_RGBA(); -void tmvline4_add_RGBA(); -fixed_t tmvline1_addclamp_RGBA(); -void tmvline4_addclamp_RGBA(); -fixed_t tmvline1_subclamp_RGBA(); -void tmvline4_subclamp_RGBA(); -fixed_t tmvline1_revsubclamp_RGBA(); -void tmvline4_revsubclamp_RGBA(); -DWORD vlinec1_RGBA(); -void vlinec4_RGBA(); -DWORD mvlinec1_RGBA(); -void mvlinec4_RGBA(); - void R_DrawSpanTranslucentP_C (void); void R_DrawSpanMaskedTranslucentP_C (void); @@ -348,9 +268,6 @@ void R_FillColumnP_C (void); void R_FillColumnHorizP_C (void); void R_FillSpan_C (void); -void R_FillColumnHorizP_RGBA_C(void); -void R_FillSpan_RGBA_C(void); - #ifdef X86_ASM #define R_SetupDrawSlab R_SetupDrawSlabA #define R_DrawSlab R_DrawSlabA @@ -443,160 +360,4 @@ void R_SetDSColorMapLight(FColormap *base_colormap, float light, int shade); void R_SetTranslationMap(lighttable_t *translation); -// Redirect drawer commands to worker threads -void R_BeginDrawerCommands(); - -// Wait until all drawers finished executing -void R_EndDrawerCommands(); - -class DrawerCommandQueue; - -class DrawerThread -{ -public: - std::thread thread; - - // Thread line index of this thread - int core = 0; - - // Number of active threads - int num_cores = 1; - - // Range of rows processed this pass - int pass_start_y = 0; - int pass_end_y = MAXHEIGHT; - - uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT * 4]; - uint32_t *dc_temp_rgba; - - // Checks if a line is rendered by this thread - bool line_skipped_by_thread(int line) - { - return line < pass_start_y || line >= pass_end_y || line % num_cores != core; - } - - // The number of lines to skip to reach the first line to be rendered by this thread - int skipped_by_thread(int first_line) - { - int pass_skip = MAX(pass_start_y - first_line, 0); - int core_skip = (num_cores - (first_line + pass_skip - core) % num_cores) % num_cores; - return pass_skip + core_skip; - } - - // The number of lines to be rendered by this thread - int count_for_thread(int first_line, int count) - { - int lines_until_pass_end = MAX(pass_end_y - first_line, 0); - count = MIN(count, lines_until_pass_end); - int c = (count - skipped_by_thread(first_line) + num_cores - 1) / num_cores; - return MAX(c, 0); - } - - // Calculate the dest address for the first line to be rendered by this thread - uint32_t *dest_for_thread(int first_line, int pitch, uint32_t *dest) - { - return dest + skipped_by_thread(first_line) * pitch; - } -}; - -class DrawerCommand -{ -protected: - int dc_dest_y; - -public: - DrawerCommand() - { - dc_dest_y = static_cast((dc_dest - dc_destorg) / (dc_pitch * 4)); - } - - virtual void Execute(DrawerThread *thread) = 0; -}; - -class DrawerCommandQueue -{ - enum { memorypool_size = 4 * 1024 * 1024 }; - char memorypool[memorypool_size]; - size_t memorypool_pos = 0; - - std::vector commands; - - std::vector threads; - - std::mutex start_mutex; - std::condition_variable start_condition; - std::vector active_commands; - bool shutdown_flag = false; - int run_id = 0; - - std::mutex end_mutex; - std::condition_variable end_condition; - size_t finished_threads = 0; - - int threaded_render = 0; - DrawerThread single_core_thread; - int num_passes = 2; - int rows_in_pass = 540; - - void StartThreads(); - void StopThreads(); - void Finish(); - - static DrawerCommandQueue *Instance(); - - ~DrawerCommandQueue(); - -public: - // Allocate memory valid for the duration of a command execution - static void* AllocMemory(size_t size); - - // Queue command to be executed by drawer worker threads - template - static void QueueCommand(Types &&... args) - { - auto queue = Instance(); - if (queue->threaded_render == 0) - { - T command(std::forward(args)...); - command.Execute(&queue->single_core_thread); - } - else - { - void *ptr = AllocMemory(sizeof(T)); - if (!ptr) - return; - T *command = new (ptr)T(std::forward(args)...); - queue->commands.push_back(command); - } - } - - // Redirects all drawing commands to worker threads until End is called - // Begin/End blocks can be nested. - static void Begin(); - - // End redirection and wait until all worker threads finished executing - static void End(); - - // Waits until all worker threads finished executing - static void WaitForWorkers(); -}; - -class ApplySpecialColormapRGBACommand : public DrawerCommand -{ - BYTE *buffer; - int pitch; - int width; - int height; - int start_red; - int start_green; - int start_blue; - int end_red; - int end_green; - int end_blue; - -public: - ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen); - void Execute(DrawerThread *thread) override; -}; - #endif diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 7e9f85117..a9dd2db32 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -37,6 +37,7 @@ #include "v_palette.h" #include "r_data/colormaps.h" #include "r_plane.h" +#include "r_draw_rgba.h" #include "gi.h" #include "stats.h" @@ -3655,7 +3656,7 @@ void R_EndDrawerCommands() DrawerCommandQueue::End(); } -void R_DrawColumnP_RGBA_C() +void R_DrawColumnP_RGBA() { DrawerCommandQueue::QueueCommand(); } @@ -3665,7 +3666,7 @@ void R_FillColumnP_RGBA() DrawerCommandQueue::QueueCommand(); } -void R_FillAddColumn_RGBA_C() +void R_FillAddColumn_RGBA() { DrawerCommandQueue::QueueCommand(); } @@ -3685,88 +3686,88 @@ void R_FillRevSubClampColumn_RGBA() DrawerCommandQueue::QueueCommand(); } -void R_DrawFuzzColumnP_RGBA_C() +void R_DrawFuzzColumnP_RGBA() { DrawerCommandQueue::QueueCommand(); fuzzpos = (fuzzpos + dc_yh - dc_yl) % FUZZTABLE; } -void R_DrawAddColumnP_RGBA_C() +void R_DrawAddColumnP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawTranslatedColumnP_RGBA_C() +void R_DrawTranslatedColumnP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawTlatedAddColumnP_RGBA_C() +void R_DrawTlatedAddColumnP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawShadedColumnP_RGBA_C() +void R_DrawShadedColumnP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawAddClampColumnP_RGBA_C() +void R_DrawAddClampColumnP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawAddClampTranslatedColumnP_RGBA_C() +void R_DrawAddClampTranslatedColumnP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSubClampColumnP_RGBA_C() +void R_DrawSubClampColumnP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSubClampTranslatedColumnP_RGBA_C() +void R_DrawSubClampTranslatedColumnP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawRevSubClampColumnP_RGBA_C() +void R_DrawRevSubClampColumnP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawRevSubClampTranslatedColumnP_RGBA_C() +void R_DrawRevSubClampTranslatedColumnP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSpanP_RGBA_C() +void R_DrawSpanP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSpanMaskedP_RGBA_C() +void R_DrawSpanMaskedP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSpanTranslucentP_RGBA_C() +void R_DrawSpanTranslucentP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSpanMaskedTranslucentP_RGBA_C() +void R_DrawSpanMaskedTranslucentP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSpanAddClampP_RGBA_C() +void R_DrawSpanAddClampP_RGBA() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSpanMaskedAddClampP_RGBA_C() +void R_DrawSpanMaskedAddClampP_RGBA() { DrawerCommandQueue::QueueCommand(); } diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h new file mode 100644 index 000000000..5d7402634 --- /dev/null +++ b/src/r_draw_rgba.h @@ -0,0 +1,276 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id:$ +// +// Copyright (C) 1993-1996 by id Software, Inc. +// +// This source is available for distribution and/or modification +// only under the terms of the DOOM Source Code License as +// published by id Software. All rights reserved. +// +// The source is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License +// for more details. +// +// DESCRIPTION: +// System specific interface stuff. +// +//----------------------------------------------------------------------------- + + +#ifndef __R_DRAW_RGBA__ +#define __R_DRAW_RGBA__ + +#include "r_draw.h" +#include +#include +#include +#include +#include + +///////////////////////////////////////////////////////////////////////////// +// Drawer functions: + +void rt_initcols_rgba(BYTE *buffer); +void rt_span_coverage_rgba(int x, int start, int stop); + +void rt_copy1col_RGBA(int hx, int sx, int yl, int yh); +void rt_copy4cols_RGBA(int sx, int yl, int yh); +void rt_shaded1col_RGBA(int hx, int sx, int yl, int yh); +void rt_shaded4cols_RGBA(int sx, int yl, int yh); +void rt_map1col_RGBA(int hx, int sx, int yl, int yh); +void rt_add1col_RGBA(int hx, int sx, int yl, int yh); +void rt_addclamp1col_RGBA(int hx, int sx, int yl, int yh); +void rt_subclamp1col_RGBA(int hx, int sx, int yl, int yh); +void rt_revsubclamp1col_RGBA(int hx, int sx, int yl, int yh); +void rt_tlate1col_RGBA(int hx, int sx, int yl, int yh); +void rt_tlateadd1col_RGBA(int hx, int sx, int yl, int yh); +void rt_tlateaddclamp1col_RGBA(int hx, int sx, int yl, int yh); +void rt_tlatesubclamp1col_RGBA(int hx, int sx, int yl, int yh); +void rt_tlaterevsubclamp1col_RGBA(int hx, int sx, int yl, int yh); +void rt_map4cols_RGBA(int sx, int yl, int yh); +void rt_add4cols_RGBA(int sx, int yl, int yh); +void rt_addclamp4cols_RGBA(int sx, int yl, int yh); +void rt_subclamp4cols_RGBA(int sx, int yl, int yh); +void rt_revsubclamp4cols_RGBA(int sx, int yl, int yh); +void rt_tlate4cols_RGBA(int sx, int yl, int yh); +void rt_tlateadd4cols_RGBA(int sx, int yl, int yh); +void rt_tlateaddclamp4cols_RGBA(int sx, int yl, int yh); +void rt_tlatesubclamp4cols_RGBA(int sx, int yl, int yh); +void rt_tlaterevsubclamp4cols_RGBA(int sx, int yl, int yh); + +void R_DrawColumnHorizP_RGBA(); +void R_DrawColumnP_RGBA(); +void R_DrawFuzzColumnP_RGBA(); +void R_DrawTranslatedColumnP_RGBA(); +void R_DrawShadedColumnP_RGBA(); + +void R_FillColumnP_RGBA(); +void R_FillAddColumn_RGBA(); +void R_FillAddClampColumn_RGBA(); +void R_FillSubClampColumn_RGBA(); +void R_FillRevSubClampColumn_RGBA(); +void R_DrawAddColumnP_RGBA(); +void R_DrawTlatedAddColumnP_RGBA(); +void R_DrawAddClampColumnP_RGBA(); +void R_DrawAddClampTranslatedColumnP_RGBA(); +void R_DrawSubClampColumnP_RGBA(); +void R_DrawSubClampTranslatedColumnP_RGBA(); +void R_DrawRevSubClampColumnP_RGBA(); +void R_DrawRevSubClampTranslatedColumnP_RGBA(); + +void R_DrawSpanP_RGBA(void); +void R_DrawSpanMaskedP_RGBA(void); +void R_DrawSpanTranslucentP_RGBA(); +void R_DrawSpanMaskedTranslucentP_RGBA(); +void R_DrawSpanAddClampP_RGBA(); +void R_DrawSpanMaskedAddClampP_RGBA(); +void R_FillSpan_RGBA(); + +void R_DrawFogBoundary_RGBA(int x1, int x2, short *uclip, short *dclip); + +DWORD vlinec1_RGBA(); +void vlinec4_RGBA(); +DWORD mvlinec1_RGBA(); +void mvlinec4_RGBA(); +fixed_t tmvline1_add_RGBA(); +void tmvline4_add_RGBA(); +fixed_t tmvline1_addclamp_RGBA(); +void tmvline4_addclamp_RGBA(); +fixed_t tmvline1_subclamp_RGBA(); +void tmvline4_subclamp_RGBA(); +fixed_t tmvline1_revsubclamp_RGBA(); +void tmvline4_revsubclamp_RGBA(); + +void R_FillColumnHorizP_RGBA(); +void R_FillSpan_RGBA(); + +///////////////////////////////////////////////////////////////////////////// +// Multithreaded rendering infrastructure: + +// Redirect drawer commands to worker threads +void R_BeginDrawerCommands(); + +// Wait until all drawers finished executing +void R_EndDrawerCommands(); + +struct FSpecialColormap; +class DrawerCommandQueue; + +// Worker data for each thread executing drawer commands +class DrawerThread +{ +public: + std::thread thread; + + // Thread line index of this thread + int core = 0; + + // Number of active threads + int num_cores = 1; + + // Range of rows processed this pass + int pass_start_y = 0; + int pass_end_y = MAXHEIGHT; + + uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT * 4]; + uint32_t *dc_temp_rgba; + + // Checks if a line is rendered by this thread + bool line_skipped_by_thread(int line) + { + return line < pass_start_y || line >= pass_end_y || line % num_cores != core; + } + + // The number of lines to skip to reach the first line to be rendered by this thread + int skipped_by_thread(int first_line) + { + int pass_skip = MAX(pass_start_y - first_line, 0); + int core_skip = (num_cores - (first_line + pass_skip - core) % num_cores) % num_cores; + return pass_skip + core_skip; + } + + // The number of lines to be rendered by this thread + int count_for_thread(int first_line, int count) + { + int lines_until_pass_end = MAX(pass_end_y - first_line, 0); + count = MIN(count, lines_until_pass_end); + int c = (count - skipped_by_thread(first_line) + num_cores - 1) / num_cores; + return MAX(c, 0); + } + + // Calculate the dest address for the first line to be rendered by this thread + uint32_t *dest_for_thread(int first_line, int pitch, uint32_t *dest) + { + return dest + skipped_by_thread(first_line) * pitch; + } +}; + +// Task to be executed by each worker thread +class DrawerCommand +{ +protected: + int dc_dest_y; + +public: + DrawerCommand() + { + dc_dest_y = static_cast((dc_dest - dc_destorg) / (dc_pitch * 4)); + } + + virtual void Execute(DrawerThread *thread) = 0; +}; + +// Manages queueing up commands and executing them on worker threads +class DrawerCommandQueue +{ + enum { memorypool_size = 4 * 1024 * 1024 }; + char memorypool[memorypool_size]; + size_t memorypool_pos = 0; + + std::vector commands; + + std::vector threads; + + std::mutex start_mutex; + std::condition_variable start_condition; + std::vector active_commands; + bool shutdown_flag = false; + int run_id = 0; + + std::mutex end_mutex; + std::condition_variable end_condition; + size_t finished_threads = 0; + + int threaded_render = 0; + DrawerThread single_core_thread; + int num_passes = 2; + int rows_in_pass = 540; + + void StartThreads(); + void StopThreads(); + void Finish(); + + static DrawerCommandQueue *Instance(); + + ~DrawerCommandQueue(); + +public: + // Allocate memory valid for the duration of a command execution + static void* AllocMemory(size_t size); + + // Queue command to be executed by drawer worker threads + template + static void QueueCommand(Types &&... args) + { + auto queue = Instance(); + if (queue->threaded_render == 0) + { + T command(std::forward(args)...); + command.Execute(&queue->single_core_thread); + } + else + { + void *ptr = AllocMemory(sizeof(T)); + if (!ptr) + return; + T *command = new (ptr)T(std::forward(args)...); + queue->commands.push_back(command); + } + } + + // Redirects all drawing commands to worker threads until End is called + // Begin/End blocks can be nested. + static void Begin(); + + // End redirection and wait until all worker threads finished executing + static void End(); + + // Waits until all worker threads finished executing + static void WaitForWorkers(); +}; + +///////////////////////////////////////////////////////////////////////////// +// Drawer commands: + +class ApplySpecialColormapRGBACommand : public DrawerCommand +{ + BYTE *buffer; + int pitch; + int width; + int height; + int start_red; + int start_green; + int start_blue; + int end_red; + int end_green; + int end_blue; + +public: + ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen); + void Execute(DrawerThread *thread) override; +}; + +#endif diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index cd124ac63..32d5080c5 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -42,6 +42,7 @@ #include "r_main.h" #include "r_things.h" #include "v_video.h" +#include "r_draw_rgba.h" #ifndef NO_SSE #include #endif @@ -1628,171 +1629,171 @@ public: ///////////////////////////////////////////////////////////////////////////// // Copies one span at hx to the screen at sx. -void rt_copy1col_RGBA_c (int hx, int sx, int yl, int yh) +void rt_copy1col_RGBA (int hx, int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Copies all four spans to the screen starting at sx. -void rt_copy4cols_RGBA_c (int sx, int yl, int yh) +void rt_copy4cols_RGBA (int sx, int yl, int yh) { // To do: we could do this with SSE using __m128i - rt_copy1col_RGBA_c(0, sx, yl, yh); - rt_copy1col_RGBA_c(1, sx + 1, yl, yh); - rt_copy1col_RGBA_c(2, sx + 2, yl, yh); - rt_copy1col_RGBA_c(3, sx + 3, yl, yh); + rt_copy1col_RGBA(0, sx, yl, yh); + rt_copy1col_RGBA(1, sx + 1, yl, yh); + rt_copy1col_RGBA(2, sx + 2, yl, yh); + rt_copy1col_RGBA(3, sx + 3, yl, yh); } // Maps one span at hx to the screen at sx. -void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh) +void rt_map1col_RGBA (int hx, int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Maps all four spans to the screen starting at sx. -void rt_map4cols_RGBA_c (int sx, int yl, int yh) +void rt_map4cols_RGBA (int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(sx, yl, yh); } -void rt_Translate1col_RGBA_c(const BYTE *translation, int hx, int yl, int yh) +void rt_Translate1col_RGBA(const BYTE *translation, int hx, int yl, int yh) { DrawerCommandQueue::QueueCommand(translation, hx, yl, yh); } -void rt_Translate4cols_RGBA_c(const BYTE *translation, int yl, int yh) +void rt_Translate4cols_RGBA(const BYTE *translation, int yl, int yh) { DrawerCommandQueue::QueueCommand(translation, yl, yh); } // Translates one span at hx to the screen at sx. -void rt_tlate1col_RGBA_c (int hx, int sx, int yl, int yh) +void rt_tlate1col_RGBA (int hx, int sx, int yl, int yh) { - rt_Translate1col_RGBA_c(dc_translation, hx, yl, yh); + rt_Translate1col_RGBA(dc_translation, hx, yl, yh); rt_map1col(hx, sx, yl, yh); } // Translates all four spans to the screen starting at sx. -void rt_tlate4cols_RGBA_c (int sx, int yl, int yh) +void rt_tlate4cols_RGBA (int sx, int yl, int yh) { - rt_Translate4cols_RGBA_c(dc_translation, yl, yh); + rt_Translate4cols_RGBA(dc_translation, yl, yh); rt_map4cols(sx, yl, yh); } // Adds one span at hx to the screen at sx without clamping. -void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh) +void rt_add1col_RGBA (int hx, int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Adds all four spans to the screen starting at sx without clamping. -void rt_add4cols_RGBA_c (int sx, int yl, int yh) +void rt_add4cols_RGBA (int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(sx, yl, yh); } // Translates and adds one span at hx to the screen at sx without clamping. -void rt_tlateadd1col_RGBA_c (int hx, int sx, int yl, int yh) +void rt_tlateadd1col_RGBA (int hx, int sx, int yl, int yh) { - rt_Translate1col_RGBA_c(dc_translation, hx, yl, yh); + rt_Translate1col_RGBA(dc_translation, hx, yl, yh); rt_add1col(hx, sx, yl, yh); } // Translates and adds all four spans to the screen starting at sx without clamping. -void rt_tlateadd4cols_RGBA_c(int sx, int yl, int yh) +void rt_tlateadd4cols_RGBA(int sx, int yl, int yh) { - rt_Translate4cols_RGBA_c(dc_translation, yl, yh); + rt_Translate4cols_RGBA(dc_translation, yl, yh); rt_add4cols(sx, yl, yh); } // Shades one span at hx to the screen at sx. -void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh) +void rt_shaded1col_RGBA (int hx, int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Shades all four spans to the screen starting at sx. -void rt_shaded4cols_RGBA_c (int sx, int yl, int yh) +void rt_shaded4cols_RGBA (int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(sx, yl, yh); } // Adds one span at hx to the screen at sx with clamping. -void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh) +void rt_addclamp1col_RGBA (int hx, int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Adds all four spans to the screen starting at sx with clamping. -void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh) +void rt_addclamp4cols_RGBA (int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(sx, yl, yh); } // Translates and adds one span at hx to the screen at sx with clamping. -void rt_tlateaddclamp1col_RGBA_c (int hx, int sx, int yl, int yh) +void rt_tlateaddclamp1col_RGBA (int hx, int sx, int yl, int yh) { - rt_Translate1col_RGBA_c(dc_translation, hx, yl, yh); - rt_addclamp1col_RGBA_c(hx, sx, yl, yh); + rt_Translate1col_RGBA(dc_translation, hx, yl, yh); + rt_addclamp1col_RGBA(hx, sx, yl, yh); } // Translates and adds all four spans to the screen starting at sx with clamping. -void rt_tlateaddclamp4cols_RGBA_c (int sx, int yl, int yh) +void rt_tlateaddclamp4cols_RGBA (int sx, int yl, int yh) { - rt_Translate4cols_RGBA_c(dc_translation, yl, yh); + rt_Translate4cols_RGBA(dc_translation, yl, yh); rt_addclamp4cols(sx, yl, yh); } // Subtracts one span at hx to the screen at sx with clamping. -void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh) +void rt_subclamp1col_RGBA (int hx, int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Subtracts all four spans to the screen starting at sx with clamping. -void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh) +void rt_subclamp4cols_RGBA (int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(sx, yl, yh); } // Translates and subtracts one span at hx to the screen at sx with clamping. -void rt_tlatesubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) +void rt_tlatesubclamp1col_RGBA (int hx, int sx, int yl, int yh) { - rt_Translate1col_RGBA_c(dc_translation, hx, yl, yh); - rt_subclamp1col_RGBA_c(hx, sx, yl, yh); + rt_Translate1col_RGBA(dc_translation, hx, yl, yh); + rt_subclamp1col_RGBA(hx, sx, yl, yh); } // Translates and subtracts all four spans to the screen starting at sx with clamping. -void rt_tlatesubclamp4cols_RGBA_c (int sx, int yl, int yh) +void rt_tlatesubclamp4cols_RGBA (int sx, int yl, int yh) { - rt_Translate4cols_RGBA_c(dc_translation, yl, yh); - rt_subclamp4cols_RGBA_c(sx, yl, yh); + rt_Translate4cols_RGBA(dc_translation, yl, yh); + rt_subclamp4cols_RGBA(sx, yl, yh); } // Subtracts one span at hx from the screen at sx with clamping. -void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) +void rt_revsubclamp1col_RGBA (int hx, int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Subtracts all four spans from the screen starting at sx with clamping. -void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh) +void rt_revsubclamp4cols_RGBA (int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(sx, yl, yh); } // Translates and subtracts one span at hx from the screen at sx with clamping. -void rt_tlaterevsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) +void rt_tlaterevsubclamp1col_RGBA (int hx, int sx, int yl, int yh) { - rt_Translate1col_RGBA_c(dc_translation, hx, yl, yh); - rt_revsubclamp1col_RGBA_c(hx, sx, yl, yh); + rt_Translate1col_RGBA(dc_translation, hx, yl, yh); + rt_revsubclamp1col_RGBA(hx, sx, yl, yh); } // Translates and subtracts all four spans from the screen starting at sx with clamping. -void rt_tlaterevsubclamp4cols_RGBA_c (int sx, int yl, int yh) +void rt_tlaterevsubclamp4cols_RGBA (int sx, int yl, int yh) { - rt_Translate4cols_RGBA_c(dc_translation, yl, yh); - rt_revsubclamp4cols_RGBA_c(sx, yl, yh); + rt_Translate4cols_RGBA(dc_translation, yl, yh); + rt_revsubclamp4cols_RGBA(sx, yl, yh); } // Before each pass through a rendering loop that uses these routines, @@ -1815,7 +1816,7 @@ void rt_span_coverage_rgba(int x, int start, int stop) // Stretches a column into a temporary buffer which is later // drawn to the screen along with up to three other columns. -void R_DrawColumnHorizP_RGBA_C (void) +void R_DrawColumnHorizP_RGBA (void) { if (dc_count <= 0) return; @@ -1830,7 +1831,7 @@ void R_DrawColumnHorizP_RGBA_C (void) } // [RH] Just fills a column with a given color -void R_FillColumnHorizP_RGBA_C (void) +void R_FillColumnHorizP_RGBA (void) { if (dc_count <= 0) return; diff --git a/src/r_main.cpp b/src/r_main.cpp index 4e5ff1dbd..247a98125 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -40,6 +40,7 @@ #include "r_segs.h" #include "r_3dfloors.h" #include "r_sky.h" +#include "r_draw_rgba.h" #include "st_stuff.h" #include "c_cvars.h" #include "c_dispatch.h" diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 5be41660e..fbbd65b17 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -42,6 +42,7 @@ #include "r_3dfloors.h" #include "textures/textures.h" #include "r_data/voxels.h" +#include "r_draw_rgba.h" EXTERN_CVAR(Bool, r_shadercolormaps) diff --git a/src/r_things.cpp b/src/r_things.cpp index 2dc0bdb6c..f1f29f160 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -58,6 +58,7 @@ #include "r_plane.h" #include "r_segs.h" #include "r_3dfloors.h" +#include "r_draw_rgba.h" #include "v_palette.h" #include "r_data/r_translate.h" #include "r_data/colormaps.h" From 586d5cdf1eb5609fcd480aa0d69fc764c4fc0103 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 13 Jun 2016 23:33:52 +0200 Subject: [PATCH 0656/1509] Normalize naming convention a little --- src/r_draw.cpp | 136 +++++++++++++++++++++---------------------- src/r_draw_rgba.cpp | 80 ++++++++++++------------- src/r_draw_rgba.h | 128 ++++++++++++++++++++-------------------- src/r_drawt_rgba.cpp | 94 +++++++++++++++--------------- src/r_plane.cpp | 4 +- src/r_plane.h | 4 +- src/r_things.cpp | 2 +- src/r_things.h | 2 +- 8 files changed, 225 insertions(+), 225 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 552e5ff13..ecb4441f8 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -2296,82 +2296,82 @@ void R_InitColumnDrawers () domvline4_saved = domvline4; } - R_DrawColumnHoriz = R_DrawColumnHorizP_RGBA; - R_DrawColumn = R_DrawColumnP_RGBA; - R_DrawFuzzColumn = R_DrawFuzzColumnP_RGBA; - R_DrawTranslatedColumn = R_DrawTranslatedColumnP_RGBA; - R_DrawShadedColumn = R_DrawShadedColumnP_RGBA; - R_DrawSpanMasked = R_DrawSpanMaskedP_RGBA; - R_DrawSpan = R_DrawSpanP_RGBA; + R_DrawColumnHoriz = R_DrawColumnHoriz_rgba; + R_DrawColumn = R_DrawColumn_rgba; + R_DrawFuzzColumn = R_DrawFuzzColumn_rgba; + R_DrawTranslatedColumn = R_DrawTranslatedColumn_rgba; + R_DrawShadedColumn = R_DrawShadedColumn_rgba; + R_DrawSpanMasked = R_DrawSpanMasked_rgba; + R_DrawSpan = R_DrawSpan_rgba; - R_DrawSpanTranslucent = R_DrawSpanTranslucentP_RGBA; - R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucentP_RGBA; - R_DrawSpanAddClamp = R_DrawSpanAddClampP_RGBA; - R_DrawSpanMaskedAddClamp = R_DrawSpanMaskedAddClampP_RGBA; - R_FillColumn = R_FillColumnP_RGBA; - R_FillAddColumn = R_FillAddColumn_RGBA; - R_FillAddClampColumn = R_FillAddClampColumn_RGBA; - R_FillSubClampColumn = R_FillSubClampColumn_RGBA; - R_FillRevSubClampColumn = R_FillRevSubClampColumn_RGBA; - R_DrawAddColumn = R_DrawAddColumnP_RGBA; - R_DrawTlatedAddColumn = R_DrawTlatedAddColumnP_RGBA; - R_DrawAddClampColumn = R_DrawAddClampColumnP_RGBA; - R_DrawAddClampTranslatedColumn = R_DrawAddClampTranslatedColumnP_RGBA; - R_DrawSubClampColumn = R_DrawSubClampColumnP_RGBA; - R_DrawSubClampTranslatedColumn = R_DrawSubClampTranslatedColumnP_RGBA; - R_DrawRevSubClampColumn = R_DrawRevSubClampColumnP_RGBA; - R_DrawRevSubClampTranslatedColumn = R_DrawRevSubClampTranslatedColumnP_RGBA; - R_FillSpan = R_FillSpan_RGBA; - R_DrawFogBoundary = R_DrawFogBoundary_RGBA; - R_FillColumnHoriz = R_FillColumnHorizP_RGBA; + R_DrawSpanTranslucent = R_DrawSpanTranslucent_rgba; + R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucent_rgba; + R_DrawSpanAddClamp = R_DrawSpanAddClamp_rgba; + R_DrawSpanMaskedAddClamp = R_DrawSpanMaskedAddClamp_rgba; + R_FillColumn = R_FillColumn_rgba; + R_FillAddColumn = R_FillAddColumn_rgba; + R_FillAddClampColumn = R_FillAddClampColumn_rgba; + R_FillSubClampColumn = R_FillSubClampColumn_rgba; + R_FillRevSubClampColumn = R_FillRevSubClampColumn_rgba; + R_DrawAddColumn = R_DrawAddColumn_rgba; + R_DrawTlatedAddColumn = R_DrawTlatedAddColumn_rgba; + R_DrawAddClampColumn = R_DrawAddClampColumn_rgba; + R_DrawAddClampTranslatedColumn = R_DrawAddClampTranslatedColumn_rgba; + R_DrawSubClampColumn = R_DrawSubClampColumn_rgba; + R_DrawSubClampTranslatedColumn = R_DrawSubClampTranslatedColumn_rgba; + R_DrawRevSubClampColumn = R_DrawRevSubClampColumn_rgba; + R_DrawRevSubClampTranslatedColumn = R_DrawRevSubClampTranslatedColumn_rgba; + R_FillSpan = R_FillSpan_rgba; + R_DrawFogBoundary = R_DrawFogBoundary_rgba; + R_FillColumnHoriz = R_FillColumnHoriz_rgba; - R_DrawFogBoundary = R_DrawFogBoundary_RGBA; - R_MapTiltedPlane = R_MapTiltedPlane_RGBA; - R_MapColoredPlane = R_MapColoredPlane_RGBA; - R_DrawParticle = R_DrawParticle_RGBA; + R_DrawFogBoundary = R_DrawFogBoundary_rgba; + R_MapTiltedPlane = R_MapTiltedPlane_rgba; + R_MapColoredPlane = R_MapColoredPlane_rgba; + R_DrawParticle = R_DrawParticle_rgba; - tmvline1_add = tmvline1_add_RGBA; - tmvline4_add = tmvline4_add_RGBA; - tmvline1_addclamp = tmvline1_addclamp_RGBA; - tmvline4_addclamp = tmvline4_addclamp_RGBA; - tmvline1_subclamp = tmvline1_subclamp_RGBA; - tmvline4_subclamp = tmvline4_subclamp_RGBA; - tmvline1_revsubclamp = tmvline1_revsubclamp_RGBA; - tmvline4_revsubclamp = tmvline4_revsubclamp_RGBA; + tmvline1_add = tmvline1_add_rgba; + tmvline4_add = tmvline4_add_rgba; + tmvline1_addclamp = tmvline1_addclamp_rgba; + tmvline4_addclamp = tmvline4_addclamp_rgba; + tmvline1_subclamp = tmvline1_subclamp_rgba; + tmvline4_subclamp = tmvline4_subclamp_rgba; + tmvline1_revsubclamp = tmvline1_revsubclamp_rgba; + tmvline4_revsubclamp = tmvline4_revsubclamp_rgba; - rt_copy1col = rt_copy1col_RGBA; - rt_copy4cols = rt_copy4cols_RGBA; - rt_map1col = rt_map1col_RGBA; - rt_map4cols = rt_map4cols_RGBA; - rt_shaded1col = rt_shaded1col_RGBA; - rt_shaded4cols = rt_shaded4cols_RGBA; - rt_add1col = rt_add1col_RGBA; - rt_add4cols = rt_add4cols_RGBA; - rt_addclamp1col = rt_addclamp1col_RGBA; - rt_addclamp4cols = rt_addclamp4cols_RGBA; - rt_subclamp1col = rt_subclamp1col_RGBA; - rt_revsubclamp1col = rt_revsubclamp1col_RGBA; - rt_tlate1col = rt_tlate1col_RGBA; - rt_tlateadd1col = rt_tlateadd1col_RGBA; - rt_tlateaddclamp1col = rt_tlateaddclamp1col_RGBA; - rt_tlatesubclamp1col = rt_tlatesubclamp1col_RGBA; - rt_tlaterevsubclamp1col = rt_tlaterevsubclamp1col_RGBA; - rt_subclamp4cols = rt_subclamp4cols_RGBA; - rt_revsubclamp4cols = rt_revsubclamp4cols_RGBA; - rt_tlate4cols = rt_tlate4cols_RGBA; - rt_tlateadd4cols = rt_tlateadd4cols_RGBA; - rt_tlateaddclamp4cols = rt_tlateaddclamp4cols_RGBA; - rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_RGBA; - rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_RGBA; + rt_copy1col = rt_copy1col_rgba; + rt_copy4cols = rt_copy4cols_rgba; + rt_map1col = rt_map1col_rgba; + rt_map4cols = rt_map4cols_rgba; + rt_shaded1col = rt_shaded1col_rgba; + rt_shaded4cols = rt_shaded4cols_rgba; + rt_add1col = rt_add1col_rgba; + rt_add4cols = rt_add4cols_rgba; + rt_addclamp1col = rt_addclamp1col_rgba; + rt_addclamp4cols = rt_addclamp4cols_rgba; + rt_subclamp1col = rt_subclamp1col_rgba; + rt_revsubclamp1col = rt_revsubclamp1col_rgba; + rt_tlate1col = rt_tlate1col_rgba; + rt_tlateadd1col = rt_tlateadd1col_rgba; + rt_tlateaddclamp1col = rt_tlateaddclamp1col_rgba; + rt_tlatesubclamp1col = rt_tlatesubclamp1col_rgba; + rt_tlaterevsubclamp1col = rt_tlaterevsubclamp1col_rgba; + rt_subclamp4cols = rt_subclamp4cols_rgba; + rt_revsubclamp4cols = rt_revsubclamp4cols_rgba; + rt_tlate4cols = rt_tlate4cols_rgba; + rt_tlateadd4cols = rt_tlateadd4cols_rgba; + rt_tlateaddclamp4cols = rt_tlateaddclamp4cols_rgba; + rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_rgba; + rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_rgba; rt_initcols = rt_initcols_rgba; rt_span_coverage = rt_span_coverage_rgba; - dovline1 = vlinec1_RGBA; - doprevline1 = vlinec1_RGBA; - domvline1 = mvlinec1_RGBA; + dovline1 = vlinec1_rgba; + doprevline1 = vlinec1_rgba; + domvline1 = mvlinec1_rgba; - dovline4 = vlinec4_RGBA; - domvline4 = mvlinec4_RGBA; + dovline4 = vlinec4_rgba; + domvline4 = mvlinec4_rgba; } else { diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index a9dd2db32..2062609b4 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -3656,130 +3656,130 @@ void R_EndDrawerCommands() DrawerCommandQueue::End(); } -void R_DrawColumnP_RGBA() +void R_DrawColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_FillColumnP_RGBA() +void R_FillColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_FillAddColumn_RGBA() +void R_FillAddColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_FillAddClampColumn_RGBA() +void R_FillAddClampColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_FillSubClampColumn_RGBA() +void R_FillSubClampColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_FillRevSubClampColumn_RGBA() +void R_FillRevSubClampColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawFuzzColumnP_RGBA() +void R_DrawFuzzColumn_rgba() { DrawerCommandQueue::QueueCommand(); fuzzpos = (fuzzpos + dc_yh - dc_yl) % FUZZTABLE; } -void R_DrawAddColumnP_RGBA() +void R_DrawAddColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawTranslatedColumnP_RGBA() +void R_DrawTranslatedColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawTlatedAddColumnP_RGBA() +void R_DrawTlatedAddColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawShadedColumnP_RGBA() +void R_DrawShadedColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawAddClampColumnP_RGBA() +void R_DrawAddClampColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawAddClampTranslatedColumnP_RGBA() +void R_DrawAddClampTranslatedColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSubClampColumnP_RGBA() +void R_DrawSubClampColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSubClampTranslatedColumnP_RGBA() +void R_DrawSubClampTranslatedColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawRevSubClampColumnP_RGBA() +void R_DrawRevSubClampColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawRevSubClampTranslatedColumnP_RGBA() +void R_DrawRevSubClampTranslatedColumn_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSpanP_RGBA() +void R_DrawSpan_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSpanMaskedP_RGBA() +void R_DrawSpanMasked_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSpanTranslucentP_RGBA() +void R_DrawSpanTranslucent_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSpanMaskedTranslucentP_RGBA() +void R_DrawSpanMaskedTranslucent_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSpanAddClampP_RGBA() +void R_DrawSpanAddClamp_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_DrawSpanMaskedAddClampP_RGBA() +void R_DrawSpanMaskedAddClamp_rgba() { DrawerCommandQueue::QueueCommand(); } -void R_FillSpan_RGBA() +void R_FillSpan_rgba() { DrawerCommandQueue::QueueCommand(); } //extern FTexture *rw_pic; // For the asserts below -DWORD vlinec1_RGBA() +DWORD vlinec1_rgba() { /*DWORD fracstep = dc_iscale; DWORD frac = dc_texturefrac; @@ -3792,79 +3792,79 @@ DWORD vlinec1_RGBA() return dc_texturefrac + dc_count * dc_iscale; } -void vlinec4_RGBA() +void vlinec4_rgba() { DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } -DWORD mvlinec1_RGBA() +DWORD mvlinec1_rgba() { DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } -void mvlinec4_RGBA() +void mvlinec4_rgba() { DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } -fixed_t tmvline1_add_RGBA() +fixed_t tmvline1_add_rgba() { DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } -void tmvline4_add_RGBA() +void tmvline4_add_rgba() { DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } -fixed_t tmvline1_addclamp_RGBA() +fixed_t tmvline1_addclamp_rgba() { DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } -void tmvline4_addclamp_RGBA() +void tmvline4_addclamp_rgba() { DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } -fixed_t tmvline1_subclamp_RGBA() +fixed_t tmvline1_subclamp_rgba() { DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } -void tmvline4_subclamp_RGBA() +void tmvline4_subclamp_rgba() { DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } -fixed_t tmvline1_revsubclamp_RGBA() +fixed_t tmvline1_revsubclamp_rgba() { DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } -void tmvline4_revsubclamp_RGBA() +void tmvline4_revsubclamp_rgba() { DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } -void R_DrawFogBoundarySection_RGBA(int y, int y2, int x1) +void R_DrawFogBoundarySection_rgba(int y, int y2, int x1) { for (; y < y2; ++y) { @@ -3873,7 +3873,7 @@ void R_DrawFogBoundarySection_RGBA(int y, int y2, int x1) } } -void R_DrawFogBoundary_RGBA(int x1, int x2, short *uclip, short *dclip) +void R_DrawFogBoundary_rgba(int x1, int x2, short *uclip, short *dclip) { // To do: we do not need to create new spans when using rgba output - instead we should calculate light on a per pixel basis @@ -3913,7 +3913,7 @@ void R_DrawFogBoundary_RGBA(int x1, int x2, short *uclip, short *dclip) if (t2 < b2 && rcolormap != 0) { // Colormap 0 is always the identity map, so rendering it is // just a waste of time. - R_DrawFogBoundarySection_RGBA(t2, b2, xr); + R_DrawFogBoundarySection_rgba(t2, b2, xr); } if (t1 < t2) t2 = t1; if (b1 > b2) b2 = b1; @@ -3965,6 +3965,6 @@ void R_DrawFogBoundary_RGBA(int x1, int x2, short *uclip, short *dclip) } if (t2 < b2 && rcolormap != 0) { - R_DrawFogBoundarySection_RGBA(t2, b2, x1); + R_DrawFogBoundarySection_rgba(t2, b2, x1); } } diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 5d7402634..9f07ff0bf 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -36,76 +36,76 @@ void rt_initcols_rgba(BYTE *buffer); void rt_span_coverage_rgba(int x, int start, int stop); -void rt_copy1col_RGBA(int hx, int sx, int yl, int yh); -void rt_copy4cols_RGBA(int sx, int yl, int yh); -void rt_shaded1col_RGBA(int hx, int sx, int yl, int yh); -void rt_shaded4cols_RGBA(int sx, int yl, int yh); -void rt_map1col_RGBA(int hx, int sx, int yl, int yh); -void rt_add1col_RGBA(int hx, int sx, int yl, int yh); -void rt_addclamp1col_RGBA(int hx, int sx, int yl, int yh); -void rt_subclamp1col_RGBA(int hx, int sx, int yl, int yh); -void rt_revsubclamp1col_RGBA(int hx, int sx, int yl, int yh); -void rt_tlate1col_RGBA(int hx, int sx, int yl, int yh); -void rt_tlateadd1col_RGBA(int hx, int sx, int yl, int yh); -void rt_tlateaddclamp1col_RGBA(int hx, int sx, int yl, int yh); -void rt_tlatesubclamp1col_RGBA(int hx, int sx, int yl, int yh); -void rt_tlaterevsubclamp1col_RGBA(int hx, int sx, int yl, int yh); -void rt_map4cols_RGBA(int sx, int yl, int yh); -void rt_add4cols_RGBA(int sx, int yl, int yh); -void rt_addclamp4cols_RGBA(int sx, int yl, int yh); -void rt_subclamp4cols_RGBA(int sx, int yl, int yh); -void rt_revsubclamp4cols_RGBA(int sx, int yl, int yh); -void rt_tlate4cols_RGBA(int sx, int yl, int yh); -void rt_tlateadd4cols_RGBA(int sx, int yl, int yh); -void rt_tlateaddclamp4cols_RGBA(int sx, int yl, int yh); -void rt_tlatesubclamp4cols_RGBA(int sx, int yl, int yh); -void rt_tlaterevsubclamp4cols_RGBA(int sx, int yl, int yh); +void rt_copy1col_rgba(int hx, int sx, int yl, int yh); +void rt_copy4cols_rgba(int sx, int yl, int yh); +void rt_shaded1col_rgba(int hx, int sx, int yl, int yh); +void rt_shaded4cols_rgba(int sx, int yl, int yh); +void rt_map1col_rgba(int hx, int sx, int yl, int yh); +void rt_add1col_rgba(int hx, int sx, int yl, int yh); +void rt_addclamp1col_rgba(int hx, int sx, int yl, int yh); +void rt_subclamp1col_rgba(int hx, int sx, int yl, int yh); +void rt_revsubclamp1col_rgba(int hx, int sx, int yl, int yh); +void rt_tlate1col_rgba(int hx, int sx, int yl, int yh); +void rt_tlateadd1col_rgba(int hx, int sx, int yl, int yh); +void rt_tlateaddclamp1col_rgba(int hx, int sx, int yl, int yh); +void rt_tlatesubclamp1col_rgba(int hx, int sx, int yl, int yh); +void rt_tlaterevsubclamp1col_rgba(int hx, int sx, int yl, int yh); +void rt_map4cols_rgba(int sx, int yl, int yh); +void rt_add4cols_rgba(int sx, int yl, int yh); +void rt_addclamp4cols_rgba(int sx, int yl, int yh); +void rt_subclamp4cols_rgba(int sx, int yl, int yh); +void rt_revsubclamp4cols_rgba(int sx, int yl, int yh); +void rt_tlate4cols_rgba(int sx, int yl, int yh); +void rt_tlateadd4cols_rgba(int sx, int yl, int yh); +void rt_tlateaddclamp4cols_rgba(int sx, int yl, int yh); +void rt_tlatesubclamp4cols_rgba(int sx, int yl, int yh); +void rt_tlaterevsubclamp4cols_rgba(int sx, int yl, int yh); -void R_DrawColumnHorizP_RGBA(); -void R_DrawColumnP_RGBA(); -void R_DrawFuzzColumnP_RGBA(); -void R_DrawTranslatedColumnP_RGBA(); -void R_DrawShadedColumnP_RGBA(); +void R_DrawColumnHoriz_rgba(); +void R_DrawColumn_rgba(); +void R_DrawFuzzColumn_rgba(); +void R_DrawTranslatedColumn_rgba(); +void R_DrawShadedColumn_rgba(); -void R_FillColumnP_RGBA(); -void R_FillAddColumn_RGBA(); -void R_FillAddClampColumn_RGBA(); -void R_FillSubClampColumn_RGBA(); -void R_FillRevSubClampColumn_RGBA(); -void R_DrawAddColumnP_RGBA(); -void R_DrawTlatedAddColumnP_RGBA(); -void R_DrawAddClampColumnP_RGBA(); -void R_DrawAddClampTranslatedColumnP_RGBA(); -void R_DrawSubClampColumnP_RGBA(); -void R_DrawSubClampTranslatedColumnP_RGBA(); -void R_DrawRevSubClampColumnP_RGBA(); -void R_DrawRevSubClampTranslatedColumnP_RGBA(); +void R_FillColumn_rgba(); +void R_FillAddColumn_rgba(); +void R_FillAddClampColumn_rgba(); +void R_FillSubClampColumn_rgba(); +void R_FillRevSubClampColumn_rgba(); +void R_DrawAddColumn_rgba(); +void R_DrawTlatedAddColumn_rgba(); +void R_DrawAddClampColumn_rgba(); +void R_DrawAddClampTranslatedColumn_rgba(); +void R_DrawSubClampColumn_rgba(); +void R_DrawSubClampTranslatedColumn_rgba(); +void R_DrawRevSubClampColumn_rgba(); +void R_DrawRevSubClampTranslatedColumn_rgba(); -void R_DrawSpanP_RGBA(void); -void R_DrawSpanMaskedP_RGBA(void); -void R_DrawSpanTranslucentP_RGBA(); -void R_DrawSpanMaskedTranslucentP_RGBA(); -void R_DrawSpanAddClampP_RGBA(); -void R_DrawSpanMaskedAddClampP_RGBA(); -void R_FillSpan_RGBA(); +void R_DrawSpan_rgba(void); +void R_DrawSpanMasked_rgba(void); +void R_DrawSpanTranslucent_rgba(); +void R_DrawSpanMaskedTranslucent_rgba(); +void R_DrawSpanAddClamp_rgba(); +void R_DrawSpanMaskedAddClamp_rgba(); +void R_FillSpan_rgba(); -void R_DrawFogBoundary_RGBA(int x1, int x2, short *uclip, short *dclip); +void R_DrawFogBoundary_rgba(int x1, int x2, short *uclip, short *dclip); -DWORD vlinec1_RGBA(); -void vlinec4_RGBA(); -DWORD mvlinec1_RGBA(); -void mvlinec4_RGBA(); -fixed_t tmvline1_add_RGBA(); -void tmvline4_add_RGBA(); -fixed_t tmvline1_addclamp_RGBA(); -void tmvline4_addclamp_RGBA(); -fixed_t tmvline1_subclamp_RGBA(); -void tmvline4_subclamp_RGBA(); -fixed_t tmvline1_revsubclamp_RGBA(); -void tmvline4_revsubclamp_RGBA(); +DWORD vlinec1_rgba(); +void vlinec4_rgba(); +DWORD mvlinec1_rgba(); +void mvlinec4_rgba(); +fixed_t tmvline1_add_rgba(); +void tmvline4_add_rgba(); +fixed_t tmvline1_addclamp_rgba(); +void tmvline4_addclamp_rgba(); +fixed_t tmvline1_subclamp_rgba(); +void tmvline4_subclamp_rgba(); +fixed_t tmvline1_revsubclamp_rgba(); +void tmvline4_revsubclamp_rgba(); -void R_FillColumnHorizP_RGBA(); -void R_FillSpan_RGBA(); +void R_FillColumnHoriz_rgba(); +void R_FillSpan_rgba(); ///////////////////////////////////////////////////////////////////////////// // Multithreaded rendering infrastructure: diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 32d5080c5..8f6d2ca13 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -1629,171 +1629,171 @@ public: ///////////////////////////////////////////////////////////////////////////// // Copies one span at hx to the screen at sx. -void rt_copy1col_RGBA (int hx, int sx, int yl, int yh) +void rt_copy1col_rgba (int hx, int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Copies all four spans to the screen starting at sx. -void rt_copy4cols_RGBA (int sx, int yl, int yh) +void rt_copy4cols_rgba (int sx, int yl, int yh) { // To do: we could do this with SSE using __m128i - rt_copy1col_RGBA(0, sx, yl, yh); - rt_copy1col_RGBA(1, sx + 1, yl, yh); - rt_copy1col_RGBA(2, sx + 2, yl, yh); - rt_copy1col_RGBA(3, sx + 3, yl, yh); + rt_copy1col_rgba(0, sx, yl, yh); + rt_copy1col_rgba(1, sx + 1, yl, yh); + rt_copy1col_rgba(2, sx + 2, yl, yh); + rt_copy1col_rgba(3, sx + 3, yl, yh); } // Maps one span at hx to the screen at sx. -void rt_map1col_RGBA (int hx, int sx, int yl, int yh) +void rt_map1col_rgba (int hx, int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Maps all four spans to the screen starting at sx. -void rt_map4cols_RGBA (int sx, int yl, int yh) +void rt_map4cols_rgba (int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(sx, yl, yh); } -void rt_Translate1col_RGBA(const BYTE *translation, int hx, int yl, int yh) +void rt_Translate1col_rgba(const BYTE *translation, int hx, int yl, int yh) { DrawerCommandQueue::QueueCommand(translation, hx, yl, yh); } -void rt_Translate4cols_RGBA(const BYTE *translation, int yl, int yh) +void rt_Translate4cols_rgba(const BYTE *translation, int yl, int yh) { DrawerCommandQueue::QueueCommand(translation, yl, yh); } // Translates one span at hx to the screen at sx. -void rt_tlate1col_RGBA (int hx, int sx, int yl, int yh) +void rt_tlate1col_rgba (int hx, int sx, int yl, int yh) { - rt_Translate1col_RGBA(dc_translation, hx, yl, yh); + rt_Translate1col_rgba(dc_translation, hx, yl, yh); rt_map1col(hx, sx, yl, yh); } // Translates all four spans to the screen starting at sx. -void rt_tlate4cols_RGBA (int sx, int yl, int yh) +void rt_tlate4cols_rgba (int sx, int yl, int yh) { - rt_Translate4cols_RGBA(dc_translation, yl, yh); + rt_Translate4cols_rgba(dc_translation, yl, yh); rt_map4cols(sx, yl, yh); } // Adds one span at hx to the screen at sx without clamping. -void rt_add1col_RGBA (int hx, int sx, int yl, int yh) +void rt_add1col_rgba (int hx, int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Adds all four spans to the screen starting at sx without clamping. -void rt_add4cols_RGBA (int sx, int yl, int yh) +void rt_add4cols_rgba (int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(sx, yl, yh); } // Translates and adds one span at hx to the screen at sx without clamping. -void rt_tlateadd1col_RGBA (int hx, int sx, int yl, int yh) +void rt_tlateadd1col_rgba (int hx, int sx, int yl, int yh) { - rt_Translate1col_RGBA(dc_translation, hx, yl, yh); + rt_Translate1col_rgba(dc_translation, hx, yl, yh); rt_add1col(hx, sx, yl, yh); } // Translates and adds all four spans to the screen starting at sx without clamping. -void rt_tlateadd4cols_RGBA(int sx, int yl, int yh) +void rt_tlateadd4cols_rgba(int sx, int yl, int yh) { - rt_Translate4cols_RGBA(dc_translation, yl, yh); + rt_Translate4cols_rgba(dc_translation, yl, yh); rt_add4cols(sx, yl, yh); } // Shades one span at hx to the screen at sx. -void rt_shaded1col_RGBA (int hx, int sx, int yl, int yh) +void rt_shaded1col_rgba (int hx, int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Shades all four spans to the screen starting at sx. -void rt_shaded4cols_RGBA (int sx, int yl, int yh) +void rt_shaded4cols_rgba (int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(sx, yl, yh); } // Adds one span at hx to the screen at sx with clamping. -void rt_addclamp1col_RGBA (int hx, int sx, int yl, int yh) +void rt_addclamp1col_rgba (int hx, int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Adds all four spans to the screen starting at sx with clamping. -void rt_addclamp4cols_RGBA (int sx, int yl, int yh) +void rt_addclamp4cols_rgba (int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(sx, yl, yh); } // Translates and adds one span at hx to the screen at sx with clamping. -void rt_tlateaddclamp1col_RGBA (int hx, int sx, int yl, int yh) +void rt_tlateaddclamp1col_rgba (int hx, int sx, int yl, int yh) { - rt_Translate1col_RGBA(dc_translation, hx, yl, yh); - rt_addclamp1col_RGBA(hx, sx, yl, yh); + rt_Translate1col_rgba(dc_translation, hx, yl, yh); + rt_addclamp1col_rgba(hx, sx, yl, yh); } // Translates and adds all four spans to the screen starting at sx with clamping. -void rt_tlateaddclamp4cols_RGBA (int sx, int yl, int yh) +void rt_tlateaddclamp4cols_rgba (int sx, int yl, int yh) { - rt_Translate4cols_RGBA(dc_translation, yl, yh); + rt_Translate4cols_rgba(dc_translation, yl, yh); rt_addclamp4cols(sx, yl, yh); } // Subtracts one span at hx to the screen at sx with clamping. -void rt_subclamp1col_RGBA (int hx, int sx, int yl, int yh) +void rt_subclamp1col_rgba (int hx, int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Subtracts all four spans to the screen starting at sx with clamping. -void rt_subclamp4cols_RGBA (int sx, int yl, int yh) +void rt_subclamp4cols_rgba (int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(sx, yl, yh); } // Translates and subtracts one span at hx to the screen at sx with clamping. -void rt_tlatesubclamp1col_RGBA (int hx, int sx, int yl, int yh) +void rt_tlatesubclamp1col_rgba (int hx, int sx, int yl, int yh) { - rt_Translate1col_RGBA(dc_translation, hx, yl, yh); - rt_subclamp1col_RGBA(hx, sx, yl, yh); + rt_Translate1col_rgba(dc_translation, hx, yl, yh); + rt_subclamp1col_rgba(hx, sx, yl, yh); } // Translates and subtracts all four spans to the screen starting at sx with clamping. -void rt_tlatesubclamp4cols_RGBA (int sx, int yl, int yh) +void rt_tlatesubclamp4cols_rgba (int sx, int yl, int yh) { - rt_Translate4cols_RGBA(dc_translation, yl, yh); - rt_subclamp4cols_RGBA(sx, yl, yh); + rt_Translate4cols_rgba(dc_translation, yl, yh); + rt_subclamp4cols_rgba(sx, yl, yh); } // Subtracts one span at hx from the screen at sx with clamping. -void rt_revsubclamp1col_RGBA (int hx, int sx, int yl, int yh) +void rt_revsubclamp1col_rgba (int hx, int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Subtracts all four spans from the screen starting at sx with clamping. -void rt_revsubclamp4cols_RGBA (int sx, int yl, int yh) +void rt_revsubclamp4cols_rgba (int sx, int yl, int yh) { DrawerCommandQueue::QueueCommand(sx, yl, yh); } // Translates and subtracts one span at hx from the screen at sx with clamping. -void rt_tlaterevsubclamp1col_RGBA (int hx, int sx, int yl, int yh) +void rt_tlaterevsubclamp1col_rgba (int hx, int sx, int yl, int yh) { - rt_Translate1col_RGBA(dc_translation, hx, yl, yh); - rt_revsubclamp1col_RGBA(hx, sx, yl, yh); + rt_Translate1col_rgba(dc_translation, hx, yl, yh); + rt_revsubclamp1col_rgba(hx, sx, yl, yh); } // Translates and subtracts all four spans from the screen starting at sx with clamping. -void rt_tlaterevsubclamp4cols_RGBA (int sx, int yl, int yh) +void rt_tlaterevsubclamp4cols_rgba (int sx, int yl, int yh) { - rt_Translate4cols_RGBA(dc_translation, yl, yh); - rt_revsubclamp4cols_RGBA(sx, yl, yh); + rt_Translate4cols_rgba(dc_translation, yl, yh); + rt_revsubclamp4cols_rgba(sx, yl, yh); } // Before each pass through a rendering loop that uses these routines, @@ -1816,7 +1816,7 @@ void rt_span_coverage_rgba(int x, int start, int stop) // Stretches a column into a temporary buffer which is later // drawn to the screen along with up to three other columns. -void R_DrawColumnHorizP_RGBA (void) +void R_DrawColumnHoriz_rgba (void) { if (dc_count <= 0) return; @@ -1831,7 +1831,7 @@ void R_DrawColumnHorizP_RGBA (void) } // [RH] Just fills a column with a given color -void R_FillColumnHorizP_RGBA (void) +void R_FillColumnHoriz_rgba (void) { if (dc_count <= 0) return; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 1cde16071..1a08d1793 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -477,7 +477,7 @@ void R_MapTiltedPlane_C (int y, int x1) #endif } -void R_MapTiltedPlane_RGBA (int y, int x1) +void R_MapTiltedPlane_rgba (int y, int x1) { int x2 = spanend[y]; @@ -509,7 +509,7 @@ void R_MapColoredPlane_C (int y, int x1) memset (ylookup[y] + x1 + dc_destorg, ds_color, (spanend[y] - x1 + 1)); } -void R_MapColoredPlane_RGBA(int y, int x1) +void R_MapColoredPlane_rgba(int y, int x1) { uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg; int count = (spanend[y] - x1 + 1); diff --git a/src/r_plane.h b/src/r_plane.h index 7505ac995..b199d3477 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -97,9 +97,9 @@ extern void(*R_MapColoredPlane)(int y, int x1); extern void(*R_MapTiltedPlane)(int y, int x1); void R_MapTiltedPlane_C(int y, int x1); -void R_MapTiltedPlane_RGBA(int y, int x); +void R_MapTiltedPlane_rgba(int y, int x); void R_MapColoredPlane_C(int y, int x1); -void R_MapColoredPlane_RGBA(int y, int x1); +void R_MapColoredPlane_rgba(int y, int x1); visplane_t *R_FindPlane ( const secplane_t &height, diff --git a/src/r_things.cpp b/src/r_things.cpp index f1f29f160..0858dce2f 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2676,7 +2676,7 @@ void R_DrawParticle_C (vissprite_t *vis) } } -void R_DrawParticle_RGBA(vissprite_t *vis) +void R_DrawParticle_rgba(vissprite_t *vis) { int spacing; uint32_t *dest; diff --git a/src/r_things.h b/src/r_things.h index 785729b09..f5cd30e00 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -98,7 +98,7 @@ struct particle_t; extern void(*R_DrawParticle)(vissprite_t *); void R_DrawParticle_C (vissprite_t *); -void R_DrawParticle_RGBA (vissprite_t *); +void R_DrawParticle_rgba (vissprite_t *); void R_ProjectParticle (particle_t *, const sector_t *sector, int shade, int fakeside); From 9c8c1e0ea51534d8c6d5fba8ed0c58a965aa88e8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 14 Jun 2016 00:27:08 +0200 Subject: [PATCH 0657/1509] Fixed window transparency bug --- src/r_drawt_rgba.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 8f6d2ca13..d2d715c8d 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -588,6 +588,8 @@ class RtAdd4colsRGBACommand : public DrawerCommand fixed_t dc_light; ShadeConstants dc_shade_constants; BYTE *dc_colormap; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; public: RtAdd4colsRGBACommand(int sx, int yl, int yh) @@ -601,6 +603,8 @@ public: dc_light = ::dc_light; dc_shade_constants = ::dc_shade_constants; dc_colormap = ::dc_colormap; + dc_srcalpha = ::dc_srcalpha; + dc_destalpha = ::dc_destalpha; } #ifdef NO_SSE @@ -722,10 +726,10 @@ public: __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; // shade_pal_index: __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); From 77c4786b9d716ab018ec4b082490b6ed78f5cc36 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 14 Jun 2016 23:05:20 +0200 Subject: [PATCH 0658/1509] Minor code cleanup --- src/f_wipe.cpp | 5 +- src/r_draw.cpp | 57 +++-------- src/r_draw.h | 19 +++- src/r_draw_rgba.h | 213 +++++++++++++++++++++++++++++++++++++++++ src/r_drawt.cpp | 32 +++---- src/r_main.h | 223 ------------------------------------------- src/r_plane.cpp | 28 +++--- src/r_swrenderer.cpp | 2 +- src/r_things.cpp | 5 +- src/v_draw.cpp | 1 + 10 files changed, 277 insertions(+), 308 deletions(-) diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index 84b6036e4..aa9038eeb 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -78,7 +78,7 @@ bool wipe_initMelt (int ticks) int i, r; // copy start screen to main screen - screen->DrawBlock(0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start); + screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start); // makes this wipe faster (in theory) // to have stuff in column-major format @@ -271,8 +271,7 @@ bool wipe_doBurn (int ticks) // Draw the screen int xstep, ystep, firex, firey; int x, y; - BYTE *to; - BYTE *fromold, *fromnew; + BYTE *to, *fromold, *fromnew; const int SHIFT = 16; xstep = (FIREWIDTH << SHIFT) / SCREENWIDTH; diff --git a/src/r_draw.cpp b/src/r_draw.cpp index ecb4441f8..4dcdc3e6b 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -63,7 +63,7 @@ extern int ST_Y; BYTE* viewimage; extern "C" { int ylookup[MAXHEIGHT]; -BYTE* dc_destorg; +BYTE *dc_destorg; } int scaledviewwidth; @@ -276,7 +276,7 @@ void R_DrawColumnP_C (void) { // Re-map color indices from wall texture column // using a lighting/special effects LUT. - *dest = colormap[source[frac >> FRACBITS]]; + *dest = colormap[source[frac>>FRACBITS]]; dest += pitch; frac += fracstep; @@ -321,13 +321,12 @@ void R_FillAddColumn_C (void) return; dest = dc_dest; - int pitch = dc_pitch; - DWORD *bg2rgb; DWORD fg; bg2rgb = dc_destblend; fg = dc_srccolor; + int pitch = dc_pitch; do { @@ -348,13 +347,12 @@ void R_FillAddClampColumn_C (void) return; dest = dc_dest; - int pitch = dc_pitch; - DWORD *bg2rgb; DWORD fg; bg2rgb = dc_destblend; fg = dc_srccolor; + int pitch = dc_pitch; do { @@ -381,13 +379,12 @@ void R_FillSubClampColumn_C (void) return; dest = dc_dest; - int pitch = dc_pitch; - DWORD *bg2rgb; DWORD fg; bg2rgb = dc_destblend; fg = dc_srccolor | 0x40100400; + int pitch = dc_pitch; do { @@ -413,13 +410,12 @@ void R_FillRevSubClampColumn_C (void) return; dest = dc_dest; - int pitch = dc_pitch; - DWORD *bg2rgb; DWORD fg; bg2rgb = dc_destblend; fg = dc_srccolor; + int pitch = dc_pitch; do { @@ -672,13 +668,14 @@ void R_DrawTranslatedColumnP_C (void) { *dest = colormap[translation[source[frac>>FRACBITS]]]; dest += pitch; + frac += fracstep; } while (--count); } } // Draw a column that is both translated and translucent -void R_DrawTlatedAddColumnP_C() +void R_DrawTlatedAddColumnP_C (void) { int count; BYTE *dest; @@ -772,15 +769,15 @@ void R_DrawAddClampColumnP_C () frac = dc_texturefrac; { - const BYTE *source = dc_source; BYTE *colormap = dc_colormap; + const BYTE *source = dc_source; int pitch = dc_pitch; DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; do { - DWORD a = fg2rgb[colormap[source[frac >> FRACBITS]]] + bg2rgb[*dest]; + DWORD a = fg2rgb[colormap[source[frac>>FRACBITS]]] + bg2rgb[*dest]; DWORD b = a; a |= 0x01f07c1f; @@ -788,7 +785,7 @@ void R_DrawAddClampColumnP_C () a &= 0x3fffffff; b = b - (b >> 5); a |= b; - *dest = RGB32k.All[a & (a >> 15)]; + *dest = RGB32k.All[a & (a>>15)]; dest += pitch; frac += fracstep; } while (--count); @@ -1190,9 +1187,6 @@ void R_DrawSpanP_C (void) } while (--count); } } -#endif - -#ifndef X86_ASM // [RH] Draw a span with holes void R_DrawSpanMaskedP_C (void) @@ -1282,8 +1276,6 @@ void R_DrawSpanTranslucentP_C (void) xstep = ds_xstep; ystep = ds_ystep; - uint32_t light = calc_light_multiplier(ds_light); - if (ds_xbits == 6 && ds_ybits == 6) { // 64x64 is the most common case by far, so special case it. @@ -1334,8 +1326,6 @@ void R_DrawSpanMaskedTranslucentP_C (void) DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; - uint32_t light = calc_light_multiplier(ds_light); - xfrac = ds_xfrac; yfrac = ds_yfrac; @@ -1426,7 +1416,6 @@ void R_DrawSpanAddClampP_C (void) do { spot = ((xfrac>>(32-6-6))&(63*64)) + (yfrac>>(32-6)); - DWORD a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; DWORD b = a; @@ -1436,7 +1425,6 @@ void R_DrawSpanAddClampP_C (void) b = b - (b >> 5); a |= b; *dest++ = RGB32k.All[a & (a>>15)]; - xfrac += xstep; yfrac += ystep; } while (--count); @@ -1449,7 +1437,6 @@ void R_DrawSpanAddClampP_C (void) do { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - DWORD a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; DWORD b = a; @@ -1459,14 +1446,12 @@ void R_DrawSpanAddClampP_C (void) b = b - (b >> 5); a |= b; *dest++ = RGB32k.All[a & (a>>15)]; - xfrac += xstep; yfrac += ystep; } while (--count); } } - void R_DrawSpanMaskedAddClampP_C (void) { dsfixed_t xfrac; @@ -1481,8 +1466,6 @@ void R_DrawSpanMaskedAddClampP_C (void) DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; - uint32_t light = calc_light_multiplier(ds_light); - xfrac = ds_xfrac; yfrac = ds_yfrac; @@ -1552,7 +1535,7 @@ void R_DrawSpanMaskedAddClampP_C (void) // [RH] Just fill a span with a color void R_FillSpan_C (void) { - memset (ylookup[ds_y] + ds_x1 + dc_destorg, ds_color, (ds_x2 - ds_x1 + 1)); + memset (ylookup[ds_y] + ds_x1 + dc_destorg, ds_color, ds_x2 - ds_x1 + 1); } @@ -1759,7 +1742,7 @@ DWORD vlinec1 () do { - *dest = colormap[source[frac >> bits]]; + *dest = colormap[source[frac>>bits]]; frac += fracstep; dest += pitch; } while (--count); @@ -1830,9 +1813,7 @@ DWORD mvlinec1 () return frac; } -#endif -#if !defined(X86_ASM) void mvlinec4 () { BYTE *dest = dc_dest; @@ -1843,6 +1824,7 @@ void mvlinec4 () do { BYTE pix; + pix = bufplce[0][(place=vplce[0])>>bits]; if(pix) dest[0] = palookupoffse[0][pix]; vplce[0] = place+vince[0]; pix = bufplce[1][(place=vplce[1])>>bits]; if(pix) dest[1] = palookupoffse[1][pix]; vplce[1] = place+vince[1]; pix = bufplce[2][(place=vplce[2])>>bits]; if(pix) dest[2] = palookupoffse[2][pix]; vplce[2] = place+vince[2]; @@ -1879,7 +1861,6 @@ static void R_DrawFogBoundaryLine (int y, int x) int x2 = spanend[y]; BYTE *colormap = dc_colormap; BYTE *dest = ylookup[y] + dc_destorg; - do { dest[x] = colormap[dest[x]]; @@ -1996,8 +1977,6 @@ fixed_t tmvline1_add_C () DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; - uint32_t light = calc_light_multiplier(dc_light); - do { BYTE pix = source[frac>>bits]; @@ -2024,12 +2003,6 @@ void tmvline4_add_C () DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; - uint32_t light[4]; - light[0] = calc_light_multiplier(palookuplight[0]); - light[1] = calc_light_multiplier(palookuplight[1]); - light[2] = calc_light_multiplier(palookuplight[2]); - light[3] = calc_light_multiplier(palookuplight[3]); - do { for (int i = 0; i < 4; ++i) @@ -2062,8 +2035,6 @@ fixed_t tmvline1_addclamp_C () DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; - uint32_t light = calc_light_multiplier(dc_light); - do { BYTE pix = source[frac>>bits]; diff --git a/src/r_draw.h b/src/r_draw.h index cea05e469..a31183405 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -32,7 +32,20 @@ extern "C" int fuzzpos; extern "C" int fuzzviewheight; struct FColormap; -struct ShadeConstants; + +struct ShadeConstants +{ + uint16_t light_alpha; + uint16_t light_red; + uint16_t light_green; + uint16_t light_blue; + uint16_t fade_alpha; + uint16_t fade_red; + uint16_t fade_green; + uint16_t fade_blue; + uint16_t desaturate; + bool simple_shade; +}; extern "C" int ylookup[MAXHEIGHT]; @@ -58,7 +71,7 @@ extern "C" fixed_t dc_destalpha; // first pixel in a column extern "C" const BYTE* dc_source; -extern "C" BYTE* dc_dest, *dc_destorg; +extern "C" BYTE *dc_dest, *dc_destorg; extern "C" int dc_count; extern "C" DWORD vplce[4]; @@ -68,7 +81,7 @@ extern "C" fixed_t palookuplight[4]; extern "C" const BYTE* bufplce[4]; // [RH] Temporary buffer for column drawing -extern "C" BYTE *dc_temp; +extern "C" BYTE *dc_temp; extern "C" unsigned int dc_tspans[4][MAXHEIGHT]; extern "C" unsigned int *dc_ctspan[4]; extern "C" unsigned int horizspans[4]; diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 9f07ff0bf..47ea75260 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -24,6 +24,7 @@ #define __R_DRAW_RGBA__ #include "r_draw.h" +#include "v_palette.h" #include #include #include @@ -273,4 +274,216 @@ public: void Execute(DrawerThread *thread) override; }; +///////////////////////////////////////////////////////////////////////////// +// Pixel shading macros and inline functions: + +// Give the compiler a strong hint we want these functions inlined: +#ifndef FORCEINLINE +#if defined(_MSC_VER) +#define FORCEINLINE __forceinline +#elif defined(__GNUC__) +#define FORCEINLINE __attribute__((always_inline)) inline +#else +#define FORCEINLINE inline +#endif +#endif + +// calculates the light constant passed to the shade_pal_index function +FORCEINLINE uint32_t calc_light_multiplier(dsfixed_t light) +{ + return 256 - (light >> (FRACBITS - 8)); +} + +// Calculates a ARGB8 color for the given palette index and light multiplier +FORCEINLINE uint32_t shade_pal_index_simple(uint32_t index, uint32_t light) +{ + const PalEntry &color = GPalette.BaseColors[index]; + uint32_t red = color.r; + uint32_t green = color.g; + uint32_t blue = color.b; + + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; + + return 0xff000000 | (red << 16) | (green << 8) | blue; +} + +FORCEINLINE uint32_t shade_bgra_simple(uint32_t color, uint32_t light) +{ + uint32_t red = (color >> 16) & 0xff; + uint32_t green = (color >> 8) & 0xff; + uint32_t blue = color & 0xff; + + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; + + return 0xff000000 | (red << 16) | (green << 8) | blue; +} + +// Calculates a ARGB8 color for the given palette index, light multiplier and dynamic colormap +FORCEINLINE uint32_t shade_pal_index(uint32_t index, uint32_t light, const ShadeConstants &constants) +{ + const PalEntry &color = GPalette.BaseColors[index]; + uint32_t red = color.r; + uint32_t green = color.g; + uint32_t blue = color.b; + if (constants.simple_shade) + { + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; + } + else + { + uint32_t inv_light = 256 - light; + uint32_t inv_desaturate = 256 - constants.desaturate; + + uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; + + red = (red * inv_desaturate + intensity) / 256; + green = (green * inv_desaturate + intensity) / 256; + blue = (blue * inv_desaturate + intensity) / 256; + + red = (constants.fade_red * inv_light + red * light) / 256; + green = (constants.fade_green * inv_light + green * light) / 256; + blue = (constants.fade_blue * inv_light + blue * light) / 256; + + red = (red * constants.light_red) / 256; + green = (green * constants.light_green) / 256; + blue = (blue * constants.light_blue) / 256; + } + return 0xff000000 | (red << 16) | (green << 8) | blue; +} + +FORCEINLINE uint32_t shade_bgra(uint32_t color, uint32_t light, const ShadeConstants &constants) +{ + uint32_t red = (color >> 16) & 0xff; + uint32_t green = (color >> 8) & 0xff; + uint32_t blue = color & 0xff; + if (constants.simple_shade) + { + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; + } + else + { + uint32_t inv_light = 256 - light; + uint32_t inv_desaturate = 256 - constants.desaturate; + + uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; + + red = (red * inv_desaturate + intensity) / 256; + green = (green * inv_desaturate + intensity) / 256; + blue = (blue * inv_desaturate + intensity) / 256; + + red = (constants.fade_red * inv_light + red * light) / 256; + green = (constants.fade_green * inv_light + green * light) / 256; + blue = (constants.fade_blue * inv_light + blue * light) / 256; + + red = (red * constants.light_red) / 256; + green = (green * constants.light_green) / 256; + blue = (blue * constants.light_blue) / 256; + } + return 0xff000000 | (red << 16) | (green << 8) | blue; +} + +FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) +{ + uint32_t fg_alpha = (fg >> 24) & 0xff; + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t alpha = fg_alpha + (fg_alpha >> 7); // 255 -> 256 + uint32_t inv_alpha = 256 - alpha; + + uint32_t bg_red = (bg >> 16) & 0xff; + uint32_t bg_green = (bg >> 8) & 0xff; + uint32_t bg_blue = bg & 0xff; + + uint32_t red = ((fg_red * alpha) + (bg_red * inv_alpha)) / 256; + uint32_t green = ((fg_green * alpha) + (bg_green * inv_alpha)) / 256; + uint32_t blue = ((fg_blue * alpha) + (bg_blue * inv_alpha)) / 256; + + return 0xff000000 | (red << 16) | (green << 8) | blue; +} + +// Calculate constants for a simple shade +#define SSE_SHADE_SIMPLE_INIT(light) \ + __m128i mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ + __m128i mlight_lo = mlight_hi; + +// Calculate constants for a simple shade with different light levels for each pixel +#define SSE_SHADE_SIMPLE_INIT4(light3, light2, light1, light0) \ + __m128i mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); \ + __m128i mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); + +// Simple shade 4 pixels +#define SSE_SHADE_SIMPLE(fg) { \ + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); \ + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); \ + fg_hi = _mm_mullo_epi16(fg_hi, mlight_hi); \ + fg_hi = _mm_srli_epi16(fg_hi, 8); \ + fg_lo = _mm_mullo_epi16(fg_lo, mlight_lo); \ + fg_lo = _mm_srli_epi16(fg_lo, 8); \ + fg = _mm_packus_epi16(fg_lo, fg_hi); \ +} + +// Calculate constants for a complex shade +#define SSE_SHADE_INIT(light, shade_constants) \ + __m128i mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ + __m128i mlight_lo = mlight_hi; \ + __m128i color = _mm_set_epi16( \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ + __m128i fade = _mm_set_epi16( \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ + __m128i fade_amount_hi = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_hi)); \ + __m128i fade_amount_lo = fade_amount_hi; \ + __m128i inv_desaturate = _mm_set1_epi16(256 - shade_constants.desaturate); \ + +// Calculate constants for a complex shade with different light levels for each pixel +#define SSE_SHADE_INIT4(light3, light2, light1, light0, shade_constants) \ + __m128i mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); \ + __m128i mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); \ + __m128i color = _mm_set_epi16( \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ + __m128i fade = _mm_set_epi16( \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ + __m128i fade_amount_hi = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_hi)); \ + __m128i fade_amount_lo = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_lo)); \ + __m128i inv_desaturate = _mm_set1_epi16(256 - shade_constants.desaturate); \ + +// Complex shade 4 pixels +#define SSE_SHADE(fg, shade_constants) { \ + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); \ + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); \ + \ + __m128i intensity_hi = _mm_mullo_epi16(fg_hi, _mm_set_epi16(0, 77, 143, 37, 0, 77, 143, 37)); \ + uint16_t intensity_hi0 = ((_mm_extract_epi16(intensity_hi, 2) + _mm_extract_epi16(intensity_hi, 1) + _mm_extract_epi16(intensity_hi, 0)) >> 8) * shade_constants.desaturate; \ + uint16_t intensity_hi1 = ((_mm_extract_epi16(intensity_hi, 6) + _mm_extract_epi16(intensity_hi, 5) + _mm_extract_epi16(intensity_hi, 4)) >> 8) * shade_constants.desaturate; \ + intensity_hi = _mm_set_epi16(intensity_hi1, intensity_hi1, intensity_hi1, intensity_hi1, intensity_hi0, intensity_hi0, intensity_hi0, intensity_hi0); \ + \ + fg_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, inv_desaturate), intensity_hi), 8); \ + fg_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mlight_hi), fade_amount_hi), 8); \ + fg_hi = _mm_srli_epi16(_mm_mullo_epi16(fg_hi, color), 8); \ + \ + __m128i intensity_lo = _mm_mullo_epi16(fg_lo, _mm_set_epi16(0, 77, 143, 37, 0, 77, 143, 37)); \ + uint16_t intensity_lo0 = ((_mm_extract_epi16(intensity_lo, 2) + _mm_extract_epi16(intensity_lo, 1) + _mm_extract_epi16(intensity_lo, 0)) >> 8) * shade_constants.desaturate; \ + uint16_t intensity_lo1 = ((_mm_extract_epi16(intensity_lo, 6) + _mm_extract_epi16(intensity_lo, 5) + _mm_extract_epi16(intensity_lo, 4)) >> 8) * shade_constants.desaturate; \ + intensity_lo = _mm_set_epi16(intensity_lo1, intensity_lo1, intensity_lo1, intensity_lo1, intensity_lo0, intensity_lo0, intensity_lo0, intensity_lo0); \ + \ + fg_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, inv_desaturate), intensity_lo), 8); \ + fg_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mlight_lo), fade_amount_lo), 8); \ + fg_lo = _mm_srli_epi16(_mm_mullo_epi16(fg_lo, color), 8); \ + \ + fg = _mm_packus_epi16(fg_lo, fg_hi); \ +} + #endif diff --git a/src/r_drawt.cpp b/src/r_drawt.cpp index c829c2dc4..837093044 100644 --- a/src/r_drawt.cpp +++ b/src/r_drawt.cpp @@ -340,13 +340,13 @@ void rt_add1col_c (int hx, int sx, int yl, int yh) return; count++; + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4 + hx]; pitch = dc_pitch; colormap = dc_colormap; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; do { DWORD fg = colormap[*source]; DWORD bg = *dest; @@ -374,14 +374,13 @@ void rt_add4cols_c (int sx, int yl, int yh) return; count++; + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4]; pitch = dc_pitch; colormap = dc_colormap; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; - do { DWORD fg = colormap[source[0]]; DWORD bg = dest[0]; @@ -434,6 +433,7 @@ void rt_tlateadd4cols_c (int sx, int yl, int yh) // Shades one span at hx to the screen at sx. void rt_shaded1col_c (int hx, int sx, int yl, int yh) { + DWORD *fgstart; BYTE *colormap; BYTE *source; BYTE *dest; @@ -445,14 +445,12 @@ void rt_shaded1col_c (int hx, int sx, int yl, int yh) return; count++; + fgstart = &Col2RGB8[0][dc_color]; colormap = dc_colormap; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4 + hx]; pitch = dc_pitch; - DWORD *fgstart; - fgstart = &Col2RGB8[0][dc_color]; - do { DWORD val = colormap[*source]; DWORD fg = fgstart[val<<8]; @@ -466,6 +464,7 @@ void rt_shaded1col_c (int hx, int sx, int yl, int yh) // Shades all four spans to the screen starting at sx. void rt_shaded4cols_c (int sx, int yl, int yh) { + DWORD *fgstart; BYTE *colormap; BYTE *source; BYTE *dest; @@ -477,14 +476,12 @@ void rt_shaded4cols_c (int sx, int yl, int yh) return; count++; + fgstart = &Col2RGB8[0][dc_color]; colormap = dc_colormap; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4]; pitch = dc_pitch; - DWORD *fgstart; - fgstart = &Col2RGB8[0][dc_color]; - do { DWORD val; @@ -523,14 +520,13 @@ void rt_addclamp1col_c (int hx, int sx, int yl, int yh) return; count++; + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4 + hx]; pitch = dc_pitch; colormap = dc_colormap; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; - do { DWORD a = fg2rgb[colormap[*source]] + bg2rgb[*dest]; DWORD b = a; @@ -639,13 +635,13 @@ void rt_subclamp1col_c (int hx, int sx, int yl, int yh) return; count++; + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4 + hx]; pitch = dc_pitch; colormap = dc_colormap; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; do { DWORD a = (fg2rgb[colormap[*source]] | 0x40100400) - bg2rgb[*dest]; DWORD b = a; @@ -674,13 +670,13 @@ void rt_subclamp4cols_c (int sx, int yl, int yh) return; count++; + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; dest = ylookup[yl] + sx + dc_destorg; source = &dc_temp[yl*4]; pitch = dc_pitch; colormap = dc_colormap; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; do { DWORD a = (fg2rgb[colormap[source[0]]] | 0x40100400) - bg2rgb[dest[0]]; DWORD b = a; diff --git a/src/r_main.h b/src/r_main.h index d71d44fe1..fa8fe0bb1 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -90,229 +90,6 @@ extern bool r_dontmaplines; // Converts fixedlightlev into a shade value #define FIXEDLIGHT2SHADE(lightlev) (((lightlev) >> COLORMAPSHIFT) << FRACBITS) -struct ShadeConstants -{ - uint16_t light_alpha; - uint16_t light_red; - uint16_t light_green; - uint16_t light_blue; - uint16_t fade_alpha; - uint16_t fade_red; - uint16_t fade_green; - uint16_t fade_blue; - uint16_t desaturate; - bool simple_shade; -}; - -// calculates the light constant passed to the shade_pal_index function -inline uint32_t calc_light_multiplier(dsfixed_t light) -{ - return 256 - (light >> (FRACBITS - 8)); -} - -// Give the compiler a strong hint we want these functions inlined: -#ifndef FORCEINLINE -#if defined(_MSC_VER) -#define FORCEINLINE __forceinline -#elif defined(__GNUC__) -#define FORCEINLINE __attribute__((always_inline)) inline -#else -#define FORCEINLINE inline -#endif -#endif - -// Calculates a ARGB8 color for the given palette index and light multiplier -FORCEINLINE uint32_t shade_pal_index_simple(uint32_t index, uint32_t light) -{ - const PalEntry &color = GPalette.BaseColors[index]; - uint32_t red = color.r; - uint32_t green = color.g; - uint32_t blue = color.b; - - red = red * light / 256; - green = green * light / 256; - blue = blue * light / 256; - - return 0xff000000 | (red << 16) | (green << 8) | blue; -} - -FORCEINLINE uint32_t shade_bgra_simple(uint32_t color, uint32_t light) -{ - uint32_t red = (color >> 16) & 0xff; - uint32_t green = (color >> 8) & 0xff; - uint32_t blue = color & 0xff; - - red = red * light / 256; - green = green * light / 256; - blue = blue * light / 256; - - return 0xff000000 | (red << 16) | (green << 8) | blue; -} - -// Calculates a ARGB8 color for the given palette index, light multiplier and dynamic colormap -FORCEINLINE uint32_t shade_pal_index(uint32_t index, uint32_t light, const ShadeConstants &constants) -{ - const PalEntry &color = GPalette.BaseColors[index]; - uint32_t red = color.r; - uint32_t green = color.g; - uint32_t blue = color.b; - if (constants.simple_shade) - { - red = red * light / 256; - green = green * light / 256; - blue = blue * light / 256; - } - else - { - uint32_t inv_light = 256 - light; - uint32_t inv_desaturate = 256 - constants.desaturate; - - uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; - - red = (red * inv_desaturate + intensity) / 256; - green = (green * inv_desaturate + intensity) / 256; - blue = (blue * inv_desaturate + intensity) / 256; - - red = (constants.fade_red * inv_light + red * light) / 256; - green = (constants.fade_green * inv_light + green * light) / 256; - blue = (constants.fade_blue * inv_light + blue * light) / 256; - - red = (red * constants.light_red) / 256; - green = (green * constants.light_green) / 256; - blue = (blue * constants.light_blue) / 256; - } - return 0xff000000 | (red << 16) | (green << 8) | blue; -} - -FORCEINLINE uint32_t shade_bgra(uint32_t color, uint32_t light, const ShadeConstants &constants) -{ - uint32_t red = (color >> 16) & 0xff; - uint32_t green = (color >> 8) & 0xff; - uint32_t blue = color & 0xff; - if (constants.simple_shade) - { - red = red * light / 256; - green = green * light / 256; - blue = blue * light / 256; - } - else - { - uint32_t inv_light = 256 - light; - uint32_t inv_desaturate = 256 - constants.desaturate; - - uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; - - red = (red * inv_desaturate + intensity) / 256; - green = (green * inv_desaturate + intensity) / 256; - blue = (blue * inv_desaturate + intensity) / 256; - - red = (constants.fade_red * inv_light + red * light) / 256; - green = (constants.fade_green * inv_light + green * light) / 256; - blue = (constants.fade_blue * inv_light + blue * light) / 256; - - red = (red * constants.light_red) / 256; - green = (green * constants.light_green) / 256; - blue = (blue * constants.light_blue) / 256; - } - return 0xff000000 | (red << 16) | (green << 8) | blue; -} - -FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) -{ - uint32_t fg_alpha = (fg >> 24) & 0xff; - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t alpha = fg_alpha + (fg_alpha >> 7); // 255 -> 256 - uint32_t inv_alpha = 256 - alpha; - - uint32_t bg_red = (bg >> 16) & 0xff; - uint32_t bg_green = (bg >> 8) & 0xff; - uint32_t bg_blue = bg & 0xff; - - uint32_t red = ((fg_red * alpha) + (bg_red * inv_alpha)) / 256; - uint32_t green = ((fg_green * alpha) + (bg_green * inv_alpha)) / 256; - uint32_t blue = ((fg_blue * alpha) + (bg_blue * inv_alpha)) / 256; - - return 0xff000000 | (red << 16) | (green << 8) | blue; -} - -// Calculate constants for a simple shade -#define SSE_SHADE_SIMPLE_INIT(light) \ - __m128i mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ - __m128i mlight_lo = mlight_hi; - -// Calculate constants for a simple shade with different light levels for each pixel -#define SSE_SHADE_SIMPLE_INIT4(light3, light2, light1, light0) \ - __m128i mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); \ - __m128i mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); - -// Simple shade 4 pixels -#define SSE_SHADE_SIMPLE(fg) { \ - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); \ - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); \ - fg_hi = _mm_mullo_epi16(fg_hi, mlight_hi); \ - fg_hi = _mm_srli_epi16(fg_hi, 8); \ - fg_lo = _mm_mullo_epi16(fg_lo, mlight_lo); \ - fg_lo = _mm_srli_epi16(fg_lo, 8); \ - fg = _mm_packus_epi16(fg_lo, fg_hi); \ -} - -// Calculate constants for a complex shade -#define SSE_SHADE_INIT(light, shade_constants) \ - __m128i mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ - __m128i mlight_lo = mlight_hi; \ - __m128i color = _mm_set_epi16( \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ - __m128i fade = _mm_set_epi16( \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ - __m128i fade_amount_hi = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_hi)); \ - __m128i fade_amount_lo = fade_amount_hi; \ - __m128i inv_desaturate = _mm_set1_epi16(256 - shade_constants.desaturate); \ - -// Calculate constants for a complex shade with different light levels for each pixel -#define SSE_SHADE_INIT4(light3, light2, light1, light0, shade_constants) \ - __m128i mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); \ - __m128i mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); \ - __m128i color = _mm_set_epi16( \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ - __m128i fade = _mm_set_epi16( \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ - __m128i fade_amount_hi = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_hi)); \ - __m128i fade_amount_lo = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_lo)); \ - __m128i inv_desaturate = _mm_set1_epi16(256 - shade_constants.desaturate); \ - -// Complex shade 4 pixels -#define SSE_SHADE(fg, shade_constants) { \ - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); \ - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); \ - \ - __m128i intensity_hi = _mm_mullo_epi16(fg_hi, _mm_set_epi16(0, 77, 143, 37, 0, 77, 143, 37)); \ - uint16_t intensity_hi0 = ((_mm_extract_epi16(intensity_hi, 2) + _mm_extract_epi16(intensity_hi, 1) + _mm_extract_epi16(intensity_hi, 0)) >> 8) * shade_constants.desaturate; \ - uint16_t intensity_hi1 = ((_mm_extract_epi16(intensity_hi, 6) + _mm_extract_epi16(intensity_hi, 5) + _mm_extract_epi16(intensity_hi, 4)) >> 8) * shade_constants.desaturate; \ - intensity_hi = _mm_set_epi16(intensity_hi1, intensity_hi1, intensity_hi1, intensity_hi1, intensity_hi0, intensity_hi0, intensity_hi0, intensity_hi0); \ - \ - fg_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, inv_desaturate), intensity_hi), 8); \ - fg_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mlight_hi), fade_amount_hi), 8); \ - fg_hi = _mm_srli_epi16(_mm_mullo_epi16(fg_hi, color), 8); \ - \ - __m128i intensity_lo = _mm_mullo_epi16(fg_lo, _mm_set_epi16(0, 77, 143, 37, 0, 77, 143, 37)); \ - uint16_t intensity_lo0 = ((_mm_extract_epi16(intensity_lo, 2) + _mm_extract_epi16(intensity_lo, 1) + _mm_extract_epi16(intensity_lo, 0)) >> 8) * shade_constants.desaturate; \ - uint16_t intensity_lo1 = ((_mm_extract_epi16(intensity_lo, 6) + _mm_extract_epi16(intensity_lo, 5) + _mm_extract_epi16(intensity_lo, 4)) >> 8) * shade_constants.desaturate; \ - intensity_lo = _mm_set_epi16(intensity_lo1, intensity_lo1, intensity_lo1, intensity_lo1, intensity_lo0, intensity_lo0, intensity_lo0, intensity_lo0); \ - \ - fg_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, inv_desaturate), intensity_lo), 8); \ - fg_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mlight_lo), fade_amount_lo), 8); \ - fg_lo = _mm_srli_epi16(_mm_mullo_epi16(fg_lo, color), 8); \ - \ - fg = _mm_packus_epi16(fg_lo, fg_hi); \ -} - extern bool r_swtruecolor; extern double GlobVis; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 1a08d1793..807066f77 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -58,6 +58,7 @@ #include "r_3dfloors.h" #include "v_palette.h" #include "r_data/colormaps.h" +#include "r_draw_rgba.h" #ifdef _MSC_VER #pragma warning(disable:4244) @@ -506,7 +507,7 @@ void R_MapTiltedPlane_rgba (int y, int x1) void R_MapColoredPlane_C (int y, int x1) { - memset (ylookup[y] + x1 + dc_destorg, ds_color, (spanend[y] - x1 + 1)); + memset (ylookup[y] + x1 + dc_destorg, ds_color, spanend[y] - x1 + 1); } void R_MapColoredPlane_rgba(int y, int x1) @@ -1710,7 +1711,7 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t // //========================================================================== -void R_DrawTiltedPlane(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked) +void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked) { static const float ifloatpow2[16] = { @@ -1745,7 +1746,7 @@ void R_DrawTiltedPlane(visplane_t *pl, double _xscale, double _yscale, fixed_t a // p is the texture origin in view space // Don't add in the offsets at this stage, because doing so can result in // errors if the flat is rotated. - ang = M_PI * 3 / 2 - ViewAngle.Radians(); + ang = M_PI*3/2 - ViewAngle.Radians(); cosine = cos(ang), sine = sin(ang); p[0] = ViewPos.X * cosine - ViewPos.Y * sine; p[2] = ViewPos.X * sine + ViewPos.Y * cosine; @@ -1756,25 +1757,25 @@ void R_DrawTiltedPlane(visplane_t *pl, double _xscale, double _yscale, fixed_t a cosine = cos(ang), sine = sin(ang); m[0] = yscale * cosine; m[2] = yscale * sine; - // m[1] = pl->height.ZatPointF (0, iyscale) - pl->height.ZatPointF (0,0)); - // VectorScale2 (m, 64.f/VectorLength(m)); +// m[1] = pl->height.ZatPointF (0, iyscale) - pl->height.ZatPointF (0,0)); +// VectorScale2 (m, 64.f/VectorLength(m)); - // n is the u direction vector in view space + // n is the u direction vector in view space #if 0 //let's use the sin/cosine we already know instead of computing new ones - ang += M_PI / 2 - n[0] = -xscale * cos(ang); + ang += M_PI/2 + n[0] = -xscale * cos(ang); n[2] = -xscale * sin(ang); #else n[0] = xscale * sine; n[2] = -xscale * cosine; #endif - // n[1] = pl->height.ZatPointF (ixscale, 0) - pl->height.ZatPointF (0,0)); - // VectorScale2 (n, 64.f/VectorLength(n)); +// n[1] = pl->height.ZatPointF (ixscale, 0) - pl->height.ZatPointF (0,0)); +// VectorScale2 (n, 64.f/VectorLength(n)); - // This code keeps the texture coordinates constant across the x,y plane no matter - // how much you slope the surface. Use the commented-out code above instead to keep - // the textures a constant size across the surface's plane instead. + // This code keeps the texture coordinates constant across the x,y plane no matter + // how much you slope the surface. Use the commented-out code above instead to keep + // the textures a constant size across the surface's plane instead. cosine = cos(planeang), sine = sin(planeang); m[1] = pl->height.ZatPoint(ViewPos.X + yscale * sine, ViewPos.Y + yscale * cosine) - zeroheight; n[1] = pl->height.ZatPoint(ViewPos.X - xscale * cosine, ViewPos.Y + xscale * sine) - zeroheight; @@ -1807,7 +1808,6 @@ void R_DrawTiltedPlane(visplane_t *pl, double _xscale, double _yscale, fixed_t a if (pl->height.fC() > 0) planelightfloat = -planelightfloat; - ds_light = 0; if (fixedlightlev >= 0) { R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index fbbd65b17..c4347236d 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -96,7 +96,7 @@ void FSoftwareRenderer::PrecacheTexture(FTexture *tex, int cache) else if (cache != 0) { if (r_swtruecolor) - tex->GetPixels(); + tex->GetPixelsBgra(); else tex->GetPixels (); } diff --git a/src/r_things.cpp b/src/r_things.cpp index 0858dce2f..836f58690 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2612,8 +2612,10 @@ static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) void R_DrawParticle_C (vissprite_t *vis) { + DWORD *bg2rgb; int spacing; BYTE *dest; + DWORD fg; BYTE color = vis->Style.BaseColormap->Maps[(vis->Style.ColormapNum << COLORMAPSHIFT) + vis->startfrac]; int yl = vis->y1; int ycount = vis->y2 - yl + 1; @@ -2622,9 +2624,6 @@ void R_DrawParticle_C (vissprite_t *vis) R_DrawMaskedSegsBehindParticle (vis); - DWORD *bg2rgb; - DWORD fg; - // vis->renderflags holds translucency level (0-255) { fixed_t fglevel, bglevel; diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 02ba591b6..6a8dad047 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -44,6 +44,7 @@ #include "r_utility.h" #ifndef NO_SWRENDER #include "r_draw.h" +#include "r_draw_rgba.h" #include "r_main.h" #include "r_things.h" #endif From 312776621e194e36f7ef1b01d36942929ff241bf Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 16 Jun 2016 06:47:30 +0200 Subject: [PATCH 0659/1509] Added DrawerContext class --- src/CMakeLists.txt | 1 + src/r_bsp.cpp | 4 +- src/r_draw.cpp | 798 ++++++++++++++++++++++++++++++++++++++- src/r_draw.h | 89 ++++- src/r_draw_rgba.cpp | 169 +++++++++ src/r_draw_rgba.h | 7 + src/r_drawer_context.cpp | 464 +++++++++++++++++++++++ src/r_drawer_context.h | 123 ++++++ src/r_drawt.cpp | 22 +- src/r_drawt_rgba.cpp | 2 + src/r_main.cpp | 14 +- src/r_main.h | 16 - src/r_plane.cpp | 454 ++-------------------- src/r_plane.h | 8 - src/r_segs.cpp | 541 +++++--------------------- src/r_swrenderer.cpp | 1 + src/r_things.cpp | 382 +++++-------------- src/r_things.h | 9 +- src/v_draw.cpp | 109 +++--- 19 files changed, 1922 insertions(+), 1291 deletions(-) create mode 100644 src/r_drawer_context.cpp create mode 100644 src/r_drawer_context.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8c0a30ea0..49152b785 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -892,6 +892,7 @@ set( FASTMATH_PCH_SOURCES r_swrenderer.cpp r_3dfloors.cpp r_bsp.cpp + r_drawer_context.cpp r_draw.cpp r_draw_rgba.cpp r_drawt.cpp diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 934d2d3e5..2b94b1e95 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -41,7 +41,7 @@ #include "r_local.h" #include "r_main.h" #include "r_plane.h" -#include "r_draw.h" +#include "r_drawer_context.h" #include "r_things.h" #include "r_3dfloors.h" #include "a_sharedglobal.h" @@ -545,7 +545,7 @@ void R_AddLine (seg_t *line) curline = line; // [RH] Color if not texturing line - dc_color = (((int)(line - segs) * 8) + 4) & 255; + DrawerContext::SetFlatColor((((int)(line - segs) * 8) + 4) & 255); pt1 = line->v1->fPos() - ViewPos; pt2 = line->v2->fPos() - ViewPos; diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 4dcdc3e6b..19195e907 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -23,6 +23,8 @@ // //----------------------------------------------------------------------------- +#define DRAWER_INTERNALS + #include #include "templates.h" @@ -40,6 +42,8 @@ #include "r_data/colormaps.h" #include "r_plane.h" #include "r_draw_rgba.h" +#include "r_drawer_context.h" +#include "d_net.h" #include "gi.h" #include "stats.h" @@ -66,6 +70,7 @@ int ylookup[MAXHEIGHT]; BYTE *dc_destorg; } int scaledviewwidth; +DCanvas *dc_canvas; // [RH] Pointers to the different column drawers. // These get changed depending on the current @@ -97,9 +102,9 @@ void (*R_DrawSpanMaskedAddClamp)(void); void (*R_FillSpan)(void); void (*R_FillColumnHoriz)(void); void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); -void (*R_MapTiltedPlane)(int y, int x1); -void (*R_MapColoredPlane)(int y, int x1); -void (*R_DrawParticle)(vissprite_t *); +void (*R_DrawTiltedSpan)(int y, int x1, int x2); +void (*R_DrawColoredSpan)(int y, int x1, int x2); +void (*R_FillTransColumn)(int x, int y1, int y2, int color, int alpha); fixed_t (*tmvline1_add)(); void (*tmvline4_add)(); fixed_t (*tmvline1_addclamp)(); @@ -134,6 +139,24 @@ void (*rt_tlatesubclamp4cols)(int sx, int yl, int yh); void (*rt_tlaterevsubclamp4cols)(int sx, int yl, int yh); void (*rt_initcols)(BYTE *buffer); void (*rt_span_coverage)(int x, int start, int stop); +void (*colfunc) (void); +void (*basecolfunc) (void); +void (*fuzzcolfunc) (void); +void (*transcolfunc) (void); +void (*spanfunc) (void); +void (*hcolfunc_pre) (void); +void (*hcolfunc_post1) (int hx, int sx, int yl, int yh); +void (*hcolfunc_post2) (int hx, int sx, int yl, int yh); +void (*hcolfunc_post4) (int sx, int yl, int yh); + +extern "C" void R_DrawTiltedPlane_ASM(int y, int x1); +#ifdef X86_ASM +extern "C" void R_SetSpanSource_ASM(const BYTE *flat); +extern "C" void R_SetSpanSize_ASM(int xbits, int ybits); +extern "C" void R_SetSpanColormap_ASM(BYTE *colormap); +extern "C" void R_SetTiltedSpanSource_ASM(const BYTE *flat); +extern "C" BYTE *ds_curcolormap, *ds_cursource, *ds_curtiltedsource; +#endif // // R_DrawColumn @@ -1040,13 +1063,6 @@ const BYTE* ds_source; // just for profiling int dscount; - -#ifdef X86_ASM -extern "C" void R_SetSpanSource_ASM (const BYTE *flat); -extern "C" void R_SetSpanSize_ASM (int xbits, int ybits); -extern "C" void R_SetSpanColormap_ASM (BYTE *colormap); -extern "C" BYTE *ds_curcolormap, *ds_cursource, *ds_curtiltedsource; -#endif } //========================================================================== @@ -1076,9 +1092,8 @@ void R_SetSpanSource(const BYTE *pixels) // //========================================================================== -void R_SetSpanColormap(FDynamicColormap *colormap, int shade) +void R_SetSpanColormap() { - R_SetDSColorMapLight(colormap, 0, shade); #ifdef X86_ASM if (!r_swtruecolor && ds_colormap != ds_curcolormap) { @@ -2297,9 +2312,9 @@ void R_InitColumnDrawers () R_FillColumnHoriz = R_FillColumnHoriz_rgba; R_DrawFogBoundary = R_DrawFogBoundary_rgba; - R_MapTiltedPlane = R_MapTiltedPlane_rgba; - R_MapColoredPlane = R_MapColoredPlane_rgba; - R_DrawParticle = R_DrawParticle_rgba; + R_DrawTiltedSpan = R_DrawTiltedSpan_rgba; + R_DrawColoredSpan = R_DrawColoredSpan_rgba; + R_FillTransColumn = R_FillTransColumn_rgba; tmvline1_add = tmvline1_add_rgba; tmvline4_add = tmvline4_add_rgba; @@ -2394,9 +2409,15 @@ void R_InitColumnDrawers () R_FillColumnHoriz = R_FillColumnHorizP_C; R_DrawFogBoundary = R_DrawFogBoundary_C; - R_MapTiltedPlane = R_MapTiltedPlane_C; - R_MapColoredPlane = R_MapColoredPlane_C; - R_DrawParticle = R_DrawParticle_C; + R_DrawColoredSpan = R_DrawColoredSpan_C; + R_FillTransColumn = R_FillTransColumn_C; + +#ifdef X86_ASM + // To do: update R_DrawTiltedPlane_ASM to use x2 rather than spanend[y] + R_DrawTiltedSpan = [](int y, int x1, int x2) { R_DrawTiltedPlane_ASM(y, x1); }; +#else + R_DrawTiltedSpan = R_DrawTiltedSpan_C; +#endif tmvline1_add = tmvline1_add_C; tmvline4_add = tmvline4_add_C; @@ -2829,3 +2850,744 @@ void R_SetDSColorMapLight(FColormap *base_colormap, float light, int shade) ds_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); } } + +///////////////////////////////////////////////////////////////////////////// + +FVector3 ds_plane_sz, ds_plane_su, ds_plane_sv; +bool ds_plane_shade; +float ds_planelightfloat; +fixed_t ds_pviewx, ds_pviewy; +int ds_planeshade; +extern "C" BYTE *tiltlighting[MAXWIDTH]; + +extern "C" { void R_CalcTiltedLighting(double lval, double lend, int width); } + +#ifdef _MSC_VER +#pragma warning(disable:4244) // warning C4244: conversion from 'SQWORD' to 'DWORD', possible loss of data +#endif + +//========================================================================== +// +// R_CalcTiltedLighting +// +// Calculates the lighting for one row of a tilted plane. If the definition +// of GETPALOOKUP changes, this needs to change, too. +// +//========================================================================== + +extern "C" { +void R_CalcTiltedLighting (double lval, double lend, int width) +{ + double lstep; + BYTE *lightfiller; + BYTE *basecolormapdata = ds_fcolormap->Maps; + int i = 0; + + if (width == 0 || lval == lend) + { // Constant lighting + lightfiller = basecolormapdata + (GETPALOOKUP(lval, ds_planeshade) << COLORMAPSHIFT); + } + else + { + lstep = (lend - lval) / width; + if (lval >= MAXLIGHTVIS) + { // lval starts "too bright". + lightfiller = basecolormapdata + (GETPALOOKUP(lval, ds_planeshade) << COLORMAPSHIFT); + for (; i <= width && lval >= MAXLIGHTVIS; ++i) + { + tiltlighting[i] = lightfiller; + lval += lstep; + } + } + if (lend >= MAXLIGHTVIS) + { // lend ends "too bright". + lightfiller = basecolormapdata + (GETPALOOKUP(lend, ds_planeshade) << COLORMAPSHIFT); + for (; width > i && lend >= MAXLIGHTVIS; --width) + { + tiltlighting[width] = lightfiller; + lend -= lstep; + } + } + if (width > 0) + { + lval = FIXED2DBL(ds_planeshade) - lval; + lend = FIXED2DBL(ds_planeshade) - lend; + lstep = (lend - lval) / width; + if (lstep < 0) + { // Going from dark to light + if (lval < 1.) + { // All bright + lightfiller = basecolormapdata; + } + else + { + if (lval >= NUMCOLORMAPS) + { // Starts beyond the dark end + BYTE *clight = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT); + while (lval >= NUMCOLORMAPS && i <= width) + { + tiltlighting[i++] = clight; + lval += lstep; + } + if (i > width) + return; + } + while (i <= width && lval >= 0) + { + tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT); + lval += lstep; + } + lightfiller = basecolormapdata; + } + } + else + { // Going from light to dark + if (lval >= (NUMCOLORMAPS-1)) + { // All dark + lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT); + } + else + { + while (lval < 0 && i <= width) + { + tiltlighting[i++] = basecolormapdata; + lval += lstep; + } + if (i > width) + return; + while (i <= width && lval < (NUMCOLORMAPS-1)) + { + tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT); + lval += lstep; + } + lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT); + } + } + } + } + for (; i <= width; i++) + { + tiltlighting[i] = lightfiller; + } +} +} // extern "C" + +void R_DrawTiltedSpan_C (int y, int x1, int x2) +{ + int width = x2 - x1; + double iz, uz, vz; + BYTE *fb; + DWORD u, v; + int i; + + iz = ds_plane_sz[2] + ds_plane_sz[1]*(centery-y) + ds_plane_sz[0]*(x1-centerx); + + // Lighting is simple. It's just linear interpolation from start to end + if (ds_plane_shade) + { + uz = (iz + ds_plane_sz[0]*width) * ds_planelightfloat; + vz = iz * ds_planelightfloat; + R_CalcTiltedLighting (vz, uz, width); + } + + uz = ds_plane_su[2] + ds_plane_su[1]*(centery-y) + ds_plane_su[0]*(x1-centerx); + vz = ds_plane_sv[2] + ds_plane_sv[1]*(centery-y) + ds_plane_sv[0]*(x1-centerx); + + fb = ylookup[y] + x1 + dc_destorg; + + BYTE vshift = 32 - ds_ybits; + BYTE ushift = vshift - ds_xbits; + int umask = ((1 << ds_xbits) - 1) << ds_ybits; + +#if 0 // The "perfect" reference version of this routine. Pretty slow. + // Use it only to see how things are supposed to look. + i = 0; + do + { + double z = 1.f/iz; + + u = SQWORD(uz*z) + ds_pviewx; + v = SQWORD(vz*z) + ds_pviewy; + R_SetDSColorMapLight(tiltlighting[i], 0, 0); + fb[i++] = ds_colormap[ds_source[(v >> vshift) | ((u >> ushift) & umask)]]; + iz += ds_plane_sz[0]; + uz += ds_plane_su[0]; + vz += ds_plane_sv[0]; + } while (--width >= 0); +#else +//#define SPANSIZE 32 +//#define INVSPAN 0.03125f +//#define SPANSIZE 8 +//#define INVSPAN 0.125f +#define SPANSIZE 16 +#define INVSPAN 0.0625f + + double startz = 1.f/iz; + double startu = uz*startz; + double startv = vz*startz; + double izstep, uzstep, vzstep; + + izstep = ds_plane_sz[0] * SPANSIZE; + uzstep = ds_plane_su[0] * SPANSIZE; + vzstep = ds_plane_sv[0] * SPANSIZE; + x1 = 0; + width++; + + while (width >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + double endz = 1.f/iz; + double endu = uz*endz; + double endv = vz*endz; + DWORD stepu = SQWORD((endu - startu) * INVSPAN); + DWORD stepv = SQWORD((endv - startv) * INVSPAN); + u = SQWORD(startu) + ds_pviewx; + v = SQWORD(startv) + ds_pviewy; + + for (i = SPANSIZE-1; i >= 0; i--) + { + fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); + x1++; + u += stepu; + v += stepv; + } + startu = endu; + startv = endv; + width -= SPANSIZE; + } + if (width > 0) + { + if (width == 1) + { + u = SQWORD(startu); + v = SQWORD(startv); + fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); + } + else + { + double left = width; + iz += ds_plane_sz[0] * left; + uz += ds_plane_su[0] * left; + vz += ds_plane_sv[0] * left; + + double endz = 1.f/iz; + double endu = uz*endz; + double endv = vz*endz; + left = 1.f/left; + DWORD stepu = SQWORD((endu - startu) * left); + DWORD stepv = SQWORD((endv - startv) * left); + u = SQWORD(startu) + ds_pviewx; + v = SQWORD(startv) + ds_pviewy; + + for (; width != 0; width--) + { + fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); + x1++; + u += stepu; + v += stepv; + } + } + } +#endif +} + +void R_DrawColoredSpan_C (int y, int x1, int x2) +{ + memset (ylookup[y] + x1 + dc_destorg, ds_color, x2 - x1 + 1); +} + +///////////////////////////////////////////////////////////////////////////// + +// Draw a column with support for non-power-of-two ranges +uint32_t wallscan_drawcol1(int x, int y1, int y2, uint32_t uv_start, uint32_t uv_step, uint32_t uv_max, const BYTE *source, DWORD(*draw1column)()) +{ + int pixelsize = r_swtruecolor ? 4 : 1; + if (uv_max == 0) // power of two + { + int count = y2 - y1; + + dc_source = source; + dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; + dc_count = count; + dc_iscale = uv_step; + dc_texturefrac = uv_start; + draw1column(); + + uint64_t step64 = uv_step; + uint64_t pos64 = uv_start; + return (uint32_t)(pos64 + step64 * count); + } + else + { + uint32_t uv_pos = uv_start; + + uint32_t left = y2 - y1; + while (left > 0) + { + uint32_t available = uv_max - uv_pos; + uint32_t next_uv_wrap = available / uv_step; + if (available % uv_step != 0) + next_uv_wrap++; + uint32_t count = MIN(left, next_uv_wrap); + + dc_source = source; + dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; + dc_count = count; + dc_iscale = uv_step; + dc_texturefrac = uv_pos; + draw1column(); + + left -= count; + uv_pos += uv_step * count; + if (uv_pos >= uv_max) + uv_pos -= uv_max; + } + + return uv_pos; + } +} + +// Draw four columns with support for non-power-of-two ranges +void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_step, uint32_t uv_max, const BYTE **source, void(*draw4columns)()) +{ + int pixelsize = r_swtruecolor ? 4 : 1; + if (uv_max == 0) // power of two, no wrap handling needed + { + int count = y2 - y1; + for (int i = 0; i < 4; i++) + { + bufplce[i] = source[i]; + vplce[i] = uv_pos[i]; + vince[i] = uv_step[i]; + + uint64_t step64 = uv_step[i]; + uint64_t pos64 = uv_pos[i]; + uv_pos[i] = (uint32_t)(pos64 + step64 * count); + } + dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; + dc_count = count; + draw4columns(); + } + else + { + dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; + for (int i = 0; i < 4; i++) + bufplce[i] = source[i]; + + uint32_t left = y2 - y1; + while (left > 0) + { + // Find which column wraps first + uint32_t count = left; + for (int i = 0; i < 4; i++) + { + uint32_t available = uv_max - uv_pos[i]; + uint32_t next_uv_wrap = available / uv_step[i]; + if (available % uv_step[i] != 0) + next_uv_wrap++; + count = MIN(next_uv_wrap, count); + } + + // Draw until that column wraps + for (int i = 0; i < 4; i++) + { + vplce[i] = uv_pos[i]; + vince[i] = uv_step[i]; + } + dc_count = count; + draw4columns(); + + // Wrap the uv position + for (int i = 0; i < 4; i++) + { + uv_pos[i] += uv_step[i] * count; + if (uv_pos[i] >= uv_max) + uv_pos[i] -= uv_max; + } + + left -= count; + } + } +} + +// Calculates a wrapped uv start position value for a column +void calc_uv_start_and_step(int y1, float swal, double yrepeat, uint32_t uv_height, int fracbits, uint32_t &uv_start_out, uint32_t &uv_step_out) +{ + double uv_stepd = swal * yrepeat; + + // Find start uv in [0-uv_height[ range. + // Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range. + double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / uv_height; + v = v - floor(v); + v *= uv_height; + v *= (1 << fracbits); + + uv_start_out = (uint32_t)v; + uv_step_out = xs_ToFixed(fracbits, uv_stepd); +} + +typedef DWORD(*Draw1ColumnFuncPtr)(); +typedef void(*Draw4ColumnsFuncPtr)(); + +void wallscan_any( + int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, + FTexture *rw_pic, fixed_t rw_offset, const BYTE *(*getcol)(FTexture *tex, int x), + void(setupwallscan(int bits, Draw1ColumnFuncPtr &draw1, Draw4ColumnsFuncPtr &draw2))) +{ + if (rw_pic->UseType == FTexture::TEX_Null) + return; + + uint32_t uv_height = rw_pic->GetHeight(); + uint32_t fracbits = 32 - rw_pic->HeightBits; + uint32_t uv_max = uv_height << fracbits; + + DWORD(*draw1column)(); + void(*draw4columns)(); + setupwallscan(fracbits, draw1column, draw4columns); + + fixed_t xoffset = rw_offset; + + bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); + if (fixed) + { + palookupoffse[0] = dc_colormap; + palookupoffse[1] = dc_colormap; + palookupoffse[2] = dc_colormap; + palookupoffse[3] = dc_colormap; + palookuplight[0] = 0; + palookuplight[1] = 0; + palookuplight[2] = 0; + palookuplight[3] = 0; + } + + if (fixedcolormap) + R_SetColorMapLight(fixedcolormap, 0, 0); + else + R_SetColorMapLight(basecolormap, 0, 0); + + float light = rw_light; + + // Calculate where 4 column alignment begins and ends: + int aligned_x1 = clamp((x1 + 3) / 4 * 4, x1, x2); + int aligned_x2 = clamp(x2 / 4 * 4, x1, x2); + + // First unaligned columns: + for (int x = x1; x < aligned_x1; x++, light += rw_lightstep) + { + int y1 = uwal[x]; + int y2 = dwal[x]; + if (y2 <= y1) + continue; + + if (!fixed) + R_SetColorMapLight(basecolormap, light, wallshade); + + const BYTE *source = getcol(rw_pic, (lwal[x] + xoffset) >> FRACBITS); + + uint32_t uv_start, uv_step; + calc_uv_start_and_step(y1, swal[x], yrepeat, uv_height, fracbits, uv_start, uv_step); + + wallscan_drawcol1(x, y1, y2, uv_start, uv_step, uv_max, source, draw1column); + } + + // The aligned columns + for (int x = aligned_x1; x < aligned_x2; x += 4) + { + // Find y1, y2, light and uv values for four columns: + int y1[4] = { uwal[x], uwal[x + 1], uwal[x + 2], uwal[x + 3] }; + int y2[4] = { dwal[x], dwal[x + 1], dwal[x + 2], dwal[x + 3] }; + + const BYTE *source[4]; + for (int i = 0; i < 4; i++) + source[i] = getcol(rw_pic, (lwal[x + i] + xoffset) >> FRACBITS); + + float lights[4]; + for (int i = 0; i < 4; i++) + { + lights[i] = light; + light += rw_lightstep; + } + + uint32_t uv_pos[4], uv_step[4]; + for (int i = 0; i < 4; i++) + calc_uv_start_and_step(y1[i], swal[x + i], yrepeat, uv_height, fracbits, uv_pos[i], uv_step[i]); + + // Figure out where we vertically can start and stop drawing 4 columns in one go + int middle_y1 = y1[0]; + int middle_y2 = y2[0]; + for (int i = 1; i < 4; i++) + { + middle_y1 = MAX(y1[i], middle_y1); + middle_y2 = MIN(y2[i], middle_y2); + } + + // If we got an empty column in our set we cannot draw 4 columns in one go: + bool empty_column_in_set = false; + for (int i = 0; i < 4; i++) + { + if (y2[i] <= y1[i]) + empty_column_in_set = true; + } + + if (empty_column_in_set || middle_y2 <= middle_y1) + { + for (int i = 0; i < 4; i++) + { + if (y2[i] <= y1[i]) + continue; + + if (!fixed) + R_SetColorMapLight(basecolormap, lights[i], wallshade); + wallscan_drawcol1(x + i, y1[i], y2[i], uv_pos[i], uv_step[i], uv_max, source[i], draw1column); + } + continue; + } + + // Draw the first rows where not all 4 columns are active + for (int i = 0; i < 4; i++) + { + if (!fixed) + R_SetColorMapLight(basecolormap, lights[i], wallshade); + + if (y1[i] < middle_y1) + uv_pos[i] = wallscan_drawcol1(x + i, y1[i], middle_y1, uv_pos[i], uv_step[i], uv_max, source[i], draw1column); + } + + // Draw the area where all 4 columns are active + if (!fixed) + { + for (int i = 0; i < 4; i++) + { + if (r_swtruecolor) + { + palookupoffse[i] = basecolormap->Maps; + palookuplight[i] = LIGHTSCALE(lights[i], wallshade); + } + else + { + palookupoffse[i] = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); + palookuplight[i] = 0; + } + } + } + wallscan_drawcol4(x, middle_y1, middle_y2, uv_pos, uv_step, uv_max, source, draw4columns); + + // Draw the last rows where not all 4 columns are active + for (int i = 0; i < 4; i++) + { + if (!fixed) + R_SetColorMapLight(basecolormap, lights[i], wallshade); + + if (middle_y2 < y2[i]) + uv_pos[i] = wallscan_drawcol1(x + i, middle_y2, y2[i], uv_pos[i], uv_step[i], uv_max, source[i], draw1column); + } + } + + // The last unaligned columns: + for (int x = aligned_x2; x < x2; x++, light += rw_lightstep) + { + int y1 = uwal[x]; + int y2 = dwal[x]; + if (y2 <= y1) + continue; + + if (!fixed) + R_SetColorMapLight(basecolormap, light, wallshade); + + const BYTE *source = getcol(rw_pic, (lwal[x] + xoffset) >> FRACBITS); + + uint32_t uv_start, uv_step; + calc_uv_start_and_step(y1, swal[x], yrepeat, uv_height, fracbits, uv_start, uv_step); + + wallscan_drawcol1(x, y1, y2, uv_start, uv_step, uv_max, source, draw1column); + } + + NetUpdate(); +} + +void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, FTexture *rw_pic, fixed_t rw_offset, const BYTE *(*getcol)(FTexture *tex, int x)) +{ + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, rw_pic, rw_offset, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + { + setupvline(bits); + line1 = dovline1; + line4 = dovline4; + }); +} + +void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, FTexture *rw_pic, fixed_t rw_offset, const BYTE *(*getcol)(FTexture *tex, int x)) +{ + if (!rw_pic->bMasked) // Textures that aren't masked can use the faster wallscan. + { + wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, rw_pic, rw_offset, getcol); + } + else + { + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, rw_pic, rw_offset, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + { + setupmvline(bits); + line1 = domvline1; + line4 = domvline4; + }); + } +} + +void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, FTexture *rw_pic, fixed_t rw_offset, const BYTE *(*getcol)(FTexture *tex, int x)) +{ + static fixed_t(*tmvline1)(); + static void(*tmvline4)(); + if (!R_GetTransMaskDrawers(&tmvline1, &tmvline4)) + { + // The current translucency is unsupported, so draw with regular maskwallscan instead. + maskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, rw_pic, rw_offset, getcol); + } + else + { + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, rw_pic, rw_offset, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + { + setuptmvline(bits); + line1 = reinterpret_cast(tmvline1); + line4 = tmvline4; + }); + } +} + +///////////////////////////////////////////////////////////////////////////// + +void R_FillTransColumn_C(int x, int y1, int y2, int color, int alpha) +{ + fixed_t fglevel, bglevel; + DWORD *fg2rgb; + DWORD *bg2rgb; + int spacing; + BYTE *dest; + DWORD fg; + + fglevel = ((alpha + 1) << 8) & ~0x3ff; + bglevel = FRACUNIT - fglevel; + fg2rgb = Col2RGB8[fglevel >> 10]; + bg2rgb = Col2RGB8[bglevel >> 10]; + fg = fg2rgb[color]; + + spacing = dc_pitch; + + int ycount = y2 - y1 + 1; + dest = ylookup[y1] + x + dc_destorg; + for (int y = 0; y < ycount; y++) + { + DWORD bg = bg2rgb[*dest]; + bg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[bg & (bg >> 15)]; + dest += spacing; + } +} + +///////////////////////////////////////////////////////////////////////////// + +// +// R_DrawMaskedColumn +// Used for sprites and masked mid textures. +// Masked means: partly transparent, i.e. stored +// in posts/runs of opaque pixels. +// +short* dc_mfloorclip; +short* dc_mceilingclip; + +double dc_spryscale; +double dc_sprtopscreen; + +bool dc_sprflipvert; + +void R_DrawMaskedColumn(int x, const BYTE *column, const FTexture::Span *span) +{ + int pixelsize = r_swtruecolor ? 4 : 1; + const fixed_t centeryfrac = FLOAT2FIXED(CenterY); + const fixed_t texturemid = FLOAT2FIXED(dc_texturemid); + while (span->Length != 0) + { + const int length = span->Length; + const int top = span->TopOffset; + + fixed_t texturefrac = dc_texturefrac; + fixed_t iscale = dc_iscale; + + // calculate unclipped screen coordinates for post + int yl = xs_RoundToInt(dc_sprtopscreen + dc_spryscale * top); + int yh = xs_RoundToInt(dc_sprtopscreen + dc_spryscale * (top + length)) - 1; + + if (dc_sprflipvert) + { + swapvalues(yl, yh); + } + + if (yh >= dc_mfloorclip[x]) + { + yh = dc_mfloorclip[x] - 1; + } + if (yl < dc_mceilingclip[x]) + { + yl = dc_mceilingclip[x]; + } + + if (yl <= yh) + { + if (dc_sprflipvert) + { + texturefrac = (yl*iscale) - (top << FRACBITS) + - FixedMul(centeryfrac, iscale) - texturemid; + const fixed_t maxfrac = length << FRACBITS; + while (texturefrac >= maxfrac) + { + if (++yl > yh) + goto nextpost; + texturefrac += iscale; + } + fixed_t endfrac = texturefrac + (yh - yl)*iscale; + while (endfrac < 0) + { + if (--yh < yl) + goto nextpost; + endfrac -= iscale; + } + } + else + { + texturefrac = texturemid - (top << FRACBITS) + + (yl*iscale) - FixedMul(centeryfrac - FRACUNIT, iscale); + while (texturefrac < 0) + { + if (++yl > yh) + goto nextpost; + texturefrac += iscale; + } + fixed_t endfrac = texturefrac + (yh - yl)*iscale; + const fixed_t maxfrac = length << FRACBITS; + if (yh < dc_mfloorclip[x] - 1 && endfrac < maxfrac - iscale) + { + yh++; + } + else while (endfrac >= maxfrac) + { + if (--yh < yl) + goto nextpost; + endfrac -= iscale; + } + } + + dc_yl = yl; + dc_yh = yh; + dc_x = x; + dc_texturefrac = texturefrac; + dc_iscale = iscale; + dc_source = column + top; + dc_count = yh - yl + 1; + dc_dest = (ylookup[yl] + x) * pixelsize + dc_destorg; + colfunc(); + } + nextpost: + span++; + } +} diff --git a/src/r_draw.h b/src/r_draw.h index a31183405..c22c958d0 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -25,6 +25,11 @@ #include "r_defs.h" +// Prevents files outside the DrawerContext class getting good ideas about +// accessing the private globals. Any drawer actions should be facilitated +// via the DrawerContext class! +#ifdef DRAWER_INTERNALS + // Spectre/Invisibility. #define FUZZTABLE 50 extern "C" int fuzzoffset[FUZZTABLE + 1]; // [RH] +1 for the assembly routine @@ -71,6 +76,7 @@ extern "C" fixed_t dc_destalpha; // first pixel in a column extern "C" const BYTE* dc_source; +extern DCanvas *dc_canvas; extern "C" BYTE *dc_dest, *dc_destorg; extern "C" int dc_count; @@ -86,6 +92,23 @@ extern "C" unsigned int dc_tspans[4][MAXHEIGHT]; extern "C" unsigned int *dc_ctspan[4]; extern "C" unsigned int horizspans[4]; +// +// Function pointers to switch refresh/drawing functions. +// Used to select shadow mode etc. +// +extern void (*colfunc) (void); +extern void (*basecolfunc) (void); +extern void (*fuzzcolfunc) (void); +extern void (*transcolfunc) (void); +// No shadow effects on floors. +extern void (*spanfunc) (void); + +// [RH] Function pointers for the horizontal column drawers. +extern void (*hcolfunc_pre) (void); +extern void (*hcolfunc_post1) (int hx, int sx, int yl, int yh); +extern void (*hcolfunc_post2) (int hx, int sx, int yl, int yh); +extern void (*hcolfunc_post4) (int sx, int yl, int yh); + // [RH] Pointers to the different column and span drawers... // The span blitting interface. @@ -116,7 +139,7 @@ extern void (*R_DrawTranslatedColumn)(void); // Span drawing for rows, floor/ceiling. No Spectre effect needed. extern void (*R_DrawSpan)(void); void R_SetupSpanBits(FTexture *tex); -void R_SetSpanColormap(FDynamicColormap *colormap, int shade); +void R_SetSpanColormap(); void R_SetSpanSource(const BYTE *pixels); // Span drawing for masked textures. @@ -281,6 +304,15 @@ void R_FillColumnP_C (void); void R_FillColumnHorizP_C (void); void R_FillSpan_C (void); +// vars for R_DrawMaskedColumn +extern short* dc_mfloorclip; +extern short* dc_mceilingclip; +extern double dc_spryscale; +extern double dc_sprtopscreen; +extern bool dc_sprflipvert; + +void R_DrawMaskedColumn(int x, const BYTE *column, const FTexture::Span *spans); + #ifdef X86_ASM #define R_SetupDrawSlab R_SetupDrawSlabA #define R_DrawSlab R_DrawSlabA @@ -325,12 +357,7 @@ void R_InitShadeMaps(); void R_InitFuzzTable (int fuzzoff); // [RH] Consolidate column drawer selection -enum ESPSResult -{ - DontDraw, // not useful to draw this - DoDraw0, // draw this as if r_columnmethod is 0 - DoDraw1, // draw this as if r_columnmethod is 1 -}; +enum ESPSResult; ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, DWORD color); inline ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translation, DWORD color) { @@ -353,18 +380,6 @@ extern void(*tmvline4_revsubclamp)(); // transmaskwallscan calls this to find out what column drawers to use bool R_GetTransMaskDrawers (fixed_t (**tmvline1)(), void (**tmvline4)()); -// Retrieve column data for wallscan. Should probably be removed -// to just use the texture's GetColumn() method. It just exists -// for double-layer skies. -const BYTE *R_GetColumn (FTexture *tex, int col); -void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); - -// maskwallscan is exactly like wallscan but does not draw anything where the texture is color 0. -void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); - -// transmaskwallscan is like maskwallscan, but it can also blend to the background -void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); - // Sets dc_colormap and dc_light to their appropriate values depending on the output format (pal vs true color) void R_SetColorMapLight(FColormap *base_colormap, float light, int shade); @@ -373,4 +388,40 @@ void R_SetDSColorMapLight(FColormap *base_colormap, float light, int shade); void R_SetTranslationMap(lighttable_t *translation); +// Retrieve column data for wallscan. Should probably be removed +// to just use the texture's GetColumn() method. It just exists +// for double-layer skies. +const BYTE *R_GetColumn (FTexture *tex, int col); +void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, FTexture *rw_pic, fixed_t rw_offset, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); + +// maskwallscan is exactly like wallscan but does not draw anything where the texture is color 0. +void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, FTexture *rw_pic, fixed_t rw_offset, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); + +// transmaskwallscan is like maskwallscan, but it can also blend to the background +void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, FTexture *rw_pic, fixed_t rw_offset, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); + +extern void(*R_DrawColoredSpan)(int y, int x1, int x2); +extern void(*R_DrawTiltedSpan)(int y, int x1, int x2); + +void R_DrawTiltedSpan_C(int y, int x1, int x2); +void R_DrawTiltedSpan_rgba(int y, int x1, int x2); +void R_DrawColoredSpan_C(int y, int x1, int x2); +void R_DrawColoredSpan_rgba(int y, int x1, int x2); + +extern FVector3 ds_plane_sz, ds_plane_su, ds_plane_sv; +extern bool ds_plane_shade; +extern float ds_planelightfloat; +extern fixed_t ds_pviewx, ds_pviewy; +extern int ds_planeshade; + +extern "C" BYTE *tiltlighting[MAXWIDTH]; +extern "C" { void R_CalcTiltedLighting(double lval, double lend, int width); } + +struct vissprite_t; +extern void(*R_FillTransColumn)(int x, int y1, int y2, int color, int alpha); +void R_FillTransColumn_C(int x, int y1, int y2, int color, int alpha); +void R_FillTransColumn_rgba(int x, int y1, int y2, int color, int alpha); + +#endif + #endif diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 2062609b4..420b63dff 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -21,6 +21,8 @@ // //----------------------------------------------------------------------------- +#define DRAWER_INTERNALS + #include #include "templates.h" @@ -3492,6 +3494,158 @@ public: } }; +class DrawTiltedSpanRGBACommand : public DrawerCommand +{ + int _y; + int _x1; + int _x2; + BYTE *dc_destorg; + fixed_t dc_light; + ShadeConstants dc_shade_constants; + const BYTE *ds_source; + +public: + DrawTiltedSpanRGBACommand(int y, int x1, int x2) + { + _y = y; + _x1 = x1; + _x2 = x2; + + dc_destorg = ::dc_destorg; + ds_source = ::ds_source; + } + + void Execute(DrawerThread *thread) override + { + if (thread->line_skipped_by_thread(_y)) + return; + + int y = _y; + int x1 = _x1; + int x2 = _x2; + + // Slopes are broken currently in master. + // Until R_DrawTiltedPlane is fixed we are just going to fill with a solid color. + + uint32_t *source = (uint32_t*)ds_source; + uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg; + + int count = x2 - x1 + 1; + while (count > 0) + { + *(dest++) = source[0]; + count--; + } + } +}; + +class DrawColoredSpanRGBACommand : public DrawerCommand +{ + int _y; + int _x1; + int _x2; + BYTE *dc_destorg; + fixed_t ds_light; + int ds_color; + +public: + DrawColoredSpanRGBACommand(int y, int x1, int x2) + { + _y = y; + _x1 = x1; + _x2 = x2; + + dc_destorg = ::dc_destorg; + ds_light = ::ds_light; + ds_color = ::ds_color; + } + + void Execute(DrawerThread *thread) override + { + if (thread->line_skipped_by_thread(_y)) + return; + + int y = _y; + int x1 = _x1; + int x2 = _x2; + + uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg; + int count = (x2 - x1 + 1); + uint32_t light = calc_light_multiplier(ds_light); + uint32_t color = shade_pal_index_simple(ds_color, light); + for (int i = 0; i < count; i++) + dest[i] = color; + } +}; + +class FillTransColumnRGBACommand : public DrawerCommand +{ + int _x; + int _y1; + int _y2; + int _color; + int _a; + BYTE *dc_destorg; + int dc_pitch; + fixed_t ds_light; + int ds_color; + +public: + FillTransColumnRGBACommand(int x, int y1, int y2, int color, int a) + { + _x = x; + _y1 = y1; + _y2 = y2; + _color = color; + _a = a; + + dc_destorg = ::dc_destorg; + dc_pitch = ::dc_pitch; + } + + void Execute(DrawerThread *thread) override + { + int x = _x; + int y1 = _y1; + int y2 = _y2; + int color = _color; + int a = _a; + + int ycount = thread->count_for_thread(y1, y2 - y1 + 1); + if (ycount <= 0) + return; + + uint32_t fg = GPalette.BaseColors[color].d; + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t alpha = a + 1; + uint32_t inv_alpha = 256 - alpha; + + fg_red *= alpha; + fg_green *= alpha; + fg_blue *= alpha; + + int spacing = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(y1, dc_pitch, ylookup[y1] + x + (uint32_t*)dc_destorg); + + for (int y = 0; y < ycount; y++) + { + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red * inv_alpha) / 256; + uint32_t green = (fg_green + bg_green * inv_alpha) / 256; + uint32_t blue = (fg_blue + bg_blue * inv_alpha) / 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += spacing; + } + } +}; + ApplySpecialColormapRGBACommand::ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen) { buffer = screen->GetBuffer(); @@ -3968,3 +4122,18 @@ void R_DrawFogBoundary_rgba(int x1, int x2, short *uclip, short *dclip) R_DrawFogBoundarySection_rgba(t2, b2, x1); } } + +void R_DrawTiltedSpan_rgba(int y, int x1, int x2) +{ + DrawerCommandQueue::QueueCommand(y, x1, x2); +} + +void R_DrawColoredSpan_rgba(int y, int x1, int x2) +{ + DrawerCommandQueue::QueueCommand(y, x1, x2); +} + +void R_FillTransColumn_rgba(int x, int y1, int y2, int color, int a) +{ + DrawerCommandQueue::QueueCommand(x, y1, y2, color, a); +} diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 47ea75260..a91b54d74 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -23,6 +23,11 @@ #ifndef __R_DRAW_RGBA__ #define __R_DRAW_RGBA__ +// Prevents files outside the DrawerContext class getting good ideas about +// accessing the private globals. Any drawer actions should be facilitated +// via the DrawerContext class! +#ifdef DRAWER_INTERNALS + #include "r_draw.h" #include "v_palette.h" #include @@ -487,3 +492,5 @@ FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) } #endif + +#endif diff --git a/src/r_drawer_context.cpp b/src/r_drawer_context.cpp new file mode 100644 index 000000000..3533a3e4f --- /dev/null +++ b/src/r_drawer_context.cpp @@ -0,0 +1,464 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id:$ +// +// Copyright (C) 1993-1996 by id Software, Inc. +// +// This source is available for distribution and/or modification +// only under the terms of the DOOM Source Code License as +// published by id Software. All rights reserved. +// +// The source is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License +// for more details. +// +// $Log:$ +// +// DESCRIPTION: +// The actual span/column drawing functions. +// Here find the main potential for optimization, +// e.g. inline assembly, different algorithms. +// +//----------------------------------------------------------------------------- + +#define DRAWER_INTERNALS + +#include + +#include "templates.h" +#include "doomdef.h" +#include "i_system.h" +#include "w_wad.h" +#include "r_local.h" +#include "v_video.h" +#include "doomstat.h" +#include "st_stuff.h" +#include "g_game.h" +#include "g_level.h" +#include "r_data/r_translate.h" +#include "v_palette.h" +#include "r_data/colormaps.h" +#include "r_plane.h" +#include "r_draw_rgba.h" +#include "d_net.h" +#include "r_drawer_context.h" + +#include "gi.h" +#include "stats.h" +#include "x86.h" + +#ifdef X86_ASM +extern "C" void R_SetSpanSource_ASM (const BYTE *flat); +extern "C" void R_SetSpanSize_ASM (int xbits, int ybits); +extern "C" void R_SetSpanColormap_ASM (BYTE *colormap); +extern "C" void R_SetTiltedSpanSource_ASM(const BYTE *flat); +extern "C" BYTE *ds_curcolormap, *ds_cursource, *ds_curtiltedsource; +#endif + +DCanvas *DrawerContext::Canvas() +{ + return dc_canvas; +} + +uint8_t DrawerContext::FlatColor() +{ + return dc_color; +} + +FColormap *DrawerContext::LightColormap() +{ + return dc_fcolormap; +} + +fixed_t DrawerContext::TextureFrac() +{ + return dc_texturefrac; +} + +fixed_t DrawerContext::TextureStep() +{ + return dc_iscale; +} + +double DrawerContext::TextureMid() +{ + return dc_texturemid; +} + +int DrawerContext::SpanXBits() +{ + return ds_xbits; +} + +int DrawerContext::SpanYBits() +{ + return ds_ybits; +} + +lighttable_t *DrawerContext::SpanLitColormap() +{ + return ds_colormap; +} + +bool DrawerContext::IsFuzzColumn() +{ + return colfunc == fuzzcolfunc; +} + +bool DrawerContext::IsFillColumn() +{ + return colfunc == R_FillColumn; +} + +bool DrawerContext::IsBaseColumn() +{ + return colfunc == basecolfunc; +} + +void DrawerContext::SetDest(int x, int y) +{ + int pixelsize = r_swtruecolor ? 4 : 1; + dc_dest = dc_destorg + (ylookup[y] + x) * pixelsize; +} + +void DrawerContext::SetFlatColor(uint8_t color_index) +{ + dc_color = color_index; +} + +void DrawerContext::SetLight(FColormap *base_colormap, float light, int shade) +{ + R_SetColorMapLight(base_colormap, light, shade); +} + +void DrawerContext::SetX(int x) +{ + dc_x = x; +} + +void DrawerContext::SetY1(int y) +{ + dc_yl = y; +} + +void DrawerContext::SetY2(int y) +{ + dc_yh = y; +} + +void DrawerContext::SetSource(const BYTE *source) +{ + dc_source = source; +} + +void DrawerContext::SetTextureFrac(fixed_t pos) +{ + dc_texturefrac = pos; +} + +void DrawerContext::SetTextureStep(fixed_t step) +{ + dc_iscale = step; +} + +void DrawerContext::SetTextureMid(double value) +{ + dc_texturemid = value; +} + +void DrawerContext::SetDrawCount(int count) +{ + dc_count = count; +} + +void DrawerContext::SetSpanY(int y) +{ + ds_y = y; +} + +void DrawerContext::SetSpanX1(int x) +{ + ds_x1 = x; +} + +void DrawerContext::SetSpanX2(int x) +{ + ds_x2 = x; +} + +void DrawerContext::SetSpanXStep(dsfixed_t step) +{ + ds_xstep = step; +} + +void DrawerContext::SetSpanYStep(dsfixed_t step) +{ + ds_ystep = step; +} + +void DrawerContext::SetSpanXBits(int bits) +{ + ds_xbits = bits; +} + +void DrawerContext::SetSpanYBits(int bits) +{ + ds_ybits = bits; +} + +void DrawerContext::SetSpanXFrac(dsfixed_t frac) +{ + ds_xfrac = frac; +} + +void DrawerContext::SetSpanYFrac(dsfixed_t frac) +{ + ds_yfrac = frac; +} + +void DrawerContext::SetSpanLight(FColormap *base_colormap, float light, int shade) +{ + R_SetDSColorMapLight(base_colormap ? base_colormap : &identitycolormap, light, shade); + R_SetSpanColormap(); +} + +ESPSResult DrawerContext::SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, DWORD color) +{ + return R_SetPatchStyle(style, alpha, translation, color); +} + +ESPSResult DrawerContext::SetPatchStyle(FRenderStyle style, float alpha, int translation, DWORD color) +{ + return R_SetPatchStyle(style, FLOAT2FIXED(alpha), translation, color); +} + +void DrawerContext::FinishSetPatchStyle() +{ + R_FinishSetPatchStyle(); +} + +void DrawerContext::SetCanvas(DCanvas *canvas) +{ + dc_canvas = canvas; + dc_destorg = canvas->GetBuffer(); + + if (r_swtruecolor != canvas->IsBgra()) + { + r_swtruecolor = canvas->IsBgra(); + R_InitColumnDrawers(); + } +} + +void DrawerContext::SetTranslationMap(lighttable_t *translation) +{ + R_SetTranslationMap(translation ? translation : identitymap); +} + +void DrawerContext::SetSpanSource(FTexture *tex) +{ + R_SetupSpanBits(tex); + if (r_swtruecolor) + ds_source = (const BYTE*)tex->GetPixelsBgra(); + else + ds_source = tex->GetPixels(); + +#ifdef X86_ASM + if (!r_swtruecolor && ds_source != ds_cursource) + { + R_SetSpanSource_ASM (ds_source); + } + if (!r_swtruecolor) + { + if (ds_source != ds_curtiltedsource) + R_SetTiltedSpanSource_ASM(ds_source); + } +#endif +} + +void DrawerContext::SetTiltedSpanState(FVector3 plane_sz, FVector3 plane_su, FVector3 plane_sv, bool plane_shade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) +{ + ds_plane_sz = plane_sz; + ds_plane_su = plane_su; + ds_plane_sv = plane_sv; + ds_plane_shade = plane_shade; + ds_planelightfloat = planelightfloat; + ds_pviewx = pviewx; + ds_pviewy = pviewy; + + if (!plane_shade) + { + for (int i = 0; i < viewwidth; ++i) + { + tiltlighting[i] = DrawerContext::SpanLitColormap(); + } + } +} + +void DrawerContext::SetSlabLight(const BYTE *colormap) +{ + R_SetupDrawSlab(colormap); +} + +void DrawerContext::DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *source, int dest_x, int dest_y) +{ + int pixelsize = r_swtruecolor ? 4 : 1; + R_DrawSlab(dx, v, dy, vi, source, (ylookup[dest_y] + dest_x) * pixelsize + dc_destorg); +} + +void DrawerContext::SetSpanStyle(fixed_t alpha, bool additive, bool masked) +{ + if (spanfunc != R_FillSpan) + { + if (masked) + { + if (alpha < OPAQUE || additive) + { + if (!additive) + { + spanfunc = R_DrawSpanMaskedTranslucent; + dc_srcblend = Col2RGB8[alpha >> 10]; + dc_destblend = Col2RGB8[(OPAQUE - alpha) >> 10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE - alpha; + } + else + { + spanfunc = R_DrawSpanMaskedAddClamp; + dc_srcblend = Col2RGB8_LessPrecision[alpha >> 10]; + dc_destblend = Col2RGB8_LessPrecision[FRACUNIT >> 10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE - alpha; + } + } + else + { + spanfunc = R_DrawSpanMasked; + } + } + else + { + if (alpha < OPAQUE || additive) + { + if (!additive) + { + spanfunc = R_DrawSpanTranslucent; + dc_srcblend = Col2RGB8[alpha >> 10]; + dc_destblend = Col2RGB8[(OPAQUE - alpha) >> 10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE - alpha; + } + else + { + spanfunc = R_DrawSpanAddClamp; + dc_srcblend = Col2RGB8_LessPrecision[alpha >> 10]; + dc_destblend = Col2RGB8_LessPrecision[FRACUNIT >> 10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE - alpha; + } + } + else + { + spanfunc = R_DrawSpan; + } + } + } +} + +void DrawerContext::RtInitCols(BYTE *buffer) +{ + rt_initcols(buffer); +} + +void DrawerContext::RtSpanCoverage(int x, int start, int stop) +{ + rt_span_coverage(x, start, stop); +} + +void DrawerContext::SetMaskedColumnState(short *mfloorclip, short *mceilingclip, double spryscale, double sprtopscreen, bool sprflipvert) +{ + dc_mfloorclip = mfloorclip; + dc_mceilingclip = mceilingclip; + dc_spryscale = spryscale; + dc_sprtopscreen = sprtopscreen; + dc_sprflipvert = sprflipvert; +} + +void DrawerContext::DrawMaskedColumn(int x, const BYTE *column, const FTexture::Span *spans) +{ + R_DrawMaskedColumn(x, column, spans); +} + +void DrawerContext::DrawMaskedColumnHoriz(int x, const BYTE *column, const FTexture::Span *spans) +{ + dc_x = x; + R_DrawMaskedColumnHoriz(column, spans); +} + +void DrawerContext::DrawFogBoundary(int x1, int x2, short *uclip, short *dclip) +{ + R_DrawFogBoundary(x1, x2, uclip, dclip); +} + +void DrawerContext::DrawRt4cols(int sx) +{ + rt_draw4cols(sx); +} + +void DrawerContext::DrawColumn() +{ + colfunc(); +} + +void DrawerContext::DrawSpan() +{ + spanfunc(); +} + +void DrawerContext::DrawHColumnPre() +{ + hcolfunc_pre(); +} + +void DrawerContext::DrawSimplePolySpan() +{ + R_DrawSpan(); +} + +void DrawerContext::SetBaseStyle() +{ + colfunc = basecolfunc; + hcolfunc_post1 = rt_map1col; + hcolfunc_post4 = rt_map4cols; +} + +void DrawerContext::DrawWall(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, FTexture *rw_pic, fixed_t rw_offset, const BYTE *(*getcol)(FTexture *tex, int col)) +{ + wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, rw_pic, rw_offset, getcol ? getcol : R_GetColumn); +} + +void DrawerContext::DrawMaskedWall(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, FTexture *rw_pic, fixed_t rw_offset, const BYTE *(*getcol)(FTexture *tex, int col)) +{ + maskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, rw_pic, rw_offset, getcol ? getcol : R_GetColumn); +} + +void DrawerContext::DrawTransMaskedWall(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, FTexture *rw_pic, fixed_t rw_offset, const BYTE *(*getcol)(FTexture *tex, int col)) +{ + transmaskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, rw_pic, rw_offset, getcol ? getcol : R_GetColumn); +} + +void DrawerContext::DrawColoredSpan(int y, int x1, int x2) +{ + R_DrawColoredSpan(y, x1, x2); +} + +void DrawerContext::DrawTiltedSpan(int y, int x1, int x2) +{ + R_DrawTiltedSpan(y, x1, x2); +} + +void DrawerContext::FillTransColumn(int x, int y1, int y2, int color, int alpha) +{ + R_FillTransColumn(x, y1, y2, color, alpha); +} diff --git a/src/r_drawer_context.h b/src/r_drawer_context.h new file mode 100644 index 000000000..64e0bf6a0 --- /dev/null +++ b/src/r_drawer_context.h @@ -0,0 +1,123 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id:$ +// +// Copyright (C) 1993-1996 by id Software, Inc. +// +// This source is available for distribution and/or modification +// only under the terms of the DOOM Source Code License as +// published by id Software. All rights reserved. +// +// The source is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License +// for more details. +// +// DESCRIPTION: +// System specific interface stuff. +// +//----------------------------------------------------------------------------- + + +#ifndef __R_DRAWER_CONTEXT__ +#define __R_DRAWER_CONTEXT__ + +#include "r_defs.h" + +// [RH] Consolidate column drawer selection +enum ESPSResult +{ + DontDraw, // not useful to draw this + DoDraw0, // draw this as if r_columnmethod is 0 + DoDraw1, // draw this as if r_columnmethod is 1 +}; + +struct TiltedPlaneData; + +// Immediate graphics context for column/span based software rendering. +class DrawerContext +{ +public: + static DCanvas *Canvas(); // dc_destorg + + static uint8_t FlatColor(); // dc_color + static FColormap *LightColormap(); // dc_fcolormap + static fixed_t TextureFrac(); // dc_texturefrac + static fixed_t TextureStep(); // dc_iscale + static double TextureMid(); // dc_texturemid + + static int SpanXBits(); // ds_xbits + static int SpanYBits(); // ds_ybits + static lighttable_t *SpanLitColormap(); // ds_colormap + + static bool IsFuzzColumn(); // colfunc == fuzzcolfunc + static bool IsFillColumn(); // colfunc == R_FillColumn + static bool IsBaseColumn(); // colfunc == basecolfunc + + static void SetCanvas(DCanvas *canvas); // dc_destorg + + static void SetFlatColor(uint8_t color_index); // dc_color + static void SetLight(FColormap *base_colormap, float light, int shade); + static void SetTranslationMap(lighttable_t *translation); + static void SetX(int x); // dc_x + static void SetY1(int y); // dc_yl + static void SetY2(int y); // dc_yh + static void SetSource(const BYTE *source); // dc_source + static void SetTextureFrac(fixed_t pos); // dc_texturefrac + static void SetTextureStep(fixed_t step); // dc_iscale + static void SetTextureMid(double value); // dc_texturemid + static void SetDest(int x, int y); // dc_dest + static void SetDrawCount(int count); // dc_count + + static void SetSpanY(int y); // ds_y + static void SetSpanX1(int x); // ds_x1 + static void SetSpanX2(int x); // ds_x2 + static void SetSpanXStep(dsfixed_t step); // ds_xstep + static void SetSpanYStep(dsfixed_t step); // ds_ystep + static void SetSpanXBits(int bits); // ds_xbits + static void SetSpanYBits(int bits); // ds_ybits + static void SetSpanXFrac(dsfixed_t frac); // ds_xfrac + static void SetSpanYFrac(dsfixed_t frac); // ds_yfrac + static void SetSpanLight(FColormap *base_colormap, float light, int shade); + static void SetSpanSource(FTexture *texture); + static void SetSpanStyle(fixed_t alpha, bool additive, bool masked); + + static void SetSlabLight(const BYTE *colormap); + + static ESPSResult SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, DWORD color); + static ESPSResult SetPatchStyle(FRenderStyle style, float alpha, int translation, DWORD color); + // Call this after finished drawing the current thing, in case its style was STYLE_Shade + static void SetBaseStyle(); + static void FinishSetPatchStyle(); + + static void SetMaskedColumnState(short *mfloorclip, short *mceilingclip, double spryscale, double sprtopscreen, bool sprflipvert); + static void SetTiltedSpanState(FVector3 plane_sz, FVector3 plane_su, FVector3 plane_sv, bool plane_shade, float planelightfloat, fixed_t pviewx, fixed_t pviewy); + + static void RtInitCols(BYTE *buffer); + static void RtSpanCoverage(int x, int start, int stop); + + static void DrawMaskedColumn(int x, const BYTE *column, const FTexture::Span *spans); + static void DrawMaskedColumnHoriz(int x, const BYTE *column, const FTexture::Span *spans); + + static void DrawRt4cols(int sx); + static void DrawColumn(); + static void DrawHColumnPre(); + static void DrawSpan(); + static void DrawSimplePolySpan(); + + static void DrawWall(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, FTexture *texture, fixed_t texturefrac, const BYTE *(*getcol)(FTexture *tex, int col) = nullptr); + static void DrawMaskedWall(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, FTexture *texture, fixed_t texturefrac, const BYTE *(*getcol)(FTexture *tex, int col) = nullptr); + static void DrawTransMaskedWall(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, FTexture *texture, fixed_t texturefrac, const BYTE *(*getcol)(FTexture *tex, int col) = nullptr); + + static void DrawColoredSpan(int y, int x1, int x2); + static void DrawTiltedSpan(int y, int x1, int x2); + + static void DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *source, int dest_x, int dest_y); + + static void FillTransColumn(int x, int y1, int y2, int color, int alpha); + + static void DrawFogBoundary(int x1, int x2, short *uclip, short *dclip); +}; + +#endif diff --git a/src/r_drawt.cpp b/src/r_drawt.cpp index 837093044..a74dc0133 100644 --- a/src/r_drawt.cpp +++ b/src/r_drawt.cpp @@ -38,6 +38,8 @@ ** Let's hope so. :-) */ +#define DRAWER_INTERNALS + #include "templates.h" #include "doomtype.h" #include "doomdef.h" @@ -1128,26 +1130,26 @@ void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span) const int top = span->TopOffset; // calculate unclipped screen coordinates for post - dc_yl = xs_RoundToInt(sprtopscreen + spryscale * top); - dc_yh = xs_RoundToInt(sprtopscreen + spryscale * (top + length) - 1); + dc_yl = xs_RoundToInt(dc_sprtopscreen + dc_spryscale * top); + dc_yh = xs_RoundToInt(dc_sprtopscreen + dc_spryscale * (top + length) - 1); - if (sprflipvert) + if (dc_sprflipvert) { swapvalues (dc_yl, dc_yh); } - if (dc_yh >= mfloorclip[dc_x]) + if (dc_yh >= dc_mfloorclip[dc_x]) { - dc_yh = mfloorclip[dc_x] - 1; + dc_yh = dc_mfloorclip[dc_x] - 1; } - if (dc_yl < mceilingclip[dc_x]) + if (dc_yl < dc_mceilingclip[dc_x]) { - dc_yl = mceilingclip[dc_x]; + dc_yl = dc_mceilingclip[dc_x]; } if (dc_yl <= dc_yh) { - if (sprflipvert) + if (dc_sprflipvert) { dc_texturefrac = (dc_yl*dc_iscale) - (top << FRACBITS) - fixed_t(CenterY * dc_iscale) - texturemid; @@ -1178,7 +1180,7 @@ void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span) } fixed_t endfrac = dc_texturefrac + (dc_yh-dc_yl)*dc_iscale; const fixed_t maxfrac = length << FRACBITS; - if (dc_yh < mfloorclip[dc_x]-1 && endfrac < maxfrac - dc_iscale) + if (dc_yh < dc_mfloorclip[dc_x]-1 && endfrac < maxfrac - dc_iscale) { dc_yh++; } @@ -1198,7 +1200,7 @@ nextpost: span++; } - if (sprflipvert) + if (dc_sprflipvert) { unsigned int *front = horizspan[dc_x&3]; unsigned int *back = dc_ctspan[dc_x&3] - 2; diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index d2d715c8d..4b6605b4a 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -34,6 +34,8 @@ ** Please see r_drawt.cpp for a description of the globals used. */ +#define DRAWER_INTERNALS + #include "templates.h" #include "doomtype.h" #include "doomdef.h" diff --git a/src/r_main.cpp b/src/r_main.cpp index 247a98125..a30aa232b 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -23,6 +23,8 @@ // //----------------------------------------------------------------------------- +#define DRAWER_INTERNALS + // HEADER FILES ------------------------------------------------------------ #include @@ -150,17 +152,6 @@ angle_t xtoviewangle[MAXWIDTH+1]; bool foggy; // [RH] ignore extralight and fullbright? int r_actualextralight; -void (*colfunc) (void); -void (*basecolfunc) (void); -void (*fuzzcolfunc) (void); -void (*transcolfunc) (void); -void (*spanfunc) (void); - -void (*hcolfunc_pre) (void); -void (*hcolfunc_post1) (int hx, int sx, int yl, int yh); -void (*hcolfunc_post2) (int hx, int sx, int yl, int yh); -void (*hcolfunc_post4) (int sx, int yl, int yh); - cycle_t WallCycles, PlaneCycles, MaskedCycles, WallScanCycles; // PRIVATE DATA DEFINITIONS ------------------------------------------------ @@ -820,6 +811,7 @@ void R_SetupBuffer () ASM_PatchPitch (); #endif } + dc_canvas = RenderTarget; dc_destorg = lineptr; for (int i = 0; i < RenderTarget->GetHeight(); i++) { diff --git a/src/r_main.h b/src/r_main.h index fa8fe0bb1..91eb5b183 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -110,22 +110,6 @@ extern FColormap* fixedcolormap; extern FSpecialColormap*realfixedcolormap; -// -// Function pointers to switch refresh/drawing functions. -// Used to select shadow mode etc. -// -extern void (*colfunc) (void); -extern void (*basecolfunc) (void); -extern void (*fuzzcolfunc) (void); -extern void (*transcolfunc) (void); -// No shadow effects on floors. -extern void (*spanfunc) (void); - -// [RH] Function pointers for the horizontal column drawers. -extern void (*hcolfunc_pre) (void); -extern void (*hcolfunc_post1) (int hx, int sx, int yl, int yh); -extern void (*hcolfunc_post2) (int hx, int sx, int yl, int yh); -extern void (*hcolfunc_post4) (int sx, int yl, int yh); void R_InitTextureMapping (); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 807066f77..c4d7cd59c 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -58,7 +58,7 @@ #include "r_3dfloors.h" #include "v_palette.h" #include "r_data/colormaps.h" -#include "r_draw_rgba.h" +#include "r_drawer_context.h" #ifdef _MSC_VER #pragma warning(disable:4244) @@ -138,8 +138,6 @@ FVector3 plane_sz, plane_su, plane_sv; float planelightfloat; bool plane_shade; fixed_t pviewx, pviewy; - -void R_DrawTiltedPlane_ASM (int y, int x1); } float yslope[MAXHEIGHT]; @@ -147,13 +145,6 @@ static fixed_t xscale, yscale; static double xstepscale, ystepscale; static double basexfrac, baseyfrac; -#ifdef X86_ASM -extern "C" void R_SetSpanSource_ASM (const BYTE *flat); -extern "C" void R_SetSpanSize_ASM (int xbits, int ybits); -extern "C" void R_SetSpanColormap_ASM (BYTE *colormap); -extern "C" void R_SetTiltedSpanSource_ASM (const BYTE *flat); -extern "C" BYTE *ds_curcolormap, *ds_cursource, *ds_curtiltedsource; -#endif void R_DrawSinglePlane (visplane_t *, fixed_t alpha, bool additive, bool masked); //========================================================================== @@ -220,304 +211,22 @@ void R_MapPlane (int y, int x1) distance = planeheight * yslope[y]; - ds_xstep = xs_ToFixed(32-ds_xbits, distance * xstepscale); - ds_ystep = xs_ToFixed(32-ds_ybits, distance * ystepscale); - ds_xfrac = xs_ToFixed(32-ds_xbits, distance * basexfrac) + pviewx; - ds_yfrac = xs_ToFixed(32-ds_ybits, distance * baseyfrac) + pviewy; + DrawerContext::SetSpanXStep(xs_ToFixed(32 - DrawerContext::SpanXBits(), distance * xstepscale)); + DrawerContext::SetSpanYStep(xs_ToFixed(32 - DrawerContext::SpanYBits(), distance * ystepscale)); + DrawerContext::SetSpanXFrac(xs_ToFixed(32 - DrawerContext::SpanXBits(), distance * basexfrac) + pviewx); + DrawerContext::SetSpanYFrac(xs_ToFixed(32 - DrawerContext::SpanYBits(), distance * baseyfrac) + pviewy); if (plane_shade) { // Determine lighting based on the span's distance from the viewer. - R_SetDSColorMapLight(basecolormap, GlobVis * fabs(CenterY - y), planeshade); + DrawerContext::SetSpanLight(basecolormap, GlobVis * fabs(CenterY - y), planeshade); } -#ifdef X86_ASM - if (!r_swtruecolor && ds_colormap != ds_curcolormap) - R_SetSpanColormap_ASM (ds_colormap); -#endif + DrawerContext::SetSpanY(y); + DrawerContext::SetSpanX1(x1); + DrawerContext::SetSpanX2(x2); - ds_y = y; - ds_x1 = x1; - ds_x2 = x2; - - spanfunc (); -} - -//========================================================================== -// -// R_CalcTiltedLighting -// -// Calculates the lighting for one row of a tilted plane. If the definition -// of GETPALOOKUP changes, this needs to change, too. -// -//========================================================================== - -extern "C" { -void R_CalcTiltedLighting (double lval, double lend, int width) -{ - double lstep; - BYTE *lightfiller; - BYTE *basecolormapdata = basecolormap->Maps; - int i = 0; - - if (width == 0 || lval == lend) - { // Constant lighting - lightfiller = basecolormapdata + (GETPALOOKUP(lval, planeshade) << COLORMAPSHIFT); - } - else - { - lstep = (lend - lval) / width; - if (lval >= MAXLIGHTVIS) - { // lval starts "too bright". - lightfiller = basecolormapdata + (GETPALOOKUP(lval, planeshade) << COLORMAPSHIFT); - for (; i <= width && lval >= MAXLIGHTVIS; ++i) - { - tiltlighting[i] = lightfiller; - lval += lstep; - } - } - if (lend >= MAXLIGHTVIS) - { // lend ends "too bright". - lightfiller = basecolormapdata + (GETPALOOKUP(lend, planeshade) << COLORMAPSHIFT); - for (; width > i && lend >= MAXLIGHTVIS; --width) - { - tiltlighting[width] = lightfiller; - lend -= lstep; - } - } - if (width > 0) - { - lval = FIXED2DBL(planeshade) - lval; - lend = FIXED2DBL(planeshade) - lend; - lstep = (lend - lval) / width; - if (lstep < 0) - { // Going from dark to light - if (lval < 1.) - { // All bright - lightfiller = basecolormapdata; - } - else - { - if (lval >= NUMCOLORMAPS) - { // Starts beyond the dark end - BYTE *clight = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT); - while (lval >= NUMCOLORMAPS && i <= width) - { - tiltlighting[i++] = clight; - lval += lstep; - } - if (i > width) - return; - } - while (i <= width && lval >= 0) - { - tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT); - lval += lstep; - } - lightfiller = basecolormapdata; - } - } - else - { // Going from light to dark - if (lval >= (NUMCOLORMAPS-1)) - { // All dark - lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT); - } - else - { - while (lval < 0 && i <= width) - { - tiltlighting[i++] = basecolormapdata; - lval += lstep; - } - if (i > width) - return; - while (i <= width && lval < (NUMCOLORMAPS-1)) - { - tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT); - lval += lstep; - } - lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT); - } - } - } - } - for (; i <= width; i++) - { - tiltlighting[i] = lightfiller; - } -} -} // extern "C" - -//========================================================================== -// -// R_MapTiltedPlane -// -//========================================================================== - -void R_MapTiltedPlane_C (int y, int x1) -{ - int x2 = spanend[y]; - int width = x2 - x1; - double iz, uz, vz; - BYTE *fb; - DWORD u, v; - int i; - - iz = plane_sz[2] + plane_sz[1]*(centery-y) + plane_sz[0]*(x1-centerx); - - // Lighting is simple. It's just linear interpolation from start to end - if (plane_shade) - { - uz = (iz + plane_sz[0]*width) * planelightfloat; - vz = iz * planelightfloat; - R_CalcTiltedLighting (vz, uz, width); - } - - uz = plane_su[2] + plane_su[1]*(centery-y) + plane_su[0]*(x1-centerx); - vz = plane_sv[2] + plane_sv[1]*(centery-y) + plane_sv[0]*(x1-centerx); - - fb = ylookup[y] + x1 + dc_destorg; - - BYTE vshift = 32 - ds_ybits; - BYTE ushift = vshift - ds_xbits; - int umask = ((1 << ds_xbits) - 1) << ds_ybits; - -#if 0 // The "perfect" reference version of this routine. Pretty slow. - // Use it only to see how things are supposed to look. - i = 0; - do - { - double z = 1.f/iz; - - u = SQWORD(uz*z) + pviewx; - v = SQWORD(vz*z) + pviewy; - R_SetDSColorMapLight(tiltlighting[i], 0, 0); - fb[i++] = ds_colormap[ds_source[(v >> vshift) | ((u >> ushift) & umask)]]; - iz += plane_sz[0]; - uz += plane_su[0]; - vz += plane_sv[0]; - } while (--width >= 0); -#else -//#define SPANSIZE 32 -//#define INVSPAN 0.03125f -//#define SPANSIZE 8 -//#define INVSPAN 0.125f -#define SPANSIZE 16 -#define INVSPAN 0.0625f - - double startz = 1.f/iz; - double startu = uz*startz; - double startv = vz*startz; - double izstep, uzstep, vzstep; - - izstep = plane_sz[0] * SPANSIZE; - uzstep = plane_su[0] * SPANSIZE; - vzstep = plane_sv[0] * SPANSIZE; - x1 = 0; - width++; - - while (width >= SPANSIZE) - { - iz += izstep; - uz += uzstep; - vz += vzstep; - - double endz = 1.f/iz; - double endu = uz*endz; - double endv = vz*endz; - DWORD stepu = SQWORD((endu - startu) * INVSPAN); - DWORD stepv = SQWORD((endv - startv) * INVSPAN); - u = SQWORD(startu) + pviewx; - v = SQWORD(startv) + pviewy; - - for (i = SPANSIZE-1; i >= 0; i--) - { - fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); - x1++; - u += stepu; - v += stepv; - } - startu = endu; - startv = endv; - width -= SPANSIZE; - } - if (width > 0) - { - if (width == 1) - { - u = SQWORD(startu); - v = SQWORD(startv); - fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); - } - else - { - double left = width; - iz += plane_sz[0] * left; - uz += plane_su[0] * left; - vz += plane_sv[0] * left; - - double endz = 1.f/iz; - double endu = uz*endz; - double endv = vz*endz; - left = 1.f/left; - DWORD stepu = SQWORD((endu - startu) * left); - DWORD stepv = SQWORD((endv - startv) * left); - u = SQWORD(startu) + pviewx; - v = SQWORD(startv) + pviewy; - - for (; width != 0; width--) - { - fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); - x1++; - u += stepu; - v += stepv; - } - } - } -#endif -} - -void R_MapTiltedPlane_rgba (int y, int x1) -{ - int x2 = spanend[y]; - - // Slopes are broken currently in master. - // Until R_DrawTiltedPlane is fixed we are just going to fill with a solid color. - - uint32_t *source = (uint32_t*)ds_source; - int source_width = 1 << ds_xbits; - int source_height = 1 << ds_ybits; - - uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg; - - int count = x2 - x1 + 1; - while (count > 0) - { - *(dest++) = source[0]; - count--; - } -} - -//========================================================================== -// -// R_MapColoredPlane -// -//========================================================================== - -void R_MapColoredPlane_C (int y, int x1) -{ - memset (ylookup[y] + x1 + dc_destorg, ds_color, spanend[y] - x1 + 1); -} - -void R_MapColoredPlane_rgba(int y, int x1) -{ - uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg; - int count = (spanend[y] - x1 + 1); - uint32_t light = calc_light_multiplier(ds_light); - uint32_t color = shade_pal_index_simple(ds_color, light); - for (int i = 0; i < count; i++) - dest[i] = color; + DrawerContext::DrawSpan(); } //========================================================================== @@ -1014,7 +723,7 @@ static void R_DrawSky (visplane_t *pl) rw_offset = 0; frontyScale = rw_pic->Scale.Y; - dc_texturemid = skymid * frontyScale; + DrawerContext::SetTextureMid(skymid * frontyScale); if (1 << frontskytex->HeightBits == frontskytex->GetHeight()) { // The texture tiles nicely @@ -1023,8 +732,8 @@ static void R_DrawSky (visplane_t *pl) lastskycol[x] = 0xffffffff; lastskycol_bgra[x] = 0xffffffff; } - wallscan (pl->left, pl->right, (short *)pl->top, (short *)pl->bottom, swall, lwall, - frontyScale, backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns); + DrawerContext::DrawWall (pl->left, pl->right, (short *)pl->top, (short *)pl->bottom, swall, lwall, + frontyScale, rw_pic, rw_offset, backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns); } else { // The texture does not tile nicely @@ -1047,7 +756,7 @@ static void R_DrawSkyStriped (visplane_t *pl) if (topfrac < 0) topfrac += frontskytex->GetHeight(); yl = 0; yh = short((frontskytex->GetHeight() - topfrac) * frontyScale); - dc_texturemid = topfrac - iscale * (1 - CenterY); + DrawerContext::SetTextureMid(topfrac - iscale * (1 - CenterY)); while (yl < viewheight) { @@ -1061,11 +770,11 @@ static void R_DrawSkyStriped (visplane_t *pl) lastskycol[x] = 0xffffffff; lastskycol_bgra[x] = 0xffffffff; } - wallscan (pl->left, pl->right, top, bot, swall, lwall, rw_pic->Scale.Y, - backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns); + DrawerContext::DrawWall(pl->left, pl->right, top, bot, swall, lwall, rw_pic->Scale.Y, + rw_pic, rw_offset, backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns); yl = yh; yh += drawheight; - dc_texturemid = iscale * (centery-yl-1); + DrawerContext::SetTextureMid(iscale * (centery-yl-1)); } } @@ -1086,7 +795,7 @@ int R_DrawPlanes () int i; int vpcount = 0; - ds_color = 3; + DrawerContext::SetFlatColor(3); for (i = 0; i < MAXVISPLANES; i++) { @@ -1111,7 +820,7 @@ void R_DrawHeightPlanes(double height) visplane_t *pl; int i; - ds_color = 3; + DrawerContext::SetFlatColor(3); DVector3 oViewPos = ViewPos; DAngle oViewAngle = ViewAngle; @@ -1151,8 +860,8 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske if (r_drawflat) { // [RH] no texture mapping - ds_color += 4; - R_MapVisPlane (pl, R_MapColoredPlane); + DrawerContext::SetFlatColor(DrawerContext::FlatColor() + 4); + R_MapVisPlane (pl, [](int y, int x1) { DrawerContext::DrawColoredSpan(y, x1, spanend[y]); }); } else if (pl->picnum == skyflatnum) { // sky flat @@ -1175,13 +884,9 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske { // Don't waste time on a masked texture if it isn't really masked. masked = false; } - R_SetupSpanBits(tex); double xscale = pl->xform.xScale * tex->Scale.X; double yscale = pl->xform.yScale * tex->Scale.Y; - if (r_swtruecolor) - ds_source = (const BYTE*)tex->GetPixelsBgra(); - else - ds_source = tex->GetPixels(); + DrawerContext::SetSpanSource(tex); basecolormap = pl->colormap; planeshade = LIGHT2SHADE(pl->lightlevel); @@ -1544,13 +1249,13 @@ void R_DrawSkyPlane (visplane_t *pl) bool fakefixed = false; if (fixedcolormap) { - R_SetColorMapLight(fixedcolormap, 0, 0); + DrawerContext::SetLight(fixedcolormap, 0, 0); } else { fakefixed = true; fixedcolormap = &NormalLight; - R_SetColorMapLight(fixedcolormap, 0, 0); + DrawerContext::SetLight(fixedcolormap, 0, 0); } R_DrawSky (pl); @@ -1567,13 +1272,6 @@ void R_DrawSkyPlane (visplane_t *pl) void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked) { -#ifdef X86_ASM - if (!r_swtruecolor && ds_source != ds_cursource) - { - R_SetSpanSource_ASM (ds_source); - } -#endif - if (alpha <= 0) { return; @@ -1583,8 +1281,8 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t double xstep, ystep, leftxfrac, leftyfrac, rightxfrac, rightyfrac; double x; - xscale = xs_ToFixed(32 - ds_xbits, _xscale); - yscale = xs_ToFixed(32 - ds_ybits, _yscale); + xscale = xs_ToFixed(32 - DrawerContext::SpanXBits(), _xscale); + yscale = xs_ToFixed(32 - DrawerContext::SpanYBits(), _yscale); if (planeang != 0) { double cosine = cos(planeang), sine = sin(planeang); @@ -1631,15 +1329,14 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t planeheight = fabs(pl->height.Zat0() - ViewPos.Z); GlobVis = r_FloorVisibility / planeheight; - ds_light = 0; if (fixedlightlev >= 0) { - R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + DrawerContext::SetSpanLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); plane_shade = false; } else if (fixedcolormap) { - R_SetDSColorMapLight(fixedcolormap, 0, 0); + DrawerContext::SetSpanLight(fixedcolormap, 0, 0); plane_shade = false; } else @@ -1647,61 +1344,8 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t plane_shade = true; } - if (spanfunc != R_FillSpan) - { - if (masked) - { - if (alpha < OPAQUE || additive) - { - if (!additive) - { - spanfunc = R_DrawSpanMaskedTranslucent; - dc_srcblend = Col2RGB8[alpha>>10]; - dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10]; - dc_srcalpha = alpha; - dc_destalpha = OPAQUE - alpha; - } - else - { - spanfunc = R_DrawSpanMaskedAddClamp; - dc_srcblend = Col2RGB8_LessPrecision[alpha>>10]; - dc_destblend = Col2RGB8_LessPrecision[FRACUNIT>>10]; - dc_srcalpha = alpha; - dc_destalpha = OPAQUE - alpha; - } - } - else - { - spanfunc = R_DrawSpanMasked; - } - } - else - { - if (alpha < OPAQUE || additive) - { - if (!additive) - { - spanfunc = R_DrawSpanTranslucent; - dc_srcblend = Col2RGB8[alpha>>10]; - dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10]; - dc_srcalpha = alpha; - dc_destalpha = OPAQUE - alpha; - } - else - { - spanfunc = R_DrawSpanAddClamp; - dc_srcblend = Col2RGB8_LessPrecision[alpha>>10]; - dc_destblend = Col2RGB8_LessPrecision[FRACUNIT>>10]; - dc_srcalpha = alpha; - dc_destalpha = OPAQUE - alpha; - } - } - else - { - spanfunc = R_DrawSpan; - } - } - } + DrawerContext::SetSpanStyle(alpha, additive, masked); + R_MapVisPlane (pl, R_MapPlane); } @@ -1733,14 +1377,14 @@ void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t return; } - lxscale = _xscale * ifloatpow2[ds_xbits]; - lyscale = _yscale * ifloatpow2[ds_ybits]; + lxscale = _xscale * ifloatpow2[DrawerContext::SpanXBits()]; + lyscale = _yscale * ifloatpow2[DrawerContext::SpanYBits()]; xscale = 64.f / lxscale; yscale = 64.f / lyscale; zeroheight = pl->height.ZatPoint(ViewPos); - pviewx = xs_ToFixed(32 - ds_xbits, pl->xform.xOffs * pl->xform.xScale); - pviewy = xs_ToFixed(32 - ds_ybits, pl->xform.yOffs * pl->xform.yScale); + pviewx = xs_ToFixed(32 - DrawerContext::SpanXBits(), pl->xform.xOffs * pl->xform.xScale); + pviewy = xs_ToFixed(32 - DrawerContext::SpanYBits(), pl->xform.yOffs * pl->xform.yScale); planeang = (pl->xform.Angle + pl->xform.baseAngle).Radians(); // p is the texture origin in view space @@ -1810,42 +1454,22 @@ void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t if (fixedlightlev >= 0) { - R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + DrawerContext::SetSpanLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); plane_shade = false; } else if (fixedcolormap) { - R_SetDSColorMapLight(fixedcolormap, 0, 0); + DrawerContext::SetSpanLight(fixedcolormap, 0, 0); plane_shade = false; } else { - R_SetDSColorMapLight(basecolormap, 0, 0); + DrawerContext::SetSpanLight(basecolormap, 0, 0); plane_shade = true; } - if (!plane_shade) - { - for (int i = 0; i < viewwidth; ++i) - { - tiltlighting[i] = ds_colormap; - } - } - -#if defined(X86_ASM) - if (!r_swtruecolor) - { - if (ds_source != ds_curtiltedsource) - R_SetTiltedSpanSource_ASM(ds_source); - R_MapVisPlane(pl, R_DrawTiltedPlane_ASM); - } - else - { - R_MapVisPlane(pl, R_MapTiltedPlane); - } -#else - R_MapVisPlane (pl, R_MapTiltedPlane); -#endif + DrawerContext::SetTiltedSpanState(plane_sz, plane_su, plane_sv, plane_shade, planelightfloat, pviewx, pviewy); + R_MapVisPlane (pl, [](int y, int x1) { DrawerContext::DrawTiltedSpan(y, x1, spanend[y]); }); } //========================================================================== diff --git a/src/r_plane.h b/src/r_plane.h index b199d3477..d4db3dc09 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -93,14 +93,6 @@ void R_DrawNormalPlane (visplane_t *pl, double xscale, double yscale, fixed_t al void R_DrawTiltedPlane (visplane_t *pl, double xscale, double yscale, fixed_t alpha, bool additive, bool masked); void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1)); -extern void(*R_MapColoredPlane)(int y, int x1); -extern void(*R_MapTiltedPlane)(int y, int x1); - -void R_MapTiltedPlane_C(int y, int x1); -void R_MapTiltedPlane_rgba(int y, int x); -void R_MapColoredPlane_C(int y, int x1); -void R_MapColoredPlane_rgba(int y, int x1); - visplane_t *R_FindPlane ( const secplane_t &height, FTextureID picnum, diff --git a/src/r_segs.cpp b/src/r_segs.cpp index ad242b2f9..2476e07ac 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -52,6 +52,7 @@ #include "r_3dfloors.h" #include "v_palette.h" #include "r_data/colormaps.h" +#include "r_drawer_context.h" #define WALLYREPEAT 8 @@ -172,19 +173,19 @@ CVAR(Bool, r_drawmirrors, true, 0) float *MaskedSWall; float MaskedScaleY; -static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FTexture::Span *spans), FTexture *tex) +static void BlastMaskedColumn (int x, void (*blastfunc)(int x, const BYTE *pixels, const FTexture::Span *spans), FTexture *tex) { // calculate lighting if (fixedcolormap == NULL && fixedlightlev < 0) { - R_SetColorMapLight(basecolormap, rw_light, wallshade); + DrawerContext::SetLight(basecolormap, rw_light, wallshade); } - dc_iscale = xs_Fix<16>::ToFix(MaskedSWall[dc_x] * MaskedScaleY); + DrawerContext::SetTextureStep(xs_Fix<16>::ToFix(MaskedSWall[x] * MaskedScaleY)); if (sprflipvert) - sprtopscreen = CenterY + dc_texturemid * spryscale; + sprtopscreen = CenterY + DrawerContext::TextureMid() * spryscale; else - sprtopscreen = CenterY - dc_texturemid * spryscale; + sprtopscreen = CenterY - DrawerContext::TextureMid() * spryscale; // killough 1/25/98: here's where Medusa came in, because // it implicitly assumed that the column was all one patch. @@ -194,10 +195,12 @@ static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FText // the Medusa effect. The fix is to construct true columns // when forming multipatched textures (see r_data.c). + DrawerContext::SetMaskedColumnState(mfloorclip, mceilingclip, spryscale, sprtopscreen, sprflipvert); + // draw the texture const FTexture::Span *spans; - const BYTE *pixels = tex->GetColumn (maskedtexturecol[dc_x] >> FRACBITS, &spans); - blastfunc (pixels, spans); + const BYTE *pixels = tex->GetColumn (maskedtexturecol[x] >> FRACBITS, &spans); + blastfunc (x, pixels, spans); rw_light += rw_lightstep; spryscale += rw_scalestep; } @@ -243,7 +246,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) // [RH] modified because we don't use user-definable translucency maps ESPSResult drawmode; - drawmode = R_SetPatchStyle (LegacyRenderStyles[curline->linedef->flags & ML_ADDTRANS ? STYLE_Add : STYLE_Translucent], + drawmode = DrawerContext::SetPatchStyle (LegacyRenderStyles[curline->linedef->flags & ML_ADDTRANS ? STYLE_Add : STYLE_Translucent], (float)MIN(curline->linedef->alpha, 1.), 0, 0); if ((drawmode == DontDraw && !ds->bFogBoundary && !ds->bFakeBoundary)) @@ -295,7 +298,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) // [RH] Draw fog partition if (ds->bFogBoundary) { - R_DrawFogBoundary (x1, x2, mceilingclip, mfloorclip); + DrawerContext::DrawFogBoundary (x1, x2, mceilingclip, mfloorclip); if (ds->maskedtexturecol == -1) { goto clearfog; @@ -313,9 +316,9 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) rw_scalestep = ds->iscalestep; if (fixedlightlev >= 0) - R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + DrawerContext::SetLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - R_SetColorMapLight(fixedcolormap, 0, 0); + DrawerContext::SetLight(fixedcolormap, 0, 0); // find positioning texheight = tex->GetScaledHeightDouble(); @@ -326,11 +329,11 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) } if (curline->linedef->flags & ML_DONTPEGBOTTOM) { - dc_texturemid = MAX(frontsector->GetPlaneTexZ(sector_t::floor), backsector->GetPlaneTexZ(sector_t::floor)) + texheight; + DrawerContext::SetTextureMid(MAX(frontsector->GetPlaneTexZ(sector_t::floor), backsector->GetPlaneTexZ(sector_t::floor)) + texheight); } else { - dc_texturemid = MIN(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling)); + DrawerContext::SetTextureMid(MIN(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling))); } rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid); @@ -349,21 +352,21 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) { // rowoffset is added before the multiply so that the masked texture will // still be positioned in world units rather than texels. - dc_texturemid += rowoffset - ViewPos.Z; - textop = dc_texturemid; - dc_texturemid *= MaskedScaleY; + DrawerContext::SetTextureMid(DrawerContext::TextureMid() + rowoffset - ViewPos.Z); + textop = DrawerContext::TextureMid(); + DrawerContext::SetTextureMid(DrawerContext::TextureMid() * MaskedScaleY); } else { // rowoffset is added outside the multiply so that it positions the texture // by texels instead of world units. - textop = dc_texturemid + rowoffset / MaskedScaleY - ViewPos.Z; - dc_texturemid = (dc_texturemid - ViewPos.Z) * MaskedScaleY + rowoffset; + textop = DrawerContext::TextureMid() + rowoffset / MaskedScaleY - ViewPos.Z; + DrawerContext::SetTextureMid((DrawerContext::TextureMid() - ViewPos.Z) * MaskedScaleY + rowoffset); } if (sprflipvert) { MaskedScaleY = -MaskedScaleY; - dc_texturemid -= tex->GetHeight() << FRACBITS; + DrawerContext::SetTextureMid(DrawerContext::TextureMid() - tex->GetHeight()); } // [RH] Don't bother drawing segs that are completely offscreen @@ -438,9 +441,9 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) // draw the columns one at a time if (drawmode == DoDraw0) { - for (dc_x = x1; dc_x < x2; ++dc_x) + for (int x = x1; x < x2; ++x) { - BlastMaskedColumn (R_DrawMaskedColumn, tex); + BlastMaskedColumn (x, DrawerContext::DrawMaskedColumn, tex); } } else @@ -451,29 +454,29 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) if (x1 >= x2) goto clearfog; - dc_x = x1; + int x = x1; - while ((dc_x < stop) && (dc_x & 3)) + while ((x < stop) && (x & 3)) { - BlastMaskedColumn (R_DrawMaskedColumn, tex); - dc_x++; + BlastMaskedColumn (x, DrawerContext::DrawMaskedColumn, tex); + x++; } - while (dc_x < stop) + while (x < stop) { - rt_initcols(nullptr); - BlastMaskedColumn (R_DrawMaskedColumnHoriz, tex); dc_x++; - BlastMaskedColumn (R_DrawMaskedColumnHoriz, tex); dc_x++; - BlastMaskedColumn (R_DrawMaskedColumnHoriz, tex); dc_x++; - BlastMaskedColumn (R_DrawMaskedColumnHoriz, tex); - rt_draw4cols (dc_x - 3); - dc_x++; + DrawerContext::RtInitCols(nullptr); + BlastMaskedColumn (x, DrawerContext::DrawMaskedColumnHoriz, tex); + BlastMaskedColumn (x + 1, DrawerContext::DrawMaskedColumnHoriz, tex); + BlastMaskedColumn (x + 2, DrawerContext::DrawMaskedColumnHoriz, tex); + BlastMaskedColumn (x + 3, DrawerContext::DrawMaskedColumnHoriz, tex); + DrawerContext::DrawRt4cols (x); + x += 4; } - while (dc_x < x2) + while (x < x2) { - BlastMaskedColumn (R_DrawMaskedColumn, tex); - dc_x++; + BlastMaskedColumn (x, DrawerContext::DrawMaskedColumn, tex); + x++; } } } @@ -483,13 +486,13 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) { // rowoffset is added before the multiply so that the masked texture will // still be positioned in world units rather than texels. - dc_texturemid = (dc_texturemid - ViewPos.Z + rowoffset) * MaskedScaleY; + DrawerContext::SetTextureMid((DrawerContext::TextureMid() - ViewPos.Z + rowoffset) * MaskedScaleY); } else { // rowoffset is added outside the multiply so that it positions the texture // by texels instead of world units. - dc_texturemid = (dc_texturemid - ViewPos.Z) * MaskedScaleY + rowoffset; + DrawerContext::SetTextureMid((DrawerContext::TextureMid() - ViewPos.Z) * MaskedScaleY + rowoffset); } WallC.sz1 = ds->sz1; @@ -535,7 +538,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) } clearfog: - R_FinishSetPatchStyle (); + DrawerContext::FinishSetPatchStyle (); if (ds->bFakeBoundary & 3) { R_RenderFakeWallRange(ds, x1, x2); @@ -567,11 +570,11 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) fixed_t Alpha = Scale(rover->alpha, OPAQUE, 255); ESPSResult drawmode; - drawmode = R_SetPatchStyle (LegacyRenderStyles[rover->flags & FF_ADDITIVETRANS ? STYLE_Add : STYLE_Translucent], + drawmode = DrawerContext::SetPatchStyle (LegacyRenderStyles[rover->flags & FF_ADDITIVETRANS ? STYLE_Add : STYLE_Translucent], Alpha, 0, 0); if(drawmode == DontDraw) { - R_FinishSetPatchStyle(); + DrawerContext::FinishSetPatchStyle(); return; } @@ -613,26 +616,26 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) { rowoffset += rw_pic->GetHeight(); } - dc_texturemid = (planez - ViewPos.Z) * yscale; + DrawerContext::SetTextureMid((planez - ViewPos.Z) * yscale); if (rw_pic->bWorldPanning) { // rowoffset is added before the multiply so that the masked texture will // still be positioned in world units rather than texels. - dc_texturemid = dc_texturemid + rowoffset * yscale; + DrawerContext::SetTextureMid(DrawerContext::TextureMid() + rowoffset * yscale); rw_offset = xs_RoundToInt(rw_offset * xscale); } else { // rowoffset is added outside the multiply so that it positions the texture // by texels instead of world units. - dc_texturemid += rowoffset; + DrawerContext::SetTextureMid(DrawerContext::TextureMid() + rowoffset); } if (fixedlightlev >= 0) - R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + DrawerContext::SetLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - R_SetColorMapLight(fixedcolormap, 0, 0); + DrawerContext::SetLight(fixedcolormap, 0, 0); WallC.sz1 = ds->sz1; WallC.sz2 = ds->sz2; @@ -660,7 +663,7 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) PrepLWall (lwall, curline->sidedef->TexelLength*xscale, ds->sx1, ds->sx2); wallscan_np2_ds(ds, x1, x2, wallupper, walllower, MaskedSWall, lwall, yscale); - R_FinishSetPatchStyle(); + DrawerContext::FinishSetPatchStyle(); } // kg3D - walls of fake floors @@ -1065,360 +1068,6 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2) return; } -// Draw a column with support for non-power-of-two ranges -uint32_t wallscan_drawcol1(int x, int y1, int y2, uint32_t uv_start, uint32_t uv_step, uint32_t uv_max, const BYTE *source, DWORD(*draw1column)()) -{ - int pixelsize = r_swtruecolor ? 4 : 1; - if (uv_max == 0) // power of two - { - int count = y2 - y1; - - dc_source = source; - dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; - dc_count = count; - dc_iscale = uv_step; - dc_texturefrac = uv_start; - draw1column(); - - uint64_t step64 = uv_step; - uint64_t pos64 = uv_start; - return (uint32_t)(pos64 + step64 * count); - } - else - { - uint32_t uv_pos = uv_start; - - uint32_t left = y2 - y1; - while (left > 0) - { - uint32_t available = uv_max - uv_pos; - uint32_t next_uv_wrap = available / uv_step; - if (available % uv_step != 0) - next_uv_wrap++; - uint32_t count = MIN(left, next_uv_wrap); - - dc_source = source; - dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; - dc_count = count; - dc_iscale = uv_step; - dc_texturefrac = uv_pos; - draw1column(); - - left -= count; - uv_pos += uv_step * count; - if (uv_pos >= uv_max) - uv_pos -= uv_max; - } - - return uv_pos; - } -} - -// Draw four columns with support for non-power-of-two ranges -void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_step, uint32_t uv_max, const BYTE **source, void(*draw4columns)()) -{ - int pixelsize = r_swtruecolor ? 4 : 1; - if (uv_max == 0) // power of two, no wrap handling needed - { - int count = y2 - y1; - for (int i = 0; i < 4; i++) - { - bufplce[i] = source[i]; - vplce[i] = uv_pos[i]; - vince[i] = uv_step[i]; - - uint64_t step64 = uv_step[i]; - uint64_t pos64 = uv_pos[i]; - uv_pos[i] = (uint32_t)(pos64 + step64 * count); - } - dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; - dc_count = count; - draw4columns(); - } - else - { - dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; - for (int i = 0; i < 4; i++) - bufplce[i] = source[i]; - - uint32_t left = y2 - y1; - while (left > 0) - { - // Find which column wraps first - uint32_t count = left; - for (int i = 0; i < 4; i++) - { - uint32_t available = uv_max - uv_pos[i]; - uint32_t next_uv_wrap = available / uv_step[i]; - if (available % uv_step[i] != 0) - next_uv_wrap++; - count = MIN(next_uv_wrap, count); - } - - // Draw until that column wraps - for (int i = 0; i < 4; i++) - { - vplce[i] = uv_pos[i]; - vince[i] = uv_step[i]; - } - dc_count = count; - draw4columns(); - - // Wrap the uv position - for (int i = 0; i < 4; i++) - { - uv_pos[i] += uv_step[i] * count; - if (uv_pos[i] >= uv_max) - uv_pos[i] -= uv_max; - } - - left -= count; - } - } -} - -// Calculates a wrapped uv start position value for a column -void calc_uv_start_and_step(int y1, float swal, double yrepeat, uint32_t uv_height, int fracbits, uint32_t &uv_start_out, uint32_t &uv_step_out) -{ - double uv_stepd = swal * yrepeat; - - // Find start uv in [0-uv_height[ range. - // Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range. - double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / uv_height; - v = v - floor(v); - v *= uv_height; - v *= (1 << fracbits); - - uv_start_out = (uint32_t)v; - uv_step_out = xs_ToFixed(fracbits, uv_stepd); -} - -typedef DWORD(*Draw1ColumnFuncPtr)(); -typedef void(*Draw4ColumnsFuncPtr)(); - -void wallscan_any( - int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, - const BYTE *(*getcol)(FTexture *tex, int x), - void(setupwallscan(int bits,Draw1ColumnFuncPtr &draw1, Draw4ColumnsFuncPtr &draw2))) -{ - if (rw_pic->UseType == FTexture::TEX_Null) - return; - - uint32_t uv_height = rw_pic->GetHeight(); - uint32_t fracbits = 32 - rw_pic->HeightBits; - uint32_t uv_max = uv_height << fracbits; - - DWORD(*draw1column)(); - void(*draw4columns)(); - setupwallscan(fracbits, draw1column, draw4columns); - - fixed_t xoffset = rw_offset; - - bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); - if (fixed) - { - palookupoffse[0] = dc_colormap; - palookupoffse[1] = dc_colormap; - palookupoffse[2] = dc_colormap; - palookupoffse[3] = dc_colormap; - palookuplight[0] = 0; - palookuplight[1] = 0; - palookuplight[2] = 0; - palookuplight[3] = 0; - } - - if (fixedcolormap) - R_SetColorMapLight(fixedcolormap, 0, 0); - else - R_SetColorMapLight(basecolormap, 0, 0); - - float light = rw_light; - - // Calculate where 4 column alignment begins and ends: - int aligned_x1 = clamp((x1 + 3) / 4 * 4, x1, x2); - int aligned_x2 = clamp(x2 / 4 * 4, x1, x2); - - // First unaligned columns: - for (int x = x1; x < aligned_x1; x++, light += rw_lightstep) - { - int y1 = uwal[x]; - int y2 = dwal[x]; - if (y2 <= y1) - continue; - - if (!fixed) - R_SetColorMapLight(basecolormap, light, wallshade); - - const BYTE *source = getcol(rw_pic, (lwal[x] + xoffset) >> FRACBITS); - - uint32_t uv_start, uv_step; - calc_uv_start_and_step(y1, swal[x], yrepeat, uv_height, fracbits, uv_start, uv_step); - - wallscan_drawcol1(x, y1, y2, uv_start, uv_step, uv_max, source, draw1column); - } - - // The aligned columns - for (int x = aligned_x1; x < aligned_x2; x += 4) - { - // Find y1, y2, light and uv values for four columns: - int y1[4] = { uwal[x], uwal[x + 1], uwal[x + 2], uwal[x + 3] }; - int y2[4] = { dwal[x], dwal[x + 1], dwal[x + 2], dwal[x + 3] }; - - const BYTE *source[4]; - for (int i = 0; i < 4; i++) - source[i] = getcol(rw_pic, (lwal[x + i] + xoffset) >> FRACBITS); - - float lights[4]; - for (int i = 0; i < 4; i++) - { - lights[i] = light; - light += rw_lightstep; - } - - uint32_t uv_pos[4], uv_step[4]; - for (int i = 0; i < 4; i++) - calc_uv_start_and_step(y1[i], swal[x + i], yrepeat, uv_height, fracbits, uv_pos[i], uv_step[i]); - - // Figure out where we vertically can start and stop drawing 4 columns in one go - int middle_y1 = y1[0]; - int middle_y2 = y2[0]; - for (int i = 1; i < 4; i++) - { - middle_y1 = MAX(y1[i], middle_y1); - middle_y2 = MIN(y2[i], middle_y2); - } - - // If we got an empty column in our set we cannot draw 4 columns in one go: - bool empty_column_in_set = false; - for (int i = 0; i < 4; i++) - { - if (y2[i] <= y1[i]) - empty_column_in_set = true; - } - - if (empty_column_in_set || middle_y2 <= middle_y1) - { - for (int i = 0; i < 4; i++) - { - if (y2[i] <= y1[i]) - continue; - - if (!fixed) - R_SetColorMapLight(basecolormap, lights[i], wallshade); - wallscan_drawcol1(x + i, y1[i], y2[i], uv_pos[i], uv_step[i], uv_max, source[i], draw1column); - } - continue; - } - - // Draw the first rows where not all 4 columns are active - for (int i = 0; i < 4; i++) - { - if (!fixed) - R_SetColorMapLight(basecolormap, lights[i], wallshade); - - if (y1[i] < middle_y1) - uv_pos[i] = wallscan_drawcol1(x + i, y1[i], middle_y1, uv_pos[i], uv_step[i], uv_max, source[i], draw1column); - } - - // Draw the area where all 4 columns are active - if (!fixed) - { - for (int i = 0; i < 4; i++) - { - if (r_swtruecolor) - { - palookupoffse[i] = basecolormap->Maps; - palookuplight[i] = LIGHTSCALE(lights[i], wallshade); - } - else - { - palookupoffse[i] = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); - palookuplight[i] = 0; - } - } - } - wallscan_drawcol4(x, middle_y1, middle_y2, uv_pos, uv_step, uv_max, source, draw4columns); - - // Draw the last rows where not all 4 columns are active - for (int i = 0; i < 4; i++) - { - if (!fixed) - R_SetColorMapLight(basecolormap, lights[i], wallshade); - - if (middle_y2 < y2[i]) - uv_pos[i] = wallscan_drawcol1(x + i, middle_y2, y2[i], uv_pos[i], uv_step[i], uv_max, source[i], draw1column); - } - } - - // The last unaligned columns: - for (int x = aligned_x2; x < x2; x++, light += rw_lightstep) - { - int y1 = uwal[x]; - int y2 = dwal[x]; - if (y2 <= y1) - continue; - - if (!fixed) - R_SetColorMapLight(basecolormap, light, wallshade); - - const BYTE *source = getcol(rw_pic, (lwal[x] + xoffset) >> FRACBITS); - - uint32_t uv_start, uv_step; - calc_uv_start_and_step(y1, swal[x], yrepeat, uv_height, fracbits, uv_start, uv_step); - - wallscan_drawcol1(x, y1, y2, uv_start, uv_step, uv_max, source, draw1column); - } - - NetUpdate (); -} - -void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) -{ - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) - { - setupvline(bits); - line1 = dovline1; - line4 = dovline4; - }); -} - -void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) -{ - if (!rw_pic->bMasked) // Textures that aren't masked can use the faster wallscan. - { - wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); - } - else - { - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) - { - setupmvline(bits); - line1 = domvline1; - line4 = domvline4; - }); - } -} - -void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) -{ - static fixed_t(*tmvline1)(); - static void(*tmvline4)(); - if (!R_GetTransMaskDrawers(&tmvline1, &tmvline4)) - { - // The current translucency is unsupported, so draw with regular maskwallscan instead. - maskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); - } - else - { - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) - { - setuptmvline(bits); - line1 = reinterpret_cast(tmvline1); - line4 = tmvline4; - }); - } -} - void wallscan_striped (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) { FDynamicColormap *startcolormap = basecolormap; @@ -1444,7 +1093,7 @@ void wallscan_striped (int x1, int x2, short *uwal, short *dwal, float *swal, fi { down[j] = clamp (most3[j], up[j], dwal[j]); } - wallscan (x1, x2, up, down, swal, lwal, yrepeat); + DrawerContext::DrawWall (x1, x2, up, down, swal, lwal, yrepeat, rw_pic, rw_offset); up = down; down = (down == most1) ? most2 : most1; } @@ -1455,7 +1104,7 @@ void wallscan_striped (int x1, int x2, short *uwal, short *dwal, float *swal, fi *lit->p_lightlevel, lit->lightsource != NULL) + r_actualextralight); } - wallscan (x1, x2, up, dwal, swal, lwal, yrepeat); + DrawerContext::DrawWall (x1, x2, up, dwal, swal, lwal, yrepeat, rw_pic, rw_offset); basecolormap = startcolormap; wallshade = startshade; } @@ -1464,20 +1113,20 @@ static void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, { if (mask) { - if (colfunc == basecolfunc) + if (DrawerContext::IsBaseColumn()) { - maskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); + DrawerContext::DrawMaskedWall(x1, x2, uwal, dwal, swal, lwal, yrepeat, rw_pic, rw_offset); } else { - transmaskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); + DrawerContext::DrawTransMaskedWall(x1, x2, uwal, dwal, swal, lwal, yrepeat, rw_pic, rw_offset); } } else { if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size())) { - wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); + DrawerContext::DrawWall(x1, x2, uwal, dwal, swal, lwal, yrepeat, rw_pic, rw_offset); } else { @@ -1513,14 +1162,14 @@ void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t if (yrepeat >= 0) { // normal orientation: draw strips from top to bottom - partition = top - fmod(top - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); + partition = top - fmod(top - DrawerContext::TextureMid() / yrepeat - ViewPos.Z, scaledtexheight); if (partition == top) { partition -= scaledtexheight; } up = uwal; down = most1; - dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; + DrawerContext::SetTextureMid((partition - ViewPos.Z) * yrepeat + texheight); while (partition > bot) { int j = OWallMost(most3, partition - ViewPos.Z, &WallC); @@ -1535,16 +1184,16 @@ void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t down = (down == most1) ? most2 : most1; } partition -= scaledtexheight; - dc_texturemid -= texheight; + DrawerContext::SetTextureMid(DrawerContext::TextureMid() - texheight); } call_wallscan(x1, x2, up, dwal, swal, lwal, yrepeat, mask); } else { // upside down: draw strips from bottom to top - partition = bot - fmod(bot - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); + partition = bot - fmod(bot - DrawerContext::TextureMid() / yrepeat - ViewPos.Z, scaledtexheight); up = most1; down = dwal; - dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; + DrawerContext::SetTextureMid((partition - ViewPos.Z) * yrepeat + texheight); while (partition < top) { int j = OWallMost(most3, partition - ViewPos.Z, &WallC); @@ -1559,7 +1208,7 @@ void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t up = (up == most1) ? most2 : most1; } partition -= scaledtexheight; - dc_texturemid -= texheight; + DrawerContext::SetTextureMid(DrawerContext::TextureMid() - texheight); } call_wallscan(x1, x2, uwal, down, swal, lwal, yrepeat, mask); } @@ -1612,9 +1261,9 @@ void R_RenderSegLoop () fixed_t xoffset = rw_offset; if (fixedlightlev >= 0) - R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + DrawerContext::SetLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - R_SetColorMapLight(fixedcolormap, 0, 0); + DrawerContext::SetLight(fixedcolormap, 0, 0); // clip wall to the floor and ceiling for (x = x1; x < x2; ++x) @@ -1695,7 +1344,7 @@ void R_RenderSegLoop () { // one sided line if (midtexture->UseType != FTexture::TEX_Null && viewactive) { - dc_texturemid = rw_midtexturemid; + DrawerContext::SetTextureMid(rw_midtexturemid); rw_pic = midtexture; xscale = rw_pic->Scale.X * rw_midtexturescalex; yscale = rw_pic->Scale.Y * rw_midtexturescaley; @@ -1738,7 +1387,7 @@ void R_RenderSegLoop () } if (viewactive) { - dc_texturemid = rw_toptexturemid; + DrawerContext::SetTextureMid(rw_toptexturemid); rw_pic = toptexture; xscale = rw_pic->Scale.X * rw_toptexturescalex; yscale = rw_pic->Scale.Y * rw_toptexturescaley; @@ -1784,7 +1433,7 @@ void R_RenderSegLoop () } if (viewactive) { - dc_texturemid = rw_bottomtexturemid; + DrawerContext::SetTextureMid(rw_bottomtexturemid); rw_pic = bottomtexture; xscale = rw_pic->Scale.X * rw_bottomtexturescalex; yscale = rw_pic->Scale.Y * rw_bottomtexturescaley; @@ -2974,7 +2623,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, } yscale = decal->ScaleY; - dc_texturemid = WallSpriteTile->TopOffset + (zpos - ViewPos.Z) / yscale; + DrawerContext::SetTextureMid(WallSpriteTile->TopOffset + (zpos - ViewPos.Z) / yscale); // Clip sprite to drawseg x1 = MAX(clipper->x1, x1); @@ -3011,11 +2660,11 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rw_light = rw_lightleft + (x1 - WallC.sx1) * rw_lightstep; if (fixedlightlev >= 0) - R_SetColorMapLight(usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + DrawerContext::SetLight(usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - R_SetColorMapLight(fixedcolormap, 0, 0); + DrawerContext::SetLight(fixedcolormap, 0, 0); else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT)) - R_SetColorMapLight(usecolormap, 0, 0); + DrawerContext::SetLight(usecolormap, 0, 0); else calclighting = true; @@ -3024,7 +2673,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { sprflipvert = true; yscale = -yscale; - dc_texturemid -= WallSpriteTile->GetHeight(); + DrawerContext::SetTextureMid(DrawerContext::TextureMid() - WallSpriteTile->GetHeight()); } else { @@ -3034,10 +2683,9 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, MaskedScaleY = float(1 / yscale); do { - dc_x = x1; ESPSResult mode; - mode = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); + mode = DrawerContext::SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); // R_SetPatchStyle can modify basecolormap. if (rereadcolormap) @@ -3053,48 +2701,50 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { int stop4; + int x = x1; + if (mode == DoDraw0) { // 1 column at a time - stop4 = dc_x; + stop4 = x; } else // DoDraw1 { // up to 4 columns at a time stop4 = x2 & ~3; } - while ((dc_x < stop4) && (dc_x & 3)) + while ((x < stop4) && (x & 3)) { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap, rw_light, wallshade); + DrawerContext::SetLight(usecolormap, rw_light, wallshade); } - R_WallSpriteColumn (R_DrawMaskedColumn); - dc_x++; + R_WallSpriteColumn (x, DrawerContext::DrawMaskedColumn); + x++; } - while (dc_x < stop4) + while (x < stop4) { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap, rw_light, wallshade); + DrawerContext::SetLight(usecolormap, rw_light, wallshade); } - rt_initcols(nullptr); - for (int zz = 4; zz; --zz) + DrawerContext::RtInitCols(nullptr); + for (int zz = 0; zz < 4; ++zz) { - R_WallSpriteColumn (R_DrawMaskedColumnHoriz); - dc_x++; + R_WallSpriteColumn (x + zz, DrawerContext::DrawMaskedColumnHoriz); } - rt_draw4cols (dc_x - 4); + DrawerContext::DrawRt4cols (x); + x += 4; } - while (dc_x < x2) + while (x < x2) { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap, rw_light, wallshade); + DrawerContext::SetLight(usecolormap, rw_light, wallshade); } - R_WallSpriteColumn (R_DrawMaskedColumn); - dc_x++; + R_WallSpriteColumn (x, DrawerContext::DrawMaskedColumn); + x++; } } @@ -3103,14 +2753,11 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, // needrepeat will be 0, and the while will fail. mceilingclip = floorclip; mfloorclip = wallbottom; - R_FinishSetPatchStyle (); + DrawerContext::FinishSetPatchStyle (); } while (needrepeat--); - colfunc = basecolfunc; - hcolfunc_post1 = rt_map1col; - hcolfunc_post4 = rt_map4cols; - - R_FinishSetPatchStyle (); + DrawerContext::SetBaseStyle(); + DrawerContext::FinishSetPatchStyle (); done: WallC = savecoord; } diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index c4347236d..480cdd02b 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -32,6 +32,7 @@ ** */ +#define DRAWER_INTERNALS #include "r_local.h" #include "v_palette.h" diff --git a/src/r_things.cpp b/src/r_things.cpp index 836f58690..b856b968a 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -58,7 +58,7 @@ #include "r_plane.h" #include "r_segs.h" #include "r_3dfloors.h" -#include "r_draw_rgba.h" +#include "r_drawer_context.h" #include "v_palette.h" #include "r_data/r_translate.h" #include "r_data/colormaps.h" @@ -229,12 +229,6 @@ vissprite_t *R_NewVisSprite (void) return *(vissprite_p-1); } -// -// R_DrawMaskedColumn -// Used for sprites and masked mid textures. -// Masked means: partly transparent, i.e. stored -// in posts/runs of opaque pixels. -// short* mfloorclip; short* mceilingclip; @@ -243,88 +237,6 @@ double sprtopscreen; bool sprflipvert; -void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span) -{ - int pixelsize = r_swtruecolor ? 4 : 1; - const fixed_t centeryfrac = FLOAT2FIXED(CenterY); - const fixed_t texturemid = FLOAT2FIXED(dc_texturemid); - while (span->Length != 0) - { - const int length = span->Length; - const int top = span->TopOffset; - - // calculate unclipped screen coordinates for post - dc_yl = xs_RoundToInt(sprtopscreen + spryscale * top); - dc_yh = xs_RoundToInt(sprtopscreen + spryscale * (top + length)) - 1; - - if (sprflipvert) - { - swapvalues (dc_yl, dc_yh); - } - - if (dc_yh >= mfloorclip[dc_x]) - { - dc_yh = mfloorclip[dc_x] - 1; - } - if (dc_yl < mceilingclip[dc_x]) - { - dc_yl = mceilingclip[dc_x]; - } - - if (dc_yl <= dc_yh) - { - if (sprflipvert) - { - dc_texturefrac = (dc_yl*dc_iscale) - (top << FRACBITS) - - FixedMul (centeryfrac, dc_iscale) - texturemid; - const fixed_t maxfrac = length << FRACBITS; - while (dc_texturefrac >= maxfrac) - { - if (++dc_yl > dc_yh) - goto nextpost; - dc_texturefrac += dc_iscale; - } - fixed_t endfrac = dc_texturefrac + (dc_yh-dc_yl)*dc_iscale; - while (endfrac < 0) - { - if (--dc_yh < dc_yl) - goto nextpost; - endfrac -= dc_iscale; - } - } - else - { - dc_texturefrac = texturemid - (top << FRACBITS) - + (dc_yl*dc_iscale) - FixedMul (centeryfrac-FRACUNIT, dc_iscale); - while (dc_texturefrac < 0) - { - if (++dc_yl > dc_yh) - goto nextpost; - dc_texturefrac += dc_iscale; - } - fixed_t endfrac = dc_texturefrac + (dc_yh-dc_yl)*dc_iscale; - const fixed_t maxfrac = length << FRACBITS; - if (dc_yh < mfloorclip[dc_x]-1 && endfrac < maxfrac - dc_iscale) - { - dc_yh++; - } - else while (endfrac >= maxfrac) - { - if (--dc_yh < dc_yl) - goto nextpost; - endfrac -= dc_iscale; - } - } - dc_source = column + top; - dc_dest = (ylookup[dc_yl] + dc_x) * pixelsize + dc_destorg; - dc_count = dc_yh - dc_yl + 1; - colfunc (); - } -nextpost: - span++; - } -} - // [ZZ] // R_ClipSpriteColumnWithPortals // @@ -361,7 +273,7 @@ static inline void R_CollectPortals() } } -static inline bool R_ClipSpriteColumnWithPortals(vissprite_t* spr) +bool R_ClipSpriteColumnWithPortals(int x, vissprite_t* spr) { // [ZZ] 10.01.2016: don't clip sprites from the root of a skybox. if (CurrentPortalInSkybox) @@ -380,7 +292,7 @@ static inline bool R_ClipSpriteColumnWithPortals(vissprite_t* spr) continue; // now if current column is covered by this drawseg, we clip it away - if ((dc_x >= seg->x1) && (dc_x < seg->x2)) + if ((x >= seg->x1) && (x < seg->x2)) return true; } @@ -409,15 +321,15 @@ void R_DrawVisSprite (vissprite_t *vis) } fixed_t centeryfrac = FLOAT2FIXED(CenterY); - R_SetColorMapLight(vis->Style.BaseColormap, 0, vis->Style.ColormapNum << FRACBITS); + DrawerContext::SetLight(vis->Style.BaseColormap, 0, vis->Style.ColormapNum << FRACBITS); - mode = R_SetPatchStyle (vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor); + mode = DrawerContext::SetPatchStyle (vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor); if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Shaded]) { // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but // it is the brightest one. We need to get back to the proper light level for // this sprite. - R_SetColorMapLight(dc_fcolormap, 0, vis->Style.ColormapNum << FRACBITS); + DrawerContext::SetLight(DrawerContext::LightColormap(), 0, vis->Style.ColormapNum << FRACBITS); } if (mode != DontDraw) @@ -436,65 +348,67 @@ void R_DrawVisSprite (vissprite_t *vis) tex = vis->pic; spryscale = vis->yscale; sprflipvert = false; - dc_iscale = FLOAT2FIXED(1 / vis->yscale); + DrawerContext::SetTextureStep(FLOAT2FIXED(1 / vis->yscale)); frac = vis->startfrac; xiscale = vis->xiscale; - dc_texturemid = vis->texturemid; + DrawerContext::SetTextureMid(vis->texturemid); if (vis->renderflags & RF_YFLIP) { sprflipvert = true; spryscale = -spryscale; - dc_iscale = -dc_iscale; - dc_texturemid -= vis->pic->GetHeight(); - sprtopscreen = CenterY + dc_texturemid * spryscale; + DrawerContext::SetTextureStep(-DrawerContext::TextureStep()); + DrawerContext::SetTextureMid(DrawerContext::TextureMid() - vis->pic->GetHeight()); + sprtopscreen = CenterY + DrawerContext::TextureMid() * spryscale; } else { sprflipvert = false; - sprtopscreen = CenterY - dc_texturemid * spryscale; + sprtopscreen = CenterY - DrawerContext::TextureMid() * spryscale; } - dc_x = vis->x1; + int x = vis->x1; x2 = vis->x2; - if (dc_x < x2) + if (x < x2) { - while ((dc_x < stop4) && (dc_x & 3)) + DrawerContext::SetMaskedColumnState(mfloorclip, mceilingclip, spryscale, sprtopscreen, sprflipvert); + + while ((x < stop4) && (x & 3)) { pixels = tex->GetColumn (frac >> FRACBITS, &spans); - if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (pixels, spans); - dc_x++; + if (ispsprite || !R_ClipSpriteColumnWithPortals(x, vis)) + DrawerContext::DrawMaskedColumn (x, pixels, spans); + x++; frac += xiscale; } - while (dc_x < stop4) + while (x < stop4) { - rt_initcols(nullptr); - for (int zz = 4; zz; --zz) + DrawerContext::RtInitCols(nullptr); + for (int zz = 0; zz < 4; ++zz) { pixels = tex->GetColumn (frac >> FRACBITS, &spans); - if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumnHoriz (pixels, spans); - dc_x++; + if (ispsprite || !R_ClipSpriteColumnWithPortals(x + zz, vis)) + DrawerContext::DrawMaskedColumnHoriz (x + zz, pixels, spans); frac += xiscale; } - rt_draw4cols (dc_x - 4); + DrawerContext::DrawRt4cols(x); + x += 4; } - while (dc_x < x2) + while (x < x2) { pixels = tex->GetColumn (frac >> FRACBITS, &spans); - if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (pixels, spans); - dc_x++; + if (ispsprite || !R_ClipSpriteColumnWithPortals(x, vis)) + DrawerContext::DrawMaskedColumn (x, pixels, spans); + x++; frac += xiscale; } } } - R_FinishSetPatchStyle (); + DrawerContext::FinishSetPatchStyle (); NetUpdate (); } @@ -511,7 +425,7 @@ void R_DrawWallSprite(vissprite_t *spr) WallT.InitFromWallCoords(&spr->wallc); PrepWall(swall, lwall, spr->pic->GetWidth() << FRACBITS, x1, x2); iyscale = 1 / spr->yscale; - dc_texturemid = (spr->gzt - ViewPos.Z) * iyscale; + DrawerContext::SetTextureMid((spr->gzt - ViewPos.Z) * iyscale); if (spr->renderflags & RF_XFLIP) { int right = (spr->pic->GetWidth() << FRACBITS) - 1; @@ -539,11 +453,11 @@ void R_DrawWallSprite(vissprite_t *spr) rw_lightstep = float((GlobVis / spr->wallc.sz2 - rw_lightleft) / (spr->wallc.sx2 - spr->wallc.sx1)); rw_light = rw_lightleft + (x1 - spr->wallc.sx1) * rw_lightstep; if (fixedlightlev >= 0) - R_SetColorMapLight(usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + DrawerContext::SetLight(usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - R_SetColorMapLight(fixedcolormap, 0, 0); + DrawerContext::SetLight(fixedcolormap, 0, 0); else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) - R_SetColorMapLight(usecolormap, 0, 0); + DrawerContext::SetLight(usecolormap, 0, 0); else calclighting = true; @@ -553,7 +467,7 @@ void R_DrawWallSprite(vissprite_t *spr) { sprflipvert = true; iyscale = -iyscale; - dc_texturemid -= spr->pic->GetHeight(); + DrawerContext::SetTextureMid(DrawerContext::TextureMid() - spr->pic->GetHeight()); } else { @@ -562,10 +476,9 @@ void R_DrawWallSprite(vissprite_t *spr) MaskedScaleY = (float)iyscale; - dc_x = x1; ESPSResult mode; - mode = R_SetPatchStyle (spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); + mode = DrawerContext::SetPatchStyle (spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); // R_SetPatchStyle can modify basecolormap. if (rereadcolormap) @@ -581,71 +494,74 @@ void R_DrawWallSprite(vissprite_t *spr) { int stop4; + int x = x1; + if (mode == DoDraw0) { // 1 column at a time - stop4 = dc_x; + stop4 = x; } else // DoDraw1 { // up to 4 columns at a time stop4 = x2 & ~3; } - while ((dc_x < stop4) && (dc_x & 3)) + while ((x < stop4) && (x & 3)) { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap, rw_light, shade); + DrawerContext::SetLight(usecolormap, rw_light, shade); } - if (!R_ClipSpriteColumnWithPortals(spr)) - R_WallSpriteColumn(R_DrawMaskedColumn); - dc_x++; + if (!R_ClipSpriteColumnWithPortals(x, spr)) + R_WallSpriteColumn(x, DrawerContext::DrawMaskedColumn); + x++; } - while (dc_x < stop4) + while (x < stop4) { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap, rw_light, shade); + DrawerContext::SetLight(usecolormap, rw_light, shade); } - rt_initcols(nullptr); - for (int zz = 4; zz; --zz) + DrawerContext::RtInitCols(nullptr); + for (int zz = 0; zz < 4; ++zz) { - if (!R_ClipSpriteColumnWithPortals(spr)) - R_WallSpriteColumn(R_DrawMaskedColumnHoriz); - dc_x++; + if (!R_ClipSpriteColumnWithPortals(x + zz, spr)) + R_WallSpriteColumn(x + zz, DrawerContext::DrawMaskedColumnHoriz); } - rt_draw4cols(dc_x - 4); + DrawerContext::DrawRt4cols(x); + x += 4; } - while (dc_x < x2) + while (x < x2) { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap, rw_light, shade); + DrawerContext::SetLight(usecolormap, rw_light, shade); } - if (!R_ClipSpriteColumnWithPortals(spr)) - R_WallSpriteColumn(R_DrawMaskedColumn); - dc_x++; + if (!R_ClipSpriteColumnWithPortals(x, spr)) + R_WallSpriteColumn(x, DrawerContext::DrawMaskedColumn); + x++; } } - R_FinishSetPatchStyle(); + DrawerContext::FinishSetPatchStyle(); } -void R_WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans)) +void R_WallSpriteColumn (int x, void (*drawfunc)(int x, const BYTE *column, const FTexture::Span *spans)) { - float iscale = swall[dc_x] * MaskedScaleY; - dc_iscale = FLOAT2FIXED(iscale); + float iscale = swall[x] * MaskedScaleY; + DrawerContext::SetTextureStep(FLOAT2FIXED(iscale)); spryscale = 1 / iscale; if (sprflipvert) - sprtopscreen = CenterY + dc_texturemid * spryscale; + sprtopscreen = CenterY + DrawerContext::TextureMid() * spryscale; else - sprtopscreen = CenterY - dc_texturemid * spryscale; + sprtopscreen = CenterY - DrawerContext::TextureMid() * spryscale; const BYTE *column; const FTexture::Span *spans; - column = WallSpriteTile->GetColumn (lwall[dc_x] >> FRACBITS, &spans); - dc_texturefrac = 0; - drawfunc (column, spans); + column = WallSpriteTile->GetColumn (lwall[x] >> FRACBITS, &spans); + DrawerContext::SetTextureFrac(0); + DrawerContext::SetMaskedColumnState(mfloorclip, mceilingclip, spryscale, sprtopscreen, sprflipvert); + drawfunc (x, column, spans); rw_light += rw_lightstep; } @@ -655,18 +571,18 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop int flags = 0; // Do setup for blending. - R_SetColorMapLight(spr->Style.BaseColormap, 0, spr->Style.ColormapNum << FRACBITS); - mode = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); + DrawerContext::SetLight(spr->Style.BaseColormap, 0, spr->Style.ColormapNum << FRACBITS); + mode = DrawerContext::SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); if (mode == DontDraw) { return; } - if (colfunc == fuzzcolfunc || colfunc == R_FillColumn) + if (DrawerContext::IsFuzzColumn() || DrawerContext::IsFillColumn()) { flags = DVF_OFFSCREEN | DVF_SPANSONLY; } - else if (colfunc != basecolfunc) + else if (!DrawerContext::IsBaseColumn()) { flags = DVF_OFFSCREEN; } @@ -692,32 +608,32 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop { if (!(flags & DVF_SPANSONLY) && (x & 3) == 0) { - rt_initcols(OffscreenColorBuffer + x * OffscreenBufferHeight); + DrawerContext::RtInitCols(OffscreenColorBuffer + x * OffscreenBufferHeight); } for (FCoverageBuffer::Span *span = OffscreenCoverageBuffer->Spans[x]; span != NULL; span = span->NextSpan) { if (flags & DVF_SPANSONLY) { - dc_x = x; - dc_yl = span->Start; - dc_yh = span->Stop - 1; - dc_count = span->Stop - span->Start; - dc_dest = (ylookup[span->Start] + x) * pixelsize + dc_destorg; - colfunc(); + DrawerContext::SetX(x); + DrawerContext::SetY1(span->Start); + DrawerContext::SetY2(span->Stop - 1); + DrawerContext::SetDrawCount(span->Stop - span->Start); + DrawerContext::SetDest(x, span->Start); + DrawerContext::DrawColumn(); } else { - rt_span_coverage(x, span->Start, span->Stop - 1); + DrawerContext::RtSpanCoverage(x, span->Start, span->Stop - 1); } } if (!(flags & DVF_SPANSONLY) && (x & 3) == 3) { - rt_draw4cols(x - 3); + DrawerContext::DrawRt4cols(x - 3); } } } - R_FinishSetPatchStyle(); + DrawerContext::FinishSetPatchStyle(); NetUpdate(); } @@ -2585,7 +2501,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, } } -static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) +void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) { const int x1 = vis->x1; const int x2 = vis->x2; @@ -2610,120 +2526,24 @@ static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) } } -void R_DrawParticle_C (vissprite_t *vis) +void R_DrawParticle(vissprite_t *vis) { - DWORD *bg2rgb; - int spacing; - BYTE *dest; - DWORD fg; BYTE color = vis->Style.BaseColormap->Maps[(vis->Style.ColormapNum << COLORMAPSHIFT) + vis->startfrac]; int yl = vis->y1; - int ycount = vis->y2 - yl + 1; - int x1 = vis->x1; - int countbase = vis->x2 - x1; - - R_DrawMaskedSegsBehindParticle (vis); - - // vis->renderflags holds translucency level (0-255) - { - fixed_t fglevel, bglevel; - DWORD *fg2rgb; - - fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff; - bglevel = FRACUNIT-fglevel; - fg2rgb = Col2RGB8[fglevel>>10]; - bg2rgb = Col2RGB8[bglevel>>10]; - fg = fg2rgb[color]; - } - - /* - - spacing = RenderTarget->GetPitch() - countbase; - dest = ylookup[yl] + x1 + dc_destorg; - - do - { - int count = countbase; - do - { - DWORD bg = bg2rgb[*dest]; - bg = (fg+bg) | 0x1f07c1f; - *dest++ = RGB32k.All[bg & (bg>>15)]; - } while (--count); - dest += spacing; - } while (--ycount);*/ - - // original was row-wise - // width = countbase - // height = ycount - - spacing = RenderTarget->GetPitch(); - - for (int x = x1; x < (x1+countbase); x++) - { - dc_x = x; - if (R_ClipSpriteColumnWithPortals(vis)) - continue; - dest = ylookup[yl] + x + dc_destorg; - for (int y = 0; y < ycount; y++) - { - DWORD bg = bg2rgb[*dest]; - bg = (fg+bg) | 0x1f07c1f; - *dest = RGB32k.All[bg & (bg>>15)]; - dest += spacing; - } - } -} - -void R_DrawParticle_rgba(vissprite_t *vis) -{ - int spacing; - uint32_t *dest; - BYTE color = vis->Style.BaseColormap->Maps[vis->startfrac]; - int yl = vis->y1; - int ycount = vis->y2 - yl + 1; + int yh = vis->y2; int x1 = vis->x1; int countbase = vis->x2 - x1; R_DrawMaskedSegsBehindParticle(vis); - - DrawerCommandQueue::WaitForWorkers(); - - uint32_t fg = shade_pal_index_simple(color, calc_light_multiplier(LIGHTSCALE(0, vis->Style.ColormapNum << FRACBITS))); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; // vis->renderflags holds translucency level (0-255) - fixed_t fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff; - uint32_t alpha = fglevel * 256 / FRACUNIT; - uint32_t inv_alpha = 256 - alpha; - - fg_red *= alpha; - fg_green *= alpha; - fg_blue *= alpha; - - spacing = RenderTarget->GetPitch(); + int alpha = vis->renderflags; for (int x = x1; x < (x1 + countbase); x++) { - dc_x = x; - if (R_ClipSpriteColumnWithPortals(vis)) + if (R_ClipSpriteColumnWithPortals(x, vis)) continue; - dest = ylookup[yl] + x + (uint32_t*)dc_destorg; - for (int y = 0; y < ycount; y++) - { - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red + bg_red * inv_alpha) / 256; - uint32_t green = (fg_green + bg_green * inv_alpha) / 256; - uint32_t blue = (fg_blue + bg_blue * inv_alpha) / 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += spacing; - } + DrawerContext::FillTransColumn(x, yl, yh, color, alpha); } } @@ -2769,9 +2589,7 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, sprcosang = FLOAT2FIXED(dasprang.Cos()) >> 2; sprsinang = FLOAT2FIXED(-dasprang.Sin()) >> 2; - R_SetupDrawSlab(colormap); - - int pixelsize = r_swtruecolor ? 4 : 1; + DrawerContext::SetSlabLight(colormap); // Select mip level i = abs(DMulScale6(dasprx - globalposx, cosang, daspry - globalposy, sinang)); @@ -3026,25 +2844,25 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, if (!(flags & DVF_OFFSCREEN)) { // Draw directly to the screen. - R_DrawSlab(xxr - xxl, yplc[xxl], z2 - z1, yinc, col, (ylookup[z1] + lxt + xxl) * pixelsize + dc_destorg); + DrawerContext::DrawSlab(xxr - xxl, yplc[xxl], z2 - z1, yinc, col, lxt + xxl, z1); } else { // Record the area covered and possibly draw to an offscreen buffer. - dc_yl = z1; - dc_yh = z2 - 1; - dc_count = z2 - z1; - dc_iscale = yinc; + DrawerContext::SetY1(z1); + DrawerContext::SetY2(z2 - 1); + DrawerContext::SetDrawCount(z2 - z1); + DrawerContext::SetTextureStep(yinc); for (int x = xxl; x < xxr; ++x) { OffscreenCoverageBuffer->InsertSpan(lxt + x, z1, z2); if (!(flags & DVF_SPANSONLY)) { - dc_x = lxt + x; - rt_initcols(OffscreenColorBuffer + (dc_x & ~3) * OffscreenBufferHeight); - dc_source = col; - dc_texturefrac = yplc[xxl]; - hcolfunc_pre(); + DrawerContext::RtInitCols(OffscreenColorBuffer + ((lxt + x) & ~3) * OffscreenBufferHeight); + DrawerContext::SetX(lxt + x); + DrawerContext::SetSource(col); + DrawerContext::SetTextureFrac(yplc[xxl]); + DrawerContext::DrawHColumnPre(); } } } diff --git a/src/r_things.h b/src/r_things.h index f5cd30e00..869de4da2 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -96,11 +96,8 @@ struct vissprite_t struct particle_t; -extern void(*R_DrawParticle)(vissprite_t *); -void R_DrawParticle_C (vissprite_t *); -void R_DrawParticle_rgba (vissprite_t *); - void R_ProjectParticle (particle_t *, const sector_t *sector, int shade, int fakeside); +void R_DrawParticle (vissprite_t *vis); extern int MaxVisSprites; @@ -112,7 +109,6 @@ extern vissprite_t **vissprite_p; extern short zeroarray[MAXWIDTH]; extern short screenheightarray[MAXWIDTH]; -// vars for R_DrawMaskedColumn extern short* mfloorclip; extern short* mceilingclip; extern double spryscale; @@ -126,8 +122,7 @@ extern double pspriteyscale; extern FTexture *WallSpriteTile; -void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *spans); -void R_WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans)); +void R_WallSpriteColumn (int x, void (*drawfunc)(int x, const BYTE *column, const FTexture::Span *spans)); void R_CacheSprite (spritedef_t *sprite); void R_SortVisSprites (int (*compare)(const void *, const void *), size_t first); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 6a8dad047..21cbd1a33 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -43,8 +43,7 @@ #include "r_defs.h" #include "r_utility.h" #ifndef NO_SWRENDER -#include "r_draw.h" -#include "r_draw_rgba.h" +#include "r_drawer_context.h" #include "r_main.h" #include "r_things.h" #endif @@ -130,12 +129,14 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH]; const BYTE *translation = NULL; - if (r_swtruecolor != IsBgra()) + DCanvas *destorgsave = DrawerContext::Canvas(); + if (screen->GetBuffer() == NULL) { - r_swtruecolor = IsBgra(); - R_InitColumnDrawers(); + I_FatalError("Attempt to write to buffer of hardware canvas"); } + DrawerContext::SetCanvas(screen); + if (parms.masked) { spanptr = &spans; @@ -172,22 +173,15 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) if (translation != NULL) { - R_SetTranslationMap((lighttable_t *)translation); + DrawerContext::SetTranslationMap((lighttable_t *)translation); } else { - R_SetTranslationMap(identitymap); + DrawerContext::SetTranslationMap(nullptr); } - fixedcolormap = dc_fcolormap; - ESPSResult mode = R_SetPatchStyle (parms.style, parms.Alpha, 0, parms.fillcolor); - - BYTE *destorgsave = dc_destorg; - dc_destorg = screen->GetBuffer(); - if (dc_destorg == NULL) - { - I_FatalError("Attempt to write to buffer of hardware canvas"); - } + fixedcolormap = DrawerContext::LightColormap(); + ESPSResult mode = DrawerContext::SetPatchStyle (parms.style, parms.Alpha, 0, parms.fillcolor); double x0 = parms.x - parms.left * parms.destwidth / parms.texwidth; double y0 = parms.y - parms.top * parms.destheight / parms.texheight; @@ -220,11 +214,11 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) assert(spryscale > 0); sprflipvert = false; - //dc_iscale = FLOAT2FIXED(iyscale); - //dc_texturemid = (-y0) * iyscale; - //dc_iscale = 0xffffffffu / (unsigned)spryscale; - dc_iscale = FLOAT2FIXED(1 / spryscale); - dc_texturemid = (CenterY - 1 - sprtopscreen) * dc_iscale / 65536; + //DrawerContext::SetTextureStep(FLOAT2FIXED(iyscale)); + //DrawerContext::SetTextureMid((-y0) * iyscale); + //DrawerContext::SetTextureStep(0xffffffffu / (unsigned)spryscale); + DrawerContext::SetTextureStep(FLOAT2FIXED(1 / spryscale)); + DrawerContext::SetTextureMid((CenterY - 1 - sprtopscreen) * DrawerContext::TextureStep() / 65536); fixed_t frac = 0; double xiscale = img->GetWidth() / parms.destwidth; double x2 = x0 + parms.destwidth; @@ -278,14 +272,14 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) mode = DoDraw0; } - dc_x = int(x0); + int x = int(x0); int x2_i = int(x2); fixed_t xiscale_i = FLOAT2FIXED(xiscale); if (mode == DoDraw0) { // One column at a time - stop4 = dc_x; + stop4 = x; } else // DoDraw1` { @@ -293,42 +287,44 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) stop4 = x2_i & ~3; } - if (dc_x < x2_i) + if (x < x2_i) { - while ((dc_x < stop4) && (dc_x & 3)) + DrawerContext::SetMaskedColumnState(mfloorclip, mceilingclip, spryscale, sprtopscreen, sprflipvert); + + while ((x < stop4) && (x & 3)) { pixels = img->GetColumn(frac >> FRACBITS, spanptr); - R_DrawMaskedColumn(pixels, spans); - dc_x++; + DrawerContext::DrawMaskedColumn(x, pixels, spans); + x++; frac += xiscale_i; } - while (dc_x < stop4) + while (x < stop4) { - rt_initcols(nullptr); - for (int zz = 4; zz; --zz) + DrawerContext::RtInitCols(nullptr); + for (int zz = 0; zz < 4; ++zz) { pixels = img->GetColumn(frac >> FRACBITS, spanptr); - R_DrawMaskedColumnHoriz(pixels, spans); - dc_x++; + DrawerContext::DrawMaskedColumnHoriz(x + zz, pixels, spans); frac += xiscale_i; } - rt_draw4cols(dc_x - 4); + DrawerContext::DrawRt4cols(x); + x += 4; } - while (dc_x < x2_i) + while (x < x2_i) { pixels = img->GetColumn(frac >> FRACBITS, spanptr); - R_DrawMaskedColumn(pixels, spans); - dc_x++; + DrawerContext::DrawMaskedColumn(x, pixels, spans); + x++; frac += xiscale_i; } } CenterY = centeryback; } - R_FinishSetPatchStyle (); + DrawerContext::FinishSetPatchStyle (); - dc_destorg = destorgsave; + DrawerContext::SetCanvas(destorgsave); if (ticdup != 0 && menuactive == MENU_Off) { @@ -1024,9 +1020,11 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) if (IsBgra()) { + int inv_level = 64 - level; + uint32_t *spot = (uint32_t*)GetBuffer() + oldyyshifted + xx; - uint32_t fg = shade_pal_index_simple(basecolor, calc_light_multiplier(0)); + uint32_t fg = GPalette.BaseColors[basecolor].d; uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -1035,9 +1033,9 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) uint32_t bg_green = (*spot >> 8) & 0xff; uint32_t bg_blue = (*spot) & 0xff; - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; + uint32_t red = (fg_red * level + bg_red * inv_level + 1) / 64; + uint32_t green = (fg_green * level + bg_green * inv_level + 1) / 64; + uint32_t blue = (fg_blue * level + bg_blue * inv_level + 1) / 64; *spot = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -1399,16 +1397,15 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, sinrot = sin(rotation.Radians()); // Setup constant texture mapping parameters. - R_SetupSpanBits(tex); if (colormap) - R_SetSpanColormap(colormap, clamp(shade >> FRACBITS, 0, NUMCOLORMAPS - 1)); + DrawerContext::SetSpanLight(colormap, 0, clamp(shade >> FRACBITS, 0, NUMCOLORMAPS - 1)); else - R_SetSpanColormap(&identitycolormap, 0); - R_SetSpanSource(r_swtruecolor ? (const BYTE*)tex->GetPixelsBgra() : tex->GetPixels()); - scalex = double(1u << (32 - ds_xbits)) / scalex; - scaley = double(1u << (32 - ds_ybits)) / scaley; - ds_xstep = xs_RoundToInt(cosrot * scalex); - ds_ystep = xs_RoundToInt(sinrot * scaley); + DrawerContext::SetSpanLight(nullptr, 0, 0); + DrawerContext::SetSpanSource(tex); + scalex = double(1u << (32 - DrawerContext::SpanXBits())) / scalex; + scaley = double(1u << (32 - DrawerContext::SpanYBits())) / scaley; + DrawerContext::SetSpanXStep(xs_RoundToInt(cosrot * scalex)); + DrawerContext::SetSpanYStep(xs_RoundToInt(sinrot * scaley)); // Travel down the right edge and create an outline of that edge. pt1 = toppt; @@ -1472,9 +1469,9 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, #if 0 memset(this->Buffer + y * this->Pitch + x1, (int)tex, x2 - x1); #else - ds_y = y; - ds_x1 = x1; - ds_x2 = x2 - 1; + DrawerContext::SetSpanY(y); + DrawerContext::SetSpanX1(x1); + DrawerContext::SetSpanX2(x2 - 1); DVector2 tex(x1 - originx, y - originy); if (dorotate) @@ -1483,10 +1480,10 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, tex.X = t * cosrot - tex.Y * sinrot; tex.Y = tex.Y * cosrot + t * sinrot; } - ds_xfrac = xs_RoundToInt(tex.X * scalex); - ds_yfrac = xs_RoundToInt(tex.Y * scaley); + DrawerContext::SetSpanXFrac(xs_RoundToInt(tex.X * scalex)); + DrawerContext::SetSpanYFrac(xs_RoundToInt(tex.Y * scaley)); - R_DrawSpan(); + DrawerContext::DrawSimplePolySpan(); #endif } x += xinc; From 70dbde4f78a99f167c3dcfc41491cb3f5cfc6cc8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 17 Jun 2016 07:38:05 +0200 Subject: [PATCH 0660/1509] Added r_multithreaded CVAR and fixed some broken colors --- src/r_draw_rgba.cpp | 2057 +++++++++++++++++++++--------------------- src/r_draw_rgba.h | 8 +- src/r_drawt_rgba.cpp | 540 +++++------ 3 files changed, 1314 insertions(+), 1291 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 420b63dff..3e4bf241a 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -58,6 +58,8 @@ extern float rw_light; extern float rw_lightstep; extern int wallshade; +CVAR(Bool, r_multithreaded, true, 0) + ///////////////////////////////////////////////////////////////////////////// DrawerCommandQueue *DrawerCommandQueue::Instance() @@ -229,28 +231,28 @@ void DrawerCommandQueue::StopThreads() class DrawColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_texturefrac; - DWORD dc_iscale; - fixed_t dc_light; - const BYTE *dc_source; - int dc_pitch; - ShadeConstants dc_shade_constants; - BYTE *dc_colormap; + int _count; + BYTE *_dest; + DWORD _texturefrac; + DWORD _iscale; + fixed_t _light; + const BYTE *_source; + int _pitch; + ShadeConstants _shade_constants; + BYTE *_colormap; public: DrawColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_texturefrac = ::dc_texturefrac; - dc_iscale = ::dc_iscale; - dc_light = ::dc_light; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_shade_constants = ::dc_shade_constants; - dc_colormap = ::dc_colormap; + _count = dc_count; + _dest = dc_dest; + _texturefrac = dc_texturefrac; + _iscale = dc_iscale; + _light = dc_light; + _source = dc_source; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + _colormap = dc_colormap; } void Execute(DrawerThread *thread) override @@ -260,28 +262,28 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); // Zero length, column does not exceed a pixel. if (count <= 0) return; // Framebuffer destination address. - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; // Determine scaling, // which is the only mapping to be done. - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); // [RH] Get local copies of these variables so that the compiler // has a better chance of optimizing this well. - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; - BYTE *colormap = dc_colormap; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; + BYTE *colormap = _colormap; do { @@ -296,20 +298,20 @@ public: class FillColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - fixed_t dc_light; - int dc_pitch; - int dc_color; + int _count; + BYTE *_dest; + fixed_t _light; + int _pitch; + int _color; public: FillColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_light = ::dc_light; - dc_pitch = ::dc_pitch; - dc_color = ::dc_color; + _count = dc_count; + _dest = dc_dest; + _light = dc_light; + _pitch = dc_pitch; + _color = dc_color; } void Execute(DrawerThread *thread) override @@ -317,18 +319,18 @@ public: int count; uint32_t* dest; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - uint32_t light = calc_light_multiplier(dc_light); + uint32_t light = calc_light_multiplier(_light); { - int pitch = dc_pitch * thread->num_cores; - uint32_t color = shade_pal_index_simple(dc_color, light); + int pitch = _pitch * thread->num_cores; + uint32_t color = shade_pal_index_simple(_color, light); do { @@ -341,20 +343,20 @@ public: class FillAddColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - int dc_pitch; - fixed_t dc_light; - int dc_color; + int _count; + BYTE *_dest; + int _pitch; + fixed_t _light; + int _color; public: FillAddColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_color = ::dc_color; + _count = dc_count; + _dest = dc_dest; + _pitch = dc_pitch; + _light = dc_light; + _color = dc_color; } void Execute(DrawerThread *thread) override @@ -362,14 +364,14 @@ public: int count; uint32_t *dest; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -392,20 +394,20 @@ public: class FillAddClampColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - int dc_pitch; - fixed_t dc_light; - int dc_color; + int _count; + BYTE *_dest; + int _pitch; + fixed_t _light; + int _color; public: FillAddClampColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_color = ::dc_color; + _count = dc_count; + _dest = dc_dest; + _pitch = dc_pitch; + _light = dc_light; + _color = dc_color; } void Execute(DrawerThread *thread) override @@ -413,14 +415,14 @@ public: int count; uint32_t *dest; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -443,20 +445,20 @@ public: class FillSubClampColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - int dc_pitch; - int dc_color; - fixed_t dc_light; + int _count; + BYTE *_dest; + int _pitch; + int _color; + fixed_t _light; public: FillSubClampColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_pitch = ::dc_pitch; - dc_color = ::dc_color; - dc_light = ::dc_light; + _count = dc_count; + _dest = dc_dest; + _pitch = dc_pitch; + _color = dc_color; + _light = dc_light; } void Execute(DrawerThread *thread) override @@ -464,14 +466,14 @@ public: int count; uint32_t *dest; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -494,20 +496,20 @@ public: class FillRevSubClampColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - int dc_pitch; - int dc_color; - fixed_t dc_light; + int _count; + BYTE *_dest; + int _pitch; + int _color; + fixed_t _light; public: FillRevSubClampColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_pitch = ::dc_pitch; - dc_color = ::dc_color; - dc_light = ::dc_light; + _count = dc_count; + _dest = dc_dest; + _pitch = dc_pitch; + _color = dc_color; + _light = dc_light; } void Execute(DrawerThread *thread) override @@ -515,14 +517,14 @@ public: int count; uint32_t *dest; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -545,22 +547,22 @@ public: class DrawFuzzColumnRGBACommand : public DrawerCommand { - int dc_x; - int dc_yl; - int dc_yh; - BYTE *dc_destorg; - int dc_pitch; + int _x; + int _yl; + int _yh; + BYTE *_destorg; + int _pitch; int fuzzpos; int fuzzviewheight; public: DrawFuzzColumnRGBACommand() { - dc_x = ::dc_x; - dc_yl = ::dc_yl; - dc_yh = ::dc_yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; + _x = dc_x; + _yl = dc_yl; + _yh = dc_yh; + _destorg = dc_destorg; + _pitch = dc_pitch; fuzzpos = ::fuzzpos; fuzzviewheight = ::fuzzviewheight; } @@ -571,24 +573,24 @@ public: uint32_t *dest; // Adjust borders. Low... - if (dc_yl == 0) - dc_yl = 1; + if (_yl == 0) + _yl = 1; // .. and high. - if (dc_yh > fuzzviewheight) - dc_yh = fuzzviewheight; + if (_yh > fuzzviewheight) + _yh = fuzzviewheight; - count = thread->count_for_thread(dc_yl, dc_yh - dc_yl + 1); + count = thread->count_for_thread(_yl, _yh - _yl + 1); // Zero length. if (count <= 0) return; - dest = thread->dest_for_thread(dc_yl, dc_pitch, ylookup[dc_yl] + dc_x + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(_yl, _pitch, ylookup[_yl] + _x + (uint32_t*)_destorg); - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; int fuzzstep = thread->num_cores; - int fuzz = (fuzzpos + thread->skipped_by_thread(dc_yl)) % FUZZTABLE; + int fuzz = (fuzzpos + thread->skipped_by_thread(_yl)) % FUZZTABLE; while (count > 0) { @@ -622,32 +624,32 @@ public: class DrawAddColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - const BYTE *dc_source; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - BYTE *dc_colormap; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + const BYTE *_source; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; + BYTE *_colormap; public: DrawAddColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_colormap = ::dc_colormap; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _source = dc_source; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _colormap = dc_colormap; } void Execute(DrawerThread *thread) override @@ -657,25 +659,25 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - BYTE *colormap = dc_colormap; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; + BYTE *colormap = _colormap; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -703,28 +705,28 @@ public: class DrawTranslatedColumnRGBACommand : public DrawerCommand { - int dc_count; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - BYTE *dc_translation; - const BYTE *dc_source; - int dc_pitch; + int _count; + fixed_t _light; + ShadeConstants _shade_constants; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + BYTE *_translation; + const BYTE *_source; + int _pitch; public: DrawTranslatedColumnRGBACommand() { - dc_count = ::dc_count; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_translation = ::dc_translation; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; + _count = dc_count; + _light = dc_light; + _shade_constants = dc_shade_constants; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _translation = dc_translation; + _source = dc_source; + _pitch = dc_pitch; } void Execute(DrawerThread *thread) override @@ -734,23 +736,23 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { // [RH] Local copies of global vars to improve compiler optimizations - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; + BYTE *translation = _translation; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; do { @@ -764,28 +766,32 @@ public: class DrawTlatedAddColumnRGBACommand : public DrawerCommand { - int dc_count; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - BYTE *dc_translation; - const BYTE *dc_source; - int dc_pitch; + int _count; + fixed_t _light; + ShadeConstants _shade_constants; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + BYTE *_translation; + const BYTE *_source; + int _pitch; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawTlatedAddColumnRGBACommand() { - dc_count = ::dc_count; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_translation = ::dc_translation; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; + _count = dc_count; + _light = dc_light; + _shade_constants = dc_shade_constants; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _translation = dc_translation; + _source = dc_source; + _pitch = dc_pitch; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -795,25 +801,25 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; + BYTE *translation = _translation; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -842,28 +848,28 @@ public: class DrawShadedColumnRGBACommand : public DrawerCommand { private: - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - fixed_t dc_light; - const BYTE *dc_source; - lighttable_t *dc_colormap; - int dc_color; - int dc_pitch; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + fixed_t _light; + const BYTE *_source; + lighttable_t *_colormap; + int _color; + int _pitch; public: DrawShadedColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_light = ::dc_light; - dc_source = ::dc_source; - dc_colormap = ::dc_colormap; - dc_color = ::dc_color; - dc_pitch = ::dc_pitch; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _light = dc_light; + _source = dc_source; + _colormap = dc_colormap; + _color = dc_color; + _pitch = dc_pitch; } void Execute(DrawerThread *thread) override @@ -872,25 +878,25 @@ public: uint32_t *dest; fixed_t frac, fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; { - const BYTE *source = dc_source; - BYTE *colormap = dc_colormap; - int pitch = dc_pitch * thread->num_cores; + const BYTE *source = _source; + BYTE *colormap = _colormap; + int pitch = _pitch * thread->num_cores; do { @@ -915,30 +921,30 @@ public: class DrawAddClampColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - const BYTE *dc_source; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + const BYTE *_source; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawAddClampColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _source = dc_source; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -948,23 +954,23 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -991,32 +997,32 @@ public: class DrawAddClampTranslatedColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - BYTE *dc_translation; - const BYTE *dc_source; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + BYTE *_translation; + const BYTE *_source; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawAddClampTranslatedColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_translation = ::dc_translation; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _translation = dc_translation; + _source = dc_source; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -1026,24 +1032,24 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + BYTE *translation = _translation; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -1070,30 +1076,30 @@ public: class DrawSubClampColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - const BYTE *dc_source; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + const BYTE *_source; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawSubClampColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _source = dc_source; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -1103,23 +1109,23 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -1146,32 +1152,32 @@ public: class DrawSubClampTranslatedColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - const BYTE *dc_source; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - BYTE *dc_translation; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + const BYTE *_source; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; + BYTE *_translation; public: DrawSubClampTranslatedColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_translation = ::dc_translation; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _source = dc_source; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _translation = dc_translation; } void Execute(DrawerThread *thread) override @@ -1181,24 +1187,24 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + BYTE *translation = _translation; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -1225,30 +1231,30 @@ public: class DrawRevSubClampColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - const BYTE *dc_source; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + const BYTE *_source; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawRevSubClampColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _source = dc_source; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -1258,22 +1264,22 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -1300,32 +1306,32 @@ public: class DrawRevSubClampTranslatedColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - const BYTE *dc_source; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - BYTE *dc_translation; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + const BYTE *_source; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; + BYTE *_translation; public: DrawRevSubClampTranslatedColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_translation = ::dc_translation; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _source = dc_source; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _translation = dc_translation; } void Execute(DrawerThread *thread) override @@ -1335,24 +1341,24 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + BYTE *translation = _translation; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -1379,42 +1385,42 @@ public: class DrawSpanRGBACommand : public DrawerCommand { - const uint32_t *ds_source; - fixed_t ds_xfrac; - fixed_t ds_yfrac; - fixed_t ds_xstep; - fixed_t ds_ystep; - int ds_x1; - int ds_x2; - int ds_y; - int ds_xbits; - int ds_ybits; - BYTE *dc_destorg; - fixed_t ds_light; - ShadeConstants ds_shade_constants; + const uint32_t *_source; + fixed_t _xfrac; + fixed_t _yfrac; + fixed_t _xstep; + fixed_t _ystep; + int _x1; + int _x2; + int _y; + int _xbits; + int _ybits; + BYTE *_destorg; + fixed_t _light; + ShadeConstants _shade_constants; public: DrawSpanRGBACommand() { - ds_source = (const uint32_t*)::ds_source; - ds_xfrac = ::ds_xfrac; - ds_yfrac = ::ds_yfrac; - ds_xstep = ::ds_xstep; - ds_ystep = ::ds_ystep; - ds_x1 = ::ds_x1; - ds_x2 = ::ds_x2; - ds_y = ::ds_y; - ds_xbits = ::ds_xbits; - ds_ybits = ::ds_ybits; - dc_destorg = ::dc_destorg; - ds_light = ::ds_light; - ds_shade_constants = ::ds_shade_constants; + _source = (const uint32_t*)ds_source; + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _xstep = ds_xstep; + _ystep = ds_ystep; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _xbits = ds_xbits; + _ybits = ds_ybits; + _destorg = dc_destorg; + _light = ds_light; + _shade_constants = ds_shade_constants; } #ifdef NO_SSE void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1422,24 +1428,24 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const uint32_t* source = ds_source; + const uint32_t* source = _source; int count; int spot; - xfrac = ds_xfrac; - yfrac = ds_yfrac; + xfrac = _xfrac; + yfrac = _yfrac; - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - count = ds_x2 - ds_x1 + 1; + count = _x2 - _x1 + 1; - xstep = ds_xstep; - ystep = ds_ystep; + xstep = _xstep; + ystep = _ystep; - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - if (ds_xbits == 6 && ds_ybits == 6) + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. @@ -1458,9 +1464,9 @@ public: } else { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; do { @@ -1479,7 +1485,7 @@ public: #else void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1487,24 +1493,24 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const uint32_t* source = ds_source; + const uint32_t* source = _source; int count; int spot; - xfrac = ds_xfrac; - yfrac = ds_yfrac; + xfrac = _xfrac; + yfrac = _yfrac; - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - count = ds_x2 - ds_x1 + 1; + count = _x2 - _x1 + 1; - xstep = ds_xstep; - ystep = ds_ystep; + xstep = _xstep; + ystep = _ystep; - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - if (ds_xbits == 6 && ds_ybits == 6) + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. @@ -1604,9 +1610,9 @@ public: } else { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; int sse_count = count / 4; count -= sse_count * 4; @@ -1700,42 +1706,42 @@ public: class DrawSpanMaskedRGBACommand : public DrawerCommand { - const uint32_t *ds_source; - fixed_t ds_light; - ShadeConstants ds_shade_constants; - fixed_t ds_xfrac; - fixed_t ds_yfrac; - BYTE *dc_destorg; - int ds_x1; - int ds_x2; - int ds_y1; - int ds_y; - fixed_t ds_xstep; - fixed_t ds_ystep; - int ds_xbits; - int ds_ybits; + const uint32_t *_source; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _xfrac; + fixed_t _yfrac; + BYTE *_destorg; + int _x1; + int _x2; + int _y1; + int _y; + fixed_t _xstep; + fixed_t _ystep; + int _xbits; + int _ybits; public: DrawSpanMaskedRGBACommand() { - ds_source = (const uint32_t*)::ds_source; - ds_light = ::ds_light; - ds_shade_constants = ::ds_shade_constants; - ds_xfrac = ::ds_xfrac; - ds_yfrac = ::ds_yfrac; - dc_destorg = ::dc_destorg; - ds_x1 = ::ds_x1; - ds_x2 = ::ds_x2; - ds_y = ::ds_y; - ds_xstep = ::ds_xstep; - ds_ystep = ::ds_ystep; - ds_xbits = ::ds_xbits; - ds_ybits = ::ds_ybits; + _source = (const uint32_t*)ds_source; + _light = ds_light; + _shade_constants = ds_shade_constants; + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _destorg = dc_destorg; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _xstep = ds_xstep; + _ystep = ds_ystep; + _xbits = ds_xbits; + _ybits = ds_ybits; } void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1743,24 +1749,24 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const uint32_t* source = ds_source; + const uint32_t* source = _source; int count; int spot; - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - xfrac = ds_xfrac; - yfrac = ds_yfrac; + xfrac = _xfrac; + yfrac = _yfrac; - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - count = ds_x2 - ds_x1 + 1; + count = _x2 - _x1 + 1; - xstep = ds_xstep; - ystep = ds_ystep; + xstep = _xstep; + ystep = _ystep; - if (ds_xbits == 6 && ds_ybits == 6) + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. do @@ -1780,9 +1786,9 @@ public: } else { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; do { uint32_t texdata; @@ -1803,42 +1809,46 @@ public: class DrawSpanTranslucentRGBACommand : public DrawerCommand { - const uint32_t *ds_source; - fixed_t ds_light; - ShadeConstants ds_shade_constants; - fixed_t ds_xfrac; - fixed_t ds_yfrac; - BYTE *dc_destorg; - int ds_x1; - int ds_x2; - int ds_y1; - int ds_y; - fixed_t ds_xstep; - fixed_t ds_ystep; - int ds_xbits; - int ds_ybits; + const uint32_t *_source; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _xfrac; + fixed_t _yfrac; + BYTE *_destorg; + int _x1; + int _x2; + int _y1; + int _y; + fixed_t _xstep; + fixed_t _ystep; + int _xbits; + int _ybits; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawSpanTranslucentRGBACommand() { - ds_source = (const uint32_t *)::ds_source; - ds_light = ::ds_light; - ds_shade_constants = ::ds_shade_constants; - ds_xfrac = ::ds_xfrac; - ds_yfrac = ::ds_yfrac; - dc_destorg = ::dc_destorg; - ds_x1 = ::ds_x1; - ds_x2 = ::ds_x2; - ds_y = ::ds_y; - ds_xstep = ::ds_xstep; - ds_ystep = ::ds_ystep; - ds_xbits = ::ds_xbits; - ds_ybits = ::ds_ybits; + _source = (const uint32_t *)ds_source; + _light = ds_light; + _shade_constants = ds_shade_constants; + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _destorg = dc_destorg; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _xstep = ds_xstep; + _ystep = ds_ystep; + _xbits = ds_xbits; + _ybits = ds_ybits; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1846,27 +1856,27 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const uint32_t* source = ds_source; + const uint32_t* source = _source; int count; int spot; - xfrac = ds_xfrac; - yfrac = ds_yfrac; + xfrac = _xfrac; + yfrac = _yfrac; - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - count = ds_x2 - ds_x1 + 1; + count = _x2 - _x1 + 1; - xstep = ds_xstep; - ystep = ds_ystep; + xstep = _xstep; + ystep = _ystep; - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - if (ds_xbits == 6 && ds_ybits == 6) + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. do @@ -1894,9 +1904,9 @@ public: } else { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; do { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); @@ -1925,42 +1935,46 @@ public: class DrawSpanMaskedTranslucentRGBACommand : public DrawerCommand { - const uint32_t *ds_source; - fixed_t ds_light; - ShadeConstants ds_shade_constants; - fixed_t ds_xfrac; - fixed_t ds_yfrac; - BYTE *dc_destorg; - int ds_x1; - int ds_x2; - int ds_y1; - int ds_y; - fixed_t ds_xstep; - fixed_t ds_ystep; - int ds_xbits; - int ds_ybits; + const uint32_t *_source; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _xfrac; + fixed_t _yfrac; + BYTE *_destorg; + int _x1; + int _x2; + int _y1; + int _y; + fixed_t _xstep; + fixed_t _ystep; + int _xbits; + int _ybits; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawSpanMaskedTranslucentRGBACommand() { - ds_source = (const uint32_t*)::ds_source; - ds_light = ::ds_light; - ds_shade_constants = ::ds_shade_constants; - ds_xfrac = ::ds_xfrac; - ds_yfrac = ::ds_yfrac; - dc_destorg = ::dc_destorg; - ds_x1 = ::ds_x1; - ds_x2 = ::ds_x2; - ds_y = ::ds_y; - ds_xstep = ::ds_xstep; - ds_ystep = ::ds_ystep; - ds_xbits = ::ds_xbits; - ds_ybits = ::ds_ybits; + _source = (const uint32_t*)ds_source; + _light = ds_light; + _shade_constants = ds_shade_constants; + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _destorg = dc_destorg; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _xstep = ds_xstep; + _ystep = ds_ystep; + _xbits = ds_xbits; + _ybits = ds_ybits; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1968,27 +1982,27 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const uint32_t* source = ds_source; + const uint32_t* source = _source; int count; int spot; - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - xfrac = ds_xfrac; - yfrac = ds_yfrac; + xfrac = _xfrac; + yfrac = _yfrac; - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - count = ds_x2 - ds_x1 + 1; + count = _x2 - _x1 + 1; - xstep = ds_xstep; - ystep = ds_ystep; + xstep = _xstep; + ystep = _ystep; - if (ds_xbits == 6 && ds_ybits == 6) + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. do @@ -2021,9 +2035,9 @@ public: } else { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; do { uint32_t texdata; @@ -2057,42 +2071,46 @@ public: class DrawSpanAddClampRGBACommand : public DrawerCommand { - const uint32_t *ds_source; - fixed_t ds_light; - ShadeConstants ds_shade_constants; - fixed_t ds_xfrac; - fixed_t ds_yfrac; - BYTE *dc_destorg; - int ds_x1; - int ds_x2; - int ds_y1; - int ds_y; - fixed_t ds_xstep; - fixed_t ds_ystep; - int ds_xbits; - int ds_ybits; + const uint32_t *_source; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _xfrac; + fixed_t _yfrac; + BYTE *_destorg; + int _x1; + int _x2; + int _y1; + int _y; + fixed_t _xstep; + fixed_t _ystep; + int _xbits; + int _ybits; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawSpanAddClampRGBACommand() { - ds_source = (const uint32_t*)::ds_source; - ds_light = ::ds_light; - ds_shade_constants = ::ds_shade_constants; - ds_xfrac = ::ds_xfrac; - ds_yfrac = ::ds_yfrac; - dc_destorg = ::dc_destorg; - ds_x1 = ::ds_x1; - ds_x2 = ::ds_x2; - ds_y = ::ds_y; - ds_xstep = ::ds_xstep; - ds_ystep = ::ds_ystep; - ds_xbits = ::ds_xbits; - ds_ybits = ::ds_ybits; + _source = (const uint32_t*)ds_source; + _light = ds_light; + _shade_constants = ds_shade_constants; + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _destorg = dc_destorg; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _xstep = ds_xstep; + _ystep = ds_ystep; + _xbits = ds_xbits; + _ybits = ds_ybits; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -2100,27 +2118,27 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const uint32_t* source = ds_source; + const uint32_t* source = _source; int count; int spot; - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - xfrac = ds_xfrac; - yfrac = ds_yfrac; + xfrac = _xfrac; + yfrac = _yfrac; - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - count = ds_x2 - ds_x1 + 1; + count = _x2 - _x1 + 1; - xstep = ds_xstep; - ystep = ds_ystep; + xstep = _xstep; + ystep = _ystep; - if (ds_xbits == 6 && ds_ybits == 6) + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. do @@ -2148,9 +2166,9 @@ public: } else { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; do { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); @@ -2179,42 +2197,46 @@ public: class DrawSpanMaskedAddClampRGBACommand : public DrawerCommand { - const uint32_t *ds_source; - fixed_t ds_light; - ShadeConstants ds_shade_constants; - fixed_t ds_xfrac; - fixed_t ds_yfrac; - BYTE *dc_destorg; - int ds_x1; - int ds_x2; - int ds_y1; - int ds_y; - fixed_t ds_xstep; - fixed_t ds_ystep; - int ds_xbits; - int ds_ybits; + const uint32_t *_source; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _xfrac; + fixed_t _yfrac; + BYTE *_destorg; + int _x1; + int _x2; + int _y1; + int _y; + fixed_t _xstep; + fixed_t _ystep; + int _xbits; + int _ybits; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawSpanMaskedAddClampRGBACommand() { - ds_source = (const uint32_t*)::ds_source; - ds_light = ::ds_light; - ds_shade_constants = ::ds_shade_constants; - ds_xfrac = ::ds_xfrac; - ds_yfrac = ::ds_yfrac; - dc_destorg = ::dc_destorg; - ds_x1 = ::ds_x1; - ds_x2 = ::ds_x2; - ds_y = ::ds_y; - ds_xstep = ::ds_xstep; - ds_ystep = ::ds_ystep; - ds_xbits = ::ds_xbits; - ds_ybits = ::ds_ybits; + _source = (const uint32_t*)ds_source; + _light = ds_light; + _shade_constants = ds_shade_constants; + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _destorg = dc_destorg; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _xstep = ds_xstep; + _ystep = ds_ystep; + _xbits = ds_xbits; + _ybits = ds_ybits; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -2222,27 +2244,27 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const uint32_t* source = ds_source; + const uint32_t* source = _source; int count; int spot; - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - xfrac = ds_xfrac; - yfrac = ds_yfrac; + xfrac = _xfrac; + yfrac = _yfrac; - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - count = ds_x2 - ds_x1 + 1; + count = _x2 - _x1 + 1; - xstep = ds_xstep; - ystep = ds_ystep; + xstep = _xstep; + ystep = _ystep; - if (ds_xbits == 6 && ds_ybits == 6) + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. do @@ -2275,9 +2297,9 @@ public: } else { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; do { uint32_t texdata; @@ -2311,33 +2333,33 @@ public: class FillSpanRGBACommand : public DrawerCommand { - int ds_x1; - int ds_x2; - int ds_y; - BYTE *dc_destorg; - fixed_t ds_light; - int ds_color; + int _x1; + int _x2; + int _y; + BYTE *_destorg; + fixed_t _light; + int _color; public: FillSpanRGBACommand() { - ds_x1 = ::ds_x1; - ds_x2 = ::ds_x2; - ds_y = ::ds_y; - dc_destorg = ::dc_destorg; - ds_light = ::ds_light; - ds_color = ::ds_color; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _destorg = dc_destorg; + _light = ds_light; + _color = ds_color; } void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; - uint32_t *dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; - int count = (ds_x2 - ds_x1 + 1); - uint32_t light = calc_light_multiplier(ds_light); - uint32_t color = shade_pal_index_simple(ds_color, light); + uint32_t *dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; + int count = (_x2 - _x1 + 1); + uint32_t light = calc_light_multiplier(_light); + uint32_t color = shade_pal_index_simple(_color, light); for (int i = 0; i < count; i++) dest[i] = color; } @@ -2345,45 +2367,45 @@ public: class Vlinec1RGBACommand : public DrawerCommand { - DWORD dc_iscale; - DWORD dc_texturefrac; - int dc_count; - const BYTE *dc_source; - BYTE *dc_dest; + DWORD _iscale; + DWORD _texturefrac; + int _count; + const BYTE *_source; + BYTE *_dest; int vlinebits; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; public: Vlinec1RGBACommand() { - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_count = ::dc_count; - dc_source = ::dc_source; - dc_dest = ::dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _count = dc_count; + _source = dc_source; + _dest = dc_dest; vlinebits = ::vlinebits; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - DWORD fracstep = dc_iscale * thread->num_cores; - DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const uint32 *source = (const uint32 *)dc_source; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + DWORD fracstep = _iscale * thread->num_cores; + DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); + const uint32 *source = (const uint32 *)_source; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = vlinebits; - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; do { @@ -2396,10 +2418,10 @@ public: class Vlinec4RGBACommand : public DrawerCommand { - BYTE *dc_dest; - int dc_count; - int dc_pitch; - ShadeConstants dc_shade_constants; + BYTE *_dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; int vlinebits; fixed_t palookuplight[4]; DWORD vplce[4]; @@ -2409,10 +2431,10 @@ class Vlinec4RGBACommand : public DrawerCommand public: Vlinec4RGBACommand() { - dc_dest = ::dc_dest; - dc_count = ::dc_count; - dc_pitch = ::dc_pitch; - dc_shade_constants = ::dc_shade_constants; + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; vlinebits = ::vlinebits; for (int i = 0; i < 4; i++) { @@ -2426,12 +2448,12 @@ public: #ifdef NO_SSE void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; int bits = vlinebits; DWORD place; @@ -2440,11 +2462,11 @@ public: uint32_t light2 = calc_light_multiplier(palookuplight[2]); uint32_t light3 = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -2463,24 +2485,24 @@ public: #else void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = vlinebits; - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; uint32_t light0 = calc_light_multiplier(palookuplight[0]); uint32_t light1 = calc_light_multiplier(palookuplight[1]); uint32_t light2 = calc_light_multiplier(palookuplight[2]); uint32_t light3 = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -2545,45 +2567,45 @@ public: class Mvlinec1RGBACommand : public DrawerCommand { - DWORD dc_iscale; - DWORD dc_texturefrac; - int dc_count; - const BYTE *dc_source; - BYTE *dc_dest; + DWORD _iscale; + DWORD _texturefrac; + int _count; + const BYTE *_source; + BYTE *_dest; int mvlinebits; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; public: Mvlinec1RGBACommand() { - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_count = ::dc_count; - dc_source = ::dc_source; - dc_dest = ::dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _count = dc_count; + _source = dc_source; + _dest = dc_dest; mvlinebits = ::mvlinebits; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - DWORD fracstep = dc_iscale * thread->num_cores; - DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const uint32 *source = (const uint32 *)dc_source; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + DWORD fracstep = _iscale * thread->num_cores; + DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); + const uint32 *source = (const uint32 *)_source; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = mvlinebits; - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; do { @@ -2600,10 +2622,10 @@ public: class Mvlinec4RGBACommand : public DrawerCommand { - BYTE *dc_dest; - int dc_count; - int dc_pitch; - ShadeConstants dc_shade_constants; + BYTE *_dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; int mvlinebits; fixed_t palookuplight[4]; DWORD vplce[4]; @@ -2613,10 +2635,10 @@ class Mvlinec4RGBACommand : public DrawerCommand public: Mvlinec4RGBACommand() { - dc_dest = ::dc_dest; - dc_count = ::dc_count; - dc_pitch = ::dc_pitch; - dc_shade_constants = ::dc_shade_constants; + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; mvlinebits = ::mvlinebits; for (int i = 0; i < 4; i++) { @@ -2630,12 +2652,12 @@ public: #ifdef NO_SSE void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; int bits = mvlinebits; DWORD place; @@ -2644,11 +2666,11 @@ public: uint32_t light2 = calc_light_multiplier(palookuplight[2]); uint32_t light3 = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -2668,12 +2690,12 @@ public: #else void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; int bits = mvlinebits; uint32_t light0 = calc_light_multiplier(palookuplight[0]); @@ -2681,11 +2703,11 @@ public: uint32_t light2 = calc_light_multiplier(palookuplight[2]); uint32_t light3 = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -2756,52 +2778,52 @@ public: class Tmvline1AddRGBACommand : public DrawerCommand { - DWORD dc_iscale; - DWORD dc_texturefrac; - int dc_count; - const BYTE *dc_source; - BYTE *dc_dest; + DWORD _iscale; + DWORD _texturefrac; + int _count; + const BYTE *_source; + BYTE *_dest; int tmvlinebits; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: Tmvline1AddRGBACommand() { - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_count = ::dc_count; - dc_source = ::dc_source; - dc_dest = ::dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _count = dc_count; + _source = dc_source; + _dest = dc_dest; tmvlinebits = ::tmvlinebits; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - DWORD fracstep = dc_iscale * thread->num_cores; - DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const uint32 *source = (const uint32 *)dc_source; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + DWORD fracstep = _iscale * thread->num_cores; + DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); + const uint32 *source = (const uint32 *)_source; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = tmvlinebits; - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -2831,12 +2853,12 @@ public: class Tmvline4AddRGBACommand : public DrawerCommand { - BYTE *dc_dest; - int dc_count; - int dc_pitch; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + BYTE *_dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; int tmvlinebits; fixed_t palookuplight[4]; DWORD vplce[4]; @@ -2846,12 +2868,12 @@ class Tmvline4AddRGBACommand : public DrawerCommand public: Tmvline4AddRGBACommand() { - dc_dest = ::dc_dest; - dc_count = ::dc_count; - dc_pitch = ::dc_pitch; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; tmvlinebits = ::tmvlinebits; for (int i = 0; i < 4; i++) { @@ -2864,12 +2886,12 @@ public: void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; int bits = tmvlinebits; uint32_t light[4]; @@ -2878,14 +2900,14 @@ public: light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -2923,52 +2945,52 @@ public: class Tmvline1AddClampRGBACommand : public DrawerCommand { - DWORD dc_iscale; - DWORD dc_texturefrac; - int dc_count; - const BYTE *dc_source; - BYTE *dc_dest; + DWORD _iscale; + DWORD _texturefrac; + int _count; + const BYTE *_source; + BYTE *_dest; int tmvlinebits; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: Tmvline1AddClampRGBACommand() { - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_count = ::dc_count; - dc_source = ::dc_source; - dc_dest = ::dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _count = dc_count; + _source = dc_source; + _dest = dc_dest; tmvlinebits = ::tmvlinebits; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - DWORD fracstep = dc_iscale * thread->num_cores; - DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const uint32 *source = (const uint32 *)dc_source; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + DWORD fracstep = _iscale * thread->num_cores; + DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); + const uint32 *source = (const uint32 *)_source; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = tmvlinebits; - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -2998,12 +3020,12 @@ public: class Tmvline4AddClampRGBACommand : public DrawerCommand { - BYTE *dc_dest; - int dc_count; - int dc_pitch; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + BYTE *_dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; int tmvlinebits; fixed_t palookuplight[4]; DWORD vplce[4]; @@ -3013,12 +3035,12 @@ class Tmvline4AddClampRGBACommand : public DrawerCommand public: Tmvline4AddClampRGBACommand() { - dc_dest = ::dc_dest; - dc_count = ::dc_count; - dc_pitch = ::dc_pitch; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; tmvlinebits = ::tmvlinebits; for (int i = 0; i < 4; i++) { @@ -3031,12 +3053,12 @@ public: void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; int bits = tmvlinebits; uint32_t light[4]; @@ -3045,14 +3067,14 @@ public: light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -3090,52 +3112,52 @@ public: class Tmvline1SubClampRGBACommand : public DrawerCommand { - DWORD dc_iscale; - DWORD dc_texturefrac; - int dc_count; - const BYTE *dc_source; - BYTE *dc_dest; + DWORD _iscale; + DWORD _texturefrac; + int _count; + const BYTE *_source; + BYTE *_dest; int tmvlinebits; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: Tmvline1SubClampRGBACommand() { - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_count = ::dc_count; - dc_source = ::dc_source; - dc_dest = ::dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _count = dc_count; + _source = dc_source; + _dest = dc_dest; tmvlinebits = ::tmvlinebits; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - DWORD fracstep = dc_iscale * thread->num_cores; - DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const uint32 *source = (const uint32 *)dc_source; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + DWORD fracstep = _iscale * thread->num_cores; + DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); + const uint32 *source = (const uint32 *)_source; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = tmvlinebits; - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -3165,12 +3187,12 @@ public: class Tmvline4SubClampRGBACommand : public DrawerCommand { - BYTE *dc_dest; - int dc_count; - int dc_pitch; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + BYTE *_dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; int tmvlinebits; fixed_t palookuplight[4]; DWORD vplce[4]; @@ -3180,12 +3202,12 @@ class Tmvline4SubClampRGBACommand : public DrawerCommand public: Tmvline4SubClampRGBACommand() { - dc_dest = ::dc_dest; - dc_count = ::dc_count; - dc_pitch = ::dc_pitch; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; tmvlinebits = ::tmvlinebits; for (int i = 0; i < 4; i++) { @@ -3198,12 +3220,12 @@ public: void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; int bits = tmvlinebits; uint32_t light[4]; @@ -3212,14 +3234,14 @@ public: light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -3257,52 +3279,52 @@ public: class Tmvline1RevSubClampRGBACommand : public DrawerCommand { - DWORD dc_iscale; - DWORD dc_texturefrac; - int dc_count; - const BYTE *dc_source; - BYTE *dc_dest; + DWORD _iscale; + DWORD _texturefrac; + int _count; + const BYTE *_source; + BYTE *_dest; int tmvlinebits; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: Tmvline1RevSubClampRGBACommand() { - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_count = ::dc_count; - dc_source = ::dc_source; - dc_dest = ::dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _count = dc_count; + _source = dc_source; + _dest = dc_dest; tmvlinebits = ::tmvlinebits; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - DWORD fracstep = dc_iscale * thread->num_cores; - DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const uint32 *source = (const uint32 *)dc_source; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + DWORD fracstep = _iscale * thread->num_cores; + DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); + const uint32 *source = (const uint32 *)_source; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = tmvlinebits; - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -3332,12 +3354,12 @@ public: class Tmvline4RevSubClampRGBACommand : public DrawerCommand { - BYTE *dc_dest; - int dc_count; - int dc_pitch; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + BYTE *_dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; int tmvlinebits; fixed_t palookuplight[4]; DWORD vplce[4]; @@ -3347,12 +3369,12 @@ class Tmvline4RevSubClampRGBACommand : public DrawerCommand public: Tmvline4RevSubClampRGBACommand() { - dc_dest = ::dc_dest; - dc_count = ::dc_count; - dc_pitch = ::dc_pitch; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; tmvlinebits = ::tmvlinebits; for (int i = 0; i < 4; i++) { @@ -3365,12 +3387,12 @@ public: void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; int bits = tmvlinebits; uint32_t light[4]; @@ -3379,14 +3401,14 @@ public: light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -3427,9 +3449,9 @@ class DrawFogBoundaryLineRGBACommand : public DrawerCommand int _y; int _x; int _x2; - BYTE *dc_destorg; - fixed_t dc_light; - ShadeConstants dc_shade_constants; + BYTE *_destorg; + fixed_t _light; + ShadeConstants _shade_constants; public: DrawFogBoundaryLineRGBACommand(int y, int x, int x2) @@ -3438,9 +3460,9 @@ public: _x = x; _x2 = x2; - dc_destorg = ::dc_destorg; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; + _destorg = dc_destorg; + _light = dc_light; + _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override @@ -3452,10 +3474,10 @@ public: int x = _x; int x2 = _x2; - uint32_t *dest = ylookup[y] + (uint32_t*)dc_destorg; + uint32_t *dest = ylookup[y] + (uint32_t*)_destorg; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants constants = _shade_constants; do { @@ -3499,10 +3521,10 @@ class DrawTiltedSpanRGBACommand : public DrawerCommand int _y; int _x1; int _x2; - BYTE *dc_destorg; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - const BYTE *ds_source; + BYTE *_destorg; + fixed_t _light; + ShadeConstants _shade_constants; + const BYTE *_source; public: DrawTiltedSpanRGBACommand(int y, int x1, int x2) @@ -3511,8 +3533,8 @@ public: _x1 = x1; _x2 = x2; - dc_destorg = ::dc_destorg; - ds_source = ::ds_source; + _destorg = dc_destorg; + _source = ds_source; } void Execute(DrawerThread *thread) override @@ -3527,8 +3549,8 @@ public: // Slopes are broken currently in master. // Until R_DrawTiltedPlane is fixed we are just going to fill with a solid color. - uint32_t *source = (uint32_t*)ds_source; - uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg; + uint32_t *source = (uint32_t*)_source; + uint32_t *dest = ylookup[y] + x1 + (uint32_t*)_destorg; int count = x2 - x1 + 1; while (count > 0) @@ -3544,9 +3566,9 @@ class DrawColoredSpanRGBACommand : public DrawerCommand int _y; int _x1; int _x2; - BYTE *dc_destorg; - fixed_t ds_light; - int ds_color; + BYTE *_destorg; + fixed_t _light; + int _color; public: DrawColoredSpanRGBACommand(int y, int x1, int x2) @@ -3555,9 +3577,9 @@ public: _x1 = x1; _x2 = x2; - dc_destorg = ::dc_destorg; - ds_light = ::ds_light; - ds_color = ::ds_color; + _destorg = dc_destorg; + _light = ds_light; + _color = ds_color; } void Execute(DrawerThread *thread) override @@ -3569,10 +3591,10 @@ public: int x1 = _x1; int x2 = _x2; - uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg; + uint32_t *dest = ylookup[y] + x1 + (uint32_t*)_destorg; int count = (x2 - x1 + 1); - uint32_t light = calc_light_multiplier(ds_light); - uint32_t color = shade_pal_index_simple(ds_color, light); + uint32_t light = calc_light_multiplier(_light); + uint32_t color = shade_pal_index_simple(_color, light); for (int i = 0; i < count; i++) dest[i] = color; } @@ -3585,10 +3607,9 @@ class FillTransColumnRGBACommand : public DrawerCommand int _y2; int _color; int _a; - BYTE *dc_destorg; - int dc_pitch; - fixed_t ds_light; - int ds_color; + BYTE *_destorg; + int _pitch; + fixed_t _light; public: FillTransColumnRGBACommand(int x, int y1, int y2, int color, int a) @@ -3599,8 +3620,8 @@ public: _color = color; _a = a; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; + _destorg = dc_destorg; + _pitch = dc_pitch; } void Execute(DrawerThread *thread) override @@ -3627,8 +3648,8 @@ public: fg_green *= alpha; fg_blue *= alpha; - int spacing = dc_pitch * thread->num_cores; - uint32_t *dest = thread->dest_for_thread(y1, dc_pitch, ylookup[y1] + x + (uint32_t*)dc_destorg); + int spacing = _pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(y1, _pitch, ylookup[y1] + x + (uint32_t*)_destorg); for (int y = 0; y < ycount; y++) { diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index a91b54d74..6e35de9ff 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -178,17 +178,19 @@ public: class DrawerCommand { protected: - int dc_dest_y; + int _dest_y; public: DrawerCommand() { - dc_dest_y = static_cast((dc_dest - dc_destorg) / (dc_pitch * 4)); + _dest_y = static_cast((dc_dest - dc_destorg) / (dc_pitch * 4)); } virtual void Execute(DrawerThread *thread) = 0; }; +EXTERN_CVAR(Bool, r_multithreaded) + // Manages queueing up commands and executing them on worker threads class DrawerCommandQueue { @@ -232,7 +234,7 @@ public: static void QueueCommand(Types &&... args) { auto queue = Instance(); - if (queue->threaded_render == 0) + if (queue->threaded_render == 0 || !r_multithreaded) { T command(std::forward(args)...); command.Execute(&queue->single_core_thread); diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 4b6605b4a..0eabc48d8 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -61,8 +61,8 @@ class RtCopy1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; + BYTE *_destorg; + int _pitch; public: RtCopy1colRGBACommand(int hx, int sx, int yl, int yh) @@ -72,8 +72,8 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; + _destorg = dc_destorg; + _pitch = dc_pitch; } void Execute(DrawerThread *thread) override @@ -87,9 +87,9 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = thread->num_cores * 4; if (count & 1) { @@ -123,11 +123,11 @@ class RtMap1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - BYTE *dc_destorg; - int dc_pitch; - BYTE *dc_colormap; + fixed_t _light; + ShadeConstants _shade_constants; + BYTE *_destorg; + int _pitch; + BYTE *_colormap; public: RtMap1colRGBACommand(int hx, int sx, int yl, int yh) @@ -137,11 +137,11 @@ public: this->yl = yl; this->yh = yh; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_colormap = ::dc_colormap; + _light = dc_light; + _shade_constants = dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _colormap = dc_colormap; } void Execute(DrawerThread *thread) override @@ -156,15 +156,15 @@ public: if (count <= 0) return; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = thread->num_cores * 4; - BYTE *colormap = dc_colormap; + BYTE *colormap = _colormap; if (count & 1) { *dest = shade_pal_index(colormap[*source], light, shade_constants); @@ -188,11 +188,11 @@ class RtMap4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - BYTE *dc_destorg; - int dc_pitch; - BYTE *colormap; + fixed_t _light; + ShadeConstants _shade_constants; + BYTE *_destorg; + int _pitch; + BYTE *_colormap; public: RtMap4colsRGBACommand(int sx, int yl, int yh) @@ -201,11 +201,11 @@ public: this->yl = yl; this->yh = yh; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_colormap = ::dc_colormap; + _light = dc_light; + _shade_constants = dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _colormap = dc_colormap; } #ifdef NO_SSE @@ -221,15 +221,15 @@ public: if (count <= 0) return; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = thread->num_cores * 4; - BYTE *colormap = dc_colormap; + BYTE *colormap = _colormap; if (count & 1) { dest[0] = shade_pal_index(colormap[source[0]], light, shade_constants); @@ -268,16 +268,16 @@ public: if (count <= 0) return; - ShadeConstants shade_constants = dc_shade_constants; - uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = _shade_constants; + uint32_t light = calc_light_multiplier(_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = thread->num_cores * 4; - BYTE *colormap = dc_colormap; + BYTE *colormap = _colormap; if (shade_constants.simple_shade) { @@ -509,13 +509,13 @@ class RtAdd1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - BYTE *dc_colormap; + BYTE *_destorg; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; + BYTE *_colormap; public: RtAdd1colRGBACommand(int hx, int sx, int yl, int yh) @@ -525,13 +525,13 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_colormap = ::dc_colormap; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _colormap = dc_colormap; } void Execute(DrawerThread *thread) override @@ -546,17 +546,17 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - BYTE *colormap = dc_colormap; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; + BYTE *colormap = _colormap; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { uint32_t fg = shade_pal_index(colormap[*source], light, shade_constants); @@ -585,13 +585,13 @@ class RtAdd4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - BYTE *dc_colormap; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + BYTE *_destorg; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + BYTE *_colormap; + fixed_t _srcalpha; + fixed_t _destalpha; public: RtAdd4colsRGBACommand(int sx, int yl, int yh) @@ -600,13 +600,13 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_colormap = ::dc_colormap; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _colormap = dc_colormap; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } #ifdef NO_SSE @@ -622,17 +622,17 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - BYTE *colormap = dc_colormap; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; + BYTE *colormap = _colormap; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { for (int i = 0; i < 4; i++) @@ -670,19 +670,19 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); + uint32_t light = calc_light_multiplier(_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; - BYTE *colormap = dc_colormap; + BYTE *colormap = _colormap; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; if (shade_constants.simple_shade) { @@ -766,11 +766,11 @@ class RtShaded1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - lighttable_t *dc_colormap; - BYTE *dc_destorg; - int dc_pitch; - int dc_color; - fixed_t dc_light; + lighttable_t *_colormap; + BYTE *_destorg; + int _pitch; + int _color; + fixed_t _light; public: RtShaded1colRGBACommand(int hx, int sx, int yl, int yh) @@ -780,11 +780,11 @@ public: this->yl = yl; this->yh = yh; - dc_colormap = ::dc_colormap; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_color = ::dc_color; - dc_light = ::dc_light; + _colormap = dc_colormap; + _destorg = dc_destorg; + _pitch = dc_pitch; + _color = dc_color; + _light = dc_light; } void Execute(DrawerThread *thread) override @@ -800,13 +800,13 @@ public: if (count <= 0) return; - colormap = dc_colormap; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + colormap = _colormap; + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -835,11 +835,11 @@ class RtShaded4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - lighttable_t *dc_colormap; - int dc_color; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; + lighttable_t *_colormap; + int _color; + BYTE *_destorg; + int _pitch; + fixed_t _light; public: RtShaded4colsRGBACommand(int sx, int yl, int yh) @@ -848,11 +848,11 @@ public: this->yl = yl; this->yh = yh; - dc_colormap = ::dc_colormap; - dc_color = ::dc_color; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; + _colormap = dc_colormap; + _color = dc_color; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; } #ifdef NO_SSE @@ -869,13 +869,13 @@ public: if (count <= 0) return; - colormap = dc_colormap; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + colormap = _colormap; + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -914,13 +914,13 @@ public: if (count <= 0) return; - colormap = dc_colormap; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + colormap = _colormap; + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light))), _mm_setzero_si128()); + __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(shade_pal_index_simple(_color, calc_light_multiplier(_light))), _mm_setzero_si128()); __m128i alpha_one = _mm_set1_epi16(64); do { @@ -959,12 +959,12 @@ class RtAddClamp1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + BYTE *_destorg; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: RtAddClamp1colRGBACommand(int hx, int sx, int yl, int yh) @@ -974,12 +974,12 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -994,16 +994,16 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { uint32_t fg = shade_pal_index(*source, light, shade_constants); @@ -1031,12 +1031,12 @@ class RtAddClamp4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - ShadeConstants dc_shade_constants; + BYTE *_destorg; + int _pitch; + fixed_t _light; + fixed_t _srcalpha; + fixed_t _destalpha; + ShadeConstants _shade_constants; public: RtAddClamp4colsRGBACommand(int sx, int yl, int yh) @@ -1045,12 +1045,12 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_shade_constants = ::dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _shade_constants = dc_shade_constants; } #ifdef NO_SSE @@ -1066,16 +1066,16 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { for (int i = 0; i < 4; i++) @@ -1112,18 +1112,18 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); + uint32_t light = calc_light_multiplier(_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; if (shade_constants.simple_shade) { @@ -1207,12 +1207,12 @@ class RtSubClamp1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - ShadeConstants dc_shade_constants; + BYTE *_destorg; + int _pitch; + fixed_t _light; + fixed_t _srcalpha; + fixed_t _destalpha; + ShadeConstants _shade_constants; public: RtSubClamp1colRGBACommand(int hx, int sx, int yl, int yh) @@ -1222,12 +1222,12 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_shade_constants = ::dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override @@ -1242,16 +1242,16 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { uint32_t fg = shade_pal_index(*source, light, shade_constants); @@ -1279,12 +1279,12 @@ class RtSubClamp4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - ShadeConstants dc_shade_constants; + BYTE *_destorg; + int _pitch; + fixed_t _light; + fixed_t _srcalpha; + fixed_t _destalpha; + ShadeConstants _shade_constants; public: RtSubClamp4colsRGBACommand(int sx, int yl, int yh) @@ -1293,12 +1293,12 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_shade_constants = ::dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override @@ -1313,16 +1313,16 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { for (int i = 0; i < 4; i++) @@ -1355,12 +1355,12 @@ class RtRevSubClamp1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - ShadeConstants dc_shade_constants; + BYTE *_destorg; + int _pitch; + fixed_t _light; + fixed_t _srcalpha; + fixed_t _destalpha; + ShadeConstants _shade_constants; public: RtRevSubClamp1colRGBACommand(int hx, int sx, int yl, int yh) @@ -1370,12 +1370,12 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_shade_constants = ::dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override @@ -1390,16 +1390,16 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { uint32_t fg = shade_pal_index(*source, light, shade_constants); @@ -1427,12 +1427,12 @@ class RtRevSubClamp4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - ShadeConstants dc_shade_constants; + BYTE *_destorg; + int _pitch; + fixed_t _light; + fixed_t _srcalpha; + fixed_t _destalpha; + ShadeConstants _shade_constants; public: RtRevSubClamp4colsRGBACommand(int sx, int yl, int yh) @@ -1441,12 +1441,12 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_shade_constants = ::dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override @@ -1461,16 +1461,16 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { for (int i = 0; i < 4; i++) @@ -1515,29 +1515,29 @@ public: class DrawColumnHorizRGBACommand : public DrawerCommand { - int dc_count; - fixed_t dc_iscale; - fixed_t dc_texturefrac; - const BYTE *dc_source; - int dc_x; - int dc_yl; - int dc_yh; + int _count; + fixed_t _iscale; + fixed_t _texturefrac; + const BYTE *_source; + int _x; + int _yl; + int _yh; public: DrawColumnHorizRGBACommand() { - dc_count = ::dc_count; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_source = ::dc_source; - dc_x = ::dc_x; - dc_yl = ::dc_yl; - dc_yh = ::dc_yh; + _count = dc_count; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _source = dc_source; + _x = dc_x; + _yl = dc_yl; + _yh = dc_yh; } void Execute(DrawerThread *thread) override { - int count = dc_count; + int count = _count; uint32_t *dest; fixed_t fracstep; fixed_t frac; @@ -1546,13 +1546,13 @@ public: return; { - int x = dc_x & 3; - dest = &thread->dc_temp_rgba[x + 4 * dc_yl]; + int x = _x & 3; + dest = &thread->dc_temp_rgba[x + 4 * _yl]; } - fracstep = dc_iscale; - frac = dc_texturefrac; + fracstep = _iscale; + frac = _texturefrac; - const BYTE *source = dc_source; + const BYTE *source = _source; if (count & 1) { *dest = source[frac >> FRACBITS]; dest += 4; frac += fracstep; @@ -1589,34 +1589,34 @@ public: class FillColumnHorizRGBACommand : public DrawerCommand { - int dc_x; - int dc_yl; - int dc_yh; - int dc_count; - int dc_color; + int _x; + int _yl; + int _yh; + int _count; + int _color; public: FillColumnHorizRGBACommand() { - dc_x = ::dc_x; - dc_count = ::dc_count; - dc_color = ::dc_color; - dc_yl = ::dc_yl; - dc_yh = ::dc_yh; + _x = dc_x; + _count = dc_count; + _color = dc_color; + _yl = dc_yl; + _yh = dc_yh; } void Execute(DrawerThread *thread) override { - int count = dc_count; - int color = dc_color; + int count = _count; + int color = _color; uint32_t *dest; if (count <= 0) return; { - int x = dc_x & 3; - dest = &thread->dc_temp_rgba[x + 4 * dc_yl]; + int x = _x & 3; + dest = &thread->dc_temp_rgba[x + 4 * _yl]; } if (count & 1) { From fee8650357e87ee6fc19a622133ec95d9ca9f364 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 17 Jun 2016 08:02:41 +0200 Subject: [PATCH 0661/1509] Add r_multithreaded and fix color issue --- src/r_draw_rgba.cpp | 2159 +++++++++++++++++++++++------------------- src/r_draw_rgba.h | 4 +- src/r_drawt_rgba.cpp | 540 +++++------ 3 files changed, 1439 insertions(+), 1264 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 2062609b4..722fbb8cd 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -56,6 +56,8 @@ extern float rw_light; extern float rw_lightstep; extern int wallshade; +CVAR(Bool, r_multithreaded, true, 0) + ///////////////////////////////////////////////////////////////////////////// DrawerCommandQueue *DrawerCommandQueue::Instance() @@ -227,28 +229,28 @@ void DrawerCommandQueue::StopThreads() class DrawColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_texturefrac; - DWORD dc_iscale; - fixed_t dc_light; - const BYTE *dc_source; - int dc_pitch; - ShadeConstants dc_shade_constants; - BYTE *dc_colormap; + int _count; + BYTE *_dest; + DWORD _texturefrac; + DWORD _iscale; + fixed_t _light; + const BYTE *_source; + int _pitch; + ShadeConstants _shade_constants; + BYTE *_colormap; public: DrawColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_texturefrac = ::dc_texturefrac; - dc_iscale = ::dc_iscale; - dc_light = ::dc_light; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_shade_constants = ::dc_shade_constants; - dc_colormap = ::dc_colormap; + _count = dc_count; + _dest = dc_dest; + _texturefrac = dc_texturefrac; + _iscale = dc_iscale; + _light = dc_light; + _source = dc_source; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + _colormap = dc_colormap; } void Execute(DrawerThread *thread) override @@ -258,28 +260,28 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); // Zero length, column does not exceed a pixel. if (count <= 0) return; // Framebuffer destination address. - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; // Determine scaling, // which is the only mapping to be done. - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); // [RH] Get local copies of these variables so that the compiler // has a better chance of optimizing this well. - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; - BYTE *colormap = dc_colormap; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; + BYTE *colormap = _colormap; do { @@ -294,20 +296,20 @@ public: class FillColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - fixed_t dc_light; - int dc_pitch; - int dc_color; + int _count; + BYTE *_dest; + fixed_t _light; + int _pitch; + int _color; public: FillColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_light = ::dc_light; - dc_pitch = ::dc_pitch; - dc_color = ::dc_color; + _count = dc_count; + _dest = dc_dest; + _light = dc_light; + _pitch = dc_pitch; + _color = dc_color; } void Execute(DrawerThread *thread) override @@ -315,18 +317,18 @@ public: int count; uint32_t* dest; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - uint32_t light = calc_light_multiplier(dc_light); + uint32_t light = calc_light_multiplier(_light); { - int pitch = dc_pitch * thread->num_cores; - uint32_t color = shade_pal_index_simple(dc_color, light); + int pitch = _pitch * thread->num_cores; + uint32_t color = shade_pal_index_simple(_color, light); do { @@ -339,20 +341,20 @@ public: class FillAddColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - int dc_pitch; - fixed_t dc_light; - int dc_color; + int _count; + BYTE *_dest; + int _pitch; + fixed_t _light; + int _color; public: FillAddColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_color = ::dc_color; + _count = dc_count; + _dest = dc_dest; + _pitch = dc_pitch; + _light = dc_light; + _color = dc_color; } void Execute(DrawerThread *thread) override @@ -360,14 +362,14 @@ public: int count; uint32_t *dest; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -390,20 +392,20 @@ public: class FillAddClampColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - int dc_pitch; - fixed_t dc_light; - int dc_color; + int _count; + BYTE *_dest; + int _pitch; + fixed_t _light; + int _color; public: FillAddClampColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_color = ::dc_color; + _count = dc_count; + _dest = dc_dest; + _pitch = dc_pitch; + _light = dc_light; + _color = dc_color; } void Execute(DrawerThread *thread) override @@ -411,14 +413,14 @@ public: int count; uint32_t *dest; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -441,20 +443,20 @@ public: class FillSubClampColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - int dc_pitch; - int dc_color; - fixed_t dc_light; + int _count; + BYTE *_dest; + int _pitch; + int _color; + fixed_t _light; public: FillSubClampColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_pitch = ::dc_pitch; - dc_color = ::dc_color; - dc_light = ::dc_light; + _count = dc_count; + _dest = dc_dest; + _pitch = dc_pitch; + _color = dc_color; + _light = dc_light; } void Execute(DrawerThread *thread) override @@ -462,14 +464,14 @@ public: int count; uint32_t *dest; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -492,20 +494,20 @@ public: class FillRevSubClampColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - int dc_pitch; - int dc_color; - fixed_t dc_light; + int _count; + BYTE *_dest; + int _pitch; + int _color; + fixed_t _light; public: FillRevSubClampColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_pitch = ::dc_pitch; - dc_color = ::dc_color; - dc_light = ::dc_light; + _count = dc_count; + _dest = dc_dest; + _pitch = dc_pitch; + _color = dc_color; + _light = dc_light; } void Execute(DrawerThread *thread) override @@ -513,14 +515,14 @@ public: int count; uint32_t *dest; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -543,22 +545,22 @@ public: class DrawFuzzColumnRGBACommand : public DrawerCommand { - int dc_x; - int dc_yl; - int dc_yh; - BYTE *dc_destorg; - int dc_pitch; + int _x; + int _yl; + int _yh; + BYTE *_destorg; + int _pitch; int fuzzpos; int fuzzviewheight; public: DrawFuzzColumnRGBACommand() { - dc_x = ::dc_x; - dc_yl = ::dc_yl; - dc_yh = ::dc_yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; + _x = dc_x; + _yl = dc_yl; + _yh = dc_yh; + _destorg = dc_destorg; + _pitch = dc_pitch; fuzzpos = ::fuzzpos; fuzzviewheight = ::fuzzviewheight; } @@ -569,24 +571,24 @@ public: uint32_t *dest; // Adjust borders. Low... - if (dc_yl == 0) - dc_yl = 1; + if (_yl == 0) + _yl = 1; // .. and high. - if (dc_yh > fuzzviewheight) - dc_yh = fuzzviewheight; + if (_yh > fuzzviewheight) + _yh = fuzzviewheight; - count = thread->count_for_thread(dc_yl, dc_yh - dc_yl + 1); + count = thread->count_for_thread(_yl, _yh - _yl + 1); // Zero length. if (count <= 0) return; - dest = thread->dest_for_thread(dc_yl, dc_pitch, ylookup[dc_yl] + dc_x + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(_yl, _pitch, ylookup[_yl] + _x + (uint32_t*)_destorg); - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; int fuzzstep = thread->num_cores; - int fuzz = (fuzzpos + thread->skipped_by_thread(dc_yl)) % FUZZTABLE; + int fuzz = (fuzzpos + thread->skipped_by_thread(_yl)) % FUZZTABLE; while (count > 0) { @@ -620,32 +622,32 @@ public: class DrawAddColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - const BYTE *dc_source; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - BYTE *dc_colormap; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + const BYTE *_source; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; + BYTE *_colormap; public: DrawAddColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_colormap = ::dc_colormap; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _source = dc_source; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _colormap = dc_colormap; } void Execute(DrawerThread *thread) override @@ -655,25 +657,25 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - BYTE *colormap = dc_colormap; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; + BYTE *colormap = _colormap; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -701,28 +703,28 @@ public: class DrawTranslatedColumnRGBACommand : public DrawerCommand { - int dc_count; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - BYTE *dc_translation; - const BYTE *dc_source; - int dc_pitch; + int _count; + fixed_t _light; + ShadeConstants _shade_constants; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + BYTE *_translation; + const BYTE *_source; + int _pitch; public: DrawTranslatedColumnRGBACommand() { - dc_count = ::dc_count; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_translation = ::dc_translation; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; + _count = dc_count; + _light = dc_light; + _shade_constants = dc_shade_constants; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _translation = dc_translation; + _source = dc_source; + _pitch = dc_pitch; } void Execute(DrawerThread *thread) override @@ -732,23 +734,23 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { // [RH] Local copies of global vars to improve compiler optimizations - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; + BYTE *translation = _translation; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; do { @@ -762,28 +764,32 @@ public: class DrawTlatedAddColumnRGBACommand : public DrawerCommand { - int dc_count; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - BYTE *dc_translation; - const BYTE *dc_source; - int dc_pitch; + int _count; + fixed_t _light; + ShadeConstants _shade_constants; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + BYTE *_translation; + const BYTE *_source; + int _pitch; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawTlatedAddColumnRGBACommand() { - dc_count = ::dc_count; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_translation = ::dc_translation; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; + _count = dc_count; + _light = dc_light; + _shade_constants = dc_shade_constants; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _translation = dc_translation; + _source = dc_source; + _pitch = dc_pitch; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -793,25 +799,25 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; + BYTE *translation = _translation; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -840,28 +846,28 @@ public: class DrawShadedColumnRGBACommand : public DrawerCommand { private: - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - fixed_t dc_light; - const BYTE *dc_source; - lighttable_t *dc_colormap; - int dc_color; - int dc_pitch; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + fixed_t _light; + const BYTE *_source; + lighttable_t *_colormap; + int _color; + int _pitch; public: DrawShadedColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_light = ::dc_light; - dc_source = ::dc_source; - dc_colormap = ::dc_colormap; - dc_color = ::dc_color; - dc_pitch = ::dc_pitch; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _light = dc_light; + _source = dc_source; + _colormap = dc_colormap; + _color = dc_color; + _pitch = dc_pitch; } void Execute(DrawerThread *thread) override @@ -870,25 +876,25 @@ public: uint32_t *dest; fixed_t frac, fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; { - const BYTE *source = dc_source; - BYTE *colormap = dc_colormap; - int pitch = dc_pitch * thread->num_cores; + const BYTE *source = _source; + BYTE *colormap = _colormap; + int pitch = _pitch * thread->num_cores; do { @@ -913,30 +919,30 @@ public: class DrawAddClampColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - const BYTE *dc_source; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + const BYTE *_source; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawAddClampColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _source = dc_source; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -946,23 +952,23 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -989,32 +995,32 @@ public: class DrawAddClampTranslatedColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - BYTE *dc_translation; - const BYTE *dc_source; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + BYTE *_translation; + const BYTE *_source; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawAddClampTranslatedColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_translation = ::dc_translation; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _translation = dc_translation; + _source = dc_source; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -1024,24 +1030,24 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + BYTE *translation = _translation; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -1068,30 +1074,30 @@ public: class DrawSubClampColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - const BYTE *dc_source; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + const BYTE *_source; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawSubClampColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _source = dc_source; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -1101,23 +1107,23 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -1144,32 +1150,32 @@ public: class DrawSubClampTranslatedColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - const BYTE *dc_source; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - BYTE *dc_translation; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + const BYTE *_source; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; + BYTE *_translation; public: DrawSubClampTranslatedColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_translation = ::dc_translation; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _source = dc_source; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _translation = dc_translation; } void Execute(DrawerThread *thread) override @@ -1179,24 +1185,24 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + BYTE *translation = _translation; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -1223,30 +1229,30 @@ public: class DrawRevSubClampColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - const BYTE *dc_source; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + const BYTE *_source; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawRevSubClampColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _source = dc_source; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -1256,22 +1262,22 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -1298,32 +1304,32 @@ public: class DrawRevSubClampTranslatedColumnRGBACommand : public DrawerCommand { - int dc_count; - BYTE *dc_dest; - DWORD dc_iscale; - DWORD dc_texturefrac; - const BYTE *dc_source; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - BYTE *dc_translation; + int _count; + BYTE *_dest; + DWORD _iscale; + DWORD _texturefrac; + const BYTE *_source; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; + BYTE *_translation; public: DrawRevSubClampTranslatedColumnRGBACommand() { - dc_count = ::dc_count; - dc_dest = ::dc_dest; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_source = ::dc_source; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_translation = ::dc_translation; + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _source = dc_source; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _translation = dc_translation; } void Execute(DrawerThread *thread) override @@ -1333,24 +1339,24 @@ public: fixed_t frac; fixed_t fracstep; - count = thread->count_for_thread(dc_dest_y, dc_count); + count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - fracstep = dc_iscale * thread->num_cores; - frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); + fracstep = _iscale * thread->num_cores; + frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - BYTE *translation = dc_translation; - const BYTE *source = dc_source; - int pitch = dc_pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + BYTE *translation = _translation; + const BYTE *source = _source; + int pitch = _pitch * thread->num_cores; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -1377,42 +1383,42 @@ public: class DrawSpanRGBACommand : public DrawerCommand { - const uint32_t *ds_source; - fixed_t ds_xfrac; - fixed_t ds_yfrac; - fixed_t ds_xstep; - fixed_t ds_ystep; - int ds_x1; - int ds_x2; - int ds_y; - int ds_xbits; - int ds_ybits; - BYTE *dc_destorg; - fixed_t ds_light; - ShadeConstants ds_shade_constants; + const uint32_t *_source; + fixed_t _xfrac; + fixed_t _yfrac; + fixed_t _xstep; + fixed_t _ystep; + int _x1; + int _x2; + int _y; + int _xbits; + int _ybits; + BYTE *_destorg; + fixed_t _light; + ShadeConstants _shade_constants; public: DrawSpanRGBACommand() { - ds_source = (const uint32_t*)::ds_source; - ds_xfrac = ::ds_xfrac; - ds_yfrac = ::ds_yfrac; - ds_xstep = ::ds_xstep; - ds_ystep = ::ds_ystep; - ds_x1 = ::ds_x1; - ds_x2 = ::ds_x2; - ds_y = ::ds_y; - ds_xbits = ::ds_xbits; - ds_ybits = ::ds_ybits; - dc_destorg = ::dc_destorg; - ds_light = ::ds_light; - ds_shade_constants = ::ds_shade_constants; + _source = (const uint32_t*)ds_source; + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _xstep = ds_xstep; + _ystep = ds_ystep; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _xbits = ds_xbits; + _ybits = ds_ybits; + _destorg = dc_destorg; + _light = ds_light; + _shade_constants = ds_shade_constants; } #ifdef NO_SSE void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1420,24 +1426,24 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const uint32_t* source = ds_source; + const uint32_t* source = _source; int count; int spot; - xfrac = ds_xfrac; - yfrac = ds_yfrac; + xfrac = _xfrac; + yfrac = _yfrac; - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - count = ds_x2 - ds_x1 + 1; + count = _x2 - _x1 + 1; - xstep = ds_xstep; - ystep = ds_ystep; + xstep = _xstep; + ystep = _ystep; - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - if (ds_xbits == 6 && ds_ybits == 6) + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. @@ -1456,9 +1462,9 @@ public: } else { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; do { @@ -1477,7 +1483,7 @@ public: #else void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1485,24 +1491,24 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const uint32_t* source = ds_source; + const uint32_t* source = _source; int count; int spot; - xfrac = ds_xfrac; - yfrac = ds_yfrac; + xfrac = _xfrac; + yfrac = _yfrac; - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - count = ds_x2 - ds_x1 + 1; + count = _x2 - _x1 + 1; - xstep = ds_xstep; - ystep = ds_ystep; + xstep = _xstep; + ystep = _ystep; - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - if (ds_xbits == 6 && ds_ybits == 6) + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. @@ -1602,9 +1608,9 @@ public: } else { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; int sse_count = count / 4; count -= sse_count * 4; @@ -1698,42 +1704,42 @@ public: class DrawSpanMaskedRGBACommand : public DrawerCommand { - const uint32_t *ds_source; - fixed_t ds_light; - ShadeConstants ds_shade_constants; - fixed_t ds_xfrac; - fixed_t ds_yfrac; - BYTE *dc_destorg; - int ds_x1; - int ds_x2; - int ds_y1; - int ds_y; - fixed_t ds_xstep; - fixed_t ds_ystep; - int ds_xbits; - int ds_ybits; + const uint32_t *_source; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _xfrac; + fixed_t _yfrac; + BYTE *_destorg; + int _x1; + int _x2; + int _y1; + int _y; + fixed_t _xstep; + fixed_t _ystep; + int _xbits; + int _ybits; public: DrawSpanMaskedRGBACommand() { - ds_source = (const uint32_t*)::ds_source; - ds_light = ::ds_light; - ds_shade_constants = ::ds_shade_constants; - ds_xfrac = ::ds_xfrac; - ds_yfrac = ::ds_yfrac; - dc_destorg = ::dc_destorg; - ds_x1 = ::ds_x1; - ds_x2 = ::ds_x2; - ds_y = ::ds_y; - ds_xstep = ::ds_xstep; - ds_ystep = ::ds_ystep; - ds_xbits = ::ds_xbits; - ds_ybits = ::ds_ybits; + _source = (const uint32_t*)ds_source; + _light = ds_light; + _shade_constants = ds_shade_constants; + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _destorg = dc_destorg; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _xstep = ds_xstep; + _ystep = ds_ystep; + _xbits = ds_xbits; + _ybits = ds_ybits; } void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1741,24 +1747,24 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const uint32_t* source = ds_source; + const uint32_t* source = _source; int count; int spot; - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - xfrac = ds_xfrac; - yfrac = ds_yfrac; + xfrac = _xfrac; + yfrac = _yfrac; - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - count = ds_x2 - ds_x1 + 1; + count = _x2 - _x1 + 1; - xstep = ds_xstep; - ystep = ds_ystep; + xstep = _xstep; + ystep = _ystep; - if (ds_xbits == 6 && ds_ybits == 6) + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. do @@ -1778,9 +1784,9 @@ public: } else { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; do { uint32_t texdata; @@ -1801,42 +1807,46 @@ public: class DrawSpanTranslucentRGBACommand : public DrawerCommand { - const uint32_t *ds_source; - fixed_t ds_light; - ShadeConstants ds_shade_constants; - fixed_t ds_xfrac; - fixed_t ds_yfrac; - BYTE *dc_destorg; - int ds_x1; - int ds_x2; - int ds_y1; - int ds_y; - fixed_t ds_xstep; - fixed_t ds_ystep; - int ds_xbits; - int ds_ybits; + const uint32_t *_source; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _xfrac; + fixed_t _yfrac; + BYTE *_destorg; + int _x1; + int _x2; + int _y1; + int _y; + fixed_t _xstep; + fixed_t _ystep; + int _xbits; + int _ybits; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawSpanTranslucentRGBACommand() { - ds_source = (const uint32_t *)::ds_source; - ds_light = ::ds_light; - ds_shade_constants = ::ds_shade_constants; - ds_xfrac = ::ds_xfrac; - ds_yfrac = ::ds_yfrac; - dc_destorg = ::dc_destorg; - ds_x1 = ::ds_x1; - ds_x2 = ::ds_x2; - ds_y = ::ds_y; - ds_xstep = ::ds_xstep; - ds_ystep = ::ds_ystep; - ds_xbits = ::ds_xbits; - ds_ybits = ::ds_ybits; + _source = (const uint32_t *)ds_source; + _light = ds_light; + _shade_constants = ds_shade_constants; + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _destorg = dc_destorg; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _xstep = ds_xstep; + _ystep = ds_ystep; + _xbits = ds_xbits; + _ybits = ds_ybits; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1844,27 +1854,27 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const uint32_t* source = ds_source; + const uint32_t* source = _source; int count; int spot; - xfrac = ds_xfrac; - yfrac = ds_yfrac; + xfrac = _xfrac; + yfrac = _yfrac; - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - count = ds_x2 - ds_x1 + 1; + count = _x2 - _x1 + 1; - xstep = ds_xstep; - ystep = ds_ystep; + xstep = _xstep; + ystep = _ystep; - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - if (ds_xbits == 6 && ds_ybits == 6) + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. do @@ -1892,9 +1902,9 @@ public: } else { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; do { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); @@ -1923,42 +1933,46 @@ public: class DrawSpanMaskedTranslucentRGBACommand : public DrawerCommand { - const uint32_t *ds_source; - fixed_t ds_light; - ShadeConstants ds_shade_constants; - fixed_t ds_xfrac; - fixed_t ds_yfrac; - BYTE *dc_destorg; - int ds_x1; - int ds_x2; - int ds_y1; - int ds_y; - fixed_t ds_xstep; - fixed_t ds_ystep; - int ds_xbits; - int ds_ybits; + const uint32_t *_source; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _xfrac; + fixed_t _yfrac; + BYTE *_destorg; + int _x1; + int _x2; + int _y1; + int _y; + fixed_t _xstep; + fixed_t _ystep; + int _xbits; + int _ybits; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawSpanMaskedTranslucentRGBACommand() { - ds_source = (const uint32_t*)::ds_source; - ds_light = ::ds_light; - ds_shade_constants = ::ds_shade_constants; - ds_xfrac = ::ds_xfrac; - ds_yfrac = ::ds_yfrac; - dc_destorg = ::dc_destorg; - ds_x1 = ::ds_x1; - ds_x2 = ::ds_x2; - ds_y = ::ds_y; - ds_xstep = ::ds_xstep; - ds_ystep = ::ds_ystep; - ds_xbits = ::ds_xbits; - ds_ybits = ::ds_ybits; + _source = (const uint32_t*)ds_source; + _light = ds_light; + _shade_constants = ds_shade_constants; + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _destorg = dc_destorg; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _xstep = ds_xstep; + _ystep = ds_ystep; + _xbits = ds_xbits; + _ybits = ds_ybits; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1966,27 +1980,27 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const uint32_t* source = ds_source; + const uint32_t* source = _source; int count; int spot; - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - xfrac = ds_xfrac; - yfrac = ds_yfrac; + xfrac = _xfrac; + yfrac = _yfrac; - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - count = ds_x2 - ds_x1 + 1; + count = _x2 - _x1 + 1; - xstep = ds_xstep; - ystep = ds_ystep; + xstep = _xstep; + ystep = _ystep; - if (ds_xbits == 6 && ds_ybits == 6) + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. do @@ -2019,9 +2033,9 @@ public: } else { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; do { uint32_t texdata; @@ -2055,42 +2069,46 @@ public: class DrawSpanAddClampRGBACommand : public DrawerCommand { - const uint32_t *ds_source; - fixed_t ds_light; - ShadeConstants ds_shade_constants; - fixed_t ds_xfrac; - fixed_t ds_yfrac; - BYTE *dc_destorg; - int ds_x1; - int ds_x2; - int ds_y1; - int ds_y; - fixed_t ds_xstep; - fixed_t ds_ystep; - int ds_xbits; - int ds_ybits; + const uint32_t *_source; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _xfrac; + fixed_t _yfrac; + BYTE *_destorg; + int _x1; + int _x2; + int _y1; + int _y; + fixed_t _xstep; + fixed_t _ystep; + int _xbits; + int _ybits; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawSpanAddClampRGBACommand() { - ds_source = (const uint32_t*)::ds_source; - ds_light = ::ds_light; - ds_shade_constants = ::ds_shade_constants; - ds_xfrac = ::ds_xfrac; - ds_yfrac = ::ds_yfrac; - dc_destorg = ::dc_destorg; - ds_x1 = ::ds_x1; - ds_x2 = ::ds_x2; - ds_y = ::ds_y; - ds_xstep = ::ds_xstep; - ds_ystep = ::ds_ystep; - ds_xbits = ::ds_xbits; - ds_ybits = ::ds_ybits; + _source = (const uint32_t*)ds_source; + _light = ds_light; + _shade_constants = ds_shade_constants; + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _destorg = dc_destorg; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _xstep = ds_xstep; + _ystep = ds_ystep; + _xbits = ds_xbits; + _ybits = ds_ybits; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -2098,27 +2116,27 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const uint32_t* source = ds_source; + const uint32_t* source = _source; int count; int spot; - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - xfrac = ds_xfrac; - yfrac = ds_yfrac; + xfrac = _xfrac; + yfrac = _yfrac; - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - count = ds_x2 - ds_x1 + 1; + count = _x2 - _x1 + 1; - xstep = ds_xstep; - ystep = ds_ystep; + xstep = _xstep; + ystep = _ystep; - if (ds_xbits == 6 && ds_ybits == 6) + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. do @@ -2146,9 +2164,9 @@ public: } else { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; do { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); @@ -2177,42 +2195,46 @@ public: class DrawSpanMaskedAddClampRGBACommand : public DrawerCommand { - const uint32_t *ds_source; - fixed_t ds_light; - ShadeConstants ds_shade_constants; - fixed_t ds_xfrac; - fixed_t ds_yfrac; - BYTE *dc_destorg; - int ds_x1; - int ds_x2; - int ds_y1; - int ds_y; - fixed_t ds_xstep; - fixed_t ds_ystep; - int ds_xbits; - int ds_ybits; + const uint32_t *_source; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _xfrac; + fixed_t _yfrac; + BYTE *_destorg; + int _x1; + int _x2; + int _y1; + int _y; + fixed_t _xstep; + fixed_t _ystep; + int _xbits; + int _ybits; + fixed_t _srcalpha; + fixed_t _destalpha; public: DrawSpanMaskedAddClampRGBACommand() { - ds_source = (const uint32_t*)::ds_source; - ds_light = ::ds_light; - ds_shade_constants = ::ds_shade_constants; - ds_xfrac = ::ds_xfrac; - ds_yfrac = ::ds_yfrac; - dc_destorg = ::dc_destorg; - ds_x1 = ::ds_x1; - ds_x2 = ::ds_x2; - ds_y = ::ds_y; - ds_xstep = ::ds_xstep; - ds_ystep = ::ds_ystep; - ds_xbits = ::ds_xbits; - ds_ybits = ::ds_ybits; + _source = (const uint32_t*)ds_source; + _light = ds_light; + _shade_constants = ds_shade_constants; + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _destorg = dc_destorg; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _xstep = ds_xstep; + _ystep = ds_ystep; + _xbits = ds_xbits; + _ybits = ds_ybits; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -2220,27 +2242,27 @@ public: dsfixed_t xstep; dsfixed_t ystep; uint32_t* dest; - const uint32_t* source = ds_source; + const uint32_t* source = _source; int count; int spot; - uint32_t light = calc_light_multiplier(ds_light); - ShadeConstants shade_constants = ds_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - xfrac = ds_xfrac; - yfrac = ds_yfrac; + xfrac = _xfrac; + yfrac = _yfrac; - dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - count = ds_x2 - ds_x1 + 1; + count = _x2 - _x1 + 1; - xstep = ds_xstep; - ystep = ds_ystep; + xstep = _xstep; + ystep = _ystep; - if (ds_xbits == 6 && ds_ybits == 6) + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. do @@ -2273,9 +2295,9 @@ public: } else { - BYTE yshift = 32 - ds_ybits; - BYTE xshift = yshift - ds_xbits; - int xmask = ((1 << ds_xbits) - 1) << ds_ybits; + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; do { uint32_t texdata; @@ -2309,33 +2331,33 @@ public: class FillSpanRGBACommand : public DrawerCommand { - int ds_x1; - int ds_x2; - int ds_y; - BYTE *dc_destorg; - fixed_t ds_light; - int ds_color; + int _x1; + int _x2; + int _y; + BYTE *_destorg; + fixed_t _light; + int _color; public: FillSpanRGBACommand() { - ds_x1 = ::ds_x1; - ds_x2 = ::ds_x2; - ds_y = ::ds_y; - dc_destorg = ::dc_destorg; - ds_light = ::ds_light; - ds_color = ::ds_color; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _destorg = dc_destorg; + _light = ds_light; + _color = ds_color; } void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(ds_y)) + if (thread->line_skipped_by_thread(_y)) return; - uint32_t *dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg; - int count = (ds_x2 - ds_x1 + 1); - uint32_t light = calc_light_multiplier(ds_light); - uint32_t color = shade_pal_index_simple(ds_color, light); + uint32_t *dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; + int count = (_x2 - _x1 + 1); + uint32_t light = calc_light_multiplier(_light); + uint32_t color = shade_pal_index_simple(_color, light); for (int i = 0; i < count; i++) dest[i] = color; } @@ -2343,45 +2365,45 @@ public: class Vlinec1RGBACommand : public DrawerCommand { - DWORD dc_iscale; - DWORD dc_texturefrac; - int dc_count; - const BYTE *dc_source; - BYTE *dc_dest; + DWORD _iscale; + DWORD _texturefrac; + int _count; + const BYTE *_source; + BYTE *_dest; int vlinebits; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; public: Vlinec1RGBACommand() { - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_count = ::dc_count; - dc_source = ::dc_source; - dc_dest = ::dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _count = dc_count; + _source = dc_source; + _dest = dc_dest; vlinebits = ::vlinebits; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - DWORD fracstep = dc_iscale * thread->num_cores; - DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const uint32 *source = (const uint32 *)dc_source; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + DWORD fracstep = _iscale * thread->num_cores; + DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); + const uint32 *source = (const uint32 *)_source; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = vlinebits; - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; do { @@ -2394,10 +2416,10 @@ public: class Vlinec4RGBACommand : public DrawerCommand { - BYTE *dc_dest; - int dc_count; - int dc_pitch; - ShadeConstants dc_shade_constants; + BYTE *_dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; int vlinebits; fixed_t palookuplight[4]; DWORD vplce[4]; @@ -2407,10 +2429,10 @@ class Vlinec4RGBACommand : public DrawerCommand public: Vlinec4RGBACommand() { - dc_dest = ::dc_dest; - dc_count = ::dc_count; - dc_pitch = ::dc_pitch; - dc_shade_constants = ::dc_shade_constants; + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; vlinebits = ::vlinebits; for (int i = 0; i < 4; i++) { @@ -2424,12 +2446,12 @@ public: #ifdef NO_SSE void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; int bits = vlinebits; DWORD place; @@ -2438,11 +2460,11 @@ public: uint32_t light2 = calc_light_multiplier(palookuplight[2]); uint32_t light3 = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -2461,24 +2483,24 @@ public: #else void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = vlinebits; - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; uint32_t light0 = calc_light_multiplier(palookuplight[0]); uint32_t light1 = calc_light_multiplier(palookuplight[1]); uint32_t light2 = calc_light_multiplier(palookuplight[2]); uint32_t light3 = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -2543,45 +2565,45 @@ public: class Mvlinec1RGBACommand : public DrawerCommand { - DWORD dc_iscale; - DWORD dc_texturefrac; - int dc_count; - const BYTE *dc_source; - BYTE *dc_dest; + DWORD _iscale; + DWORD _texturefrac; + int _count; + const BYTE *_source; + BYTE *_dest; int mvlinebits; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; public: Mvlinec1RGBACommand() { - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_count = ::dc_count; - dc_source = ::dc_source; - dc_dest = ::dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _count = dc_count; + _source = dc_source; + _dest = dc_dest; mvlinebits = ::mvlinebits; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - DWORD fracstep = dc_iscale * thread->num_cores; - DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const uint32 *source = (const uint32 *)dc_source; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + DWORD fracstep = _iscale * thread->num_cores; + DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); + const uint32 *source = (const uint32 *)_source; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = mvlinebits; - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; do { @@ -2598,10 +2620,10 @@ public: class Mvlinec4RGBACommand : public DrawerCommand { - BYTE *dc_dest; - int dc_count; - int dc_pitch; - ShadeConstants dc_shade_constants; + BYTE *_dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; int mvlinebits; fixed_t palookuplight[4]; DWORD vplce[4]; @@ -2611,10 +2633,10 @@ class Mvlinec4RGBACommand : public DrawerCommand public: Mvlinec4RGBACommand() { - dc_dest = ::dc_dest; - dc_count = ::dc_count; - dc_pitch = ::dc_pitch; - dc_shade_constants = ::dc_shade_constants; + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; mvlinebits = ::mvlinebits; for (int i = 0; i < 4; i++) { @@ -2628,12 +2650,12 @@ public: #ifdef NO_SSE void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; int bits = mvlinebits; DWORD place; @@ -2642,11 +2664,11 @@ public: uint32_t light2 = calc_light_multiplier(palookuplight[2]); uint32_t light3 = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -2666,12 +2688,12 @@ public: #else void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; int bits = mvlinebits; uint32_t light0 = calc_light_multiplier(palookuplight[0]); @@ -2679,11 +2701,11 @@ public: uint32_t light2 = calc_light_multiplier(palookuplight[2]); uint32_t light3 = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -2754,52 +2776,52 @@ public: class Tmvline1AddRGBACommand : public DrawerCommand { - DWORD dc_iscale; - DWORD dc_texturefrac; - int dc_count; - const BYTE *dc_source; - BYTE *dc_dest; + DWORD _iscale; + DWORD _texturefrac; + int _count; + const BYTE *_source; + BYTE *_dest; int tmvlinebits; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: Tmvline1AddRGBACommand() { - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_count = ::dc_count; - dc_source = ::dc_source; - dc_dest = ::dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _count = dc_count; + _source = dc_source; + _dest = dc_dest; tmvlinebits = ::tmvlinebits; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - DWORD fracstep = dc_iscale * thread->num_cores; - DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const uint32 *source = (const uint32 *)dc_source; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + DWORD fracstep = _iscale * thread->num_cores; + DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); + const uint32 *source = (const uint32 *)_source; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = tmvlinebits; - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -2829,12 +2851,12 @@ public: class Tmvline4AddRGBACommand : public DrawerCommand { - BYTE *dc_dest; - int dc_count; - int dc_pitch; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + BYTE *_dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; int tmvlinebits; fixed_t palookuplight[4]; DWORD vplce[4]; @@ -2844,12 +2866,12 @@ class Tmvline4AddRGBACommand : public DrawerCommand public: Tmvline4AddRGBACommand() { - dc_dest = ::dc_dest; - dc_count = ::dc_count; - dc_pitch = ::dc_pitch; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; tmvlinebits = ::tmvlinebits; for (int i = 0; i < 4; i++) { @@ -2862,12 +2884,12 @@ public: void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; int bits = tmvlinebits; uint32_t light[4]; @@ -2876,14 +2898,14 @@ public: light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -2921,52 +2943,52 @@ public: class Tmvline1AddClampRGBACommand : public DrawerCommand { - DWORD dc_iscale; - DWORD dc_texturefrac; - int dc_count; - const BYTE *dc_source; - BYTE *dc_dest; + DWORD _iscale; + DWORD _texturefrac; + int _count; + const BYTE *_source; + BYTE *_dest; int tmvlinebits; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: Tmvline1AddClampRGBACommand() { - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_count = ::dc_count; - dc_source = ::dc_source; - dc_dest = ::dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _count = dc_count; + _source = dc_source; + _dest = dc_dest; tmvlinebits = ::tmvlinebits; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - DWORD fracstep = dc_iscale * thread->num_cores; - DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const uint32 *source = (const uint32 *)dc_source; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + DWORD fracstep = _iscale * thread->num_cores; + DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); + const uint32 *source = (const uint32 *)_source; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = tmvlinebits; - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -2996,12 +3018,12 @@ public: class Tmvline4AddClampRGBACommand : public DrawerCommand { - BYTE *dc_dest; - int dc_count; - int dc_pitch; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + BYTE *_dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; int tmvlinebits; fixed_t palookuplight[4]; DWORD vplce[4]; @@ -3011,12 +3033,12 @@ class Tmvline4AddClampRGBACommand : public DrawerCommand public: Tmvline4AddClampRGBACommand() { - dc_dest = ::dc_dest; - dc_count = ::dc_count; - dc_pitch = ::dc_pitch; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; tmvlinebits = ::tmvlinebits; for (int i = 0; i < 4; i++) { @@ -3029,12 +3051,12 @@ public: void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; int bits = tmvlinebits; uint32_t light[4]; @@ -3043,14 +3065,14 @@ public: light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -3088,52 +3110,52 @@ public: class Tmvline1SubClampRGBACommand : public DrawerCommand { - DWORD dc_iscale; - DWORD dc_texturefrac; - int dc_count; - const BYTE *dc_source; - BYTE *dc_dest; + DWORD _iscale; + DWORD _texturefrac; + int _count; + const BYTE *_source; + BYTE *_dest; int tmvlinebits; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: Tmvline1SubClampRGBACommand() { - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_count = ::dc_count; - dc_source = ::dc_source; - dc_dest = ::dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _count = dc_count; + _source = dc_source; + _dest = dc_dest; tmvlinebits = ::tmvlinebits; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - DWORD fracstep = dc_iscale * thread->num_cores; - DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const uint32 *source = (const uint32 *)dc_source; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + DWORD fracstep = _iscale * thread->num_cores; + DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); + const uint32 *source = (const uint32 *)_source; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = tmvlinebits; - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -3163,12 +3185,12 @@ public: class Tmvline4SubClampRGBACommand : public DrawerCommand { - BYTE *dc_dest; - int dc_count; - int dc_pitch; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + BYTE *_dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; int tmvlinebits; fixed_t palookuplight[4]; DWORD vplce[4]; @@ -3178,12 +3200,12 @@ class Tmvline4SubClampRGBACommand : public DrawerCommand public: Tmvline4SubClampRGBACommand() { - dc_dest = ::dc_dest; - dc_count = ::dc_count; - dc_pitch = ::dc_pitch; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; tmvlinebits = ::tmvlinebits; for (int i = 0; i < 4; i++) { @@ -3196,12 +3218,12 @@ public: void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; int bits = tmvlinebits; uint32_t light[4]; @@ -3210,14 +3232,14 @@ public: light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -3255,52 +3277,52 @@ public: class Tmvline1RevSubClampRGBACommand : public DrawerCommand { - DWORD dc_iscale; - DWORD dc_texturefrac; - int dc_count; - const BYTE *dc_source; - BYTE *dc_dest; + DWORD _iscale; + DWORD _texturefrac; + int _count; + const BYTE *_source; + BYTE *_dest; int tmvlinebits; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: Tmvline1RevSubClampRGBACommand() { - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_count = ::dc_count; - dc_source = ::dc_source; - dc_dest = ::dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _count = dc_count; + _source = dc_source; + _dest = dc_dest; tmvlinebits = ::tmvlinebits; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - DWORD fracstep = dc_iscale * thread->num_cores; - DWORD frac = dc_texturefrac + dc_iscale * thread->skipped_by_thread(dc_dest_y); - const uint32 *source = (const uint32 *)dc_source; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); + DWORD fracstep = _iscale * thread->num_cores; + DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); + const uint32 *source = (const uint32 *)_source; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = tmvlinebits; - int pitch = dc_pitch * thread->num_cores; + int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { @@ -3330,12 +3352,12 @@ public: class Tmvline4RevSubClampRGBACommand : public DrawerCommand { - BYTE *dc_dest; - int dc_count; - int dc_pitch; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + BYTE *_dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; int tmvlinebits; fixed_t palookuplight[4]; DWORD vplce[4]; @@ -3345,12 +3367,12 @@ class Tmvline4RevSubClampRGBACommand : public DrawerCommand public: Tmvline4RevSubClampRGBACommand() { - dc_dest = ::dc_dest; - dc_count = ::dc_count; - dc_pitch = ::dc_pitch; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; tmvlinebits = ::tmvlinebits; for (int i = 0; i < 4; i++) { @@ -3363,12 +3385,12 @@ public: void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(dc_dest_y, dc_count); + int count = thread->count_for_thread(_dest_y, _count); if (count <= 0) return; - uint32_t *dest = thread->dest_for_thread(dc_dest_y, dc_pitch, (uint32_t*)dc_dest); - int pitch = dc_pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; int bits = tmvlinebits; uint32_t light[4]; @@ -3377,14 +3399,14 @@ public: light[2] = calc_light_multiplier(palookuplight[2]); light[3] = calc_light_multiplier(palookuplight[3]); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(dc_dest_y); + int skipped = thread->skipped_by_thread(_dest_y); for (int i = 0; i < 4; i++) { local_vplce[i] += local_vince[i] * skipped; @@ -3425,9 +3447,9 @@ class DrawFogBoundaryLineRGBACommand : public DrawerCommand int _y; int _x; int _x2; - BYTE *dc_destorg; - fixed_t dc_light; - ShadeConstants dc_shade_constants; + BYTE *_destorg; + fixed_t _light; + ShadeConstants _shade_constants; public: DrawFogBoundaryLineRGBACommand(int y, int x, int x2) @@ -3436,9 +3458,9 @@ public: _x = x; _x2 = x2; - dc_destorg = ::dc_destorg; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; + _destorg = dc_destorg; + _light = dc_light; + _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override @@ -3450,10 +3472,10 @@ public: int x = _x; int x2 = _x2; - uint32_t *dest = ylookup[y] + (uint32_t*)dc_destorg; + uint32_t *dest = ylookup[y] + (uint32_t*)_destorg; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants constants = _shade_constants; do { @@ -3492,6 +3514,157 @@ public: } }; +class DrawTiltedSpanRGBACommand : public DrawerCommand +{ + int _y; + int _x1; + int _x2; + BYTE *_destorg; + fixed_t _light; + ShadeConstants _shade_constants; + const BYTE *_source; + +public: + DrawTiltedSpanRGBACommand(int y, int x1, int x2) + { + _y = y; + _x1 = x1; + _x2 = x2; + + _destorg = dc_destorg; + _source = ds_source; + } + + void Execute(DrawerThread *thread) override + { + if (thread->line_skipped_by_thread(_y)) + return; + + int y = _y; + int x1 = _x1; + int x2 = _x2; + + // Slopes are broken currently in master. + // Until R_DrawTiltedPlane is fixed we are just going to fill with a solid color. + + uint32_t *source = (uint32_t*)_source; + uint32_t *dest = ylookup[y] + x1 + (uint32_t*)_destorg; + + int count = x2 - x1 + 1; + while (count > 0) + { + *(dest++) = source[0]; + count--; + } + } +}; + +class DrawColoredSpanRGBACommand : public DrawerCommand +{ + int _y; + int _x1; + int _x2; + BYTE *_destorg; + fixed_t _light; + int _color; + +public: + DrawColoredSpanRGBACommand(int y, int x1, int x2) + { + _y = y; + _x1 = x1; + _x2 = x2; + + _destorg = dc_destorg; + _light = ds_light; + _color = ds_color; + } + + void Execute(DrawerThread *thread) override + { + if (thread->line_skipped_by_thread(_y)) + return; + + int y = _y; + int x1 = _x1; + int x2 = _x2; + + uint32_t *dest = ylookup[y] + x1 + (uint32_t*)_destorg; + int count = (x2 - x1 + 1); + uint32_t light = calc_light_multiplier(_light); + uint32_t color = shade_pal_index_simple(_color, light); + for (int i = 0; i < count; i++) + dest[i] = color; + } +}; + +class FillTransColumnRGBACommand : public DrawerCommand +{ + int _x; + int _y1; + int _y2; + int _color; + int _a; + BYTE *_destorg; + int _pitch; + fixed_t _light; + +public: + FillTransColumnRGBACommand(int x, int y1, int y2, int color, int a) + { + _x = x; + _y1 = y1; + _y2 = y2; + _color = color; + _a = a; + + _destorg = dc_destorg; + _pitch = dc_pitch; + } + + void Execute(DrawerThread *thread) override + { + int x = _x; + int y1 = _y1; + int y2 = _y2; + int color = _color; + int a = _a; + + int ycount = thread->count_for_thread(y1, y2 - y1 + 1); + if (ycount <= 0) + return; + + uint32_t fg = GPalette.BaseColors[color].d; + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t alpha = a + 1; + uint32_t inv_alpha = 256 - alpha; + + fg_red *= alpha; + fg_green *= alpha; + fg_blue *= alpha; + + int spacing = _pitch * thread->num_cores; + uint32_t *dest = thread->dest_for_thread(y1, _pitch, ylookup[y1] + x + (uint32_t*)_destorg); + + for (int y = 0; y < ycount; y++) + { + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red * inv_alpha) / 256; + uint32_t green = (fg_green + bg_green * inv_alpha) / 256; + uint32_t blue = (fg_blue + bg_blue * inv_alpha) / 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += spacing; + } + } +}; + ApplySpecialColormapRGBACommand::ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen) { buffer = screen->GetBuffer(); diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 47ea75260..0ab3e298a 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -184,6 +184,8 @@ public: virtual void Execute(DrawerThread *thread) = 0; }; +EXTERN_CVAR(Bool, r_multithreaded) + // Manages queueing up commands and executing them on worker threads class DrawerCommandQueue { @@ -227,7 +229,7 @@ public: static void QueueCommand(Types &&... args) { auto queue = Instance(); - if (queue->threaded_render == 0) + if (queue->threaded_render == 0 || !r_multithreaded) { T command(std::forward(args)...); command.Execute(&queue->single_core_thread); diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index d2d715c8d..2311cb447 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -59,8 +59,8 @@ class RtCopy1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; + BYTE *_destorg; + int _pitch; public: RtCopy1colRGBACommand(int hx, int sx, int yl, int yh) @@ -70,8 +70,8 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; + _destorg = dc_destorg; + _pitch = dc_pitch; } void Execute(DrawerThread *thread) override @@ -85,9 +85,9 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = thread->num_cores * 4; if (count & 1) { @@ -121,11 +121,11 @@ class RtMap1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - BYTE *dc_destorg; - int dc_pitch; - BYTE *dc_colormap; + fixed_t _light; + ShadeConstants _shade_constants; + BYTE *_destorg; + int _pitch; + BYTE *_colormap; public: RtMap1colRGBACommand(int hx, int sx, int yl, int yh) @@ -135,11 +135,11 @@ public: this->yl = yl; this->yh = yh; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_colormap = ::dc_colormap; + _light = dc_light; + _shade_constants = dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _colormap = dc_colormap; } void Execute(DrawerThread *thread) override @@ -154,15 +154,15 @@ public: if (count <= 0) return; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = thread->num_cores * 4; - BYTE *colormap = dc_colormap; + BYTE *colormap = _colormap; if (count & 1) { *dest = shade_pal_index(colormap[*source], light, shade_constants); @@ -186,11 +186,11 @@ class RtMap4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - BYTE *dc_destorg; - int dc_pitch; - BYTE *colormap; + fixed_t _light; + ShadeConstants _shade_constants; + BYTE *_destorg; + int _pitch; + BYTE *_colormap; public: RtMap4colsRGBACommand(int sx, int yl, int yh) @@ -199,11 +199,11 @@ public: this->yl = yl; this->yh = yh; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_colormap = ::dc_colormap; + _light = dc_light; + _shade_constants = dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _colormap = dc_colormap; } #ifdef NO_SSE @@ -219,15 +219,15 @@ public: if (count <= 0) return; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = thread->num_cores * 4; - BYTE *colormap = dc_colormap; + BYTE *colormap = _colormap; if (count & 1) { dest[0] = shade_pal_index(colormap[source[0]], light, shade_constants); @@ -266,16 +266,16 @@ public: if (count <= 0) return; - ShadeConstants shade_constants = dc_shade_constants; - uint32_t light = calc_light_multiplier(dc_light); + ShadeConstants shade_constants = _shade_constants; + uint32_t light = calc_light_multiplier(_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = thread->num_cores * 4; - BYTE *colormap = dc_colormap; + BYTE *colormap = _colormap; if (shade_constants.simple_shade) { @@ -507,13 +507,13 @@ class RtAdd1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - BYTE *dc_colormap; + BYTE *_destorg; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; + BYTE *_colormap; public: RtAdd1colRGBACommand(int hx, int sx, int yl, int yh) @@ -523,13 +523,13 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_colormap = ::dc_colormap; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _colormap = dc_colormap; } void Execute(DrawerThread *thread) override @@ -544,17 +544,17 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - BYTE *colormap = dc_colormap; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; + BYTE *colormap = _colormap; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { uint32_t fg = shade_pal_index(colormap[*source], light, shade_constants); @@ -583,13 +583,13 @@ class RtAdd4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - BYTE *dc_colormap; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + BYTE *_destorg; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + BYTE *_colormap; + fixed_t _srcalpha; + fixed_t _destalpha; public: RtAdd4colsRGBACommand(int sx, int yl, int yh) @@ -598,13 +598,13 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_colormap = ::dc_colormap; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _colormap = dc_colormap; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } #ifdef NO_SSE @@ -620,17 +620,17 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; - BYTE *colormap = dc_colormap; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; + BYTE *colormap = _colormap; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { for (int i = 0; i < 4; i++) @@ -668,19 +668,19 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); + uint32_t light = calc_light_multiplier(_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; - BYTE *colormap = dc_colormap; + BYTE *colormap = _colormap; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; if (shade_constants.simple_shade) { @@ -764,11 +764,11 @@ class RtShaded1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - lighttable_t *dc_colormap; - BYTE *dc_destorg; - int dc_pitch; - int dc_color; - fixed_t dc_light; + lighttable_t *_colormap; + BYTE *_destorg; + int _pitch; + int _color; + fixed_t _light; public: RtShaded1colRGBACommand(int hx, int sx, int yl, int yh) @@ -778,11 +778,11 @@ public: this->yl = yl; this->yh = yh; - dc_colormap = ::dc_colormap; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_color = ::dc_color; - dc_light = ::dc_light; + _colormap = dc_colormap; + _destorg = dc_destorg; + _pitch = dc_pitch; + _color = dc_color; + _light = dc_light; } void Execute(DrawerThread *thread) override @@ -798,13 +798,13 @@ public: if (count <= 0) return; - colormap = dc_colormap; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + colormap = _colormap; + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -833,11 +833,11 @@ class RtShaded4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - lighttable_t *dc_colormap; - int dc_color; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; + lighttable_t *_colormap; + int _color; + BYTE *_destorg; + int _pitch; + fixed_t _light; public: RtShaded4colsRGBACommand(int sx, int yl, int yh) @@ -846,11 +846,11 @@ public: this->yl = yl; this->yh = yh; - dc_colormap = ::dc_colormap; - dc_color = ::dc_color; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; + _colormap = dc_colormap; + _color = dc_color; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; } #ifdef NO_SSE @@ -867,13 +867,13 @@ public: if (count <= 0) return; - colormap = dc_colormap; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + colormap = _colormap; + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t fg = shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light)); + uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -912,13 +912,13 @@ public: if (count <= 0) return; - colormap = dc_colormap; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + colormap = _colormap; + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(shade_pal_index_simple(dc_color, calc_light_multiplier(dc_light))), _mm_setzero_si128()); + __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(shade_pal_index_simple(_color, calc_light_multiplier(_light))), _mm_setzero_si128()); __m128i alpha_one = _mm_set1_epi16(64); do { @@ -957,12 +957,12 @@ class RtAddClamp1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - ShadeConstants dc_shade_constants; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; + BYTE *_destorg; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; public: RtAddClamp1colRGBACommand(int hx, int sx, int yl, int yh) @@ -972,12 +972,12 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_shade_constants = ::dc_shade_constants; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -992,16 +992,16 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { uint32_t fg = shade_pal_index(*source, light, shade_constants); @@ -1029,12 +1029,12 @@ class RtAddClamp4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - ShadeConstants dc_shade_constants; + BYTE *_destorg; + int _pitch; + fixed_t _light; + fixed_t _srcalpha; + fixed_t _destalpha; + ShadeConstants _shade_constants; public: RtAddClamp4colsRGBACommand(int sx, int yl, int yh) @@ -1043,12 +1043,12 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_shade_constants = ::dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _shade_constants = dc_shade_constants; } #ifdef NO_SSE @@ -1064,16 +1064,16 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { for (int i = 0; i < 4; i++) @@ -1110,18 +1110,18 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); + uint32_t light = calc_light_multiplier(_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - ShadeConstants shade_constants = dc_shade_constants; + ShadeConstants shade_constants = _shade_constants; if (shade_constants.simple_shade) { @@ -1205,12 +1205,12 @@ class RtSubClamp1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - ShadeConstants dc_shade_constants; + BYTE *_destorg; + int _pitch; + fixed_t _light; + fixed_t _srcalpha; + fixed_t _destalpha; + ShadeConstants _shade_constants; public: RtSubClamp1colRGBACommand(int hx, int sx, int yl, int yh) @@ -1220,12 +1220,12 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_shade_constants = ::dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override @@ -1240,16 +1240,16 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { uint32_t fg = shade_pal_index(*source, light, shade_constants); @@ -1277,12 +1277,12 @@ class RtSubClamp4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - ShadeConstants dc_shade_constants; + BYTE *_destorg; + int _pitch; + fixed_t _light; + fixed_t _srcalpha; + fixed_t _destalpha; + ShadeConstants _shade_constants; public: RtSubClamp4colsRGBACommand(int sx, int yl, int yh) @@ -1291,12 +1291,12 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_shade_constants = ::dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override @@ -1311,16 +1311,16 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { for (int i = 0; i < 4; i++) @@ -1353,12 +1353,12 @@ class RtRevSubClamp1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - ShadeConstants dc_shade_constants; + BYTE *_destorg; + int _pitch; + fixed_t _light; + fixed_t _srcalpha; + fixed_t _destalpha; + ShadeConstants _shade_constants; public: RtRevSubClamp1colRGBACommand(int hx, int sx, int yl, int yh) @@ -1368,12 +1368,12 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_shade_constants = ::dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override @@ -1388,16 +1388,16 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { uint32_t fg = shade_pal_index(*source, light, shade_constants); @@ -1425,12 +1425,12 @@ class RtRevSubClamp4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *dc_destorg; - int dc_pitch; - fixed_t dc_light; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - ShadeConstants dc_shade_constants; + BYTE *_destorg; + int _pitch; + fixed_t _light; + fixed_t _srcalpha; + fixed_t _destalpha; + ShadeConstants _shade_constants; public: RtRevSubClamp4colsRGBACommand(int sx, int yl, int yh) @@ -1439,12 +1439,12 @@ public: this->yl = yl; this->yh = yh; - dc_destorg = ::dc_destorg; - dc_pitch = ::dc_pitch; - dc_light = ::dc_light; - dc_srcalpha = ::dc_srcalpha; - dc_destalpha = ::dc_destalpha; - dc_shade_constants = ::dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override @@ -1459,16 +1459,16 @@ public: if (count <= 0) return; - dest = thread->dest_for_thread(yl, dc_pitch, ylookup[yl] + sx + (uint32_t*)dc_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = dc_pitch * thread->num_cores; + pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(dc_light); - ShadeConstants shade_constants = dc_shade_constants; + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { for (int i = 0; i < 4; i++) @@ -1513,29 +1513,29 @@ public: class DrawColumnHorizRGBACommand : public DrawerCommand { - int dc_count; - fixed_t dc_iscale; - fixed_t dc_texturefrac; - const BYTE *dc_source; - int dc_x; - int dc_yl; - int dc_yh; + int _count; + fixed_t _iscale; + fixed_t _texturefrac; + const BYTE *_source; + int _x; + int _yl; + int _yh; public: DrawColumnHorizRGBACommand() { - dc_count = ::dc_count; - dc_iscale = ::dc_iscale; - dc_texturefrac = ::dc_texturefrac; - dc_source = ::dc_source; - dc_x = ::dc_x; - dc_yl = ::dc_yl; - dc_yh = ::dc_yh; + _count = dc_count; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _source = dc_source; + _x = dc_x; + _yl = dc_yl; + _yh = dc_yh; } void Execute(DrawerThread *thread) override { - int count = dc_count; + int count = _count; uint32_t *dest; fixed_t fracstep; fixed_t frac; @@ -1544,13 +1544,13 @@ public: return; { - int x = dc_x & 3; - dest = &thread->dc_temp_rgba[x + 4 * dc_yl]; + int x = _x & 3; + dest = &thread->dc_temp_rgba[x + 4 * _yl]; } - fracstep = dc_iscale; - frac = dc_texturefrac; + fracstep = _iscale; + frac = _texturefrac; - const BYTE *source = dc_source; + const BYTE *source = _source; if (count & 1) { *dest = source[frac >> FRACBITS]; dest += 4; frac += fracstep; @@ -1587,34 +1587,34 @@ public: class FillColumnHorizRGBACommand : public DrawerCommand { - int dc_x; - int dc_yl; - int dc_yh; - int dc_count; - int dc_color; + int _x; + int _yl; + int _yh; + int _count; + int _color; public: FillColumnHorizRGBACommand() { - dc_x = ::dc_x; - dc_count = ::dc_count; - dc_color = ::dc_color; - dc_yl = ::dc_yl; - dc_yh = ::dc_yh; + _x = dc_x; + _count = dc_count; + _color = dc_color; + _yl = dc_yl; + _yh = dc_yh; } void Execute(DrawerThread *thread) override { - int count = dc_count; - int color = dc_color; + int count = _count; + int color = _color; uint32_t *dest; if (count <= 0) return; { - int x = dc_x & 3; - dest = &thread->dc_temp_rgba[x + 4 * dc_yl]; + int x = _x & 3; + dest = &thread->dc_temp_rgba[x + 4 * _yl]; } if (count & 1) { From 3089043b07c206db4a2d05cb27639378147d2851 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 17 Jun 2016 08:28:30 +0200 Subject: [PATCH 0662/1509] Fixed typo --- src/r_draw_rgba.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 0ab3e298a..15a76c689 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -173,12 +173,12 @@ public: class DrawerCommand { protected: - int dc_dest_y; + int _dest_y; public: DrawerCommand() { - dc_dest_y = static_cast((dc_dest - dc_destorg) / (dc_pitch * 4)); + _dest_y = static_cast((dc_dest - dc_destorg) / (dc_pitch * 4)); } virtual void Execute(DrawerThread *thread) = 0; From 000008e04dfa50fa5443d005d8076511dba1ca46 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 17 Jun 2016 10:14:33 +0200 Subject: [PATCH 0663/1509] Fixed empty canvas in kdizd intermission screen --- src/r_swrenderer.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index c4347236d..c788dfd54 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -370,7 +370,30 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin FTexture::FlipNonSquareBlockRemap(Pixels, Canvas->GetBuffer(), tex->GetWidth(), tex->GetHeight(), Canvas->GetPitch(), GPalette.Remap); } } - tex->SetUpdated(); + + if (r_swtruecolor) + { + // True color render still sometimes uses palette textures (for sprites, mostly). + // We need to make sure that both pixel buffers contain data: + int width = tex->GetWidth(); + int height = tex->GetHeight(); + BYTE *palbuffer = (BYTE *)tex->GetPixels(); + uint32_t *bgrabuffer = (uint32_t*)tex->GetPixelsBgra(); + for (int x = 0; x < width; x++) + { + for (int y = 0; y < height; y++) + { + uint32_t color = bgrabuffer[y]; + int r = RPART(color); + int g = GPART(color); + int b = BPART(color); + palbuffer[y] = RGB32k.RGB[r >> 3][g >> 3][b >> 3]; + } + palbuffer += height; + bgrabuffer += height; + } + } + fixedcolormap = savecolormap; realfixedcolormap = savecm; } From 5963f29afd0906d7c4d1c99f116e78907c60dac4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 17 Jun 2016 10:16:34 +0200 Subject: [PATCH 0664/1509] Added missing SetUpdated --- src/r_swrenderer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index c788dfd54..c81d2a110 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -394,6 +394,8 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin } } + tex->SetUpdated(); + fixedcolormap = savecolormap; realfixedcolormap = savecm; } From 12a50c140c7656ad944df027bd9f5c332f48f698 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 17 Jun 2016 10:47:30 +0200 Subject: [PATCH 0665/1509] Fix animated textures not updating in swtruecolor mode --- src/g_strife/strife_sbar.cpp | 11 +++++++++++ src/menu/playerdisplay.cpp | 11 +++++++++++ src/textures/textures.h | 1 + src/textures/warptexture.cpp | 12 ++++++++++++ 4 files changed, 35 insertions(+) diff --git a/src/g_strife/strife_sbar.cpp b/src/g_strife/strife_sbar.cpp index eb3fa2608..e1fcb3cda 100644 --- a/src/g_strife/strife_sbar.cpp +++ b/src/g_strife/strife_sbar.cpp @@ -34,6 +34,7 @@ public: const BYTE *GetColumn (unsigned int column, const Span **spans_out); const BYTE *GetPixels (); + const uint32_t *GetPixelsBgra() override; bool CheckModified (); void SetVial (int level); @@ -115,6 +116,16 @@ const BYTE *FHealthBar::GetPixels () return Pixels; } +const uint32_t *FHealthBar::GetPixelsBgra() +{ + if (NeedRefresh) + { + MakeTexture(); + PixelsBgra.clear(); + } + return FTexture::GetPixelsBgra(); +} + void FHealthBar::SetVial (int level) { if (level < 0) diff --git a/src/menu/playerdisplay.cpp b/src/menu/playerdisplay.cpp index 16671975a..7b7e9ca5d 100644 --- a/src/menu/playerdisplay.cpp +++ b/src/menu/playerdisplay.cpp @@ -78,6 +78,7 @@ public: const BYTE *GetColumn(unsigned int column, const Span **spans_out); const BYTE *GetPixels(); + const uint32_t *GetPixelsBgra() override; bool CheckModified(); protected: @@ -246,6 +247,16 @@ const BYTE *FBackdropTexture::GetPixels() return Pixels; } +const uint32_t *FBackdropTexture::GetPixelsBgra() +{ + if (LastRenderTic != gametic) + { + Render(); + PixelsBgra.clear(); + } + return FTexture::GetPixelsBgra(); +} + //============================================================================= // // This is one plasma and two rotozoomers. I think it turned out quite awesome. diff --git a/src/textures/textures.h b/src/textures/textures.h index 38d1ef487..3b4b0b8b3 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -484,6 +484,7 @@ public: virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL); const BYTE *GetColumn (unsigned int column, const Span **spans_out); const BYTE *GetPixels (); + const uint32_t *GetPixelsBgra() override; void Unload (); bool CheckModified (); diff --git a/src/textures/warptexture.cpp b/src/textures/warptexture.cpp index b6977dd77..0d18ab58f 100644 --- a/src/textures/warptexture.cpp +++ b/src/textures/warptexture.cpp @@ -93,6 +93,18 @@ const BYTE *FWarpTexture::GetPixels () return Pixels; } +const uint32_t *FWarpTexture::GetPixelsBgra() +{ + DWORD time = r_FrameTime; + + if (Pixels == NULL || time != GenTime) + { + MakeTexture(time); + PixelsBgra.clear(); + } + return FTexture::GetPixelsBgra(); +} + const BYTE *FWarpTexture::GetColumn (unsigned int column, const Span **spans_out) { DWORD time = r_FrameTime; From 35c078dc1e0f4dc67d0ed3cd09f292e257fb1b9c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 17 Jun 2016 11:24:21 +0200 Subject: [PATCH 0666/1509] Screenshot fix --- src/v_video.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v_video.cpp b/src/v_video.cpp index 2cf04a29d..bcd49f920 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -445,7 +445,7 @@ void DCanvas::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &colo { Lock(true); buffer = GetBuffer(); - pitch = GetPitch(); + pitch = IsBgra() ? GetPitch() * 4 : GetPitch(); color_type = IsBgra() ? SS_BGRA : SS_PAL; } From f53e468f3f32fcb544842e86be5c06a63b0c3f31 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 17 Jun 2016 12:38:00 +0200 Subject: [PATCH 0667/1509] Fixed fill column rgba drawers --- src/r_draw.cpp | 11 +++-- src/r_draw.h | 1 + src/r_draw_rgba.cpp | 114 ++++++++++++++++++++++++++++---------------- 3 files changed, 82 insertions(+), 44 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 4dcdc3e6b..7829e2b77 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -154,6 +154,7 @@ fixed_t dc_iscale; fixed_t dc_texturefrac; int dc_color; // [RH] Color for column filler DWORD dc_srccolor; +uint32_t dc_srccolor_bgra; DWORD *dc_srcblend; // [RH] Source and destination DWORD *dc_destblend; // blending lookups fixed_t dc_srcalpha; // Alpha value used by dc_srcblend @@ -2702,10 +2703,10 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, if (style.Flags & STYLEF_ColorIsFixed) { - int x = fglevel >> 10; - int r = RPART(color); - int g = GPART(color); - int b = BPART(color); + uint32_t x = fglevel >> 10; + uint32_t r = RPART(color); + uint32_t g = GPART(color); + uint32_t b = BPART(color); // dc_color is used by the rt_* routines. It is indexed into dc_srcblend. dc_color = RGB32k.RGB[r>>3][g>>3][b>>3]; if (style.Flags & STYLEF_InvertSource) @@ -2714,6 +2715,8 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, g = 255 - g; b = 255 - b; } + uint32_t alpha = clamp(fglevel >> (FRACBITS - 8), 0, 255); + dc_srccolor_bgra = (alpha << 24) | (r << 16) | (g << 8) | b; // dc_srccolor is used by the R_Fill* routines. It is premultiplied // with the alpha. dc_srccolor = ((((r*x)>>4)<<20) | ((g*x)>>4) | ((((b)*x)>>4)<<10)) & 0x3feffbff; diff --git a/src/r_draw.h b/src/r_draw.h index a31183405..99ee4d10d 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -63,6 +63,7 @@ extern double dc_texturemid; extern "C" fixed_t dc_texturefrac; extern "C" int dc_color; // [RH] For flat colors (no texturing) extern "C" DWORD dc_srccolor; +extern "C" uint32_t dc_srccolor_bgra; extern "C" DWORD *dc_srcblend; extern "C" DWORD *dc_destblend; extern "C" fixed_t dc_srcalpha; diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 722fbb8cd..491c6ab98 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -344,8 +344,7 @@ class FillAddColumnRGBACommand : public DrawerCommand int _count; BYTE *_dest; int _pitch; - fixed_t _light; - int _color; + uint32_t _srccolor; public: FillAddColumnRGBACommand() @@ -353,8 +352,7 @@ public: _count = dc_count; _dest = dc_dest; _pitch = dc_pitch; - _light = dc_light; - _color = dc_color; + _srccolor = dc_srccolor_bgra; } void Execute(DrawerThread *thread) override @@ -369,10 +367,18 @@ public: dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int pitch = _pitch * thread->num_cores; - uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); - uint32_t fg_red = (fg >> 24) & 0xff; - uint32_t fg_green = (fg >> 16) & 0xff; + uint32_t fg = _srccolor; + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; + uint32_t fg_alpha = fg >> 24; + fg_alpha += fg_alpha >> 7; + + fg_red *= fg_alpha; + fg_green *= fg_alpha; + fg_blue *= fg_alpha; + + uint32_t inv_alpha = 256 - fg_alpha; do { @@ -380,9 +386,9 @@ public: uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; + uint32_t red = (fg_red + bg_red * inv_alpha) / 256; + uint32_t green = (fg_green + bg_green * inv_alpha) / 256; + uint32_t blue = (fg_blue + bg_blue * inv_alpha) / 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -395,8 +401,10 @@ class FillAddClampColumnRGBACommand : public DrawerCommand int _count; BYTE *_dest; int _pitch; - fixed_t _light; int _color; + uint32_t _srccolor; + fixed_t _srcalpha; + fixed_t _destalpha; public: FillAddClampColumnRGBACommand() @@ -404,8 +412,10 @@ public: _count = dc_count; _dest = dc_dest; _pitch = dc_pitch; - _light = dc_light; _color = dc_color; + _srccolor = dc_srccolor_bgra; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -420,20 +430,26 @@ public: dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int pitch = _pitch * thread->num_cores; - uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); - uint32_t fg_red = (fg >> 24) & 0xff; - uint32_t fg_green = (fg >> 16) & 0xff; + uint32_t fg = _srccolor; + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); + + fg_red *= fg_alpha; + fg_green *= fg_alpha; + fg_blue *= fg_alpha; + + do { - do - { uint32_t bg_red = (*dest >> 16) & 0xff; uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); + uint32_t red = clamp((fg_red + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue + bg_blue * bg_alpha) / 256, 0, 255); *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -447,7 +463,9 @@ class FillSubClampColumnRGBACommand : public DrawerCommand BYTE *_dest; int _pitch; int _color; - fixed_t _light; + uint32_t _srccolor; + fixed_t _srcalpha; + fixed_t _destalpha; public: FillSubClampColumnRGBACommand() @@ -456,7 +474,9 @@ public: _dest = dc_dest; _pitch = dc_pitch; _color = dc_color; - _light = dc_light; + _srccolor = dc_srccolor_bgra; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -471,20 +491,25 @@ public: dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int pitch = _pitch * thread->num_cores; - uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); - uint32_t fg_red = (fg >> 24) & 0xff; - uint32_t fg_green = (fg >> 16) & 0xff; + uint32_t fg = _srccolor; + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - do - { + fg_red *= fg_alpha; + fg_green *= fg_alpha; + fg_blue *= fg_alpha; + + do { uint32_t bg_red = (*dest >> 16) & 0xff; uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(256 - fg_red + bg_red, 256, 256 + 255) - 255; - uint32_t green = clamp(256 - fg_green + bg_green, 256, 256 + 255) - 255; - uint32_t blue = clamp(256 - fg_blue + bg_blue, 256, 256 + 255) - 255; + uint32_t red = clamp((0x10000 - fg_red + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -498,7 +523,9 @@ class FillRevSubClampColumnRGBACommand : public DrawerCommand BYTE *_dest; int _pitch; int _color; - fixed_t _light; + uint32_t _srccolor; + fixed_t _srcalpha; + fixed_t _destalpha; public: FillRevSubClampColumnRGBACommand() @@ -507,7 +534,9 @@ public: _dest = dc_dest; _pitch = dc_pitch; _color = dc_color; - _light = dc_light; + _srccolor = dc_srccolor_bgra; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override @@ -522,20 +551,25 @@ public: dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int pitch = _pitch * thread->num_cores; - uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); - uint32_t fg_red = (fg >> 24) & 0xff; - uint32_t fg_green = (fg >> 16) & 0xff; + uint32_t fg = _srccolor; + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - do - { + fg_red *= fg_alpha; + fg_green *= fg_alpha; + fg_blue *= fg_alpha; + + do { uint32_t bg_red = (*dest >> 16) & 0xff; uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = clamp(256 + fg_red - bg_red, 256, 256 + 255) - 255; - uint32_t green = clamp(256 + fg_green - bg_green, 256, 256 + 255) - 255; - uint32_t blue = clamp(256 + fg_blue - bg_blue, 256, 256 + 255) - 255; + uint32_t red = clamp((0x10000 + fg_red - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; From 822bbd5b9a015141d6ca17d19df8b8a8600f220b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 17 Jun 2016 13:40:23 +0200 Subject: [PATCH 0668/1509] Fuzz (invisibility) adjustments --- src/r_draw_rgba.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 491c6ab98..bdbcd1250 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -584,8 +584,8 @@ class DrawFuzzColumnRGBACommand : public DrawerCommand int _yh; BYTE *_destorg; int _pitch; - int fuzzpos; - int fuzzviewheight; + int _fuzzpos; + int _fuzzviewheight; public: DrawFuzzColumnRGBACommand() @@ -595,8 +595,8 @@ public: _yh = dc_yh; _destorg = dc_destorg; _pitch = dc_pitch; - fuzzpos = ::fuzzpos; - fuzzviewheight = ::fuzzviewheight; + _fuzzpos = fuzzpos; + _fuzzviewheight = fuzzviewheight; } void Execute(DrawerThread *thread) override @@ -609,8 +609,8 @@ public: _yl = 1; // .. and high. - if (_yh > fuzzviewheight) - _yh = fuzzviewheight; + if (_yh > _fuzzviewheight) + _yh = _fuzzviewheight; count = thread->count_for_thread(_yl, _yh - _yl + 1); @@ -622,7 +622,7 @@ public: int pitch = _pitch * thread->num_cores; int fuzzstep = thread->num_cores; - int fuzz = (fuzzpos + thread->skipped_by_thread(_yl)) % FUZZTABLE; + int fuzz = (_fuzzpos + thread->skipped_by_thread(_yl)) % FUZZTABLE; while (count > 0) { @@ -640,9 +640,9 @@ public: uint32_t bg_green = (bg >> 8) & 0xff; uint32_t bg_blue = (bg) & 0xff; - uint32_t red = bg_red * 3 / 4; - uint32_t green = bg_green * 3 / 4; - uint32_t blue = bg_blue * 3 / 4; + uint32_t red = bg_red * 7 / 8; + uint32_t green = bg_green * 7 / 8; + uint32_t blue = bg_blue * 7 / 8; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -3896,7 +3896,13 @@ void R_FillRevSubClampColumn_rgba() void R_DrawFuzzColumn_rgba() { DrawerCommandQueue::QueueCommand(); - fuzzpos = (fuzzpos + dc_yh - dc_yl) % FUZZTABLE; + + if (dc_yl == 0) + dc_yl = 1; + if (dc_yh > fuzzviewheight) + dc_yh = fuzzviewheight; + + fuzzpos = (fuzzpos + dc_yh - dc_yl + 1) % FUZZTABLE; } void R_DrawAddColumn_rgba() From 4ef2fb3cdb19d71a67c21c860f7d0bea96db8cb2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 17 Jun 2016 14:45:52 +0200 Subject: [PATCH 0669/1509] Fixed multithreaded rendering issue with the fuzz effect --- src/r_draw_rgba.cpp | 75 +++++++++++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index bdbcd1250..b1ee1f02c 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -604,26 +604,48 @@ public: int count; uint32_t *dest; - // Adjust borders. Low... - if (_yl == 0) - _yl = 1; + int yl = MAX(_yl, 1); + int yh = MIN(_yh, _fuzzviewheight); - // .. and high. - if (_yh > _fuzzviewheight) - _yh = _fuzzviewheight; - - count = thread->count_for_thread(_yl, _yh - _yl + 1); + count = thread->count_for_thread(yl, yh - yl + 1); // Zero length. if (count <= 0) return; - dest = thread->dest_for_thread(_yl, _pitch, ylookup[_yl] + _x + (uint32_t*)_destorg); + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + _x + (uint32_t*)_destorg); int pitch = _pitch * thread->num_cores; int fuzzstep = thread->num_cores; - int fuzz = (_fuzzpos + thread->skipped_by_thread(_yl)) % FUZZTABLE; + int fuzz = (_fuzzpos + thread->skipped_by_thread(yl)) % FUZZTABLE; + yl += thread->skipped_by_thread(yl); + + // Handle the case where we would go out of bounds at the top: + if (yl < fuzzstep) + { + count--; + + uint32_t bg = dest[fuzzoffset[fuzz] * fuzzstep + pitch]; + uint32_t bg_red = (bg >> 16) & 0xff; + uint32_t bg_green = (bg >> 8) & 0xff; + uint32_t bg_blue = (bg) & 0xff; + + uint32_t red = bg_red * 3 / 4; + uint32_t green = bg_green * 3 / 4; + uint32_t blue = bg_blue * 3 / 4; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + fuzz += fuzzstep; + fuzz %= FUZZTABLE; + } + + bool lowerbounds = (yl + count * fuzzstep > _fuzzviewheight); + if (lowerbounds) + count--; + + // Fuzz where fuzzoffset stays within bounds while (count > 0) { int available = (FUZZTABLE - fuzz); @@ -635,14 +657,14 @@ public: count -= cnt; do { - uint32_t bg = dest[fuzzoffset[fuzz]]; + uint32_t bg = dest[fuzzoffset[fuzz] * fuzzstep]; uint32_t bg_red = (bg >> 16) & 0xff; uint32_t bg_green = (bg >> 8) & 0xff; uint32_t bg_blue = (bg) & 0xff; - uint32_t red = bg_red * 7 / 8; - uint32_t green = bg_green * 7 / 8; - uint32_t blue = bg_blue * 7 / 8; + uint32_t red = bg_red * 3 / 4; + uint32_t green = bg_green * 3 / 4; + uint32_t blue = bg_blue * 3 / 4; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -651,6 +673,21 @@ public: fuzz %= FUZZTABLE; } + + // Handle the case where we would go out of bounds at the bottom + if (lowerbounds) + { + uint32_t bg = dest[fuzzoffset[fuzz] * fuzzstep - pitch]; + uint32_t bg_red = (bg >> 16) & 0xff; + uint32_t bg_green = (bg >> 8) & 0xff; + uint32_t bg_blue = (bg) & 0xff; + + uint32_t red = bg_red * 3 / 4; + uint32_t green = bg_green * 3 / 4; + uint32_t blue = bg_blue * 3 / 4; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + } } }; @@ -3897,12 +3934,10 @@ void R_DrawFuzzColumn_rgba() { DrawerCommandQueue::QueueCommand(); - if (dc_yl == 0) - dc_yl = 1; - if (dc_yh > fuzzviewheight) - dc_yh = fuzzviewheight; - - fuzzpos = (fuzzpos + dc_yh - dc_yl + 1) % FUZZTABLE; + dc_yl = MAX(dc_yl, 1); + dc_yh = MIN(dc_yh, fuzzviewheight); + if (dc_yl <= dc_yh) + fuzzpos = (fuzzpos + dc_yh - dc_yl + 1) % FUZZTABLE; } void R_DrawAddColumn_rgba() From 8ca07443f15ee7af829b34517d0564a8bfc101f0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 17 Jun 2016 16:16:31 +0200 Subject: [PATCH 0670/1509] - fixed: Sprite splitting at 3D floors must set the fog parameters for the new light level. --- src/gl/scene/gl_sprite.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 97e041497..eb154357f 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -239,7 +239,9 @@ void GLSprite::Draw(int pass) secplane_t *topplane = i == 0 ? &topp : &(*lightlist)[i].plane; secplane_t *lowplane = i == (*lightlist).Size() - 1 ? &bottomp : &(*lightlist)[i + 1].plane; - int thisll = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel; + int thislight = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel; + int thisll = (byte)gl_CheckSpriteGlow(actor->Sector, thislight, actor->InterpolatedPosition(r_TicFracF)); + FColormap thiscm; thiscm.FadeColor = Colormap.FadeColor; thiscm.CopyFrom3DLight(&(*lightlist)[i]); @@ -249,6 +251,10 @@ void GLSprite::Draw(int pass) } gl_SetColor(thisll, rel, thiscm, trans); + if (!foglayer) + { + gl_SetFog(thislight, rel, &thiscm, additivefog); + } gl_RenderState.SetSplitPlanes(*topplane, *lowplane); } else if (clipping) @@ -930,7 +936,7 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s lightlevel = gl_ClampLight(sector->GetTexture(sector_t::ceiling) == skyflatnum ? sector->GetCeilingLight() : sector->GetFloorLight()); - foglevel = sector->lightlevel; + foglevel = (BYTE)clamp(sector->lightlevel, 0, 255); if (gl_fixedcolormap) { From 92e2ce2aefa4fb7e6f5ad0d94e27d73549c84cfd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 17 Jun 2016 17:21:42 +0200 Subject: [PATCH 0671/1509] - adjustments for weapon rendering in GL. This adds support for the new weapon state code and fixed some lighting calculations. Note that this currently will not allow combination of HUD models with other sprite frames yet. --- src/gl/models/gl_models.cpp | 11 +-- src/gl/models/gl_models.h | 2 +- src/gl/renderer/gl_renderer.h | 4 +- src/gl/scene/gl_weapon.cpp | 159 ++++++++++++++++++++++------------ src/p_pspr.h | 1 + 5 files changed, 113 insertions(+), 64 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index a79e5ba7c..d28dfc805 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -1019,10 +1019,10 @@ void gl_RenderModel(GLSprite * spr) // //=========================================================================== -void gl_RenderHUDModel(pspdef_t *psp, float ofsX, float ofsY) +void gl_RenderHUDModel(DPSprite *psp, float ofsX, float ofsY) { AActor * playermo=players[consoleplayer].camera; - FSpriteModelFrame *smf = gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->state->sprite, psp->state->GetFrame(), false); + FSpriteModelFrame *smf = gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetState()->sprite, psp->GetState()->GetFrame(), false); // [BB] No model found for this sprite, so we can't render anything. if ( smf == nullptr ) @@ -1062,7 +1062,7 @@ void gl_RenderHUDModel(pspdef_t *psp, float ofsX, float ofsY) gl_RenderState.mViewMatrix.rotate(-smf->rolloffset, 1, 0, 0); gl_RenderState.ApplyMatrices(); - gl_RenderFrameModels( smf, psp->state, psp->tics, playermo->player->ReadyWeapon->GetClass(), nullptr, 0 ); + gl_RenderFrameModels( smf, psp->GetState(), psp->GetTics(), playermo->player->ReadyWeapon->GetClass(), nullptr, 0 ); glDepthFunc(GL_LESS); if (!( playermo->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) @@ -1077,10 +1077,11 @@ void gl_RenderHUDModel(pspdef_t *psp, float ofsX, float ofsY) bool gl_IsHUDModelForPlayerAvailable (player_t * player) { - if ( (player == nullptr) || (player->ReadyWeapon == nullptr) || (player->psprites[0].state == nullptr) ) + DPSprite *psp = player->FindPSprite(PSP_WEAPON); + if ( (player == nullptr) || (player->ReadyWeapon == nullptr) || (psp->GetState() == nullptr) ) return false; - FState* state = player->psprites[0].state; + FState* state = psp->GetState(); FSpriteModelFrame *smf = gl_FindModelFrame(player->ReadyWeapon->GetClass(), state->sprite, state->GetFrame(), false); return ( smf != nullptr ); } diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 33fa00736..9ccf765f6 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -371,7 +371,7 @@ FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame, void gl_RenderModel(GLSprite * spr); // [BB] HUD weapon model rendering functions. -void gl_RenderHUDModel(pspdef_t *psp, float ofsx, float ofsy); +void gl_RenderHUDModel(DPSprite *psp, float ofsx, float ofsy); bool gl_IsHUDModelForPlayerAvailable (player_t * player); diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index a78b8c5dc..3da5a22df 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -13,11 +13,11 @@ class FFlatVertexBuffer; class FSkyVertexBuffer; class OpenGLFrameBuffer; struct FDrawInfo; -struct pspdef_t; class FShaderManager; class GLPortal; class FLightBuffer; class FSamplerManager; +class DPSprite; inline float DEG2RAD(float deg) { @@ -109,7 +109,7 @@ public: void DrawScene(bool toscreen = false); void DrawBlend(sector_t * viewsector); - void DrawPSprite (player_t * player,pspdef_t *psp,float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture); + void DrawPSprite (player_t * player,DPSprite *psp,float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture); void DrawPlayerSprites(sector_t * viewsector, bool hudModelStep); void DrawTargeterSprites(); diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index f1cd5e38b..c5d1dc82a 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -71,7 +71,7 @@ EXTERN_CVAR (Bool, r_deathcamera) // //========================================================================== -void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp, float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture) +void FGLRenderer::DrawPSprite (player_t * player,DPSprite *psp, float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture) { float fU1,fV1; float fU2,fV2; @@ -86,13 +86,13 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp, float sx, float // [BB] In the HUD model step we just render the model and break out. if ( hudModelStep ) { - gl_RenderHUDModel( psp, sx, sy); + gl_RenderHUDModel(psp, sx, sy); return; } // decide which patch to use bool mirror; - FTextureID lump = gl_GetSpriteFrame(psp->sprite, psp->frame, 0, 0, &mirror); + FTextureID lump = gl_GetSpriteFrame(psp->GetSprite(), psp->GetFrame(), 0, 0, &mirror); if (!lump.isValid()) return; FMaterial * tex = FMaterial::ValidateTexture(lump, true, false); @@ -174,6 +174,29 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp, float sx, float gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f); } +//========================================================================== +// +// +// +//========================================================================== + +static bool isBright(DPSprite *psp) +{ + if (psp != nullptr && psp->GetState() != nullptr) + { + bool disablefullbright = false; + FTextureID lump = gl_GetSpriteFrame(psp->GetSprite(), psp->GetFrame(), 0, 0, NULL); + if (lump.isValid()) + { + FMaterial * tex = FMaterial::ValidateTexture(lump, false, false); + if (tex) + disablefullbright = tex->tex->gl_info.bDisableFullbright; + } + return psp->GetState()->GetFullbright() && !disablefullbright; + } + return false; +} + //========================================================================== // // R_DrawPlayerSprites @@ -184,11 +207,9 @@ EXTERN_CVAR(Bool, gl_brightfog) void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) { - bool statebright[2] = {false, false}; + bool brightflash = false; unsigned int i; - pspdef_t *psp; int lightlevel=0; - float ofsx, ofsy; FColormap cm; sector_t * fakesec, fs; AActor * playermo=players[consoleplayer].camera; @@ -202,33 +223,35 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) (r_deathcamera && camera->health <= 0)) return; - P_BobWeapon (player, &player->psprites[ps_weapon], &ofsx, &ofsy, r_TicFracF); + float bobx, boby, wx, wy; + DPSprite *weapon; - // check for fullbright - if (player->fixedcolormap==NOFIXEDCOLORMAP) + P_BobWeapon(camera->player, &bobx, &boby, r_TicFracF); + + // Interpolate the main weapon layer once so as to be able to add it to other layers. + if ((weapon = camera->player->FindPSprite(PSP_WEAPON)) != nullptr) { - for (i = 0, psp = player->psprites; i <= ps_flash; i++, psp++) + if (weapon->firstTic) { - if (psp->state != NULL) - { - bool disablefullbright = false; - FTextureID lump = gl_GetSpriteFrame(psp->sprite, psp->frame, 0, 0, NULL); - if (lump.isValid()) - { - FMaterial * tex=FMaterial::ValidateTexture(lump, false, false); - if (tex) - disablefullbright = tex->tex->gl_info.bDisableFullbright; - } - statebright[i] = !!psp->state->GetFullbright() && !disablefullbright; - } + wx = weapon->x; + wy = weapon->y; } + else + { + wx = weapon->oldx + (weapon->x - weapon->oldx) * r_TicFracF; + wy = weapon->oldy + (weapon->y - weapon->oldy) * r_TicFracF; + } + } + else + { + wx = 0; + wy = 0; } if (gl_fixedcolormap) { lightlevel=255; cm.Clear(); - statebright[0] = statebright[1] = true; fakesec = viewsector; } else @@ -237,20 +260,6 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) // calculate light level for weapon sprites lightlevel = gl_ClampLight(fakesec->lightlevel); - if (glset.lightmode == 8) - { - lightlevel = gl_CalcLightLevel(lightlevel, getExtraLight(), true); - - // Korshun: the way based on max possible light level for sector like in software renderer. - float min_L = 36.0/31.0 - ((lightlevel/255.0) * (63.0/31.0)); // Lightlevel in range 0-63 - if (min_L < 0) - min_L = 0; - else if (min_L > 1.0) - min_L = 1.0; - - lightlevel = (1.0 - min_L) * 255; - } - lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->Pos()); // calculate colormap for weapon sprites if (viewsector->e->XFloor.ffloors.Size() && !glset.nocoloredspritelighting) @@ -282,8 +291,27 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) cm=fakesec->ColorMap; if (glset.nocoloredspritelighting) cm.ClearColor(); } - } + lightlevel = gl_CalcLightLevel(lightlevel, getExtraLight(), true); + + if (glset.lightmode == 8) + { + // Korshun: the way based on max possible light level for sector like in software renderer. + float min_L = 36.0 / 31.0 - ((lightlevel / 255.0) * (63.0 / 31.0)); // Lightlevel in range 0-63 + if (min_L < 0) + min_L = 0; + else if (min_L > 1.0) + min_L = 1.0; + + lightlevel = (1.0 - min_L) * 255; + } + else + { + lightlevel = (2 * lightlevel + 255) / 3; + } + lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->Pos()); + + } // Korshun: fullbright fog in opengl, render weapon sprites fullbright (but don't cancel out the light color!) if (glset.brightfog && ((level.flags&LEVEL_HASFADETABLE) || cm.FadeColor != 0)) @@ -332,7 +360,6 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) vis.RenderStyle.BlendOp = STYLEOP_Shadow; } } - statebright[0] = statebright[1] = false; } gl_SetRenderStyle(vis.RenderStyle, false, false); @@ -356,24 +383,19 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); gl_RenderState.BlendEquation(GL_FUNC_ADD); - if (statebright[0] || statebright[1]) - { - // brighten the weapon to reduce the difference between - // normal sprite and fullbright flash. - if (glset.lightmode != 8) lightlevel = (2*lightlevel+255)/3; - } - + // hack alert! Rather than changing everything in the underlying lighting code let's just temporarily change // light mode here to draw the weapon sprite. int oldlightmode = glset.lightmode; if (glset.lightmode == 8) glset.lightmode = 2; - - for (i=0, psp=player->psprites; i<=ps_flash; i++,psp++) + + for(DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext()) { - if (psp->state) + if (psp->GetState() != nullptr) { FColormap cmc = cm; - if (statebright[i]) + int ll = lightlevel; + if (isBright(psp)) { if (fakesec == viewsector || in_area != area_below) { @@ -388,6 +410,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) cmc.LightColor.g = (3*cmc.LightColor.g + 0xff)/4; cmc.LightColor.b = (3*cmc.LightColor.b + 0xff)/4; } + ll = 255; } // set the lighting parameters if (vis.RenderStyle.BlendOp == STYLEOP_Shadow) @@ -400,9 +423,33 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) { gl_SetDynSpriteLight(playermo, NULL); } - gl_SetColor(statebright[i] ? 255 : lightlevel, 0, cmc, trans, true); + gl_SetColor(ll, 0, cmc, trans, true); } - DrawPSprite(player, psp, psp->sx + ofsx, psp->sy + ofsy, hudModelStep, OverrideShader, !!(vis.RenderStyle.Flags & STYLEF_RedIsAlpha)); + + if (psp->firstTic) + { // Can't interpolate the first tic. + psp->firstTic = false; + psp->oldx = psp->x; + psp->oldy = psp->y; + } + + float sx = psp->oldx + (psp->x - psp->oldx) * r_TicFracF; + float sy = psp->oldy + (psp->y - psp->oldy) * r_TicFracF; + + if (psp->Flags & PSPF_ADDBOB) + { + sx += bobx; + sy += boby; + } + + if (psp->Flags & PSPF_ADDWEAPON && psp->GetID() != PSP_WEAPON) + { + sx += wx; + sy += wy; + } + + + DrawPSprite(player, psp, sx, sy, hudModelStep, OverrideShader, !!(vis.RenderStyle.Flags & STYLEF_RedIsAlpha)); } } gl_RenderState.SetObjectColor(0xffffffff); @@ -419,8 +466,6 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) void FGLRenderer::DrawTargeterSprites() { - int i; - pspdef_t *psp; AActor * playermo=players[consoleplayer].camera; player_t * player=playermo->player; @@ -435,6 +480,8 @@ void FGLRenderer::DrawTargeterSprites() gl_RenderState.SetTextureMode(TM_MODULATE); // The Targeter's sprites are always drawn normally. - for (i=ps_targetcenter, psp = &player->psprites[ps_targetcenter]; istate) DrawPSprite (player,psp,psp->sx, psp->sy, false, 0, false); + for (DPSprite *psp = player->FindPSprite(PSP_TARGETCENTER); psp != nullptr; psp = psp->GetNext()) + { + if (psp->GetState() != nullptr) DrawPSprite(player, psp, psp->x, psp->y, false, 0, false); + } } \ No newline at end of file diff --git a/src/p_pspr.h b/src/p_pspr.h index 2c7a36518..e00f8916f 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -73,6 +73,7 @@ public: int GetID() const { return ID; } int GetSprite() const { return Sprite; } int GetFrame() const { return Frame; } + int GetTics() const { return Tics; } FState* GetState() const { return State; } DPSprite* GetNext() { return Next; } AActor* GetCaller() { return Caller; } From e7cdcd9c0af6d82c8acc7c14102fbc8c4e34da1e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 18 Jun 2016 05:20:34 +0200 Subject: [PATCH 0672/1509] Change to one pass rendering to remove fuzz artifact --- src/r_draw_rgba.cpp | 6 ++++-- src/r_draw_rgba.h | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index b1ee1f02c..6021c9265 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -624,8 +624,6 @@ public: // Handle the case where we would go out of bounds at the top: if (yl < fuzzstep) { - count--; - uint32_t bg = dest[fuzzoffset[fuzz] * fuzzstep + pitch]; uint32_t bg_red = (bg >> 16) & 0xff; uint32_t bg_green = (bg >> 8) & 0xff; @@ -639,6 +637,10 @@ public: dest += pitch; fuzz += fuzzstep; fuzz %= FUZZTABLE; + + count--; + if (count == 0) + return; } bool lowerbounds = (yl + count * fuzzstep > _fuzzviewheight); diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 15a76c689..83977d65c 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -209,8 +209,8 @@ class DrawerCommandQueue int threaded_render = 0; DrawerThread single_core_thread; - int num_passes = 2; - int rows_in_pass = 540; + int num_passes = 1; + int rows_in_pass = MAXHEIGHT; void StartThreads(); void StopThreads(); From 87d27b8db3308369eaf6044158dd6c2398ff1a4f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 18 Jun 2016 10:01:24 +0200 Subject: [PATCH 0673/1509] - fixed some crash issues with recent changes. --- src/gl/models/gl_models.cpp | 6 +++++- src/gl/scene/gl_sprite.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index d28dfc805..c2f45ea10 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -1077,8 +1077,12 @@ void gl_RenderHUDModel(DPSprite *psp, float ofsX, float ofsY) bool gl_IsHUDModelForPlayerAvailable (player_t * player) { + if (player == nullptr || player->ReadyWeapon == nullptr) + return false; + DPSprite *psp = player->FindPSprite(PSP_WEAPON); - if ( (player == nullptr) || (player->ReadyWeapon == nullptr) || (psp->GetState() == nullptr) ) + + if (psp == nullptr || psp->GetState() == nullptr) return false; FState* state = psp->GetState(); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index eb154357f..447e6b78e 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -240,7 +240,7 @@ void GLSprite::Draw(int pass) secplane_t *lowplane = i == (*lightlist).Size() - 1 ? &bottomp : &(*lightlist)[i + 1].plane; int thislight = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel; - int thisll = (byte)gl_CheckSpriteGlow(actor->Sector, thislight, actor->InterpolatedPosition(r_TicFracF)); + int thisll = actor == nullptr? thislight : (uint8_t)gl_CheckSpriteGlow(actor->Sector, thislight, actor->InterpolatedPosition(r_TicFracF)); FColormap thiscm; thiscm.FadeColor = Colormap.FadeColor; From 3e7eb79729049302bf80e79908af8a8006c3841c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 18 Jun 2016 11:17:59 +0200 Subject: [PATCH 0674/1509] Added some experimental AVX2 drawers --- src/r_draw_rgba.cpp | 420 ++++++++++++++++++++++++++++++++++--------- src/r_draw_rgba.h | 91 ++++++++++ src/r_drawt_rgba.cpp | 46 ++--- 3 files changed, 454 insertions(+), 103 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 6021c9265..271250855 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -44,9 +44,14 @@ #include "x86.h" #ifndef NO_SSE #include +#include #endif #include +#ifdef _MSC_VER +#pragma warning(disable: 4752) // warning C4752: found Intel(R) Advanced Vector Extensions; consider using /arch:AVX +#endif + extern int vlinebits; extern int mvlinebits; extern int tmvlinebits; @@ -58,6 +63,8 @@ extern int wallshade; CVAR(Bool, r_multithreaded, true, 0) +//#define USE_AVX // Use AVX2 256 bit intrinsics (requires Haswell or newer) + ///////////////////////////////////////////////////////////////////////////// DrawerCommandQueue *DrawerCommandQueue::Instance() @@ -230,14 +237,14 @@ void DrawerCommandQueue::StopThreads() class DrawColumnRGBACommand : public DrawerCommand { int _count; - BYTE *_dest; + BYTE * RESTRICT _dest; DWORD _texturefrac; DWORD _iscale; fixed_t _light; - const BYTE *_source; + const BYTE * RESTRICT _source; int _pitch; ShadeConstants _shade_constants; - BYTE *_colormap; + BYTE * RESTRICT _colormap; public: DrawColumnRGBACommand() @@ -297,7 +304,7 @@ public: class FillColumnRGBACommand : public DrawerCommand { int _count; - BYTE *_dest; + BYTE * RESTRICT _dest; fixed_t _light; int _pitch; int _color; @@ -342,7 +349,7 @@ public: class FillAddColumnRGBACommand : public DrawerCommand { int _count; - BYTE *_dest; + BYTE * RESTRICT _dest; int _pitch; uint32_t _srccolor; @@ -399,7 +406,7 @@ public: class FillAddClampColumnRGBACommand : public DrawerCommand { int _count; - BYTE *_dest; + BYTE * RESTRICT _dest; int _pitch; int _color; uint32_t _srccolor; @@ -460,7 +467,7 @@ public: class FillSubClampColumnRGBACommand : public DrawerCommand { int _count; - BYTE *_dest; + BYTE * RESTRICT _dest; int _pitch; int _color; uint32_t _srccolor; @@ -520,7 +527,7 @@ public: class FillRevSubClampColumnRGBACommand : public DrawerCommand { int _count; - BYTE *_dest; + BYTE * RESTRICT _dest; int _pitch; int _color; uint32_t _srccolor; @@ -582,7 +589,7 @@ class DrawFuzzColumnRGBACommand : public DrawerCommand int _x; int _yl; int _yh; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _pitch; int _fuzzpos; int _fuzzviewheight; @@ -696,16 +703,16 @@ public: class DrawAddColumnRGBACommand : public DrawerCommand { int _count; - BYTE *_dest; + BYTE * RESTRICT _dest; DWORD _iscale; DWORD _texturefrac; - const BYTE *_source; + const BYTE * RESTRICT _source; int _pitch; fixed_t _light; ShadeConstants _shade_constants; fixed_t _srcalpha; fixed_t _destalpha; - BYTE *_colormap; + BYTE * RESTRICT _colormap; public: DrawAddColumnRGBACommand() @@ -779,11 +786,11 @@ class DrawTranslatedColumnRGBACommand : public DrawerCommand int _count; fixed_t _light; ShadeConstants _shade_constants; - BYTE *_dest; + BYTE * RESTRICT _dest; DWORD _iscale; DWORD _texturefrac; - BYTE *_translation; - const BYTE *_source; + BYTE * RESTRICT _translation; + const BYTE * RESTRICT _source; int _pitch; public: @@ -840,11 +847,11 @@ class DrawTlatedAddColumnRGBACommand : public DrawerCommand int _count; fixed_t _light; ShadeConstants _shade_constants; - BYTE *_dest; + BYTE * RESTRICT _dest; DWORD _iscale; DWORD _texturefrac; - BYTE *_translation; - const BYTE *_source; + BYTE * RESTRICT _translation; + const BYTE * RESTRICT _source; int _pitch; fixed_t _srcalpha; fixed_t _destalpha; @@ -920,12 +927,12 @@ class DrawShadedColumnRGBACommand : public DrawerCommand { private: int _count; - BYTE *_dest; + BYTE * RESTRICT _dest; DWORD _iscale; DWORD _texturefrac; fixed_t _light; - const BYTE *_source; - lighttable_t *_colormap; + const BYTE * RESTRICT _source; + lighttable_t * RESTRICT _colormap; int _color; int _pitch; @@ -993,10 +1000,10 @@ public: class DrawAddClampColumnRGBACommand : public DrawerCommand { int _count; - BYTE *_dest; + BYTE * RESTRICT _dest; DWORD _iscale; DWORD _texturefrac; - const BYTE *_source; + const BYTE * RESTRICT _source; int _pitch; fixed_t _light; ShadeConstants _shade_constants; @@ -1069,11 +1076,11 @@ public: class DrawAddClampTranslatedColumnRGBACommand : public DrawerCommand { int _count; - BYTE *_dest; + BYTE * RESTRICT _dest; DWORD _iscale; DWORD _texturefrac; - BYTE *_translation; - const BYTE *_source; + BYTE * RESTRICT _translation; + const BYTE * RESTRICT _source; int _pitch; fixed_t _light; ShadeConstants _shade_constants; @@ -1148,10 +1155,10 @@ public: class DrawSubClampColumnRGBACommand : public DrawerCommand { int _count; - BYTE *_dest; + BYTE * RESTRICT _dest; DWORD _iscale; DWORD _texturefrac; - const BYTE *_source; + const BYTE * RESTRICT _source; int _pitch; fixed_t _light; ShadeConstants _shade_constants; @@ -1224,16 +1231,16 @@ public: class DrawSubClampTranslatedColumnRGBACommand : public DrawerCommand { int _count; - BYTE *_dest; + BYTE * RESTRICT _dest; DWORD _iscale; DWORD _texturefrac; - const BYTE *_source; + const BYTE * RESTRICT _source; int _pitch; fixed_t _light; ShadeConstants _shade_constants; fixed_t _srcalpha; fixed_t _destalpha; - BYTE *_translation; + BYTE * RESTRICT _translation; public: DrawSubClampTranslatedColumnRGBACommand() @@ -1303,10 +1310,10 @@ public: class DrawRevSubClampColumnRGBACommand : public DrawerCommand { int _count; - BYTE *_dest; + BYTE * RESTRICT _dest; DWORD _iscale; DWORD _texturefrac; - const BYTE *_source; + const BYTE * RESTRICT _source; int _pitch; fixed_t _light; ShadeConstants _shade_constants; @@ -1378,16 +1385,16 @@ public: class DrawRevSubClampTranslatedColumnRGBACommand : public DrawerCommand { int _count; - BYTE *_dest; + BYTE * RESTRICT _dest; DWORD _iscale; DWORD _texturefrac; - const BYTE *_source; + const BYTE * RESTRICT _source; int _pitch; fixed_t _light; ShadeConstants _shade_constants; fixed_t _srcalpha; fixed_t _destalpha; - BYTE *_translation; + BYTE * RESTRICT _translation; public: DrawRevSubClampTranslatedColumnRGBACommand() @@ -1422,8 +1429,8 @@ public: frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); { - BYTE *translation = _translation; - const BYTE *source = _source; + BYTE * RESTRICT translation = _translation; + const BYTE * RESTRICT source = _source; int pitch = _pitch * thread->num_cores; uint32_t light = calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; @@ -1456,7 +1463,7 @@ public: class DrawSpanRGBACommand : public DrawerCommand { - const uint32_t *_source; + const uint32_t * RESTRICT _source; fixed_t _xfrac; fixed_t _yfrac; fixed_t _xstep; @@ -1466,7 +1473,7 @@ class DrawSpanRGBACommand : public DrawerCommand int _y; int _xbits; int _ybits; - BYTE *_destorg; + BYTE * RESTRICT _destorg; fixed_t _light; ShadeConstants _shade_constants; @@ -1539,6 +1546,181 @@ public: BYTE xshift = yshift - _xbits; int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + // Current texture index in u,v. + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + + // Lookup pixel from flat texture tile + *dest++ = shade_bgra(source[spot], light, shade_constants); + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + } +#elif defined(USE_AVX) + void Execute(DrawerThread *thread) override + { + if (thread->line_skipped_by_thread(_y)) + return; + + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + uint32_t* dest; + const uint32_t* source = _source; + int count; + int spot; + + xfrac = _xfrac; + yfrac = _yfrac; + + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; + + count = _x2 - _x1 + 1; + + xstep = _xstep; + ystep = _ystep; + + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; + + if (_xbits == 6 && _ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + + int sse_count = count / 8; + count -= sse_count * 8; + + if (shade_constants.simple_shade) + { + AVX2_SHADE_SIMPLE_INIT(light); + + while (sse_count--) + { + uint32_t fg_pixels[8]; + for (int i = 0; i < 8; i++) + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + fg_pixels[i] = source[spot]; + xfrac += xstep; + yfrac += ystep; + } + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + __m256i fg = _mm256_loadu_si256((const __m256i*)fg_pixels); + AVX2_SHADE_SIMPLE(fg); + _mm256_storeu_si256((__m256i*)dest, fg); + + // Next step in u,v. + dest += 8; + } + } + else + { + AVX2_SHADE_INIT(light, shade_constants); + + while (sse_count--) + { + uint32_t fg_pixels[8]; + for (int i = 0; i < 8; i++) + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + fg_pixels[i] = source[spot]; + xfrac += xstep; + yfrac += ystep; + } + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + __m256i fg = _mm256_loadu_si256((const __m256i*)fg_pixels); + AVX2_SHADE(fg, shade_constants); + _mm256_storeu_si256((__m256i*)dest, fg); + + // Next step in u,v. + dest += 8; + } + } + + if (count == 0) + return; + + do + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + + // Lookup pixel from flat texture tile + *dest++ = shade_bgra(source[spot], light, shade_constants); + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + + int sse_count = count / 8; + count -= sse_count * 8; + + if (shade_constants.simple_shade) + { + AVX2_SHADE_SIMPLE_INIT(light); + + while (sse_count--) + { + uint32_t fg_pixels[8]; + for (int i = 0; i < 8; i++) + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + fg_pixels[i] = source[spot]; + xfrac += xstep; + yfrac += ystep; + } + + // Lookup pixel from flat texture tile + __m256i fg = _mm256_loadu_si256((const __m256i*)fg_pixels); + AVX2_SHADE_SIMPLE(fg); + _mm256_storeu_si256((__m256i*)dest, fg); + dest += 8; + } + } + else + { + AVX2_SHADE_INIT(light, shade_constants); + + while (sse_count--) + { + uint32_t fg_pixels[8]; + for (int i = 0; i < 8; i++) + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + fg_pixels[i] = source[spot]; + xfrac += xstep; + yfrac += ystep; + } + + // Lookup pixel from flat texture tile + __m256i fg = _mm256_loadu_si256((const __m256i*)fg_pixels); + AVX2_SHADE_SIMPLE(fg); + _mm256_storeu_si256((__m256i*)dest, fg); + dest += 4; + } + } + + if (count == 0) + return; + do { // Current texture index in u,v. @@ -1777,12 +1959,12 @@ public: class DrawSpanMaskedRGBACommand : public DrawerCommand { - const uint32_t *_source; + const uint32_t * RESTRICT _source; fixed_t _light; ShadeConstants _shade_constants; fixed_t _xfrac; fixed_t _yfrac; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _x1; int _x2; int _y1; @@ -1880,12 +2062,12 @@ public: class DrawSpanTranslucentRGBACommand : public DrawerCommand { - const uint32_t *_source; + const uint32_t * RESTRICT _source; fixed_t _light; ShadeConstants _shade_constants; fixed_t _xfrac; fixed_t _yfrac; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _x1; int _x2; int _y1; @@ -2006,12 +2188,12 @@ public: class DrawSpanMaskedTranslucentRGBACommand : public DrawerCommand { - const uint32_t *_source; + const uint32_t * RESTRICT _source; fixed_t _light; ShadeConstants _shade_constants; fixed_t _xfrac; fixed_t _yfrac; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _x1; int _x2; int _y1; @@ -2142,12 +2324,12 @@ public: class DrawSpanAddClampRGBACommand : public DrawerCommand { - const uint32_t *_source; + const uint32_t * RESTRICT _source; fixed_t _light; ShadeConstants _shade_constants; fixed_t _xfrac; fixed_t _yfrac; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _x1; int _x2; int _y1; @@ -2268,12 +2450,12 @@ public: class DrawSpanMaskedAddClampRGBACommand : public DrawerCommand { - const uint32_t *_source; + const uint32_t * RESTRICT _source; fixed_t _light; ShadeConstants _shade_constants; fixed_t _xfrac; fixed_t _yfrac; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _x1; int _x2; int _y1; @@ -2407,7 +2589,7 @@ class FillSpanRGBACommand : public DrawerCommand int _x1; int _x2; int _y; - BYTE *_destorg; + BYTE * RESTRICT _destorg; fixed_t _light; int _color; @@ -2441,8 +2623,8 @@ class Vlinec1RGBACommand : public DrawerCommand DWORD _iscale; DWORD _texturefrac; int _count; - const BYTE *_source; - BYTE *_dest; + const BYTE * RESTRICT _source; + BYTE * RESTRICT _dest; int vlinebits; int _pitch; fixed_t _light; @@ -2489,7 +2671,7 @@ public: class Vlinec4RGBACommand : public DrawerCommand { - BYTE *_dest; + BYTE * RESTRICT _dest; int _count; int _pitch; ShadeConstants _shade_constants; @@ -2497,7 +2679,7 @@ class Vlinec4RGBACommand : public DrawerCommand fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; - const uint32 *bufplce[4]; + const uint32 * RESTRICT bufplce[4]; public: Vlinec4RGBACommand() @@ -2553,6 +2735,84 @@ public: dest += pitch; } while (--count); } +#elif defined(USE_AVX) + void Execute(DrawerThread *thread) override + { + int count = thread->count_for_thread(_dest_y, _count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int bits = vlinebits; + int pitch = _pitch * thread->num_cores; + + uint32_t light0 = calc_light_multiplier(palookuplight[0]); + uint32_t light1 = calc_light_multiplier(palookuplight[1]); + uint32_t light2 = calc_light_multiplier(palookuplight[2]); + uint32_t light3 = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = _shade_constants; + + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } + + if (count & 1) + { + DWORD place; + dest[0] = shade_bgra(bufplce[0][(place = local_vplce[0]) >> bits], light0, shade_constants); local_vplce[0] = place + local_vince[0]; + dest[1] = shade_bgra(bufplce[1][(place = local_vplce[1]) >> bits], light1, shade_constants); local_vplce[1] = place + local_vince[1]; + dest[2] = shade_bgra(bufplce[2][(place = local_vplce[2]) >> bits], light2, shade_constants); local_vplce[2] = place + local_vince[2]; + dest[3] = shade_bgra(bufplce[3][(place = local_vplce[3]) >> bits], light3, shade_constants); local_vplce[3] = place + local_vince[3]; + dest += pitch; + } + count /= 2; + + // Assume all columns come from the same texture (which they do): + const uint32_t *base_addr = MIN(MIN(MIN(bufplce[0], bufplce[1]), bufplce[2]), bufplce[3]); + __m256i column_offsets = _mm256_set_epi32( + bufplce[3] - base_addr, bufplce[2] - base_addr, bufplce[1] - base_addr, bufplce[0] - base_addr, + bufplce[3] - base_addr, bufplce[2] - base_addr, bufplce[1] - base_addr, bufplce[0] - base_addr); + + __m256i place = _mm256_set_epi32( + local_vplce[3] + local_vince[3], local_vplce[2] + local_vince[2], local_vplce[1] + local_vince[1], local_vplce[0] + local_vince[0], + local_vplce[3], local_vplce[2], local_vplce[1], local_vplce[0]); + + __m256i step = _mm256_set_epi32( + local_vince[3], local_vince[2], local_vince[1], local_vince[0], + local_vince[3], local_vince[2], local_vince[1], local_vince[0]); + step = _mm256_add_epi32(step, step); + + if (shade_constants.simple_shade) + { + AVX2_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); + while (count--) + { + __m256i fg = _mm256_i32gather_epi32((const int *)base_addr, _mm256_add_epi32(column_offsets, _mm256_srli_epi32(place, bits)), 4); + place = _mm256_add_epi32(place, step); + AVX2_SHADE_SIMPLE(fg); + _mm256_storeu2_m128i((__m128i*)(dest + pitch), (__m128i*)dest, fg); + dest += pitch * 2; + } + } + else + { + AVX2_SHADE_INIT4(light3, light2, light1, light0, shade_constants); + while (count--) + { + __m256i fg = _mm256_i32gather_epi32((const int *)base_addr, _mm256_add_epi32(column_offsets, _mm256_srai_epi32(place, bits)), 4); + place = _mm256_add_epi32(place, step); + AVX2_SHADE(fg, shade_constants); + _mm256_storeu2_m128i((__m128i*)(dest + pitch), (__m128i*)dest, fg); + dest += pitch * 2; + } + } + } #else void Execute(DrawerThread *thread) override { @@ -2641,8 +2901,8 @@ class Mvlinec1RGBACommand : public DrawerCommand DWORD _iscale; DWORD _texturefrac; int _count; - const BYTE *_source; - BYTE *_dest; + const BYTE * RESTRICT _source; + BYTE * RESTRICT _dest; int mvlinebits; int _pitch; fixed_t _light; @@ -2693,7 +2953,7 @@ public: class Mvlinec4RGBACommand : public DrawerCommand { - BYTE *_dest; + BYTE * RESTRICT _dest; int _count; int _pitch; ShadeConstants _shade_constants; @@ -2701,7 +2961,7 @@ class Mvlinec4RGBACommand : public DrawerCommand fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; - const uint32 *bufplce[4]; + const uint32 * RESTRICT bufplce[4]; public: Mvlinec4RGBACommand() @@ -2852,8 +3112,8 @@ class Tmvline1AddRGBACommand : public DrawerCommand DWORD _iscale; DWORD _texturefrac; int _count; - const BYTE *_source; - BYTE *_dest; + const BYTE * RESTRICT _source; + BYTE * RESTRICT _dest; int tmvlinebits; int _pitch; fixed_t _light; @@ -2924,7 +3184,7 @@ public: class Tmvline4AddRGBACommand : public DrawerCommand { - BYTE *_dest; + BYTE * RESTRICT _dest; int _count; int _pitch; ShadeConstants _shade_constants; @@ -2934,7 +3194,7 @@ class Tmvline4AddRGBACommand : public DrawerCommand fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; - const uint32 *bufplce[4]; + const uint32 * RESTRICT bufplce[4]; public: Tmvline4AddRGBACommand() @@ -3019,8 +3279,8 @@ class Tmvline1AddClampRGBACommand : public DrawerCommand DWORD _iscale; DWORD _texturefrac; int _count; - const BYTE *_source; - BYTE *_dest; + const BYTE * RESTRICT _source; + BYTE * RESTRICT _dest; int tmvlinebits; int _pitch; fixed_t _light; @@ -3091,7 +3351,7 @@ public: class Tmvline4AddClampRGBACommand : public DrawerCommand { - BYTE *_dest; + BYTE * RESTRICT _dest; int _count; int _pitch; ShadeConstants _shade_constants; @@ -3101,7 +3361,7 @@ class Tmvline4AddClampRGBACommand : public DrawerCommand fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; - const uint32 *bufplce[4]; + const uint32 *RESTRICT bufplce[4]; public: Tmvline4AddClampRGBACommand() @@ -3186,8 +3446,8 @@ class Tmvline1SubClampRGBACommand : public DrawerCommand DWORD _iscale; DWORD _texturefrac; int _count; - const BYTE *_source; - BYTE *_dest; + const BYTE * RESTRICT _source; + BYTE * RESTRICT _dest; int tmvlinebits; int _pitch; fixed_t _light; @@ -3258,7 +3518,7 @@ public: class Tmvline4SubClampRGBACommand : public DrawerCommand { - BYTE *_dest; + BYTE * RESTRICT _dest; int _count; int _pitch; ShadeConstants _shade_constants; @@ -3268,7 +3528,7 @@ class Tmvline4SubClampRGBACommand : public DrawerCommand fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; - const uint32 *bufplce[4]; + const uint32 *RESTRICT bufplce[4]; public: Tmvline4SubClampRGBACommand() @@ -3353,8 +3613,8 @@ class Tmvline1RevSubClampRGBACommand : public DrawerCommand DWORD _iscale; DWORD _texturefrac; int _count; - const BYTE *_source; - BYTE *_dest; + const BYTE * RESTRICT _source; + BYTE * RESTRICT _dest; int tmvlinebits; int _pitch; fixed_t _light; @@ -3425,7 +3685,7 @@ public: class Tmvline4RevSubClampRGBACommand : public DrawerCommand { - BYTE *_dest; + BYTE * RESTRICT _dest; int _count; int _pitch; ShadeConstants _shade_constants; @@ -3435,7 +3695,7 @@ class Tmvline4RevSubClampRGBACommand : public DrawerCommand fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; - const uint32 *bufplce[4]; + const uint32 *RESTRICT bufplce[4]; public: Tmvline4RevSubClampRGBACommand() @@ -3520,7 +3780,7 @@ class DrawFogBoundaryLineRGBACommand : public DrawerCommand int _y; int _x; int _x2; - BYTE *_destorg; + BYTE * RESTRICT _destorg; fixed_t _light; ShadeConstants _shade_constants; @@ -3592,10 +3852,10 @@ class DrawTiltedSpanRGBACommand : public DrawerCommand int _y; int _x1; int _x2; - BYTE *_destorg; + BYTE * RESTRICT _destorg; fixed_t _light; ShadeConstants _shade_constants; - const BYTE *_source; + const BYTE * RESTRICT _source; public: DrawTiltedSpanRGBACommand(int y, int x1, int x2) @@ -3637,7 +3897,7 @@ class DrawColoredSpanRGBACommand : public DrawerCommand int _y; int _x1; int _x2; - BYTE *_destorg; + BYTE * RESTRICT _destorg; fixed_t _light; int _color; @@ -3678,7 +3938,7 @@ class FillTransColumnRGBACommand : public DrawerCommand int _y2; int _color; int _a; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _pitch; fixed_t _light; diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 83977d65c..8f051b4cb 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -290,6 +290,17 @@ public: #endif #endif +// Promise compiler we have no aliasing of this pointer +#ifndef RESTRICT +#if defined(_MSC_VER) +#define RESTRICT __restrict +#elif defined(__GNUC__) +#define RESTRICT __restrict__ +#else +#define RESTRICT +#endif +#endif + // calculates the light constant passed to the shade_pal_index function FORCEINLINE uint32_t calc_light_multiplier(dsfixed_t light) { @@ -413,6 +424,86 @@ FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) return 0xff000000 | (red << 16) | (green << 8) | blue; } +// Calculate constants for a simple shade +#define AVX2_SHADE_SIMPLE_INIT(light) \ + __m256i mlight = _mm256_set_epi16(256, light, light, light, 256, light, light, light, 256, light, light, light, 256, light, light, light); + +// Calculate constants for a simple shade with different light levels for each pixel +#define AVX2_SHADE_SIMPLE_INIT4(light3, light2, light1, light0) \ + __m256i mlight = _mm256_set_epi16(256, light3, light3, light3, 256, light2, light2, light2, 256, light1, light1, light1, 256, light0, light0, light0); + +// Simple shade 8 pixels +#define AVX2_SHADE_SIMPLE(fg) { \ + __m256i fg_hi = _mm256_unpackhi_epi8(fg, _mm256_setzero_si256()); \ + __m256i fg_lo = _mm256_unpacklo_epi8(fg, _mm256_setzero_si256()); \ + fg_hi = _mm256_mullo_epi16(fg_hi, mlight); \ + fg_hi = _mm256_srli_epi16(fg_hi, 8); \ + fg_lo = _mm256_mullo_epi16(fg_lo, mlight); \ + fg_lo = _mm256_srli_epi16(fg_lo, 8); \ + fg = _mm256_packus_epi16(fg_lo, fg_hi); \ +} + +// Calculate constants for a complex shade +#define AVX2_SHADE_INIT(light, shade_constants) \ + __m256i mlight = _mm256_set_epi16(256, light, light, light, 256, light, light, light, 256, light, light, light, 256, light, light, light); \ + __m256i color = _mm256_set_epi16( \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ + __m256i fade = _mm256_set_epi16( \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ + __m256i fade_amount = _mm256_mullo_epi16(fade, _mm256_subs_epu16(_mm256_set1_epi16(256), mlight)); \ + __m256i desaturate = _mm256_set1_epi16(shade_constants.desaturate); \ + __m256i inv_desaturate = _mm256_set1_epi16(256 - shade_constants.desaturate); + +// Calculate constants for a complex shade with different light levels for each pixel +#define AVX2_SHADE_INIT4(light3, light2, light1, light0, shade_constants) \ + __m256i mlight = _mm256_set_epi16(256, light3, light3, light3, 256, light2, light2, light2, 256, light1, light1, light1, 256, light0, light0, light0); \ + __m256i color = _mm256_set_epi16( \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ + shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ + __m256i fade = _mm256_set_epi16( \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ + shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ + __m256i fade_amount = _mm256_mullo_epi16(fade, _mm256_subs_epu16(_mm256_set1_epi16(256), mlight)); \ + __m256i desaturate = _mm256_set1_epi16(shade_constants.desaturate); \ + __m256i inv_desaturate = _mm256_set1_epi16(256 - shade_constants.desaturate); + +// Complex shade 8 pixels +#define AVX2_SHADE(fg, shade_constants) { \ + __m256i fg_hi = _mm256_unpackhi_epi8(fg, _mm256_setzero_si256()); \ + __m256i fg_lo = _mm256_unpacklo_epi8(fg, _mm256_setzero_si256()); \ + \ + __m256i intensity_hi = _mm256_mullo_epi16(fg_hi, _mm256_set_epi16(0, 77, 143, 37, 0, 77, 143, 37, 0, 77, 143, 37, 0, 77, 143, 37)); \ + __m256i intensity_lo = _mm256_mullo_epi16(fg_lo, _mm256_set_epi16(0, 77, 143, 37, 0, 77, 143, 37, 0, 77, 143, 37, 0, 77, 143, 37)); \ + __m256i intensity = _mm256_mullo_epi16(_mm256_srli_epi16(_mm256_hadd_epi16(_mm256_hadd_epi16(intensity_lo, intensity_hi), _mm256_setzero_si256()), 8), desaturate); \ + intensity = _mm256_unpacklo_epi16(intensity, intensity); \ + intensity_hi = _mm256_unpackhi_epi32(intensity, intensity); \ + intensity_lo = _mm256_unpacklo_epi32(intensity, intensity); \ + \ + fg_hi = _mm256_srli_epi16(_mm256_adds_epu16(_mm256_mullo_epi16(fg_hi, inv_desaturate), intensity_hi), 8); \ + fg_hi = _mm256_srli_epi16(_mm256_adds_epu16(_mm256_mullo_epi16(fg_hi, mlight), fade_amount), 8); \ + fg_hi = _mm256_srli_epi16(_mm256_mullo_epi16(fg_hi, color), 8); \ + \ + fg_lo = _mm256_srli_epi16(_mm256_adds_epu16(_mm256_mullo_epi16(fg_lo, inv_desaturate), intensity_lo), 8); \ + fg_lo = _mm256_srli_epi16(_mm256_adds_epu16(_mm256_mullo_epi16(fg_lo, mlight), fade_amount), 8); \ + fg_lo = _mm256_srli_epi16(_mm256_mullo_epi16(fg_lo, color), 8); \ + \ + fg = _mm256_packus_epi16(fg_lo, fg_hi); \ +} + + + + + // Calculate constants for a simple shade #define SSE_SHADE_SIMPLE_INIT(light) \ __m128i mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 2311cb447..269dd9d9d 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -59,7 +59,7 @@ class RtCopy1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _pitch; public: @@ -123,9 +123,9 @@ class RtMap1colRGBACommand : public DrawerCommand int yh; fixed_t _light; ShadeConstants _shade_constants; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _pitch; - BYTE *_colormap; + BYTE * RESTRICT _colormap; public: RtMap1colRGBACommand(int hx, int sx, int yl, int yh) @@ -188,9 +188,9 @@ class RtMap4colsRGBACommand : public DrawerCommand int yh; fixed_t _light; ShadeConstants _shade_constants; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _pitch; - BYTE *_colormap; + BYTE * RESTRICT _colormap; public: RtMap4colsRGBACommand(int sx, int yl, int yh) @@ -383,7 +383,7 @@ public: class RtTranslate1colRGBACommand : public DrawerCommand { - const BYTE *translation; + const BYTE * RESTRICT translation; int hx; int yl; int yh; @@ -447,7 +447,7 @@ public: class RtTranslate4colsRGBACommand : public DrawerCommand { - const BYTE *translation; + const BYTE * RESTRICT translation; int yl; int yh; @@ -507,13 +507,13 @@ class RtAdd1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _pitch; fixed_t _light; ShadeConstants _shade_constants; fixed_t _srcalpha; fixed_t _destalpha; - BYTE *_colormap; + BYTE * RESTRICT _colormap; public: RtAdd1colRGBACommand(int hx, int sx, int yl, int yh) @@ -583,11 +583,11 @@ class RtAdd4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _pitch; fixed_t _light; ShadeConstants _shade_constants; - BYTE *_colormap; + BYTE * RESTRICT _colormap; fixed_t _srcalpha; fixed_t _destalpha; @@ -764,8 +764,8 @@ class RtShaded1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - lighttable_t *_colormap; - BYTE *_destorg; + lighttable_t * RESTRICT _colormap; + BYTE * RESTRICT _destorg; int _pitch; int _color; fixed_t _light; @@ -833,9 +833,9 @@ class RtShaded4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - lighttable_t *_colormap; + lighttable_t * RESTRICT _colormap; int _color; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _pitch; fixed_t _light; @@ -957,7 +957,7 @@ class RtAddClamp1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _pitch; fixed_t _light; ShadeConstants _shade_constants; @@ -1029,7 +1029,7 @@ class RtAddClamp4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _pitch; fixed_t _light; fixed_t _srcalpha; @@ -1205,7 +1205,7 @@ class RtSubClamp1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _pitch; fixed_t _light; fixed_t _srcalpha; @@ -1277,7 +1277,7 @@ class RtSubClamp4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _pitch; fixed_t _light; fixed_t _srcalpha; @@ -1353,7 +1353,7 @@ class RtRevSubClamp1colRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _pitch; fixed_t _light; fixed_t _srcalpha; @@ -1425,7 +1425,7 @@ class RtRevSubClamp4colsRGBACommand : public DrawerCommand int sx; int yl; int yh; - BYTE *_destorg; + BYTE * RESTRICT _destorg; int _pitch; fixed_t _light; fixed_t _srcalpha; @@ -1497,7 +1497,7 @@ public: class RtInitColsRGBACommand : public DrawerCommand { - BYTE *buff; + BYTE * RESTRICT buff; public: RtInitColsRGBACommand(BYTE *buff) @@ -1516,7 +1516,7 @@ class DrawColumnHorizRGBACommand : public DrawerCommand int _count; fixed_t _iscale; fixed_t _texturefrac; - const BYTE *_source; + const BYTE * RESTRICT _source; int _x; int _yl; int _yh; From 7b99c883e1d2eaf2cf932e6ab3b908ac45947aa0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 18 Jun 2016 12:14:20 +0200 Subject: [PATCH 0675/1509] - use the exact same semantics and methods to handle player visibility as in the software renderer. This fixes invisible player sprites in recursive line portals. --- src/gl/renderer/gl_renderer.h | 8 +++++++- src/gl/scene/gl_portal.cpp | 27 +++++++++++++-------------- src/gl/scene/gl_portal.h | 2 +- src/gl/scene/gl_scene.cpp | 22 ++++++++++++++++++---- src/gl/scene/gl_sprite.cpp | 15 ++++++--------- 5 files changed, 45 insertions(+), 29 deletions(-) diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 3da5a22df..e8ef87157 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -53,6 +53,12 @@ struct GL_IRECT } }; +enum +{ + DM_MAINVIEW, + DM_OFFSCREEN, + DM_PORTAL +}; class FGLRenderer { @@ -106,7 +112,7 @@ public: void RenderMultipassStuff(); void RenderScene(int recursion); void RenderTranslucent(); - void DrawScene(bool toscreen = false); + void DrawScene(int drawmode); void DrawBlend(sector_t * viewsector); void DrawPSprite (player_t * player,DPSprite *psp,float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture); diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index e4603cd1e..6082c6f4f 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -306,9 +306,10 @@ bool GLPortal::Start(bool usestencil, bool doquery) savedAngle = ViewAngle; savedviewactor=GLRenderer->mViewActor; savedviewarea=in_area; - savedshowviewer = r_showviewer; savedviewpath[0] = ViewPath[0]; savedviewpath[1] = ViewPath[1]; + savedvisibility = camera ? camera->renderflags & RF_INVISIBLE : ActorRenderFlags::FromInt(0); + PrevPortal = GLRenderer->mCurrentPortal; PrevClipPortal = GLRenderer->mClipPortal; @@ -375,7 +376,7 @@ void GLPortal::End(bool usestencil) ViewAngle = savedAngle; GLRenderer->mViewActor=savedviewactor; in_area=savedviewarea; - r_showviewer = savedshowviewer; + if (camera != nullptr) camera->renderflags = (camera->renderflags & ~RF_INVISIBLE) | savedvisibility; GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); { @@ -432,7 +433,7 @@ void GLPortal::End(bool usestencil) ViewAngle = savedAngle; GLRenderer->mViewActor=savedviewactor; in_area=savedviewarea; - r_showviewer = savedshowviewer; + if (camera != nullptr) camera->renderflags |= savedvisibility; GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); // This draws a valid z-buffer into the stencil's contents to ensure it @@ -665,7 +666,7 @@ void GLSkyboxPortal::DrawContents() SaveMapSection(); currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7); - GLRenderer->DrawScene(); + GLRenderer->DrawScene(DM_PORTAL); portal->mFlags &= ~PORTSF_INSKYBOX; inskybox = false; gl_RenderState.SetDepthClamp(oldclamp); @@ -755,7 +756,7 @@ void GLSectorStackPortal::DrawContents() SaveMapSection(); SetupCoverage(); ClearClipper(); - GLRenderer->DrawScene(); + GLRenderer->DrawScene(DM_PORTAL); RestoreMapSection(); if (origin->plane != -1) instack[origin->plane]--; @@ -791,14 +792,13 @@ void GLPlaneMirrorPortal::DrawContents() ViewPos.Z = 2 * planez - ViewPos.Z; GLRenderer->mViewActor = NULL; PlaneMirrorMode = origin->fC() < 0 ? -1 : 1; - r_showviewer = true; - + PlaneMirrorFlag++; GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); ClearClipper(); gl_RenderState.SetClipHeight(planez, PlaneMirrorMode < 0? -1.f : 1.f); - GLRenderer->DrawScene(); + GLRenderer->DrawScene(DM_PORTAL); gl_RenderState.SetClipHeight(0.f, 0.f); PlaneMirrorFlag--; PlaneMirrorMode=old_pm; @@ -955,7 +955,6 @@ void GLMirrorPortal::DrawContents() ViewAngle = linedef->Delta().Angle() * 2. - StartAngle; GLRenderer->mViewActor = NULL; - r_showviewer = true; MirrorFlag++; GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); @@ -971,7 +970,7 @@ void GLMirrorPortal::DrawContents() gl_RenderState.SetClipLine(linedef); gl_RenderState.EnableClipLine(true); - GLRenderer->DrawScene(); + GLRenderer->DrawScene(DM_PORTAL); gl_RenderState.EnableClipLine(false); MirrorFlag--; @@ -1009,7 +1008,7 @@ void GLLineToLinePortal::DrawContents() P_TranslatePortalZ(origin, ViewPos.Z); P_TranslatePortalXY(origin, ViewPath[0].X, ViewPath[0].Y); P_TranslatePortalXY(origin, ViewPath[1].X, ViewPath[1].Y); - if (!r_showviewer) + if (!r_showviewer && camera != nullptr && P_PointOnLineSidePrecise(ViewPath[0], glport->lines[0]->mDestination) != P_PointOnLineSidePrecise(ViewPath[1], glport->lines[0]->mDestination)) { double distp = (ViewPath[0] - ViewPath[1]).Length(); if (distp > EQUAL_EPSILON) @@ -1017,9 +1016,9 @@ void GLLineToLinePortal::DrawContents() double dist1 = (ViewPos - ViewPath[0]).Length(); double dist2 = (ViewPos - ViewPath[1]).Length(); - if (dist1 + dist2 > distp + 1) + if (dist1 + dist2 < distp + 1) { - r_showviewer = true; + camera->renderflags |= RF_INVISIBLE; } } } @@ -1044,7 +1043,7 @@ void GLLineToLinePortal::DrawContents() ClearClipper(); gl_RenderState.SetClipLine(glport->lines[0]->mDestination); gl_RenderState.EnableClipLine(true); - GLRenderer->DrawScene(); + GLRenderer->DrawScene(DM_PORTAL); gl_RenderState.EnableClipLine(false); RestoreMapSection(); } diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index c8afee2a6..9ebfe083b 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -105,7 +105,7 @@ private: DAngle savedAngle; AActor * savedviewactor; area_t savedviewarea; - bool savedshowviewer; + ActorRenderFlags savedvisibility; DVector3 savedviewpath[2]; GLPortal *PrevPortal; GLPortal *PrevClipPortal; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 44368775a..6352ca0cd 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -98,6 +98,7 @@ EXTERN_CVAR (Bool, r_deathcamera) extern int viewpitch; extern bool NoInterpolateView; +extern bool r_showviewer; DWORD gl_fixedcolormap; area_t in_area; @@ -501,16 +502,29 @@ void FGLRenderer::RenderTranslucent() //----------------------------------------------------------------------------- EXTERN_CVAR(Bool, gl_draw_sync) -void FGLRenderer::DrawScene(bool toscreen) +void FGLRenderer::DrawScene(int drawmode) { static int recursion=0; - CreateScene(); + if (camera != nullptr) + { + ActorRenderFlags savedflags = camera->renderflags; + if (drawmode != DM_PORTAL && !r_showviewer) + { + camera->renderflags |= RF_INVISIBLE; + } + CreateScene(); + camera->renderflags = savedflags; + } + else + { + CreateScene(); + } GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. // Up to this point in the main draw call no rendering is performed so we can wait // with swapping the render buffer until now. - if (!gl_draw_sync && toscreen) + if (!gl_draw_sync && drawmode == DM_MAINVIEW) { All.Unclock(); static_cast(screen)->Swap(); @@ -734,7 +748,7 @@ void FGLRenderer::ProcessScene(bool toscreen) int mapsection = R_PointInSubsector(ViewPos)->mapsection; memset(¤tmapsection[0], 0, currentmapsection.Size()); currentmapsection[mapsection>>3] |= 1 << (mapsection & 7); - DrawScene(toscreen); + DrawScene(toscreen ? DM_MAINVIEW : DM_OFFSCREEN); FDrawInfo::EndDrawInfo(); } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 447e6b78e..59e001416 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -81,7 +81,6 @@ CUSTOM_CVAR(Int, gl_fuzztype, 0, CVAR_ARCHIVE) if (self < 0 || self > 7) self = 0; } -extern bool r_showviewer; EXTERN_CVAR (Float, transsouls) extern TArray sprites; @@ -552,8 +551,6 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) { sector_t rs; sector_t * rendersector; - // don't draw the thing that's used as camera (for viewshifts during quakes!) - if (thing == GLRenderer->mViewActor || (thing == players[consoleplayer].camera && !r_showviewer)) return; // Don't waste time projecting sprites that are definitely not visible. if (thing == NULL || thing->sprite == 0 || !thing->IsVisibleToPlayer()) @@ -561,6 +558,12 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) return; } + if (thing->renderflags & RF_INVISIBLE || !thing->RenderStyle.IsVisible(thing->Alpha)) + { + if (!(thing->flags & MF_STEALTH) || !gl_fixedcolormap || !gl_enhanced_nightvision || thing == camera) + return; + } + int spritenum = thing->sprite; DVector2 sprscale = thing->Scale; if (thing->player != NULL) @@ -568,12 +571,6 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) P_CheckPlayerSprite(thing, spritenum, sprscale); } - if (thing->renderflags & RF_INVISIBLE || !thing->RenderStyle.IsVisible(thing->Alpha)) - { - if (!(thing->flags & MF_STEALTH) || !gl_fixedcolormap || !gl_enhanced_nightvision) - return; - } - // If this thing is in a map section that's not in view it can't possibly be visible if (!thruportal && !(currentmapsection[thing->subsector->mapsection >> 3] & (1 << (thing->subsector->mapsection & 7)))) return; From 3f905197d09e224db664264c9c8534985ca4c7df Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 19 Jun 2016 07:40:01 +0200 Subject: [PATCH 0676/1509] Moved vectorized drawers to their own files --- src/r_draw_rgba.cpp | 701 +++-------------------------------------- src/r_draw_rgba.h | 161 +++++++--- src/r_draw_rgba_sse.h | 491 +++++++++++++++++++++++++++++ src/r_drawt_rgba.cpp | 443 ++++---------------------- src/r_drawt_rgba_sse.h | 495 +++++++++++++++++++++++++++++ 5 files changed, 1212 insertions(+), 1079 deletions(-) create mode 100644 src/r_draw_rgba_sse.h create mode 100644 src/r_drawt_rgba_sse.h diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 271250855..28c5df2ac 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -48,10 +48,6 @@ #endif #include -#ifdef _MSC_VER -#pragma warning(disable: 4752) // warning C4752: found Intel(R) Advanced Vector Extensions; consider using /arch:AVX -#endif - extern int vlinebits; extern int mvlinebits; extern int tmvlinebits; @@ -62,8 +58,38 @@ extern float rw_lightstep; extern int wallshade; CVAR(Bool, r_multithreaded, true, 0) +CVAR(Bool, r_linearlight, false, 0) -//#define USE_AVX // Use AVX2 256 bit intrinsics (requires Haswell or newer) +#ifndef NO_SSE + +// Generate SSE drawers: +#define VecCommand(name) name##_SSE_Command +#define VEC_SHADE_SIMPLE_INIT SSE_SHADE_SIMPLE_INIT +#define VEC_SHADE_SIMPLE_INIT4 SSE_SHADE_SIMPLE_INIT4 +#define VEC_SHADE_SIMPLE SSE_SHADE_SIMPLE +#define VEC_SHADE_INIT SSE_SHADE_INIT +#define VEC_SHADE_INIT4 SSE_SHADE_INIT4 +#define VEC_SHADE SSE_SHADE +#include "r_draw_rgba_sse.h" + +// Generate AVX drawers: +#undef VecCommand +#undef VEC_SHADE_SIMPLE_INIT +#undef VEC_SHADE_SIMPLE_INIT4 +#undef VEC_SHADE_SIMPLE +#undef VEC_SHADE_INIT +#undef VEC_SHADE_INIT4 +#undef VEC_SHADE +#define VecCommand(name) name##_AVX_Command +#define VEC_SHADE_SIMPLE_INIT AVX_LINEAR_SHADE_SIMPLE_INIT +#define VEC_SHADE_SIMPLE_INIT4 AVX_LINEAR_SHADE_SIMPLE_INIT4 +#define VEC_SHADE_SIMPLE AVX_LINEAR_SHADE_SIMPLE +#define VEC_SHADE_INIT AVX_LINEAR_SHADE_INIT +#define VEC_SHADE_INIT4 AVX_LINEAR_SHADE_INIT4 +#define VEC_SHADE AVX_LINEAR_SHADE +#include "r_draw_rgba_sse.h" + +#endif ///////////////////////////////////////////////////////////////////////////// @@ -1495,7 +1521,6 @@ public: _shade_constants = ds_shade_constants; } -#ifdef NO_SSE void Execute(DrawerThread *thread) override { if (thread->line_skipped_by_thread(_y)) @@ -1560,401 +1585,6 @@ public: } while (--count); } } -#elif defined(USE_AVX) - void Execute(DrawerThread *thread) override - { - if (thread->line_skipped_by_thread(_y)) - return; - - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const uint32_t* source = _source; - int count; - int spot; - - xfrac = _xfrac; - yfrac = _yfrac; - - dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - - count = _x2 - _x1 + 1; - - xstep = _xstep; - ystep = _ystep; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - if (_xbits == 6 && _ybits == 6) - { - // 64x64 is the most common case by far, so special case it. - - int sse_count = count / 8; - count -= sse_count * 8; - - if (shade_constants.simple_shade) - { - AVX2_SHADE_SIMPLE_INIT(light); - - while (sse_count--) - { - uint32_t fg_pixels[8]; - for (int i = 0; i < 8; i++) - { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - fg_pixels[i] = source[spot]; - xfrac += xstep; - yfrac += ystep; - } - - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - __m256i fg = _mm256_loadu_si256((const __m256i*)fg_pixels); - AVX2_SHADE_SIMPLE(fg); - _mm256_storeu_si256((__m256i*)dest, fg); - - // Next step in u,v. - dest += 8; - } - } - else - { - AVX2_SHADE_INIT(light, shade_constants); - - while (sse_count--) - { - uint32_t fg_pixels[8]; - for (int i = 0; i < 8; i++) - { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - fg_pixels[i] = source[spot]; - xfrac += xstep; - yfrac += ystep; - } - - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - __m256i fg = _mm256_loadu_si256((const __m256i*)fg_pixels); - AVX2_SHADE(fg, shade_constants); - _mm256_storeu_si256((__m256i*)dest, fg); - - // Next step in u,v. - dest += 8; - } - } - - if (count == 0) - return; - - do - { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - - // Lookup pixel from flat texture tile - *dest++ = shade_bgra(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - else - { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; - - int sse_count = count / 8; - count -= sse_count * 8; - - if (shade_constants.simple_shade) - { - AVX2_SHADE_SIMPLE_INIT(light); - - while (sse_count--) - { - uint32_t fg_pixels[8]; - for (int i = 0; i < 8; i++) - { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - fg_pixels[i] = source[spot]; - xfrac += xstep; - yfrac += ystep; - } - - // Lookup pixel from flat texture tile - __m256i fg = _mm256_loadu_si256((const __m256i*)fg_pixels); - AVX2_SHADE_SIMPLE(fg); - _mm256_storeu_si256((__m256i*)dest, fg); - dest += 8; - } - } - else - { - AVX2_SHADE_INIT(light, shade_constants); - - while (sse_count--) - { - uint32_t fg_pixels[8]; - for (int i = 0; i < 8; i++) - { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - fg_pixels[i] = source[spot]; - xfrac += xstep; - yfrac += ystep; - } - - // Lookup pixel from flat texture tile - __m256i fg = _mm256_loadu_si256((const __m256i*)fg_pixels); - AVX2_SHADE_SIMPLE(fg); - _mm256_storeu_si256((__m256i*)dest, fg); - dest += 4; - } - } - - if (count == 0) - return; - - do - { - // Current texture index in u,v. - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - - // Lookup pixel from flat texture tile - *dest++ = shade_bgra(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - } -#else - void Execute(DrawerThread *thread) override - { - if (thread->line_skipped_by_thread(_y)) - return; - - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const uint32_t* source = _source; - int count; - int spot; - - xfrac = _xfrac; - yfrac = _yfrac; - - dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - - count = _x2 - _x1 + 1; - - xstep = _xstep; - ystep = _ystep; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - if (_xbits == 6 && _ybits == 6) - { - // 64x64 is the most common case by far, so special case it. - - int sse_count = count / 4; - count -= sse_count * 4; - - if (shade_constants.simple_shade) - { - SSE_SHADE_SIMPLE_INIT(light); - - while (sse_count--) - { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p0 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p1 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p2 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p3 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - SSE_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - - // Next step in u,v. - dest += 4; - } - } - else - { - SSE_SHADE_INIT(light, shade_constants); - - while (sse_count--) - { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p0 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p1 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p2 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p3 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - SSE_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - - // Next step in u,v. - dest += 4; - } - } - - if (count == 0) - return; - - do - { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - - // Lookup pixel from flat texture tile - *dest++ = shade_bgra(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - else - { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; - - int sse_count = count / 4; - count -= sse_count * 4; - - if (shade_constants.simple_shade) - { - SSE_SHADE_SIMPLE_INIT(light); - - while (sse_count--) - { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p0 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p1 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p2 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p3 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - // Lookup pixel from flat texture tile - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - SSE_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += 4; - } - } - else - { - SSE_SHADE_INIT(light, shade_constants); - - while (sse_count--) - { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p0 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p1 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p2 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p3 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - // Lookup pixel from flat texture tile - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - SSE_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - dest += 4; - } - } - - if (count == 0) - return; - - do - { - // Current texture index in u,v. - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - - // Lookup pixel from flat texture tile - *dest++ = shade_bgra(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - } -#endif }; class DrawSpanMaskedRGBACommand : public DrawerCommand @@ -2698,7 +2328,6 @@ public: } } -#ifdef NO_SSE void Execute(DrawerThread *thread) override { int count = thread->count_for_thread(_dest_y, _count); @@ -2735,165 +2364,6 @@ public: dest += pitch; } while (--count); } -#elif defined(USE_AVX) - void Execute(DrawerThread *thread) override - { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int bits = vlinebits; - int pitch = _pitch * thread->num_cores; - - uint32_t light0 = calc_light_multiplier(palookuplight[0]); - uint32_t light1 = calc_light_multiplier(palookuplight[1]); - uint32_t light2 = calc_light_multiplier(palookuplight[2]); - uint32_t light3 = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - - if (count & 1) - { - DWORD place; - dest[0] = shade_bgra(bufplce[0][(place = local_vplce[0]) >> bits], light0, shade_constants); local_vplce[0] = place + local_vince[0]; - dest[1] = shade_bgra(bufplce[1][(place = local_vplce[1]) >> bits], light1, shade_constants); local_vplce[1] = place + local_vince[1]; - dest[2] = shade_bgra(bufplce[2][(place = local_vplce[2]) >> bits], light2, shade_constants); local_vplce[2] = place + local_vince[2]; - dest[3] = shade_bgra(bufplce[3][(place = local_vplce[3]) >> bits], light3, shade_constants); local_vplce[3] = place + local_vince[3]; - dest += pitch; - } - count /= 2; - - // Assume all columns come from the same texture (which they do): - const uint32_t *base_addr = MIN(MIN(MIN(bufplce[0], bufplce[1]), bufplce[2]), bufplce[3]); - __m256i column_offsets = _mm256_set_epi32( - bufplce[3] - base_addr, bufplce[2] - base_addr, bufplce[1] - base_addr, bufplce[0] - base_addr, - bufplce[3] - base_addr, bufplce[2] - base_addr, bufplce[1] - base_addr, bufplce[0] - base_addr); - - __m256i place = _mm256_set_epi32( - local_vplce[3] + local_vince[3], local_vplce[2] + local_vince[2], local_vplce[1] + local_vince[1], local_vplce[0] + local_vince[0], - local_vplce[3], local_vplce[2], local_vplce[1], local_vplce[0]); - - __m256i step = _mm256_set_epi32( - local_vince[3], local_vince[2], local_vince[1], local_vince[0], - local_vince[3], local_vince[2], local_vince[1], local_vince[0]); - step = _mm256_add_epi32(step, step); - - if (shade_constants.simple_shade) - { - AVX2_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); - while (count--) - { - __m256i fg = _mm256_i32gather_epi32((const int *)base_addr, _mm256_add_epi32(column_offsets, _mm256_srli_epi32(place, bits)), 4); - place = _mm256_add_epi32(place, step); - AVX2_SHADE_SIMPLE(fg); - _mm256_storeu2_m128i((__m128i*)(dest + pitch), (__m128i*)dest, fg); - dest += pitch * 2; - } - } - else - { - AVX2_SHADE_INIT4(light3, light2, light1, light0, shade_constants); - while (count--) - { - __m256i fg = _mm256_i32gather_epi32((const int *)base_addr, _mm256_add_epi32(column_offsets, _mm256_srai_epi32(place, bits)), 4); - place = _mm256_add_epi32(place, step); - AVX2_SHADE(fg, shade_constants); - _mm256_storeu2_m128i((__m128i*)(dest + pitch), (__m128i*)dest, fg); - dest += pitch * 2; - } - } - } -#else - void Execute(DrawerThread *thread) override - { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int bits = vlinebits; - int pitch = _pitch * thread->num_cores; - - uint32_t light0 = calc_light_multiplier(palookuplight[0]); - uint32_t light1 = calc_light_multiplier(palookuplight[1]); - uint32_t light2 = calc_light_multiplier(palookuplight[2]); - uint32_t light3 = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - - if (shade_constants.simple_shade) - { - SSE_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); - do - { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; - - uint32_t p0 = bufplce[0][place0 >> bits]; - uint32_t p1 = bufplce[1][place1 >> bits]; - uint32_t p2 = bufplce[2][place2 >> bits]; - uint32_t p3 = bufplce[3][place3 >> bits]; - - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; - - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - SSE_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += pitch; - } while (--count); - } - else - { - SSE_SHADE_INIT4(light3, light2, light1, light0, shade_constants); - do - { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; - - uint32_t p0 = bufplce[0][place0 >> bits]; - uint32_t p1 = bufplce[1][place1 >> bits]; - uint32_t p2 = bufplce[2][place2 >> bits]; - uint32_t p3 = bufplce[3][place3 >> bits]; - - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; - - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - SSE_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - dest += pitch; - } while (--count); - } - } -#endif }; class Mvlinec1RGBACommand : public DrawerCommand @@ -2980,7 +2450,6 @@ public: } } -#ifdef NO_SSE void Execute(DrawerThread *thread) override { int count = thread->count_for_thread(_dest_y, _count); @@ -3018,93 +2487,6 @@ public: dest += pitch; } while (--count); } -#else - void Execute(DrawerThread *thread) override - { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - int bits = mvlinebits; - - uint32_t light0 = calc_light_multiplier(palookuplight[0]); - uint32_t light1 = calc_light_multiplier(palookuplight[1]); - uint32_t light2 = calc_light_multiplier(palookuplight[2]); - uint32_t light3 = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - - if (shade_constants.simple_shade) - { - SSE_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); - do - { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; - - uint32_t pix0 = bufplce[0][place0 >> bits]; - uint32_t pix1 = bufplce[1][place1 >> bits]; - uint32_t pix2 = bufplce[2][place2 >> bits]; - uint32_t pix3 = bufplce[3][place3 >> bits]; - - // movemask = !(pix == 0) - __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); - - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; - - __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - SSE_SHADE_SIMPLE(fg); - _mm_maskmoveu_si128(fg, movemask, (char*)dest); - dest += pitch; - } while (--count); - } - else - { - SSE_SHADE_INIT4(light3, light2, light1, light0, shade_constants); - do - { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; - - uint32_t pix0 = bufplce[0][place0 >> bits]; - uint32_t pix1 = bufplce[1][place1 >> bits]; - uint32_t pix2 = bufplce[2][place2 >> bits]; - uint32_t pix3 = bufplce[3][place3 >> bits]; - - // movemask = !(pix == 0) - __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); - - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; - - __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - SSE_SHADE(fg, shade_constants); - _mm_maskmoveu_si128(fg, movemask, (char*)dest); - dest += pitch; - } while (--count); - } - } -#endif }; class Tmvline1AddRGBACommand : public DrawerCommand @@ -4254,7 +3636,14 @@ void R_DrawRevSubClampTranslatedColumn_rgba() void R_DrawSpan_rgba() { +#ifdef NO_SSE DrawerCommandQueue::QueueCommand(); +#else + if (!r_linearlight) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); +#endif } void R_DrawSpanMasked_rgba() @@ -4304,7 +3693,14 @@ DWORD vlinec1_rgba() void vlinec4_rgba() { +#ifdef NO_SSE DrawerCommandQueue::QueueCommand(); +#else + if (!r_linearlight) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); +#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } @@ -4317,7 +3713,14 @@ DWORD mvlinec1_rgba() void mvlinec4_rgba() { +#ifdef NO_SSE DrawerCommandQueue::QueueCommand(); +#else + if (!r_linearlight) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); +#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 8f051b4cb..174478162 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -424,59 +424,124 @@ FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) return 0xff000000 | (red << 16) | (green << 8) | blue; } -// Calculate constants for a simple shade -#define AVX2_SHADE_SIMPLE_INIT(light) \ - __m256i mlight = _mm256_set_epi16(256, light, light, light, 256, light, light, light, 256, light, light, light, 256, light, light, light); +// Calculate constants for a simple shade with gamma correction +#define AVX_LINEAR_SHADE_SIMPLE_INIT(light) \ + __m256 mlight_hi = _mm256_set_ps(1.0f, light * (1.0f/256.0f), light * (1.0f/256.0f), light * (1.0f/256.0f), 1.0f, light * (1.0f/256.0f), light * (1.0f/256.0f), light * (1.0f/256.0f)); \ + mlight_hi = _mm256_mul_ps(mlight_hi, mlight_hi); \ + __m256 mlight_lo = mlight_hi; \ + __m256 mrcp_255 = _mm256_set1_ps(1.0f/255.0f); \ + __m256 m255 = _mm256_set1_ps(255.0f); -// Calculate constants for a simple shade with different light levels for each pixel -#define AVX2_SHADE_SIMPLE_INIT4(light3, light2, light1, light0) \ - __m256i mlight = _mm256_set_epi16(256, light3, light3, light3, 256, light2, light2, light2, 256, light1, light1, light1, 256, light0, light0, light0); +// Calculate constants for a simple shade with different light levels for each pixel and gamma correction +#define AVX_LINEAR_SHADE_SIMPLE_INIT4(light3, light2, light1, light0) \ + __m256 mlight_hi = _mm256_set_ps(1.0f, light1 * (1.0f/256.0f), light1 * (1.0f/256.0f), light1 * (1.0f/256.0f), 1.0f, light0 * (1.0f/256.0f), light0 * (1.0f/256.0f), light0 * (1.0f/256.0f)); \ + __m256 mlight_lo = _mm256_set_ps(1.0f, light3 * (1.0f/256.0f), light3 * (1.0f/256.0f), light3 * (1.0f/256.0f), 1.0f, light2 * (1.0f/256.0f), light2 * (1.0f/256.0f), light2 * (1.0f/256.0f)); \ + mlight_hi = _mm256_mul_ps(mlight_hi, mlight_hi); \ + mlight_lo = _mm256_mul_ps(mlight_lo, mlight_lo); \ + __m256 mrcp_255 = _mm256_set1_ps(1.0f/255.0f); \ + __m256 m255 = _mm256_set1_ps(255.0f); -// Simple shade 8 pixels -#define AVX2_SHADE_SIMPLE(fg) { \ - __m256i fg_hi = _mm256_unpackhi_epi8(fg, _mm256_setzero_si256()); \ - __m256i fg_lo = _mm256_unpacklo_epi8(fg, _mm256_setzero_si256()); \ - fg_hi = _mm256_mullo_epi16(fg_hi, mlight); \ - fg_hi = _mm256_srli_epi16(fg_hi, 8); \ - fg_lo = _mm256_mullo_epi16(fg_lo, mlight); \ - fg_lo = _mm256_srli_epi16(fg_lo, 8); \ - fg = _mm256_packus_epi16(fg_lo, fg_hi); \ +// Simple shade 4 pixels with gamma correction +#define AVX_LINEAR_SHADE_SIMPLE(fg) { \ + __m256i fg_16 = _mm256_set_m128i(_mm_unpackhi_epi8(fg, _mm_setzero_si128()), _mm_unpacklo_epi8(fg, _mm_setzero_si128())); \ + __m256 fg_hi = _mm256_cvtepi32_ps(_mm256_unpackhi_epi16(fg_16, _mm256_setzero_si256())); \ + __m256 fg_lo = _mm256_cvtepi32_ps(_mm256_unpacklo_epi16(fg_16, _mm256_setzero_si256())); \ + fg_hi = _mm256_mul_ps(fg_hi, mrcp_255); \ + fg_hi = _mm256_mul_ps(fg_hi, fg_hi); \ + fg_hi = _mm256_mul_ps(fg_hi, mlight_hi); \ + fg_hi = _mm256_sqrt_ps(fg_hi); \ + fg_hi = _mm256_mul_ps(fg_hi, m255); \ + fg_lo = _mm256_mul_ps(fg_lo, mrcp_255); \ + fg_lo = _mm256_mul_ps(fg_lo, fg_lo); \ + fg_lo = _mm256_mul_ps(fg_lo, mlight_lo); \ + fg_lo = _mm256_sqrt_ps(fg_lo); \ + fg_lo = _mm256_mul_ps(fg_lo, m255); \ + fg_16 = _mm256_packus_epi32(_mm256_cvtps_epi32(fg_lo), _mm256_cvtps_epi32(fg_hi)); \ + fg = _mm_packus_epi16(_mm256_extractf128_si256(fg_16, 0), _mm256_extractf128_si256(fg_16, 1)); \ } -// Calculate constants for a complex shade -#define AVX2_SHADE_INIT(light, shade_constants) \ - __m256i mlight = _mm256_set_epi16(256, light, light, light, 256, light, light, light, 256, light, light, light, 256, light, light, light); \ - __m256i color = _mm256_set_epi16( \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ - __m256i fade = _mm256_set_epi16( \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ - __m256i fade_amount = _mm256_mullo_epi16(fade, _mm256_subs_epu16(_mm256_set1_epi16(256), mlight)); \ - __m256i desaturate = _mm256_set1_epi16(shade_constants.desaturate); \ - __m256i inv_desaturate = _mm256_set1_epi16(256 - shade_constants.desaturate); +// Calculate constants for a complex shade with gamma correction +#define AVX_LINEAR_SHADE_INIT(light, shade_constants) \ + __m256 mlight_hi = _mm256_set_ps(1.0f, light * (1.0f/256.0f), light * (1.0f/256.0f), light * (1.0f/256.0f), 1.0f, light * (1.0f/256.0f), light * (1.0f/256.0f), light * (1.0f/256.0f)); \ + mlight_hi = _mm256_mul_ps(mlight_hi, mlight_hi); \ + __m256 mlight_lo = mlight_hi; \ + __m256 mrcp_255 = _mm256_set1_ps(1.0f/255.0f); \ + __m256 m255 = _mm256_set1_ps(255.0f); \ + __m256 color = _mm256_set_ps( \ + shade_constants.light_alpha * (1.0f/256.0f), shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f), \ + shade_constants.light_alpha * (1.0f/256.0f), shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f)); \ + __m256 fade = _mm256_set_ps( \ + shade_constants.fade_alpha * (1.0f/256.0f), shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f), \ + shade_constants.fade_alpha * (1.0f/256.0f), shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f)); \ + __m256 fade_amount_hi = _mm256_mul_ps(fade, _mm256_sub_ps(_mm256_set1_ps(1.0f), mlight_hi)); \ + __m256 fade_amount_lo = _mm256_mul_ps(fade, _mm256_sub_ps(_mm256_set1_ps(1.0f), mlight_lo)); \ + __m256 inv_desaturate = _mm256_set1_ps((256 - shade_constants.desaturate) * (1.0f/256.0f)); \ + __m128 ss_desaturate = _mm_set_ss(shade_constants.desaturate * (1.0f/256.0f)); \ + __m128 intensity_weight = _mm_set_ps(0.0f, 77.0f/256.0f, 143.0f/256.0f, 37.0f/256.0f); -// Calculate constants for a complex shade with different light levels for each pixel -#define AVX2_SHADE_INIT4(light3, light2, light1, light0, shade_constants) \ - __m256i mlight = _mm256_set_epi16(256, light3, light3, light3, 256, light2, light2, light2, 256, light1, light1, light1, 256, light0, light0, light0); \ - __m256i color = _mm256_set_epi16( \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ - __m256i fade = _mm256_set_epi16( \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ - __m256i fade_amount = _mm256_mullo_epi16(fade, _mm256_subs_epu16(_mm256_set1_epi16(256), mlight)); \ - __m256i desaturate = _mm256_set1_epi16(shade_constants.desaturate); \ - __m256i inv_desaturate = _mm256_set1_epi16(256 - shade_constants.desaturate); +// Calculate constants for a complex shade with different light levels for each pixel and gamma correction +#define AVX_LINEAR_SHADE_INIT4(light3, light2, light1, light0, shade_constants) \ + __m256 mlight_hi = _mm256_set_ps(1.0f, light1 * (1.0f/256.0f), light1 * (1.0f/256.0f), light1 * (1.0f/256.0f), 1.0f, light0 * (1.0f/256.0f), light0 * (1.0f/256.0f), light0 * (1.0f/256.0f)); \ + __m256 mlight_lo = _mm256_set_ps(1.0f, light3 * (1.0f/256.0f), light3 * (1.0f/256.0f), light3 * (1.0f/256.0f), 1.0f, light2 * (1.0f/256.0f), light2 * (1.0f/256.0f), light2 * (1.0f/256.0f)); \ + mlight_hi = _mm256_mul_ps(mlight_hi, mlight_hi); \ + mlight_lo = _mm256_mul_ps(mlight_lo, mlight_lo); \ + __m256 mrcp_255 = _mm256_set1_ps(1.0f/255.0f); \ + __m256 m255 = _mm256_set1_ps(255.0f); \ + __m256 color = _mm256_set_ps( \ + shade_constants.light_alpha * (1.0f/256.0f), shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f), \ + shade_constants.light_alpha * (1.0f/256.0f), shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f)); \ + __m256 fade = _mm256_set_ps( \ + shade_constants.fade_alpha * (1.0f/256.0f), shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f), \ + shade_constants.fade_alpha * (1.0f/256.0f), shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f)); \ + __m256 fade_amount_hi = _mm256_mul_ps(fade, _mm256_sub_ps(_mm256_set1_ps(1.0f), mlight_hi)); \ + __m256 fade_amount_lo = _mm256_mul_ps(fade, _mm256_sub_ps(_mm256_set1_ps(1.0f), mlight_lo)); \ + __m256 inv_desaturate = _mm256_set1_ps((256 - shade_constants.desaturate) * (1.0f/256.0f)); \ + __m128 ss_desaturate = _mm_set_ss(shade_constants.desaturate * (1.0f/256.0f)); \ + __m128 intensity_weight = _mm_set_ps(0.0f, 77.0f/256.0f, 143.0f/256.0f, 37.0f/256.0f); +// Complex shade 4 pixels with gamma correction +#define AVX_LINEAR_SHADE(fg, shade_constants) { \ + __m256i fg_16 = _mm256_set_m128i(_mm_unpackhi_epi8(fg, _mm_setzero_si128()), _mm_unpacklo_epi8(fg, _mm_setzero_si128())); \ + __m256 fg_hi = _mm256_cvtepi32_ps(_mm256_unpackhi_epi16(fg_16, _mm256_setzero_si256())); \ + __m256 fg_lo = _mm256_cvtepi32_ps(_mm256_unpacklo_epi16(fg_16, _mm256_setzero_si256())); \ + fg_hi = _mm256_mul_ps(fg_hi, mrcp_255); \ + fg_hi = _mm256_mul_ps(fg_hi, fg_hi); \ + fg_lo = _mm256_mul_ps(fg_lo, mrcp_255); \ + fg_lo = _mm256_mul_ps(fg_lo, fg_lo); \ + \ + __m128 intensity_hi0 = _mm_mul_ps(_mm256_extractf128_ps(fg_hi, 0), intensity_weight); \ + __m128 intensity_hi1 = _mm_mul_ps(_mm256_extractf128_ps(fg_hi, 1), intensity_weight); \ + intensity_hi0 = _mm_mul_ss(_mm_add_ss(_mm_add_ss(intensity_hi0, _mm_shuffle_ps(intensity_hi0, intensity_hi0, _MM_SHUFFLE(1,1,1,1))), _mm_shuffle_ps(intensity_hi0, intensity_hi0, _MM_SHUFFLE(2,2,2,2))), ss_desaturate); \ + intensity_hi0 = _mm_shuffle_ps(intensity_hi0, intensity_hi0, _MM_SHUFFLE(0,0,0,0)); \ + intensity_hi1 = _mm_mul_ss(_mm_add_ss(_mm_add_ss(intensity_hi1, _mm_shuffle_ps(intensity_hi1, intensity_hi1, _MM_SHUFFLE(1,1,1,1))), _mm_shuffle_ps(intensity_hi1, intensity_hi1, _MM_SHUFFLE(2,2,2,2))), ss_desaturate); \ + intensity_hi1 = _mm_shuffle_ps(intensity_hi1, intensity_hi1, _MM_SHUFFLE(0,0,0,0)); \ + __m256 intensity_hi = _mm256_set_m128(intensity_hi1, intensity_hi0); \ + \ + fg_hi = _mm256_add_ps(_mm256_mul_ps(fg_hi, inv_desaturate), intensity_hi); \ + fg_hi = _mm256_add_ps(_mm256_mul_ps(fg_hi, mlight_hi), fade_amount_hi); \ + fg_hi = _mm256_mul_ps(fg_hi, color); \ + \ + __m128 intensity_lo0 = _mm_mul_ps(_mm256_extractf128_ps(fg_lo, 0), intensity_weight); \ + __m128 intensity_lo1 = _mm_mul_ps(_mm256_extractf128_ps(fg_lo, 1), intensity_weight); \ + intensity_lo0 = _mm_mul_ss(_mm_add_ss(_mm_add_ss(intensity_lo0, _mm_shuffle_ps(intensity_lo0, intensity_lo0, _MM_SHUFFLE(1,1,1,1))), _mm_shuffle_ps(intensity_lo0, intensity_lo0, _MM_SHUFFLE(2,2,2,2))), ss_desaturate); \ + intensity_lo0 = _mm_shuffle_ps(intensity_lo0, intensity_lo0, _MM_SHUFFLE(0,0,0,0)); \ + intensity_lo1 = _mm_mul_ss(_mm_add_ss(_mm_add_ss(intensity_lo1, _mm_shuffle_ps(intensity_lo1, intensity_lo1, _MM_SHUFFLE(1,1,1,1))), _mm_shuffle_ps(intensity_lo1, intensity_lo1, _MM_SHUFFLE(2,2,2,2))), ss_desaturate); \ + intensity_lo1 = _mm_shuffle_ps(intensity_lo1, intensity_lo1, _MM_SHUFFLE(0,0,0,0)); \ + __m256 intensity_lo = _mm256_set_m128(intensity_lo1, intensity_lo0); \ + \ + fg_lo = _mm256_add_ps(_mm256_mul_ps(fg_lo, inv_desaturate), intensity_lo); \ + fg_lo = _mm256_add_ps(_mm256_mul_ps(fg_lo, mlight_lo), fade_amount_lo); \ + fg_lo = _mm256_mul_ps(fg_lo, color); \ + \ + fg_hi = _mm256_sqrt_ps(fg_hi); \ + fg_hi = _mm256_mul_ps(fg_hi, m255); \ + fg_lo = _mm256_sqrt_ps(fg_lo); \ + fg_lo = _mm256_mul_ps(fg_lo, m255); \ + fg_16 = _mm256_packus_epi32(_mm256_cvtps_epi32(fg_lo), _mm256_cvtps_epi32(fg_hi)); \ + fg = _mm_packus_epi16(_mm256_extractf128_si256(fg_16, 0), _mm256_extractf128_si256(fg_16, 1)); \ +} + +/* // Complex shade 8 pixels #define AVX2_SHADE(fg, shade_constants) { \ __m256i fg_hi = _mm256_unpackhi_epi8(fg, _mm256_setzero_si256()); \ @@ -499,7 +564,7 @@ FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) \ fg = _mm256_packus_epi16(fg_lo, fg_hi); \ } - +*/ diff --git a/src/r_draw_rgba_sse.h b/src/r_draw_rgba_sse.h new file mode 100644 index 000000000..14ebbbb41 --- /dev/null +++ b/src/r_draw_rgba_sse.h @@ -0,0 +1,491 @@ +// +// SSE/AVX intrinsics based drawers for the r_draw family of drawers. +// +// Note: This header file is intentionally not guarded by a __R_DRAW_RGBA_SSE__ define. +// It is because the code is nearly identical for SSE vs AVX. The file is included +// multiple times by r_draw_rgba.cpp with different defines that changes the class +// names outputted and the type of intrinsics used. + +#ifdef _MSC_VER +#pragma warning(disable: 4752) // warning C4752: found Intel(R) Advanced Vector Extensions; consider using /arch:AVX +#endif + +class VecCommand(DrawSpanRGBA) : public DrawerCommand +{ + const uint32_t * RESTRICT _source; + fixed_t _xfrac; + fixed_t _yfrac; + fixed_t _xstep; + fixed_t _ystep; + int _x1; + int _x2; + int _y; + int _xbits; + int _ybits; + BYTE * RESTRICT _destorg; + fixed_t _light; + ShadeConstants _shade_constants; + +public: + VecCommand(DrawSpanRGBA)() + { + _source = (const uint32_t*)ds_source; + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _xstep = ds_xstep; + _ystep = ds_ystep; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _xbits = ds_xbits; + _ybits = ds_ybits; + _destorg = dc_destorg; + _light = ds_light; + _shade_constants = ds_shade_constants; + } + + void Execute(DrawerThread *thread) override + { + if (thread->line_skipped_by_thread(_y)) + return; + + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + uint32_t* dest; + const uint32_t* source = _source; + int count; + int spot; + + xfrac = _xfrac; + yfrac = _yfrac; + + dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; + + count = _x2 - _x1 + 1; + + xstep = _xstep; + ystep = _ystep; + + uint32_t light = calc_light_multiplier(_light); + ShadeConstants shade_constants = _shade_constants; + + if (_xbits == 6 && _ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + + int sse_count = count / 4; + count -= sse_count * 4; + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT(light); + + while (sse_count--) + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p0 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p1 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p2 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p3 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); + VEC_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + + // Next step in u,v. + dest += 4; + } + } + else + { + VEC_SHADE_INIT(light, shade_constants); + + while (sse_count--) + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p0 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p1 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p2 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p3 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); + VEC_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + + // Next step in u,v. + dest += 4; + } + } + + if (count == 0) + return; + + do + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + + // Lookup pixel from flat texture tile + *dest++ = shade_bgra(source[spot], light, shade_constants); + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + + int sse_count = count / 4; + count -= sse_count * 4; + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT(light); + + while (sse_count--) + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p0 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p1 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p2 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p3 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + // Lookup pixel from flat texture tile + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); + VEC_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += 4; + } + } + else + { + VEC_SHADE_INIT(light, shade_constants); + + while (sse_count--) + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p0 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p1 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p2 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p3 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + // Lookup pixel from flat texture tile + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); + VEC_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + dest += 4; + } + } + + if (count == 0) + return; + + do + { + // Current texture index in u,v. + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + + // Lookup pixel from flat texture tile + *dest++ = shade_bgra(source[spot], light, shade_constants); + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + } +}; + +class VecCommand(Vlinec4RGBA) : public DrawerCommand +{ + BYTE * RESTRICT _dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; + int vlinebits; + fixed_t palookuplight[4]; + DWORD vplce[4]; + DWORD vince[4]; + const uint32 * RESTRICT bufplce[4]; + +public: + VecCommand(Vlinec4RGBA)() + { + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + vlinebits = ::vlinebits; + for (int i = 0; i < 4; i++) + { + palookuplight[i] = ::palookuplight[i]; + vplce[i] = ::vplce[i]; + vince[i] = ::vince[i]; + bufplce[i] = (const uint32 *)::bufplce[i]; + } + } + + void Execute(DrawerThread *thread) override + { + int count = thread->count_for_thread(_dest_y, _count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int bits = vlinebits; + int pitch = _pitch * thread->num_cores; + + uint32_t light0 = calc_light_multiplier(palookuplight[0]); + uint32_t light1 = calc_light_multiplier(palookuplight[1]); + uint32_t light2 = calc_light_multiplier(palookuplight[2]); + uint32_t light3 = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = _shade_constants; + + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; + + uint32_t p0 = bufplce[0][place0 >> bits]; + uint32_t p1 = bufplce[1][place1 >> bits]; + uint32_t p2 = bufplce[2][place2 >> bits]; + uint32_t p3 = bufplce[3][place3 >> bits]; + + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; + + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); + VEC_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += pitch; + } while (--count); + } + else + { + VEC_SHADE_INIT4(light3, light2, light1, light0, shade_constants); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; + + uint32_t p0 = bufplce[0][place0 >> bits]; + uint32_t p1 = bufplce[1][place1 >> bits]; + uint32_t p2 = bufplce[2][place2 >> bits]; + uint32_t p3 = bufplce[3][place3 >> bits]; + + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; + + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); + VEC_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + dest += pitch; + } while (--count); + } + } +}; + +class VecCommand(Mvlinec4RGBA) : public DrawerCommand +{ + BYTE * RESTRICT _dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; + int mvlinebits; + fixed_t palookuplight[4]; + DWORD vplce[4]; + DWORD vince[4]; + const uint32 * RESTRICT bufplce[4]; + +public: + VecCommand(Mvlinec4RGBA)() + { + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + mvlinebits = ::mvlinebits; + for (int i = 0; i < 4; i++) + { + palookuplight[i] = ::palookuplight[i]; + vplce[i] = ::vplce[i]; + vince[i] = ::vince[i]; + bufplce[i] = (const uint32 *)::bufplce[i]; + } + } + + void Execute(DrawerThread *thread) override + { + int count = thread->count_for_thread(_dest_y, _count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; + int bits = mvlinebits; + + uint32_t light0 = calc_light_multiplier(palookuplight[0]); + uint32_t light1 = calc_light_multiplier(palookuplight[1]); + uint32_t light2 = calc_light_multiplier(palookuplight[2]); + uint32_t light3 = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = _shade_constants; + + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; + + uint32_t pix0 = bufplce[0][place0 >> bits]; + uint32_t pix1 = bufplce[1][place1 >> bits]; + uint32_t pix2 = bufplce[2][place2 >> bits]; + uint32_t pix3 = bufplce[3][place3 >> bits]; + + // movemask = !(pix == 0) + __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); + + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; + + __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); + VEC_SHADE_SIMPLE(fg); + _mm_maskmoveu_si128(fg, movemask, (char*)dest); + dest += pitch; + } while (--count); + } + else + { + VEC_SHADE_INIT4(light3, light2, light1, light0, shade_constants); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; + + uint32_t pix0 = bufplce[0][place0 >> bits]; + uint32_t pix1 = bufplce[1][place1 >> bits]; + uint32_t pix2 = bufplce[2][place2 >> bits]; + uint32_t pix3 = bufplce[3][place3 >> bits]; + + // movemask = !(pix == 0) + __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); + + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; + + __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); + VEC_SHADE(fg, shade_constants); + _mm_maskmoveu_si128(fg, movemask, (char*)dest); + dest += pitch; + } while (--count); + } + } +}; diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 269dd9d9d..4da963430 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -51,6 +51,39 @@ extern unsigned int dc_tspans[4][MAXHEIGHT]; extern unsigned int *dc_ctspan[4]; extern unsigned int *horizspan[4]; +EXTERN_CVAR(Bool, r_linearlight) + +#ifndef NO_SSE + +// Generate SSE drawers: +#define VecCommand(name) name##_SSE_Command +#define VEC_SHADE_SIMPLE_INIT SSE_SHADE_SIMPLE_INIT +#define VEC_SHADE_SIMPLE_INIT4 SSE_SHADE_SIMPLE_INIT4 +#define VEC_SHADE_SIMPLE SSE_SHADE_SIMPLE +#define VEC_SHADE_INIT SSE_SHADE_INIT +#define VEC_SHADE_INIT4 SSE_SHADE_INIT4 +#define VEC_SHADE SSE_SHADE +#include "r_drawt_rgba_sse.h" + +// Generate AVX drawers: +#undef VecCommand +#undef VEC_SHADE_SIMPLE_INIT +#undef VEC_SHADE_SIMPLE_INIT4 +#undef VEC_SHADE_SIMPLE +#undef VEC_SHADE_INIT +#undef VEC_SHADE_INIT4 +#undef VEC_SHADE +#define VecCommand(name) name##_AVX_Command +#define VEC_SHADE_SIMPLE_INIT AVX_LINEAR_SHADE_SIMPLE_INIT +#define VEC_SHADE_SIMPLE_INIT4 AVX_LINEAR_SHADE_SIMPLE_INIT4 +#define VEC_SHADE_SIMPLE AVX_LINEAR_SHADE_SIMPLE +#define VEC_SHADE_INIT AVX_LINEAR_SHADE_INIT +#define VEC_SHADE_INIT4 AVX_LINEAR_SHADE_INIT4 +#define VEC_SHADE AVX_LINEAR_SHADE +#include "r_drawt_rgba_sse.h" + +#endif + ///////////////////////////////////////////////////////////////////////////// class RtCopy1colRGBACommand : public DrawerCommand @@ -206,7 +239,6 @@ public: _colormap = dc_colormap; } -#ifdef NO_SSE void Execute(DrawerThread *thread) override { uint32_t *source; @@ -253,132 +285,6 @@ public: dest += pitch * 2; } while (--count); } -#else - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - ShadeConstants shade_constants = _shade_constants; - uint32_t light = calc_light_multiplier(_light); - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = thread->num_cores * 4; - - BYTE *colormap = _colormap; - - if (shade_constants.simple_shade) - { - SSE_SHADE_SIMPLE_INIT(light); - - if (count & 1) { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - - source += sincr; - dest += pitch; - } - if (!(count >>= 1)) - return; - - do { - // shade_pal_index 0-3 - { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - } - - // shade_pal_index 4-7 (pitch) - { - uint32_t p0 = colormap[source[sincr]]; - uint32_t p1 = colormap[source[sincr + 1]]; - uint32_t p2 = colormap[source[sincr + 2]]; - uint32_t p3 = colormap[source[sincr + 3]]; - - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)(dest + pitch), fg); - } - - source += sincr * 2; - dest += pitch * 2; - } while (--count); - } - else - { - SSE_SHADE_INIT(light, shade_constants); - - if (count & 1) { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - - source += sincr; - dest += pitch; - } - if (!(count >>= 1)) - return; - - do { - // shade_pal_index 0-3 - { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - } - - // shade_pal_index 4-7 (pitch) - { - uint32_t p0 = colormap[source[sincr]]; - uint32_t p1 = colormap[source[sincr + 1]]; - uint32_t p2 = colormap[source[sincr + 2]]; - uint32_t p3 = colormap[source[sincr + 3]]; - - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)(dest + pitch), fg); - } - - source += sincr * 2; - dest += pitch * 2; - } while (--count); - } - } -#endif }; class RtTranslate1colRGBACommand : public DrawerCommand @@ -607,7 +513,6 @@ public: _destalpha = dc_destalpha; } -#ifdef NO_SSE void Execute(DrawerThread *thread) override { uint32_t *source; @@ -655,107 +560,6 @@ public: dest += pitch; } while (--count); } -#else - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t light = calc_light_multiplier(_light); - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - BYTE *colormap = _colormap; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - ShadeConstants shade_constants = _shade_constants; - - if (shade_constants.simple_shade) - { - SSE_SHADE_SIMPLE_INIT(light); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE_SIMPLE(fg); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += sincr; - dest += pitch; - } while (--count); - } - else - { - SSE_SHADE_INIT(light, shade_constants); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE(fg, shade_constants); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += sincr; - dest += pitch; - } while (--count); - } - } -#endif }; class RtShaded1colRGBACommand : public DrawerCommand @@ -853,7 +657,6 @@ public: _light = dc_light; } -#ifdef NO_SSE void Execute(DrawerThread *thread) override { BYTE *colormap; @@ -898,57 +701,6 @@ public: dest += pitch; } while (--count); } -#else - void Execute(DrawerThread *thread) override - { - BYTE *colormap; - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - colormap = _colormap; - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(shade_pal_index_simple(_color, calc_light_multiplier(_light))), _mm_setzero_si128()); - __m128i alpha_one = _mm_set1_epi16(64); - - do { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - __m128i alpha_hi = _mm_set_epi16(64, p3, p3, p3, 64, p2, p2, p2); - __m128i alpha_lo = _mm_set_epi16(64, p1, p1, p1, 64, p0, p0, p0); - __m128i inv_alpha_hi = _mm_subs_epu16(alpha_one, alpha_hi); - __m128i inv_alpha_lo = _mm_subs_epu16(alpha_one, alpha_lo); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * alpha + bg_red * inv_alpha) / 64: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg, alpha_hi), _mm_mullo_epi16(bg_hi, inv_alpha_hi)), 6); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg, alpha_lo), _mm_mullo_epi16(bg_lo, inv_alpha_lo)), 6); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += sincr; - dest += pitch; - } while (--count); - } -#endif }; class RtAddClamp1colRGBACommand : public DrawerCommand @@ -1051,7 +803,6 @@ public: _shade_constants = dc_shade_constants; } -#ifdef NO_SSE void Execute(DrawerThread *thread) override { uint32_t *source; @@ -1097,106 +848,6 @@ public: dest += pitch; } while (--count); } -#else - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t light = calc_light_multiplier(_light); - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - ShadeConstants shade_constants = _shade_constants; - - if (shade_constants.simple_shade) - { - SSE_SHADE_SIMPLE_INIT(light); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE_SIMPLE(fg); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += sincr; - dest += pitch; - } while (--count); - } - else - { - SSE_SHADE_INIT(light, shade_constants); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - SSE_SHADE(fg, shade_constants); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += sincr; - dest += pitch; - } while (--count); - } - } -#endif }; class RtSubClamp1colRGBACommand : public DrawerCommand @@ -1657,7 +1308,14 @@ void rt_map1col_rgba (int hx, int sx, int yl, int yh) // Maps all four spans to the screen starting at sx. void rt_map4cols_rgba (int sx, int yl, int yh) { +#ifdef NO_SSE DrawerCommandQueue::QueueCommand(sx, yl, yh); +#else + if (!r_linearlight) + DrawerCommandQueue::QueueCommand(sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(sx, yl, yh); +#endif } void rt_Translate1col_rgba(const BYTE *translation, int hx, int yl, int yh) @@ -1693,7 +1351,14 @@ void rt_add1col_rgba (int hx, int sx, int yl, int yh) // Adds all four spans to the screen starting at sx without clamping. void rt_add4cols_rgba (int sx, int yl, int yh) { +#ifdef NO_SSE DrawerCommandQueue::QueueCommand(sx, yl, yh); +#else + if (!r_linearlight) + DrawerCommandQueue::QueueCommand(sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(sx, yl, yh); +#endif } // Translates and adds one span at hx to the screen at sx without clamping. @@ -1719,7 +1384,14 @@ void rt_shaded1col_rgba (int hx, int sx, int yl, int yh) // Shades all four spans to the screen starting at sx. void rt_shaded4cols_rgba (int sx, int yl, int yh) { +#ifdef NO_SSE DrawerCommandQueue::QueueCommand(sx, yl, yh); +#else + if (!r_linearlight) + DrawerCommandQueue::QueueCommand(sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(sx, yl, yh); +#endif } // Adds one span at hx to the screen at sx with clamping. @@ -1731,7 +1403,14 @@ void rt_addclamp1col_rgba (int hx, int sx, int yl, int yh) // Adds all four spans to the screen starting at sx with clamping. void rt_addclamp4cols_rgba (int sx, int yl, int yh) { +#ifdef NO_SSE DrawerCommandQueue::QueueCommand(sx, yl, yh); +#else + if (!r_linearlight) + DrawerCommandQueue::QueueCommand(sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(sx, yl, yh); +#endif } // Translates and adds one span at hx to the screen at sx with clamping. diff --git a/src/r_drawt_rgba_sse.h b/src/r_drawt_rgba_sse.h new file mode 100644 index 000000000..5b8ae8081 --- /dev/null +++ b/src/r_drawt_rgba_sse.h @@ -0,0 +1,495 @@ +// +// SSE/AVX intrinsics based drawers for the r_drawt family of drawers. +// +// Note: This header file is intentionally not guarded by a __R_DRAWT_RGBA_SSE__ define. +// It is because the code is nearly identical for SSE vs AVX. The file is included +// multiple times by r_drawt_rgba.cpp with different defines that changes the class +// names outputted and the type of intrinsics used. + +#ifdef _MSC_VER +#pragma warning(disable: 4752) // warning C4752: found Intel(R) Advanced Vector Extensions; consider using /arch:AVX +#endif + +class VecCommand(RtMap4colsRGBA) : public DrawerCommand +{ + int sx; + int yl; + int yh; + fixed_t _light; + ShadeConstants _shade_constants; + BYTE * RESTRICT _destorg; + int _pitch; + BYTE * RESTRICT _colormap; + +public: + VecCommand(RtMap4colsRGBA)(int sx, int yl, int yh) + { + this->sx = sx; + this->yl = yl; + this->yh = yh; + + _light = dc_light; + _shade_constants = dc_shade_constants; + _destorg = dc_destorg; + _pitch = dc_pitch; + _colormap = dc_colormap; + } + + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + int sincr; + + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) + return; + + ShadeConstants shade_constants = _shade_constants; + uint32_t light = calc_light_multiplier(_light); + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = _pitch * thread->num_cores; + sincr = thread->num_cores * 4; + + BYTE *colormap = _colormap; + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT(light); + + if (count & 1) { + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + VEC_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + + source += sincr; + dest += pitch; + } + if (!(count >>= 1)) + return; + + do { + // shade_pal_index 0-3 + { + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + VEC_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + } + + // shade_pal_index 4-7 (pitch) + { + uint32_t p0 = colormap[source[sincr]]; + uint32_t p1 = colormap[source[sincr + 1]]; + uint32_t p2 = colormap[source[sincr + 2]]; + uint32_t p3 = colormap[source[sincr + 3]]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + VEC_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)(dest + pitch), fg); + } + + source += sincr * 2; + dest += pitch * 2; + } while (--count); + } + else + { + VEC_SHADE_INIT(light, shade_constants); + + if (count & 1) { + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + VEC_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + + source += sincr; + dest += pitch; + } + if (!(count >>= 1)) + return; + + do { + // shade_pal_index 0-3 + { + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + VEC_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + } + + // shade_pal_index 4-7 (pitch) + { + uint32_t p0 = colormap[source[sincr]]; + uint32_t p1 = colormap[source[sincr + 1]]; + uint32_t p2 = colormap[source[sincr + 2]]; + uint32_t p3 = colormap[source[sincr + 3]]; + + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + VEC_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)(dest + pitch), fg); + } + + source += sincr * 2; + dest += pitch * 2; + } while (--count); + } + } +}; + +class VecCommand(RtAdd4colsRGBA) : public DrawerCommand +{ + int sx; + int yl; + int yh; + BYTE * RESTRICT _destorg; + int _pitch; + fixed_t _light; + ShadeConstants _shade_constants; + BYTE * RESTRICT _colormap; + fixed_t _srcalpha; + fixed_t _destalpha; + +public: + VecCommand(RtAdd4colsRGBA)(int sx, int yl, int yh) + { + this->sx = sx; + this->yl = yl; + this->yh = yh; + + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _shade_constants = dc_shade_constants; + _colormap = dc_colormap; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + } + + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + int sincr; + + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) + return; + + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = _pitch * thread->num_cores; + sincr = 4 * thread->num_cores; + + uint32_t light = calc_light_multiplier(_light); + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + BYTE *colormap = _colormap; + + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); + + ShadeConstants shade_constants = _shade_constants; + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT(light); + + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + VEC_SHADE_SIMPLE(fg); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += sincr; + dest += pitch; + } while (--count); + } + else + { + VEC_SHADE_INIT(light, shade_constants); + + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + VEC_SHADE(fg, shade_constants); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += sincr; + dest += pitch; + } while (--count); + } + } +}; + +class VecCommand(RtShaded4colsRGBA) : public DrawerCommand +{ + int sx; + int yl; + int yh; + lighttable_t * RESTRICT _colormap; + int _color; + BYTE * RESTRICT _destorg; + int _pitch; + fixed_t _light; + +public: + VecCommand(RtShaded4colsRGBA)(int sx, int yl, int yh) + { + this->sx = sx; + this->yl = yl; + this->yh = yh; + + _colormap = dc_colormap; + _color = dc_color; + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + } + + void Execute(DrawerThread *thread) override + { + BYTE *colormap; + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + int sincr; + + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) + return; + + colormap = _colormap; + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = _pitch * thread->num_cores; + sincr = 4 * thread->num_cores; + + __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(shade_pal_index_simple(_color, calc_light_multiplier(_light))), _mm_setzero_si128()); + __m128i alpha_one = _mm_set1_epi16(64); + + do { + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; + + __m128i alpha_hi = _mm_set_epi16(64, p3, p3, p3, 64, p2, p2, p2); + __m128i alpha_lo = _mm_set_epi16(64, p1, p1, p1, 64, p0, p0, p0); + __m128i inv_alpha_hi = _mm_subs_epu16(alpha_one, alpha_hi); + __m128i inv_alpha_lo = _mm_subs_epu16(alpha_one, alpha_lo); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * alpha + bg_red * inv_alpha) / 64: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg, alpha_hi), _mm_mullo_epi16(bg_hi, inv_alpha_hi)), 6); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg, alpha_lo), _mm_mullo_epi16(bg_lo, inv_alpha_lo)), 6); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += sincr; + dest += pitch; + } while (--count); + } +}; + +class VecCommand(RtAddClamp4colsRGBA) : public DrawerCommand +{ + int sx; + int yl; + int yh; + BYTE * RESTRICT _destorg; + int _pitch; + fixed_t _light; + fixed_t _srcalpha; + fixed_t _destalpha; + ShadeConstants _shade_constants; + +public: + VecCommand(RtAddClamp4colsRGBA)(int sx, int yl, int yh) + { + this->sx = sx; + this->yl = yl; + this->yh = yh; + + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _shade_constants = dc_shade_constants; + } + + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + int sincr; + + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) + return; + + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = _pitch * thread->num_cores; + sincr = 4 * thread->num_cores; + + uint32_t light = calc_light_multiplier(_light); + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); + + ShadeConstants shade_constants = _shade_constants; + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT(light); + + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + VEC_SHADE_SIMPLE(fg); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += sincr; + dest += pitch; + } while (--count); + } + else + { + VEC_SHADE_INIT(light, shade_constants); + + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + VEC_SHADE(fg, shade_constants); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += sincr; + dest += pitch; + } while (--count); + } + } +}; From 2813a22740342c768e3d76e849b7a19944eea9d6 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 19 Jun 2016 11:19:31 +0300 Subject: [PATCH 0677/1509] Fixed inconsistent state of lights in compatibility renderer --- src/gl/compatibility/gl_20.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 2224dd9f4..957a73f4a 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -456,7 +456,7 @@ bool gl_SetupLightTexture() { if (GLRenderer->gllight == nullptr) return false; FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight, false); - pat->Bind(CLAMP_XY_NOMIP, 0); + gl_RenderState.SetMaterial(pat, CLAMP_XY_NOMIP, 0, -1, false); return true; } From 38aba81dcc816ce9bb0888f95b94f73714771f67 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 19 Jun 2016 23:11:41 +0200 Subject: [PATCH 0678/1509] Added more SSE drawers --- src/r_draw_rgba.cpp | 313 ++++++++++++---------- src/r_draw_rgba.h | 58 +++- src/r_draw_rgba_sse.h | 583 ++++++++++++++++++++++++++++++++++++++++- src/r_drawt_rgba.cpp | 14 + src/r_drawt_rgba_sse.h | 252 ++++++++++++++++++ 5 files changed, 1072 insertions(+), 148 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 28c5df2ac..96232ab0c 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -2411,10 +2411,7 @@ public: do { uint32_t pix = source[frac >> bits]; - if (pix != 0) - { - *dest = shade_bgra(pix, light, shade_constants); - } + *dest = alpha_blend(shade_bgra(pix, light, shade_constants), *dest); frac += fracstep; dest += pitch; } while (--count); @@ -2480,10 +2477,10 @@ public: do { uint32_t pix; - pix = bufplce[0][(place = local_vplce[0]) >> bits]; if (pix) dest[0] = shade_bgra(pix, light0, shade_constants); local_vplce[0] = place + local_vince[0]; - pix = bufplce[1][(place = local_vplce[1]) >> bits]; if (pix) dest[1] = shade_bgra(pix, light1, shade_constants); local_vplce[1] = place + local_vince[1]; - pix = bufplce[2][(place = local_vplce[2]) >> bits]; if (pix) dest[2] = shade_bgra(pix, light2, shade_constants); local_vplce[2] = place + local_vince[2]; - pix = bufplce[3][(place = local_vplce[3]) >> bits]; if (pix) dest[3] = shade_bgra(pix, light3, shade_constants); local_vplce[3] = place + local_vince[3]; + pix = bufplce[0][(place = local_vplce[0]) >> bits]; dest[0] = alpha_blend(shade_bgra(pix, light0, shade_constants), dest[0]); local_vplce[0] = place + local_vince[0]; + pix = bufplce[1][(place = local_vplce[1]) >> bits]; dest[1] = alpha_blend(shade_bgra(pix, light1, shade_constants), dest[1]); local_vplce[1] = place + local_vince[1]; + pix = bufplce[2][(place = local_vplce[2]) >> bits]; dest[2] = alpha_blend(shade_bgra(pix, light2, shade_constants), dest[2]); local_vplce[2] = place + local_vince[2]; + pix = bufplce[3][(place = local_vplce[3]) >> bits]; dest[3] = alpha_blend(shade_bgra(pix, light3, shade_constants), dest[3]); local_vplce[3] = place + local_vince[3]; dest += pitch; } while (--count); } @@ -2535,29 +2532,31 @@ public: uint32_t light = calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); + uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); do { uint32_t pix = source[frac >> bits]; - if (pix != 0) - { - uint32_t fg = shade_bgra(pix, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; + uint32_t fg_alpha, bg_alpha; + calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + uint32_t fg = shade_bgra(pix, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } frac += fracstep; dest += pitch; } while (--count); @@ -2615,8 +2614,8 @@ public: ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); + uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; @@ -2632,23 +2631,25 @@ public: for (int i = 0; i < 4; ++i) { uint32_t pix = bufplce[i][local_vplce[i] >> bits]; - if (pix != 0) - { - uint32_t fg = shade_bgra(pix, light[i], shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; + uint32_t fg_alpha, bg_alpha; + calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + uint32_t fg = shade_bgra(pix, light[i], shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } local_vplce[i] += local_vince[i]; } dest += pitch; @@ -2702,29 +2703,31 @@ public: uint32_t light = calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); + uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); do { uint32_t pix = source[frac >> bits]; - if (pix != 0) - { - uint32_t fg = shade_bgra(pix, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; + uint32_t fg_alpha, bg_alpha; + calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + uint32_t fg = shade_bgra(pix, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } frac += fracstep; dest += pitch; } while (--count); @@ -2782,8 +2785,8 @@ public: ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); + uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; @@ -2799,23 +2802,25 @@ public: for (int i = 0; i < 4; ++i) { uint32_t pix = bufplce[i][local_vplce[i] >> bits]; - if (pix != 0) - { - uint32_t fg = shade_bgra(pix, light[i], shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; + uint32_t fg_alpha, bg_alpha; + calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + uint32_t fg = shade_bgra(pix, light[i], shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); + uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); + uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } local_vplce[i] += local_vince[i]; } dest += pitch; @@ -2869,29 +2874,31 @@ public: uint32_t light = calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); + uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); do { uint32_t pix = source[frac >> bits]; - if (pix != 0) - { - uint32_t fg = shade_bgra(pix, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; + uint32_t fg_alpha, bg_alpha; + calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); - uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t fg = shade_bgra(pix, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } frac += fracstep; dest += pitch; } while (--count); @@ -2949,8 +2956,8 @@ public: ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); + uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; @@ -2966,23 +2973,25 @@ public: for (int i = 0; i < 4; ++i) { uint32_t pix = bufplce[i][local_vplce[i] >> bits]; - if (pix != 0) - { - uint32_t fg = shade_bgra(pix, light[i], shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; + uint32_t fg_alpha, bg_alpha; + calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); - uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t fg = shade_bgra(pix, light[i], shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } local_vplce[i] += local_vince[i]; } dest += pitch; @@ -3036,29 +3045,31 @@ public: uint32_t light = calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); + uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); do { uint32_t pix = source[frac >> bits]; - if (pix != 0) - { - uint32_t fg = shade_bgra(pix, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; + uint32_t fg_alpha, bg_alpha; + calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); - uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t fg = shade_bgra(pix, light, shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } frac += fracstep; dest += pitch; } while (--count); @@ -3116,8 +3127,8 @@ public: ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); + uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; @@ -3133,23 +3144,25 @@ public: for (int i = 0; i < 4; ++i) { uint32_t pix = bufplce[i][local_vplce[i] >> bits]; - if (pix != 0) - { - uint32_t fg = shade_bgra(pix, light[i], shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; + uint32_t fg_alpha, bg_alpha; + calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); - uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t fg = shade_bgra(pix, light[i], shade_constants); + uint32_t fg_red = (fg >> 16) & 0xff; + uint32_t fg_green = (fg >> 8) & 0xff; + uint32_t fg_blue = fg & 0xff; + + uint32_t bg_red = (dest[i] >> 16) & 0xff; + uint32_t bg_green = (dest[i] >> 8) & 0xff; + uint32_t bg_blue = (dest[i]) & 0xff; + + uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + + dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } local_vplce[i] += local_vince[i]; } dest += pitch; @@ -3733,7 +3746,14 @@ fixed_t tmvline1_add_rgba() void tmvline4_add_rgba() { +#ifdef NO_SSE DrawerCommandQueue::QueueCommand(); +#else + if (!r_linearlight) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); +#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } @@ -3746,7 +3766,14 @@ fixed_t tmvline1_addclamp_rgba() void tmvline4_addclamp_rgba() { +#ifdef NO_SSE DrawerCommandQueue::QueueCommand(); +#else + if (!r_linearlight) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); +#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } @@ -3759,7 +3786,14 @@ fixed_t tmvline1_subclamp_rgba() void tmvline4_subclamp_rgba() { +#ifdef NO_SSE DrawerCommandQueue::QueueCommand(); +#else + if (!r_linearlight) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); +#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } @@ -3772,7 +3806,14 @@ fixed_t tmvline1_revsubclamp_rgba() void tmvline4_revsubclamp_rgba() { +#ifdef NO_SSE DrawerCommandQueue::QueueCommand(); +#else + if (!r_linearlight) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); +#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 174478162..66be1f38b 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -417,9 +417,9 @@ FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) uint32_t bg_green = (bg >> 8) & 0xff; uint32_t bg_blue = bg & 0xff; - uint32_t red = ((fg_red * alpha) + (bg_red * inv_alpha)) / 256; - uint32_t green = ((fg_green * alpha) + (bg_green * inv_alpha)) / 256; - uint32_t blue = ((fg_blue * alpha) + (bg_blue * inv_alpha)) / 256; + uint32_t red = clamp(fg_red + (bg_red * inv_alpha) / 256, 0, 255); + uint32_t green = clamp(fg_green + (bg_green * inv_alpha) / 256, 0, 255); + uint32_t blue = clamp(fg_blue + (bg_blue * inv_alpha) / 256, 0, 255); return 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -543,7 +543,7 @@ FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) /* // Complex shade 8 pixels -#define AVX2_SHADE(fg, shade_constants) { \ +#define AVX_SHADE(fg, shade_constants) { \ __m256i fg_hi = _mm256_unpackhi_epi8(fg, _mm256_setzero_si256()); \ __m256i fg_lo = _mm256_unpacklo_epi8(fg, _mm256_setzero_si256()); \ \ @@ -566,8 +566,58 @@ FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) } */ +// Normal premultiplied alpha blend using the alpha from fg +#define VEC_ALPHA_BLEND(fg,bg) { \ + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); \ + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); \ + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); \ + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); \ + __m128i m255 = _mm_set1_epi16(255); \ + __m128i inv_alpha_hi = _mm_sub_epi16(m255, _mm_shufflehi_epi16(_mm_shufflelo_epi16(fg_hi, _MM_SHUFFLE(3,3,3,3)), _MM_SHUFFLE(3,3,3,3))); \ + __m128i inv_alpha_lo = _mm_sub_epi16(m255, _mm_shufflehi_epi16(_mm_shufflelo_epi16(fg_lo, _MM_SHUFFLE(3,3,3,3)), _MM_SHUFFLE(3,3,3,3))); \ + inv_alpha_hi = _mm_add_epi16(inv_alpha_hi, _mm_srli_epi16(inv_alpha_hi, 7)); \ + inv_alpha_lo = _mm_add_epi16(inv_alpha_lo, _mm_srli_epi16(inv_alpha_lo, 7)); \ + bg_hi = _mm_mullo_epi16(bg_hi, inv_alpha_hi); \ + bg_hi = _mm_srli_epi16(bg_hi, 8); \ + bg_lo = _mm_mullo_epi16(bg_lo, inv_alpha_lo); \ + bg_lo = _mm_srli_epi16(bg_lo, 8); \ + bg = _mm_packus_epi16(bg_lo, bg_hi); \ + fg = _mm_adds_epu8(fg, bg); \ +} +/* +FORCEINLINE void calc_blend_alpha(uint32_t fg, uint32_t src_alpha, uint32_t dest_alpha, uint32_t &fg_alpha, uint32_t &bg_alpha) +{ + fg_alpha = src_alpha; + bg_alpha = dest_alpha; +} +#define VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha) \ + __m128i fg_alpha_hi = msrc_alpha; \ + __m128i fg_alpha_lo = msrc_alpha; \ + __m128i bg_alpha_hi = mdest_alpha; \ + __m128i bg_alpha_lo = mdest_alpha; +*/ + +// Calculates the final alpha values to be used when combined with the source texture alpha channel +FORCEINLINE void calc_blend_alpha(uint32_t fg, uint32_t src_alpha, uint32_t dest_alpha, uint32_t &fg_alpha, uint32_t &bg_alpha) +{ + fg_alpha = (fg >> 24) & 0xff; + fg_alpha += fg_alpha >> 7; + bg_alpha = (dest_alpha * (256 - fg_alpha)) >> 8; + fg_alpha = (src_alpha * fg_alpha) >> 8; +} + +// Calculates the final alpha values to be used when combined with the source texture alpha channel +#define VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha) \ + __m128i fg_alpha_hi = _mm_shufflehi_epi16(_mm_shufflelo_epi16(_mm_unpackhi_epi8(fg, _mm_setzero_si128()), _MM_SHUFFLE(3, 3, 3, 3)), _MM_SHUFFLE(3, 3, 3, 3)); \ + __m128i fg_alpha_lo = _mm_shufflehi_epi16(_mm_shufflelo_epi16(_mm_unpacklo_epi8(fg, _mm_setzero_si128()), _MM_SHUFFLE(3, 3, 3, 3)), _MM_SHUFFLE(3, 3, 3, 3)); \ + fg_alpha_hi = _mm_add_epi16(fg_alpha_hi, _mm_srli_epi16(fg_alpha_hi, 7)); \ + fg_alpha_lo = _mm_add_epi16(fg_alpha_lo, _mm_srli_epi16(fg_alpha_lo, 7)); \ + __m128i bg_alpha_hi = _mm_srli_epi16(_mm_mullo_epi16(_mm_sub_epi16(_mm_set1_epi16(256), fg_alpha_hi), mdest_alpha), 8); \ + __m128i bg_alpha_lo = _mm_srli_epi16(_mm_mullo_epi16(_mm_sub_epi16(_mm_set1_epi16(256), fg_alpha_lo), mdest_alpha), 8); \ + fg_alpha_hi = _mm_srli_epi16(_mm_mullo_epi16(fg_alpha_hi, msrc_alpha), 8); \ + fg_alpha_lo = _mm_srli_epi16(_mm_mullo_epi16(fg_alpha_lo, msrc_alpha), 8); // Calculate constants for a simple shade #define SSE_SHADE_SIMPLE_INIT(light) \ diff --git a/src/r_draw_rgba_sse.h b/src/r_draw_rgba_sse.h index 14ebbbb41..0597580e1 100644 --- a/src/r_draw_rgba_sse.h +++ b/src/r_draw_rgba_sse.h @@ -444,17 +444,16 @@ public: uint32_t pix2 = bufplce[2][place2 >> bits]; uint32_t pix3 = bufplce[3][place3 >> bits]; - // movemask = !(pix == 0) - __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); - local_vplce[0] = place0 + local_vince[0]; local_vplce[1] = place1 + local_vince[1]; local_vplce[2] = place2 + local_vince[2]; local_vplce[3] = place3 + local_vince[3]; __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); + __m128i bg = _mm_loadu_si128((const __m128i*)dest); VEC_SHADE_SIMPLE(fg); - _mm_maskmoveu_si128(fg, movemask, (char*)dest); + VEC_ALPHA_BLEND(fg, bg); + _mm_storeu_si128((__m128i*)dest, fg); dest += pitch; } while (--count); } @@ -473,17 +472,585 @@ public: uint32_t pix2 = bufplce[2][place2 >> bits]; uint32_t pix3 = bufplce[3][place3 >> bits]; - // movemask = !(pix == 0) - __m128i movemask = _mm_xor_si128(_mm_cmpeq_epi32(_mm_set_epi32(pix3, pix2, pix1, pix0), _mm_setzero_si128()), _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); - local_vplce[0] = place0 + local_vince[0]; local_vplce[1] = place1 + local_vince[1]; local_vplce[2] = place2 + local_vince[2]; local_vplce[3] = place3 + local_vince[3]; __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); + __m128i bg = _mm_loadu_si128((const __m128i*)dest); VEC_SHADE(fg, shade_constants); - _mm_maskmoveu_si128(fg, movemask, (char*)dest); + VEC_ALPHA_BLEND(fg, bg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += pitch; + } while (--count); + } + } +}; + +class VecCommand(Tmvline4AddRGBA) : public DrawerCommand +{ + BYTE * RESTRICT _dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; + int tmvlinebits; + fixed_t palookuplight[4]; + DWORD vplce[4]; + DWORD vince[4]; + const uint32 * RESTRICT bufplce[4]; + +public: + VecCommand(Tmvline4AddRGBA)() + { + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + tmvlinebits = ::tmvlinebits; + for (int i = 0; i < 4; i++) + { + palookuplight[i] = ::palookuplight[i]; + vplce[i] = ::vplce[i]; + vince[i] = ::vince[i]; + bufplce[i] = (const uint32 *)::bufplce[i]; + } + } + + void Execute(DrawerThread *thread) override + { + int count = thread->count_for_thread(_dest_y, _count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; + int bits = tmvlinebits; + + uint32_t light[4]; + light[0] = calc_light_multiplier(palookuplight[0]); + light[1] = calc_light_multiplier(palookuplight[1]); + light[2] = calc_light_multiplier(palookuplight[2]); + light[3] = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = _shade_constants; + + uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); + + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT4(light[3], light[2], light[1], light[0]); + + __m128i msrc_alpha = _mm_set1_epi16(src_alpha); + __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + + do + { + uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; + uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; + uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; + uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + + local_vplce[0] = local_vplce[0] + local_vince[0]; + local_vplce[1] = local_vplce[1] + local_vince[1]; + local_vplce[2] = local_vplce[2] + local_vince[2]; + local_vplce[3] = local_vplce[3] + local_vince[3]; + + __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); + + VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_SHADE_SIMPLE(fg); + + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + __m128i out_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); + __m128i out_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); + __m128i out = _mm_packus_epi16(out_lo, out_hi); + + _mm_storeu_si128((__m128i*)dest, out); + dest += pitch; + } while (--count); + } + else + { + VEC_SHADE_INIT4(light[3], light[2], light[1], light[0], shade_constants); + + __m128i msrc_alpha = _mm_set1_epi16(src_alpha); + __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + + do + { + uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; + uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; + uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; + uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + + local_vplce[0] = local_vplce[0] + local_vince[0]; + local_vplce[1] = local_vplce[1] + local_vince[1]; + local_vplce[2] = local_vplce[2] + local_vince[2]; + local_vplce[3] = local_vplce[3] + local_vince[3]; + + __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); + VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_SHADE(fg, shade_constants); + + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + __m128i out_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); + __m128i out_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); + __m128i out = _mm_packus_epi16(out_lo, out_hi); + + _mm_storeu_si128((__m128i*)dest, out); + dest += pitch; + } while (--count); + } + } +}; + +class VecCommand(Tmvline4AddClampRGBA) : public DrawerCommand +{ + BYTE * RESTRICT _dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; + int tmvlinebits; + fixed_t palookuplight[4]; + DWORD vplce[4]; + DWORD vince[4]; + const uint32 *RESTRICT bufplce[4]; + +public: + VecCommand(Tmvline4AddClampRGBA)() + { + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + tmvlinebits = ::tmvlinebits; + for (int i = 0; i < 4; i++) + { + palookuplight[i] = ::palookuplight[i]; + vplce[i] = ::vplce[i]; + vince[i] = ::vince[i]; + bufplce[i] = (const uint32 *)::bufplce[i]; + } + } + + void Execute(DrawerThread *thread) override + { + int count = thread->count_for_thread(_dest_y, _count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; + int bits = tmvlinebits; + + uint32_t light[4]; + light[0] = calc_light_multiplier(palookuplight[0]); + light[1] = calc_light_multiplier(palookuplight[1]); + light[2] = calc_light_multiplier(palookuplight[2]); + light[3] = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = _shade_constants; + + uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); + + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT4(light[3], light[2], light[1], light[0]); + + __m128i msrc_alpha = _mm_set1_epi16(src_alpha); + __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + + do + { + uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; + uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; + uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; + uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + + local_vplce[0] = local_vplce[0] + local_vince[0]; + local_vplce[1] = local_vplce[1] + local_vince[1]; + local_vplce[2] = local_vplce[2] + local_vince[2]; + local_vplce[3] = local_vplce[3] + local_vince[3]; + + __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); + VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_SHADE_SIMPLE(fg); + + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + __m128i out_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); + __m128i out_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); + __m128i out = _mm_packus_epi16(out_lo, out_hi); + + _mm_storeu_si128((__m128i*)dest, out); + dest += pitch; + } while (--count); + } + else + { + VEC_SHADE_INIT4(light[3], light[2], light[1], light[0], shade_constants); + + __m128i msrc_alpha = _mm_set1_epi16(src_alpha); + __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + + do + { + uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; + uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; + uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; + uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + + local_vplce[0] = local_vplce[0] + local_vince[0]; + local_vplce[1] = local_vplce[1] + local_vince[1]; + local_vplce[2] = local_vplce[2] + local_vince[2]; + local_vplce[3] = local_vplce[3] + local_vince[3]; + + __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); + VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_SHADE(fg, shade_constants); + + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + __m128i out_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); + __m128i out_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); + __m128i out = _mm_packus_epi16(out_lo, out_hi); + + _mm_storeu_si128((__m128i*)dest, out); + dest += pitch; + } while (--count); + } + } +}; + +class VecCommand(Tmvline4SubClampRGBA) : public DrawerCommand +{ + BYTE * RESTRICT _dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; + int tmvlinebits; + fixed_t palookuplight[4]; + DWORD vplce[4]; + DWORD vince[4]; + const uint32 *RESTRICT bufplce[4]; + +public: + VecCommand(Tmvline4SubClampRGBA)() + { + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + tmvlinebits = ::tmvlinebits; + for (int i = 0; i < 4; i++) + { + palookuplight[i] = ::palookuplight[i]; + vplce[i] = ::vplce[i]; + vince[i] = ::vince[i]; + bufplce[i] = (const uint32 *)::bufplce[i]; + } + } + + void Execute(DrawerThread *thread) override + { + int count = thread->count_for_thread(_dest_y, _count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; + int bits = tmvlinebits; + + uint32_t light[4]; + light[0] = calc_light_multiplier(palookuplight[0]); + light[1] = calc_light_multiplier(palookuplight[1]); + light[2] = calc_light_multiplier(palookuplight[2]); + light[3] = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = _shade_constants; + + uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); + + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT4(light[3], light[2], light[1], light[0]); + + __m128i msrc_alpha = _mm_set1_epi16(src_alpha); + __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + + do + { + uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; + uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; + uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; + uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + + local_vplce[0] = local_vplce[0] + local_vince[0]; + local_vplce[1] = local_vplce[1] + local_vince[1]; + local_vplce[2] = local_vplce[2] + local_vince[2]; + local_vplce[3] = local_vplce[3] + local_vince[3]; + + __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); + VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_SHADE_SIMPLE(fg); + + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_hi, bg_alpha_hi), _mm_mullo_epi16(fg_hi, fg_alpha_hi)), 8); + __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_lo, bg_alpha_lo), _mm_mullo_epi16(fg_lo, fg_alpha_lo)), 8); + __m128i out = _mm_packus_epi16(out_lo, out_hi); + + _mm_storeu_si128((__m128i*)dest, out); + dest += pitch; + } while (--count); + } + else + { + VEC_SHADE_INIT4(light[3], light[2], light[1], light[0], shade_constants); + + __m128i msrc_alpha = _mm_set1_epi16(src_alpha); + __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + + do + { + uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; + uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; + uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; + uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + + local_vplce[0] = local_vplce[0] + local_vince[0]; + local_vplce[1] = local_vplce[1] + local_vince[1]; + local_vplce[2] = local_vplce[2] + local_vince[2]; + local_vplce[3] = local_vplce[3] + local_vince[3]; + + __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); + VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_SHADE(fg, shade_constants); + + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_hi, bg_alpha_hi), _mm_mullo_epi16(fg_hi, fg_alpha_hi)), 8); + __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_lo, bg_alpha_lo), _mm_mullo_epi16(fg_lo, fg_alpha_lo)), 8); + __m128i out = _mm_packus_epi16(out_lo, out_hi); + + _mm_storeu_si128((__m128i*)dest, out); + dest += pitch; + } while (--count); + } + } +}; + +class VecCommand(Tmvline4RevSubClampRGBA) : public DrawerCommand +{ + BYTE * RESTRICT _dest; + int _count; + int _pitch; + ShadeConstants _shade_constants; + fixed_t _srcalpha; + fixed_t _destalpha; + int tmvlinebits; + fixed_t palookuplight[4]; + DWORD vplce[4]; + DWORD vince[4]; + const uint32 *RESTRICT bufplce[4]; + +public: + VecCommand(Tmvline4RevSubClampRGBA)() + { + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + tmvlinebits = ::tmvlinebits; + for (int i = 0; i < 4; i++) + { + palookuplight[i] = ::palookuplight[i]; + vplce[i] = ::vplce[i]; + vince[i] = ::vince[i]; + bufplce[i] = (const uint32 *)::bufplce[i]; + } + } + + void Execute(DrawerThread *thread) override + { + int count = thread->count_for_thread(_dest_y, _count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); + int pitch = _pitch * thread->num_cores; + int bits = tmvlinebits; + + uint32_t light[4]; + light[0] = calc_light_multiplier(palookuplight[0]); + light[1] = calc_light_multiplier(palookuplight[1]); + light[2] = calc_light_multiplier(palookuplight[2]); + light[3] = calc_light_multiplier(palookuplight[3]); + + ShadeConstants shade_constants = _shade_constants; + + uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); + + DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; + DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; + int skipped = thread->skipped_by_thread(_dest_y); + for (int i = 0; i < 4; i++) + { + local_vplce[i] += local_vince[i] * skipped; + local_vince[i] *= thread->num_cores; + } + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT4(light[3], light[2], light[1], light[0]); + + __m128i msrc_alpha = _mm_set1_epi16(src_alpha); + __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + + do + { + uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; + uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; + uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; + uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + + local_vplce[0] = local_vplce[0] + local_vince[0]; + local_vplce[1] = local_vplce[1] + local_vince[1]; + local_vplce[2] = local_vplce[2] + local_vince[2]; + local_vplce[3] = local_vplce[3] + local_vince[3]; + + __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); + VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_SHADE_SIMPLE(fg); + + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); + __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); + __m128i out = _mm_packus_epi16(out_lo, out_hi); + + _mm_storeu_si128((__m128i*)dest, out); + dest += pitch; + } while (--count); + } + else + { + VEC_SHADE_INIT4(light[3], light[2], light[1], light[0], shade_constants); + + __m128i msrc_alpha = _mm_set1_epi16(src_alpha); + __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + + do + { + uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; + uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; + uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; + uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + + local_vplce[0] = local_vplce[0] + local_vince[0]; + local_vplce[1] = local_vplce[1] + local_vince[1]; + local_vplce[2] = local_vplce[2] + local_vince[2]; + local_vplce[3] = local_vplce[3] + local_vince[3]; + + __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); + VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_SHADE(fg, shade_constants); + + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); + __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); + __m128i out = _mm_packus_epi16(out_lo, out_hi); + + _mm_storeu_si128((__m128i*)dest, out); dest += pitch; } while (--count); } diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 4da963430..1e1236f0e 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -1436,7 +1436,14 @@ void rt_subclamp1col_rgba (int hx, int sx, int yl, int yh) // Subtracts all four spans to the screen starting at sx with clamping. void rt_subclamp4cols_rgba (int sx, int yl, int yh) { +#ifdef NO_SSE DrawerCommandQueue::QueueCommand(sx, yl, yh); +#else + if (!r_linearlight) + DrawerCommandQueue::QueueCommand(sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(sx, yl, yh); +#endif } // Translates and subtracts one span at hx to the screen at sx with clamping. @@ -1462,7 +1469,14 @@ void rt_revsubclamp1col_rgba (int hx, int sx, int yl, int yh) // Subtracts all four spans from the screen starting at sx with clamping. void rt_revsubclamp4cols_rgba (int sx, int yl, int yh) { +#ifdef NO_SSE DrawerCommandQueue::QueueCommand(sx, yl, yh); +#else + if (!r_linearlight) + DrawerCommandQueue::QueueCommand(sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(sx, yl, yh); +#endif } // Translates and subtracts one span at hx from the screen at sx with clamping. diff --git a/src/r_drawt_rgba_sse.h b/src/r_drawt_rgba_sse.h index 5b8ae8081..684be2b6a 100644 --- a/src/r_drawt_rgba_sse.h +++ b/src/r_drawt_rgba_sse.h @@ -493,3 +493,255 @@ public: } } }; + +class VecCommand(RtSubClamp4colsRGBA) : public DrawerCommand +{ + int sx; + int yl; + int yh; + BYTE * RESTRICT _destorg; + int _pitch; + fixed_t _light; + fixed_t _srcalpha; + fixed_t _destalpha; + ShadeConstants _shade_constants; + +public: + VecCommand(RtSubClamp4colsRGBA)(int sx, int yl, int yh) + { + this->sx = sx; + this->yl = yl; + this->yh = yh; + + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _shade_constants = dc_shade_constants; + } + + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + int sincr; + + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) + return; + + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = _pitch * thread->num_cores; + sincr = 4 * thread->num_cores; + + uint32_t light = calc_light_multiplier(_light); + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + ShadeConstants shade_constants = _shade_constants; + + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT(light); + + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + VEC_SHADE_SIMPLE(fg); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (bg_red * bg_alpha - fg_red * fg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_hi, mbg_alpha), _mm_mullo_epi16(fg_hi, mfg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_lo, mbg_alpha), _mm_mullo_epi16(fg_lo, mfg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += sincr; + dest += pitch; + } while (--count); + } + else + { + VEC_SHADE_INIT(light, shade_constants); + + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + VEC_SHADE(fg, shade_constants); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (bg_red * bg_alpha - fg_red * fg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_hi, mbg_alpha), _mm_mullo_epi16(fg_hi, mfg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_lo, mbg_alpha), _mm_mullo_epi16(fg_lo, mfg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += sincr; + dest += pitch; + } while (--count); + } + } +}; + +class VecCommand(RtRevSubClamp4colsRGBA) : public DrawerCommand +{ + int sx; + int yl; + int yh; + BYTE * RESTRICT _destorg; + int _pitch; + fixed_t _light; + fixed_t _srcalpha; + fixed_t _destalpha; + ShadeConstants _shade_constants; + +public: + VecCommand(RtRevSubClamp4colsRGBA)(int sx, int yl, int yh) + { + this->sx = sx; + this->yl = yl; + this->yh = yh; + + _destorg = dc_destorg; + _pitch = dc_pitch; + _light = dc_light; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; + _shade_constants = dc_shade_constants; + } + + void Execute(DrawerThread *thread) override + { + uint32_t *source; + uint32_t *dest; + int count; + int pitch; + int sincr; + + count = thread->count_for_thread(yl, yh - yl + 1); + if (count <= 0) + return; + + dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); + source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; + pitch = _pitch * thread->num_cores; + sincr = 4 * thread->num_cores; + + uint32_t light = calc_light_multiplier(_light); + uint32_t *palette = (uint32_t*)GPalette.BaseColors; + ShadeConstants shade_constants = _shade_constants; + + uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); + uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT(light); + + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + VEC_SHADE_SIMPLE(fg); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha - bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += sincr; + dest += pitch; + } while (--count); + } + else + { + VEC_SHADE_INIT(light, shade_constants); + + __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); + __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); + + do { + uint32_t p0 = source[0]; + uint32_t p1 = source[1]; + uint32_t p2 = source[2]; + uint32_t p3 = source[3]; + + // shade_pal_index: + __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); + VEC_SHADE(fg, shade_constants); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + + // unpack bg: + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + // (fg_red * fg_alpha - bg_red * bg_alpha) / 256: + __m128i color_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); + __m128i color_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); + + __m128i color = _mm_packus_epi16(color_lo, color_hi); + _mm_storeu_si128((__m128i*)dest, color); + + source += sincr; + dest += pitch; + } while (--count); + } + } +}; From e72a032a114c7710112534157abad8fa300c2f7d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 19 Jun 2016 23:12:10 +0200 Subject: [PATCH 0679/1509] Fixed alpha channel issue with textures --- src/textures/pngtexture.cpp | 10 ++++++++-- src/textures/texture.cpp | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index 206797a34..408cf1e2f 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -724,8 +724,9 @@ void FPNGTexture::MakeTextureBgra () { for (y = Height; y > 0; --y) { + // output as premultiplied alpha uint32_t alpha = in[1]; - uint32_t gray = in[0]; + uint32_t gray = (in[0] * alpha + 127) / 255; *out++ = (alpha << 24) | (gray << 16) | (gray << 8) | gray; in += pitch; } @@ -740,7 +741,12 @@ void FPNGTexture::MakeTextureBgra () { for (y = Height; y > 0; --y) { - *out++ = (((uint32_t)in[3]) << 24) | (((uint32_t)in[0]) << 16) | (((uint32_t)in[1]) << 8) | ((uint32_t)in[2]); + // output as premultiplied alpha + uint32_t alpha = in[3]; + uint32_t red = (in[0] * alpha + 127) / 255; + uint32_t green = (in[1] * alpha + 127) / 255; + uint32_t blue = (in[2] * alpha + 127) / 255; + *out++ = (alpha << 24) | (red << 16) | (green << 8) | blue; in += pitch; } in -= backstep; diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 0030719cb..da5dd8ad7 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -203,7 +203,7 @@ const uint32_t *FTexture::GetPixelsBgra() PixelsBgra.resize(Width * Height); for (int i = 0; i < Width * Height; i++) { - PixelsBgra[i] = GPalette.BaseColors[indices[i]].d; + PixelsBgra[i] = 0xff000000 | GPalette.BaseColors[indices[i]].d; } } return PixelsBgra.data(); From d3bc68a160be4b6549f68454b308ad66c62e1d50 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 19 Jun 2016 23:37:22 +0200 Subject: [PATCH 0680/1509] Disabled the AVX intrinsics --- src/r_draw_rgba.cpp | 40 +++++++++------------------------------- src/r_drawt_rgba.cpp | 36 ++++++++---------------------------- 2 files changed, 17 insertions(+), 59 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 96232ab0c..b437fbe00 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -58,7 +58,6 @@ extern float rw_lightstep; extern int wallshade; CVAR(Bool, r_multithreaded, true, 0) -CVAR(Bool, r_linearlight, false, 0) #ifndef NO_SSE @@ -71,7 +70,7 @@ CVAR(Bool, r_linearlight, false, 0) #define VEC_SHADE_INIT4 SSE_SHADE_INIT4 #define VEC_SHADE SSE_SHADE #include "r_draw_rgba_sse.h" - +/* // Generate AVX drawers: #undef VecCommand #undef VEC_SHADE_SIMPLE_INIT @@ -88,7 +87,7 @@ CVAR(Bool, r_linearlight, false, 0) #define VEC_SHADE_INIT4 AVX_LINEAR_SHADE_INIT4 #define VEC_SHADE AVX_LINEAR_SHADE #include "r_draw_rgba_sse.h" - +*/ #endif ///////////////////////////////////////////////////////////////////////////// @@ -3652,10 +3651,7 @@ void R_DrawSpan_rgba() #ifdef NO_SSE DrawerCommandQueue::QueueCommand(); #else - if (!r_linearlight) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); #endif } @@ -3709,10 +3705,7 @@ void vlinec4_rgba() #ifdef NO_SSE DrawerCommandQueue::QueueCommand(); #else - if (!r_linearlight) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); #endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -3729,10 +3722,7 @@ void mvlinec4_rgba() #ifdef NO_SSE DrawerCommandQueue::QueueCommand(); #else - if (!r_linearlight) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); #endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -3749,10 +3739,7 @@ void tmvline4_add_rgba() #ifdef NO_SSE DrawerCommandQueue::QueueCommand(); #else - if (!r_linearlight) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); #endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -3769,10 +3756,7 @@ void tmvline4_addclamp_rgba() #ifdef NO_SSE DrawerCommandQueue::QueueCommand(); #else - if (!r_linearlight) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); #endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -3789,10 +3773,7 @@ void tmvline4_subclamp_rgba() #ifdef NO_SSE DrawerCommandQueue::QueueCommand(); #else - if (!r_linearlight) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); #endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -3809,10 +3790,7 @@ void tmvline4_revsubclamp_rgba() #ifdef NO_SSE DrawerCommandQueue::QueueCommand(); #else - if (!r_linearlight) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); #endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 1e1236f0e..e239674e8 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -51,8 +51,6 @@ extern unsigned int dc_tspans[4][MAXHEIGHT]; extern unsigned int *dc_ctspan[4]; extern unsigned int *horizspan[4]; -EXTERN_CVAR(Bool, r_linearlight) - #ifndef NO_SSE // Generate SSE drawers: @@ -64,7 +62,7 @@ EXTERN_CVAR(Bool, r_linearlight) #define VEC_SHADE_INIT4 SSE_SHADE_INIT4 #define VEC_SHADE SSE_SHADE #include "r_drawt_rgba_sse.h" - +/* // Generate AVX drawers: #undef VecCommand #undef VEC_SHADE_SIMPLE_INIT @@ -81,7 +79,7 @@ EXTERN_CVAR(Bool, r_linearlight) #define VEC_SHADE_INIT4 AVX_LINEAR_SHADE_INIT4 #define VEC_SHADE AVX_LINEAR_SHADE #include "r_drawt_rgba_sse.h" - +*/ #endif ///////////////////////////////////////////////////////////////////////////// @@ -1311,10 +1309,7 @@ void rt_map4cols_rgba (int sx, int yl, int yh) #ifdef NO_SSE DrawerCommandQueue::QueueCommand(sx, yl, yh); #else - if (!r_linearlight) - DrawerCommandQueue::QueueCommand(sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(sx, yl, yh); + DrawerCommandQueue::QueueCommand(sx, yl, yh); #endif } @@ -1354,10 +1349,7 @@ void rt_add4cols_rgba (int sx, int yl, int yh) #ifdef NO_SSE DrawerCommandQueue::QueueCommand(sx, yl, yh); #else - if (!r_linearlight) - DrawerCommandQueue::QueueCommand(sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(sx, yl, yh); + DrawerCommandQueue::QueueCommand(sx, yl, yh); #endif } @@ -1387,10 +1379,7 @@ void rt_shaded4cols_rgba (int sx, int yl, int yh) #ifdef NO_SSE DrawerCommandQueue::QueueCommand(sx, yl, yh); #else - if (!r_linearlight) - DrawerCommandQueue::QueueCommand(sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(sx, yl, yh); + DrawerCommandQueue::QueueCommand(sx, yl, yh); #endif } @@ -1406,10 +1395,7 @@ void rt_addclamp4cols_rgba (int sx, int yl, int yh) #ifdef NO_SSE DrawerCommandQueue::QueueCommand(sx, yl, yh); #else - if (!r_linearlight) - DrawerCommandQueue::QueueCommand(sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(sx, yl, yh); + DrawerCommandQueue::QueueCommand(sx, yl, yh); #endif } @@ -1439,10 +1425,7 @@ void rt_subclamp4cols_rgba (int sx, int yl, int yh) #ifdef NO_SSE DrawerCommandQueue::QueueCommand(sx, yl, yh); #else - if (!r_linearlight) - DrawerCommandQueue::QueueCommand(sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(sx, yl, yh); + DrawerCommandQueue::QueueCommand(sx, yl, yh); #endif } @@ -1472,10 +1455,7 @@ void rt_revsubclamp4cols_rgba (int sx, int yl, int yh) #ifdef NO_SSE DrawerCommandQueue::QueueCommand(sx, yl, yh); #else - if (!r_linearlight) - DrawerCommandQueue::QueueCommand(sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(sx, yl, yh); + DrawerCommandQueue::QueueCommand(sx, yl, yh); #endif } From 6daeb5a15881c2198af31cb564c23d6090f026d4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 20 Jun 2016 02:36:54 +0200 Subject: [PATCH 0681/1509] Blend mode fixes --- src/r_draw_rgba.cpp | 32 +++++++-------- src/r_draw_rgba.h | 87 ++++++++++++++++++---------------------- src/r_draw_rgba_sse.h | 48 ++++++++-------------- src/textures/texture.cpp | 5 ++- 4 files changed, 76 insertions(+), 96 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index b437fbe00..f317a34d6 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -2538,8 +2538,8 @@ public: { uint32_t pix = source[frac >> bits]; - uint32_t fg_alpha, bg_alpha; - calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); + uint32_t fg_alpha = src_alpha; + uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); uint32_t fg = shade_bgra(pix, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; @@ -2631,8 +2631,8 @@ public: { uint32_t pix = bufplce[i][local_vplce[i] >> bits]; - uint32_t fg_alpha, bg_alpha; - calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); + uint32_t fg_alpha = src_alpha; + uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); uint32_t fg = shade_bgra(pix, light[i], shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; @@ -2709,8 +2709,8 @@ public: { uint32_t pix = source[frac >> bits]; - uint32_t fg_alpha, bg_alpha; - calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); + uint32_t fg_alpha = src_alpha; + uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); uint32_t fg = shade_bgra(pix, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; @@ -2802,8 +2802,8 @@ public: { uint32_t pix = bufplce[i][local_vplce[i] >> bits]; - uint32_t fg_alpha, bg_alpha; - calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); + uint32_t fg_alpha = src_alpha; + uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); uint32_t fg = shade_bgra(pix, light[i], shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; @@ -2880,8 +2880,8 @@ public: { uint32_t pix = source[frac >> bits]; - uint32_t fg_alpha, bg_alpha; - calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); + uint32_t fg_alpha = src_alpha; + uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); uint32_t fg = shade_bgra(pix, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; @@ -2973,8 +2973,8 @@ public: { uint32_t pix = bufplce[i][local_vplce[i] >> bits]; - uint32_t fg_alpha, bg_alpha; - calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); + uint32_t fg_alpha = src_alpha; + uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); uint32_t fg = shade_bgra(pix, light[i], shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; @@ -3051,8 +3051,8 @@ public: { uint32_t pix = source[frac >> bits]; - uint32_t fg_alpha, bg_alpha; - calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); + uint32_t fg_alpha = src_alpha; + uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); uint32_t fg = shade_bgra(pix, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; @@ -3144,8 +3144,8 @@ public: { uint32_t pix = bufplce[i][local_vplce[i] >> bits]; - uint32_t fg_alpha, bg_alpha; - calc_blend_alpha(pix, src_alpha, dest_alpha, fg_alpha, bg_alpha); + uint32_t fg_alpha = src_alpha; + uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); uint32_t fg = shade_bgra(pix, light[i], shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 66be1f38b..2527e84a6 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -339,6 +339,7 @@ FORCEINLINE uint32_t shade_bgra_simple(uint32_t color, uint32_t light) FORCEINLINE uint32_t shade_pal_index(uint32_t index, uint32_t light, const ShadeConstants &constants) { const PalEntry &color = GPalette.BaseColors[index]; + uint32_t alpha = color.d & 0xff000000; uint32_t red = color.r; uint32_t green = color.g; uint32_t blue = color.b; @@ -367,11 +368,12 @@ FORCEINLINE uint32_t shade_pal_index(uint32_t index, uint32_t light, const Shade green = (green * constants.light_green) / 256; blue = (blue * constants.light_blue) / 256; } - return 0xff000000 | (red << 16) | (green << 8) | blue; + return alpha | (red << 16) | (green << 8) | blue; } FORCEINLINE uint32_t shade_bgra(uint32_t color, uint32_t light, const ShadeConstants &constants) { + uint32_t alpha = color & 0xff000000; uint32_t red = (color >> 16) & 0xff; uint32_t green = (color >> 8) & 0xff; uint32_t blue = color & 0xff; @@ -400,12 +402,12 @@ FORCEINLINE uint32_t shade_bgra(uint32_t color, uint32_t light, const ShadeConst green = (green * constants.light_green) / 256; blue = (blue * constants.light_blue) / 256; } - return 0xff000000 | (red << 16) | (green << 8) | blue; + return alpha | (red << 16) | (green << 8) | blue; } FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) { - uint32_t fg_alpha = (fg >> 24) & 0xff; + uint32_t fg_alpha = fg >> 24; uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -468,11 +470,11 @@ FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) __m256 mrcp_255 = _mm256_set1_ps(1.0f/255.0f); \ __m256 m255 = _mm256_set1_ps(255.0f); \ __m256 color = _mm256_set_ps( \ - shade_constants.light_alpha * (1.0f/256.0f), shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f), \ - shade_constants.light_alpha * (1.0f/256.0f), shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f)); \ + 1.0f, shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f), \ + 1.0f, shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f)); \ __m256 fade = _mm256_set_ps( \ - shade_constants.fade_alpha * (1.0f/256.0f), shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f), \ - shade_constants.fade_alpha * (1.0f/256.0f), shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f)); \ + 0.0f, shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f), \ + 0.0f, shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f)); \ __m256 fade_amount_hi = _mm256_mul_ps(fade, _mm256_sub_ps(_mm256_set1_ps(1.0f), mlight_hi)); \ __m256 fade_amount_lo = _mm256_mul_ps(fade, _mm256_sub_ps(_mm256_set1_ps(1.0f), mlight_lo)); \ __m256 inv_desaturate = _mm256_set1_ps((256 - shade_constants.desaturate) * (1.0f/256.0f)); \ @@ -488,11 +490,11 @@ FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) __m256 mrcp_255 = _mm256_set1_ps(1.0f/255.0f); \ __m256 m255 = _mm256_set1_ps(255.0f); \ __m256 color = _mm256_set_ps( \ - shade_constants.light_alpha * (1.0f/256.0f), shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f), \ - shade_constants.light_alpha * (1.0f/256.0f), shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f)); \ + 1.0f, shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f), \ + 1.0f, shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f)); \ __m256 fade = _mm256_set_ps( \ - shade_constants.fade_alpha * (1.0f/256.0f), shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f), \ - shade_constants.fade_alpha * (1.0f/256.0f), shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f)); \ + 0.0f, shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f), \ + 0.0f, shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f)); \ __m256 fade_amount_hi = _mm256_mul_ps(fade, _mm256_sub_ps(_mm256_set1_ps(1.0f), mlight_hi)); \ __m256 fade_amount_lo = _mm256_mul_ps(fade, _mm256_sub_ps(_mm256_set1_ps(1.0f), mlight_lo)); \ __m256 inv_desaturate = _mm256_set1_ps((256 - shade_constants.desaturate) * (1.0f/256.0f)); \ @@ -585,39 +587,30 @@ FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) fg = _mm_adds_epu8(fg, bg); \ } -/* -FORCEINLINE void calc_blend_alpha(uint32_t fg, uint32_t src_alpha, uint32_t dest_alpha, uint32_t &fg_alpha, uint32_t &bg_alpha) +// Calculates the final alpha values to be used when combined with the source texture alpha channel +FORCEINLINE uint32_t calc_blend_bgalpha(uint32_t fg, uint32_t dest_alpha) { - fg_alpha = src_alpha; - bg_alpha = dest_alpha; + uint32_t alpha = fg >> 24; + alpha += alpha >> 7; + return 256 - alpha; // (dest_alpha * (256 - alpha)) >> 8; } -#define VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha) \ - __m128i fg_alpha_hi = msrc_alpha; \ - __m128i fg_alpha_lo = msrc_alpha; \ - __m128i bg_alpha_hi = mdest_alpha; \ - __m128i bg_alpha_lo = mdest_alpha; -*/ +#define VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha) \ + __m128i msrc_alpha = _mm_set1_epi16(src_alpha); \ + __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); // Calculates the final alpha values to be used when combined with the source texture alpha channel -FORCEINLINE void calc_blend_alpha(uint32_t fg, uint32_t src_alpha, uint32_t dest_alpha, uint32_t &fg_alpha, uint32_t &bg_alpha) -{ - fg_alpha = (fg >> 24) & 0xff; - fg_alpha += fg_alpha >> 7; - bg_alpha = (dest_alpha * (256 - fg_alpha)) >> 8; - fg_alpha = (src_alpha * fg_alpha) >> 8; -} - -// Calculates the final alpha values to be used when combined with the source texture alpha channel -#define VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha) \ - __m128i fg_alpha_hi = _mm_shufflehi_epi16(_mm_shufflelo_epi16(_mm_unpackhi_epi8(fg, _mm_setzero_si128()), _MM_SHUFFLE(3, 3, 3, 3)), _MM_SHUFFLE(3, 3, 3, 3)); \ - __m128i fg_alpha_lo = _mm_shufflehi_epi16(_mm_shufflelo_epi16(_mm_unpacklo_epi8(fg, _mm_setzero_si128()), _MM_SHUFFLE(3, 3, 3, 3)), _MM_SHUFFLE(3, 3, 3, 3)); \ - fg_alpha_hi = _mm_add_epi16(fg_alpha_hi, _mm_srli_epi16(fg_alpha_hi, 7)); \ - fg_alpha_lo = _mm_add_epi16(fg_alpha_lo, _mm_srli_epi16(fg_alpha_lo, 7)); \ - __m128i bg_alpha_hi = _mm_srli_epi16(_mm_mullo_epi16(_mm_sub_epi16(_mm_set1_epi16(256), fg_alpha_hi), mdest_alpha), 8); \ - __m128i bg_alpha_lo = _mm_srli_epi16(_mm_mullo_epi16(_mm_sub_epi16(_mm_set1_epi16(256), fg_alpha_lo), mdest_alpha), 8); \ - fg_alpha_hi = _mm_srli_epi16(_mm_mullo_epi16(fg_alpha_hi, msrc_alpha), 8); \ - fg_alpha_lo = _mm_srli_epi16(_mm_mullo_epi16(fg_alpha_lo, msrc_alpha), 8); +#define VEC_CALC_BLEND_ALPHA(fg) \ + __m128i fg_alpha_hi, fg_alpha_lo, bg_alpha_hi, bg_alpha_lo; { \ + __m128i alpha_hi = _mm_shufflehi_epi16(_mm_shufflelo_epi16(_mm_unpackhi_epi8(fg, _mm_setzero_si128()), _MM_SHUFFLE(3, 3, 3, 3)), _MM_SHUFFLE(3, 3, 3, 3)); \ + __m128i alpha_lo = _mm_shufflehi_epi16(_mm_shufflelo_epi16(_mm_unpacklo_epi8(fg, _mm_setzero_si128()), _MM_SHUFFLE(3, 3, 3, 3)), _MM_SHUFFLE(3, 3, 3, 3)); \ + alpha_hi = _mm_add_epi16(alpha_hi, _mm_srli_epi16(alpha_hi, 7)); \ + alpha_lo = _mm_add_epi16(alpha_lo, _mm_srli_epi16(alpha_lo, 7)); \ + bg_alpha_hi = _mm_sub_epi16(_mm_set1_epi16(256), alpha_hi); /* _mm_srli_epi16(_mm_mullo_epi16(_mm_sub_epi16(_mm_set1_epi16(256), alpha_hi), mdest_alpha), 8);*/ \ + bg_alpha_lo = _mm_sub_epi16(_mm_set1_epi16(256), alpha_lo); /* _mm_srli_epi16(_mm_mullo_epi16(_mm_sub_epi16(_mm_set1_epi16(256), alpha_lo), mdest_alpha), 8);*/ \ + fg_alpha_hi = msrc_alpha; \ + fg_alpha_lo = msrc_alpha; \ + } // Calculate constants for a simple shade #define SSE_SHADE_SIMPLE_INIT(light) \ @@ -645,11 +638,11 @@ FORCEINLINE void calc_blend_alpha(uint32_t fg, uint32_t src_alpha, uint32_t dest __m128i mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ __m128i mlight_lo = mlight_hi; \ __m128i color = _mm_set_epi16( \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ + 256, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ + 256, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ __m128i fade = _mm_set_epi16( \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ + 0, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ + 0, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ __m128i fade_amount_hi = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_hi)); \ __m128i fade_amount_lo = fade_amount_hi; \ __m128i inv_desaturate = _mm_set1_epi16(256 - shade_constants.desaturate); \ @@ -659,11 +652,11 @@ FORCEINLINE void calc_blend_alpha(uint32_t fg, uint32_t src_alpha, uint32_t dest __m128i mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); \ __m128i mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); \ __m128i color = _mm_set_epi16( \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ - shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ + 256, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ + 256, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ __m128i fade = _mm_set_epi16( \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ - shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ + 0, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ + 0, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ __m128i fade_amount_hi = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_hi)); \ __m128i fade_amount_lo = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_lo)); \ __m128i inv_desaturate = _mm_set1_epi16(256 - shade_constants.desaturate); \ diff --git a/src/r_draw_rgba_sse.h b/src/r_draw_rgba_sse.h index 0597580e1..220638c75 100644 --- a/src/r_draw_rgba_sse.h +++ b/src/r_draw_rgba_sse.h @@ -554,9 +554,7 @@ public: if (shade_constants.simple_shade) { VEC_SHADE_SIMPLE_INIT4(light[3], light[2], light[1], light[0]); - - __m128i msrc_alpha = _mm_set1_epi16(src_alpha); - __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); do { @@ -572,7 +570,7 @@ public: __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_CALC_BLEND_ALPHA(fg); VEC_SHADE_SIMPLE(fg); __m128i bg = _mm_loadu_si128((const __m128i*)dest); @@ -593,9 +591,7 @@ public: else { VEC_SHADE_INIT4(light[3], light[2], light[1], light[0], shade_constants); - - __m128i msrc_alpha = _mm_set1_epi16(src_alpha); - __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); do { @@ -610,7 +606,7 @@ public: local_vplce[3] = local_vplce[3] + local_vince[3]; __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_CALC_BLEND_ALPHA(fg); VEC_SHADE(fg, shade_constants); __m128i bg = _mm_loadu_si128((const __m128i*)dest); @@ -697,9 +693,7 @@ public: if (shade_constants.simple_shade) { VEC_SHADE_SIMPLE_INIT4(light[3], light[2], light[1], light[0]); - - __m128i msrc_alpha = _mm_set1_epi16(src_alpha); - __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); do { @@ -714,7 +708,7 @@ public: local_vplce[3] = local_vplce[3] + local_vince[3]; __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_CALC_BLEND_ALPHA(fg); VEC_SHADE_SIMPLE(fg); __m128i bg = _mm_loadu_si128((const __m128i*)dest); @@ -735,9 +729,7 @@ public: else { VEC_SHADE_INIT4(light[3], light[2], light[1], light[0], shade_constants); - - __m128i msrc_alpha = _mm_set1_epi16(src_alpha); - __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); do { @@ -752,7 +744,7 @@ public: local_vplce[3] = local_vplce[3] + local_vince[3]; __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_CALC_BLEND_ALPHA(fg); VEC_SHADE(fg, shade_constants); __m128i bg = _mm_loadu_si128((const __m128i*)dest); @@ -839,9 +831,7 @@ public: if (shade_constants.simple_shade) { VEC_SHADE_SIMPLE_INIT4(light[3], light[2], light[1], light[0]); - - __m128i msrc_alpha = _mm_set1_epi16(src_alpha); - __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); do { @@ -856,7 +846,7 @@ public: local_vplce[3] = local_vplce[3] + local_vince[3]; __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_CALC_BLEND_ALPHA(fg); VEC_SHADE_SIMPLE(fg); __m128i bg = _mm_loadu_si128((const __m128i*)dest); @@ -877,9 +867,7 @@ public: else { VEC_SHADE_INIT4(light[3], light[2], light[1], light[0], shade_constants); - - __m128i msrc_alpha = _mm_set1_epi16(src_alpha); - __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); do { @@ -894,7 +882,7 @@ public: local_vplce[3] = local_vplce[3] + local_vince[3]; __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_CALC_BLEND_ALPHA(fg); VEC_SHADE(fg, shade_constants); __m128i bg = _mm_loadu_si128((const __m128i*)dest); @@ -981,9 +969,7 @@ public: if (shade_constants.simple_shade) { VEC_SHADE_SIMPLE_INIT4(light[3], light[2], light[1], light[0]); - - __m128i msrc_alpha = _mm_set1_epi16(src_alpha); - __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); do { @@ -998,7 +984,7 @@ public: local_vplce[3] = local_vplce[3] + local_vince[3]; __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_CALC_BLEND_ALPHA(fg); VEC_SHADE_SIMPLE(fg); __m128i bg = _mm_loadu_si128((const __m128i*)dest); @@ -1019,9 +1005,7 @@ public: else { VEC_SHADE_INIT4(light[3], light[2], light[1], light[0], shade_constants); - - __m128i msrc_alpha = _mm_set1_epi16(src_alpha); - __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); do { @@ -1036,7 +1020,7 @@ public: local_vplce[3] = local_vplce[3] + local_vince[3]; __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg, msrc_alpha, mdest_alpha); + VEC_CALC_BLEND_ALPHA(fg); VEC_SHADE(fg, shade_constants); __m128i bg = _mm_loadu_si128((const __m128i*)dest); diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index da5dd8ad7..16a9e63a6 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -203,7 +203,10 @@ const uint32_t *FTexture::GetPixelsBgra() PixelsBgra.resize(Width * Height); for (int i = 0; i < Width * Height; i++) { - PixelsBgra[i] = 0xff000000 | GPalette.BaseColors[indices[i]].d; + if (indices[i] != 0) + PixelsBgra[i] = 0xff000000 | GPalette.BaseColors[indices[i]].d; + else + PixelsBgra[i] = 0; } } return PixelsBgra.data(); From c70aa1fe99657e053e3b0aa1a9d00b307ab54bca Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 20 Jun 2016 08:24:02 +0200 Subject: [PATCH 0682/1509] Added bilinear filtering --- src/r_draw.cpp | 4 ++ src/r_draw.h | 36 ++++++++++ src/r_draw_rgba.cpp | 158 ++++++++++++++++++++++++++++++++------------ src/r_draw_rgba.h | 52 +++++++++++++++ src/r_segs.cpp | 54 +++++++++------ 5 files changed, 242 insertions(+), 62 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 7829e2b77..83c4ac8d4 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -162,6 +162,8 @@ fixed_t dc_destalpha; // Alpha value used by dc_destblend // first pixel in a column (possibly virtual) const BYTE* dc_source; +const BYTE* dc_source2; +uint32_t dc_texturefracx; BYTE* dc_dest; int dc_count; @@ -171,6 +173,8 @@ DWORD vince[4]; BYTE* palookupoffse[4]; fixed_t palookuplight[4]; const BYTE* bufplce[4]; +const BYTE* bufplce2[4]; +uint32_t buftexturefracx[4]; // just for profiling int dccount; diff --git a/src/r_draw.h b/src/r_draw.h index 99ee4d10d..d5ecbd289 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -71,6 +71,8 @@ extern "C" fixed_t dc_destalpha; // first pixel in a column extern "C" const BYTE* dc_source; +extern "C" const BYTE* dc_source2; +extern "C" uint32_t dc_texturefracx; extern "C" BYTE *dc_dest, *dc_destorg; extern "C" int dc_count; @@ -80,6 +82,8 @@ extern "C" DWORD vince[4]; extern "C" BYTE* palookupoffse[4]; extern "C" fixed_t palookuplight[4]; extern "C" const BYTE* bufplce[4]; +extern "C" const BYTE* bufplce2[4]; +extern "C" uint32_t buftexturefracx[4]; // [RH] Temporary buffer for column drawing extern "C" BYTE *dc_temp; @@ -374,4 +378,36 @@ void R_SetDSColorMapLight(FColormap *base_colormap, float light, int shade); void R_SetTranslationMap(lighttable_t *translation); +extern bool r_swtruecolor; +EXTERN_CVAR(Bool, r_bilinear); + +// Texture sampler state needed for bilinear filtering +struct SamplerSetup +{ + SamplerSetup() { } + SamplerSetup(fixed_t xoffset, bool magnifying, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)); + + const BYTE *source; + const BYTE *source2; + uint32_t texturefracx; +}; + +inline SamplerSetup::SamplerSetup(fixed_t xoffset, bool magnifying, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)) +{ + // Only do bilinear filtering if enabled and not a magnifying filter + if (!r_swtruecolor || !r_bilinear || magnifying) + { + source = getcol(texture, xoffset >> FRACBITS); + source2 = nullptr; + texturefracx = 0; + } + else + { + int tx = (xoffset - FRACUNIT / 2) >> FRACBITS; + source = getcol(texture, tx); + source2 = getcol(texture, tx + 1); + texturefracx = ((xoffset + FRACUNIT / 2) >> (FRACBITS - 4)) & 15; + } +} + #endif diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index f317a34d6..d85d9994b 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -58,6 +58,7 @@ extern float rw_lightstep; extern int wallshade; CVAR(Bool, r_multithreaded, true, 0) +CVAR(Bool, r_bilinear, false, 0) #ifndef NO_SSE @@ -1547,41 +1548,72 @@ public: uint32_t light = calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; - if (_xbits == 6 && _ybits == 6) + fixed_t xmagnitude = abs((fixed_t)xstep) >> (32 - _xbits - FRACBITS); + fixed_t ymagnitude = abs((fixed_t)ystep) >> (32 - _ybits - FRACBITS); + fixed_t magnitude = xmagnitude + ymagnitude; + + bool magnifying = !r_bilinear || magnitude >> (FRACBITS - 1) == 0; + if (magnifying) { - // 64x64 is the most common case by far, so special case it. - - do + if (_xbits == 6 && _ybits == 6) { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + // 64x64 is the most common case by far, so special case it. - // Lookup pixel from flat texture tile - *dest++ = shade_bgra(source[spot], light, shade_constants); + do + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); + // Lookup pixel from flat texture tile + *dest++ = shade_bgra(source[spot], light, shade_constants); + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + + do + { + // Current texture index in u,v. + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + + // Lookup pixel from flat texture tile + *dest++ = shade_bgra(source[spot], light, shade_constants); + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; - - do + if (_xbits == 6 && _ybits == 6) { - // Current texture index in u,v. - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + // 64x64 is the most common case by far, so special case it. - // Lookup pixel from flat texture tile - *dest++ = shade_bgra(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); + do + { + *dest++ = shade_bgra(sample_bilinear(source, xfrac, yfrac, 26, 26), light, shade_constants); + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + do + { + *dest++ = shade_bgra(sample_bilinear(source, xfrac, yfrac, 32 - _xbits, 32 - _ybits), light, shade_constants); + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } } }; @@ -2253,6 +2285,8 @@ class Vlinec1RGBACommand : public DrawerCommand DWORD _texturefrac; int _count; const BYTE * RESTRICT _source; + const BYTE * RESTRICT _source2; + uint32_t _texturefracx; BYTE * RESTRICT _dest; int vlinebits; int _pitch; @@ -2266,6 +2300,8 @@ public: _texturefrac = dc_texturefrac; _count = dc_count; _source = dc_source; + _source2 = dc_source2; + _texturefracx = dc_texturefracx; _dest = dc_dest; vlinebits = ::vlinebits; _pitch = dc_pitch; @@ -2282,6 +2318,8 @@ public: DWORD fracstep = _iscale * thread->num_cores; DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); const uint32 *source = (const uint32 *)_source; + const uint32 *source2 = (const uint32 *)_source2; + uint32_t texturefracx = _texturefracx; uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = vlinebits; int pitch = _pitch * thread->num_cores; @@ -2289,12 +2327,24 @@ public: uint32_t light = calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; - do + if (_source2 == nullptr) { - *dest = shade_bgra(source[frac >> bits], light, shade_constants); - frac += fracstep; - dest += pitch; - } while (--count); + do + { + *dest = shade_bgra(source[frac >> bits], light, shade_constants); + frac += fracstep; + dest += pitch; + } while (--count); + } + else + { + do + { + *dest = shade_bgra(sample_bilinear(source, source2, texturefracx, frac, bits), light, shade_constants); + frac += fracstep; + dest += pitch; + } while (--count); + } } }; @@ -2308,7 +2358,9 @@ class Vlinec4RGBACommand : public DrawerCommand fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; - const uint32 * RESTRICT bufplce[4]; + const uint32_t * RESTRICT bufplce[4]; + const uint32_t * RESTRICT bufplce2[4]; + uint32_t buftexturefracx[4]; public: Vlinec4RGBACommand() @@ -2323,7 +2375,9 @@ public: palookuplight[i] = ::palookuplight[i]; vplce[i] = ::vplce[i]; vince[i] = ::vince[i]; - bufplce[i] = (const uint32 *)::bufplce[i]; + bufplce[i] = (const uint32_t *)::bufplce[i]; + bufplce2[i] = (const uint32_t *)::bufplce2[i]; + buftexturefracx[i] = ::buftexturefracx[i]; } } @@ -2354,14 +2408,28 @@ public: local_vince[i] *= thread->num_cores; } - do + if (bufplce2[0] == nullptr) { - dest[0] = shade_bgra(bufplce[0][(place = local_vplce[0]) >> bits], light0, shade_constants); local_vplce[0] = place + local_vince[0]; - dest[1] = shade_bgra(bufplce[1][(place = local_vplce[1]) >> bits], light1, shade_constants); local_vplce[1] = place + local_vince[1]; - dest[2] = shade_bgra(bufplce[2][(place = local_vplce[2]) >> bits], light2, shade_constants); local_vplce[2] = place + local_vince[2]; - dest[3] = shade_bgra(bufplce[3][(place = local_vplce[3]) >> bits], light3, shade_constants); local_vplce[3] = place + local_vince[3]; - dest += pitch; - } while (--count); + do + { + dest[0] = shade_bgra(bufplce[0][(place = local_vplce[0]) >> bits], light0, shade_constants); local_vplce[0] = place + local_vince[0]; + dest[1] = shade_bgra(bufplce[1][(place = local_vplce[1]) >> bits], light1, shade_constants); local_vplce[1] = place + local_vince[1]; + dest[2] = shade_bgra(bufplce[2][(place = local_vplce[2]) >> bits], light2, shade_constants); local_vplce[2] = place + local_vince[2]; + dest[3] = shade_bgra(bufplce[3][(place = local_vplce[3]) >> bits], light3, shade_constants); local_vplce[3] = place + local_vince[3]; + dest += pitch; + } while (--count); + } + else + { + do + { + dest[0] = shade_bgra(sample_bilinear(bufplce[0], bufplce2[0], buftexturefracx[0], place = local_vplce[0], bits), light0, shade_constants); local_vplce[0] = place + local_vince[0]; + dest[1] = shade_bgra(sample_bilinear(bufplce[1], bufplce2[1], buftexturefracx[1], place = local_vplce[1], bits), light1, shade_constants); local_vplce[1] = place + local_vince[1]; + dest[2] = shade_bgra(sample_bilinear(bufplce[2], bufplce2[2], buftexturefracx[2], place = local_vplce[2], bits), light2, shade_constants); local_vplce[2] = place + local_vince[2]; + dest[3] = shade_bgra(sample_bilinear(bufplce[3], bufplce2[3], buftexturefracx[3], place = local_vplce[3], bits), light3, shade_constants); local_vplce[3] = place + local_vince[3]; + dest += pitch; + } while (--count); + } } }; @@ -3651,7 +3719,10 @@ void R_DrawSpan_rgba() #ifdef NO_SSE DrawerCommandQueue::QueueCommand(); #else - DrawerCommandQueue::QueueCommand(); + if (!r_bilinear) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); #endif } @@ -3705,7 +3776,10 @@ void vlinec4_rgba() #ifdef NO_SSE DrawerCommandQueue::QueueCommand(); #else - DrawerCommandQueue::QueueCommand(); + if (!r_bilinear) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); #endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 2527e84a6..a266ce878 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -426,6 +426,58 @@ FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) return 0xff000000 | (red << 16) | (green << 8) | blue; } +FORCEINLINE uint32_t sample_bilinear(const uint32_t *col0, const uint32_t *col1, uint32_t texturefracx, uint32_t texturefracy, int ybits) +{ + uint32_t half = 1 << (ybits - 1); + uint32_t y = (texturefracy - half) >> ybits; + + uint32_t p00 = col0[y]; + uint32_t p01 = col0[y + 1]; + uint32_t p10 = col1[y]; + uint32_t p11 = col1[y + 1]; + + uint32_t inv_b = texturefracx; + uint32_t inv_a = ((texturefracy + half) >> (ybits - 4)) & 15; + uint32_t a = 16 - inv_a; + uint32_t b = 16 - inv_b; + + uint32_t red = (RPART(p00) * a * b + RPART(p01) * inv_a * b + RPART(p10) * a * inv_b + RPART(p11) * inv_a * inv_b + 127) >> 8; + uint32_t green = (GPART(p00) * a * b + GPART(p01) * inv_a * b + GPART(p10) * a * inv_b + GPART(p11) * inv_a * inv_b + 127) >> 8; + uint32_t blue = (BPART(p00) * a * b + BPART(p01) * inv_a * b + BPART(p10) * a * inv_b + BPART(p11) * inv_a * inv_b + 127) >> 8; + uint32_t alpha = (APART(p00) * a * b + APART(p01) * inv_a * b + APART(p10) * a * inv_b + APART(p11) * inv_a * inv_b + 127) >> 8; + + return (alpha << 24) | (red << 16) | (green << 8) | blue; +} + +FORCEINLINE uint32_t sample_bilinear(const uint32_t *texture, dsfixed_t xfrac, dsfixed_t yfrac, int xbits, int ybits) +{ + int xshift = (32 - xbits); + int yshift = (32 - ybits); + int xmask = (1 << xshift) - 1; + int ymask = (1 << yshift) - 1; + uint32_t xhalf = 1 << (xbits - 1); + uint32_t yhalf = 1 << (ybits - 1); + uint32_t x = (xfrac - xhalf) >> xbits; + uint32_t y = (yfrac - yhalf) >> ybits; + + uint32_t p00 = texture[(y & ymask) + ((x & xmask) << yshift)]; + uint32_t p01 = texture[(y + 1 & ymask) + ((x & xmask) << yshift)]; + uint32_t p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)]; + uint32_t p11 = texture[(y + 1 & ymask) + (((x + 1) & xmask) << yshift)]; + + uint32_t inv_b = ((xfrac + xhalf) >> (xbits - 4)) & 15; + uint32_t inv_a = ((yfrac + yhalf) >> (ybits - 4)) & 15; + uint32_t a = 16 - inv_a; + uint32_t b = 16 - inv_b; + + uint32_t red = (RPART(p00) * a * b + RPART(p01) * inv_a * b + RPART(p10) * a * inv_b + RPART(p11) * inv_a * inv_b + 127) >> 8; + uint32_t green = (GPART(p00) * a * b + GPART(p01) * inv_a * b + GPART(p10) * a * inv_b + GPART(p11) * inv_a * inv_b + 127) >> 8; + uint32_t blue = (BPART(p00) * a * b + BPART(p01) * inv_a * b + BPART(p10) * a * inv_b + BPART(p11) * inv_a * inv_b + 127) >> 8; + uint32_t alpha = (APART(p00) * a * b + APART(p01) * inv_a * b + APART(p10) * a * inv_b + APART(p11) * inv_a * inv_b + 127) >> 8; + + return (alpha << 24) | (red << 16) | (green << 8) | blue; +} + // Calculate constants for a simple shade with gamma correction #define AVX_LINEAR_SHADE_SIMPLE_INIT(light) \ __m256 mlight_hi = _mm256_set_ps(1.0f, light * (1.0f/256.0f), light * (1.0f/256.0f), light * (1.0f/256.0f), 1.0f, light * (1.0f/256.0f), light * (1.0f/256.0f), light * (1.0f/256.0f)); \ diff --git a/src/r_segs.cpp b/src/r_segs.cpp index ad242b2f9..d71487bb9 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -58,6 +58,8 @@ CVAR(Bool, r_np2, true, 0) +EXTERN_CVAR(Bool, r_bilinear) + //CVAR (Int, ty, 8, 0) //CVAR (Int, tx, 8, 0) @@ -1066,14 +1068,16 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2) } // Draw a column with support for non-power-of-two ranges -uint32_t wallscan_drawcol1(int x, int y1, int y2, uint32_t uv_start, uint32_t uv_step, uint32_t uv_max, const BYTE *source, DWORD(*draw1column)()) +uint32_t wallscan_drawcol1(int x, int y1, int y2, uint32_t uv_start, uint32_t uv_step, uint32_t uv_max, const SamplerSetup &sampler, DWORD(*draw1column)()) { int pixelsize = r_swtruecolor ? 4 : 1; if (uv_max == 0) // power of two { int count = y2 - y1; - dc_source = source; + dc_source = sampler.source; + dc_source2 = sampler.source2; + dc_texturefracx = sampler.texturefracx; dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; dc_count = count; dc_iscale = uv_step; @@ -1097,7 +1101,9 @@ uint32_t wallscan_drawcol1(int x, int y1, int y2, uint32_t uv_start, uint32_t uv next_uv_wrap++; uint32_t count = MIN(left, next_uv_wrap); - dc_source = source; + dc_source = sampler.source; + dc_source2 = sampler.source2; + dc_texturefracx = sampler.texturefracx; dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; dc_count = count; dc_iscale = uv_step; @@ -1115,7 +1121,7 @@ uint32_t wallscan_drawcol1(int x, int y1, int y2, uint32_t uv_start, uint32_t uv } // Draw four columns with support for non-power-of-two ranges -void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_step, uint32_t uv_max, const BYTE **source, void(*draw4columns)()) +void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_step, uint32_t uv_max, const SamplerSetup *sampler, void(*draw4columns)()) { int pixelsize = r_swtruecolor ? 4 : 1; if (uv_max == 0) // power of two, no wrap handling needed @@ -1123,7 +1129,9 @@ void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_ste int count = y2 - y1; for (int i = 0; i < 4; i++) { - bufplce[i] = source[i]; + bufplce[i] = sampler[i].source; + bufplce2[i] = sampler[i].source2; + buftexturefracx[i] = sampler[i].texturefracx; vplce[i] = uv_pos[i]; vince[i] = uv_step[i]; @@ -1139,7 +1147,11 @@ void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_ste { dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; for (int i = 0; i < 4; i++) - bufplce[i] = source[i]; + { + bufplce[i] = sampler[i].source; + bufplce2[i] = sampler[i].source2; + buftexturefracx[i] = sampler[i].texturefracx; + } uint32_t left = y2 - y1; while (left > 0) @@ -1249,12 +1261,11 @@ void wallscan_any( if (!fixed) R_SetColorMapLight(basecolormap, light, wallshade); - const BYTE *source = getcol(rw_pic, (lwal[x] + xoffset) >> FRACBITS); - uint32_t uv_start, uv_step; calc_uv_start_and_step(y1, swal[x], yrepeat, uv_height, fracbits, uv_start, uv_step); - wallscan_drawcol1(x, y1, y2, uv_start, uv_step, uv_max, source, draw1column); + SamplerSetup sampler(lwal[x] + xoffset, uv_step >> (fracbits - 1) == 0, rw_pic, getcol); + wallscan_drawcol1(x, y1, y2, uv_start, uv_step, uv_max, sampler, draw1column); } // The aligned columns @@ -1264,10 +1275,6 @@ void wallscan_any( int y1[4] = { uwal[x], uwal[x + 1], uwal[x + 2], uwal[x + 3] }; int y2[4] = { dwal[x], dwal[x + 1], dwal[x + 2], dwal[x + 3] }; - const BYTE *source[4]; - for (int i = 0; i < 4; i++) - source[i] = getcol(rw_pic, (lwal[x + i] + xoffset) >> FRACBITS); - float lights[4]; for (int i = 0; i < 4; i++) { @@ -1276,8 +1283,16 @@ void wallscan_any( } uint32_t uv_pos[4], uv_step[4]; + int magnifying = 0; for (int i = 0; i < 4; i++) + { calc_uv_start_and_step(y1[i], swal[x + i], yrepeat, uv_height, fracbits, uv_pos[i], uv_step[i]); + magnifying |= uv_step[i] >> (fracbits - 1); + } + + SamplerSetup sampler[4]; + for (int i = 0; i < 4; i++) + sampler[i] = SamplerSetup(lwal[x + i] + xoffset, magnifying == 0, rw_pic, getcol); // Figure out where we vertically can start and stop drawing 4 columns in one go int middle_y1 = y1[0]; @@ -1305,7 +1320,7 @@ void wallscan_any( if (!fixed) R_SetColorMapLight(basecolormap, lights[i], wallshade); - wallscan_drawcol1(x + i, y1[i], y2[i], uv_pos[i], uv_step[i], uv_max, source[i], draw1column); + wallscan_drawcol1(x + i, y1[i], y2[i], uv_pos[i], uv_step[i], uv_max, sampler[i], draw1column); } continue; } @@ -1317,7 +1332,7 @@ void wallscan_any( R_SetColorMapLight(basecolormap, lights[i], wallshade); if (y1[i] < middle_y1) - uv_pos[i] = wallscan_drawcol1(x + i, y1[i], middle_y1, uv_pos[i], uv_step[i], uv_max, source[i], draw1column); + uv_pos[i] = wallscan_drawcol1(x + i, y1[i], middle_y1, uv_pos[i], uv_step[i], uv_max, sampler[i], draw1column); } // Draw the area where all 4 columns are active @@ -1337,7 +1352,7 @@ void wallscan_any( } } } - wallscan_drawcol4(x, middle_y1, middle_y2, uv_pos, uv_step, uv_max, source, draw4columns); + wallscan_drawcol4(x, middle_y1, middle_y2, uv_pos, uv_step, uv_max, sampler, draw4columns); // Draw the last rows where not all 4 columns are active for (int i = 0; i < 4; i++) @@ -1346,7 +1361,7 @@ void wallscan_any( R_SetColorMapLight(basecolormap, lights[i], wallshade); if (middle_y2 < y2[i]) - uv_pos[i] = wallscan_drawcol1(x + i, middle_y2, y2[i], uv_pos[i], uv_step[i], uv_max, source[i], draw1column); + uv_pos[i] = wallscan_drawcol1(x + i, middle_y2, y2[i], uv_pos[i], uv_step[i], uv_max, sampler[i], draw1column); } } @@ -1361,12 +1376,11 @@ void wallscan_any( if (!fixed) R_SetColorMapLight(basecolormap, light, wallshade); - const BYTE *source = getcol(rw_pic, (lwal[x] + xoffset) >> FRACBITS); - uint32_t uv_start, uv_step; calc_uv_start_and_step(y1, swal[x], yrepeat, uv_height, fracbits, uv_start, uv_step); - wallscan_drawcol1(x, y1, y2, uv_start, uv_step, uv_max, source, draw1column); + SamplerSetup sampler(lwal[x] + xoffset, uv_step >> (fracbits - 1) == 0, rw_pic, getcol); + wallscan_drawcol1(x, y1, y2, uv_start, uv_step, uv_max, sampler, draw1column); } NetUpdate (); From c1b5ba5b9064997cbe9802f1b5df59a88231d4e3 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 21 Jun 2016 06:22:43 +0200 Subject: [PATCH 0683/1509] Added SSE versions of bilinear filtering --- src/r_draw_rgba.cpp | 163 +++++++---- src/r_draw_rgba.h | 82 ++++++ src/r_draw_rgba_sse.h | 657 +++++++++++++++++++++++++++--------------- 3 files changed, 611 insertions(+), 291 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index d85d9994b..869edaba1 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -58,7 +58,7 @@ extern float rw_lightstep; extern int wallshade; CVAR(Bool, r_multithreaded, true, 0) -CVAR(Bool, r_bilinear, false, 0) +CVAR(Bool, r_bilinear, true, 0) #ifndef NO_SSE @@ -1680,43 +1680,70 @@ public: xstep = _xstep; ystep = _ystep; - if (_xbits == 6 && _ybits == 6) - { - // 64x64 is the most common case by far, so special case it. - do - { - uint32_t texdata; + fixed_t xmagnitude = abs((fixed_t)xstep) >> (32 - _xbits - FRACBITS); + fixed_t ymagnitude = abs((fixed_t)ystep) >> (32 - _ybits - FRACBITS); + fixed_t magnitude = xmagnitude + ymagnitude; - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - texdata = source[spot]; - if (texdata != 0) + bool magnifying = !r_bilinear || magnitude >> (FRACBITS - 1) == 0; + if (magnifying) + { + if (_xbits == 6 && _ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do { - *dest = shade_bgra(texdata, light, shade_constants); - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint32_t texdata; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + texdata = source[spot]; + *dest = alpha_blend(shade_bgra(texdata, light, shade_constants), *dest); + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + uint32_t texdata; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + texdata = source[spot]; + *dest = alpha_blend(shade_bgra(texdata, light, shade_constants), *dest); + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; - do + if (_xbits == 6 && _ybits == 6) { - uint32_t texdata; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - texdata = source[spot]; - if (texdata != 0) + // 64x64 is the most common case by far, so special case it. + do { - *dest = shade_bgra(texdata, light, shade_constants); - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); + *dest++ = alpha_blend(shade_bgra(sample_bilinear(source, xfrac, yfrac, 26, 26), light, shade_constants), *dest); + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + *dest++ = alpha_blend(shade_bgra(sample_bilinear(source, xfrac, yfrac, 32 - _xbits, 32 - _ybits), light, shade_constants), *dest); + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } } }; @@ -2439,6 +2466,8 @@ class Mvlinec1RGBACommand : public DrawerCommand DWORD _texturefrac; int _count; const BYTE * RESTRICT _source; + const BYTE * RESTRICT _source2; + uint32_t _texturefracx; BYTE * RESTRICT _dest; int mvlinebits; int _pitch; @@ -2452,6 +2481,8 @@ public: _texturefrac = dc_texturefrac; _count = dc_count; _source = dc_source; + _source2 = dc_source2; + _texturefracx = dc_texturefracx; _dest = dc_dest; mvlinebits = ::mvlinebits; _pitch = dc_pitch; @@ -2468,6 +2499,8 @@ public: DWORD fracstep = _iscale * thread->num_cores; DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); const uint32 *source = (const uint32 *)_source; + const uint32 *source2 = (const uint32 *)_source2; + uint32_t texturefracx = _texturefracx; uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int bits = mvlinebits; int pitch = _pitch * thread->num_cores; @@ -2475,13 +2508,25 @@ public: uint32_t light = calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; - do + if (_source2 == nullptr) { - uint32_t pix = source[frac >> bits]; - *dest = alpha_blend(shade_bgra(pix, light, shade_constants), *dest); - frac += fracstep; - dest += pitch; - } while (--count); + do + { + uint32_t pix = source[frac >> bits]; + *dest = alpha_blend(shade_bgra(pix, light, shade_constants), *dest); + frac += fracstep; + dest += pitch; + } while (--count); + } + else + { + do + { + *dest = alpha_blend(shade_bgra(sample_bilinear(source, source2, texturefracx, frac, bits), light, shade_constants), *dest); + frac += fracstep; + dest += pitch; + } while (--count); + } } }; @@ -2496,6 +2541,8 @@ class Mvlinec4RGBACommand : public DrawerCommand DWORD vplce[4]; DWORD vince[4]; const uint32 * RESTRICT bufplce[4]; + const uint32 * RESTRICT bufplce2[4]; + uint32_t buftexturefracx[4]; public: Mvlinec4RGBACommand() @@ -2511,6 +2558,8 @@ public: vplce[i] = ::vplce[i]; vince[i] = ::vince[i]; bufplce[i] = (const uint32 *)::bufplce[i]; + bufplce2[i] = (const uint32_t *)::bufplce2[i]; + buftexturefracx[i] = ::buftexturefracx[i]; } } @@ -2541,15 +2590,29 @@ public: local_vince[i] *= thread->num_cores; } - do + if (bufplce2[0] == nullptr) { - uint32_t pix; - pix = bufplce[0][(place = local_vplce[0]) >> bits]; dest[0] = alpha_blend(shade_bgra(pix, light0, shade_constants), dest[0]); local_vplce[0] = place + local_vince[0]; - pix = bufplce[1][(place = local_vplce[1]) >> bits]; dest[1] = alpha_blend(shade_bgra(pix, light1, shade_constants), dest[1]); local_vplce[1] = place + local_vince[1]; - pix = bufplce[2][(place = local_vplce[2]) >> bits]; dest[2] = alpha_blend(shade_bgra(pix, light2, shade_constants), dest[2]); local_vplce[2] = place + local_vince[2]; - pix = bufplce[3][(place = local_vplce[3]) >> bits]; dest[3] = alpha_blend(shade_bgra(pix, light3, shade_constants), dest[3]); local_vplce[3] = place + local_vince[3]; - dest += pitch; - } while (--count); + do + { + uint32_t pix; + pix = bufplce[0][(place = local_vplce[0]) >> bits]; dest[0] = alpha_blend(shade_bgra(pix, light0, shade_constants), dest[0]); local_vplce[0] = place + local_vince[0]; + pix = bufplce[1][(place = local_vplce[1]) >> bits]; dest[1] = alpha_blend(shade_bgra(pix, light1, shade_constants), dest[1]); local_vplce[1] = place + local_vince[1]; + pix = bufplce[2][(place = local_vplce[2]) >> bits]; dest[2] = alpha_blend(shade_bgra(pix, light2, shade_constants), dest[2]); local_vplce[2] = place + local_vince[2]; + pix = bufplce[3][(place = local_vplce[3]) >> bits]; dest[3] = alpha_blend(shade_bgra(pix, light3, shade_constants), dest[3]); local_vplce[3] = place + local_vince[3]; + dest += pitch; + } while (--count); + } + else + { + do + { + dest[0] = alpha_blend(shade_bgra(sample_bilinear(bufplce[0], bufplce2[0], buftexturefracx[0], place = local_vplce[0], bits), light0, shade_constants), dest[0]); local_vplce[0] = place + local_vince[0]; + dest[1] = alpha_blend(shade_bgra(sample_bilinear(bufplce[1], bufplce2[1], buftexturefracx[1], place = local_vplce[1], bits), light1, shade_constants), dest[1]); local_vplce[1] = place + local_vince[1]; + dest[2] = alpha_blend(shade_bgra(sample_bilinear(bufplce[2], bufplce2[2], buftexturefracx[2], place = local_vplce[2], bits), light2, shade_constants), dest[2]); local_vplce[2] = place + local_vince[2]; + dest[3] = alpha_blend(shade_bgra(sample_bilinear(bufplce[3], bufplce2[3], buftexturefracx[3], place = local_vplce[3], bits), light3, shade_constants), dest[3]); local_vplce[3] = place + local_vince[3]; + dest += pitch; + } while (--count); + } } }; @@ -3719,10 +3782,7 @@ void R_DrawSpan_rgba() #ifdef NO_SSE DrawerCommandQueue::QueueCommand(); #else - if (!r_bilinear) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); #endif } @@ -3776,10 +3836,7 @@ void vlinec4_rgba() #ifdef NO_SSE DrawerCommandQueue::QueueCommand(); #else - if (!r_bilinear) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); #endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index a266ce878..0900e8997 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -478,6 +478,88 @@ FORCEINLINE uint32_t sample_bilinear(const uint32_t *texture, dsfixed_t xfrac, d return (alpha << 24) | (red << 16) | (green << 8) | blue; } +#ifndef NO_SSE +FORCEINLINE __m128i sample_bilinear4_sse(const uint32_t **col0, const uint32_t **col1, uint32_t texturefracx[4], uint32_t texturefracy[4], int ybits) +{ + uint32_t half = 1 << (ybits - 1); + + __m128i m127 = _mm_set1_epi16(127); + __m128i fg = _mm_setzero_si128(); + for (int i = 0; i < 4; i++) + { + uint32_t y = (texturefracy[i] - half) >> ybits; + + uint32_t inv_b = texturefracx[i]; + uint32_t inv_a = ((texturefracy[i] + half) >> (ybits - 4)) & 15; + uint32_t a = 16 - inv_a; + uint32_t b = 16 - inv_b; + + uint32_t ab = a * b; + uint32_t invab = inv_a * b; + uint32_t ainvb = a * inv_b; + uint32_t invainvb = inv_a * inv_b; + __m128i ab_invab = _mm_set_epi16(invab, invab, invab, invab, ab, ab, ab, ab); + __m128i ainvb_invainvb = _mm_set_epi16(invainvb, invainvb, invainvb, invainvb, ainvb, ainvb, ainvb, ainvb); + + __m128i p0 = _mm_unpacklo_epi8(_mm_loadl_epi64((const __m128i*)(col0[i] + y)), _mm_setzero_si128()); + __m128i p1 = _mm_unpacklo_epi8(_mm_loadl_epi64((const __m128i*)(col1[i] + y)), _mm_setzero_si128()); + + __m128i tmp = _mm_adds_epu16(_mm_mullo_epi16(p0, ab_invab), _mm_mullo_epi16(p1, ainvb_invainvb)); + __m128i color = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_srli_si128(tmp, 8), tmp), m127), 8); + + fg = _mm_or_si128(_mm_srli_si128(fg, 4), _mm_slli_si128(_mm_packus_epi16(color, _mm_setzero_si128()), 12)); + } + return fg; +} + +FORCEINLINE __m128i sample_bilinear4_sse(const uint32_t *texture, dsfixed_t &xfrac, dsfixed_t &yfrac, dsfixed_t xstep, dsfixed_t ystep, int xbits, int ybits) +{ + int xshift = (32 - xbits); + int yshift = (32 - ybits); + int xmask = (1 << xshift) - 1; + int ymask = (1 << yshift) - 1; + uint32_t xhalf = 1 << (xbits - 1); + uint32_t yhalf = 1 << (ybits - 1); + + __m128i m127 = _mm_set1_epi16(127); + __m128i fg = _mm_setzero_si128(); + for (int i = 0; i < 4; i++) + { + uint32_t x = (xfrac - xhalf) >> xbits; + uint32_t y = (yfrac - yhalf) >> ybits; + + uint32_t p00 = texture[(y & ymask) + ((x & xmask) << yshift)]; + uint32_t p01 = texture[(y + 1 & ymask) + ((x & xmask) << yshift)]; + uint32_t p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)]; + uint32_t p11 = texture[(y + 1 & ymask) + (((x + 1) & xmask) << yshift)]; + + uint32_t inv_b = ((xfrac + xhalf) >> (xbits - 4)) & 15; + uint32_t inv_a = ((yfrac + yhalf) >> (ybits - 4)) & 15; + uint32_t a = 16 - inv_a; + uint32_t b = 16 - inv_b; + + uint32_t ab = a * b; + uint32_t invab = inv_a * b; + uint32_t ainvb = a * inv_b; + uint32_t invainvb = inv_a * inv_b; + __m128i ab_invab = _mm_set_epi16(invab, invab, invab, invab, ab, ab, ab, ab); + __m128i ainvb_invainvb = _mm_set_epi16(invainvb, invainvb, invainvb, invainvb, ainvb, ainvb, ainvb, ainvb); + + __m128i p0 = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, p01, p00), _mm_setzero_si128()); + __m128i p1 = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, p11, p10), _mm_setzero_si128()); + + __m128i tmp = _mm_adds_epu16(_mm_mullo_epi16(p0, ab_invab), _mm_mullo_epi16(p1, ainvb_invainvb)); + __m128i color = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_srli_si128(tmp, 8), tmp), m127), 8); + + fg = _mm_or_si128(_mm_srli_si128(fg, 4), _mm_slli_si128(_mm_packus_epi16(color, _mm_setzero_si128()), 12)); + + xfrac += xstep; + yfrac += ystep; + } + return fg; +} +#endif + // Calculate constants for a simple shade with gamma correction #define AVX_LINEAR_SHADE_SIMPLE_INIT(light) \ __m256 mlight_hi = _mm256_set_ps(1.0f, light * (1.0f/256.0f), light * (1.0f/256.0f), light * (1.0f/256.0f), 1.0f, light * (1.0f/256.0f), light * (1.0f/256.0f), light * (1.0f/256.0f)); \ diff --git a/src/r_draw_rgba_sse.h b/src/r_draw_rgba_sse.h index 220638c75..721471724 100644 --- a/src/r_draw_rgba_sse.h +++ b/src/r_draw_rgba_sse.h @@ -71,195 +71,284 @@ public: uint32_t light = calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; - if (_xbits == 6 && _ybits == 6) + fixed_t xmagnitude = abs((fixed_t)xstep) >> (32 - _xbits - FRACBITS); + fixed_t ymagnitude = abs((fixed_t)ystep) >> (32 - _ybits - FRACBITS); + fixed_t magnitude = xmagnitude + ymagnitude; + + bool magnifying = !r_bilinear || magnitude >> (FRACBITS - 1) == 0; + if (magnifying) { - // 64x64 is the most common case by far, so special case it. - - int sse_count = count / 4; - count -= sse_count * 4; - - if (shade_constants.simple_shade) + if (_xbits == 6 && _ybits == 6) { - VEC_SHADE_SIMPLE_INIT(light); + // 64x64 is the most common case by far, so special case it. - while (sse_count--) + int sse_count = count / 4; + count -= sse_count * 4; + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT(light); + + while (sse_count--) + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p0 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p1 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p2 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p3 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); + VEC_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + + // Next step in u,v. + dest += 4; + } + } + else + { + VEC_SHADE_INIT(light, shade_constants); + + while (sse_count--) + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p0 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p1 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p2 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t p3 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); + VEC_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + + // Next step in u,v. + dest += 4; + } + } + + if (count == 0) + return; + + do { // Current texture index in u,v. spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p0 = source[spot]; - xfrac += xstep; - yfrac += ystep; - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p1 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p2 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p3 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - VEC_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); + // Lookup pixel from flat texture tile + *dest++ = shade_bgra(source[spot], light, shade_constants); // Next step in u,v. - dest += 4; - } + xfrac += xstep; + yfrac += ystep; + } while (--count); } else { - VEC_SHADE_INIT(light, shade_constants); + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; - while (sse_count--) + int sse_count = count / 4; + count -= sse_count * 4; + + if (shade_constants.simple_shade) + { + VEC_SHADE_SIMPLE_INIT(light); + + while (sse_count--) + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p0 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p1 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p2 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p3 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + // Lookup pixel from flat texture tile + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); + VEC_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += 4; + } + } + else + { + VEC_SHADE_INIT(light, shade_constants); + + while (sse_count--) + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p0 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p1 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p2 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t p3 = source[spot]; + xfrac += xstep; + yfrac += ystep; + + // Lookup pixel from flat texture tile + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); + VEC_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + dest += 4; + } + } + + if (count == 0) + return; + + do { // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p0 = source[spot]; - xfrac += xstep; - yfrac += ystep; + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p1 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p2 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p3 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - VEC_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); + // Lookup pixel from flat texture tile + *dest++ = shade_bgra(source[spot], light, shade_constants); // Next step in u,v. - dest += 4; - } + xfrac += xstep; + yfrac += ystep; + } while (--count); } - - if (count == 0) - return; - - do - { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - - // Lookup pixel from flat texture tile - *dest++ = shade_bgra(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; - - int sse_count = count / 4; - count -= sse_count * 4; - - if (shade_constants.simple_shade) + if (_xbits == 6 && _ybits == 6) { - VEC_SHADE_SIMPLE_INIT(light); + // 64x64 is the most common case by far, so special case it. - while (sse_count--) + int sse_count = count / 4; + count -= sse_count * 4; + + if (shade_constants.simple_shade) { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p0 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p1 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p2 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p3 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - // Lookup pixel from flat texture tile - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - VEC_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += 4; + VEC_SHADE_SIMPLE_INIT(light); + while (sse_count--) + { + __m128i fg = sample_bilinear4_sse(source, xfrac, yfrac, xstep, ystep, 26, 26); + VEC_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += 4; + } } + else + { + VEC_SHADE_INIT(light, shade_constants); + while (sse_count--) + { + __m128i fg = sample_bilinear4_sse(source, xfrac, yfrac, xstep, ystep, 26, 26); + VEC_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + dest += 4; + } + } + + if (count == 0) + return; + + do + { + *dest++ = shade_bgra(sample_bilinear(source, xfrac, yfrac, 26, 26), light, shade_constants); + xfrac += xstep; + yfrac += ystep; + } while (--count); } else { - VEC_SHADE_INIT(light, shade_constants); + int sse_count = count / 4; + count -= sse_count * 4; - while (sse_count--) + if (shade_constants.simple_shade) { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p0 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p1 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p2 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p3 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - // Lookup pixel from flat texture tile - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - VEC_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - dest += 4; + VEC_SHADE_SIMPLE_INIT(light); + while (sse_count--) + { + __m128i fg = sample_bilinear4_sse(source, xfrac, yfrac, xstep, ystep, 32 -_xbits, 32 - _ybits); + VEC_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += 4; + } } + else + { + VEC_SHADE_INIT(light, shade_constants); + while (sse_count--) + { + __m128i fg = sample_bilinear4_sse(source, xfrac, yfrac, xstep, ystep, 32 - _xbits, 32 - _ybits); + VEC_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + dest += 4; + } + } + + if (count == 0) + return; + + do + { + *dest++ = shade_bgra(sample_bilinear(source, xfrac, yfrac, 32 - _xbits, 32 - _ybits), light, shade_constants); + xfrac += xstep; + yfrac += ystep; + } while (--count); } - - if (count == 0) - return; - - do - { - // Current texture index in u,v. - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - - // Lookup pixel from flat texture tile - *dest++ = shade_bgra(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); } } }; @@ -275,6 +364,8 @@ class VecCommand(Vlinec4RGBA) : public DrawerCommand DWORD vplce[4]; DWORD vince[4]; const uint32 * RESTRICT bufplce[4]; + const uint32_t * RESTRICT bufplce2[4]; + uint32_t buftexturefracx[4]; public: VecCommand(Vlinec4RGBA)() @@ -290,6 +381,8 @@ public: vplce[i] = ::vplce[i]; vince[i] = ::vince[i]; bufplce[i] = (const uint32 *)::bufplce[i]; + bufplce2[i] = (const uint32_t *)::bufplce2[i]; + buftexturefracx[i] = ::buftexturefracx[i]; } } @@ -319,57 +412,97 @@ public: local_vince[i] *= thread->num_cores; } - if (shade_constants.simple_shade) + if (bufplce2[0] == nullptr) { - VEC_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); - do + if (shade_constants.simple_shade) { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; + VEC_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; - uint32_t p0 = bufplce[0][place0 >> bits]; - uint32_t p1 = bufplce[1][place1 >> bits]; - uint32_t p2 = bufplce[2][place2 >> bits]; - uint32_t p3 = bufplce[3][place3 >> bits]; + uint32_t p0 = bufplce[0][place0 >> bits]; + uint32_t p1 = bufplce[1][place1 >> bits]; + uint32_t p2 = bufplce[2][place2 >> bits]; + uint32_t p3 = bufplce[3][place3 >> bits]; - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - VEC_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += pitch; - } while (--count); + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); + VEC_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += pitch; + } while (--count); + } + else + { + VEC_SHADE_INIT4(light3, light2, light1, light0, shade_constants); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; + + uint32_t p0 = bufplce[0][place0 >> bits]; + uint32_t p1 = bufplce[1][place1 >> bits]; + uint32_t p2 = bufplce[2][place2 >> bits]; + uint32_t p3 = bufplce[3][place3 >> bits]; + + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; + + __m128i fg = _mm_set_epi32(p3, p2, p1, p0); + VEC_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + dest += pitch; + } while (--count); + } } else { - VEC_SHADE_INIT4(light3, light2, light1, light0, shade_constants); - do + if (shade_constants.simple_shade) { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; + VEC_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); + do + { + __m128i fg = sample_bilinear4_sse(bufplce, bufplce2, buftexturefracx, local_vplce, bits); - uint32_t p0 = bufplce[0][place0 >> bits]; - uint32_t p1 = bufplce[1][place1 >> bits]; - uint32_t p2 = bufplce[2][place2 >> bits]; - uint32_t p3 = bufplce[3][place3 >> bits]; + local_vplce[0] = local_vplce[0] + local_vince[0]; + local_vplce[1] = local_vplce[1] + local_vince[1]; + local_vplce[2] = local_vplce[2] + local_vince[2]; + local_vplce[3] = local_vplce[3] + local_vince[3]; - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; + VEC_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += pitch; + } while (--count); + } + else + { + VEC_SHADE_INIT4(light3, light2, light1, light0, shade_constants); + do + { + __m128i fg = sample_bilinear4_sse(bufplce, bufplce2, buftexturefracx, local_vplce, bits); - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - VEC_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - dest += pitch; - } while (--count); + local_vplce[0] = local_vplce[0] + local_vince[0]; + local_vplce[1] = local_vplce[1] + local_vince[1]; + local_vplce[2] = local_vplce[2] + local_vince[2]; + local_vplce[3] = local_vplce[3] + local_vince[3]; + + VEC_SHADE(fg, shade_constants); + _mm_storeu_si128((__m128i*)dest, fg); + dest += pitch; + } while (--count); + } } } }; @@ -385,6 +518,8 @@ class VecCommand(Mvlinec4RGBA) : public DrawerCommand DWORD vplce[4]; DWORD vince[4]; const uint32 * RESTRICT bufplce[4]; + const uint32 * RESTRICT bufplce2[4]; + uint32_t buftexturefracx[4]; public: VecCommand(Mvlinec4RGBA)() @@ -400,6 +535,8 @@ public: vplce[i] = ::vplce[i]; vince[i] = ::vince[i]; bufplce[i] = (const uint32 *)::bufplce[i]; + bufplce2[i] = (const uint32_t *)::bufplce2[i]; + buftexturefracx[i] = ::buftexturefracx[i]; } } @@ -429,61 +566,105 @@ public: local_vince[i] *= thread->num_cores; } - if (shade_constants.simple_shade) + if (bufplce2[0] == nullptr) { - VEC_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); - do + if (shade_constants.simple_shade) { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; + VEC_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; - uint32_t pix0 = bufplce[0][place0 >> bits]; - uint32_t pix1 = bufplce[1][place1 >> bits]; - uint32_t pix2 = bufplce[2][place2 >> bits]; - uint32_t pix3 = bufplce[3][place3 >> bits]; + uint32_t pix0 = bufplce[0][place0 >> bits]; + uint32_t pix1 = bufplce[1][place1 >> bits]; + uint32_t pix2 = bufplce[2][place2 >> bits]; + uint32_t pix3 = bufplce[3][place3 >> bits]; - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; - __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - VEC_SHADE_SIMPLE(fg); - VEC_ALPHA_BLEND(fg, bg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += pitch; - } while (--count); + __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + VEC_SHADE_SIMPLE(fg); + VEC_ALPHA_BLEND(fg, bg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += pitch; + } while (--count); + } + else + { + VEC_SHADE_INIT4(light3, light2, light1, light0, shade_constants); + do + { + DWORD place0 = local_vplce[0]; + DWORD place1 = local_vplce[1]; + DWORD place2 = local_vplce[2]; + DWORD place3 = local_vplce[3]; + + uint32_t pix0 = bufplce[0][place0 >> bits]; + uint32_t pix1 = bufplce[1][place1 >> bits]; + uint32_t pix2 = bufplce[2][place2 >> bits]; + uint32_t pix3 = bufplce[3][place3 >> bits]; + + local_vplce[0] = place0 + local_vince[0]; + local_vplce[1] = place1 + local_vince[1]; + local_vplce[2] = place2 + local_vince[2]; + local_vplce[3] = place3 + local_vince[3]; + + __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + VEC_SHADE(fg, shade_constants); + VEC_ALPHA_BLEND(fg, bg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += pitch; + } while (--count); + } } else { - VEC_SHADE_INIT4(light3, light2, light1, light0, shade_constants); - do + if (shade_constants.simple_shade) { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; + VEC_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); + do + { + __m128i fg = sample_bilinear4_sse(bufplce, bufplce2, buftexturefracx, local_vplce, bits); - uint32_t pix0 = bufplce[0][place0 >> bits]; - uint32_t pix1 = bufplce[1][place1 >> bits]; - uint32_t pix2 = bufplce[2][place2 >> bits]; - uint32_t pix3 = bufplce[3][place3 >> bits]; + local_vplce[0] = local_vplce[0] + local_vince[0]; + local_vplce[1] = local_vplce[1] + local_vince[1]; + local_vplce[2] = local_vplce[2] + local_vince[2]; + local_vplce[3] = local_vplce[3] + local_vince[3]; - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + VEC_SHADE_SIMPLE(fg); + VEC_ALPHA_BLEND(fg, bg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += pitch; + } while (--count); + } + else + { + VEC_SHADE_INIT4(light3, light2, light1, light0, shade_constants); + do + { + __m128i fg = sample_bilinear4_sse(bufplce, bufplce2, buftexturefracx, local_vplce, bits); - __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - VEC_SHADE(fg, shade_constants); - VEC_ALPHA_BLEND(fg, bg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += pitch; - } while (--count); + local_vplce[0] = local_vplce[0] + local_vince[0]; + local_vplce[1] = local_vplce[1] + local_vince[1]; + local_vplce[2] = local_vplce[2] + local_vince[2]; + local_vplce[3] = local_vplce[3] + local_vince[3]; + + __m128i bg = _mm_loadu_si128((const __m128i*)dest); + VEC_SHADE(fg, shade_constants); + VEC_ALPHA_BLEND(fg, bg); + _mm_storeu_si128((__m128i*)dest, fg); + dest += pitch; + } while (--count); + } } } }; From d15af1524cebd3e000bbd7971d9b5e51205cfde6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 21 Jun 2016 09:38:47 +0200 Subject: [PATCH 0684/1509] Added mipmap support for floor and ceiling --- src/r_draw.cpp | 6 +-- src/r_draw.h | 2 +- src/r_draw_rgba.cpp | 119 +++++++++++++++++++++++++++++++++++++----- src/r_draw_rgba.h | 33 ++++++++++++ src/r_draw_rgba_sse.h | 9 ++-- src/r_plane.cpp | 5 +- src/r_swrenderer.cpp | 1 + src/v_draw.cpp | 2 +- 8 files changed, 150 insertions(+), 27 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 83c4ac8d4..73ddb72f8 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -1062,13 +1062,13 @@ extern "C" BYTE *ds_curcolormap, *ds_cursource, *ds_curtiltedsource; // //========================================================================== -void R_SetSpanSource(const BYTE *pixels) +void R_SetSpanSource(FTexture *tex) { - ds_source = pixels; + R_SetMipmappedSpanSource(tex); #ifdef X86_ASM if (!r_swtruecolor && ds_cursource != ds_source) { - R_SetSpanSource_ASM(pixels); + R_SetSpanSource_ASM(ds_source); } #endif } diff --git a/src/r_draw.h b/src/r_draw.h index d5ecbd289..b662ddcee 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -122,7 +122,7 @@ extern void (*R_DrawTranslatedColumn)(void); extern void (*R_DrawSpan)(void); void R_SetupSpanBits(FTexture *tex); void R_SetSpanColormap(FDynamicColormap *colormap, int shade); -void R_SetSpanSource(const BYTE *pixels); +void R_SetSpanSource(FTexture *tex); // Span drawing for masked textures. extern void (*R_DrawSpanMasked)(void); diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 869edaba1..9cdcdbf80 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -59,6 +59,7 @@ extern int wallshade; CVAR(Bool, r_multithreaded, true, 0) CVAR(Bool, r_bilinear, true, 0) +CVAR(Bool, r_mipmap, true, 0) #ifndef NO_SSE @@ -1502,6 +1503,7 @@ class DrawSpanRGBACommand : public DrawerCommand BYTE * RESTRICT _destorg; fixed_t _light; ShadeConstants _shade_constants; + bool _magnifying; public: DrawSpanRGBACommand() @@ -1519,6 +1521,7 @@ public: _destorg = dc_destorg; _light = ds_light; _shade_constants = ds_shade_constants; + _magnifying = !span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep); } void Execute(DrawerThread *thread) override @@ -1548,12 +1551,7 @@ public: uint32_t light = calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; - fixed_t xmagnitude = abs((fixed_t)xstep) >> (32 - _xbits - FRACBITS); - fixed_t ymagnitude = abs((fixed_t)ystep) >> (32 - _ybits - FRACBITS); - fixed_t magnitude = xmagnitude + ymagnitude; - - bool magnifying = !r_bilinear || magnitude >> (FRACBITS - 1) == 0; - if (magnifying) + if (_magnifying) { if (_xbits == 6 && _ybits == 6) { @@ -1634,6 +1632,7 @@ class DrawSpanMaskedRGBACommand : public DrawerCommand fixed_t _ystep; int _xbits; int _ybits; + bool _magnifying; public: DrawSpanMaskedRGBACommand() @@ -1651,6 +1650,7 @@ public: _ystep = ds_ystep; _xbits = ds_xbits; _ybits = ds_ybits; + _magnifying = !span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep); } void Execute(DrawerThread *thread) override @@ -1680,12 +1680,7 @@ public: xstep = _xstep; ystep = _ystep; - fixed_t xmagnitude = abs((fixed_t)xstep) >> (32 - _xbits - FRACBITS); - fixed_t ymagnitude = abs((fixed_t)ystep) >> (32 - _ybits - FRACBITS); - fixed_t magnitude = xmagnitude + ymagnitude; - - bool magnifying = !r_bilinear || magnitude >> (FRACBITS - 1) == 0; - if (magnifying) + if (_magnifying) { if (_xbits == 6 && _ybits == 6) { @@ -3677,6 +3672,106 @@ void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) ///////////////////////////////////////////////////////////////////////////// +#include + +class MipmappedTexture +{ +public: + MipmappedTexture(FTexture *texture) + { + const uint32_t *base_texture = texture->GetPixelsBgra(); + Width = texture->GetWidth(); + Height = texture->GetHeight(); + Levels = MAX(texture->WidthBits, texture->HeightBits); + + // I bet there is a better way to calculate this.. + int buffersize = 0; + for (int i = 0; i < Levels; i++) + { + int w = MAX(Width >> i, 2); // 2 instead of 1 because we texelGather in 2x2 blocks + int h = MAX(Height >> i, 2); + buffersize += w * h; + } + Pixels.resize(buffersize); + + // Base level: + memcpy(Pixels.data(), base_texture, Width * Height * 4); + + // Mipmap levels: + uint32_t *src = Pixels.data(); + uint32_t *dest = src + Width * Height; + for (int i = 1; i < Levels; i++) + { + int srch = MAX(Height >> (i - 1), 2); + int w = MAX(Width >> i, 2); + int h = MAX(Height >> i, 2); + + for (int x = 0; x < w; x++) + { + for (int y = 0; y < h; y++) + { + uint32_t src00 = src[y * 2 + x * 2 * srch]; + uint32_t src01 = src[y * 2 + 1 + x * 2 * srch]; + uint32_t src10 = src[y * 2 + (x * 2 + 1) * srch]; + uint32_t src11 = src[y * 2 + 1 + (x * 2 + 1) * srch]; + + uint32_t alpha = (APART(src00) + APART(src01) + APART(src10) + APART(src11) + 2) / 4; + uint32_t red = (RPART(src00) + RPART(src01) + RPART(src10) + RPART(src11) + 2) / 4; + uint32_t green = (GPART(src00) + GPART(src01) + GPART(src10) + GPART(src11) + 2) / 4; + uint32_t blue = (BPART(src00) + BPART(src01) + BPART(src10) + BPART(src11) + 2) / 4; + + dest[y + x * h] = (alpha << 24) | (red << 16) | (green << 8) | blue; + } + } + + src = dest; + dest += w * h; + } + } + + int Width = 0; + int Height = 0; + int Levels = 0; + std::vector Pixels; +}; + +class TextureMipmapper +{ +public: + static std::map> &Textures() + { + static std::map> textures; + return textures; + } +}; + +void R_SetMipmappedSpanSource(FTexture *tex) +{ + if (r_swtruecolor) + { + if (r_mipmap) + { + auto &mipmap = TextureMipmapper::Textures()[tex]; + if (!mipmap) + mipmap = std::make_shared(tex); + ds_source = (const BYTE*)mipmap->Pixels.data(); + } + else + { + ds_source = (const BYTE*)tex->GetPixelsBgra(); + } + } + else + { + ds_source = tex->GetPixels(); + } +} + +void R_ClearMipmapCache() +{ + TextureMipmapper::Textures().clear(); +} + void R_BeginDrawerCommands() { DrawerCommandQueue::Begin(); diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 0900e8997..37dc1a70a 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -108,6 +108,9 @@ void tmvline4_revsubclamp_rgba(); void R_FillColumnHoriz_rgba(); void R_FillSpan_rgba(); +void R_SetMipmappedSpanSource(FTexture *tex); +void R_ClearMipmapCache(); + ///////////////////////////////////////////////////////////////////////////// // Multithreaded rendering infrastructure: @@ -185,6 +188,7 @@ public: }; EXTERN_CVAR(Bool, r_multithreaded) +EXTERN_CVAR(Bool, r_mipmap) // Manages queueing up commands and executing them on worker threads class DrawerCommandQueue @@ -426,6 +430,35 @@ FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) return 0xff000000 | (red << 16) | (green << 8) | blue; } +inline bool span_sampler_setup(const uint32_t *&source, int &xbits, int &ybits, fixed_t xstep, fixed_t ystep) +{ + if (!r_bilinear) + return false; + + // Is this a magfilter or minfilter? + fixed_t xmagnitude = abs(xstep) >> (32 - xbits - FRACBITS); + fixed_t ymagnitude = abs(ystep) >> (32 - ybits - FRACBITS); + fixed_t magnitude = (xmagnitude + ymagnitude) * 3 + (1 << (FRACBITS -1)); + if (magnitude >> FRACBITS == 0) + return false; + + if (r_mipmap) + { + int level = magnitude >> (FRACBITS + 1); + while (level != 0) + { + if (xbits <= 2 || ybits <= 2) + break; + + source += (1 << (xbits)) * (1 << (ybits)); + xbits -= 1; + ybits -= 1; + level >>= 1; + } + } + return true; +} + FORCEINLINE uint32_t sample_bilinear(const uint32_t *col0, const uint32_t *col1, uint32_t texturefracx, uint32_t texturefracy, int ybits) { uint32_t half = 1 << (ybits - 1); diff --git a/src/r_draw_rgba_sse.h b/src/r_draw_rgba_sse.h index 721471724..4002a5535 100644 --- a/src/r_draw_rgba_sse.h +++ b/src/r_draw_rgba_sse.h @@ -25,6 +25,7 @@ class VecCommand(DrawSpanRGBA) : public DrawerCommand BYTE * RESTRICT _destorg; fixed_t _light; ShadeConstants _shade_constants; + bool _magnifying; public: VecCommand(DrawSpanRGBA)() @@ -42,6 +43,7 @@ public: _destorg = dc_destorg; _light = ds_light; _shade_constants = ds_shade_constants; + _magnifying = !span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep); } void Execute(DrawerThread *thread) override @@ -71,12 +73,7 @@ public: uint32_t light = calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; - fixed_t xmagnitude = abs((fixed_t)xstep) >> (32 - _xbits - FRACBITS); - fixed_t ymagnitude = abs((fixed_t)ystep) >> (32 - _ybits - FRACBITS); - fixed_t magnitude = xmagnitude + ymagnitude; - - bool magnifying = !r_bilinear || magnitude >> (FRACBITS - 1) == 0; - if (magnifying) + if (_magnifying) { if (_xbits == 6 && _ybits == 6) { diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 807066f77..6913db918 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1178,10 +1178,7 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske R_SetupSpanBits(tex); double xscale = pl->xform.xScale * tex->Scale.X; double yscale = pl->xform.yScale * tex->Scale.Y; - if (r_swtruecolor) - ds_source = (const BYTE*)tex->GetPixelsBgra(); - else - ds_source = tex->GetPixels(); + R_SetSpanSource(tex); basecolormap = pl->colormap; planeshade = LIGHT2SHADE(pl->lightlevel); diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index c81d2a110..c1e2d4bd0 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -170,6 +170,7 @@ void FSoftwareRenderer::RenderView(player_t *player) R_InitColumnDrawers(); } + R_ClearMipmapCache(); R_BeginDrawerCommands(); R_RenderActorView (player->mo); // [RH] Let cameras draw onto textures that were visible this frame. diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 6a8dad047..fd12a1587 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -1404,7 +1404,7 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, R_SetSpanColormap(colormap, clamp(shade >> FRACBITS, 0, NUMCOLORMAPS - 1)); else R_SetSpanColormap(&identitycolormap, 0); - R_SetSpanSource(r_swtruecolor ? (const BYTE*)tex->GetPixelsBgra() : tex->GetPixels()); + R_SetSpanSource(tex); scalex = double(1u << (32 - ds_xbits)) / scalex; scaley = double(1u << (32 - ds_ybits)) / scaley; ds_xstep = xs_RoundToInt(cosrot * scalex); From c235de5c22f6f7aebbf36aa3f80a45e0f5f6accf Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 21 Jun 2016 21:55:08 +0200 Subject: [PATCH 0685/1509] Native mipmap support to FTexture --- src/r_draw.cpp | 2 +- src/r_draw_rgba.cpp | 100 ---------------------- src/r_draw_rgba.h | 157 +++++++++++++++++------------------ src/r_draw_rgba_sse.h | 28 +++++-- src/r_swrenderer.cpp | 1 - src/textures/jpegtexture.cpp | 4 +- src/textures/pngtexture.cpp | 3 +- src/textures/texture.cpp | 68 ++++++++++++++- src/textures/textures.h | 4 + 9 files changed, 171 insertions(+), 196 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 73ddb72f8..55353a006 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -1064,7 +1064,7 @@ extern "C" BYTE *ds_curcolormap, *ds_cursource, *ds_curtiltedsource; void R_SetSpanSource(FTexture *tex) { - R_SetMipmappedSpanSource(tex); + ds_source = r_swtruecolor ? (const BYTE*)tex->GetPixelsBgra() : tex->GetPixels(); #ifdef X86_ASM if (!r_swtruecolor && ds_cursource != ds_source) { diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 9cdcdbf80..8144c096d 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -3672,106 +3672,6 @@ void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) ///////////////////////////////////////////////////////////////////////////// -#include - -class MipmappedTexture -{ -public: - MipmappedTexture(FTexture *texture) - { - const uint32_t *base_texture = texture->GetPixelsBgra(); - Width = texture->GetWidth(); - Height = texture->GetHeight(); - Levels = MAX(texture->WidthBits, texture->HeightBits); - - // I bet there is a better way to calculate this.. - int buffersize = 0; - for (int i = 0; i < Levels; i++) - { - int w = MAX(Width >> i, 2); // 2 instead of 1 because we texelGather in 2x2 blocks - int h = MAX(Height >> i, 2); - buffersize += w * h; - } - Pixels.resize(buffersize); - - // Base level: - memcpy(Pixels.data(), base_texture, Width * Height * 4); - - // Mipmap levels: - uint32_t *src = Pixels.data(); - uint32_t *dest = src + Width * Height; - for (int i = 1; i < Levels; i++) - { - int srch = MAX(Height >> (i - 1), 2); - int w = MAX(Width >> i, 2); - int h = MAX(Height >> i, 2); - - for (int x = 0; x < w; x++) - { - for (int y = 0; y < h; y++) - { - uint32_t src00 = src[y * 2 + x * 2 * srch]; - uint32_t src01 = src[y * 2 + 1 + x * 2 * srch]; - uint32_t src10 = src[y * 2 + (x * 2 + 1) * srch]; - uint32_t src11 = src[y * 2 + 1 + (x * 2 + 1) * srch]; - - uint32_t alpha = (APART(src00) + APART(src01) + APART(src10) + APART(src11) + 2) / 4; - uint32_t red = (RPART(src00) + RPART(src01) + RPART(src10) + RPART(src11) + 2) / 4; - uint32_t green = (GPART(src00) + GPART(src01) + GPART(src10) + GPART(src11) + 2) / 4; - uint32_t blue = (BPART(src00) + BPART(src01) + BPART(src10) + BPART(src11) + 2) / 4; - - dest[y + x * h] = (alpha << 24) | (red << 16) | (green << 8) | blue; - } - } - - src = dest; - dest += w * h; - } - } - - int Width = 0; - int Height = 0; - int Levels = 0; - std::vector Pixels; -}; - -class TextureMipmapper -{ -public: - static std::map> &Textures() - { - static std::map> textures; - return textures; - } -}; - -void R_SetMipmappedSpanSource(FTexture *tex) -{ - if (r_swtruecolor) - { - if (r_mipmap) - { - auto &mipmap = TextureMipmapper::Textures()[tex]; - if (!mipmap) - mipmap = std::make_shared(tex); - ds_source = (const BYTE*)mipmap->Pixels.data(); - } - else - { - ds_source = (const BYTE*)tex->GetPixelsBgra(); - } - } - else - { - ds_source = tex->GetPixels(); - } -} - -void R_ClearMipmapCache() -{ - TextureMipmapper::Textures().clear(); -} - void R_BeginDrawerCommands() { DrawerCommandQueue::Begin(); diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 37dc1a70a..4808cb257 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -108,9 +108,6 @@ void tmvline4_revsubclamp_rgba(); void R_FillColumnHoriz_rgba(); void R_FillSpan_rgba(); -void R_SetMipmappedSpanSource(FTexture *tex); -void R_ClearMipmapCache(); - ///////////////////////////////////////////////////////////////////////////// // Multithreaded rendering infrastructure: @@ -494,9 +491,9 @@ FORCEINLINE uint32_t sample_bilinear(const uint32_t *texture, dsfixed_t xfrac, d uint32_t y = (yfrac - yhalf) >> ybits; uint32_t p00 = texture[(y & ymask) + ((x & xmask) << yshift)]; - uint32_t p01 = texture[(y + 1 & ymask) + ((x & xmask) << yshift)]; + uint32_t p01 = texture[((y + 1) & ymask) + ((x & xmask) << yshift)]; uint32_t p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)]; - uint32_t p11 = texture[(y + 1 & ymask) + (((x + 1) & xmask) << yshift)]; + uint32_t p11 = texture[((y + 1) & ymask) + (((x + 1) & xmask) << yshift)]; uint32_t inv_b = ((xfrac + xhalf) >> (xbits - 4)) & 15; uint32_t inv_a = ((yfrac + yhalf) >> (ybits - 4)) & 15; @@ -511,87 +508,81 @@ FORCEINLINE uint32_t sample_bilinear(const uint32_t *texture, dsfixed_t xfrac, d return (alpha << 24) | (red << 16) | (green << 8) | blue; } -#ifndef NO_SSE -FORCEINLINE __m128i sample_bilinear4_sse(const uint32_t **col0, const uint32_t **col1, uint32_t texturefracx[4], uint32_t texturefracy[4], int ybits) -{ - uint32_t half = 1 << (ybits - 1); - - __m128i m127 = _mm_set1_epi16(127); - __m128i fg = _mm_setzero_si128(); - for (int i = 0; i < 4; i++) - { - uint32_t y = (texturefracy[i] - half) >> ybits; - - uint32_t inv_b = texturefracx[i]; - uint32_t inv_a = ((texturefracy[i] + half) >> (ybits - 4)) & 15; - uint32_t a = 16 - inv_a; - uint32_t b = 16 - inv_b; - - uint32_t ab = a * b; - uint32_t invab = inv_a * b; - uint32_t ainvb = a * inv_b; - uint32_t invainvb = inv_a * inv_b; - __m128i ab_invab = _mm_set_epi16(invab, invab, invab, invab, ab, ab, ab, ab); - __m128i ainvb_invainvb = _mm_set_epi16(invainvb, invainvb, invainvb, invainvb, ainvb, ainvb, ainvb, ainvb); - - __m128i p0 = _mm_unpacklo_epi8(_mm_loadl_epi64((const __m128i*)(col0[i] + y)), _mm_setzero_si128()); - __m128i p1 = _mm_unpacklo_epi8(_mm_loadl_epi64((const __m128i*)(col1[i] + y)), _mm_setzero_si128()); - - __m128i tmp = _mm_adds_epu16(_mm_mullo_epi16(p0, ab_invab), _mm_mullo_epi16(p1, ainvb_invainvb)); - __m128i color = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_srli_si128(tmp, 8), tmp), m127), 8); - - fg = _mm_or_si128(_mm_srli_si128(fg, 4), _mm_slli_si128(_mm_packus_epi16(color, _mm_setzero_si128()), 12)); - } - return fg; +#define VEC_SAMPLE_BILINEAR4_COLUMN(fg, col0, col1, texturefracx, texturefracy, ybits) { \ + uint32_t half = 1 << (ybits - 1); \ + \ + __m128i m127 = _mm_set1_epi16(127); \ + fg = _mm_setzero_si128(); \ + for (int i = 0; i < 4; i++) \ + { \ + uint32_t y = (texturefracy[i] - half) >> ybits; \ + \ + uint32_t inv_b = texturefracx[i]; \ + uint32_t inv_a = ((texturefracy[i] + half) >> (ybits - 4)) & 15; \ + uint32_t a = 16 - inv_a; \ + uint32_t b = 16 - inv_b; \ + \ + uint32_t ab = a * b; \ + uint32_t invab = inv_a * b; \ + uint32_t ainvb = a * inv_b; \ + uint32_t invainvb = inv_a * inv_b; \ + __m128i ab_invab = _mm_set_epi16(invab, invab, invab, invab, ab, ab, ab, ab); \ + __m128i ainvb_invainvb = _mm_set_epi16(invainvb, invainvb, invainvb, invainvb, ainvb, ainvb, ainvb, ainvb); \ + \ + __m128i p0 = _mm_unpacklo_epi8(_mm_loadl_epi64((const __m128i*)(col0[i] + y)), _mm_setzero_si128()); \ + __m128i p1 = _mm_unpacklo_epi8(_mm_loadl_epi64((const __m128i*)(col1[i] + y)), _mm_setzero_si128()); \ + \ + __m128i tmp = _mm_adds_epu16(_mm_mullo_epi16(p0, ab_invab), _mm_mullo_epi16(p1, ainvb_invainvb)); \ + __m128i color = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_srli_si128(tmp, 8), tmp), m127), 8); \ + \ + fg = _mm_or_si128(_mm_srli_si128(fg, 4), _mm_slli_si128(_mm_packus_epi16(color, _mm_setzero_si128()), 12)); \ + } \ } -FORCEINLINE __m128i sample_bilinear4_sse(const uint32_t *texture, dsfixed_t &xfrac, dsfixed_t &yfrac, dsfixed_t xstep, dsfixed_t ystep, int xbits, int ybits) -{ - int xshift = (32 - xbits); - int yshift = (32 - ybits); - int xmask = (1 << xshift) - 1; - int ymask = (1 << yshift) - 1; - uint32_t xhalf = 1 << (xbits - 1); - uint32_t yhalf = 1 << (ybits - 1); - - __m128i m127 = _mm_set1_epi16(127); - __m128i fg = _mm_setzero_si128(); - for (int i = 0; i < 4; i++) - { - uint32_t x = (xfrac - xhalf) >> xbits; - uint32_t y = (yfrac - yhalf) >> ybits; - - uint32_t p00 = texture[(y & ymask) + ((x & xmask) << yshift)]; - uint32_t p01 = texture[(y + 1 & ymask) + ((x & xmask) << yshift)]; - uint32_t p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)]; - uint32_t p11 = texture[(y + 1 & ymask) + (((x + 1) & xmask) << yshift)]; - - uint32_t inv_b = ((xfrac + xhalf) >> (xbits - 4)) & 15; - uint32_t inv_a = ((yfrac + yhalf) >> (ybits - 4)) & 15; - uint32_t a = 16 - inv_a; - uint32_t b = 16 - inv_b; - - uint32_t ab = a * b; - uint32_t invab = inv_a * b; - uint32_t ainvb = a * inv_b; - uint32_t invainvb = inv_a * inv_b; - __m128i ab_invab = _mm_set_epi16(invab, invab, invab, invab, ab, ab, ab, ab); - __m128i ainvb_invainvb = _mm_set_epi16(invainvb, invainvb, invainvb, invainvb, ainvb, ainvb, ainvb, ainvb); - - __m128i p0 = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, p01, p00), _mm_setzero_si128()); - __m128i p1 = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, p11, p10), _mm_setzero_si128()); - - __m128i tmp = _mm_adds_epu16(_mm_mullo_epi16(p0, ab_invab), _mm_mullo_epi16(p1, ainvb_invainvb)); - __m128i color = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_srli_si128(tmp, 8), tmp), m127), 8); - - fg = _mm_or_si128(_mm_srli_si128(fg, 4), _mm_slli_si128(_mm_packus_epi16(color, _mm_setzero_si128()), 12)); - - xfrac += xstep; - yfrac += ystep; - } - return fg; +#define VEC_SAMPLE_BILINEAR4_SPAN(fg, texture, xfrac, yfrac, xstep, ystep, xbits, ybits) { \ + int xshift = (32 - xbits); \ + int yshift = (32 - ybits); \ + int xmask = (1 << xshift) - 1; \ + int ymask = (1 << yshift) - 1; \ + uint32_t xhalf = 1 << (xbits - 1); \ + uint32_t yhalf = 1 << (ybits - 1); \ + \ + __m128i m127 = _mm_set1_epi16(127); \ + fg = _mm_setzero_si128(); \ + for (int i = 0; i < 4; i++) \ + { \ + uint32_t x = (xfrac - xhalf) >> xbits; \ + uint32_t y = (yfrac - yhalf) >> ybits; \ + \ + uint32_t p00 = texture[(y & ymask) + ((x & xmask) << yshift)]; \ + uint32_t p01 = texture[((y + 1) & ymask) + ((x & xmask) << yshift)]; \ + uint32_t p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)]; \ + uint32_t p11 = texture[((y + 1) & ymask) + (((x + 1) & xmask) << yshift)]; \ + \ + uint32_t inv_b = ((xfrac + xhalf) >> (xbits - 4)) & 15; \ + uint32_t inv_a = ((yfrac + yhalf) >> (ybits - 4)) & 15; \ + uint32_t a = 16 - inv_a; \ + uint32_t b = 16 - inv_b; \ + \ + uint32_t ab = a * b; \ + uint32_t invab = inv_a * b; \ + uint32_t ainvb = a * inv_b; \ + uint32_t invainvb = inv_a * inv_b; \ + __m128i ab_invab = _mm_set_epi16(invab, invab, invab, invab, ab, ab, ab, ab); \ + __m128i ainvb_invainvb = _mm_set_epi16(invainvb, invainvb, invainvb, invainvb, ainvb, ainvb, ainvb, ainvb); \ + \ + __m128i p0 = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, p01, p00), _mm_setzero_si128()); \ + __m128i p1 = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, p11, p10), _mm_setzero_si128()); \ + \ + __m128i tmp = _mm_adds_epu16(_mm_mullo_epi16(p0, ab_invab), _mm_mullo_epi16(p1, ainvb_invainvb)); \ + __m128i color = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_srli_si128(tmp, 8), tmp), m127), 8); \ + \ + fg = _mm_or_si128(_mm_srli_si128(fg, 4), _mm_slli_si128(_mm_packus_epi16(color, _mm_setzero_si128()), 12)); \ + \ + xfrac += xstep; \ + yfrac += ystep; \ + } \ } -#endif // Calculate constants for a simple shade with gamma correction #define AVX_LINEAR_SHADE_SIMPLE_INIT(light) \ diff --git a/src/r_draw_rgba_sse.h b/src/r_draw_rgba_sse.h index 4002a5535..af761c6e7 100644 --- a/src/r_draw_rgba_sse.h +++ b/src/r_draw_rgba_sse.h @@ -280,7 +280,8 @@ public: VEC_SHADE_SIMPLE_INIT(light); while (sse_count--) { - __m128i fg = sample_bilinear4_sse(source, xfrac, yfrac, xstep, ystep, 26, 26); + __m128i fg; + VEC_SAMPLE_BILINEAR4_SPAN(fg, source, xfrac, yfrac, xstep, ystep, 26, 26); VEC_SHADE_SIMPLE(fg); _mm_storeu_si128((__m128i*)dest, fg); dest += 4; @@ -291,7 +292,8 @@ public: VEC_SHADE_INIT(light, shade_constants); while (sse_count--) { - __m128i fg = sample_bilinear4_sse(source, xfrac, yfrac, xstep, ystep, 26, 26); + __m128i fg; + VEC_SAMPLE_BILINEAR4_SPAN(fg, source, xfrac, yfrac, xstep, ystep, 26, 26); VEC_SHADE(fg, shade_constants); _mm_storeu_si128((__m128i*)dest, fg); dest += 4; @@ -318,7 +320,10 @@ public: VEC_SHADE_SIMPLE_INIT(light); while (sse_count--) { - __m128i fg = sample_bilinear4_sse(source, xfrac, yfrac, xstep, ystep, 32 -_xbits, 32 - _ybits); + __m128i fg; + int tmpx = 32 - _xbits; + int tmpy = 32 - _ybits; + VEC_SAMPLE_BILINEAR4_SPAN(fg, source, xfrac, yfrac, xstep, ystep, tmpx, tmpy); VEC_SHADE_SIMPLE(fg); _mm_storeu_si128((__m128i*)dest, fg); dest += 4; @@ -329,7 +334,10 @@ public: VEC_SHADE_INIT(light, shade_constants); while (sse_count--) { - __m128i fg = sample_bilinear4_sse(source, xfrac, yfrac, xstep, ystep, 32 - _xbits, 32 - _ybits); + __m128i fg; + int tmpx = 32 - _xbits; + int tmpy = 32 - _ybits; + VEC_SAMPLE_BILINEAR4_SPAN(fg, source, xfrac, yfrac, xstep, ystep, tmpx, tmpy); VEC_SHADE(fg, shade_constants); _mm_storeu_si128((__m128i*)dest, fg); dest += 4; @@ -471,7 +479,8 @@ public: VEC_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); do { - __m128i fg = sample_bilinear4_sse(bufplce, bufplce2, buftexturefracx, local_vplce, bits); + __m128i fg; + VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits); local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -488,7 +497,8 @@ public: VEC_SHADE_INIT4(light3, light2, light1, light0, shade_constants); do { - __m128i fg = sample_bilinear4_sse(bufplce, bufplce2, buftexturefracx, local_vplce, bits); + __m128i fg; + VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits); local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -629,7 +639,8 @@ public: VEC_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); do { - __m128i fg = sample_bilinear4_sse(bufplce, bufplce2, buftexturefracx, local_vplce, bits); + __m128i fg; + VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits); local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -648,7 +659,8 @@ public: VEC_SHADE_INIT4(light3, light2, light1, light0, shade_constants); do { - __m128i fg = sample_bilinear4_sse(bufplce, bufplce2, buftexturefracx, local_vplce, bits); + __m128i fg; + VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits); local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index c1e2d4bd0..c81d2a110 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -170,7 +170,6 @@ void FSoftwareRenderer::RenderView(player_t *player) R_InitColumnDrawers(); } - R_ClearMipmapCache(); R_BeginDrawerCommands(); R_RenderActorView (player->mo); // [RH] Let cameras draw onto textures that were visible this frame. diff --git a/src/textures/jpegtexture.cpp b/src/textures/jpegtexture.cpp index 3b5359846..f44b34d08 100644 --- a/src/textures/jpegtexture.cpp +++ b/src/textures/jpegtexture.cpp @@ -474,7 +474,7 @@ void FJPEGTexture::MakeTextureBgra() jpeg_decompress_struct cinfo; jpeg_error_mgr jerr; - PixelsBgra.resize(Width * Height, 0xffba0000); + CreatePixelsBgraWithMipmaps(); cinfo.err = jpeg_std_error(&jerr); cinfo.err->output_message = JPEG_OutputMessage; @@ -560,6 +560,8 @@ void FJPEGTexture::MakeTextureBgra() { delete[] buff; } + + GenerateBgraMipmaps(); } diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index 408cf1e2f..ee4eabe90 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -633,7 +633,7 @@ void FPNGTexture::MakeTextureBgra () lump = new FileReader(SourceFile.GetChars()); } - PixelsBgra.resize(Width * Height, 0xffff0000); + CreatePixelsBgraWithMipmaps(); if (StartOfIDAT != 0) { DWORD len, id; @@ -757,6 +757,7 @@ void FPNGTexture::MakeTextureBgra () } } delete lump; + GenerateBgraMipmaps(); } //=========================================================================== diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 16a9e63a6..f5e4d4aa8 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -200,7 +200,7 @@ const uint32_t *FTexture::GetPixelsBgra() const BYTE *indices = GetPixels(); if (indices == nullptr) return nullptr; - PixelsBgra.resize(Width * Height); + CreatePixelsBgraWithMipmaps(); for (int i = 0; i < Width * Height; i++) { if (indices[i] != 0) @@ -208,6 +208,7 @@ const uint32_t *FTexture::GetPixelsBgra() else PixelsBgra[i] = 0; } + GenerateBgraMipmaps(); } return PixelsBgra.data(); } @@ -355,6 +356,71 @@ void FTexture::FreeSpans (Span **spans) const M_Free (spans); } +void FTexture::CreatePixelsBgraWithMipmaps() +{ + int levels = MipmapLevels(); + int buffersize = 0; + for (int i = 0; i < levels; i++) + { + int w = MAX(Width >> i, 1); + int h = MAX(Height >> i, 1); + buffersize += w * h; + } + PixelsBgra.resize(buffersize, 0xffff0000); +} + +int FTexture::MipmapLevels() const +{ + int widthbits = 0; + while ((Width >> widthbits) != 0) widthbits++; + + int heightbits = 0; + while ((Height >> heightbits) != 0) heightbits++; + + return MAX(widthbits, heightbits); +} + +void FTexture::GenerateBgraMipmaps() +{ + uint32_t *src = PixelsBgra.data(); + uint32_t *dest = src + Width * Height; + int levels = MipmapLevels(); + for (int i = 1; i < levels; i++) + { + int srcw = MAX(Width >> (i - 1), 1); + int srch = MAX(Height >> (i - 1), 1); + int w = MAX(Width >> i, 1); + int h = MAX(Height >> i, 1); + + for (int x = 0; x < w; x++) + { + int sx0 = x * 2; + int sx1 = MIN((x + 1) * 2, srcw - 1); + + for (int y = 0; y < h; y++) + { + int sy0 = y * 2; + int sy1 = MIN((y + 1) * 2, srch - 1); + + uint32_t src00 = src[sy0 + sx0 * srch]; + uint32_t src01 = src[sy1 + sx0 * srch]; + uint32_t src10 = src[sy0 + sx1 * srch]; + uint32_t src11 = src[sy1 + sx1 * srch]; + + uint32_t alpha = (APART(src00) + APART(src01) + APART(src10) + APART(src11) + 2) / 4; + uint32_t red = (RPART(src00) + RPART(src01) + RPART(src10) + RPART(src11) + 2) / 4; + uint32_t green = (GPART(src00) + GPART(src01) + GPART(src10) + GPART(src11) + 2) / 4; + uint32_t blue = (BPART(src00) + BPART(src01) + BPART(src10) + BPART(src11) + 2) / 4; + + dest[y + x * h] = (alpha << 24) | (red << 16) | (green << 8) | blue; + } + } + + src = dest; + dest += w * h; + } +} + void FTexture::CopyToBlock (BYTE *dest, int dwidth, int dheight, int xpos, int ypos, int rotate, const BYTE *translation) { const BYTE *pixels = GetPixels(); diff --git a/src/textures/textures.h b/src/textures/textures.h index 3b4b0b8b3..ab9dc3719 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -271,6 +271,10 @@ protected: std::vector PixelsBgra; + void CreatePixelsBgraWithMipmaps(); + void GenerateBgraMipmaps(); + int MipmapLevels() const; + public: static void FlipSquareBlock (BYTE *block, int x, int y); static void FlipSquareBlockBgra (uint32_t *block, int x, int y); From 4142b6ed1b1dc858a4a7ab16ca2f01a79567ce3b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 21 Jun 2016 22:03:34 +0200 Subject: [PATCH 0686/1509] GCC compile fix --- src/r_draw_rgba.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 4808cb257..617e83107 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -427,7 +427,7 @@ FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) return 0xff000000 | (red << 16) | (green << 8) | blue; } -inline bool span_sampler_setup(const uint32_t *&source, int &xbits, int &ybits, fixed_t xstep, fixed_t ystep) +inline bool span_sampler_setup(const uint32_t * RESTRICT &source, int &xbits, int &ybits, fixed_t xstep, fixed_t ystep) { if (!r_bilinear) return false; From f81042b3e20a2d9d300c0431d0bb094435eef340 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 21 Jun 2016 22:10:04 +0200 Subject: [PATCH 0687/1509] Fix warning generated by gcc --- src/r_draw_rgba.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 8144c096d..57b32b28c 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -1722,7 +1722,8 @@ public: // 64x64 is the most common case by far, so special case it. do { - *dest++ = alpha_blend(shade_bgra(sample_bilinear(source, xfrac, yfrac, 26, 26), light, shade_constants), *dest); + *dest = alpha_blend(shade_bgra(sample_bilinear(source, xfrac, yfrac, 26, 26), light, shade_constants), *dest); + dest++; xfrac += xstep; yfrac += ystep; } while (--count); @@ -1734,7 +1735,8 @@ public: int xmask = ((1 << _xbits) - 1) << _ybits; do { - *dest++ = alpha_blend(shade_bgra(sample_bilinear(source, xfrac, yfrac, 32 - _xbits, 32 - _ybits), light, shade_constants), *dest); + *dest = alpha_blend(shade_bgra(sample_bilinear(source, xfrac, yfrac, 32 - _xbits, 32 - _ybits), light, shade_constants), *dest); + dest++; xfrac += xstep; yfrac += ystep; } while (--count); From e294906d692e4eee921d35e013fafdd633f42257 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 22 Jun 2016 00:22:06 +0200 Subject: [PATCH 0688/1509] Voxel support in true color mode --- src/r_draw.cpp | 13 ++++ src/r_draw.h | 18 +++--- src/r_draw_rgba.cpp | 142 ++++++++++++++++++++++++++++++++++++++++++++ src/r_draw_rgba.h | 3 + src/r_things.cpp | 6 +- src/r_things.h | 2 +- 6 files changed, 171 insertions(+), 13 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 55353a006..8cca13289 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -100,6 +100,8 @@ void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); void (*R_MapTiltedPlane)(int y, int x1); void (*R_MapColoredPlane)(int y, int x1); void (*R_DrawParticle)(vissprite_t *); +void (*R_SetupDrawSlab)(FColormap *base_colormap, float light, int shade); +void (*R_DrawSlab)(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); fixed_t (*tmvline1_add)(); void (*tmvline4_add)(); fixed_t (*tmvline1_addclamp)(); @@ -2306,6 +2308,9 @@ void R_InitColumnDrawers () R_MapColoredPlane = R_MapColoredPlane_rgba; R_DrawParticle = R_DrawParticle_rgba; + R_SetupDrawSlab = R_SetupDrawSlab_rgba; + R_DrawSlab = R_DrawSlab_rgba; + tmvline1_add = tmvline1_add_rgba; tmvline4_add = tmvline4_add_rgba; tmvline1_addclamp = tmvline1_addclamp_rgba; @@ -2403,6 +2408,14 @@ void R_InitColumnDrawers () R_MapColoredPlane = R_MapColoredPlane_C; R_DrawParticle = R_DrawParticle_C; +#ifdef X86_ASM + R_SetupDrawSlab = [](FColormap *colormap, float light, int shade) { R_SetupDrawSlabA(colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT)); }; + R_DrawSlab = R_DrawSlabA; +#else + R_SetupDrawSlab = [](FColormap *colormap, float light, int shade) { R_SetupDrawSlabC(colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT)); }; + R_DrawSlab = R_DrawSlabC; +#endif + tmvline1_add = tmvline1_add_C; tmvline4_add = tmvline4_add_C; tmvline1_addclamp = tmvline1_addclamp_C; diff --git a/src/r_draw.h b/src/r_draw.h index b662ddcee..547a044ea 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -286,16 +286,16 @@ void R_FillColumnP_C (void); void R_FillColumnHorizP_C (void); void R_FillSpan_C (void); -#ifdef X86_ASM -#define R_SetupDrawSlab R_SetupDrawSlabA -#define R_DrawSlab R_DrawSlabA -#else -#define R_SetupDrawSlab R_SetupDrawSlabC -#define R_DrawSlab R_DrawSlabC -#endif +extern void(*R_SetupDrawSlab)(FColormap *base_colormap, float light, int shade); +extern void(*R_DrawSlab)(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); -extern "C" void R_SetupDrawSlab(const BYTE *colormap); -extern "C" void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); +#ifdef X86_ASM +extern "C" void R_SetupDrawSlabA(const BYTE *colormap); +extern "C" void R_DrawSlabA(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); +#else +extern "C" void R_SetupDrawSlabC(const BYTE *colormap); +extern "C" void R_DrawSlabC(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); +#endif extern "C" int ds_y; extern "C" int ds_x1; diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 57b32b28c..9603a8b3e 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -2303,6 +2303,123 @@ public: } }; +class DrawSlabRGBACommand : public DrawerCommand +{ + int _dx; + fixed_t _v; + int _dy; + fixed_t _vi; + const BYTE *_vptr; + uint32_t *_p; + ShadeConstants _shade_constants; + const BYTE *_colormap; + fixed_t _light; + int _pitch; + int _start_y; + +public: + DrawSlabRGBACommand(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p, ShadeConstants shade_constants, const BYTE *colormap, fixed_t light) + { + _dx = dx; + _v = v; + _dy = dy; + _vi = vi; + _vptr = vptr; + _p = (uint32_t *)p; + _shade_constants = shade_constants; + _colormap = colormap; + _light = light; + _pitch = dc_pitch; + _start_y = static_cast((p - dc_destorg) / (dc_pitch * 4)); + assert(dx > 0); + } + + void Execute(DrawerThread *thread) override + { + int dx = _dx; + fixed_t v = _v; + int dy = _dy; + fixed_t vi = _vi; + const BYTE *vptr = _vptr; + uint32_t *p = _p; + ShadeConstants shade_constants = _shade_constants; + const BYTE *colormap = _colormap; + uint32_t light = calc_light_multiplier(_light); + int pitch = _pitch; + int x; + + dy = thread->count_for_thread(_start_y, dy); + p = thread->dest_for_thread(_start_y, pitch, p); + v += vi * thread->skipped_by_thread(_start_y); + vi *= thread->num_cores; + pitch *= thread->num_cores; + + if (dx == 1) + { + while (dy > 0) + { + *p = shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); + p += pitch; + v += vi; + dy--; + } + } + else if (dx == 2) + { + while (dy > 0) + { + uint32_t color = shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); + p[0] = color; + p[1] = color; + p += pitch; + v += vi; + dy--; + } + } + else if (dx == 3) + { + while (dy > 0) + { + uint32_t color = shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); + p[0] = color; + p[1] = color; + p[2] = color; + p += pitch; + v += vi; + dy--; + } + } + else if (dx == 4) + { + while (dy > 0) + { + uint32_t color = shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); + p[0] = color; + p[1] = color; + p[2] = color; + p[3] = color; + p += pitch; + v += vi; + dy--; + } + } + else while (dy > 0) + { + uint32_t color = shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); + // The optimizer will probably turn this into a memset call. + // Since dx is not likely to be large, I'm not sure that's a good thing, + // hence the alternatives above. + for (x = 0; x < dx; x++) + { + p[x] = color; + } + p += pitch; + v += vi; + dy--; + } + } +}; + class Vlinec1RGBACommand : public DrawerCommand { DWORD _iscale; @@ -3813,6 +3930,31 @@ void R_FillSpan_rgba() DrawerCommandQueue::QueueCommand(); } +static ShadeConstants slab_rgba_shade_constants; +static const BYTE *slab_rgba_colormap; +static fixed_t slab_rgba_light; + +void R_SetupDrawSlab_rgba(FColormap *base_colormap, float light, int shade) +{ + slab_rgba_shade_constants.light_red = base_colormap->Color.r * 256 / 255; + slab_rgba_shade_constants.light_green = base_colormap->Color.g * 256 / 255; + slab_rgba_shade_constants.light_blue = base_colormap->Color.b * 256 / 255; + slab_rgba_shade_constants.light_alpha = base_colormap->Color.a * 256 / 255; + slab_rgba_shade_constants.fade_red = base_colormap->Fade.r; + slab_rgba_shade_constants.fade_green = base_colormap->Fade.g; + slab_rgba_shade_constants.fade_blue = base_colormap->Fade.b; + slab_rgba_shade_constants.fade_alpha = base_colormap->Fade.a; + slab_rgba_shade_constants.desaturate = MIN(abs(base_colormap->Desaturate), 255) * 255 / 256; + slab_rgba_shade_constants.simple_shade = (base_colormap->Color.d == 0x00ffffff && base_colormap->Fade.d == 0x00000000 && base_colormap->Desaturate == 0); + slab_rgba_colormap = base_colormap->Maps; + slab_rgba_light = LIGHTSCALE(light, shade); +} + +void R_DrawSlab_rgba(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p) +{ + DrawerCommandQueue::QueueCommand(dx, v, dy, vi, vptr, p, slab_rgba_shade_constants, slab_rgba_colormap, slab_rgba_light); +} + //extern FTexture *rw_pic; // For the asserts below DWORD vlinec1_rgba() diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 617e83107..c94cb1e4b 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -90,6 +90,9 @@ void R_DrawSpanAddClamp_rgba(); void R_DrawSpanMaskedAddClamp_rgba(); void R_FillSpan_rgba(); +void R_SetupDrawSlab_rgba(FColormap *base_colormap, float light, int shade); +void R_DrawSlab_rgba(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); + void R_DrawFogBoundary_rgba(int x1, int x2, short *uclip, short *dclip); DWORD vlinec1_rgba(); diff --git a/src/r_things.cpp b/src/r_things.cpp index f6a1a709f..e1f1017f3 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -688,7 +688,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop // Render the voxel, either directly to the screen or offscreen. R_DrawVoxel(spr->pa.vpos, spr->pa.vang, spr->gpos, spr->Angle, - spr->xscale, FLOAT2FIXED(spr->yscale), spr->voxel, spr->Style.BaseColormap->Maps + (spr->Style.ColormapNum << COLORMAPSHIFT), cliptop, clipbot, + spr->xscale, FLOAT2FIXED(spr->yscale), spr->voxel, spr->Style.BaseColormap, spr->Style.ColormapNum, cliptop, clipbot, minslabz, maxslabz, flags); // Blend the voxel, if that's what we need to do. @@ -2775,7 +2775,7 @@ extern double BaseYaspectMul;; void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, const FVector3 &dasprpos, DAngle dasprang, fixed_t daxscale, fixed_t dayscale, FVoxel *voxobj, - lighttable_t *colormap, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags) + FColormap *colormap, int colormapnum, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags) { int i, j, k, x, y, syoff, ggxstart, ggystart, nxoff; fixed_t cosang, sinang, sprcosang, sprsinang; @@ -2812,7 +2812,7 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, sprcosang = FLOAT2FIXED(dasprang.Cos()) >> 2; sprsinang = FLOAT2FIXED(-dasprang.Sin()) >> 2; - R_SetupDrawSlab(colormap); + R_SetupDrawSlab(colormap, 0.0f, colormapnum << FRACBITS); int pixelsize = r_swtruecolor ? 4 : 1; diff --git a/src/r_things.h b/src/r_things.h index 04d5487ee..13f89574b 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -144,7 +144,7 @@ enum { DVF_OFFSCREEN = 1, DVF_SPANSONLY = 2, DVF_MIRRORED = 4 }; void R_DrawVoxel(const FVector3 &viewpos, FAngle viewangle, const FVector3 &sprpos, DAngle dasprang, fixed_t daxscale, fixed_t dayscale, struct FVoxel *voxobj, - lighttable_t *colormap, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags); + FColormap *colormap, int colormapnum, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags); void R_ClipVisSprite (vissprite_t *vis, int xl, int xh); From db4cba239a16662c437da8dc5d03ce3f14dd151c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 22 Jun 2016 00:27:12 +0200 Subject: [PATCH 0689/1509] Renamed member variable to make it compile with gcc --- src/r_draw_rgba.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 9603a8b3e..1e2678bd3 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -2309,7 +2309,7 @@ class DrawSlabRGBACommand : public DrawerCommand fixed_t _v; int _dy; fixed_t _vi; - const BYTE *_vptr; + const BYTE *_voxelptr; uint32_t *_p; ShadeConstants _shade_constants; const BYTE *_colormap; @@ -2324,7 +2324,7 @@ public: _v = v; _dy = dy; _vi = vi; - _vptr = vptr; + _voxelptr = vptr; _p = (uint32_t *)p; _shade_constants = shade_constants; _colormap = colormap; @@ -2340,7 +2340,7 @@ public: fixed_t v = _v; int dy = _dy; fixed_t vi = _vi; - const BYTE *vptr = _vptr; + const BYTE *vptr = _voxelptr; uint32_t *p = _p; ShadeConstants shade_constants = _shade_constants; const BYTE *colormap = _colormap; From ca9d8e580e4b2b94c19182dcb160d9de6c904b5c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 22 Jun 2016 00:51:16 +0200 Subject: [PATCH 0690/1509] Increase command queue memory pool to 16 MB and make it flush if its exhausted --- src/r_draw_rgba.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index c94cb1e4b..47f7c8865 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -193,7 +193,7 @@ EXTERN_CVAR(Bool, r_mipmap) // Manages queueing up commands and executing them on worker threads class DrawerCommandQueue { - enum { memorypool_size = 4 * 1024 * 1024 }; + enum { memorypool_size = 16 * 1024 * 1024 }; char memorypool[memorypool_size]; size_t memorypool_pos = 0; @@ -241,8 +241,13 @@ public: else { void *ptr = AllocMemory(sizeof(T)); - if (!ptr) - return; + if (!ptr) // Out of memory - render what we got + { + queue->Finish(); + ptr = AllocMemory(sizeof(T)); + if (!ptr) + return; + } T *command = new (ptr)T(std::forward(args)...); queue->commands.push_back(command); } From 7a0c801a18bcf4f1910a1ae5cc708fe746ca2f9c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 22 Jun 2016 08:23:16 +0200 Subject: [PATCH 0691/1509] Added mipmapping to wallscan --- src/r_draw.h | 29 ------- src/r_draw_rgba.h | 2 +- src/r_segs.cpp | 207 +++++++++++++++++++++++++++++----------------- 3 files changed, 130 insertions(+), 108 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index 547a044ea..72304e81f 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -381,33 +381,4 @@ void R_SetTranslationMap(lighttable_t *translation); extern bool r_swtruecolor; EXTERN_CVAR(Bool, r_bilinear); -// Texture sampler state needed for bilinear filtering -struct SamplerSetup -{ - SamplerSetup() { } - SamplerSetup(fixed_t xoffset, bool magnifying, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)); - - const BYTE *source; - const BYTE *source2; - uint32_t texturefracx; -}; - -inline SamplerSetup::SamplerSetup(fixed_t xoffset, bool magnifying, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)) -{ - // Only do bilinear filtering if enabled and not a magnifying filter - if (!r_swtruecolor || !r_bilinear || magnifying) - { - source = getcol(texture, xoffset >> FRACBITS); - source2 = nullptr; - texturefracx = 0; - } - else - { - int tx = (xoffset - FRACUNIT / 2) >> FRACBITS; - source = getcol(texture, tx); - source2 = getcol(texture, tx + 1); - texturefracx = ((xoffset + FRACUNIT / 2) >> (FRACBITS - 4)) & 15; - } -} - #endif diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 47f7c8865..8f97d4ecd 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -443,7 +443,7 @@ inline bool span_sampler_setup(const uint32_t * RESTRICT &source, int &xbits, in // Is this a magfilter or minfilter? fixed_t xmagnitude = abs(xstep) >> (32 - xbits - FRACBITS); fixed_t ymagnitude = abs(ystep) >> (32 - ybits - FRACBITS); - fixed_t magnitude = (xmagnitude + ymagnitude) * 3 + (1 << (FRACBITS -1)); + fixed_t magnitude = (xmagnitude + ymagnitude) * 2 + (1 << (FRACBITS -1)); if (magnitude >> FRACBITS == 0) return false; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index d71487bb9..84c967d1d 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1067,11 +1067,92 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2) return; } +EXTERN_CVAR(Bool, r_mipmap) + +struct WallscanSampler +{ + WallscanSampler() { } + WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)); + + uint32_t uv_pos; + uint32_t uv_step; + int32_t uv_fracbits; + uint32_t uv_max; + + const BYTE *source; + const BYTE *source2; + uint32_t texturefracx; +}; + +WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)) +{ + int base_width = texture->GetWidth(); + int base_height = texture->GetHeight(); + uv_fracbits = 32 - texture->HeightBits; + uv_max = base_height << uv_fracbits; + + // Find start uv in [0-base_height[ range. + // Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range. + double uv_stepd = swal * yrepeat; + double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / base_height; + v = v - floor(v); + v *= base_height; + v *= (1 << uv_fracbits); + + uv_pos = (uint32_t)v; + uv_step = xs_ToFixed(uv_fracbits, uv_stepd); + + bool magnifying = uv_step >> (uv_fracbits - 1) == 0; + + // Only do bilinear filtering if enabled and not a magnifying filter + if (!r_swtruecolor || !r_bilinear || magnifying || getcol != R_GetColumn) + { + source = getcol(texture, xoffset >> FRACBITS); + source2 = nullptr; + texturefracx = 0; + } + else + { + int mipmap_offset = 0; + int mip_width = base_width; + int mip_height = base_height; + if (r_mipmap) + { + fixed_t magnitude = abs((int32_t)uv_step) >> (uv_fracbits - FRACBITS); + int level = magnitude >> FRACBITS; + while (level != 0) + { + if (uv_fracbits > 30) + break; + + mipmap_offset += mip_width * mip_height; + uv_fracbits += 1; + uv_pos >>= 1; + uv_step >>= 1; + xoffset >>= 1; + level >>= 1; + mip_width = MAX(mip_width >> 1, 1); + mip_height = MAX(mip_height >> 1, 1); + } + } + + const uint32_t *pixels = texture->GetPixelsBgra() + mipmap_offset; + + int tx0 = ((xoffset - FRACUNIT / 2) >> FRACBITS) % mip_width; + if (tx0 < 0) + tx0 += mip_width; + int tx1 = (tx0 + 1) % mip_width; + source = (BYTE*)(pixels + tx0 * mip_height); + source2 = (BYTE*)(pixels + tx1 * mip_height); + texturefracx = ((xoffset + FRACUNIT / 2) >> (FRACBITS - 4)) & 15; + } +} + // Draw a column with support for non-power-of-two ranges -uint32_t wallscan_drawcol1(int x, int y1, int y2, uint32_t uv_start, uint32_t uv_step, uint32_t uv_max, const SamplerSetup &sampler, DWORD(*draw1column)()) +void wallscan_drawcol1(int x, int y1, int y2, WallscanSampler &sampler, DWORD(*draw1column)()) { int pixelsize = r_swtruecolor ? 4 : 1; - if (uv_max == 0) // power of two + if (sampler.uv_max == 0) // power of two { int count = y2 - y1; @@ -1080,24 +1161,24 @@ uint32_t wallscan_drawcol1(int x, int y1, int y2, uint32_t uv_start, uint32_t uv dc_texturefracx = sampler.texturefracx; dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; dc_count = count; - dc_iscale = uv_step; - dc_texturefrac = uv_start; + dc_iscale = sampler.uv_step; + dc_texturefrac = sampler.uv_pos; draw1column(); - uint64_t step64 = uv_step; - uint64_t pos64 = uv_start; - return (uint32_t)(pos64 + step64 * count); + uint64_t step64 = sampler.uv_step; + uint64_t pos64 = sampler.uv_pos; + sampler.uv_pos = (uint32_t)(pos64 + step64 * count); } else { - uint32_t uv_pos = uv_start; + uint32_t uv_pos = sampler.uv_pos; uint32_t left = y2 - y1; while (left > 0) { - uint32_t available = uv_max - uv_pos; - uint32_t next_uv_wrap = available / uv_step; - if (available % uv_step != 0) + uint32_t available = sampler.uv_max - uv_pos; + uint32_t next_uv_wrap = available / sampler.uv_step; + if (available % sampler.uv_step != 0) next_uv_wrap++; uint32_t count = MIN(left, next_uv_wrap); @@ -1106,25 +1187,25 @@ uint32_t wallscan_drawcol1(int x, int y1, int y2, uint32_t uv_start, uint32_t uv dc_texturefracx = sampler.texturefracx; dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; dc_count = count; - dc_iscale = uv_step; + dc_iscale = sampler.uv_step; dc_texturefrac = uv_pos; draw1column(); left -= count; - uv_pos += uv_step * count; - if (uv_pos >= uv_max) - uv_pos -= uv_max; + uv_pos += sampler.uv_step * count; + if (uv_pos >= sampler.uv_max) + uv_pos -= sampler.uv_max; } - return uv_pos; + sampler.uv_pos = uv_pos; } } // Draw four columns with support for non-power-of-two ranges -void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_step, uint32_t uv_max, const SamplerSetup *sampler, void(*draw4columns)()) +void wallscan_drawcol4(int x, int y1, int y2, WallscanSampler *sampler, void(*draw4columns)()) { int pixelsize = r_swtruecolor ? 4 : 1; - if (uv_max == 0) // power of two, no wrap handling needed + if (sampler[0].uv_max == 0) // power of two, no wrap handling needed { int count = y2 - y1; for (int i = 0; i < 4; i++) @@ -1132,12 +1213,12 @@ void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_ste bufplce[i] = sampler[i].source; bufplce2[i] = sampler[i].source2; buftexturefracx[i] = sampler[i].texturefracx; - vplce[i] = uv_pos[i]; - vince[i] = uv_step[i]; + vplce[i] = sampler[i].uv_pos; + vince[i] = sampler[i].uv_step; - uint64_t step64 = uv_step[i]; - uint64_t pos64 = uv_pos[i]; - uv_pos[i] = (uint32_t)(pos64 + step64 * count); + uint64_t step64 = sampler[i].uv_step; + uint64_t pos64 = sampler[i].uv_pos; + sampler[i].uv_pos = (uint32_t)(pos64 + step64 * count); } dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; dc_count = count; @@ -1160,9 +1241,9 @@ void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_ste uint32_t count = left; for (int i = 0; i < 4; i++) { - uint32_t available = uv_max - uv_pos[i]; - uint32_t next_uv_wrap = available / uv_step[i]; - if (available % uv_step[i] != 0) + uint32_t available = sampler[i].uv_max - sampler[i].uv_pos; + uint32_t next_uv_wrap = available / sampler[i].uv_step; + if (available % sampler[i].uv_step != 0) next_uv_wrap++; count = MIN(next_uv_wrap, count); } @@ -1170,8 +1251,8 @@ void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_ste // Draw until that column wraps for (int i = 0; i < 4; i++) { - vplce[i] = uv_pos[i]; - vince[i] = uv_step[i]; + vplce[i] = sampler[i].uv_pos; + vince[i] = sampler[i].uv_step; } dc_count = count; draw4columns(); @@ -1179,9 +1260,9 @@ void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_ste // Wrap the uv position for (int i = 0; i < 4; i++) { - uv_pos[i] += uv_step[i] * count; - if (uv_pos[i] >= uv_max) - uv_pos[i] -= uv_max; + sampler[i].uv_pos += sampler[i].uv_step * count; + if (sampler[i].uv_pos >= sampler[i].uv_max) + sampler[i].uv_pos -= sampler[i].uv_max; } left -= count; @@ -1189,22 +1270,6 @@ void wallscan_drawcol4(int x, int y1, int y2, uint32_t *uv_pos, uint32_t *uv_ste } } -// Calculates a wrapped uv start position value for a column -void calc_uv_start_and_step(int y1, float swal, double yrepeat, uint32_t uv_height, int fracbits, uint32_t &uv_start_out, uint32_t &uv_step_out) -{ - double uv_stepd = swal * yrepeat; - - // Find start uv in [0-uv_height[ range. - // Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range. - double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / uv_height; - v = v - floor(v); - v *= uv_height; - v *= (1 << fracbits); - - uv_start_out = (uint32_t)v; - uv_step_out = xs_ToFixed(fracbits, uv_stepd); -} - typedef DWORD(*Draw1ColumnFuncPtr)(); typedef void(*Draw4ColumnsFuncPtr)(); @@ -1216,15 +1281,12 @@ void wallscan_any( if (rw_pic->UseType == FTexture::TEX_Null) return; - uint32_t uv_height = rw_pic->GetHeight(); - uint32_t fracbits = 32 - rw_pic->HeightBits; - uint32_t uv_max = uv_height << fracbits; + fixed_t xoffset = rw_offset; + rw_pic->GetHeight(); // To ensure that rw_pic->HeightBits has been set DWORD(*draw1column)(); void(*draw4columns)(); - setupwallscan(fracbits, draw1column, draw4columns); - - fixed_t xoffset = rw_offset; + setupwallscan(32 - rw_pic->HeightBits, draw1column, draw4columns); bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); if (fixed) @@ -1261,11 +1323,8 @@ void wallscan_any( if (!fixed) R_SetColorMapLight(basecolormap, light, wallshade); - uint32_t uv_start, uv_step; - calc_uv_start_and_step(y1, swal[x], yrepeat, uv_height, fracbits, uv_start, uv_step); - - SamplerSetup sampler(lwal[x] + xoffset, uv_step >> (fracbits - 1) == 0, rw_pic, getcol); - wallscan_drawcol1(x, y1, y2, uv_start, uv_step, uv_max, sampler, draw1column); + WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, rw_pic, getcol); + wallscan_drawcol1(x, y1, y2, sampler, draw1column); } // The aligned columns @@ -1282,17 +1341,9 @@ void wallscan_any( light += rw_lightstep; } - uint32_t uv_pos[4], uv_step[4]; - int magnifying = 0; + WallscanSampler sampler[4]; for (int i = 0; i < 4; i++) - { - calc_uv_start_and_step(y1[i], swal[x + i], yrepeat, uv_height, fracbits, uv_pos[i], uv_step[i]); - magnifying |= uv_step[i] >> (fracbits - 1); - } - - SamplerSetup sampler[4]; - for (int i = 0; i < 4; i++) - sampler[i] = SamplerSetup(lwal[x + i] + xoffset, magnifying == 0, rw_pic, getcol); + sampler[i] = WallscanSampler(y1[i], swal[x + i], yrepeat, lwal[x + i] + xoffset, rw_pic, getcol); // Figure out where we vertically can start and stop drawing 4 columns in one go int middle_y1 = y1[0]; @@ -1305,13 +1356,16 @@ void wallscan_any( // If we got an empty column in our set we cannot draw 4 columns in one go: bool empty_column_in_set = false; + int bilinear_count = 0; for (int i = 0; i < 4; i++) { if (y2[i] <= y1[i]) empty_column_in_set = true; + if (sampler[i].source2) + bilinear_count++; } - if (empty_column_in_set || middle_y2 <= middle_y1) + if (empty_column_in_set || middle_y2 <= middle_y1 || (bilinear_count > 0 && bilinear_count < 4)) { for (int i = 0; i < 4; i++) { @@ -1320,7 +1374,7 @@ void wallscan_any( if (!fixed) R_SetColorMapLight(basecolormap, lights[i], wallshade); - wallscan_drawcol1(x + i, y1[i], y2[i], uv_pos[i], uv_step[i], uv_max, sampler[i], draw1column); + wallscan_drawcol1(x + i, y1[i], y2[i], sampler[i], draw1column); } continue; } @@ -1332,7 +1386,7 @@ void wallscan_any( R_SetColorMapLight(basecolormap, lights[i], wallshade); if (y1[i] < middle_y1) - uv_pos[i] = wallscan_drawcol1(x + i, y1[i], middle_y1, uv_pos[i], uv_step[i], uv_max, sampler[i], draw1column); + wallscan_drawcol1(x + i, y1[i], middle_y1, sampler[i], draw1column); } // Draw the area where all 4 columns are active @@ -1352,7 +1406,7 @@ void wallscan_any( } } } - wallscan_drawcol4(x, middle_y1, middle_y2, uv_pos, uv_step, uv_max, sampler, draw4columns); + wallscan_drawcol4(x, middle_y1, middle_y2, sampler, draw4columns); // Draw the last rows where not all 4 columns are active for (int i = 0; i < 4; i++) @@ -1361,7 +1415,7 @@ void wallscan_any( R_SetColorMapLight(basecolormap, lights[i], wallshade); if (middle_y2 < y2[i]) - uv_pos[i] = wallscan_drawcol1(x + i, middle_y2, y2[i], uv_pos[i], uv_step[i], uv_max, sampler[i], draw1column); + wallscan_drawcol1(x + i, middle_y2, y2[i], sampler[i], draw1column); } } @@ -1376,11 +1430,8 @@ void wallscan_any( if (!fixed) R_SetColorMapLight(basecolormap, light, wallshade); - uint32_t uv_start, uv_step; - calc_uv_start_and_step(y1, swal[x], yrepeat, uv_height, fracbits, uv_start, uv_step); - - SamplerSetup sampler(lwal[x] + xoffset, uv_step >> (fracbits - 1) == 0, rw_pic, getcol); - wallscan_drawcol1(x, y1, y2, uv_start, uv_step, uv_max, sampler, draw1column); + WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, rw_pic, getcol); + wallscan_drawcol1(x, y1, y2, sampler, draw1column); } NetUpdate (); From 4e1c53af913d77829631a3d6862e0a36a957d90b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 22 Jun 2016 13:35:03 +0200 Subject: [PATCH 0692/1509] - fixed FraggleScript's resurrect function to call AActor::Revive to ensure that everything gets reset. --- src/fragglescript/t_func.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index f8648808d..ef4f65d34 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -3473,12 +3473,7 @@ void FParser::SF_Resurrect() mo->SetState(state); mo->Height = mo->GetDefault()->Height; mo->radius = mo->GetDefault()->radius; - mo->flags = mo->GetDefault()->flags; - mo->flags2 = mo->GetDefault()->flags2; - mo->flags3 = mo->GetDefault()->flags3; - mo->flags4 = mo->GetDefault()->flags4; - mo->flags5 = mo->GetDefault()->flags5; - mo->health = mo->GetDefault()->health; + mo->Revive(); mo->target = NULL; } } From 96272fc8b8e9ac03004daa0b3682a0613966aaca Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 22 Jun 2016 13:37:35 +0200 Subject: [PATCH 0693/1509] - removed unused cruft in FS code. --- src/fragglescript/t_func.cpp | 64 ------------------------------------ 1 file changed, 64 deletions(-) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index ef4f65d34..aabe797ef 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -3761,30 +3761,6 @@ void FParser::SF_SetCorona(void) t_return.value.i = 0; } -//========================================================================== -// -// new for GZDoom: Call a Hexen line special (deprecated, superseded by direct use) -// -//========================================================================== - -void FParser::SF_Ls() -{ - int args[5]={0,0,0,0,0}; - int spc; - - if (CheckArgs(1)) - { - spc=intvalue(t_argv[0]); - for(int i=0;i<5;i++) - { - if (t_argc>=i+2) args[i]=intvalue(t_argv[i+1]); - } - if (spc>=0 && spc<256) - P_ExecuteSpecial(spc, NULL,Script->trigger,false, args[0],args[1],args[2],args[3],args[4]); - } -} - - //========================================================================== // // new for GZDoom: Gets the levelnum @@ -4019,17 +3995,6 @@ void FParser::SF_KillInSector() } } -//========================================================================== -// -// new for GZDoom: Sets a sector's type -// -//========================================================================== - -void FParser::SF_SectorType(void) -{ - // I don't think this was ever used publicly so I'm not going to bother fixing it. -} - //========================================================================== // // new for GZDoom: Sets a new line trigger type (Doom format!) @@ -4064,30 +4029,6 @@ void FParser::SF_SetLineTrigger() } -//========================================================================== -// -// -// -//========================================================================== - -void FParser::SF_ChangeTag() -{ - // Development garbage! -} - - -//========================================================================== -// -// -// -//========================================================================== - -void FParser::SF_WallGlow() -{ - // Development garbage! -} - - //========================================================================== // // new for GZDoom: Call a Hexen line special @@ -4505,13 +4446,10 @@ void init_functions(void) // new for GZDoom gscr->NewFunction("spawnshot2", &FParser::SF_SpawnShot2); gscr->NewFunction("setcolor", &FParser::SF_SetColor); - gscr->NewFunction("sectortype", &FParser::SF_SectorType); - gscr->NewFunction("wallglow", &FParser::SF_WallGlow); gscr->NewFunction("objradius", &FParser::SF_MobjRadius); gscr->NewFunction("objheight", &FParser::SF_MobjHeight); gscr->NewFunction("thingcount", &FParser::SF_ThingCount); gscr->NewFunction("killinsector", &FParser::SF_KillInSector); - gscr->NewFunction("changetag", &FParser::SF_ChangeTag); gscr->NewFunction("levelnum", &FParser::SF_LevelNum); // new inventory @@ -4520,8 +4458,6 @@ void init_functions(void) gscr->NewFunction("checkinventory", &FParser::SF_CheckInventory); gscr->NewFunction("setweapon", &FParser::SF_SetWeapon); - gscr->NewFunction("ls", &FParser::SF_Ls); // execute Hexen type line special - // Dummies - shut up warnings gscr->NewFunction("setcorona", &FParser::SF_SetCorona); } From 698b5f3db19dd5b3331cae5a7a234c23192c310a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 24 Jun 2016 11:37:51 +0200 Subject: [PATCH 0694/1509] Simplify drawer code by creating loop iterators Fixed blending bug --- src/r_draw.cpp | 12 +- src/r_draw.h | 6 +- src/r_draw_rgba.cpp | 3338 +++++++++++----------------------------- src/r_draw_rgba.h | 426 ++--- src/r_draw_rgba_sse.h | 116 +- src/r_drawt_rgba.cpp | 70 +- src/r_drawt_rgba_sse.h | 12 +- src/r_plane.cpp | 4 +- src/r_segs.cpp | 16 +- src/r_things.cpp | 2 +- src/v_draw.cpp | 2 +- 11 files changed, 1235 insertions(+), 2769 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 8cca13289..578ca9646 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -1644,6 +1644,8 @@ extern "C" void R_DrawSlabC(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *v int vlinebits; int mvlinebits; +uint32_t vlinemax; +uint32_t mvlinemax; #ifndef X86_ASM static DWORD vlinec1 (); @@ -1693,11 +1695,12 @@ DWORD (*domvline1)() = mvlineasm1; void (*domvline4)() = mvlineasm4; #endif -void setupvline (int fracbits) +void setupvline (int fracbits, int fracmax) { if (r_swtruecolor) { vlinebits = fracbits; + vlinemax = fracmax; return; } @@ -1777,7 +1780,7 @@ void vlinec4 () } #endif -void setupmvline (int fracbits) +void setupmvline (int fracbits, int fracmax) { if (!r_swtruecolor) { @@ -1792,6 +1795,7 @@ void setupmvline (int fracbits) else { mvlinebits = fracbits; + mvlinemax = fracmax; } } @@ -1964,10 +1968,12 @@ void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip) } int tmvlinebits; +uint32_t tmvlinemax; -void setuptmvline (int bits) +void setuptmvline (int bits, int fracmax) { tmvlinebits = bits; + tmvlinemax = fracmax; } fixed_t tmvline1_add_C () diff --git a/src/r_draw.h b/src/r_draw.h index 72304e81f..bd477efc4 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -100,13 +100,13 @@ extern void (*R_DrawColumn)(void); extern DWORD (*dovline1) (); extern DWORD (*doprevline1) (); extern void (*dovline4) (); -extern void setupvline (int); +extern void setupvline (int,int); extern DWORD (*domvline1) (); extern void (*domvline4) (); -extern void setupmvline (int); +extern void setupmvline (int,int); -extern void setuptmvline (int); +extern void setuptmvline (int,int); // The Spectre/Invisibility effect. extern void (*R_DrawFuzzColumn)(void); diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 1e2678bd3..dc97fdd47 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -51,6 +51,9 @@ extern int vlinebits; extern int mvlinebits; extern int tmvlinebits; +extern uint32_t vlinemax; +extern uint32_t mvlinemax; +extern uint32_t tmvlinemax; extern "C" short spanend[MAXHEIGHT]; extern float rw_light; @@ -261,353 +264,520 @@ void DrawerCommandQueue::StopThreads() ///////////////////////////////////////////////////////////////////////////// -class DrawColumnRGBACommand : public DrawerCommand +class DrawerColumnCommand : public DrawerCommand { +public: int _count; BYTE * RESTRICT _dest; - DWORD _texturefrac; - DWORD _iscale; - fixed_t _light; - const BYTE * RESTRICT _source; int _pitch; + DWORD _iscale; + DWORD _texturefrac; + + DrawerColumnCommand() + { + _count = dc_count; + _dest = dc_dest; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _pitch = dc_pitch; + } + + class LoopIterator + { + public: + int count; + uint32_t *dest; + int pitch; + fixed_t fracstep; + fixed_t frac; + + LoopIterator(DrawerColumnCommand *command, DrawerThread *thread) + { + count = thread->count_for_thread(command->_dest_y, command->_count); + if (count <= 0) + return; + + dest = thread->dest_for_thread(command->_dest_y, command->_pitch, (uint32_t*)command->_dest); + pitch = command->_pitch * thread->num_cores; + + fracstep = command->_iscale * thread->num_cores; + frac = command->_texturefrac + command->_iscale * thread->skipped_by_thread(command->_dest_y); + } + + uint32_t sample_index() + { + return frac >> FRACBITS; + } + + explicit operator bool() + { + return count > 0; + } + + bool next() + { + dest += pitch; + frac += fracstep; + return (--count) != 0; + } + }; +}; + +class DrawColumnRGBACommand : public DrawerColumnCommand +{ + uint32_t _light; + const BYTE * RESTRICT _source; ShadeConstants _shade_constants; BYTE * RESTRICT _colormap; public: DrawColumnRGBACommand() { - _count = dc_count; - _dest = dc_dest; - _texturefrac = dc_texturefrac; - _iscale = dc_iscale; - _light = dc_light; - _source = dc_source; - _pitch = dc_pitch; + _light = LightBgra::calc_light_multiplier(dc_light); _shade_constants = dc_shade_constants; + _source = dc_source; _colormap = dc_colormap; } void Execute(DrawerThread *thread) override { - int count; - uint32_t* dest; - fixed_t frac; - fixed_t fracstep; - - count = thread->count_for_thread(_dest_y, _count); - - // Zero length, column does not exceed a pixel. - if (count <= 0) - return; - - // Framebuffer destination address. - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - // Determine scaling, - // which is the only mapping to be done. - fracstep = _iscale * thread->num_cores; - frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - - // [RH] Get local copies of these variables so that the compiler - // has a better chance of optimizing this well. - const BYTE *source = _source; - int pitch = _pitch * thread->num_cores; - BYTE *colormap = _colormap; - + LoopIterator loop(this, thread); + if (!loop) return; do { - *dest = shade_pal_index(colormap[source[frac >> FRACBITS]], light, shade_constants); - - dest += pitch; - frac += fracstep; - - } while (--count); + uint32_t fg = LightBgra::shade_pal_index(_colormap[_source[loop.sample_index()]], _light, _shade_constants); + *loop.dest = BlendBgra::copy(fg); + } while (loop.next()); } }; -class FillColumnRGBACommand : public DrawerCommand +class FillColumnRGBACommand : public DrawerColumnCommand { - int _count; - BYTE * RESTRICT _dest; - fixed_t _light; - int _pitch; - int _color; + uint32_t _color; public: FillColumnRGBACommand() { - _count = dc_count; - _dest = dc_dest; - _light = dc_light; - _pitch = dc_pitch; - _color = dc_color; + uint32_t light = LightBgra::calc_light_multiplier(dc_light); + _color = LightBgra::shade_pal_index_simple(dc_color, light); } void Execute(DrawerThread *thread) override { - int count; - uint32_t* dest; - - count = thread->count_for_thread(_dest_y, _count); - - if (count <= 0) - return; - - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - - uint32_t light = calc_light_multiplier(_light); - + LoopIterator loop(this, thread); + if (!loop) return; + do { - int pitch = _pitch * thread->num_cores; - uint32_t color = shade_pal_index_simple(_color, light); - - do - { - *dest = color; - dest += pitch; - } while (--count); - } + *loop.dest = BlendBgra::copy(_color); + } while (loop.next()); } }; -class FillAddColumnRGBACommand : public DrawerCommand +class FillAddColumnRGBACommand : public DrawerColumnCommand { - int _count; - BYTE * RESTRICT _dest; - int _pitch; uint32_t _srccolor; public: FillAddColumnRGBACommand() { - _count = dc_count; - _dest = dc_dest; - _pitch = dc_pitch; _srccolor = dc_srccolor_bgra; } void Execute(DrawerThread *thread) override { - int count; - uint32_t *dest; + LoopIterator loop(this, thread); + if (!loop) return; - count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - - uint32_t fg = _srccolor; - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - uint32_t fg_alpha = fg >> 24; - fg_alpha += fg_alpha >> 7; - - fg_red *= fg_alpha; - fg_green *= fg_alpha; - fg_blue *= fg_alpha; - - uint32_t inv_alpha = 256 - fg_alpha; + uint32_t alpha = APART(_srccolor); + alpha += alpha >> 7; do { - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red + bg_red * inv_alpha) / 256; - uint32_t green = (fg_green + bg_green * inv_alpha) / 256; - uint32_t blue = (fg_blue + bg_blue * inv_alpha) / 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--count); + *loop.dest = BlendBgra::add(_srccolor, *loop.dest, alpha, 256 - alpha); + } while (loop.next()); } }; -class FillAddClampColumnRGBACommand : public DrawerCommand +class FillAddClampColumnRGBACommand : public DrawerColumnCommand { - int _count; - BYTE * RESTRICT _dest; - int _pitch; int _color; uint32_t _srccolor; - fixed_t _srcalpha; - fixed_t _destalpha; + uint32_t _srcalpha; + uint32_t _destalpha; public: FillAddClampColumnRGBACommand() { - _count = dc_count; - _dest = dc_dest; - _pitch = dc_pitch; _color = dc_color; _srccolor = dc_srccolor_bgra; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); } void Execute(DrawerThread *thread) override { - int count; - uint32_t *dest; - - count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - - uint32_t fg = _srccolor; - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - fg_red *= fg_alpha; - fg_green *= fg_alpha; - fg_blue *= fg_alpha; - - do { - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--count); + LoopIterator loop(this, thread); + if (!loop) return; + do + { + *loop.dest = BlendBgra::add(_srccolor, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); } }; -class FillSubClampColumnRGBACommand : public DrawerCommand +class FillSubClampColumnRGBACommand : public DrawerColumnCommand { - int _count; - BYTE * RESTRICT _dest; - int _pitch; - int _color; uint32_t _srccolor; - fixed_t _srcalpha; - fixed_t _destalpha; + uint32_t _srcalpha; + uint32_t _destalpha; public: FillSubClampColumnRGBACommand() { - _count = dc_count; - _dest = dc_dest; - _pitch = dc_pitch; - _color = dc_color; _srccolor = dc_srccolor_bgra; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); } void Execute(DrawerThread *thread) override { - int count; - uint32_t *dest; - - count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - - uint32_t fg = _srccolor; - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - fg_red *= fg_alpha; - fg_green *= fg_alpha; - fg_blue *= fg_alpha; - - do { - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 - fg_red + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--count); + LoopIterator loop(this, thread); + if (!loop) return; + do + { + *loop.dest = BlendBgra::sub(_srccolor, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); } }; -class FillRevSubClampColumnRGBACommand : public DrawerCommand +class FillRevSubClampColumnRGBACommand : public DrawerColumnCommand { - int _count; - BYTE * RESTRICT _dest; - int _pitch; - int _color; uint32_t _srccolor; - fixed_t _srcalpha; - fixed_t _destalpha; + uint32_t _srcalpha; + uint32_t _destalpha; public: FillRevSubClampColumnRGBACommand() { - _count = dc_count; - _dest = dc_dest; - _pitch = dc_pitch; - _color = dc_color; _srccolor = dc_srccolor_bgra; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); } void Execute(DrawerThread *thread) override { - int count; - uint32_t *dest; + LoopIterator loop(this, thread); + if (!loop) return; + do + { + *loop.dest = BlendBgra::revsub(_srccolor, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); + } +}; - count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; +class DrawAddColumnRGBACommand : public DrawerColumnCommand +{ + const BYTE * RESTRICT _source; + uint32_t _light; + ShadeConstants _shade_constants; + uint32_t _srcalpha; + uint32_t _destalpha; + BYTE * RESTRICT _colormap; - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; +public: + DrawAddColumnRGBACommand() + { + _source = dc_source; + _light = LightBgra::calc_light_multiplier(dc_light); + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); + _colormap = dc_colormap; + } - uint32_t fg = _srccolor; - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = LightBgra::shade_pal_index(_colormap[_source[loop.sample_index()]], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); + } +}; - fg_red *= fg_alpha; - fg_green *= fg_alpha; - fg_blue *= fg_alpha; +class DrawTranslatedColumnRGBACommand : public DrawerColumnCommand +{ + fixed_t _light; + ShadeConstants _shade_constants; + BYTE * RESTRICT _translation; + const BYTE * RESTRICT _source; - do { - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; +public: + DrawTranslatedColumnRGBACommand() + { + _light = LightBgra::calc_light_multiplier(dc_light); + _shade_constants = dc_shade_constants; + _translation = dc_translation; + _source = dc_source; + } - uint32_t red = clamp((0x10000 + fg_red - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = LightBgra::shade_pal_index(_translation[_source[loop.sample_index()]], _light, _shade_constants); + *loop.dest = BlendBgra::copy(fg); + } while (loop.next()); + } +}; - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - } while (--count); +class DrawTlatedAddColumnRGBACommand : public DrawerColumnCommand +{ + fixed_t _light; + ShadeConstants _shade_constants; + BYTE * RESTRICT _translation; + const BYTE * RESTRICT _source; + uint32_t _srcalpha; + uint32_t _destalpha; + +public: + DrawTlatedAddColumnRGBACommand() + { + _light = LightBgra::calc_light_multiplier(dc_light); + _shade_constants = dc_shade_constants; + _translation = dc_translation; + _source = dc_source; + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = LightBgra::shade_pal_index(_translation[_source[loop.sample_index()]], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); + } +}; + +class DrawShadedColumnRGBACommand : public DrawerColumnCommand +{ +private: + const BYTE * RESTRICT _source; + lighttable_t * RESTRICT _colormap; + uint32_t _color; + +public: + DrawShadedColumnRGBACommand() + { + _source = dc_source; + _colormap = dc_colormap; + _color = LightBgra::shade_pal_index_simple(dc_color, LightBgra::calc_light_multiplier(dc_light)); + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t alpha = clamp(_colormap[_source[loop.sample_index()]], 0, 64) * 4; + uint32_t inv_alpha = 256 - alpha; + *loop.dest = BlendBgra::add(_color, *loop.dest, alpha, inv_alpha); + } while (loop.next()); + } +}; + +class DrawAddClampColumnRGBACommand : public DrawerColumnCommand +{ + const BYTE * RESTRICT _source; + uint32_t _light; + ShadeConstants _shade_constants; + uint32_t _srcalpha; + uint32_t _destalpha; + +public: + DrawAddClampColumnRGBACommand() + { + _source = dc_source; + _light = LightBgra::calc_light_multiplier(dc_light); + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = LightBgra::shade_pal_index(_source[loop.sample_index()], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); + } +}; + +class DrawAddClampTranslatedColumnRGBACommand : public DrawerColumnCommand +{ + BYTE * RESTRICT _translation; + const BYTE * RESTRICT _source; + uint32_t _light; + ShadeConstants _shade_constants; + uint32_t _srcalpha; + uint32_t _destalpha; + +public: + DrawAddClampTranslatedColumnRGBACommand() + { + _translation = dc_translation; + _source = dc_source; + _light = LightBgra::calc_light_multiplier(dc_light); + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = LightBgra::shade_pal_index(_translation[_source[loop.sample_index()]], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); + } +}; + +class DrawSubClampColumnRGBACommand : public DrawerColumnCommand +{ + const BYTE * RESTRICT _source; + uint32_t _light; + ShadeConstants _shade_constants; + uint32_t _srcalpha; + uint32_t _destalpha; + +public: + DrawSubClampColumnRGBACommand() + { + _source = dc_source; + _light = LightBgra::calc_light_multiplier(dc_light); + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = LightBgra::shade_pal_index(_source[loop.sample_index()], _light, _shade_constants); + *loop.dest = BlendBgra::sub(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); + } +}; + +class DrawSubClampTranslatedColumnRGBACommand : public DrawerColumnCommand +{ + const BYTE * RESTRICT _source; + uint32_t _light; + ShadeConstants _shade_constants; + uint32_t _srcalpha; + uint32_t _destalpha; + BYTE * RESTRICT _translation; + +public: + DrawSubClampTranslatedColumnRGBACommand() + { + _source = dc_source; + _light = LightBgra::calc_light_multiplier(dc_light); + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); + _translation = dc_translation; + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = LightBgra::shade_pal_index(_translation[_source[loop.sample_index()]], _light, _shade_constants); + *loop.dest = BlendBgra::sub(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); + } +}; + +class DrawRevSubClampColumnRGBACommand : public DrawerColumnCommand +{ + const BYTE * RESTRICT _source; + uint32_t _light; + ShadeConstants _shade_constants; + uint32_t _srcalpha; + uint32_t _destalpha; + +public: + DrawRevSubClampColumnRGBACommand() + { + _source = dc_source; + _light = LightBgra::calc_light_multiplier(dc_light); + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = LightBgra::shade_pal_index(_source[loop.sample_index()], _light, _shade_constants); + *loop.dest = BlendBgra::revsub(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); + } +}; + +class DrawRevSubClampTranslatedColumnRGBACommand : public DrawerColumnCommand +{ + const BYTE * RESTRICT _source; + uint32_t _light; + ShadeConstants _shade_constants; + uint32_t _srcalpha; + uint32_t _destalpha; + BYTE * RESTRICT _translation; + +public: + DrawRevSubClampTranslatedColumnRGBACommand() + { + _source = dc_source; + _light = LightBgra::calc_light_multiplier(dc_light); + _shade_constants = dc_shade_constants; + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); + _translation = dc_translation; + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = LightBgra::shade_pal_index(_translation[_source[loop.sample_index()]], _light, _shade_constants); + *loop.dest = BlendBgra::revsub(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); } }; @@ -635,19 +805,16 @@ public: void Execute(DrawerThread *thread) override { - int count; - uint32_t *dest; - int yl = MAX(_yl, 1); int yh = MIN(_yh, _fuzzviewheight); - count = thread->count_for_thread(yl, yh - yl + 1); + int count = thread->count_for_thread(yl, yh - yl + 1); // Zero length. if (count <= 0) return; - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + _x + (uint32_t*)_destorg); + uint32_t *dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + _x + (uint32_t*)_destorg); int pitch = _pitch * thread->num_cores; int fuzzstep = thread->num_cores; @@ -659,13 +826,10 @@ public: if (yl < fuzzstep) { uint32_t bg = dest[fuzzoffset[fuzz] * fuzzstep + pitch]; - uint32_t bg_red = (bg >> 16) & 0xff; - uint32_t bg_green = (bg >> 8) & 0xff; - uint32_t bg_blue = (bg) & 0xff; - uint32_t red = bg_red * 3 / 4; - uint32_t green = bg_green * 3 / 4; - uint32_t blue = bg_blue * 3 / 4; + uint32_t red = RPART(bg) * 3 / 4; + uint32_t green = GPART(bg) * 3 / 4; + uint32_t blue = BPART(bg) * 3 / 4; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -694,13 +858,10 @@ public: do { uint32_t bg = dest[fuzzoffset[fuzz] * fuzzstep]; - uint32_t bg_red = (bg >> 16) & 0xff; - uint32_t bg_green = (bg >> 8) & 0xff; - uint32_t bg_blue = (bg) & 0xff; - uint32_t red = bg_red * 3 / 4; - uint32_t green = bg_green * 3 / 4; - uint32_t blue = bg_blue * 3 / 4; + uint32_t red = RPART(bg) * 3 / 4; + uint32_t green = GPART(bg) * 3 / 4; + uint32_t blue = BPART(bg) * 3 / 4; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; @@ -714,783 +875,21 @@ public: if (lowerbounds) { uint32_t bg = dest[fuzzoffset[fuzz] * fuzzstep - pitch]; - uint32_t bg_red = (bg >> 16) & 0xff; - uint32_t bg_green = (bg >> 8) & 0xff; - uint32_t bg_blue = (bg) & 0xff; - uint32_t red = bg_red * 3 / 4; - uint32_t green = bg_green * 3 / 4; - uint32_t blue = bg_blue * 3 / 4; + uint32_t red = RPART(bg) * 3 / 4; + uint32_t green = GPART(bg) * 3 / 4; + uint32_t blue = BPART(bg) * 3 / 4; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; } } }; -class DrawAddColumnRGBACommand : public DrawerCommand -{ - int _count; - BYTE * RESTRICT _dest; - DWORD _iscale; - DWORD _texturefrac; - const BYTE * RESTRICT _source; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - BYTE * RESTRICT _colormap; +///////////////////////////////////////////////////////////////////////////// +class DrawerSpanCommand : public DrawerCommand +{ public: - DrawAddColumnRGBACommand() - { - _count = dc_count; - _dest = dc_dest; - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _source = dc_source; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - _colormap = dc_colormap; - } - - void Execute(DrawerThread *thread) override - { - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - - fracstep = _iscale * thread->num_cores; - frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - - { - const BYTE *source = _source; - int pitch = _pitch * thread->num_cores; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - BYTE *colormap = _colormap; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light, shade_constants); - - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } - } -}; - -class DrawTranslatedColumnRGBACommand : public DrawerCommand -{ - int _count; - fixed_t _light; - ShadeConstants _shade_constants; - BYTE * RESTRICT _dest; - DWORD _iscale; - DWORD _texturefrac; - BYTE * RESTRICT _translation; - const BYTE * RESTRICT _source; - int _pitch; - -public: - DrawTranslatedColumnRGBACommand() - { - _count = dc_count; - _light = dc_light; - _shade_constants = dc_shade_constants; - _dest = dc_dest; - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _translation = dc_translation; - _source = dc_source; - _pitch = dc_pitch; - } - - void Execute(DrawerThread *thread) override - { - int count; - uint32_t* dest; - fixed_t frac; - fixed_t fracstep; - - count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - - fracstep = _iscale * thread->num_cores; - frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - - { - // [RH] Local copies of global vars to improve compiler optimizations - BYTE *translation = _translation; - const BYTE *source = _source; - int pitch = _pitch * thread->num_cores; - - do - { - *dest = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); - dest += pitch; - frac += fracstep; - } while (--count); - } - } -}; - -class DrawTlatedAddColumnRGBACommand : public DrawerCommand -{ - int _count; - fixed_t _light; - ShadeConstants _shade_constants; - BYTE * RESTRICT _dest; - DWORD _iscale; - DWORD _texturefrac; - BYTE * RESTRICT _translation; - const BYTE * RESTRICT _source; - int _pitch; - fixed_t _srcalpha; - fixed_t _destalpha; - -public: - DrawTlatedAddColumnRGBACommand() - { - _count = dc_count; - _light = dc_light; - _shade_constants = dc_shade_constants; - _dest = dc_dest; - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _translation = dc_translation; - _source = dc_source; - _pitch = dc_pitch; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - } - - void Execute(DrawerThread *thread) override - { - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - - fracstep = _iscale * thread->num_cores; - frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - - { - BYTE *translation = _translation; - const BYTE *source = _source; - int pitch = _pitch * thread->num_cores; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); - - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } - } -}; - -class DrawShadedColumnRGBACommand : public DrawerCommand -{ -private: - int _count; - BYTE * RESTRICT _dest; - DWORD _iscale; - DWORD _texturefrac; - fixed_t _light; - const BYTE * RESTRICT _source; - lighttable_t * RESTRICT _colormap; - int _color; - int _pitch; - -public: - DrawShadedColumnRGBACommand() - { - _count = dc_count; - _dest = dc_dest; - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _light = dc_light; - _source = dc_source; - _colormap = dc_colormap; - _color = dc_color; - _pitch = dc_pitch; - } - - void Execute(DrawerThread *thread) override - { - int count; - uint32_t *dest; - fixed_t frac, fracstep; - - count = thread->count_for_thread(_dest_y, _count); - - if (count <= 0) - return; - - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - - fracstep = _iscale * thread->num_cores; - frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - - uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - { - const BYTE *source = _source; - BYTE *colormap = _colormap; - int pitch = _pitch * thread->num_cores; - - do - { - DWORD alpha = clamp(colormap[source[frac >> FRACBITS]], 0, 64); - DWORD inv_alpha = 64 - alpha; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; - uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; - uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } - } -}; - -class DrawAddClampColumnRGBACommand : public DrawerCommand -{ - int _count; - BYTE * RESTRICT _dest; - DWORD _iscale; - DWORD _texturefrac; - const BYTE * RESTRICT _source; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - -public: - DrawAddClampColumnRGBACommand() - { - _count = dc_count; - _dest = dc_dest; - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _source = dc_source; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - } - - void Execute(DrawerThread *thread) override - { - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - - fracstep = _iscale * thread->num_cores; - frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - - { - const BYTE *source = _source; - int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } - } -}; - -class DrawAddClampTranslatedColumnRGBACommand : public DrawerCommand -{ - int _count; - BYTE * RESTRICT _dest; - DWORD _iscale; - DWORD _texturefrac; - BYTE * RESTRICT _translation; - const BYTE * RESTRICT _source; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - -public: - DrawAddClampTranslatedColumnRGBACommand() - { - _count = dc_count; - _dest = dc_dest; - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _translation = dc_translation; - _source = dc_source; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - } - - void Execute(DrawerThread *thread) override - { - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - - fracstep = _iscale * thread->num_cores; - frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - - { - BYTE *translation = _translation; - const BYTE *source = _source; - int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } - } -}; - -class DrawSubClampColumnRGBACommand : public DrawerCommand -{ - int _count; - BYTE * RESTRICT _dest; - DWORD _iscale; - DWORD _texturefrac; - const BYTE * RESTRICT _source; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - -public: - DrawSubClampColumnRGBACommand() - { - _count = dc_count; - _dest = dc_dest; - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _source = dc_source; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - } - - void Execute(DrawerThread *thread) override - { - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - - fracstep = _iscale * thread->num_cores; - frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - - { - const BYTE *source = _source; - int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } - } -}; - -class DrawSubClampTranslatedColumnRGBACommand : public DrawerCommand -{ - int _count; - BYTE * RESTRICT _dest; - DWORD _iscale; - DWORD _texturefrac; - const BYTE * RESTRICT _source; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - BYTE * RESTRICT _translation; - -public: - DrawSubClampTranslatedColumnRGBACommand() - { - _count = dc_count; - _dest = dc_dest; - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _source = dc_source; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - _translation = dc_translation; - } - - void Execute(DrawerThread *thread) override - { - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - - fracstep = _iscale * thread->num_cores; - frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - - { - BYTE *translation = _translation; - const BYTE *source = _source; - int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } - } -}; - -class DrawRevSubClampColumnRGBACommand : public DrawerCommand -{ - int _count; - BYTE * RESTRICT _dest; - DWORD _iscale; - DWORD _texturefrac; - const BYTE * RESTRICT _source; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - -public: - DrawRevSubClampColumnRGBACommand() - { - _count = dc_count; - _dest = dc_dest; - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _source = dc_source; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - } - - void Execute(DrawerThread *thread) override - { - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - - fracstep = _iscale * thread->num_cores; - frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - - { - const BYTE *source = _source; - int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } - } -}; - -class DrawRevSubClampTranslatedColumnRGBACommand : public DrawerCommand -{ - int _count; - BYTE * RESTRICT _dest; - DWORD _iscale; - DWORD _texturefrac; - const BYTE * RESTRICT _source; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - BYTE * RESTRICT _translation; - -public: - DrawRevSubClampTranslatedColumnRGBACommand() - { - _count = dc_count; - _dest = dc_dest; - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _source = dc_source; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - _translation = dc_translation; - } - - void Execute(DrawerThread *thread) override - { - int count; - uint32_t *dest; - fixed_t frac; - fixed_t fracstep; - - count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - - fracstep = _iscale * thread->num_cores; - frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - - { - BYTE * RESTRICT translation = _translation; - const BYTE * RESTRICT source = _source; - int pitch = _pitch * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do - { - uint32_t fg = shade_pal_index(translation[source[frac >> FRACBITS]], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - frac += fracstep; - } while (--count); - } - } -}; - -class DrawSpanRGBACommand : public DrawerCommand -{ - const uint32_t * RESTRICT _source; fixed_t _xfrac; fixed_t _yfrac; fixed_t _xstep; @@ -1501,14 +900,17 @@ class DrawSpanRGBACommand : public DrawerCommand int _xbits; int _ybits; BYTE * RESTRICT _destorg; - fixed_t _light; + + const uint32_t * RESTRICT _source; + uint32_t _light; ShadeConstants _shade_constants; bool _magnifying; -public: - DrawSpanRGBACommand() + uint32_t _srcalpha; + uint32_t _destalpha; + + DrawerSpanCommand() { - _source = (const uint32_t*)ds_source; _xfrac = ds_xfrac; _yfrac = ds_yfrac; _xstep = ds_xstep; @@ -1519,752 +921,270 @@ public: _xbits = ds_xbits; _ybits = ds_ybits; _destorg = dc_destorg; - _light = ds_light; + + _source = (const uint32_t*)ds_source; + _light = LightBgra::calc_light_multiplier(ds_light); _shade_constants = ds_shade_constants; - _magnifying = !span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep); + _magnifying = !SampleBgra::span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep); + + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); } + class LoopIterator + { + public: + uint32_t *dest; + int count; + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + BYTE yshift; + BYTE xshift; + int xmask; + bool is_64x64; + bool skipped; + + LoopIterator(DrawerSpanCommand *command, DrawerThread *thread) + { + dest = ylookup[command->_y] + command->_x1 + (uint32_t*)command->_destorg; + count = command->_x2 - command->_x1 + 1; + xfrac = command->_xfrac; + yfrac = command->_yfrac; + xstep = command->_xstep; + ystep = command->_ystep; + yshift = 32 - command->_ybits; + xshift = yshift - command->_xbits; + xmask = ((1 << command->_xbits) - 1) << command->_ybits; + is_64x64 = command->_xbits == 6 && command->_ybits == 6; + skipped = thread->line_skipped_by_thread(command->_y); + } + + // 64x64 is the most common case by far, so special case it. + int spot64() + { + return ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + } + + int spot() + { + return ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + } + + explicit operator bool() + { + return !skipped && count > 0; + } + + bool next() + { + dest++; + xfrac += xstep; + yfrac += ystep; + return (--count) != 0; + } + }; +}; + +class DrawSpanRGBACommand : public DrawerSpanCommand +{ +public: void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(_y)) - return; - - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const uint32_t* source = _source; - int count; - int spot; - - xfrac = _xfrac; - yfrac = _yfrac; - - dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - - count = _x2 - _x1 + 1; - - xstep = _xstep; - ystep = _ystep; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; + LoopIterator loop(this, thread); + if (!loop) return; if (_magnifying) { - if (_xbits == 6 && _ybits == 6) + if (loop.is_64x64) { - // 64x64 is the most common case by far, so special case it. - do { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - - // Lookup pixel from flat texture tile - *dest++ = shade_bgra(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); + *loop.dest = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); + } while (loop.next()); } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; - do { - // Current texture index in u,v. - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - - // Lookup pixel from flat texture tile - *dest++ = shade_bgra(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); + *loop.dest = LightBgra::shade_bgra(_source[loop.spot()], _light, _shade_constants); + } while (loop.next()); } } else { - if (_xbits == 6 && _ybits == 6) + if (loop.is_64x64) { - // 64x64 is the most common case by far, so special case it. - do { - *dest++ = shade_bgra(sample_bilinear(source, xfrac, yfrac, 26, 26), light, shade_constants); - xfrac += xstep; - yfrac += ystep; - } while (--count); + *loop.dest = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, loop.xfrac, loop.yfrac, 26, 26), _light, _shade_constants); + } while (loop.next()); } else { do { - *dest++ = shade_bgra(sample_bilinear(source, xfrac, yfrac, 32 - _xbits, 32 - _ybits), light, shade_constants); - xfrac += xstep; - yfrac += ystep; - } while (--count); + *loop.dest = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, loop.xfrac, loop.yfrac, 32 - _xbits, 32 - _ybits), _light, _shade_constants); + } while (loop.next()); } } } }; -class DrawSpanMaskedRGBACommand : public DrawerCommand +class DrawSpanMaskedRGBACommand : public DrawerSpanCommand { - const uint32_t * RESTRICT _source; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _xfrac; - fixed_t _yfrac; - BYTE * RESTRICT _destorg; - int _x1; - int _x2; - int _y1; - int _y; - fixed_t _xstep; - fixed_t _ystep; - int _xbits; - int _ybits; - bool _magnifying; - public: - DrawSpanMaskedRGBACommand() - { - _source = (const uint32_t*)ds_source; - _light = ds_light; - _shade_constants = ds_shade_constants; - _xfrac = ds_xfrac; - _yfrac = ds_yfrac; - _destorg = dc_destorg; - _x1 = ds_x1; - _x2 = ds_x2; - _y = ds_y; - _xstep = ds_xstep; - _ystep = ds_ystep; - _xbits = ds_xbits; - _ybits = ds_ybits; - _magnifying = !span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep); - } - void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(_y)) - return; - - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const uint32_t* source = _source; - int count; - int spot; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - xfrac = _xfrac; - yfrac = _yfrac; - - dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - - count = _x2 - _x1 + 1; - - xstep = _xstep; - ystep = _ystep; + LoopIterator loop(this, thread); + if (!loop) return; if (_magnifying) { - if (_xbits == 6 && _ybits == 6) + if (loop.is_64x64) { - // 64x64 is the most common case by far, so special case it. do { - uint32_t texdata; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - texdata = source[spot]; - *dest = alpha_blend(shade_bgra(texdata, light, shade_constants), *dest); - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); + *loop.dest = BlendBgra::alpha_blend(fg, *loop.dest); + } while (loop.next()); } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; do { - uint32_t texdata; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - texdata = source[spot]; - *dest = alpha_blend(shade_bgra(texdata, light, shade_constants), *dest); - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.spot()], _light, _shade_constants); + *loop.dest = BlendBgra::alpha_blend(fg, *loop.dest); + } while (loop.next()); } } else { - if (_xbits == 6 && _ybits == 6) + if (loop.is_64x64) { - // 64x64 is the most common case by far, so special case it. do { - *dest = alpha_blend(shade_bgra(sample_bilinear(source, xfrac, yfrac, 26, 26), light, shade_constants), *dest); - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, loop.xfrac, loop.yfrac, 26, 26), _light, _shade_constants); + *loop.dest = BlendBgra::alpha_blend(fg, *loop.dest); + } while (loop.next()); } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; do { - *dest = alpha_blend(shade_bgra(sample_bilinear(source, xfrac, yfrac, 32 - _xbits, 32 - _ybits), light, shade_constants), *dest); - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, loop.xfrac, loop.yfrac, 32 - _xbits, 32 - _ybits), _light, _shade_constants); + *loop.dest = BlendBgra::alpha_blend(fg, *loop.dest); + } while (loop.next()); } } } }; -class DrawSpanTranslucentRGBACommand : public DrawerCommand +class DrawSpanTranslucentRGBACommand : public DrawerSpanCommand { - const uint32_t * RESTRICT _source; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _xfrac; - fixed_t _yfrac; - BYTE * RESTRICT _destorg; - int _x1; - int _x2; - int _y1; - int _y; - fixed_t _xstep; - fixed_t _ystep; - int _xbits; - int _ybits; - fixed_t _srcalpha; - fixed_t _destalpha; - public: - DrawSpanTranslucentRGBACommand() - { - _source = (const uint32_t *)ds_source; - _light = ds_light; - _shade_constants = ds_shade_constants; - _xfrac = ds_xfrac; - _yfrac = ds_yfrac; - _destorg = dc_destorg; - _x1 = ds_x1; - _x2 = ds_x2; - _y = ds_y; - _xstep = ds_xstep; - _ystep = ds_ystep; - _xbits = ds_xbits; - _ybits = ds_ybits; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - } - void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(_y)) - return; + LoopIterator loop(this, thread); + if (!loop) return; - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const uint32_t* source = _source; - int count; - int spot; - - xfrac = _xfrac; - yfrac = _yfrac; - - dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - - count = _x2 - _x1 + 1; - - xstep = _xstep; - ystep = _ystep; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - if (_xbits == 6 && _ybits == 6) + if (loop.is_64x64) { - // 64x64 is the most common case by far, so special case it. do { - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - - uint32_t fg = shade_bgra(source[spot], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; - uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; - uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; - - *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; - - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; do { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - - uint32_t fg = shade_bgra(source[spot], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; - uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; - uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; - - *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; - - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.spot()], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); } } }; -class DrawSpanMaskedTranslucentRGBACommand : public DrawerCommand +class DrawSpanMaskedTranslucentRGBACommand : public DrawerSpanCommand { - const uint32_t * RESTRICT _source; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _xfrac; - fixed_t _yfrac; - BYTE * RESTRICT _destorg; - int _x1; - int _x2; - int _y1; - int _y; - fixed_t _xstep; - fixed_t _ystep; - int _xbits; - int _ybits; - fixed_t _srcalpha; - fixed_t _destalpha; - public: - DrawSpanMaskedTranslucentRGBACommand() - { - _source = (const uint32_t*)ds_source; - _light = ds_light; - _shade_constants = ds_shade_constants; - _xfrac = ds_xfrac; - _yfrac = ds_yfrac; - _destorg = dc_destorg; - _x1 = ds_x1; - _x2 = ds_x2; - _y = ds_y; - _xstep = ds_xstep; - _ystep = ds_ystep; - _xbits = ds_xbits; - _ybits = ds_ybits; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - } - void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(_y)) - return; + LoopIterator loop(this, thread); + if (!loop) return; - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const uint32_t* source = _source; - int count; - int spot; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - xfrac = _xfrac; - yfrac = _yfrac; - - dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - - count = _x2 - _x1 + 1; - - xstep = _xstep; - ystep = _ystep; - - if (_xbits == 6 && _ybits == 6) + if (loop.is_64x64) { - // 64x64 is the most common case by far, so special case it. do { - uint32_t texdata; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - texdata = source[spot]; - if (texdata != 0) - { - uint32_t fg = shade_bgra(texdata, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; - uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; - uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); + } while (loop.next()); } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; do { - uint32_t texdata; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - texdata = source[spot]; - if (texdata != 0) - { - uint32_t fg = shade_bgra(texdata, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; - uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; - uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.spot()], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); + } while (loop.next()); } } }; -class DrawSpanAddClampRGBACommand : public DrawerCommand +class DrawSpanAddClampRGBACommand : public DrawerSpanCommand { - const uint32_t * RESTRICT _source; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _xfrac; - fixed_t _yfrac; - BYTE * RESTRICT _destorg; - int _x1; - int _x2; - int _y1; - int _y; - fixed_t _xstep; - fixed_t _ystep; - int _xbits; - int _ybits; - fixed_t _srcalpha; - fixed_t _destalpha; - public: - DrawSpanAddClampRGBACommand() - { - _source = (const uint32_t*)ds_source; - _light = ds_light; - _shade_constants = ds_shade_constants; - _xfrac = ds_xfrac; - _yfrac = ds_yfrac; - _destorg = dc_destorg; - _x1 = ds_x1; - _x2 = ds_x2; - _y = ds_y; - _xstep = ds_xstep; - _ystep = ds_ystep; - _xbits = ds_xbits; - _ybits = ds_ybits; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - } - void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(_y)) - return; + LoopIterator loop(this, thread); + if (!loop) return; - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const uint32_t* source = _source; - int count; - int spot; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - xfrac = _xfrac; - yfrac = _yfrac; - - dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - - count = _x2 - _x1 + 1; - - xstep = _xstep; - ystep = _ystep; - - if (_xbits == 6 && _ybits == 6) + if (loop.is_64x64) { - // 64x64 is the most common case by far, so special case it. do { - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - - uint32_t fg = shade_bgra(source[spot], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; - - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; do { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - - uint32_t fg = shade_bgra(source[spot], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest++ = 0xff000000 | (red << 16) | (green << 8) | blue; - - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.spot()], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); } } }; -class DrawSpanMaskedAddClampRGBACommand : public DrawerCommand +class DrawSpanMaskedAddClampRGBACommand : public DrawerSpanCommand { - const uint32_t * RESTRICT _source; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _xfrac; - fixed_t _yfrac; - BYTE * RESTRICT _destorg; - int _x1; - int _x2; - int _y1; - int _y; - fixed_t _xstep; - fixed_t _ystep; - int _xbits; - int _ybits; - fixed_t _srcalpha; - fixed_t _destalpha; - public: - DrawSpanMaskedAddClampRGBACommand() - { - _source = (const uint32_t*)ds_source; - _light = ds_light; - _shade_constants = ds_shade_constants; - _xfrac = ds_xfrac; - _yfrac = ds_yfrac; - _destorg = dc_destorg; - _x1 = ds_x1; - _x2 = ds_x2; - _y = ds_y; - _xstep = ds_xstep; - _ystep = ds_ystep; - _xbits = ds_xbits; - _ybits = ds_ybits; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - } - void Execute(DrawerThread *thread) override { - if (thread->line_skipped_by_thread(_y)) - return; + LoopIterator loop(this, thread); + if (!loop) return; - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const uint32_t* source = _source; - int count; - int spot; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - xfrac = _xfrac; - yfrac = _yfrac; - - dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - - count = _x2 - _x1 + 1; - - xstep = _xstep; - ystep = _ystep; - - if (_xbits == 6 && _ybits == 6) + if (loop.is_64x64) { - // 64x64 is the most common case by far, so special case it. do { - uint32_t texdata; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - texdata = source[spot]; - if (texdata != 0) - { - uint32_t fg = shade_bgra(texdata, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; - uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; - uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); + } while (loop.next()); } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; do { - uint32_t texdata; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - texdata = source[spot]; - if (texdata != 0) - { - uint32_t fg = shade_bgra(texdata, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = (fg) & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * fg_alpha + bg_red * bg_alpha) / 256; - uint32_t green = (fg_green * fg_alpha + bg_green * bg_alpha) / 256; - uint32_t blue = (fg_blue * fg_alpha + bg_blue * bg_alpha) / 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.spot()], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); + } while (loop.next()); } } }; @@ -2296,13 +1216,15 @@ public: uint32_t *dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; int count = (_x2 - _x1 + 1); - uint32_t light = calc_light_multiplier(_light); - uint32_t color = shade_pal_index_simple(_color, light); + uint32_t light = LightBgra::calc_light_multiplier(_light); + uint32_t color = LightBgra::shade_pal_index_simple(_color, light); for (int i = 0; i < count; i++) dest[i] = color; } }; +///////////////////////////////////////////////////////////////////////////// + class DrawSlabRGBACommand : public DrawerCommand { int _dx; @@ -2344,7 +1266,7 @@ public: uint32_t *p = _p; ShadeConstants shade_constants = _shade_constants; const BYTE *colormap = _colormap; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); int pitch = _pitch; int x; @@ -2358,7 +1280,7 @@ public: { while (dy > 0) { - *p = shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); + *p = LightBgra::shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); p += pitch; v += vi; dy--; @@ -2368,7 +1290,7 @@ public: { while (dy > 0) { - uint32_t color = shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); + uint32_t color = LightBgra::shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); p[0] = color; p[1] = color; p += pitch; @@ -2380,7 +1302,7 @@ public: { while (dy > 0) { - uint32_t color = shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); + uint32_t color = LightBgra::shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); p[0] = color; p[1] = color; p[2] = color; @@ -2393,7 +1315,7 @@ public: { while (dy > 0) { - uint32_t color = shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); + uint32_t color = LightBgra::shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); p[0] = color; p[1] = color; p[2] = color; @@ -2405,7 +1327,7 @@ public: } else while (dy > 0) { - uint32_t color = shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); + uint32_t color = LightBgra::shade_pal_index(colormap[vptr[v >> FRACBITS]], light, shade_constants); // The optimizer will probably turn this into a memset call. // Since dx is not likely to be large, I'm not sure that's a good thing, // hence the alternatives above. @@ -2420,1000 +1342,484 @@ public: } }; -class Vlinec1RGBACommand : public DrawerCommand +///////////////////////////////////////////////////////////////////////////// + +class DrawerWall1Command : public DrawerCommand { - DWORD _iscale; - DWORD _texturefrac; - int _count; - const BYTE * RESTRICT _source; - const BYTE * RESTRICT _source2; - uint32_t _texturefracx; +public: BYTE * RESTRICT _dest; - int vlinebits; int _pitch; - fixed_t _light; + int _count; + DWORD _texturefrac; + uint32_t _texturefracx; + DWORD _iscale; + int _vlinebits; + uint32_t _vlinemax; + + const uint32 * RESTRICT _source; + const uint32 * RESTRICT _source2; + uint32_t _light; ShadeConstants _shade_constants; -public: - Vlinec1RGBACommand() + uint32_t _srcalpha; + uint32_t _destalpha; + + DrawerWall1Command(int vlinebits, uint32_t vlinemax) { - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _count = dc_count; - _source = dc_source; - _source2 = dc_source2; - _texturefracx = dc_texturefracx; _dest = dc_dest; - vlinebits = ::vlinebits; _pitch = dc_pitch; - _light = dc_light; + _count = dc_count; + _texturefrac = dc_texturefrac; + _texturefracx = dc_texturefracx; + _iscale = dc_iscale; + _vlinebits = vlinebits; + _vlinemax = vlinemax; + + _source = (const uint32 *)dc_source; + _source2 = (const uint32 *)dc_source2; + _light = LightBgra::calc_light_multiplier(dc_light); _shade_constants = dc_shade_constants; + + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); + } + + class LoopIterator + { + public: + uint32_t *dest; + int pitch; + int count; + uint32_t fracstep; + uint32_t frac; + uint32_t texturefracx; + int bits; + + LoopIterator(DrawerWall1Command *command, DrawerThread *thread) + { + count = thread->count_for_thread(command->_dest_y, command->_count); + if (count <= 0) + return; + + fracstep = command->_iscale * thread->num_cores; + frac = command->_texturefrac + command->_iscale * thread->skipped_by_thread(command->_dest_y); + texturefracx = command->_texturefracx; + dest = thread->dest_for_thread(command->_dest_y, command->_pitch, (uint32_t*)command->_dest); + bits = command->_vlinebits; + pitch = command->_pitch * thread->num_cores; + } + + explicit operator bool() + { + return count > 0; + } + + int sample_index() + { + return frac >> bits; + } + + bool next() + { + frac += fracstep; + dest += pitch; + return (--count) != 0; + } + }; +}; + +class DrawerWall4Command : public DrawerCommand +{ +public: + BYTE * RESTRICT _dest; + int _count; + int _pitch; + int _vlinebits; + uint32_t _vlinemax; + ShadeConstants _shade_constants; + uint32_t _vplce[4]; + uint32_t _vince[4]; + uint32_t _buftexturefracx[4]; + const uint32_t * RESTRICT _bufplce[4]; + const uint32_t * RESTRICT _bufplce2[4]; + uint32_t _light[4]; + + uint32_t _srcalpha; + uint32_t _destalpha; + + DrawerWall4Command(int vlinebits, uint32_t vlinemax) + { + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _vlinebits = vlinebits; + _vlinemax = vlinemax; + _shade_constants = dc_shade_constants; + for (int i = 0; i < 4; i++) + { + _vplce[i] = vplce[i]; + _vince[i] = vince[i]; + _buftexturefracx[i] = buftexturefracx[i]; + _bufplce[i] = (const uint32_t *)bufplce[i]; + _bufplce2[i] = (const uint32_t *)bufplce2[i]; + _light[i] = LightBgra::calc_light_multiplier(palookuplight[i]); + } + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); + } + + class LoopIterator + { + public: + uint32_t *dest; + int pitch; + int count; + int bits; + uint32_t vplce[4]; + uint32_t vince[4]; + + LoopIterator(DrawerWall4Command *command, DrawerThread *thread) + { + count = thread->count_for_thread(command->_dest_y, command->_count); + if (count <= 0) + return; + + dest = thread->dest_for_thread(command->_dest_y, command->_pitch, (uint32_t*)command->_dest); + pitch = command->_pitch * thread->num_cores; + bits = command->_vlinebits; + + int skipped = thread->skipped_by_thread(command->_dest_y); + for (int i = 0; i < 4; i++) + { + vplce[i] = command->_vplce[i] + command->_vince[i] * skipped; + vince[i] = command->_vince[i] * thread->num_cores; + } + } + + explicit operator bool() + { + return count > 0; + } + + int sample_index(int col) + { + return vplce[col] >> bits; + } + + bool next() + { + vplce[0] += vince[0]; + vplce[1] += vince[1]; + vplce[2] += vince[2]; + vplce[3] += vince[3]; + dest += pitch; + return (--count) != 0; + } + }; +}; + +class Vlinec1RGBACommand : public DrawerWall1Command +{ +public: + Vlinec1RGBACommand() : DrawerWall1Command(vlinebits, vlinemax) + { } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - DWORD fracstep = _iscale * thread->num_cores; - DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - const uint32 *source = (const uint32 *)_source; - const uint32 *source2 = (const uint32 *)_source2; - uint32_t texturefracx = _texturefracx; - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int bits = vlinebits; - int pitch = _pitch * thread->num_cores; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; + LoopIterator loop(this, thread); + if (!loop) return; if (_source2 == nullptr) { do { - *dest = shade_bgra(source[frac >> bits], light, shade_constants); - frac += fracstep; - dest += pitch; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.sample_index()], _light, _shade_constants); + *loop.dest = BlendBgra::copy(fg); + } while (loop.next()); } else { do { - *dest = shade_bgra(sample_bilinear(source, source2, texturefracx, frac, bits), light, shade_constants); - frac += fracstep; - dest += pitch; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, _source2, loop.texturefracx, loop.frac, loop.bits, _vlinemax), _light, _shade_constants); + *loop.dest = BlendBgra::copy(fg); + } while (loop.next()); } } }; -class Vlinec4RGBACommand : public DrawerCommand +class Vlinec4RGBACommand : public DrawerWall4Command { - BYTE * RESTRICT _dest; - int _count; - int _pitch; - ShadeConstants _shade_constants; - int vlinebits; - fixed_t palookuplight[4]; - DWORD vplce[4]; - DWORD vince[4]; - const uint32_t * RESTRICT bufplce[4]; - const uint32_t * RESTRICT bufplce2[4]; - uint32_t buftexturefracx[4]; - public: - Vlinec4RGBACommand() + Vlinec4RGBACommand() : DrawerWall4Command(vlinebits, vlinemax) { - _dest = dc_dest; - _count = dc_count; - _pitch = dc_pitch; - _shade_constants = dc_shade_constants; - vlinebits = ::vlinebits; - for (int i = 0; i < 4; i++) - { - palookuplight[i] = ::palookuplight[i]; - vplce[i] = ::vplce[i]; - vince[i] = ::vince[i]; - bufplce[i] = (const uint32_t *)::bufplce[i]; - bufplce2[i] = (const uint32_t *)::bufplce2[i]; - buftexturefracx[i] = ::buftexturefracx[i]; - } } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; + LoopIterator loop(this, thread); + if (!loop) return; - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - int bits = vlinebits; - DWORD place; - - uint32_t light0 = calc_light_multiplier(palookuplight[0]); - uint32_t light1 = calc_light_multiplier(palookuplight[1]); - uint32_t light2 = calc_light_multiplier(palookuplight[2]); - uint32_t light3 = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - - if (bufplce2[0] == nullptr) + if (_bufplce2[0] == nullptr) { do { - dest[0] = shade_bgra(bufplce[0][(place = local_vplce[0]) >> bits], light0, shade_constants); local_vplce[0] = place + local_vince[0]; - dest[1] = shade_bgra(bufplce[1][(place = local_vplce[1]) >> bits], light1, shade_constants); local_vplce[1] = place + local_vince[1]; - dest[2] = shade_bgra(bufplce[2][(place = local_vplce[2]) >> bits], light2, shade_constants); local_vplce[2] = place + local_vince[2]; - dest[3] = shade_bgra(bufplce[3][(place = local_vplce[3]) >> bits], light3, shade_constants); local_vplce[3] = place + local_vince[3]; - dest += pitch; - } while (--count); + for (int i = 0; i < 4; i++) + { + uint32_t fg = LightBgra::shade_bgra(_bufplce[i][loop.sample_index(i)], _light[i], _shade_constants); + loop.dest[i] = BlendBgra::copy(fg); + } + } while (loop.next()); } else { do { - dest[0] = shade_bgra(sample_bilinear(bufplce[0], bufplce2[0], buftexturefracx[0], place = local_vplce[0], bits), light0, shade_constants); local_vplce[0] = place + local_vince[0]; - dest[1] = shade_bgra(sample_bilinear(bufplce[1], bufplce2[1], buftexturefracx[1], place = local_vplce[1], bits), light1, shade_constants); local_vplce[1] = place + local_vince[1]; - dest[2] = shade_bgra(sample_bilinear(bufplce[2], bufplce2[2], buftexturefracx[2], place = local_vplce[2], bits), light2, shade_constants); local_vplce[2] = place + local_vince[2]; - dest[3] = shade_bgra(sample_bilinear(bufplce[3], bufplce2[3], buftexturefracx[3], place = local_vplce[3], bits), light3, shade_constants); local_vplce[3] = place + local_vince[3]; - dest += pitch; - } while (--count); + for (int i = 0; i < 4; i++) + { + uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_bufplce[i], _bufplce2[i], _buftexturefracx[i], loop.sample_index(i), loop.bits, _vlinemax), _light[i], _shade_constants); + loop.dest[i] = BlendBgra::copy(fg); + } + } while (loop.next()); } } }; -class Mvlinec1RGBACommand : public DrawerCommand +class Mvlinec1RGBACommand : public DrawerWall1Command { - DWORD _iscale; - DWORD _texturefrac; - int _count; - const BYTE * RESTRICT _source; - const BYTE * RESTRICT _source2; - uint32_t _texturefracx; - BYTE * RESTRICT _dest; - int mvlinebits; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - public: - Mvlinec1RGBACommand() + Mvlinec1RGBACommand() : DrawerWall1Command(mvlinebits, mvlinemax) { - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _count = dc_count; - _source = dc_source; - _source2 = dc_source2; - _texturefracx = dc_texturefracx; - _dest = dc_dest; - mvlinebits = ::mvlinebits; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - DWORD fracstep = _iscale * thread->num_cores; - DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - const uint32 *source = (const uint32 *)_source; - const uint32 *source2 = (const uint32 *)_source2; - uint32_t texturefracx = _texturefracx; - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int bits = mvlinebits; - int pitch = _pitch * thread->num_cores; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; + LoopIterator loop(this, thread); + if (!loop) return; if (_source2 == nullptr) { do { - uint32_t pix = source[frac >> bits]; - *dest = alpha_blend(shade_bgra(pix, light, shade_constants), *dest); - frac += fracstep; - dest += pitch; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.sample_index()], _light, _shade_constants); + *loop.dest = BlendBgra::alpha_blend(fg, *loop.dest); + } while (loop.next()); } else { do { - *dest = alpha_blend(shade_bgra(sample_bilinear(source, source2, texturefracx, frac, bits), light, shade_constants), *dest); - frac += fracstep; - dest += pitch; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, _source2, loop.texturefracx, loop.frac, loop.bits, _vlinemax), _light, _shade_constants); + *loop.dest = BlendBgra::alpha_blend(fg, *loop.dest); + } while (loop.next()); } } }; -class Mvlinec4RGBACommand : public DrawerCommand +class Mvlinec4RGBACommand : public DrawerWall4Command { - BYTE * RESTRICT _dest; - int _count; - int _pitch; - ShadeConstants _shade_constants; - int mvlinebits; - fixed_t palookuplight[4]; - DWORD vplce[4]; - DWORD vince[4]; - const uint32 * RESTRICT bufplce[4]; - const uint32 * RESTRICT bufplce2[4]; - uint32_t buftexturefracx[4]; - public: - Mvlinec4RGBACommand() + Mvlinec4RGBACommand(): DrawerWall4Command(mvlinebits, mvlinemax) { - _dest = dc_dest; - _count = dc_count; - _pitch = dc_pitch; - _shade_constants = dc_shade_constants; - mvlinebits = ::mvlinebits; - for (int i = 0; i < 4; i++) - { - palookuplight[i] = ::palookuplight[i]; - vplce[i] = ::vplce[i]; - vince[i] = ::vince[i]; - bufplce[i] = (const uint32 *)::bufplce[i]; - bufplce2[i] = (const uint32_t *)::bufplce2[i]; - buftexturefracx[i] = ::buftexturefracx[i]; - } } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; + LoopIterator loop(this, thread); + if (!loop) return; - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - int bits = mvlinebits; - DWORD place; - - uint32_t light0 = calc_light_multiplier(palookuplight[0]); - uint32_t light1 = calc_light_multiplier(palookuplight[1]); - uint32_t light2 = calc_light_multiplier(palookuplight[2]); - uint32_t light3 = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - - if (bufplce2[0] == nullptr) + if (_bufplce2[0] == nullptr) { do { - uint32_t pix; - pix = bufplce[0][(place = local_vplce[0]) >> bits]; dest[0] = alpha_blend(shade_bgra(pix, light0, shade_constants), dest[0]); local_vplce[0] = place + local_vince[0]; - pix = bufplce[1][(place = local_vplce[1]) >> bits]; dest[1] = alpha_blend(shade_bgra(pix, light1, shade_constants), dest[1]); local_vplce[1] = place + local_vince[1]; - pix = bufplce[2][(place = local_vplce[2]) >> bits]; dest[2] = alpha_blend(shade_bgra(pix, light2, shade_constants), dest[2]); local_vplce[2] = place + local_vince[2]; - pix = bufplce[3][(place = local_vplce[3]) >> bits]; dest[3] = alpha_blend(shade_bgra(pix, light3, shade_constants), dest[3]); local_vplce[3] = place + local_vince[3]; - dest += pitch; - } while (--count); + for (int i = 0; i < 4; i++) + { + uint32_t fg = LightBgra::shade_bgra(_bufplce[i][loop.sample_index(i)], _light[i], _shade_constants); + loop.dest[i] = BlendBgra::alpha_blend(fg, loop.dest[i]); + } + } while (loop.next()); } else { do { - dest[0] = alpha_blend(shade_bgra(sample_bilinear(bufplce[0], bufplce2[0], buftexturefracx[0], place = local_vplce[0], bits), light0, shade_constants), dest[0]); local_vplce[0] = place + local_vince[0]; - dest[1] = alpha_blend(shade_bgra(sample_bilinear(bufplce[1], bufplce2[1], buftexturefracx[1], place = local_vplce[1], bits), light1, shade_constants), dest[1]); local_vplce[1] = place + local_vince[1]; - dest[2] = alpha_blend(shade_bgra(sample_bilinear(bufplce[2], bufplce2[2], buftexturefracx[2], place = local_vplce[2], bits), light2, shade_constants), dest[2]); local_vplce[2] = place + local_vince[2]; - dest[3] = alpha_blend(shade_bgra(sample_bilinear(bufplce[3], bufplce2[3], buftexturefracx[3], place = local_vplce[3], bits), light3, shade_constants), dest[3]); local_vplce[3] = place + local_vince[3]; - dest += pitch; - } while (--count); + for (int i = 0; i < 4; i++) + { + uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_bufplce[i], _bufplce2[i], _buftexturefracx[i], loop.sample_index(i), loop.bits, _vlinemax), _light[i], _shade_constants); + loop.dest[i] = BlendBgra::alpha_blend(fg, loop.dest[i]); + } + } while (loop.next()); } } }; -class Tmvline1AddRGBACommand : public DrawerCommand +class Tmvline1AddRGBACommand : public DrawerWall1Command { - DWORD _iscale; - DWORD _texturefrac; - int _count; - const BYTE * RESTRICT _source; - BYTE * RESTRICT _dest; - int tmvlinebits; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - public: - Tmvline1AddRGBACommand() + Tmvline1AddRGBACommand() : DrawerWall1Command(tmvlinebits, tmvlinemax) { - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _count = dc_count; - _source = dc_source; - _dest = dc_dest; - tmvlinebits = ::tmvlinebits; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - DWORD fracstep = _iscale * thread->num_cores; - DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - const uint32 *source = (const uint32 *)_source; - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int bits = tmvlinebits; - int pitch = _pitch * thread->num_cores; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); - + LoopIterator loop(this, thread); + if (!loop) return; do { - uint32_t pix = source[frac >> bits]; - - uint32_t fg_alpha = src_alpha; - uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); - - uint32_t fg = shade_bgra(pix, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - - frac += fracstep; - dest += pitch; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.sample_index()], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); + } while (loop.next()); } }; -class Tmvline4AddRGBACommand : public DrawerCommand +class Tmvline4AddRGBACommand : public DrawerWall4Command { - BYTE * RESTRICT _dest; - int _count; - int _pitch; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - int tmvlinebits; - fixed_t palookuplight[4]; - DWORD vplce[4]; - DWORD vince[4]; - const uint32 * RESTRICT bufplce[4]; - public: - Tmvline4AddRGBACommand() + Tmvline4AddRGBACommand() : DrawerWall4Command(tmvlinebits, tmvlinemax) { - _dest = dc_dest; - _count = dc_count; - _pitch = dc_pitch; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - tmvlinebits = ::tmvlinebits; - for (int i = 0; i < 4; i++) - { - palookuplight[i] = ::palookuplight[i]; - vplce[i] = ::vplce[i]; - vince[i] = ::vince[i]; - bufplce[i] = (const uint32 *)::bufplce[i]; - } } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - int bits = tmvlinebits; - - uint32_t light[4]; - light[0] = calc_light_multiplier(palookuplight[0]); - light[1] = calc_light_multiplier(palookuplight[1]); - light[2] = calc_light_multiplier(palookuplight[2]); - light[3] = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - + LoopIterator loop(this, thread); + if (!loop) return; do { - for (int i = 0; i < 4; ++i) + for (int i = 0; i < 4; i++) { - uint32_t pix = bufplce[i][local_vplce[i] >> bits]; - - uint32_t fg_alpha = src_alpha; - uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); - - uint32_t fg = shade_bgra(pix, light[i], shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - - local_vplce[i] += local_vince[i]; + uint32_t fg = LightBgra::shade_bgra(_bufplce[i][loop.sample_index(i)], _light[i], _shade_constants); + loop.dest[i] = BlendBgra::add(fg, loop.dest[i], _srcalpha, calc_blend_bgalpha(fg, _destalpha)); } - dest += pitch; - } while (--count); + } while (loop.next()); } }; -class Tmvline1AddClampRGBACommand : public DrawerCommand +class Tmvline1AddClampRGBACommand : public DrawerWall1Command { - DWORD _iscale; - DWORD _texturefrac; - int _count; - const BYTE * RESTRICT _source; - BYTE * RESTRICT _dest; - int tmvlinebits; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - public: - Tmvline1AddClampRGBACommand() + Tmvline1AddClampRGBACommand() : DrawerWall1Command(tmvlinebits, tmvlinemax) { - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _count = dc_count; - _source = dc_source; - _dest = dc_dest; - tmvlinebits = ::tmvlinebits; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - DWORD fracstep = _iscale * thread->num_cores; - DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - const uint32 *source = (const uint32 *)_source; - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int bits = tmvlinebits; - int pitch = _pitch * thread->num_cores; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); - + LoopIterator loop(this, thread); + if (!loop) return; do { - uint32_t pix = source[frac >> bits]; - - uint32_t fg_alpha = src_alpha; - uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); - - uint32_t fg = shade_bgra(pix, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - - frac += fracstep; - dest += pitch; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.sample_index()], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); + } while (loop.next()); } }; -class Tmvline4AddClampRGBACommand : public DrawerCommand +class Tmvline4AddClampRGBACommand : public DrawerWall4Command { - BYTE * RESTRICT _dest; - int _count; - int _pitch; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - int tmvlinebits; - fixed_t palookuplight[4]; - DWORD vplce[4]; - DWORD vince[4]; - const uint32 *RESTRICT bufplce[4]; - public: - Tmvline4AddClampRGBACommand() + Tmvline4AddClampRGBACommand() : DrawerWall4Command(tmvlinebits, tmvlinemax) { - _dest = dc_dest; - _count = dc_count; - _pitch = dc_pitch; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - tmvlinebits = ::tmvlinebits; - for (int i = 0; i < 4; i++) - { - palookuplight[i] = ::palookuplight[i]; - vplce[i] = ::vplce[i]; - vince[i] = ::vince[i]; - bufplce[i] = (const uint32 *)::bufplce[i]; - } } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - int bits = tmvlinebits; - - uint32_t light[4]; - light[0] = calc_light_multiplier(palookuplight[0]); - light[1] = calc_light_multiplier(palookuplight[1]); - light[2] = calc_light_multiplier(palookuplight[2]); - light[3] = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - + LoopIterator loop(this, thread); + if (!loop) return; do { - for (int i = 0; i < 4; ++i) + for (int i = 0; i < 4; i++) { - uint32_t pix = bufplce[i][local_vplce[i] >> bits]; - - uint32_t fg_alpha = src_alpha; - uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); - - uint32_t fg = shade_bgra(pix, light[i], shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - - local_vplce[i] += local_vince[i]; + uint32_t fg = LightBgra::shade_bgra(_bufplce[i][loop.sample_index(i)], _light[i], _shade_constants); + loop.dest[i] = BlendBgra::add(fg, loop.dest[i], _srcalpha, calc_blend_bgalpha(fg, _destalpha)); } - dest += pitch; - } while (--count); + } while (loop.next()); } }; -class Tmvline1SubClampRGBACommand : public DrawerCommand +class Tmvline1SubClampRGBACommand : public DrawerWall1Command { - DWORD _iscale; - DWORD _texturefrac; - int _count; - const BYTE * RESTRICT _source; - BYTE * RESTRICT _dest; - int tmvlinebits; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - public: - Tmvline1SubClampRGBACommand() + Tmvline1SubClampRGBACommand() : DrawerWall1Command(tmvlinebits, tmvlinemax) { - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _count = dc_count; - _source = dc_source; - _dest = dc_dest; - tmvlinebits = ::tmvlinebits; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - DWORD fracstep = _iscale * thread->num_cores; - DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - const uint32 *source = (const uint32 *)_source; - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int bits = tmvlinebits; - int pitch = _pitch * thread->num_cores; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); - + LoopIterator loop(this, thread); + if (!loop) return; do { - uint32_t pix = source[frac >> bits]; - - uint32_t fg_alpha = src_alpha; - uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); - - uint32_t fg = shade_bgra(pix, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - - frac += fracstep; - dest += pitch; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.sample_index()], _light, _shade_constants); + *loop.dest = BlendBgra::sub(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); + } while (loop.next()); } }; -class Tmvline4SubClampRGBACommand : public DrawerCommand +class Tmvline4SubClampRGBACommand : public DrawerWall4Command { - BYTE * RESTRICT _dest; - int _count; - int _pitch; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - int tmvlinebits; - fixed_t palookuplight[4]; - DWORD vplce[4]; - DWORD vince[4]; - const uint32 *RESTRICT bufplce[4]; - public: - Tmvline4SubClampRGBACommand() + Tmvline4SubClampRGBACommand() : DrawerWall4Command(tmvlinebits, tmvlinemax) { - _dest = dc_dest; - _count = dc_count; - _pitch = dc_pitch; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - tmvlinebits = ::tmvlinebits; - for (int i = 0; i < 4; i++) - { - palookuplight[i] = ::palookuplight[i]; - vplce[i] = ::vplce[i]; - vince[i] = ::vince[i]; - bufplce[i] = (const uint32 *)::bufplce[i]; - } } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - int bits = tmvlinebits; - - uint32_t light[4]; - light[0] = calc_light_multiplier(palookuplight[0]); - light[1] = calc_light_multiplier(palookuplight[1]); - light[2] = calc_light_multiplier(palookuplight[2]); - light[3] = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - + LoopIterator loop(this, thread); + if (!loop) return; do { - for (int i = 0; i < 4; ++i) + for (int i = 0; i < 4; i++) { - uint32_t pix = bufplce[i][local_vplce[i] >> bits]; - - uint32_t fg_alpha = src_alpha; - uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); - - uint32_t fg = shade_bgra(pix, light[i], shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - - local_vplce[i] += local_vince[i]; + uint32_t fg = LightBgra::shade_bgra(_bufplce[i][loop.sample_index(i)], _light[i], _shade_constants); + loop.dest[i] = BlendBgra::sub(fg, loop.dest[i], _srcalpha, calc_blend_bgalpha(fg, _destalpha)); } - dest += pitch; - } while (--count); + } while (loop.next()); } }; -class Tmvline1RevSubClampRGBACommand : public DrawerCommand +class Tmvline1RevSubClampRGBACommand : public DrawerWall1Command { - DWORD _iscale; - DWORD _texturefrac; - int _count; - const BYTE * RESTRICT _source; - BYTE * RESTRICT _dest; - int tmvlinebits; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - public: - Tmvline1RevSubClampRGBACommand() + Tmvline1RevSubClampRGBACommand() : DrawerWall1Command(tmvlinebits, tmvlinemax) { - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _count = dc_count; - _source = dc_source; - _dest = dc_dest; - tmvlinebits = ::tmvlinebits; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - DWORD fracstep = _iscale * thread->num_cores; - DWORD frac = _texturefrac + _iscale * thread->skipped_by_thread(_dest_y); - const uint32 *source = (const uint32 *)_source; - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int bits = tmvlinebits; - int pitch = _pitch * thread->num_cores; - - uint32_t light = calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); - + LoopIterator loop(this, thread); + if (!loop) return; do { - uint32_t pix = source[frac >> bits]; - - uint32_t fg_alpha = src_alpha; - uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); - - uint32_t fg = shade_bgra(pix, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - - frac += fracstep; - dest += pitch; - } while (--count); + uint32_t fg = LightBgra::shade_bgra(_source[loop.sample_index()], _light, _shade_constants); + *loop.dest = BlendBgra::revsub(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); + } while (loop.next()); } }; -class Tmvline4RevSubClampRGBACommand : public DrawerCommand +class Tmvline4RevSubClampRGBACommand : public DrawerWall4Command { - BYTE * RESTRICT _dest; - int _count; - int _pitch; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - int tmvlinebits; - fixed_t palookuplight[4]; - DWORD vplce[4]; - DWORD vince[4]; - const uint32 *RESTRICT bufplce[4]; - public: - Tmvline4RevSubClampRGBACommand() + Tmvline4RevSubClampRGBACommand() : DrawerWall4Command(tmvlinebits, tmvlinemax) { - _dest = dc_dest; - _count = dc_count; - _pitch = dc_pitch; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - tmvlinebits = ::tmvlinebits; - for (int i = 0; i < 4; i++) - { - palookuplight[i] = ::palookuplight[i]; - vplce[i] = ::vplce[i]; - vince[i] = ::vince[i]; - bufplce[i] = (const uint32 *)::bufplce[i]; - } } void Execute(DrawerThread *thread) override { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - int bits = tmvlinebits; - - uint32_t light[4]; - light[0] = calc_light_multiplier(palookuplight[0]); - light[1] = calc_light_multiplier(palookuplight[1]); - light[2] = calc_light_multiplier(palookuplight[2]); - light[3] = calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - + LoopIterator loop(this, thread); + if (!loop) return; do { - for (int i = 0; i < 4; ++i) + for (int i = 0; i < 4; i++) { - uint32_t pix = bufplce[i][local_vplce[i] >> bits]; - - uint32_t fg_alpha = src_alpha; - uint32_t bg_alpha = calc_blend_bgalpha(pix, dest_alpha); - - uint32_t fg = shade_bgra(pix, light[i], shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - - local_vplce[i] += local_vince[i]; + uint32_t fg = LightBgra::shade_bgra(_bufplce[i][loop.sample_index(i)], _light[i], _shade_constants); + loop.dest[i] = BlendBgra::revsub(fg, loop.dest[i], _srcalpha, calc_blend_bgalpha(fg, _destalpha)); } - dest += pitch; - } while (--count); + } while (loop.next()); } }; +///////////////////////////////////////////////////////////////////////////// + class DrawFogBoundaryLineRGBACommand : public DrawerCommand { int _y; @@ -3446,7 +1852,7 @@ public: uint32_t *dest = ylookup[y] + (uint32_t*)_destorg; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); ShadeConstants constants = _shade_constants; do @@ -3563,8 +1969,8 @@ public: uint32_t *dest = ylookup[y] + x1 + (uint32_t*)_destorg; int count = (x2 - x1 + 1); - uint32_t light = calc_light_multiplier(_light); - uint32_t color = shade_pal_index_simple(_color, light); + uint32_t light = LightBgra::calc_light_multiplier(_light); + uint32_t color = LightBgra::shade_pal_index_simple(_color, light); for (int i = 0; i < count; i++) dest[i] = color; } diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 8f97d4ecd..20fff4fc0 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -286,7 +286,7 @@ public: }; ///////////////////////////////////////////////////////////////////////////// -// Pixel shading macros and inline functions: +// Pixel shading inline functions: // Give the compiler a strong hint we want these functions inlined: #ifndef FORCEINLINE @@ -310,220 +310,256 @@ public: #endif #endif -// calculates the light constant passed to the shade_pal_index function -FORCEINLINE uint32_t calc_light_multiplier(dsfixed_t light) +class LightBgra { - return 256 - (light >> (FRACBITS - 8)); -} - -// Calculates a ARGB8 color for the given palette index and light multiplier -FORCEINLINE uint32_t shade_pal_index_simple(uint32_t index, uint32_t light) -{ - const PalEntry &color = GPalette.BaseColors[index]; - uint32_t red = color.r; - uint32_t green = color.g; - uint32_t blue = color.b; - - red = red * light / 256; - green = green * light / 256; - blue = blue * light / 256; - - return 0xff000000 | (red << 16) | (green << 8) | blue; -} - -FORCEINLINE uint32_t shade_bgra_simple(uint32_t color, uint32_t light) -{ - uint32_t red = (color >> 16) & 0xff; - uint32_t green = (color >> 8) & 0xff; - uint32_t blue = color & 0xff; - - red = red * light / 256; - green = green * light / 256; - blue = blue * light / 256; - - return 0xff000000 | (red << 16) | (green << 8) | blue; -} - -// Calculates a ARGB8 color for the given palette index, light multiplier and dynamic colormap -FORCEINLINE uint32_t shade_pal_index(uint32_t index, uint32_t light, const ShadeConstants &constants) -{ - const PalEntry &color = GPalette.BaseColors[index]; - uint32_t alpha = color.d & 0xff000000; - uint32_t red = color.r; - uint32_t green = color.g; - uint32_t blue = color.b; - if (constants.simple_shade) +public: + // calculates the light constant passed to the shade_pal_index function + FORCEINLINE static uint32_t calc_light_multiplier(dsfixed_t light) { + return 256 - (light >> (FRACBITS - 8)); + } + + // Calculates a ARGB8 color for the given palette index and light multiplier + FORCEINLINE static uint32_t shade_pal_index_simple(uint32_t index, uint32_t light) + { + const PalEntry &color = GPalette.BaseColors[index]; + uint32_t red = color.r; + uint32_t green = color.g; + uint32_t blue = color.b; + red = red * light / 256; green = green * light / 256; blue = blue * light / 256; + + return 0xff000000 | (red << 16) | (green << 8) | blue; } - else + + // Calculates a ARGB8 color for the given palette index, light multiplier and dynamic colormap + FORCEINLINE static uint32_t shade_pal_index(uint32_t index, uint32_t light, const ShadeConstants &constants) { - uint32_t inv_light = 256 - light; - uint32_t inv_desaturate = 256 - constants.desaturate; - - uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; - - red = (red * inv_desaturate + intensity) / 256; - green = (green * inv_desaturate + intensity) / 256; - blue = (blue * inv_desaturate + intensity) / 256; - - red = (constants.fade_red * inv_light + red * light) / 256; - green = (constants.fade_green * inv_light + green * light) / 256; - blue = (constants.fade_blue * inv_light + blue * light) / 256; - - red = (red * constants.light_red) / 256; - green = (green * constants.light_green) / 256; - blue = (blue * constants.light_blue) / 256; - } - return alpha | (red << 16) | (green << 8) | blue; -} - -FORCEINLINE uint32_t shade_bgra(uint32_t color, uint32_t light, const ShadeConstants &constants) -{ - uint32_t alpha = color & 0xff000000; - uint32_t red = (color >> 16) & 0xff; - uint32_t green = (color >> 8) & 0xff; - uint32_t blue = color & 0xff; - if (constants.simple_shade) - { - red = red * light / 256; - green = green * light / 256; - blue = blue * light / 256; - } - else - { - uint32_t inv_light = 256 - light; - uint32_t inv_desaturate = 256 - constants.desaturate; - - uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; - - red = (red * inv_desaturate + intensity) / 256; - green = (green * inv_desaturate + intensity) / 256; - blue = (blue * inv_desaturate + intensity) / 256; - - red = (constants.fade_red * inv_light + red * light) / 256; - green = (constants.fade_green * inv_light + green * light) / 256; - blue = (constants.fade_blue * inv_light + blue * light) / 256; - - red = (red * constants.light_red) / 256; - green = (green * constants.light_green) / 256; - blue = (blue * constants.light_blue) / 256; - } - return alpha | (red << 16) | (green << 8) | blue; -} - -FORCEINLINE uint32_t alpha_blend(uint32_t fg, uint32_t bg) -{ - uint32_t fg_alpha = fg >> 24; - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t alpha = fg_alpha + (fg_alpha >> 7); // 255 -> 256 - uint32_t inv_alpha = 256 - alpha; - - uint32_t bg_red = (bg >> 16) & 0xff; - uint32_t bg_green = (bg >> 8) & 0xff; - uint32_t bg_blue = bg & 0xff; - - uint32_t red = clamp(fg_red + (bg_red * inv_alpha) / 256, 0, 255); - uint32_t green = clamp(fg_green + (bg_green * inv_alpha) / 256, 0, 255); - uint32_t blue = clamp(fg_blue + (bg_blue * inv_alpha) / 256, 0, 255); - - return 0xff000000 | (red << 16) | (green << 8) | blue; -} - -inline bool span_sampler_setup(const uint32_t * RESTRICT &source, int &xbits, int &ybits, fixed_t xstep, fixed_t ystep) -{ - if (!r_bilinear) - return false; - - // Is this a magfilter or minfilter? - fixed_t xmagnitude = abs(xstep) >> (32 - xbits - FRACBITS); - fixed_t ymagnitude = abs(ystep) >> (32 - ybits - FRACBITS); - fixed_t magnitude = (xmagnitude + ymagnitude) * 2 + (1 << (FRACBITS -1)); - if (magnitude >> FRACBITS == 0) - return false; - - if (r_mipmap) - { - int level = magnitude >> (FRACBITS + 1); - while (level != 0) + const PalEntry &color = GPalette.BaseColors[index]; + uint32_t alpha = color.d & 0xff000000; + uint32_t red = color.r; + uint32_t green = color.g; + uint32_t blue = color.b; + if (constants.simple_shade) { - if (xbits <= 2 || ybits <= 2) - break; - - source += (1 << (xbits)) * (1 << (ybits)); - xbits -= 1; - ybits -= 1; - level >>= 1; + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; } + else + { + uint32_t inv_light = 256 - light; + uint32_t inv_desaturate = 256 - constants.desaturate; + + uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; + + red = (red * inv_desaturate + intensity) / 256; + green = (green * inv_desaturate + intensity) / 256; + blue = (blue * inv_desaturate + intensity) / 256; + + red = (constants.fade_red * inv_light + red * light) / 256; + green = (constants.fade_green * inv_light + green * light) / 256; + blue = (constants.fade_blue * inv_light + blue * light) / 256; + + red = (red * constants.light_red) / 256; + green = (green * constants.light_green) / 256; + blue = (blue * constants.light_blue) / 256; + } + return alpha | (red << 16) | (green << 8) | blue; } - return true; -} -FORCEINLINE uint32_t sample_bilinear(const uint32_t *col0, const uint32_t *col1, uint32_t texturefracx, uint32_t texturefracy, int ybits) + FORCEINLINE static uint32_t shade_bgra_simple(uint32_t color, uint32_t light) + { + uint32_t red = RPART(color) * light / 256; + uint32_t green = GPART(color) * light / 256; + uint32_t blue = BPART(color) * light / 256; + return 0xff000000 | (red << 16) | (green << 8) | blue; + } + + FORCEINLINE static uint32_t shade_bgra(uint32_t color, uint32_t light, const ShadeConstants &constants) + { + uint32_t alpha = color & 0xff000000; + uint32_t red = (color >> 16) & 0xff; + uint32_t green = (color >> 8) & 0xff; + uint32_t blue = color & 0xff; + if (constants.simple_shade) + { + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; + } + else + { + uint32_t inv_light = 256 - light; + uint32_t inv_desaturate = 256 - constants.desaturate; + + uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; + + red = (red * inv_desaturate + intensity) / 256; + green = (green * inv_desaturate + intensity) / 256; + blue = (blue * inv_desaturate + intensity) / 256; + + red = (constants.fade_red * inv_light + red * light) / 256; + green = (constants.fade_green * inv_light + green * light) / 256; + blue = (constants.fade_blue * inv_light + blue * light) / 256; + + red = (red * constants.light_red) / 256; + green = (green * constants.light_green) / 256; + blue = (blue * constants.light_blue) / 256; + } + return alpha | (red << 16) | (green << 8) | blue; + } +}; + +class BlendBgra { - uint32_t half = 1 << (ybits - 1); - uint32_t y = (texturefracy - half) >> ybits; +public: + FORCEINLINE static uint32_t copy(uint32_t fg) + { + return fg; + } - uint32_t p00 = col0[y]; - uint32_t p01 = col0[y + 1]; - uint32_t p10 = col1[y]; - uint32_t p11 = col1[y + 1]; + FORCEINLINE static uint32_t add(uint32_t fg, uint32_t bg, uint32_t srcalpha, uint32_t destalpha) + { + uint32_t red = MIN((RPART(fg) * srcalpha + RPART(bg) * destalpha) >> 8, 255); + uint32_t green = MIN((GPART(fg) * srcalpha + GPART(bg) * destalpha) >> 8, 255); + uint32_t blue = MIN((BPART(fg) * srcalpha + BPART(bg) * destalpha) >> 8, 255); + return 0xff000000 | (red << 16) | (green << 8) | blue; + } - uint32_t inv_b = texturefracx; - uint32_t inv_a = ((texturefracy + half) >> (ybits - 4)) & 15; - uint32_t a = 16 - inv_a; - uint32_t b = 16 - inv_b; + FORCEINLINE static uint32_t sub(uint32_t fg, uint32_t bg, uint32_t srcalpha, uint32_t destalpha) + { + uint32_t red = clamp((0x10000 - RPART(fg) * srcalpha + RPART(bg) * destalpha) >> 8, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 - GPART(fg) * srcalpha + GPART(bg) * destalpha) >> 8, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 - BPART(fg) * srcalpha + BPART(bg) * destalpha) >> 8, 256, 256 + 255) - 256; + return 0xff000000 | (red << 16) | (green << 8) | blue; + } - uint32_t red = (RPART(p00) * a * b + RPART(p01) * inv_a * b + RPART(p10) * a * inv_b + RPART(p11) * inv_a * inv_b + 127) >> 8; - uint32_t green = (GPART(p00) * a * b + GPART(p01) * inv_a * b + GPART(p10) * a * inv_b + GPART(p11) * inv_a * inv_b + 127) >> 8; - uint32_t blue = (BPART(p00) * a * b + BPART(p01) * inv_a * b + BPART(p10) * a * inv_b + BPART(p11) * inv_a * inv_b + 127) >> 8; - uint32_t alpha = (APART(p00) * a * b + APART(p01) * inv_a * b + APART(p10) * a * inv_b + APART(p11) * inv_a * inv_b + 127) >> 8; + FORCEINLINE static uint32_t revsub(uint32_t fg, uint32_t bg, uint32_t srcalpha, uint32_t destalpha) + { + uint32_t red = clamp((0x10000 + RPART(fg) * srcalpha - RPART(bg) * destalpha) >> 8, 256, 256 + 255) - 256; + uint32_t green = clamp((0x10000 + GPART(fg) * srcalpha - GPART(bg) * destalpha) >> 8, 256, 256 + 255) - 256; + uint32_t blue = clamp((0x10000 + BPART(fg) * srcalpha - BPART(bg) * destalpha) >> 8, 256, 256 + 255) - 256; + return 0xff000000 | (red << 16) | (green << 8) | blue; + } - return (alpha << 24) | (red << 16) | (green << 8) | blue; -} + FORCEINLINE static uint32_t alpha_blend(uint32_t fg, uint32_t bg) + { + uint32_t alpha = APART(fg) + (APART(fg) >> 7); // 255 -> 256 + uint32_t inv_alpha = 256 - alpha; + uint32_t red = MIN(RPART(fg) + (RPART(bg) * inv_alpha) / 256, 255); + uint32_t green = MIN(GPART(fg) + (GPART(bg) * inv_alpha) / 256, 255); + uint32_t blue = MIN(BPART(fg) + (BPART(bg) * inv_alpha) / 256, 255); + return 0xff000000 | (red << 16) | (green << 8) | blue; + } +}; -FORCEINLINE uint32_t sample_bilinear(const uint32_t *texture, dsfixed_t xfrac, dsfixed_t yfrac, int xbits, int ybits) +class SampleBgra { - int xshift = (32 - xbits); - int yshift = (32 - ybits); - int xmask = (1 << xshift) - 1; - int ymask = (1 << yshift) - 1; - uint32_t xhalf = 1 << (xbits - 1); - uint32_t yhalf = 1 << (ybits - 1); - uint32_t x = (xfrac - xhalf) >> xbits; - uint32_t y = (yfrac - yhalf) >> ybits; +public: + inline static bool span_sampler_setup(const uint32_t * RESTRICT &source, int &xbits, int &ybits, fixed_t xstep, fixed_t ystep) + { + if (!r_bilinear) + return false; - uint32_t p00 = texture[(y & ymask) + ((x & xmask) << yshift)]; - uint32_t p01 = texture[((y + 1) & ymask) + ((x & xmask) << yshift)]; - uint32_t p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)]; - uint32_t p11 = texture[((y + 1) & ymask) + (((x + 1) & xmask) << yshift)]; + // Is this a magfilter or minfilter? + fixed_t xmagnitude = abs(xstep) >> (32 - xbits - FRACBITS); + fixed_t ymagnitude = abs(ystep) >> (32 - ybits - FRACBITS); + fixed_t magnitude = (xmagnitude + ymagnitude) * 2 + (1 << (FRACBITS - 1)); + if (magnitude >> FRACBITS == 0) + return false; - uint32_t inv_b = ((xfrac + xhalf) >> (xbits - 4)) & 15; - uint32_t inv_a = ((yfrac + yhalf) >> (ybits - 4)) & 15; - uint32_t a = 16 - inv_a; - uint32_t b = 16 - inv_b; + if (r_mipmap) + { + int level = magnitude >> (FRACBITS + 1); + while (level != 0) + { + if (xbits <= 2 || ybits <= 2) + break; - uint32_t red = (RPART(p00) * a * b + RPART(p01) * inv_a * b + RPART(p10) * a * inv_b + RPART(p11) * inv_a * inv_b + 127) >> 8; - uint32_t green = (GPART(p00) * a * b + GPART(p01) * inv_a * b + GPART(p10) * a * inv_b + GPART(p11) * inv_a * inv_b + 127) >> 8; - uint32_t blue = (BPART(p00) * a * b + BPART(p01) * inv_a * b + BPART(p10) * a * inv_b + BPART(p11) * inv_a * inv_b + 127) >> 8; - uint32_t alpha = (APART(p00) * a * b + APART(p01) * inv_a * b + APART(p10) * a * inv_b + APART(p11) * inv_a * inv_b + 127) >> 8; + source += (1 << (xbits)) * (1 << (ybits)); + xbits -= 1; + ybits -= 1; + level >>= 1; + } + } + return true; + } - return (alpha << 24) | (red << 16) | (green << 8) | blue; -} + FORCEINLINE static uint32_t sample_bilinear(const uint32_t *col0, const uint32_t *col1, uint32_t texturefracx, uint32_t texturefracy, int ybits, uint32_t ymax) + { + uint32_t half = 1 << (ybits - 1); + uint32_t y0 = (texturefracy - half) >> ybits; + if (y0 > ymax) + y0 = 0; + uint32_t y1 = y0 + 1; + if (y1 > ymax) + y1 = 0; -#define VEC_SAMPLE_BILINEAR4_COLUMN(fg, col0, col1, texturefracx, texturefracy, ybits) { \ + uint32_t p00 = col0[y0]; + uint32_t p01 = col0[y1]; + uint32_t p10 = col1[y0]; + uint32_t p11 = col1[y1]; + + uint32_t inv_b = texturefracx; + uint32_t inv_a = ((texturefracy + half) >> (ybits - 4)) & 15; + uint32_t a = 16 - inv_a; + uint32_t b = 16 - inv_b; + + uint32_t red = (RPART(p00) * a * b + RPART(p01) * inv_a * b + RPART(p10) * a * inv_b + RPART(p11) * inv_a * inv_b + 127) >> 8; + uint32_t green = (GPART(p00) * a * b + GPART(p01) * inv_a * b + GPART(p10) * a * inv_b + GPART(p11) * inv_a * inv_b + 127) >> 8; + uint32_t blue = (BPART(p00) * a * b + BPART(p01) * inv_a * b + BPART(p10) * a * inv_b + BPART(p11) * inv_a * inv_b + 127) >> 8; + uint32_t alpha = (APART(p00) * a * b + APART(p01) * inv_a * b + APART(p10) * a * inv_b + APART(p11) * inv_a * inv_b + 127) >> 8; + + return (alpha << 24) | (red << 16) | (green << 8) | blue; + } + + FORCEINLINE static uint32_t sample_bilinear(const uint32_t *texture, dsfixed_t xfrac, dsfixed_t yfrac, int xbits, int ybits) + { + int xshift = (32 - xbits); + int yshift = (32 - ybits); + int xmask = (1 << xshift) - 1; + int ymask = (1 << yshift) - 1; + uint32_t xhalf = 1 << (xbits - 1); + uint32_t yhalf = 1 << (ybits - 1); + uint32_t x = (xfrac - xhalf) >> xbits; + uint32_t y = (yfrac - yhalf) >> ybits; + + uint32_t p00 = texture[(y & ymask) + ((x & xmask) << yshift)]; + uint32_t p01 = texture[((y + 1) & ymask) + ((x & xmask) << yshift)]; + uint32_t p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)]; + uint32_t p11 = texture[((y + 1) & ymask) + (((x + 1) & xmask) << yshift)]; + + uint32_t inv_b = ((xfrac + xhalf) >> (xbits - 4)) & 15; + uint32_t inv_a = ((yfrac + yhalf) >> (ybits - 4)) & 15; + uint32_t a = 16 - inv_a; + uint32_t b = 16 - inv_b; + + uint32_t red = (RPART(p00) * a * b + RPART(p01) * inv_a * b + RPART(p10) * a * inv_b + RPART(p11) * inv_a * inv_b + 127) >> 8; + uint32_t green = (GPART(p00) * a * b + GPART(p01) * inv_a * b + GPART(p10) * a * inv_b + GPART(p11) * inv_a * inv_b + 127) >> 8; + uint32_t blue = (BPART(p00) * a * b + BPART(p01) * inv_a * b + BPART(p10) * a * inv_b + BPART(p11) * inv_a * inv_b + 127) >> 8; + uint32_t alpha = (APART(p00) * a * b + APART(p01) * inv_a * b + APART(p10) * a * inv_b + APART(p11) * inv_a * inv_b + 127) >> 8; + + return (alpha << 24) | (red << 16) | (green << 8) | blue; + } +}; + +///////////////////////////////////////////////////////////////////////////// +// SSE/AVX shading macros: + +#define VEC_SAMPLE_BILINEAR4_COLUMN(fg, col0, col1, texturefracx, texturefracy, ybits, ymax) { \ uint32_t half = 1 << (ybits - 1); \ \ __m128i m127 = _mm_set1_epi16(127); \ fg = _mm_setzero_si128(); \ for (int i = 0; i < 4; i++) \ { \ - uint32_t y = (texturefracy[i] - half) >> ybits; \ + uint32_t y0 = (texturefracy[i] - half) >> ybits; \ + if (y0 > ymax) y0 = 0; \ + uint32_t y1 = y0 + 1; \ + if (y1 > ymax) y1 = 0; \ \ uint32_t inv_b = texturefracx[i]; \ uint32_t inv_a = ((texturefracy[i] + half) >> (ybits - 4)) & 15; \ @@ -537,8 +573,8 @@ FORCEINLINE uint32_t sample_bilinear(const uint32_t *texture, dsfixed_t xfrac, d __m128i ab_invab = _mm_set_epi16(invab, invab, invab, invab, ab, ab, ab, ab); \ __m128i ainvb_invainvb = _mm_set_epi16(invainvb, invainvb, invainvb, invainvb, ainvb, ainvb, ainvb, ainvb); \ \ - __m128i p0 = _mm_unpacklo_epi8(_mm_loadl_epi64((const __m128i*)(col0[i] + y)), _mm_setzero_si128()); \ - __m128i p1 = _mm_unpacklo_epi8(_mm_loadl_epi64((const __m128i*)(col1[i] + y)), _mm_setzero_si128()); \ + __m128i p0 = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, col0[i][y1], col0[i][y0]), _mm_setzero_si128()); \ + __m128i p1 = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, col1[i][y1], col1[i][y0]), _mm_setzero_si128()); \ \ __m128i tmp = _mm_adds_epu16(_mm_mullo_epi16(p0, ab_invab), _mm_mullo_epi16(p1, ainvb_invainvb)); \ __m128i color = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_srli_si128(tmp, 8), tmp), m127), 8); \ @@ -758,12 +794,16 @@ FORCEINLINE uint32_t calc_blend_bgalpha(uint32_t fg, uint32_t dest_alpha) { uint32_t alpha = fg >> 24; alpha += alpha >> 7; - return 256 - alpha; // (dest_alpha * (256 - alpha)) >> 8; + uint32_t inv_alpha = 256 - alpha; + return (dest_alpha * alpha + 256 * inv_alpha + 128) >> 8; } #define VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha) \ __m128i msrc_alpha = _mm_set1_epi16(src_alpha); \ - __m128i mdest_alpha = _mm_set1_epi16(dest_alpha); + __m128i mdest_alpha = _mm_set1_epi16(dest_alpha * 255 / 256); \ + __m128i m256 = _mm_set1_epi16(256); \ + __m128i m255 = _mm_set1_epi16(255); \ + __m128i m128 = _mm_set1_epi16(128); // Calculates the final alpha values to be used when combined with the source texture alpha channel #define VEC_CALC_BLEND_ALPHA(fg) \ @@ -772,8 +812,10 @@ FORCEINLINE uint32_t calc_blend_bgalpha(uint32_t fg, uint32_t dest_alpha) __m128i alpha_lo = _mm_shufflehi_epi16(_mm_shufflelo_epi16(_mm_unpacklo_epi8(fg, _mm_setzero_si128()), _MM_SHUFFLE(3, 3, 3, 3)), _MM_SHUFFLE(3, 3, 3, 3)); \ alpha_hi = _mm_add_epi16(alpha_hi, _mm_srli_epi16(alpha_hi, 7)); \ alpha_lo = _mm_add_epi16(alpha_lo, _mm_srli_epi16(alpha_lo, 7)); \ - bg_alpha_hi = _mm_sub_epi16(_mm_set1_epi16(256), alpha_hi); /* _mm_srli_epi16(_mm_mullo_epi16(_mm_sub_epi16(_mm_set1_epi16(256), alpha_hi), mdest_alpha), 8);*/ \ - bg_alpha_lo = _mm_sub_epi16(_mm_set1_epi16(256), alpha_lo); /* _mm_srli_epi16(_mm_mullo_epi16(_mm_sub_epi16(_mm_set1_epi16(256), alpha_lo), mdest_alpha), 8);*/ \ + bg_alpha_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_mullo_epi16(mdest_alpha, alpha_hi), _mm_mullo_epi16(m255, _mm_sub_epi16(m256, alpha_hi))), m128), 8); \ + bg_alpha_hi = _mm_add_epi16(bg_alpha_hi, _mm_srli_epi16(bg_alpha_hi, 7)); \ + bg_alpha_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_mullo_epi16(mdest_alpha, alpha_lo), _mm_mullo_epi16(m255, _mm_sub_epi16(m256, alpha_lo))), m128), 8); \ + bg_alpha_lo = _mm_add_epi16(bg_alpha_lo, _mm_srli_epi16(bg_alpha_lo, 7)); \ fg_alpha_hi = msrc_alpha; \ fg_alpha_lo = msrc_alpha; \ } diff --git a/src/r_draw_rgba_sse.h b/src/r_draw_rgba_sse.h index af761c6e7..408a2f5a2 100644 --- a/src/r_draw_rgba_sse.h +++ b/src/r_draw_rgba_sse.h @@ -43,7 +43,7 @@ public: _destorg = dc_destorg; _light = ds_light; _shade_constants = ds_shade_constants; - _magnifying = !span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep); + _magnifying = !SampleBgra::span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep); } void Execute(DrawerThread *thread) override @@ -70,7 +70,7 @@ public: xstep = _xstep; ystep = _ystep; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; if (_magnifying) @@ -166,7 +166,7 @@ public: spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); // Lookup pixel from flat texture tile - *dest++ = shade_bgra(source[spot], light, shade_constants); + *dest++ = LightBgra::shade_bgra(source[spot], light, shade_constants); // Next step in u,v. xfrac += xstep; @@ -258,7 +258,7 @@ public: spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); // Lookup pixel from flat texture tile - *dest++ = shade_bgra(source[spot], light, shade_constants); + *dest++ = LightBgra::shade_bgra(source[spot], light, shade_constants); // Next step in u,v. xfrac += xstep; @@ -305,7 +305,7 @@ public: do { - *dest++ = shade_bgra(sample_bilinear(source, xfrac, yfrac, 26, 26), light, shade_constants); + *dest++ = LightBgra::shade_bgra(SampleBgra::sample_bilinear(source, xfrac, yfrac, 26, 26), light, shade_constants); xfrac += xstep; yfrac += ystep; } while (--count); @@ -349,7 +349,7 @@ public: do { - *dest++ = shade_bgra(sample_bilinear(source, xfrac, yfrac, 32 - _xbits, 32 - _ybits), light, shade_constants); + *dest++ = LightBgra::shade_bgra(SampleBgra::sample_bilinear(source, xfrac, yfrac, 32 - _xbits, 32 - _ybits), light, shade_constants); xfrac += xstep; yfrac += ystep; } while (--count); @@ -364,7 +364,8 @@ class VecCommand(Vlinec4RGBA) : public DrawerCommand int _count; int _pitch; ShadeConstants _shade_constants; - int vlinebits; + int _vlinebits; + uint32_t _vlinemax; fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; @@ -379,7 +380,8 @@ public: _count = dc_count; _pitch = dc_pitch; _shade_constants = dc_shade_constants; - vlinebits = ::vlinebits; + _vlinebits = vlinebits; + _vlinemax = vlinemax; for (int i = 0; i < 4; i++) { palookuplight[i] = ::palookuplight[i]; @@ -398,13 +400,13 @@ public: return; uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int bits = vlinebits; + int bits = _vlinebits; int pitch = _pitch * thread->num_cores; - uint32_t light0 = calc_light_multiplier(palookuplight[0]); - uint32_t light1 = calc_light_multiplier(palookuplight[1]); - uint32_t light2 = calc_light_multiplier(palookuplight[2]); - uint32_t light3 = calc_light_multiplier(palookuplight[3]); + uint32_t light0 = LightBgra::calc_light_multiplier(palookuplight[0]); + uint32_t light1 = LightBgra::calc_light_multiplier(palookuplight[1]); + uint32_t light2 = LightBgra::calc_light_multiplier(palookuplight[2]); + uint32_t light3 = LightBgra::calc_light_multiplier(palookuplight[3]); ShadeConstants shade_constants = _shade_constants; @@ -480,7 +482,7 @@ public: do { __m128i fg; - VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits); + VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits, _vlinemax); local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -498,7 +500,7 @@ public: do { __m128i fg; - VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits); + VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits, _vlinemax); local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -520,7 +522,8 @@ class VecCommand(Mvlinec4RGBA) : public DrawerCommand int _count; int _pitch; ShadeConstants _shade_constants; - int mvlinebits; + int _mvlinebits; + uint32_t _mvlinemax; fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; @@ -535,7 +538,8 @@ public: _count = dc_count; _pitch = dc_pitch; _shade_constants = dc_shade_constants; - mvlinebits = ::mvlinebits; + _mvlinebits = mvlinebits; + _mvlinemax = mvlinemax; for (int i = 0; i < 4; i++) { palookuplight[i] = ::palookuplight[i]; @@ -555,12 +559,12 @@ public: uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int pitch = _pitch * thread->num_cores; - int bits = mvlinebits; + int bits = _mvlinebits; - uint32_t light0 = calc_light_multiplier(palookuplight[0]); - uint32_t light1 = calc_light_multiplier(palookuplight[1]); - uint32_t light2 = calc_light_multiplier(palookuplight[2]); - uint32_t light3 = calc_light_multiplier(palookuplight[3]); + uint32_t light0 = LightBgra::calc_light_multiplier(palookuplight[0]); + uint32_t light1 = LightBgra::calc_light_multiplier(palookuplight[1]); + uint32_t light2 = LightBgra::calc_light_multiplier(palookuplight[2]); + uint32_t light3 = LightBgra::calc_light_multiplier(palookuplight[3]); ShadeConstants shade_constants = _shade_constants; @@ -640,7 +644,7 @@ public: do { __m128i fg; - VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits); + VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits, _mvlinemax); local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -660,7 +664,7 @@ public: do { __m128i fg; - VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits); + VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits, _mvlinemax); local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -686,7 +690,8 @@ class VecCommand(Tmvline4AddRGBA) : public DrawerCommand ShadeConstants _shade_constants; fixed_t _srcalpha; fixed_t _destalpha; - int tmvlinebits; + int _tmvlinebits; + uint32_t _tmvlinemax; fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; @@ -701,7 +706,8 @@ public: _shade_constants = dc_shade_constants; _srcalpha = dc_srcalpha; _destalpha = dc_destalpha; - tmvlinebits = ::tmvlinebits; + _tmvlinebits = tmvlinebits; + _tmvlinemax = tmvlinemax; for (int i = 0; i < 4; i++) { palookuplight[i] = ::palookuplight[i]; @@ -719,13 +725,13 @@ public: uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int pitch = _pitch * thread->num_cores; - int bits = tmvlinebits; + int bits = _tmvlinebits; uint32_t light[4]; - light[0] = calc_light_multiplier(palookuplight[0]); - light[1] = calc_light_multiplier(palookuplight[1]); - light[2] = calc_light_multiplier(palookuplight[2]); - light[3] = calc_light_multiplier(palookuplight[3]); + light[0] = LightBgra::calc_light_multiplier(palookuplight[0]); + light[1] = LightBgra::calc_light_multiplier(palookuplight[1]); + light[2] = LightBgra::calc_light_multiplier(palookuplight[2]); + light[3] = LightBgra::calc_light_multiplier(palookuplight[3]); ShadeConstants shade_constants = _shade_constants; @@ -825,7 +831,8 @@ class VecCommand(Tmvline4AddClampRGBA) : public DrawerCommand ShadeConstants _shade_constants; fixed_t _srcalpha; fixed_t _destalpha; - int tmvlinebits; + int _tmvlinebits; + uint32_t _tmvlinemax; fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; @@ -840,7 +847,8 @@ public: _shade_constants = dc_shade_constants; _srcalpha = dc_srcalpha; _destalpha = dc_destalpha; - tmvlinebits = ::tmvlinebits; + _tmvlinebits = tmvlinebits; + _tmvlinemax = tmvlinemax; for (int i = 0; i < 4; i++) { palookuplight[i] = ::palookuplight[i]; @@ -858,13 +866,13 @@ public: uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int pitch = _pitch * thread->num_cores; - int bits = tmvlinebits; + int bits = _tmvlinebits; uint32_t light[4]; - light[0] = calc_light_multiplier(palookuplight[0]); - light[1] = calc_light_multiplier(palookuplight[1]); - light[2] = calc_light_multiplier(palookuplight[2]); - light[3] = calc_light_multiplier(palookuplight[3]); + light[0] = LightBgra::calc_light_multiplier(palookuplight[0]); + light[1] = LightBgra::calc_light_multiplier(palookuplight[1]); + light[2] = LightBgra::calc_light_multiplier(palookuplight[2]); + light[3] = LightBgra::calc_light_multiplier(palookuplight[3]); ShadeConstants shade_constants = _shade_constants; @@ -963,7 +971,8 @@ class VecCommand(Tmvline4SubClampRGBA) : public DrawerCommand ShadeConstants _shade_constants; fixed_t _srcalpha; fixed_t _destalpha; - int tmvlinebits; + int _tmvlinebits; + uint32_t _tmvlinemax; fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; @@ -978,7 +987,8 @@ public: _shade_constants = dc_shade_constants; _srcalpha = dc_srcalpha; _destalpha = dc_destalpha; - tmvlinebits = ::tmvlinebits; + _tmvlinebits = tmvlinebits; + _tmvlinemax = tmvlinemax; for (int i = 0; i < 4; i++) { palookuplight[i] = ::palookuplight[i]; @@ -996,13 +1006,13 @@ public: uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int pitch = _pitch * thread->num_cores; - int bits = tmvlinebits; + int bits = _tmvlinebits; uint32_t light[4]; - light[0] = calc_light_multiplier(palookuplight[0]); - light[1] = calc_light_multiplier(palookuplight[1]); - light[2] = calc_light_multiplier(palookuplight[2]); - light[3] = calc_light_multiplier(palookuplight[3]); + light[0] = LightBgra::calc_light_multiplier(palookuplight[0]); + light[1] = LightBgra::calc_light_multiplier(palookuplight[1]); + light[2] = LightBgra::calc_light_multiplier(palookuplight[2]); + light[3] = LightBgra::calc_light_multiplier(palookuplight[3]); ShadeConstants shade_constants = _shade_constants; @@ -1101,7 +1111,8 @@ class VecCommand(Tmvline4RevSubClampRGBA) : public DrawerCommand ShadeConstants _shade_constants; fixed_t _srcalpha; fixed_t _destalpha; - int tmvlinebits; + int _tmvlinebits; + uint32_t _tmvlinemax; fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; @@ -1116,7 +1127,8 @@ public: _shade_constants = dc_shade_constants; _srcalpha = dc_srcalpha; _destalpha = dc_destalpha; - tmvlinebits = ::tmvlinebits; + _tmvlinebits = tmvlinebits; + _tmvlinemax = tmvlinemax; for (int i = 0; i < 4; i++) { palookuplight[i] = ::palookuplight[i]; @@ -1134,13 +1146,13 @@ public: uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int pitch = _pitch * thread->num_cores; - int bits = tmvlinebits; + int bits = _tmvlinebits; uint32_t light[4]; - light[0] = calc_light_multiplier(palookuplight[0]); - light[1] = calc_light_multiplier(palookuplight[1]); - light[2] = calc_light_multiplier(palookuplight[2]); - light[3] = calc_light_multiplier(palookuplight[3]); + light[0] = LightBgra::calc_light_multiplier(palookuplight[0]); + light[1] = LightBgra::calc_light_multiplier(palookuplight[1]); + light[2] = LightBgra::calc_light_multiplier(palookuplight[2]); + light[3] = LightBgra::calc_light_multiplier(palookuplight[3]); ShadeConstants shade_constants = _shade_constants; diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index e239674e8..c39fdc287 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -185,7 +185,7 @@ public: if (count <= 0) return; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); @@ -196,7 +196,7 @@ public: BYTE *colormap = _colormap; if (count & 1) { - *dest = shade_pal_index(colormap[*source], light, shade_constants); + *dest = LightBgra::shade_pal_index(colormap[*source], light, shade_constants); source += sincr; dest += pitch; } @@ -204,8 +204,8 @@ public: return; do { - dest[0] = shade_pal_index(colormap[source[0]], light, shade_constants); - dest[pitch] = shade_pal_index(colormap[source[sincr]], light, shade_constants); + dest[0] = LightBgra::shade_pal_index(colormap[source[0]], light, shade_constants); + dest[pitch] = LightBgra::shade_pal_index(colormap[source[sincr]], light, shade_constants); source += sincr * 2; dest += pitch * 2; } while (--count); @@ -249,7 +249,7 @@ public: if (count <= 0) return; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); @@ -260,10 +260,10 @@ public: BYTE *colormap = _colormap; if (count & 1) { - dest[0] = shade_pal_index(colormap[source[0]], light, shade_constants); - dest[1] = shade_pal_index(colormap[source[1]], light, shade_constants); - dest[2] = shade_pal_index(colormap[source[2]], light, shade_constants); - dest[3] = shade_pal_index(colormap[source[3]], light, shade_constants); + dest[0] = LightBgra::shade_pal_index(colormap[source[0]], light, shade_constants); + dest[1] = LightBgra::shade_pal_index(colormap[source[1]], light, shade_constants); + dest[2] = LightBgra::shade_pal_index(colormap[source[2]], light, shade_constants); + dest[3] = LightBgra::shade_pal_index(colormap[source[3]], light, shade_constants); source += sincr; dest += pitch; } @@ -271,14 +271,14 @@ public: return; do { - dest[0] = shade_pal_index(colormap[source[0]], light, shade_constants); - dest[1] = shade_pal_index(colormap[source[1]], light, shade_constants); - dest[2] = shade_pal_index(colormap[source[2]], light, shade_constants); - dest[3] = shade_pal_index(colormap[source[3]], light, shade_constants); - dest[pitch] = shade_pal_index(colormap[source[sincr]], light, shade_constants); - dest[pitch + 1] = shade_pal_index(colormap[source[sincr + 1]], light, shade_constants); - dest[pitch + 2] = shade_pal_index(colormap[source[sincr + 2]], light, shade_constants); - dest[pitch + 3] = shade_pal_index(colormap[source[sincr + 3]], light, shade_constants); + dest[0] = LightBgra::shade_pal_index(colormap[source[0]], light, shade_constants); + dest[1] = LightBgra::shade_pal_index(colormap[source[1]], light, shade_constants); + dest[2] = LightBgra::shade_pal_index(colormap[source[2]], light, shade_constants); + dest[3] = LightBgra::shade_pal_index(colormap[source[3]], light, shade_constants); + dest[pitch] = LightBgra::shade_pal_index(colormap[source[sincr]], light, shade_constants); + dest[pitch + 1] = LightBgra::shade_pal_index(colormap[source[sincr + 1]], light, shade_constants); + dest[pitch + 2] = LightBgra::shade_pal_index(colormap[source[sincr + 2]], light, shade_constants); + dest[pitch + 3] = LightBgra::shade_pal_index(colormap[source[sincr + 3]], light, shade_constants); source += sincr * 2; dest += pitch * 2; } while (--count); @@ -453,7 +453,7 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; BYTE *colormap = _colormap; @@ -461,7 +461,7 @@ public: uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(colormap[*source], light, shade_constants); + uint32_t fg = LightBgra::shade_pal_index(colormap[*source], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -528,7 +528,7 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; BYTE *colormap = _colormap; @@ -538,7 +538,7 @@ public: do { for (int i = 0; i < 4; i++) { - uint32_t fg = shade_pal_index(colormap[source[i]], light, shade_constants); + uint32_t fg = LightBgra::shade_pal_index(colormap[source[i]], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -606,7 +606,7 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); + uint32_t fg = LightBgra::shade_pal_index_simple(_color, LightBgra::calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -674,7 +674,7 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t fg = shade_pal_index_simple(_color, calc_light_multiplier(_light)); + uint32_t fg = LightBgra::shade_pal_index_simple(_color, LightBgra::calc_light_multiplier(_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -747,14 +747,14 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(*source, light, shade_constants); + uint32_t fg = LightBgra::shade_pal_index(*source, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -818,7 +818,7 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); @@ -827,7 +827,7 @@ public: do { for (int i = 0; i < 4; i++) { - uint32_t fg = shade_pal_index(source[i], light, shade_constants); + uint32_t fg = LightBgra::shade_pal_index(source[i], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -894,14 +894,14 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(*source, light, shade_constants); + uint32_t fg = LightBgra::shade_pal_index(*source, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -965,7 +965,7 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); @@ -974,7 +974,7 @@ public: do { for (int i = 0; i < 4; i++) { - uint32_t fg = shade_pal_index(source[i], light, shade_constants); + uint32_t fg = LightBgra::shade_pal_index(source[i], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -1042,14 +1042,14 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(*source, light, shade_constants); + uint32_t fg = LightBgra::shade_pal_index(*source, light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -1113,7 +1113,7 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); @@ -1122,7 +1122,7 @@ public: do { for (int i = 0; i < 4; i++) { - uint32_t fg = shade_pal_index(source[i], light, shade_constants); + uint32_t fg = LightBgra::shade_pal_index(source[i], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; diff --git a/src/r_drawt_rgba_sse.h b/src/r_drawt_rgba_sse.h index 684be2b6a..64a77e288 100644 --- a/src/r_drawt_rgba_sse.h +++ b/src/r_drawt_rgba_sse.h @@ -48,7 +48,7 @@ public: return; ShadeConstants shade_constants = _shade_constants; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); @@ -207,7 +207,7 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; BYTE *colormap = _colormap; @@ -335,7 +335,7 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(shade_pal_index_simple(_color, calc_light_multiplier(_light))), _mm_setzero_si128()); + __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(LightBgra::shade_pal_index_simple(_color, LightBgra::calc_light_multiplier(_light))), _mm_setzero_si128()); __m128i alpha_one = _mm_set1_epi16(64); do { @@ -411,7 +411,7 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); @@ -538,7 +538,7 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; ShadeConstants shade_constants = _shade_constants; @@ -664,7 +664,7 @@ public: pitch = _pitch * thread->num_cores; sincr = 4 * thread->num_cores; - uint32_t light = calc_light_multiplier(_light); + uint32_t light = LightBgra::calc_light_multiplier(_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; ShadeConstants shade_constants = _shade_constants; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 6913db918..0ede451e0 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -514,8 +514,8 @@ void R_MapColoredPlane_rgba(int y, int x1) { uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg; int count = (spanend[y] - x1 + 1); - uint32_t light = calc_light_multiplier(ds_light); - uint32_t color = shade_pal_index_simple(ds_color, light); + uint32_t light = LightBgra::calc_light_multiplier(ds_light); + uint32_t color = LightBgra::shade_pal_index_simple(ds_color, light); for (int i = 0; i < count; i++) dest[i] = color; } diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 84c967d1d..95dd287aa 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1276,7 +1276,7 @@ typedef void(*Draw4ColumnsFuncPtr)(); void wallscan_any( int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x), - void(setupwallscan(int bits,Draw1ColumnFuncPtr &draw1, Draw4ColumnsFuncPtr &draw2))) + void(setupwallscan(int bits, int fracmax, Draw1ColumnFuncPtr &draw1, Draw4ColumnsFuncPtr &draw2))) { if (rw_pic->UseType == FTexture::TEX_Null) return; @@ -1286,7 +1286,7 @@ void wallscan_any( DWORD(*draw1column)(); void(*draw4columns)(); - setupwallscan(32 - rw_pic->HeightBits, draw1column, draw4columns); + setupwallscan(32 - rw_pic->HeightBits, (rw_pic->GetHeight() - 1) << (32 - rw_pic->HeightBits), draw1column, draw4columns); bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); if (fixed) @@ -1439,9 +1439,9 @@ void wallscan_any( void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) { - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, int fracmax, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) { - setupvline(bits); + setupvline(bits, fracmax); line1 = dovline1; line4 = dovline4; }); @@ -1455,9 +1455,9 @@ void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t } else { - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, int fracmax, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) { - setupmvline(bits); + setupmvline(bits, fracmax); line1 = domvline1; line4 = domvline4; }); @@ -1475,9 +1475,9 @@ void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fi } else { - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, int fracmax, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) { - setuptmvline(bits); + setuptmvline(bits, fracmax); line1 = reinterpret_cast(tmvline1); line4 = tmvline4; }); diff --git a/src/r_things.cpp b/src/r_things.cpp index e1f1017f3..74707ff72 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2732,7 +2732,7 @@ void R_DrawParticle_rgba(vissprite_t *vis) DrawerCommandQueue::WaitForWorkers(); - uint32_t fg = shade_pal_index_simple(color, calc_light_multiplier(LIGHTSCALE(0, vis->Style.ColormapNum << FRACBITS))); + uint32_t fg = LightBgra::shade_pal_index_simple(color, LightBgra::calc_light_multiplier(LIGHTSCALE(0, vis->Style.ColormapNum << FRACBITS))); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; diff --git a/src/v_draw.cpp b/src/v_draw.cpp index fd12a1587..0fb433343 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -1026,7 +1026,7 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) { uint32_t *spot = (uint32_t*)GetBuffer() + oldyyshifted + xx; - uint32_t fg = shade_pal_index_simple(basecolor, calc_light_multiplier(0)); + uint32_t fg = LightBgra::shade_pal_index_simple(basecolor, LightBgra::calc_light_multiplier(0)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; From b7f32d1bfce120c6372d3ca453aaaba755f8207f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 24 Jun 2016 18:05:32 +0200 Subject: [PATCH 0695/1509] Added LoopIterator to the drawt family of drawers --- src/r_drawt_rgba.cpp | 1193 ++++++++++++------------------------------ 1 file changed, 330 insertions(+), 863 deletions(-) diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index c39fdc287..82932b1f2 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -84,8 +84,9 @@ extern unsigned int *horizspan[4]; ///////////////////////////////////////////////////////////////////////////// -class RtCopy1colRGBACommand : public DrawerCommand +class DrawerRt1colCommand : public DrawerCommand { +public: int hx; int sx; int yl; @@ -93,8 +94,14 @@ class RtCopy1colRGBACommand : public DrawerCommand BYTE * RESTRICT _destorg; int _pitch; -public: - RtCopy1colRGBACommand(int hx, int sx, int yl, int yh) + uint32_t _light; + ShadeConstants _shade_constants; + BYTE * RESTRICT _colormap; + + uint32_t _srcalpha; + uint32_t _destalpha; + + DrawerRt1colCommand(int hx, int sx, int yl, int yh) { this->hx = hx; this->sx = sx; @@ -103,185 +110,384 @@ public: _destorg = dc_destorg; _pitch = dc_pitch; + + _light = LightBgra::calc_light_multiplier(dc_light); + _shade_constants = dc_shade_constants; + _colormap = dc_colormap; + + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); } - void Execute(DrawerThread *thread) override + class LoopIterator { + public: uint32_t *source; uint32_t *dest; int count; int pitch, sincr; - count = thread->count_for_thread(yl, (yh - yl + 1)); - if (count <= 0) - return; + LoopIterator(DrawerRt1colCommand *command, DrawerThread *thread) + { + count = thread->count_for_thread(command->yl, (command->yh - command->yl + 1)); + if (count <= 0) + return; - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = thread->num_cores * 4; + dest = thread->dest_for_thread(command->yl, command->_pitch, ylookup[command->yl] + command->sx + (uint32_t*)command->_destorg); + source = &thread->dc_temp_rgba[command->yl * 4 + command->hx] + thread->skipped_by_thread(command->yl) * 4; + pitch = command->_pitch * thread->num_cores; + sincr = thread->num_cores * 4; + } - if (count & 1) { - *dest = GPalette.BaseColors[*source]; - source += sincr; + explicit operator bool() + { + return count > 0; + } + + bool next() + { dest += pitch; + source += sincr; + return (--count) != 0; } - if (count & 2) { - dest[0] = GPalette.BaseColors[source[0]]; - dest[pitch] = GPalette.BaseColors[source[sincr]]; - source += sincr * 2; - dest += pitch * 2; - } - if (!(count >>= 2)) - return; - - do { - dest[0] = GPalette.BaseColors[source[0]]; - dest[pitch] = GPalette.BaseColors[source[sincr]]; - dest[pitch * 2] = GPalette.BaseColors[source[sincr * 2]]; - dest[pitch * 3] = GPalette.BaseColors[source[sincr * 3]]; - source += sincr * 4; - dest += pitch * 4; - } while (--count); - } + }; }; -class RtMap1colRGBACommand : public DrawerCommand +class DrawerRt4colsCommand : public DrawerCommand { - int hx; +public: int sx; int yl; int yh; - fixed_t _light; + uint32_t _light; ShadeConstants _shade_constants; BYTE * RESTRICT _destorg; int _pitch; BYTE * RESTRICT _colormap; + uint32_t _srcalpha; + uint32_t _destalpha; -public: - RtMap1colRGBACommand(int hx, int sx, int yl, int yh) + DrawerRt4colsCommand(int sx, int yl, int yh) { - this->hx = hx; this->sx = sx; this->yl = yl; this->yh = yh; - _light = dc_light; + _light = LightBgra::calc_light_multiplier(dc_light); _shade_constants = dc_shade_constants; _destorg = dc_destorg; _pitch = dc_pitch; _colormap = dc_colormap; + + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); } - void Execute(DrawerThread *thread) override + class LoopIterator { + public: uint32_t *source; uint32_t *dest; int count; int pitch; int sincr; - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; + LoopIterator(DrawerRt4colsCommand *command, DrawerThread *thread) + { + count = thread->count_for_thread(command->yl, command->yh - command->yl + 1); + if (count <= 0) + return; - uint32_t light = LightBgra::calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = thread->num_cores * 4; - - BYTE *colormap = _colormap; - - if (count & 1) { - *dest = LightBgra::shade_pal_index(colormap[*source], light, shade_constants); - source += sincr; - dest += pitch; + dest = thread->dest_for_thread(command->yl, command->_pitch, ylookup[command->yl] + command->sx + (uint32_t*)command->_destorg); + source = &thread->dc_temp_rgba[command->yl * 4] + thread->skipped_by_thread(command->yl) * 4; + pitch = command->_pitch * thread->num_cores; + sincr = thread->num_cores * 4; } - if (!(count >>= 1)) - return; - do { - dest[0] = LightBgra::shade_pal_index(colormap[source[0]], light, shade_constants); - dest[pitch] = LightBgra::shade_pal_index(colormap[source[sincr]], light, shade_constants); - source += sincr * 2; - dest += pitch * 2; - } while (--count); - } + explicit operator bool() + { + return count > 0; + } + + bool next() + { + dest += pitch; + source += sincr; + return (--count) != 0; + } + }; }; -class RtMap4colsRGBACommand : public DrawerCommand +class RtCopy1colRGBACommand : public DrawerRt1colCommand { - int sx; - int yl; - int yh; - fixed_t _light; - ShadeConstants _shade_constants; - BYTE * RESTRICT _destorg; - int _pitch; - BYTE * RESTRICT _colormap; - public: - RtMap4colsRGBACommand(int sx, int yl, int yh) + RtCopy1colRGBACommand(int hx, int sx, int yl, int yh) : DrawerRt1colCommand(hx, sx, yl, yh) { - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _light = dc_light; - _shade_constants = dc_shade_constants; - _destorg = dc_destorg; - _pitch = dc_pitch; - _colormap = dc_colormap; } void Execute(DrawerThread *thread) override { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = GPalette.BaseColors[*loop.source]; + *loop.dest = BlendBgra::copy(fg); + } while (loop.next()); + } +}; - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; +class RtMap1colRGBACommand : public DrawerRt1colCommand +{ +public: + RtMap1colRGBACommand(int hx, int sx, int yl, int yh) : DrawerRt1colCommand(hx, sx, yl, yh) + { + } - uint32_t light = LightBgra::calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = LightBgra::shade_pal_index(_colormap[*loop.source], _light, _shade_constants); + *loop.dest = BlendBgra::copy(fg); + } while (loop.next()); + } +}; - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = thread->num_cores * 4; - - BYTE *colormap = _colormap; +class RtMap4colsRGBACommand : public DrawerRt4colsCommand +{ +public: + RtMap4colsRGBACommand(int sx, int yl, int yh) : DrawerRt4colsCommand(sx, yl, yh) + { + } - if (count & 1) { - dest[0] = LightBgra::shade_pal_index(colormap[source[0]], light, shade_constants); - dest[1] = LightBgra::shade_pal_index(colormap[source[1]], light, shade_constants); - dest[2] = LightBgra::shade_pal_index(colormap[source[2]], light, shade_constants); - dest[3] = LightBgra::shade_pal_index(colormap[source[3]], light, shade_constants); - source += sincr; - dest += pitch; - } - if (!(count >>= 1)) - return; + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + for (int i = 0; i < 4; i++) + { + uint32_t fg = LightBgra::shade_pal_index(_colormap[loop.source[i]], _light, _shade_constants); + loop.dest[i] = BlendBgra::copy(fg); + } + } while (loop.next()); + } +}; - do { - dest[0] = LightBgra::shade_pal_index(colormap[source[0]], light, shade_constants); - dest[1] = LightBgra::shade_pal_index(colormap[source[1]], light, shade_constants); - dest[2] = LightBgra::shade_pal_index(colormap[source[2]], light, shade_constants); - dest[3] = LightBgra::shade_pal_index(colormap[source[3]], light, shade_constants); - dest[pitch] = LightBgra::shade_pal_index(colormap[source[sincr]], light, shade_constants); - dest[pitch + 1] = LightBgra::shade_pal_index(colormap[source[sincr + 1]], light, shade_constants); - dest[pitch + 2] = LightBgra::shade_pal_index(colormap[source[sincr + 2]], light, shade_constants); - dest[pitch + 3] = LightBgra::shade_pal_index(colormap[source[sincr + 3]], light, shade_constants); - source += sincr * 2; - dest += pitch * 2; - } while (--count); +class RtAdd1colRGBACommand : public DrawerRt1colCommand +{ +public: + RtAdd1colRGBACommand(int hx, int sx, int yl, int yh) : DrawerRt1colCommand(hx, sx, yl, yh) + { + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = LightBgra::shade_pal_index(_colormap[*loop.source], _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); + } +}; + +class RtAdd4colsRGBACommand : public DrawerRt4colsCommand +{ +public: + RtAdd4colsRGBACommand(int sx, int yl, int yh) : DrawerRt4colsCommand(sx, yl, yh) + { + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + for (int i = 0; i < 4; i++) + { + uint32_t fg = LightBgra::shade_pal_index(_colormap[loop.source[i]], _light, _shade_constants); + loop.dest[i] = BlendBgra::add(fg, loop.dest[i], _srcalpha, _destalpha); + } + } while (loop.next()); + } +}; + +class RtShaded1colRGBACommand : public DrawerRt1colCommand +{ + uint32_t _color; + +public: + RtShaded1colRGBACommand(int hx, int sx, int yl, int yh) : DrawerRt1colCommand(hx, sx, yl, yh) + { + _color = LightBgra::shade_pal_index(dc_color, _light, _shade_constants); + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t alpha = _colormap[*loop.source] * 4; + uint32_t inv_alpha = 256 - alpha; + *loop.dest = BlendBgra::add(_color, *loop.dest, alpha, inv_alpha); + } while (loop.next()); + } +}; + +class RtShaded4colsRGBACommand : public DrawerRt4colsCommand +{ + uint32_t _color; + +public: + RtShaded4colsRGBACommand(int sx, int yl, int yh) : DrawerRt4colsCommand(sx, yl, yh) + { + _color = LightBgra::shade_pal_index(dc_color, _light, _shade_constants); + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + for (int i = 0; i < 4; i++) + { + uint32_t alpha = _colormap[loop.source[i]] * 4; + uint32_t inv_alpha = 256 - alpha; + loop.dest[i] = BlendBgra::add(_color, loop.dest[i], alpha, inv_alpha); + } + } while (loop.next()); + } +}; + +class RtAddClamp1colRGBACommand : public DrawerRt1colCommand +{ +public: + RtAddClamp1colRGBACommand(int hx, int sx, int yl, int yh) : DrawerRt1colCommand(hx, sx, yl, yh) + { + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = LightBgra::shade_pal_index(*loop.source, _light, _shade_constants); + *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); + } +}; + +class RtAddClamp4colsRGBACommand : public DrawerRt4colsCommand +{ +public: + RtAddClamp4colsRGBACommand(int sx, int yl, int yh) : DrawerRt4colsCommand(sx, yl, yh) + { + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + for (int i = 0; i < 4; i++) + { + uint32_t fg = LightBgra::shade_pal_index(loop.source[i], _light, _shade_constants); + loop.dest[i] = BlendBgra::add(fg, loop.dest[i], _srcalpha, _destalpha); + } + } while (loop.next()); + } +}; + +class RtSubClamp1colRGBACommand : public DrawerRt1colCommand +{ +public: + RtSubClamp1colRGBACommand(int hx, int sx, int yl, int yh) : DrawerRt1colCommand(hx, sx, yl, yh) + { + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = LightBgra::shade_pal_index(*loop.source, _light, _shade_constants); + *loop.dest = BlendBgra::sub(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); + } +}; + +class RtSubClamp4colsRGBACommand : public DrawerRt4colsCommand +{ +public: + RtSubClamp4colsRGBACommand(int sx, int yl, int yh) : DrawerRt4colsCommand(sx, yl, yh) + { + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + for (int i = 0; i < 4; i++) + { + uint32_t fg = LightBgra::shade_pal_index(loop.source[i], _light, _shade_constants); + loop.dest[i] = BlendBgra::sub(fg, loop.dest[i], _srcalpha, _destalpha); + } + } while (loop.next()); + } +}; + +class RtRevSubClamp1colRGBACommand : public DrawerRt1colCommand +{ +public: + RtRevSubClamp1colRGBACommand(int hx, int sx, int yl, int yh) : DrawerRt1colCommand(hx, sx, yl, yh) + { + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + uint32_t fg = LightBgra::shade_pal_index(*loop.source, _light, _shade_constants); + *loop.dest = BlendBgra::revsub(fg, *loop.dest, _srcalpha, _destalpha); + } while (loop.next()); + } +}; + +class RtRevSubClamp4colsRGBACommand : public DrawerRt4colsCommand +{ +public: + RtRevSubClamp4colsRGBACommand(int sx, int yl, int yh) : DrawerRt4colsCommand(sx, yl, yh) + { + } + + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + do + { + for (int i = 0; i < 4; i++) + { + uint32_t fg = LightBgra::shade_pal_index(loop.source[i], _light, _shade_constants); + loop.dest[i] = BlendBgra::revsub(fg, loop.dest[i], _srcalpha, _destalpha); + } + } while (loop.next()); } }; @@ -405,745 +611,6 @@ public: } }; -class RtAdd1colRGBACommand : public DrawerCommand -{ - int hx; - int sx; - int yl; - int yh; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - BYTE * RESTRICT _colormap; - -public: - RtAdd1colRGBACommand(int hx, int sx, int yl, int yh) - { - this->hx = hx; - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _destorg = dc_destorg; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - _colormap = dc_colormap; - } - - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t light = LightBgra::calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - BYTE *colormap = _colormap; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do { - uint32_t fg = LightBgra::shade_pal_index(colormap[*source], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - - source += sincr; - dest += pitch; - } while (--count); - } -}; - -class RtAdd4colsRGBACommand : public DrawerCommand -{ - int sx; - int yl; - int yh; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - BYTE * RESTRICT _colormap; - fixed_t _srcalpha; - fixed_t _destalpha; - -public: - RtAdd4colsRGBACommand(int sx, int yl, int yh) - { - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _destorg = dc_destorg; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _colormap = dc_colormap; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - } - - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t light = LightBgra::calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - BYTE *colormap = _colormap; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_pal_index(colormap[source[i]], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - - source += sincr; - dest += pitch; - } while (--count); - } -}; - -class RtShaded1colRGBACommand : public DrawerCommand -{ - int hx; - int sx; - int yl; - int yh; - lighttable_t * RESTRICT _colormap; - BYTE * RESTRICT _destorg; - int _pitch; - int _color; - fixed_t _light; - -public: - RtShaded1colRGBACommand(int hx, int sx, int yl, int yh) - { - this->hx = hx; - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _colormap = dc_colormap; - _destorg = dc_destorg; - _pitch = dc_pitch; - _color = dc_color; - _light = dc_light; - } - - void Execute(DrawerThread *thread) override - { - BYTE *colormap; - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - colormap = _colormap; - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t fg = LightBgra::shade_pal_index_simple(_color, LightBgra::calc_light_multiplier(_light)); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - do { - uint32_t alpha = colormap[*source]; - uint32_t inv_alpha = 64 - alpha; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; - uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; - uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += sincr; - dest += pitch; - } while (--count); - } -}; - -class RtShaded4colsRGBACommand : public DrawerCommand -{ - int sx; - int yl; - int yh; - lighttable_t * RESTRICT _colormap; - int _color; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; - -public: - RtShaded4colsRGBACommand(int sx, int yl, int yh) - { - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _colormap = dc_colormap; - _color = dc_color; - _destorg = dc_destorg; - _pitch = dc_pitch; - _light = dc_light; - } - - void Execute(DrawerThread *thread) override - { - BYTE *colormap; - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - colormap = _colormap; - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t fg = LightBgra::shade_pal_index_simple(_color, LightBgra::calc_light_multiplier(_light)); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - do { - for (int i = 0; i < 4; i++) - { - uint32_t alpha = colormap[source[i]]; - uint32_t inv_alpha = 64 - alpha; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 64; - uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 64; - uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 64; - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - source += sincr; - dest += pitch; - } while (--count); - } -}; - -class RtAddClamp1colRGBACommand : public DrawerCommand -{ - int hx; - int sx; - int yl; - int yh; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - -public: - RtAddClamp1colRGBACommand(int hx, int sx, int yl, int yh) - { - this->hx = hx; - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _destorg = dc_destorg; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - } - - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t light = LightBgra::calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do { - uint32_t fg = LightBgra::shade_pal_index(*source, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += sincr; - dest += pitch; - } while (--count); - } -}; - -class RtAddClamp4colsRGBACommand : public DrawerCommand -{ - int sx; - int yl; - int yh; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; - fixed_t _srcalpha; - fixed_t _destalpha; - ShadeConstants _shade_constants; - -public: - RtAddClamp4colsRGBACommand(int sx, int yl, int yh) - { - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _destorg = dc_destorg; - _pitch = dc_pitch; - _light = dc_light; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - _shade_constants = dc_shade_constants; - } - - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t light = LightBgra::calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_pal_index(source[i], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp((fg_red * fg_alpha + bg_red * bg_alpha) / 256, 0, 255); - uint32_t green = clamp((fg_green * fg_alpha + bg_green * bg_alpha) / 256, 0, 255); - uint32_t blue = clamp((fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 0, 255); - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - source += sincr; - dest += pitch; - } while (--count); - } -}; - -class RtSubClamp1colRGBACommand : public DrawerCommand -{ - int hx; - int sx; - int yl; - int yh; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; - fixed_t _srcalpha; - fixed_t _destalpha; - ShadeConstants _shade_constants; - -public: - RtSubClamp1colRGBACommand(int hx, int sx, int yl, int yh) - { - this->hx = hx; - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _destorg = dc_destorg; - _pitch = dc_pitch; - _light = dc_light; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - _shade_constants = dc_shade_constants; - } - - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t light = LightBgra::calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do { - uint32_t fg = LightBgra::shade_pal_index(*source, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += sincr; - dest += pitch; - } while (--count); - } -}; - -class RtSubClamp4colsRGBACommand : public DrawerCommand -{ - int sx; - int yl; - int yh; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; - fixed_t _srcalpha; - fixed_t _destalpha; - ShadeConstants _shade_constants; - -public: - RtSubClamp4colsRGBACommand(int sx, int yl, int yh) - { - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _destorg = dc_destorg; - _pitch = dc_pitch; - _light = dc_light; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - _shade_constants = dc_shade_constants; - } - - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t light = LightBgra::calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_pal_index(source[i], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp((0x10000 - fg_red * fg_alpha + bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - fg_green * fg_alpha + bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - fg_blue * fg_alpha + bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - - source += sincr; - dest += pitch; - } while (--count); - } -}; - -class RtRevSubClamp1colRGBACommand : public DrawerCommand -{ - int hx; - int sx; - int yl; - int yh; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; - fixed_t _srcalpha; - fixed_t _destalpha; - ShadeConstants _shade_constants; - -public: - RtRevSubClamp1colRGBACommand(int hx, int sx, int yl, int yh) - { - this->hx = hx; - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _destorg = dc_destorg; - _pitch = dc_pitch; - _light = dc_light; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - _shade_constants = dc_shade_constants; - } - - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4 + hx] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t light = LightBgra::calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do { - uint32_t fg = LightBgra::shade_pal_index(*source, light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - source += sincr; - dest += pitch; - } while (--count); - } -}; - -class RtRevSubClamp4colsRGBACommand : public DrawerCommand -{ - int sx; - int yl; - int yh; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; - fixed_t _srcalpha; - fixed_t _destalpha; - ShadeConstants _shade_constants; - -public: - RtRevSubClamp4colsRGBACommand(int sx, int yl, int yh) - { - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _destorg = dc_destorg; - _pitch = dc_pitch; - _light = dc_light; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - _shade_constants = dc_shade_constants; - } - - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t light = LightBgra::calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - do { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_pal_index(source[i], light, shade_constants); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; - - uint32_t bg_red = (dest[i] >> 16) & 0xff; - uint32_t bg_green = (dest[i] >> 8) & 0xff; - uint32_t bg_blue = (dest[i]) & 0xff; - - uint32_t red = clamp((0x10000 + fg_red * fg_alpha - bg_red * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + fg_green * fg_alpha - bg_green * bg_alpha) / 256, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + fg_blue * fg_alpha - bg_blue * bg_alpha) / 256, 256, 256 + 255) - 256; - - dest[i] = 0xff000000 | (red << 16) | (green << 8) | blue; - } - - source += sincr; - dest += pitch; - } while (--count); - } -}; - class RtInitColsRGBACommand : public DrawerCommand { BYTE * RESTRICT buff; From 8ec420a597ee40f52aa0de394d782784a02c6cb9 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 24 Jun 2016 19:05:04 +0200 Subject: [PATCH 0696/1509] Added support for more texture filtering control --- src/r_draw.h | 6 +++++- src/r_draw_rgba.cpp | 15 ++++++++------- src/r_draw_rgba.h | 9 +++------ src/r_draw_rgba_sse.h | 6 +++--- src/r_segs.cpp | 33 ++++++++++++++++++++++----------- 5 files changed, 41 insertions(+), 28 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index bd477efc4..6a078b08f 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -379,6 +379,10 @@ void R_SetDSColorMapLight(FColormap *base_colormap, float light, int shade); void R_SetTranslationMap(lighttable_t *translation); extern bool r_swtruecolor; -EXTERN_CVAR(Bool, r_bilinear); + +EXTERN_CVAR(Bool, r_multithreaded); +EXTERN_CVAR(Bool, r_magfilter_linear); +EXTERN_CVAR(Bool, r_minfilter_linear); +EXTERN_CVAR(Bool, r_mipmap); #endif diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index dc97fdd47..5a6e88e3b 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -60,9 +60,10 @@ extern float rw_light; extern float rw_lightstep; extern int wallshade; -CVAR(Bool, r_multithreaded, true, 0) -CVAR(Bool, r_bilinear, true, 0) -CVAR(Bool, r_mipmap, true, 0) +CVAR(Bool, r_multithreaded, true, 0); +CVAR(Bool, r_magfilter_linear, false, 0); +CVAR(Bool, r_minfilter_linear, false, 0); +CVAR(Bool, r_mipmap, true, 0); #ifndef NO_SSE @@ -904,7 +905,7 @@ public: const uint32_t * RESTRICT _source; uint32_t _light; ShadeConstants _shade_constants; - bool _magnifying; + bool _nearest_filter; uint32_t _srcalpha; uint32_t _destalpha; @@ -925,7 +926,7 @@ public: _source = (const uint32_t*)ds_source; _light = LightBgra::calc_light_multiplier(ds_light); _shade_constants = ds_shade_constants; - _magnifying = !SampleBgra::span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep); + _nearest_filter = !SampleBgra::span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep); _srcalpha = dc_srcalpha >> (FRACBITS - 8); _destalpha = dc_destalpha >> (FRACBITS - 8); @@ -995,7 +996,7 @@ public: LoopIterator loop(this, thread); if (!loop) return; - if (_magnifying) + if (_nearest_filter) { if (loop.is_64x64) { @@ -1040,7 +1041,7 @@ public: LoopIterator loop(this, thread); if (!loop) return; - if (_magnifying) + if (_nearest_filter) { if (loop.is_64x64) { diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 20fff4fc0..56f1faa24 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -461,15 +461,11 @@ class SampleBgra public: inline static bool span_sampler_setup(const uint32_t * RESTRICT &source, int &xbits, int &ybits, fixed_t xstep, fixed_t ystep) { - if (!r_bilinear) - return false; - // Is this a magfilter or minfilter? fixed_t xmagnitude = abs(xstep) >> (32 - xbits - FRACBITS); fixed_t ymagnitude = abs(ystep) >> (32 - ybits - FRACBITS); fixed_t magnitude = (xmagnitude + ymagnitude) * 2 + (1 << (FRACBITS - 1)); - if (magnitude >> FRACBITS == 0) - return false; + bool magnifying = (magnitude >> FRACBITS == 0); if (r_mipmap) { @@ -485,7 +481,8 @@ public: level >>= 1; } } - return true; + + return (magnifying && r_magfilter_linear) || (!magnifying && r_minfilter_linear); } FORCEINLINE static uint32_t sample_bilinear(const uint32_t *col0, const uint32_t *col1, uint32_t texturefracx, uint32_t texturefracy, int ybits, uint32_t ymax) diff --git a/src/r_draw_rgba_sse.h b/src/r_draw_rgba_sse.h index 408a2f5a2..bca30185c 100644 --- a/src/r_draw_rgba_sse.h +++ b/src/r_draw_rgba_sse.h @@ -25,7 +25,7 @@ class VecCommand(DrawSpanRGBA) : public DrawerCommand BYTE * RESTRICT _destorg; fixed_t _light; ShadeConstants _shade_constants; - bool _magnifying; + bool _nearest_filter; public: VecCommand(DrawSpanRGBA)() @@ -43,7 +43,7 @@ public: _destorg = dc_destorg; _light = ds_light; _shade_constants = ds_shade_constants; - _magnifying = !SampleBgra::span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep); + _nearest_filter = !SampleBgra::span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep); } void Execute(DrawerThread *thread) override @@ -73,7 +73,7 @@ public: uint32_t light = LightBgra::calc_light_multiplier(_light); ShadeConstants shade_constants = _shade_constants; - if (_magnifying) + if (_nearest_filter) { if (_xbits == 6 && _ybits == 6) { diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 95dd287aa..5c9037375 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -50,6 +50,7 @@ #include "r_plane.h" #include "r_segs.h" #include "r_3dfloors.h" +#include "r_draw.h" #include "v_palette.h" #include "r_data/colormaps.h" @@ -58,8 +59,6 @@ CVAR(Bool, r_np2, true, 0) -EXTERN_CVAR(Bool, r_bilinear) - //CVAR (Int, ty, 8, 0) //CVAR (Int, tx, 8, 0) @@ -1104,8 +1103,7 @@ WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xof bool magnifying = uv_step >> (uv_fracbits - 1) == 0; - // Only do bilinear filtering if enabled and not a magnifying filter - if (!r_swtruecolor || !r_bilinear || magnifying || getcol != R_GetColumn) + if (!r_swtruecolor || getcol != R_GetColumn) { source = getcol(texture, xoffset >> FRACBITS); source2 = nullptr; @@ -1138,13 +1136,26 @@ WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xof const uint32_t *pixels = texture->GetPixelsBgra() + mipmap_offset; - int tx0 = ((xoffset - FRACUNIT / 2) >> FRACBITS) % mip_width; - if (tx0 < 0) - tx0 += mip_width; - int tx1 = (tx0 + 1) % mip_width; - source = (BYTE*)(pixels + tx0 * mip_height); - source2 = (BYTE*)(pixels + tx1 * mip_height); - texturefracx = ((xoffset + FRACUNIT / 2) >> (FRACBITS - 4)) & 15; + bool filter_nearest = (magnifying && !r_magfilter_linear) || (!magnifying && !r_minfilter_linear); + if (filter_nearest) + { + int tx = (xoffset >> FRACBITS) % mip_width; + if (tx < 0) + tx += mip_width; + source = (BYTE*)(pixels + tx * mip_height); + source2 = nullptr; + texturefracx = 0; + } + else + { + int tx0 = ((xoffset - FRACUNIT / 2) >> FRACBITS) % mip_width; + if (tx0 < 0) + tx0 += mip_width; + int tx1 = (tx0 + 1) % mip_width; + source = (BYTE*)(pixels + tx0 * mip_height); + source2 = (BYTE*)(pixels + tx1 * mip_height); + texturefracx = ((xoffset + FRACUNIT / 2) >> (FRACBITS - 4)) & 15; + } } } From 77054639666f967c7f885e63205ed7978203d3f0 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 25 Jun 2016 10:33:35 +0200 Subject: [PATCH 0697/1509] Improved linear filtering of walls Fixed some crash bugs Added mipmap and filtering options to the display menu --- src/r_draw.cpp | 16 +- src/r_draw.h | 13 +- src/r_draw_rgba.cpp | 120 ++++----------- src/r_draw_rgba.h | 35 ++--- src/r_draw_rgba_sse.h | 194 +++++++++++++----------- src/r_segs.cpp | 292 +++++++++++++++++++++++-------------- src/textures/textures.h | 4 + wadsrc/static/language.enu | 3 + wadsrc/static/menudef.txt | 3 + 9 files changed, 364 insertions(+), 316 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 578ca9646..682ed4668 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -154,6 +154,7 @@ int dc_yl; int dc_yh; fixed_t dc_iscale; fixed_t dc_texturefrac; +uint32_t dc_textureheight; int dc_color; // [RH] Color for column filler DWORD dc_srccolor; uint32_t dc_srccolor_bgra; @@ -177,6 +178,7 @@ fixed_t palookuplight[4]; const BYTE* bufplce[4]; const BYTE* bufplce2[4]; uint32_t buftexturefracx[4]; +uint32_t bufheight[4]; // just for profiling int dccount; @@ -1044,6 +1046,7 @@ int ds_ybits; // start of a floor/ceiling tile image const BYTE* ds_source; +bool ds_source_mipmapped; // just for profiling int dscount; @@ -1067,6 +1070,7 @@ extern "C" BYTE *ds_curcolormap, *ds_cursource, *ds_curtiltedsource; void R_SetSpanSource(FTexture *tex) { ds_source = r_swtruecolor ? (const BYTE*)tex->GetPixelsBgra() : tex->GetPixels(); + ds_source_mipmapped = tex->Mipmapped(); #ifdef X86_ASM if (!r_swtruecolor && ds_cursource != ds_source) { @@ -1644,8 +1648,6 @@ extern "C" void R_DrawSlabC(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *v int vlinebits; int mvlinebits; -uint32_t vlinemax; -uint32_t mvlinemax; #ifndef X86_ASM static DWORD vlinec1 (); @@ -1695,12 +1697,11 @@ DWORD (*domvline1)() = mvlineasm1; void (*domvline4)() = mvlineasm4; #endif -void setupvline (int fracbits, int fracmax) +void setupvline (int fracbits) { if (r_swtruecolor) { vlinebits = fracbits; - vlinemax = fracmax; return; } @@ -1780,7 +1781,7 @@ void vlinec4 () } #endif -void setupmvline (int fracbits, int fracmax) +void setupmvline (int fracbits) { if (!r_swtruecolor) { @@ -1795,7 +1796,6 @@ void setupmvline (int fracbits, int fracmax) else { mvlinebits = fracbits; - mvlinemax = fracmax; } } @@ -1968,12 +1968,10 @@ void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip) } int tmvlinebits; -uint32_t tmvlinemax; -void setuptmvline (int bits, int fracmax) +void setuptmvline (int bits) { tmvlinebits = bits; - tmvlinemax = fracmax; } fixed_t tmvline1_add_C () diff --git a/src/r_draw.h b/src/r_draw.h index 6a078b08f..591ae0b5f 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -61,6 +61,7 @@ extern "C" int dc_yh; extern "C" fixed_t dc_iscale; extern double dc_texturemid; extern "C" fixed_t dc_texturefrac; +extern "C" uint32_t dc_textureheight; extern "C" int dc_color; // [RH] For flat colors (no texturing) extern "C" DWORD dc_srccolor; extern "C" uint32_t dc_srccolor_bgra; @@ -84,6 +85,7 @@ extern "C" fixed_t palookuplight[4]; extern "C" const BYTE* bufplce[4]; extern "C" const BYTE* bufplce2[4]; extern "C" uint32_t buftexturefracx[4]; +extern "C" uint32_t bufheight[4]; // [RH] Temporary buffer for column drawing extern "C" BYTE *dc_temp; @@ -100,13 +102,13 @@ extern void (*R_DrawColumn)(void); extern DWORD (*dovline1) (); extern DWORD (*doprevline1) (); extern void (*dovline4) (); -extern void setupvline (int,int); +extern void setupvline (int); extern DWORD (*domvline1) (); extern void (*domvline4) (); -extern void setupmvline (int,int); +extern void setupmvline (int); -extern void setuptmvline (int,int); +extern void setuptmvline (int); // The Spectre/Invisibility effect. extern void (*R_DrawFuzzColumn)(void); @@ -316,6 +318,7 @@ extern "C" fixed_t ds_alpha; // start of a 64*64 tile image extern "C" const BYTE* ds_source; +extern "C" bool ds_source_mipmapped; extern "C" int ds_color; // [RH] For flat color (no texturing) @@ -381,8 +384,8 @@ void R_SetTranslationMap(lighttable_t *translation); extern bool r_swtruecolor; EXTERN_CVAR(Bool, r_multithreaded); -EXTERN_CVAR(Bool, r_magfilter_linear); -EXTERN_CVAR(Bool, r_minfilter_linear); +EXTERN_CVAR(Bool, r_magfilter); +EXTERN_CVAR(Bool, r_minfilter); EXTERN_CVAR(Bool, r_mipmap); #endif diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 5a6e88e3b..2576cfeda 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -48,22 +48,22 @@ #endif #include -extern int vlinebits; -extern int mvlinebits; -extern int tmvlinebits; -extern uint32_t vlinemax; -extern uint32_t mvlinemax; -extern uint32_t tmvlinemax; - extern "C" short spanend[MAXHEIGHT]; extern float rw_light; extern float rw_lightstep; extern int wallshade; +// Use multiple threads when drawing CVAR(Bool, r_multithreaded, true, 0); -CVAR(Bool, r_magfilter_linear, false, 0); -CVAR(Bool, r_minfilter_linear, false, 0); -CVAR(Bool, r_mipmap, true, 0); + +// Use linear filtering when scaling up +CVAR(Bool, r_magfilter, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); + +// Use linear filtering when scaling down +CVAR(Bool, r_minfilter, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); + +// Use mipmapped textures +CVAR(Bool, r_mipmap, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); #ifndef NO_SSE @@ -926,7 +926,7 @@ public: _source = (const uint32_t*)ds_source; _light = LightBgra::calc_light_multiplier(ds_light); _shade_constants = ds_shade_constants; - _nearest_filter = !SampleBgra::span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep); + _nearest_filter = !SampleBgra::span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep, ds_source_mipmapped); _srcalpha = dc_srcalpha >> (FRACBITS - 8); _destalpha = dc_destalpha >> (FRACBITS - 8); @@ -1354,8 +1354,7 @@ public: DWORD _texturefrac; uint32_t _texturefracx; DWORD _iscale; - int _vlinebits; - uint32_t _vlinemax; + uint32_t _textureheight; const uint32 * RESTRICT _source; const uint32 * RESTRICT _source2; @@ -1365,7 +1364,7 @@ public: uint32_t _srcalpha; uint32_t _destalpha; - DrawerWall1Command(int vlinebits, uint32_t vlinemax) + DrawerWall1Command() { _dest = dc_dest; _pitch = dc_pitch; @@ -1373,8 +1372,7 @@ public: _texturefrac = dc_texturefrac; _texturefracx = dc_texturefracx; _iscale = dc_iscale; - _vlinebits = vlinebits; - _vlinemax = vlinemax; + _textureheight = dc_textureheight; _source = (const uint32 *)dc_source; _source2 = (const uint32 *)dc_source2; @@ -1394,7 +1392,8 @@ public: uint32_t fracstep; uint32_t frac; uint32_t texturefracx; - int bits; + uint32_t height; + uint32_t half; LoopIterator(DrawerWall1Command *command, DrawerThread *thread) { @@ -1406,8 +1405,10 @@ public: frac = command->_texturefrac + command->_iscale * thread->skipped_by_thread(command->_dest_y); texturefracx = command->_texturefracx; dest = thread->dest_for_thread(command->_dest_y, command->_pitch, (uint32_t*)command->_dest); - bits = command->_vlinebits; pitch = command->_pitch * thread->num_cores; + + height = command->_textureheight; + half = (0x80000000 + height - 1) / height; } explicit operator bool() @@ -1417,7 +1418,7 @@ public: int sample_index() { - return frac >> bits; + return ((frac >> FRACBITS) * height) >> FRACBITS; } bool next() @@ -1435,12 +1436,11 @@ public: BYTE * RESTRICT _dest; int _count; int _pitch; - int _vlinebits; - uint32_t _vlinemax; ShadeConstants _shade_constants; uint32_t _vplce[4]; uint32_t _vince[4]; uint32_t _buftexturefracx[4]; + uint32_t _bufheight[4]; const uint32_t * RESTRICT _bufplce[4]; const uint32_t * RESTRICT _bufplce2[4]; uint32_t _light[4]; @@ -1448,19 +1448,18 @@ public: uint32_t _srcalpha; uint32_t _destalpha; - DrawerWall4Command(int vlinebits, uint32_t vlinemax) + DrawerWall4Command() { _dest = dc_dest; _count = dc_count; _pitch = dc_pitch; - _vlinebits = vlinebits; - _vlinemax = vlinemax; _shade_constants = dc_shade_constants; for (int i = 0; i < 4; i++) { _vplce[i] = vplce[i]; _vince[i] = vince[i]; _buftexturefracx[i] = buftexturefracx[i]; + _bufheight[i] = bufheight[i]; _bufplce[i] = (const uint32_t *)bufplce[i]; _bufplce2[i] = (const uint32_t *)bufplce2[i]; _light[i] = LightBgra::calc_light_multiplier(palookuplight[i]); @@ -1475,9 +1474,10 @@ public: uint32_t *dest; int pitch; int count; - int bits; uint32_t vplce[4]; uint32_t vince[4]; + uint32_t height[4]; + uint32_t half[4]; LoopIterator(DrawerWall4Command *command, DrawerThread *thread) { @@ -1487,13 +1487,14 @@ public: dest = thread->dest_for_thread(command->_dest_y, command->_pitch, (uint32_t*)command->_dest); pitch = command->_pitch * thread->num_cores; - bits = command->_vlinebits; int skipped = thread->skipped_by_thread(command->_dest_y); for (int i = 0; i < 4; i++) { vplce[i] = command->_vplce[i] + command->_vince[i] * skipped; vince[i] = command->_vince[i] * thread->num_cores; + height[i] = command->_bufheight[i]; + half[i] = (0x80000000 + height[i] - 1) / height[i]; } } @@ -1504,7 +1505,7 @@ public: int sample_index(int col) { - return vplce[col] >> bits; + return ((vplce[col] >> FRACBITS) * height[col]) >> FRACBITS; } bool next() @@ -1522,10 +1523,6 @@ public: class Vlinec1RGBACommand : public DrawerWall1Command { public: - Vlinec1RGBACommand() : DrawerWall1Command(vlinebits, vlinemax) - { - } - void Execute(DrawerThread *thread) override { LoopIterator loop(this, thread); @@ -1543,7 +1540,7 @@ public: { do { - uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, _source2, loop.texturefracx, loop.frac, loop.bits, _vlinemax), _light, _shade_constants); + uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, _source2, loop.texturefracx, loop.frac, loop.half, loop.height), _light, _shade_constants); *loop.dest = BlendBgra::copy(fg); } while (loop.next()); } @@ -1553,10 +1550,6 @@ public: class Vlinec4RGBACommand : public DrawerWall4Command { public: - Vlinec4RGBACommand() : DrawerWall4Command(vlinebits, vlinemax) - { - } - void Execute(DrawerThread *thread) override { LoopIterator loop(this, thread); @@ -1579,7 +1572,7 @@ public: { for (int i = 0; i < 4; i++) { - uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_bufplce[i], _bufplce2[i], _buftexturefracx[i], loop.sample_index(i), loop.bits, _vlinemax), _light[i], _shade_constants); + uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_bufplce[i], _bufplce2[i], _buftexturefracx[i], loop.sample_index(i), loop.half[i], loop.height[i]), _light[i], _shade_constants); loop.dest[i] = BlendBgra::copy(fg); } } while (loop.next()); @@ -1590,10 +1583,6 @@ public: class Mvlinec1RGBACommand : public DrawerWall1Command { public: - Mvlinec1RGBACommand() : DrawerWall1Command(mvlinebits, mvlinemax) - { - } - void Execute(DrawerThread *thread) override { LoopIterator loop(this, thread); @@ -1611,7 +1600,7 @@ public: { do { - uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, _source2, loop.texturefracx, loop.frac, loop.bits, _vlinemax), _light, _shade_constants); + uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, _source2, loop.texturefracx, loop.frac, loop.half, loop.height), _light, _shade_constants); *loop.dest = BlendBgra::alpha_blend(fg, *loop.dest); } while (loop.next()); } @@ -1621,10 +1610,6 @@ public: class Mvlinec4RGBACommand : public DrawerWall4Command { public: - Mvlinec4RGBACommand(): DrawerWall4Command(mvlinebits, mvlinemax) - { - } - void Execute(DrawerThread *thread) override { LoopIterator loop(this, thread); @@ -1647,7 +1632,7 @@ public: { for (int i = 0; i < 4; i++) { - uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_bufplce[i], _bufplce2[i], _buftexturefracx[i], loop.sample_index(i), loop.bits, _vlinemax), _light[i], _shade_constants); + uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_bufplce[i], _bufplce2[i], _buftexturefracx[i], loop.sample_index(i), loop.half[i], loop.height[i]), _light[i], _shade_constants); loop.dest[i] = BlendBgra::alpha_blend(fg, loop.dest[i]); } } while (loop.next()); @@ -1658,10 +1643,6 @@ public: class Tmvline1AddRGBACommand : public DrawerWall1Command { public: - Tmvline1AddRGBACommand() : DrawerWall1Command(tmvlinebits, tmvlinemax) - { - } - void Execute(DrawerThread *thread) override { LoopIterator loop(this, thread); @@ -1677,10 +1658,6 @@ public: class Tmvline4AddRGBACommand : public DrawerWall4Command { public: - Tmvline4AddRGBACommand() : DrawerWall4Command(tmvlinebits, tmvlinemax) - { - } - void Execute(DrawerThread *thread) override { LoopIterator loop(this, thread); @@ -1699,10 +1676,6 @@ public: class Tmvline1AddClampRGBACommand : public DrawerWall1Command { public: - Tmvline1AddClampRGBACommand() : DrawerWall1Command(tmvlinebits, tmvlinemax) - { - } - void Execute(DrawerThread *thread) override { LoopIterator loop(this, thread); @@ -1718,10 +1691,6 @@ public: class Tmvline4AddClampRGBACommand : public DrawerWall4Command { public: - Tmvline4AddClampRGBACommand() : DrawerWall4Command(tmvlinebits, tmvlinemax) - { - } - void Execute(DrawerThread *thread) override { LoopIterator loop(this, thread); @@ -1740,10 +1709,6 @@ public: class Tmvline1SubClampRGBACommand : public DrawerWall1Command { public: - Tmvline1SubClampRGBACommand() : DrawerWall1Command(tmvlinebits, tmvlinemax) - { - } - void Execute(DrawerThread *thread) override { LoopIterator loop(this, thread); @@ -1759,10 +1724,6 @@ public: class Tmvline4SubClampRGBACommand : public DrawerWall4Command { public: - Tmvline4SubClampRGBACommand() : DrawerWall4Command(tmvlinebits, tmvlinemax) - { - } - void Execute(DrawerThread *thread) override { LoopIterator loop(this, thread); @@ -1781,10 +1742,6 @@ public: class Tmvline1RevSubClampRGBACommand : public DrawerWall1Command { public: - Tmvline1RevSubClampRGBACommand() : DrawerWall1Command(tmvlinebits, tmvlinemax) - { - } - void Execute(DrawerThread *thread) override { LoopIterator loop(this, thread); @@ -1800,10 +1757,6 @@ public: class Tmvline4RevSubClampRGBACommand : public DrawerWall4Command { public: - Tmvline4RevSubClampRGBACommand() : DrawerWall4Command(tmvlinebits, tmvlinemax) - { - } - void Execute(DrawerThread *thread) override { LoopIterator loop(this, thread); @@ -2362,17 +2315,8 @@ void R_DrawSlab_rgba(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BY DrawerCommandQueue::QueueCommand(dx, v, dy, vi, vptr, p, slab_rgba_shade_constants, slab_rgba_colormap, slab_rgba_light); } -//extern FTexture *rw_pic; // For the asserts below - DWORD vlinec1_rgba() { - /*DWORD fracstep = dc_iscale; - DWORD frac = dc_texturefrac; - DWORD height = rw_pic->GetHeight(); - assert((frac >> vlinebits) < height); - frac += (dc_count-1) * fracstep; - assert((frac >> vlinebits) <= height);*/ - DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 56f1faa24..a60fd65c7 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -459,7 +459,7 @@ public: class SampleBgra { public: - inline static bool span_sampler_setup(const uint32_t * RESTRICT &source, int &xbits, int &ybits, fixed_t xstep, fixed_t ystep) + inline static bool span_sampler_setup(const uint32_t * RESTRICT &source, int &xbits, int &ybits, fixed_t xstep, fixed_t ystep, bool mipmapped) { // Is this a magfilter or minfilter? fixed_t xmagnitude = abs(xstep) >> (32 - xbits - FRACBITS); @@ -467,7 +467,7 @@ public: fixed_t magnitude = (xmagnitude + ymagnitude) * 2 + (1 << (FRACBITS - 1)); bool magnifying = (magnitude >> FRACBITS == 0); - if (r_mipmap) + if (r_mipmap && mipmapped) { int level = magnitude >> (FRACBITS + 1); while (level != 0) @@ -482,18 +482,15 @@ public: } } - return (magnifying && r_magfilter_linear) || (!magnifying && r_minfilter_linear); + return (magnifying && r_magfilter) || (!magnifying && r_minfilter); } - FORCEINLINE static uint32_t sample_bilinear(const uint32_t *col0, const uint32_t *col1, uint32_t texturefracx, uint32_t texturefracy, int ybits, uint32_t ymax) + FORCEINLINE static uint32_t sample_bilinear(const uint32_t *col0, const uint32_t *col1, uint32_t texturefracx, uint32_t texturefracy, uint32_t half, uint32_t height) { - uint32_t half = 1 << (ybits - 1); - uint32_t y0 = (texturefracy - half) >> ybits; - if (y0 > ymax) - y0 = 0; - uint32_t y1 = y0 + 1; - if (y1 > ymax) - y1 = 0; + uint32_t frac_y0 = ((texturefracy - half) >> FRACBITS) * height; + uint32_t frac_y1 = ((texturefracy + half) >> FRACBITS) * height; + uint32_t y0 = frac_y0 >> FRACBITS; + uint32_t y1 = frac_y1 >> FRACBITS; uint32_t p00 = col0[y0]; uint32_t p01 = col0[y1]; @@ -501,7 +498,7 @@ public: uint32_t p11 = col1[y1]; uint32_t inv_b = texturefracx; - uint32_t inv_a = ((texturefracy + half) >> (ybits - 4)) & 15; + uint32_t inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; uint32_t a = 16 - inv_a; uint32_t b = 16 - inv_b; @@ -546,20 +543,18 @@ public: ///////////////////////////////////////////////////////////////////////////// // SSE/AVX shading macros: -#define VEC_SAMPLE_BILINEAR4_COLUMN(fg, col0, col1, texturefracx, texturefracy, ybits, ymax) { \ - uint32_t half = 1 << (ybits - 1); \ - \ +#define VEC_SAMPLE_BILINEAR4_COLUMN(fg, col0, col1, texturefracx, texturefracy, half, height) { \ __m128i m127 = _mm_set1_epi16(127); \ fg = _mm_setzero_si128(); \ for (int i = 0; i < 4; i++) \ { \ - uint32_t y0 = (texturefracy[i] - half) >> ybits; \ - if (y0 > ymax) y0 = 0; \ - uint32_t y1 = y0 + 1; \ - if (y1 > ymax) y1 = 0; \ + uint32_t frac_y0 = ((texturefracy[i] - half[i]) >> FRACBITS) * height[i]; \ + uint32_t frac_y1 = ((texturefracy[i] + half[i]) >> FRACBITS) * height[i]; \ + uint32_t y0 = frac_y0 >> FRACBITS; \ + uint32_t y1 = frac_y1 >> FRACBITS; \ \ uint32_t inv_b = texturefracx[i]; \ - uint32_t inv_a = ((texturefracy[i] + half) >> (ybits - 4)) & 15; \ + uint32_t inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; \ uint32_t a = 16 - inv_a; \ uint32_t b = 16 - inv_b; \ \ diff --git a/src/r_draw_rgba_sse.h b/src/r_draw_rgba_sse.h index bca30185c..ae8d3bf42 100644 --- a/src/r_draw_rgba_sse.h +++ b/src/r_draw_rgba_sse.h @@ -43,7 +43,7 @@ public: _destorg = dc_destorg; _light = ds_light; _shade_constants = ds_shade_constants; - _nearest_filter = !SampleBgra::span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep); + _nearest_filter = !SampleBgra::span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep, ds_source_mipmapped); } void Execute(DrawerThread *thread) override @@ -364,14 +364,13 @@ class VecCommand(Vlinec4RGBA) : public DrawerCommand int _count; int _pitch; ShadeConstants _shade_constants; - int _vlinebits; - uint32_t _vlinemax; fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; const uint32 * RESTRICT bufplce[4]; const uint32_t * RESTRICT bufplce2[4]; uint32_t buftexturefracx[4]; + uint32_t bufheight[4]; public: VecCommand(Vlinec4RGBA)() @@ -380,8 +379,6 @@ public: _count = dc_count; _pitch = dc_pitch; _shade_constants = dc_shade_constants; - _vlinebits = vlinebits; - _vlinemax = vlinemax; for (int i = 0; i < 4; i++) { palookuplight[i] = ::palookuplight[i]; @@ -390,6 +387,7 @@ public: bufplce[i] = (const uint32 *)::bufplce[i]; bufplce2[i] = (const uint32_t *)::bufplce2[i]; buftexturefracx[i] = ::buftexturefracx[i]; + bufheight[i] = ::bufheight[i]; } } @@ -400,9 +398,16 @@ public: return; uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int bits = _vlinebits; int pitch = _pitch * thread->num_cores; + uint32_t height[4]; + uint32_t half[4]; + for (int i = 0; i < 4; i++) + { + height[i] = bufheight[i]; + half[i] = (0x80000000 + height[i] - 1) / height[i]; + } + uint32_t light0 = LightBgra::calc_light_multiplier(palookuplight[0]); uint32_t light1 = LightBgra::calc_light_multiplier(palookuplight[1]); uint32_t light2 = LightBgra::calc_light_multiplier(palookuplight[2]); @@ -431,10 +436,10 @@ public: DWORD place2 = local_vplce[2]; DWORD place3 = local_vplce[3]; - uint32_t p0 = bufplce[0][place0 >> bits]; - uint32_t p1 = bufplce[1][place1 >> bits]; - uint32_t p2 = bufplce[2][place2 >> bits]; - uint32_t p3 = bufplce[3][place3 >> bits]; + uint32_t p0 = bufplce[0][((place0 >> FRACBITS) * height[0]) >> FRACBITS]; + uint32_t p1 = bufplce[1][((place1 >> FRACBITS) * height[1]) >> FRACBITS]; + uint32_t p2 = bufplce[2][((place2 >> FRACBITS) * height[2]) >> FRACBITS]; + uint32_t p3 = bufplce[3][((place3 >> FRACBITS) * height[3]) >> FRACBITS]; local_vplce[0] = place0 + local_vince[0]; local_vplce[1] = place1 + local_vince[1]; @@ -457,10 +462,10 @@ public: DWORD place2 = local_vplce[2]; DWORD place3 = local_vplce[3]; - uint32_t p0 = bufplce[0][place0 >> bits]; - uint32_t p1 = bufplce[1][place1 >> bits]; - uint32_t p2 = bufplce[2][place2 >> bits]; - uint32_t p3 = bufplce[3][place3 >> bits]; + uint32_t p0 = bufplce[0][((place0 >> FRACBITS) * height[0]) >> FRACBITS]; + uint32_t p1 = bufplce[1][((place1 >> FRACBITS) * height[1]) >> FRACBITS]; + uint32_t p2 = bufplce[2][((place2 >> FRACBITS) * height[2]) >> FRACBITS]; + uint32_t p3 = bufplce[3][((place3 >> FRACBITS) * height[3]) >> FRACBITS]; local_vplce[0] = place0 + local_vince[0]; local_vplce[1] = place1 + local_vince[1]; @@ -482,7 +487,7 @@ public: do { __m128i fg; - VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits, _vlinemax); + VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, half, height); local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -500,7 +505,7 @@ public: do { __m128i fg; - VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits, _vlinemax); + VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, half, height); local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -522,7 +527,6 @@ class VecCommand(Mvlinec4RGBA) : public DrawerCommand int _count; int _pitch; ShadeConstants _shade_constants; - int _mvlinebits; uint32_t _mvlinemax; fixed_t palookuplight[4]; DWORD vplce[4]; @@ -530,6 +534,7 @@ class VecCommand(Mvlinec4RGBA) : public DrawerCommand const uint32 * RESTRICT bufplce[4]; const uint32 * RESTRICT bufplce2[4]; uint32_t buftexturefracx[4]; + uint32_t bufheight[4]; public: VecCommand(Mvlinec4RGBA)() @@ -538,8 +543,6 @@ public: _count = dc_count; _pitch = dc_pitch; _shade_constants = dc_shade_constants; - _mvlinebits = mvlinebits; - _mvlinemax = mvlinemax; for (int i = 0; i < 4; i++) { palookuplight[i] = ::palookuplight[i]; @@ -548,6 +551,7 @@ public: bufplce[i] = (const uint32 *)::bufplce[i]; bufplce2[i] = (const uint32_t *)::bufplce2[i]; buftexturefracx[i] = ::buftexturefracx[i]; + bufheight[i] = ::bufheight[i]; } } @@ -559,7 +563,13 @@ public: uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int pitch = _pitch * thread->num_cores; - int bits = _mvlinebits; + uint32_t height[4]; + uint32_t half[4]; + for (int i = 0; i < 4; i++) + { + height[i] = bufheight[i]; + half[i] = (0x80000000 + height[i] - 1) / height[i]; + } uint32_t light0 = LightBgra::calc_light_multiplier(palookuplight[0]); uint32_t light1 = LightBgra::calc_light_multiplier(palookuplight[1]); @@ -589,10 +599,10 @@ public: DWORD place2 = local_vplce[2]; DWORD place3 = local_vplce[3]; - uint32_t pix0 = bufplce[0][place0 >> bits]; - uint32_t pix1 = bufplce[1][place1 >> bits]; - uint32_t pix2 = bufplce[2][place2 >> bits]; - uint32_t pix3 = bufplce[3][place3 >> bits]; + uint32_t pix0 = bufplce[0][((place0 >> FRACBITS) * height[0]) >> FRACBITS]; + uint32_t pix1 = bufplce[1][((place1 >> FRACBITS) * height[1]) >> FRACBITS]; + uint32_t pix2 = bufplce[2][((place2 >> FRACBITS) * height[2]) >> FRACBITS]; + uint32_t pix3 = bufplce[3][((place3 >> FRACBITS) * height[3]) >> FRACBITS]; local_vplce[0] = place0 + local_vince[0]; local_vplce[1] = place1 + local_vince[1]; @@ -617,10 +627,10 @@ public: DWORD place2 = local_vplce[2]; DWORD place3 = local_vplce[3]; - uint32_t pix0 = bufplce[0][place0 >> bits]; - uint32_t pix1 = bufplce[1][place1 >> bits]; - uint32_t pix2 = bufplce[2][place2 >> bits]; - uint32_t pix3 = bufplce[3][place3 >> bits]; + uint32_t pix0 = bufplce[0][((place0 >> FRACBITS) * height[0]) >> FRACBITS]; + uint32_t pix1 = bufplce[1][((place1 >> FRACBITS) * height[1]) >> FRACBITS]; + uint32_t pix2 = bufplce[2][((place2 >> FRACBITS) * height[2]) >> FRACBITS]; + uint32_t pix3 = bufplce[3][((place3 >> FRACBITS) * height[3]) >> FRACBITS]; local_vplce[0] = place0 + local_vince[0]; local_vplce[1] = place1 + local_vince[1]; @@ -644,7 +654,7 @@ public: do { __m128i fg; - VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits, _mvlinemax); + VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, half, height); local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -664,7 +674,7 @@ public: do { __m128i fg; - VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, bits, _mvlinemax); + VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, half, height); local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -690,12 +700,11 @@ class VecCommand(Tmvline4AddRGBA) : public DrawerCommand ShadeConstants _shade_constants; fixed_t _srcalpha; fixed_t _destalpha; - int _tmvlinebits; - uint32_t _tmvlinemax; fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; const uint32 * RESTRICT bufplce[4]; + uint32_t bufheight[4]; public: VecCommand(Tmvline4AddRGBA)() @@ -706,14 +715,13 @@ public: _shade_constants = dc_shade_constants; _srcalpha = dc_srcalpha; _destalpha = dc_destalpha; - _tmvlinebits = tmvlinebits; - _tmvlinemax = tmvlinemax; for (int i = 0; i < 4; i++) { palookuplight[i] = ::palookuplight[i]; vplce[i] = ::vplce[i]; vince[i] = ::vince[i]; bufplce[i] = (const uint32 *)::bufplce[i]; + bufheight[i] = ::bufheight[i]; } } @@ -725,7 +733,14 @@ public: uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int pitch = _pitch * thread->num_cores; - int bits = _tmvlinebits; + + uint32_t height[4]; + uint32_t half[4]; + for (int i = 0; i < 4; i++) + { + height[i] = bufheight[i]; + half[i] = (0x80000000 + height[i] - 1) / height[i]; + } uint32_t light[4]; light[0] = LightBgra::calc_light_multiplier(palookuplight[0]); @@ -754,10 +769,10 @@ public: do { - uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; - uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; - uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; - uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; + uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; + uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; + uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -791,10 +806,10 @@ public: do { - uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; - uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; - uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; - uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; + uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; + uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; + uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -831,12 +846,11 @@ class VecCommand(Tmvline4AddClampRGBA) : public DrawerCommand ShadeConstants _shade_constants; fixed_t _srcalpha; fixed_t _destalpha; - int _tmvlinebits; - uint32_t _tmvlinemax; fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; const uint32 *RESTRICT bufplce[4]; + uint32_t bufheight[4]; public: VecCommand(Tmvline4AddClampRGBA)() @@ -847,14 +861,13 @@ public: _shade_constants = dc_shade_constants; _srcalpha = dc_srcalpha; _destalpha = dc_destalpha; - _tmvlinebits = tmvlinebits; - _tmvlinemax = tmvlinemax; for (int i = 0; i < 4; i++) { palookuplight[i] = ::palookuplight[i]; vplce[i] = ::vplce[i]; vince[i] = ::vince[i]; bufplce[i] = (const uint32 *)::bufplce[i]; + bufheight[i] = ::bufheight[i]; } } @@ -866,7 +879,14 @@ public: uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int pitch = _pitch * thread->num_cores; - int bits = _tmvlinebits; + + uint32_t height[4]; + uint32_t half[4]; + for (int i = 0; i < 4; i++) + { + height[i] = bufheight[i]; + half[i] = (0x80000000 + height[i] - 1) / height[i]; + } uint32_t light[4]; light[0] = LightBgra::calc_light_multiplier(palookuplight[0]); @@ -895,10 +915,10 @@ public: do { - uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; - uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; - uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; - uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; + uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; + uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; + uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -931,10 +951,10 @@ public: do { - uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; - uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; - uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; - uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; + uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; + uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; + uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -971,12 +991,11 @@ class VecCommand(Tmvline4SubClampRGBA) : public DrawerCommand ShadeConstants _shade_constants; fixed_t _srcalpha; fixed_t _destalpha; - int _tmvlinebits; - uint32_t _tmvlinemax; fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; const uint32 *RESTRICT bufplce[4]; + uint32_t bufheight[4]; public: VecCommand(Tmvline4SubClampRGBA)() @@ -987,14 +1006,13 @@ public: _shade_constants = dc_shade_constants; _srcalpha = dc_srcalpha; _destalpha = dc_destalpha; - _tmvlinebits = tmvlinebits; - _tmvlinemax = tmvlinemax; for (int i = 0; i < 4; i++) { palookuplight[i] = ::palookuplight[i]; vplce[i] = ::vplce[i]; vince[i] = ::vince[i]; bufplce[i] = (const uint32 *)::bufplce[i]; + bufheight[i] = ::bufheight[i]; } } @@ -1006,7 +1024,14 @@ public: uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int pitch = _pitch * thread->num_cores; - int bits = _tmvlinebits; + + uint32_t height[4]; + uint32_t half[4]; + for (int i = 0; i < 4; i++) + { + height[i] = bufheight[i]; + half[i] = (0x80000000 + height[i] - 1) / height[i]; + } uint32_t light[4]; light[0] = LightBgra::calc_light_multiplier(palookuplight[0]); @@ -1035,10 +1060,10 @@ public: do { - uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; - uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; - uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; - uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; + uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; + uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; + uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -1071,10 +1096,10 @@ public: do { - uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; - uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; - uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; - uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; + uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; + uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; + uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -1111,12 +1136,11 @@ class VecCommand(Tmvline4RevSubClampRGBA) : public DrawerCommand ShadeConstants _shade_constants; fixed_t _srcalpha; fixed_t _destalpha; - int _tmvlinebits; - uint32_t _tmvlinemax; fixed_t palookuplight[4]; DWORD vplce[4]; DWORD vince[4]; const uint32 *RESTRICT bufplce[4]; + uint32_t bufheight[4]; public: VecCommand(Tmvline4RevSubClampRGBA)() @@ -1127,14 +1151,13 @@ public: _shade_constants = dc_shade_constants; _srcalpha = dc_srcalpha; _destalpha = dc_destalpha; - _tmvlinebits = tmvlinebits; - _tmvlinemax = tmvlinemax; for (int i = 0; i < 4; i++) { palookuplight[i] = ::palookuplight[i]; vplce[i] = ::vplce[i]; vince[i] = ::vince[i]; bufplce[i] = (const uint32 *)::bufplce[i]; + bufheight[i] = ::bufheight[4]; } } @@ -1146,7 +1169,14 @@ public: uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); int pitch = _pitch * thread->num_cores; - int bits = _tmvlinebits; + + uint32_t height[4]; + uint32_t half[4]; + for (int i = 0; i < 4; i++) + { + height[i] = bufheight[i]; + half[i] = (0x80000000 + height[i] - 1) / height[i]; + } uint32_t light[4]; light[0] = LightBgra::calc_light_multiplier(palookuplight[0]); @@ -1175,10 +1205,10 @@ public: do { - uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; - uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; - uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; - uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; + uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; + uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; + uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; @@ -1211,10 +1241,10 @@ public: do { - uint32_t pix0 = bufplce[0][local_vplce[0] >> bits]; - uint32_t pix1 = bufplce[1][local_vplce[1] >> bits]; - uint32_t pix2 = bufplce[2][local_vplce[2] >> bits]; - uint32_t pix3 = bufplce[3][local_vplce[3] >> bits]; + uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; + uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; + uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; + uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; local_vplce[0] = local_vplce[0] + local_vince[0]; local_vplce[1] = local_vplce[1] + local_vince[1]; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 5c9037375..630d64da0 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1075,86 +1075,112 @@ struct WallscanSampler uint32_t uv_pos; uint32_t uv_step; - int32_t uv_fracbits; uint32_t uv_max; const BYTE *source; const BYTE *source2; uint32_t texturefracx; + uint32_t height; }; WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)) { - int base_width = texture->GetWidth(); - int base_height = texture->GetHeight(); - uv_fracbits = 32 - texture->HeightBits; - uv_max = base_height << uv_fracbits; - - // Find start uv in [0-base_height[ range. - // Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range. - double uv_stepd = swal * yrepeat; - double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / base_height; - v = v - floor(v); - v *= base_height; - v *= (1 << uv_fracbits); - - uv_pos = (uint32_t)v; - uv_step = xs_ToFixed(uv_fracbits, uv_stepd); - - bool magnifying = uv_step >> (uv_fracbits - 1) == 0; - - if (!r_swtruecolor || getcol != R_GetColumn) + if (!r_swtruecolor) { + height = texture->GetHeight(); + int uv_fracbits = 32 - texture->HeightBits; + uv_max = height << uv_fracbits; + + // Find start uv in [0-base_height[ range. + // Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range. + double uv_stepd = swal * yrepeat; + double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / height; + v = v - floor(v); + v *= height; + v *= (1 << uv_fracbits); + + uv_pos = (uint32_t)v; + uv_step = xs_ToFixed(uv_fracbits, uv_stepd); + if (uv_step == 0) // To prevent divide by zero elsewhere + uv_step = 1; + source = getcol(texture, xoffset >> FRACBITS); source2 = nullptr; texturefracx = 0; } else { - int mipmap_offset = 0; - int mip_width = base_width; - int mip_height = base_height; - if (r_mipmap) - { - fixed_t magnitude = abs((int32_t)uv_step) >> (uv_fracbits - FRACBITS); - int level = magnitude >> FRACBITS; - while (level != 0) - { - if (uv_fracbits > 30) - break; + // Normalize to 0-1 range: + double uv_stepd = swal * yrepeat; + double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / texture->GetHeight(); + v = v - floor(v); + double v_step = uv_stepd / texture->GetHeight(); - mipmap_offset += mip_width * mip_height; - uv_fracbits += 1; - uv_pos >>= 1; - uv_step >>= 1; - xoffset >>= 1; - level >>= 1; - mip_width = MAX(mip_width >> 1, 1); - mip_height = MAX(mip_height >> 1, 1); - } + if (isnan(v) || isnan(v_step)) // this should never happen, but it apparently does.. + { + uv_stepd = 0.0; + v = 0.0; + v_step = 0.0; } - const uint32_t *pixels = texture->GetPixelsBgra() + mipmap_offset; + // Convert to uint32: + uv_pos = (uint32_t)(v * 0x100000000LL); + uv_step = (uint32_t)(v_step * 0x100000000LL); + uv_max = 0; - bool filter_nearest = (magnifying && !r_magfilter_linear) || (!magnifying && !r_minfilter_linear); - if (filter_nearest) + // Texture mipmap and filter selection: + if (getcol != R_GetColumn) { - int tx = (xoffset >> FRACBITS) % mip_width; - if (tx < 0) - tx += mip_width; - source = (BYTE*)(pixels + tx * mip_height); + source = getcol(texture, xoffset >> FRACBITS); source2 = nullptr; + height = texture->GetHeight(); texturefracx = 0; } else { - int tx0 = ((xoffset - FRACUNIT / 2) >> FRACBITS) % mip_width; - if (tx0 < 0) - tx0 += mip_width; - int tx1 = (tx0 + 1) % mip_width; - source = (BYTE*)(pixels + tx0 * mip_height); - source2 = (BYTE*)(pixels + tx1 * mip_height); - texturefracx = ((xoffset + FRACUNIT / 2) >> (FRACBITS - 4)) & 15; + double magnitude = abs(uv_stepd * 2); + bool magnifying = magnitude < 1.0f; + + int mipmap_offset = 0; + int mip_width = texture->GetWidth(); + int mip_height = texture->GetHeight(); + if (r_mipmap && texture->Mipmapped()) + { + int level = (int)MAX(magnitude - 1.0, 0.0); + while (level != 0) + { + mipmap_offset += mip_width * mip_height; + xoffset >>= 1; + level >>= 1; + mip_width = MAX(mip_width >> 1, 1); + mip_height = MAX(mip_height >> 1, 1); + } + } + + const uint32_t *pixels = texture->GetPixelsBgra() + mipmap_offset; + + bool filter_nearest = (magnifying && !r_magfilter) || (!magnifying && !r_minfilter); + if (filter_nearest) + { + int tx = (xoffset >> FRACBITS) % mip_width; + if (tx < 0) + tx += mip_width; + source = (BYTE*)(pixels + tx * mip_height); + source2 = nullptr; + height = mip_height; + texturefracx = 0; + } + else + { + int tx0 = ((xoffset - FRACUNIT / 2) >> FRACBITS) % mip_width; + if (tx0 < 0) + tx0 += mip_width; + int tx1 = (tx0 + 1) % mip_width; + source = (BYTE*)(pixels + tx0 * mip_height); + source2 = (BYTE*)(pixels + tx1 * mip_height); + height = mip_height; + texturefracx = ((xoffset + FRACUNIT / 2) >> (FRACBITS - 4)) & 15; + } } } } @@ -1162,18 +1188,18 @@ WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xof // Draw a column with support for non-power-of-two ranges void wallscan_drawcol1(int x, int y1, int y2, WallscanSampler &sampler, DWORD(*draw1column)()) { - int pixelsize = r_swtruecolor ? 4 : 1; - if (sampler.uv_max == 0) // power of two + if (r_swtruecolor) { int count = y2 - y1; dc_source = sampler.source; dc_source2 = sampler.source2; dc_texturefracx = sampler.texturefracx; - dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; + dc_dest = (ylookup[y1] + x) * 4 + dc_destorg; dc_count = count; dc_iscale = sampler.uv_step; dc_texturefrac = sampler.uv_pos; + dc_textureheight = sampler.height; draw1column(); uint64_t step64 = sampler.uv_step; @@ -1182,41 +1208,60 @@ void wallscan_drawcol1(int x, int y1, int y2, WallscanSampler &sampler, DWORD(*d } else { - uint32_t uv_pos = sampler.uv_pos; - - uint32_t left = y2 - y1; - while (left > 0) + if (sampler.uv_max == 0) // power of two { - uint32_t available = sampler.uv_max - uv_pos; - uint32_t next_uv_wrap = available / sampler.uv_step; - if (available % sampler.uv_step != 0) - next_uv_wrap++; - uint32_t count = MIN(left, next_uv_wrap); + int count = y2 - y1; dc_source = sampler.source; dc_source2 = sampler.source2; dc_texturefracx = sampler.texturefracx; - dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; + dc_dest = (ylookup[y1] + x) + dc_destorg; dc_count = count; dc_iscale = sampler.uv_step; - dc_texturefrac = uv_pos; + dc_texturefrac = sampler.uv_pos; draw1column(); - left -= count; - uv_pos += sampler.uv_step * count; - if (uv_pos >= sampler.uv_max) - uv_pos -= sampler.uv_max; + uint64_t step64 = sampler.uv_step; + uint64_t pos64 = sampler.uv_pos; + sampler.uv_pos = (uint32_t)(pos64 + step64 * count); } + else + { + uint32_t uv_pos = sampler.uv_pos; - sampler.uv_pos = uv_pos; + uint32_t left = y2 - y1; + while (left > 0) + { + uint32_t available = sampler.uv_max - uv_pos; + uint32_t next_uv_wrap = available / sampler.uv_step; + if (available % sampler.uv_step != 0) + next_uv_wrap++; + uint32_t count = MIN(left, next_uv_wrap); + + dc_source = sampler.source; + dc_source2 = sampler.source2; + dc_texturefracx = sampler.texturefracx; + dc_dest = (ylookup[y1] + x) + dc_destorg; + dc_count = count; + dc_iscale = sampler.uv_step; + dc_texturefrac = uv_pos; + draw1column(); + + left -= count; + uv_pos += sampler.uv_step * count; + if (uv_pos >= sampler.uv_max) + uv_pos -= sampler.uv_max; + } + + sampler.uv_pos = uv_pos; + } } } // Draw four columns with support for non-power-of-two ranges void wallscan_drawcol4(int x, int y1, int y2, WallscanSampler *sampler, void(*draw4columns)()) { - int pixelsize = r_swtruecolor ? 4 : 1; - if (sampler[0].uv_max == 0) // power of two, no wrap handling needed + if (r_swtruecolor) { int count = y2 - y1; for (int i = 0; i < 4; i++) @@ -1224,6 +1269,7 @@ void wallscan_drawcol4(int x, int y1, int y2, WallscanSampler *sampler, void(*dr bufplce[i] = sampler[i].source; bufplce2[i] = sampler[i].source2; buftexturefracx[i] = sampler[i].texturefracx; + bufheight[i] = sampler[i].height; vplce[i] = sampler[i].uv_pos; vince[i] = sampler[i].uv_step; @@ -1231,52 +1277,74 @@ void wallscan_drawcol4(int x, int y1, int y2, WallscanSampler *sampler, void(*dr uint64_t pos64 = sampler[i].uv_pos; sampler[i].uv_pos = (uint32_t)(pos64 + step64 * count); } - dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; + dc_dest = (ylookup[y1] + x) * 4 + dc_destorg; dc_count = count; draw4columns(); } else { - dc_dest = (ylookup[y1] + x) * pixelsize + dc_destorg; - for (int i = 0; i < 4; i++) + if (sampler[0].uv_max == 0) // power of two, no wrap handling needed { - bufplce[i] = sampler[i].source; - bufplce2[i] = sampler[i].source2; - buftexturefracx[i] = sampler[i].texturefracx; - } - - uint32_t left = y2 - y1; - while (left > 0) - { - // Find which column wraps first - uint32_t count = left; - for (int i = 0; i < 4; i++) - { - uint32_t available = sampler[i].uv_max - sampler[i].uv_pos; - uint32_t next_uv_wrap = available / sampler[i].uv_step; - if (available % sampler[i].uv_step != 0) - next_uv_wrap++; - count = MIN(next_uv_wrap, count); - } - - // Draw until that column wraps + int count = y2 - y1; for (int i = 0; i < 4; i++) { + bufplce[i] = sampler[i].source; + bufplce2[i] = sampler[i].source2; + buftexturefracx[i] = sampler[i].texturefracx; vplce[i] = sampler[i].uv_pos; vince[i] = sampler[i].uv_step; + + uint64_t step64 = sampler[i].uv_step; + uint64_t pos64 = sampler[i].uv_pos; + sampler[i].uv_pos = (uint32_t)(pos64 + step64 * count); } + dc_dest = (ylookup[y1] + x) + dc_destorg; dc_count = count; draw4columns(); - - // Wrap the uv position + } + else + { + dc_dest = (ylookup[y1] + x) + dc_destorg; for (int i = 0; i < 4; i++) { - sampler[i].uv_pos += sampler[i].uv_step * count; - if (sampler[i].uv_pos >= sampler[i].uv_max) - sampler[i].uv_pos -= sampler[i].uv_max; + bufplce[i] = sampler[i].source; + bufplce2[i] = sampler[i].source2; + buftexturefracx[i] = sampler[i].texturefracx; } - left -= count; + uint32_t left = y2 - y1; + while (left > 0) + { + // Find which column wraps first + uint32_t count = left; + for (int i = 0; i < 4; i++) + { + uint32_t available = sampler[i].uv_max - sampler[i].uv_pos; + uint32_t next_uv_wrap = available / sampler[i].uv_step; + if (available % sampler[i].uv_step != 0) + next_uv_wrap++; + count = MIN(next_uv_wrap, count); + } + + // Draw until that column wraps + for (int i = 0; i < 4; i++) + { + vplce[i] = sampler[i].uv_pos; + vince[i] = sampler[i].uv_step; + } + dc_count = count; + draw4columns(); + + // Wrap the uv position + for (int i = 0; i < 4; i++) + { + sampler[i].uv_pos += sampler[i].uv_step * count; + if (sampler[i].uv_pos >= sampler[i].uv_max) + sampler[i].uv_pos -= sampler[i].uv_max; + } + + left -= count; + } } } } @@ -1287,7 +1355,7 @@ typedef void(*Draw4ColumnsFuncPtr)(); void wallscan_any( int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x), - void(setupwallscan(int bits, int fracmax, Draw1ColumnFuncPtr &draw1, Draw4ColumnsFuncPtr &draw2))) + void(setupwallscan(int bits, Draw1ColumnFuncPtr &draw1, Draw4ColumnsFuncPtr &draw2))) { if (rw_pic->UseType == FTexture::TEX_Null) return; @@ -1297,7 +1365,7 @@ void wallscan_any( DWORD(*draw1column)(); void(*draw4columns)(); - setupwallscan(32 - rw_pic->HeightBits, (rw_pic->GetHeight() - 1) << (32 - rw_pic->HeightBits), draw1column, draw4columns); + setupwallscan(r_swtruecolor ? FRACBITS : 32 - rw_pic->HeightBits, draw1column, draw4columns); bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); if (fixed) @@ -1450,9 +1518,9 @@ void wallscan_any( void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) { - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, int fracmax, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) { - setupvline(bits, fracmax); + setupvline(bits); line1 = dovline1; line4 = dovline4; }); @@ -1466,9 +1534,9 @@ void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t } else { - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, int fracmax, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) { - setupmvline(bits, fracmax); + setupmvline(bits); line1 = domvline1; line4 = domvline4; }); @@ -1486,9 +1554,9 @@ void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fi } else { - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, int fracmax, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) { - setuptmvline(bits, fracmax); + setuptmvline(bits); line1 = reinterpret_cast(tmvline1); line4 = tmvline4; }); diff --git a/src/textures/textures.h b/src/textures/textures.h index ab9dc3719..bb83f79e7 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -185,6 +185,9 @@ public: // Returns the whole texture, stored in column-major order, in BGRA8 format virtual const uint32_t *GetPixelsBgra(); + // Returns true if GetPixelsBgra includes mipmaps + virtual bool Mipmapped() { return true; } + virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL); int CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, FRemapTable *remap, FCopyInfo *inf = NULL); virtual bool UseBasePalette(); @@ -530,6 +533,7 @@ public: void SetUpdated() { bNeedsUpdate = false; bDidUpdate = true; bFirstUpdate = false; } DSimpleCanvas *GetCanvas() { return Canvas; } DSimpleCanvas *GetCanvasBgra() { return CanvasBgra; } + bool Mipmapped() override { return false; } void MakeTexture (); void MakeTextureBgra (); diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index f9050a27b..0bb3a84fd 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1781,6 +1781,9 @@ DSPLYMNU_VSYNC = "Vertical Sync"; DSPLYMNU_CAPFPS = "Rendering Interpolation"; DSPLYMNU_COLUMNMETHOD = "Column render mode"; DSPLYMNU_TRUECOLOR = "True color output"; +DSPLYMNU_MINFILTER = "Linear filter when downscaling"; +DSPLYMNU_MAGFILTER = "Linear filter when upscaling"; +DSPLYMNU_MIPMAP = "Use mipmapped textures"; DSPLYMNU_WIPETYPE = "Screen wipe style"; DSPLYMNU_SHOWENDOOM = "Show ENDOOM screen"; DSPLYMNU_PALLETEHACK = "DirectDraw palette hack"; // Not used diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 3c712de96..679db909b 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -662,6 +662,9 @@ OptionMenu "VideoOptions" Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn" Option "$DSPLYMNU_COLUMNMETHOD", "r_columnmethod", "ColumnMethods" Option "$DSPLYMNU_TRUECOLOR", "swtruecolor", "OnOff" + Option "$DSPLYMNU_MINFILTER", "r_minfilter", "OnOff" + Option "$DSPLYMNU_MAGFILTER", "r_magfilter", "OnOff" + Option "$DSPLYMNU_MIPMAP", "r_mipmap", "OnOff" StaticText " " Option "$DSPLYMNU_WIPETYPE", "wipetype", "Wipes" From 3b6d177787842f0d1844673a4b220797215fa1d8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 25 Jun 2016 12:14:15 +0200 Subject: [PATCH 0698/1509] Added bicubic interpolation when generating mipmaps --- src/CMakeLists.txt | 1 + src/textures/bicubic_interpolation.cpp | 107 +++++++++++++++++++++++++ src/textures/bicubic_interpolation.h | 50 ++++++++++++ src/textures/texture.cpp | 19 +++++ src/textures/textures.h | 1 + 5 files changed, 178 insertions(+) create mode 100644 src/textures/bicubic_interpolation.cpp create mode 100644 src/textures/bicubic_interpolation.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8c0a30ea0..042da0c8f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1190,6 +1190,7 @@ set (PCH_SOURCES textures/texturemanager.cpp textures/tgatexture.cpp textures/warptexture.cpp + textures/bicubic_interpolation.cpp thingdef/olddecorations.cpp thingdef/thingdef.cpp thingdef/thingdef_codeptr.cpp diff --git a/src/textures/bicubic_interpolation.cpp b/src/textures/bicubic_interpolation.cpp new file mode 100644 index 000000000..2c8a3049d --- /dev/null +++ b/src/textures/bicubic_interpolation.cpp @@ -0,0 +1,107 @@ + +#include "doomtype.h" +#include "bicubic_interpolation.h" + +void BicubicInterpolation::ScaleImage(uint32_t *dest_data, int dest_width, int dest_height, const uint32_t *src_data, int src_width, int src_height) +{ + if (dest_width <= 0 || dest_height <= 0 || src_width <= 0 || src_height <= 0) + return; + + // Scale factor as a rational number r = n / d + int n = dest_width; + int d = src_width; + + const unsigned char *src_ptr = (const unsigned char *)src_data; + unsigned char *dest_ptr = (unsigned char *)dest_data; + + scale(n, d, src_width, src_width * 4, src_height, src_ptr + 0, dest_width, dest_width * 4, dest_height, dest_ptr + 0); + scale(n, d, src_width, src_width * 4, src_height, src_ptr + 1, dest_width, dest_width * 4, dest_height, dest_ptr + 1); + scale(n, d, src_width, src_width * 4, src_height, src_ptr + 2, dest_width, dest_width * 4, dest_height, dest_ptr + 2); + scale(n, d, src_width, src_width * 4, src_height, src_ptr + 3, dest_width, dest_width * 4, dest_height, dest_ptr + 3); +} + +void BicubicInterpolation::scale(int n, int d, int in_width, int in_pitch, int in_height, const unsigned char *f, int out_width, int out_pitch, int out_height, unsigned char *g) +{ + // Implementation of Michael J. Aramini's Efficient Image Magnification by Bicubic Spline Interpolation + + int dimension_size = (out_width > out_height) ? out_width : out_height; + L_vector.resize(dimension_size); + + for (int i=0;i<4;i++) + c_vector[i].resize(dimension_size); + h_vector.resize(in_width); + + int larger_out_dimension; + int j, k, l, m, index; + int *L = &L_vector[0]; + float x; + float *c[4] = { &c_vector[0][0], &c_vector[1][0], &c_vector[2][0], &c_vector[3][0] }; + float *h = &h_vector[0]; + + larger_out_dimension = (out_width > out_height) ? out_width : out_height; + + for (k = 0; k < larger_out_dimension; k++) + L[k] = (k * d) / n; + + for (k = 0; k < n; k++) + { + x = (float)((k * d) % n) / (float)n; + c[0][k] = C0(x); + c[1][k] = C1(x); + c[2][k] = C2(x); + c[3][k] = C3(x); + } + for (k = n; k < larger_out_dimension; k++) + for (l = 0; l < 4; l++) + c[l][k] = c[l][k % n]; + + for (k = 0; k < out_height; k++) + { + for (j = 0; j < in_width; j++) + { + h[j] = 0.0f; + for (l = 0; l < 4; l++) + { + index = L[k] + l - 1; + if ((index >= 0) && (index < in_height)) + h[j] += f[index*in_pitch+j*4] * c[3 - l][k]; + } + } + for (m = 0; m < out_width; m++) + { + x = 0.5f; + for (l = 0; l < 4; l++) + { + index = L[m] + l - 1; + if ((index >= 0) && (index < in_width)) + x += h[index] * c[3 - l][m]; + } + if (x <= 0.0f) + g[k*out_pitch+m*4] = 0; + else if (x >= 255) + g[k*out_pitch+m*4] = 255; + else + g[k*out_pitch+m*4] = (unsigned char)x; + } + } +} + +inline float BicubicInterpolation::C0(float t) +{ + return -a * t * t * t + a * t * t; +} + +inline float BicubicInterpolation::C1(float t) +{ + return -(a + 2.0f) * t * t * t + (2.0f * a + 3.0f) * t * t - a * t; +} + +inline float BicubicInterpolation::C2(float t) +{ + return (a + 2.0f) * t * t * t - (a + 3.0f) * t * t + 1.0f; +} + +inline float BicubicInterpolation::C3(float t) +{ + return a * t * t * t - 2.0f * a * t * t + a * t; +} diff --git a/src/textures/bicubic_interpolation.h b/src/textures/bicubic_interpolation.h new file mode 100644 index 000000000..da547ad83 --- /dev/null +++ b/src/textures/bicubic_interpolation.h @@ -0,0 +1,50 @@ +/* +** Bicubic Image Scaler +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef __BICUBIC_INTERPOLATION_H__ +#define __BICUBIC_INTERPOLATION_H__ + +#pragma once + +#include + +// Bicubic image scaler +class BicubicInterpolation +{ +public: + void ScaleImage(uint32_t *dest, int dest_width, int dest_height, const uint32_t *src, int src_width, int src_height); + +private: + void scale(int n, int d, int in_width, int in_pitch, int in_height, const unsigned char *in_data, int out_width, int out_pitch, int out_height, unsigned char *out_data); + + float a = -0.5f; // a is a spline parameter such that -1 <= a <= 0 + + inline float C0(float t); + inline float C1(float t); + inline float C2(float t); + inline float C3(float t); + + std::vector L_vector; + std::vector c_vector[4]; + std::vector h_vector; +}; + +#endif diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index f5e4d4aa8..7ff5c9ba2 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -45,6 +45,7 @@ #include "v_video.h" #include "m_fixed.h" #include "textures/textures.h" +#include "textures/bicubic_interpolation.h" #include "v_palette.h" typedef bool (*CheckFunc)(FileReader & file); @@ -381,6 +382,24 @@ int FTexture::MipmapLevels() const } void FTexture::GenerateBgraMipmaps() +{ + BicubicInterpolation bicubic; + + uint32_t *src = PixelsBgra.data(); + uint32_t *dest = src + Width * Height; + int levels = MipmapLevels(); + for (int i = 1; i < levels; i++) + { + int w = MAX(Width >> i, 1); + int h = MAX(Height >> i, 1); + + bicubic.ScaleImage(dest, h, w, src, Height, Width); + + dest += w * h; + } +} + +void FTexture::GenerateBgraMipmapsFast() { uint32_t *src = PixelsBgra.data(); uint32_t *dest = src + Width * Height; diff --git a/src/textures/textures.h b/src/textures/textures.h index bb83f79e7..ff1093a49 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -276,6 +276,7 @@ protected: void CreatePixelsBgraWithMipmaps(); void GenerateBgraMipmaps(); + void GenerateBgraMipmapsFast(); int MipmapLevels() const; public: From 4fd127651d9177a8a32b3a5415654ff741f8c459 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 26 Jun 2016 06:54:32 +0200 Subject: [PATCH 0699/1509] Fixed fuzz drawer crash --- src/r_draw_rgba.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 2576cfeda..a0f534164 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -826,7 +826,10 @@ public: // Handle the case where we would go out of bounds at the top: if (yl < fuzzstep) { - uint32_t bg = dest[fuzzoffset[fuzz] * fuzzstep + pitch]; + uint32_t *srcdest = dest + fuzzoffset[fuzz] * fuzzstep + pitch; + //assert(static_cast((srcdest - (uint32_t*)dc_destorg) / (_pitch)) < viewheight); + + uint32_t bg = *srcdest; uint32_t red = RPART(bg) * 3 / 4; uint32_t green = GPART(bg) * 3 / 4; @@ -842,7 +845,7 @@ public: return; } - bool lowerbounds = (yl + count * fuzzstep > _fuzzviewheight); + bool lowerbounds = (yl + (count + fuzzstep - 1) * fuzzstep > _fuzzviewheight); if (lowerbounds) count--; @@ -858,7 +861,10 @@ public: count -= cnt; do { - uint32_t bg = dest[fuzzoffset[fuzz] * fuzzstep]; + uint32_t *srcdest = dest + fuzzoffset[fuzz] * fuzzstep; + //assert(static_cast((srcdest - (uint32_t*)dc_destorg) / (_pitch)) < viewheight); + + uint32_t bg = *srcdest; uint32_t red = RPART(bg) * 3 / 4; uint32_t green = GPART(bg) * 3 / 4; @@ -875,7 +881,10 @@ public: // Handle the case where we would go out of bounds at the bottom if (lowerbounds) { - uint32_t bg = dest[fuzzoffset[fuzz] * fuzzstep - pitch]; + uint32_t *srcdest = dest + fuzzoffset[fuzz] * fuzzstep - pitch; + //assert(static_cast((srcdest - (uint32_t*)dc_destorg) / (_pitch)) < viewheight); + + uint32_t bg = *srcdest; uint32_t red = RPART(bg) * 3 / 4; uint32_t green = GPART(bg) * 3 / 4; From 928e8e0d4374cff2d2f07957d7ca77d153cec128 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 26 Jun 2016 12:53:10 +0200 Subject: [PATCH 0700/1509] Improved linear filtering performance by adding a lookup table --- src/r_draw_rgba.cpp | 25 ++++++++++++ src/r_draw_rgba.h | 94 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 99 insertions(+), 20 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index a0f534164..bfabdfbbb 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -98,12 +98,37 @@ CVAR(Bool, r_mipmap, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); ///////////////////////////////////////////////////////////////////////////// +__m128i SampleBgra::samplertable[256 * 2]; + DrawerCommandQueue *DrawerCommandQueue::Instance() { static DrawerCommandQueue queue; return &queue; } +DrawerCommandQueue::DrawerCommandQueue() +{ + for (int inv_b = 0; inv_b < 16; inv_b++) + { + for (int inv_a = 0; inv_a < 16; inv_a++) + { + int a = 16 - inv_a; + int b = 16 - inv_b; + + int ab = a * b; + int invab = inv_a * b; + int ainvb = a * inv_b; + int invainvb = inv_a * inv_b; + + __m128i ab_invab = _mm_set_epi16(invab, invab, invab, invab, ab, ab, ab, ab); + __m128i ainvb_invainvb = _mm_set_epi16(invainvb, invainvb, invainvb, invainvb, ainvb, ainvb, ainvb, ainvb); + + _mm_store_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2, ab_invab); + _mm_store_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2 + 1, ainvb_invainvb); + } + } +} + DrawerCommandQueue::~DrawerCommandQueue() { StopThreads(); diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index a60fd65c7..4961fa6dc 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -222,6 +222,7 @@ class DrawerCommandQueue static DrawerCommandQueue *Instance(); + DrawerCommandQueue(); ~DrawerCommandQueue(); public: @@ -538,11 +539,75 @@ public: return (alpha << 24) | (red << 16) | (green << 8) | blue; } + +#ifndef NO_SSE + static __m128i samplertable[256 * 2]; +#endif }; ///////////////////////////////////////////////////////////////////////////// // SSE/AVX shading macros: +#define AVX2_SAMPLE_BILINEAR4_COLUMN_INIT(col0, col1, half, height, texturefracx) \ + const uint32_t *baseptr = col0[0]; \ + __m128i coloffsets0 = _mm_setr_epi32(col0[0] - baseptr, col0[1] - baseptr, col0[2] - baseptr, col0[3] - baseptr); \ + __m128i coloffsets1 = _mm_setr_epi32(col1[0] - baseptr, col1[1] - baseptr, col1[2] - baseptr, col1[3] - baseptr); \ + __m128i mhalf = _mm_loadu_si128((const __m128i*)half); \ + __m128i m127 = _mm_set1_epi16(127); \ + __m128i m16 = _mm_set1_epi32(16); \ + __m128i m15 = _mm_set1_epi32(15); \ + __m128i mheight = _mm_loadu_si128((const __m128i*)height); \ + __m128i mtexturefracx = _mm_loadu_si128((const __m128i*)texturefracx); + +#define AVX2_SAMPLE_BILINEAR4_COLUMN(fg, texturefracy) { \ + __m128i mtexturefracy = _mm_loadu_si128((const __m128i*)texturefracy); \ + __m128i multmp0 = _mm_srli_epi32(_mm_sub_epi32(mtexturefracy, mhalf), FRACBITS); \ + __m128i multmp1 = _mm_srli_epi32(_mm_add_epi32(mtexturefracy, mhalf), FRACBITS); \ + __m128i frac_y0 = _mm_or_si128(_mm_mul_epu32(multmp0, mheight), _mm_slli_si128(_mm_mul_epu32(_mm_srli_si128(multmp0, 4), _mm_srli_si128(mheight, 4)), 4)); \ + __m128i frac_y1 = _mm_or_si128(_mm_mul_epu32(multmp1, mheight), _mm_slli_si128(_mm_mul_epu32(_mm_srli_si128(multmp1, 4), _mm_srli_si128(mheight, 4)), 4)); \ + __m128i y0 = _mm_srli_epi32(frac_y0, FRACBITS); \ + __m128i y1 = _mm_srli_epi32(frac_y1, FRACBITS); \ + __m128i inv_b = mtexturefracx; \ + __m128i inv_a = _mm_and_si128(_mm_srli_epi32(frac_y1, FRACBITS - 4), m15); \ + __m128i a = _mm_sub_epi32(m16, inv_a); \ + __m128i b = _mm_sub_epi32(m16, inv_b); \ + __m128i ab = _mm_mullo_epi16(a, b); \ + __m128i invab = _mm_mullo_epi16(inv_a, b); \ + __m128i ainvb = _mm_mullo_epi16(a, inv_b); \ + __m128i invainvb = _mm_mullo_epi16(inv_a, inv_b); \ + __m128i ab_lo = _mm_shuffle_epi32(ab, _MM_SHUFFLE(1, 1, 0, 0)); \ + __m128i ab_hi = _mm_shuffle_epi32(ab, _MM_SHUFFLE(3, 3, 2, 2)); \ + __m128i invab_lo = _mm_shuffle_epi32(invab, _MM_SHUFFLE(1, 1, 0, 0)); \ + __m128i invab_hi = _mm_shuffle_epi32(invab, _MM_SHUFFLE(3, 3, 2, 2)); \ + __m128i ainvb_lo = _mm_shuffle_epi32(ainvb, _MM_SHUFFLE(1, 1, 0, 0)); \ + __m128i ainvb_hi = _mm_shuffle_epi32(ainvb, _MM_SHUFFLE(3, 3, 2, 2)); \ + __m128i invainvb_lo = _mm_shuffle_epi32(invainvb, _MM_SHUFFLE(1, 1, 0, 0)); \ + __m128i invainvb_hi = _mm_shuffle_epi32(invainvb, _MM_SHUFFLE(3, 3, 2, 2)); \ + ab_lo = _mm_or_si128(ab_lo, _mm_slli_epi32(ab_lo, 16)); \ + ab_hi = _mm_or_si128(ab_hi, _mm_slli_epi32(ab_hi, 16)); \ + invab_lo = _mm_or_si128(invab_lo, _mm_slli_epi32(invab_lo, 16)); \ + invab_hi = _mm_or_si128(invab_hi, _mm_slli_epi32(invab_hi, 16)); \ + ainvb_lo = _mm_or_si128(ainvb_lo, _mm_slli_epi32(ainvb_lo, 16)); \ + ainvb_hi = _mm_or_si128(ainvb_hi, _mm_slli_epi32(ainvb_hi, 16)); \ + invainvb_lo = _mm_or_si128(invainvb_lo, _mm_slli_epi32(invainvb_lo, 16)); \ + invainvb_hi = _mm_or_si128(invainvb_hi, _mm_slli_epi32(invainvb_hi, 16)); \ + __m128i p00 = _mm_i32gather_epi32((const int *)baseptr, _mm_add_epi32(y0, coloffsets0), 4); \ + __m128i p01 = _mm_i32gather_epi32((const int *)baseptr, _mm_add_epi32(y1, coloffsets0), 4); \ + __m128i p10 = _mm_i32gather_epi32((const int *)baseptr, _mm_add_epi32(y0, coloffsets1), 4); \ + __m128i p11 = _mm_i32gather_epi32((const int *)baseptr, _mm_add_epi32(y1, coloffsets1), 4); \ + __m128i p00_lo = _mm_mullo_epi16(_mm_unpacklo_epi8(p00, _mm_setzero_si128()), ab_lo); \ + __m128i p01_lo = _mm_mullo_epi16(_mm_unpacklo_epi8(p01, _mm_setzero_si128()), invab_lo); \ + __m128i p10_lo = _mm_mullo_epi16(_mm_unpacklo_epi8(p10, _mm_setzero_si128()), ainvb_lo); \ + __m128i p11_lo = _mm_mullo_epi16(_mm_unpacklo_epi8(p11, _mm_setzero_si128()), invainvb_lo); \ + __m128i p00_hi = _mm_mullo_epi16(_mm_unpackhi_epi8(p00, _mm_setzero_si128()), ab_hi); \ + __m128i p01_hi = _mm_mullo_epi16(_mm_unpackhi_epi8(p01, _mm_setzero_si128()), invab_hi); \ + __m128i p10_hi = _mm_mullo_epi16(_mm_unpackhi_epi8(p10, _mm_setzero_si128()), ainvb_hi); \ + __m128i p11_hi = _mm_mullo_epi16(_mm_unpackhi_epi8(p11, _mm_setzero_si128()), invainvb_hi); \ + __m128i fg_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_adds_epu16(p00_lo, p01_lo), _mm_adds_epu16(p10_lo, p11_lo)), m127), 8); \ + __m128i fg_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_adds_epu16(p00_hi, p01_hi), _mm_adds_epu16(p10_hi, p11_hi)), m127), 8); \ + fg = _mm_packus_epi16(fg_lo, fg_hi); \ +} + #define VEC_SAMPLE_BILINEAR4_COLUMN(fg, col0, col1, texturefracx, texturefracy, half, height) { \ __m128i m127 = _mm_set1_epi16(127); \ fg = _mm_setzero_si128(); \ @@ -550,23 +615,18 @@ public: { \ uint32_t frac_y0 = ((texturefracy[i] - half[i]) >> FRACBITS) * height[i]; \ uint32_t frac_y1 = ((texturefracy[i] + half[i]) >> FRACBITS) * height[i]; \ - uint32_t y0 = frac_y0 >> FRACBITS; \ - uint32_t y1 = frac_y1 >> FRACBITS; \ + uint32_t y0 = (frac_y0 >> FRACBITS); \ + uint32_t y1 = (frac_y1 >> FRACBITS); \ \ uint32_t inv_b = texturefracx[i]; \ uint32_t inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; \ - uint32_t a = 16 - inv_a; \ - uint32_t b = 16 - inv_b; \ \ - uint32_t ab = a * b; \ - uint32_t invab = inv_a * b; \ - uint32_t ainvb = a * inv_b; \ - uint32_t invainvb = inv_a * inv_b; \ - __m128i ab_invab = _mm_set_epi16(invab, invab, invab, invab, ab, ab, ab, ab); \ - __m128i ainvb_invainvb = _mm_set_epi16(invainvb, invainvb, invainvb, invainvb, ainvb, ainvb, ainvb, ainvb); \ + __m128i ab_invab = _mm_load_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2); \ + __m128i ainvb_invainvb = _mm_load_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2 + 1); \ \ - __m128i p0 = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, col0[i][y1], col0[i][y0]), _mm_setzero_si128()); \ - __m128i p1 = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, col1[i][y1], col1[i][y0]), _mm_setzero_si128()); \ + __m128i gather = _mm_set_epi32(col1[i][y1], col1[i][y0], col0[i][y1], col1[i][y0]); \ + __m128i p0 = _mm_unpacklo_epi8(gather, _mm_setzero_si128()); \ + __m128i p1 = _mm_unpackhi_epi8(gather, _mm_setzero_si128()); \ \ __m128i tmp = _mm_adds_epu16(_mm_mullo_epi16(p0, ab_invab), _mm_mullo_epi16(p1, ainvb_invainvb)); \ __m128i color = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_srli_si128(tmp, 8), tmp), m127), 8); \ @@ -597,15 +657,9 @@ public: \ uint32_t inv_b = ((xfrac + xhalf) >> (xbits - 4)) & 15; \ uint32_t inv_a = ((yfrac + yhalf) >> (ybits - 4)) & 15; \ - uint32_t a = 16 - inv_a; \ - uint32_t b = 16 - inv_b; \ \ - uint32_t ab = a * b; \ - uint32_t invab = inv_a * b; \ - uint32_t ainvb = a * inv_b; \ - uint32_t invainvb = inv_a * inv_b; \ - __m128i ab_invab = _mm_set_epi16(invab, invab, invab, invab, ab, ab, ab, ab); \ - __m128i ainvb_invainvb = _mm_set_epi16(invainvb, invainvb, invainvb, invainvb, ainvb, ainvb, ainvb, ainvb); \ + __m128i ab_invab = _mm_load_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2); \ + __m128i ainvb_invainvb = _mm_load_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2 + 1); \ \ __m128i p0 = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, p01, p00), _mm_setzero_si128()); \ __m128i p1 = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, p11, p10), _mm_setzero_si128()); \ From 6c037fa24971df781b5581a42cf58651bcb71954 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 26 Jun 2016 21:23:32 +0200 Subject: [PATCH 0701/1509] Throwing templates at the code redundancy problem in drawers --- src/r_draw_rgba.cpp | 630 ++++++++++++++++++++-------- src/r_draw_rgba.h | 88 ++-- src/r_draw_rgba_sse.h | 923 +---------------------------------------- src/r_drawt_rgba.cpp | 5 + src/r_drawt_rgba_sse.h | 10 + src/r_segs.cpp | 3 +- 6 files changed, 551 insertions(+), 1108 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index bfabdfbbb..fbb2c12c5 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -67,8 +67,13 @@ CVAR(Bool, r_mipmap, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); #ifndef NO_SSE +#ifdef _MSC_VER +#pragma warning(disable: 4101) // warning C4101: unreferenced local variable +#endif + // Generate SSE drawers: #define VecCommand(name) name##_SSE_Command +#define VEC_SHADE_VARS SSE_SHADE_VARS #define VEC_SHADE_SIMPLE_INIT SSE_SHADE_SIMPLE_INIT #define VEC_SHADE_SIMPLE_INIT4 SSE_SHADE_SIMPLE_INIT4 #define VEC_SHADE_SIMPLE SSE_SHADE_SIMPLE @@ -1552,8 +1557,446 @@ public: return (--count) != 0; } }; + +#ifdef NO_SSE + struct NearestSampler + { + FORCEINLINE static uint32_t Sample1(DrawerWall4Command &cmd, LoopIterator &loop, int index) + { + return cmd._bufplce[index][loop.sample_index(index)]; + } + }; + struct LinearSampler + { + FORCEINLINE static uint32_t Sample1(DrawerWall4Command &cmd, LoopIterator &loop, int index) + { + return SampleBgra::sample_bilinear(cmd._bufplce[index], cmd._bufplce2[index], cmd._buftexturefracx[index], loop.vplce[index], loop.half[index], loop.height[index]); + } + }; +#else + struct NearestSampler + { + FORCEINLINE static __m128i Sample4(DrawerWall4Command &cmd, LoopIterator &loop) + { + return _mm_set_epi32(cmd._bufplce[3][loop.sample_index(3)], cmd._bufplce[2][loop.sample_index(2)], cmd._bufplce[1][loop.sample_index(1)], cmd._bufplce[0][loop.sample_index(0)]); + } + }; + + struct LinearSampler + { + FORCEINLINE static __m128i Sample4(DrawerWall4Command &cmd, LoopIterator &loop) + { + __m128i fg; + VEC_SAMPLE_BILINEAR4_COLUMN(fg, cmd._bufplce, cmd._bufplce2, cmd._buftexturefracx, loop.vplce, loop.half, loop.height); + return fg; + } + }; +#endif + +#ifdef NO_SSE + template + struct Copy + { + Copy(DrawerWall4Command &cmd, LoopIterator &loop) + { + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + for (int i = 0; i < 4; i++) + { + uint32_t fg = LightBgra::shade_bgra(Sampler::Sample1(cmd, loop, i), cmd._light[i], cmd._shade_constants); + loop.dest[i] = BlendBgra::copy(fg); + } + } + }; + + template + struct Mask + { + Mask(DrawerWall4Command &cmd, LoopIterator &loop) + { + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + for (int i = 0; i < 4; i++) + { + uint32_t fg = LightBgra::shade_bgra(Sampler::Sample1(cmd, loop, i), cmd._light[i], cmd._shade_constants); + loop.dest[i] = BlendBgra::alpha_blend(fg, loop.dest[i]); + } + } + }; + + template + struct TMaskAdd + { + TMaskAdd(DrawerWall4Command &cmd, LoopIterator &loop) + { + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + for (int i = 0; i < 4; i++) + { + uint32_t fg = LightBgra::shade_bgra(Sampler::Sample1(cmd, loop, i), cmd._light[i], cmd._shade_constants); + loop.dest[i] = BlendBgra::add(fg, loop.dest[i], cmd._srcalpha, calc_blend_bgalpha(fg, cmd._destalpha)); + } + } + }; + + template + struct TMaskSub + { + TMaskSub(DrawerWall4Command &cmd, LoopIterator &loop) + { + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + for (int i = 0; i < 4; i++) + { + uint32_t fg = LightBgra::shade_bgra(Sampler::Sample1(cmd, loop, i), cmd._light[i], cmd._shade_constants); + loop.dest[i] = BlendBgra::sub(fg, loop.dest[i], cmd._srcalpha, calc_blend_bgalpha(fg, cmd._destalpha)); + } + } + }; + + template + struct TMaskRevSub + { + TMaskRevSub(DrawerWall4Command &cmd, LoopIterator &loop) + { + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + for (int i = 0; i < 4; i++) + { + uint32_t fg = LightBgra::shade_bgra(Sampler::Sample1(cmd, loop, i), cmd._light[i], cmd._shade_constants); + loop.dest[i] = BlendBgra::revsub(fg, loop.dest[i], cmd._srcalpha, calc_blend_bgalpha(fg, cmd._destalpha)); + } + } + }; + + typedef Copy CopyNearestSimple; + typedef Copy CopyLinearSimple; + typedef Copy CopyNearest; + typedef Copy CopyLinear; + typedef Mask MaskNearestSimple; + typedef Mask MaskLinearSimple; + typedef Mask MaskNearest; + typedef Mask MaskLinear; + typedef TMaskAdd TMaskAddNearestSimple; + typedef TMaskAdd TMaskAddLinearSimple; + typedef TMaskAdd TMaskAddNearest; + typedef TMaskAdd TMaskAddLinear; + typedef TMaskSub TMaskSubNearestSimple; + typedef TMaskSub TMaskSubLinearSimple; + typedef TMaskSub TMaskSubNearest; + typedef TMaskSub TMaskSubLinear; + typedef TMaskRevSub TMaskRevSubNearestSimple; + typedef TMaskRevSub TMaskRevSubLinearSimple; + typedef TMaskRevSub TMaskRevSubNearest; + typedef TMaskRevSub TMaskRevSubLinear; +#else + template + struct CopySimple + { + VEC_SHADE_VARS(); + CopySimple(DrawerWall4Command &cmd, LoopIterator &loop) + { + VEC_SHADE_SIMPLE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0]); + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + __m128i fg = Sampler::Sample4(cmd, loop); + VEC_SHADE_SIMPLE(fg); + _mm_storeu_si128((__m128i*)loop.dest, fg); + } + }; + + template + struct Copy + { + VEC_SHADE_VARS(); + Copy(DrawerWall4Command &cmd, LoopIterator &loop) + { + VEC_SHADE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0], cmd._shade_constants); + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + __m128i fg = Sampler::Sample4(cmd, loop); + VEC_SHADE(fg, cmd._shade_constants); + _mm_storeu_si128((__m128i*)loop.dest, fg); + } + }; + + template + struct MaskSimple + { + VEC_SHADE_VARS(); + MaskSimple(DrawerWall4Command &cmd, LoopIterator &loop) + { + VEC_SHADE_SIMPLE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0]); + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + __m128i fg = Sampler::Sample4(cmd, loop); + __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); + VEC_SHADE_SIMPLE(fg); + VEC_ALPHA_BLEND(fg, bg); + _mm_storeu_si128((__m128i*)loop.dest, fg); + } + }; + + template + struct Mask + { + VEC_SHADE_VARS(); + Mask(DrawerWall4Command &cmd, LoopIterator &loop) + { + VEC_SHADE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0], cmd._shade_constants); + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + __m128i fg = Sampler::Sample4(cmd, loop); + __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); + VEC_SHADE(fg, cmd._shade_constants); + VEC_ALPHA_BLEND(fg, bg); + _mm_storeu_si128((__m128i*)loop.dest, fg); + } + }; + + template + struct TMaskAddSimple + { + VEC_SHADE_VARS(); + VEC_CALC_BLEND_ALPHA_VARS(); + TMaskAddSimple(DrawerWall4Command &cmd, LoopIterator &loop) + { + VEC_SHADE_SIMPLE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0]); + VEC_CALC_BLEND_ALPHA_INIT(cmd._srcalpha, cmd._destalpha); + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + __m128i fg = Sampler::Sample4(cmd, loop); + __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); + + VEC_CALC_BLEND_ALPHA(fg); + VEC_SHADE_SIMPLE(fg); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + __m128i out_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); + __m128i out_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); + __m128i out = _mm_packus_epi16(out_lo, out_hi); + + _mm_storeu_si128((__m128i*)loop.dest, out); + } + }; + + template + struct TMaskAdd + { + VEC_SHADE_VARS(); + VEC_CALC_BLEND_ALPHA_VARS(); + TMaskAdd(DrawerWall4Command &cmd, LoopIterator &loop) + { + VEC_SHADE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0], cmd._shade_constants); + VEC_CALC_BLEND_ALPHA_INIT(cmd._srcalpha, cmd._destalpha); + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + __m128i fg = Sampler::Sample4(cmd, loop); + __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); + + VEC_CALC_BLEND_ALPHA(fg); + VEC_SHADE_SIMPLE(fg); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + __m128i out_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); + __m128i out_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); + __m128i out = _mm_packus_epi16(out_lo, out_hi); + + _mm_storeu_si128((__m128i*)loop.dest, out); + } + }; + + template + struct TMaskSubSimple + { + VEC_SHADE_VARS(); + VEC_CALC_BLEND_ALPHA_VARS(); + TMaskSubSimple(DrawerWall4Command &cmd, LoopIterator &loop) + { + VEC_SHADE_SIMPLE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0]); + VEC_CALC_BLEND_ALPHA_INIT(cmd._srcalpha, cmd._destalpha); + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + __m128i fg = Sampler::Sample4(cmd, loop); + __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); + + VEC_CALC_BLEND_ALPHA(fg); + VEC_SHADE_SIMPLE(fg); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_hi, bg_alpha_hi), _mm_mullo_epi16(fg_hi, fg_alpha_hi)), 8); + __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_lo, bg_alpha_lo), _mm_mullo_epi16(fg_lo, fg_alpha_lo)), 8); + __m128i out = _mm_packus_epi16(out_lo, out_hi); + + _mm_storeu_si128((__m128i*)loop.dest, out); + } + }; + + template + struct TMaskSub + { + VEC_SHADE_VARS(); + VEC_CALC_BLEND_ALPHA_VARS(); + TMaskSub(DrawerWall4Command &cmd, LoopIterator &loop) + { + VEC_SHADE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0], cmd._shade_constants); + VEC_CALC_BLEND_ALPHA_INIT(cmd._srcalpha, cmd._destalpha); + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + __m128i fg = Sampler::Sample4(cmd, loop); + __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); + + VEC_CALC_BLEND_ALPHA(fg); + VEC_SHADE_SIMPLE(fg); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_hi, bg_alpha_hi), _mm_mullo_epi16(fg_hi, fg_alpha_hi)), 8); + __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_lo, bg_alpha_lo), _mm_mullo_epi16(fg_lo, fg_alpha_lo)), 8); + __m128i out = _mm_packus_epi16(out_lo, out_hi); + + _mm_storeu_si128((__m128i*)loop.dest, out); + } + }; + + template + struct TMaskRevSubSimple + { + VEC_SHADE_VARS(); + VEC_CALC_BLEND_ALPHA_VARS(); + TMaskRevSubSimple(DrawerWall4Command &cmd, LoopIterator &loop) + { + VEC_SHADE_SIMPLE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0]); + VEC_CALC_BLEND_ALPHA_INIT(cmd._srcalpha, cmd._destalpha); + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + __m128i fg = Sampler::Sample4(cmd, loop); + __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); + + VEC_CALC_BLEND_ALPHA(fg); + VEC_SHADE_SIMPLE(fg); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); + __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); + __m128i out = _mm_packus_epi16(out_lo, out_hi); + + _mm_storeu_si128((__m128i*)loop.dest, out); + } + }; + + template + struct TMaskRevSub + { + VEC_SHADE_VARS(); + VEC_CALC_BLEND_ALPHA_VARS(); + TMaskRevSub(DrawerWall4Command &cmd, LoopIterator &loop) + { + VEC_SHADE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0], cmd._shade_constants); + VEC_CALC_BLEND_ALPHA_INIT(cmd._srcalpha, cmd._destalpha); + } + void Blend(DrawerWall4Command &cmd, LoopIterator &loop) + { + __m128i fg = Sampler::Sample4(cmd, loop); + __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); + + VEC_CALC_BLEND_ALPHA(fg); + VEC_SHADE_SIMPLE(fg); + + __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); + __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); + __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); + __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); + + __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); + __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); + __m128i out = _mm_packus_epi16(out_lo, out_hi); + + _mm_storeu_si128((__m128i*)loop.dest, out); + } + }; + + typedef CopySimple CopyNearestSimple; + typedef CopySimple CopyLinearSimple; + typedef Copy CopyNearest; + typedef Copy CopyLinear; + typedef MaskSimple MaskNearestSimple; + typedef MaskSimple MaskLinearSimple; + typedef Mask MaskNearest; + typedef Mask MaskLinear; + typedef TMaskAddSimple TMaskAddNearestSimple; + typedef TMaskAddSimple TMaskAddLinearSimple; + typedef TMaskAdd TMaskAddNearest; + typedef TMaskAdd TMaskAddLinear; + typedef TMaskSubSimple TMaskSubNearestSimple; + typedef TMaskSubSimple TMaskSubLinearSimple; + typedef TMaskSub TMaskSubNearest; + typedef TMaskSub TMaskSubLinear; + typedef TMaskRevSubSimple TMaskRevSubNearestSimple; + typedef TMaskRevSubSimple TMaskRevSubLinearSimple; + typedef TMaskRevSub TMaskRevSubNearest; + typedef TMaskRevSub TMaskRevSubLinear; +#endif }; +typedef DrawerBlendCommand Vlinec4NearestSimpleRGBACommand; +typedef DrawerBlendCommand Vlinec4NearestRGBACommand; +typedef DrawerBlendCommand Vlinec4LinearSimpleRGBACommand; +typedef DrawerBlendCommand Vlinec4LinearRGBACommand; +typedef DrawerBlendCommand Mvlinec4NearestSimpleRGBACommand; +typedef DrawerBlendCommand Mvlinec4NearestRGBACommand; +typedef DrawerBlendCommand Mvlinec4LinearSimpleRGBACommand; +typedef DrawerBlendCommand Mvlinec4LinearRGBACommand; +typedef DrawerBlendCommand Tmvline4AddNearestSimpleRGBACommand; +typedef DrawerBlendCommand Tmvline4AddNearestRGBACommand; +typedef DrawerBlendCommand Tmvline4AddLinearSimpleRGBACommand; +typedef DrawerBlendCommand Tmvline4AddLinearRGBACommand; +typedef DrawerBlendCommand Tmvline4AddClampNearestSimpleRGBACommand; +typedef DrawerBlendCommand Tmvline4AddClampNearestRGBACommand; +typedef DrawerBlendCommand Tmvline4AddClampLinearSimpleRGBACommand; +typedef DrawerBlendCommand Tmvline4AddClampLinearRGBACommand; +typedef DrawerBlendCommand Tmvline4SubClampNearestSimpleRGBACommand; +typedef DrawerBlendCommand Tmvline4SubClampNearestRGBACommand; +typedef DrawerBlendCommand Tmvline4SubClampLinearSimpleRGBACommand; +typedef DrawerBlendCommand Tmvline4SubClampLinearRGBACommand; +typedef DrawerBlendCommand Tmvline4RevSubClampNearestSimpleRGBACommand; +typedef DrawerBlendCommand Tmvline4RevSubClampNearestRGBACommand; +typedef DrawerBlendCommand Tmvline4RevSubClampLinearSimpleRGBACommand; +typedef DrawerBlendCommand Tmvline4RevSubClampLinearRGBACommand; + class Vlinec1RGBACommand : public DrawerWall1Command { public: @@ -1581,39 +2024,6 @@ public: } }; -class Vlinec4RGBACommand : public DrawerWall4Command -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - - if (_bufplce2[0] == nullptr) - { - do - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_bgra(_bufplce[i][loop.sample_index(i)], _light[i], _shade_constants); - loop.dest[i] = BlendBgra::copy(fg); - } - } while (loop.next()); - } - else - { - do - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_bufplce[i], _bufplce2[i], _buftexturefracx[i], loop.sample_index(i), loop.half[i], loop.height[i]), _light[i], _shade_constants); - loop.dest[i] = BlendBgra::copy(fg); - } - } while (loop.next()); - } - } -}; - class Mvlinec1RGBACommand : public DrawerWall1Command { public: @@ -1641,39 +2051,6 @@ public: } }; -class Mvlinec4RGBACommand : public DrawerWall4Command -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - - if (_bufplce2[0] == nullptr) - { - do - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_bgra(_bufplce[i][loop.sample_index(i)], _light[i], _shade_constants); - loop.dest[i] = BlendBgra::alpha_blend(fg, loop.dest[i]); - } - } while (loop.next()); - } - else - { - do - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_bufplce[i], _bufplce2[i], _buftexturefracx[i], loop.sample_index(i), loop.half[i], loop.height[i]), _light[i], _shade_constants); - loop.dest[i] = BlendBgra::alpha_blend(fg, loop.dest[i]); - } - } while (loop.next()); - } - } -}; - class Tmvline1AddRGBACommand : public DrawerWall1Command { public: @@ -1689,24 +2066,6 @@ public: } }; -class Tmvline4AddRGBACommand : public DrawerWall4Command -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_bgra(_bufplce[i][loop.sample_index(i)], _light[i], _shade_constants); - loop.dest[i] = BlendBgra::add(fg, loop.dest[i], _srcalpha, calc_blend_bgalpha(fg, _destalpha)); - } - } while (loop.next()); - } -}; - class Tmvline1AddClampRGBACommand : public DrawerWall1Command { public: @@ -1722,24 +2081,6 @@ public: } }; -class Tmvline4AddClampRGBACommand : public DrawerWall4Command -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_bgra(_bufplce[i][loop.sample_index(i)], _light[i], _shade_constants); - loop.dest[i] = BlendBgra::add(fg, loop.dest[i], _srcalpha, calc_blend_bgalpha(fg, _destalpha)); - } - } while (loop.next()); - } -}; - class Tmvline1SubClampRGBACommand : public DrawerWall1Command { public: @@ -1755,24 +2096,6 @@ public: } }; -class Tmvline4SubClampRGBACommand : public DrawerWall4Command -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_bgra(_bufplce[i][loop.sample_index(i)], _light[i], _shade_constants); - loop.dest[i] = BlendBgra::sub(fg, loop.dest[i], _srcalpha, calc_blend_bgalpha(fg, _destalpha)); - } - } while (loop.next()); - } -}; - class Tmvline1RevSubClampRGBACommand : public DrawerWall1Command { public: @@ -1788,24 +2111,6 @@ public: } }; -class Tmvline4RevSubClampRGBACommand : public DrawerWall4Command -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_bgra(_bufplce[i][loop.sample_index(i)], _light[i], _shade_constants); - loop.dest[i] = BlendBgra::revsub(fg, loop.dest[i], _srcalpha, calc_blend_bgalpha(fg, _destalpha)); - } - } while (loop.next()); - } -}; - ///////////////////////////////////////////////////////////////////////////// class DrawFogBoundaryLineRGBACommand : public DrawerCommand @@ -2355,13 +2660,22 @@ DWORD vlinec1_rgba() return dc_texturefrac + dc_count * dc_iscale; } +template +void queue_wallcommand() +{ + if (bufplce2[0] == nullptr && dc_shade_constants.simple_shade) + DrawerCommandQueue::QueueCommand(); + else if (bufplce2[0] == nullptr) + DrawerCommandQueue::QueueCommand(); + else if (dc_shade_constants.simple_shade) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); +} + void vlinec4_rgba() { -#ifdef NO_SSE - DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif + queue_wallcommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } @@ -2374,11 +2688,7 @@ DWORD mvlinec1_rgba() void mvlinec4_rgba() { -#ifdef NO_SSE - DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif + queue_wallcommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } @@ -2391,11 +2701,7 @@ fixed_t tmvline1_add_rgba() void tmvline4_add_rgba() { -#ifdef NO_SSE - DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif + queue_wallcommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } @@ -2408,11 +2714,7 @@ fixed_t tmvline1_addclamp_rgba() void tmvline4_addclamp_rgba() { -#ifdef NO_SSE - DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif + queue_wallcommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } @@ -2425,11 +2727,7 @@ fixed_t tmvline1_subclamp_rgba() void tmvline4_subclamp_rgba() { -#ifdef NO_SSE - DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif + queue_wallcommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } @@ -2442,11 +2740,7 @@ fixed_t tmvline1_revsubclamp_rgba() void tmvline4_revsubclamp_rgba() { -#ifdef NO_SSE - DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif + queue_wallcommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 4961fa6dc..53572c88b 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -286,6 +286,22 @@ public: void Execute(DrawerThread *thread) override; }; +template +class DrawerBlendCommand : public CommandType +{ +public: + void Execute(DrawerThread *thread) override + { + LoopIterator loop(this, thread); + if (!loop) return; + BlendMode blend(*this, loop); + do + { + blend.Blend(*this, loop); + } while (loop.next()); + } +}; + ///////////////////////////////////////////////////////////////////////////// // Pixel shading inline functions: @@ -624,7 +640,7 @@ public: __m128i ab_invab = _mm_load_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2); \ __m128i ainvb_invainvb = _mm_load_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2 + 1); \ \ - __m128i gather = _mm_set_epi32(col1[i][y1], col1[i][y0], col0[i][y1], col1[i][y0]); \ + __m128i gather = _mm_set_epi32(col1[i][y1], col1[i][y0], col0[i][y1], col0[i][y0]); \ __m128i p0 = _mm_unpacklo_epi8(gather, _mm_setzero_si128()); \ __m128i p1 = _mm_unpackhi_epi8(gather, _mm_setzero_si128()); \ \ @@ -635,6 +651,26 @@ public: } \ } +#define VEC_SAMPLE_MIP_NEAREST4_COLUMN(fg, col0, col1, mipfrac, texturefracy, height0, height1) { \ + uint32_t y0[4], y1[4]; \ + for (int i = 0; i < 4; i++) \ + { \ + y0[i] = (texturefracy[i] >> FRACBITS) * height0[i]; \ + y1[i] = (texturefracy[i] >> FRACBITS) * height1[i]; \ + } \ + __m128i p0 = _mm_set_epi32(col0[y0[3]], col0[y0[2]], col0[y0[1]], col0[y0[0]]); \ + __m128i p1 = _mm_set_epi32(col1[y1[3]], col1[y1[2]], col1[y1[1]], col1[y1[0]]); \ + __m128i t = _mm_loadu_si128((const __m128i*)mipfrac); \ + __m128i inv_t = _mm_sub_epi32(_mm_set1_epi32(256), mipfrac); \ + __m128i p0_lo = _mm_unpacklo_epi8(p0, _mm_setzero_si128()); \ + __m128i p0_hi = _mm_unpackhi_epi8(p0, _mm_setzero_si128()); \ + __m128i p1_lo = _mm_unpacklo_epi8(p1, _mm_setzero_si128()); \ + __m128i p1_hi = _mm_unpackhi_epi8(p1, _mm_setzero_si128()); \ + __m128i fg_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(p0_lo, t), _mm_mullo_epi16(p1_lo, inv_t)), 8); \ + __m128i fg_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(p0_hi, t), _mm_mullo_epi16(p1_hi, inv_t)), 8); \ + fg = _mm_packus_epi16(fg_lo, fg_hi); \ +} + #define VEC_SAMPLE_BILINEAR4_SPAN(fg, texture, xfrac, yfrac, xstep, ystep, xbits, ybits) { \ int xshift = (32 - xbits); \ int yshift = (32 - ybits); \ @@ -844,12 +880,14 @@ FORCEINLINE uint32_t calc_blend_bgalpha(uint32_t fg, uint32_t dest_alpha) return (dest_alpha * alpha + 256 * inv_alpha + 128) >> 8; } +#define VEC_CALC_BLEND_ALPHA_VARS() __m128i msrc_alpha, mdest_alpha, m256, m255, m128; + #define VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha) \ - __m128i msrc_alpha = _mm_set1_epi16(src_alpha); \ - __m128i mdest_alpha = _mm_set1_epi16(dest_alpha * 255 / 256); \ - __m128i m256 = _mm_set1_epi16(256); \ - __m128i m255 = _mm_set1_epi16(255); \ - __m128i m128 = _mm_set1_epi16(128); + msrc_alpha = _mm_set1_epi16(src_alpha); \ + mdest_alpha = _mm_set1_epi16(dest_alpha * 255 / 256); \ + m256 = _mm_set1_epi16(256); \ + m255 = _mm_set1_epi16(255); \ + m128 = _mm_set1_epi16(128); // Calculates the final alpha values to be used when combined with the source texture alpha channel #define VEC_CALC_BLEND_ALPHA(fg) \ @@ -866,15 +904,17 @@ FORCEINLINE uint32_t calc_blend_bgalpha(uint32_t fg, uint32_t dest_alpha) fg_alpha_lo = msrc_alpha; \ } +#define SSE_SHADE_VARS() __m128i mlight_hi, mlight_lo, color, fade, fade_amount_hi, fade_amount_lo, inv_desaturate; + // Calculate constants for a simple shade #define SSE_SHADE_SIMPLE_INIT(light) \ - __m128i mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ - __m128i mlight_lo = mlight_hi; + mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ + mlight_lo = mlight_hi; // Calculate constants for a simple shade with different light levels for each pixel #define SSE_SHADE_SIMPLE_INIT4(light3, light2, light1, light0) \ - __m128i mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); \ - __m128i mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); + mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); \ + mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); // Simple shade 4 pixels #define SSE_SHADE_SIMPLE(fg) { \ @@ -889,31 +929,31 @@ FORCEINLINE uint32_t calc_blend_bgalpha(uint32_t fg, uint32_t dest_alpha) // Calculate constants for a complex shade #define SSE_SHADE_INIT(light, shade_constants) \ - __m128i mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ - __m128i mlight_lo = mlight_hi; \ - __m128i color = _mm_set_epi16( \ + mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ + mlight_lo = mlight_hi; \ + color = _mm_set_epi16( \ 256, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ 256, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ - __m128i fade = _mm_set_epi16( \ + fade = _mm_set_epi16( \ 0, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ 0, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ - __m128i fade_amount_hi = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_hi)); \ - __m128i fade_amount_lo = fade_amount_hi; \ - __m128i inv_desaturate = _mm_set1_epi16(256 - shade_constants.desaturate); \ + fade_amount_hi = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_hi)); \ + fade_amount_lo = fade_amount_hi; \ + inv_desaturate = _mm_set1_epi16(256 - shade_constants.desaturate); \ // Calculate constants for a complex shade with different light levels for each pixel #define SSE_SHADE_INIT4(light3, light2, light1, light0, shade_constants) \ - __m128i mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); \ - __m128i mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); \ - __m128i color = _mm_set_epi16( \ + mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); \ + mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); \ + color = _mm_set_epi16( \ 256, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ 256, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ - __m128i fade = _mm_set_epi16( \ + fade = _mm_set_epi16( \ 0, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ 0, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ - __m128i fade_amount_hi = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_hi)); \ - __m128i fade_amount_lo = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_lo)); \ - __m128i inv_desaturate = _mm_set1_epi16(256 - shade_constants.desaturate); \ + fade_amount_hi = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_hi)); \ + fade_amount_lo = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_lo)); \ + inv_desaturate = _mm_set1_epi16(256 - shade_constants.desaturate); \ // Complex shade 4 pixels #define SSE_SHADE(fg, shade_constants) { \ diff --git a/src/r_draw_rgba_sse.h b/src/r_draw_rgba_sse.h index ae8d3bf42..4ee557693 100644 --- a/src/r_draw_rgba_sse.h +++ b/src/r_draw_rgba_sse.h @@ -84,6 +84,7 @@ public: if (shade_constants.simple_shade) { + VEC_SHADE_VARS(); VEC_SHADE_SIMPLE_INIT(light); while (sse_count--) @@ -121,6 +122,7 @@ public: } else { + VEC_SHADE_VARS(); VEC_SHADE_INIT(light, shade_constants); while (sse_count--) @@ -184,6 +186,7 @@ public: if (shade_constants.simple_shade) { + VEC_SHADE_VARS(); VEC_SHADE_SIMPLE_INIT(light); while (sse_count--) @@ -217,6 +220,7 @@ public: } else { + VEC_SHADE_VARS(); VEC_SHADE_INIT(light, shade_constants); while (sse_count--) @@ -277,6 +281,7 @@ public: if (shade_constants.simple_shade) { + VEC_SHADE_VARS(); VEC_SHADE_SIMPLE_INIT(light); while (sse_count--) { @@ -289,6 +294,7 @@ public: } else { + VEC_SHADE_VARS(); VEC_SHADE_INIT(light, shade_constants); while (sse_count--) { @@ -317,6 +323,7 @@ public: if (shade_constants.simple_shade) { + VEC_SHADE_VARS(); VEC_SHADE_SIMPLE_INIT(light); while (sse_count--) { @@ -331,6 +338,7 @@ public: } else { + VEC_SHADE_VARS(); VEC_SHADE_INIT(light, shade_constants); while (sse_count--) { @@ -357,918 +365,3 @@ public: } } }; - -class VecCommand(Vlinec4RGBA) : public DrawerCommand -{ - BYTE * RESTRICT _dest; - int _count; - int _pitch; - ShadeConstants _shade_constants; - fixed_t palookuplight[4]; - DWORD vplce[4]; - DWORD vince[4]; - const uint32 * RESTRICT bufplce[4]; - const uint32_t * RESTRICT bufplce2[4]; - uint32_t buftexturefracx[4]; - uint32_t bufheight[4]; - -public: - VecCommand(Vlinec4RGBA)() - { - _dest = dc_dest; - _count = dc_count; - _pitch = dc_pitch; - _shade_constants = dc_shade_constants; - for (int i = 0; i < 4; i++) - { - palookuplight[i] = ::palookuplight[i]; - vplce[i] = ::vplce[i]; - vince[i] = ::vince[i]; - bufplce[i] = (const uint32 *)::bufplce[i]; - bufplce2[i] = (const uint32_t *)::bufplce2[i]; - buftexturefracx[i] = ::buftexturefracx[i]; - bufheight[i] = ::bufheight[i]; - } - } - - void Execute(DrawerThread *thread) override - { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - - uint32_t height[4]; - uint32_t half[4]; - for (int i = 0; i < 4; i++) - { - height[i] = bufheight[i]; - half[i] = (0x80000000 + height[i] - 1) / height[i]; - } - - uint32_t light0 = LightBgra::calc_light_multiplier(palookuplight[0]); - uint32_t light1 = LightBgra::calc_light_multiplier(palookuplight[1]); - uint32_t light2 = LightBgra::calc_light_multiplier(palookuplight[2]); - uint32_t light3 = LightBgra::calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - - if (bufplce2[0] == nullptr) - { - if (shade_constants.simple_shade) - { - VEC_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); - do - { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; - - uint32_t p0 = bufplce[0][((place0 >> FRACBITS) * height[0]) >> FRACBITS]; - uint32_t p1 = bufplce[1][((place1 >> FRACBITS) * height[1]) >> FRACBITS]; - uint32_t p2 = bufplce[2][((place2 >> FRACBITS) * height[2]) >> FRACBITS]; - uint32_t p3 = bufplce[3][((place3 >> FRACBITS) * height[3]) >> FRACBITS]; - - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; - - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - VEC_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += pitch; - } while (--count); - } - else - { - VEC_SHADE_INIT4(light3, light2, light1, light0, shade_constants); - do - { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; - - uint32_t p0 = bufplce[0][((place0 >> FRACBITS) * height[0]) >> FRACBITS]; - uint32_t p1 = bufplce[1][((place1 >> FRACBITS) * height[1]) >> FRACBITS]; - uint32_t p2 = bufplce[2][((place2 >> FRACBITS) * height[2]) >> FRACBITS]; - uint32_t p3 = bufplce[3][((place3 >> FRACBITS) * height[3]) >> FRACBITS]; - - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; - - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - VEC_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - dest += pitch; - } while (--count); - } - } - else - { - if (shade_constants.simple_shade) - { - VEC_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); - do - { - __m128i fg; - VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, half, height); - - local_vplce[0] = local_vplce[0] + local_vince[0]; - local_vplce[1] = local_vplce[1] + local_vince[1]; - local_vplce[2] = local_vplce[2] + local_vince[2]; - local_vplce[3] = local_vplce[3] + local_vince[3]; - - VEC_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += pitch; - } while (--count); - } - else - { - VEC_SHADE_INIT4(light3, light2, light1, light0, shade_constants); - do - { - __m128i fg; - VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, half, height); - - local_vplce[0] = local_vplce[0] + local_vince[0]; - local_vplce[1] = local_vplce[1] + local_vince[1]; - local_vplce[2] = local_vplce[2] + local_vince[2]; - local_vplce[3] = local_vplce[3] + local_vince[3]; - - VEC_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - dest += pitch; - } while (--count); - } - } - } -}; - -class VecCommand(Mvlinec4RGBA) : public DrawerCommand -{ - BYTE * RESTRICT _dest; - int _count; - int _pitch; - ShadeConstants _shade_constants; - uint32_t _mvlinemax; - fixed_t palookuplight[4]; - DWORD vplce[4]; - DWORD vince[4]; - const uint32 * RESTRICT bufplce[4]; - const uint32 * RESTRICT bufplce2[4]; - uint32_t buftexturefracx[4]; - uint32_t bufheight[4]; - -public: - VecCommand(Mvlinec4RGBA)() - { - _dest = dc_dest; - _count = dc_count; - _pitch = dc_pitch; - _shade_constants = dc_shade_constants; - for (int i = 0; i < 4; i++) - { - palookuplight[i] = ::palookuplight[i]; - vplce[i] = ::vplce[i]; - vince[i] = ::vince[i]; - bufplce[i] = (const uint32 *)::bufplce[i]; - bufplce2[i] = (const uint32_t *)::bufplce2[i]; - buftexturefracx[i] = ::buftexturefracx[i]; - bufheight[i] = ::bufheight[i]; - } - } - - void Execute(DrawerThread *thread) override - { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - uint32_t height[4]; - uint32_t half[4]; - for (int i = 0; i < 4; i++) - { - height[i] = bufheight[i]; - half[i] = (0x80000000 + height[i] - 1) / height[i]; - } - - uint32_t light0 = LightBgra::calc_light_multiplier(palookuplight[0]); - uint32_t light1 = LightBgra::calc_light_multiplier(palookuplight[1]); - uint32_t light2 = LightBgra::calc_light_multiplier(palookuplight[2]); - uint32_t light3 = LightBgra::calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - - if (bufplce2[0] == nullptr) - { - if (shade_constants.simple_shade) - { - VEC_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); - do - { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; - - uint32_t pix0 = bufplce[0][((place0 >> FRACBITS) * height[0]) >> FRACBITS]; - uint32_t pix1 = bufplce[1][((place1 >> FRACBITS) * height[1]) >> FRACBITS]; - uint32_t pix2 = bufplce[2][((place2 >> FRACBITS) * height[2]) >> FRACBITS]; - uint32_t pix3 = bufplce[3][((place3 >> FRACBITS) * height[3]) >> FRACBITS]; - - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; - - __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - VEC_SHADE_SIMPLE(fg); - VEC_ALPHA_BLEND(fg, bg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += pitch; - } while (--count); - } - else - { - VEC_SHADE_INIT4(light3, light2, light1, light0, shade_constants); - do - { - DWORD place0 = local_vplce[0]; - DWORD place1 = local_vplce[1]; - DWORD place2 = local_vplce[2]; - DWORD place3 = local_vplce[3]; - - uint32_t pix0 = bufplce[0][((place0 >> FRACBITS) * height[0]) >> FRACBITS]; - uint32_t pix1 = bufplce[1][((place1 >> FRACBITS) * height[1]) >> FRACBITS]; - uint32_t pix2 = bufplce[2][((place2 >> FRACBITS) * height[2]) >> FRACBITS]; - uint32_t pix3 = bufplce[3][((place3 >> FRACBITS) * height[3]) >> FRACBITS]; - - local_vplce[0] = place0 + local_vince[0]; - local_vplce[1] = place1 + local_vince[1]; - local_vplce[2] = place2 + local_vince[2]; - local_vplce[3] = place3 + local_vince[3]; - - __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - VEC_SHADE(fg, shade_constants); - VEC_ALPHA_BLEND(fg, bg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += pitch; - } while (--count); - } - } - else - { - if (shade_constants.simple_shade) - { - VEC_SHADE_SIMPLE_INIT4(light3, light2, light1, light0); - do - { - __m128i fg; - VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, half, height); - - local_vplce[0] = local_vplce[0] + local_vince[0]; - local_vplce[1] = local_vplce[1] + local_vince[1]; - local_vplce[2] = local_vplce[2] + local_vince[2]; - local_vplce[3] = local_vplce[3] + local_vince[3]; - - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - VEC_SHADE_SIMPLE(fg); - VEC_ALPHA_BLEND(fg, bg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += pitch; - } while (--count); - } - else - { - VEC_SHADE_INIT4(light3, light2, light1, light0, shade_constants); - do - { - __m128i fg; - VEC_SAMPLE_BILINEAR4_COLUMN(fg, bufplce, bufplce2, buftexturefracx, local_vplce, half, height); - - local_vplce[0] = local_vplce[0] + local_vince[0]; - local_vplce[1] = local_vplce[1] + local_vince[1]; - local_vplce[2] = local_vplce[2] + local_vince[2]; - local_vplce[3] = local_vplce[3] + local_vince[3]; - - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - VEC_SHADE(fg, shade_constants); - VEC_ALPHA_BLEND(fg, bg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += pitch; - } while (--count); - } - } - } -}; - -class VecCommand(Tmvline4AddRGBA) : public DrawerCommand -{ - BYTE * RESTRICT _dest; - int _count; - int _pitch; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - fixed_t palookuplight[4]; - DWORD vplce[4]; - DWORD vince[4]; - const uint32 * RESTRICT bufplce[4]; - uint32_t bufheight[4]; - -public: - VecCommand(Tmvline4AddRGBA)() - { - _dest = dc_dest; - _count = dc_count; - _pitch = dc_pitch; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - for (int i = 0; i < 4; i++) - { - palookuplight[i] = ::palookuplight[i]; - vplce[i] = ::vplce[i]; - vince[i] = ::vince[i]; - bufplce[i] = (const uint32 *)::bufplce[i]; - bufheight[i] = ::bufheight[i]; - } - } - - void Execute(DrawerThread *thread) override - { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - - uint32_t height[4]; - uint32_t half[4]; - for (int i = 0; i < 4; i++) - { - height[i] = bufheight[i]; - half[i] = (0x80000000 + height[i] - 1) / height[i]; - } - - uint32_t light[4]; - light[0] = LightBgra::calc_light_multiplier(palookuplight[0]); - light[1] = LightBgra::calc_light_multiplier(palookuplight[1]); - light[2] = LightBgra::calc_light_multiplier(palookuplight[2]); - light[3] = LightBgra::calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - - if (shade_constants.simple_shade) - { - VEC_SHADE_SIMPLE_INIT4(light[3], light[2], light[1], light[0]); - VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); - - do - { - uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; - uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; - uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; - uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; - - local_vplce[0] = local_vplce[0] + local_vince[0]; - local_vplce[1] = local_vplce[1] + local_vince[1]; - local_vplce[2] = local_vplce[2] + local_vince[2]; - local_vplce[3] = local_vplce[3] + local_vince[3]; - - __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - - VEC_CALC_BLEND_ALPHA(fg); - VEC_SHADE_SIMPLE(fg); - - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - __m128i out_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); - __m128i out_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); - __m128i out = _mm_packus_epi16(out_lo, out_hi); - - _mm_storeu_si128((__m128i*)dest, out); - dest += pitch; - } while (--count); - } - else - { - VEC_SHADE_INIT4(light[3], light[2], light[1], light[0], shade_constants); - VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); - - do - { - uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; - uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; - uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; - uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; - - local_vplce[0] = local_vplce[0] + local_vince[0]; - local_vplce[1] = local_vplce[1] + local_vince[1]; - local_vplce[2] = local_vplce[2] + local_vince[2]; - local_vplce[3] = local_vplce[3] + local_vince[3]; - - __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg); - VEC_SHADE(fg, shade_constants); - - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - __m128i out_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); - __m128i out_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); - __m128i out = _mm_packus_epi16(out_lo, out_hi); - - _mm_storeu_si128((__m128i*)dest, out); - dest += pitch; - } while (--count); - } - } -}; - -class VecCommand(Tmvline4AddClampRGBA) : public DrawerCommand -{ - BYTE * RESTRICT _dest; - int _count; - int _pitch; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - fixed_t palookuplight[4]; - DWORD vplce[4]; - DWORD vince[4]; - const uint32 *RESTRICT bufplce[4]; - uint32_t bufheight[4]; - -public: - VecCommand(Tmvline4AddClampRGBA)() - { - _dest = dc_dest; - _count = dc_count; - _pitch = dc_pitch; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - for (int i = 0; i < 4; i++) - { - palookuplight[i] = ::palookuplight[i]; - vplce[i] = ::vplce[i]; - vince[i] = ::vince[i]; - bufplce[i] = (const uint32 *)::bufplce[i]; - bufheight[i] = ::bufheight[i]; - } - } - - void Execute(DrawerThread *thread) override - { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - - uint32_t height[4]; - uint32_t half[4]; - for (int i = 0; i < 4; i++) - { - height[i] = bufheight[i]; - half[i] = (0x80000000 + height[i] - 1) / height[i]; - } - - uint32_t light[4]; - light[0] = LightBgra::calc_light_multiplier(palookuplight[0]); - light[1] = LightBgra::calc_light_multiplier(palookuplight[1]); - light[2] = LightBgra::calc_light_multiplier(palookuplight[2]); - light[3] = LightBgra::calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - - if (shade_constants.simple_shade) - { - VEC_SHADE_SIMPLE_INIT4(light[3], light[2], light[1], light[0]); - VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); - - do - { - uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; - uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; - uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; - uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; - - local_vplce[0] = local_vplce[0] + local_vince[0]; - local_vplce[1] = local_vplce[1] + local_vince[1]; - local_vplce[2] = local_vplce[2] + local_vince[2]; - local_vplce[3] = local_vplce[3] + local_vince[3]; - - __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg); - VEC_SHADE_SIMPLE(fg); - - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - __m128i out_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); - __m128i out_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); - __m128i out = _mm_packus_epi16(out_lo, out_hi); - - _mm_storeu_si128((__m128i*)dest, out); - dest += pitch; - } while (--count); - } - else - { - VEC_SHADE_INIT4(light[3], light[2], light[1], light[0], shade_constants); - VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); - - do - { - uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; - uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; - uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; - uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; - - local_vplce[0] = local_vplce[0] + local_vince[0]; - local_vplce[1] = local_vplce[1] + local_vince[1]; - local_vplce[2] = local_vplce[2] + local_vince[2]; - local_vplce[3] = local_vplce[3] + local_vince[3]; - - __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg); - VEC_SHADE(fg, shade_constants); - - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - __m128i out_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); - __m128i out_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); - __m128i out = _mm_packus_epi16(out_lo, out_hi); - - _mm_storeu_si128((__m128i*)dest, out); - dest += pitch; - } while (--count); - } - } -}; - -class VecCommand(Tmvline4SubClampRGBA) : public DrawerCommand -{ - BYTE * RESTRICT _dest; - int _count; - int _pitch; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - fixed_t palookuplight[4]; - DWORD vplce[4]; - DWORD vince[4]; - const uint32 *RESTRICT bufplce[4]; - uint32_t bufheight[4]; - -public: - VecCommand(Tmvline4SubClampRGBA)() - { - _dest = dc_dest; - _count = dc_count; - _pitch = dc_pitch; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - for (int i = 0; i < 4; i++) - { - palookuplight[i] = ::palookuplight[i]; - vplce[i] = ::vplce[i]; - vince[i] = ::vince[i]; - bufplce[i] = (const uint32 *)::bufplce[i]; - bufheight[i] = ::bufheight[i]; - } - } - - void Execute(DrawerThread *thread) override - { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - - uint32_t height[4]; - uint32_t half[4]; - for (int i = 0; i < 4; i++) - { - height[i] = bufheight[i]; - half[i] = (0x80000000 + height[i] - 1) / height[i]; - } - - uint32_t light[4]; - light[0] = LightBgra::calc_light_multiplier(palookuplight[0]); - light[1] = LightBgra::calc_light_multiplier(palookuplight[1]); - light[2] = LightBgra::calc_light_multiplier(palookuplight[2]); - light[3] = LightBgra::calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - - if (shade_constants.simple_shade) - { - VEC_SHADE_SIMPLE_INIT4(light[3], light[2], light[1], light[0]); - VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); - - do - { - uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; - uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; - uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; - uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; - - local_vplce[0] = local_vplce[0] + local_vince[0]; - local_vplce[1] = local_vplce[1] + local_vince[1]; - local_vplce[2] = local_vplce[2] + local_vince[2]; - local_vplce[3] = local_vplce[3] + local_vince[3]; - - __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg); - VEC_SHADE_SIMPLE(fg); - - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_hi, bg_alpha_hi), _mm_mullo_epi16(fg_hi, fg_alpha_hi)), 8); - __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_lo, bg_alpha_lo), _mm_mullo_epi16(fg_lo, fg_alpha_lo)), 8); - __m128i out = _mm_packus_epi16(out_lo, out_hi); - - _mm_storeu_si128((__m128i*)dest, out); - dest += pitch; - } while (--count); - } - else - { - VEC_SHADE_INIT4(light[3], light[2], light[1], light[0], shade_constants); - VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); - - do - { - uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; - uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; - uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; - uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; - - local_vplce[0] = local_vplce[0] + local_vince[0]; - local_vplce[1] = local_vplce[1] + local_vince[1]; - local_vplce[2] = local_vplce[2] + local_vince[2]; - local_vplce[3] = local_vplce[3] + local_vince[3]; - - __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg); - VEC_SHADE(fg, shade_constants); - - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_hi, bg_alpha_hi), _mm_mullo_epi16(fg_hi, fg_alpha_hi)), 8); - __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_lo, bg_alpha_lo), _mm_mullo_epi16(fg_lo, fg_alpha_lo)), 8); - __m128i out = _mm_packus_epi16(out_lo, out_hi); - - _mm_storeu_si128((__m128i*)dest, out); - dest += pitch; - } while (--count); - } - } -}; - -class VecCommand(Tmvline4RevSubClampRGBA) : public DrawerCommand -{ - BYTE * RESTRICT _dest; - int _count; - int _pitch; - ShadeConstants _shade_constants; - fixed_t _srcalpha; - fixed_t _destalpha; - fixed_t palookuplight[4]; - DWORD vplce[4]; - DWORD vince[4]; - const uint32 *RESTRICT bufplce[4]; - uint32_t bufheight[4]; - -public: - VecCommand(Tmvline4RevSubClampRGBA)() - { - _dest = dc_dest; - _count = dc_count; - _pitch = dc_pitch; - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - for (int i = 0; i < 4; i++) - { - palookuplight[i] = ::palookuplight[i]; - vplce[i] = ::vplce[i]; - vince[i] = ::vince[i]; - bufplce[i] = (const uint32 *)::bufplce[i]; - bufheight[i] = ::bufheight[4]; - } - } - - void Execute(DrawerThread *thread) override - { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, (uint32_t*)_dest); - int pitch = _pitch * thread->num_cores; - - uint32_t height[4]; - uint32_t half[4]; - for (int i = 0; i < 4; i++) - { - height[i] = bufheight[i]; - half[i] = (0x80000000 + height[i] - 1) / height[i]; - } - - uint32_t light[4]; - light[0] = LightBgra::calc_light_multiplier(palookuplight[0]); - light[1] = LightBgra::calc_light_multiplier(palookuplight[1]); - light[2] = LightBgra::calc_light_multiplier(palookuplight[2]); - light[3] = LightBgra::calc_light_multiplier(palookuplight[3]); - - ShadeConstants shade_constants = _shade_constants; - - uint32_t src_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t dest_alpha = _destalpha >> (FRACBITS - 8); - - DWORD local_vplce[4] = { vplce[0], vplce[1], vplce[2], vplce[3] }; - DWORD local_vince[4] = { vince[0], vince[1], vince[2], vince[3] }; - int skipped = thread->skipped_by_thread(_dest_y); - for (int i = 0; i < 4; i++) - { - local_vplce[i] += local_vince[i] * skipped; - local_vince[i] *= thread->num_cores; - } - - if (shade_constants.simple_shade) - { - VEC_SHADE_SIMPLE_INIT4(light[3], light[2], light[1], light[0]); - VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); - - do - { - uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; - uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; - uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; - uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; - - local_vplce[0] = local_vplce[0] + local_vince[0]; - local_vplce[1] = local_vplce[1] + local_vince[1]; - local_vplce[2] = local_vplce[2] + local_vince[2]; - local_vplce[3] = local_vplce[3] + local_vince[3]; - - __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg); - VEC_SHADE_SIMPLE(fg); - - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); - __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); - __m128i out = _mm_packus_epi16(out_lo, out_hi); - - _mm_storeu_si128((__m128i*)dest, out); - dest += pitch; - } while (--count); - } - else - { - VEC_SHADE_INIT4(light[3], light[2], light[1], light[0], shade_constants); - VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha); - - do - { - uint32_t pix0 = bufplce[0][((local_vplce[0] >> FRACBITS) * height[0]) >> FRACBITS]; - uint32_t pix1 = bufplce[1][((local_vplce[1] >> FRACBITS) * height[1]) >> FRACBITS]; - uint32_t pix2 = bufplce[2][((local_vplce[2] >> FRACBITS) * height[2]) >> FRACBITS]; - uint32_t pix3 = bufplce[3][((local_vplce[3] >> FRACBITS) * height[3]) >> FRACBITS]; - - local_vplce[0] = local_vplce[0] + local_vince[0]; - local_vplce[1] = local_vplce[1] + local_vince[1]; - local_vplce[2] = local_vplce[2] + local_vince[2]; - local_vplce[3] = local_vplce[3] + local_vince[3]; - - __m128i fg = _mm_set_epi32(pix3, pix2, pix1, pix0); - VEC_CALC_BLEND_ALPHA(fg); - VEC_SHADE(fg, shade_constants); - - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); - __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); - __m128i out = _mm_packus_epi16(out_lo, out_hi); - - _mm_storeu_si128((__m128i*)dest, out); - dest += pitch; - } while (--count); - } - } -}; diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 82932b1f2..45bd5c029 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -53,8 +53,13 @@ extern unsigned int *horizspan[4]; #ifndef NO_SSE +#ifdef _MSC_VER +#pragma warning(disable: 4101) // warning C4101: unreferenced local variable +#endif + // Generate SSE drawers: #define VecCommand(name) name##_SSE_Command +#define VEC_SHADE_VARS SSE_SHADE_VARS #define VEC_SHADE_SIMPLE_INIT SSE_SHADE_SIMPLE_INIT #define VEC_SHADE_SIMPLE_INIT4 SSE_SHADE_SIMPLE_INIT4 #define VEC_SHADE_SIMPLE SSE_SHADE_SIMPLE diff --git a/src/r_drawt_rgba_sse.h b/src/r_drawt_rgba_sse.h index 64a77e288..7a02f2282 100644 --- a/src/r_drawt_rgba_sse.h +++ b/src/r_drawt_rgba_sse.h @@ -60,6 +60,7 @@ public: if (shade_constants.simple_shade) { + VEC_SHADE_VARS(); VEC_SHADE_SIMPLE_INIT(light); if (count & 1) { @@ -110,6 +111,7 @@ public: } else { + VEC_SHADE_VARS(); VEC_SHADE_INIT(light, shade_constants); if (count & 1) { @@ -218,6 +220,7 @@ public: if (shade_constants.simple_shade) { + VEC_SHADE_VARS(); VEC_SHADE_SIMPLE_INIT(light); __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); @@ -254,6 +257,7 @@ public: } else { + VEC_SHADE_VARS(); VEC_SHADE_INIT(light, shade_constants); __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); @@ -421,6 +425,7 @@ public: if (shade_constants.simple_shade) { + VEC_SHADE_VARS(); VEC_SHADE_SIMPLE_INIT(light); __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); @@ -457,6 +462,7 @@ public: } else { + VEC_SHADE_VARS(); VEC_SHADE_INIT(light, shade_constants); __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); @@ -547,6 +553,7 @@ public: if (shade_constants.simple_shade) { + VEC_SHADE_VARS(); VEC_SHADE_SIMPLE_INIT(light); __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); @@ -583,6 +590,7 @@ public: } else { + VEC_SHADE_VARS(); VEC_SHADE_INIT(light, shade_constants); __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); @@ -673,6 +681,7 @@ public: if (shade_constants.simple_shade) { + VEC_SHADE_VARS(); VEC_SHADE_SIMPLE_INIT(light); __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); @@ -709,6 +718,7 @@ public: } else { + VEC_SHADE_VARS(); VEC_SHADE_INIT(light, shade_constants); __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 630d64da0..870d74894 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1146,15 +1146,16 @@ WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xof int mip_height = texture->GetHeight(); if (r_mipmap && texture->Mipmapped()) { + uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width); int level = (int)MAX(magnitude - 1.0, 0.0); while (level != 0) { mipmap_offset += mip_width * mip_height; - xoffset >>= 1; level >>= 1; mip_width = MAX(mip_width >> 1, 1); mip_height = MAX(mip_height >> 1, 1); } + xoffset = (xpos >> FRACBITS) * mip_width; } const uint32_t *pixels = texture->GetPixelsBgra() + mipmap_offset; From 8f38d3af990c5e9373f109781add7448f2de3c9f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 27 Jun 2016 10:49:15 +0200 Subject: [PATCH 0702/1509] Replaced the bicubic interpolation filter with a simple sharpening filter --- src/CMakeLists.txt | 1 - src/r_draw_rgba.cpp | 4 + src/textures/bicubic_interpolation.cpp | 107 --------------------- src/textures/bicubic_interpolation.h | 50 ---------- src/textures/texture.cpp | 124 ++++++++++++++++++++++--- 5 files changed, 117 insertions(+), 169 deletions(-) delete mode 100644 src/textures/bicubic_interpolation.cpp delete mode 100644 src/textures/bicubic_interpolation.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 042da0c8f..8c0a30ea0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1190,7 +1190,6 @@ set (PCH_SOURCES textures/texturemanager.cpp textures/tgatexture.cpp textures/warptexture.cpp - textures/bicubic_interpolation.cpp thingdef/olddecorations.cpp thingdef/thingdef.cpp thingdef/thingdef_codeptr.cpp diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index fbb2c12c5..aa88e4302 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -103,7 +103,9 @@ CVAR(Bool, r_mipmap, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); ///////////////////////////////////////////////////////////////////////////// +#ifndef NO_SSE __m128i SampleBgra::samplertable[256 * 2]; +#endif DrawerCommandQueue *DrawerCommandQueue::Instance() { @@ -113,6 +115,7 @@ DrawerCommandQueue *DrawerCommandQueue::Instance() DrawerCommandQueue::DrawerCommandQueue() { +#ifndef NO_SSE for (int inv_b = 0; inv_b < 16; inv_b++) { for (int inv_a = 0; inv_a < 16; inv_a++) @@ -132,6 +135,7 @@ DrawerCommandQueue::DrawerCommandQueue() _mm_store_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2 + 1, ainvb_invainvb); } } +#endif } DrawerCommandQueue::~DrawerCommandQueue() diff --git a/src/textures/bicubic_interpolation.cpp b/src/textures/bicubic_interpolation.cpp deleted file mode 100644 index 2c8a3049d..000000000 --- a/src/textures/bicubic_interpolation.cpp +++ /dev/null @@ -1,107 +0,0 @@ - -#include "doomtype.h" -#include "bicubic_interpolation.h" - -void BicubicInterpolation::ScaleImage(uint32_t *dest_data, int dest_width, int dest_height, const uint32_t *src_data, int src_width, int src_height) -{ - if (dest_width <= 0 || dest_height <= 0 || src_width <= 0 || src_height <= 0) - return; - - // Scale factor as a rational number r = n / d - int n = dest_width; - int d = src_width; - - const unsigned char *src_ptr = (const unsigned char *)src_data; - unsigned char *dest_ptr = (unsigned char *)dest_data; - - scale(n, d, src_width, src_width * 4, src_height, src_ptr + 0, dest_width, dest_width * 4, dest_height, dest_ptr + 0); - scale(n, d, src_width, src_width * 4, src_height, src_ptr + 1, dest_width, dest_width * 4, dest_height, dest_ptr + 1); - scale(n, d, src_width, src_width * 4, src_height, src_ptr + 2, dest_width, dest_width * 4, dest_height, dest_ptr + 2); - scale(n, d, src_width, src_width * 4, src_height, src_ptr + 3, dest_width, dest_width * 4, dest_height, dest_ptr + 3); -} - -void BicubicInterpolation::scale(int n, int d, int in_width, int in_pitch, int in_height, const unsigned char *f, int out_width, int out_pitch, int out_height, unsigned char *g) -{ - // Implementation of Michael J. Aramini's Efficient Image Magnification by Bicubic Spline Interpolation - - int dimension_size = (out_width > out_height) ? out_width : out_height; - L_vector.resize(dimension_size); - - for (int i=0;i<4;i++) - c_vector[i].resize(dimension_size); - h_vector.resize(in_width); - - int larger_out_dimension; - int j, k, l, m, index; - int *L = &L_vector[0]; - float x; - float *c[4] = { &c_vector[0][0], &c_vector[1][0], &c_vector[2][0], &c_vector[3][0] }; - float *h = &h_vector[0]; - - larger_out_dimension = (out_width > out_height) ? out_width : out_height; - - for (k = 0; k < larger_out_dimension; k++) - L[k] = (k * d) / n; - - for (k = 0; k < n; k++) - { - x = (float)((k * d) % n) / (float)n; - c[0][k] = C0(x); - c[1][k] = C1(x); - c[2][k] = C2(x); - c[3][k] = C3(x); - } - for (k = n; k < larger_out_dimension; k++) - for (l = 0; l < 4; l++) - c[l][k] = c[l][k % n]; - - for (k = 0; k < out_height; k++) - { - for (j = 0; j < in_width; j++) - { - h[j] = 0.0f; - for (l = 0; l < 4; l++) - { - index = L[k] + l - 1; - if ((index >= 0) && (index < in_height)) - h[j] += f[index*in_pitch+j*4] * c[3 - l][k]; - } - } - for (m = 0; m < out_width; m++) - { - x = 0.5f; - for (l = 0; l < 4; l++) - { - index = L[m] + l - 1; - if ((index >= 0) && (index < in_width)) - x += h[index] * c[3 - l][m]; - } - if (x <= 0.0f) - g[k*out_pitch+m*4] = 0; - else if (x >= 255) - g[k*out_pitch+m*4] = 255; - else - g[k*out_pitch+m*4] = (unsigned char)x; - } - } -} - -inline float BicubicInterpolation::C0(float t) -{ - return -a * t * t * t + a * t * t; -} - -inline float BicubicInterpolation::C1(float t) -{ - return -(a + 2.0f) * t * t * t + (2.0f * a + 3.0f) * t * t - a * t; -} - -inline float BicubicInterpolation::C2(float t) -{ - return (a + 2.0f) * t * t * t - (a + 3.0f) * t * t + 1.0f; -} - -inline float BicubicInterpolation::C3(float t) -{ - return a * t * t * t - 2.0f * a * t * t + a * t; -} diff --git a/src/textures/bicubic_interpolation.h b/src/textures/bicubic_interpolation.h deleted file mode 100644 index da547ad83..000000000 --- a/src/textures/bicubic_interpolation.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -** Bicubic Image Scaler -** Copyright (c) 2016 Magnus Norddahl -** -** This software is provided 'as-is', without any express or implied -** warranty. In no event will the authors be held liable for any damages -** arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, -** including commercial applications, and to alter it and redistribute it -** freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not -** claim that you wrote the original software. If you use this software -** in a product, an acknowledgment in the product documentation would be -** appreciated but is not required. -** 2. Altered source versions must be plainly marked as such, and must not be -** misrepresented as being the original software. -** 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef __BICUBIC_INTERPOLATION_H__ -#define __BICUBIC_INTERPOLATION_H__ - -#pragma once - -#include - -// Bicubic image scaler -class BicubicInterpolation -{ -public: - void ScaleImage(uint32_t *dest, int dest_width, int dest_height, const uint32_t *src, int src_width, int src_height); - -private: - void scale(int n, int d, int in_width, int in_pitch, int in_height, const unsigned char *in_data, int out_width, int out_pitch, int out_height, unsigned char *out_data); - - float a = -0.5f; // a is a spline parameter such that -1 <= a <= 0 - - inline float C0(float t); - inline float C1(float t); - inline float C2(float t); - inline float C3(float t); - - std::vector L_vector; - std::vector c_vector[4]; - std::vector h_vector; -}; - -#endif diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 7ff5c9ba2..ce7874ee6 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -45,7 +45,6 @@ #include "v_video.h" #include "m_fixed.h" #include "textures/textures.h" -#include "textures/bicubic_interpolation.h" #include "v_palette.h" typedef bool (*CheckFunc)(FileReader & file); @@ -383,19 +382,122 @@ int FTexture::MipmapLevels() const void FTexture::GenerateBgraMipmaps() { - BicubicInterpolation bicubic; - - uint32_t *src = PixelsBgra.data(); - uint32_t *dest = src + Width * Height; - int levels = MipmapLevels(); - for (int i = 1; i < levels; i++) + struct Color4f { - int w = MAX(Width >> i, 1); - int h = MAX(Height >> i, 1); + float a, r, g, b; + Color4f operator*(const Color4f &v) const { return Color4f{ a * v.a, r * v.r, g * v.g, b * v.b }; } + Color4f operator/(const Color4f &v) const { return Color4f{ a / v.a, r / v.r, g / v.g, b / v.b }; } + Color4f operator+(const Color4f &v) const { return Color4f{ a + v.a, r + v.r, g + v.g, b + v.b }; } + Color4f operator-(const Color4f &v) const { return Color4f{ a - v.a, r - v.r, g - v.g, b - v.b }; } + Color4f operator*(float s) const { return Color4f{ a * s, r * s, g * s, b * s }; } + Color4f operator/(float s) const { return Color4f{ a / s, r / s, g / s, b / s }; } + Color4f operator+(float s) const { return Color4f{ a + s, r + s, g + s, b + s }; } + Color4f operator-(float s) const { return Color4f{ a - s, r - s, g - s, b - s }; } + }; - bicubic.ScaleImage(dest, h, w, src, Height, Width); + int levels = MipmapLevels(); + std::vector image(PixelsBgra.size()); - dest += w * h; + // Convert to normalized linear colorspace + { + for (int x = 0; x < Width; x++) + { + for (int y = 0; y < Height; y++) + { + uint32_t c8 = PixelsBgra[x * Height + y]; + Color4f c; + c.a = std::pow(APART(c8) * (1.0f / 255.0f), 2.2f); + c.r = std::pow(RPART(c8) * (1.0f / 255.0f), 2.2f); + c.g = std::pow(GPART(c8) * (1.0f / 255.0f), 2.2f); + c.b = std::pow(BPART(c8) * (1.0f / 255.0f), 2.2f); + image[x * Height + y] = c; + } + } + } + + // Generate mipmaps + { + std::vector smoothed(Width * Height); + Color4f *src = image.data(); + Color4f *dest = src + Width * Height; + for (int i = 1; i < levels; i++) + { + int srcw = MAX(Width >> (i - 1), 1); + int srch = MAX(Height >> (i - 1), 1); + int w = MAX(Width >> i, 1); + int h = MAX(Height >> i, 1); + + // Downscale + for (int x = 0; x < w; x++) + { + int sx0 = x * 2; + int sx1 = MIN((x + 1) * 2, srcw - 1); + for (int y = 0; y < h; y++) + { + int sy0 = y * 2; + int sy1 = MIN((y + 1) * 2, srch - 1); + + Color4f src00 = src[sy0 + sx0 * srch]; + Color4f src01 = src[sy1 + sx0 * srch]; + Color4f src10 = src[sy0 + sx1 * srch]; + Color4f src11 = src[sy1 + sx1 * srch]; + Color4f c = (src00 + src01 + src10 + src11) * 0.25f; + + dest[y + x * h] = src00; + } + } + + // Sharpen filter with a 3x3 kernel: + for (int x = 0; x < w; x++) + { + for (int y = 0; y < h; y++) + { + Color4f c = { 0.0f, 0.0f, 0.0f, 0.0f }; + for (int kx = -1; kx < 2; kx++) + { + for (int ky = -1; ky < 2; ky++) + { + int a = y + ky; + int b = x + kx; + if (a < 0) a = h - 1; + if (a == h) a = 0; + if (b < 0) b = w - 1; + if (b == h) b = 0; + c = c + dest[a + b * h]; + } + } + c = c * (1.0f / 9.0f); + smoothed[y + x * h] = c; + } + } + float k = 0.04f; + for (int j = 0; j < w * h; j++) + dest[j] = dest[j] + (dest[j] - smoothed[j]) * k; + + src = dest; + dest += w * h; + } + } + + // Convert to bgra8 sRGB colorspace + { + Color4f *src = image.data() + Width * Height; + uint32_t *dest = PixelsBgra.data() + Width * Height; + for (int i = 1; i < levels; i++) + { + int w = MAX(Width >> i, 1); + int h = MAX(Height >> i, 1); + for (int j = 0; j < w * h; j++) + { + uint32_t a = (uint32_t)clamp(std::pow(src[j].a, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t r = (uint32_t)clamp(std::pow(src[j].r, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t g = (uint32_t)clamp(std::pow(src[j].g, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t b = (uint32_t)clamp(std::pow(src[j].b, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + dest[j] = (a << 24) | (r << 16) | (g << 8) | b; + } + src += w * h; + dest += w * h; + } } } From 200d357b0d1f609ce67fdb23c03c77836285f0e3 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 27 Jun 2016 11:43:24 +0200 Subject: [PATCH 0703/1509] Linear filtering bug fix --- src/r_draw_rgba.cpp | 16 ++++++++-------- src/r_draw_rgba.h | 40 ++++++++++++++++++---------------------- src/r_segs.cpp | 4 ++-- 3 files changed, 28 insertions(+), 32 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index aa88e4302..7a071e1d4 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -1436,7 +1436,7 @@ public: uint32_t frac; uint32_t texturefracx; uint32_t height; - uint32_t half; + uint32_t one; LoopIterator(DrawerWall1Command *command, DrawerThread *thread) { @@ -1451,7 +1451,7 @@ public: pitch = command->_pitch * thread->num_cores; height = command->_textureheight; - half = (0x80000000 + height - 1) / height; + one = ((0x80000000 + height - 1) / height) * 2 + 1; } explicit operator bool() @@ -1520,7 +1520,7 @@ public: uint32_t vplce[4]; uint32_t vince[4]; uint32_t height[4]; - uint32_t half[4]; + uint32_t one[4]; LoopIterator(DrawerWall4Command *command, DrawerThread *thread) { @@ -1537,7 +1537,7 @@ public: vplce[i] = command->_vplce[i] + command->_vince[i] * skipped; vince[i] = command->_vince[i] * thread->num_cores; height[i] = command->_bufheight[i]; - half[i] = (0x80000000 + height[i] - 1) / height[i]; + one[i] = ((0x80000000 + height[i] - 1) / height[i]) * 2 + 1; } } @@ -1574,7 +1574,7 @@ public: { FORCEINLINE static uint32_t Sample1(DrawerWall4Command &cmd, LoopIterator &loop, int index) { - return SampleBgra::sample_bilinear(cmd._bufplce[index], cmd._bufplce2[index], cmd._buftexturefracx[index], loop.vplce[index], loop.half[index], loop.height[index]); + return SampleBgra::sample_bilinear(cmd._bufplce[index], cmd._bufplce2[index], cmd._buftexturefracx[index], loop.vplce[index], loop.one[index], loop.height[index]); } }; #else @@ -1591,7 +1591,7 @@ public: FORCEINLINE static __m128i Sample4(DrawerWall4Command &cmd, LoopIterator &loop) { __m128i fg; - VEC_SAMPLE_BILINEAR4_COLUMN(fg, cmd._bufplce, cmd._bufplce2, cmd._buftexturefracx, loop.vplce, loop.half, loop.height); + VEC_SAMPLE_BILINEAR4_COLUMN(fg, cmd._bufplce, cmd._bufplce2, cmd._buftexturefracx, loop.vplce, loop.one, loop.height); return fg; } }; @@ -2021,7 +2021,7 @@ public: { do { - uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, _source2, loop.texturefracx, loop.frac, loop.half, loop.height), _light, _shade_constants); + uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, _source2, loop.texturefracx, loop.frac, loop.one, loop.height), _light, _shade_constants); *loop.dest = BlendBgra::copy(fg); } while (loop.next()); } @@ -2048,7 +2048,7 @@ public: { do { - uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, _source2, loop.texturefracx, loop.frac, loop.half, loop.height), _light, _shade_constants); + uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, _source2, loop.texturefracx, loop.frac, loop.one, loop.height), _light, _shade_constants); *loop.dest = BlendBgra::alpha_blend(fg, *loop.dest); } while (loop.next()); } diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 53572c88b..27d7bd035 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -502,10 +502,10 @@ public: return (magnifying && r_magfilter) || (!magnifying && r_minfilter); } - FORCEINLINE static uint32_t sample_bilinear(const uint32_t *col0, const uint32_t *col1, uint32_t texturefracx, uint32_t texturefracy, uint32_t half, uint32_t height) + FORCEINLINE static uint32_t sample_bilinear(const uint32_t *col0, const uint32_t *col1, uint32_t texturefracx, uint32_t texturefracy, uint32_t one, uint32_t height) { - uint32_t frac_y0 = ((texturefracy - half) >> FRACBITS) * height; - uint32_t frac_y1 = ((texturefracy + half) >> FRACBITS) * height; + uint32_t frac_y0 = (texturefracy >> FRACBITS) * height; + uint32_t frac_y1 = ((texturefracy + one) >> FRACBITS) * height; uint32_t y0 = frac_y0 >> FRACBITS; uint32_t y1 = frac_y1 >> FRACBITS; @@ -533,18 +533,16 @@ public: int yshift = (32 - ybits); int xmask = (1 << xshift) - 1; int ymask = (1 << yshift) - 1; - uint32_t xhalf = 1 << (xbits - 1); - uint32_t yhalf = 1 << (ybits - 1); - uint32_t x = (xfrac - xhalf) >> xbits; - uint32_t y = (yfrac - yhalf) >> ybits; + uint32_t x = xfrac >> xbits; + uint32_t y = yfrac >> ybits; uint32_t p00 = texture[(y & ymask) + ((x & xmask) << yshift)]; uint32_t p01 = texture[((y + 1) & ymask) + ((x & xmask) << yshift)]; uint32_t p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)]; uint32_t p11 = texture[((y + 1) & ymask) + (((x + 1) & xmask) << yshift)]; - uint32_t inv_b = ((xfrac + xhalf) >> (xbits - 4)) & 15; - uint32_t inv_a = ((yfrac + yhalf) >> (ybits - 4)) & 15; + uint32_t inv_b = (xfrac >> (xbits - 4)) & 15; + uint32_t inv_a = (yfrac >> (ybits - 4)) & 15; uint32_t a = 16 - inv_a; uint32_t b = 16 - inv_b; @@ -564,11 +562,11 @@ public: ///////////////////////////////////////////////////////////////////////////// // SSE/AVX shading macros: -#define AVX2_SAMPLE_BILINEAR4_COLUMN_INIT(col0, col1, half, height, texturefracx) \ +#define AVX2_SAMPLE_BILINEAR4_COLUMN_INIT(col0, col1, one, height, texturefracx) \ const uint32_t *baseptr = col0[0]; \ __m128i coloffsets0 = _mm_setr_epi32(col0[0] - baseptr, col0[1] - baseptr, col0[2] - baseptr, col0[3] - baseptr); \ __m128i coloffsets1 = _mm_setr_epi32(col1[0] - baseptr, col1[1] - baseptr, col1[2] - baseptr, col1[3] - baseptr); \ - __m128i mhalf = _mm_loadu_si128((const __m128i*)half); \ + __m128i mone = _mm_loadu_si128((const __m128i*)one); \ __m128i m127 = _mm_set1_epi16(127); \ __m128i m16 = _mm_set1_epi32(16); \ __m128i m15 = _mm_set1_epi32(15); \ @@ -577,8 +575,8 @@ public: #define AVX2_SAMPLE_BILINEAR4_COLUMN(fg, texturefracy) { \ __m128i mtexturefracy = _mm_loadu_si128((const __m128i*)texturefracy); \ - __m128i multmp0 = _mm_srli_epi32(_mm_sub_epi32(mtexturefracy, mhalf), FRACBITS); \ - __m128i multmp1 = _mm_srli_epi32(_mm_add_epi32(mtexturefracy, mhalf), FRACBITS); \ + __m128i multmp0 = _mm_srli_epi32(mtexturefracy, FRACBITS); \ + __m128i multmp1 = _mm_srli_epi32(_mm_add_epi32(mtexturefracy, mone), FRACBITS); \ __m128i frac_y0 = _mm_or_si128(_mm_mul_epu32(multmp0, mheight), _mm_slli_si128(_mm_mul_epu32(_mm_srli_si128(multmp0, 4), _mm_srli_si128(mheight, 4)), 4)); \ __m128i frac_y1 = _mm_or_si128(_mm_mul_epu32(multmp1, mheight), _mm_slli_si128(_mm_mul_epu32(_mm_srli_si128(multmp1, 4), _mm_srli_si128(mheight, 4)), 4)); \ __m128i y0 = _mm_srli_epi32(frac_y0, FRACBITS); \ @@ -624,13 +622,13 @@ public: fg = _mm_packus_epi16(fg_lo, fg_hi); \ } -#define VEC_SAMPLE_BILINEAR4_COLUMN(fg, col0, col1, texturefracx, texturefracy, half, height) { \ +#define VEC_SAMPLE_BILINEAR4_COLUMN(fg, col0, col1, texturefracx, texturefracy, one, height) { \ __m128i m127 = _mm_set1_epi16(127); \ fg = _mm_setzero_si128(); \ for (int i = 0; i < 4; i++) \ { \ - uint32_t frac_y0 = ((texturefracy[i] - half[i]) >> FRACBITS) * height[i]; \ - uint32_t frac_y1 = ((texturefracy[i] + half[i]) >> FRACBITS) * height[i]; \ + uint32_t frac_y0 = (texturefracy[i] >> FRACBITS) * height[i]; \ + uint32_t frac_y1 = ((texturefracy[i] + one[i]) >> FRACBITS) * height[i]; \ uint32_t y0 = (frac_y0 >> FRACBITS); \ uint32_t y1 = (frac_y1 >> FRACBITS); \ \ @@ -676,23 +674,21 @@ public: int yshift = (32 - ybits); \ int xmask = (1 << xshift) - 1; \ int ymask = (1 << yshift) - 1; \ - uint32_t xhalf = 1 << (xbits - 1); \ - uint32_t yhalf = 1 << (ybits - 1); \ \ __m128i m127 = _mm_set1_epi16(127); \ fg = _mm_setzero_si128(); \ for (int i = 0; i < 4; i++) \ { \ - uint32_t x = (xfrac - xhalf) >> xbits; \ - uint32_t y = (yfrac - yhalf) >> ybits; \ + uint32_t x = xfrac >> xbits; \ + uint32_t y = yfrac >> ybits; \ \ uint32_t p00 = texture[(y & ymask) + ((x & xmask) << yshift)]; \ uint32_t p01 = texture[((y + 1) & ymask) + ((x & xmask) << yshift)]; \ uint32_t p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)]; \ uint32_t p11 = texture[((y + 1) & ymask) + (((x + 1) & xmask) << yshift)]; \ \ - uint32_t inv_b = ((xfrac + xhalf) >> (xbits - 4)) & 15; \ - uint32_t inv_a = ((yfrac + yhalf) >> (ybits - 4)) & 15; \ + uint32_t inv_b = (xfrac >> (xbits - 4)) & 15; \ + uint32_t inv_a = (yfrac >> (ybits - 4)) & 15; \ \ __m128i ab_invab = _mm_load_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2); \ __m128i ainvb_invainvb = _mm_load_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2 + 1); \ diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 870d74894..96bb1f948 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1173,14 +1173,14 @@ WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xof } else { - int tx0 = ((xoffset - FRACUNIT / 2) >> FRACBITS) % mip_width; + int tx0 = (xoffset >> FRACBITS) % mip_width; if (tx0 < 0) tx0 += mip_width; int tx1 = (tx0 + 1) % mip_width; source = (BYTE*)(pixels + tx0 * mip_height); source2 = (BYTE*)(pixels + tx1 * mip_height); height = mip_height; - texturefracx = ((xoffset + FRACUNIT / 2) >> (FRACBITS - 4)) & 15; + texturefracx = (xoffset >> (FRACBITS - 4)) & 15; } } } From 7a65a0f5953c33ea32ab4600064541e82603a8be Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 27 Jun 2016 11:57:27 +0200 Subject: [PATCH 0704/1509] Made mipmapping a little less aggressive --- src/r_segs.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 96bb1f948..2d39a6d97 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1147,11 +1147,12 @@ WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xof if (r_mipmap && texture->Mipmapped()) { uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width); - int level = (int)MAX(magnitude - 1.0, 0.0); - while (level != 0) + double texture_bias = 1.7f; + double level = MAX(magnitude - 3.0, 0.0); + while (level > texture_bias) { mipmap_offset += mip_width * mip_height; - level >>= 1; + level *= 0.5f; mip_width = MAX(mip_width >> 1, 1); mip_height = MAX(mip_height >> 1, 1); } From 8e3263a433004d99ca06784542ceefe6f37b9226 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 27 Jun 2016 12:01:11 +0200 Subject: [PATCH 0705/1509] - fixed return value inversion of FS's ceilingheight and floorheight functions. --- src/fragglescript/t_func.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index aabe797ef..f02843c89 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -1573,7 +1573,7 @@ void FParser::SF_FloorHeight(void) sectors[i].floorplane.PointToDist (sectors[i].centerspot, dest), crush? 10:-1, (dest > sectors[i].CenterFloor()) ? 1 : -1, - false) != EMoveResult::crushed) + false) == EMoveResult::crushed) { returnval = 0; } @@ -1662,7 +1662,7 @@ void FParser::SF_CeilingHeight(void) sectors[i].ceilingplane.PointToDist (sectors[i].centerspot, dest), crush? 10:-1, (dest > sectors[i].CenterCeiling()) ? 1 : -1, - false) != EMoveResult::crushed) + false) == EMoveResult::crushed) { returnval = 0; } From 17c212d5bc98462ba6e4950cdfeca7b98d9ede31 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Jun 2016 12:19:00 +0200 Subject: [PATCH 0706/1509] - disable transparent door render hacks if any of the involved sectors contains floor slopes. These lead to false positives but rarely represent actual hacks. --- src/gl/data/gl_setup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index a6a0141f3..fb9c2252f 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -348,7 +348,7 @@ static void PrepareTransparentDoors(sector_t * sector) int side = sector->lines[i]->sidedef[0]->sector == sec; - if (sector->GetPlaneTexZ(sector_t::floor)!=sec->GetPlaneTexZ(sector_t::floor)+1.) + if (sector->GetPlaneTexZ(sector_t::floor)!=sec->GetPlaneTexZ(sector_t::floor)+1. || sec->floorplane.isSlope()) { sector->transdoor=false; return; From fc8eaab57b9c15aa9313ad7fda319448cd3ad88c Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 26 Jun 2016 11:37:21 +0300 Subject: [PATCH 0707/1509] Fixed crash in dynamic lights compatibility renderer Reproduces using -iwad plutonia -file brutalv20b.pk3 +map map07 --- src/gl/compatibility/gl_20.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 957a73f4a..431f6bfe9 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -673,7 +673,7 @@ void GLFlat::DrawLightsCompat(int pass) while (node) { - DrawSubsectorLights(sub, pass); + DrawSubsectorLights(node->sub, pass); node = node->next; } } From e6a7db99e41168d672759e04e38b795510b8b675 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 28 Jun 2016 10:44:48 +0300 Subject: [PATCH 0708/1509] Fixed missing polyobjects in compatibility renderer --- src/gl/compatibility/gl_20.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 431f6bfe9..27f08a344 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -484,7 +484,7 @@ bool GLWall::PutWallCompat(int passflag) } else if (sub) { - if (sub->lighthead != nullptr) return false; + if (sub->lighthead == nullptr) return false; } bool foggy = !gl_isBlack(Colormap.FadeColor) || (level.flags&LEVEL_HASFADETABLE) || gl_lights_additive; From 924b8105c535d69140e28a7d190a8a7150f09e46 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 29 Jun 2016 11:34:14 +0300 Subject: [PATCH 0709/1509] Fixed splitting of complex walls in compatibility renderer Example: +warp 2720 -200 -32 on Extreme Terror https://www.doomworld.com/idgames/levels/doom2/Ports/d-f/exterror --- src/gl/scene/gl_walls.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 1abbb2e5f..a688a036b 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -272,7 +272,7 @@ void GLWall::SplitWallComplex(sector_t * frontsector, bool translucent, float ma if ((maplightbottomleftztop[1]) || (maplightbottomleft>ztop[0] && maplightbottomright(fabsf(glseg.x2 - glseg.x1), fabsf(glseg.y2 - glseg.y2)); + float clen = MAX(fabsf(glseg.x2 - glseg.x1), fabsf(glseg.y2 - glseg.y1)); float dch = ztop[1] - ztop[0]; float dfh = maplightbottomright - maplightbottomleft; @@ -312,7 +312,7 @@ void GLWall::SplitWallComplex(sector_t * frontsector, bool translucent, float ma if ((maplightbottomleftzbottom[1]) || (maplightbottomleft>zbottom[0] && maplightbottomright(fabsf(glseg.x2 - glseg.x1), fabsf(glseg.y2 - glseg.y2)); + float clen = MAX(fabsf(glseg.x2 - glseg.x1), fabsf(glseg.y2 - glseg.y1)); float dch = zbottom[1] - zbottom[0]; float dfh = maplightbottomright - maplightbottomleft; From d1617fcdf08ddc4f03dca8d92195261bf7dcc4ef Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 30 Jun 2016 13:45:06 +0200 Subject: [PATCH 0710/1509] GCC compile fixes --- src/r_draw_rgba.h | 4 ++++ src/textures/texture.cpp | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 27d7bd035..96e96530c 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -31,6 +31,10 @@ #include #include +#ifndef NO_SSE +#include +#endif + ///////////////////////////////////////////////////////////////////////////// // Drawer functions: diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index ce7874ee6..160223617 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -406,10 +406,10 @@ void FTexture::GenerateBgraMipmaps() { uint32_t c8 = PixelsBgra[x * Height + y]; Color4f c; - c.a = std::pow(APART(c8) * (1.0f / 255.0f), 2.2f); - c.r = std::pow(RPART(c8) * (1.0f / 255.0f), 2.2f); - c.g = std::pow(GPART(c8) * (1.0f / 255.0f), 2.2f); - c.b = std::pow(BPART(c8) * (1.0f / 255.0f), 2.2f); + c.a = powf(APART(c8) * (1.0f / 255.0f), 2.2f); + c.r = powf(RPART(c8) * (1.0f / 255.0f), 2.2f); + c.g = powf(GPART(c8) * (1.0f / 255.0f), 2.2f); + c.b = powf(BPART(c8) * (1.0f / 255.0f), 2.2f); image[x * Height + y] = c; } } @@ -489,10 +489,10 @@ void FTexture::GenerateBgraMipmaps() int h = MAX(Height >> i, 1); for (int j = 0; j < w * h; j++) { - uint32_t a = (uint32_t)clamp(std::pow(src[j].a, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t r = (uint32_t)clamp(std::pow(src[j].r, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t g = (uint32_t)clamp(std::pow(src[j].g, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t b = (uint32_t)clamp(std::pow(src[j].b, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t a = (uint32_t)clamp(powf(src[j].a, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t r = (uint32_t)clamp(powf(src[j].r, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t g = (uint32_t)clamp(powf(src[j].g, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t b = (uint32_t)clamp(powf(src[j].b, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); dest[j] = (a << 24) | (r << 16) | (g << 8) | b; } src += w * h; From 13ef9a834c45355ba70fb029c54170e44b54cb76 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 30 Jun 2016 13:56:53 +0200 Subject: [PATCH 0711/1509] Compile fix for gcc/clang --- src/r_draw_rgba.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 96e96530c..c976602f6 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -296,7 +296,7 @@ class DrawerBlendCommand : public CommandType public: void Execute(DrawerThread *thread) override { - LoopIterator loop(this, thread); + typename CommandType::LoopIterator loop(this, thread); if (!loop) return; BlendMode blend(*this, loop); do From 6b0b7ea0493dfe7daab28f53af7a6d9fac585e6f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 4 Jul 2016 01:00:01 +0200 Subject: [PATCH 0712/1509] - fixed sprite z coordinate calculation for flatsprites. --- src/gl/scene/gl_sprite.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 7b8c48d8f..2e7992fbc 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -689,25 +689,19 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) topclip = rendersector->PortalBlocksMovement(sector_t::ceiling) ? LARGE_VALUE : rendersector->GetPortalPlaneZ(sector_t::ceiling); bottomclip = rendersector->PortalBlocksMovement(sector_t::floor) ? -LARGE_VALUE : rendersector->GetPortalPlaneZ(sector_t::floor); + DWORD spritetype = (thing->renderflags & RF_SPRITETYPEMASK); x = thingpos.X; + z = thingpos.Z; y = thingpos.Y; + if (spritetype == RF_FLATSPRITE) z -= thing->Floorclip; - DWORD spritetype = thing->renderflags & RF_SPRITETYPEMASK; - - switch (spritetype) + // [RH] Make floatbobbing a renderer-only effect. + if (thing->flags2 & MF2_FLOATBOB) { - case RF_FLATSPRITE: - z = thingpos.Z; - default: - z = thingpos.Z - thing->Floorclip; - // [RH] Make floatbobbing a renderer-only effect. - if (thing->flags2 & MF2_FLOATBOB) - { - float fz = thing->GetBobOffset(r_TicFracF); - z += fz; - } - break; + float fz = thing->GetBobOffset(r_TicFracF); + z += fz; } + modelframe = gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED)); if (!modelframe) { From b0e9adfc10ad40dde1c080ff8cb0e034e91cd069 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 4 Jul 2016 16:33:19 +0200 Subject: [PATCH 0713/1509] Fix single layer skies by using a cube box rather than a cylinder --- src/r_plane.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 0ede451e0..8345a83ce 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -880,14 +880,34 @@ static DWORD lastskycol_bgra[4]; static int skycolplace; static int skycolplace_bgra; +// Treat sky as a cube rather than a cylinder +CVAR(Bool, r_cubesky, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); + // Get a column of sky when there is only one sky texture. static const BYTE *R_GetOneSkyColumn (FTexture *fronttex, int x) { - angle_t column = (skyangle + xtoviewangle[x]) ^ skyflip; - if (!r_swtruecolor) - return fronttex->GetColumn((UMulScale16(column, frontcyl) + frontpos) >> FRACBITS, NULL); + int tx; + if (r_cubesky) + { + int tx0 = (UMulScale16((skyangle + xtoviewangle[0]) ^ skyflip, frontcyl) + frontpos) >> FRACBITS; + int tx1 = tx0 - ((UMulScale16(xtoviewangle[0], frontcyl) * 2) >> FRACBITS); + tx = (int)(tx0 + (tx1 - tx0) * x / viewwidth + 0.5); + tx %= fronttex->GetWidth(); + if (tx < 0) + tx += fronttex->GetWidth(); + } else - return (const BYTE *)fronttex->GetColumnBgra((UMulScale16(column, frontcyl) + frontpos) >> FRACBITS, NULL); + { + angle_t column = (skyangle + xtoviewangle[x]) ^ skyflip; + tx = (UMulScale16(column, frontcyl) + frontpos) >> FRACBITS; + } + + if (!r_swtruecolor) + return fronttex->GetColumn(tx, NULL); + else + { + return (const BYTE *)fronttex->GetColumnBgra(tx, NULL); + } } // Get a column of sky when there are two overlapping sky textures @@ -1030,7 +1050,7 @@ static void R_DrawSky (visplane_t *pl) { // The texture does not tile nicely frontyScale *= skyscale; frontiScale = 1 / frontyScale; - R_DrawSkyStriped (pl); + //R_DrawSkyStriped (pl); } } From 19030b555f233f85334eaca0f2c8c66b91f1e577 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 6 Jul 2016 20:19:01 +0200 Subject: [PATCH 0714/1509] Fix sky stretching on widescreen displays --- src/r_plane.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 8345a83ce..75826d328 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -880,21 +880,17 @@ static DWORD lastskycol_bgra[4]; static int skycolplace; static int skycolplace_bgra; -// Treat sky as a cube rather than a cylinder -CVAR(Bool, r_cubesky, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR(Bool, r_linearsky, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); // Get a column of sky when there is only one sky texture. static const BYTE *R_GetOneSkyColumn (FTexture *fronttex, int x) { int tx; - if (r_cubesky) + if (r_linearsky) { - int tx0 = (UMulScale16((skyangle + xtoviewangle[0]) ^ skyflip, frontcyl) + frontpos) >> FRACBITS; - int tx1 = tx0 - ((UMulScale16(xtoviewangle[0], frontcyl) * 2) >> FRACBITS); - tx = (int)(tx0 + (tx1 - tx0) * x / viewwidth + 0.5); - tx %= fronttex->GetWidth(); - if (tx < 0) - tx += fronttex->GetWidth(); + angle_t xangle = (angle_t)((0.5 - x / (double)viewwidth) * FocalTangent * ANGLE_90); + angle_t column = (skyangle + xangle) ^ skyflip; + tx = (UMulScale16(column, frontcyl) + frontpos) >> FRACBITS; } else { From cc8d84cd5dcf05a64ebf603afa1c51fe60619ab0 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Mon, 4 Jul 2016 13:28:15 -0500 Subject: [PATCH 0715/1509] Fixed sprites defaulting to rotate around the center instead of the offsets. Seeing how it's still useful however, ROLLCENTER can still be used to center upon actors that are offsetted like monsters. --- src/gl/scene/gl_sprite.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 2e7992fbc..17b2c01dc 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -285,6 +285,7 @@ void GLSprite::Draw(int pass) // [Nash] is a flat sprite const bool isFlatSprite = (actor != NULL) && (spritetype == RF_WALLSPRITE || spritetype == RF_FLATSPRITE); const bool dontFlip = (actor != nullptr) && (actor->renderflags & RF_DONTFLIP); + const bool useOffsets = (actor != nullptr) && !(actor->renderflags & RF_ROLLCENTER); // [Nash] check for special sprite drawing modes if (drawWithXYBillboard || drawBillboardFacingCamera || drawRollSpriteActor || isFlatSprite) @@ -293,7 +294,9 @@ void GLSprite::Draw(int pass) float xcenter = (x1 + x2)*0.5; float ycenter = (y1 + y2)*0.5; float zcenter = (z1 + z2)*0.5; - + float xx = -xcenter + x; + float yy = -zcenter + z; + float zz = -ycenter + y; Matrix3x4 mat; mat.MakeIdentity(); mat.Translate(xcenter, zcenter, ycenter); // move to sprite center @@ -337,13 +340,16 @@ void GLSprite::Draw(int pass) DAngle angto = diff.Angle(); angto = deltaangle(actor->Angles.Yaw, angto); - float pitchDegrees = actor->Angles.Pitch.Degrees; + float pitchDegrees = -actor->Angles.Pitch.Degrees; bool noFlipSprite = (!dontFlip || (fabs(angto) < 90.)); mat.Rotate(0, 1, 0, (noFlipSprite) ? 0 : 180); + mat.Rotate(-yawvecY, 0, yawvecX, (noFlipSprite) ? -pitchDegrees : pitchDegrees); if (drawRollSpriteActor) { + if (useOffsets) mat.Translate(xx, yy, zz); mat.Rotate(yawvecX, 0, yawvecY, (noFlipSprite) ? -rollDegrees : rollDegrees); + if (useOffsets) mat.Translate(-xx, -yy, -zz); } } // [fgsfds] Rotate the sprite about the sight vector (roll) @@ -351,15 +357,21 @@ void GLSprite::Draw(int pass) { mat.Rotate(0, 1, 0, 0); if (drawRollSpriteActor) + { + if (useOffsets) mat.Translate(xx, yy, zz); mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); + if (useOffsets) mat.Translate(-xx, -yy, -zz); + } } else if (drawRollSpriteActor) { + if (useOffsets) mat.Translate(xx, yy, zz); if (drawWithXYBillboard) { mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); } mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees); + if (useOffsets) mat.Translate(-xx, -yy, -zz); } // apply the transform @@ -370,6 +382,7 @@ void GLSprite::Draw(int pass) // in the x/y plane. mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); } + mat.Translate(-xcenter, -zcenter, -ycenter); // retreat from sprite center v1 = mat * FVector3(x1, z1, y1); v2 = mat * FVector3(x2, z1, y2); From e56196eb1ad0ce0569c29bb86b9ad012ffe99a2d Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Tue, 5 Jul 2016 19:10:49 -0500 Subject: [PATCH 0716/1509] Disable facing camera rotations if the actor is a flat/wall sprite. - It not only looks bad, it also throws off users when trying to make perfectly aligned images since the plane is distorted wildly. --- src/gl/scene/gl_sprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 17b2c01dc..e5edcaf97 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -302,7 +302,7 @@ void GLSprite::Draw(int pass) mat.Translate(xcenter, zcenter, ycenter); // move to sprite center // Order of rotations matters. Perform yaw rotation (Y, face camera) before pitch (X, tilt up/down). - if (drawBillboardFacingCamera) + if (drawBillboardFacingCamera && !isFlatSprite) { // [CMB] Rotate relative to camera XY position, not just camera direction, // which is nicer in VR From f4b80a451ed069d9bacc3801b7f2af8e3149d634 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 16 Jul 2016 08:57:48 +0200 Subject: [PATCH 0717/1509] - fixed: The render style specific blend settings were overridden when adding code to ensure proper setup of all properties. It turned out that the only thing that wasn't set is the alpha function, not the blend settings themselves. --- src/gl/scene/gl_weapon.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index c5d1dc82a..0e2e962da 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -380,9 +380,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) // now draw the different layers of the weapon gl_RenderState.EnableBrightmap(true); gl_RenderState.SetObjectColor(ThingColor); - gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); - gl_RenderState.BlendEquation(GL_FUNC_ADD); // hack alert! Rather than changing everything in the underlying lighting code let's just temporarily change // light mode here to draw the weapon sprite. From bc7b439dd0688897cd26354b4499f096b0a2106f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 16 Jul 2016 09:10:18 +0200 Subject: [PATCH 0718/1509] - addressed: MDL_INHERITACTORPITCH got the direction of the rotation wrong. Fixed by deprecating this flag (and also MDL_INHERITACTORROLL) and introducing proper flags, named MDL_USE*. This not only resolves the issue but also elimintates the nonsensical INHERIT part of the names. --- src/gl/models/gl_models.cpp | 25 +++++++++++++++++++------ src/gl/models/gl_models.h | 3 ++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index c2f45ea10..7f05ebb2e 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -616,11 +616,19 @@ void gl_InitModels() } else if (sc.Compare("inheritactorpitch")) { - smf.flags |= MDL_INHERITACTORPITCH; + smf.flags |= MDL_USEACTORPITCH | MDL_BADROTATION; } else if (sc.Compare("inheritactorroll")) { - smf.flags |= MDL_INHERITACTORROLL; + smf.flags |= MDL_USEACTORROLL; + } + else if (sc.Compare("useactorpitch")) + { + smf.flags |= MDL_USEACTORPITCH; + } + else if (sc.Compare("useactorroll")) + { + smf.flags |= MDL_USEACTORROLL; } else if (sc.Compare("rotating")) { @@ -961,10 +969,15 @@ void gl_RenderModel(GLSprite * spr) rotateOffset = float((time - xs_FloorToInt(time)) *360.f ); } - // Added MDL_INHERITACTORPITCH and MDL_INHERITACTORROLL flags processing. - // If both flags MDL_INHERITACTORPITCH and MDL_PITCHFROMMOMENTUM are set, the pitch sums up the actor pitch and the momentum vector pitch. - if(smf->flags & MDL_INHERITACTORPITCH) pitch -= spr->actor->Angles.Pitch.Degrees; - if(smf->flags & MDL_INHERITACTORROLL) roll += spr->actor->Angles.Roll.Degrees; + // Added MDL_USEACTORPITCH and MDL_USEACTORROLL flags processing. + // If both flags MDL_USEACTORPITCH and MDL_PITCHFROMMOMENTUM are set, the pitch sums up the actor pitch and the momentum vector pitch. + if (smf->flags & MDL_USEACTORPITCH) + { + double d = spr->actor->Angles.Pitch.Degrees; + if (smf->flags & MDL_BADROTATION) pitch -= d; + else pitch += d; + } + if(smf->flags & MDL_USEACTORROLL) roll += spr->actor->Angles.Roll.Degrees; gl_RenderState.mModelMatrix.loadIdentity(); diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 9ccf765f6..ab53bd7e4 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -339,7 +339,8 @@ enum MDL_INTERPOLATEDOUBLEDFRAMES = 8, MDL_NOINTERPOLATION = 16, MDL_INHERITACTORPITCH = 32, - MDL_INHERITACTORROLL = 64, // useless for now + MDL_INHERITACTORROLL = 64, + MDL_BADROTATION = 128, }; struct FSpriteModelFrame From b3b2eb42c67e804a444036d7f8f1758158eb5e5b Mon Sep 17 00:00:00 2001 From: Jordon Moss Date: Thu, 14 Jul 2016 12:35:30 -0300 Subject: [PATCH 0719/1509] Added SurfaceSkin MODELDEF property, allows overriding MD3 per-surface skins. --- src/gl/models/gl_models.cpp | 37 ++++++++++++++++++++++++++++++++- src/gl/models/gl_models.h | 8 +++++++ src/gl/models/gl_models_md3.cpp | 16 ++++++++++++-- src/gl/scene/gl_scene.cpp | 1 + 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 7f05ebb2e..3c2eb05c8 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -460,7 +460,7 @@ void gl_InitModels() { int Lump, lastLump; FString path; - int index; + int index, surface; int i; FSpriteModelFrame smf; @@ -696,6 +696,39 @@ void gl_InitModels() } } } + else if (sc.Compare("surfaceskin")) + { + sc.MustGetNumber(); + index = sc.Number; + sc.MustGetNumber(); + surface = sc.Number; + + if (index<0 || index >= MAX_MODELS_PER_FRAME) + { + sc.ScriptError("Too many models in %s", smf.type->TypeName.GetChars()); + } + + if (surface<0 || index >= MD3_MAX_SURFACES) + { + sc.ScriptError("Invalid MD3 Surface %d in %s", MD3_MAX_SURFACES, smf.type->TypeName.GetChars()); + } + + sc.MustGetString(); + FixPathSeperator(sc.String); + if (sc.Compare("")) + { + smf.surfaceskinIDs[index][surface] = FNullTextureID(); + } + else + { + smf.surfaceskinIDs[index][surface] = LoadSkin("", sc.String); + if (!smf.surfaceskinIDs[index][surface].isValid()) + { + Printf("Surface Skin '%s' not found in '%s'\n", + sc.String, smf.type->TypeName.GetChars()); + } + } + } else if (sc.Compare("frameindex") || sc.Compare("frame")) { bool isframe=!!sc.Compare("frame"); @@ -901,6 +934,8 @@ void gl_RenderFrameModels( const FSpriteModelFrame *smf, mdl->BuildVertexBuffer(); gl_RenderState.SetVertexBuffer(mdl->mVBuf); + mdl->PushSpriteFrame(smf, i); + if ( smfNext && smf->modelframes[i] != smfNext->modelframes[i] ) mdl->RenderFrame(tex, smf->modelframes[i], smfNext->modelframes[i], inter, translation); else diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index ab53bd7e4..a75e74305 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -16,9 +16,12 @@ enum { VX, VZ, VY }; #define DMD_MAGIC 0x4D444D44 #define MD3_MAGIC 0x33504449 #define NUMVERTEXNORMALS 162 +#define MD3_MAX_SURFACES 32 FTextureID LoadSkin(const char * path, const char * fn); +// [JM] Necessary forward declaration +typedef struct FSpriteModelFrame FSpriteModelFrame; class FModel { @@ -42,6 +45,10 @@ public: } virtual float getAspectFactor() { return 1.f; } + const FSpriteModelFrame *curSpriteMDLFrame; + int curMDLIndex; + void PushSpriteFrame(const FSpriteModelFrame *smf, int index) { curSpriteMDLFrame = smf; curMDLIndex = index; }; + FModelVertexBuffer *mVBuf; FString mFileName; }; @@ -347,6 +354,7 @@ struct FSpriteModelFrame { int modelIDs[MAX_MODELS_PER_FRAME]; FTextureID skinIDs[MAX_MODELS_PER_FRAME]; + FTextureID surfaceskinIDs[MAX_MODELS_PER_FRAME][MD3_MAX_SURFACES]; int modelframes[MAX_MODELS_PER_FRAME]; float xscale, yscale, zscale; // [BB] Added zoffset, rotation parameters and flags. diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index 267e85c91..b9c0a120a 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -319,6 +319,11 @@ void FMD3Model::AddSkins(BYTE *hitlist) { for (int i = 0; i < numSurfaces; i++) { + if (curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].isValid()) + { + hitlist[curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].GetIndex()] |= FTexture::TEX_Flat; + } + MD3Surface * surf = &surfaces[i]; for (int j = 0; j < surf->numSkins; j++) { @@ -365,8 +370,15 @@ void FMD3Model::RenderFrame(FTexture * skin, int frameno, int frameno2, double i FTexture *surfaceSkin = skin; if (!surfaceSkin) { - if (surf->numSkins==0 || !surf->skins[0].isValid()) return; - surfaceSkin = TexMan(surf->skins[0]); + if (curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].isValid()) + { + surfaceSkin = TexMan(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i]); + } + else if(surf->numSkins > 0 && surf->skins[0].isValid()) + { + surfaceSkin = TexMan(surf->skins[0]); + } + if (!surfaceSkin) return; } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 6352ca0cd..619b94f84 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -1113,6 +1113,7 @@ void FGLInterface::Precache(BYTE *texhitlist, TMap &actorhit } else if (smf->modelIDs[i] != -1) { + Models[smf->modelIDs[i]]->PushSpriteFrame(smf, i); Models[smf->modelIDs[i]]->AddSkins(texhitlist); } if (smf->modelIDs[i] != -1) From 8bbc04a46f293af2ed891b1798a3b479f9d4f402 Mon Sep 17 00:00:00 2001 From: Jordon Moss Date: Fri, 15 Jul 2016 23:54:32 -0300 Subject: [PATCH 0720/1509] Fixed a minor typo in SurfaceSkin validity check. --- src/gl/models/gl_models.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 3c2eb05c8..0b7870833 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -708,7 +708,7 @@ void gl_InitModels() sc.ScriptError("Too many models in %s", smf.type->TypeName.GetChars()); } - if (surface<0 || index >= MD3_MAX_SURFACES) + if (surface<0 || surface >= MD3_MAX_SURFACES) { sc.ScriptError("Invalid MD3 Surface %d in %s", MD3_MAX_SURFACES, smf.type->TypeName.GetChars()); } From 6014bde3d03aecc0373dd1ee84195279fcc37db5 Mon Sep 17 00:00:00 2001 From: Jordon Moss Date: Sat, 16 Jul 2016 01:15:14 -0300 Subject: [PATCH 0721/1509] Renamed PushSpriteFrame to PushSpriteMDLFrame for consistency. --- src/gl/models/gl_models.cpp | 2 +- src/gl/models/gl_models.h | 2 +- src/gl/scene/gl_scene.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 0b7870833..b73c42b3b 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -934,7 +934,7 @@ void gl_RenderFrameModels( const FSpriteModelFrame *smf, mdl->BuildVertexBuffer(); gl_RenderState.SetVertexBuffer(mdl->mVBuf); - mdl->PushSpriteFrame(smf, i); + mdl->PushSpriteMDLFrame(smf, i); if ( smfNext && smf->modelframes[i] != smfNext->modelframes[i] ) mdl->RenderFrame(tex, smf->modelframes[i], smfNext->modelframes[i], inter, translation); diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index a75e74305..f6967d1f7 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -47,7 +47,7 @@ public: const FSpriteModelFrame *curSpriteMDLFrame; int curMDLIndex; - void PushSpriteFrame(const FSpriteModelFrame *smf, int index) { curSpriteMDLFrame = smf; curMDLIndex = index; }; + void PushSpriteMDLFrame(const FSpriteModelFrame *smf, int index) { curSpriteMDLFrame = smf; curMDLIndex = index; }; FModelVertexBuffer *mVBuf; FString mFileName; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 619b94f84..4cb79262e 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -1113,7 +1113,7 @@ void FGLInterface::Precache(BYTE *texhitlist, TMap &actorhit } else if (smf->modelIDs[i] != -1) { - Models[smf->modelIDs[i]]->PushSpriteFrame(smf, i); + Models[smf->modelIDs[i]]->PushSpriteMDLFrame(smf, i); Models[smf->modelIDs[i]]->AddSkins(texhitlist); } if (smf->modelIDs[i] != -1) From 1ef8057fa7df0131f51416b39b0b9f4c8548f980 Mon Sep 17 00:00:00 2001 From: Jordon Moss Date: Sat, 16 Jul 2016 04:06:36 -0300 Subject: [PATCH 0722/1509] Updated SurfaceSkin to take the path property. --- src/gl/models/gl_models.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index b73c42b3b..e686f2cea 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -721,7 +721,7 @@ void gl_InitModels() } else { - smf.surfaceskinIDs[index][surface] = LoadSkin("", sc.String); + smf.surfaceskinIDs[index][surface] = LoadSkin(path.GetChars(), sc.String); if (!smf.surfaceskinIDs[index][surface].isValid()) { Printf("Surface Skin '%s' not found in '%s'\n", From a2f56b6ef56faee0bab78f01be84c35675a4687b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 16 Jul 2016 09:35:20 +0200 Subject: [PATCH 0723/1509] - This should have been part of an earlier commit, no idea why it wasn't saved... --- src/gl/models/gl_models.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index f6967d1f7..463f81138 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -345,8 +345,8 @@ enum MDL_ROTATING = 4, MDL_INTERPOLATEDOUBLEDFRAMES = 8, MDL_NOINTERPOLATION = 16, - MDL_INHERITACTORPITCH = 32, - MDL_INHERITACTORROLL = 64, + MDL_USEACTORPITCH = 32, + MDL_USEACTORROLL = 64, MDL_BADROTATION = 128, }; From c5db5dff997e738a855013e7ad3daed2907e66ad Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 16 Jul 2016 12:45:49 +0200 Subject: [PATCH 0724/1509] - fixed a crash when initializing the GL portal data for an incomplete or inactive portal. Also did a bit of cleanup on this code, the 'delta' member was never used. --- src/gl/data/gl_data.h | 5 ++- src/gl/data/gl_portaldata.cpp | 65 ++++++++++++++++------------------- src/gl/scene/gl_portal.h | 2 +- 3 files changed, 33 insertions(+), 39 deletions(-) diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index 3e43408dd..f1bc27ee4 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -56,9 +56,8 @@ struct FPortal struct FGLLinePortal { - // defines the complete span of this portal - vertex_t *v1, *v2; // vertices, from v1 to v2 - DVector2 delta; // precalculated v2 - v1 for side checking + // defines the complete span of this portal, if this is of type PORTT_LINKED. + vertex_t *v1 = nullptr, *v2 = nullptr; // vertices, from v1 to v2 TArray lines; int validcount = 0; }; diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 2635c9a2e..847bf6f61 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -443,54 +443,49 @@ void gl_InitPortals() tempindex[i] = glLinePortals.Size(); line_t *pSrcLine = linePortals[i].mOrigin; line_t *pLine = linePortals[i].mDestination; - FGLLinePortal glport; - - glport.v1 = pLine->v1; - glport.v2 = pLine->v2; - glport.delta = { 0, 0 }; + FGLLinePortal &glport = glLinePortals[glLinePortals.Reserve(1)]; glport.lines.Push(&linePortals[i]); - glLinePortals.Push(glport); // We cannot do this grouping for non-linked portals because they can be changed at run time. - if (linePortals[i].mType == PORTT_LINKED) - do + if (linePortals[i].mType == PORTT_LINKED && pLine != nullptr) { - // now collect all other colinear lines connected to this one. We run this loop as long as it still finds a match - gotsome = false; - for (unsigned j = 0; j < linePortals.Size(); j++) + glport.v1 = pLine->v1; + glport.v2 = pLine->v2; + do { - if (tempindex[j] == -1) + // now collect all other colinear lines connected to this one. We run this loop as long as it still finds a match + gotsome = false; + for (unsigned j = 0; j < linePortals.Size(); j++) { - line_t *pSrcLine2 = linePortals[j].mOrigin; - line_t *pLine2 = linePortals[j].mDestination; - // angular precision is intentionally reduced to 32 bit BAM to account for precision problems (otherwise many not perfectly horizontal or vertical portals aren't found here.) - unsigned srcang = pSrcLine->Delta().Angle().BAMs(); - unsigned dstang = pLine->Delta().Angle().BAMs(); - if ((pSrcLine->v2 == pSrcLine2->v1 && pLine->v1 == pLine2->v2) || - (pSrcLine->v1 == pSrcLine2->v2 && pLine->v2 == pLine2->v1)) + if (tempindex[j] == -1) { - // The line connects, now check the translation - unsigned srcang2 = pSrcLine2->Delta().Angle().BAMs(); - unsigned dstang2 = pLine2->Delta().Angle().BAMs(); - if (srcang == srcang2 && dstang == dstang2) + line_t *pSrcLine2 = linePortals[j].mOrigin; + line_t *pLine2 = linePortals[j].mDestination; + // angular precision is intentionally reduced to 32 bit BAM to account for precision problems (otherwise many not perfectly horizontal or vertical portals aren't found here.) + unsigned srcang = pSrcLine->Delta().Angle().BAMs(); + unsigned dstang = pLine->Delta().Angle().BAMs(); + if ((pSrcLine->v2 == pSrcLine2->v1 && pLine->v1 == pLine2->v2) || + (pSrcLine->v1 == pSrcLine2->v2 && pLine->v2 == pLine2->v1)) { - // The lines connect and both source and destination are colinear, so this is a match - gotsome = true; - tempindex[j] = tempindex[i]; - if (pLine->v1 == pLine2->v2) glLinePortals[tempindex[i]].v1 = pLine2->v1; - else glLinePortals[tempindex[i]].v2 = pLine2->v2; - glLinePortals[tempindex[i]].lines.Push(&linePortals[j]); + // The line connects, now check the translation + unsigned srcang2 = pSrcLine2->Delta().Angle().BAMs(); + unsigned dstang2 = pLine2->Delta().Angle().BAMs(); + if (srcang == srcang2 && dstang == dstang2) + { + // The lines connect and both source and destination are colinear, so this is a match + gotsome = true; + tempindex[j] = tempindex[i]; + if (pLine->v1 == pLine2->v2) glport.v1 = pLine2->v1; + else glport.v2 = pLine2->v2; + glport.lines.Push(&linePortals[j]); + } } } } - } - } while (gotsome); + } while (gotsome); + } } } - for (auto glport : glLinePortals) - { - glport.delta = glport.v2->fPos() - glport.v1->fPos(); - } linePortalToGL.Resize(linePortals.Size()); for (unsigned i = 0; i < linePortals.Size(); i++) { diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 9ebfe083b..7b9f896db 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -195,7 +195,7 @@ struct GLLinePortal : public GLPortal GLLinePortal(FGLLinePortal *line) { - if (line->lines[0]->mType != PORTT_LINKED) + if (line->lines[0]->mType != PORTT_LINKED || line->v1 == nullptr) { // For non-linked portals we must check the actual linedef. line_t *lline = line->lines[0]->mDestination; From 35666f1e097f72128880397c6b68519545f39e29 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 21 Jul 2016 13:12:12 -0500 Subject: [PATCH 0725/1509] Fixed a nullptr crash with flatsprite actors. --- src/gl/scene/gl_sprite.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index e5edcaf97..d144da8fd 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -270,7 +270,7 @@ void GLSprite::Draw(int pass) const bool drawBillboardFacingCamera = gl_billboard_faces_camera; // [Nash] has +ROLLSPRITE - const bool drawRollSpriteActor = (actor != NULL && actor->renderflags & RF_ROLLSPRITE); + const bool drawRollSpriteActor = (actor != nullptr && actor->renderflags & RF_ROLLSPRITE); gl_RenderState.Apply(); FVector3 v1; @@ -280,10 +280,10 @@ void GLSprite::Draw(int pass) // [fgsfds] check sprite type mask DWORD spritetype = (DWORD)-1; - if (actor != NULL) spritetype = actor->renderflags & RF_SPRITETYPEMASK; + if (actor != nullptr) spritetype = actor->renderflags & RF_SPRITETYPEMASK; // [Nash] is a flat sprite - const bool isFlatSprite = (actor != NULL) && (spritetype == RF_WALLSPRITE || spritetype == RF_FLATSPRITE); + const bool isFlatSprite = (actor != nullptr) && (spritetype == RF_WALLSPRITE || spritetype == RF_FLATSPRITE); const bool dontFlip = (actor != nullptr) && (actor->renderflags & RF_DONTFLIP); const bool useOffsets = (actor != nullptr) && !(actor->renderflags & RF_ROLLCENTER); @@ -295,8 +295,8 @@ void GLSprite::Draw(int pass) float ycenter = (y1 + y2)*0.5; float zcenter = (z1 + z2)*0.5; float xx = -xcenter + x; - float yy = -zcenter + z; - float zz = -ycenter + y; + float zz = -zcenter + z; + float yy = -ycenter + y; Matrix3x4 mat; mat.MakeIdentity(); mat.Translate(xcenter, zcenter, ycenter); // move to sprite center @@ -336,20 +336,22 @@ void GLSprite::Draw(int pass) // Here we need some form of priority in order to work. if (spritetype == RF_FLATSPRITE) { - DVector3 diff = actor->Vec3To(GLRenderer->mViewActor); + float pitchDegrees = -actor->Angles.Pitch.Degrees; + DVector3 apos = { x, y, z }; + DVector3 diff = ViewPos - apos; DAngle angto = diff.Angle(); + angto = deltaangle(actor->Angles.Yaw, angto); - float pitchDegrees = -actor->Angles.Pitch.Degrees; bool noFlipSprite = (!dontFlip || (fabs(angto) < 90.)); mat.Rotate(0, 1, 0, (noFlipSprite) ? 0 : 180); mat.Rotate(-yawvecY, 0, yawvecX, (noFlipSprite) ? -pitchDegrees : pitchDegrees); if (drawRollSpriteActor) { - if (useOffsets) mat.Translate(xx, yy, zz); + if (useOffsets) mat.Translate(xx, zz, yy); mat.Rotate(yawvecX, 0, yawvecY, (noFlipSprite) ? -rollDegrees : rollDegrees); - if (useOffsets) mat.Translate(-xx, -yy, -zz); + if (useOffsets) mat.Translate(-xx, -zz, -yy); } } // [fgsfds] Rotate the sprite about the sight vector (roll) @@ -358,20 +360,20 @@ void GLSprite::Draw(int pass) mat.Rotate(0, 1, 0, 0); if (drawRollSpriteActor) { - if (useOffsets) mat.Translate(xx, yy, zz); + if (useOffsets) mat.Translate(xx, zz, yy); mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); - if (useOffsets) mat.Translate(-xx, -yy, -zz); + if (useOffsets) mat.Translate(-xx, -zz, -yy); } } else if (drawRollSpriteActor) { - if (useOffsets) mat.Translate(xx, yy, zz); + if (useOffsets) mat.Translate(xx, zz, yy); if (drawWithXYBillboard) { mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); } mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees); - if (useOffsets) mat.Translate(-xx, -yy, -zz); + if (useOffsets) mat.Translate(-xx, -zz, -yy); } // apply the transform From d405cf5b7c61aebf0e59040d09a997fe20281675 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 23 Jul 2016 09:47:14 +0200 Subject: [PATCH 0726/1509] - fixed: Before rendering a sector stack portal the clipper needs to be completely filled, if the view point's subsector is not inside the portal. If this is not done, some setups where a recursive look into the originating area is possible may exhibit some issues. --- src/gl/scene/gl_portal.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 6082c6f4f..b95e1fee0 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -756,6 +756,15 @@ void GLSectorStackPortal::DrawContents() SaveMapSection(); SetupCoverage(); ClearClipper(); + + // If the viewpoint is not within the portal, we need to invalidate the entire clip area. + // The portal will re-validate the necessary parts when its subsectors get traversed. + subsector_t *sub = R_PointInSubsector(ViewPos); + if (!(gl_drawinfo->ss_renderflags[sub - ::subsectors] & SSRF_SEEN)) + { + clipper.SafeAddClipRange(0, ANGLE_MAX); + } + GLRenderer->DrawScene(DM_PORTAL); RestoreMapSection(); From 54a120d61247c699405b22c6a55ae606735e1041 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 23 Jul 2016 10:23:34 +0200 Subject: [PATCH 0727/1509] - do not process subsectors if rendering a stacked sector portal and the clipper is set to 'blocked', i.e. no visible parts are present. This solves the most severe occurences of sprites being drawn in front of a portal's contents. It is not a full fix, though, there's still some extreme cases where portals may glitch if some stuff gets between the camera and the actual portal area. Normally this has to perform a full check of the subsector against the portal's camera-facing linedefs but that's too costly for those rare cases where it may be an issue. --- src/gl/scene/gl_bsp.cpp | 2 ++ src/gl/scene/gl_clipper.cpp | 1 + src/gl/scene/gl_clipper.h | 12 ++++++++++++ src/gl/scene/gl_portal.cpp | 1 + 4 files changed, 16 insertions(+) diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index b9915dd72..5f95902a3 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -79,6 +79,7 @@ static void UnclipSubsector(subsector_t *sub) if (startAngle-endAngle >= ANGLE_180) { clipper.SafeRemoveClipRange(startAngle, endAngle); + clipper.SetBlocked(false); } seg++; } @@ -444,6 +445,7 @@ static void DoSubsector(subsector_t * sub) // range this subsector spans before going on. UnclipSubsector(sub); } + if (clipper.IsBlocked()) return; // if we are inside a stacked sector portal which hasn't unclipped anything yet. fakesector=gl_FakeFlat(sector, &fake, false); diff --git a/src/gl/scene/gl_clipper.cpp b/src/gl/scene/gl_clipper.cpp index a523b27fd..cd076d58a 100644 --- a/src/gl/scene/gl_clipper.cpp +++ b/src/gl/scene/gl_clipper.cpp @@ -92,6 +92,7 @@ void Clipper::Clear() ClipNode *node = cliphead; ClipNode *temp; + blocked = false; while (node != NULL) { temp = node; diff --git a/src/gl/scene/gl_clipper.h b/src/gl/scene/gl_clipper.h index d09a82147..8da75080e 100644 --- a/src/gl/scene/gl_clipper.h +++ b/src/gl/scene/gl_clipper.h @@ -54,6 +54,7 @@ class Clipper ClipNode * clipnodes; ClipNode * cliphead; ClipNode * silhouette; // will be preserved even when RemoveClipRange is called + bool blocked; static angle_t AngleToPseudo(angle_t ang); bool IsRangeVisible(angle_t startangle, angle_t endangle); @@ -68,6 +69,7 @@ public: Clipper() { + blocked = false; clipnodes=cliphead=NULL; } @@ -129,6 +131,16 @@ public: SafeRemoveClipRange(AngleToPseudo(startangle), AngleToPseudo(endangle)); } + void SetBlocked(bool on) + { + blocked = on; + } + + bool IsBlocked() const + { + return blocked; + } + bool CheckBox(const float *bspcoord); }; diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index b95e1fee0..2cca5c1f0 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -763,6 +763,7 @@ void GLSectorStackPortal::DrawContents() if (!(gl_drawinfo->ss_renderflags[sub - ::subsectors] & SSRF_SEEN)) { clipper.SafeAddClipRange(0, ANGLE_MAX); + clipper.SetBlocked(true); } GLRenderer->DrawScene(DM_PORTAL); From c08fc8f5a82d423a641f5303b49d3c49c0bc6360 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 23 Jul 2016 16:30:28 +0200 Subject: [PATCH 0728/1509] Fix depth calculations for R_DoomLightingEquation and make it an exact match of what zdoom does --- wadsrc/static/shaders/glsl/main.fp | 45 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 0afcb9813..faa2ff0e3 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -117,34 +117,35 @@ vec4 getTexel(vec2 st) //=========================================================================== // -// Doom lighting equation ripped from EDGE. -// Big thanks to EDGE developers for making the only port -// that actually replicates software renderer's lighting in OpenGL. -// Float version. -// Basically replace int with float and divide all constants by 31. +// Doom lighting equation exactly as calculated by zdoom. // //=========================================================================== - -float R_DoomLightingEquation(float light, float dist) +float R_DoomLightingEquation(float light) { - // Changing this constant gives results very similar to changing r_visibility. - // Default is 232, it seems to give exactly the same light bands as software renderer. - #define DOOMLIGHTFACTOR 232.0 + // Calculated from r_visibility. It differs between walls, floor and sprites. + // + // Wall: globVis = r_WallVisibility + // Floor: r_FloorVisibility / abs(plane.Zat0 - ViewPos.Z) + // Sprite: same as wall + // All are calculated in R_SetVisibility and seem to be decided by the + // aspect ratio amongst other things. + // + // 1706 is the value for walls on 1080p 16:9 displays. + float globVis = 1706.0; - /* L in the range 0 to 63 */ - float L = light * 63.0/31.0; + /* L is the integer light level used in the game */ + float L = light * 255.0; - float min_L = clamp(36.0/31.0 - L, 0.03, 1.0); + /* z is the depth in view/eye space, positive going into the screen */ + float z = pixelpos.w; - // Fix objects getting totally black when close. - if (dist < 0.0001) - dist = 0.0001; + /* The zdoom light equation */ + float vis = globVis / z; + float shade = 64.0 - (L + 12) * 32.0/128.0; + float lightscale = clamp((shade - min(24.0, vis)) / 32.0, 0.0, 31/32.0); - float scale = 1.0 / dist; - float index = (59.0/31.0 - L) - (scale * DOOMLIGHTFACTOR/31.0 - DOOMLIGHTFACTOR/31.0); - - /* result is colormap index (0 bright .. 31 dark) */ - return clamp(index, min_L, 1.0); + // Result is the normalized colormap index (0 bright .. 1 dark) + return lightscale; } //=========================================================================== @@ -167,7 +168,7 @@ vec4 getLightColor(float fogdist, float fogfactor) if (uLightLevel >= 0.0) { - float newlightlevel = 1.0 - R_DoomLightingEquation(uLightLevel, gl_FragCoord.z); + float newlightlevel = 1.0 - R_DoomLightingEquation(uLightLevel); color.rgb *= newlightlevel; } else if (uFogEnabled > 0) From 669238db664f5e02c8c1b002da7395844ec63593 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 23 Jul 2016 17:19:07 +0200 Subject: [PATCH 0729/1509] Fix Apple GLSL compile errors --- wadsrc/static/shaders/glsl/main.fp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index faa2ff0e3..b10c99a17 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -141,8 +141,8 @@ float R_DoomLightingEquation(float light) /* The zdoom light equation */ float vis = globVis / z; - float shade = 64.0 - (L + 12) * 32.0/128.0; - float lightscale = clamp((shade - min(24.0, vis)) / 32.0, 0.0, 31/32.0); + float shade = 64.0 - (L + 12.0) * 32.0/128.0; + float lightscale = clamp((shade - min(24.0, vis)) / 32.0, 0.0, 31.0/32.0); // Result is the normalized colormap index (0 bright .. 1 dark) return lightscale; From 41e959e102fd069b0c1df324d29d70b6902f10f2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 23 Jul 2016 09:16:34 +0200 Subject: [PATCH 0730/1509] Adds the last texture filter mode (trilinear min filter with nearest magnification) --- src/gl/textures/gl_texture.cpp | 3 ++- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.z | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index f33fed6a3..f1e6f0b0b 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -71,7 +71,7 @@ CCMD(gl_flush) CUSTOM_CVAR(Int, gl_texture_filter, 4, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) { - if (self < 0 || self > 5) self=4; + if (self < 0 || self > 6) self=4; if (GLRenderer != NULL && GLRenderer->mSamplerManager != NULL) GLRenderer->mSamplerManager->SetTextureFilterMode(); } @@ -105,6 +105,7 @@ TexFilter_s TexFilter[]={ {GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR, true}, {GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, true}, {GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST, true}, + {GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST, true}, }; int TexFormat[]={ diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index b8a7bcdc0..b8abd71ec 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2625,6 +2625,7 @@ OPTVAL_INFRAREDANDTORCH = "Infrared and torch"; OPTVAL_ANYFIXEDCOLORMAP = "Any fixed colormap"; OPTVAL_NONENEARESTMIPMAP = "None (nearest mipmap)"; OPTVAL_NONELINEARMIPMAP = "None (linear mipmap)"; +OPTVAL_NONETRILINEAR = "None (trilinear)"; OPTVAL_BILINEAR = "Bilinear"; OPTVAL_TRILINEAR = "Trilinear"; OPTVAL_RGBA8 = "RGBA8"; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 7f7791954..59cb94f73 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -19,6 +19,7 @@ OptionValue "FilterModes" 0, "$OPTVAL_NONE" 1, "$OPTVAL_NONENEARESTMIPMAP" 5, "$OPTVAL_NONELINEARMIPMAP" + 6, "$OPTVAL_NONETRILINEAR" 2, "$OPTVAL_LINEAR" 3, "$OPTVAL_BILINEAR" 4, "$OPTVAL_TRILINEAR" From 071485b22e60309b09f70727cf9bbc9afa1c3caa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 25 Jul 2016 11:55:47 +0200 Subject: [PATCH 0731/1509] - fixed: If the resulting render style, after all adjustments, is None for the weapon sprite, do not attempt to draw it at all. --- src/gl/scene/gl_weapon.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 0e2e962da..34779ec7c 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -338,6 +338,11 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) vis.RenderStyle.Flags |= STYLEF_InvertSource; } } + if (vis.RenderStyle.AsDWORD == 0) + { + // This is RenderStyle None. + return; + } // Set the render parameters From aeb7df09de843542c3da7c889e5cc18540e59f87 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 26 Jul 2016 21:27:02 +0200 Subject: [PATCH 0732/1509] Added hardware gamma option and improved window handling on Windows --- src/CMakeLists.txt | 3 + src/gl/renderer/gl_renderbuffers.cpp | 159 ++++++++++++++++++++ src/gl/renderer/gl_renderbuffers.h | 29 ++++ src/gl/renderer/gl_renderer.cpp | 69 +++++++++ src/gl/renderer/gl_renderer.h | 14 +- src/gl/scene/gl_scene.cpp | 146 +++++++++++++----- src/gl/shaders/gl_presentshader.cpp | 67 +++++++++ src/gl/shaders/gl_presentshader.h | 20 +++ src/gl/shaders/gl_shaderprogram.cpp | 205 ++++++++++++++++++++++++++ src/gl/shaders/gl_shaderprogram.h | 36 +++++ src/gl/system/gl_framebuffer.cpp | 29 +++- src/gl/system/gl_framebuffer.h | 4 +- src/gl/system/gl_wipe.cpp | 32 +++- src/posix/cocoa/i_video.mm | 14 ++ src/posix/cocoa/sdlglvideo.h | 6 +- src/posix/sdl/sdlglvideo.cpp | 31 +++- src/posix/sdl/sdlglvideo.h | 4 + src/win32/hardware.cpp | 2 +- src/win32/win32gliface.cpp | 49 ++++-- src/win32/win32gliface.h | 3 + wadsrc/static/language.enu | 2 + wadsrc/static/menudef.txt | 1 + wadsrc/static/menudef.z | 7 + wadsrc/static/shaders/glsl/present.fp | 23 +++ wadsrc/static/shaders/glsl/present.vp | 11 ++ 25 files changed, 899 insertions(+), 67 deletions(-) create mode 100644 src/gl/renderer/gl_renderbuffers.cpp create mode 100644 src/gl/renderer/gl_renderbuffers.h create mode 100644 src/gl/shaders/gl_presentshader.cpp create mode 100644 src/gl/shaders/gl_presentshader.h create mode 100644 src/gl/shaders/gl_shaderprogram.cpp create mode 100644 src/gl/shaders/gl_shaderprogram.h create mode 100644 wadsrc/static/shaders/glsl/present.fp create mode 100644 wadsrc/static/shaders/glsl/present.vp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index be053d1bb..cad329962 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1060,6 +1060,7 @@ set( FASTMATH_SOURCES gl/utility/gl_geometric.cpp gl/renderer/gl_renderer.cpp gl/renderer/gl_renderstate.cpp + gl/renderer/gl_renderbuffers.cpp gl/renderer/gl_lightdata.cpp gl/hqnx/init.cpp gl/hqnx/hq2x.cpp @@ -1103,6 +1104,8 @@ set( FASTMATH_SOURCES gl/dynlights/gl_lightbuffer.cpp gl/shaders/gl_shader.cpp gl/shaders/gl_texshader.cpp + gl/shaders/gl_shaderprogram.cpp + gl/shaders/gl_presentshader.cpp gl/system/gl_interface.cpp gl/system/gl_framebuffer.cpp gl/system/gl_menu.cpp diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp new file mode 100644 index 000000000..9468c23ef --- /dev/null +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -0,0 +1,159 @@ +/* +** gl_renderbuffers.cpp +** Render buffers used during rendering +** +**--------------------------------------------------------------------------- +** Copyright 2008 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "gl/gl_functions.h" +#include "vectors.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderbuffers.h" +#include "w_wad.h" +#include "i_system.h" +#include "doomerrors.h" + +//========================================================================== +// +// Initialize render buffers and textures used in rendering passes +// +//========================================================================== + +FGLRenderBuffers::FGLRenderBuffers() +{ + glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&mOutputFB); +} + +//========================================================================== +// +// Free render buffer resources +// +//========================================================================== + +FGLRenderBuffers::~FGLRenderBuffers() +{ + if (mSceneFB != 0) + glDeleteFramebuffers(1, &mSceneFB); + if (mSceneTexture != 0) + glDeleteTextures(1, &mSceneTexture); + if (mSceneDepthStencil != 0) + glDeleteRenderbuffers(1, &mSceneDepthStencil); +} + +//========================================================================== +// +// Makes sure all render buffers have sizes suitable for rending at the +// specified resolution +// +//========================================================================== + +void FGLRenderBuffers::Setup(int width, int height) +{ + if (width <= mWidth && height <= mHeight) + return; + + if (mSceneFB != 0) + glDeleteFramebuffers(1, &mSceneFB); + if (mSceneTexture != 0) + glDeleteTextures(1, &mSceneTexture); + if (mSceneDepthStencil != 0) + glDeleteRenderbuffers(1, &mSceneDepthStencil); + + glGenFramebuffers(1, &mSceneFB); + glGenTextures(1, &mSceneTexture); + glGenRenderbuffers(1, &mSceneDepthStencil); + + glBindTexture(GL_TEXTURE_2D, mSceneTexture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGBA, GL_FLOAT, nullptr); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glBindTexture(GL_TEXTURE_2D, 0); + + glBindRenderbuffer(GL_RENDERBUFFER, mSceneDepthStencil); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); + glBindRenderbuffer(GL_RENDERBUFFER, 0); + + glBindFramebuffer(GL_FRAMEBUFFER, mSceneFB); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mSceneTexture, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mSceneDepthStencil); + glBindFramebuffer(GL_FRAMEBUFFER, mOutputFB); + + mWidth = width; + mHeight = height; +} + +//========================================================================== +// +// Makes the scene frame buffer active +// +//========================================================================== + +void FGLRenderBuffers::BindSceneFB() +{ + glBindFramebuffer(GL_FRAMEBUFFER, mSceneFB); +} + +//========================================================================== +// +// Makes the screen frame buffer active +// +//========================================================================== + +void FGLRenderBuffers::BindOutputFB() +{ + glBindFramebuffer(GL_FRAMEBUFFER, mOutputFB); +} + +//========================================================================== +// +// Binds the scene frame buffer texture to the specified texture unit +// +//========================================================================== + +void FGLRenderBuffers::BindSceneTexture(int index) +{ + glActiveTexture(index); + glBindTexture(GL_TEXTURE_2D, mSceneTexture); +} diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h new file mode 100644 index 000000000..bbb38b533 --- /dev/null +++ b/src/gl/renderer/gl_renderbuffers.h @@ -0,0 +1,29 @@ +#ifndef __GL_RENDERBUFFERS_H +#define __GL_RENDERBUFFERS_H + +#include "gl/shaders/gl_shader.h" + +class FGLRenderBuffers +{ +public: + FGLRenderBuffers(); + ~FGLRenderBuffers(); + + void Setup(int width, int height); + void BindSceneFB(); + void BindOutputFB(); + void BindSceneTexture(int index); + + static bool IsSupported() { return gl.version >= 3.3f; } + +private: + int mWidth = 0; + int mHeight = 0; + + GLuint mSceneTexture = 0; + GLuint mSceneDepthStencil = 0; + GLuint mSceneFB = 0; + GLuint mOutputFB = 0; +}; + +#endif \ No newline at end of file diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 0a0049426..6c1677b7b 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -49,6 +49,7 @@ //#include "gl/gl_intern.h" #include "gl/gl_functions.h" #include "vectors.h" +#include "doomstat.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" @@ -56,10 +57,12 @@ #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_renderbuffers.h" #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/shaders/gl_shader.h" +#include "gl/shaders/gl_presentshader.h" #include "gl/textures/gl_texture.h" #include "gl/textures/gl_translate.h" #include "gl/textures/gl_material.h" @@ -69,6 +72,8 @@ #include "gl/models/gl_models.h" #include "gl/dynlights/gl_lightbuffer.h" +EXTERN_CVAR(Int, screenblocks) + //=========================================================================== // // Renderer interface @@ -104,6 +109,9 @@ void gl_FlushModels(); void FGLRenderer::Initialize() { + mBuffers = new FGLRenderBuffers(); + mPresentShader = new FPresentShader(); + // Only needed for the core profile, because someone decided it was a good idea to remove the default VAO. if (gl.version >= 4.0) { @@ -150,7 +158,57 @@ FGLRenderer::~FGLRenderer() glBindVertexArray(0); glDeleteVertexArrays(1, &mVAOID); } + if (mBuffers) delete mBuffers; + if (mPresentShader) delete mPresentShader; +} +//========================================================================== +// +// Calculates the viewport values needed for 2D and 3D operations +// +//========================================================================== + +void FGLRenderer::SetOutputViewport(GL_IRECT *bounds) +{ + if (bounds) + { + mOutputViewport = *bounds; + mOutputViewportLB = *bounds; + return; + } + + int height, width; + + // Special handling so the view with a visible status bar displays properly + + if (screenblocks >= 10) + { + height = framebuffer->GetHeight(); + width = framebuffer->GetWidth(); + } + else + { + height = (screenblocks*framebuffer->GetHeight() / 10) & ~7; + width = (screenblocks*framebuffer->GetWidth() / 10); + } + + int trueheight = framebuffer->GetTrueHeight(); // ugh... + int bars = (trueheight - framebuffer->GetHeight()) / 2; + + int vw = viewwidth; + int vh = viewheight; + + // Letterboxed viewport for the main scene + mOutputViewportLB.left = viewwindowx; + mOutputViewportLB.top = trueheight - bars - (height + viewwindowy - ((height - vh) / 2)); + mOutputViewportLB.width = vw; + mOutputViewportLB.height = height; + + // Entire canvas for player sprites + mOutputViewport.left = 0; + mOutputViewport.top = (trueheight - framebuffer->GetHeight()) / 2; + mOutputViewport.width = framebuffer->GetWidth(); + mOutputViewport.height = framebuffer->GetHeight(); } //=========================================================================== @@ -166,6 +224,17 @@ void FGLRenderer::SetupLevel() void FGLRenderer::Begin2D() { + if (FGLRenderBuffers::IsSupported()) + { + mBuffers->Setup(framebuffer->GetWidth(), framebuffer->GetHeight()); + mBuffers->BindSceneFB(); + glViewport(0, 0, mOutputViewport.width, mOutputViewport.height); + } + else + { + glViewport(mOutputViewport.left, mOutputViewport.top, mOutputViewport.width, mOutputViewport.height); + } + gl_RenderState.EnableFog(false); gl_RenderState.Set2DMode(true); } diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index e8ef87157..992076528 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -18,6 +18,8 @@ class GLPortal; class FLightBuffer; class FSamplerManager; class DPSprite; +class FGLRenderBuffers; +class FPresentShader; inline float DEG2RAD(float deg) { @@ -79,6 +81,9 @@ public: unsigned int mVAOID; int mOldFBID; + FGLRenderBuffers *mBuffers; + FPresentShader *mPresentShader; + FTexture *gllight; FTexture *glpart2; FTexture *glpart; @@ -93,14 +98,17 @@ public: FSkyVertexBuffer *mSkyVBO; FLightBuffer *mLights; + GL_IRECT mOutputViewportLB; + GL_IRECT mOutputViewport; FGLRenderer(OpenGLFrameBuffer *fb); ~FGLRenderer() ; angle_t FrustumAngle(); void SetViewArea(); - void ResetViewport(); - void SetViewport(GL_IRECT *bounds); + void SetOutputViewport(GL_IRECT *bounds); + void Set3DViewport(); + void Reset3DViewport(); sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen); void RenderView(player_t *player); void SetViewAngle(DAngle viewangle); @@ -139,7 +147,7 @@ public: void SetFixedColormap (player_t *player); void WriteSavePic (player_t *player, FILE *file, int width, int height); void EndDrawScene(sector_t * viewsector); - void Flush() {} + void Flush(); void SetProjection(float fov, float ratio, float fovratio); void SetProjection(VSMatrix matrix); // raw matrix input from stereo 3d modes diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 4cb79262e..3f52ce2b1 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -63,6 +63,7 @@ #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_renderbuffers.h" #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/dynlights/gl_dynlight.h" @@ -71,6 +72,7 @@ #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" #include "gl/shaders/gl_shader.h" +#include "gl/shaders/gl_presentshader.h" #include "gl/stereo3d/gl_stereo3d.h" #include "gl/stereo3d/scoped_view_shifter.h" #include "gl/textures/gl_translate.h" @@ -91,9 +93,10 @@ CVAR(Float, gl_mask_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_sprite_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, gl_sort_textures, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -EXTERN_CVAR (Int, screenblocks) EXTERN_CVAR (Bool, cl_capfps) EXTERN_CVAR (Bool, r_deathcamera) +EXTERN_CVAR(Float, vid_brightness) +EXTERN_CVAR(Float, vid_contrast) extern int viewpitch; @@ -155,10 +158,12 @@ void FGLRenderer::SetViewArea() // //----------------------------------------------------------------------------- -void FGLRenderer::ResetViewport() +void FGLRenderer::Reset3DViewport() { - int trueheight = static_cast(screen)->GetTrueHeight(); // ugh... - glViewport(0, (trueheight-screen->GetHeight())/2, screen->GetWidth(), screen->GetHeight()); + if (FGLRenderBuffers::IsSupported()) + glViewport(0, 0, mOutputViewport.width, mOutputViewport.height); + else + glViewport(mOutputViewport.left, mOutputViewport.top, mOutputViewport.width, mOutputViewport.height); } //----------------------------------------------------------------------------- @@ -167,38 +172,22 @@ void FGLRenderer::ResetViewport() // //----------------------------------------------------------------------------- -void FGLRenderer::SetViewport(GL_IRECT *bounds) +void FGLRenderer::Set3DViewport() { - if (!bounds) + const auto &bounds = mOutputViewportLB; + if (FGLRenderBuffers::IsSupported()) { - int height, width; - - // Special handling so the view with a visible status bar displays properly - - if (screenblocks >= 10) - { - height = SCREENHEIGHT; - width = SCREENWIDTH; - } - else - { - height = (screenblocks*SCREENHEIGHT/10) & ~7; - width = (screenblocks*SCREENWIDTH/10); - } - - int trueheight = static_cast(screen)->GetTrueHeight(); // ugh... - int bars = (trueheight-screen->GetHeight())/2; - - int vw = viewwidth; - int vh = viewheight; - glViewport(viewwindowx, trueheight-bars-(height+viewwindowy-((height-vh)/2)), vw, height); - glScissor(viewwindowx, trueheight-bars-(vh+viewwindowy), vw, vh); + mBuffers->Setup(mOutputViewport.width, mOutputViewport.height); + mBuffers->BindSceneFB(); + glViewport(0, 0, bounds.width, bounds.height); + glScissor(0, 0, bounds.width, bounds.height); } else { - glViewport(bounds->left, bounds->top, bounds->width, bounds->height); - glScissor(bounds->left, bounds->top, bounds->width, bounds->height); + glViewport(bounds.left, bounds.top, bounds.width, bounds.height); + glScissor(bounds.left, bounds.top, bounds.width, bounds.height); } + glEnable(GL_SCISSOR_TEST); #ifdef _DEBUG @@ -215,6 +204,97 @@ void FGLRenderer::SetViewport(GL_IRECT *bounds) glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE); } +//----------------------------------------------------------------------------- +// +// Run post processing steps and copy to frame buffer +// +//----------------------------------------------------------------------------- + +void FGLRenderer::Flush() +{ + if (FGLRenderBuffers::IsSupported()) + { + glDisable(GL_MULTISAMPLE); + glDisable(GL_DEPTH_TEST); + glDisable(GL_STENCIL_TEST); + + mBuffers->BindOutputFB(); + + // Calculate letterbox + int clientWidth = framebuffer->GetClientWidth(); + int clientHeight = framebuffer->GetClientHeight(); + float scaleX = clientWidth / (float)mOutputViewport.width; + float scaleY = clientHeight / (float)mOutputViewport.height; + float scale = MIN(scaleX, scaleY); + int width = (int)round(mOutputViewport.width * scale); + int height = (int)round(mOutputViewport.height * scale); + int x = (clientWidth - width) / 2; + int y = (clientHeight - height) / 2; + + // Black bars around the box: + glViewport(0, 0, clientWidth, clientHeight); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glEnable(GL_SCISSOR_TEST); + if (y > 0) + { + glScissor(0, 0, clientWidth, y); + glClear(GL_COLOR_BUFFER_BIT); + } + if (clientHeight - y - height > 0) + { + glScissor(0, y + height, clientWidth, clientHeight - y - height); + glClear(GL_COLOR_BUFFER_BIT); + } + if (x > 0) + { + glScissor(0, y, x, height); + glClear(GL_COLOR_BUFFER_BIT); + } + if (clientWidth - x - width > 0) + { + glScissor(x + width, y, clientWidth - x - width, height); + glClear(GL_COLOR_BUFFER_BIT); + } + glDisable(GL_SCISSOR_TEST); + + // Present what was rendered: + glViewport(x, y, width, height); + + GLboolean blendEnabled; + GLint currentProgram; + glGetBooleanv(GL_BLEND, &blendEnabled); + glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); + glDisable(GL_BLEND); + + mPresentShader->Bind(); + mPresentShader->InputTexture.Set(0); + if (framebuffer->IsHWGammaActive()) + { + mPresentShader->Gamma.Set(1.0f); + mPresentShader->Contrast.Set(1.0f); + mPresentShader->Brightness.Set(0.0f); + } + else + { + mPresentShader->Gamma.Set(clamp(Gamma, 0.1f, 4.f)); + mPresentShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); + mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); + } + mBuffers->BindSceneTexture(0); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; + ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; + ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; + ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + + if (blendEnabled) + glEnable(GL_BLEND); + glUseProgram(currentProgram); + } +} + //----------------------------------------------------------------------------- // // Setup the camera position @@ -707,7 +787,7 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) framebuffer->Begin2D(false); - ResetViewport(); + Reset3DViewport(); // [BB] Only draw the sprites if we didn't render a HUD model before. if ( renderHUDModel == false ) { @@ -846,7 +926,8 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo const s3d::EyePose * eye = stereo3dMode.getEyePose(eye_ix); eye->SetUp(); // TODO: stereo specific viewport - needed when implementing side-by-side modes etc. - SetViewport(bounds); + SetOutputViewport(bounds); + Set3DViewport(); mCurrentFoV = fov; // Stereo mode specific perspective projection SetProjection( eye->GetProjection(fov, ratio, fovratio) ); @@ -873,7 +954,6 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo return retval; } - //----------------------------------------------------------------------------- // // renders the view diff --git a/src/gl/shaders/gl_presentshader.cpp b/src/gl/shaders/gl_presentshader.cpp new file mode 100644 index 000000000..36266ded3 --- /dev/null +++ b/src/gl/shaders/gl_presentshader.cpp @@ -0,0 +1,67 @@ +/* +** gl_presentshader.cpp +** Copy rendered texture to back buffer, possibly with gamma correction +** +**--------------------------------------------------------------------------- +** Copyright 2008 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "gl/gl_functions.h" +#include "vectors.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_presentshader.h" + +void FPresentShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/present.vp"); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/present.fp"); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/present"); + mShader.SetAttribLocation(0, "PositionInProjection"); + InputTexture.Init(mShader, "InputTexture"); + Gamma.Init(mShader, "Gamma"); + Contrast.Init(mShader, "Contrast"); + Brightness.Init(mShader, "Brightness"); + } + mShader.Bind(); +} diff --git a/src/gl/shaders/gl_presentshader.h b/src/gl/shaders/gl_presentshader.h new file mode 100644 index 000000000..6bec79625 --- /dev/null +++ b/src/gl/shaders/gl_presentshader.h @@ -0,0 +1,20 @@ +#ifndef __GL_PRESENTSHADER_H +#define __GL_PRESENTSHADER_H + +#include "gl_shaderprogram.h" + +class FPresentShader +{ +public: + void Bind(); + + FBufferedUniform1i InputTexture; + FBufferedUniform1f Gamma; + FBufferedUniform1f Contrast; + FBufferedUniform1f Brightness; + +private: + FShaderProgram mShader; +}; + +#endif \ No newline at end of file diff --git a/src/gl/shaders/gl_shaderprogram.cpp b/src/gl/shaders/gl_shaderprogram.cpp new file mode 100644 index 000000000..bcbdf0c1a --- /dev/null +++ b/src/gl/shaders/gl_shaderprogram.cpp @@ -0,0 +1,205 @@ +/* +** gl_shaderprogram.cpp +** GLSL shader program compile and link +** +**--------------------------------------------------------------------------- +** Copyright 2008 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "gl/gl_functions.h" +#include "vectors.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_shaderprogram.h" +#include "w_wad.h" +#include "i_system.h" +#include "doomerrors.h" + +//========================================================================== +// +// Free shader program resources +// +//========================================================================== + +FShaderProgram::~FShaderProgram() +{ + if (mProgram != 0) + glDeleteProgram(mProgram); + + for (int i = 0; i < NumShaderTypes; i++) + { + if (mShaders[i] != 0) + glDeleteShader(mShaders[i]); + } +} + +//========================================================================== +// +// Creates an OpenGL shader object for the specified type of shader +// +//========================================================================== + +void FShaderProgram::CreateShader(ShaderType type) +{ + GLenum gltype = 0; + switch (type) + { + default: + case Vertex: gltype = GL_VERTEX_SHADER; break; + case Fragment: gltype = GL_FRAGMENT_SHADER; break; + } + mShaders[type] = glCreateShader(gltype); +} + +//========================================================================== +// +// Compiles a shader and attaches it the program object +// +//========================================================================== + +void FShaderProgram::Compile(ShaderType type, const char *lumpName) +{ + CreateShader(type); + + const auto &handle = mShaders[type]; + + int lump = Wads.CheckNumForFullName(lumpName); + if (lump == -1) I_Error("Unable to load '%s'", lumpName); + FString code = Wads.ReadLump(lump).GetString().GetChars(); + + int lengths[1] = { (int)code.Len() }; + const char *sources[1] = { code.GetChars() }; + glShaderSource(handle, 1, sources, lengths); + + glCompileShader(handle); + + GLint status = 0; + glGetShaderiv(handle, GL_COMPILE_STATUS, &status); + if (status == GL_FALSE) + { + I_Error("Compile Shader '%s':\n%s\n", lumpName, GetShaderInfoLog(handle).GetChars()); + } + else + { + if (mProgram == 0) + mProgram = glCreateProgram(); + glAttachShader(mProgram, handle); + } +} + +//========================================================================== +// +// Binds a fragment output variable to a frame buffer render target +// +//========================================================================== + +void FShaderProgram::SetFragDataLocation(int index, const char *name) +{ + glBindFragDataLocation(mProgram, index, name); +} + +//========================================================================== +// +// Links a program with the compiled shaders +// +//========================================================================== + +void FShaderProgram::Link(const char *name) +{ + glLinkProgram(mProgram); + + GLint status = 0; + glGetProgramiv(mProgram, GL_LINK_STATUS, &status); + if (status == GL_FALSE) + { + I_Error("Link Shader '%s':\n%s\n", name, GetProgramInfoLog(mProgram).GetChars()); + } +} + +//========================================================================== +// +// Set vertex attribute location +// +//========================================================================== + +void FShaderProgram::SetAttribLocation(int index, const char *name) +{ + glBindAttribLocation(mProgram, index, name); +} + +//========================================================================== +// +// Makes the shader the active program +// +//========================================================================== + +void FShaderProgram::Bind() +{ + glUseProgram(mProgram); +} + +//========================================================================== +// +// Returns the shader info log (warnings and compile errors) +// +//========================================================================== + +FString FShaderProgram::GetShaderInfoLog(GLuint handle) +{ + static char buffer[10000]; + GLsizei length = 0; + buffer[0] = 0; + glGetShaderInfoLog(handle, 10000, &length, buffer); + return FString(buffer); +} + +//========================================================================== +// +// Returns the program info log (warnings and compile errors) +// +//========================================================================== + +FString FShaderProgram::GetProgramInfoLog(GLuint handle) +{ + static char buffer[10000]; + GLsizei length = 0; + buffer[0] = 0; + glGetProgramInfoLog(handle, 10000, &length, buffer); + return FString(buffer); +} diff --git a/src/gl/shaders/gl_shaderprogram.h b/src/gl/shaders/gl_shaderprogram.h new file mode 100644 index 000000000..9cc331525 --- /dev/null +++ b/src/gl/shaders/gl_shaderprogram.h @@ -0,0 +1,36 @@ +#ifndef __GL_SHADERPROGRAM_H +#define __GL_SHADERPROGRAM_H + +#include "gl_shader.h" + +class FShaderProgram +{ +public: + ~FShaderProgram(); + + enum ShaderType + { + Vertex, + Fragment, + NumShaderTypes + }; + + void Compile(ShaderType type, const char *lumpName); + void SetFragDataLocation(int index, const char *name); + void Link(const char *name); + void SetAttribLocation(int index, const char *name); + void Bind(); + + operator GLuint() const { return mProgram; } + explicit operator bool() const { return mProgram != 0; } + +private: + void CreateShader(ShaderType type); + FString GetShaderInfoLog(GLuint handle); + FString GetProgramInfoLog(GLuint handle); + + GLuint mProgram = 0; + GLuint mShaders[NumShaderTypes]; +}; + +#endif \ No newline at end of file diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 818084706..1b3a880b2 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -78,6 +78,12 @@ void gl_LoadExtensions(); void gl_PrintStartupLog(); void gl_SetupMenu(); +CUSTOM_CVAR(Int, vid_hwgamma, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (self < 0 || self > 2) self = 2; + if (GLRenderer != NULL && GLRenderer->framebuffer != NULL) GLRenderer->framebuffer->DoSetGamma(); +} + //========================================================================== // // @@ -150,12 +156,13 @@ void OpenGLFrameBuffer::InitializeState() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - int trueH = GetTrueHeight(); - int h = GetHeight(); - glViewport(0, (trueH - h)/2, GetWidth(), GetHeight()); + //int trueH = GetTrueHeight(); + //int h = GetHeight(); + //glViewport(0, (trueH - h)/2, GetWidth(), GetHeight()); - Begin2D(false); GLRenderer->Initialize(); + GLRenderer->SetOutputViewport(nullptr); + Begin2D(false); } //========================================================================== @@ -230,10 +237,11 @@ void OpenGLFrameBuffer::Swap() void OpenGLFrameBuffer::DoSetGamma() { - WORD gammaTable[768]; - - if (m_supportsGamma) + bool useHWGamma = m_supportsGamma && ((vid_hwgamma == 0) || (vid_hwgamma == 2 && IsFullscreen())); + if (useHWGamma) { + WORD gammaTable[768]; + // This formula is taken from Doomsday float gamma = clamp(Gamma, 0.1f, 4.f); float contrast = clamp(vid_contrast, 0.1f, 3.f); @@ -251,6 +259,13 @@ void OpenGLFrameBuffer::DoSetGamma() gammaTable[i] = gammaTable[i + 256] = gammaTable[i + 512] = (WORD)clamp(val*256, 0, 0xffff); } SetGammaTable(gammaTable); + + HWGammaActive = true; + } + else if (HWGammaActive) + { + ResetGammaTable(); + HWGammaActive = false; } } diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index ad25851af..3da60fac4 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -77,7 +77,7 @@ public: void WipeCleanup(); void Swap(); bool Is8BitMode() { return false; } - + bool IsHWGammaActive() const { return HWGammaActive; } private: PalEntry Flash; @@ -107,6 +107,8 @@ private: FHardwareTexture *wipestartscreen; FHardwareTexture *wipeendscreen; + bool HWGammaActive = false; + public: AActor * LastCamera; int palette_brightness; diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 00fc002f3..6b15e0b6d 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -52,7 +52,9 @@ #include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_renderbuffers.h" #include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" #include "gl/shaders/gl_shader.h" #include "gl/textures/gl_translate.h" #include "gl/textures/gl_material.h" @@ -153,11 +155,21 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE, -1); glFinish(); wipestartscreen->Bind(0, false, false); - GLint readbuffer = 0; - glGetIntegerv(GL_READ_BUFFER, &readbuffer); - glReadBuffer(GL_FRONT); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); - glReadBuffer(readbuffer); + + if (FGLRenderBuffers::IsSupported()) + { + GLRenderer->mBuffers->BindSceneFB(); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); + } + else + { + GLint readbuffer = 0; + glGetIntegerv(GL_READ_BUFFER, &readbuffer); + glReadBuffer(GL_FRONT); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); + glReadBuffer(readbuffer); + } + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); @@ -179,6 +191,10 @@ void OpenGLFrameBuffer::WipeEndScreen() GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1); glFinish(); wipeendscreen->Bind(0, false, false); + + if (FGLRenderBuffers::IsSupported()) + GLRenderer->mBuffers->BindSceneFB(); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -214,6 +230,12 @@ bool OpenGLFrameBuffer::WipeDo(int ticks) glDisable(GL_DEPTH_TEST); glDepthMask(false); + if (FGLRenderBuffers::IsSupported()) + { + GLRenderer->mBuffers->BindSceneFB(); + glViewport(0, 0, GLRenderer->mOutputViewport.width, GLRenderer->mOutputViewport.height); + } + bool done = ScreenWipe->Run(ticks, this); glDepthMask(true); //DrawLetterbox(); diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index c3fe258b8..4fa4f5574 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -1239,6 +1239,20 @@ void SDLGLFB::SetGammaTable(WORD* table) { } +void SDLGLFB::ResetGammaTable() +{ +} + +int SDLGLFB::GetClientWidth() +{ + return GetWidth(); +} + +int SDLGLFB::GetClientHeight() +{ + return GetHeight(); +} + // --------------------------------------------------------------------------- diff --git a/src/posix/cocoa/sdlglvideo.h b/src/posix/cocoa/sdlglvideo.h index 439b4d5ce..4a63a9193 100644 --- a/src/posix/cocoa/sdlglvideo.h +++ b/src/posix/cocoa/sdlglvideo.h @@ -62,13 +62,16 @@ public: virtual bool IsFullscreen(); virtual void SetVSync(bool vsync); + int GetClientWidth(); + int GetClientHeight(); + int GetTrueHeight() { return GetHeight(); } protected: int m_lock; bool m_isUpdatePending; - static const bool m_supportsGamma = true; + static const bool m_supportsGamma = false; SDLGLFB(); @@ -78,6 +81,7 @@ protected: void SwapBuffers(); void SetGammaTable(WORD* table); + void ResetGammaTable(); }; #endif // COCOA_SDLGLVIDEO_H_INCLUDED diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 54506b813..aa87f6eb8 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -350,10 +350,7 @@ SDLGLFB::~SDLGLFB () { if (Screen) { - if (m_supportsGamma) - { - SDL_SetWindowGammaRamp(Screen, m_origGamma[0], m_origGamma[1], m_origGamma[2]); - } + ResetGammaTable(); if (GLContext) { @@ -387,7 +384,18 @@ bool SDLGLFB::CanUpdate () void SDLGLFB::SetGammaTable(WORD *tbl) { - SDL_SetWindowGammaRamp(Screen, &tbl[0], &tbl[256], &tbl[512]); + if (m_supportsGamma) + { + SDL_SetWindowGammaRamp(Screen, &tbl[0], &tbl[256], &tbl[512]); + } +} + +void SDLGLFB::ResetGammaTable() +{ + if (m_supportsGamma) + { + SDL_SetWindowGammaRamp(Screen, m_origGamma[0], m_origGamma[1], m_origGamma[2]); + } } bool SDLGLFB::Lock(bool buffered) @@ -447,3 +455,16 @@ void SDLGLFB::SwapBuffers() SDL_GL_SwapWindow (Screen); } +int SDLGLFB::GetClientWidth() +{ + int width = 0; + SDL_GL_GetDrawableSize(Screen, &width, nullptr); + return width; +} + +int SDLGLFB::GetClientHeight() +{ + int height = 0; + SDL_GL_GetDrawableSize(Screen, nullptr, &height); + return width; +} diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h index 19e6a5ff5..0b6a46c12 100644 --- a/src/posix/sdl/sdlglvideo.h +++ b/src/posix/sdl/sdlglvideo.h @@ -58,12 +58,16 @@ public: friend class SDLGLVideo; + int GetClientWidth(); + int GetClientHeight(); + //[C] int GetTrueHeight() { return GetHeight();} protected: bool CanUpdate(); void SetGammaTable(WORD *tbl); + void ResetGammaTable(); void InitializeState(); SDLGLFB () {} diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index fd92694cd..787c0a4f3 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -357,7 +357,7 @@ void I_RestoreWindowedPos () extern int NewWidth, NewHeight, NewBits, DisplayBits; -CUSTOM_CVAR (Bool, fullscreen, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +CUSTOM_CVAR (Bool, fullscreen, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) { NewWidth = screen->GetWidth(); NewHeight = screen->GetHeight(); diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 11c359a32..2e61ae3a6 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -951,7 +951,7 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in style |= WS_POPUP; else { - style |= WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX; + style |= WS_OVERLAPPEDWINDOW; exStyle |= WS_EX_WINDOWEDGE; } @@ -967,7 +967,13 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in } else { - MoveWindow(Window, r.left, r.top, width + (GetSystemMetrics(SM_CXSIZEFRAME) * 2), height + (GetSystemMetrics(SM_CYSIZEFRAME) * 2) + GetSystemMetrics(SM_CYCAPTION), FALSE); + RECT windowRect; + windowRect.left = r.left; + windowRect.top = r.top; + windowRect.right = windowRect.left + width; + windowRect.bottom = windowRect.top + height; + AdjustWindowRectEx(&windowRect, style, FALSE, exStyle); + MoveWindow(Window, windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, FALSE); I_RestoreWindowedPos(); } @@ -993,12 +999,7 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in Win32GLFrameBuffer::~Win32GLFrameBuffer() { - if (m_supportsGamma) - { - HDC hDC = GetDC(Window); - SetDeviceGammaRamp(hDC, (void *)m_origGamma); - ReleaseDC(Window, hDC); - } + ResetGammaTable(); I_SaveWindowedPos(); static_cast(Video)->SetFullscreen(m_displayDeviceName, 0,0,0,0); @@ -1041,11 +1042,24 @@ bool Win32GLFrameBuffer::CanUpdate() // //========================================================================== +void Win32GLFrameBuffer::ResetGammaTable() +{ + if (m_supportsGamma) + { + HDC hDC = GetDC(Window); + SetDeviceGammaRamp(hDC, (void *)m_origGamma); + ReleaseDC(Window, hDC); + } +} + void Win32GLFrameBuffer::SetGammaTable(WORD *tbl) { - HDC hDC = GetDC(Window); - SetDeviceGammaRamp(hDC, (void *)tbl); - ReleaseDC(Window, hDC); + if (m_supportsGamma) + { + HDC hDC = GetDC(Window); + SetDeviceGammaRamp(hDC, (void *)tbl); + ReleaseDC(Window, hDC); + } } //========================================================================== @@ -1152,6 +1166,19 @@ void Win32GLFrameBuffer::NewRefreshRate () } } +int Win32GLFrameBuffer::GetClientWidth() +{ + RECT rect = { 0 }; + GetClientRect(Window, &rect); + return rect.right - rect.left; +} + +int Win32GLFrameBuffer::GetClientHeight() +{ + RECT rect = { 0 }; + GetClientRect(Window, &rect); + return rect.bottom - rect.top; +} IVideo *gl_CreateVideo() { diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index 4ef48ce18..00e6cba81 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -118,6 +118,8 @@ public: void SwapBuffers(); void NewRefreshRate (); + int GetClientWidth(); + int GetClientHeight(); int GetTrueHeight() { return static_cast(Video)->GetTrueHeight(); } @@ -136,6 +138,7 @@ public: protected: bool CanUpdate(); + void ResetGammaTable(); void SetGammaTable(WORD * tbl); float m_Gamma, m_Brightness, m_Contrast; diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index b8abd71ec..30b0f542f 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2281,6 +2281,7 @@ OPTVAL_SINC = "Sinc"; OPTVAL_NOTEONOFFONLY = "Note on/off only"; OPTVAL_FULLRAMPING = "Full ramping"; OPTVAL_ALLUNACKNOWLEDGED = "All unacknowledged"; +OPTVAL_FULLSCREENONLY = "Fullscreen only"; // Colors C_BRICK = "\cabrick"; C_TAN = "\cbtan"; @@ -2562,6 +2563,7 @@ MUSIC_DM2INT = "dm2int"; DSPLYMNU_GLOPT = "OpenGL Options"; DSPLYMNU_GAMMA = "Gamma correction"; DSPLYMNU_CONTRAST ="Contrast"; +DSPLYMNU_HWGAMMA = "Hardware Gamma"; // OpenGL Options GLMNU_TITLE = "OPENGL OPTIONS"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 209d8267c..6a584d292 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -670,6 +670,7 @@ OptionMenu "VideoOptions" Slider "$DSPLYMNU_GAMMA", "Gamma", 0.75, 3.0, 0.05, 2 Slider "$DSPLYMNU_BRIGHTNESS", "vid_brightness", -0.8,0.8, 0.05 Slider "$DSPLYMNU_CONTRAST", "vid_contrast", 0.1, 3.0, 0.1 + Option "$DSPLYMNU_HWGAMMA", "vid_hwgamma", "HWGammaModes" Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff" Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn" diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 59cb94f73..e96f6b55c 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -25,6 +25,13 @@ OptionValue "FilterModes" 4, "$OPTVAL_TRILINEAR" } +OptionValue "HWGammaModes" +{ + 0, "$OPTVAL_ON" + 1, "$OPTVAL_OFF" + 2, "$OPTVAL_FULLSCREENONLY" +} + OptionValue "TextureFormats" { 0, "$OPTVAL_RGBA8" diff --git a/wadsrc/static/shaders/glsl/present.fp b/wadsrc/static/shaders/glsl/present.fp new file mode 100644 index 000000000..93534ba7f --- /dev/null +++ b/wadsrc/static/shaders/glsl/present.fp @@ -0,0 +1,23 @@ + +#version 330 + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D InputTexture; +uniform float Gamma; +uniform float Contrast; +uniform float Brightness; + +vec4 ApplyGamma(vec4 c) +{ + vec3 val = c.rgb * Contrast - (Contrast - 1.0) * 0.5; + val = pow(val, vec3(1.0 / Gamma)); + val += Brightness * 0.5; + return vec4(val, c.a); +} + +void main() +{ + FragColor = ApplyGamma(texture(InputTexture, TexCoord)); +} diff --git a/wadsrc/static/shaders/glsl/present.vp b/wadsrc/static/shaders/glsl/present.vp new file mode 100644 index 000000000..b73fe7fc8 --- /dev/null +++ b/wadsrc/static/shaders/glsl/present.vp @@ -0,0 +1,11 @@ + +#version 330 + +in vec4 PositionInProjection; +out vec2 TexCoord; + +void main() +{ + gl_Position = PositionInProjection; + TexCoord = PositionInProjection.xy * 0.5 + 0.5; +} From e82c38e4f94998cabfbe7b2c0f044cb8b1ea1d47 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 27 Jul 2016 10:23:36 +0200 Subject: [PATCH 0733/1509] Update copyright and typo fix --- src/gl/renderer/gl_renderbuffers.cpp | 2 +- src/gl/shaders/gl_presentshader.cpp | 2 +- src/gl/shaders/gl_shaderprogram.cpp | 2 +- src/posix/sdl/sdlglvideo.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 9468c23ef..26377553f 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -3,7 +3,7 @@ ** Render buffers used during rendering ** **--------------------------------------------------------------------------- -** Copyright 2008 Christoph Oelckers +** Copyright 2016 Magnus Norddahl ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without diff --git a/src/gl/shaders/gl_presentshader.cpp b/src/gl/shaders/gl_presentshader.cpp index 36266ded3..a5d514308 100644 --- a/src/gl/shaders/gl_presentshader.cpp +++ b/src/gl/shaders/gl_presentshader.cpp @@ -3,7 +3,7 @@ ** Copy rendered texture to back buffer, possibly with gamma correction ** **--------------------------------------------------------------------------- -** Copyright 2008 Christoph Oelckers +** Copyright 2016 Magnus Norddahl ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without diff --git a/src/gl/shaders/gl_shaderprogram.cpp b/src/gl/shaders/gl_shaderprogram.cpp index bcbdf0c1a..35fd468ae 100644 --- a/src/gl/shaders/gl_shaderprogram.cpp +++ b/src/gl/shaders/gl_shaderprogram.cpp @@ -3,7 +3,7 @@ ** GLSL shader program compile and link ** **--------------------------------------------------------------------------- -** Copyright 2008 Christoph Oelckers +** Copyright 2016 Magnus Norddahl ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index aa87f6eb8..d79dfb94a 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -466,5 +466,5 @@ int SDLGLFB::GetClientHeight() { int height = 0; SDL_GL_GetDrawableSize(Screen, nullptr, &height); - return width; + return height; } From da1762ac2ca5a485e2a6141f3497adea90ba0416 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 27 Jul 2016 16:27:40 +0200 Subject: [PATCH 0734/1509] - fixed: DoSetMapSection could cause a stack overflow on large maps. Made it iterative instead of recursive to avoid that. --- src/gl/data/gl_setup.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index fb9c2252f..04ed4c427 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -69,26 +69,34 @@ void InitGLRMapinfoData(); // // //========================================================================== +static TArray MapSectionCollector; static void DoSetMapSection(subsector_t *sub, int num) { + MapSectionCollector.Resize(1); + MapSectionCollector[0] = sub; sub->mapsection = num; - - for(DWORD i=0;inumlines;i++) + for (unsigned a = 0; a < MapSectionCollector.Size(); a++) { - seg_t * seg = sub->firstline + i; - - if (seg->PartnerSeg) + sub = MapSectionCollector[a]; + for (DWORD i = 0; i < sub->numlines; i++) { - subsector_t * sub2 = seg->PartnerSeg->Subsector; + seg_t * seg = sub->firstline + i; - if (sub2->mapsection != num) + if (seg->PartnerSeg) { - assert(sub2->mapsection == 0); - DoSetMapSection(sub2, num); + subsector_t * sub2 = seg->PartnerSeg->Subsector; + + if (sub2->mapsection != num) + { + assert(sub2->mapsection == 0); + sub2->mapsection = num; + MapSectionCollector.Push(sub2); + } } } } + MapSectionCollector.Clear(); } //========================================================================== From 69f52cc89800a38406155d9b040642c0fb436b69 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 27 Jul 2016 21:50:30 +0200 Subject: [PATCH 0735/1509] Added bloom shaders --- src/CMakeLists.txt | 2 + src/gl/renderer/gl_renderbuffers.cpp | 74 +++++- src/gl/renderer/gl_renderbuffers.h | 16 ++ src/gl/renderer/gl_renderer.cpp | 8 + src/gl/renderer/gl_renderer.h | 7 + src/gl/scene/gl_scene.cpp | 128 ++++++++++ src/gl/shaders/gl_bloomshader.cpp | 79 ++++++ src/gl/shaders/gl_bloomshader.h | 29 +++ src/gl/shaders/gl_blurshader.cpp | 265 +++++++++++++++++++++ src/gl/shaders/gl_blurshader.h | 39 +++ src/gl/shaders/gl_shaderprogram.cpp | 14 +- src/gl/shaders/gl_shaderprogram.h | 1 + wadsrc/static/shaders/glsl/bloomcombine.fp | 12 + wadsrc/static/shaders/glsl/bloomcombine.vp | 11 + wadsrc/static/shaders/glsl/bloomextract.fp | 14 ++ wadsrc/static/shaders/glsl/bloomextract.vp | 11 + 16 files changed, 696 insertions(+), 14 deletions(-) create mode 100644 src/gl/shaders/gl_bloomshader.cpp create mode 100644 src/gl/shaders/gl_bloomshader.h create mode 100644 src/gl/shaders/gl_blurshader.cpp create mode 100644 src/gl/shaders/gl_blurshader.h create mode 100644 wadsrc/static/shaders/glsl/bloomcombine.fp create mode 100644 wadsrc/static/shaders/glsl/bloomcombine.vp create mode 100644 wadsrc/static/shaders/glsl/bloomextract.fp create mode 100644 wadsrc/static/shaders/glsl/bloomextract.vp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cad329962..4e7ae8cbb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1106,6 +1106,8 @@ set( FASTMATH_SOURCES gl/shaders/gl_texshader.cpp gl/shaders/gl_shaderprogram.cpp gl/shaders/gl_presentshader.cpp + gl/shaders/gl_bloomshader.cpp + gl/shaders/gl_blurshader.cpp gl/system/gl_interface.cpp gl/system/gl_framebuffer.cpp gl/system/gl_menu.cpp diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 26377553f..52182c9da 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -72,12 +72,37 @@ FGLRenderBuffers::FGLRenderBuffers() FGLRenderBuffers::~FGLRenderBuffers() { + Clear(); +} + +void FGLRenderBuffers::Clear() +{ + for (int i = 0; i < NumBloomLevels; i++) + { + auto &level = BloomLevels[i]; + if (level.HFramebuffer != 0) + glDeleteFramebuffers(1, &level.HFramebuffer); + if (level.VFramebuffer != 0) + glDeleteFramebuffers(1, &level.VFramebuffer); + if (level.HTexture != 0) + glDeleteTextures(1, &level.HTexture); + if (level.VTexture != 0) + glDeleteTextures(1, &level.VTexture); + level = FGLBloomTextureLevel(); + } + if (mSceneFB != 0) glDeleteFramebuffers(1, &mSceneFB); if (mSceneTexture != 0) glDeleteTextures(1, &mSceneTexture); if (mSceneDepthStencil != 0) glDeleteRenderbuffers(1, &mSceneDepthStencil); + + mSceneFB = 0; + mSceneTexture = 0; + mSceneDepthStencil = 0; + mWidth = 0; + mHeight = 0; } //========================================================================== @@ -92,12 +117,9 @@ void FGLRenderBuffers::Setup(int width, int height) if (width <= mWidth && height <= mHeight) return; - if (mSceneFB != 0) - glDeleteFramebuffers(1, &mSceneFB); - if (mSceneTexture != 0) - glDeleteTextures(1, &mSceneTexture); - if (mSceneDepthStencil != 0) - glDeleteRenderbuffers(1, &mSceneDepthStencil); + Clear(); + + glActiveTexture(GL_TEXTURE0); glGenFramebuffers(1, &mSceneFB); glGenTextures(1, &mSceneTexture); @@ -109,15 +131,49 @@ void FGLRenderBuffers::Setup(int width, int height) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glBindTexture(GL_TEXTURE_2D, 0); glBindRenderbuffer(GL_RENDERBUFFER, mSceneDepthStencil); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); - glBindRenderbuffer(GL_RENDERBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, mSceneFB); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mSceneTexture, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mSceneDepthStencil); + + int bloomWidth = MAX(width / 2, 1); + int bloomHeight = MAX(height / 2, 1); + for (int i = 0; i < NumBloomLevels; i++) + { + auto &level = BloomLevels[i]; + level.Width = MAX(bloomWidth / 2, 1); + level.Height = MAX(bloomHeight / 2, 1); + + glGenTextures(1, &level.VTexture); + glGenTextures(1, &level.HTexture); + glGenFramebuffers(1, &level.VFramebuffer); + glGenFramebuffers(1, &level.HFramebuffer); + + glBindTexture(GL_TEXTURE_2D, level.VTexture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, level.Width, level.Height, 0, GL_RGBA, GL_FLOAT, nullptr); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glBindTexture(GL_TEXTURE_2D, level.HTexture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, level.Width, level.Height, 0, GL_RGBA, GL_FLOAT, nullptr); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glBindFramebuffer(GL_FRAMEBUFFER, level.VFramebuffer); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, level.VTexture, 0); + + glBindFramebuffer(GL_FRAMEBUFFER, level.HFramebuffer); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, level.HTexture, 0); + + bloomWidth = level.Width; + bloomHeight = level.Height; + } + + glBindTexture(GL_TEXTURE_2D, 0); + glBindRenderbuffer(GL_RENDERBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, mOutputFB); mWidth = width; @@ -154,6 +210,6 @@ void FGLRenderBuffers::BindOutputFB() void FGLRenderBuffers::BindSceneTexture(int index) { - glActiveTexture(index); + glActiveTexture(GL_TEXTURE0 + index); glBindTexture(GL_TEXTURE_2D, mSceneTexture); } diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index bbb38b533..611d196d2 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -3,6 +3,17 @@ #include "gl/shaders/gl_shader.h" +class FGLBloomTextureLevel +{ +public: + GLuint VTexture = 0; + GLuint VFramebuffer = 0; + GLuint HTexture = 0; + GLuint HFramebuffer = 0; + GLuint Width = 0; + GLuint Height = 0; +}; + class FGLRenderBuffers { public: @@ -16,7 +27,12 @@ public: static bool IsSupported() { return gl.version >= 3.3f; } + enum { NumBloomLevels = 4 }; + FGLBloomTextureLevel BloomLevels[NumBloomLevels]; + private: + void Clear(); + int mWidth = 0; int mHeight = 0; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 6c1677b7b..2eed18bb9 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -62,6 +62,8 @@ #include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/shaders/gl_shader.h" +#include "gl/shaders/gl_bloomshader.h" +#include "gl/shaders/gl_blurshader.h" #include "gl/shaders/gl_presentshader.h" #include "gl/textures/gl_texture.h" #include "gl/textures/gl_translate.h" @@ -110,6 +112,9 @@ void gl_FlushModels(); void FGLRenderer::Initialize() { mBuffers = new FGLRenderBuffers(); + mBloomExtractShader = new FBloomExtractShader(); + mBloomCombineShader = new FBloomCombineShader(); + mBlurShader = new FBlurShader(); mPresentShader = new FPresentShader(); // Only needed for the core profile, because someone decided it was a good idea to remove the default VAO. @@ -160,6 +165,9 @@ FGLRenderer::~FGLRenderer() } if (mBuffers) delete mBuffers; if (mPresentShader) delete mPresentShader; + if (mBloomExtractShader) delete mBloomExtractShader; + if (mBloomCombineShader) delete mBloomCombineShader; + if (mBlurShader) delete mBlurShader; } //========================================================================== diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 992076528..6635c2353 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -19,6 +19,9 @@ class FLightBuffer; class FSamplerManager; class DPSprite; class FGLRenderBuffers; +class FBloomExtractShader; +class FBloomCombineShader; +class FBlurShader; class FPresentShader; inline float DEG2RAD(float deg) @@ -82,6 +85,9 @@ public: int mOldFBID; FGLRenderBuffers *mBuffers; + FBloomExtractShader *mBloomExtractShader; + FBloomCombineShader *mBloomCombineShader; + FBlurShader *mBlurShader; FPresentShader *mPresentShader; FTexture *gllight; @@ -147,6 +153,7 @@ public: void SetFixedColormap (player_t *player); void WriteSavePic (player_t *player, FILE *file, int width, int height); void EndDrawScene(sector_t * viewsector); + void BloomScene(); void Flush(); void SetProjection(float fov, float ratio, float fovratio); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 3f52ce2b1..0aa9f0444 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -72,6 +72,8 @@ #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" #include "gl/shaders/gl_shader.h" +#include "gl/shaders/gl_bloomshader.h" +#include "gl/shaders/gl_blurshader.h" #include "gl/shaders/gl_presentshader.h" #include "gl/stereo3d/gl_stereo3d.h" #include "gl/stereo3d/scoped_view_shifter.h" @@ -204,6 +206,130 @@ void FGLRenderer::Set3DViewport() glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE); } +//----------------------------------------------------------------------------- +// +// Adds bloom contribution to scene texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::BloomScene() +{ + if (!FGLRenderBuffers::IsSupported()) + return; + + const float blurAmount = 4.0f; + int sampleCount = 5; // Note: must be uneven number 3 to 15 + float exposure = 2.0f; + + auto vbo = GLRenderer->mVBO; + + // TODO: Need a better way to share state with other parts of the pipeline + GLboolean blendEnabled, scissorEnabled; + GLint currentProgram, blendEquationRgb, blendEquationAlpha, blendSrcRgb, blendSrcAlpha, blendDestRgb, blendDestAlpha; + glGetBooleanv(GL_BLEND, &blendEnabled); + glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); + glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); + glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRgb); + glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); + glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRgb); + glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); + glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRgb); + glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); + + glDisable(GL_BLEND); + glDisable(GL_SCISSOR_TEST); + + const auto &level0 = mBuffers->BloomLevels[0]; + + // Extract blooming pixels from scene texture: + glBindFramebuffer(GL_FRAMEBUFFER, level0.VFramebuffer); + glViewport(0, 0, level0.Width, level0.Height); + mBuffers->BindSceneTexture(0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mBloomExtractShader->Bind(); + mBloomExtractShader->SceneTexture.Set(0); + mBloomExtractShader->Exposure.Set(exposure); + { + FFlatVertex *ptr = vbo->GetBuffer(); + ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; + ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; + ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; + ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; + vbo->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + // Blur and downscale: + for (int i = 0; i < FGLRenderBuffers::NumBloomLevels - 1; i++) + { + const auto &level = mBuffers->BloomLevels[i]; + const auto &next = mBuffers->BloomLevels[i + 1]; + mBlurShader->BlurHorizontal(vbo, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); + mBlurShader->BlurVertical(vbo, blurAmount, sampleCount, level.HTexture, next.VFramebuffer, next.Width, next.Height); + } + + // Blur and upscale: + for (int i = FGLRenderBuffers::NumBloomLevels - 1; i > 0; i--) + { + const auto &level = mBuffers->BloomLevels[i]; + const auto &next = mBuffers->BloomLevels[i - 1]; + + mBlurShader->BlurHorizontal(vbo, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); + mBlurShader->BlurVertical(vbo, blurAmount, sampleCount, level.HTexture, level.VFramebuffer, level.Width, level.Height); + + // Linear upscale: + glBindFramebuffer(GL_FRAMEBUFFER, next.VFramebuffer); + glViewport(0, 0, next.Width, next.Height); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, level.VTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mBloomCombineShader->Bind(); + mBloomCombineShader->BloomTexture.Set(0); + { + FFlatVertex *ptr = vbo->GetBuffer(); + ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; + ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; + ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; + ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; + vbo->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } + } + + mBlurShader->BlurHorizontal(vbo, blurAmount, sampleCount, level0.VTexture, level0.HFramebuffer, level0.Width, level0.Height); + mBlurShader->BlurVertical(vbo, blurAmount, sampleCount, level0.HTexture, level0.VFramebuffer, level0.Width, level0.Height); + + // Add bloom back to scene texture: + mBuffers->BindSceneFB(); + glViewport(0, 0, mOutputViewport.width, mOutputViewport.height); + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + glBlendFunc(GL_ONE, GL_ONE); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, level0.VTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mBloomCombineShader->Bind(); + mBloomCombineShader->BloomTexture.Set(0); + { + FFlatVertex *ptr = vbo->GetBuffer(); + ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; + ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; + ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; + ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; + vbo->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } + + if (blendEnabled) + glEnable(GL_BLEND); + if (scissorEnabled) + glEnable(GL_SCISSOR_TEST); + glBlendEquationSeparate(blendEquationRgb, blendEquationAlpha); + glBlendFuncSeparate(blendSrcRgb, blendDestRgb, blendSrcAlpha, blendDestAlpha); +} + //----------------------------------------------------------------------------- // // Run post processing steps and copy to frame buffer @@ -810,6 +936,8 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) gl_RenderState.ResetColor(); gl_RenderState.EnableTexture(true); glDisable(GL_SCISSOR_TEST); + + BloomScene(); } diff --git a/src/gl/shaders/gl_bloomshader.cpp b/src/gl/shaders/gl_bloomshader.cpp new file mode 100644 index 000000000..23cda96b7 --- /dev/null +++ b/src/gl/shaders/gl_bloomshader.cpp @@ -0,0 +1,79 @@ +/* +** gl_bloomshader.cpp +** Shaders used to do bloom +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "gl/gl_functions.h" +#include "vectors.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_bloomshader.h" + +void FBloomExtractShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/bloomextract.vp"); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomextract.fp"); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/bloomextract"); + mShader.SetAttribLocation(0, "PositionInProjection"); + SceneTexture.Init(mShader, "SceneTexture"); + Exposure.Init(mShader, "ExposureAdjustment"); + } + mShader.Bind(); +} + +void FBloomCombineShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/bloomcombine.vp"); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomcombine.fp"); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/bloomcombine"); + mShader.SetAttribLocation(0, "PositionInProjection"); + BloomTexture.Init(mShader, "Bloom"); + } + mShader.Bind(); +} diff --git a/src/gl/shaders/gl_bloomshader.h b/src/gl/shaders/gl_bloomshader.h new file mode 100644 index 000000000..a8e93df83 --- /dev/null +++ b/src/gl/shaders/gl_bloomshader.h @@ -0,0 +1,29 @@ +#ifndef __GL_BLOOMSHADER_H +#define __GL_BLOOMSHADER_H + +#include "gl_shaderprogram.h" + +class FBloomExtractShader +{ +public: + void Bind(); + + FBufferedUniform1i SceneTexture; + FBufferedUniform1f Exposure; + +private: + FShaderProgram mShader; +}; + +class FBloomCombineShader +{ +public: + void Bind(); + + FBufferedUniform1i BloomTexture; + +private: + FShaderProgram mShader; +}; + +#endif \ No newline at end of file diff --git a/src/gl/shaders/gl_blurshader.cpp b/src/gl/shaders/gl_blurshader.cpp new file mode 100644 index 000000000..6ed7573ee --- /dev/null +++ b/src/gl/shaders/gl_blurshader.cpp @@ -0,0 +1,265 @@ +/* +** gl_blurshader.cpp +** Gaussian blur shader +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "gl/gl_functions.h" +#include "vectors.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_blurshader.h" +#include "gl/data/gl_vertexbuffer.h" + +//========================================================================== +// +// Performs a vertical gaussian blur pass +// +//========================================================================== + +void FBlurShader::BlurVertical(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height) +{ + Blur(vbo, blurAmount, sampleCount, inputTexture, outputFrameBuffer, width, height, true); +} + +//========================================================================== +// +// Performs a horizontal gaussian blur pass +// +//========================================================================== + +void FBlurShader::BlurHorizontal(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height) +{ + Blur(vbo, blurAmount, sampleCount, inputTexture, outputFrameBuffer, width, height, false); +} + +//========================================================================== +// +// Helper for BlurVertical and BlurHorizontal. Executes the actual pass +// +//========================================================================== + +void FBlurShader::Blur(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height, bool vertical) +{ + int error = glGetError(); + BlurSetup *setup = GetSetup(blurAmount, sampleCount); + error = glGetError(); + if (vertical) + setup->VerticalShader->Bind(); + else + setup->HorizontalShader->Bind(); + error = glGetError(); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, inputTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + error = glGetError(); + glBindFramebuffer(GL_FRAMEBUFFER, outputFrameBuffer); + glViewport(0, 0, width, height); + glDisable(GL_BLEND); + error = glGetError(); + FFlatVertex *ptr = vbo->GetBuffer(); + ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; + ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; + ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; + ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; + vbo->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + error = glGetError(); +} + +//========================================================================== +// +// Compiles the blur shaders needed for the specified blur amount and +// kernel size +// +//========================================================================== + +FBlurShader::BlurSetup *FBlurShader::GetSetup(float blurAmount, int sampleCount) +{ + for (size_t mBlurSetupIndex = 0; mBlurSetupIndex < mBlurSetups.Size(); mBlurSetupIndex++) + { + if (mBlurSetups[mBlurSetupIndex].blurAmount == blurAmount && mBlurSetups[mBlurSetupIndex].sampleCount == sampleCount) + { + return &mBlurSetups[mBlurSetupIndex]; + } + } + + BlurSetup blurSetup(blurAmount, sampleCount); + + FString vertexCode = VertexShaderCode(); + FString horizontalCode = FragmentShaderCode(blurAmount, sampleCount, false); + FString verticalCode = FragmentShaderCode(blurAmount, sampleCount, true); + + blurSetup.VerticalShader = std::make_shared(); + blurSetup.VerticalShader->Compile(FShaderProgram::Vertex, "vertical blur vertex shader", vertexCode); + blurSetup.VerticalShader->Compile(FShaderProgram::Fragment, "vertical blur fragment shader", verticalCode); + blurSetup.VerticalShader->SetFragDataLocation(0, "FragColor"); + blurSetup.VerticalShader->SetAttribLocation(0, "PositionInProjection"); + blurSetup.VerticalShader->Link("vertical blur"); + blurSetup.VerticalShader->Bind(); + int error = glGetError(); + glUniform1i(glGetUniformLocation(*blurSetup.VerticalShader.get(), "SourceTexture"), 0); + error = glGetError(); + + blurSetup.HorizontalShader = std::make_shared(); + blurSetup.HorizontalShader->Compile(FShaderProgram::Vertex, "horizontal blur vertex shader", vertexCode); + blurSetup.HorizontalShader->Compile(FShaderProgram::Fragment, "horizontal blur fragment shader", horizontalCode); + blurSetup.HorizontalShader->SetFragDataLocation(0, "FragColor"); + blurSetup.HorizontalShader->SetAttribLocation(0, "PositionInProjection"); + blurSetup.HorizontalShader->Link("horizontal blur"); + blurSetup.HorizontalShader->Bind(); + glUniform1i(glGetUniformLocation(*blurSetup.HorizontalShader.get(), "SourceTexture"), 0); + + mBlurSetups.Push(blurSetup); + + return &mBlurSetups[mBlurSetups.Size() - 1]; +} + +//========================================================================== +// +// The vertex shader GLSL code +// +//========================================================================== + +FString FBlurShader::VertexShaderCode() +{ + return R"( + #version 330 + + in vec4 PositionInProjection; + out vec2 TexCoord; + + void main() + { + gl_Position = PositionInProjection; + TexCoord = (gl_Position.xy + 1.0) * 0.5; + } + )"; +} + +//========================================================================== +// +// Generates the fragment shader GLSL code for a specific blur setup +// +//========================================================================== + +FString FBlurShader::FragmentShaderCode(float blurAmount, int sampleCount, bool vertical) +{ + TArray sampleWeights; + TArray sampleOffsets; + ComputeBlurSamples(sampleCount, blurAmount, sampleWeights, sampleOffsets); + + const char *fragmentShader = + R"( + #version 330 + in vec2 TexCoord; + uniform sampler2D SourceTexture; + out vec4 FragColor; + void main() + { + FragColor = %s; + } + )"; + + FString loopCode; + for (int i = 0; i < sampleCount; i++) + { + if (i > 0) + loopCode += " + "; + + if (vertical) + loopCode.AppendFormat("\r\n\t\t\ttextureOffset(SourceTexture, TexCoord, ivec2(0, %d)) * %f", sampleOffsets[i], (double)sampleWeights[i]); + else + loopCode.AppendFormat("\r\n\t\t\ttextureOffset(SourceTexture, TexCoord, ivec2(%d, 0)) * %f", sampleOffsets[i], (double)sampleWeights[i]); + } + + FString code; + code.Format(fragmentShader, loopCode.GetChars()); + return code; +} + +//========================================================================== +// +// Calculates the sample weight for a specific offset in the kernel +// +//========================================================================== + +float FBlurShader::ComputeGaussian(float n, float theta) // theta = Blur Amount +{ + return (float)((1.0f / sqrtf(2 * (float)M_PI * theta)) * expf(-(n * n) / (2.0f * theta * theta))); +} + +//========================================================================== +// +// Calculates the sample weights and offsets +// +//========================================================================== + +void FBlurShader::ComputeBlurSamples(int sampleCount, float blurAmount, TArray &sampleWeights, TArray &sampleOffsets) +{ + sampleWeights.Resize(sampleCount); + sampleOffsets.Resize(sampleCount); + + sampleWeights[0] = ComputeGaussian(0, blurAmount); + sampleOffsets[0] = 0; + + float totalWeights = sampleWeights[0]; + + for (int i = 0; i < sampleCount / 2; i++) + { + float weight = ComputeGaussian(i + 1.0f, blurAmount); + + sampleWeights[i * 2 + 1] = weight; + sampleWeights[i * 2 + 2] = weight; + sampleOffsets[i * 2 + 1] = i + 1; + sampleOffsets[i * 2 + 2] = -i - 1; + + totalWeights += weight * 2; + } + + for (int i = 0; i < sampleCount; i++) + { + sampleWeights[i] /= totalWeights; + } +} diff --git a/src/gl/shaders/gl_blurshader.h b/src/gl/shaders/gl_blurshader.h new file mode 100644 index 000000000..9bf4a9d5d --- /dev/null +++ b/src/gl/shaders/gl_blurshader.h @@ -0,0 +1,39 @@ +#ifndef __GL_BLURSHADER_H +#define __GL_BLURSHADER_H + +#include "gl_shaderprogram.h" +#include + +class FFlatVertexBuffer; + +class FBlurShader +{ +public: + void BlurVertical(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height); + void BlurHorizontal(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height); + +private: + void Blur(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height, bool vertical); + + struct BlurSetup + { + BlurSetup(float blurAmount, int sampleCount) : blurAmount(blurAmount), sampleCount(sampleCount) { } + + float blurAmount; + int sampleCount; + std::shared_ptr VerticalShader; + std::shared_ptr HorizontalShader; + }; + + BlurSetup *GetSetup(float blurAmount, int sampleCount); + + FString VertexShaderCode(); + FString FragmentShaderCode(float blurAmount, int sampleCount, bool vertical); + + float ComputeGaussian(float n, float theta); + void ComputeBlurSamples(int sampleCount, float blurAmount, TArray &sample_weights, TArray &sample_offsets); + + TArray mBlurSetups; +}; + +#endif \ No newline at end of file diff --git a/src/gl/shaders/gl_shaderprogram.cpp b/src/gl/shaders/gl_shaderprogram.cpp index 35fd468ae..4448bdf59 100644 --- a/src/gl/shaders/gl_shaderprogram.cpp +++ b/src/gl/shaders/gl_shaderprogram.cpp @@ -95,13 +95,17 @@ void FShaderProgram::CreateShader(ShaderType type) void FShaderProgram::Compile(ShaderType type, const char *lumpName) { - CreateShader(type); - - const auto &handle = mShaders[type]; - int lump = Wads.CheckNumForFullName(lumpName); if (lump == -1) I_Error("Unable to load '%s'", lumpName); FString code = Wads.ReadLump(lump).GetString().GetChars(); + Compile(type, lumpName, code); +} + +void FShaderProgram::Compile(ShaderType type, const char *name, const FString &code) +{ + CreateShader(type); + + const auto &handle = mShaders[type]; int lengths[1] = { (int)code.Len() }; const char *sources[1] = { code.GetChars() }; @@ -113,7 +117,7 @@ void FShaderProgram::Compile(ShaderType type, const char *lumpName) glGetShaderiv(handle, GL_COMPILE_STATUS, &status); if (status == GL_FALSE) { - I_Error("Compile Shader '%s':\n%s\n", lumpName, GetShaderInfoLog(handle).GetChars()); + I_Error("Compile Shader '%s':\n%s\n", name, GetShaderInfoLog(handle).GetChars()); } else { diff --git a/src/gl/shaders/gl_shaderprogram.h b/src/gl/shaders/gl_shaderprogram.h index 9cc331525..8aebf1623 100644 --- a/src/gl/shaders/gl_shaderprogram.h +++ b/src/gl/shaders/gl_shaderprogram.h @@ -16,6 +16,7 @@ public: }; void Compile(ShaderType type, const char *lumpName); + void Compile(ShaderType type, const char *name, const FString &code); void SetFragDataLocation(int index, const char *name); void Link(const char *name); void SetAttribLocation(int index, const char *name); diff --git a/wadsrc/static/shaders/glsl/bloomcombine.fp b/wadsrc/static/shaders/glsl/bloomcombine.fp new file mode 100644 index 000000000..0db4802f0 --- /dev/null +++ b/wadsrc/static/shaders/glsl/bloomcombine.fp @@ -0,0 +1,12 @@ + +#version 330 + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D Bloom; + +void main() +{ + FragColor = vec4(texture(Bloom, TexCoord).rgb, 0.0); +} diff --git a/wadsrc/static/shaders/glsl/bloomcombine.vp b/wadsrc/static/shaders/glsl/bloomcombine.vp new file mode 100644 index 000000000..b73fe7fc8 --- /dev/null +++ b/wadsrc/static/shaders/glsl/bloomcombine.vp @@ -0,0 +1,11 @@ + +#version 330 + +in vec4 PositionInProjection; +out vec2 TexCoord; + +void main() +{ + gl_Position = PositionInProjection; + TexCoord = PositionInProjection.xy * 0.5 + 0.5; +} diff --git a/wadsrc/static/shaders/glsl/bloomextract.fp b/wadsrc/static/shaders/glsl/bloomextract.fp new file mode 100644 index 000000000..b6d663db6 --- /dev/null +++ b/wadsrc/static/shaders/glsl/bloomextract.fp @@ -0,0 +1,14 @@ + +#version 330 + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D SceneTexture; +uniform float ExposureAdjustment; + +void main() +{ + vec4 color = texture(SceneTexture, TexCoord); + FragColor = max(vec4(color.rgb * ExposureAdjustment - 1, 1), vec4(0)); +} diff --git a/wadsrc/static/shaders/glsl/bloomextract.vp b/wadsrc/static/shaders/glsl/bloomextract.vp new file mode 100644 index 000000000..b73fe7fc8 --- /dev/null +++ b/wadsrc/static/shaders/glsl/bloomextract.vp @@ -0,0 +1,11 @@ + +#version 330 + +in vec4 PositionInProjection; +out vec2 TexCoord; + +void main() +{ + gl_Position = PositionInProjection; + TexCoord = PositionInProjection.xy * 0.5 + 0.5; +} From 0efee85bd835fb0fffe73cf9a519ace5ff595abb Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 29 Jul 2016 00:36:43 +0200 Subject: [PATCH 0736/1509] Added tonemapping and sector based exposure control --- src/CMakeLists.txt | 1 + src/gl/renderer/gl_renderbuffers.cpp | 41 ++++++++++++++ src/gl/renderer/gl_renderbuffers.h | 4 ++ src/gl/renderer/gl_renderer.cpp | 8 ++- src/gl/renderer/gl_renderer.h | 5 ++ src/gl/scene/gl_scene.cpp | 79 +++++++++++++++++++++------ src/gl/shaders/gl_blurshader.cpp | 11 +--- src/gl/shaders/gl_tonemapshader.cpp | 65 ++++++++++++++++++++++ src/gl/shaders/gl_tonemapshader.h | 18 ++++++ src/gl/system/gl_wipe.cpp | 6 +- wadsrc/static/shaders/glsl/tonemap.fp | 65 ++++++++++++++++++++++ wadsrc/static/shaders/glsl/tonemap.vp | 11 ++++ 12 files changed, 284 insertions(+), 30 deletions(-) create mode 100644 src/gl/shaders/gl_tonemapshader.cpp create mode 100644 src/gl/shaders/gl_tonemapshader.h create mode 100644 wadsrc/static/shaders/glsl/tonemap.fp create mode 100644 wadsrc/static/shaders/glsl/tonemap.vp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4e7ae8cbb..6009a2c37 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1108,6 +1108,7 @@ set( FASTMATH_SOURCES gl/shaders/gl_presentshader.cpp gl/shaders/gl_bloomshader.cpp gl/shaders/gl_blurshader.cpp + gl/shaders/gl_tonemapshader.cpp gl/system/gl_interface.cpp gl/system/gl_framebuffer.cpp gl/system/gl_menu.cpp diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 52182c9da..590ea3935 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -97,10 +97,16 @@ void FGLRenderBuffers::Clear() glDeleteTextures(1, &mSceneTexture); if (mSceneDepthStencil != 0) glDeleteRenderbuffers(1, &mSceneDepthStencil); + if (mHudFB != 0) + glDeleteFramebuffers(1, &mHudFB); + if (mHudTexture != 0) + glDeleteTextures(1, &mHudTexture); mSceneFB = 0; mSceneTexture = 0; mSceneDepthStencil = 0; + mHudFB = 0; + mHudTexture = 0; mWidth = 0; mHeight = 0; } @@ -122,7 +128,9 @@ void FGLRenderBuffers::Setup(int width, int height) glActiveTexture(GL_TEXTURE0); glGenFramebuffers(1, &mSceneFB); + glGenFramebuffers(1, &mHudFB); glGenTextures(1, &mSceneTexture); + glGenTextures(1, &mHudTexture); glGenRenderbuffers(1, &mSceneDepthStencil); glBindTexture(GL_TEXTURE_2D, mSceneTexture); @@ -139,6 +147,16 @@ void FGLRenderBuffers::Setup(int width, int height) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mSceneTexture, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mSceneDepthStencil); + glBindTexture(GL_TEXTURE_2D, mHudTexture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT, nullptr); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glBindFramebuffer(GL_FRAMEBUFFER, mHudFB); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mHudTexture, 0); + int bloomWidth = MAX(width / 2, 1); int bloomHeight = MAX(height / 2, 1); for (int i = 0; i < NumBloomLevels; i++) @@ -191,6 +209,17 @@ void FGLRenderBuffers::BindSceneFB() glBindFramebuffer(GL_FRAMEBUFFER, mSceneFB); } +//========================================================================== +// +// Makes the 2D/HUD frame buffer active +// +//========================================================================== + +void FGLRenderBuffers::BindHudFB() +{ + glBindFramebuffer(GL_FRAMEBUFFER, mHudFB); +} + //========================================================================== // // Makes the screen frame buffer active @@ -213,3 +242,15 @@ void FGLRenderBuffers::BindSceneTexture(int index) glActiveTexture(GL_TEXTURE0 + index); glBindTexture(GL_TEXTURE_2D, mSceneTexture); } + +//========================================================================== +// +// Binds the 2D/HUD frame buffer texture to the specified texture unit +// +//========================================================================== + +void FGLRenderBuffers::BindHudTexture(int index) +{ + glActiveTexture(GL_TEXTURE0 + index); + glBindTexture(GL_TEXTURE_2D, mHudTexture); +} diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 611d196d2..24d301d52 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -22,8 +22,10 @@ public: void Setup(int width, int height); void BindSceneFB(); + void BindHudFB(); void BindOutputFB(); void BindSceneTexture(int index); + void BindHudTexture(int index); static bool IsSupported() { return gl.version >= 3.3f; } @@ -39,6 +41,8 @@ private: GLuint mSceneTexture = 0; GLuint mSceneDepthStencil = 0; GLuint mSceneFB = 0; + GLuint mHudTexture = 0; + GLuint mHudFB = 0; GLuint mOutputFB = 0; }; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 2eed18bb9..264ff4c7f 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -64,6 +64,7 @@ #include "gl/shaders/gl_shader.h" #include "gl/shaders/gl_bloomshader.h" #include "gl/shaders/gl_blurshader.h" +#include "gl/shaders/gl_tonemapshader.h" #include "gl/shaders/gl_presentshader.h" #include "gl/textures/gl_texture.h" #include "gl/textures/gl_translate.h" @@ -115,6 +116,7 @@ void FGLRenderer::Initialize() mBloomExtractShader = new FBloomExtractShader(); mBloomCombineShader = new FBloomCombineShader(); mBlurShader = new FBlurShader(); + mTonemapShader = new FTonemapShader(); mPresentShader = new FPresentShader(); // Only needed for the core profile, because someone decided it was a good idea to remove the default VAO. @@ -168,6 +170,7 @@ FGLRenderer::~FGLRenderer() if (mBloomExtractShader) delete mBloomExtractShader; if (mBloomCombineShader) delete mBloomCombineShader; if (mBlurShader) delete mBlurShader; + if (mTonemapShader) delete mTonemapShader; } //========================================================================== @@ -235,7 +238,10 @@ void FGLRenderer::Begin2D() if (FGLRenderBuffers::IsSupported()) { mBuffers->Setup(framebuffer->GetWidth(), framebuffer->GetHeight()); - mBuffers->BindSceneFB(); + if (mDrawingScene2D) + mBuffers->BindSceneFB(); + else + mBuffers->BindHudFB(); glViewport(0, 0, mOutputViewport.width, mOutputViewport.height); } else diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 6635c2353..39eddcbf0 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -22,6 +22,7 @@ class FGLRenderBuffers; class FBloomExtractShader; class FBloomCombineShader; class FBlurShader; +class FTonemapShader; class FPresentShader; inline float DEG2RAD(float deg) @@ -88,6 +89,7 @@ public: FBloomExtractShader *mBloomExtractShader; FBloomCombineShader *mBloomCombineShader; FBlurShader *mBlurShader; + FTonemapShader *mTonemapShader; FPresentShader *mPresentShader; FTexture *gllight; @@ -106,6 +108,8 @@ public: GL_IRECT mOutputViewportLB; GL_IRECT mOutputViewport; + bool mDrawingScene2D = false; + float mCameraExposure = 1.0f; FGLRenderer(OpenGLFrameBuffer *fb); ~FGLRenderer() ; @@ -154,6 +158,7 @@ public: void WriteSavePic (player_t *player, FILE *file, int width, int height); void EndDrawScene(sector_t * viewsector); void BloomScene(); + void TonemapScene(); void Flush(); void SetProjection(float fov, float ratio, float fovratio); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 0aa9f0444..2136e21a2 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -74,6 +74,7 @@ #include "gl/shaders/gl_shader.h" #include "gl/shaders/gl_bloomshader.h" #include "gl/shaders/gl_blurshader.h" +#include "gl/shaders/gl_tonemapshader.h" #include "gl/shaders/gl_presentshader.h" #include "gl/stereo3d/gl_stereo3d.h" #include "gl/stereo3d/scoped_view_shifter.h" @@ -219,11 +220,9 @@ void FGLRenderer::BloomScene() const float blurAmount = 4.0f; int sampleCount = 5; // Note: must be uneven number 3 to 15 - float exposure = 2.0f; + float exposure = mCameraExposure; - auto vbo = GLRenderer->mVBO; - - // TODO: Need a better way to share state with other parts of the pipeline + // TBD: Maybe need a better way to share state with other parts of the pipeline GLboolean blendEnabled, scissorEnabled; GLint currentProgram, blendEquationRgb, blendEquationAlpha, blendSrcRgb, blendSrcAlpha, blendDestRgb, blendDestAlpha; glGetBooleanv(GL_BLEND, &blendEnabled); @@ -251,12 +250,12 @@ void FGLRenderer::BloomScene() mBloomExtractShader->SceneTexture.Set(0); mBloomExtractShader->Exposure.Set(exposure); { - FFlatVertex *ptr = vbo->GetBuffer(); + FFlatVertex *ptr = mVBO->GetBuffer(); ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; - vbo->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -266,8 +265,8 @@ void FGLRenderer::BloomScene() { const auto &level = mBuffers->BloomLevels[i]; const auto &next = mBuffers->BloomLevels[i + 1]; - mBlurShader->BlurHorizontal(vbo, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); - mBlurShader->BlurVertical(vbo, blurAmount, sampleCount, level.HTexture, next.VFramebuffer, next.Width, next.Height); + mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); + mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level.HTexture, next.VFramebuffer, next.Width, next.Height); } // Blur and upscale: @@ -276,8 +275,8 @@ void FGLRenderer::BloomScene() const auto &level = mBuffers->BloomLevels[i]; const auto &next = mBuffers->BloomLevels[i - 1]; - mBlurShader->BlurHorizontal(vbo, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); - mBlurShader->BlurVertical(vbo, blurAmount, sampleCount, level.HTexture, level.VFramebuffer, level.Width, level.Height); + mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); + mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level.HTexture, level.VFramebuffer, level.Width, level.Height); // Linear upscale: glBindFramebuffer(GL_FRAMEBUFFER, next.VFramebuffer); @@ -289,17 +288,17 @@ void FGLRenderer::BloomScene() mBloomCombineShader->Bind(); mBloomCombineShader->BloomTexture.Set(0); { - FFlatVertex *ptr = vbo->GetBuffer(); + FFlatVertex *ptr = mVBO->GetBuffer(); ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; - vbo->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } } - mBlurShader->BlurHorizontal(vbo, blurAmount, sampleCount, level0.VTexture, level0.HFramebuffer, level0.Width, level0.Height); - mBlurShader->BlurVertical(vbo, blurAmount, sampleCount, level0.HTexture, level0.VFramebuffer, level0.Width, level0.Height); + mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level0.VTexture, level0.HFramebuffer, level0.Width, level0.Height); + mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level0.HTexture, level0.VFramebuffer, level0.Width, level0.Height); // Add bloom back to scene texture: mBuffers->BindSceneFB(); @@ -314,12 +313,12 @@ void FGLRenderer::BloomScene() mBloomCombineShader->Bind(); mBloomCombineShader->BloomTexture.Set(0); { - FFlatVertex *ptr = vbo->GetBuffer(); + FFlatVertex *ptr = mVBO->GetBuffer(); ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; - vbo->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } if (blendEnabled) @@ -332,7 +331,41 @@ void FGLRenderer::BloomScene() //----------------------------------------------------------------------------- // -// Run post processing steps and copy to frame buffer +// Tonemap scene texture and place the result in the HUD/2D texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::TonemapScene() +{ + GLboolean blendEnabled, scissorEnabled; + glGetBooleanv(GL_BLEND, &blendEnabled); + glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); + + glDisable(GL_BLEND); + glDisable(GL_SCISSOR_TEST); + + mBuffers->BindHudFB(); + mBuffers->BindSceneTexture(0); + mTonemapShader->Bind(); + mTonemapShader->SceneTexture.Set(0); + mTonemapShader->Exposure.Set(mCameraExposure); + + FFlatVertex *ptr = mVBO->GetBuffer(); + ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; + ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; + ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; + ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; + mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + + if (blendEnabled) + glEnable(GL_BLEND); + if (scissorEnabled) + glEnable(GL_SCISSOR_TEST); +} + +//----------------------------------------------------------------------------- +// +// Gamma correct while copying to frame buffer // //----------------------------------------------------------------------------- @@ -406,7 +439,7 @@ void FGLRenderer::Flush() mPresentShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); } - mBuffers->BindSceneTexture(0); + mBuffers->BindHudTexture(0); FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; @@ -938,6 +971,7 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) glDisable(GL_SCISSOR_TEST); BloomScene(); + TonemapScene(); } @@ -1042,6 +1076,13 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo mViewActor=camera; } + if (toscreen) + { + float light = viewsector->lightlevel / 255.0f; + float exposure = MAX(1.0f + (1.0f - light * light) * 1.5f, 0.5f); + mCameraExposure = mCameraExposure * 0.98f + exposure * 0.02f; + } + // 'viewsector' will not survive the rendering so it cannot be used anymore below. retval = viewsector; @@ -1056,6 +1097,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo // TODO: stereo specific viewport - needed when implementing side-by-side modes etc. SetOutputViewport(bounds); Set3DViewport(); + mDrawingScene2D = true; mCurrentFoV = fov; // Stereo mode specific perspective projection SetProjection( eye->GetProjection(fov, ratio, fovratio) ); @@ -1073,6 +1115,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo ProcessScene(toscreen); if (mainview) EndDrawScene(retval); // do not call this for camera textures. + mDrawingScene2D = false; eye->TearDown(); } stereo3dMode.TearDown(); diff --git a/src/gl/shaders/gl_blurshader.cpp b/src/gl/shaders/gl_blurshader.cpp index 6ed7573ee..aee8696d9 100644 --- a/src/gl/shaders/gl_blurshader.cpp +++ b/src/gl/shaders/gl_blurshader.cpp @@ -80,32 +80,29 @@ void FBlurShader::BlurHorizontal(FFlatVertexBuffer *vbo, float blurAmount, int s void FBlurShader::Blur(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height, bool vertical) { - int error = glGetError(); BlurSetup *setup = GetSetup(blurAmount, sampleCount); - error = glGetError(); if (vertical) setup->VerticalShader->Bind(); else setup->HorizontalShader->Bind(); - error = glGetError(); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, inputTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - error = glGetError(); + glBindFramebuffer(GL_FRAMEBUFFER, outputFrameBuffer); glViewport(0, 0, width, height); glDisable(GL_BLEND); - error = glGetError(); + FFlatVertex *ptr = vbo->GetBuffer(); ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; vbo->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - error = glGetError(); } //========================================================================== @@ -138,9 +135,7 @@ FBlurShader::BlurSetup *FBlurShader::GetSetup(float blurAmount, int sampleCount) blurSetup.VerticalShader->SetAttribLocation(0, "PositionInProjection"); blurSetup.VerticalShader->Link("vertical blur"); blurSetup.VerticalShader->Bind(); - int error = glGetError(); glUniform1i(glGetUniformLocation(*blurSetup.VerticalShader.get(), "SourceTexture"), 0); - error = glGetError(); blurSetup.HorizontalShader = std::make_shared(); blurSetup.HorizontalShader->Compile(FShaderProgram::Vertex, "horizontal blur vertex shader", vertexCode); diff --git a/src/gl/shaders/gl_tonemapshader.cpp b/src/gl/shaders/gl_tonemapshader.cpp new file mode 100644 index 000000000..44ea40012 --- /dev/null +++ b/src/gl/shaders/gl_tonemapshader.cpp @@ -0,0 +1,65 @@ +/* +** gl_tonemapshader.cpp +** Converts a HDR texture to 0-1 range by applying a tonemap operator +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "gl/gl_functions.h" +#include "vectors.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_tonemapshader.h" + +void FTonemapShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/tonemap.vp"); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/tonemap.fp"); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/tonemap"); + mShader.SetAttribLocation(0, "PositionInProjection"); + SceneTexture.Init(mShader, "InputTexture"); + Exposure.Init(mShader, "ExposureAdjustment"); + } + mShader.Bind(); +} diff --git a/src/gl/shaders/gl_tonemapshader.h b/src/gl/shaders/gl_tonemapshader.h new file mode 100644 index 000000000..0380e31b8 --- /dev/null +++ b/src/gl/shaders/gl_tonemapshader.h @@ -0,0 +1,18 @@ +#ifndef __GL_TONEMAPSHADER_H +#define __GL_TONEMAPSHADER_H + +#include "gl_shaderprogram.h" + +class FTonemapShader +{ +public: + void Bind(); + + FBufferedUniform1i SceneTexture; + FBufferedUniform1f Exposure; + +private: + FShaderProgram mShader; +}; + +#endif \ No newline at end of file diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 6b15e0b6d..1f1dedba3 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -158,7 +158,7 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) if (FGLRenderBuffers::IsSupported()) { - GLRenderer->mBuffers->BindSceneFB(); + GLRenderer->mBuffers->BindHudFB(); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); } else @@ -193,7 +193,7 @@ void OpenGLFrameBuffer::WipeEndScreen() wipeendscreen->Bind(0, false, false); if (FGLRenderBuffers::IsSupported()) - GLRenderer->mBuffers->BindSceneFB(); + GLRenderer->mBuffers->BindHudFB(); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -232,7 +232,7 @@ bool OpenGLFrameBuffer::WipeDo(int ticks) if (FGLRenderBuffers::IsSupported()) { - GLRenderer->mBuffers->BindSceneFB(); + GLRenderer->mBuffers->BindHudFB(); glViewport(0, 0, GLRenderer->mOutputViewport.width, GLRenderer->mOutputViewport.height); } diff --git a/wadsrc/static/shaders/glsl/tonemap.fp b/wadsrc/static/shaders/glsl/tonemap.fp new file mode 100644 index 000000000..e1e3d3497 --- /dev/null +++ b/wadsrc/static/shaders/glsl/tonemap.fp @@ -0,0 +1,65 @@ + +#version 330 + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D InputTexture; +uniform float ExposureAdjustment; + +vec3 Linear(vec3 c) +{ + //return pow(c, 2.2); + return c * c; // cheaper, but assuming gamma of 2.0 instead of 2.2 +} + +vec3 sRGB(vec3 c) +{ + //return pow(c, vec3(1.0 / 2.2)); + return sqrt(c); // cheaper, but assuming gamma of 2.0 instead of 2.2 +} + +vec3 TonemapLinear(vec3 color) +{ + return sRGB(color); +} + +vec3 TonemapReinhard(vec3 color) +{ + color = color / (1 + color); + return sRGB(color); +} + +vec3 TonemapHejlDawson(vec3 color) +{ + vec3 x = max(vec3(0), color - 0.004); + return (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06); // no sRGB needed +} + +vec3 Uncharted2Tonemap(vec3 x) +{ + float A = 0.15; + float B = 0.50; + float C = 0.10; + float D = 0.20; + float E = 0.02; + float F = 0.30; + return ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F; +} + +vec3 TonemapUncharted2(vec3 color) +{ + float W = 11.2; + float ExposureBias = 2.0; + vec3 curr = Uncharted2Tonemap(ExposureBias * color); + vec3 whiteScale = vec3(1) / Uncharted2Tonemap(vec3(W)); + return sRGB(curr * whiteScale); +} + +void main() +{ + vec3 color = texture(InputTexture, TexCoord).rgb; + color = color * ExposureAdjustment; + color = Linear(color); // needed because gzdoom's scene texture is not linear at the moment + FragColor = vec4(TonemapUncharted2(color), 1.0); +} diff --git a/wadsrc/static/shaders/glsl/tonemap.vp b/wadsrc/static/shaders/glsl/tonemap.vp new file mode 100644 index 000000000..b73fe7fc8 --- /dev/null +++ b/wadsrc/static/shaders/glsl/tonemap.vp @@ -0,0 +1,11 @@ + +#version 330 + +in vec4 PositionInProjection; +out vec2 TexCoord; + +void main() +{ + gl_Position = PositionInProjection; + TexCoord = PositionInProjection.xy * 0.5 + 0.5; +} From 5849c830289fb74022bee01df6e924f0102a147f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 29 Jul 2016 21:31:20 +0200 Subject: [PATCH 0737/1509] Added bloom and tonemap to menus Added gl_renderbuffers CVAR that disables render buffers Added patch shader support to FShaderProgram Added OpenGL 2 fallback support to render buffers --- src/gl/renderer/gl_renderbuffers.cpp | 220 ++++++++++++++------- src/gl/renderer/gl_renderbuffers.h | 14 +- src/gl/renderer/gl_renderer.cpp | 2 +- src/gl/renderer/gl_renderer.h | 2 +- src/gl/scene/gl_scene.cpp | 61 ++++-- src/gl/shaders/gl_bloomshader.cpp | 8 +- src/gl/shaders/gl_blurshader.cpp | 11 +- src/gl/shaders/gl_presentshader.cpp | 4 +- src/gl/shaders/gl_shader.cpp | 44 +---- src/gl/shaders/gl_shaderprogram.cpp | 100 +++++++++- src/gl/shaders/gl_shaderprogram.h | 11 +- src/gl/shaders/gl_tonemapshader.cpp | 31 ++- src/gl/shaders/gl_tonemapshader.h | 14 +- src/gl/system/gl_cvars.h | 8 + src/gl/system/gl_interface.cpp | 3 + src/gl/system/gl_interface.h | 3 + src/gl/system/gl_wipe.cpp | 6 +- wadsrc/static/language.enu | 5 + wadsrc/static/menudef.z | 11 ++ wadsrc/static/shaders/glsl/bloomcombine.fp | 2 - wadsrc/static/shaders/glsl/bloomcombine.vp | 2 - wadsrc/static/shaders/glsl/bloomextract.fp | 2 - wadsrc/static/shaders/glsl/bloomextract.vp | 2 - wadsrc/static/shaders/glsl/present.fp | 2 - wadsrc/static/shaders/glsl/present.vp | 2 - wadsrc/static/shaders/glsl/tonemap.fp | 22 ++- wadsrc/static/shaders/glsl/tonemap.vp | 2 - 27 files changed, 401 insertions(+), 193 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 590ea3935..8be9e6b07 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -53,6 +53,8 @@ #include "i_system.h" #include "doomerrors.h" +CVAR(Bool, gl_renderbuffers, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); + //========================================================================== // // Initialize render buffers and textures used in rendering passes @@ -80,37 +82,45 @@ void FGLRenderBuffers::Clear() for (int i = 0; i < NumBloomLevels; i++) { auto &level = BloomLevels[i]; - if (level.HFramebuffer != 0) - glDeleteFramebuffers(1, &level.HFramebuffer); - if (level.VFramebuffer != 0) - glDeleteFramebuffers(1, &level.VFramebuffer); - if (level.HTexture != 0) - glDeleteTextures(1, &level.HTexture); - if (level.VTexture != 0) - glDeleteTextures(1, &level.VTexture); + DeleteFrameBuffer(level.HFramebuffer); + DeleteFrameBuffer(level.VFramebuffer); + DeleteTexture(level.HTexture); + DeleteTexture(level.VTexture); level = FGLBloomTextureLevel(); } - if (mSceneFB != 0) - glDeleteFramebuffers(1, &mSceneFB); - if (mSceneTexture != 0) - glDeleteTextures(1, &mSceneTexture); - if (mSceneDepthStencil != 0) - glDeleteRenderbuffers(1, &mSceneDepthStencil); - if (mHudFB != 0) - glDeleteFramebuffers(1, &mHudFB); - if (mHudTexture != 0) - glDeleteTextures(1, &mHudTexture); - - mSceneFB = 0; - mSceneTexture = 0; - mSceneDepthStencil = 0; - mHudFB = 0; - mHudTexture = 0; + DeleteFrameBuffer(mSceneFB); + DeleteTexture(mSceneTexture); + DeleteRenderBuffer(mSceneDepthStencil); + DeleteRenderBuffer(mSceneDepth); + DeleteRenderBuffer(mSceneStencil); + DeleteFrameBuffer(mHudFB); + DeleteTexture(mHudTexture); mWidth = 0; mHeight = 0; } +void FGLRenderBuffers::DeleteTexture(GLuint &handle) +{ + if (handle != 0) + glDeleteTextures(1, &handle); + handle = 0; +} + +void FGLRenderBuffers::DeleteRenderBuffer(GLuint &handle) +{ + if (handle != 0) + glDeleteRenderbuffers(1, &handle); + handle = 0; +} + +void FGLRenderBuffers::DeleteFrameBuffer(GLuint &handle) +{ + if (handle != 0) + glDeleteFramebuffers(1, &handle); + handle = 0; +} + //========================================================================== // // Makes sure all render buffers have sizes suitable for rending at the @@ -125,37 +135,23 @@ void FGLRenderBuffers::Setup(int width, int height) Clear(); - glActiveTexture(GL_TEXTURE0); + GLuint hdrFormat = ((gl.flags & RFL_NO_RGBA16F) != 0) ? GL_RGBA8 : GL_RGBA16F; - glGenFramebuffers(1, &mSceneFB); - glGenFramebuffers(1, &mHudFB); - glGenTextures(1, &mSceneTexture); - glGenTextures(1, &mHudTexture); - glGenRenderbuffers(1, &mSceneDepthStencil); + mSceneTexture = Create2DTexture(hdrFormat, width, height); + if ((gl.flags & RFL_NO_DEPTHSTENCIL) != 0) + { + mSceneDepth = CreateRenderBuffer(GL_DEPTH_COMPONENT24, width, height); + mSceneStencil = CreateRenderBuffer(GL_STENCIL_INDEX8, width, height); + mSceneFB = CreateFrameBuffer(mSceneTexture, mSceneDepth, mSceneStencil); + } + else + { + mSceneDepthStencil = CreateRenderBuffer(GL_DEPTH24_STENCIL8, width, height); + mSceneFB = CreateFrameBuffer(mSceneTexture, mSceneDepthStencil); + } - glBindTexture(GL_TEXTURE_2D, mSceneTexture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGBA, GL_FLOAT, nullptr); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glBindRenderbuffer(GL_RENDERBUFFER, mSceneDepthStencil); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); - - glBindFramebuffer(GL_FRAMEBUFFER, mSceneFB); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mSceneTexture, 0); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mSceneDepthStencil); - - glBindTexture(GL_TEXTURE_2D, mHudTexture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT, nullptr); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glBindFramebuffer(GL_FRAMEBUFFER, mHudFB); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mHudTexture, 0); + mHudTexture = Create2DTexture(hdrFormat, width, height); + mHudFB = CreateFrameBuffer(mHudTexture); int bloomWidth = MAX(width / 2, 1); int bloomHeight = MAX(height / 2, 1); @@ -165,31 +161,16 @@ void FGLRenderBuffers::Setup(int width, int height) level.Width = MAX(bloomWidth / 2, 1); level.Height = MAX(bloomHeight / 2, 1); - glGenTextures(1, &level.VTexture); - glGenTextures(1, &level.HTexture); - glGenFramebuffers(1, &level.VFramebuffer); - glGenFramebuffers(1, &level.HFramebuffer); - - glBindTexture(GL_TEXTURE_2D, level.VTexture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, level.Width, level.Height, 0, GL_RGBA, GL_FLOAT, nullptr); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glBindTexture(GL_TEXTURE_2D, level.HTexture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, level.Width, level.Height, 0, GL_RGBA, GL_FLOAT, nullptr); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glBindFramebuffer(GL_FRAMEBUFFER, level.VFramebuffer); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, level.VTexture, 0); - - glBindFramebuffer(GL_FRAMEBUFFER, level.HFramebuffer); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, level.HTexture, 0); + level.VTexture = Create2DTexture(hdrFormat, level.Width, level.Height); + level.HTexture = Create2DTexture(hdrFormat, level.Width, level.Height); + level.VFramebuffer = CreateFrameBuffer(level.VTexture); + level.HFramebuffer = CreateFrameBuffer(level.HTexture); bloomWidth = level.Width; bloomHeight = level.Height; } + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); glBindRenderbuffer(GL_RENDERBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, mOutputFB); @@ -198,6 +179,78 @@ void FGLRenderBuffers::Setup(int width, int height) mHeight = height; } +//========================================================================== +// +// Creates a 2D texture defaulting to linear filtering and clamp to edge +// +//========================================================================== + +GLuint FGLRenderBuffers::Create2DTexture(GLuint format, int width, int height) +{ + GLuint type = (format == GL_RGBA16F) ? GL_FLOAT : GL_UNSIGNED_BYTE; + GLuint handle = 0; + glGenTextures(1, &handle); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, handle); + glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, GL_RGBA, type, nullptr); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + return handle; +} + +//========================================================================== +// +// Creates a render buffer +// +//========================================================================== + +GLuint FGLRenderBuffers::CreateRenderBuffer(GLuint format, int width, int height) +{ + GLuint handle = 0; + glGenRenderbuffers(1, &handle); + glBindRenderbuffer(GL_RENDERBUFFER, handle); + glRenderbufferStorage(GL_RENDERBUFFER, format, width, height); + return handle; +} + +//========================================================================== +// +// Creates a frame buffer +// +//========================================================================== + +GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer) +{ + GLuint handle = 0; + glGenFramebuffers(1, &handle); + glBindFramebuffer(GL_FRAMEBUFFER, handle); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); + return handle; +} + +GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depthstencil) +{ + GLuint handle = 0; + glGenFramebuffers(1, &handle); + glBindFramebuffer(GL_FRAMEBUFFER, handle); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil); + return handle; +} + +GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLuint stencil) +{ + GLuint handle = 0; + glGenFramebuffers(1, &handle); + glBindFramebuffer(GL_FRAMEBUFFER, handle); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil); + return handle; +} + //========================================================================== // // Makes the scene frame buffer active @@ -217,7 +270,10 @@ void FGLRenderBuffers::BindSceneFB() void FGLRenderBuffers::BindHudFB() { - glBindFramebuffer(GL_FRAMEBUFFER, mHudFB); + if (gl_tonemap != 0) + glBindFramebuffer(GL_FRAMEBUFFER, mHudFB); + else + glBindFramebuffer(GL_FRAMEBUFFER, mSceneFB); } //========================================================================== @@ -252,5 +308,19 @@ void FGLRenderBuffers::BindSceneTexture(int index) void FGLRenderBuffers::BindHudTexture(int index) { glActiveTexture(GL_TEXTURE0 + index); - glBindTexture(GL_TEXTURE_2D, mHudTexture); + if (gl_tonemap != 0) + glBindTexture(GL_TEXTURE_2D, mHudTexture); + else + glBindTexture(GL_TEXTURE_2D, mSceneTexture); +} + +//========================================================================== +// +// Returns true if render buffers are supported and should be used +// +//========================================================================== + +bool FGLRenderBuffers::IsEnabled() +{ + return gl_renderbuffers && gl.glslversion != 0; } diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 24d301d52..ba5e94ab3 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -27,19 +27,29 @@ public: void BindSceneTexture(int index); void BindHudTexture(int index); - static bool IsSupported() { return gl.version >= 3.3f; } - enum { NumBloomLevels = 4 }; FGLBloomTextureLevel BloomLevels[NumBloomLevels]; + static bool IsEnabled(); + private: void Clear(); + GLuint Create2DTexture(GLuint format, int width, int height); + GLuint CreateRenderBuffer(GLuint format, int width, int height); + GLuint CreateFrameBuffer(GLuint colorbuffer); + GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depthstencil); + GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLuint stencil); + void DeleteTexture(GLuint &handle); + void DeleteRenderBuffer(GLuint &handle); + void DeleteFrameBuffer(GLuint &handle); int mWidth = 0; int mHeight = 0; GLuint mSceneTexture = 0; GLuint mSceneDepthStencil = 0; + GLuint mSceneDepth = 0; + GLuint mSceneStencil = 0; GLuint mSceneFB = 0; GLuint mHudTexture = 0; GLuint mHudFB = 0; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 264ff4c7f..a1d8bb2a7 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -235,7 +235,7 @@ void FGLRenderer::SetupLevel() void FGLRenderer::Begin2D() { - if (FGLRenderBuffers::IsSupported()) + if (FGLRenderBuffers::IsEnabled()) { mBuffers->Setup(framebuffer->GetWidth(), framebuffer->GetHeight()); if (mDrawingScene2D) diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 39eddcbf0..ad2046cad 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -117,7 +117,7 @@ public: angle_t FrustumAngle(); void SetViewArea(); void SetOutputViewport(GL_IRECT *bounds); - void Set3DViewport(); + void Set3DViewport(bool toscreen); void Reset3DViewport(); sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen); void RenderView(player_t *player); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 2136e21a2..c23992f1b 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -96,6 +96,22 @@ CVAR(Float, gl_mask_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_sprite_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, gl_sort_textures, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Bool, gl_bloom, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +CVAR(Float, gl_bloom_amount, 1.4f, 0) +CVAR(Float, gl_exposure, 0.0f, 0) + +CUSTOM_CVAR(Int, gl_tonemap, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + if (self < 0 || self > 4) + self = 0; +} + +CUSTOM_CVAR(Int, gl_bloom_kernel_size, 7, 0) +{ + if (self < 3 || self > 15 || self % 2 == 0) + self = 7; +} + EXTERN_CVAR (Bool, cl_capfps) EXTERN_CVAR (Bool, r_deathcamera) EXTERN_CVAR(Float, vid_brightness) @@ -163,7 +179,7 @@ void FGLRenderer::SetViewArea() void FGLRenderer::Reset3DViewport() { - if (FGLRenderBuffers::IsSupported()) + if (FGLRenderBuffers::IsEnabled()) glViewport(0, 0, mOutputViewport.width, mOutputViewport.height); else glViewport(mOutputViewport.left, mOutputViewport.top, mOutputViewport.width, mOutputViewport.height); @@ -175,10 +191,10 @@ void FGLRenderer::Reset3DViewport() // //----------------------------------------------------------------------------- -void FGLRenderer::Set3DViewport() +void FGLRenderer::Set3DViewport(bool toscreen) { const auto &bounds = mOutputViewportLB; - if (FGLRenderBuffers::IsSupported()) + if (toscreen && FGLRenderBuffers::IsEnabled()) { mBuffers->Setup(mOutputViewport.width, mOutputViewport.height); mBuffers->BindSceneFB(); @@ -215,12 +231,12 @@ void FGLRenderer::Set3DViewport() void FGLRenderer::BloomScene() { - if (!FGLRenderBuffers::IsSupported()) + // Only bloom things if enabled and no special fixed light mode is active + if (!gl_bloom || !FGLRenderBuffers::IsEnabled() || gl_fixedcolormap != CM_DEFAULT) return; - const float blurAmount = 4.0f; - int sampleCount = 5; // Note: must be uneven number 3 to 15 - float exposure = mCameraExposure; + const float blurAmount = gl_bloom_amount; + int sampleCount = gl_bloom_kernel_size; // TBD: Maybe need a better way to share state with other parts of the pipeline GLboolean blendEnabled, scissorEnabled; @@ -248,7 +264,7 @@ void FGLRenderer::BloomScene() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); mBloomExtractShader->Bind(); mBloomExtractShader->SceneTexture.Set(0); - mBloomExtractShader->Exposure.Set(exposure); + mBloomExtractShader->Exposure.Set(mCameraExposure); { FFlatVertex *ptr = mVBO->GetBuffer(); ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; @@ -327,6 +343,7 @@ void FGLRenderer::BloomScene() glEnable(GL_SCISSOR_TEST); glBlendEquationSeparate(blendEquationRgb, blendEquationAlpha); glBlendFuncSeparate(blendSrcRgb, blendDestRgb, blendSrcAlpha, blendDestAlpha); + glUseProgram(currentProgram); } //----------------------------------------------------------------------------- @@ -337,6 +354,9 @@ void FGLRenderer::BloomScene() void FGLRenderer::TonemapScene() { + if (gl_tonemap == 0) + return; + GLboolean blendEnabled, scissorEnabled; glGetBooleanv(GL_BLEND, &blendEnabled); glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); @@ -371,7 +391,7 @@ void FGLRenderer::TonemapScene() void FGLRenderer::Flush() { - if (FGLRenderBuffers::IsSupported()) + if (FGLRenderBuffers::IsEnabled()) { glDisable(GL_MULTISAMPLE); glDisable(GL_DEPTH_TEST); @@ -969,9 +989,6 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) gl_RenderState.ResetColor(); gl_RenderState.EnableTexture(true); glDisable(GL_SCISSOR_TEST); - - BloomScene(); - TonemapScene(); } @@ -1078,9 +1095,16 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo if (toscreen) { - float light = viewsector->lightlevel / 255.0f; - float exposure = MAX(1.0f + (1.0f - light * light) * 1.5f, 0.5f); - mCameraExposure = mCameraExposure * 0.98f + exposure * 0.02f; + if (gl_exposure == 0.0f) + { + float light = viewsector->lightlevel / 255.0f; + float exposure = MAX(1.0f + (1.0f - light * light) * 0.9f, 0.5f); + mCameraExposure = mCameraExposure * 0.995f + exposure * 0.005f; + } + else + { + mCameraExposure = gl_exposure; + } } // 'viewsector' will not survive the rendering so it cannot be used anymore below. @@ -1096,7 +1120,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo eye->SetUp(); // TODO: stereo specific viewport - needed when implementing side-by-side modes etc. SetOutputViewport(bounds); - Set3DViewport(); + Set3DViewport(toscreen); mDrawingScene2D = true; mCurrentFoV = fov; // Stereo mode specific perspective projection @@ -1115,6 +1139,11 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo ProcessScene(toscreen); if (mainview) EndDrawScene(retval); // do not call this for camera textures. + if (toscreen) + { + BloomScene(); + TonemapScene(); + } mDrawingScene2D = false; eye->TearDown(); } diff --git a/src/gl/shaders/gl_bloomshader.cpp b/src/gl/shaders/gl_bloomshader.cpp index 23cda96b7..c7191884f 100644 --- a/src/gl/shaders/gl_bloomshader.cpp +++ b/src/gl/shaders/gl_bloomshader.cpp @@ -53,8 +53,8 @@ void FBloomExtractShader::Bind() { if (!mShader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/bloomextract.vp"); - mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomextract.fp"); + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/bloomextract.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomextract.fp", "", 330); mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/bloomextract"); mShader.SetAttribLocation(0, "PositionInProjection"); @@ -68,8 +68,8 @@ void FBloomCombineShader::Bind() { if (!mShader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/bloomcombine.vp"); - mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomcombine.fp"); + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/bloomcombine.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomcombine.fp", "", 330); mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/bloomcombine"); mShader.SetAttribLocation(0, "PositionInProjection"); diff --git a/src/gl/shaders/gl_blurshader.cpp b/src/gl/shaders/gl_blurshader.cpp index aee8696d9..14bcc28c5 100644 --- a/src/gl/shaders/gl_blurshader.cpp +++ b/src/gl/shaders/gl_blurshader.cpp @@ -129,8 +129,8 @@ FBlurShader::BlurSetup *FBlurShader::GetSetup(float blurAmount, int sampleCount) FString verticalCode = FragmentShaderCode(blurAmount, sampleCount, true); blurSetup.VerticalShader = std::make_shared(); - blurSetup.VerticalShader->Compile(FShaderProgram::Vertex, "vertical blur vertex shader", vertexCode); - blurSetup.VerticalShader->Compile(FShaderProgram::Fragment, "vertical blur fragment shader", verticalCode); + blurSetup.VerticalShader->Compile(FShaderProgram::Vertex, "vertical blur vertex shader", vertexCode, "", 330); + blurSetup.VerticalShader->Compile(FShaderProgram::Fragment, "vertical blur fragment shader", verticalCode, "", 330); blurSetup.VerticalShader->SetFragDataLocation(0, "FragColor"); blurSetup.VerticalShader->SetAttribLocation(0, "PositionInProjection"); blurSetup.VerticalShader->Link("vertical blur"); @@ -138,8 +138,8 @@ FBlurShader::BlurSetup *FBlurShader::GetSetup(float blurAmount, int sampleCount) glUniform1i(glGetUniformLocation(*blurSetup.VerticalShader.get(), "SourceTexture"), 0); blurSetup.HorizontalShader = std::make_shared(); - blurSetup.HorizontalShader->Compile(FShaderProgram::Vertex, "horizontal blur vertex shader", vertexCode); - blurSetup.HorizontalShader->Compile(FShaderProgram::Fragment, "horizontal blur fragment shader", horizontalCode); + blurSetup.HorizontalShader->Compile(FShaderProgram::Vertex, "horizontal blur vertex shader", vertexCode, "", 330); + blurSetup.HorizontalShader->Compile(FShaderProgram::Fragment, "horizontal blur fragment shader", horizontalCode, "", 330); blurSetup.HorizontalShader->SetFragDataLocation(0, "FragColor"); blurSetup.HorizontalShader->SetAttribLocation(0, "PositionInProjection"); blurSetup.HorizontalShader->Link("horizontal blur"); @@ -160,8 +160,6 @@ FBlurShader::BlurSetup *FBlurShader::GetSetup(float blurAmount, int sampleCount) FString FBlurShader::VertexShaderCode() { return R"( - #version 330 - in vec4 PositionInProjection; out vec2 TexCoord; @@ -187,7 +185,6 @@ FString FBlurShader::FragmentShaderCode(float blurAmount, int sampleCount, bool const char *fragmentShader = R"( - #version 330 in vec2 TexCoord; uniform sampler2D SourceTexture; out vec4 FragColor; diff --git a/src/gl/shaders/gl_presentshader.cpp b/src/gl/shaders/gl_presentshader.cpp index a5d514308..0ebfc9945 100644 --- a/src/gl/shaders/gl_presentshader.cpp +++ b/src/gl/shaders/gl_presentshader.cpp @@ -53,8 +53,8 @@ void FPresentShader::Bind() { if (!mShader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/present.vp"); - mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/present.fp"); + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/present.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/present.fp", "", 330); mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/present"); mShader.SetAttribLocation(0, "PositionInProjection"); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 551707398..b5fd1dbbd 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -56,48 +56,10 @@ #include "gl/renderer/gl_renderstate.h" #include "gl/system/gl_cvars.h" #include "gl/shaders/gl_shader.h" +#include "gl/shaders/gl_shaderprogram.h" #include "gl/textures/gl_material.h" #include "gl/dynlights/gl_lightbuffer.h" -//========================================================================== -// -// patch the shader source to work with -// GLSL 1.2 keywords and identifiers -// -//========================================================================== - -void PatchCommon(FString &code) -{ - code.Substitute("precision highp int;", ""); - code.Substitute("precision highp float;", ""); -} - -void PatchVertShader(FString &code) -{ - PatchCommon(code); - code.Substitute("in vec", "attribute vec"); - code.Substitute("out vec", "varying vec"); - code.Substitute("gl_ClipDistance", "//"); -} - -void PatchFragShader(FString &code) -{ - PatchCommon(code); - code.Substitute("out vec4 FragColor;", ""); - code.Substitute("FragColor", "gl_FragColor"); - code.Substitute("in vec", "varying vec"); - // this patches the switch statement to if's. - code.Substitute("break;", ""); - code.Substitute("switch (uFixedColormap)", "int i = uFixedColormap;"); - code.Substitute("case 0:", "if (i == 0)"); - code.Substitute("case 1:", "else if (i == 1)"); - code.Substitute("case 2:", "else if (i == 2)"); - code.Substitute("case 3:", "else if (i == 3)"); - code.Substitute("case 4:", "else if (i == 4)"); - code.Substitute("case 5:", "else if (i == 5)"); - code.Substitute("texture(", "texture2D("); -} - //========================================================================== // // @@ -204,8 +166,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * if (gl.glslversion < 1.3) { - PatchVertShader(vp_comb); - PatchFragShader(fp_comb); + FShaderProgram::PatchVertShader(vp_comb); + FShaderProgram::PatchFragShader(fp_comb); } hVertProg = glCreateShader(GL_VERTEX_SHADER); diff --git a/src/gl/shaders/gl_shaderprogram.cpp b/src/gl/shaders/gl_shaderprogram.cpp index 4448bdf59..bed4a2e29 100644 --- a/src/gl/shaders/gl_shaderprogram.cpp +++ b/src/gl/shaders/gl_shaderprogram.cpp @@ -93,22 +93,23 @@ void FShaderProgram::CreateShader(ShaderType type) // //========================================================================== -void FShaderProgram::Compile(ShaderType type, const char *lumpName) +void FShaderProgram::Compile(ShaderType type, const char *lumpName, const char *defines, int maxGlslVersion) { int lump = Wads.CheckNumForFullName(lumpName); - if (lump == -1) I_Error("Unable to load '%s'", lumpName); + if (lump == -1) I_FatalError("Unable to load '%s'", lumpName); FString code = Wads.ReadLump(lump).GetString().GetChars(); - Compile(type, lumpName, code); + Compile(type, lumpName, code, defines, maxGlslVersion); } -void FShaderProgram::Compile(ShaderType type, const char *name, const FString &code) +void FShaderProgram::Compile(ShaderType type, const char *name, const FString &code, const char *defines, int maxGlslVersion) { CreateShader(type); const auto &handle = mShaders[type]; - int lengths[1] = { (int)code.Len() }; - const char *sources[1] = { code.GetChars() }; + FString patchedCode = PatchShader(type, code, defines, maxGlslVersion); + int lengths[1] = { (int)patchedCode.Len() }; + const char *sources[1] = { patchedCode.GetChars() }; glShaderSource(handle, 1, sources, lengths); glCompileShader(handle); @@ -117,7 +118,7 @@ void FShaderProgram::Compile(ShaderType type, const char *name, const FString &c glGetShaderiv(handle, GL_COMPILE_STATUS, &status); if (status == GL_FALSE) { - I_Error("Compile Shader '%s':\n%s\n", name, GetShaderInfoLog(handle).GetChars()); + I_FatalError("Compile Shader '%s':\n%s\n", name, GetShaderInfoLog(handle).GetChars()); } else { @@ -152,7 +153,7 @@ void FShaderProgram::Link(const char *name) glGetProgramiv(mProgram, GL_LINK_STATUS, &status); if (status == GL_FALSE) { - I_Error("Link Shader '%s':\n%s\n", name, GetProgramInfoLog(mProgram).GetChars()); + I_FatalError("Link Shader '%s':\n%s\n", name, GetProgramInfoLog(mProgram).GetChars()); } } @@ -207,3 +208,86 @@ FString FShaderProgram::GetProgramInfoLog(GLuint handle) glGetProgramInfoLog(handle, 10000, &length, buffer); return FString(buffer); } + +//========================================================================== +// +// Patches a shader to be compatible with the version of OpenGL in use +// +//========================================================================== + +FString FShaderProgram::PatchShader(ShaderType type, const FString &code, const char *defines, int maxGlslVersion) +{ + FString patchedCode; + + int shaderVersion = MIN((int)round(gl.glslversion * 10) * 10, maxGlslVersion); + patchedCode.AppendFormat("#version %d\n", shaderVersion); + + // TODO: Find some way to add extension requirements to the patching + // + // #extension GL_ARB_uniform_buffer_object : require + // #extension GL_ARB_shader_storage_buffer_object : require + + if (defines) + patchedCode << defines; + + if (gl.glslversion >= 1.3) + { + // these settings are actually pointless but there seem to be some old ATI drivers that fail to compile the shader without setting the precision here. + patchedCode << "precision highp int;\n"; + patchedCode << "precision highp float;\n"; + } + + patchedCode << "#line 1\n"; + patchedCode << code; + + if (gl.glslversion < 1.3) + { + if (type == Vertex) + PatchVertShader(patchedCode); + else if (type == Fragment) + PatchFragShader(patchedCode); + } + + return patchedCode; +} + +//========================================================================== +// +// patch the shader source to work with +// GLSL 1.2 keywords and identifiers +// +//========================================================================== + +void FShaderProgram::PatchCommon(FString &code) +{ + code.Substitute("precision highp int;", ""); + code.Substitute("precision highp float;", ""); +} + +void FShaderProgram::PatchVertShader(FString &code) +{ + PatchCommon(code); + code.Substitute("in vec", "attribute vec"); + code.Substitute("in float", "attribute float"); + code.Substitute("out vec", "varying vec"); + code.Substitute("out float", "varying float"); + code.Substitute("gl_ClipDistance", "//"); +} + +void FShaderProgram::PatchFragShader(FString &code) +{ + PatchCommon(code); + code.Substitute("out vec4 FragColor;", ""); + code.Substitute("FragColor", "gl_FragColor"); + code.Substitute("in vec", "varying vec"); + // this patches the switch statement to if's. + code.Substitute("break;", ""); + code.Substitute("switch (uFixedColormap)", "int i = uFixedColormap;"); + code.Substitute("case 0:", "if (i == 0)"); + code.Substitute("case 1:", "else if (i == 1)"); + code.Substitute("case 2:", "else if (i == 2)"); + code.Substitute("case 3:", "else if (i == 3)"); + code.Substitute("case 4:", "else if (i == 4)"); + code.Substitute("case 5:", "else if (i == 5)"); + code.Substitute("texture(", "texture2D("); +} diff --git a/src/gl/shaders/gl_shaderprogram.h b/src/gl/shaders/gl_shaderprogram.h index 8aebf1623..16684ddff 100644 --- a/src/gl/shaders/gl_shaderprogram.h +++ b/src/gl/shaders/gl_shaderprogram.h @@ -15,8 +15,8 @@ public: NumShaderTypes }; - void Compile(ShaderType type, const char *lumpName); - void Compile(ShaderType type, const char *name, const FString &code); + void Compile(ShaderType type, const char *lumpName, const char *defines, int maxGlslVersion); + void Compile(ShaderType type, const char *name, const FString &code, const char *defines, int maxGlslVersion); void SetFragDataLocation(int index, const char *name); void Link(const char *name); void SetAttribLocation(int index, const char *name); @@ -25,7 +25,14 @@ public: operator GLuint() const { return mProgram; } explicit operator bool() const { return mProgram != 0; } + // Needed by FShader + static void PatchVertShader(FString &code); + static void PatchFragShader(FString &code); + private: + static FString PatchShader(ShaderType type, const FString &code, const char *defines, int maxGlslVersion); + static void PatchCommon(FString &code); + void CreateShader(ShaderType type); FString GetShaderInfoLog(GLuint handle); FString GetProgramInfoLog(GLuint handle); diff --git a/src/gl/shaders/gl_tonemapshader.cpp b/src/gl/shaders/gl_tonemapshader.cpp index 44ea40012..c26e8d1af 100644 --- a/src/gl/shaders/gl_tonemapshader.cpp +++ b/src/gl/shaders/gl_tonemapshader.cpp @@ -51,15 +51,28 @@ void FTonemapShader::Bind() { - if (!mShader) + auto &shader = mShader[gl_tonemap]; + if (!shader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/tonemap.vp"); - mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/tonemap.fp"); - mShader.SetFragDataLocation(0, "FragColor"); - mShader.Link("shaders/glsl/tonemap"); - mShader.SetAttribLocation(0, "PositionInProjection"); - SceneTexture.Init(mShader, "InputTexture"); - Exposure.Init(mShader, "ExposureAdjustment"); + shader.Compile(FShaderProgram::Vertex, "shaders/glsl/tonemap.vp", "", 330); + shader.Compile(FShaderProgram::Fragment, "shaders/glsl/tonemap.fp", GetDefines(gl_tonemap), 330); + shader.SetFragDataLocation(0, "FragColor"); + shader.Link("shaders/glsl/tonemap"); + shader.SetAttribLocation(0, "PositionInProjection"); + SceneTexture.Init(shader, "InputTexture"); + Exposure.Init(shader, "ExposureAdjustment"); + } + shader.Bind(); +} + +const char *FTonemapShader::GetDefines(int mode) +{ + switch (mode) + { + default: + case Linear: return "#define LINEAR\n"; + case Reinhard: return "#define REINHARD\n"; + case HejlDawson: return "#define HEJLDAWSON\n"; + case Uncharted2: return "#define UNCHARTED2\n"; } - mShader.Bind(); } diff --git a/src/gl/shaders/gl_tonemapshader.h b/src/gl/shaders/gl_tonemapshader.h index 0380e31b8..846fdf659 100644 --- a/src/gl/shaders/gl_tonemapshader.h +++ b/src/gl/shaders/gl_tonemapshader.h @@ -12,7 +12,19 @@ public: FBufferedUniform1f Exposure; private: - FShaderProgram mShader; + enum TonemapMode + { + None, + Uncharted2, + HejlDawson, + Reinhard, + Linear, + NumTonemapModes + }; + + static const char *GetDefines(int mode); + + FShaderProgram mShader[NumTonemapModes]; }; #endif \ No newline at end of file diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index cedeec06a..27b588e11 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -41,4 +41,12 @@ EXTERN_CVAR(Bool, gl_seamless) EXTERN_CVAR(Float, gl_mask_threshold) EXTERN_CVAR(Float, gl_mask_sprite_threshold) +EXTERN_CVAR(Bool, gl_renderbuffers); + +EXTERN_CVAR(Bool, gl_bloom); +EXTERN_CVAR(Float, gl_bloom_amount) +EXTERN_CVAR(Int, gl_bloom_kernel_size) +EXTERN_CVAR(Int, gl_tonemap) +EXTERN_CVAR(Float, gl_exposure) + #endif // _GL_INTERN_H diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 7d091ebb6..ced1b8b4a 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -192,6 +192,9 @@ void gl_LoadExtensions() { if (CheckExtension("GL_NV_GPU_shader4") || CheckExtension("GL_EXT_GPU_shader4")) gl.glslversion = 1.21f; // for pre-3.0 drivers that support capable hardware. Needed for Apple. else gl.glslversion = 0; + + if (!CheckExtension("GL_EXT_packed_float")) gl.flags |= RFL_NO_RGBA16F; + if (!CheckExtension("GL_EXT_packed_depth_stencil")) gl.flags |= RFL_NO_DEPTHSTENCIL; } else if (gl.version < 4.f) { diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 433c2327c..1813e2c7f 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -20,6 +20,9 @@ enum RenderFlags RFL_SHADER_STORAGE_BUFFER = 4, RFL_BUFFER_STORAGE = 8, RFL_SAMPLER_OBJECTS = 16, + + RFL_NO_RGBA16F = 32, + RFL_NO_DEPTHSTENCIL = 64 }; enum TexMode diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 1f1dedba3..4c6922e4f 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -156,7 +156,7 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) glFinish(); wipestartscreen->Bind(0, false, false); - if (FGLRenderBuffers::IsSupported()) + if (FGLRenderBuffers::IsEnabled()) { GLRenderer->mBuffers->BindHudFB(); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); @@ -192,7 +192,7 @@ void OpenGLFrameBuffer::WipeEndScreen() glFinish(); wipeendscreen->Bind(0, false, false); - if (FGLRenderBuffers::IsSupported()) + if (FGLRenderBuffers::IsEnabled()) GLRenderer->mBuffers->BindHudFB(); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); @@ -230,7 +230,7 @@ bool OpenGLFrameBuffer::WipeDo(int ticks) glDisable(GL_DEPTH_TEST); glDepthMask(false); - if (FGLRenderBuffers::IsSupported()) + if (FGLRenderBuffers::IsEnabled()) { GLRenderer->mBuffers->BindHudFB(); glViewport(0, 0, GLRenderer->mOutputViewport.width, GLRenderer->mOutputViewport.height); diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 30b0f542f..df47661a4 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2618,6 +2618,8 @@ GLPREFMNU_AMBLIGHT = "Ambient light level"; GLPREFMNU_RENDERQUALITY = "Rendering quality"; GLPREFMNU_VRMODE = "Stereo 3D VR"; GLPREFMNU_VRQUADSTEREO = "Enable Quad Stereo"; +GLPREFMNU_TONEMAP = "Tonemap Mode"; +GLPREFMNU_BLOOM = "Bloom effect"; // Option Values OPTVAL_SMART = "Smart"; @@ -2686,3 +2688,6 @@ OPTVAL_AMBERBLUE = "Amber/Blue"; OPTVAL_LEFTEYE = "Left Eye"; OPTVAL_RIGHTEYE = "Right Eye"; OPTVAL_QUADBUFFERED = "Quad-buffered"; +OPTVAL_UNCHARTED2 = "Uncharted 2"; +OPTVAL_HEJLDAWSON = "Hejl Dawson"; +OPTVAL_REINHARD = "Reinhard"; \ No newline at end of file diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index e96f6b55c..d49197dad 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -32,6 +32,15 @@ OptionValue "HWGammaModes" 2, "$OPTVAL_FULLSCREENONLY" } +OptionValue "TonemapModes" +{ + 0, "$OPTVAL_OFF" + 1, "$OPTVAL_UNCHARTED2" + 2, "$OPTVAL_HEJLDAWSON" + 3, "$OPTVAL_REINHARD" + 4, "$OPTVAL_LINEAR" +} + OptionValue "TextureFormats" { 0, "$OPTVAL_RGBA8" @@ -198,4 +207,6 @@ OptionMenu "GLPrefOptions" Option "$GLPREFMNU_RENDERQUALITY", gl_render_precise, "Precision" Option "$GLPREFMNU_VRMODE", vr_mode, "VRMode" Option "$GLPREFMNU_VRQUADSTEREO", vr_enable_quadbuffered, "OnOff" + Option "$GLPREFMNU_TONEMAP", gl_tonemap, "TonemapModes" + Option "$GLPREFMNU_BLOOM", gl_bloom, "OnOff" } diff --git a/wadsrc/static/shaders/glsl/bloomcombine.fp b/wadsrc/static/shaders/glsl/bloomcombine.fp index 0db4802f0..57496771c 100644 --- a/wadsrc/static/shaders/glsl/bloomcombine.fp +++ b/wadsrc/static/shaders/glsl/bloomcombine.fp @@ -1,6 +1,4 @@ -#version 330 - in vec2 TexCoord; out vec4 FragColor; diff --git a/wadsrc/static/shaders/glsl/bloomcombine.vp b/wadsrc/static/shaders/glsl/bloomcombine.vp index b73fe7fc8..5990669a5 100644 --- a/wadsrc/static/shaders/glsl/bloomcombine.vp +++ b/wadsrc/static/shaders/glsl/bloomcombine.vp @@ -1,6 +1,4 @@ -#version 330 - in vec4 PositionInProjection; out vec2 TexCoord; diff --git a/wadsrc/static/shaders/glsl/bloomextract.fp b/wadsrc/static/shaders/glsl/bloomextract.fp index b6d663db6..dc753ce49 100644 --- a/wadsrc/static/shaders/glsl/bloomextract.fp +++ b/wadsrc/static/shaders/glsl/bloomextract.fp @@ -1,6 +1,4 @@ -#version 330 - in vec2 TexCoord; out vec4 FragColor; diff --git a/wadsrc/static/shaders/glsl/bloomextract.vp b/wadsrc/static/shaders/glsl/bloomextract.vp index b73fe7fc8..5990669a5 100644 --- a/wadsrc/static/shaders/glsl/bloomextract.vp +++ b/wadsrc/static/shaders/glsl/bloomextract.vp @@ -1,6 +1,4 @@ -#version 330 - in vec4 PositionInProjection; out vec2 TexCoord; diff --git a/wadsrc/static/shaders/glsl/present.fp b/wadsrc/static/shaders/glsl/present.fp index 93534ba7f..4a3f41840 100644 --- a/wadsrc/static/shaders/glsl/present.fp +++ b/wadsrc/static/shaders/glsl/present.fp @@ -1,6 +1,4 @@ -#version 330 - in vec2 TexCoord; out vec4 FragColor; diff --git a/wadsrc/static/shaders/glsl/present.vp b/wadsrc/static/shaders/glsl/present.vp index b73fe7fc8..5990669a5 100644 --- a/wadsrc/static/shaders/glsl/present.vp +++ b/wadsrc/static/shaders/glsl/present.vp @@ -1,6 +1,4 @@ -#version 330 - in vec4 PositionInProjection; out vec2 TexCoord; diff --git a/wadsrc/static/shaders/glsl/tonemap.fp b/wadsrc/static/shaders/glsl/tonemap.fp index e1e3d3497..35388b7b8 100644 --- a/wadsrc/static/shaders/glsl/tonemap.fp +++ b/wadsrc/static/shaders/glsl/tonemap.fp @@ -1,6 +1,4 @@ -#version 330 - in vec2 TexCoord; out vec4 FragColor; @@ -19,23 +17,31 @@ vec3 sRGB(vec3 c) return sqrt(c); // cheaper, but assuming gamma of 2.0 instead of 2.2 } -vec3 TonemapLinear(vec3 color) +#if defined(LINEAR) + +vec3 Tonemap(vec3 color) { return sRGB(color); } -vec3 TonemapReinhard(vec3 color) +#elif defined(REINHARD) + +vec3 Tonemap(vec3 color) { color = color / (1 + color); return sRGB(color); } -vec3 TonemapHejlDawson(vec3 color) +#elif defined(HEJLDAWSON) + +vec3 Tonemap(vec3 color) { vec3 x = max(vec3(0), color - 0.004); return (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06); // no sRGB needed } +#else + vec3 Uncharted2Tonemap(vec3 x) { float A = 0.15; @@ -47,7 +53,7 @@ vec3 Uncharted2Tonemap(vec3 x) return ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F; } -vec3 TonemapUncharted2(vec3 color) +vec3 Tonemap(vec3 color) { float W = 11.2; float ExposureBias = 2.0; @@ -56,10 +62,12 @@ vec3 TonemapUncharted2(vec3 color) return sRGB(curr * whiteScale); } +#endif + void main() { vec3 color = texture(InputTexture, TexCoord).rgb; color = color * ExposureAdjustment; color = Linear(color); // needed because gzdoom's scene texture is not linear at the moment - FragColor = vec4(TonemapUncharted2(color), 1.0); + FragColor = vec4(Tonemap(color), 1.0); } diff --git a/wadsrc/static/shaders/glsl/tonemap.vp b/wadsrc/static/shaders/glsl/tonemap.vp index b73fe7fc8..5990669a5 100644 --- a/wadsrc/static/shaders/glsl/tonemap.vp +++ b/wadsrc/static/shaders/glsl/tonemap.vp @@ -1,6 +1,4 @@ -#version 330 - in vec4 PositionInProjection; out vec2 TexCoord; From 9bfce5b6eafa5ddadc027d6567f43fb1dcf9ef2c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 30 Jul 2016 00:02:26 +0200 Subject: [PATCH 0738/1509] Moved post processing effects to its own file --- src/CMakeLists.txt | 1 + src/gl/renderer/gl_postprocess.cpp | 346 +++++++++++++++++++++++++++++ src/gl/scene/gl_scene.cpp | 273 ----------------------- 3 files changed, 347 insertions(+), 273 deletions(-) create mode 100644 src/gl/renderer/gl_postprocess.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6009a2c37..d3d339e0f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1062,6 +1062,7 @@ set( FASTMATH_SOURCES gl/renderer/gl_renderstate.cpp gl/renderer/gl_renderbuffers.cpp gl/renderer/gl_lightdata.cpp + gl/renderer/gl_postprocess.cpp gl/hqnx/init.cpp gl/hqnx/hq2x.cpp gl/hqnx/hq3x.cpp diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp new file mode 100644 index 000000000..c68cd6531 --- /dev/null +++ b/src/gl/renderer/gl_postprocess.cpp @@ -0,0 +1,346 @@ +/* +** gl_postprocess.cpp +** Post processing effects in the render pipeline +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "gi.h" +#include "m_png.h" +#include "m_random.h" +#include "st_stuff.h" +#include "dobject.h" +#include "doomstat.h" +#include "g_level.h" +#include "r_data/r_interpolate.h" +#include "r_utility.h" +#include "d_player.h" +#include "p_effect.h" +#include "sbar.h" +#include "po_man.h" +#include "r_utility.h" +#include "a_hexenglobal.h" +#include "p_local.h" +#include "gl/gl_functions.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_renderbuffers.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/shaders/gl_bloomshader.h" +#include "gl/shaders/gl_blurshader.h" +#include "gl/shaders/gl_tonemapshader.h" +#include "gl/shaders/gl_presentshader.h" + +//========================================================================== +// +// CVARs +// +//========================================================================== +CVAR(Bool, gl_bloom, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +CVAR(Float, gl_bloom_amount, 1.4f, 0) +CVAR(Float, gl_exposure, 0.0f, 0) + +CUSTOM_CVAR(Int, gl_tonemap, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + if (self < 0 || self > 4) + self = 0; +} + +CUSTOM_CVAR(Int, gl_bloom_kernel_size, 7, 0) +{ + if (self < 3 || self > 15 || self % 2 == 0) + self = 7; +} + +EXTERN_CVAR(Float, vid_brightness) +EXTERN_CVAR(Float, vid_contrast) + +//----------------------------------------------------------------------------- +// +// Adds bloom contribution to scene texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::BloomScene() +{ + // Only bloom things if enabled and no special fixed light mode is active + if (!gl_bloom || !FGLRenderBuffers::IsEnabled() || gl_fixedcolormap != CM_DEFAULT) + return; + + const float blurAmount = gl_bloom_amount; + int sampleCount = gl_bloom_kernel_size; + + // TBD: Maybe need a better way to share state with other parts of the pipeline + GLboolean blendEnabled, scissorEnabled; + GLint currentProgram, blendEquationRgb, blendEquationAlpha, blendSrcRgb, blendSrcAlpha, blendDestRgb, blendDestAlpha; + glGetBooleanv(GL_BLEND, &blendEnabled); + glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); + glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); + glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRgb); + glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); + glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRgb); + glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); + glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRgb); + glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); + + glDisable(GL_BLEND); + glDisable(GL_SCISSOR_TEST); + + const auto &level0 = mBuffers->BloomLevels[0]; + + // Extract blooming pixels from scene texture: + glBindFramebuffer(GL_FRAMEBUFFER, level0.VFramebuffer); + glViewport(0, 0, level0.Width, level0.Height); + mBuffers->BindSceneTexture(0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mBloomExtractShader->Bind(); + mBloomExtractShader->SceneTexture.Set(0); + mBloomExtractShader->Exposure.Set(mCameraExposure); + { + FFlatVertex *ptr = mVBO->GetBuffer(); + ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; + ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; + ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; + ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; + mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + // Blur and downscale: + for (int i = 0; i < FGLRenderBuffers::NumBloomLevels - 1; i++) + { + const auto &level = mBuffers->BloomLevels[i]; + const auto &next = mBuffers->BloomLevels[i + 1]; + mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); + mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level.HTexture, next.VFramebuffer, next.Width, next.Height); + } + + // Blur and upscale: + for (int i = FGLRenderBuffers::NumBloomLevels - 1; i > 0; i--) + { + const auto &level = mBuffers->BloomLevels[i]; + const auto &next = mBuffers->BloomLevels[i - 1]; + + mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); + mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level.HTexture, level.VFramebuffer, level.Width, level.Height); + + // Linear upscale: + glBindFramebuffer(GL_FRAMEBUFFER, next.VFramebuffer); + glViewport(0, 0, next.Width, next.Height); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, level.VTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mBloomCombineShader->Bind(); + mBloomCombineShader->BloomTexture.Set(0); + { + FFlatVertex *ptr = mVBO->GetBuffer(); + ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; + ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; + ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; + ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; + mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } + } + + mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level0.VTexture, level0.HFramebuffer, level0.Width, level0.Height); + mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level0.HTexture, level0.VFramebuffer, level0.Width, level0.Height); + + // Add bloom back to scene texture: + mBuffers->BindSceneFB(); + glViewport(0, 0, mOutputViewport.width, mOutputViewport.height); + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + glBlendFunc(GL_ONE, GL_ONE); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, level0.VTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mBloomCombineShader->Bind(); + mBloomCombineShader->BloomTexture.Set(0); + { + FFlatVertex *ptr = mVBO->GetBuffer(); + ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; + ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; + ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; + ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; + mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } + + if (blendEnabled) + glEnable(GL_BLEND); + if (scissorEnabled) + glEnable(GL_SCISSOR_TEST); + glBlendEquationSeparate(blendEquationRgb, blendEquationAlpha); + glBlendFuncSeparate(blendSrcRgb, blendDestRgb, blendSrcAlpha, blendDestAlpha); + glUseProgram(currentProgram); +} + +//----------------------------------------------------------------------------- +// +// Tonemap scene texture and place the result in the HUD/2D texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::TonemapScene() +{ + if (gl_tonemap == 0) + return; + + GLboolean blendEnabled, scissorEnabled; + glGetBooleanv(GL_BLEND, &blendEnabled); + glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); + + glDisable(GL_BLEND); + glDisable(GL_SCISSOR_TEST); + + mBuffers->BindHudFB(); + mBuffers->BindSceneTexture(0); + mTonemapShader->Bind(); + mTonemapShader->SceneTexture.Set(0); + mTonemapShader->Exposure.Set(mCameraExposure); + + FFlatVertex *ptr = mVBO->GetBuffer(); + ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; + ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; + ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; + ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; + mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + + if (blendEnabled) + glEnable(GL_BLEND); + if (scissorEnabled) + glEnable(GL_SCISSOR_TEST); +} + +//----------------------------------------------------------------------------- +// +// Gamma correct while copying to frame buffer +// +//----------------------------------------------------------------------------- + +void FGLRenderer::Flush() +{ + if (FGLRenderBuffers::IsEnabled()) + { + glDisable(GL_MULTISAMPLE); + glDisable(GL_DEPTH_TEST); + glDisable(GL_STENCIL_TEST); + + mBuffers->BindOutputFB(); + + // Calculate letterbox + int clientWidth = framebuffer->GetClientWidth(); + int clientHeight = framebuffer->GetClientHeight(); + float scaleX = clientWidth / (float)mOutputViewport.width; + float scaleY = clientHeight / (float)mOutputViewport.height; + float scale = MIN(scaleX, scaleY); + int width = (int)round(mOutputViewport.width * scale); + int height = (int)round(mOutputViewport.height * scale); + int x = (clientWidth - width) / 2; + int y = (clientHeight - height) / 2; + + // Black bars around the box: + glViewport(0, 0, clientWidth, clientHeight); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glEnable(GL_SCISSOR_TEST); + if (y > 0) + { + glScissor(0, 0, clientWidth, y); + glClear(GL_COLOR_BUFFER_BIT); + } + if (clientHeight - y - height > 0) + { + glScissor(0, y + height, clientWidth, clientHeight - y - height); + glClear(GL_COLOR_BUFFER_BIT); + } + if (x > 0) + { + glScissor(0, y, x, height); + glClear(GL_COLOR_BUFFER_BIT); + } + if (clientWidth - x - width > 0) + { + glScissor(x + width, y, clientWidth - x - width, height); + glClear(GL_COLOR_BUFFER_BIT); + } + glDisable(GL_SCISSOR_TEST); + + // Present what was rendered: + glViewport(x, y, width, height); + + GLboolean blendEnabled; + GLint currentProgram; + glGetBooleanv(GL_BLEND, &blendEnabled); + glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); + glDisable(GL_BLEND); + + mPresentShader->Bind(); + mPresentShader->InputTexture.Set(0); + if (framebuffer->IsHWGammaActive()) + { + mPresentShader->Gamma.Set(1.0f); + mPresentShader->Contrast.Set(1.0f); + mPresentShader->Brightness.Set(0.0f); + } + else + { + mPresentShader->Gamma.Set(clamp(Gamma, 0.1f, 4.f)); + mPresentShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); + mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); + } + mBuffers->BindHudTexture(0); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; + ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; + ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; + ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + + if (blendEnabled) + glEnable(GL_BLEND); + glUseProgram(currentProgram); + } +} diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index c23992f1b..aea69d941 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -72,10 +72,6 @@ #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" #include "gl/shaders/gl_shader.h" -#include "gl/shaders/gl_bloomshader.h" -#include "gl/shaders/gl_blurshader.h" -#include "gl/shaders/gl_tonemapshader.h" -#include "gl/shaders/gl_presentshader.h" #include "gl/stereo3d/gl_stereo3d.h" #include "gl/stereo3d/scoped_view_shifter.h" #include "gl/textures/gl_translate.h" @@ -96,26 +92,8 @@ CVAR(Float, gl_mask_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_sprite_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, gl_sort_textures, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -CVAR(Bool, gl_bloom, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); -CVAR(Float, gl_bloom_amount, 1.4f, 0) -CVAR(Float, gl_exposure, 0.0f, 0) - -CUSTOM_CVAR(Int, gl_tonemap, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -{ - if (self < 0 || self > 4) - self = 0; -} - -CUSTOM_CVAR(Int, gl_bloom_kernel_size, 7, 0) -{ - if (self < 3 || self > 15 || self % 2 == 0) - self = 7; -} - EXTERN_CVAR (Bool, cl_capfps) EXTERN_CVAR (Bool, r_deathcamera) -EXTERN_CVAR(Float, vid_brightness) -EXTERN_CVAR(Float, vid_contrast) extern int viewpitch; @@ -223,257 +201,6 @@ void FGLRenderer::Set3DViewport(bool toscreen) glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE); } -//----------------------------------------------------------------------------- -// -// Adds bloom contribution to scene texture -// -//----------------------------------------------------------------------------- - -void FGLRenderer::BloomScene() -{ - // Only bloom things if enabled and no special fixed light mode is active - if (!gl_bloom || !FGLRenderBuffers::IsEnabled() || gl_fixedcolormap != CM_DEFAULT) - return; - - const float blurAmount = gl_bloom_amount; - int sampleCount = gl_bloom_kernel_size; - - // TBD: Maybe need a better way to share state with other parts of the pipeline - GLboolean blendEnabled, scissorEnabled; - GLint currentProgram, blendEquationRgb, blendEquationAlpha, blendSrcRgb, blendSrcAlpha, blendDestRgb, blendDestAlpha; - glGetBooleanv(GL_BLEND, &blendEnabled); - glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); - glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRgb); - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRgb); - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRgb); - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - - glDisable(GL_BLEND); - glDisable(GL_SCISSOR_TEST); - - const auto &level0 = mBuffers->BloomLevels[0]; - - // Extract blooming pixels from scene texture: - glBindFramebuffer(GL_FRAMEBUFFER, level0.VFramebuffer); - glViewport(0, 0, level0.Width, level0.Height); - mBuffers->BindSceneTexture(0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - mBloomExtractShader->Bind(); - mBloomExtractShader->SceneTexture.Set(0); - mBloomExtractShader->Exposure.Set(mCameraExposure); - { - FFlatVertex *ptr = mVBO->GetBuffer(); - ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; - ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; - ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; - ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; - mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - // Blur and downscale: - for (int i = 0; i < FGLRenderBuffers::NumBloomLevels - 1; i++) - { - const auto &level = mBuffers->BloomLevels[i]; - const auto &next = mBuffers->BloomLevels[i + 1]; - mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); - mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level.HTexture, next.VFramebuffer, next.Width, next.Height); - } - - // Blur and upscale: - for (int i = FGLRenderBuffers::NumBloomLevels - 1; i > 0; i--) - { - const auto &level = mBuffers->BloomLevels[i]; - const auto &next = mBuffers->BloomLevels[i - 1]; - - mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); - mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level.HTexture, level.VFramebuffer, level.Width, level.Height); - - // Linear upscale: - glBindFramebuffer(GL_FRAMEBUFFER, next.VFramebuffer); - glViewport(0, 0, next.Width, next.Height); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, level.VTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - mBloomCombineShader->Bind(); - mBloomCombineShader->BloomTexture.Set(0); - { - FFlatVertex *ptr = mVBO->GetBuffer(); - ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; - ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; - ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; - ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; - mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } - } - - mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level0.VTexture, level0.HFramebuffer, level0.Width, level0.Height); - mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level0.HTexture, level0.VFramebuffer, level0.Width, level0.Height); - - // Add bloom back to scene texture: - mBuffers->BindSceneFB(); - glViewport(0, 0, mOutputViewport.width, mOutputViewport.height); - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_ONE, GL_ONE); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, level0.VTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - mBloomCombineShader->Bind(); - mBloomCombineShader->BloomTexture.Set(0); - { - FFlatVertex *ptr = mVBO->GetBuffer(); - ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; - ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; - ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; - ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; - mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } - - if (blendEnabled) - glEnable(GL_BLEND); - if (scissorEnabled) - glEnable(GL_SCISSOR_TEST); - glBlendEquationSeparate(blendEquationRgb, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRgb, blendDestRgb, blendSrcAlpha, blendDestAlpha); - glUseProgram(currentProgram); -} - -//----------------------------------------------------------------------------- -// -// Tonemap scene texture and place the result in the HUD/2D texture -// -//----------------------------------------------------------------------------- - -void FGLRenderer::TonemapScene() -{ - if (gl_tonemap == 0) - return; - - GLboolean blendEnabled, scissorEnabled; - glGetBooleanv(GL_BLEND, &blendEnabled); - glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); - - glDisable(GL_BLEND); - glDisable(GL_SCISSOR_TEST); - - mBuffers->BindHudFB(); - mBuffers->BindSceneTexture(0); - mTonemapShader->Bind(); - mTonemapShader->SceneTexture.Set(0); - mTonemapShader->Exposure.Set(mCameraExposure); - - FFlatVertex *ptr = mVBO->GetBuffer(); - ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; - ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; - ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; - ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; - mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - - if (blendEnabled) - glEnable(GL_BLEND); - if (scissorEnabled) - glEnable(GL_SCISSOR_TEST); -} - -//----------------------------------------------------------------------------- -// -// Gamma correct while copying to frame buffer -// -//----------------------------------------------------------------------------- - -void FGLRenderer::Flush() -{ - if (FGLRenderBuffers::IsEnabled()) - { - glDisable(GL_MULTISAMPLE); - glDisable(GL_DEPTH_TEST); - glDisable(GL_STENCIL_TEST); - - mBuffers->BindOutputFB(); - - // Calculate letterbox - int clientWidth = framebuffer->GetClientWidth(); - int clientHeight = framebuffer->GetClientHeight(); - float scaleX = clientWidth / (float)mOutputViewport.width; - float scaleY = clientHeight / (float)mOutputViewport.height; - float scale = MIN(scaleX, scaleY); - int width = (int)round(mOutputViewport.width * scale); - int height = (int)round(mOutputViewport.height * scale); - int x = (clientWidth - width) / 2; - int y = (clientHeight - height) / 2; - - // Black bars around the box: - glViewport(0, 0, clientWidth, clientHeight); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glEnable(GL_SCISSOR_TEST); - if (y > 0) - { - glScissor(0, 0, clientWidth, y); - glClear(GL_COLOR_BUFFER_BIT); - } - if (clientHeight - y - height > 0) - { - glScissor(0, y + height, clientWidth, clientHeight - y - height); - glClear(GL_COLOR_BUFFER_BIT); - } - if (x > 0) - { - glScissor(0, y, x, height); - glClear(GL_COLOR_BUFFER_BIT); - } - if (clientWidth - x - width > 0) - { - glScissor(x + width, y, clientWidth - x - width, height); - glClear(GL_COLOR_BUFFER_BIT); - } - glDisable(GL_SCISSOR_TEST); - - // Present what was rendered: - glViewport(x, y, width, height); - - GLboolean blendEnabled; - GLint currentProgram; - glGetBooleanv(GL_BLEND, &blendEnabled); - glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); - glDisable(GL_BLEND); - - mPresentShader->Bind(); - mPresentShader->InputTexture.Set(0); - if (framebuffer->IsHWGammaActive()) - { - mPresentShader->Gamma.Set(1.0f); - mPresentShader->Contrast.Set(1.0f); - mPresentShader->Brightness.Set(0.0f); - } - else - { - mPresentShader->Gamma.Set(clamp(Gamma, 0.1f, 4.f)); - mPresentShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); - mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); - } - mBuffers->BindHudTexture(0); - - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; - ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; - ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; - ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - - if (blendEnabled) - glEnable(GL_BLEND); - glUseProgram(currentProgram); - } -} - //----------------------------------------------------------------------------- // // Setup the camera position From 36705b0f040290bdc53e00d5245f24d80de5b71b Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Thu, 28 Jul 2016 16:47:04 -0500 Subject: [PATCH 0739/1509] Added GZDoom version of SpriteAngle and SpriteRotation. --- src/gl/scene/gl_sprite.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index d144da8fd..98e0fb8d5 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -722,7 +722,11 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) { bool mirror; DAngle ang = (thingpos - ViewPos).Angle(); - FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, (ang - thing->Angles.Yaw).BAMs(), &mirror); + FTextureID patch; + if (thing->flags7 & MF7_SPRITEANGLE) + patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, (thing->SpriteAngle).BAMs(), &mirror); + else + patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, (ang - (thing->Angles.Yaw + thing->SpriteRotation)).BAMs(), &mirror); if (!patch.isValid()) return; int type = thing->renderflags & RF_SPRITETYPEMASK; gltexture = FMaterial::ValidateTexture(patch, (type == RF_FACESPRITE), false); From e2a2d38a25c04b5a5584ba7f410bf763f8d055a9 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 30 Jul 2016 10:25:42 +0300 Subject: [PATCH 0740/1509] Removed redundant comparison in compatibility renderer Clang no longer reports "warning: comparison of array 'this->tcs' not equal to a null pointer is always true" --- src/gl/compatibility/gl_20.cpp | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 27f08a344..fb4064d3b 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -705,28 +705,25 @@ bool GLWall::PrepareLight(ADynamicLight * light, int pass) return false; } - if (tcs != NULL) + Vector t1; + int outcnt[4] = { 0,0,0,0 }; + + for (int i = 0; i<4; i++) { - Vector t1; - int outcnt[4] = { 0,0,0,0 }; + t1.Set(&vtx[i * 3]); + Vector nearToVert = t1 - nearPt; + tcs[i].u = (nearToVert.Dot(right) * scale) + 0.5f; + tcs[i].v = (nearToVert.Dot(up) * scale) + 0.5f; - for (int i = 0; i<4; i++) - { - t1.Set(&vtx[i * 3]); - Vector nearToVert = t1 - nearPt; - tcs[i].u = (nearToVert.Dot(right) * scale) + 0.5f; - tcs[i].v = (nearToVert.Dot(up) * scale) + 0.5f; + // quick check whether the light touches this polygon + if (tcs[i].u<0) outcnt[0]++; + if (tcs[i].u>1) outcnt[1]++; + if (tcs[i].v<0) outcnt[2]++; + if (tcs[i].v>1) outcnt[3]++; - // quick check whether the light touches this polygon - if (tcs[i].u<0) outcnt[0]++; - if (tcs[i].u>1) outcnt[1]++; - if (tcs[i].v<0) outcnt[2]++; - if (tcs[i].v>1) outcnt[3]++; - - } - // The light doesn't touch this polygon - if (outcnt[0] == 4 || outcnt[1] == 4 || outcnt[2] == 4 || outcnt[3] == 4) return false; } + // The light doesn't touch this polygon + if (outcnt[0] == 4 || outcnt[1] == 4 || outcnt[2] == 4 || outcnt[3] == 4) return false; draw_dlight++; return true; From c0b86278e388930827bd7b60ffb630d631bf5431 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 30 Jul 2016 12:27:49 +0300 Subject: [PATCH 0741/1509] Removed old cruft from macOS OpenGL backend The only thing left unimplemented is gl_smooth_rendered CVAR --- src/posix/cocoa/i_video.mm | 342 +------------------------------------ src/v_video.h | 2 - 2 files changed, 3 insertions(+), 341 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 4fa4f5574..3b04c64a0 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -333,74 +333,6 @@ private: // --------------------------------------------------------------------------- -class NonCopyable -{ -protected: - NonCopyable() { } - ~NonCopyable() { } - -private: - NonCopyable(const NonCopyable&); - const NonCopyable& operator=(const NonCopyable&); -}; - - -// --------------------------------------------------------------------------- - - -class RenderTarget : private NonCopyable -{ -public: - RenderTarget(const GLsizei width, const GLsizei height); - ~RenderTarget(); - - void Bind(); - void Unbind(); - - FHardwareTexture& GetColorTexture() - { - return m_texture; - } - -private: - GLuint m_ID; - GLuint m_oldID; - - FHardwareTexture m_texture; - - static GLuint GetBoundID(); - -}; // class RenderTarget - - -// --------------------------------------------------------------------------- - - -class CocoaOpenGLFrameBuffer : public OpenGLFrameBuffer, private NonCopyable -{ - typedef OpenGLFrameBuffer Super; - -public: - CocoaOpenGLFrameBuffer(void* hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen); - - virtual bool Lock(bool buffered); - virtual void Update(); - - virtual void GetScreenshotBuffer(const BYTE*& buffer, int& pitch, ESSType& color_type); - - virtual void SetSmoothPicture(bool smooth); - -private: - RenderTarget m_renderTarget; - - void DrawRenderTarget(); - -}; // class CocoaOpenGLFrameBuffer - - -// --------------------------------------------------------------------------- - - EXTERN_CVAR(Float, Gamma) CUSTOM_CVAR(Float, rgamma, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) @@ -661,7 +593,7 @@ DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, c if (1 == s_currentRenderer) { - fb = new CocoaOpenGLFrameBuffer(NULL, width, height, 32, 60, fullscreen); + fb = new OpenGLFrameBuffer(NULL, width, height, 32, 60, fullscreen); } else { @@ -1245,280 +1177,12 @@ void SDLGLFB::ResetGammaTable() int SDLGLFB::GetClientWidth() { - return GetWidth(); + return static_cast(rbOpts.width + 2.0f * rbOpts.shiftX); } int SDLGLFB::GetClientHeight() { - return GetHeight(); -} - - -// --------------------------------------------------------------------------- - - -void BoundTextureSetFilter(const GLenum target, const GLint filter) -{ - glTexParameteri(target, GL_TEXTURE_MIN_FILTER, filter); - glTexParameteri(target, GL_TEXTURE_MAG_FILTER, filter); - - glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); -} - -EXTERN_CVAR(Float, vid_brightness) -EXTERN_CVAR(Float, vid_contrast) - -void BoundTextureDraw2D(const GLsizei width, const GLsizei height) -{ - gl_RenderState.SetEffect(EFF_GAMMACORRECTION); - gl_RenderState.SetTextureMode(TM_OPAQUE); - gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); - gl_RenderState.SetColor(Gamma, vid_contrast, vid_brightness); - gl_RenderState.Apply(); - - static const float x = 0.f; - static const float y = 0.f; - const float w = float(width); - const float h = float(height); - - static const float u1 = 0.f; - static const float v1 = 1.f; - static const float u2 = 1.f; - static const float v2 = 0.f; - - FFlatVertexBuffer* const vbo = GLRenderer->mVBO; - FFlatVertex* ptr = vbo->GetBuffer(); - - ptr->Set(x, y, 0, u1, v1); ++ptr; - ptr->Set(x, y + h, 0, u1, v2); ++ptr; - ptr->Set(x + w, y, 0, u2, v1); ++ptr; - ptr->Set(x + w, y + h, 0, u2, v2); ++ptr; - - vbo->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - - gl_RenderState.SetEffect(EFF_NONE); - gl_RenderState.SetTextureMode(TM_MODULATE); -} - -bool BoundTextureSaveAsPNG(const GLenum target, const char* const path) -{ - if (NULL == path) - { - return false; - } - - GLint width = 0; - GLint height = 0; - - glGetTexLevelParameteriv(target, 0, GL_TEXTURE_WIDTH, &width ); - glGetTexLevelParameteriv(target, 0, GL_TEXTURE_HEIGHT, &height); - - if (0 == width || 0 == height) - { - Printf("BoundTextureSaveAsPNG: invalid texture size %ix%i\n", width, height); - - return false; - } - - static const int BYTES_PER_PIXEL = 4; - - const int imageSize = width * height * BYTES_PER_PIXEL; - unsigned char* imageBuffer = static_cast(malloc(imageSize)); - - if (NULL == imageBuffer) - { - Printf("BoundTextureSaveAsPNG: cannot allocate %i bytes\n", imageSize); - - return false; - } - - glGetTexImage(target, 0, GL_BGRA, GL_UNSIGNED_BYTE, imageBuffer); - - const int lineSize = width * BYTES_PER_PIXEL; - unsigned char lineBuffer[lineSize]; - - for (GLint line = 0; line < height / 2; ++line) - { - void* frontLinePtr = &imageBuffer[line * lineSize]; - void* backLinePtr = &imageBuffer[(height - line - 1) * lineSize]; - - memcpy( lineBuffer, frontLinePtr, lineSize); - memcpy(frontLinePtr, backLinePtr, lineSize); - memcpy( backLinePtr, lineBuffer, lineSize); - } - - FILE* file = fopen(path, "w"); - - if (NULL == file) - { - Printf("BoundTextureSaveAsPNG: cannot open file %s\n", path); - - free(imageBuffer); - - return false; - } - - const bool result = - M_CreatePNG(file, &imageBuffer[0], NULL, SS_BGRA, width, height, width * BYTES_PER_PIXEL) - && M_FinishPNG(file); - - fclose(file); - - free(imageBuffer); - - return result; -} - - -// --------------------------------------------------------------------------- - - -RenderTarget::RenderTarget(const GLsizei width, const GLsizei height) -: m_ID(0) -, m_oldID(0) -, m_texture(width, height, true) -{ - glGenFramebuffersEXT(1, &m_ID); - - Bind(); - m_texture.CreateTexture(NULL, width, height, 0, false, 0); - m_texture.BindToFrameBuffer(); - Unbind(); -} - -RenderTarget::~RenderTarget() -{ - glDeleteFramebuffersEXT(1, &m_ID); -} - - -void RenderTarget::Bind() -{ - const GLuint boundID = GetBoundID(); - - if (m_ID != boundID) - { - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_ID); - m_oldID = boundID; - } -} - -void RenderTarget::Unbind() -{ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_oldID); - m_oldID = 0; -} - - -GLuint RenderTarget::GetBoundID() -{ - GLint result; - glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &result); - - return static_cast(result); -} - - -// --------------------------------------------------------------------------- - - -CocoaOpenGLFrameBuffer::CocoaOpenGLFrameBuffer(void* hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) -: OpenGLFrameBuffer(hMonitor, width, height, bits, refreshHz, fullscreen) -, m_renderTarget(width, height) -{ - SetSmoothPicture(gl_smooth_rendered); - - // Fill render target with black color - - m_renderTarget.Bind(); - glClear(GL_COLOR_BUFFER_BIT); - m_renderTarget.Unbind(); -} - - -bool CocoaOpenGLFrameBuffer::Lock(bool buffered) -{ - if (0 == m_lock) - { - m_renderTarget.Bind(); - } - - return Super::Lock(buffered); -} - -void CocoaOpenGLFrameBuffer::Update() -{ - if (!CanUpdate()) - { - GLRenderer->Flush(); - return; - } - - Begin2D(false); - - DrawRateStuff(); - GLRenderer->Flush(); - - DrawRenderTarget(); - - Swap(); - Unlock(); - - CheckBench(); -} - - -void CocoaOpenGLFrameBuffer::GetScreenshotBuffer(const BYTE*& buffer, int& pitch, ESSType& color_type) -{ - m_renderTarget.Bind(); - - Super::GetScreenshotBuffer(buffer, pitch, color_type); - - m_renderTarget.Unbind(); -} - - -void CocoaOpenGLFrameBuffer::DrawRenderTarget() -{ - m_renderTarget.Unbind(); - m_renderTarget.GetColorTexture().Bind(0, 0, false); - - if (rbOpts.dirty) - { - // TODO: Figure out why the following glClear() call is needed - // to avoid drawing of garbage in fullscreen mode when - // in-game's aspect ratio is different from display one - glClear(GL_COLOR_BUFFER_BIT); - - rbOpts.dirty = false; - } - - glViewport(rbOpts.shiftX, rbOpts.shiftY, rbOpts.width, rbOpts.height); - - BoundTextureDraw2D(Width, Height); - - glViewport(0, 0, Width, Height); -} - - -void CocoaOpenGLFrameBuffer::SetSmoothPicture(const bool smooth) -{ - FHardwareTexture& texture = m_renderTarget.GetColorTexture(); - texture.Bind(0, 0, false); - BoundTextureSetFilter(GL_TEXTURE_2D, smooth ? GL_LINEAR : GL_NEAREST); -} - - -// --------------------------------------------------------------------------- - - -CUSTOM_CVAR(Bool, gl_smooth_rendered, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ - if (NULL != screen) - { - screen->SetSmoothPicture(self); - } + return static_cast(rbOpts.height + 2.0f * rbOpts.shiftY); } diff --git a/src/v_video.h b/src/v_video.h index 58dd2d9cb..fa1ce83df 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -415,8 +415,6 @@ public: virtual bool Is8BitMode() = 0; #endif - virtual void SetSmoothPicture(bool smooth) {} - protected: void DrawRateStuff (); void CopyFromBuff (BYTE *src, int srcPitch, int width, int height, BYTE *dest); From 7de242930a81c959c5812f0c77bdd29d713d2171 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 30 Jul 2016 15:30:35 +0300 Subject: [PATCH 0742/1509] Removed obsolete gamma correct shader used on macOS only --- src/gl/renderer/gl_renderstate.h | 1 - src/gl/shaders/gl_shader.cpp | 1 - wadsrc/static/shaders/glsl/gammacorrection.fp | 30 ------------------- 3 files changed, 32 deletions(-) delete mode 100644 wadsrc/static/shaders/glsl/gammacorrection.fp diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 0172488eb..2ad611ab2 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -37,7 +37,6 @@ enum EEffect EFF_SPHEREMAP, EFF_BURN, EFF_STENCIL, - EFF_GAMMACORRECTION, MAX_EFFECTS }; diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index b5fd1dbbd..f2b4c7ebd 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -395,7 +395,6 @@ static const FEffectShader effectshaders[]= { "spheremap", "shaders/glsl/main.vp", "shaders/glsl/main.fp", "shaders/glsl/func_normal.fp", "#define SPHEREMAP\n#define NO_ALPHATEST\n" }, { "burn", "shaders/glsl/main.vp", "shaders/glsl/burn.fp", NULL, "#define SIMPLE\n#define NO_ALPHATEST\n" }, { "stencil", "shaders/glsl/main.vp", "shaders/glsl/stencil.fp", NULL, "#define SIMPLE\n#define NO_ALPHATEST\n" }, - { "gammacorrection", "shaders/glsl/main.vp", "shaders/glsl/gammacorrection.fp", NULL, "#define SIMPLE\n" }, }; diff --git a/wadsrc/static/shaders/glsl/gammacorrection.fp b/wadsrc/static/shaders/glsl/gammacorrection.fp deleted file mode 100644 index fe40ac680..000000000 --- a/wadsrc/static/shaders/glsl/gammacorrection.fp +++ /dev/null @@ -1,30 +0,0 @@ -uniform sampler2D tex; - -in vec4 vTexCoord; -in vec4 vColor; - -out vec4 FragColor; - -void main() -{ - vec3 color = texture(tex, vTexCoord.st).rgb; - -// /* DEBUG */ if (vTexCoord.x > 0.5) - { - // Apply contrast - float contrast = clamp(vColor.y, 0.1, 3.0); - color = color.rgb * contrast - (contrast - 1.0) * 0.5; - - // Apply gamma - float gamma = clamp(vColor.x, 0.1, 4.0); - color = sign(color) * pow(abs(color), vec3(1.0 / gamma)); - - // Apply brightness - float brightness = clamp(vColor.z, -0.8, 0.8); - color += brightness * 0.5; - - color = clamp(color, 0.0, 1.0); - } - - FragColor = vec4(color, 1.0); -} From cfc20d119889adeefbad1f1e1ec2403e2a2286c8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 30 Jul 2016 15:33:30 +0200 Subject: [PATCH 0743/1509] Added multisample support to FGLRenderBuffers and added gl_multisample to the menus --- src/gl/renderer/gl_postprocess.cpp | 2 +- src/gl/renderer/gl_renderbuffers.cpp | 222 +++++++++++++++++++++++---- src/gl/renderer/gl_renderbuffers.h | 17 +- src/gl/scene/gl_scene.cpp | 1 + src/gl/system/gl_cvars.h | 5 +- wadsrc/static/language.enu | 2 + wadsrc/static/menudef.z | 11 ++ 7 files changed, 223 insertions(+), 37 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index c68cd6531..3c3dc4ee1 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -188,7 +188,7 @@ void FGLRenderer::BloomScene() mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level0.HTexture, level0.VFramebuffer, level0.Width, level0.Height); // Add bloom back to scene texture: - mBuffers->BindSceneFB(); + mBuffers->BindSceneTextureFB(); glViewport(0, 0, mOutputViewport.width, mOutputViewport.height); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 8be9e6b07..4863e1ec2 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -53,6 +53,7 @@ #include "i_system.h" #include "doomerrors.h" +CVAR(Int, gl_multisample, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); CVAR(Bool, gl_renderbuffers, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); //========================================================================== @@ -74,10 +75,29 @@ FGLRenderBuffers::FGLRenderBuffers() FGLRenderBuffers::~FGLRenderBuffers() { - Clear(); + ClearScene(); + ClearHud(); + ClearBloom(); } -void FGLRenderBuffers::Clear() +void FGLRenderBuffers::ClearScene() +{ + DeleteFrameBuffer(mSceneFB); + DeleteFrameBuffer(mSceneTextureFB); + DeleteRenderBuffer(mSceneMultisample); + DeleteRenderBuffer(mSceneDepthStencil); + DeleteRenderBuffer(mSceneDepth); + DeleteRenderBuffer(mSceneStencil); + DeleteTexture(mSceneTexture); +} + +void FGLRenderBuffers::ClearHud() +{ + DeleteFrameBuffer(mHudFB); + DeleteTexture(mHudTexture); +} + +void FGLRenderBuffers::ClearBloom() { for (int i = 0; i < NumBloomLevels; i++) { @@ -88,16 +108,6 @@ void FGLRenderBuffers::Clear() DeleteTexture(level.VTexture); level = FGLBloomTextureLevel(); } - - DeleteFrameBuffer(mSceneFB); - DeleteTexture(mSceneTexture); - DeleteRenderBuffer(mSceneDepthStencil); - DeleteRenderBuffer(mSceneDepth); - DeleteRenderBuffer(mSceneStencil); - DeleteFrameBuffer(mHudFB); - DeleteTexture(mHudTexture); - mWidth = 0; - mHeight = 0; } void FGLRenderBuffers::DeleteTexture(GLuint &handle) @@ -130,28 +140,80 @@ void FGLRenderBuffers::DeleteFrameBuffer(GLuint &handle) void FGLRenderBuffers::Setup(int width, int height) { - if (width <= mWidth && height <= mHeight) - return; + int samples = GetCvarSamples(); - Clear(); + if (width == mWidth && height == mHeight && mSamples != samples) + { + CreateScene(mWidth, mHeight, samples); + mSamples = samples; + } + else if (width > mWidth || height > mHeight) + { + CreateScene(width, height, samples); + CreateHud(width, height); + CreateBloom(width, height); + mWidth = width; + mHeight = height; + mSamples = samples; + } - GLuint hdrFormat = ((gl.flags & RFL_NO_RGBA16F) != 0) ? GL_RGBA8 : GL_RGBA16F; + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, 0); + glBindRenderbuffer(GL_RENDERBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); +} + +//========================================================================== +// +// Creates the scene buffers +// +//========================================================================== + +void FGLRenderBuffers::CreateScene(int width, int height, int samples) +{ + ClearScene(); + + mSceneTexture = Create2DTexture(GetHdrFormat(), width, height); + mSceneTextureFB = CreateFrameBuffer(mSceneTexture); + + if (samples > 1) + mSceneMultisample = CreateRenderBuffer(GetHdrFormat(), samples, width, height); - mSceneTexture = Create2DTexture(hdrFormat, width, height); if ((gl.flags & RFL_NO_DEPTHSTENCIL) != 0) { - mSceneDepth = CreateRenderBuffer(GL_DEPTH_COMPONENT24, width, height); - mSceneStencil = CreateRenderBuffer(GL_STENCIL_INDEX8, width, height); - mSceneFB = CreateFrameBuffer(mSceneTexture, mSceneDepth, mSceneStencil); + mSceneDepth = CreateRenderBuffer(GL_DEPTH_COMPONENT24, samples, width, height); + mSceneStencil = CreateRenderBuffer(GL_STENCIL_INDEX8, samples, width, height); + mSceneFB = CreateFrameBuffer(samples > 1 ? mSceneMultisample : mSceneTexture, mSceneDepth, mSceneStencil); } else { - mSceneDepthStencil = CreateRenderBuffer(GL_DEPTH24_STENCIL8, width, height); - mSceneFB = CreateFrameBuffer(mSceneTexture, mSceneDepthStencil); + mSceneDepthStencil = CreateRenderBuffer(GL_DEPTH24_STENCIL8, samples, width, height); + mSceneFB = CreateFrameBuffer(samples > 1 ? mSceneMultisample : mSceneTexture, mSceneDepthStencil); } +} - mHudTexture = Create2DTexture(hdrFormat, width, height); +//========================================================================== +// +// Creates the post-tonemapping-step buffers +// +//========================================================================== + +void FGLRenderBuffers::CreateHud(int width, int height) +{ + ClearHud(); + mHudTexture = Create2DTexture(GetHdrFormat(), width, height); mHudFB = CreateFrameBuffer(mHudTexture); +} + +//========================================================================== +// +// Creates bloom pass working buffers +// +//========================================================================== + +void FGLRenderBuffers::CreateBloom(int width, int height) +{ + ClearBloom(); int bloomWidth = MAX(width / 2, 1); int bloomHeight = MAX(height / 2, 1); @@ -161,22 +223,44 @@ void FGLRenderBuffers::Setup(int width, int height) level.Width = MAX(bloomWidth / 2, 1); level.Height = MAX(bloomHeight / 2, 1); - level.VTexture = Create2DTexture(hdrFormat, level.Width, level.Height); - level.HTexture = Create2DTexture(hdrFormat, level.Width, level.Height); + level.VTexture = Create2DTexture(GetHdrFormat(), level.Width, level.Height); + level.HTexture = Create2DTexture(GetHdrFormat(), level.Width, level.Height); level.VFramebuffer = CreateFrameBuffer(level.VTexture); level.HFramebuffer = CreateFrameBuffer(level.HTexture); bloomWidth = level.Width; bloomHeight = level.Height; } +} - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, 0); - glBindRenderbuffer(GL_RENDERBUFFER, 0); - glBindFramebuffer(GL_FRAMEBUFFER, mOutputFB); +//========================================================================== +// +// Fallback support for older OpenGL where RGBA16F might not be available +// +//========================================================================== - mWidth = width; - mHeight = height; +GLuint FGLRenderBuffers::GetHdrFormat() +{ + return ((gl.flags & RFL_NO_RGBA16F) != 0) ? GL_RGBA8 : GL_RGBA16F; +} + +//========================================================================== +// +// Converts the CVAR multisample value into a valid level for OpenGL +// +//========================================================================== + +int FGLRenderBuffers::GetCvarSamples() +{ + int maxSamples = 0; + glGetIntegerv(GL_MAX_SAMPLES, &maxSamples); + + int samples = clamp((int)gl_multisample, 0, maxSamples); + + int count; + for (count = 0; samples > 0; count++) + samples >>= 1; + return count; } //========================================================================== @@ -215,6 +299,18 @@ GLuint FGLRenderBuffers::CreateRenderBuffer(GLuint format, int width, int height return handle; } +GLuint FGLRenderBuffers::CreateRenderBuffer(GLuint format, int samples, int width, int height) +{ + if (samples <= 1) + return CreateRenderBuffer(format, width, height); + + GLuint handle = 0; + glGenRenderbuffers(1, &handle); + glBindRenderbuffer(GL_RENDERBUFFER, handle); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, format, width, height); + return handle; +} + //========================================================================== // // Creates a frame buffer @@ -227,6 +323,7 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer) glGenFramebuffers(1, &handle); glBindFramebuffer(GL_FRAMEBUFFER, handle); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); + CheckFrameBufferCompleteness(); return handle; } @@ -237,6 +334,7 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depthstenc glBindFramebuffer(GL_FRAMEBUFFER, handle); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil); + CheckFrameBufferCompleteness(); return handle; } @@ -248,12 +346,59 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLu glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil); + CheckFrameBufferCompleteness(); return handle; } //========================================================================== // -// Makes the scene frame buffer active +// Verifies that the frame buffer setup is valid +// +//========================================================================== + +void FGLRenderBuffers::CheckFrameBufferCompleteness() +{ + GLenum result = glCheckFramebufferStatus(GL_FRAMEBUFFER); + if (result == GL_FRAMEBUFFER_COMPLETE) + return; + + FString error = "glCheckFramebufferStatus failed: "; + switch (result) + { + default: error.AppendFormat("error code %d", (int)result); break; + case GL_FRAMEBUFFER_UNDEFINED: error << "GL_FRAMEBUFFER_UNDEFINED"; break; + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: error << "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"; break; + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: error << "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"; break; + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: error << "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER"; break; + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: error << "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER"; break; + case GL_FRAMEBUFFER_UNSUPPORTED: error << "GL_FRAMEBUFFER_UNSUPPORTED"; break; + case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: error << "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"; break; + case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: error << "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS"; break; + } + I_FatalError(error); +} + +//========================================================================== +// +// Resolves the multisample frame buffer by copying it to the scene texture +// +//========================================================================== + +void FGLRenderBuffers::BlitSceneToTexture() +{ + if (mSamples <= 1) + return; + + glBindFramebuffer(GL_READ_FRAMEBUFFER, mSceneFB); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mSceneTextureFB); + glBlitFramebuffer(0, 0, mWidth, mHeight, 0, 0, mWidth, mHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST); + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); +} + +//========================================================================== +// +// Makes the scene frame buffer active (multisample, depth, stecil, etc.) // //========================================================================== @@ -262,6 +407,17 @@ void FGLRenderBuffers::BindSceneFB() glBindFramebuffer(GL_FRAMEBUFFER, mSceneFB); } +//========================================================================== +// +// Makes the scene texture frame buffer active (final 2D texture only) +// +//========================================================================== + +void FGLRenderBuffers::BindSceneTextureFB() +{ + glBindFramebuffer(GL_FRAMEBUFFER, mSceneTextureFB); +} + //========================================================================== // // Makes the 2D/HUD frame buffer active @@ -273,7 +429,7 @@ void FGLRenderBuffers::BindHudFB() if (gl_tonemap != 0) glBindFramebuffer(GL_FRAMEBUFFER, mHudFB); else - glBindFramebuffer(GL_FRAMEBUFFER, mSceneFB); + glBindFramebuffer(GL_FRAMEBUFFER, mSceneTextureFB); } //========================================================================== diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index ba5e94ab3..9c221a42a 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -21,7 +21,9 @@ public: ~FGLRenderBuffers(); void Setup(int width, int height); + void BlitSceneToTexture(); void BindSceneFB(); + void BindSceneTextureFB(); void BindHudFB(); void BindOutputFB(); void BindSceneTexture(int index); @@ -33,24 +35,37 @@ public: static bool IsEnabled(); private: - void Clear(); + void ClearScene(); + void ClearHud(); + void ClearBloom(); + void CreateScene(int width, int height, int samples); + void CreateHud(int width, int height); + void CreateBloom(int width, int height); GLuint Create2DTexture(GLuint format, int width, int height); GLuint CreateRenderBuffer(GLuint format, int width, int height); + GLuint CreateRenderBuffer(GLuint format, int samples, int width, int height); GLuint CreateFrameBuffer(GLuint colorbuffer); GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depthstencil); GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLuint stencil); + void CheckFrameBufferCompleteness(); void DeleteTexture(GLuint &handle); void DeleteRenderBuffer(GLuint &handle); void DeleteFrameBuffer(GLuint &handle); + int GetCvarSamples(); + GLuint GetHdrFormat(); + int mWidth = 0; int mHeight = 0; + int mSamples = 0; GLuint mSceneTexture = 0; + GLuint mSceneMultisample = 0; GLuint mSceneDepthStencil = 0; GLuint mSceneDepth = 0; GLuint mSceneStencil = 0; GLuint mSceneFB = 0; + GLuint mSceneTextureFB = 0; GLuint mHudTexture = 0; GLuint mHudFB = 0; GLuint mOutputFB = 0; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index aea69d941..b28e2c293 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -868,6 +868,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo if (mainview) EndDrawScene(retval); // do not call this for camera textures. if (toscreen) { + if (FGLRenderBuffers::IsEnabled()) mBuffers->BlitSceneToTexture(); BloomScene(); TonemapScene(); } diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index 27b588e11..30f4cc4f3 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -41,9 +41,10 @@ EXTERN_CVAR(Bool, gl_seamless) EXTERN_CVAR(Float, gl_mask_threshold) EXTERN_CVAR(Float, gl_mask_sprite_threshold) -EXTERN_CVAR(Bool, gl_renderbuffers); +EXTERN_CVAR(Bool, gl_renderbuffers) +EXTERN_CVAR(Int, gl_multisample) -EXTERN_CVAR(Bool, gl_bloom); +EXTERN_CVAR(Bool, gl_bloom) EXTERN_CVAR(Float, gl_bloom_amount) EXTERN_CVAR(Int, gl_bloom_kernel_size) EXTERN_CVAR(Int, gl_tonemap) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index df47661a4..21aab53a6 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2618,6 +2618,7 @@ GLPREFMNU_AMBLIGHT = "Ambient light level"; GLPREFMNU_RENDERQUALITY = "Rendering quality"; GLPREFMNU_VRMODE = "Stereo 3D VR"; GLPREFMNU_VRQUADSTEREO = "Enable Quad Stereo"; +GLPREFMNU_MULTISAMPLE = "Multisample"; GLPREFMNU_TONEMAP = "Tonemap Mode"; GLPREFMNU_BLOOM = "Bloom effect"; @@ -2644,6 +2645,7 @@ OPTVAL_2X = "2x"; OPTVAL_4X = "4x"; OPTVAL_8X = "8x"; OPTVAL_16X = "16x"; +OPTVAL_32X = "32x"; OPTVAL_USEASPALETTE = "Use as palette"; OPTVAL_BLEND = "Blend"; OPTVAL_STANDARD = "Standard"; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index d49197dad..bcee4ca01 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -63,6 +63,16 @@ OptionValue "Anisotropy" 16, "$OPTVAL_16X" } +OptionValue "Multisample" +{ + 1, "$OPTVAL_OFF" + 2, "$OPTVAL_2X" + 4, "$OPTVAL_4X" + 8, "$OPTVAL_8X" + 16, "$OPTVAL_16X" + 32, "$OPTVAL_32X" +} + OptionValue "Colormaps" { 0, "$OPTVAL_USEASPALETTE" @@ -207,6 +217,7 @@ OptionMenu "GLPrefOptions" Option "$GLPREFMNU_RENDERQUALITY", gl_render_precise, "Precision" Option "$GLPREFMNU_VRMODE", vr_mode, "VRMode" Option "$GLPREFMNU_VRQUADSTEREO", vr_enable_quadbuffered, "OnOff" + Option "$GLPREFMNU_MULTISAMPLE", gl_multisample, "Multisample" Option "$GLPREFMNU_TONEMAP", gl_tonemap, "TonemapModes" Option "$GLPREFMNU_BLOOM", gl_bloom, "OnOff" } From 1682b02c670b7d581554b787d7bc253eca61df7b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 30 Jul 2016 19:54:20 +0200 Subject: [PATCH 0744/1509] Fix glBindSampler state messing up post processing shaders --- src/gl/renderer/gl_postprocess.cpp | 50 +++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index c68cd6531..54848fa64 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -110,6 +110,15 @@ void FGLRenderer::BloomScene() int sampleCount = gl_bloom_kernel_size; // TBD: Maybe need a better way to share state with other parts of the pipeline + GLint activeTex, textureBinding, samplerBinding; + glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); + glActiveTexture(GL_TEXTURE0); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding); + glBindSampler(0, 0); + } GLboolean blendEnabled, scissorEnabled; GLint currentProgram, blendEquationRgb, blendEquationAlpha, blendSrcRgb, blendSrcAlpha, blendDestRgb, blendDestAlpha; glGetBooleanv(GL_BLEND, &blendEnabled); @@ -215,6 +224,10 @@ void FGLRenderer::BloomScene() glBlendEquationSeparate(blendEquationRgb, blendEquationAlpha); glBlendFuncSeparate(blendSrcRgb, blendDestRgb, blendSrcAlpha, blendDestAlpha); glUseProgram(currentProgram); + glBindTexture(GL_TEXTURE_2D, textureBinding); + if (gl.flags & RFL_SAMPLER_OBJECTS) + glBindSampler(0, samplerBinding); + glActiveTexture(activeTex); } //----------------------------------------------------------------------------- @@ -228,6 +241,16 @@ void FGLRenderer::TonemapScene() if (gl_tonemap == 0) return; + GLint activeTex, textureBinding, samplerBinding; + glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); + glActiveTexture(GL_TEXTURE0); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding); + glBindSampler(0, 0); + } + GLboolean blendEnabled, scissorEnabled; glGetBooleanv(GL_BLEND, &blendEnabled); glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); @@ -252,6 +275,10 @@ void FGLRenderer::TonemapScene() glEnable(GL_BLEND); if (scissorEnabled) glEnable(GL_SCISSOR_TEST); + glBindTexture(GL_TEXTURE_2D, textureBinding); + if (gl.flags & RFL_SAMPLER_OBJECTS) + glBindSampler(0, samplerBinding); + glActiveTexture(activeTex); } //----------------------------------------------------------------------------- @@ -268,6 +295,20 @@ void FGLRenderer::Flush() glDisable(GL_DEPTH_TEST); glDisable(GL_STENCIL_TEST); + GLboolean blendEnabled; + GLint currentProgram; + GLint activeTex, textureBinding, samplerBinding; + glGetBooleanv(GL_BLEND, &blendEnabled); + glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); + glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); + glActiveTexture(GL_TEXTURE0); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding); + glBindSampler(0, 0); + } + mBuffers->BindOutputFB(); // Calculate letterbox @@ -309,11 +350,6 @@ void FGLRenderer::Flush() // Present what was rendered: glViewport(x, y, width, height); - - GLboolean blendEnabled; - GLint currentProgram; - glGetBooleanv(GL_BLEND, &blendEnabled); - glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); glDisable(GL_BLEND); mPresentShader->Bind(); @@ -342,5 +378,9 @@ void FGLRenderer::Flush() if (blendEnabled) glEnable(GL_BLEND); glUseProgram(currentProgram); + glBindTexture(GL_TEXTURE_2D, textureBinding); + if (gl.flags & RFL_SAMPLER_OBJECTS) + glBindSampler(0, samplerBinding); + glActiveTexture(activeTex); } } From b789aaa0ebcba90e22977be45663f473a3145b5d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 31 Jul 2016 03:16:48 +0200 Subject: [PATCH 0745/1509] Fix binding error that Nvidia didn't complain about but Intel on Mac does --- src/gl/renderer/gl_renderbuffers.cpp | 18 ++++++++++++------ src/gl/renderer/gl_renderbuffers.h | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 4863e1ec2..a65626007 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -183,12 +183,12 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples) { mSceneDepth = CreateRenderBuffer(GL_DEPTH_COMPONENT24, samples, width, height); mSceneStencil = CreateRenderBuffer(GL_STENCIL_INDEX8, samples, width, height); - mSceneFB = CreateFrameBuffer(samples > 1 ? mSceneMultisample : mSceneTexture, mSceneDepth, mSceneStencil); + mSceneFB = CreateFrameBuffer(samples > 1 ? mSceneMultisample : mSceneTexture, mSceneDepth, mSceneStencil, samples > 1); } else { mSceneDepthStencil = CreateRenderBuffer(GL_DEPTH24_STENCIL8, samples, width, height); - mSceneFB = CreateFrameBuffer(samples > 1 ? mSceneMultisample : mSceneTexture, mSceneDepthStencil); + mSceneFB = CreateFrameBuffer(samples > 1 ? mSceneMultisample : mSceneTexture, mSceneDepthStencil, samples > 1); } } @@ -327,23 +327,29 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer) return handle; } -GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depthstencil) +GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer) { GLuint handle = 0; glGenFramebuffers(1, &handle); glBindFramebuffer(GL_FRAMEBUFFER, handle); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); + if (colorIsARenderBuffer) + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); + else + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil); CheckFrameBufferCompleteness(); return handle; } -GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLuint stencil) +GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer) { GLuint handle = 0; glGenFramebuffers(1, &handle); glBindFramebuffer(GL_FRAMEBUFFER, handle); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); + if (colorIsARenderBuffer) + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); + else + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil); CheckFrameBufferCompleteness(); diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 9c221a42a..b4765b544 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -45,8 +45,8 @@ private: GLuint CreateRenderBuffer(GLuint format, int width, int height); GLuint CreateRenderBuffer(GLuint format, int samples, int width, int height); GLuint CreateFrameBuffer(GLuint colorbuffer); - GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depthstencil); - GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLuint stencil); + GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer); + GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer); void CheckFrameBufferCompleteness(); void DeleteTexture(GLuint &handle); void DeleteRenderBuffer(GLuint &handle); From 849e80074e47a92361b628c2dfb1c702dd5cf3ca Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 31 Jul 2016 03:54:16 +0200 Subject: [PATCH 0746/1509] Added GLSL 120 fallback support --- src/gl/shaders/gl_blurshader.cpp | 30 ++++++++++++++++++++++++++++++ src/gl/shaders/gl_blurshader.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/src/gl/shaders/gl_blurshader.cpp b/src/gl/shaders/gl_blurshader.cpp index 14bcc28c5..10168148b 100644 --- a/src/gl/shaders/gl_blurshader.cpp +++ b/src/gl/shaders/gl_blurshader.cpp @@ -86,6 +86,20 @@ void FBlurShader::Blur(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount else setup->HorizontalShader->Bind(); + if (gl.glslversion < 1.3) + { + if (vertical) + { + setup->VerticalScaleX.Set(1.0f / width); + setup->VerticalScaleY.Set(1.0f / height); + } + else + { + setup->HorizontalScaleX.Set(1.0f / width); + setup->HorizontalScaleY.Set(1.0f / height); + } + } + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, inputTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -145,6 +159,14 @@ FBlurShader::BlurSetup *FBlurShader::GetSetup(float blurAmount, int sampleCount) blurSetup.HorizontalShader->Link("horizontal blur"); blurSetup.HorizontalShader->Bind(); glUniform1i(glGetUniformLocation(*blurSetup.HorizontalShader.get(), "SourceTexture"), 0); + + if (gl.glslversion < 1.3) + { + blurSetup.VerticalScaleX.Init(*blurSetup.VerticalShader.get(), "ScaleX"); + blurSetup.VerticalScaleY.Init(*blurSetup.VerticalShader.get(), "ScaleY"); + blurSetup.HorizontalScaleX.Init(*blurSetup.HorizontalShader.get(), "ScaleX"); + blurSetup.HorizontalScaleY.Init(*blurSetup.HorizontalShader.get(), "ScaleY"); + } mBlurSetups.Push(blurSetup); @@ -188,6 +210,14 @@ FString FBlurShader::FragmentShaderCode(float blurAmount, int sampleCount, bool in vec2 TexCoord; uniform sampler2D SourceTexture; out vec4 FragColor; + #if __VERSION__ < 130 + uniform float ScaleX; + uniform float ScaleY; + vec4 textureOffset(sampler2D s, vec2 texCoord, ivec2 offset) + { + return texture2D(s, texCoord + vec2(ScaleX * float(offset.x), ScaleY * float(offset.y))); + } + #endif void main() { FragColor = %s; diff --git a/src/gl/shaders/gl_blurshader.h b/src/gl/shaders/gl_blurshader.h index 9bf4a9d5d..9af5a9101 100644 --- a/src/gl/shaders/gl_blurshader.h +++ b/src/gl/shaders/gl_blurshader.h @@ -23,6 +23,8 @@ private: int sampleCount; std::shared_ptr VerticalShader; std::shared_ptr HorizontalShader; + FBufferedUniform1f VerticalScaleX, VerticalScaleY; + FBufferedUniform1f HorizontalScaleX, HorizontalScaleY; }; BlurSetup *GetSetup(float blurAmount, int sampleCount); From d3457f45080c7735dd7dac007730942dbb3a72f1 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 31 Jul 2016 12:19:08 +0300 Subject: [PATCH 0747/1509] Implemented hardware gamma support for macOS Hardware gamma is limited to main display only, use shader-based correction for other displays --- src/posix/cocoa/i_video.mm | 30 ++++++++++++++++++++++++++++++ src/posix/cocoa/sdlglvideo.h | 7 ++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 3b04c64a0..242cb489b 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -1086,6 +1086,20 @@ SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool , m_lock(-1) , m_isUpdatePending(false) { + CGGammaValue gammaTable[GAMMA_TABLE_SIZE]; + uint32_t actualChannelSize; + + const CGError result = CGGetDisplayTransferByTable(kCGDirectMainDisplay, GAMMA_CHANNEL_SIZE, + gammaTable, &gammaTable[GAMMA_CHANNEL_SIZE], &gammaTable[GAMMA_CHANNEL_SIZE * 2], &actualChannelSize); + m_supportsGamma = kCGErrorSuccess == result && GAMMA_CHANNEL_SIZE == actualChannelSize; + + if (m_supportsGamma) + { + for (uint32_t i = 0; i < GAMMA_TABLE_SIZE; ++i) + { + m_originalGamma[i] = static_cast(gammaTable[i] * 65535.0f); + } + } } SDLGLFB::SDLGLFB() @@ -1169,10 +1183,26 @@ void SDLGLFB::SwapBuffers() void SDLGLFB::SetGammaTable(WORD* table) { + if (m_supportsGamma) + { + CGGammaValue gammaTable[GAMMA_TABLE_SIZE]; + + for (uint32_t i = 0; i < GAMMA_TABLE_SIZE; ++i) + { + gammaTable[i] = static_cast(table[i] / 65535.0f); + } + + CGSetDisplayTransferByTable(kCGDirectMainDisplay, GAMMA_CHANNEL_SIZE, + gammaTable, &gammaTable[GAMMA_CHANNEL_SIZE], &gammaTable[GAMMA_CHANNEL_SIZE * 2]); + } } void SDLGLFB::ResetGammaTable() { + if (m_supportsGamma) + { + SetGammaTable(m_originalGamma); + } } int SDLGLFB::GetClientWidth() diff --git a/src/posix/cocoa/sdlglvideo.h b/src/posix/cocoa/sdlglvideo.h index 4a63a9193..cab846a15 100644 --- a/src/posix/cocoa/sdlglvideo.h +++ b/src/posix/cocoa/sdlglvideo.h @@ -71,7 +71,12 @@ protected: int m_lock; bool m_isUpdatePending; - static const bool m_supportsGamma = false; + static const uint32_t GAMMA_CHANNEL_SIZE = 256; + static const uint32_t GAMMA_CHANNEL_COUNT = 3; + static const uint32_t GAMMA_TABLE_SIZE = GAMMA_CHANNEL_SIZE * GAMMA_CHANNEL_COUNT; + + bool m_supportsGamma; + WORD m_originalGamma[GAMMA_TABLE_SIZE]; SDLGLFB(); From a6354c74cfc6dfd20c8d6344326fe5c67e527861 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 31 Jul 2016 13:23:49 +0200 Subject: [PATCH 0748/1509] Fix incorrect viewport location when not using fullscreen HUD --- src/gl/renderer/gl_postprocess.cpp | 2 +- src/gl/renderer/gl_renderer.cpp | 13 ++++++++----- src/gl/renderer/gl_renderer.h | 1 + src/gl/scene/gl_scene.cpp | 17 +++++------------ src/gl/system/gl_wipe.cpp | 3 ++- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 9dc0dd99e..e13acda4a 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -198,7 +198,7 @@ void FGLRenderer::BloomScene() // Add bloom back to scene texture: mBuffers->BindSceneTextureFB(); - glViewport(0, 0, mOutputViewport.width, mOutputViewport.height); + glViewport(mOutputViewport.left, mOutputViewport.top, mOutputViewport.width, mOutputViewport.height); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); glBlendFunc(GL_ONE, GL_ONE); diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index a1d8bb2a7..d2a0cb959 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -185,6 +185,7 @@ void FGLRenderer::SetOutputViewport(GL_IRECT *bounds) { mOutputViewport = *bounds; mOutputViewportLB = *bounds; + mScreenViewport = *bounds; return; } @@ -209,6 +210,12 @@ void FGLRenderer::SetOutputViewport(GL_IRECT *bounds) int vw = viewwidth; int vh = viewheight; + // The entire renderable area, including the 2D HUD + mScreenViewport.left = 0; + mScreenViewport.top = 0; + mScreenViewport.width = framebuffer->GetWidth(); + mScreenViewport.height = framebuffer->GetHeight(); + // Letterboxed viewport for the main scene mOutputViewportLB.left = viewwindowx; mOutputViewportLB.top = trueheight - bars - (height + viewwindowy - ((height - vh) / 2)); @@ -242,12 +249,8 @@ void FGLRenderer::Begin2D() mBuffers->BindSceneFB(); else mBuffers->BindHudFB(); - glViewport(0, 0, mOutputViewport.width, mOutputViewport.height); - } - else - { - glViewport(mOutputViewport.left, mOutputViewport.top, mOutputViewport.width, mOutputViewport.height); } + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); gl_RenderState.EnableFog(false); gl_RenderState.Set2DMode(true); diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index ad2046cad..150d23f6a 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -106,6 +106,7 @@ public: FSkyVertexBuffer *mSkyVBO; FLightBuffer *mLights; + GL_IRECT mScreenViewport; GL_IRECT mOutputViewportLB; GL_IRECT mOutputViewport; bool mDrawingScene2D = false; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index b28e2c293..d0a9e23b9 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -157,10 +157,7 @@ void FGLRenderer::SetViewArea() void FGLRenderer::Reset3DViewport() { - if (FGLRenderBuffers::IsEnabled()) - glViewport(0, 0, mOutputViewport.width, mOutputViewport.height); - else - glViewport(mOutputViewport.left, mOutputViewport.top, mOutputViewport.width, mOutputViewport.height); + glViewport(mOutputViewport.left, mOutputViewport.top, mOutputViewport.width, mOutputViewport.height); } //----------------------------------------------------------------------------- @@ -171,20 +168,16 @@ void FGLRenderer::Reset3DViewport() void FGLRenderer::Set3DViewport(bool toscreen) { - const auto &bounds = mOutputViewportLB; if (toscreen && FGLRenderBuffers::IsEnabled()) { mBuffers->Setup(mOutputViewport.width, mOutputViewport.height); mBuffers->BindSceneFB(); - glViewport(0, 0, bounds.width, bounds.height); - glScissor(0, 0, bounds.width, bounds.height); - } - else - { - glViewport(bounds.left, bounds.top, bounds.width, bounds.height); - glScissor(bounds.left, bounds.top, bounds.width, bounds.height); } + const auto &bounds = mOutputViewportLB; + glViewport(bounds.left, bounds.top, bounds.width, bounds.height); + glScissor(bounds.left, bounds.top, bounds.width, bounds.height); + glEnable(GL_SCISSOR_TEST); #ifdef _DEBUG diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 4c6922e4f..781194ca4 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -233,7 +233,8 @@ bool OpenGLFrameBuffer::WipeDo(int ticks) if (FGLRenderBuffers::IsEnabled()) { GLRenderer->mBuffers->BindHudFB(); - glViewport(0, 0, GLRenderer->mOutputViewport.width, GLRenderer->mOutputViewport.height); + const auto &bounds = GLRenderer->mScreenViewport; + glViewport(bounds.left, bounds.top, bounds.width, bounds.height); } bool done = ScreenWipe->Run(ticks, this); From 7709db4bb08a68073939d21fb904d7e99ad1c398 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 31 Jul 2016 16:23:21 +0200 Subject: [PATCH 0749/1509] Fix broken viewport/backbuffer location for WriteSavePic --- src/gl/data/gl_vertexbuffer.h | 10 +++ src/gl/renderer/gl_postprocess.cpp | 122 +++++++++++--------------- src/gl/renderer/gl_renderbuffers.h | 3 + src/gl/renderer/gl_renderer.h | 5 +- src/gl/scene/gl_scene.cpp | 9 +- src/gl/shaders/gl_presentshader.cpp | 1 + wadsrc/static/shaders/glsl/present.vp | 3 +- 7 files changed, 74 insertions(+), 79 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index b88cc6ca1..eeb3ace48 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -105,6 +105,16 @@ public: if (pcount) *pcount = count; } + void RenderScreenQuad(float maxU = 1.0f, float maxV = 1.0f) + { + FFlatVertex *ptr = GetBuffer(); + ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; + ptr->Set(-1.0f, 1.0f, 0, 0.0f, maxV); ptr++; + ptr->Set(1.0f, -1.0f, 0, maxU, 0.0f); ptr++; + ptr->Set(1.0f, 1.0f, 0, maxU, maxV); ptr++; + RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } + #endif void Reset() { diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index e13acda4a..1f937be55 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -145,14 +145,7 @@ void FGLRenderer::BloomScene() mBloomExtractShader->Bind(); mBloomExtractShader->SceneTexture.Set(0); mBloomExtractShader->Exposure.Set(mCameraExposure); - { - FFlatVertex *ptr = mVBO->GetBuffer(); - ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; - ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; - ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; - ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; - mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } + mVBO->RenderScreenQuad(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -183,14 +176,7 @@ void FGLRenderer::BloomScene() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); mBloomCombineShader->Bind(); mBloomCombineShader->BloomTexture.Set(0); - { - FFlatVertex *ptr = mVBO->GetBuffer(); - ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; - ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; - ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; - ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; - mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } + mVBO->RenderScreenQuad(); } mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level0.VTexture, level0.HFramebuffer, level0.Width, level0.Height); @@ -208,14 +194,7 @@ void FGLRenderer::BloomScene() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); mBloomCombineShader->Bind(); mBloomCombineShader->BloomTexture.Set(0); - { - FFlatVertex *ptr = mVBO->GetBuffer(); - ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; - ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; - ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; - ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; - mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } + mVBO->RenderScreenQuad(); if (blendEnabled) glEnable(GL_BLEND); @@ -263,13 +242,7 @@ void FGLRenderer::TonemapScene() mTonemapShader->Bind(); mTonemapShader->SceneTexture.Set(0); mTonemapShader->Exposure.Set(mCameraExposure); - - FFlatVertex *ptr = mVBO->GetBuffer(); - ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; - ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; - ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; - ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; - mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + mVBO->RenderScreenQuad(); if (blendEnabled) glEnable(GL_BLEND); @@ -287,7 +260,7 @@ void FGLRenderer::TonemapScene() // //----------------------------------------------------------------------------- -void FGLRenderer::Flush() +void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds) { if (FGLRenderBuffers::IsEnabled()) { @@ -311,40 +284,51 @@ void FGLRenderer::Flush() mBuffers->BindOutputFB(); - // Calculate letterbox - int clientWidth = framebuffer->GetClientWidth(); - int clientHeight = framebuffer->GetClientHeight(); - float scaleX = clientWidth / (float)mOutputViewport.width; - float scaleY = clientHeight / (float)mOutputViewport.height; - float scale = MIN(scaleX, scaleY); - int width = (int)round(mOutputViewport.width * scale); - int height = (int)round(mOutputViewport.height * scale); - int x = (clientWidth - width) / 2; - int y = (clientHeight - height) / 2; + int x, y, width, height; + if (bounds) + { + x = bounds->left; + y = bounds->top; + width = bounds->width; + height = bounds->height; + } + else + { + // Calculate letterbox + int clientWidth = framebuffer->GetClientWidth(); + int clientHeight = framebuffer->GetClientHeight(); + float scaleX = clientWidth / (float)mScreenViewport.width; + float scaleY = clientHeight / (float)mScreenViewport.height; + float scale = MIN(scaleX, scaleY); + width = (int)round(mScreenViewport.width * scale); + height = (int)round(mScreenViewport.height * scale); + x = (clientWidth - width) / 2; + y = (clientHeight - height) / 2; - // Black bars around the box: - glViewport(0, 0, clientWidth, clientHeight); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glEnable(GL_SCISSOR_TEST); - if (y > 0) - { - glScissor(0, 0, clientWidth, y); - glClear(GL_COLOR_BUFFER_BIT); - } - if (clientHeight - y - height > 0) - { - glScissor(0, y + height, clientWidth, clientHeight - y - height); - glClear(GL_COLOR_BUFFER_BIT); - } - if (x > 0) - { - glScissor(0, y, x, height); - glClear(GL_COLOR_BUFFER_BIT); - } - if (clientWidth - x - width > 0) - { - glScissor(x + width, y, clientWidth - x - width, height); - glClear(GL_COLOR_BUFFER_BIT); + // Black bars around the box: + glViewport(0, 0, clientWidth, clientHeight); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glEnable(GL_SCISSOR_TEST); + if (y > 0) + { + glScissor(0, 0, clientWidth, y); + glClear(GL_COLOR_BUFFER_BIT); + } + if (clientHeight - y - height > 0) + { + glScissor(0, y + height, clientWidth, clientHeight - y - height); + glClear(GL_COLOR_BUFFER_BIT); + } + if (x > 0) + { + glScissor(0, y, x, height); + glClear(GL_COLOR_BUFFER_BIT); + } + if (clientWidth - x - width > 0) + { + glScissor(x + width, y, clientWidth - x - width, height); + glClear(GL_COLOR_BUFFER_BIT); + } } glDisable(GL_SCISSOR_TEST); @@ -367,13 +351,7 @@ void FGLRenderer::Flush() mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); } mBuffers->BindHudTexture(0); - - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; - ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; - ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; - ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + mVBO->RenderScreenQuad(width / (float)mBuffers->GetWidth(), height / (float)mBuffers->GetHeight()); if (blendEnabled) glEnable(GL_BLEND); diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index b4765b544..37bbdc2e5 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -34,6 +34,9 @@ public: static bool IsEnabled(); + int GetWidth() const { return mWidth; } + int GetHeight() const { return mHeight; } + private: void ClearScene(); void ClearHud(); diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 150d23f6a..3fd2afa86 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -118,7 +118,7 @@ public: angle_t FrustumAngle(); void SetViewArea(); void SetOutputViewport(GL_IRECT *bounds); - void Set3DViewport(bool toscreen); + void Set3DViewport(bool mainview); void Reset3DViewport(); sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen); void RenderView(player_t *player); @@ -160,7 +160,8 @@ public: void EndDrawScene(sector_t * viewsector); void BloomScene(); void TonemapScene(); - void Flush(); + void CopyToBackbuffer(const GL_IRECT *bounds); + void Flush() { CopyToBackbuffer(nullptr); } void SetProjection(float fov, float ratio, float fovratio); void SetProjection(VSMatrix matrix); // raw matrix input from stereo 3d modes diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index d0a9e23b9..734257c8c 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -166,9 +166,9 @@ void FGLRenderer::Reset3DViewport() // //----------------------------------------------------------------------------- -void FGLRenderer::Set3DViewport(bool toscreen) +void FGLRenderer::Set3DViewport(bool mainview) { - if (toscreen && FGLRenderBuffers::IsEnabled()) + if (mainview && FGLRenderBuffers::IsEnabled()) { mBuffers->Setup(mOutputViewport.width, mOutputViewport.height); mBuffers->BindSceneFB(); @@ -840,7 +840,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo eye->SetUp(); // TODO: stereo specific viewport - needed when implementing side-by-side modes etc. SetOutputViewport(bounds); - Set3DViewport(toscreen); + Set3DViewport(mainview); mDrawingScene2D = true; mCurrentFoV = fov; // Stereo mode specific perspective projection @@ -859,7 +859,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo ProcessScene(toscreen); if (mainview) EndDrawScene(retval); // do not call this for camera textures. - if (toscreen) + if (mainview) { if (FGLRenderBuffers::IsEnabled()) mBuffers->BlitSceneToTexture(); BloomScene(); @@ -976,6 +976,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei gl_RenderState.SetSoftLightLevel(-1); screen->Begin2D(false); DrawBlend(viewsector); + CopyToBackbuffer(&bounds); glFlush(); byte * scr = (byte *)M_Malloc(width * height * 3); diff --git a/src/gl/shaders/gl_presentshader.cpp b/src/gl/shaders/gl_presentshader.cpp index 0ebfc9945..2f9642458 100644 --- a/src/gl/shaders/gl_presentshader.cpp +++ b/src/gl/shaders/gl_presentshader.cpp @@ -58,6 +58,7 @@ void FPresentShader::Bind() mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/present"); mShader.SetAttribLocation(0, "PositionInProjection"); + mShader.SetAttribLocation(1, "UV"); InputTexture.Init(mShader, "InputTexture"); Gamma.Init(mShader, "Gamma"); Contrast.Init(mShader, "Contrast"); diff --git a/wadsrc/static/shaders/glsl/present.vp b/wadsrc/static/shaders/glsl/present.vp index 5990669a5..fea7e25ad 100644 --- a/wadsrc/static/shaders/glsl/present.vp +++ b/wadsrc/static/shaders/glsl/present.vp @@ -1,9 +1,10 @@ in vec4 PositionInProjection; +in vec2 UV; out vec2 TexCoord; void main() { gl_Position = PositionInProjection; - TexCoord = PositionInProjection.xy * 0.5 + 0.5; + TexCoord = UV; } From e8c98a5901a5d9d90bbf22cc1bdf59d436bb3a17 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 31 Jul 2016 16:56:41 +0200 Subject: [PATCH 0750/1509] No gamma and player sprites on screenshots --- src/gl/renderer/gl_postprocess.cpp | 4 ++-- src/gl/renderer/gl_renderer.h | 4 ++-- src/gl/scene/gl_scene.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 1f937be55..5ccacf305 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -260,7 +260,7 @@ void FGLRenderer::TonemapScene() // //----------------------------------------------------------------------------- -void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds) +void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) { if (FGLRenderBuffers::IsEnabled()) { @@ -338,7 +338,7 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds) mPresentShader->Bind(); mPresentShader->InputTexture.Set(0); - if (framebuffer->IsHWGammaActive()) + if (!applyGamma || framebuffer->IsHWGammaActive()) { mPresentShader->Gamma.Set(1.0f); mPresentShader->Contrast.Set(1.0f); diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 3fd2afa86..78eac4cbf 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -160,8 +160,8 @@ public: void EndDrawScene(sector_t * viewsector); void BloomScene(); void TonemapScene(); - void CopyToBackbuffer(const GL_IRECT *bounds); - void Flush() { CopyToBackbuffer(nullptr); } + void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma); + void Flush() { CopyToBackbuffer(nullptr, true); } void SetProjection(float fov, float ratio, float fovratio); void SetProjection(VSMatrix matrix); // raw matrix input from stereo 3d modes diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 734257c8c..87197d09d 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -858,7 +858,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo clipper.SafeAddClipRangeRealAngles(ViewAngle.BAMs() + a1, ViewAngle.BAMs() - a1); ProcessScene(toscreen); - if (mainview) EndDrawScene(retval); // do not call this for camera textures. + if (mainview && toscreen) EndDrawScene(retval); // do not call this for camera textures. if (mainview) { if (FGLRenderBuffers::IsEnabled()) mBuffers->BlitSceneToTexture(); @@ -976,7 +976,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei gl_RenderState.SetSoftLightLevel(-1); screen->Begin2D(false); DrawBlend(viewsector); - CopyToBackbuffer(&bounds); + CopyToBackbuffer(&bounds, false); glFlush(); byte * scr = (byte *)M_Malloc(width * height * 3); From 8aebfdb3abac02639ba6936e3a76912089ba24ad Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Aug 2016 11:29:28 +0200 Subject: [PATCH 0751/1509] - fixed: gl_bloom_amount may never be 0. --- src/gl/renderer/gl_postprocess.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 5ccacf305..d5b4005b6 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -76,7 +76,11 @@ // //========================================================================== CVAR(Bool, gl_bloom, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); -CVAR(Float, gl_bloom_amount, 1.4f, 0) +CUSTOM_CVAR(Float, gl_bloom_amount, 1.4f, 0) +{ + if (self < 0.1f) self = 0.1f; +} + CVAR(Float, gl_exposure, 0.0f, 0) CUSTOM_CVAR(Int, gl_tonemap, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) From f980a1f42ba9d7e8bea557e4a834dbe0944646c1 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 1 Aug 2016 15:12:13 +0200 Subject: [PATCH 0752/1509] Fix wrong UV calculations when resizing or maximizing window --- src/gl/renderer/gl_postprocess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index d5b4005b6..1e400f597 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -355,7 +355,7 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); } mBuffers->BindHudTexture(0); - mVBO->RenderScreenQuad(width / (float)mBuffers->GetWidth(), height / (float)mBuffers->GetHeight()); + mVBO->RenderScreenQuad(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight()); if (blendEnabled) glEnable(GL_BLEND); From 5a67ae6021f13f9d2e56ed32d326bd0f7909b26f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 2 Aug 2016 00:27:01 +0200 Subject: [PATCH 0753/1509] Fix missing VBO bind calls --- src/gl/renderer/gl_postprocess.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index d5b4005b6..f029d17c4 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -149,6 +149,7 @@ void FGLRenderer::BloomScene() mBloomExtractShader->Bind(); mBloomExtractShader->SceneTexture.Set(0); mBloomExtractShader->Exposure.Set(mCameraExposure); + mVBO->BindVBO(); mVBO->RenderScreenQuad(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -246,6 +247,7 @@ void FGLRenderer::TonemapScene() mTonemapShader->Bind(); mTonemapShader->SceneTexture.Set(0); mTonemapShader->Exposure.Set(mCameraExposure); + mVBO->BindVBO(); mVBO->RenderScreenQuad(); if (blendEnabled) @@ -355,6 +357,7 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); } mBuffers->BindHudTexture(0); + mVBO->BindVBO(); mVBO->RenderScreenQuad(width / (float)mBuffers->GetWidth(), height / (float)mBuffers->GetHeight()); if (blendEnabled) From 6b9529d70f52879ffb885fcad05789eb83cce162 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 2 Aug 2016 17:32:21 +0200 Subject: [PATCH 0754/1509] Added lens distortion shader --- src/CMakeLists.txt | 1 + src/gl/renderer/gl_postprocess.cpp | 73 ++++++++++++++++++++ src/gl/renderer/gl_renderbuffers.cpp | 4 +- src/gl/renderer/gl_renderer.cpp | 3 + src/gl/renderer/gl_renderer.h | 3 + src/gl/scene/gl_scene.cpp | 1 + src/gl/shaders/gl_lensshader.cpp | 66 ++++++++++++++++++ src/gl/shaders/gl_lensshader.h | 19 +++++ src/gl/system/gl_cvars.h | 4 ++ wadsrc/static/shaders/glsl/lensdistortion.fp | 55 +++++++++++++++ wadsrc/static/shaders/glsl/lensdistortion.vp | 9 +++ 11 files changed, 236 insertions(+), 2 deletions(-) create mode 100644 src/gl/shaders/gl_lensshader.cpp create mode 100644 src/gl/shaders/gl_lensshader.h create mode 100644 wadsrc/static/shaders/glsl/lensdistortion.fp create mode 100644 wadsrc/static/shaders/glsl/lensdistortion.vp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d3d339e0f..5317c277a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1110,6 +1110,7 @@ set( FASTMATH_SOURCES gl/shaders/gl_bloomshader.cpp gl/shaders/gl_blurshader.cpp gl/shaders/gl_tonemapshader.cpp + gl/shaders/gl_lensshader.cpp gl/system/gl_interface.cpp gl/system/gl_framebuffer.cpp gl/system/gl_menu.cpp diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index a8e5867c9..373f7c635 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -68,6 +68,7 @@ #include "gl/shaders/gl_bloomshader.h" #include "gl/shaders/gl_blurshader.h" #include "gl/shaders/gl_tonemapshader.h" +#include "gl/shaders/gl_lensshader.h" #include "gl/shaders/gl_presentshader.h" //========================================================================== @@ -95,6 +96,12 @@ CUSTOM_CVAR(Int, gl_bloom_kernel_size, 7, 0) self = 7; } +CVAR(Bool, gl_lens, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) + +CVAR(Float, gl_lens_k, -0.15f, 0) +CVAR(Float, gl_lens_kcube, 0.15f, 0) +CVAR(Float, gl_lens_chromatic, 1.2f, 0) + EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) @@ -260,6 +267,70 @@ void FGLRenderer::TonemapScene() glActiveTexture(activeTex); } +//----------------------------------------------------------------------------- +// +// Apply lens distortion and place the result in the HUD/2D texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::LensDistortScene() +{ + if (gl_lens == 0) + return; + + GLint activeTex, textureBinding, samplerBinding; + glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); + glActiveTexture(GL_TEXTURE0); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding); + glBindSampler(0, 0); + } + + GLboolean blendEnabled, scissorEnabled; + glGetBooleanv(GL_BLEND, &blendEnabled); + glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); + + glDisable(GL_BLEND); + glDisable(GL_SCISSOR_TEST); + + float k[4] = + { + gl_lens_k, + gl_lens_k * gl_lens_chromatic, + gl_lens_k * gl_lens_chromatic * gl_lens_chromatic, + 0.0f + }; + float kcube[4] = + { + gl_lens_kcube, + gl_lens_kcube * gl_lens_chromatic, + gl_lens_kcube * gl_lens_chromatic * gl_lens_chromatic, + 0.0f + }; + + mBuffers->BindHudFB(); + mBuffers->BindSceneTexture(0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mLensShader->Bind(); + mLensShader->InputTexture.Set(0); + mLensShader->LensDistortionCoefficient.Set(k); + mLensShader->CubicDistortionValue.Set(kcube); + mVBO->BindVBO(); + mVBO->RenderScreenQuad(); + + if (blendEnabled) + glEnable(GL_BLEND); + if (scissorEnabled) + glEnable(GL_SCISSOR_TEST); + glBindTexture(GL_TEXTURE_2D, textureBinding); + if (gl.flags & RFL_SAMPLER_OBJECTS) + glBindSampler(0, samplerBinding); + glActiveTexture(activeTex); +} + //----------------------------------------------------------------------------- // // Gamma correct while copying to frame buffer @@ -357,6 +428,8 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); } mBuffers->BindHudTexture(0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); mVBO->BindVBO(); mVBO->RenderScreenQuad(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight()); diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index a65626007..d9a8823cd 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -432,7 +432,7 @@ void FGLRenderBuffers::BindSceneTextureFB() void FGLRenderBuffers::BindHudFB() { - if (gl_tonemap != 0) + if (gl_tonemap != 0 || gl_lens) glBindFramebuffer(GL_FRAMEBUFFER, mHudFB); else glBindFramebuffer(GL_FRAMEBUFFER, mSceneTextureFB); @@ -470,7 +470,7 @@ void FGLRenderBuffers::BindSceneTexture(int index) void FGLRenderBuffers::BindHudTexture(int index) { glActiveTexture(GL_TEXTURE0 + index); - if (gl_tonemap != 0) + if (gl_tonemap != 0 || gl_lens) glBindTexture(GL_TEXTURE_2D, mHudTexture); else glBindTexture(GL_TEXTURE_2D, mSceneTexture); diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index d2a0cb959..5fa52ec6b 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -65,6 +65,7 @@ #include "gl/shaders/gl_bloomshader.h" #include "gl/shaders/gl_blurshader.h" #include "gl/shaders/gl_tonemapshader.h" +#include "gl/shaders/gl_lensshader.h" #include "gl/shaders/gl_presentshader.h" #include "gl/textures/gl_texture.h" #include "gl/textures/gl_translate.h" @@ -117,6 +118,7 @@ void FGLRenderer::Initialize() mBloomCombineShader = new FBloomCombineShader(); mBlurShader = new FBlurShader(); mTonemapShader = new FTonemapShader(); + mLensShader = new FLensShader(); mPresentShader = new FPresentShader(); // Only needed for the core profile, because someone decided it was a good idea to remove the default VAO. @@ -171,6 +173,7 @@ FGLRenderer::~FGLRenderer() if (mBloomCombineShader) delete mBloomCombineShader; if (mBlurShader) delete mBlurShader; if (mTonemapShader) delete mTonemapShader; + if (mLensShader) delete mLensShader; } //========================================================================== diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 78eac4cbf..9be66bbfb 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -23,6 +23,7 @@ class FBloomExtractShader; class FBloomCombineShader; class FBlurShader; class FTonemapShader; +class FLensShader; class FPresentShader; inline float DEG2RAD(float deg) @@ -90,6 +91,7 @@ public: FBloomCombineShader *mBloomCombineShader; FBlurShader *mBlurShader; FTonemapShader *mTonemapShader; + FLensShader *mLensShader; FPresentShader *mPresentShader; FTexture *gllight; @@ -160,6 +162,7 @@ public: void EndDrawScene(sector_t * viewsector); void BloomScene(); void TonemapScene(); + void LensDistortScene(); void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma); void Flush() { CopyToBackbuffer(nullptr, true); } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 87197d09d..16bb6cd34 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -864,6 +864,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo if (FGLRenderBuffers::IsEnabled()) mBuffers->BlitSceneToTexture(); BloomScene(); TonemapScene(); + LensDistortScene(); } mDrawingScene2D = false; eye->TearDown(); diff --git a/src/gl/shaders/gl_lensshader.cpp b/src/gl/shaders/gl_lensshader.cpp new file mode 100644 index 000000000..9181d260d --- /dev/null +++ b/src/gl/shaders/gl_lensshader.cpp @@ -0,0 +1,66 @@ +/* +** gl_lensshader.cpp +** Lens distortion with chromatic aberration shader +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "gl/gl_functions.h" +#include "vectors.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_lensshader.h" + +void FLensShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/lensdistortion.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/lensdistortion.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/lensdistortion"); + mShader.SetAttribLocation(0, "PositionInProjection"); + InputTexture.Init(mShader, "InputTexture"); + LensDistortionCoefficient.Init(mShader, "k"); + CubicDistortionValue.Init(mShader, "kcube"); + } + mShader.Bind(); +} diff --git a/src/gl/shaders/gl_lensshader.h b/src/gl/shaders/gl_lensshader.h new file mode 100644 index 000000000..a83532161 --- /dev/null +++ b/src/gl/shaders/gl_lensshader.h @@ -0,0 +1,19 @@ +#ifndef __GL_LENSSHADER_H +#define __GL_LENSSHADER_H + +#include "gl_shaderprogram.h" + +class FLensShader +{ +public: + void Bind(); + + FBufferedUniform1i InputTexture; + FBufferedUniform4f LensDistortionCoefficient; + FBufferedUniform4f CubicDistortionValue; + +private: + FShaderProgram mShader; +}; + +#endif \ No newline at end of file diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index 30f4cc4f3..4b28bb667 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -49,5 +49,9 @@ EXTERN_CVAR(Float, gl_bloom_amount) EXTERN_CVAR(Int, gl_bloom_kernel_size) EXTERN_CVAR(Int, gl_tonemap) EXTERN_CVAR(Float, gl_exposure) +EXTERN_CVAR(Bool, gl_lens) +EXTERN_CVAR(Float, gl_lens_k) +EXTERN_CVAR(Float, gl_lens_kcube) +EXTERN_CVAR(Float, gl_lens_chromatic) #endif // _GL_INTERN_H diff --git a/wadsrc/static/shaders/glsl/lensdistortion.fp b/wadsrc/static/shaders/glsl/lensdistortion.fp new file mode 100644 index 000000000..9d6fd1a26 --- /dev/null +++ b/wadsrc/static/shaders/glsl/lensdistortion.fp @@ -0,0 +1,55 @@ +/* + Original Lens Distortion Algorithm from SSontech + http://www.ssontech.com/content/lensalg.htm + + If (u,v) are the coordinates of a feature in the undistorted perfect + image plane, then (u', v') are the coordinates of the feature on the + distorted image plate, ie the scanned or captured image from the + camera. The distortion occurs radially away from the image center, + with correction for the image aspect ratio (image_aspect = physical + image width/height), as follows: + + r2 = image_aspect*image_aspect*u*u + v*v + f = 1 + r2*(k + kcube*sqrt(r2)) + u' = f*u + v' = f*v + + The constant k is the distortion coefficient that appears on the lens + panel and through Sizzle. It is generally a small positive or negative + number under 1%. The constant kcube is the cubic distortion value found + on the image preprocessor's lens panel: it can be used to undistort or + redistort images, but it does not affect or get computed by the solver. + When no cubic distortion is needed, neither is the square root, saving + time. + + Chromatic Aberration example, + using red distord channel with green and blue undistord channel: + + k = vec3(-0.15, 0.0, 0.0); + kcube = vec3(0.15, 0.0, 0.0); +*/ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D InputTexture; +uniform vec4 k; // lens distortion coefficient +uniform vec4 kcube; // cubic distortion value + +void main() +{ + vec2 position = TexCoord - vec2(0.5); + + float r2 = dot(position, position); + vec3 f = vec3(1.0) + r2 * (k.rgb + kcube.rgb * sqrt(r2)); + + vec3 x = f * position.x + 0.5; + vec3 y = f * position.y + 0.5; + + vec3 c; + c.r = texture(InputTexture, vec2(x.r, y.r)).r; + c.g = texture(InputTexture, vec2(x.g, y.g)).g; + c.b = texture(InputTexture, vec2(x.b, y.b)).b; + + FragColor = vec4(c, 1.0); +} diff --git a/wadsrc/static/shaders/glsl/lensdistortion.vp b/wadsrc/static/shaders/glsl/lensdistortion.vp new file mode 100644 index 000000000..5990669a5 --- /dev/null +++ b/wadsrc/static/shaders/glsl/lensdistortion.vp @@ -0,0 +1,9 @@ + +in vec4 PositionInProjection; +out vec2 TexCoord; + +void main() +{ + gl_Position = PositionInProjection; + TexCoord = PositionInProjection.xy * 0.5 + 0.5; +} From 7ba62694502124306c4d9a49b3a60f1de5cbb778 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 4 Aug 2016 12:16:53 +0200 Subject: [PATCH 0755/1509] - changed rendering of sky cubemaps to use precalculated vertex data from the SkyVertexBuffer. --- src/gl/data/gl_setup.cpp | 2 +- src/gl/data/gl_vertexbuffer.h | 9 ++ src/gl/scene/gl_skydome.cpp | 168 +++++++++++++++------------------- 3 files changed, 86 insertions(+), 93 deletions(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index 04ed4c427..f45995d90 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -322,7 +322,7 @@ static void PrepareTransparentDoors(sector_t * sector) sector_t * nextsec=NULL; #ifdef _DEBUG - if (sector-sectors==2) + if (sector-sectors==34) { int a = 0; } diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index eeb3ace48..f7a48a3e3 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -167,6 +167,10 @@ private: int mRows, mColumns; + // indices for sky cubemap faces + int mFaceStart[7]; + int mSideStart; + void SkyVertex(int r, int c, bool yflip); void CreateSkyHemisphere(int hemi); void CreateDome(); @@ -178,6 +182,11 @@ public: virtual ~FSkyVertexBuffer(); void RenderDome(FMaterial *tex, int mode); void BindVBO(); + int FaceStart(int i) + { + if (i >= 0 && i < 7) return mFaceStart[i]; + else return mSideStart; + } }; diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 33c73d82c..6e379117a 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -215,6 +215,72 @@ void FSkyVertexBuffer::CreateDome() CreateSkyHemisphere(SKYHEMI_UPPER); CreateSkyHemisphere(SKYHEMI_LOWER); mPrimStart.Push(mVertices.Size()); + + mSideStart = mVertices.Size(); + mFaceStart[0] = mSideStart + 10; + mFaceStart[1] = mFaceStart[0] + 4; + mFaceStart[2] = mFaceStart[1] + 4; + mFaceStart[3] = mFaceStart[2] + 4; + mFaceStart[4] = mFaceStart[3] + 4; + mFaceStart[5] = mFaceStart[4] + 4; + mFaceStart[6] = mFaceStart[5] + 4; + mVertices.Reserve(10 + 7*4); + FSkyVertex *ptr = &mVertices[mSideStart]; + + // all sides + ptr[0].Set(128.f, 128.f, -128.f, 0, 0); + ptr[1].Set(128.f, -128.f, -128.f, 0, 1); + ptr[2].Set(-128.f, 128.f, -128.f, 0.25f, 0); + ptr[3].Set(-128.f, -128.f, -128.f, 0.25f, 1); + ptr[4].Set(-128.f, 128.f, 128.f, 0.5f, 0); + ptr[5].Set(-128.f, -128.f, 128.f, 0.5f, 1); + ptr[6].Set(128.f, 128.f, 128.f, 0.75f, 0); + ptr[7].Set(128.f, -128.f, 128.f, 0.75f, 1); + ptr[8].Set(128.f, 128.f, -128.f, 1, 0); + ptr[9].Set(128.f, -128.f, -128.f, 1, 1); + + // north face + ptr[10].Set(128.f, 128.f, -128.f, 0, 0); + ptr[11].Set(-128.f, 128.f, -128.f, 1, 0); + ptr[12].Set(128.f, -128.f, -128.f, 0, 1); + ptr[13].Set(-128.f, -128.f, -128.f, 1, 1); + + // east face + ptr[14].Set(-128.f, 128.f, -128.f, 0, 0); + ptr[15].Set(-128.f, 128.f, 128.f, 1, 0); + ptr[16].Set(-128.f, -128.f, -128.f, 0, 1); + ptr[17].Set(-128.f, -128.f, 128.f, 1, 1); + + // south face + ptr[18].Set(-128.f, 128.f, 128.f, 0, 0); + ptr[19].Set(128.f, 128.f, 128.f, 1, 0); + ptr[20].Set(-128.f, -128.f, 128.f, 0, 1); + ptr[21].Set(128.f, -128.f, 128.f, 1, 1); + + // west face + ptr[22].Set(128.f, 128.f, 128.f, 0, 0); + ptr[23].Set(128.f, 128.f, -128.f, 1, 0); + ptr[24].Set(128.f, -128.f, 128.f, 0, 1); + ptr[25].Set(128.f, -128.f, -128.f, 1, 1); + + // bottom face + ptr[26].Set(128.f, -128.f, -128.f, 0, 0); + ptr[27].Set(-128.f, -128.f, -128.f, 1, 0); + ptr[28].Set(128.f, -128.f, 128.f, 0, 1); + ptr[29].Set(-128.f, -128.f, 128.f, 1, 1); + + // top face + ptr[30].Set(128.f, 128.f, -128.f, 0, 0); + ptr[31].Set(-128.f, 128.f, -128.f, 1, 0); + ptr[32].Set(128.f, 128.f, 128.f, 0, 1); + ptr[33].Set(-128.f, 128.f, 128.f, 1, 1); + + // top face flipped + ptr[34].Set(128.f, 128.f, -128.f, 0, 1); + ptr[35].Set(-128.f, 128.f, -128.f, 1, 1); + ptr[36].Set(128.f, 128.f, 128.f, 0, 0); + ptr[37].Set(-128.f, 128.f, 128.f, 1, 0); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glBufferData(GL_ARRAY_BUFFER, mVertices.Size() * sizeof(FSkyVertex), &mVertices[0], GL_STATIC_DRAW); } @@ -327,7 +393,6 @@ void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, in GLRenderer->mSkyVBO->RenderDome(tex, mode); gl_RenderState.EnableTextureMatrix(false); - gl_RenderState.EnableModelMatrix(false); } @@ -351,7 +416,6 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool else gl_RenderState.mModelMatrix.rotate(-180.0f+x_offset, glset.skyrotatevector2.X, glset.skyrotatevector2.Z, glset.skyrotatevector2.Y); - FFlatVertex *ptr; if (sb->faces[5]) { faces=4; @@ -360,65 +424,25 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool tex = FMaterial::ValidateTexture(sb->faces[0], false); gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); - - ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(128.f, 128.f, -128.f, 0, 0); - ptr++; - ptr->Set(-128.f, 128.f, -128.f, 1, 0); - ptr++; - ptr->Set(128.f, -128.f, -128.f, 0, 1); - ptr++; - ptr->Set(-128.f, -128.f, -128.f, 1, 1); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + glDrawArrays(GL_TRIANGLE_STRIP, GLRenderer->mSkyVBO->FaceStart(0), 4); // east tex = FMaterial::ValidateTexture(sb->faces[1], false); gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); - - ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(-128.f, 128.f, -128.f, 0, 0); - ptr++; - ptr->Set(-128.f, 128.f, 128.f, 1, 0); - ptr++; - ptr->Set(-128.f, -128.f, -128.f, 0, 1); - ptr++; - ptr->Set(-128.f, -128.f, 128.f, 1, 1); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + glDrawArrays(GL_TRIANGLE_STRIP, GLRenderer->mSkyVBO->FaceStart(1), 4); // south tex = FMaterial::ValidateTexture(sb->faces[2], false); gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); - - ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(-128.f, 128.f, 128.f, 0, 0); - ptr++; - ptr->Set(128.f, 128.f, 128.f, 1, 0); - ptr++; - ptr->Set(-128.f, -128.f, 128.f, 0, 1); - ptr++; - ptr->Set(128.f, -128.f, 128.f, 1, 1); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + glDrawArrays(GL_TRIANGLE_STRIP, GLRenderer->mSkyVBO->FaceStart(2), 4); // west tex = FMaterial::ValidateTexture(sb->faces[3], false); gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); - - ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(128.f, 128.f, 128.f, 0, 0); - ptr++; - ptr->Set(128.f, 128.f, -128.f, 1, 0); - ptr++; - ptr->Set(128.f, -128.f, 128.f, 0, 1); - ptr++; - ptr->Set(128.f, -128.f, -128.f, 1, 1); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + glDrawArrays(GL_TRIANGLE_STRIP, GLRenderer->mSkyVBO->FaceStart(3), 4); } else { @@ -426,62 +450,21 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool tex = FMaterial::ValidateTexture(sb->faces[0], false); gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); - - ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(128.f, 128.f, -128.f, 0, 0); - ptr++; - ptr->Set(128.f, -128.f, -128.f, 0, 1); - ptr++; - ptr->Set(-128.f, 128.f, -128.f, 0.25f, 0); - ptr++; - ptr->Set(-128.f, -128.f, -128.f, 0.25f, 1); - ptr++; - ptr->Set(-128.f, 128.f, 128.f, 0.5f, 0); - ptr++; - ptr->Set(-128.f, -128.f, 128.f, 0.5f, 1); - ptr++; - ptr->Set(128.f, 128.f, 128.f, 0.75f, 0); - ptr++; - ptr->Set(128.f, -128.f, 128.f, 0.75f, 1); - ptr++; - ptr->Set(128.f, 128.f, -128.f, 1, 0); - ptr++; - ptr->Set(128.f, -128.f, -128.f, 1, 1); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + glDrawArrays(GL_TRIANGLE_STRIP, GLRenderer->mSkyVBO->FaceStart(-1), 10); } // top tex = FMaterial::ValidateTexture(sb->faces[faces], false); gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); - - ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(128.f, 128.f, -128.f, 0, sb->fliptop); - ptr++; - ptr->Set(-128.f, 128.f, -128.f, 1, sb->fliptop); - ptr++; - ptr->Set(128.f, 128.f, 128.f, 0, !sb->fliptop); - ptr++; - ptr->Set(-128.f, 128.f, 128.f, 1, !sb->fliptop); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + glDrawArrays(GL_TRIANGLE_STRIP, GLRenderer->mSkyVBO->FaceStart(sb->fliptop? 6:5), 4); // bottom tex = FMaterial::ValidateTexture(sb->faces[faces+1], false); gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_STRIP, GLRenderer->mSkyVBO->FaceStart(4), 4); - ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(128.f, -128.f, -128.f, 0, 0); - ptr++; - ptr->Set(-128.f, -128.f, -128.f, 1, 0); - ptr++; - ptr->Set(128.f, -128.f, 128.f, 0, 1); - ptr++; - ptr->Set(-128.f, -128.f, 128.f, 1, 1); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); gl_RenderState.EnableModelMatrix(false); } @@ -512,13 +495,13 @@ void GLSkyPortal::DrawContents() gl_MatrixStack.Push(gl_RenderState.mViewMatrix); GLRenderer->SetupView(0, 0, 0, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO); if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox) { RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2); } else { - gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO); if (origin->texture[0]==origin->texture[1] && origin->doublesky) origin->doublesky=false; if (origin->texture[0]) @@ -547,11 +530,12 @@ void GLSkyPortal::DrawContents() gl_RenderState.EnableTexture(true); gl_RenderState.SetObjectColor(0xffffffff); } - gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); } + gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); gl_MatrixStack.Pop(gl_RenderState.mViewMatrix); gl_RenderState.ApplyMatrices(); glset.lightmode = oldlightmode; gl_RenderState.SetDepthClamp(oldClamp); + gl_RenderState.EnableModelMatrix(false); } From 63ad7d99d1d4ce7d0db48ed707e6542d50b0fcf6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 4 Aug 2016 12:55:21 +0200 Subject: [PATCH 0756/1509] - fixed: The dynamic light buffer's behavior needs to obey the gl.lightmethod variable, and not depend on presence of persistently mapped buffers. Since there is a command line switch to revert to the lower behavior it can well be that they do not match. --- src/gl/dynlights/gl_lightbuffer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index 4fd3b985a..604b6f9a2 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -71,7 +71,7 @@ FLightBuffer::FLightBuffer() glGenBuffers(1, &mBufferId); glBindBufferBase(mBufferType, LIGHTBUF_BINDINGPOINT, mBufferId); glBindBuffer(mBufferType, mBufferId); // Note: Some older AMD drivers don't do that in glBindBufferBase, as they should. - if (gl.flags & RFL_BUFFER_STORAGE) + if (gl.lightmethod == LM_DIRECT) { glBufferStorage(mBufferType, mByteSize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); @@ -151,7 +151,7 @@ int FLightBuffer::UploadLights(FDynLightData &data) // create the new buffer's storage (twice as large as the old one) mBufferSize *= 2; mByteSize *= 2; - if (gl.flags & RFL_BUFFER_STORAGE) + if (gl.lightmethod == LM_DIRECT) { glBufferStorage(mBufferType, mByteSize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); @@ -190,7 +190,7 @@ int FLightBuffer::UploadLights(FDynLightData &data) void FLightBuffer::Begin() { - if (!(gl.flags & RFL_BUFFER_STORAGE)) + if (gl.lightmethod == LM_DEFERRED) { glBindBuffer(mBufferType, mBufferId); mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT); @@ -199,7 +199,7 @@ void FLightBuffer::Begin() void FLightBuffer::Finish() { - if (!(gl.flags & RFL_BUFFER_STORAGE)) + if (gl.lightmethod == LM_DEFERRED) { glBindBuffer(mBufferType, mBufferId); glUnmapBuffer(mBufferType); From 21536781a93688b40556c5f3a29d70d8026fc843 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 4 Aug 2016 13:01:42 +0200 Subject: [PATCH 0757/1509] - forgot to save this. --- src/gl/scene/gl_walls_draw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 20d170977..67f40dd6d 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -387,7 +387,7 @@ void GLWall::RenderTranslucentWall() { if (gltexture) { - if (gl_fixedcolormap == CM_DEFAULT && gl_lights && (gl.flags & RFL_BUFFER_STORAGE)) + if (gl_fixedcolormap == CM_DEFAULT && gl_lights && gl.lightmethod == LM_DIRECT) { SetupLights(); } From 6fc7596d52710a0c92338806e2777cbd4e49f592 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 4 Aug 2016 15:47:15 +0200 Subject: [PATCH 0758/1509] Fix aspect ratio and texture clipping in lens shader --- src/gl/renderer/gl_postprocess.cpp | 18 +++++++++++++++--- src/gl/shaders/gl_lensshader.cpp | 2 ++ src/gl/shaders/gl_lensshader.h | 2 ++ wadsrc/static/shaders/glsl/lensdistortion.fp | 15 +++++++++------ 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 373f7c635..b934720b3 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -98,9 +98,9 @@ CUSTOM_CVAR(Int, gl_bloom_kernel_size, 7, 0) CVAR(Bool, gl_lens, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -CVAR(Float, gl_lens_k, -0.15f, 0) -CVAR(Float, gl_lens_kcube, 0.15f, 0) -CVAR(Float, gl_lens_chromatic, 1.2f, 0) +CVAR(Float, gl_lens_k, -0.12f, 0) +CVAR(Float, gl_lens_kcube, 0.1f, 0) +CVAR(Float, gl_lens_chromatic, 1.12f, 0) EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) @@ -310,12 +310,24 @@ void FGLRenderer::LensDistortScene() 0.0f }; + float aspect = mOutputViewport.width / mOutputViewport.height; + + // Scale factor to keep sampling within the input texture + float r2 = aspect * aspect * 0.25 + 0.25f; + float sqrt_r2 = sqrt(r2); + float f0 = 1.0f + MAX(r2 * (k[0] + kcube[0] * sqrt_r2), 0.0f); + float f2 = 1.0f + MAX(r2 * (k[2] + kcube[2] * sqrt_r2), 0.0f); + float f = MAX(f0, f2); + float scale = 1.0f / f; + mBuffers->BindHudFB(); mBuffers->BindSceneTexture(0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); mLensShader->Bind(); mLensShader->InputTexture.Set(0); + mLensShader->AspectRatio.Set(aspect); + mLensShader->Scale.Set(scale); mLensShader->LensDistortionCoefficient.Set(k); mLensShader->CubicDistortionValue.Set(kcube); mVBO->BindVBO(); diff --git a/src/gl/shaders/gl_lensshader.cpp b/src/gl/shaders/gl_lensshader.cpp index 9181d260d..39f5042e7 100644 --- a/src/gl/shaders/gl_lensshader.cpp +++ b/src/gl/shaders/gl_lensshader.cpp @@ -59,6 +59,8 @@ void FLensShader::Bind() mShader.Link("shaders/glsl/lensdistortion"); mShader.SetAttribLocation(0, "PositionInProjection"); InputTexture.Init(mShader, "InputTexture"); + AspectRatio.Init(mShader, "Aspect"); + Scale.Init(mShader, "Scale"); LensDistortionCoefficient.Init(mShader, "k"); CubicDistortionValue.Init(mShader, "kcube"); } diff --git a/src/gl/shaders/gl_lensshader.h b/src/gl/shaders/gl_lensshader.h index a83532161..ef0810e4e 100644 --- a/src/gl/shaders/gl_lensshader.h +++ b/src/gl/shaders/gl_lensshader.h @@ -9,6 +9,8 @@ public: void Bind(); FBufferedUniform1i InputTexture; + FBufferedUniform1f AspectRatio; + FBufferedUniform1f Scale; FBufferedUniform4f LensDistortionCoefficient; FBufferedUniform4f CubicDistortionValue; diff --git a/wadsrc/static/shaders/glsl/lensdistortion.fp b/wadsrc/static/shaders/glsl/lensdistortion.fp index 9d6fd1a26..7facf5a80 100644 --- a/wadsrc/static/shaders/glsl/lensdistortion.fp +++ b/wadsrc/static/shaders/glsl/lensdistortion.fp @@ -33,18 +33,21 @@ in vec2 TexCoord; out vec4 FragColor; uniform sampler2D InputTexture; -uniform vec4 k; // lens distortion coefficient -uniform vec4 kcube; // cubic distortion value +uniform float Aspect; // image width/height +uniform float Scale; // 1/max(f) +uniform vec4 k; // lens distortion coefficient +uniform vec4 kcube; // cubic distortion value void main() { - vec2 position = TexCoord - vec2(0.5); + vec2 position = (TexCoord - vec2(0.5)); - float r2 = dot(position, position); + vec2 p = vec2(position.x * Aspect, position.y); + float r2 = dot(p, p); vec3 f = vec3(1.0) + r2 * (k.rgb + kcube.rgb * sqrt(r2)); - vec3 x = f * position.x + 0.5; - vec3 y = f * position.y + 0.5; + vec3 x = f * position.x * Scale + 0.5; + vec3 y = f * position.y * Scale + 0.5; vec3 c; c.r = texture(InputTexture, vec2(x.r, y.r)).r; From 976a78429e174ebfbc218546763467b5a23d2fb2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 4 Aug 2016 17:16:49 +0200 Subject: [PATCH 0759/1509] Simplify post process buffer handling --- src/gl/renderer/gl_postprocess.cpp | 16 ++-- src/gl/renderer/gl_renderbuffers.cpp | 106 +++++++++++++-------------- src/gl/renderer/gl_renderbuffers.h | 31 +++++--- src/gl/renderer/gl_renderer.cpp | 2 +- src/gl/system/gl_wipe.cpp | 6 +- 5 files changed, 85 insertions(+), 76 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index b934720b3..155321de4 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -150,7 +150,7 @@ void FGLRenderer::BloomScene() // Extract blooming pixels from scene texture: glBindFramebuffer(GL_FRAMEBUFFER, level0.VFramebuffer); glViewport(0, 0, level0.Width, level0.Height); - mBuffers->BindSceneTexture(0); + mBuffers->BindCurrentTexture(0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); mBloomExtractShader->Bind(); @@ -195,7 +195,7 @@ void FGLRenderer::BloomScene() mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level0.HTexture, level0.VFramebuffer, level0.Width, level0.Height); // Add bloom back to scene texture: - mBuffers->BindSceneTextureFB(); + mBuffers->BindCurrentFB(); glViewport(mOutputViewport.left, mOutputViewport.top, mOutputViewport.width, mOutputViewport.height); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); @@ -249,13 +249,14 @@ void FGLRenderer::TonemapScene() glDisable(GL_BLEND); glDisable(GL_SCISSOR_TEST); - mBuffers->BindHudFB(); - mBuffers->BindSceneTexture(0); + mBuffers->BindNextFB(); + mBuffers->BindCurrentTexture(0); mTonemapShader->Bind(); mTonemapShader->SceneTexture.Set(0); mTonemapShader->Exposure.Set(mCameraExposure); mVBO->BindVBO(); mVBO->RenderScreenQuad(); + mBuffers->NextTexture(); if (blendEnabled) glEnable(GL_BLEND); @@ -320,8 +321,8 @@ void FGLRenderer::LensDistortScene() float f = MAX(f0, f2); float scale = 1.0f / f; - mBuffers->BindHudFB(); - mBuffers->BindSceneTexture(0); + mBuffers->BindNextFB(); + mBuffers->BindCurrentTexture(0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); mLensShader->Bind(); @@ -332,6 +333,7 @@ void FGLRenderer::LensDistortScene() mLensShader->CubicDistortionValue.Set(kcube); mVBO->BindVBO(); mVBO->RenderScreenQuad(); + mBuffers->NextTexture(); if (blendEnabled) glEnable(GL_BLEND); @@ -439,7 +441,7 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) mPresentShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); } - mBuffers->BindHudTexture(0); + mBuffers->BindCurrentTexture(0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); mVBO->BindVBO(); diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index d9a8823cd..490d73ed0 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -76,25 +76,26 @@ FGLRenderBuffers::FGLRenderBuffers() FGLRenderBuffers::~FGLRenderBuffers() { ClearScene(); - ClearHud(); + ClearPipeline(); ClearBloom(); } void FGLRenderBuffers::ClearScene() { DeleteFrameBuffer(mSceneFB); - DeleteFrameBuffer(mSceneTextureFB); DeleteRenderBuffer(mSceneMultisample); DeleteRenderBuffer(mSceneDepthStencil); DeleteRenderBuffer(mSceneDepth); DeleteRenderBuffer(mSceneStencil); - DeleteTexture(mSceneTexture); } -void FGLRenderBuffers::ClearHud() +void FGLRenderBuffers::ClearPipeline() { - DeleteFrameBuffer(mHudFB); - DeleteTexture(mHudTexture); + for (int i = 0; i < NumPipelineTextures; i++) + { + DeleteFrameBuffer(mPipelineFB[i]); + DeleteTexture(mPipelineTexture[i]); + } } void FGLRenderBuffers::ClearBloom() @@ -149,8 +150,8 @@ void FGLRenderBuffers::Setup(int width, int height) } else if (width > mWidth || height > mHeight) { + CreatePipeline(width, height); CreateScene(width, height, samples); - CreateHud(width, height); CreateBloom(width, height); mWidth = width; mHeight = height; @@ -173,9 +174,6 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples) { ClearScene(); - mSceneTexture = Create2DTexture(GetHdrFormat(), width, height); - mSceneTextureFB = CreateFrameBuffer(mSceneTexture); - if (samples > 1) mSceneMultisample = CreateRenderBuffer(GetHdrFormat(), samples, width, height); @@ -183,26 +181,30 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples) { mSceneDepth = CreateRenderBuffer(GL_DEPTH_COMPONENT24, samples, width, height); mSceneStencil = CreateRenderBuffer(GL_STENCIL_INDEX8, samples, width, height); - mSceneFB = CreateFrameBuffer(samples > 1 ? mSceneMultisample : mSceneTexture, mSceneDepth, mSceneStencil, samples > 1); + mSceneFB = CreateFrameBuffer(samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepth, mSceneStencil, samples > 1); } else { mSceneDepthStencil = CreateRenderBuffer(GL_DEPTH24_STENCIL8, samples, width, height); - mSceneFB = CreateFrameBuffer(samples > 1 ? mSceneMultisample : mSceneTexture, mSceneDepthStencil, samples > 1); + mSceneFB = CreateFrameBuffer(samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1); } } //========================================================================== // -// Creates the post-tonemapping-step buffers +// Creates the buffers needed for post processing steps // //========================================================================== -void FGLRenderBuffers::CreateHud(int width, int height) +void FGLRenderBuffers::CreatePipeline(int width, int height) { - ClearHud(); - mHudTexture = Create2DTexture(GetHdrFormat(), width, height); - mHudFB = CreateFrameBuffer(mHudTexture); + ClearPipeline(); + + for (int i = 0; i < NumPipelineTextures; i++) + { + mPipelineTexture[i] = Create2DTexture(GetHdrFormat(), width, height); + mPipelineFB[i] = CreateFrameBuffer(mPipelineTexture[i]); + } } //========================================================================== @@ -392,11 +394,13 @@ void FGLRenderBuffers::CheckFrameBufferCompleteness() void FGLRenderBuffers::BlitSceneToTexture() { + mCurrentPipelineTexture = 0; + if (mSamples <= 1) return; glBindFramebuffer(GL_READ_FRAMEBUFFER, mSceneFB); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mSceneTextureFB); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mPipelineFB[mCurrentPipelineTexture]); glBlitFramebuffer(0, 0, mWidth, mHeight, 0, 0, mWidth, mHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST); glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); @@ -415,27 +419,48 @@ void FGLRenderBuffers::BindSceneFB() //========================================================================== // -// Makes the scene texture frame buffer active (final 2D texture only) +// Binds the current scene/effect/hud texture to the specified texture unit // //========================================================================== -void FGLRenderBuffers::BindSceneTextureFB() +void FGLRenderBuffers::BindCurrentTexture(int index) { - glBindFramebuffer(GL_FRAMEBUFFER, mSceneTextureFB); + glActiveTexture(GL_TEXTURE0 + index); + glBindTexture(GL_TEXTURE_2D, mPipelineFB[mCurrentPipelineTexture]); } //========================================================================== // -// Makes the 2D/HUD frame buffer active +// Makes the frame buffer for the current texture active // //========================================================================== -void FGLRenderBuffers::BindHudFB() +void FGLRenderBuffers::BindCurrentFB() { - if (gl_tonemap != 0 || gl_lens) - glBindFramebuffer(GL_FRAMEBUFFER, mHudFB); - else - glBindFramebuffer(GL_FRAMEBUFFER, mSceneTextureFB); + glBindFramebuffer(GL_FRAMEBUFFER, mPipelineFB[mCurrentPipelineTexture]); +} + +//========================================================================== +// +// Makes the frame buffer for the next texture active +// +//========================================================================== + +void FGLRenderBuffers::BindNextFB() +{ + int out = (mCurrentPipelineTexture + 1) % NumPipelineTextures; + glBindFramebuffer(GL_FRAMEBUFFER, mPipelineFB[out]); +} + +//========================================================================== +// +// Next pipeline texture now contains the output +// +//========================================================================== + +void FGLRenderBuffers::NextTexture() +{ + mCurrentPipelineTexture = (mCurrentPipelineTexture + 1) % NumPipelineTextures; } //========================================================================== @@ -449,33 +474,6 @@ void FGLRenderBuffers::BindOutputFB() glBindFramebuffer(GL_FRAMEBUFFER, mOutputFB); } -//========================================================================== -// -// Binds the scene frame buffer texture to the specified texture unit -// -//========================================================================== - -void FGLRenderBuffers::BindSceneTexture(int index) -{ - glActiveTexture(GL_TEXTURE0 + index); - glBindTexture(GL_TEXTURE_2D, mSceneTexture); -} - -//========================================================================== -// -// Binds the 2D/HUD frame buffer texture to the specified texture unit -// -//========================================================================== - -void FGLRenderBuffers::BindHudTexture(int index) -{ - glActiveTexture(GL_TEXTURE0 + index); - if (gl_tonemap != 0 || gl_lens) - glBindTexture(GL_TEXTURE_2D, mHudTexture); - else - glBindTexture(GL_TEXTURE_2D, mSceneTexture); -} - //========================================================================== // // Returns true if render buffers are supported and should be used diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 37bbdc2e5..8b3001c96 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -21,13 +21,16 @@ public: ~FGLRenderBuffers(); void Setup(int width, int height); - void BlitSceneToTexture(); + void BindSceneFB(); - void BindSceneTextureFB(); - void BindHudFB(); + void BlitSceneToTexture(); + + void BindCurrentTexture(int index); + void BindCurrentFB(); + void BindNextFB(); + void NextTexture(); + void BindOutputFB(); - void BindSceneTexture(int index); - void BindHudTexture(int index); enum { NumBloomLevels = 4 }; FGLBloomTextureLevel BloomLevels[NumBloomLevels]; @@ -39,10 +42,10 @@ public: private: void ClearScene(); - void ClearHud(); + void ClearPipeline(); void ClearBloom(); void CreateScene(int width, int height, int samples); - void CreateHud(int width, int height); + void CreatePipeline(int width, int height); void CreateBloom(int width, int height); GLuint Create2DTexture(GLuint format, int width, int height); GLuint CreateRenderBuffer(GLuint format, int width, int height); @@ -62,15 +65,21 @@ private: int mHeight = 0; int mSamples = 0; - GLuint mSceneTexture = 0; + static const int NumPipelineTextures = 2; + int mCurrentPipelineTexture = 0; + + // Buffers for the scene GLuint mSceneMultisample = 0; GLuint mSceneDepthStencil = 0; GLuint mSceneDepth = 0; GLuint mSceneStencil = 0; GLuint mSceneFB = 0; - GLuint mSceneTextureFB = 0; - GLuint mHudTexture = 0; - GLuint mHudFB = 0; + + // Effect/HUD buffers + GLuint mPipelineTexture[NumPipelineTextures]; + GLuint mPipelineFB[NumPipelineTextures]; + + // Back buffer frame buffer GLuint mOutputFB = 0; }; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 5fa52ec6b..9105c08c7 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -251,7 +251,7 @@ void FGLRenderer::Begin2D() if (mDrawingScene2D) mBuffers->BindSceneFB(); else - mBuffers->BindHudFB(); + mBuffers->BindCurrentFB(); } glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 781194ca4..0d1973131 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -158,7 +158,7 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) if (FGLRenderBuffers::IsEnabled()) { - GLRenderer->mBuffers->BindHudFB(); + GLRenderer->mBuffers->BindCurrentFB(); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); } else @@ -193,7 +193,7 @@ void OpenGLFrameBuffer::WipeEndScreen() wipeendscreen->Bind(0, false, false); if (FGLRenderBuffers::IsEnabled()) - GLRenderer->mBuffers->BindHudFB(); + GLRenderer->mBuffers->BindCurrentFB(); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -232,7 +232,7 @@ bool OpenGLFrameBuffer::WipeDo(int ticks) if (FGLRenderBuffers::IsEnabled()) { - GLRenderer->mBuffers->BindHudFB(); + GLRenderer->mBuffers->BindCurrentFB(); const auto &bounds = GLRenderer->mScreenViewport; glViewport(bounds.left, bounds.top, bounds.width, bounds.height); } From 0457fee9c02a18093ba760b121cb81b3f7f5b2ba Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 4 Aug 2016 17:22:05 +0200 Subject: [PATCH 0760/1509] Added lens distortion effect to menus --- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.z | 1 + 2 files changed, 2 insertions(+) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 21aab53a6..8050079e8 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2621,6 +2621,7 @@ GLPREFMNU_VRQUADSTEREO = "Enable Quad Stereo"; GLPREFMNU_MULTISAMPLE = "Multisample"; GLPREFMNU_TONEMAP = "Tonemap Mode"; GLPREFMNU_BLOOM = "Bloom effect"; +GLPREFMNU_LENS = "Lens distortion effect"; // Option Values OPTVAL_SMART = "Smart"; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index bcee4ca01..bd458f376 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -220,4 +220,5 @@ OptionMenu "GLPrefOptions" Option "$GLPREFMNU_MULTISAMPLE", gl_multisample, "Multisample" Option "$GLPREFMNU_TONEMAP", gl_tonemap, "TonemapModes" Option "$GLPREFMNU_BLOOM", gl_bloom, "OnOff" + Option "$GLPREFMNU_LENS", gl_lens, "OnOff" } From 5b201287fa9b332dcc83ef6f4156a1bdb80cc0b4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 5 Aug 2016 15:27:35 +0200 Subject: [PATCH 0761/1509] - fixed bad #pragma pack combination in hqnx_asm_Image.h --- src/gl/hqnx_asm/hqnx_asm_Image.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/hqnx_asm/hqnx_asm_Image.h b/src/gl/hqnx_asm/hqnx_asm_Image.h index e4157a7b5..38f0f1d6a 100644 --- a/src/gl/hqnx_asm/hqnx_asm_Image.h +++ b/src/gl/hqnx_asm/hqnx_asm_Image.h @@ -147,6 +147,6 @@ class CImage char m_cBuf[32768]; }; -#pragma pack(8) +#pragma pack() } \ No newline at end of file From 13a2bf57e535ac4b051fc82d0cfe6218b448fe47 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 6 Aug 2016 11:47:03 +0200 Subject: [PATCH 0762/1509] - fixed vertex coordinate ordering for the sky cubemap. This was done differently for FFlatVertex and FSkyVertex which caused a switch of the y and z coordinates for the skybox image. --- src/gl/data/gl_vertexbuffer.h | 10 +++++ src/gl/scene/gl_skydome.cpp | 76 +++++++++++++++++------------------ 2 files changed, 48 insertions(+), 38 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index f7a48a3e3..6420e8fc8 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -146,6 +146,16 @@ struct FSkyVertex color = col; } + void SetXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0, PalEntry col = 0xffffffff) + { + x = xx; + y = yy; + z = zz; + u = uu; + v = vv; + color = col; + } + }; class FSkyVertexBuffer : public FVertexBuffer diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 6e379117a..52dfa064f 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -228,58 +228,58 @@ void FSkyVertexBuffer::CreateDome() FSkyVertex *ptr = &mVertices[mSideStart]; // all sides - ptr[0].Set(128.f, 128.f, -128.f, 0, 0); - ptr[1].Set(128.f, -128.f, -128.f, 0, 1); - ptr[2].Set(-128.f, 128.f, -128.f, 0.25f, 0); - ptr[3].Set(-128.f, -128.f, -128.f, 0.25f, 1); - ptr[4].Set(-128.f, 128.f, 128.f, 0.5f, 0); - ptr[5].Set(-128.f, -128.f, 128.f, 0.5f, 1); - ptr[6].Set(128.f, 128.f, 128.f, 0.75f, 0); - ptr[7].Set(128.f, -128.f, 128.f, 0.75f, 1); - ptr[8].Set(128.f, 128.f, -128.f, 1, 0); - ptr[9].Set(128.f, -128.f, -128.f, 1, 1); + ptr[0].SetXYZ(128.f, 128.f, -128.f, 0, 0); + ptr[1].SetXYZ(128.f, -128.f, -128.f, 0, 1); + ptr[2].SetXYZ(-128.f, 128.f, -128.f, 0.25f, 0); + ptr[3].SetXYZ(-128.f, -128.f, -128.f, 0.25f, 1); + ptr[4].SetXYZ(-128.f, 128.f, 128.f, 0.5f, 0); + ptr[5].SetXYZ(-128.f, -128.f, 128.f, 0.5f, 1); + ptr[6].SetXYZ(128.f, 128.f, 128.f, 0.75f, 0); + ptr[7].SetXYZ(128.f, -128.f, 128.f, 0.75f, 1); + ptr[8].SetXYZ(128.f, 128.f, -128.f, 1, 0); + ptr[9].SetXYZ(128.f, -128.f, -128.f, 1, 1); // north face - ptr[10].Set(128.f, 128.f, -128.f, 0, 0); - ptr[11].Set(-128.f, 128.f, -128.f, 1, 0); - ptr[12].Set(128.f, -128.f, -128.f, 0, 1); - ptr[13].Set(-128.f, -128.f, -128.f, 1, 1); + ptr[10].SetXYZ(128.f, 128.f, -128.f, 0, 0); + ptr[11].SetXYZ(-128.f, 128.f, -128.f, 1, 0); + ptr[12].SetXYZ(128.f, -128.f, -128.f, 0, 1); + ptr[13].SetXYZ(-128.f, -128.f, -128.f, 1, 1); // east face - ptr[14].Set(-128.f, 128.f, -128.f, 0, 0); - ptr[15].Set(-128.f, 128.f, 128.f, 1, 0); - ptr[16].Set(-128.f, -128.f, -128.f, 0, 1); - ptr[17].Set(-128.f, -128.f, 128.f, 1, 1); + ptr[14].SetXYZ(-128.f, 128.f, -128.f, 0, 0); + ptr[15].SetXYZ(-128.f, 128.f, 128.f, 1, 0); + ptr[16].SetXYZ(-128.f, -128.f, -128.f, 0, 1); + ptr[17].SetXYZ(-128.f, -128.f, 128.f, 1, 1); // south face - ptr[18].Set(-128.f, 128.f, 128.f, 0, 0); - ptr[19].Set(128.f, 128.f, 128.f, 1, 0); - ptr[20].Set(-128.f, -128.f, 128.f, 0, 1); - ptr[21].Set(128.f, -128.f, 128.f, 1, 1); + ptr[18].SetXYZ(-128.f, 128.f, 128.f, 0, 0); + ptr[19].SetXYZ(128.f, 128.f, 128.f, 1, 0); + ptr[20].SetXYZ(-128.f, -128.f, 128.f, 0, 1); + ptr[21].SetXYZ(128.f, -128.f, 128.f, 1, 1); // west face - ptr[22].Set(128.f, 128.f, 128.f, 0, 0); - ptr[23].Set(128.f, 128.f, -128.f, 1, 0); - ptr[24].Set(128.f, -128.f, 128.f, 0, 1); - ptr[25].Set(128.f, -128.f, -128.f, 1, 1); + ptr[22].SetXYZ(128.f, 128.f, 128.f, 0, 0); + ptr[23].SetXYZ(128.f, 128.f, -128.f, 1, 0); + ptr[24].SetXYZ(128.f, -128.f, 128.f, 0, 1); + ptr[25].SetXYZ(128.f, -128.f, -128.f, 1, 1); // bottom face - ptr[26].Set(128.f, -128.f, -128.f, 0, 0); - ptr[27].Set(-128.f, -128.f, -128.f, 1, 0); - ptr[28].Set(128.f, -128.f, 128.f, 0, 1); - ptr[29].Set(-128.f, -128.f, 128.f, 1, 1); + ptr[26].SetXYZ(128.f, -128.f, -128.f, 0, 0); + ptr[27].SetXYZ(-128.f, -128.f, -128.f, 1, 0); + ptr[28].SetXYZ(128.f, -128.f, 128.f, 0, 1); + ptr[29].SetXYZ(-128.f, -128.f, 128.f, 1, 1); // top face - ptr[30].Set(128.f, 128.f, -128.f, 0, 0); - ptr[31].Set(-128.f, 128.f, -128.f, 1, 0); - ptr[32].Set(128.f, 128.f, 128.f, 0, 1); - ptr[33].Set(-128.f, 128.f, 128.f, 1, 1); + ptr[30].SetXYZ(128.f, 128.f, -128.f, 0, 0); + ptr[31].SetXYZ(-128.f, 128.f, -128.f, 1, 0); + ptr[32].SetXYZ(128.f, 128.f, 128.f, 0, 1); + ptr[33].SetXYZ(-128.f, 128.f, 128.f, 1, 1); // top face flipped - ptr[34].Set(128.f, 128.f, -128.f, 0, 1); - ptr[35].Set(-128.f, 128.f, -128.f, 1, 1); - ptr[36].Set(128.f, 128.f, 128.f, 0, 0); - ptr[37].Set(-128.f, 128.f, 128.f, 1, 0); + ptr[34].SetXYZ(128.f, 128.f, -128.f, 0, 1); + ptr[35].SetXYZ(-128.f, 128.f, -128.f, 1, 1); + ptr[36].SetXYZ(128.f, 128.f, 128.f, 0, 0); + ptr[37].SetXYZ(-128.f, 128.f, 128.f, 1, 0); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glBufferData(GL_ARRAY_BUFFER, mVertices.Size() * sizeof(FSkyVertex), &mVertices[0], GL_STATIC_DRAW); From 346badf25f10c4597215f89187d665bebaec7300 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 5 Aug 2016 17:12:00 +0200 Subject: [PATCH 0763/1509] Moved state to FGLPostProcessState and merged vertex shaders --- src/CMakeLists.txt | 1 + src/gl/renderer/gl_postprocess.cpp | 122 ++--------------- src/gl/renderer/gl_postprocessstate.cpp | 124 ++++++++++++++++++ src/gl/renderer/gl_postprocessstate.h | 37 ++++++ src/gl/shaders/gl_bloomshader.cpp | 4 +- src/gl/shaders/gl_lensshader.cpp | 2 +- src/gl/shaders/gl_presentshader.cpp | 2 +- src/gl/shaders/gl_tonemapshader.cpp | 2 +- wadsrc/static/shaders/glsl/bloomcombine.vp | 9 -- wadsrc/static/shaders/glsl/bloomextract.vp | 9 -- wadsrc/static/shaders/glsl/lensdistortion.vp | 9 -- .../glsl/{present.vp => screenquad.vp} | 0 wadsrc/static/shaders/glsl/tonemap.vp | 9 -- 13 files changed, 176 insertions(+), 154 deletions(-) create mode 100644 src/gl/renderer/gl_postprocessstate.cpp create mode 100644 src/gl/renderer/gl_postprocessstate.h delete mode 100644 wadsrc/static/shaders/glsl/bloomcombine.vp delete mode 100644 wadsrc/static/shaders/glsl/bloomextract.vp delete mode 100644 wadsrc/static/shaders/glsl/lensdistortion.vp rename wadsrc/static/shaders/glsl/{present.vp => screenquad.vp} (100%) delete mode 100644 wadsrc/static/shaders/glsl/tonemap.vp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5317c277a..b5dd8739c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1063,6 +1063,7 @@ set( FASTMATH_SOURCES gl/renderer/gl_renderbuffers.cpp gl/renderer/gl_lightdata.cpp gl/renderer/gl_postprocess.cpp + gl/renderer/gl_postprocessstate.cpp gl/hqnx/init.cpp gl/hqnx/hq2x.cpp gl/hqnx/hq3x.cpp diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 155321de4..da7031afe 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -63,6 +63,7 @@ #include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderbuffers.h" #include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_postprocessstate.h" #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/shaders/gl_bloomshader.h" @@ -117,34 +118,11 @@ void FGLRenderer::BloomScene() if (!gl_bloom || !FGLRenderBuffers::IsEnabled() || gl_fixedcolormap != CM_DEFAULT) return; + FGLPostProcessState savedState; + const float blurAmount = gl_bloom_amount; int sampleCount = gl_bloom_kernel_size; - // TBD: Maybe need a better way to share state with other parts of the pipeline - GLint activeTex, textureBinding, samplerBinding; - glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); - glActiveTexture(GL_TEXTURE0); - glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); - if (gl.flags & RFL_SAMPLER_OBJECTS) - { - glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding); - glBindSampler(0, 0); - } - GLboolean blendEnabled, scissorEnabled; - GLint currentProgram, blendEquationRgb, blendEquationAlpha, blendSrcRgb, blendSrcAlpha, blendDestRgb, blendDestAlpha; - glGetBooleanv(GL_BLEND, &blendEnabled); - glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); - glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRgb); - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRgb); - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRgb); - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - - glDisable(GL_BLEND); - glDisable(GL_SCISSOR_TEST); - const auto &level0 = mBuffers->BloomLevels[0]; // Extract blooming pixels from scene texture: @@ -207,18 +185,6 @@ void FGLRenderer::BloomScene() mBloomCombineShader->Bind(); mBloomCombineShader->BloomTexture.Set(0); mVBO->RenderScreenQuad(); - - if (blendEnabled) - glEnable(GL_BLEND); - if (scissorEnabled) - glEnable(GL_SCISSOR_TEST); - glBlendEquationSeparate(blendEquationRgb, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRgb, blendDestRgb, blendSrcAlpha, blendDestAlpha); - glUseProgram(currentProgram); - glBindTexture(GL_TEXTURE_2D, textureBinding); - if (gl.flags & RFL_SAMPLER_OBJECTS) - glBindSampler(0, samplerBinding); - glActiveTexture(activeTex); } //----------------------------------------------------------------------------- @@ -232,22 +198,7 @@ void FGLRenderer::TonemapScene() if (gl_tonemap == 0) return; - GLint activeTex, textureBinding, samplerBinding; - glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); - glActiveTexture(GL_TEXTURE0); - glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); - if (gl.flags & RFL_SAMPLER_OBJECTS) - { - glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding); - glBindSampler(0, 0); - } - - GLboolean blendEnabled, scissorEnabled; - glGetBooleanv(GL_BLEND, &blendEnabled); - glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); - - glDisable(GL_BLEND); - glDisable(GL_SCISSOR_TEST); + FGLPostProcessState savedState; mBuffers->BindNextFB(); mBuffers->BindCurrentTexture(0); @@ -257,15 +208,6 @@ void FGLRenderer::TonemapScene() mVBO->BindVBO(); mVBO->RenderScreenQuad(); mBuffers->NextTexture(); - - if (blendEnabled) - glEnable(GL_BLEND); - if (scissorEnabled) - glEnable(GL_SCISSOR_TEST); - glBindTexture(GL_TEXTURE_2D, textureBinding); - if (gl.flags & RFL_SAMPLER_OBJECTS) - glBindSampler(0, samplerBinding); - glActiveTexture(activeTex); } //----------------------------------------------------------------------------- @@ -279,23 +221,6 @@ void FGLRenderer::LensDistortScene() if (gl_lens == 0) return; - GLint activeTex, textureBinding, samplerBinding; - glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); - glActiveTexture(GL_TEXTURE0); - glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); - if (gl.flags & RFL_SAMPLER_OBJECTS) - { - glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding); - glBindSampler(0, 0); - } - - GLboolean blendEnabled, scissorEnabled; - glGetBooleanv(GL_BLEND, &blendEnabled); - glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); - - glDisable(GL_BLEND); - glDisable(GL_SCISSOR_TEST); - float k[4] = { gl_lens_k, @@ -321,6 +246,8 @@ void FGLRenderer::LensDistortScene() float f = MAX(f0, f2); float scale = 1.0f / f; + FGLPostProcessState savedState; + mBuffers->BindNextFB(); mBuffers->BindCurrentTexture(0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -333,16 +260,9 @@ void FGLRenderer::LensDistortScene() mLensShader->CubicDistortionValue.Set(kcube); mVBO->BindVBO(); mVBO->RenderScreenQuad(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); mBuffers->NextTexture(); - - if (blendEnabled) - glEnable(GL_BLEND); - if (scissorEnabled) - glEnable(GL_SCISSOR_TEST); - glBindTexture(GL_TEXTURE_2D, textureBinding); - if (gl.flags & RFL_SAMPLER_OBJECTS) - glBindSampler(0, samplerBinding); - glActiveTexture(activeTex); } //----------------------------------------------------------------------------- @@ -355,23 +275,7 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) { if (FGLRenderBuffers::IsEnabled()) { - glDisable(GL_MULTISAMPLE); - glDisable(GL_DEPTH_TEST); - glDisable(GL_STENCIL_TEST); - - GLboolean blendEnabled; - GLint currentProgram; - GLint activeTex, textureBinding, samplerBinding; - glGetBooleanv(GL_BLEND, &blendEnabled); - glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); - glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); - glActiveTexture(GL_TEXTURE0); - glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); - if (gl.flags & RFL_SAMPLER_OBJECTS) - { - glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding); - glBindSampler(0, 0); - } + FGLPostProcessState savedState; mBuffers->BindOutputFB(); @@ -446,13 +350,5 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); mVBO->BindVBO(); mVBO->RenderScreenQuad(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight()); - - if (blendEnabled) - glEnable(GL_BLEND); - glUseProgram(currentProgram); - glBindTexture(GL_TEXTURE_2D, textureBinding); - if (gl.flags & RFL_SAMPLER_OBJECTS) - glBindSampler(0, samplerBinding); - glActiveTexture(activeTex); } } diff --git a/src/gl/renderer/gl_postprocessstate.cpp b/src/gl/renderer/gl_postprocessstate.cpp new file mode 100644 index 000000000..7e34a1149 --- /dev/null +++ b/src/gl/renderer/gl_postprocessstate.cpp @@ -0,0 +1,124 @@ +/* +** gl_postprocessstate.cpp +** Render state maintenance +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "templates.h" +#include "gl/system/gl_system.h" +#include "gl/system/gl_interface.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_shader.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_postprocessstate.h" + +//----------------------------------------------------------------------------- +// +// Saves state modified by post processing shaders +// +//----------------------------------------------------------------------------- + +FGLPostProcessState::FGLPostProcessState() +{ + glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); + glActiveTexture(GL_TEXTURE0); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding); + glBindSampler(0, 0); + } + + glGetBooleanv(GL_BLEND, &blendEnabled); + glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); + glGetBooleanv(GL_DEPTH_TEST, &depthEnabled); + glGetBooleanv(GL_MULTISAMPLE, &multisampleEnabled); + glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); + glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRgb); + glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); + glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRgb); + glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); + glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRgb); + glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); + + glDisable(GL_MULTISAMPLE); + glDisable(GL_DEPTH_TEST); + glDisable(GL_SCISSOR_TEST); + glDisable(GL_BLEND); +} + +//----------------------------------------------------------------------------- +// +// Restores state at the end of post processing +// +//----------------------------------------------------------------------------- + +FGLPostProcessState::~FGLPostProcessState() +{ + if (blendEnabled) + glEnable(GL_BLEND); + else + glDisable(GL_BLEND); + + if (scissorEnabled) + glEnable(GL_SCISSOR_TEST); + else + glDisable(GL_SCISSOR_TEST); + + if (depthEnabled) + glEnable(GL_DEPTH_TEST); + else + glDisable(GL_DEPTH_TEST); + + if (multisampleEnabled) + glEnable(GL_MULTISAMPLE); + else + glDisable(GL_MULTISAMPLE); + + glBlendEquationSeparate(blendEquationRgb, blendEquationAlpha); + glBlendFuncSeparate(blendSrcRgb, blendDestRgb, blendSrcAlpha, blendDestAlpha); + + glUseProgram(currentProgram); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, textureBinding); + if (gl.flags & RFL_SAMPLER_OBJECTS) + glBindSampler(0, samplerBinding); + glActiveTexture(activeTex); +} diff --git a/src/gl/renderer/gl_postprocessstate.h b/src/gl/renderer/gl_postprocessstate.h new file mode 100644 index 000000000..5cba73674 --- /dev/null +++ b/src/gl/renderer/gl_postprocessstate.h @@ -0,0 +1,37 @@ +#ifndef __GL_POSTPROCESSSTATE_H +#define __GL_POSTPROCESSSTATE_H + +#include +#include "gl/system/gl_interface.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_matrix.h" +#include "c_cvars.h" +#include "r_defs.h" + +class FGLPostProcessState +{ +public: + FGLPostProcessState(); + ~FGLPostProcessState(); + +private: + FGLPostProcessState(const FGLPostProcessState &) = delete; + FGLPostProcessState &operator=(const FGLPostProcessState &) = delete; + + GLint activeTex; + GLint textureBinding; + GLint samplerBinding; + GLboolean blendEnabled; + GLboolean scissorEnabled; + GLboolean depthEnabled; + GLboolean multisampleEnabled; + GLint currentProgram; + GLint blendEquationRgb; + GLint blendEquationAlpha; + GLint blendSrcRgb; + GLint blendSrcAlpha; + GLint blendDestRgb; + GLint blendDestAlpha; +}; + +#endif diff --git a/src/gl/shaders/gl_bloomshader.cpp b/src/gl/shaders/gl_bloomshader.cpp index c7191884f..f9e38e0c3 100644 --- a/src/gl/shaders/gl_bloomshader.cpp +++ b/src/gl/shaders/gl_bloomshader.cpp @@ -53,7 +53,7 @@ void FBloomExtractShader::Bind() { if (!mShader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/bloomextract.vp", "", 330); + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomextract.fp", "", 330); mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/bloomextract"); @@ -68,7 +68,7 @@ void FBloomCombineShader::Bind() { if (!mShader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/bloomcombine.vp", "", 330); + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomcombine.fp", "", 330); mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/bloomcombine"); diff --git a/src/gl/shaders/gl_lensshader.cpp b/src/gl/shaders/gl_lensshader.cpp index 39f5042e7..4dc23f14d 100644 --- a/src/gl/shaders/gl_lensshader.cpp +++ b/src/gl/shaders/gl_lensshader.cpp @@ -53,7 +53,7 @@ void FLensShader::Bind() { if (!mShader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/lensdistortion.vp", "", 330); + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/lensdistortion.fp", "", 330); mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/lensdistortion"); diff --git a/src/gl/shaders/gl_presentshader.cpp b/src/gl/shaders/gl_presentshader.cpp index 2f9642458..9998fda36 100644 --- a/src/gl/shaders/gl_presentshader.cpp +++ b/src/gl/shaders/gl_presentshader.cpp @@ -53,7 +53,7 @@ void FPresentShader::Bind() { if (!mShader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/present.vp", "", 330); + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/present.fp", "", 330); mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/present"); diff --git a/src/gl/shaders/gl_tonemapshader.cpp b/src/gl/shaders/gl_tonemapshader.cpp index c26e8d1af..8e1f3a844 100644 --- a/src/gl/shaders/gl_tonemapshader.cpp +++ b/src/gl/shaders/gl_tonemapshader.cpp @@ -54,7 +54,7 @@ void FTonemapShader::Bind() auto &shader = mShader[gl_tonemap]; if (!shader) { - shader.Compile(FShaderProgram::Vertex, "shaders/glsl/tonemap.vp", "", 330); + shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); shader.Compile(FShaderProgram::Fragment, "shaders/glsl/tonemap.fp", GetDefines(gl_tonemap), 330); shader.SetFragDataLocation(0, "FragColor"); shader.Link("shaders/glsl/tonemap"); diff --git a/wadsrc/static/shaders/glsl/bloomcombine.vp b/wadsrc/static/shaders/glsl/bloomcombine.vp deleted file mode 100644 index 5990669a5..000000000 --- a/wadsrc/static/shaders/glsl/bloomcombine.vp +++ /dev/null @@ -1,9 +0,0 @@ - -in vec4 PositionInProjection; -out vec2 TexCoord; - -void main() -{ - gl_Position = PositionInProjection; - TexCoord = PositionInProjection.xy * 0.5 + 0.5; -} diff --git a/wadsrc/static/shaders/glsl/bloomextract.vp b/wadsrc/static/shaders/glsl/bloomextract.vp deleted file mode 100644 index 5990669a5..000000000 --- a/wadsrc/static/shaders/glsl/bloomextract.vp +++ /dev/null @@ -1,9 +0,0 @@ - -in vec4 PositionInProjection; -out vec2 TexCoord; - -void main() -{ - gl_Position = PositionInProjection; - TexCoord = PositionInProjection.xy * 0.5 + 0.5; -} diff --git a/wadsrc/static/shaders/glsl/lensdistortion.vp b/wadsrc/static/shaders/glsl/lensdistortion.vp deleted file mode 100644 index 5990669a5..000000000 --- a/wadsrc/static/shaders/glsl/lensdistortion.vp +++ /dev/null @@ -1,9 +0,0 @@ - -in vec4 PositionInProjection; -out vec2 TexCoord; - -void main() -{ - gl_Position = PositionInProjection; - TexCoord = PositionInProjection.xy * 0.5 + 0.5; -} diff --git a/wadsrc/static/shaders/glsl/present.vp b/wadsrc/static/shaders/glsl/screenquad.vp similarity index 100% rename from wadsrc/static/shaders/glsl/present.vp rename to wadsrc/static/shaders/glsl/screenquad.vp diff --git a/wadsrc/static/shaders/glsl/tonemap.vp b/wadsrc/static/shaders/glsl/tonemap.vp deleted file mode 100644 index 5990669a5..000000000 --- a/wadsrc/static/shaders/glsl/tonemap.vp +++ /dev/null @@ -1,9 +0,0 @@ - -in vec4 PositionInProjection; -out vec2 TexCoord; - -void main() -{ - gl_Position = PositionInProjection; - TexCoord = PositionInProjection.xy * 0.5 + 0.5; -} From 2e555e6dabf18891ca82deef827fbfd427ad4373 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 6 Aug 2016 12:03:16 +0200 Subject: [PATCH 0764/1509] - use client arrays on compatibility profiles instead of calling glBegin/glEnd. This eliminates most behavioral differences for FFlatVertexBuffer between both operating modes, now the only difference is where the buffer is located. --- src/gl/data/gl_vertexbuffer.cpp | 57 +++++++++++++-------------------- src/gl/data/gl_vertexbuffer.h | 9 +----- src/gl/system/gl_interface.cpp | 13 ++++++++ src/gl/system/gl_interface.h | 9 ++++++ 4 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 96343b284..dd3854596 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -78,9 +78,9 @@ FVertexBuffer::~FVertexBuffer() //========================================================================== FFlatVertexBuffer::FFlatVertexBuffer() -: FVertexBuffer(!!(gl.flags & RFL_BUFFER_STORAGE)) +: FVertexBuffer(gl.buffermethod == BM_PERSISTENT) { - if (gl.flags & RFL_BUFFER_STORAGE) + if (gl.buffermethod == BM_PERSISTENT) { unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); @@ -91,19 +91,24 @@ FFlatVertexBuffer::FFlatVertexBuffer() { // The fallback path uses immediate mode rendering and does not set up an actual vertex buffer vbo_shadowdata.Reserve(BUFFER_SIZE); - map = &vbo_shadowdata[0]; + map = new FFlatVertex[BUFFER_SIZE]; } mNumReserved = mIndex = mCurIndex = 0; } FFlatVertexBuffer::~FFlatVertexBuffer() { - if (gl.flags & RFL_BUFFER_STORAGE) + if (vbo_id != 0) { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glUnmapBuffer(GL_ARRAY_BUFFER); glBindBuffer(GL_ARRAY_BUFFER, 0); } + else + { + delete[] map; + } + map = nullptr; } @@ -116,14 +121,15 @@ void FFlatVertexBuffer::BindVBO() { glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); - glEnableVertexAttribArray(VATTR_VERTEX); - glEnableVertexAttribArray(VATTR_TEXCOORD); } else { - glDisableVertexAttribArray(VATTR_VERTEX); - glDisableVertexAttribArray(VATTR_TEXCOORD); + // If we cannot use a hardware buffer, use an old-style client array. + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &map->x); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &map->u); } + glEnableVertexAttribArray(VATTR_VERTEX); + glEnableVertexAttribArray(VATTR_TEXCOORD); glDisableVertexAttribArray(VATTR_COLOR); glDisableVertexAttribArray(VATTR_VERTEX2); } @@ -346,24 +352,10 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) void FFlatVertexBuffer::CreateVBO() { - if (gl.flags & RFL_BUFFER_STORAGE) - { - vbo_shadowdata.Resize(mNumReserved); - CreateFlatVBO(); - mCurIndex = mIndex = vbo_shadowdata.Size(); - memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); - } - else if (sectors) - { - // set all VBO info to invalid values so that we can save some checks in the rendering code - for(int i=0;iGetHeightSec(); - if (hs != NULL) CheckPlanes(hs); - for (unsigned i = 0; i < sector->e->XFloor.ffloors.Size(); i++) - CheckPlanes(sector->e->XFloor.ffloors[i]->model); - } + CheckPlanes(sector); + sector_t *hs = sector->GetHeightSec(); + if (hs != NULL) CheckPlanes(hs); + for (unsigned i = 0; i < sector->e->XFloor.ffloors.Size(); i++) + CheckPlanes(sector->e->XFloor.ffloors[i]->model); } \ No newline at end of file diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 6420e8fc8..c82ea707b 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -85,14 +85,7 @@ public: void RenderArray(unsigned int primtype, unsigned int offset, unsigned int count) { drawcalls.Clock(); - if (gl.flags & RFL_BUFFER_STORAGE) - { - glDrawArrays(primtype, offset, count); - } - else - { - ImmRenderBuffer(primtype, offset, count); - } + glDrawArrays(primtype, offset, count); drawcalls.Unclock(); } diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index ced1b8b4a..beb636d9c 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -167,6 +167,7 @@ void gl_LoadExtensions() gl.vendorstring = (char*)glGetString(GL_VENDOR); gl.lightmethod = LM_SOFTWARE; + gl.buffermethod = BM_CLIENTARRAY; if ((gl.version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) && !Args->CheckParm("-nosampler")) { @@ -177,6 +178,10 @@ void gl_LoadExtensions() if (gl.version > 3.0f && (gl.version >= 3.3f || CheckExtension("GL_ARB_uniform_buffer_object"))) { gl.lightmethod = LM_DEFERRED; + // Only Apple requires the core profile for GL 3.x+. + // #ifdef __APPLE__ + // gl.buffermethod = BM_DEFERRED; + // #endif } if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION; @@ -222,6 +227,7 @@ void gl_LoadExtensions() } gl.flags |= RFL_BUFFER_STORAGE; gl.lightmethod = LM_DIRECT; + gl.buffermethod = BM_PERSISTENT; } else { @@ -236,6 +242,13 @@ void gl_LoadExtensions() if (!stricmp(lm, "textured")) gl.lightmethod = LM_SOFTWARE; } + lm = Args->CheckValue("-buffermethod"); + if (lm != NULL) + { + //if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED; + if (!stricmp(lm, "clientarray")) gl.buffermethod = BM_CLIENTARRAY; + } + int v; if (gl.lightmethod != LM_SOFTWARE && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 1813e2c7f..d43252ebc 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -44,6 +44,14 @@ enum ELightMethod LM_DIRECT = 2, // calculate lights on the fly along with the render data }; +enum EBufferMethod +{ + BM_CLIENTARRAY = 0, // use a client array instead of a hardware buffer + BM_DEFERRED = 1, // use a temporarily mapped buffer (only necessary on GL 3.x core profile, i.e. Apple) + BM_PERSISTENT = 2 // use a persistently mapped buffer +}; + + struct RenderContext { unsigned int flags; @@ -51,6 +59,7 @@ struct RenderContext unsigned int maxuniformblock; unsigned int uniformblockalignment; int lightmethod; + int buffermethod; float version; float glslversion; int max_texturesize; From 7576e85cef145ca38607d560841d01a72f6d771f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 6 Aug 2016 13:06:55 +0200 Subject: [PATCH 0765/1509] - force use of shaders on all hardware, unless -noshader is specified. Right it's only for easy testing, so only the code that does the feature checking has been disabled. --- src/gl/system/gl_interface.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index beb636d9c..bf926cd93 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -187,7 +187,7 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags |= RFL_TEXTURE_COMPRESSION_S3TC; - if (Args->CheckParm("-noshader") || gl.glslversion < 1.2f) + if (Args->CheckParm("-noshader")/* || gl.glslversion < 1.2f*/) { gl.version = 2.11f; gl.glslversion = 0; @@ -195,8 +195,9 @@ void gl_LoadExtensions() } else if (gl.version < 3.0f) { - if (CheckExtension("GL_NV_GPU_shader4") || CheckExtension("GL_EXT_GPU_shader4")) gl.glslversion = 1.21f; // for pre-3.0 drivers that support capable hardware. Needed for Apple. - else gl.glslversion = 0; + //if (CheckExtension("GL_NV_GPU_shader4") || CheckExtension("GL_EXT_GPU_shader4")) gl.glslversion = 1.21f; // for pre-3.0 drivers that support capable hardware. Needed for Apple. + //else gl.glslversion = 0; + gl.glslversion = 1.21f; if (!CheckExtension("GL_EXT_packed_float")) gl.flags |= RFL_NO_RGBA16F; if (!CheckExtension("GL_EXT_packed_depth_stencil")) gl.flags |= RFL_NO_DEPTHSTENCIL; From 6a66d0255db59e0b72dfb95d05b8640c4e57858d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 6 Aug 2016 14:12:40 +0200 Subject: [PATCH 0766/1509] - use a dedicated vertex buffer for rendering the wipes. - fixed: The postprocessing shaders clobbered the render state's vertex buffer info by bypassing and not notifying it of the change. --- src/gl/data/gl_vertexbuffer.h | 10 -- src/gl/renderer/gl_postprocess.cpp | 29 +++-- src/gl/renderer/gl_renderer.h | 1 + src/gl/system/gl_framebuffer.h | 8 ++ src/gl/system/gl_interface.cpp | 1 - src/gl/system/gl_wipe.cpp | 203 +++++++++++++++++++---------- 6 files changed, 160 insertions(+), 92 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index c82ea707b..edb38733a 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -98,16 +98,6 @@ public: if (pcount) *pcount = count; } - void RenderScreenQuad(float maxU = 1.0f, float maxV = 1.0f) - { - FFlatVertex *ptr = GetBuffer(); - ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; - ptr->Set(-1.0f, 1.0f, 0, 0.0f, maxV); ptr++; - ptr->Set(1.0f, -1.0f, 0, maxU, 0.0f); ptr++; - ptr->Set(1.0f, 1.0f, 0, maxU, maxV); ptr++; - RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } - #endif void Reset() { diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index da7031afe..a997f5b47 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -106,6 +106,19 @@ CVAR(Float, gl_lens_chromatic, 1.12f, 0) EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) + +void FGLRenderer::RenderScreenQuad(float maxU, float maxV) +{ + FFlatVertex *ptr = mVBO->GetBuffer(); + mVBO->BindVBO(); + gl_RenderState.ResetVertexBuffer(); + ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; + ptr->Set(-1.0f, 1.0f, 0, 0.0f, maxV); ptr++; + ptr->Set(1.0f, -1.0f, 0, maxU, 0.0f); ptr++; + ptr->Set(1.0f, 1.0f, 0, maxU, maxV); ptr++; + mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); +} + //----------------------------------------------------------------------------- // // Adds bloom contribution to scene texture @@ -134,8 +147,7 @@ void FGLRenderer::BloomScene() mBloomExtractShader->Bind(); mBloomExtractShader->SceneTexture.Set(0); mBloomExtractShader->Exposure.Set(mCameraExposure); - mVBO->BindVBO(); - mVBO->RenderScreenQuad(); + RenderScreenQuad(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -166,7 +178,7 @@ void FGLRenderer::BloomScene() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); mBloomCombineShader->Bind(); mBloomCombineShader->BloomTexture.Set(0); - mVBO->RenderScreenQuad(); + RenderScreenQuad(); } mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level0.VTexture, level0.HFramebuffer, level0.Width, level0.Height); @@ -184,7 +196,7 @@ void FGLRenderer::BloomScene() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); mBloomCombineShader->Bind(); mBloomCombineShader->BloomTexture.Set(0); - mVBO->RenderScreenQuad(); + RenderScreenQuad(); } //----------------------------------------------------------------------------- @@ -205,8 +217,7 @@ void FGLRenderer::TonemapScene() mTonemapShader->Bind(); mTonemapShader->SceneTexture.Set(0); mTonemapShader->Exposure.Set(mCameraExposure); - mVBO->BindVBO(); - mVBO->RenderScreenQuad(); + RenderScreenQuad(); mBuffers->NextTexture(); } @@ -258,8 +269,7 @@ void FGLRenderer::LensDistortScene() mLensShader->Scale.Set(scale); mLensShader->LensDistortionCoefficient.Set(k); mLensShader->CubicDistortionValue.Set(kcube); - mVBO->BindVBO(); - mVBO->RenderScreenQuad(); + RenderScreenQuad(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); mBuffers->NextTexture(); @@ -348,7 +358,6 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) mBuffers->BindCurrentTexture(0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - mVBO->BindVBO(); - mVBO->RenderScreenQuad(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight()); + RenderScreenQuad(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight()); } } diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 9be66bbfb..9caace177 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -157,6 +157,7 @@ public: unsigned char *GetTextureBuffer(FTexture *tex, int &w, int &h); void SetupLevel(); + void RenderScreenQuad(float maxU = 1.0f, float maxV = 1.0f); void SetFixedColormap (player_t *player); void WriteSavePic (player_t *player, FILE *file, int width, int height); void EndDrawScene(sector_t * viewsector); diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index 3da60fac4..2ba90ff5b 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -94,7 +94,15 @@ private: class Wiper { + class WipeVertexBuffer; + + protected: + WipeVertexBuffer *mVertexBuf; + + void MakeVBO(OpenGLFrameBuffer *fb); + public: + Wiper(); virtual ~Wiper(); virtual bool Run(int ticks, OpenGLFrameBuffer *fb) = 0; }; diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index bf926cd93..6b1105ee4 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -197,7 +197,6 @@ void gl_LoadExtensions() { //if (CheckExtension("GL_NV_GPU_shader4") || CheckExtension("GL_EXT_GPU_shader4")) gl.glslversion = 1.21f; // for pre-3.0 drivers that support capable hardware. Needed for Apple. //else gl.glslversion = 0; - gl.glslversion = 1.21f; if (!CheckExtension("GL_EXT_packed_float")) gl.flags |= RFL_NO_RGBA16F; if (!CheckExtension("GL_EXT_packed_depth_stencil")) gl.flags |= RFL_NO_DEPTHSTENCIL; diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 0d1973131..bc1708061 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -97,6 +97,7 @@ class OpenGLFrameBuffer::Wiper_Melt : public OpenGLFrameBuffer::Wiper { public: Wiper_Melt(); + int MakeVBO(int ticks, OpenGLFrameBuffer *fb, bool &done); bool Run(int ticks, OpenGLFrameBuffer *fb); private: @@ -217,29 +218,28 @@ void OpenGLFrameBuffer::WipeEndScreen() bool OpenGLFrameBuffer::WipeDo(int ticks) { + bool done = true; // Sanity checks. - if (wipestartscreen == NULL || wipeendscreen == NULL) + if (wipestartscreen != nullptr && wipeendscreen != nullptr) { - return true; + Lock(true); + + gl_RenderState.EnableTexture(true); + gl_RenderState.EnableFog(false); + glDisable(GL_DEPTH_TEST); + glDepthMask(false); + + if (FGLRenderBuffers::IsEnabled()) + { + GLRenderer->mBuffers->BindCurrentFB(); + const auto &bounds = GLRenderer->mScreenViewport; + glViewport(bounds.left, bounds.top, bounds.width, bounds.height); + } + + done = ScreenWipe->Run(ticks, this); + glDepthMask(true); } - - Lock(true); - - gl_RenderState.EnableTexture(true); - gl_RenderState.EnableFog(false); - glDisable(GL_DEPTH_TEST); - glDepthMask(false); - - if (FGLRenderBuffers::IsEnabled()) - { - GLRenderer->mBuffers->BindCurrentFB(); - const auto &bounds = GLRenderer->mScreenViewport; - glViewport(bounds.left, bounds.top, bounds.width, bounds.height); - } - - bool done = ScreenWipe->Run(ticks, this); - glDepthMask(true); - //DrawLetterbox(); + gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); return done; } @@ -273,12 +273,80 @@ void OpenGLFrameBuffer::WipeCleanup() //========================================================================== // -// OpenGLFrameBuffer :: Wiper Constructor +// The wiper vertex buffer +// +// Note that this will recreate the buffer each frame, although +// only for melt its contents will change. +// +// But since this is no time critical code, ease of implementation +// was chosen over maximum efficiency. // //========================================================================== +class OpenGLFrameBuffer::Wiper::WipeVertexBuffer : public FVertexBuffer +{ +public: + WipeVertexBuffer() + { + } + void BindVBO() + { + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + if (gl.glslversion > 0) + { + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); + glDisableVertexAttribArray(VATTR_COLOR); + glDisableVertexAttribArray(VATTR_VERTEX2); + } + else + { + glVertexPointer(3, GL_FLOAT, sizeof(FFlatVertex), &VTO->x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FFlatVertex), &VTO->u); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + } + } + void set(FFlatVertex *verts, int count) + { + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + gl_RenderState.SetVertexBuffer(this); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(*verts), verts, GL_STREAM_DRAW); + } +}; + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper Constructor +// +//========================================================================== +OpenGLFrameBuffer::Wiper::Wiper() +{ + mVertexBuf = new WipeVertexBuffer; +} + OpenGLFrameBuffer::Wiper::~Wiper() { + delete mVertexBuf; +} + +void OpenGLFrameBuffer::Wiper::MakeVBO(OpenGLFrameBuffer *fb) +{ + FFlatVertex make[4]; + FFlatVertex *ptr = make; + + float ur = fb->GetWidth() / FHardwareTexture::GetTexDimension(fb->GetWidth()); + float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight()); + + ptr->Set(0, 0, 0, 0, vb); + ptr++; + ptr->Set(0, fb->Height, 0, 0, 0); + ptr++; + ptr->Set(fb->Width, 0, 0, ur, vb); + ptr++; + ptr->Set(fb->Width, fb->Height, 0, ur, 0); + mVertexBuf->set(make, 4); } // WIPE: CROSSFADE --------------------------------------------------------- @@ -306,32 +374,21 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) { Clock += ticks; - float ur = fb->GetWidth() / FHardwareTexture::GetTexDimension(fb->GetWidth()); - float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight()); + MakeVBO(fb); gl_RenderState.SetTextureMode(TM_OPAQUE); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.ResetColor(); gl_RenderState.Apply(); fb->wipestartscreen->Bind(0, 0, false); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - FFlatVertex *ptr; - unsigned int offset, count; - ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(0, 0, 0, 0, vb); - ptr++; - ptr->Set(0, fb->Height, 0, 0, 0); - ptr++; - ptr->Set(fb->Width, 0, 0, ur, vb); - ptr++; - ptr->Set(fb->Width, fb->Height, 0, ur, 0); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); - - fb->wipeendscreen->Bind(0, 0, false); - gl_RenderState.SetColorAlpha(0xffffff, clamp(Clock/32.f, 0.f, 1.f)); + float a = clamp(Clock / 32.f, 0.f, 1.f); + Printf("%f\n", a); + gl_RenderState.SetColorAlpha(0xffffff, a); gl_RenderState.Apply(); - GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); + fb->wipeendscreen->Bind(0, 0, false); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f); gl_RenderState.SetTextureMode(TM_MODULATE); @@ -366,18 +423,15 @@ OpenGLFrameBuffer::Wiper_Melt::Wiper_Melt() // //========================================================================== -bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) +int OpenGLFrameBuffer::Wiper_Melt::MakeVBO(int ticks, OpenGLFrameBuffer *fb, bool &done) { + FFlatVertex *make = new FFlatVertex[321*4]; + FFlatVertex *ptr = make; + int dy; + float ur = fb->GetWidth() / FHardwareTexture::GetTexDimension(fb->GetWidth()); float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight()); - // Draw the new screen on the bottom. - gl_RenderState.SetTextureMode(TM_OPAQUE); - gl_RenderState.ResetColor(); - gl_RenderState.Apply(); - fb->wipeendscreen->Bind(0, 0, false); - FFlatVertex *ptr; - ptr = GLRenderer->mVBO->GetBuffer(); ptr->Set(0, 0, 0, 0, vb); ptr++; ptr->Set(0, fb->Height, 0, 0, 0); @@ -386,31 +440,26 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) ptr++; ptr->Set(fb->Width, fb->Height, 0, ur, 0); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - int i, dy; - bool done = false; - - fb->wipestartscreen->Bind(0, 0, false); // Copy the old screen in vertical strips on top of the new one. while (ticks--) { done = true; - for (i = 0; i < WIDTH; i++) + for (int i = 0; i < WIDTH; i++) { if (y[i] < 0) { y[i]++; done = false; - } + } else if (y[i] < HEIGHT) { - dy = (y[i] < 16) ? y[i]+1 : 8; + dy = (y[i] < 16) ? y[i] + 1 : 8; y[i] = MIN(y[i] + dy, HEIGHT); done = false; } if (ticks == 0) - { + { // Only draw for the final tick. // No need for optimization. Wipes won't ever be drawn with anything else. RECT rect; @@ -429,7 +478,6 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) rect.bottom = fb->Height - rect.bottom; rect.top = fb->Height - rect.top; - ptr = GLRenderer->mVBO->GetBuffer(); ptr->Set(rect.left, rect.bottom, 0, rect.left / tw, rect.top / th); ptr++; ptr->Set(rect.left, rect.top, 0, rect.left / tw, rect.bottom / th); @@ -438,12 +486,34 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) ptr++; ptr->Set(rect.right, rect.top, 0, rect.right / tw, rect.bottom / th); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } } } } + int numverts = int(ptr - make); + mVertexBuf->set(make, numverts); + delete[] make; + return numverts; +} + +bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) +{ + bool done = false; + int maxvert = MakeVBO(ticks, fb, done); + + // Draw the new screen on the bottom. + gl_RenderState.SetTextureMode(TM_OPAQUE); + gl_RenderState.ResetColor(); + gl_RenderState.Apply(); + fb->wipeendscreen->Bind(0, 0, false); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + fb->wipestartscreen->Bind(0, 0, false); gl_RenderState.SetTextureMode(TM_MODULATE); + for (int i = 4; i < maxvert; i += 4) + { + glDrawArrays(GL_TRIANGLE_STRIP, i, 4); + } return done; } @@ -486,6 +556,8 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) { bool done; + MakeVBO(fb); + BurnTime += ticks; ticks *= 2; @@ -524,18 +596,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.ResetColor(); gl_RenderState.Apply(); fb->wipestartscreen->Bind(0, 0, false); - FFlatVertex *ptr; - unsigned int offset, count; - ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(0, 0, 0, 0, vb); - ptr++; - ptr->Set(0, fb->Height, 0, 0, 0); - ptr++; - ptr->Set(fb->Width, 0, 0, ur, vb); - ptr++; - ptr->Set(fb->Width, fb->Height, 0, ur, 0); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.SetEffect(EFF_BURN); @@ -547,7 +608,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, 1, true, 0); - GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); gl_RenderState.SetEffect(EFF_NONE); // The fire may not always stabilize, so the wipe is forced to end From 8f0629932d4849550253d248473ca9c68189723b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 6 Aug 2016 14:29:21 +0200 Subject: [PATCH 0767/1509] - ImmRenderBuffer is not needed anymore. --- src/gl/data/gl_vertexbuffer.cpp | 34 --------------------------------- src/gl/data/gl_vertexbuffer.h | 2 -- 2 files changed, 36 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index dd3854596..fc17f7ff8 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -141,40 +141,6 @@ void FFlatVertexBuffer::BindVBO() } } -//========================================================================== -// -// immediate mode fallback for drivers without GL_ARB_buffer_storage -// -// No single core method is performant enough to handle this adequately -// so we have to resort to immediate mode instead... -// -//========================================================================== - -void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count) -{ - // this will only get called if we can't acquire a persistently mapped buffer. -#ifndef CORE_PROFILE - glBegin(primtype); - if (gl.glslversion > 0) - { - for (unsigned int i = 0; i < count; i++) - { - glVertexAttrib2fv(VATTR_TEXCOORD, &map[offset + i].u); - glVertexAttrib3fv(VATTR_VERTEX, &map[offset + i].x); - } - } - else // no shader means no vertex attributes, so use the old stuff instead. - { - for (unsigned int i = 0; i < count; i++) - { - glTexCoord2fv(&map[offset + i].u); - glVertex3fv(&map[offset + i].x); - } - } - glEnd(); -#endif -} - //========================================================================== // // Initialize a single vertex diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index edb38733a..0223c5791 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -54,8 +54,6 @@ class FFlatVertexBuffer : public FVertexBuffer static const unsigned int BUFFER_SIZE = 2000000; static const unsigned int BUFFER_SIZE_TO_USE = 1999500; - void ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count); - public: TArray vbo_shadowdata; // this is kept around for updating the actual (non-readable) buffer and as stand-in for pre GL 4.x From 21390e91b8a28c71ba44bf62ee3c7545508a74e2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 6 Aug 2016 21:04:45 +0200 Subject: [PATCH 0768/1509] Remove linear sky again --- src/r_plane.cpp | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index e25812fbd..c751fc5dc 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -880,30 +880,16 @@ static DWORD lastskycol_bgra[4]; static int skycolplace; static int skycolplace_bgra; -CVAR(Bool, r_linearsky, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); - // Get a column of sky when there is only one sky texture. static const BYTE *R_GetOneSkyColumn (FTexture *fronttex, int x) { - int tx; - if (r_linearsky) - { - angle_t xangle = (angle_t)((0.5 - x / (double)viewwidth) * FocalTangent * ANGLE_90); - angle_t column = (skyangle + xangle) ^ skyflip; - tx = (UMulScale16(column, frontcyl) + frontpos) >> FRACBITS; - } - else - { - angle_t column = (skyangle + xtoviewangle[x]) ^ skyflip; - tx = (UMulScale16(column, frontcyl) + frontpos) >> FRACBITS; - } + angle_t column = (skyangle + xtoviewangle[x]) ^ skyflip; + int tx = (UMulScale16(column, frontcyl) + frontpos) >> FRACBITS; if (!r_swtruecolor) return fronttex->GetColumn(tx, NULL); else - { return (const BYTE *)fronttex->GetColumnBgra(tx, NULL); - } } // Get a column of sky when there are two overlapping sky textures From 7000d0ccf9a97a01ab74853ea571d753e6e252b0 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 6 Aug 2016 22:59:16 +0200 Subject: [PATCH 0769/1509] Change GetPixelsBgra to use CopyTrueColorPixels --- src/g_strife/strife_sbar.cpp | 11 --- src/menu/playerdisplay.cpp | 11 --- src/textures/jpegtexture.cpp | 109 ------------------------- src/textures/pngtexture.cpp | 151 ----------------------------------- src/textures/texture.cpp | 46 ++++++++--- src/textures/textures.h | 1 + src/textures/warptexture.cpp | 14 +++- 7 files changed, 45 insertions(+), 298 deletions(-) diff --git a/src/g_strife/strife_sbar.cpp b/src/g_strife/strife_sbar.cpp index e1fcb3cda..eb3fa2608 100644 --- a/src/g_strife/strife_sbar.cpp +++ b/src/g_strife/strife_sbar.cpp @@ -34,7 +34,6 @@ public: const BYTE *GetColumn (unsigned int column, const Span **spans_out); const BYTE *GetPixels (); - const uint32_t *GetPixelsBgra() override; bool CheckModified (); void SetVial (int level); @@ -116,16 +115,6 @@ const BYTE *FHealthBar::GetPixels () return Pixels; } -const uint32_t *FHealthBar::GetPixelsBgra() -{ - if (NeedRefresh) - { - MakeTexture(); - PixelsBgra.clear(); - } - return FTexture::GetPixelsBgra(); -} - void FHealthBar::SetVial (int level) { if (level < 0) diff --git a/src/menu/playerdisplay.cpp b/src/menu/playerdisplay.cpp index 7b7e9ca5d..16671975a 100644 --- a/src/menu/playerdisplay.cpp +++ b/src/menu/playerdisplay.cpp @@ -78,7 +78,6 @@ public: const BYTE *GetColumn(unsigned int column, const Span **spans_out); const BYTE *GetPixels(); - const uint32_t *GetPixelsBgra() override; bool CheckModified(); protected: @@ -247,16 +246,6 @@ const BYTE *FBackdropTexture::GetPixels() return Pixels; } -const uint32_t *FBackdropTexture::GetPixelsBgra() -{ - if (LastRenderTic != gametic) - { - Render(); - PixelsBgra.clear(); - } - return FTexture::GetPixelsBgra(); -} - //============================================================================= // // This is one plasma and two rotozoomers. I think it turned out quite awesome. diff --git a/src/textures/jpegtexture.cpp b/src/textures/jpegtexture.cpp index f44b34d08..fc629b37e 100644 --- a/src/textures/jpegtexture.cpp +++ b/src/textures/jpegtexture.cpp @@ -187,7 +187,6 @@ public: const BYTE *GetColumn (unsigned int column, const Span **spans_out); const BYTE *GetPixels (); - const uint32_t *GetPixelsBgra (); void Unload (); FTextureFormat GetFormat (); int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); @@ -199,7 +198,6 @@ protected: Span DummySpans[2]; void MakeTexture (); - void MakeTextureBgra (); friend class FTexture; }; @@ -358,15 +356,6 @@ const BYTE *FJPEGTexture::GetPixels () return Pixels; } -const uint32_t *FJPEGTexture::GetPixelsBgra() -{ - if (PixelsBgra.empty()) - { - MakeTextureBgra(); - } - return PixelsBgra.data(); -} - //========================================================================== // // @@ -466,104 +455,6 @@ void FJPEGTexture::MakeTexture () } } -void FJPEGTexture::MakeTextureBgra() -{ - FWadLump lump = Wads.OpenLumpNum(SourceLump); - JSAMPLE *buff = NULL; - - jpeg_decompress_struct cinfo; - jpeg_error_mgr jerr; - - CreatePixelsBgraWithMipmaps(); - - cinfo.err = jpeg_std_error(&jerr); - cinfo.err->output_message = JPEG_OutputMessage; - cinfo.err->error_exit = JPEG_ErrorExit; - jpeg_create_decompress(&cinfo); - try - { - FLumpSourceMgr sourcemgr(&lump, &cinfo); - jpeg_read_header(&cinfo, TRUE); - if (!((cinfo.out_color_space == JCS_RGB && cinfo.num_components == 3) || - (cinfo.out_color_space == JCS_CMYK && cinfo.num_components == 4) || - (cinfo.out_color_space == JCS_GRAYSCALE && cinfo.num_components == 1))) - { - Printf(TEXTCOLOR_ORANGE "Unsupported color format\n"); - throw - 1; - } - - jpeg_start_decompress(&cinfo); - - int y = 0; - buff = new BYTE[cinfo.output_width * cinfo.output_components]; - - while (cinfo.output_scanline < cinfo.output_height) - { - int num_scanlines = jpeg_read_scanlines(&cinfo, &buff, 1); - BYTE *in = buff; - uint32_t *out = PixelsBgra.data() + y; - switch (cinfo.out_color_space) - { - case JCS_RGB: - for (int x = Width; x > 0; --x) - { - uint32_t r = in[0]; - uint32_t g = in[1]; - uint32_t b = in[2]; - *out = 0xff000000 | (r << 16) | (g << 8) | b; - out += Height; - in += 3; - } - break; - - case JCS_GRAYSCALE: - for (int x = Width; x > 0; --x) - { - uint32_t gray = in[0]; - *out = 0xff000000 | (gray << 16) | (gray << 8) | gray; - out += Height; - in += 1; - } - break; - - case JCS_CMYK: - // What are you doing using a CMYK image? :) - for (int x = Width; x > 0; --x) - { - // To be precise, these calculations should use 255, but - // 256 is much faster and virtually indistinguishable. - uint32_t r = in[3] - (((256 - in[0])*in[3]) >> 8); - uint32_t g = in[3] - (((256 - in[1])*in[3]) >> 8); - uint32_t b = in[3] - (((256 - in[2])*in[3]) >> 8); - *out = 0xff000000 | (r << 16) | (g << 8) | b; - out += Height; - in += 4; - } - break; - - default: - // The other colorspaces were considered above and discarded, - // but GCC will complain without a default for them here. - break; - } - y++; - } - jpeg_finish_decompress(&cinfo); - jpeg_destroy_decompress(&cinfo); - } - catch (int) - { - Printf(TEXTCOLOR_ORANGE " in texture %s\n", Name.GetChars()); - jpeg_destroy_decompress(&cinfo); - } - if (buff != NULL) - { - delete[] buff; - } - - GenerateBgraMipmaps(); -} - //=========================================================================== // diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index ee4eabe90..31d76f567 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -57,7 +57,6 @@ public: const BYTE *GetColumn (unsigned int column, const Span **spans_out); const BYTE *GetPixels (); - const uint32_t *GetPixelsBgra (); void Unload (); FTextureFormat GetFormat (); int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); @@ -81,7 +80,6 @@ protected: DWORD StartOfIDAT; void MakeTexture (); - void MakeTextureBgra (); friend class FTexture; }; @@ -454,15 +452,6 @@ const BYTE *FPNGTexture::GetPixels () return Pixels; } -const uint32_t *FPNGTexture::GetPixelsBgra() -{ - if (PixelsBgra.empty()) - { - MakeTextureBgra(); - } - return PixelsBgra.data(); -} - //========================================================================== // @@ -620,146 +609,6 @@ void FPNGTexture::MakeTexture () delete lump; } -void FPNGTexture::MakeTextureBgra () -{ - FileReader *lump; - - if (SourceLump >= 0) - { - lump = new FWadLump(Wads.OpenLumpNum(SourceLump)); - } - else - { - lump = new FileReader(SourceFile.GetChars()); - } - - CreatePixelsBgraWithMipmaps(); - if (StartOfIDAT != 0) - { - DWORD len, id; - lump->Seek (StartOfIDAT, SEEK_SET); - lump->Read(&len, 4); - lump->Read(&id, 4); - - if (ColorType == 0 || ColorType == 3) /* Grayscale and paletted */ - { - std::vector src(Width*Height); - M_ReadIDAT (lump, src.data(), Width, Height, Width, BitDepth, ColorType, Interlace, BigLong((unsigned int)len)); - - if (!PngPalette.empty()) - { - for (int x = 0; x < Width; x++) - { - for (int y = 0; y < Height; y++) - { - uint32_t r = PngPalette[src[x + y * Width] * 3 + 0]; - uint32_t g = PngPalette[src[x + y * Width] * 3 + 1]; - uint32_t b = PngPalette[src[x + y * Width] * 3 + 2]; - PixelsBgra[x * Height + y] = 0xff000000 | (r << 16) | (g << 8) | b; - } - } - } - else - { - for (int x = 0; x < Width; x++) - { - for (int y = 0; y < Height; y++) - { - uint32_t gray = src[x + y * Width]; - PixelsBgra[x * Height + y] = 0xff000000 | (gray << 16) | (gray << 8) | gray; - } - } - } - } - else /* RGB and/or Alpha present */ - { - int bytesPerPixel = ColorType == 2 ? 3 : ColorType == 4 ? 2 : 4; - BYTE *tempix = new BYTE[Width * Height * bytesPerPixel]; - BYTE *in; - uint32_t *out; - int x, y, pitch, backstep; - - M_ReadIDAT (lump, tempix, Width, Height, Width*bytesPerPixel, BitDepth, ColorType, Interlace, BigLong((unsigned int)len)); - in = tempix; - out = PixelsBgra.data(); - - // Convert from source format to paletted, column-major. - // Formats with alpha maps are reduced to only 1 bit of alpha. - switch (ColorType) - { - case 2: // RGB - pitch = Width * 3; - backstep = Height * pitch - 3; - for (x = Width; x > 0; --x) - { - for (y = Height; y > 0; --y) - { - if (!HaveTrans) - { - *out++ = 0xff000000 | (((uint32_t)in[0]) << 16) | (((uint32_t)in[1]) << 8) | ((uint32_t)in[2]); - } - else - { - if (in[0] == NonPaletteTrans[0] && - in[1] == NonPaletteTrans[1] && - in[2] == NonPaletteTrans[2]) - { - *out++ = 0; - } - else - { - *out++ = 0xff000000 | (((uint32_t)in[0]) << 16) | (((uint32_t)in[1]) << 8) | ((uint32_t)in[2]); - } - } - in += pitch; - } - in -= backstep; - } - break; - - case 4: // Grayscale + Alpha - pitch = Width * 2; - backstep = Height * pitch - 2; - for (x = Width; x > 0; --x) - { - for (y = Height; y > 0; --y) - { - // output as premultiplied alpha - uint32_t alpha = in[1]; - uint32_t gray = (in[0] * alpha + 127) / 255; - *out++ = (alpha << 24) | (gray << 16) | (gray << 8) | gray; - in += pitch; - } - in -= backstep; - } - break; - - case 6: // RGB + Alpha - pitch = Width * 4; - backstep = Height * pitch - 4; - for (x = Width; x > 0; --x) - { - for (y = Height; y > 0; --y) - { - // output as premultiplied alpha - uint32_t alpha = in[3]; - uint32_t red = (in[0] * alpha + 127) / 255; - uint32_t green = (in[1] * alpha + 127) / 255; - uint32_t blue = (in[2] * alpha + 127) / 255; - *out++ = (alpha << 24) | (red << 16) | (green << 8) | blue; - in += pitch; - } - in -= backstep; - } - break; - } - delete[] tempix; - } - } - delete lump; - GenerateBgraMipmaps(); -} - //=========================================================================== // // FPNGTexture::CopyTrueColorPixels diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 160223617..7dfe04b23 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -194,21 +194,15 @@ const uint32_t *FTexture::GetColumnBgra(unsigned int column, const Span **spans_ const uint32_t *FTexture::GetPixelsBgra() { - if (PixelsBgra.empty()) + if (PixelsBgra.empty() || CheckModified()) { - GetColumn(0, nullptr); - const BYTE *indices = GetPixels(); - if (indices == nullptr) + if (!GetColumn(0, nullptr)) return nullptr; - CreatePixelsBgraWithMipmaps(); - for (int i = 0; i < Width * Height; i++) - { - if (indices[i] != 0) - PixelsBgra[i] = 0xff000000 | GPalette.BaseColors[indices[i]].d; - else - PixelsBgra[i] = 0; - } - GenerateBgraMipmaps(); + + FBitmap bitmap; + bitmap.Create(GetWidth(), GetHeight()); + CopyTrueColorPixels(&bitmap, 0, 0); + GenerateBgraFromBitmap(bitmap); } return PixelsBgra.data(); } @@ -356,6 +350,32 @@ void FTexture::FreeSpans (Span **spans) const M_Free (spans); } +void FTexture::GenerateBgraFromBitmap(const FBitmap &bitmap) +{ + CreatePixelsBgraWithMipmaps(); + + // Transpose and premultiply alpha + const uint32_t *src = (const uint32_t *)bitmap.GetPixels(); + uint32_t *dest = PixelsBgra.data(); + for (int x = 0; x < Width; x++) + { + for (int y = 0; y < Height; y++) + { + uint32_t p = src[x + y * Width]; + uint32_t red = RPART(p); + uint32_t green = GPART(p); + uint32_t blue = BPART(p); + uint32_t alpha = APART(p); + red = (red * alpha + 127) / 255; + green = (green * alpha + 127) / 255; + blue = (blue * alpha + 127) / 255; + dest[y + x * Height] = (alpha << 24) | (red << 16) | (green << 8) | blue; + } + } + + GenerateBgraMipmaps(); +} + void FTexture::CreatePixelsBgraWithMipmaps() { int levels = MipmapLevels(); diff --git a/src/textures/textures.h b/src/textures/textures.h index ff1093a49..e5ecdc679 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -274,6 +274,7 @@ protected: std::vector PixelsBgra; + void GenerateBgraFromBitmap(const FBitmap &bitmap); void CreatePixelsBgraWithMipmaps(); void GenerateBgraMipmaps(); void GenerateBgraMipmapsFast(); diff --git a/src/textures/warptexture.cpp b/src/textures/warptexture.cpp index 0d18ab58f..91c7b9fc4 100644 --- a/src/textures/warptexture.cpp +++ b/src/textures/warptexture.cpp @@ -39,6 +39,7 @@ #include "r_utility.h" #include "textures/textures.h" #include "warpbuffer.h" +#include "v_palette.h" FWarpTexture::FWarpTexture (FTexture *source, int warptype) @@ -96,13 +97,20 @@ const BYTE *FWarpTexture::GetPixels () const uint32_t *FWarpTexture::GetPixelsBgra() { DWORD time = r_FrameTime; - if (Pixels == NULL || time != GenTime) { MakeTexture(time); - PixelsBgra.clear(); + CreatePixelsBgraWithMipmaps(); + for (int i = 0; i < Width * Height; i++) + { + if (Pixels[i] != 0) + PixelsBgra[i] = 0xff000000 | GPalette.BaseColors[Pixels[i]].d; + else + PixelsBgra[i] = 0; + } + GenerateBgraMipmapsFast(); } - return FTexture::GetPixelsBgra(); + return PixelsBgra.data(); } const BYTE *FWarpTexture::GetColumn (unsigned int column, const Span **spans_out) From 2f512e54cdee4c1d15f632fcab64d3850004028b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 6 Aug 2016 23:12:34 +0200 Subject: [PATCH 0770/1509] Remove unused code --- src/textures/pngtexture.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index 31d76f567..9a64bac61 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -41,7 +41,6 @@ #include "bitmap.h" #include "v_palette.h" #include "textures/textures.h" -#include //========================================================================== // @@ -74,7 +73,6 @@ protected: bool HaveTrans; WORD NonPaletteTrans[3]; - std::vector PngPalette; BYTE *PaletteMap; int PaletteSize; DWORD StartOfIDAT; @@ -268,12 +266,6 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename { lump.Seek (len - PaletteSize * 3, SEEK_CUR); } - for (i = 0; i < PaletteSize; i++) - { - PngPalette.push_back(p.pngpal[i][0]); - PngPalette.push_back(p.pngpal[i][1]); - PngPalette.push_back(p.pngpal[i][2]); - } for (i = PaletteSize - 1; i >= 0; --i) { p.palette[i] = MAKERGB(p.pngpal[i][0], p.pngpal[i][1], p.pngpal[i][2]); From 04c59b434bc722147fbaab75bbd621174b38c796 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 7 Aug 2016 00:40:31 +0200 Subject: [PATCH 0771/1509] - renamed WipeVertexBuffer to FSimpleVertexBuffer because this will be useful elsewhere, too. --- src/gl/data/gl_vertexbuffer.cpp | 28 ++++++++++++++++++++ src/gl/data/gl_vertexbuffer.h | 10 +++++++ src/gl/system/gl_framebuffer.h | 4 +-- src/gl/system/gl_wipe.cpp | 47 +-------------------------------- 4 files changed, 41 insertions(+), 48 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index fc17f7ff8..2f38a720e 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -71,6 +71,34 @@ FVertexBuffer::~FVertexBuffer() } } + +void FSimpleVertexBuffer::BindVBO() +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + if (gl.glslversion > 0) + { + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); + glDisableVertexAttribArray(VATTR_COLOR); + glDisableVertexAttribArray(VATTR_VERTEX2); + } + else + { + glVertexPointer(3, GL_FLOAT, sizeof(FFlatVertex), &VTO->x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FFlatVertex), &VTO->u); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + } +} + +void FSimpleVertexBuffer::set(FFlatVertex *verts, int count) +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + gl_RenderState.SetVertexBuffer(this); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(*verts), verts, GL_STREAM_DRAW); +} + //========================================================================== // // diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 0223c5791..4d39a7f58 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -41,6 +41,16 @@ struct FFlatVertex #define VTO ((FFlatVertex*)NULL) +class FSimpleVertexBuffer : public FVertexBuffer +{ + TArray mBuffer; +public: + FSimpleVertexBuffer() + { + } + void BindVBO(); + void set(FFlatVertex *verts, int count); +}; class FFlatVertexBuffer : public FVertexBuffer { diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index 2ba90ff5b..d648da30c 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -7,6 +7,7 @@ #endif class FHardwareTexture; +class FSimpleVertexBuffer; extern long gl_frameMS; extern long gl_frameCount; @@ -94,10 +95,9 @@ private: class Wiper { - class WipeVertexBuffer; protected: - WipeVertexBuffer *mVertexBuf; + FSimpleVertexBuffer *mVertexBuf; void MakeVBO(OpenGLFrameBuffer *fb); diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index bc1708061..2978dd55d 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -271,51 +271,6 @@ void OpenGLFrameBuffer::WipeCleanup() FMaterial::ClearLastTexture(); } -//========================================================================== -// -// The wiper vertex buffer -// -// Note that this will recreate the buffer each frame, although -// only for melt its contents will change. -// -// But since this is no time critical code, ease of implementation -// was chosen over maximum efficiency. -// -//========================================================================== - -class OpenGLFrameBuffer::Wiper::WipeVertexBuffer : public FVertexBuffer -{ -public: - WipeVertexBuffer() - { - } - void BindVBO() - { - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - if (gl.glslversion > 0) - { - glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); - glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); - glDisableVertexAttribArray(VATTR_COLOR); - glDisableVertexAttribArray(VATTR_VERTEX2); - } - else - { - glVertexPointer(3, GL_FLOAT, sizeof(FFlatVertex), &VTO->x); - glTexCoordPointer(2, GL_FLOAT, sizeof(FFlatVertex), &VTO->u); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - } - } - void set(FFlatVertex *verts, int count) - { - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - gl_RenderState.SetVertexBuffer(this); - glBufferData(GL_ARRAY_BUFFER, count * sizeof(*verts), verts, GL_STREAM_DRAW); - } -}; - //========================================================================== // // OpenGLFrameBuffer :: Wiper Constructor @@ -323,7 +278,7 @@ public: //========================================================================== OpenGLFrameBuffer::Wiper::Wiper() { - mVertexBuf = new WipeVertexBuffer; + mVertexBuf = new FSimpleVertexBuffer; } OpenGLFrameBuffer::Wiper::~Wiper() From d4615861aef3655156ae11142765ff8ec311ae1b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 6 Aug 2016 23:42:37 +0200 Subject: [PATCH 0772/1509] Fix missing FGLRenderBuffers::IsEnabled checks --- src/gl/renderer/gl_postprocess.cpp | 4 ++-- src/gl/renderer/gl_renderbuffers.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index a997f5b47..f249aa1cc 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -207,7 +207,7 @@ void FGLRenderer::BloomScene() void FGLRenderer::TonemapScene() { - if (gl_tonemap == 0) + if (gl_tonemap == 0 || !FGLRenderBuffers::IsEnabled()) return; FGLPostProcessState savedState; @@ -229,7 +229,7 @@ void FGLRenderer::TonemapScene() void FGLRenderer::LensDistortScene() { - if (gl_lens == 0) + if (gl_lens == 0 || !FGLRenderBuffers::IsEnabled()) return; float k[4] = diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 490d73ed0..3b402d801 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -141,6 +141,9 @@ void FGLRenderBuffers::DeleteFrameBuffer(GLuint &handle) void FGLRenderBuffers::Setup(int width, int height) { + if (!IsEnabled()) + return; + int samples = GetCvarSamples(); if (width == mWidth && height == mHeight && mSamples != samples) From def3ad7533693978b9a546967219e0c900af94c4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 8 Aug 2016 12:13:09 +0200 Subject: [PATCH 0773/1509] - refactored all 2D drawing to use its own vertex buffer which does not need to be mapped permanently. --- src/CMakeLists.txt | 1 + src/gl/data/gl_vertexbuffer.cpp | 18 +- src/gl/data/gl_vertexbuffer.h | 23 +- src/gl/renderer/gl_2ddrawer.cpp | 488 +++++++++++++++++++++++++++++ src/gl/renderer/gl_2ddrawer.h | 73 +++++ src/gl/renderer/gl_postprocess.cpp | 2 + src/gl/renderer/gl_renderer.cpp | 371 +--------------------- src/gl/renderer/gl_renderer.h | 11 +- src/gl/system/gl_framebuffer.cpp | 29 +- src/gl/system/gl_wipe.cpp | 10 +- 10 files changed, 632 insertions(+), 394 deletions(-) create mode 100644 src/gl/renderer/gl_2ddrawer.cpp create mode 100644 src/gl/renderer/gl_2ddrawer.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 170737fa5..e002fc66f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1060,6 +1060,7 @@ set( FASTMATH_SOURCES gl/utility/gl_clock.cpp gl/utility/gl_cycler.cpp gl/utility/gl_geometric.cpp + gl/renderer/gl_2ddrawer.cpp gl/renderer/gl_renderer.cpp gl/renderer/gl_renderstate.cpp gl/renderer/gl_renderbuffers.cpp diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 2f38a720e..1d69c2547 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -77,22 +77,26 @@ void FSimpleVertexBuffer::BindVBO() glBindBuffer(GL_ARRAY_BUFFER, vbo_id); if (gl.glslversion > 0) { - glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); - glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); - glDisableVertexAttribArray(VATTR_COLOR); + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FSimpleVertex), &VSiO->x); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSimpleVertex), &VSiO->u); + glVertexAttribPointer(VATTR_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(FSimpleVertex), &VSiO->color); + glEnableVertexAttribArray(VATTR_VERTEX); + glEnableVertexAttribArray(VATTR_TEXCOORD); + glEnableVertexAttribArray(VATTR_COLOR); glDisableVertexAttribArray(VATTR_VERTEX2); } else { - glVertexPointer(3, GL_FLOAT, sizeof(FFlatVertex), &VTO->x); - glTexCoordPointer(2, GL_FLOAT, sizeof(FFlatVertex), &VTO->u); + glVertexPointer(3, GL_FLOAT, sizeof(FSimpleVertex), &VSiO->x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FSimpleVertex), &VSiO->u); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(FSimpleVertex), &VSiO->color); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); } } -void FSimpleVertexBuffer::set(FFlatVertex *verts, int count) +void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count) { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); gl_RenderState.SetVertexBuffer(this); diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 4d39a7f58..ce598965f 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -36,20 +36,37 @@ struct FFlatVertex u = uu; v = vv; } - void BindVBO(); +}; + +struct FSimpleVertex +{ + float x, z, y; // world position + float u, v; // texture coordinates + PalEntry color; + + void Set(float xx, float zz, float yy, float uu = 0, float vv = 0, PalEntry col = 0xffffffff) + { + x = xx; + z = zz; + y = yy; + u = uu; + v = vv; + color = col; + } }; #define VTO ((FFlatVertex*)NULL) +#define VSiO ((FSimpleVertex*)NULL) class FSimpleVertexBuffer : public FVertexBuffer { - TArray mBuffer; + TArray mBuffer; public: FSimpleVertexBuffer() { } void BindVBO(); - void set(FFlatVertex *verts, int count); + void set(FSimpleVertex *verts, int count); }; class FFlatVertexBuffer : public FVertexBuffer diff --git a/src/gl/renderer/gl_2ddrawer.cpp b/src/gl/renderer/gl_2ddrawer.cpp new file mode 100644 index 000000000..75f76bbe6 --- /dev/null +++ b/src/gl/renderer/gl_2ddrawer.cpp @@ -0,0 +1,488 @@ +/* +** gl_2ddrawer.h +** Container class for drawing 2d graphics with a vertex buffer +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_2ddrawer.h" +#include "gl/textures/gl_material.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/textures/gl_translate.h" +#include "vectors.h" + +//========================================================================== +// +// +// +//========================================================================== + +int F2DDrawer::AddData(const F2DDrawer::DataGeneric *data) +{ + int addr = mData.Reserve(data->mLen); + memcpy(&mData[addr], data, data->mLen); + mLastLineCmd = -1; + return addr; +} + +//========================================================================== +// +// Draws a texture +// +//========================================================================== + +void F2DDrawer::AddTexture(FTexture *img, DrawParms &parms) +{ + double xscale = parms.destwidth / parms.texwidth; + double yscale = parms.destheight / parms.texheight; + double x = parms.x - parms.left * xscale; + double y = parms.y - parms.top * yscale; + double w = parms.destwidth; + double h = parms.destheight; + float u1, v1, u2, v2; + int light = 255; + + FMaterial * gltex = FMaterial::ValidateTexture(img, false); + if (gltex == nullptr) return; + + DataTexture dg; + + dg.mType = DrawTypeTexture; + dg.mLen = (sizeof(dg) + 7) & ~7; + dg.mVertCount = 4; + dg.mRenderStyle = parms.style; + dg.mMasked = !!parms.masked; + dg.mTexture = gltex; + + if (parms.colorOverlay && (parms.colorOverlay & 0xffffff) == 0) + { + // handle black overlays as reduced light. + light = 255 - APART(parms.colorOverlay); + parms.colorOverlay = 0; + } + dg.mVertIndex = (int)mVertices.Reserve(parms.colorOverlay == 0? 4 : 8); + dg.mColorOverlay = parms.colorOverlay; + dg.mTranslation = 0; + + if (!img->bHasCanvas) + { + if (!parms.alphaChannel) + { + if (parms.remap != NULL && !parms.remap->Inactive) + { + GLTranslationPalette * pal = static_cast(parms.remap->GetNative()); + if (pal) dg.mTranslation = -pal->GetIndex(); + } + } + dg.mAlphaTexture = !!(parms.style.Flags & STYLEF_RedIsAlpha); + u1 = gltex->GetUL(); + v1 = gltex->GetVT(); + u2 = gltex->GetUR(); + v2 = gltex->GetVB(); + + } + else + { + dg.mAlphaTexture = false; + u1 = 0.f; + v1 = 1.f; + u2 = 1.f; + v2 = 0.f; + } + + if (parms.flipX) + std::swap(u1, u2); + + + if (parms.windowleft > 0 || parms.windowright < parms.texwidth) + { + double wi = MIN(parms.windowright, parms.texwidth); + x += parms.windowleft * xscale; + w -= (parms.texwidth - wi + parms.windowleft) * xscale; + + u1 = float(u1 + parms.windowleft / parms.texwidth); + u2 = float(u2 - (parms.texwidth - wi) / parms.texwidth); + } + + PalEntry color; + if (parms.style.Flags & STYLEF_ColorIsFixed) + { + color = parms.fillcolor; + std::swap(color.r, color.b); + } + else + { + color = PalEntry(light, light, light); + } + color.a = (BYTE)(parms.Alpha * 255); + + // scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates + int btm = (SCREENHEIGHT - screen->GetHeight()) / 2; + btm = SCREENHEIGHT - btm; + + int space = (static_cast(screen)->GetTrueHeight() - screen->GetHeight()) / 2; + dg.mScissor[0] = parms.lclip; + dg.mScissor[1] = btm - parms.dclip + space; + dg.mScissor[2] = parms.rclip - parms.lclip; + dg.mScissor[3] = parms.dclip - parms.uclip; + + FSimpleVertex *ptr = &mVertices[dg.mVertIndex]; + ptr->Set(x, y, 0, u1, v1, color); ptr++; + ptr->Set(x, y + h, 0, u1, v2, color); ptr++; + ptr->Set(x + w, y, 0, u2, v1, color); ptr++; + ptr->Set(x + w, y + h, 0, u2, v2, color); ptr++; + if (parms.colorOverlay != 0) + { + color = parms.colorOverlay; + std::swap(color.r, color.b); + ptr->Set(x, y, 0, u1, v1, color); ptr++; + ptr->Set(x, y + h, 0, u1, v2, color); ptr++; + ptr->Set(x + w, y, 0, u2, v1, color); ptr++; + ptr->Set(x + w, y + h, 0, u2, v2, color); ptr++; + } + AddData(&dg); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::AddPoly(FTexture *texture, FVector2 *points, int npoints, + double originx, double originy, double scalex, double scaley, + DAngle rotation, FDynamicColormap *colormap, int lightlevel) +{ + FMaterial *gltexture = FMaterial::ValidateTexture(texture, false); + + if (gltexture == nullptr) + { + return; + } + DataSimplePoly poly; + + poly.mType = DrawTypePoly; + poly.mLen = (sizeof(poly) + 7) & ~7; + poly.mTexture = gltexture; + poly.mColormap = colormap; + poly.mLightLevel = lightlevel; + poly.mVertCount = npoints; + poly.mVertIndex = (int)mVertices.Reserve(npoints); + + bool dorotate = rotation != 0; + + float cosrot = cos(rotation.Radians()); + float sinrot = sin(rotation.Radians()); + + float uscale = float(1.f / (texture->GetScaledWidth() * scalex)); + float vscale = float(1.f / (texture->GetScaledHeight() * scaley)); + if (texture->bHasCanvas) + { + vscale = 0 - vscale; + } + float ox = float(originx); + float oy = float(originy); + + for (int i = 0; i < npoints; ++i) + { + float u = points[i].X - 0.5f - ox; + float v = points[i].Y - 0.5f - oy; + if (dorotate) + { + float t = u; + u = t * cosrot - v * sinrot; + v = v * cosrot + t * sinrot; + } + mVertices[poly.mVertIndex+i].Set(points[i].X, points[i].Y, 0, u*uscale, v*vscale); + } + AddData(&poly); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void F2DDrawer::AddDim(PalEntry color, float damount, int x1, int y1, int w, int h) +{ + color.a = uint8_t(damount * 255); + std::swap(color.r, color.b); + + DataGeneric dg; + + dg.mType = DrawTypeDim; + dg.mLen = (sizeof(dg) + 7) & ~7; + dg.mVertCount = 4; + dg.mVertIndex = (int)mVertices.Reserve(4); + FSimpleVertex *ptr = &mVertices[dg.mVertIndex]; + ptr->Set(x1, y1, 0, 0, 0, color); ptr++; + ptr->Set(x1, y1 + h, 0, 0, 0, color); ptr++; + ptr->Set(x1 + w, y1 + h, 0, 0, 0, color); ptr++; + ptr->Set(x1 + w, y1, 0, 0, 0, color); ptr++; + AddData(&dg); +} + +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::AddClear(int left, int top, int right, int bottom, int palcolor, uint32 color) +{ + PalEntry p = palcolor == -1 || color != 0 ? (PalEntry)color : GPalette.BaseColors[palcolor]; + AddDim(p, 1.f, left, top, right - left, bottom - top); +} + +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin) +{ + float fU1, fU2, fV1, fV2; + + FMaterial *gltexture = FMaterial::ValidateTexture(src, false); + + if (!gltexture) return; + + DataFlatFill dg; + + dg.mType = DrawTypeFlatFill; + dg.mLen = (sizeof(dg) + 7) & ~7; + dg.mVertCount = 4; + dg.mVertIndex = (int)mVertices.Reserve(4); + dg.mTexture = gltexture; + + // scaling is not used here. + if (!local_origin) + { + fU1 = float(left) / src->GetWidth(); + fV1 = float(top) / src->GetHeight(); + fU2 = float(right) / src->GetWidth(); + fV2 = float(bottom) / src->GetHeight(); + } + else + { + fU1 = 0; + fV1 = 0; + fU2 = float(right - left) / src->GetWidth(); + fV2 = float(bottom - top) / src->GetHeight(); + } + FSimpleVertex *ptr = &mVertices[dg.mVertIndex]; + ptr->Set(left, top, 0, fU1, fV1); ptr++; + ptr->Set(left, bottom, 0, fU1, fV2); ptr++; + ptr->Set(right, top, 0, fU2, fV1); ptr++; + ptr->Set(right, bottom, 0, fU2, fV2); ptr++; + AddData(&dg); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::AddLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color) +{ + PalEntry p = color ? (PalEntry)color : GPalette.BaseColors[palcolor]; + p.a = 255; + std::swap(p.r, p.b); + + DataGeneric dg; + + dg.mType = DrawTypeLine; + dg.mLen = (sizeof(dg) + 7) & ~7; + dg.mVertCount = 2; + dg.mVertIndex = (int)mVertices.Reserve(2); + mVertices[dg.mVertIndex].Set(x1, y1, 0, 0, 0, p); + mVertices[dg.mVertIndex+1].Set(x2, y2, 0, 0, 0, p); + + // Test if we can batch multiple line commands + if (mLastLineCmd == -1) + { + mLastLineCmd = AddData(&dg); + } + else + { + DataGeneric *dg = (DataGeneric *)&mData[mLastLineCmd]; + dg->mVertCount += 2; + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::AddPixel(int x1, int y1, int palcolor, uint32 color) +{ + PalEntry p = color ? (PalEntry)color : GPalette.BaseColors[palcolor]; + p.a = 255; + std::swap(p.r, p.b); + + DataGeneric dg; + + dg.mType = DrawTypePixel; + dg.mLen = (sizeof(dg) + 7) & ~7; + dg.mVertCount = 2; + dg.mVertIndex = (int)mVertices.Reserve(1); + mVertices[dg.mVertIndex].Set(x1, y1, 0, 0, 0, p); + AddData(&dg); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::Flush() +{ + if (mData.Size() == 0) return; + SBYTE savedlightmode = glset.lightmode; + // lightmode is only relevant for automap subsectors, + // but We cannot use the software light mode here because it doesn't properly calculate the light for 2D rendering. + if (glset.lightmode == 8) glset.lightmode = 0; + + set(&mVertices[0], mVertices.Size()); + for (unsigned i = 0; i < mData.Size();) + { + DataGeneric *dg = (DataGeneric *)&mData[i]; + switch (dg->mType) + { + default: + break; + + case DrawTypeTexture: + { + DataTexture *dt = static_cast(dg); + + gl_SetRenderStyle(dt->mRenderStyle, !dt->mMasked, false); + gl_RenderState.SetMaterial(dt->mTexture, CLAMP_XY_NOMIP, dt->mTranslation, -1, dt->mAlphaTexture); + if (dt->mTexture->tex->bHasCanvas) gl_RenderState.SetTextureMode(TM_OPAQUE); + + glEnable(GL_SCISSOR_TEST); + glScissor(dt->mScissor[0], dt->mScissor[1], dt->mScissor[2], dt->mScissor[3]); + + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_RenderState.Apply(); + + glDrawArrays(GL_TRIANGLE_STRIP, dt->mVertIndex, 4); + + gl_RenderState.BlendEquation(GL_FUNC_ADD); + if (dt->mVertCount > 4) + { + gl_RenderState.SetTextureMode(TM_MASK); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_STRIP, dt->mVertIndex + 4, 4); + } + + glScissor(0, 0, screen->GetWidth(), screen->GetHeight()); + glDisable(GL_SCISSOR_TEST); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.SetTextureMode(TM_MODULATE); + break; + } + + case DrawTypePoly: + { + DataSimplePoly *dsp = static_cast(dg); + + FColormap cm; + cm = dsp->mColormap; + gl_SetColor(dsp->mLightLevel, 0, cm, 1.f); + gl_RenderState.SetMaterial(dsp->mTexture, CLAMP_NONE, 0, -1, false); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_FAN, dsp->mVertIndex, dsp->mVertCount); + break; + } + + case DrawTypeFlatFill: + { + DataFlatFill *dff = static_cast(dg); + gl_RenderState.SetMaterial(dff->mTexture, CLAMP_NONE, 0, -1, false); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_STRIP, dg->mVertIndex, dg->mVertCount); + break; + } + + case DrawTypeDim: + gl_RenderState.EnableTexture(false); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.AlphaFunc(GL_GREATER, 0); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_FAN, dg->mVertIndex, dg->mVertCount); + gl_RenderState.EnableTexture(true); + break; + + case DrawTypeLine: + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(); + glDrawArrays(GL_LINES, dg->mVertIndex, dg->mVertCount); + gl_RenderState.EnableTexture(true); + break; + + case DrawTypePixel: + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(); + glDrawArrays(GL_POINTS, dg->mVertIndex, dg->mVertCount); + gl_RenderState.EnableTexture(true); + break; + + } + i += dg->mLen; + } + mVertices.Clear(); + mData.Clear(); + gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); + glset.lightmode = savedlightmode; +} + + diff --git a/src/gl/renderer/gl_2ddrawer.h b/src/gl/renderer/gl_2ddrawer.h new file mode 100644 index 000000000..32d2ad1f5 --- /dev/null +++ b/src/gl/renderer/gl_2ddrawer.h @@ -0,0 +1,73 @@ +#ifndef __2DDRAWER_H +#define __2DDRAWER_H + +#include "tarray.h" +#include "gl/data/gl_vertexbuffer.h" + +class F2DDrawer : public FSimpleVertexBuffer +{ + enum EDrawType + { + DrawTypeTexture, + DrawTypeDim, + DrawTypeFlatFill, + DrawTypePoly, + DrawTypeLine, + DrawTypePixel + }; + + struct DataGeneric + { + EDrawType mType; + uint32_t mLen; + int mVertIndex; + int mVertCount; + }; + + struct DataTexture : public DataGeneric + { + FMaterial *mTexture; + int mScissor[4]; + uint32_t mColorOverlay; + int mTranslation; + FRenderStyle mRenderStyle; + bool mMasked; + bool mAlphaTexture; + }; + + struct DataFlatFill : public DataGeneric + { + FMaterial *mTexture; + }; + + struct DataSimplePoly : public DataGeneric + { + FMaterial *mTexture; + int mLightLevel; + FDynamicColormap *mColormap; + }; + + TArray mVertices; + TArray mData; + int mLastLineCmd = -1; // consecutive lines can be batched into a single draw call so keep this info around. + + int AddData(const DataGeneric *data); + +public: + void AddTexture(FTexture *img, DrawParms &parms); + void AddDim(PalEntry color, float damount, int x1, int y1, int w, int h); + void AddClear(int left, int top, int right, int bottom, int palcolor, uint32 color); + void AddFlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin); + + void AddPoly(FTexture *texture, FVector2 *points, int npoints, + double originx, double originy, double scalex, double scaley, + DAngle rotation, FDynamicColormap *colormap, int lightlevel); + + void AddLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color); + void AddPixel(int x1, int y1, int palcolor, uint32 color); + + void Flush(); +}; + + +#endif diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index f249aa1cc..79bd31860 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -71,6 +71,7 @@ #include "gl/shaders/gl_tonemapshader.h" #include "gl/shaders/gl_lensshader.h" #include "gl/shaders/gl_presentshader.h" +#include "gl/renderer/gl_2ddrawer.h" //========================================================================== // @@ -283,6 +284,7 @@ void FGLRenderer::LensDistortScene() void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) { + m2DDrawer->Flush(); // draw all pending 2D stuff before copying the buffer if (FGLRenderBuffers::IsEnabled()) { FGLPostProcessState savedState; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 9105c08c7..2716c6a2c 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -58,6 +58,7 @@ #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderbuffers.h" +#include "gl/renderer/gl_2ddrawer.h" #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_drawinfo.h" @@ -106,6 +107,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mShaderManager = NULL; gllight = glpart2 = glpart = mirrortexture = NULL; mLights = NULL; + m2DDrawer = nullptr; } void gl_LoadModels(); @@ -120,6 +122,7 @@ void FGLRenderer::Initialize() mTonemapShader = new FTonemapShader(); mLensShader = new FLensShader(); mPresentShader = new FPresentShader(); + m2DDrawer = new F2DDrawer; // Only needed for the core profile, because someone decided it was a good idea to remove the default VAO. if (gl.version >= 4.0) @@ -153,6 +156,7 @@ FGLRenderer::~FGLRenderer() gl_FlushModels(); gl_DeleteAllAttachedLights(); FMaterial::FlushAll(); + if (m2DDrawer != nullptr) delete m2DDrawer; if (mShaderManager != NULL) delete mShaderManager; if (mSamplerManager != NULL) delete mSamplerManager; if (mVBO != NULL) delete mVBO; @@ -378,366 +382,13 @@ void FGLRenderer::ClearBorders() int borderHeight = (trueHeight - height) / 2; glViewport(0, 0, width, trueHeight); - gl_RenderState.mProjectionMatrix.loadIdentity(); - gl_RenderState.mProjectionMatrix.ortho(0.0f, width * 1.0f, 0.0f, trueHeight, -1.0f, 1.0f); - gl_RenderState.SetColor(0.f ,0.f ,0.f ,1.f); - gl_RenderState.Set2DMode(true); - gl_RenderState.EnableTexture(false); - gl_RenderState.Apply(); - gl_RenderState.ApplyMatrices(); - - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(0, borderHeight, 0, 0, 0); ptr++; - ptr->Set(0, 0, 0, 0, 0); ptr++; - ptr->Set(width, 0, 0, 0, 0); ptr++; - ptr->Set(width, borderHeight, 0, 0, 0); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - ptr->Set(0, trueHeight, 0, 0, 0); ptr++; - ptr->Set(0, trueHeight - borderHeight, 0, 0, 0); ptr++; - ptr->Set(width, trueHeight - borderHeight, 0, 0, 0); ptr++; - ptr->Set(width, trueHeight, 0, 0, 0); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - gl_RenderState.EnableTexture(true); - + glClearColor(0, 0, 0, 1); + glEnable(GL_SCISSOR_TEST); + glScissor(0, 0, width, borderHeight); + glClear(GL_COLOR_BUFFER_BIT); + glScissor(0, trueHeight-borderHeight, width, borderHeight); + glClear(GL_COLOR_BUFFER_BIT); + glDisable(GL_SCISSOR_TEST); glViewport(0, (trueHeight - height) / 2, width, height); } -//========================================================================== -// -// Draws a texture -// -//========================================================================== - -void FGLRenderer::DrawTexture(FTexture *img, DrawParms &parms) -{ - double xscale = parms.destwidth / parms.texwidth; - double yscale = parms.destheight / parms.texheight; - double x = parms.x - parms.left * xscale; - double y = parms.y - parms.top * yscale; - double w = parms.destwidth; - double h = parms.destheight; - float u1, v1, u2, v2; - int light = 255; - - FMaterial * gltex = FMaterial::ValidateTexture(img, false); - - if (parms.colorOverlay && (parms.colorOverlay & 0xffffff) == 0) - { - // Right now there's only black. Should be implemented properly later - light = 255 - APART(parms.colorOverlay); - parms.colorOverlay = 0; - } - - gl_SetRenderStyle(parms.style, !parms.masked, false); - if (!img->bHasCanvas) - { - int translation = 0; - if (!parms.alphaChannel) - { - if (parms.remap != NULL && !parms.remap->Inactive) - { - GLTranslationPalette * pal = static_cast(parms.remap->GetNative()); - if (pal) translation = -pal->GetIndex(); - } - } - gl_RenderState.SetMaterial(gltex, CLAMP_XY_NOMIP, translation, -1, !!(parms.style.Flags & STYLEF_RedIsAlpha)); - - u1 = gltex->GetUL(); - v1 = gltex->GetVT(); - u2 = gltex->GetUR(); - v2 = gltex->GetVB(); - - } - else - { - gl_RenderState.SetMaterial(gltex, CLAMP_XY_NOMIP, 0, -1, false); - u1 = 0.f; - v1 = 1.f; - u2 = 1.f; - v2 = 0.f; - gl_RenderState.SetTextureMode(TM_OPAQUE); - } - - if (parms.flipX) - { - float temp = u1; - u1 = u2; - u2 = temp; - } - - - if (parms.windowleft > 0 || parms.windowright < parms.texwidth) - { - double wi = MIN(parms.windowright, parms.texwidth); - x += parms.windowleft * xscale; - w -= (parms.texwidth - wi + parms.windowleft) * xscale; - - u1 = float(u1 + parms.windowleft / parms.texwidth); - u2 = float(u2 - (parms.texwidth - wi) / parms.texwidth); - } - - PalEntry color; - if (parms.style.Flags & STYLEF_ColorIsFixed) - { - color = parms.fillcolor; - } - else - { - color = PalEntry(light, light, light); - } - color.a = (BYTE)(parms.Alpha * 255); - - // scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates - int btm = (SCREENHEIGHT - screen->GetHeight()) / 2; - btm = SCREENHEIGHT - btm; - - glEnable(GL_SCISSOR_TEST); - int space = (static_cast(screen)->GetTrueHeight()-screen->GetHeight())/2; - glScissor(parms.lclip, btm - parms.dclip + space, parms.rclip - parms.lclip, parms.dclip - parms.uclip); - - gl_RenderState.SetColor(color); - gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); - gl_RenderState.Apply(); - - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(x, y, 0, u1, v1); ptr++; - ptr->Set(x, y + h, 0, u1, v2); ptr++; - ptr->Set(x + w, y, 0, u2, v1); ptr++; - ptr->Set(x + w, y + h, 0, u2, v2); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - - if (parms.colorOverlay) - { - gl_RenderState.SetTextureMode(TM_MASK); - gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl_RenderState.BlendEquation(GL_FUNC_ADD); - gl_RenderState.SetColor(PalEntry(parms.colorOverlay)); - gl_RenderState.Apply(); - - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(x, y, 0, u1, v1); ptr++; - ptr->Set(x, y + h, 0, u1, v2); ptr++; - ptr->Set(x + w, y, 0, u2, v1); ptr++; - ptr->Set(x + w, y + h, 0, u2, v2); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } - - glScissor(0, 0, screen->GetWidth(), screen->GetHeight()); - glDisable(GL_SCISSOR_TEST); - gl_RenderState.SetTextureMode(TM_MODULATE); - gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl_RenderState.BlendEquation(GL_FUNC_ADD); -} - -//========================================================================== -// -// -// -//========================================================================== -void FGLRenderer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color) -{ - PalEntry p = color? (PalEntry)color : GPalette.BaseColors[palcolor]; - gl_RenderState.EnableTexture(false); - gl_RenderState.SetColorAlpha(p, 1.f); - gl_RenderState.Apply(); - - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(x1, y1, 0, 0, 0); ptr++; - ptr->Set(x2, y2, 0, 0, 0); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_LINES); - - gl_RenderState.EnableTexture(true); -} - -//========================================================================== -// -// -// -//========================================================================== -void FGLRenderer::DrawPixel(int x1, int y1, int palcolor, uint32 color) -{ - PalEntry p = color? (PalEntry)color : GPalette.BaseColors[palcolor]; - gl_RenderState.EnableTexture(false); - gl_RenderState.SetColorAlpha(p, 1.f); - gl_RenderState.Apply(); - - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(x1, y1, 0, 0, 0); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_POINTS); - - gl_RenderState.EnableTexture(true); -} - -//=========================================================================== -// -// -// -//=========================================================================== - -void FGLRenderer::Dim(PalEntry color, float damount, int x1, int y1, int w, int h) -{ - gl_RenderState.EnableTexture(false); - gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl_RenderState.AlphaFunc(GL_GREATER,0); - gl_RenderState.SetColorAlpha(color, damount); - gl_RenderState.Apply(); - - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(x1, y1, 0, 0, 0); ptr++; - ptr->Set(x1, y1+h, 0, 0, 0); ptr++; - ptr->Set(x1+w, y1+h, 0, 0, 0); ptr++; - ptr->Set(x1+w, y1, 0, 0, 0); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); - - gl_RenderState.EnableTexture(true); -} - -//========================================================================== -// -// -// -//========================================================================== -void FGLRenderer::FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin) -{ - float fU1,fU2,fV1,fV2; - - FMaterial *gltexture=FMaterial::ValidateTexture(src, false); - - if (!gltexture) return; - - gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); - - // scaling is not used here. - if (!local_origin) - { - fU1 = float(left) / src->GetWidth(); - fV1 = float(top) / src->GetHeight(); - fU2 = float(right) / src->GetWidth(); - fV2 = float(bottom) / src->GetHeight(); - } - else - { - fU1 = 0; - fV1 = 0; - fU2 = float(right-left) / src->GetWidth(); - fV2 = float(bottom-top) / src->GetHeight(); - } - gl_RenderState.ResetColor(); - gl_RenderState.Apply(); - - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(left, top, 0, fU1, fV1); ptr++; - ptr->Set(left, bottom, 0, fU1, fV2); ptr++; - ptr->Set(right, top, 0, fU2, fV1); ptr++; - ptr->Set(right, bottom, 0, fU2, fV2); ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); -} - -//========================================================================== -// -// -// -//========================================================================== -void FGLRenderer::Clear(int left, int top, int right, int bottom, int palcolor, uint32 color) -{ - int rt; - int offY = 0; - PalEntry p = palcolor==-1 || color != 0? (PalEntry)color : GPalette.BaseColors[palcolor]; - int width = right-left; - int height= bottom-top; - - - rt = screen->GetHeight() - top; - - int space = (static_cast(screen)->GetTrueHeight()-screen->GetHeight())/2; // ugh... - rt += space; - /* - if (!m_windowed && (m_trueHeight != m_height)) - { - offY = (m_trueHeight - m_height) / 2; - rt += offY; - } - */ - - glEnable(GL_SCISSOR_TEST); - glScissor(left, rt - height, width, height); - - glClearColor(p.r/255.0f, p.g/255.0f, p.b/255.0f, 0.f); - glClear(GL_COLOR_BUFFER_BIT); - glClearColor(0.f, 0.f, 0.f, 0.f); - - glDisable(GL_SCISSOR_TEST); -} - -//========================================================================== -// -// D3DFB :: FillSimplePoly -// -// Here, "simple" means that a simple triangle fan can draw it. -// -//========================================================================== - -void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, - double originx, double originy, double scalex, double scaley, - DAngle rotation, FDynamicColormap *colormap, int lightlevel) -{ - if (npoints < 3) - { // This is no polygon. - return; - } - - FMaterial *gltexture = FMaterial::ValidateTexture(texture, false); - - if (gltexture == NULL) - { - return; - } - - FColormap cm; - cm = colormap; - - // We cannot use the software light mode here because it doesn't properly calculate the light for 2D rendering. - SBYTE savedlightmode = glset.lightmode; - if (glset.lightmode == 8) glset.lightmode = 0; - - gl_SetColor(lightlevel, 0, cm, 1.f); - - glset.lightmode = savedlightmode; - - gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); - - int i; - bool dorotate = rotation != 0; - - float cosrot = cos(rotation.Radians()); - float sinrot = sin(rotation.Radians()); - - //float yoffs = GatheringWipeScreen ? 0 : LBOffset; - float uscale = float(1.f / (texture->GetScaledWidth() * scalex)); - float vscale = float(1.f / (texture->GetScaledHeight() * scaley)); - if (gltexture->tex->bHasCanvas) - { - vscale = 0 - vscale; - } - float ox = float(originx); - float oy = float(originy); - - gl_RenderState.Apply(); - - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - for (i = 0; i < npoints; ++i) - { - float u = points[i].X - 0.5f - ox; - float v = points[i].Y - 0.5f - oy; - if (dorotate) - { - float t = u; - u = t * cosrot - v * sinrot; - v = v * cosrot + t * sinrot; - } - ptr->Set(points[i].X, points[i].Y, 0, u*uscale, v*vscale); - ptr++; - } - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); -} - diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 9caace177..8a00e6ce4 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -25,6 +25,7 @@ class FBlurShader; class FTonemapShader; class FLensShader; class FPresentShader; +class F2DDrawer; inline float DEG2RAD(float deg) { @@ -107,6 +108,7 @@ public: FFlatVertexBuffer *mVBO; FSkyVertexBuffer *mSkyVBO; FLightBuffer *mLights; + F2DDrawer *m2DDrawer; GL_IRECT mScreenViewport; GL_IRECT mOutputViewportLB; @@ -142,12 +144,6 @@ public: void Begin2D(); void ClearBorders(); - void DrawTexture(FTexture *img, DrawParms &parms); - void DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color); - void DrawPixel(int x1, int y1, int palcolor, uint32 color); - void Dim(PalEntry color, float damount, int x1, int y1, int w, int h); - void FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin); - void Clear(int left, int top, int right, int bottom, int palcolor, uint32 color); void ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector); void ProcessSprite(AActor *thing, sector_t *sector, bool thruportal); @@ -175,6 +171,9 @@ public: bool StartOffscreen(); void EndOffscreen(); + void StartSimplePolys(); + void FinishSimplePolys(); + void FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, DAngle rotation, FDynamicColormap *colormap, int lightlevel); diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 1b3a880b2..d5bb578e5 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -64,6 +64,7 @@ #include "gl/utility/gl_clock.h" #include "gl/utility/gl_templates.h" #include "gl/gl_functions.h" +#include "gl/renderer/gl_2ddrawer.h" IMPLEMENT_CLASS(OpenGLFrameBuffer) EXTERN_CVAR (Float, vid_brightness) @@ -386,7 +387,8 @@ bool OpenGLFrameBuffer::Begin2D(bool) void OpenGLFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) { - if (GLRenderer != NULL) GLRenderer->DrawTexture(img, parms); + if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr) + GLRenderer->m2DDrawer->AddTexture(img, parms); } //========================================================================== @@ -396,8 +398,8 @@ void OpenGLFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) //========================================================================== void OpenGLFrameBuffer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color) { - if (GLRenderer != NULL) - GLRenderer->DrawLine(x1, y1, x2, y2, palcolor, color); + if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr) + GLRenderer->m2DDrawer->AddLine(x1, y1, x2, y2, palcolor, color); } //========================================================================== @@ -407,8 +409,8 @@ void OpenGLFrameBuffer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, u //========================================================================== void OpenGLFrameBuffer::DrawPixel(int x1, int y1, int palcolor, uint32 color) { - if (GLRenderer != NULL) - GLRenderer->DrawPixel(x1, y1, palcolor, color); + if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr) + GLRenderer->m2DDrawer->AddPixel(x1, y1, palcolor, color); } //========================================================================== @@ -425,8 +427,8 @@ void OpenGLFrameBuffer::Dim(PalEntry) void OpenGLFrameBuffer::Dim(PalEntry color, float damount, int x1, int y1, int w, int h) { - if (GLRenderer != NULL) - GLRenderer->Dim(color, damount, x1, y1, w, h); + if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr) + GLRenderer->m2DDrawer->AddDim(color, damount, x1, y1, w, h); } //========================================================================== @@ -437,8 +439,8 @@ void OpenGLFrameBuffer::Dim(PalEntry color, float damount, int x1, int y1, int w void OpenGLFrameBuffer::FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin) { - if (GLRenderer != NULL) - GLRenderer->FlatFill(left, top, right, bottom, src, local_origin); + if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr) + GLRenderer->m2DDrawer->AddFlatFill(left, top, right, bottom, src, local_origin); } //========================================================================== @@ -448,8 +450,8 @@ void OpenGLFrameBuffer::FlatFill (int left, int top, int right, int bottom, FTex //========================================================================== void OpenGLFrameBuffer::Clear(int left, int top, int right, int bottom, int palcolor, uint32 color) { - if (GLRenderer != NULL) - GLRenderer->Clear(left, top, right, bottom, palcolor, color); + if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr) + GLRenderer->m2DDrawer->AddClear(left, top, right, bottom, palcolor, color); } //========================================================================== @@ -464,10 +466,9 @@ void OpenGLFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, int double originx, double originy, double scalex, double scaley, DAngle rotation, FDynamicColormap *colormap, int lightlevel) { - if (GLRenderer != NULL) + if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr && npoints >= 3) { - GLRenderer->FillSimplePoly(texture, points, npoints, originx, originy, scalex, scaley, - rotation, colormap, lightlevel); + GLRenderer->m2DDrawer->AddPoly(texture, points, npoints, originx, originy, scalex, scaley, rotation, colormap, lightlevel); } } diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 2978dd55d..bd03ca96e 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -61,6 +61,7 @@ #include "gl/textures/gl_samplers.h" #include "gl/utility/gl_templates.h" #include "gl/data/gl_vertexbuffer.h" +#include "gl/renderer/gl_2ddrawer.h" #ifndef _WIN32 struct POINT { @@ -187,6 +188,7 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) void OpenGLFrameBuffer::WipeEndScreen() { + GLRenderer->m2DDrawer->Flush(); wipeendscreen = new FHardwareTexture(Width, Height, true); wipeendscreen->CreateTexture(NULL, Width, Height, 0, false, 0); GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1); @@ -288,8 +290,8 @@ OpenGLFrameBuffer::Wiper::~Wiper() void OpenGLFrameBuffer::Wiper::MakeVBO(OpenGLFrameBuffer *fb) { - FFlatVertex make[4]; - FFlatVertex *ptr = make; + FSimpleVertex make[4]; + FSimpleVertex *ptr = make; float ur = fb->GetWidth() / FHardwareTexture::GetTexDimension(fb->GetWidth()); float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight()); @@ -380,8 +382,8 @@ OpenGLFrameBuffer::Wiper_Melt::Wiper_Melt() int OpenGLFrameBuffer::Wiper_Melt::MakeVBO(int ticks, OpenGLFrameBuffer *fb, bool &done) { - FFlatVertex *make = new FFlatVertex[321*4]; - FFlatVertex *ptr = make; + FSimpleVertex *make = new FSimpleVertex[321*4]; + FSimpleVertex *ptr = make; int dy; float ur = fb->GetWidth() / FHardwareTexture::GetTexDimension(fb->GetWidth()); From 9ab9548723e1c258cfa713799b9c6cf12ccc927d Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 7 Aug 2016 14:50:48 +0300 Subject: [PATCH 0774/1509] Additional fix for splitting of complex wall in compatibility renderer warp 2720 -200 -32 on Extreme Terror https://www.doomworld.com/idgames/levels/doom2/Ports/d-f/exterror --- src/gl/scene/gl_wall.h | 2 +- src/gl/scene/gl_walls.cpp | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index fdeb99ed0..674d7fffd 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -187,7 +187,7 @@ private: void RenderLightsCompat(int pass); void Put3DWall(lightlist_t * lightlist, bool translucent); - void SplitWallComplex(sector_t * frontsector, bool translucent, float maplightbottomleft, float maplightbottomright); + bool SplitWallComplex(sector_t * frontsector, bool translucent, float& maplightbottomleft, float& maplightbottomright); void SplitWall(sector_t * frontsector, bool translucent); void SetupLights(); diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index a688a036b..6f1f02d86 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -264,7 +264,7 @@ void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent) // //========================================================================== -void GLWall::SplitWallComplex(sector_t * frontsector, bool translucent, float maplightbottomleft, float maplightbottomright) +bool GLWall::SplitWallComplex(sector_t * frontsector, bool translucent, float& maplightbottomleft, float& maplightbottomright) { GLWall copyWall1, copyWall2; @@ -304,7 +304,7 @@ void GLWall::SplitWallComplex(sector_t * frontsector, bool translucent, float ma copyWall1.SplitWall(frontsector, translucent); copyWall2.SplitWall(frontsector, translucent); - return; + return true; } } @@ -345,9 +345,11 @@ void GLWall::SplitWallComplex(sector_t * frontsector, bool translucent, float ma copyWall1.SplitWall(frontsector, translucent); copyWall2.SplitWall(frontsector, translucent); - return; + return true; } } + + return false; } void GLWall::SplitWall(sector_t * frontsector, bool translucent) @@ -406,14 +408,14 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) // Use hardware clipping if this cannot be done cleanly. this->lightlist = &lightlist; PutWall(translucent); - } - else - { - // crappy fallback if no clip planes available - SplitWallComplex(frontsector, translucent, maplightbottomleft, maplightbottomright); - } - goto out; + goto out; + } + // crappy fallback if no clip planes available + else if (SplitWallComplex(frontsector, translucent, maplightbottomleft, maplightbottomright)) + { + goto out; + } } // 3D floor is completely within this light From 2ac91f0c5a8d7076c45ad050017fa3d4769f1a40 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 8 Aug 2016 01:11:43 +0200 Subject: [PATCH 0775/1509] Fix Nvidia driver ignoring wglSwapIntervalEXT --- src/gl/system/gl_framebuffer.cpp | 5 ++++- src/win32/win32gliface.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index d5bb578e5..151683d56 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -94,6 +94,10 @@ CUSTOM_CVAR(Int, vid_hwgamma, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITC OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : Super(hMonitor, width, height, bits, refreshHz, fullscreen) { + // SetVSync needs to be at the very top to workaround a bug in Nvidia's OpenGL driver. + // If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed! + SetVSync(vid_vsync); + GLRenderer = new FGLRenderer(this); memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256); UpdatePalette (); @@ -107,7 +111,6 @@ OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int needsetgamma = true; swapped = false; Accel2D = true; - SetVSync(vid_vsync); } OpenGLFrameBuffer::~OpenGLFrameBuffer() diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 2e61ae3a6..4f8c4d49b 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -1141,7 +1141,7 @@ void Win32GLFrameBuffer::ReleaseResources () void Win32GLFrameBuffer::SetVSync (bool vsync) { - if (vsyncfunc != NULL) vsyncfunc(vsync); + if (vsyncfunc != NULL) vsyncfunc(vsync ? 1 : 0); } void Win32GLFrameBuffer::SwapBuffers() From 9c9edbffdb0c7a5460433683e5bde0700c846d8a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 8 Aug 2016 12:55:09 +0200 Subject: [PATCH 0776/1509] - on older ATI drivers where the clip planes are broken, only disable the clip planes themselves, but not OpenGL 3.x so that dynamic lights still work as intended. - only disable clip planes on Windows, but not on Linux or macOS. - If a driver reports full OpenGL 4.5 support, assume that all features are working properly. --- src/gl/renderer/gl_renderstate.cpp | 4 ++-- src/gl/renderer/gl_renderstate.h | 4 ++-- src/gl/scene/gl_sprite.cpp | 2 +- src/gl/scene/gl_walls.cpp | 2 +- src/gl/shaders/gl_shader.cpp | 6 ++++++ src/gl/system/gl_interface.cpp | 17 +++++++++++++---- src/gl/system/gl_interface.h | 3 ++- 7 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 865053b41..84badd07b 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -344,12 +344,12 @@ void FRenderState::SetClipHeight(float height, float direction) mClipHeightDirection = direction; #if 1 // This still doesn't work... :( - if (gl.glslversion < 1.3f) return; + if (gl.flags & RFL_NO_CLIP_PLANES) return; #endif if (direction != 0.f) { /* - if (gl.glslversion < 1.3f) + if (gl.flags & RFL_NO_CLIP_PLANES) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 2ad611ab2..12671c2a6 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -237,7 +237,7 @@ public: void EnableSplit(bool on) { - if (gl.glslversion >= 1.3f) + if (!(gl.flags & RFL_NO_CLIP_PLANES)) { mSplitEnabled = on; if (on) @@ -260,7 +260,7 @@ public: void EnableClipLine(bool on) { - if (gl.glslversion >= 1.3f) + if (!(gl.flags & RFL_NO_CLIP_PLANES)) { mClipLineEnabled = on; if (on) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 98e0fb8d5..76796adf9 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -972,7 +972,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) if (thing->Sector->e->XFloor.lightlist.Size() != 0 && gl_fixedcolormap == CM_DEFAULT && !fullbright && RenderStyle.BlendOp != STYLEOP_Shadow && RenderStyle.BlendOp != STYLEOP_RevSub) { - if (gl.glslversion < 1.3) // on old hardware we are rather limited... + if (gl.flags & RFL_NO_CLIP_PLANES) // on old hardware we are rather limited... { lightlist = NULL; if (!drawWithXYBillboard && !modelframe) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 6f1f02d86..d8cef9771 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -403,7 +403,7 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) (maplightbottomleftzbottom[1]) || (maplightbottomleft > zbottom[0] && maplightbottomright < zbottom[1])) { - if (gl.glslversion >= 1.3f) + if (!(gl.flags & RFL_NO_CLIP_PLANES)) { // Use hardware clipping if this cannot be done cleanly. this->lightlist = &lightlist; diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index f2b4c7ebd..cce8c6563 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -169,6 +169,12 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * FShaderProgram::PatchVertShader(vp_comb); FShaderProgram::PatchFragShader(fp_comb); } + else if (gl.flags & RFL_NO_CLIP_PLANES) + { + // On ATI's GL3 drivers we have to disable gl_ClipDistance because it's hopelessly broken. + // This will cause some glitches and regressions but is the only way to avoid total display garbage. + vp_comb.Substitute("gl_ClipDistance", "//"); + } hVertProg = glCreateShader(GL_VERTEX_SHADER); hFragProg = glCreateShader(GL_FRAGMENT_SHADER); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 6b1105ee4..6176a2be9 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -192,6 +192,7 @@ void gl_LoadExtensions() gl.version = 2.11f; gl.glslversion = 0; gl.lightmethod = LM_SOFTWARE; + gl.flags |= RFL_NO_CLIP_PLANES; } else if (gl.version < 3.0f) { @@ -200,17 +201,18 @@ void gl_LoadExtensions() if (!CheckExtension("GL_EXT_packed_float")) gl.flags |= RFL_NO_RGBA16F; if (!CheckExtension("GL_EXT_packed_depth_stencil")) gl.flags |= RFL_NO_DEPTHSTENCIL; + gl.flags |= RFL_NO_CLIP_PLANES; } else if (gl.version < 4.f) { +#ifdef _WIN32 if (strstr(gl.vendorstring, "ATI Tech")) { - gl.version = 2.11f; - gl.glslversion = 1.21f; - gl.lightmethod = LM_SOFTWARE; // do not use uniform buffers with the fallback shader, it may cause problems. + gl.flags |= RFL_NO_CLIP_PLANES; // gl_ClipDistance is horribly broken on ATI GL3 drivers for Windows. } +#endif } - else + else if (gl.version < 4.5f) { // don't use GL 4.x features when running in GL 3 emulation mode. if (CheckExtension("GL_ARB_buffer_storage")) @@ -234,6 +236,13 @@ void gl_LoadExtensions() gl.version = 3.3f; } } + else + { + // Assume that everything works without problems on GL 4.5 drivers where these things are core features. + gl.flags |= RFL_SHADER_STORAGE_BUFFER | RFL_BUFFER_STORAGE; + gl.lightmethod = LM_DIRECT; + gl.buffermethod = BM_PERSISTENT; + } const char *lm = Args->CheckValue("-lightmethod"); if (lm != NULL) diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index d43252ebc..fbe4e09c8 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -22,7 +22,8 @@ enum RenderFlags RFL_SAMPLER_OBJECTS = 16, RFL_NO_RGBA16F = 32, - RFL_NO_DEPTHSTENCIL = 64 + RFL_NO_DEPTHSTENCIL = 64, + RFL_NO_CLIP_PLANES = 128 }; enum TexMode From 8daaf61160c526817b49c0acbaa660243f400c54 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 8 Aug 2016 14:24:48 +0200 Subject: [PATCH 0777/1509] - predefine the vertex data for the blend overlay which will never change throughout the lifetime of the GLRenderer object. --- src/gl/data/gl_vertexbuffer.cpp | 20 +++++++++++++++++--- src/gl/data/gl_vertexbuffer.h | 2 +- src/gl/renderer/gl_renderer.cpp | 4 ++-- src/gl/renderer/gl_renderer.h | 2 +- src/gl/scene/gl_scene.cpp | 12 ++---------- src/gl/system/gl_framebuffer.cpp | 2 +- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 1d69c2547..4cb0efd6a 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -109,7 +109,7 @@ void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count) // //========================================================================== -FFlatVertexBuffer::FFlatVertexBuffer() +FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) : FVertexBuffer(gl.buffermethod == BM_PERSISTENT) { if (gl.buffermethod == BM_PERSISTENT) @@ -125,7 +125,22 @@ FFlatVertexBuffer::FFlatVertexBuffer() vbo_shadowdata.Reserve(BUFFER_SIZE); map = new FFlatVertex[BUFFER_SIZE]; } - mNumReserved = mIndex = mCurIndex = 0; + mIndex = mCurIndex = 0; + mNumReserved = 8; + vbo_shadowdata.Resize(mNumReserved); + + // the first quad is reserved for handling coordinates through uniforms. + vbo_shadowdata[0].Set(1, 0, 0, 0, 0); + vbo_shadowdata[1].Set(2, 0, 0, 0, 0); + vbo_shadowdata[2].Set(3, 0, 0, 0, 0); + vbo_shadowdata[3].Set(4, 0, 0, 0, 0); + + // and the second one for the fullscreen quad used for blend overlays. + vbo_shadowdata[4].Set(0, 0, 0, 0, 0); + vbo_shadowdata[5].Set(0, (float)height, 0, 0, 0); + vbo_shadowdata[6].Set((float)width, 0, 0, 0, 0); + vbo_shadowdata[7].Set((float)width, (float)height, 0, 0, 0); + } FFlatVertexBuffer::~FFlatVertexBuffer() @@ -350,7 +365,6 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) void FFlatVertexBuffer::CreateVBO() { - vbo_shadowdata.Resize(mNumReserved); CreateFlatVBO(); mCurIndex = mIndex = vbo_shadowdata.Size(); memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index ce598965f..31251653d 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -84,7 +84,7 @@ class FFlatVertexBuffer : public FVertexBuffer public: TArray vbo_shadowdata; // this is kept around for updating the actual (non-readable) buffer and as stand-in for pre GL 4.x - FFlatVertexBuffer(); + FFlatVertexBuffer(int width, int height); ~FFlatVertexBuffer(); void BindVBO(); diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 2716c6a2c..b00396e21 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -113,7 +113,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) void gl_LoadModels(); void gl_FlushModels(); -void FGLRenderer::Initialize() +void FGLRenderer::Initialize(int width, int height) { mBuffers = new FGLRenderBuffers(); mBloomExtractShader = new FBloomExtractShader(); @@ -137,7 +137,7 @@ void FGLRenderer::Initialize() glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch); mirrortexture = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/mirror.png"), FTexture::TEX_MiscPatch); - mVBO = new FFlatVertexBuffer; + mVBO = new FFlatVertexBuffer(width, height); mSkyVBO = new FSkyVertexBuffer; if (gl.lightmethod != LM_SOFTWARE) mLights = new FLightBuffer(); else mLights = NULL; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 8a00e6ce4..0fe91dae2 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -129,7 +129,7 @@ public: void SetViewAngle(DAngle viewangle); void SetupView(float viewx, float viewy, float viewz, DAngle viewangle, bool mirror, bool planemirror); - void Initialize(); + void Initialize(int width, int height); void CreateScene(); void RenderMultipassStuff(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 16bb6cd34..44118087d 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -525,16 +525,8 @@ void gl_FillScreen() gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(0, 0, 0, 0, 0); - ptr++; - ptr->Set(0, (float)SCREENHEIGHT, 0, 0, 0); - ptr++; - ptr->Set((float)SCREENWIDTH, 0, 0, 0, 0); - ptr++; - ptr->Set((float)SCREENWIDTH, (float)SCREENHEIGHT, 0, 0, 0); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + // The fullscreen quad is stored at index 4 in the main vertex buffer. + glDrawArrays(GL_TRIANGLE_STRIP, 4, 4); } //========================================================================== diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 151683d56..495df07e8 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -164,7 +164,7 @@ void OpenGLFrameBuffer::InitializeState() //int h = GetHeight(); //glViewport(0, (trueH - h)/2, GetWidth(), GetHeight()); - GLRenderer->Initialize(); + GLRenderer->Initialize(GetWidth(), GetHeight()); GLRenderer->SetOutputViewport(nullptr); Begin2D(false); } From 675822004de6c698576cc2724b520673ca26d354 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 8 Aug 2016 16:06:02 +0200 Subject: [PATCH 0778/1509] - use static buffer data and a uniform to handle the texture positioning of the present shader. That's again one less write access to the buffer. The uniform method was chosen because this way a buffer update can be completely avoided, and setting a single uniform is a lot cheaper and simpler to handle. --- src/gl/data/gl_vertexbuffer.cpp | 8 +++++++- src/gl/renderer/gl_postprocess.cpp | 12 ++++-------- src/gl/renderer/gl_renderer.h | 2 +- src/gl/shaders/gl_presentshader.cpp | 3 ++- src/gl/shaders/gl_presentshader.h | 1 + src/gl/shaders/gl_shader.h | 11 +++++++++++ wadsrc/static/shaders/glsl/screenquadscale.vp | 11 +++++++++++ 7 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 wadsrc/static/shaders/glsl/screenquadscale.vp diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 4cb0efd6a..8e27c34fe 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -126,7 +126,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) map = new FFlatVertex[BUFFER_SIZE]; } mIndex = mCurIndex = 0; - mNumReserved = 8; + mNumReserved = 12; vbo_shadowdata.Resize(mNumReserved); // the first quad is reserved for handling coordinates through uniforms. @@ -141,6 +141,12 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) vbo_shadowdata[6].Set((float)width, 0, 0, 0, 0); vbo_shadowdata[7].Set((float)width, (float)height, 0, 0, 0); + // and this is for the postprocessing copy operation + vbo_shadowdata[8].Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); + vbo_shadowdata[9].Set(-1.0f, 1.0f, 0, 0.0f, 1.f); + vbo_shadowdata[10].Set(1.0f, -1.0f, 0, 1.f, 0.0f); + vbo_shadowdata[11].Set(1.0f, 1.0f, 0, 1.f, 1.f); + } FFlatVertexBuffer::~FFlatVertexBuffer() diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 79bd31860..dd4cc71aa 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -108,16 +108,11 @@ EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) -void FGLRenderer::RenderScreenQuad(float maxU, float maxV) +void FGLRenderer::RenderScreenQuad() { - FFlatVertex *ptr = mVBO->GetBuffer(); mVBO->BindVBO(); gl_RenderState.ResetVertexBuffer(); - ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; - ptr->Set(-1.0f, 1.0f, 0, 0.0f, maxV); ptr++; - ptr->Set(1.0f, -1.0f, 0, maxU, 0.0f); ptr++; - ptr->Set(1.0f, 1.0f, 0, maxU, maxV); ptr++; - mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + glDrawArrays(GL_TRIANGLE_STRIP, 8, 4); } //----------------------------------------------------------------------------- @@ -357,9 +352,10 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) mPresentShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); } + mPresentShader->Scale.Set(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight()); mBuffers->BindCurrentTexture(0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - RenderScreenQuad(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight()); + RenderScreenQuad(); } } diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 0fe91dae2..1a8883b3f 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -153,7 +153,7 @@ public: unsigned char *GetTextureBuffer(FTexture *tex, int &w, int &h); void SetupLevel(); - void RenderScreenQuad(float maxU = 1.0f, float maxV = 1.0f); + void RenderScreenQuad(); void SetFixedColormap (player_t *player); void WriteSavePic (player_t *player, FILE *file, int width, int height); void EndDrawScene(sector_t * viewsector); diff --git a/src/gl/shaders/gl_presentshader.cpp b/src/gl/shaders/gl_presentshader.cpp index 9998fda36..e40aa7a2c 100644 --- a/src/gl/shaders/gl_presentshader.cpp +++ b/src/gl/shaders/gl_presentshader.cpp @@ -53,7 +53,7 @@ void FPresentShader::Bind() { if (!mShader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquadscale.vp", "", 330); mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/present.fp", "", 330); mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/present"); @@ -63,6 +63,7 @@ void FPresentShader::Bind() Gamma.Init(mShader, "Gamma"); Contrast.Init(mShader, "Contrast"); Brightness.Init(mShader, "Brightness"); + Scale.Init(mShader, "UVScale"); } mShader.Bind(); } diff --git a/src/gl/shaders/gl_presentshader.h b/src/gl/shaders/gl_presentshader.h index 6bec79625..513af41cc 100644 --- a/src/gl/shaders/gl_presentshader.h +++ b/src/gl/shaders/gl_presentshader.h @@ -12,6 +12,7 @@ public: FBufferedUniform1f Gamma; FBufferedUniform1f Contrast; FBufferedUniform1f Brightness; + FBufferedUniform2f Scale; private: FShaderProgram mShader; diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index ca534c31d..a0b01d20d 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -123,6 +123,17 @@ public: glUniform2fv(mIndex, 1, newvalue); } } + + void Set(float f1, float f2) + { + if (mBuffer[0] != f1 || mBuffer[1] != f2) + { + mBuffer[0] = f1; + mBuffer[1] = f2; + glUniform2fv(mIndex, 1, mBuffer); + } + } + }; class FBufferedUniform4f diff --git a/wadsrc/static/shaders/glsl/screenquadscale.vp b/wadsrc/static/shaders/glsl/screenquadscale.vp new file mode 100644 index 000000000..2d7f505b4 --- /dev/null +++ b/wadsrc/static/shaders/glsl/screenquadscale.vp @@ -0,0 +1,11 @@ + +in vec4 PositionInProjection; +in vec2 UV; +uniform vec2 UVScale; +out vec2 TexCoord; + +void main() +{ + gl_Position = PositionInProjection; + TexCoord = UV * UVScale; +} From e5f88a9883adfe5316458e7db81c0f252ed14f26 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 8 Aug 2016 16:18:07 +0200 Subject: [PATCH 0779/1509] - fixed: The textured automap was not using correct light levels. In order for the externally passed vertex attribute to work the buffer's color attrib array needs to be disabled for these. --- src/gl/data/gl_vertexbuffer.cpp | 27 +++++++++++++++++++++++++++ src/gl/data/gl_vertexbuffer.h | 1 + src/gl/renderer/gl_2ddrawer.cpp | 13 +++++++++++++ 3 files changed, 41 insertions(+) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 8e27c34fe..2faae2990 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -96,6 +96,33 @@ void FSimpleVertexBuffer::BindVBO() } } +void FSimpleVertexBuffer::EnableColorArray(bool on) +{ + if (on) + { + if (gl.glslversion > 0) + { + glEnableVertexAttribArray(VATTR_COLOR); + } + else + { + glEnableClientState(GL_COLOR_ARRAY); + } + } + else + { + if (gl.glslversion > 0) + { + glDisableVertexAttribArray(VATTR_COLOR); + } + else + { + glDisableClientState(GL_COLOR_ARRAY); + } + } +} + + void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count) { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 31251653d..4d2252fe0 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -67,6 +67,7 @@ public: } void BindVBO(); void set(FSimpleVertex *verts, int count); + void EnableColorArray(bool on); }; class FFlatVertexBuffer : public FVertexBuffer diff --git a/src/gl/renderer/gl_2ddrawer.cpp b/src/gl/renderer/gl_2ddrawer.cpp index 75f76bbe6..67cb5f2f4 100644 --- a/src/gl/renderer/gl_2ddrawer.cpp +++ b/src/gl/renderer/gl_2ddrawer.cpp @@ -384,6 +384,8 @@ void F2DDrawer::AddPixel(int x1, int y1, int palcolor, uint32 color) void F2DDrawer::Flush() { + F2DDrawer::EDrawType lasttype = DrawTypeTexture; + if (mData.Size() == 0) return; SBYTE savedlightmode = glset.lightmode; // lightmode is only relevant for automap subsectors, @@ -394,6 +396,17 @@ void F2DDrawer::Flush() for (unsigned i = 0; i < mData.Size();) { DataGeneric *dg = (DataGeneric *)&mData[i]; + // DrawTypePoly may not use the color part of the vertex buffer because it needs to use gl_SetColor to produce proper output. + if (lasttype == DrawTypePoly && dg->mType != DrawTypePoly) + { + EnableColorArray(true); + } + else if (lasttype != DrawTypePoly && dg->mType == DrawTypePoly) + { + EnableColorArray(false); + } + lasttype = dg->mType; + switch (dg->mType) { default: From 56a60ebe8587d27cc000c449b0b3590a0f9f036b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 8 Aug 2016 20:47:54 +0200 Subject: [PATCH 0780/1509] - restored a line that got accidentally deleted. --- src/gl/data/gl_vertexbuffer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 2faae2990..77623b3ca 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -398,6 +398,7 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) void FFlatVertexBuffer::CreateVBO() { + vbo_shadowdata.Reserve(mNumReserved); CreateFlatVBO(); mCurIndex = mIndex = vbo_shadowdata.Size(); memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); From 3c8719f9458d4f210f27e827d89ad86234717232 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 8 Aug 2016 22:35:26 +0200 Subject: [PATCH 0781/1509] Fix buffer overflow in FTexture::GenerateBgraMipmaps --- src/textures/texture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 7dfe04b23..05574e9da 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -482,7 +482,7 @@ void FTexture::GenerateBgraMipmaps() if (a < 0) a = h - 1; if (a == h) a = 0; if (b < 0) b = w - 1; - if (b == h) b = 0; + if (b == w) b = 0; c = c + dest[a + b * h]; } } From abef073ea499f85337ad688e61ac8c65c3a689ac Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 9 Aug 2016 01:17:45 +0200 Subject: [PATCH 0782/1509] Implemented sloped planes for true color mode --- src/r_draw_rgba.cpp | 144 +++++++++++++++++++++++++++++++++++++++----- src/r_draw_rgba.h | 3 + src/r_plane.cpp | 25 +------- 3 files changed, 134 insertions(+), 38 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 7a071e1d4..69ebfeb84 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -2191,23 +2191,44 @@ public: class DrawTiltedSpanRGBACommand : public DrawerCommand { - int _y; int _x1; int _x2; + int _y; BYTE * RESTRICT _destorg; fixed_t _light; ShadeConstants _shade_constants; - const BYTE * RESTRICT _source; + FVector3 _plane_sz; + FVector3 _plane_su; + FVector3 _plane_sv; + bool _plane_shade; + int _planeshade; + float _planelightfloat; + fixed_t _pviewx; + fixed_t _pviewy; + int _xbits; + int _ybits; + const uint32_t * RESTRICT _source; public: - DrawTiltedSpanRGBACommand(int y, int x1, int x2) + DrawTiltedSpanRGBACommand(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) { - _y = y; _x1 = x1; _x2 = x2; - + _y = y; _destorg = dc_destorg; - _source = ds_source; + _light = ds_light; + _shade_constants = ds_shade_constants; + _plane_sz = plane_sz; + _plane_su = plane_su; + _plane_sv = plane_sv; + _plane_shade = plane_shade; + _planeshade = planeshade; + _planelightfloat = planelightfloat; + _pviewx = pviewx; + _pviewy = pviewy; + _source = (const uint32_t*)ds_source; + _xbits = ds_xbits; + _ybits = ds_ybits; } void Execute(DrawerThread *thread) override @@ -2215,20 +2236,103 @@ public: if (thread->line_skipped_by_thread(_y)) return; - int y = _y; - int x1 = _x1; - int x2 = _x2; + //#define SPANSIZE 32 + //#define INVSPAN 0.03125f + //#define SPANSIZE 8 + //#define INVSPAN 0.125f + #define SPANSIZE 16 + #define INVSPAN 0.0625f - // Slopes are broken currently in master. - // Until R_DrawTiltedPlane is fixed we are just going to fill with a solid color. + int source_width = 1 << _xbits; + int source_height = 1 << _ybits; - uint32_t *source = (uint32_t*)_source; - uint32_t *dest = ylookup[y] + x1 + (uint32_t*)_destorg; + uint32_t *dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; + int count = _x2 - _x1 + 1; - int count = x2 - x1 + 1; + // Depth (Z) change across the span + double iz = _plane_sz[2] + _plane_sz[1] * (centery - _y) + _plane_sz[0] * (_x1 - centerx); + + // Light change across the span + fixed_t lightstart = _light; + fixed_t lightend = lightstart; + if (_plane_shade) + { + double vis_start = iz * _planelightfloat; + double vis_end = (iz + _plane_sz[0] * count) * _planelightfloat; + + lightstart = LIGHTSCALE(vis_start, _planeshade); + lightend = LIGHTSCALE(vis_end, _planeshade); + } + fixed_t light = lightstart; + fixed_t steplight = (lightend - lightstart) / count; + + // Texture coordinates + double uz = _plane_su[2] + _plane_su[1] * (centery - _y) + _plane_su[0] * (_x1 - centerx); + double vz = _plane_sv[2] + _plane_sv[1] * (centery - _y) + _plane_sv[0] * (_x1 - centerx); + double startz = 1.f / iz; + double startu = uz*startz; + double startv = vz*startz; + double izstep = _plane_sz[0] * SPANSIZE; + double uzstep = _plane_su[0] * SPANSIZE; + double vzstep = _plane_sv[0] * SPANSIZE; + + // Linear interpolate in sizes of SPANSIZE to increase speed + while (count >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + double endz = 1.f / iz; + double endu = uz*endz; + double endv = vz*endz; + uint32_t stepu = (uint32_t)(SQWORD((endu - startu) * INVSPAN)); + uint32_t stepv = (uint32_t)(SQWORD((endv - startv) * INVSPAN)); + uint32_t u = (uint32_t)(SQWORD(startu) + _pviewx); + uint32_t v = (uint32_t)(SQWORD(startv) + _pviewy); + + for (int i = 0; i < SPANSIZE; i++) + { + uint32_t sx = ((u >> 16) * source_width) >> 16; + uint32_t sy = ((v >> 16) * source_height) >> 16; + uint32_t fg = _source[sy + sx * source_height]; + + if (_shade_constants.simple_shade) + *(dest++) = LightBgra::shade_bgra_simple(fg, LightBgra::calc_light_multiplier(light)); + else + *(dest++) = LightBgra::shade_bgra(fg, LightBgra::calc_light_multiplier(light), _shade_constants); + + u += stepu; + v += stepv; + light += steplight; + } + startu = endu; + startv = endv; + count -= SPANSIZE; + } + + // The last few pixels at the end while (count > 0) { - *(dest++) = source[0]; + double endz = 1.f / iz; + startu = uz*endz; + startv = vz*endz; + uint32_t u = (uint32_t)(SQWORD(startu) + _pviewx); + uint32_t v = (uint32_t)(SQWORD(startv) + _pviewy); + + uint32_t sx = ((u >> 16) * source_width) >> 16; + uint32_t sy = ((v >> 16) * source_height) >> 16; + uint32_t fg = _source[sy + sx * source_height]; + + if (_shade_constants.simple_shade) + *(dest++) = LightBgra::shade_bgra_simple(fg, LightBgra::calc_light_multiplier(light)); + else + *(dest++) = LightBgra::shade_bgra(fg, LightBgra::calc_light_multiplier(light), _shade_constants); + + iz += _plane_sz[0]; + uz += _plane_su[0]; + vz += _plane_sv[0]; + light += steplight; count--; } } @@ -2633,6 +2737,16 @@ void R_FillSpan_rgba() DrawerCommandQueue::QueueCommand(); } +void R_DrawTiltedSpan_rgba(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) +{ + DrawerCommandQueue::QueueCommand(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); +} + +void R_DrawColoredSpan_rgba(int y, int x1, int x2) +{ + DrawerCommandQueue::QueueCommand(y, x1, x2); +} + static ShadeConstants slab_rgba_shade_constants; static const BYTE *slab_rgba_colormap; static fixed_t slab_rgba_light; diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index c976602f6..083258bf0 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -94,6 +94,9 @@ void R_DrawSpanAddClamp_rgba(); void R_DrawSpanMaskedAddClamp_rgba(); void R_FillSpan_rgba(); +void R_DrawTiltedSpan_rgba(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy); +void R_DrawColoredSpan_rgba(int y, int x1, int x2); + void R_SetupDrawSlab_rgba(FColormap *base_colormap, float light, int shade); void R_DrawSlab_rgba(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index c751fc5dc..706d6fad7 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -480,23 +480,7 @@ void R_MapTiltedPlane_C (int y, int x1) void R_MapTiltedPlane_rgba (int y, int x1) { - int x2 = spanend[y]; - - // Slopes are broken currently in master. - // Until R_DrawTiltedPlane is fixed we are just going to fill with a solid color. - - uint32_t *source = (uint32_t*)ds_source; - int source_width = 1 << ds_xbits; - int source_height = 1 << ds_ybits; - - uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg; - - int count = x2 - x1 + 1; - while (count > 0) - { - *(dest++) = source[0]; - count--; - } + R_DrawTiltedSpan_rgba(y, x1, spanend[y], plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); } //========================================================================== @@ -512,12 +496,7 @@ void R_MapColoredPlane_C (int y, int x1) void R_MapColoredPlane_rgba(int y, int x1) { - uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg; - int count = (spanend[y] - x1 + 1); - uint32_t light = LightBgra::calc_light_multiplier(ds_light); - uint32_t color = LightBgra::shade_pal_index_simple(ds_color, light); - for (int i = 0; i < count; i++) - dest[i] = color; + R_DrawColoredSpan_rgba(y, x1, spanend[y]); } //========================================================================== From 0e5a3ebe50354c222586cba00ae0bde5360581db Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 10 Aug 2016 00:35:42 +0200 Subject: [PATCH 0783/1509] - fixed bad function call in vertex buffer init code. --- src/gl/data/gl_vertexbuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 77623b3ca..637de85aa 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -398,7 +398,7 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) void FFlatVertexBuffer::CreateVBO() { - vbo_shadowdata.Reserve(mNumReserved); + vbo_shadowdata.Resize(mNumReserved); CreateFlatVBO(); mCurIndex = mIndex = vbo_shadowdata.Size(); memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); From 0fdd80eae719545255d487bbe5880ad11fe418d2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 10 Aug 2016 16:32:31 +0200 Subject: [PATCH 0784/1509] - removed debug Printf. --- src/gl/system/gl_wipe.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index bd03ca96e..59adc7e9e 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -341,7 +341,6 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); float a = clamp(Clock / 32.f, 0.f, 1.f); - Printf("%f\n", a); gl_RenderState.SetColorAlpha(0xffffff, a); gl_RenderState.Apply(); fb->wipeendscreen->Bind(0, 0, false); From 353a464f5b6dc98f9a9e3627907805f4c70127fd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 13 Aug 2016 22:15:00 +0200 Subject: [PATCH 0785/1509] - fixed: The 2D texture drawer did not reset the render state's color so any previously set desaturation would persist. --- src/gl/renderer/gl_2ddrawer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/renderer/gl_2ddrawer.cpp b/src/gl/renderer/gl_2ddrawer.cpp index 67cb5f2f4..7c896d62c 100644 --- a/src/gl/renderer/gl_2ddrawer.cpp +++ b/src/gl/renderer/gl_2ddrawer.cpp @@ -399,6 +399,7 @@ void F2DDrawer::Flush() // DrawTypePoly may not use the color part of the vertex buffer because it needs to use gl_SetColor to produce proper output. if (lasttype == DrawTypePoly && dg->mType != DrawTypePoly) { + gl_RenderState.ResetColor(); // this is needed to reset the desaturation. EnableColorArray(true); } else if (lasttype != DrawTypePoly && dg->mType == DrawTypePoly) From f56250b9107ab0446c040aca51419a7c1cd25479 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 14 Aug 2016 05:10:34 +0200 Subject: [PATCH 0786/1509] Remove premultiplied alpha --- src/r_draw_rgba.h | 23 +++++++++++++++-------- src/textures/texture.cpp | 12 ++---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 083258bf0..ca54f7263 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -473,9 +473,9 @@ public: { uint32_t alpha = APART(fg) + (APART(fg) >> 7); // 255 -> 256 uint32_t inv_alpha = 256 - alpha; - uint32_t red = MIN(RPART(fg) + (RPART(bg) * inv_alpha) / 256, 255); - uint32_t green = MIN(GPART(fg) + (GPART(bg) * inv_alpha) / 256, 255); - uint32_t blue = MIN(BPART(fg) + (BPART(bg) * inv_alpha) / 256, 255); + uint32_t red = MIN(RPART(fg) * alpha + (RPART(bg) * inv_alpha) / 256, 255); + uint32_t green = MIN(GPART(fg) * alpha + (GPART(bg) * inv_alpha) / 256, 255); + uint32_t blue = MIN(BPART(fg) * alpha + (BPART(bg) * inv_alpha) / 256, 255); return 0xff000000 | (red << 16) | (green << 8) | blue; } }; @@ -861,11 +861,18 @@ public: __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); \ __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); \ __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); \ - __m128i m255 = _mm_set1_epi16(255); \ - __m128i inv_alpha_hi = _mm_sub_epi16(m255, _mm_shufflehi_epi16(_mm_shufflelo_epi16(fg_hi, _MM_SHUFFLE(3,3,3,3)), _MM_SHUFFLE(3,3,3,3))); \ - __m128i inv_alpha_lo = _mm_sub_epi16(m255, _mm_shufflehi_epi16(_mm_shufflelo_epi16(fg_lo, _MM_SHUFFLE(3,3,3,3)), _MM_SHUFFLE(3,3,3,3))); \ - inv_alpha_hi = _mm_add_epi16(inv_alpha_hi, _mm_srli_epi16(inv_alpha_hi, 7)); \ - inv_alpha_lo = _mm_add_epi16(inv_alpha_lo, _mm_srli_epi16(inv_alpha_lo, 7)); \ + __m128i m256 = _mm_set1_epi16(256); \ + __m128i alpha_hi = _mm_shufflehi_epi16(_mm_shufflelo_epi16(fg_hi, _MM_SHUFFLE(3,3,3,3)), _MM_SHUFFLE(3,3,3,3)); \ + __m128i alpha_lo = _mm_shufflehi_epi16(_mm_shufflelo_epi16(fg_lo, _MM_SHUFFLE(3,3,3,3)), _MM_SHUFFLE(3,3,3,3)); \ + alpha_hi = _mm_add_epi16(alpha_hi, _mm_srli_epi16(alpha_hi, 7)); \ + alpha_lo = _mm_add_epi16(alpha_lo, _mm_srli_epi16(alpha_lo, 7)); \ + __m128i inv_alpha_hi = _mm_sub_epi16(m256, alpha_hi); \ + __m128i inv_alpha_lo = _mm_sub_epi16(m256, alpha_lo); \ + fg_hi = _mm_mullo_epi16(fg_hi, alpha_hi); \ + fg_hi = _mm_srli_epi16(fg_hi, 8); \ + fg_lo = _mm_mullo_epi16(fg_lo, alpha_lo); \ + fg_lo = _mm_srli_epi16(fg_lo, 8); \ + fg = _mm_packus_epi16(fg_lo, fg_hi); \ bg_hi = _mm_mullo_epi16(bg_hi, inv_alpha_hi); \ bg_hi = _mm_srli_epi16(bg_hi, 8); \ bg_lo = _mm_mullo_epi16(bg_lo, inv_alpha_lo); \ diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 05574e9da..12e9d8549 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -354,22 +354,14 @@ void FTexture::GenerateBgraFromBitmap(const FBitmap &bitmap) { CreatePixelsBgraWithMipmaps(); - // Transpose and premultiply alpha + // Transpose const uint32_t *src = (const uint32_t *)bitmap.GetPixels(); uint32_t *dest = PixelsBgra.data(); for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { - uint32_t p = src[x + y * Width]; - uint32_t red = RPART(p); - uint32_t green = GPART(p); - uint32_t blue = BPART(p); - uint32_t alpha = APART(p); - red = (red * alpha + 127) / 255; - green = (green * alpha + 127) / 255; - blue = (blue * alpha + 127) / 255; - dest[y + x * Height] = (alpha << 24) | (red << 16) | (green << 8) | blue; + dest[y + x * Height] = src[x + y * Width]; } } From c817979eae9507ea37c1ef180086b948ede0a4d4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 12 Aug 2016 07:28:29 +0200 Subject: [PATCH 0787/1509] Remove GetTrueHeight from GL renderer and concentrate all viewport calculations in SetOutputViewport --- src/gl/renderer/gl_2ddrawer.cpp | 15 ++-- src/gl/renderer/gl_postprocess.cpp | 97 +++++++++++++------------ src/gl/renderer/gl_renderer.cpp | 109 +++++++++++++++-------------- src/gl/renderer/gl_renderer.h | 9 ++- src/gl/scene/gl_scene.cpp | 6 +- src/gl/system/gl_framebuffer.cpp | 43 ++++++++---- src/gl/system/gl_wipe.cpp | 17 +++-- src/posix/cocoa/sdlglvideo.h | 2 - src/posix/sdl/sdlglvideo.h | 3 - 9 files changed, 163 insertions(+), 138 deletions(-) diff --git a/src/gl/renderer/gl_2ddrawer.cpp b/src/gl/renderer/gl_2ddrawer.cpp index 7c896d62c..8eb7b6c78 100644 --- a/src/gl/renderer/gl_2ddrawer.cpp +++ b/src/gl/renderer/gl_2ddrawer.cpp @@ -155,14 +155,10 @@ void F2DDrawer::AddTexture(FTexture *img, DrawParms &parms) color.a = (BYTE)(parms.Alpha * 255); // scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates - int btm = (SCREENHEIGHT - screen->GetHeight()) / 2; - btm = SCREENHEIGHT - btm; - - int space = (static_cast(screen)->GetTrueHeight() - screen->GetHeight()) / 2; - dg.mScissor[0] = parms.lclip; - dg.mScissor[1] = btm - parms.dclip + space; - dg.mScissor[2] = parms.rclip - parms.lclip; - dg.mScissor[3] = parms.dclip - parms.uclip; + dg.mScissor[0] = GLRenderer->ScreenToWindowX(parms.lclip); + dg.mScissor[1] = GLRenderer->ScreenToWindowY(parms.dclip); + dg.mScissor[2] = GLRenderer->ScreenToWindowX(parms.rclip) - GLRenderer->ScreenToWindowX(parms.lclip); + dg.mScissor[3] = GLRenderer->ScreenToWindowY(parms.dclip) - GLRenderer->ScreenToWindowY(parms.uclip); FSimpleVertex *ptr = &mVertices[dg.mVertIndex]; ptr->Set(x, y, 0, u1, v1, color); ptr++; @@ -438,7 +434,8 @@ void F2DDrawer::Flush() glDrawArrays(GL_TRIANGLE_STRIP, dt->mVertIndex + 4, 4); } - glScissor(0, 0, screen->GetWidth(), screen->GetHeight()); + const auto &viewport = GLRenderer->mScreenViewport; + glScissor(viewport.left, viewport.top, viewport.width, viewport.height); glDisable(GL_SCISSOR_TEST); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.SetTextureMode(TM_MODULATE); diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index dd4cc71aa..2d62a8d02 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -182,7 +182,7 @@ void FGLRenderer::BloomScene() // Add bloom back to scene texture: mBuffers->BindCurrentFB(); - glViewport(mOutputViewport.left, mOutputViewport.top, mOutputViewport.width, mOutputViewport.height); + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); glBlendFunc(GL_ONE, GL_ONE); @@ -243,7 +243,7 @@ void FGLRenderer::LensDistortScene() 0.0f }; - float aspect = mOutputViewport.width / mOutputViewport.height; + float aspect = mSceneViewport.width / mSceneViewport.height; // Scale factor to keep sampling within the input texture float r2 = aspect * aspect * 0.25 + 0.25f; @@ -283,60 +283,21 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) if (FGLRenderBuffers::IsEnabled()) { FGLPostProcessState savedState; - mBuffers->BindOutputFB(); - int x, y, width, height; + GL_IRECT box; if (bounds) { - x = bounds->left; - y = bounds->top; - width = bounds->width; - height = bounds->height; + box = *bounds; } else { - // Calculate letterbox - int clientWidth = framebuffer->GetClientWidth(); - int clientHeight = framebuffer->GetClientHeight(); - float scaleX = clientWidth / (float)mScreenViewport.width; - float scaleY = clientHeight / (float)mScreenViewport.height; - float scale = MIN(scaleX, scaleY); - width = (int)round(mScreenViewport.width * scale); - height = (int)round(mScreenViewport.height * scale); - x = (clientWidth - width) / 2; - y = (clientHeight - height) / 2; - - // Black bars around the box: - glViewport(0, 0, clientWidth, clientHeight); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glEnable(GL_SCISSOR_TEST); - if (y > 0) - { - glScissor(0, 0, clientWidth, y); - glClear(GL_COLOR_BUFFER_BIT); - } - if (clientHeight - y - height > 0) - { - glScissor(0, y + height, clientWidth, clientHeight - y - height); - glClear(GL_COLOR_BUFFER_BIT); - } - if (x > 0) - { - glScissor(0, y, x, height); - glClear(GL_COLOR_BUFFER_BIT); - } - if (clientWidth - x - width > 0) - { - glScissor(x + width, y, clientWidth - x - width, height); - glClear(GL_COLOR_BUFFER_BIT); - } + ClearBorders(); + box = mOutputLetterbox; } - glDisable(GL_SCISSOR_TEST); // Present what was rendered: - glViewport(x, y, width, height); - glDisable(GL_BLEND); + glViewport(box.left, box.top, box.width, box.height); mPresentShader->Bind(); mPresentShader->InputTexture.Set(0); @@ -358,4 +319,48 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); RenderScreenQuad(); } + else if (!bounds) + { + FGLPostProcessState savedState; + ClearBorders(); + } +} + +//----------------------------------------------------------------------------- +// +// Fills the black bars around the screen letterbox +// +//----------------------------------------------------------------------------- + +void FGLRenderer::ClearBorders() +{ + const auto &box = mOutputLetterbox; + + int clientWidth = framebuffer->GetClientWidth(); + int clientHeight = framebuffer->GetClientHeight(); + + glViewport(0, 0, clientWidth, clientHeight); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glEnable(GL_SCISSOR_TEST); + if (box.top > 0) + { + glScissor(0, 0, clientWidth, box.top); + glClear(GL_COLOR_BUFFER_BIT); + } + if (clientHeight - box.top - box.height > 0) + { + glScissor(0, box.top + box.height, clientWidth, clientHeight - box.top - box.height); + glClear(GL_COLOR_BUFFER_BIT); + } + if (box.left > 0) + { + glScissor(0, box.top, box.left, box.height); + glClear(GL_COLOR_BUFFER_BIT); + } + if (clientWidth - box.left - box.width > 0) + { + glScissor(box.left + box.width, box.top, clientWidth - box.left - box.width, box.height); + glClear(GL_COLOR_BUFFER_BIT); + } + glDisable(GL_SCISSOR_TEST); } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index b00396e21..7a4dbab55 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -79,6 +79,8 @@ EXTERN_CVAR(Int, screenblocks) +CVAR(Bool, gl_scale_viewport, true, 0); + //=========================================================================== // // Renderer interface @@ -190,16 +192,14 @@ void FGLRenderer::SetOutputViewport(GL_IRECT *bounds) { if (bounds) { - mOutputViewport = *bounds; - mOutputViewportLB = *bounds; + mSceneViewport = *bounds; mScreenViewport = *bounds; + mOutputLetterbox = *bounds; return; } - int height, width; - // Special handling so the view with a visible status bar displays properly - + int height, width; if (screenblocks >= 10) { height = framebuffer->GetHeight(); @@ -211,29 +211,64 @@ void FGLRenderer::SetOutputViewport(GL_IRECT *bounds) width = (screenblocks*framebuffer->GetWidth() / 10); } - int trueheight = framebuffer->GetTrueHeight(); // ugh... - int bars = (trueheight - framebuffer->GetHeight()) / 2; - - int vw = viewwidth; - int vh = viewheight; + // Back buffer letterbox for the final output + int clientWidth = framebuffer->GetClientWidth(); + int clientHeight = framebuffer->GetClientHeight(); + int screenWidth = framebuffer->GetWidth(); + int screenHeight = framebuffer->GetHeight(); + float scale = MIN(clientWidth / (float)screenWidth, clientHeight / (float)screenHeight); + mOutputLetterbox.width = (int)round(screenWidth * scale); + mOutputLetterbox.height = (int)round(screenHeight * scale); + mOutputLetterbox.left = (clientWidth - mOutputLetterbox.width) / 2; + mOutputLetterbox.top = (clientHeight - mOutputLetterbox.height) / 2; // The entire renderable area, including the 2D HUD mScreenViewport.left = 0; mScreenViewport.top = 0; - mScreenViewport.width = framebuffer->GetWidth(); - mScreenViewport.height = framebuffer->GetHeight(); + mScreenViewport.width = screenWidth; + mScreenViewport.height = screenHeight; - // Letterboxed viewport for the main scene - mOutputViewportLB.left = viewwindowx; - mOutputViewportLB.top = trueheight - bars - (height + viewwindowy - ((height - vh) / 2)); - mOutputViewportLB.width = vw; - mOutputViewportLB.height = height; + // Viewport for the 3D scene + mSceneViewport.left = viewwindowx; + mSceneViewport.top = screenHeight - (height + viewwindowy - ((height - viewheight) / 2)); + mSceneViewport.width = viewwidth; + mSceneViewport.height = height; - // Entire canvas for player sprites - mOutputViewport.left = 0; - mOutputViewport.top = (trueheight - framebuffer->GetHeight()) / 2; - mOutputViewport.width = framebuffer->GetWidth(); - mOutputViewport.height = framebuffer->GetHeight(); + // Scale viewports to fit letterbox + if (gl_scale_viewport || !FGLRenderBuffers::IsEnabled()) + { + mScreenViewport.width = mOutputLetterbox.width; + mScreenViewport.height = mOutputLetterbox.height; + mSceneViewport.left = (int)round(mSceneViewport.left * scale); + mSceneViewport.top = (int)round(mSceneViewport.top * scale); + mSceneViewport.width = (int)round(mSceneViewport.width * scale); + mSceneViewport.height = (int)round(mSceneViewport.height * scale); + + // Without render buffers we have to render directly to the letterbox + if (!FGLRenderBuffers::IsEnabled()) + { + mScreenViewport.left += mOutputLetterbox.left; + mScreenViewport.top += mOutputLetterbox.top; + mSceneViewport.left += mOutputLetterbox.left; + mSceneViewport.top += mOutputLetterbox.top; + } + } +} + +//=========================================================================== +// +// Calculates the OpenGL window coordinates for a zdoom screen position +// +//=========================================================================== + +int FGLRenderer::ScreenToWindowX(int x) +{ + return mScreenViewport.left + (int)round(x * mScreenViewport.width / (float)framebuffer->GetWidth()); +} + +int FGLRenderer::ScreenToWindowY(int y) +{ + return mScreenViewport.top + mScreenViewport.height - (int)round(y * mScreenViewport.height / (float)framebuffer->GetHeight()); } //=========================================================================== @@ -258,6 +293,7 @@ void FGLRenderer::Begin2D() mBuffers->BindCurrentFB(); } glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + glScissor(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); gl_RenderState.EnableFog(false); gl_RenderState.Set2DMode(true); @@ -363,32 +399,3 @@ unsigned char *FGLRenderer::GetTextureBuffer(FTexture *tex, int &w, int &h) } return NULL; } - -//=========================================================================== -// -// -// -//=========================================================================== - -void FGLRenderer::ClearBorders() -{ - OpenGLFrameBuffer *glscreen = static_cast(screen); - - // Letterbox time! Draw black top and bottom borders. - int width = glscreen->GetWidth(); - int height = glscreen->GetHeight(); - int trueHeight = glscreen->GetTrueHeight(); - - int borderHeight = (trueHeight - height) / 2; - - glViewport(0, 0, width, trueHeight); - glClearColor(0, 0, 0, 1); - glEnable(GL_SCISSOR_TEST); - glScissor(0, 0, width, borderHeight); - glClear(GL_COLOR_BUFFER_BIT); - glScissor(0, trueHeight-borderHeight, width, borderHeight); - glClear(GL_COLOR_BUFFER_BIT); - glDisable(GL_SCISSOR_TEST); - glViewport(0, (trueHeight - height) / 2, width, height); -} - diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 1a8883b3f..1ce241da3 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -111,17 +111,20 @@ public: F2DDrawer *m2DDrawer; GL_IRECT mScreenViewport; - GL_IRECT mOutputViewportLB; - GL_IRECT mOutputViewport; + GL_IRECT mSceneViewport; + GL_IRECT mOutputLetterbox; bool mDrawingScene2D = false; float mCameraExposure = 1.0f; FGLRenderer(OpenGLFrameBuffer *fb); ~FGLRenderer() ; + void SetOutputViewport(GL_IRECT *bounds); + int ScreenToWindowX(int x); + int ScreenToWindowY(int y); + angle_t FrustumAngle(); void SetViewArea(); - void SetOutputViewport(GL_IRECT *bounds); void Set3DViewport(bool mainview); void Reset3DViewport(); sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 44118087d..4ba181656 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -157,7 +157,7 @@ void FGLRenderer::SetViewArea() void FGLRenderer::Reset3DViewport() { - glViewport(mOutputViewport.left, mOutputViewport.top, mOutputViewport.width, mOutputViewport.height); + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); } //----------------------------------------------------------------------------- @@ -170,11 +170,11 @@ void FGLRenderer::Set3DViewport(bool mainview) { if (mainview && FGLRenderBuffers::IsEnabled()) { - mBuffers->Setup(mOutputViewport.width, mOutputViewport.height); + mBuffers->Setup(mScreenViewport.width, mScreenViewport.height); mBuffers->BindSceneFB(); } - const auto &bounds = mOutputViewportLB; + const auto &bounds = mSceneViewport; glViewport(bounds.left, bounds.top, bounds.width, bounds.height); glScissor(bounds.left, bounds.top, bounds.width, bounds.height); diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 495df07e8..d06b917a6 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -160,10 +160,6 @@ void OpenGLFrameBuffer::InitializeState() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - //int trueH = GetTrueHeight(); - //int h = GetHeight(); - //glViewport(0, (trueH - h)/2, GetWidth(), GetHeight()); - GLRenderer->Initialize(GetWidth(), GetHeight()); GLRenderer->SetOutputViewport(nullptr); Begin2D(false); @@ -191,13 +187,6 @@ void OpenGLFrameBuffer::Update() DrawRateStuff(); GLRenderer->Flush(); - if (GetTrueHeight() != GetHeight()) - { - if (GLRenderer != NULL) - GLRenderer->ClearBorders(); - - Begin2D(false); - } if (gl_draw_sync || !swapped) { Swap(); @@ -484,15 +473,41 @@ void OpenGLFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, int void OpenGLFrameBuffer::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type) { + const auto &viewport = GLRenderer->mScreenViewport; + + // Grab what is in the back buffer. + // We cannot rely on SCREENWIDTH/HEIGHT here because the output may have been scaled. + TArray pixels; + pixels.Resize(viewport.width * viewport.height); + glPixelStorei(GL_PACK_ALIGNMENT, 1); + glReadPixels(viewport.left, viewport.top, viewport.width, viewport.height, GL_RGB, GL_UNSIGNED_BYTE, &pixels[0]); + glPixelStorei(GL_PACK_ALIGNMENT, 4); + + // Copy to screenshot buffer: int w = SCREENWIDTH; int h = SCREENHEIGHT; ReleaseScreenshotBuffer(); ScreenshotBuffer = new BYTE[w * h * 3]; - glPixelStorei(GL_PACK_ALIGNMENT, 1); - glReadPixels(0,(GetTrueHeight() - GetHeight()) / 2,w,h,GL_RGB,GL_UNSIGNED_BYTE,ScreenshotBuffer); - glPixelStorei(GL_PACK_ALIGNMENT, 4); + float rcpWidth = 1.0f / viewport.width; + float rcpHeight = 1.0f / viewport.height; + for (int y = 0; y < h; y++) + { + for (int x = 0; x < w; x++) + { + float u = (x + 0.5f) * rcpWidth; + float v = (y + 0.5f) * rcpHeight; + int sx = u * viewport.width; + int sy = v * viewport.height; + int sindex = (sx + sy * w) * 3; + int dindex = (x + y * w) * 3; + ScreenshotBuffer[dindex] = pixels[sindex]; + ScreenshotBuffer[dindex + 1] = pixels[sindex + 1]; + ScreenshotBuffer[dindex + 2] = pixels[sindex + 2]; + } + } + pitch = -w*3; color_type = SS_RGB; buffer = ScreenshotBuffer + w * 3 * (h - 1); diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 59adc7e9e..c6c09b551 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -151,8 +151,9 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) return false; } - wipestartscreen = new FHardwareTexture(Width, Height, true); - wipestartscreen->CreateTexture(NULL, Width, Height, 0, false, 0); + const auto &viewport = GLRenderer->mScreenViewport; + wipestartscreen = new FHardwareTexture(viewport.width, viewport.height, true); + wipestartscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0); GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1); GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE, -1); glFinish(); @@ -161,14 +162,14 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) if (FGLRenderBuffers::IsEnabled()) { GLRenderer->mBuffers->BindCurrentFB(); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height); } else { GLint readbuffer = 0; glGetIntegerv(GL_READ_BUFFER, &readbuffer); glReadBuffer(GL_FRONT); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height); glReadBuffer(readbuffer); } @@ -189,8 +190,10 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) void OpenGLFrameBuffer::WipeEndScreen() { GLRenderer->m2DDrawer->Flush(); - wipeendscreen = new FHardwareTexture(Width, Height, true); - wipeendscreen->CreateTexture(NULL, Width, Height, 0, false, 0); + + const auto &viewport = GLRenderer->mScreenViewport; + wipeendscreen = new FHardwareTexture(viewport.width, viewport.height, true); + wipeendscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0); GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1); glFinish(); wipeendscreen->Bind(0, false, false); @@ -198,7 +201,7 @@ void OpenGLFrameBuffer::WipeEndScreen() if (FGLRenderBuffers::IsEnabled()) GLRenderer->mBuffers->BindCurrentFB(); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); diff --git a/src/posix/cocoa/sdlglvideo.h b/src/posix/cocoa/sdlglvideo.h index cab846a15..fcbf23f2a 100644 --- a/src/posix/cocoa/sdlglvideo.h +++ b/src/posix/cocoa/sdlglvideo.h @@ -65,8 +65,6 @@ public: int GetClientWidth(); int GetClientHeight(); - int GetTrueHeight() { return GetHeight(); } - protected: int m_lock; bool m_isUpdatePending; diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h index 0b6a46c12..d8ce9005d 100644 --- a/src/posix/sdl/sdlglvideo.h +++ b/src/posix/sdl/sdlglvideo.h @@ -61,9 +61,6 @@ public: int GetClientWidth(); int GetClientHeight(); -//[C] - int GetTrueHeight() { return GetHeight();} - protected: bool CanUpdate(); void SetGammaTable(WORD *tbl); From d5b122b09287abda5a29d648e0a068f1a89264d6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 12 Aug 2016 07:34:05 +0200 Subject: [PATCH 0788/1509] Fix GetScreenshotBuffer grabbing from wrong location --- src/gl/system/gl_framebuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index d06b917a6..fb752c571 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -473,7 +473,7 @@ void OpenGLFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, int void OpenGLFrameBuffer::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type) { - const auto &viewport = GLRenderer->mScreenViewport; + const auto &viewport = GLRenderer->mOutputLetterbox; // Grab what is in the back buffer. // We cannot rely on SCREENWIDTH/HEIGHT here because the output may have been scaled. From 4ecb77385d46a27c98879ebf23bc1b67bcc3d55b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 12 Aug 2016 07:42:49 +0200 Subject: [PATCH 0789/1509] GetScreenshotBuffer bug fix --- src/gl/system/gl_framebuffer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index fb752c571..beaf3bcf3 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -478,7 +478,7 @@ void OpenGLFrameBuffer::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESS // Grab what is in the back buffer. // We cannot rely on SCREENWIDTH/HEIGHT here because the output may have been scaled. TArray pixels; - pixels.Resize(viewport.width * viewport.height); + pixels.Resize(viewport.width * viewport.height * 3); glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(viewport.left, viewport.top, viewport.width, viewport.height, GL_RGB, GL_UNSIGNED_BYTE, &pixels[0]); glPixelStorei(GL_PACK_ALIGNMENT, 4); @@ -490,8 +490,8 @@ void OpenGLFrameBuffer::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESS ReleaseScreenshotBuffer(); ScreenshotBuffer = new BYTE[w * h * 3]; - float rcpWidth = 1.0f / viewport.width; - float rcpHeight = 1.0f / viewport.height; + float rcpWidth = 1.0f / w; + float rcpHeight = 1.0f / h; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) @@ -500,7 +500,7 @@ void OpenGLFrameBuffer::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESS float v = (y + 0.5f) * rcpHeight; int sx = u * viewport.width; int sy = v * viewport.height; - int sindex = (sx + sy * w) * 3; + int sindex = (sx + sy * viewport.width) * 3; int dindex = (x + y * w) * 3; ScreenshotBuffer[dindex] = pixels[sindex]; ScreenshotBuffer[dindex + 1] = pixels[sindex + 1]; From 210fce1193657ede24a60d3be1e3da79c8add8e6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 12 Aug 2016 17:44:59 +0200 Subject: [PATCH 0790/1509] Fix bloom shader missing its target --- src/gl/renderer/gl_postprocess.cpp | 5 ++++- src/gl/renderer/gl_renderbuffers.cpp | 13 ++++++++++--- src/gl/renderer/gl_renderbuffers.h | 4 +++- src/gl/renderer/gl_renderer.cpp | 2 +- src/gl/scene/gl_scene.cpp | 2 +- src/gl/shaders/gl_bloomshader.cpp | 2 ++ src/gl/shaders/gl_bloomshader.h | 2 ++ wadsrc/static/shaders/glsl/bloomextract.fp | 4 +++- 8 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 2d62a8d02..c6535c2df 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -143,6 +143,8 @@ void FGLRenderer::BloomScene() mBloomExtractShader->Bind(); mBloomExtractShader->SceneTexture.Set(0); mBloomExtractShader->Exposure.Set(mCameraExposure); + mBloomExtractShader->Scale.Set(mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height); + mBloomExtractShader->Offset.Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); RenderScreenQuad(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -182,7 +184,7 @@ void FGLRenderer::BloomScene() // Add bloom back to scene texture: mBuffers->BindCurrentFB(); - glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + glViewport(mSceneViewport.left, mSceneViewport.top, mSceneViewport.width, mSceneViewport.height); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); glBlendFunc(GL_ONE, GL_ONE); @@ -193,6 +195,7 @@ void FGLRenderer::BloomScene() mBloomCombineShader->Bind(); mBloomCombineShader->BloomTexture.Set(0); RenderScreenQuad(); + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); } //----------------------------------------------------------------------------- diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 3b402d801..918850e31 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -139,7 +139,7 @@ void FGLRenderBuffers::DeleteFrameBuffer(GLuint &handle) // //========================================================================== -void FGLRenderBuffers::Setup(int width, int height) +void FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHeight) { if (!IsEnabled()) return; @@ -151,16 +151,23 @@ void FGLRenderBuffers::Setup(int width, int height) CreateScene(mWidth, mHeight, samples); mSamples = samples; } - else if (width > mWidth || height > mHeight) + else if (width != mWidth || height != mHeight) { CreatePipeline(width, height); CreateScene(width, height, samples); - CreateBloom(width, height); mWidth = width; mHeight = height; mSamples = samples; } + // Bloom bluring buffers need to match the scene to avoid bloom bleeding artifacts + if (mBloomWidth != sceneWidth || mBloomHeight != sceneHeight) + { + CreateBloom(sceneWidth, sceneHeight); + mBloomWidth = sceneWidth; + mBloomHeight = sceneHeight; + } + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); glBindRenderbuffer(GL_RENDERBUFFER, 0); diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 8b3001c96..68c4b2a31 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -20,7 +20,7 @@ public: FGLRenderBuffers(); ~FGLRenderBuffers(); - void Setup(int width, int height); + void Setup(int width, int height, int sceneWidth, int sceneHeight); void BindSceneFB(); void BlitSceneToTexture(); @@ -64,6 +64,8 @@ private: int mWidth = 0; int mHeight = 0; int mSamples = 0; + int mBloomWidth = 0; + int mBloomHeight = 0; static const int NumPipelineTextures = 2; int mCurrentPipelineTexture = 0; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 7a4dbab55..84d02159f 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -286,7 +286,7 @@ void FGLRenderer::Begin2D() { if (FGLRenderBuffers::IsEnabled()) { - mBuffers->Setup(framebuffer->GetWidth(), framebuffer->GetHeight()); + mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height); if (mDrawingScene2D) mBuffers->BindSceneFB(); else diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 4ba181656..751a74c09 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -170,7 +170,7 @@ void FGLRenderer::Set3DViewport(bool mainview) { if (mainview && FGLRenderBuffers::IsEnabled()) { - mBuffers->Setup(mScreenViewport.width, mScreenViewport.height); + mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height); mBuffers->BindSceneFB(); } diff --git a/src/gl/shaders/gl_bloomshader.cpp b/src/gl/shaders/gl_bloomshader.cpp index f9e38e0c3..9e8f60133 100644 --- a/src/gl/shaders/gl_bloomshader.cpp +++ b/src/gl/shaders/gl_bloomshader.cpp @@ -60,6 +60,8 @@ void FBloomExtractShader::Bind() mShader.SetAttribLocation(0, "PositionInProjection"); SceneTexture.Init(mShader, "SceneTexture"); Exposure.Init(mShader, "ExposureAdjustment"); + Scale.Init(mShader, "Scale"); + Offset.Init(mShader, "Offset"); } mShader.Bind(); } diff --git a/src/gl/shaders/gl_bloomshader.h b/src/gl/shaders/gl_bloomshader.h index a8e93df83..cbc740ab6 100644 --- a/src/gl/shaders/gl_bloomshader.h +++ b/src/gl/shaders/gl_bloomshader.h @@ -10,6 +10,8 @@ public: FBufferedUniform1i SceneTexture; FBufferedUniform1f Exposure; + FBufferedUniform2f Scale; + FBufferedUniform2f Offset; private: FShaderProgram mShader; diff --git a/wadsrc/static/shaders/glsl/bloomextract.fp b/wadsrc/static/shaders/glsl/bloomextract.fp index dc753ce49..bc94c3c0e 100644 --- a/wadsrc/static/shaders/glsl/bloomextract.fp +++ b/wadsrc/static/shaders/glsl/bloomextract.fp @@ -4,9 +4,11 @@ out vec4 FragColor; uniform sampler2D SceneTexture; uniform float ExposureAdjustment; +uniform vec2 Scale; +uniform vec2 Offset; void main() { - vec4 color = texture(SceneTexture, TexCoord); + vec4 color = texture(SceneTexture, Offset + TexCoord * Scale); FragColor = max(vec4(color.rgb * ExposureAdjustment - 1, 1), vec4(0)); } From 647ef5d0291264fa290c91ed017391fbbdc8c00b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 12 Aug 2016 17:51:06 +0200 Subject: [PATCH 0791/1509] Fix blur shader to use RenderScreenQuad --- src/gl/renderer/gl_postprocess.cpp | 12 ++++++------ src/gl/shaders/gl_blurshader.cpp | 18 +++++++----------- src/gl/shaders/gl_blurshader.h | 8 ++++---- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index c6535c2df..b8553bde1 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -154,8 +154,8 @@ void FGLRenderer::BloomScene() { const auto &level = mBuffers->BloomLevels[i]; const auto &next = mBuffers->BloomLevels[i + 1]; - mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); - mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level.HTexture, next.VFramebuffer, next.Width, next.Height); + mBlurShader->BlurHorizontal(this, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); + mBlurShader->BlurVertical(this, blurAmount, sampleCount, level.HTexture, next.VFramebuffer, next.Width, next.Height); } // Blur and upscale: @@ -164,8 +164,8 @@ void FGLRenderer::BloomScene() const auto &level = mBuffers->BloomLevels[i]; const auto &next = mBuffers->BloomLevels[i - 1]; - mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); - mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level.HTexture, level.VFramebuffer, level.Width, level.Height); + mBlurShader->BlurHorizontal(this, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); + mBlurShader->BlurVertical(this, blurAmount, sampleCount, level.HTexture, level.VFramebuffer, level.Width, level.Height); // Linear upscale: glBindFramebuffer(GL_FRAMEBUFFER, next.VFramebuffer); @@ -179,8 +179,8 @@ void FGLRenderer::BloomScene() RenderScreenQuad(); } - mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level0.VTexture, level0.HFramebuffer, level0.Width, level0.Height); - mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level0.HTexture, level0.VFramebuffer, level0.Width, level0.Height); + mBlurShader->BlurHorizontal(this, blurAmount, sampleCount, level0.VTexture, level0.HFramebuffer, level0.Width, level0.Height); + mBlurShader->BlurVertical(this, blurAmount, sampleCount, level0.HTexture, level0.VFramebuffer, level0.Width, level0.Height); // Add bloom back to scene texture: mBuffers->BindCurrentFB(); diff --git a/src/gl/shaders/gl_blurshader.cpp b/src/gl/shaders/gl_blurshader.cpp index 10168148b..6154c17ce 100644 --- a/src/gl/shaders/gl_blurshader.cpp +++ b/src/gl/shaders/gl_blurshader.cpp @@ -49,6 +49,7 @@ #include "gl/system/gl_cvars.h" #include "gl/shaders/gl_blurshader.h" #include "gl/data/gl_vertexbuffer.h" +#include "gl/renderer/gl_renderer.h" //========================================================================== // @@ -56,9 +57,9 @@ // //========================================================================== -void FBlurShader::BlurVertical(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height) +void FBlurShader::BlurVertical(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height) { - Blur(vbo, blurAmount, sampleCount, inputTexture, outputFrameBuffer, width, height, true); + Blur(renderer, blurAmount, sampleCount, inputTexture, outputFrameBuffer, width, height, true); } //========================================================================== @@ -67,9 +68,9 @@ void FBlurShader::BlurVertical(FFlatVertexBuffer *vbo, float blurAmount, int sam // //========================================================================== -void FBlurShader::BlurHorizontal(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height) +void FBlurShader::BlurHorizontal(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height) { - Blur(vbo, blurAmount, sampleCount, inputTexture, outputFrameBuffer, width, height, false); + Blur(renderer, blurAmount, sampleCount, inputTexture, outputFrameBuffer, width, height, false); } //========================================================================== @@ -78,7 +79,7 @@ void FBlurShader::BlurHorizontal(FFlatVertexBuffer *vbo, float blurAmount, int s // //========================================================================== -void FBlurShader::Blur(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height, bool vertical) +void FBlurShader::Blur(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height, bool vertical) { BlurSetup *setup = GetSetup(blurAmount, sampleCount); if (vertical) @@ -111,12 +112,7 @@ void FBlurShader::Blur(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount glViewport(0, 0, width, height); glDisable(GL_BLEND); - FFlatVertex *ptr = vbo->GetBuffer(); - ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++; - ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++; - ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++; - ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++; - vbo->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + renderer->RenderScreenQuad(); } //========================================================================== diff --git a/src/gl/shaders/gl_blurshader.h b/src/gl/shaders/gl_blurshader.h index 9af5a9101..92ef5f115 100644 --- a/src/gl/shaders/gl_blurshader.h +++ b/src/gl/shaders/gl_blurshader.h @@ -4,16 +4,16 @@ #include "gl_shaderprogram.h" #include -class FFlatVertexBuffer; +class FGLRenderer; class FBlurShader { public: - void BlurVertical(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height); - void BlurHorizontal(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height); + void BlurVertical(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height); + void BlurHorizontal(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height); private: - void Blur(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height, bool vertical); + void Blur(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height, bool vertical); struct BlurSetup { From 4e38f31a86906315d3b598f2a66d5bbb15d5b8e6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 13 Aug 2016 17:49:20 +0200 Subject: [PATCH 0792/1509] Change GetClientWidth/GetClientHeight on macOS to grab size from view. Fix that GetClientWidth/Height returns 0 when queried before initial show. Allow window to be resizable on macOS. --- src/posix/cocoa/i_video.mm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 242cb489b..8f8b7c135 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -169,7 +169,7 @@ namespace const NSInteger LEVEL_WINDOWED = NSNormalWindowLevel; const NSUInteger STYLE_MASK_FULLSCREEN = NSBorderlessWindowMask; - const NSUInteger STYLE_MASK_WINDOWED = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask; + const NSUInteger STYLE_MASK_WINDOWED = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask; } @@ -1207,12 +1207,18 @@ void SDLGLFB::ResetGammaTable() int SDLGLFB::GetClientWidth() { - return static_cast(rbOpts.width + 2.0f * rbOpts.shiftX); + NSView *view = [[NSOpenGLContext currentContext] view]; + NSRect backingBounds = [view convertRectToBacking: [view bounds]]; + int clientWidth = (int)backingBounds.size.width; + return clientWidth > 0 ? clientWidth : Width; } int SDLGLFB::GetClientHeight() { - return static_cast(rbOpts.height + 2.0f * rbOpts.shiftY); + NSView *view = [[NSOpenGLContext currentContext] view]; + NSRect backingBounds = [view convertRectToBacking: [view bounds]]; + int clientHeight = (int)backingBounds.size.height; + return clientHeight > 0 ? clientHeight : Height; } From 847d2e8862f87ea4c1efff6a2d7d2c23073d26bf Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 13 Aug 2016 18:24:27 +0200 Subject: [PATCH 0793/1509] Fix viewport not being updated when resizing window when no scene is active --- src/gl/renderer/gl_renderer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 84d02159f..ae7c7d93c 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -286,6 +286,9 @@ void FGLRenderer::Begin2D() { if (FGLRenderBuffers::IsEnabled()) { + if (!mDrawingScene2D) // For when there's no scene rendered (main menu and intermission) + SetOutputViewport(nullptr); + mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height); if (mDrawingScene2D) mBuffers->BindSceneFB(); From af62352860321d741a8f1a05f1c0b2a85586bcc8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 13 Aug 2016 18:25:25 +0200 Subject: [PATCH 0794/1509] Fix uninitialized data in render buffers at creation --- src/gl/renderer/gl_renderbuffers.cpp | 27 +++++++++++++++++++++++++++ src/gl/renderer/gl_renderbuffers.h | 1 + 2 files changed, 28 insertions(+) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 918850e31..0d1f10d4e 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -336,6 +336,7 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer) glBindFramebuffer(GL_FRAMEBUFFER, handle); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); CheckFrameBufferCompleteness(); + ClearFrameBuffer(); return handle; } @@ -350,6 +351,7 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depthstenc glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil); CheckFrameBufferCompleteness(); + ClearFrameBuffer(); return handle; } @@ -365,6 +367,7 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLu glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil); CheckFrameBufferCompleteness(); + ClearFrameBuffer(); return handle; } @@ -396,6 +399,30 @@ void FGLRenderBuffers::CheckFrameBufferCompleteness() I_FatalError(error); } +//========================================================================== +// +// Clear frame buffer to make sure it never contains uninitialized data +// +//========================================================================== + +void FGLRenderBuffers::ClearFrameBuffer() +{ + GLint scissorEnabled, stencilValue; + GLdouble depthValue; + glGetIntegerv(GL_SCISSOR_TEST, &scissorEnabled); + glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilValue); + glGetDoublev(GL_DEPTH_CLEAR_VALUE, &depthValue); + glDisable(GL_SCISSOR_TEST); + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearDepth(0.0); + glClearStencil(0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + glClearStencil(stencilValue); + glClearDepth(depthValue); + if (scissorEnabled) + glEnable(GL_SCISSOR_TEST); +} + //========================================================================== // // Resolves the multisample frame buffer by copying it to the scene texture diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 68c4b2a31..4d2c551c2 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -54,6 +54,7 @@ private: GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer); GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer); void CheckFrameBufferCompleteness(); + void ClearFrameBuffer(); void DeleteTexture(GLuint &handle); void DeleteRenderBuffer(GLuint &handle); void DeleteFrameBuffer(GLuint &handle); From 94b72d25e97bf698fe83b0c78e3d2fe2b812c07d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 13 Aug 2016 18:43:30 +0200 Subject: [PATCH 0795/1509] First render may not have known scene dimensions --- src/gl/renderer/gl_renderbuffers.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 0d1f10d4e..419dce95f 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -143,6 +143,9 @@ void FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei { if (!IsEnabled()) return; + + if (width <= 0 || height <= 0) + I_FatalError("Requested invalid render buffer sizes: screen = %dx%d", width, height); int samples = GetCvarSamples(); @@ -226,6 +229,10 @@ void FGLRenderBuffers::CreatePipeline(int width, int height) void FGLRenderBuffers::CreateBloom(int width, int height) { ClearBloom(); + + // No scene, no bloom! + if (width <= 0 || height <= 0) + return; int bloomWidth = MAX(width / 2, 1); int bloomHeight = MAX(height / 2, 1); From fd4422eb626c1d84cddd63cfe20315f5a9a3f910 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 13 Aug 2016 22:24:21 +0200 Subject: [PATCH 0796/1509] Restore bound texture when FGLRenderBuffers::Setup finishes --- src/gl/renderer/gl_renderbuffers.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 419dce95f..976b80c48 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -149,6 +149,12 @@ void FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei int samples = GetCvarSamples(); + GLint activeTex; + GLint textureBinding; + glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); + glActiveTexture(GL_TEXTURE0); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); + if (width == mWidth && height == mHeight && mSamples != samples) { CreateScene(mWidth, mHeight, samples); @@ -171,8 +177,8 @@ void FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei mBloomHeight = sceneHeight; } - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, 0); + glBindTexture(GL_TEXTURE_BINDING_2D, textureBinding); + glActiveTexture(activeTex); glBindRenderbuffer(GL_RENDERBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0); } @@ -293,7 +299,6 @@ GLuint FGLRenderBuffers::Create2DTexture(GLuint format, int width, int height) GLuint type = (format == GL_RGBA16F) ? GL_FLOAT : GL_UNSIGNED_BYTE; GLuint handle = 0; glGenTextures(1, &handle); - glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, handle); glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, GL_RGBA, type, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -414,9 +419,10 @@ void FGLRenderBuffers::CheckFrameBufferCompleteness() void FGLRenderBuffers::ClearFrameBuffer() { - GLint scissorEnabled, stencilValue; + GLboolean scissorEnabled; + GLint stencilValue; GLdouble depthValue; - glGetIntegerv(GL_SCISSOR_TEST, &scissorEnabled); + glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilValue); glGetDoublev(GL_DEPTH_CLEAR_VALUE, &depthValue); glDisable(GL_SCISSOR_TEST); From f8cc56ea3a30eb0dc62f9dc7215a36f0ce27434e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 13 Aug 2016 23:07:13 +0200 Subject: [PATCH 0797/1509] Move SetOutputViewport to OpenGLFrameBuffer::Update as it cannot be safely called from Begin2D --- src/gl/renderer/gl_renderer.cpp | 3 --- src/gl/system/gl_framebuffer.cpp | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index ae7c7d93c..84d02159f 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -286,9 +286,6 @@ void FGLRenderer::Begin2D() { if (FGLRenderBuffers::IsEnabled()) { - if (!mDrawingScene2D) // For when there's no scene rendered (main menu and intermission) - SetOutputViewport(nullptr); - mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height); if (mDrawingScene2D) mBuffers->BindSceneFB(); diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index beaf3bcf3..096a33393 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -187,6 +187,8 @@ void OpenGLFrameBuffer::Update() DrawRateStuff(); GLRenderer->Flush(); + GLRenderer->SetOutputViewport(nullptr); + if (gl_draw_sync || !swapped) { Swap(); From 4e8a96aa0e8e1053792b49455ece2fa0f644a503 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 14 Aug 2016 09:14:26 +0200 Subject: [PATCH 0798/1509] - removed FRenderState::set2DMode because it had no effect. This looks like development garbage from old times. --- src/gl/renderer/gl_renderer.cpp | 1 - src/gl/renderer/gl_renderstate.cpp | 1 - src/gl/renderer/gl_renderstate.h | 8 +------- src/gl/scene/gl_portal.cpp | 1 - src/gl/scene/gl_scene.cpp | 2 -- 5 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 84d02159f..8c4baee60 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -296,7 +296,6 @@ void FGLRenderer::Begin2D() glScissor(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); gl_RenderState.EnableFog(false); - gl_RenderState.Set2DMode(true); } //=========================================================================== diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 84badd07b..83303d61e 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -81,7 +81,6 @@ void FRenderState::Reset() mAlphaThreshold = 0.5f; mBlendEquation = GL_FUNC_ADD; mObjectColor = 0xffffffff; - m2D = true; mVertexBuffer = mCurrentVertexBuffer = NULL; mColormapState = CM_DEFAULT; mLightParms[3] = -1.f; diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 12671c2a6..3e0729bbe 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -60,13 +60,12 @@ class FRenderState int mSrcBlend, mDstBlend; float mAlphaThreshold; int mBlendEquation; - bool m2D; bool mModelMatrixEnabled; bool mTextureMatrixEnabled; + bool mLastDepthClamp; float mInterpolationFactor; float mClipHeight, mClipHeightDirection; float mShaderTimer; - bool mLastDepthClamp; FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; FStateVec4 mColor; @@ -428,11 +427,6 @@ public: return res; } - void Set2DMode(bool on) - { - m2D = on; - } - void SetInterpolationFactor(float fac) { mInterpolationFactor = fac; diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 2cca5c1f0..559c14976 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -135,7 +135,6 @@ void GLPortal::ClearScreen() gl_MatrixStack.Pop(gl_RenderState.mViewMatrix); gl_RenderState.ApplyMatrices(); if (multi) glEnable(GL_MULTISAMPLE); - gl_RenderState.Set2DMode(false); } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 751a74c09..91f01adf7 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -223,7 +223,6 @@ void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovratio)); gl_RenderState.mProjectionMatrix.perspective(fovy, ratio, 5.f, 65536.f); - gl_RenderState.Set2DMode(false); } // raw matrix input from stereo 3d modes @@ -231,7 +230,6 @@ void FGLRenderer::SetProjection(VSMatrix matrix) { gl_RenderState.mProjectionMatrix.loadIdentity(); gl_RenderState.mProjectionMatrix.multMatrix(matrix); - gl_RenderState.Set2DMode(false); } //----------------------------------------------------------------------------- From e03696a6c94908de74f44615f793006b24e3e696 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 14 Aug 2016 20:11:46 +0200 Subject: [PATCH 0799/1509] - fixed: The model matrix must be disabled right after rendering the sky dome, so that it won't get used for the skyfog layer. --- src/gl/scene/gl_skydome.cpp | 44 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 52dfa064f..2b6843bdf 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -119,7 +119,7 @@ void FSkyVertexBuffer::SkyVertex(int r, int c, bool zflip) static const FAngle maxSideAngle = 60.f; static const float scale = 10000.; - FAngle topAngle= (c / (float)mColumns * 360.f); + FAngle topAngle = (c / (float)mColumns * 360.f); FAngle sideAngle = maxSideAngle * (mRows - r) / mRows; float height = sideAngle.Sin(); float realRadius = scale * sideAngle.Cos(); @@ -127,13 +127,13 @@ void FSkyVertexBuffer::SkyVertex(int r, int c, bool zflip) float z = (!zflip) ? scale * height : -scale * height; FSkyVertex vert; - + vert.color = r == 0 ? 0xffffff : 0xffffffff; - + // And the texture coordinates. - if(!zflip) // Flipped Y is for the lower hemisphere. + if (!zflip) // Flipped Y is for the lower hemisphere. { - vert.u = (-c / (float)mColumns) ; + vert.u = (-c / (float)mColumns); vert.v = (r / (float)mRows); } else @@ -142,7 +142,7 @@ void FSkyVertexBuffer::SkyVertex(int r, int c, bool zflip) vert.v = 1.0f + ((mRows - r) / (float)mRows); } - if (r != 4) z+=300; + if (r != 4) z += 300; // And finally the vertex. vert.x = -pos.X; // Doom mirrors the sky vertically! vert.y = z - 1.f; @@ -194,21 +194,21 @@ void FSkyVertexBuffer::CreateDome() // the first thing we put into the buffer is the fog layer object which is just 4 triangles around the viewpoint. mVertices.Reserve(12); - mVertices[0].Set( 1.0f, 1.0f, -1.0f); - mVertices[1].Set( 1.0f, -1.0f, -1.0f); - mVertices[2].Set(-1.0f, 0.0f, -1.0f); + mVertices[0].Set(1.0f, 1.0f, -1.0f); + mVertices[1].Set(1.0f, -1.0f, -1.0f); + mVertices[2].Set(-1.0f, 0.0f, -1.0f); - mVertices[3].Set( 1.0f, 1.0f, -1.0f); - mVertices[4].Set( 1.0f, -1.0f, -1.0f); - mVertices[5].Set( 0.0f, 0.0f, 1.0f); + mVertices[3].Set(1.0f, 1.0f, -1.0f); + mVertices[4].Set(1.0f, -1.0f, -1.0f); + mVertices[5].Set(0.0f, 0.0f, 1.0f); mVertices[6].Set(-1.0f, 0.0f, -1.0f); - mVertices[7].Set( 1.0f, 1.0f, -1.0f); - mVertices[8].Set( 0.0f, 0.0f, 1.0f); + mVertices[7].Set(1.0f, 1.0f, -1.0f); + mVertices[8].Set(0.0f, 0.0f, 1.0f); mVertices[9].Set(1.0f, -1.0f, -1.0f); mVertices[10].Set(-1.0f, 0.0f, -1.0f); - mVertices[11].Set( 0.0f, 0.0f, 1.0f); + mVertices[11].Set(0.0f, 0.0f, 1.0f); mColumns = 128; mRows = 4; @@ -358,7 +358,7 @@ void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, in gl_RenderState.EnableModelMatrix(true); gl_RenderState.mModelMatrix.loadIdentity(); - gl_RenderState.mModelMatrix.rotate(-180.0f+x_offset, 0.f, 1.f, 0.f); + gl_RenderState.mModelMatrix.rotate(-180.0f + x_offset, 0.f, 1.f, 0.f); float xscale = texw < 1024.f ? floor(1024.f / float(texw)) : 1.f; float yscale = 1.f; @@ -366,18 +366,18 @@ void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, in { // smaller sky textures must be tiled. We restrict it to 128 sky pixels, though gl_RenderState.mModelMatrix.translate(0.f, -1250.f, 0.f); - gl_RenderState.mModelMatrix.scale(1.f, 128/230.f, 1.f); + gl_RenderState.mModelMatrix.scale(1.f, 128 / 230.f, 1.f); yscale = 128 / texh; // intentionally left as integer. } else if (texh < 200) { gl_RenderState.mModelMatrix.translate(0.f, -1250.f, 0.f); - gl_RenderState.mModelMatrix.scale(1.f, texh/230.f, 1.f); + gl_RenderState.mModelMatrix.scale(1.f, texh / 230.f, 1.f); } else if (texh <= 240) { gl_RenderState.mModelMatrix.translate(0.f, (200 - texh + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); - gl_RenderState.mModelMatrix.scale(1.f, 1.f + ((texh-200.f)/200.f) * 1.17f, 1.f); + gl_RenderState.mModelMatrix.scale(1.f, 1.f + ((texh - 200.f) / 200.f) * 1.17f, 1.f); } else { @@ -387,12 +387,13 @@ void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, in } gl_RenderState.EnableTextureMatrix(true); gl_RenderState.mTextureMatrix.loadIdentity(); - gl_RenderState.mTextureMatrix.scale(mirror? -xscale : xscale, yscale, 1.f); + gl_RenderState.mTextureMatrix.scale(mirror ? -xscale : xscale, yscale, 1.f); gl_RenderState.mTextureMatrix.translate(1.f, y_offset / texh, 1.f); } GLRenderer->mSkyVBO->RenderDome(tex, mode); gl_RenderState.EnableTextureMatrix(false); + gl_RenderState.EnableModelMatrix(false); } @@ -493,7 +494,7 @@ void GLSkyPortal::DrawContents() bool oldClamp = gl_RenderState.SetDepthClamp(true); gl_MatrixStack.Push(gl_RenderState.mViewMatrix); - GLRenderer->SetupView(0, 0, 0, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + GLRenderer->SetupView(0, 0, 0, ViewAngle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO); if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox) @@ -536,6 +537,5 @@ void GLSkyPortal::DrawContents() gl_RenderState.ApplyMatrices(); glset.lightmode = oldlightmode; gl_RenderState.SetDepthClamp(oldClamp); - gl_RenderState.EnableModelMatrix(false); } From ac80ffcc006d41c0f40d9d5e3d00f629820aff33 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 15 Aug 2016 08:53:49 +0200 Subject: [PATCH 0800/1509] - fixed scissor calculations in 2D drawer. --- src/gl/renderer/gl_2ddrawer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/renderer/gl_2ddrawer.cpp b/src/gl/renderer/gl_2ddrawer.cpp index 8eb7b6c78..ac7d35397 100644 --- a/src/gl/renderer/gl_2ddrawer.cpp +++ b/src/gl/renderer/gl_2ddrawer.cpp @@ -157,8 +157,8 @@ void F2DDrawer::AddTexture(FTexture *img, DrawParms &parms) // scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates dg.mScissor[0] = GLRenderer->ScreenToWindowX(parms.lclip); dg.mScissor[1] = GLRenderer->ScreenToWindowY(parms.dclip); - dg.mScissor[2] = GLRenderer->ScreenToWindowX(parms.rclip) - GLRenderer->ScreenToWindowX(parms.lclip); - dg.mScissor[3] = GLRenderer->ScreenToWindowY(parms.dclip) - GLRenderer->ScreenToWindowY(parms.uclip); + dg.mScissor[2] = GLRenderer->ScreenToWindowX(parms.rclip) - dg.mScissor[0]; + dg.mScissor[3] = GLRenderer->ScreenToWindowY(parms.uclip) - dg.mScissor[1]; FSimpleVertex *ptr = &mVertices[dg.mVertIndex]; ptr->Set(x, y, 0, u1, v1, color); ptr++; From a03b2ff48b305064c7689419e2cc297b5ccdc1aa Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 15 Aug 2016 23:51:49 +0200 Subject: [PATCH 0801/1509] Change render buffers from RGBA16F to RGBA16 --- src/gl/renderer/gl_renderbuffers.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 976b80c48..abf32500a 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -266,7 +266,7 @@ void FGLRenderBuffers::CreateBloom(int width, int height) GLuint FGLRenderBuffers::GetHdrFormat() { - return ((gl.flags & RFL_NO_RGBA16F) != 0) ? GL_RGBA8 : GL_RGBA16F; + return ((gl.flags & RFL_NO_RGBA16F) != 0) ? GL_RGBA8 : GL_RGBA16; } //========================================================================== @@ -296,7 +296,7 @@ int FGLRenderBuffers::GetCvarSamples() GLuint FGLRenderBuffers::Create2DTexture(GLuint format, int width, int height) { - GLuint type = (format == GL_RGBA16F) ? GL_FLOAT : GL_UNSIGNED_BYTE; + GLuint type = (format == GL_RGBA16) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE; GLuint handle = 0; glGenTextures(1, &handle); glBindTexture(GL_TEXTURE_2D, handle); From a8d1197ea79549ea0fcade41e6390de7ce76496b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 16 Aug 2016 00:01:18 +0200 Subject: [PATCH 0802/1509] Make sure we never pass a negative value to pow, and optimize gamma uniform --- src/gl/renderer/gl_postprocess.cpp | 4 ++-- src/gl/shaders/gl_presentshader.cpp | 2 +- src/gl/shaders/gl_presentshader.h | 2 +- wadsrc/static/shaders/glsl/present.fp | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index b8553bde1..a53067d8b 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -306,13 +306,13 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) mPresentShader->InputTexture.Set(0); if (!applyGamma || framebuffer->IsHWGammaActive()) { - mPresentShader->Gamma.Set(1.0f); + mPresentShader->InvGamma.Set(1.0f); mPresentShader->Contrast.Set(1.0f); mPresentShader->Brightness.Set(0.0f); } else { - mPresentShader->Gamma.Set(clamp(Gamma, 0.1f, 4.f)); + mPresentShader->InvGamma.Set(1.0f / clamp(Gamma, 0.1f, 4.f)); mPresentShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); } diff --git a/src/gl/shaders/gl_presentshader.cpp b/src/gl/shaders/gl_presentshader.cpp index e40aa7a2c..426253639 100644 --- a/src/gl/shaders/gl_presentshader.cpp +++ b/src/gl/shaders/gl_presentshader.cpp @@ -60,7 +60,7 @@ void FPresentShader::Bind() mShader.SetAttribLocation(0, "PositionInProjection"); mShader.SetAttribLocation(1, "UV"); InputTexture.Init(mShader, "InputTexture"); - Gamma.Init(mShader, "Gamma"); + InvGamma.Init(mShader, "InvGamma"); Contrast.Init(mShader, "Contrast"); Brightness.Init(mShader, "Brightness"); Scale.Init(mShader, "UVScale"); diff --git a/src/gl/shaders/gl_presentshader.h b/src/gl/shaders/gl_presentshader.h index 513af41cc..b54fa2e36 100644 --- a/src/gl/shaders/gl_presentshader.h +++ b/src/gl/shaders/gl_presentshader.h @@ -9,7 +9,7 @@ public: void Bind(); FBufferedUniform1i InputTexture; - FBufferedUniform1f Gamma; + FBufferedUniform1f InvGamma; FBufferedUniform1f Contrast; FBufferedUniform1f Brightness; FBufferedUniform2f Scale; diff --git a/wadsrc/static/shaders/glsl/present.fp b/wadsrc/static/shaders/glsl/present.fp index 4a3f41840..53fc007b6 100644 --- a/wadsrc/static/shaders/glsl/present.fp +++ b/wadsrc/static/shaders/glsl/present.fp @@ -3,14 +3,14 @@ in vec2 TexCoord; out vec4 FragColor; uniform sampler2D InputTexture; -uniform float Gamma; +uniform float InvGamma; uniform float Contrast; uniform float Brightness; vec4 ApplyGamma(vec4 c) { - vec3 val = c.rgb * Contrast - (Contrast - 1.0) * 0.5; - val = pow(val, vec3(1.0 / Gamma)); + vec3 val = max(c.rgb * Contrast - (Contrast - 1.0) * 0.5, vec3(0.0)); + val = pow(val, vec3(InvGamma)); val += Brightness * 0.5; return vec4(val, c.a); } From 0e2d9affb26543a504cace9142354941a315964f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 16 Aug 2016 00:22:00 +0200 Subject: [PATCH 0803/1509] Make sure tonemap shader never takes the sqrt of a negative number Fix bug where the old hardcoded exposure bias was still being used in the uncharted2 tonemap --- wadsrc/static/shaders/glsl/tonemap.fp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wadsrc/static/shaders/glsl/tonemap.fp b/wadsrc/static/shaders/glsl/tonemap.fp index 35388b7b8..110cb6030 100644 --- a/wadsrc/static/shaders/glsl/tonemap.fp +++ b/wadsrc/static/shaders/glsl/tonemap.fp @@ -7,12 +7,14 @@ uniform float ExposureAdjustment; vec3 Linear(vec3 c) { + //c = max(c, vec3(0.0)); //return pow(c, 2.2); return c * c; // cheaper, but assuming gamma of 2.0 instead of 2.2 } vec3 sRGB(vec3 c) { + c = max(c, vec3(0.0)); //return pow(c, vec3(1.0 / 2.2)); return sqrt(c); // cheaper, but assuming gamma of 2.0 instead of 2.2 } @@ -56,8 +58,7 @@ vec3 Uncharted2Tonemap(vec3 x) vec3 Tonemap(vec3 color) { float W = 11.2; - float ExposureBias = 2.0; - vec3 curr = Uncharted2Tonemap(ExposureBias * color); + vec3 curr = Uncharted2Tonemap(color); vec3 whiteScale = vec3(1) / Uncharted2Tonemap(vec3(W)); return sRGB(curr * whiteScale); } From fa2bcebd51400779ac19aaeba0a696a25294f3cf Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 17 Aug 2016 16:48:11 +0200 Subject: [PATCH 0804/1509] Add KHR_debug and ARB_invalidate_subdata --- src/gl/system/gl_extlist.txt | 2 + src/gl/system/gl_load.c | 202 ++++++++++++++++++--------------- src/gl/system/gl_load.h | 210 ++++++++++++++++++++++++----------- 3 files changed, 264 insertions(+), 150 deletions(-) diff --git a/src/gl/system/gl_extlist.txt b/src/gl/system/gl_extlist.txt index df59c7a27..efa51ad01 100644 --- a/src/gl/system/gl_extlist.txt +++ b/src/gl/system/gl_extlist.txt @@ -12,3 +12,5 @@ EXT_framebuffer_object EXT_texture_compression_s3tc EXT_texture_filter_anisotropic EXT_texture_sRGB +KHR_debug +ARB_invalidate_subdata diff --git a/src/gl/system/gl_load.c b/src/gl/system/gl_load.c index aed4e0ff8..c686b60fc 100644 --- a/src/gl/system/gl_load.c +++ b/src/gl/system/gl_load.c @@ -87,15 +87,37 @@ static PROC WinGetProcAddress(const char *name) #endif #endif -int ogl_ext_ARB_texture_compression = ogl_LOAD_FAILED; -int ogl_ext_EXT_texture_compression_s3tc = ogl_LOAD_FAILED; +int ogl_ext_APPLE_client_storage = ogl_LOAD_FAILED; int ogl_ext_ARB_buffer_storage = ogl_LOAD_FAILED; int ogl_ext_ARB_shader_storage_buffer_object = ogl_LOAD_FAILED; -int ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; -int ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; -int ogl_ext_EXT_framebuffer_object = ogl_LOAD_FAILED; -int ogl_ext_APPLE_client_storage = ogl_LOAD_FAILED; +int ogl_ext_ARB_texture_compression = ogl_LOAD_FAILED; int ogl_ext_ARB_texture_rectangle = ogl_LOAD_FAILED; +int ogl_ext_EXT_framebuffer_object = ogl_LOAD_FAILED; +int ogl_ext_EXT_texture_compression_s3tc = ogl_LOAD_FAILED; +int ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; +int ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; +int ogl_ext_KHR_debug = ogl_LOAD_FAILED; +int ogl_ext_ARB_invalidate_subdata = ogl_LOAD_FAILED; + +void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum target, GLsizeiptr size, const void * data, GLbitfield flags) = NULL; + +static int Load_ARB_buffer_storage(void) +{ + int numFailed = 0; + _ptrc_glBufferStorage = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizeiptr, const void *, GLbitfield))IntGetProcAddress("glBufferStorage"); + if(!_ptrc_glBufferStorage) numFailed++; + return numFailed; +} + +void (CODEGEN_FUNCPTR *_ptrc_glShaderStorageBlockBinding)(GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding) = NULL; + +static int Load_ARB_shader_storage_buffer_object(void) +{ + int numFailed = 0; + _ptrc_glShaderStorageBlockBinding = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress("glShaderStorageBlockBinding"); + if(!_ptrc_glShaderStorageBlockBinding) numFailed++; + return numFailed; +} void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data) = NULL; @@ -125,26 +147,6 @@ static int Load_ARB_texture_compression(void) return numFailed; } -void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum target, GLsizeiptr size, const void * data, GLbitfield flags) = NULL; - -static int Load_ARB_buffer_storage(void) -{ - int numFailed = 0; - _ptrc_glBufferStorage = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizeiptr, const void *, GLbitfield))IntGetProcAddress("glBufferStorage"); - if(!_ptrc_glBufferStorage) numFailed++; - return numFailed; -} - -void (CODEGEN_FUNCPTR *_ptrc_glShaderStorageBlockBinding)(GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding) = NULL; - -static int Load_ARB_shader_storage_buffer_object(void) -{ - int numFailed = 0; - _ptrc_glShaderStorageBlockBinding = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress("glShaderStorageBlockBinding"); - if(!_ptrc_glShaderStorageBlockBinding) numFailed++; - return numFailed; -} - void (CODEGEN_FUNCPTR *_ptrc_glBindFramebufferEXT)(GLenum target, GLuint framebuffer) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbufferEXT)(GLenum target, GLuint renderbuffer) = NULL; GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatusEXT)(GLenum target) = NULL; @@ -203,6 +205,71 @@ static int Load_EXT_framebuffer_object(void) return numFailed; } +void (CODEGEN_FUNCPTR *_ptrc_glDebugMessageCallback)(GLDEBUGPROC callback, const void * userParam) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDebugMessageControl)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDebugMessageInsert)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glGetDebugMessageLog)(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetObjectLabel)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetObjectPtrLabel)(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPointerv)(GLenum pname, void ** params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glObjectLabel)(GLenum identifier, GLuint name, GLsizei length, const GLchar * label) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glObjectPtrLabel)(const void * ptr, GLsizei length, const GLchar * label) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPopDebugGroup)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPushDebugGroup)(GLenum source, GLuint id, GLsizei length, const GLchar * message) = NULL; + +static int Load_KHR_debug(void) +{ + int numFailed = 0; + _ptrc_glDebugMessageCallback = (void (CODEGEN_FUNCPTR *)(GLDEBUGPROC, const void *))IntGetProcAddress("glDebugMessageCallback"); + if(!_ptrc_glDebugMessageCallback) numFailed++; + _ptrc_glDebugMessageControl = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLsizei, const GLuint *, GLboolean))IntGetProcAddress("glDebugMessageControl"); + if(!_ptrc_glDebugMessageControl) numFailed++; + _ptrc_glDebugMessageInsert = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *))IntGetProcAddress("glDebugMessageInsert"); + if(!_ptrc_glDebugMessageInsert) numFailed++; + _ptrc_glGetDebugMessageLog = (GLuint (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLenum *, GLenum *, GLuint *, GLenum *, GLsizei *, GLchar *))IntGetProcAddress("glGetDebugMessageLog"); + if(!_ptrc_glGetDebugMessageLog) numFailed++; + _ptrc_glGetObjectLabel = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetObjectLabel"); + if(!_ptrc_glGetObjectLabel) numFailed++; + _ptrc_glGetObjectPtrLabel = (void (CODEGEN_FUNCPTR *)(const void *, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetObjectPtrLabel"); + if(!_ptrc_glGetObjectPtrLabel) numFailed++; + _ptrc_glGetPointerv = (void (CODEGEN_FUNCPTR *)(GLenum, void **))IntGetProcAddress("glGetPointerv"); + if(!_ptrc_glGetPointerv) numFailed++; + _ptrc_glObjectLabel = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLsizei, const GLchar *))IntGetProcAddress("glObjectLabel"); + if(!_ptrc_glObjectLabel) numFailed++; + _ptrc_glObjectPtrLabel = (void (CODEGEN_FUNCPTR *)(const void *, GLsizei, const GLchar *))IntGetProcAddress("glObjectPtrLabel"); + if(!_ptrc_glObjectPtrLabel) numFailed++; + _ptrc_glPopDebugGroup = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glPopDebugGroup"); + if(!_ptrc_glPopDebugGroup) numFailed++; + _ptrc_glPushDebugGroup = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLsizei, const GLchar *))IntGetProcAddress("glPushDebugGroup"); + if(!_ptrc_glPushDebugGroup) numFailed++; + return numFailed; +} + +void (CODEGEN_FUNCPTR *_ptrc_glInvalidateBufferData)(GLuint buffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInvalidateBufferSubData)(GLuint buffer, GLintptr offset, GLsizeiptr length) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInvalidateFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum * attachments) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInvalidateSubFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInvalidateTexImage)(GLuint texture, GLint level) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInvalidateTexSubImage)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth) = NULL; + +static int Load_ARB_invalidate_subdata(void) +{ + int numFailed = 0; + _ptrc_glInvalidateBufferData = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glInvalidateBufferData"); + if(!_ptrc_glInvalidateBufferData) numFailed++; + _ptrc_glInvalidateBufferSubData = (void (CODEGEN_FUNCPTR *)(GLuint, GLintptr, GLsizeiptr))IntGetProcAddress("glInvalidateBufferSubData"); + if(!_ptrc_glInvalidateBufferSubData) numFailed++; + _ptrc_glInvalidateFramebuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLenum *))IntGetProcAddress("glInvalidateFramebuffer"); + if(!_ptrc_glInvalidateFramebuffer) numFailed++; + _ptrc_glInvalidateSubFramebuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLenum *, GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glInvalidateSubFramebuffer"); + if(!_ptrc_glInvalidateSubFramebuffer) numFailed++; + _ptrc_glInvalidateTexImage = (void (CODEGEN_FUNCPTR *)(GLuint, GLint))IntGetProcAddress("glInvalidateTexImage"); + if(!_ptrc_glInvalidateTexImage) numFailed++; + _ptrc_glInvalidateTexSubImage = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei))IntGetProcAddress("glInvalidateTexSubImage"); + if(!_ptrc_glInvalidateTexSubImage) numFailed++; + return numFailed; +} + void (CODEGEN_FUNCPTR *_ptrc_glAccum)(GLenum op, GLfloat value) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glAlphaFunc)(GLenum func, GLfloat ref) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glBegin)(GLenum mode) = NULL; @@ -525,7 +592,6 @@ void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum mode, GLsizei count, GLenum void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagPointer)(GLsizei stride, const void * pointer) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glEnableClientState)(GLenum ren_array) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei n, GLuint * textures) = NULL; -void (CODEGEN_FUNCPTR *_ptrc_glGetPointerv)(GLenum pname, void ** params) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glIndexPointer)(GLenum type, GLsizei stride, const void * pointer) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glIndexub)(GLubyte c) = NULL; void (CODEGEN_FUNCPTR *_ptrc_glIndexubv)(const GLubyte * c) = NULL; @@ -2311,19 +2377,21 @@ typedef struct ogl_StrToExtMap_s PFN_LOADFUNCPOINTERS LoadExtension; } ogl_StrToExtMap; -static ogl_StrToExtMap ExtensionMap[9] = { - {"GL_ARB_texture_compression", &ogl_ext_ARB_texture_compression, Load_ARB_texture_compression}, - {"GL_EXT_texture_compression_s3tc", &ogl_ext_EXT_texture_compression_s3tc, NULL}, +static ogl_StrToExtMap ExtensionMap[11] = { + {"GL_APPLE_client_storage", &ogl_ext_APPLE_client_storage, NULL}, {"GL_ARB_buffer_storage", &ogl_ext_ARB_buffer_storage, Load_ARB_buffer_storage}, {"GL_ARB_shader_storage_buffer_object", &ogl_ext_ARB_shader_storage_buffer_object, Load_ARB_shader_storage_buffer_object}, - {"GL_EXT_texture_sRGB", &ogl_ext_EXT_texture_sRGB, NULL}, - {"GL_EXT_texture_filter_anisotropic", &ogl_ext_EXT_texture_filter_anisotropic, NULL}, - {"GL_EXT_framebuffer_object", &ogl_ext_EXT_framebuffer_object, Load_EXT_framebuffer_object}, - {"GL_APPLE_client_storage", &ogl_ext_APPLE_client_storage, NULL}, + {"GL_ARB_texture_compression", &ogl_ext_ARB_texture_compression, Load_ARB_texture_compression}, {"GL_ARB_texture_rectangle", &ogl_ext_ARB_texture_rectangle, NULL}, + {"GL_EXT_framebuffer_object", &ogl_ext_EXT_framebuffer_object, Load_EXT_framebuffer_object}, + {"GL_EXT_texture_compression_s3tc", &ogl_ext_EXT_texture_compression_s3tc, NULL}, + {"GL_EXT_texture_filter_anisotropic", &ogl_ext_EXT_texture_filter_anisotropic, NULL}, + {"GL_EXT_texture_sRGB", &ogl_ext_EXT_texture_sRGB, NULL}, + {"GL_KHR_debug", &ogl_ext_KHR_debug, Load_KHR_debug}, + {"GL_ARB_invalidate_subdata", &ogl_ext_ARB_invalidate_subdata, Load_ARB_invalidate_subdata}, }; -static int g_extensionMapSize = 9; +static int g_extensionMapSize = 11; static ogl_StrToExtMap *FindExtEntry(const char *extensionName) { @@ -2340,15 +2408,17 @@ static ogl_StrToExtMap *FindExtEntry(const char *extensionName) static void ClearExtensionVars(void) { - ogl_ext_ARB_texture_compression = ogl_LOAD_FAILED; - ogl_ext_EXT_texture_compression_s3tc = ogl_LOAD_FAILED; + ogl_ext_APPLE_client_storage = ogl_LOAD_FAILED; ogl_ext_ARB_buffer_storage = ogl_LOAD_FAILED; ogl_ext_ARB_shader_storage_buffer_object = ogl_LOAD_FAILED; - ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; - ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; - ogl_ext_EXT_framebuffer_object = ogl_LOAD_FAILED; - ogl_ext_APPLE_client_storage = ogl_LOAD_FAILED; + ogl_ext_ARB_texture_compression = ogl_LOAD_FAILED; ogl_ext_ARB_texture_rectangle = ogl_LOAD_FAILED; + ogl_ext_EXT_framebuffer_object = ogl_LOAD_FAILED; + ogl_ext_EXT_texture_compression_s3tc = ogl_LOAD_FAILED; + ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; + ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; + ogl_ext_KHR_debug = ogl_LOAD_FAILED; + ogl_ext_ARB_invalidate_subdata = ogl_LOAD_FAILED; } @@ -2377,47 +2447,11 @@ static void LoadExtByName(const char *extensionName) } } -static void ProcExtsFromExtString(const char *strExtList) -{ - size_t iExtListLen = strlen(strExtList); - const char *strExtListEnd = strExtList + iExtListLen; - const char *strCurrPos = strExtList; - char strWorkBuff[256]; - while(*strCurrPos) - { - /*Get the extension at our position.*/ - int iStrLen = 0; - const char *strEndStr = strchr(strCurrPos, ' '); - int iStop = 0; - if(strEndStr == NULL) - { - strEndStr = strExtListEnd; - iStop = 1; - } - - iStrLen = (int)((ptrdiff_t)strEndStr - (ptrdiff_t)strCurrPos); - - if(iStrLen > 255) - return; - - strncpy(strWorkBuff, strCurrPos, iStrLen); - strWorkBuff[iStrLen] = '\0'; - - LoadExtByName(strWorkBuff); - - strCurrPos = strEndStr + 1; - if(iStop) break; - } -} - -static int ProcExtsFromExtList(void) +static void ProcExtsFromExtList(void) { GLint iLoop; GLint iNumExtensions = 0; - - if (_ptrc_glGetStringi == NULL) return 0; - _ptrc_glGetIntegerv(GL_NUM_EXTENSIONS, &iNumExtensions); for(iLoop = 0; iLoop < iNumExtensions; iLoop++) @@ -2425,8 +2459,6 @@ static int ProcExtsFromExtList(void) const char *strExtensionName = (const char *)_ptrc_glGetStringi(GL_EXTENSIONS, iLoop); LoadExtByName(strExtensionName); } - - return iNumExtensions; } int ogl_LoadFunctions() @@ -2437,15 +2469,9 @@ int ogl_LoadFunctions() _ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress("glGetIntegerv"); if(!_ptrc_glGetIntegerv) return ogl_LOAD_FAILED; _ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi"); + if(!_ptrc_glGetStringi) return ogl_LOAD_FAILED; - if (0 == ProcExtsFromExtList()) - { - _ptrc_glGetString = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGetString"); - if(!_ptrc_glGetString) return ogl_LOAD_FAILED; - - ProcExtsFromExtString((const char *)_ptrc_glGetString(GL_EXTENSIONS)); - } - + ProcExtsFromExtList(); numFailed = Load_Version_3_3(); if(numFailed == 0) diff --git a/src/gl/system/gl_load.h b/src/gl/system/gl_load.h index 3360b8777..892709ccd 100644 --- a/src/gl/system/gl_load.h +++ b/src/gl/system/gl_load.h @@ -153,32 +153,19 @@ typedef unsigned int GLhandleARB; extern "C" { #endif /*__cplusplus*/ -extern int ogl_ext_ARB_texture_compression; -extern int ogl_ext_EXT_texture_compression_s3tc; +extern int ogl_ext_APPLE_client_storage; extern int ogl_ext_ARB_buffer_storage; extern int ogl_ext_ARB_shader_storage_buffer_object; -extern int ogl_ext_EXT_texture_sRGB; -extern int ogl_ext_EXT_texture_filter_anisotropic; -extern int ogl_ext_EXT_framebuffer_object; -extern int ogl_ext_APPLE_client_storage; +extern int ogl_ext_ARB_texture_compression; extern int ogl_ext_ARB_texture_rectangle; +extern int ogl_ext_EXT_framebuffer_object; +extern int ogl_ext_EXT_texture_compression_s3tc; +extern int ogl_ext_EXT_texture_filter_anisotropic; +extern int ogl_ext_EXT_texture_sRGB; +extern int ogl_ext_KHR_debug; +extern int ogl_ext_ARB_invalidate_subdata; -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF - -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 #define GL_BUFFER_IMMUTABLE_STORAGE 0x821F #define GL_BUFFER_STORAGE_FLAGS 0x8220 @@ -208,25 +195,22 @@ extern int ogl_ext_ARB_texture_rectangle; #define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 #define GL_SHADER_STORAGE_BUFFER_START 0x90D4 -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB_EXT 0x8C40 +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 #define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 #define GL_COLOR_ATTACHMENT10_EXT 0x8CEA @@ -280,12 +264,72 @@ extern int ogl_ext_ARB_texture_rectangle; #define GL_STENCIL_INDEX4_EXT 0x8D47 #define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE + +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB_EXT 0x8C40 + +#define GL_BUFFER 0x82E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DISPLAY_LIST 0x82E7 +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_PROGRAM 0x82E2 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_QUERY 0x82E3 +#define GL_SAMPLER 0x82E6 +#define GL_SHADER 0x82E1 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_VERTEX_ARRAY 0x8074 #define GL_2D 0x0600 #define GL_2_BYTES 0x1407 @@ -722,8 +766,8 @@ extern int ogl_ext_ARB_texture_rectangle; #define GL_SRC_ALPHA 0x0302 #define GL_SRC_ALPHA_SATURATE 0x0308 #define GL_SRC_COLOR 0x0300 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 +/*Copied GL_STACK_OVERFLOW From: KHR_debug*/ +/*Copied GL_STACK_UNDERFLOW From: KHR_debug*/ #define GL_STENCIL 0x1802 #define GL_STENCIL_BITS 0x0D57 #define GL_STENCIL_BUFFER_BIT 0x00000400 @@ -804,7 +848,7 @@ extern int ogl_ext_ARB_texture_rectangle; #define GL_V3F 0x2A21 #define GL_VENDOR 0x1F00 #define GL_VERSION 0x1F02 -#define GL_VERTEX_ARRAY 0x8074 +/*Copied GL_VERTEX_ARRAY From: KHR_debug*/ #define GL_VERTEX_ARRAY_POINTER 0x808E #define GL_VERTEX_ARRAY_SIZE 0x807A #define GL_VERTEX_ARRAY_STRIDE 0x807C @@ -1544,6 +1588,19 @@ extern int ogl_ext_ARB_texture_rectangle; #define GL_TIME_ELAPSED 0x88BF #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE + +#ifndef GL_ARB_buffer_storage +#define GL_ARB_buffer_storage 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum target, GLsizeiptr size, const void * data, GLbitfield flags); +#define glBufferStorage _ptrc_glBufferStorage +#endif /*GL_ARB_buffer_storage*/ + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glShaderStorageBlockBinding)(GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +#define glShaderStorageBlockBinding _ptrc_glShaderStorageBlockBinding +#endif /*GL_ARB_shader_storage_buffer_object*/ + #ifndef GL_ARB_texture_compression #define GL_ARB_texture_compression 1 extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data); @@ -1563,20 +1620,6 @@ extern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImageARB)(GLenum target, G #endif /*GL_ARB_texture_compression*/ -#ifndef GL_ARB_buffer_storage -#define GL_ARB_buffer_storage 1 -extern void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum target, GLsizeiptr size, const void * data, GLbitfield flags); -#define glBufferStorage _ptrc_glBufferStorage -#endif /*GL_ARB_buffer_storage*/ - -#ifndef GL_ARB_shader_storage_buffer_object -#define GL_ARB_shader_storage_buffer_object 1 -extern void (CODEGEN_FUNCPTR *_ptrc_glShaderStorageBlockBinding)(GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); -#define glShaderStorageBlockBinding _ptrc_glShaderStorageBlockBinding -#endif /*GL_ARB_shader_storage_buffer_object*/ - - - #ifndef GL_EXT_framebuffer_object #define GL_EXT_framebuffer_object 1 extern void (CODEGEN_FUNCPTR *_ptrc_glBindFramebufferEXT)(GLenum target, GLuint framebuffer); @@ -1617,6 +1660,49 @@ extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageEXT)(GLenum target, GLe + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glDebugMessageCallback)(GLDEBUGPROC callback, const void * userParam); +#define glDebugMessageCallback _ptrc_glDebugMessageCallback +extern void (CODEGEN_FUNCPTR *_ptrc_glDebugMessageControl)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled); +#define glDebugMessageControl _ptrc_glDebugMessageControl +extern void (CODEGEN_FUNCPTR *_ptrc_glDebugMessageInsert)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf); +#define glDebugMessageInsert _ptrc_glDebugMessageInsert +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glGetDebugMessageLog)(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog); +#define glGetDebugMessageLog _ptrc_glGetDebugMessageLog +extern void (CODEGEN_FUNCPTR *_ptrc_glGetObjectLabel)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label); +#define glGetObjectLabel _ptrc_glGetObjectLabel +extern void (CODEGEN_FUNCPTR *_ptrc_glGetObjectPtrLabel)(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label); +#define glGetObjectPtrLabel _ptrc_glGetObjectPtrLabel +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPointerv)(GLenum pname, void ** params); +#define glGetPointerv _ptrc_glGetPointerv +extern void (CODEGEN_FUNCPTR *_ptrc_glObjectLabel)(GLenum identifier, GLuint name, GLsizei length, const GLchar * label); +#define glObjectLabel _ptrc_glObjectLabel +extern void (CODEGEN_FUNCPTR *_ptrc_glObjectPtrLabel)(const void * ptr, GLsizei length, const GLchar * label); +#define glObjectPtrLabel _ptrc_glObjectPtrLabel +extern void (CODEGEN_FUNCPTR *_ptrc_glPopDebugGroup)(void); +#define glPopDebugGroup _ptrc_glPopDebugGroup +extern void (CODEGEN_FUNCPTR *_ptrc_glPushDebugGroup)(GLenum source, GLuint id, GLsizei length, const GLchar * message); +#define glPushDebugGroup _ptrc_glPushDebugGroup +#endif /*GL_KHR_debug*/ + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glInvalidateBufferData)(GLuint buffer); +#define glInvalidateBufferData _ptrc_glInvalidateBufferData +extern void (CODEGEN_FUNCPTR *_ptrc_glInvalidateBufferSubData)(GLuint buffer, GLintptr offset, GLsizeiptr length); +#define glInvalidateBufferSubData _ptrc_glInvalidateBufferSubData +extern void (CODEGEN_FUNCPTR *_ptrc_glInvalidateFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum * attachments); +#define glInvalidateFramebuffer _ptrc_glInvalidateFramebuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glInvalidateSubFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height); +#define glInvalidateSubFramebuffer _ptrc_glInvalidateSubFramebuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glInvalidateTexImage)(GLuint texture, GLint level); +#define glInvalidateTexImage _ptrc_glInvalidateTexImage +extern void (CODEGEN_FUNCPTR *_ptrc_glInvalidateTexSubImage)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +#define glInvalidateTexSubImage _ptrc_glInvalidateTexSubImage +#endif /*GL_ARB_invalidate_subdata*/ + extern void (CODEGEN_FUNCPTR *_ptrc_glAccum)(GLenum op, GLfloat value); #define glAccum _ptrc_glAccum extern void (CODEGEN_FUNCPTR *_ptrc_glAlphaFunc)(GLenum func, GLfloat ref); From 5eeac830eb5de7b5f2aa345af11cfd044e844b07 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 17 Aug 2016 17:37:13 +0200 Subject: [PATCH 0805/1509] Clear and InvalidateFramebuffer optimization --- src/gl/scene/gl_scene.cpp | 14 +++++++------- src/gl/system/gl_interface.cpp | 2 ++ src/gl/system/gl_interface.h | 4 +++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 91f01adf7..b96b1d3b6 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -174,18 +174,18 @@ void FGLRenderer::Set3DViewport(bool mainview) mBuffers->BindSceneFB(); } + // Always clear all buffers with scissor test disabled. + // This is faster on newer hardware because it allows the GPU to skip + // reading from slower memory where the full buffers are stored. + glDisable(GL_SCISSOR_TEST); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + const auto &bounds = mSceneViewport; glViewport(bounds.left, bounds.top, bounds.width, bounds.height); glScissor(bounds.left, bounds.top, bounds.width, bounds.height); glEnable(GL_SCISSOR_TEST); - - #ifdef _DEBUG - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - #else - glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - #endif glEnable(GL_MULTISAMPLE); glEnable(GL_DEPTH_TEST); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 6176a2be9..8c1e4cd9b 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -244,6 +244,8 @@ void gl_LoadExtensions() gl.buffermethod = BM_PERSISTENT; } + if (gl.version >= 4.3f || CheckExtension("GL_ARB_invalidate_subdata")) gl.flags |= RFL_INVALIDATE_BUFFER; + const char *lm = Args->CheckValue("-lightmethod"); if (lm != NULL) { diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index fbe4e09c8..11b0573e5 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -23,7 +23,9 @@ enum RenderFlags RFL_NO_RGBA16F = 32, RFL_NO_DEPTHSTENCIL = 64, - RFL_NO_CLIP_PLANES = 128 + RFL_NO_CLIP_PLANES = 128, + + RFL_INVALIDATE_BUFFER = 256 }; enum TexMode From 3c08f5ae481527a00c99ce1953cf0989f9457327 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 17 Aug 2016 17:37:49 +0200 Subject: [PATCH 0806/1509] Fix multisample count bug --- src/gl/renderer/gl_renderbuffers.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index abf32500a..c4f1b5fee 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -280,12 +280,7 @@ int FGLRenderBuffers::GetCvarSamples() int maxSamples = 0; glGetIntegerv(GL_MAX_SAMPLES, &maxSamples); - int samples = clamp((int)gl_multisample, 0, maxSamples); - - int count; - for (count = 0; samples > 0; count++) - samples >>= 1; - return count; + return clamp((int)gl_multisample, 0, maxSamples); } //========================================================================== @@ -452,6 +447,13 @@ void FGLRenderBuffers::BlitSceneToTexture() glBindFramebuffer(GL_READ_FRAMEBUFFER, mSceneFB); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mPipelineFB[mCurrentPipelineTexture]); glBlitFramebuffer(0, 0, mWidth, mHeight, 0, 0, mWidth, mHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST); + + if ((gl.flags & RFL_INVALIDATE_BUFFER) == 0) + { + GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT }; + glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 2, attachments); + } + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); } From fc01a6b832e6b36edee28b24789e074d123f8bfb Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 17 Aug 2016 17:59:47 +0200 Subject: [PATCH 0807/1509] Only query for GL_MAX_SAMPLES once --- src/gl/renderer/gl_renderbuffers.cpp | 17 ++--------------- src/gl/renderer/gl_renderbuffers.h | 2 +- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index c4f1b5fee..f4ca9d935 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -65,6 +65,7 @@ CVAR(Bool, gl_renderbuffers, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); FGLRenderBuffers::FGLRenderBuffers() { glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&mOutputFB); + glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples); } //========================================================================== @@ -147,7 +148,7 @@ void FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei if (width <= 0 || height <= 0) I_FatalError("Requested invalid render buffer sizes: screen = %dx%d", width, height); - int samples = GetCvarSamples(); + int samples = clamp((int)gl_multisample, 0, mMaxSamples); GLint activeTex; GLint textureBinding; @@ -269,20 +270,6 @@ GLuint FGLRenderBuffers::GetHdrFormat() return ((gl.flags & RFL_NO_RGBA16F) != 0) ? GL_RGBA8 : GL_RGBA16; } -//========================================================================== -// -// Converts the CVAR multisample value into a valid level for OpenGL -// -//========================================================================== - -int FGLRenderBuffers::GetCvarSamples() -{ - int maxSamples = 0; - glGetIntegerv(GL_MAX_SAMPLES, &maxSamples); - - return clamp((int)gl_multisample, 0, maxSamples); -} - //========================================================================== // // Creates a 2D texture defaulting to linear filtering and clamp to edge diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 4d2c551c2..0a604766d 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -59,12 +59,12 @@ private: void DeleteRenderBuffer(GLuint &handle); void DeleteFrameBuffer(GLuint &handle); - int GetCvarSamples(); GLuint GetHdrFormat(); int mWidth = 0; int mHeight = 0; int mSamples = 0; + int mMaxSamples = 0; int mBloomWidth = 0; int mBloomHeight = 0; From 2cb5f1740ecd0565d6071a024a24e0b08e770f87 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 17 Aug 2016 20:33:10 +0200 Subject: [PATCH 0808/1509] Add OpenGL debug messages to the console --- src/CMakeLists.txt | 1 + src/gl/system/gl_cvars.h | 3 + src/gl/system/gl_debug.cpp | 249 +++++++++++++++++++++++++++++++ src/gl/system/gl_debug.h | 31 ++++ src/gl/system/gl_framebuffer.cpp | 4 + src/gl/system/gl_framebuffer.h | 5 + 6 files changed, 293 insertions(+) create mode 100644 src/gl/system/gl_debug.cpp create mode 100644 src/gl/system/gl_debug.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e002fc66f..c74c9534d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1117,6 +1117,7 @@ set( FASTMATH_SOURCES gl/shaders/gl_lensshader.cpp gl/system/gl_interface.cpp gl/system/gl_framebuffer.cpp + gl/system/gl_debug.cpp gl/system/gl_menu.cpp gl/system/gl_wipe.cpp gl/system/gl_load.c diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index 4b28bb667..0c31f53a8 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -54,4 +54,7 @@ EXTERN_CVAR(Float, gl_lens_k) EXTERN_CVAR(Float, gl_lens_kcube) EXTERN_CVAR(Float, gl_lens_chromatic) +EXTERN_CVAR(Int, gl_debug_level) +EXTERN_CVAR(Bool, gl_debug_breakpoint) + #endif // _GL_INTERN_H diff --git a/src/gl/system/gl_debug.cpp b/src/gl/system/gl_debug.cpp new file mode 100644 index 000000000..5c3e60276 --- /dev/null +++ b/src/gl/system/gl_debug.cpp @@ -0,0 +1,249 @@ +/* +** gl_debig.cpp +** OpenGL debugging support functions +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "templates.h" +#include "gl/system/gl_system.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_debug.h" + +#ifndef _MSC_VER +#include +#endif + +CVAR(Int, gl_debug_level, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR(Bool, gl_debug_breakpoint, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); + +//----------------------------------------------------------------------------- +// +// Updates OpenGL debugging state +// +//----------------------------------------------------------------------------- + +void FGLDebug::Update() +{ + SetupBreakpointMode(); + UpdateLoggingLevel(); + OutputMessageLog(); +} + +//----------------------------------------------------------------------------- +// +// Turns on synchronous debugging on and off based on gl_debug_breakpoint +// +// Allows getting the debugger to break exactly at the OpenGL function emitting +// a message. +// +//----------------------------------------------------------------------------- + +void FGLDebug::SetupBreakpointMode() +{ + if (mBreakpointMode != gl_debug_breakpoint) + { + if (gl_debug_breakpoint) + { + glDebugMessageCallback(&FGLDebug::DebugCallback, this); + glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); + } + else + { + glDebugMessageCallback(nullptr, nullptr); + glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS); + } + mBreakpointMode = gl_debug_breakpoint; + } +} + +//----------------------------------------------------------------------------- +// +// Tells OpenGL which debug messages we are interested in +// +//----------------------------------------------------------------------------- + +void FGLDebug::UpdateLoggingLevel() +{ + int level = gl_debug_level; + if (level != mCurrentLevel) + { + glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH, 0, nullptr, level > 0); + glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, 0, nullptr, level > 1); + glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW, 0, nullptr, level > 2); + glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_NOTIFICATION, 0, nullptr, level > 3); + mCurrentLevel = level; + } +} + +//----------------------------------------------------------------------------- +// +// Prints all logged messages to the console +// +//----------------------------------------------------------------------------- + +void FGLDebug::OutputMessageLog() +{ + if (mCurrentLevel <= 0) + return; + + GLint maxDebugMessageLength = 0; + glGetIntegerv(GL_MAX_DEBUG_MESSAGE_LENGTH, &maxDebugMessageLength); + + const int maxMessages = 50; + const int messageLogSize = maxMessages * maxDebugMessageLength; + + TArray sources, types, severities; + TArray ids; + TArray lengths; + TArray messageLog; + + sources.Resize(maxMessages); + types.Resize(maxMessages); + severities.Resize(maxMessages); + ids.Resize(maxMessages); + lengths.Resize(maxMessages); + messageLog.Resize(messageLogSize); + + while (true) + { + GLuint numMessages = glGetDebugMessageLog(maxMessages, messageLogSize, &sources[0], &types[0], &ids[0], &severities[0], &lengths[0], &messageLog[0]); + if (numMessages <= 0) break; + + GLsizei offset = 0; + for (GLuint i = 0; i < numMessages; i++) + { + PrintMessage(sources[i], types[i], ids[i], severities[i], lengths[i], &messageLog[offset]); + offset += lengths[i]; + } + } +} + +//----------------------------------------------------------------------------- +// +// Print a single message to the console +// +//----------------------------------------------------------------------------- + +void FGLDebug::PrintMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message) +{ + static int messagesPrinted = 0; + messagesPrinted++; + if (messagesPrinted == 50) + { + Printf("Max OpenGL debug messages reached. Suppressing further output.\n"); + } + else if (messagesPrinted < 50) + { + FString msg(message, length); + FString sourceStr = SourceToString(source); + FString typeStr = TypeToString(type); + FString severityStr = SeverityToString(severity); + Printf("%s [%s] %s: %s\n", severityStr.GetChars(), sourceStr.GetChars(), typeStr.GetChars(), msg.GetChars()); + } +} + +//----------------------------------------------------------------------------- +// +// OpenGL callback function used when synchronous debugging is enabled +// +//----------------------------------------------------------------------------- + +void FGLDebug::DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) +{ + PrintMessage(source, type, id, severity, length, message); + +#ifdef _MSC_VER + DebugBreak(); +#else + raise(SIGTRAP); +#endif +} + +//----------------------------------------------------------------------------- +// +// Enum to string helpers +// +//----------------------------------------------------------------------------- + +FString FGLDebug::SourceToString(GLenum source) +{ + FString s; + switch (source) + { + case GL_DEBUG_SOURCE_API: s = "api"; break; + case GL_DEBUG_SOURCE_WINDOW_SYSTEM: s = "window system"; break; + case GL_DEBUG_SOURCE_SHADER_COMPILER: s = "shader compiler"; break; + case GL_DEBUG_SOURCE_THIRD_PARTY: s = "third party"; break; + case GL_DEBUG_SOURCE_APPLICATION: s = "application"; break; + case GL_DEBUG_SOURCE_OTHER: s = "other"; break; + default: s.Format("%d", (int)source); + } + return s; +} + +FString FGLDebug::TypeToString(GLenum type) +{ + FString s; + switch (type) + { + case GL_DEBUG_TYPE_ERROR: s = "error"; break; + case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: s = "deprecated"; break; + case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: s = "undefined"; break; + case GL_DEBUG_TYPE_PORTABILITY: s = "portability"; break; + case GL_DEBUG_TYPE_PERFORMANCE: s = "performance"; break; + case GL_DEBUG_TYPE_MARKER: s = "marker"; break; + case GL_DEBUG_TYPE_PUSH_GROUP: s = "push group"; break; + case GL_DEBUG_TYPE_POP_GROUP: s = "pop group"; break; + case GL_DEBUG_TYPE_OTHER: s = "other"; break; + default: s.Format("%d", (int)type); + } + return s; +} + +FString FGLDebug::SeverityToString(GLenum severity) +{ + FString s; + switch (severity) + { + case GL_DEBUG_SEVERITY_LOW: s = "low severity"; break; + case GL_DEBUG_SEVERITY_MEDIUM: s = "medium severity"; break; + case GL_DEBUG_SEVERITY_HIGH: s = "high severity"; break; + case GL_DEBUG_SEVERITY_NOTIFICATION: s = "notification"; break; + default: s.Format("%d", (int)severity); + } + return s; +} diff --git a/src/gl/system/gl_debug.h b/src/gl/system/gl_debug.h new file mode 100644 index 000000000..ce919cebd --- /dev/null +++ b/src/gl/system/gl_debug.h @@ -0,0 +1,31 @@ +#ifndef __GL_DEBUG_H +#define __GL_DEBUG_H + +#include +#include "gl/system/gl_interface.h" +#include "c_cvars.h" +#include "r_defs.h" + +class FGLDebug +{ +public: + void Update(); + +private: + void SetupBreakpointMode(); + void UpdateLoggingLevel(); + void OutputMessageLog(); + + static void PrintMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message); + + static void APIENTRY DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam); + + static FString SourceToString(GLenum source); + static FString TypeToString(GLenum type); + static FString SeverityToString(GLenum severity); + + GLenum mCurrentLevel = 0; + bool mBreakpointMode = false; +}; + +#endif diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 096a33393..c74009e1f 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -65,6 +65,7 @@ #include "gl/utility/gl_templates.h" #include "gl/gl_functions.h" #include "gl/renderer/gl_2ddrawer.h" +#include "gl_debug.h" IMPLEMENT_CLASS(OpenGLFrameBuffer) EXTERN_CVAR (Float, vid_brightness) @@ -105,6 +106,8 @@ OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int LastCamera = NULL; InitializeState(); + mDebug = std::make_shared(); + mDebug->Update(); gl_SetupMenu(); gl_GenerateGlobalBrightmapFromColormap(); DoSetGamma(); @@ -219,6 +222,7 @@ void OpenGLFrameBuffer::Swap() Finish.Unclock(); swapped = true; FHardwareTexture::UnbindAll(); + mDebug->Update(); } //=========================================================================== diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index d648da30c..5315bb0a9 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -6,8 +6,11 @@ #include "win32gliface.h" #endif +#include + class FHardwareTexture; class FSimpleVertexBuffer; +class FGLDebug; extern long gl_frameMS; extern long gl_frameCount; @@ -117,6 +120,8 @@ private: bool HWGammaActive = false; + std::shared_ptr mDebug; + public: AActor * LastCamera; int palette_brightness; From 0c2db5447c1ab180b16473e04b731ae405ec83a4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 17 Aug 2016 20:57:00 +0200 Subject: [PATCH 0809/1509] Save gl_debug in ini file and add support in Linux --- src/posix/sdl/sdlglvideo.cpp | 7 +++++++ src/win32/win32gliface.cpp | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index d79dfb94a..29c96d3ea 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -58,6 +58,11 @@ CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ Printf("This won't take effect until " GAMENAME " is restarted.\n"); } +CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + Printf("This won't take effect until " GAMENAME " is restarted.\n"); +} + // PRIVATE DATA DEFINITIONS ------------------------------------------------ // Dummy screen sizes to pass when windowed @@ -289,6 +294,8 @@ bool SDLGLVideo::SetupPixelFormat(bool allowsoftware, int multisample) SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample ); } + if (gl_debug) + SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); return true; } diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 4f8c4d49b..2edd89631 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -45,7 +45,10 @@ CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ Printf("This won't take effect until " GAMENAME " is restarted.\n"); } -CVAR(Bool, gl_debug, false, 0) +CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + Printf("This won't take effect until " GAMENAME " is restarted.\n"); +} EXTERN_CVAR(Bool, vr_enable_quadbuffered) EXTERN_CVAR(Int, vid_refreshrate) From a37225b81e04c161a3bf652fab67ff635e823c19 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 17 Aug 2016 21:25:03 +0200 Subject: [PATCH 0810/1509] Don't debug break on notifications --- src/gl/system/gl_debug.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gl/system/gl_debug.cpp b/src/gl/system/gl_debug.cpp index 5c3e60276..984893ddc 100644 --- a/src/gl/system/gl_debug.cpp +++ b/src/gl/system/gl_debug.cpp @@ -186,11 +186,14 @@ void FGLDebug::DebugCallback(GLenum source, GLenum type, GLuint id, GLenum sever { PrintMessage(source, type, id, severity, length, message); + if (severity != GL_DEBUG_SEVERITY_NOTIFICATION) + { #ifdef _MSC_VER - DebugBreak(); + DebugBreak(); #else - raise(SIGTRAP); + raise(SIGTRAP); #endif + } } //----------------------------------------------------------------------------- From 2825bd496712be25fbc2dd176f707b585698c20f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 17 Aug 2016 21:25:31 +0200 Subject: [PATCH 0811/1509] Fix invalid value error --- src/gl/renderer/gl_renderbuffers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index f4ca9d935..a3433c075 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -178,7 +178,7 @@ void FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei mBloomHeight = sceneHeight; } - glBindTexture(GL_TEXTURE_BINDING_2D, textureBinding); + glBindTexture(GL_TEXTURE_2D, textureBinding); glActiveTexture(activeTex); glBindRenderbuffer(GL_RENDERBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0); From d380d765c98e5046b80e84b856880c8c49bc728f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 17 Aug 2016 23:18:47 +0200 Subject: [PATCH 0812/1509] OpenGL object labels and debug groups --- src/gl/renderer/gl_postprocess.cpp | 15 +++++++++ src/gl/renderer/gl_renderbuffers.cpp | 45 ++++++++++++++----------- src/gl/renderer/gl_renderbuffers.h | 12 +++---- src/gl/renderer/gl_renderer.cpp | 8 ++++- src/gl/shaders/gl_shader.cpp | 4 +++ src/gl/shaders/gl_shaderprogram.cpp | 4 +++ src/gl/system/gl_debug.cpp | 49 ++++++++++++++++++++++++++++ src/gl/system/gl_debug.h | 6 ++++ src/gl/system/gl_wipe.cpp | 6 ++-- src/gl/textures/gl_hwtexture.cpp | 4 ++- src/gl/textures/gl_hwtexture.h | 2 +- src/gl/textures/gl_material.cpp | 2 +- src/gl/textures/gl_samplers.cpp | 8 +++++ 13 files changed, 133 insertions(+), 32 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index a53067d8b..5f523e9eb 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -59,6 +59,7 @@ #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_cvars.h" +#include "gl/system/gl_debug.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderbuffers.h" @@ -127,6 +128,8 @@ void FGLRenderer::BloomScene() if (!gl_bloom || !FGLRenderBuffers::IsEnabled() || gl_fixedcolormap != CM_DEFAULT) return; + FGLDebug::PushGroup("BloomScene"); + FGLPostProcessState savedState; const float blurAmount = gl_bloom_amount; @@ -196,6 +199,8 @@ void FGLRenderer::BloomScene() mBloomCombineShader->BloomTexture.Set(0); RenderScreenQuad(); glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + + FGLDebug::PopGroup(); } //----------------------------------------------------------------------------- @@ -209,6 +214,8 @@ void FGLRenderer::TonemapScene() if (gl_tonemap == 0 || !FGLRenderBuffers::IsEnabled()) return; + FGLDebug::PushGroup("TonemapScene"); + FGLPostProcessState savedState; mBuffers->BindNextFB(); @@ -218,6 +225,8 @@ void FGLRenderer::TonemapScene() mTonemapShader->Exposure.Set(mCameraExposure); RenderScreenQuad(); mBuffers->NextTexture(); + + FGLDebug::PopGroup(); } //----------------------------------------------------------------------------- @@ -231,6 +240,8 @@ void FGLRenderer::LensDistortScene() if (gl_lens == 0 || !FGLRenderBuffers::IsEnabled()) return; + FGLDebug::PushGroup("LensDistortScene"); + float k[4] = { gl_lens_k, @@ -272,6 +283,8 @@ void FGLRenderer::LensDistortScene() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); mBuffers->NextTexture(); + + FGLDebug::PopGroup(); } //----------------------------------------------------------------------------- @@ -283,6 +296,7 @@ void FGLRenderer::LensDistortScene() void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) { m2DDrawer->Flush(); // draw all pending 2D stuff before copying the buffer + FGLDebug::PushGroup("CopyToBackbuffer"); if (FGLRenderBuffers::IsEnabled()) { FGLPostProcessState savedState; @@ -327,6 +341,7 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) FGLPostProcessState savedState; ClearBorders(); } + FGLDebug::PopGroup(); } //----------------------------------------------------------------------------- diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index a3433c075..7abd6d85c 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -47,6 +47,7 @@ #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_cvars.h" +#include "gl/system/gl_debug.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderbuffers.h" #include "w_wad.h" @@ -195,18 +196,18 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples) ClearScene(); if (samples > 1) - mSceneMultisample = CreateRenderBuffer(GetHdrFormat(), samples, width, height); + mSceneMultisample = CreateRenderBuffer("SceneMultisample", GetHdrFormat(), samples, width, height); if ((gl.flags & RFL_NO_DEPTHSTENCIL) != 0) { - mSceneDepth = CreateRenderBuffer(GL_DEPTH_COMPONENT24, samples, width, height); - mSceneStencil = CreateRenderBuffer(GL_STENCIL_INDEX8, samples, width, height); - mSceneFB = CreateFrameBuffer(samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepth, mSceneStencil, samples > 1); + mSceneDepth = CreateRenderBuffer("SceneDepth", GL_DEPTH_COMPONENT24, samples, width, height); + mSceneStencil = CreateRenderBuffer("SceneStencil", GL_STENCIL_INDEX8, samples, width, height); + mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepth, mSceneStencil, samples > 1); } else { - mSceneDepthStencil = CreateRenderBuffer(GL_DEPTH24_STENCIL8, samples, width, height); - mSceneFB = CreateFrameBuffer(samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1); + mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, samples, width, height); + mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1); } } @@ -222,8 +223,8 @@ void FGLRenderBuffers::CreatePipeline(int width, int height) for (int i = 0; i < NumPipelineTextures; i++) { - mPipelineTexture[i] = Create2DTexture(GetHdrFormat(), width, height); - mPipelineFB[i] = CreateFrameBuffer(mPipelineTexture[i]); + mPipelineTexture[i] = Create2DTexture("PipelineTexture", GetHdrFormat(), width, height); + mPipelineFB[i] = CreateFrameBuffer("PipelineFB", mPipelineTexture[i]); } } @@ -249,10 +250,10 @@ void FGLRenderBuffers::CreateBloom(int width, int height) level.Width = MAX(bloomWidth / 2, 1); level.Height = MAX(bloomHeight / 2, 1); - level.VTexture = Create2DTexture(GetHdrFormat(), level.Width, level.Height); - level.HTexture = Create2DTexture(GetHdrFormat(), level.Width, level.Height); - level.VFramebuffer = CreateFrameBuffer(level.VTexture); - level.HFramebuffer = CreateFrameBuffer(level.HTexture); + level.VTexture = Create2DTexture("Bloom.VTexture", GetHdrFormat(), level.Width, level.Height); + level.HTexture = Create2DTexture("Bloom.HTexture", GetHdrFormat(), level.Width, level.Height); + level.VFramebuffer = CreateFrameBuffer("Bloom.VFramebuffer", level.VTexture); + level.HFramebuffer = CreateFrameBuffer("Bloom.HFramebuffer", level.HTexture); bloomWidth = level.Width; bloomHeight = level.Height; @@ -276,12 +277,13 @@ GLuint FGLRenderBuffers::GetHdrFormat() // //========================================================================== -GLuint FGLRenderBuffers::Create2DTexture(GLuint format, int width, int height) +GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height) { GLuint type = (format == GL_RGBA16) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE; GLuint handle = 0; glGenTextures(1, &handle); glBindTexture(GL_TEXTURE_2D, handle); + FGLDebug::LabelObject(GL_TEXTURE, handle, name); glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, GL_RGBA, type, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -296,23 +298,25 @@ GLuint FGLRenderBuffers::Create2DTexture(GLuint format, int width, int height) // //========================================================================== -GLuint FGLRenderBuffers::CreateRenderBuffer(GLuint format, int width, int height) +GLuint FGLRenderBuffers::CreateRenderBuffer(const FString &name, GLuint format, int width, int height) { GLuint handle = 0; glGenRenderbuffers(1, &handle); glBindRenderbuffer(GL_RENDERBUFFER, handle); + FGLDebug::LabelObject(GL_RENDERBUFFER, handle, name); glRenderbufferStorage(GL_RENDERBUFFER, format, width, height); return handle; } -GLuint FGLRenderBuffers::CreateRenderBuffer(GLuint format, int samples, int width, int height) +GLuint FGLRenderBuffers::CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height) { if (samples <= 1) - return CreateRenderBuffer(format, width, height); + return CreateRenderBuffer(name, format, width, height); GLuint handle = 0; glGenRenderbuffers(1, &handle); glBindRenderbuffer(GL_RENDERBUFFER, handle); + FGLDebug::LabelObject(GL_RENDERBUFFER, handle, name); glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, format, width, height); return handle; } @@ -323,22 +327,24 @@ GLuint FGLRenderBuffers::CreateRenderBuffer(GLuint format, int samples, int widt // //========================================================================== -GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer) +GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer) { GLuint handle = 0; glGenFramebuffers(1, &handle); glBindFramebuffer(GL_FRAMEBUFFER, handle); + FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); CheckFrameBufferCompleteness(); ClearFrameBuffer(); return handle; } -GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer) +GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer) { GLuint handle = 0; glGenFramebuffers(1, &handle); glBindFramebuffer(GL_FRAMEBUFFER, handle); + FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); if (colorIsARenderBuffer) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); else @@ -349,11 +355,12 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depthstenc return handle; } -GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer) +GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer) { GLuint handle = 0; glGenFramebuffers(1, &handle); glBindFramebuffer(GL_FRAMEBUFFER, handle); + FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); if (colorIsARenderBuffer) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); else diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 0a604766d..9402d9396 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -47,12 +47,12 @@ private: void CreateScene(int width, int height, int samples); void CreatePipeline(int width, int height); void CreateBloom(int width, int height); - GLuint Create2DTexture(GLuint format, int width, int height); - GLuint CreateRenderBuffer(GLuint format, int width, int height); - GLuint CreateRenderBuffer(GLuint format, int samples, int width, int height); - GLuint CreateFrameBuffer(GLuint colorbuffer); - GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer); - GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer); + GLuint Create2DTexture(const FString &name, GLuint format, int width, int height); + GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height); + GLuint CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height); + GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer); + GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer); + GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer); void CheckFrameBufferCompleteness(); void ClearFrameBuffer(); void DeleteTexture(GLuint &handle); diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 8c4baee60..9d2276b52 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -54,6 +54,7 @@ #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_cvars.h" +#include "gl/system/gl_debug.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" @@ -131,6 +132,7 @@ void FGLRenderer::Initialize(int width, int height) { glGenVertexArrays(1, &mVAOID); glBindVertexArray(mVAOID); + FGLDebug::LabelObject(GL_VERTEX_ARRAY, mVAOID, "FGLRenderer.mVAOID"); } else mVAOID = 0; @@ -366,9 +368,13 @@ void FGLRenderer::FlushTextures() bool FGLRenderer::StartOffscreen() { - if (mFBID == 0) glGenFramebuffers(1, &mFBID); + bool firstBind = (mFBID == 0); + if (mFBID == 0) + glGenFramebuffers(1, &mFBID); glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mOldFBID); glBindFramebuffer(GL_FRAMEBUFFER, mFBID); + if (firstBind) + FGLDebug::LabelObject(GL_FRAMEBUFFER, mFBID, "OffscreenFB"); return true; } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index cce8c6563..d0cc5ef3f 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -50,6 +50,7 @@ #include "cmdlib.h" #include "gl/system/gl_interface.h" +#include "gl/system/gl_debug.h" #include "gl/data/gl_data.h" #include "gl/data/gl_matrix.h" #include "gl/renderer/gl_renderer.h" @@ -179,6 +180,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * hVertProg = glCreateShader(GL_VERTEX_SHADER); hFragProg = glCreateShader(GL_FRAGMENT_SHADER); + FGLDebug::LabelObject(GL_SHADER, hVertProg, vert_prog_lump); + FGLDebug::LabelObject(GL_SHADER, hFragProg, frag_prog_lump); int vp_size = (int)vp_comb.Len(); int fp_size = (int)fp_comb.Len(); @@ -193,6 +196,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * glCompileShader(hFragProg); hShader = glCreateProgram(); + FGLDebug::LabelObject(GL_PROGRAM, hShader, name); glAttachShader(hShader, hVertProg); glAttachShader(hShader, hFragProg); diff --git a/src/gl/shaders/gl_shaderprogram.cpp b/src/gl/shaders/gl_shaderprogram.cpp index bed4a2e29..63ce09261 100644 --- a/src/gl/shaders/gl_shaderprogram.cpp +++ b/src/gl/shaders/gl_shaderprogram.cpp @@ -46,6 +46,7 @@ #include "vectors.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" +#include "gl/system/gl_debug.h" #include "gl/shaders/gl_shaderprogram.h" #include "w_wad.h" #include "i_system.h" @@ -107,6 +108,8 @@ void FShaderProgram::Compile(ShaderType type, const char *name, const FString &c const auto &handle = mShaders[type]; + FGLDebug::LabelObject(GL_SHADER, handle, name); + FString patchedCode = PatchShader(type, code, defines, maxGlslVersion); int lengths[1] = { (int)patchedCode.Len() }; const char *sources[1] = { patchedCode.GetChars() }; @@ -147,6 +150,7 @@ void FShaderProgram::SetFragDataLocation(int index, const char *name) void FShaderProgram::Link(const char *name) { + FGLDebug::LabelObject(GL_PROGRAM, mProgram, name); glLinkProgram(mProgram); GLint status = 0; diff --git a/src/gl/system/gl_debug.cpp b/src/gl/system/gl_debug.cpp index 984893ddc..365356752 100644 --- a/src/gl/system/gl_debug.cpp +++ b/src/gl/system/gl_debug.cpp @@ -63,6 +63,52 @@ void FGLDebug::Update() OutputMessageLog(); } +//----------------------------------------------------------------------------- +// +// Label objects so they are referenced by name in debug messages and in +// OpenGL debuggers (renderdoc) +// +//----------------------------------------------------------------------------- + +void FGLDebug::LabelObject(GLenum type, GLuint handle, const FString &name) +{ + if (gl_debug_level != 0) + { + glObjectLabel(type, handle, (GLsizei)name.Len(), name.GetChars()); + } +} + +void FGLDebug::LabelObjectPtr(void *ptr, const FString &name) +{ + if (gl_debug_level != 0) + { + glObjectPtrLabel(ptr, (GLsizei)name.Len(), name.GetChars()); + } +} + +//----------------------------------------------------------------------------- +// +// Marks which render pass/group is executing commands so that debuggers can +// display this information +// +//----------------------------------------------------------------------------- + +void FGLDebug::PushGroup(const FString &name) +{ + if (gl_debug_level != 0) + { + glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, (GLsizei)name.Len(), name.GetChars()); + } +} + +void FGLDebug::PopGroup() +{ + if (gl_debug_level != 0) + { + glPopDebugGroup(); + } +} + //----------------------------------------------------------------------------- // // Turns on synchronous debugging on and off based on gl_debug_breakpoint @@ -160,6 +206,9 @@ void FGLDebug::OutputMessageLog() void FGLDebug::PrintMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message) { + if (type == GL_DEBUG_TYPE_PUSH_GROUP || type == GL_DEBUG_TYPE_POP_GROUP) + return; + static int messagesPrinted = 0; messagesPrinted++; if (messagesPrinted == 50) diff --git a/src/gl/system/gl_debug.h b/src/gl/system/gl_debug.h index ce919cebd..2401ba5cc 100644 --- a/src/gl/system/gl_debug.h +++ b/src/gl/system/gl_debug.h @@ -11,6 +11,12 @@ class FGLDebug public: void Update(); + static void LabelObject(GLenum type, GLuint handle, const FString &name); + static void LabelObjectPtr(void *ptr, const FString &name); + + static void PushGroup(const FString &name); + static void PopGroup(); + private: void SetupBreakpointMode(); void UpdateLoggingLevel(); diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index c6c09b551..0fbf3cd14 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -153,7 +153,7 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) const auto &viewport = GLRenderer->mScreenViewport; wipestartscreen = new FHardwareTexture(viewport.width, viewport.height, true); - wipestartscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0); + wipestartscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen"); GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1); GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE, -1); glFinish(); @@ -193,7 +193,7 @@ void OpenGLFrameBuffer::WipeEndScreen() const auto &viewport = GLRenderer->mScreenViewport; wipeendscreen = new FHardwareTexture(viewport.width, viewport.height, true); - wipeendscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0); + wipeendscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen"); GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1); glFinish(); wipeendscreen->Bind(0, false, false); @@ -565,7 +565,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) // Burn the new screen on top of it. fb->wipeendscreen->Bind(0, 0, false); - BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, 1, true, 0); + BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, 1, true, 0, "BurnTexture"); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); gl_RenderState.SetEffect(EFF_NONE); diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 7d9d754fd..73c4e7b36 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -48,6 +48,7 @@ #include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" +#include "gl/system/gl_debug.h" #include "gl/renderer/gl_renderer.h" #include "gl/textures/gl_material.h" @@ -184,7 +185,7 @@ void FHardwareTexture::Resize(int width, int height, unsigned char *src_data, un // //=========================================================================== -unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation) +unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, const FString &name) { int rh,rw; int texformat=TexFormat[gl_texture_format]; @@ -198,6 +199,7 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int if (glTex->glTexID==0) glGenTextures(1,&glTex->glTexID); if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); glBindTexture(GL_TEXTURE_2D, glTex->glTexID); + FGLDebug::LabelObject(GL_TEXTURE, glTex->glTexID, name); lastbound[texunit] = glTex->glTexID; if (!buffer) diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h index 6b01fb437..9b7028f8c 100644 --- a/src/gl/textures/gl_hwtexture.h +++ b/src/gl/textures/gl_hwtexture.h @@ -77,7 +77,7 @@ public: void BindToFrameBuffer(); unsigned int Bind(int texunit, int translation, bool needmipmap); - unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation); + unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, const FString &name); void Clean(bool all); void CleanUnused(SpriteHits &usedtranslations); diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 6a579b0d5..8e0ab73e6 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -337,7 +337,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla } tex->ProcessData(buffer, w, h, false); } - if (!hwtex->CreateTexture(buffer, w, h, texunit, needmipmap, translation)) + if (!hwtex->CreateTexture(buffer, w, h, texunit, needmipmap, translation, "FGLTexture.Bind")) { // could not create texture delete[] buffer; diff --git a/src/gl/textures/gl_samplers.cpp b/src/gl/textures/gl_samplers.cpp index cee2fd894..64674e63c 100644 --- a/src/gl/textures/gl_samplers.cpp +++ b/src/gl/textures/gl_samplers.cpp @@ -42,6 +42,7 @@ #include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" +#include "gl/system/gl_debug.h" #include "gl/renderer/gl_renderer.h" #include "gl_samplers.h" #include "gl_material.h" @@ -67,6 +68,13 @@ FSamplerManager::FSamplerManager() glSamplerParameteri(mSamplers[3], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + for (int i = 0; i < 7; i++) + { + FString name; + name.Format("mSamplers[%d]", i); + FGLDebug::LabelObject(GL_SAMPLER, mSamplers[i], name); + } } } From 18ff65fb0e0090926674a875322a8bfb2bd1f6b0 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 17 Aug 2016 23:52:20 +0200 Subject: [PATCH 0813/1509] Filter logging to only display each message once --- src/gl/system/gl_debug.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/gl/system/gl_debug.cpp b/src/gl/system/gl_debug.cpp index 365356752..932ae221d 100644 --- a/src/gl/system/gl_debug.cpp +++ b/src/gl/system/gl_debug.cpp @@ -42,6 +42,7 @@ #include "gl/system/gl_system.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_debug.h" +#include #ifndef _MSC_VER #include @@ -209,19 +210,33 @@ void FGLDebug::PrintMessage(GLenum source, GLenum type, GLuint id, GLenum severi if (type == GL_DEBUG_TYPE_PUSH_GROUP || type == GL_DEBUG_TYPE_POP_GROUP) return; + const int maxMessages = 50; + static int messagesPrinted = 0; + if (messagesPrinted > maxMessages) + return; + + FString msg(message, length); + + static std::set seenMessages; + bool alreadySeen = !seenMessages.insert(msg.GetChars()).second; + if (alreadySeen) + return; + messagesPrinted++; - if (messagesPrinted == 50) + if (messagesPrinted == maxMessages) { Printf("Max OpenGL debug messages reached. Suppressing further output.\n"); } - else if (messagesPrinted < 50) + else if (messagesPrinted < maxMessages) { - FString msg(message, length); FString sourceStr = SourceToString(source); FString typeStr = TypeToString(type); FString severityStr = SeverityToString(severity); - Printf("%s [%s] %s: %s\n", severityStr.GetChars(), sourceStr.GetChars(), typeStr.GetChars(), msg.GetChars()); + if (type != GL_DEBUG_TYPE_OTHER) + Printf("[%s] %s, %s: %s\n", sourceStr.GetChars(), severityStr.GetChars(), typeStr.GetChars(), msg.GetChars()); + else + Printf("[%s] %s: %s\n", sourceStr.GetChars(), severityStr.GetChars(), msg.GetChars()); } } From 01f9a2d27ac505ae9472d4d297011583834a5158 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 18 Aug 2016 00:21:33 +0200 Subject: [PATCH 0814/1509] Fix clear warning --- src/gl/renderer/gl_renderbuffers.cpp | 15 ++++++++++----- src/gl/renderer/gl_renderbuffers.h | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 7abd6d85c..ab00fc10f 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -335,7 +335,7 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); CheckFrameBufferCompleteness(); - ClearFrameBuffer(); + ClearFrameBuffer(false, false); return handle; } @@ -351,7 +351,7 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil); CheckFrameBufferCompleteness(); - ClearFrameBuffer(); + ClearFrameBuffer(true, true); return handle; } @@ -368,7 +368,7 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil); CheckFrameBufferCompleteness(); - ClearFrameBuffer(); + ClearFrameBuffer(true, true); return handle; } @@ -406,7 +406,7 @@ void FGLRenderBuffers::CheckFrameBufferCompleteness() // //========================================================================== -void FGLRenderBuffers::ClearFrameBuffer() +void FGLRenderBuffers::ClearFrameBuffer(bool stencil, bool depth) { GLboolean scissorEnabled; GLint stencilValue; @@ -418,7 +418,12 @@ void FGLRenderBuffers::ClearFrameBuffer() glClearColor(0.0, 0.0, 0.0, 0.0); glClearDepth(0.0); glClearStencil(0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + GLenum flags = GL_COLOR_BUFFER_BIT; + if (stencil) + flags |= GL_STENCIL_BUFFER_BIT; + if (depth) + flags |= GL_DEPTH_BUFFER_BIT; + glClear(flags); glClearStencil(stencilValue); glClearDepth(depthValue); if (scissorEnabled) diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 9402d9396..9c04eb546 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -54,7 +54,7 @@ private: GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer); void CheckFrameBufferCompleteness(); - void ClearFrameBuffer(); + void ClearFrameBuffer(bool stencil, bool depth); void DeleteTexture(GLuint &handle); void DeleteRenderBuffer(GLuint &handle); void DeleteFrameBuffer(GLuint &handle); From b21b65eb436f542bb9095e3756869839890458c8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 18 Aug 2016 01:32:41 +0200 Subject: [PATCH 0815/1509] Rearrange binding of texture and sampler to get rid of texture state usage warning --- src/gl/renderer/gl_postprocessstate.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_postprocessstate.cpp b/src/gl/renderer/gl_postprocessstate.cpp index 7e34a1149..058e41190 100644 --- a/src/gl/renderer/gl_postprocessstate.cpp +++ b/src/gl/renderer/gl_postprocessstate.cpp @@ -59,6 +59,7 @@ FGLPostProcessState::FGLPostProcessState() glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); glActiveTexture(GL_TEXTURE0); glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); + glBindTexture(GL_TEXTURE_2D, 0); if (gl.flags & RFL_SAMPLER_OBJECTS) { glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding); @@ -117,8 +118,9 @@ FGLPostProcessState::~FGLPostProcessState() glUseProgram(currentProgram); glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, textureBinding); + glBindTexture(GL_TEXTURE_2D, 0); if (gl.flags & RFL_SAMPLER_OBJECTS) glBindSampler(0, samplerBinding); + glBindTexture(GL_TEXTURE_2D, textureBinding); glActiveTexture(activeTex); } From f75b6d8c5d41dc1532ddd8e674672fc5afadd7c6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 18 Aug 2016 02:10:54 +0200 Subject: [PATCH 0816/1509] Improve debug level filtering --- src/gl/system/gl_debug.cpp | 26 +++++++++++++++++++++++++- src/gl/system/gl_debug.h | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/gl/system/gl_debug.cpp b/src/gl/system/gl_debug.cpp index 932ae221d..d4a0b2fcf 100644 --- a/src/gl/system/gl_debug.cpp +++ b/src/gl/system/gl_debug.cpp @@ -156,6 +156,26 @@ void FGLDebug::UpdateLoggingLevel() } } +//----------------------------------------------------------------------------- +// +// The log may already contain entries for a debug level we are no longer +// interested in.. +// +//----------------------------------------------------------------------------- + +bool FGLDebug::IsFilteredByDebugLevel(GLenum severity) +{ + int severityLevel = 0; + switch (severity) + { + case GL_DEBUG_SEVERITY_LOW: severityLevel = 1; break; + case GL_DEBUG_SEVERITY_MEDIUM: severityLevel = 2; break; + case GL_DEBUG_SEVERITY_HIGH: severityLevel = 3; break; + case GL_DEBUG_SEVERITY_NOTIFICATION: severityLevel = 4; break; + } + return severityLevel >= (int)gl_debug_level; +} + //----------------------------------------------------------------------------- // // Prints all logged messages to the console @@ -193,7 +213,8 @@ void FGLDebug::OutputMessageLog() GLsizei offset = 0; for (GLuint i = 0; i < numMessages; i++) { - PrintMessage(sources[i], types[i], ids[i], severities[i], lengths[i], &messageLog[offset]); + if (!IsFilteredByDebugLevel(severities[i])) + PrintMessage(sources[i], types[i], ids[i], severities[i], lengths[i], &messageLog[offset]); offset += lengths[i]; } } @@ -248,6 +269,9 @@ void FGLDebug::PrintMessage(GLenum source, GLenum type, GLuint id, GLenum severi void FGLDebug::DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) { + if (IsFilteredByDebugLevel(severity)) + return; + PrintMessage(source, type, id, severity, length, message); if (severity != GL_DEBUG_SEVERITY_NOTIFICATION) diff --git a/src/gl/system/gl_debug.h b/src/gl/system/gl_debug.h index 2401ba5cc..1688297be 100644 --- a/src/gl/system/gl_debug.h +++ b/src/gl/system/gl_debug.h @@ -22,6 +22,7 @@ private: void UpdateLoggingLevel(); void OutputMessageLog(); + static bool IsFilteredByDebugLevel(GLenum severity); static void PrintMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message); static void APIENTRY DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam); From 4241026f1c86881cfcff005888442a0036dc7c06 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 18 Aug 2016 02:21:53 +0200 Subject: [PATCH 0817/1509] Swapped order in IsFilteredByDebugLevel --- src/gl/system/gl_debug.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/system/gl_debug.cpp b/src/gl/system/gl_debug.cpp index d4a0b2fcf..af0704f77 100644 --- a/src/gl/system/gl_debug.cpp +++ b/src/gl/system/gl_debug.cpp @@ -168,9 +168,9 @@ bool FGLDebug::IsFilteredByDebugLevel(GLenum severity) int severityLevel = 0; switch (severity) { - case GL_DEBUG_SEVERITY_LOW: severityLevel = 1; break; + case GL_DEBUG_SEVERITY_HIGH: severityLevel = 1; break; case GL_DEBUG_SEVERITY_MEDIUM: severityLevel = 2; break; - case GL_DEBUG_SEVERITY_HIGH: severityLevel = 3; break; + case GL_DEBUG_SEVERITY_LOW: severityLevel = 3; break; case GL_DEBUG_SEVERITY_NOTIFICATION: severityLevel = 4; break; } return severityLevel >= (int)gl_debug_level; From e8fc935f04b9cc0bb7c5a8fb2c02848de02bbc38 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 18 Aug 2016 02:24:57 +0200 Subject: [PATCH 0818/1509] Another IsFilteredByDebugLevel typo.. --- src/gl/system/gl_debug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/system/gl_debug.cpp b/src/gl/system/gl_debug.cpp index af0704f77..9553345c9 100644 --- a/src/gl/system/gl_debug.cpp +++ b/src/gl/system/gl_debug.cpp @@ -173,7 +173,7 @@ bool FGLDebug::IsFilteredByDebugLevel(GLenum severity) case GL_DEBUG_SEVERITY_LOW: severityLevel = 3; break; case GL_DEBUG_SEVERITY_NOTIFICATION: severityLevel = 4; break; } - return severityLevel >= (int)gl_debug_level; + return severityLevel > (int)gl_debug_level; } //----------------------------------------------------------------------------- From eadc2f35dd1b9bdac0f2ae5f83510c46047c6f3a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 Aug 2016 00:21:17 +0200 Subject: [PATCH 0819/1509] - fixed: The crossfade wipe must use its own alpha for the second layer, not the one from the vertex buffer. --- src/gl/system/gl_wipe.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index c6c09b551..4f701265e 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -347,6 +347,7 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.SetColorAlpha(0xffffff, a); gl_RenderState.Apply(); fb->wipeendscreen->Bind(0, 0, false); + mVertexBuf->EnableColorArray(false); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f); gl_RenderState.SetTextureMode(TM_MODULATE); From f63635e07a428f2a198274c719a1f48821f5a7b0 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 19 Aug 2016 01:11:11 +0200 Subject: [PATCH 0820/1509] Fix RFL_INVALIDATE_BUFFER check being inverted --- src/gl/renderer/gl_renderbuffers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index ab00fc10f..9c9c76979 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -447,7 +447,7 @@ void FGLRenderBuffers::BlitSceneToTexture() glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mPipelineFB[mCurrentPipelineTexture]); glBlitFramebuffer(0, 0, mWidth, mHeight, 0, 0, mWidth, mHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST); - if ((gl.flags & RFL_INVALIDATE_BUFFER) == 0) + if ((gl.flags & RFL_INVALIDATE_BUFFER) != 0) { GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT }; glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 2, attachments); From dde81b33ea39d0f6649794a94c1a12702511ff53 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Aug 2016 08:45:21 +0200 Subject: [PATCH 0821/1509] - glEnable(GL_TEXTURE_2D) only makes sense if no shaders are being used. --- src/gl/system/gl_framebuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index c74009e1f..6d56c1b27 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -157,7 +157,7 @@ void OpenGLFrameBuffer::InitializeState() glEnable(GL_BLEND); glEnable(GL_DEPTH_CLAMP); glDisable(GL_DEPTH_TEST); - glEnable(GL_TEXTURE_2D); + if (gl.glslversion == 0) glEnable(GL_TEXTURE_2D); glDisable(GL_LINE_SMOOTH); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); From 3e01039bbb49dc4f80b92a418602ab5a947c7fce Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 21 Aug 2016 15:47:56 +0300 Subject: [PATCH 0822/1509] Fixed missing #include for GCC/Clang --- src/gl/system/gl_debug.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/system/gl_debug.cpp b/src/gl/system/gl_debug.cpp index 9553345c9..52fbadf33 100644 --- a/src/gl/system/gl_debug.cpp +++ b/src/gl/system/gl_debug.cpp @@ -43,6 +43,7 @@ #include "gl/system/gl_interface.h" #include "gl/system/gl_debug.h" #include +#include #ifndef _MSC_VER #include From 302f59ea33f557da33ca9b4555b4ad4a150c4633 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 22 Aug 2016 01:52:51 +0200 Subject: [PATCH 0823/1509] Fix r_clearbuffer color not being used --- src/gl/renderer/gl_renderer.h | 2 ++ src/gl/scene/gl_scene.cpp | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 1ce241da3..36654fad4 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -116,6 +116,8 @@ public: bool mDrawingScene2D = false; float mCameraExposure = 1.0f; + float mSceneClearColor[3]; + FGLRenderer(OpenGLFrameBuffer *fb); ~FGLRenderer() ; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index b96b1d3b6..6e1f9a565 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -178,7 +178,7 @@ void FGLRenderer::Set3DViewport(bool mainview) // This is faster on newer hardware because it allows the GPU to skip // reading from slower memory where the full buffers are stored. glDisable(GL_SCISSOR_TEST); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClearColor(mSceneClearColor[0], mSceneClearColor[1], mSceneClearColor[2], 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); const auto &bounds = mSceneViewport; @@ -775,6 +775,9 @@ void FGLRenderer::SetFixedColormap (player_t *player) sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen) { sector_t * retval; + mSceneClearColor[0] = 0.0f; + mSceneClearColor[1] = 0.0f; + mSceneClearColor[2] = 0.0f; R_SetupFrame (camera); SetViewArea(); @@ -1251,8 +1254,9 @@ int FGLInterface::GetMaxViewPitch(bool down) void FGLInterface::ClearBuffer(int color) { PalEntry pe = GPalette.BaseColors[color]; - glClearColor(pe.r/255.f, pe.g/255.f, pe.b/255.f, 1.f); - glClear(GL_COLOR_BUFFER_BIT); + GLRenderer->mSceneClearColor[0] = pe.r / 255.f; + GLRenderer->mSceneClearColor[1] = pe.g / 255.f; + GLRenderer->mSceneClearColor[2] = pe.b / 255.f; } //=========================================================================== From 7ba5acfb35aeeda77458895c10e0dae6a9b3bc8a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 22 Aug 2016 14:00:25 +0200 Subject: [PATCH 0824/1509] - added quad drawer interface so that this part can be done without altering a vertex buffer. So far it's only the framework, the new code is not active yet. --- src/CMakeLists.txt | 1 + src/gl/data/gl_vertexbuffer.h | 10 ++- src/gl/renderer/gl_quaddrawer.cpp | 85 +++++++++++++++++++++++++ src/gl/renderer/gl_quaddrawer.h | 44 +++++++++++++ src/gl/scene/gl_decal.cpp | 12 ++-- src/gl/scene/gl_drawinfo.cpp | 50 ++++++--------- src/gl/scene/gl_sprite.cpp | 20 +++--- src/gl/scene/gl_weapon.cpp | 17 ++--- src/gl/shaders/gl_shader.cpp | 3 + src/gl/shaders/gl_shader.h | 3 + src/gl/system/gl_interface.h | 3 +- wadsrc/static/shaders/glsl/main.vp | 28 ++++++-- wadsrc/static/shaders/glsl/shaderdefs.i | 7 ++ 13 files changed, 216 insertions(+), 67 deletions(-) create mode 100644 src/gl/renderer/gl_quaddrawer.cpp create mode 100644 src/gl/renderer/gl_quaddrawer.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c74c9534d..03f3372f0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1061,6 +1061,7 @@ set( FASTMATH_SOURCES gl/utility/gl_cycler.cpp gl/utility/gl_geometric.cpp gl/renderer/gl_2ddrawer.cpp + gl/renderer/gl_quaddrawer.cpp gl/renderer/gl_renderer.cpp gl/renderer/gl_renderstate.cpp gl/renderer/gl_renderbuffers.cpp diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 4d2252fe0..c9abae0da 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -97,9 +97,17 @@ public: { return &map[mCurIndex]; } + FFlatVertex *Alloc(int num, int *poffset) + { + FFlatVertex *p = GetBuffer(); + *poffset = mCurIndex; + mCurIndex += num; + if (mCurIndex >= BUFFER_SIZE_TO_USE) mCurIndex = mIndex; + return p; + } + unsigned int GetCount(FFlatVertex *newptr, unsigned int *poffset) { - unsigned int newofs = (unsigned int)(newptr - map); unsigned int diff = newofs - mCurIndex; *poffset = mCurIndex; diff --git a/src/gl/renderer/gl_quaddrawer.cpp b/src/gl/renderer/gl_quaddrawer.cpp new file mode 100644 index 000000000..b80f123e0 --- /dev/null +++ b/src/gl/renderer/gl_quaddrawer.cpp @@ -0,0 +1,85 @@ +/* +** gl_quaddrawer.h +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "gl/shaders/gl_shader.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_quaddrawer.h" +#include "gl/data/gl_matrix.h" + +/* +** For handling of dynamically created quads when no persistently mapped +** buffer or client array is available (i.e. GL 3.x core profiles) +** +** In this situation the 4 vertices of a quad primitive are being passed +** as a matrix uniform because that is a lot faster than any kind of +** temporary buffer change. +*/ + +FFlatVertex FQuadDrawer::buffer[4]; + +//========================================================================== +// +// +// +//========================================================================== + +void FQuadDrawer::DoRender(int type) +{ + // When this gets called, the render state must already be applied so we can just + // send our vertices to the current shader. + float matV[16], matT[16]; + + for(int i=0;i<4;i++) + { + matV[i*4+0] = buffer[i].x; + matV[i*4+1] = buffer[i].z; + matV[i*4+2] = buffer[i].y; + matT[i*4+0] = buffer[i].u; + matT[i*4+1] = buffer[i].v; + matV[i*4+3] = matT[i*4+2] = matT[i*4+3] = 0; + } + FShader *shader = GLRenderer->mShaderManager->GetActiveShader(); + glUniformMatrix4fv(shader->vertexmatrix_index, 1, false, matV); + glUniformMatrix4fv(shader->texcoordmatrix_index, 1, false, matT); + glUniform1i(shader->quadmode_index, 1); + GLRenderer->mVBO->RenderArray(type, 0, 4); + glUniform1i(shader->quadmode_index, 0); +} diff --git a/src/gl/renderer/gl_quaddrawer.h b/src/gl/renderer/gl_quaddrawer.h new file mode 100644 index 000000000..3fcca65c2 --- /dev/null +++ b/src/gl/renderer/gl_quaddrawer.h @@ -0,0 +1,44 @@ +#ifndef __QDRAWER_H +#define __QDRAWER_H + +#include "gl/data/gl_vertexbuffer.h" + +class FQuadDrawer +{ + FFlatVertex *p; + int ndx; + static FFlatVertex buffer[4]; + + void DoRender(int type); +public: + + FQuadDrawer() + { + if (gl.flags & RFL_QUADHACK) + { + p = buffer; + } + else + { + p = GLRenderer->mVBO->Alloc(4, &ndx); + } + } + void Set(int ndx, float x, float y, float z, float s, float t) + { + p[ndx].Set(x, y, z, s, t); + } + void Render(int type) + { + if (gl.flags & RFL_QUADHACK) + { + DoRender(type); + } + else + { + GLRenderer->mVBO->RenderArray(type, ndx, 4); + } + } +}; + + +#endif diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 1a10b3f4d..c9de15144 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -54,6 +54,7 @@ #include "gl/textures/gl_texture.h" #include "gl/textures/gl_material.h" #include "gl/utility/gl_clock.h" +#include "gl/renderer/gl_quaddrawer.h" struct DecalVertex { @@ -328,22 +329,19 @@ void GLWall::DrawDecal(DBaseDecal *decal) gl_RenderState.SetFog(0,-1); } - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + FQuadDrawer qd; for (i = 0; i < 4; i++) { - ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); - ptr++; + qd.Set(i, dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); } if (lightlist == NULL) { gl_RenderState.Apply(); - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + qd.Render(GL_TRIANGLE_FAN); } else { - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); for (unsigned k = 0; k < lightlist->Size(); k++) { secplane_t &lowplane = k == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[k + 1].plane; @@ -363,7 +361,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) gl_RenderState.SetSplitPlanes((*lightlist)[k].plane, lowplane); gl_RenderState.Apply(); - GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, offset, count); + qd.Render(GL_TRIANGLE_FAN); } if (low1 <= dv[0].z && low2 <= dv[3].z) break; } diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 0dc8efd84..1d3936948 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -57,6 +57,7 @@ #include "gl/utility/gl_templates.h" #include "gl/shaders/gl_shader.h" #include "gl/stereo3d/scoped_color_mask.h" +#include "gl/renderer/gl_quaddrawer.h" FDrawInfo * gl_drawinfo; @@ -1079,17 +1080,12 @@ void FDrawInfo::SetupFloodStencil(wallseg * ws) glDepthMask(true); gl_RenderState.Apply(); - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0); - ptr++; - ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0); - ptr++; - ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0); - ptr++; - ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); - + FQuadDrawer qd; + qd.Set(0, ws->x1, ws->z1, ws->y1, 0, 0); + qd.Set(1, ws->x1, ws->z2, ws->y1, 0, 0); + qd.Set(2, ws->x2, ws->z2, ws->y2, 0, 0); + qd.Set(3, ws->x2, ws->z1, ws->y2, 0, 0); + qd.Render(GL_TRIANGLE_FAN); glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil @@ -1112,16 +1108,12 @@ void FDrawInfo::ClearFloodStencil(wallseg * ws) gl_RenderState.ResetColor(); gl_RenderState.Apply(); - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0); - ptr++; - ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0); - ptr++; - ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0); - ptr++; - ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + FQuadDrawer qd; + qd.Set(0, ws->x1, ws->z1, ws->y1, 0, 0); + qd.Set(1, ws->x1, ws->z2, ws->y1, 0, 0); + qd.Set(2, ws->x2, ws->z2, ws->y2, 0, 0); + qd.Set(3, ws->x2, ws->z1, ws->y2, 0, 0); + qd.Render(GL_TRIANGLE_FAN); // restore old stencil op. glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); @@ -1192,16 +1184,12 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo float px4 = fviewx + prj_fac1 * (ws->x2-fviewx); float py4 = fviewy + prj_fac1 * (ws->y2-fviewy); - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(px1, planez, py1, px1 / 64, -py1 / 64); - ptr++; - ptr->Set(px2, planez, py2, px2 / 64, -py2 / 64); - ptr++; - ptr->Set(px3, planez, py3, px3 / 64, -py3 / 64); - ptr++; - ptr->Set(px4, planez, py4, px4 / 64, -py4 / 64); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + FQuadDrawer qd; + qd.Set(0, px1, planez, py1, px1 / 64, -py1 / 64); + qd.Set(1, px2, planez, py2, px2 / 64, -py2 / 64); + qd.Set(2, px3, planez, py3, px3 / 64, -py3 / 64); + qd.Set(3, px4, planez, py4, px4 / 64, -py4 / 64); + qd.Render(GL_TRIANGLE_FAN); gl_RenderState.EnableTextureMatrix(false); } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 76796adf9..3dff0f32a 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -64,6 +64,7 @@ #include "gl/textures/gl_material.h" #include "gl/utility/gl_clock.h" #include "gl/data/gl_vertexbuffer.h" +#include "gl/renderer/gl_quaddrawer.h" CVAR(Bool, gl_usecolorblending, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, gl_spritebrightfog, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); @@ -400,17 +401,12 @@ void GLSprite::Draw(int pass) } FFlatVertex *ptr; - unsigned int offset, count; - ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(v1[0], v1[1], v1[2], ul, vt); - ptr++; - ptr->Set(v2[0], v2[1], v2[2], ur, vt); - ptr++; - ptr->Set(v3[0], v3[1], v3[2], ul, vb); - ptr++; - ptr->Set(v4[0], v4[1], v4[2], ur, vb); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); + FQuadDrawer qd; + qd.Set(0, v1[0], v1[1], v1[2], ul, vt); + qd.Set(1, v2[0], v2[1], v2[2], ur, vt); + qd.Set(2, v3[0], v3[1], v3[2], ul, vb); + qd.Set(3, v4[0], v4[1], v4[2], ur, vb); + qd.Render(GL_TRIANGLE_STRIP); if (foglayer) { @@ -420,7 +416,7 @@ void GLSprite::Draw(int pass) gl_RenderState.BlendEquation(GL_FUNC_ADD); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.Apply(); - GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); + qd.Render(GL_TRIANGLE_STRIP); gl_RenderState.SetFixedColormap(CM_DEFAULT); } } diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 34779ec7c..598254c10 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -57,6 +57,7 @@ #include "gl/models/gl_models.h" #include "gl/shaders/gl_shader.h" #include "gl/textures/gl_material.h" +#include "gl/renderer/gl_quaddrawer.h" EXTERN_CVAR (Bool, r_drawplayersprites) EXTERN_CVAR(Float, transsouls) @@ -161,16 +162,12 @@ void FGLRenderer::DrawPSprite (player_t * player,DPSprite *psp, float sx, float gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); } gl_RenderState.Apply(); - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(x1, y1, 0, fU1, fV1); - ptr++; - ptr->Set(x1, y2, 0, fU1, fV2); - ptr++; - ptr->Set(x2, y1, 0, fU2, fV1); - ptr++; - ptr->Set(x2, y2, 0, fU2, fV2); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + FQuadDrawer qd; + qd.Set(0, x1, y1, 0, fU1, fV1); + qd.Set(1, x1, y2, 0, fU1, fV2); + qd.Set(2, x2, y1, 0, fU2, fV1); + qd.Set(3, x2, y2, 0, fU2, fV2); + qd.Render(GL_TRIANGLE_STRIP); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f); } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index d0cc5ef3f..c3f0f83da 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -265,6 +265,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * viewmatrix_index = glGetUniformLocation(hShader, "ViewMatrix"); modelmatrix_index = glGetUniformLocation(hShader, "ModelMatrix"); texturematrix_index = glGetUniformLocation(hShader, "TextureMatrix"); + vertexmatrix_index = glGetUniformLocation(hShader, "uQuadVertices"); + texcoordmatrix_index = glGetUniformLocation(hShader, "uQuadTexCoords"); + quadmode_index = glGetUniformLocation(hShader, "uQuadMode"); if (LM_SOFTWARE != gl.lightmethod && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) { diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index a0b01d20d..75e4b4e5e 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -244,6 +244,9 @@ class FShader int modelmatrix_index; int texturematrix_index; public: + int vertexmatrix_index; + int texcoordmatrix_index; + int quadmode_index; int fakevb_index; private: int currentglowstate = 0; diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 11b0573e5..9eca673f5 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -25,7 +25,8 @@ enum RenderFlags RFL_NO_DEPTHSTENCIL = 64, RFL_NO_CLIP_PLANES = 128, - RFL_INVALIDATE_BUFFER = 256 + RFL_INVALIDATE_BUFFER = 256, + RFL_QUADHACK = 512 }; enum TexMode diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 7cc4d4d83..281c509d3 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -13,10 +13,28 @@ out vec4 vColor; void main() { - #ifndef SIMPLE - vec4 worldcoord = ModelMatrix * mix(aPosition, aVertex2, uInterpolationFactor); + vec2 parmTexCoord; + vec4 parmPosition; + #ifndef USE_QUAD_DRAWER + parmTexCoord = aTexCoord; + parmPosition = aPosition; #else - vec4 worldcoord = ModelMatrix * aPosition; + if (uQuadMode == 0) + { + parmTexCoord = aTexCoord; + parmPosition = aPosition; + } + else + { + parmPosition = uQuadVertices[int(aPosition.x)].st; + parmTexCoord = uQuadTexCoords[int(aPosition.x)]; + } + #endif + + #ifndef SIMPLE + vec4 worldcoord = ModelMatrix * mix(parmPosition, aVertex2, uInterpolationFactor); + #else + vec4 worldcoord = ModelMatrix * parmPosition; #endif vec4 eyeCoordPos = ViewMatrix * worldcoord; @@ -39,13 +57,13 @@ void main() #ifdef SPHEREMAP vec3 u = normalize(eyeCoordPos.xyz); - vec4 n = normalize(TextureMatrix * vec4(aTexCoord.x, 0.0, aTexCoord.y, 0.0)); // use texture matrix and coordinates for our normal. Since this is only used on walls, the normal's y coordinate is always 0. + vec4 n = normalize(TextureMatrix * vec4(parmTexCoord.x, 0.0, parmTexCoord.y, 0.0)); // use texture matrix and coordinates for our normal. Since this is only used on walls, the normal's y coordinate is always 0. vec3 r = reflect(u, n.xyz); float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) ); vec2 sst = vec2(r.x/m + 0.5, r.y/m + 0.5); vTexCoord.xy = sst; #else - vTexCoord = TextureMatrix * vec4(aTexCoord, 0.0, 1.0); + vTexCoord = TextureMatrix * vec4(parmTexCoord, 0.0, 1.0); #endif gl_Position = ProjectionMatrix * eyeCoordPos; diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 7500a0cfc..3701694bc 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -45,6 +45,13 @@ uniform int uFogEnabled; // dynamic lights uniform int uLightIndex; +// quad drawer stuff +#ifdef USE_QUAD_DRAWER +uniform mat4 uQuadVertices; +uniform mat4 uQuadTexCoords; +uniform int uQuadMode; +#endif + // matrices uniform mat4 ProjectionMatrix; uniform mat4 ViewMatrix; From 250be72939aec68b5f27e6efdf956a33c482c5ea Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 22 Aug 2016 15:31:23 +0200 Subject: [PATCH 0825/1509] - added handling for drawing with uniform vertices. It draws something but in the wrong place. Right now I have no idea what's happening... --- src/gl/data/gl_vertexbuffer.cpp | 12 ++++++------ src/gl/renderer/gl_quaddrawer.h | 4 ++-- src/gl/shaders/gl_shader.cpp | 5 +++++ src/gl/system/gl_interface.cpp | 20 ++++++++++++++------ src/gl/system/gl_interface.h | 3 +-- wadsrc/static/shaders/glsl/main.vp | 13 ++++--------- 6 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 637de85aa..05fd475c0 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -137,9 +137,9 @@ void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count) //========================================================================== FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) -: FVertexBuffer(gl.buffermethod == BM_PERSISTENT) +: FVertexBuffer(gl.buffermethod != BM_CLIENTARRAY) { - if (gl.buffermethod == BM_PERSISTENT) + if (gl.buffermethod != BM_CLIENTARRAY) { unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); @@ -157,10 +157,10 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) vbo_shadowdata.Resize(mNumReserved); // the first quad is reserved for handling coordinates through uniforms. - vbo_shadowdata[0].Set(1, 0, 0, 0, 0); - vbo_shadowdata[1].Set(2, 0, 0, 0, 0); - vbo_shadowdata[2].Set(3, 0, 0, 0, 0); - vbo_shadowdata[3].Set(4, 0, 0, 0, 0); + vbo_shadowdata[0].Set(0, 0, 0, 0, 0); + vbo_shadowdata[1].Set(1, 0, 0, 0, 0); + vbo_shadowdata[2].Set(2, 0, 0, 0, 0); + vbo_shadowdata[3].Set(3, 0, 0, 0, 0); // and the second one for the fullscreen quad used for blend overlays. vbo_shadowdata[4].Set(0, 0, 0, 0, 0); diff --git a/src/gl/renderer/gl_quaddrawer.h b/src/gl/renderer/gl_quaddrawer.h index 3fcca65c2..b9db60684 100644 --- a/src/gl/renderer/gl_quaddrawer.h +++ b/src/gl/renderer/gl_quaddrawer.h @@ -14,7 +14,7 @@ public: FQuadDrawer() { - if (gl.flags & RFL_QUADHACK) + if (gl.buffermethod == BM_DEFERRED) { p = buffer; } @@ -29,7 +29,7 @@ public: } void Render(int type) { - if (gl.flags & RFL_QUADHACK) + if (gl.buffermethod == BM_DEFERRED) { DoRender(type); } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index c3f0f83da..67b9a2d6a 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -125,6 +125,10 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n"; } } + //if (gl.buffermethod == BM_DEFERRED) + { + vp_comb << "#define USE_QUAD_DRAWER\n"; + } vp_comb << defines << i_data.GetString().GetChars(); FString fp_comb = vp_comb; @@ -276,6 +280,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * } glUseProgram(hShader); + if (quadmode_index > 0) glUniform1i(quadmode_index, 0); // set up other texture units (if needed by the shader) for (int i = 2; i<16; i++) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 8c1e4cd9b..4d83ebec0 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -156,7 +156,15 @@ void gl_LoadExtensions() gl.version = strtod(version, NULL) + 0.01f; - // Don't even start if it's lower than 3.0 + bool iscore = false; + if (gl.version >= 3.2) + { + int v; + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &v); + iscore = !!(v & GL_CONTEXT_CORE_PROFILE_BIT); + } + + // Don't even start if it's lower than 2.0 or no framebuffers are available if ((gl.version < 2.0 || !CheckExtension("GL_EXT_framebuffer_object")) && gl.version < 3.0) { I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 2.0 with framebuffer support is required to run " GAMENAME ".\n"); @@ -178,10 +186,10 @@ void gl_LoadExtensions() if (gl.version > 3.0f && (gl.version >= 3.3f || CheckExtension("GL_ARB_uniform_buffer_object"))) { gl.lightmethod = LM_DEFERRED; - // Only Apple requires the core profile for GL 3.x+. - // #ifdef __APPLE__ - // gl.buffermethod = BM_DEFERRED; - // #endif + if (iscore) + { + gl.buffermethod = BM_DEFERRED; + } } if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION; @@ -256,7 +264,7 @@ void gl_LoadExtensions() lm = Args->CheckValue("-buffermethod"); if (lm != NULL) { - //if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED; + if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED; if (!stricmp(lm, "clientarray")) gl.buffermethod = BM_CLIENTARRAY; } diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 9eca673f5..11b0573e5 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -25,8 +25,7 @@ enum RenderFlags RFL_NO_DEPTHSTENCIL = 64, RFL_NO_CLIP_PLANES = 128, - RFL_INVALIDATE_BUFFER = 256, - RFL_QUADHACK = 512 + RFL_INVALIDATE_BUFFER = 256 }; enum TexMode diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 281c509d3..a2c1bac5b 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -15,6 +15,7 @@ void main() { vec2 parmTexCoord; vec4 parmPosition; + #ifndef USE_QUAD_DRAWER parmTexCoord = aTexCoord; parmPosition = aPosition; @@ -26,8 +27,8 @@ void main() } else { - parmPosition = uQuadVertices[int(aPosition.x)].st; - parmTexCoord = uQuadTexCoords[int(aPosition.x)]; + parmPosition = uQuadVertices[int(aPosition.x)]; + parmTexCoord = uQuadTexCoords[int(aPosition.x)].st; } #endif @@ -67,13 +68,7 @@ void main() #endif gl_Position = ProjectionMatrix * eyeCoordPos; - - #if defined __GLSL_CG_DATA_TYPES && defined GLSL12_COMPATIBILE - gl_ClipVertex = eyeCoordPos; - #endif - - - + if (uClipHeightDirection != 0.0) // clip planes used for reflective flats { gl_ClipDistance[0] = (worldcoord.y - uClipHeight) * uClipHeightDirection; From 1594cc95700ba77af4956899eb154002d551dcf7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 22 Aug 2016 19:25:13 +0200 Subject: [PATCH 0826/1509] Only use KHR_debug if available --- src/gl/system/gl_debug.cpp | 20 +++++++++++++++----- src/gl/system/gl_debug.h | 2 ++ src/gl/system/gl_interface.cpp | 1 + src/gl/system/gl_interface.h | 3 ++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/gl/system/gl_debug.cpp b/src/gl/system/gl_debug.cpp index 52fbadf33..023073951 100644 --- a/src/gl/system/gl_debug.cpp +++ b/src/gl/system/gl_debug.cpp @@ -49,7 +49,14 @@ #include #endif -CVAR(Int, gl_debug_level, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CUSTOM_CVAR(Int, gl_debug_level, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (!FGLDebug::HasDebugApi()) + { + Printf("No OpenGL debug support detected.\n"); + } +} + CVAR(Bool, gl_debug_breakpoint, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); //----------------------------------------------------------------------------- @@ -60,6 +67,9 @@ CVAR(Bool, gl_debug_breakpoint, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); void FGLDebug::Update() { + if (!HasDebugApi()) + return; + SetupBreakpointMode(); UpdateLoggingLevel(); OutputMessageLog(); @@ -74,7 +84,7 @@ void FGLDebug::Update() void FGLDebug::LabelObject(GLenum type, GLuint handle, const FString &name) { - if (gl_debug_level != 0) + if (HasDebugApi() && gl_debug_level != 0) { glObjectLabel(type, handle, (GLsizei)name.Len(), name.GetChars()); } @@ -82,7 +92,7 @@ void FGLDebug::LabelObject(GLenum type, GLuint handle, const FString &name) void FGLDebug::LabelObjectPtr(void *ptr, const FString &name) { - if (gl_debug_level != 0) + if (HasDebugApi() && gl_debug_level != 0) { glObjectPtrLabel(ptr, (GLsizei)name.Len(), name.GetChars()); } @@ -97,7 +107,7 @@ void FGLDebug::LabelObjectPtr(void *ptr, const FString &name) void FGLDebug::PushGroup(const FString &name) { - if (gl_debug_level != 0) + if (HasDebugApi() && gl_debug_level != 0) { glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, (GLsizei)name.Len(), name.GetChars()); } @@ -105,7 +115,7 @@ void FGLDebug::PushGroup(const FString &name) void FGLDebug::PopGroup() { - if (gl_debug_level != 0) + if (HasDebugApi() && gl_debug_level != 0) { glPopDebugGroup(); } diff --git a/src/gl/system/gl_debug.h b/src/gl/system/gl_debug.h index 1688297be..52645ec16 100644 --- a/src/gl/system/gl_debug.h +++ b/src/gl/system/gl_debug.h @@ -17,6 +17,8 @@ public: static void PushGroup(const FString &name); static void PopGroup(); + static bool HasDebugApi() { return (gl.flags & RFL_DEBUG) != 0; } + private: void SetupBreakpointMode(); void UpdateLoggingLevel(); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 4d83ebec0..30839e8f4 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -253,6 +253,7 @@ void gl_LoadExtensions() } if (gl.version >= 4.3f || CheckExtension("GL_ARB_invalidate_subdata")) gl.flags |= RFL_INVALIDATE_BUFFER; + if (gl.version >= 4.3f || CheckExtension("GL_KHR_debug")) gl.flags |= RFL_DEBUG; const char *lm = Args->CheckValue("-lightmethod"); if (lm != NULL) diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 11b0573e5..8300b9973 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -25,7 +25,8 @@ enum RenderFlags RFL_NO_DEPTHSTENCIL = 64, RFL_NO_CLIP_PLANES = 128, - RFL_INVALIDATE_BUFFER = 256 + RFL_INVALIDATE_BUFFER = 256, + RFL_DEBUG = 512 }; enum TexMode From 276fb7dbb2f43fcb0db6a5fc276495af6254316f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 22 Aug 2016 20:03:08 +0200 Subject: [PATCH 0827/1509] Add vid_maxfps support for Windows and Linux --- src/posix/sdl/sdlglvideo.cpp | 7 +++++++ src/win32/win32gliface.cpp | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 29c96d3ea..0635002e1 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -459,6 +459,13 @@ void SDLGLFB::NewRefreshRate () void SDLGLFB::SwapBuffers() { +#ifndef __APPLE__ + if (vid_maxfps && !cl_capfps) + { + SEMAPHORE_WAIT(FPSLimitSemaphore) + } +#endif + SDL_GL_SwapWindow (Screen); } diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 2edd89631..bec2a19cf 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -1149,6 +1149,11 @@ void Win32GLFrameBuffer::SetVSync (bool vsync) void Win32GLFrameBuffer::SwapBuffers() { + // Limiting the frame rate is as simple as waiting for the timer to signal this event. + if (FPSLimitEvent != NULL) + { + WaitForSingleObject(FPSLimitEvent, 1000); + } ::SwapBuffers(static_cast(Video)->m_hDC); } From b946114145fcaa3d62a25fb6a2d41ceaa670b3eb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 22 Aug 2016 21:59:03 +0200 Subject: [PATCH 0828/1509] - removed unused variable. --- src/gl/scene/gl_sprite.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 3dff0f32a..0c5b2581a 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -400,7 +400,6 @@ void GLSprite::Draw(int pass) v4 = FVector3(x2, z2, y2); } - FFlatVertex *ptr; FQuadDrawer qd; qd.Set(0, v1[0], v1[1], v1[2], ul, vt); qd.Set(1, v2[0], v2[1], v2[2], ur, vt); From 9555617816206fbe62dee5869aaa0c90223074b3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 22 Aug 2016 22:02:02 +0200 Subject: [PATCH 0829/1509] - fixed: The default for position.w is 1, so gl_quaddrawer.cpp needs to set this, too, for the uniform vertex positions. --- src/gl/renderer/gl_quaddrawer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_quaddrawer.cpp b/src/gl/renderer/gl_quaddrawer.cpp index b80f123e0..4dbd52a98 100644 --- a/src/gl/renderer/gl_quaddrawer.cpp +++ b/src/gl/renderer/gl_quaddrawer.cpp @@ -72,9 +72,10 @@ void FQuadDrawer::DoRender(int type) matV[i*4+0] = buffer[i].x; matV[i*4+1] = buffer[i].z; matV[i*4+2] = buffer[i].y; + matV[i*4+3] = 1; matT[i*4+0] = buffer[i].u; matT[i*4+1] = buffer[i].v; - matV[i*4+3] = matT[i*4+2] = matT[i*4+3] = 0; + matT[i*4+2] = matT[i*4+3] = 0; } FShader *shader = GLRenderer->mShaderManager->GetActiveShader(); glUniformMatrix4fv(shader->vertexmatrix_index, 1, false, matV); From 25645d901e4fd5b9ba7fa2fdbf730279f2cd3b62 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 23 Aug 2016 09:18:18 +0200 Subject: [PATCH 0830/1509] Add Palette LUT tonemap mode --- src/gl/renderer/gl_postprocess.cpp | 53 ++++++++++++++++++++++++- src/gl/renderer/gl_postprocessstate.cpp | 11 ++++- src/gl/renderer/gl_postprocessstate.h | 2 +- src/gl/renderer/gl_renderer.cpp | 2 + src/gl/renderer/gl_renderer.h | 3 ++ src/gl/shaders/gl_tonemapshader.cpp | 7 ++++ src/gl/shaders/gl_tonemapshader.h | 4 ++ wadsrc/static/language.enu | 3 +- wadsrc/static/menudef.z | 1 + wadsrc/static/shaders/glsl/tonemap.fp | 23 ++++++++++- 10 files changed, 102 insertions(+), 7 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 5f523e9eb..a9aec57c6 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -55,6 +55,7 @@ #include "r_utility.h" #include "a_hexenglobal.h" #include "p_local.h" +#include "colormatcher.h" #include "gl/gl_functions.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" @@ -89,7 +90,7 @@ CVAR(Float, gl_exposure, 0.0f, 0) CUSTOM_CVAR(Int, gl_tonemap, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) { - if (self < 0 || self > 4) + if (self < 0 || self > 5) self = 0; } @@ -222,13 +223,61 @@ void FGLRenderer::TonemapScene() mBuffers->BindCurrentTexture(0); mTonemapShader->Bind(); mTonemapShader->SceneTexture.Set(0); - mTonemapShader->Exposure.Set(mCameraExposure); + + if (mTonemapShader->IsPaletteMode()) + { + mTonemapShader->PaletteLUT.Set(1); + BindTonemapPalette(1); + } + else + { + mTonemapShader->Exposure.Set(mCameraExposure); + } + RenderScreenQuad(); mBuffers->NextTexture(); FGLDebug::PopGroup(); } +void FGLRenderer::BindTonemapPalette(int texunit) +{ + if (mTonemapPalette) + { + mTonemapPalette->Bind(texunit, 0, false); + } + else + { + TArray lut; + lut.Resize(512 * 512 * 4); + for (int r = 0; r < 64; r++) + { + for (int g = 0; g < 64; g++) + { + for (int b = 0; b < 64; b++) + { + PalEntry color = GPalette.BaseColors[ColorMatcher.Pick((r << 2) | (r >> 1), (g << 2) | (g >> 1), (b << 2) | (b >> 1))]; + int index = ((r * 64 + g) * 64 + b) * 4; + lut[index] = color.r; + lut[index + 1] = color.g; + lut[index + 2] = color.b; + lut[index + 3] = 255; + } + } + } + + mTonemapPalette = new FHardwareTexture(512, 512, true); + mTonemapPalette->CreateTexture(&lut[0], 512, 512, texunit, false, 0, "mTonemapPalette"); + + glActiveTexture(GL_TEXTURE0 + texunit); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glActiveTexture(GL_TEXTURE0); + } +} + //----------------------------------------------------------------------------- // // Apply lens distortion and place the result in the HUD/2D texture diff --git a/src/gl/renderer/gl_postprocessstate.cpp b/src/gl/renderer/gl_postprocessstate.cpp index 058e41190..05cca7f31 100644 --- a/src/gl/renderer/gl_postprocessstate.cpp +++ b/src/gl/renderer/gl_postprocessstate.cpp @@ -62,8 +62,12 @@ FGLPostProcessState::FGLPostProcessState() glBindTexture(GL_TEXTURE_2D, 0); if (gl.flags & RFL_SAMPLER_OBJECTS) { - glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding); + glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding[0]); glBindSampler(0, 0); + glActiveTexture(GL_TEXTURE0 + 1); + glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding[1]); + glBindSampler(1, 0); + glActiveTexture(GL_TEXTURE0); } glGetBooleanv(GL_BLEND, &blendEnabled); @@ -120,7 +124,10 @@ FGLPostProcessState::~FGLPostProcessState() glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); if (gl.flags & RFL_SAMPLER_OBJECTS) - glBindSampler(0, samplerBinding); + { + glBindSampler(0, samplerBinding[0]); + glBindSampler(1, samplerBinding[1]); + } glBindTexture(GL_TEXTURE_2D, textureBinding); glActiveTexture(activeTex); } diff --git a/src/gl/renderer/gl_postprocessstate.h b/src/gl/renderer/gl_postprocessstate.h index 5cba73674..4f2ca81a1 100644 --- a/src/gl/renderer/gl_postprocessstate.h +++ b/src/gl/renderer/gl_postprocessstate.h @@ -20,7 +20,7 @@ private: GLint activeTex; GLint textureBinding; - GLint samplerBinding; + GLint samplerBinding[2]; GLboolean blendEnabled; GLboolean scissorEnabled; GLboolean depthEnabled; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 9d2276b52..fba3a09ea 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -123,6 +123,7 @@ void FGLRenderer::Initialize(int width, int height) mBloomCombineShader = new FBloomCombineShader(); mBlurShader = new FBlurShader(); mTonemapShader = new FTonemapShader(); + mTonemapPalette = nullptr; mLensShader = new FLensShader(); mPresentShader = new FPresentShader(); m2DDrawer = new F2DDrawer; @@ -181,6 +182,7 @@ FGLRenderer::~FGLRenderer() if (mBloomCombineShader) delete mBloomCombineShader; if (mBlurShader) delete mBlurShader; if (mTonemapShader) delete mTonemapShader; + if (mTonemapPalette) delete mTonemapPalette; if (mLensShader) delete mLensShader; } diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 36654fad4..da2a11ed0 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -26,6 +26,7 @@ class FTonemapShader; class FLensShader; class FPresentShader; class F2DDrawer; +class FHardwareTexture; inline float DEG2RAD(float deg) { @@ -92,6 +93,7 @@ public: FBloomCombineShader *mBloomCombineShader; FBlurShader *mBlurShader; FTonemapShader *mTonemapShader; + FHardwareTexture *mTonemapPalette; FLensShader *mLensShader; FPresentShader *mPresentShader; @@ -164,6 +166,7 @@ public: void EndDrawScene(sector_t * viewsector); void BloomScene(); void TonemapScene(); + void BindTonemapPalette(int texunit); void LensDistortScene(); void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma); void Flush() { CopyToBackbuffer(nullptr, true); } diff --git a/src/gl/shaders/gl_tonemapshader.cpp b/src/gl/shaders/gl_tonemapshader.cpp index 8e1f3a844..56708a694 100644 --- a/src/gl/shaders/gl_tonemapshader.cpp +++ b/src/gl/shaders/gl_tonemapshader.cpp @@ -61,10 +61,16 @@ void FTonemapShader::Bind() shader.SetAttribLocation(0, "PositionInProjection"); SceneTexture.Init(shader, "InputTexture"); Exposure.Init(shader, "ExposureAdjustment"); + PaletteLUT.Init(shader, "PaletteLUT"); } shader.Bind(); } +bool FTonemapShader::IsPaletteMode() +{ + return gl_tonemap == Palette; +} + const char *FTonemapShader::GetDefines(int mode) { switch (mode) @@ -74,5 +80,6 @@ const char *FTonemapShader::GetDefines(int mode) case Reinhard: return "#define REINHARD\n"; case HejlDawson: return "#define HEJLDAWSON\n"; case Uncharted2: return "#define UNCHARTED2\n"; + case Palette: return "#define PALETTE\n"; } } diff --git a/src/gl/shaders/gl_tonemapshader.h b/src/gl/shaders/gl_tonemapshader.h index 846fdf659..9d427713f 100644 --- a/src/gl/shaders/gl_tonemapshader.h +++ b/src/gl/shaders/gl_tonemapshader.h @@ -10,6 +10,9 @@ public: FBufferedUniform1i SceneTexture; FBufferedUniform1f Exposure; + FBufferedUniform1i PaletteLUT; + + static bool IsPaletteMode(); private: enum TonemapMode @@ -19,6 +22,7 @@ private: HejlDawson, Reinhard, Linear, + Palette, NumTonemapModes }; diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 42190e5fa..1e20ebeb2 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2699,4 +2699,5 @@ OPTVAL_RIGHTEYE = "Right Eye"; OPTVAL_QUADBUFFERED = "Quad-buffered"; OPTVAL_UNCHARTED2 = "Uncharted 2"; OPTVAL_HEJLDAWSON = "Hejl Dawson"; -OPTVAL_REINHARD = "Reinhard"; \ No newline at end of file +OPTVAL_REINHARD = "Reinhard"; +OPTVAL_PALETTE = "Palette"; \ No newline at end of file diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index bd458f376..2386b1076 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -39,6 +39,7 @@ OptionValue "TonemapModes" 2, "$OPTVAL_HEJLDAWSON" 3, "$OPTVAL_REINHARD" 4, "$OPTVAL_LINEAR" + 5, "$OPTVAL_PALETTE" } OptionValue "TextureFormats" diff --git a/wadsrc/static/shaders/glsl/tonemap.fp b/wadsrc/static/shaders/glsl/tonemap.fp index 110cb6030..caf95f885 100644 --- a/wadsrc/static/shaders/glsl/tonemap.fp +++ b/wadsrc/static/shaders/glsl/tonemap.fp @@ -42,7 +42,7 @@ vec3 Tonemap(vec3 color) return (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06); // no sRGB needed } -#else +#elif defined(UNCHARTED2) vec3 Uncharted2Tonemap(vec3 x) { @@ -63,12 +63,33 @@ vec3 Tonemap(vec3 color) return sRGB(curr * whiteScale); } +#elif defined(PALETTE) + +uniform sampler2D PaletteLUT; + +vec3 Tonemap(vec3 color) +{ + ivec3 c = ivec3(clamp(color.rgb, vec3(0.0), vec3(1.0)) * 255.0 + 0.5); + int index = ((c.r >> 2) * 64 + (c.g >> 2)) * 64 + (c.b >> 2); + int tx = index % 512; + int ty = index / 512; + #if __VERSION__ < 130 + return texture2D(PaletteLUT, vec2(float(tx) / 512.0, float(ty) / 512.0))).rgb; + #else + return texelFetch(PaletteLUT, ivec2(tx, ty), 0).rgb; + #endif +} + +#else +#error "Tonemap mode define is missing" #endif void main() { vec3 color = texture(InputTexture, TexCoord).rgb; +#ifndef PALETTE color = color * ExposureAdjustment; color = Linear(color); // needed because gzdoom's scene texture is not linear at the moment +#endif FragColor = vec4(Tonemap(color), 1.0); } From a18588692418bec02f8c62f8e02fc369136aad17 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 24 Aug 2016 10:26:11 +0300 Subject: [PATCH 0831/1509] Added compatibility handling for fog and dynamic lights used together See http://forum.drdteam.org/viewtopic.php?t=7063 --- src/gl/scene/gl_flats.cpp | 1 + src/gl/scene/gl_walls_draw.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index d7c47c618..57861d1c1 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -448,6 +448,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG case GLPASS_LIGHTTEX: case GLPASS_LIGHTTEX_ADDITIVE: + case GLPASS_LIGHTTEX_FOGGY: DrawLightsCompat(pass); break; diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 67f40dd6d..5c0455fdb 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -448,6 +448,7 @@ void GLWall::Draw(int pass) case GLPASS_LIGHTTEX: case GLPASS_LIGHTTEX_ADDITIVE: + case GLPASS_LIGHTTEX_FOGGY: RenderLightsCompat(pass); break; From 52b51e79b9f40b924c9bbd656312f94b57f75abc Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 24 Aug 2016 10:27:14 +0300 Subject: [PATCH 0832/1509] Fixed missing decals in compatibility renderer The problem was appeared in conjunction with dynamic lights only See http://forum.zdoom.org/viewtopic.php?f=4&t=19321&start=405#p932733 --- src/gl/scene/gl_scene.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 6e1f9a565..24fd9a678 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -411,6 +411,8 @@ void FGLRenderer::RenderScene(int recursion) if (gl.lightmethod == LM_SOFTWARE) { // also process the render lists with walls and dynamic lights + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawDecals(); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawDecals(); } gl_RenderState.SetTextureMode(TM_MODULATE); From 2f893af857a5d70031f29fb35a6b07eff01b7f0a Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 24 Aug 2016 11:44:33 +0300 Subject: [PATCH 0833/1509] Fixed palette tonemap mode for OpenGL 2.x --- wadsrc/static/shaders/glsl/tonemap.fp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/wadsrc/static/shaders/glsl/tonemap.fp b/wadsrc/static/shaders/glsl/tonemap.fp index caf95f885..5a84ca5a4 100644 --- a/wadsrc/static/shaders/glsl/tonemap.fp +++ b/wadsrc/static/shaders/glsl/tonemap.fp @@ -70,14 +70,17 @@ uniform sampler2D PaletteLUT; vec3 Tonemap(vec3 color) { ivec3 c = ivec3(clamp(color.rgb, vec3(0.0), vec3(1.0)) * 255.0 + 0.5); +#if __VERSION__ < 130 + int index = (c.r / 4 * 64 + c.g / 4) * 64 + c.b / 4; + float tx = mod(index, 512) / 512.0; + float ty = float(index / 512) / 512.0; + return texture2D(PaletteLUT, vec2(tx, ty)).rgb; +#else int index = ((c.r >> 2) * 64 + (c.g >> 2)) * 64 + (c.b >> 2); int tx = index % 512; int ty = index / 512; - #if __VERSION__ < 130 - return texture2D(PaletteLUT, vec2(float(tx) / 512.0, float(ty) / 512.0))).rgb; - #else - return texelFetch(PaletteLUT, ivec2(tx, ty), 0).rgb; - #endif + return texelFetch(PaletteLUT, ivec2(tx, ty), 0).rgb; +#endif } #else From f79c442df533e26888eb748e14041eb71b1e6ab7 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 24 Aug 2016 16:44:40 +0300 Subject: [PATCH 0834/1509] Fixed compilation of SDL backend --- src/posix/sdl/sdlglvideo.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 0635002e1..0cd6b223b 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -49,7 +49,8 @@ EXTERN_CVAR (Float, Gamma) EXTERN_CVAR (Int, vid_adapter) EXTERN_CVAR (Int, vid_displaybits) EXTERN_CVAR (Int, vid_renderer) - +EXTERN_CVAR (Int, vid_maxfps) +EXTERN_CVAR (Bool, cl_capfps) // PUBLIC DATA DEFINITIONS ------------------------------------------------- From 9525d3690f64ac06c8f5cb083c122b4bbeaf1cf5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 25 Aug 2016 06:25:05 +0200 Subject: [PATCH 0835/1509] Added gl_light_math and changed pixelpos + lights to be in eye space --- src/gl/dynlights/gl_dynlight1.cpp | 29 ++++++- src/gl/renderer/gl_renderstate.cpp | 1 + src/gl/shaders/gl_shader.cpp | 1 + src/gl/shaders/gl_shader.h | 1 + src/gl/system/gl_cvars.h | 1 + wadsrc/static/language.enu | 6 +- wadsrc/static/menudef.z | 8 ++ wadsrc/static/shaders/glsl/main.fp | 102 ++++++++++++++++++++++-- wadsrc/static/shaders/glsl/main.vp | 2 +- wadsrc/static/shaders/glsl/shaderdefs.i | 1 + 10 files changed, 140 insertions(+), 12 deletions(-) diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index 361b94618..56db94e4d 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -80,6 +80,11 @@ CUSTOM_CVAR (Bool, gl_lights_additive, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG gl_RecreateAllAttachedLights(); } +CUSTOM_CVAR(Int, gl_light_math, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (self < 0 || self > 2) self = 0; +} + //========================================================================== // // Sets up the parameters to render one dynamic light onto one plane @@ -128,10 +133,28 @@ bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, bo i = 1; } + float worldPos[4] = { (float)pos.X, (float)pos.Z, (float)pos.Y, 1.0f }; + float eyePos[4]; + gl_RenderState.mViewMatrix.multMatrixPoint(worldPos, eyePos); + + if (gl_light_math != 0) + { + // Adjust light slightly to make the range better match plain attenuation + radius *= 1.5; + + // Move light up because flasks/vials have their light source location at/below the floor. + // + // If the point is exactly on the wall plane it might cause some acne as some pixels could + // be in front and some behind. Move light just a tiny bit to avoid this. + eyePos[0] += 0.01f; + eyePos[1] += 5.01f; + eyePos[2] += 0.01f; + } + float *data = &ldata.arrays[i][ldata.arrays[i].Reserve(8)]; - data[0] = pos.X; - data[1] = pos.Z; - data[2] = pos.Y; + data[0] = eyePos[0]; + data[1] = eyePos[1]; + data[2] = eyePos[2]; data[3] = radius; data[4] = r; data[5] = g; diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 83303d61e..61b3e13d7 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -144,6 +144,7 @@ bool FRenderState::ApplyShader() activeShader->muTimer.Set(gl_frameMS * mShaderTimer / 1000.f); activeShader->muAlphaThreshold.Set(mAlphaThreshold); activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now + activeShader->muLightMath.Set(gl_light_math); activeShader->muClipSplit.Set(mClipSplit); if (mGlowEnabled) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 67b9a2d6a..4acfd4bbe 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -246,6 +246,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muColormapStart.Init(hShader, "uFixedColormapStart"); muColormapRange.Init(hShader, "uFixedColormapRange"); muLightIndex.Init(hShader, "uLightIndex"); + muLightMath.Init(hShader, "uLightMath"); muFogColor.Init(hShader, "uFogColor"); muDynLightColor.Init(hShader, "uDynLightColor"); muObjectColor.Init(hShader, "uObjectColor"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 75e4b4e5e..09b43310d 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -221,6 +221,7 @@ class FShader FUniform1i muFixedColormap; FUniform4f muColormapStart; FUniform4f muColormapRange; + FBufferedUniform1i muLightMath; FBufferedUniform1i muLightIndex; FBufferedUniformPE muFogColor; FBufferedUniform4f muDynLightColor; diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index 0c31f53a8..290f3ea8c 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -29,6 +29,7 @@ EXTERN_CVAR (Float, gl_lights_size); EXTERN_CVAR (Bool, gl_lights_additive); EXTERN_CVAR (Bool, gl_light_sprites); EXTERN_CVAR (Bool, gl_light_particles); +EXTERN_CVAR (Int, gl_light_math); EXTERN_CVAR(Int, gl_fogmode) EXTERN_CVAR(Int, gl_lightmode) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 1e20ebeb2..79f71edf8 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2603,6 +2603,7 @@ GLLIGHTMNU_LIGHTPARTICLES = "Lights affect particles"; GLLIGHTMNU_FORCEADDITIVE = "Force additive lighting"; GLLIGHTMNU_LIGHTINTENSITY = "Light intensity"; GLLIGHTMNU_LIGHTSIZE = "Light size"; +GLLIGHTMNU_LIGHTMATH = "Light quality"; // OpenGL Preferences GLPREFMNU_TITLE = "OPENGL PREFERENCES"; @@ -2700,4 +2701,7 @@ OPTVAL_QUADBUFFERED = "Quad-buffered"; OPTVAL_UNCHARTED2 = "Uncharted 2"; OPTVAL_HEJLDAWSON = "Hejl Dawson"; OPTVAL_REINHARD = "Reinhard"; -OPTVAL_PALETTE = "Palette"; \ No newline at end of file +OPTVAL_PALETTE = "Palette"; +OPTVAL_LOW = "Low"; +OPTVAL_MEDIUM = "Medium"; +OPTVAL_HIGH = "High"; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 2386b1076..0d080d709 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -25,6 +25,13 @@ OptionValue "FilterModes" 4, "$OPTVAL_TRILINEAR" } +OptionValue "LightMathModes" +{ + 0, "$OPTVAL_LOW" + 1, "$OPTVAL_MEDIUM" + 2, "$OPTVAL_HIGH" +} + OptionValue "HWGammaModes" { 0, "$OPTVAL_ON" @@ -193,6 +200,7 @@ OptionMenu "GLLightOptions" Option "$GLLIGHTMNU_LIGHTSPRITES", gl_light_sprites, "YesNo" Option "$GLLIGHTMNU_LIGHTPARTICLES", gl_light_particles, "YesNo" Option "$GLLIGHTMNU_FORCEADDITIVE", gl_lights_additive, "YesNo" + Option "$GLLIGHTMNU_LIGHTMATH", gl_light_math, "LightMathModes" Slider "$GLLIGHTMNU_LIGHTINTENSITY", gl_lights_intensity, 0.0, 1.0, 0.1 Slider "$GLLIGHTMNU_LIGHTSIZE", gl_lights_size, 0.0, 2.0, 0.1 } diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index b10c99a17..2a783e00c 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -25,6 +25,88 @@ vec4 Process(vec4 color); vec4 ProcessTexel(); vec4 ProcessLight(vec4 color); +// Smoothed normal used for the face, in eye space. Should be converted to an 'in' variable in the future. +vec3 pixelnormal; + +//=========================================================================== +// +// Calculates the face normal vector for the fragment, in eye space +// +//=========================================================================== + +vec3 calculateFaceNormal() +{ +#if __VERSION__ < 450 + vec3 dFdxPos = dFdx(pixelpos.xyz); + vec3 dFdyPos = dFdy(pixelpos.xyz); +#else + vec3 dFdxPos = dFdxCoarse(pixelpos.xyz); + vec3 dFdyPos = dFdyCoarse(pixelpos.xyz); +#endif + return normalize(cross(dFdxPos,dFdyPos)); +} + +//=========================================================================== +// +// Standard lambertian diffuse light calculation +// +//=========================================================================== + +float diffuseContribution(vec3 eyeLightDirection, vec3 eyeNormal) +{ + return max(dot(eyeNormal, eyeLightDirection), 0.0f); +} + +//=========================================================================== +// +// Blinn specular light calculation +// +//=========================================================================== + +float blinnSpecularContribution(float diffuseContribution, vec3 eyeLightDirection, vec3 eyePosition, vec3 eyeNormal, float glossiness, float specularLevel) +{ + if (diffuseContribution > 0.0f) + { + vec3 viewDir = normalize(-eyePosition); + vec3 halfDir = normalize(eyeLightDirection + viewDir); + float specAngle = max(dot(halfDir, eyeNormal), 0.0f); + float phExp = glossiness * 4.0f; + return specularLevel * pow(specAngle, phExp); + } + else + { + return 0.0f; + } +} + +//=========================================================================== +// +// Calculates the brightness of a dynamic point light +// +//=========================================================================== + +float pointLightAttenuation(vec4 lightpos) +{ + float attenuation = max(lightpos.w - distance(pixelpos.xyz, lightpos.xyz),0.0) / lightpos.w; + if (uLightMath == 0) + { + return attenuation; + } + else + { + vec3 lightDirection = normalize(lightpos.xyz - pixelpos.xyz); + float diffuseAmount = diffuseContribution(lightDirection, pixelnormal); + if (uLightMath == 1) + { + return attenuation * diffuseAmount; + } + else + { + float specularAmount = blinnSpecularContribution(diffuseAmount, lightDirection, pixelpos.xyz, pixelnormal, 3.0, 1.2); + return attenuation * (diffuseAmount + specularAmount); + } + } +} //=========================================================================== // @@ -223,7 +305,7 @@ vec4 getLightColor(float fogdist, float fogfactor) vec4 lightpos = lights[i]; vec4 lightcolor = lights[i+1]; - lightcolor.rgb *= max(lightpos.w - distance(pixelpos.xyz, lightpos.xyz),0.0) / lightpos.w; + lightcolor.rgb *= pointLightAttenuation(lightpos); dynlight.rgb += lightcolor.rgb; } // @@ -233,8 +315,8 @@ vec4 getLightColor(float fogdist, float fogfactor) { vec4 lightpos = lights[i]; vec4 lightcolor = lights[i+1]; - - lightcolor.rgb *= max(lightpos.w - distance(pixelpos.xyz, lightpos.xyz),0.0) / lightpos.w; + + lightcolor.rgb *= pointLightAttenuation(lightpos); dynlight.rgb -= lightcolor.rgb; } } @@ -267,6 +349,13 @@ vec4 applyFog(vec4 frag, float fogfactor) void main() { vec4 frag = ProcessTexel(); + +#if defined NUM_UBO_LIGHTS || defined SHADER_STORAGE_LIGHTS + if (uLightMath != 0) // Remove this if pixelnormal is converted to an 'in' variable + { + pixelnormal = calculateFaceNormal(); + } +#endif #ifndef NO_ALPHATEST if (frag.a <= uAlphaThreshold) discard; @@ -292,12 +381,11 @@ void main() } else { - fogdist = max(16.0, distance(pixelpos.xyz, uCameraPos.xyz)); + fogdist = max(16.0, length(pixelpos.xyz)); } fogfactor = exp2 (uFogDensity * fogdist); } - frag *= getLightColor(fogdist, fogfactor); #if defined NUM_UBO_LIGHTS || defined SHADER_STORAGE_LIGHTS @@ -316,7 +404,7 @@ void main() vec4 lightpos = lights[i]; vec4 lightcolor = lights[i+1]; - lightcolor.rgb *= max(lightpos.w - distance(pixelpos.xyz, lightpos.xyz),0.0) / lightpos.w; + lightcolor.rgb *= pointLightAttenuation(lightpos); addlight.rgb += lightcolor.rgb; } frag.rgb = clamp(frag.rgb + desaturate(addlight).rgb, 0.0, 1.0); @@ -363,7 +451,7 @@ void main() } else { - fogdist = max(16.0, distance(pixelpos.xyz, uCameraPos.xyz)); + fogdist = max(16.0, length(pixelpos.xyz)); } fogfactor = exp2 (uFogDensity * fogdist); diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index a2c1bac5b..27faafb86 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -43,7 +43,7 @@ void main() vColor = aColor; #ifndef SIMPLE - pixelpos.xyz = worldcoord.xyz; + pixelpos.xyz = eyeCoordPos.xyz; pixelpos.w = -eyeCoordPos.z/eyeCoordPos.w; glowdist.x = -((uGlowTopPlane.w + uGlowTopPlane.x * worldcoord.x + uGlowTopPlane.y * worldcoord.z) * uGlowTopPlane.z) - worldcoord.y; diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 3701694bc..0f0545b2d 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -44,6 +44,7 @@ uniform int uFogEnabled; // dynamic lights uniform int uLightIndex; +uniform int uLightMath; // 0, when using only attenuation, 1 for diffuse light, 2 for blinn specular light // quad drawer stuff #ifdef USE_QUAD_DRAWER From 4ab8ca63cec13c2b8cf6b344b06f22d27ff36ee8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 25 Aug 2016 22:23:31 +0200 Subject: [PATCH 0836/1509] - use more desctiptive names for the predefined vertex buffer indices. --- src/gl/compatibility/gl_20.cpp | 2 ++ src/gl/data/gl_vertexbuffer.h | 7 +++++++ src/gl/renderer/gl_postprocess.cpp | 2 +- src/gl/renderer/gl_quaddrawer.cpp | 2 +- src/gl/scene/gl_wall.h | 3 +++ src/gl/scene/gl_walls.cpp | 5 +++++ 6 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index fb4064d3b..c1ba2d2db 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -772,11 +772,13 @@ void GLWall::RenderLightsCompat(int pass) } if (PrepareLight(light, pass)) { + vertcount = 0; RenderWall(RWF_TEXTURED, NULL); } node = node->nextLight; } memcpy(tcs, save, sizeof(tcs)); + vertcount = 0; } //========================================================================== diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index c9abae0da..5e6912a10 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -83,6 +83,13 @@ class FFlatVertexBuffer : public FVertexBuffer static const unsigned int BUFFER_SIZE_TO_USE = 1999500; public: + enum + { + QUAD_INDEX = 0, + FULLSCREEN_INDEX = 4, + PRESENT_INDEX = 8 + }; + TArray vbo_shadowdata; // this is kept around for updating the actual (non-readable) buffer and as stand-in for pre GL 4.x FFlatVertexBuffer(int width, int height); diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index a9aec57c6..c1b39e556 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -114,7 +114,7 @@ void FGLRenderer::RenderScreenQuad() { mVBO->BindVBO(); gl_RenderState.ResetVertexBuffer(); - glDrawArrays(GL_TRIANGLE_STRIP, 8, 4); + glDrawArrays(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); } //----------------------------------------------------------------------------- diff --git a/src/gl/renderer/gl_quaddrawer.cpp b/src/gl/renderer/gl_quaddrawer.cpp index 4dbd52a98..eedac12e5 100644 --- a/src/gl/renderer/gl_quaddrawer.cpp +++ b/src/gl/renderer/gl_quaddrawer.cpp @@ -81,6 +81,6 @@ void FQuadDrawer::DoRender(int type) glUniformMatrix4fv(shader->vertexmatrix_index, 1, false, matV); glUniformMatrix4fv(shader->texcoordmatrix_index, 1, false, matT); glUniform1i(shader->quadmode_index, 1); - GLRenderer->mVBO->RenderArray(type, 0, 4); + GLRenderer->mVBO->RenderArray(type, FFlatVertexBuffer::QUAD_INDEX, 4); glUniform1i(shader->quadmode_index, 0); } diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 674d7fffd..59f21dc37 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -172,6 +172,9 @@ public: float zceil[2]; float zfloor[2]; + unsigned int vertindex; + unsigned int vertcount; + public: seg_t * seg; // this gives the easiest access to all other structs involved subsector_t * sub; // For polyobjects diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index d8cef9771..54ba8c731 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1467,6 +1467,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) // note: we always have a valid sidedef and linedef reference when getting here. this->seg = seg; + vertindex = 0; + vertcount = 0; if ((seg->sidedef->Flags & WALLF_POLYOBJ) && seg->backsector) { @@ -1760,6 +1762,9 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * float ffh = frontsector->GetPlaneTexZ(sector_t::floor); float bfh = backsector->GetPlaneTexZ(sector_t::floor); + + vertindex = 0; + vertcount = 0; if (bfh > ffh) { this->seg = seg; From 8cf53f04e87151fbf317a1ad5f71d41dc0eb7abd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 25 Aug 2016 22:54:08 +0200 Subject: [PATCH 0837/1509] - split off the vertex creation from RenderWall. --- src/gl/scene/gl_wall.h | 1 + src/gl/scene/gl_walls_draw.cpp | 57 ++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 59f21dc37..f8d8ef1bb 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -195,6 +195,7 @@ private: void SetupLights(); bool PrepareLight(ADynamicLight * light, int pass); + void MakeVertices(bool nosplit); void RenderWall(int textured, unsigned int *store = NULL); void RenderTextured(int rflags); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 5c0455fdb..9f0d168a4 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -167,6 +167,36 @@ void GLWall::SetupLights() dynlightindex = GLRenderer->mLights->UploadLights(lightdata); } +//========================================================================== +// +// build the vertices for this wall +// +//========================================================================== + +void GLWall::MakeVertices(bool nosplit) +{ + if (vertcount == 0) + { + bool split = (gl_seamless && !nosplit && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT)); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + + ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v); + ptr++; + if (split && glseg.fracleft == 0) SplitLeftEdge(ptr); + ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v); + ptr++; + if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(ptr); + ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v); + ptr++; + if (split && glseg.fracright == 1) SplitRightEdge(ptr); + ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v); + ptr++; + if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(ptr); + vertcount = GLRenderer->mVBO->GetCount(ptr, &vertindex); + } +} + //========================================================================== // @@ -177,31 +207,18 @@ void GLWall::SetupLights() void GLWall::RenderWall(int textured, unsigned int *store) { - bool split = (gl_seamless && !(textured&RWF_NOSPLIT) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT)); - if (!(textured & RWF_NORENDER)) { gl_RenderState.Apply(); gl_RenderState.ApplyLightIndex(dynlightindex); } - - // the rest of the code is identical for textured rendering and lights - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - unsigned int count, offset; - - ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v); - ptr++; - if (split && glseg.fracleft == 0) SplitLeftEdge(ptr); - ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v); - ptr++; - if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(ptr); - ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v); - ptr++; - if (split && glseg.fracright == 1) SplitRightEdge(ptr); - ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v); - ptr++; - if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(ptr); - count = GLRenderer->mVBO->GetCount(ptr, &offset); + + if (gl.buffermethod != BM_DEFERRED) + { + MakeVertices(!(textured&RWF_NOSPLIT)); + } + + unsigned int count = vertcount, offset = vertindex; if (!(textured & RWF_NORENDER)) { GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, offset, count); From 8f331f56e29116fbe45c46ce5dcedc7e465b3c9f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 25 Aug 2016 23:02:43 +0200 Subject: [PATCH 0838/1509] - use MakeVertices directly in the portal code and remove all related code from RenderWall. --- src/gl/compatibility/gl_20.cpp | 2 +- src/gl/scene/gl_portal.cpp | 4 +++- src/gl/scene/gl_wall.h | 2 +- src/gl/scene/gl_walls_draw.cpp | 24 +++++------------------- 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index c1ba2d2db..f05256452 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -773,7 +773,7 @@ void GLWall::RenderLightsCompat(int pass) if (PrepareLight(light, pass)) { vertcount = 0; - RenderWall(RWF_TEXTURED, NULL); + RenderWall(RWF_TEXTURED); } node = node->nextLight; } diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 559c14976..bb7166805 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -152,7 +152,9 @@ void GLPortal::DrawPortalStencil() for (unsigned int i = 0; imVBO->RenderArray(GL_TRIANGLE_FAN, offset, count); - vertexcount += count; - } - if (store != NULL) - { - store[0] = offset; - store[1] = count; - } + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, vertindex, vertcount); + vertexcount += vertcount; } //========================================================================== From 4598c4138c98350d8059dc334105d9ed964df8f6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 25 Aug 2016 23:13:49 +0200 Subject: [PATCH 0839/1509] - added vertex initialization for walls in the processing pass for core profile without persistent buffers. This is slower than doing it in the render pass so it's only active when actually needed - it's also slower than using a client array so this code only gets used when there is no choice but to work with a 3.x core profile context. --- src/gl/scene/gl_drawinfo.cpp | 2 ++ src/gl/scene/gl_scene.cpp | 2 +- src/gl/scene/gl_walls.cpp | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 1d3936948..842423094 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -325,6 +325,7 @@ void GLDrawList::SortWallIntoPlane(SortNode * head,SortNode * sort) if (gl.glslversion < 1.3f) { GLWall * ws1; + ws->vertcount = 0; // invalidate current vertices. ws1=&walls[walls.Size()-1]; ws=&walls[drawitems[sort->itemindex].index]; // may have been reallocated! float newtexv = ws->tcs[GLWall::UPLFT].v + ((ws->tcs[GLWall::LOLFT].v - ws->tcs[GLWall::UPLFT].v) / (ws->zbottom[0] - ws->ztop[0])) * (fh->z - ws->ztop[0]); @@ -467,6 +468,7 @@ void GLDrawList::SortWallIntoWall(SortNode * head,SortNode * sort) float izt=(float)(ws->ztop[0]+r*(ws->ztop[1]-ws->ztop[0])); float izb=(float)(ws->zbottom[0]+r*(ws->zbottom[1]-ws->zbottom[0])); + ws->vertcount = 0; // invalidate current vertices. GLWall w=*ws; AddWall(&w); ws1=&walls[walls.Size()-1]; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 24fd9a678..ef82472e0 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -526,7 +526,7 @@ void gl_FillScreen() gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); // The fullscreen quad is stored at index 4 in the main vertex buffer. - glDrawArrays(GL_TRIANGLE_STRIP, 4, 4); + glDrawArrays(GL_TRIANGLE_STRIP, FFlatVertexBuffer::FULLSCREEN_INDEX, 4); } //========================================================================== diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 54ba8c731..3afde063c 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -135,6 +135,7 @@ void GLWall::PutWall(bool translucent) if (translucent) // translucent walls { ViewDistance = (ViewPos - (seg->linedef->v1->fPos() + seg->linedef->Delta() / 2)).XY().LengthSquared(); + if (gl.buffermethod == BM_DEFERRED) MakeVertices(true); gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this); } else @@ -157,16 +158,19 @@ void GLWall::PutWall(bool translucent) { list = masked ? GLDL_MASKEDWALLS : GLDL_PLAINWALLS; } + if (gl.buffermethod == BM_DEFERRED) MakeVertices(false); gl_drawinfo->drawlists[list].AddWall(this); } lightlist = NULL; + vertcount = 0; // make sure that following parts of the same linedef do not get this one's vertex info. } void GLWall::PutPortal(int ptype) { GLPortal * portal; + if (gl.buffermethod == BM_DEFERRED) MakeVertices(false); switch (ptype) { // portals don't go into the draw list. @@ -237,6 +241,7 @@ void GLWall::PutPortal(int ptype) portal->AddLine(this); break; } + vertcount = 0; } //========================================================================== // From 76d7b52fcdbbb7d27f1e02606fb7988563ae58f2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 25 Aug 2016 23:20:23 +0200 Subject: [PATCH 0840/1509] - handle the case where a wall gets drawn with an unmapped buffer and no vertex data. This uses the quad drawer because it can only happen with translucent walls that got split during sorting. --- src/gl/scene/gl_walls_draw.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index a8ae5fc79..585ced1a8 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -60,6 +60,7 @@ #include "gl/textures/gl_material.h" #include "gl/utility/gl_clock.h" #include "gl/utility/gl_templates.h" +#include "gl/renderer/gl_quaddrawer.h" EXTERN_CVAR(Bool, gl_seamless) @@ -213,6 +214,20 @@ void GLWall::RenderWall(int textured) { MakeVertices(!(textured&RWF_NOSPLIT)); } + else if (vertcount == 0) + { + // in case we get here without valid vertex data and no ability to create them now, + // use the quad drawer as fallback (without edge splitting.) + // This can only happen in one special situation, when a translucent line got split during sorting. + FQuadDrawer qd; + qd.Set(0, glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v); + qd.Set(1, glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v); + qd.Set(2, glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v); + qd.Set(3, glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v); + qd.Render(GL_TRIANGLE_FAN); + vertexcount += 4; + return; + } GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, vertindex, vertcount); vertexcount += vertcount; } From b83c2056a8a1d36eb037f461ad17a11a42a444f2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Aug 2016 00:01:51 +0200 Subject: [PATCH 0841/1509] - store the stencil caps in the reserved part of the main vertex buffer instead of constantly recreating them. --- src/gl/data/gl_vertexbuffer.cpp | 13 ++++++++++++- src/gl/data/gl_vertexbuffer.h | 6 +++++- src/gl/scene/gl_portal.cpp | 29 +++++++---------------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 05fd475c0..7e7784954 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -153,7 +153,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) map = new FFlatVertex[BUFFER_SIZE]; } mIndex = mCurIndex = 0; - mNumReserved = 12; + mNumReserved = NUM_RESERVED; vbo_shadowdata.Resize(mNumReserved); // the first quad is reserved for handling coordinates through uniforms. @@ -174,6 +174,17 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) vbo_shadowdata[10].Set(1.0f, -1.0f, 0, 1.f, 0.0f); vbo_shadowdata[11].Set(1.0f, 1.0f, 0, 1.f, 1.f); + // The next two are the stencil caps. + vbo_shadowdata[12].Set(-32767.0f, 32767.0f, -32767.0f, 0, 0); + vbo_shadowdata[13].Set(-32767.0f, 32767.0f, 32767.0f, 0, 0); + vbo_shadowdata[14].Set(32767.0f, 32767.0f, 32767.0f, 0, 0); + vbo_shadowdata[15].Set(32767.0f, 32767.0f, -32767.0f, 0, 0); + + vbo_shadowdata[16].Set(-32767.0f, -32767.0f, -32767.0f, 0, 0); + vbo_shadowdata[17].Set(-32767.0f, -32767.0f, 32767.0f, 0, 0); + vbo_shadowdata[18].Set(32767.0f, -32767.0f, 32767.0f, 0, 0); + vbo_shadowdata[19].Set(32767.0f, -32767.0f, -32767.0f, 0, 0); + } FFlatVertexBuffer::~FFlatVertexBuffer() diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 5e6912a10..68f101367 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -87,7 +87,11 @@ public: { QUAD_INDEX = 0, FULLSCREEN_INDEX = 4, - PRESENT_INDEX = 8 + PRESENT_INDEX = 8, + STENCILTOP_INDEX = 12, + STENCILBOTTOM_INDEX = 16, + + NUM_RESERVED = 20 }; TArray vbo_shadowdata; // this is kept around for updating the actual (non-readable) buffer and as stand-in for pre GL 4.x diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index bb7166805..628e0f915 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -147,40 +147,25 @@ void GLPortal::DrawPortalStencil() { if (mPrimIndices.Size() == 0) { - bool cap = NeedCap() && lines.Size() > 1; - mPrimIndices.Resize(2 * lines.Size() + 4 * cap); + mPrimIndices.Resize(2 * lines.Size()); - for (unsigned int i = 0; imVBO->GetBuffer(); - ptr[0].Set(-32767.0f, 32767.0f, -32767.0f, 0, 0); - ptr[1].Set(-32767.0f, 32767.0f, 32767.0f, 0, 0); - ptr[2].Set(32767.0f, 32767.0f, 32767.0f, 0, 0); - ptr[3].Set(32767.0f, 32767.0f, -32767.0f, 0, 0); - ptr += 4; - mPrimIndices[n + 1] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n]); - ptr[0].Set(-32767.0f, -32767.0f, -32767.0f, 0, 0); - ptr[1].Set(-32767.0f, -32767.0f, 32767.0f, 0, 0); - ptr[2].Set(32767.0f, -32767.0f, 32767.0f, 0, 0); - ptr[3].Set(32767.0f, -32767.0f, -32767.0f, 0, 0); - ptr += 4; - mPrimIndices[n + 3] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n + 2]); - } } gl_RenderState.Apply(); for (unsigned int i = 0; i < mPrimIndices.Size(); i += 2) { GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, mPrimIndices[i], mPrimIndices[i + 1]); } + if (NeedCap() && lines.Size() > 1) + { + glDrawArrays(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILTOP_INDEX, 4); + glDrawArrays(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILBOTTOM_INDEX, 4); + } } From 6755cb2a25e274803d30a1b8b7867339933d68e1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Aug 2016 00:02:32 +0200 Subject: [PATCH 0842/1509] - use the quad drawer for skybox-flagged sectors. --- src/gl/scene/gl_flats.cpp | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 57861d1c1..3ce888089 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -64,6 +64,7 @@ #include "gl/utility/gl_clock.h" #include "gl/utility/gl_convert.h" #include "gl/utility/gl_templates.h" +#include "gl/renderer/gl_quaddrawer.h" #ifdef _DEBUG CVAR(Int, gl_breaksec, -1, 0) @@ -318,7 +319,6 @@ void GLFlat::DrawSubsectors(int pass, bool processlights, bool istrans) void GLFlat::DrawSkyboxSector(int pass, bool processlights) { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); float minx = FLT_MAX, miny = FLT_MAX; float maxx = -FLT_MAX, maxy = -FLT_MAX; @@ -345,36 +345,13 @@ void GLFlat::DrawSkyboxSector(int pass, bool processlights) static float vvals[] = { 1, 0, 0, 1 }; int rot = -xs_FloorToInt(plane.Angle / 90.f); + FQuadDrawer qd; - ptr->x = minx; - ptr->z = z; - ptr->y = miny; - ptr->u = uvals[rot & 3]; - ptr->v = vvals[rot & 3]; - ptr++; - - ptr->x = minx; - ptr->z = z; - ptr->y = maxy; - ptr->u = uvals[(rot + 1) & 3]; - ptr->v = vvals[(rot + 1) & 3]; - ptr++; - - ptr->x = maxx; - ptr->z = z; - ptr->y = maxy; - ptr->u = uvals[(rot + 2) & 3]; - ptr->v = vvals[(rot + 2) & 3]; - ptr++; - - ptr->x = maxx; - ptr->z = z; - ptr->y = miny; - ptr->u = uvals[(rot + 3) & 3]; - ptr->v = vvals[(rot + 3) & 3]; - ptr++; - - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + qd.Set(0, minx, z, miny, uvals[rot & 3], vvals[rot & 3]); + qd.Set(1, minx, z, maxy, uvals[(rot + 1) & 3], vvals[(rot + 1) & 3]); + qd.Set(2, maxx, z, maxy, uvals[(rot + 2) & 3], vvals[(rot + 2) & 3]); + qd.Set(3, maxx, z, miny, uvals[(rot + 3) & 3], vvals[(rot + 3) & 3]); + qd.Render(GL_TRIANGLE_FAN); flatvertices += 4; flatprimitives++; From f6544f3c4472062cfe43dbd2d04dc7d5a8f91f77 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Aug 2016 00:04:29 +0200 Subject: [PATCH 0843/1509] - removed unused GLFLat::sub and all codes depending on it a valid pointer. --- src/gl/compatibility/gl_20.cpp | 40 +++++------ src/gl/scene/gl_flats.cpp | 118 ++++++++++++++------------------- src/gl/scene/gl_wall.h | 1 - 3 files changed, 66 insertions(+), 93 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index f05256452..8e6682f17 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -647,35 +647,27 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) void GLFlat::DrawLightsCompat(int pass) { gl_RenderState.Apply(); - if (sub) + // Draw the subsectors belonging to this sector + for (int i = 0; isubsectorcount; i++) { - // This represents a single subsector - DrawSubsectorLights(sub, pass); - } - else - { - // Draw the subsectors belonging to this sector - for (int i = 0; isubsectorcount; i++) + subsector_t * sub = sector->subsectors[i]; + if (gl_drawinfo->ss_renderflags[sub - subsectors] & renderflags) { - subsector_t * sub = sector->subsectors[i]; - if (gl_drawinfo->ss_renderflags[sub - subsectors] & renderflags) - { - DrawSubsectorLights(sub, pass); - } + DrawSubsectorLights(sub, pass); } + } - // Draw the subsectors assigned to it due to missing textures - if (!(renderflags&SSRF_RENDER3DPLANES)) + // Draw the subsectors assigned to it due to missing textures + if (!(renderflags&SSRF_RENDER3DPLANES)) + { + gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR) ? + gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) : + gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum); + + while (node) { - gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR) ? - gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) : - gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum); - - while (node) - { - DrawSubsectorLights(node->sub, pass); - node = node->next; - } + DrawSubsectorLights(node->sub, pass); + node = node->next; } } } diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 3ce888089..bd55a1a09 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -204,35 +204,27 @@ void GLFlat::ProcessLights(bool istrans) { dynlightindex = GLRenderer->mLights->GetIndexPtr(); - if (sub) + // Draw the subsectors belonging to this sector + for (int i=0; isubsectorcount; i++) { - // This represents a single subsector - SetupSubsectorLights(GLPASS_LIGHTSONLY, sub); - } - else - { - // Draw the subsectors belonging to this sector - for (int i=0; isubsectorcount; i++) + subsector_t * sub = sector->subsectors[i]; + if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) { - subsector_t * sub = sector->subsectors[i]; - if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) - { - SetupSubsectorLights(GLPASS_LIGHTSONLY, sub); - } + SetupSubsectorLights(GLPASS_LIGHTSONLY, sub); } + } - // Draw the subsectors assigned to it due to missing textures - if (!(renderflags&SSRF_RENDER3DPLANES)) + // Draw the subsectors assigned to it due to missing textures + if (!(renderflags&SSRF_RENDER3DPLANES)) + { + gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR)? + gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) : + gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum); + + while (node) { - gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR)? - gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) : - gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum); - - while (node) - { - SetupSubsectorLights(GLPASS_LIGHTSONLY, node->sub); - node = node->next; - } + SetupSubsectorLights(GLPASS_LIGHTSONLY, node->sub); + node = node->next; } } } @@ -249,60 +241,51 @@ void GLFlat::DrawSubsectors(int pass, bool processlights, bool istrans) int dli = dynlightindex; gl_RenderState.Apply(); - if (sub) + if (vboindex >= 0) { - // This represents a single subsector - if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli); - DrawSubsector(sub); - } - else - { - if (vboindex >= 0) + int index = vboindex; + for (int i=0; isubsectorcount; i++) { - int index = vboindex; - for (int i=0; isubsectorcount; i++) - { - subsector_t * sub = sector->subsectors[i]; + subsector_t * sub = sector->subsectors[i]; - if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) - { - if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli); - drawcalls.Clock(); - glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines); - drawcalls.Unclock(); - flatvertices += sub->numlines; - flatprimitives++; - } - index += sub->numlines; + if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) + { + if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli); + drawcalls.Clock(); + glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines); + drawcalls.Unclock(); + flatvertices += sub->numlines; + flatprimitives++; } + index += sub->numlines; } - else + } + else + { + // Draw the subsectors belonging to this sector + for (int i=0; isubsectorcount; i++) { - // Draw the subsectors belonging to this sector - for (int i=0; isubsectorcount; i++) + subsector_t * sub = sector->subsectors[i]; + if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) { - subsector_t * sub = sector->subsectors[i]; - if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) - { - if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli); - DrawSubsector(sub); - } + if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli); + DrawSubsector(sub); } } + } - // Draw the subsectors assigned to it due to missing textures - if (!(renderflags&SSRF_RENDER3DPLANES)) - { - gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR)? - gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) : - gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum); + // Draw the subsectors assigned to it due to missing textures + if (!(renderflags&SSRF_RENDER3DPLANES)) + { + gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR)? + gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) : + gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum); - while (node) - { - if (processlights) SetupSubsectorLights(GLPASS_ALL, node->sub, &dli); - DrawSubsector(node->sub); - node = node->next; - } + while (node) + { + if (processlights) SetupSubsectorLights(GLPASS_ALL, node->sub, &dli); + DrawSubsector(node->sub); + node = node->next; } } } @@ -565,7 +548,6 @@ void GLFlat::ProcessSector(sector_t * frontsector) // Get the real sector for this one. sector = §ors[frontsector->sectornum]; extsector_t::xfloor &x = sector->e->XFloor; - this->sub = NULL; dynlightindex = -1; byte &srf = gl_drawinfo->sectorrenderflags[sector->sectornum]; diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 60da86130..ae7014c7d 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -288,7 +288,6 @@ public: friend struct GLDrawList; sector_t * sector; - subsector_t * sub; // only used for translucent planes float dz; // z offset for rendering hacks float z; // the z position of the flat (only valid for non-sloped planes) FMaterial *gltexture; From 960038bb81631f70d4afb55fb7c0a3beaffcbd79 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 26 Aug 2016 01:36:21 +0200 Subject: [PATCH 0844/1509] Clear global state tracking variables when the OpenGL context is (re)created --- src/gl/renderer/gl_renderstate.cpp | 25 +++++++++++++++++++++++++ src/gl/system/gl_framebuffer.cpp | 5 +++++ src/gl/textures/gl_hwtexture.h | 4 ++-- src/gl/textures/gl_material.cpp | 6 ++++++ src/gl/textures/gl_material.h | 1 + 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 83303d61e..56b319f00 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -80,19 +80,44 @@ void FRenderState::Reset() mDstBlend = GL_ONE_MINUS_SRC_ALPHA; mAlphaThreshold = 0.5f; mBlendEquation = GL_FUNC_ADD; + mModelMatrixEnabled = false; + mTextureMatrixEnabled = false; mObjectColor = 0xffffffff; mVertexBuffer = mCurrentVertexBuffer = NULL; mColormapState = CM_DEFAULT; + mSoftLight = 0; + mLightParms[0] = mLightParms[1] = mLightParms[2] = 0.0f; mLightParms[3] = -1.f; mSpecialEffect = EFF_NONE; mClipHeight = 0.f; mClipHeightDirection = 0.f; + mShaderTimer = 0.0f; ClearClipSplit(); stSrcBlend = stDstBlend = -1; stBlendEquation = -1; stAlphaThreshold = -1.f; + stAlphaTest = 0; mLastDepthClamp = true; + mInterpolationFactor = 0.0f; + + mColor.Set(0.0f, 0.0f, 0.0f, 0.0f); + mCameraPos.Set(0.0f, 0.0f, 0.0f, 0.0f); + mGlowTop.Set(0.0f, 0.0f, 0.0f, 0.0f); + mGlowBottom.Set(0.0f, 0.0f, 0.0f, 0.0f); + mGlowTopPlane.Set(0.0f, 0.0f, 0.0f, 0.0f); + mGlowBottomPlane.Set(0.0f, 0.0f, 0.0f, 0.0f); + mSplitTopPlane.Set(0.0f, 0.0f, 0.0f, 0.0f); + mSplitBottomPlane.Set(0.0f, 0.0f, 0.0f, 0.0f); + mClipLine.Set(0.0f, 0.0f, 0.0f, 0.0f); + mDynColor.Set(0.0f, 0.0f, 0.0f, 0.0f); + mClipSplit[0] = mClipSplit[1] = 0.0f; + mEffectState = 0; + activeShader = nullptr; + mProjectionMatrix.loadIdentity(); + mViewMatrix.loadIdentity(); + mModelMatrix.loadIdentity(); + mTextureMatrix.loadIdentity(); } //========================================================================== diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 6d56c1b27..ec8b3f599 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -99,6 +99,11 @@ OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int // If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed! SetVSync(vid_vsync); + // Make sure all global variables tracking OpenGL context state are reset.. + FHardwareTexture::InitGlobalState(); + FMaterial::InitGlobalState(); + gl_RenderState.Reset(); + GLRenderer = new FGLRenderer(this); memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256); UpdatePalette (); diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h index 9b7028f8c..4c00af272 100644 --- a/src/gl/textures/gl_hwtexture.h +++ b/src/gl/textures/gl_hwtexture.h @@ -48,11 +48,11 @@ private: public: static unsigned int lastbound[MAX_TEXTURES]; - static int lastactivetexture; - static int max_texturesize; static int GetTexDimension(int value); + static void InitGlobalState() { for (int i = 0; i < MAX_TEXTURES; i++) lastbound[i] = 0; } + private: short texwidth, texheight; diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 8e0ab73e6..6ba1fe4b0 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -669,6 +669,12 @@ static FMaterial *last; static int lastclamp; static int lasttrans; +void FMaterial::InitGlobalState() +{ + last = nullptr; + lastclamp = 0; + lasttrans = 0; +} void FMaterial::Bind(int clampmode, int translation) { diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index dea0d4cf5..d44a845f6 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -263,6 +263,7 @@ public: static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans); static void ClearLastTexture(); + static void InitGlobalState(); }; #endif From b68bbaf617974d669d3cd13c69efcfdbdf4bd1fb Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 26 Aug 2016 01:40:28 +0200 Subject: [PATCH 0845/1509] Fix uninitialized memory access if a FShaderProgram is destroyed without being fully compiled and linked --- src/gl/shaders/gl_shaderprogram.cpp | 6 ++++++ src/gl/shaders/gl_shaderprogram.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/gl/shaders/gl_shaderprogram.cpp b/src/gl/shaders/gl_shaderprogram.cpp index 63ce09261..959315a9d 100644 --- a/src/gl/shaders/gl_shaderprogram.cpp +++ b/src/gl/shaders/gl_shaderprogram.cpp @@ -52,6 +52,12 @@ #include "i_system.h" #include "doomerrors.h" +FShaderProgram::FShaderProgram() +{ + for (int i = 0; i < NumShaderTypes; i++) + mShaders[i] = 0; +} + //========================================================================== // // Free shader program resources diff --git a/src/gl/shaders/gl_shaderprogram.h b/src/gl/shaders/gl_shaderprogram.h index 16684ddff..64a36db49 100644 --- a/src/gl/shaders/gl_shaderprogram.h +++ b/src/gl/shaders/gl_shaderprogram.h @@ -6,6 +6,7 @@ class FShaderProgram { public: + FShaderProgram(); ~FShaderProgram(); enum ShaderType @@ -30,6 +31,9 @@ public: static void PatchFragShader(FString &code); private: + FShaderProgram(const FShaderProgram &) = delete; + FShaderProgram &operator=(const FShaderProgram &) = delete; + static FString PatchShader(ShaderType type, const FString &code, const char *defines, int maxGlslVersion); static void PatchCommon(FString &code); From 5f09d3b7ef7b8915d9e69b310fa2bf12fd5b4ce6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 26 Aug 2016 01:46:39 +0200 Subject: [PATCH 0846/1509] Add FBufferedUniformSampler because sampler uniforms may default bind to other locations than zero --- src/gl/shaders/gl_bloomshader.h | 4 ++-- src/gl/shaders/gl_lensshader.h | 2 +- src/gl/shaders/gl_presentshader.h | 2 +- src/gl/shaders/gl_shader.h | 22 ++++++++++++++++++++++ src/gl/shaders/gl_tonemapshader.h | 4 ++-- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/gl/shaders/gl_bloomshader.h b/src/gl/shaders/gl_bloomshader.h index cbc740ab6..b20277a42 100644 --- a/src/gl/shaders/gl_bloomshader.h +++ b/src/gl/shaders/gl_bloomshader.h @@ -8,7 +8,7 @@ class FBloomExtractShader public: void Bind(); - FBufferedUniform1i SceneTexture; + FBufferedUniformSampler SceneTexture; FBufferedUniform1f Exposure; FBufferedUniform2f Scale; FBufferedUniform2f Offset; @@ -22,7 +22,7 @@ class FBloomCombineShader public: void Bind(); - FBufferedUniform1i BloomTexture; + FBufferedUniformSampler BloomTexture; private: FShaderProgram mShader; diff --git a/src/gl/shaders/gl_lensshader.h b/src/gl/shaders/gl_lensshader.h index ef0810e4e..7e9ef6392 100644 --- a/src/gl/shaders/gl_lensshader.h +++ b/src/gl/shaders/gl_lensshader.h @@ -8,7 +8,7 @@ class FLensShader public: void Bind(); - FBufferedUniform1i InputTexture; + FBufferedUniformSampler InputTexture; FBufferedUniform1f AspectRatio; FBufferedUniform1f Scale; FBufferedUniform4f LensDistortionCoefficient; diff --git a/src/gl/shaders/gl_presentshader.h b/src/gl/shaders/gl_presentshader.h index b54fa2e36..6f4e899bb 100644 --- a/src/gl/shaders/gl_presentshader.h +++ b/src/gl/shaders/gl_presentshader.h @@ -8,7 +8,7 @@ class FPresentShader public: void Bind(); - FBufferedUniform1i InputTexture; + FBufferedUniformSampler InputTexture; FBufferedUniform1f InvGamma; FBufferedUniform1f Contrast; FBufferedUniform1f Brightness; diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 75e4b4e5e..52ca59ec7 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -201,6 +201,28 @@ public: } }; +class FBufferedUniformSampler +{ + int mBuffer; + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + mBuffer = -1; + } + + void Set(int newvalue) + { + if (newvalue != mBuffer) + { + mBuffer = newvalue; + glUniform1i(mIndex, newvalue); + } + } +}; + class FShader { diff --git a/src/gl/shaders/gl_tonemapshader.h b/src/gl/shaders/gl_tonemapshader.h index 9d427713f..7ec24117b 100644 --- a/src/gl/shaders/gl_tonemapshader.h +++ b/src/gl/shaders/gl_tonemapshader.h @@ -8,9 +8,9 @@ class FTonemapShader public: void Bind(); - FBufferedUniform1i SceneTexture; + FBufferedUniformSampler SceneTexture; FBufferedUniform1f Exposure; - FBufferedUniform1i PaletteLUT; + FBufferedUniformSampler PaletteLUT; static bool IsPaletteMode(); From abba548e40737f5621725e1d1edec02c13521b6e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Aug 2016 02:03:24 +0200 Subject: [PATCH 0847/1509] - render sector hacks through the quad renderer if the vertex buffer is not accessible. --- src/gl/scene/gl_flats.cpp | 50 +++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index bd55a1a09..605897127 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -47,6 +47,7 @@ #include "doomstat.h" #include "d_player.h" #include "portal.h" +#include "templates.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" @@ -176,18 +177,46 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli) void GLFlat::DrawSubsector(subsector_t * sub) { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - for (unsigned int k = 0; k < sub->numlines; k++) + if (gl.buffermethod != BM_DEFERRED) { - vertex_t *vt = sub->firstline[k].v1; - ptr->x = vt->fX(); - ptr->z = plane.plane.ZatPoint(vt) + dz; - ptr->y = vt->fY(); - ptr->u = vt->fX() / 64.f; - ptr->v = -vt->fY() / 64.f; - ptr++; + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (unsigned int k = 0; k < sub->numlines; k++) + { + vertex_t *vt = sub->firstline[k].v1; + ptr->x = vt->fX(); + ptr->z = plane.plane.ZatPoint(vt) + dz; + ptr->y = vt->fY(); + ptr->u = vt->fX() / 64.f; + ptr->v = -vt->fY() / 64.f; + ptr++; + } + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + } + else + { + // if we cannot access the buffer, use the quad drawer as fallback by splitting the subsector into quads. + // Trying to get this into the vertex buffer in the processing pass is too costly and this is only used for render hacks. + FQuadDrawer qd; + unsigned int vi[4]; + + vi[0] = 0; + for (unsigned int i = 1; i < sub->numlines; i += 2) + { + if (i < sub->numlines - 3) + { + for (unsigned int j = 1; j < 4; j++) + { + vi[j] = MIN(i + j, sub->numlines - 1); + } + for (unsigned int x = 0; x < 4; x++) + { + vertex_t *vt = sub->firstline[vi[x]].v1; + qd.Set(x, vt->fX(), plane.plane.ZatPoint(vt) + dz, vt->fY(), vt->fX() / 64.f, -vt->fY() / 64.f); + } + qd.Render(GL_TRIANGLE_FAN); + } + } } - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); flatvertices += sub->numlines; flatprimitives++; @@ -263,6 +292,7 @@ void GLFlat::DrawSubsectors(int pass, bool processlights, bool istrans) else { // Draw the subsectors belonging to this sector + // (can this case even happen?) for (int i=0; isubsectorcount; i++) { subsector_t * sub = sector->subsectors[i]; From 597e10116f5df541c4132124c6a4035b296eb18c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Aug 2016 08:30:47 +0200 Subject: [PATCH 0848/1509] - added missing framebuffer function to fudging block. --- src/gl/system/gl_interface.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 30839e8f4..a7b1be648 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -307,6 +307,7 @@ void gl_LoadExtensions() FUDGE_FUNC(glDeleteRenderbuffers, EXT); FUDGE_FUNC(glRenderbufferStorage, EXT); FUDGE_FUNC(glBindRenderbuffer, EXT); + FUDGE_FUNC(glCheckFramebufferStatus, EXT); gl_PatchMenu(); } From c9578ae72df9e8bf8826c7915cef68f666389c58 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Aug 2016 18:18:50 +0200 Subject: [PATCH 0849/1509] - create vertex buffer data for horizon portals in the constructor instead of in the draw function. This was the last remaining place where the vertex buffer was accessed in the render pass. --- src/gl/scene/gl_flats.cpp | 2 +- src/gl/scene/gl_portal.cpp | 119 ++++++++++++++++++++----------------- src/gl/scene/gl_portal.h | 9 +-- 3 files changed, 68 insertions(+), 62 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 605897127..8b665648e 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -200,7 +200,7 @@ void GLFlat::DrawSubsector(subsector_t * sub) unsigned int vi[4]; vi[0] = 0; - for (unsigned int i = 1; i < sub->numlines; i += 2) + for (unsigned int i = 1; i < sub->numlines-1; i += 2) { if (i < sub->numlines - 3) { diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 628e0f915..4b8d8eb27 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -1070,6 +1070,66 @@ void GLLineToLinePortal::RenderAttached() // //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- + +GLHorizonPortal::GLHorizonPortal(GLHorizonInfo * pt, bool local) + : GLPortal(local) +{ + origin = pt; + + // create the vertex data for this horizon portal. + GLSectorPlane * sp = &origin->plane; + const float vx = ViewPos.X; + const float vy = ViewPos.Y; + const float vz = ViewPos.Z; + const float z = sp->Texheight; + const float tz = (z - vz); + + // Draw to some far away boundary + // This is not drawn as larger strips because it causes visual glitches. + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (float x = -32768 + vx; x<32768 + vx; x += 4096) + { + for (float y = -32768 + vy; y<32768 + vy; y += 4096) + { + ptr->Set(x, z, y, x / 64, -y / 64); + ptr++; + ptr->Set(x + 4096, z, y, x / 64 + 64, -y / 64); + ptr++; + ptr->Set(x, z, y + 4096, x / 64, -y / 64 - 64); + ptr++; + ptr->Set(x + 4096, z, y + 4096, x / 64 + 64, -y / 64 - 64); + ptr++; + } + } + + // fill the gap between the polygon and the true horizon + // Since I can't draw into infinity there can always be a + // small gap + ptr->Set(-32768 + vx, z, -32768 + vy, 512.f, 0); + ptr++; + ptr->Set(-32768 + vx, vz, -32768 + vy, 512.f, tz); + ptr++; + ptr->Set(-32768 + vx, z, 32768 + vy, -512.f, 0); + ptr++; + ptr->Set(-32768 + vx, vz, 32768 + vy, -512.f, tz); + ptr++; + ptr->Set(32768 + vx, z, 32768 + vy, 512.f, 0); + ptr++; + ptr->Set(32768 + vx, vz, 32768 + vy, 512.f, tz); + ptr++; + ptr->Set(32768 + vx, z, -32768 + vy, -512.f, 0); + ptr++; + ptr->Set(32768 + vx, vz, -32768 + vy, -512.f, tz); + ptr++; + ptr->Set(-32768 + vx, z, -32768 + vy, 512.f, 0); + ptr++; + ptr->Set(-32768 + vx, vz, -32768 + vy, 512.f, tz); + ptr++; + + vcount = GLRenderer->mVBO->GetCount(ptr, &voffset) - 10; + +} + //----------------------------------------------------------------------------- // // GLHorizonPortal::DrawContents @@ -1079,11 +1139,10 @@ void GLHorizonPortal::DrawContents() { PortalAll.Clock(); - GLSectorPlane * sp=&origin->plane; FMaterial * gltexture; PalEntry color; - float z; player_t * player=&players[consoleplayer]; + GLSectorPlane * sp = &origin->plane; gltexture=FMaterial::ValidateTexture(sp->texture, false, true); if (!gltexture) @@ -1095,9 +1154,6 @@ void GLHorizonPortal::DrawContents() gl_RenderState.SetCameraPos(ViewPos.X, ViewPos.Y, ViewPos.Z); - z=sp->Texheight; - - if (gltexture && gltexture->tex->isFullbright()) { // glowing textures are always drawn full bright without color @@ -1120,58 +1176,11 @@ void GLHorizonPortal::DrawContents() gl_RenderState.Apply(); - - float vx= ViewPos.X; - float vy= ViewPos.Y; - - // Draw to some far away boundary - // This is not drawn as larher strips because it causes visual glitches. - for(float x=-32768+vx; x<32768+vx; x+=4096) + for (unsigned i = 0; i < vcount; i += 4) { - for(float y=-32768+vy; y<32768+vy;y+=4096) - { - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(x, z, y, x / 64, -y / 64); - ptr++; - ptr->Set(x + 4096, z, y, x / 64 + 64, -y / 64); - ptr++; - ptr->Set(x, z, y + 4096, x / 64, -y / 64 - 64); - ptr++; - ptr->Set(x + 4096, z, y + 4096, x / 64 + 64, -y / 64 - 64); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); - } + glDrawArrays(GL_TRIANGLE_STRIP, voffset + i, 4); } - - float vz= ViewPos.Z; - float tz=(z-vz);///64.0f; - - // fill the gap between the polygon and the true horizon - // Since I can't draw into infinity there can always be a - // small gap - - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->Set(-32768 + vx, z, -32768 + vy, 512.f, 0); - ptr++; - ptr->Set(-32768 + vx, vz, -32768 + vy, 512.f, tz); - ptr++; - ptr->Set(-32768 + vx, z, 32768 + vy, -512.f, 0); - ptr++; - ptr->Set(-32768 + vx, vz, 32768 + vy, -512.f, tz); - ptr++; - ptr->Set(32768 + vx, z, 32768 + vy, 512.f, 0); - ptr++; - ptr->Set(32768 + vx, vz, 32768 + vy, 512.f, tz); - ptr++; - ptr->Set(32768 + vx, z, -32768 + vy, -512.f, 0); - ptr++; - ptr->Set(32768 + vx, vz, -32768 + vy, -512.f, tz); - ptr++; - ptr->Set(-32768 + vx, z, -32768 + vy, 512.f, 0); - ptr++; - ptr->Set(-32768 + vx, vz, -32768 + vy, 512.f, tz); - ptr++; - GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + glDrawArrays(GL_TRIANGLE_STRIP, voffset + vcount, 10); gl_RenderState.EnableTextureMatrix(false); PortalAll.Unclock(); diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 7b9f896db..fbd3a0c7f 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -365,6 +365,8 @@ public: struct GLHorizonPortal : public GLPortal { GLHorizonInfo * origin; + unsigned int voffset; + unsigned int vcount; friend struct GLEEHorizonPortal; protected: @@ -376,12 +378,7 @@ protected: public: - GLHorizonPortal(GLHorizonInfo * pt, bool local = false) - : GLPortal(local) - { - origin=pt; - } - + GLHorizonPortal(GLHorizonInfo * pt, bool local = false); }; struct GLEEHorizonPortal : public GLPortal From b1a0108a961ec24ec7af922b60355947c453e31f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 25 Aug 2016 19:58:50 +0200 Subject: [PATCH 0850/1509] Fix tonemap palette not being rebuilt on palette change --- src/gl/renderer/gl_postprocess.cpp | 6 ++++++ src/gl/renderer/gl_renderer.cpp | 1 + src/gl/renderer/gl_renderer.h | 1 + src/gl/system/gl_framebuffer.cpp | 3 +++ 4 files changed, 11 insertions(+) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index c1b39e556..20f6f469f 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -278,6 +278,12 @@ void FGLRenderer::BindTonemapPalette(int texunit) } } +void FGLRenderer::ClearTonemapPalette() +{ + delete mTonemapPalette; + mTonemapPalette = nullptr; +} + //----------------------------------------------------------------------------- // // Apply lens distortion and place the result in the HUD/2D texture diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index fba3a09ea..d154766d6 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -111,6 +111,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) gllight = glpart2 = glpart = mirrortexture = NULL; mLights = NULL; m2DDrawer = nullptr; + mTonemapPalette = nullptr; } void gl_LoadModels(); diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index da2a11ed0..4b663680f 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -167,6 +167,7 @@ public: void BloomScene(); void TonemapScene(); void BindTonemapPalette(int texunit); + void ClearTonemapPalette(); void LensDistortScene(); void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma); void Flush() { CopyToBackbuffer(nullptr, true); } diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index ec8b3f599..ae1fabaed 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -310,6 +310,9 @@ void OpenGLFrameBuffer::UpdatePalette() bb>>=8; palette_brightness = (rr*77 + gg*143 + bb*35)/255; + + if (GLRenderer) + GLRenderer->ClearTonemapPalette(); } void OpenGLFrameBuffer::GetFlashedPalette (PalEntry pal[256]) From 6c5109ec9949bf60e94b893f6fbc594d836cad82 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 27 Aug 2016 06:24:36 +0200 Subject: [PATCH 0851/1509] Fix uninitialized mPipelineTexture and fix BindCurrentTexture using the wrong handle --- src/gl/renderer/gl_renderbuffers.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 9c9c76979..9f27e6313 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -65,6 +65,12 @@ CVAR(Bool, gl_renderbuffers, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); FGLRenderBuffers::FGLRenderBuffers() { + for (int i = 0; i < NumPipelineTextures; i++) + { + mPipelineTexture[i] = 0; + mPipelineFB[i] = 0; + } + glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&mOutputFB); glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples); } @@ -477,7 +483,7 @@ void FGLRenderBuffers::BindSceneFB() void FGLRenderBuffers::BindCurrentTexture(int index) { glActiveTexture(GL_TEXTURE0 + index); - glBindTexture(GL_TEXTURE_2D, mPipelineFB[mCurrentPipelineTexture]); + glBindTexture(GL_TEXTURE_2D, mPipelineTexture[mCurrentPipelineTexture]); } //========================================================================== From 9b91a1348766dd6a68186f32f21bd8efa0ba8ebe Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 28 Aug 2016 10:21:20 +0300 Subject: [PATCH 0852/1509] Restored legacy way to collect OpenGL extensions --- src/gl/system/gl_load.c | 56 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/src/gl/system/gl_load.c b/src/gl/system/gl_load.c index c686b60fc..a32eb226f 100644 --- a/src/gl/system/gl_load.c +++ b/src/gl/system/gl_load.c @@ -2447,11 +2447,49 @@ static void LoadExtByName(const char *extensionName) } } +/* BEGINNING OF MANUAL CHANGES, DO NOT REMOVE! */ -static void ProcExtsFromExtList(void) +static void ProcExtsFromExtString(const char *strExtList) +{ + size_t iExtListLen = strlen(strExtList); + const char *strExtListEnd = strExtList + iExtListLen; + const char *strCurrPos = strExtList; + char strWorkBuff[256]; + + while (*strCurrPos) + { + /*Get the extension at our position.*/ + int iStrLen = 0; + const char *strEndStr = strchr(strCurrPos, ' '); + int iStop = 0; + if (strEndStr == NULL) + { + strEndStr = strExtListEnd; + iStop = 1; + } + + iStrLen = (int)((ptrdiff_t)strEndStr - (ptrdiff_t)strCurrPos); + + if (iStrLen > 255) + return; + + strncpy(strWorkBuff, strCurrPos, iStrLen); + strWorkBuff[iStrLen] = '\0'; + + LoadExtByName(strWorkBuff); + + strCurrPos = strEndStr + 1; + if (iStop) break; + } +} + +static int ProcExtsFromExtList(void) { GLint iLoop; GLint iNumExtensions = 0; + + if (_ptrc_glGetStringi == NULL) return 0; + _ptrc_glGetIntegerv(GL_NUM_EXTENSIONS, &iNumExtensions); for(iLoop = 0; iLoop < iNumExtensions; iLoop++) @@ -2459,6 +2497,8 @@ static void ProcExtsFromExtList(void) const char *strExtensionName = (const char *)_ptrc_glGetStringi(GL_EXTENSIONS, iLoop); LoadExtByName(strExtensionName); } + + return iNumExtensions; } int ogl_LoadFunctions() @@ -2469,9 +2509,15 @@ int ogl_LoadFunctions() _ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress("glGetIntegerv"); if(!_ptrc_glGetIntegerv) return ogl_LOAD_FAILED; _ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi"); - if(!_ptrc_glGetStringi) return ogl_LOAD_FAILED; - - ProcExtsFromExtList(); + + if (0 == ProcExtsFromExtList()) + { + _ptrc_glGetString = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGetString"); + if (!_ptrc_glGetString) return ogl_LOAD_FAILED; + + ProcExtsFromExtString((const char *)_ptrc_glGetString(GL_EXTENSIONS)); + } + numFailed = Load_Version_3_3(); if(numFailed == 0) @@ -2480,6 +2526,8 @@ int ogl_LoadFunctions() return ogl_LOAD_SUCCEEDED + numFailed; } +/* END OF MANUAL CHANGES, DO NOT REMOVE! */ + static int g_major_version = 0; static int g_minor_version = 0; From 03d055a5ec645beee5a953f78b5c6d6615686d52 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 28 Aug 2016 10:11:09 +0200 Subject: [PATCH 0853/1509] - adjustments for message modes. --- src/gl/data/gl_setup.cpp | 2 +- src/gl/textures/gl_texture.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index f45995d90..73ceddb13 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -294,7 +294,7 @@ static void PrepareSectorData() seg[j].PartnerSeg!=NULL && subsectors[i].render_sector != seg[j].PartnerSeg->Subsector->render_sector) { - DPrintf("Found hack: (%f,%f) (%f,%f)\n", seg[j].v1->fX(), seg[j].v1->fY(), seg[j].v2->fX(), seg[j].v2->fY()); + DPrintf(DMSG_NOTIFY, "Found hack: (%f,%f) (%f,%f)\n", seg[j].v1->fX(), seg[j].v1->fY(), seg[j].v2->fX(), seg[j].v2->fY()); subsectors[i].hacked|=5; SpreadHackedFlag(&subsectors[i]); } diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index f1e6f0b0b..eb14862c6 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -166,7 +166,7 @@ void gl_GenerateGlobalBrightmapFromColormap() for(int i=0;i<256;i++) { HasGlobalBrightmap |= GlobalBrightmap.Remap[i] == white; - if (GlobalBrightmap.Remap[i] == white) DPrintf("Marked color %d as fullbright\n",i); + if (GlobalBrightmap.Remap[i] == white) DPrintf(DMSG_NOTIFY, "Marked color %d as fullbright\n",i); } } @@ -290,7 +290,7 @@ void FTexture::CreateDefaultBrightmap() if (GlobalBrightmap.Remap[texbuf[i]] == white) { // Create a brightmap - DPrintf("brightmap created for texture '%s'\n", Name.GetChars()); + DPrintf(DMSG_NOTIFY, "brightmap created for texture '%s'\n", Name.GetChars()); gl_info.Brightmap = new FBrightmapTexture(this); gl_info.bBrightmapChecked = 1; TexMan.AddTexture(gl_info.Brightmap); @@ -298,7 +298,7 @@ void FTexture::CreateDefaultBrightmap() } } // No bright pixels found - DPrintf("No bright pixels found in texture '%s'\n", Name.GetChars()); + DPrintf(DMSG_SPAMMY, "No bright pixels found in texture '%s'\n", Name.GetChars()); gl_info.bBrightmapChecked = 1; } else From 47714509d6345fa0589b3d7aa3d412fc327010f0 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 28 Aug 2016 11:12:06 +0300 Subject: [PATCH 0854/1509] Changed render buffers format back to RGBA16F Reverted a03b2ff48b305064c7689419e2cc297b5ccdc1aa to fix issues with nVidia graphics on macOS --- src/gl/renderer/gl_renderbuffers.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 9f27e6313..9daec41dd 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -274,7 +274,7 @@ void FGLRenderBuffers::CreateBloom(int width, int height) GLuint FGLRenderBuffers::GetHdrFormat() { - return ((gl.flags & RFL_NO_RGBA16F) != 0) ? GL_RGBA8 : GL_RGBA16; + return ((gl.flags & RFL_NO_RGBA16F) != 0) ? GL_RGBA8 : GL_RGBA16F; } //========================================================================== @@ -285,7 +285,7 @@ GLuint FGLRenderBuffers::GetHdrFormat() GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height) { - GLuint type = (format == GL_RGBA16) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE; + GLuint type = (format == GL_RGBA16F) ? GL_FLOAT : GL_UNSIGNED_BYTE; GLuint handle = 0; glGenTextures(1, &handle); glBindTexture(GL_TEXTURE_2D, handle); From bb066f6f07815fccd2c78394158e13b2b1e40338 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 28 Aug 2016 18:07:44 +0200 Subject: [PATCH 0855/1509] Fall back to gl_renderbuffers 0 if buffer creation fails --- src/gl/renderer/gl_renderbuffers.cpp | 44 +++++++++++++++++++++------- src/gl/renderer/gl_renderbuffers.h | 6 ++-- src/gl/renderer/gl_renderer.cpp | 3 +- src/gl/scene/gl_scene.cpp | 3 +- 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 9daec41dd..fd98522d8 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -147,10 +147,10 @@ void FGLRenderBuffers::DeleteFrameBuffer(GLuint &handle) // //========================================================================== -void FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHeight) +bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHeight) { if (!IsEnabled()) - return; + return false; if (width <= 0 || height <= 0) I_FatalError("Requested invalid render buffer sizes: screen = %dx%d", width, height); @@ -189,6 +189,20 @@ void FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei glActiveTexture(activeTex); glBindRenderbuffer(GL_RENDERBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0); + + if (FailedCreate) + { + ClearScene(); + ClearPipeline(); + ClearBloom(); + mWidth = 0; + mHeight = 0; + mSamples = 0; + mBloomWidth = 0; + mBloomHeight = 0; + } + + return !FailedCreate; } //========================================================================== @@ -340,8 +354,8 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff glBindFramebuffer(GL_FRAMEBUFFER, handle); FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); - CheckFrameBufferCompleteness(); - ClearFrameBuffer(false, false); + if (CheckFrameBufferCompleteness()) + ClearFrameBuffer(false, false); return handle; } @@ -356,8 +370,8 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff else glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil); - CheckFrameBufferCompleteness(); - ClearFrameBuffer(true, true); + if (CheckFrameBufferCompleteness()) + ClearFrameBuffer(true, true); return handle; } @@ -373,8 +387,8 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil); - CheckFrameBufferCompleteness(); - ClearFrameBuffer(true, true); + if (CheckFrameBufferCompleteness()) + ClearFrameBuffer(true, true); return handle; } @@ -384,12 +398,15 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff // //========================================================================== -void FGLRenderBuffers::CheckFrameBufferCompleteness() +bool FGLRenderBuffers::CheckFrameBufferCompleteness() { GLenum result = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (result == GL_FRAMEBUFFER_COMPLETE) - return; + return true; + FailedCreate = true; + +#if 0 FString error = "glCheckFramebufferStatus failed: "; switch (result) { @@ -404,6 +421,9 @@ void FGLRenderBuffers::CheckFrameBufferCompleteness() case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: error << "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS"; break; } I_FatalError(error); +#endif + + return false; } //========================================================================== @@ -539,5 +559,7 @@ void FGLRenderBuffers::BindOutputFB() bool FGLRenderBuffers::IsEnabled() { - return gl_renderbuffers && gl.glslversion != 0; + return gl_renderbuffers && gl.glslversion != 0 && !FailedCreate; } + +bool FGLRenderBuffers::FailedCreate = false; diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 9c04eb546..ee6d8de5e 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -20,7 +20,7 @@ public: FGLRenderBuffers(); ~FGLRenderBuffers(); - void Setup(int width, int height, int sceneWidth, int sceneHeight); + bool Setup(int width, int height, int sceneWidth, int sceneHeight); void BindSceneFB(); void BlitSceneToTexture(); @@ -53,7 +53,7 @@ private: GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer); - void CheckFrameBufferCompleteness(); + bool CheckFrameBufferCompleteness(); void ClearFrameBuffer(bool stencil, bool depth); void DeleteTexture(GLuint &handle); void DeleteRenderBuffer(GLuint &handle); @@ -84,6 +84,8 @@ private: // Back buffer frame buffer GLuint mOutputFB = 0; + + static bool FailedCreate; }; #endif \ No newline at end of file diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index d154766d6..eb0eebaa1 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -289,9 +289,8 @@ void FGLRenderer::SetupLevel() void FGLRenderer::Begin2D() { - if (FGLRenderBuffers::IsEnabled()) + if (mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height)) { - mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height); if (mDrawingScene2D) mBuffers->BindSceneFB(); else diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index ef82472e0..250ec0c53 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -168,9 +168,8 @@ void FGLRenderer::Reset3DViewport() void FGLRenderer::Set3DViewport(bool mainview) { - if (mainview && FGLRenderBuffers::IsEnabled()) + if (mainview && mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height)) { - mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height); mBuffers->BindSceneFB(); } From 945d5b154a3f810d79bda16b14f9574e3e45118e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 28 Aug 2016 18:10:39 +0200 Subject: [PATCH 0856/1509] Remove gl_vid_multisample --- src/posix/cocoa/i_video.mm | 7 +------ src/posix/sdl/sdlglvideo.cpp | 11 +---------- src/win32/win32gliface.cpp | 11 +---------- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 8f8b7c135..e2b59449d 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -149,11 +149,6 @@ CUSTOM_CVAR(Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINIT } } -CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ - Printf("This won't take effect until " GAMENAME " is restarted.\n"); -} - EXTERN_CVAR(Bool, gl_smooth_rendered) @@ -1259,7 +1254,7 @@ void I_InitGraphics() val.Bool = !!Args->CheckParm("-devparm"); ticker.SetGenericRepDefault(val, CVAR_Bool); - Video = new CocoaVideo(gl_vid_multisample); + Video = new CocoaVideo(0); atterm(I_ShutdownGraphics); } diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 0cd6b223b..d8c00f236 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -54,11 +54,6 @@ EXTERN_CVAR (Bool, cl_capfps) // PUBLIC DATA DEFINITIONS ------------------------------------------------- -CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL ) -{ - Printf("This won't take effect until " GAMENAME " is restarted.\n"); -} - CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { Printf("This won't take effect until " GAMENAME " is restarted.\n"); @@ -322,17 +317,13 @@ bool SDLGLVideo::InitHardware (bool allowsoftware, int multisample) SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen) : DFrameBuffer (width, height) { - static int localmultisample=-1; - - if (localmultisample<0) localmultisample=gl_vid_multisample; - int i; m_Lock=0; UpdatePending = false; - if (!static_cast(Video)->InitHardware(false, localmultisample)) + if (!static_cast(Video)->InitHardware(false, 0)) { vid_renderer = 0; return; diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index bec2a19cf..23f156592 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -40,11 +40,6 @@ PFNWGLCREATECONTEXTATTRIBSARBPROC myWglCreateContextAttribsARB; PFNWGLSWAPINTERVALEXTPROC vsyncfunc; -CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL ) -{ - Printf("This won't take effect until " GAMENAME " is restarted.\n"); -} - CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { Printf("This won't take effect until " GAMENAME " is restarted.\n"); @@ -911,10 +906,6 @@ IMPLEMENT_ABSTRACT_CLASS(Win32GLFrameBuffer) Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : BaseWinFB(width, height) { - static int localmultisample=-1; - - if (localmultisample<0) localmultisample=gl_vid_multisample; - m_Width = width; m_Height = height; m_Bits = bits; @@ -981,7 +972,7 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in I_RestoreWindowedPos(); } - if (!static_cast(Video)->InitHardware(Window, localmultisample)) + if (!static_cast(Video)->InitHardware(Window, 0)) { vid_renderer = 0; return; From 71387b1b42fff9f527758fbbc9680b2db1b70e15 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 29 Aug 2016 05:19:47 +0200 Subject: [PATCH 0857/1509] Fix wrong initial mClipSplit values. --- src/gl/renderer/gl_renderstate.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 56b319f00..86ea497ed 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -111,7 +111,6 @@ void FRenderState::Reset() mSplitBottomPlane.Set(0.0f, 0.0f, 0.0f, 0.0f); mClipLine.Set(0.0f, 0.0f, 0.0f, 0.0f); mDynColor.Set(0.0f, 0.0f, 0.0f, 0.0f); - mClipSplit[0] = mClipSplit[1] = 0.0f; mEffectState = 0; activeShader = nullptr; mProjectionMatrix.loadIdentity(); From e0e43ee7b335f8d69ca1868d18c5e5e4efabc076 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 29 Aug 2016 05:31:12 +0200 Subject: [PATCH 0858/1509] Fix mColor reset value --- src/gl/renderer/gl_renderstate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 86ea497ed..7fda92428 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -101,7 +101,7 @@ void FRenderState::Reset() mLastDepthClamp = true; mInterpolationFactor = 0.0f; - mColor.Set(0.0f, 0.0f, 0.0f, 0.0f); + mColor.Set(1.0f, 1.0f, 1.0f, 1.0f); mCameraPos.Set(0.0f, 0.0f, 0.0f, 0.0f); mGlowTop.Set(0.0f, 0.0f, 0.0f, 0.0f); mGlowBottom.Set(0.0f, 0.0f, 0.0f, 0.0f); From 0f0dc2c852723f397583dc0a771726d38c9e1df0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 29 Aug 2016 10:43:03 +0200 Subject: [PATCH 0859/1509] - implemented buffers for GL 3.x. These only get mapped during the data collection pass so the order of some things is different here. --- src/gl/data/gl_vertexbuffer.cpp | 63 ++++++++++++++++++++++++++---- src/gl/data/gl_vertexbuffer.h | 3 ++ src/gl/renderer/gl_postprocess.cpp | 2 +- src/gl/scene/gl_portal.cpp | 8 ++-- src/gl/scene/gl_scene.cpp | 4 +- src/gl/shaders/gl_shader.cpp | 2 +- src/gl/system/gl_interface.cpp | 8 +++- 7 files changed, 74 insertions(+), 16 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 7e7784954..31cb8d0b5 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -126,6 +126,7 @@ void FSimpleVertexBuffer::EnableColorArray(bool on) void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count) { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + gl_RenderState.ResetVertexBuffer(); gl_RenderState.SetVertexBuffer(this); glBufferData(GL_ARRAY_BUFFER, count * sizeof(*verts), verts, GL_STREAM_DRAW); } @@ -139,18 +140,32 @@ void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count) FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) : FVertexBuffer(gl.buffermethod != BM_CLIENTARRAY) { - if (gl.buffermethod != BM_CLIENTARRAY) + switch (gl.buffermethod) + { + case BM_PERSISTENT: { unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + break; } - else + + case BM_DEFERRED: + { + unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferData(GL_ARRAY_BUFFER, bytesize, NULL, GL_STREAM_DRAW); + map = nullptr; + break; + } + + case BM_CLIENTARRAY: { // The fallback path uses immediate mode rendering and does not set up an actual vertex buffer - vbo_shadowdata.Reserve(BUFFER_SIZE); map = new FFlatVertex[BUFFER_SIZE]; + break; + } } mIndex = mCurIndex = 0; mNumReserved = NUM_RESERVED; @@ -185,6 +200,13 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) vbo_shadowdata[18].Set(32767.0f, -32767.0f, 32767.0f, 0, 0); vbo_shadowdata[19].Set(32767.0f, -32767.0f, -32767.0f, 0, 0); + if (gl.buffermethod == BM_DEFERRED) + { + Map(); + memcpy(map, &vbo_shadowdata[0], mNumReserved * sizeof(FFlatVertex)); + Unmap(); + } + } FFlatVertexBuffer::~FFlatVertexBuffer() @@ -195,7 +217,7 @@ FFlatVertexBuffer::~FFlatVertexBuffer() glUnmapBuffer(GL_ARRAY_BUFFER); glBindBuffer(GL_ARRAY_BUFFER, 0); } - else + if (gl.buffermethod == BM_CLIENTARRAY) { delete[] map; } @@ -208,7 +230,7 @@ void FFlatVertexBuffer::BindVBO() glBindBuffer(GL_ARRAY_BUFFER, vbo_id); if (gl.glslversion > 0) { - if (vbo_id != 0) // set this up only if there is an actual buffer. + if (gl.buffermethod != BM_CLIENTARRAY) { glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); @@ -226,12 +248,37 @@ void FFlatVertexBuffer::BindVBO() } else { - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(3, GL_FLOAT, sizeof(FFlatVertex), &map->x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FFlatVertex), &map->u); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); } } +void FFlatVertexBuffer::Map() +{ + if (gl.buffermethod == BM_DEFERRED) + { + unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + gl_RenderState.ResetVertexBuffer(); + map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT); + } +} + +void FFlatVertexBuffer::Unmap() +{ + if (gl.buffermethod == BM_DEFERRED) + { + unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + gl_RenderState.ResetVertexBuffer(); + glUnmapBuffer(GL_ARRAY_BUFFER); + map = nullptr; + } +} + //========================================================================== // // Initialize a single vertex @@ -412,7 +459,9 @@ void FFlatVertexBuffer::CreateVBO() vbo_shadowdata.Resize(mNumReserved); CreateFlatVBO(); mCurIndex = mIndex = vbo_shadowdata.Size(); + Map(); memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); + Unmap(); } //========================================================================== diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 68f101367..88a1de2b8 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -149,6 +149,9 @@ public: mCurIndex = mIndex; } + void Map(); + void Unmap(); + private: int CreateSubsectorVertices(subsector_t *sub, const secplane_t &plane, int floor); int CreateSectorVertices(sector_t *sec, const secplane_t &plane, int floor); diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 20f6f469f..3a83f4caf 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -114,7 +114,7 @@ void FGLRenderer::RenderScreenQuad() { mVBO->BindVBO(); gl_RenderState.ResetVertexBuffer(); - glDrawArrays(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); } //----------------------------------------------------------------------------- diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 4b8d8eb27..cd3efb9e3 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -163,8 +163,8 @@ void GLPortal::DrawPortalStencil() } if (NeedCap() && lines.Size() > 1) { - glDrawArrays(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILTOP_INDEX, 4); - glDrawArrays(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILBOTTOM_INDEX, 4); + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILTOP_INDEX, 4); + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILBOTTOM_INDEX, 4); } } @@ -1178,9 +1178,9 @@ void GLHorizonPortal::DrawContents() for (unsigned i = 0; i < vcount; i += 4) { - glDrawArrays(GL_TRIANGLE_STRIP, voffset + i, 4); + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, voffset + i, 4); } - glDrawArrays(GL_TRIANGLE_STRIP, voffset + vcount, 10); + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, voffset + vcount, 10); gl_RenderState.EnableTextureMatrix(false); PortalAll.Unclock(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 250ec0c53..08591283c 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -284,6 +284,7 @@ void FGLRenderer::CreateScene() for(unsigned i=0;iglportal = NULL; gl_spriteindex=0; Bsp.Clock(); + GLRenderer->mVBO->Map(); R_SetView(); validcount++; // used for processing sidedefs only once by the renderer. gl_RenderBSPNode (nodes + numnodes - 1); @@ -295,6 +296,7 @@ void FGLRenderer::CreateScene() gl_drawinfo->HandleMissingTextures(); // Missing upper/lower textures gl_drawinfo->HandleHackedSubsectors(); // open sector hacks for deep water gl_drawinfo->ProcessSectorStacks(); // merge visplanes of sector stacks + GLRenderer->mVBO->Unmap(); ProcessAll.Unclock(); @@ -525,7 +527,7 @@ void gl_FillScreen() gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); // The fullscreen quad is stored at index 4 in the main vertex buffer. - glDrawArrays(GL_TRIANGLE_STRIP, FFlatVertexBuffer::FULLSCREEN_INDEX, 4); + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, FFlatVertexBuffer::FULLSCREEN_INDEX, 4); } //========================================================================== diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 67b9a2d6a..8ac2b7093 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -125,7 +125,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n"; } } - //if (gl.buffermethod == BM_DEFERRED) + if (gl.buffermethod == BM_DEFERRED) { vp_comb << "#define USE_QUAD_DRAWER\n"; } diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index a7b1be648..9eb1d779e 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -204,8 +204,12 @@ void gl_LoadExtensions() } else if (gl.version < 3.0f) { - //if (CheckExtension("GL_NV_GPU_shader4") || CheckExtension("GL_EXT_GPU_shader4")) gl.glslversion = 1.21f; // for pre-3.0 drivers that support capable hardware. Needed for Apple. - //else gl.glslversion = 0; + if (CheckExtension("GL_NV_GPU_shader4") || CheckExtension("GL_EXT_GPU_shader4")) gl.glslversion = 1.21f; // for pre-3.0 drivers that support capable hardware. Needed for Apple. + else + { + gl.buffermethod = BM_CLIENTARRAY; + gl.glslversion = 0; + } if (!CheckExtension("GL_EXT_packed_float")) gl.flags |= RFL_NO_RGBA16F; if (!CheckExtension("GL_EXT_packed_depth_stencil")) gl.flags |= RFL_NO_DEPTHSTENCIL; From 8f535997f86cdc4bc2dfdc182a33b97960fa4703 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 29 Aug 2016 11:33:20 +0200 Subject: [PATCH 0860/1509] - enable core profile by default on GL 3.x. After doing some profiling it was very obvious that this has better performance than client arrays. Persistent buffers are still better, though, especially for handling dynamic lights. --- src/gl/data/gl_vertexbuffer.cpp | 4 ++- src/gl/renderer/gl_renderer.cpp | 2 +- src/gl/system/gl_interface.cpp | 13 +------ src/win32/win32gliface.cpp | 60 +++++---------------------------- src/win32/win32gliface.h | 1 - 5 files changed, 14 insertions(+), 66 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 31cb8d0b5..5833d3109 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -148,6 +148,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + DPrintf(DMSG_NOTIFY, "Using persistent buffer\n"); break; } @@ -157,13 +158,14 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glBufferData(GL_ARRAY_BUFFER, bytesize, NULL, GL_STREAM_DRAW); map = nullptr; + DPrintf(DMSG_NOTIFY, "Using deferred buffer\n"); break; } case BM_CLIENTARRAY: { - // The fallback path uses immediate mode rendering and does not set up an actual vertex buffer map = new FFlatVertex[BUFFER_SIZE]; + DPrintf(DMSG_NOTIFY, "Using client array buffer\n"); break; } } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index eb0eebaa1..c8f2eb224 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -130,7 +130,7 @@ void FGLRenderer::Initialize(int width, int height) m2DDrawer = new F2DDrawer; // Only needed for the core profile, because someone decided it was a good idea to remove the default VAO. - if (gl.version >= 4.0) + if (gl.buffermethod != BM_CLIENTARRAY) { glGenVertexArrays(1, &mVAOID); glBindVertexArray(mVAOID); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 9eb1d779e..c54d96448 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -156,14 +156,6 @@ void gl_LoadExtensions() gl.version = strtod(version, NULL) + 0.01f; - bool iscore = false; - if (gl.version >= 3.2) - { - int v; - glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &v); - iscore = !!(v & GL_CONTEXT_CORE_PROFILE_BIT); - } - // Don't even start if it's lower than 2.0 or no framebuffers are available if ((gl.version < 2.0 || !CheckExtension("GL_EXT_framebuffer_object")) && gl.version < 3.0) { @@ -186,10 +178,7 @@ void gl_LoadExtensions() if (gl.version > 3.0f && (gl.version >= 3.3f || CheckExtension("GL_ARB_uniform_buffer_object"))) { gl.lightmethod = LM_DEFERRED; - if (iscore) - { - gl.buffermethod = BM_DEFERRED; - } + gl.buffermethod = BM_DEFERRED; } if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION; diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 23f156592..494d94233 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -737,42 +737,6 @@ bool Win32GLVideo::SetupPixelFormat(int multisample) // //========================================================================== -// since we cannot use the extension loader here, before it gets initialized, -// we have to define the extended GL stuff we need, ourselves here. -// The headers generated by GLLoadGen only work if the loader gets initialized. -typedef const GLubyte * (APIENTRY *PFNGLGETSTRINGIPROC)(GLenum, GLuint); -#define GL_NUM_EXTENSIONS 0x821D - -bool Win32GLVideo::checkCoreUsability() -{ - const char *version = Args->CheckValue("-glversion"); - if (version != NULL) - { - if (strtod(version, NULL) < 4.0) return false; - } - if (Args->CheckParm("-noshader")) return false; - - // GL 4.4 implies GL_ARB_buffer_storage - if (strcmp((char*)glGetString(GL_VERSION), "4.4") >= 0) return true; - - // at this point the extension loader has not been initialized so we have to retrieve glGetStringi ourselves. - PFNGLGETSTRINGIPROC myglGetStringi = (PFNGLGETSTRINGIPROC)wglGetProcAddress("glGetStringi"); - if (!myglGetStringi) return false; // this should not happen. - - const char *extension; - - int max = 0; - glGetIntegerv(GL_NUM_EXTENSIONS, &max); - - // step through all reported extensions and see if we got what we need... - for (int i = 0; i < max; i++) - { - extension = (const char*)myglGetStringi(GL_EXTENSIONS, i); - if (!strcmp(extension, "GL_ARB_buffer_storage")) return true; - } - return false; -} - bool Win32GLVideo::InitHardware (HWND Window, int multisample) { m_Window=Window; @@ -783,7 +747,14 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) return false; } - for (int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; prof <= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; prof++) + int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; + const char *lm = Args->CheckValue("-buffermethod"); + if (lm != NULL) + { + if (!stricmp(lm, "clientarray")) prof = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; + } + + for (; prof <= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; prof++) { m_hRC = NULL; if (myWglCreateContextAttribsARB != NULL) @@ -802,8 +773,6 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) 0 }; - //Printf("Trying to create an OpenGL %d.%d %s profile context\n", versions[i] / 10, versions[i] % 10, prof == WGL_CONTEXT_CORE_PROFILE_BIT_ARB ? "Core" : "Compatibility"); - m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); if (m_hRC != NULL) break; } @@ -811,7 +780,6 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) if (m_hRC == NULL && prof == WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) { - m_hRC = wglCreateContext(m_hDC); if (m_hRC == NULL) { @@ -823,17 +791,7 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) if (m_hRC != NULL) { wglMakeCurrent(m_hDC, m_hRC); - - // we can only use core profile contexts if GL_ARB_buffer_storage is supported or GL version is >= 4.4 - if (prof == WGL_CONTEXT_CORE_PROFILE_BIT_ARB && !checkCoreUsability()) - { - wglMakeCurrent(0, 0); - wglDeleteContext(m_hRC); - } - else - { - return true; - } + return true; } } // We get here if the driver doesn't support the modern context creation API which always means an old driver. diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index 00e6cba81..6320e2903 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -86,7 +86,6 @@ protected: void MakeModesList(); void AddMode(int x, int y, int bits, int baseHeight, int refreshHz); void FreeModes(); - bool checkCoreUsability(); public: int GetTrueHeight() { return m_trueHeight; } From 737e70077421023fcebf7a2c177afa032f3a7297 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 29 Aug 2016 13:10:22 +0200 Subject: [PATCH 0861/1509] Added SSAO pass --- src/CMakeLists.txt | 1 + src/gl/renderer/gl_postprocess.cpp | 106 ++++++++++++++- src/gl/renderer/gl_renderbuffers.cpp | 152 +++++++++++++++++----- src/gl/renderer/gl_renderbuffers.h | 30 +++-- src/gl/renderer/gl_renderer.cpp | 5 + src/gl/renderer/gl_renderer.h | 9 ++ src/gl/scene/gl_scene.cpp | 10 +- src/gl/shaders/gl_ambientshader.cpp | 89 +++++++++++++ src/gl/shaders/gl_ambientshader.h | 39 ++++++ src/gl/stereo3d/gl_stereo3d.cpp | 2 +- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.z | 1 + wadsrc/static/shaders/glsl/lineardepth.fp | 16 +++ wadsrc/static/shaders/glsl/ssao.fp | 117 +++++++++++++++++ 14 files changed, 531 insertions(+), 47 deletions(-) create mode 100644 src/gl/shaders/gl_ambientshader.cpp create mode 100644 src/gl/shaders/gl_ambientshader.h create mode 100644 wadsrc/static/shaders/glsl/lineardepth.fp create mode 100644 wadsrc/static/shaders/glsl/ssao.fp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 03f3372f0..13ef11ec3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1113,6 +1113,7 @@ set( FASTMATH_SOURCES gl/shaders/gl_shaderprogram.cpp gl/shaders/gl_presentshader.cpp gl/shaders/gl_bloomshader.cpp + gl/shaders/gl_ambientshader.cpp gl/shaders/gl_blurshader.cpp gl/shaders/gl_tonemapshader.cpp gl/shaders/gl_lensshader.cpp diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 3a83f4caf..c7d0494c8 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -68,6 +68,7 @@ #include "gl/renderer/gl_postprocessstate.h" #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" +#include "gl/shaders/gl_ambientshader.h" #include "gl/shaders/gl_bloomshader.h" #include "gl/shaders/gl_blurshader.h" #include "gl/shaders/gl_tonemapshader.h" @@ -106,6 +107,20 @@ CVAR(Float, gl_lens_k, -0.12f, 0) CVAR(Float, gl_lens_kcube, 0.1f, 0) CVAR(Float, gl_lens_chromatic, 1.12f, 0) +CVAR(Bool, gl_ssao, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, gl_ssao_debug, false, 0) +CVAR(Float, gl_ssao_bias, 0.5f, 0) +CVAR(Float, gl_ssao_radius, 100.0f, 0) +CUSTOM_CVAR(Float, gl_ssao_blur_amount, 6.0f, 0) +{ + if (self < 0.1f) self = 0.1f; +} +CUSTOM_CVAR(Int, gl_ssao_blur_samples, 9, 0) +{ + if (self < 3 || self > 15 || self % 2 == 0) + self = 9; +} + EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) @@ -117,6 +132,95 @@ void FGLRenderer::RenderScreenQuad() GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); } +void FGLRenderer::PostProcessScene() +{ + if (FGLRenderBuffers::IsEnabled()) mBuffers->BlitSceneToTexture(); + AmbientOccludeScene(); + BloomScene(); + TonemapScene(); + LensDistortScene(); +} + +//----------------------------------------------------------------------------- +// +// Adds ambient occlusion to the scene +// +//----------------------------------------------------------------------------- + +void FGLRenderer::AmbientOccludeScene() +{ + if (!gl_ssao || !FGLRenderBuffers::IsEnabled()) + return; + + FGLDebug::PushGroup("AmbientOccludeScene"); + + FGLPostProcessState savedState; + + float bias = gl_ssao_bias; + float aoRadius = gl_ssao_radius; + const float blurAmount = gl_ssao_blur_amount; + int blurSampleCount = gl_ssao_blur_samples; + + //float tanHalfFovy = tan(fovy * (M_PI / 360.0f)); + float tanHalfFovy = 1.0f / 1.33333302f; //gl_RenderState.mProjectionMatrix.get()[5]; + float invFocalLenX = tanHalfFovy * (mBuffers->AmbientWidth / (float)mBuffers->AmbientHeight); + float invFocalLenY = tanHalfFovy; + float nDotVBias = clamp(bias, 0.0f, 1.0f); + float r2 = aoRadius * aoRadius; + + // Calculate linear depth values + glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB0); + glViewport(0, 0, mBuffers->AmbientWidth, mBuffers->AmbientHeight); + mBuffers->BindSceneDepthTexture(0); + mLinearDepthShader->Bind(); + mLinearDepthShader->DepthTexture.Set(0); + mLinearDepthShader->LinearizeDepthA.Set(1.0f / GetZFar() - 1.0f / GetZNear()); + mLinearDepthShader->LinearizeDepthB.Set(MAX(1.0f / GetZNear(), 1.e-8f)); + mLinearDepthShader->InverseDepthRangeA.Set(1.0f); + mLinearDepthShader->InverseDepthRangeB.Set(0.0f); + RenderScreenQuad(); + + // Apply ambient occlusion + glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB1); + glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + mSSAOShader->Bind(); + mSSAOShader->DepthTexture.Set(0); + mSSAOShader->UVToViewA.Set(2.0f * invFocalLenX, -2.0f * invFocalLenY); + mSSAOShader->UVToViewB.Set(-invFocalLenX, invFocalLenY); + mSSAOShader->InvFullResolution.Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); + mSSAOShader->NDotVBias.Set(nDotVBias); + mSSAOShader->NegInvR2.Set(-1.0f / r2); + mSSAOShader->RadiusToScreen.Set(aoRadius * 0.5 / tanHalfFovy * mBuffers->AmbientHeight); + mSSAOShader->AOMultiplier.Set(1.0f / (1.0f - nDotVBias)); + RenderScreenQuad(); + + // Blur SSAO texture + mBlurShader->BlurHorizontal(this, blurAmount, blurSampleCount, mBuffers->AmbientTexture1, mBuffers->AmbientFB0, mBuffers->AmbientWidth, mBuffers->AmbientHeight); + mBlurShader->BlurVertical(this, blurAmount, blurSampleCount, mBuffers->AmbientTexture0, mBuffers->AmbientFB1, mBuffers->AmbientWidth, mBuffers->AmbientHeight); + + // Add SSAO back to scene texture: + mBuffers->BindCurrentFB(); + glViewport(mSceneViewport.left, mSceneViewport.top, mSceneViewport.width, mSceneViewport.height); + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + if (gl_ssao_debug) + glBlendFunc(GL_ONE, GL_ZERO); + else + glBlendFunc(GL_ZERO, GL_SRC_COLOR); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mBloomCombineShader->Bind(); + mBloomCombineShader->BloomTexture.Set(0); + RenderScreenQuad(); + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + + FGLDebug::PopGroup(); +} + //----------------------------------------------------------------------------- // // Adds bloom contribution to scene texture @@ -126,7 +230,7 @@ void FGLRenderer::RenderScreenQuad() void FGLRenderer::BloomScene() { // Only bloom things if enabled and no special fixed light mode is active - if (!gl_bloom || !FGLRenderBuffers::IsEnabled() || gl_fixedcolormap != CM_DEFAULT) + if (!gl_bloom || !FGLRenderBuffers::IsEnabled() || gl_fixedcolormap != CM_DEFAULT || gl_ssao_debug) return; FGLDebug::PushGroup("BloomScene"); diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index fd98522d8..c1976565b 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -86,15 +86,16 @@ FGLRenderBuffers::~FGLRenderBuffers() ClearScene(); ClearPipeline(); ClearBloom(); + ClearAmbientOcclusion(); } void FGLRenderBuffers::ClearScene() { DeleteFrameBuffer(mSceneFB); - DeleteRenderBuffer(mSceneMultisample); - DeleteRenderBuffer(mSceneDepthStencil); - DeleteRenderBuffer(mSceneDepth); - DeleteRenderBuffer(mSceneStencil); + DeleteRenderBuffer(mSceneMSColor); + DeleteRenderBuffer(mSceneMSDepthStencil); + DeleteRenderBuffer(mSceneMSDepth); + DeleteRenderBuffer(mSceneMSStencil); } void FGLRenderBuffers::ClearPipeline() @@ -104,6 +105,9 @@ void FGLRenderBuffers::ClearPipeline() DeleteFrameBuffer(mPipelineFB[i]); DeleteTexture(mPipelineTexture[i]); } + DeleteTexture(mPipelineDepthStencil); + DeleteTexture(mPipelineDepth); + DeleteTexture(mPipelineStencil); } void FGLRenderBuffers::ClearBloom() @@ -119,6 +123,14 @@ void FGLRenderBuffers::ClearBloom() } } +void FGLRenderBuffers::ClearAmbientOcclusion() +{ + DeleteFrameBuffer(AmbientFB0); + DeleteFrameBuffer(AmbientFB1); + DeleteTexture(AmbientTexture0); + DeleteTexture(AmbientTexture1); +} + void FGLRenderBuffers::DeleteTexture(GLuint &handle) { if (handle != 0) @@ -178,11 +190,12 @@ bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei } // Bloom bluring buffers need to match the scene to avoid bloom bleeding artifacts - if (mBloomWidth != sceneWidth || mBloomHeight != sceneHeight) + if (mSceneWidth != sceneWidth || mSceneHeight != sceneHeight) { CreateBloom(sceneWidth, sceneHeight); - mBloomWidth = sceneWidth; - mBloomHeight = sceneHeight; + CreateAmbientOcclusion(sceneWidth, sceneHeight); + mSceneWidth = sceneWidth; + mSceneHeight = sceneHeight; } glBindTexture(GL_TEXTURE_2D, textureBinding); @@ -198,8 +211,8 @@ bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei mWidth = 0; mHeight = 0; mSamples = 0; - mBloomWidth = 0; - mBloomHeight = 0; + mSceneWidth = 0; + mSceneHeight = 0; } return !FailedCreate; @@ -216,18 +229,27 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples) ClearScene(); if (samples > 1) - mSceneMultisample = CreateRenderBuffer("SceneMultisample", GetHdrFormat(), samples, width, height); - - if ((gl.flags & RFL_NO_DEPTHSTENCIL) != 0) { - mSceneDepth = CreateRenderBuffer("SceneDepth", GL_DEPTH_COMPONENT24, samples, width, height); - mSceneStencil = CreateRenderBuffer("SceneStencil", GL_STENCIL_INDEX8, samples, width, height); - mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepth, mSceneStencil, samples > 1); + mSceneMSColor = CreateRenderBuffer("SceneMSColor", GetHdrFormat(), samples, width, height); + + if ((gl.flags & RFL_NO_DEPTHSTENCIL) != 0) + { + mSceneMSDepth = CreateRenderBuffer("SceneMSDepth", GL_DEPTH_COMPONENT24, samples, width, height); + mSceneMSStencil = CreateRenderBuffer("SceneMSStencil", GL_STENCIL_INDEX8, samples, width, height); + mSceneFB = CreateFrameBuffer("SceneFB", mSceneMSColor, mSceneMSDepth, mSceneMSStencil, true); + } + else + { + mSceneMSDepthStencil = CreateRenderBuffer("SceneMSDepthStencil", GL_DEPTH24_STENCIL8, samples, width, height); + mSceneFB = CreateFrameBuffer("SceneFB", mSceneMSColor, mSceneMSDepthStencil, true); + } } else { - mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, samples, width, height); - mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1); + if ((gl.flags & RFL_NO_DEPTHSTENCIL) != 0) + mSceneFB = CreateFrameBuffer("SceneFB", mPipelineTexture[0], mPipelineDepth, mPipelineStencil, false); + else + mSceneFB = CreateFrameBuffer("SceneFB", mPipelineTexture[0], mPipelineDepthStencil, false); } } @@ -241,10 +263,23 @@ void FGLRenderBuffers::CreatePipeline(int width, int height) { ClearPipeline(); + if ((gl.flags & RFL_NO_DEPTHSTENCIL) != 0) + { + mPipelineDepth = Create2DTexture("PipelineDepth", GL_DEPTH_COMPONENT24, width, height); + mPipelineStencil = Create2DTexture("PipelineStencil", GL_STENCIL_INDEX8, width, height); + } + else + { + mPipelineDepthStencil = Create2DTexture("PipelineDepthStencil", GL_DEPTH24_STENCIL8, width, height); + } + for (int i = 0; i < NumPipelineTextures; i++) { mPipelineTexture[i] = Create2DTexture("PipelineTexture", GetHdrFormat(), width, height); - mPipelineFB[i] = CreateFrameBuffer("PipelineFB", mPipelineTexture[i]); + if ((gl.flags & RFL_NO_DEPTHSTENCIL) != 0) + mPipelineFB[i] = CreateFrameBuffer("PipelineFB", mPipelineTexture[i], mPipelineDepth, mPipelineStencil, false); + else + mPipelineFB[i] = CreateFrameBuffer("PipelineFB", mPipelineTexture[i], mPipelineDepthStencil, false); } } @@ -280,6 +315,27 @@ void FGLRenderBuffers::CreateBloom(int width, int height) } } +//========================================================================== +// +// Creates ambient occlusion working buffers +// +//========================================================================== + +void FGLRenderBuffers::CreateAmbientOcclusion(int width, int height) +{ + ClearAmbientOcclusion(); + + if (width <= 0 || height <= 0) + return; + + AmbientWidth = width / 2; + AmbientHeight = height / 2; + AmbientTexture0 = Create2DTexture("AmbientTexture0", GetHdrFormat(), AmbientWidth, AmbientHeight); + AmbientTexture1 = Create2DTexture("AmbientTexture1", GetHdrFormat(), AmbientWidth, AmbientHeight); + AmbientFB0 = CreateFrameBuffer("AmbientFB0", AmbientTexture0); + AmbientFB1 = CreateFrameBuffer("AmbientFB1", AmbientTexture1); +} + //========================================================================== // // Fallback support for older OpenGL where RGBA16F might not be available @@ -299,12 +355,24 @@ GLuint FGLRenderBuffers::GetHdrFormat() GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height) { - GLuint type = (format == GL_RGBA16F) ? GL_FLOAT : GL_UNSIGNED_BYTE; GLuint handle = 0; glGenTextures(1, &handle); glBindTexture(GL_TEXTURE_2D, handle); FGLDebug::LabelObject(GL_TEXTURE, handle, name); - glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, GL_RGBA, type, nullptr); + + GLenum dataformat, datatype; + switch (format) // Special thanks to the designers of OpenGL.. + { + case GL_RGBA8: dataformat = GL_RGBA; datatype = GL_UNSIGNED_BYTE; break; + case GL_RGBA16: dataformat = GL_RGBA; datatype = GL_UNSIGNED_SHORT; break; + case GL_RGBA16F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; + case GL_DEPTH_COMPONENT24: dataformat = GL_DEPTH_COMPONENT; datatype = GL_FLOAT; break; + case GL_STENCIL_INDEX8: dataformat = GL_STENCIL_INDEX; datatype = GL_INT; break; + case GL_DEPTH24_STENCIL8: dataformat = GL_DEPTH_STENCIL; datatype = GL_UNSIGNED_INT_24_8; break; + default: I_FatalError("Unknown format passed to FGLRenderBuffers.Create2DTexture"); + } + + glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, dataformat, datatype, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -359,34 +427,45 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff return handle; } -GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer) +GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool fromRenderBuffers) { GLuint handle = 0; glGenFramebuffers(1, &handle); glBindFramebuffer(GL_FRAMEBUFFER, handle); FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); - if (colorIsARenderBuffer) + if (fromRenderBuffers) + { glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil); + } else + { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthstencil, 0); + } if (CheckFrameBufferCompleteness()) ClearFrameBuffer(true, true); return handle; } -GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer) +GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool fromRenderBuffers) { GLuint handle = 0; glGenFramebuffers(1, &handle); glBindFramebuffer(GL_FRAMEBUFFER, handle); FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); - if (colorIsARenderBuffer) + if (fromRenderBuffers) + { glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil); + } else + { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, stencil, 0); + } if (CheckFrameBufferCompleteness()) ClearFrameBuffer(true, true); return handle; @@ -441,7 +520,7 @@ void FGLRenderBuffers::ClearFrameBuffer(bool stencil, bool depth) glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilValue); glGetDoublev(GL_DEPTH_CLEAR_VALUE, &depthValue); glDisable(GL_SCISSOR_TEST); - glClearColor(0.0, 0.0, 0.0, 0.0); + glClearColor(1.0, 0.0, 0.0, 0.0); glClearDepth(0.0); glClearStencil(0); GLenum flags = GL_COLOR_BUFFER_BIT; @@ -471,7 +550,7 @@ void FGLRenderBuffers::BlitSceneToTexture() glBindFramebuffer(GL_READ_FRAMEBUFFER, mSceneFB); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mPipelineFB[mCurrentPipelineTexture]); - glBlitFramebuffer(0, 0, mWidth, mHeight, 0, 0, mWidth, mHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST); + glBlitFramebuffer(0, 0, mWidth, mHeight, 0, 0, mWidth, mHeight, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); if ((gl.flags & RFL_INVALIDATE_BUFFER) != 0) { @@ -494,6 +573,21 @@ void FGLRenderBuffers::BindSceneFB() glBindFramebuffer(GL_FRAMEBUFFER, mSceneFB); } +//========================================================================== +// +// Binds the depth texture to the specified texture unit +// +//========================================================================== + +void FGLRenderBuffers::BindSceneDepthTexture(int index) +{ + glActiveTexture(GL_TEXTURE0 + index); + if ((gl.flags & RFL_NO_DEPTHSTENCIL) != 0) + glBindTexture(GL_TEXTURE_2D, mPipelineDepth); + else + glBindTexture(GL_TEXTURE_2D, mPipelineDepthStencil); +} + //========================================================================== // // Binds the current scene/effect/hud texture to the specified texture unit diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index ee6d8de5e..898193e59 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -23,6 +23,7 @@ public: bool Setup(int width, int height, int sceneWidth, int sceneHeight); void BindSceneFB(); + void BindSceneDepthTexture(int index); void BlitSceneToTexture(); void BindCurrentTexture(int index); @@ -35,6 +36,14 @@ public: enum { NumBloomLevels = 4 }; FGLBloomTextureLevel BloomLevels[NumBloomLevels]; + // Ambient occlusion buffers + GLuint AmbientTexture0 = 0; + GLuint AmbientTexture1 = 0; + GLuint AmbientFB0 = 0; + GLuint AmbientFB1 = 0; + int AmbientWidth = 0; + int AmbientHeight = 0; + static bool IsEnabled(); int GetWidth() const { return mWidth; } @@ -44,15 +53,17 @@ private: void ClearScene(); void ClearPipeline(); void ClearBloom(); + void ClearAmbientOcclusion(); void CreateScene(int width, int height, int samples); void CreatePipeline(int width, int height); void CreateBloom(int width, int height); + void CreateAmbientOcclusion(int width, int height); GLuint Create2DTexture(const FString &name, GLuint format, int width, int height); GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height); GLuint CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer); - GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer); - GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer); + GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool fromRenderBuffers); + GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool fromRenderBuffers); bool CheckFrameBufferCompleteness(); void ClearFrameBuffer(bool stencil, bool depth); void DeleteTexture(GLuint &handle); @@ -65,22 +76,25 @@ private: int mHeight = 0; int mSamples = 0; int mMaxSamples = 0; - int mBloomWidth = 0; - int mBloomHeight = 0; + int mSceneWidth = 0; + int mSceneHeight = 0; static const int NumPipelineTextures = 2; int mCurrentPipelineTexture = 0; // Buffers for the scene - GLuint mSceneMultisample = 0; - GLuint mSceneDepthStencil = 0; - GLuint mSceneDepth = 0; - GLuint mSceneStencil = 0; + GLuint mSceneMSColor = 0; + GLuint mSceneMSDepthStencil = 0; + GLuint mSceneMSDepth = 0; + GLuint mSceneMSStencil = 0; GLuint mSceneFB = 0; // Effect/HUD buffers GLuint mPipelineTexture[NumPipelineTextures]; GLuint mPipelineFB[NumPipelineTextures]; + GLuint mPipelineDepthStencil = 0; + GLuint mPipelineDepth = 0; + GLuint mPipelineStencil = 0; // Back buffer frame buffer GLuint mOutputFB = 0; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index c8f2eb224..9e64c13b0 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -64,6 +64,7 @@ #include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/shaders/gl_shader.h" +#include "gl/shaders/gl_ambientshader.h" #include "gl/shaders/gl_bloomshader.h" #include "gl/shaders/gl_blurshader.h" #include "gl/shaders/gl_tonemapshader.h" @@ -120,6 +121,8 @@ void gl_FlushModels(); void FGLRenderer::Initialize(int width, int height) { mBuffers = new FGLRenderBuffers(); + mLinearDepthShader = new FLinearDepthShader(); + mSSAOShader = new FSSAOShader(); mBloomExtractShader = new FBloomExtractShader(); mBloomCombineShader = new FBloomCombineShader(); mBlurShader = new FBlurShader(); @@ -179,6 +182,8 @@ FGLRenderer::~FGLRenderer() } if (mBuffers) delete mBuffers; if (mPresentShader) delete mPresentShader; + if (mLinearDepthShader) delete mLinearDepthShader; + if (mSSAOShader) delete mSSAOShader; if (mBloomExtractShader) delete mBloomExtractShader; if (mBloomCombineShader) delete mBloomCombineShader; if (mBlurShader) delete mBlurShader; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 4b663680f..b07870738 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -19,6 +19,8 @@ class FLightBuffer; class FSamplerManager; class DPSprite; class FGLRenderBuffers; +class FLinearDepthShader; +class FSSAOShader; class FBloomExtractShader; class FBloomCombineShader; class FBlurShader; @@ -89,6 +91,8 @@ public: int mOldFBID; FGLRenderBuffers *mBuffers; + FLinearDepthShader *mLinearDepthShader; + FSSAOShader *mSSAOShader; FBloomExtractShader *mBloomExtractShader; FBloomCombineShader *mBloomCombineShader; FBlurShader *mBlurShader; @@ -164,6 +168,8 @@ public: void SetFixedColormap (player_t *player); void WriteSavePic (player_t *player, FILE *file, int width, int height); void EndDrawScene(sector_t * viewsector); + void PostProcessScene(); + void AmbientOccludeScene(); void BloomScene(); void TonemapScene(); void BindTonemapPalette(int texunit); @@ -186,6 +192,9 @@ public: void FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, DAngle rotation, FDynamicColormap *colormap, int lightlevel); + + static float GetZNear() { return 5.f; } + static float GetZFar() { return 65536.f; } }; // Global functions. Make them members of GLRenderer later? diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 08591283c..7537010b3 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -221,7 +221,7 @@ void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) { float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovratio)); - gl_RenderState.mProjectionMatrix.perspective(fovy, ratio, 5.f, 65536.f); + gl_RenderState.mProjectionMatrix.perspective(fovy, ratio, GetZNear(), GetZFar()); } // raw matrix input from stereo 3d modes @@ -855,13 +855,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo ProcessScene(toscreen); if (mainview && toscreen) EndDrawScene(retval); // do not call this for camera textures. - if (mainview) - { - if (FGLRenderBuffers::IsEnabled()) mBuffers->BlitSceneToTexture(); - BloomScene(); - TonemapScene(); - LensDistortScene(); - } + if (mainview) PostProcessScene(); mDrawingScene2D = false; eye->TearDown(); } diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp new file mode 100644 index 000000000..d9d4a3425 --- /dev/null +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -0,0 +1,89 @@ +/* +** gl_bloomshader.cpp +** Shaders used for screen space ambient occlusion +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "gl/gl_functions.h" +#include "vectors.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_ambientshader.h" + +void FLinearDepthShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/lineardepth.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/lineardepth"); + mShader.SetAttribLocation(0, "PositionInProjection"); + DepthTexture.Init(mShader, "DepthTexture"); + LinearizeDepthA.Init(mShader, "LinearizeDepthA"); + LinearizeDepthB.Init(mShader, "LinearizeDepthB"); + InverseDepthRangeA.Init(mShader, "InverseDepthRangeA"); + InverseDepthRangeB.Init(mShader, "InverseDepthRangeB"); + } + mShader.Bind(); +} + +void FSSAOShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssao.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/ssao"); + mShader.SetAttribLocation(0, "PositionInProjection"); + DepthTexture.Init(mShader, "DepthTexture"); + UVToViewA.Init(mShader, "UVToViewA"); + UVToViewB.Init(mShader, "UVToViewB"); + InvFullResolution.Init(mShader, "InvFullResolution"); + NDotVBias.Init(mShader, "NDotVBias"); + NegInvR2.Init(mShader, "NegInvR2"); + RadiusToScreen.Init(mShader, "RadiusToScreen"); + AOMultiplier.Init(mShader, "AOMultiplier"); + } + mShader.Bind(); +} diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h new file mode 100644 index 000000000..44f916596 --- /dev/null +++ b/src/gl/shaders/gl_ambientshader.h @@ -0,0 +1,39 @@ +#ifndef __GL_AMBIENTSHADER_H +#define __GL_AMBIENTSHADER_H + +#include "gl_shaderprogram.h" + +class FLinearDepthShader +{ +public: + void Bind(); + + FBufferedUniformSampler DepthTexture; + FBufferedUniform1f LinearizeDepthA; + FBufferedUniform1f LinearizeDepthB; + FBufferedUniform1f InverseDepthRangeA; + FBufferedUniform1f InverseDepthRangeB; + +private: + FShaderProgram mShader; +}; + +class FSSAOShader +{ +public: + void Bind(); + + FBufferedUniformSampler DepthTexture; + FBufferedUniform2f UVToViewA; + FBufferedUniform2f UVToViewB; + FBufferedUniform2f InvFullResolution; + FBufferedUniform1f NDotVBias; + FBufferedUniform1f NegInvR2; + FBufferedUniform1f RadiusToScreen; + FBufferedUniform1f AOMultiplier; + +private: + FShaderProgram mShader; +}; + +#endif \ No newline at end of file diff --git a/src/gl/stereo3d/gl_stereo3d.cpp b/src/gl/stereo3d/gl_stereo3d.cpp index d686a4a43..fa2a20ad4 100644 --- a/src/gl/stereo3d/gl_stereo3d.cpp +++ b/src/gl/stereo3d/gl_stereo3d.cpp @@ -49,7 +49,7 @@ VSMatrix EyePose::GetProjection(float fov, float aspectRatio, float fovRatio) co // Lifted from gl_scene.cpp FGLRenderer::SetProjection() float fovy = (float)(2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio))); - result.perspective(fovy, aspectRatio, 5.f, 65536.f); + result.perspective(fovy, aspectRatio, FGLRenderer::GetZNear(), FGLRenderer::GetZFar()); return result; } diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 010c70565..6c455b94c 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2634,6 +2634,7 @@ GLPREFMNU_MULTISAMPLE = "Multisample"; GLPREFMNU_TONEMAP = "Tonemap Mode"; GLPREFMNU_BLOOM = "Bloom effect"; GLPREFMNU_LENS = "Lens distortion effect"; +GLPREFMNU_SSAO = "Ambient occlusion"; // Option Values OPTVAL_SMART = "Smart"; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 0d080d709..aae2ae76d 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -230,4 +230,5 @@ OptionMenu "GLPrefOptions" Option "$GLPREFMNU_TONEMAP", gl_tonemap, "TonemapModes" Option "$GLPREFMNU_BLOOM", gl_bloom, "OnOff" Option "$GLPREFMNU_LENS", gl_lens, "OnOff" + Option "$GLPREFMNU_SSAO", gl_ssao, "OnOff" } diff --git a/wadsrc/static/shaders/glsl/lineardepth.fp b/wadsrc/static/shaders/glsl/lineardepth.fp new file mode 100644 index 000000000..f61bb3995 --- /dev/null +++ b/wadsrc/static/shaders/glsl/lineardepth.fp @@ -0,0 +1,16 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D DepthTexture; +uniform float LinearizeDepthA; +uniform float LinearizeDepthB; +uniform float InverseDepthRangeA; +uniform float InverseDepthRangeB; + +void main() +{ + float depth = texture(DepthTexture, TexCoord).x; + float normalizedDepth = clamp(InverseDepthRangeA * depth + InverseDepthRangeB, 0.0, 1.0); + FragColor = vec4(1.0 / (normalizedDepth * LinearizeDepthA + LinearizeDepthB), 0.0, 0.0, 1.0); +} diff --git a/wadsrc/static/shaders/glsl/ssao.fp b/wadsrc/static/shaders/glsl/ssao.fp new file mode 100644 index 000000000..c9f8534d9 --- /dev/null +++ b/wadsrc/static/shaders/glsl/ssao.fp @@ -0,0 +1,117 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform vec2 UVToViewA; +uniform vec2 UVToViewB; +uniform vec2 InvFullResolution; + +uniform float NDotVBias; +uniform float NegInvR2; +uniform float RadiusToScreen; +uniform float AOMultiplier; + +uniform sampler2D DepthTexture; + +#if USE_RANDOM_TEXTURE +uniform sampler2D RandomTexture; +#endif + +#define NUM_DIRECTIONS 8.0 +#define NUM_STEPS 4.0 + +#define PI 3.14159265358979323846 + +// Calculate eye space position for the specified texture coordinate +vec3 FetchViewPos(vec2 uv) +{ + float z = texture(DepthTexture, uv).x; + return vec3((UVToViewA * uv + UVToViewB) * z, z); +} + +vec3 MinDiff(vec3 p, vec3 pr, vec3 pl) +{ + vec3 v1 = pr - p; + vec3 v2 = p - pl; + return (dot(v1, v1) < dot(v2, v2)) ? v1 : v2; +} + +// Reconstruct eye space normal from nearest neighbors +vec3 ReconstructNormal(vec3 p) +{ + vec3 pr = FetchViewPos(TexCoord + vec2(InvFullResolution.x, 0)); + vec3 pl = FetchViewPos(TexCoord + vec2(-InvFullResolution.x, 0)); + vec3 pt = FetchViewPos(TexCoord + vec2(0, InvFullResolution.y)); + vec3 pb = FetchViewPos(TexCoord + vec2(0, -InvFullResolution.y)); + return normalize(cross(MinDiff(p, pr, pl), MinDiff(p, pt, pb))); +} + +// Compute normalized 2D direction +vec2 RotateDirection(vec2 dir, vec2 cossin) +{ + return vec2(dir.x * cossin.x - dir.y * cossin.y, dir.x * cossin.y + dir.y * cossin.x); +} + +vec4 GetJitter() +{ +#if !USE_RANDOM_TEXTURE + return vec4(1,0,1,1); + //vec3 rand = noise3(TexCoord.x + TexCoord.y); + //float angle = 2.0 * PI * rand.x / NUM_DIRECTIONS; + //return vec4(cos(angle), sin(angle), rand.y, rand.z); +#else + #define RANDOM_TEXTURE_WIDTH 4.0 + return texture(RandomTexture, gl_FragCoord.xy / RANDOM_TEXTURE_WIDTH); +#endif +} + +// Calculates the ambient occlusion of a sample +float ComputeSampleAO(vec3 kernelPos, vec3 normal, vec3 samplePos) +{ + vec3 v = samplePos - kernelPos; + float distanceSquare = dot(v, v); + float nDotV = dot(normal, v) * inversesqrt(distanceSquare); + return clamp(nDotV - NDotVBias, 0.0, 1.0) * clamp(distanceSquare * NegInvR2 + 1.0, 0.0, 1.0); +} + +// Calculates the total ambient occlusion for the entire fragment +float ComputeAO(vec3 viewPosition, vec3 viewNormal) +{ + vec4 rand = GetJitter(); + + float radiusPixels = RadiusToScreen / viewPosition.z; + float stepSizePixels = radiusPixels / (NUM_STEPS + 1.0); + + const float directionAngleStep = 2.0 * PI / NUM_DIRECTIONS; + float ao = 0.0; + + for (float directionIndex = 0.0; directionIndex < NUM_DIRECTIONS; ++directionIndex) + { + float angle = directionAngleStep * directionIndex; + + vec2 direction = RotateDirection(vec2(cos(angle), sin(angle)), rand.xy); + float rayPixels = (rand.z * stepSizePixels + 1.0); + + for (float StepIndex = 0.0; StepIndex < NUM_STEPS; ++StepIndex) + { + vec2 sampleUV = round(rayPixels * direction) * InvFullResolution + TexCoord; + vec3 samplePos = FetchViewPos(sampleUV); + ao += ComputeSampleAO(viewPosition, viewNormal, samplePos); + rayPixels += stepSizePixels; + } + } + + ao *= AOMultiplier / (NUM_DIRECTIONS * NUM_STEPS); + return clamp(1.0 - ao * 2.0, 0.0, 1.0); +} + +void main() +{ + vec3 viewPosition = FetchViewPos(TexCoord); + vec3 viewNormal = ReconstructNormal(viewPosition); + float occlusion = ComputeAO(viewPosition, viewNormal); + //FragColor = vec4(viewPosition.x * 0.001 + 0.5, viewPosition.y * 0.001 + 0.5, viewPosition.z * 0.001, 1.0); + //FragColor = vec4(viewNormal.x * 0.5 + 0.5, viewNormal.y * 0.5 + 0.5, viewNormal.z * 0.5 + 0.5, 1.0); + //FragColor = vec4(occlusion, viewPosition.z, 0.0, 1.0); + FragColor = vec4(occlusion, occlusion, occlusion, 1.0); +} From b7ec26335f8c8fd0e223e3f268c2b7d2258e5b07 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 29 Aug 2016 22:03:25 +0300 Subject: [PATCH 0862/1509] Enabled OpenGL Core Profile on macOS --- src/posix/cocoa/i_common.h | 3 +++ src/posix/cocoa/i_video.mm | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/posix/cocoa/i_common.h b/src/posix/cocoa/i_common.h index 4a558cf24..9cedb0262 100644 --- a/src/posix/cocoa/i_common.h +++ b/src/posix/cocoa/i_common.h @@ -190,6 +190,9 @@ typedef NSInteger NSApplicationActivationPolicy; static const NSWindowCollectionBehavior NSWindowCollectionBehaviorFullScreenAuxiliary = NSWindowCollectionBehavior(1 << 8); +static const NSOpenGLPixelFormatAttribute NSOpenGLPFAOpenGLProfile(96); +static const NSOpenGLPixelFormatAttribute NSOpenGLProfileVersion3_2Core(0x3200); + #endif // prior to 10.7 #endif // COCOA_I_COMMON_INCLUDED diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index e2b59449d..b026fa9b9 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -501,6 +501,12 @@ CocoaVideo::CocoaVideo(const int multisample) attributes[i++] = NSOpenGLPixelFormatAttribute(multisample); } + if (NSAppKitVersionNumber >= AppKit10_7) + { + attributes[i++] = NSOpenGLPFAOpenGLProfile; + attributes[i++] = NSOpenGLProfileVersion3_2Core; + } + attributes[i] = NSOpenGLPixelFormatAttribute(0); // Create OpenGL context and view From 3ba3149df35f858e135b1d49cceeecc6d6910d1a Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 29 Aug 2016 22:08:57 +0300 Subject: [PATCH 0863/1509] Deleted remains of obsolete multisampling in Cocoa backend --- src/posix/cocoa/i_video.mm | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index b026fa9b9..f455a5f9f 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -233,7 +233,7 @@ namespace class CocoaVideo : public IVideo { public: - explicit CocoaVideo(int multisample); + CocoaVideo(); virtual EDisplayType GetDisplayType() { return DISPLAY_Both; } virtual void SetWindowedScale(float scale); @@ -465,7 +465,7 @@ CocoaWindow* CreateCocoaWindow(const NSUInteger styleMask) // --------------------------------------------------------------------------- -CocoaVideo::CocoaVideo(const int multisample) +CocoaVideo::CocoaVideo() : m_window(CreateCocoaWindow(STYLE_MASK_WINDOWED)) , m_width(-1) , m_height(-1) @@ -492,15 +492,6 @@ CocoaVideo::CocoaVideo(const int multisample) attributes[i++] = NSOpenGLPFAAllowOfflineRenderers; } - if (multisample) - { - attributes[i++] = NSOpenGLPFAMultisample; - attributes[i++] = NSOpenGLPFASampleBuffers; - attributes[i++] = NSOpenGLPixelFormatAttribute(1); - attributes[i++] = NSOpenGLPFASamples; - attributes[i++] = NSOpenGLPixelFormatAttribute(multisample); - } - if (NSAppKitVersionNumber >= AppKit10_7) { attributes[i++] = NSOpenGLPFAOpenGLProfile; @@ -1260,7 +1251,7 @@ void I_InitGraphics() val.Bool = !!Args->CheckParm("-devparm"); ticker.SetGenericRepDefault(val, CVAR_Bool); - Video = new CocoaVideo(0); + Video = new CocoaVideo; atterm(I_ShutdownGraphics); } From 240ebf94a1d3c8463a4a4e8eb36ae3b2d95160d5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 29 Aug 2016 22:42:46 +0200 Subject: [PATCH 0864/1509] Remove radius increase in point light modes --- src/gl/dynlights/gl_dynlight1.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index 56db94e4d..858bcfd09 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -139,9 +139,6 @@ bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, bo if (gl_light_math != 0) { - // Adjust light slightly to make the range better match plain attenuation - radius *= 1.5; - // Move light up because flasks/vials have their light source location at/below the floor. // // If the point is exactly on the wall plane it might cause some acne as some pixels could From 45ff15559dc713248bcde7fa44a68f5b78219d68 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 30 Aug 2016 00:33:02 +0200 Subject: [PATCH 0865/1509] - removed gl_draw_synv because with the postprocessing this is no longer useful. --- src/gl/scene/gl_scene.cpp | 9 --------- src/gl/scene/gl_walls.cpp | 1 - src/gl/system/gl_framebuffer.cpp | 8 +------- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 08591283c..c2812db0f 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -480,7 +480,6 @@ void FGLRenderer::RenderTranslucent() // stencil, z-buffer and the projection matrix intact! // //----------------------------------------------------------------------------- -EXTERN_CVAR(Bool, gl_draw_sync) void FGLRenderer::DrawScene(int drawmode) { @@ -502,14 +501,6 @@ void FGLRenderer::DrawScene(int drawmode) } GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. - // Up to this point in the main draw call no rendering is performed so we can wait - // with swapping the render buffer until now. - if (!gl_draw_sync && drawmode == DM_MAINVIEW) - { - All.Unclock(); - static_cast(screen)->Swap(); - All.Clock(); - } RenderScene(recursion); // Handle all portals after rendering the opaque objects but before diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 3afde063c..5b2271433 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -142,7 +142,6 @@ void GLWall::PutWall(bool translucent) { if (gl.lightmethod == LM_SOFTWARE && !translucent) { - // This is not yet ready. if (PutWallCompat(passflag[type])) return; } diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index ae1fabaed..ec77cfd14 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -179,9 +179,6 @@ void OpenGLFrameBuffer::InitializeState() // //========================================================================== -// Testing only for now. -CVAR(Bool, gl_draw_sync, true, 0) //false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) - void OpenGLFrameBuffer::Update() { if (!CanUpdate()) @@ -197,10 +194,7 @@ void OpenGLFrameBuffer::Update() GLRenderer->SetOutputViewport(nullptr); - if (gl_draw_sync || !swapped) - { - Swap(); - } + Swap(); swapped = false; Unlock(); CheckBench(); From 55ea4a7729b012fb1cda06e274d5dd4d991e6b8b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 30 Aug 2016 01:09:21 +0200 Subject: [PATCH 0866/1509] Add ssao random texture --- src/gl/renderer/gl_postprocess.cpp | 10 +++++++++ src/gl/renderer/gl_postprocessstate.cpp | 26 ++++++++++++++++++++++-- src/gl/renderer/gl_postprocessstate.h | 5 ++++- src/gl/renderer/gl_renderbuffers.cpp | 27 +++++++++++++++++++++++-- src/gl/renderer/gl_renderbuffers.h | 3 ++- src/gl/shaders/gl_ambientshader.cpp | 11 +++++++++- src/gl/shaders/gl_ambientshader.h | 2 ++ wadsrc/static/shaders/glsl/ssao.fp | 16 ++++++++------- 8 files changed, 86 insertions(+), 14 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index c7d0494c8..bd35fedd3 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -108,6 +108,7 @@ CVAR(Float, gl_lens_kcube, 0.1f, 0) CVAR(Float, gl_lens_chromatic, 1.12f, 0) CVAR(Bool, gl_ssao, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Float, gl_ssao_strength, 0.7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, gl_ssao_debug, false, 0) CVAR(Float, gl_ssao_bias, 0.5f, 0) CVAR(Float, gl_ssao_radius, 100.0f, 0) @@ -155,11 +156,13 @@ void FGLRenderer::AmbientOccludeScene() FGLDebug::PushGroup("AmbientOccludeScene"); FGLPostProcessState savedState; + savedState.SaveTextureBinding1(); float bias = gl_ssao_bias; float aoRadius = gl_ssao_radius; const float blurAmount = gl_ssao_blur_amount; int blurSampleCount = gl_ssao_blur_samples; + float aoStrength = gl_ssao_strength; //float tanHalfFovy = tan(fovy * (M_PI / 360.0f)); float tanHalfFovy = 1.0f / 1.33333302f; //gl_RenderState.mProjectionMatrix.get()[5]; @@ -185,8 +188,14 @@ void FGLRenderer::AmbientOccludeScene() glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientRandomTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glActiveTexture(GL_TEXTURE0); mSSAOShader->Bind(); mSSAOShader->DepthTexture.Set(0); + mSSAOShader->RandomTexture.Set(1); mSSAOShader->UVToViewA.Set(2.0f * invFocalLenX, -2.0f * invFocalLenY); mSSAOShader->UVToViewB.Set(-invFocalLenX, invFocalLenY); mSSAOShader->InvFullResolution.Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); @@ -194,6 +203,7 @@ void FGLRenderer::AmbientOccludeScene() mSSAOShader->NegInvR2.Set(-1.0f / r2); mSSAOShader->RadiusToScreen.Set(aoRadius * 0.5 / tanHalfFovy * mBuffers->AmbientHeight); mSSAOShader->AOMultiplier.Set(1.0f / (1.0f - nDotVBias)); + mSSAOShader->AOStrength.Set(aoStrength); RenderScreenQuad(); // Blur SSAO texture diff --git a/src/gl/renderer/gl_postprocessstate.cpp b/src/gl/renderer/gl_postprocessstate.cpp index 05cca7f31..06a50d89a 100644 --- a/src/gl/renderer/gl_postprocessstate.cpp +++ b/src/gl/renderer/gl_postprocessstate.cpp @@ -58,7 +58,7 @@ FGLPostProcessState::FGLPostProcessState() { glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); glActiveTexture(GL_TEXTURE0); - glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding[0]); glBindTexture(GL_TEXTURE_2D, 0); if (gl.flags & RFL_SAMPLER_OBJECTS) { @@ -88,6 +88,15 @@ FGLPostProcessState::FGLPostProcessState() glDisable(GL_BLEND); } +void FGLPostProcessState::SaveTextureBinding1() +{ + glActiveTexture(GL_TEXTURE1); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding[1]); + glBindTexture(GL_TEXTURE_2D, 0); + textureBinding1Saved = true; + glActiveTexture(GL_TEXTURE0); +} + //----------------------------------------------------------------------------- // // Restores state at the end of post processing @@ -121,6 +130,12 @@ FGLPostProcessState::~FGLPostProcessState() glUseProgram(currentProgram); + if (textureBinding1Saved) + { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, 0); + } + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); if (gl.flags & RFL_SAMPLER_OBJECTS) @@ -128,6 +143,13 @@ FGLPostProcessState::~FGLPostProcessState() glBindSampler(0, samplerBinding[0]); glBindSampler(1, samplerBinding[1]); } - glBindTexture(GL_TEXTURE_2D, textureBinding); + glBindTexture(GL_TEXTURE_2D, textureBinding[0]); + + if (textureBinding1Saved) + { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, textureBinding[1]); + } + glActiveTexture(activeTex); } diff --git a/src/gl/renderer/gl_postprocessstate.h b/src/gl/renderer/gl_postprocessstate.h index 4f2ca81a1..bf53aa7de 100644 --- a/src/gl/renderer/gl_postprocessstate.h +++ b/src/gl/renderer/gl_postprocessstate.h @@ -14,12 +14,14 @@ public: FGLPostProcessState(); ~FGLPostProcessState(); + void SaveTextureBinding1(); + private: FGLPostProcessState(const FGLPostProcessState &) = delete; FGLPostProcessState &operator=(const FGLPostProcessState &) = delete; GLint activeTex; - GLint textureBinding; + GLint textureBinding[2]; GLint samplerBinding[2]; GLboolean blendEnabled; GLboolean scissorEnabled; @@ -32,6 +34,7 @@ private: GLint blendSrcAlpha; GLint blendDestRgb; GLint blendDestAlpha; + bool textureBinding1Saved = false; }; #endif diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index c1976565b..e00d836bf 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -53,6 +53,7 @@ #include "w_wad.h" #include "i_system.h" #include "doomerrors.h" +#include CVAR(Int, gl_multisample, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); CVAR(Bool, gl_renderbuffers, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); @@ -129,6 +130,7 @@ void FGLRenderBuffers::ClearAmbientOcclusion() DeleteFrameBuffer(AmbientFB1); DeleteTexture(AmbientTexture0); DeleteTexture(AmbientTexture1); + DeleteTexture(AmbientRandomTexture); } void FGLRenderBuffers::DeleteTexture(GLuint &handle) @@ -334,6 +336,26 @@ void FGLRenderBuffers::CreateAmbientOcclusion(int width, int height) AmbientTexture1 = Create2DTexture("AmbientTexture1", GetHdrFormat(), AmbientWidth, AmbientHeight); AmbientFB0 = CreateFrameBuffer("AmbientFB0", AmbientTexture0); AmbientFB1 = CreateFrameBuffer("AmbientFB1", AmbientTexture1); + + int16_t randomValues[16 * 4]; + std::mt19937 generator(1337); + std::uniform_real_distribution distribution(-1.0, 1.0); + for (int i = 0; i < 16; i++) + { + double num_directions = 8.0; // Must be same as the define in ssao.fp + double angle = 2.0 * M_PI * distribution(generator) / num_directions; + double x = cos(angle); + double y = sin(angle); + double z = distribution(generator); + double w = distribution(generator); + + randomValues[i * 4 + 0] = (int16_t)clamp(x * 32768.0, -32767.0, 32768.0); + randomValues[i * 4 + 1] = (int16_t)clamp(y * 32768.0, -32767.0, 32768.0); + randomValues[i * 4 + 2] = (int16_t)clamp(z * 32768.0, -32767.0, 32768.0); + randomValues[i * 4 + 3] = (int16_t)clamp(w * 32768.0, -32767.0, 32768.0); + } + + AmbientRandomTexture = Create2DTexture("AmbientRandomTexture", GL_RGBA16_SNORM, 4, 4, randomValues); } //========================================================================== @@ -353,7 +375,7 @@ GLuint FGLRenderBuffers::GetHdrFormat() // //========================================================================== -GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height) +GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height, const void *data) { GLuint handle = 0; glGenTextures(1, &handle); @@ -369,10 +391,11 @@ GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int case GL_DEPTH_COMPONENT24: dataformat = GL_DEPTH_COMPONENT; datatype = GL_FLOAT; break; case GL_STENCIL_INDEX8: dataformat = GL_STENCIL_INDEX; datatype = GL_INT; break; case GL_DEPTH24_STENCIL8: dataformat = GL_DEPTH_STENCIL; datatype = GL_UNSIGNED_INT_24_8; break; + case GL_RGBA16_SNORM: dataformat = GL_RGBA; datatype = GL_SHORT; break; default: I_FatalError("Unknown format passed to FGLRenderBuffers.Create2DTexture"); } - glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, dataformat, datatype, nullptr); + glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, dataformat, datatype, data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 898193e59..814fd9de8 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -43,6 +43,7 @@ public: GLuint AmbientFB1 = 0; int AmbientWidth = 0; int AmbientHeight = 0; + GLuint AmbientRandomTexture = 0; static bool IsEnabled(); @@ -58,7 +59,7 @@ private: void CreatePipeline(int width, int height); void CreateBloom(int width, int height); void CreateAmbientOcclusion(int width, int height); - GLuint Create2DTexture(const FString &name, GLuint format, int width, int height); + GLuint Create2DTexture(const FString &name, GLuint format, int width, int height, const void *data = nullptr); GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height); GLuint CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer); diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index d9d4a3425..55682a91e 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -71,12 +71,20 @@ void FSSAOShader::Bind() { if (!mShader) { + const char *defines = R"( + #define USE_RANDOM_TEXTURE + #define RANDOM_TEXTURE_WIDTH 4.0 + #define NUM_DIRECTIONS 8.0 + #define NUM_STEPS 4.0 + )"; + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); - mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssao.fp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssao.fp", defines, 330); mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/ssao"); mShader.SetAttribLocation(0, "PositionInProjection"); DepthTexture.Init(mShader, "DepthTexture"); + RandomTexture.Init(mShader, "RandomTexture"); UVToViewA.Init(mShader, "UVToViewA"); UVToViewB.Init(mShader, "UVToViewB"); InvFullResolution.Init(mShader, "InvFullResolution"); @@ -84,6 +92,7 @@ void FSSAOShader::Bind() NegInvR2.Init(mShader, "NegInvR2"); RadiusToScreen.Init(mShader, "RadiusToScreen"); AOMultiplier.Init(mShader, "AOMultiplier"); + AOStrength.Init(mShader, "AOStrength"); } mShader.Bind(); } diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index 44f916596..fdff178ec 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -24,6 +24,7 @@ public: void Bind(); FBufferedUniformSampler DepthTexture; + FBufferedUniformSampler RandomTexture; FBufferedUniform2f UVToViewA; FBufferedUniform2f UVToViewB; FBufferedUniform2f InvFullResolution; @@ -31,6 +32,7 @@ public: FBufferedUniform1f NegInvR2; FBufferedUniform1f RadiusToScreen; FBufferedUniform1f AOMultiplier; + FBufferedUniform1f AOStrength; private: FShaderProgram mShader; diff --git a/wadsrc/static/shaders/glsl/ssao.fp b/wadsrc/static/shaders/glsl/ssao.fp index c9f8534d9..f143e913f 100644 --- a/wadsrc/static/shaders/glsl/ssao.fp +++ b/wadsrc/static/shaders/glsl/ssao.fp @@ -11,15 +11,14 @@ uniform float NegInvR2; uniform float RadiusToScreen; uniform float AOMultiplier; +uniform float AOStrength; + uniform sampler2D DepthTexture; -#if USE_RANDOM_TEXTURE +#if defined(USE_RANDOM_TEXTURE) uniform sampler2D RandomTexture; #endif -#define NUM_DIRECTIONS 8.0 -#define NUM_STEPS 4.0 - #define PI 3.14159265358979323846 // Calculate eye space position for the specified texture coordinate @@ -54,13 +53,12 @@ vec2 RotateDirection(vec2 dir, vec2 cossin) vec4 GetJitter() { -#if !USE_RANDOM_TEXTURE +#if !defined(USE_RANDOM_TEXTURE) return vec4(1,0,1,1); //vec3 rand = noise3(TexCoord.x + TexCoord.y); //float angle = 2.0 * PI * rand.x / NUM_DIRECTIONS; //return vec4(cos(angle), sin(angle), rand.y, rand.z); #else - #define RANDOM_TEXTURE_WIDTH 4.0 return texture(RandomTexture, gl_FragCoord.xy / RANDOM_TEXTURE_WIDTH); #endif } @@ -109,7 +107,11 @@ void main() { vec3 viewPosition = FetchViewPos(TexCoord); vec3 viewNormal = ReconstructNormal(viewPosition); - float occlusion = ComputeAO(viewPosition, viewNormal); + float occlusion = ComputeAO(viewPosition, viewNormal) * AOStrength + (1.0 - AOStrength); + + // GZDoom does not use linear buffers at the moment, apply some gamma to get it closer to correct + occlusion = occlusion * occlusion; + //FragColor = vec4(viewPosition.x * 0.001 + 0.5, viewPosition.y * 0.001 + 0.5, viewPosition.z * 0.001, 1.0); //FragColor = vec4(viewNormal.x * 0.5 + 0.5, viewNormal.y * 0.5 + 0.5, viewNormal.z * 0.5 + 0.5, 1.0); //FragColor = vec4(occlusion, viewPosition.z, 0.0, 1.0); From 4a0e0828366dda0fb6de69b734c4e190ba9c6026 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 31 Aug 2016 23:26:49 +0200 Subject: [PATCH 0867/1509] - fixed: The wall splitter in the translucent sorting code needs to set fracleft and fracright so that vertex generation is done correctly for the split segments. --- src/gl/scene/gl_drawinfo.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 842423094..d5ed62755 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -476,6 +476,7 @@ void GLDrawList::SortWallIntoWall(SortNode * head,SortNode * sort) ws1->glseg.x1=ws->glseg.x2=ix; ws1->glseg.y1=ws->glseg.y2=iy; + ws1->glseg.fracleft = ws->glseg.fracright = ws->glseg.fracleft + r*(ws->glseg.fracright - ws->glseg.fracleft); ws1->ztop[0]=ws->ztop[1]=izt; ws1->zbottom[0]=ws->zbottom[1]=izb; ws1->tcs[GLWall::LOLFT].u = ws1->tcs[GLWall::UPLFT].u = ws->tcs[GLWall::LORGT].u = ws->tcs[GLWall::UPRGT].u = iu; From 8a2737a0ce3b2cc40e03dc3037a315c8105b8a83 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 1 Sep 2016 07:15:40 +0200 Subject: [PATCH 0868/1509] Fix precision issue in SSAO shader --- src/gl/renderer/gl_postprocess.cpp | 8 ++++---- src/gl/renderer/gl_renderbuffers.cpp | 5 +++-- src/gl/renderer/gl_renderbuffers.h | 3 +++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index bd35fedd3..62815f718 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -112,11 +112,11 @@ CVAR(Float, gl_ssao_strength, 0.7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, gl_ssao_debug, false, 0) CVAR(Float, gl_ssao_bias, 0.5f, 0) CVAR(Float, gl_ssao_radius, 100.0f, 0) -CUSTOM_CVAR(Float, gl_ssao_blur_amount, 6.0f, 0) +CUSTOM_CVAR(Float, gl_ssao_blur_amount, 4.0f, 0) { if (self < 0.1f) self = 0.1f; } -CUSTOM_CVAR(Int, gl_ssao_blur_samples, 9, 0) +CUSTOM_CVAR(Int, gl_ssao_blur_samples, 5, 0) { if (self < 3 || self > 15 || self % 2 == 0) self = 9; @@ -165,8 +165,8 @@ void FGLRenderer::AmbientOccludeScene() float aoStrength = gl_ssao_strength; //float tanHalfFovy = tan(fovy * (M_PI / 360.0f)); - float tanHalfFovy = 1.0f / 1.33333302f; //gl_RenderState.mProjectionMatrix.get()[5]; - float invFocalLenX = tanHalfFovy * (mBuffers->AmbientWidth / (float)mBuffers->AmbientHeight); + float tanHalfFovy = 1.0f / 1.33333302f; // 1.0f / gl_RenderState.mProjectionMatrix.get()[5]; + float invFocalLenX = tanHalfFovy * (mBuffers->GetSceneWidth() / (float)mBuffers->GetSceneHeight()); float invFocalLenY = tanHalfFovy; float nDotVBias = clamp(bias, 0.0f, 1.0f); float r2 = aoRadius * aoRadius; diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index e00d836bf..6da85bba7 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -332,8 +332,8 @@ void FGLRenderBuffers::CreateAmbientOcclusion(int width, int height) AmbientWidth = width / 2; AmbientHeight = height / 2; - AmbientTexture0 = Create2DTexture("AmbientTexture0", GetHdrFormat(), AmbientWidth, AmbientHeight); - AmbientTexture1 = Create2DTexture("AmbientTexture1", GetHdrFormat(), AmbientWidth, AmbientHeight); + AmbientTexture0 = Create2DTexture("AmbientTexture0", GL_RGBA32F, AmbientWidth, AmbientHeight); + AmbientTexture1 = Create2DTexture("AmbientTexture1", GL_RGBA32F, AmbientWidth, AmbientHeight); AmbientFB0 = CreateFrameBuffer("AmbientFB0", AmbientTexture0); AmbientFB1 = CreateFrameBuffer("AmbientFB1", AmbientTexture1); @@ -388,6 +388,7 @@ GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int case GL_RGBA8: dataformat = GL_RGBA; datatype = GL_UNSIGNED_BYTE; break; case GL_RGBA16: dataformat = GL_RGBA; datatype = GL_UNSIGNED_SHORT; break; case GL_RGBA16F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; + case GL_RGBA32F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; case GL_DEPTH_COMPONENT24: dataformat = GL_DEPTH_COMPONENT; datatype = GL_FLOAT; break; case GL_STENCIL_INDEX8: dataformat = GL_STENCIL_INDEX; datatype = GL_INT; break; case GL_DEPTH24_STENCIL8: dataformat = GL_DEPTH_STENCIL; datatype = GL_UNSIGNED_INT_24_8; break; diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 814fd9de8..5dc2e49bd 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -50,6 +50,9 @@ public: int GetWidth() const { return mWidth; } int GetHeight() const { return mHeight; } + int GetSceneWidth() const { return mSceneWidth; } + int GetSceneHeight() const { return mSceneHeight; } + private: void ClearScene(); void ClearPipeline(); From 3389a5a74edbc240a6618336b1cf917cea4144b1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 1 Sep 2016 11:52:52 +0200 Subject: [PATCH 0869/1509] - removed most of the specific options for legacy hardware and consolidated them in one variable (does not work yet.) --- src/gl/compatibility/gl_20.cpp | 35 +---- src/gl/data/gl_vertexbuffer.cpp | 27 ++-- src/gl/models/gl_models.cpp | 10 +- src/gl/renderer/gl_postprocess.cpp | 6 +- src/gl/renderer/gl_renderbuffers.cpp | 17 +-- src/gl/renderer/gl_renderer.cpp | 6 +- src/gl/renderer/gl_renderstate.cpp | 4 +- src/gl/renderer/gl_renderstate.h | 2 +- src/gl/scene/gl_drawinfo.cpp | 17 ++- src/gl/scene/gl_drawinfo.h | 2 - src/gl/scene/gl_flats.cpp | 4 +- src/gl/scene/gl_scene.cpp | 12 +- src/gl/scene/gl_skydome.cpp | 4 +- src/gl/scene/gl_sprite.cpp | 2 +- src/gl/scene/gl_walls.cpp | 2 +- src/gl/scene/gl_walls_draw.cpp | 9 +- src/gl/shaders/gl_blurshader.cpp | 22 --- src/gl/shaders/gl_shader.cpp | 50 +++---- src/gl/shaders/gl_shaderprogram.cpp | 50 +------ src/gl/shaders/gl_shaderprogram.h | 5 - src/gl/system/gl_framebuffer.cpp | 2 +- src/gl/system/gl_interface.cpp | 194 ++++++++++++-------------- src/gl/system/gl_interface.h | 16 +-- src/gl/textures/gl_hqresize.cpp | 2 +- src/gl/textures/gl_material.cpp | 8 +- wadsrc/static/shaders/glsl/main.fp | 27 ---- wadsrc/static/shaders/glsl/tonemap.fp | 7 - 27 files changed, 182 insertions(+), 360 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 8e6682f17..97abc0d82 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -66,7 +66,7 @@ void gl_PatchMenu() { - if (gl.glslversion == 0) + if (gl.legacyMode) { // Radial fog and Doom lighting are not available without full shader support. @@ -99,6 +99,8 @@ void gl_PatchMenu() // disable features that don't work without shaders. if (gl_lightmode == 2 || gl_lightmode == 8) gl_lightmode = 3; if (gl_fogmode == 2) gl_fogmode = 1; + + // todo: remove more unsupported stuff like postprocessing options. } } @@ -378,7 +380,7 @@ void FRenderState::DrawColormapOverlay() //========================================================================== bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, - float & scale, int desaturation, bool checkside, bool additive) + float & scale, bool checkside, bool additive) { Vector fn, pos; @@ -434,14 +436,6 @@ bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, { gl_RenderState.BlendEquation(GL_FUNC_ADD); } - if (desaturation > 0 && gl.glslversion > 0) // no-shader excluded because no desaturated textures. - { - float gray = (r * 77 + g * 143 + b * 37) / 257; - - r = (r*(32 - desaturation) + gray*desaturation) / 32; - g = (g*(32 - desaturation) + gray*desaturation) / 32; - b = (b*(32 - desaturation) + gray*desaturation) / 32; - } gl_RenderState.SetColor(r, g, b); return true; } @@ -491,11 +485,6 @@ bool GLWall::PutWallCompat(int passflag) bool masked = passflag == 2 && gltexture->isMasked(); int list = list_indices[masked][foggy]; - if (list == GLLDL_WALLS_PLAIN) - { - if (gltexture->tex->gl_info.Brightmap && gl.glslversion >= 0.f) list = GLLDL_WALLS_BRIGHT; - //if (flags & GLWF_GLOW) list = GLLDL_WALLS_BRIGHT; - } gl_drawinfo->dldrawlists[list].AddWall(this); return true; @@ -520,10 +509,6 @@ bool GLFlat::PutFlatCompat(bool fog) int list = list_indices[masked][foggy]; - if (list == GLLDL_FLATS_PLAIN) - { - if (gltexture->tex->gl_info.Brightmap && gl.glslversion >= 0.f) list = GLLDL_FLATS_BRIGHT; - } gl_drawinfo->dldrawlists[list].AddFlat(this); return true; } @@ -612,7 +597,7 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) } p.Set(plane.plane); - if (!gl_SetupLight(sub->sector->PortalGroup, p, light, nearPt, up, right, scale, CM_DEFAULT, false, pass != GLPASS_LIGHTTEX)) + if (!gl_SetupLight(sub->sector->PortalGroup, p, light, nearPt, up, right, scale, false, pass != GLPASS_LIGHTTEX)) { node = node->nextLight; continue; @@ -692,7 +677,7 @@ bool GLWall::PrepareLight(ADynamicLight * light, int pass) return false; } - if (!gl_SetupLight(seg->frontsector->PortalGroup, p, light, nearPt, up, right, scale, CM_DEFAULT, true, pass != GLPASS_LIGHTTEX)) + if (!gl_SetupLight(seg->frontsector->PortalGroup, p, light, nearPt, up, right, scale, true, pass != GLPASS_LIGHTTEX)) { return false; } @@ -798,9 +783,7 @@ void FGLRenderer::RenderMultipassStuff() gl_RenderState.SetTextureMode(TM_MASK); gl_RenderState.EnableBrightmap(true); gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); - gl_drawinfo->dldrawlists[GLLDL_WALLS_BRIGHT].DrawWalls(GLPASS_PLAIN); gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_PLAIN); - gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_PLAIN); gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_PLAIN); // Part 3: The base of fogged surfaces, including the texture @@ -823,10 +806,8 @@ void FGLRenderer::RenderMultipassStuff() glDepthFunc(GL_EQUAL); if (glset.lightmode == 8) gl_RenderState.SetSoftLightLevel(255); gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_LIGHTTEX); - gl_drawinfo->dldrawlists[GLLDL_WALLS_BRIGHT].DrawWalls(GLPASS_LIGHTTEX); gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_LIGHTTEX); gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX); - gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_LIGHTTEX); gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_LIGHTTEX); gl_RenderState.BlendEquation(GL_FUNC_ADD); } @@ -841,8 +822,6 @@ void FGLRenderer::RenderMultipassStuff() glDepthFunc(GL_LEQUAL); gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_TEXONLY); gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_TEXONLY); - gl_drawinfo->dldrawlists[GLLDL_WALLS_BRIGHT].DrawWalls(GLPASS_TEXONLY); - gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_TEXONLY); gl_RenderState.AlphaFunc(GL_GREATER, gl_mask_threshold); gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_TEXONLY); gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_TEXONLY); @@ -854,10 +833,8 @@ void FGLRenderer::RenderMultipassStuff() if (gl_SetupLightTexture()) { gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE); - gl_drawinfo->dldrawlists[GLLDL_WALLS_BRIGHT].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE); gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE); gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); - gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(GLPASS_LIGHTTEX_FOGGY); gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(GLPASS_LIGHTTEX_FOGGY); diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 5833d3109..0309b2bcd 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -75,7 +75,7 @@ FVertexBuffer::~FVertexBuffer() void FSimpleVertexBuffer::BindVBO() { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - if (gl.glslversion > 0) + if (!gl.legacyMode) { glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FSimpleVertex), &VSiO->x); glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSimpleVertex), &VSiO->u); @@ -100,7 +100,7 @@ void FSimpleVertexBuffer::EnableColorArray(bool on) { if (on) { - if (gl.glslversion > 0) + if (!gl.legacyMode) { glEnableVertexAttribArray(VATTR_COLOR); } @@ -111,7 +111,7 @@ void FSimpleVertexBuffer::EnableColorArray(bool on) } else { - if (gl.glslversion > 0) + if (!gl.legacyMode) { glDisableVertexAttribArray(VATTR_COLOR); } @@ -138,7 +138,7 @@ void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count) //========================================================================== FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) -: FVertexBuffer(gl.buffermethod != BM_CLIENTARRAY) +: FVertexBuffer(!gl.legacyMode) { switch (gl.buffermethod) { @@ -162,7 +162,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) break; } - case BM_CLIENTARRAY: + default: { map = new FFlatVertex[BUFFER_SIZE]; DPrintf(DMSG_NOTIFY, "Using client array buffer\n"); @@ -219,7 +219,7 @@ FFlatVertexBuffer::~FFlatVertexBuffer() glUnmapBuffer(GL_ARRAY_BUFFER); glBindBuffer(GL_ARRAY_BUFFER, 0); } - if (gl.buffermethod == BM_CLIENTARRAY) + if (gl.legacyMode) { delete[] map; } @@ -230,19 +230,10 @@ FFlatVertexBuffer::~FFlatVertexBuffer() void FFlatVertexBuffer::BindVBO() { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - if (gl.glslversion > 0) + if (!gl.legacyMode) { - if (gl.buffermethod != BM_CLIENTARRAY) - { - glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); - glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); - } - else - { - // If we cannot use a hardware buffer, use an old-style client array. - glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &map->x); - glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &map->u); - } + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); glEnableVertexAttribArray(VATTR_VERTEX); glEnableVertexAttribArray(VATTR_TEXCOORD); glDisableVertexAttribArray(VATTR_COLOR); diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index e686f2cea..22b61ace4 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -105,7 +105,7 @@ void gl_FlushModels() //=========================================================================== FModelVertexBuffer::FModelVertexBuffer(bool needindex, bool singleframe) - : FVertexBuffer(singleframe || gl.glslversion > 0) + : FVertexBuffer(singleframe || !gl.legacyMode) { vbo_ptr = nullptr; ibo_id = 0; @@ -125,7 +125,7 @@ void FModelVertexBuffer::BindVBO() { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - if (gl.glslversion > 0) + if (!gl.legacyMode) { glEnableVertexAttribArray(VATTR_VERTEX); glEnableVertexAttribArray(VATTR_TEXCOORD); @@ -170,7 +170,7 @@ FModelVertex *FModelVertexBuffer::LockVertexBuffer(unsigned int size) { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glBufferData(GL_ARRAY_BUFFER, size * sizeof(FModelVertex), nullptr, GL_STATIC_DRAW); - if (gl.version >= 3.0) + if (!gl.legacyMode) return (FModelVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, size * sizeof(FModelVertex), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); else return (FModelVertex*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); @@ -211,7 +211,7 @@ unsigned int *FModelVertexBuffer::LockIndexBuffer(unsigned int size) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); glBufferData(GL_ELEMENT_ARRAY_BUFFER, size * sizeof(unsigned int), NULL, GL_STATIC_DRAW); - if (gl.version >= 3.0) + if (!gl.legacyMode) return (unsigned int*)glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, size * sizeof(unsigned int), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); else return (unsigned int*)glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); @@ -251,7 +251,7 @@ unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int fr glBindBuffer(GL_ARRAY_BUFFER, vbo_id); if (vbo_id > 0) { - if (gl.glslversion > 0) + if (!gl.legacyMode) { glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].x); glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].u); diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 3a83f4caf..047153554 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -126,7 +126,7 @@ void FGLRenderer::RenderScreenQuad() void FGLRenderer::BloomScene() { // Only bloom things if enabled and no special fixed light mode is active - if (!gl_bloom || !FGLRenderBuffers::IsEnabled() || gl_fixedcolormap != CM_DEFAULT) + if (!gl_bloom || gl_fixedcolormap != CM_DEFAULT) return; FGLDebug::PushGroup("BloomScene"); @@ -212,7 +212,7 @@ void FGLRenderer::BloomScene() void FGLRenderer::TonemapScene() { - if (gl_tonemap == 0 || !FGLRenderBuffers::IsEnabled()) + if (gl_tonemap == 0) return; FGLDebug::PushGroup("TonemapScene"); @@ -292,7 +292,7 @@ void FGLRenderer::ClearTonemapPalette() void FGLRenderer::LensDistortScene() { - if (gl_lens == 0 || !FGLRenderBuffers::IsEnabled()) + if (gl_lens == 0) return; FGLDebug::PushGroup("LensDistortScene"); diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index fd98522d8..f8b5dfcdd 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -218,17 +218,8 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples) if (samples > 1) mSceneMultisample = CreateRenderBuffer("SceneMultisample", GetHdrFormat(), samples, width, height); - if ((gl.flags & RFL_NO_DEPTHSTENCIL) != 0) - { - mSceneDepth = CreateRenderBuffer("SceneDepth", GL_DEPTH_COMPONENT24, samples, width, height); - mSceneStencil = CreateRenderBuffer("SceneStencil", GL_STENCIL_INDEX8, samples, width, height); - mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepth, mSceneStencil, samples > 1); - } - else - { - mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, samples, width, height); - mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1); - } + mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, samples, width, height); + mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1); } //========================================================================== @@ -288,7 +279,7 @@ void FGLRenderBuffers::CreateBloom(int width, int height) GLuint FGLRenderBuffers::GetHdrFormat() { - return ((gl.flags & RFL_NO_RGBA16F) != 0) ? GL_RGBA8 : GL_RGBA16F; + return GL_RGBA16F; } //========================================================================== @@ -559,7 +550,7 @@ void FGLRenderBuffers::BindOutputFB() bool FGLRenderBuffers::IsEnabled() { - return gl_renderbuffers && gl.glslversion != 0 && !FailedCreate; + return gl_renderbuffers && !gl.legacyMode && !FailedCreate; } bool FGLRenderBuffers::FailedCreate = false; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index c8f2eb224..20126ba77 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -129,8 +129,8 @@ void FGLRenderer::Initialize(int width, int height) mPresentShader = new FPresentShader(); m2DDrawer = new F2DDrawer; - // Only needed for the core profile, because someone decided it was a good idea to remove the default VAO. - if (gl.buffermethod != BM_CLIENTARRAY) + // needed for the core profile, because someone decided it was a good idea to remove the default VAO. + if (!gl.legacyMode) { glGenVertexArrays(1, &mVAOID); glBindVertexArray(mVAOID); @@ -145,7 +145,7 @@ void FGLRenderer::Initialize(int width, int height) mVBO = new FFlatVertexBuffer(width, height); mSkyVBO = new FSkyVertexBuffer; - if (gl.lightmethod != LM_SOFTWARE) mLights = new FLightBuffer(); + if (!gl.legacyMode) mLights = new FLightBuffer(); else mLights = NULL; gl_RenderState.SetVertexBuffer(mVBO); mFBID = 0; diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 7fda92428..caf276d37 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -314,7 +314,7 @@ void FRenderState::Apply() else mVertexBuffer->BindVBO(); mCurrentVertexBuffer = mVertexBuffer; } - if (gl.glslversion > 0) + if (!gl.legacyMode) { ApplyShader(); } @@ -351,7 +351,7 @@ void FRenderState::ApplyMatrices() void FRenderState::ApplyLightIndex(int index) { - if (gl.lightmethod != LM_SOFTWARE) + if (!gl.legacyMode) { if (index > -1 && GLRenderer->mLights->GetBufferType() == GL_UNIFORM_BUFFER) { diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 3e0729bbe..6acf44026 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -113,7 +113,7 @@ public: // Without shaders this translation must be applied to any texture. if (alphatexture) { - if (mat->tex->UseBasePalette() || gl.glslversion == 0) translation = TRANSLATION(TRANSLATION_Standard, 8); + if (mat->tex->UseBasePalette() || gl.legacyMode) translation = TRANSLATION(TRANSLATION_Standard, 8); } mEffectState = overrideshader >= 0? overrideshader : mat->mShaderIndex; mShaderTimer = mat->tex->gl_info.shaderspeed; diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index d5ed62755..c34d79816 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -322,7 +322,7 @@ void GLDrawList::SortWallIntoPlane(SortNode * head,SortNode * sort) AddWall(&w); // Splitting is done in the shader with clip planes, if available - if (gl.glslversion < 1.3f) + if (gl.flags & RFL_NO_CLIP_PLANES) { GLWall * ws1; ws->vertcount = 0; // invalidate current vertices. @@ -382,7 +382,7 @@ void GLDrawList::SortSpriteIntoPlane(SortNode * head,SortNode * sort) AddSprite(&s); // add a copy to avoid reallocation issues. // Splitting is done in the shader with clip planes, if available - if (gl.glslversion < 1.3f) + if (gl.flags & RFL_NO_CLIP_PLANES) { GLSprite * ss1; ss1=&sprites[sprites.Size()-1]; @@ -480,6 +480,11 @@ void GLDrawList::SortWallIntoWall(SortNode * head,SortNode * sort) ws1->ztop[0]=ws->ztop[1]=izt; ws1->zbottom[0]=ws->zbottom[1]=izb; ws1->tcs[GLWall::LOLFT].u = ws1->tcs[GLWall::UPLFT].u = ws->tcs[GLWall::LORGT].u = ws->tcs[GLWall::UPRGT].u = iu; + if (gl.buffermethod == BM_DEFERRED) + { + ws->MakeVertices(false); + ws1->MakeVertices(false); + } SortNode * sort2=SortNodes.GetNew(); memset(sort2,0,sizeof(SortNode)); @@ -806,17 +811,19 @@ void GLDrawList::DrawSorted() if (!sorted) { + GLRenderer->mVBO->Map(); MakeSortList(); sorted=DoSort(SortNodes[SortNodeStart]); + GLRenderer->mVBO->Unmap(); } gl_RenderState.ClearClipSplit(); - if (gl.glslversion >= 1.3f) + if (!(gl.flags & RFL_NO_CLIP_PLANES)) { glEnable(GL_CLIP_DISTANCE1); glEnable(GL_CLIP_DISTANCE2); } DoDrawSorted(sorted); - if (gl.glslversion >= 1.3f) + if (!(gl.flags & RFL_NO_CLIP_PLANES)) { glDisable(GL_CLIP_DISTANCE1); glDisable(GL_CLIP_DISTANCE2); @@ -995,7 +1002,7 @@ static FDrawInfoList di_list; FDrawInfo::FDrawInfo() { next = NULL; - if (gl.lightmethod == LM_SOFTWARE) + if (gl.legacyMode) { dldrawlists = new GLDrawList[GLLDL_TYPES]; } diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index 124440eee..0e7296ee3 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -30,11 +30,9 @@ enum DLDrawListType { // These are organized so that the various multipass rendering modes have to be set as few times as possible GLLDL_WALLS_PLAIN, // dynamic lights on normal walls - GLLDL_WALLS_BRIGHT, // dynamic lights on brightmapped walls GLLDL_WALLS_MASKED, // dynamic lights on masked midtextures GLLDL_FLATS_PLAIN, // dynamic lights on normal flats - GLLDL_FLATS_BRIGHT, // dynamic lights on brightmapped flats GLLDL_FLATS_MASKED, // dynamic lights on masked flats GLLDL_WALLS_FOG, // lights on fogged walls diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 8b665648e..1a3fe994b 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -430,7 +430,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG { gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); gl_SetPlaneTextureRotation(&plane, gltexture); - DrawSubsectors(pass, gl.lightmethod != LM_SOFTWARE, true); + DrawSubsectors(pass, !gl.legacyMode, true); gl_RenderState.EnableTextureMatrix(false); } if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -468,7 +468,7 @@ inline void GLFlat::PutFlat(bool fog) { Colormap.Clear(); } - if (gl.lightmethod == LM_SOFTWARE) + if (gl.legacyMode) { if (PutFlatCompat(fog)) return; } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index c2812db0f..7d634054a 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -409,7 +409,7 @@ void FGLRenderer::RenderScene(int recursion) // this is the only geometry type on which decals can possibly appear gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawDecals(); - if (gl.lightmethod == LM_SOFTWARE) + if (gl.legacyMode) { // also process the render lists with walls and dynamic lights gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawDecals(); @@ -681,7 +681,7 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) gl_RenderState.SetSoftLightLevel(-1); DrawTargeterSprites(); DrawBlend(viewsector); - if (gl.glslversion == 0.0) + if (gl.legacyMode) { gl_RenderState.SetFixedColormap(cm); gl_RenderState.DrawColormapOverlay(); @@ -846,9 +846,9 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo ProcessScene(toscreen); if (mainview && toscreen) EndDrawScene(retval); // do not call this for camera textures. - if (mainview) + if (mainview && FGLRenderBuffers::IsEnabled()) { - if (FGLRenderBuffers::IsEnabled()) mBuffers->BlitSceneToTexture(); + mBuffers->BlitSceneToTexture(); BloomScene(); TonemapScene(); LensDistortScene(); @@ -896,7 +896,7 @@ void FGLRenderer::RenderView (player_t* player) P_FindParticleSubsectors (); - if (gl.lightmethod != LM_SOFTWARE) GLRenderer->mLights->Clear(); + if (!gl.legacyMode) GLRenderer->mLights->Clear(); // NoInterpolateView should have no bearing on camera textures, but needs to be preserved for the main view below. bool saved_niv = NoInterpolateView; @@ -951,7 +951,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei SetFixedColormap(player); gl_RenderState.SetVertexBuffer(mVBO); GLRenderer->mVBO->Reset(); - if (gl.lightmethod != LM_SOFTWARE) GLRenderer->mLights->Clear(); + if (!gl.legacyMode) GLRenderer->mLights->Clear(); // Check if there's some lights. If not some code can be skipped. TThinkerIterator it(STAT_DLIGHT); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 2b6843bdf..97c5cb458 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -87,7 +87,7 @@ FSkyVertexBuffer::~FSkyVertexBuffer() void FSkyVertexBuffer::BindVBO() { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - if (gl.glslversion > 0) + if (!gl.legacyMode) { glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->x); glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->u); @@ -321,7 +321,7 @@ void FSkyVertexBuffer::RenderDome(FMaterial *tex, int mode) RenderRow(GL_TRIANGLE_FAN, rc); gl_RenderState.EnableTexture(true); // The color array can only be activated now if this is drawn without shader - if (gl.glslversion == 0) + if (gl.legacyMode) { glEnableClientState(GL_COLOR_ARRAY); } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 0c5b2581a..8a8c89c80 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -870,7 +870,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) RenderStyle.CheckFuzz(); if (RenderStyle.BlendOp == STYLEOP_Fuzz) { - if (gl_fuzztype != 0 && gl.glslversion > 0) + if (gl_fuzztype != 0 && !gl.legacyMode) { // Todo: implement shader selection here RenderStyle = LegacyRenderStyles[STYLE_Translucent]; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 5b2271433..f8bb2a876 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -140,7 +140,7 @@ void GLWall::PutWall(bool translucent) } else { - if (gl.lightmethod == LM_SOFTWARE && !translucent) + if (gl.legacyMode && !translucent) { if (PutWallCompat(passflag[type])) return; } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 585ced1a8..40145abc4 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -216,9 +216,8 @@ void GLWall::RenderWall(int textured) } else if (vertcount == 0) { - // in case we get here without valid vertex data and no ability to create them now, - // use the quad drawer as fallback (without edge splitting.) - // This can only happen in one special situation, when a translucent line got split during sorting. + // This should never happen but in case it actually does, use the quad drawer as fallback (without edge splitting.) + // This way it at least gets drawn. FQuadDrawer qd; qd.Set(0, glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v); qd.Set(1, glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v); @@ -242,7 +241,7 @@ void GLWall::RenderFogBoundary() { if (gl_fogmode && gl_fixedcolormap == 0) { - if (gl.glslversion > 0.f) + if (!gl.legacyMode) { int rel = rellight + getExtraLight(); gl_SetFog(lightlevel, rel, &Colormap, false); @@ -276,7 +275,7 @@ void GLWall::RenderMirrorSurface() Vector v(glseg.y2-glseg.y1, 0 ,-glseg.x2+glseg.x1); v.Normalize(); - if (gl.glslversion >= 0.f) + if (!gl.legacyMode) { // we use texture coordinates and texture matrix to pass the normal stuff to the shader so that the default vertex buffer format can be used as is. tcs[LOLFT].u = tcs[LORGT].u = tcs[UPLFT].u = tcs[UPRGT].u = v.X(); diff --git a/src/gl/shaders/gl_blurshader.cpp b/src/gl/shaders/gl_blurshader.cpp index 6154c17ce..bf2e29c7e 100644 --- a/src/gl/shaders/gl_blurshader.cpp +++ b/src/gl/shaders/gl_blurshader.cpp @@ -87,20 +87,6 @@ void FBlurShader::Blur(FGLRenderer *renderer, float blurAmount, int sampleCount, else setup->HorizontalShader->Bind(); - if (gl.glslversion < 1.3) - { - if (vertical) - { - setup->VerticalScaleX.Set(1.0f / width); - setup->VerticalScaleY.Set(1.0f / height); - } - else - { - setup->HorizontalScaleX.Set(1.0f / width); - setup->HorizontalScaleY.Set(1.0f / height); - } - } - glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, inputTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -156,14 +142,6 @@ FBlurShader::BlurSetup *FBlurShader::GetSetup(float blurAmount, int sampleCount) blurSetup.HorizontalShader->Bind(); glUniform1i(glGetUniformLocation(*blurSetup.HorizontalShader.get(), "SourceTexture"), 0); - if (gl.glslversion < 1.3) - { - blurSetup.VerticalScaleX.Init(*blurSetup.VerticalShader.get(), "ScaleX"); - blurSetup.VerticalScaleY.Init(*blurSetup.VerticalShader.get(), "ScaleY"); - blurSetup.HorizontalScaleX.Init(*blurSetup.HorizontalShader.get(), "ScaleX"); - blurSetup.HorizontalScaleY.Init(*blurSetup.HorizontalShader.get(), "ScaleY"); - } - mBlurSetups.Push(blurSetup); return &mBlurSetups[mBlurSetups.Size() - 1]; diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 8ac2b7093..3c574bd62 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -91,40 +91,27 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * // FString vp_comb; - if (gl.lightmethod == LM_SOFTWARE) + assert(GLRenderer->mLights != NULL); + // On the shader side there is no difference between LM_DEFERRED and LM_DIRECT, it only decides how the buffer is initialized. + unsigned int lightbuffertype = GLRenderer->mLights->GetBufferType(); + unsigned int lightbuffersize = GLRenderer->mLights->GetBlockSize(); + if (lightbuffertype == GL_UNIFORM_BUFFER) { - if (gl.glslversion >= 1.3) + // This differentiation is for some Intel drivers which fail on #extension, so use of #version 140 is necessary + if (gl.glslversion < 1.4f) { - vp_comb = "#version 130\n"; + vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); } else { - vp_comb = "#define GLSL12_COMPATIBLE\n"; + vp_comb.Format("#version 140\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); } } else { - assert(GLRenderer->mLights != NULL); - // On the shader side there is no difference between LM_DEFERRED and LM_DIRECT, it only matters which buffer type is used by the light buffer. - unsigned int lightbuffertype = GLRenderer->mLights->GetBufferType(); - unsigned int lightbuffersize = GLRenderer->mLights->GetBlockSize(); - if (lightbuffertype == GL_UNIFORM_BUFFER) - { - // This differentiation is for some Intel drivers which fail on #extension, so use of #version 140 is necessary - if (gl.glslversion < 1.4f || gl.version < 3.1f) - { - vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); - } - else - { - vp_comb.Format("#version 140\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); - } - } - else - { - vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n"; - } + vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n"; } + if (gl.buffermethod == BM_DEFERRED) { vp_comb << "#define USE_QUAD_DRAWER\n"; @@ -169,12 +156,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * } } - if (gl.glslversion < 1.3) - { - FShaderProgram::PatchVertShader(vp_comb); - FShaderProgram::PatchFragShader(fp_comb); - } - else if (gl.flags & RFL_NO_CLIP_PLANES) + if (gl.flags & RFL_NO_CLIP_PLANES) { // On ATI's GL3 drivers we have to disable gl_ClipDistance because it's hopelessly broken. // This will cause some glitches and regressions but is the only way to avoid total display garbage. @@ -273,7 +255,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * texcoordmatrix_index = glGetUniformLocation(hShader, "uQuadTexCoords"); quadmode_index = glGetUniformLocation(hShader, "uQuadMode"); - if (LM_SOFTWARE != gl.lightmethod && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + if (!gl.legacyMode && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) { int tempindex = glGetUniformBlockIndex(hShader, "LightBufferUBO"); if (tempindex != -1) glUniformBlockBinding(hShader, tempindex, LIGHTBUF_BINDINGPOINT); @@ -424,7 +406,7 @@ static const FEffectShader effectshaders[]= FShaderManager::FShaderManager() { - if (gl.glslversion > 0) CompileShaders(); + if (!gl.legacyMode) CompileShaders(); } //========================================================================== @@ -435,7 +417,7 @@ FShaderManager::FShaderManager() FShaderManager::~FShaderManager() { - if (gl.glslversion > 0) Clean(); + if (!gl.legacyMode) Clean(); } //========================================================================== @@ -577,7 +559,7 @@ EXTERN_CVAR(Int, gl_fuzztype) void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view) { - if (gl.glslversion == 0) + if (gl.legacyMode) { glMatrixMode(GL_PROJECTION); glLoadMatrixf(proj->get()); diff --git a/src/gl/shaders/gl_shaderprogram.cpp b/src/gl/shaders/gl_shaderprogram.cpp index 959315a9d..80a7ea99e 100644 --- a/src/gl/shaders/gl_shaderprogram.cpp +++ b/src/gl/shaders/gl_shaderprogram.cpp @@ -240,24 +240,13 @@ FString FShaderProgram::PatchShader(ShaderType type, const FString &code, const if (defines) patchedCode << defines; - if (gl.glslversion >= 1.3) - { - // these settings are actually pointless but there seem to be some old ATI drivers that fail to compile the shader without setting the precision here. - patchedCode << "precision highp int;\n"; - patchedCode << "precision highp float;\n"; - } + // these settings are actually pointless but there seem to be some old ATI drivers that fail to compile the shader without setting the precision here. + patchedCode << "precision highp int;\n"; + patchedCode << "precision highp float;\n"; patchedCode << "#line 1\n"; patchedCode << code; - if (gl.glslversion < 1.3) - { - if (type == Vertex) - PatchVertShader(patchedCode); - else if (type == Fragment) - PatchFragShader(patchedCode); - } - return patchedCode; } @@ -268,36 +257,3 @@ FString FShaderProgram::PatchShader(ShaderType type, const FString &code, const // //========================================================================== -void FShaderProgram::PatchCommon(FString &code) -{ - code.Substitute("precision highp int;", ""); - code.Substitute("precision highp float;", ""); -} - -void FShaderProgram::PatchVertShader(FString &code) -{ - PatchCommon(code); - code.Substitute("in vec", "attribute vec"); - code.Substitute("in float", "attribute float"); - code.Substitute("out vec", "varying vec"); - code.Substitute("out float", "varying float"); - code.Substitute("gl_ClipDistance", "//"); -} - -void FShaderProgram::PatchFragShader(FString &code) -{ - PatchCommon(code); - code.Substitute("out vec4 FragColor;", ""); - code.Substitute("FragColor", "gl_FragColor"); - code.Substitute("in vec", "varying vec"); - // this patches the switch statement to if's. - code.Substitute("break;", ""); - code.Substitute("switch (uFixedColormap)", "int i = uFixedColormap;"); - code.Substitute("case 0:", "if (i == 0)"); - code.Substitute("case 1:", "else if (i == 1)"); - code.Substitute("case 2:", "else if (i == 2)"); - code.Substitute("case 3:", "else if (i == 3)"); - code.Substitute("case 4:", "else if (i == 4)"); - code.Substitute("case 5:", "else if (i == 5)"); - code.Substitute("texture(", "texture2D("); -} diff --git a/src/gl/shaders/gl_shaderprogram.h b/src/gl/shaders/gl_shaderprogram.h index 64a36db49..aabfb1f6f 100644 --- a/src/gl/shaders/gl_shaderprogram.h +++ b/src/gl/shaders/gl_shaderprogram.h @@ -26,16 +26,11 @@ public: operator GLuint() const { return mProgram; } explicit operator bool() const { return mProgram != 0; } - // Needed by FShader - static void PatchVertShader(FString &code); - static void PatchFragShader(FString &code); - private: FShaderProgram(const FShaderProgram &) = delete; FShaderProgram &operator=(const FShaderProgram &) = delete; static FString PatchShader(ShaderType type, const FString &code, const char *defines, int maxGlslVersion); - static void PatchCommon(FString &code); void CreateShader(ShaderType type); FString GetShaderInfoLog(GLuint handle); diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index ec77cfd14..158d7f333 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -162,7 +162,7 @@ void OpenGLFrameBuffer::InitializeState() glEnable(GL_BLEND); glEnable(GL_DEPTH_CLAMP); glDisable(GL_DEPTH_TEST); - if (gl.glslversion == 0) glEnable(GL_TEXTURE_2D); + if (gl.legacyMode) glEnable(GL_TEXTURE_2D); glDisable(GL_LINE_SMOOTH); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index c54d96448..9185b63dc 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -154,10 +154,10 @@ void gl_LoadExtensions() else Printf("Emulating OpenGL v %s\n", version); } - gl.version = strtod(version, NULL) + 0.01f; + float gl_version = (float)strtod(version, NULL) + 0.01f; - // Don't even start if it's lower than 2.0 or no framebuffers are available - if ((gl.version < 2.0 || !CheckExtension("GL_EXT_framebuffer_object")) && gl.version < 3.0) + // Don't even start if it's lower than 2.0 or no framebuffers are available (The framebuffer extension is needed for glGenerateMipmapsEXT!) + if ((gl_version < 2.0f || !CheckExtension("GL_EXT_framebuffer_object")) && gl_version < 3.0f) { I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 2.0 with framebuffer support is required to run " GAMENAME ".\n"); } @@ -166,105 +166,86 @@ void gl_LoadExtensions() gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL) + 0.01f; gl.vendorstring = (char*)glGetString(GL_VENDOR); - gl.lightmethod = LM_SOFTWARE; - gl.buffermethod = BM_CLIENTARRAY; - if ((gl.version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) && !Args->CheckParm("-nosampler")) + // first test for optional features + if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION; + if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags |= RFL_TEXTURE_COMPRESSION_S3TC; + + if ((gl_version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) && !Args->CheckParm("-nosampler")) { gl.flags |= RFL_SAMPLER_OBJECTS; } - // Buffer lighting is only feasible with GLSL 1.3 and higher, even if 1.2 supports the extension. - if (gl.version > 3.0f && (gl.version >= 3.3f || CheckExtension("GL_ARB_uniform_buffer_object"))) + // The minimum requirement for the modern render path are GL 3.0 + uniform buffers + if (gl_version < 3.0f || (gl_version < 3.1f && !CheckExtension("GL_ARB_uniform_buffer_object"))) { - gl.lightmethod = LM_DEFERRED; - gl.buffermethod = BM_DEFERRED; - } - - if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION; - if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags |= RFL_TEXTURE_COMPRESSION_S3TC; - - if (Args->CheckParm("-noshader")/* || gl.glslversion < 1.2f*/) - { - gl.version = 2.11f; + gl.legacyMode = true; + gl.lightmethod = LM_LEGACY; + gl.buffermethod = BM_LEGACY; gl.glslversion = 0; - gl.lightmethod = LM_SOFTWARE; gl.flags |= RFL_NO_CLIP_PLANES; } - else if (gl.version < 3.0f) - { - if (CheckExtension("GL_NV_GPU_shader4") || CheckExtension("GL_EXT_GPU_shader4")) gl.glslversion = 1.21f; // for pre-3.0 drivers that support capable hardware. Needed for Apple. - else - { - gl.buffermethod = BM_CLIENTARRAY; - gl.glslversion = 0; - } - - if (!CheckExtension("GL_EXT_packed_float")) gl.flags |= RFL_NO_RGBA16F; - if (!CheckExtension("GL_EXT_packed_depth_stencil")) gl.flags |= RFL_NO_DEPTHSTENCIL; - gl.flags |= RFL_NO_CLIP_PLANES; - } - else if (gl.version < 4.f) - { -#ifdef _WIN32 - if (strstr(gl.vendorstring, "ATI Tech")) - { - gl.flags |= RFL_NO_CLIP_PLANES; // gl_ClipDistance is horribly broken on ATI GL3 drivers for Windows. - } -#endif - } - else if (gl.version < 4.5f) - { - // don't use GL 4.x features when running in GL 3 emulation mode. - if (CheckExtension("GL_ARB_buffer_storage")) - { - // work around a problem with older AMD drivers: Their implementation of shader storage buffer objects is piss-poor and does not match uniform buffers even closely. - // Recent drivers, GL 4.4 don't have this problem, these can easily be recognized by also supporting the GL_ARB_buffer_storage extension. - if (CheckExtension("GL_ARB_shader_storage_buffer_object")) - { - // Shader storage buffer objects are broken on current Intel drivers. - if (strstr(gl.vendorstring, "Intel") == NULL) - { - gl.flags |= RFL_SHADER_STORAGE_BUFFER; - } - } - gl.flags |= RFL_BUFFER_STORAGE; - gl.lightmethod = LM_DIRECT; - gl.buffermethod = BM_PERSISTENT; - } - else - { - gl.version = 3.3f; - } - } else { - // Assume that everything works without problems on GL 4.5 drivers where these things are core features. - gl.flags |= RFL_SHADER_STORAGE_BUFFER | RFL_BUFFER_STORAGE; - gl.lightmethod = LM_DIRECT; - gl.buffermethod = BM_PERSISTENT; - } + gl.legacyMode = false; + gl.lightmethod = LM_DEFERRED; + gl.buffermethod = BM_DEFERRED; + if (gl_version < 4.f) + { +#ifdef _WIN32 + if (strstr(gl.vendorstring, "ATI Tech")) + { + gl.flags |= RFL_NO_CLIP_PLANES; // gl_ClipDistance is horribly broken on ATI GL3 drivers for Windows. + } +#endif + } + else if (gl_version < 4.5f) + { + // don't use GL 4.x features when running a GL 3.x context. + if (CheckExtension("GL_ARB_buffer_storage")) + { + // work around a problem with older AMD drivers: Their implementation of shader storage buffer objects is piss-poor and does not match uniform buffers even closely. + // Recent drivers, GL 4.4 don't have this problem, these can easily be recognized by also supporting the GL_ARB_buffer_storage extension. + if (CheckExtension("GL_ARB_shader_storage_buffer_object")) + { + // Shader storage buffer objects are broken on current Intel drivers. + if (strstr(gl.vendorstring, "Intel") == NULL) + { + gl.flags |= RFL_SHADER_STORAGE_BUFFER; + } + } + gl.flags |= RFL_BUFFER_STORAGE; + gl.lightmethod = LM_DIRECT; + gl.buffermethod = BM_PERSISTENT; + } + } + else + { + // Assume that everything works without problems on GL 4.5 drivers where these things are core features. + gl.flags |= RFL_SHADER_STORAGE_BUFFER | RFL_BUFFER_STORAGE; + gl.lightmethod = LM_DIRECT; + gl.buffermethod = BM_PERSISTENT; + } - if (gl.version >= 4.3f || CheckExtension("GL_ARB_invalidate_subdata")) gl.flags |= RFL_INVALIDATE_BUFFER; - if (gl.version >= 4.3f || CheckExtension("GL_KHR_debug")) gl.flags |= RFL_DEBUG; + if (gl_version >= 4.3f || CheckExtension("GL_ARB_invalidate_subdata")) gl.flags |= RFL_INVALIDATE_BUFFER; + if (gl_version >= 4.3f || CheckExtension("GL_KHR_debug")) gl.flags |= RFL_DEBUG; - const char *lm = Args->CheckValue("-lightmethod"); - if (lm != NULL) - { - if (!stricmp(lm, "deferred") && gl.lightmethod == LM_DIRECT) gl.lightmethod = LM_DEFERRED; - if (!stricmp(lm, "textured")) gl.lightmethod = LM_SOFTWARE; - } + const char *lm = Args->CheckValue("-lightmethod"); + if (lm != NULL) + { + if (!stricmp(lm, "deferred") && gl.lightmethod == LM_DIRECT) gl.lightmethod = LM_DEFERRED; + } - lm = Args->CheckValue("-buffermethod"); - if (lm != NULL) - { - if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED; - if (!stricmp(lm, "clientarray")) gl.buffermethod = BM_CLIENTARRAY; + lm = Args->CheckValue("-buffermethod"); + if (lm != NULL) + { + if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED; + } } int v; - if (gl.lightmethod != LM_SOFTWARE && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + if (!gl.legacyMode && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) { glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); gl.maxuniforms = v; @@ -284,24 +265,27 @@ void gl_LoadExtensions() glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - // fudge a bit with the framebuffer stuff to avoid redundancies in the main code. Some of the older cards do not have the ARB stuff but the calls are nearly identical. - FUDGE_FUNC(glGenerateMipmap, EXT); - FUDGE_FUNC(glGenFramebuffers, EXT); - FUDGE_FUNC(glBindFramebuffer, EXT); - FUDGE_FUNC(glDeleteFramebuffers, EXT); - FUDGE_FUNC(glFramebufferTexture2D, EXT); - FUDGE_FUNC(glGenerateMipmap, EXT); - FUDGE_FUNC(glGenFramebuffers, EXT); - FUDGE_FUNC(glBindFramebuffer, EXT); - FUDGE_FUNC(glDeleteFramebuffers, EXT); - FUDGE_FUNC(glFramebufferTexture2D, EXT); - FUDGE_FUNC(glFramebufferRenderbuffer, EXT); - FUDGE_FUNC(glGenRenderbuffers, EXT); - FUDGE_FUNC(glDeleteRenderbuffers, EXT); - FUDGE_FUNC(glRenderbufferStorage, EXT); - FUDGE_FUNC(glBindRenderbuffer, EXT); - FUDGE_FUNC(glCheckFramebufferStatus, EXT); - gl_PatchMenu(); + if (gl.legacyMode) + { + // fudge a bit with the framebuffer stuff to avoid redundancies in the main code. Some of the older cards do not have the ARB stuff but the calls are nearly identical. + FUDGE_FUNC(glGenerateMipmap, EXT); + FUDGE_FUNC(glGenFramebuffers, EXT); + FUDGE_FUNC(glBindFramebuffer, EXT); + FUDGE_FUNC(glDeleteFramebuffers, EXT); + FUDGE_FUNC(glFramebufferTexture2D, EXT); + FUDGE_FUNC(glGenerateMipmap, EXT); + FUDGE_FUNC(glGenFramebuffers, EXT); + FUDGE_FUNC(glBindFramebuffer, EXT); + FUDGE_FUNC(glDeleteFramebuffers, EXT); + FUDGE_FUNC(glFramebufferTexture2D, EXT); + FUDGE_FUNC(glFramebufferRenderbuffer, EXT); + FUDGE_FUNC(glGenRenderbuffers, EXT); + FUDGE_FUNC(glDeleteRenderbuffers, EXT); + FUDGE_FUNC(glRenderbufferStorage, EXT); + FUDGE_FUNC(glBindRenderbuffer, EXT); + FUDGE_FUNC(glCheckFramebufferStatus, EXT); + gl_PatchMenu(); + } } //========================================================================== @@ -313,7 +297,7 @@ void gl_LoadExtensions() void gl_PrintStartupLog() { int v = 0; - if (gl.version >= 3.2) glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &v); + if (!gl.legacyMode) glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &v); Printf ("GL_VENDOR: %s\n", glGetString(GL_VENDOR)); Printf ("GL_RENDERER: %s\n", glGetString(GL_RENDERER)); @@ -332,7 +316,7 @@ void gl_PrintStartupLog() glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); Printf ("Max. varying: %d\n", v); - if (gl.lightmethod != LM_SOFTWARE && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + if (!gl.legacyMode && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) { glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); Printf ("Max. uniform block size: %d\n", v); @@ -349,7 +333,7 @@ void gl_PrintStartupLog() } // For shader-less, the special alphatexture translation must be changed to actually set the alpha, because it won't get translated by a shader. - if (gl.glslversion == 0) + if (gl.legacyMode) { FRemapTable *remap = translationtables[TRANSLATION_Standard][8]; for (int i = 0; i < 256; i++) diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 8300b9973..edaec58c0 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -21,12 +21,10 @@ enum RenderFlags RFL_BUFFER_STORAGE = 8, RFL_SAMPLER_OBJECTS = 16, - RFL_NO_RGBA16F = 32, - RFL_NO_DEPTHSTENCIL = 64, - RFL_NO_CLIP_PLANES = 128, + RFL_NO_CLIP_PLANES = 32, - RFL_INVALIDATE_BUFFER = 256, - RFL_DEBUG = 512 + RFL_INVALIDATE_BUFFER = 64, + RFL_DEBUG = 128 }; enum TexMode @@ -43,15 +41,15 @@ enum TexMode enum ELightMethod { - LM_SOFTWARE = 0, // multi-pass texturing + LM_LEGACY = 0, // placeholder for legacy mode (textured lights), should not be checked anywhere in the code! LM_DEFERRED = 1, // calculate lights up front in a separate pass LM_DIRECT = 2, // calculate lights on the fly along with the render data }; enum EBufferMethod { - BM_CLIENTARRAY = 0, // use a client array instead of a hardware buffer - BM_DEFERRED = 1, // use a temporarily mapped buffer (only necessary on GL 3.x core profile, i.e. Apple) + BM_LEGACY = 0, // placeholder for legacy mode (client arrays), should not be checked anywhere in the code! + BM_DEFERRED = 1, // use a temporarily mapped buffer, for GL 3.x core profile BM_PERSISTENT = 2 // use a persistently mapped buffer }; @@ -64,10 +62,10 @@ struct RenderContext unsigned int uniformblockalignment; int lightmethod; int buffermethod; - float version; float glslversion; int max_texturesize; char * vendorstring; + bool legacyMode; int MaxLights() const { diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 785f3c6e9..0af793e58 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -264,7 +264,7 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u return inputBuffer; // [BB] Don't upsample non-shader handled warped textures. Needs too much memory and time - if (gl.glslversion == 0 && inputTexture->bWarped) + if (gl.legacyMode && inputTexture->bWarped) return inputBuffer; // already scaled? diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 6ba1fe4b0..bc9dc2f52 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -296,7 +296,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla if (translation <= 0) translation = -translation; else { - alphatrans = (gl.glslversion == 0 && translation == TRANSLATION(TRANSLATION_Standard, 8)); + alphatrans = (gl.legacyMode && translation == TRANSLATION(TRANSLATION_Standard, 8)); translation = GLTranslationPalette::GetInternalTranslation(translation); } @@ -307,7 +307,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla if (hwtex) { // Texture has become invalid - if ((!tex->bHasCanvas && (!tex->bWarped || gl.glslversion == 0)) && tex->CheckModified()) + if ((!tex->bHasCanvas && (!tex->bWarped || gl.legacyMode)) && tex->CheckModified()) { Clean(true); hwtex = CreateHwTexture(); @@ -325,7 +325,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla if (!tex->bHasCanvas) { buffer = CreateTexBuffer(translation, w, h, hirescheck, true, alphatrans); - if (tex->bWarped && gl.glslversion == 0 && w*h <= 256*256) // do not software-warp larger textures, especially on the old systems that still need this fallback. + if (tex->bWarped && gl.legacyMode && w*h <= 256*256) // do not software-warp larger textures, especially on the old systems that still need this fallback. { // need to do software warping FWarpTexture *wt = static_cast(tex); @@ -489,7 +489,7 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) mSpriteU[0] = mSpriteV[0] = 0.f; mSpriteU[1] = mSpriteV[1] = 1.f; - FTexture *basetex = (tx->bWarped && gl.glslversion == 0)? tx : tx->GetRedirect(false); + FTexture *basetex = (tx->bWarped && gl.legacyMode)? tx : tx->GetRedirect(false); // allow the redirect only if the textute is not expanded or the scale matches. if (!expanded || (tx->Scale.X == basetex->Scale.X && tx->Scale.Y == basetex->Scale.Y)) { diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index b10c99a17..95ac874b7 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -51,32 +51,6 @@ vec4 desaturate(vec4 texel) // //=========================================================================== -#ifdef GLSL12_COMPATIBLE -vec4 getTexel(vec2 st) -{ - vec4 texel = texture(tex, st); - - // - // Apply texture modes - // - if (uTextureMode != 0) - { - if (uTextureMode == 1) texel.rgb = vec3(1.0,1.0,1.0); - else if (uTextureMode == 2) texel.a = 1.0; - else if (uTextureMode == 3) texel = vec4(1.0-texel.r, 1.0-texel.b, 1.0-texel.g, texel.a); - else if (uTextureMode == 4) texel = vec4(1.0, 1.0, 1.0, texel.r*texel.a); - else if (uTextureMode == 5) - { - if (st.t < 0.0 || st.t > 1.0) - { - texel.a = 0.0; - } - } - } - texel *= uObjectColor; - return desaturate(texel); -} -#else vec4 getTexel(vec2 st) { vec4 texel = texture(tex, st); @@ -113,7 +87,6 @@ vec4 getTexel(vec2 st) return desaturate(texel); } -#endif //=========================================================================== // diff --git a/wadsrc/static/shaders/glsl/tonemap.fp b/wadsrc/static/shaders/glsl/tonemap.fp index 5a84ca5a4..c33349a38 100644 --- a/wadsrc/static/shaders/glsl/tonemap.fp +++ b/wadsrc/static/shaders/glsl/tonemap.fp @@ -70,17 +70,10 @@ uniform sampler2D PaletteLUT; vec3 Tonemap(vec3 color) { ivec3 c = ivec3(clamp(color.rgb, vec3(0.0), vec3(1.0)) * 255.0 + 0.5); -#if __VERSION__ < 130 - int index = (c.r / 4 * 64 + c.g / 4) * 64 + c.b / 4; - float tx = mod(index, 512) / 512.0; - float ty = float(index / 512) / 512.0; - return texture2D(PaletteLUT, vec2(tx, ty)).rgb; -#else int index = ((c.r >> 2) * 64 + (c.g >> 2)) * 64 + (c.b >> 2); int tx = index % 512; int ty = index / 512; return texelFetch(PaletteLUT, ivec2(tx, ty), 0).rgb; -#endif } #else From 7efae2c8f8c5940d2bfb27047e6f87f1c1249088 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 1 Sep 2016 12:14:20 +0200 Subject: [PATCH 0870/1509] - fixed: When requesting GL version 2.x, do not try to create a core profile context, because that can not support legacy features. --- src/win32/win32gliface.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 494d94233..7ca001e1e 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -748,11 +748,9 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) } int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; - const char *lm = Args->CheckValue("-buffermethod"); - if (lm != NULL) - { - if (!stricmp(lm, "clientarray")) prof = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; - } + const char *version = Args->CheckValue("-glversion"); + + if (version != nullptr && strcmp(version, "3.0") < 0) prof = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; for (; prof <= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; prof++) { From 589936f570b43a75df8c44892e1fdd917956e915 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 1 Sep 2016 17:14:51 +0200 Subject: [PATCH 0871/1509] - draw the colormap blend after postprocessing, not before it. - added colormap shader to postprocessing. This replaces the in-place application of fullscreen colormaps if renderbuffers are active. This way the fully composed scene gets inverted, not each element on its own which is highly problematic for additively blended things. --- src/CMakeLists.txt | 1 + src/gl/compatibility/gl_20.cpp | 57 +++++++++++----------- src/gl/renderer/gl_lightdata.cpp | 2 +- src/gl/renderer/gl_postprocess.cpp | 33 +++++++++++++ src/gl/renderer/gl_renderbuffers.cpp | 9 +++- src/gl/renderer/gl_renderer.cpp | 26 +++++++--- src/gl/renderer/gl_renderer.h | 3 ++ src/gl/renderer/gl_renderstate.cpp | 24 ++++++--- src/gl/scene/gl_scene.cpp | 19 +++++--- src/gl/shaders/gl_colormapshader.cpp | 67 ++++++++++++++++++++++++++ src/gl/shaders/gl_colormapshader.h | 20 ++++++++ wadsrc/static/shaders/glsl/colormap.fp | 16 ++++++ 12 files changed, 224 insertions(+), 53 deletions(-) create mode 100644 src/gl/shaders/gl_colormapshader.cpp create mode 100644 src/gl/shaders/gl_colormapshader.h create mode 100644 wadsrc/static/shaders/glsl/colormap.fp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 03f3372f0..dfac22fe0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1114,6 +1114,7 @@ set( FASTMATH_SOURCES gl/shaders/gl_presentshader.cpp gl/shaders/gl_bloomshader.cpp gl/shaders/gl_blurshader.cpp + gl/shaders/gl_colormapshader.cpp gl/shaders/gl_tonemapshader.cpp gl/shaders/gl_lensshader.cpp gl/system/gl_interface.cpp diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 97abc0d82..fdda99130 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -66,42 +66,39 @@ void gl_PatchMenu() { - if (gl.legacyMode) + // Radial fog and Doom lighting are not available without full shader support. + + FOptionValues **opt = OptionValues.CheckKey("LightingModes"); + if (opt != NULL) { - // Radial fog and Doom lighting are not available without full shader support. - - FOptionValues **opt = OptionValues.CheckKey("LightingModes"); - if (opt != NULL) + for(int i = (*opt)->mValues.Size()-1; i>=0; i--) { - for(int i = (*opt)->mValues.Size()-1; i>=0; i--) + // Delete 'Doom' lighting mode + if ((*opt)->mValues[i].Value == 2.0 || (*opt)->mValues[i].Value == 8.0) { - // Delete 'Doom' lighting mode - if ((*opt)->mValues[i].Value == 2.0 || (*opt)->mValues[i].Value == 8.0) - { - (*opt)->mValues.Delete(i); - } + (*opt)->mValues.Delete(i); } } - - opt = OptionValues.CheckKey("FogMode"); - if (opt != NULL) - { - for(int i = (*opt)->mValues.Size()-1; i>=0; i--) - { - // Delete 'Radial' fog mode - if ((*opt)->mValues[i].Value == 2.0) - { - (*opt)->mValues.Delete(i); - } - } - } - - // disable features that don't work without shaders. - if (gl_lightmode == 2 || gl_lightmode == 8) gl_lightmode = 3; - if (gl_fogmode == 2) gl_fogmode = 1; - - // todo: remove more unsupported stuff like postprocessing options. } + + opt = OptionValues.CheckKey("FogMode"); + if (opt != NULL) + { + for(int i = (*opt)->mValues.Size()-1; i>=0; i--) + { + // Delete 'Radial' fog mode + if ((*opt)->mValues[i].Value == 2.0) + { + (*opt)->mValues.Delete(i); + } + } + } + + // disable features that don't work without shaders. + if (gl_lightmode == 2 || gl_lightmode == 8) gl_lightmode = 3; + if (gl_fogmode == 2) gl_fogmode = 1; + + // todo: remove more unsupported stuff like postprocessing options. } diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 5d153894f..c2329879c 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -71,7 +71,7 @@ CUSTOM_CVAR(Bool, gl_enhanced_nightvision, true, CVAR_ARCHIVE|CVAR_NOINITCALL) { // The fixed colormap state needs to be reset because if this happens when // a shader is set to CM_LITE or CM_TORCH it won't register the change in behavior caused by this CVAR. - if (GLRenderer != NULL && GLRenderer->mShaderManager != NULL) + if (GLRenderer != nullptr && GLRenderer->mShaderManager != nullptr) { GLRenderer->mShaderManager->ResetFixedColormap(); } diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 047153554..77ee5cd79 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -71,6 +71,7 @@ #include "gl/shaders/gl_bloomshader.h" #include "gl/shaders/gl_blurshader.h" #include "gl/shaders/gl_tonemapshader.h" +#include "gl/shaders/gl_colormapshader.h" #include "gl/shaders/gl_lensshader.h" #include "gl/shaders/gl_presentshader.h" #include "gl/renderer/gl_2ddrawer.h" @@ -284,6 +285,38 @@ void FGLRenderer::ClearTonemapPalette() mTonemapPalette = nullptr; } +//----------------------------------------------------------------------------- +// +// Colormap scene texture and place the result in the HUD/2D texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::ColormapScene() +{ + if (gl_fixedcolormap < CM_FIRSTSPECIALCOLORMAP || gl_fixedcolormap >= CM_MAXCOLORMAP) + return; + + FGLDebug::PushGroup("ColormapScene"); + + FGLPostProcessState savedState; + + mBuffers->BindNextFB(); + mBuffers->BindCurrentTexture(0); + mColormapShader->Bind(); + + FSpecialColormap *scm = &SpecialColormaps[gl_fixedcolormap - CM_FIRSTSPECIALCOLORMAP]; + float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0], + scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f }; + + mColormapShader->MapStart.Set(scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f); + mColormapShader->MapRange.Set(m); + + RenderScreenQuad(); + mBuffers->NextTexture(); + + FGLDebug::PopGroup(); +} + //----------------------------------------------------------------------------- // // Apply lens distortion and place the result in the HUD/2D texture diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index f8b5dfcdd..35be00abc 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -55,7 +55,14 @@ #include "doomerrors.h" CVAR(Int, gl_multisample, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); -CVAR(Bool, gl_renderbuffers, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +CUSTOM_CVAR(Bool, gl_renderbuffers, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + // this CVAR alters some fixed colormap related settings + if (GLRenderer != nullptr && GLRenderer->mShaderManager != nullptr) + { + //GLRenderer->mShaderManager->ResetFixedColormap(); + } +} //========================================================================== // diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 20126ba77..6cd38390f 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -67,6 +67,7 @@ #include "gl/shaders/gl_bloomshader.h" #include "gl/shaders/gl_blurshader.h" #include "gl/shaders/gl_tonemapshader.h" +#include "gl/shaders/gl_colormapshader.h" #include "gl/shaders/gl_lensshader.h" #include "gl/shaders/gl_presentshader.h" #include "gl/textures/gl_texture.h" @@ -97,21 +98,30 @@ CVAR(Bool, gl_scale_viewport, true, 0); FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) { framebuffer = fb; - mClipPortal = NULL; - mCurrentPortal = NULL; + mClipPortal = nullptr; + mCurrentPortal = nullptr; mMirrorCount = 0; mPlaneMirrorCount = 0; mLightCount = 0; mAngles = FRotator(0.f, 0.f, 0.f); mViewVector = FVector2(0,0); - mVBO = NULL; - mSkyVBO = NULL; + mVBO = nullptr; + mSkyVBO = nullptr; gl_spriteindex = 0; - mShaderManager = NULL; - gllight = glpart2 = glpart = mirrortexture = NULL; - mLights = NULL; + mShaderManager = nullptr; + gllight = glpart2 = glpart = mirrortexture = nullptr; + mLights = nullptr; m2DDrawer = nullptr; mTonemapPalette = nullptr; + mBuffers = nullptr; + mPresentShader = nullptr; + mBloomExtractShader = nullptr; + mBloomCombineShader = nullptr; + mBlurShader = nullptr; + mTonemapShader = nullptr; + mTonemapPalette = nullptr; + mColormapShader = nullptr; + mLensShader = nullptr; } void gl_LoadModels(); @@ -124,6 +134,7 @@ void FGLRenderer::Initialize(int width, int height) mBloomCombineShader = new FBloomCombineShader(); mBlurShader = new FBlurShader(); mTonemapShader = new FTonemapShader(); + mColormapShader = new FColormapShader(); mTonemapPalette = nullptr; mLensShader = new FLensShader(); mPresentShader = new FPresentShader(); @@ -184,6 +195,7 @@ FGLRenderer::~FGLRenderer() if (mBlurShader) delete mBlurShader; if (mTonemapShader) delete mTonemapShader; if (mTonemapPalette) delete mTonemapPalette; + if (mColormapShader) delete mColormapShader; if (mLensShader) delete mLensShader; } diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 4b663680f..120f6a449 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -23,6 +23,7 @@ class FBloomExtractShader; class FBloomCombineShader; class FBlurShader; class FTonemapShader; +class FColormapShader; class FLensShader; class FPresentShader; class F2DDrawer; @@ -93,6 +94,7 @@ public: FBloomCombineShader *mBloomCombineShader; FBlurShader *mBlurShader; FTonemapShader *mTonemapShader; + FColormapShader *mColormapShader; FHardwareTexture *mTonemapPalette; FLensShader *mLensShader; FPresentShader *mPresentShader; @@ -166,6 +168,7 @@ public: void EndDrawScene(sector_t * viewsector); void BloomScene(); void TonemapScene(); + void ColormapScene(); void BindTonemapPalette(int texunit); void ClearTonemapPalette(); void LensDistortScene(); diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index caf276d37..c3cc905e5 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -49,6 +49,7 @@ #include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_colormap.h" #include "gl/dynlights//gl_lightbuffer.h" +#include "gl/renderer/gl_renderbuffers.h" void gl_SetTextureMode(int type); @@ -220,15 +221,24 @@ bool FRenderState::ApplyShader() { activeShader->muFixedColormap.Set(0); } - else if (mColormapState < CM_MAXCOLORMAP) + else if (mColormapState > CM_DEFAULT && mColormapState < CM_MAXCOLORMAP) { - FSpecialColormap *scm = &SpecialColormaps[gl_fixedcolormap - CM_FIRSTSPECIALCOLORMAP]; - float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0], - scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f }; + if (FGLRenderBuffers::IsEnabled()) + { + // When using postprocessing to apply the colormap, we must render the image fullbright here. + activeShader->muFixedColormap.Set(2); + activeShader->muColormapStart.Set(1, 1, 1, 1.f); + } + else + { + FSpecialColormap *scm = &SpecialColormaps[gl_fixedcolormap - CM_FIRSTSPECIALCOLORMAP]; + float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0], + scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f }; - activeShader->muFixedColormap.Set(1); - activeShader->muColormapStart.Set(scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f); - activeShader->muColormapRange.Set(m); + activeShader->muFixedColormap.Set(1); + activeShader->muColormapStart.Set(scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f); + activeShader->muColormapRange.Set(m); + } } else if (mColormapState == CM_FOGLAYER) { diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 7d634054a..ab3fe744d 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -635,9 +635,9 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) V_AddBlend (player->BlendR, player->BlendG, player->BlendB, player->BlendA, blend); } + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if (blend[3]>0.0f) { - gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.SetColor(blend[0], blend[1], blend[2], blend[3]); gl_FillScreen(); } @@ -676,16 +676,19 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) { DrawPlayerSprites (viewsector, false); } - int cm = gl_RenderState.GetFixedColormap(); + if (gl.legacyMode) + { + int cm = gl_RenderState.GetFixedColormap(); + gl_RenderState.SetFixedColormap(cm); + gl_RenderState.DrawColormapOverlay(); + } + gl_RenderState.SetFixedColormap(CM_DEFAULT); gl_RenderState.SetSoftLightLevel(-1); DrawTargeterSprites(); - DrawBlend(viewsector); - if (gl.legacyMode) + if (FGLRenderBuffers::IsEnabled()) { - gl_RenderState.SetFixedColormap(cm); - gl_RenderState.DrawColormapOverlay(); - gl_RenderState.SetFixedColormap(CM_DEFAULT); + DrawBlend(viewsector); } // Restore standard rendering state @@ -851,7 +854,9 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo mBuffers->BlitSceneToTexture(); BloomScene(); TonemapScene(); + ColormapScene(); LensDistortScene(); + DrawBlend(viewsector); // This should be done after postprocessing, not before. } mDrawingScene2D = false; eye->TearDown(); diff --git a/src/gl/shaders/gl_colormapshader.cpp b/src/gl/shaders/gl_colormapshader.cpp new file mode 100644 index 000000000..f28003150 --- /dev/null +++ b/src/gl/shaders/gl_colormapshader.cpp @@ -0,0 +1,67 @@ +/* +** gl_colormapshader.cpp +** Applies a fullscreen colormap to the scene +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "gl/gl_functions.h" +#include "vectors.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_colormapshader.h" + +void FColormapShader::Bind() +{ + auto &shader = mShader; + if (!shader) + { + shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + shader.Compile(FShaderProgram::Fragment, "shaders/glsl/colormap.fp", "", 330); + shader.SetFragDataLocation(0, "FragColor"); + shader.Link("shaders/glsl/colormap"); + shader.SetAttribLocation(0, "PositionInProjection"); + MapStart.Init(shader, "uFixedColormapStart"); + MapRange.Init(shader, "uFixedColormapRange"); + } + shader.Bind(); +} + diff --git a/src/gl/shaders/gl_colormapshader.h b/src/gl/shaders/gl_colormapshader.h new file mode 100644 index 000000000..b20c23a4c --- /dev/null +++ b/src/gl/shaders/gl_colormapshader.h @@ -0,0 +1,20 @@ +#ifndef __GL_COLORMAPSHADER_H +#define __GL_COLORMAPSHADER_H + +#include "gl_shaderprogram.h" + +class FColormapShader +{ +public: + void Bind(); + + FBufferedUniformSampler SceneTexture; + FUniform4f MapStart; + FUniform4f MapRange; + +private: + + FShaderProgram mShader; +}; + +#endif \ No newline at end of file diff --git a/wadsrc/static/shaders/glsl/colormap.fp b/wadsrc/static/shaders/glsl/colormap.fp new file mode 100644 index 000000000..e86429c37 --- /dev/null +++ b/wadsrc/static/shaders/glsl/colormap.fp @@ -0,0 +1,16 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D tex; +uniform vec4 uFixedColormapStart; +uniform vec4 uFixedColormapRange; + +void main() +{ + vec4 frag = texture(tex, TexCoord); + float gray = (frag.r * 0.3 + frag.g * 0.56 + frag.b * 0.14); + vec4 cm = uFixedColormapStart + gray * uFixedColormapRange; + FragColor = vec4(clamp(cm.rgb, 0.0, 1.0), frag.a); +} + From 4e8027612ff40ec71d1717171dddb3dc253cb16c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 1 Sep 2016 17:38:17 +0200 Subject: [PATCH 0872/1509] - restored 2 lines of code that somehow got lost before the last commit. --- src/gl/scene/gl_scene.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index ab3fe744d..c1f022ab0 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -641,6 +641,8 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) gl_RenderState.SetColor(blend[0], blend[1], blend[2], blend[3]); gl_FillScreen(); } + gl_RenderState.ResetColor(); + gl_RenderState.EnableTexture(true); } From 98032bc73f7bbdd3a9f8254f42abd2e8aa717e5a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 2 Sep 2016 05:45:00 +0200 Subject: [PATCH 0873/1509] Change SSAO blur to be depth aware --- src/gl/renderer/gl_postprocess.cpp | 22 ++++-- src/gl/renderer/gl_renderbuffers.cpp | 6 +- src/gl/renderer/gl_renderer.cpp | 8 +++ src/gl/renderer/gl_renderer.h | 4 ++ src/gl/shaders/gl_ambientshader.cpp | 32 +++++++++ src/gl/shaders/gl_ambientshader.h | 25 +++++++ wadsrc/static/shaders/glsl/depthblur.fp | 81 +++++++++++++++++++++++ wadsrc/static/shaders/glsl/ssao.fp | 9 +-- wadsrc/static/shaders/glsl/ssaocombine.fp | 11 +++ 9 files changed, 184 insertions(+), 14 deletions(-) create mode 100644 wadsrc/static/shaders/glsl/depthblur.fp create mode 100644 wadsrc/static/shaders/glsl/ssaocombine.fp diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 684985074..edf1148ef 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -209,8 +209,22 @@ void FGLRenderer::AmbientOccludeScene() RenderScreenQuad(); // Blur SSAO texture - mBlurShader->BlurHorizontal(this, blurAmount, blurSampleCount, mBuffers->AmbientTexture1, mBuffers->AmbientFB0, mBuffers->AmbientWidth, mBuffers->AmbientHeight); - mBlurShader->BlurVertical(this, blurAmount, blurSampleCount, mBuffers->AmbientTexture0, mBuffers->AmbientFB1, mBuffers->AmbientWidth, mBuffers->AmbientHeight); + glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB0); + glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + mDepthBlurShader->Bind(false); + mDepthBlurShader->BlurSharpness[false].Set(blurAmount); + mDepthBlurShader->InvFullResolution[false].Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); + RenderScreenQuad(); + + glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB1); + glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture0); + mDepthBlurShader->Bind(true); + mDepthBlurShader->BlurSharpness[true].Set(blurAmount); + mDepthBlurShader->InvFullResolution[true].Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); + mDepthBlurShader->PowExponent[true].Set(1.8f); + RenderScreenQuad(); // Add SSAO back to scene texture: mBuffers->BindCurrentFB(); @@ -225,8 +239,8 @@ void FGLRenderer::AmbientOccludeScene() glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - mBloomCombineShader->Bind(); - mBloomCombineShader->BloomTexture.Set(0); + mSSAOCombineShader->Bind(); + mSSAOCombineShader->AODepthTexture.Set(0); RenderScreenQuad(); glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 93625722d..9eb7c6f39 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -313,8 +313,8 @@ void FGLRenderBuffers::CreateAmbientOcclusion(int width, int height) AmbientWidth = width / 2; AmbientHeight = height / 2; - AmbientTexture0 = Create2DTexture("AmbientTexture0", GL_RGBA32F, AmbientWidth, AmbientHeight); - AmbientTexture1 = Create2DTexture("AmbientTexture1", GL_RGBA32F, AmbientWidth, AmbientHeight); + AmbientTexture0 = Create2DTexture("AmbientTexture0", GL_RG32F, AmbientWidth, AmbientHeight); + AmbientTexture1 = Create2DTexture("AmbientTexture1", GL_RG32F, AmbientWidth, AmbientHeight); AmbientFB0 = CreateFrameBuffer("AmbientFB0", AmbientTexture0); AmbientFB1 = CreateFrameBuffer("AmbientFB1", AmbientTexture1); @@ -370,6 +370,8 @@ GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int case GL_RGBA16: dataformat = GL_RGBA; datatype = GL_UNSIGNED_SHORT; break; case GL_RGBA16F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; case GL_RGBA32F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; + case GL_R32F: dataformat = GL_RED; datatype = GL_FLOAT; break; + case GL_RG32F: dataformat = GL_RG; datatype = GL_FLOAT; break; case GL_DEPTH_COMPONENT24: dataformat = GL_DEPTH_COMPONENT; datatype = GL_FLOAT; break; case GL_STENCIL_INDEX8: dataformat = GL_STENCIL_INDEX; datatype = GL_INT; break; case GL_DEPTH24_STENCIL8: dataformat = GL_DEPTH_STENCIL; datatype = GL_UNSIGNED_INT_24_8; break; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 2d32f0d20..ed45ec0f3 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -123,6 +123,10 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mTonemapPalette = nullptr; mColormapShader = nullptr; mLensShader = nullptr; + mLinearDepthShader = nullptr; + mDepthBlurShader = nullptr; + mSSAOShader = nullptr; + mSSAOCombineShader = nullptr; } void gl_LoadModels(); @@ -132,7 +136,9 @@ void FGLRenderer::Initialize(int width, int height) { mBuffers = new FGLRenderBuffers(); mLinearDepthShader = new FLinearDepthShader(); + mDepthBlurShader = new FDepthBlurShader(); mSSAOShader = new FSSAOShader(); + mSSAOCombineShader = new FSSAOCombineShader(); mBloomExtractShader = new FBloomExtractShader(); mBloomCombineShader = new FBloomCombineShader(); mBlurShader = new FBlurShader(); @@ -194,7 +200,9 @@ FGLRenderer::~FGLRenderer() if (mBuffers) delete mBuffers; if (mPresentShader) delete mPresentShader; if (mLinearDepthShader) delete mLinearDepthShader; + if (mDepthBlurShader) delete mDepthBlurShader; if (mSSAOShader) delete mSSAOShader; + if (mSSAOCombineShader) delete mSSAOCombineShader; if (mBloomExtractShader) delete mBloomExtractShader; if (mBloomCombineShader) delete mBloomCombineShader; if (mBlurShader) delete mBlurShader; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index c487c4a77..8955acfd6 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -20,7 +20,9 @@ class FSamplerManager; class DPSprite; class FGLRenderBuffers; class FLinearDepthShader; +class FDepthBlurShader; class FSSAOShader; +class FSSAOCombineShader; class FBloomExtractShader; class FBloomCombineShader; class FBlurShader; @@ -94,6 +96,8 @@ public: FGLRenderBuffers *mBuffers; FLinearDepthShader *mLinearDepthShader; FSSAOShader *mSSAOShader; + FDepthBlurShader *mDepthBlurShader; + FSSAOCombineShader *mSSAOCombineShader; FBloomExtractShader *mBloomExtractShader; FBloomCombineShader *mBloomCombineShader; FBlurShader *mBlurShader; diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index 55682a91e..6b8c9cc48 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -96,3 +96,35 @@ void FSSAOShader::Bind() } mShader.Bind(); } + +void FDepthBlurShader::Bind(bool vertical) +{ + auto &shader = mShader[vertical]; + if (!shader) + { + shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + shader.Compile(FShaderProgram::Fragment, "shaders/glsl/depthblur.fp", vertical ? "#define BLUR_VERTICAL\n" : "#define BLUR_HORIZONTAL\n", 330); + shader.SetFragDataLocation(0, "FragColor"); + shader.Link("shaders/glsl/depthblur"); + shader.SetAttribLocation(0, "PositionInProjection"); + AODepthTexture[vertical].Init(shader, "AODepthTexture"); + BlurSharpness[vertical].Init(shader, "BlurSharpness"); + InvFullResolution[vertical].Init(shader, "InvFullResolution"); + PowExponent[vertical].Init(shader, "PowExponent"); + } + shader.Bind(); +} + +void FSSAOCombineShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssaocombine.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/ssaocombine"); + mShader.SetAttribLocation(0, "PositionInProjection"); + AODepthTexture.Init(mShader, "AODepthTexture"); + } + mShader.Bind(); +} diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index fdff178ec..419ca939e 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -38,4 +38,29 @@ private: FShaderProgram mShader; }; +class FDepthBlurShader +{ +public: + void Bind(bool vertical); + + FBufferedUniformSampler AODepthTexture[2]; + FBufferedUniform1f BlurSharpness[2]; + FBufferedUniform2f InvFullResolution[2]; + FBufferedUniform1f PowExponent[2]; + +private: + FShaderProgram mShader[2]; +}; + +class FSSAOCombineShader +{ +public: + void Bind(); + + FBufferedUniformSampler AODepthTexture; + +private: + FShaderProgram mShader; +}; + #endif \ No newline at end of file diff --git a/wadsrc/static/shaders/glsl/depthblur.fp b/wadsrc/static/shaders/glsl/depthblur.fp new file mode 100644 index 000000000..bd464d03d --- /dev/null +++ b/wadsrc/static/shaders/glsl/depthblur.fp @@ -0,0 +1,81 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D AODepthTexture; +uniform float BlurSharpness; +uniform vec2 InvFullResolution; +uniform float PowExponent; + +#define KERNEL_RADIUS 3.0 + +struct CenterPixelData +{ + vec2 UV; + float Depth; + float Sharpness; +}; + +float CrossBilateralWeight(float r, float sampleDepth, CenterPixelData center) +{ + const float blurSigma = KERNEL_RADIUS * 0.5; + const float blurFalloff = 1.0 / (2.0 * blurSigma * blurSigma); + + float deltaZ = (sampleDepth - center.Depth) * center.Sharpness; + + return exp2(-r * r * blurFalloff - deltaZ * deltaZ); +} + +void ProcessSample(float ao, float z, float r, CenterPixelData center, inout float totalAO, inout float totalW) +{ + float w = CrossBilateralWeight(r, z, center); + totalAO += w * ao; + totalW += w; +} + +void ProcessRadius(vec2 deltaUV, CenterPixelData center, inout float totalAO, inout float totalW) +{ + for (float r = 1; r <= KERNEL_RADIUS; r += 1.0) + { + vec2 uv = r * deltaUV + center.UV; + vec2 aoZ = texture(AODepthTexture, uv).xy; + ProcessSample(aoZ.x, aoZ.y, r, center, totalAO, totalW); + } +} + +vec2 ComputeBlur(vec2 deltaUV) +{ + vec2 aoZ = texture(AODepthTexture, TexCoord).xy; + + CenterPixelData center; + center.UV = TexCoord; + center.Depth = aoZ.y; + center.Sharpness = BlurSharpness; + + float totalAO = aoZ.x; + float totalW = 1.0; + + ProcessRadius(deltaUV, center, totalAO, totalW); + ProcessRadius(-deltaUV, center, totalAO, totalW); + + return vec2(totalAO / totalW, aoZ.y); +} + +vec2 BlurX() +{ + return ComputeBlur(vec2(InvFullResolution.x, 0.0)); +} + +float BlurY() +{ + return pow(clamp(ComputeBlur(vec2(0.0, InvFullResolution.y)).x, 0.0, 1.0), PowExponent); +} + +void main() +{ +#if defined(BLUR_HORIZONTAL) + FragColor = vec4(BlurX(), 0.0, 1.0); +#else + FragColor = vec4(BlurY(), 0.0, 0.0, 1.0); +#endif +} diff --git a/wadsrc/static/shaders/glsl/ssao.fp b/wadsrc/static/shaders/glsl/ssao.fp index f143e913f..e0d972c57 100644 --- a/wadsrc/static/shaders/glsl/ssao.fp +++ b/wadsrc/static/shaders/glsl/ssao.fp @@ -108,12 +108,5 @@ void main() vec3 viewPosition = FetchViewPos(TexCoord); vec3 viewNormal = ReconstructNormal(viewPosition); float occlusion = ComputeAO(viewPosition, viewNormal) * AOStrength + (1.0 - AOStrength); - - // GZDoom does not use linear buffers at the moment, apply some gamma to get it closer to correct - occlusion = occlusion * occlusion; - - //FragColor = vec4(viewPosition.x * 0.001 + 0.5, viewPosition.y * 0.001 + 0.5, viewPosition.z * 0.001, 1.0); - //FragColor = vec4(viewNormal.x * 0.5 + 0.5, viewNormal.y * 0.5 + 0.5, viewNormal.z * 0.5 + 0.5, 1.0); - //FragColor = vec4(occlusion, viewPosition.z, 0.0, 1.0); - FragColor = vec4(occlusion, occlusion, occlusion, 1.0); + FragColor = vec4(occlusion, viewPosition.z, 0.0, 1.0); } diff --git a/wadsrc/static/shaders/glsl/ssaocombine.fp b/wadsrc/static/shaders/glsl/ssaocombine.fp new file mode 100644 index 000000000..21fdff102 --- /dev/null +++ b/wadsrc/static/shaders/glsl/ssaocombine.fp @@ -0,0 +1,11 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D AODepthTexture; + +void main() +{ + float attenutation = texture(AODepthTexture, TexCoord).x; + FragColor = vec4(attenutation, attenutation, attenutation, 0.0); +} From ee503ea2751255e6b38a89d49e2b61f02c25a8e3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Sep 2016 10:55:56 +0200 Subject: [PATCH 0874/1509] - removed now redundant mystdint.h file. Visual Studio now ships stdint.h so this workaround is no longer needed. --- src/gl/hqnx/common.h | 2 +- src/gl/hqnx/hq2x.cpp | 1 - src/gl/hqnx/hq3x.cpp | 1 - src/gl/hqnx/hq4x.cpp | 1 - src/gl/hqnx/hqx.h | 2 +- src/gl/hqnx/init.cpp | 1 - src/gl/hqnx/mystdint.h | 19 ------------------- 7 files changed, 2 insertions(+), 25 deletions(-) delete mode 100644 src/gl/hqnx/mystdint.h diff --git a/src/gl/hqnx/common.h b/src/gl/hqnx/common.h index 3388651bf..c3e700571 100644 --- a/src/gl/hqnx/common.h +++ b/src/gl/hqnx/common.h @@ -23,7 +23,7 @@ #define __HQX_COMMON_H_ #include -#include "mystdint.h" +#include #define MASK_2 0x0000FF00 #define MASK_13 0x00FF00FF diff --git a/src/gl/hqnx/hq2x.cpp b/src/gl/hqnx/hq2x.cpp index 679a8c2b6..637d1fb78 100644 --- a/src/gl/hqnx/hq2x.cpp +++ b/src/gl/hqnx/hq2x.cpp @@ -18,7 +18,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mystdint.h" #include "common.h" #include "hqx.h" diff --git a/src/gl/hqnx/hq3x.cpp b/src/gl/hqnx/hq3x.cpp index cbc7fab39..3768f9c92 100644 --- a/src/gl/hqnx/hq3x.cpp +++ b/src/gl/hqnx/hq3x.cpp @@ -18,7 +18,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mystdint.h" #include "common.h" #include "hqx.h" diff --git a/src/gl/hqnx/hq4x.cpp b/src/gl/hqnx/hq4x.cpp index 7ad6e06c3..5af8193cb 100644 --- a/src/gl/hqnx/hq4x.cpp +++ b/src/gl/hqnx/hq4x.cpp @@ -18,7 +18,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mystdint.h" #include "common.h" #include "hqx.h" diff --git a/src/gl/hqnx/hqx.h b/src/gl/hqnx/hqx.h index ee968a561..089b5a0bc 100644 --- a/src/gl/hqnx/hqx.h +++ b/src/gl/hqnx/hqx.h @@ -21,7 +21,7 @@ #ifndef __HQX_H_ #define __HQX_H_ -#include "mystdint.h" +#include #if defined( __GNUC__ ) #ifdef __MINGW32__ diff --git a/src/gl/hqnx/init.cpp b/src/gl/hqnx/init.cpp index f27d45a65..0e8c2db1c 100644 --- a/src/gl/hqnx/init.cpp +++ b/src/gl/hqnx/init.cpp @@ -16,7 +16,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mystdint.h" #include "hqx.h" uint32_t *RGBtoYUV; diff --git a/src/gl/hqnx/mystdint.h b/src/gl/hqnx/mystdint.h deleted file mode 100644 index b2da9df8c..000000000 --- a/src/gl/hqnx/mystdint.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __MYSTDINT_H -#define __MYSTDINT_H - -#ifndef _MSC_VER -#include -#else -typedef unsigned __int64 uint64_t; -typedef signed __int64 int64_t; -typedef unsigned __int32 uint32_t; -typedef signed __int32 int32_t; -typedef unsigned __int16 uint16_t; -typedef signed __int16 int16_t; -typedef unsigned __int8 uint8_t; -typedef signed __int8 int8_t; -#endif - - - -#endif \ No newline at end of file From 77dde2e3addbd7e44083b027059f102c0dc737c7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 3 Sep 2016 00:13:05 +0200 Subject: [PATCH 0875/1509] Fix not switching back to the default frame buffer when gl_renderbuffers is toggled off --- src/gl/renderer/gl_renderbuffers.cpp | 29 +++++++++++++--------------- src/gl/renderer/gl_renderbuffers.h | 3 +-- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 35be00abc..5fe2f5b3a 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -156,6 +156,13 @@ void FGLRenderBuffers::DeleteFrameBuffer(GLuint &handle) bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHeight) { + if (gl_renderbuffers != BuffersActive) + { + if (BuffersActive) + glBindFramebuffer(GL_FRAMEBUFFER, mOutputFB); + BuffersActive = gl_renderbuffers; + } + if (!IsEnabled()) return false; @@ -223,7 +230,7 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples) ClearScene(); if (samples > 1) - mSceneMultisample = CreateRenderBuffer("SceneMultisample", GetHdrFormat(), samples, width, height); + mSceneMultisample = CreateRenderBuffer("SceneMultisample", GL_RGBA16F, samples, width, height); mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, samples, width, height); mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1); @@ -241,7 +248,7 @@ void FGLRenderBuffers::CreatePipeline(int width, int height) for (int i = 0; i < NumPipelineTextures; i++) { - mPipelineTexture[i] = Create2DTexture("PipelineTexture", GetHdrFormat(), width, height); + mPipelineTexture[i] = Create2DTexture("PipelineTexture", GL_RGBA16F, width, height); mPipelineFB[i] = CreateFrameBuffer("PipelineFB", mPipelineTexture[i]); } } @@ -268,8 +275,8 @@ void FGLRenderBuffers::CreateBloom(int width, int height) level.Width = MAX(bloomWidth / 2, 1); level.Height = MAX(bloomHeight / 2, 1); - level.VTexture = Create2DTexture("Bloom.VTexture", GetHdrFormat(), level.Width, level.Height); - level.HTexture = Create2DTexture("Bloom.HTexture", GetHdrFormat(), level.Width, level.Height); + level.VTexture = Create2DTexture("Bloom.VTexture", GL_RGBA16F, level.Width, level.Height); + level.HTexture = Create2DTexture("Bloom.HTexture", GL_RGBA16F, level.Width, level.Height); level.VFramebuffer = CreateFrameBuffer("Bloom.VFramebuffer", level.VTexture); level.HFramebuffer = CreateFrameBuffer("Bloom.HFramebuffer", level.HTexture); @@ -278,17 +285,6 @@ void FGLRenderBuffers::CreateBloom(int width, int height) } } -//========================================================================== -// -// Fallback support for older OpenGL where RGBA16F might not be available -// -//========================================================================== - -GLuint FGLRenderBuffers::GetHdrFormat() -{ - return GL_RGBA16F; -} - //========================================================================== // // Creates a 2D texture defaulting to linear filtering and clamp to edge @@ -557,7 +553,8 @@ void FGLRenderBuffers::BindOutputFB() bool FGLRenderBuffers::IsEnabled() { - return gl_renderbuffers && !gl.legacyMode && !FailedCreate; + return BuffersActive && !gl.legacyMode && !FailedCreate; } bool FGLRenderBuffers::FailedCreate = false; +bool FGLRenderBuffers::BuffersActive = false; diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index ee6d8de5e..08303a912 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -59,8 +59,6 @@ private: void DeleteRenderBuffer(GLuint &handle); void DeleteFrameBuffer(GLuint &handle); - GLuint GetHdrFormat(); - int mWidth = 0; int mHeight = 0; int mSamples = 0; @@ -86,6 +84,7 @@ private: GLuint mOutputFB = 0; static bool FailedCreate; + static bool BuffersActive; }; #endif \ No newline at end of file From 90ab0223a6cf11e3e37b4e57c0fbef90d445eef7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 3 Sep 2016 00:36:23 +0200 Subject: [PATCH 0876/1509] - handle colormap parameter reset when renderbuffers are toggled. --- src/gl/renderer/gl_renderbuffers.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 5fe2f5b3a..f66ea1354 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -55,14 +55,7 @@ #include "doomerrors.h" CVAR(Int, gl_multisample, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); -CUSTOM_CVAR(Bool, gl_renderbuffers, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ - // this CVAR alters some fixed colormap related settings - if (GLRenderer != nullptr && GLRenderer->mShaderManager != nullptr) - { - //GLRenderer->mShaderManager->ResetFixedColormap(); - } -} +CVAR(Bool, gl_renderbuffers, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) //========================================================================== // @@ -161,6 +154,7 @@ bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei if (BuffersActive) glBindFramebuffer(GL_FRAMEBUFFER, mOutputFB); BuffersActive = gl_renderbuffers; + GLRenderer->mShaderManager->ResetFixedColormap(); } if (!IsEnabled()) From 8b7a87f256e3ac1e42b429766dbcad6ac1e29627 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 3 Sep 2016 00:43:18 +0200 Subject: [PATCH 0877/1509] - fix conditions for DrawBlend calls. --- src/gl/scene/gl_scene.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index c1f022ab0..31aea734c 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -688,7 +688,7 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) gl_RenderState.SetFixedColormap(CM_DEFAULT); gl_RenderState.SetSoftLightLevel(-1); DrawTargeterSprites(); - if (FGLRenderBuffers::IsEnabled()) + if (!FGLRenderBuffers::IsEnabled()) { DrawBlend(viewsector); } @@ -970,7 +970,10 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei gl_RenderState.SetFixedColormap(CM_DEFAULT); gl_RenderState.SetSoftLightLevel(-1); screen->Begin2D(false); - DrawBlend(viewsector); + if (!FGLRenderBuffers::IsEnabled()) + { + DrawBlend(viewsector); + } CopyToBackbuffer(&bounds, false); glFlush(); From 902097d6da05cc4e4ca315d40bccef7dcf791d8a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 3 Sep 2016 04:12:00 +0200 Subject: [PATCH 0878/1509] Resolve multisampling depth in shader --- src/gl/renderer/gl_postprocess.cpp | 20 ++- src/gl/renderer/gl_renderbuffers.cpp | 186 ++++++++++++++++------ src/gl/renderer/gl_renderbuffers.h | 27 +++- src/gl/shaders/gl_ambientshader.cpp | 28 ++-- src/gl/shaders/gl_ambientshader.h | 15 +- wadsrc/static/shaders/glsl/lineardepth.fp | 19 +++ 6 files changed, 211 insertions(+), 84 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index edf1148ef..1cd893f1c 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -136,8 +136,8 @@ void FGLRenderer::RenderScreenQuad() void FGLRenderer::PostProcessScene() { - mBuffers->BlitSceneToTexture(); AmbientOccludeScene(); + mBuffers->BlitSceneToTexture(); BloomScene(); TonemapScene(); ColormapScene(); @@ -165,6 +165,7 @@ void FGLRenderer::AmbientOccludeScene() const float blurAmount = gl_ssao_blur_amount; int blurSampleCount = gl_ssao_blur_samples; float aoStrength = gl_ssao_strength; + bool multisample = gl_multisample > 1; //float tanHalfFovy = tan(fovy * (M_PI / 360.0f)); float tanHalfFovy = 1.0f / 1.33333302f; // 1.0f / gl_RenderState.mProjectionMatrix.get()[5]; @@ -177,12 +178,15 @@ void FGLRenderer::AmbientOccludeScene() glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB0); glViewport(0, 0, mBuffers->AmbientWidth, mBuffers->AmbientHeight); mBuffers->BindSceneDepthTexture(0); - mLinearDepthShader->Bind(); - mLinearDepthShader->DepthTexture.Set(0); - mLinearDepthShader->LinearizeDepthA.Set(1.0f / GetZFar() - 1.0f / GetZNear()); - mLinearDepthShader->LinearizeDepthB.Set(MAX(1.0f / GetZNear(), 1.e-8f)); - mLinearDepthShader->InverseDepthRangeA.Set(1.0f); - mLinearDepthShader->InverseDepthRangeB.Set(0.0f); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + mLinearDepthShader->Bind(multisample); + mLinearDepthShader->DepthTexture[multisample].Set(0); + if (multisample) mLinearDepthShader->SampleCount[multisample].Set(gl_multisample); + mLinearDepthShader->LinearizeDepthA[multisample].Set(1.0f / GetZFar() - 1.0f / GetZNear()); + mLinearDepthShader->LinearizeDepthB[multisample].Set(MAX(1.0f / GetZNear(), 1.e-8f)); + mLinearDepthShader->InverseDepthRangeA[multisample].Set(1.0f); + mLinearDepthShader->InverseDepthRangeB[multisample].Set(0.0f); RenderScreenQuad(); // Apply ambient occlusion @@ -227,7 +231,7 @@ void FGLRenderer::AmbientOccludeScene() RenderScreenQuad(); // Add SSAO back to scene texture: - mBuffers->BindCurrentFB(); + mBuffers->BindSceneFB(); glViewport(mSceneViewport.left, mSceneViewport.top, mSceneViewport.width, mSceneViewport.height); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index f66ea1354..b2cee5704 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -53,6 +53,7 @@ #include "w_wad.h" #include "i_system.h" #include "doomerrors.h" +#include CVAR(Int, gl_multisample, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); CVAR(Bool, gl_renderbuffers, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) @@ -86,15 +87,14 @@ FGLRenderBuffers::~FGLRenderBuffers() ClearScene(); ClearPipeline(); ClearBloom(); + ClearAmbientOcclusion(); } void FGLRenderBuffers::ClearScene() { DeleteFrameBuffer(mSceneFB); - DeleteRenderBuffer(mSceneMultisample); - DeleteRenderBuffer(mSceneDepthStencil); - DeleteRenderBuffer(mSceneDepth); - DeleteRenderBuffer(mSceneStencil); + DeleteTexture(mSceneMultisample); + DeleteTexture(mSceneDepthStencil); } void FGLRenderBuffers::ClearPipeline() @@ -119,6 +119,15 @@ void FGLRenderBuffers::ClearBloom() } } +void FGLRenderBuffers::ClearAmbientOcclusion() +{ + DeleteFrameBuffer(AmbientFB0); + DeleteFrameBuffer(AmbientFB1); + DeleteTexture(AmbientTexture0); + DeleteTexture(AmbientTexture1); + DeleteTexture(AmbientRandomTexture); +} + void FGLRenderBuffers::DeleteTexture(GLuint &handle) { if (handle != 0) @@ -186,11 +195,12 @@ bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei } // Bloom bluring buffers need to match the scene to avoid bloom bleeding artifacts - if (mBloomWidth != sceneWidth || mBloomHeight != sceneHeight) + if (mSceneWidth != sceneWidth || mSceneHeight != sceneHeight) { CreateBloom(sceneWidth, sceneHeight); - mBloomWidth = sceneWidth; - mBloomHeight = sceneHeight; + CreateAmbientOcclusion(sceneWidth, sceneHeight); + mSceneWidth = sceneWidth; + mSceneHeight = sceneHeight; } glBindTexture(GL_TEXTURE_2D, textureBinding); @@ -206,8 +216,8 @@ bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei mWidth = 0; mHeight = 0; mSamples = 0; - mBloomWidth = 0; - mBloomHeight = 0; + mSceneWidth = 0; + mSceneHeight = 0; } return !FailedCreate; @@ -224,9 +234,15 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples) ClearScene(); if (samples > 1) - mSceneMultisample = CreateRenderBuffer("SceneMultisample", GL_RGBA16F, samples, width, height); + { + mSceneMultisample = Create2DMultisampleTexture("SceneMultisample", GL_RGBA16F, width, height, samples, false); + mSceneDepthStencil = Create2DMultisampleTexture("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height, samples, false); + } + else + { + mSceneDepthStencil = Create2DTexture("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height); + } - mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, samples, width, height); mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1); } @@ -279,20 +295,77 @@ void FGLRenderBuffers::CreateBloom(int width, int height) } } +//========================================================================== +// +// Creates ambient occlusion working buffers +// +//========================================================================== + +void FGLRenderBuffers::CreateAmbientOcclusion(int width, int height) +{ + ClearAmbientOcclusion(); + + if (width <= 0 || height <= 0) + return; + + AmbientWidth = width / 2; + AmbientHeight = height / 2; + AmbientTexture0 = Create2DTexture("AmbientTexture0", GL_RG32F, AmbientWidth, AmbientHeight); + AmbientTexture1 = Create2DTexture("AmbientTexture1", GL_RG32F, AmbientWidth, AmbientHeight); + AmbientFB0 = CreateFrameBuffer("AmbientFB0", AmbientTexture0); + AmbientFB1 = CreateFrameBuffer("AmbientFB1", AmbientTexture1); + + int16_t randomValues[16 * 4]; + std::mt19937 generator(1337); + std::uniform_real_distribution distribution(-1.0, 1.0); + for (int i = 0; i < 16; i++) + { + double num_directions = 8.0; // Must be same as the define in ssao.fp + double angle = 2.0 * M_PI * distribution(generator) / num_directions; + double x = cos(angle); + double y = sin(angle); + double z = distribution(generator); + double w = distribution(generator); + + randomValues[i * 4 + 0] = (int16_t)clamp(x * 32768.0, -32767.0, 32768.0); + randomValues[i * 4 + 1] = (int16_t)clamp(y * 32768.0, -32767.0, 32768.0); + randomValues[i * 4 + 2] = (int16_t)clamp(z * 32768.0, -32767.0, 32768.0); + randomValues[i * 4 + 3] = (int16_t)clamp(w * 32768.0, -32767.0, 32768.0); + } + + AmbientRandomTexture = Create2DTexture("AmbientRandomTexture", GL_RGBA16_SNORM, 4, 4, randomValues); +} + //========================================================================== // // Creates a 2D texture defaulting to linear filtering and clamp to edge // //========================================================================== -GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height) +GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height, const void *data) { - GLuint type = (format == GL_RGBA16F) ? GL_FLOAT : GL_UNSIGNED_BYTE; GLuint handle = 0; glGenTextures(1, &handle); glBindTexture(GL_TEXTURE_2D, handle); FGLDebug::LabelObject(GL_TEXTURE, handle, name); - glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, GL_RGBA, type, nullptr); + + GLenum dataformat, datatype; + switch (format) + { + case GL_RGBA8: dataformat = GL_RGBA; datatype = GL_UNSIGNED_BYTE; break; + case GL_RGBA16: dataformat = GL_RGBA; datatype = GL_UNSIGNED_SHORT; break; + case GL_RGBA16F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; + case GL_RGBA32F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; + case GL_R32F: dataformat = GL_RED; datatype = GL_FLOAT; break; + case GL_RG32F: dataformat = GL_RG; datatype = GL_FLOAT; break; + case GL_DEPTH_COMPONENT24: dataformat = GL_DEPTH_COMPONENT; datatype = GL_FLOAT; break; + case GL_STENCIL_INDEX8: dataformat = GL_STENCIL_INDEX; datatype = GL_INT; break; + case GL_DEPTH24_STENCIL8: dataformat = GL_DEPTH_STENCIL; datatype = GL_UNSIGNED_INT_24_8; break; + case GL_RGBA16_SNORM: dataformat = GL_RGBA; datatype = GL_SHORT; break; + default: I_FatalError("Unknown format passed to FGLRenderBuffers.Create2DTexture"); + } + + glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, dataformat, datatype, data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -300,6 +373,17 @@ GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int return handle; } +GLuint FGLRenderBuffers::Create2DMultisampleTexture(const FString &name, GLuint format, int width, int height, int samples, bool fixedSampleLocations) +{ + GLuint handle = 0; + glGenTextures(1, &handle); + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, handle); + FGLDebug::LabelObject(GL_TEXTURE, handle, name); + glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, format, width, height, fixedSampleLocations); + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0); + return handle; +} + //========================================================================== // // Creates a render buffer @@ -347,34 +431,22 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff return handle; } -GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer) +GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool multisample) { GLuint handle = 0; glGenFramebuffers(1, &handle); glBindFramebuffer(GL_FRAMEBUFFER, handle); FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); - if (colorIsARenderBuffer) - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); + if (multisample) + { + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, colorbuffer, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D_MULTISAMPLE, depthstencil, 0); + } else + { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil); - if (CheckFrameBufferCompleteness()) - ClearFrameBuffer(true, true); - return handle; -} - -GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer) -{ - GLuint handle = 0; - glGenFramebuffers(1, &handle); - glBindFramebuffer(GL_FRAMEBUFFER, handle); - FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); - if (colorIsARenderBuffer) - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); - else - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthstencil, 0); + } if (CheckFrameBufferCompleteness()) ClearFrameBuffer(true, true); return handle; @@ -394,22 +466,23 @@ bool FGLRenderBuffers::CheckFrameBufferCompleteness() FailedCreate = true; -#if 0 - FString error = "glCheckFramebufferStatus failed: "; - switch (result) + if (gl_debug_level > 0) { - default: error.AppendFormat("error code %d", (int)result); break; - case GL_FRAMEBUFFER_UNDEFINED: error << "GL_FRAMEBUFFER_UNDEFINED"; break; - case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: error << "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"; break; - case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: error << "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"; break; - case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: error << "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER"; break; - case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: error << "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER"; break; - case GL_FRAMEBUFFER_UNSUPPORTED: error << "GL_FRAMEBUFFER_UNSUPPORTED"; break; - case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: error << "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"; break; - case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: error << "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS"; break; + FString error = "glCheckFramebufferStatus failed: "; + switch (result) + { + default: error.AppendFormat("error code %d", (int)result); break; + case GL_FRAMEBUFFER_UNDEFINED: error << "GL_FRAMEBUFFER_UNDEFINED"; break; + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: error << "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"; break; + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: error << "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"; break; + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: error << "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER"; break; + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: error << "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER"; break; + case GL_FRAMEBUFFER_UNSUPPORTED: error << "GL_FRAMEBUFFER_UNSUPPORTED"; break; + case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: error << "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"; break; + case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: error << "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS"; break; + } + Printf("%s\n", error.GetChars()); } - I_FatalError(error); -#endif return false; } @@ -482,6 +555,21 @@ void FGLRenderBuffers::BindSceneFB() glBindFramebuffer(GL_FRAMEBUFFER, mSceneFB); } +//========================================================================== +// +// Binds the depth texture to the specified texture unit +// +//========================================================================== + +void FGLRenderBuffers::BindSceneDepthTexture(int index) +{ + glActiveTexture(GL_TEXTURE0 + index); + if (mSamples > 1) + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mSceneDepthStencil); + else + glBindTexture(GL_TEXTURE_2D, mSceneDepthStencil); +} + //========================================================================== // // Binds the current scene/effect/hud texture to the specified texture unit diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 08303a912..32430f2ed 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -23,6 +23,7 @@ public: bool Setup(int width, int height, int sceneWidth, int sceneHeight); void BindSceneFB(); + void BindSceneDepthTexture(int index); void BlitSceneToTexture(); void BindCurrentTexture(int index); @@ -35,24 +36,38 @@ public: enum { NumBloomLevels = 4 }; FGLBloomTextureLevel BloomLevels[NumBloomLevels]; + // Ambient occlusion buffers + GLuint AmbientTexture0 = 0; + GLuint AmbientTexture1 = 0; + GLuint AmbientFB0 = 0; + GLuint AmbientFB1 = 0; + int AmbientWidth = 0; + int AmbientHeight = 0; + GLuint AmbientRandomTexture = 0; + static bool IsEnabled(); int GetWidth() const { return mWidth; } int GetHeight() const { return mHeight; } + int GetSceneWidth() const { return mSceneWidth; } + int GetSceneHeight() const { return mSceneHeight; } + private: void ClearScene(); void ClearPipeline(); void ClearBloom(); + void ClearAmbientOcclusion(); void CreateScene(int width, int height, int samples); void CreatePipeline(int width, int height); void CreateBloom(int width, int height); - GLuint Create2DTexture(const FString &name, GLuint format, int width, int height); + void CreateAmbientOcclusion(int width, int height); + GLuint Create2DTexture(const FString &name, GLuint format, int width, int height, const void *data = nullptr); + GLuint Create2DMultisampleTexture(const FString &name, GLuint format, int width, int height, int samples, bool fixedSampleLocations); GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height); GLuint CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer); - GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer); - GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer); + GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool multisample); bool CheckFrameBufferCompleteness(); void ClearFrameBuffer(bool stencil, bool depth); void DeleteTexture(GLuint &handle); @@ -63,8 +78,8 @@ private: int mHeight = 0; int mSamples = 0; int mMaxSamples = 0; - int mBloomWidth = 0; - int mBloomHeight = 0; + int mSceneWidth = 0; + int mSceneHeight = 0; static const int NumPipelineTextures = 2; int mCurrentPipelineTexture = 0; @@ -72,8 +87,6 @@ private: // Buffers for the scene GLuint mSceneMultisample = 0; GLuint mSceneDepthStencil = 0; - GLuint mSceneDepth = 0; - GLuint mSceneStencil = 0; GLuint mSceneFB = 0; // Effect/HUD buffers diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index 6b8c9cc48..f3b6eced6 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -49,22 +49,24 @@ #include "gl/system/gl_cvars.h" #include "gl/shaders/gl_ambientshader.h" -void FLinearDepthShader::Bind() +void FLinearDepthShader::Bind(bool multisample) { - if (!mShader) + auto &shader = mShader[multisample]; + if (!shader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); - mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/lineardepth.fp", "", 330); - mShader.SetFragDataLocation(0, "FragColor"); - mShader.Link("shaders/glsl/lineardepth"); - mShader.SetAttribLocation(0, "PositionInProjection"); - DepthTexture.Init(mShader, "DepthTexture"); - LinearizeDepthA.Init(mShader, "LinearizeDepthA"); - LinearizeDepthB.Init(mShader, "LinearizeDepthB"); - InverseDepthRangeA.Init(mShader, "InverseDepthRangeA"); - InverseDepthRangeB.Init(mShader, "InverseDepthRangeB"); + shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + shader.Compile(FShaderProgram::Fragment, "shaders/glsl/lineardepth.fp", multisample ? "#define MULTISAMPLE\n" : "", 330); + shader.SetFragDataLocation(0, "FragColor"); + shader.Link("shaders/glsl/lineardepth"); + shader.SetAttribLocation(0, "PositionInProjection"); + DepthTexture[multisample].Init(shader, "DepthTexture"); + SampleCount[multisample].Init(shader, "SampleCount"); + LinearizeDepthA[multisample].Init(shader, "LinearizeDepthA"); + LinearizeDepthB[multisample].Init(shader, "LinearizeDepthB"); + InverseDepthRangeA[multisample].Init(shader, "InverseDepthRangeA"); + InverseDepthRangeB[multisample].Init(shader, "InverseDepthRangeB"); } - mShader.Bind(); + shader.Bind(); } void FSSAOShader::Bind() diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index 419ca939e..5f9ef630b 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -6,16 +6,17 @@ class FLinearDepthShader { public: - void Bind(); + void Bind(bool multisample); - FBufferedUniformSampler DepthTexture; - FBufferedUniform1f LinearizeDepthA; - FBufferedUniform1f LinearizeDepthB; - FBufferedUniform1f InverseDepthRangeA; - FBufferedUniform1f InverseDepthRangeB; + FBufferedUniformSampler DepthTexture[2]; + FBufferedUniform1i SampleCount[2]; + FBufferedUniform1f LinearizeDepthA[2]; + FBufferedUniform1f LinearizeDepthB[2]; + FBufferedUniform1f InverseDepthRangeA[2]; + FBufferedUniform1f InverseDepthRangeB[2]; private: - FShaderProgram mShader; + FShaderProgram mShader[2]; }; class FSSAOShader diff --git a/wadsrc/static/shaders/glsl/lineardepth.fp b/wadsrc/static/shaders/glsl/lineardepth.fp index f61bb3995..31df9dc32 100644 --- a/wadsrc/static/shaders/glsl/lineardepth.fp +++ b/wadsrc/static/shaders/glsl/lineardepth.fp @@ -2,7 +2,12 @@ in vec2 TexCoord; out vec4 FragColor; +#if defined(MULTISAMPLE) +uniform sampler2DMS DepthTexture; +uniform int SampleCount; +#else uniform sampler2D DepthTexture; +#endif uniform float LinearizeDepthA; uniform float LinearizeDepthB; uniform float InverseDepthRangeA; @@ -10,7 +15,21 @@ uniform float InverseDepthRangeB; void main() { +#if defined(MULTISAMPLE) + ivec2 texSize = textureSize(DepthTexture); + ivec2 ipos = ivec2(TexCoord * vec2(texSize)); + float depth = 0.0; + for (int i = 0; i < SampleCount; i++) + depth += texelFetch(DepthTexture, ipos, i).x; + depth /= float(SampleCount); +#else + /*ivec2 texSize = textureSize(DepthTexture, 0); + ivec2 ipos = ivec2(TexCoord * vec2(texSize)); + if (ipos.x < 0) ipos.x += texSize.x; + if (ipos.y < 0) ipos.y += texSize.y; + float depth = texelFetch(DepthTexture, ipos, 0).x;*/ float depth = texture(DepthTexture, TexCoord).x; +#endif float normalizedDepth = clamp(InverseDepthRangeA * depth + InverseDepthRangeB, 0.0, 1.0); FragColor = vec4(1.0 / (normalizedDepth * LinearizeDepthA + LinearizeDepthB), 0.0, 0.0, 1.0); } From e7765bb240820c608dcb710a94a7b42d19ea465c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 3 Sep 2016 04:29:50 +0200 Subject: [PATCH 0879/1509] Move SSAO pass to be before translucent rendering Fix depth sampling location when not using fullscreen scene --- src/gl/renderer/gl_postprocess.cpp | 4 ++-- src/gl/scene/gl_scene.cpp | 2 ++ src/gl/shaders/gl_ambientshader.cpp | 2 ++ src/gl/shaders/gl_ambientshader.h | 2 ++ wadsrc/static/shaders/glsl/lineardepth.fp | 12 +++++++++--- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 1cd893f1c..56032704e 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -136,7 +136,6 @@ void FGLRenderer::RenderScreenQuad() void FGLRenderer::PostProcessScene() { - AmbientOccludeScene(); mBuffers->BlitSceneToTexture(); BloomScene(); TonemapScene(); @@ -187,6 +186,8 @@ void FGLRenderer::AmbientOccludeScene() mLinearDepthShader->LinearizeDepthB[multisample].Set(MAX(1.0f / GetZNear(), 1.e-8f)); mLinearDepthShader->InverseDepthRangeA[multisample].Set(1.0f); mLinearDepthShader->InverseDepthRangeB[multisample].Set(0.0f); + mLinearDepthShader->Scale[multisample].Set(mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height); + mLinearDepthShader->Offset[multisample].Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); RenderScreenQuad(); // Apply ambient occlusion @@ -246,7 +247,6 @@ void FGLRenderer::AmbientOccludeScene() mSSAOCombineShader->Bind(); mSSAOCombineShader->AODepthTexture.Set(0); RenderScreenQuad(); - glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); FGLDebug::PopGroup(); } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index d5df31784..087bd9f62 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -503,6 +503,8 @@ void FGLRenderer::DrawScene(int drawmode) RenderScene(recursion); + AmbientOccludeScene(); + // Handle all portals after rendering the opaque objects but before // doing all translucent stuff recursion++; diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index f3b6eced6..54a651281 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -65,6 +65,8 @@ void FLinearDepthShader::Bind(bool multisample) LinearizeDepthB[multisample].Init(shader, "LinearizeDepthB"); InverseDepthRangeA[multisample].Init(shader, "InverseDepthRangeA"); InverseDepthRangeB[multisample].Init(shader, "InverseDepthRangeB"); + Scale[multisample].Init(shader, "Scale"); + Offset[multisample].Init(shader, "Offset"); } shader.Bind(); } diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index 5f9ef630b..5b18ea85f 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -14,6 +14,8 @@ public: FBufferedUniform1f LinearizeDepthB[2]; FBufferedUniform1f InverseDepthRangeA[2]; FBufferedUniform1f InverseDepthRangeB[2]; + FBufferedUniform2f Scale[2]; + FBufferedUniform2f Offset[2]; private: FShaderProgram mShader[2]; diff --git a/wadsrc/static/shaders/glsl/lineardepth.fp b/wadsrc/static/shaders/glsl/lineardepth.fp index 31df9dc32..7e4eee745 100644 --- a/wadsrc/static/shaders/glsl/lineardepth.fp +++ b/wadsrc/static/shaders/glsl/lineardepth.fp @@ -8,28 +8,34 @@ uniform int SampleCount; #else uniform sampler2D DepthTexture; #endif + uniform float LinearizeDepthA; uniform float LinearizeDepthB; uniform float InverseDepthRangeA; uniform float InverseDepthRangeB; +uniform vec2 Scale; +uniform vec2 Offset; void main() { + vec2 uv = Offset + TexCoord * Scale; + #if defined(MULTISAMPLE) ivec2 texSize = textureSize(DepthTexture); - ivec2 ipos = ivec2(TexCoord * vec2(texSize)); + ivec2 ipos = ivec2(uv * vec2(texSize)); float depth = 0.0; for (int i = 0; i < SampleCount; i++) depth += texelFetch(DepthTexture, ipos, i).x; depth /= float(SampleCount); #else /*ivec2 texSize = textureSize(DepthTexture, 0); - ivec2 ipos = ivec2(TexCoord * vec2(texSize)); + ivec2 ipos = ivec2(uv * vec2(texSize)); if (ipos.x < 0) ipos.x += texSize.x; if (ipos.y < 0) ipos.y += texSize.y; float depth = texelFetch(DepthTexture, ipos, 0).x;*/ - float depth = texture(DepthTexture, TexCoord).x; + float depth = texture(DepthTexture, uv).x; #endif + float normalizedDepth = clamp(InverseDepthRangeA * depth + InverseDepthRangeB, 0.0, 1.0); FragColor = vec4(1.0 / (normalizedDepth * LinearizeDepthA + LinearizeDepthB), 0.0, 0.0, 1.0); } From aece9aaa58bed5864fde2e7a84976e0afaf5288f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 3 Sep 2016 14:01:51 +0200 Subject: [PATCH 0880/1509] - added xBRZ texture scaler after clearing the licensing conditions. A screenshot of the confirmation that this is ok has been added to the 'licenses' folder. --- docs/licenses/xBRZ.jpg | Bin 0 -> 60099 bytes src/CMakeLists.txt | 6 +++- src/gl/data/gl_vertexbuffer.h | 10 ++++++ src/gl/scene/gl_scene.cpp | 2 -- src/gl/shaders/gl_shader.h | 3 +- src/gl/textures/gl_hqresize.cpp | 62 +++++++++++++++++++++++++++++--- wadsrc/static/menudef.z | 6 ++++ 7 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 docs/licenses/xBRZ.jpg diff --git a/docs/licenses/xBRZ.jpg b/docs/licenses/xBRZ.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ab8335391b0e35541662e9664ad53c31aaed0c51 GIT binary patch literal 60099 zcmex=Bm<7<_#hv=|r|I2c$Mr5IQl7#J8C z7#QprrQvKhMhymLus9O~1EV1W69WT-AOiz~9|Hs=faMrKrZO-VBxdH7=;fuBD46IO z=ouO?F#NyG;LISv&BMpTCBVnaCnP8!ETJJKAtokasH`fhVP$MovIz$!vMUve7&T5@$f4}C@t|nX#SbdRNkvVZTw>x9l2WQ_ z>Kd9_CZ=ZQ7M51dF0O9w9-dyoA)#U65s^{JDXD4c8JStdC8cHM6_r)ZEv;?s9i3g1 zCQq3GGAU*RJ2VdF$b$ z$4{OPfBE|D`;VW$K>lK6UWKS#c@69{;yl(wme1fG zL-^|!0}nGJ1Ct=LAcH-_7cMQ!Wf1|!Opd8>ww}koE|cC7;+0a`nUvde&O!2kZM{^P z=q2?<3#)f$oNC|E>CMv+!_yyScRly_{x2Q-tN*QkE^mMNTDQS2wMC03rS^GTXo_+> zaQw36UoE!%p))U^n6k*iZ9?uX&SMtms{5{}7Ub%lE(zhS%vyLl<`9#NSxn9Tc(2NN z0!w>Vh%g+PCc*H<-b?4ui%DHw(K8f-E}fN0^y5rpW^3EoC}oG zDOCyc1FwsG-J7PjKV^=`DhW5Q)JBUF)*F9aE!tFhF|TWFX8E_p3ZGK?PviJ)ZjRzvnX*|;XTLZ?-T6%bwOxyDcd#cke|&gzqlAS zx{3ra4in5;eY<|EgOZ|$-qPk01p}43sUex~ncr{i6A;TcRQ|oXX|})P!BK-M?aq^bA2If^pMLxL-d2s3ez!$6 zR_3Mu?aO%FaZD*wdFGQ_M;Z=pFF*L4_oYv+?kwwy)0(callf-12lg-gtL@iSb0((a zbgo@-+N#K?$CYJ;%8KUmQxe6FuHR8DdWb+4Ix@-O@A(0QlQuGn3l@yX6%?zYG8)8(sw6-J4KEKj<%vs-Mk z((Ngqau?PsF47g2IpHC*{gkcoz2%dRJrmZyG1q_ADsx|LF`rU~2^Ig`w!B#NJg3!H zY3(k5+0`zJZ9=O%4xNZdzprJ#)+ky~wIysvScv8hd&LHY`A@?$R#xqvHg#&x@6~M9 zu1gBED*XkWKeh7qIWXT|F8Osywq%%OODgx4lS=PY((~?d9+xlqb*)#VEoH7*rPAax zhWRBk3OpHhGg$}4W=8FjI1%B3`m&K<#d)>9u` z*2}+q?uy=%f;+A1{lA|t__ON3g)MIqj?XE7{73Vn*NnT93NLVNn4~?Y)uw^-D!cco9dnfOg(1~1D8+pL=3|2Z1l6f-TL zDCEJluwDCnkBFb1nsGzOeY^c>rH+$VzpJlLy1O!};9{w}yQ`>sc=Y9@^UF^KrTpBu zMfULJi81O6;+AeR}E}uNu_oRBN{NsR%+y88J>+jp2TJO5zW%g2s>E>o{SiB^;*=*S*mflJIt^GRt zN6qa>=M@jWDg5p_HT~!`fioYsgsV>MnxpmYPqzIbuH%8bC#fpkmyrDR@mF}L&Bfae zpS=zyJ5KWD-%%-1|6%&e{|ujxJ^%MJ{-4%%-DlC=70(=;PAqJ&Ey$j>r7d3QRoc5J zqMKSC3SYndCwmQp2BQN*0mEB&hgZ5Hfex(02`5xcY`Pmc`Et(uv)Xl=w!XD}pV0eA zdP&RV?Y|H7IedRn&vmQWYtha&CB2YY(KD6*#!PbgqjdA~B)>8fe0 zQ+a??#2kU=5?s}S!S}saaH?$GWv@~=`MC8-_WA#|W-i#>bwA5!VNR=}Q$uZmR*T^s zozodhPBE|KTIH!ynv}I-*^)i&9kb@0x_;s9EA81GZ*%We&d$j&^7RhcYHOzJC)$>o z>cVc((>Q;f<2vEX7TZ71dhpsiW6|yN=PqCV^ZVEJwCjO!FD~72D(dH!U(Vh&Bl3XG zzT+DzrOk4`t-2;*|uqKc0BD-PBi$H_YNv`9vp~ z-WL96yiskcZ4!@yycV@ezHZQXC)-oc9e=zu@d=B^)AqJdi4$K}S=~Ld>)1-U$r<-| zhy8ucH}n0^daLW(FT7p5RcvqTQ}?8zhTc8DlUB-e+%OhO+ja8!d;R|m!fx*#Zrqxk zE4y?{fzu8b2~pGH{|p~GGXFDtzV-ayulRpz+t%h@x^~M#StrQ!7I*0a&J~Ng7&L|% zezKKQOgHYSO8mZ?2OmsqJn{8KrjT`ca}BFde30Gute5L^7VO`ap(n0Y$x;yVtNF%t z zRz+E$-olatg1@((P`7yU)wJ)I-MZ(x%Y};Pyz950_v^JuwsPXKqui~Z`_F31-uP61 z_`{;*ItpKX_Z?p9=eH<7C2rOC^31fZPpf~XHf?S&nE9@D)zOeEx=(jEL@(Alu6SgP zzjbxvyX=nln)hF&+%UPe?xNC}jX#g*N#q?=wtReF^wNF)8`i+g=#65mDZ&`z`v+|P8 zT#ae&f^C`K5+%MIzkX}M&P$gby}2XFwb5`+^6wu1*I~-$X$2_}VX|{tlOpVD3oMRC zEU@Vb*_Xb59{22TTc&up1m*;+ncEjpJU==7$v&os3)(o-OPK4YZ(%*}Gfnx+3jMe5 z_17-hTJiRpC7;dNClie4@7})7_GR*xom+O#^G@xGcz(-c;;E?$$t&0`7c!cBKXflN zGWS`;%_h#epq;kX&u=dcZTjF?xbkG7vc#f^1x9{GiyLguI_gcdKB;JU+vBXolo)Gy z13kyv-)lEsTe|a7$`12WakkTWCMjB4q#kD}m#Mn2fBgaO4RLF(^D-aSF>1Xh=2Nt9 zL6d99q*obRPfkplS0bRD)6>H|`5dRHZSVRCPiGxFcX!+4686de8T$G(C*8igY^mzi zT?ZaM5`5&z^`ObGB6!{wMjffCdp(ynm3=T3IJSjbR z%zbNed~~-pcZI?Zw=2oD7aPCN*l4}u%aebhn{#t?*96_<=a^mm`n|h@w%(fF)Nk9i z%~i0tbv*y<XFkUJB`e;$C;klM+{7P%O7UadbIiC2k z_>H-_@Ez~Mr*4;`e=@ioZLh0jzP?obiog&3J-f3#zIoexa$3LDa85$XBoEozmu{=M zm#|4Zo%-zVHd6+J+ut`&VmN+nm8@FOwauQqYu?K!iT4G0O|TLunjQ_cDZDds4BbdwTCp*ZTaH5xDO%?OLbM`GQZ! zBt;(Vj44g>kY69Qx^%^sL+7GP=GI^8$(M6TJ76hW`0J8H{pPq+VLP@)CU5@~t2R9$ z!FuKK^;^yTw#<5T?N*K!W69?U#i!;xmZ`q{`foYw_OCatZrSa&PIjgOp8A+H^x_fn|Q}D-(=O#pKcf2 z_$*H{Zw>3ZRgjynyJuVe<~2T(gckJeWMMv6yGrzunupHCY21w*xgSn>IQd)3$j!AB zxiL}Y`~Hl{zLVG{3VC*In#a%ZMDUHPyXs?SnY63#RL_3wyympDKW4>whQi}sB~d9K zqi?o;a=v};k_gM&gX#^1H{`tvFRKd*t(BaZ&wHxLk3)T-#pC7|8UOYx{M&EzB>cp8 z-Mo({MVjo5`TJ%b5AZd)>t4Ln_QdDp-oWW8`RQ9VJxp?gM z2{)O^2P~N9xn`Zsooo3v>A)E`)ANqUSk*U_YA;)~La|LlFHhpYrYE`Q?#+49mwDmU zMy~`rpOZ4r1y3EwO@4Xs#2;7HwLKf|9@RDy^$u-$Fy|fn&k%#m$;T6yA2=)bIOncwR;L9s-p-u#_^i2V|BS#MB8ZBYx?*=S?XQ`YfTpD1B?d`q@i$=I}8{K3m`$r{+3! z!8{AeKO41KZ_jx=N2ag((aikhlI>z?$$Y0>Qh8dQeljpJJTCWa<&Ef=xR*}11yy(Z z9GzdN-|*xCPx6Y_vsf=&>-*wc@X?iJ-Nt>#C**SR*DbeSs#1O^bEaZbq+ooqmsuIGaJ#DPj*XUhz)(EjPqRdFNnXpW#N91|yOfpQ$@Cc+ zM^1ZZzj^JGIrooU+7rL$bK||^7xFCPDkVhguHEy0WAXMz?u6Sdhs&%B&$_F&tY02^ zyUq85P0n$3_B`XRbxXcz`BxUQSS^`&;^^WXu0Ed|%AW9iymPJler1wrb!N+@NkZ~d zHXaZDzOnzC`^% z>U_P2sVO~wmhk`Jc>ZB^`G&1Wr+iq*xTJTA@MV>x$v2zstjt{T@7X=e2Xj>_wky^y zKckTHpsDiLqouxHoQhi~GEXeI9gvVx;CcSCC{xs(ysg!TSpsgZs|(lN@%EUfLIT(N zrP1wI)uw5(Oe>i7iRj~#=kl2!eFm#{q%Zm=$-MH>-1^*7+q=7uZ8*tdZ$Ism=;?1ZnlA(I-8f&f;iQh) zArJY2-Wj_rlv!j}9DkC@Gxcjm5NArovhdDBHZHse=FRy|K9s z@n^2GqF!%vFH07AJ4CvbndCXZt{*E19wTrT~|%E?CkQ;OBCGP zUE2D1V%L}FmJHv&t+vYD9QpFY?cHoCF+x^pE2cy(>eA#Hhz7Nm<~qgg0hiCpc=<7w zaT))(vUT?AlTU3Y|Genj*?(T+RR6?XpX}!{#I8S6N5d0M~wN)~6T}b7_ zOWE^hMHdCeaGYmm`J#MnX!ps<6BbM` z^0Tzn7UDjc(#P7AtnxDL>GiV5&v^H`uaDa*vQ}jG;_bVqMf6YnEa{!tGv~p)w!Q@= zJg=5I8?g3?2w(XfAnQGahns;j<`d(8hOc4TTHQA$d8T}NxaZc=rFq734l461ZT}Yf z?frXgVcBct#U_R+?KWzUWE$UCfBTccoYl2(`G#rMt$ksW?$;?zu1s=cE4b@#`TUR8 z^4Z$aOQsv`39MYC8C@B}$|5}PW}UHvbjY<-*E?@SswQ`xXnS+ygU#isjgvy%${zkp z-2AHW!dH{;MgOEbpOl?;l}vwC)mOKLajk38&+{@xo|(#Lxx6-~kM!nr%Hh0ra)uO`5@4KeS z8$Dc`JgHnGdFp17HRcS5^Uof%k=y&~j!w#|c<1Dz_cwRs9V?ty=(omx%bDDTQ?!ba%?+Gd*5R0!4;ftEvMYCazreCU#Mm7B5qm#)6@ZvyB#< zHekMUx#q?G=Zos^J2j{*TKsv@e};LT{~2nzY^WzHb4t={&V!zUf_key?ufOgB@T<_ zt$BCO|B}!=PiT`}j{{2D+p}@eO7=rxD3eEQ~%@*vTe+FCOf4@ZFMlg7~x?>R)a+x$mkMl-3<0Q7)kG@B0^%oeS90dafo`XXVwM(@XsPpW*qmkGrog zkD717@aE#Iyo|F9)+TAQXBj*2ot0entmgvrX1C0)B70%)Sqx^_n{f`n=_s_~b^4XX7?#X$j6>AqxWb!(-VB+Kh7SDFYT%46; zuylu*Z!M>>Cx@Zv{es77?>O~OGIuqd%hbDdO?=11Mdm@vl6EFf<(^>PBgTAhm(Rsn z3@5|pnwo7e@(Nrcyn33t;Nz+1e;?qflDdA@QFKediBAei@2}20Ex+L8gK9ploC^%g z`;T0DHhHP!0-m#`dAwI2t8C<`yK>W6Ql~=x=x*juYi?J*Gt4#GY8kkSE4g?nL%_A}j@+KCHUAkh`x*NfEx#W87dq2qyXLp!iU~8H z_n+%c(GoK-++87g@ZF8aAJ%o7q%{}>J<5)D*=x>ix+i$f8sja8lX((0N~)OKd=Z&^ zvYxTTQzg59!%VJs>U{BY_^MJGzpVXpaTde#Ns-rXWq0T;o}|H3B+~VExsCj6m4<@w z?OVNbi%U%pw0X*kxtTkjmrgo(=wHR-OWTdzGMM$9=SrOAnEjStBIxp(w_0|^uj+!2 zYuT<2>_1gEC9V0yQ3kzi@t~PG`D(kGKHZ2hagfe*dsdUqSm4O={KBXc% zfh$9y(A#@YZ_jx$Z(0BAPt0tWo*OH6z4O#N`*`u8G~M5Ok6SuS{~QGMvj!+SZ#`SZH#@ z_R!3f%KJ|x6X!gC`ueu$#RC^-2pszT_?FqWzc=OM{xd|CWt?S@{MmmYq`dtvU;VFV z_fIW(Kg-zjRofPWc43?FZcdcM2$ z>fTSKnq%MU5_@7zo^s^Diyuer}@5zk`}eGk za}WG2D*hQ_F8p@;&flU}HaRJ!<8*nX@Bcb+)EHRI)Fm1`LN`ZTQNTH{z`1lBXr6(uT!unZ|Be z-r^={lfgM+L{Np#Q#`0xIoMNJtTOFTl9*S&v{#c%tc;raa6!FOw~ z{AZ~CCDqgb7McFqecpeD&!@jG>SD0@{-0r9{93u{{|x8#uXSlKe7^s$vTjS|`~M6! z`=c}#FrTmg`SjPt=llPB`kS$6XzG6scK>I%`{zUae;)4tdWiq+VgCOI@&A7YXaI~F zQ2%qVgu&2FhLmI@PKBh)O>TC<#~*234Q>8g|A*y2gJIYTChqmS=D)9Z4hZ=kUuu8v zU)zEO9HP&sKkE$7&*>_=z5m_upYk79zM0{kAiGN|2G@0ET;|mNvp4QySiJ51?~VW5|76@Q|9j&rgI%@i!&c_mr$gpwn6&HrabH1E9-OSWygpAXP6Ls{P)zOX$|J}4^^lCtG)d1mr4C0Z~Z^N zm;e2e&22I&F&ZSJiD5Jw47!rRilfHktk#+hS}ScPRE7Q8kji5vIO~CN>>K%y@8y3l z{u#jXp?>{;hKBji2-Q67k@>&5epcMy-h0>Bw~y`f#KqgqZv6g{xOInZVCNDz;8?cGt4Xc&v1X+e+Djw1W%z%#^y7TG6qR*?9A)y3}5>8-Mw<8 zETMDm?THuO9sKL+jiSNs%Kp#i;(vd;|ImTcbl2HZX-}y=Sv__Me0*;9YgIN%EbV>N zUZl0@O$<-E+z#25_p{=EKG*;IJO9Jtx8DC5Y@YsS*q{4PgfTYfslbUA-eY%@*=^G2 z*-zD(=xaX9N3~pwVU6QCiOKht{|@@kaNe^1{q6czdAJ!1IF@cNGiMD*y~{Pv@|Z@S zX4s1)qm6B8)?HJd@A`iJKSSJ7?E1JxLhEsbz(&__?3y@V+y9Gu`b+=oYJ0c~R-NLU z`b1&f8wUP3`@bcO(V&Ve^!)F(9doYduKv$(LhJe8!!d3djBol@tUGZq-a4XBTDH)6 z@$v0dM(?Dj7aVh6vHJRPDYKdX8FK5tXl?p-(M0gftIHB=ra4Mm3;4aMdct^}S%k57 zmT}ay3%6{$?|IAaVm9be-m+UH*(Ueo$?wZ6%>-}nxp+h`+1$xAJw1N1iHIOS2<#J?&La4Z$7r$S(3%;=ks~ea`U4Y&YZP!shFM9 zapG>lVYV&L<&ecUadLe>2{ce;)aB?QUJGN8G226n1hyU-(p-A=T5q{O9B4TNBe7WM{p9@SmZ-;y=S( z`BQs-o4zopKfb5_UH?-D;e-G7|6{73u{t!2|LcE-55j+rMlImb+xMz|?_XX=q>eb3 z#-av7So5{~C$63U849lR&U#nc|C8m;e})~|t!Eh`yMDcsI8qqvFU8ljNr3&KPxQ=d zE~WDvUKp&Ac-_DpZ&QDV{EoM7pHXo0^{lM8nB$zSda4n9MO{xc&&O%;T%5%)NporA_ruD^ z9{-rwVVd?jXjbKdnQ5G0u>m(iyCBS z8Do%NH0&SWv;Xe?X}$G&m*#)AkN-22)N3)!gQvw+8{m~WgJbFU;J@!*WO2=V{cid1 z`xmZ=Fa-Kae49P5%j7aDq)D^CrRTQG4}^FP72+W%_V|Ng1}xH{cf{Lgec7oo(tKPiLu2{H0jH`K#&ztNai5 zE$e@Nk^lbjKf|$pWX`(1cQ<(?S9eT3a5CtD;IXP&P2V%jYcBRruD>T=e*NWp2a)=R za+mf$zfgbw_%D3BA&h1HwMo{iD?_#vA9=+Q6ncT|7~+@AF})&7L}0 zD+-RzU|4?t^OEY-6^|n0DyEtJUKhhq*Vb*YO9PMHHD?yiFFqz1Vrc!7d7j4`i`Txt zW4BLH{p}JL`M~aD^N)*Z;;#D0$pt0tY)PJ|>hN*bF1eoN3YS;%oIwpCv;fQY>tZ0J zV&&c^Yi%}0-Cnayz34Kgzel|NP?r{o_BwV|Qdu zSjygr_d)j)6&vpSeCT+EWs z%2|46N8*XEa#t>w=CP!l7gMot-cxhmKT7A&i^cyLIKEB&&tTX5@1OmTizvKnjnfR) z9CNwV&Qs2#`F+`0`>86L+wHR7o~tVG|FY;{Ng#f^-K*Z;+>w8*?D?Fk%TllIa0SIjSUpjW)8uSQF{&w*f0%rnz*5GYjr+xbx41 z(Hp6dMoF|Mi&-XZ2|O!(Vt=J*qw*_F)~B1T7u|7*WYk%BP`huZ2yUGQufmF>xf=_m zjzs4@Pq6&*Z>#p5gEHC5XQdYZy_Uuxzic&AKF%Uzt+UN$zlTZwsuIgSJug(gEw`t1 z(Z3Io(I(5xCp373vd^iSclcfdzTz^?`@-~s+Z}g%+F3U^t!MfAuHt2|-={_WYKqFj z{WG^UzVo*~)u4e~!kQp+Ock!kc|87f5|EBin-}rm^8|zN0_*Cp3%KqhM>|Ryi2hx= z|F-M$S^ElOZ=C=6e6OAK4E4KD&dbcMdXrH2GXPIBVVSR=q<&4uE%W|UMv|cinb{>) z>uW^toZ#saFW@|xzmy>WZ;_GZyuwp_#^l?rQ$r&|RqjX^9*{h6+*Ij)l4MlG3~%9_ zjK`;+JXV$|XTQ~;jVJdT?49J18zm9CWJm1n$P-+Klh5&Qcp3IxQ0^rI3(p32iv>LI zafaNo{=o3AN*<#|;WweT%FP+RyuH5vahPt}Z`U=!Z*M-|{H{LoMsI;2 zqqLXVzQ>K%m1X2=|7}%Wd-|;MaT6s?(a;UjWg-8V=kYS&Z#fWC5fZK{X`&+Q40J#( zbk%D1Kh?+oz4#ZxXe0mnKf?p{pIuu+6aF*A|7T#dKNGr&p$Xa`7qz{9*Z=$eg)20e zvV;G1^8fDsv#M=1OSpL1OCz^aO2xkq7}!<({IfYc*Z-G}{X71r0r#R#+FU#-vZ7UV zN}JQolfgIJECU@x(l&2xy|}3BhS5nrF0JP8mp^{}b3E$Oo>?v#iXCq==jZ)N&p4>k zU#GSHhThD{XLk3jNJ(Q-W8F5@_D;{Ay@g@x*8aP&BJ|Hr<=huP&hh)X7dATxZrOB0 zrN2-)#&s%3f%%g;36Gg&HIE0lPEdB$U|6;LV@vWyf7?n~Bg@x;Tjy+QO5b_s=*5Q6 zLk!Dp^!(MYo7^-xQhm9=X8z1(vlq^G?u+G`8*eqJP7e6=^hWOTr(KIDFr+ce;VZuJ zxhGiR%FH!ypHx>$Wd_$zmosj#w3#=j@8`3HvD$xi(=!96PT2Qe`?+(R-~nbGfut0^Y|nC&rt5@&ZG`+lh1do zPkmHz3`l9SJG|lR>JP^hTb1KF7#=YG;?r7xBQnWR=3q)+*wlz+?q~cQCBNiHF)w($ zQc*CcDZP@Lp^MEixQWk?{kdTu-`c@qO;)tU+$*|)K;_tVB{EA8s&iAAat<=JYV?DV~H!`-^#^~5|#XZe)-yX6hC`~IT!3Uns)B#<7ooD zB6Z$MKUTJrV5B?&#(JvvGCmfoKQ9S#WJk)QIs=kb28ODNV`9zXdk z&2;WbC!fq6uKcHVa2<`9wD{7TZJRwyHgB;Oxx>jNWW?Z;^5C)Maj%Q0I&bWqrMR*4 zVdK>6nMT&hH#RD*39f+zryMwFmhPT5wLQ=mMU%5^Xh(`R~_1FW{0-oBK6?ixo?7?&hLxW!v60?|&JpWAb{&tgEV##ksqA zV$F(QHtu+SUvw){GALne%}%b+TXQc$wr1@k=e=d0IHW@g*dOqly!N)dJN&$>O{X|2{lsk^Rr` zw(xZjYQkYin`>9OVCua}rCDL0&3KoF^zS}re2l#+`*y5{RBpfY&(nHWw4&cJ6wc}6 zU%xa9Rdc+x@wbdK*^*1P^)alKJiT+`4WXUqPk(y6uJX9VS+hsi9_7zIHC4>RC08U@ zPMqbdik#&u%WrGrksQ5vZu@4pnho=}uVJ3?j9X>Se}>{eb@3;zc3+*acgw^hmwp!I zr3Nt`yJS7_blvX3Ky^Je>P*g!sEgd=T~4l-Z>#XBjBX`v>#84 z`0TYN%|?pMQnqf#E2t@|LDtnA>~3g*#E34hp;ImvULNF{cX`PZtGB7F(Gmww%G4UW z-&|fB{g$s$rnc2HEarCJVR7F%zY_8+zaKTacI-oJ zs$UVvbuz$L)`przCH;Fx4>= zzHK^XHMfT{pOn%oue|4$59;TA-H7DH62{p}Z~NwEXNz3xiu8V0d*ElJN>6R=s#@o_ zd_fuyr!LI-*(**Vf7|zj?#s%xAW+dwdn=Hg?T> zbua94o}!S=B`brV-;S2D77U^Dk&@X0t2<4P)GOCYhAUZe=2h`7sWA!0=R`pTz;$x~Wy?g!9vRbR1J0 zmh?wW273orbfQH!v(Y2&8SnJZ6i7~c$q=+=aVB?Pk^9S8tDl_AUvZqF{Vm@#Mh+If zAMbB%hn7Re-{taW|K4vbU0yh+Dy_kAy5Fwt{rOYB^?s{!b7tJQU+&JoDU)v8o1xr& zBFXN=#+trW&fo7;O?+cyyBal$g@0SUS>dmq-$`e_MF;BItnE4d+00!=_-MwoY1X8+ zrwO<*9{2gO66#=B*s<<;pRJZK{jK#hr%NI~PfaN65pFy#nsv?6{!;2BV`-nC93CnR z43fuXSDi;m6&YJ^XJ%}^QM+_;ccS!^w-&OU2VY)Wd+YXDk%FJw`Hl)`>q~nck9lmr z)*mGm#@!S5)H|)mGAS>vs&_%Xp=V~kPT90om-gh!WJwurXKB1JNB+W9loY{pQ#W;Y zW%Qf>3~A}Di;FxIZ#-u2TafUnpmMcXrtzJVg*IwJ$q|R9v3#85FT3-v)^%ieGOt+n z6H?-qr_x`^Z|EyrDu)qGF;eh{V(X3Ul z37HT^R%l~ds~Wm!Du6LxxjUnw_52CTQ@?7n{0;vzJa7KbaNql%$?4>Oz2d){e+KL2 zCv4SHOJi+R&N41AoY#D(u7uHi#(##-2mdp?U;3Xx%I5fghI#z|8EW-^Tn)XND|waK zgIja`$*|EsY7`(^)QcVx>zYlzLy)c<_&pW*wZ{|voy$^RM7v;Sw3@bh@y{|C<$u_}UR3|WX^Xb)e}?9NyVU=+Xgd*{zalih zHQ@5+;8P?Q*SvtvoGjpcfar;>X8-k{;Rolxq_qJo;?Na#E8jt9^Bh=r{%3IO{(JDx zs! zJH<*fPN1?RPnf(`d~N`w{_8x#JVRy!9~) zdm34`f%W@`Hyrr^#m6589hGvH=rg^w_`V6_%%=zc&YE82@afdaXEq<--fNdsSLvH; z__k|9zPf#8!G$%20xS1=s!ZTdJ|EXm9JIG}^G03C!!n!l6Iy<+E2!71zIEWmtKjy8 zvrX>G63UksymSz`9I&%gV_*Et=N-)^InAuabC*1u`TWl5x&;y~7j;&g-7?ietGMT{ z^_5RAFN(VMBvdYPSG}#y(DQs%yAv|M-8snEy*)E!U7g6iM3(T7Ir}+q?iiz1^S=Uv9c;4Scx5K_C{krhNIX z-z)!p|6!dBPj`Qo%Q-pftlwUFa|?rU z-;)5=E-m9ip%WALbWGZDqIX8#pOwqr-He@Z$3?R4({xGsD27>G$>(_zyH9m*VY)qo zhxxL}(Y;&CLcM21&VJXZpz>FPDND24Mqk@y(_)Xk0R}2{BEPU^vTQ^&q$6Snel{vo zSjs1>=^_;J-t;#mu`Ok33cUk@U z@c#_^c;!D#&aD4@^*_V=<`~`R%Ugba)$Uj0UC=l!?FDPzhYwzF=e!mT+^y2L|DRB< z{=cgIe?Nd`TXPCGCKSPbw^K~|cE1Z^2a5s>hxbshM@-CCSz$>enn>Y@NEOwf* zEqR*KnsWDQ_70QRona<3+Va?*Ds6dv`k+D+ztUba`LBlHmQ8Zhq~+Pt7uLLrdom@^ zHK9as&#HEI`&RXN``Q-G{+qet1=IO?``Y?#Yk9*KHR$|&{UYP@^$S8nwH&K`b+QUBY1p+~s{HVu;d}__AOnW<^VycaL$t--Z?W2Rc1L1i-`*d` zCC*x|c~62|9Cu;moXi&mOLeiQbhj z$jWni^43jN!v6CvmHm!8^82&f$4}O|C;w_YW6`%dXR>SAsfixbju#6m27gZfQQ-M} z^4ZvB2v^C~*nhqXI$nW)(ah(E|1;PIgHBFBINGi&eLnx6ui(=SVA2e~H0MFJxkDub zm|qYw^n)|cN|vfF1_A{MOL6^*$$u~ZS$!t^^0NO7f$G1P{|uj-IdRRdscUk-M}?k$ z9$S%~s#chE^-kc`Oe@p9^X5N`Ju=Bx>FM^Kx8Fp=4=V|-x!+y?HM%aQDs6qmqV#U> z$%)Ek;`YH2`-FCMalZ@;=iFzb=V#>jGFUFtDJa!@nsATcg}d1Xk@wwm3#SV4w7;=D zZW?{W$}28f@=@UP1t*k$v@cwvFYGV#tLbNsbkf6(=PcKCJI;K5A<;-?Dr-@7LxE<| z4p(2%bF2J9ZXUY6-1*-k@bVywy^gY9UhHM*?LW6yPX4PPxUh*+z3V#jq3E26s-|}o zPA(5AI=-jyO1R>!@HCwx^S)eiV426TRH3;!^nLQA>|&luxkRor{CDG?fBIK)VO~d< zt%L2H%RgNt8gpB|N}RCoSZ!D19q4F{@lU#$=3 zA9*&-*hJi1{>3G$6Azm;W0EsuPuQ-E4r@R2W@d)BWWXU;EkDNdEMJbge_Iim^66RU zEQ501$4`I#3e9+Ae~VYlSS0s3|LVg2^M!x1S)nD~u=qVZD3z{;I|Gv-4 z(ug^~arv|3&C}yJ*ypu;kzcXm(JuG9dsYc5_B!V8abFrdjl1`g(xJ$dX_n^iBp7l} zyq@#XukBhy-kIOrc@rC1`louHQ2zA%Kf_vgEpe0GQlc`Kta1g9#m;z8++eqStM;+8 zN*iWg&<|xSxF6H=FI4pAj8>0{r?%fuQ4p}*)d9*HTXMW=3`Rg(B&&#o? zJ*nP)oIfXSYhvH-f2~1E??&&wh|k;Ka7i~GE1pwwe5*IhzLM&$w+d60Ef2DbhFPSx z99KF#f%}na;-_?pZ*PBHU7gVr(3-?86xs1rU9CZdj^|D@p8W29Y4x2LpXq{*ES}0% z#*;pYGH3?gkbfWA^1J)Xs_k}J@s2iS?~T^vwI~KSs&c$?|L)76GTnSaOJ?o@j#z=I zb0(P^#5_*;x_ayULe-V*YKKlkb$SqJ?;u)wMp8huy4|) zJCrgb!!rfXNrv|cc~LSY|=3ggSm_qL%NN3nCU38U=OJ7r;$VouMU*fXcp?&`V!42M#RkIg^+ zx9mT|n{4+Z&;O~I+kfEy%M;GWFT!}a{!q&OFMR(QPTc?7EB|4p`CsP!pUnR=B!?*6 zRE|De%A+PQ3zigU+BIE5+!zD!??FFt}7D)w=(BZu z{pNgL;)JH~XLtDQ8N;72=FMSj2=)B+`Jd>q9|ivzj{Lj+kNrQx0;xAC{~7w1fqIa$ z1DNCSj;AQk{_6s6pk}hHW%+n&f0Y@JJ#*Z2^Ix6zckNH@Ikwwif5yY3FHcqRUNOx2 z6@TKs%E_tuUJvti*6A!YyyF(~&Eny{w)HP|J(-pGX^y1s$#eH!)w=%(59HgrJZ8D@ z@$(<{vwt#~ZY!Q0%lj$Z^WK?9IcxItmkHi>i?)rH*ZMsVp|4JFW_VlyVmlyR{-2c7!7xFPaCBnC|Q)5xrW9zQX^=nOKBQmz{mc8-(@~z2l z{xiI-o5IK{YJc-T!>zv>zwLj=FJ*A_IJItRq_d`kLQiv;-T8mlU%Er2nRcyO)auH$ zAc4VvRoDMp{kQ#IU}*=@NfwXqK3%l#@y=~MDZehSs^9#dVe79zunLBzuK5sqYUlr5 zf2l!X(Q>dg^6CE>vcD|g&{+8o*$OVLQO(05z!W8!8U9U4`PF}F8A^N?)w(}*^I!32 zRX$20SpRHreFG7*9NTP?q7CL3Pr?wzp^I`Ml}YI=SJYpZwE19MAh~i!WT6 zc>ngv-8nP3mTo!~B4FL*u6!qe@f!=*zL-tNUY&7XXZ%@a;t6HReTlKHc9@D?QThgA`w3w%7`7;X{!3)1G&-=u2IInnWZHv~V@?;AJzKSmkIF8L} zJ$=&VlHtwMf`8PN8w|sXL#6)RO?JO`#I8V8vR}4>Sy@E-M96N*=}C+Bb5+Sac)qWe zl_C19bv@o0|VK6F_CG(@pQ-Py;uT$gE&ZlsZIJBE=l5?|&HwXr|1+S#PYz%kQJ}; zvi+uHz7Yv@P0KQ^+J5~PS1FWYaM`>%W)FkxiB(6w9X$UdFyHEqTP!1kvA*4c3H4J$ zvK{SK8=rix_0vOilDmUnw0%j>w>96lPKiF$FKM8CcIqUt*^{1U-r}oDpI=|aaBbEv zjkJuLF`M3;WB6xw%RVq{HP7ukOw2m#4(2wd#rerhp10TfvwxGA_{RB)M^DVX73n1) zWmovQMETvvd4_Ktq{5B2Fe}~j3}>0t$`HTqnaJzRqi6RNYZUy zT2Oe-^82HWPd2M%J~!Cxqqj)ocjfI*DgAjnmmP}I-fYK;X3Fq9 z;B9q~+rQLhSIwJA$IfhY`#9xR-5Vz*apnCI^pF4q7xi? z*7P(+Oz=?nRQUF#kJ)sdNt>6b-V0Q_@W${{<6*`L6|cK?KC9oT58g_7=08IcWDlmu zyh~4RyDV8UN$vfNQ!h@>n^Ac3xL?(y_KkD58%~Y$otW4!J(E-2?%2AY^WS*?XQ;dV zN8_{o4d}K}mn}2biB;NcxK}>o)RGBoXBV@}%s;i}=8+3dfgLKlx68fp|GK;qQyl8;=DuB~MLdVPJfHto~R7 zJA7u~Jko>#-UB$<)`$K2&*12{3`(OYW&xikIg>^3_R*(DIASKBRGH-Gsq!hyOM}s@ z_x1+kp0sI$=xUv1+e3f-XK?m|(hhv^3AVLTh-o(xb|$%sFa#37*QpTVT-(1dI%S%# zbK*?h3!4W_o_`pYns4CVv9_oA%vA36$`k+9Ph63@W!9sgOEXg%m3=3^xmBJ%&8GQ{ zJy+YMThDGiyBlRTNh9=;P+rViRj+#P&G0>YxGFdZz0c0$&ycZC7SGl$|h9)3RS(F_FG3_6~~Fq6*HdHtSkFf z%PW8V8QU7;!v#whOjQji@G?l?f9PAix@3yW=Odeh8(I&j{MA}FJ73FNWwXwyGpqLR zO*wh2TH%=GtI8Gc)-0L+c1MT#oR3q_*(Dgxf9)Xd`gCK%IlV+f=4Q2zTjbYj-@WZF zb>h3Amcglw1&ngXR`_OH-P?M|`I*+aO)M--htux#%t;ZxH|^HB)Oq*ZJ2ZHWCr&8K zvt)k#WdZlcI|p^zES~k=;XNAKs8IE2V&2<%%33il7n`?iC~&Zwxn}>Hn`h_l(P}ai z@RpY8pR&#HQe(2siZdV2M9va$Su3v?t==keK)!z~Lwv5+MIQ!#>CQQejCLq1)YkJK z32mDwI5qNW^{YI0=bP=yZ{|TUojwzlSZW(5o@P59lfu{Dwd6xwl4&1T~5*WqvWMYuTK@-FFN4S4G3{)c521MeNfqtE7v~nHRpCK1x;y1e?O{L(DK*jgflcG=SO}KVE>CA;UiWLEceYPuJ z$a)5Sy5(`Evyj`3kDHx^`Q@y@@|*-S3igu+V(fnr*2kxqhlQ z_at1p6B#3^I?dp*xKe7kT^J2CzNfwzVtu4QL*O+}irQUgl zVOqdrgM_pCGO!j8g`uiv)~E;vB?2l zp1L9~v+v5vXDA4_v3z~JHMH6?;*Lc(uj-i~J~yv*cm73~l=8K8%oCftKxpAqH!n8n zhF>A(<{P8V3;CSrR7i@wp&@bn$5riW%}ZZv&RZ<<`P6o&(JtqAp8A}GkH11^UzrjY z?Jv7?j+?xqSCbK&;Uo>F({~O^_SjrpIr&{`!`&}m7p_Z)Ji=>|6!yd|BG0}xX|B;r zr4S{jO-{-wos+pwTBtTYe)ek5$1kgkZr|a)kl6Wc^I~ITWw#s0JlUV|HXgHhPhi%dK%8Khdo=g7k? z#PR3%Rgbmr!YY&v1SZCKDo!qXu$t`{Tk)T`DU1tcukKlQQuc`7DI=#HD*RE(ySGhK zn`YfH&*b;HbsX}+5#Pc-#oWBjzll+%@Z_WzMzsfSY?hMeJdfvn)!4dwk|ej=6Sm%| zsh_^@yF6*hdWkRRYc8-&zx8%czx`XmO3ULj_vHS0rM}8&-zr=8FsU>e_nCzld;VTua3vPDWA;? z9MAswTf7%B>i=V$V-}hCBy5=lzyION4^rj4RwpGK^h)Mfb9A(Jv zJ{>GLCFbzc_2Ksn?4`nXZ4Y%y@8Gn176aPKb+S`++NbK4ZT7o&hGmrNJ^sC?>ak7p zwdGqk&D2w#`skL~nZk*m#1b6-Y<3XZx0XxgfJo)S7N1ZR7Qvnm_3Ny=woDIu*Yn!O zHQ-@KVXIyHy-i`KUgkV$KcR9mWnzla0}I}R&+jeYwQ=ID(msX2$E_hL32&1;{;c4C z{Yh`_+r@8gmU8D?hYK<9_{ASpb?3n4E!-w)p-+xUvd-jS4!TVSNJ;O!uf)YjyzcpPO2Q;vv$dc z;|1X5b#4%#IIg>ejb#48E<-rgtfF&s;bC$w=tA-=V3oMU+GU+emNtiaF;31#o zVVMN^GocmxpBNVZXNXDummj%#5&OR0l+=mq9$DP;WSH`V`ThLUxB3?3ZD!Ttus1w# zK>hQVMeY%cGi4rz2>CA%ov>ad+(~p=P?nSo6SPX=?ae*|yPYgw|7y)!SQ7TP zrD)eKZ>hJ&Qy(i^^zeute3iB9#?+1LW$y^>aH-jNx3T$;I{Vj^uciI|GxWcxn{NNh zBS8a<4TL3!wai<)xnQvZr9j8^GWkt$K<4^+j(aymlw|ee3T(KIQA-AY*UlNNsA|6 z)^KNc9~N0Fvv9e9;Uq(CkAwdi?kaOseY}5PRQ2NKYNfxClAb{D-VNX$%_=HC4^eIx(+c)}lshyI7`0XHFfEcR40oJ?+=8(B1$yy&So4 zjn#I>dsaO4v#NglXBNY5k(EZ`z1uZZi~Alt__t`zyNwIW6ILx&ncTpd9L3h=p%SU` z_vw{Wr+2)){drFA%PZ-&Sv`|ycPtB;=I*JxB+2f=xgrC%hYcdXx!A9~(#+~TU4LX& z*w%@&zpE_Po~GWn;OnZQyK4{b&dB>H(556CF_pbIed1+X&bL1TR5xz*@MH7OI%KYw z6LReNNpb1eTTi=kk5x>UJXT=*`e??>x5}9ZPAW`(pPS&FT2y$F*{1ycwe}5Si>9h| zs`k8dXPokQg~_kyEVp$Q@!L!^y18(BXwmNb>>GX`fA{fxeAT?_&Idb6%L_IL7Th=d z-OkXz{Qlz`0SE3Z+MJrX=z_|`xh?m+Epz5Hxz&3uue%(5YNO6?5f>g`)x#^(Po9^s z{#~>D`n?A8m7E7ozK!^NF8Qj6$IecdgHXi>G}J;W*4+&ADFc3RNg|B%64nNb2nd9$}hFs#$42Oq_51}yYq>; zTc%jV_BlGqWqkJ-pSw(4vLeVO-0i_?p5};)mD7#grOzA0 z#0ZJG#XNFgSNOI%)8y>}ofDDE%^o%$^UU2_x20r9>BcgR#Z87XhD$Q6v^1DMEx*R? zJ+)->?x_#d1fOwwCw4z*IPxo5`A=s0q==x5Yi^%{UTB+4-t;!M;lX|t-s4}7GUQzh z+47&kDAs~g^-gp_c$j+6oSGv{74Pq_O;bI4WhvvtgVV+C7(Sey_e}0TL;d_j_h`lo zfe}p4&s=#N@oYlg+=&NwBppcT5n<*svamcGvtd%^a*w$;W`}C(+t+Sx@L$ht-?4z# zN?Sf;cIuIX&nKxxID%8EIxMAbPLO@~?#a|Un|3(tK6mw}$ULi36UMr(gIDyr?r-P| z5BE%tT~@RwC0($wX@{+^C*u_FeEqrFCew`;hE14y%ltv|@f#N)1c4>Zk-Z=Y9F+Tz|j$@!%8 z2G8^My$tz*5tDrj|1JwZ8&asmadlZjq=9kA0mc2@^X}bPy(=QED>BZ#EHkF&oCkv; z1LK7N)=LFO)xk+f+0t~P%#ABIZJte?IY(gAwvdDeCMgMwmkVAWU+bKgzI{{kn@?Wn zzUln-)G_DXao~mFyt^693s&3<>3!^;W73}0Q);39lR0A91Emw!wg-9U%=0#B3;ON% zpJDbh^~;j7D<2ixKH3vhxk~T+wDOetm2cn9Vz{0enC8)4^NusHZ$YyCnc!xorv^m~ zwtV(hM=#Ga-@hf%X4092dJE%ex9;n?@!$Owva4m%-&GlxG6m`vH*W1XmZI>e!Sux% zw_@QvM*dn+Yp-1|o4RTB1_ASQg*>}0Khv83%Gf?xofi60bIQ7BED3oJ<{9_LlrP}z z(&jSXF-ddDtjK8|Z>Ao&6aGwbr$YIona?Lmnq3d}6zt_a{Ij)7=&-u|p~Bq?$r5it zX(y;;jcc;W#iOD})@EI|4!stpI{mat@6D5v-~WXQ$5ifWT2plL^O+Z~@}$cQ4zn^G z>gnSvc94GY>V>R?(S{QWPXztem8RZY_VU$a)`lbHn`5>lSTOeeanh&KBe;W`ML6 z<%ZL?u?g;$%%5#t`zs_oIO)|3?v-H=ed=7CoERoV7(qtW}>TNR!&_b(S=T&uH^t8L;2 zZdRFcb>^?8s>Ow8V(+r-e$2}#u_Lps=3HHp-Av}LjXc+RS4_CH>V!(c$De2X&K3UN zlUOZ#^Ir+$PS?Oo9=}^AT_I<$`>=Pi<*g9G`7yz%Tbd$j7E7&q zqp>uEX+e)nRp|On{~0b<)_=VJVey;&U+%^KDgUFvv~}+mvy3@df^@kdi7Y#0%o~B7#Qnx2C@ozl;gV4+{wiWYId!t|f zWwn|Gp->m)cQ`D1awp}zhOq1gzWTM^t_-3q*B)gqnmG5P;2nWvmIpoajPGAtz6ezl zfs?6(Ry(FB&hWZ?)>vz*zd`dBxxMVR?CR=WTQS$as=DUpZF_aV+S)oVy(YE)0mBPc zUrbf#D`(wJvQ6}bg+#BcJRX;MVxeF_Nnlqg=ICEY;DL>2byoSk^w6C*hbLqUe7z^Q zW$&A}`s=^8xe%&B7QUo4%5*MtohvE3uf4%*A)0@Nl#2(eo+)q?vbNfs`b3L?rHc8r zcTWAqMgJKJ>b07lUDeB9Sh>(MDdL9g0|8F$KK=_ASer`}TWlX6W>lAdZSm)X$oE~1 zGRkMAHcB#VV3*s!G-#eM%ZHQsIdUfM{<>!C?mT#s&b&3e?Nr8tnOsfBE+z%>2brhT zEov~?cR#bK?kXGOE&mx7cJrf(?;e=U5m#|7>_zK=3w;sMC+$9 zM0MWl;;zQ!8@gm0|7CpFeBq#MTf2hka?IP^eZ2c?CBLUHT{TUnQ z_HnRGu&<dTiFdY;KRF7TY}&r@3;UJZ9W~Y;m;b4dW@ZD>HUXT>N6~7$KQA;~ z6)!Nk=P}P%|2uQ<{i)u&HY)T!n>aDy(AviysV9!Je?Ff#*ZSJAj2Fz`19#1wW$eIz zH*|^RuKe%fKezhMYV6Ac59l`tBKEj!z7Jcef%oQm#?@E%?Y|Jb5<;zDQk@(1^Z~;= z*D&>MeD#Nxu9~RK8}{(jgk>5Batb_j|Cu_yl6<^->f+8@7PH@KZuLAZ!^FOy_vZz+ ztD@)6W}Fm^T>E62+jco`E#XZ;p2-ux`*}R?zqD*>YNT50qN#J=B~36o<~6}A<@xet z2dQnJ*B(i8VPQD4=U0>Czfk$x$^Xv(&b$8U&wgVG$z#TmP4{P3Zs@ZxbzqsYf|ZpGJ^`bTVzKKIE( znO`z{tKy+_=F`lkBG=v|Y!A*8Q@OWkarBl2Cy$?PaI}2Rdp?RK&sWP)__X4!4sOF^ z1)7H^&N{zy`y^k+2c?;*pA6gLXKb@Isyx3pWKXMnq1Yya?1F6zlk9ib)$VitUTN|2 zt%LNGP+eCQGp(}Cn{4t9x_KUED$wfL`19kP-G>d_cJeJ;pvQ58Ez&}zKBg*w?XKyK zRbpHbjo;mj>a7k<vg>wpzRR`q6MHH4Y zd%R3;+>v+q^M8i^x-C1y3qS8W_EmIta_+b4J4;+e-(J~y{9esG&v*4v%U8I3ir=id z^0QdPhkxG2qAWtr&$+C6`0Jylt$7nv9&Wx$ZEnyb3l8fgVF}fRJ^vZ3PPUz$zGh5Fv$$PTy=5tZ^b9Y9Z&dn>nyzu4us^r^#r3_~{azD5|+T4ij1lc5hMz-jgHOFqByClQ&yZHFENfFB`obN`9 zC%qQbm-b)?s7vZT&2;n6!3DgNwRBDk+V4r#VY6!N`OjeJ=M>2-s^xL+a!>!M4LQ0! z#kcotTf-r&HD9H7XF~Y(jAMo8t0rB#l-hSoUbm&_xb*3X4QrYgepk9Xe0NzU!Ole3n$^b9y?L!S_K`bMx`4qT?GUpXy!Mxb9%5Bv; zE#Epwm&$Bfq9x^aKu4tT&K&+L*F?9jz0nmrd(z_*sgrY9&G+w~_Om}m@b#^w^X^^p zHv4TiUun@EpHm46GUgV+CoRr-$o!hcaA(oR<=y|(x>d^Fyooj3Cp=a5)CoQj#y{%o z?Y6F4BW=On+~+95@QOe+j;$$yS1h|Ue*G7dR}hNf)w$+>(BlO!!l(8~*gGe9RLfmR zc}G|PBTu2Lvu&q6+}hp0`Lsy=&VK91`tzbMwuWu4Jasfr&t~pf z>n$CNC&@41odfElm4r!N$vea0T=ywsTF9ZE0?q`x9rE9=TE5R)rlFWw=97|Q$Z{f7 zfq(BYtNBq3w-#+u-n%PV#_yEM9OY$a1jHo^te!8AtNXA*IAHH@mC2JH*Y5T*|5*_x zYt~TYZu@rybK%`&r*{WK-8|J9xS|%eQssn=kYQ$H*ej$JyU*rFAGaLBg!qi zhT)BS-JJlor=l(S`YPKhr#)CcJ#BJgV8NO4bW2%_mCttV5IU=Mc8jY?VMkeyLGGS; z#`9KAGZ;CJ`|!@ceAA8JTz^^||5%;=pW(WLa_ZawrZ*x&3@VQ&Uz!`qUs#&2d?a1Jnek+R;m!{S z3NQDs-)kp5vu%M``xW5e9za>AlGs^a+hs*5A3GSB4x;uLGPv5@QV7_9_m06j2YUR5= ziAjdqY!X??!hF)^$@3n;+iM;2(|?ylt4(|~Dcy03LkmNN{Lu;SaZ?yKyQa9-S|81+ zd2!fww#U&A;sv*xYT4Chf4ei7FV8aMTnzd0QoUqq zo_VS~!%p8H2kgx*H&p)F81nCO!PEG+IyN_#w4dhMuOPj_UGn_tc}12lotc9)7tQr{ zR`OsxsBz%Iui&6}w>*0^3x&Omr|@y}ls;M!y=L{pse;y9+U{##R(|@z(7RB_Fe=I< z;IQh7l27Mng*4CMT`cpjZcFI~vHuKPboSiWep^sE^Y->LlINEh2d`c&#&uw-MFPL` z`$(~mcVi;_^Cmhz^;B8C_lc!s*~#16e_h>cS$4K+!8|o)`wy%Oxcgp8iBD`=)iW)* zLCd1pqy! zHu>DonQo%{LSI-HzRO^`bXIsn=tPM*57^ij9{kg*GVS9@lcF7}i=WmdH`EqhHtm~U z9ChfKokR3Yvx#>+5B~Ly+%YTLJCf_}>`uNjOe-YIWm1xv;pf zkJEN&MDE%2yG-nfo`e10EdMQc_il+!D>}H8_vz0hH?AYhZI9)4d|SXfOIz&Gzo*}} zZng~F9@(tn8m4YvUHPE!_O)#xlNL;D?qY}<+;s)3NT35D%u9tL)0HnqgU5k&<4NZK z4A%osX6NhF#Z3EX#k@OPLD_D{*JrCO%%gfH*z|35mD+aW&O+7BCli}*FW;*e^?YjY7(eX$NzJ=X`v7X~y(P?u9lP`*J45u=GZLVEA-pUO|D?xAzWG(c%TUi;H@g z`y9UfWp&fdy>h~JkHhJIn>p<2*RKt~oHEVZQ}&<{XNt6Ux@jD?mbtrfcsq6i@+;J6PuQ#2s$s?B~r?>Bw?i_OQ`UQlhPvd?gsfBZ`hQ_Vx4=g zz*25%8t0#v>ApKY#itctf68vZmVxcml>>@q7k)ZCQJ-e^{JO}OCW#Z8LV8AQB7A$Z zI&uI-_)K5V=y63e!F~4cgMCj8FMLy&x2Qo+CGc3pajAvH)3gkC{F;@1bM2qU<`d;- z`IWzs-fy)sd9{0`MQ_dix!lW6I?M3C=YMF^XZb$Jzb;|NR33+;JaIYwyXO=ika+U( zl?Kz1vJX!0J~~Soe>$^@F@OD9{(PSPeIChWx3}vom{V1&HFw>5mVN1SRrl0I1VyIv z%&@h~vwXbNUG|1}{?3^f*BSJvSOh+0`{N#G``JNCm&fP!EEAQ-lNN70@n@yjE!Mfq zBa(%-vpFm-{FAk&{8R1Bb<4Kj%zrvFbn17R(t{Eb7GKUf%{r0sL|Z1vV=3E>WqeBv z4?LHxUBT>>U7^Pyd{|~d3E#r~bNO>w=Ecus$$$Fy>)HjI)5gxyUi(W=H68xA zL~Pn=&8fMMgoGzOWb^!b)>Mz@n|EQ}?9b5YDDg!0Y)|^_wf=b*w|>#gRK4b)mO69Eu}ge>^7{%e-)k^c>atK4JS^qb zyl7E_y;jDy2A|6u$wC_r)-EoTk6N0}k^Ov{r1~eNGxa9t9^T%0P`&Z;>sh5&zu#Ow zMMvk&BE{Y(%sV??UZ{^^*weM5QP62s4+9&6sMM`!m1m{fJ5y~_IGE*+&CD$L{PVO* zlBH5@kLY&h12!`J@m}Y=cOUl-OJ#E|RbmZ4kigu)FUw}j@AGv5Z;PvAOTc242Rubp zSM-xJRrcjf+hEf^_pOBb=T$3LI?rfNXE1Vzbn;Wq7(`}Q&nsXtH7J3%ys)YwEzAoTC&Er+Hae=Z;tL!=dXPFys z-99SqF1yF0|NGPchWmk$-@bn@7dJbT*k_^Ixa9V;l>ZET{C8iUUtcwe`)6vG>DFzZ z4Y@oXK6}FUf>HUIjogl37g%q+eb5=0+-4GD8L)~W_?4~ICC|)UEtX05)E&H8Q&>{I z+DA3M|MqkLuKx_-R?gpdy}Nz>pY5;Elzo%#ow2UWow-!{`5ZSki3cgqKgeBST&%iB zXo}Hc=@~zrPJt4qjnZmkR>s*YnJ0&=HD%vD&9sj}a8YDr_b2o82E+6ISvA*-x~H|> zV>Ik_woAEv-GaH#pM9O(7RI8kbGxscU3=-s#iLs`^`$YM^D`2cY5Xe7Yo+UQvg(6K zuhTS^%KdvJ-UZ9@Cvm>gVEQXM7kgHBnZD^@b@?-f+=q=R4Dz$>&2!3+uTOmKAY~F7 zojp@!=EHfSU9JHSwBNDFd_VBKtM@C@uJ)TXJAO5O_7c6VylSOP(*-oH{W!#OFsDJ?dvGov*wIbd)3`l0;v}HlkFRxFW;8I9M*O6-$kX@XQr5B^923exH=`(>yuS_ z^YLqIGJkd5+cWXs>neu(yQX;Tu=^qN@lu0+U}Sdb(|e~jiKqVd4E=e6!)8HMxopMv zv);0Q=BH(^T>CBhXIf}#?Qz)xH#R<7V+ZjUYnEJdc2|seG|5%N?5IJhVjsK3>$mvV#VSED%*dA@OIB!H?LA% z@W4S)#dP)sDu4D&KK~MAp5#39X;)Kr?4G7Di77c!w3BB+9``wSr6sLTqh~N}d31Lj zhoffh(VES3p3h0Y{zrp3scU6%^|wkDw|k zq#gP-hi~4OwY7Phb=>@CZfp{n`h3CN3&JmFF*NzAiTmrSOj9xBhz#hT=~g(W`Bmoo z<;RZBOqr-+RM~i?XXP#No}OgpeOZ=UBc?^Pq->J($*bA+in+kz$&=)sD`!{STH~qq zEm5tkwRh%@*9Rme-aGJb-5wp`lX326T2jQ5Nq)XzTQ~7-&n*;I*r8IH;}%+L@l~~- zeXqx_xwBZ+f}GW7m@PIx{rbRz;Im&h%y4}sbfj^@l6C%$yCqouR$pL=zu9r(k>|6C zcQigr^q$`GB$-)8t}5i)wnMkiD7jBulKbX-&*TPc#+RXI&)z9Fmre3JY6aMeG_KU#syj&({MHM#hv$IVNCd&LXR z&#HEQuDO$vY+d#*Vs%IWtHqZW7kPYjE;(;l(0L;_ z)OH86eP5<)gW=n0k1Fd@6Jq+z<}@}i{M(w>#jxs{mru`RU*VJLGa@-2Jm70d=;8ah zjMvJf&$KHtx#aHeqsJcac)EFlyZXGTWnB!N3-9JXSu;uh^!AFJ?a!)zUroRCQ0uht zNv^r`wUQZDvY0D;J|N#3x2QqWY|f@NP1T*t^d)vhI&e{G*7&|Ty5<|2T@`FPHDv_=Tv0O z?0)Cj^w&*!o$biduQ<(fNdaS};T*o^2KM5xj0HT8mv6Z~U0?geh7%{sG^JA*`1bz# ztND8Au}#{QmqjC`Tzz^M%z3`eKlsYkR~k%R{~fyO>R7yx#aWG(DX=2Mrm(7gR1lm?>$OR9M*O> zxwvWiQ;(B8MefSiFVEWR$`HC`W7maeX2rj^_CK?oZt<_gKSg!Msm;FJMy>TajXU_} zy36`2v(MV<$`Cl&r_WP%&&#Q?*W4W3xOo!3oKHMf=r5-It##_NsfP?xdONh1^vD#> zd)`!dHhNKmc64NS@~5-fO1&$k1-G&F$-#S>U3vUZQ*uwds7fi3VFpbx2K(BX%<+8Y5gK!1 zqmbEZnI~V)7vGn;yl7*WymGeXCy`Z8`W(OhS#?!}(Y55p#lWOl8Q+#2({RvR@PYIA z&L;_S9}>624SYmdKwr!c8r@2ctEoz2$E zrzI5_E6OmwVUPz+_G+wa#aaOBci6>Bbzxoua2Z#NkK zc(yLkL6j9E&u&?pvgE``lZ!T!DqAP?@iDw`<2djhlsbZ>N-|}#MK&FKx%+!}@A1OZ z=?Z=RwpxeWUMe*_IkIv)Pm$->^YPb~E^5#^ofh|WdEc{)$SK+^9FEKuzfaZr3Pt8k zKHFEBIH5sya{l?gnJj|y3$(6^Fotn+qYx7icy#o+{oKquD-e-|3dQ$ zlwzD-w4HaA$FxUEQ8zR{b4r|+t6;bHzcyo+v%3M8^ARsYUE`iyhT4M%e=nZ=>(SO1 z3p3bi!i3asehU6xF64FZ;r8T@KU-a{i6@!3lxpsCOBLEuvpGd(#mNKeecEAN3`e@| zz2cm9OJ8+v&Q*!c0_^G&kK6lSTP{`e@x1t?6CJY|CwLs3p>dFBere}1qxz*;fer#3 z?6;#H^vu^$n)Bt!+w|?Pr2(^GctVI4J_=3Z*-gHO! zNs`qYuAFk#P+lmx%rFDg@m!HIWpx7M@wLY1^Bo<;GFIKIuHv%!_CZagS)DmV$;iPBTf}%v-$;HopWl+(luQd zUW;9xyD>&t_>bl5A3?{JqfS4M6ciSo-oME6t8D*{HTwmAq+R!J&C|_`);So)X{l3x zQ)yHuFSx^2O`*;WScUT*TzSn+gn!sC@|&rOote{ELZlu3TR zMxnZrOkv&oz8-Ub#<74sFeG>RL`9=hpL|qnoR(-L**l(BpLgZ+3iT60nz47xPcWRg zRp5B?Xt=hbuh@%K^Ygkj9-IihD8a*1bDa6U&DD-)k#a5p#nQQ!znK4KMlM{bX4j>) zvaKDAyNen_RsV1`7V zgUa{!zd}zD)#k$07NbPm(w5Pr`0r&u{~dNy!=9h5excC!@L^c*ohe+N3JYW%|9xD* zE%TqDEY96dL`+S_~_*AtL{}c_K&=CRXlmGZWdO4mw9=b-5LJnTa&$(Jk_s!QG9WAQ1JJ8 z?T#yd)IItgV!rVell=s(#fSGNyzg@}4!wWqd!IpR$RFK?{|q-*B|f%Qc$|IaOqE8* zv-$cRv5(L0-K=Q;`TB}K>_4t;?$!S6nU!l1xZh;j(rkG?_hnfIv9Vcp$$7WBg7co) zvIobyz>cSSQnKRtl|3%g#ra~QR+gzRNRtS#=b80-;eUoe(B_0Kxws)!T68)`qx%`h2Yhq2u8PK-iRmsj%sFj8Va?%Fts))) z4H0JU*O$g_YkX+5WfFU)bm5`5%ni2wOMPAWd^;U=-P~CMrWv|)L_FQLLh{#@z}u&$ z^DBGx$b6n+$-IHx{?eMjpvXAsU}?3N=4+C3lJg8~|N3d(bNuuqbi!)uJRWPg`=^#I zYEXy{O*&g3l%8a@oLSbua;44w`#*R7lU-0}@=JqBF|SoNg_->jf+nv7`%z7r(vX<&FYqBqt zSm9En`9SgeInKXY>U_yo6P|m@9J#P{&c4tWAt!&TF$?bh&mdIWt8&YA>+!QX96$f* zl>W(HUNO%_;Xt_T_$wi}4vh#IQwEc-7 z-mtS9x4BzN#<)B$vwGZDcwbh7>HMVmcmHO9bvYN83HwfZ$Fz>c%|(6TW2KfWy7Me$ zJR2ogH!UfB;h;RBI(aRF?~~=<>!WO@{Cod8V6NK@xAl8BoZp~7?e_N4V|UW+TP^bw zvilWde$MIN<)Bi^@R;Ry0Lwg(YZjmMfA?>z*X6J#@6bu*H-2-QpEyu>oqeD6V~f@M zvMTTSy`P`=CV9IT1K4PHkgKvJw{mBw8lF_-;b7-D!c@iNaKP?Ld*Iev$Ezo--`sKI z>COj*Cm(!S!1)K{8i%XJ>CPKI&HLG4ol7b(n?AqNJYF&GSEe zeg0tqHBleE*n6ZN}IGFoY z?RWpWkmhL7vi&{RG-g?c$G@)du8h(MGn!*?cS4VYfkM@BQ~)ey{x%()LZ_&!JE6 zxD_0P%+xK|B_z+Um%r4Y299EI!dMXSy?Qy?O4Uh6oz>s&-)h379aOw zCCD$9R_hiD-Ii{8e3E;A!IR{58H_dXsLPxb zdr+|8eX~?sVpD}W^Xo}g!F6}@pUf;by8u4!Y_Hj4%Rd@S@d&>w&9Yo5bnNzoo+ifg zPp{iu4SF8bsdFzv#`>qP64P=CxqWkfJ!;VX3CbSec)M0&)xGtI$M&-F=+9GI5~nlF z`TO{|#GlNh-Fw8YZ8zGxd&yJA-ej%A$Oq4=X-SU=vD!h<Il&Z|W z(P_LzCnvgZ597qH?%zS;l~bj&RFnb@-LyejBRKurfYMLo+Ulx(Wpa0~s(7?CsWBHO@JoZ1gPe_wp1Jm2&FbSFi`~v` zQkue?XT+iM>$&CE1>ANB`?y|-trb4`Of-aHLrSX6mj^v_zI|Qr%50Io!EVO=XdV0#`>|TeYH9gDO z7e3+2nf~pf|C8MlesUG`ga}^{?%_X%QU+Z5#yf!LiKKYVBT&;4nf z+nxbV%(qP#^$~H;ujTe}@ir;vt!`Fxg#R?Ii2HX_z_2XAn?cMh`O_RZhI5SXQ35t7 z{puRgl3+G;HcU4#{D&6s_in)1CT7xdw+u&?{HP`9w z+k5vcepD{Gz2n$9hJ&{3KmV*ey)w#ZH>cl~peIujxcZh9p7@p4ppNj$(yq{1hDv$2 zs`7%Ce=_;S(2oeqC5sx6YSEP%3pgP4%d}OeLXzjd3>sPk;jAT%)Ba_il#VkAuzn); zpFwJUZnBPj@|_bkEvY%eCoNw73~Lo(bbb?5pR{$}lg~V^#*=$yrCyu!dCw7}hLaL8 zhBAwVuawC2xn>4BNKSb9NoB%`gCc8=xyvP=DBQ5(=j=&URY8u+_JlW{lQNySB+S^- z((-ZoU0Hwo<)$lL8Bz|W>J%Q*_hI5LDTpxqxykUH!vSXdzgg4Wd-t77pYSgI(CVs1 zAC`Z7^3Qa!D?`G4!^me_yF6x`waE+Y{LHRBN6%6w-SY8#uN~LIHM2Ilyq<4)_ln2K zot`SZ2U1Gqr-Iy67FBY=qgPq+)}}s*$ViWi_TSch zt2{|PVqN43mY)qZ$DajRNLrk$e6)SV0-m?gYna4Ccc$HHwwd52@%XmoAI;4-d~A+v z736r@;8Z@zjB%dBaT~cgC2OrTnDxB5`wcG{3${M%i#>C^;P!T9iT@1g>#|~l&&a13 zvg$wYVY6UwzPJ9OgCzelzjJy<%hJ+yx{Z%5F0(S~nUgEKb7in!Nnc5@1b@zkb;bv! z_ZAhNc$e+fWfj5mQztdwoM*o6`bn1d)$=dU>i=z*DAJtc7ZqB-y=h_#_hG(}k3Va( zgSr?_S4%I>=9)C=)a-r9#*6i;5|69!&FL%PX$cL~emaaPIuqvpR+$z(fSarep3>W#+=udTc2AlY{ARdB&))qO9OT{w4k z{PeUf;COvdR&(w07~5U#HM@MDDOJ8daLnxI{OX;Se?W6-YtxydqjI=*e~M^$E54?ATXiqRukvN?4*zV`rC=F)2OWHTmCO+-D+p~Upp>euwgLE~2 zRjk`7?`6r-3TO9BtU2;EC;7vp^%osP7i~}3J1r?Z`&b9V>j}|+vP_y@Nze4L^X$rG zo>o+@&mh=SeECZ0>Ma3mIc33XHZGR<)3GdbYNK^u@j;2l?@P~Tm2U0X@VCEM@sr@x z4gM;Rmp_dX31D-2`F+AMF=gho`zLeHR9M>dS-!rsq}_Lt+`T_PWC3&w-(9znn}G zcvqq`X_~tFyEht(U-#5)UG2({b}Qn%{LMZ0^}h?4#A^%B-`#xq)-n%0g-b#A#QNWI z3OF2@yYraw0;?}CkMFh3S)S=~N#g3Q2VSSv zcrfVQVea#P0Mc+iTGH+OOuOi1vseCJZol5-_wVYN_v}^Mr!n5ym+gLD!ZOa!@^RO0 zSBB)dW-oIe^qF<0^eM{E+GJ%k@qYh4+dliK3ws*hDY^t1skmEy;o+WXTIAi zxm=f9qgA*>cW?2e!a01kyVIt9I`r<*!`W3c{v1g;v(A8#U7DSJLZu}*$!S}+?EmcO z@#xN(+bTJB?oRCu)lcLK-+Ql!^ej0OIE6W1CFa*Q!ykp=FBWiZH#l9q>@*|CrjwF! zoLZc6JN`{&*;dY5wdqKZ>76CJP8^tE)il3!uTlNdjEfGHqWOu_oLMHY==03pwo^f{ z$*Q5YR%__YCC4>pv|A3?VE5Q zwsq4__q@9N*~|C)&D%2h(6M(;2@}`(T%3{0;SnNT{JDhreMz-6ZF1s&woU8bcrB-$MIqkeIhNIO2dQzg>k8Zye zxQ+E^;pX{=Z8N$~pQ>2W#WYFxa>K#8H}&Rnr+f)$_yayxK+>5ALD$wyrJv-&yF}s&GG9SM_+Lp0^Cwj*1zY4Y+OR6Un zUEI>eKFv~Ve??02WqU7^8L534=0{$v+RPWQB4*bF!*dodjH5#W8jfC>Bz`3&a_zmE z+ck{=+oaWHt>o+OZ86&G z*+6w$pLWKr>@qd)V@A9!oAu&lN|j|-hTRRFx_s-zH{~A5-KTW7TO2>x)BotWO#0Sb zPa&^>UC)#A;;Q67WqC0?f4+T+b53gGvmFtlPJ3LB6<@HhSFYOl?aRva?K8K!rLmaL zXj2yuOV}aF_=%~1?}XawXWL#Z;Hgm3T>Z{NVp_T0d(N-`_wS$EWDTqfUq+occ*TI7 z{fa=nvLE3gVq&HuNmc`yFQwK-QDR01sj&HnlIa0j>m6DJPeW_k$z%Riv9JF={CRlYbJQCj-8wY+jwzoZzZb#6t1ke6k=KtOQ(|RM7NuHK!d(HB{3f1qbpIX^l zmRL2%;{4{%T-%ptets1$=OgXNtaJ7P*DI5`QuogLf7W~CsW!3b_OY_xT&o{W|3vSH?7>g)LnnbC~CGzU=CM8?fo*)3d@R3GbwjpZ@w~d78M(mEf8iABtWdWcYkx zUh`K`nQ)Ka+ow9I7_QL$-tlG88NJRGix$sv_g!Rhdb12)0sED2ON_j}C%I-SHKbButE-mvottFn<=*nQ#wFdw7X(EiObezX!b9kq5 z$JW)-?!~Xr>h8`-k2DlIRnpyx;+z(+YFRV?eZ?@l;HyZU+@jT<#g!ax({3@eUgV5C zsa(u@&Wt~5H+(6DllxvO-I9rIpA)(m{(VnOmiw=G{(Jc^^m$ZDw%*cg>Dp^ki+^5U zboSpOaHcb93Tvu(8oyVXO}=s69MV%qM~bC-9iRczU5CS;yi{MEGkp?1fDeN$5l zWV(XXw>HXw0GwjPcu}`NSoeGvclIow_C;cL0(Ub)bzH_}jmX)3C ze&q6Ty9N8A*>3E}DelW&bRn(si-b?Rs$`SZXpZekh!CM=~clJ^$ zTV}4CZI{`5SN^GnNV05^dD+`vVN*q8-n9FQ5PiktqTs*h`=Gs$L z8Rfhtdp7*NV7IVB{iEg5p0liHkN-01+hmb&DqP|gdl7%uwpA+@20E>fVBlf&_BpbhE2;Sy;${>kMo5{U*W&+TQipw9^ZZ1 zHTHOMuEfc&%Y&bbE6&ytmww{fvgxEwQT`nRhT9XbTRxi0yJo}Pncu|jDl>7)YfYZu z{`CBRhNvwXi|4j)c9t{C6m2=zSha$??bnm^Pb=1)Iils#7rO7aB17ZbN%mG7T^$$t zpPHn0MnFJHq07j=%+a>q?&iy&4le1Gz$x7;zaL}&yz<2Yu6~(K_R|tW$|!w^Re7M<)Y}t_nm9}_8wdSKy(AJsj#Dsd^ zwFkP2o+=aA5`DMtP4UaOp5W{Dra~^JVsHfWz}NEy#>ATltHh_w{l4u=s%D$T`7*io zwchzfdNv0HFD}kqv$m(Xp<4L01N%+HC4l~cXSEJ z%wUq=jJSPpUKc|%#C^4(yXBUzSf?IcvFA8T@2Nf26YSSAm?KGc&z_j4EEj#^lG)Xe zW1a_XPslQ^T!GiLMGXo_ciXLef$FNN-lrb-Ov(;>l&v@(+*CiogyB4Hmn}_lnk2H3 zdBLkp#}n)l-xhGxorhn%sFj3%HnIt$JW`DKqXbj%MF#<}XZyjng?vGcDEwhO+%;>4 z>GmxztNik9C8Ps9WVUZFePkRPDH`N-%3HvSxA)qL(;2=;k314H`n%4kcMI$U#b}cN zcKfH+S(#e5X58@keWG=HGE2${KMtD$Hg=JXktSvvE6d)j`=+-kkp*PKYMdw7_#f)>(*`J-a z+iM(kC4kLrVgBsyZ_#C$s#_UllhxIqoj4&|6`ZH@r2DOBwqQucBXus1`Wf#Z|LC*& zZo1u-A>dMyp|g5G>!KF8Xc zj5PD8)SSCt^WToY+Qx6*e{+k-UFzAodhNkaCyeYRp8x18K5_natf&ZMY+FM( zr8Ol2d#e8ypG^}qeY$44zO9LHIje|C8!c_>9Z zj$N^rJ&NJDi=oHlqxo7s@4yG5*}2i&%5e$=$fall*ePc{2N!Co^O`D%fH_L z+_rVPiaWJZd3P2uD{qpKTddHh72?_}3O;4ViqYM{U{UMhEjw>BX53MlG41A~nCFwX zTjm+gDLra*?|RO~J=11(=55!zowR^i&PaR`+XMSwS1$%SNZvZ(EW2T=AFZKsl_mw3#Z+|%cs|M_}4$b51Ny4mHZ z;)jDd2hl$r_0K2O-&g8alK=T+{`V8B z<8b&lmac=l?Ur^&^-KLi}I 9) -#else - if (self < 0 || self > 6) -#endif + if (self < 0 || self > 16) + { self = 0; + } + #ifndef HAVE_MMX + // This is to allow the menu option to work properly so that these filters can be skipped while cycling through them. + if (self == 7) self = 10; + if (self == 8) self = 10; + if (self == 9) self = 6; + #endif GLRenderer->FlushTextures(); } @@ -242,6 +248,42 @@ static unsigned char *hqNxHelper( void (*hqNxFunction) ( unsigned*, unsigned*, i } + +static unsigned char *xbrzHelper( void (*xbrzFunction) ( size_t, const uint32_t*, uint32_t*, int, int, xbrz::ColorFormat, const xbrz::ScalerCfg&, int, int ), + const int N, + unsigned char *inputBuffer, + const int inWidth, + const int inHeight, + int &outWidth, + int &outHeight ) +{ + outWidth = N * inWidth; + outHeight = N *inHeight; + + unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; + xbrzFunction(N, reinterpret_cast(inputBuffer), reinterpret_cast(newBuffer), inWidth, inHeight, xbrz::ARGB, xbrz::ScalerCfg(), 0, std::numeric_limits::max()); + delete[] inputBuffer; + return newBuffer; +} + +static unsigned char *xbrzoldHelper( void (*xbrzFunction) ( size_t factor, const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz_old::ScalerCfg& cfg, int yFirst, int yLast ), + const int N, + unsigned char *inputBuffer, + const int inWidth, + const int inHeight, + int &outWidth, + int &outHeight ) +{ + outWidth = N * inWidth; + outHeight = N *inHeight; + + unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; + xbrzFunction(N, reinterpret_cast(inputBuffer), reinterpret_cast(newBuffer), inWidth, inHeight, xbrz_old::ScalerCfg(), 0, std::numeric_limits::max()); + delete[] inputBuffer; + return newBuffer; +} + + //=========================================================================== // // [BB] Upsamples the texture in inputBuffer, frees inputBuffer and returns @@ -322,6 +364,16 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u case 9: return hqNxAsmHelper( &HQnX_asm::hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); #endif + case 10: + case 11: + case 12: + return xbrzHelper(xbrz::scale, type - 8, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + + case 13: + case 14: + case 15: + return xbrzoldHelper(xbrz_old::scale, type - 11, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + } } return inputBuffer; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 2386b1076..86e2d5dc0 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -134,6 +134,12 @@ OptionValue "HqResizeModes" 7, "$OPTVAL_HQ2XMMX" 8, "$OPTVAL_HQ3XMMX" 9, "$OPTVAL_HQ4XMMX" + 10, "xBRZ 2x" + 11, "xBRZ 3x" + 12, "xBRZ 4x" + 13, "xBRZ_old 2x" + 14, "xBRZ_old 3x" + 15, "xBRZ_old 4x" } OptionValue "FogMode" From 4a80f8e4ed0bfff6e56bfef8bc1f302599253958 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 3 Sep 2016 16:54:17 +0200 Subject: [PATCH 0881/1509] - fixed: Camera textures and savegame pictures should not be drawn with a Stereo3D mode. --- src/gl/scene/gl_scene.cpp | 4 ++-- src/gl/stereo3d/gl_stereo3d.h | 1 + src/gl/stereo3d/gl_stereo_cvars.cpp | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 82b63aa00..b4dd95d50 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -822,7 +822,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo // Render (potentially) multiple views for stereo 3d float viewShift[3]; - const s3d::Stereo3DMode& stereo3dMode = s3d::Stereo3DMode::getCurrentMode(); + const s3d::Stereo3DMode& stereo3dMode = mainview && toscreen? s3d::Stereo3DMode::getCurrentMode() : s3d::Stereo3DMode::getMonoMode(); stereo3dMode.SetUp(); for (int eye_ix = 0; eye_ix < stereo3dMode.eye_count(); ++eye_ix) { @@ -1313,7 +1313,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in gl_fixedcolormap=CM_DEFAULT; gl_RenderState.SetFixedColormap(CM_DEFAULT); - bool usefb = gl_usefb || gltex->GetWidth() > screen->GetWidth() || gltex->GetHeight() > screen->GetHeight(); + bool usefb = !gl.legacyMode || gl_usefb || gltex->GetWidth() > screen->GetWidth() || gltex->GetHeight() > screen->GetHeight(); if (!usefb) { glFlush(); diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h index 303f18825..c56cc078f 100644 --- a/src/gl/stereo3d/gl_stereo3d.h +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -74,6 +74,7 @@ class Stereo3DMode public: /* static methods for managing the selected stereoscopic view state */ static const Stereo3DMode& getCurrentMode(); + static const Stereo3DMode& getMonoMode(); Stereo3DMode(); virtual ~Stereo3DMode(); diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index e7d08df41..897b28088 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -105,5 +105,12 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() return *currentStereo3DMode; } +const Stereo3DMode& Stereo3DMode::getMonoMode() +{ + setCurrentMode(MonoView::getInstance()); + return *currentStereo3DMode; +} + + } /* namespace s3d */ From 3ae2e77512acdc65b89d958345fa2fb73633d794 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 3 Sep 2016 16:55:16 +0200 Subject: [PATCH 0882/1509] - added xBRZ files. --- src/gl/xbr/xbrz.cpp | 1229 ++++++++++++++++++++++++++++++ src/gl/xbr/xbrz.h | 102 +++ src/gl/xbr/xbrz_config.h | 45 ++ src/gl/xbr/xbrz_config_old.h | 45 ++ src/gl/xbr/xbrz_old.cpp | 1365 ++++++++++++++++++++++++++++++++++ src/gl/xbr/xbrz_old.h | 92 +++ 6 files changed, 2878 insertions(+) create mode 100644 src/gl/xbr/xbrz.cpp create mode 100644 src/gl/xbr/xbrz.h create mode 100644 src/gl/xbr/xbrz_config.h create mode 100644 src/gl/xbr/xbrz_config_old.h create mode 100644 src/gl/xbr/xbrz_old.cpp create mode 100644 src/gl/xbr/xbrz_old.h diff --git a/src/gl/xbr/xbrz.cpp b/src/gl/xbr/xbrz.cpp new file mode 100644 index 000000000..b26d4bbd3 --- /dev/null +++ b/src/gl/xbr/xbrz.cpp @@ -0,0 +1,1229 @@ +// **************************************************************************** +// * This file is part of the HqMAME project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * +// * * +// * Additionally and as a special exception, the author gives permission * +// * to link the code of this program with the MAME library (or with modified * +// * versions of MAME that use the same license as MAME), and distribute * +// * linked combinations including the two. You must obey the GNU General * +// * Public License in all respects for all of the code used other than MAME. * +// * If you modify this file, you may extend this exception to your version * +// * of the file, but you are not obligated to do so. If you do not wish to * +// * do so, delete this exception statement from your version. * +// * * +// * An explicit permission was granted to use xBRZ in combination with ZDoom * +// * and derived projects as long as it is used for non-commercial purposes. * +// * * +// * Backported to C++98 by Alexey Lysiuk * +// **************************************************************************** + +#include "xbrz.h" + +#include +#include +#include +#include + +#if __cplusplus <= 199711 +#define static_assert(VAL, MSG) static_assertion(); +template struct static_assertion; +template<> struct static_assertion {}; +#endif // __cplusplus <= 199711 + +namespace +{ +template inline +unsigned char getByte(uint32_t val) { return static_cast((val >> (8 * N)) & 0xff); } + +inline unsigned char getAlpha(uint32_t pix) { return getByte<3>(pix); } +inline unsigned char getRed (uint32_t pix) { return getByte<2>(pix); } +inline unsigned char getGreen(uint32_t pix) { return getByte<1>(pix); } +inline unsigned char getBlue (uint32_t pix) { return getByte<0>(pix); } + +inline uint32_t makePixel( unsigned char r, unsigned char g, unsigned char b) { return (r << 16) | (g << 8) | b; } +inline uint32_t makePixel(unsigned char a, unsigned char r, unsigned char g, unsigned char b) { return (a << 24) | (r << 16) | (g << 8) | b; } + + +template inline +uint32_t gradientRGB(uint32_t pixFront, uint32_t pixBack) //blend front color with opacity M / N over opaque background: http://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending +{ + static_assert(0 < M && M < N && N <= 1000, ""); + +#define calcColor(colFront, colBack) \ + (((colFront) * M + (colBack) * (N - M)) / N) + + return makePixel(calcColor(getRed (pixFront), getRed (pixBack)), + calcColor(getGreen(pixFront), getGreen(pixBack)), + calcColor(getBlue (pixFront), getBlue (pixBack))); + +#undef calcColor +} + + +template inline +uint32_t gradientARGB(uint32_t pixFront, uint32_t pixBack) //find intermediate color between two colors with alpha channels (=> NO alpha blending!!!) +{ + static_assert(0 < M && M < N && N <= 1000, ""); + + const unsigned int weightFront = getAlpha(pixFront) * M; + const unsigned int weightBack = getAlpha(pixBack) * (N - M); + const unsigned int weightSum = weightFront + weightBack; + if (weightSum == 0) + return 0; + +#define calcColor(colFront, colBack) \ + static_cast(((colFront) * weightFront + (colBack) * weightBack) / weightSum) + + return makePixel(static_cast(weightSum / N), + calcColor(getRed (pixFront), getRed (pixBack)), + calcColor(getGreen(pixFront), getGreen(pixBack)), + calcColor(getBlue (pixFront), getBlue (pixBack))); + +#undef calcColor +} + + +//inline +//double fastSqrt(double n) +//{ +// __asm //speeds up xBRZ by about 9% compared to std::sqrt which internally uses the same assembler instructions but adds some "fluff" +// { +// fld n +// fsqrt +// } +//} +// + + +uint32_t* byteAdvance( uint32_t* ptr, int bytes) { return reinterpret_cast< uint32_t*>(reinterpret_cast< char*>(ptr) + bytes); } +const uint32_t* byteAdvance(const uint32_t* ptr, int bytes) { return reinterpret_cast(reinterpret_cast(ptr) + bytes); } + + +//fill block with the given color +inline +void fillBlock(uint32_t* trg, int pitch, uint32_t col, int blockWidth, int blockHeight) +{ + //for (int y = 0; y < blockHeight; ++y, trg = byteAdvance(trg, pitch)) + // std::fill(trg, trg + blockWidth, col); + + for (int y = 0; y < blockHeight; ++y, trg = byteAdvance(trg, pitch)) + for (int x = 0; x < blockWidth; ++x) + trg[x] = col; +} + +inline +void fillBlock(uint32_t* trg, int pitch, uint32_t col, int n) { fillBlock(trg, pitch, col, n, n); } + + +#ifdef _MSC_VER + #define FORCE_INLINE __forceinline +#elif defined __GNUC__ + #define FORCE_INLINE __attribute__((always_inline)) inline +#else + #define FORCE_INLINE inline +#endif + + +enum RotationDegree //clock-wise +{ + ROT_0, + ROT_90, + ROT_180, + ROT_270 +}; + +//calculate input matrix coordinates after rotation at compile time +template +struct MatrixRotation; + +template +struct MatrixRotation +{ + static const size_t I_old = I; + static const size_t J_old = J; +}; + +template //(i, j) = (row, col) indices, N = size of (square) matrix +struct MatrixRotation +{ + static const size_t I_old = N - 1 - MatrixRotation(rotDeg - 1), I, J, N>::J_old; //old coordinates before rotation! + static const size_t J_old = MatrixRotation(rotDeg - 1), I, J, N>::I_old; // +}; + + +template +class OutputMatrix +{ +public: + OutputMatrix(uint32_t* out, int outWidth) : //access matrix area, top-left at position "out" for image with given width + out_(out), + outWidth_(outWidth) {} + + template + uint32_t& ref() const + { + static const size_t I_old = MatrixRotation::I_old; + static const size_t J_old = MatrixRotation::J_old; + return *(out_ + J_old + I_old * outWidth_); + } + +private: + uint32_t* out_; + const int outWidth_; +}; + + +template inline +T square(T value) { return value * value; } + + + +inline +double distRGB(uint32_t pix1, uint32_t pix2) +{ + const double r_diff = static_cast(getRed (pix1)) - getRed (pix2); + const double g_diff = static_cast(getGreen(pix1)) - getGreen(pix2); + const double b_diff = static_cast(getBlue (pix1)) - getBlue (pix2); + + //euklidean RGB distance + return std::sqrt(square(r_diff) + square(g_diff) + square(b_diff)); +} + + +inline +double distYCbCr(uint32_t pix1, uint32_t pix2, double lumaWeight) +{ + //http://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion + //YCbCr conversion is a matrix multiplication => take advantage of linearity by subtracting first! + const int r_diff = static_cast(getRed (pix1)) - getRed (pix2); //we may delay division by 255 to after matrix multiplication + const int g_diff = static_cast(getGreen(pix1)) - getGreen(pix2); // + const int b_diff = static_cast(getBlue (pix1)) - getBlue (pix2); //substraction for int is noticeable faster than for double! + + //const double k_b = 0.0722; //ITU-R BT.709 conversion + //const double k_r = 0.2126; // + const double k_b = 0.0593; //ITU-R BT.2020 conversion + const double k_r = 0.2627; // + const double k_g = 1 - k_b - k_r; + + const double scale_b = 0.5 / (1 - k_b); + const double scale_r = 0.5 / (1 - k_r); + + const double y = k_r * r_diff + k_g * g_diff + k_b * b_diff; //[!], analog YCbCr! + const double c_b = scale_b * (b_diff - y); + const double c_r = scale_r * (r_diff - y); + + //we skip division by 255 to have similar range like other distance functions + return std::sqrt(square(lumaWeight * y) + square(c_b) + square(c_r)); +} + + +struct DistYCbCrBuffer //30% perf boost compared to distYCbCr()! +{ +public: + static double dist(uint32_t pix1, uint32_t pix2) + { +#if defined _MSC_VER && _MSC_VER < 1900 +#error function scope static initialization is not yet thread-safe! +#endif + static const DistYCbCrBuffer inst; + return inst.distImpl(pix1, pix2); + } + +private: + DistYCbCrBuffer() : buffer(256 * 256 * 256) + { + for (uint32_t i = 0; i < 256 * 256 * 256; ++i) //startup time: 114 ms on Intel Core i5 (four cores) + { + const int r_diff = getByte<2>(i) * 2 - 255; + const int g_diff = getByte<1>(i) * 2 - 255; + const int b_diff = getByte<0>(i) * 2 - 255; + + const double k_b = 0.0593; //ITU-R BT.2020 conversion + const double k_r = 0.2627; // + const double k_g = 1 - k_b - k_r; + + const double scale_b = 0.5 / (1 - k_b); + const double scale_r = 0.5 / (1 - k_r); + + const double y = k_r * r_diff + k_g * g_diff + k_b * b_diff; //[!], analog YCbCr! + const double c_b = scale_b * (b_diff - y); + const double c_r = scale_r * (r_diff - y); + + buffer[i] = static_cast(std::sqrt(square(y) + square(c_b) + square(c_r))); + } + } + + double distImpl(uint32_t pix1, uint32_t pix2) const + { + //if (pix1 == pix2) -> 8% perf degradation! + // return 0; + //if (pix1 > pix2) + // std::swap(pix1, pix2); -> 30% perf degradation!!! + + const int r_diff = static_cast(getRed (pix1)) - getRed (pix2); + const int g_diff = static_cast(getGreen(pix1)) - getGreen(pix2); + const int b_diff = static_cast(getBlue (pix1)) - getBlue (pix2); + + return buffer[(((r_diff + 255) / 2) << 16) | //slightly reduce precision (division by 2) to squeeze value into single byte + (((g_diff + 255) / 2) << 8) | + (( b_diff + 255) / 2)]; + } + + std::vector buffer; //consumes 64 MB memory; using double is only 2% faster, but takes 128 MB +}; + + +enum BlendType +{ + BLEND_NONE = 0, + BLEND_NORMAL, //a normal indication to blend + BLEND_DOMINANT, //a strong indication to blend + //attention: BlendType must fit into the value range of 2 bit!!! +}; + +struct BlendResult +{ + BlendType + /**/blend_f, blend_g, + /**/blend_j, blend_k; +}; + + +struct Kernel_4x4 //kernel for preprocessing step +{ + uint32_t + /**/a, b, c, d, + /**/e, f, g, h, + /**/i, j, k, l, + /**/m, n, o, p; +}; + +/* +input kernel area naming convention: +----------------- +| A | B | C | D | +----|---|---|---| +| E | F | G | H | //evaluate the four corners between F, G, J, K +----|---|---|---| //input pixel is at position F +| I | J | K | L | +----|---|---|---| +| M | N | O | P | +----------------- +*/ +template +FORCE_INLINE //detect blend direction +BlendResult preProcessCorners(const Kernel_4x4& ker, const xbrz::ScalerCfg& cfg) //result: F, G, J, K corners of "GradientType" +{ + BlendResult result = {}; + + if ((ker.f == ker.g && + ker.j == ker.k) || + (ker.f == ker.j && + ker.g == ker.k)) + return result; + +#define dist(pix1, pix2) \ + ColorDistance::dist((pix1), (pix2), cfg.luminanceWeight) + + const int weight = 4; + double jg = dist(ker.i, ker.f) + dist(ker.f, ker.c) + dist(ker.n, ker.k) + dist(ker.k, ker.h) + weight * dist(ker.j, ker.g); + double fk = dist(ker.e, ker.j) + dist(ker.j, ker.o) + dist(ker.b, ker.g) + dist(ker.g, ker.l) + weight * dist(ker.f, ker.k); + +#undef dist + + if (jg < fk) //test sample: 70% of values max(jg, fk) / min(jg, fk) are between 1.1 and 3.7 with median being 1.8 + { + const bool dominantGradient = cfg.dominantDirectionThreshold * jg < fk; + if (ker.f != ker.g && ker.f != ker.j) + result.blend_f = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + + if (ker.k != ker.j && ker.k != ker.g) + result.blend_k = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + } + else if (fk < jg) + { + const bool dominantGradient = cfg.dominantDirectionThreshold * fk < jg; + if (ker.j != ker.f && ker.j != ker.k) + result.blend_j = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + + if (ker.g != ker.f && ker.g != ker.k) + result.blend_g = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + } + return result; +} + +struct Kernel_3x3 +{ + uint32_t + /**/a, b, c, + /**/d, e, f, + /**/g, h, i; +}; + +#define DEF_GETTER(x) template uint32_t inline get_##x(const Kernel_3x3& ker) { return ker.x; } +//we cannot and NEED NOT write "ker.##x" since ## concatenates preprocessor tokens but "." is not a token +DEF_GETTER(a) DEF_GETTER(b) DEF_GETTER(c) +DEF_GETTER(d) DEF_GETTER(e) DEF_GETTER(f) +DEF_GETTER(g) DEF_GETTER(h) DEF_GETTER(i) +#undef DEF_GETTER + +#define DEF_GETTER(x, y) template <> inline uint32_t get_##x(const Kernel_3x3& ker) { return ker.y; } +DEF_GETTER(a, g) DEF_GETTER(b, d) DEF_GETTER(c, a) +DEF_GETTER(d, h) DEF_GETTER(e, e) DEF_GETTER(f, b) +DEF_GETTER(g, i) DEF_GETTER(h, f) DEF_GETTER(i, c) +#undef DEF_GETTER + +#define DEF_GETTER(x, y) template <> inline uint32_t get_##x(const Kernel_3x3& ker) { return ker.y; } +DEF_GETTER(a, i) DEF_GETTER(b, h) DEF_GETTER(c, g) +DEF_GETTER(d, f) DEF_GETTER(e, e) DEF_GETTER(f, d) +DEF_GETTER(g, c) DEF_GETTER(h, b) DEF_GETTER(i, a) +#undef DEF_GETTER + +#define DEF_GETTER(x, y) template <> inline uint32_t get_##x(const Kernel_3x3& ker) { return ker.y; } +DEF_GETTER(a, c) DEF_GETTER(b, f) DEF_GETTER(c, i) +DEF_GETTER(d, b) DEF_GETTER(e, e) DEF_GETTER(f, h) +DEF_GETTER(g, a) DEF_GETTER(h, d) DEF_GETTER(i, g) +#undef DEF_GETTER + + +//compress four blend types into a single byte +inline BlendType getTopL (unsigned char b) { return static_cast(0x3 & b); } +inline BlendType getTopR (unsigned char b) { return static_cast(0x3 & (b >> 2)); } +inline BlendType getBottomR(unsigned char b) { return static_cast(0x3 & (b >> 4)); } +inline BlendType getBottomL(unsigned char b) { return static_cast(0x3 & (b >> 6)); } + +inline void setTopL (unsigned char& b, BlendType bt) { b |= bt; } //buffer is assumed to be initialized before preprocessing! +inline void setTopR (unsigned char& b, BlendType bt) { b |= (bt << 2); } +inline void setBottomR(unsigned char& b, BlendType bt) { b |= (bt << 4); } +inline void setBottomL(unsigned char& b, BlendType bt) { b |= (bt << 6); } + +inline bool blendingNeeded(unsigned char b) { return b != 0; } + +template inline +unsigned char rotateBlendInfo(unsigned char b) { return b; } +template <> inline unsigned char rotateBlendInfo(unsigned char b) { return ((b << 2) | (b >> 6)) & 0xff; } +template <> inline unsigned char rotateBlendInfo(unsigned char b) { return ((b << 4) | (b >> 4)) & 0xff; } +template <> inline unsigned char rotateBlendInfo(unsigned char b) { return ((b << 6) | (b >> 2)) & 0xff; } + + +/* +input kernel area naming convention: +------------- +| A | B | C | +----|---|---| +| D | E | F | //input pixel is at position E +----|---|---| +| G | H | I | +------------- +*/ +template +FORCE_INLINE //perf: quite worth it! +void blendPixel(const Kernel_3x3& ker, + uint32_t* target, int trgWidth, + unsigned char blendInfo, //result of preprocessing all four corners of pixel "e" + const xbrz::ScalerCfg& cfg) +{ +#define a get_a(ker) +#define b get_b(ker) +#define c get_c(ker) +#define d get_d(ker) +#define e get_e(ker) +#define f get_f(ker) +#define g get_g(ker) +#define h get_h(ker) +#define i get_i(ker) + + const unsigned char blend = rotateBlendInfo(blendInfo); + + if (getBottomR(blend) >= BLEND_NORMAL) + { + struct LineBlend + { + static bool Eval(const Kernel_3x3& ker, const xbrz::ScalerCfg& cfg, const unsigned char blend) + { + if (getBottomR(blend) >= BLEND_DOMINANT) + return true; + +#define eq(pix1, pix2) \ + (ColorDistance::dist((pix1), (pix2), cfg.luminanceWeight) < cfg.equalColorTolerance) + + //make sure there is no second blending in an adjacent rotation for this pixel: handles insular pixels, mario eyes + if (getTopR(blend) != BLEND_NONE && !eq(e, g)) //but support double-blending for 90 degree corners + return false; + if (getBottomL(blend) != BLEND_NONE && !eq(e, c)) + return false; + + //no full blending for L-shapes; blend corner only (handles "mario mushroom eyes") + if (!eq(e, i) && eq(g, h) && eq(h , i) && eq(i, f) && eq(f, c)) + return false; + +#undef eq + + return true; + } + }; + + const bool doLineBlend = LineBlend::Eval(ker, cfg, blend); + +#define dist(pix1, pix2) \ + ColorDistance::dist((pix1), (pix2), cfg.luminanceWeight) + + const uint32_t px = dist(e, f) <= dist(e, h) ? f : h; //choose most similar color + + OutputMatrix out(target, trgWidth); + + if (doLineBlend) + { + const double fg = dist(f, g); //test sample: 70% of values max(fg, hc) / min(fg, hc) are between 1.1 and 3.7 with median being 1.9 + const double hc = dist(h, c); // + + const bool haveShallowLine = cfg.steepDirectionThreshold * fg <= hc && e != g && d != g; + const bool haveSteepLine = cfg.steepDirectionThreshold * hc <= fg && e != c && b != c; + + if (haveShallowLine) + { + if (haveSteepLine) + Scaler::blendLineSteepAndShallow(px, out); + else + Scaler::blendLineShallow(px, out); + } + else + { + if (haveSteepLine) + Scaler::blendLineSteep(px, out); + else + Scaler::blendLineDiagonal(px,out); + } + } + else + Scaler::blendCorner(px, out); + } + +#undef dist + +#undef a +#undef b +#undef c +#undef d +#undef e +#undef f +#undef g +#undef h +#undef i +} + + +template //scaler policy: see "Scaler2x" reference implementation +void scaleImage(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz::ScalerCfg& cfg, int yFirst, int yLast) +{ + yFirst = std::max(yFirst, 0); + yLast = std::min(yLast, srcHeight); + if (yFirst >= yLast || srcWidth <= 0) + return; + + const int trgWidth = srcWidth * Scaler::scale; + + //"use" space at the end of the image as temporary buffer for "on the fly preprocessing": we even could use larger area of + //"sizeof(uint32_t) * srcWidth * (yLast - yFirst)" bytes without risk of accidental overwriting before accessing + const int bufferSize = srcWidth; + unsigned char* preProcBuffer = reinterpret_cast(trg + yLast * Scaler::scale * trgWidth) - bufferSize; + std::fill(preProcBuffer, preProcBuffer + bufferSize, 0); + static_assert(BLEND_NONE == 0, ""); + + //initialize preprocessing buffer for first row of current stripe: detect upper left and right corner blending + //this cannot be optimized for adjacent processing stripes; we must not allow for a memory race condition! + if (yFirst > 0) + { + const int y = yFirst - 1; + + const uint32_t* s_m1 = src + srcWidth * std::max(y - 1, 0); + const uint32_t* s_0 = src + srcWidth * y; //center line + const uint32_t* s_p1 = src + srcWidth * std::min(y + 1, srcHeight - 1); + const uint32_t* s_p2 = src + srcWidth * std::min(y + 2, srcHeight - 1); + + for (int x = 0; x < srcWidth; ++x) + { + const int x_m1 = std::max(x - 1, 0); + const int x_p1 = std::min(x + 1, srcWidth - 1); + const int x_p2 = std::min(x + 2, srcWidth - 1); + + Kernel_4x4 ker = {}; //perf: initialization is negligible + ker.a = s_m1[x_m1]; //read sequentially from memory as far as possible + ker.b = s_m1[x]; + ker.c = s_m1[x_p1]; + ker.d = s_m1[x_p2]; + + ker.e = s_0[x_m1]; + ker.f = s_0[x]; + ker.g = s_0[x_p1]; + ker.h = s_0[x_p2]; + + ker.i = s_p1[x_m1]; + ker.j = s_p1[x]; + ker.k = s_p1[x_p1]; + ker.l = s_p1[x_p2]; + + ker.m = s_p2[x_m1]; + ker.n = s_p2[x]; + ker.o = s_p2[x_p1]; + ker.p = s_p2[x_p2]; + + const BlendResult res = preProcessCorners(ker, cfg); + /* + preprocessing blend result: + --------- + | F | G | //evalute corner between F, G, J, K + ----|---| //input pixel is at position F + | J | K | + --------- + */ + setTopR(preProcBuffer[x], res.blend_j); + + if (x + 1 < bufferSize) + setTopL(preProcBuffer[x + 1], res.blend_k); + } + } + //------------------------------------------------------------------------------------ + + for (int y = yFirst; y < yLast; ++y) + { + uint32_t* out = trg + Scaler::scale * y * trgWidth; //consider MT "striped" access + + const uint32_t* s_m1 = src + srcWidth * std::max(y - 1, 0); + const uint32_t* s_0 = src + srcWidth * y; //center line + const uint32_t* s_p1 = src + srcWidth * std::min(y + 1, srcHeight - 1); + const uint32_t* s_p2 = src + srcWidth * std::min(y + 2, srcHeight - 1); + + unsigned char blend_xy1 = 0; //corner blending for current (x, y + 1) position + + for (int x = 0; x < srcWidth; ++x, out += Scaler::scale) + { + //all those bounds checks have only insignificant impact on performance! + const int x_m1 = std::max(x - 1, 0); //perf: prefer array indexing to additional pointers! + const int x_p1 = std::min(x + 1, srcWidth - 1); + const int x_p2 = std::min(x + 2, srcWidth - 1); + + Kernel_4x4 ker4 = {}; //perf: initialization is negligible + + ker4.a = s_m1[x_m1]; //read sequentially from memory as far as possible + ker4.b = s_m1[x]; + ker4.c = s_m1[x_p1]; + ker4.d = s_m1[x_p2]; + + ker4.e = s_0[x_m1]; + ker4.f = s_0[x]; + ker4.g = s_0[x_p1]; + ker4.h = s_0[x_p2]; + + ker4.i = s_p1[x_m1]; + ker4.j = s_p1[x]; + ker4.k = s_p1[x_p1]; + ker4.l = s_p1[x_p2]; + + ker4.m = s_p2[x_m1]; + ker4.n = s_p2[x]; + ker4.o = s_p2[x_p1]; + ker4.p = s_p2[x_p2]; + + //evaluate the four corners on bottom-right of current pixel + unsigned char blend_xy = 0; //for current (x, y) position + { + const BlendResult res = preProcessCorners(ker4, cfg); + /* + preprocessing blend result: + --------- + | F | G | //evalute corner between F, G, J, K + ----|---| //current input pixel is at position F + | J | K | + --------- + */ + blend_xy = preProcBuffer[x]; + setBottomR(blend_xy, res.blend_f); //all four corners of (x, y) have been determined at this point due to processing sequence! + + setTopR(blend_xy1, res.blend_j); //set 2nd known corner for (x, y + 1) + preProcBuffer[x] = blend_xy1; //store on current buffer position for use on next row + + blend_xy1 = 0; + setTopL(blend_xy1, res.blend_k); //set 1st known corner for (x + 1, y + 1) and buffer for use on next column + + if (x + 1 < bufferSize) //set 3rd known corner for (x + 1, y) + setBottomL(preProcBuffer[x + 1], res.blend_g); + } + + //fill block of size scale * scale with the given color + fillBlock(out, trgWidth * sizeof(uint32_t), ker4.f, Scaler::scale); //place *after* preprocessing step, to not overwrite the results while processing the the last pixel! + + //blend four corners of current pixel + if (blendingNeeded(blend_xy)) //good 5% perf-improvement + { + Kernel_3x3 ker3 = {}; //perf: initialization is negligible + + ker3.a = ker4.a; + ker3.b = ker4.b; + ker3.c = ker4.c; + + ker3.d = ker4.e; + ker3.e = ker4.f; + ker3.f = ker4.g; + + ker3.g = ker4.i; + ker3.h = ker4.j; + ker3.i = ker4.k; + + blendPixel(ker3, out, trgWidth, blend_xy, cfg); + blendPixel(ker3, out, trgWidth, blend_xy, cfg); + blendPixel(ker3, out, trgWidth, blend_xy, cfg); + blendPixel(ker3, out, trgWidth, blend_xy, cfg); + } + } + } +} + +//------------------------------------------------------------------------------------ + +template +struct Scaler2x : public ColorGradient +{ + static const int scale = 2; + + template //bring template function into scope for GCC + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) { ColorGradient::template alphaGrad(pixBack, pixFront); } + + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<0, scale - 1>(), col); + alphaGrad<3, 4>(out.template ref<1, scale - 1>(), col); + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<1, 0>(), col); + alphaGrad<1, 4>(out.template ref<0, 1>(), col); + alphaGrad<5, 6>(out.template ref<1, 1>(), col); //[!] fixes 7/8 used in xBR + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 2>(out.template ref<1, 1>(), col); + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaGrad<21, 100>(out.template ref<1, 1>(), col); //exact: 1 - pi/4 = 0.2146018366 + } +}; + + +template +struct Scaler3x : public ColorGradient +{ + static const int scale = 3; + + template //bring template function into scope for GCC + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) { ColorGradient::template alphaGrad(pixBack, pixFront); } + + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + + alphaGrad<3, 4>(out.template ref(), col); + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<0, scale - 1>(), col); + alphaGrad<1, 4>(out.template ref<2, scale - 2>(), col); + + alphaGrad<3, 4>(out.template ref<1, scale - 1>(), col); + out.template ref<2, scale - 1>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<2, 0>(), col); + alphaGrad<1, 4>(out.template ref<0, 2>(), col); + alphaGrad<3, 4>(out.template ref<2, 1>(), col); + alphaGrad<3, 4>(out.template ref<1, 2>(), col); + out.template ref<2, 2>() = col; + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 8>(out.template ref<1, 2>(), col); //conflict with other rotations for this odd scale + alphaGrad<1, 8>(out.template ref<2, 1>(), col); + alphaGrad<7, 8>(out.template ref<2, 2>(), col); // + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaGrad<45, 100>(out.template ref<2, 2>(), col); //exact: 0.4545939598 + //alphaGrad<7, 256>(out.template ref<2, 1>(), col); //0.02826017254 -> negligible + avoid conflicts with other rotations for this odd scale + //alphaGrad<7, 256>(out.template ref<1, 2>(), col); //0.02826017254 + } +}; + + +template +struct Scaler4x : public ColorGradient +{ + static const int scale = 4; + + template //bring template function into scope for GCC + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) { ColorGradient::template alphaGrad(pixBack, pixFront); } + + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + + alphaGrad<3, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<0, scale - 1>(), col); + alphaGrad<1, 4>(out.template ref<2, scale - 2>(), col); + + alphaGrad<3, 4>(out.template ref<1, scale - 1>(), col); + alphaGrad<3, 4>(out.template ref<3, scale - 2>(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<3, 4>(out.template ref<3, 1>(), col); + alphaGrad<3, 4>(out.template ref<1, 3>(), col); + alphaGrad<1, 4>(out.template ref<3, 0>(), col); + alphaGrad<1, 4>(out.template ref<0, 3>(), col); + + alphaGrad<1, 3>(out.template ref<2, 2>(), col); //[!] fixes 1/4 used in xBR + + out.template ref<3, 3>() = col; + out.template ref<3, 2>() = col; + out.template ref<2, 3>() = col; + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 2>(out.template ref(), col); + alphaGrad<1, 2>(out.template ref(), col); + out.template ref() = col; + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaGrad<68, 100>(out.template ref<3, 3>(), col); //exact: 0.6848532563 + alphaGrad< 9, 100>(out.template ref<3, 2>(), col); //0.08677704501 + alphaGrad< 9, 100>(out.template ref<2, 3>(), col); //0.08677704501 + } +}; + + +template +struct Scaler5x : public ColorGradient +{ + static const int scale = 5; + + template //bring template function into scope for GCC + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) { ColorGradient::template alphaGrad(pixBack, pixFront); } + + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + + alphaGrad<3, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<0, scale - 1>(), col); + alphaGrad<1, 4>(out.template ref<2, scale - 2>(), col); + alphaGrad<1, 4>(out.template ref<4, scale - 3>(), col); + + alphaGrad<3, 4>(out.template ref<1, scale - 1>(), col); + alphaGrad<3, 4>(out.template ref<3, scale - 2>(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + out.template ref<4, scale - 1>() = col; + out.template ref<4, scale - 2>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<0, scale - 1>(), col); + alphaGrad<1, 4>(out.template ref<2, scale - 2>(), col); + alphaGrad<3, 4>(out.template ref<1, scale - 1>(), col); + + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + + alphaGrad<2, 3>(out.template ref<3, 3>(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + out.template ref<4, scale - 1>() = col; + + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 8>(out.template ref(), col); //conflict with other rotations for this odd scale + alphaGrad<1, 8>(out.template ref(), col); + alphaGrad<1, 8>(out.template ref(), col); // + + alphaGrad<7, 8>(out.template ref<4, 3>(), col); + alphaGrad<7, 8>(out.template ref<3, 4>(), col); + + out.template ref<4, 4>() = col; + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaGrad<86, 100>(out.template ref<4, 4>(), col); //exact: 0.8631434088 + alphaGrad<23, 100>(out.template ref<4, 3>(), col); //0.2306749731 + alphaGrad<23, 100>(out.template ref<3, 4>(), col); //0.2306749731 + //alphaGrad<1, 64>(out.template ref<4, 2>(), col); //0.01676812367 -> negligible + avoid conflicts with other rotations for this odd scale + //alphaGrad<1, 64>(out.template ref<2, 4>(), col); //0.01676812367 + } +}; + + +template +struct Scaler6x : public ColorGradient +{ + static const int scale = 6; + + template //bring template function into scope for GCC + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) { ColorGradient::template alphaGrad(pixBack, pixFront); } + + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + + alphaGrad<3, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<0, scale - 1>(), col); + alphaGrad<1, 4>(out.template ref<2, scale - 2>(), col); + alphaGrad<1, 4>(out.template ref<4, scale - 3>(), col); + + alphaGrad<3, 4>(out.template ref<1, scale - 1>(), col); + alphaGrad<3, 4>(out.template ref<3, scale - 2>(), col); + alphaGrad<3, 4>(out.template ref<5, scale - 3>(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + out.template ref<4, scale - 1>() = col; + out.template ref<5, scale - 1>() = col; + + out.template ref<4, scale - 2>() = col; + out.template ref<5, scale - 2>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<0, scale - 1>(), col); + alphaGrad<1, 4>(out.template ref<2, scale - 2>(), col); + alphaGrad<3, 4>(out.template ref<1, scale - 1>(), col); + alphaGrad<3, 4>(out.template ref<3, scale - 2>(), col); + + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + out.template ref<4, scale - 1>() = col; + out.template ref<5, scale - 1>() = col; + + out.template ref<4, scale - 2>() = col; + out.template ref<5, scale - 2>() = col; + + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 2>(out.template ref(), col); + alphaGrad<1, 2>(out.template ref(), col); + alphaGrad<1, 2>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaGrad<97, 100>(out.template ref<5, 5>(), col); //exact: 0.9711013910 + alphaGrad<42, 100>(out.template ref<4, 5>(), col); //0.4236372243 + alphaGrad<42, 100>(out.template ref<5, 4>(), col); //0.4236372243 + alphaGrad< 6, 100>(out.template ref<5, 3>(), col); //0.05652034508 + alphaGrad< 6, 100>(out.template ref<3, 5>(), col); //0.05652034508 + } +}; + +//------------------------------------------------------------------------------------ + +struct ColorDistanceRGB +{ + static double dist(uint32_t pix1, uint32_t pix2, double luminanceWeight) + { + return DistYCbCrBuffer::dist(pix1, pix2); + + //if (pix1 == pix2) //about 4% perf boost + // return 0; + //return distYCbCr(pix1, pix2, luminanceWeight); + } +}; + +struct ColorDistanceARGB +{ + static double dist(uint32_t pix1, uint32_t pix2, double luminanceWeight) + { + const double a1 = getAlpha(pix1) / 255.0 ; + const double a2 = getAlpha(pix2) / 255.0 ; + /* + Requirements for a color distance handling alpha channel: with a1, a2 in [0, 1] + + 1. if a1 = a2, distance should be: a1 * distYCbCr() + 2. if a1 = 0, distance should be: a2 * distYCbCr(black, white) = a2 * 255 + 3. if a1 = 1, ??? maybe: 255 * (1 - a2) + a2 * distYCbCr() + */ + + //return std::min(a1, a2) * DistYCbCrBuffer::dist(pix1, pix2) + 255 * abs(a1 - a2); + //=> following code is 15% faster: + const double d = DistYCbCrBuffer::dist(pix1, pix2); + if (a1 < a2) + return a1 * d + 255 * (a2 - a1); + else + return a2 * d + 255 * (a1 - a2); + + //alternative? return std::sqrt(a1 * a2 * square(DistYCbCrBuffer::dist(pix1, pix2)) + square(255 * (a1 - a2))); + } +}; + + +struct ColorGradientRGB +{ + template + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) + { + pixBack = gradientRGB(pixFront, pixBack); + } +}; + +struct ColorGradientARGB +{ + template + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) + { + pixBack = gradientARGB(pixFront, pixBack); + } +}; +} + + +void xbrz::scale(size_t factor, const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, ColorFormat colFmt, const xbrz::ScalerCfg& cfg, int yFirst, int yLast) +{ + switch (colFmt) + { + case ARGB: + switch (factor) + { + case 2: + return scaleImage, ColorDistanceARGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 3: + return scaleImage, ColorDistanceARGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 4: + return scaleImage, ColorDistanceARGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 5: + return scaleImage, ColorDistanceARGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 6: + return scaleImage, ColorDistanceARGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + } + break; + + case RGB: + switch (factor) + { + case 2: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 3: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 4: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 5: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 6: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + } + break; + } + assert(false); +} + + +bool xbrz::equalColorTest(uint32_t col1, uint32_t col2, ColorFormat colFmt, double luminanceWeight, double equalColorTolerance) +{ + switch (colFmt) + { + case ARGB: + return ColorDistanceARGB::dist(col1, col2, luminanceWeight) < equalColorTolerance; + + case RGB: + return ColorDistanceRGB::dist(col1, col2, luminanceWeight) < equalColorTolerance; + } + assert(false); + return false; +} + + +void xbrz::nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, int srcPitch, + uint32_t* trg, int trgWidth, int trgHeight, int trgPitch, + SliceType st, int yFirst, int yLast) +{ + if (srcPitch < srcWidth * static_cast(sizeof(uint32_t)) || + trgPitch < trgWidth * static_cast(sizeof(uint32_t))) + { + assert(false); + return; + } + + switch (st) + { + case NN_SCALE_SLICE_SOURCE: + //nearest-neighbor (going over source image - fast for upscaling, since source is read only once + yFirst = std::max(yFirst, 0); + yLast = std::min(yLast, srcHeight); + if (yFirst >= yLast || trgWidth <= 0 || trgHeight <= 0) return; + + for (int y = yFirst; y < yLast; ++y) + { + //mathematically: ySrc = floor(srcHeight * yTrg / trgHeight) + // => search for integers in: [ySrc, ySrc + 1) * trgHeight / srcHeight + + //keep within for loop to support MT input slices! + const int yTrg_first = ( y * trgHeight + srcHeight - 1) / srcHeight; //=ceil(y * trgHeight / srcHeight) + const int yTrg_last = ((y + 1) * trgHeight + srcHeight - 1) / srcHeight; //=ceil(((y + 1) * trgHeight) / srcHeight) + const int blockHeight = yTrg_last - yTrg_first; + + if (blockHeight > 0) + { + const uint32_t* srcLine = byteAdvance(src, y * srcPitch); + uint32_t* trgLine = byteAdvance(trg, yTrg_first * trgPitch); + int xTrg_first = 0; + + for (int x = 0; x < srcWidth; ++x) + { + int xTrg_last = ((x + 1) * trgWidth + srcWidth - 1) / srcWidth; + const int blockWidth = xTrg_last - xTrg_first; + if (blockWidth > 0) + { + xTrg_first = xTrg_last; + fillBlock(trgLine, trgPitch, srcLine[x], blockWidth, blockHeight); + trgLine += blockWidth; + } + } + } + } + break; + + case NN_SCALE_SLICE_TARGET: + //nearest-neighbor (going over target image - slow for upscaling, since source is read multiple times missing out on cache! Fast for similar image sizes!) + yFirst = std::max(yFirst, 0); + yLast = std::min(yLast, trgHeight); + if (yFirst >= yLast || srcHeight <= 0 || srcWidth <= 0) return; + + for (int y = yFirst; y < yLast; ++y) + { + uint32_t* trgLine = byteAdvance(trg, y * trgPitch); + const int ySrc = srcHeight * y / trgHeight; + const uint32_t* srcLine = byteAdvance(src, ySrc * srcPitch); + for (int x = 0; x < trgWidth; ++x) + { + const int xSrc = srcWidth * x / trgWidth; + trgLine[x] = srcLine[xSrc]; + } + } + break; + } +} diff --git a/src/gl/xbr/xbrz.h b/src/gl/xbr/xbrz.h new file mode 100644 index 000000000..c641429e5 --- /dev/null +++ b/src/gl/xbr/xbrz.h @@ -0,0 +1,102 @@ +// **************************************************************************** +// * This file is part of the HqMAME project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * +// * * +// * Additionally and as a special exception, the author gives permission * +// * to link the code of this program with the MAME library (or with modified * +// * versions of MAME that use the same license as MAME), and distribute * +// * linked combinations including the two. You must obey the GNU General * +// * Public License in all respects for all of the code used other than MAME. * +// * If you modify this file, you may extend this exception to your version * +// * of the file, but you are not obligated to do so. If you do not wish to * +// * do so, delete this exception statement from your version. * +// * * +// * An explicit permission was granted to use xBRZ in combination with ZDoom * +// * and derived projects as long as it is used for non-commercial purposes. * +// * * +// * Backported to C++98 by Alexey Lysiuk * +// **************************************************************************** + +#ifndef XBRZ_HEADER_3847894708239054 +#define XBRZ_HEADER_3847894708239054 + +#include //size_t +#include //uint32_t +#include +#include "xbrz_config.h" + +namespace xbrz +{ +/* +------------------------------------------------------------------------- +| xBRZ: "Scale by rules" - high quality image upscaling filter by Zenju | +------------------------------------------------------------------------- +using a modified approach of xBR: +http://board.byuu.org/viewtopic.php?f=10&t=2248 +- new rule set preserving small image features +- highly optimized for performance +- support alpha channel +- support multithreading +- support 64-bit architectures +- support processing image slices +- support scaling up to 6xBRZ +*/ + +enum ColorFormat //from high bits -> low bits, 8 bit per channel +{ + RGB, //8 bit for each red, green, blue, upper 8 bits unused + ARGB, //including alpha channel, BGRA byte order on little-endian machines +}; + +/* +-> map source (srcWidth * srcHeight) to target (scale * width x scale * height) image, optionally processing a half-open slice of rows [yFirst, yLast) only +-> support for source/target pitch in bytes! +-> if your emulator changes only a few image slices during each cycle (e.g. DOSBox) then there's no need to run xBRZ on the complete image: + Just make sure you enlarge the source image slice by 2 rows on top and 2 on bottom (this is the additional range the xBRZ algorithm is using during analysis) + Caveat: If there are multiple changed slices, make sure they do not overlap after adding these additional rows in order to avoid a memory race condition + in the target image data if you are using multiple threads for processing each enlarged slice! + +THREAD-SAFETY: - parts of the same image may be scaled by multiple threads as long as the [yFirst, yLast) ranges do not overlap! + - there is a minor inefficiency for the first row of a slice, so avoid processing single rows only; suggestion: process 8-16 rows at least +*/ +#ifdef max +#undef max +#endif +void scale(size_t factor, //valid range: 2 - 6 + const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, + ColorFormat colFmt, + const ScalerCfg& cfg = ScalerCfg(), + int yFirst = 0, int yLast = std::numeric_limits::max()); //slice of source image + +void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, + uint32_t* trg, int trgWidth, int trgHeight); + +enum SliceType +{ + NN_SCALE_SLICE_SOURCE, + NN_SCALE_SLICE_TARGET, +}; +void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, int srcPitch, //pitch in bytes! + uint32_t* trg, int trgWidth, int trgHeight, int trgPitch, + SliceType st, int yFirst, int yLast); + +//parameter tuning +bool equalColorTest(uint32_t col1, uint32_t col2, ColorFormat colFmt, double luminanceWeight, double equalColorTolerance); + + + + + +//########################### implementation ########################### +inline +void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, + uint32_t* trg, int trgWidth, int trgHeight) +{ + nearestNeighborScale(src, srcWidth, srcHeight, srcWidth * sizeof(uint32_t), + trg, trgWidth, trgHeight, trgWidth * sizeof(uint32_t), + NN_SCALE_SLICE_TARGET, 0, trgHeight); +} +} + +#endif diff --git a/src/gl/xbr/xbrz_config.h b/src/gl/xbr/xbrz_config.h new file mode 100644 index 000000000..28e9e9044 --- /dev/null +++ b/src/gl/xbr/xbrz_config.h @@ -0,0 +1,45 @@ +// **************************************************************************** +// * This file is part of the HqMAME project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * +// * * +// * Additionally and as a special exception, the author gives permission * +// * to link the code of this program with the MAME library (or with modified * +// * versions of MAME that use the same license as MAME), and distribute * +// * linked combinations including the two. You must obey the GNU General * +// * Public License in all respects for all of the code used other than MAME. * +// * If you modify this file, you may extend this exception to your version * +// * of the file, but you are not obligated to do so. If you do not wish to * +// * do so, delete this exception statement from your version. * +// * * +// * An explicit permission was granted to use xBRZ in combination with ZDoom * +// * and derived projects as long as it is used for non-commercial purposes. * +// * * +// * Backported to C++98 by Alexey Lysiuk * +// **************************************************************************** + +#ifndef XBRZ_CONFIG_HEADER_284578425345 +#define XBRZ_CONFIG_HEADER_284578425345 + +//do NOT include any headers here! used by xBRZ_dll!!! + +namespace xbrz +{ +struct ScalerCfg +{ + ScalerCfg() : + luminanceWeight(1), + equalColorTolerance(30), + dominantDirectionThreshold(3.6), + steepDirectionThreshold(2.2), + newTestAttribute(0) {} + + double luminanceWeight; + double equalColorTolerance; + double dominantDirectionThreshold; + double steepDirectionThreshold; + double newTestAttribute; //unused; test new parameters +}; +} + +#endif \ No newline at end of file diff --git a/src/gl/xbr/xbrz_config_old.h b/src/gl/xbr/xbrz_config_old.h new file mode 100644 index 000000000..480af7976 --- /dev/null +++ b/src/gl/xbr/xbrz_config_old.h @@ -0,0 +1,45 @@ +// **************************************************************************** +// * This file is part of the HqMAME project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * +// * * +// * Additionally and as a special exception, the author gives permission * +// * to link the code of this program with the MAME library (or with modified * +// * versions of MAME that use the same license as MAME), and distribute * +// * linked combinations including the two. You must obey the GNU General * +// * Public License in all respects for all of the code used other than MAME. * +// * If you modify this file, you may extend this exception to your version * +// * of the file, but you are not obligated to do so. If you do not wish to * +// * do so, delete this exception statement from your version. * +// * * +// * An explicit permission was granted to use xBRZ in combination with ZDoom * +// * and derived projects as long as it is used for non-commercial purposes. * +// * * +// * Backported to C++98 by Alexey Lysiuk * +// **************************************************************************** + +#ifndef __XBRZ_CONFIG_OLD_HEADER_INCLUDED__ +#define __XBRZ_CONFIG_OLD_HEADER_INCLUDED__ + +//do NOT include any headers here! used by xBRZ_dll!!! + +namespace xbrz_old +{ +struct ScalerCfg +{ + ScalerCfg() : + luminanceWeight_(1), + equalColorTolerance_(30), + dominantDirectionThreshold(3.6), + steepDirectionThreshold(2.2), + newTestAttribute_(0) {} + + double luminanceWeight_; + double equalColorTolerance_; + double dominantDirectionThreshold; + double steepDirectionThreshold; + double newTestAttribute_; //unused; test new parameters +}; +} + +#endif \ No newline at end of file diff --git a/src/gl/xbr/xbrz_old.cpp b/src/gl/xbr/xbrz_old.cpp new file mode 100644 index 000000000..07527cb95 --- /dev/null +++ b/src/gl/xbr/xbrz_old.cpp @@ -0,0 +1,1365 @@ +// **************************************************************************** +// * This file is part of the HqMAME project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * +// * * +// * Additionally and as a special exception, the author gives permission * +// * to link the code of this program with the MAME library (or with modified * +// * versions of MAME that use the same license as MAME), and distribute * +// * linked combinations including the two. You must obey the GNU General * +// * Public License in all respects for all of the code used other than MAME. * +// * If you modify this file, you may extend this exception to your version * +// * of the file, but you are not obligated to do so. If you do not wish to * +// * do so, delete this exception statement from your version. * +// * * +// * An explicit permission was granted to use xBRZ in combination with ZDoom * +// * and derived projects as long as it is used for non-commercial purposes. * +// * * +// * Backported to C++98 by Alexey Lysiuk * +// **************************************************************************** + +#include "xbrz_old.h" + +#include +#include +#include + +#if __cplusplus > 199711 +#define XBRZ_CXX11 +#endif // __cplusplus > 199711 + +namespace +{ +template inline +unsigned char getByte(uint32_t val) { return static_cast((val >> (8 * N)) & 0xff); } + +inline unsigned char getRed (uint32_t val) { return getByte<2>(val); } +inline unsigned char getGreen(uint32_t val) { return getByte<1>(val); } +inline unsigned char getBlue (uint32_t val) { return getByte<0>(val); } + +template inline +T abs(T value) +{ +#ifdef XBRZ_CXX11 + static_assert(std::numeric_limits::is_signed, ""); +#endif // XBRZ_CXX11 + return value < 0 ? -value : value; +} + +const uint32_t redMask = 0xff0000; +const uint32_t greenMask = 0x00ff00; +const uint32_t blueMask = 0x0000ff; + +template inline +void alphaBlend(uint32_t& dst, uint32_t col) //blend color over destination with opacity N / M +{ +#ifdef XBRZ_CXX11 + static_assert(N < 256, "possible overflow of (col & redMask) * N"); + static_assert(M < 256, "possible overflow of (col & redMask ) * N + (dst & redMask ) * (M - N)"); + static_assert(0 < N && N < M, ""); +#endif // XBRZ_CXX11 + + static const uint32_t ALPHA_MASK = 0xFF000000; + static const uint32_t ALPHA_SHIFT = 24; + + static const uint32_t FULL_OPAQUE = 0xFF; + + const uint32_t colAlpha = col >> ALPHA_SHIFT; + const uint32_t dstAlpha = dst >> ALPHA_SHIFT; + + // Overflow is ignored intentionally! + + const uint32_t alpha = (FULL_OPAQUE == colAlpha && FULL_OPAQUE == dstAlpha) + ? ALPHA_MASK + : ALPHA_MASK & ((colAlpha * N + dstAlpha * (M - N)) / M << ALPHA_SHIFT); + + dst = (redMask & ((col & redMask ) * N + (dst & redMask ) * (M - N)) / M) | //this works because 8 upper bits are free + (greenMask & ((col & greenMask) * N + (dst & greenMask) * (M - N)) / M) | + (blueMask & ((col & blueMask ) * N + (dst & blueMask ) * (M - N)) / M) | + alpha; +} + + +//inline +//double fastSqrt(double n) +//{ +// __asm //speeds up xBRZ by about 9% compared to std::sqrt +// { +// fld n +// fsqrt +// } +//} +// + + +inline +uint32_t alphaBlend2(uint32_t pix1, uint32_t pix2, double alpha) +{ + return (redMask & static_cast((pix1 & redMask ) * alpha + (pix2 & redMask ) * (1 - alpha))) | + (greenMask & static_cast((pix1 & greenMask) * alpha + (pix2 & greenMask) * (1 - alpha))) | + (blueMask & static_cast((pix1 & blueMask ) * alpha + (pix2 & blueMask ) * (1 - alpha))); +} + + +uint32_t* byteAdvance( uint32_t* ptr, int bytes) { return reinterpret_cast< uint32_t*>(reinterpret_cast< char*>(ptr) + bytes); } +const uint32_t* byteAdvance(const uint32_t* ptr, int bytes) { return reinterpret_cast(reinterpret_cast(ptr) + bytes); } + + +//fill block with the given color +inline +void fillBlock(uint32_t* trg, int pitch, uint32_t col, int blockWidth, int blockHeight) +{ + //for (int y = 0; y < blockHeight; ++y, trg = byteAdvance(trg, pitch)) + // std::fill(trg, trg + blockWidth, col); + + for (int y = 0; y < blockHeight; ++y, trg = byteAdvance(trg, pitch)) + for (int x = 0; x < blockWidth; ++x) + trg[x] = col; +} + +inline +void fillBlock(uint32_t* trg, int pitch, uint32_t col, int n) { fillBlock(trg, pitch, col, n, n); } + + +#ifdef _MSC_VER +#define FORCE_INLINE __forceinline +#elif defined __GNUC__ +#define FORCE_INLINE __attribute__((always_inline)) inline +#else +#define FORCE_INLINE inline +#endif + + +enum RotationDegree //clock-wise +{ + ROT_0, + ROT_90, + ROT_180, + ROT_270 +}; + +//calculate input matrix coordinates after rotation at compile time +template +struct MatrixRotation; + +template +struct MatrixRotation +{ + static const size_t I_old = I; + static const size_t J_old = J; +}; + +template //(i, j) = (row, col) indices, N = size of (square) matrix +struct MatrixRotation +{ + static const size_t I_old = N - 1 - MatrixRotation(rotDeg - 1), I, J, N>::J_old; //old coordinates before rotation! + static const size_t J_old = MatrixRotation(rotDeg - 1), I, J, N>::I_old; // +}; + + +template +class OutputMatrix +{ +public: + OutputMatrix(uint32_t* out, int outWidth) : //access matrix area, top-left at position "out" for image with given width + out_(out), + outWidth_(outWidth) {} + + template + uint32_t& ref() const + { + static const size_t I_old = MatrixRotation::I_old; + static const size_t J_old = MatrixRotation::J_old; + return *(out_ + J_old + I_old * outWidth_); + } + +private: + uint32_t* out_; + const int outWidth_; +}; + + +template inline +T square(T value) { return value * value; } + + +/* +inline +void rgbtoLuv(uint32_t c, double& L, double& u, double& v) +{ + //http://www.easyrgb.com/index.php?X=MATH&H=02#text2 + double r = getRed (c) / 255.0; + double g = getGreen(c) / 255.0; + double b = getBlue (c) / 255.0; + + if ( r > 0.04045 ) + r = std::pow(( ( r + 0.055 ) / 1.055 ) , 2.4); + else + r /= 12.92; + if ( g > 0.04045 ) + g = std::pow(( ( g + 0.055 ) / 1.055 ) , 2.4); + else + g /= 12.92; + if ( b > 0.04045 ) + b = std::pow(( ( b + 0.055 ) / 1.055 ) , 2.4); + else + b /= 12.92; + + r *= 100; + g *= 100; + b *= 100; + + double x = 0.4124564 * r + 0.3575761 * g + 0.1804375 * b; + double y = 0.2126729 * r + 0.7151522 * g + 0.0721750 * b; + double z = 0.0193339 * r + 0.1191920 * g + 0.9503041 * b; + //--------------------- + double var_U = 4 * x / ( x + 15 * y + 3 * z ); + double var_V = 9 * y / ( x + 15 * y + 3 * z ); + double var_Y = y / 100; + + if ( var_Y > 0.008856 ) var_Y = std::pow(var_Y , 1.0/3 ); + else var_Y = 7.787 * var_Y + 16.0 / 116; + + const double ref_X = 95.047; //Observer= 2 degree, Illuminant= D65 + const double ref_Y = 100.000; + const double ref_Z = 108.883; + + const double ref_U = ( 4 * ref_X ) / ( ref_X + ( 15 * ref_Y ) + ( 3 * ref_Z ) ); + const double ref_V = ( 9 * ref_Y ) / ( ref_X + ( 15 * ref_Y ) + ( 3 * ref_Z ) ); + + L = ( 116 * var_Y ) - 16; + u = 13 * L * ( var_U - ref_U ); + v = 13 * L * ( var_V - ref_V ); +} +*/ + +inline +void rgbtoLab(uint32_t c, unsigned char& L, signed char& A, signed char& B) +{ + //code: http://www.easyrgb.com/index.php?X=MATH + //test: http://www.workwithcolor.com/color-converter-01.htm + //------RGB to XYZ------ + double r = getRed (c) / 255.0; + double g = getGreen(c) / 255.0; + double b = getBlue (c) / 255.0; + + r = r > 0.04045 ? std::pow(( r + 0.055 ) / 1.055, 2.4) : r / 12.92; + r = g > 0.04045 ? std::pow(( g + 0.055 ) / 1.055, 2.4) : g / 12.92; + r = b > 0.04045 ? std::pow(( b + 0.055 ) / 1.055, 2.4) : b / 12.92; + + r *= 100; + g *= 100; + b *= 100; + + double x = 0.4124564 * r + 0.3575761 * g + 0.1804375 * b; + double y = 0.2126729 * r + 0.7151522 * g + 0.0721750 * b; + double z = 0.0193339 * r + 0.1191920 * g + 0.9503041 * b; + //------XYZ to Lab------ + const double refX = 95.047; // + const double refY = 100.000; //Observer= 2 degree, Illuminant= D65 + const double refZ = 108.883; // + double var_X = x / refX; + double var_Y = y / refY; + double var_Z = z / refZ; + + var_X = var_X > 0.008856 ? std::pow(var_X, 1.0 / 3) : 7.787 * var_X + 4.0 / 29; + var_Y = var_Y > 0.008856 ? std::pow(var_Y, 1.0 / 3) : 7.787 * var_Y + 4.0 / 29; + var_Z = var_Z > 0.008856 ? std::pow(var_Z, 1.0 / 3) : 7.787 * var_Z + 4.0 / 29; + + L = static_cast(116 * var_Y - 16); + A = static_cast< signed char>(500 * (var_X - var_Y)); + B = static_cast< signed char>(200 * (var_Y - var_Z)); +}; + + +inline +double distLAB(uint32_t pix1, uint32_t pix2) +{ + unsigned char L1 = 0; //[0, 100] + signed char a1 = 0; //[-128, 127] + signed char b1 = 0; //[-128, 127] + rgbtoLab(pix1, L1, a1, b1); + + unsigned char L2 = 0; + signed char a2 = 0; + signed char b2 = 0; + rgbtoLab(pix2, L2, a2, b2); + + //----------------------------- + //http://www.easyrgb.com/index.php?X=DELT + + //Delta E/CIE76 + return std::sqrt(square(1.0 * L1 - L2) + + square(1.0 * a1 - a2) + + square(1.0 * b1 - b2)); +} + + +/* +inline +void rgbtoHsl(uint32_t c, double& h, double& s, double& l) +{ + //http://www.easyrgb.com/index.php?X=MATH&H=18#text18 + const int r = getRed (c); + const int g = getGreen(c); + const int b = getBlue (c); + + const int varMin = numeric::min(r, g, b); + const int varMax = numeric::max(r, g, b); + const int delMax = varMax - varMin; + + l = (varMax + varMin) / 2.0 / 255.0; + + if (delMax == 0) //gray, no chroma... + { + h = 0; + s = 0; + } + else + { + s = l < 0.5 ? + delMax / (1.0 * varMax + varMin) : + delMax / (2.0 * 255 - varMax - varMin); + + double delR = ((varMax - r) / 6.0 + delMax / 2.0) / delMax; + double delG = ((varMax - g) / 6.0 + delMax / 2.0) / delMax; + double delB = ((varMax - b) / 6.0 + delMax / 2.0) / delMax; + + if (r == varMax) + h = delB - delG; + else if (g == varMax) + h = 1 / 3.0 + delR - delB; + else if (b == varMax) + h = 2 / 3.0 + delG - delR; + + if (h < 0) + h += 1; + if (h > 1) + h -= 1; + } +} + +inline +double distHSL(uint32_t pix1, uint32_t pix2, double lightningWeight) +{ + double h1 = 0; + double s1 = 0; + double l1 = 0; + rgbtoHsl(pix1, h1, s1, l1); + double h2 = 0; + double s2 = 0; + double l2 = 0; + rgbtoHsl(pix2, h2, s2, l2); + + //HSL is in cylindric coordinatates where L represents height, S radius, H angle, + //however we interpret the cylinder as a bi-conic solid with top/bottom radius 0, middle radius 1 + assert(0 <= h1 && h1 <= 1); + assert(0 <= h2 && h2 <= 1); + + double r1 = l1 < 0.5 ? + l1 * 2 : + 2 - l1 * 2; + + double x1 = r1 * s1 * std::cos(h1 * 2 * numeric::pi); + double y1 = r1 * s1 * std::sin(h1 * 2 * numeric::pi); + double z1 = l1; + + double r2 = l2 < 0.5 ? + l2 * 2 : + 2 - l2 * 2; + + double x2 = r2 * s2 * std::cos(h2 * 2 * numeric::pi); + double y2 = r2 * s2 * std::sin(h2 * 2 * numeric::pi); + double z2 = l2; + + return 255 * std::sqrt(square(x1 - x2) + square(y1 - y2) + square(lightningWeight * (z1 - z2))); +} +*/ + + +inline +double distRGB(uint32_t pix1, uint32_t pix2) +{ + const double r_diff = static_cast(getRed (pix1)) - getRed (pix2); + const double g_diff = static_cast(getGreen(pix1)) - getGreen(pix2); + const double b_diff = static_cast(getBlue (pix1)) - getBlue (pix2); + + //euklidean RGB distance + return std::sqrt(square(r_diff) + square(g_diff) + square(b_diff)); +} + + +inline +double distNonLinearRGB(uint32_t pix1, uint32_t pix2) +{ + //non-linear rgb: http://www.compuphase.com/cmetric.htm + const double r_diff = static_cast(getRed (pix1)) - getRed (pix2); + const double g_diff = static_cast(getGreen(pix1)) - getGreen(pix2); + const double b_diff = static_cast(getBlue (pix1)) - getBlue (pix2); + + const double r_avg = (static_cast(getRed(pix1)) + getRed(pix2)) / 2; + return std::sqrt((2 + r_avg / 255) * square(r_diff) + 4 * square(g_diff) + (2 + (255 - r_avg) / 255) * square(b_diff)); +} + + +inline +double distYCbCr(uint32_t pix1, uint32_t pix2, double lumaWeight) +{ + //http://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion + //YCbCr conversion is a matrix multiplication => take advantage of linearity by subtracting first! + const int r_diff = static_cast(getRed (pix1)) - getRed (pix2); //we may delay division by 255 to after matrix multiplication + const int g_diff = static_cast(getGreen(pix1)) - getGreen(pix2); // + const int b_diff = static_cast(getBlue (pix1)) - getBlue (pix2); //substraction for int is noticeable faster than for double! + + const double k_b = 0.0722; //ITU-R BT.709 conversion + const double k_r = 0.2126; // + const double k_g = 1 - k_b - k_r; + + const double scale_b = 0.5 / (1 - k_b); + const double scale_r = 0.5 / (1 - k_r); + + const double y = k_r * r_diff + k_g * g_diff + k_b * b_diff; //[!], analog YCbCr! + const double c_b = scale_b * (b_diff - y); + const double c_r = scale_r * (r_diff - y); + + //we skip division by 255 to have similar range like other distance functions + return std::sqrt(square(lumaWeight * y) + square(c_b) + square(c_r)); +} + + +inline +double distYUV(uint32_t pix1, uint32_t pix2, double luminanceWeight) +{ + //perf: it's not worthwhile to buffer the YUV-conversion, the direct code is faster by ~ 6% + //since RGB -> YUV conversion is essentially a matrix multiplication, we can calculate the RGB diff before the conversion (distributive property) + const double r_diff = static_cast(getRed (pix1)) - getRed (pix2); + const double g_diff = static_cast(getGreen(pix1)) - getGreen(pix2); + const double b_diff = static_cast(getBlue (pix1)) - getBlue (pix2); + + //http://en.wikipedia.org/wiki/YUV#Conversion_to.2Ffrom_RGB + const double w_b = 0.114; + const double w_r = 0.299; + const double w_g = 1 - w_r - w_b; + + const double u_max = 0.436; + const double v_max = 0.615; + + const double scale_u = u_max / (1 - w_b); + const double scale_v = v_max / (1 - w_r); + + double y = w_r * r_diff + w_g * g_diff + w_b * b_diff;//value range: 255 * [-1, 1] + double u = scale_u * (b_diff - y); //value range: 255 * 2 * u_max * [-1, 1] + double v = scale_v * (r_diff - y); //value range: 255 * 2 * v_max * [-1, 1] + +#ifndef NDEBUG + const double eps = 0.5; +#endif + assert(std::abs(y) <= 255 + eps); + assert(std::abs(u) <= 255 * 2 * u_max + eps); + assert(std::abs(v) <= 255 * 2 * v_max + eps); + + return std::sqrt(square(luminanceWeight * y) + square(u) + square(v)); +} + + +inline +double colorDist(uint32_t pix1, uint32_t pix2, double luminanceWeight) +{ + if (pix1 == pix2) //about 8% perf boost + return 0; + + //return distHSL(pix1, pix2, luminanceWeight); + //return distRGB(pix1, pix2); + //return distLAB(pix1, pix2); + //return distNonLinearRGB(pix1, pix2); + //return distYUV(pix1, pix2, luminanceWeight); + + return distYCbCr(pix1, pix2, luminanceWeight); +} + + +enum BlendType +{ + BLEND_NONE = 0, + BLEND_NORMAL, //a normal indication to blend + BLEND_DOMINANT, //a strong indication to blend + //attention: BlendType must fit into the value range of 2 bit!!! +}; + +struct BlendResult +{ + BlendType + /**/blend_f, blend_g, + /**/blend_j, blend_k; +}; + + +struct Kernel_4x4 //kernel for preprocessing step +{ + uint32_t + /**/a, b, c, d, + /**/e, f, g, h, + /**/i, j, k, l, + /**/m, n, o, p; +}; + +/* +input kernel area naming convention: +----------------- +| A | B | C | D | +----|---|---|---| +| E | F | G | H | //evalute the four corners between F, G, J, K +----|---|---|---| //input pixel is at position F +| I | J | K | L | +----|---|---|---| +| M | N | O | P | +----------------- +*/ +FORCE_INLINE //detect blend direction +BlendResult preProcessCorners(const Kernel_4x4& ker, const xbrz_old::ScalerCfg& cfg) //result: F, G, J, K corners of "GradientType" +{ + BlendResult result = {}; + + if ((ker.f == ker.g && + ker.j == ker.k) || + (ker.f == ker.j && + ker.g == ker.k)) + return result; + +#ifdef XBRZ_CXX11 + auto dist = [&](uint32_t col1, uint32_t col2) { return colorDist(col1, col2, cfg.luminanceWeight_); }; +#else // !XBRZ_CXX11 +#define dist(C1, C2) colorDist((C1), (C2), cfg.luminanceWeight_) +#endif // XBRZ_CXX11 + + const int weight = 4; + double jg = dist(ker.i, ker.f) + dist(ker.f, ker.c) + dist(ker.n, ker.k) + dist(ker.k, ker.h) + weight * dist(ker.j, ker.g); + double fk = dist(ker.e, ker.j) + dist(ker.j, ker.o) + dist(ker.b, ker.g) + dist(ker.g, ker.l) + weight * dist(ker.f, ker.k); + +#ifndef XBRZ_CXX11 +#undef dist +#endif // !XBRZ_CXX11 + + if (jg < fk) //test sample: 70% of values max(jg, fk) / min(jg, fk) are between 1.1 and 3.7 with median being 1.8 + { + const bool dominantGradient = cfg.dominantDirectionThreshold * jg < fk; + if (ker.f != ker.g && ker.f != ker.j) + result.blend_f = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + + if (ker.k != ker.j && ker.k != ker.g) + result.blend_k = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + } + else if (fk < jg) + { + const bool dominantGradient = cfg.dominantDirectionThreshold * fk < jg; + if (ker.j != ker.f && ker.j != ker.k) + result.blend_j = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + + if (ker.g != ker.f && ker.g != ker.k) + result.blend_g = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + } + return result; +} + +struct Kernel_3x3 +{ + uint32_t + /**/a, b, c, + /**/d, e, f, + /**/g, h, i; +}; + +#define DEF_GETTER(x) template uint32_t inline get_##x(const Kernel_3x3& ker) { return ker.x; } +//we cannot and NEED NOT write "ker.##x" since ## concatenates preprocessor tokens but "." is not a token +DEF_GETTER(a) DEF_GETTER(b) DEF_GETTER(c) +DEF_GETTER(d) DEF_GETTER(e) DEF_GETTER(f) +DEF_GETTER(g) DEF_GETTER(h) DEF_GETTER(i) +#undef DEF_GETTER + +#define DEF_GETTER(x, y) template <> inline uint32_t get_##x(const Kernel_3x3& ker) { return ker.y; } +DEF_GETTER(a, g) DEF_GETTER(b, d) DEF_GETTER(c, a) +DEF_GETTER(d, h) DEF_GETTER(e, e) DEF_GETTER(f, b) +DEF_GETTER(g, i) DEF_GETTER(h, f) DEF_GETTER(i, c) +#undef DEF_GETTER + +#define DEF_GETTER(x, y) template <> inline uint32_t get_##x(const Kernel_3x3& ker) { return ker.y; } +DEF_GETTER(a, i) DEF_GETTER(b, h) DEF_GETTER(c, g) +DEF_GETTER(d, f) DEF_GETTER(e, e) DEF_GETTER(f, d) +DEF_GETTER(g, c) DEF_GETTER(h, b) DEF_GETTER(i, a) +#undef DEF_GETTER + +#define DEF_GETTER(x, y) template <> inline uint32_t get_##x(const Kernel_3x3& ker) { return ker.y; } +DEF_GETTER(a, c) DEF_GETTER(b, f) DEF_GETTER(c, i) +DEF_GETTER(d, b) DEF_GETTER(e, e) DEF_GETTER(f, h) +DEF_GETTER(g, a) DEF_GETTER(h, d) DEF_GETTER(i, g) +#undef DEF_GETTER + + +//compress four blend types into a single byte +inline BlendType getTopL (unsigned char b) { return static_cast(0x3 & b); } +inline BlendType getTopR (unsigned char b) { return static_cast(0x3 & (b >> 2)); } +inline BlendType getBottomR(unsigned char b) { return static_cast(0x3 & (b >> 4)); } +inline BlendType getBottomL(unsigned char b) { return static_cast(0x3 & (b >> 6)); } + +inline void setTopL (unsigned char& b, BlendType bt) { b |= bt; } //buffer is assumed to be initialized before preprocessing! +inline void setTopR (unsigned char& b, BlendType bt) { b |= (bt << 2); } +inline void setBottomR(unsigned char& b, BlendType bt) { b |= (bt << 4); } +inline void setBottomL(unsigned char& b, BlendType bt) { b |= (bt << 6); } + +inline bool blendingNeeded(unsigned char b) { return b != 0; } + +template inline +unsigned char rotateBlendInfo(unsigned char b) { return b; } +template <> inline unsigned char rotateBlendInfo(unsigned char b) { return ((b << 2) | (b >> 6)) & 0xff; } +template <> inline unsigned char rotateBlendInfo(unsigned char b) { return ((b << 4) | (b >> 4)) & 0xff; } +template <> inline unsigned char rotateBlendInfo(unsigned char b) { return ((b << 6) | (b >> 2)) & 0xff; } + + +#ifndef NDEBUG +int debugPixelX = -1; +int debugPixelY = 84; +bool breakIntoDebugger = false; +#endif + +#define a get_a(ker) +#define b get_b(ker) +#define c get_c(ker) +#define d get_d(ker) +#define e get_e(ker) +#define f get_f(ker) +#define g get_g(ker) +#define h get_h(ker) +#define i get_i(ker) + +#ifndef XBRZ_CXX11 + +template +bool doLineBlend(const Kernel_3x3& ker, const xbrz_old::ScalerCfg& cfg, const unsigned char blend) +{ + if (getBottomR(blend) >= BLEND_DOMINANT) + return true; + +#define eq(C1, C2) (colorDist((C1), (C2), cfg.luminanceWeight_) < cfg.equalColorTolerance_) + + //make sure there is no second blending in an adjacent rotation for this pixel: handles insular pixels, mario eyes + if (getTopR(blend) != BLEND_NONE && !eq(e, g)) //but support double-blending for 90 degree corners + return false; + if (getBottomL(blend) != BLEND_NONE && !eq(e, c)) + return false; + + //no full blending for L-shapes; blend corner only (handles "mario mushroom eyes") + if (eq(g, h) && eq(h , i) && eq(i, f) && eq(f, c) && !eq(e, i)) + return false; + +#undef eq + + return true; +}; + +#endif // !XBRZ_CXX11 + +/* +input kernel area naming convention: +------------- +| A | B | C | +----|---|---| +| D | E | F | //input pixel is at position E +----|---|---| +| G | H | I | +------------- +*/ +template +FORCE_INLINE //perf: quite worth it! +void scalePixel(const Kernel_3x3& ker, + uint32_t* target, int trgWidth, + unsigned char blendInfo, //result of preprocessing all four corners of pixel "e" + const xbrz_old::ScalerCfg& cfg) +{ +#ifndef NDEBUG + if (breakIntoDebugger) +#ifdef _MSC_VER + __debugbreak(); //__asm int 3; +#else // !_MSC_VER + __builtin_trap(); +#endif // _MSC_VER +#endif + + const unsigned char blend = rotateBlendInfo(blendInfo); + + if (getBottomR(blend) >= BLEND_NORMAL) + { +#ifdef XBRZ_CXX11 + auto eq = [&](uint32_t col1, uint32_t col2) { return colorDist(col1, col2, cfg.luminanceWeight_) < cfg.equalColorTolerance_; }; + auto dist = [&](uint32_t col1, uint32_t col2) { return colorDist(col1, col2, cfg.luminanceWeight_); }; + + const bool doLineBlend = [&]() -> bool + { + if (getBottomR(blend) >= BLEND_DOMINANT) + return true; + + //make sure there is no second blending in an adjacent rotation for this pixel: handles insular pixels, mario eyes + if (getTopR(blend) != BLEND_NONE && !eq(e, g)) //but support double-blending for 90 degree corners + return false; + if (getBottomL(blend) != BLEND_NONE && !eq(e, c)) + return false; + + //no full blending for L-shapes; blend corner only (handles "mario mushroom eyes") + if (eq(g, h) && eq(h , i) && eq(i, f) && eq(f, c) && !eq(e, i)) + return false; + + return true; + }(); +#else // !XBRZ_CXX11 +#define dist(C1, C2) colorDist((C1), (C2), cfg.luminanceWeight_) +#endif // XBRZ_CXX11 + + const uint32_t px = dist(e, f) <= dist(e, h) ? f : h; //choose most similar color + + OutputMatrix out(target, trgWidth); + +#ifdef XBRZ_CXX11 + if (doLineBlend) +#else // !XBRZ_CXX11 + if (doLineBlend(ker, cfg, blend)) +#endif // XBRZ_CXX11 + { + const double fg = dist(f, g); //test sample: 70% of values max(fg, hc) / min(fg, hc) are between 1.1 and 3.7 with median being 1.9 + const double hc = dist(h, c); // + + const bool haveShallowLine = cfg.steepDirectionThreshold * fg <= hc && e != g && d != g; + const bool haveSteepLine = cfg.steepDirectionThreshold * hc <= fg && e != c && b != c; + + if (haveShallowLine) + { + if (haveSteepLine) + Scaler::blendLineSteepAndShallow(px, out); + else + Scaler::blendLineShallow(px, out); + } + else + { + if (haveSteepLine) + Scaler::blendLineSteep(px, out); + else + Scaler::blendLineDiagonal(px,out); + } + } + else + Scaler::blendCorner(px, out); + } + +#ifndef XBRZ_CXX11 +#undef dist +#endif // XBRZ_CXX11 + +#undef a +#undef b +#undef c +#undef d +#undef e +#undef f +#undef g +#undef h +#undef i +} + + +template //scaler policy: see "Scaler2x" reference implementation +void scaleImage(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz_old::ScalerCfg& cfg, int yFirst, int yLast) +{ + yFirst = std::max(yFirst, 0); + yLast = std::min(yLast, srcHeight); + if (yFirst >= yLast || srcWidth <= 0) + return; + + const int trgWidth = srcWidth * Scaler::scale; + + //"use" space at the end of the image as temporary buffer for "on the fly preprocessing": we even could use larger area of + //"sizeof(uint32_t) * srcWidth * (yLast - yFirst)" bytes without risk of accidental overwriting before accessing + const int bufferSize = srcWidth; + unsigned char* preProcBuffer = reinterpret_cast(trg + yLast * Scaler::scale * trgWidth) - bufferSize; + std::fill(preProcBuffer, preProcBuffer + bufferSize, 0); +#ifdef XBRZ_CXX11 + static_assert(BLEND_NONE == 0, ""); +#endif // XBRZ_CXX11 + + //initialize preprocessing buffer for first row: detect upper left and right corner blending + //this cannot be optimized for adjacent processing stripes; we must not allow for a memory race condition! + if (yFirst > 0) + { + const int y = yFirst - 1; + + const uint32_t* s_m1 = src + srcWidth * std::max(y - 1, 0); + const uint32_t* s_0 = src + srcWidth * y; //center line + const uint32_t* s_p1 = src + srcWidth * std::min(y + 1, srcHeight - 1); + const uint32_t* s_p2 = src + srcWidth * std::min(y + 2, srcHeight - 1); + + for (int x = 0; x < srcWidth; ++x) + { + const int x_m1 = std::max(x - 1, 0); + const int x_p1 = std::min(x + 1, srcWidth - 1); + const int x_p2 = std::min(x + 2, srcWidth - 1); + + Kernel_4x4 ker = {}; //perf: initialization is negligable + ker.a = s_m1[x_m1]; //read sequentially from memory as far as possible + ker.b = s_m1[x]; + ker.c = s_m1[x_p1]; + ker.d = s_m1[x_p2]; + + ker.e = s_0[x_m1]; + ker.f = s_0[x]; + ker.g = s_0[x_p1]; + ker.h = s_0[x_p2]; + + ker.i = s_p1[x_m1]; + ker.j = s_p1[x]; + ker.k = s_p1[x_p1]; + ker.l = s_p1[x_p2]; + + ker.m = s_p2[x_m1]; + ker.n = s_p2[x]; + ker.o = s_p2[x_p1]; + ker.p = s_p2[x_p2]; + + const BlendResult res = preProcessCorners(ker, cfg); + /* + preprocessing blend result: + --------- + | F | G | //evalute corner between F, G, J, K + ----|---| //input pixel is at position F + | J | K | + --------- + */ + setTopR(preProcBuffer[x], res.blend_j); + + if (x + 1 < srcWidth) + setTopL(preProcBuffer[x + 1], res.blend_k); + } + } + //------------------------------------------------------------------------------------ + + for (int y = yFirst; y < yLast; ++y) + { + uint32_t* out = trg + Scaler::scale * y * trgWidth; //consider MT "striped" access + + const uint32_t* s_m1 = src + srcWidth * std::max(y - 1, 0); + const uint32_t* s_0 = src + srcWidth * y; //center line + const uint32_t* s_p1 = src + srcWidth * std::min(y + 1, srcHeight - 1); + const uint32_t* s_p2 = src + srcWidth * std::min(y + 2, srcHeight - 1); + + unsigned char blend_xy1 = 0; //corner blending for current (x, y + 1) position + + for (int x = 0; x < srcWidth; ++x, out += Scaler::scale) + { +#ifndef NDEBUG + breakIntoDebugger = debugPixelX == x && debugPixelY == y; +#endif + //all those bounds checks have only insignificant impact on performance! + const int x_m1 = std::max(x - 1, 0); //perf: prefer array indexing to additional pointers! + const int x_p1 = std::min(x + 1, srcWidth - 1); + const int x_p2 = std::min(x + 2, srcWidth - 1); + + //evaluate the four corners on bottom-right of current pixel + unsigned char blend_xy = 0; //for current (x, y) position + { + Kernel_4x4 ker = {}; //perf: initialization is negligable + ker.a = s_m1[x_m1]; //read sequentially from memory as far as possible + ker.b = s_m1[x]; + ker.c = s_m1[x_p1]; + ker.d = s_m1[x_p2]; + + ker.e = s_0[x_m1]; + ker.f = s_0[x]; + ker.g = s_0[x_p1]; + ker.h = s_0[x_p2]; + + ker.i = s_p1[x_m1]; + ker.j = s_p1[x]; + ker.k = s_p1[x_p1]; + ker.l = s_p1[x_p2]; + + ker.m = s_p2[x_m1]; + ker.n = s_p2[x]; + ker.o = s_p2[x_p1]; + ker.p = s_p2[x_p2]; + + const BlendResult res = preProcessCorners(ker, cfg); + /* + preprocessing blend result: + --------- + | F | G | //evalute corner between F, G, J, K + ----|---| //current input pixel is at position F + | J | K | + --------- + */ + blend_xy = preProcBuffer[x]; + setBottomR(blend_xy, res.blend_f); //all four corners of (x, y) have been determined at this point due to processing sequence! + + setTopR(blend_xy1, res.blend_j); //set 2nd known corner for (x, y + 1) + preProcBuffer[x] = blend_xy1; //store on current buffer position for use on next row + + blend_xy1 = 0; + setTopL(blend_xy1, res.blend_k); //set 1st known corner for (x + 1, y + 1) and buffer for use on next column + + if (x + 1 < srcWidth) //set 3rd known corner for (x + 1, y) + setBottomL(preProcBuffer[x + 1], res.blend_g); + } + + //fill block of size scale * scale with the given color + fillBlock(out, trgWidth * sizeof(uint32_t), s_0[x], Scaler::scale); //place *after* preprocessing step, to not overwrite the results while processing the the last pixel! + + //blend four corners of current pixel + if (blendingNeeded(blend_xy)) //good 20% perf-improvement + { + Kernel_3x3 ker = {}; //perf: initialization is negligable + + ker.a = s_m1[x_m1]; //read sequentially from memory as far as possible + ker.b = s_m1[x]; + ker.c = s_m1[x_p1]; + + ker.d = s_0[x_m1]; + ker.e = s_0[x]; + ker.f = s_0[x_p1]; + + ker.g = s_p1[x_m1]; + ker.h = s_p1[x]; + ker.i = s_p1[x_p1]; + + scalePixel(ker, out, trgWidth, blend_xy, cfg); + scalePixel(ker, out, trgWidth, blend_xy, cfg); + scalePixel(ker, out, trgWidth, blend_xy, cfg); + scalePixel(ker, out, trgWidth, blend_xy, cfg); + } + } + } +} + + +struct Scaler2x +{ + static const int scale = 2; + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<0, scale - 1>(), col); + alphaBlend<3, 4>(out.template ref<1, scale - 1>(), col); + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<1, 0>(), col); + alphaBlend<1, 4>(out.template ref<0, 1>(), col); + alphaBlend<5, 6>(out.template ref<1, 1>(), col); //[!] fixes 7/8 used in xBR + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 2>(out.template ref<1, 1>(), col); + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaBlend<21, 100>(out.template ref<1, 1>(), col); //exact: 1 - pi/4 = 0.2146018366 + } +}; + + +struct Scaler3x +{ + static const int scale = 3; + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + + alphaBlend<3, 4>(out.template ref(), col); + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<0, scale - 1>(), col); + alphaBlend<1, 4>(out.template ref<2, scale - 2>(), col); + + alphaBlend<3, 4>(out.template ref<1, scale - 1>(), col); + out.template ref<2, scale - 1>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<2, 0>(), col); + alphaBlend<1, 4>(out.template ref<0, 2>(), col); + alphaBlend<3, 4>(out.template ref<2, 1>(), col); + alphaBlend<3, 4>(out.template ref<1, 2>(), col); + out.template ref<2, 2>() = col; + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 8>(out.template ref<1, 2>(), col); + alphaBlend<1, 8>(out.template ref<2, 1>(), col); + alphaBlend<7, 8>(out.template ref<2, 2>(), col); + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaBlend<45, 100>(out.template ref<2, 2>(), col); //exact: 0.4545939598 + //alphaBlend<14, 1000>(out.template ref<2, 1>(), col); //0.01413008627 -> negligable + //alphaBlend<14, 1000>(out.template ref<1, 2>(), col); //0.01413008627 + } +}; + + +struct Scaler4x +{ + static const int scale = 4; + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + + alphaBlend<3, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<0, scale - 1>(), col); + alphaBlend<1, 4>(out.template ref<2, scale - 2>(), col); + + alphaBlend<3, 4>(out.template ref<1, scale - 1>(), col); + alphaBlend<3, 4>(out.template ref<3, scale - 2>(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<3, 4>(out.template ref<3, 1>(), col); + alphaBlend<3, 4>(out.template ref<1, 3>(), col); + alphaBlend<1, 4>(out.template ref<3, 0>(), col); + alphaBlend<1, 4>(out.template ref<0, 3>(), col); + alphaBlend<1, 3>(out.template ref<2, 2>(), col); //[!] fixes 1/4 used in xBR + out.template ref<3, 3>() = out.template ref<3, 2>() = out.template ref<2, 3>() = col; + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 2>(out.template ref(), col); + alphaBlend<1, 2>(out.template ref(), col); + out.template ref() = col; + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaBlend<68, 100>(out.template ref<3, 3>(), col); //exact: 0.6848532563 + alphaBlend< 9, 100>(out.template ref<3, 2>(), col); //0.08677704501 + alphaBlend< 9, 100>(out.template ref<2, 3>(), col); //0.08677704501 + } +}; + + +struct Scaler5x +{ + static const int scale = 5; + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + + alphaBlend<3, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<0, scale - 1>(), col); + alphaBlend<1, 4>(out.template ref<2, scale - 2>(), col); + alphaBlend<1, 4>(out.template ref<4, scale - 3>(), col); + + alphaBlend<3, 4>(out.template ref<1, scale - 1>(), col); + alphaBlend<3, 4>(out.template ref<3, scale - 2>(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + out.template ref<4, scale - 1>() = col; + out.template ref<4, scale - 2>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<0, scale - 1>(), col); + alphaBlend<1, 4>(out.template ref<2, scale - 2>(), col); + alphaBlend<3, 4>(out.template ref<1, scale - 1>(), col); + + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + + out.template ref() = col; + out.template ref() = col; + + out.template ref<4, scale - 1>() = col; + + alphaBlend<2, 3>(out.template ref<3, 3>(), col); + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 8>(out.template ref(), col); + alphaBlend<1, 8>(out.template ref(), col); + alphaBlend<1, 8>(out.template ref(), col); + + alphaBlend<7, 8>(out.template ref<4, 3>(), col); + alphaBlend<7, 8>(out.template ref<3, 4>(), col); + + out.template ref<4, 4>() = col; + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaBlend<86, 100>(out.template ref<4, 4>(), col); //exact: 0.8631434088 + alphaBlend<23, 100>(out.template ref<4, 3>(), col); //0.2306749731 + alphaBlend<23, 100>(out.template ref<3, 4>(), col); //0.2306749731 + //alphaBlend<8, 1000>(out.template ref<4, 2>(), col); //0.008384061834 -> negligable + //alphaBlend<8, 1000>(out.template ref<2, 4>(), col); //0.008384061834 + } +}; +} + + +struct Scaler6x +{ + static const int scale = 6; + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + + alphaBlend<3, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<0, scale - 1>(), col); + alphaBlend<1, 4>(out.template ref<2, scale - 2>(), col); + alphaBlend<1, 4>(out.template ref<4, scale - 3>(), col); + + alphaBlend<3, 4>(out.template ref<1, scale - 1>(), col); + alphaBlend<3, 4>(out.template ref<3, scale - 2>(), col); + alphaBlend<3, 4>(out.template ref<5, scale - 3>(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + out.template ref<4, scale - 1>() = col; + out.template ref<5, scale - 1>() = col; + + out.template ref<4, scale - 2>() = col; + out.template ref<5, scale - 2>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<0, scale - 1>(), col); + alphaBlend<1, 4>(out.template ref<2, scale - 2>(), col); + alphaBlend<3, 4>(out.template ref<1, scale - 1>(), col); + alphaBlend<3, 4>(out.template ref<3, scale - 2>(), col); + + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + out.template ref<4, scale - 1>() = col; + out.template ref<5, scale - 1>() = col; + + out.template ref<4, scale - 2>() = col; + out.template ref<5, scale - 2>() = col; + + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 2>(out.template ref(), col); + alphaBlend<1, 2>(out.template ref(), col); + alphaBlend<1, 2>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaBlend<97, 100>(out.template ref<5, 5>(), col); //exact: 0.9711013910 + alphaBlend<42, 100>(out.template ref<4, 5>(), col); //0.4236372243 + alphaBlend<42, 100>(out.template ref<5, 4>(), col); //0.4236372243 + alphaBlend< 6, 100>(out.template ref<5, 3>(), col); //0.05652034508 + alphaBlend< 6, 100>(out.template ref<3, 5>(), col); //0.05652034508 + } +}; + + +void xbrz_old::scale(size_t factor, const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz_old::ScalerCfg& cfg, int yFirst, int yLast) +{ + switch (factor) + { + case 2: + return scaleImage(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 3: + return scaleImage(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 4: + return scaleImage(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 5: + return scaleImage(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 6: + return scaleImage(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + } + assert(false); +} + + +bool xbrz_old::equalColor(uint32_t col1, uint32_t col2, double luminanceWeight, double equalColorTolerance) +{ + return colorDist(col1, col2, luminanceWeight) < equalColorTolerance; +} + + +void xbrz_old::nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, int srcPitch, + uint32_t* trg, int trgWidth, int trgHeight, int trgPitch, + SliceType st, int yFirst, int yLast) +{ + if (srcPitch < srcWidth * static_cast(sizeof(uint32_t)) || + trgPitch < trgWidth * static_cast(sizeof(uint32_t))) + { + assert(false); + return; + } + + switch (st) + { + case NN_SCALE_SLICE_SOURCE: + //nearest-neighbor (going over source image - fast for upscaling, since source is read only once + yFirst = std::max(yFirst, 0); + yLast = std::min(yLast, srcHeight); + if (yFirst >= yLast || trgWidth <= 0 || trgHeight <= 0) return; + + for (int y = yFirst; y < yLast; ++y) + { + //mathematically: ySrc = floor(srcHeight * yTrg / trgHeight) + // => search for integers in: [ySrc, ySrc + 1) * trgHeight / srcHeight + + //keep within for loop to support MT input slices! + const int yTrg_first = ( y * trgHeight + srcHeight - 1) / srcHeight; //=ceil(y * trgHeight / srcHeight) + const int yTrg_last = ((y + 1) * trgHeight + srcHeight - 1) / srcHeight; //=ceil(((y + 1) * trgHeight) / srcHeight) + const int blockHeight = yTrg_last - yTrg_first; + + if (blockHeight > 0) + { + const uint32_t* srcLine = byteAdvance(src, y * srcPitch); + uint32_t* trgLine = byteAdvance(trg, yTrg_first * trgPitch); + int xTrg_first = 0; + + for (int x = 0; x < srcWidth; ++x) + { + int xTrg_last = ((x + 1) * trgWidth + srcWidth - 1) / srcWidth; + const int blockWidth = xTrg_last - xTrg_first; + if (blockWidth > 0) + { + xTrg_first = xTrg_last; + fillBlock(trgLine, trgPitch, srcLine[x], blockWidth, blockHeight); + trgLine += blockWidth; + } + } + } + } + break; + + case NN_SCALE_SLICE_TARGET: + //nearest-neighbor (going over target image - slow for upscaling, since source is read multiple times missing out on cache! Fast for similar image sizes!) + yFirst = std::max(yFirst, 0); + yLast = std::min(yLast, trgHeight); + if (yFirst >= yLast || srcHeight <= 0 || srcWidth <= 0) return; + + for (int y = yFirst; y < yLast; ++y) + { + uint32_t* trgLine = byteAdvance(trg, y * trgPitch); + const int ySrc = srcHeight * y / trgHeight; + const uint32_t* srcLine = byteAdvance(src, ySrc * srcPitch); + for (int x = 0; x < trgWidth; ++x) + { + const int xSrc = srcWidth * x / trgWidth; + trgLine[x] = srcLine[xSrc]; + } + } + break; + } +} diff --git a/src/gl/xbr/xbrz_old.h b/src/gl/xbr/xbrz_old.h new file mode 100644 index 000000000..c93a1480a --- /dev/null +++ b/src/gl/xbr/xbrz_old.h @@ -0,0 +1,92 @@ +// **************************************************************************** +// * This file is part of the HqMAME project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * +// * * +// * Additionally and as a special exception, the author gives permission * +// * to link the code of this program with the MAME library (or with modified * +// * versions of MAME that use the same license as MAME), and distribute * +// * linked combinations including the two. You must obey the GNU General * +// * Public License in all respects for all of the code used other than MAME. * +// * If you modify this file, you may extend this exception to your version * +// * of the file, but you are not obligated to do so. If you do not wish to * +// * do so, delete this exception statement from your version. * +// * * +// * An explicit permission was granted to use xBRZ in combination with ZDoom * +// * and derived projects as long as it is used for non-commercial purposes. * +// * * +// * Backported to C++98 by Alexey Lysiuk * +// **************************************************************************** + +#ifndef __XBRZ_OLD_HEADER_INCLUDED__ +#define __XBRZ_OLD_HEADER_INCLUDED__ + +#include //size_t +#include //uint32_t +#include +#include "xbrz_config_old.h" + +namespace xbrz_old +{ +/* +------------------------------------------------------------------------- +| xBRZ: "Scale by rules" - high quality image upscaling filter by Zenju | +------------------------------------------------------------------------- +using a modified approach of xBR: +http://board.byuu.org/viewtopic.php?f=10&t=2248 +- new rule set preserving small image features +- support multithreading +- support 64 bit architectures +- support processing image slices +*/ + +/* +-> map source (srcWidth * srcHeight) to target (scale * width x scale * height) image, optionally processing a half-open slice of rows [yFirst, yLast) only +-> color format: ARGB (BGRA byte order), alpha channel unused +-> support for source/target pitch in bytes! +-> if your emulator changes only a few image slices during each cycle (e.g. Dosbox) then there's no need to run xBRZ on the complete image: + Just make sure you enlarge the source image slice by 2 rows on top and 2 on bottom (this is the additional range the xBRZ algorithm is using during analysis) + Caveat: If there are multiple changed slices, make sure they do not overlap after adding these additional rows in order to avoid a memory race condition + if you are using multiple threads for processing each enlarged slice! + +THREAD-SAFETY: - parts of the same image may be scaled by multiple threads as long as the [yFirst, yLast) ranges do not overlap! + - there is a minor inefficiency for the first row of a slice, so avoid processing single rows only + + +*/ +void scale(size_t factor, //valid range: 2 - 5 + const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, + const ScalerCfg& cfg = ScalerCfg(), + int yFirst = 0, int yLast = std::numeric_limits::max()); //slice of source image + +void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, + uint32_t* trg, int trgWidth, int trgHeight); + +enum SliceType +{ + NN_SCALE_SLICE_SOURCE, + NN_SCALE_SLICE_TARGET, +}; +void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, int srcPitch, //pitch in bytes! + uint32_t* trg, int trgWidth, int trgHeight, int trgPitch, + SliceType st, int yFirst, int yLast); + +//parameter tuning +bool equalColor(uint32_t col1, uint32_t col2, double luminanceWeight, double equalColorTolerance); + + + + + +//########################### implementation ########################### +inline +void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, + uint32_t* trg, int trgWidth, int trgHeight) +{ + nearestNeighborScale(src, srcWidth, srcHeight, srcWidth * sizeof(uint32_t), + trg, trgWidth, trgHeight, trgWidth * sizeof(uint32_t), + NN_SCALE_SLICE_TARGET, 0, trgHeight); +} +} + +#endif From 217601f3385d771ed657bff023b98d3ef8a7724f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 4 Sep 2016 01:46:29 +0200 Subject: [PATCH 0883/1509] - fixed: FPortal::ClearScreen may not use the 2D drawing code anymore. 2D calls are accumulated and then executed all at once at the end of the frame, but this one needs to be interleaved with the 3D rendering. It now uses the quad drawer to fill the portal with blackness. --- src/gl/scene/gl_portal.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index cd3efb9e3..b613032ea 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -56,6 +56,7 @@ #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_quaddrawer.h" #include "gl/dynlights/gl_glow.h" #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" @@ -128,8 +129,21 @@ void GLPortal::ClearScreen() bool multi = !!glIsEnabled(GL_MULTISAMPLE); gl_MatrixStack.Push(gl_RenderState.mViewMatrix); gl_MatrixStack.Push(gl_RenderState.mProjectionMatrix); - screen->Begin2D(false); - screen->Dim(0, 1.f, 0, 0, SCREENWIDTH, SCREENHEIGHT); + + gl_RenderState.mViewMatrix.loadIdentity(); + gl_RenderState.mProjectionMatrix.ortho(0, SCREENWIDTH, SCREENHEIGHT, 0, -1.0f, 1.0f); + gl_RenderState.ApplyMatrices(); + + glDisable(GL_MULTISAMPLE); + glDisable(GL_DEPTH_TEST); + + FQuadDrawer qd; + qd.Set(0, 0, 0, 0, 0, 0); + qd.Set(1, 0, SCREENHEIGHT, 0, 0, 0); + qd.Set(2, SCREENWIDTH, SCREENHEIGHT, 0, 0, 0); + qd.Set(3, SCREENWIDTH, 0, 0, 0, 0); + qd.Render(GL_TRIANGLE_FAN); + glEnable(GL_DEPTH_TEST); gl_MatrixStack.Pop(gl_RenderState.mProjectionMatrix); gl_MatrixStack.Pop(gl_RenderState.mViewMatrix); @@ -137,7 +151,6 @@ void GLPortal::ClearScreen() if (multi) glEnable(GL_MULTISAMPLE); } - //----------------------------------------------------------------------------- // // DrawPortalStencil From dc39a006dc3d58182d2dba83a4ac50258799c9f6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 4 Sep 2016 02:37:59 +0200 Subject: [PATCH 0884/1509] Fix palette tonemap precision and compile error on Intel --- src/gl/renderer/gl_postprocess.cpp | 2 +- wadsrc/static/shaders/glsl/tonemap.fp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 77ee5cd79..645bc3fe1 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -257,7 +257,7 @@ void FGLRenderer::BindTonemapPalette(int texunit) { for (int b = 0; b < 64; b++) { - PalEntry color = GPalette.BaseColors[ColorMatcher.Pick((r << 2) | (r >> 1), (g << 2) | (g >> 1), (b << 2) | (b >> 1))]; + PalEntry color = GPalette.BaseColors[ColorMatcher.Pick((r << 2) | (r >> 4), (g << 2) | (g >> 4), (b << 2) | (b >> 4))]; int index = ((r * 64 + g) * 64 + b) * 4; lut[index] = color.r; lut[index + 1] = color.g; diff --git a/wadsrc/static/shaders/glsl/tonemap.fp b/wadsrc/static/shaders/glsl/tonemap.fp index c33349a38..d6574b295 100644 --- a/wadsrc/static/shaders/glsl/tonemap.fp +++ b/wadsrc/static/shaders/glsl/tonemap.fp @@ -69,15 +69,15 @@ uniform sampler2D PaletteLUT; vec3 Tonemap(vec3 color) { - ivec3 c = ivec3(clamp(color.rgb, vec3(0.0), vec3(1.0)) * 255.0 + 0.5); - int index = ((c.r >> 2) * 64 + (c.g >> 2)) * 64 + (c.b >> 2); + ivec3 c = ivec3(clamp(color.rgb, vec3(0.0), vec3(1.0)) * 63.0 + 0.5); + int index = (c.r * 64 + c.g) * 64 + c.b; int tx = index % 512; int ty = index / 512; return texelFetch(PaletteLUT, ivec2(tx, ty), 0).rgb; } #else -#error "Tonemap mode define is missing" +#error Tonemap mode define is missing #endif void main() From 5f02e08c8e133f93d9e9e72e004e662d15ef8b7d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 4 Sep 2016 03:15:50 +0200 Subject: [PATCH 0885/1509] Fix minimize crash --- src/gl/renderer/gl_postprocess.cpp | 2 ++ src/gl/renderer/gl_renderer.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 645bc3fe1..e6ca7faad 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -444,6 +444,8 @@ void FGLRenderer::ClearBorders() int clientWidth = framebuffer->GetClientWidth(); int clientHeight = framebuffer->GetClientHeight(); + if (clientWidth == 0 || clientHeight == 0) + return; glViewport(0, 0, clientWidth, clientHeight); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 6cd38390f..f9d627d93 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -231,6 +231,13 @@ void FGLRenderer::SetOutputViewport(GL_IRECT *bounds) // Back buffer letterbox for the final output int clientWidth = framebuffer->GetClientWidth(); int clientHeight = framebuffer->GetClientHeight(); + if (clientWidth == 0 || clientHeight == 0) + { + // When window is minimized there may not be any client area. + // Pretend to the rest of the render code that we just have a very small window. + clientWidth = 160; + clientHeight = 120; + } int screenWidth = framebuffer->GetWidth(); int screenHeight = framebuffer->GetHeight(); float scale = MIN(clientWidth / (float)screenWidth, clientHeight / (float)screenHeight); From 527703ae8c2612a63925e4e7296df49f9ea3af22 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 4 Sep 2016 03:21:47 +0200 Subject: [PATCH 0886/1509] Fix missing flash if multisampling was on and no post processing effects active --- src/gl/scene/gl_scene.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index b4dd95d50..23d7c7c80 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -856,7 +856,11 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo TonemapScene(); ColormapScene(); LensDistortScene(); - DrawBlend(viewsector); // This should be done after postprocessing, not before. + + // This should be done after postprocessing, not before. + mBuffers->BindCurrentFB(); + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + DrawBlend(viewsector); } mDrawingScene2D = false; eye->TearDown(); From 3727c5ed0fc50f2bcaff689766e9d728ddf017a5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 4 Sep 2016 08:15:29 +0200 Subject: [PATCH 0887/1509] Mark portals in scene alpha channel for the SSAO pass --- src/gl/renderer/gl_postprocess.cpp | 5 +++++ src/gl/renderer/gl_renderbuffers.cpp | 15 +++++++++++++++ src/gl/renderer/gl_renderbuffers.h | 1 + src/gl/scene/gl_portal.cpp | 8 +++++--- src/gl/shaders/gl_ambientshader.cpp | 1 + src/gl/shaders/gl_ambientshader.h | 1 + wadsrc/static/shaders/glsl/lineardepth.fp | 8 +++++--- wadsrc/static/shaders/glsl/stencil.fp | 2 +- 8 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 56032704e..512209454 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -179,8 +179,13 @@ void FGLRenderer::AmbientOccludeScene() mBuffers->BindSceneDepthTexture(0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + mBuffers->BindSceneColorTexture(1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glActiveTexture(GL_TEXTURE0); mLinearDepthShader->Bind(multisample); mLinearDepthShader->DepthTexture[multisample].Set(0); + mLinearDepthShader->ColorTexture[multisample].Set(1); if (multisample) mLinearDepthShader->SampleCount[multisample].Set(gl_multisample); mLinearDepthShader->LinearizeDepthA[multisample].Set(1.0f / GetZFar() - 1.0f / GetZNear()); mLinearDepthShader->LinearizeDepthB[multisample].Set(MAX(1.0f / GetZNear(), 1.e-8f)); diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index b2cee5704..b0ea123a0 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -555,6 +555,21 @@ void FGLRenderBuffers::BindSceneFB() glBindFramebuffer(GL_FRAMEBUFFER, mSceneFB); } +//========================================================================== +// +// Binds the scene color texture to the specified texture unit +// +//========================================================================== + +void FGLRenderBuffers::BindSceneColorTexture(int index) +{ + glActiveTexture(GL_TEXTURE0 + index); + if (mSamples > 1) + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mSceneMultisample); + else + glBindTexture(GL_TEXTURE_2D, mPipelineTexture[0]); +} + //========================================================================== // // Binds the depth texture to the specified texture unit diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 32430f2ed..2661908e3 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -23,6 +23,7 @@ public: bool Setup(int width, int height, int sceneWidth, int sceneHeight); void BindSceneFB(); + void BindSceneColorTexture(int index); void BindSceneDepthTexture(int index); void BlitSceneToTexture(); diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index cd3efb9e3..20ded84aa 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -429,14 +429,16 @@ void GLPortal::End(bool usestencil) glDepthFunc(GL_LEQUAL); glDepthRange(0, 1); { - ScopedColorMask colorMask(0, 0, 0, 0); - // glColorMask(0,0,0,0); // no graphics + ScopedColorMask colorMask(0, 0, 0, 1); // mark portal in alpha channel but don't touch color gl_RenderState.SetEffect(EFF_STENCIL); gl_RenderState.EnableTexture(false); + gl_RenderState.BlendFunc(GL_ONE, GL_ZERO); + gl_RenderState.BlendEquation(GL_ADD); + gl_RenderState.Apply(); DrawPortalStencil(); gl_RenderState.SetEffect(EFF_NONE); gl_RenderState.EnableTexture(true); - } // glColorMask(1, 1, 1, 1); + } glDepthFunc(GL_LESS); } PortalAll.Unclock(); diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index 54a651281..3fbd03434 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -60,6 +60,7 @@ void FLinearDepthShader::Bind(bool multisample) shader.Link("shaders/glsl/lineardepth"); shader.SetAttribLocation(0, "PositionInProjection"); DepthTexture[multisample].Init(shader, "DepthTexture"); + ColorTexture[multisample].Init(shader, "ColorTexture"); SampleCount[multisample].Init(shader, "SampleCount"); LinearizeDepthA[multisample].Init(shader, "LinearizeDepthA"); LinearizeDepthB[multisample].Init(shader, "LinearizeDepthB"); diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index 5b18ea85f..9c97791ba 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -9,6 +9,7 @@ public: void Bind(bool multisample); FBufferedUniformSampler DepthTexture[2]; + FBufferedUniformSampler ColorTexture[2]; FBufferedUniform1i SampleCount[2]; FBufferedUniform1f LinearizeDepthA[2]; FBufferedUniform1f LinearizeDepthB[2]; diff --git a/wadsrc/static/shaders/glsl/lineardepth.fp b/wadsrc/static/shaders/glsl/lineardepth.fp index 7e4eee745..61e5e8126 100644 --- a/wadsrc/static/shaders/glsl/lineardepth.fp +++ b/wadsrc/static/shaders/glsl/lineardepth.fp @@ -4,9 +4,11 @@ out vec4 FragColor; #if defined(MULTISAMPLE) uniform sampler2DMS DepthTexture; +uniform sampler2DMS ColorTexture; uniform int SampleCount; #else uniform sampler2D DepthTexture; +uniform sampler2D ColorTexture; #endif uniform float LinearizeDepthA; @@ -25,15 +27,15 @@ void main() ivec2 ipos = ivec2(uv * vec2(texSize)); float depth = 0.0; for (int i = 0; i < SampleCount; i++) - depth += texelFetch(DepthTexture, ipos, i).x; + depth += texelFetch(ColorTexture, ipos, i).a != 0.0 ? texelFetch(DepthTexture, ipos, i).x : 1.0; depth /= float(SampleCount); #else /*ivec2 texSize = textureSize(DepthTexture, 0); ivec2 ipos = ivec2(uv * vec2(texSize)); if (ipos.x < 0) ipos.x += texSize.x; if (ipos.y < 0) ipos.y += texSize.y; - float depth = texelFetch(DepthTexture, ipos, 0).x;*/ - float depth = texture(DepthTexture, uv).x; + float depth = texelFetch(ColorTexture, ipos, 0).a != 0.0 ? texelFetch(DepthTexture, ipos, 0).x : 1.0;*/ + float depth = texture(ColorTexture, uv).a != 0.0 ? texture(DepthTexture, uv).x : 1.0; #endif float normalizedDepth = clamp(InverseDepthRangeA * depth + InverseDepthRangeB, 0.0, 1.0); diff --git a/wadsrc/static/shaders/glsl/stencil.fp b/wadsrc/static/shaders/glsl/stencil.fp index d1b8745f6..65f12b405 100644 --- a/wadsrc/static/shaders/glsl/stencil.fp +++ b/wadsrc/static/shaders/glsl/stencil.fp @@ -3,6 +3,6 @@ out vec4 FragColor; void main() { - FragColor = vec4(1.0); + FragColor = vec4(1.0, 1.0, 1.0, 0.0); } From e7856ce1e354da13f2b5ffd9795b0bfb1586e37e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 4 Sep 2016 12:35:26 +0200 Subject: [PATCH 0888/1509] - removed unused forceadditive parameter from gl_GetLight. - restricted gl_lights_additive to legacy code and removed menu entry for this. For modern hardware this setting is completely pointless, it offers no advantage and degrades visual quality. Its only reason for existence was that drawing additive lights with textures is a lot faster, and that's all it's being used for now. --- src/gl/compatibility/gl_20.cpp | 4 +++- src/gl/dynlights/a_dynlight.cpp | 1 - src/gl/dynlights/gl_dynlight.h | 2 +- src/gl/dynlights/gl_dynlight1.cpp | 9 ++------- src/gl/scene/gl_flats.cpp | 2 +- src/gl/scene/gl_walls_draw.cpp | 2 +- src/gl/system/gl_cvars.h | 1 - wadsrc/static/menudef.z | 1 - 8 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index fdda99130..60dd9ecdb 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -57,6 +57,8 @@ #include "gl/data/gl_vertexbuffer.h" +CVAR(Bool, gl_lights_additive, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) + //========================================================================== // // Do some tinkering with the menus so that certain options only appear @@ -478,7 +480,7 @@ bool GLWall::PutWallCompat(int passflag) if (sub->lighthead == nullptr) return false; } - bool foggy = !gl_isBlack(Colormap.FadeColor) || (level.flags&LEVEL_HASFADETABLE) || gl_lights_additive; + bool foggy = gl_CheckFog(&Colormap, lightlevel) || (level.flags&LEVEL_HASFADETABLE) || gl_lights_additive; bool masked = passflag == 2 && gltexture->isMasked(); int list = list_indices[masked][foggy]; diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index ef96fdd3e..e90bbdc80 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -58,7 +58,6 @@ #include "gl/utility/gl_templates.h" EXTERN_CVAR (Float, gl_lights_size); -EXTERN_CVAR (Bool, gl_lights_additive); EXTERN_CVAR(Int, vid_renderer) diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index 513245be5..6b6e40c2d 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -184,7 +184,7 @@ struct FDynLightData -bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, bool forceadditive, FDynLightData &data); +bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FDynLightData &data); void gl_UploadLights(FDynLightData &data); diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index 361b94618..eb3c45f9c 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -74,18 +74,13 @@ CVAR (Float, gl_lights_intensity, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CVAR (Float, gl_lights_size, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CVAR (Bool, gl_light_sprites, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CVAR (Bool, gl_light_particles, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); -CUSTOM_CVAR (Bool, gl_lights_additive, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ - gl_DeleteAllAttachedLights(); - gl_RecreateAllAttachedLights(); -} //========================================================================== // // Sets up the parameters to render one dynamic light onto one plane // //========================================================================== -bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, bool forceadditive, FDynLightData &ldata) +bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FDynLightData &ldata) { int i = 0; @@ -103,7 +98,7 @@ bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, bo float cs; - if (gl_lights_additive || light->flags4&MF4_ADDITIVE || forceadditive) + if (light->IsAdditive()) { cs = 0.2f; i = 2; diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 1a3fe994b..9e9a73e5d 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -154,7 +154,7 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli) } p.Set(plane.plane); - gl_GetLight(sub->sector->PortalGroup, p, light, false, false, lightdata); + gl_GetLight(sub->sector->PortalGroup, p, light, false, lightdata); node = node->nextLight; } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 40145abc4..9599b8fa3 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -158,7 +158,7 @@ void GLWall::SetupLights() } if (outcnt[0]!=4 && outcnt[1]!=4 && outcnt[2]!=4 && outcnt[3]!=4) { - gl_GetLight(seg->frontsector->PortalGroup, p, node->lightsource, true, false, lightdata); + gl_GetLight(seg->frontsector->PortalGroup, p, node->lightsource, true, lightdata); } } } diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index 0c31f53a8..da1febe3c 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -26,7 +26,6 @@ EXTERN_CVAR (Bool, gl_attachedlights); EXTERN_CVAR (Bool, gl_lights_checkside); EXTERN_CVAR (Float, gl_lights_intensity); EXTERN_CVAR (Float, gl_lights_size); -EXTERN_CVAR (Bool, gl_lights_additive); EXTERN_CVAR (Bool, gl_light_sprites); EXTERN_CVAR (Bool, gl_light_particles); diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 86e2d5dc0..abc7cfacc 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -198,7 +198,6 @@ OptionMenu "GLLightOptions" Option "$GLLIGHTMNU_CLIPLIGHTS", gl_lights_checkside, "YesNo" Option "$GLLIGHTMNU_LIGHTSPRITES", gl_light_sprites, "YesNo" Option "$GLLIGHTMNU_LIGHTPARTICLES", gl_light_particles, "YesNo" - Option "$GLLIGHTMNU_FORCEADDITIVE", gl_lights_additive, "YesNo" Slider "$GLLIGHTMNU_LIGHTINTENSITY", gl_lights_intensity, 0.0, 1.0, 0.1 Slider "$GLLIGHTMNU_LIGHTSIZE", gl_lights_size, 0.0, 2.0, 0.1 } From 8b01a88b76f815833f77b3b7a7fcc47159d471e0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 4 Sep 2016 12:45:09 +0200 Subject: [PATCH 0889/1509] - removed gl_lights_size and gl_lights_intensity. Both of these were inherited from ZDoomGL and in terms of light design in maps it makes absolutely no sense to have them user configurable. They should have been removed 11 years ago. --- src/gl/compatibility/gl_20.cpp | 8 ++++---- src/gl/dynlights/a_dynlight.cpp | 3 +-- src/gl/dynlights/gl_dynlight.cpp | 4 +--- src/gl/dynlights/gl_dynlight1.cpp | 10 ++++------ src/gl/scene/gl_spritelight.cpp | 8 ++++---- src/gl/scene/gl_walls_draw.cpp | 2 +- src/gl/system/gl_cvars.h | 2 -- wadsrc/static/menudef.z | 2 -- 8 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 60dd9ecdb..e192b213e 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -386,7 +386,7 @@ bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, DVector3 lpos = light->PosRelative(group); float dist = fabsf(p.DistToPoint(lpos.X, lpos.Z, lpos.Y)); - float radius = (light->GetRadius() * gl_lights_size); + float radius = light->GetRadius(); if (radius <= 0.f) return false; if (dist > radius) return false; @@ -417,9 +417,9 @@ bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, float cs = 1.0f - (dist / radius); if (additive) cs *= 0.2f; // otherwise the light gets too strong. - float r = light->GetRed() / 255.0f * cs * gl_lights_intensity; - float g = light->GetGreen() / 255.0f * cs * gl_lights_intensity; - float b = light->GetBlue() / 255.0f * cs * gl_lights_intensity; + float r = light->GetRed() / 255.0f * cs; + float g = light->GetGreen() / 255.0f * cs; + float b = light->GetBlue() / 255.0f * cs; if (light->IsSubtractive()) { diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index e90bbdc80..ac929e7c0 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -57,7 +57,6 @@ #include "gl/utility/gl_convert.h" #include "gl/utility/gl_templates.h" -EXTERN_CVAR (Float, gl_lights_size); EXTERN_CVAR(Int, vid_renderer) @@ -378,7 +377,7 @@ void ADynamicLight::UpdateLocation() { intensity = m_currentRadius; } - radius = intensity * 2.0f * gl_lights_size; + radius = intensity * 2.0f; if (X() != oldx || Y() != oldy || radius != oldradius) { diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index e7d876b2a..b12290ab6 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -61,8 +61,6 @@ #include "gl/utility/gl_clock.h" #include "gl/utility/gl_convert.h" -EXTERN_CVAR (Float, gl_lights_intensity); -EXTERN_CVAR (Float, gl_lights_size); int ScriptDepth; void gl_InitGlow(FScanner &sc); void gl_ParseBrightmap(FScanner &sc, int); @@ -175,7 +173,7 @@ void FLightDefaults::ApplyProperties(ADynamicLight * light) const light->Angles.Yaw.Degrees = m_Param; light->SetOffset(m_Pos); light->halo = m_halo; - for (int a = 0; a < 3; a++) light->args[a] = clamp((int)(m_Args[a] * gl_lights_intensity), 0, 255); + for (int a = 0; a < 3; a++) light->args[a] = clamp((int)(m_Args[a]), 0, 255); light->m_Radius[0] = int(m_Args[LIGHT_INTENSITY]); light->m_Radius[1] = int(m_Args[LIGHT_SECONDARY_INTENSITY]); light->flags4 &= ~(MF4_ADDITIVE | MF4_SUBTRACTIVE | MF4_DONTLIGHTSELF); diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index eb3c45f9c..89cdd1ecb 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -70,8 +70,6 @@ CUSTOM_CVAR (Bool, gl_lights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOIN CVAR (Bool, gl_attachedlights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CVAR (Bool, gl_lights_checkside, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); -CVAR (Float, gl_lights_intensity, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); -CVAR (Float, gl_lights_size, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CVAR (Bool, gl_light_sprites, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CVAR (Bool, gl_light_particles, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); @@ -87,7 +85,7 @@ bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FD DVector3 pos = light->PosRelative(group); float dist = fabsf(p.DistToPoint(pos.X, pos.Z, pos.Y)); - float radius = (light->GetRadius() * gl_lights_size); + float radius = (light->GetRadius()); if (radius <= 0.f) return false; if (dist > radius) return false; @@ -108,9 +106,9 @@ bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FD cs = 1.0f; } - float r = light->GetRed() / 255.0f * cs * gl_lights_intensity; - float g = light->GetGreen() / 255.0f * cs * gl_lights_intensity; - float b = light->GetBlue() / 255.0f * cs * gl_lights_intensity; + float r = light->GetRed() / 255.0f * cs; + float g = light->GetGreen() / 255.0f * cs; + float b = light->GetBlue() / 255.0f * cs; if (light->IsSubtractive()) { diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index b25fc30f0..329459bd1 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -96,7 +96,7 @@ void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t * dist = FVector3(x - light->X(), y - light->Y(), z - light->Z()).LengthSquared(); } - radius = light->GetRadius() * gl_lights_size; + radius = light->GetRadius(); if (dist < radius * radius) { @@ -106,9 +106,9 @@ void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t * if (frac > 0) { - lr = light->GetRed() / 255.0f * gl_lights_intensity; - lg = light->GetGreen() / 255.0f * gl_lights_intensity; - lb = light->GetBlue() / 255.0f * gl_lights_intensity; + lr = light->GetRed() / 255.0f; + lg = light->GetGreen() / 255.0f; + lb = light->GetBlue() / 255.0f; if (light->IsSubtractive()) { float bright = FVector3(lr, lg, lb).Length(); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 9599b8fa3..9f521ad11 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -124,7 +124,7 @@ void GLWall::SetupLights() float y = node->lightsource->Y(); float z = node->lightsource->Z(); float dist = fabsf(p.DistToPoint(x, z, y)); - float radius = (node->lightsource->GetRadius() * gl_lights_size); + float radius = node->lightsource->GetRadius(); float scale = 1.0f / ((2.f * radius) - dist); if (radius > 0.f && dist < radius) diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index da1febe3c..4cda3657d 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -24,8 +24,6 @@ EXTERN_CVAR(Int, gl_weaponlight) EXTERN_CVAR (Bool, gl_lights); EXTERN_CVAR (Bool, gl_attachedlights); EXTERN_CVAR (Bool, gl_lights_checkside); -EXTERN_CVAR (Float, gl_lights_intensity); -EXTERN_CVAR (Float, gl_lights_size); EXTERN_CVAR (Bool, gl_light_sprites); EXTERN_CVAR (Bool, gl_light_particles); diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index abc7cfacc..8879d6170 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -198,8 +198,6 @@ OptionMenu "GLLightOptions" Option "$GLLIGHTMNU_CLIPLIGHTS", gl_lights_checkside, "YesNo" Option "$GLLIGHTMNU_LIGHTSPRITES", gl_light_sprites, "YesNo" Option "$GLLIGHTMNU_LIGHTPARTICLES", gl_light_particles, "YesNo" - Slider "$GLLIGHTMNU_LIGHTINTENSITY", gl_lights_intensity, 0.0, 1.0, 0.1 - Slider "$GLLIGHTMNU_LIGHTSIZE", gl_lights_size, 0.0, 2.0, 0.1 } OptionMenu "GLPrefOptions" From 95bedac6ca8240e010bb9ff49168fdd4abde06e7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 4 Sep 2016 13:14:14 +0200 Subject: [PATCH 0890/1509] - inlined FHardwareTexture::GetTexDimension. --- src/gl/textures/gl_hwtexture.cpp | 12 ------------ src/gl/textures/gl_hwtexture.h | 7 ++++++- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 73c4e7b36..25dc989e7 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -64,18 +64,6 @@ extern int TexFormat[]; //=========================================================================== unsigned int FHardwareTexture::lastbound[FHardwareTexture::MAX_TEXTURES]; -//=========================================================================== -// -// STATIC - Gets the maximum size of hardware textures -// -//=========================================================================== -int FHardwareTexture::GetTexDimension(int value) -{ - if (value > gl.max_texturesize) return gl.max_texturesize; - return value; -} - - //=========================================================================== // // Quick'n dirty image rescaling. diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h index 4c00af272..96eff0264 100644 --- a/src/gl/textures/gl_hwtexture.h +++ b/src/gl/textures/gl_hwtexture.h @@ -10,6 +10,7 @@ #define DIRECT_PALETTE -2 #include "tarray.h" +#include "gl/system/gl_interface.h" class FCanvasTexture; class AActor; @@ -49,7 +50,11 @@ public: static unsigned int lastbound[MAX_TEXTURES]; - static int GetTexDimension(int value); + static int GetTexDimension(int value) + { + if (value > gl.max_texturesize) return gl.max_texturesize; + return value; + } static void InitGlobalState() { for (int i = 0; i < MAX_TEXTURES; i++) lastbound[i] = 0; } From d2ead39bccb393f8496e4ba9176f464ec5b4bf3f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 4 Sep 2016 14:16:05 +0200 Subject: [PATCH 0891/1509] - force framebuffers for camera textures on GL 3+ hardware. With all the postprocessing stuff added I don't think it's ok to use the screenbuffer for this anymore. - disable framebuffers for camera textures in legacy mode entirely. This depends on a GL_DEPTH24_STENCIL8 surface which most of these old chipsets do not support, and I really see no point to invest any work here. The worst that can happen is that oversized camera textures won't be processed, which, due to general performance issues, might even be a good thing. --- src/gl/scene/gl_scene.cpp | 25 ++++++------------------- wadsrc/static/language.enu | 4 ---- wadsrc/static/menudef.z | 1 - 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 23d7c7c80..8a2764829 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -1317,29 +1317,16 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in gl_fixedcolormap=CM_DEFAULT; gl_RenderState.SetFixedColormap(CM_DEFAULT); - bool usefb = !gl.legacyMode || gl_usefb || gltex->GetWidth() > screen->GetWidth() || gltex->GetHeight() > screen->GetHeight(); - if (!usefb) + if (gl.legacyMode) { + // In legacy mode, fail if the requested texture is too large. + if (gltex->GetWidth() > screen->GetWidth() || gltex->GetHeight() > screen->GetHeight()) return; glFlush(); } else { -#if defined(_WIN32) && (defined(_MSC_VER) || defined(__INTEL_COMPILER)) - __try -#endif - { - GLRenderer->StartOffscreen(); - gltex->BindToFrameBuffer(); - } -#if defined(_WIN32) && (defined(_MSC_VER) || defined(__INTEL_COMPILER)) - __except(1) - { - usefb = false; - gl_usefb = false; - GLRenderer->EndOffscreen(); - glFlush(); - } -#endif + GLRenderer->StartOffscreen(); + gltex->BindToFrameBuffer(); } GL_IRECT bounds; @@ -1349,7 +1336,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in GLRenderer->RenderViewpoint(Viewpoint, &bounds, FOV, (float)width/height, (float)width/height, false, false); - if (!usefb) + if (gl.legacyMode) { glFlush(); gl_RenderState.SetMaterial(gltex, 0, 0, -1, false); diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index d2da033d7..c7d19fd92 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2594,7 +2594,6 @@ GLTEXMNU_RESIZETEX = "Resize textures"; GLTEXMNU_RESIZESPR = "Resize sprites"; GLTEXMNU_RESIZEFNT = "Resize fonts"; GLTEXMNU_PRECACHETEX = "Precache GL textures"; -GLTEXMNU_CAMTEXOFFSCR = "Camera textures offscreen"; GLTEXMNU_TRIMSPREDGE = "Trim sprite edges"; GLTEXMNU_SORTDRAWLIST = "Sort draw lists by texture"; @@ -2605,9 +2604,6 @@ GLLIGHTMNU_LIGHTDEFS = "Enable light definitions"; GLLIGHTMNU_CLIPLIGHTS = "Clip lights"; GLLIGHTMNU_LIGHTSPRITES = "Lights affect sprites"; GLLIGHTMNU_LIGHTPARTICLES = "Lights affect particles"; -GLLIGHTMNU_FORCEADDITIVE = "Force additive lighting"; -GLLIGHTMNU_LIGHTINTENSITY = "Light intensity"; -GLLIGHTMNU_LIGHTSIZE = "Light size"; // OpenGL Preferences GLPREFMNU_TITLE = "OPENGL PREFERENCES"; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 8879d6170..980cdacc3 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -185,7 +185,6 @@ OptionMenu "GLTextureGLOptions" Option "$GLTEXMNU_RESIZESPR", gl_texture_hqresize_sprites, "OnOff" Option "$GLTEXMNU_RESIZEFNT", gl_texture_hqresize_fonts, "OnOff" Option "$GLTEXMNU_PRECACHETEX", gl_precache, "YesNo" - Option "$GLTEXMNU_CAMTEXOFFSCR", gl_usefb, "OnOff" Option "$GLTEXMNU_TRIMSPREDGE", gl_trimsprites, "OnOff" Option "$GLTEXMNU_SORTDRAWLIST", gl_sort_textures, "YesNo" } From 108dcf122ae02d0354742081e9f67aa791831f7d Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 4 Sep 2016 15:23:29 +0300 Subject: [PATCH 0892/1509] Updated support for legacy renderer in Cocoa backend Added fallback to legacy profile when creation of pixel format for core context failed Added handling of -glversion command line switch --- src/posix/cocoa/i_video.mm | 71 ++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 19 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index f455a5f9f..624e8ad07 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -459,23 +459,14 @@ CocoaWindow* CreateCocoaWindow(const NSUInteger styleMask) return window; } -} // unnamed namespace - - -// --------------------------------------------------------------------------- - - -CocoaVideo::CocoaVideo() -: m_window(CreateCocoaWindow(STYLE_MASK_WINDOWED)) -, m_width(-1) -, m_height(-1) -, m_fullscreen(false) -, m_hiDPI(false) +enum OpenGLProfile { - memset(&m_modeIterator, 0, sizeof m_modeIterator); - - // Set attributes for OpenGL context + Core, + Legacy +}; +NSOpenGLPixelFormat* CreatePixelFormat(const OpenGLProfile profile) +{ NSOpenGLPixelFormatAttribute attributes[16]; size_t i = 0; @@ -492,17 +483,59 @@ CocoaVideo::CocoaVideo() attributes[i++] = NSOpenGLPFAAllowOfflineRenderers; } - if (NSAppKitVersionNumber >= AppKit10_7) + if (NSAppKitVersionNumber >= AppKit10_7 && OpenGLProfile::Core == profile) { + NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersion3_2Core; + const char* const glversion = Args->CheckValue("-glversion"); + + if (nullptr != glversion) + { + const double version = strtod(glversion, nullptr) + 0.01; + if (version < 3.2) + { + profile = NSOpenGLProfileVersionLegacy; + } + } + attributes[i++] = NSOpenGLPFAOpenGLProfile; - attributes[i++] = NSOpenGLProfileVersion3_2Core; + attributes[i++] = profile; } attributes[i] = NSOpenGLPixelFormatAttribute(0); - // Create OpenGL context and view + return [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; +} - NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; +} // unnamed namespace + + +// --------------------------------------------------------------------------- + + +CocoaVideo::CocoaVideo() +: m_window(CreateCocoaWindow(STYLE_MASK_WINDOWED)) +, m_width(-1) +, m_height(-1) +, m_fullscreen(false) +, m_hiDPI(false) +{ + memset(&m_modeIterator, 0, sizeof m_modeIterator); + + // Create OpenGL pixel format + + NSOpenGLPixelFormat* pixelFormat = CreatePixelFormat(OpenGLProfile::Core); + + if (nil == pixelFormat) + { + pixelFormat = CreatePixelFormat(OpenGLProfile::Legacy); + + if (nil == pixelFormat) + { + I_FatalError("Cannot OpenGL create pixel format, graphics hardware is not supported"); + } + } + + // Create OpenGL context and view const NSRect contentRect = [m_window contentRectForFrameRect:[m_window frame]]; NSOpenGLView* glView = [[CocoaView alloc] initWithFrame:contentRect From 74ede7bb4ee92aa5ad14494f689fc81e75f60d05 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 5 Sep 2016 09:07:34 +0200 Subject: [PATCH 0893/1509] - fixed: The DrawBlend call in the postprocessing case was using the global 'viewsector' variable directly. As with the Stereo3D stuff, this cannot be done because recursive processing of portals will change it. Instead the local copy has to be used here, just like the EndDrawScene call already did. --- src/gl/scene/gl_scene.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 8a2764829..48d4fb7ff 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -771,7 +771,7 @@ void FGLRenderer::SetFixedColormap (player_t *player) sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen) { - sector_t * retval; + sector_t * lviewsector; mSceneClearColor[0] = 0.0f; mSceneClearColor[1] = 0.0f; mSceneClearColor[2] = 0.0f; @@ -818,7 +818,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo } // 'viewsector' will not survive the rendering so it cannot be used anymore below. - retval = viewsector; + lviewsector = viewsector; // Render (potentially) multiple views for stereo 3d float viewShift[3]; @@ -848,7 +848,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo clipper.SafeAddClipRangeRealAngles(ViewAngle.BAMs() + a1, ViewAngle.BAMs() - a1); ProcessScene(toscreen); - if (mainview && toscreen) EndDrawScene(retval); // do not call this for camera textures. + if (mainview && toscreen) EndDrawScene(lviewsector); // do not call this for camera textures. if (mainview && FGLRenderBuffers::IsEnabled()) { mBuffers->BlitSceneToTexture(); @@ -860,7 +860,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo // This should be done after postprocessing, not before. mBuffers->BindCurrentFB(); glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); - DrawBlend(viewsector); + DrawBlend(lviewsector); } mDrawingScene2D = false; eye->TearDown(); @@ -869,7 +869,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo gl_frameCount++; // This counter must be increased right before the interpolations are restored. interpolator.RestoreInterpolations (); - return retval; + return lviewsector; } //----------------------------------------------------------------------------- From a5c0f9a5487fa51c36c4f9fd90788fbbb0be6482 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 6 Sep 2016 11:58:22 +0200 Subject: [PATCH 0894/1509] - use the predefined fullscreen vertices for clearing a portal instead of using the quad drawer. --- src/gl/scene/gl_portal.cpp | 7 +------ src/gl/textures/gl_material.h | 2 ++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index b613032ea..bd60713b6 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -137,12 +137,7 @@ void GLPortal::ClearScreen() glDisable(GL_MULTISAMPLE); glDisable(GL_DEPTH_TEST); - FQuadDrawer qd; - qd.Set(0, 0, 0, 0, 0, 0); - qd.Set(1, 0, SCREENHEIGHT, 0, 0, 0); - qd.Set(2, SCREENWIDTH, SCREENHEIGHT, 0, 0, 0); - qd.Set(3, SCREENWIDTH, 0, 0, 0, 0); - qd.Render(GL_TRIANGLE_FAN); + glDrawArrays(GL_TRIANGLE_STRIP, FFlatVertexBuffer::FULLSCREEN_INDEX, 4); glEnable(GL_DEPTH_TEST); gl_MatrixStack.Pop(gl_RenderState.mProjectionMatrix); diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index d44a845f6..ee42a66d0 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -267,3 +267,5 @@ public: }; #endif + + From a36d89405afe1d50946d8a8a1c8b5c69994eac6d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 6 Sep 2016 12:22:00 +0200 Subject: [PATCH 0895/1509] - separated the coordinate calculation from GLSprite::Draw. --- src/gl/scene/gl_sprite.cpp | 285 +++++++++++++++++++------------------ src/gl/scene/gl_wall.h | 1 + 2 files changed, 149 insertions(+), 137 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 8a8c89c80..2def85ef5 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -110,17 +110,157 @@ CVAR(Bool, gl_nolayer, false, 0) static const float LARGE_VALUE = 1e19f; + //========================================================================== // // // //========================================================================== + +void GLSprite::CalculateVertices(FVector3 *v) +{ + // [BB] Billboard stuff + const bool drawWithXYBillboard = ((particle && gl_billboard_particles) || (!(actor && actor->renderflags & RF_FORCEYBILLBOARD) + //&& GLRenderer->mViewActor != NULL + && (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD)))); + + const bool drawBillboardFacingCamera = gl_billboard_faces_camera; + // [Nash] has +ROLLSPRITE + const bool drawRollSpriteActor = (actor != nullptr && actor->renderflags & RF_ROLLSPRITE); + + + // [fgsfds] check sprite type mask + DWORD spritetype = (DWORD)-1; + if (actor != nullptr) spritetype = actor->renderflags & RF_SPRITETYPEMASK; + + // [Nash] is a flat sprite + const bool isFlatSprite = (actor != nullptr) && (spritetype == RF_WALLSPRITE || spritetype == RF_FLATSPRITE); + const bool dontFlip = (actor != nullptr) && (actor->renderflags & RF_DONTFLIP); + const bool useOffsets = (actor != nullptr) && !(actor->renderflags & RF_ROLLCENTER); + + // [Nash] check for special sprite drawing modes + if (drawWithXYBillboard || drawBillboardFacingCamera || drawRollSpriteActor || isFlatSprite) + { + // Compute center of sprite + float xcenter = (x1 + x2)*0.5; + float ycenter = (y1 + y2)*0.5; + float zcenter = (z1 + z2)*0.5; + float xx = -xcenter + x; + float zz = -zcenter + z; + float yy = -ycenter + y; + Matrix3x4 mat; + mat.MakeIdentity(); + mat.Translate(xcenter, zcenter, ycenter); // move to sprite center + + // Order of rotations matters. Perform yaw rotation (Y, face camera) before pitch (X, tilt up/down). + if (drawBillboardFacingCamera && !isFlatSprite) + { + // [CMB] Rotate relative to camera XY position, not just camera direction, + // which is nicer in VR + float xrel = xcenter - ViewPos.X; + float yrel = ycenter - ViewPos.Y; + float absAngleDeg = RAD2DEG(atan2(-yrel, xrel)); + float counterRotationDeg = 270. - GLRenderer->mAngles.Yaw.Degrees; // counteracts existing sprite rotation + float relAngleDeg = counterRotationDeg + absAngleDeg; + + mat.Rotate(0, 1, 0, relAngleDeg); + } + + // [fgsfds] calculate yaw vectors + float yawvecX = 0, yawvecY = 0, rollDegrees = 0; + float angleRad = (270. - GLRenderer->mAngles.Yaw).Radians(); + if (actor) rollDegrees = actor->Angles.Roll.Degrees; + if (isFlatSprite) + { + yawvecX = actor->Angles.Yaw.Cos(); + yawvecY = actor->Angles.Yaw.Sin(); + } + + // [MC] This is the only thing that I changed in Nash's submission which + // was constantly applying roll to everything. That was wrong. Flat sprites + // with roll literally look like paper thing space ships trying to swerve. + // However, it does well with wall sprites. + // Also, renamed FLOORSPRITE to FLATSPRITE because that's technically incorrect. + // I plan on adding proper FLOORSPRITEs which can actually curve along sloped + // 3D floors later... if possible. + + // Here we need some form of priority in order to work. + if (spritetype == RF_FLATSPRITE) + { + float pitchDegrees = -actor->Angles.Pitch.Degrees; + DVector3 apos = { x, y, z }; + DVector3 diff = ViewPos - apos; + DAngle angto = diff.Angle(); + + angto = deltaangle(actor->Angles.Yaw, angto); + + bool noFlipSprite = (!dontFlip || (fabs(angto) < 90.)); + mat.Rotate(0, 1, 0, (noFlipSprite) ? 0 : 180); + + mat.Rotate(-yawvecY, 0, yawvecX, (noFlipSprite) ? -pitchDegrees : pitchDegrees); + if (drawRollSpriteActor) + { + if (useOffsets) mat.Translate(xx, zz, yy); + mat.Rotate(yawvecX, 0, yawvecY, (noFlipSprite) ? -rollDegrees : rollDegrees); + if (useOffsets) mat.Translate(-xx, -zz, -yy); + } + } + // [fgsfds] Rotate the sprite about the sight vector (roll) + else if (spritetype == RF_WALLSPRITE) + { + mat.Rotate(0, 1, 0, 0); + if (drawRollSpriteActor) + { + if (useOffsets) mat.Translate(xx, zz, yy); + mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); + if (useOffsets) mat.Translate(-xx, -zz, -yy); + } + } + else if (drawRollSpriteActor) + { + if (useOffsets) mat.Translate(xx, zz, yy); + if (drawWithXYBillboard) + { + mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); + } + mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees); + if (useOffsets) mat.Translate(-xx, -zz, -yy); + } + + // apply the transform + else if (drawWithXYBillboard) + { + // Rotate the sprite about the vector starting at the center of the sprite + // triangle strip and with direction orthogonal to where the player is looking + // in the x/y plane. + mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); + } + + mat.Translate(-xcenter, -zcenter, -ycenter); // retreat from sprite center + v[0] = mat * FVector3(x1, z1, y1); + v[1] = mat * FVector3(x2, z1, y2); + v[2] = mat * FVector3(x1, z2, y1); + v[3] = mat * FVector3(x2, z2, y2); + } + else // traditional "Y" billboard mode + { + v[0] = FVector3(x1, z1, y1); + v[1] = FVector3(x2, z1, y2); + v[2] = FVector3(x1, z2, y1); + v[3] = FVector3(x2, z2, y2); + } +} + +//========================================================================== +// +// +// +//========================================================================== + void GLSprite::Draw(int pass) { if (pass == GLPASS_DECALS || pass == GLPASS_LIGHTSONLY) return; - - bool additivefog = false; bool foglayer = false; int rel = fullbright? 0 : getExtraLight(); @@ -264,147 +404,18 @@ void GLSprite::Draw(int pass) if (!modelframe) { - // [BB] Billboard stuff - const bool drawWithXYBillboard = ((particle && gl_billboard_particles) || (!(actor && actor->renderflags & RF_FORCEYBILLBOARD) - //&& GLRenderer->mViewActor != NULL - && (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD)))); - - const bool drawBillboardFacingCamera = gl_billboard_faces_camera; - // [Nash] has +ROLLSPRITE - const bool drawRollSpriteActor = (actor != nullptr && actor->renderflags & RF_ROLLSPRITE); gl_RenderState.Apply(); - FVector3 v1; - FVector3 v2; - FVector3 v3; - FVector3 v4; + FVector3 v[4]; - // [fgsfds] check sprite type mask - DWORD spritetype = (DWORD)-1; - if (actor != nullptr) spritetype = actor->renderflags & RF_SPRITETYPEMASK; - - // [Nash] is a flat sprite - const bool isFlatSprite = (actor != nullptr) && (spritetype == RF_WALLSPRITE || spritetype == RF_FLATSPRITE); - const bool dontFlip = (actor != nullptr) && (actor->renderflags & RF_DONTFLIP); - const bool useOffsets = (actor != nullptr) && !(actor->renderflags & RF_ROLLCENTER); - - // [Nash] check for special sprite drawing modes - if (drawWithXYBillboard || drawBillboardFacingCamera || drawRollSpriteActor || isFlatSprite) - { - // Compute center of sprite - float xcenter = (x1 + x2)*0.5; - float ycenter = (y1 + y2)*0.5; - float zcenter = (z1 + z2)*0.5; - float xx = -xcenter + x; - float zz = -zcenter + z; - float yy = -ycenter + y; - Matrix3x4 mat; - mat.MakeIdentity(); - mat.Translate(xcenter, zcenter, ycenter); // move to sprite center + CalculateVertices(v); - // Order of rotations matters. Perform yaw rotation (Y, face camera) before pitch (X, tilt up/down). - if (drawBillboardFacingCamera && !isFlatSprite) - { - // [CMB] Rotate relative to camera XY position, not just camera direction, - // which is nicer in VR - float xrel = xcenter - ViewPos.X; - float yrel = ycenter - ViewPos.Y; - float absAngleDeg = RAD2DEG(atan2(-yrel, xrel)); - float counterRotationDeg = 270. - GLRenderer->mAngles.Yaw.Degrees; // counteracts existing sprite rotation - float relAngleDeg = counterRotationDeg + absAngleDeg; - - mat.Rotate(0, 1, 0, relAngleDeg); - } - - // [fgsfds] calculate yaw vectors - float yawvecX = 0, yawvecY = 0, rollDegrees = 0; - float angleRad = (270. - GLRenderer->mAngles.Yaw).Radians(); - if (actor) rollDegrees = actor->Angles.Roll.Degrees; - if (isFlatSprite) - { - yawvecX = actor->Angles.Yaw.Cos(); - yawvecY = actor->Angles.Yaw.Sin(); - } - - // [MC] This is the only thing that I changed in Nash's submission which - // was constantly applying roll to everything. That was wrong. Flat sprites - // with roll literally look like paper thing space ships trying to swerve. - // However, it does well with wall sprites. - // Also, renamed FLOORSPRITE to FLATSPRITE because that's technically incorrect. - // I plan on adding proper FLOORSPRITEs which can actually curve along sloped - // 3D floors later... if possible. - - // Here we need some form of priority in order to work. - if (spritetype == RF_FLATSPRITE) - { - float pitchDegrees = -actor->Angles.Pitch.Degrees; - DVector3 apos = { x, y, z }; - DVector3 diff = ViewPos - apos; - DAngle angto = diff.Angle(); - - angto = deltaangle(actor->Angles.Yaw, angto); - - bool noFlipSprite = (!dontFlip || (fabs(angto) < 90.)); - mat.Rotate(0, 1, 0, (noFlipSprite) ? 0 : 180); - - mat.Rotate(-yawvecY, 0, yawvecX, (noFlipSprite) ? -pitchDegrees : pitchDegrees); - if (drawRollSpriteActor) - { - if (useOffsets) mat.Translate(xx, zz, yy); - mat.Rotate(yawvecX, 0, yawvecY, (noFlipSprite) ? -rollDegrees : rollDegrees); - if (useOffsets) mat.Translate(-xx, -zz, -yy); - } - } - // [fgsfds] Rotate the sprite about the sight vector (roll) - else if (spritetype == RF_WALLSPRITE) - { - mat.Rotate(0, 1, 0, 0); - if (drawRollSpriteActor) - { - if (useOffsets) mat.Translate(xx, zz, yy); - mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); - if (useOffsets) mat.Translate(-xx, -zz, -yy); - } - } - else if (drawRollSpriteActor) - { - if (useOffsets) mat.Translate(xx, zz, yy); - if (drawWithXYBillboard) - { - mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); - } - mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees); - if (useOffsets) mat.Translate(-xx, -zz, -yy); - } - - // apply the transform - else if (drawWithXYBillboard) - { - // Rotate the sprite about the vector starting at the center of the sprite - // triangle strip and with direction orthogonal to where the player is looking - // in the x/y plane. - mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); - } - - mat.Translate(-xcenter, -zcenter, -ycenter); // retreat from sprite center - v1 = mat * FVector3(x1, z1, y1); - v2 = mat * FVector3(x2, z1, y2); - v3 = mat * FVector3(x1, z2, y1); - v4 = mat * FVector3(x2, z2, y2); - } - else // traditional "Y" billboard mode - { - v1 = FVector3(x1, z1, y1); - v2 = FVector3(x2, z1, y2); - v3 = FVector3(x1, z2, y1); - v4 = FVector3(x2, z2, y2); - } FQuadDrawer qd; - qd.Set(0, v1[0], v1[1], v1[2], ul, vt); - qd.Set(1, v2[0], v2[1], v2[2], ur, vt); - qd.Set(2, v3[0], v3[1], v3[2], ul, vb); - qd.Set(3, v4[0], v4[1], v4[2], ur, vb); + qd.Set(0, v[0][0], v[0][1], v[0][2], ul, vt); + qd.Set(1, v[1][0], v[1][1], v[1][2], ur, vt); + qd.Set(2, v[2][0], v[2][1], v[2][2], ul, vb); + qd.Set(3, v[3][0], v[3][1], v[3][2], ur, vb); qd.Render(GL_TRIANGLE_STRIP); if (foglayer) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index ae7014c7d..32dc6ee5b 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -371,6 +371,7 @@ public: void SplitSprite(sector_t * frontsector, bool translucent); void SetLowerParam(); void PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight); + void CalculateVertices(FVector3 *v); public: From bfe34f4dc7f86d2ce56ccd2b3243bf310f2e162d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 6 Sep 2016 21:39:13 +0200 Subject: [PATCH 0896/1509] - cleanup. --- src/gl/scene/gl_sprite.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 2def85ef5..dba76d15d 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -226,8 +226,6 @@ void GLSprite::CalculateVertices(FVector3 *v) mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees); if (useOffsets) mat.Translate(-xx, -zz, -yy); } - - // apply the transform else if (drawWithXYBillboard) { // Rotate the sprite about the vector starting at the center of the sprite @@ -407,7 +405,6 @@ void GLSprite::Draw(int pass) gl_RenderState.Apply(); FVector3 v[4]; - CalculateVertices(v); From 181e5dc4db824f815cdaf6ff8f37a6191e11d914 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 6 Sep 2016 22:18:47 +0200 Subject: [PATCH 0897/1509] - fixed floor clipping of sprites. --- src/gl/scene/gl_sprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index dba76d15d..07f397d6d 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -711,7 +711,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) x = thingpos.X; z = thingpos.Z; y = thingpos.Y; - if (spritetype == RF_FLATSPRITE) z -= thing->Floorclip; + if (spritetype != RF_FLATSPRITE) z -= thing->Floorclip; // [RH] Make floatbobbing a renderer-only effect. if (thing->flags2 & MF2_FLOATBOB) From 5a64307ad12253d5f4a492bf5201d2552d68b6a9 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Wed, 7 Sep 2016 03:34:08 -0400 Subject: [PATCH 0898/1509] Changes the tonemap generation algorithm. --- src/gl/renderer/gl_postprocess.cpp | 39 +++++++++++++++++++++++++++++- src/gl/renderer/gl_renderer.h | 2 ++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index e6ca7faad..d7eac8007 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -257,7 +257,7 @@ void FGLRenderer::BindTonemapPalette(int texunit) { for (int b = 0; b < 64; b++) { - PalEntry color = GPalette.BaseColors[ColorMatcher.Pick((r << 2) | (r >> 4), (g << 2) | (g >> 4), (b << 2) | (b >> 4))]; + PalEntry color = GPalette.BaseColors[(BYTE)PTM_BestColor((uint32 *)GPalette.BaseColors, (r << 2) | (r >> 4), (g << 2) | (g >> 4), (b << 2) | (b >> 4), 0, 256)]; int index = ((r * 64 + g) * 64 + b) * 4; lut[index] = color.r; lut[index + 1] = color.g; @@ -472,3 +472,40 @@ void FGLRenderer::ClearBorders() } glDisable(GL_SCISSOR_TEST); } + + +// [SP] Re-implemented BestColor for more precision rather than speed. This function is only ever called once until the game palette is changed. + +int FGLRenderer::PTM_BestColor (const uint32 *pal_in, int r, int g, int b, int first, int num) +{ + const PalEntry *pal = (const PalEntry *)pal_in; + static double powtable[256]; + static bool firstTime = true; + + double fbestdist, fdist; + int bestcolor; + + if (firstTime) + { + firstTime = false; + for (int x = 0; x < 256; x++) powtable[x] = pow((double)x/255,1.2); + } + + for (int color = first; color < num; color++) + { + double x = powtable[abs(r-pal[color].r)]; + double y = powtable[abs(g-pal[color].g)]; + double z = powtable[abs(b-pal[color].b)]; + fdist = x + y + z; + if (color == first || fdist < fbestdist) + { + if (fdist == 0) + return color; + + fbestdist = fdist; + bestcolor = color; + } + } + return bestcolor; +} + diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 120f6a449..f652b4765 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -189,6 +189,8 @@ public: void FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, DAngle rotation, FDynamicColormap *colormap, int lightlevel); + + int PTM_BestColor (const uint32 *pal_in, int r, int g, int b, int first, int num); }; // Global functions. Make them members of GLRenderer later? From b9ca3c85f8cde4b145a82029307728577a07aed6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Sep 2016 12:18:09 +0200 Subject: [PATCH 0899/1509] - fixed: translucency detection in multipatch textures did not work. - fixed: The flat drawer never checked if a texture had translucent parts. --- src/gl/scene/gl_flats.cpp | 19 ++++++++++++++++++- src/textures/bitmap.h | 2 +- src/textures/multipatchtexture.cpp | 5 +++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 9e9a73e5d..48ad30786 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -419,15 +419,17 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE); gl_SetColor(lightlevel, rel, Colormap, alpha); gl_SetFog(lightlevel, rel, &Colormap, false); - gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); if (!gltexture) { + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.EnableTexture(false); DrawSubsectors(pass, false, true); gl_RenderState.EnableTexture(true); } else { + if (!gltexture->GetTransparent()) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); + else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); gl_SetPlaneTextureRotation(&plane, gltexture); DrawSubsectors(pass, !gl.legacyMode, true); @@ -477,6 +479,21 @@ inline void GLFlat::PutFlat(bool fog) // translucent 3D floors go into the regular translucent list, translucent portals go into the translucent border list. list = (renderflags&SSRF_RENDER3DPLANES) ? GLDL_TRANSLUCENT : GLDL_TRANSLUCENTBORDER; } + else if (gltexture->GetTransparent()) + { + if (stack) + { + list = GLDL_TRANSLUCENTBORDER; + } + else if ((renderflags&SSRF_RENDER3DPLANES) && !plane.plane.isSlope()) + { + list = GLDL_TRANSLUCENT; + } + else + { + list = GLDL_PLAINFLATS; + } + } else { bool masked = gltexture->isMasked() && ((renderflags&SSRF_RENDER3DPLANES) || stack); diff --git a/src/textures/bitmap.h b/src/textures/bitmap.h index 27d3c0b4b..a27d1ff98 100644 --- a/src/textures/bitmap.h +++ b/src/textures/bitmap.h @@ -380,7 +380,7 @@ struct bCopyAlpha }; struct bOverlay -{ +{ static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; } static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = MAX(s,d); } static __forceinline bool ProcessAlpha0() { return false; } diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index b0db481a8..41ba5f0f2 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -628,8 +628,9 @@ int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rota { ret = Parts[i].Texture->CopyTrueColorPixels(bmp, x+Parts[i].OriginX, y+Parts[i].OriginY, Parts[i].Rotate, &info); } - - if (ret > retv) retv = ret; + // treat -1 (i.e. unknown) as absolute. We have no idea if this may have overwritten previous info so a real check needs to be done. + if (ret == -1) retv = ret; + else if (retv != -1 && ret > retv) retv = ret; } // Restore previous clipping rectangle. bmp->SetClipRect(saved_cr); From 4bdd872f097d7998718daf9fb11a56ca518ae85e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 7 Sep 2016 20:31:42 +0200 Subject: [PATCH 0900/1509] Add eye textures and FBOs to FGLRenderBuffers --- src/gl/renderer/gl_renderbuffers.cpp | 81 ++++++++++++++++++++++++++++ src/gl/renderer/gl_renderbuffers.h | 10 ++++ 2 files changed, 91 insertions(+) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index f66ea1354..a7a07a43c 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -85,6 +85,7 @@ FGLRenderBuffers::~FGLRenderBuffers() { ClearScene(); ClearPipeline(); + ClearEyeBuffers(); ClearBloom(); } @@ -119,6 +120,18 @@ void FGLRenderBuffers::ClearBloom() } } +void FGLRenderBuffers::ClearEyeBuffers() +{ + for (auto handle : mEyeTextures) + DeleteTexture(handle); + + for (auto handle : mEyeFBs) + DeleteFrameBuffer(handle); + + mEyeTextures.Clear(); + mEyeFBs.Clear(); +} + void FGLRenderBuffers::DeleteTexture(GLuint &handle) { if (handle != 0) @@ -202,6 +215,7 @@ bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei { ClearScene(); ClearPipeline(); + ClearEyeBuffers(); ClearBloom(); mWidth = 0; mHeight = 0; @@ -239,6 +253,7 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples) void FGLRenderBuffers::CreatePipeline(int width, int height) { ClearPipeline(); + ClearEyeBuffers(); for (int i = 0; i < NumPipelineTextures; i++) { @@ -279,6 +294,35 @@ void FGLRenderBuffers::CreateBloom(int width, int height) } } +//========================================================================== +// +// Creates eye buffers if needed +// +//========================================================================== + +void FGLRenderBuffers::CreateEyeBuffers(int eye) +{ + if (mEyeFBs.Size() > eye) + return; + + GLint activeTex, textureBinding, frameBufferBinding; + glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); + glActiveTexture(GL_TEXTURE0); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &frameBufferBinding); + + while (mEyeFBs.Size() < eye) + { + GLuint texture = Create2DTexture("EyeTexture", GL_RGBA16F, mWidth, mHeight); + mEyeTextures.Push(texture); + mEyeFBs.Push(CreateFrameBuffer("EyeFB", texture)); + } + + glBindTexture(GL_TEXTURE_2D, textureBinding); + glActiveTexture(activeTex); + glBindFramebuffer(GL_FRAMEBUFFER, frameBufferBinding); +} + //========================================================================== // // Creates a 2D texture defaulting to linear filtering and clamp to edge @@ -471,6 +515,43 @@ void FGLRenderBuffers::BlitSceneToTexture() glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); } +//========================================================================== +// +// Eye textures and their frame buffers +// +//========================================================================== + +void FGLRenderBuffers::BlitToEyeTexture(int eye) +{ + CreateEyeBuffers(eye); + + glBindFramebuffer(GL_READ_FRAMEBUFFER, mPipelineFB[mCurrentPipelineTexture]); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mEyeFBs[eye]); + glBlitFramebuffer(0, 0, mWidth, mHeight, 0, 0, mWidth, mHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST); + + if ((gl.flags & RFL_INVALIDATE_BUFFER) != 0) + { + GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT }; + glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 2, attachments); + } + + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); +} + +void FGLRenderBuffers::BindEyeTexture(int eye, int texunit) +{ + CreateEyeBuffers(eye); + glActiveTexture(GL_TEXTURE0 + texunit); + glBindTexture(GL_TEXTURE_2D, mEyeTextures[eye]); +} + +void FGLRenderBuffers::BindEyeFB(int eye) +{ + CreateEyeBuffers(eye); + glBindFramebuffer(GL_FRAMEBUFFER, mEyeFBs[eye]); +} + //========================================================================== // // Makes the scene frame buffer active (multisample, depth, stecil, etc.) diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 08303a912..e5600fde4 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -32,6 +32,10 @@ public: void BindOutputFB(); + void BlitToEyeTexture(int eye); + void BindEyeTexture(int eye, int texunit); + void BindEyeFB(int eye); + enum { NumBloomLevels = 4 }; FGLBloomTextureLevel BloomLevels[NumBloomLevels]; @@ -43,10 +47,12 @@ public: private: void ClearScene(); void ClearPipeline(); + void ClearEyeBuffers(); void ClearBloom(); void CreateScene(int width, int height, int samples); void CreatePipeline(int width, int height); void CreateBloom(int width, int height); + void CreateEyeBuffers(int eye); GLuint Create2DTexture(const FString &name, GLuint format, int width, int height); GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height); GLuint CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height); @@ -83,6 +89,10 @@ private: // Back buffer frame buffer GLuint mOutputFB = 0; + // Eye buffers + TArray mEyeTextures; + TArray mEyeFBs; + static bool FailedCreate; static bool BuffersActive; }; From aaa3581ee698c6d6859cff551327f099e471c817 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 7 Sep 2016 21:52:43 +0200 Subject: [PATCH 0901/1509] Hook up eye textures in renderer --- src/gl/renderer/gl_postprocess.cpp | 33 ++++++++++++++++++++++++++++ src/gl/renderer/gl_renderbuffers.cpp | 12 +++++----- src/gl/renderer/gl_renderbuffers.h | 2 +- src/gl/renderer/gl_renderer.h | 2 +- src/gl/scene/gl_scene.cpp | 2 ++ src/gl/stereo3d/gl_stereo3d.cpp | 23 +++++++++++++++++++ src/gl/stereo3d/gl_stereo3d.h | 5 +++++ 7 files changed, 71 insertions(+), 8 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index d7eac8007..243a73a38 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -75,6 +75,7 @@ #include "gl/shaders/gl_lensshader.h" #include "gl/shaders/gl_presentshader.h" #include "gl/renderer/gl_2ddrawer.h" +#include "gl/stereo3d/gl_stereo3d.h" //========================================================================== // @@ -375,6 +376,38 @@ void FGLRenderer::LensDistortScene() FGLDebug::PopGroup(); } +//----------------------------------------------------------------------------- +// +// Copies the rendered screen to its final destination +// +//----------------------------------------------------------------------------- + +void FGLRenderer::Flush() +{ + const s3d::Stereo3DMode& stereo3dMode = s3d::Stereo3DMode::getCurrentMode(); + + if (stereo3dMode.IsMono() || !FGLRenderBuffers::IsEnabled()) + { + CopyToBackbuffer(nullptr, true); + } + else + { + // Render 2D to eye textures + for (int eye_ix = 0; eye_ix < stereo3dMode.eye_count(); ++eye_ix) + { + FGLDebug::PushGroup("Eye2D"); + mBuffers->BindEyeFB(eye_ix); + m2DDrawer->Flush(); // Draw the 2D + FGLDebug::PopGroup(); + } + + FGLPostProcessState savedState; + FGLDebug::PushGroup("PresentEyes"); + stereo3dMode.Present(); + FGLDebug::PopGroup(); + } +} + //----------------------------------------------------------------------------- // // Gamma correct while copying to frame buffer diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index a7a07a43c..7ad299e2e 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -122,12 +122,12 @@ void FGLRenderBuffers::ClearBloom() void FGLRenderBuffers::ClearEyeBuffers() { - for (auto handle : mEyeTextures) - DeleteTexture(handle); - for (auto handle : mEyeFBs) DeleteFrameBuffer(handle); + for (auto handle : mEyeTextures) + DeleteTexture(handle); + mEyeTextures.Clear(); mEyeFBs.Clear(); } @@ -311,7 +311,7 @@ void FGLRenderBuffers::CreateEyeBuffers(int eye) glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); glGetIntegerv(GL_FRAMEBUFFER_BINDING, &frameBufferBinding); - while (mEyeFBs.Size() < eye) + while (mEyeFBs.Size() <= eye) { GLuint texture = Create2DTexture("EyeTexture", GL_RGBA16F, mWidth, mHeight); mEyeTextures.Push(texture); @@ -546,10 +546,10 @@ void FGLRenderBuffers::BindEyeTexture(int eye, int texunit) glBindTexture(GL_TEXTURE_2D, mEyeTextures[eye]); } -void FGLRenderBuffers::BindEyeFB(int eye) +void FGLRenderBuffers::BindEyeFB(int eye, bool readBuffer) { CreateEyeBuffers(eye); - glBindFramebuffer(GL_FRAMEBUFFER, mEyeFBs[eye]); + glBindFramebuffer(readBuffer ? GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER, mEyeFBs[eye]); } //========================================================================== diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index e5600fde4..08731e39f 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -34,7 +34,7 @@ public: void BlitToEyeTexture(int eye); void BindEyeTexture(int eye, int texunit); - void BindEyeFB(int eye); + void BindEyeFB(int eye, bool readBuffer = false); enum { NumBloomLevels = 4 }; FGLBloomTextureLevel BloomLevels[NumBloomLevels]; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index f652b4765..d768728c4 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -173,7 +173,7 @@ public: void ClearTonemapPalette(); void LensDistortScene(); void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma); - void Flush() { CopyToBackbuffer(nullptr, true); } + void Flush(); void SetProjection(float fov, float ratio, float fovratio); void SetProjection(VSMatrix matrix); // raw matrix input from stereo 3d modes diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 48d4fb7ff..5fca06dad 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -863,6 +863,8 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo DrawBlend(lviewsector); } mDrawingScene2D = false; + if (!stereo3dMode.IsMono()) + mBuffers->BlitToEyeTexture(eye_ix); eye->TearDown(); } stereo3dMode.TearDown(); diff --git a/src/gl/stereo3d/gl_stereo3d.cpp b/src/gl/stereo3d/gl_stereo3d.cpp index d686a4a43..e1c4f6306 100644 --- a/src/gl/stereo3d/gl_stereo3d.cpp +++ b/src/gl/stereo3d/gl_stereo3d.cpp @@ -36,6 +36,7 @@ #include "gl/system/gl_system.h" #include "gl/stereo3d/gl_stereo3d.h" #include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderbuffers.h" #include "vectors.h" // RAD2DEG #include "doomtype.h" // M_PI @@ -79,6 +80,28 @@ Stereo3DMode::~Stereo3DMode() { } +void Stereo3DMode::Present() const +{ + // Example copying eye textures to the back buffer: + + // The letterbox for the output destination. + // If stereo modes needs different dimensions then that needs to be added to FGLRenderer::SetOutputViewport. + const auto &box = GLRenderer->mOutputLetterbox; + + GLRenderer->mBuffers->BindOutputFB(); + glClearColor(0.0, 0.0, 0.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + for (int eye_ix = 0; eye_ix < eye_count(); ++eye_ix) + { + GLRenderer->mBuffers->BindEyeFB(eye_ix, true); + int width = GLRenderer->mBuffers->GetWidth(); + int height = GLRenderer->mBuffers->GetHeight(); + glBlitFramebuffer(0, 0, width, height, box.left + eye_ix * box.width / eye_count(), box.top, box.left + (eye_ix + 1) * box.width / eye_count(), box.height, GL_COLOR_BUFFER_BIT, GL_LINEAR); + } + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); +} + // Avoid static initialization order fiasco by declaring first Mode type (Mono) here in the // same source file as Stereo3DMode::getCurrentMode() // https://isocpp.org/wiki/faq/ctors#static-init-order diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h index c56cc078f..3cac6b79d 100644 --- a/src/gl/stereo3d/gl_stereo3d.h +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -85,6 +85,9 @@ public: virtual void SetUp() const {}; virtual void TearDown() const {}; + virtual bool IsMono() const { return false; } + virtual void Present() const; + protected: TArray eye_ptrs; @@ -102,6 +105,8 @@ class MonoView : public Stereo3DMode public: static const MonoView& getInstance(); + bool IsMono() const override { return true; } + protected: MonoView() { eye_ptrs.Push(¢ralEye); } EyePose centralEye; From ccbe5160b0b6546a9c8fcdb4cf02267603de4056 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 8 Sep 2016 09:18:10 +0200 Subject: [PATCH 0902/1509] Split F2DDrawer::Flush into Draw and Clear --- src/gl/renderer/gl_2ddrawer.cpp | 10 ++++++---- src/gl/renderer/gl_2ddrawer.h | 3 ++- src/gl/renderer/gl_postprocess.cpp | 7 +++++-- src/gl/system/gl_wipe.cpp | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/gl/renderer/gl_2ddrawer.cpp b/src/gl/renderer/gl_2ddrawer.cpp index ac7d35397..e0f67c713 100644 --- a/src/gl/renderer/gl_2ddrawer.cpp +++ b/src/gl/renderer/gl_2ddrawer.cpp @@ -378,7 +378,7 @@ void F2DDrawer::AddPixel(int x1, int y1, int palcolor, uint32 color) // //========================================================================== -void F2DDrawer::Flush() +void F2DDrawer::Draw() { F2DDrawer::EDrawType lasttype = DrawTypeTexture; @@ -490,10 +490,12 @@ void F2DDrawer::Flush() } i += dg->mLen; } - mVertices.Clear(); - mData.Clear(); gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); glset.lightmode = savedlightmode; } - +void F2DDrawer::Clear() +{ + mVertices.Clear(); + mData.Clear(); +} diff --git a/src/gl/renderer/gl_2ddrawer.h b/src/gl/renderer/gl_2ddrawer.h index 32d2ad1f5..8c27f13d8 100644 --- a/src/gl/renderer/gl_2ddrawer.h +++ b/src/gl/renderer/gl_2ddrawer.h @@ -66,7 +66,8 @@ public: void AddLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color); void AddPixel(int x1, int y1, int palcolor, uint32 color); - void Flush(); + void Draw(); + void Clear(); }; diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 243a73a38..4bacf54d4 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -397,9 +397,10 @@ void FGLRenderer::Flush() { FGLDebug::PushGroup("Eye2D"); mBuffers->BindEyeFB(eye_ix); - m2DDrawer->Flush(); // Draw the 2D + m2DDrawer->Draw(); FGLDebug::PopGroup(); } + m2DDrawer->Clear(); FGLPostProcessState savedState; FGLDebug::PushGroup("PresentEyes"); @@ -416,7 +417,9 @@ void FGLRenderer::Flush() void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) { - m2DDrawer->Flush(); // draw all pending 2D stuff before copying the buffer + m2DDrawer->Draw(); // draw all pending 2D stuff before copying the buffer + m2DDrawer->Clear(); + FGLDebug::PushGroup("CopyToBackbuffer"); if (FGLRenderBuffers::IsEnabled()) { diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 05d63f65d..577bc12db 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -189,7 +189,8 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type) void OpenGLFrameBuffer::WipeEndScreen() { - GLRenderer->m2DDrawer->Flush(); + GLRenderer->m2DDrawer->Draw(); + GLRenderer->m2DDrawer->Clear(); const auto &viewport = GLRenderer->mScreenViewport; wipeendscreen = new FHardwareTexture(viewport.width, viewport.height, true); From 8b7267cf879d80515f1f63a90fcd4f7f4bdbec09 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 8 Sep 2016 19:02:13 +0200 Subject: [PATCH 0903/1509] MaskAnaglyph present mode --- src/gl/renderer/gl_postprocess.cpp | 50 +++++++++++++++++------------- src/gl/renderer/gl_renderer.h | 1 + src/gl/stereo3d/gl_anaglyph.cpp | 21 +++++++++++++ src/gl/stereo3d/gl_anaglyph.h | 21 +++---------- 4 files changed, 56 insertions(+), 37 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 4bacf54d4..00083480c 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -397,6 +397,8 @@ void FGLRenderer::Flush() { FGLDebug::PushGroup("Eye2D"); mBuffers->BindEyeFB(eye_ix); + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + glScissor(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); m2DDrawer->Draw(); FGLDebug::PopGroup(); } @@ -437,28 +439,8 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) box = mOutputLetterbox; } - // Present what was rendered: - glViewport(box.left, box.top, box.width, box.height); - - mPresentShader->Bind(); - mPresentShader->InputTexture.Set(0); - if (!applyGamma || framebuffer->IsHWGammaActive()) - { - mPresentShader->InvGamma.Set(1.0f); - mPresentShader->Contrast.Set(1.0f); - mPresentShader->Brightness.Set(0.0f); - } - else - { - mPresentShader->InvGamma.Set(1.0f / clamp(Gamma, 0.1f, 4.f)); - mPresentShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); - mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); - } - mPresentShader->Scale.Set(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight()); mBuffers->BindCurrentTexture(0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - RenderScreenQuad(); + DrawPresentTexture(box, applyGamma); } else if (!bounds) { @@ -468,6 +450,32 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) FGLDebug::PopGroup(); } +void FGLRenderer::DrawPresentTexture(const GL_IRECT &box, bool applyGamma) +{ + glViewport(box.left, box.top, box.width, box.height); + + glActiveTexture(GL_TEXTURE0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + mPresentShader->Bind(); + mPresentShader->InputTexture.Set(0); + if (!applyGamma || framebuffer->IsHWGammaActive()) + { + mPresentShader->InvGamma.Set(1.0f); + mPresentShader->Contrast.Set(1.0f); + mPresentShader->Brightness.Set(0.0f); + } + else + { + mPresentShader->InvGamma.Set(1.0f / clamp(Gamma, 0.1f, 4.f)); + mPresentShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); + mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); + } + mPresentShader->Scale.Set(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight()); + RenderScreenQuad(); +} + //----------------------------------------------------------------------------- // // Fills the black bars around the screen letterbox diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index d768728c4..162fb6dcf 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -173,6 +173,7 @@ public: void ClearTonemapPalette(); void LensDistortScene(); void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma); + void DrawPresentTexture(const GL_IRECT &box, bool applyGamma); void Flush(); void SetProjection(float fov, float ratio, float fovratio); diff --git a/src/gl/stereo3d/gl_anaglyph.cpp b/src/gl/stereo3d/gl_anaglyph.cpp index c84c35091..3c051d390 100644 --- a/src/gl/stereo3d/gl_anaglyph.cpp +++ b/src/gl/stereo3d/gl_anaglyph.cpp @@ -34,6 +34,8 @@ */ #include "gl_anaglyph.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderbuffers.h" namespace s3d { @@ -44,6 +46,25 @@ MaskAnaglyph::MaskAnaglyph(const ColorMask& leftColorMask, double ipdMeters) eye_ptrs.Push(&rightEye); } +void MaskAnaglyph::Present() const +{ + GLRenderer->mBuffers->BindOutputFB(); + GLRenderer->ClearBorders(); + + gl_RenderState.SetColorMask(leftEye.GetColorMask().r, leftEye.GetColorMask().g, leftEye.GetColorMask().b, true); + gl_RenderState.ApplyColorMask(); + GLRenderer->mBuffers->BindEyeTexture(0, 0); + GLRenderer->DrawPresentTexture(GLRenderer->mOutputLetterbox, true); + + gl_RenderState.SetColorMask(rightEye.GetColorMask().r, rightEye.GetColorMask().g, rightEye.GetColorMask().b, true); + gl_RenderState.ApplyColorMask(); + GLRenderer->mBuffers->BindEyeTexture(1, 0); + GLRenderer->DrawPresentTexture(GLRenderer->mOutputLetterbox, true); + + gl_RenderState.ResetColorMask(); + gl_RenderState.ApplyColorMask(); +} + /* static */ const GreenMagenta& GreenMagenta::getInstance(float ipd) diff --git a/src/gl/stereo3d/gl_anaglyph.h b/src/gl/stereo3d/gl_anaglyph.h index a82ce0f3b..e3383fe26 100644 --- a/src/gl/stereo3d/gl_anaglyph.h +++ b/src/gl/stereo3d/gl_anaglyph.h @@ -61,14 +61,8 @@ class AnaglyphLeftPose : public LeftEyePose { public: AnaglyphLeftPose(const ColorMask& colorMask, float ipd) : LeftEyePose(ipd), colorMask(colorMask) {} - virtual void SetUp() const { - gl_RenderState.SetColorMask(colorMask.r, colorMask.g, colorMask.b, true); - gl_RenderState.ApplyColorMask(); - } - virtual void TearDown() const { - gl_RenderState.ResetColorMask(); - gl_RenderState.ApplyColorMask(); - } + ColorMask GetColorMask() const { return colorMask; } + private: ColorMask colorMask; }; @@ -77,14 +71,8 @@ class AnaglyphRightPose : public RightEyePose { public: AnaglyphRightPose(const ColorMask& colorMask, float ipd) : RightEyePose(ipd), colorMask(colorMask) {} - virtual void SetUp() const { - gl_RenderState.SetColorMask(colorMask.r, colorMask.g, colorMask.b, true); - gl_RenderState.ApplyColorMask(); - } - virtual void TearDown() const { - gl_RenderState.ResetColorMask(); - gl_RenderState.ApplyColorMask(); - } + ColorMask GetColorMask() const { return colorMask; } + private: ColorMask colorMask; }; @@ -93,6 +81,7 @@ class MaskAnaglyph : public Stereo3DMode { public: MaskAnaglyph(const ColorMask& leftColorMask, double ipdMeters); + void Present() const override; private: AnaglyphLeftPose leftEye; AnaglyphRightPose rightEye; From 63dc3949139586fe5b7d71dc0800ff2adb01c4af Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 8 Sep 2016 21:15:00 +0200 Subject: [PATCH 0904/1509] Present function for left, right and quad-buffered stereo3d --- src/gl/stereo3d/gl_quadstereo.cpp | 31 ++++++++++++++++++++++++- src/gl/stereo3d/gl_quadstereo.h | 18 ++------------ src/gl/stereo3d/gl_stereo3d.cpp | 23 ------------------ src/gl/stereo3d/gl_stereo3d.h | 3 ++- src/gl/stereo3d/gl_stereo_leftright.cpp | 18 ++++++++++++++ src/gl/stereo3d/gl_stereo_leftright.h | 2 ++ 6 files changed, 54 insertions(+), 41 deletions(-) diff --git a/src/gl/stereo3d/gl_quadstereo.cpp b/src/gl/stereo3d/gl_quadstereo.cpp index 63bbbedc1..cd689d3b5 100644 --- a/src/gl/stereo3d/gl_quadstereo.cpp +++ b/src/gl/stereo3d/gl_quadstereo.cpp @@ -34,6 +34,8 @@ */ #include "gl_quadstereo.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderbuffers.h" namespace s3d { @@ -46,7 +48,7 @@ QuadStereo::QuadStereo(double ipdMeters) GLboolean supportsStereo, supportsBuffered; glGetBooleanv(GL_STEREO, &supportsStereo); glGetBooleanv(GL_DOUBLEBUFFER, &supportsBuffered); - bool bQuadStereoSupported = supportsStereo && supportsBuffered; + bQuadStereoSupported = supportsStereo && supportsBuffered; leftEye.bQuadStereoSupported = bQuadStereoSupported; rightEye.bQuadStereoSupported = bQuadStereoSupported; @@ -57,6 +59,33 @@ QuadStereo::QuadStereo(double ipdMeters) } } +void QuadStereo::Present() const +{ + if (bQuadStereoSupported) + { + GLRenderer->mBuffers->BindOutputFB(); + + glDrawBuffer(GL_BACK_LEFT); + GLRenderer->ClearBorders(); + GLRenderer->mBuffers->BindEyeTexture(0, 0); + GLRenderer->DrawPresentTexture(GLRenderer->mOutputLetterbox, true); + + glDrawBuffer(GL_BACK_RIGHT); + GLRenderer->ClearBorders(); + GLRenderer->mBuffers->BindEyeTexture(1, 0); + GLRenderer->DrawPresentTexture(GLRenderer->mOutputLetterbox, true); + + glDrawBuffer(GL_BACK); + } + else + { + GLRenderer->mBuffers->BindOutputFB(); + GLRenderer->ClearBorders(); + GLRenderer->mBuffers->BindEyeTexture(1, 0); + GLRenderer->DrawPresentTexture(GLRenderer->mOutputLetterbox, true); + } +} + /* static */ const QuadStereo& QuadStereo::getInstance(float ipd) { diff --git a/src/gl/stereo3d/gl_quadstereo.h b/src/gl/stereo3d/gl_quadstereo.h index f27fb78f8..d9aa4f435 100644 --- a/src/gl/stereo3d/gl_quadstereo.h +++ b/src/gl/stereo3d/gl_quadstereo.h @@ -47,14 +47,6 @@ class QuadStereoLeftPose : public LeftEyePose { public: QuadStereoLeftPose(float ipd) : LeftEyePose(ipd), bQuadStereoSupported(false) {} - virtual void SetUp() const { - if (bQuadStereoSupported) - glDrawBuffer(GL_BACK_LEFT); - } - virtual void TearDown() const { - if (bQuadStereoSupported) - glDrawBuffer(GL_BACK); - } bool bQuadStereoSupported; }; @@ -62,14 +54,6 @@ class QuadStereoRightPose : public RightEyePose { public: QuadStereoRightPose(float ipd) : RightEyePose(ipd), bQuadStereoSupported(false){} - virtual void SetUp() const { - if (bQuadStereoSupported) - glDrawBuffer(GL_BACK_RIGHT); - } - virtual void TearDown() const { - if (bQuadStereoSupported) - glDrawBuffer(GL_BACK); - } bool bQuadStereoSupported; }; @@ -84,10 +68,12 @@ class QuadStereo : public Stereo3DMode { public: QuadStereo(double ipdMeters); + void Present() const override; static const QuadStereo& getInstance(float ipd); private: QuadStereoLeftPose leftEye; QuadStereoRightPose rightEye; + bool bQuadStereoSupported; }; diff --git a/src/gl/stereo3d/gl_stereo3d.cpp b/src/gl/stereo3d/gl_stereo3d.cpp index e1c4f6306..d686a4a43 100644 --- a/src/gl/stereo3d/gl_stereo3d.cpp +++ b/src/gl/stereo3d/gl_stereo3d.cpp @@ -36,7 +36,6 @@ #include "gl/system/gl_system.h" #include "gl/stereo3d/gl_stereo3d.h" #include "gl/renderer/gl_renderer.h" -#include "gl/renderer/gl_renderbuffers.h" #include "vectors.h" // RAD2DEG #include "doomtype.h" // M_PI @@ -80,28 +79,6 @@ Stereo3DMode::~Stereo3DMode() { } -void Stereo3DMode::Present() const -{ - // Example copying eye textures to the back buffer: - - // The letterbox for the output destination. - // If stereo modes needs different dimensions then that needs to be added to FGLRenderer::SetOutputViewport. - const auto &box = GLRenderer->mOutputLetterbox; - - GLRenderer->mBuffers->BindOutputFB(); - glClearColor(0.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - for (int eye_ix = 0; eye_ix < eye_count(); ++eye_ix) - { - GLRenderer->mBuffers->BindEyeFB(eye_ix, true); - int width = GLRenderer->mBuffers->GetWidth(); - int height = GLRenderer->mBuffers->GetHeight(); - glBlitFramebuffer(0, 0, width, height, box.left + eye_ix * box.width / eye_count(), box.top, box.left + (eye_ix + 1) * box.width / eye_count(), box.height, GL_COLOR_BUFFER_BIT, GL_LINEAR); - } - glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); -} - // Avoid static initialization order fiasco by declaring first Mode type (Mono) here in the // same source file as Stereo3DMode::getCurrentMode() // https://isocpp.org/wiki/faq/ctors#static-init-order diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h index 3cac6b79d..2cb9417d2 100644 --- a/src/gl/stereo3d/gl_stereo3d.h +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -86,7 +86,7 @@ public: virtual void TearDown() const {}; virtual bool IsMono() const { return false; } - virtual void Present() const; + virtual void Present() const = 0; protected: TArray eye_ptrs; @@ -106,6 +106,7 @@ public: static const MonoView& getInstance(); bool IsMono() const override { return true; } + void Present() const override { } protected: MonoView() { eye_ptrs.Push(¢ralEye); } diff --git a/src/gl/stereo3d/gl_stereo_leftright.cpp b/src/gl/stereo3d/gl_stereo_leftright.cpp index 354185792..8605c9b53 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.cpp +++ b/src/gl/stereo3d/gl_stereo_leftright.cpp @@ -37,7 +37,10 @@ #include "vectors.h" // RAD2DEG #include "doomtype.h" // M_PI #include "gl/system/gl_cvars.h" +#include "gl/system/gl_system.h" +#include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderbuffers.h" #include EXTERN_CVAR(Float, vr_screendist) @@ -89,6 +92,13 @@ const LeftEyeView& LeftEyeView::getInstance(float ipd) return instance; } +void LeftEyeView::Present() const +{ + GLRenderer->mBuffers->BindOutputFB(); + GLRenderer->ClearBorders(); + GLRenderer->mBuffers->BindEyeTexture(0, 0); + GLRenderer->DrawPresentTexture(GLRenderer->mOutputLetterbox, true); +} /* static */ const RightEyeView& RightEyeView::getInstance(float ipd) @@ -98,5 +108,13 @@ const RightEyeView& RightEyeView::getInstance(float ipd) return instance; } +void RightEyeView::Present() const +{ + GLRenderer->mBuffers->BindOutputFB(); + GLRenderer->ClearBorders(); + GLRenderer->mBuffers->BindEyeTexture(0, 0); + GLRenderer->DrawPresentTexture(GLRenderer->mOutputLetterbox, true); +} + } /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_stereo_leftright.h b/src/gl/stereo3d/gl_stereo_leftright.h index de13a32cb..250846651 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.h +++ b/src/gl/stereo3d/gl_stereo_leftright.h @@ -83,6 +83,7 @@ public: LeftEyeView(float ipd) : eye(ipd) { eye_ptrs.Push(&eye); } float getIpd() const { return eye.getIpd(); } void setIpd(float ipd) { eye.setIpd(ipd); } + void Present() const override; protected: LeftEyePose eye; }; @@ -96,6 +97,7 @@ public: RightEyeView(float ipd) : eye(ipd) { eye_ptrs.Push(&eye); } float getIpd() const { return eye.getIpd(); } void setIpd(float ipd) { eye.setIpd(ipd); } + void Present() const override; protected: RightEyePose eye; }; From d83a72f361bd4df365caa2c7e14173afe34dee94 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 8 Sep 2016 21:24:25 +0200 Subject: [PATCH 0905/1509] Add missing IsEnabled check --- src/gl/scene/gl_scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 5fca06dad..26e226554 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -863,7 +863,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo DrawBlend(lviewsector); } mDrawingScene2D = false; - if (!stereo3dMode.IsMono()) + if (!stereo3dMode.IsMono() && FGLRenderBuffers::IsEnabled()) mBuffers->BlitToEyeTexture(eye_ix); eye->TearDown(); } From 8861b1aaffe2f0f6b9cb416cf2ad7ed5a6e8ad0b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 9 Sep 2016 09:47:46 +0200 Subject: [PATCH 0906/1509] Grab tanHalfFovy from the projection matrix --- src/gl/renderer/gl_postprocess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index b4fd4d05f..06c85a7bc 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -168,7 +168,7 @@ void FGLRenderer::AmbientOccludeScene() bool multisample = gl_multisample > 1; //float tanHalfFovy = tan(fovy * (M_PI / 360.0f)); - float tanHalfFovy = 1.0f / 1.33333302f; // 1.0f / gl_RenderState.mProjectionMatrix.get()[5]; + float tanHalfFovy = 1.0f / gl_RenderState.mProjectionMatrix.get()[5]; float invFocalLenX = tanHalfFovy * (mBuffers->GetSceneWidth() / (float)mBuffers->GetSceneHeight()); float invFocalLenY = tanHalfFovy; float nDotVBias = clamp(bias, 0.0f, 1.0f); From 63fb604e988298edf1ad9cf13e1f8a1ad95b747e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 9 Sep 2016 18:19:00 +0200 Subject: [PATCH 0907/1509] Fix stripes in the reconstructed normals due to down scaling --- src/gl/renderer/gl_postprocess.cpp | 2 +- wadsrc/static/shaders/glsl/lineardepth.fp | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 06c85a7bc..e00ca7305 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -192,7 +192,7 @@ void FGLRenderer::AmbientOccludeScene() mLinearDepthShader->LinearizeDepthB[multisample].Set(MAX(1.0f / GetZNear(), 1.e-8f)); mLinearDepthShader->InverseDepthRangeA[multisample].Set(1.0f); mLinearDepthShader->InverseDepthRangeB[multisample].Set(0.0f); - mLinearDepthShader->Scale[multisample].Set(mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height); + mLinearDepthShader->Scale[multisample].Set(mBuffers->AmbientWidth * 2.0f / (float)mScreenViewport.width, mBuffers->AmbientHeight * 2.0f / (float)mScreenViewport.height); mLinearDepthShader->Offset[multisample].Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); RenderScreenQuad(); diff --git a/wadsrc/static/shaders/glsl/lineardepth.fp b/wadsrc/static/shaders/glsl/lineardepth.fp index 61e5e8126..558738bd9 100644 --- a/wadsrc/static/shaders/glsl/lineardepth.fp +++ b/wadsrc/static/shaders/glsl/lineardepth.fp @@ -24,18 +24,21 @@ void main() #if defined(MULTISAMPLE) ivec2 texSize = textureSize(DepthTexture); - ivec2 ipos = ivec2(uv * vec2(texSize)); +#else + ivec2 texSize = textureSize(DepthTexture, 0); +#endif + + // Use floor here because as we downscale the sampling error has to remain uniform to prevent + // noise in the depth values. + ivec2 ipos = ivec2(max(floor(uv * vec2(texSize) - 0.75), vec2(0.0))); + +#if defined(MULTISAMPLE) float depth = 0.0; for (int i = 0; i < SampleCount; i++) depth += texelFetch(ColorTexture, ipos, i).a != 0.0 ? texelFetch(DepthTexture, ipos, i).x : 1.0; depth /= float(SampleCount); #else - /*ivec2 texSize = textureSize(DepthTexture, 0); - ivec2 ipos = ivec2(uv * vec2(texSize)); - if (ipos.x < 0) ipos.x += texSize.x; - if (ipos.y < 0) ipos.y += texSize.y; - float depth = texelFetch(ColorTexture, ipos, 0).a != 0.0 ? texelFetch(DepthTexture, ipos, 0).x : 1.0;*/ - float depth = texture(ColorTexture, uv).a != 0.0 ? texture(DepthTexture, uv).x : 1.0; + float depth = texelFetch(ColorTexture, ipos, 0).a != 0.0 ? texelFetch(DepthTexture, ipos, 0).x : 1.0; #endif float normalizedDepth = clamp(InverseDepthRangeA * depth + InverseDepthRangeB, 0.0, 1.0); From 30cb651d9241a54c3d808850a992866829e1ad60 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 10 Sep 2016 10:58:53 +0200 Subject: [PATCH 0908/1509] - completely removed the flat sprite code. This was conceptionally so wrong that there is no chance to salvage any of it. --- src/gl/scene/gl_sprite.cpp | 57 +++++++++++++++----------------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 07f397d6d..c7cfe8554 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -135,7 +135,6 @@ void GLSprite::CalculateVertices(FVector3 *v) // [Nash] is a flat sprite const bool isFlatSprite = (actor != nullptr) && (spritetype == RF_WALLSPRITE || spritetype == RF_FLATSPRITE); - const bool dontFlip = (actor != nullptr) && (actor->renderflags & RF_DONTFLIP); const bool useOffsets = (actor != nullptr) && !(actor->renderflags & RF_ROLLCENTER); // [Nash] check for special sprite drawing modes @@ -176,37 +175,8 @@ void GLSprite::CalculateVertices(FVector3 *v) yawvecY = actor->Angles.Yaw.Sin(); } - // [MC] This is the only thing that I changed in Nash's submission which - // was constantly applying roll to everything. That was wrong. Flat sprites - // with roll literally look like paper thing space ships trying to swerve. - // However, it does well with wall sprites. - // Also, renamed FLOORSPRITE to FLATSPRITE because that's technically incorrect. - // I plan on adding proper FLOORSPRITEs which can actually curve along sloped - // 3D floors later... if possible. - - // Here we need some form of priority in order to work. - if (spritetype == RF_FLATSPRITE) - { - float pitchDegrees = -actor->Angles.Pitch.Degrees; - DVector3 apos = { x, y, z }; - DVector3 diff = ViewPos - apos; - DAngle angto = diff.Angle(); - - angto = deltaangle(actor->Angles.Yaw, angto); - - bool noFlipSprite = (!dontFlip || (fabs(angto) < 90.)); - mat.Rotate(0, 1, 0, (noFlipSprite) ? 0 : 180); - - mat.Rotate(-yawvecY, 0, yawvecX, (noFlipSprite) ? -pitchDegrees : pitchDegrees); - if (drawRollSpriteActor) - { - if (useOffsets) mat.Translate(xx, zz, yy); - mat.Rotate(yawvecX, 0, yawvecY, (noFlipSprite) ? -rollDegrees : rollDegrees); - if (useOffsets) mat.Translate(-xx, -zz, -yy); - } - } // [fgsfds] Rotate the sprite about the sight vector (roll) - else if (spritetype == RF_WALLSPRITE) + if (spritetype == RF_WALLSPRITE) { mat.Rotate(0, 1, 0, 0); if (drawRollSpriteActor) @@ -405,7 +375,13 @@ void GLSprite::Draw(int pass) gl_RenderState.Apply(); FVector3 v[4]; - CalculateVertices(v); + if ((actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE) + { + } + else + { + CalculateVertices(v); + } FQuadDrawer qd; @@ -711,7 +687,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) x = thingpos.X; z = thingpos.Z; y = thingpos.Y; - if (spritetype != RF_FLATSPRITE) z -= thing->Floorclip; + if (spritetype == RF_FACESPRITE) z -= thing->Floorclip; // wall and flat sprites are to be considered level geometry so this may not apply. // [RH] Make floatbobbing a renderer-only effect. if (thing->flags2 & MF2_FLOATBOB) @@ -727,9 +703,19 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) DAngle ang = (thingpos - ViewPos).Angle(); FTextureID patch; if (thing->flags7 & MF7_SPRITEANGLE) + { patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, (thing->SpriteAngle).BAMs(), &mirror); - else + } + else if (!(thing->renderflags & RF_FLATSPRITE)) + { patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, (ang - (thing->Angles.Yaw + thing->SpriteRotation)).BAMs(), &mirror); + } + else + { + // Flat sprites cannot rotate in a predictable manner. + patch = gl_GetSpriteFrame(spritenum, thing->frame, 0, 0, &mirror); + } + if (!patch.isValid()) return; int type = thing->renderflags & RF_SPRITETYPEMASK; gltexture = FMaterial::ValidateTexture(patch, (type == RF_FACESPRITE), false); @@ -781,6 +767,9 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) break; case RF_FLATSPRITE: + // needs careful rethinking + return; + case RF_WALLSPRITE: viewvecX = thing->Angles.Yaw.Cos(); viewvecY = thing->Angles.Yaw.Sin(); From d3246be48805bde32349984141b484857bf4591a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 10 Sep 2016 12:24:13 +0200 Subject: [PATCH 0909/1509] - draw wall sprites without translucent pixels as opaque. This looses the border smoothing with texture filtering but avoids sorting problems. --- src/gl/scene/gl_sprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index c7cfe8554..ea6083680 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -437,7 +437,7 @@ inline void GLSprite::PutSprite(bool translucent) { int list; // [BB] Allow models to be drawn in the GLDL_TRANSLUCENT pass. - if (translucent || !modelframe) + if (translucent || (!modelframe && (actor->renderflags & RF_SPRITETYPEMASK) != RF_WALLSPRITE)) { list = GLDL_TRANSLUCENT; } From 71f4bacbd7ba3a3c6297d6f30f4160a5e3e5c908 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 10 Sep 2016 12:36:44 +0200 Subject: [PATCH 0910/1509] - missed something for last commit. --- src/gl/scene/gl_sprite.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index ea6083680..36e3e00ff 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -899,8 +899,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) // This is a non-translucent sprite (i.e. STYLE_Normal or equivalent) trans=1.f; - - if (!gl_sprite_blend || modelframe) + if (!gl_sprite_blend || modelframe || (thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) { RenderStyle.SrcAlpha = STYLEALPHA_One; RenderStyle.DestAlpha = STYLEALPHA_Zero; From 66c5121e3801218701b58a1bc7fc29c40e0e484e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 10 Sep 2016 17:54:19 +0300 Subject: [PATCH 0911/1509] Do not use OpenGL Core Profile for software renderer on macOS --- src/posix/cocoa/i_video.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 624e8ad07..08a563b25 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -483,7 +483,7 @@ NSOpenGLPixelFormat* CreatePixelFormat(const OpenGLProfile profile) attributes[i++] = NSOpenGLPFAAllowOfflineRenderers; } - if (NSAppKitVersionNumber >= AppKit10_7 && OpenGLProfile::Core == profile) + if (NSAppKitVersionNumber >= AppKit10_7 && OpenGLProfile::Core == profile && 1 == vid_renderer) { NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersion3_2Core; const char* const glversion = Args->CheckValue("-glversion"); From 03d0b09f293b20d454dd5a7357096a2aae557746 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 10 Sep 2016 22:39:09 +0200 Subject: [PATCH 0912/1509] Fix depth blur --- src/gl/renderer/gl_postprocess.cpp | 12 ++++------ wadsrc/static/shaders/glsl/depthblur.fp | 32 ++++++++----------------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index e00ca7305..9b791a3f1 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -118,11 +118,6 @@ CUSTOM_CVAR(Float, gl_ssao_blur_amount, 4.0f, 0) { if (self < 0.1f) self = 0.1f; } -CUSTOM_CVAR(Int, gl_ssao_blur_samples, 5, 0) -{ - if (self < 3 || self > 15 || self % 2 == 0) - self = 9; -} EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) @@ -163,7 +158,6 @@ void FGLRenderer::AmbientOccludeScene() float bias = gl_ssao_bias; float aoRadius = gl_ssao_radius; const float blurAmount = gl_ssao_blur_amount; - int blurSampleCount = gl_ssao_blur_samples; float aoStrength = gl_ssao_strength; bool multisample = gl_multisample > 1; @@ -174,6 +168,8 @@ void FGLRenderer::AmbientOccludeScene() float nDotVBias = clamp(bias, 0.0f, 1.0f); float r2 = aoRadius * aoRadius; + float blurSharpness = 1.0f / blurAmount; + // Calculate linear depth values glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB0); glViewport(0, 0, mBuffers->AmbientWidth, mBuffers->AmbientHeight); @@ -225,14 +221,14 @@ void FGLRenderer::AmbientOccludeScene() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); mDepthBlurShader->Bind(false); - mDepthBlurShader->BlurSharpness[false].Set(blurAmount); + mDepthBlurShader->BlurSharpness[false].Set(blurSharpness); mDepthBlurShader->InvFullResolution[false].Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); RenderScreenQuad(); glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB1); glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture0); mDepthBlurShader->Bind(true); - mDepthBlurShader->BlurSharpness[true].Set(blurAmount); + mDepthBlurShader->BlurSharpness[true].Set(blurSharpness); mDepthBlurShader->InvFullResolution[true].Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); mDepthBlurShader->PowExponent[true].Set(1.8f); RenderScreenQuad(); diff --git a/wadsrc/static/shaders/glsl/depthblur.fp b/wadsrc/static/shaders/glsl/depthblur.fp index bd464d03d..c4f4438d3 100644 --- a/wadsrc/static/shaders/glsl/depthblur.fp +++ b/wadsrc/static/shaders/glsl/depthblur.fp @@ -7,39 +7,32 @@ uniform float BlurSharpness; uniform vec2 InvFullResolution; uniform float PowExponent; -#define KERNEL_RADIUS 3.0 +#define KERNEL_RADIUS 7.0 -struct CenterPixelData -{ - vec2 UV; - float Depth; - float Sharpness; -}; - -float CrossBilateralWeight(float r, float sampleDepth, CenterPixelData center) +float CrossBilateralWeight(float r, float sampleDepth, float centerDepth) { const float blurSigma = KERNEL_RADIUS * 0.5; const float blurFalloff = 1.0 / (2.0 * blurSigma * blurSigma); - float deltaZ = (sampleDepth - center.Depth) * center.Sharpness; + float deltaZ = (sampleDepth - centerDepth) * BlurSharpness; return exp2(-r * r * blurFalloff - deltaZ * deltaZ); } -void ProcessSample(float ao, float z, float r, CenterPixelData center, inout float totalAO, inout float totalW) +void ProcessSample(float ao, float z, float r, float centerDepth, inout float totalAO, inout float totalW) { - float w = CrossBilateralWeight(r, z, center); + float w = CrossBilateralWeight(r, z, centerDepth); totalAO += w * ao; totalW += w; } -void ProcessRadius(vec2 deltaUV, CenterPixelData center, inout float totalAO, inout float totalW) +void ProcessRadius(vec2 deltaUV, float centerDepth, inout float totalAO, inout float totalW) { for (float r = 1; r <= KERNEL_RADIUS; r += 1.0) { - vec2 uv = r * deltaUV + center.UV; + vec2 uv = r * deltaUV + TexCoord; vec2 aoZ = texture(AODepthTexture, uv).xy; - ProcessSample(aoZ.x, aoZ.y, r, center, totalAO, totalW); + ProcessSample(aoZ.x, aoZ.y, r, centerDepth, totalAO, totalW); } } @@ -47,16 +40,11 @@ vec2 ComputeBlur(vec2 deltaUV) { vec2 aoZ = texture(AODepthTexture, TexCoord).xy; - CenterPixelData center; - center.UV = TexCoord; - center.Depth = aoZ.y; - center.Sharpness = BlurSharpness; - float totalAO = aoZ.x; float totalW = 1.0; - ProcessRadius(deltaUV, center, totalAO, totalW); - ProcessRadius(-deltaUV, center, totalAO, totalW); + ProcessRadius(deltaUV, aoZ.y, totalAO, totalW); + ProcessRadius(-deltaUV, aoZ.y, totalAO, totalW); return vec2(totalAO / totalW, aoZ.y); } From 924aaa3a92a5fbaad525afb1a439a35cdfdda747 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 10 Sep 2016 12:20:45 -0400 Subject: [PATCH 0913/1509] fixed: Delay setup of quad-buffered stereo 3d mode, in case a useful OpenGL context is not immediately provided. --- src/gl/stereo3d/gl_quadstereo.cpp | 50 ++++++++++++++++++++++++------- src/gl/stereo3d/gl_quadstereo.h | 2 ++ 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/gl/stereo3d/gl_quadstereo.cpp b/src/gl/stereo3d/gl_quadstereo.cpp index cd689d3b5..1388e6944 100644 --- a/src/gl/stereo3d/gl_quadstereo.cpp +++ b/src/gl/stereo3d/gl_quadstereo.cpp @@ -45,17 +45,38 @@ QuadStereo::QuadStereo(double ipdMeters) // Check whether quad-buffered stereo is supported in the current context // We are assuming the OpenGL context is already current at this point, // i.e. this constructor is called "just in time". - GLboolean supportsStereo, supportsBuffered; - glGetBooleanv(GL_STEREO, &supportsStereo); - glGetBooleanv(GL_DOUBLEBUFFER, &supportsBuffered); - bQuadStereoSupported = supportsStereo && supportsBuffered; - leftEye.bQuadStereoSupported = bQuadStereoSupported; - rightEye.bQuadStereoSupported = bQuadStereoSupported; - eye_ptrs.Push(&leftEye); - // If stereo is not supported, just draw scene once (left eye view only) - if (bQuadStereoSupported) { - eye_ptrs.Push(&rightEye); + // First initialize to mono-ish initial state + bQuadStereoSupported = leftEye.bQuadStereoSupported = rightEye.bQuadStereoSupported = false; + eye_ptrs.Push(&leftEye); // We ALWAYS want to show at least this one view... + // We will possibly advance to true stereo mode in the Setup() method... +} + +// Sometimes the stereo render context is not ready immediately at start up +/* private */ +void QuadStereo::checkInitialRenderContextState() +{ + // Keep trying until we see at least one good OpenGL context to render to + static bool bDecentContextWasFound = false; + if (!bDecentContextWasFound) { + // I'm using a "random" OpenGL call (glGetFramebufferAttachmentParameteriv) + // that appears to correlate with whether the context is ready + GLint attachmentType = GL_NONE; + glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &attachmentType); + if (attachmentType != GL_NONE) // Finally, a useful OpenGL context + { + // This block will be executed exactly ONCE during a game run + bDecentContextWasFound = true; // now we can stop checking every frame... + // Now check whether this context supports hardware stereo + GLboolean supportsStereo, supportsBuffered; + glGetBooleanv(GL_STEREO, &supportsStereo); + glGetBooleanv(GL_DOUBLEBUFFER, &supportsBuffered); + bQuadStereoSupported = supportsStereo && supportsBuffered; + leftEye.bQuadStereoSupported = bQuadStereoSupported; + rightEye.bQuadStereoSupported = bQuadStereoSupported; + if (bQuadStereoSupported) + eye_ptrs.Push(&rightEye); // Use the other eye too, if we can do stereo + } } } @@ -81,11 +102,18 @@ void QuadStereo::Present() const { GLRenderer->mBuffers->BindOutputFB(); GLRenderer->ClearBorders(); - GLRenderer->mBuffers->BindEyeTexture(1, 0); + GLRenderer->mBuffers->BindEyeTexture(0, 0); GLRenderer->DrawPresentTexture(GLRenderer->mOutputLetterbox, true); } } +void QuadStereo::SetUp() const +{ + Stereo3DMode::SetUp(); + // Maybe advance to true stereo mode (ONCE), after the stereo context is finally ready + const_cast(this)->checkInitialRenderContextState(); +} + /* static */ const QuadStereo& QuadStereo::getInstance(float ipd) { diff --git a/src/gl/stereo3d/gl_quadstereo.h b/src/gl/stereo3d/gl_quadstereo.h index d9aa4f435..2c58c88c5 100644 --- a/src/gl/stereo3d/gl_quadstereo.h +++ b/src/gl/stereo3d/gl_quadstereo.h @@ -69,11 +69,13 @@ class QuadStereo : public Stereo3DMode public: QuadStereo(double ipdMeters); void Present() const override; + void SetUp() const override; static const QuadStereo& getInstance(float ipd); private: QuadStereoLeftPose leftEye; QuadStereoRightPose rightEye; bool bQuadStereoSupported; + void checkInitialRenderContextState(); }; From a0b6a0275c5c521455e843709153ed1d7270435b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 11 Sep 2016 11:09:40 +0200 Subject: [PATCH 0914/1509] Fix random texture sampling bug --- src/gl/renderer/gl_postprocess.cpp | 2 ++ src/gl/renderer/gl_renderbuffers.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 9b791a3f1..f79ab2bf1 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -201,6 +201,8 @@ void FGLRenderer::AmbientOccludeScene() glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientRandomTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glActiveTexture(GL_TEXTURE0); mSSAOShader->Bind(); mSSAOShader->DepthTexture.Set(0); diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 9c442ce4e..dec9ab8ed 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -342,10 +342,10 @@ void FGLRenderBuffers::CreateAmbientOcclusion(int width, int height) double z = distribution(generator); double w = distribution(generator); - randomValues[i * 4 + 0] = (int16_t)clamp(x * 32768.0, -32767.0, 32768.0); - randomValues[i * 4 + 1] = (int16_t)clamp(y * 32768.0, -32767.0, 32768.0); - randomValues[i * 4 + 2] = (int16_t)clamp(z * 32768.0, -32767.0, 32768.0); - randomValues[i * 4 + 3] = (int16_t)clamp(w * 32768.0, -32767.0, 32768.0); + randomValues[i * 4 + 0] = (int16_t)clamp(x * 32767.0, -32768.0, 32767.0); + randomValues[i * 4 + 1] = (int16_t)clamp(y * 32767.0, -32768.0, 32767.0); + randomValues[i * 4 + 2] = (int16_t)clamp(z * 32767.0, -32768.0, 32767.0); + randomValues[i * 4 + 3] = (int16_t)clamp(w * 32767.0, -32768.0, 32767.0); } AmbientRandomTexture = Create2DTexture("AmbientRandomTexture", GL_RGBA16_SNORM, 4, 4, randomValues); From 7bdbaaff22fecb244f2de8fedba45d198650d5e8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 12 Sep 2016 20:29:26 +0200 Subject: [PATCH 0915/1509] GL aspect ratio adjustments --- src/gl/scene/gl_scene.cpp | 10 +++------- src/gl/scene/gl_weapon.cpp | 4 +--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 26e226554..9a5ba5756 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -120,7 +120,7 @@ angle_t FGLRenderer::FrustumAngle() // ok, this is a gross hack that barely works... // but at least it doesn't overestimate too much... - double floatangle=2.0+(45.0+((tilt/1.9)))*mCurrentFoV*48.0/BaseRatioSizes[WidescreenRatio][3]/90.0; + double floatangle=2.0+(45.0+((tilt/1.9)))*mCurrentFoV*48.0/AspectMultiplier(WidescreenRatio)/90.0; angle_t a1 = DAngle(floatangle).BAMs(); if (a1>=ANGLE_180) return 0xffffffff; return a1; @@ -917,14 +917,10 @@ void FGLRenderer::RenderView (player_t* player) NoInterpolateView = saved_niv; - // I stopped using BaseRatioSizes here because the information there wasn't well presented. - // 4:3 16:9 16:10 17:10 5:4 - static float ratios[]={1.333333f, 1.777777f, 1.6f, 1.7f, 1.25f, 1.7f, 2.333333f}; - // now render the main view float fovratio; - float ratio = ratios[WidescreenRatio]; - if (! Is54Aspect(WidescreenRatio)) + float ratio = WidescreenRatio; + if (WidescreenRatio >= 1.3f) { fovratio = 1.333333f; } diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 598254c10..db778679e 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -81,8 +81,6 @@ void FGLRenderer::DrawPSprite (player_t * player,DPSprite *psp, float sx, float float scale; float scalex; float ftexturemid; - // 4:3 16:9 16:10 17:10 5:4 17:10 21:9 - static float xratio[] = {1.f, 3.f/4, 5.f/6, 40.f/51, 1.f, 40.f/51, 4.f/7}; // [BB] In the HUD model step we just render the model and break out. if ( hudModelStep ) @@ -108,7 +106,7 @@ void FGLRenderer::DrawPSprite (player_t * player,DPSprite *psp, float sx, float tex->GetSpriteRect(&r); // calculate edges of the shape - scalex = xratio[WidescreenRatio] * vw / 320; + scalex = (320.0f / (240.0f * WidescreenRatio)) * vw / 320; tx = sx - (160 - r.left); x1 = tx * scalex + vw/2; From b378b3d05a1c776def6719def44ab04a0e22559e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 12 Sep 2016 20:43:45 +0200 Subject: [PATCH 0916/1509] Remove black bars from windowed mode --- src/gl/system/gl_framebuffer.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 158d7f333..ed0d07bd5 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -192,12 +192,23 @@ void OpenGLFrameBuffer::Update() DrawRateStuff(); GLRenderer->Flush(); - GLRenderer->SetOutputViewport(nullptr); - Swap(); swapped = false; Unlock(); CheckBench(); + + if (Windowed) + { + int clientWidth = GetClientWidth(); + int clientHeight = GetClientHeight(); + if (clientWidth > 0 && clientHeight > 0 && (Width != clientWidth || Height != clientHeight)) + { + Resize(clientWidth, clientHeight); + V_OutputResized(Width, Height); + } + } + + GLRenderer->SetOutputViewport(nullptr); } From c593dda8f35c3d589711b7e4a551e0edfd9877bf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Sep 2016 23:03:27 +0200 Subject: [PATCH 0917/1509] - added missing nullptr check. --- src/gl/scene/gl_sprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 36e3e00ff..7bea8d82c 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -375,7 +375,7 @@ void GLSprite::Draw(int pass) gl_RenderState.Apply(); FVector3 v[4]; - if ((actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE) + if (actor != nullptr && (actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE) { } else From dcabcaa5b6a5b0deb180ac9eaa067ac62f1b2cc6 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 13 Sep 2016 22:10:07 +0300 Subject: [PATCH 0918/1509] Fixed compilation on non-Windows platforms --- src/gl/system/gl_framebuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index ed0d07bd5..d99566a5a 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -197,7 +197,7 @@ void OpenGLFrameBuffer::Update() Unlock(); CheckBench(); - if (Windowed) + if (!IsFullscreen()) { int clientWidth = GetClientWidth(); int clientHeight = GetClientHeight(); From a98f364cc3767503a8e496d450ba7f1c7db266b5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 13 Sep 2016 23:35:25 +0200 Subject: [PATCH 0919/1509] - added another missing nullptr check. --- src/gl/data/gl_matrix.cpp | 4 ++-- src/gl/scene/gl_sprite.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/data/gl_matrix.cpp b/src/gl/data/gl_matrix.cpp index bc0f4129f..d8017ad40 100644 --- a/src/gl/data/gl_matrix.cpp +++ b/src/gl/data/gl_matrix.cpp @@ -422,7 +422,7 @@ void VSMatrix::computeNormalMatrix(const FLOATTYPE *aMatrix) { - FLOATTYPE mMat3x3[9]; + double mMat3x3[9]; mMat3x3[0] = aMatrix[0]; mMat3x3[1] = aMatrix[1]; @@ -436,7 +436,7 @@ VSMatrix::computeNormalMatrix(const FLOATTYPE *aMatrix) mMat3x3[7] = aMatrix[9]; mMat3x3[8] = aMatrix[10]; - FLOATTYPE det, invDet; + double det, invDet; det = mMat3x3[0] * (mMat3x3[4] * mMat3x3[8] - mMat3x3[5] * mMat3x3[7]) + mMat3x3[1] * (mMat3x3[5] * mMat3x3[6] - mMat3x3[8] * mMat3x3[3]) + diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 7bea8d82c..4a94cdb9c 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -437,7 +437,7 @@ inline void GLSprite::PutSprite(bool translucent) { int list; // [BB] Allow models to be drawn in the GLDL_TRANSLUCENT pass. - if (translucent || (!modelframe && (actor->renderflags & RF_SPRITETYPEMASK) != RF_WALLSPRITE)) + if (translucent || actor == nullptr || (!modelframe && (actor->renderflags & RF_SPRITETYPEMASK) != RF_WALLSPRITE)) { list = GLDL_TRANSLUCENT; } From b85e3b56e38e5c1a7edfbd0640889a0dbc6b0216 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Wed, 14 Sep 2016 02:21:35 -0400 Subject: [PATCH 0920/1509] Establish QZDoom --- CMakeLists.txt | 4 ++-- src/version.h | 8 ++++---- src/win32/zdoom.rc | 16 ++++++++-------- wadsrc/CMakeLists.txt | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80eac0c54..97c9410c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required( VERSION 2.8.7 ) -project(GZDoom) +project(QZDoom) if( COMMAND cmake_policy ) if( POLICY CMP0011 ) @@ -68,7 +68,7 @@ IF( NOT CMAKE_BUILD_TYPE ) ENDIF() set( ZDOOM_OUTPUT_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Directory where zdoom.pk3 and the executable will be created." ) -set( ZDOOM_EXE_NAME "gzdoom" CACHE FILEPATH "Name of the executable to create" ) +set( ZDOOM_EXE_NAME "qzdoom" CACHE FILEPATH "Name of the executable to create" ) if( MSVC ) # Allow the user to use ZDOOM_OUTPUT_DIR as a single release point. # Use zdoom, zdoomd, zdoom64, and zdoomd64 for the binary names diff --git a/src/version.h b/src/version.h index 0b2fa22e7..9b2cd8f1a 100644 --- a/src/version.h +++ b/src/version.h @@ -85,12 +85,12 @@ const char *GetVersionString(); #define DYNLIGHT // This is so that derivates can use the same savegame versions without worrying about engine compatibility -#define GAMESIG "GZDOOM" -#define BASEWAD "gzdoom.pk3" +#define GAMESIG "QZDOOM" +#define BASEWAD "qzdoom.pk3" // More stuff that needs to be different for derivatives. -#define GAMENAME "GZDoom" -#define GAMENAMELOWERCASE "gzdoom" +#define GAMENAME "QZDoom" +#define GAMENAMELOWERCASE "qzdoom" #define FORUM_URL "http://forum.drdteam.org" #define BUGS_FORUM_URL "http://forum.drdteam.org/viewforum.php?f=24" diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index 5e2226c6d..1f760d8ea 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -72,13 +72,13 @@ BEGIN " BEGIN\r\n" " VALUE ""Comments"", ""Thanks to id Software for creating DOOM and then releasing the source code. Thanks also to TeamTNT for creating BOOM, which ZDoom is partially based on. Includes code based on the Cajun Bot 0.97 by Martin Collberg.""\r\n" " VALUE ""CompanyName"", "" ""\r\n" - " VALUE ""FileDescription"", ""GZDoom""\r\n" + " VALUE ""FileDescription"", ""QZDoom""\r\n" " VALUE ""FileVersion"", RC_FILEVERSION2\r\n" - " VALUE ""InternalName"", ""GZDoom""\r\n" + " VALUE ""InternalName"", ""QZDoom""\r\n" " VALUE ""LegalCopyright"", ""Copyright \\u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al.""\r\n" " VALUE ""LegalTrademarks"", ""DoomR is a Registered Trademark of id Software, Inc.""\r\n" - " VALUE ""OriginalFilename"", ""gzdoom.exe""\r\n" - " VALUE ""ProductName"", ""GZDoom""\r\n" + " VALUE ""OriginalFilename"", ""qzdoom.exe""\r\n" + " VALUE ""ProductName"", ""QZDoom""\r\n" " VALUE ""ProductVersion"", RC_PRODUCTVERSION2\r\n" " END\r\n" " END\r\n" @@ -492,13 +492,13 @@ BEGIN BEGIN VALUE "Comments", "Thanks to id Software for creating DOOM and then releasing the source code. Thanks also to TeamTNT for creating BOOM, which ZDoom is partially based on. Includes code based on the Cajun Bot 0.97 by Martin Collberg." VALUE "CompanyName", " " - VALUE "FileDescription", "GZDoom" + VALUE "FileDescription", "QZDoom" VALUE "FileVersion", RC_FILEVERSION2 - VALUE "InternalName", "GZDoom" + VALUE "InternalName", "QZDoom" VALUE "LegalCopyright", "Copyright \u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al." VALUE "LegalTrademarks", "DoomR is a Registered Trademark of id Software, Inc." - VALUE "OriginalFilename", "gzdoom.exe" - VALUE "ProductName", "GZDoom" + VALUE "OriginalFilename", "qzdoom.exe" + VALUE "ProductName", "QZDoom" VALUE "ProductVersion", RC_PRODUCTVERSION2 END END diff --git a/wadsrc/CMakeLists.txt b/wadsrc/CMakeLists.txt index 80189a328..5a85840e0 100644 --- a/wadsrc/CMakeLists.txt +++ b/wadsrc/CMakeLists.txt @@ -1,3 +1,3 @@ cmake_minimum_required( VERSION 2.8.7 ) -add_pk3(gzdoom.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static) +add_pk3(qzdoom.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static) From 004c7de89bb812cc9f01b7f86af242c3f11fe5c6 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Wed, 14 Sep 2016 04:03:39 -0400 Subject: [PATCH 0921/1509] Part 1 of code merge --- src/gl/renderer/gl_colormap.h | 1 - src/r_data/colormaps.cpp | 2 +- src/r_data/colormaps.h | 8 ++++---- src/r_defs.h | 4 ++-- src/r_draw.cpp | 14 +++++++------- src/r_draw.h | 12 ++++++------ src/r_draw_rgba.cpp | 2 +- src/r_draw_rgba.h | 2 +- src/r_main.cpp | 2 +- src/r_main.h | 2 +- src/r_swrenderer.cpp | 2 +- src/r_things.cpp | 8 ++++---- src/r_things.h | 2 +- src/win32/win32gliface.cpp | 5 +++-- src/win32/win32gliface.h | 2 +- 15 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/gl/renderer/gl_colormap.h b/src/gl/renderer/gl_colormap.h index 2122b1248..d66950309 100644 --- a/src/gl/renderer/gl_colormap.h +++ b/src/gl/renderer/gl_colormap.h @@ -75,5 +75,4 @@ struct FColormap }; - #endif diff --git a/src/r_data/colormaps.cpp b/src/r_data/colormaps.cpp index ffaaa38ac..3bfc89b4b 100644 --- a/src/r_data/colormaps.cpp +++ b/src/r_data/colormaps.cpp @@ -71,7 +71,7 @@ struct FakeCmap }; TArray fakecmaps; -FColormap realcolormaps; +FSWColormap realcolormaps; size_t numfakecmaps; diff --git a/src/r_data/colormaps.h b/src/r_data/colormaps.h index bda6a5ea4..039a85189 100644 --- a/src/r_data/colormaps.h +++ b/src/r_data/colormaps.h @@ -9,10 +9,10 @@ void R_DeinitColormaps (); DWORD R_ColormapNumForName(const char *name); // killough 4/4/98 void R_SetDefaultColormap (const char *name); // [RH] change normal fadetable DWORD R_BlendForColormap (DWORD map); // [RH] return calculated blend for a colormap -extern FColormap realcolormaps; // [RH] make the colormaps externally visible +extern FSWColormap realcolormaps; // [RH] make the colormaps externally visible extern size_t numfakecmaps; -struct FColormap +struct FSWColormap { BYTE *Maps = nullptr; PalEntry Color = 0xffffffff; @@ -20,7 +20,7 @@ struct FColormap int Desaturate = 0; }; -struct FDynamicColormap : FColormap +struct FDynamicColormap : FSWColormap { void ChangeFade (PalEntry fadecolor); void ChangeColor (PalEntry lightcolor, int desaturate); @@ -47,7 +47,7 @@ enum }; -struct FSpecialColormap : FColormap +struct FSpecialColormap : FSWColormap { FSpecialColormap() { diff --git a/src/r_defs.h b/src/r_defs.h index f4bfbcdcf..7d7ad7eab 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1509,13 +1509,13 @@ struct FMiniBSP // typedef BYTE lighttable_t; // This could be wider for >8 bit display. -struct FColormap; +struct FSWColormap; // This encapsulates the fields of vissprite_t that can be altered by AlterWeaponSprite struct visstyle_t { int ColormapNum; // Which colormap is rendered - FColormap *BaseColormap; // Base colormap used together with ColormapNum + FSWColormap *BaseColormap; // Base colormap used together with ColormapNum float Alpha; FRenderStyle RenderStyle; }; diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 682ed4668..f255352f5 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -100,7 +100,7 @@ void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); void (*R_MapTiltedPlane)(int y, int x1); void (*R_MapColoredPlane)(int y, int x1); void (*R_DrawParticle)(vissprite_t *); -void (*R_SetupDrawSlab)(FColormap *base_colormap, float light, int shade); +void (*R_SetupDrawSlab)(FSWColormap *base_colormap, float light, int shade); void (*R_DrawSlab)(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); fixed_t (*tmvline1_add)(); void (*tmvline4_add)(); @@ -146,7 +146,7 @@ extern "C" { int dc_pitch=0xABadCafe; // [RH] Distance between rows lighttable_t* dc_colormap; -FColormap *dc_fcolormap; +FSWColormap *dc_fcolormap; ShadeConstants dc_shade_constants; fixed_t dc_light; int dc_x; @@ -1032,7 +1032,7 @@ int ds_y; int ds_x1; int ds_x2; -FColormap* ds_fcolormap; +FSWColormap* ds_fcolormap; lighttable_t* ds_colormap; ShadeConstants ds_shade_constants; dsfixed_t ds_light; @@ -2413,10 +2413,10 @@ void R_InitColumnDrawers () R_DrawParticle = R_DrawParticle_C; #ifdef X86_ASM - R_SetupDrawSlab = [](FColormap *colormap, float light, int shade) { R_SetupDrawSlabA(colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT)); }; + R_SetupDrawSlab = [](FSWColormap *colormap, float light, int shade) { R_SetupDrawSlabA(colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT)); }; R_DrawSlab = R_DrawSlabA; #else - R_SetupDrawSlab = [](FColormap *colormap, float light, int shade) { R_SetupDrawSlabC(colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT)); }; + R_SetupDrawSlab = [](FSWColormap *colormap, float light, int shade) { R_SetupDrawSlabC(colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT)); }; R_DrawSlab = R_DrawSlabC; #endif @@ -2806,7 +2806,7 @@ void R_SetTranslationMap(lighttable_t *translation) } } -void R_SetColorMapLight(FColormap *base_colormap, float light, int shade) +void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade) { dc_fcolormap = base_colormap; if (r_swtruecolor) @@ -2830,7 +2830,7 @@ void R_SetColorMapLight(FColormap *base_colormap, float light, int shade) } } -void R_SetDSColorMapLight(FColormap *base_colormap, float light, int shade) +void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade) { ds_fcolormap = base_colormap; if (r_swtruecolor) diff --git a/src/r_draw.h b/src/r_draw.h index 591ae0b5f..204f2a493 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -31,7 +31,7 @@ extern "C" int fuzzoffset[FUZZTABLE + 1]; // [RH] +1 for the assembly routine extern "C" int fuzzpos; extern "C" int fuzzviewheight; -struct FColormap; +struct FSWColormap; struct ShadeConstants { @@ -52,7 +52,7 @@ extern "C" int ylookup[MAXHEIGHT]; extern "C" int dc_pitch; // [RH] Distance between rows extern "C" lighttable_t*dc_colormap; -extern "C" FColormap *dc_fcolormap; +extern "C" FSWColormap *dc_fcolormap; extern "C" ShadeConstants dc_shade_constants; extern "C" fixed_t dc_light; extern "C" int dc_x; @@ -288,7 +288,7 @@ void R_FillColumnP_C (void); void R_FillColumnHorizP_C (void); void R_FillSpan_C (void); -extern void(*R_SetupDrawSlab)(FColormap *base_colormap, float light, int shade); +extern void(*R_SetupDrawSlab)(FSWColormap *base_colormap, float light, int shade); extern void(*R_DrawSlab)(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); #ifdef X86_ASM @@ -303,7 +303,7 @@ extern "C" int ds_y; extern "C" int ds_x1; extern "C" int ds_x2; -extern "C" FColormap* ds_fcolormap; +extern "C" FSWColormap* ds_fcolormap; extern "C" lighttable_t* ds_colormap; extern "C" ShadeConstants ds_shade_constants; extern "C" dsfixed_t ds_light; @@ -374,10 +374,10 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); // Sets dc_colormap and dc_light to their appropriate values depending on the output format (pal vs true color) -void R_SetColorMapLight(FColormap *base_colormap, float light, int shade); +void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade); // Same as R_SetColorMapLight, but for ds_colormap and ds_light -void R_SetDSColorMapLight(FColormap *base_colormap, float light, int shade); +void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade); void R_SetTranslationMap(lighttable_t *translation); diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 69ebfeb84..0d86ead47 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -2751,7 +2751,7 @@ static ShadeConstants slab_rgba_shade_constants; static const BYTE *slab_rgba_colormap; static fixed_t slab_rgba_light; -void R_SetupDrawSlab_rgba(FColormap *base_colormap, float light, int shade) +void R_SetupDrawSlab_rgba(FSWColormap *base_colormap, float light, int shade) { slab_rgba_shade_constants.light_red = base_colormap->Color.r * 256 / 255; slab_rgba_shade_constants.light_green = base_colormap->Color.g * 256 / 255; diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index ca54f7263..df3d0f233 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -97,7 +97,7 @@ void R_FillSpan_rgba(); void R_DrawTiltedSpan_rgba(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy); void R_DrawColoredSpan_rgba(int y, int x1, int x2); -void R_SetupDrawSlab_rgba(FColormap *base_colormap, float light, int shade); +void R_SetupDrawSlab_rgba(FSWColormap *base_colormap, float light, int shade); void R_DrawSlab_rgba(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); void R_DrawFogBoundary_rgba(int x1, int x2, short *uclip, short *dclip); diff --git a/src/r_main.cpp b/src/r_main.cpp index 5ff80b101..ba02a7c60 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -120,7 +120,7 @@ double FocalLengthX; double FocalLengthY; FDynamicColormap*basecolormap; // [RH] colormap currently drawing with int fixedlightlev; -FColormap *fixedcolormap; +FSWColormap *fixedcolormap; FSpecialColormap *realfixedcolormap; double WallTMapScale2; diff --git a/src/r_main.h b/src/r_main.h index fa8fe0bb1..8d1867526 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -106,7 +106,7 @@ extern double r_SpriteVisibility; extern int r_actualextralight; extern bool foggy; extern int fixedlightlev; -extern FColormap* fixedcolormap; +extern FSWColormap* fixedcolormap; extern FSpecialColormap*realfixedcolormap; diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 034275101..9bc8e4b96 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -340,7 +340,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin // curse Doom's overuse of global variables in the renderer. // These get clobbered by rendering to a camera texture but they need to be preserved so the final rendering can be done with the correct palette. - FColormap *savecolormap = fixedcolormap; + FSWColormap *savecolormap = fixedcolormap; FSpecialColormap *savecm = realfixedcolormap; DAngle savedfov = FieldOfView; diff --git a/src/r_things.cpp b/src/r_things.cpp index 013fc7152..6f1fb2700 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1481,7 +1481,7 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double if (camera->Inventory != nullptr) { BYTE oldcolormapnum = vis->Style.ColormapNum; - FColormap *oldcolormap = vis->Style.BaseColormap; + FSWColormap *oldcolormap = vis->Style.BaseColormap; camera->Inventory->AlterWeaponSprite (&vis->Style); if (vis->Style.BaseColormap != oldcolormap || vis->Style.ColormapNum != oldcolormapnum) { @@ -1960,7 +1960,7 @@ void R_DrawSprite (vissprite_t *spr) int r1, r2; short topclip, botclip; short *clip1, *clip2; - FColormap *colormap = spr->Style.BaseColormap; + FSWColormap *colormap = spr->Style.BaseColormap; int colormapnum = spr->Style.ColormapNum; F3DFloor *rover; FDynamicColormap *mybasecolormap; @@ -2486,7 +2486,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, int x1, x2, y1, y2; vissprite_t* vis; sector_t* heightsec = NULL; - FColormap* map; + FSWColormap* map; // [ZZ] Particle not visible through the portal plane if (CurrentPortal && !!P_PointOnLineSide(particle->Pos, CurrentPortal->dst)) @@ -2785,7 +2785,7 @@ extern double BaseYaspectMul;; void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, const FVector3 &dasprpos, DAngle dasprang, fixed_t daxscale, fixed_t dayscale, FVoxel *voxobj, - FColormap *colormap, int colormapnum, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags) + FSWColormap *colormap, int colormapnum, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags) { int i, j, k, x, y, syoff, ggxstart, ggystart, nxoff; fixed_t cosang, sinang, sprcosang, sprsinang; diff --git a/src/r_things.h b/src/r_things.h index 13f89574b..cbe34015f 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -144,7 +144,7 @@ enum { DVF_OFFSCREEN = 1, DVF_SPANSONLY = 2, DVF_MIRRORED = 4 }; void R_DrawVoxel(const FVector3 &viewpos, FAngle viewangle, const FVector3 &sprpos, DAngle dasprang, fixed_t daxscale, fixed_t dayscale, struct FVoxel *voxobj, - FColormap *colormap, int colormapnum, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags); + FSWColormap *colormap, int colormapnum, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags); void R_ClipVisSprite (vissprite_t *vis, int xl, int xh); diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 7ca001e1e..59ef471d3 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -346,7 +346,8 @@ bool Win32GLVideo::GoFullscreen(bool yes) // //========================================================================== -DFrameBuffer *Win32GLVideo::CreateFrameBuffer(int width, int height, bool fs, DFrameBuffer *old) + +DFrameBuffer *Win32GLVideo::CreateFrameBuffer(int width, int height, bool bgra, bool fs, DFrameBuffer *old) { Win32GLFrameBuffer *fb; @@ -860,7 +861,7 @@ IMPLEMENT_ABSTRACT_CLASS(Win32GLFrameBuffer) // //========================================================================== -Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : BaseWinFB(width, height) +Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : BaseWinFB(width, height, false) { m_Width = width; m_Height = height; diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index 6320e2903..87eb10de6 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -38,7 +38,7 @@ public: void StartModeIterator (int bits, bool fs); bool NextMode (int *width, int *height, bool *letterbox); bool GoFullscreen(bool yes); - DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old); + DFrameBuffer *CreateFrameBuffer (int width, int height, bool bgra, bool fs, DFrameBuffer *old); virtual bool SetResolution (int width, int height, int bits); void DumpAdapters(); bool InitHardware (HWND Window, int multisample); From 3ebf8c7e746ec0f0b9bab827e7b2fa9a0f91bd30 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Wed, 14 Sep 2016 06:28:39 -0400 Subject: [PATCH 0922/1509] More code fixes - now it compiles. --- src/r_data/colormaps.h | 2 +- src/r_defs.h | 1 + src/v_video.cpp | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/r_data/colormaps.h b/src/r_data/colormaps.h index 039a85189..ca1574893 100644 --- a/src/r_data/colormaps.h +++ b/src/r_data/colormaps.h @@ -1,7 +1,7 @@ #ifndef __RES_CMAP_H #define __RES_CMAP_H -struct FColormap; +struct FSWColormap; void R_InitColormaps (); void R_DeinitColormaps (); diff --git a/src/r_defs.h b/src/r_defs.h index 7d7ad7eab..50d514fc5 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1516,6 +1516,7 @@ struct visstyle_t { int ColormapNum; // Which colormap is rendered FSWColormap *BaseColormap; // Base colormap used together with ColormapNum + lighttable_t *colormap; // [SP] Restored from GZDoom - will this work? float Alpha; FRenderStyle RenderStyle; }; diff --git a/src/v_video.cpp b/src/v_video.cpp index d07fdc61a..1bef7df40 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -71,6 +71,7 @@ FRenderer *Renderer; IMPLEMENT_ABSTRACT_CLASS (DCanvas) IMPLEMENT_ABSTRACT_CLASS (DFrameBuffer) +EXTERN_CVAR (Bool, swtruecolor) #if defined(_DEBUG) && defined(_M_IX86) #define DBGBREAK { __asm int 3 } @@ -813,7 +814,7 @@ void DSimpleCanvas::Resize(int width, int height) Pitch = width + MAX(0, CPU.DataL1LineSize - 8); } } - int bytes_per_pixel = bgra ? 4 : 1; + int bytes_per_pixel = swtruecolor ? 4 : 1; MemBuffer = new BYTE[Pitch * height * bytes_per_pixel]; memset (MemBuffer, 0, Pitch * height * bytes_per_pixel); } From b0029fcd1ebb67e7ff23fdebd72c51b13a17a55f Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Wed, 14 Sep 2016 06:38:08 -0400 Subject: [PATCH 0923/1509] Set version to 0.0 (prerelease), set render defaults for true-color software renderer since that is the focus of this project --- src/posix/cocoa/i_video.mm | 2 +- src/posix/sdl/hardware.cpp | 2 +- src/version.h | 8 ++++---- src/win32/hardware.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 20a93ce25..4f91fd369 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -106,7 +106,7 @@ EXTERN_CVAR(Bool, ticker ) EXTERN_CVAR(Bool, vid_vsync) EXTERN_CVAR(Bool, vid_hidpi) -CUSTOM_CVAR(Bool, swtruecolor, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR(Bool, swtruecolor, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // Strictly speaking this doesn't require a mode switch, but it is the easiest // way to force a CreateFramebuffer call without a lot of refactoring. diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 2c0ba617e..b69a0d3d8 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -321,7 +321,7 @@ CUSTOM_CVAR (Int, vid_maxfps, 200, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) extern int NewWidth, NewHeight, NewBits, DisplayBits; -CUSTOM_CVAR(Bool, swtruecolor, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +CUSTOM_CVAR(Bool, swtruecolor, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) { // Strictly speaking this doesn't require a mode switch, but it is the easiest // way to force a CreateFramebuffer call without a lot of refactoring. diff --git a/src/version.h b/src/version.h index 9b2cd8f1a..f3706b1de 100644 --- a/src/version.h +++ b/src/version.h @@ -41,12 +41,12 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "2.2pre" +#define VERSIONSTR "0.0pre" // The version as seen in the Windows resource -#define RC_FILEVERSION 2,1,9999,0 -#define RC_PRODUCTVERSION 2,1,9999,0 -#define RC_PRODUCTVERSION2 "2.2pre" +#define RC_FILEVERSION 0,0,9999,0 +#define RC_PRODUCTVERSION 0,0,9999,0 +#define RC_PRODUCTVERSION2 "0.0pre" // Version identifier for network games. // Bump it every time you do a release unless you're certain you diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index cc55dd400..3cf941307 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -72,7 +72,7 @@ int currentrenderer = -1; bool changerenderer; // [ZDoomGL] -CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer @@ -358,7 +358,7 @@ void I_RestoreWindowedPos () extern int NewWidth, NewHeight, NewBits, DisplayBits; -CUSTOM_CVAR(Bool, swtruecolor, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +CUSTOM_CVAR(Bool, swtruecolor, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) { // Strictly speaking this doesn't require a mode switch, but it is the easiest // way to force a CreateFramebuffer call without a lot of refactoring. From 842558384a74c9f427fb41aaeab426f4fadbd7c7 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Wed, 14 Sep 2016 07:33:31 -0400 Subject: [PATCH 0924/1509] Forgot to set vid_renderer defaults for Linux and Mac. --- src/posix/cocoa/i_video.mm | 2 +- src/posix/sdl/hardware.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 4f91fd369..ba3a3e27e 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -134,7 +134,7 @@ CUSTOM_CVAR(Bool, vid_autoswitch, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ static int s_currentRenderer; -CUSTOM_CVAR(Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR(Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index b69a0d3d8..18c7ad737 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -65,7 +65,7 @@ void I_RestartRenderer(); int currentrenderer; // [ZDoomGL] -CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer From 8b6e09ca09d4ea50af8fe1f4585558ae6294fec6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 14 Sep 2016 20:01:13 +0200 Subject: [PATCH 0925/1509] - changed the license of the OpenGL renderer to LGPL v3. This was done to clean up the license and to ensure that any commercial fork of the engine has to obey the far stricter requirements concerning source distribution. The old license was compatible with GPLv2 whereas combining GPLv2 and LGPLv3 force a license upgrade to GPLv3. The license of code that originates from ZDoomGL has not been changed. --- src/gl/compatibility/gl_20.cpp | 52 +++++++++------------ src/gl/data/gl_data.cpp | 57 +++++++++-------------- src/gl/data/gl_portaldata.cpp | 57 +++++++++-------------- src/gl/data/gl_setup.cpp | 57 +++++++++-------------- src/gl/data/gl_vertexbuffer.cpp | 59 ++++++++++-------------- src/gl/data/gl_vertexbuffer.h | 22 +++++++++ src/gl/dynlights/a_dynlight.cpp | 36 +++++++++++---- src/gl/dynlights/gl_dynlight.cpp | 6 --- src/gl/dynlights/gl_dynlight.h | 22 +++++++++ src/gl/dynlights/gl_dynlight1.cpp | 57 +++++++++-------------- src/gl/dynlights/gl_glow.cpp | 57 +++++++++-------------- src/gl/dynlights/gl_lightbuffer.cpp | 57 +++++++++-------------- src/gl/models/gl_models.cpp | 55 +++++++++-------------- src/gl/models/gl_models.h | 22 +++++++++ src/gl/models/gl_models_md2.cpp | 55 +++++++++-------------- src/gl/models/gl_models_md3.cpp | 57 +++++++++-------------- src/gl/models/gl_voxels.cpp | 55 +++++++++-------------- src/gl/renderer/gl_2ddrawer.cpp | 57 +++++++++-------------- src/gl/renderer/gl_lightdata.cpp | 58 +++++++++--------------- src/gl/renderer/gl_postprocess.cpp | 55 +++++++++-------------- src/gl/renderer/gl_postprocessstate.cpp | 57 +++++++++-------------- src/gl/renderer/gl_quaddrawer.cpp | 59 +++++++++--------------- src/gl/renderer/gl_renderbuffers.cpp | 55 +++++++++-------------- src/gl/renderer/gl_renderer.cpp | 55 +++++++++-------------- src/gl/renderer/gl_renderstate.cpp | 55 +++++++++-------------- src/gl/renderer/gl_renderstate.h | 22 +++++++++ src/gl/scene/gl_bsp.cpp | 57 +++++++++-------------- src/gl/scene/gl_decal.cpp | 55 +++++++++-------------- src/gl/scene/gl_drawinfo.cpp | 56 +++++++++-------------- src/gl/scene/gl_fakeflat.cpp | 55 +++++++++-------------- src/gl/scene/gl_flats.cpp | 55 +++++++++-------------- src/gl/scene/gl_portal.cpp | 56 +++++++++-------------- src/gl/scene/gl_renderhacks.cpp | 57 +++++++++-------------- src/gl/scene/gl_scene.cpp | 55 +++++++++-------------- src/gl/scene/gl_sky.cpp | 60 +++++++++---------------- src/gl/scene/gl_skydome.cpp | 26 +++++++++-- src/gl/scene/gl_sprite.cpp | 56 +++++++++-------------- src/gl/scene/gl_spritelight.cpp | 55 +++++++++-------------- src/gl/scene/gl_vertex.cpp | 59 +++++++++--------------- src/gl/scene/gl_walls.cpp | 60 +++++++++---------------- src/gl/scene/gl_walls_draw.cpp | 60 +++++++++---------------- src/gl/scene/gl_weapon.cpp | 56 +++++++++-------------- src/gl/shaders/gl_bloomshader.cpp | 55 +++++++++-------------- src/gl/shaders/gl_blurshader.cpp | 55 +++++++++-------------- src/gl/shaders/gl_colormapshader.cpp | 55 +++++++++-------------- src/gl/shaders/gl_lensshader.cpp | 55 +++++++++-------------- src/gl/shaders/gl_presentshader.cpp | 55 +++++++++-------------- src/gl/shaders/gl_shader.cpp | 56 +++++++++-------------- src/gl/shaders/gl_shader.h | 21 +++++++++ src/gl/shaders/gl_shaderprogram.cpp | 55 +++++++++-------------- src/gl/shaders/gl_tonemapshader.cpp | 55 +++++++++-------------- src/gl/stereo3d/gl_anaglyph.cpp | 50 +++++++++------------ src/gl/stereo3d/gl_anaglyph.h | 50 +++++++++------------ src/gl/stereo3d/gl_quadstereo.cpp | 50 +++++++++------------ src/gl/stereo3d/gl_quadstereo.h | 50 +++++++++------------ src/gl/stereo3d/gl_stereo3d.cpp | 50 +++++++++------------ src/gl/stereo3d/gl_stereo3d.h | 50 +++++++++------------ src/gl/stereo3d/gl_stereo_cvars.cpp | 50 +++++++++------------ src/gl/stereo3d/gl_stereo_leftright.cpp | 50 +++++++++------------ src/gl/stereo3d/gl_stereo_leftright.h | 50 +++++++++------------ src/gl/stereo3d/scoped_color_mask.h | 50 +++++++++------------ src/gl/stereo3d/scoped_view_shifter.cpp | 50 +++++++++------------ src/gl/stereo3d/scoped_view_shifter.h | 50 +++++++++------------ src/gl/system/gl_debug.cpp | 55 +++++++++-------------- src/gl/system/gl_framebuffer.cpp | 55 +++++++++-------------- src/gl/system/gl_interface.cpp | 53 +++++++++------------- src/gl/system/gl_menu.cpp | 21 +++++++++ src/gl/system/gl_wipe.cpp | 58 +++++++++--------------- src/gl/textures/gl_bitmap.cpp | 53 +++++++++------------- src/gl/textures/gl_hirestex.cpp | 55 +++++++++-------------- src/gl/textures/gl_hwtexture.cpp | 55 +++++++++-------------- src/gl/textures/gl_material.cpp | 57 +++++++++-------------- src/gl/textures/gl_material.h | 4 +- src/gl/textures/gl_samplers.cpp | 57 +++++++++-------------- src/gl/textures/gl_skyboxtexture.cpp | 57 +++++++++-------------- src/gl/textures/gl_texture.cpp | 53 +++++++++------------- src/gl/textures/gl_texture.h | 38 +--------------- src/gl/textures/gl_translate.cpp | 55 +++++++++-------------- src/gl/utility/gl_clock.cpp | 36 +++++++++++++++ src/gl/utility/gl_geometric.cpp | 32 +++++++++++++ src/gl/utility/gl_geometric.h | 33 ++++++++++++++ 81 files changed, 1714 insertions(+), 2309 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index e192b213e..348663929 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -1,3 +1,24 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_20.cpp ** @@ -5,37 +26,8 @@ ** This file collects everything larger that is only needed for ** OpenGL 2.0/no shader compatibility. ** -**--------------------------------------------------------------------------- -** Copyright 2005-2016 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ + #include "gl/system/gl_system.h" #include "menu/menu.h" #include "tarray.h" diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 2aea2b8a3..ad9c824bb 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -1,42 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_data.cpp ** Maintenance data for GL renderer (mostly to handle rendering hacks) ** -**--------------------------------------------------------------------------- -** Copyright 2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +**/ #include "gl/system/gl_system.h" diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 847bf6f61..a7e140449 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -1,43 +1,30 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_setup.cpp ** Initializes the data structures required by the GL renderer to handle ** a level ** -**--------------------------------------------------------------------------- -** Copyright 2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +**/ #include "doomtype.h" #include "colormatcher.h" diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index 73ceddb13..37f5c370e 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -1,43 +1,30 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_setup.cpp ** Initializes the data structures required by the GL renderer to handle ** a level ** -**--------------------------------------------------------------------------- -** Copyright 2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +**/ #include "gl/system/gl_system.h" #include "doomtype.h" diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 0309b2bcd..71bac435c 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -1,42 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* -** glc_vertexbuffer.cpp +** gl_vertexbuffer.cpp ** Vertex buffer handling. ** -**--------------------------------------------------------------------------- -** Copyright 2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +**/ #include "gl/system/gl_system.h" #include "doomtype.h" diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 0efff5508..1e9692f48 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -1,3 +1,25 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// + #ifndef __VERTEXBUFFER_H #define __VERTEXBUFFER_H diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index ac929e7c0..fcb945f01 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -1,10 +1,32 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2004-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** a_dynlight.cpp ** Implements actors representing dynamic lights (hardware independent) ** +** +** all functions marked with [TS] are licensed under **--------------------------------------------------------------------------- ** Copyright 2003 Timothy Stump -** Copyright 2005-2016 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -18,8 +40,6 @@ ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. -** 4. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -154,7 +174,7 @@ void ADynamicLight::Serialize(FArchive &arc) //========================================================================== // -// +// [TS] // //========================================================================== void ADynamicLight::BeginPlay() @@ -169,7 +189,7 @@ void ADynamicLight::BeginPlay() //========================================================================== // -// +// [TS] // //========================================================================== void ADynamicLight::PostBeginPlay() @@ -187,7 +207,7 @@ void ADynamicLight::PostBeginPlay() //========================================================================== // -// +// [TS] // //========================================================================== void ADynamicLight::Activate(AActor *activator) @@ -213,7 +233,7 @@ void ADynamicLight::Activate(AActor *activator) //========================================================================== // -// +// [TS] // //========================================================================== void ADynamicLight::Deactivate(AActor *activator) @@ -225,7 +245,7 @@ void ADynamicLight::Deactivate(AActor *activator) //========================================================================== // -// +// [TS] // //========================================================================== void ADynamicLight::Tick() diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index b12290ab6..3fffe3641 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -18,12 +18,6 @@ ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index 6b6e40c2d..d92bf35c6 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -1,3 +1,25 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// + #ifndef __GLC_DYNLIGHT_H #define __GLC_DYNLIGHT_H diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index 89cdd1ecb..d20f5c01b 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -1,42 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2002-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_dynlight1.cpp ** dynamic light application ** -**--------------------------------------------------------------------------- -** Copyright 2002-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +**/ #include "gl/system/gl_system.h" #include "c_dispatch.h" diff --git a/src/gl/dynlights/gl_glow.cpp b/src/gl/dynlights/gl_glow.cpp index eee1788dc..eacbfa953 100644 --- a/src/gl/dynlights/gl_glow.cpp +++ b/src/gl/dynlights/gl_glow.cpp @@ -1,42 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_glow.cpp ** Glowing flats like Doomsday ** -**--------------------------------------------------------------------------- -** Copyright 2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +**/ #include "w_wad.h" #include "sc_man.h" diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index 604b6f9a2..b819a3be6 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -1,42 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2014-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_lightbuffer.cpp ** Buffer data maintenance for dynamic lights ** -**--------------------------------------------------------------------------- -** Copyright 2014 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +**/ #include "gl/system/gl_system.h" #include "gl/shaders/gl_shader.h" diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 22b61ace4..91bd9131e 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -1,41 +1,30 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_models.cpp ** ** General model handling code ** -**--------------------------------------------------------------------------- -** Copyright 2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +**/ #include "gl/system/gl_system.h" #include "w_wad.h" diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 463f81138..f0267b891 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -1,3 +1,25 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// + #ifndef __GL_MODELS_H_ #define __GL_MODELS_H_ diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index c0bd155fb..0a4e85fed 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -1,41 +1,30 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_models.cpp ** ** MD2/DMD model format code ** -**--------------------------------------------------------------------------- -** Copyright 2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +**/ #include "gl/system/gl_system.h" #include "w_wad.h" diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp index b9c0a120a..b91473714 100644 --- a/src/gl/models/gl_models_md3.cpp +++ b/src/gl/models/gl_models_md3.cpp @@ -1,39 +1,24 @@ -/* -** gl_models_md3.cpp -** -**--------------------------------------------------------------------------- -** Copyright 2006 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2006-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// #include "gl/system/gl_system.h" #include "w_wad.h" diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index ec7f0573b..d37bdf8a0 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -1,41 +1,30 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2010-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_voxels.cpp ** ** Voxel management ** -**--------------------------------------------------------------------------- -** Copyright 2010 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +**/ #include "gl/system/gl_system.h" #include "w_wad.h" diff --git a/src/gl/renderer/gl_2ddrawer.cpp b/src/gl/renderer/gl_2ddrawer.cpp index e0f67c713..082e51ca4 100644 --- a/src/gl/renderer/gl_2ddrawer.cpp +++ b/src/gl/renderer/gl_2ddrawer.cpp @@ -1,42 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_2ddrawer.h ** Container class for drawing 2d graphics with a vertex buffer ** -**--------------------------------------------------------------------------- -** Copyright 2016 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +**/ #include "gl/system/gl_system.h" #include "gl/system/gl_framebuffer.h" diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index c2329879c..288af5c08 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -1,43 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2002-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_light.cpp ** Light level / fog management / dynamic lights ** -**--------------------------------------------------------------------------- -** Copyright 2002-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ - +**/ #include "gl/system/gl_system.h" #include "gl/system/gl_interface.h" diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 00083480c..b6b658a41 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Magnus Norddahl +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_postprocess.cpp ** Post processing effects in the render pipeline ** -**--------------------------------------------------------------------------- -** Copyright 2016 Magnus Norddahl -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/renderer/gl_postprocessstate.cpp b/src/gl/renderer/gl_postprocessstate.cpp index 05cca7f31..9d995783d 100644 --- a/src/gl/renderer/gl_postprocessstate.cpp +++ b/src/gl/renderer/gl_postprocessstate.cpp @@ -1,42 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Magnus Norddahl +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_postprocessstate.cpp ** Render state maintenance ** -**--------------------------------------------------------------------------- -** Copyright 2016 Magnus Norddahl -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +**/ #include "templates.h" #include "gl/system/gl_system.h" diff --git a/src/gl/renderer/gl_quaddrawer.cpp b/src/gl/renderer/gl_quaddrawer.cpp index eedac12e5..d6a4f98a8 100644 --- a/src/gl/renderer/gl_quaddrawer.cpp +++ b/src/gl/renderer/gl_quaddrawer.cpp @@ -1,41 +1,24 @@ -/* -** gl_quaddrawer.h -** -**--------------------------------------------------------------------------- -** Copyright 2016 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// #include "gl/system/gl_system.h" #include "gl/shaders/gl_shader.h" diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 7ad299e2e..4383d706e 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Magnus Norddahl +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_renderbuffers.cpp ** Render buffers used during rendering ** -**--------------------------------------------------------------------------- -** Copyright 2016 Magnus Norddahl -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index f9d627d93..4b59ad1a9 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl1_renderer.cpp ** Renderer interface ** -**--------------------------------------------------------------------------- -** Copyright 2008 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index c3cc905e5..967296cb8 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2009-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_renderstate.cpp ** Render state maintenance ** -**--------------------------------------------------------------------------- -** Copyright 2009 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "templates.h" diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 6acf44026..1c0a20348 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -1,3 +1,25 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2009-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// + #ifndef __GL_RENDERSTATE_H #define __GL_RENDERSTATE_H diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index 5f95902a3..7b9830050 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -1,42 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2000-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_bsp.cpp ** Main rendering loop / BSP traversal / visibility clipping ** -**--------------------------------------------------------------------------- -** Copyright 2000-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +**/ #include "p_lnspec.h" #include "p_local.h" diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index c9de15144..651cb7aa9 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2003-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_decal.cpp ** OpenGL decal rendering code ** -**--------------------------------------------------------------------------- -** Copyright 2003-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "doomdata.h" diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index c34d79816..0d612cf64 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -1,44 +1,32 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2002-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_drawinfo.cpp ** Implements the draw info structure which contains most of the ** data in a scene and the draw lists - including a very thorough BSP ** style sorting algorithm for translucent objects. ** -**--------------------------------------------------------------------------- -** Copyright 2002-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ + #include "gl/system/gl_system.h" #include "r_sky.h" #include "r_utility.h" diff --git a/src/gl/scene/gl_fakeflat.cpp b/src/gl/scene/gl_fakeflat.cpp index 04a19a7ed..b35b36c0e 100644 --- a/src/gl/scene/gl_fakeflat.cpp +++ b/src/gl/scene/gl_fakeflat.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2001-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_fakeflat.cpp ** Fake flat functions to render stacked sectors ** -**--------------------------------------------------------------------------- -** Copyright 2001-2011 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "p_lnspec.h" diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 48ad30786..90f3be66f 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2000-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_flat.cpp ** Flat rendering ** -**--------------------------------------------------------------------------- -** Copyright 2000-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index bd60713b6..f34b5e23f 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -1,41 +1,27 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2004-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_portal.cpp ** Generalized portal maintenance classes for skyboxes, horizons etc. -** Requires a stencil buffer! -** -**--------------------------------------------------------------------------- -** Copyright 2004-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- ** */ diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index 150ad1554..9242df2a9 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2000-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* -** gl_missingtexture.cpp +** gl_renderhacks.cpp ** Handles missing upper and lower textures and self referencing sector hacks ** -**--------------------------------------------------------------------------- -** Copyright 2000-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "a_sharedglobal.h" diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 9a5ba5756..ccceeac5f 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2004-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_scene.cpp ** manages the rendering of the player's view ** -**--------------------------------------------------------------------------- -** Copyright 2004-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 6d82aefa7..2a2952548 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -1,42 +1,24 @@ -/* -** gl_sky.cpp -** Sky preparation code. -** -**--------------------------------------------------------------------------- -** Copyright 2002-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2002-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// #include "gl/system/gl_system.h" #include "a_sharedglobal.h" diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 97c5cb458..1653d2bb8 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -1,11 +1,31 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2003-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* -** gl_sky.cpp ** ** Draws the sky. Loosely based on the JDoom sky and the ZDoomGL 0.66.2 sky. ** +** for FSkyVertexBuffer::SkyVertex only: **--------------------------------------------------------------------------- ** Copyright 2003 Tim Stump -** Copyright 2005 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -19,8 +39,6 @@ ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. -** 4. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 4a94cdb9c..200541eba 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -1,42 +1,30 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2002-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_sprite.cpp ** Sprite/Particle rendering ** -**--------------------------------------------------------------------------- -** Copyright 2002-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ + #include "gl/system/gl_system.h" #include "p_local.h" #include "p_effect.h" diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index 329459bd1..6efa078ca 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2002-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_light.cpp ** Light level / fog management / dynamic lights ** -**--------------------------------------------------------------------------- -** Copyright 2002-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/scene/gl_vertex.cpp b/src/gl/scene/gl_vertex.cpp index 27ad8e059..d693227d5 100644 --- a/src/gl/scene/gl_vertex.cpp +++ b/src/gl/scene/gl_vertex.cpp @@ -1,41 +1,24 @@ -/* -** gl_vertex.cpp -** -**--------------------------------------------------------------------------- -** Copyright 2006 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2006-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index f8bb2a876..3a7baec33 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1,42 +1,24 @@ -/* -** gl_wall.cpp -** Wall rendering preparation -** -**--------------------------------------------------------------------------- -** Copyright 2000-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2000-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// #include "gl/system/gl_system.h" #include "p_local.h" diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 9f521ad11..a7884b51a 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -1,42 +1,24 @@ -/* -** gl_walls_draw.cpp -** Wall rendering -** -**--------------------------------------------------------------------------- -** Copyright 2000-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2000-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// #include "gl/system/gl_system.h" #include "p_local.h" diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index db778679e..d8400aaf6 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -1,42 +1,30 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2000-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_weapon.cpp ** Weapon sprite drawing ** -**--------------------------------------------------------------------------- -** Copyright 2002-2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ + #include "gl/system/gl_system.h" #include "sbar.h" #include "r_utility.h" diff --git a/src/gl/shaders/gl_bloomshader.cpp b/src/gl/shaders/gl_bloomshader.cpp index 9e8f60133..a16c9ed1e 100644 --- a/src/gl/shaders/gl_bloomshader.cpp +++ b/src/gl/shaders/gl_bloomshader.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Magnus Norddahl +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_bloomshader.cpp ** Shaders used to do bloom ** -**--------------------------------------------------------------------------- -** Copyright 2016 Magnus Norddahl -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/shaders/gl_blurshader.cpp b/src/gl/shaders/gl_blurshader.cpp index bf2e29c7e..cd4532cc4 100644 --- a/src/gl/shaders/gl_blurshader.cpp +++ b/src/gl/shaders/gl_blurshader.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Magnus Norddahl +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_blurshader.cpp ** Gaussian blur shader ** -**--------------------------------------------------------------------------- -** Copyright 2016 Magnus Norddahl -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/shaders/gl_colormapshader.cpp b/src/gl/shaders/gl_colormapshader.cpp index f28003150..06c72160a 100644 --- a/src/gl/shaders/gl_colormapshader.cpp +++ b/src/gl/shaders/gl_colormapshader.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_colormapshader.cpp ** Applies a fullscreen colormap to the scene ** -**--------------------------------------------------------------------------- -** Copyright 2016 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/shaders/gl_lensshader.cpp b/src/gl/shaders/gl_lensshader.cpp index 4dc23f14d..9d242aa87 100644 --- a/src/gl/shaders/gl_lensshader.cpp +++ b/src/gl/shaders/gl_lensshader.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Magnus Norddahl +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_lensshader.cpp ** Lens distortion with chromatic aberration shader ** -**--------------------------------------------------------------------------- -** Copyright 2016 Magnus Norddahl -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/shaders/gl_presentshader.cpp b/src/gl/shaders/gl_presentshader.cpp index 426253639..39d20d0fc 100644 --- a/src/gl/shaders/gl_presentshader.cpp +++ b/src/gl/shaders/gl_presentshader.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Magnus Norddahl +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_presentshader.cpp ** Copy rendered texture to back buffer, possibly with gamma correction ** -**--------------------------------------------------------------------------- -** Copyright 2016 Magnus Norddahl -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 3c574bd62..d4e05dfa8 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -1,43 +1,31 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2004-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_shader.cpp ** ** GLSL shader handling ** -**--------------------------------------------------------------------------- -** Copyright 2004-2009 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ + #include "gl/system/gl_system.h" #include "c_cvars.h" #include "v_video.h" diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index e205d0cf8..343942321 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -1,3 +1,24 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2004-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// #ifndef __GL_SHADERS_H__ #define __GL_SHADERS_H__ diff --git a/src/gl/shaders/gl_shaderprogram.cpp b/src/gl/shaders/gl_shaderprogram.cpp index 80a7ea99e..1ed19913a 100644 --- a/src/gl/shaders/gl_shaderprogram.cpp +++ b/src/gl/shaders/gl_shaderprogram.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Magnus Norddahl +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_shaderprogram.cpp ** GLSL shader program compile and link ** -**--------------------------------------------------------------------------- -** Copyright 2016 Magnus Norddahl -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/shaders/gl_tonemapshader.cpp b/src/gl/shaders/gl_tonemapshader.cpp index 56708a694..144981b18 100644 --- a/src/gl/shaders/gl_tonemapshader.cpp +++ b/src/gl/shaders/gl_tonemapshader.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Magnus Norddahl +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_tonemapshader.cpp ** Converts a HDR texture to 0-1 range by applying a tonemap operator ** -**--------------------------------------------------------------------------- -** Copyright 2016 Magnus Norddahl -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/stereo3d/gl_anaglyph.cpp b/src/gl/stereo3d/gl_anaglyph.cpp index 3c051d390..0eb994baf 100644 --- a/src/gl/stereo3d/gl_anaglyph.cpp +++ b/src/gl/stereo3d/gl_anaglyph.cpp @@ -1,36 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2015 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_anaglyph.cpp ** Color mask based stereoscopic 3D modes for GZDoom ** -**--------------------------------------------------------------------------- -** Copyright 2015 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** */ #include "gl_anaglyph.h" diff --git a/src/gl/stereo3d/gl_anaglyph.h b/src/gl/stereo3d/gl_anaglyph.h index e3383fe26..c05174e35 100644 --- a/src/gl/stereo3d/gl_anaglyph.h +++ b/src/gl/stereo3d/gl_anaglyph.h @@ -1,36 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2015 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_anaglyph.h ** Color mask based stereoscopic 3D modes for GZDoom ** -**--------------------------------------------------------------------------- -** Copyright 2015 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** */ #ifndef GL_ANAGLYPH_H_ diff --git a/src/gl/stereo3d/gl_quadstereo.cpp b/src/gl/stereo3d/gl_quadstereo.cpp index 1388e6944..b65c109c8 100644 --- a/src/gl/stereo3d/gl_quadstereo.cpp +++ b/src/gl/stereo3d/gl_quadstereo.cpp @@ -1,36 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2015 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_quadstereo.cpp ** Quad-buffered OpenGL stereoscopic 3D mode for GZDoom ** -**--------------------------------------------------------------------------- -** Copyright 2015 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** */ #include "gl_quadstereo.h" diff --git a/src/gl/stereo3d/gl_quadstereo.h b/src/gl/stereo3d/gl_quadstereo.h index 2c58c88c5..377d846b3 100644 --- a/src/gl/stereo3d/gl_quadstereo.h +++ b/src/gl/stereo3d/gl_quadstereo.h @@ -1,36 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2015 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_quadstereo.h ** Quad-buffered OpenGL stereoscopic 3D mode for GZDoom ** -**--------------------------------------------------------------------------- -** Copyright 2016 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** */ #ifndef GL_QUADSTEREO_H_ diff --git a/src/gl/stereo3d/gl_stereo3d.cpp b/src/gl/stereo3d/gl_stereo3d.cpp index d686a4a43..9403d4751 100644 --- a/src/gl/stereo3d/gl_stereo3d.cpp +++ b/src/gl/stereo3d/gl_stereo3d.cpp @@ -1,36 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2015 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_stereo3d.cpp ** Stereoscopic 3D API ** -**--------------------------------------------------------------------------- -** Copyright 2015 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h index 2cb9417d2..e2a8a1ea6 100644 --- a/src/gl/stereo3d/gl_stereo3d.h +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -1,36 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2015 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_stereo3d.h ** Stereoscopic 3D API ** -**--------------------------------------------------------------------------- -** Copyright 2015 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** */ #ifndef GL_STEREO3D_H_ diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index 897b28088..f904c2a51 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -1,36 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2015 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_stereo_cvars.cpp ** Console variables related to stereoscopic 3D in GZDoom ** -**--------------------------------------------------------------------------- -** Copyright 2015 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** */ #include "gl/stereo3d/gl_stereo3d.h" diff --git a/src/gl/stereo3d/gl_stereo_leftright.cpp b/src/gl/stereo3d/gl_stereo_leftright.cpp index 8605c9b53..1919e320f 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.cpp +++ b/src/gl/stereo3d/gl_stereo_leftright.cpp @@ -1,36 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2015 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_stereo_leftright.cpp ** Offsets for left and right eye views ** -**--------------------------------------------------------------------------- -** Copyright 2015 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** */ #include "gl_stereo_leftright.h" diff --git a/src/gl/stereo3d/gl_stereo_leftright.h b/src/gl/stereo3d/gl_stereo_leftright.h index 250846651..2070ff53a 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.h +++ b/src/gl/stereo3d/gl_stereo_leftright.h @@ -1,36 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2015 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_stereo_leftright.h ** Offsets for left and right eye views ** -**--------------------------------------------------------------------------- -** Copyright 2015 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** */ #ifndef GL_STEREO_LEFTRIGHT_H_ diff --git a/src/gl/stereo3d/scoped_color_mask.h b/src/gl/stereo3d/scoped_color_mask.h index 5c35752e5..42c02db3a 100644 --- a/src/gl/stereo3d/scoped_color_mask.h +++ b/src/gl/stereo3d/scoped_color_mask.h @@ -1,36 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2015 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** scoped_color_mask.h ** Stack-scoped class for temporarily changing the OpenGL color mask setting. ** -**--------------------------------------------------------------------------- -** Copyright 2015 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** */ #ifndef GL_STEREO3D_SCOPED_COLOR_MASK_H_ diff --git a/src/gl/stereo3d/scoped_view_shifter.cpp b/src/gl/stereo3d/scoped_view_shifter.cpp index f4274ed95..b0eb13ef9 100644 --- a/src/gl/stereo3d/scoped_view_shifter.cpp +++ b/src/gl/stereo3d/scoped_view_shifter.cpp @@ -1,37 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2015 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** scoped_view_shifter.cpp ** Stack-scoped class for temporarily changing camera viewpoint ** Used for stereoscopic 3D. ** -**--------------------------------------------------------------------------- -** Copyright 2015 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** */ #include "scoped_view_shifter.h" diff --git a/src/gl/stereo3d/scoped_view_shifter.h b/src/gl/stereo3d/scoped_view_shifter.h index 8e39d533b..bac7f2dac 100644 --- a/src/gl/stereo3d/scoped_view_shifter.h +++ b/src/gl/stereo3d/scoped_view_shifter.h @@ -1,37 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2015 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** scoped_view_shifter.h ** Stack-scoped class for temporarily changing camera viewpoint ** Used for stereoscopic 3D. ** -**--------------------------------------------------------------------------- -** Copyright 2015 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** */ #ifndef GL_STEREO3D_SCOPED_VIEW_SHIFTER_H_ diff --git a/src/gl/system/gl_debug.cpp b/src/gl/system/gl_debug.cpp index 023073951..a8b1bab5d 100644 --- a/src/gl/system/gl_debug.cpp +++ b/src/gl/system/gl_debug.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Magnus Norddahl +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_debig.cpp ** OpenGL debugging support functions ** -**--------------------------------------------------------------------------- -** Copyright 2016 Magnus Norddahl -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "templates.h" diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index d99566a5a..a61d139c0 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -1,42 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2010-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_framebuffer.cpp ** Implementation of the non-hardware specific parts of the ** OpenGL frame buffer ** -**--------------------------------------------------------------------------- -** Copyright 2000-2007 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 9185b63dc..b0bc46ab2 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -1,40 +1,31 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** r_opengl.cpp ** ** OpenGL system interface ** -**--------------------------------------------------------------------------- -** Copyright 2005 Tim Stump -** Copyright 2005-2013 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ + #include "gl/system/gl_system.h" #include "tarray.h" #include "doomtype.h" diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index d4688cfd1..11534436b 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -1,3 +1,24 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// #include "gl/system/gl_system.h" diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 577bc12db..642f20fb1 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -1,42 +1,26 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2008-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* -** gl_wipe.cpp ** Screen wipe stuff -** (This uses immediate mode and the fixed function pipeline -** even if the new renderer is active) -** -**--------------------------------------------------------------------------- -** Copyright 2008 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- ** */ diff --git a/src/gl/textures/gl_bitmap.cpp b/src/gl/textures/gl_bitmap.cpp index 0db901380..f5156c7a5 100644 --- a/src/gl/textures/gl_bitmap.cpp +++ b/src/gl/textures/gl_bitmap.cpp @@ -1,39 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2004-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_bitmap.cpp ** Bitmap class for texture composition ** -**--------------------------------------------------------------------------- -** Copyright 2004-2009 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ diff --git a/src/gl/textures/gl_hirestex.cpp b/src/gl/textures/gl_hirestex.cpp index e3d115c4e..b00e550a1 100644 --- a/src/gl/textures/gl_hirestex.cpp +++ b/src/gl/textures/gl_hirestex.cpp @@ -1,40 +1,27 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2005-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** Hires texture management ** -**--------------------------------------------------------------------------- -** Copyright 2005 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #ifdef _MSC_VER diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 25dc989e7..edcda4398 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -1,42 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2004-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gltexture.cpp ** Low level OpenGL texture handling. These classes are also ** containers for the various translations a texture can have. ** -**--------------------------------------------------------------------------- -** Copyright 2004-2014 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index bc9dc2f52..dd224b8e0 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -1,39 +1,24 @@ -/* -** gl_material.cpp -** -**--------------------------------------------------------------------------- -** Copyright 2004-2009 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2004-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// #include "gl/system/gl_system.h" #include "w_wad.h" diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index ee42a66d0..671d8c694 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -1,6 +1,6 @@ -#ifndef __GL_TEXTURE_H -#define __GL_TEXTURE_H +#ifndef __GL_MATERIAL_H +#define __GL_MATERIAL_H #include "m_fixed.h" #include "textures/textures.h" diff --git a/src/gl/textures/gl_samplers.cpp b/src/gl/textures/gl_samplers.cpp index 64674e63c..d9d2d0700 100644 --- a/src/gl/textures/gl_samplers.cpp +++ b/src/gl/textures/gl_samplers.cpp @@ -1,39 +1,24 @@ -/* -** gl_samplers.cpp -** -**--------------------------------------------------------------------------- -** Copyright 2014 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2014-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// #include "gl/system/gl_system.h" #include "templates.h" diff --git a/src/gl/textures/gl_skyboxtexture.cpp b/src/gl/textures/gl_skyboxtexture.cpp index 4e4a9c72f..2f7328e28 100644 --- a/src/gl/textures/gl_skyboxtexture.cpp +++ b/src/gl/textures/gl_skyboxtexture.cpp @@ -1,39 +1,24 @@ -/* -** gl_skyboxtexture.cpp -** -**--------------------------------------------------------------------------- -** Copyright 2004-2009 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2004-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// #include "doomtype.h" #include "sc_man.h" diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index eb14862c6..ce6ff398c 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -1,38 +1,27 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2004-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** Global texture data ** -**--------------------------------------------------------------------------- -** Copyright 2004-2009 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "gl/system/gl_system.h" diff --git a/src/gl/textures/gl_texture.h b/src/gl/textures/gl_texture.h index a1c471ea8..9ee9b27f9 100644 --- a/src/gl/textures/gl_texture.h +++ b/src/gl/textures/gl_texture.h @@ -1,39 +1,5 @@ -/* -** gl_hqresize.h -** Contains high quality upsampling functions. -** -**--------------------------------------------------------------------------- -** Copyright 2008 Benjamin Berkels -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ - -#ifndef __GL_HQRESIZE_H__ -#define __GL_HQRESIZE_H__ +#ifndef __GL_TEXTURE_H__ +#define __GL_TEXTURE_H__ #include "r_defs.h" diff --git a/src/gl/textures/gl_translate.cpp b/src/gl/textures/gl_translate.cpp index f9a46dba8..5a6ecbea2 100644 --- a/src/gl/textures/gl_translate.cpp +++ b/src/gl/textures/gl_translate.cpp @@ -1,41 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2007-2016 Christoph Oelckers +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_translate.cpp ** GL-related translation stuff ** -**--------------------------------------------------------------------------- -** Copyright 2007 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #include "doomtype.h" diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp index 0bb75cd52..0dc9fd76c 100644 --- a/src/gl/utility/gl_clock.cpp +++ b/src/gl/utility/gl_clock.cpp @@ -1,3 +1,39 @@ +/* +** +** This is a copy of the regular cycle_t from a time when that was based +** on QueryPerformanceCounter which is too costly for real-time profiling. +** +**--------------------------------------------------------------------------- +** Copyright 1998-2016 Randy Heit +** Copyright 2007-2016 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + #ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include diff --git a/src/gl/utility/gl_geometric.cpp b/src/gl/utility/gl_geometric.cpp index 15b01f254..6db10af74 100644 --- a/src/gl/utility/gl_geometric.cpp +++ b/src/gl/utility/gl_geometric.cpp @@ -1,3 +1,35 @@ +/* +** gl_geometric.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2003 Timothy Stump +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ #include diff --git a/src/gl/utility/gl_geometric.h b/src/gl/utility/gl_geometric.h index f1053c430..243361d41 100644 --- a/src/gl/utility/gl_geometric.h +++ b/src/gl/utility/gl_geometric.h @@ -1,3 +1,36 @@ +/* +** gl_geometric.h +** +**--------------------------------------------------------------------------- +** Copyright 2003 Timothy Stump +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + #ifndef __GL_GEOM #define __GL_GEOM From f3a4036dc5eff14e51894695e7cc93f337b88e98 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 14 Sep 2016 21:05:25 +0200 Subject: [PATCH 0926/1509] - lgpl.txt --- docs/licenses/lgpl.txt | 1179 ++++++++++++++++++++++++++-------------- 1 file changed, 758 insertions(+), 421 deletions(-) diff --git a/docs/licenses/lgpl.txt b/docs/licenses/lgpl.txt index 5ab7695ab..be2c3ea8e 100644 --- a/docs/licenses/lgpl.txt +++ b/docs/licenses/lgpl.txt @@ -1,504 +1,841 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - Preamble + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. + 0. Additional Definitions. - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. + 1. Exception to Section 3 of the GNU GPL. - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. + 2. Conveying Modified Versions. - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + 3. Object Code Incorporating Material from Library Header Files. - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) + b) Accompany the object code with a copy of the GNU GPL and this license + document. - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. + 4. Combined Works. - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the Library. - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - a) The modified work must itself be a software library. + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. + Preamble - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. + The GNU General Public License is a free, copyleft license for +software and other kinds of works. - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. + The precise terms and conditions for copying, distribution and +modification follow. - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. + TERMS AND CONDITIONS - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. + 0. Definitions. - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) + "This License" refers to version 3 of the GNU General Public License. - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. + A "covered work" means either the unmodified Program or a work based +on the Program. - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. + 1. Source Code. - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. + 13. Use with the GNU Affero General Public License. -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. + 14. Revised Versions of this License. - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. - NO WARRANTY + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + 15. Disclaimer of Warranty. - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries + 16. Limitation of Liability. - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. + 17. Interpretation of Sections 15 and 16. - + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + Copyright (C) - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This library is distributed in the hope that it will be useful, + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + You should have received a copy of the GNU General Public License + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 3c1868f7e6bfff93def8884f611d58c796273b6a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 16 Sep 2016 02:53:19 +0200 Subject: [PATCH 0927/1509] Fix wrong flash rectangle size after window resize --- src/gl/data/gl_vertexbuffer.cpp | 14 ++++++++++++++ src/gl/data/gl_vertexbuffer.h | 2 ++ src/gl/system/gl_framebuffer.cpp | 1 + 3 files changed, 17 insertions(+) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 71bac435c..844ff9212 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -213,6 +213,20 @@ FFlatVertexBuffer::~FFlatVertexBuffer() map = nullptr; } +void FFlatVertexBuffer::OutputResized(int width, int height) +{ + vbo_shadowdata[4].Set(0, 0, 0, 0, 0); + vbo_shadowdata[5].Set(0, (float)height, 0, 0, 0); + vbo_shadowdata[6].Set((float)width, 0, 0, 0, 0); + vbo_shadowdata[7].Set((float)width, (float)height, 0, 0, 0); + + if (gl.buffermethod == BM_DEFERRED) + { + Map(); + memcpy(map, &vbo_shadowdata[0], mNumReserved * sizeof(FFlatVertex)); + Unmap(); + } +} void FFlatVertexBuffer::BindVBO() { diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 1e9692f48..596de35d9 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -131,6 +131,8 @@ public: FFlatVertexBuffer(int width, int height); ~FFlatVertexBuffer(); + void OutputResized(int width, int height); + void BindVBO(); void CreateVBO(); diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index a61d139c0..07d8abaef 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -192,6 +192,7 @@ void OpenGLFrameBuffer::Update() { Resize(clientWidth, clientHeight); V_OutputResized(Width, Height); + GLRenderer->mVBO->OutputResized(Width, Height); } } From 7c2886e8ea336c831cb926ff51da7fbfdb9f5587 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 16 Sep 2016 08:10:19 +0200 Subject: [PATCH 0928/1509] - fixed the last commit: The altered vertices must always be copied to the actual buffer and it's not necessary to copy everything, copying the 4 changed ones is sufficient. --- src/gl/data/gl_vertexbuffer.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 844ff9212..b18b367c3 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -220,12 +220,9 @@ void FFlatVertexBuffer::OutputResized(int width, int height) vbo_shadowdata[6].Set((float)width, 0, 0, 0, 0); vbo_shadowdata[7].Set((float)width, (float)height, 0, 0, 0); - if (gl.buffermethod == BM_DEFERRED) - { - Map(); - memcpy(map, &vbo_shadowdata[0], mNumReserved * sizeof(FFlatVertex)); - Unmap(); - } + Map(); + memcpy(map, &vbo_shadowdata[4], 4 * sizeof(FFlatVertex)); + Unmap(); } void FFlatVertexBuffer::BindVBO() From 66d20726c260c6fee8a21a7df815acaf65602155 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Fri, 16 Sep 2016 11:45:58 -0500 Subject: [PATCH 0929/1509] Reintroduced flat sprites once more. - Take note, current flat sprites will change. With no pitch involved, sprites are now flat across the ground. --- src/gl/scene/gl_sprite.cpp | 59 +++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 200541eba..2482588c9 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -363,8 +363,48 @@ void GLSprite::Draw(int pass) gl_RenderState.Apply(); FVector3 v[4]; - if (actor != nullptr && (actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE) + if (actor != nullptr) { + if ((actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE) + { + Matrix3x4 mat; + mat.MakeIdentity(); + + float cx, cy, cz = z; + if ((actor->renderflags & RF_ROLLCENTER)) + { + cx = (x1 + x2) * 0.5; + cy = (y1 + y2) * 0.5; + } + else + { + cx = x; + cy = y; + } + + // [MC] Rotate around the center or offsets given to the sprites. + // Counteract any existing rotations, then rotate the angle. + // Tilt the actor up or down based on pitch (increase 'somersaults' forward). + // Then counteract the roll and DO A BARREL ROLL. + + FAngle pitch = (float)-actor->Angles.Pitch.Degrees; + pitch.Normalized180(); + + mat.Translate(cx, cz, cy); + mat.Rotate(0, 1, 0, 270. - actor->Angles.Yaw.Degrees + 90); + mat.Rotate(0, 0, 1, pitch.Degrees); + mat.Rotate(0, 1, 0, 270. - actor->Angles.Roll.Degrees); + mat.Translate(-cx, -cz, -cy); + v[0] = mat * FVector3(x1, z, y2); + v[1] = mat * FVector3(x2, z, y2); + v[2] = mat * FVector3(x1, z, y1); + v[3] = mat * FVector3(x2, z, y1); + + } + else + { + CalculateVertices(v); + } } else { @@ -595,7 +635,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) sector_t * rendersector; // Don't waste time projecting sprites that are definitely not visible. - if (thing == NULL || thing->sprite == 0 || !thing->IsVisibleToPlayer()) + if (thing == nullptr || thing->sprite == 0 || !thing->IsVisibleToPlayer()) { return; } @@ -728,7 +768,8 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) float rightfac = -r.left; float leftfac = rightfac - r.width; - + float bottomfac = -r.top; + float topfac = bottomfac - r.height; z1 = z - r.top; z2 = z1 - r.height; @@ -753,11 +794,15 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) y1 = y + viewvecX*leftfac; y2 = y + viewvecX*rightfac; break; - + case RF_FLATSPRITE: - // needs careful rethinking - return; - + { + x1 = x + leftfac; + x2 = x + rightfac; + y1 = y - topfac; + y2 = y - bottomfac; + } + break; case RF_WALLSPRITE: viewvecX = thing->Angles.Yaw.Cos(); viewvecY = thing->Angles.Yaw.Sin(); From d01b0e061e60dd82a09390328baa0fd0bf378ca3 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Fri, 16 Sep 2016 12:07:01 -0500 Subject: [PATCH 0930/1509] Moved flatsprite code into CalculateVertices. --- src/gl/scene/gl_sprite.cpp | 88 +++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 49 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 2482588c9..765e11969 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -107,6 +107,43 @@ static const float LARGE_VALUE = 1e19f; void GLSprite::CalculateVertices(FVector3 *v) { + if (actor != nullptr && (actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE) + { + Matrix3x4 mat; + mat.MakeIdentity(); + + float cx, cy, cz = z; + if ((actor->renderflags & RF_ROLLCENTER)) + { + cx = (x1 + x2) * 0.5; + cy = (y1 + y2) * 0.5; + } + else + { + cx = x; + cy = y; + } + + // [MC] Rotate around the center or offsets given to the sprites. + // Counteract any existing rotations, then rotate the angle. + // Tilt the actor up or down based on pitch (increase 'somersaults' forward). + // Then counteract the roll and DO A BARREL ROLL. + + FAngle pitch = (float)-actor->Angles.Pitch.Degrees; + pitch.Normalized180(); + + mat.Translate(cx, cz, cy); + mat.Rotate(0, 1, 0, 270. - actor->Angles.Yaw.Degrees + 90); + mat.Rotate(0, 0, 1, pitch.Degrees); + mat.Rotate(0, 1, 0, 270. - actor->Angles.Roll.Degrees); + mat.Translate(-cx, -cz, -cy); + v[0] = mat * FVector3(x1, z, y2); + v[1] = mat * FVector3(x2, z, y2); + v[2] = mat * FVector3(x1, z, y1); + v[3] = mat * FVector3(x2, z, y1); + return; + } + // [BB] Billboard stuff const bool drawWithXYBillboard = ((particle && gl_billboard_particles) || (!(actor && actor->renderflags & RF_FORCEYBILLBOARD) //&& GLRenderer->mViewActor != NULL @@ -363,55 +400,8 @@ void GLSprite::Draw(int pass) gl_RenderState.Apply(); FVector3 v[4]; - if (actor != nullptr) - { - if ((actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE) - { - Matrix3x4 mat; - mat.MakeIdentity(); - - float cx, cy, cz = z; - if ((actor->renderflags & RF_ROLLCENTER)) - { - cx = (x1 + x2) * 0.5; - cy = (y1 + y2) * 0.5; - } - else - { - cx = x; - cy = y; - } - - // [MC] Rotate around the center or offsets given to the sprites. - // Counteract any existing rotations, then rotate the angle. - // Tilt the actor up or down based on pitch (increase 'somersaults' forward). - // Then counteract the roll and DO A BARREL ROLL. - - FAngle pitch = (float)-actor->Angles.Pitch.Degrees; - pitch.Normalized180(); - - mat.Translate(cx, cz, cy); - mat.Rotate(0, 1, 0, 270. - actor->Angles.Yaw.Degrees + 90); - mat.Rotate(0, 0, 1, pitch.Degrees); - mat.Rotate(0, 1, 0, 270. - actor->Angles.Roll.Degrees); - mat.Translate(-cx, -cz, -cy); - v[0] = mat * FVector3(x1, z, y2); - v[1] = mat * FVector3(x2, z, y2); - v[2] = mat * FVector3(x1, z, y1); - v[3] = mat * FVector3(x2, z, y1); - - } - else - { - CalculateVertices(v); - } - } - else - { - CalculateVertices(v); - } - - + CalculateVertices(v); + FQuadDrawer qd; qd.Set(0, v[0][0], v[0][1], v[0][2], ul, vt); qd.Set(1, v[1][0], v[1][1], v[1][2], ur, vt); From d99d43aebaf55f8ad1fbf870faff011714ebd602 Mon Sep 17 00:00:00 2001 From: Gaerzi Date: Fri, 16 Sep 2016 14:34:41 -0400 Subject: [PATCH 0931/1509] Fixes to fuzz shaders --- wadsrc/static/shaders/glsl/fuzz_noise.fp | 4 ++-- wadsrc/static/shaders/glsl/fuzz_standard.fp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wadsrc/static/shaders/glsl/fuzz_noise.fp b/wadsrc/static/shaders/glsl/fuzz_noise.fp index 9f5da5f25..b11f1800c 100644 --- a/wadsrc/static/shaders/glsl/fuzz_noise.fp +++ b/wadsrc/static/shaders/glsl/fuzz_noise.fp @@ -6,8 +6,8 @@ vec4 ProcessTexel() vec2 texCoord = vTexCoord.st; vec4 basicColor = getTexel(texCoord); - texCoord.x = float( int(texCoord.x * 128.0) ) / 128.0; - texCoord.y = float( int(texCoord.y * 128.0) ) / 128.0; + texCoord.x = float( int(texCoord.x * texSize.x) ) / texSize.x; + texCoord.y = float( int(texCoord.y * texSize.y) ) / texSize.y; float texX = sin(mod(texCoord.x * 100.0 + timer*5.0, 3.489)) + texCoord.x / 4.0; float texY = cos(mod(texCoord.y * 100.0 + timer*5.0, 3.489)) + texCoord.y / 4.0; diff --git a/wadsrc/static/shaders/glsl/fuzz_standard.fp b/wadsrc/static/shaders/glsl/fuzz_standard.fp index fd87eaa46..02624073e 100644 --- a/wadsrc/static/shaders/glsl/fuzz_standard.fp +++ b/wadsrc/static/shaders/glsl/fuzz_standard.fp @@ -6,8 +6,8 @@ vec4 ProcessTexel() vec2 texCoord = vTexCoord.st; vec4 basicColor = getTexel(texCoord); - texCoord.x = float( int(texCoord.x * 128.0) ) / 128.0; - texCoord.y = float( int(texCoord.y * 128.0) ) / 128.0; + texCoord.x = float( int(texCoord.x * texSize.x) ) / texSize.x; + texCoord.y = float( int(texCoord.y * texSize.y) ) / texSize.y; float texX = texCoord.x / 3.0 + 0.66; float texY = 0.34 - texCoord.y / 3.0; From f2a3b8978d37ef7ac2295a1c0dd29906f800bb43 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 16 Sep 2016 15:05:16 -0400 Subject: [PATCH 0932/1509] Added declaration in the shader that was missing --- wadsrc/static/shaders/glsl/fuzz_noise.fp | 1 + wadsrc/static/shaders/glsl/fuzz_standard.fp | 1 + 2 files changed, 2 insertions(+) diff --git a/wadsrc/static/shaders/glsl/fuzz_noise.fp b/wadsrc/static/shaders/glsl/fuzz_noise.fp index b11f1800c..17f15d03b 100644 --- a/wadsrc/static/shaders/glsl/fuzz_noise.fp +++ b/wadsrc/static/shaders/glsl/fuzz_noise.fp @@ -5,6 +5,7 @@ vec4 ProcessTexel() { vec2 texCoord = vTexCoord.st; vec4 basicColor = getTexel(texCoord); + ivec2 texSize = textureSize(tex, 0); texCoord.x = float( int(texCoord.x * texSize.x) ) / texSize.x; texCoord.y = float( int(texCoord.y * texSize.y) ) / texSize.y; diff --git a/wadsrc/static/shaders/glsl/fuzz_standard.fp b/wadsrc/static/shaders/glsl/fuzz_standard.fp index 02624073e..95ba52431 100644 --- a/wadsrc/static/shaders/glsl/fuzz_standard.fp +++ b/wadsrc/static/shaders/glsl/fuzz_standard.fp @@ -5,6 +5,7 @@ vec4 ProcessTexel() { vec2 texCoord = vTexCoord.st; vec4 basicColor = getTexel(texCoord); + ivec2 texSize = textureSize(tex, 0); texCoord.x = float( int(texCoord.x * texSize.x) ) / texSize.x; texCoord.y = float( int(texCoord.y * texSize.y) ) / texSize.y; From bec17bd222f775147bf617d54c6d080bc27f46e1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 17 Sep 2016 08:26:30 +0200 Subject: [PATCH 0933/1509] - FLATSPRITE fixes. --- src/gl/scene/gl_sprite.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 765e11969..b63732e3b 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -112,18 +112,6 @@ void GLSprite::CalculateVertices(FVector3 *v) Matrix3x4 mat; mat.MakeIdentity(); - float cx, cy, cz = z; - if ((actor->renderflags & RF_ROLLCENTER)) - { - cx = (x1 + x2) * 0.5; - cy = (y1 + y2) * 0.5; - } - else - { - cx = x; - cy = y; - } - // [MC] Rotate around the center or offsets given to the sprites. // Counteract any existing rotations, then rotate the angle. // Tilt the actor up or down based on pitch (increase 'somersaults' forward). @@ -132,11 +120,24 @@ void GLSprite::CalculateVertices(FVector3 *v) FAngle pitch = (float)-actor->Angles.Pitch.Degrees; pitch.Normalized180(); - mat.Translate(cx, cz, cy); - mat.Rotate(0, 1, 0, 270. - actor->Angles.Yaw.Degrees + 90); + mat.Translate(x, z, y); + mat.Rotate(0, 1, 0, 270. - actor->Angles.Yaw.Degrees); mat.Rotate(0, 0, 1, pitch.Degrees); - mat.Rotate(0, 1, 0, 270. - actor->Angles.Roll.Degrees); - mat.Translate(-cx, -cz, -cy); + + if (actor->renderflags & RF_ROLLCENTER) + { + float cx = (x1 + x2) * 0.5; + float cy = (y1 + y2) * 0.5; + + mat.Translate(cx - x, 0, cy - y); + mat.Rotate(0, 1, 0, - actor->Angles.Roll.Degrees); + mat.Translate(-cx, -z, -cy); + } + else + { + mat.Rotate(0, 1, 0, - actor->Angles.Roll.Degrees); + mat.Translate(-x, -z, -y); + } v[0] = mat * FVector3(x1, z, y2); v[1] = mat * FVector3(x2, z, y2); v[2] = mat * FVector3(x1, z, y1); From 80c1baa5965e29dab24c37ba33eb5af64bd3865d Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sat, 17 Sep 2016 12:08:58 -0500 Subject: [PATCH 0934/1509] Fixed: Pitch was rotating around the wrong axis. --- src/gl/scene/gl_sprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index b63732e3b..af76de826 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -122,7 +122,7 @@ void GLSprite::CalculateVertices(FVector3 *v) mat.Translate(x, z, y); mat.Rotate(0, 1, 0, 270. - actor->Angles.Yaw.Degrees); - mat.Rotate(0, 0, 1, pitch.Degrees); + mat.Rotate(1, 0, 0, pitch.Degrees); if (actor->renderflags & RF_ROLLCENTER) { From 1e2935f4e0bb49e7af64ace8d1b26db04cb58727 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 18 Sep 2016 15:57:22 +0200 Subject: [PATCH 0935/1509] Added exposure pass calculating the bloom/tonemap exposure based on what the eye is seeing --- src/gl/renderer/gl_postprocess.cpp | 90 ++++++++++++++++++- src/gl/renderer/gl_postprocessstate.cpp | 26 +++++- src/gl/renderer/gl_postprocessstate.h | 5 +- src/gl/renderer/gl_renderbuffers.cpp | 66 ++++++++++++-- src/gl/renderer/gl_renderbuffers.h | 22 ++++- src/gl/renderer/gl_renderer.cpp | 9 ++ src/gl/renderer/gl_renderer.h | 8 +- src/gl/scene/gl_scene.cpp | 15 +--- src/gl/shaders/gl_bloomshader.cpp | 2 +- src/gl/shaders/gl_bloomshader.h | 2 +- src/gl/shaders/gl_tonemapshader.cpp | 50 ++++++++++- src/gl/shaders/gl_tonemapshader.h | 41 ++++++++- wadsrc/static/shaders/glsl/bloomextract.fp | 5 +- wadsrc/static/shaders/glsl/exposureaverage.fp | 23 +++++ wadsrc/static/shaders/glsl/exposurecombine.fp | 16 ++++ wadsrc/static/shaders/glsl/exposureextract.fp | 13 +++ wadsrc/static/shaders/glsl/tonemap.fp | 5 +- 17 files changed, 358 insertions(+), 40 deletions(-) create mode 100644 wadsrc/static/shaders/glsl/exposureaverage.fp create mode 100644 wadsrc/static/shaders/glsl/exposurecombine.fp create mode 100644 wadsrc/static/shaders/glsl/exposureextract.fp diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index b6b658a41..1cdad9f9b 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -75,7 +75,10 @@ CUSTOM_CVAR(Float, gl_bloom_amount, 1.4f, 0) if (self < 0.1f) self = 0.1f; } -CVAR(Float, gl_exposure, 0.0f, 0) +CVAR(Float, gl_exposure_scale, 0.75f, 0) +CVAR(Float, gl_exposure_min, 0.35f, 0) +CVAR(Float, gl_exposure_base, 0.35f, 0) +CVAR(Float, gl_exposure_speed, 0.05f, 0) CUSTOM_CVAR(Int, gl_tonemap, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) { @@ -106,6 +109,78 @@ void FGLRenderer::RenderScreenQuad() GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); } +//----------------------------------------------------------------------------- +// +// Extracts light average from the scene and updates the camera exposure texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::UpdateCameraExposure() +{ + if (!gl_bloom && gl_tonemap == 0) + return; + + FGLDebug::PushGroup("UpdateCameraExposure"); + + FGLPostProcessState savedState; + savedState.SaveTextureBinding1(); + + // Extract light level from scene texture: + const auto &level0 = mBuffers->ExposureLevels[0]; + glBindFramebuffer(GL_FRAMEBUFFER, level0.Framebuffer); + glViewport(0, 0, level0.Width, level0.Height); + mBuffers->BindCurrentTexture(0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mExposureExtractShader->Bind(); + mExposureExtractShader->SceneTexture.Set(0); + mExposureExtractShader->Scale.Set(mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height); + mExposureExtractShader->Offset.Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); + RenderScreenQuad(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + // Find the average value: + for (int i = 0; i + 1 < mBuffers->ExposureLevels.Size(); i++) + { + const auto &level = mBuffers->ExposureLevels[i]; + const auto &next = mBuffers->ExposureLevels[i + 1]; + + glBindFramebuffer(GL_FRAMEBUFFER, next.Framebuffer); + glViewport(0, 0, next.Width, next.Height); + glBindTexture(GL_TEXTURE_2D, level.Texture); + mExposureAverageShader->Bind(); + mExposureAverageShader->ExposureTexture.Set(0); + RenderScreenQuad(); + } + + // Combine average value with current camera exposure: + glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->ExposureFB); + glViewport(0, 0, 1, 1); + if (!mBuffers->FirstExposureFrame) + { + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + else + { + mBuffers->FirstExposureFrame = false; + } + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, mBuffers->ExposureLevels.Last().Texture); + mExposureCombineShader->Bind(); + mExposureCombineShader->ExposureTexture.Set(0); + mExposureCombineShader->ExposureBase.Set(gl_exposure_base); + mExposureCombineShader->ExposureMin.Set(gl_exposure_min); + mExposureCombineShader->ExposureScale.Set(gl_exposure_scale); + mExposureCombineShader->ExposureSpeed.Set(gl_exposure_speed); + RenderScreenQuad(); + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + + FGLDebug::PopGroup(); +} + //----------------------------------------------------------------------------- // // Adds bloom contribution to scene texture @@ -121,6 +196,7 @@ void FGLRenderer::BloomScene() FGLDebug::PushGroup("BloomScene"); FGLPostProcessState savedState; + savedState.SaveTextureBinding1(); const float blurAmount = gl_bloom_amount; int sampleCount = gl_bloom_kernel_size; @@ -133,9 +209,12 @@ void FGLRenderer::BloomScene() mBuffers->BindCurrentTexture(0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, mBuffers->ExposureTexture); + glActiveTexture(GL_TEXTURE0); mBloomExtractShader->Bind(); mBloomExtractShader->SceneTexture.Set(0); - mBloomExtractShader->Exposure.Set(mCameraExposure); + mBloomExtractShader->ExposureTexture.Set(1); mBloomExtractShader->Scale.Set(mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height); mBloomExtractShader->Offset.Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); RenderScreenQuad(); @@ -220,7 +299,12 @@ void FGLRenderer::TonemapScene() } else { - mTonemapShader->Exposure.Set(mCameraExposure); + savedState.SaveTextureBinding1(); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, mBuffers->ExposureTexture); + glActiveTexture(GL_TEXTURE0); + + mTonemapShader->ExposureTexture.Set(1); } RenderScreenQuad(); diff --git a/src/gl/renderer/gl_postprocessstate.cpp b/src/gl/renderer/gl_postprocessstate.cpp index 9d995783d..57b7862f5 100644 --- a/src/gl/renderer/gl_postprocessstate.cpp +++ b/src/gl/renderer/gl_postprocessstate.cpp @@ -45,7 +45,7 @@ FGLPostProcessState::FGLPostProcessState() { glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); glActiveTexture(GL_TEXTURE0); - glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding[0]); glBindTexture(GL_TEXTURE_2D, 0); if (gl.flags & RFL_SAMPLER_OBJECTS) { @@ -75,6 +75,15 @@ FGLPostProcessState::FGLPostProcessState() glDisable(GL_BLEND); } +void FGLPostProcessState::SaveTextureBinding1() +{ + glActiveTexture(GL_TEXTURE1); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding[1]); + glBindTexture(GL_TEXTURE_2D, 0); + textureBinding1Saved = true; + glActiveTexture(GL_TEXTURE0); +} + //----------------------------------------------------------------------------- // // Restores state at the end of post processing @@ -108,6 +117,12 @@ FGLPostProcessState::~FGLPostProcessState() glUseProgram(currentProgram); + if (textureBinding1Saved) + { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, 0); + } + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); if (gl.flags & RFL_SAMPLER_OBJECTS) @@ -115,6 +130,13 @@ FGLPostProcessState::~FGLPostProcessState() glBindSampler(0, samplerBinding[0]); glBindSampler(1, samplerBinding[1]); } - glBindTexture(GL_TEXTURE_2D, textureBinding); + glBindTexture(GL_TEXTURE_2D, textureBinding[0]); + + if (textureBinding1Saved) + { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, textureBinding[1]); + } + glActiveTexture(activeTex); } diff --git a/src/gl/renderer/gl_postprocessstate.h b/src/gl/renderer/gl_postprocessstate.h index 4f2ca81a1..bf53aa7de 100644 --- a/src/gl/renderer/gl_postprocessstate.h +++ b/src/gl/renderer/gl_postprocessstate.h @@ -14,12 +14,14 @@ public: FGLPostProcessState(); ~FGLPostProcessState(); + void SaveTextureBinding1(); + private: FGLPostProcessState(const FGLPostProcessState &) = delete; FGLPostProcessState &operator=(const FGLPostProcessState &) = delete; GLint activeTex; - GLint textureBinding; + GLint textureBinding[2]; GLint samplerBinding[2]; GLboolean blendEnabled; GLboolean scissorEnabled; @@ -32,6 +34,7 @@ private: GLint blendSrcAlpha; GLint blendDestRgb; GLint blendDestAlpha; + bool textureBinding1Saved = false; }; #endif diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 4383d706e..b2471e4b9 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -74,6 +74,7 @@ FGLRenderBuffers::~FGLRenderBuffers() ClearPipeline(); ClearEyeBuffers(); ClearBloom(); + ClearExposureLevels(); } void FGLRenderBuffers::ClearScene() @@ -107,6 +108,18 @@ void FGLRenderBuffers::ClearBloom() } } +void FGLRenderBuffers::ClearExposureLevels() +{ + for (auto &level : ExposureLevels) + { + DeleteTexture(level.Texture); + DeleteFrameBuffer(level.Framebuffer); + } + ExposureLevels.Clear(); + DeleteTexture(ExposureTexture); + DeleteFrameBuffer(ExposureFB); +} + void FGLRenderBuffers::ClearEyeBuffers() { for (auto handle : mEyeFBs) @@ -186,11 +199,12 @@ bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei } // Bloom bluring buffers need to match the scene to avoid bloom bleeding artifacts - if (mBloomWidth != sceneWidth || mBloomHeight != sceneHeight) + if (mSceneWidth != sceneWidth || mSceneHeight != sceneHeight) { CreateBloom(sceneWidth, sceneHeight); - mBloomWidth = sceneWidth; - mBloomHeight = sceneHeight; + CreateExposureLevels(sceneWidth, sceneHeight); + mSceneWidth = sceneWidth; + mSceneHeight = sceneHeight; } glBindTexture(GL_TEXTURE_2D, textureBinding); @@ -204,11 +218,12 @@ bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei ClearPipeline(); ClearEyeBuffers(); ClearBloom(); + ClearExposureLevels(); mWidth = 0; mHeight = 0; mSamples = 0; - mBloomWidth = 0; - mBloomHeight = 0; + mSceneWidth = 0; + mSceneHeight = 0; } return !FailedCreate; @@ -281,6 +296,41 @@ void FGLRenderBuffers::CreateBloom(int width, int height) } } +//========================================================================== +// +// Creates camera exposure level buffers +// +//========================================================================== + +void FGLRenderBuffers::CreateExposureLevels(int width, int height) +{ + ClearExposureLevels(); + + int i = 0; + do + { + width = MAX(width / 2, 1); + height = MAX(height / 2, 1); + + FString textureName, fbName; + textureName.Format("Exposure.Texture%d", i); + fbName.Format("Exposure.Framebuffer%d", i); + i++; + + FGLExposureTextureLevel level; + level.Width = width; + level.Height = height; + level.Texture = Create2DTexture(textureName, GL_R32F, level.Width, level.Height); + level.Framebuffer = CreateFrameBuffer(fbName, level.Texture); + ExposureLevels.Push(level); + } while (width > 1 || height > 1); + + ExposureTexture = Create2DTexture("Exposure.CameraTexture", GL_R32F, 1, 1); + ExposureFB = CreateFrameBuffer("Exposure.CameraFB", ExposureTexture); + + FirstExposureFrame = true; +} + //========================================================================== // // Creates eye buffers if needed @@ -316,14 +366,14 @@ void FGLRenderBuffers::CreateEyeBuffers(int eye) // //========================================================================== -GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height) +GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height, const void *data) { - GLuint type = (format == GL_RGBA16F) ? GL_FLOAT : GL_UNSIGNED_BYTE; + GLuint type = (format == GL_RGBA16F || format == GL_R32F) ? GL_FLOAT : GL_UNSIGNED_BYTE; GLuint handle = 0; glGenTextures(1, &handle); glBindTexture(GL_TEXTURE_2D, handle); FGLDebug::LabelObject(GL_TEXTURE, handle, name); - glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, GL_RGBA, type, nullptr); + glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format != GL_R32F ? GL_RGBA : GL_RED, type, data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 08731e39f..4477718f4 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -14,6 +14,15 @@ public: GLuint Height = 0; }; +class FGLExposureTextureLevel +{ +public: + GLuint Texture = 0; + GLuint Framebuffer = 0; + GLuint Width = 0; + GLuint Height = 0; +}; + class FGLRenderBuffers { public: @@ -39,6 +48,11 @@ public: enum { NumBloomLevels = 4 }; FGLBloomTextureLevel BloomLevels[NumBloomLevels]; + TArray ExposureLevels; + GLuint ExposureTexture = 0; + GLuint ExposureFB = 0; + bool FirstExposureFrame = true; + static bool IsEnabled(); int GetWidth() const { return mWidth; } @@ -49,11 +63,13 @@ private: void ClearPipeline(); void ClearEyeBuffers(); void ClearBloom(); + void ClearExposureLevels(); void CreateScene(int width, int height, int samples); void CreatePipeline(int width, int height); void CreateBloom(int width, int height); + void CreateExposureLevels(int width, int height); void CreateEyeBuffers(int eye); - GLuint Create2DTexture(const FString &name, GLuint format, int width, int height); + GLuint Create2DTexture(const FString &name, GLuint format, int width, int height, const void *data = nullptr); GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height); GLuint CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer); @@ -69,8 +85,8 @@ private: int mHeight = 0; int mSamples = 0; int mMaxSamples = 0; - int mBloomWidth = 0; - int mBloomHeight = 0; + int mSceneWidth = 0; + int mSceneHeight = 0; static const int NumPipelineTextures = 2; int mCurrentPipelineTexture = 0; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 4b59ad1a9..ab0e658e7 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -104,6 +104,9 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mPresentShader = nullptr; mBloomExtractShader = nullptr; mBloomCombineShader = nullptr; + mExposureExtractShader = nullptr; + mExposureAverageShader = nullptr; + mExposureCombineShader = nullptr; mBlurShader = nullptr; mTonemapShader = nullptr; mTonemapPalette = nullptr; @@ -119,6 +122,9 @@ void FGLRenderer::Initialize(int width, int height) mBuffers = new FGLRenderBuffers(); mBloomExtractShader = new FBloomExtractShader(); mBloomCombineShader = new FBloomCombineShader(); + mExposureExtractShader = new FExposureExtractShader(); + mExposureAverageShader = new FExposureAverageShader(); + mExposureCombineShader = new FExposureCombineShader(); mBlurShader = new FBlurShader(); mTonemapShader = new FTonemapShader(); mColormapShader = new FColormapShader(); @@ -179,6 +185,9 @@ FGLRenderer::~FGLRenderer() if (mPresentShader) delete mPresentShader; if (mBloomExtractShader) delete mBloomExtractShader; if (mBloomCombineShader) delete mBloomCombineShader; + if (mExposureExtractShader) delete mExposureExtractShader; + if (mExposureAverageShader) delete mExposureAverageShader; + if (mExposureCombineShader) delete mExposureCombineShader; if (mBlurShader) delete mBlurShader; if (mTonemapShader) delete mTonemapShader; if (mTonemapPalette) delete mTonemapPalette; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 162fb6dcf..b95408521 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -21,6 +21,9 @@ class DPSprite; class FGLRenderBuffers; class FBloomExtractShader; class FBloomCombineShader; +class FExposureExtractShader; +class FExposureAverageShader; +class FExposureCombineShader; class FBlurShader; class FTonemapShader; class FColormapShader; @@ -92,6 +95,9 @@ public: FGLRenderBuffers *mBuffers; FBloomExtractShader *mBloomExtractShader; FBloomCombineShader *mBloomCombineShader; + FExposureExtractShader *mExposureExtractShader; + FExposureAverageShader *mExposureAverageShader; + FExposureCombineShader *mExposureCombineShader; FBlurShader *mBlurShader; FTonemapShader *mTonemapShader; FColormapShader *mColormapShader; @@ -118,7 +124,6 @@ public: GL_IRECT mSceneViewport; GL_IRECT mOutputLetterbox; bool mDrawingScene2D = false; - float mCameraExposure = 1.0f; float mSceneClearColor[3]; @@ -166,6 +171,7 @@ public: void SetFixedColormap (player_t *player); void WriteSavePic (player_t *player, FILE *file, int width, int height); void EndDrawScene(sector_t * viewsector); + void UpdateCameraExposure(); void BloomScene(); void TonemapScene(); void ColormapScene(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index ccceeac5f..c66bd64e8 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -790,20 +790,6 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo mViewActor=camera; } - if (toscreen) - { - if (gl_exposure == 0.0f) - { - float light = viewsector->lightlevel / 255.0f; - float exposure = MAX(1.0f + (1.0f - light * light) * 0.9f, 0.5f); - mCameraExposure = mCameraExposure * 0.995f + exposure * 0.005f; - } - else - { - mCameraExposure = gl_exposure; - } - } - // 'viewsector' will not survive the rendering so it cannot be used anymore below. lviewsector = viewsector; @@ -839,6 +825,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo if (mainview && FGLRenderBuffers::IsEnabled()) { mBuffers->BlitSceneToTexture(); + UpdateCameraExposure(); BloomScene(); TonemapScene(); ColormapScene(); diff --git a/src/gl/shaders/gl_bloomshader.cpp b/src/gl/shaders/gl_bloomshader.cpp index a16c9ed1e..44253ae79 100644 --- a/src/gl/shaders/gl_bloomshader.cpp +++ b/src/gl/shaders/gl_bloomshader.cpp @@ -46,7 +46,7 @@ void FBloomExtractShader::Bind() mShader.Link("shaders/glsl/bloomextract"); mShader.SetAttribLocation(0, "PositionInProjection"); SceneTexture.Init(mShader, "SceneTexture"); - Exposure.Init(mShader, "ExposureAdjustment"); + ExposureTexture.Init(mShader, "ExposureTexture"); Scale.Init(mShader, "Scale"); Offset.Init(mShader, "Offset"); } diff --git a/src/gl/shaders/gl_bloomshader.h b/src/gl/shaders/gl_bloomshader.h index b20277a42..8b34bb479 100644 --- a/src/gl/shaders/gl_bloomshader.h +++ b/src/gl/shaders/gl_bloomshader.h @@ -9,7 +9,7 @@ public: void Bind(); FBufferedUniformSampler SceneTexture; - FBufferedUniform1f Exposure; + FBufferedUniformSampler ExposureTexture; FBufferedUniform2f Scale; FBufferedUniform2f Offset; diff --git a/src/gl/shaders/gl_tonemapshader.cpp b/src/gl/shaders/gl_tonemapshader.cpp index 144981b18..3db6db8ba 100644 --- a/src/gl/shaders/gl_tonemapshader.cpp +++ b/src/gl/shaders/gl_tonemapshader.cpp @@ -47,7 +47,7 @@ void FTonemapShader::Bind() shader.Link("shaders/glsl/tonemap"); shader.SetAttribLocation(0, "PositionInProjection"); SceneTexture.Init(shader, "InputTexture"); - Exposure.Init(shader, "ExposureAdjustment"); + ExposureTexture.Init(shader, "ExposureTexture"); PaletteLUT.Init(shader, "PaletteLUT"); } shader.Bind(); @@ -70,3 +70,51 @@ const char *FTonemapShader::GetDefines(int mode) case Palette: return "#define PALETTE\n"; } } + +void FExposureExtractShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/exposureextract.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/exposureextract"); + mShader.SetAttribLocation(0, "PositionInProjection"); + SceneTexture.Init(mShader, "SceneTexture"); + Scale.Init(mShader, "Scale"); + Offset.Init(mShader, "Offset"); + } + mShader.Bind(); +} + +void FExposureAverageShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 400); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/exposureaverage.fp", "", 400); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/exposureaverage"); + mShader.SetAttribLocation(0, "PositionInProjection"); + ExposureTexture.Init(mShader, "ExposureTexture"); + } + mShader.Bind(); +} + +void FExposureCombineShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/exposurecombine.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/exposurecombine"); + mShader.SetAttribLocation(0, "PositionInProjection"); + ExposureTexture.Init(mShader, "ExposureTexture"); + ExposureBase.Init(mShader, "ExposureBase"); + ExposureMin.Init(mShader, "ExposureMin"); + ExposureScale.Init(mShader, "ExposureScale"); + ExposureSpeed.Init(mShader, "ExposureSpeed"); + } + mShader.Bind(); +} \ No newline at end of file diff --git a/src/gl/shaders/gl_tonemapshader.h b/src/gl/shaders/gl_tonemapshader.h index 7ec24117b..b4cd102de 100644 --- a/src/gl/shaders/gl_tonemapshader.h +++ b/src/gl/shaders/gl_tonemapshader.h @@ -9,7 +9,7 @@ public: void Bind(); FBufferedUniformSampler SceneTexture; - FBufferedUniform1f Exposure; + FBufferedUniformSampler ExposureTexture; FBufferedUniformSampler PaletteLUT; static bool IsPaletteMode(); @@ -31,4 +31,43 @@ private: FShaderProgram mShader[NumTonemapModes]; }; +class FExposureExtractShader +{ +public: + void Bind(); + + FBufferedUniformSampler SceneTexture; + FBufferedUniform2f Scale; + FBufferedUniform2f Offset; + +private: + FShaderProgram mShader; +}; + +class FExposureAverageShader +{ +public: + void Bind(); + + FBufferedUniformSampler ExposureTexture; + +private: + FShaderProgram mShader; +}; + +class FExposureCombineShader +{ +public: + void Bind(); + + FBufferedUniformSampler ExposureTexture; + FBufferedUniform1f ExposureBase; + FBufferedUniform1f ExposureMin; + FBufferedUniform1f ExposureScale; + FBufferedUniform1f ExposureSpeed; + +private: + FShaderProgram mShader; +}; + #endif \ No newline at end of file diff --git a/wadsrc/static/shaders/glsl/bloomextract.fp b/wadsrc/static/shaders/glsl/bloomextract.fp index bc94c3c0e..9c5aa0bea 100644 --- a/wadsrc/static/shaders/glsl/bloomextract.fp +++ b/wadsrc/static/shaders/glsl/bloomextract.fp @@ -3,12 +3,13 @@ in vec2 TexCoord; out vec4 FragColor; uniform sampler2D SceneTexture; -uniform float ExposureAdjustment; +uniform sampler2D ExposureTexture; uniform vec2 Scale; uniform vec2 Offset; void main() { + float exposureAdjustment = texture(ExposureTexture, vec2(0.5)).x; vec4 color = texture(SceneTexture, Offset + TexCoord * Scale); - FragColor = max(vec4(color.rgb * ExposureAdjustment - 1, 1), vec4(0)); + FragColor = max(vec4((color.rgb + vec3(0.001)) * exposureAdjustment - 1, 1), vec4(0)); } diff --git a/wadsrc/static/shaders/glsl/exposureaverage.fp b/wadsrc/static/shaders/glsl/exposureaverage.fp new file mode 100644 index 000000000..41c0909d2 --- /dev/null +++ b/wadsrc/static/shaders/glsl/exposureaverage.fp @@ -0,0 +1,23 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D ExposureTexture; + +void main() +{ +#if __VERSION__ < 400 + ivec2 size = textureSize(ExposureTexture, 0); + ivec2 tl = max(ivec2(TexCoord * vec2(size) - 0.5), ivec2(0)); + ivec2 br = min(tl + ivec2(1), size - ivec2(1)); + vec4 values = vec4( + texelFetch(ExposureTexture, tl, 0).x, + texelFetch(ExposureTexture, ivec2(tl.x, br.y), 0).x, + texelFetch(ExposureTexture, ivec2(br.x, tl.y), 0).x, + texelFetch(ExposureTexture, br, 0).x); +#else + vec4 values = textureGather(ExposureTexture, TexCoord); +#endif + + FragColor = vec4((values.x + values.y + values.z + values.w) * 0.25, 0.0, 0.0, 1.0); +} diff --git a/wadsrc/static/shaders/glsl/exposurecombine.fp b/wadsrc/static/shaders/glsl/exposurecombine.fp new file mode 100644 index 000000000..f806f8f86 --- /dev/null +++ b/wadsrc/static/shaders/glsl/exposurecombine.fp @@ -0,0 +1,16 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D ExposureTexture; +uniform float ExposureBase; +uniform float ExposureMin; +uniform float ExposureScale; +uniform float ExposureSpeed; + +void main() +{ + float light = texture(ExposureTexture, TexCoord).x; + float exposureAdjustment = 1.0 / max(ExposureBase + light * ExposureScale, ExposureMin); + FragColor = vec4(exposureAdjustment, 0.0, 0.0, ExposureSpeed); +} diff --git a/wadsrc/static/shaders/glsl/exposureextract.fp b/wadsrc/static/shaders/glsl/exposureextract.fp new file mode 100644 index 000000000..f673bf029 --- /dev/null +++ b/wadsrc/static/shaders/glsl/exposureextract.fp @@ -0,0 +1,13 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D SceneTexture; +uniform vec2 Scale; +uniform vec2 Offset; + +void main() +{ + vec4 color = texture(SceneTexture, Offset + TexCoord * Scale); + FragColor = vec4(max(max(color.r, color.g), color.b), 0.0, 0.0, 1.0); +} diff --git a/wadsrc/static/shaders/glsl/tonemap.fp b/wadsrc/static/shaders/glsl/tonemap.fp index d6574b295..5cb7cf8bd 100644 --- a/wadsrc/static/shaders/glsl/tonemap.fp +++ b/wadsrc/static/shaders/glsl/tonemap.fp @@ -3,7 +3,7 @@ in vec2 TexCoord; out vec4 FragColor; uniform sampler2D InputTexture; -uniform float ExposureAdjustment; +uniform sampler2D ExposureTexture; vec3 Linear(vec3 c) { @@ -84,7 +84,8 @@ void main() { vec3 color = texture(InputTexture, TexCoord).rgb; #ifndef PALETTE - color = color * ExposureAdjustment; + float exposureAdjustment = texture(ExposureTexture, vec2(0.5)).x; + color = color * exposureAdjustment; color = Linear(color); // needed because gzdoom's scene texture is not linear at the moment #endif FragColor = vec4(Tonemap(color), 1.0); From ceaa040750dc481c67e679e6469aa4c69464b4db Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 18 Sep 2016 17:45:02 +0200 Subject: [PATCH 0936/1509] - added a workaround to avoid sprite splitting when it may cause glitches for sprites that get rotated in the draw pass. --- src/gl/scene/gl_drawinfo.cpp | 25 +++++++++++++++++++++++++ src/gl/scene/gl_sprite.cpp | 4 +--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 0d612cf64..d1dd60c4f 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -497,6 +497,10 @@ void GLDrawList::SortWallIntoWall(SortNode * head,SortNode * sort) // // //========================================================================== +EXTERN_CVAR(Int, gl_billboard_mode) +EXTERN_CVAR(Bool, gl_billboard_faces_camera) +EXTERN_CVAR(Bool, gl_billboard_particles) + void GLDrawList::SortSpriteIntoWall(SortNode * head,SortNode * sort) { GLWall * wh=&walls[drawitems[head->itemindex].index]; @@ -527,6 +531,27 @@ void GLDrawList::SortSpriteIntoWall(SortNode * head,SortNode * sort) } else { + const bool drawWithXYBillboard = ((ss->particle && gl_billboard_particles) || (!(ss->actor && ss->actor->renderflags & RF_FORCEYBILLBOARD) + && (gl_billboard_mode == 1 || (ss->actor && ss->actor->renderflags & RF_FORCEXYBILLBOARD)))); + + const bool drawBillboardFacingCamera = gl_billboard_faces_camera; + // [Nash] has +ROLLSPRITE + const bool rotated = (ss->actor != nullptr && ss->actor->renderflags & RF_ROLLSPRITE | RF_WALLSPRITE | RF_FLATSPRITE); + + // cannot sort them at the moment. This requires more complex splitting. + if (drawWithXYBillboard || drawBillboardFacingCamera || rotated) + { + float v1 = wh->PointOnSide(ss->x, ss->y); + if (v1 < 0) + { + head->AddToLeft(sort); + } + else + { + head->AddToRight(sort); + } + return; + } double r=ss->CalcIntersectionVertex(wh); float ix=(float)(ss->x1 + r * (ss->x2-ss->x1)); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index af76de826..720df3b2b 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -923,7 +923,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) // This is a non-translucent sprite (i.e. STYLE_Normal or equivalent) trans=1.f; - if (!gl_sprite_blend || modelframe || (thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) + if (!gl_sprite_blend || modelframe || (thing->renderflags & (RF_FLATSPRITE|RF_WALLSPRITE)) || gl_billboard_faces_camera) { RenderStyle.SrcAlpha = STYLEALPHA_One; RenderStyle.DestAlpha = STYLEALPHA_Zero; @@ -934,8 +934,6 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) RenderStyle.SrcAlpha = STYLEALPHA_Src; RenderStyle.DestAlpha = STYLEALPHA_InvSrc; } - - } if ((gltexture && gltexture->GetTransparent()) || (RenderStyle.Flags & STYLEF_RedIsAlpha)) { From 210dd6d26a3e3041092d5aba14b1d140a8f377b6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 18 Sep 2016 19:31:09 +0200 Subject: [PATCH 0937/1509] Make bloom/exposure less aggressive --- src/gl/renderer/gl_postprocess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 1cdad9f9b..7ce8be0ad 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -75,7 +75,7 @@ CUSTOM_CVAR(Float, gl_bloom_amount, 1.4f, 0) if (self < 0.1f) self = 0.1f; } -CVAR(Float, gl_exposure_scale, 0.75f, 0) +CVAR(Float, gl_exposure_scale, 1.3f, 0) CVAR(Float, gl_exposure_min, 0.35f, 0) CVAR(Float, gl_exposure_base, 0.35f, 0) CVAR(Float, gl_exposure_speed, 0.05f, 0) From daf33b5b4f15b11fdcbe3cf014080ccc6dfdc439 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 19 Sep 2016 09:01:21 +0200 Subject: [PATCH 0938/1509] - master is now at 2.3pre. --- src/version.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/version.h b/src/version.h index 0b2fa22e7..42006c2f8 100644 --- a/src/version.h +++ b/src/version.h @@ -41,12 +41,12 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "2.2pre" +#define VERSIONSTR "2.3pre" // The version as seen in the Windows resource -#define RC_FILEVERSION 2,1,9999,0 -#define RC_PRODUCTVERSION 2,1,9999,0 -#define RC_PRODUCTVERSION2 "2.2pre" +#define RC_FILEVERSION 2,3,9999,0 +#define RC_PRODUCTVERSION 2,3,9999,0 +#define RC_PRODUCTVERSION2 "2.3pre" // Version identifier for network games. // Bump it every time you do a release unless you're certain you From 24f748da03dad1c43c2c8a779546da7bf97d3176 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 20 Sep 2016 02:57:57 +0200 Subject: [PATCH 0939/1509] Add gbuffer pass support to FShaderManager and FRenderState --- src/gl/renderer/gl_renderstate.cpp | 7 +- src/gl/renderer/gl_renderstate.h | 19 +++ src/gl/shaders/gl_shader.cpp | 179 ++++++++++++++++++----------- src/gl/shaders/gl_shader.h | 46 +++++--- wadsrc/static/shaders/glsl/main.fp | 6 + 5 files changed, 170 insertions(+), 87 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index cd51e540a..2cfd739e9 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -105,6 +105,7 @@ void FRenderState::Reset() mViewMatrix.loadIdentity(); mModelMatrix.loadIdentity(); mTextureMatrix.loadIdentity(); + mPassType = NORMAL_PASS; } //========================================================================== @@ -118,11 +119,11 @@ bool FRenderState::ApplyShader() static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f }; if (mSpecialEffect > EFF_NONE) { - activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect); + activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect, mPassType); } else { - activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4, mAlphaThreshold >= 0.f); + activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4, mAlphaThreshold >= 0.f, mPassType); activeShader->Bind(); } @@ -343,7 +344,7 @@ void FRenderState::ApplyMatrices() { if (GLRenderer->mShaderManager != NULL) { - GLRenderer->mShaderManager->ApplyMatrices(&mProjectionMatrix, &mViewMatrix); + GLRenderer->mShaderManager->ApplyMatrices(&mProjectionMatrix, &mViewMatrix, mPassType); } } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 1c0a20348..7bec51be0 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -63,6 +63,13 @@ enum EEffect MAX_EFFECTS }; +enum EPassType +{ + NORMAL_PASS, + GBUFFER_PASS, + MAX_PASS_TYPES +}; + class FRenderState { bool mTextureEnabled; @@ -111,6 +118,8 @@ class FRenderState FShader *activeShader; + EPassType mPassType = NORMAL_PASS; + bool ApplyShader(); public: @@ -459,6 +468,16 @@ public: return mInterpolationFactor; } + void SetPassType(EPassType passType) + { + mPassType = passType; + } + + EPassType GetPassType() + { + return mPassType; + } + // Backwards compatibility crap follows void ApplyFixedFunction(); void DrawColormapOverlay(); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 158163a48..26a449bf2 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -180,6 +180,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * glBindAttribLocation(hShader, VATTR_COLOR, "aColor"); glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2"); + glBindFragDataLocation(hShader, 0, "FragColor"); + glBindFragDataLocation(hShader, 1, "FragData"); + glLinkProgram(hShader); glGetShaderInfoLog(hVertProg, 10000, NULL, buffer); @@ -298,12 +301,13 @@ bool FShader::Bind() // //========================================================================== -FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath, bool usediscard) +FShader *FShaderCollection::Compile (const char *ShaderName, const char *ShaderPath, bool usediscard, EPassType passType) { FString defines; // this can't be in the shader code due to ATI strangeness. if (gl.MaxLights() == 128) defines += "#define MAXLIGHTS128\n"; if (!usediscard) defines += "#define NO_ALPHATEST\n"; + if (passType == GBUFFER_PASS) defines += "#define GBUFFER_PASS\n"; FShader *shader = NULL; try @@ -386,27 +390,75 @@ static const FEffectShader effectshaders[]= { "stencil", "shaders/glsl/main.vp", "shaders/glsl/stencil.fp", NULL, "#define SIMPLE\n#define NO_ALPHATEST\n" }, }; - -//========================================================================== -// -// -// -//========================================================================== - FShaderManager::FShaderManager() { - if (!gl.legacyMode) CompileShaders(); + if (!gl.legacyMode) + { + for (int passType = 0; passType < MAX_PASS_TYPES; passType++) + mPassShaders.Push(new FShaderCollection((EPassType)passType)); + } } -//========================================================================== -// -// -// -//========================================================================== - FShaderManager::~FShaderManager() { - if (!gl.legacyMode) Clean(); + if (!gl.legacyMode) + { + glUseProgram(0); + mActiveShader = NULL; + + for (auto collection : mPassShaders) + delete collection; + } +} + +void FShaderManager::SetActiveShader(FShader *sh) +{ + if (mActiveShader != sh) + { + glUseProgram(sh!= NULL? sh->GetHandle() : 0); + mActiveShader = sh; + } +} + +FShader *FShaderManager::BindEffect(int effect, EPassType passType) +{ + if (passType < mPassShaders.Size()) + return mPassShaders[passType]->BindEffect(effect); + else + return nullptr; +} + +FShader *FShaderManager::Get(unsigned int eff, bool alphateston, EPassType passType) +{ + if (passType < mPassShaders.Size()) + return mPassShaders[passType]->Get(eff, alphateston); + else + return nullptr; +} + +void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view, EPassType passType) +{ + if (gl.legacyMode) + { + glMatrixMode(GL_PROJECTION); + glLoadMatrixf(proj->get()); + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(view->get()); + } + else + { + if (passType < mPassShaders.Size()) + mPassShaders[passType]->ApplyMatrices(proj, view); + + if (mActiveShader) + mActiveShader->Bind(); + } +} + +void FShaderManager::ResetFixedColormap() +{ + for (auto &collection : mPassShaders) + collection->ResetFixedColormap(); } //========================================================================== @@ -415,10 +467,30 @@ FShaderManager::~FShaderManager() // //========================================================================== -void FShaderManager::CompileShaders() +FShaderCollection::FShaderCollection(EPassType passType) { - mActiveShader = NULL; + CompileShaders(passType); +} +//========================================================================== +// +// +// +//========================================================================== + +FShaderCollection::~FShaderCollection() +{ + Clean(); +} + +//========================================================================== +// +// +// +//========================================================================== + +void FShaderCollection::CompileShaders(EPassType passType) +{ mTextureEffects.Clear(); mTextureEffectsNAT.Clear(); for (int i = 0; i < MAX_EFFECTS; i++) @@ -428,11 +500,11 @@ void FShaderManager::CompileShaders() for(int i=0;defaultshaders[i].ShaderName != NULL;i++) { - FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, true); + FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, true, passType); mTextureEffects.Push(shc); if (i <= 3) { - FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, false); + FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, false, passType); mTextureEffectsNAT.Push(shc); } } @@ -442,7 +514,7 @@ void FShaderManager::CompileShaders() FString name = ExtractFileBase(usershaders[i]); FName sfn = name; - FShader *shc = Compile(sfn, usershaders[i], true); + FShader *shc = Compile(sfn, usershaders[i], true, passType); mTextureEffects.Push(shc); } @@ -464,11 +536,8 @@ void FShaderManager::CompileShaders() // //========================================================================== -void FShaderManager::Clean() +void FShaderCollection::Clean() { - glUseProgram(0); - mActiveShader = NULL; - for (unsigned int i = 0; i < mTextureEffectsNAT.Size(); i++) { if (mTextureEffectsNAT[i] != NULL) delete mTextureEffectsNAT[i]; @@ -492,7 +561,7 @@ void FShaderManager::Clean() // //========================================================================== -int FShaderManager::Find(const char * shn) +int FShaderCollection::Find(const char * shn) { FName sfn = shn; @@ -506,21 +575,6 @@ int FShaderManager::Find(const char * shn) return -1; } -//========================================================================== -// -// -// -//========================================================================== - -void FShaderManager::SetActiveShader(FShader *sh) -{ - if (mActiveShader != sh) - { - glUseProgram(sh!= NULL? sh->GetHandle() : 0); - mActiveShader = sh; - } -} - //========================================================================== // @@ -528,7 +582,7 @@ void FShaderManager::SetActiveShader(FShader *sh) // //========================================================================== -FShader *FShaderManager::BindEffect(int effect) +FShader *FShaderCollection::BindEffect(int effect) { if (effect >= 0 && effect < MAX_EFFECTS && mEffectShaders[effect] != NULL) { @@ -546,36 +600,25 @@ FShader *FShaderManager::BindEffect(int effect) //========================================================================== EXTERN_CVAR(Int, gl_fuzztype) -void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view) +void FShaderCollection::ApplyMatrices(VSMatrix *proj, VSMatrix *view) { - if (gl.legacyMode) + for (int i = 0; i < 4; i++) { - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(proj->get()); - glMatrixMode(GL_MODELVIEW); - glLoadMatrixf(view->get()); + mTextureEffects[i]->ApplyMatrices(proj, view); + mTextureEffectsNAT[i]->ApplyMatrices(proj, view); } - else + mTextureEffects[4]->ApplyMatrices(proj, view); + if (gl_fuzztype != 0) { - for (int i = 0; i < 4; i++) - { - mTextureEffects[i]->ApplyMatrices(proj, view); - mTextureEffectsNAT[i]->ApplyMatrices(proj, view); - } - mTextureEffects[4]->ApplyMatrices(proj, view); - if (gl_fuzztype != 0) - { - mTextureEffects[4 + gl_fuzztype]->ApplyMatrices(proj, view); - } - for (unsigned i = 12; i < mTextureEffects.Size(); i++) - { - mTextureEffects[i]->ApplyMatrices(proj, view); - } - for (int i = 0; i < MAX_EFFECTS; i++) - { - mEffectShaders[i]->ApplyMatrices(proj, view); - } - if (mActiveShader != NULL) mActiveShader->Bind(); + mTextureEffects[4 + gl_fuzztype]->ApplyMatrices(proj, view); + } + for (unsigned i = 12; i < mTextureEffects.Size(); i++) + { + mTextureEffects[i]->ApplyMatrices(proj, view); + } + for (int i = 0; i < MAX_EFFECTS; i++) + { + mEffectShaders[i]->ApplyMatrices(proj, view); } } diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 5af927e6d..793fa63dd 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -37,6 +37,7 @@ enum VATTR_NORMAL = 4 }; +class FShaderCollection; //========================================================================== // @@ -248,7 +249,7 @@ public: class FShader { - friend class FShaderManager; + friend class FShaderCollection; friend class FRenderState; unsigned int hShader; @@ -323,7 +324,6 @@ public: }; - //========================================================================== // // The global shader manager @@ -331,26 +331,40 @@ public: //========================================================================== class FShaderManager { - TArray mTextureEffects; - TArray mTextureEffectsNAT; - FShader *mActiveShader; - FShader *mEffectShaders[MAX_EFFECTS]; - - void Clean(); - void CompileShaders(); - public: FShaderManager(); ~FShaderManager(); - FShader *Compile(const char *ShaderName, const char *ShaderPath, bool usediscard); + + void SetActiveShader(FShader *sh); + FShader *GetActiveShader() const { return mActiveShader; } + + FShader *BindEffect(int effect, EPassType passType); + FShader *Get(unsigned int eff, bool alphateston, EPassType passType); + void ApplyMatrices(VSMatrix *proj, VSMatrix *view, EPassType passType); + + void ResetFixedColormap(); + +private: + FShader *mActiveShader = nullptr; + TArray mPassShaders; +}; + +class FShaderCollection +{ + TArray mTextureEffects; + TArray mTextureEffectsNAT; + FShader *mEffectShaders[MAX_EFFECTS]; + + void Clean(); + void CompileShaders(EPassType passType); + +public: + FShaderCollection(EPassType passType); + ~FShaderCollection(); + FShader *Compile(const char *ShaderName, const char *ShaderPath, bool usediscard, EPassType passType); int Find(const char *mame); FShader *BindEffect(int effect); - void SetActiveShader(FShader *sh); void ApplyMatrices(VSMatrix *proj, VSMatrix *view); - FShader *GetActiveShader() const - { - return mActiveShader; - } void ResetFixedColormap() { diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 84b7f5742..0b66f0569 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -5,6 +5,9 @@ in vec4 vTexCoord; in vec4 vColor; out vec4 FragColor; +#ifdef GBUFFER_PASS +out vec4 FragData; +#endif #ifdef SHADER_STORAGE_LIGHTS layout(std430, binding = 1) buffer LightBufferSSO @@ -433,5 +436,8 @@ void main() } } FragColor = frag; +#ifdef GBUFFER_PASS + FragData = vec4(uFogColor.rgb, 1.0); +#endif } From b6c64416be6180f53ffeee09755a1f65f9e6ba70 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 21 Sep 2016 02:04:56 +0200 Subject: [PATCH 0940/1509] Added SceneData texture as the second colorbuffer when rendering a scene and placed fog data into it --- src/gl/renderer/gl_postprocess.cpp | 18 +++++++----- src/gl/renderer/gl_renderbuffers.cpp | 36 +++++++++++++++++++---- src/gl/renderer/gl_renderbuffers.h | 7 +++-- src/gl/renderer/gl_renderer.cpp | 2 +- src/gl/scene/gl_scene.cpp | 23 +++++++++++++-- src/gl/shaders/gl_ambientshader.cpp | 23 +++++++++------ src/gl/shaders/gl_ambientshader.h | 10 +++++-- src/gl/system/gl_cvars.h | 6 ++++ wadsrc/static/shaders/glsl/main.fp | 28 +++++++++++++++++- wadsrc/static/shaders/glsl/ssaocombine.fp | 29 +++++++++++++++++- 10 files changed, 150 insertions(+), 32 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 8b8afd52e..b3d125922 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -138,9 +138,6 @@ void FGLRenderer::PostProcessScene() void FGLRenderer::AmbientOccludeScene() { - if (!gl_ssao || !FGLRenderBuffers::IsEnabled()) - return; - FGLDebug::PushGroup("AmbientOccludeScene"); FGLPostProcessState savedState; @@ -227,20 +224,27 @@ void FGLRenderer::AmbientOccludeScene() RenderScreenQuad(); // Add SSAO back to scene texture: - mBuffers->BindSceneFB(); + mBuffers->BindSceneFB(false); + GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; + glDrawBuffers(1, buffers); glViewport(mSceneViewport.left, mSceneViewport.top, mSceneViewport.width, mSceneViewport.height); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); if (gl_ssao_debug) glBlendFunc(GL_ONE, GL_ZERO); else - glBlendFunc(GL_ZERO, GL_SRC_COLOR); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - mSSAOCombineShader->Bind(); - mSSAOCombineShader->AODepthTexture.Set(0); + mBuffers->BindSceneDataTexture(1); + mSSAOCombineShader->Bind(multisample); + mSSAOCombineShader->AODepthTexture[multisample].Set(0); + mSSAOCombineShader->SceneDataTexture[multisample].Set(1); + if (multisample) mSSAOCombineShader->SampleCount[multisample].Set(gl_multisample); + mSSAOCombineShader->Scale[multisample].Set(mBuffers->AmbientWidth * 2.0f / (float)mScreenViewport.width, mBuffers->AmbientHeight * 2.0f / (float)mScreenViewport.height); + mSSAOCombineShader->Offset[multisample].Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); RenderScreenQuad(); FGLDebug::PopGroup(); diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index b52f2a0b6..54d597c4d 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -82,7 +82,9 @@ FGLRenderBuffers::~FGLRenderBuffers() void FGLRenderBuffers::ClearScene() { DeleteFrameBuffer(mSceneFB); + DeleteFrameBuffer(mSceneDataFB); DeleteTexture(mSceneMultisample); + DeleteTexture(mSceneData); DeleteTexture(mSceneDepthStencil); } @@ -253,13 +255,16 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples) { mSceneMultisample = Create2DMultisampleTexture("SceneMultisample", GL_RGBA16F, width, height, samples, false); mSceneDepthStencil = Create2DMultisampleTexture("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height, samples, false); + mSceneData = Create2DMultisampleTexture("SceneSSAOData", GL_RGBA8, width, height, samples, false); } else { mSceneDepthStencil = Create2DTexture("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height); + mSceneData = Create2DTexture("SceneSSAOData", GL_RGBA8, width, height); } - mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1); + mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], 0, mSceneDepthStencil, samples > 1); + mSceneDataFB = CreateFrameBuffer("SSAOSceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneData, mSceneDepthStencil, samples > 1); } //========================================================================== @@ -512,7 +517,7 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff return handle; } -GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool multisample) +GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer0, GLuint colorbuffer1, GLuint depthstencil, bool multisample) { GLuint handle = 0; glGenFramebuffers(1, &handle); @@ -520,12 +525,16 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); if (multisample) { - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, colorbuffer, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, colorbuffer0, 0); + if (colorbuffer1 != 0) + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D_MULTISAMPLE, colorbuffer1, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D_MULTISAMPLE, depthstencil, 0); } else { - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer0, 0); + if (colorbuffer1 != 0) + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, colorbuffer1, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthstencil, 0); } if (CheckFrameBufferCompleteness()) @@ -668,9 +677,9 @@ void FGLRenderBuffers::BindEyeFB(int eye, bool readBuffer) // //========================================================================== -void FGLRenderBuffers::BindSceneFB() +void FGLRenderBuffers::BindSceneFB(bool sceneData) { - glBindFramebuffer(GL_FRAMEBUFFER, mSceneFB); + glBindFramebuffer(GL_FRAMEBUFFER, sceneData ? mSceneDataFB : mSceneFB); } //========================================================================== @@ -688,6 +697,21 @@ void FGLRenderBuffers::BindSceneColorTexture(int index) glBindTexture(GL_TEXTURE_2D, mPipelineTexture[0]); } +//========================================================================== +// +// Binds the scene data texture to the specified texture unit +// +//========================================================================== + +void FGLRenderBuffers::BindSceneDataTexture(int index) +{ + glActiveTexture(GL_TEXTURE0 + index); + if (mSamples > 1) + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mSceneData); + else + glBindTexture(GL_TEXTURE_2D, mSceneData); +} + //========================================================================== // // Binds the depth texture to the specified texture unit diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 19a2979f2..080593881 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -31,8 +31,9 @@ public: bool Setup(int width, int height, int sceneWidth, int sceneHeight); - void BindSceneFB(); + void BindSceneFB(bool sceneData); void BindSceneColorTexture(int index); + void BindSceneDataTexture(int index); void BindSceneDepthTexture(int index); void BlitSceneToTexture(); @@ -90,7 +91,7 @@ private: GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height); GLuint CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer); - GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool multisample); + GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer0, GLuint colorbuffer1, GLuint depthstencil, bool multisample); bool CheckFrameBufferCompleteness(); void ClearFrameBuffer(bool stencil, bool depth); void DeleteTexture(GLuint &handle); @@ -110,7 +111,9 @@ private: // Buffers for the scene GLuint mSceneMultisample = 0; GLuint mSceneDepthStencil = 0; + GLuint mSceneData = 0; GLuint mSceneFB = 0; + GLuint mSceneDataFB = 0; // Effect/HUD buffers GLuint mPipelineTexture[NumPipelineTextures]; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index db2be0d9d..a02d27852 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -320,7 +320,7 @@ void FGLRenderer::Begin2D() if (mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height)) { if (mDrawingScene2D) - mBuffers->BindSceneFB(); + mBuffers->BindSceneFB(false); else mBuffers->BindCurrentFB(); } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 2659e8ea2..596f2c22b 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -157,7 +157,11 @@ void FGLRenderer::Set3DViewport(bool mainview) { if (mainview && mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height)) { - mBuffers->BindSceneFB(); + mBuffers->BindSceneFB(gl_ssao); + GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; + glDrawBuffers(gl_ssao ? 2 : 1, buffers); + gl_RenderState.SetPassType(gl_ssao ? GBUFFER_PASS : NORMAL_PASS); + gl_RenderState.Apply(); } // Always clear all buffers with scissor test disabled. @@ -490,7 +494,13 @@ void FGLRenderer::DrawScene(int drawmode) RenderScene(recursion); - AmbientOccludeScene(); + bool applySSAO = gl_ssao && FGLRenderBuffers::IsEnabled() && drawmode != DM_PORTAL; + if (applySSAO) + { + AmbientOccludeScene(); + gl_RenderState.SetPassType(GBUFFER_PASS); + gl_RenderState.Apply(); + } // Handle all portals after rendering the opaque objects but before // doing all translucent stuff @@ -498,6 +508,15 @@ void FGLRenderer::DrawScene(int drawmode) GLPortal::EndFrame(); recursion--; RenderTranslucent(); + + if (applySSAO) + { + mBuffers->BindSceneFB(true); + GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; + glDrawBuffers(2, buffers); + gl_RenderState.SetPassType(NORMAL_PASS); + gl_RenderState.Apply(); + } } diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index 3fbd03434..4fa5b0e01 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -120,16 +120,21 @@ void FDepthBlurShader::Bind(bool vertical) shader.Bind(); } -void FSSAOCombineShader::Bind() +void FSSAOCombineShader::Bind(bool multisample) { - if (!mShader) + auto &shader = mShader[multisample]; + if (!shader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); - mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssaocombine.fp", "", 330); - mShader.SetFragDataLocation(0, "FragColor"); - mShader.Link("shaders/glsl/ssaocombine"); - mShader.SetAttribLocation(0, "PositionInProjection"); - AODepthTexture.Init(mShader, "AODepthTexture"); + shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + shader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssaocombine.fp", multisample ? "#define MULTISAMPLE\n" : "", 330); + shader.SetFragDataLocation(0, "FragColor"); + shader.Link("shaders/glsl/ssaocombine"); + shader.SetAttribLocation(0, "PositionInProjection"); + AODepthTexture[multisample].Init(shader, "AODepthTexture"); + SceneDataTexture[multisample].Init(shader, "SceneDataTexture"); + SampleCount[multisample].Init(shader, "SampleCount"); + Scale[multisample].Init(shader, "Scale"); + Offset[multisample].Init(shader, "Offset"); } - mShader.Bind(); + shader.Bind(); } diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index 9c97791ba..f36b10625 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -59,12 +59,16 @@ private: class FSSAOCombineShader { public: - void Bind(); + void Bind(bool multisample); - FBufferedUniformSampler AODepthTexture; + FBufferedUniformSampler AODepthTexture[2]; + FBufferedUniformSampler SceneDataTexture[2]; + FBufferedUniform1i SampleCount[2]; + FBufferedUniform2f Scale[2]; + FBufferedUniform2f Offset[2]; private: - FShaderProgram mShader; + FShaderProgram mShader[2]; }; #endif \ No newline at end of file diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index f6dc61472..c1bc5c2fe 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -51,6 +51,12 @@ EXTERN_CVAR(Bool, gl_lens) EXTERN_CVAR(Float, gl_lens_k) EXTERN_CVAR(Float, gl_lens_kcube) EXTERN_CVAR(Float, gl_lens_chromatic) +EXTERN_CVAR(Bool, gl_ssao) +EXTERN_CVAR(Float, gl_ssao_strength) +EXTERN_CVAR(Bool, gl_ssao_debug) +EXTERN_CVAR(Float, gl_ssao_bias) +EXTERN_CVAR(Float, gl_ssao_radius) +EXTERN_CVAR(Float, gl_ssao_blur_amount) EXTERN_CVAR(Int, gl_debug_level) EXTERN_CVAR(Bool, gl_debug_breakpoint) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 0b66f0569..cdd6ffe3f 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -315,6 +315,32 @@ vec4 applyFog(vec4 frag, float fogfactor) return vec4(mix(uFogColor.rgb, frag.rgb, fogfactor), frag.a); } +//=========================================================================== +// +// The color of the fragment if it is fully occluded by ambient lighting +// +//=========================================================================== + +vec3 AmbientOcclusionColor() +{ + float fogdist; + float fogfactor; + + // + // calculate fog factor + // + if (uFogEnabled == -1) + { + fogdist = pixelpos.w; + } + else + { + fogdist = max(16.0, length(pixelpos.xyz)); + } + fogfactor = exp2 (uFogDensity * fogdist); + + return mix(uFogColor.rgb, vec3(0.0), fogfactor); +} //=========================================================================== // @@ -437,7 +463,7 @@ void main() } FragColor = frag; #ifdef GBUFFER_PASS - FragData = vec4(uFogColor.rgb, 1.0); + FragData = vec4(AmbientOcclusionColor(), 1.0); #endif } diff --git a/wadsrc/static/shaders/glsl/ssaocombine.fp b/wadsrc/static/shaders/glsl/ssaocombine.fp index 21fdff102..7cd096276 100644 --- a/wadsrc/static/shaders/glsl/ssaocombine.fp +++ b/wadsrc/static/shaders/glsl/ssaocombine.fp @@ -4,8 +4,35 @@ out vec4 FragColor; uniform sampler2D AODepthTexture; +#if defined(MULTISAMPLE) +uniform sampler2DMS SceneDataTexture; +uniform int SampleCount; +#else +uniform sampler2D SceneDataTexture; +#endif + +uniform vec2 Scale; +uniform vec2 Offset; + void main() { + vec2 uv = Offset + TexCoord * Scale; +#if defined(MULTISAMPLE) + ivec2 texSize = textureSize(SceneDataTexture); +#else + ivec2 texSize = textureSize(SceneDataTexture, 0); +#endif + ivec2 ipos = ivec2(max(floor(uv * vec2(texSize) - 0.75), vec2(0.0))); + +#if defined(MULTISAMPLE) + vec3 fogColor = vec3(0.0); + for (int i = 0; i < SampleCount; i++) + fogColor += texelFetch(SceneDataTexture, ipos, i).rgb; + fogColor /= float(SampleCount); +#else + vec3 fogColor = texelFetch(SceneDataTexture, ipos, 0).rgb; +#endif + float attenutation = texture(AODepthTexture, TexCoord).x; - FragColor = vec4(attenutation, attenutation, attenutation, 0.0); + FragColor = vec4(fogColor, 1.0 - attenutation); } From d9e60644b1e256c6e8bed445e070a3f17598820a Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Wed, 21 Sep 2016 01:08:00 -0400 Subject: [PATCH 0941/1509] Some Linux SDL fixes. Will have to do this for Mac, later, too. --- src/posix/sdl/sdlglvideo.cpp | 4 ++-- src/posix/sdl/sdlglvideo.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index d8c00f236..e581cfde9 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -163,7 +163,7 @@ bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox) return false; } -DFrameBuffer *SDLGLVideo::CreateFrameBuffer (int width, int height, bool fullscreen, DFrameBuffer *old) +DFrameBuffer *SDLGLVideo::CreateFrameBuffer (int width, int height, bool bgra, bool fullscreen, DFrameBuffer *old) { static int retry = 0; static int owidth, oheight; @@ -315,7 +315,7 @@ bool SDLGLVideo::InitHardware (bool allowsoftware, int multisample) // FrameBuffer implementation ----------------------------------------------- SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen) - : DFrameBuffer (width, height) + : DFrameBuffer (width, height, false) { int i; diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h index d8ce9005d..3b84f83c4 100644 --- a/src/posix/sdl/sdlglvideo.h +++ b/src/posix/sdl/sdlglvideo.h @@ -21,7 +21,7 @@ class SDLGLVideo : public IVideo EDisplayType GetDisplayType () { return DISPLAY_Both; } void SetWindowedScale (float scale); - DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old); + DFrameBuffer *CreateFrameBuffer (int width, int height, bool bgra, bool fs, DFrameBuffer *old); void StartModeIterator (int bits, bool fs); bool NextMode (int *width, int *height, bool *letterbox); From 7c862b85b3d9c939ac17031b6d4e1a7aa29bab7e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 22 Sep 2016 03:49:19 +0200 Subject: [PATCH 0942/1509] Don't do ambient occlusion when rendering to texture --- src/gl/scene/gl_scene.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 596f2c22b..8331930bc 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -492,14 +492,29 @@ void FGLRenderer::DrawScene(int drawmode) } GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. - RenderScene(recursion); - - bool applySSAO = gl_ssao && FGLRenderBuffers::IsEnabled() && drawmode != DM_PORTAL; + // If SSAO is active, switch to gbuffer shaders and use the gbuffer framebuffer + bool applySSAO = gl_ssao && FGLRenderBuffers::IsEnabled() && drawmode == DM_MAINVIEW; if (applySSAO) { - AmbientOccludeScene(); + GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; + glDrawBuffers(2, buffers); gl_RenderState.SetPassType(GBUFFER_PASS); gl_RenderState.Apply(); + gl_RenderState.ApplyMatrices(); + } + + RenderScene(recursion); + + // Apply ambient occlusion and switch back to shaders without gbuffer output + if (applySSAO) + { + GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; + glDrawBuffers(1, buffers); + AmbientOccludeScene(); + mBuffers->BindSceneFB(true); + gl_RenderState.SetPassType(NORMAL_PASS); + gl_RenderState.Apply(); + gl_RenderState.ApplyMatrices(); } // Handle all portals after rendering the opaque objects but before @@ -508,15 +523,6 @@ void FGLRenderer::DrawScene(int drawmode) GLPortal::EndFrame(); recursion--; RenderTranslucent(); - - if (applySSAO) - { - mBuffers->BindSceneFB(true); - GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; - glDrawBuffers(2, buffers); - gl_RenderState.SetPassType(NORMAL_PASS); - gl_RenderState.Apply(); - } } From 146b5d2d066e06b255fa0095da1dafe25f0ac695 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Sep 2016 09:06:21 +0200 Subject: [PATCH 0943/1509] - use 'override' qualifier on renderer interface. Bad things can happen if these get changed in ZDoom without adapting to the change so better let the compiler handle this automatically. --- src/gl/scene/gl_scene.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index ccceeac5f..cca452800 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -979,25 +979,25 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei struct FGLInterface : public FRenderer { - bool UsesColormap() const; + bool UsesColormap() const override; void PrecacheTexture(FTexture *tex, int cache); void PrecacheSprite(FTexture *tex, SpriteHits &hits); - void Precache(BYTE *texhitlist, TMap &actorhitlist); - void RenderView(player_t *player); - void WriteSavePic (player_t *player, FILE *file, int width, int height); - void StateChanged(AActor *actor); - void StartSerialize(FArchive &arc); - void EndSerialize(FArchive &arc); - void RenderTextureView (FCanvasTexture *self, AActor *viewpoint, int fov); - sector_t *FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel, bool back); - void SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog); - void PreprocessLevel(); - void CleanLevelData(); - bool RequireGLNodes(); + void Precache(BYTE *texhitlist, TMap &actorhitlist) override; + void RenderView(player_t *player) override; + void WriteSavePic (player_t *player, FILE *file, int width, int height) override; + void StateChanged(AActor *actor) override; + void StartSerialize(FArchive &arc) override; + void EndSerialize(FArchive &arc) override; + void RenderTextureView (FCanvasTexture *self, AActor *viewpoint, int fov) override; + sector_t *FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel, bool back) override; + void SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog) override; + void PreprocessLevel() override; + void CleanLevelData() override; + bool RequireGLNodes() override; - int GetMaxViewPitch(bool down); - void ClearBuffer(int color); - void Init(); + int GetMaxViewPitch(bool down) override; + void ClearBuffer(int color) override; + void Init() override; }; //=========================================================================== From f7b6b1433cf688cefa7a9bd9c05167d04a8e039a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 18 Sep 2016 15:57:22 +0200 Subject: [PATCH 0944/1509] Added exposure pass calculating the bloom/tonemap exposure based on what the eye is seeing --- src/gl/renderer/gl_postprocess.cpp | 90 ++++++++++++++++++- src/gl/renderer/gl_postprocessstate.cpp | 26 +++++- src/gl/renderer/gl_postprocessstate.h | 5 +- src/gl/renderer/gl_renderbuffers.cpp | 66 ++++++++++++-- src/gl/renderer/gl_renderbuffers.h | 22 ++++- src/gl/renderer/gl_renderer.cpp | 9 ++ src/gl/renderer/gl_renderer.h | 8 +- src/gl/scene/gl_scene.cpp | 15 +--- src/gl/shaders/gl_bloomshader.cpp | 2 +- src/gl/shaders/gl_bloomshader.h | 2 +- src/gl/shaders/gl_tonemapshader.cpp | 50 ++++++++++- src/gl/shaders/gl_tonemapshader.h | 41 ++++++++- wadsrc/static/shaders/glsl/bloomextract.fp | 5 +- wadsrc/static/shaders/glsl/exposureaverage.fp | 23 +++++ wadsrc/static/shaders/glsl/exposurecombine.fp | 16 ++++ wadsrc/static/shaders/glsl/exposureextract.fp | 13 +++ wadsrc/static/shaders/glsl/tonemap.fp | 5 +- 17 files changed, 358 insertions(+), 40 deletions(-) create mode 100644 wadsrc/static/shaders/glsl/exposureaverage.fp create mode 100644 wadsrc/static/shaders/glsl/exposurecombine.fp create mode 100644 wadsrc/static/shaders/glsl/exposureextract.fp diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index b6b658a41..1cdad9f9b 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -75,7 +75,10 @@ CUSTOM_CVAR(Float, gl_bloom_amount, 1.4f, 0) if (self < 0.1f) self = 0.1f; } -CVAR(Float, gl_exposure, 0.0f, 0) +CVAR(Float, gl_exposure_scale, 0.75f, 0) +CVAR(Float, gl_exposure_min, 0.35f, 0) +CVAR(Float, gl_exposure_base, 0.35f, 0) +CVAR(Float, gl_exposure_speed, 0.05f, 0) CUSTOM_CVAR(Int, gl_tonemap, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) { @@ -106,6 +109,78 @@ void FGLRenderer::RenderScreenQuad() GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); } +//----------------------------------------------------------------------------- +// +// Extracts light average from the scene and updates the camera exposure texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::UpdateCameraExposure() +{ + if (!gl_bloom && gl_tonemap == 0) + return; + + FGLDebug::PushGroup("UpdateCameraExposure"); + + FGLPostProcessState savedState; + savedState.SaveTextureBinding1(); + + // Extract light level from scene texture: + const auto &level0 = mBuffers->ExposureLevels[0]; + glBindFramebuffer(GL_FRAMEBUFFER, level0.Framebuffer); + glViewport(0, 0, level0.Width, level0.Height); + mBuffers->BindCurrentTexture(0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mExposureExtractShader->Bind(); + mExposureExtractShader->SceneTexture.Set(0); + mExposureExtractShader->Scale.Set(mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height); + mExposureExtractShader->Offset.Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); + RenderScreenQuad(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + // Find the average value: + for (int i = 0; i + 1 < mBuffers->ExposureLevels.Size(); i++) + { + const auto &level = mBuffers->ExposureLevels[i]; + const auto &next = mBuffers->ExposureLevels[i + 1]; + + glBindFramebuffer(GL_FRAMEBUFFER, next.Framebuffer); + glViewport(0, 0, next.Width, next.Height); + glBindTexture(GL_TEXTURE_2D, level.Texture); + mExposureAverageShader->Bind(); + mExposureAverageShader->ExposureTexture.Set(0); + RenderScreenQuad(); + } + + // Combine average value with current camera exposure: + glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->ExposureFB); + glViewport(0, 0, 1, 1); + if (!mBuffers->FirstExposureFrame) + { + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + else + { + mBuffers->FirstExposureFrame = false; + } + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, mBuffers->ExposureLevels.Last().Texture); + mExposureCombineShader->Bind(); + mExposureCombineShader->ExposureTexture.Set(0); + mExposureCombineShader->ExposureBase.Set(gl_exposure_base); + mExposureCombineShader->ExposureMin.Set(gl_exposure_min); + mExposureCombineShader->ExposureScale.Set(gl_exposure_scale); + mExposureCombineShader->ExposureSpeed.Set(gl_exposure_speed); + RenderScreenQuad(); + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + + FGLDebug::PopGroup(); +} + //----------------------------------------------------------------------------- // // Adds bloom contribution to scene texture @@ -121,6 +196,7 @@ void FGLRenderer::BloomScene() FGLDebug::PushGroup("BloomScene"); FGLPostProcessState savedState; + savedState.SaveTextureBinding1(); const float blurAmount = gl_bloom_amount; int sampleCount = gl_bloom_kernel_size; @@ -133,9 +209,12 @@ void FGLRenderer::BloomScene() mBuffers->BindCurrentTexture(0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, mBuffers->ExposureTexture); + glActiveTexture(GL_TEXTURE0); mBloomExtractShader->Bind(); mBloomExtractShader->SceneTexture.Set(0); - mBloomExtractShader->Exposure.Set(mCameraExposure); + mBloomExtractShader->ExposureTexture.Set(1); mBloomExtractShader->Scale.Set(mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height); mBloomExtractShader->Offset.Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); RenderScreenQuad(); @@ -220,7 +299,12 @@ void FGLRenderer::TonemapScene() } else { - mTonemapShader->Exposure.Set(mCameraExposure); + savedState.SaveTextureBinding1(); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, mBuffers->ExposureTexture); + glActiveTexture(GL_TEXTURE0); + + mTonemapShader->ExposureTexture.Set(1); } RenderScreenQuad(); diff --git a/src/gl/renderer/gl_postprocessstate.cpp b/src/gl/renderer/gl_postprocessstate.cpp index 9d995783d..57b7862f5 100644 --- a/src/gl/renderer/gl_postprocessstate.cpp +++ b/src/gl/renderer/gl_postprocessstate.cpp @@ -45,7 +45,7 @@ FGLPostProcessState::FGLPostProcessState() { glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); glActiveTexture(GL_TEXTURE0); - glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding[0]); glBindTexture(GL_TEXTURE_2D, 0); if (gl.flags & RFL_SAMPLER_OBJECTS) { @@ -75,6 +75,15 @@ FGLPostProcessState::FGLPostProcessState() glDisable(GL_BLEND); } +void FGLPostProcessState::SaveTextureBinding1() +{ + glActiveTexture(GL_TEXTURE1); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding[1]); + glBindTexture(GL_TEXTURE_2D, 0); + textureBinding1Saved = true; + glActiveTexture(GL_TEXTURE0); +} + //----------------------------------------------------------------------------- // // Restores state at the end of post processing @@ -108,6 +117,12 @@ FGLPostProcessState::~FGLPostProcessState() glUseProgram(currentProgram); + if (textureBinding1Saved) + { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, 0); + } + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); if (gl.flags & RFL_SAMPLER_OBJECTS) @@ -115,6 +130,13 @@ FGLPostProcessState::~FGLPostProcessState() glBindSampler(0, samplerBinding[0]); glBindSampler(1, samplerBinding[1]); } - glBindTexture(GL_TEXTURE_2D, textureBinding); + glBindTexture(GL_TEXTURE_2D, textureBinding[0]); + + if (textureBinding1Saved) + { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, textureBinding[1]); + } + glActiveTexture(activeTex); } diff --git a/src/gl/renderer/gl_postprocessstate.h b/src/gl/renderer/gl_postprocessstate.h index 4f2ca81a1..bf53aa7de 100644 --- a/src/gl/renderer/gl_postprocessstate.h +++ b/src/gl/renderer/gl_postprocessstate.h @@ -14,12 +14,14 @@ public: FGLPostProcessState(); ~FGLPostProcessState(); + void SaveTextureBinding1(); + private: FGLPostProcessState(const FGLPostProcessState &) = delete; FGLPostProcessState &operator=(const FGLPostProcessState &) = delete; GLint activeTex; - GLint textureBinding; + GLint textureBinding[2]; GLint samplerBinding[2]; GLboolean blendEnabled; GLboolean scissorEnabled; @@ -32,6 +34,7 @@ private: GLint blendSrcAlpha; GLint blendDestRgb; GLint blendDestAlpha; + bool textureBinding1Saved = false; }; #endif diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 4383d706e..b2471e4b9 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -74,6 +74,7 @@ FGLRenderBuffers::~FGLRenderBuffers() ClearPipeline(); ClearEyeBuffers(); ClearBloom(); + ClearExposureLevels(); } void FGLRenderBuffers::ClearScene() @@ -107,6 +108,18 @@ void FGLRenderBuffers::ClearBloom() } } +void FGLRenderBuffers::ClearExposureLevels() +{ + for (auto &level : ExposureLevels) + { + DeleteTexture(level.Texture); + DeleteFrameBuffer(level.Framebuffer); + } + ExposureLevels.Clear(); + DeleteTexture(ExposureTexture); + DeleteFrameBuffer(ExposureFB); +} + void FGLRenderBuffers::ClearEyeBuffers() { for (auto handle : mEyeFBs) @@ -186,11 +199,12 @@ bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei } // Bloom bluring buffers need to match the scene to avoid bloom bleeding artifacts - if (mBloomWidth != sceneWidth || mBloomHeight != sceneHeight) + if (mSceneWidth != sceneWidth || mSceneHeight != sceneHeight) { CreateBloom(sceneWidth, sceneHeight); - mBloomWidth = sceneWidth; - mBloomHeight = sceneHeight; + CreateExposureLevels(sceneWidth, sceneHeight); + mSceneWidth = sceneWidth; + mSceneHeight = sceneHeight; } glBindTexture(GL_TEXTURE_2D, textureBinding); @@ -204,11 +218,12 @@ bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei ClearPipeline(); ClearEyeBuffers(); ClearBloom(); + ClearExposureLevels(); mWidth = 0; mHeight = 0; mSamples = 0; - mBloomWidth = 0; - mBloomHeight = 0; + mSceneWidth = 0; + mSceneHeight = 0; } return !FailedCreate; @@ -281,6 +296,41 @@ void FGLRenderBuffers::CreateBloom(int width, int height) } } +//========================================================================== +// +// Creates camera exposure level buffers +// +//========================================================================== + +void FGLRenderBuffers::CreateExposureLevels(int width, int height) +{ + ClearExposureLevels(); + + int i = 0; + do + { + width = MAX(width / 2, 1); + height = MAX(height / 2, 1); + + FString textureName, fbName; + textureName.Format("Exposure.Texture%d", i); + fbName.Format("Exposure.Framebuffer%d", i); + i++; + + FGLExposureTextureLevel level; + level.Width = width; + level.Height = height; + level.Texture = Create2DTexture(textureName, GL_R32F, level.Width, level.Height); + level.Framebuffer = CreateFrameBuffer(fbName, level.Texture); + ExposureLevels.Push(level); + } while (width > 1 || height > 1); + + ExposureTexture = Create2DTexture("Exposure.CameraTexture", GL_R32F, 1, 1); + ExposureFB = CreateFrameBuffer("Exposure.CameraFB", ExposureTexture); + + FirstExposureFrame = true; +} + //========================================================================== // // Creates eye buffers if needed @@ -316,14 +366,14 @@ void FGLRenderBuffers::CreateEyeBuffers(int eye) // //========================================================================== -GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height) +GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height, const void *data) { - GLuint type = (format == GL_RGBA16F) ? GL_FLOAT : GL_UNSIGNED_BYTE; + GLuint type = (format == GL_RGBA16F || format == GL_R32F) ? GL_FLOAT : GL_UNSIGNED_BYTE; GLuint handle = 0; glGenTextures(1, &handle); glBindTexture(GL_TEXTURE_2D, handle); FGLDebug::LabelObject(GL_TEXTURE, handle, name); - glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, GL_RGBA, type, nullptr); + glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format != GL_R32F ? GL_RGBA : GL_RED, type, data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 08731e39f..4477718f4 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -14,6 +14,15 @@ public: GLuint Height = 0; }; +class FGLExposureTextureLevel +{ +public: + GLuint Texture = 0; + GLuint Framebuffer = 0; + GLuint Width = 0; + GLuint Height = 0; +}; + class FGLRenderBuffers { public: @@ -39,6 +48,11 @@ public: enum { NumBloomLevels = 4 }; FGLBloomTextureLevel BloomLevels[NumBloomLevels]; + TArray ExposureLevels; + GLuint ExposureTexture = 0; + GLuint ExposureFB = 0; + bool FirstExposureFrame = true; + static bool IsEnabled(); int GetWidth() const { return mWidth; } @@ -49,11 +63,13 @@ private: void ClearPipeline(); void ClearEyeBuffers(); void ClearBloom(); + void ClearExposureLevels(); void CreateScene(int width, int height, int samples); void CreatePipeline(int width, int height); void CreateBloom(int width, int height); + void CreateExposureLevels(int width, int height); void CreateEyeBuffers(int eye); - GLuint Create2DTexture(const FString &name, GLuint format, int width, int height); + GLuint Create2DTexture(const FString &name, GLuint format, int width, int height, const void *data = nullptr); GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height); GLuint CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer); @@ -69,8 +85,8 @@ private: int mHeight = 0; int mSamples = 0; int mMaxSamples = 0; - int mBloomWidth = 0; - int mBloomHeight = 0; + int mSceneWidth = 0; + int mSceneHeight = 0; static const int NumPipelineTextures = 2; int mCurrentPipelineTexture = 0; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 4b59ad1a9..ab0e658e7 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -104,6 +104,9 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mPresentShader = nullptr; mBloomExtractShader = nullptr; mBloomCombineShader = nullptr; + mExposureExtractShader = nullptr; + mExposureAverageShader = nullptr; + mExposureCombineShader = nullptr; mBlurShader = nullptr; mTonemapShader = nullptr; mTonemapPalette = nullptr; @@ -119,6 +122,9 @@ void FGLRenderer::Initialize(int width, int height) mBuffers = new FGLRenderBuffers(); mBloomExtractShader = new FBloomExtractShader(); mBloomCombineShader = new FBloomCombineShader(); + mExposureExtractShader = new FExposureExtractShader(); + mExposureAverageShader = new FExposureAverageShader(); + mExposureCombineShader = new FExposureCombineShader(); mBlurShader = new FBlurShader(); mTonemapShader = new FTonemapShader(); mColormapShader = new FColormapShader(); @@ -179,6 +185,9 @@ FGLRenderer::~FGLRenderer() if (mPresentShader) delete mPresentShader; if (mBloomExtractShader) delete mBloomExtractShader; if (mBloomCombineShader) delete mBloomCombineShader; + if (mExposureExtractShader) delete mExposureExtractShader; + if (mExposureAverageShader) delete mExposureAverageShader; + if (mExposureCombineShader) delete mExposureCombineShader; if (mBlurShader) delete mBlurShader; if (mTonemapShader) delete mTonemapShader; if (mTonemapPalette) delete mTonemapPalette; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 162fb6dcf..b95408521 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -21,6 +21,9 @@ class DPSprite; class FGLRenderBuffers; class FBloomExtractShader; class FBloomCombineShader; +class FExposureExtractShader; +class FExposureAverageShader; +class FExposureCombineShader; class FBlurShader; class FTonemapShader; class FColormapShader; @@ -92,6 +95,9 @@ public: FGLRenderBuffers *mBuffers; FBloomExtractShader *mBloomExtractShader; FBloomCombineShader *mBloomCombineShader; + FExposureExtractShader *mExposureExtractShader; + FExposureAverageShader *mExposureAverageShader; + FExposureCombineShader *mExposureCombineShader; FBlurShader *mBlurShader; FTonemapShader *mTonemapShader; FColormapShader *mColormapShader; @@ -118,7 +124,6 @@ public: GL_IRECT mSceneViewport; GL_IRECT mOutputLetterbox; bool mDrawingScene2D = false; - float mCameraExposure = 1.0f; float mSceneClearColor[3]; @@ -166,6 +171,7 @@ public: void SetFixedColormap (player_t *player); void WriteSavePic (player_t *player, FILE *file, int width, int height); void EndDrawScene(sector_t * viewsector); + void UpdateCameraExposure(); void BloomScene(); void TonemapScene(); void ColormapScene(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index cca452800..7c04ce77a 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -790,20 +790,6 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo mViewActor=camera; } - if (toscreen) - { - if (gl_exposure == 0.0f) - { - float light = viewsector->lightlevel / 255.0f; - float exposure = MAX(1.0f + (1.0f - light * light) * 0.9f, 0.5f); - mCameraExposure = mCameraExposure * 0.995f + exposure * 0.005f; - } - else - { - mCameraExposure = gl_exposure; - } - } - // 'viewsector' will not survive the rendering so it cannot be used anymore below. lviewsector = viewsector; @@ -839,6 +825,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo if (mainview && FGLRenderBuffers::IsEnabled()) { mBuffers->BlitSceneToTexture(); + UpdateCameraExposure(); BloomScene(); TonemapScene(); ColormapScene(); diff --git a/src/gl/shaders/gl_bloomshader.cpp b/src/gl/shaders/gl_bloomshader.cpp index a16c9ed1e..44253ae79 100644 --- a/src/gl/shaders/gl_bloomshader.cpp +++ b/src/gl/shaders/gl_bloomshader.cpp @@ -46,7 +46,7 @@ void FBloomExtractShader::Bind() mShader.Link("shaders/glsl/bloomextract"); mShader.SetAttribLocation(0, "PositionInProjection"); SceneTexture.Init(mShader, "SceneTexture"); - Exposure.Init(mShader, "ExposureAdjustment"); + ExposureTexture.Init(mShader, "ExposureTexture"); Scale.Init(mShader, "Scale"); Offset.Init(mShader, "Offset"); } diff --git a/src/gl/shaders/gl_bloomshader.h b/src/gl/shaders/gl_bloomshader.h index b20277a42..8b34bb479 100644 --- a/src/gl/shaders/gl_bloomshader.h +++ b/src/gl/shaders/gl_bloomshader.h @@ -9,7 +9,7 @@ public: void Bind(); FBufferedUniformSampler SceneTexture; - FBufferedUniform1f Exposure; + FBufferedUniformSampler ExposureTexture; FBufferedUniform2f Scale; FBufferedUniform2f Offset; diff --git a/src/gl/shaders/gl_tonemapshader.cpp b/src/gl/shaders/gl_tonemapshader.cpp index 144981b18..3db6db8ba 100644 --- a/src/gl/shaders/gl_tonemapshader.cpp +++ b/src/gl/shaders/gl_tonemapshader.cpp @@ -47,7 +47,7 @@ void FTonemapShader::Bind() shader.Link("shaders/glsl/tonemap"); shader.SetAttribLocation(0, "PositionInProjection"); SceneTexture.Init(shader, "InputTexture"); - Exposure.Init(shader, "ExposureAdjustment"); + ExposureTexture.Init(shader, "ExposureTexture"); PaletteLUT.Init(shader, "PaletteLUT"); } shader.Bind(); @@ -70,3 +70,51 @@ const char *FTonemapShader::GetDefines(int mode) case Palette: return "#define PALETTE\n"; } } + +void FExposureExtractShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/exposureextract.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/exposureextract"); + mShader.SetAttribLocation(0, "PositionInProjection"); + SceneTexture.Init(mShader, "SceneTexture"); + Scale.Init(mShader, "Scale"); + Offset.Init(mShader, "Offset"); + } + mShader.Bind(); +} + +void FExposureAverageShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 400); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/exposureaverage.fp", "", 400); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/exposureaverage"); + mShader.SetAttribLocation(0, "PositionInProjection"); + ExposureTexture.Init(mShader, "ExposureTexture"); + } + mShader.Bind(); +} + +void FExposureCombineShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/exposurecombine.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/exposurecombine"); + mShader.SetAttribLocation(0, "PositionInProjection"); + ExposureTexture.Init(mShader, "ExposureTexture"); + ExposureBase.Init(mShader, "ExposureBase"); + ExposureMin.Init(mShader, "ExposureMin"); + ExposureScale.Init(mShader, "ExposureScale"); + ExposureSpeed.Init(mShader, "ExposureSpeed"); + } + mShader.Bind(); +} \ No newline at end of file diff --git a/src/gl/shaders/gl_tonemapshader.h b/src/gl/shaders/gl_tonemapshader.h index 7ec24117b..b4cd102de 100644 --- a/src/gl/shaders/gl_tonemapshader.h +++ b/src/gl/shaders/gl_tonemapshader.h @@ -9,7 +9,7 @@ public: void Bind(); FBufferedUniformSampler SceneTexture; - FBufferedUniform1f Exposure; + FBufferedUniformSampler ExposureTexture; FBufferedUniformSampler PaletteLUT; static bool IsPaletteMode(); @@ -31,4 +31,43 @@ private: FShaderProgram mShader[NumTonemapModes]; }; +class FExposureExtractShader +{ +public: + void Bind(); + + FBufferedUniformSampler SceneTexture; + FBufferedUniform2f Scale; + FBufferedUniform2f Offset; + +private: + FShaderProgram mShader; +}; + +class FExposureAverageShader +{ +public: + void Bind(); + + FBufferedUniformSampler ExposureTexture; + +private: + FShaderProgram mShader; +}; + +class FExposureCombineShader +{ +public: + void Bind(); + + FBufferedUniformSampler ExposureTexture; + FBufferedUniform1f ExposureBase; + FBufferedUniform1f ExposureMin; + FBufferedUniform1f ExposureScale; + FBufferedUniform1f ExposureSpeed; + +private: + FShaderProgram mShader; +}; + #endif \ No newline at end of file diff --git a/wadsrc/static/shaders/glsl/bloomextract.fp b/wadsrc/static/shaders/glsl/bloomextract.fp index bc94c3c0e..9c5aa0bea 100644 --- a/wadsrc/static/shaders/glsl/bloomextract.fp +++ b/wadsrc/static/shaders/glsl/bloomextract.fp @@ -3,12 +3,13 @@ in vec2 TexCoord; out vec4 FragColor; uniform sampler2D SceneTexture; -uniform float ExposureAdjustment; +uniform sampler2D ExposureTexture; uniform vec2 Scale; uniform vec2 Offset; void main() { + float exposureAdjustment = texture(ExposureTexture, vec2(0.5)).x; vec4 color = texture(SceneTexture, Offset + TexCoord * Scale); - FragColor = max(vec4(color.rgb * ExposureAdjustment - 1, 1), vec4(0)); + FragColor = max(vec4((color.rgb + vec3(0.001)) * exposureAdjustment - 1, 1), vec4(0)); } diff --git a/wadsrc/static/shaders/glsl/exposureaverage.fp b/wadsrc/static/shaders/glsl/exposureaverage.fp new file mode 100644 index 000000000..41c0909d2 --- /dev/null +++ b/wadsrc/static/shaders/glsl/exposureaverage.fp @@ -0,0 +1,23 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D ExposureTexture; + +void main() +{ +#if __VERSION__ < 400 + ivec2 size = textureSize(ExposureTexture, 0); + ivec2 tl = max(ivec2(TexCoord * vec2(size) - 0.5), ivec2(0)); + ivec2 br = min(tl + ivec2(1), size - ivec2(1)); + vec4 values = vec4( + texelFetch(ExposureTexture, tl, 0).x, + texelFetch(ExposureTexture, ivec2(tl.x, br.y), 0).x, + texelFetch(ExposureTexture, ivec2(br.x, tl.y), 0).x, + texelFetch(ExposureTexture, br, 0).x); +#else + vec4 values = textureGather(ExposureTexture, TexCoord); +#endif + + FragColor = vec4((values.x + values.y + values.z + values.w) * 0.25, 0.0, 0.0, 1.0); +} diff --git a/wadsrc/static/shaders/glsl/exposurecombine.fp b/wadsrc/static/shaders/glsl/exposurecombine.fp new file mode 100644 index 000000000..f806f8f86 --- /dev/null +++ b/wadsrc/static/shaders/glsl/exposurecombine.fp @@ -0,0 +1,16 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D ExposureTexture; +uniform float ExposureBase; +uniform float ExposureMin; +uniform float ExposureScale; +uniform float ExposureSpeed; + +void main() +{ + float light = texture(ExposureTexture, TexCoord).x; + float exposureAdjustment = 1.0 / max(ExposureBase + light * ExposureScale, ExposureMin); + FragColor = vec4(exposureAdjustment, 0.0, 0.0, ExposureSpeed); +} diff --git a/wadsrc/static/shaders/glsl/exposureextract.fp b/wadsrc/static/shaders/glsl/exposureextract.fp new file mode 100644 index 000000000..f673bf029 --- /dev/null +++ b/wadsrc/static/shaders/glsl/exposureextract.fp @@ -0,0 +1,13 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D SceneTexture; +uniform vec2 Scale; +uniform vec2 Offset; + +void main() +{ + vec4 color = texture(SceneTexture, Offset + TexCoord * Scale); + FragColor = vec4(max(max(color.r, color.g), color.b), 0.0, 0.0, 1.0); +} diff --git a/wadsrc/static/shaders/glsl/tonemap.fp b/wadsrc/static/shaders/glsl/tonemap.fp index d6574b295..5cb7cf8bd 100644 --- a/wadsrc/static/shaders/glsl/tonemap.fp +++ b/wadsrc/static/shaders/glsl/tonemap.fp @@ -3,7 +3,7 @@ in vec2 TexCoord; out vec4 FragColor; uniform sampler2D InputTexture; -uniform float ExposureAdjustment; +uniform sampler2D ExposureTexture; vec3 Linear(vec3 c) { @@ -84,7 +84,8 @@ void main() { vec3 color = texture(InputTexture, TexCoord).rgb; #ifndef PALETTE - color = color * ExposureAdjustment; + float exposureAdjustment = texture(ExposureTexture, vec2(0.5)).x; + color = color * exposureAdjustment; color = Linear(color); // needed because gzdoom's scene texture is not linear at the moment #endif FragColor = vec4(Tonemap(color), 1.0); From af699dcebccb8205eea6b17a9d3b6ed21d4036b0 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 18 Sep 2016 19:31:09 +0200 Subject: [PATCH 0945/1509] Make bloom/exposure less aggressive --- src/gl/renderer/gl_postprocess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 1cdad9f9b..7ce8be0ad 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -75,7 +75,7 @@ CUSTOM_CVAR(Float, gl_bloom_amount, 1.4f, 0) if (self < 0.1f) self = 0.1f; } -CVAR(Float, gl_exposure_scale, 0.75f, 0) +CVAR(Float, gl_exposure_scale, 1.3f, 0) CVAR(Float, gl_exposure_min, 0.35f, 0) CVAR(Float, gl_exposure_base, 0.35f, 0) CVAR(Float, gl_exposure_speed, 0.05f, 0) From 72491049e0b371dff959e567ac88ca6dc733c2c7 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Wed, 21 Sep 2016 15:08:53 -0400 Subject: [PATCH 0946/1509] Changes to the contrast/brightness/gamma formula for both hardware and shader gamma correction. Mainly makes a correction with the shader version where contrast/brightness being negative values would clip them inappropriately. --- src/gl/system/gl_framebuffer.cpp | 2 +- wadsrc/static/shaders/glsl/present.fp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 07d8abaef..1ca2f7edd 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -250,8 +250,8 @@ void OpenGLFrameBuffer::DoSetGamma() for (int i = 0; i < 256; i++) { double val = i * contrast - (contrast - 1) * 127; - if(gamma != 1) val = pow(val, invgamma) / norm; val += bright * 128; + if(gamma != 1) val = pow(val, invgamma) / norm; gammaTable[i] = gammaTable[i + 256] = gammaTable[i + 512] = (WORD)clamp(val*256, 0, 0xffff); } diff --git a/wadsrc/static/shaders/glsl/present.fp b/wadsrc/static/shaders/glsl/present.fp index 53fc007b6..4f5c7cffa 100644 --- a/wadsrc/static/shaders/glsl/present.fp +++ b/wadsrc/static/shaders/glsl/present.fp @@ -9,9 +9,9 @@ uniform float Brightness; vec4 ApplyGamma(vec4 c) { - vec3 val = max(c.rgb * Contrast - (Contrast - 1.0) * 0.5, vec3(0.0)); - val = pow(val, vec3(InvGamma)); + vec3 val = c.rgb * Contrast - (Contrast - 1.0) * 0.5; val += Brightness * 0.5; + val = pow(val, vec3(InvGamma)); return vec4(val, c.a); } From 2339b18b0140005d3d5cbac46cc47004764f732d Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Wed, 21 Sep 2016 15:13:10 -0400 Subject: [PATCH 0947/1509] Quick fix: prevents negative values being passed to pow. --- wadsrc/static/shaders/glsl/present.fp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/shaders/glsl/present.fp b/wadsrc/static/shaders/glsl/present.fp index 4f5c7cffa..31c1217cb 100644 --- a/wadsrc/static/shaders/glsl/present.fp +++ b/wadsrc/static/shaders/glsl/present.fp @@ -11,7 +11,7 @@ vec4 ApplyGamma(vec4 c) { vec3 val = c.rgb * Contrast - (Contrast - 1.0) * 0.5; val += Brightness * 0.5; - val = pow(val, vec3(InvGamma)); + val = pow(max(val, vec3(0.0)), vec3(InvGamma)); return vec4(val, c.a); } From 9a257ac158617be196713d0f4b3d9f2b919ce6f3 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 10 Sep 2016 15:34:15 -0400 Subject: [PATCH 0948/1509] Implement side-by-side narrow 3D mode. --- src/CMakeLists.txt | 1 + src/gl/stereo3d/gl_sidebyside3d.cpp | 79 +++++++++++++++++++++++++++++ src/gl/stereo3d/gl_sidebyside3d.h | 63 +++++++++++++++++++++++ src/gl/stereo3d/gl_stereo_cvars.cpp | 6 ++- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.z | 1 + 6 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 src/gl/stereo3d/gl_sidebyside3d.cpp create mode 100644 src/gl/stereo3d/gl_sidebyside3d.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6edd616ae..230c3dac9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1115,6 +1115,7 @@ set( FASTMATH_SOURCES gl/stereo3d/scoped_view_shifter.cpp gl/stereo3d/gl_anaglyph.cpp gl/stereo3d/gl_quadstereo.cpp + gl/stereo3d/gl_sidebyside3d.cpp gl/dynlights/gl_dynlight.cpp gl/dynlights/gl_glow.cpp gl/dynlights/gl_dynlight1.cpp diff --git a/src/gl/stereo3d/gl_sidebyside3d.cpp b/src/gl/stereo3d/gl_sidebyside3d.cpp new file mode 100644 index 000000000..f526dce8b --- /dev/null +++ b/src/gl/stereo3d/gl_sidebyside3d.cpp @@ -0,0 +1,79 @@ +/* +** gl_sidebyside3d.cpp +** Color mask based stereoscopic 3D modes for GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + +#include "gl_sidebyside3d.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderbuffers.h" + +namespace s3d { + + +/* static */ +const SideBySideSquished& SideBySideSquished::getInstance(float ipd) +{ + static SideBySideSquished instance(ipd); + return instance; +} + +SideBySideSquished::SideBySideSquished(double ipdMeters) + : leftEye(ipdMeters), rightEye(ipdMeters) +{ + eye_ptrs.Push(&leftEye); + eye_ptrs.Push(&rightEye); +} + +void SideBySideSquished::Present() const +{ + GLRenderer->mBuffers->BindOutputFB(); + GLRenderer->ClearBorders(); + + // Compute screen regions to use for left and right eye views + int leftWidth = GLRenderer->mOutputLetterbox.width/2; + int rightWidth = GLRenderer->mOutputLetterbox.width - leftWidth; + GL_IRECT leftHalfScreen = GLRenderer->mOutputLetterbox; + leftHalfScreen.width = leftWidth; + GL_IRECT rightHalfScreen = GLRenderer->mOutputLetterbox; + rightHalfScreen.width = rightWidth; + rightHalfScreen.left += leftWidth; + + GLRenderer->mBuffers->BindEyeTexture(0, 0); + GLRenderer->DrawPresentTexture(leftHalfScreen, true); + + GLRenderer->mBuffers->BindEyeTexture(1, 0); + GLRenderer->DrawPresentTexture(rightHalfScreen, true); +} + + +} /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_sidebyside3d.h b/src/gl/stereo3d/gl_sidebyside3d.h new file mode 100644 index 000000000..2f2946424 --- /dev/null +++ b/src/gl/stereo3d/gl_sidebyside3d.h @@ -0,0 +1,63 @@ +/* +** gl_sidebyside3d.h +** Color mask based stereoscopic 3D modes for GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + +#ifndef GL_SIDEBYSIDE3D_H_ +#define GL_SIDEBYSIDE3D_H_ + +#include "gl_stereo3d.h" +#include "gl_stereo_leftright.h" +#include "gl/system/gl_system.h" +#include "gl/renderer/gl_renderstate.h" + + +namespace s3d { + +class SideBySideSquished : public Stereo3DMode +{ +public: + static const SideBySideSquished& getInstance(float ipd); + + SideBySideSquished(double ipdMeters); + void Present() const override; +private: + LeftEyePose leftEye; + RightEyePose rightEye; +}; + + +} /* namespace s3d */ + + +#endif /* GL_SIDEBYSIDE3D_H_ */ diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index f904c2a51..cd6336026 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -29,6 +29,7 @@ #include "gl/stereo3d/gl_stereo_leftright.h" #include "gl/stereo3d/gl_anaglyph.h" #include "gl/stereo3d/gl_quadstereo.h" +#include "gl/stereo3d/gl_sidebyside3d.h" #include "gl/system/gl_cvars.h" // Set up 3D-specific console variables: @@ -71,7 +72,10 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() case 2: setCurrentMode(RedCyan::getInstance(vr_ipd)); break; - // TODO: missing indices 3, 4 for not-yet-implemented side-by-side modes, to match values from GZ3Doom + // TODO: missing index 3 for not-yet-implemented side-by-side mode, to match values from GZ3Doom + case 4: + setCurrentMode(SideBySideSquished::getInstance(vr_ipd)); + break; case 5: setCurrentMode(LeftEyeView::getInstance(vr_ipd)); break; diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index e3fbb16ca..4b4013cc7 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2701,6 +2701,7 @@ OPTVAL_REDCYAN = "Red/Cyan"; OPTVAL_AMBERBLUE = "Amber/Blue"; OPTVAL_LEFTEYE = "Left Eye"; OPTVAL_RIGHTEYE = "Right Eye"; +OPTVAL_SBSNARROW = "Side-by-side Narrow"; OPTVAL_QUADBUFFERED = "Quad-buffered"; OPTVAL_UNCHARTED2 = "Uncharted 2"; OPTVAL_HEJLDAWSON = "Hejl Dawson"; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 980cdacc3..28c343c2a 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -167,6 +167,7 @@ OptionValue VRMode 1, "$OPTVAL_GREENMAGENTA" 2, "$OPTVAL_REDCYAN" 9, "$OPTVAL_AMBERBLUE" + 4, "$OPTVAL_SBSNARROW" 5, "$OPTVAL_LEFTEYE" 6, "$OPTVAL_RIGHTEYE" 7, "$OPTVAL_QUADBUFFERED" From 1f79e23d5be7d29d55f0b45977f582dfc3919593 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sun, 11 Sep 2016 13:42:41 -0400 Subject: [PATCH 0949/1509] Implement wide side-by-side mode, using adjusted aspect ratio in projection matrix. Use optimal framebuffer size for side-by-side modes. --- src/gl/renderer/gl_renderer.cpp | 3 ++ src/gl/scene/gl_scene.cpp | 1 - src/gl/stereo3d/gl_sidebyside3d.cpp | 58 ++++++++++++++++++++--------- src/gl/stereo3d/gl_sidebyside3d.h | 37 ++++++++++++++++-- src/gl/stereo3d/gl_stereo3d.h | 2 + src/gl/stereo3d/gl_stereo_cvars.cpp | 8 +++- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.z | 1 + 8 files changed, 87 insertions(+), 24 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index ab0e658e7..42b4a8e1b 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -57,6 +57,7 @@ #include "gl/shaders/gl_colormapshader.h" #include "gl/shaders/gl_lensshader.h" #include "gl/shaders/gl_presentshader.h" +#include "gl/stereo3d/gl_stereo3d.h" #include "gl/textures/gl_texture.h" #include "gl/textures/gl_translate.h" #include "gl/textures/gl_material.h" @@ -273,6 +274,8 @@ void FGLRenderer::SetOutputViewport(GL_IRECT *bounds) mSceneViewport.top += mOutputLetterbox.top; } } + + s3d::Stereo3DMode::getCurrentMode().AdjustViewports(); } //=========================================================================== diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 7c04ce77a..6ddd12a1f 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -801,7 +801,6 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo { const s3d::EyePose * eye = stereo3dMode.getEyePose(eye_ix); eye->SetUp(); - // TODO: stereo specific viewport - needed when implementing side-by-side modes etc. SetOutputViewport(bounds); Set3DViewport(mainview); mDrawingScene2D = true; diff --git a/src/gl/stereo3d/gl_sidebyside3d.cpp b/src/gl/stereo3d/gl_sidebyside3d.cpp index f526dce8b..8a66fc91c 100644 --- a/src/gl/stereo3d/gl_sidebyside3d.cpp +++ b/src/gl/stereo3d/gl_sidebyside3d.cpp @@ -39,6 +39,36 @@ namespace s3d { +void SideBySideBase::Present() const +{ + GLRenderer->mBuffers->BindOutputFB(); + GLRenderer->ClearBorders(); + + // Compute screen regions to use for left and right eye views + int leftWidth = GLRenderer->mOutputLetterbox.width / 2; + int rightWidth = GLRenderer->mOutputLetterbox.width - leftWidth; + GL_IRECT leftHalfScreen = GLRenderer->mOutputLetterbox; + leftHalfScreen.width = leftWidth; + GL_IRECT rightHalfScreen = GLRenderer->mOutputLetterbox; + rightHalfScreen.width = rightWidth; + rightHalfScreen.left += leftWidth; + + GLRenderer->mBuffers->BindEyeTexture(0, 0); + GLRenderer->DrawPresentTexture(leftHalfScreen, true); + + GLRenderer->mBuffers->BindEyeTexture(1, 0); + GLRenderer->DrawPresentTexture(rightHalfScreen, true); +} + +// AdjustViewports() is called from within FLGRenderer::SetOutputViewport(...) +void SideBySideBase::AdjustViewports() const +{ + // Change size of renderbuffer, and align to screen + GLRenderer->mSceneViewport.width /= 2; + GLRenderer->mSceneViewport.left /= 2; + GLRenderer->mScreenViewport.width /= 2; + GLRenderer->mScreenViewport.left /= 2; +} /* static */ const SideBySideSquished& SideBySideSquished::getInstance(float ipd) @@ -54,26 +84,18 @@ SideBySideSquished::SideBySideSquished(double ipdMeters) eye_ptrs.Push(&rightEye); } -void SideBySideSquished::Present() const +/* static */ +const SideBySideFull& SideBySideFull::getInstance(float ipd) { - GLRenderer->mBuffers->BindOutputFB(); - GLRenderer->ClearBorders(); - - // Compute screen regions to use for left and right eye views - int leftWidth = GLRenderer->mOutputLetterbox.width/2; - int rightWidth = GLRenderer->mOutputLetterbox.width - leftWidth; - GL_IRECT leftHalfScreen = GLRenderer->mOutputLetterbox; - leftHalfScreen.width = leftWidth; - GL_IRECT rightHalfScreen = GLRenderer->mOutputLetterbox; - rightHalfScreen.width = rightWidth; - rightHalfScreen.left += leftWidth; - - GLRenderer->mBuffers->BindEyeTexture(0, 0); - GLRenderer->DrawPresentTexture(leftHalfScreen, true); - - GLRenderer->mBuffers->BindEyeTexture(1, 0); - GLRenderer->DrawPresentTexture(rightHalfScreen, true); + static SideBySideFull instance(ipd); + return instance; } +SideBySideFull::SideBySideFull(double ipdMeters) + : leftEye(ipdMeters), rightEye(ipdMeters) +{ + eye_ptrs.Push(&leftEye); + eye_ptrs.Push(&rightEye); +} } /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_sidebyside3d.h b/src/gl/stereo3d/gl_sidebyside3d.h index 2f2946424..c79c0c4b4 100644 --- a/src/gl/stereo3d/gl_sidebyside3d.h +++ b/src/gl/stereo3d/gl_sidebyside3d.h @@ -44,18 +44,49 @@ namespace s3d { -class SideBySideSquished : public Stereo3DMode +class SideBySideBase : public Stereo3DMode +{ +public: + void Present() const override; + virtual void AdjustViewports() const override; +}; + +class SideBySideSquished : public SideBySideBase { public: static const SideBySideSquished& getInstance(float ipd); - SideBySideSquished(double ipdMeters); - void Present() const override; private: LeftEyePose leftEye; RightEyePose rightEye; }; +class SBSFLeftEyePose : public LeftEyePose { +public: + SBSFLeftEyePose(double ipdMeters) : LeftEyePose(ipdMeters) {} + virtual VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio) const override { + return LeftEyePose::GetProjection(fov, 0.5f * aspectRatio, fovRatio); + } +}; + +class SBSFRightEyePose : public RightEyePose { +public: + SBSFRightEyePose(double ipdMeters) : RightEyePose(ipdMeters) {} + virtual VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio) const override { + return RightEyePose::GetProjection(fov, 0.5f * aspectRatio, fovRatio); + } +}; + +class SideBySideFull : public SideBySideBase +{ +public: + static const SideBySideFull& getInstance(float ipd); + SideBySideFull(double ipdMeters); +private: + SBSFLeftEyePose leftEye; + SBSFRightEyePose rightEye; +}; + } /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h index e2a8a1ea6..747bcd0c0 100644 --- a/src/gl/stereo3d/gl_stereo3d.h +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -31,6 +31,7 @@ #include // needed for memcpy on linux, which is needed by VSMatrix copy ctor #include "tarray.h" #include "gl/data/gl_matrix.h" +#include "gl/renderer/gl_renderer.h" /* stereoscopic 3D API */ @@ -78,6 +79,7 @@ public: virtual void TearDown() const {}; virtual bool IsMono() const { return false; } + virtual void AdjustViewports() const {}; virtual void Present() const = 0; protected: diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index cd6336026..0927829fc 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -72,7 +72,9 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() case 2: setCurrentMode(RedCyan::getInstance(vr_ipd)); break; - // TODO: missing index 3 for not-yet-implemented side-by-side mode, to match values from GZ3Doom + case 3: + setCurrentMode(SideBySideFull::getInstance(vr_ipd)); + break; case 4: setCurrentMode(SideBySideSquished::getInstance(vr_ipd)); break; @@ -93,7 +95,9 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() // TODO: 8: Oculus Rift case 9: setCurrentMode(AmberBlue::getInstance(vr_ipd)); - break; case 0: + break; + // TODO: 10: HTC Vive/OpenVR + case 0: default: setCurrentMode(MonoView::getInstance()); break; diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 4b4013cc7..50526a75b 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2701,6 +2701,7 @@ OPTVAL_REDCYAN = "Red/Cyan"; OPTVAL_AMBERBLUE = "Amber/Blue"; OPTVAL_LEFTEYE = "Left Eye"; OPTVAL_RIGHTEYE = "Right Eye"; +OPTVAL_SBSFULL = "Side-by-side Full"; OPTVAL_SBSNARROW = "Side-by-side Narrow"; OPTVAL_QUADBUFFERED = "Quad-buffered"; OPTVAL_UNCHARTED2 = "Uncharted 2"; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 28c343c2a..1ab4f1a6d 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -167,6 +167,7 @@ OptionValue VRMode 1, "$OPTVAL_GREENMAGENTA" 2, "$OPTVAL_REDCYAN" 9, "$OPTVAL_AMBERBLUE" + 3, "$OPTVAL_SBSFULL" 4, "$OPTVAL_SBSNARROW" 5, "$OPTVAL_LEFTEYE" 6, "$OPTVAL_RIGHTEYE" From d10a0309abb56b36eb3e6492ce832525ee8b1307 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sun, 11 Sep 2016 15:02:50 -0400 Subject: [PATCH 0950/1509] Update header comment in gl_sidebyside3d source files --- src/gl/stereo3d/gl_sidebyside3d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/stereo3d/gl_sidebyside3d.cpp b/src/gl/stereo3d/gl_sidebyside3d.cpp index 8a66fc91c..57fc8aac9 100644 --- a/src/gl/stereo3d/gl_sidebyside3d.cpp +++ b/src/gl/stereo3d/gl_sidebyside3d.cpp @@ -1,6 +1,6 @@ /* ** gl_sidebyside3d.cpp -** Color mask based stereoscopic 3D modes for GZDoom +** Mosaic image stereoscopic 3D modes for GZDoom ** **--------------------------------------------------------------------------- ** Copyright 2016 Christopher Bruns From 7b8847c6be41948079570f4ebf6df35082a3579f Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sun, 11 Sep 2016 15:04:06 -0400 Subject: [PATCH 0951/1509] Update comment for other file. --- src/gl/stereo3d/gl_sidebyside3d.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/stereo3d/gl_sidebyside3d.h b/src/gl/stereo3d/gl_sidebyside3d.h index c79c0c4b4..68ce88f6a 100644 --- a/src/gl/stereo3d/gl_sidebyside3d.h +++ b/src/gl/stereo3d/gl_sidebyside3d.h @@ -1,6 +1,6 @@ /* ** gl_sidebyside3d.h -** Color mask based stereoscopic 3D modes for GZDoom +** Mosaic image stereoscopic 3D modes for GZDoom ** **--------------------------------------------------------------------------- ** Copyright 2016 Christopher Bruns From a5c27af59bd902b53fb8d560b17738ecfe674ae1 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Mon, 19 Sep 2016 20:06:52 -0400 Subject: [PATCH 0952/1509] Show weapon at full width in SideBySideFull 3D mode. (cherry picked from commit c42e98c0042937adc05c1f1569d909d58a5b8ffb) --- src/gl/scene/gl_scene.cpp | 5 ++++- src/gl/stereo3d/gl_sidebyside3d.cpp | 10 ++++++++++ src/gl/stereo3d/gl_sidebyside3d.h | 1 + src/gl/stereo3d/gl_stereo3d.h | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 6ddd12a1f..425841333 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -660,6 +660,9 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) framebuffer->Begin2D(false); Reset3DViewport(); + + s3d::Stereo3DMode::getCurrentMode().AdjustPlayerSprites(); + // [BB] Only draw the sprites if we didn't render a HUD model before. if ( renderHUDModel == false ) { @@ -820,7 +823,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo clipper.SafeAddClipRangeRealAngles(ViewAngle.BAMs() + a1, ViewAngle.BAMs() - a1); ProcessScene(toscreen); - if (mainview && toscreen) EndDrawScene(lviewsector); // do not call this for camera textures. + if (mainview && toscreen) EndDrawScene(lviewsector); // do not call this for camera textures. if (mainview && FGLRenderBuffers::IsEnabled()) { mBuffers->BlitSceneToTexture(); diff --git a/src/gl/stereo3d/gl_sidebyside3d.cpp b/src/gl/stereo3d/gl_sidebyside3d.cpp index 57fc8aac9..c6463d2c8 100644 --- a/src/gl/stereo3d/gl_sidebyside3d.cpp +++ b/src/gl/stereo3d/gl_sidebyside3d.cpp @@ -98,4 +98,14 @@ SideBySideFull::SideBySideFull(double ipdMeters) eye_ptrs.Push(&rightEye); } +/* virtual */ +void SideBySideFull::AdjustPlayerSprites() const /* override */ +{ + // Show weapon at double width, so it would appear normal width after rescaling + int w = GLRenderer->mScreenViewport.width; + int h = GLRenderer->mScreenViewport.height; + gl_RenderState.mProjectionMatrix.ortho(w/2, w + w/2, h, 0, -1.0f, 1.0f); + gl_RenderState.ApplyMatrices(); +} + } /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_sidebyside3d.h b/src/gl/stereo3d/gl_sidebyside3d.h index 68ce88f6a..374f255c5 100644 --- a/src/gl/stereo3d/gl_sidebyside3d.h +++ b/src/gl/stereo3d/gl_sidebyside3d.h @@ -82,6 +82,7 @@ class SideBySideFull : public SideBySideBase public: static const SideBySideFull& getInstance(float ipd); SideBySideFull(double ipdMeters); + virtual void AdjustPlayerSprites() const override; private: SBSFLeftEyePose leftEye; SBSFRightEyePose rightEye; diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h index 747bcd0c0..c55154e51 100644 --- a/src/gl/stereo3d/gl_stereo3d.h +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -58,6 +58,7 @@ public: virtual void GetViewShift(float yaw, float outViewShift[3]) const; virtual void SetUp() const {}; virtual void TearDown() const {}; + // virtual void EndDrawScene(sector_t * viewsector) const {GLRenderer->EndDrawScene(viewsector);}; }; @@ -80,6 +81,7 @@ public: virtual bool IsMono() const { return false; } virtual void AdjustViewports() const {}; + virtual void AdjustPlayerSprites() const {}; virtual void Present() const = 0; protected: From a1cbd39f3f61964e03253514a80662dfdf7fcda3 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Mon, 19 Sep 2016 21:21:20 -0400 Subject: [PATCH 0953/1509] Move call to Stereo3DMode.AdjustPlayerSprites into FGLRenderer.DrawPlayerSprites() (cherry picked from commit 5b5598d7d85c6bb8930e874d5d94cca835061bf0) --- src/gl/scene/gl_scene.cpp | 2 -- src/gl/scene/gl_weapon.cpp | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 425841333..246057ad2 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -661,8 +661,6 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) Reset3DViewport(); - s3d::Stereo3DMode::getCurrentMode().AdjustPlayerSprites(); - // [BB] Only draw the sprites if we didn't render a HUD model before. if ( renderHUDModel == false ) { diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index d8400aaf6..cfa5c05d7 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -46,6 +46,7 @@ #include "gl/shaders/gl_shader.h" #include "gl/textures/gl_material.h" #include "gl/renderer/gl_quaddrawer.h" +#include "gl/stereo3d/gl_stereo3d.h" EXTERN_CVAR (Bool, r_drawplayersprites) EXTERN_CVAR(Float, transsouls) @@ -198,6 +199,8 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) AActor * playermo=players[consoleplayer].camera; player_t * player=playermo->player; + s3d::Stereo3DMode::getCurrentMode().AdjustPlayerSprites(); + // this is the same as the software renderer if (!player || !r_drawplayersprites || From 2e8d2ed62681316389e226e71fd3c8b85d53fbd5 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Tue, 20 Sep 2016 18:14:14 -0400 Subject: [PATCH 0954/1509] Implement vr_swap_eyes CVAR, now that side-by-side mode is mostly working. --- src/gl/stereo3d/gl_stereo3d.h | 1 - src/gl/stereo3d/gl_stereo_cvars.cpp | 3 +++ src/gl/stereo3d/gl_stereo_leftright.cpp | 11 ++++++++--- src/gl/stereo3d/gl_stereo_leftright.h | 11 +++++++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h index c55154e51..81a72874f 100644 --- a/src/gl/stereo3d/gl_stereo3d.h +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -58,7 +58,6 @@ public: virtual void GetViewShift(float yaw, float outViewShift[3]) const; virtual void SetUp() const {}; virtual void TearDown() const {}; - // virtual void EndDrawScene(sector_t * viewsector) const {GLRenderer->EndDrawScene(viewsector);}; }; diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index 0927829fc..c09a7a974 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -35,6 +35,9 @@ // Set up 3D-specific console variables: CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG) +// switch left and right eye views +CVAR(Bool, vr_swap_eyes, false, CVAR_GLOBALCONFIG) + // For broadest GL compatibility, require user to explicitly enable quad-buffered stereo mode. // Setting vr_enable_quadbuffered_stereo does not automatically invoke quad-buffered stereo, // but makes it possible for subsequent "vr_mode 7" to invoke quad-buffered stereo diff --git a/src/gl/stereo3d/gl_stereo_leftright.cpp b/src/gl/stereo3d/gl_stereo_leftright.cpp index 1919e320f..f2b1ba3fc 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.cpp +++ b/src/gl/stereo3d/gl_stereo_leftright.cpp @@ -37,6 +37,7 @@ EXTERN_CVAR(Float, vr_screendist) EXTERN_CVAR(Float, vr_hunits_per_meter) +EXTERN_CVAR(Bool, vr_swap_eyes) namespace s3d { @@ -50,7 +51,7 @@ VSMatrix ShiftedEyePose::GetProjection(float fov, float aspectRatio, float fovRa // For stereo 3D, use asymmetric frustum shift in projection matrix // Q: shouldn't shift vary with roll angle, at least for desktop display? // A: No. (lab) roll is not measured on desktop display (yet) - double frustumShift = zNear * shift / vr_screendist; // meters cancel, leaving doom units + double frustumShift = zNear * getShift() / vr_screendist; // meters cancel, leaving doom units // double frustumShift = 0; // Turning off shift for debugging double fH = zNear * tan(DEG2RAD(fov) / 2) / fovRatio; double fW = fH * aspectRatio; @@ -68,13 +69,17 @@ VSMatrix ShiftedEyePose::GetProjection(float fov, float aspectRatio, float fovRa /* virtual */ void ShiftedEyePose::GetViewShift(float yaw, float outViewShift[3]) const { - float dx = -cos(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; - float dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; + float dx = -cos(DEG2RAD(yaw)) * vr_hunits_per_meter * getShift(); + float dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * getShift(); outViewShift[0] = dx; outViewShift[1] = dy; outViewShift[2] = 0; } +float ShiftedEyePose::getShift() const +{ + return vr_swap_eyes ? -shift : shift; +} /* static */ const LeftEyeView& LeftEyeView::getInstance(float ipd) diff --git a/src/gl/stereo3d/gl_stereo_leftright.h b/src/gl/stereo3d/gl_stereo_leftright.h index 2070ff53a..9fa7b40bc 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.h +++ b/src/gl/stereo3d/gl_stereo_leftright.h @@ -37,11 +37,14 @@ class ShiftedEyePose : public EyePose { public: ShiftedEyePose(float shift) : shift(shift) {}; - float getShift() const { return shift; } - void setShift(float shift) { this->shift = shift; } + float getShift() const; virtual VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio) const; virtual void GetViewShift(float yaw, float outViewShift[3]) const; + protected: + void setShift(float shift) { this->shift = shift; } + +private: float shift; }; @@ -50,7 +53,7 @@ class LeftEyePose : public ShiftedEyePose { public: LeftEyePose(float ipd) : ShiftedEyePose( float(-0.5) * ipd) {} - float getIpd() const { return float(-2.0)*getShift(); } + float getIpd() const { return float(fabs(2.0f*getShift())); } void setIpd(float ipd) { setShift(float(-0.5)*ipd); } }; @@ -59,7 +62,7 @@ class RightEyePose : public ShiftedEyePose { public: RightEyePose(float ipd) : ShiftedEyePose(float(+0.5)*ipd) {} - float getIpd() const { return float(+2.0)*shift; } + float getIpd() const { return float(fabs(2.0f*getShift())); } void setIpd(float ipd) { setShift(float(+0.5)*ipd); } }; From 0a98fb0be7c9f0ee64b798cbe0a27b83de096703 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Sep 2016 09:32:04 +0200 Subject: [PATCH 0955/1509] - integrated dynamic light definitions into regular DECORATE as another include. - renamed menudef.z zo menudef.zz. This was done because some tool out there stupidly assume that *.z is some sort of archive and refuse to operate on these files (shame on you, Beyond Compare!) --- wadsrc/static/{decorate.z => actors/shared/dynlights.txt} | 0 wadsrc/static/decorate.txt | 1 + wadsrc/static/{menudef.z => menudef.zz} | 0 3 files changed, 1 insertion(+) rename wadsrc/static/{decorate.z => actors/shared/dynlights.txt} (100%) rename wadsrc/static/{menudef.z => menudef.zz} (100%) diff --git a/wadsrc/static/decorate.z b/wadsrc/static/actors/shared/dynlights.txt similarity index 100% rename from wadsrc/static/decorate.z rename to wadsrc/static/actors/shared/dynlights.txt diff --git a/wadsrc/static/decorate.txt b/wadsrc/static/decorate.txt index c6a205d42..71c7d549b 100644 --- a/wadsrc/static/decorate.txt +++ b/wadsrc/static/decorate.txt @@ -30,6 +30,7 @@ #include "actors/shared/action.txt" #include "actors/shared/dog.txt" #include "actors/shared/damagetypes.txt" +#include "actors/shared/dynlights.txt" #include "actors/doom/doomplayer.txt" #include "actors/doom/possessed.txt" diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.zz similarity index 100% rename from wadsrc/static/menudef.z rename to wadsrc/static/menudef.zz From 52d4c3970e3241a60a61dc5c304f8f425d14d9e2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Sep 2016 10:00:40 +0200 Subject: [PATCH 0956/1509] - use glPOlygonOffset on non-translucent flat and wall sprites to avoid z-fighting. --- src/gl/scene/gl_sprite.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 720df3b2b..123bf258c 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -310,6 +310,11 @@ void GLSprite::Draw(int pass) additivefog = true; } } + else if (modelframe == nullptr) + { + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); + } if (RenderStyle.BlendOp!=STYLEOP_Shadow) { if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap && !fullbright) @@ -440,6 +445,11 @@ void GLSprite::Draw(int pass) gl_RenderState.BlendEquation(GL_FUNC_ADD); gl_RenderState.SetTextureMode(TM_MODULATE); } + else if (modelframe == nullptr) + { + glPolygonOffset(0.0f, 0.0f); + glDisable(GL_POLYGON_OFFSET_FILL); + } gl_RenderState.SetObjectColor(0xffffffff); gl_RenderState.EnableTexture(true); From 960ed5130c5b48d4708296ef5b86194417c9b5f8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Sep 2016 10:20:36 +0200 Subject: [PATCH 0957/1509] - fixed: DTA_ColorOverlay was not properly handled by F2DDrawer. --- src/gl/renderer/gl_2ddrawer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/renderer/gl_2ddrawer.cpp b/src/gl/renderer/gl_2ddrawer.cpp index 082e51ca4..ba78634a3 100644 --- a/src/gl/renderer/gl_2ddrawer.cpp +++ b/src/gl/renderer/gl_2ddrawer.cpp @@ -160,6 +160,7 @@ void F2DDrawer::AddTexture(FTexture *img, DrawParms &parms) ptr->Set(x, y + h, 0, u1, v2, color); ptr++; ptr->Set(x + w, y, 0, u2, v1, color); ptr++; ptr->Set(x + w, y + h, 0, u2, v2, color); ptr++; + dg.mVertCount = 8; } AddData(&dg); } From 1bddc277e6e56b18cd4512dbc1365abd6689fb24 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Sep 2016 10:28:14 +0200 Subject: [PATCH 0958/1509] - fixed winding of voxel polygons. --- src/gl/models/gl_voxels.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index d37bdf8a0..6213eb006 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -275,8 +275,8 @@ void FVoxelModel::AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3 mIndices.Push(indx[1]); mIndices.Push(indx[3]); mIndices.Push(indx[1]); - mIndices.Push(indx[3]); mIndices.Push(indx[2]); + mIndices.Push(indx[3]); } //=========================================================================== From 18ee6353fa605c830aba65c1db2f70885e9cd180 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Sep 2016 10:54:16 +0200 Subject: [PATCH 0959/1509] - let's be safe and set the proper texture mode for the fullscreen blend rect. I've got spurious reports that on some occasions it was rendered opaque. --- src/gl/scene/gl_scene.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 246057ad2..528925b7a 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -622,6 +622,7 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) V_AddBlend (player->BlendR, player->BlendG, player->BlendB, player->BlendA, blend); } + gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if (blend[3]>0.0f) { From ee2766d00be3dd9309309dde3151668cd39e3c30 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Sep 2016 01:47:44 +0200 Subject: [PATCH 0960/1509] - made adjustments for new savegame code. --- src/gl/dynlights/a_dynlight.cpp | 32 ++++++++++++++++++----------- src/gl/dynlights/gl_dynlight.h | 5 +++-- src/gl/renderer/gl_renderer.h | 2 +- src/gl/scene/gl_scene.cpp | 29 ++++++++++++++------------ src/gl/system/gl_framebuffer.cpp | 1 - src/gl/utility/gl_cycler.cpp | 21 ++++++++++++++----- src/gl/utility/gl_cycler.h | 35 +++++++++++--------------------- src/p_saveg.cpp | 2 ++ 8 files changed, 70 insertions(+), 57 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index fcb945f01..36ef1b948 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -69,6 +69,7 @@ #include "r_utility.h" #include "portal.h" #include "doomstat.h" +#include "serializer.h" #include "gl/renderer/gl_renderer.h" @@ -154,24 +155,31 @@ static FRandom randLight; // // //========================================================================== -void ADynamicLight::Serialize(FArchive &arc) +void ADynamicLight::Serialize(FSerializer &arc) { Super::Serialize (arc); - arc << lightflags << lighttype; - arc << m_tickCount << m_currentRadius; - arc << m_Radius[0] << m_Radius[1]; + auto def = static_cast(GetDefault()); + arc("lightflags", lightflags, def->lightflags) + ("lighttype", lighttype, def->lighttype) + ("tickcount", m_tickCount, def->m_tickCount) + ("currentradius", m_currentRadius, def->m_currentRadius) + .Array("radius", m_Radius, def->m_Radius, 2); - if (lighttype == PulseLight) arc << m_lastUpdate << m_cycler; - if (arc.IsLoading()) - { - // The default constructor which is used for creating objects before deserialization will not set this variable. - // It needs to be true for all placed lights. - visibletoplayer = true; - LinkLight(); - } + if (lighttype == PulseLight) + arc("lastupdate", m_lastUpdate, def->m_lastUpdate) + ("cycler", m_cycler, def->m_cycler); } +void ADynamicLight::PostSerialize() +{ + Super::PostSerialize(); + // The default constructor which is used for creating objects before deserialization will not set this variable. + // It needs to be true for all placed lights. + visibletoplayer = true; + LinkLight(); +} + //========================================================================== // // [TS] diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index d92bf35c6..84965e318 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -32,7 +32,7 @@ EXTERN_CVAR(Bool, gl_lights) EXTERN_CVAR(Bool, gl_attachedlights) class ADynamicLight; -class FArchive; +class FSerializer; @@ -93,7 +93,8 @@ class ADynamicLight : public AActor DECLARE_CLASS (ADynamicLight, AActor) public: virtual void Tick(); - void Serialize(FArchive &arc); + void Serialize(FSerializer &arc); + void PostSerialize(); BYTE GetRed() const { return args[LIGHT_RED]; } BYTE GetGreen() const { return args[LIGHT_GREEN]; } BYTE GetBlue() const { return args[LIGHT_BLUE]; } diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index b95408521..71c52474a 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -169,7 +169,7 @@ public: void RenderScreenQuad(); void SetFixedColormap (player_t *player); - void WriteSavePic (player_t *player, FILE *file, int width, int height); + void WriteSavePic (player_t *player, FileWriter *file, int width, int height); void EndDrawScene(sector_t * viewsector); void UpdateCameraExposure(); void BloomScene(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 528925b7a..0c76b4bb1 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -43,6 +43,7 @@ #include "a_hexenglobal.h" #include "p_local.h" #include "gl/gl_functions.h" +#include "serializer.h" #include "gl/dynlights/gl_lightbuffer.h" #include "gl/system/gl_interface.h" @@ -921,7 +922,7 @@ void FGLRenderer::RenderView (player_t* player) // //=========================================================================== -void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int height) +void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, int height) { GL_IRECT bounds; @@ -972,10 +973,10 @@ struct FGLInterface : public FRenderer void PrecacheSprite(FTexture *tex, SpriteHits &hits); void Precache(BYTE *texhitlist, TMap &actorhitlist) override; void RenderView(player_t *player) override; - void WriteSavePic (player_t *player, FILE *file, int width, int height) override; + void WriteSavePic (player_t *player, FileWriter *file, int width, int height) override; void StateChanged(AActor *actor) override; - void StartSerialize(FArchive &arc) override; - void EndSerialize(FArchive &arc) override; + void StartSerialize(FSerializer &arc) override; + void EndSerialize(FSerializer &arc) override; void RenderTextureView (FCanvasTexture *self, AActor *viewpoint, int fov) override; sector_t *FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel, bool back) override; void SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog) override; @@ -1195,20 +1196,22 @@ void FGLInterface::StateChanged(AActor *actor) // //=========================================================================== -void FGLInterface::StartSerialize(FArchive &arc) +void FGLInterface::StartSerialize(FSerializer &arc) { gl_DeleteAllAttachedLights(); + if (arc.BeginObject("glinfo")) + { + arc("fogdensity", fogdensity) + ("outsidefogdensity", outsidefogdensity) + ("skyfog", skyfog) + .EndObject(); + } } -void gl_SerializeGlobals(FArchive &arc) -{ - arc << fogdensity << outsidefogdensity << skyfog; -} - -void FGLInterface::EndSerialize(FArchive &arc) +void FGLInterface::EndSerialize(FSerializer &arc) { gl_RecreateAllAttachedLights(); - if (arc.IsLoading()) gl_InitPortals(); + if (arc.isReading()) gl_InitPortals(); } //=========================================================================== @@ -1244,7 +1247,7 @@ void FGLInterface::ClearBuffer(int color) // //=========================================================================== -void FGLInterface::WriteSavePic (player_t *player, FILE *file, int width, int height) +void FGLInterface::WriteSavePic (player_t *player, FileWriter *file, int width, int height) { GLRenderer->WriteSavePic(player, file, width, height); } diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 1ca2f7edd..94eba0817 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -36,7 +36,6 @@ #include "vectors.h" #include "v_palette.h" #include "templates.h" -#include "farchive.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" diff --git a/src/gl/utility/gl_cycler.cpp b/src/gl/utility/gl_cycler.cpp index a12cb4851..b6d160925 100644 --- a/src/gl/utility/gl_cycler.cpp +++ b/src/gl/utility/gl_cycler.cpp @@ -34,19 +34,30 @@ */ #include +#include "serializer.h" #include "gl/utility/gl_cycler.h" //========================================================================== // -// +// This will never be called with a null-def, so don't bother with that case. // //========================================================================== -void FCycler::Serialize(FArchive & arc) +FSerializer &Serialize(FSerializer &arc, const char *key, FCycler &c, FCycler *def) { - arc << m_start << m_end << m_current - << m_time << m_cycle << m_increment << m_shouldCycle - << m_cycleType; + if (arc.BeginObject(key)) + { + arc("start", c.m_start, def->m_start) + ("end", c.m_end, def->m_end) + ("current", c.m_current, def->m_current) + ("time", c.m_time, def->m_time) + ("cycle", c.m_cycle, def->m_cycle) + ("increment", c.m_increment, def->m_increment) + ("shouldcycle", c.m_shouldCycle, def->m_shouldCycle) + .Enum("type", c.m_cycleType) + .EndObject(); + } + return arc; } //========================================================================== diff --git a/src/gl/utility/gl_cycler.h b/src/gl/utility/gl_cycler.h index 8a6b55581..42effce34 100644 --- a/src/gl/utility/gl_cycler.h +++ b/src/gl/utility/gl_cycler.h @@ -1,28 +1,24 @@ #ifndef __GL_CYCLER_H #define __GL_CYCLER_H -#include "farchive.h" +class FSerializer; -typedef enum +enum CycleType { - CYCLE_Linear, - CYCLE_Sin, - CYCLE_Cos, - CYCLE_SawTooth, - CYCLE_Square -} CycleType; - -inline FArchive &operator<< (FArchive &arc, CycleType &type) -{ - BYTE val = (BYTE)type; - arc << val; - type = (CycleType)val; - return arc; -} + CYCLE_Linear, + CYCLE_Sin, + CYCLE_Cos, + CYCLE_SawTooth, + CYCLE_Square +}; +class FCycler; +FSerializer &Serialize(FSerializer &arc, const char *key, FCycler &c, FCycler *def); class FCycler { + friend FSerializer &Serialize(FSerializer &arc, const char *key, FCycler &c, FCycler *def); + public: FCycler(); void Update(float diff); @@ -33,7 +29,6 @@ public: inline operator float () const { return m_current; } - void Serialize(FArchive & arc); protected: float m_start, m_end, m_current; float m_time, m_cycle; @@ -42,11 +37,5 @@ protected: CycleType m_cycleType; }; -inline FArchive &operator<< (FArchive &arc, FCycler &type) -{ - type.Serialize(arc); - return arc; -} - #endif diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 465760137..170273b43 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -271,6 +271,8 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sector_t &p, sector_t .Terrain("floorterrain", p.terrainnum[0], &def->terrainnum[0]) .Terrain("ceilingterrain", p.terrainnum[1], &def->terrainnum[1]) ("scrolls", scroll, nul) + // GZDoom exclusive: + .Array("reflect", p.reflect, def->reflect, 2) .EndObject(); if (arc.isReading() && !scroll.isZero()) From 43505877143dbba40e8ef454625b053ff5b7ca6b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 24 Sep 2016 08:40:28 +0200 Subject: [PATCH 0961/1509] Remove accidental UpdateCameraExposure duplicate from merge --- src/gl/renderer/gl_postprocess.cpp | 72 ------------------------------ 1 file changed, 72 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 0747e95d8..b3d125922 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -322,78 +322,6 @@ void FGLRenderer::UpdateCameraExposure() FGLDebug::PopGroup(); } -//----------------------------------------------------------------------------- -// -// Extracts light average from the scene and updates the camera exposure texture -// -//----------------------------------------------------------------------------- - -void FGLRenderer::UpdateCameraExposure() -{ - if (!gl_bloom && gl_tonemap == 0) - return; - - FGLDebug::PushGroup("UpdateCameraExposure"); - - FGLPostProcessState savedState; - savedState.SaveTextureBinding1(); - - // Extract light level from scene texture: - const auto &level0 = mBuffers->ExposureLevels[0]; - glBindFramebuffer(GL_FRAMEBUFFER, level0.Framebuffer); - glViewport(0, 0, level0.Width, level0.Height); - mBuffers->BindCurrentTexture(0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - mExposureExtractShader->Bind(); - mExposureExtractShader->SceneTexture.Set(0); - mExposureExtractShader->Scale.Set(mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height); - mExposureExtractShader->Offset.Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); - RenderScreenQuad(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - // Find the average value: - for (int i = 0; i + 1 < mBuffers->ExposureLevels.Size(); i++) - { - const auto &level = mBuffers->ExposureLevels[i]; - const auto &next = mBuffers->ExposureLevels[i + 1]; - - glBindFramebuffer(GL_FRAMEBUFFER, next.Framebuffer); - glViewport(0, 0, next.Width, next.Height); - glBindTexture(GL_TEXTURE_2D, level.Texture); - mExposureAverageShader->Bind(); - mExposureAverageShader->ExposureTexture.Set(0); - RenderScreenQuad(); - } - - // Combine average value with current camera exposure: - glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->ExposureFB); - glViewport(0, 0, 1, 1); - if (!mBuffers->FirstExposureFrame) - { - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - else - { - mBuffers->FirstExposureFrame = false; - } - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, mBuffers->ExposureLevels.Last().Texture); - mExposureCombineShader->Bind(); - mExposureCombineShader->ExposureTexture.Set(0); - mExposureCombineShader->ExposureBase.Set(gl_exposure_base); - mExposureCombineShader->ExposureMin.Set(gl_exposure_min); - mExposureCombineShader->ExposureScale.Set(gl_exposure_scale); - mExposureCombineShader->ExposureSpeed.Set(gl_exposure_speed); - RenderScreenQuad(); - glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); - - FGLDebug::PopGroup(); -} - //----------------------------------------------------------------------------- // // Adds bloom contribution to scene texture From 561edd31eca39b8e6b3f0bf77cbd4a8454b9ff99 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sun, 18 Sep 2016 15:07:08 -0500 Subject: [PATCH 0962/1509] Added check for angle visibility for GZDoom. --- src/gl/scene/gl_sprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 123bf258c..706fb33e4 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -636,7 +636,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) sector_t * rendersector; // Don't waste time projecting sprites that are definitely not visible. - if (thing == nullptr || thing->sprite == 0 || !thing->IsVisibleToPlayer()) + if (thing == nullptr || thing->sprite == 0 || !thing->IsVisibleToPlayer() || !thing->IsInsideVisibleAngle()) { return; } From 7ef5a9f1177f682f01d6730058c064697531bb80 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 24 Sep 2016 09:36:37 +0200 Subject: [PATCH 0963/1509] Add the experimental swrenderer2 --- src/CMakeLists.txt | 1 + src/r_main.cpp | 23 +- src/r_swrenderer2.cpp | 1871 +++++++++++++++++++++++++++++++++++++++++ src/r_swrenderer2.h | 345 ++++++++ 4 files changed, 2236 insertions(+), 4 deletions(-) create mode 100644 src/r_swrenderer2.cpp create mode 100644 src/r_swrenderer2.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f4252300..a213af8f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -971,6 +971,7 @@ set( NOT_COMPILED_SOURCE_FILES set( FASTMATH_PCH_SOURCES r_swrenderer.cpp + r_swrenderer2.cpp r_3dfloors.cpp r_bsp.cpp r_draw.cpp diff --git a/src/r_main.cpp b/src/r_main.cpp index ba02a7c60..f1d41506e 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -60,6 +60,9 @@ #include "r_data/colormaps.h" #include "farchive.h" #include "p_maputl.h" +#include "r_swrenderer2.h" + +CVAR(Bool, r_newrenderer, 0, 0); // MACROS ------------------------------------------------------------------ @@ -897,7 +900,15 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) // Link the polyobjects right before drawing the scene to reduce the amounts of calls to this function PO_LinkToSubsectors(); InSubsector = NULL; - R_RenderBSPNode (nodes + numnodes - 1); // The head node is the last node output. + if (!r_newrenderer || !r_swtruecolor) + { + R_RenderBSPNode(nodes + numnodes - 1); // The head node is the last node output. + } + else + { + RenderBsp bsp; + bsp.Render(); + } R_3D_ResetClip(); // reset clips (floor/ceiling) camera->renderflags = savedflags; WallCycles.Unclock(); @@ -907,8 +918,11 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) if (viewactive) { PlaneCycles.Clock(); - R_DrawPlanes (); - R_DrawPortals (); + if (!r_newrenderer || !r_swtruecolor) + { + R_DrawPlanes(); + R_DrawPortals(); + } PlaneCycles.Unclock(); // [RH] Walk through mirrors @@ -925,7 +939,8 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) NetUpdate (); MaskedCycles.Clock(); - R_DrawMasked (); + if (!r_newrenderer || !r_swtruecolor) + R_DrawMasked (); MaskedCycles.Unclock(); NetUpdate (); diff --git a/src/r_swrenderer2.cpp b/src/r_swrenderer2.cpp new file mode 100644 index 000000000..f7fb6afb9 --- /dev/null +++ b/src/r_swrenderer2.cpp @@ -0,0 +1,1871 @@ + +#include +#include "templates.h" +#include "doomdef.h" +#include "sbar.h" +#include "r_data/r_translate.h" +#include "r_swrenderer2.h" +#include "r_draw.h" +#include "r_plane.h" // for yslope +#include "r_sky.h" // for skyflatnum +#include "r_things.h" // for pspritexscale + +EXTERN_CVAR(Bool, r_drawplayersprites) +EXTERN_CVAR(Bool, r_deathcamera) +EXTERN_CVAR(Bool, st_scale) + +DVector3 ViewPosTransform::WorldToEye(const DVector3 &worldPoint) const +{ + double tr_x = worldPoint.X - ViewPos.X; + double tr_y = worldPoint.Y - ViewPos.Y; + double tr_z = worldPoint.Z - ViewPos.Z; + double tx = tr_x * ViewSin - tr_y * ViewCos; + double tz = tr_x * ViewTanCos + tr_y * ViewTanSin; + return DVector3(tx, tr_z, tz); +} + +DVector3 ViewPosTransform::EyeToViewport(const DVector3 &eyePoint) const +{ + double rcp_z = 1.0 / eyePoint.Z; + return DVector3(eyePoint.X * rcp_z, eyePoint.Y * rcp_z, rcp_z); +} + +DVector3 ViewPosTransform::ViewportToScreen(const DVector3 &viewportPoint) const +{ + return DVector3(CenterX + viewportPoint.X * CenterX, CenterY - viewportPoint.Y * InvZtoScale, viewportPoint.Z); +} + +double ViewPosTransform::ScreenXToEye(int x, double z) const +{ + return (x + 0.5 - CenterX) / CenterX * z; +} + +double ViewPosTransform::ScreenYToEye(int y, double z) const +{ + return -(y + 0.5 - CenterY) / InvZtoScale * z; +} + +///////////////////////////////////////////////////////////////////////////// + +WallCoords::WallCoords(const ViewPosTransform &transform, const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2) : Transform(transform) +{ + // Transform wall to eye space + DVector3 top1 = transform.WorldToEye(DVector3(v1, ceil1)); + DVector3 top2 = transform.WorldToEye(DVector3(v2, ceil2)); + DVector3 bottom1 = transform.WorldToEye(DVector3(v1, floor1)); + DVector3 bottom2 = transform.WorldToEye(DVector3(v2, floor2)); + + double clipNearZ = transform.NearZ(); + + // Is entire wall behind znear clipping plane? If so, wall is culled + if ((top1.Z < clipNearZ && top2.Z < clipNearZ)) + return; + + PlaneNormal = (top2 - top1) ^ (top1 - bottom1); + PlaneD = -(PlaneNormal | top1); + + // Clip wall to znear clipping plane + if (top1.Z < clipNearZ) + { + double t = (clipNearZ - top1.Z) / (top2.Z - top1.Z); + top1 = Mix(top1, top2, t); + bottom1 = Mix(bottom1, bottom2, t); + + VaryingXScale = 1.0 - t; + VaryingXOffset = t; + } + else if (top2.Z < clipNearZ) + { + double t = (clipNearZ - top1.Z) / (top2.Z - top1.Z); + top2 = Mix(top1, top2, t); + bottom2 = Mix(bottom1, bottom2, t); + VaryingXScale = t; + VaryingXOffset = 0.0; + } + + NearZ = MIN(top1.Z, top2.Z); + FarZ = MAX(top1.Z, top2.Z); + + // Transform to screen coordinates + ScreenTopLeft = transform.EyeToScreen(top1); + ScreenTopRight = transform.EyeToScreen(top2); + ScreenBottomLeft = transform.EyeToScreen(bottom1); + ScreenBottomRight = transform.EyeToScreen(bottom2); + if (ScreenTopLeft.X > ScreenTopRight.X) + { + std::swap(ScreenTopLeft, ScreenTopRight); + std::swap(ScreenBottomLeft, ScreenBottomRight); + } + + ScreenX1 = xs_RoundToInt(MAX(ScreenTopLeft.X, 0.0)); + ScreenX2 = xs_RoundToInt(MIN(ScreenTopRight.X, (double)viewwidth)); + ScreenY1 = xs_RoundToInt(MAX(MIN(ScreenTopLeft.Y, ScreenTopRight.Y), 0.0)); + ScreenY2 = xs_RoundToInt(MIN(MAX(ScreenBottomLeft.Y, ScreenBottomRight.Y), (double)viewheight)); + + // Cull if nothing of the wall is visible + if (ScreenX2 <= ScreenX1 || ScreenY2 <= ScreenY1) + return; + + RcpDeltaScreenX = 1.0 / (ScreenTopRight.X - ScreenTopLeft.X); + Culled = false; +} + +DVector3 WallCoords::Mix(const DVector3 &a, const DVector3 &b, double t) +{ + double invt = 1.0 - t; + return DVector3(a.X * invt + b.X * t, a.Y * invt + b.Y * t, a.Z * invt + b.Z * t); +} + +double WallCoords::Mix(double a, double b, double t) +{ + return a * (1.0 - t) + b * t; +} + +short WallCoords::Y1(int x) const +{ + double t = (x + 0.5 - ScreenTopLeft.X) * RcpDeltaScreenX; + return (short)MAX(xs_RoundToInt(Mix(ScreenTopLeft.Y, ScreenTopRight.Y, t)), 0); +} + +short WallCoords::Y2(int x) const +{ + double t = (x + 0.5 - ScreenBottomLeft.X) * RcpDeltaScreenX; + return (short)MIN(xs_RoundToInt(Mix(ScreenBottomLeft.Y, ScreenBottomRight.Y, t)), viewheight); +} + +double WallCoords::Z(int x) const +{ + double t = (x + 0.5 - ScreenTopLeft.X) * RcpDeltaScreenX; + double rcp_z = Mix(ScreenTopLeft.Z, ScreenTopRight.Z, t); + return 1.0 / rcp_z; +} + +double WallCoords::VaryingX(int x, double start, double end) const +{ + double t = (x + 0.5 - ScreenTopLeft.X) * RcpDeltaScreenX; + double rcp_z = Mix(ScreenTopLeft.Z, ScreenTopRight.Z, t); + double t2 = VaryingXOffset + t / rcp_z * ScreenTopRight.Z * VaryingXScale; + return Mix(start, end, t2); +} + +double WallCoords::VaryingY(int x, int y, double start, double end) const +{ + double t = (x + 0.5 - ScreenTopLeft.X) * RcpDeltaScreenX; + double y1 = Mix(ScreenTopLeft.Y, ScreenTopRight.Y, t); + double y2 = Mix(ScreenBottomLeft.Y, ScreenBottomRight.Y, t); + if (y1 == y2 || y1 == -y2) + return start; + double t2 = (y + 0.5 - y1) / (y2 - y1); + return Mix(start, end, t2); +} + +///////////////////////////////////////////////////////////////////////////// + +void RenderBsp::Render() +{ + Clip.Clear(0, viewwidth); + Planes.Clear(); + VisibleSprites.clear(); + ScreenSprites.clear(); + + if (numnodes == 0) + RenderSubsector(subsectors); + else + RenderNode(nodes + numnodes - 1); // The head node is the last node output. + + Planes.Render(); + + RenderMaskedObjects(); + RenderPlayerSprites(); + RenderScreenSprites(); // To do: should be called by FSoftwareRenderer::DrawRemainingPlayerSprites instead of here +} + +void RenderBsp::RenderScreenSprites() +{ + for (auto &sprite : ScreenSprites) + sprite.Render(); +} + +void RenderBsp::RenderMaskedObjects() +{ + Clip.DrawMaskedWall = [&](short x1, short x2, int drawIndex, const short *clipTop, const short *clipBottom) + { + VisibleMaskedWalls[drawIndex].RenderMasked(x1, x2, clipTop, clipBottom); + }; + + std::stable_sort(VisibleSprites.begin(), VisibleSprites.end(), [](const auto &a, const auto &b) { return a.EyePos.Z > b.EyePos.Z; }); + + for (auto &sprite : VisibleSprites) + sprite.Render(&Clip); + + Clip.RenderMaskedWalls(); +} + +void RenderBsp::RenderPlayerSprites() +{ + if (!r_drawplayersprites || + !camera || + !camera->player || + (players[consoleplayer].cheats & CF_CHASECAM) || + (r_deathcamera && camera->health <= 0)) + return; + + float bobx, boby; + P_BobWeapon(camera->player, &bobx, &boby, r_TicFracF); + + // Interpolate the main weapon layer once so as to be able to add it to other layers. + double wx, wy; + DPSprite *weapon = camera->player->FindPSprite(PSP_WEAPON); + if (weapon) + { + if (weapon->firstTic) + { + wx = weapon->x; + wy = weapon->y; + } + else + { + wx = weapon->oldx + (weapon->x - weapon->oldx) * r_TicFracF; + wy = weapon->oldy + (weapon->y - weapon->oldy) * r_TicFracF; + } + } + else + { + wx = 0; + wy = 0; + } + + for (DPSprite *sprite = camera->player->psprites; sprite != nullptr; sprite = sprite->GetNext()) + { + // [RH] Don't draw the targeter's crosshair if the player already has a crosshair set. + // It's possible this psprite's caller is now null but the layer itself hasn't been destroyed + // because it didn't tick yet (if we typed 'take all' while in the console for example). + // In this case let's simply not draw it to avoid crashing. + if ((sprite->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr) && sprite->GetCaller() != nullptr) + { + RenderPlayerSprite(sprite, camera, bobx, boby, wx, wy, r_TicFracF); + } + } +} + +void RenderBsp::RenderPlayerSprite(DPSprite *sprite, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac) +{ + // decide which patch to use + if ((unsigned)sprite->GetSprite() >= (unsigned)sprites.Size()) + { + DPrintf(DMSG_ERROR, "RenderPlayerSprite: invalid sprite number %i\n", sprite->GetSprite()); + return; + } + + spritedef_t *def = &sprites[sprite->GetSprite()]; + if (sprite->GetFrame() >= def->numframes) + { + DPrintf(DMSG_ERROR, "RenderPlayerSprite: invalid sprite frame %i : %i\n", sprite->GetSprite(), sprite->GetFrame()); + return; + } + + spriteframe_t *frame = &SpriteFrames[def->spriteframes + sprite->GetFrame()]; + FTextureID picnum = frame->Texture[0]; + bool flip = (frame->Flip & 1) != 0; + + FTexture *tex = TexMan(picnum); + if (tex->UseType == FTexture::TEX_Null) + return; + + // Can't interpolate the first tic. + if (sprite->firstTic) + { + sprite->firstTic = false; + sprite->oldx = sprite->x; + sprite->oldy = sprite->y; + } + + double sx = sprite->oldx + (sprite->x - sprite->oldx) * ticfrac; + double sy = sprite->oldy + (sprite->y - sprite->oldy) * ticfrac; + + if (sprite->Flags & PSPF_ADDBOB) + { + sx += bobx; + sy += boby; + } + + if (sprite->Flags & PSPF_ADDWEAPON && sprite->GetID() != PSP_WEAPON) + { + sx += wx; + sy += wy; + } + + // calculate edges of the shape + double tx = sx - BaseXCenter; + + tx -= tex->GetScaledLeftOffset(); + int x1 = xs_RoundToInt(CenterX + tx * pspritexscale); + + // off the right side + if (x1 > viewwidth) + return; + + tx += tex->GetScaledWidth(); + int x2 = xs_RoundToInt(CenterX + tx * pspritexscale); + + // off the left side + if (x2 <= 0) + return; + + double texturemid = (BaseYCenter - sy) * tex->Scale.Y + tex->TopOffset; + + // Adjust PSprite for fullscreen views + if (camera->player && (RenderTarget != screen || viewheight == RenderTarget->GetHeight() || (RenderTarget->GetWidth() > (BaseXCenter * 2) && !st_scale))) + { + AWeapon *weapon = dyn_cast(sprite->GetCaller()); + if (weapon != nullptr && weapon->YAdjust != 0) + { + if (RenderTarget != screen || viewheight == RenderTarget->GetHeight()) + { + texturemid -= weapon->YAdjust; + } + else + { + texturemid -= StatusBar->GetDisplacement() * weapon->YAdjust; + } + } + } + + // Move the weapon down for 1280x1024. + if (sprite->GetID() < PSP_TARGETCENTER) + { + texturemid -= AspectPspriteOffset(WidescreenRatio); + } + + int clipped_x1 = MAX(x1, 0); + int clipped_x2 = MIN(x2, viewwidth); + double xscale = pspritexscale / tex->Scale.X; + double yscale = pspriteyscale / tex->Scale.Y; + uint32_t translation = 0; // [RH] Use default colors + + double xiscale, startfrac; + if (flip) + { + xiscale = -pspritexiscale * tex->Scale.X; + startfrac = 1; + } + else + { + xiscale = pspritexiscale * tex->Scale.X; + startfrac = 0; + } + + if (clipped_x1 > x1) + startfrac += xiscale * (clipped_x1 - x1); + + bool noaccel = false; + + FDynamicColormap *basecolormap = viewsector->ColorMap; + FDynamicColormap *colormap_to_use = basecolormap; + + visstyle_t visstyle; + visstyle.ColormapNum = 0; + visstyle.BaseColormap = basecolormap; + visstyle.Alpha = 0; + visstyle.RenderStyle = STYLE_Normal; + + bool foggy = false; + int actualextralight = foggy ? 0 : extralight << 4; + int spriteshade = LIGHT2SHADE(owner->Sector->lightlevel + actualextralight); + double minz = double((2048 * 4) / double(1 << 20)); + visstyle.ColormapNum = GETPALOOKUP(r_SpriteVisibility / minz, spriteshade); + + if (sprite->GetID() < PSP_TARGETCENTER) + { + // Lots of complicated style and noaccel stuff + } + + // Check for hardware-assisted 2D. If it's available, and this sprite is not + // fuzzy, don't draw it until after the switch to 2D mode. + if (!noaccel && RenderTarget == screen && (DFrameBuffer *)screen->Accel2D) + { + FRenderStyle style = visstyle.RenderStyle; + style.CheckFuzz(); + if (style.BlendOp != STYLEOP_Fuzz) + { + ScreenSprite screenSprite; + screenSprite.Pic = tex; + screenSprite.X1 = viewwindowx + x1; + screenSprite.Y1 = viewwindowy + viewheight / 2 - texturemid * yscale - 0.5; + screenSprite.Width = tex->GetWidth() * xscale; + screenSprite.Height = tex->GetHeight() * yscale; + screenSprite.Translation = TranslationToTable(translation); + screenSprite.Flip = xiscale < 0; + screenSprite.visstyle = visstyle; + screenSprite.Colormap = colormap_to_use; + ScreenSprites.push_back(screenSprite); + return; + } + } + + //R_DrawVisSprite(vis); +} + +bool RenderBsp::IsThingCulled(AActor *thing) +{ + FIntCVar *cvar = thing->GetClass()->distancecheck; + if (cvar != nullptr && *cvar >= 0) + { + double dist = (thing->Pos() - ViewPos).LengthSquared(); + double check = (double)**cvar; + if (dist >= check * check) + return true; + } + + // Don't waste time projecting sprites that are definitely not visible. + if (thing == nullptr || + (thing->renderflags & RF_INVISIBLE) || + !thing->RenderStyle.IsVisible(thing->Alpha) || + !thing->IsVisibleToPlayer()) + { + return true; + } + + return false; +} + +void RenderBsp::AddSprite(AActor *thing) +{ + if (IsThingCulled(thing)) + return; + + DVector3 pos = thing->InterpolatedPosition(r_TicFracF); + pos.Z += thing->GetBobOffset(r_TicFracF); + + DVector3 eyePos = Transform.WorldToEye(pos); + + // thing is behind view plane? + if (eyePos.Z < Transform.NearZ()) + return; + + // too far off the side? + if (fabs(eyePos.X / 64) > eyePos.Z) + return; + + VisibleSprites.push_back({ thing, eyePos }); +} + +void RenderBsp::AddWallSprite(AActor *thing) +{ + if (IsThingCulled(thing)) + return; +} + +void RenderBsp::RenderSubsector(subsector_t *sub) +{ + sector_t *frontsector = sub->sector; + frontsector->MoreFlags |= SECF_DRAWN; + + for (AActor *thing = sub->sector->thinglist; thing != nullptr; thing = thing->snext) + { + if ((thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) + AddWallSprite(thing); + else + AddSprite(thing); + } + + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + if (line->sidedef == NULL || !(line->sidedef->Flags & WALLF_POLYOBJ)) + AddLine(line, frontsector); + } +} + +void RenderBsp::AddLine(seg_t *line, sector_t *frontsector) +{ + // Reject lines not facing viewer + DVector2 pt1 = line->v1->fPos() - ViewPos; + DVector2 pt2 = line->v2->fPos() - ViewPos; + if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0) + return; + + double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1); + double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1); + double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2); + double frontfloorz2 = frontsector->floorplane.ZatPoint(line->v2); + + WallCoords entireWall(Transform, line->v1->fPos(), line->v2->fPos(), frontceilz1, frontfloorz1, frontceilz2, frontfloorz2); + if (entireWall.Culled) + return; + + VisiblePlaneKey ceilingPlaneKey(frontsector->GetTexture(sector_t::ceiling), frontsector->ColorMap, frontsector->lightlevel, frontsector->ceilingplane, frontsector->planes[sector_t::ceiling].xform); + VisiblePlaneKey floorPlaneKey(frontsector->GetTexture(sector_t::floor), frontsector->ColorMap, frontsector->lightlevel, frontsector->floorplane, frontsector->planes[sector_t::floor].xform); + + RenderWall wall; + wall.Line = line; + wall.Colormap = frontsector->ColorMap; + wall.Masked = false; + + if (line->backsector == nullptr) + { + Planes.MarkCeilingPlane(ceilingPlaneKey, Clip, entireWall); + Planes.MarkFloorPlane(floorPlaneKey, Clip, entireWall); + + wall.Coords = entireWall; + wall.TopZ = frontceilz1; + wall.BottomZ = frontfloorz1; + wall.UnpeggedCeil = frontceilz1; + wall.Texpart = side_t::mid; + wall.Render(Clip); + + Clip.MarkSegmentCulled(entireWall, -1); + } + else + { + sector_t *backsector = (line->backsector != line->frontsector) ? line->backsector : line->frontsector; + + double backceilz1 = backsector->ceilingplane.ZatPoint(line->v1); + double backfloorz1 = backsector->floorplane.ZatPoint(line->v1); + double backceilz2 = backsector->ceilingplane.ZatPoint(line->v2); + double backfloorz2 = backsector->floorplane.ZatPoint(line->v2); + + double topceilz1 = frontceilz1; + double topceilz2 = frontceilz2; + double topfloorz1 = MIN(backceilz1, frontceilz1); + double topfloorz2 = MIN(backceilz2, frontceilz2); + double bottomceilz1 = MAX(frontfloorz1, backfloorz1); + double bottomceilz2 = MAX(frontfloorz2, backfloorz2); + double bottomfloorz1 = frontfloorz1; + double bottomfloorz2 = frontfloorz2; + double middleceilz1 = topfloorz1; + double middleceilz2 = topfloorz2; + double middlefloorz1 = MIN(bottomceilz1, middleceilz1); + double middlefloorz2 = MIN(bottomceilz2, middleceilz2); + + bool bothSkyCeiling = frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum; + bool bothSkyFloor = frontsector->GetTexture(sector_t::floor) == skyflatnum && backsector->GetTexture(sector_t::floor) == skyflatnum; + + int maskedWallIndex = -1; + + if ((topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && !bothSkyCeiling && line->sidedef) + { + WallCoords topwall(Transform, line->v1->fPos(), line->v2->fPos(), topceilz1, topfloorz1, topceilz2, topfloorz2); + if (!topwall.Culled) + { + wall.Coords = topwall; + wall.TopZ = topceilz1; + wall.BottomZ = topfloorz1; + wall.UnpeggedCeil = topceilz1; + wall.Texpart = side_t::top; + wall.Render(Clip); + } + } + + if ((bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && !bothSkyFloor && line->sidedef) + { + WallCoords bottomwall(Transform, line->v1->fPos(), line->v2->fPos(), bottomceilz1, bottomfloorz2, bottomceilz2, bottomfloorz2); + if (!bottomwall.Culled) + { + wall.Coords = bottomwall; + wall.TopZ = bottomceilz1; + wall.BottomZ = bottomfloorz2; + wall.UnpeggedCeil = topceilz1; + wall.Texpart = side_t::bottom; + wall.Render(Clip); + } + } + + WallCoords midwall(Transform, line->v1->fPos(), line->v2->fPos(), middleceilz1, middlefloorz1, middleceilz2, middlefloorz2); + if (!midwall.Culled && line->sidedef) + { + FTexture *midtex = TexMan(line->sidedef->GetTexture(side_t::mid), true); + if (midtex && midtex->UseType != FTexture::TEX_Null) + { + DVector3 v1 = Transform.WorldToEye({ line->v1->fPos(), 0.0 }); + DVector3 v2 = Transform.WorldToEye({ line->v2->fPos(), 0.0 }); + wall.Coords = midwall; + wall.TopZ = middleceilz1; + wall.BottomZ = middlefloorz1; + wall.UnpeggedCeil = topceilz1; + wall.Texpart = side_t::mid; + wall.Masked = true; + + maskedWallIndex = (int)VisibleMaskedWalls.size(); + VisibleMaskedWalls.push_back(wall); + } + } + + if (!bothSkyCeiling && !bothSkyFloor) + { + Planes.MarkCeilingPlane(ceilingPlaneKey, Clip, entireWall); + Planes.MarkFloorPlane(floorPlaneKey, Clip, entireWall); + if (!midwall.Culled) + Clip.ClipVertical(midwall, maskedWallIndex); + else + Clip.MarkSegmentCulled(entireWall, maskedWallIndex); + } + else if (bothSkyCeiling) + { + Planes.MarkFloorPlane(floorPlaneKey, Clip, entireWall); + if (!midwall.Culled) + Clip.ClipBottom(midwall, maskedWallIndex); + else + Clip.MarkSegmentCulled(entireWall, maskedWallIndex); + } + else if (bothSkyFloor) + { + Planes.MarkCeilingPlane(ceilingPlaneKey, Clip, entireWall); + if (!midwall.Culled) + Clip.ClipTop(midwall, maskedWallIndex); + else + Clip.MarkSegmentCulled(entireWall, maskedWallIndex); + } + } +} + +void RenderBsp::RenderNode(void *node) +{ + while (!((size_t)node & 1)) // Keep going until found a subsector + { + node_t *bsp = (node_t *)node; + + // Decide which side the view point is on. + int side = PointOnSide(ViewPos, bsp); + + // Recursively divide front space (toward the viewer). + RenderNode(bsp->children[side]); + + // Possibly divide back space (away from the viewer). + side ^= 1; + if (!CheckBBox(bsp->bbox[side])) + return; + + node = bsp->children[side]; + } + RenderSubsector((subsector_t *)((BYTE *)node - 1)); +} + +int RenderBsp::PointOnSide(const DVector2 &pos, const node_t *node) +{ + return DMulScale32(FLOAT2FIXED(pos.Y) - node->y, node->dx, node->x - FLOAT2FIXED(pos.X), node->dy) > 0; +} + +bool RenderBsp::CheckBBox(float *bspcoord) +{ + static const int checkcoord[12][4] = + { + { 3,0,2,1 }, + { 3,0,2,0 }, + { 3,1,2,0 }, + { 0 }, + { 2,0,2,1 }, + { 0,0,0,0 }, + { 3,1,3,0 }, + { 0 }, + { 2,0,3,1 }, + { 2,1,3,1 }, + { 2,1,3,0 } + }; + + int boxx; + int boxy; + int boxpos; + + double x1, y1, x2, y2; + double rx1, ry1, rx2, ry2; + int sx1, sx2; + + // Find the corners of the box + // that define the edges from current viewpoint. + if (ViewPos.X <= bspcoord[BOXLEFT]) + boxx = 0; + else if (ViewPos.X < bspcoord[BOXRIGHT]) + boxx = 1; + else + boxx = 2; + + if (ViewPos.Y >= bspcoord[BOXTOP]) + boxy = 0; + else if (ViewPos.Y > bspcoord[BOXBOTTOM]) + boxy = 1; + else + boxy = 2; + + boxpos = (boxy << 2) + boxx; + if (boxpos == 5) + return true; + + x1 = bspcoord[checkcoord[boxpos][0]] - ViewPos.X; + y1 = bspcoord[checkcoord[boxpos][1]] - ViewPos.Y; + x2 = bspcoord[checkcoord[boxpos][2]] - ViewPos.X; + y2 = bspcoord[checkcoord[boxpos][3]] - ViewPos.Y; + + // check clip list for an open space + + // Sitting on a line? + if (y1 * (x1 - x2) + x1 * (y2 - y1) >= -EQUAL_EPSILON) + return true; + + rx1 = x1 * ViewSin - y1 * ViewCos; + rx2 = x2 * ViewSin - y2 * ViewCos; + ry1 = x1 * ViewTanCos + y1 * ViewTanSin; + ry2 = x2 * ViewTanCos + y2 * ViewTanSin; + + /*if (MirrorFlags & RF_XFLIP) + { + double t = -rx1; + rx1 = -rx2; + rx2 = t; + swapvalues(ry1, ry2); + }*/ + + if (rx1 >= -ry1) + { + if (rx1 > ry1) return false; // left edge is off the right side + if (ry1 == 0) return false; + sx1 = xs_RoundToInt(CenterX + rx1 * CenterX / ry1); + } + else + { + if (rx2 < -ry2) return false; // wall is off the left side + if (rx1 - rx2 - ry2 + ry1 == 0) return false; // wall does not intersect view volume + sx1 = 0; + } + + if (rx2 <= ry2) + { + if (rx2 < -ry2) return false; // right edge is off the left side + if (ry2 == 0) return false; + sx2 = xs_RoundToInt(CenterX + rx2 * CenterX / ry2); + } + else + { + if (rx1 > ry1) return false; // wall is off the right side + if (ry2 - ry1 - rx2 + rx1 == 0) return false; // wall does not intersect view volume + sx2 = viewwidth; + } + + // Find the first clippost that touches the source post + // (adjacent pixels are touching). + + // Does not cross a pixel. + if (sx2 <= sx1) + return false; + + return !Clip.IsSegmentCulled(sx1, sx2); +} + +///////////////////////////////////////////////////////////////////////////// + +WallTextureCoords::WallTextureCoords(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil) +{ + CalcU(tex, line, texpart); + CalcV(tex, line, texpart, topz, bottomz, unpeggedceil); +} + +void WallTextureCoords::CalcU(FTexture *tex, const seg_t *line, side_t::ETexpart texpart) +{ + double lineLength = line->sidedef->TexelLength; + double lineStart = 0.0; + + bool entireSegment = ((line->linedef->v1 == line->v1) && (line->linedef->v2 == line->v2) || (line->linedef->v2 == line->v1) && (line->linedef->v1 == line->v2)); + if (!entireSegment) + { + lineLength = (line->v2->fPos() - line->v1->fPos()).Length(); + lineStart = (line->v1->fPos() - line->linedef->v1->fPos()).Length(); + } + + int texWidth = tex->GetWidth(); + double uscale = line->sidedef->GetTextureXScale(texpart) * tex->Scale.X; + u1 = lineStart + line->sidedef->GetTextureXOffset(texpart); + u2 = u1 + lineLength; + u1 *= uscale; + u2 *= uscale; + u1 /= texWidth; + u2 /= texWidth; +} + +void WallTextureCoords::CalcV(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil) +{ + double vscale = line->sidedef->GetTextureYScale(texpart) * tex->Scale.Y; + + double yoffset = line->sidedef->GetTextureYOffset(texpart); + if (tex->bWorldPanning) + yoffset *= vscale; + + switch (texpart) + { + default: + case side_t::mid: + CalcVMidPart(tex, line, topz, bottomz, vscale, yoffset); + break; + case side_t::top: + CalcVTopPart(tex, line, topz, bottomz, vscale, yoffset); + break; + case side_t::bottom: + CalcVBottomPart(tex, line, topz, bottomz, unpeggedceil, vscale, yoffset); + break; + } + + int texHeight = tex->GetHeight(); + v1 /= texHeight; + v2 /= texHeight; +} + +void WallTextureCoords::CalcVTopPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset) +{ + bool pegged = (line->linedef->flags & ML_DONTPEGTOP) == 0; + if (pegged) // bottom to top + { + int texHeight = tex->GetHeight(); + v1 = -yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + v1 = texHeight - v1; + v2 = texHeight - v2; + std::swap(v1, v2); + } + else // top to bottom + { + v1 = yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + } +} + +void WallTextureCoords::CalcVMidPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset) +{ + bool pegged = (line->linedef->flags & ML_DONTPEGBOTTOM) == 0; + if (pegged) // top to bottom + { + v1 = yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + } + else // bottom to top + { + int texHeight = tex->GetHeight(); + v1 = yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + v1 = texHeight - v1; + v2 = texHeight - v2; + std::swap(v1, v2); + } +} + +void WallTextureCoords::CalcVBottomPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double unpeggedceil, double vscale, double yoffset) +{ + bool pegged = (line->linedef->flags & ML_DONTPEGBOTTOM) == 0; + if (pegged) // top to bottom + { + v1 = yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + } + else + { + v1 = yoffset + (unpeggedceil - topz); + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + } +} + +///////////////////////////////////////////////////////////////////////////// + +void RenderClipBuffer::Clear(short left, short right) +{ + SolidSegments.clear(); + SolidSegments.reserve(MAXWIDTH / 2 + 2); + SolidSegments.push_back({ -0x7fff, left }); + SolidSegments.push_back({ right, 0x7fff }); + + DrawSegments.clear(); + ClipValues.clear(); + + for (int x = left; x < right; x++) + { + Top[x] = 0; + Bottom[x] = viewheight; + } +} + +bool RenderClipBuffer::IsSegmentCulled(short x1, short x2) const +{ + int next = 0; + while (SolidSegments[next].X2 <= x2) + next++; + return (x1 >= SolidSegments[next].X1 && x2 <= SolidSegments[next].X2); +} + +void RenderClipBuffer::MarkSegmentCulled(const WallCoords &wallCoords, int drawIndex) +{ + if (wallCoords.Culled) + return; + + VisibleSegmentsIterator it(*this, wallCoords.ScreenX1, wallCoords.ScreenX2); + while (it.Step()) + { + for (short x = it.X1; x < it.X2; x++) + { + Bottom[x] = Top[x]; + } + + AddDrawSegment(it.X1, it.X2, wallCoords, true, true, drawIndex); + } + + short x1 = wallCoords.ScreenX1; + short x2 = wallCoords.ScreenX2; + + if (x1 >= x2) + return; + + int cur = 1; + while (true) + { + if (SolidSegments[cur].X1 <= x1 && SolidSegments[cur].X2 >= x2) // Already fully marked + { + break; + } + else if (cur + 1 != SolidSegments.size() && SolidSegments[cur].X2 >= x1 && SolidSegments[cur].X1 <= x2) // Merge segments + { + // Find last segment + int merge = cur; + while (merge + 2 != SolidSegments.size() && SolidSegments[merge + 1].X1 <= x2) + merge++; + + // Apply new merged range + SolidSegments[cur].X1 = MIN(SolidSegments[cur].X1, x1); + SolidSegments[cur].X2 = MAX(SolidSegments[merge].X2, x2); + + // Remove additional segments we merged with + if (merge > cur) + SolidSegments.erase(SolidSegments.begin() + (cur + 1), SolidSegments.begin() + (merge + 1)); + + break; + } + else if (SolidSegments[cur].X1 > x1) // Insert new segment + { + SolidSegments.insert(SolidSegments.begin() + cur, { x1, x2 }); + break; + } + cur++; + } +} + +void RenderClipBuffer::ClipVertical(const WallCoords &wallCoords, int drawIndex) +{ + if (wallCoords.Culled) + return; + + VisibleSegmentsIterator it(*this, wallCoords.ScreenX1, wallCoords.ScreenX2); + while (it.Step()) + { + for (short x = it.X1; x < it.X2; x++) + { + Top[x] = MAX(wallCoords.Y1(x), Top[x]); + Bottom[x] = MIN(wallCoords.Y2(x), Bottom[x]); + } + AddDrawSegment(it.X1, it.X2, wallCoords, true, true, drawIndex); + } +} + +void RenderClipBuffer::ClipTop(const WallCoords &wallCoords, int drawIndex) +{ + if (wallCoords.Culled) + return; + + VisibleSegmentsIterator it(*this, wallCoords.ScreenX1, wallCoords.ScreenX2); + while (it.Step()) + { + for (short x = it.X1; x < it.X2; x++) + { + Top[x] = MAX(wallCoords.Y1(x), Top[x]); + } + AddDrawSegment(it.X1, it.X2, wallCoords, true, false, drawIndex); + } +} + +void RenderClipBuffer::ClipBottom(const WallCoords &wallCoords, int drawIndex) +{ + if (wallCoords.Culled) + return; + + VisibleSegmentsIterator it(*this, wallCoords.ScreenX1, wallCoords.ScreenX2); + while (it.Step()) + { + for (short x = it.X1; x < it.X2; x++) + { + Bottom[x] = MIN(wallCoords.Y2(x), Bottom[x]); + } + AddDrawSegment(it.X1, it.X2, wallCoords, false, true, drawIndex); + } +} + +void RenderClipBuffer::AddDrawSegment(short x1, short x2, const WallCoords &wall, bool clipTop, bool clipBottom, int drawIndex) +{ + if (drawIndex != -1) // DrawMaskedWall needs both clipping ranges + { + clipTop = true; + clipBottom = true; + } + + DrawSegment segment; + segment.X1 = x1; + segment.X2 = x2; + segment.ClipOffset = (int)ClipValues.size(); + segment.ClipTop = clipTop; + segment.ClipBottom = clipBottom; + segment.PlaneNormal = wall.PlaneNormal; + segment.PlaneD = wall.PlaneD; + segment.NearZ = wall.NearZ; + segment.FarZ = wall.FarZ; + segment.DrawIndex = drawIndex; + + if (clipTop) + { + ClipValues.insert(ClipValues.end(), Top + x1, Top + x2); + } + + if (clipBottom) + { + ClipValues.insert(ClipValues.end(), Bottom + x1, Bottom + x2); + } + + DrawSegments.push_back(segment); +} + +void RenderClipBuffer::SetupSpriteClip(short x1, short x2, const DVector3 &pos, bool wallSprite) +{ + for (int i = x1; i < x2; i++) + { + Top[i] = 0; + Bottom[i] = viewheight; + } + + for (auto it = DrawSegments.crbegin(); it != DrawSegments.crend(); ++it) + { + const auto &segment = *it; + + int r1 = MAX(segment.X1, x1); + int r2 = MIN(segment.X2, x2); + if (r2 <= r1) + continue; + + short *clipTop = ClipValues.data() + segment.ClipOffset; + short *clipBottom = segment.ClipTop ? clipTop + (segment.X2 - segment.X1) : clipTop; + + double side = (pos | segment.PlaneNormal) + segment.PlaneD; + bool segBehindSprite; + if (!wallSprite) + segBehindSprite = (segment.NearZ >= pos.Z) || (segment.FarZ >= pos.Z && side <= 0.0); + else + segBehindSprite = side <= 0.0; + + if (segBehindSprite) + { + if (segment.DrawIndex != -1 && DrawMaskedWall) + DrawMaskedWall(r1, r2, segment.DrawIndex, clipTop + (r1 - segment.X1), clipBottom + (r1 - segment.X1)); + + if (segment.ClipTop) + { + for (int i = r1 - segment.X1; i < r2 - segment.X1; i++) + clipTop[i] = 0; + } + + if (segment.ClipBottom) + { + for (int i = r1 - segment.X1; i < r2 - segment.X1; i++) + clipBottom[i] = 0; + } + } + else + { + if (segment.ClipTop) + { + for (int x = r1; x < r2; x++) + Top[x] = MAX(clipTop[x - segment.X1], Top[x]); + } + + if (segment.ClipBottom) + { + for (int x = r1; x < r2; x++) + Bottom[x] = MIN(clipBottom[x - segment.X1], Bottom[x]); + } + } + } +} + +void RenderClipBuffer::RenderMaskedWalls() +{ + for (int i = 0; i < viewwidth; i++) + { + Top[i] = 0; + Bottom[i] = viewheight; + } + + for (auto it = DrawSegments.crbegin(); it != DrawSegments.crend(); ++it) + { + const auto &segment = *it; + if (segment.DrawIndex != -1 && DrawMaskedWall) + { + short *clipTop = ClipValues.data() + segment.ClipOffset; + short *clipBottom = segment.ClipTop ? clipTop + (segment.X2 - segment.X1) : clipTop; + DrawMaskedWall(segment.X1, segment.X2, segment.DrawIndex, clipTop, clipBottom); + } + } +} + +///////////////////////////////////////////////////////////////////////////// + +VisibleSegmentsIterator::VisibleSegmentsIterator(const RenderClipBuffer &buffer, short startx, short endx) : SolidSegments(buffer.SolidSegments), endx(endx) +{ + X1 = startx; + X2 = startx; +} + +bool VisibleSegmentsIterator::Step() +{ + if (next == 0) + { + while (SolidSegments[next].X2 <= X1) + next++; + if (SolidSegments[next].X1 <= X1) + X1 = SolidSegments[next++].X2; + X2 = MIN(SolidSegments[next].X1, endx); + } + else if (X2 == SolidSegments[next].X1 && next + 1 != SolidSegments.size()) + { + X1 = SolidSegments[next++].X2; + X2 = MIN(SolidSegments[next].X1, endx); + } + else + { + X1 = X2; + } + + return X1 < X2; +} + +///////////////////////////////////////////////////////////////////////////// + +RenderVisiblePlane::RenderVisiblePlane(VisiblePlane *plane, FTexture *tex) +{ + const auto &key = plane->Key; + + double xscale = key.Transform.xScale * tex->Scale.X; + double yscale = key.Transform.yScale * tex->Scale.Y; + + double planeang = (key.Transform.Angle + key.Transform.baseAngle).Radians(); + double cosine = cos(planeang); + double sine = sin(planeang); + viewx = (key.Transform.xOffs + ViewPos.X * cosine - ViewPos.Y * sine) * xscale; + viewy = (key.Transform.yOffs - ViewPos.X * sine - ViewPos.Y * cosine) * yscale; + + // left to right mapping + planeang += (ViewAngle - 90).Radians(); + + // Scale will be unit scale at FocalLengthX (normally SCREENWIDTH/2) distance + double xstep = cos(planeang) / FocalLengthX; + double ystep = -sin(planeang) / FocalLengthX; + + // [RH] flip for mirrors + /*if (MirrorFlags & RF_XFLIP) + { + xstep = -xstep; + ystep = -ystep; + }*/ + + planeang += M_PI / 2; + cosine = cos(planeang); + sine = -sin(planeang); + double x = plane->Right - centerx - 0.5; + double rightxfrac = xscale * (cosine + x * xstep); + double rightyfrac = yscale * (sine + x * ystep); + x = plane->Left - centerx - 0.5; + double leftxfrac = xscale * (cosine + x * xstep); + double leftyfrac = yscale * (sine + x * ystep); + + basexfrac = rightxfrac; + baseyfrac = rightyfrac; + xstepscale = (rightxfrac - leftxfrac) / (plane->Right - plane->Left); + ystepscale = (rightyfrac - leftyfrac) / (plane->Right - plane->Left); + + planeheight = fabs(key.Plane.Zat0() - ViewPos.Z); +} + +void RenderVisiblePlane::Step() +{ + basexfrac -= xstepscale; + baseyfrac -= ystepscale; +} + +///////////////////////////////////////////////////////////////////////////// + +void RenderPlanes::Render() +{ + for (int i = 0; i < NumBuckets; i++) + { + VisiblePlane *plane = PlaneBuckets[i].get(); + while (plane) + { + RenderPlane(plane); + plane = plane->Next.get(); + } + } +} + +void RenderPlanes::RenderPlane(VisiblePlane *plane) +{ + FTexture *tex = TexMan(plane->Key.Picnum); + if (tex->UseType == FTexture::TEX_Null) + return; + + RenderVisiblePlane render(plane, tex); + + short spanend[MAXHEIGHT]; + int x = plane->Right - 1; + int t2 = plane->Top[x]; + int b2 = plane->Bottom[x]; + + if (b2 > t2) + { + clearbufshort(spanend + t2, b2 - t2, x); + } + + for (--x; x >= plane->Left; --x) + { + int t1 = plane->Top[x]; + int b1 = plane->Bottom[x]; + const int xr = x + 1; + int stop; + + // Draw any spans that have just closed + stop = MIN(t1, b2); + while (t2 < stop) + { + int y = t2++; + RenderSpan(y, xr, spanend[y], plane->Key, tex, render); + } + stop = MAX(b1, t2); + while (b2 > stop) + { + int y = --b2; + RenderSpan(y, xr, spanend[y], plane->Key, tex, render); + } + + // Mark any spans that have just opened + stop = MIN(t2, b1); + while (t1 < stop) + { + spanend[t1++] = x; + } + stop = MAX(b2, t2); + while (b1 > stop) + { + spanend[--b1] = x; + } + + t2 = plane->Top[x]; + b2 = plane->Bottom[x]; + render.Step(); + } + // Draw any spans that are still open + while (t2 < b2) + { + int y = --b2; + RenderSpan(y, plane->Left, spanend[y], plane->Key, tex, render); + } +} + +void RenderPlanes::RenderSpan(int y, int x1, int x2, const VisiblePlaneKey &key, FTexture *tex, const RenderVisiblePlane &renderInfo) +{ + if (key.Picnum != skyflatnum) + { + double distance = renderInfo.planeheight * yslope[y]; + + double u = distance * renderInfo.basexfrac + renderInfo.viewx; + double v = distance * renderInfo.baseyfrac + renderInfo.viewy; + double uscale = distance * renderInfo.xstepscale; + double vscale = distance * renderInfo.ystepscale; + + double vis = r_FloorVisibility / renderInfo.planeheight; + + if (fixedlightlev >= 0) + R_SetDSColorMapLight(key.ColorMap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + else if (fixedcolormap) + R_SetDSColorMapLight(fixedcolormap, 0, 0); + else + R_SetDSColorMapLight(key.ColorMap, (float)(vis * fabs(CenterY - y)), LIGHT2SHADE(key.LightLevel)); + + ds_source = (const BYTE *)tex->GetPixelsBgra(); + ds_source_mipmapped = false; + ds_xbits = tex->WidthBits; + ds_ybits = tex->HeightBits; + ds_xfrac = (uint32_t)(u * (1 << (32 - ds_xbits))); + ds_yfrac = (uint32_t)(v * (1 << (32 - ds_ybits))); + ds_xstep = (uint32_t)(uscale * (1 << (32 - ds_xbits))); + ds_ystep = (uint32_t)(vscale * (1 << (32 - ds_ybits))); + ds_y = y; + ds_x1 = x1; + ds_x2 = x2; + R_DrawSpan(); + } + else + { + tex = TexMan(sky1texture, true); + + double xangle1 = ((0.5 - x1 / (double)viewwidth) * FocalTangent * 90.0); + double xangle2 = ((0.5 - x2 / (double)viewwidth) * FocalTangent * 90.0); + + double u1 = sky1pos + (ViewAngle.Degrees + xangle1) * sky1cyl / 360.0; + double u2 = sky1pos + (ViewAngle.Degrees + xangle2) * sky1cyl / 360.0; + double u = u1; + double v = (y - CenterY) * skyiscale + skytexturemid * tex->Scale.Y; + double uscale = (u2 - u1) / (x2 - x1); + double vscale = 0.0; + + if (fixedlightlev >= 0) + R_SetDSColorMapLight(key.ColorMap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + else if (fixedcolormap) + R_SetDSColorMapLight(fixedcolormap, 0, 0); + else + R_SetDSColorMapLight(key.ColorMap, 0, 0); + + ds_source = (const BYTE *)tex->GetPixelsBgra(); + ds_source_mipmapped = false; + ds_xbits = tex->WidthBits; + ds_ybits = tex->HeightBits; + ds_xfrac = (uint32_t)(u * (1 << (32 - ds_xbits))); + ds_yfrac = (uint32_t)(v * (1 << (32 - ds_ybits))); + ds_xstep = (uint32_t)(uscale * (1 << (32 - ds_xbits))); + ds_ystep = (uint32_t)(vscale * (1 << (32 - ds_ybits))); + ds_y = y; + ds_x1 = x1; + ds_x2 = x2; + R_DrawSpan(); + } +} + +void RenderPlanes::Clear() +{ + for (int i = 0; i < NumBuckets; i++) + { + std::unique_ptr plane = std::move(PlaneBuckets[i]); + while (plane) + { + std::unique_ptr next = std::move(plane->Next); + FreePlanes.push_back(std::move(plane)); + plane = std::move(next); + } + } +} + +void RenderPlanes::MarkCeilingPlane(const VisiblePlaneKey &key, const RenderClipBuffer &clip, const WallCoords &wallCoords) +{ + VisibleSegmentsIterator it(clip, wallCoords.ScreenX1, wallCoords.ScreenX2); + while (it.Step()) + { + VisiblePlane *plane = GetPlaneWithUnsetRange(key, it.X1, it.X2); + + for (short x = it.X1; x < it.X2; x++) + { + short walltop = MAX(wallCoords.Y1(x), clip.Top[x]); + short top = clip.Top[x]; + short bottom = MIN(walltop, clip.Bottom[x]); + if (top < bottom) + { + plane->Top[x] = top; + plane->Bottom[x] = bottom; + } + } + } +} + +void RenderPlanes::MarkFloorPlane(const VisiblePlaneKey &key, const RenderClipBuffer &clip, const WallCoords &wallCoords) +{ + VisibleSegmentsIterator it(clip, wallCoords.ScreenX1, wallCoords.ScreenX2); + while (it.Step()) + { + VisiblePlane *plane = GetPlaneWithUnsetRange(key, it.X1, it.X2); + + for (short x = it.X1; x < it.X2; x++) + { + short wallbottom = MIN(wallCoords.Y2(x), clip.Bottom[x]); + short top = MAX(wallbottom, clip.Top[x]); + short bottom = clip.Bottom[x]; + if (top < bottom) + { + plane->Top[x] = top; + plane->Bottom[x] = bottom; + } + } + } +} + +VisiblePlane *RenderPlanes::GetPlaneWithUnsetRange(const VisiblePlaneKey &key, int start, int stop) +{ + VisiblePlane *plane = GetPlane(key); + + int intrl, intrh; + int unionl, unionh; + + if (start < plane->Left) + { + intrl = plane->Left; + unionl = start; + } + else + { + unionl = plane->Left; + intrl = start; + } + + if (stop > plane->Right) + { + intrh = plane->Right; + unionh = stop; + } + else + { + unionh = plane->Right; + intrh = stop; + } + + // Verify that the entire range has unset values + int x = intrl; + while (x < intrh && plane->Top[x] == VisiblePlane::UnsetValue) + x++; + + if (x >= intrh) // They do. Use the current plane + { + plane->Left = unionl; + plane->Right = unionh; + return plane; + } + else // Create new plane and make sure it is found first + { + auto &bucket = PlaneBuckets[Hash(key)]; + std::unique_ptr newPlane = AllocPlane(key); + newPlane->Left = start; + newPlane->Right = stop; + newPlane->Next = std::move(bucket); + bucket = std::move(newPlane); + return bucket.get(); + } +} + +VisiblePlane *RenderPlanes::GetPlane(const VisiblePlaneKey &key) +{ + auto &bucket = PlaneBuckets[Hash(key)]; + VisiblePlane *plane = bucket.get(); + + while (plane != nullptr) + { + if (plane->Key == key) + return plane; + plane = plane->Next.get(); + } + + std::unique_ptr new_plane = AllocPlane(key); + new_plane->Next = std::move(bucket); + bucket = std::move(new_plane); + return bucket.get(); +} + +std::unique_ptr RenderPlanes::AllocPlane(const VisiblePlaneKey &key) +{ + if (!FreePlanes.empty()) + { + std::unique_ptr plane = std::move(FreePlanes.back()); + FreePlanes.pop_back(); + plane->Clear(key); + return std::move(plane); + } + else + { + return std::make_unique(key); + } +} + +///////////////////////////////////////////////////////////////////////////// + +void RenderWall::Render(const RenderClipBuffer &clip) +{ + FTexture *tex = GetTexture(); + if (!tex) + return; + int texWidth = tex->GetWidth(); + int texHeight = tex->GetHeight(); + + WallTextureCoords texcoords(tex, Line, Texpart, TopZ, BottomZ, UnpeggedCeil); + + VisibleSegmentsIterator it(clip, Coords.ScreenX1, Coords.ScreenX2); + while (it.Step()) + { + for (short x = it.X1; x < it.X2; x++) + { + short y1 = MAX(Coords.Y1(x), clip.Top[x]); + short y2 = MIN(Coords.Y2(x), clip.Bottom[x]); + if (y1 >= y2) + continue; + + double u = Coords.VaryingX(x, texcoords.u1, texcoords.u2); + double v1 = Coords.VaryingY(x, y1, texcoords.v1, texcoords.v2); + double v2 = Coords.VaryingY(x, y2, texcoords.v1, texcoords.v2); + + R_SetColorMapLight(Colormap, GetLight(x), GetShade()); + + dc_source = (const BYTE *)tex->GetColumnBgra((int)(u * texWidth), nullptr); + dc_source2 = nullptr; + dc_textureheight = texHeight; + dc_texturefrac = (uint32_t)(v1 * 0xffffffff); + dc_iscale = (uint32_t)((v2 - v1) / (y2 - y1) * 0xffffffff); + dc_dest = dc_destorg + (ylookup[y1] + x) * 4; + dc_count = y2 - y1; + dovline1(); + } + } +} + +void RenderWall::RenderMasked(short x1, short x2, const short *clipTop, const short *clipBottom) +{ + FTexture *tex = GetTexture(); + if (!tex) + return; + int texWidth = tex->GetWidth(); + int texHeight = tex->GetHeight(); + + WallTextureCoords texcoords(tex, Line, Texpart, TopZ, BottomZ, UnpeggedCeil); + + for (short x = x1; x < x2; x++) + { + short y1 = MAX(Coords.Y1(x), clipTop[x - x1]); + short y2 = MIN(Coords.Y2(x), clipBottom[x - x1]); + if (y1 >= y2) + continue; + + double u = Coords.VaryingX(x, texcoords.u1, texcoords.u2); + double v1 = Coords.VaryingY(x, y1, texcoords.v1, texcoords.v2); + double v2 = Coords.VaryingY(x, y2, texcoords.v1, texcoords.v2); + + R_SetColorMapLight(Colormap, GetLight(x), GetShade()); + + dc_source = (const BYTE *)tex->GetColumnBgra((int)(u * texWidth), nullptr); + dc_source2 = nullptr; + dc_textureheight = texHeight; + dc_texturefrac = (uint32_t)(v1 * 0xffffffff); + dc_iscale = (uint32_t)((v2 - v1) / (y2 - y1) * 0xffffffff); + dc_dest = dc_destorg + (ylookup[y1] + x) * 4; + dc_count = y2 - y1; + domvline1(); + } +} + +FTexture *RenderWall::GetTexture() +{ + FTexture *tex = TexMan(Line->sidedef->GetTexture(Texpart), true); + if (tex == nullptr || tex->UseType == FTexture::TEX_Null) + return nullptr; + else + return tex; +} + +int RenderWall::GetShade() +{ + if (fixedlightlev >= 0 || fixedcolormap) + { + return 0; + } + else + { + bool foggy = false; + int actualextralight = foggy ? 0 : extralight << 4; + int shade = LIGHT2SHADE(Line->sidedef->GetLightLevel(foggy, Line->frontsector->lightlevel) + actualextralight); + return shade; + } +} + +float RenderWall::GetLight(short x) +{ + if (fixedlightlev >= 0 || fixedcolormap) + return 0.0f; + else + return (float)(r_WallVisibility / Coords.Z(x)); +} + +///////////////////////////////////////////////////////////////////////////// + +VisibleSprite::VisibleSprite(AActor *actor, const DVector3 &eyePos) : Actor(actor), EyePos(eyePos) +{ +} + +void VisibleSprite::Render(RenderClipBuffer *clip) +{ + //if (MirrorFlags & RF_XFLIP) + // tx = -tx; + + bool flipTextureX = false; + FTexture *tex = GetSpriteTexture(Actor, flipTextureX); + DVector2 spriteScale = Actor->Scale; + + const double thingxscalemul = spriteScale.X / tex->Scale.X; + + double xscale = CenterX / EyePos.Z; + double yscale = spriteScale.Y / tex->Scale.Y;// spriteScale.Y / tex->Scale.Y * InvZtoScale / EyePos.Z; + + double tx; + if (flipTextureX) + { + tx = EyePos.X - (tex->GetWidth() - tex->LeftOffset - 1) * thingxscalemul; + } + else + { + tx = EyePos.X - tex->LeftOffset * thingxscalemul; + } + + double texturemid = tex->TopOffset + (EyePos.Y - Actor->Floorclip) / yscale; + double y = CenterY - texturemid * (InvZtoScale * yscale / EyePos.Z); + + int x1 = centerx + xs_RoundToInt(tx * xscale); + int x2 = centerx + xs_RoundToInt((tx + tex->GetWidth() * thingxscalemul) * xscale); + int y1 = xs_RoundToInt(y); + int y2 = xs_RoundToInt(y + (InvZtoScale * yscale / EyePos.Z) * tex->GetHeight()); + + xscale = spriteScale.X * xscale / tex->Scale.X; + + int clipped_x1 = clamp(x1, 0, viewwidth - 1); + int clipped_x2 = clamp(x2, 0, viewwidth - 1); + int clipped_y1 = clamp(y1, 0, viewheight - 1); + int clipped_y2 = clamp(y2, 0, viewheight - 1); + if (clipped_x1 >= clipped_x2 || clipped_y1 >= clipped_y2) + return; + + clip->SetupSpriteClip(clipped_x1, clipped_x2, EyePos, false); + + uint32_t texwidth = tex->GetWidth(); + uint32_t texheight = tex->GetHeight(); + + visstyle_t visstyle = GetSpriteVisStyle(Actor, EyePos.Z); + // Rumor has it that AlterWeaponSprite needs to be called with visstyle passed in somewhere around here.. + R_SetColorMapLight(visstyle.BaseColormap, 0, visstyle.ColormapNum << FRACBITS); + + for (int x = clipped_x1; x < clipped_x2; x++) + { + short top = MAX(clipped_y1, clip->Top[x]); + short bottom = MIN(clipped_y2, clip->Bottom[x]); + if (top < bottom) + { + float u = (x - x1) / (float)(x2 - x1); + float v = (top - y1) / (float)(y2 - y1); + if (flipTextureX) + u = 1.0f - u; + u = u - floor(u); + + dc_source = (const BYTE *)tex->GetColumnBgra((int)(u * texwidth), nullptr); + dc_source2 = nullptr; + dc_textureheight = texheight; + dc_texturefrac = (uint32_t)(v * 0xffffffff); + dc_iscale = 0xffffffff / (y2 - y1); + dc_dest = dc_destorg + (ylookup[top] + x) * 4; + dc_count = bottom - top; + domvline1(); + } + } +} + +visstyle_t VisibleSprite::GetSpriteVisStyle(AActor *thing, double z) +{ + visstyle_t visstyle; + + bool foggy = false; + int actualextralight = foggy ? 0 : extralight << 4; + int spriteshade = LIGHT2SHADE(thing->Sector->lightlevel + actualextralight); + + visstyle.RenderStyle = thing->RenderStyle; + visstyle.Alpha = float(thing->Alpha); + visstyle.ColormapNum = 0; + + // The software renderer cannot invert the source without inverting the overlay + // too. That means if the source is inverted, we need to do the reverse of what + // the invert overlay flag says to do. + bool invertcolormap = (visstyle.RenderStyle.Flags & STYLEF_InvertOverlay) != 0; + + if (visstyle.RenderStyle.Flags & STYLEF_InvertSource) + { + invertcolormap = !invertcolormap; + } + + FDynamicColormap *mybasecolormap = thing->Sector->ColorMap; + + // Sprites that are added to the scene must fade to black. + if (visstyle.RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0) + { + mybasecolormap = GetSpecialLights(mybasecolormap->Color, 0, mybasecolormap->Desaturate); + } + + if (visstyle.RenderStyle.Flags & STYLEF_FadeToBlack) + { + if (invertcolormap) + { // Fade to white + mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(255, 255, 255), mybasecolormap->Desaturate); + invertcolormap = false; + } + else + { // Fade to black + mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(0, 0, 0), mybasecolormap->Desaturate); + } + } + + // get light level + if (fixedcolormap != NULL) + { // fixed map + visstyle.BaseColormap = fixedcolormap; + visstyle.ColormapNum = 0; + } + else + { + if (invertcolormap) + { + mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate); + } + if (fixedlightlev >= 0) + { + visstyle.BaseColormap = mybasecolormap; + visstyle.ColormapNum = fixedlightlev >> COLORMAPSHIFT; + } + else if (!foggy && ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) + { // full bright + visstyle.BaseColormap = mybasecolormap; + visstyle.ColormapNum = 0; + } + else + { // diminished light + double minz = double((2048 * 4) / double(1 << 20)); + visstyle.ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(z, minz), spriteshade); + visstyle.BaseColormap = mybasecolormap; + } + } + + return visstyle; +} + +FTexture *VisibleSprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX) +{ + flipX = false; + if (thing->picnum.isValid()) + { + FTexture *tex = TexMan(thing->picnum); + if (tex->UseType == FTexture::TEX_Null) + { + return nullptr; + } + + if (tex->Rotations != 0xFFFF) + { + // choose a different rotation based on player view + spriteframe_t *sprframe = &SpriteFrames[tex->Rotations]; + DVector3 pos = thing->InterpolatedPosition(r_TicFracF); + pos.Z += thing->GetBobOffset(r_TicFracF); + DAngle ang = (pos - ViewPos).Angle(); + angle_t rot; + if (sprframe->Texture[0] == sprframe->Texture[1]) + { + rot = (ang - thing->Angles.Yaw + 45.0 / 2 * 9).BAMs() >> 28; + } + else + { + rot = (ang - thing->Angles.Yaw + (45.0 / 2 * 9 - 180.0 / 16)).BAMs() >> 28; + } + flipX = (sprframe->Flip & (1 << rot)) != 0; + tex = TexMan[sprframe->Texture[rot]]; // Do not animate the rotation + } + return tex; + } + else + { + // decide which texture to use for the sprite + int spritenum = thing->sprite; + if (spritenum >= (signed)sprites.Size() || spritenum < 0) + return nullptr; + + spritedef_t *sprdef = &sprites[spritenum]; + if (thing->frame >= sprdef->numframes) + { + // If there are no frames at all for this sprite, don't draw it. + return nullptr; + } + else + { + //picnum = SpriteFrames[sprdef->spriteframes + thing->frame].Texture[0]; + // choose a different rotation based on player view + spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + thing->frame]; + DVector3 pos = thing->InterpolatedPosition(r_TicFracF); + pos.Z += thing->GetBobOffset(r_TicFracF); + DAngle ang = (pos - ViewPos).Angle(); + angle_t rot; + if (sprframe->Texture[0] == sprframe->Texture[1]) + { + rot = (ang - thing->Angles.Yaw + 45.0 / 2 * 9).BAMs() >> 28; + } + else + { + rot = (ang - thing->Angles.Yaw + (45.0 / 2 * 9 - 180.0 / 16)).BAMs() >> 28; + } + flipX = (sprframe->Flip & (1 << rot)) != 0; + return TexMan[sprframe->Texture[rot]]; // Do not animate the rotation + } + } +} + +///////////////////////////////////////////////////////////////////////////// + +void ScreenSprite::Render() +{ + FSpecialColormap *special = nullptr; + FColormapStyle colormapstyle; + PalEntry overlay = 0; + bool usecolormapstyle = false; + if (visstyle.BaseColormap >= &SpecialColormaps[0] && + visstyle.BaseColormap < &SpecialColormaps[SpecialColormaps.Size()]) + { + special = static_cast(visstyle.BaseColormap); + } + else if (Colormap->Color == PalEntry(255, 255, 255) && + Colormap->Desaturate == 0) + { + overlay = Colormap->Fade; + overlay.a = BYTE(visstyle.ColormapNum * 255 / NUMCOLORMAPS); + } + else + { + usecolormapstyle = true; + colormapstyle.Color = Colormap->Color; + colormapstyle.Fade = Colormap->Fade; + colormapstyle.Desaturate = Colormap->Desaturate; + colormapstyle.FadeLevel = visstyle.ColormapNum / float(NUMCOLORMAPS); + } + + screen->DrawTexture(Pic, + X1, + Y1, + DTA_DestWidthF, Width, + DTA_DestHeightF, Height, + DTA_Translation, Translation, + DTA_FlipX, Flip, + DTA_TopOffset, 0, + DTA_LeftOffset, 0, + DTA_ClipLeft, viewwindowx, + DTA_ClipTop, viewwindowy, + DTA_ClipRight, viewwindowx + viewwidth, + DTA_ClipBottom, viewwindowy + viewheight, + DTA_AlphaF, visstyle.Alpha, + DTA_RenderStyle, visstyle.RenderStyle, + DTA_FillColor, FillColor, + DTA_SpecialColormap, special, + DTA_ColorOverlay, overlay.d, + DTA_ColormapStyle, usecolormapstyle ? &colormapstyle : NULL, + TAG_DONE); +} diff --git a/src/r_swrenderer2.h b/src/r_swrenderer2.h new file mode 100644 index 000000000..1004b66bd --- /dev/null +++ b/src/r_swrenderer2.h @@ -0,0 +1,345 @@ + +#pragma once + +#include +#include +#include +#include +#include "doomdata.h" +#include "r_utility.h" +#include "r_main.h" + +// Transform for a view position and its viewport +// +// World space uses map coordinates in the XY plane. Z is up. +// Eye space means relative to viewer, Y is up and Z is into the screen. +// Viewport means in normalized device coordinates (-1 to 1 range with perspective division). 0,0 is in the center of the viewport and Y is still up. +// Screen means in final screen coordinates. 0,0 is the upper left corner and Y is down. Z is still 1/z. +// +class ViewPosTransform +{ +public: + DVector3 WorldToEye(const DVector3 &worldPoint) const; + DVector3 WorldToViewport(const DVector3 &worldPoint) const { return EyeToViewport(WorldToEye(worldPoint)); } + DVector3 WorldToScreen(const DVector3 &worldPoint) const { return EyeToScreen(WorldToEye(worldPoint)); } + + DVector3 EyeToViewport(const DVector3 &eyePoint) const; + DVector3 EyeToScreen(const DVector3 &eyePoint) const { return ViewportToScreen(EyeToViewport(eyePoint)); } + + DVector3 ViewportToScreen(const DVector3 &viewportPoint) const; + + double ScreenXToEye(int x, double z) const; + double ScreenYToEye(int y, double z) const; + + double NearZ() const { return 0.0078125; }; +}; + +// Screen space coordinates for a wall +class WallCoords +{ +public: + WallCoords() = default; + WallCoords(const ViewPosTransform &transform, const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2); + + // True if transform and clip culled the wall + bool Culled = true; + + // Plane for wall in eye space + DVector3 PlaneNormal; + double PlaneD = 0.0; + + // Z range of the wall in eye space + double NearZ = 0.0; + double FarZ = 0.0; + + // Screen space bounding box of the wall + int ScreenX1 = 0; + int ScreenX2 = 0; + int ScreenY1 = 0; + int ScreenY2 = 0; + + // Get the Y positions for the given column + short Y1(int x) const; + short Y2(int x) const; + + // Get the depth for a column + double Z(int x) const; + + // Perspective correct interpolation from start to end (used to calculate texture coordinates) + double VaryingX(int x, double start, double end) const; + double VaryingY(int x, int y, double start, double end) const; + +private: + static DVector3 Mix(const DVector3 &a, const DVector3 &b, double t); + static double Mix(double a, double b, double t); + + ViewPosTransform Transform; + DVector3 ScreenTopLeft; + DVector3 ScreenTopRight; + DVector3 ScreenBottomLeft; + DVector3 ScreenBottomRight; + double RcpDeltaScreenX = 0.0; + double VaryingXScale = 1.0; + double VaryingXOffset = 0.0; +}; + +// Texture coordinates for a wall +class WallTextureCoords +{ +public: + WallTextureCoords(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil); + + double u1, u2; + double v1, v2; + +private: + void CalcU(FTexture *tex, const seg_t *line, side_t::ETexpart texpart); + void CalcV(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil); + void CalcVTopPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset); + void CalcVMidPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset); + void CalcVBottomPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double unpeggedceil, double vscale, double yoffset); +}; + +// Clipping buffers used during rendering +class RenderClipBuffer +{ +public: + void Clear(short left, short right); + void MarkSegmentCulled(const WallCoords &wallCoords, int drawIndex); + void ClipVertical(const WallCoords &wallCoords, int drawIndex); + void ClipTop(const WallCoords &wallCoords, int drawIndex); + void ClipBottom(const WallCoords &wallCoords, int drawIndex); + bool IsSegmentCulled(short x1, short x2) const; + + void SetupSpriteClip(short x1, short x2, const DVector3 &pos, bool wallSprite); + void RenderMaskedWalls(); + + short Top[MAXWIDTH]; + short Bottom[MAXWIDTH]; + + std::function DrawMaskedWall; + +private: + void AddDrawSegment(short x1, short x2, const WallCoords &wall, bool clipTop, bool clipBottom, int drawIndex); + + struct SolidSegment + { + SolidSegment(short x1, short x2) : X1(x1), X2(x2) { } + short X1, X2; + }; + + struct DrawSegment + { + short X1; + short X2; + int ClipOffset; + bool ClipTop; + bool ClipBottom; + DVector3 PlaneNormal; + double PlaneD; + double NearZ; + double FarZ; + int DrawIndex; + }; + + std::vector SolidSegments; + std::vector DrawSegments; + std::vector ClipValues; + + friend class VisibleSegmentsIterator; +}; + +// Walks the visible segments in a range +class VisibleSegmentsIterator +{ +public: + VisibleSegmentsIterator(const RenderClipBuffer &buffer, short startx, short endx); + bool Step(); + + short X1; + short X2; + +private: + const std::vector &SolidSegments; + short endx; + int next = 0; +}; + +// Class used to group sector ceilings/floors sharing common properties +class VisiblePlaneKey +{ +public: + VisiblePlaneKey() { } + VisiblePlaneKey(FTextureID picnum, FSWColormap *colormap, int lightlevel, secplane_t plane, const FTransform &xform) : Picnum(picnum), ColorMap(colormap), LightLevel(lightlevel), Plane(plane), Transform(xform) { } + + bool operator==(const VisiblePlaneKey &other) const + { + return Picnum == other.Picnum && LightLevel == other.LightLevel && Plane.fD() == other.Plane.fD(); + } + + FTextureID Picnum; + FSWColormap *ColorMap; + int LightLevel; + secplane_t Plane; + FTransform Transform; +}; + +// Visible plane to be rendered +class VisiblePlane +{ +public: + VisiblePlane(const VisiblePlaneKey &key) { Clear(key); } + + void Clear(const VisiblePlaneKey &key) + { + Key = key; + Left = viewwidth; + Right = 0; + for (int i = 0; i < MAXWIDTH; i++) + { + Top[i] = UnsetValue; + Bottom[i] = 0; + } + } + + VisiblePlaneKey Key; + + enum { UnsetValue = 0x7fff }; + short Left; + short Right; + short Top[MAXWIDTH]; + short Bottom[MAXWIDTH]; + std::unique_ptr Next; +}; + +class RenderVisiblePlane +{ +public: + RenderVisiblePlane(VisiblePlane *plane, FTexture *tex); + void Step(); + + double viewx; + double viewy; + double planeheight; + double basexfrac; + double baseyfrac; + double xstepscale; + double ystepscale; +}; + +// Tracks plane locations and renders them +class RenderPlanes +{ +public: + void Clear(); + void MarkCeilingPlane(const VisiblePlaneKey &key, const RenderClipBuffer &clip, const WallCoords &wallCoords); + void MarkFloorPlane(const VisiblePlaneKey &key, const RenderClipBuffer &clip, const WallCoords &wallCoords); + void Render(); + +private: + void RenderPlane(VisiblePlane *plane); + void RenderSpan(int y, int x1, int x2, const VisiblePlaneKey &key, FTexture *texture, const RenderVisiblePlane &renderInfo); + + VisiblePlane *GetPlaneWithUnsetRange(const VisiblePlaneKey &key, int x0, int x1); + VisiblePlane *GetPlane(const VisiblePlaneKey &key); + std::unique_ptr AllocPlane(const VisiblePlaneKey &key); + static uint32_t Hash(const VisiblePlaneKey &key) { return ((unsigned)((key.Picnum.GetIndex()) * 3 + (key.LightLevel) + (FLOAT2FIXED(key.Plane.fD())) * 7) & (NumBuckets - 1)); } + + enum { NumBuckets = 128 /* must be a power of 2 */ }; + std::unique_ptr PlaneBuckets[NumBuckets]; + std::vector> FreePlanes; +}; + +// Renders a wall texture +class RenderWall +{ +public: + void Render(const RenderClipBuffer &clip); + void RenderMasked(short x1, short x2, const short *clipTop, const short *clipBottom); + + WallCoords Coords; + const seg_t *Line; + side_t::ETexpart Texpart; + double TopZ; + double BottomZ; + double UnpeggedCeil; + FSWColormap *Colormap; + bool Masked; + +private: + FTexture *GetTexture(); + int GetShade(); + float GetLight(short x); +}; + +// Sprite thing to be rendered +class VisibleSprite +{ +public: + VisibleSprite(AActor *actor, const DVector3 &eyePos); + void Render(RenderClipBuffer *clip); + +private: + AActor *Actor; + DVector3 EyePos; + + FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); + visstyle_t GetSpriteVisStyle(AActor *thing, double z); + + friend class RenderBsp; // For sorting +}; + +// DScreen accelerated sprite to be rendered +class ScreenSprite +{ +public: + void Render(); + + FTexture *Pic = nullptr; + double X1 = 0.0; + double Y1 = 0.0; + double Width = 0.0; + double Height = 0.0; + FRemapTable *Translation = nullptr; + bool Flip = false; + visstyle_t visstyle; + uint32_t FillColor = 0; + FDynamicColormap *Colormap = nullptr; +}; + +// Renders a BSP tree in a scene +class RenderBsp +{ +public: + void Render(); + void RenderScreenSprites(); + +private: + void RenderNode(void *node); + void RenderSubsector(subsector_t *sub); + void AddLine(seg_t *line, sector_t *frontsector); + + void AddSprite(AActor *thing); + void AddWallSprite(AActor *thing); + bool IsThingCulled(AActor *thing); + void RenderMaskedObjects(); + + void RenderPlayerSprites(); + void RenderPlayerSprite(DPSprite *sprite, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac); + + int PointOnSide(const DVector2 &pos, const node_t *node); + + // Checks BSP node/subtree bounding box. + // Returns true if some part of the bbox might be visible. + bool CheckBBox(float *bspcoord); + + ViewPosTransform Transform; + RenderClipBuffer Clip; + RenderPlanes Planes; + std::vector VisibleSprites; + std::vector VisibleMaskedWalls; + std::vector ScreenSprites; + + const int BaseXCenter = 160; + const int BaseYCenter = 100; +}; From 8907a8bfe8ee9b3b8ffd672c252e1cfd2f189b9c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Sep 2016 12:09:53 +0200 Subject: [PATCH 0964/1509] - fixed incorrect function name in sprites drawer. - fixed duplicate property key in ADynamicLight serializer. Radius was already claimed by AActor so this needs a different name. --- src/gl/dynlights/a_dynlight.cpp | 2 +- src/gl/scene/gl_sprite.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 36ef1b948..20d0d6078 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -163,7 +163,7 @@ void ADynamicLight::Serialize(FSerializer &arc) ("lighttype", lighttype, def->lighttype) ("tickcount", m_tickCount, def->m_tickCount) ("currentradius", m_currentRadius, def->m_currentRadius) - .Array("radius", m_Radius, def->m_Radius, 2); + .Array("lightradius", m_Radius, def->m_Radius, 2); if (lighttype == PulseLight) arc("lastupdate", m_lastUpdate, def->m_lastUpdate) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 706fb33e4..19753f742 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -636,7 +636,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) sector_t * rendersector; // Don't waste time projecting sprites that are definitely not visible. - if (thing == nullptr || thing->sprite == 0 || !thing->IsVisibleToPlayer() || !thing->IsInsideVisibleAngle()) + if (thing == nullptr || thing->sprite == 0 || !thing->IsVisibleToPlayer() || !thing->IsInsideVisibleAngles()) { return; } From 9076d462619a5c9a4020c28477365c2efa568ce1 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 29 Aug 2016 13:10:22 +0200 Subject: [PATCH 0965/1509] Added SSAO pass --- src/CMakeLists.txt | 1 + src/gl/renderer/gl_postprocess.cpp | 107 ++++++++++- src/gl/renderer/gl_renderbuffers.cpp | 221 +++++++++++++++++----- src/gl/renderer/gl_renderbuffers.h | 24 ++- src/gl/renderer/gl_renderer.cpp | 5 + src/gl/renderer/gl_renderer.h | 9 + src/gl/scene/gl_scene.cpp | 9 +- src/gl/shaders/gl_ambientshader.cpp | 89 +++++++++ src/gl/shaders/gl_ambientshader.h | 39 ++++ src/gl/stereo3d/gl_stereo3d.cpp | 2 +- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.zz | 1 + wadsrc/static/shaders/glsl/lineardepth.fp | 16 ++ wadsrc/static/shaders/glsl/ssao.fp | 117 ++++++++++++ 14 files changed, 580 insertions(+), 61 deletions(-) create mode 100644 src/gl/shaders/gl_ambientshader.cpp create mode 100644 src/gl/shaders/gl_ambientshader.h create mode 100644 wadsrc/static/shaders/glsl/lineardepth.fp create mode 100644 wadsrc/static/shaders/glsl/ssao.fp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 73dba07c4..039a03b52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1125,6 +1125,7 @@ set( FASTMATH_SOURCES gl/shaders/gl_shaderprogram.cpp gl/shaders/gl_presentshader.cpp gl/shaders/gl_bloomshader.cpp + gl/shaders/gl_ambientshader.cpp gl/shaders/gl_blurshader.cpp gl/shaders/gl_colormapshader.cpp gl/shaders/gl_tonemapshader.cpp diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 7ce8be0ad..9df28ce5b 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -55,6 +55,7 @@ #include "gl/renderer/gl_postprocessstate.h" #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" +#include "gl/shaders/gl_ambientshader.h" #include "gl/shaders/gl_bloomshader.h" #include "gl/shaders/gl_blurshader.h" #include "gl/shaders/gl_tonemapshader.h" @@ -98,6 +99,20 @@ CVAR(Float, gl_lens_k, -0.12f, 0) CVAR(Float, gl_lens_kcube, 0.1f, 0) CVAR(Float, gl_lens_chromatic, 1.12f, 0) +CVAR(Bool, gl_ssao, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, gl_ssao_debug, false, 0) +CVAR(Float, gl_ssao_bias, 0.5f, 0) +CVAR(Float, gl_ssao_radius, 100.0f, 0) +CUSTOM_CVAR(Float, gl_ssao_blur_amount, 6.0f, 0) +{ + if (self < 0.1f) self = 0.1f; +} +CUSTOM_CVAR(Int, gl_ssao_blur_samples, 9, 0) +{ + if (self < 3 || self > 15 || self % 2 == 0) + self = 9; +} + EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) @@ -109,6 +124,96 @@ void FGLRenderer::RenderScreenQuad() GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); } +void FGLRenderer::PostProcessScene() +{ + if (FGLRenderBuffers::IsEnabled()) mBuffers->BlitSceneToTexture(); + AmbientOccludeScene(); + UpdateCameraExposure(); + BloomScene(); + TonemapScene(); + LensDistortScene(); +} + +//----------------------------------------------------------------------------- +// +// Adds ambient occlusion to the scene +// +//----------------------------------------------------------------------------- + +void FGLRenderer::AmbientOccludeScene() +{ + if (!gl_ssao || !FGLRenderBuffers::IsEnabled()) + return; + + FGLDebug::PushGroup("AmbientOccludeScene"); + + FGLPostProcessState savedState; + + float bias = gl_ssao_bias; + float aoRadius = gl_ssao_radius; + const float blurAmount = gl_ssao_blur_amount; + int blurSampleCount = gl_ssao_blur_samples; + + //float tanHalfFovy = tan(fovy * (M_PI / 360.0f)); + float tanHalfFovy = 1.0f / 1.33333302f; //gl_RenderState.mProjectionMatrix.get()[5]; + float invFocalLenX = tanHalfFovy * (mBuffers->AmbientWidth / (float)mBuffers->AmbientHeight); + float invFocalLenY = tanHalfFovy; + float nDotVBias = clamp(bias, 0.0f, 1.0f); + float r2 = aoRadius * aoRadius; + + // Calculate linear depth values + glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB0); + glViewport(0, 0, mBuffers->AmbientWidth, mBuffers->AmbientHeight); + mBuffers->BindSceneDepthTexture(0); + mLinearDepthShader->Bind(); + mLinearDepthShader->DepthTexture.Set(0); + mLinearDepthShader->LinearizeDepthA.Set(1.0f / GetZFar() - 1.0f / GetZNear()); + mLinearDepthShader->LinearizeDepthB.Set(MAX(1.0f / GetZNear(), 1.e-8f)); + mLinearDepthShader->InverseDepthRangeA.Set(1.0f); + mLinearDepthShader->InverseDepthRangeB.Set(0.0f); + RenderScreenQuad(); + + // Apply ambient occlusion + glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB1); + glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + mSSAOShader->Bind(); + mSSAOShader->DepthTexture.Set(0); + mSSAOShader->UVToViewA.Set(2.0f * invFocalLenX, -2.0f * invFocalLenY); + mSSAOShader->UVToViewB.Set(-invFocalLenX, invFocalLenY); + mSSAOShader->InvFullResolution.Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); + mSSAOShader->NDotVBias.Set(nDotVBias); + mSSAOShader->NegInvR2.Set(-1.0f / r2); + mSSAOShader->RadiusToScreen.Set(aoRadius * 0.5 / tanHalfFovy * mBuffers->AmbientHeight); + mSSAOShader->AOMultiplier.Set(1.0f / (1.0f - nDotVBias)); + RenderScreenQuad(); + + // Blur SSAO texture + mBlurShader->BlurHorizontal(this, blurAmount, blurSampleCount, mBuffers->AmbientTexture1, mBuffers->AmbientFB0, mBuffers->AmbientWidth, mBuffers->AmbientHeight); + mBlurShader->BlurVertical(this, blurAmount, blurSampleCount, mBuffers->AmbientTexture0, mBuffers->AmbientFB1, mBuffers->AmbientWidth, mBuffers->AmbientHeight); + + // Add SSAO back to scene texture: + mBuffers->BindCurrentFB(); + glViewport(mSceneViewport.left, mSceneViewport.top, mSceneViewport.width, mSceneViewport.height); + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + if (gl_ssao_debug) + glBlendFunc(GL_ONE, GL_ZERO); + else + glBlendFunc(GL_ZERO, GL_SRC_COLOR); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mBloomCombineShader->Bind(); + mBloomCombineShader->BloomTexture.Set(0); + RenderScreenQuad(); + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + + FGLDebug::PopGroup(); +} + //----------------------------------------------------------------------------- // // Extracts light average from the scene and updates the camera exposure texture @@ -190,7 +295,7 @@ void FGLRenderer::UpdateCameraExposure() void FGLRenderer::BloomScene() { // Only bloom things if enabled and no special fixed light mode is active - if (!gl_bloom || gl_fixedcolormap != CM_DEFAULT) + if (!gl_bloom || gl_fixedcolormap != CM_DEFAULT || gl_ssao_debug) return; FGLDebug::PushGroup("BloomScene"); diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index b2471e4b9..54d597c4d 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -40,6 +40,7 @@ #include "w_wad.h" #include "i_system.h" #include "doomerrors.h" +#include CVAR(Int, gl_multisample, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); CVAR(Bool, gl_renderbuffers, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) @@ -75,15 +76,16 @@ FGLRenderBuffers::~FGLRenderBuffers() ClearEyeBuffers(); ClearBloom(); ClearExposureLevels(); + ClearAmbientOcclusion(); } void FGLRenderBuffers::ClearScene() { DeleteFrameBuffer(mSceneFB); - DeleteRenderBuffer(mSceneMultisample); - DeleteRenderBuffer(mSceneDepthStencil); - DeleteRenderBuffer(mSceneDepth); - DeleteRenderBuffer(mSceneStencil); + DeleteFrameBuffer(mSceneDataFB); + DeleteTexture(mSceneMultisample); + DeleteTexture(mSceneData); + DeleteTexture(mSceneDepthStencil); } void FGLRenderBuffers::ClearPipeline() @@ -132,6 +134,15 @@ void FGLRenderBuffers::ClearEyeBuffers() mEyeFBs.Clear(); } +void FGLRenderBuffers::ClearAmbientOcclusion() +{ + DeleteFrameBuffer(AmbientFB0); + DeleteFrameBuffer(AmbientFB1); + DeleteTexture(AmbientTexture0); + DeleteTexture(AmbientTexture1); + DeleteTexture(AmbientRandomTexture); +} + void FGLRenderBuffers::DeleteTexture(GLuint &handle) { if (handle != 0) @@ -203,6 +214,7 @@ bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei { CreateBloom(sceneWidth, sceneHeight); CreateExposureLevels(sceneWidth, sceneHeight); + CreateAmbientOcclusion(sceneWidth, sceneHeight); mSceneWidth = sceneWidth; mSceneHeight = sceneHeight; } @@ -240,10 +252,19 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples) ClearScene(); if (samples > 1) - mSceneMultisample = CreateRenderBuffer("SceneMultisample", GL_RGBA16F, samples, width, height); + { + mSceneMultisample = Create2DMultisampleTexture("SceneMultisample", GL_RGBA16F, width, height, samples, false); + mSceneDepthStencil = Create2DMultisampleTexture("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height, samples, false); + mSceneData = Create2DMultisampleTexture("SceneSSAOData", GL_RGBA8, width, height, samples, false); + } + else + { + mSceneDepthStencil = Create2DTexture("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height); + mSceneData = Create2DTexture("SceneSSAOData", GL_RGBA8, width, height); + } - mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, samples, width, height); - mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1); + mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], 0, mSceneDepthStencil, samples > 1); + mSceneDataFB = CreateFrameBuffer("SSAOSceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneData, mSceneDepthStencil, samples > 1); } //========================================================================== @@ -296,6 +317,47 @@ void FGLRenderBuffers::CreateBloom(int width, int height) } } +//========================================================================== +// +// Creates ambient occlusion working buffers +// +//========================================================================== + +void FGLRenderBuffers::CreateAmbientOcclusion(int width, int height) +{ + ClearAmbientOcclusion(); + + if (width <= 0 || height <= 0) + return; + + AmbientWidth = width / 2; + AmbientHeight = height / 2; + AmbientTexture0 = Create2DTexture("AmbientTexture0", GL_RG32F, AmbientWidth, AmbientHeight); + AmbientTexture1 = Create2DTexture("AmbientTexture1", GL_RG32F, AmbientWidth, AmbientHeight); + AmbientFB0 = CreateFrameBuffer("AmbientFB0", AmbientTexture0); + AmbientFB1 = CreateFrameBuffer("AmbientFB1", AmbientTexture1); + + int16_t randomValues[16 * 4]; + std::mt19937 generator(1337); + std::uniform_real_distribution distribution(-1.0, 1.0); + for (int i = 0; i < 16; i++) + { + double num_directions = 8.0; // Must be same as the define in ssao.fp + double angle = 2.0 * M_PI * distribution(generator) / num_directions; + double x = cos(angle); + double y = sin(angle); + double z = distribution(generator); + double w = distribution(generator); + + randomValues[i * 4 + 0] = (int16_t)clamp(x * 32767.0, -32768.0, 32767.0); + randomValues[i * 4 + 1] = (int16_t)clamp(y * 32767.0, -32768.0, 32767.0); + randomValues[i * 4 + 2] = (int16_t)clamp(z * 32767.0, -32768.0, 32767.0); + randomValues[i * 4 + 3] = (int16_t)clamp(w * 32767.0, -32768.0, 32767.0); + } + + AmbientRandomTexture = Create2DTexture("AmbientRandomTexture", GL_RGBA16_SNORM, 4, 4, randomValues); +} + //========================================================================== // // Creates camera exposure level buffers @@ -368,12 +430,28 @@ void FGLRenderBuffers::CreateEyeBuffers(int eye) GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height, const void *data) { - GLuint type = (format == GL_RGBA16F || format == GL_R32F) ? GL_FLOAT : GL_UNSIGNED_BYTE; GLuint handle = 0; glGenTextures(1, &handle); glBindTexture(GL_TEXTURE_2D, handle); FGLDebug::LabelObject(GL_TEXTURE, handle, name); - glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format != GL_R32F ? GL_RGBA : GL_RED, type, data); + + GLenum dataformat, datatype; + switch (format) + { + case GL_RGBA8: dataformat = GL_RGBA; datatype = GL_UNSIGNED_BYTE; break; + case GL_RGBA16: dataformat = GL_RGBA; datatype = GL_UNSIGNED_SHORT; break; + case GL_RGBA16F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; + case GL_RGBA32F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; + case GL_R32F: dataformat = GL_RED; datatype = GL_FLOAT; break; + case GL_RG32F: dataformat = GL_RG; datatype = GL_FLOAT; break; + case GL_DEPTH_COMPONENT24: dataformat = GL_DEPTH_COMPONENT; datatype = GL_FLOAT; break; + case GL_STENCIL_INDEX8: dataformat = GL_STENCIL_INDEX; datatype = GL_INT; break; + case GL_DEPTH24_STENCIL8: dataformat = GL_DEPTH_STENCIL; datatype = GL_UNSIGNED_INT_24_8; break; + case GL_RGBA16_SNORM: dataformat = GL_RGBA; datatype = GL_SHORT; break; + default: I_FatalError("Unknown format passed to FGLRenderBuffers.Create2DTexture"); + } + + glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, dataformat, datatype, data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -381,6 +459,17 @@ GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int return handle; } +GLuint FGLRenderBuffers::Create2DMultisampleTexture(const FString &name, GLuint format, int width, int height, int samples, bool fixedSampleLocations) +{ + GLuint handle = 0; + glGenTextures(1, &handle); + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, handle); + FGLDebug::LabelObject(GL_TEXTURE, handle, name); + glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, format, width, height, fixedSampleLocations); + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0); + return handle; +} + //========================================================================== // // Creates a render buffer @@ -428,34 +517,26 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff return handle; } -GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer) +GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer0, GLuint colorbuffer1, GLuint depthstencil, bool multisample) { GLuint handle = 0; glGenFramebuffers(1, &handle); glBindFramebuffer(GL_FRAMEBUFFER, handle); FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); - if (colorIsARenderBuffer) - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); + if (multisample) + { + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, colorbuffer0, 0); + if (colorbuffer1 != 0) + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D_MULTISAMPLE, colorbuffer1, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D_MULTISAMPLE, depthstencil, 0); + } else - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil); - if (CheckFrameBufferCompleteness()) - ClearFrameBuffer(true, true); - return handle; -} - -GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer) -{ - GLuint handle = 0; - glGenFramebuffers(1, &handle); - glBindFramebuffer(GL_FRAMEBUFFER, handle); - FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); - if (colorIsARenderBuffer) - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); - else - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil); + { + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer0, 0); + if (colorbuffer1 != 0) + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, colorbuffer1, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthstencil, 0); + } if (CheckFrameBufferCompleteness()) ClearFrameBuffer(true, true); return handle; @@ -475,22 +556,23 @@ bool FGLRenderBuffers::CheckFrameBufferCompleteness() FailedCreate = true; -#if 0 - FString error = "glCheckFramebufferStatus failed: "; - switch (result) + if (gl_debug_level > 0) { - default: error.AppendFormat("error code %d", (int)result); break; - case GL_FRAMEBUFFER_UNDEFINED: error << "GL_FRAMEBUFFER_UNDEFINED"; break; - case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: error << "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"; break; - case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: error << "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"; break; - case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: error << "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER"; break; - case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: error << "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER"; break; - case GL_FRAMEBUFFER_UNSUPPORTED: error << "GL_FRAMEBUFFER_UNSUPPORTED"; break; - case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: error << "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"; break; - case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: error << "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS"; break; + FString error = "glCheckFramebufferStatus failed: "; + switch (result) + { + default: error.AppendFormat("error code %d", (int)result); break; + case GL_FRAMEBUFFER_UNDEFINED: error << "GL_FRAMEBUFFER_UNDEFINED"; break; + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: error << "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"; break; + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: error << "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"; break; + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: error << "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER"; break; + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: error << "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER"; break; + case GL_FRAMEBUFFER_UNSUPPORTED: error << "GL_FRAMEBUFFER_UNSUPPORTED"; break; + case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: error << "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"; break; + case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: error << "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS"; break; + } + Printf("%s\n", error.GetChars()); } - I_FatalError(error); -#endif return false; } @@ -595,9 +677,54 @@ void FGLRenderBuffers::BindEyeFB(int eye, bool readBuffer) // //========================================================================== -void FGLRenderBuffers::BindSceneFB() +void FGLRenderBuffers::BindSceneFB(bool sceneData) { - glBindFramebuffer(GL_FRAMEBUFFER, mSceneFB); + glBindFramebuffer(GL_FRAMEBUFFER, sceneData ? mSceneDataFB : mSceneFB); +} + +//========================================================================== +// +// Binds the scene color texture to the specified texture unit +// +//========================================================================== + +void FGLRenderBuffers::BindSceneColorTexture(int index) +{ + glActiveTexture(GL_TEXTURE0 + index); + if (mSamples > 1) + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mSceneMultisample); + else + glBindTexture(GL_TEXTURE_2D, mPipelineTexture[0]); +} + +//========================================================================== +// +// Binds the scene data texture to the specified texture unit +// +//========================================================================== + +void FGLRenderBuffers::BindSceneDataTexture(int index) +{ + glActiveTexture(GL_TEXTURE0 + index); + if (mSamples > 1) + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mSceneData); + else + glBindTexture(GL_TEXTURE_2D, mSceneData); +} + +//========================================================================== +// +// Binds the depth texture to the specified texture unit +// +//========================================================================== + +void FGLRenderBuffers::BindSceneDepthTexture(int index) +{ + glActiveTexture(GL_TEXTURE0 + index); + if (mSamples > 1) + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mSceneDepthStencil); + else + glBindTexture(GL_TEXTURE_2D, mSceneDepthStencil); } //========================================================================== diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 4477718f4..351a0ed0c 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -31,7 +31,10 @@ public: bool Setup(int width, int height, int sceneWidth, int sceneHeight); - void BindSceneFB(); + void BindSceneFB(bool sceneData); + void BindSceneColorTexture(int index); + void BindSceneDataTexture(int index); + void BindSceneDepthTexture(int index); void BlitSceneToTexture(); void BindCurrentTexture(int index); @@ -53,6 +56,15 @@ public: GLuint ExposureFB = 0; bool FirstExposureFrame = true; + // Ambient occlusion buffers + GLuint AmbientTexture0 = 0; + GLuint AmbientTexture1 = 0; + GLuint AmbientFB0 = 0; + GLuint AmbientFB1 = 0; + int AmbientWidth = 0; + int AmbientHeight = 0; + GLuint AmbientRandomTexture = 0; + static bool IsEnabled(); int GetWidth() const { return mWidth; } @@ -64,17 +76,19 @@ private: void ClearEyeBuffers(); void ClearBloom(); void ClearExposureLevels(); + void ClearAmbientOcclusion(); void CreateScene(int width, int height, int samples); void CreatePipeline(int width, int height); void CreateBloom(int width, int height); void CreateExposureLevels(int width, int height); void CreateEyeBuffers(int eye); + void CreateAmbientOcclusion(int width, int height); GLuint Create2DTexture(const FString &name, GLuint format, int width, int height, const void *data = nullptr); + GLuint Create2DMultisampleTexture(const FString &name, GLuint format, int width, int height, int samples, bool fixedSampleLocations); GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height); GLuint CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer); - GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer); - GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer); + GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer0, GLuint colorbuffer1, GLuint depthstencil, bool multisample); bool CheckFrameBufferCompleteness(); void ClearFrameBuffer(bool stencil, bool depth); void DeleteTexture(GLuint &handle); @@ -94,9 +108,9 @@ private: // Buffers for the scene GLuint mSceneMultisample = 0; GLuint mSceneDepthStencil = 0; - GLuint mSceneDepth = 0; - GLuint mSceneStencil = 0; + GLuint mSceneData = 0; GLuint mSceneFB = 0; + GLuint mSceneDataFB = 0; // Effect/HUD buffers GLuint mPipelineTexture[NumPipelineTextures]; diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 42b4a8e1b..829b2500b 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -51,6 +51,7 @@ #include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/shaders/gl_shader.h" +#include "gl/shaders/gl_ambientshader.h" #include "gl/shaders/gl_bloomshader.h" #include "gl/shaders/gl_blurshader.h" #include "gl/shaders/gl_tonemapshader.h" @@ -121,6 +122,8 @@ void gl_FlushModels(); void FGLRenderer::Initialize(int width, int height) { mBuffers = new FGLRenderBuffers(); + mLinearDepthShader = new FLinearDepthShader(); + mSSAOShader = new FSSAOShader(); mBloomExtractShader = new FBloomExtractShader(); mBloomCombineShader = new FBloomCombineShader(); mExposureExtractShader = new FExposureExtractShader(); @@ -184,6 +187,8 @@ FGLRenderer::~FGLRenderer() } if (mBuffers) delete mBuffers; if (mPresentShader) delete mPresentShader; + if (mLinearDepthShader) delete mLinearDepthShader; + if (mSSAOShader) delete mSSAOShader; if (mBloomExtractShader) delete mBloomExtractShader; if (mBloomCombineShader) delete mBloomCombineShader; if (mExposureExtractShader) delete mExposureExtractShader; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 71c52474a..2ec35b4a8 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -19,6 +19,8 @@ class FLightBuffer; class FSamplerManager; class DPSprite; class FGLRenderBuffers; +class FLinearDepthShader; +class FSSAOShader; class FBloomExtractShader; class FBloomCombineShader; class FExposureExtractShader; @@ -93,6 +95,8 @@ public: int mOldFBID; FGLRenderBuffers *mBuffers; + FLinearDepthShader *mLinearDepthShader; + FSSAOShader *mSSAOShader; FBloomExtractShader *mBloomExtractShader; FBloomCombineShader *mBloomCombineShader; FExposureExtractShader *mExposureExtractShader; @@ -172,6 +176,8 @@ public: void WriteSavePic (player_t *player, FileWriter *file, int width, int height); void EndDrawScene(sector_t * viewsector); void UpdateCameraExposure(); + void PostProcessScene(); + void AmbientOccludeScene(); void BloomScene(); void TonemapScene(); void ColormapScene(); @@ -198,6 +204,9 @@ public: DAngle rotation, FDynamicColormap *colormap, int lightlevel); int PTM_BestColor (const uint32 *pal_in, int r, int g, int b, int first, int num); + + static float GetZNear() { return 5.f; } + static float GetZFar() { return 65536.f; } }; // Global functions. Make them members of GLRenderer later? diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 0c76b4bb1..27772a0ca 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -209,7 +209,7 @@ void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) { float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovratio)); - gl_RenderState.mProjectionMatrix.perspective(fovy, ratio, 5.f, 65536.f); + gl_RenderState.mProjectionMatrix.perspective(fovy, ratio, GetZNear(), GetZFar()); } // raw matrix input from stereo 3d modes @@ -826,12 +826,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo if (mainview && toscreen) EndDrawScene(lviewsector); // do not call this for camera textures. if (mainview && FGLRenderBuffers::IsEnabled()) { - mBuffers->BlitSceneToTexture(); - UpdateCameraExposure(); - BloomScene(); - TonemapScene(); - ColormapScene(); - LensDistortScene(); + PostProcessScene(); // This should be done after postprocessing, not before. mBuffers->BindCurrentFB(); diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp new file mode 100644 index 000000000..d9d4a3425 --- /dev/null +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -0,0 +1,89 @@ +/* +** gl_bloomshader.cpp +** Shaders used for screen space ambient occlusion +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "gl/gl_functions.h" +#include "vectors.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_ambientshader.h" + +void FLinearDepthShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/lineardepth.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/lineardepth"); + mShader.SetAttribLocation(0, "PositionInProjection"); + DepthTexture.Init(mShader, "DepthTexture"); + LinearizeDepthA.Init(mShader, "LinearizeDepthA"); + LinearizeDepthB.Init(mShader, "LinearizeDepthB"); + InverseDepthRangeA.Init(mShader, "InverseDepthRangeA"); + InverseDepthRangeB.Init(mShader, "InverseDepthRangeB"); + } + mShader.Bind(); +} + +void FSSAOShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssao.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/ssao"); + mShader.SetAttribLocation(0, "PositionInProjection"); + DepthTexture.Init(mShader, "DepthTexture"); + UVToViewA.Init(mShader, "UVToViewA"); + UVToViewB.Init(mShader, "UVToViewB"); + InvFullResolution.Init(mShader, "InvFullResolution"); + NDotVBias.Init(mShader, "NDotVBias"); + NegInvR2.Init(mShader, "NegInvR2"); + RadiusToScreen.Init(mShader, "RadiusToScreen"); + AOMultiplier.Init(mShader, "AOMultiplier"); + } + mShader.Bind(); +} diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h new file mode 100644 index 000000000..44f916596 --- /dev/null +++ b/src/gl/shaders/gl_ambientshader.h @@ -0,0 +1,39 @@ +#ifndef __GL_AMBIENTSHADER_H +#define __GL_AMBIENTSHADER_H + +#include "gl_shaderprogram.h" + +class FLinearDepthShader +{ +public: + void Bind(); + + FBufferedUniformSampler DepthTexture; + FBufferedUniform1f LinearizeDepthA; + FBufferedUniform1f LinearizeDepthB; + FBufferedUniform1f InverseDepthRangeA; + FBufferedUniform1f InverseDepthRangeB; + +private: + FShaderProgram mShader; +}; + +class FSSAOShader +{ +public: + void Bind(); + + FBufferedUniformSampler DepthTexture; + FBufferedUniform2f UVToViewA; + FBufferedUniform2f UVToViewB; + FBufferedUniform2f InvFullResolution; + FBufferedUniform1f NDotVBias; + FBufferedUniform1f NegInvR2; + FBufferedUniform1f RadiusToScreen; + FBufferedUniform1f AOMultiplier; + +private: + FShaderProgram mShader; +}; + +#endif \ No newline at end of file diff --git a/src/gl/stereo3d/gl_stereo3d.cpp b/src/gl/stereo3d/gl_stereo3d.cpp index 9403d4751..6b1623ba6 100644 --- a/src/gl/stereo3d/gl_stereo3d.cpp +++ b/src/gl/stereo3d/gl_stereo3d.cpp @@ -41,7 +41,7 @@ VSMatrix EyePose::GetProjection(float fov, float aspectRatio, float fovRatio) co // Lifted from gl_scene.cpp FGLRenderer::SetProjection() float fovy = (float)(2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio))); - result.perspective(fovy, aspectRatio, 5.f, 65536.f); + result.perspective(fovy, aspectRatio, FGLRenderer::GetZNear(), FGLRenderer::GetZFar()); return result; } diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 50526a75b..197e262f5 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2633,6 +2633,7 @@ GLPREFMNU_MULTISAMPLE = "Multisample"; GLPREFMNU_TONEMAP = "Tonemap Mode"; GLPREFMNU_BLOOM = "Bloom effect"; GLPREFMNU_LENS = "Lens distortion effect"; +GLPREFMNU_SSAO = "Ambient occlusion"; // Option Values OPTVAL_SMART = "Smart"; diff --git a/wadsrc/static/menudef.zz b/wadsrc/static/menudef.zz index 1ab4f1a6d..68523ea83 100644 --- a/wadsrc/static/menudef.zz +++ b/wadsrc/static/menudef.zz @@ -226,4 +226,5 @@ OptionMenu "GLPrefOptions" Option "$GLPREFMNU_TONEMAP", gl_tonemap, "TonemapModes" Option "$GLPREFMNU_BLOOM", gl_bloom, "OnOff" Option "$GLPREFMNU_LENS", gl_lens, "OnOff" + Option "$GLPREFMNU_SSAO", gl_ssao, "OnOff" } diff --git a/wadsrc/static/shaders/glsl/lineardepth.fp b/wadsrc/static/shaders/glsl/lineardepth.fp new file mode 100644 index 000000000..f61bb3995 --- /dev/null +++ b/wadsrc/static/shaders/glsl/lineardepth.fp @@ -0,0 +1,16 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D DepthTexture; +uniform float LinearizeDepthA; +uniform float LinearizeDepthB; +uniform float InverseDepthRangeA; +uniform float InverseDepthRangeB; + +void main() +{ + float depth = texture(DepthTexture, TexCoord).x; + float normalizedDepth = clamp(InverseDepthRangeA * depth + InverseDepthRangeB, 0.0, 1.0); + FragColor = vec4(1.0 / (normalizedDepth * LinearizeDepthA + LinearizeDepthB), 0.0, 0.0, 1.0); +} diff --git a/wadsrc/static/shaders/glsl/ssao.fp b/wadsrc/static/shaders/glsl/ssao.fp new file mode 100644 index 000000000..c9f8534d9 --- /dev/null +++ b/wadsrc/static/shaders/glsl/ssao.fp @@ -0,0 +1,117 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform vec2 UVToViewA; +uniform vec2 UVToViewB; +uniform vec2 InvFullResolution; + +uniform float NDotVBias; +uniform float NegInvR2; +uniform float RadiusToScreen; +uniform float AOMultiplier; + +uniform sampler2D DepthTexture; + +#if USE_RANDOM_TEXTURE +uniform sampler2D RandomTexture; +#endif + +#define NUM_DIRECTIONS 8.0 +#define NUM_STEPS 4.0 + +#define PI 3.14159265358979323846 + +// Calculate eye space position for the specified texture coordinate +vec3 FetchViewPos(vec2 uv) +{ + float z = texture(DepthTexture, uv).x; + return vec3((UVToViewA * uv + UVToViewB) * z, z); +} + +vec3 MinDiff(vec3 p, vec3 pr, vec3 pl) +{ + vec3 v1 = pr - p; + vec3 v2 = p - pl; + return (dot(v1, v1) < dot(v2, v2)) ? v1 : v2; +} + +// Reconstruct eye space normal from nearest neighbors +vec3 ReconstructNormal(vec3 p) +{ + vec3 pr = FetchViewPos(TexCoord + vec2(InvFullResolution.x, 0)); + vec3 pl = FetchViewPos(TexCoord + vec2(-InvFullResolution.x, 0)); + vec3 pt = FetchViewPos(TexCoord + vec2(0, InvFullResolution.y)); + vec3 pb = FetchViewPos(TexCoord + vec2(0, -InvFullResolution.y)); + return normalize(cross(MinDiff(p, pr, pl), MinDiff(p, pt, pb))); +} + +// Compute normalized 2D direction +vec2 RotateDirection(vec2 dir, vec2 cossin) +{ + return vec2(dir.x * cossin.x - dir.y * cossin.y, dir.x * cossin.y + dir.y * cossin.x); +} + +vec4 GetJitter() +{ +#if !USE_RANDOM_TEXTURE + return vec4(1,0,1,1); + //vec3 rand = noise3(TexCoord.x + TexCoord.y); + //float angle = 2.0 * PI * rand.x / NUM_DIRECTIONS; + //return vec4(cos(angle), sin(angle), rand.y, rand.z); +#else + #define RANDOM_TEXTURE_WIDTH 4.0 + return texture(RandomTexture, gl_FragCoord.xy / RANDOM_TEXTURE_WIDTH); +#endif +} + +// Calculates the ambient occlusion of a sample +float ComputeSampleAO(vec3 kernelPos, vec3 normal, vec3 samplePos) +{ + vec3 v = samplePos - kernelPos; + float distanceSquare = dot(v, v); + float nDotV = dot(normal, v) * inversesqrt(distanceSquare); + return clamp(nDotV - NDotVBias, 0.0, 1.0) * clamp(distanceSquare * NegInvR2 + 1.0, 0.0, 1.0); +} + +// Calculates the total ambient occlusion for the entire fragment +float ComputeAO(vec3 viewPosition, vec3 viewNormal) +{ + vec4 rand = GetJitter(); + + float radiusPixels = RadiusToScreen / viewPosition.z; + float stepSizePixels = radiusPixels / (NUM_STEPS + 1.0); + + const float directionAngleStep = 2.0 * PI / NUM_DIRECTIONS; + float ao = 0.0; + + for (float directionIndex = 0.0; directionIndex < NUM_DIRECTIONS; ++directionIndex) + { + float angle = directionAngleStep * directionIndex; + + vec2 direction = RotateDirection(vec2(cos(angle), sin(angle)), rand.xy); + float rayPixels = (rand.z * stepSizePixels + 1.0); + + for (float StepIndex = 0.0; StepIndex < NUM_STEPS; ++StepIndex) + { + vec2 sampleUV = round(rayPixels * direction) * InvFullResolution + TexCoord; + vec3 samplePos = FetchViewPos(sampleUV); + ao += ComputeSampleAO(viewPosition, viewNormal, samplePos); + rayPixels += stepSizePixels; + } + } + + ao *= AOMultiplier / (NUM_DIRECTIONS * NUM_STEPS); + return clamp(1.0 - ao * 2.0, 0.0, 1.0); +} + +void main() +{ + vec3 viewPosition = FetchViewPos(TexCoord); + vec3 viewNormal = ReconstructNormal(viewPosition); + float occlusion = ComputeAO(viewPosition, viewNormal); + //FragColor = vec4(viewPosition.x * 0.001 + 0.5, viewPosition.y * 0.001 + 0.5, viewPosition.z * 0.001, 1.0); + //FragColor = vec4(viewNormal.x * 0.5 + 0.5, viewNormal.y * 0.5 + 0.5, viewNormal.z * 0.5 + 0.5, 1.0); + //FragColor = vec4(occlusion, viewPosition.z, 0.0, 1.0); + FragColor = vec4(occlusion, occlusion, occlusion, 1.0); +} From 723eb746f660d8ee63b63fff7a515ad27fb4264f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 30 Aug 2016 01:09:21 +0200 Subject: [PATCH 0966/1509] Add ssao random texture --- src/gl/renderer/gl_postprocess.cpp | 10 ++++++++++ src/gl/shaders/gl_ambientshader.cpp | 11 ++++++++++- src/gl/shaders/gl_ambientshader.h | 2 ++ wadsrc/static/shaders/glsl/ssao.fp | 16 +++++++++------- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 9df28ce5b..4fb83c642 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -100,6 +100,7 @@ CVAR(Float, gl_lens_kcube, 0.1f, 0) CVAR(Float, gl_lens_chromatic, 1.12f, 0) CVAR(Bool, gl_ssao, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Float, gl_ssao_strength, 0.7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, gl_ssao_debug, false, 0) CVAR(Float, gl_ssao_bias, 0.5f, 0) CVAR(Float, gl_ssao_radius, 100.0f, 0) @@ -148,11 +149,13 @@ void FGLRenderer::AmbientOccludeScene() FGLDebug::PushGroup("AmbientOccludeScene"); FGLPostProcessState savedState; + savedState.SaveTextureBinding1(); float bias = gl_ssao_bias; float aoRadius = gl_ssao_radius; const float blurAmount = gl_ssao_blur_amount; int blurSampleCount = gl_ssao_blur_samples; + float aoStrength = gl_ssao_strength; //float tanHalfFovy = tan(fovy * (M_PI / 360.0f)); float tanHalfFovy = 1.0f / 1.33333302f; //gl_RenderState.mProjectionMatrix.get()[5]; @@ -178,8 +181,14 @@ void FGLRenderer::AmbientOccludeScene() glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientRandomTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glActiveTexture(GL_TEXTURE0); mSSAOShader->Bind(); mSSAOShader->DepthTexture.Set(0); + mSSAOShader->RandomTexture.Set(1); mSSAOShader->UVToViewA.Set(2.0f * invFocalLenX, -2.0f * invFocalLenY); mSSAOShader->UVToViewB.Set(-invFocalLenX, invFocalLenY); mSSAOShader->InvFullResolution.Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); @@ -187,6 +196,7 @@ void FGLRenderer::AmbientOccludeScene() mSSAOShader->NegInvR2.Set(-1.0f / r2); mSSAOShader->RadiusToScreen.Set(aoRadius * 0.5 / tanHalfFovy * mBuffers->AmbientHeight); mSSAOShader->AOMultiplier.Set(1.0f / (1.0f - nDotVBias)); + mSSAOShader->AOStrength.Set(aoStrength); RenderScreenQuad(); // Blur SSAO texture diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index d9d4a3425..55682a91e 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -71,12 +71,20 @@ void FSSAOShader::Bind() { if (!mShader) { + const char *defines = R"( + #define USE_RANDOM_TEXTURE + #define RANDOM_TEXTURE_WIDTH 4.0 + #define NUM_DIRECTIONS 8.0 + #define NUM_STEPS 4.0 + )"; + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); - mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssao.fp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssao.fp", defines, 330); mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/ssao"); mShader.SetAttribLocation(0, "PositionInProjection"); DepthTexture.Init(mShader, "DepthTexture"); + RandomTexture.Init(mShader, "RandomTexture"); UVToViewA.Init(mShader, "UVToViewA"); UVToViewB.Init(mShader, "UVToViewB"); InvFullResolution.Init(mShader, "InvFullResolution"); @@ -84,6 +92,7 @@ void FSSAOShader::Bind() NegInvR2.Init(mShader, "NegInvR2"); RadiusToScreen.Init(mShader, "RadiusToScreen"); AOMultiplier.Init(mShader, "AOMultiplier"); + AOStrength.Init(mShader, "AOStrength"); } mShader.Bind(); } diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index 44f916596..fdff178ec 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -24,6 +24,7 @@ public: void Bind(); FBufferedUniformSampler DepthTexture; + FBufferedUniformSampler RandomTexture; FBufferedUniform2f UVToViewA; FBufferedUniform2f UVToViewB; FBufferedUniform2f InvFullResolution; @@ -31,6 +32,7 @@ public: FBufferedUniform1f NegInvR2; FBufferedUniform1f RadiusToScreen; FBufferedUniform1f AOMultiplier; + FBufferedUniform1f AOStrength; private: FShaderProgram mShader; diff --git a/wadsrc/static/shaders/glsl/ssao.fp b/wadsrc/static/shaders/glsl/ssao.fp index c9f8534d9..f143e913f 100644 --- a/wadsrc/static/shaders/glsl/ssao.fp +++ b/wadsrc/static/shaders/glsl/ssao.fp @@ -11,15 +11,14 @@ uniform float NegInvR2; uniform float RadiusToScreen; uniform float AOMultiplier; +uniform float AOStrength; + uniform sampler2D DepthTexture; -#if USE_RANDOM_TEXTURE +#if defined(USE_RANDOM_TEXTURE) uniform sampler2D RandomTexture; #endif -#define NUM_DIRECTIONS 8.0 -#define NUM_STEPS 4.0 - #define PI 3.14159265358979323846 // Calculate eye space position for the specified texture coordinate @@ -54,13 +53,12 @@ vec2 RotateDirection(vec2 dir, vec2 cossin) vec4 GetJitter() { -#if !USE_RANDOM_TEXTURE +#if !defined(USE_RANDOM_TEXTURE) return vec4(1,0,1,1); //vec3 rand = noise3(TexCoord.x + TexCoord.y); //float angle = 2.0 * PI * rand.x / NUM_DIRECTIONS; //return vec4(cos(angle), sin(angle), rand.y, rand.z); #else - #define RANDOM_TEXTURE_WIDTH 4.0 return texture(RandomTexture, gl_FragCoord.xy / RANDOM_TEXTURE_WIDTH); #endif } @@ -109,7 +107,11 @@ void main() { vec3 viewPosition = FetchViewPos(TexCoord); vec3 viewNormal = ReconstructNormal(viewPosition); - float occlusion = ComputeAO(viewPosition, viewNormal); + float occlusion = ComputeAO(viewPosition, viewNormal) * AOStrength + (1.0 - AOStrength); + + // GZDoom does not use linear buffers at the moment, apply some gamma to get it closer to correct + occlusion = occlusion * occlusion; + //FragColor = vec4(viewPosition.x * 0.001 + 0.5, viewPosition.y * 0.001 + 0.5, viewPosition.z * 0.001, 1.0); //FragColor = vec4(viewNormal.x * 0.5 + 0.5, viewNormal.y * 0.5 + 0.5, viewNormal.z * 0.5 + 0.5, 1.0); //FragColor = vec4(occlusion, viewPosition.z, 0.0, 1.0); From a6fdaca6337cc2226dafb3a26e38273a2bb0e909 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 1 Sep 2016 07:15:40 +0200 Subject: [PATCH 0967/1509] Fix precision issue in SSAO shader --- src/gl/renderer/gl_postprocess.cpp | 8 ++++---- src/gl/renderer/gl_renderbuffers.h | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 4fb83c642..2356eaee7 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -104,11 +104,11 @@ CVAR(Float, gl_ssao_strength, 0.7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, gl_ssao_debug, false, 0) CVAR(Float, gl_ssao_bias, 0.5f, 0) CVAR(Float, gl_ssao_radius, 100.0f, 0) -CUSTOM_CVAR(Float, gl_ssao_blur_amount, 6.0f, 0) +CUSTOM_CVAR(Float, gl_ssao_blur_amount, 4.0f, 0) { if (self < 0.1f) self = 0.1f; } -CUSTOM_CVAR(Int, gl_ssao_blur_samples, 9, 0) +CUSTOM_CVAR(Int, gl_ssao_blur_samples, 5, 0) { if (self < 3 || self > 15 || self % 2 == 0) self = 9; @@ -158,8 +158,8 @@ void FGLRenderer::AmbientOccludeScene() float aoStrength = gl_ssao_strength; //float tanHalfFovy = tan(fovy * (M_PI / 360.0f)); - float tanHalfFovy = 1.0f / 1.33333302f; //gl_RenderState.mProjectionMatrix.get()[5]; - float invFocalLenX = tanHalfFovy * (mBuffers->AmbientWidth / (float)mBuffers->AmbientHeight); + float tanHalfFovy = 1.0f / 1.33333302f; // 1.0f / gl_RenderState.mProjectionMatrix.get()[5]; + float invFocalLenX = tanHalfFovy * (mBuffers->GetSceneWidth() / (float)mBuffers->GetSceneHeight()); float invFocalLenY = tanHalfFovy; float nDotVBias = clamp(bias, 0.0f, 1.0f); float r2 = aoRadius * aoRadius; diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 351a0ed0c..080593881 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -70,6 +70,9 @@ public: int GetWidth() const { return mWidth; } int GetHeight() const { return mHeight; } + int GetSceneWidth() const { return mSceneWidth; } + int GetSceneHeight() const { return mSceneHeight; } + private: void ClearScene(); void ClearPipeline(); From a246b586733613f318897d64a0f65df092c058c6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 2 Sep 2016 05:45:00 +0200 Subject: [PATCH 0968/1509] Change SSAO blur to be depth aware --- src/gl/renderer/gl_postprocess.cpp | 22 ++++-- src/gl/renderer/gl_renderer.cpp | 8 +++ src/gl/renderer/gl_renderer.h | 4 ++ src/gl/shaders/gl_ambientshader.cpp | 32 +++++++++ src/gl/shaders/gl_ambientshader.h | 25 +++++++ wadsrc/static/shaders/glsl/depthblur.fp | 81 +++++++++++++++++++++++ wadsrc/static/shaders/glsl/ssao.fp | 9 +-- wadsrc/static/shaders/glsl/ssaocombine.fp | 11 +++ 8 files changed, 180 insertions(+), 12 deletions(-) create mode 100644 wadsrc/static/shaders/glsl/depthblur.fp create mode 100644 wadsrc/static/shaders/glsl/ssaocombine.fp diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 2356eaee7..97491cb58 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -200,8 +200,22 @@ void FGLRenderer::AmbientOccludeScene() RenderScreenQuad(); // Blur SSAO texture - mBlurShader->BlurHorizontal(this, blurAmount, blurSampleCount, mBuffers->AmbientTexture1, mBuffers->AmbientFB0, mBuffers->AmbientWidth, mBuffers->AmbientHeight); - mBlurShader->BlurVertical(this, blurAmount, blurSampleCount, mBuffers->AmbientTexture0, mBuffers->AmbientFB1, mBuffers->AmbientWidth, mBuffers->AmbientHeight); + glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB0); + glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + mDepthBlurShader->Bind(false); + mDepthBlurShader->BlurSharpness[false].Set(blurAmount); + mDepthBlurShader->InvFullResolution[false].Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); + RenderScreenQuad(); + + glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB1); + glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture0); + mDepthBlurShader->Bind(true); + mDepthBlurShader->BlurSharpness[true].Set(blurAmount); + mDepthBlurShader->InvFullResolution[true].Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); + mDepthBlurShader->PowExponent[true].Set(1.8f); + RenderScreenQuad(); // Add SSAO back to scene texture: mBuffers->BindCurrentFB(); @@ -216,8 +230,8 @@ void FGLRenderer::AmbientOccludeScene() glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - mBloomCombineShader->Bind(); - mBloomCombineShader->BloomTexture.Set(0); + mSSAOCombineShader->Bind(); + mSSAOCombineShader->AODepthTexture.Set(0); RenderScreenQuad(); glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 829b2500b..befa330e9 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -114,6 +114,10 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mTonemapPalette = nullptr; mColormapShader = nullptr; mLensShader = nullptr; + mLinearDepthShader = nullptr; + mDepthBlurShader = nullptr; + mSSAOShader = nullptr; + mSSAOCombineShader = nullptr; } void gl_LoadModels(); @@ -123,7 +127,9 @@ void FGLRenderer::Initialize(int width, int height) { mBuffers = new FGLRenderBuffers(); mLinearDepthShader = new FLinearDepthShader(); + mDepthBlurShader = new FDepthBlurShader(); mSSAOShader = new FSSAOShader(); + mSSAOCombineShader = new FSSAOCombineShader(); mBloomExtractShader = new FBloomExtractShader(); mBloomCombineShader = new FBloomCombineShader(); mExposureExtractShader = new FExposureExtractShader(); @@ -188,7 +194,9 @@ FGLRenderer::~FGLRenderer() if (mBuffers) delete mBuffers; if (mPresentShader) delete mPresentShader; if (mLinearDepthShader) delete mLinearDepthShader; + if (mDepthBlurShader) delete mDepthBlurShader; if (mSSAOShader) delete mSSAOShader; + if (mSSAOCombineShader) delete mSSAOCombineShader; if (mBloomExtractShader) delete mBloomExtractShader; if (mBloomCombineShader) delete mBloomCombineShader; if (mExposureExtractShader) delete mExposureExtractShader; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 2ec35b4a8..a285c9ef7 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -20,7 +20,9 @@ class FSamplerManager; class DPSprite; class FGLRenderBuffers; class FLinearDepthShader; +class FDepthBlurShader; class FSSAOShader; +class FSSAOCombineShader; class FBloomExtractShader; class FBloomCombineShader; class FExposureExtractShader; @@ -97,6 +99,8 @@ public: FGLRenderBuffers *mBuffers; FLinearDepthShader *mLinearDepthShader; FSSAOShader *mSSAOShader; + FDepthBlurShader *mDepthBlurShader; + FSSAOCombineShader *mSSAOCombineShader; FBloomExtractShader *mBloomExtractShader; FBloomCombineShader *mBloomCombineShader; FExposureExtractShader *mExposureExtractShader; diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index 55682a91e..6b8c9cc48 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -96,3 +96,35 @@ void FSSAOShader::Bind() } mShader.Bind(); } + +void FDepthBlurShader::Bind(bool vertical) +{ + auto &shader = mShader[vertical]; + if (!shader) + { + shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + shader.Compile(FShaderProgram::Fragment, "shaders/glsl/depthblur.fp", vertical ? "#define BLUR_VERTICAL\n" : "#define BLUR_HORIZONTAL\n", 330); + shader.SetFragDataLocation(0, "FragColor"); + shader.Link("shaders/glsl/depthblur"); + shader.SetAttribLocation(0, "PositionInProjection"); + AODepthTexture[vertical].Init(shader, "AODepthTexture"); + BlurSharpness[vertical].Init(shader, "BlurSharpness"); + InvFullResolution[vertical].Init(shader, "InvFullResolution"); + PowExponent[vertical].Init(shader, "PowExponent"); + } + shader.Bind(); +} + +void FSSAOCombineShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssaocombine.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/ssaocombine"); + mShader.SetAttribLocation(0, "PositionInProjection"); + AODepthTexture.Init(mShader, "AODepthTexture"); + } + mShader.Bind(); +} diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index fdff178ec..419ca939e 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -38,4 +38,29 @@ private: FShaderProgram mShader; }; +class FDepthBlurShader +{ +public: + void Bind(bool vertical); + + FBufferedUniformSampler AODepthTexture[2]; + FBufferedUniform1f BlurSharpness[2]; + FBufferedUniform2f InvFullResolution[2]; + FBufferedUniform1f PowExponent[2]; + +private: + FShaderProgram mShader[2]; +}; + +class FSSAOCombineShader +{ +public: + void Bind(); + + FBufferedUniformSampler AODepthTexture; + +private: + FShaderProgram mShader; +}; + #endif \ No newline at end of file diff --git a/wadsrc/static/shaders/glsl/depthblur.fp b/wadsrc/static/shaders/glsl/depthblur.fp new file mode 100644 index 000000000..bd464d03d --- /dev/null +++ b/wadsrc/static/shaders/glsl/depthblur.fp @@ -0,0 +1,81 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D AODepthTexture; +uniform float BlurSharpness; +uniform vec2 InvFullResolution; +uniform float PowExponent; + +#define KERNEL_RADIUS 3.0 + +struct CenterPixelData +{ + vec2 UV; + float Depth; + float Sharpness; +}; + +float CrossBilateralWeight(float r, float sampleDepth, CenterPixelData center) +{ + const float blurSigma = KERNEL_RADIUS * 0.5; + const float blurFalloff = 1.0 / (2.0 * blurSigma * blurSigma); + + float deltaZ = (sampleDepth - center.Depth) * center.Sharpness; + + return exp2(-r * r * blurFalloff - deltaZ * deltaZ); +} + +void ProcessSample(float ao, float z, float r, CenterPixelData center, inout float totalAO, inout float totalW) +{ + float w = CrossBilateralWeight(r, z, center); + totalAO += w * ao; + totalW += w; +} + +void ProcessRadius(vec2 deltaUV, CenterPixelData center, inout float totalAO, inout float totalW) +{ + for (float r = 1; r <= KERNEL_RADIUS; r += 1.0) + { + vec2 uv = r * deltaUV + center.UV; + vec2 aoZ = texture(AODepthTexture, uv).xy; + ProcessSample(aoZ.x, aoZ.y, r, center, totalAO, totalW); + } +} + +vec2 ComputeBlur(vec2 deltaUV) +{ + vec2 aoZ = texture(AODepthTexture, TexCoord).xy; + + CenterPixelData center; + center.UV = TexCoord; + center.Depth = aoZ.y; + center.Sharpness = BlurSharpness; + + float totalAO = aoZ.x; + float totalW = 1.0; + + ProcessRadius(deltaUV, center, totalAO, totalW); + ProcessRadius(-deltaUV, center, totalAO, totalW); + + return vec2(totalAO / totalW, aoZ.y); +} + +vec2 BlurX() +{ + return ComputeBlur(vec2(InvFullResolution.x, 0.0)); +} + +float BlurY() +{ + return pow(clamp(ComputeBlur(vec2(0.0, InvFullResolution.y)).x, 0.0, 1.0), PowExponent); +} + +void main() +{ +#if defined(BLUR_HORIZONTAL) + FragColor = vec4(BlurX(), 0.0, 1.0); +#else + FragColor = vec4(BlurY(), 0.0, 0.0, 1.0); +#endif +} diff --git a/wadsrc/static/shaders/glsl/ssao.fp b/wadsrc/static/shaders/glsl/ssao.fp index f143e913f..e0d972c57 100644 --- a/wadsrc/static/shaders/glsl/ssao.fp +++ b/wadsrc/static/shaders/glsl/ssao.fp @@ -108,12 +108,5 @@ void main() vec3 viewPosition = FetchViewPos(TexCoord); vec3 viewNormal = ReconstructNormal(viewPosition); float occlusion = ComputeAO(viewPosition, viewNormal) * AOStrength + (1.0 - AOStrength); - - // GZDoom does not use linear buffers at the moment, apply some gamma to get it closer to correct - occlusion = occlusion * occlusion; - - //FragColor = vec4(viewPosition.x * 0.001 + 0.5, viewPosition.y * 0.001 + 0.5, viewPosition.z * 0.001, 1.0); - //FragColor = vec4(viewNormal.x * 0.5 + 0.5, viewNormal.y * 0.5 + 0.5, viewNormal.z * 0.5 + 0.5, 1.0); - //FragColor = vec4(occlusion, viewPosition.z, 0.0, 1.0); - FragColor = vec4(occlusion, occlusion, occlusion, 1.0); + FragColor = vec4(occlusion, viewPosition.z, 0.0, 1.0); } diff --git a/wadsrc/static/shaders/glsl/ssaocombine.fp b/wadsrc/static/shaders/glsl/ssaocombine.fp new file mode 100644 index 000000000..21fdff102 --- /dev/null +++ b/wadsrc/static/shaders/glsl/ssaocombine.fp @@ -0,0 +1,11 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D AODepthTexture; + +void main() +{ + float attenutation = texture(AODepthTexture, TexCoord).x; + FragColor = vec4(attenutation, attenutation, attenutation, 0.0); +} From 09bec67821f6ac1a78aab3bfbd037b1397721b2a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 3 Sep 2016 04:12:00 +0200 Subject: [PATCH 0969/1509] Resolve multisampling depth in shader --- src/gl/renderer/gl_postprocess.cpp | 21 +++++++++-------- src/gl/shaders/gl_ambientshader.cpp | 28 ++++++++++++----------- src/gl/shaders/gl_ambientshader.h | 15 ++++++------ wadsrc/static/shaders/glsl/lineardepth.fp | 19 +++++++++++++++ 4 files changed, 54 insertions(+), 29 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 97491cb58..8282bc387 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -127,8 +127,7 @@ void FGLRenderer::RenderScreenQuad() void FGLRenderer::PostProcessScene() { - if (FGLRenderBuffers::IsEnabled()) mBuffers->BlitSceneToTexture(); - AmbientOccludeScene(); + mBuffers->BlitSceneToTexture(); UpdateCameraExposure(); BloomScene(); TonemapScene(); @@ -156,6 +155,7 @@ void FGLRenderer::AmbientOccludeScene() const float blurAmount = gl_ssao_blur_amount; int blurSampleCount = gl_ssao_blur_samples; float aoStrength = gl_ssao_strength; + bool multisample = gl_multisample > 1; //float tanHalfFovy = tan(fovy * (M_PI / 360.0f)); float tanHalfFovy = 1.0f / 1.33333302f; // 1.0f / gl_RenderState.mProjectionMatrix.get()[5]; @@ -168,12 +168,15 @@ void FGLRenderer::AmbientOccludeScene() glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB0); glViewport(0, 0, mBuffers->AmbientWidth, mBuffers->AmbientHeight); mBuffers->BindSceneDepthTexture(0); - mLinearDepthShader->Bind(); - mLinearDepthShader->DepthTexture.Set(0); - mLinearDepthShader->LinearizeDepthA.Set(1.0f / GetZFar() - 1.0f / GetZNear()); - mLinearDepthShader->LinearizeDepthB.Set(MAX(1.0f / GetZNear(), 1.e-8f)); - mLinearDepthShader->InverseDepthRangeA.Set(1.0f); - mLinearDepthShader->InverseDepthRangeB.Set(0.0f); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + mLinearDepthShader->Bind(multisample); + mLinearDepthShader->DepthTexture[multisample].Set(0); + if (multisample) mLinearDepthShader->SampleCount[multisample].Set(gl_multisample); + mLinearDepthShader->LinearizeDepthA[multisample].Set(1.0f / GetZFar() - 1.0f / GetZNear()); + mLinearDepthShader->LinearizeDepthB[multisample].Set(MAX(1.0f / GetZNear(), 1.e-8f)); + mLinearDepthShader->InverseDepthRangeA[multisample].Set(1.0f); + mLinearDepthShader->InverseDepthRangeB[multisample].Set(0.0f); RenderScreenQuad(); // Apply ambient occlusion @@ -218,7 +221,7 @@ void FGLRenderer::AmbientOccludeScene() RenderScreenQuad(); // Add SSAO back to scene texture: - mBuffers->BindCurrentFB(); + mBuffers->BindSceneFB(); glViewport(mSceneViewport.left, mSceneViewport.top, mSceneViewport.width, mSceneViewport.height); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index 6b8c9cc48..f3b6eced6 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -49,22 +49,24 @@ #include "gl/system/gl_cvars.h" #include "gl/shaders/gl_ambientshader.h" -void FLinearDepthShader::Bind() +void FLinearDepthShader::Bind(bool multisample) { - if (!mShader) + auto &shader = mShader[multisample]; + if (!shader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); - mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/lineardepth.fp", "", 330); - mShader.SetFragDataLocation(0, "FragColor"); - mShader.Link("shaders/glsl/lineardepth"); - mShader.SetAttribLocation(0, "PositionInProjection"); - DepthTexture.Init(mShader, "DepthTexture"); - LinearizeDepthA.Init(mShader, "LinearizeDepthA"); - LinearizeDepthB.Init(mShader, "LinearizeDepthB"); - InverseDepthRangeA.Init(mShader, "InverseDepthRangeA"); - InverseDepthRangeB.Init(mShader, "InverseDepthRangeB"); + shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + shader.Compile(FShaderProgram::Fragment, "shaders/glsl/lineardepth.fp", multisample ? "#define MULTISAMPLE\n" : "", 330); + shader.SetFragDataLocation(0, "FragColor"); + shader.Link("shaders/glsl/lineardepth"); + shader.SetAttribLocation(0, "PositionInProjection"); + DepthTexture[multisample].Init(shader, "DepthTexture"); + SampleCount[multisample].Init(shader, "SampleCount"); + LinearizeDepthA[multisample].Init(shader, "LinearizeDepthA"); + LinearizeDepthB[multisample].Init(shader, "LinearizeDepthB"); + InverseDepthRangeA[multisample].Init(shader, "InverseDepthRangeA"); + InverseDepthRangeB[multisample].Init(shader, "InverseDepthRangeB"); } - mShader.Bind(); + shader.Bind(); } void FSSAOShader::Bind() diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index 419ca939e..5f9ef630b 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -6,16 +6,17 @@ class FLinearDepthShader { public: - void Bind(); + void Bind(bool multisample); - FBufferedUniformSampler DepthTexture; - FBufferedUniform1f LinearizeDepthA; - FBufferedUniform1f LinearizeDepthB; - FBufferedUniform1f InverseDepthRangeA; - FBufferedUniform1f InverseDepthRangeB; + FBufferedUniformSampler DepthTexture[2]; + FBufferedUniform1i SampleCount[2]; + FBufferedUniform1f LinearizeDepthA[2]; + FBufferedUniform1f LinearizeDepthB[2]; + FBufferedUniform1f InverseDepthRangeA[2]; + FBufferedUniform1f InverseDepthRangeB[2]; private: - FShaderProgram mShader; + FShaderProgram mShader[2]; }; class FSSAOShader diff --git a/wadsrc/static/shaders/glsl/lineardepth.fp b/wadsrc/static/shaders/glsl/lineardepth.fp index f61bb3995..31df9dc32 100644 --- a/wadsrc/static/shaders/glsl/lineardepth.fp +++ b/wadsrc/static/shaders/glsl/lineardepth.fp @@ -2,7 +2,12 @@ in vec2 TexCoord; out vec4 FragColor; +#if defined(MULTISAMPLE) +uniform sampler2DMS DepthTexture; +uniform int SampleCount; +#else uniform sampler2D DepthTexture; +#endif uniform float LinearizeDepthA; uniform float LinearizeDepthB; uniform float InverseDepthRangeA; @@ -10,7 +15,21 @@ uniform float InverseDepthRangeB; void main() { +#if defined(MULTISAMPLE) + ivec2 texSize = textureSize(DepthTexture); + ivec2 ipos = ivec2(TexCoord * vec2(texSize)); + float depth = 0.0; + for (int i = 0; i < SampleCount; i++) + depth += texelFetch(DepthTexture, ipos, i).x; + depth /= float(SampleCount); +#else + /*ivec2 texSize = textureSize(DepthTexture, 0); + ivec2 ipos = ivec2(TexCoord * vec2(texSize)); + if (ipos.x < 0) ipos.x += texSize.x; + if (ipos.y < 0) ipos.y += texSize.y; + float depth = texelFetch(DepthTexture, ipos, 0).x;*/ float depth = texture(DepthTexture, TexCoord).x; +#endif float normalizedDepth = clamp(InverseDepthRangeA * depth + InverseDepthRangeB, 0.0, 1.0); FragColor = vec4(1.0 / (normalizedDepth * LinearizeDepthA + LinearizeDepthB), 0.0, 0.0, 1.0); } From c7c0ffadb55421a1d7723db9bb1dac46ebd1d005 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 3 Sep 2016 04:29:50 +0200 Subject: [PATCH 0970/1509] Move SSAO pass to be before translucent rendering Fix depth sampling location when not using fullscreen scene --- src/gl/renderer/gl_postprocess.cpp | 3 ++- src/gl/scene/gl_scene.cpp | 2 ++ src/gl/shaders/gl_ambientshader.cpp | 2 ++ src/gl/shaders/gl_ambientshader.h | 2 ++ wadsrc/static/shaders/glsl/lineardepth.fp | 12 +++++++++--- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 8282bc387..3031d80ba 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -177,6 +177,8 @@ void FGLRenderer::AmbientOccludeScene() mLinearDepthShader->LinearizeDepthB[multisample].Set(MAX(1.0f / GetZNear(), 1.e-8f)); mLinearDepthShader->InverseDepthRangeA[multisample].Set(1.0f); mLinearDepthShader->InverseDepthRangeB[multisample].Set(0.0f); + mLinearDepthShader->Scale[multisample].Set(mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height); + mLinearDepthShader->Offset[multisample].Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); RenderScreenQuad(); // Apply ambient occlusion @@ -236,7 +238,6 @@ void FGLRenderer::AmbientOccludeScene() mSSAOCombineShader->Bind(); mSSAOCombineShader->AODepthTexture.Set(0); RenderScreenQuad(); - glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); FGLDebug::PopGroup(); } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 27772a0ca..a50fe87f8 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -491,6 +491,8 @@ void FGLRenderer::DrawScene(int drawmode) RenderScene(recursion); + AmbientOccludeScene(); + // Handle all portals after rendering the opaque objects but before // doing all translucent stuff recursion++; diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index f3b6eced6..54a651281 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -65,6 +65,8 @@ void FLinearDepthShader::Bind(bool multisample) LinearizeDepthB[multisample].Init(shader, "LinearizeDepthB"); InverseDepthRangeA[multisample].Init(shader, "InverseDepthRangeA"); InverseDepthRangeB[multisample].Init(shader, "InverseDepthRangeB"); + Scale[multisample].Init(shader, "Scale"); + Offset[multisample].Init(shader, "Offset"); } shader.Bind(); } diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index 5f9ef630b..5b18ea85f 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -14,6 +14,8 @@ public: FBufferedUniform1f LinearizeDepthB[2]; FBufferedUniform1f InverseDepthRangeA[2]; FBufferedUniform1f InverseDepthRangeB[2]; + FBufferedUniform2f Scale[2]; + FBufferedUniform2f Offset[2]; private: FShaderProgram mShader[2]; diff --git a/wadsrc/static/shaders/glsl/lineardepth.fp b/wadsrc/static/shaders/glsl/lineardepth.fp index 31df9dc32..7e4eee745 100644 --- a/wadsrc/static/shaders/glsl/lineardepth.fp +++ b/wadsrc/static/shaders/glsl/lineardepth.fp @@ -8,28 +8,34 @@ uniform int SampleCount; #else uniform sampler2D DepthTexture; #endif + uniform float LinearizeDepthA; uniform float LinearizeDepthB; uniform float InverseDepthRangeA; uniform float InverseDepthRangeB; +uniform vec2 Scale; +uniform vec2 Offset; void main() { + vec2 uv = Offset + TexCoord * Scale; + #if defined(MULTISAMPLE) ivec2 texSize = textureSize(DepthTexture); - ivec2 ipos = ivec2(TexCoord * vec2(texSize)); + ivec2 ipos = ivec2(uv * vec2(texSize)); float depth = 0.0; for (int i = 0; i < SampleCount; i++) depth += texelFetch(DepthTexture, ipos, i).x; depth /= float(SampleCount); #else /*ivec2 texSize = textureSize(DepthTexture, 0); - ivec2 ipos = ivec2(TexCoord * vec2(texSize)); + ivec2 ipos = ivec2(uv * vec2(texSize)); if (ipos.x < 0) ipos.x += texSize.x; if (ipos.y < 0) ipos.y += texSize.y; float depth = texelFetch(DepthTexture, ipos, 0).x;*/ - float depth = texture(DepthTexture, TexCoord).x; + float depth = texture(DepthTexture, uv).x; #endif + float normalizedDepth = clamp(InverseDepthRangeA * depth + InverseDepthRangeB, 0.0, 1.0); FragColor = vec4(1.0 / (normalizedDepth * LinearizeDepthA + LinearizeDepthB), 0.0, 0.0, 1.0); } From e025f6e54bbf140c584030928706e95dee2bb8a5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 4 Sep 2016 08:15:29 +0200 Subject: [PATCH 0971/1509] Mark portals in scene alpha channel for the SSAO pass --- src/gl/renderer/gl_postprocess.cpp | 5 +++++ src/gl/scene/gl_portal.cpp | 8 +++++--- src/gl/shaders/gl_ambientshader.cpp | 1 + src/gl/shaders/gl_ambientshader.h | 1 + wadsrc/static/shaders/glsl/lineardepth.fp | 8 +++++--- wadsrc/static/shaders/glsl/stencil.fp | 2 +- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 3031d80ba..d2b1b14c1 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -170,8 +170,13 @@ void FGLRenderer::AmbientOccludeScene() mBuffers->BindSceneDepthTexture(0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + mBuffers->BindSceneColorTexture(1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glActiveTexture(GL_TEXTURE0); mLinearDepthShader->Bind(multisample); mLinearDepthShader->DepthTexture[multisample].Set(0); + mLinearDepthShader->ColorTexture[multisample].Set(1); if (multisample) mLinearDepthShader->SampleCount[multisample].Set(gl_multisample); mLinearDepthShader->LinearizeDepthA[multisample].Set(1.0f / GetZFar() - 1.0f / GetZNear()); mLinearDepthShader->LinearizeDepthB[multisample].Set(MAX(1.0f / GetZNear(), 1.e-8f)); diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index f34b5e23f..575ef968d 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -423,14 +423,16 @@ void GLPortal::End(bool usestencil) glDepthFunc(GL_LEQUAL); glDepthRange(0, 1); { - ScopedColorMask colorMask(0, 0, 0, 0); - // glColorMask(0,0,0,0); // no graphics + ScopedColorMask colorMask(0, 0, 0, 1); // mark portal in alpha channel but don't touch color gl_RenderState.SetEffect(EFF_STENCIL); gl_RenderState.EnableTexture(false); + gl_RenderState.BlendFunc(GL_ONE, GL_ZERO); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.Apply(); DrawPortalStencil(); gl_RenderState.SetEffect(EFF_NONE); gl_RenderState.EnableTexture(true); - } // glColorMask(1, 1, 1, 1); + } glDepthFunc(GL_LESS); } PortalAll.Unclock(); diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index 54a651281..3fbd03434 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -60,6 +60,7 @@ void FLinearDepthShader::Bind(bool multisample) shader.Link("shaders/glsl/lineardepth"); shader.SetAttribLocation(0, "PositionInProjection"); DepthTexture[multisample].Init(shader, "DepthTexture"); + ColorTexture[multisample].Init(shader, "ColorTexture"); SampleCount[multisample].Init(shader, "SampleCount"); LinearizeDepthA[multisample].Init(shader, "LinearizeDepthA"); LinearizeDepthB[multisample].Init(shader, "LinearizeDepthB"); diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index 5b18ea85f..9c97791ba 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -9,6 +9,7 @@ public: void Bind(bool multisample); FBufferedUniformSampler DepthTexture[2]; + FBufferedUniformSampler ColorTexture[2]; FBufferedUniform1i SampleCount[2]; FBufferedUniform1f LinearizeDepthA[2]; FBufferedUniform1f LinearizeDepthB[2]; diff --git a/wadsrc/static/shaders/glsl/lineardepth.fp b/wadsrc/static/shaders/glsl/lineardepth.fp index 7e4eee745..61e5e8126 100644 --- a/wadsrc/static/shaders/glsl/lineardepth.fp +++ b/wadsrc/static/shaders/glsl/lineardepth.fp @@ -4,9 +4,11 @@ out vec4 FragColor; #if defined(MULTISAMPLE) uniform sampler2DMS DepthTexture; +uniform sampler2DMS ColorTexture; uniform int SampleCount; #else uniform sampler2D DepthTexture; +uniform sampler2D ColorTexture; #endif uniform float LinearizeDepthA; @@ -25,15 +27,15 @@ void main() ivec2 ipos = ivec2(uv * vec2(texSize)); float depth = 0.0; for (int i = 0; i < SampleCount; i++) - depth += texelFetch(DepthTexture, ipos, i).x; + depth += texelFetch(ColorTexture, ipos, i).a != 0.0 ? texelFetch(DepthTexture, ipos, i).x : 1.0; depth /= float(SampleCount); #else /*ivec2 texSize = textureSize(DepthTexture, 0); ivec2 ipos = ivec2(uv * vec2(texSize)); if (ipos.x < 0) ipos.x += texSize.x; if (ipos.y < 0) ipos.y += texSize.y; - float depth = texelFetch(DepthTexture, ipos, 0).x;*/ - float depth = texture(DepthTexture, uv).x; + float depth = texelFetch(ColorTexture, ipos, 0).a != 0.0 ? texelFetch(DepthTexture, ipos, 0).x : 1.0;*/ + float depth = texture(ColorTexture, uv).a != 0.0 ? texture(DepthTexture, uv).x : 1.0; #endif float normalizedDepth = clamp(InverseDepthRangeA * depth + InverseDepthRangeB, 0.0, 1.0); diff --git a/wadsrc/static/shaders/glsl/stencil.fp b/wadsrc/static/shaders/glsl/stencil.fp index d1b8745f6..65f12b405 100644 --- a/wadsrc/static/shaders/glsl/stencil.fp +++ b/wadsrc/static/shaders/glsl/stencil.fp @@ -3,6 +3,6 @@ out vec4 FragColor; void main() { - FragColor = vec4(1.0); + FragColor = vec4(1.0, 1.0, 1.0, 0.0); } From 11725c435e623470633fc4589dc9134abd59824e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 9 Sep 2016 09:47:46 +0200 Subject: [PATCH 0972/1509] Grab tanHalfFovy from the projection matrix --- src/gl/renderer/gl_postprocess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index d2b1b14c1..232ad91ba 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -158,7 +158,7 @@ void FGLRenderer::AmbientOccludeScene() bool multisample = gl_multisample > 1; //float tanHalfFovy = tan(fovy * (M_PI / 360.0f)); - float tanHalfFovy = 1.0f / 1.33333302f; // 1.0f / gl_RenderState.mProjectionMatrix.get()[5]; + float tanHalfFovy = 1.0f / gl_RenderState.mProjectionMatrix.get()[5]; float invFocalLenX = tanHalfFovy * (mBuffers->GetSceneWidth() / (float)mBuffers->GetSceneHeight()); float invFocalLenY = tanHalfFovy; float nDotVBias = clamp(bias, 0.0f, 1.0f); From 24ab13f1ce6cf2ed4455f74a0d6cdc9afac9631a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 9 Sep 2016 18:19:00 +0200 Subject: [PATCH 0973/1509] Fix stripes in the reconstructed normals due to down scaling --- src/gl/renderer/gl_postprocess.cpp | 2 +- wadsrc/static/shaders/glsl/lineardepth.fp | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 232ad91ba..da56dc2cf 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -182,7 +182,7 @@ void FGLRenderer::AmbientOccludeScene() mLinearDepthShader->LinearizeDepthB[multisample].Set(MAX(1.0f / GetZNear(), 1.e-8f)); mLinearDepthShader->InverseDepthRangeA[multisample].Set(1.0f); mLinearDepthShader->InverseDepthRangeB[multisample].Set(0.0f); - mLinearDepthShader->Scale[multisample].Set(mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height); + mLinearDepthShader->Scale[multisample].Set(mBuffers->AmbientWidth * 2.0f / (float)mScreenViewport.width, mBuffers->AmbientHeight * 2.0f / (float)mScreenViewport.height); mLinearDepthShader->Offset[multisample].Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); RenderScreenQuad(); diff --git a/wadsrc/static/shaders/glsl/lineardepth.fp b/wadsrc/static/shaders/glsl/lineardepth.fp index 61e5e8126..558738bd9 100644 --- a/wadsrc/static/shaders/glsl/lineardepth.fp +++ b/wadsrc/static/shaders/glsl/lineardepth.fp @@ -24,18 +24,21 @@ void main() #if defined(MULTISAMPLE) ivec2 texSize = textureSize(DepthTexture); - ivec2 ipos = ivec2(uv * vec2(texSize)); +#else + ivec2 texSize = textureSize(DepthTexture, 0); +#endif + + // Use floor here because as we downscale the sampling error has to remain uniform to prevent + // noise in the depth values. + ivec2 ipos = ivec2(max(floor(uv * vec2(texSize) - 0.75), vec2(0.0))); + +#if defined(MULTISAMPLE) float depth = 0.0; for (int i = 0; i < SampleCount; i++) depth += texelFetch(ColorTexture, ipos, i).a != 0.0 ? texelFetch(DepthTexture, ipos, i).x : 1.0; depth /= float(SampleCount); #else - /*ivec2 texSize = textureSize(DepthTexture, 0); - ivec2 ipos = ivec2(uv * vec2(texSize)); - if (ipos.x < 0) ipos.x += texSize.x; - if (ipos.y < 0) ipos.y += texSize.y; - float depth = texelFetch(ColorTexture, ipos, 0).a != 0.0 ? texelFetch(DepthTexture, ipos, 0).x : 1.0;*/ - float depth = texture(ColorTexture, uv).a != 0.0 ? texture(DepthTexture, uv).x : 1.0; + float depth = texelFetch(ColorTexture, ipos, 0).a != 0.0 ? texelFetch(DepthTexture, ipos, 0).x : 1.0; #endif float normalizedDepth = clamp(InverseDepthRangeA * depth + InverseDepthRangeB, 0.0, 1.0); From 0a8cc1b74c8176deff39f931da68b3f698d030bd Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 10 Sep 2016 22:39:09 +0200 Subject: [PATCH 0974/1509] Fix depth blur --- src/gl/renderer/gl_postprocess.cpp | 12 ++++------ wadsrc/static/shaders/glsl/depthblur.fp | 32 ++++++++----------------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index da56dc2cf..c58f6ea3a 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -108,11 +108,6 @@ CUSTOM_CVAR(Float, gl_ssao_blur_amount, 4.0f, 0) { if (self < 0.1f) self = 0.1f; } -CUSTOM_CVAR(Int, gl_ssao_blur_samples, 5, 0) -{ - if (self < 3 || self > 15 || self % 2 == 0) - self = 9; -} EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) @@ -153,7 +148,6 @@ void FGLRenderer::AmbientOccludeScene() float bias = gl_ssao_bias; float aoRadius = gl_ssao_radius; const float blurAmount = gl_ssao_blur_amount; - int blurSampleCount = gl_ssao_blur_samples; float aoStrength = gl_ssao_strength; bool multisample = gl_multisample > 1; @@ -164,6 +158,8 @@ void FGLRenderer::AmbientOccludeScene() float nDotVBias = clamp(bias, 0.0f, 1.0f); float r2 = aoRadius * aoRadius; + float blurSharpness = 1.0f / blurAmount; + // Calculate linear depth values glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB0); glViewport(0, 0, mBuffers->AmbientWidth, mBuffers->AmbientHeight); @@ -215,14 +211,14 @@ void FGLRenderer::AmbientOccludeScene() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); mDepthBlurShader->Bind(false); - mDepthBlurShader->BlurSharpness[false].Set(blurAmount); + mDepthBlurShader->BlurSharpness[false].Set(blurSharpness); mDepthBlurShader->InvFullResolution[false].Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); RenderScreenQuad(); glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB1); glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture0); mDepthBlurShader->Bind(true); - mDepthBlurShader->BlurSharpness[true].Set(blurAmount); + mDepthBlurShader->BlurSharpness[true].Set(blurSharpness); mDepthBlurShader->InvFullResolution[true].Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); mDepthBlurShader->PowExponent[true].Set(1.8f); RenderScreenQuad(); diff --git a/wadsrc/static/shaders/glsl/depthblur.fp b/wadsrc/static/shaders/glsl/depthblur.fp index bd464d03d..c4f4438d3 100644 --- a/wadsrc/static/shaders/glsl/depthblur.fp +++ b/wadsrc/static/shaders/glsl/depthblur.fp @@ -7,39 +7,32 @@ uniform float BlurSharpness; uniform vec2 InvFullResolution; uniform float PowExponent; -#define KERNEL_RADIUS 3.0 +#define KERNEL_RADIUS 7.0 -struct CenterPixelData -{ - vec2 UV; - float Depth; - float Sharpness; -}; - -float CrossBilateralWeight(float r, float sampleDepth, CenterPixelData center) +float CrossBilateralWeight(float r, float sampleDepth, float centerDepth) { const float blurSigma = KERNEL_RADIUS * 0.5; const float blurFalloff = 1.0 / (2.0 * blurSigma * blurSigma); - float deltaZ = (sampleDepth - center.Depth) * center.Sharpness; + float deltaZ = (sampleDepth - centerDepth) * BlurSharpness; return exp2(-r * r * blurFalloff - deltaZ * deltaZ); } -void ProcessSample(float ao, float z, float r, CenterPixelData center, inout float totalAO, inout float totalW) +void ProcessSample(float ao, float z, float r, float centerDepth, inout float totalAO, inout float totalW) { - float w = CrossBilateralWeight(r, z, center); + float w = CrossBilateralWeight(r, z, centerDepth); totalAO += w * ao; totalW += w; } -void ProcessRadius(vec2 deltaUV, CenterPixelData center, inout float totalAO, inout float totalW) +void ProcessRadius(vec2 deltaUV, float centerDepth, inout float totalAO, inout float totalW) { for (float r = 1; r <= KERNEL_RADIUS; r += 1.0) { - vec2 uv = r * deltaUV + center.UV; + vec2 uv = r * deltaUV + TexCoord; vec2 aoZ = texture(AODepthTexture, uv).xy; - ProcessSample(aoZ.x, aoZ.y, r, center, totalAO, totalW); + ProcessSample(aoZ.x, aoZ.y, r, centerDepth, totalAO, totalW); } } @@ -47,16 +40,11 @@ vec2 ComputeBlur(vec2 deltaUV) { vec2 aoZ = texture(AODepthTexture, TexCoord).xy; - CenterPixelData center; - center.UV = TexCoord; - center.Depth = aoZ.y; - center.Sharpness = BlurSharpness; - float totalAO = aoZ.x; float totalW = 1.0; - ProcessRadius(deltaUV, center, totalAO, totalW); - ProcessRadius(-deltaUV, center, totalAO, totalW); + ProcessRadius(deltaUV, aoZ.y, totalAO, totalW); + ProcessRadius(-deltaUV, aoZ.y, totalAO, totalW); return vec2(totalAO / totalW, aoZ.y); } From 37e3172c945298a95709e81752c783bc70b2f8c4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 11 Sep 2016 11:09:40 +0200 Subject: [PATCH 0975/1509] Fix random texture sampling bug --- src/gl/renderer/gl_postprocess.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index c58f6ea3a..f89776d63 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -191,6 +191,8 @@ void FGLRenderer::AmbientOccludeScene() glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientRandomTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glActiveTexture(GL_TEXTURE0); mSSAOShader->Bind(); mSSAOShader->DepthTexture.Set(0); From 9af34bac69147d22774ac9c999dc3ef751efa86a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 20 Sep 2016 02:57:57 +0200 Subject: [PATCH 0976/1509] Add gbuffer pass support to FShaderManager and FRenderState --- src/gl/renderer/gl_renderstate.cpp | 7 +- src/gl/renderer/gl_renderstate.h | 19 +++ src/gl/shaders/gl_shader.cpp | 179 ++++++++++++++++++----------- src/gl/shaders/gl_shader.h | 46 +++++--- wadsrc/static/shaders/glsl/main.fp | 6 + 5 files changed, 170 insertions(+), 87 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 967296cb8..17f19455e 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -105,6 +105,7 @@ void FRenderState::Reset() mViewMatrix.loadIdentity(); mModelMatrix.loadIdentity(); mTextureMatrix.loadIdentity(); + mPassType = NORMAL_PASS; } //========================================================================== @@ -118,11 +119,11 @@ bool FRenderState::ApplyShader() static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f }; if (mSpecialEffect > EFF_NONE) { - activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect); + activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect, mPassType); } else { - activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4, mAlphaThreshold >= 0.f); + activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4, mAlphaThreshold >= 0.f, mPassType); activeShader->Bind(); } @@ -342,7 +343,7 @@ void FRenderState::ApplyMatrices() { if (GLRenderer->mShaderManager != NULL) { - GLRenderer->mShaderManager->ApplyMatrices(&mProjectionMatrix, &mViewMatrix); + GLRenderer->mShaderManager->ApplyMatrices(&mProjectionMatrix, &mViewMatrix, mPassType); } } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 1c0a20348..7bec51be0 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -63,6 +63,13 @@ enum EEffect MAX_EFFECTS }; +enum EPassType +{ + NORMAL_PASS, + GBUFFER_PASS, + MAX_PASS_TYPES +}; + class FRenderState { bool mTextureEnabled; @@ -111,6 +118,8 @@ class FRenderState FShader *activeShader; + EPassType mPassType = NORMAL_PASS; + bool ApplyShader(); public: @@ -459,6 +468,16 @@ public: return mInterpolationFactor; } + void SetPassType(EPassType passType) + { + mPassType = passType; + } + + EPassType GetPassType() + { + return mPassType; + } + // Backwards compatibility crap follows void ApplyFixedFunction(); void DrawColormapOverlay(); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index d4e05dfa8..59b941e86 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -180,6 +180,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * glBindAttribLocation(hShader, VATTR_COLOR, "aColor"); glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2"); + glBindFragDataLocation(hShader, 0, "FragColor"); + glBindFragDataLocation(hShader, 1, "FragData"); + glLinkProgram(hShader); glGetShaderInfoLog(hVertProg, 10000, NULL, buffer); @@ -297,12 +300,13 @@ bool FShader::Bind() // //========================================================================== -FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath, bool usediscard) +FShader *FShaderCollection::Compile (const char *ShaderName, const char *ShaderPath, bool usediscard, EPassType passType) { FString defines; // this can't be in the shader code due to ATI strangeness. if (gl.MaxLights() == 128) defines += "#define MAXLIGHTS128\n"; if (!usediscard) defines += "#define NO_ALPHATEST\n"; + if (passType == GBUFFER_PASS) defines += "#define GBUFFER_PASS\n"; FShader *shader = NULL; try @@ -385,27 +389,75 @@ static const FEffectShader effectshaders[]= { "stencil", "shaders/glsl/main.vp", "shaders/glsl/stencil.fp", NULL, "#define SIMPLE\n#define NO_ALPHATEST\n" }, }; - -//========================================================================== -// -// -// -//========================================================================== - FShaderManager::FShaderManager() { - if (!gl.legacyMode) CompileShaders(); + if (!gl.legacyMode) + { + for (int passType = 0; passType < MAX_PASS_TYPES; passType++) + mPassShaders.Push(new FShaderCollection((EPassType)passType)); + } } -//========================================================================== -// -// -// -//========================================================================== - FShaderManager::~FShaderManager() { - if (!gl.legacyMode) Clean(); + if (!gl.legacyMode) + { + glUseProgram(0); + mActiveShader = NULL; + + for (auto collection : mPassShaders) + delete collection; + } +} + +void FShaderManager::SetActiveShader(FShader *sh) +{ + if (mActiveShader != sh) + { + glUseProgram(sh!= NULL? sh->GetHandle() : 0); + mActiveShader = sh; + } +} + +FShader *FShaderManager::BindEffect(int effect, EPassType passType) +{ + if (passType < mPassShaders.Size()) + return mPassShaders[passType]->BindEffect(effect); + else + return nullptr; +} + +FShader *FShaderManager::Get(unsigned int eff, bool alphateston, EPassType passType) +{ + if (passType < mPassShaders.Size()) + return mPassShaders[passType]->Get(eff, alphateston); + else + return nullptr; +} + +void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view, EPassType passType) +{ + if (gl.legacyMode) + { + glMatrixMode(GL_PROJECTION); + glLoadMatrixf(proj->get()); + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(view->get()); + } + else + { + if (passType < mPassShaders.Size()) + mPassShaders[passType]->ApplyMatrices(proj, view); + + if (mActiveShader) + mActiveShader->Bind(); + } +} + +void FShaderManager::ResetFixedColormap() +{ + for (auto &collection : mPassShaders) + collection->ResetFixedColormap(); } //========================================================================== @@ -414,10 +466,30 @@ FShaderManager::~FShaderManager() // //========================================================================== -void FShaderManager::CompileShaders() +FShaderCollection::FShaderCollection(EPassType passType) { - mActiveShader = NULL; + CompileShaders(passType); +} +//========================================================================== +// +// +// +//========================================================================== + +FShaderCollection::~FShaderCollection() +{ + Clean(); +} + +//========================================================================== +// +// +// +//========================================================================== + +void FShaderCollection::CompileShaders(EPassType passType) +{ mTextureEffects.Clear(); mTextureEffectsNAT.Clear(); for (int i = 0; i < MAX_EFFECTS; i++) @@ -427,11 +499,11 @@ void FShaderManager::CompileShaders() for(int i=0;defaultshaders[i].ShaderName != NULL;i++) { - FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, true); + FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, true, passType); mTextureEffects.Push(shc); if (i <= 3) { - FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, false); + FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, false, passType); mTextureEffectsNAT.Push(shc); } } @@ -441,7 +513,7 @@ void FShaderManager::CompileShaders() FString name = ExtractFileBase(usershaders[i]); FName sfn = name; - FShader *shc = Compile(sfn, usershaders[i], true); + FShader *shc = Compile(sfn, usershaders[i], true, passType); mTextureEffects.Push(shc); } @@ -463,11 +535,8 @@ void FShaderManager::CompileShaders() // //========================================================================== -void FShaderManager::Clean() +void FShaderCollection::Clean() { - glUseProgram(0); - mActiveShader = NULL; - for (unsigned int i = 0; i < mTextureEffectsNAT.Size(); i++) { if (mTextureEffectsNAT[i] != NULL) delete mTextureEffectsNAT[i]; @@ -491,7 +560,7 @@ void FShaderManager::Clean() // //========================================================================== -int FShaderManager::Find(const char * shn) +int FShaderCollection::Find(const char * shn) { FName sfn = shn; @@ -505,21 +574,6 @@ int FShaderManager::Find(const char * shn) return -1; } -//========================================================================== -// -// -// -//========================================================================== - -void FShaderManager::SetActiveShader(FShader *sh) -{ - if (mActiveShader != sh) - { - glUseProgram(sh!= NULL? sh->GetHandle() : 0); - mActiveShader = sh; - } -} - //========================================================================== // @@ -527,7 +581,7 @@ void FShaderManager::SetActiveShader(FShader *sh) // //========================================================================== -FShader *FShaderManager::BindEffect(int effect) +FShader *FShaderCollection::BindEffect(int effect) { if (effect >= 0 && effect < MAX_EFFECTS && mEffectShaders[effect] != NULL) { @@ -545,36 +599,25 @@ FShader *FShaderManager::BindEffect(int effect) //========================================================================== EXTERN_CVAR(Int, gl_fuzztype) -void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view) +void FShaderCollection::ApplyMatrices(VSMatrix *proj, VSMatrix *view) { - if (gl.legacyMode) + for (int i = 0; i < 4; i++) { - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(proj->get()); - glMatrixMode(GL_MODELVIEW); - glLoadMatrixf(view->get()); + mTextureEffects[i]->ApplyMatrices(proj, view); + mTextureEffectsNAT[i]->ApplyMatrices(proj, view); } - else + mTextureEffects[4]->ApplyMatrices(proj, view); + if (gl_fuzztype != 0) { - for (int i = 0; i < 4; i++) - { - mTextureEffects[i]->ApplyMatrices(proj, view); - mTextureEffectsNAT[i]->ApplyMatrices(proj, view); - } - mTextureEffects[4]->ApplyMatrices(proj, view); - if (gl_fuzztype != 0) - { - mTextureEffects[4 + gl_fuzztype]->ApplyMatrices(proj, view); - } - for (unsigned i = 12; i < mTextureEffects.Size(); i++) - { - mTextureEffects[i]->ApplyMatrices(proj, view); - } - for (int i = 0; i < MAX_EFFECTS; i++) - { - mEffectShaders[i]->ApplyMatrices(proj, view); - } - if (mActiveShader != NULL) mActiveShader->Bind(); + mTextureEffects[4 + gl_fuzztype]->ApplyMatrices(proj, view); + } + for (unsigned i = 12; i < mTextureEffects.Size(); i++) + { + mTextureEffects[i]->ApplyMatrices(proj, view); + } + for (int i = 0; i < MAX_EFFECTS; i++) + { + mEffectShaders[i]->ApplyMatrices(proj, view); } } diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 343942321..ce285c3ee 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -37,6 +37,7 @@ enum VATTR_NORMAL = 4 }; +class FShaderCollection; //========================================================================== // @@ -248,7 +249,7 @@ public: class FShader { - friend class FShaderManager; + friend class FShaderCollection; friend class FRenderState; unsigned int hShader; @@ -322,7 +323,6 @@ public: }; - //========================================================================== // // The global shader manager @@ -330,26 +330,40 @@ public: //========================================================================== class FShaderManager { - TArray mTextureEffects; - TArray mTextureEffectsNAT; - FShader *mActiveShader; - FShader *mEffectShaders[MAX_EFFECTS]; - - void Clean(); - void CompileShaders(); - public: FShaderManager(); ~FShaderManager(); - FShader *Compile(const char *ShaderName, const char *ShaderPath, bool usediscard); + + void SetActiveShader(FShader *sh); + FShader *GetActiveShader() const { return mActiveShader; } + + FShader *BindEffect(int effect, EPassType passType); + FShader *Get(unsigned int eff, bool alphateston, EPassType passType); + void ApplyMatrices(VSMatrix *proj, VSMatrix *view, EPassType passType); + + void ResetFixedColormap(); + +private: + FShader *mActiveShader = nullptr; + TArray mPassShaders; +}; + +class FShaderCollection +{ + TArray mTextureEffects; + TArray mTextureEffectsNAT; + FShader *mEffectShaders[MAX_EFFECTS]; + + void Clean(); + void CompileShaders(EPassType passType); + +public: + FShaderCollection(EPassType passType); + ~FShaderCollection(); + FShader *Compile(const char *ShaderName, const char *ShaderPath, bool usediscard, EPassType passType); int Find(const char *mame); FShader *BindEffect(int effect); - void SetActiveShader(FShader *sh); void ApplyMatrices(VSMatrix *proj, VSMatrix *view); - FShader *GetActiveShader() const - { - return mActiveShader; - } void ResetFixedColormap() { diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 95ac874b7..4d3531f01 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -5,6 +5,9 @@ in vec4 vTexCoord; in vec4 vColor; out vec4 FragColor; +#ifdef GBUFFER_PASS +out vec4 FragData; +#endif #ifdef SHADER_STORAGE_LIGHTS layout(std430, binding = 1) buffer LightBufferSSO @@ -345,5 +348,8 @@ void main() } } FragColor = frag; +#ifdef GBUFFER_PASS + FragData = vec4(uFogColor.rgb, 1.0); +#endif } From d7741362823fbe3bca3821b20fe75d0802575379 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 21 Sep 2016 02:04:56 +0200 Subject: [PATCH 0977/1509] Added SceneData texture as the second colorbuffer when rendering a scene and placed fog data into it --- src/gl/renderer/gl_postprocess.cpp | 18 ++++++++------ src/gl/renderer/gl_renderer.cpp | 2 +- src/gl/scene/gl_scene.cpp | 23 ++++++++++++++++-- src/gl/shaders/gl_ambientshader.cpp | 23 +++++++++++------- src/gl/shaders/gl_ambientshader.h | 10 +++++--- src/gl/system/gl_cvars.h | 6 +++++ wadsrc/static/shaders/glsl/main.fp | 28 +++++++++++++++++++++- wadsrc/static/shaders/glsl/ssaocombine.fp | 29 ++++++++++++++++++++++- 8 files changed, 115 insertions(+), 24 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index f89776d63..3b94fd8cc 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -137,9 +137,6 @@ void FGLRenderer::PostProcessScene() void FGLRenderer::AmbientOccludeScene() { - if (!gl_ssao || !FGLRenderBuffers::IsEnabled()) - return; - FGLDebug::PushGroup("AmbientOccludeScene"); FGLPostProcessState savedState; @@ -226,20 +223,27 @@ void FGLRenderer::AmbientOccludeScene() RenderScreenQuad(); // Add SSAO back to scene texture: - mBuffers->BindSceneFB(); + mBuffers->BindSceneFB(false); + GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; + glDrawBuffers(1, buffers); glViewport(mSceneViewport.left, mSceneViewport.top, mSceneViewport.width, mSceneViewport.height); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); if (gl_ssao_debug) glBlendFunc(GL_ONE, GL_ZERO); else - glBlendFunc(GL_ZERO, GL_SRC_COLOR); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - mSSAOCombineShader->Bind(); - mSSAOCombineShader->AODepthTexture.Set(0); + mBuffers->BindSceneDataTexture(1); + mSSAOCombineShader->Bind(multisample); + mSSAOCombineShader->AODepthTexture[multisample].Set(0); + mSSAOCombineShader->SceneDataTexture[multisample].Set(1); + if (multisample) mSSAOCombineShader->SampleCount[multisample].Set(gl_multisample); + mSSAOCombineShader->Scale[multisample].Set(mBuffers->AmbientWidth * 2.0f / (float)mScreenViewport.width, mBuffers->AmbientHeight * 2.0f / (float)mScreenViewport.height); + mSSAOCombineShader->Offset[multisample].Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); RenderScreenQuad(); FGLDebug::PopGroup(); diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index befa330e9..368db63d2 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -323,7 +323,7 @@ void FGLRenderer::Begin2D() if (mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height)) { if (mDrawingScene2D) - mBuffers->BindSceneFB(); + mBuffers->BindSceneFB(false); else mBuffers->BindCurrentFB(); } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index a50fe87f8..6a8c9a11a 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -158,7 +158,11 @@ void FGLRenderer::Set3DViewport(bool mainview) { if (mainview && mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height)) { - mBuffers->BindSceneFB(); + mBuffers->BindSceneFB(gl_ssao); + GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; + glDrawBuffers(gl_ssao ? 2 : 1, buffers); + gl_RenderState.SetPassType(gl_ssao ? GBUFFER_PASS : NORMAL_PASS); + gl_RenderState.Apply(); } // Always clear all buffers with scissor test disabled. @@ -491,7 +495,13 @@ void FGLRenderer::DrawScene(int drawmode) RenderScene(recursion); - AmbientOccludeScene(); + bool applySSAO = gl_ssao && FGLRenderBuffers::IsEnabled() && drawmode != DM_PORTAL; + if (applySSAO) + { + AmbientOccludeScene(); + gl_RenderState.SetPassType(GBUFFER_PASS); + gl_RenderState.Apply(); + } // Handle all portals after rendering the opaque objects but before // doing all translucent stuff @@ -499,6 +509,15 @@ void FGLRenderer::DrawScene(int drawmode) GLPortal::EndFrame(); recursion--; RenderTranslucent(); + + if (applySSAO) + { + mBuffers->BindSceneFB(true); + GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; + glDrawBuffers(2, buffers); + gl_RenderState.SetPassType(NORMAL_PASS); + gl_RenderState.Apply(); + } } diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index 3fbd03434..4fa5b0e01 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -120,16 +120,21 @@ void FDepthBlurShader::Bind(bool vertical) shader.Bind(); } -void FSSAOCombineShader::Bind() +void FSSAOCombineShader::Bind(bool multisample) { - if (!mShader) + auto &shader = mShader[multisample]; + if (!shader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); - mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssaocombine.fp", "", 330); - mShader.SetFragDataLocation(0, "FragColor"); - mShader.Link("shaders/glsl/ssaocombine"); - mShader.SetAttribLocation(0, "PositionInProjection"); - AODepthTexture.Init(mShader, "AODepthTexture"); + shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + shader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssaocombine.fp", multisample ? "#define MULTISAMPLE\n" : "", 330); + shader.SetFragDataLocation(0, "FragColor"); + shader.Link("shaders/glsl/ssaocombine"); + shader.SetAttribLocation(0, "PositionInProjection"); + AODepthTexture[multisample].Init(shader, "AODepthTexture"); + SceneDataTexture[multisample].Init(shader, "SceneDataTexture"); + SampleCount[multisample].Init(shader, "SampleCount"); + Scale[multisample].Init(shader, "Scale"); + Offset[multisample].Init(shader, "Offset"); } - mShader.Bind(); + shader.Bind(); } diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index 9c97791ba..f36b10625 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -59,12 +59,16 @@ private: class FSSAOCombineShader { public: - void Bind(); + void Bind(bool multisample); - FBufferedUniformSampler AODepthTexture; + FBufferedUniformSampler AODepthTexture[2]; + FBufferedUniformSampler SceneDataTexture[2]; + FBufferedUniform1i SampleCount[2]; + FBufferedUniform2f Scale[2]; + FBufferedUniform2f Offset[2]; private: - FShaderProgram mShader; + FShaderProgram mShader[2]; }; #endif \ No newline at end of file diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index 4cda3657d..97bd0b46c 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -50,6 +50,12 @@ EXTERN_CVAR(Bool, gl_lens) EXTERN_CVAR(Float, gl_lens_k) EXTERN_CVAR(Float, gl_lens_kcube) EXTERN_CVAR(Float, gl_lens_chromatic) +EXTERN_CVAR(Bool, gl_ssao) +EXTERN_CVAR(Float, gl_ssao_strength) +EXTERN_CVAR(Bool, gl_ssao_debug) +EXTERN_CVAR(Float, gl_ssao_bias) +EXTERN_CVAR(Float, gl_ssao_radius) +EXTERN_CVAR(Float, gl_ssao_blur_amount) EXTERN_CVAR(Int, gl_debug_level) EXTERN_CVAR(Bool, gl_debug_breakpoint) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 4d3531f01..0d2b419c1 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -233,6 +233,32 @@ vec4 applyFog(vec4 frag, float fogfactor) return vec4(mix(uFogColor.rgb, frag.rgb, fogfactor), frag.a); } +//=========================================================================== +// +// The color of the fragment if it is fully occluded by ambient lighting +// +//=========================================================================== + +vec3 AmbientOcclusionColor() +{ + float fogdist; + float fogfactor; + + // + // calculate fog factor + // + if (uFogEnabled == -1) + { + fogdist = pixelpos.w; + } + else + { + fogdist = max(16.0, length(pixelpos.xyz)); + } + fogfactor = exp2 (uFogDensity * fogdist); + + return mix(uFogColor.rgb, vec3(0.0), fogfactor); +} //=========================================================================== // @@ -349,7 +375,7 @@ void main() } FragColor = frag; #ifdef GBUFFER_PASS - FragData = vec4(uFogColor.rgb, 1.0); + FragData = vec4(AmbientOcclusionColor(), 1.0); #endif } diff --git a/wadsrc/static/shaders/glsl/ssaocombine.fp b/wadsrc/static/shaders/glsl/ssaocombine.fp index 21fdff102..7cd096276 100644 --- a/wadsrc/static/shaders/glsl/ssaocombine.fp +++ b/wadsrc/static/shaders/glsl/ssaocombine.fp @@ -4,8 +4,35 @@ out vec4 FragColor; uniform sampler2D AODepthTexture; +#if defined(MULTISAMPLE) +uniform sampler2DMS SceneDataTexture; +uniform int SampleCount; +#else +uniform sampler2D SceneDataTexture; +#endif + +uniform vec2 Scale; +uniform vec2 Offset; + void main() { + vec2 uv = Offset + TexCoord * Scale; +#if defined(MULTISAMPLE) + ivec2 texSize = textureSize(SceneDataTexture); +#else + ivec2 texSize = textureSize(SceneDataTexture, 0); +#endif + ivec2 ipos = ivec2(max(floor(uv * vec2(texSize) - 0.75), vec2(0.0))); + +#if defined(MULTISAMPLE) + vec3 fogColor = vec3(0.0); + for (int i = 0; i < SampleCount; i++) + fogColor += texelFetch(SceneDataTexture, ipos, i).rgb; + fogColor /= float(SampleCount); +#else + vec3 fogColor = texelFetch(SceneDataTexture, ipos, 0).rgb; +#endif + float attenutation = texture(AODepthTexture, TexCoord).x; - FragColor = vec4(attenutation, attenutation, attenutation, 0.0); + FragColor = vec4(fogColor, 1.0 - attenutation); } From 0397fe185f68d923fec0cee03faee4bc946e0126 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 22 Sep 2016 03:49:19 +0200 Subject: [PATCH 0978/1509] Don't do ambient occlusion when rendering to texture --- src/gl/scene/gl_scene.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 6a8c9a11a..59d6e0987 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -493,14 +493,29 @@ void FGLRenderer::DrawScene(int drawmode) } GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. - RenderScene(recursion); - - bool applySSAO = gl_ssao && FGLRenderBuffers::IsEnabled() && drawmode != DM_PORTAL; + // If SSAO is active, switch to gbuffer shaders and use the gbuffer framebuffer + bool applySSAO = gl_ssao && FGLRenderBuffers::IsEnabled() && drawmode == DM_MAINVIEW; if (applySSAO) { - AmbientOccludeScene(); + GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; + glDrawBuffers(2, buffers); gl_RenderState.SetPassType(GBUFFER_PASS); gl_RenderState.Apply(); + gl_RenderState.ApplyMatrices(); + } + + RenderScene(recursion); + + // Apply ambient occlusion and switch back to shaders without gbuffer output + if (applySSAO) + { + GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; + glDrawBuffers(1, buffers); + AmbientOccludeScene(); + mBuffers->BindSceneFB(true); + gl_RenderState.SetPassType(NORMAL_PASS); + gl_RenderState.Apply(); + gl_RenderState.ApplyMatrices(); } // Handle all portals after rendering the opaque objects but before @@ -509,15 +524,6 @@ void FGLRenderer::DrawScene(int drawmode) GLPortal::EndFrame(); recursion--; RenderTranslucent(); - - if (applySSAO) - { - mBuffers->BindSceneFB(true); - GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; - glDrawBuffers(2, buffers); - gl_RenderState.SetPassType(NORMAL_PASS); - gl_RenderState.Apply(); - } } From 3f11c0562c446ce2c007c8a10ec99f3898ccc7fe Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 24 Sep 2016 19:26:25 +0200 Subject: [PATCH 0979/1509] Add ssao quality setting --- src/gl/renderer/gl_postprocess.cpp | 7 +++- src/gl/scene/gl_scene.cpp | 9 +++-- src/gl/shaders/gl_ambientshader.cpp | 63 ++++++++++++++++++----------- src/gl/shaders/gl_ambientshader.h | 13 +++++- src/gl/system/gl_cvars.h | 2 +- wadsrc/static/language.enu | 5 ++- wadsrc/static/menudef.zz | 10 ++++- 7 files changed, 76 insertions(+), 33 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 3b94fd8cc..2fcfe245a 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -99,7 +99,12 @@ CVAR(Float, gl_lens_k, -0.12f, 0) CVAR(Float, gl_lens_kcube, 0.1f, 0) CVAR(Float, gl_lens_chromatic, 1.12f, 0) -CVAR(Bool, gl_ssao, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CUSTOM_CVAR(Int, gl_ssao, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (self < 0 || self > 3) + self = 0; +} + CVAR(Float, gl_ssao_strength, 0.7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, gl_ssao_debug, false, 0) CVAR(Float, gl_ssao_bias, 0.5f, 0) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 59d6e0987..3efd22155 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -158,10 +158,11 @@ void FGLRenderer::Set3DViewport(bool mainview) { if (mainview && mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height)) { - mBuffers->BindSceneFB(gl_ssao); + bool useSSAO = (gl_ssao != 0); + mBuffers->BindSceneFB(useSSAO); GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; - glDrawBuffers(gl_ssao ? 2 : 1, buffers); - gl_RenderState.SetPassType(gl_ssao ? GBUFFER_PASS : NORMAL_PASS); + glDrawBuffers(useSSAO ? 2 : 1, buffers); + gl_RenderState.SetPassType(useSSAO ? GBUFFER_PASS : NORMAL_PASS); gl_RenderState.Apply(); } @@ -494,7 +495,7 @@ void FGLRenderer::DrawScene(int drawmode) GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. // If SSAO is active, switch to gbuffer shaders and use the gbuffer framebuffer - bool applySSAO = gl_ssao && FGLRenderBuffers::IsEnabled() && drawmode == DM_MAINVIEW; + bool applySSAO = gl_ssao != 0 && FGLRenderBuffers::IsEnabled() && drawmode == DM_MAINVIEW; if (applySSAO) { GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index 4fa5b0e01..7d0e26a6a 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -74,32 +74,47 @@ void FLinearDepthShader::Bind(bool multisample) void FSSAOShader::Bind() { - if (!mShader) + auto &shader = mShader[gl_ssao]; + if (!shader) { - const char *defines = R"( - #define USE_RANDOM_TEXTURE - #define RANDOM_TEXTURE_WIDTH 4.0 - #define NUM_DIRECTIONS 8.0 - #define NUM_STEPS 4.0 - )"; - - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); - mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssao.fp", defines, 330); - mShader.SetFragDataLocation(0, "FragColor"); - mShader.Link("shaders/glsl/ssao"); - mShader.SetAttribLocation(0, "PositionInProjection"); - DepthTexture.Init(mShader, "DepthTexture"); - RandomTexture.Init(mShader, "RandomTexture"); - UVToViewA.Init(mShader, "UVToViewA"); - UVToViewB.Init(mShader, "UVToViewB"); - InvFullResolution.Init(mShader, "InvFullResolution"); - NDotVBias.Init(mShader, "NDotVBias"); - NegInvR2.Init(mShader, "NegInvR2"); - RadiusToScreen.Init(mShader, "RadiusToScreen"); - AOMultiplier.Init(mShader, "AOMultiplier"); - AOStrength.Init(mShader, "AOStrength"); + shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + shader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssao.fp", GetDefines(gl_ssao), 330); + shader.SetFragDataLocation(0, "FragColor"); + shader.Link("shaders/glsl/ssao"); + shader.SetAttribLocation(0, "PositionInProjection"); + DepthTexture.Init(shader, "DepthTexture"); + RandomTexture.Init(shader, "RandomTexture"); + UVToViewA.Init(shader, "UVToViewA"); + UVToViewB.Init(shader, "UVToViewB"); + InvFullResolution.Init(shader, "InvFullResolution"); + NDotVBias.Init(shader, "NDotVBias"); + NegInvR2.Init(shader, "NegInvR2"); + RadiusToScreen.Init(shader, "RadiusToScreen"); + AOMultiplier.Init(shader, "AOMultiplier"); + AOStrength.Init(shader, "AOStrength"); } - mShader.Bind(); + shader.Bind(); +} + +FString FSSAOShader::GetDefines(int mode) +{ + int numDirections, numSteps; + switch (gl_ssao) + { + default: + case LowQuality: numDirections = 2; numSteps = 4; break; + case MediumQuality: numDirections = 4; numSteps = 4; break; + case HighQuality: numDirections = 8; numSteps = 4; break; + } + + FString defines; + defines.Format(R"( + #define USE_RANDOM_TEXTURE + #define RANDOM_TEXTURE_WIDTH 4.0 + #define NUM_DIRECTIONS %d.0 + #define NUM_STEPS %d.0 + )", numDirections, numSteps); + return defines; } void FDepthBlurShader::Bind(bool vertical) diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index f36b10625..704729b24 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -39,7 +39,18 @@ public: FBufferedUniform1f AOStrength; private: - FShaderProgram mShader; + enum Quality + { + Off, + LowQuality, + MediumQuality, + HighQuality, + NumQualityModes + }; + + FString GetDefines(int mode); + + FShaderProgram mShader[NumQualityModes]; }; class FDepthBlurShader diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index 97bd0b46c..845f0dd22 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -50,7 +50,7 @@ EXTERN_CVAR(Bool, gl_lens) EXTERN_CVAR(Float, gl_lens_k) EXTERN_CVAR(Float, gl_lens_kcube) EXTERN_CVAR(Float, gl_lens_chromatic) -EXTERN_CVAR(Bool, gl_ssao) +EXTERN_CVAR(Int, gl_ssao) EXTERN_CVAR(Float, gl_ssao_strength) EXTERN_CVAR(Bool, gl_ssao_debug) EXTERN_CVAR(Float, gl_ssao_bias) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 197e262f5..fae6d871b 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2167,6 +2167,9 @@ NETMNU_TICBALANCE = "Latency balancing"; // Option Values OPTVAL_OFF = "Off"; OPTVAL_ON = "On"; +OPTVAL_LOW = "Low"; +OPTVAL_MEDIUM = "Medium"; +OPTVAL_HIGH = "High"; OPTVAL_MALE = "Male"; OPTVAL_FEMALE = "Female"; OPTVAL_OTHER = "Other"; @@ -2633,7 +2636,7 @@ GLPREFMNU_MULTISAMPLE = "Multisample"; GLPREFMNU_TONEMAP = "Tonemap Mode"; GLPREFMNU_BLOOM = "Bloom effect"; GLPREFMNU_LENS = "Lens distortion effect"; -GLPREFMNU_SSAO = "Ambient occlusion"; +GLPREFMNU_SSAO = "Ambient occlusion quality"; // Option Values OPTVAL_SMART = "Smart"; diff --git a/wadsrc/static/menudef.zz b/wadsrc/static/menudef.zz index 68523ea83..8b742ceff 100644 --- a/wadsrc/static/menudef.zz +++ b/wadsrc/static/menudef.zz @@ -42,6 +42,14 @@ OptionValue "TonemapModes" 5, "$OPTVAL_PALETTE" } +OptionValue "SSAOModes" +{ + 0, "$OPTVAL_OFF" + 1, "$OPTVAL_LOW" + 2, "$OPTVAL_MEDIUM" + 3, "$OPTVAL_HIGH" +} + OptionValue "TextureFormats" { 0, "$OPTVAL_RGBA8" @@ -226,5 +234,5 @@ OptionMenu "GLPrefOptions" Option "$GLPREFMNU_TONEMAP", gl_tonemap, "TonemapModes" Option "$GLPREFMNU_BLOOM", gl_bloom, "OnOff" Option "$GLPREFMNU_LENS", gl_lens, "OnOff" - Option "$GLPREFMNU_SSAO", gl_ssao, "OnOff" + Option "$GLPREFMNU_SSAO", gl_ssao, "SSAOModes" } From 979e70ca8f9514b1f976d604e7a0a63907149238 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 24 Sep 2016 20:09:40 +0200 Subject: [PATCH 0980/1509] Add gl_ssao_portals for controlling how many portals gets SSAO --- src/gl/renderer/gl_postprocess.cpp | 6 ++++++ src/gl/scene/gl_scene.cpp | 13 +++++++++++-- src/gl/system/gl_cvars.h | 1 + wadsrc/static/language.enu | 1 + wadsrc/static/menudef.zz | 1 + 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 2fcfe245a..23fdda2eb 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -105,6 +105,12 @@ CUSTOM_CVAR(Int, gl_ssao, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) self = 0; } +CUSTOM_CVAR(Int, gl_ssao_portals, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (self < 0) + self = 0; +} + CVAR(Float, gl_ssao_strength, 0.7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, gl_ssao_debug, false, 0) CVAR(Float, gl_ssao_bias, 0.5f, 0) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 3efd22155..b6120f940 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -477,6 +477,7 @@ void FGLRenderer::RenderTranslucent() void FGLRenderer::DrawScene(int drawmode) { static int recursion=0; + static int ssao_portals_available = 0; if (camera != nullptr) { @@ -494,8 +495,16 @@ void FGLRenderer::DrawScene(int drawmode) } GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. - // If SSAO is active, switch to gbuffer shaders and use the gbuffer framebuffer - bool applySSAO = gl_ssao != 0 && FGLRenderBuffers::IsEnabled() && drawmode == DM_MAINVIEW; + // Decide if we need to do ssao for this scene + bool applySSAO = gl_ssao != 0 && FGLRenderBuffers::IsEnabled(); + switch (drawmode) + { + case DM_MAINVIEW: ssao_portals_available = gl_ssao_portals; break; + case DM_OFFSCREEN: ssao_portals_available = 0; applySSAO = false; break; + case DM_PORTAL: applySSAO = applySSAO && (ssao_portals_available > 0); ssao_portals_available--; break; + } + + // If SSAO is active, switch to gbuffer shaders and use the framebuffer with gbuffers if (applySSAO) { GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index 845f0dd22..836787117 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -51,6 +51,7 @@ EXTERN_CVAR(Float, gl_lens_k) EXTERN_CVAR(Float, gl_lens_kcube) EXTERN_CVAR(Float, gl_lens_chromatic) EXTERN_CVAR(Int, gl_ssao) +EXTERN_CVAR(Int, gl_ssao_portals) EXTERN_CVAR(Float, gl_ssao_strength) EXTERN_CVAR(Bool, gl_ssao_debug) EXTERN_CVAR(Float, gl_ssao_bias) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index fae6d871b..cb3af51aa 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2637,6 +2637,7 @@ GLPREFMNU_TONEMAP = "Tonemap Mode"; GLPREFMNU_BLOOM = "Bloom effect"; GLPREFMNU_LENS = "Lens distortion effect"; GLPREFMNU_SSAO = "Ambient occlusion quality"; +GLPREFMNU_SSAO_PORTALS = "Portals with AO"; // Option Values OPTVAL_SMART = "Smart"; diff --git a/wadsrc/static/menudef.zz b/wadsrc/static/menudef.zz index 8b742ceff..4784baa93 100644 --- a/wadsrc/static/menudef.zz +++ b/wadsrc/static/menudef.zz @@ -235,4 +235,5 @@ OptionMenu "GLPrefOptions" Option "$GLPREFMNU_BLOOM", gl_bloom, "OnOff" Option "$GLPREFMNU_LENS", gl_lens, "OnOff" Option "$GLPREFMNU_SSAO", gl_ssao, "SSAOModes" + Slider "$GLPREFMNU_SSAO_PORTALS", gl_ssao_portals, 0.0, 4.0, 1.0, 0 } From 6cb9f875dd3acc102cf46be46d0a8cb38d4860c6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 25 Sep 2016 00:31:43 +0200 Subject: [PATCH 0981/1509] Fix missing call from merge --- src/gl/renderer/gl_postprocess.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 23fdda2eb..6c18edd1e 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -137,6 +137,7 @@ void FGLRenderer::PostProcessScene() UpdateCameraExposure(); BloomScene(); TonemapScene(); + ColormapScene(); LensDistortScene(); } From 287acea6b46669d4192b132e84d889b4e0730c95 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 25 Sep 2016 00:31:57 +0200 Subject: [PATCH 0982/1509] Update copyright --- src/gl/shaders/gl_ambientshader.cpp | 60 ++++++++++------------------- 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index 7d0e26a6a..43adb5c0e 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -1,42 +1,24 @@ -/* -** gl_bloomshader.cpp -** Shaders used for screen space ambient occlusion -** -**--------------------------------------------------------------------------- -** Copyright 2016 Magnus Norddahl -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be -** covered by the terms of the GNU Lesser General Public License as published -** by the Free Software Foundation; either version 2.1 of the License, or (at -** your option) any later version. -** 5. Full disclosure of the entire project's source code, except for third -** party libraries is mandatory. (NOTE: This clause is non-negotiable!) -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Magnus Norddahl +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// #include "gl/system/gl_system.h" #include "files.h" From e9b1da57a397aa7c53e7c545a59d5f785fa8c227 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 25 Sep 2016 17:43:52 +0300 Subject: [PATCH 0983/1509] Fixed compilation on macOS --- src/posix/cocoa/i_video.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index ba3a3e27e..7dc7a6eed 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -1101,7 +1101,7 @@ void CocoaFrameBuffer::Flip() #endif // __LITTLE_ENDIAN__ if (IsBgra()) - glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, Width, Height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, m_pixelBuffer); + glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, Width, Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, m_pixelBuffer); else glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, Width, Height, 0, format, GL_UNSIGNED_BYTE, m_pixelBuffer); @@ -1127,7 +1127,7 @@ void CocoaFrameBuffer::Flip() SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool fullscreen) -: DFrameBuffer(width, height) +: DFrameBuffer(width, height, false) , m_lock(-1) , m_isUpdatePending(false) { From 0bc54cbda4461d430905008450868d3e19b43595 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Sun, 25 Sep 2016 17:40:37 -0400 Subject: [PATCH 0984/1509] Fixed SDL backend. This project is now Linux capable! --- src/posix/sdl/sdlglvideo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index e581cfde9..86371bd49 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -237,7 +237,7 @@ DFrameBuffer *SDLGLVideo::CreateFrameBuffer (int width, int height, bool bgra, b } ++retry; - fb = static_cast(CreateFrameBuffer (width, height, fullscreen, NULL)); + fb = static_cast(CreateFrameBuffer (width, height, false, fullscreen, NULL)); } // fb->SetFlash (flashColor, flashAmount); From 750c1949597179a1bb60daaad4fa71d80ecc7e47 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 26 Sep 2016 01:38:25 +0200 Subject: [PATCH 0985/1509] - changed order of SwapBuffers and glFinish call. The new order with glFinish coming last is recommended by OpenGL and it fixes a stalling problem with portals and camera textures visible at the same time. - check and use WGL_EXT_swap_control_tear extension. The above change makes the system always wait for a full vsync with a wglSwapInterval of 1, so it now uses the official extension that enables adaptive vsync. Hopefully this also works on the cards where the old setup did not. --- src/gl/scene/gl_portal.cpp | 6 +++--- src/gl/system/gl_framebuffer.cpp | 2 +- src/win32/win32gliface.cpp | 34 +++++++++++++++++++++++++++----- src/win32/win32gliface.h | 1 + 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index f34b5e23f..4a7fa9d7a 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -176,12 +176,12 @@ void GLPortal::DrawPortalStencil() bool GLPortal::Start(bool usestencil, bool doquery) { rendered_portals++; - PortalAll.Clock(); +// PortalAll.Clock(); if (usestencil) { if (!gl_portals) { - PortalAll.Unclock(); +// PortalAll.Unclock(); return false; } @@ -297,7 +297,7 @@ bool GLPortal::Start(bool usestencil, bool doquery) GLRenderer->mCurrentPortal = this; if (PrevPortal != NULL) PrevPortal->PushState(); - PortalAll.Unclock(); +// PortalAll.Unclock(); return true; } diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 94eba0817..08aca521f 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -209,13 +209,13 @@ void OpenGLFrameBuffer::Swap() { Finish.Reset(); Finish.Clock(); - glFinish(); if (needsetgamma) { //DoSetGamma(); needsetgamma = false; } SwapBuffers(); + glFinish(); Finish.Unclock(); swapped = true; FHardwareTexture::UnbindAll(); diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 7ca001e1e..5d68d8427 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -37,7 +37,9 @@ extern int NewWidth, NewHeight, NewBits, DisplayBits; // these get used before GLEW is initialized so we have to use separate pointers with different names PFNWGLCHOOSEPIXELFORMATARBPROC myWglChoosePixelFormatARB; // = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); PFNWGLCREATECONTEXTATTRIBSARBPROC myWglCreateContextAttribsARB; -PFNWGLSWAPINTERVALEXTPROC vsyncfunc; +PFNWGLSWAPINTERVALEXTPROC myWglSwapIntervalExtProc; + + CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) @@ -933,10 +935,32 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in vid_renderer = 0; return; } - - vsyncfunc = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); - HDC hDC = GetDC(Window); + const char *wglext = nullptr; + + myWglSwapIntervalExtProc = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); + auto myWglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB"); + if (myWglGetExtensionsStringARB) + { + wglext = myWglGetExtensionsStringARB(hDC); + } + else + { + auto myWglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)wglGetProcAddress("wglGetExtensionsStringEXT"); + if (myWglGetExtensionsStringEXT) + { + wglext = myWglGetExtensionsStringEXT(); + } + } + SwapInterval = 1; + if (wglext != nullptr) + { + if (strstr(wglext, "WGL_EXT_swap_control_tear")) + { + SwapInterval = -1; + } + } + m_supportsGamma = !!GetDeviceGammaRamp(hDC, (void *)m_origGamma); ReleaseDC(Window, hDC); } @@ -1091,7 +1115,7 @@ void Win32GLFrameBuffer::ReleaseResources () void Win32GLFrameBuffer::SetVSync (bool vsync) { - if (vsyncfunc != NULL) vsyncfunc(vsync ? 1 : 0); + if (myWglSwapIntervalExtProc != NULL) myWglSwapIntervalExtProc(vsync ? SwapInterval : 0); } void Win32GLFrameBuffer::SwapBuffers() diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index 6320e2903..e767073c4 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -148,6 +148,7 @@ protected: int m_Lock; char m_displayDeviceNameBuffer[CCHDEVICENAME]; char *m_displayDeviceName; + int SwapInterval; friend class Win32GLVideo; From 3dd8b593b6a9e35fefd4ce76490f963cccc70fb4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 26 Sep 2016 09:00:19 +0200 Subject: [PATCH 0986/1509] Use LLVM to JIT the code for one of the drawer functions --- src/CMakeLists.txt | 86 ++ .../fixedfunction/fixedfunction.cpp | 1046 +++++++++++++++++ src/r_compiler/fixedfunction/fixedfunction.h | 130 ++ src/r_compiler/llvm_include.h | 46 + src/r_compiler/ssa/ssa_barycentric_weight.h | 97 ++ src/r_compiler/ssa/ssa_bool.cpp | 91 ++ src/r_compiler/ssa/ssa_bool.h | 37 + src/r_compiler/ssa/ssa_float.cpp | 152 +++ src/r_compiler/ssa/ssa_float.h | 42 + src/r_compiler/ssa/ssa_float_ptr.cpp | 65 + src/r_compiler/ssa/ssa_float_ptr.h | 27 + src/r_compiler/ssa/ssa_for_block.cpp | 25 + src/r_compiler/ssa/ssa_for_block.h | 18 + src/r_compiler/ssa/ssa_function.cpp | 55 + src/r_compiler/ssa/ssa_function.h | 30 + src/r_compiler/ssa/ssa_if_block.cpp | 30 + src/r_compiler/ssa/ssa_if_block.h | 46 + src/r_compiler/ssa/ssa_int.cpp | 117 ++ src/r_compiler/ssa/ssa_int.h | 41 + src/r_compiler/ssa/ssa_int_ptr.cpp | 58 + src/r_compiler/ssa/ssa_int_ptr.h | 27 + src/r_compiler/ssa/ssa_phi.h | 33 + src/r_compiler/ssa/ssa_pixelformat4f.h | 28 + src/r_compiler/ssa/ssa_pixelformat4ub.h | 28 + .../ssa/ssa_pixelformat4ub_argb_rev.h | 35 + src/r_compiler/ssa/ssa_pixelformat4ub_rev.h | 28 + src/r_compiler/ssa/ssa_pixels.h | 39 + src/r_compiler/ssa/ssa_pixeltype.h | 498 ++++++++ src/r_compiler/ssa/ssa_scope.cpp | 65 + src/r_compiler/ssa/ssa_scope.h | 41 + src/r_compiler/ssa/ssa_stack.h | 25 + src/r_compiler/ssa/ssa_struct_type.cpp | 18 + src/r_compiler/ssa/ssa_struct_type.h | 17 + src/r_compiler/ssa/ssa_ubyte.cpp | 95 ++ src/r_compiler/ssa/ssa_ubyte.h | 35 + src/r_compiler/ssa/ssa_ubyte_ptr.cpp | 106 ++ src/r_compiler/ssa/ssa_ubyte_ptr.h | 32 + src/r_compiler/ssa/ssa_value.cpp | 56 + src/r_compiler/ssa/ssa_value.h | 53 + src/r_compiler/ssa/ssa_vec16ub.cpp | 155 +++ src/r_compiler/ssa/ssa_vec16ub.h | 42 + src/r_compiler/ssa/ssa_vec4f.cpp | 244 ++++ src/r_compiler/ssa/ssa_vec4f.h | 57 + src/r_compiler/ssa/ssa_vec4f_ptr.cpp | 50 + src/r_compiler/ssa/ssa_vec4f_ptr.h | 24 + src/r_compiler/ssa/ssa_vec4i.cpp | 213 ++++ src/r_compiler/ssa/ssa_vec4i.h | 56 + src/r_compiler/ssa/ssa_vec4i_ptr.cpp | 50 + src/r_compiler/ssa/ssa_vec4i_ptr.h | 24 + src/r_compiler/ssa/ssa_vec8s.cpp | 178 +++ src/r_compiler/ssa/ssa_vec8s.h | 48 + src/r_draw_rgba.cpp | 66 ++ 52 files changed, 4705 insertions(+) create mode 100644 src/r_compiler/fixedfunction/fixedfunction.cpp create mode 100644 src/r_compiler/fixedfunction/fixedfunction.h create mode 100644 src/r_compiler/llvm_include.h create mode 100644 src/r_compiler/ssa/ssa_barycentric_weight.h create mode 100644 src/r_compiler/ssa/ssa_bool.cpp create mode 100644 src/r_compiler/ssa/ssa_bool.h create mode 100644 src/r_compiler/ssa/ssa_float.cpp create mode 100644 src/r_compiler/ssa/ssa_float.h create mode 100644 src/r_compiler/ssa/ssa_float_ptr.cpp create mode 100644 src/r_compiler/ssa/ssa_float_ptr.h create mode 100644 src/r_compiler/ssa/ssa_for_block.cpp create mode 100644 src/r_compiler/ssa/ssa_for_block.h create mode 100644 src/r_compiler/ssa/ssa_function.cpp create mode 100644 src/r_compiler/ssa/ssa_function.h create mode 100644 src/r_compiler/ssa/ssa_if_block.cpp create mode 100644 src/r_compiler/ssa/ssa_if_block.h create mode 100644 src/r_compiler/ssa/ssa_int.cpp create mode 100644 src/r_compiler/ssa/ssa_int.h create mode 100644 src/r_compiler/ssa/ssa_int_ptr.cpp create mode 100644 src/r_compiler/ssa/ssa_int_ptr.h create mode 100644 src/r_compiler/ssa/ssa_phi.h create mode 100644 src/r_compiler/ssa/ssa_pixelformat4f.h create mode 100644 src/r_compiler/ssa/ssa_pixelformat4ub.h create mode 100644 src/r_compiler/ssa/ssa_pixelformat4ub_argb_rev.h create mode 100644 src/r_compiler/ssa/ssa_pixelformat4ub_rev.h create mode 100644 src/r_compiler/ssa/ssa_pixels.h create mode 100644 src/r_compiler/ssa/ssa_pixeltype.h create mode 100644 src/r_compiler/ssa/ssa_scope.cpp create mode 100644 src/r_compiler/ssa/ssa_scope.h create mode 100644 src/r_compiler/ssa/ssa_stack.h create mode 100644 src/r_compiler/ssa/ssa_struct_type.cpp create mode 100644 src/r_compiler/ssa/ssa_struct_type.h create mode 100644 src/r_compiler/ssa/ssa_ubyte.cpp create mode 100644 src/r_compiler/ssa/ssa_ubyte.h create mode 100644 src/r_compiler/ssa/ssa_ubyte_ptr.cpp create mode 100644 src/r_compiler/ssa/ssa_ubyte_ptr.h create mode 100644 src/r_compiler/ssa/ssa_value.cpp create mode 100644 src/r_compiler/ssa/ssa_value.h create mode 100644 src/r_compiler/ssa/ssa_vec16ub.cpp create mode 100644 src/r_compiler/ssa/ssa_vec16ub.h create mode 100644 src/r_compiler/ssa/ssa_vec4f.cpp create mode 100644 src/r_compiler/ssa/ssa_vec4f.h create mode 100644 src/r_compiler/ssa/ssa_vec4f_ptr.cpp create mode 100644 src/r_compiler/ssa/ssa_vec4f_ptr.h create mode 100644 src/r_compiler/ssa/ssa_vec4i.cpp create mode 100644 src/r_compiler/ssa/ssa_vec4i.h create mode 100644 src/r_compiler/ssa/ssa_vec4i_ptr.cpp create mode 100644 src/r_compiler/ssa/ssa_vec4i_ptr.h create mode 100644 src/r_compiler/ssa/ssa_vec8s.cpp create mode 100644 src/r_compiler/ssa/ssa_vec8s.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2d71170ee..4f9599b35 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -104,6 +104,15 @@ if( WIN32 ) endif() add_definitions( -D_WIN32 ) + + set( FMOD_SEARCH_PATHS + "C:/Program Files/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" + "C:/Program Files (x86)/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" + # This next one is for Randy. + "E:/Software/Dev/FMOD/${WIN_TYPE}/api" + ) + set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES inc ) + set( FMOD_LIB_PATH_SUFFIXES PATH_SUFFIXES lib ) set( FMOD_SEARCH_PATHS "C:/Program Files/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" @@ -255,6 +264,57 @@ if( NOT NO_OPENAL ) endif() endif() +# C:/Development/Environment/Src/llvm-3.9.0/build/lib/cmake/llvm +find_package(LLVM REQUIRED CONFIG) +message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") +message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") +llvm_map_components_to_libnames(llvm_libs + analysis + asmparser + asmprinter + bitreader + bitwriter + codegen + core + executionengine + globalisel + instcombine + ipo + irreader + linker + lto + mc + mcdisassembler + mcjit + mcparser + mirparser + object + objectyaml + orcjit + passes + scalaropts + selectiondag + support + symbolize + tablegen + target + transformutils + vectorize + x86asmparser + x86asmprinter + x86codegen + x86desc + x86info + x86utils + aarch64asmparser + aarch64asmprinter + aarch64codegen + aarch64desc + aarch64info + aarch64utils) +include_directories(${LLVM_INCLUDE_DIRS}) +set( ZDOOM_LIBS ${ZDOOM_LIBS} ${llvm_libs} ) + if( NOT NO_FMOD ) # Search for FMOD include files if( NOT WIN32 ) @@ -843,6 +903,9 @@ file( GLOB HEADER_FILES posix/*.h posix/cocoa/*.h posix/sdl/*.h + r_compiler/*.h + r_compiler/ssa/*.h + r_compiler/fixedfunction/*.h r_data/*.h resourcefiles/*.h sfmt/*.h @@ -1372,6 +1435,26 @@ set (PCH_SOURCES fragglescript/t_spec.cpp fragglescript/t_variable.cpp fragglescript/t_cmd.cpp + r_compiler/ssa/ssa_bool.cpp + r_compiler/ssa/ssa_float.cpp + r_compiler/ssa/ssa_float_ptr.cpp + r_compiler/ssa/ssa_for_block.cpp + r_compiler/ssa/ssa_function.cpp + r_compiler/ssa/ssa_if_block.cpp + r_compiler/ssa/ssa_int.cpp + r_compiler/ssa/ssa_int_ptr.cpp + r_compiler/ssa/ssa_scope.cpp + r_compiler/ssa/ssa_struct_type.cpp + r_compiler/ssa/ssa_ubyte.cpp + r_compiler/ssa/ssa_ubyte_ptr.cpp + r_compiler/ssa/ssa_value.cpp + r_compiler/ssa/ssa_vec4f.cpp + r_compiler/ssa/ssa_vec4f_ptr.cpp + r_compiler/ssa/ssa_vec4i.cpp + r_compiler/ssa/ssa_vec4i_ptr.cpp + r_compiler/ssa/ssa_vec8s.cpp + r_compiler/ssa/ssa_vec16ub.cpp + r_compiler/fixedfunction/fixedfunction.cpp r_data/sprites.cpp r_data/voxels.cpp r_data/renderstyle.cpp @@ -1587,6 +1670,9 @@ source_group("Render Data\\Resource Headers" REGULAR_EXPRESSION "^${CMAKE_CURREN source_group("Render Data\\Resource Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_data/.+\\.cpp$") source_group("Render Data\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/textures/.+") source_group("Render Interface" FILES r_defs.h r_renderer.h r_sky.cpp r_sky.h r_state.h r_utility.cpp r_utility.h) +source_group("Render Compiler" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_compiler/.+") +source_group("Render Compiler\\SSA" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_compiler/ssa/.+") +source_group("Render Compiler\\Fixed Function" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_compiler/fixedfunction/.+") source_group("Resource Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/resourcefiles/.+") source_group("POSIX Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/posix/.+") source_group("Cocoa Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/posix/cocoa/.+") diff --git a/src/r_compiler/fixedfunction/fixedfunction.cpp b/src/r_compiler/fixedfunction/fixedfunction.cpp new file mode 100644 index 000000000..347ba6de3 --- /dev/null +++ b/src/r_compiler/fixedfunction/fixedfunction.cpp @@ -0,0 +1,1046 @@ + +#include "i_system.h" +#include "r_compiler/fixedfunction/fixedfunction.h" +#include "r_compiler/ssa/ssa_function.h" +#include "r_compiler/ssa/ssa_scope.h" +#include "r_compiler/ssa/ssa_for_block.h" +#include "r_compiler/ssa/ssa_if_block.h" +#include "r_compiler/ssa/ssa_stack.h" +#include "r_compiler/ssa/ssa_function.h" +#include "r_compiler/ssa/ssa_struct_type.h" +#include "r_compiler/ssa/ssa_value.h" +#include "r_compiler/ssa/ssa_barycentric_weight.h" + +RenderProgram::RenderProgram() +{ + llvm::install_fatal_error_handler([](void *user_data, const std::string& reason, bool gen_crash_diag) { + I_FatalError(reason.c_str()); + }); + + //llvm::llvm_start_multithreaded(); + llvm::InitializeNativeTarget(); + llvm::InitializeNativeTargetAsmPrinter(); + llvm::InitializeNativeTargetAsmParser(); + + mContext = std::make_unique(); + + auto moduleOwner = std::make_unique("render", context()); + mModule = moduleOwner.get(); + + std::string errorstring; + llvm::EngineBuilder engineBuilder(std::move(moduleOwner)); + engineBuilder.setErrorStr(&errorstring); + engineBuilder.setOptLevel(llvm::CodeGenOpt::Aggressive); + engineBuilder.setRelocationModel(llvm::Reloc::Static); + engineBuilder.setEngineKind(llvm::EngineKind::JIT); + mEngine.reset(engineBuilder.create()); + if (!mEngine) + I_FatalError(errorstring.c_str()); +} + +RenderProgram::~RenderProgram() +{ + mEngine.reset(); + mContext.reset(); + //llvm::llvm_stop_multithreaded(); +} + +void *RenderProgram::PointerToFunction(const char *name) +{ + llvm::Function *function = mModule->getFunction(name); + if (!function) + return nullptr; + return mEngine->getPointerToFunction(function); +} + +FixedFunction::FixedFunction() +{ + CodegenDrawSpan(); + mProgram.engine()->finalizeObject(); + + DrawSpan = mProgram.GetProcAddress("DrawSpan"); +} + +void FixedFunction::CodegenDrawSpan() +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function("DrawSpan"); + function.add_parameter(SSAInt::llvm_type()); + function.add_parameter(SSAUBytePtr::llvm_type()); + function.create_public(); + + SSAInt count = function.parameter(0); + SSAUBytePtr data = function.parameter(1); + SSAStack stack_index; + + stack_index.store(0); + SSAForBlock loop; + { + SSAInt index = stack_index.load(); + loop.loop_block(index < count); + + //SSAVec4i color(255, 255, 0, 255); + //data[index * 4].store_vec4ub(color); + data[index * 4].store(0); + data[index * 4 + 1].store(128); + data[index * 4 + 2].store(255); + data[index * 4 + 3].store(255); + stack_index.store(index + 1); + } + loop.end_block(); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + I_FatalError("verifyFunction failed for " __FUNCTION__); +} + +#if 0 + +GlslFixedFunction::GlslFixedFunction(GlslProgram &program, GlslCodeGen &vertex_codegen, GlslCodeGen &fragment_codegen) +: program(program), vertex_codegen(vertex_codegen), fragment_codegen(fragment_codegen) +{ +} + +llvm::Type *GlslFixedFunction::get_sampler_struct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt32Ty(context)); // width + elements.push_back(llvm::Type::getInt32Ty(context)); // height + elements.push_back(llvm::Type::getInt8PtrTy(context)); // data + return llvm::StructType::get(context, elements, false); +} + +void GlslFixedFunction::codegen() +{ + codegen_render_scanline(5); + codegen_calc_window_positions(); + codegen_calc_polygon_face_direction(); + codegen_calc_polygon_y_range(); + codegen_update_polygon_edge(); + codegen_draw_triangles(5, 5); + codegen_texture(); + codegen_normalize(); + codegen_reflect(); + codegen_max(); + codegen_pow(); + codegen_dot(); + codegen_mix(); +} + +void GlslFixedFunction::codegen_texture() +{ + llvm::IRBuilder<> builder(program.context()); + SSAScope ssa_scope(&program.context(), program.module(), &builder); + + SSAFunction function("fragment_texture"); + function.add_parameter(fragment_codegen.get_global_struct_type()); + function.add_parameter(get_sampler_struct(program.context())); + function.add_parameter(SSAVec4f::llvm_type()); + function.create_private(); + + SSAValue sampler_ptr = function.parameter(1); + SSAVec4f pos = function.parameter(2); + + SSAInt width = sampler_ptr[0][0].load(); + SSAInt height = sampler_ptr[0][1].load(); + SSAUBytePtr data = sampler_ptr[0][2].load(); + + SSAPixels4ub_argb_rev pixels(width, height, data); + //builder.CreateRet(pixels.linear_clamp4f(pos).v); + builder.CreateRet(pixels.linear_clamp4f(pos[0], pos[1]).v); + + llvm::verifyFunction(*function.func); +} + +void GlslFixedFunction::codegen_normalize() +{ + llvm::IRBuilder<> builder(program.context()); + SSAScope ssa_scope(&program.context(), program.module(), &builder); + + SSAFunction function("fragment_normalize"); + function.add_parameter(fragment_codegen.get_global_struct_type()); + function.add_parameter(SSAVec4f::llvm_type()); + function.create_private(); + + SSAVec4f vec = function.parameter(1); + + // To do: this can probably be done a lot faster with _mm_rsqrt_ss + SSAVec4f vec2 = vec * vec; + SSAVec4f length3(SSAFloat::sqrt(vec2[0] + vec2[1] + vec2[2])); + SSAVec4f normalized = vec / length3; + builder.CreateRet(normalized.v); + + llvm::verifyFunction(*function.func); +} + +void GlslFixedFunction::codegen_reflect() +{ + llvm::IRBuilder<> builder(program.context()); + SSAScope ssa_scope(&program.context(), program.module(), &builder); + + SSAFunction function("fragment_reflect"); + function.add_parameter(fragment_codegen.get_global_struct_type()); + function.add_parameter(SSAVec4f::llvm_type()); + function.add_parameter(SSAVec4f::llvm_type()); + function.create_private(); + + SSAVec4f i = function.parameter(1); + SSAVec4f n = function.parameter(2); + + SSAVec4f c = i * n; + SSAFloat dot3 = c[0] + c[1] + c[2]; + SSAVec4f result = i - (2.0f * dot3) * n; + builder.CreateRet(result.v); + + llvm::verifyFunction(*function.func); +} + +void GlslFixedFunction::codegen_max() +{ + llvm::IRBuilder<> builder(program.context()); + SSAScope ssa_scope(&program.context(), program.module(), &builder); + + SSAFunction function("fragment_max"); + function.add_parameter(fragment_codegen.get_global_struct_type()); + function.add_parameter(SSAFloat::llvm_type()); + function.add_parameter(SSAFloat::llvm_type()); + function.create_private(); + + SSAFloat a = function.parameter(1); + SSAFloat b = function.parameter(2); + + SSAPhi phi; + SSAIfBlock branch; + branch.if_block(a >= b); + phi.add_incoming(a); + branch.else_block(); + phi.add_incoming(b); + branch.end_block(); + SSAFloat c = phi.create(); + + builder.CreateRet(c.v); + llvm::verifyFunction(*function.func); +} + +void GlslFixedFunction::codegen_pow() +{ + llvm::IRBuilder<> builder(program.context()); + SSAScope ssa_scope(&program.context(), program.module(), &builder); + + SSAFunction function("fragment_pow"); + function.add_parameter(fragment_codegen.get_global_struct_type()); + function.add_parameter(SSAFloat::llvm_type()); + function.add_parameter(SSAFloat::llvm_type()); + function.create_private(); + + SSAFloat a = function.parameter(1); + SSAFloat b = function.parameter(2); + builder.CreateRet(a.v); + //builder.CreateRet(SSAFloat::pow(a, b).v); + + llvm::verifyFunction(*function.func); +} + +void GlslFixedFunction::codegen_dot() +{ + llvm::IRBuilder<> builder(program.context()); + SSAScope ssa_scope(&program.context(), program.module(), &builder); + + SSAFunction function("fragment_dot"); + function.add_parameter(fragment_codegen.get_global_struct_type()); + function.add_parameter(SSAVec4f::llvm_type()); + function.add_parameter(SSAVec4f::llvm_type()); + function.create_private(); + + SSAVec4f a = function.parameter(1); + SSAVec4f b = function.parameter(2); + + SSAVec4f c = a * b; + SSAFloat dot3 = c[0] + c[1] + c[2]; + builder.CreateRet(dot3.v); + + llvm::verifyFunction(*function.func); +} + +void GlslFixedFunction::codegen_mix() +{ + llvm::IRBuilder<> builder(program.context()); + SSAScope ssa_scope(&program.context(), program.module(), &builder); + + SSAFunction function("fragment_mix"); + function.add_parameter(fragment_codegen.get_global_struct_type()); + function.add_parameter(SSAVec4f::llvm_type()); + function.add_parameter(SSAVec4f::llvm_type()); + function.add_parameter(SSAFloat::llvm_type()); + function.create_private(); + + SSAVec4f v1 = function.parameter(1); + SSAVec4f v2 = function.parameter(2); + SSAFloat t = function.parameter(3); + + SSAVec4f b = t; + SSAVec4f a = 1.0f - b; + SSAVec4f mix = v1 * a + v2 * b; + builder.CreateRet(mix.v); + + llvm::verifyFunction(*function.func); +} + +void GlslFixedFunction::codegen_draw_triangles(int num_vertex_in, int num_vertex_out) +{ + llvm::IRBuilder<> builder(program.context()); + SSAScope ssa_scope(&program.context(), program.module(), &builder); + + SSAFunction function("draw_triangles"); + function.add_parameter(SSAInt::llvm_type()); // input_width + function.add_parameter(SSAInt::llvm_type()); // input_height + function.add_parameter(SSAUBytePtr::llvm_type()); // input_data + function.add_parameter(SSAInt::llvm_type()); // output_width + function.add_parameter(SSAInt::llvm_type()); // output_height + function.add_parameter(SSAUBytePtr::llvm_type()); // output_data + function.add_parameter(SSAInt::llvm_type()); // viewport_x + function.add_parameter(SSAInt::llvm_type()); // viewport_y + function.add_parameter(SSAInt::llvm_type()); // viewport_width + function.add_parameter(SSAInt::llvm_type()); // viewport_height + function.add_parameter(SSAVec4fPtr::llvm_type()); // uniforms + function.add_parameter(SSAInt::llvm_type()); // first_vertex + function.add_parameter(SSAInt::llvm_type()); // num_vertices + function.add_parameter(SSAVec4fPtr::llvm_type()->getPointerTo()); // vertex attributes + function.add_parameter(SSAInt::llvm_type()); // core + function.add_parameter(SSAInt::llvm_type()); // num_cores + function.create_public(); + + SSAInt input_width = function.parameter(0); + SSAInt input_height = function.parameter(1); + SSAUBytePtr input_data = function.parameter(2); + SSAInt output_width = function.parameter(3); + SSAInt output_height = function.parameter(4); + SSAUBytePtr output_data = function.parameter(5); + SSAInt viewport_x = function.parameter(6); + SSAInt viewport_y = function.parameter(7); + SSAInt viewport_width = function.parameter(8); + SSAInt viewport_height = function.parameter(9); + SSAVec4fPtr uniforms = function.parameter(10); + SSAInt first_vertex = function.parameter(11); + SSAInt num_vertices = function.parameter(12); + SSAValue vertex_in_ptr = function.parameter(13); + SSAInt core = function.parameter(14); + SSAInt num_cores = function.parameter(15); + + SSAStack stack_vertex_index; + SSAValue vertex_globals_ptr = SSAValue::from_llvm(SSAScope::alloca(vertex_codegen.get_global_struct_type())); + std::vector vertex_outs; + for (int i = 0; i < num_vertex_out; i++) + vertex_outs.push_back(SSAVec4fPtr::from_llvm(SSAScope::builder().CreateAlloca(SSAVec4f::llvm_type(), SSAInt(3).v))); + + int num_uniforms = 1; + { + llvm::Type *type = llvm::ArrayType::get(llvm::VectorType::get(llvm::Type::getFloatTy(program.context()), 4), 4); + llvm::Value *matrix = llvm::UndefValue::get(type); + for (int col = 0; col < 4; col++) + { + SSAVec4f column = uniforms[col].load_unaligned(); + std::vector indexes; + indexes.push_back(col); + matrix = builder.CreateInsertValue(matrix, column.v, indexes); + } + vertex_globals_ptr[0][0].store(matrix); + } + + stack_vertex_index.store(0); + SSAForBlock loop; + SSAInt vertex_index = stack_vertex_index.load(); + loop.loop_block(vertex_index + 2 < num_vertices); + for (int v = 0; v < 3; v++) + { + for (int i = 0; i < num_vertex_in; i++) + { + SSAValue attribute_ptr = vertex_in_ptr[i].load(); + SSAVec4f vertex_in = SSAVec4f::shuffle(SSAVec4fPtr(attribute_ptr)[first_vertex + vertex_index + v].load_unaligned(), 0, 1, 2, 3); + vertex_globals_ptr[0][num_uniforms + i].store(vertex_in.v); + } + SSAScope::builder().CreateCall(SSAScope::module()->getFunction((vertex_codegen.shader_prefix() + "main").c_str()), vertex_globals_ptr.v); + for (int i = 0; i < num_vertex_out; i++) + { + vertex_outs[i][v].store(vertex_globals_ptr[0][num_uniforms + num_vertex_in + i].load()); + } + } + + render_polygon(input_width, input_height, input_data, output_width, output_height, output_data, viewport_x, viewport_y, viewport_width, viewport_height, 3, vertex_outs, core, num_cores); + + stack_vertex_index.store(vertex_index + 3); + loop.end_block(); + + builder.CreateRetVoid(); + llvm::verifyFunction(*function.func); +} + +void GlslFixedFunction::codegen_calc_window_positions() +{ + llvm::IRBuilder<> builder(program.context()); + SSAScope ssa_scope(&program.context(), program.module(), &builder); + + SSAFunction function("calc_window_positions"); + function.add_parameter(SSAInt::llvm_type()); // viewport_x + function.add_parameter(SSAInt::llvm_type()); // viewport_y + function.add_parameter(SSAInt::llvm_type()); // viewport_width + function.add_parameter(SSAInt::llvm_type()); // viewport_height + function.add_parameter(SSAInt::llvm_type()); // num_vertices + function.add_parameter(SSAVec4fPtr::llvm_type()); // gl_Position + function.add_parameter(SSAVec4fPtr::llvm_type()); // window_pos + function.create_private(); + SSAInt viewport_x = function.parameter(0); + SSAInt viewport_y = function.parameter(1); + SSAInt viewport_width = function.parameter(2); + SSAInt viewport_height = function.parameter(3); + SSAInt num_vertices = function.parameter(4); + SSAVec4fPtr clip_positions = function.parameter(5); + SSAVec4fPtr window_positions = function.parameter(6); + + SSAViewport viewport(viewport_x, viewport_y, viewport_width, viewport_height); + SSAStack stack_transform_index; + stack_transform_index.store(0); + SSAForBlock loop_transform; + SSAInt transform_index = stack_transform_index.load(); + loop_transform.loop_block(transform_index < num_vertices); + { + SSAVec4f clip_pos = clip_positions[transform_index].load(); + SSAVec4f window_pos = viewport.clip_to_window(clip_pos); + window_positions[transform_index].store(window_pos); + + stack_transform_index.store(transform_index + 1); + } + loop_transform.end_block(); + + builder.CreateRetVoid(); + llvm::verifyFunction(*function.func); +} + +void GlslFixedFunction::codegen_calc_polygon_face_direction() +{ + llvm::IRBuilder<> builder(program.context()); + SSAScope ssa_scope(&program.context(), program.module(), &builder); + + SSAFunction function("calc_polygon_face_direction"); + function.set_return_type(SSABool::llvm_type()); + function.add_parameter(SSAInt::llvm_type()); // num_vertices + function.add_parameter(SSAVec4fPtr::llvm_type()); // window_pos + function.create_private(); + SSAInt num_vertices = function.parameter(0); + SSAVec4fPtr window_positions = function.parameter(1); + + SSAStack stack_face_direction; + SSAStack stack_face_vertex_index; + stack_face_direction.store(0.0f); + stack_face_vertex_index.store(0); + SSAForBlock loop_face_direction; + SSAInt face_vertex_index = stack_face_vertex_index.load(); + loop_face_direction.loop_block(face_vertex_index < num_vertices); + { + SSAVec4f v0 = window_positions[face_vertex_index].load(); + SSAVec4f v1 = window_positions[(face_vertex_index + 1) % num_vertices].load(); + stack_face_direction.store(stack_face_direction.load() + v0[0] * v1[1] - v1[0] * v0[1]); + stack_face_vertex_index.store(face_vertex_index + 1); + } + loop_face_direction.end_block(); + SSABool front_facing_ccw = (stack_face_direction.load() >= 0.0f); + + builder.CreateRet(front_facing_ccw.v); + llvm::verifyFunction(*function.func); +} + +void GlslFixedFunction::codegen_calc_polygon_y_range() +{ + llvm::IRBuilder<> builder(program.context()); + SSAScope ssa_scope(&program.context(), program.module(), &builder); + + SSAFunction function("calc_polygon_y_range"); + function.add_parameter(SSAInt::llvm_type()); // viewport_y + function.add_parameter(SSAInt::llvm_type()); // viewport_height + function.add_parameter(SSAInt::llvm_type()); // num_vertices + function.add_parameter(SSAVec4fPtr::llvm_type()); // window_pos + function.add_parameter(SSAInt::llvm_type()->getPointerTo()); // out_y_start + function.add_parameter(SSAInt::llvm_type()->getPointerTo()); // out_y_end + function.create_private(); + SSAInt viewport_y = function.parameter(0); + SSAInt viewport_height = function.parameter(1); + SSAInt num_vertices = function.parameter(2); + SSAVec4fPtr window_positions = function.parameter(3); + SSAValue out_y_start = function.parameter(4); + SSAValue out_y_end = function.parameter(5); + + SSAStack y_start; + SSAStack y_end; + y_start.store(0x7fffffff); + y_end.store(0); + + SSAStack stack_minmax_index; + stack_minmax_index.store(0); + SSAForBlock loop_minmax; + SSAInt minmax_index = stack_minmax_index.load(); + loop_minmax.loop_block(minmax_index < num_vertices); + { + SSAInt y = SSAInt(window_positions[minmax_index].load()[1] + 0.5f); + y_start.store(ssa_min(y_start.load(), y)); + y_end.store(ssa_max(y_end.load(), y)); + stack_minmax_index.store(minmax_index + 1); + } + loop_minmax.end_block(); + + y_start.store(ssa_max(y_start.load(), viewport_y)); + y_end.store(ssa_min(y_end.load(), viewport_y + viewport_height)); + + out_y_start.store(y_start.load().v); + out_y_end.store(y_end.load().v); + builder.CreateRetVoid(); + llvm::verifyFunction(*function.func); +} + +void GlslFixedFunction::codegen_update_polygon_edge() +{ + llvm::IRBuilder<> builder(program.context()); + SSAScope ssa_scope(&program.context(), program.module(), &builder); + + SSAFunction function("update_polygon_edge"); + function.add_parameter(SSAFloat::llvm_type()); // y_position + function.add_parameter(SSAInt::llvm_type()); // num_vertices + function.add_parameter(SSAVec4fPtr::llvm_type()); // window_pos + function.add_parameter(SSAInt::llvm_type()->getPointerTo()); // inout left_index + function.add_parameter(SSAInt::llvm_type()->getPointerTo()); // inout right_index + function.create_private(); + SSAFloat float_y = function.parameter(0); + SSAInt num_vertices = function.parameter(1); + SSAVec4fPtr window_positions = function.parameter(2); + SSAValue ptr_left_index = function.parameter(3); + SSAValue ptr_right_index = function.parameter(4); + + SSAStack max_iterate; + max_iterate.store(num_vertices); + SSAForBlock loop_left; + SSAInt left_index = ptr_left_index.load(); + SSAInt right_index = ptr_right_index.load(); + SSAInt next_left_index = (left_index + 1) % num_vertices; + SSAFloat left_y0 = window_positions[left_index].load()[1]; + SSAFloat left_y1 = window_positions[next_left_index].load()[1]; + SSABool in_range = (left_y0 >= float_y && left_y1 < float_y) || (left_y1 >= float_y && left_y0 < float_y); + loop_left.loop_block((left_index == right_index || !in_range) && max_iterate.load() > 0); + ptr_left_index.store(next_left_index.v); + max_iterate.store(max_iterate.load() - 1); + loop_left.end_block(); + + builder.CreateRetVoid(); + llvm::verifyFunction(*function.func); +} + +void GlslFixedFunction::render_polygon( + SSAInt input_width, + SSAInt input_height, + SSAUBytePtr input_data, + SSAInt output_width, + SSAInt output_height, + SSAUBytePtr output_data, + SSAInt viewport_x, + SSAInt viewport_y, + SSAInt viewport_width, + SSAInt viewport_height, + SSAInt num_vertices, + std::vector fragment_ins, + SSAInt core, + SSAInt num_cores) +{ + SSAVec4fPtr window_positions = SSAVec4fPtr::from_llvm(SSAScope::alloca(SSAVec4f::llvm_type(), num_vertices)); + SSAVec4fPtr left_line_varyings = SSAVec4fPtr::from_llvm(SSAScope::alloca(SSAVec4f::llvm_type(), fragment_ins.size())); + SSAVec4fPtr right_line_varyings = SSAVec4fPtr::from_llvm(SSAScope::alloca(SSAVec4f::llvm_type(), fragment_ins.size())); + + /////////////////////////////////// + + llvm::Value *calc_window_positions_args[] = { viewport_x.v, viewport_y.v, viewport_width.v, viewport_height.v, num_vertices.v, fragment_ins[0].v, window_positions.v }; + SSAScope::builder().CreateCall(SSAScope::module()->getFunction("calc_window_positions"), calc_window_positions_args); + + llvm::Value *calc_polygon_face_direction_args[] = { num_vertices.v, window_positions.v }; + SSABool front_facing_ccw = SSABool::from_llvm(SSAScope::builder().CreateCall(SSAScope::module()->getFunction("calc_polygon_face_direction"), calc_polygon_face_direction_args)); + + SSAIfBlock cull_if; + cull_if.if_block(front_facing_ccw); + { + SSAViewport viewport(viewport_x, viewport_y, viewport_width, viewport_height); + + SSAStack y_start; + SSAStack y_end; + + llvm::Value *calc_polygon_y_range_args[] = { viewport_y.v, viewport_height.v, num_vertices.v, window_positions.v, y_start.v, y_end.v }; + SSAScope::builder().CreateCall(SSAScope::module()->getFunction("calc_polygon_y_range"), calc_polygon_y_range_args); + + y_start.store((y_start.load() + num_cores - core - 1) / num_cores * num_cores + core); // find_first_line_for_core + + SSAStack stack_left_index; + SSAStack stack_right_index; + SSAStack stack_int_y; + stack_left_index.store(0); + stack_right_index.store(1); + stack_int_y.store(y_start.load()); + SSAForBlock scanlines_loop; + scanlines_loop.loop_block(stack_int_y.load() < y_end.load()); + { + SSAInt int_y = stack_int_y.load(); + SSAFloat float_y = SSAFloat(int_y) + 0.5f; + + llvm::Value *update_polygon_edge_args0[] = { float_y.v, num_vertices.v, window_positions.v, stack_left_index.v, stack_right_index.v }; + llvm::Value *update_polygon_edge_args1[] = { float_y.v, num_vertices.v, window_positions.v, stack_right_index.v, stack_left_index.v }; + SSAScope::builder().CreateCall(SSAScope::module()->getFunction("update_polygon_edge"), update_polygon_edge_args0); + SSAScope::builder().CreateCall(SSAScope::module()->getFunction("update_polygon_edge"), update_polygon_edge_args1); + + SSAInt left_index = stack_left_index.load(); + SSAInt right_index = stack_right_index.load(); + SSAInt next_left_index = (left_index + 1) % num_vertices; + SSAInt next_right_index = (right_index + 1) % num_vertices; + + SSABarycentricWeight left_weight(viewport, fragment_ins[0][left_index].load(), fragment_ins[0][next_left_index].load()); + SSABarycentricWeight right_weight(viewport, fragment_ins[0][right_index].load(), fragment_ins[0][next_right_index].load()); + + SSAFloat a = left_weight.from_window_y(int_y); + SSAFloat b = right_weight.from_window_y(int_y); + + SSAVec4f left_clip_pos = left_weight.v1 * a + left_weight.v2 * (1.0f - a); + SSAVec4f right_clip_pos = right_weight.v1 * b + right_weight.v2 * (1.0f - b); + + for (size_t i = 0; i + 1 < fragment_ins.size(); i++) + { + left_line_varyings[i].store(fragment_ins[i + 1][left_index].load() * a + fragment_ins[i + 1][next_left_index].load() * (1.0f - a)); + right_line_varyings[i].store(fragment_ins[i + 1][right_index].load() * b + fragment_ins[i + 1][next_right_index].load() * (1.0f - b)); + } + + llvm::Value *render_scanline_args[] = { output_width.v, output_height.v, output_data.v, viewport_x.v, viewport_y.v, viewport_width.v, viewport_height.v, int_y.v, left_clip_pos.v, right_clip_pos.v, left_line_varyings.v, right_line_varyings.v, input_width.v, input_height.v, input_data.v }; + SSAScope::builder().CreateCall(SSAScope::module()->getFunction("render_scanline"), render_scanline_args); + + stack_int_y.store(stack_int_y.load() + num_cores); + } + scanlines_loop.end_block(); + } + cull_if.end_block(); +} + +void GlslFixedFunction::codegen_render_scanline(int num_varyings) +{ + llvm::IRBuilder<> builder(program.context()); + SSAScope ssa_scope(&program.context(), program.module(), &builder); + + SSAFunction function("render_scanline"); + function.add_parameter(SSAInt::llvm_type()); // output_width + function.add_parameter(SSAInt::llvm_type()); // output_height + function.add_parameter(SSAUBytePtr::llvm_type()); // output_data + function.add_parameter(SSAInt::llvm_type()); // viewport_x + function.add_parameter(SSAInt::llvm_type()); // viewport_y + function.add_parameter(SSAInt::llvm_type()); // viewport_width + function.add_parameter(SSAInt::llvm_type()); // viewport_height + function.add_parameter(SSAInt::llvm_type()); // y + function.add_parameter(SSAVec4f::llvm_type()); // left_clip_pos + function.add_parameter(SSAVec4f::llvm_type()); // right_clip_pos + function.add_parameter(SSAVec4fPtr::llvm_type()); // left_line_varyings + function.add_parameter(SSAVec4fPtr::llvm_type()); // right_line_varyings + function.add_parameter(SSAInt::llvm_type()); // input_width + function.add_parameter(SSAInt::llvm_type()); // input_height + function.add_parameter(SSAUBytePtr::llvm_type()); // input_data + function.create_private(); + SSAInt output_width = function.parameter(0); + SSAInt output_height = function.parameter(1); + SSAUBytePtr output_data = function.parameter(2); + SSAInt viewport_x = function.parameter(3); + SSAInt viewport_y = function.parameter(4); + SSAInt viewport_width = function.parameter(5); + SSAInt viewport_height = function.parameter(6); + SSAInt y = function.parameter(7); + SSAVec4f left_clip_pos = function.parameter(8); + SSAVec4f right_clip_pos = function.parameter(9); + SSAVec4fPtr left_line_varyings = function.parameter(10); + SSAVec4fPtr right_line_varyings = function.parameter(11); + SSAInt input_width = function.parameter(12); + SSAInt input_height = function.parameter(13); + SSAUBytePtr input_data = function.parameter(14); + + SSAViewport viewport(viewport_x, viewport_y, viewport_width, viewport_height); + + SSAScopeHint hint; + + SSAStack stack_x; + SSAStack stack_xnormalized; + + //////////////////////////////// + // Prepare to render scanline: + + hint.set("prepare"); + OuterData outer_data; + + SSAVec4f left_window_pos = viewport.clip_to_window(left_clip_pos); + SSAVec4f right_window_pos = viewport.clip_to_window(right_clip_pos); + + SSAFloat x0 = left_window_pos[0]; + SSAFloat x1 = right_window_pos[0]; + SSAInt start(ssa_min(x0, x1)); + SSAInt end(ssa_max(x1, x0) + 0.5f); + + start = ssa_max(start, viewport.x); + end = ssa_min(end, viewport.right); + + SSABarycentricWeight weight_scanline(viewport, left_clip_pos, right_clip_pos); + + outer_data.start = start; + outer_data.end = end; + outer_data.input_width = input_width; + outer_data.input_height = input_height; + outer_data.output_width = output_width; + outer_data.output_height = output_height; + outer_data.input_pixels = input_data; + outer_data.output_pixels_line = output_data[output_width * y * 4]; + + outer_data.viewport_x = SSAFloat(viewport.x); + outer_data.viewport_rcp_half_width = viewport.rcp_half_width; + outer_data.dx = weight_scanline.v2[0] - weight_scanline.v1[0]; + outer_data.dw = weight_scanline.v2[3] - weight_scanline.v1[3]; + outer_data.v1w = weight_scanline.v1[3]; + outer_data.v1x = weight_scanline.v1[0]; + outer_data.sse_left_varying_in = left_line_varyings; + outer_data.sse_right_varying_in = right_line_varyings; + outer_data.num_varyings = num_varyings; + + outer_data.sampler = SSAScope::alloca(get_sampler_struct(SSAScope::context())); + std::vector index_list; + index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); + index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); + llvm::Value *sampler_width_ptr = SSAScope::builder().CreateGEP(outer_data.sampler, index_list); + index_list[1] = llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)1)); + llvm::Value *sampler_height_ptr = SSAScope::builder().CreateGEP(outer_data.sampler, index_list); + index_list[1] = llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)2)); + llvm::Value *sampler_data_ptr = SSAScope::builder().CreateGEP(outer_data.sampler, index_list); + SSAScope::builder().CreateStore(outer_data.input_width.v, sampler_width_ptr, false); + SSAScope::builder().CreateStore(outer_data.input_height.v, sampler_height_ptr, false); + SSAScope::builder().CreateStore(outer_data.input_pixels.v, sampler_data_ptr, false); + + + SSAVec4i xposinit = SSAVec4i(outer_data.start) + SSAVec4i(0, 1, 2, 3); + stack_x.store(outer_data.start); + stack_xnormalized.store((SSAVec4f(xposinit) + 0.5f - outer_data.viewport_x) * outer_data.viewport_rcp_half_width - 1.0f); + + ///////////////////////////////////////////////////////////////////////// + // First pixels: + + hint.set("firstpixels"); + SSAIfBlock if_block; + if_block.if_block(outer_data.end - outer_data.start > 3); + process_first_pixels(outer_data, stack_x, stack_xnormalized); + if_block.end_block(); + + ///////////////////////////////////////////////////////////////////////// + // Start: for (SSAInt x = start; x < end; x += 4) + + hint.set("loopstart"); + + SSAForBlock for_block; + SSAInt x = stack_x.load(); + for_block.loop_block(x + 3 < outer_data.end); + + ///////////////////////////////////////////////////////////////////////// + // Loop body + { + SSAVec4f xnormalized = stack_xnormalized.load(); + + hint.set("blendload"); + SSAVec4i desti[4]; + SSAVec16ub dest_block = outer_data.output_pixels_line[x << 2].load_vec16ub(); + SSAVec4i::extend(dest_block, desti[0], desti[1], desti[2], desti[3]); + + SSAVec4f frag_colors[4]; + inner_block(outer_data, xnormalized, frag_colors); + blend(frag_colors, dest_block); + + hint.set("blendstore"); + outer_data.output_pixels_line[x << 2].store_vec16ub(dest_block); + hint.clear(); + + xnormalized = xnormalized + 4.0f * outer_data.viewport_rcp_half_width; + stack_xnormalized.store(xnormalized); + } + ///////////////////////////////////////////////////////////////////////// + // End: for (SSAInt x = start; x < end; x += 4) + + hint.set("loopend"); + x = x + 4; + stack_x.store(x); + for_block.end_block(); + + ///////////////////////////////////////////////////////////////////////// + // Last pixels: + + hint.set("lastpixels"); + process_last_pixels(outer_data, stack_x, stack_xnormalized); + + builder.CreateRetVoid(); + llvm::verifyFunction(*function.func); +} + +void GlslFixedFunction::process_first_pixels(OuterData &outer_data, SSAStack &stack_x, SSAStack &stack_xnormalized) +{ + SSAInt x = stack_x.load(); + SSAVec4f xnormalized = stack_xnormalized.load(); + SSAInt offset = x << 2; + + // Find how many pixels we have left until we 16 byte align: + llvm::Value *output_line_align = SSAScope::builder().CreatePtrToInt(outer_data.output_pixels_line.v, llvm::Type::getInt32Ty(SSAScope::context())); + output_line_align = SSAScope::builder().CreateAdd(output_line_align, offset.v); + SSAInt left = 4 - (SSAInt::from_llvm(SSAScope::builder().CreateURem(output_line_align, SSAInt(16).v)) >> 2); + + SSAIfBlock if_block0; + if_block0.if_block(left == 3); + { + SSAVec4i dest[4] = + { + outer_data.output_pixels_line[offset].load_vec4ub(), + outer_data.output_pixels_line[offset + 4].load_vec4ub(), + outer_data.output_pixels_line[offset + 8].load_vec4ub(), + SSAVec4i(0) + }; + + // To do: do this in a less braindead way + SSAVec16ub dest_block(SSAVec8s(dest[0], dest[1]), SSAVec8s(dest[2], dest[3])); + SSAVec4f frag_colors[4]; + inner_block(outer_data, xnormalized, frag_colors); + blend(frag_colors, dest_block); + SSAVec4i::extend(dest_block, dest[0], dest[1], dest[2], dest[3]); + + outer_data.output_pixels_line[offset].store_vec4ub(dest[0]); + outer_data.output_pixels_line[offset + 4].store_vec4ub(dest[1]); + outer_data.output_pixels_line[offset + 8].store_vec4ub(dest[2]); + + stack_x.store(x + 3); + stack_xnormalized.store(xnormalized + 3.0f * outer_data.viewport_rcp_half_width); + } + if_block0.else_block(); + { + SSAIfBlock if_block1; + if_block1.if_block(left == 2); + { + SSAVec4i dest[4] = + { + outer_data.output_pixels_line[offset].load_vec4ub(), + outer_data.output_pixels_line[offset + 4].load_vec4ub(), + SSAVec4i(0), + SSAVec4i(0) + }; + + // To do: do this in a less braindead way + SSAVec16ub dest_block(SSAVec8s(dest[0], dest[1]), SSAVec8s(dest[2], dest[3])); + SSAVec4f frag_colors[4]; + inner_block(outer_data, xnormalized, frag_colors); + blend(frag_colors, dest_block); + SSAVec4i::extend(dest_block, dest[0], dest[1], dest[2], dest[3]); + + outer_data.output_pixels_line[offset].store_vec4ub(dest[0]); + outer_data.output_pixels_line[offset + 4].store_vec4ub(dest[1]); + + stack_x.store(x + 2); + stack_xnormalized.store(xnormalized + 2.0f * outer_data.viewport_rcp_half_width); + } + if_block1.else_block(); + { + SSAIfBlock if_block2; + if_block2.if_block(left == 1); + { + SSAVec4i dest[4] = + { + outer_data.output_pixels_line[offset].load_vec4ub(), + SSAVec4i(0), + SSAVec4i(0), + SSAVec4i(0) + }; + + // To do: do this in a less braindead way + SSAVec16ub dest_block(SSAVec8s(dest[0], dest[1]), SSAVec8s(dest[2], dest[3])); + SSAVec4f frag_colors[4]; + inner_block(outer_data, xnormalized, frag_colors); + blend(frag_colors, dest_block); + SSAVec4i::extend(dest_block, dest[0], dest[1], dest[2], dest[3]); + + outer_data.output_pixels_line[offset].store_vec4ub(dest[0]); + + stack_x.store(x + 1); + stack_xnormalized.store(xnormalized + outer_data.viewport_rcp_half_width); + } + if_block2.end_block(); + } + if_block1.end_block(); + } + if_block0.end_block(); +} + +void GlslFixedFunction::process_last_pixels(OuterData &outer_data, SSAStack &stack_x, SSAStack &stack_xnormalized) +{ + SSAInt x = stack_x.load(); + SSAVec4f xnormalized = stack_xnormalized.load(); + + SSAInt left = outer_data.end - x; + SSAInt offset = x << 2; + SSAIfBlock if_block0; + SSAIfBlock if_block1; + SSAIfBlock if_block2; + if_block0.if_block(left == 3); + { + SSAVec4i dest[4] = + { + outer_data.output_pixels_line[offset].load_vec4ub(), + outer_data.output_pixels_line[offset + 4].load_vec4ub(), + outer_data.output_pixels_line[offset + 8].load_vec4ub(), + SSAVec4i(0) + }; + + // To do: do this in a less braindead way + SSAVec16ub dest_block(SSAVec8s(dest[0], dest[1]), SSAVec8s(dest[2], dest[3])); + SSAVec4f frag_colors[4]; + inner_block(outer_data, xnormalized, frag_colors); + blend(frag_colors, dest_block); + SSAVec4i::extend(dest_block, dest[0], dest[1], dest[2], dest[3]); + + outer_data.output_pixels_line[offset].store_vec4ub(dest[0]); + outer_data.output_pixels_line[offset + 4].store_vec4ub(dest[1]); + outer_data.output_pixels_line[offset + 8].store_vec4ub(dest[2]); + } + if_block0.else_block(); + if_block1.if_block(left == 2); + { + SSAVec4i dest[4] = + { + outer_data.output_pixels_line[offset].load_vec4ub(), + outer_data.output_pixels_line[offset + 4].load_vec4ub(), + SSAVec4i(0), + SSAVec4i(0) + }; + + // To do: do this in a less braindead way + SSAVec16ub dest_block(SSAVec8s(dest[0], dest[1]), SSAVec8s(dest[2], dest[3])); + SSAVec4f frag_colors[4]; + inner_block(outer_data, xnormalized, frag_colors); + blend(frag_colors, dest_block); + SSAVec4i::extend(dest_block, dest[0], dest[1], dest[2], dest[3]); + + outer_data.output_pixels_line[offset].store_vec4ub(dest[0]); + outer_data.output_pixels_line[offset + 4].store_vec4ub(dest[1]); + } + if_block1.else_block(); + if_block2.if_block(left == 1); + { + SSAVec4i dest[4] = + { + outer_data.output_pixels_line[offset].load_vec4ub(), + SSAVec4i(0), + SSAVec4i(0), + SSAVec4i(0) + }; + + // To do: do this in a less braindead way + SSAVec16ub dest_block(SSAVec8s(dest[0], dest[1]), SSAVec8s(dest[2], dest[3])); + SSAVec4f frag_colors[4]; + inner_block(outer_data, xnormalized, frag_colors); + blend(frag_colors, dest_block); + SSAVec4i::extend(dest_block, dest[0], dest[1], dest[2], dest[3]); + + outer_data.output_pixels_line[offset].store_vec4ub(dest[0]); + } + if_block2.end_block(); + if_block1.end_block(); + if_block0.end_block(); +} + +void GlslFixedFunction::inner_block(OuterData &data, SSAVec4f xnormalized, SSAVec4f *frag_color) +{ + SSAScopeHint hint; + hint.set("varying"); + SSAVec4f a = (xnormalized * data.v1w - data.v1x) * SSAVec4f::rcp(data.dx - xnormalized * data.dw); + SSAVec4f one_minus_a = 1.0f - a; + + llvm::Value *globals_ptr[4]; + for (int i = 0; i < 4; i++) + { + globals_ptr[i] = SSAScope::alloca(fragment_codegen.get_global_struct_type()); + + std::vector index_list; + index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); + index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); + llvm::Value *sampler_ptr = SSAScope::builder().CreateGEP(globals_ptr[i], index_list); + SSAScope::builder().CreateStore(data.sampler, sampler_ptr, false); + + for (int j = 0; j < data.num_varyings; j++) + { + SSAVec4f field_value = + data.sse_left_varying_in[j].load() * SSAVec4f::shuffle(one_minus_a, i, i, i, i) + + data.sse_right_varying_in[j].load() * SSAVec4f::shuffle(a, i, i, i, i); + index_list.clear(); + index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); + index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)j+1))); + llvm::Value *field_ptr = SSAScope::builder().CreateGEP(globals_ptr[i], index_list); + SSAScope::builder().CreateStore(field_value.v, field_ptr, false); + } + } + + hint.set("fragprogram"); + for (int i = 0; i < 4; i++) + { + SSAScope::builder().CreateCall(SSAScope::module()->getFunction((fragment_codegen.shader_prefix() + "main").c_str()), globals_ptr[i]); + + std::vector index_list; + index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); + index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)5))); + llvm::Value *field_ptr = SSAScope::builder().CreateGEP(globals_ptr[i], index_list); + frag_color[i] = SSAVec4f::from_llvm(SSAScope::builder().CreateLoad(field_ptr, false)); + } +} +/* +void GlslFixedFunction::blend(SSAVec4f frag_color[4], SSAVec16ub &dest) +{ + SSAVec4i desti[4]; + SSAVec4i::extend(dest, desti[0], desti[1], desti[2], desti[3]); + + // Pre-mulitiplied alpha blend: + for (int pixel_index = 0; pixel_index < 4; pixel_index++) + { + SSAVec4f src = SSAVec4f::shuffle(frag_color[pixel_index], 2, 1, 0, 3); + desti[pixel_index] = SSAVec4i(src * 255.0f); + SSAVec4f dest = SSAVec4f(desti[pixel_index]) * (1.0f / 255.0f); + SSAVec4f alpha = SSAVec4f::shuffle(dest, 3, 3, 3, 3); + SSAVec4f resultf = src + dest * (1.0f - alpha); + desti[pixel_index] = SSAVec4i(resultf * 255.0f); + } + + dest = SSAVec16ub(SSAVec8s(desti[0], desti[1]), SSAVec8s(desti[2], desti[3])); +} +*/ +void GlslFixedFunction::blend(SSAVec4f frag_color[4], SSAVec16ub &dest) +{ + for (int i = 0; i < 4; i++) + frag_color[i] = SSAVec4f::shuffle(frag_color[i], 2, 1, 0, 3); + + // Pre-mulitiplied alpha blend: + SSAVec8s dest0 = SSAVec8s::extendlo(dest); + SSAVec8s dest1 = SSAVec8s::extendhi(dest); + + SSAVec8s src0(SSAVec4i(frag_color[0] * 255.0f), SSAVec4i(frag_color[1] * 255.0f)); + SSAVec8s src1(SSAVec4i(frag_color[2] * 255.0f), SSAVec4i(frag_color[3] * 255.0f)); + + // Extract and duplicate alpha components: + SSAVec8s alpha0 = SSAVec8s::shuffle(src0, 3, 3, 3, 3, 7, 7, 7, 7); + SSAVec8s alpha1 = SSAVec8s::shuffle(src1, 3, 3, 3, 3, 7, 7, 7, 7); + + // Convert from 0-255 to 0-256 range: + alpha0 = SSAVec8s::max_sse2(alpha0, 255); + alpha1 = SSAVec8s::max_sse2(alpha1, 255); + alpha0 = alpha0 + (alpha0 >> 7); + alpha1 = alpha1 + (alpha1 >> 7); + + SSAVec8s result0 = src0 + ((dest0 * (256 - alpha0)) >> 8); + SSAVec8s result1 = src1 + ((dest1 * (256 - alpha1)) >> 8); + + dest = SSAVec16ub(result0, result1); +} + +#endif diff --git a/src/r_compiler/fixedfunction/fixedfunction.h b/src/r_compiler/fixedfunction/fixedfunction.h new file mode 100644 index 000000000..4c81fc108 --- /dev/null +++ b/src/r_compiler/fixedfunction/fixedfunction.h @@ -0,0 +1,130 @@ + +#pragma once + +#include "r_compiler/ssa/ssa_vec4f.h" +#include "r_compiler/ssa/ssa_vec4i.h" +#include "r_compiler/ssa/ssa_vec8s.h" +#include "r_compiler/ssa/ssa_vec16ub.h" +#include "r_compiler/ssa/ssa_int.h" +#include "r_compiler/ssa/ssa_ubyte_ptr.h" +#include "r_compiler/ssa/ssa_vec4f_ptr.h" +#include "r_compiler/ssa/ssa_vec4i_ptr.h" +#include "r_compiler/ssa/ssa_pixels.h" +#include "r_compiler/ssa/ssa_stack.h" +#include "r_compiler/ssa/ssa_barycentric_weight.h" +#include "r_compiler/llvm_include.h" + +class RenderProgram +{ +public: + RenderProgram(); + ~RenderProgram(); + + template + Func *GetProcAddress(const char *name) { return reinterpret_cast(PointerToFunction(name)); } + + llvm::LLVMContext &context() { return *mContext; } + llvm::Module *module() { return mModule; } + llvm::ExecutionEngine *engine() { return mEngine.get(); } + +private: + void *PointerToFunction(const char *name); + + std::unique_ptr mContext; + llvm::Module *mModule; + std::unique_ptr mEngine; +}; + +class FixedFunction +{ +public: + FixedFunction(); + + void(*DrawSpan)(int, uint32_t *) = nullptr; + +private: + void CodegenDrawSpan(); + + RenderProgram mProgram; +}; + +#if 0 + +class GlslProgram; +class GlslCodeGen; + +class GlslFixedFunction +{ +public: + GlslFixedFunction(GlslProgram &program, GlslCodeGen &vertex_codegen, GlslCodeGen &fragment_codegen); + void codegen(); + static llvm::Type *get_sampler_struct(llvm::LLVMContext &context); + +private: + void codegen_draw_triangles(int num_vertex_in, int num_vertex_out); + void codegen_calc_window_positions(); + void codegen_calc_polygon_face_direction(); + void codegen_calc_polygon_y_range(); + void codegen_update_polygon_edge(); + void codegen_texture(); + void codegen_normalize(); + void codegen_reflect(); + void codegen_max(); + void codegen_pow(); + void codegen_dot(); + void codegen_mix(); + + struct OuterData + { + OuterData() : sampler() { } + + SSAInt start; + SSAInt end; + SSAInt input_width; + SSAInt input_height; + SSAInt output_width; + SSAInt output_height; + SSAUBytePtr input_pixels; + SSAUBytePtr output_pixels_line; + + SSAVec4fPtr sse_left_varying_in; + SSAVec4fPtr sse_right_varying_in; + int num_varyings; + SSAVec4f viewport_x; + SSAVec4f viewport_rcp_half_width; + SSAVec4f dx; + SSAVec4f dw; + SSAVec4f v1w; + SSAVec4f v1x; + + llvm::Value *sampler; + }; + + void render_polygon( + SSAInt input_width, + SSAInt input_height, + SSAUBytePtr input_data, + SSAInt output_width, + SSAInt output_height, + SSAUBytePtr output_data, + SSAInt viewport_x, + SSAInt viewport_y, + SSAInt viewport_width, + SSAInt viewport_height, + SSAInt num_vertices, + std::vector fragment_ins, + SSAInt core, + SSAInt num_cores); + + void codegen_render_scanline(int num_varyings); + void process_first_pixels(OuterData &outer_data, SSAStack &stack_x, SSAStack &stack_xnormalized); + void process_last_pixels(OuterData &outer_data, SSAStack &stack_x, SSAStack &stack_xnormalized); + void inner_block(OuterData &data, SSAVec4f xnormalized, SSAVec4f *out_frag_colors); + void blend(SSAVec4f frag_colors[4], SSAVec16ub &dest); + + GlslProgram &program; + GlslCodeGen &vertex_codegen; + GlslCodeGen &fragment_codegen; +}; + +#endif diff --git a/src/r_compiler/llvm_include.h b/src/r_compiler/llvm_include.h new file mode 100644 index 000000000..1eed549e1 --- /dev/null +++ b/src/r_compiler/llvm_include.h @@ -0,0 +1,46 @@ + +#pragma once + +#if defined(min) +#define llvm_min_bug min +#undef min +#endif +#if defined(max) +#define llvm_max_bug max +#undef max +#endif + +#pragma warning(disable: 4146) // warning C4146: unary minus operator applied to unsigned type, result still unsigned +#pragma warning(disable: 4624) // warning C4624: 'llvm::AugmentedUse' : destructor could not be generated because a base class destructor is inaccessible +#pragma warning(disable: 4355) // warning C4355: 'this' : used in base member initializer list +#pragma warning(disable: 4800) // warning C4800: 'const unsigned int' : forcing value to bool 'true' or 'false' (performance warning) +#pragma warning(disable: 4996) // warning C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_Sclan::SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' +#pragma warning(disable: 4244) // warning C4244: 'return' : conversion from 'uint64_t' to 'unsigned int', possible loss of data +#pragma warning(disable: 4141) // warning C4141: 'inline': used more than once +#pragma warning(disable: 4291) // warning C4291: 'void *llvm::User::operator new(std::size_t,unsigned int,unsigned int)': no matching operator delete found; memory will not be freed if initialization throws an exception + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(llvm_min_bug) +#define min llvm_min_bug +#undef llvm_min_bug +#endif +#if defined(llvm_max_bug) +#define max llvm_max_bug +#undef llvm_max_bug +#endif diff --git a/src/r_compiler/ssa/ssa_barycentric_weight.h b/src/r_compiler/ssa/ssa_barycentric_weight.h new file mode 100644 index 000000000..52117ccc6 --- /dev/null +++ b/src/r_compiler/ssa/ssa_barycentric_weight.h @@ -0,0 +1,97 @@ + +#pragma once + +#include "ssa_vec4f.h" +#include "ssa_float.h" +#include "ssa_int.h" + +class SSAViewport +{ +public: + SSAViewport(SSAInt x, SSAInt y, SSAInt width, SSAInt height) + : x(x), y(y), width(width), height(height), right(x + width), bottom(y + height), + half_width(SSAFloat(width) * 0.5f), half_height(SSAFloat(height) * 0.5f), + rcp_half_width(1.0f / (SSAFloat(width) * 0.5f)), + rcp_half_height(1.0f / (SSAFloat(height) * 0.5f)) + { + } + + SSAInt x, y; + SSAInt width, height; + SSAInt right, bottom; + SSAFloat half_width; + SSAFloat half_height; + SSAFloat rcp_half_width; + SSAFloat rcp_half_height; + + SSAVec4f clip_to_window(SSAVec4f clip) const + { + SSAFloat w = clip[3]; + SSAVec4f normalized = SSAVec4f::insert_element(clip / SSAVec4f::shuffle(clip, 3, 3, 3, 3), w, 3); + return normalized_to_window(normalized); + } + + SSAVec4f normalized_to_window(SSAVec4f normalized) const + { + return SSAVec4f( + SSAFloat(x) + (normalized[0] + 1.0f) * half_width, + SSAFloat(y) + (normalized[1] + 1.0f) * half_height, + 0.0f - normalized[2], + normalized[3]); + } +}; + +class SSABarycentricWeight +{ +public: + SSABarycentricWeight(SSAViewport vp, SSAVec4f v1, SSAVec4f v2); + SSAFloat from_window_x(SSAInt x) const; + SSAFloat from_window_y(SSAInt y) const; + + SSAViewport viewport; + SSAVec4f v1; + SSAVec4f v2; +}; + +inline SSABarycentricWeight::SSABarycentricWeight(SSAViewport viewport, SSAVec4f v1, SSAVec4f v2) +: viewport(viewport), v1(v1), v2(v2) +{ +} + +inline SSAFloat SSABarycentricWeight::from_window_x(SSAInt x) const +{ +/* SSAFloat xnormalized = (x + 0.5f - viewport.x) * viewport.rcp_half_width - 1.0f; + SSAFloat dx = v2.x-v1.x; + SSAFloat dw = v2.w-v1.w; + SSAFloat a = (v2.x - xnormalized * v2.w) / (dx - xnormalized * dw); + return a;*/ + + SSAFloat xnormalized = (SSAFloat(x) + 0.5f - SSAFloat(viewport.x)) * viewport.rcp_half_width - 1.0f; + SSAFloat dx = v2[0]-v1[0]; + SSAFloat dw = v2[3]-v1[3]; + SSAFloat t = (xnormalized * v1[3] - v1[0]) / (dx - xnormalized * dw); + return 1.0f - t; +} + +inline SSAFloat SSABarycentricWeight::from_window_y(SSAInt y) const +{ +/* SSAFloat ynormalized = (y + 0.5f - viewport.y) * viewport.rcp_half_height - 1.0f; + SSAFloat dy = v2.y-v1.y; + SSAFloat dw = v2.w-v1.w; + SSAFloat a = (v2.y - ynormalized * v2.w) / (dy - ynormalized * dw); + return a;*/ + + SSAFloat ynormalized = (SSAFloat(y) + 0.5f - SSAFloat(viewport.y)) * viewport.rcp_half_height - 1.0f; + SSAFloat dy = v2[1]-v1[1]; + SSAFloat dw = v2[3]-v1[3]; + SSAFloat t = (ynormalized * v1[3] - v1[1]) / (dy - ynormalized * dw); + return 1.0f - t; +} + +/* + y = (v1.y + t * dy) / (v1.w + t * dw) + + y * v1.w + y * t * dw = v1.y + t * dy + y * v1.w - v1.y = t * (dy - y * dw) + t = (y * v1.w - v1.y) / (dy - y * dw) +*/ diff --git a/src/r_compiler/ssa/ssa_bool.cpp b/src/r_compiler/ssa/ssa_bool.cpp new file mode 100644 index 000000000..101323911 --- /dev/null +++ b/src/r_compiler/ssa/ssa_bool.cpp @@ -0,0 +1,91 @@ + +#include "ssa_bool.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSABool::SSABool() +: v(0) +{ +} +/* +SSABool::SSABool(bool constant) +: v(0) +{ +} +*/ +SSABool::SSABool(llvm::Value *v) +: v(v) +{ +} + +llvm::Type *SSABool::llvm_type() +{ + return llvm::Type::getInt1Ty(SSAScope::context()); +} + +SSABool operator&&(const SSABool &a, const SSABool &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateAnd(a.v, b.v, SSAScope::hint())); +} + +SSABool operator||(const SSABool &a, const SSABool &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateOr(a.v, b.v, SSAScope::hint())); +} + +SSABool operator!(const SSABool &a) +{ + return SSABool::from_llvm(SSAScope::builder().CreateNot(a.v, SSAScope::hint())); +} + +SSABool operator<(const SSAInt &a, const SSAInt &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateICmpSLT(a.v, b.v, SSAScope::hint())); +} + +SSABool operator<=(const SSAInt &a, const SSAInt &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateICmpSLE(a.v, b.v, SSAScope::hint())); +} + +SSABool operator==(const SSAInt &a, const SSAInt &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateICmpEQ(a.v, b.v, SSAScope::hint())); +} + +SSABool operator>=(const SSAInt &a, const SSAInt &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateICmpSGE(a.v, b.v, SSAScope::hint())); +} + +SSABool operator>(const SSAInt &a, const SSAInt &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateICmpSGT(a.v, b.v, SSAScope::hint())); +} + +///////////////////////////////////////////////////////////////////////////// + +SSABool operator<(const SSAFloat &a, const SSAFloat &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateFCmpOLT(a.v, b.v, SSAScope::hint())); +} + +SSABool operator<=(const SSAFloat &a, const SSAFloat &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateFCmpOLE(a.v, b.v, SSAScope::hint())); +} + +SSABool operator==(const SSAFloat &a, const SSAFloat &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateFCmpOEQ(a.v, b.v, SSAScope::hint())); +} + +SSABool operator>=(const SSAFloat &a, const SSAFloat &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateFCmpOGE(a.v, b.v, SSAScope::hint())); +} + +SSABool operator>(const SSAFloat &a, const SSAFloat &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateFCmpOGT(a.v, b.v, SSAScope::hint())); +} diff --git a/src/r_compiler/ssa/ssa_bool.h b/src/r_compiler/ssa/ssa_bool.h new file mode 100644 index 000000000..2ef79e49b --- /dev/null +++ b/src/r_compiler/ssa/ssa_bool.h @@ -0,0 +1,37 @@ + +#pragma once + +#include "ssa_int.h" +#include "ssa_float.h" + +namespace llvm { class Value; } +namespace llvm { class Type; } + +class SSABool +{ +public: + SSABool(); + //SSABool(bool constant); + explicit SSABool(llvm::Value *v); + static SSABool from_llvm(llvm::Value *v) { return SSABool(v); } + static llvm::Type *llvm_type(); + + llvm::Value *v; +}; + +SSABool operator&&(const SSABool &a, const SSABool &b); +SSABool operator||(const SSABool &a, const SSABool &b); + +SSABool operator!(const SSABool &a); + +SSABool operator<(const SSAInt &a, const SSAInt &b); +SSABool operator<=(const SSAInt &a, const SSAInt &b); +SSABool operator==(const SSAInt &a, const SSAInt &b); +SSABool operator>=(const SSAInt &a, const SSAInt &b); +SSABool operator>(const SSAInt &a, const SSAInt &b); + +SSABool operator<(const SSAFloat &a, const SSAFloat &b); +SSABool operator<=(const SSAFloat &a, const SSAFloat &b); +SSABool operator==(const SSAFloat &a, const SSAFloat &b); +SSABool operator>=(const SSAFloat &a, const SSAFloat &b); +SSABool operator>(const SSAFloat &a, const SSAFloat &b); diff --git a/src/r_compiler/ssa/ssa_float.cpp b/src/r_compiler/ssa/ssa_float.cpp new file mode 100644 index 000000000..87488af74 --- /dev/null +++ b/src/r_compiler/ssa/ssa_float.cpp @@ -0,0 +1,152 @@ + +#include "ssa_float.h" +#include "ssa_int.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSAFloat::SSAFloat() +: v(0) +{ +} + +SSAFloat::SSAFloat(float constant) +: v(0) +{ + v = llvm::ConstantFP::get(SSAScope::context(), llvm::APFloat(constant)); +} + +SSAFloat::SSAFloat(SSAInt i) +: v(0) +{ + v = SSAScope::builder().CreateSIToFP(i.v, llvm::Type::getFloatTy(SSAScope::context()), SSAScope::hint()); +} + +SSAFloat::SSAFloat(llvm::Value *v) +: v(v) +{ +} + +llvm::Type *SSAFloat::llvm_type() +{ + return llvm::Type::getFloatTy(SSAScope::context()); +} + +SSAFloat SSAFloat::sqrt(SSAFloat f) +{ + std::vector params; + params.push_back(SSAFloat::llvm_type()); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::sqrt, params), f.v, SSAScope::hint())); +} + +SSAFloat SSAFloat::sin(SSAFloat val) +{ + std::vector params; + params.push_back(SSAFloat::llvm_type()); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::sin, params), val.v, SSAScope::hint())); +} + +SSAFloat SSAFloat::cos(SSAFloat val) +{ + std::vector params; + params.push_back(SSAFloat::llvm_type()); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::cos, params), val.v, SSAScope::hint())); +} + +SSAFloat SSAFloat::pow(SSAFloat val, SSAFloat power) +{ + std::vector params; + params.push_back(SSAFloat::llvm_type()); + //params.push_back(SSAFloat::llvm_type()); + std::vector args; + args.push_back(val.v); + args.push_back(power.v); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::pow, params), args, SSAScope::hint())); +} + +SSAFloat SSAFloat::exp(SSAFloat val) +{ + std::vector params; + params.push_back(SSAFloat::llvm_type()); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::exp, params), val.v, SSAScope::hint())); +} + +SSAFloat SSAFloat::log(SSAFloat val) +{ + std::vector params; + params.push_back(SSAFloat::llvm_type()); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::log, params), val.v, SSAScope::hint())); +} + +SSAFloat SSAFloat::fma(SSAFloat a, SSAFloat b, SSAFloat c) +{ + std::vector params; + params.push_back(SSAFloat::llvm_type()); + //params.push_back(SSAFloat::llvm_type()); + //params.push_back(SSAFloat::llvm_type()); + std::vector args; + args.push_back(a.v); + args.push_back(b.v); + args.push_back(c.v); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::fma, params), args, SSAScope::hint())); +} + +SSAFloat operator+(const SSAFloat &a, const SSAFloat &b) +{ + return SSAFloat::from_llvm(SSAScope::builder().CreateFAdd(a.v, b.v, SSAScope::hint())); +} + +SSAFloat operator-(const SSAFloat &a, const SSAFloat &b) +{ + return SSAFloat::from_llvm(SSAScope::builder().CreateFSub(a.v, b.v, SSAScope::hint())); +} + +SSAFloat operator*(const SSAFloat &a, const SSAFloat &b) +{ + return SSAFloat::from_llvm(SSAScope::builder().CreateFMul(a.v, b.v, SSAScope::hint())); +} + +SSAFloat operator/(const SSAFloat &a, const SSAFloat &b) +{ + return SSAFloat::from_llvm(SSAScope::builder().CreateFDiv(a.v, b.v, SSAScope::hint())); +} + +SSAFloat operator+(float a, const SSAFloat &b) +{ + return SSAFloat(a) + b; +} + +SSAFloat operator-(float a, const SSAFloat &b) +{ + return SSAFloat(a) - b; +} + +SSAFloat operator*(float a, const SSAFloat &b) +{ + return SSAFloat(a) * b; +} + +SSAFloat operator/(float a, const SSAFloat &b) +{ + return SSAFloat(a) / b; +} + +SSAFloat operator+(const SSAFloat &a, float b) +{ + return a + SSAFloat(b); +} + +SSAFloat operator-(const SSAFloat &a, float b) +{ + return a - SSAFloat(b); +} + +SSAFloat operator*(const SSAFloat &a, float b) +{ + return a * SSAFloat(b); +} + +SSAFloat operator/(const SSAFloat &a, float b) +{ + return a / SSAFloat(b); +} + diff --git a/src/r_compiler/ssa/ssa_float.h b/src/r_compiler/ssa/ssa_float.h new file mode 100644 index 000000000..2349ab877 --- /dev/null +++ b/src/r_compiler/ssa/ssa_float.h @@ -0,0 +1,42 @@ + +#pragma once + +namespace llvm { class Value; } +namespace llvm { class Type; } + +class SSAInt; + +class SSAFloat +{ +public: + SSAFloat(); + SSAFloat(SSAInt i); + SSAFloat(float constant); + explicit SSAFloat(llvm::Value *v); + static SSAFloat from_llvm(llvm::Value *v) { return SSAFloat(v); } + static llvm::Type *llvm_type(); + static SSAFloat sqrt(SSAFloat f); + static SSAFloat sin(SSAFloat val); + static SSAFloat cos(SSAFloat val); + static SSAFloat pow(SSAFloat val, SSAFloat power); + static SSAFloat exp(SSAFloat val); + static SSAFloat log(SSAFloat val); + static SSAFloat fma(SSAFloat a, SSAFloat b, SSAFloat c); + + llvm::Value *v; +}; + +SSAFloat operator+(const SSAFloat &a, const SSAFloat &b); +SSAFloat operator-(const SSAFloat &a, const SSAFloat &b); +SSAFloat operator*(const SSAFloat &a, const SSAFloat &b); +SSAFloat operator/(const SSAFloat &a, const SSAFloat &b); + +SSAFloat operator+(float a, const SSAFloat &b); +SSAFloat operator-(float a, const SSAFloat &b); +SSAFloat operator*(float a, const SSAFloat &b); +SSAFloat operator/(float a, const SSAFloat &b); + +SSAFloat operator+(const SSAFloat &a, float b); +SSAFloat operator-(const SSAFloat &a, float b); +SSAFloat operator*(const SSAFloat &a, float b); +SSAFloat operator/(const SSAFloat &a, float b); diff --git a/src/r_compiler/ssa/ssa_float_ptr.cpp b/src/r_compiler/ssa/ssa_float_ptr.cpp new file mode 100644 index 000000000..4413c6e92 --- /dev/null +++ b/src/r_compiler/ssa/ssa_float_ptr.cpp @@ -0,0 +1,65 @@ + +#include "ssa_float_ptr.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSAFloatPtr::SSAFloatPtr() +: v(0) +{ +} + +SSAFloatPtr::SSAFloatPtr(llvm::Value *v) +: v(v) +{ +} + +llvm::Type *SSAFloatPtr::llvm_type() +{ + return llvm::Type::getFloatPtrTy(SSAScope::context()); +} + +SSAFloatPtr SSAFloatPtr::operator[](SSAInt index) const +{ + return SSAFloatPtr::from_llvm(SSAScope::builder().CreateGEP(v, index.v, SSAScope::hint())); +} + +SSAFloat SSAFloatPtr::load() const +{ + return SSAFloat::from_llvm(SSAScope::builder().CreateLoad(v, false, SSAScope::hint())); +} + +SSAVec4f SSAFloatPtr::load_vec4f() const +{ + llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); + return SSAVec4f::from_llvm(SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), false, SSAScope::hint())); +} + +SSAVec4f SSAFloatPtr::load_unaligned_vec4f() const +{ + llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); + return SSAVec4f::from_llvm(SSAScope::builder().Insert(new llvm::LoadInst(SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), SSAScope::hint(), false, 4), SSAScope::hint())); + // return SSAVec4f::from_llvm(SSAScope::builder().CreateCall(get_intrinsic(llvm::Intrinsic::x86_sse2_loadu_dq), SSAScope::builder().CreateBitCast(v, llvm::PointerType::getUnqual(llvm::IntegerType::get(SSAScope::context(), 8))))); +} + +void SSAFloatPtr::store(const SSAFloat &new_value) +{ + SSAScope::builder().CreateStore(new_value.v, v, false); +} + +void SSAFloatPtr::store_vec4f(const SSAVec4f &new_value) +{ + llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); + SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), 16); +} + +void SSAFloatPtr::store_unaligned_vec4f(const SSAVec4f &new_value) +{ + /*llvm::Value *values[2] = + { + SSAScope::builder().CreateBitCast(v, llvm::Type::getFloatPtrTy(SSAScope::context())), + new_value.v + }; + SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse_storeu_ps), values);*/ + llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); + SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint())); +} diff --git a/src/r_compiler/ssa/ssa_float_ptr.h b/src/r_compiler/ssa/ssa_float_ptr.h new file mode 100644 index 000000000..a4318e027 --- /dev/null +++ b/src/r_compiler/ssa/ssa_float_ptr.h @@ -0,0 +1,27 @@ + +#pragma once + +#include "ssa_float.h" +#include "ssa_int.h" +#include "ssa_vec4f.h" + +namespace llvm { class Value; } +namespace llvm { class Type; } + +class SSAFloatPtr +{ +public: + SSAFloatPtr(); + explicit SSAFloatPtr(llvm::Value *v); + static SSAFloatPtr from_llvm(llvm::Value *v) { return SSAFloatPtr(v); } + static llvm::Type *llvm_type(); + SSAFloatPtr operator[](SSAInt index) const; + SSAFloat load() const; + SSAVec4f load_vec4f() const; + SSAVec4f load_unaligned_vec4f() const; + void store(const SSAFloat &new_value); + void store_vec4f(const SSAVec4f &new_value); + void store_unaligned_vec4f(const SSAVec4f &new_value); + + llvm::Value *v; +}; diff --git a/src/r_compiler/ssa/ssa_for_block.cpp b/src/r_compiler/ssa/ssa_for_block.cpp new file mode 100644 index 000000000..ce9328607 --- /dev/null +++ b/src/r_compiler/ssa/ssa_for_block.cpp @@ -0,0 +1,25 @@ + +#include "ssa_for_block.h" +#include "ssa_scope.h" + +SSAForBlock::SSAForBlock() +: if_basic_block(0), loop_basic_block(0), end_basic_block(0) +{ + if_basic_block = llvm::BasicBlock::Create(SSAScope::context(), "forbegin", SSAScope::builder().GetInsertBlock()->getParent()); + loop_basic_block = llvm::BasicBlock::Create(SSAScope::context(), "forloop", SSAScope::builder().GetInsertBlock()->getParent()); + end_basic_block = llvm::BasicBlock::Create(SSAScope::context(), "forend", SSAScope::builder().GetInsertBlock()->getParent()); + SSAScope::builder().CreateBr(if_basic_block); + SSAScope::builder().SetInsertPoint(if_basic_block); +} + +void SSAForBlock::loop_block(SSABool true_condition) +{ + SSAScope::builder().CreateCondBr(true_condition.v, loop_basic_block, end_basic_block); + SSAScope::builder().SetInsertPoint(loop_basic_block); +} + +void SSAForBlock::end_block() +{ + SSAScope::builder().CreateBr(if_basic_block); + SSAScope::builder().SetInsertPoint(end_basic_block); +} diff --git a/src/r_compiler/ssa/ssa_for_block.h b/src/r_compiler/ssa/ssa_for_block.h new file mode 100644 index 000000000..58803dee5 --- /dev/null +++ b/src/r_compiler/ssa/ssa_for_block.h @@ -0,0 +1,18 @@ + +#pragma once + +#include "ssa_bool.h" +#include "r_compiler/llvm_include.h" + +class SSAForBlock +{ +public: + SSAForBlock(); + void loop_block(SSABool true_condition); + void end_block(); + +private: + llvm::BasicBlock *if_basic_block; + llvm::BasicBlock *loop_basic_block; + llvm::BasicBlock *end_basic_block; +}; diff --git a/src/r_compiler/ssa/ssa_function.cpp b/src/r_compiler/ssa/ssa_function.cpp new file mode 100644 index 000000000..aee4de5a9 --- /dev/null +++ b/src/r_compiler/ssa/ssa_function.cpp @@ -0,0 +1,55 @@ + +#include "ssa_function.h" +#include "ssa_int.h" +#include "ssa_scope.h" +#include "ssa_value.h" +#include "r_compiler/llvm_include.h" + +SSAFunction::SSAFunction(const std::string name) +: name(name), return_type(llvm::Type::getVoidTy(SSAScope::context())), func() +{ +} + +void SSAFunction::set_return_type(llvm::Type *type) +{ + return_type = type; +} + +void SSAFunction::add_parameter(llvm::Type *type) +{ + parameters.push_back(type); +} + +void SSAFunction::create_public() +{ + func = SSAScope::module()->getFunction(name.c_str()); + if (func == 0) + { + llvm::FunctionType *function_type = llvm::FunctionType::get(return_type, parameters, false); + func = llvm::Function::Create(function_type, llvm::Function::ExternalLinkage, name.c_str(), SSAScope::module()); + //func->setCallingConv(llvm::CallingConv::X86_StdCall); + } + llvm::BasicBlock *entry = llvm::BasicBlock::Create(SSAScope::context(), "entry", func); + SSAScope::builder().SetInsertPoint(entry); +} + +void SSAFunction::create_private() +{ + func = SSAScope::module()->getFunction(name.c_str()); + if (func == 0) + { + llvm::FunctionType *function_type = llvm::FunctionType::get(return_type, parameters, false); + func = llvm::Function::Create(function_type, llvm::Function::PrivateLinkage, name.c_str(), SSAScope::module()); + func->addFnAttr(llvm::Attribute::AlwaysInline); + } + llvm::BasicBlock *entry = llvm::BasicBlock::Create(SSAScope::context(), "entry", func); + SSAScope::builder().SetInsertPoint(entry); +} + +SSAValue SSAFunction::parameter(int index) +{ + llvm::Function::arg_iterator arg_it = func->arg_begin(); + for (int i = 0; i < index; i++) + ++arg_it; + return SSAValue::from_llvm(static_cast(arg_it)); +} diff --git a/src/r_compiler/ssa/ssa_function.h b/src/r_compiler/ssa/ssa_function.h new file mode 100644 index 000000000..f1969c35b --- /dev/null +++ b/src/r_compiler/ssa/ssa_function.h @@ -0,0 +1,30 @@ + +#pragma once + +#include +#include + +namespace llvm { class Value; } +namespace llvm { class Type; } +namespace llvm { class Function; } + +class SSAInt; +class SSAValue; + +class SSAFunction +{ +public: + SSAFunction(const std::string name); + void set_return_type(llvm::Type *type); + void add_parameter(llvm::Type *type); + void create_public(); + void create_private(); + SSAValue parameter(int index); + + llvm::Function *func; + +private: + std::string name; + llvm::Type *return_type; + std::vector parameters; +}; diff --git a/src/r_compiler/ssa/ssa_if_block.cpp b/src/r_compiler/ssa/ssa_if_block.cpp new file mode 100644 index 000000000..e2de9ecad --- /dev/null +++ b/src/r_compiler/ssa/ssa_if_block.cpp @@ -0,0 +1,30 @@ + +#include "ssa_if_block.h" +#include "ssa_scope.h" + +SSAIfBlock::SSAIfBlock() +: if_basic_block(0), else_basic_block(0), end_basic_block(0) +{ +} + +void SSAIfBlock::if_block(SSABool true_condition) +{ + if_basic_block = llvm::BasicBlock::Create(SSAScope::context(), "if", SSAScope::builder().GetInsertBlock()->getParent()); + else_basic_block = llvm::BasicBlock::Create(SSAScope::context(), "else", SSAScope::builder().GetInsertBlock()->getParent()); + end_basic_block = else_basic_block; + SSAScope::builder().CreateCondBr(true_condition.v, if_basic_block, else_basic_block); + SSAScope::builder().SetInsertPoint(if_basic_block); +} + +void SSAIfBlock::else_block() +{ + end_basic_block = llvm::BasicBlock::Create(SSAScope::context(), "end", SSAScope::builder().GetInsertBlock()->getParent()); + SSAScope::builder().CreateBr(end_basic_block); + SSAScope::builder().SetInsertPoint(else_basic_block); +} + +void SSAIfBlock::end_block() +{ + SSAScope::builder().CreateBr(end_basic_block); + SSAScope::builder().SetInsertPoint(end_basic_block); +} diff --git a/src/r_compiler/ssa/ssa_if_block.h b/src/r_compiler/ssa/ssa_if_block.h new file mode 100644 index 000000000..98c534a86 --- /dev/null +++ b/src/r_compiler/ssa/ssa_if_block.h @@ -0,0 +1,46 @@ + +#pragma once + +#include "ssa_bool.h" +#include "ssa_phi.h" +#include "r_compiler/llvm_include.h" + +class SSAIfBlock +{ +public: + SSAIfBlock(); + void if_block(SSABool true_condition); + void else_block(); + void end_block(); + +private: + llvm::BasicBlock *if_basic_block; + llvm::BasicBlock *else_basic_block; + llvm::BasicBlock *end_basic_block; +}; + +template +T ssa_min(T a, T b) +{ + SSAPhi phi; + SSAIfBlock if_block; + if_block.if_block(a <= b); + phi.add_incoming(a); + if_block.else_block(); + phi.add_incoming(b); + if_block.end_block(); + return phi.create(); +} + +template +T ssa_max(T a, T b) +{ + SSAPhi phi; + SSAIfBlock if_block; + if_block.if_block(a >= b); + phi.add_incoming(a); + if_block.else_block(); + phi.add_incoming(b); + if_block.end_block(); + return phi.create(); +} diff --git a/src/r_compiler/ssa/ssa_int.cpp b/src/r_compiler/ssa/ssa_int.cpp new file mode 100644 index 000000000..9f3c54f50 --- /dev/null +++ b/src/r_compiler/ssa/ssa_int.cpp @@ -0,0 +1,117 @@ + +#include "ssa_int.h" +#include "ssa_float.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSAInt::SSAInt() +: v(0) +{ +} + +SSAInt::SSAInt(int constant) +: v(0) +{ + v = llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, constant, true)); +} + +SSAInt::SSAInt(SSAFloat f) +: v(0) +{ + v = SSAScope::builder().CreateFPToSI(f.v, llvm::Type::getInt32Ty(SSAScope::context()), SSAScope::hint()); +} + +SSAInt::SSAInt(llvm::Value *v) +: v(v) +{ +} + +llvm::Type *SSAInt::llvm_type() +{ + return llvm::Type::getInt32Ty(SSAScope::context()); +} + +SSAInt operator+(const SSAInt &a, const SSAInt &b) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); +} + +SSAInt operator-(const SSAInt &a, const SSAInt &b) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateSub(a.v, b.v, SSAScope::hint())); +} + +SSAInt operator*(const SSAInt &a, const SSAInt &b) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateMul(a.v, b.v, SSAScope::hint())); +} + +SSAInt operator/(const SSAInt &a, const SSAInt &b) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateSDiv(a.v, b.v, SSAScope::hint())); +} + +SSAInt operator%(const SSAInt &a, const SSAInt &b) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateSRem(a.v, b.v, SSAScope::hint())); +} + +SSAInt operator+(int a, const SSAInt &b) +{ + return SSAInt(a) + b; +} + +SSAInt operator-(int a, const SSAInt &b) +{ + return SSAInt(a) - b; +} + +SSAInt operator*(int a, const SSAInt &b) +{ + return SSAInt(a) * b; +} + +SSAInt operator/(int a, const SSAInt &b) +{ + return SSAInt(a) / b; +} + +SSAInt operator%(int a, const SSAInt &b) +{ + return SSAInt(a) % b; +} + +SSAInt operator+(const SSAInt &a, int b) +{ + return a + SSAInt(b); +} + +SSAInt operator-(const SSAInt &a, int b) +{ + return a - SSAInt(b); +} + +SSAInt operator*(const SSAInt &a, int b) +{ + return a * SSAInt(b); +} + +SSAInt operator/(const SSAInt &a, int b) +{ + return a / SSAInt(b); +} + +SSAInt operator%(const SSAInt &a, int b) +{ + return a % SSAInt(b); +} + +SSAInt operator<<(const SSAInt &a, int bits) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateShl(a.v, bits, SSAScope::hint())); +} + +SSAInt operator>>(const SSAInt &a, int bits) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateLShr(a.v, bits, SSAScope::hint())); +} diff --git a/src/r_compiler/ssa/ssa_int.h b/src/r_compiler/ssa/ssa_int.h new file mode 100644 index 000000000..0be37ee7e --- /dev/null +++ b/src/r_compiler/ssa/ssa_int.h @@ -0,0 +1,41 @@ + +#pragma once + +namespace llvm { class Value; } +namespace llvm { class Type; } + +class SSAFloat; + +class SSAInt +{ +public: + SSAInt(); + SSAInt(int constant); + SSAInt(SSAFloat f); + explicit SSAInt(llvm::Value *v); + static SSAInt from_llvm(llvm::Value *v) { return SSAInt(v); } + static llvm::Type *llvm_type(); + + llvm::Value *v; +}; + +SSAInt operator+(const SSAInt &a, const SSAInt &b); +SSAInt operator-(const SSAInt &a, const SSAInt &b); +SSAInt operator*(const SSAInt &a, const SSAInt &b); +SSAInt operator/(const SSAInt &a, const SSAInt &b); +SSAInt operator%(const SSAInt &a, const SSAInt &b); + +SSAInt operator+(int a, const SSAInt &b); +SSAInt operator-(int a, const SSAInt &b); +SSAInt operator*(int a, const SSAInt &b); +SSAInt operator/(int a, const SSAInt &b); +SSAInt operator%(int a, const SSAInt &b); + +SSAInt operator+(const SSAInt &a, int b); +SSAInt operator-(const SSAInt &a, int b); +SSAInt operator*(const SSAInt &a, int b); +SSAInt operator/(const SSAInt &a, int b); +SSAInt operator%(const SSAInt &a, int b); + +SSAInt operator<<(const SSAInt &a, int bits); +SSAInt operator>>(const SSAInt &a, int bits); diff --git a/src/r_compiler/ssa/ssa_int_ptr.cpp b/src/r_compiler/ssa/ssa_int_ptr.cpp new file mode 100644 index 000000000..dd0ca17f6 --- /dev/null +++ b/src/r_compiler/ssa/ssa_int_ptr.cpp @@ -0,0 +1,58 @@ + +#include "ssa_int_ptr.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSAIntPtr::SSAIntPtr() +: v(0) +{ +} + +SSAIntPtr::SSAIntPtr(llvm::Value *v) +: v(v) +{ +} + +llvm::Type *SSAIntPtr::llvm_type() +{ + return llvm::Type::getInt32PtrTy(SSAScope::context()); +} + +SSAIntPtr SSAIntPtr::operator[](SSAInt index) const +{ + return SSAIntPtr::from_llvm(SSAScope::builder().CreateGEP(v, index.v, SSAScope::hint())); +} + +SSAInt SSAIntPtr::load() const +{ + return SSAInt::from_llvm(SSAScope::builder().CreateLoad(v, false, SSAScope::hint())); +} + +SSAVec4i SSAIntPtr::load_vec4i() const +{ + llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); + return SSAVec4i::from_llvm(SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), false, SSAScope::hint())); +} + +SSAVec4i SSAIntPtr::load_unaligned_vec4i() const +{ + llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); + return SSAVec4i::from_llvm(SSAScope::builder().Insert(new llvm::LoadInst(SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), SSAScope::hint(), false, 4), SSAScope::hint())); +} + +void SSAIntPtr::store(const SSAInt &new_value) +{ + SSAScope::builder().CreateStore(new_value.v, v, false); +} + +void SSAIntPtr::store_vec4i(const SSAVec4i &new_value) +{ + llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); + SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 16); +} + +void SSAIntPtr::store_unaligned_vec4i(const SSAVec4i &new_value) +{ + llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); + SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint())); +} diff --git a/src/r_compiler/ssa/ssa_int_ptr.h b/src/r_compiler/ssa/ssa_int_ptr.h new file mode 100644 index 000000000..20e024a31 --- /dev/null +++ b/src/r_compiler/ssa/ssa_int_ptr.h @@ -0,0 +1,27 @@ + +#pragma once + +#include "ssa_float.h" +#include "ssa_int.h" +#include "ssa_vec4i.h" + +namespace llvm { class Value; } +namespace llvm { class Type; } + +class SSAIntPtr +{ +public: + SSAIntPtr(); + explicit SSAIntPtr(llvm::Value *v); + static SSAIntPtr from_llvm(llvm::Value *v) { return SSAIntPtr(v); } + static llvm::Type *llvm_type(); + SSAIntPtr operator[](SSAInt index) const; + SSAInt load() const; + SSAVec4i load_vec4i() const; + SSAVec4i load_unaligned_vec4i() const; + void store(const SSAInt &new_value); + void store_vec4i(const SSAVec4i &new_value); + void store_unaligned_vec4i(const SSAVec4i &new_value); + + llvm::Value *v; +}; diff --git a/src/r_compiler/ssa/ssa_phi.h b/src/r_compiler/ssa/ssa_phi.h new file mode 100644 index 000000000..89cbc8cf0 --- /dev/null +++ b/src/r_compiler/ssa/ssa_phi.h @@ -0,0 +1,33 @@ + +#pragma once + +#include "ssa_scope.h" + +class SSAIfBlock; + +template +class SSAPhi +{ +public: + void add_incoming(SSAVariable var) + { + incoming.push_back(Incoming(var.v, SSAScope::builder().GetInsertBlock())); + } + + SSAVariable create() + { + llvm::PHINode *phi_node = SSAScope::builder().CreatePHI(SSAVariable::llvm_type(), (unsigned int)incoming.size(), SSAScope::hint()); + for (size_t i = 0; i < incoming.size(); i++) + phi_node->addIncoming(incoming[i].v, incoming[i].bb); + return SSAVariable::from_llvm(phi_node); + } + +private: + struct Incoming + { + Incoming(llvm::Value *v, llvm::BasicBlock *bb) : v(v), bb(bb) { } + llvm::Value *v; + llvm::BasicBlock *bb; + }; + std::vector incoming; +}; diff --git a/src/r_compiler/ssa/ssa_pixelformat4f.h b/src/r_compiler/ssa/ssa_pixelformat4f.h new file mode 100644 index 000000000..507e95b5d --- /dev/null +++ b/src/r_compiler/ssa/ssa_pixelformat4f.h @@ -0,0 +1,28 @@ + +#pragma once + +#include "ssa_int.h" +#include "ssa_float_ptr.h" + +class SSAPixelFormat4f +{ +public: + SSAPixelFormat4f() { } + SSAPixelFormat4f(SSAFloatPtr pixels, SSAInt width, SSAInt height) : _pixels(pixels) { } + + SSAFloatPtr pixels() { return _pixels; } + SSAFloatPtr pixels() const { return _pixels; } + + SSAVec4f get4f(SSAInt index) const + { + return _pixels[index * 4].load_vec4f(); + } + + void set4f(SSAInt index, const SSAVec4f &pixel) + { + _pixels[index * 4].store_vec4f(pixel); + } + +protected: + SSAFloatPtr _pixels; +}; diff --git a/src/r_compiler/ssa/ssa_pixelformat4ub.h b/src/r_compiler/ssa/ssa_pixelformat4ub.h new file mode 100644 index 000000000..fdf98c4aa --- /dev/null +++ b/src/r_compiler/ssa/ssa_pixelformat4ub.h @@ -0,0 +1,28 @@ + +#pragma once + +#include "ssa_int.h" +#include "ssa_ubyte_ptr.h" + +class SSAPixelFormat4ub +{ +public: + SSAPixelFormat4ub() { } + SSAPixelFormat4ub(SSAUBytePtr pixels, SSAInt width, SSAInt height) : _pixels(pixels) { } + + SSAUBytePtr pixels() { return _pixels; } + SSAUBytePtr pixels() const { return _pixels; } + + SSAVec4f get4f(SSAInt index) const + { + return SSAVec4f(_pixels[index * 4].load_vec4ub()) * (1.0f / 255.0f); + } + + void set4f(SSAInt index, const SSAVec4f &pixel) + { + _pixels[index * 4].store_vec4ub(SSAVec4i(pixel * 255.0f)); + } + +private: + SSAUBytePtr _pixels; +}; diff --git a/src/r_compiler/ssa/ssa_pixelformat4ub_argb_rev.h b/src/r_compiler/ssa/ssa_pixelformat4ub_argb_rev.h new file mode 100644 index 000000000..4601eeb3c --- /dev/null +++ b/src/r_compiler/ssa/ssa_pixelformat4ub_argb_rev.h @@ -0,0 +1,35 @@ + +#pragma once + +#include "ssa_int.h" +#include "ssa_ubyte_ptr.h" + +class SSAPixelFormat4ub_argb_rev +{ +public: + SSAPixelFormat4ub_argb_rev() { } + SSAPixelFormat4ub_argb_rev(SSAUBytePtr pixels, SSAInt width, SSAInt height) : _pixels(pixels) { } + + SSAUBytePtr pixels() { return _pixels; } + SSAUBytePtr pixels() const { return _pixels; } +/* + void get4f(SSAInt index, SSAVec4f &out_pixel1, SSAVec4f &out_pixel2) const + { + SSAVec8s p = _pixels[index * 4].load_vec8s(); + out_pixel1 = SSAVec4f::shuffle(SSAVec4f(SSAVec4i::extendlo(p)) * (1.0f / 255.0f), 2, 1, 0, 3); + out_pixel2 = SSAVec4f::shuffle(SSAVec4f(SSAVec4i::extendhi(p)) * (1.0f / 255.0f), 2, 1, 0, 3); + } +*/ + SSAVec4f get4f(SSAInt index) const + { + return SSAVec4f::shuffle(SSAVec4f(_pixels[index * 4].load_vec4ub()) * (1.0f / 255.0f), 2, 1, 0, 3); + } + + void set4f(SSAInt index, const SSAVec4f &pixel) + { + _pixels[index * 4].store_vec4ub(SSAVec4i(SSAVec4f::shuffle(pixel * 255.0f, 2, 1, 0, 3))); + } + +public: + SSAUBytePtr _pixels; +}; diff --git a/src/r_compiler/ssa/ssa_pixelformat4ub_rev.h b/src/r_compiler/ssa/ssa_pixelformat4ub_rev.h new file mode 100644 index 000000000..402480c49 --- /dev/null +++ b/src/r_compiler/ssa/ssa_pixelformat4ub_rev.h @@ -0,0 +1,28 @@ + +#pragma once + +#include "ssa_int.h" +#include "ssa_ubyte_ptr.h" + +class SSAPixelFormat4ub_rev +{ +public: + SSAPixelFormat4ub_rev() { } + SSAPixelFormat4ub_rev(SSAUBytePtr pixels, SSAInt width, SSAInt height) : _pixels(pixels) { } + + SSAUBytePtr pixels() { return _pixels; } + SSAUBytePtr pixels() const { return _pixels; } + + SSAVec4f get4f(SSAInt index) const + { + return SSAVec4f::shuffle(SSAVec4f(_pixels[index * 4].load_vec4ub()) * (1.0f / 255.0f), 3, 2, 1, 0); + } + + void set4f(SSAInt index, const SSAVec4f &pixel) + { + _pixels[index * 4].store_vec4ub(SSAVec4i(SSAVec4f::shuffle(pixel * 255.0f, 3, 2, 1, 0))); + } + +public: + SSAUBytePtr _pixels; +}; diff --git a/src/r_compiler/ssa/ssa_pixels.h b/src/r_compiler/ssa/ssa_pixels.h new file mode 100644 index 000000000..a4209d439 --- /dev/null +++ b/src/r_compiler/ssa/ssa_pixels.h @@ -0,0 +1,39 @@ + +#pragma once + +#include "ssa_ubyte.h" +#include "ssa_ubyte_ptr.h" +#include "ssa_float.h" +#include "ssa_float_ptr.h" +#include "ssa_int.h" +#include "ssa_pixeltype.h" +//#include "ssa_pixelformat1f.h" +//#include "ssa_pixelformat2f.h" +//#include "ssa_pixelformat3f.h" +#include "ssa_pixelformat4f.h" +//#include "ssa_pixelformat1ub.h" +//#include "ssa_pixelformat2ub.h" +//#include "ssa_pixelformat3ub.h" +//#include "ssa_pixelformat3ub_rev.h" +#include "ssa_pixelformat4ub.h" +//#include "ssa_pixelformat4ub_argb.h" +#include "ssa_pixelformat4ub_rev.h" +#include "ssa_pixelformat4ub_argb_rev.h" +//#include "ssa_pixelformat4ub_channel.h" + +//typedef SSAPixelType SSAPixels1f; +//typedef SSAPixelType SSAPixels2f; +//typedef SSAPixelType SSAPixels3f; +typedef SSAPixelType SSAPixels4f; + +//typedef SSAPixelType SSAPixels1ub; +//typedef SSAPixelType SSAPixels2ub; +//typedef SSAPixelType SSAPixels3ub; +typedef SSAPixelType SSAPixels4ub; +//typedef SSAPixelType SSAPixels4ub_argb; + +//typedef SSAPixelType SSAPixels3ub_rev; +typedef SSAPixelType SSAPixels4ub_rev; +typedef SSAPixelType SSAPixels4ub_argb_rev; + +//typedef SSAPixelType SSAPixels4ub_channel; diff --git a/src/r_compiler/ssa/ssa_pixeltype.h b/src/r_compiler/ssa/ssa_pixeltype.h new file mode 100644 index 000000000..8614f171d --- /dev/null +++ b/src/r_compiler/ssa/ssa_pixeltype.h @@ -0,0 +1,498 @@ + +#pragma once + +#include "ssa_int.h" +#include "ssa_float.h" +#include "ssa_vec4f.h" +#include "ssa_bool.h" +#include "ssa_if_block.h" +#include "ssa_phi.h" + +template +class SSAPixelType : public PixelFormat +{ +public: + SSAPixelType() + { + } + + SSAPixelType(SSAInt width, SSAInt height, PixelType pixels) + : PixelFormat(pixels, width, height), _width(width), _height(height) + { + _width32 = SSAVec4i(_width); + SSAVec4i height32(_height); + _widthps = SSAVec4f(_width32); + _heightps = SSAVec4f(height32); + _width16 = SSAVec8s(_width32, _width32); + + _widthheight = SSAVec4i::shuffle(_width32, height32, 0, 0, 4, 4); + _widthheightps = SSAVec4i::shuffle(_widthps, _heightps, 0, 0, 4, 4); + } + + SSAInt width() const { return _width; } + SSAInt height() const { return _height; } + SSAInt size() const { return _width * _height; } + + SSABool in_bounds(SSAInt i) const { return i >= 0 && i < _width * _height; } + SSABool in_bounds(SSAInt x, SSAInt y) const { return x>= 0 && x < _width && y >= 0 && y < _height; } + //void throw_if_out_of_bounds(SSAInt i) const { if (!in_bounds(i)) throw clan::Exception("Out of bounds"); } + //void throw_if_out_of_bounds(SSAInt x, SSAInt y) const { if (!in_bounds(x, y)) throw clan::Exception("Out of bounds"); } + + SSAInt s_to_x(SSAFloat s) const { return round(s * SSAFloat(_width)); } + SSAInt t_to_y(SSAFloat t) const { return round(t * SSAFloat(_height)); } + SSAInt clamp_x(SSAInt x) const { return clamp(x, _width); } + SSAInt clamp_y(SSAInt y) const { return clamp(y, _height); } + SSAInt repeat_x(SSAInt x) const { return repeat(x,_width); } + SSAInt repeat_y(SSAInt y) const { return repeat(y, _height); } + SSAInt mirror_x(SSAInt x) const { return mirror(x, _width); } + SSAInt mirror_y(SSAInt y) const { return mirror(y, _height); } + + static SSAInt int_min(SSAInt a, SSAInt b) + { + SSAPhi phi; + SSAIfBlock branch; + branch.if_block(a <= b); + phi.add_incoming(a); + branch.else_block(); + phi.add_incoming(b); + branch.end_block(); + return phi.create(); + } + + static SSAInt int_max(SSAInt a, SSAInt b) + { + SSAPhi phi; + SSAIfBlock branch; + branch.if_block(a >= b); + phi.add_incoming(a); + branch.else_block(); + phi.add_incoming(b); + branch.end_block(); + return phi.create(); + } + + static SSAInt clamp(SSAInt v, SSAInt size) + { + return int_max(int_min(v, size - 1), 0); + } + + static SSAInt repeat(SSAInt v, SSAInt size) + { + SSAPhi phi; + SSAIfBlock branch; + branch.if_block(v >= 0); + phi.add_incoming(v % size); + branch.else_block(); + phi.add_incoming(size - 1 + v % size); + branch.end_block(); + return phi.create(); + } + + static SSAInt mirror(SSAInt v, SSAInt size) + { + SSAInt size2 = size * 2; + v = repeat(v, size2); + + SSAPhi phi; + SSAIfBlock branch; + branch.if_block(v < size); + phi.add_incoming(v); + branch.else_block(); + phi.add_incoming(size2 - v - 1); + branch.end_block(); + return phi.create(); + } + + static SSAInt round(SSAFloat v) + { + SSAPhi phi; + SSAIfBlock branch; + branch.if_block(v >= 0.0f); + phi.add_incoming(v + 0.5f); + branch.else_block(); + phi.add_incoming(v - 0.5f); + branch.end_block(); + return SSAInt(phi.create()); + } + + // To do: fix this: + static SSAInt int_floor(SSAFloat v) + { + return SSAInt(v); + } + static SSAFloat fract(SSAFloat v) { return v - SSAFloat(int_floor(v)); } + + SSAVec4f get4f(SSAInt x, SSAInt y) const { return PixelFormat::get4f(x + y * _width); } + void set4f(SSAInt x, SSAInt y, const SSAVec4f &pixel) { PixelFormat::set4f(x + y * _width, pixel); } + + SSAVec4f get_clamp4f(SSAInt x, SSAInt y) const { return get4f(clamp_x(x), clamp_y(y)); } + SSAVec4f get_repeat4f(SSAInt x, SSAInt y) const { return get4f(repeat_x(x), repeat_y(y)); } + SSAVec4f get_mirror4f(SSAInt x, SSAInt y) const { return get4f(mirror_x(x), mirror_y(y)); } + + SSAVec4f linear_interpolate4f(SSAFloat s, SSAFloat t, const SSAVec4f *samples) const + { + SSAFloat a = fract(s * SSAFloat(_width) - 0.5f); + SSAFloat b = fract(t * SSAFloat(_height) - 0.5f); + SSAFloat inv_a = 1.0f - a; + SSAFloat inv_b = 1.0f - b; + return + samples[0] * (inv_a * inv_b) + + samples[1] * (a * inv_b) + + samples[2] * (inv_a * b) + + samples[3] * (a * b); + } + + void gather_clamp4f(SSAFloat s, SSAFloat t, SSAVec4f *out_pixels) const + { + SSAInt x = int_floor(s * SSAFloat(_width) - 0.5f); + SSAInt y = int_floor(t * SSAFloat(_height) - 0.5f); + out_pixels[0] = get_clamp4f(x, y); + out_pixels[1] = get_clamp4f(x + 1, y); + out_pixels[2] = get_clamp4f(x, y + 1); + out_pixels[3] = get_clamp4f(x + 1, y + 1); + /* + SSAInt x0 = clamp_x(x); + SSAInt x1 = clamp_x(x + 1); + SSAInt y0 = clamp_y(y); + SSAInt y1 = clamp_y(y + 1); + SSAInt offset0 = y0 * _width; + SSAInt offset1 = y1 * _width; + SSAPhi phi0; + SSAPhi phi1; + SSAPhi phi2; + SSAPhi phi3; + SSAIfBlock if0; + if0.if_block(x0 + 1 == x1); + phi0.add_incoming(PixelFormat::get4f(x0 + offset0)); + phi1.add_incoming(PixelFormat::get4f(x1 + offset0)); + phi2.add_incoming(PixelFormat::get4f(x0 + offset1)); + phi3.add_incoming(PixelFormat::get4f(x1 + offset1)); + if0.else_block(); + phi0.add_incoming(PixelFormat::get4f(x0 + offset0)); + phi1.add_incoming(PixelFormat::get4f(x1 + offset0)); + phi2.add_incoming(PixelFormat::get4f(x0 + offset1)); + phi3.add_incoming(PixelFormat::get4f(x1 + offset1)); + if0.end_block(); + out_pixels[0] = phi0.create(); + out_pixels[1] = phi1.create(); + out_pixels[2] = phi2.create(); + out_pixels[3] = phi3.create(); + */ + } + + void gather_repeat4f(SSAFloat s, SSAFloat t, SSAVec4f *out_pixels) const + { + SSAInt x = int_floor(s * SSAFloat(_width) - 0.5f); + SSAInt y = int_floor(t * SSAFloat(_height) - 0.5f); + out_pixels[0] = get_repeat4f(x, y); + out_pixels[1] = get_repeat4f(x + 1, y); + out_pixels[2] = get_repeat4f(x, y + 1); + out_pixels[3] = get_repeat4f(x + 1, y + 1); + } + + void gather_mirror4f(SSAFloat s, SSAFloat t, SSAVec4f *out_pixels) const + { + SSAInt x = int_floor(s * SSAFloat(_width) - 0.5f); + SSAInt y = int_floor(t * SSAFloat(_height) - 0.5f); + out_pixels[0] = get_mirror4f(x, y); + out_pixels[1] = get_mirror4f(x + 1, y); + out_pixels[2] = get_mirror4f(x, y + 1); + out_pixels[3] = get_mirror4f(x + 1, y + 1); + } + + SSAVec4f nearest_clamp4f(SSAFloat s, SSAFloat t) const { return get_clamp4f(s_to_x(s), t_to_y(t)); } + SSAVec4f nearest_repeat4f(SSAFloat s, SSAFloat t) const { return get_repeat4f(s_to_x(s), t_to_y(t)); } + SSAVec4f nearest_mirror4f(SSAFloat s, SSAFloat t) const { return get_mirror4f(s_to_x(s), t_to_y(t)); } + + SSAVec4f linear_clamp4f(SSAFloat s, SSAFloat t) const + { + SSAVec4f samples[4]; + gather_clamp4f(s, t, samples); + return linear_interpolate4f(s, t, samples); + } + + SSAVec4f linear_repeat4f(SSAFloat s, SSAFloat t) const + { + SSAVec4f samples[4]; + gather_repeat4f(s, t, samples); + return linear_interpolate4f(s, t, samples); + } + + SSAVec4f linear_mirror4f(SSAFloat s, SSAFloat t) const + { + SSAVec4f samples[4]; + gather_mirror4f(s, t, samples); + return linear_interpolate4f(s, t, samples); + } + + ///////////////////////////////////////////////////////////////////////// + // Packed versions: + + SSAVec4i s_to_x(SSAVec4f s) const { return round(s * SSAVec4f(_width)); } + SSAVec4i t_to_y(SSAVec4f t) const { return round(t * SSAVec4f(_height)); } + SSAVec4i clamp_x(SSAVec4i x) const { return clamp(x, _width); } + SSAVec4i clamp_y(SSAVec4i y) const { return clamp(y, _height); } + SSAVec4i repeat_x(SSAVec4i x) const { return repeat(x,_width); } + SSAVec4i repeat_y(SSAVec4i y) const { return repeat(y, _height); } + SSAVec4i mirror_x(SSAVec4i x) const { return mirror(x, _width); } + SSAVec4i mirror_y(SSAVec4i y) const { return mirror(y, _height); } + + static SSAVec4i clamp(SSAVec4i v, SSAInt size) + { + return SSAVec4i::max_sse41(SSAVec4i::min_sse41(v, size - 1), 0); + } + + static SSAVec4i repeat(SSAVec4i v, SSAInt size) + { + return clamp(v, size); + /*SSAPhi phi; + SSAIfBlock branch; + branch.if_block(v >= 0); + phi.add_incoming(v % size); + branch.else_block(); + phi.add_incoming(size - 1 + v % size); + branch.end_block(); + return phi.create();*/ + } + + static SSAVec4i mirror(SSAVec4i v, SSAInt size) + { + return clamp(v, size); + /*SSAInt size2 = size * 2; + v = repeat(v, size2); + + SSAPhi phi; + SSAIfBlock branch; + branch.if_block(v < size); + phi.add_incoming(v); + branch.else_block(); + phi.add_incoming(size2 - v - 1); + branch.end_block(); + return phi.create();*/ + } + + static SSAVec4i round(SSAVec4f v) + { + // Maybe we should use the normal round SSE function (but that requires the rounding mode is set the round to nearest before the code runs) + SSAVec4i signbit = (SSAVec4i::bitcast(v) & 0x80000000); + SSAVec4f signed_half = SSAVec4f::bitcast(signbit | SSAVec4i::bitcast(SSAVec4f(0.5f))); + return v + signed_half; + } + + static SSAVec4i int_floor(SSAVec4f v) + { + return SSAVec4i(v) - (SSAVec4i::bitcast(v) >> 31); + } + + static SSAVec4f fract(SSAVec4f v) + { + // return v - SSAVec4f::floor_sse4(v); + return v - SSAVec4f(int_floor(v)); + } + + template + SSAVec4f nearest_helper4f(SSAVec4f s, SSAVec4f t, int index, WrapXFunctor wrap_x, WrapYFunctor wrap_y) const + { + SSAVec4i x = int_floor(s * _widthps - 0.5f); + SSAVec4i y = int_floor(t * _heightps - 0.5f); + SSAVec8s y16 = SSAVec8s(wrap_y(y), wrap_y(y)); + SSAVec8s offsethi = SSAVec8s::mulhi(y16, _width16); + SSAVec8s offsetlo = y16 * _width16; + SSAVec4i offset = SSAVec4i::combinelo(offsetlo, offsethi) + x; + return PixelFormat::get4f(offset[index]); + } + + SSAVec4f nearest_clamp4f(SSAVec4f s, SSAVec4f t, int index) const + { + struct WrapX { WrapX(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->clamp_x(v); } const SSAPixelType *self; }; + struct WrapY { WrapY(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->clamp_y(v); } const SSAPixelType *self; }; + return nearest_helper4f(s, t, index, WrapX(this), WrapY(this)); + /* + return nearest_helper4f( + s, t, index, + [this](SSAVec4i v) -> SSAVec4i { return clamp_x(v); }, + [this](SSAVec4i v) -> SSAVec4i { return clamp_y(v); }); + */ + } + + SSAVec4f nearest_repeat4f(SSAVec4f s, SSAVec4f t, int index) const + { + struct WrapX { WrapX(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->repeat_x(v); } const SSAPixelType *self; }; + struct WrapY { WrapY(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->repeat_y(v); } const SSAPixelType *self; }; + return nearest_helper4f(s, t, index, WrapX(this), WrapY(this)); + /* + return nearest_helper4f( + s, t, index, + [this](SSAVec4i v) -> SSAVec4i { return repeat_x(v); }, + [this](SSAVec4i v) -> SSAVec4i { return repeat_y(v); }); + */ + } + + SSAVec4f nearest_mirror4f(SSAVec4f s, SSAVec4f t, int index) const + { + struct WrapX { WrapX(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->mirror_x(v); } const SSAPixelType *self; }; + struct WrapY { WrapY(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->mirror_y(v); } const SSAPixelType *self; }; + return nearest_helper4f(s, t, index, WrapX(this), WrapY(this)); + /* + return nearest_helper4f( + s, t, index, + [this](SSAVec4i v) -> SSAVec4i { return mirror_x(v); }, + [this](SSAVec4i v) -> SSAVec4i { return mirror_y(v); }); + */ + } + + template + void gather_helper4f(SSAVec4f s, SSAVec4f t, int index, SSAVec4f *out_pixels, WrapXFunctor wrap_x, WrapYFunctor wrap_y) const + { + SSAVec4i x = int_floor(s * _widthps - 0.5f); + SSAVec4i y = int_floor(t * _heightps - 0.5f); + SSAVec8s y16 = SSAVec8s(wrap_y(y + 1), wrap_y(y)); + SSAVec8s offsethi = SSAVec8s::mulhi(y16, _width16); + SSAVec8s offsetlo = y16 * _width16; + SSAVec4i x0 = wrap_x(x); + SSAVec4i x1 = wrap_x(x + 1); + SSAVec4i line0 = SSAVec4i::combinehi(offsetlo, offsethi); + SSAVec4i line1 = SSAVec4i::combinelo(offsetlo, offsethi); + SSAVec4i offset0 = x0 + line0; + SSAVec4i offset1 = x1 + line0; + SSAVec4i offset2 = x0 + line1; + SSAVec4i offset3 = x1 + line1; + out_pixels[0] = PixelFormat::get4f(offset0[index]); + out_pixels[1] = PixelFormat::get4f(offset1[index]); + out_pixels[2] = PixelFormat::get4f(offset2[index]); + out_pixels[3] = PixelFormat::get4f(offset3[index]); + } + + void gather_clamp4f(SSAVec4f s, SSAVec4f t, int index, SSAVec4f *out_pixels) const + { + struct WrapX { WrapX(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->clamp_x(v); } const SSAPixelType *self; }; + struct WrapY { WrapY(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->clamp_y(v); } const SSAPixelType *self; }; + return gather_helper4f(s, t, index, out_pixels, WrapX(this), WrapY(this)); + /* + gather_helper4f( + s, t, index, out_pixels, + [this](SSAVec4i v) -> SSAVec4i { return clamp_x(v); }, + [this](SSAVec4i v) -> SSAVec4i { return clamp_y(v); }); + */ + } + + void gather_repeat4f(SSAVec4f s, SSAVec4f t, int index, SSAVec4f *out_pixels) const + { + struct WrapX { WrapX(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->repeat_x(v); } const SSAPixelType *self; }; + struct WrapY { WrapY(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->repeat_y(v); } const SSAPixelType *self; }; + return gather_helper4f(s, t, index, out_pixels, WrapX(this), WrapY(this)); + /* + gather_helper4f( + s, t, index, out_pixels, + [this](SSAVec4i v) -> SSAVec4i { return repeat_x(v); }, + [this](SSAVec4i v) -> SSAVec4i { return repeat_y(v); }); + */ + } + + void gather_mirror4f(SSAVec4f s, SSAVec4f t, int index, SSAVec4f *out_pixels) const + { + struct WrapX { WrapX(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->mirror_x(v); } const SSAPixelType *self; }; + struct WrapY { WrapY(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->mirror_y(v); } const SSAPixelType *self; }; + return gather_helper4f(s, t, index, out_pixels, WrapX(this), WrapY(this)); + /* + gather_helper4f( + s, t, index, out_pixels, + [this](SSAVec4i v) -> SSAVec4i { return mirror_x(v); }, + [this](SSAVec4i v) -> SSAVec4i { return mirror_y(v); }); + */ + } + + SSAVec4f linear_clamp4f(SSAVec4f s, SSAVec4f t, int index) const + { + SSAScopeHint hint("linearclamp"); + SSAVec4f samples[4]; + gather_clamp4f(s, t, index, samples); + return linear_interpolate4f(s, t, index, samples); + } + + SSAVec4f linear_repeat4f(SSAVec4f s, SSAVec4f t, int index) const + { + SSAVec4f samples[4]; + gather_repeat4f(s, t, index, samples); + return linear_interpolate4f(s, t, index, samples); + } + + SSAVec4f linear_mirror4f(SSAVec4f s, SSAVec4f t, int index) const + { + SSAVec4f samples[4]; + gather_mirror4f(s, t, index, samples); + return linear_interpolate4f(s, t, index, samples); + } + + SSAVec4f linear_interpolate4f(SSAVec4f s, SSAVec4f t, int index, const SSAVec4f *samples) const + { + SSAVec4f a = fract(s * _widthps - 0.5f); + SSAVec4f b = fract(t * _heightps - 0.5f); + SSAVec4f inv_a = 1.0f - a; + SSAVec4f inv_b = 1.0f - b; + return + samples[0] * SSAVec4f::shuffle(inv_a * inv_b, index, index, index, index) + + samples[1] * SSAVec4f::shuffle(a * inv_b, index, index, index, index) + + samples[2] * SSAVec4f::shuffle(inv_a * b, index, index, index, index) + + samples[3] * SSAVec4f::shuffle(a * b, index, index, index, index); + } + + ///////////////////////////////////////////////////////////////////////// + + SSAVec4i clamp(SSAVec4i sstt) const + { + return SSAVec4i::max_sse41(SSAVec4i::min_sse41(sstt, _widthheight - 1), 0); + } + + template + void gather_helper4f(SSAVec4f st, SSAVec4f *out_pixels, WrapFunctor wrap) const + { + SSAVec4f sstt = SSAVec4f::shuffle(st, 0, 0, 1, 1); + SSAVec4i xxyy = wrap(int_floor(sstt * _widthheightps - 0.5f) + SSAVec4i(0, 1, 0, 1)); + SSAVec4i xxoffset = SSAVec4f::shuffle(xxyy, xxyy * _width32, 0, 1, 6, 7); + SSAVec4i offsets = SSAVec4i::shuffle(xxoffset, 0, 1, 0, 1) + SSAVec4i::shuffle(xxoffset, 2, 2, 3, 3); + out_pixels[0] = PixelFormat::get4f(offsets[0]); + out_pixels[1] = PixelFormat::get4f(offsets[1]); + out_pixels[2] = PixelFormat::get4f(offsets[2]); + out_pixels[3] = PixelFormat::get4f(offsets[3]); + } + + void gather_clamp4f(SSAVec4f st, SSAVec4f *out_pixels) const + { + struct Wrap { Wrap(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i sstt) { return self->clamp(sstt); } const SSAPixelType *self; }; + return gather_helper4f(st, out_pixels, Wrap(this)); + } + + SSAVec4f linear_clamp4f(SSAVec4f st) const + { + SSAScopeHint hint("linearclamp"); + SSAVec4f samples[4]; + gather_clamp4f(st, samples); + return linear_interpolate4f(st, samples); + } + + SSAVec4f linear_interpolate4f(SSAVec4f st, const SSAVec4f *samples) const + { + SSAVec4f sstt = SSAVec4f::shuffle(st, 0, 0, 1, 1); + SSAVec4f aabb = fract(sstt * _widthheightps - 0.5f); + SSAVec4f inv_aabb = 1.0f - aabb; + SSAVec4f ab_inv_ab = SSAVec4f::shuffle(aabb, inv_aabb, 0, 2, 4, 6); + SSAVec4f ab__inv_a_b__inv_a_inv_b__a_invb = ab_inv_ab * SSAVec4f::shuffle(ab_inv_ab, 1, 2, 3, 0); + return + samples[0] * SSAVec4f::shuffle(ab__inv_a_b__inv_a_inv_b__a_invb, 2, 2, 2, 2) + + samples[1] * SSAVec4f::shuffle(ab__inv_a_b__inv_a_inv_b__a_invb, 3, 3, 3, 3) + + samples[2] * SSAVec4f::shuffle(ab__inv_a_b__inv_a_inv_b__a_invb, 1, 1, 1, 1) + + samples[3] * SSAVec4f::shuffle(ab__inv_a_b__inv_a_inv_b__a_invb, 0, 0, 0, 0); + } + +public: + SSAInt _width; + SSAInt _height; + SSAVec4i _width32; + SSAVec8s _width16; + SSAVec4f _widthps; + SSAVec4f _heightps; + + SSAVec4i _widthheight; + SSAVec4f _widthheightps; +}; diff --git a/src/r_compiler/ssa/ssa_scope.cpp b/src/r_compiler/ssa/ssa_scope.cpp new file mode 100644 index 000000000..f9d16f188 --- /dev/null +++ b/src/r_compiler/ssa/ssa_scope.cpp @@ -0,0 +1,65 @@ + +#include "ssa_scope.h" +#include "ssa_int.h" + +SSAScope::SSAScope(llvm::LLVMContext *context, llvm::Module *module, llvm::IRBuilder<> *builder) +: _context(context), _module(module), _builder(builder) +{ + instance = this; +} + +SSAScope::~SSAScope() +{ + instance = 0; +} + +llvm::LLVMContext &SSAScope::context() +{ + return *instance->_context; +} + +llvm::Module *SSAScope::module() +{ + return instance->_module; +} + +llvm::IRBuilder<> &SSAScope::builder() +{ + return *instance->_builder; +} + +llvm::Function *SSAScope::intrinsic(llvm::Intrinsic::ID id, llvm::ArrayRef parameter_types) +{ + llvm::Function *func = module()->getFunction(llvm::Intrinsic::getName(id)); + if (func == 0) + func = llvm::Function::Create(llvm::Intrinsic::getType(context(), id, parameter_types), llvm::Function::ExternalLinkage, llvm::Intrinsic::getName(id, parameter_types), module()); + return func; +} + +llvm::Value *SSAScope::alloca(llvm::Type *type) +{ + return alloca(type, SSAInt(1)); +} + +llvm::Value *SSAScope::alloca(llvm::Type *type, SSAInt size) +{ + // Allocas must be created at top of entry block for the PromoteMemoryToRegisterPass to work + llvm::BasicBlock &entry = SSAScope::builder().GetInsertBlock()->getParent()->getEntryBlock(); + llvm::IRBuilder<> alloca_builder(&entry, entry.begin()); + return alloca_builder.CreateAlloca(type, size.v, hint()); +} + +const std::string &SSAScope::hint() +{ + return instance->_hint; +} + +void SSAScope::set_hint(const std::string &new_hint) +{ + if (new_hint.empty()) + instance->_hint = "tmp"; + else + instance->_hint = new_hint; +} + +SSAScope *SSAScope::instance = 0; diff --git a/src/r_compiler/ssa/ssa_scope.h b/src/r_compiler/ssa/ssa_scope.h new file mode 100644 index 000000000..d184643ad --- /dev/null +++ b/src/r_compiler/ssa/ssa_scope.h @@ -0,0 +1,41 @@ + +#pragma once + +#include "r_compiler/llvm_include.h" + +class SSAInt; + +class SSAScope +{ +public: + SSAScope(llvm::LLVMContext *context, llvm::Module *module, llvm::IRBuilder<> *builder); + ~SSAScope(); + static llvm::LLVMContext &context(); + static llvm::Module *module(); + static llvm::IRBuilder<> &builder(); + static llvm::Function *intrinsic(llvm::Intrinsic::ID id, llvm::ArrayRef parameter_types = llvm::ArrayRef()); + static llvm::Value *alloca(llvm::Type *type); + static llvm::Value *alloca(llvm::Type *type, SSAInt size); + static const std::string &hint(); + static void set_hint(const std::string &hint); + +private: + static SSAScope *instance; + llvm::LLVMContext *_context; + llvm::Module *_module; + llvm::IRBuilder<> *_builder; + std::string _hint; +}; + +class SSAScopeHint +{ +public: + SSAScopeHint() : old_hint(SSAScope::hint()) { } + SSAScopeHint(const std::string &hint) : old_hint(SSAScope::hint()) { SSAScope::set_hint(hint); } + ~SSAScopeHint() { SSAScope::set_hint(old_hint); } + void set(const std::string &hint) { SSAScope::set_hint(hint); } + void clear() { SSAScope::set_hint(old_hint); } + +private: + std::string old_hint; +}; diff --git a/src/r_compiler/ssa/ssa_stack.h b/src/r_compiler/ssa/ssa_stack.h new file mode 100644 index 000000000..435530be1 --- /dev/null +++ b/src/r_compiler/ssa/ssa_stack.h @@ -0,0 +1,25 @@ + +#pragma once + +template +class SSAStack +{ +public: + SSAStack() + : v(0) + { + v = SSAScope::alloca(SSAVariable::llvm_type()); + } + + SSAVariable load() const + { + return SSAVariable::from_llvm(SSAScope::builder().CreateLoad(v, SSAScope::hint())); + } + + void store(const SSAVariable &new_value) + { + SSAScope::builder().CreateStore(new_value.v, v); + } + + llvm::Value *v; +}; diff --git a/src/r_compiler/ssa/ssa_struct_type.cpp b/src/r_compiler/ssa/ssa_struct_type.cpp new file mode 100644 index 000000000..4a79768ce --- /dev/null +++ b/src/r_compiler/ssa/ssa_struct_type.cpp @@ -0,0 +1,18 @@ + +#include "ssa_struct_type.h" +#include "ssa_scope.h" + +void SSAStructType::add_parameter(llvm::Type *type) +{ + elements.push_back(type); +} + +llvm::Type *SSAStructType::llvm_type() +{ + return llvm::StructType::get(SSAScope::context(), elements, false); +} + +llvm::Type *SSAStructType::llvm_type_packed() +{ + return llvm::StructType::get(SSAScope::context(), elements, true); +} diff --git a/src/r_compiler/ssa/ssa_struct_type.h b/src/r_compiler/ssa/ssa_struct_type.h new file mode 100644 index 000000000..67b056b32 --- /dev/null +++ b/src/r_compiler/ssa/ssa_struct_type.h @@ -0,0 +1,17 @@ + +#pragma once + +#include + +namespace llvm { class Type; } + +class SSAStructType +{ +public: + void add_parameter(llvm::Type *type); + llvm::Type *llvm_type(); + llvm::Type *llvm_type_packed(); + +private: + std::vector elements; +}; diff --git a/src/r_compiler/ssa/ssa_ubyte.cpp b/src/r_compiler/ssa/ssa_ubyte.cpp new file mode 100644 index 000000000..04db4fd28 --- /dev/null +++ b/src/r_compiler/ssa/ssa_ubyte.cpp @@ -0,0 +1,95 @@ + +#include "ssa_ubyte.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSAUByte::SSAUByte() +: v(0) +{ +} + +SSAUByte::SSAUByte(unsigned char constant) +: v(0) +{ + v = llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant, false)); +} + +SSAUByte::SSAUByte(llvm::Value *v) +: v(v) +{ +} + +llvm::Type *SSAUByte::llvm_type() +{ + return llvm::Type::getInt8Ty(SSAScope::context()); +} + +SSAUByte operator+(const SSAUByte &a, const SSAUByte &b) +{ + return SSAUByte::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); +} + +SSAUByte operator-(const SSAUByte &a, const SSAUByte &b) +{ + return SSAUByte::from_llvm(SSAScope::builder().CreateSub(a.v, b.v, SSAScope::hint())); +} + +SSAUByte operator*(const SSAUByte &a, const SSAUByte &b) +{ + return SSAUByte::from_llvm(SSAScope::builder().CreateMul(a.v, b.v, SSAScope::hint())); +} +/* +SSAUByte operator/(const SSAUByte &a, const SSAUByte &b) +{ + return SSAScope::builder().CreateDiv(a.v, b.v); +} +*/ +SSAUByte operator+(unsigned char a, const SSAUByte &b) +{ + return SSAUByte(a) + b; +} + +SSAUByte operator-(unsigned char a, const SSAUByte &b) +{ + return SSAUByte(a) - b; +} + +SSAUByte operator*(unsigned char a, const SSAUByte &b) +{ + return SSAUByte(a) * b; +} +/* +SSAUByte operator/(unsigned char a, const SSAUByte &b) +{ + return SSAUByte(a) / b; +} +*/ +SSAUByte operator+(const SSAUByte &a, unsigned char b) +{ + return a + SSAUByte(b); +} + +SSAUByte operator-(const SSAUByte &a, unsigned char b) +{ + return a - SSAUByte(b); +} + +SSAUByte operator*(const SSAUByte &a, unsigned char b) +{ + return a * SSAUByte(b); +} +/* +SSAUByte operator/(const SSAUByte &a, unsigned char b) +{ + return a / SSAUByte(b); +} +*/ +SSAUByte operator<<(const SSAUByte &a, unsigned char bits) +{ + return SSAUByte::from_llvm(SSAScope::builder().CreateShl(a.v, bits)); +} + +SSAUByte operator>>(const SSAUByte &a, unsigned char bits) +{ + return SSAUByte::from_llvm(SSAScope::builder().CreateLShr(a.v, bits)); +} diff --git a/src/r_compiler/ssa/ssa_ubyte.h b/src/r_compiler/ssa/ssa_ubyte.h new file mode 100644 index 000000000..f1e12afba --- /dev/null +++ b/src/r_compiler/ssa/ssa_ubyte.h @@ -0,0 +1,35 @@ + +#pragma once + +namespace llvm { class Value; } +namespace llvm { class Type; } + +class SSAUByte +{ +public: + SSAUByte(); + SSAUByte(unsigned char constant); + explicit SSAUByte(llvm::Value *v); + static SSAUByte from_llvm(llvm::Value *v) { return SSAUByte(v); } + static llvm::Type *llvm_type(); + + llvm::Value *v; +}; + +SSAUByte operator+(const SSAUByte &a, const SSAUByte &b); +SSAUByte operator-(const SSAUByte &a, const SSAUByte &b); +SSAUByte operator*(const SSAUByte &a, const SSAUByte &b); +//SSAUByte operator/(const SSAUByte &a, const SSAUByte &b); + +SSAUByte operator+(unsigned char a, const SSAUByte &b); +SSAUByte operator-(unsigned char a, const SSAUByte &b); +SSAUByte operator*(unsigned char a, const SSAUByte &b); +//SSAUByte operator/(unsigned char a, const SSAUByte &b); + +SSAUByte operator+(const SSAUByte &a, unsigned char b); +SSAUByte operator-(const SSAUByte &a, unsigned char b); +SSAUByte operator*(const SSAUByte &a, unsigned char b); +//SSAUByte operator/(const SSAUByte &a, unsigned char b); + +SSAUByte operator<<(const SSAUByte &a, unsigned char bits); +SSAUByte operator>>(const SSAUByte &a, unsigned char bits); diff --git a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp new file mode 100644 index 000000000..825806148 --- /dev/null +++ b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp @@ -0,0 +1,106 @@ + +#include "ssa_ubyte_ptr.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSAUBytePtr::SSAUBytePtr() +: v(0) +{ +} + +SSAUBytePtr::SSAUBytePtr(llvm::Value *v) +: v(v) +{ +} + +llvm::Type *SSAUBytePtr::llvm_type() +{ + return llvm::Type::getInt8PtrTy(SSAScope::context()); +} + +SSAUBytePtr SSAUBytePtr::operator[](SSAInt index) const +{ + return SSAUBytePtr::from_llvm(SSAScope::builder().CreateGEP(v, index.v, SSAScope::hint())); +} + +SSAUByte SSAUBytePtr::load() const +{ + return SSAUByte::from_llvm(SSAScope::builder().CreateLoad(v, false, SSAScope::hint())); +} + +SSAVec4i SSAUBytePtr::load_vec4ub() const +{ + // _mm_cvtsi32_si128 as implemented by clang: + SSAInt i32 = SSAInt::from_llvm(SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, llvm::Type::getInt32PtrTy(SSAScope::context()), SSAScope::hint()), false, SSAScope::hint())); + llvm::Value *v = SSAScope::builder().CreateInsertElement(llvm::UndefValue::get(SSAVec4i::llvm_type()), i32.v, SSAInt(0).v, SSAScope::hint()); + v = SSAScope::builder().CreateInsertElement(v, SSAInt(0).v, SSAInt(1).v, SSAScope::hint()); + v = SSAScope::builder().CreateInsertElement(v, SSAInt(0).v, SSAInt(2).v, SSAScope::hint()); + v = SSAScope::builder().CreateInsertElement(v, SSAInt(0).v, SSAInt(3).v, SSAScope::hint()); + SSAVec4i v4i = SSAVec4i::from_llvm(v); + + SSAVec8s low = SSAVec8s::bitcast(SSAVec16ub::shuffle(SSAVec16ub::bitcast(v4i), 0, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7)); // _mm_unpacklo_epi8 + return SSAVec4i::extendlo(low); // _mm_unpacklo_epi16 +/* + llvm::PointerType *m4xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 4)->getPointerTo(); + llvm::Type *m4xint32type = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4); + llvm::Value *v4ub = SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, m4xint8typeptr, SSAScope::hint()), false, SSAScope::hint()); + return SSAVec4i::from_llvm(SSAScope::builder().CreateZExt(v4ub, m4xint32type)); +*/ +} + +SSAVec16ub SSAUBytePtr::load_vec16ub() const +{ + llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); + return SSAVec16ub::from_llvm(SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), false, SSAScope::hint())); +} + +SSAVec16ub SSAUBytePtr::load_unaligned_vec16ub() const +{ + llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); + return SSAVec16ub::from_llvm(SSAScope::builder().Insert(new llvm::LoadInst(SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), SSAScope::hint(), false, 4), SSAScope::hint())); +} + +void SSAUBytePtr::store(const SSAUByte &new_value) +{ + SSAScope::builder().CreateStore(new_value.v, v, false); +} + +void SSAUBytePtr::store_vec4ub(const SSAVec4i &new_value) +{ + // Store using saturate: + SSAVec8s v8s(new_value, new_value); + SSAVec16ub v16ub(v8s, v8s); + + llvm::Type *m16xint8type = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16); + llvm::PointerType *m4xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 4)->getPointerTo(); + std::vector constants; + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 0))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 1))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 2))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 3))); + llvm::Value *mask = llvm::ConstantVector::get(constants); + llvm::Value *val_vector = SSAScope::builder().CreateShuffleVector(v16ub.v, llvm::UndefValue::get(m16xint8type), mask, SSAScope::hint()); + SSAScope::builder().CreateStore(val_vector, SSAScope::builder().CreateBitCast(v, m4xint8typeptr, SSAScope::hint()), false); +} + +void SSAUBytePtr::store_vec16ub(const SSAVec16ub &new_value) +{ + llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); + llvm::StoreInst *inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), 16); + + // The following generates _mm_stream_si128, maybe! + // llvm::MDNode *node = llvm::MDNode::get(SSAScope::context(), SSAScope::builder().getInt32(1)); + // inst->setMetadata(SSAScope::module()->getMDKindID("nontemporal"), node); +} + +void SSAUBytePtr::store_unaligned_vec16ub(const SSAVec16ub &new_value) +{ + /*llvm::Value *values[2] = + { + SSAScope::builder().CreateBitCast(v, llvm::Type::getInt8PtrTy(SSAScope::context())), + new_value.v + }; + SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_storeu_dq), values);*/ + llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); + llvm::StoreInst *inst = SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint())); +} diff --git a/src/r_compiler/ssa/ssa_ubyte_ptr.h b/src/r_compiler/ssa/ssa_ubyte_ptr.h new file mode 100644 index 000000000..5b68ee1ad --- /dev/null +++ b/src/r_compiler/ssa/ssa_ubyte_ptr.h @@ -0,0 +1,32 @@ + +#pragma once + +#include "ssa_ubyte.h" +#include "ssa_int.h" +#include "ssa_vec4i.h" +#include "ssa_vec8s.h" +#include "ssa_vec16ub.h" + +namespace llvm { class Value; } +namespace llvm { class Type; } + +class SSAUBytePtr +{ +public: + SSAUBytePtr(); + explicit SSAUBytePtr(llvm::Value *v); + static SSAUBytePtr from_llvm(llvm::Value *v) { return SSAUBytePtr(v); } + static llvm::Type *llvm_type(); + SSAUBytePtr operator[](SSAInt index) const; + SSAUByte load() const; + SSAVec4i load_vec4ub() const; + SSAVec8s load_vec8s() const; + SSAVec16ub load_vec16ub() const; + SSAVec16ub load_unaligned_vec16ub() const; + void store(const SSAUByte &new_value); + void store_vec4ub(const SSAVec4i &new_value); + void store_vec16ub(const SSAVec16ub &new_value); + void store_unaligned_vec16ub(const SSAVec16ub &new_value); + + llvm::Value *v; +}; diff --git a/src/r_compiler/ssa/ssa_value.cpp b/src/r_compiler/ssa/ssa_value.cpp new file mode 100644 index 000000000..877420fc5 --- /dev/null +++ b/src/r_compiler/ssa/ssa_value.cpp @@ -0,0 +1,56 @@ + +#include "ssa_value.h" +#include "ssa_int.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSAValue SSAValue::load() +{ + return SSAValue::from_llvm(SSAScope::builder().CreateLoad(v, false)); +} + +void SSAValue::store(llvm::Value *value) +{ + SSAScope::builder().CreateStore(value, v, false); +} + +SSAIndexLookup SSAValue::operator[](int index) +{ + SSAIndexLookup result; + result.v = v; + result.indexes.push_back(SSAInt(index).v); + return result; +} + +SSAIndexLookup SSAValue::operator[](SSAInt index) +{ + SSAIndexLookup result; + result.v = v; + result.indexes.push_back(index.v); + return result; +} + +///////////////////////////////////////////////////////////////////////////// + +SSAIndexLookup::operator SSAValue() +{ + return SSAValue::from_llvm(SSAScope::builder().CreateGEP(v, indexes)); +} + +SSAIndexLookup SSAIndexLookup::operator[](int index) +{ + SSAIndexLookup result; + result.v = v; + result.indexes = indexes; + result.indexes.push_back(SSAInt(index).v); + return result; +} + +SSAIndexLookup SSAIndexLookup::operator[](SSAInt index) +{ + SSAIndexLookup result; + result.v = v; + result.indexes = indexes; + result.indexes.push_back(index.v); + return result; +} diff --git a/src/r_compiler/ssa/ssa_value.h b/src/r_compiler/ssa/ssa_value.h new file mode 100644 index 000000000..ec156a452 --- /dev/null +++ b/src/r_compiler/ssa/ssa_value.h @@ -0,0 +1,53 @@ + +#pragma once + +#include + +namespace llvm { class Value; } + +class SSAInt; +class SSAIndexLookup; + +class SSAValue +{ +public: + SSAValue() : v(0) { } + + static SSAValue from_llvm(llvm::Value *v) { SSAValue val; val.v = v; return val; } + + SSAValue load(); + void store(llvm::Value *v); + + template + operator Type() + { + return Type::from_llvm(v); + } + + SSAIndexLookup operator[](int index); + SSAIndexLookup operator[](SSAInt index); + + llvm::Value *v; +}; + +class SSAIndexLookup +{ +public: + SSAIndexLookup() : v(0) { } + + llvm::Value *v; + std::vector indexes; + + SSAValue load() { SSAValue value = *this; return value.load(); } + void store(llvm::Value *v) { SSAValue value = *this; return value.store(v); } + + template + operator Type() + { + return Type::from_llvm(v); + } + + operator SSAValue(); + SSAIndexLookup operator[](int index); + SSAIndexLookup operator[](SSAInt index); +}; diff --git a/src/r_compiler/ssa/ssa_vec16ub.cpp b/src/r_compiler/ssa/ssa_vec16ub.cpp new file mode 100644 index 000000000..f18d68718 --- /dev/null +++ b/src/r_compiler/ssa/ssa_vec16ub.cpp @@ -0,0 +1,155 @@ + +#include "ssa_vec16ub.h" +#include "ssa_vec8s.h" +#include "ssa_vec4i.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSAVec16ub::SSAVec16ub() +: v(0) +{ +} + +SSAVec16ub::SSAVec16ub(unsigned char constant) +: v(0) +{ + std::vector constants; + constants.resize(16, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant, false))); + v = llvm::ConstantVector::get(constants); +} + +SSAVec16ub::SSAVec16ub( + unsigned char constant0, unsigned char constant1, unsigned char constant2, unsigned char constant3, unsigned char constant4, unsigned char constant5, unsigned char constant6, unsigned char constant7, + unsigned char constant8, unsigned char constant9, unsigned char constant10, unsigned char constant11, unsigned char constant12, unsigned char constant13, unsigned char constant14, unsigned char constant15) +: v(0) +{ + std::vector constants; + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant0, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant1, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant2, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant3, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant4, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant5, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant6, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant7, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant8, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant9, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant10, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant11, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant12, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant13, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant14, false))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(8, constant15, false))); + v = llvm::ConstantVector::get(constants); +} + +SSAVec16ub::SSAVec16ub(llvm::Value *v) +: v(v) +{ +} + +SSAVec16ub::SSAVec16ub(SSAVec8s s0, SSAVec8s s1) +: v(0) +{ + llvm::Value *values[2] = { s0.v, s1.v }; + v = SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_packuswb_128), values, SSAScope::hint()); +} + +llvm::Type *SSAVec16ub::llvm_type() +{ + return llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16); +} + +SSAVec16ub SSAVec16ub::bitcast(SSAVec4i i32) +{ + return SSAVec16ub::from_llvm(SSAScope::builder().CreateBitCast(i32.v, llvm_type(), SSAScope::hint())); +} + +SSAVec16ub SSAVec16ub::shuffle(const SSAVec16ub &i0, int index0, int index1, int index2, int index3, int index4, int index5, int index6, int index7, int index8, int index9, int index10, int index11, int index12, int index13, int index14, int index15) +{ + return shuffle(i0, from_llvm(llvm::UndefValue::get(llvm_type())), index0, index1, index2, index3, index4, index5, index6, index7, index8, index9, index10, index11, index12, index13, index14, index15); +} + +SSAVec16ub SSAVec16ub::shuffle(const SSAVec16ub &i0, const SSAVec16ub &i1, int index0, int index1, int index2, int index3, int index4, int index5, int index6, int index7, int index8, int index9, int index10, int index11, int index12, int index13, int index14, int index15) +{ + std::vector constants; + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index0))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index1))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index2))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index3))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index4))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index5))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index6))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index7))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index8))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index9))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index10))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index11))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index12))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index13))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index14))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index15))); + llvm::Value *mask = llvm::ConstantVector::get(constants); + return SSAVec16ub::from_llvm(SSAScope::builder().CreateShuffleVector(i0.v, i1.v, mask, SSAScope::hint())); +} + +SSAVec16ub operator+(const SSAVec16ub &a, const SSAVec16ub &b) +{ + return SSAVec16ub::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); +} + +SSAVec16ub operator-(const SSAVec16ub &a, const SSAVec16ub &b) +{ + return SSAVec16ub::from_llvm(SSAScope::builder().CreateSub(a.v, b.v, SSAScope::hint())); +} + +SSAVec16ub operator*(const SSAVec16ub &a, const SSAVec16ub &b) +{ + return SSAVec16ub::from_llvm(SSAScope::builder().CreateMul(a.v, b.v, SSAScope::hint())); +} +/* +SSAVec16ub operator/(const SSAVec16ub &a, const SSAVec16ub &b) +{ + return SSAScope::builder().CreateDiv(a.v, b.v, SSAScope::hint()); +} +*/ +SSAVec16ub operator+(unsigned char a, const SSAVec16ub &b) +{ + return SSAVec16ub(a) + b; +} + +SSAVec16ub operator-(unsigned char a, const SSAVec16ub &b) +{ + return SSAVec16ub(a) - b; +} + +SSAVec16ub operator*(unsigned char a, const SSAVec16ub &b) +{ + return SSAVec16ub(a) * b; +} +/* +SSAVec16ub operator/(unsigned char a, const SSAVec16ub &b) +{ + return SSAVec16ub(a) / b; +} +*/ +SSAVec16ub operator+(const SSAVec16ub &a, unsigned char b) +{ + return a + SSAVec16ub(b); +} + +SSAVec16ub operator-(const SSAVec16ub &a, unsigned char b) +{ + return a - SSAVec16ub(b); +} + +SSAVec16ub operator*(const SSAVec16ub &a, unsigned char b) +{ + return a * SSAVec16ub(b); +} +/* +SSAVec16ub operator/(const SSAVec16ub &a, unsigned char b) +{ + return a / SSAVec16ub(b); +} +*/ \ No newline at end of file diff --git a/src/r_compiler/ssa/ssa_vec16ub.h b/src/r_compiler/ssa/ssa_vec16ub.h new file mode 100644 index 000000000..e4cfcdc87 --- /dev/null +++ b/src/r_compiler/ssa/ssa_vec16ub.h @@ -0,0 +1,42 @@ + +#pragma once + +namespace llvm { class Value; } +namespace llvm { class Type; } + +class SSAVec8s; +class SSAVec4i; + +class SSAVec16ub +{ +public: + SSAVec16ub(); + SSAVec16ub(unsigned char constant); + SSAVec16ub( + unsigned char constant0, unsigned char constant1, unsigned char constant2, unsigned char constant3, unsigned char constant4, unsigned char constant5, unsigned char constant6, unsigned char constant7, + unsigned char constant8, unsigned char constant9, unsigned char constant10, unsigned char constant11, unsigned char constant12, unsigned char constant13, unsigned char constant14, unsigned char constant15); + explicit SSAVec16ub(llvm::Value *v); + SSAVec16ub(SSAVec8s s0, SSAVec8s s1); + static SSAVec16ub from_llvm(llvm::Value *v) { return SSAVec16ub(v); } + static llvm::Type *llvm_type(); + static SSAVec16ub bitcast(SSAVec4i i32); + static SSAVec16ub shuffle(const SSAVec16ub &i0, int index0, int index1, int index2, int index3, int index4, int index5, int index6, int index7, int index8, int index9, int index10, int index11, int index12, int index13, int index14, int index15); + static SSAVec16ub shuffle(const SSAVec16ub &i0, const SSAVec16ub &i1, int index0, int index1, int index2, int index3, int index4, int index5, int index6, int index7, int index8, int index9, int index10, int index11, int index12, int index13, int index14, int index15); + + llvm::Value *v; +}; + +SSAVec16ub operator+(const SSAVec16ub &a, const SSAVec16ub &b); +SSAVec16ub operator-(const SSAVec16ub &a, const SSAVec16ub &b); +SSAVec16ub operator*(const SSAVec16ub &a, const SSAVec16ub &b); +SSAVec16ub operator/(const SSAVec16ub &a, const SSAVec16ub &b); + +SSAVec16ub operator+(unsigned char a, const SSAVec16ub &b); +SSAVec16ub operator-(unsigned char a, const SSAVec16ub &b); +SSAVec16ub operator*(unsigned char a, const SSAVec16ub &b); +SSAVec16ub operator/(unsigned char a, const SSAVec16ub &b); + +SSAVec16ub operator+(const SSAVec16ub &a, unsigned char b); +SSAVec16ub operator-(const SSAVec16ub &a, unsigned char b); +SSAVec16ub operator*(const SSAVec16ub &a, unsigned char b); +SSAVec16ub operator/(const SSAVec16ub &a, unsigned char b); diff --git a/src/r_compiler/ssa/ssa_vec4f.cpp b/src/r_compiler/ssa/ssa_vec4f.cpp new file mode 100644 index 000000000..e002018fe --- /dev/null +++ b/src/r_compiler/ssa/ssa_vec4f.cpp @@ -0,0 +1,244 @@ + +#include "ssa_vec4f.h" +#include "ssa_vec4i.h" +#include "ssa_float.h" +#include "ssa_int.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSAVec4f::SSAVec4f() +: v(0) +{ +} + +SSAVec4f::SSAVec4f(float constant) +: v(0) +{ + std::vector constants; + constants.resize(4, llvm::ConstantFP::get(SSAScope::context(), llvm::APFloat(constant))); + v = llvm::ConstantVector::get(constants); +} + +SSAVec4f::SSAVec4f(float constant0, float constant1, float constant2, float constant3) +: v(0) +{ + std::vector constants; + constants.push_back(llvm::ConstantFP::get(SSAScope::context(), llvm::APFloat(constant0))); + constants.push_back(llvm::ConstantFP::get(SSAScope::context(), llvm::APFloat(constant1))); + constants.push_back(llvm::ConstantFP::get(SSAScope::context(), llvm::APFloat(constant2))); + constants.push_back(llvm::ConstantFP::get(SSAScope::context(), llvm::APFloat(constant3))); + v = llvm::ConstantVector::get(constants); +} + +SSAVec4f::SSAVec4f(SSAFloat f) +: v(0) +{ + llvm::Type *m1xfloattype = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 1); + std::vector constants; + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 0))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 0))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 0))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 0))); + llvm::Value *mask = llvm::ConstantVector::get(constants); + v = SSAScope::builder().CreateShuffleVector(SSAScope::builder().CreateBitCast(f.v, m1xfloattype, SSAScope::hint()), llvm::UndefValue::get(m1xfloattype), mask, SSAScope::hint()); +} + +SSAVec4f::SSAVec4f(SSAFloat f0, SSAFloat f1, SSAFloat f2, SSAFloat f3) +: v(0) +{ + v = SSAScope::builder().CreateInsertElement(llvm::UndefValue::get(llvm_type()), f0.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); + v = SSAScope::builder().CreateInsertElement(v, f1.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)1))); + v = SSAScope::builder().CreateInsertElement(v, f2.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)2))); + v = SSAScope::builder().CreateInsertElement(v, f3.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)3))); +} + +SSAVec4f::SSAVec4f(llvm::Value *v) +: v(v) +{ +} + +SSAVec4f::SSAVec4f(SSAVec4i i32) +: v(0) +{ + //llvm::VectorType *m128type = llvm::VectorType::get(llvm::Type::getFloatTy(*context), 4); + //return builder->CreateSIToFP(i32.v, m128type); + v = SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_cvtdq2ps), i32.v, SSAScope::hint()); +} + +llvm::Type *SSAVec4f::llvm_type() +{ + return llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4); +} + +SSAFloat SSAVec4f::operator[](SSAInt index) const +{ + return SSAFloat::from_llvm(SSAScope::builder().CreateExtractElement(v, index.v, SSAScope::hint())); +} + +SSAVec4f SSAVec4f::insert_element(SSAVec4f vec4f, SSAFloat value, int index) +{ + return from_llvm(SSAScope::builder().CreateInsertElement(vec4f.v, value.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)index)))); +} + +SSAVec4f SSAVec4f::bitcast(SSAVec4i i32) +{ + return SSAVec4i::from_llvm(SSAScope::builder().CreateBitCast(i32.v, llvm_type(), SSAScope::hint())); +} + +SSAVec4f SSAVec4f::sqrt(SSAVec4f f) +{ + std::vector params; + params.push_back(SSAVec4f::llvm_type()); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::sqrt, params), f.v, SSAScope::hint())); + //return SSAVec4f::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse_sqrt_ps), f.v, SSAScope::hint())); +} + +SSAVec4f SSAVec4f::rcp(SSAVec4f f) +{ + return SSAVec4f::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse_rcp_ps), f.v, SSAScope::hint())); +} + +SSAVec4f SSAVec4f::sin(SSAVec4f val) +{ + std::vector params; + params.push_back(SSAVec4f::llvm_type()); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::sin, params), val.v, SSAScope::hint())); +} + +SSAVec4f SSAVec4f::cos(SSAVec4f val) +{ + std::vector params; + params.push_back(SSAVec4f::llvm_type()); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::cos, params), val.v, SSAScope::hint())); +} + +SSAVec4f SSAVec4f::pow(SSAVec4f val, SSAVec4f power) +{ + std::vector params; + params.push_back(SSAVec4f::llvm_type()); + //params.push_back(SSAVec4f::llvm_type()); + std::vector args; + args.push_back(val.v); + args.push_back(power.v); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::pow, params), args, SSAScope::hint())); +} + +SSAVec4f SSAVec4f::exp(SSAVec4f val) +{ + std::vector params; + params.push_back(SSAVec4f::llvm_type()); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::exp, params), val.v, SSAScope::hint())); +} + +SSAVec4f SSAVec4f::log(SSAVec4f val) +{ + std::vector params; + params.push_back(SSAVec4f::llvm_type()); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::log, params), val.v, SSAScope::hint())); +} + +SSAVec4f SSAVec4f::fma(SSAVec4f a, SSAVec4f b, SSAVec4f c) +{ + std::vector params; + params.push_back(SSAVec4f::llvm_type()); + //params.push_back(SSAVec4f::llvm_type()); + //params.push_back(SSAVec4f::llvm_type()); + std::vector args; + args.push_back(a.v); + args.push_back(b.v); + args.push_back(c.v); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::fma, params), args, SSAScope::hint())); +} + +void SSAVec4f::transpose(SSAVec4f &row0, SSAVec4f &row1, SSAVec4f &row2, SSAVec4f &row3) +{ + SSAVec4f tmp0 = shuffle(row0, row1, 0x44);//_MM_SHUFFLE(1,0,1,0)); + SSAVec4f tmp2 = shuffle(row0, row1, 0xEE);//_MM_SHUFFLE(3,2,3,2)); + SSAVec4f tmp1 = shuffle(row2, row3, 0x44);//_MM_SHUFFLE(1,0,1,0)); + SSAVec4f tmp3 = shuffle(row2, row3, 0xEE);//_MM_SHUFFLE(3,2,3,2)); + row0 = shuffle(tmp0, tmp1, 0x88);//_MM_SHUFFLE(2,0,2,0)); + row1 = shuffle(tmp0, tmp1, 0xDD);//_MM_SHUFFLE(3,1,3,1)); + row2 = shuffle(tmp2, tmp3, 0x88);//_MM_SHUFFLE(2,0,2,0)); + row3 = shuffle(tmp2, tmp3, 0xDD);//_MM_SHUFFLE(3,1,3,1)); +} + +SSAVec4f SSAVec4f::shuffle(const SSAVec4f &f0, int index0, int index1, int index2, int index3) +{ + return shuffle(f0, from_llvm(llvm::UndefValue::get(llvm_type())), index0, index1, index2, index3); +} + +SSAVec4f SSAVec4f::shuffle(const SSAVec4f &f0, const SSAVec4f &f1, int index0, int index1, int index2, int index3) +{ + std::vector constants; + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index0))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index1))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index2))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index3))); + llvm::Value *mask = llvm::ConstantVector::get(constants); + return SSAVec4f::from_llvm(SSAScope::builder().CreateShuffleVector(f0.v, f1.v, mask, SSAScope::hint())); +} + +SSAVec4f SSAVec4f::shuffle(const SSAVec4f &f0, const SSAVec4f &f1, int mask) +{ + return shuffle(f0, f1, mask & 3, (mask >> 2) & 3, ((mask >> 4) & 3) + 4, ((mask >> 6) & 3) + 4); +} + +SSAVec4f operator+(const SSAVec4f &a, const SSAVec4f &b) +{ + return SSAVec4f::from_llvm(SSAScope::builder().CreateFAdd(a.v, b.v, SSAScope::hint())); +} + +SSAVec4f operator-(const SSAVec4f &a, const SSAVec4f &b) +{ + return SSAVec4f::from_llvm(SSAScope::builder().CreateFSub(a.v, b.v, SSAScope::hint())); +} + +SSAVec4f operator*(const SSAVec4f &a, const SSAVec4f &b) +{ + return SSAVec4f::from_llvm(SSAScope::builder().CreateFMul(a.v, b.v, SSAScope::hint())); +} + +SSAVec4f operator/(const SSAVec4f &a, const SSAVec4f &b) +{ + return SSAVec4f::from_llvm(SSAScope::builder().CreateFDiv(a.v, b.v, SSAScope::hint())); +} + +SSAVec4f operator+(float a, const SSAVec4f &b) +{ + return SSAVec4f(a) + b; +} + +SSAVec4f operator-(float a, const SSAVec4f &b) +{ + return SSAVec4f(a) - b; +} + +SSAVec4f operator*(float a, const SSAVec4f &b) +{ + return SSAVec4f(a) * b; +} + +SSAVec4f operator/(float a, const SSAVec4f &b) +{ + return SSAVec4f(a) / b; +} + +SSAVec4f operator+(const SSAVec4f &a, float b) +{ + return a + SSAVec4f(b); +} + +SSAVec4f operator-(const SSAVec4f &a, float b) +{ + return a - SSAVec4f(b); +} + +SSAVec4f operator*(const SSAVec4f &a, float b) +{ + return a * SSAVec4f(b); +} + +SSAVec4f operator/(const SSAVec4f &a, float b) +{ + return a / SSAVec4f(b); +} diff --git a/src/r_compiler/ssa/ssa_vec4f.h b/src/r_compiler/ssa/ssa_vec4f.h new file mode 100644 index 000000000..5e3397e58 --- /dev/null +++ b/src/r_compiler/ssa/ssa_vec4f.h @@ -0,0 +1,57 @@ + +#pragma once + +namespace llvm { class Value; } +namespace llvm { class Type; } + +class SSAVec4i; +class SSAFloat; +class SSAInt; + +class SSAVec4f +{ +public: + SSAVec4f(); + SSAVec4f(float constant); + SSAVec4f(float constant0, float constant1, float constant2, float constant3); + SSAVec4f(SSAFloat f); + SSAVec4f(SSAFloat f0, SSAFloat f1, SSAFloat f2, SSAFloat f3); + explicit SSAVec4f(llvm::Value *v); + SSAVec4f(SSAVec4i i32); + SSAFloat operator[](SSAInt index) const; + static SSAVec4f insert_element(SSAVec4f vec4f, SSAFloat value, int index); + static SSAVec4f bitcast(SSAVec4i i32); + static SSAVec4f sqrt(SSAVec4f f); + static SSAVec4f rcp(SSAVec4f f); + static SSAVec4f sin(SSAVec4f val); + static SSAVec4f cos(SSAVec4f val); + static SSAVec4f pow(SSAVec4f val, SSAVec4f power); + static SSAVec4f exp(SSAVec4f val); + static SSAVec4f log(SSAVec4f val); + static SSAVec4f fma(SSAVec4f a, SSAVec4f b, SSAVec4f c); + static void transpose(SSAVec4f &row0, SSAVec4f &row1, SSAVec4f &row2, SSAVec4f &row3); + static SSAVec4f shuffle(const SSAVec4f &f0, int index0, int index1, int index2, int index3); + static SSAVec4f shuffle(const SSAVec4f &f0, const SSAVec4f &f1, int index0, int index1, int index2, int index3); + static SSAVec4f from_llvm(llvm::Value *v) { return SSAVec4f(v); } + static llvm::Type *llvm_type(); + + llvm::Value *v; + +private: + static SSAVec4f shuffle(const SSAVec4f &f0, const SSAVec4f &f1, int mask); +}; + +SSAVec4f operator+(const SSAVec4f &a, const SSAVec4f &b); +SSAVec4f operator-(const SSAVec4f &a, const SSAVec4f &b); +SSAVec4f operator*(const SSAVec4f &a, const SSAVec4f &b); +SSAVec4f operator/(const SSAVec4f &a, const SSAVec4f &b); + +SSAVec4f operator+(float a, const SSAVec4f &b); +SSAVec4f operator-(float a, const SSAVec4f &b); +SSAVec4f operator*(float a, const SSAVec4f &b); +SSAVec4f operator/(float a, const SSAVec4f &b); + +SSAVec4f operator+(const SSAVec4f &a, float b); +SSAVec4f operator-(const SSAVec4f &a, float b); +SSAVec4f operator*(const SSAVec4f &a, float b); +SSAVec4f operator/(const SSAVec4f &a, float b); diff --git a/src/r_compiler/ssa/ssa_vec4f_ptr.cpp b/src/r_compiler/ssa/ssa_vec4f_ptr.cpp new file mode 100644 index 000000000..e2df64167 --- /dev/null +++ b/src/r_compiler/ssa/ssa_vec4f_ptr.cpp @@ -0,0 +1,50 @@ + +#include "ssa_vec4f_ptr.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSAVec4fPtr::SSAVec4fPtr() +: v(0) +{ +} + +SSAVec4fPtr::SSAVec4fPtr(llvm::Value *v) +: v(v) +{ +} + +llvm::Type *SSAVec4fPtr::llvm_type() +{ + return llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); +} + +SSAVec4fPtr SSAVec4fPtr::operator[](SSAInt index) const +{ + return SSAVec4fPtr::from_llvm(SSAScope::builder().CreateGEP(v, index.v, SSAScope::hint())); +} + +SSAVec4f SSAVec4fPtr::load() const +{ + return SSAVec4f::from_llvm(SSAScope::builder().CreateLoad(v, false, SSAScope::hint())); +} + +SSAVec4f SSAVec4fPtr::load_unaligned() const +{ + return SSAVec4f::from_llvm(SSAScope::builder().Insert(new llvm::LoadInst(v, SSAScope::hint(), false, 4), SSAScope::hint())); +} + +void SSAVec4fPtr::store(const SSAVec4f &new_value) +{ + SSAScope::builder().CreateAlignedStore(new_value.v, v, 16, false); +} + +void SSAVec4fPtr::store_unaligned(const SSAVec4f &new_value) +{ + /*llvm::Value *values[2] = + { + SSAScope::builder().CreateBitCast(v, llvm::Type::getFloatPtrTy(SSAScope::context())), + new_value.v + }; + SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse_storeu_ps), values);*/ + SSAScope::builder().CreateStore(new_value.v, v, false); +} diff --git a/src/r_compiler/ssa/ssa_vec4f_ptr.h b/src/r_compiler/ssa/ssa_vec4f_ptr.h new file mode 100644 index 000000000..ab4e84190 --- /dev/null +++ b/src/r_compiler/ssa/ssa_vec4f_ptr.h @@ -0,0 +1,24 @@ + +#pragma once + +#include "ssa_int.h" +#include "ssa_vec4f.h" + +namespace llvm { class Value; } +namespace llvm { class Type; } + +class SSAVec4fPtr +{ +public: + SSAVec4fPtr(); + explicit SSAVec4fPtr(llvm::Value *v); + static SSAVec4fPtr from_llvm(llvm::Value *v) { return SSAVec4fPtr(v); } + static llvm::Type *llvm_type(); + SSAVec4fPtr operator[](SSAInt index) const; + SSAVec4f load() const; + SSAVec4f load_unaligned() const; + void store(const SSAVec4f &new_value); + void store_unaligned(const SSAVec4f &new_value); + + llvm::Value *v; +}; diff --git a/src/r_compiler/ssa/ssa_vec4i.cpp b/src/r_compiler/ssa/ssa_vec4i.cpp new file mode 100644 index 000000000..80e07c8d4 --- /dev/null +++ b/src/r_compiler/ssa/ssa_vec4i.cpp @@ -0,0 +1,213 @@ + +#include "ssa_vec4i.h" +#include "ssa_vec4f.h" +#include "ssa_vec8s.h" +#include "ssa_vec16ub.h" +#include "ssa_int.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSAVec4i::SSAVec4i() +: v(0) +{ +} + +SSAVec4i::SSAVec4i(int constant) +: v(0) +{ + std::vector constants; + constants.resize(4, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, constant, true))); + v = llvm::ConstantVector::get(constants); +} + +SSAVec4i::SSAVec4i(int constant0, int constant1, int constant2, int constant3) +: v(0) +{ + std::vector constants; + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, constant0, true))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, constant1, true))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, constant2, true))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, constant3, true))); + v = llvm::ConstantVector::get(constants); +} + +SSAVec4i::SSAVec4i(llvm::Value *v) +: v(v) +{ +} + +SSAVec4i::SSAVec4i(SSAInt i) +: v(0) +{ + llvm::Type *m1xi32type = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 1); + std::vector constants; + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 0))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 0))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 0))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 0))); + llvm::Value *mask = llvm::ConstantVector::get(constants); + v = SSAScope::builder().CreateShuffleVector(SSAScope::builder().CreateBitCast(i.v, m1xi32type, SSAScope::hint()), llvm::UndefValue::get(m1xi32type), mask, SSAScope::hint()); +} + +SSAVec4i::SSAVec4i(SSAVec4f f32) +: v(0) +{ + v = SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_cvttps2dq), f32.v, SSAScope::hint()); +} + +SSAInt SSAVec4i::operator[](SSAInt index) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateExtractElement(v, index.v, SSAScope::hint())); +} + +llvm::Type *SSAVec4i::llvm_type() +{ + return llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4); +} + +SSAVec4i SSAVec4i::bitcast(SSAVec4f f32) +{ + return SSAVec4i::from_llvm(SSAScope::builder().CreateBitCast(f32.v, llvm_type(), SSAScope::hint())); +} + +SSAVec4i SSAVec4i::bitcast(SSAVec8s i16) +{ + return SSAVec4i::from_llvm(SSAScope::builder().CreateBitCast(i16.v, llvm_type(), SSAScope::hint())); +} + +SSAVec4i SSAVec4i::shuffle(const SSAVec4i &i0, int index0, int index1, int index2, int index3) +{ + return shuffle(i0, from_llvm(llvm::UndefValue::get(llvm_type())), index0, index1, index2, index3); +} + +SSAVec4i SSAVec4i::shuffle(const SSAVec4i &i0, const SSAVec4i &i1, int index0, int index1, int index2, int index3) +{ + std::vector constants; + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index0))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index1))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index2))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index3))); + llvm::Value *mask = llvm::ConstantVector::get(constants); + return SSAVec4i::from_llvm(SSAScope::builder().CreateShuffleVector(i0.v, i1.v, mask, SSAScope::hint())); +} + +void SSAVec4i::extend(SSAVec16ub a, SSAVec4i &out0, SSAVec4i &out1, SSAVec4i &out2, SSAVec4i &out3) +{ + SSAVec8s low = SSAVec8s::extendlo(a); + SSAVec8s high = SSAVec8s::extendhi(a); + out0 = extendlo(low); + out1 = extendhi(low); + out2 = extendlo(high); + out3 = extendhi(high); +} + +SSAVec4i SSAVec4i::extendhi(SSAVec8s i16) +{ + return SSAVec4i::bitcast(SSAVec8s::shuffle(i16, 0, 4, 8+4, 5, 8+5, 6, 8+6, 7, 8+7)); // _mm_unpackhi_epi16 +} + +SSAVec4i SSAVec4i::extendlo(SSAVec8s i16) +{ + return SSAVec4i::bitcast(SSAVec8s::shuffle(i16, 0, 0, 8+0, 1, 8+1, 2, 8+2, 3, 8+3)); // _mm_unpacklo_epi16 +} + +SSAVec4i SSAVec4i::combinehi(SSAVec8s a, SSAVec8s b) +{ + return SSAVec4i::bitcast(SSAVec8s::shuffle(a, b, 4, 8+4, 5, 8+5, 6, 8+6, 7, 8+7)); // _mm_unpackhi_epi16 +} + +SSAVec4i SSAVec4i::combinelo(SSAVec8s a, SSAVec8s b) +{ + return SSAVec4i::bitcast(SSAVec8s::shuffle(a, b, 0, 8+0, 1, 8+1, 2, 8+2, 3, 8+3)); // _mm_unpacklo_epi16 +} + +SSAVec4i SSAVec4i::sqrt(SSAVec4i f) +{ + return SSAVec4i::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_sqrt_pd), f.v, SSAScope::hint())); +} + +/* +SSAVec4i SSAVec4i::min_sse41(SSAVec4i a, SSAVec4i b) +{ + llvm::Value *values[2] = { a.v, b.v }; + return SSAVec4i::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse41_pminsd), values, SSAScope::hint())); +} + +SSAVec4i SSAVec4i::max_sse41(SSAVec4i a, SSAVec4i b) +{ + llvm::Value *values[2] = { a.v, b.v }; + return SSAVec4i::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse41_pmaxsd), values, SSAScope::hint())); +} +*/ + +SSAVec4i operator+(const SSAVec4i &a, const SSAVec4i &b) +{ + return SSAVec4i::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); +} + +SSAVec4i operator-(const SSAVec4i &a, const SSAVec4i &b) +{ + return SSAVec4i::from_llvm(SSAScope::builder().CreateSub(a.v, b.v, SSAScope::hint())); +} + +SSAVec4i operator*(const SSAVec4i &a, const SSAVec4i &b) +{ + return SSAVec4i::from_llvm(SSAScope::builder().CreateMul(a.v, b.v, SSAScope::hint())); +} + +SSAVec4i operator/(const SSAVec4i &a, const SSAVec4i &b) +{ + return SSAVec4i::from_llvm(SSAScope::builder().CreateSDiv(a.v, b.v, SSAScope::hint())); +} + +SSAVec4i operator+(int a, const SSAVec4i &b) +{ + return SSAVec4i(a) + b; +} + +SSAVec4i operator-(int a, const SSAVec4i &b) +{ + return SSAVec4i(a) - b; +} + +SSAVec4i operator*(int a, const SSAVec4i &b) +{ + return SSAVec4i(a) * b; +} + +SSAVec4i operator/(int a, const SSAVec4i &b) +{ + return SSAVec4i(a) / b; +} + +SSAVec4i operator+(const SSAVec4i &a, int b) +{ + return a + SSAVec4i(b); +} + +SSAVec4i operator-(const SSAVec4i &a, int b) +{ + return a - SSAVec4i(b); +} + +SSAVec4i operator*(const SSAVec4i &a, int b) +{ + return a * SSAVec4i(b); +} + +SSAVec4i operator/(const SSAVec4i &a, int b) +{ + return a / SSAVec4i(b); +} + +SSAVec4i operator<<(const SSAVec4i &a, int bits) +{ + //return SSAScope::builder().CreateShl(a.v, bits); + llvm::Value *values[2] = { a.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)bits)) }; + return SSAVec4i::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pslli_d), values, SSAScope::hint())); +} + +SSAVec4i operator>>(const SSAVec4i &a, int bits) +{ + return SSAVec4i::from_llvm(SSAScope::builder().CreateLShr(a.v, bits, SSAScope::hint())); +} diff --git a/src/r_compiler/ssa/ssa_vec4i.h b/src/r_compiler/ssa/ssa_vec4i.h new file mode 100644 index 000000000..d19f1d1aa --- /dev/null +++ b/src/r_compiler/ssa/ssa_vec4i.h @@ -0,0 +1,56 @@ + +#pragma once + +namespace llvm { class Value; } +namespace llvm { class Type; } + +class SSAVec4f; +class SSAVec8s; +class SSAVec16ub; +class SSAInt; + +class SSAVec4i +{ +public: + SSAVec4i(); + SSAVec4i(int constant); + SSAVec4i(int constant0, int constant1, int constant2, int constant3); + SSAVec4i(SSAInt i); + explicit SSAVec4i(llvm::Value *v); + SSAVec4i(SSAVec4f f32); + SSAInt operator[](SSAInt index); + static SSAVec4i bitcast(SSAVec4f f32); + static SSAVec4i bitcast(SSAVec8s i16); + static SSAVec4i shuffle(const SSAVec4i &f0, int index0, int index1, int index2, int index3); + static SSAVec4i shuffle(const SSAVec4i &f0, const SSAVec4i &f1, int index0, int index1, int index2, int index3); + static SSAVec4i extendhi(SSAVec8s i16); + static SSAVec4i extendlo(SSAVec8s i16); + static void extend(SSAVec16ub a, SSAVec4i &out0, SSAVec4i &out1, SSAVec4i &out2, SSAVec4i &out3); + static SSAVec4i combinehi(SSAVec8s v0, SSAVec8s v1); + static SSAVec4i combinelo(SSAVec8s v0, SSAVec8s v1); + static SSAVec4i sqrt(SSAVec4i f); + //static SSAVec4i min_sse41(SSAVec4i a, SSAVec4i b); + //static SSAVec4i max_sse41(SSAVec4i a, SSAVec4i b); + static SSAVec4i from_llvm(llvm::Value *v) { return SSAVec4i(v); } + static llvm::Type *llvm_type(); + + llvm::Value *v; +}; + +SSAVec4i operator+(const SSAVec4i &a, const SSAVec4i &b); +SSAVec4i operator-(const SSAVec4i &a, const SSAVec4i &b); +SSAVec4i operator*(const SSAVec4i &a, const SSAVec4i &b); +SSAVec4i operator/(const SSAVec4i &a, const SSAVec4i &b); + +SSAVec4i operator+(int a, const SSAVec4i &b); +SSAVec4i operator-(int a, const SSAVec4i &b); +SSAVec4i operator*(int a, const SSAVec4i &b); +SSAVec4i operator/(int a, const SSAVec4i &b); + +SSAVec4i operator+(const SSAVec4i &a, int b); +SSAVec4i operator-(const SSAVec4i &a, int b); +SSAVec4i operator*(const SSAVec4i &a, int b); +SSAVec4i operator/(const SSAVec4i &a, int b); + +SSAVec4i operator<<(const SSAVec4i &a, int bits); +SSAVec4i operator>>(const SSAVec4i &a, int bits); diff --git a/src/r_compiler/ssa/ssa_vec4i_ptr.cpp b/src/r_compiler/ssa/ssa_vec4i_ptr.cpp new file mode 100644 index 000000000..a28befb70 --- /dev/null +++ b/src/r_compiler/ssa/ssa_vec4i_ptr.cpp @@ -0,0 +1,50 @@ + +#include "ssa_vec4i_ptr.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSAVec4iPtr::SSAVec4iPtr() +: v(0) +{ +} + +SSAVec4iPtr::SSAVec4iPtr(llvm::Value *v) +: v(v) +{ +} + +llvm::Type *SSAVec4iPtr::llvm_type() +{ + return llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); +} + +SSAVec4iPtr SSAVec4iPtr::operator[](SSAInt index) const +{ + return SSAVec4iPtr::from_llvm(SSAScope::builder().CreateGEP(v, index.v, SSAScope::hint())); +} + +SSAVec4i SSAVec4iPtr::load() const +{ + return SSAVec4i::from_llvm(SSAScope::builder().CreateLoad(v, false, SSAScope::hint())); +} + +SSAVec4i SSAVec4iPtr::load_unaligned() const +{ + return SSAVec4i::from_llvm(SSAScope::builder().Insert(new llvm::LoadInst(v, SSAScope::hint(), false, 4))); +} + +void SSAVec4iPtr::store(const SSAVec4i &new_value) +{ + SSAScope::builder().CreateAlignedStore(new_value.v, v, 16, false); +} + +void SSAVec4iPtr::store_unaligned(const SSAVec4i &new_value) +{ + /*llvm::Value *values[2] = + { + v, + new_value.v + }; + SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_storeu_pd), values);*/ + SSAScope::builder().CreateStore(new_value.v, v, false); +} diff --git a/src/r_compiler/ssa/ssa_vec4i_ptr.h b/src/r_compiler/ssa/ssa_vec4i_ptr.h new file mode 100644 index 000000000..56937b1cc --- /dev/null +++ b/src/r_compiler/ssa/ssa_vec4i_ptr.h @@ -0,0 +1,24 @@ + +#pragma once + +#include "ssa_int.h" +#include "ssa_vec4i.h" + +namespace llvm { class Value; } +namespace llvm { class Type; } + +class SSAVec4iPtr +{ +public: + SSAVec4iPtr(); + explicit SSAVec4iPtr(llvm::Value *v); + static SSAVec4iPtr from_llvm(llvm::Value *v) { return SSAVec4iPtr(v); } + static llvm::Type *llvm_type(); + SSAVec4iPtr operator[](SSAInt index) const; + SSAVec4i load() const; + SSAVec4i load_unaligned() const; + void store(const SSAVec4i &new_value); + void store_unaligned(const SSAVec4i &new_value); + + llvm::Value *v; +}; diff --git a/src/r_compiler/ssa/ssa_vec8s.cpp b/src/r_compiler/ssa/ssa_vec8s.cpp new file mode 100644 index 000000000..d61a4c4a9 --- /dev/null +++ b/src/r_compiler/ssa/ssa_vec8s.cpp @@ -0,0 +1,178 @@ + +#include "ssa_vec8s.h" +#include "ssa_vec4i.h" +#include "ssa_vec16ub.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSAVec8s::SSAVec8s() +: v(0) +{ +} + +SSAVec8s::SSAVec8s(short constant) +: v(0) +{ + std::vector constants; + constants.resize(8, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(16, constant, true))); + v = llvm::ConstantVector::get(constants); +} + +SSAVec8s::SSAVec8s(short constant0, short constant1, short constant2, short constant3, short constant4, short constant5, short constant6, short constant7) +: v(0) +{ + std::vector constants; + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(16, constant0, true))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(16, constant1, true))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(16, constant2, true))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(16, constant3, true))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(16, constant4, true))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(16, constant5, true))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(16, constant6, true))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(16, constant7, true))); + v = llvm::ConstantVector::get(constants); +} + +SSAVec8s::SSAVec8s(llvm::Value *v) +: v(v) +{ +} + +SSAVec8s::SSAVec8s(SSAVec4i i0, SSAVec4i i1) +: v(0) +{ + llvm::Value *values[2] = { i0.v, i1.v }; + v = SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_packssdw_128), values, SSAScope::hint()); +} + +llvm::Type *SSAVec8s::llvm_type() +{ + return llvm::VectorType::get(llvm::Type::getInt16Ty(SSAScope::context()), 8); +} + +SSAVec8s SSAVec8s::bitcast(SSAVec16ub i8) +{ + return SSAVec8s::from_llvm(SSAScope::builder().CreateBitCast(i8.v, llvm_type(), SSAScope::hint())); +} + +SSAVec8s SSAVec8s::shuffle(const SSAVec8s &i0, int index0, int index1, int index2, int index3, int index4, int index5, int index6, int index7) +{ + return shuffle(i0, from_llvm(llvm::UndefValue::get(llvm_type())), index0, index1, index2, index3, index4, index5, index6, index7); +} + +SSAVec8s SSAVec8s::shuffle(const SSAVec8s &i0, const SSAVec8s &i1, int index0, int index1, int index2, int index3, int index4, int index5, int index6, int index7) +{ + std::vector constants; + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index0))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index1))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index2))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index3))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index4))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index5))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index6))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, index7))); + llvm::Value *mask = llvm::ConstantVector::get(constants); + return SSAVec8s::from_llvm(SSAScope::builder().CreateShuffleVector(i0.v, i1.v, mask, SSAScope::hint())); +} + +SSAVec8s SSAVec8s::extendhi(SSAVec16ub a) +{ + return SSAVec8s::bitcast(SSAVec16ub::shuffle(a, 0, 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15)); // _mm_unpackhi_epi8 +} + +SSAVec8s SSAVec8s::extendlo(SSAVec16ub a) +{ + return SSAVec8s::bitcast(SSAVec16ub::shuffle(a, 0, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7)); // _mm_unpacklo_epi8 +} + +/* +SSAVec8s SSAVec8s::min_sse2(SSAVec8s a, SSAVec8s b) +{ + llvm::Value *values[2] = { a.v, b.v }; + return SSAVec8s::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pmins_w), values, SSAScope::hint())); +} + +SSAVec8s SSAVec8s::max_sse2(SSAVec8s a, SSAVec8s b) +{ + llvm::Value *values[2] = { a.v, b.v }; + return SSAVec8s::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pmaxs_w), values, SSAScope::hint())); +} +*/ + +SSAVec8s SSAVec8s::mulhi(SSAVec8s a, SSAVec8s b) +{ + llvm::Value *values[2] = { a.v, b.v }; + return SSAVec8s::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pmulh_w), values, SSAScope::hint())); +} + +SSAVec8s operator+(const SSAVec8s &a, const SSAVec8s &b) +{ + return SSAVec8s::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); +} + +SSAVec8s operator-(const SSAVec8s &a, const SSAVec8s &b) +{ + return SSAVec8s::from_llvm(SSAScope::builder().CreateSub(a.v, b.v, SSAScope::hint())); +} + +SSAVec8s operator*(const SSAVec8s &a, const SSAVec8s &b) +{ + return SSAVec8s::from_llvm(SSAScope::builder().CreateMul(a.v, b.v, SSAScope::hint())); +} + +SSAVec8s operator/(const SSAVec8s &a, const SSAVec8s &b) +{ + return SSAVec8s::from_llvm(SSAScope::builder().CreateSDiv(a.v, b.v, SSAScope::hint())); +} + +SSAVec8s operator+(short a, const SSAVec8s &b) +{ + return SSAVec8s(a) + b; +} + +SSAVec8s operator-(short a, const SSAVec8s &b) +{ + return SSAVec8s(a) - b; +} + +SSAVec8s operator*(short a, const SSAVec8s &b) +{ + return SSAVec8s(a) * b; +} + +SSAVec8s operator/(short a, const SSAVec8s &b) +{ + return SSAVec8s(a) / b; +} + +SSAVec8s operator+(const SSAVec8s &a, short b) +{ + return a + SSAVec8s(b); +} + +SSAVec8s operator-(const SSAVec8s &a, short b) +{ + return a - SSAVec8s(b); +} + +SSAVec8s operator*(const SSAVec8s &a, short b) +{ + return a * SSAVec8s(b); +} + +SSAVec8s operator/(const SSAVec8s &a, short b) +{ + return a / SSAVec8s(b); +} + +SSAVec8s operator<<(const SSAVec8s &a, int bits) +{ + //return SSAScope::builder().CreateShl(a.v, bits); + llvm::Value *values[2] = { a.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)bits)) }; + return SSAVec8s::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pslli_d), values, SSAScope::hint())); +} + +SSAVec8s operator>>(const SSAVec8s &a, int bits) +{ + return SSAVec8s::from_llvm(SSAScope::builder().CreateLShr(a.v, bits, SSAScope::hint())); +} diff --git a/src/r_compiler/ssa/ssa_vec8s.h b/src/r_compiler/ssa/ssa_vec8s.h new file mode 100644 index 000000000..aded358dd --- /dev/null +++ b/src/r_compiler/ssa/ssa_vec8s.h @@ -0,0 +1,48 @@ + +#pragma once + +namespace llvm { class Value; } +namespace llvm { class Type; } + +class SSAVec4i; +class SSAVec16ub; + +class SSAVec8s +{ +public: + SSAVec8s(); + SSAVec8s(short constant); + SSAVec8s(short constant0, short constant1, short constant2, short constant3, short constant4, short constant5, short constant6, short constant7); + explicit SSAVec8s(llvm::Value *v); + SSAVec8s(SSAVec4i i0, SSAVec4i i1); + static SSAVec8s bitcast(SSAVec16ub i8); + static SSAVec8s shuffle(const SSAVec8s &i0, int index0, int index1, int index2, int index3, int index4, int index5, int index6, int index7); + static SSAVec8s shuffle(const SSAVec8s &i0, const SSAVec8s &i1, int index0, int index1, int index2, int index3, int index4, int index5, int index6, int index7); + static SSAVec8s extendhi(SSAVec16ub a); + static SSAVec8s extendlo(SSAVec16ub a); + //static SSAVec8s min_sse2(SSAVec8s a, SSAVec8s b); + //static SSAVec8s max_sse2(SSAVec8s a, SSAVec8s b); + static SSAVec8s mulhi(SSAVec8s a, SSAVec8s b); + static SSAVec8s from_llvm(llvm::Value *v) { return SSAVec8s(v); } + static llvm::Type *llvm_type(); + + llvm::Value *v; +}; + +SSAVec8s operator+(const SSAVec8s &a, const SSAVec8s &b); +SSAVec8s operator-(const SSAVec8s &a, const SSAVec8s &b); +SSAVec8s operator*(const SSAVec8s &a, const SSAVec8s &b); +SSAVec8s operator/(const SSAVec8s &a, const SSAVec8s &b); + +SSAVec8s operator+(short a, const SSAVec8s &b); +SSAVec8s operator-(short a, const SSAVec8s &b); +SSAVec8s operator*(short a, const SSAVec8s &b); +SSAVec8s operator/(short a, const SSAVec8s &b); + +SSAVec8s operator+(const SSAVec8s &a, short b); +SSAVec8s operator-(const SSAVec8s &a, short b); +SSAVec8s operator*(const SSAVec8s &a, short b); +SSAVec8s operator/(const SSAVec8s &a, short b); + +SSAVec8s operator<<(const SSAVec8s &a, int bits); +SSAVec8s operator>>(const SSAVec8s &a, int bits); diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 0d86ead47..d54bad7ae 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -38,6 +38,7 @@ #include "r_data/colormaps.h" #include "r_plane.h" #include "r_draw_rgba.h" +#include "r_compiler/fixedfunction/fixedfunction.h" #include "gi.h" #include "stats.h" @@ -299,6 +300,68 @@ void DrawerCommandQueue::StopThreads() ///////////////////////////////////////////////////////////////////////////// +class DrawSpanFFCommand : public DrawerCommand +{ + fixed_t _xfrac; + fixed_t _yfrac; + fixed_t _xstep; + fixed_t _ystep; + int _x1; + int _x2; + int _y; + int _xbits; + int _ybits; + BYTE * RESTRICT _destorg; + + const uint32_t * RESTRICT _source; + uint32_t _light; + ShadeConstants _shade_constants; + bool _nearest_filter; + + uint32_t _srcalpha; + uint32_t _destalpha; + + FixedFunction *_ff; + +public: + DrawSpanFFCommand() + { + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _xstep = ds_xstep; + _ystep = ds_ystep; + _x1 = ds_x1; + _x2 = ds_x2; + _y = ds_y; + _xbits = ds_xbits; + _ybits = ds_ybits; + _destorg = dc_destorg; + + _source = (const uint32_t*)ds_source; + _light = LightBgra::calc_light_multiplier(ds_light); + _shade_constants = ds_shade_constants; + _nearest_filter = !SampleBgra::span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep, ds_source_mipmapped); + + _srcalpha = dc_srcalpha >> (FRACBITS - 8); + _destalpha = dc_destalpha >> (FRACBITS - 8); + + static FixedFunction ff; + _ff = &ff; + } + + void Execute(DrawerThread *thread) override + { + if (thread->skipped_by_thread(_y)) + return; + + uint32_t *dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; + int count = _x2 - _x1 + 1; + _ff->DrawSpan(count, dest); + } +}; + +///////////////////////////////////////////////////////////////////////////// + class DrawerColumnCommand : public DrawerCommand { public: @@ -2700,11 +2763,14 @@ void R_DrawRevSubClampTranslatedColumn_rgba() void R_DrawSpan_rgba() { + DrawerCommandQueue::QueueCommand(); +/* #ifdef NO_SSE DrawerCommandQueue::QueueCommand(); #else DrawerCommandQueue::QueueCommand(); #endif +*/ } void R_DrawSpanMasked_rgba() From 4f2ae42ed59307a5e823cb97df110f0920be6b34 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 26 Sep 2016 09:04:29 +0200 Subject: [PATCH 0987/1509] Revert duplicate entry in CMakeLists.txt --- src/CMakeLists.txt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4f9599b35..09238ff57 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -104,15 +104,6 @@ if( WIN32 ) endif() add_definitions( -D_WIN32 ) - - set( FMOD_SEARCH_PATHS - "C:/Program Files/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" - "C:/Program Files (x86)/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" - # This next one is for Randy. - "E:/Software/Dev/FMOD/${WIN_TYPE}/api" - ) - set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES inc ) - set( FMOD_LIB_PATH_SUFFIXES PATH_SUFFIXES lib ) set( FMOD_SEARCH_PATHS "C:/Program Files/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" From d5c7a7ab76bb34e248a4dbb6ad3ca3800176da94 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 27 Sep 2016 03:07:03 +0200 Subject: [PATCH 0988/1509] Make LLVM compile and optimize for the current CPU --- .../fixedfunction/fixedfunction.cpp | 86 ++++++++++++++----- src/r_compiler/fixedfunction/fixedfunction.h | 4 + src/r_compiler/llvm_include.h | 11 ++- 3 files changed, 75 insertions(+), 26 deletions(-) diff --git a/src/r_compiler/fixedfunction/fixedfunction.cpp b/src/r_compiler/fixedfunction/fixedfunction.cpp index 347ba6de3..cc46b8d50 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.cpp +++ b/src/r_compiler/fixedfunction/fixedfunction.cpp @@ -13,36 +13,75 @@ RenderProgram::RenderProgram() { - llvm::install_fatal_error_handler([](void *user_data, const std::string& reason, bool gen_crash_diag) { - I_FatalError(reason.c_str()); + using namespace llvm; + + install_fatal_error_handler([](void *user_data, const std::string& reason, bool gen_crash_diag) { + I_FatalError("LLVM fatal error: %s", reason.c_str()); }); - //llvm::llvm_start_multithreaded(); - llvm::InitializeNativeTarget(); - llvm::InitializeNativeTargetAsmPrinter(); - llvm::InitializeNativeTargetAsmParser(); - - mContext = std::make_unique(); - - auto moduleOwner = std::make_unique("render", context()); - mModule = moduleOwner.get(); + InitializeNativeTarget(); + InitializeNativeTargetAsmPrinter(); + InitializeNativeTargetAsmParser(); std::string errorstring; - llvm::EngineBuilder engineBuilder(std::move(moduleOwner)); + + std::string targetTriple = sys::getProcessTriple(); + std::string cpuName = sys::getHostCPUName(); + StringMap cpuFeatures; + sys::getHostCPUFeatures(cpuFeatures); + std::string cpuFeaturesStr; + for (const auto &it : cpuFeatures) + { + if (!cpuFeaturesStr.empty()) + cpuFeaturesStr.push_back(' '); + cpuFeaturesStr.push_back(it.getValue() ? '+' : '-'); + cpuFeaturesStr += it.getKey(); + } + + Printf("LLVM target triple: %s\n", targetTriple.c_str()); + Printf("LLVM CPU and features: %s, %s\n", cpuName.c_str(), cpuFeaturesStr.c_str()); + + const Target *target = TargetRegistry::lookupTarget(targetTriple, errorstring); + if (!target) + I_FatalError("Could not find LLVM target: %s", errorstring.c_str()); + + TargetOptions opt; + auto relocModel = Optional(Reloc::Static); + TargetMachine *machine = target->createTargetMachine(targetTriple, cpuName, cpuFeaturesStr, opt, relocModel, CodeModel::Default, CodeGenOpt::Aggressive); + if (!machine) + I_FatalError("Could not create LLVM target machine"); + + mContext = std::make_unique(); + + auto moduleOwner = std::make_unique("render", context()); + mModule = moduleOwner.get(); + mModule->setTargetTriple(targetTriple); + mModule->setDataLayout(machine->createDataLayout()); + + EngineBuilder engineBuilder(std::move(moduleOwner)); engineBuilder.setErrorStr(&errorstring); - engineBuilder.setOptLevel(llvm::CodeGenOpt::Aggressive); - engineBuilder.setRelocationModel(llvm::Reloc::Static); - engineBuilder.setEngineKind(llvm::EngineKind::JIT); - mEngine.reset(engineBuilder.create()); + engineBuilder.setOptLevel(CodeGenOpt::Aggressive); + engineBuilder.setRelocationModel(Reloc::Static); + engineBuilder.setEngineKind(EngineKind::JIT); + mEngine.reset(engineBuilder.create(machine)); if (!mEngine) - I_FatalError(errorstring.c_str()); + I_FatalError("Could not create LLVM execution engine: %s", errorstring.c_str()); + + mModulePassManager = std::make_unique(); + mFunctionPassManager = std::make_unique(mModule); + + PassManagerBuilder passManagerBuilder; + passManagerBuilder.OptLevel = 3; + passManagerBuilder.SizeLevel = 0; + passManagerBuilder.Inliner = createFunctionInliningPass(); + passManagerBuilder.populateModulePassManager(*mModulePassManager.get()); + passManagerBuilder.populateFunctionPassManager(*mFunctionPassManager.get()); } RenderProgram::~RenderProgram() { mEngine.reset(); mContext.reset(); - //llvm::llvm_stop_multithreaded(); } void *RenderProgram::PointerToFunction(const char *name) @@ -57,6 +96,7 @@ FixedFunction::FixedFunction() { CodegenDrawSpan(); mProgram.engine()->finalizeObject(); + mProgram.modulePassManager()->run(*mProgram.module()); DrawSpan = mProgram.GetProcAddress("DrawSpan"); } @@ -81,12 +121,12 @@ void FixedFunction::CodegenDrawSpan() SSAInt index = stack_index.load(); loop.loop_block(index < count); - //SSAVec4i color(255, 255, 0, 255); - //data[index * 4].store_vec4ub(color); - data[index * 4].store(0); + SSAVec4i color(0, 128, 255, 255); + data[index * 4].store_vec4ub(color); + /*data[index * 4].store(0); data[index * 4 + 1].store(128); data[index * 4 + 2].store(255); - data[index * 4 + 3].store(255); + data[index * 4 + 3].store(255);*/ stack_index.store(index + 1); } loop.end_block(); @@ -95,6 +135,8 @@ void FixedFunction::CodegenDrawSpan() if (llvm::verifyFunction(*function.func)) I_FatalError("verifyFunction failed for " __FUNCTION__); + + mProgram.functionPassManager()->run(*function.func); } #if 0 diff --git a/src/r_compiler/fixedfunction/fixedfunction.h b/src/r_compiler/fixedfunction/fixedfunction.h index 4c81fc108..7ee68032e 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.h +++ b/src/r_compiler/fixedfunction/fixedfunction.h @@ -26,6 +26,8 @@ public: llvm::LLVMContext &context() { return *mContext; } llvm::Module *module() { return mModule; } llvm::ExecutionEngine *engine() { return mEngine.get(); } + llvm::legacy::PassManager *modulePassManager() { return mModulePassManager.get(); } + llvm::legacy::FunctionPassManager *functionPassManager() { return mFunctionPassManager.get(); } private: void *PointerToFunction(const char *name); @@ -33,6 +35,8 @@ private: std::unique_ptr mContext; llvm::Module *mModule; std::unique_ptr mEngine; + std::unique_ptr mModulePassManager; + std::unique_ptr mFunctionPassManager; }; class FixedFunction diff --git a/src/r_compiler/llvm_include.h b/src/r_compiler/llvm_include.h index 1eed549e1..b916bad0e 100644 --- a/src/r_compiler/llvm_include.h +++ b/src/r_compiler/llvm_include.h @@ -20,19 +20,22 @@ #pragma warning(disable: 4291) // warning C4291: 'void *llvm::User::operator new(std::size_t,unsigned int,unsigned int)': no matching operator delete found; memory will not be freed if initialization throws an exception #include -#include -#include #include #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include #include #include -#include -#include +#include #include #include From 1b7827342ccdedbd11339df2d0b1df70a2882bb4 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Tue, 27 Sep 2016 04:14:00 -0400 Subject: [PATCH 0989/1509] - Fixed: Changed r_clearbuffer to do a little more than clear the top quarter of the screen. Still need to do an actual color fill - will do it later. --- src/r_swrenderer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 5be847502..368b1c3fd 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -289,7 +289,12 @@ void FSoftwareRenderer::ErrorCleanup () void FSoftwareRenderer::ClearBuffer(int color) { - memset(RenderTarget->GetBuffer(), color, RenderTarget->GetPitch() * RenderTarget->GetHeight()); + // [SP] For now, for truecolor, this just outputs black. We'll figure out how to get something more meaningful + // later when this actually matters more. This is just to clear HOMs for now. + if (!r_swtruecolor) + memset(RenderTarget->GetBuffer(), color, RenderTarget->GetPitch() * RenderTarget->GetHeight()); + else + memset(RenderTarget->GetBuffer(), 0, RenderTarget->GetPitch() * RenderTarget->GetHeight() * 4); } //=========================================================================== From 20f67ad40a96b90e17fe44e98a026ac6cc9dac7c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 27 Sep 2016 22:53:20 +0200 Subject: [PATCH 0990/1509] Add SSAShort, shift, and, or, and fix unaligned store --- src/CMakeLists.txt | 1 + src/r_compiler/ssa/ssa_float_ptr.cpp | 11 +- src/r_compiler/ssa/ssa_int.cpp | 30 ++++++ src/r_compiler/ssa/ssa_int.h | 7 ++ src/r_compiler/ssa/ssa_int_ptr.cpp | 4 +- src/r_compiler/ssa/ssa_short.cpp | 148 +++++++++++++++++++++++++++ src/r_compiler/ssa/ssa_short.h | 49 +++++++++ src/r_compiler/ssa/ssa_ubyte_ptr.cpp | 10 +- src/r_compiler/ssa/ssa_vec4f_ptr.cpp | 10 +- src/r_compiler/ssa/ssa_vec4i_ptr.cpp | 10 +- 10 files changed, 245 insertions(+), 35 deletions(-) create mode 100644 src/r_compiler/ssa/ssa_short.cpp create mode 100644 src/r_compiler/ssa/ssa_short.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 09238ff57..4b81a24f4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1434,6 +1434,7 @@ set (PCH_SOURCES r_compiler/ssa/ssa_if_block.cpp r_compiler/ssa/ssa_int.cpp r_compiler/ssa/ssa_int_ptr.cpp + r_compiler/ssa/ssa_short.cpp r_compiler/ssa/ssa_scope.cpp r_compiler/ssa/ssa_struct_type.cpp r_compiler/ssa/ssa_ubyte.cpp diff --git a/src/r_compiler/ssa/ssa_float_ptr.cpp b/src/r_compiler/ssa/ssa_float_ptr.cpp index 4413c6e92..6a1409271 100644 --- a/src/r_compiler/ssa/ssa_float_ptr.cpp +++ b/src/r_compiler/ssa/ssa_float_ptr.cpp @@ -38,7 +38,6 @@ SSAVec4f SSAFloatPtr::load_unaligned_vec4f() const { llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); return SSAVec4f::from_llvm(SSAScope::builder().Insert(new llvm::LoadInst(SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), SSAScope::hint(), false, 4), SSAScope::hint())); - // return SSAVec4f::from_llvm(SSAScope::builder().CreateCall(get_intrinsic(llvm::Intrinsic::x86_sse2_loadu_dq), SSAScope::builder().CreateBitCast(v, llvm::PointerType::getUnqual(llvm::IntegerType::get(SSAScope::context(), 8))))); } void SSAFloatPtr::store(const SSAFloat &new_value) @@ -49,17 +48,11 @@ void SSAFloatPtr::store(const SSAFloat &new_value) void SSAFloatPtr::store_vec4f(const SSAVec4f &new_value) { llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); - SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), 16); + SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint())); } void SSAFloatPtr::store_unaligned_vec4f(const SSAVec4f &new_value) { - /*llvm::Value *values[2] = - { - SSAScope::builder().CreateBitCast(v, llvm::Type::getFloatPtrTy(SSAScope::context())), - new_value.v - }; - SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse_storeu_ps), values);*/ llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); - SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint())); + SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), 4); } diff --git a/src/r_compiler/ssa/ssa_int.cpp b/src/r_compiler/ssa/ssa_int.cpp index 9f3c54f50..674f44350 100644 --- a/src/r_compiler/ssa/ssa_int.cpp +++ b/src/r_compiler/ssa/ssa_int.cpp @@ -115,3 +115,33 @@ SSAInt operator>>(const SSAInt &a, int bits) { return SSAInt::from_llvm(SSAScope::builder().CreateLShr(a.v, bits, SSAScope::hint())); } + +SSAInt operator<<(const SSAInt &a, const SSAInt &bits) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateShl(a.v, bits.v, SSAScope::hint())); +} + +SSAInt operator>>(const SSAInt &a, const SSAInt &bits) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateLShr(a.v, bits.v, SSAScope::hint())); +} + +SSAInt operator&(const SSAInt &a, int b) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateAnd(a.v, b, SSAScope::hint())); +} + +SSAInt operator&(const SSAInt &a, const SSAInt &b) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateAnd(a.v, b.v, SSAScope::hint())); +} + +SSAInt operator|(const SSAInt &a, int b) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateOr(a.v, b, SSAScope::hint())); +} + +SSAInt operator|(const SSAInt &a, const SSAInt &b) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateOr(a.v, b.v, SSAScope::hint())); +} diff --git a/src/r_compiler/ssa/ssa_int.h b/src/r_compiler/ssa/ssa_int.h index 0be37ee7e..5e373c62e 100644 --- a/src/r_compiler/ssa/ssa_int.h +++ b/src/r_compiler/ssa/ssa_int.h @@ -39,3 +39,10 @@ SSAInt operator%(const SSAInt &a, int b); SSAInt operator<<(const SSAInt &a, int bits); SSAInt operator>>(const SSAInt &a, int bits); +SSAInt operator<<(const SSAInt &a, const SSAInt &bits); +SSAInt operator>>(const SSAInt &a, const SSAInt &bits); + +SSAInt operator&(const SSAInt &a, int b); +SSAInt operator&(const SSAInt &a, const SSAInt &b); +SSAInt operator|(const SSAInt &a, int b); +SSAInt operator|(const SSAInt &a, const SSAInt &b); diff --git a/src/r_compiler/ssa/ssa_int_ptr.cpp b/src/r_compiler/ssa/ssa_int_ptr.cpp index dd0ca17f6..3c2637073 100644 --- a/src/r_compiler/ssa/ssa_int_ptr.cpp +++ b/src/r_compiler/ssa/ssa_int_ptr.cpp @@ -48,11 +48,11 @@ void SSAIntPtr::store(const SSAInt &new_value) void SSAIntPtr::store_vec4i(const SSAVec4i &new_value) { llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); - SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 16); + SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint())); } void SSAIntPtr::store_unaligned_vec4i(const SSAVec4i &new_value) { llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); - SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint())); + SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 4); } diff --git a/src/r_compiler/ssa/ssa_short.cpp b/src/r_compiler/ssa/ssa_short.cpp new file mode 100644 index 000000000..fc8de9449 --- /dev/null +++ b/src/r_compiler/ssa/ssa_short.cpp @@ -0,0 +1,148 @@ + +#include "ssa_short.h" +#include "ssa_float.h" +#include "ssa_int.h" +#include "ssa_scope.h" +#include "r_compiler/llvm_include.h" + +SSAShort::SSAShort() +: v(0) +{ +} + +SSAShort::SSAShort(int constant) +: v(0) +{ + v = llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(16, constant, true)); +} + +SSAShort::SSAShort(SSAFloat f) +: v(0) +{ + v = SSAScope::builder().CreateFPToSI(f.v, llvm::Type::getInt16Ty(SSAScope::context()), SSAScope::hint()); +} + +SSAShort::SSAShort(llvm::Value *v) +: v(v) +{ +} + +llvm::Type *SSAShort::llvm_type() +{ + return llvm::Type::getInt16Ty(SSAScope::context()); +} + +SSAShort operator+(const SSAShort &a, const SSAShort &b) +{ + return SSAShort::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); +} + +SSAShort operator-(const SSAShort &a, const SSAShort &b) +{ + return SSAShort::from_llvm(SSAScope::builder().CreateSub(a.v, b.v, SSAScope::hint())); +} + +SSAShort operator*(const SSAShort &a, const SSAShort &b) +{ + return SSAShort::from_llvm(SSAScope::builder().CreateMul(a.v, b.v, SSAScope::hint())); +} + +SSAShort operator/(const SSAShort &a, const SSAShort &b) +{ + return SSAShort::from_llvm(SSAScope::builder().CreateSDiv(a.v, b.v, SSAScope::hint())); +} + +SSAShort operator%(const SSAShort &a, const SSAShort &b) +{ + return SSAShort::from_llvm(SSAScope::builder().CreateSRem(a.v, b.v, SSAScope::hint())); +} + +SSAShort operator+(int a, const SSAShort &b) +{ + return SSAShort(a) + b; +} + +SSAShort operator-(int a, const SSAShort &b) +{ + return SSAShort(a) - b; +} + +SSAShort operator*(int a, const SSAShort &b) +{ + return SSAShort(a) * b; +} + +SSAShort operator/(int a, const SSAShort &b) +{ + return SSAShort(a) / b; +} + +SSAShort operator%(int a, const SSAShort &b) +{ + return SSAShort(a) % b; +} + +SSAShort operator+(const SSAShort &a, int b) +{ + return a + SSAShort(b); +} + +SSAShort operator-(const SSAShort &a, int b) +{ + return a - SSAShort(b); +} + +SSAShort operator*(const SSAShort &a, int b) +{ + return a * SSAShort(b); +} + +SSAShort operator/(const SSAShort &a, int b) +{ + return a / SSAShort(b); +} + +SSAShort operator%(const SSAShort &a, int b) +{ + return a % SSAShort(b); +} + +SSAShort operator<<(const SSAShort &a, int bits) +{ + return SSAShort::from_llvm(SSAScope::builder().CreateShl(a.v, bits, SSAScope::hint())); +} + +SSAShort operator>>(const SSAShort &a, int bits) +{ + return SSAShort::from_llvm(SSAScope::builder().CreateLShr(a.v, bits, SSAScope::hint())); +} + +SSAShort operator<<(const SSAShort &a, const SSAInt &bits) +{ + return SSAShort::from_llvm(SSAScope::builder().CreateShl(a.v, bits.v, SSAScope::hint())); +} + +SSAShort operator>>(const SSAShort &a, const SSAInt &bits) +{ + return SSAShort::from_llvm(SSAScope::builder().CreateLShr(a.v, bits.v, SSAScope::hint())); +} + +SSAShort operator&(const SSAShort &a, int b) +{ + return SSAShort::from_llvm(SSAScope::builder().CreateAnd(a.v, b, SSAScope::hint())); +} + +SSAShort operator&(const SSAShort &a, const SSAShort &b) +{ + return SSAShort::from_llvm(SSAScope::builder().CreateAnd(a.v, b.v, SSAScope::hint())); +} + +SSAShort operator|(const SSAShort &a, int b) +{ + return SSAShort::from_llvm(SSAScope::builder().CreateOr(a.v, b, SSAScope::hint())); +} + +SSAShort operator|(const SSAShort &a, const SSAShort &b) +{ + return SSAShort::from_llvm(SSAScope::builder().CreateOr(a.v, b.v, SSAScope::hint())); +} diff --git a/src/r_compiler/ssa/ssa_short.h b/src/r_compiler/ssa/ssa_short.h new file mode 100644 index 000000000..ae71a1336 --- /dev/null +++ b/src/r_compiler/ssa/ssa_short.h @@ -0,0 +1,49 @@ + +#pragma once + +namespace llvm { class Value; } +namespace llvm { class Type; } + +class SSAFloat; +class SSAInt; + +class SSAShort +{ +public: + SSAShort(); + SSAShort(int constant); + SSAShort(SSAFloat f); + explicit SSAShort(llvm::Value *v); + static SSAShort from_llvm(llvm::Value *v) { return SSAShort(v); } + static llvm::Type *llvm_type(); + + llvm::Value *v; +}; + +SSAShort operator+(const SSAShort &a, const SSAShort &b); +SSAShort operator-(const SSAShort &a, const SSAShort &b); +SSAShort operator*(const SSAShort &a, const SSAShort &b); +SSAShort operator/(const SSAShort &a, const SSAShort &b); +SSAShort operator%(const SSAShort &a, const SSAShort &b); + +SSAShort operator+(int a, const SSAShort &b); +SSAShort operator-(int a, const SSAShort &b); +SSAShort operator*(int a, const SSAShort &b); +SSAShort operator/(int a, const SSAShort &b); +SSAShort operator%(int a, const SSAShort &b); + +SSAShort operator+(const SSAShort &a, int b); +SSAShort operator-(const SSAShort &a, int b); +SSAShort operator*(const SSAShort &a, int b); +SSAShort operator/(const SSAShort &a, int b); +SSAShort operator%(const SSAShort &a, int b); + +SSAShort operator<<(const SSAShort &a, int bits); +SSAShort operator>>(const SSAShort &a, int bits); +SSAShort operator<<(const SSAShort &a, const SSAInt &bits); +SSAShort operator>>(const SSAShort &a, const SSAInt &bits); + +SSAShort operator&(const SSAShort &a, int b); +SSAShort operator&(const SSAShort &a, const SSAShort &b); +SSAShort operator|(const SSAShort &a, int b); +SSAShort operator|(const SSAShort &a, const SSAShort &b); diff --git a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp index 825806148..b2408066e 100644 --- a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp +++ b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp @@ -86,7 +86,7 @@ void SSAUBytePtr::store_vec4ub(const SSAVec4i &new_value) void SSAUBytePtr::store_vec16ub(const SSAVec16ub &new_value) { llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); - llvm::StoreInst *inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), 16); + llvm::StoreInst *inst = SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint())); // The following generates _mm_stream_si128, maybe! // llvm::MDNode *node = llvm::MDNode::get(SSAScope::context(), SSAScope::builder().getInt32(1)); @@ -95,12 +95,6 @@ void SSAUBytePtr::store_vec16ub(const SSAVec16ub &new_value) void SSAUBytePtr::store_unaligned_vec16ub(const SSAVec16ub &new_value) { - /*llvm::Value *values[2] = - { - SSAScope::builder().CreateBitCast(v, llvm::Type::getInt8PtrTy(SSAScope::context())), - new_value.v - }; - SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_storeu_dq), values);*/ llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); - llvm::StoreInst *inst = SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint())); + llvm::StoreInst *inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), 4); } diff --git a/src/r_compiler/ssa/ssa_vec4f_ptr.cpp b/src/r_compiler/ssa/ssa_vec4f_ptr.cpp index e2df64167..6a197ec90 100644 --- a/src/r_compiler/ssa/ssa_vec4f_ptr.cpp +++ b/src/r_compiler/ssa/ssa_vec4f_ptr.cpp @@ -35,16 +35,10 @@ SSAVec4f SSAVec4fPtr::load_unaligned() const void SSAVec4fPtr::store(const SSAVec4f &new_value) { - SSAScope::builder().CreateAlignedStore(new_value.v, v, 16, false); + SSAScope::builder().CreateStore(new_value.v, v, false); } void SSAVec4fPtr::store_unaligned(const SSAVec4f &new_value) { - /*llvm::Value *values[2] = - { - SSAScope::builder().CreateBitCast(v, llvm::Type::getFloatPtrTy(SSAScope::context())), - new_value.v - }; - SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse_storeu_ps), values);*/ - SSAScope::builder().CreateStore(new_value.v, v, false); + SSAScope::builder().CreateAlignedStore(new_value.v, v, 4, false); } diff --git a/src/r_compiler/ssa/ssa_vec4i_ptr.cpp b/src/r_compiler/ssa/ssa_vec4i_ptr.cpp index a28befb70..7138c30d2 100644 --- a/src/r_compiler/ssa/ssa_vec4i_ptr.cpp +++ b/src/r_compiler/ssa/ssa_vec4i_ptr.cpp @@ -35,16 +35,10 @@ SSAVec4i SSAVec4iPtr::load_unaligned() const void SSAVec4iPtr::store(const SSAVec4i &new_value) { - SSAScope::builder().CreateAlignedStore(new_value.v, v, 16, false); + SSAScope::builder().CreateStore(new_value.v, v, false); } void SSAVec4iPtr::store_unaligned(const SSAVec4i &new_value) { - /*llvm::Value *values[2] = - { - v, - new_value.v - }; - SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_storeu_pd), values);*/ - SSAScope::builder().CreateStore(new_value.v, v, false); + SSAScope::builder().CreateAlignedStore(new_value.v, v, 4, false); } From f9a7186550bf6b6e72f9770ba79e3789b7acf541 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 27 Sep 2016 22:54:37 +0200 Subject: [PATCH 0991/1509] Improve DrawSpan codegen enough to do the simple shade for 64x64 flats --- .../fixedfunction/fixedfunction.cpp | 112 +++++++++++++++--- src/r_compiler/fixedfunction/fixedfunction.h | 26 +++- src/r_draw_rgba.cpp | 20 +++- 3 files changed, 139 insertions(+), 19 deletions(-) diff --git a/src/r_compiler/fixedfunction/fixedfunction.cpp b/src/r_compiler/fixedfunction/fixedfunction.cpp index cc46b8d50..8f8b09f23 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.cpp +++ b/src/r_compiler/fixedfunction/fixedfunction.cpp @@ -38,8 +38,8 @@ RenderProgram::RenderProgram() cpuFeaturesStr += it.getKey(); } - Printf("LLVM target triple: %s\n", targetTriple.c_str()); - Printf("LLVM CPU and features: %s, %s\n", cpuName.c_str(), cpuFeaturesStr.c_str()); + //Printf("LLVM target triple: %s\n", targetTriple.c_str()); + //Printf("LLVM CPU and features: %s, %s\n", cpuName.c_str(), cpuFeaturesStr.c_str()); const Target *target = TargetRegistry::lookupTarget(targetTriple, errorstring); if (!target) @@ -98,7 +98,7 @@ FixedFunction::FixedFunction() mProgram.engine()->finalizeObject(); mProgram.modulePassManager()->run(*mProgram.module()); - DrawSpan = mProgram.GetProcAddress("DrawSpan"); + DrawSpan = mProgram.GetProcAddress("DrawSpan"); } void FixedFunction::CodegenDrawSpan() @@ -107,29 +107,90 @@ void FixedFunction::CodegenDrawSpan() SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); SSAFunction function("DrawSpan"); - function.add_parameter(SSAInt::llvm_type()); - function.add_parameter(SSAUBytePtr::llvm_type()); + function.add_parameter(GetRenderArgsStruct(mProgram.context())); function.create_public(); - SSAInt count = function.parameter(0); - SSAUBytePtr data = function.parameter(1); - SSAStack stack_index; + SSAStack stack_index, stack_xfrac, stack_yfrac; + SSAValue args = function.parameter(0); + SSAUBytePtr destorg = args[0][0].load(); + SSAUBytePtr source = args[0][1].load(); + SSAInt destpitch = args[0][2].load(); + stack_xfrac.store(args[0][3].load()); + stack_yfrac.store(args[0][4].load()); + SSAInt xstep = args[0][5].load(); + SSAInt ystep = args[0][6].load(); + SSAInt x1 = args[0][7].load(); + SSAInt x2 = args[0][8].load(); + SSAInt y = args[0][9].load(); + SSAInt xbits = args[0][10].load(); + SSAInt ybits = args[0][11].load(); + SSAInt light = args[0][12].load(); + SSAInt srcalpha = args[0][13].load(); + SSAInt destalpha = args[0][14].load(); + + SSAInt count = x2 - x1 + 1; + SSAUBytePtr data = destorg[(x1 + y * destpitch) * 4]; + + SSAInt yshift = 32 - ybits; + SSAInt xshift = yshift - xbits; + SSAInt xmask = ((SSAInt(1) << xbits) - 1) << ybits; + //is_64x64 = xbits == 6 && ybits == 6; + + SSAInt sseLength = count / 4; stack_index.store(0); - SSAForBlock loop; { + SSAForBlock loop; + SSAInt index = stack_index.load(); + loop.loop_block(index < sseLength); + + SSAVec4i colors[4]; + for (int i = 0; i < 4; i++) + { + SSAInt xfrac = stack_xfrac.load(); + SSAInt yfrac = stack_yfrac.load(); + + // 64x64 is the most common case by far, so special case it. + SSAInt spot64 = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + //SSAInt spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + + //*loop.dest = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); + colors[i] = source[spot64 * 4].load_vec4ub() * light / 256; + + stack_xfrac.store(xfrac + xstep); + stack_yfrac.store(yfrac + ystep); + } + + SSAVec16ub ssecolors(SSAVec8s(colors[0], colors[1]), SSAVec8s(colors[2], colors[3])); + data[index * 16].store_unaligned_vec16ub(ssecolors); + + stack_index.store(index + 1); + loop.end_block(); + } + + stack_index.store(sseLength * 4); + { + SSAForBlock loop; SSAInt index = stack_index.load(); loop.loop_block(index < count); - SSAVec4i color(0, 128, 255, 255); + SSAInt xfrac = stack_xfrac.load(); + SSAInt yfrac = stack_yfrac.load(); + + // 64x64 is the most common case by far, so special case it. + SSAInt spot64 = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + //SSAInt spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + + //*loop.dest = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); + SSAVec4i color = source[spot64 * 4].load_vec4ub(); + color = color * light / 256; data[index * 4].store_vec4ub(color); - /*data[index * 4].store(0); - data[index * 4 + 1].store(128); - data[index * 4 + 2].store(255); - data[index * 4 + 3].store(255);*/ + stack_index.store(index + 1); + stack_xfrac.store(xfrac + xstep); + stack_yfrac.store(yfrac + ystep); + loop.end_block(); } - loop.end_block(); builder.CreateRetVoid(); @@ -139,6 +200,27 @@ void FixedFunction::CodegenDrawSpan() mProgram.functionPassManager()->run(*function.func); } +llvm::Type *FixedFunction::GetRenderArgsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *destorg; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *source; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t destpitch; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xfrac; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t yfrac; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xstep; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ystep; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x1; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x2; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t y; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xbits; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ybits; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; + return llvm::StructType::get(context, elements, false)->getPointerTo(); +} + #if 0 GlslFixedFunction::GlslFixedFunction(GlslProgram &program, GlslCodeGen &vertex_codegen, GlslCodeGen &fragment_codegen) diff --git a/src/r_compiler/fixedfunction/fixedfunction.h b/src/r_compiler/fixedfunction/fixedfunction.h index 7ee68032e..3bbf05abe 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.h +++ b/src/r_compiler/fixedfunction/fixedfunction.h @@ -6,6 +6,7 @@ #include "r_compiler/ssa/ssa_vec8s.h" #include "r_compiler/ssa/ssa_vec16ub.h" #include "r_compiler/ssa/ssa_int.h" +#include "r_compiler/ssa/ssa_short.h" #include "r_compiler/ssa/ssa_ubyte_ptr.h" #include "r_compiler/ssa/ssa_vec4f_ptr.h" #include "r_compiler/ssa/ssa_vec4i_ptr.h" @@ -39,16 +40,39 @@ private: std::unique_ptr mFunctionPassManager; }; +struct RenderArgs +{ + uint32_t *destorg; + const uint32_t *source; + int32_t destpitch; + int32_t xfrac; + int32_t yfrac; + int32_t xstep; + int32_t ystep; + int32_t x1; + int32_t x2; + int32_t y; + int32_t xbits; + int32_t ybits; + uint32_t light; + uint32_t srcalpha; + uint32_t destalpha; + //ShadeConstants _shade_constants; + //int32_t nearest_filter; +}; + class FixedFunction { public: FixedFunction(); - void(*DrawSpan)(int, uint32_t *) = nullptr; + void(*DrawSpan)(const RenderArgs *) = nullptr; private: void CodegenDrawSpan(); + static llvm::Type *GetRenderArgsStruct(llvm::LLVMContext &context); + RenderProgram mProgram; }; diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index d54bad7ae..975739095 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -354,9 +354,23 @@ public: if (thread->skipped_by_thread(_y)) return; - uint32_t *dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - int count = _x2 - _x1 + 1; - _ff->DrawSpan(count, dest); + RenderArgs args; + args.destorg = (uint32_t *)_destorg; + args.source = _source; + args.destpitch = dc_pitch; + args.xfrac = _xfrac; + args.yfrac = _yfrac; + args.xstep = _xstep; + args.ystep = _ystep; + args.x1 = _x1; + args.x2 = _x2; + args.y = _y; + args.xbits = _xbits; + args.ybits = _ybits; + args.light = _light; + args.srcalpha = _srcalpha; + args.destalpha = _destalpha; + _ff->DrawSpan(&args); } }; From d05ed3740b90dfda8b6ab8afbb688baa9439c619 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Tue, 27 Sep 2016 19:27:57 -0400 Subject: [PATCH 0992/1509] Corrected forum links in version.h --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 0c9b85120..c7a95e66e 100644 --- a/src/version.h +++ b/src/version.h @@ -90,8 +90,8 @@ const char *GetVersionString(); // More stuff that needs to be different for derivatives. #define GAMENAME "QZDoom" #define GAMENAMELOWERCASE "qzdoom" -#define FORUM_URL "http://forum.drdteam.org" -#define BUGS_FORUM_URL "http://forum.drdteam.org/viewforum.php?f=24" +#define FORUM_URL "http://forum.drdteam.org/viewforum.php?f=196" +#define BUGS_FORUM_URL "http://forum.drdteam.org/viewforum.php?f=197" #if defined(__APPLE__) || defined(_WIN32) #define GAME_DIR GAMENAME From 576fed5afceebd8b6a08c7580fbd2cb25e25b2e5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 28 Sep 2016 05:18:16 +0200 Subject: [PATCH 0993/1509] Add light, blend and sampler functions --- .../fixedfunction/fixedfunction.cpp | 123 +++++++++++++++++- src/r_compiler/fixedfunction/fixedfunction.h | 45 ++++++- src/r_compiler/ssa/ssa_vec4i.cpp | 10 ++ src/r_compiler/ssa/ssa_vec4i.h | 2 + 4 files changed, 173 insertions(+), 7 deletions(-) diff --git a/src/r_compiler/fixedfunction/fixedfunction.cpp b/src/r_compiler/fixedfunction/fixedfunction.cpp index 8f8b09f23..d70248864 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.cpp +++ b/src/r_compiler/fixedfunction/fixedfunction.cpp @@ -154,8 +154,7 @@ void FixedFunction::CodegenDrawSpan() SSAInt spot64 = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); //SSAInt spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - //*loop.dest = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); - colors[i] = source[spot64 * 4].load_vec4ub() * light / 256; + colors[i] = shade_bgra_simple(source[spot64 * 4].load_vec4ub(), light); stack_xfrac.store(xfrac + xstep); stack_yfrac.store(yfrac + ystep); @@ -181,9 +180,7 @@ void FixedFunction::CodegenDrawSpan() SSAInt spot64 = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); //SSAInt spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - //*loop.dest = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); - SSAVec4i color = source[spot64 * 4].load_vec4ub(); - color = color * light / 256; + SSAVec4i color = shade_bgra_simple(source[spot64 * 4].load_vec4ub(), light); data[index * 4].store_vec4ub(color); stack_index.store(index + 1); @@ -200,6 +197,122 @@ void FixedFunction::CodegenDrawSpan() mProgram.functionPassManager()->run(*function.func); } +SSAInt FixedFunction::calc_light_multiplier(SSAInt light) +{ + return 256 - (light >> (FRACBITS - 8)); +} + +SSAVec4i FixedFunction::shade_pal_index_simple(SSAInt index, SSAInt light, SSAUBytePtr basecolors) +{ + SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index]; + return shade_bgra_simple(color, light); +} + +SSAVec4i FixedFunction::shade_pal_index_advanced(SSAInt index, SSAInt light, const SSAShadeConstants &constants, SSAUBytePtr basecolors) +{ + SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index]; + return shade_bgra_advanced(color, light, constants); +} + +SSAVec4i FixedFunction::shade_bgra_simple(SSAVec4i color, SSAInt light) +{ + color = color * light / 256; + return color.insert(3, 255); +} + +SSAVec4i FixedFunction::shade_bgra_advanced(SSAVec4i color, SSAInt light, const SSAShadeConstants &constants) +{ + SSAInt blue = color[0]; + SSAInt green = color[1]; + SSAInt red = color[2]; + SSAInt alpha = color[3]; + + SSAInt intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; + + SSAVec4i inv_light = 256 - light; + SSAVec4i inv_desaturate = 256 - constants.desaturate; + + color = (color * inv_desaturate + intensity) / 256; + color = (constants.fade * inv_light + color * light) / 256; + color = (color * constants.light) / 256; + + return color.insert(3, alpha); +} + +SSAVec4i FixedFunction::blend_copy(SSAVec4i fg) +{ + return fg; +} + +SSAVec4i FixedFunction::blend_add(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) +{ + SSAVec4i color = (fg * srcalpha + bg * destalpha) / 256; + return color.insert(3, 255); +} + +SSAVec4i FixedFunction::blend_sub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) +{ + SSAVec4i color = (bg * destalpha - fg * srcalpha) / 256; + return color.insert(3, 255); +} + +SSAVec4i FixedFunction::blend_revsub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) +{ + SSAVec4i color = (fg * srcalpha - bg * destalpha) / 256; + return color.insert(3, 255); +} + +SSAVec4i FixedFunction::blend_alpha_blend(SSAVec4i fg, SSAVec4i bg) +{ + SSAInt alpha = fg[3]; + alpha = alpha + (alpha >> 7); // // 255 -> 256 + SSAInt inv_alpha = 256 - alpha; + SSAVec4i color = (fg * alpha + bg * inv_alpha) / 256; + return color.insert(3, 255); +} + +SSAVec4i FixedFunction::sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height) +{ + SSAInt frac_y0 = (texturefracy >> FRACBITS) * height; + SSAInt frac_y1 = ((texturefracy + one) >> FRACBITS) * height; + SSAInt y0 = frac_y0 >> FRACBITS; + SSAInt y1 = frac_y1 >> FRACBITS; + + SSAVec4i p00 = col0[y0].load_vec4ub(); + SSAVec4i p01 = col0[y1].load_vec4ub(); + SSAVec4i p10 = col1[y0].load_vec4ub(); + SSAVec4i p11 = col1[y1].load_vec4ub(); + + SSAInt inv_b = texturefracx; + SSAInt inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; + SSAInt a = 16 - inv_a; + SSAInt b = 16 - inv_b; + + return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; +} + +SSAVec4i FixedFunction::sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits) +{ + SSAInt xshift = (32 - xbits); + SSAInt yshift = (32 - ybits); + SSAInt xmask = (SSAInt(1) << xshift) - 1; + SSAInt ymask = (SSAInt(1) << yshift) - 1; + SSAInt x = xfrac >> xbits; + SSAInt y = yfrac >> ybits; + + SSAVec4i p00 = texture[(y & ymask) + ((x & xmask) << yshift)].load_vec4ub(); + SSAVec4i p01 = texture[((y + 1) & ymask) + ((x & xmask) << yshift)].load_vec4ub(); + SSAVec4i p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)].load_vec4ub(); + SSAVec4i p11 = texture[((y + 1) & ymask) + (((x + 1) & xmask) << yshift)].load_vec4ub(); + + SSAInt inv_b = (xfrac >> (xbits - 4)) & 15; + SSAInt inv_a = (yfrac >> (ybits - 4)) & 15; + SSAInt a = 16 - inv_a; + SSAInt b = 16 - inv_b; + + return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; +} + llvm::Type *FixedFunction::GetRenderArgsStruct(llvm::LLVMContext &context) { std::vector elements; diff --git a/src/r_compiler/fixedfunction/fixedfunction.h b/src/r_compiler/fixedfunction/fixedfunction.h index 3bbf05abe..40236d233 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.h +++ b/src/r_compiler/fixedfunction/fixedfunction.h @@ -6,6 +6,7 @@ #include "r_compiler/ssa/ssa_vec8s.h" #include "r_compiler/ssa/ssa_vec16ub.h" #include "r_compiler/ssa/ssa_int.h" +#include "r_compiler/ssa/ssa_int_ptr.h" #include "r_compiler/ssa/ssa_short.h" #include "r_compiler/ssa/ssa_ubyte_ptr.h" #include "r_compiler/ssa/ssa_vec4f_ptr.h" @@ -57,8 +58,30 @@ struct RenderArgs uint32_t light; uint32_t srcalpha; uint32_t destalpha; - //ShadeConstants _shade_constants; - //int32_t nearest_filter; + + uint16_t light_alpha; + uint16_t light_red; + uint16_t light_green; + uint16_t light_blue; + uint16_t fade_alpha; + uint16_t fade_red; + uint16_t fade_green; + uint16_t fade_blue; + uint16_t desaturate; + uint32_t flags; + enum Flags + { + simple_shade = 1, + nearest_filter = 2 + }; +}; + +class SSAShadeConstants +{ +public: + SSAVec4i light; + SSAVec4i fade; + SSAInt desaturate; }; class FixedFunction @@ -71,6 +94,24 @@ public: private: void CodegenDrawSpan(); + // LightBgra + SSAInt calc_light_multiplier(SSAInt light); + SSAVec4i shade_pal_index_simple(SSAInt index, SSAInt light, SSAUBytePtr basecolors); + SSAVec4i shade_pal_index_advanced(SSAInt index, SSAInt light, const SSAShadeConstants &constants, SSAUBytePtr basecolors); + SSAVec4i shade_bgra_simple(SSAVec4i color, SSAInt light); + SSAVec4i shade_bgra_advanced(SSAVec4i color, SSAInt light, const SSAShadeConstants &constants); + + // BlendBgra + SSAVec4i blend_copy(SSAVec4i fg); + SSAVec4i blend_add(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha); + SSAVec4i blend_sub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha); + SSAVec4i blend_revsub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha); + SSAVec4i blend_alpha_blend(SSAVec4i fg, SSAVec4i bg); + + // SampleBgra + SSAVec4i sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height); + SSAVec4i sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits); + static llvm::Type *GetRenderArgsStruct(llvm::LLVMContext &context); RenderProgram mProgram; diff --git a/src/r_compiler/ssa/ssa_vec4i.cpp b/src/r_compiler/ssa/ssa_vec4i.cpp index 80e07c8d4..d8e31276c 100644 --- a/src/r_compiler/ssa/ssa_vec4i.cpp +++ b/src/r_compiler/ssa/ssa_vec4i.cpp @@ -60,6 +60,16 @@ SSAInt SSAVec4i::operator[](SSAInt index) return SSAInt::from_llvm(SSAScope::builder().CreateExtractElement(v, index.v, SSAScope::hint())); } +SSAVec4i SSAVec4i::insert(SSAInt index, SSAInt value) +{ + return SSAVec4i::from_llvm(SSAScope::builder().CreateInsertElement(v, value.v, index.v, SSAScope::hint())); +} + +SSAVec4i SSAVec4i::insert(int index, SSAInt value) +{ + return SSAVec4i::from_llvm(SSAScope::builder().CreateInsertElement(v, value.v, index, SSAScope::hint())); +} + llvm::Type *SSAVec4i::llvm_type() { return llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4); diff --git a/src/r_compiler/ssa/ssa_vec4i.h b/src/r_compiler/ssa/ssa_vec4i.h index d19f1d1aa..a654a87ae 100644 --- a/src/r_compiler/ssa/ssa_vec4i.h +++ b/src/r_compiler/ssa/ssa_vec4i.h @@ -19,6 +19,8 @@ public: explicit SSAVec4i(llvm::Value *v); SSAVec4i(SSAVec4f f32); SSAInt operator[](SSAInt index); + SSAVec4i insert(SSAInt index, SSAInt value); + SSAVec4i insert(int index, SSAInt value); static SSAVec4i bitcast(SSAVec4f f32); static SSAVec4i bitcast(SSAVec8s i16); static SSAVec4i shuffle(const SSAVec4i &f0, int index0, int index1, int index2, int index3); From b75395aa74515092fd1bd55b4b32f98319ed900e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 28 Sep 2016 09:25:48 +0200 Subject: [PATCH 0994/1509] - fixed: Screen size update coordinates were copied into the wrong buffer location. --- src/gl/data/gl_vertexbuffer.cpp | 2 +- src/gl/system/gl_framebuffer.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index b18b367c3..4e76b51cb 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -221,7 +221,7 @@ void FFlatVertexBuffer::OutputResized(int width, int height) vbo_shadowdata[7].Set((float)width, (float)height, 0, 0, 0); Map(); - memcpy(map, &vbo_shadowdata[4], 4 * sizeof(FFlatVertex)); + memcpy(&map[4], &vbo_shadowdata[4], 4 * sizeof(FFlatVertex)); Unmap(); } diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 08aca521f..6264352f6 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -189,7 +189,9 @@ void OpenGLFrameBuffer::Update() int clientHeight = GetClientHeight(); if (clientWidth > 0 && clientHeight > 0 && (Width != clientWidth || Height != clientHeight)) { - Resize(clientWidth, clientHeight); + // Do not call Resize here because it's only for software canvases + Pitch = Width = clientWidth; + Height = clientHeight; V_OutputResized(Width, Height); GLRenderer->mVBO->OutputResized(Width, Height); } From 77ea195162884d0d035d0e5b1cdbe331293a8331 Mon Sep 17 00:00:00 2001 From: Marisa Heit Date: Tue, 27 Sep 2016 16:27:31 -0500 Subject: [PATCH 0995/1509] Fixed: Y and Z were flipped for sound velocity --- src/s_sound.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 866af965a..06df0dbad 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -753,8 +753,8 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, if (type == SOURCE_Actor && actor != NULL) { vel->X = float(actor->Vel.X * TICRATE); - vel->Y = float(actor->Vel.Y * TICRATE); - vel->Z = float(actor->Vel.Z * TICRATE); + vel->Y = float(actor->Vel.Z * TICRATE); + vel->Z = float(actor->Vel.Y * TICRATE); } else { From 62769fa5eaac3ea60eabdf2992005b3ba8cb9757 Mon Sep 17 00:00:00 2001 From: Marisa Heit Date: Tue, 27 Sep 2016 18:40:36 -0500 Subject: [PATCH 0996/1509] Fixed: Heretic platforms make a mid-move sound, unlike Doom's --- wadsrc/static/filter/game-heretic/sndinfo.txt | 1 + wadsrc/static/filter/game-heretic/sndseq.txt | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 wadsrc/static/filter/game-heretic/sndseq.txt diff --git a/wadsrc/static/filter/game-heretic/sndinfo.txt b/wadsrc/static/filter/game-heretic/sndinfo.txt index b9f1fd7c3..53017a49a 100644 --- a/wadsrc/static/filter/game-heretic/sndinfo.txt +++ b/wadsrc/static/filter/game-heretic/sndinfo.txt @@ -151,6 +151,7 @@ $alias switches/exitbutn switches/normbutn // Heretic has no special exit button plats/pt1_strt pstart plats/pt1_stop pstop plats/pt1_mid dormov +plats/pt2_mid stnmov // // Door Sounds diff --git a/wadsrc/static/filter/game-heretic/sndseq.txt b/wadsrc/static/filter/game-heretic/sndseq.txt new file mode 100644 index 000000000..405ebc8fb --- /dev/null +++ b/wadsrc/static/filter/game-heretic/sndseq.txt @@ -0,0 +1,5 @@ +:Platform + playuntildone plats/pt1_strt + playrepeat plats/pt2_mid + stopsound plats/pt1_stop +end From 3988a63789d14a3bf900506c888e02639e6fa715 Mon Sep 17 00:00:00 2001 From: Marisa Heit Date: Tue, 27 Sep 2016 18:58:09 -0500 Subject: [PATCH 0997/1509] Fixed: The menu no longer refreshed the screen border --- src/menu/menu.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 5e5124b2a..7e938230e 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -717,7 +717,11 @@ void M_Drawer (void) if (DMenu::CurrentMenu != NULL && menuactive != MENU_Off) { - if (DMenu::CurrentMenu->DimAllowed()) screen->Dim(fade); + if (DMenu::CurrentMenu->DimAllowed()) + { + screen->Dim(fade); + V_SetBorderNeedRefresh(); + } DMenu::CurrentMenu->Drawer(); } } From 3aea3a0beedcfcedf793a5858dba93645da46bef Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 28 Sep 2016 18:49:39 +0200 Subject: [PATCH 0998/1509] Fully implemented codegen for DrawSpan --- .../fixedfunction/fixedfunction.cpp | 1310 +++-------------- src/r_compiler/fixedfunction/fixedfunction.h | 140 +- src/r_compiler/ssa/ssa_short.cpp | 5 + src/r_compiler/ssa/ssa_short.h | 2 + src/r_compiler/ssa/ssa_vec4i.cpp | 12 + src/r_compiler/ssa/ssa_vec4i.h | 1 + src/r_draw_rgba.cpp | 92 +- 7 files changed, 337 insertions(+), 1225 deletions(-) diff --git a/src/r_compiler/fixedfunction/fixedfunction.cpp b/src/r_compiler/fixedfunction/fixedfunction.cpp index d70248864..cc53a069a 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.cpp +++ b/src/r_compiler/fixedfunction/fixedfunction.cpp @@ -92,6 +92,8 @@ void *RenderProgram::PointerToFunction(const char *name) return mEngine->getPointerToFunction(function); } +///////////////////////////////////////////////////////////////////////////// + FixedFunction::FixedFunction() { CodegenDrawSpan(); @@ -110,84 +112,8 @@ void FixedFunction::CodegenDrawSpan() function.add_parameter(GetRenderArgsStruct(mProgram.context())); function.create_public(); - SSAStack stack_index, stack_xfrac, stack_yfrac; - - SSAValue args = function.parameter(0); - SSAUBytePtr destorg = args[0][0].load(); - SSAUBytePtr source = args[0][1].load(); - SSAInt destpitch = args[0][2].load(); - stack_xfrac.store(args[0][3].load()); - stack_yfrac.store(args[0][4].load()); - SSAInt xstep = args[0][5].load(); - SSAInt ystep = args[0][6].load(); - SSAInt x1 = args[0][7].load(); - SSAInt x2 = args[0][8].load(); - SSAInt y = args[0][9].load(); - SSAInt xbits = args[0][10].load(); - SSAInt ybits = args[0][11].load(); - SSAInt light = args[0][12].load(); - SSAInt srcalpha = args[0][13].load(); - SSAInt destalpha = args[0][14].load(); - - SSAInt count = x2 - x1 + 1; - SSAUBytePtr data = destorg[(x1 + y * destpitch) * 4]; - - SSAInt yshift = 32 - ybits; - SSAInt xshift = yshift - xbits; - SSAInt xmask = ((SSAInt(1) << xbits) - 1) << ybits; - //is_64x64 = xbits == 6 && ybits == 6; - - SSAInt sseLength = count / 4; - stack_index.store(0); - { - SSAForBlock loop; - SSAInt index = stack_index.load(); - loop.loop_block(index < sseLength); - - SSAVec4i colors[4]; - for (int i = 0; i < 4; i++) - { - SSAInt xfrac = stack_xfrac.load(); - SSAInt yfrac = stack_yfrac.load(); - - // 64x64 is the most common case by far, so special case it. - SSAInt spot64 = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - //SSAInt spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - - colors[i] = shade_bgra_simple(source[spot64 * 4].load_vec4ub(), light); - - stack_xfrac.store(xfrac + xstep); - stack_yfrac.store(yfrac + ystep); - } - - SSAVec16ub ssecolors(SSAVec8s(colors[0], colors[1]), SSAVec8s(colors[2], colors[3])); - data[index * 16].store_unaligned_vec16ub(ssecolors); - - stack_index.store(index + 1); - loop.end_block(); - } - - stack_index.store(sseLength * 4); - { - SSAForBlock loop; - SSAInt index = stack_index.load(); - loop.loop_block(index < count); - - SSAInt xfrac = stack_xfrac.load(); - SSAInt yfrac = stack_yfrac.load(); - - // 64x64 is the most common case by far, so special case it. - SSAInt spot64 = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - //SSAInt spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - - SSAVec4i color = shade_bgra_simple(source[spot64 * 4].load_vec4ub(), light); - data[index * 4].store_vec4ub(color); - - stack_index.store(index + 1); - stack_xfrac.store(xfrac + xstep); - stack_yfrac.store(yfrac + ystep); - loop.end_block(); - } + DrawSpanCodegen codegen; + codegen.Generate(function.parameter(0)); builder.CreateRetVoid(); @@ -197,122 +123,6 @@ void FixedFunction::CodegenDrawSpan() mProgram.functionPassManager()->run(*function.func); } -SSAInt FixedFunction::calc_light_multiplier(SSAInt light) -{ - return 256 - (light >> (FRACBITS - 8)); -} - -SSAVec4i FixedFunction::shade_pal_index_simple(SSAInt index, SSAInt light, SSAUBytePtr basecolors) -{ - SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index]; - return shade_bgra_simple(color, light); -} - -SSAVec4i FixedFunction::shade_pal_index_advanced(SSAInt index, SSAInt light, const SSAShadeConstants &constants, SSAUBytePtr basecolors) -{ - SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index]; - return shade_bgra_advanced(color, light, constants); -} - -SSAVec4i FixedFunction::shade_bgra_simple(SSAVec4i color, SSAInt light) -{ - color = color * light / 256; - return color.insert(3, 255); -} - -SSAVec4i FixedFunction::shade_bgra_advanced(SSAVec4i color, SSAInt light, const SSAShadeConstants &constants) -{ - SSAInt blue = color[0]; - SSAInt green = color[1]; - SSAInt red = color[2]; - SSAInt alpha = color[3]; - - SSAInt intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; - - SSAVec4i inv_light = 256 - light; - SSAVec4i inv_desaturate = 256 - constants.desaturate; - - color = (color * inv_desaturate + intensity) / 256; - color = (constants.fade * inv_light + color * light) / 256; - color = (color * constants.light) / 256; - - return color.insert(3, alpha); -} - -SSAVec4i FixedFunction::blend_copy(SSAVec4i fg) -{ - return fg; -} - -SSAVec4i FixedFunction::blend_add(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) -{ - SSAVec4i color = (fg * srcalpha + bg * destalpha) / 256; - return color.insert(3, 255); -} - -SSAVec4i FixedFunction::blend_sub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) -{ - SSAVec4i color = (bg * destalpha - fg * srcalpha) / 256; - return color.insert(3, 255); -} - -SSAVec4i FixedFunction::blend_revsub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) -{ - SSAVec4i color = (fg * srcalpha - bg * destalpha) / 256; - return color.insert(3, 255); -} - -SSAVec4i FixedFunction::blend_alpha_blend(SSAVec4i fg, SSAVec4i bg) -{ - SSAInt alpha = fg[3]; - alpha = alpha + (alpha >> 7); // // 255 -> 256 - SSAInt inv_alpha = 256 - alpha; - SSAVec4i color = (fg * alpha + bg * inv_alpha) / 256; - return color.insert(3, 255); -} - -SSAVec4i FixedFunction::sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height) -{ - SSAInt frac_y0 = (texturefracy >> FRACBITS) * height; - SSAInt frac_y1 = ((texturefracy + one) >> FRACBITS) * height; - SSAInt y0 = frac_y0 >> FRACBITS; - SSAInt y1 = frac_y1 >> FRACBITS; - - SSAVec4i p00 = col0[y0].load_vec4ub(); - SSAVec4i p01 = col0[y1].load_vec4ub(); - SSAVec4i p10 = col1[y0].load_vec4ub(); - SSAVec4i p11 = col1[y1].load_vec4ub(); - - SSAInt inv_b = texturefracx; - SSAInt inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; - SSAInt a = 16 - inv_a; - SSAInt b = 16 - inv_b; - - return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; -} - -SSAVec4i FixedFunction::sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits) -{ - SSAInt xshift = (32 - xbits); - SSAInt yshift = (32 - ybits); - SSAInt xmask = (SSAInt(1) << xshift) - 1; - SSAInt ymask = (SSAInt(1) << yshift) - 1; - SSAInt x = xfrac >> xbits; - SSAInt y = yfrac >> ybits; - - SSAVec4i p00 = texture[(y & ymask) + ((x & xmask) << yshift)].load_vec4ub(); - SSAVec4i p01 = texture[((y + 1) & ymask) + ((x & xmask) << yshift)].load_vec4ub(); - SSAVec4i p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)].load_vec4ub(); - SSAVec4i p11 = texture[((y + 1) & ymask) + (((x + 1) & xmask) << yshift)].load_vec4ub(); - - SSAInt inv_b = (xfrac >> (xbits - 4)) & 15; - SSAInt inv_a = (yfrac >> (ybits - 4)) & 15; - SSAInt a = 16 - inv_a; - SSAInt b = 16 - inv_b; - - return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; -} - llvm::Type *FixedFunction::GetRenderArgsStruct(llvm::LLVMContext &context) { std::vector elements; @@ -331,953 +141,297 @@ llvm::Type *FixedFunction::GetRenderArgsStruct(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; return llvm::StructType::get(context, elements, false)->getPointerTo(); } -#if 0 +///////////////////////////////////////////////////////////////////////////// -GlslFixedFunction::GlslFixedFunction(GlslProgram &program, GlslCodeGen &vertex_codegen, GlslCodeGen &fragment_codegen) -: program(program), vertex_codegen(vertex_codegen), fragment_codegen(fragment_codegen) +void DrawSpanCodegen::Generate(SSAValue args) { -} + destorg = args[0][0].load(); + source = args[0][1].load(); + destpitch = args[0][2].load(); + stack_xfrac.store(args[0][3].load()); + stack_yfrac.store(args[0][4].load()); + xstep = args[0][5].load(); + ystep = args[0][6].load(); + x1 = args[0][7].load(); + x2 = args[0][8].load(); + y = args[0][9].load(); + xbits = args[0][10].load(); + ybits = args[0][11].load(); + light = args[0][12].load(); + srcalpha = args[0][13].load(); + destalpha = args[0][14].load(); + SSAShort light_alpha = args[0][15].load(); + SSAShort light_red = args[0][16].load(); + SSAShort light_green = args[0][17].load(); + SSAShort light_blue = args[0][18].load(); + SSAShort fade_alpha = args[0][19].load(); + SSAShort fade_red = args[0][20].load(); + SSAShort fade_green = args[0][21].load(); + SSAShort fade_blue = args[0][22].load(); + SSAShort desaturate = args[0][23].load(); + SSAInt flags = args[0][24].load(); + shade_constants.light = SSAVec4i(light_blue.zext_int(), light_green.zext_int(), light_red.zext_int(), light_alpha.zext_int()); + shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); + shade_constants.desaturate = desaturate.zext_int(); -llvm::Type *GlslFixedFunction::get_sampler_struct(llvm::LLVMContext &context) -{ - std::vector elements; - elements.push_back(llvm::Type::getInt32Ty(context)); // width - elements.push_back(llvm::Type::getInt32Ty(context)); // height - elements.push_back(llvm::Type::getInt8PtrTy(context)); // data - return llvm::StructType::get(context, elements, false); -} + count = x2 - x1 + 1; + data = destorg[(x1 + y * destpitch) * 4]; -void GlslFixedFunction::codegen() -{ - codegen_render_scanline(5); - codegen_calc_window_positions(); - codegen_calc_polygon_face_direction(); - codegen_calc_polygon_y_range(); - codegen_update_polygon_edge(); - codegen_draw_triangles(5, 5); - codegen_texture(); - codegen_normalize(); - codegen_reflect(); - codegen_max(); - codegen_pow(); - codegen_dot(); - codegen_mix(); -} + yshift = 32 - ybits; + xshift = yshift - xbits; + xmask = ((SSAInt(1) << xbits) - 1) << ybits; -void GlslFixedFunction::codegen_texture() -{ - llvm::IRBuilder<> builder(program.context()); - SSAScope ssa_scope(&program.context(), program.module(), &builder); + // 64x64 is the most common case by far, so special case it. + is_64x64 = xbits == 6 && ybits == 6; + is_simple_shade = (flags & RenderArgs::simple_shade) == RenderArgs::simple_shade; + is_nearest_filter = (flags & RenderArgs::nearest_filter) == RenderArgs::nearest_filter; - SSAFunction function("fragment_texture"); - function.add_parameter(fragment_codegen.get_global_struct_type()); - function.add_parameter(get_sampler_struct(program.context())); - function.add_parameter(SSAVec4f::llvm_type()); - function.create_private(); - - SSAValue sampler_ptr = function.parameter(1); - SSAVec4f pos = function.parameter(2); - - SSAInt width = sampler_ptr[0][0].load(); - SSAInt height = sampler_ptr[0][1].load(); - SSAUBytePtr data = sampler_ptr[0][2].load(); - - SSAPixels4ub_argb_rev pixels(width, height, data); - //builder.CreateRet(pixels.linear_clamp4f(pos).v); - builder.CreateRet(pixels.linear_clamp4f(pos[0], pos[1]).v); - - llvm::verifyFunction(*function.func); -} - -void GlslFixedFunction::codegen_normalize() -{ - llvm::IRBuilder<> builder(program.context()); - SSAScope ssa_scope(&program.context(), program.module(), &builder); - - SSAFunction function("fragment_normalize"); - function.add_parameter(fragment_codegen.get_global_struct_type()); - function.add_parameter(SSAVec4f::llvm_type()); - function.create_private(); - - SSAVec4f vec = function.parameter(1); - - // To do: this can probably be done a lot faster with _mm_rsqrt_ss - SSAVec4f vec2 = vec * vec; - SSAVec4f length3(SSAFloat::sqrt(vec2[0] + vec2[1] + vec2[2])); - SSAVec4f normalized = vec / length3; - builder.CreateRet(normalized.v); - - llvm::verifyFunction(*function.func); -} - -void GlslFixedFunction::codegen_reflect() -{ - llvm::IRBuilder<> builder(program.context()); - SSAScope ssa_scope(&program.context(), program.module(), &builder); - - SSAFunction function("fragment_reflect"); - function.add_parameter(fragment_codegen.get_global_struct_type()); - function.add_parameter(SSAVec4f::llvm_type()); - function.add_parameter(SSAVec4f::llvm_type()); - function.create_private(); - - SSAVec4f i = function.parameter(1); - SSAVec4f n = function.parameter(2); - - SSAVec4f c = i * n; - SSAFloat dot3 = c[0] + c[1] + c[2]; - SSAVec4f result = i - (2.0f * dot3) * n; - builder.CreateRet(result.v); - - llvm::verifyFunction(*function.func); -} - -void GlslFixedFunction::codegen_max() -{ - llvm::IRBuilder<> builder(program.context()); - SSAScope ssa_scope(&program.context(), program.module(), &builder); - - SSAFunction function("fragment_max"); - function.add_parameter(fragment_codegen.get_global_struct_type()); - function.add_parameter(SSAFloat::llvm_type()); - function.add_parameter(SSAFloat::llvm_type()); - function.create_private(); - - SSAFloat a = function.parameter(1); - SSAFloat b = function.parameter(2); - - SSAPhi phi; SSAIfBlock branch; - branch.if_block(a >= b); - phi.add_incoming(a); + branch.if_block(is_simple_shade); + LoopShade(true); branch.else_block(); - phi.add_incoming(b); + LoopShade(false); branch.end_block(); - SSAFloat c = phi.create(); - - builder.CreateRet(c.v); - llvm::verifyFunction(*function.func); } -void GlslFixedFunction::codegen_pow() +void DrawSpanCodegen::LoopShade(bool isSimpleShade) { - llvm::IRBuilder<> builder(program.context()); - SSAScope ssa_scope(&program.context(), program.module(), &builder); - - SSAFunction function("fragment_pow"); - function.add_parameter(fragment_codegen.get_global_struct_type()); - function.add_parameter(SSAFloat::llvm_type()); - function.add_parameter(SSAFloat::llvm_type()); - function.create_private(); - - SSAFloat a = function.parameter(1); - SSAFloat b = function.parameter(2); - builder.CreateRet(a.v); - //builder.CreateRet(SSAFloat::pow(a, b).v); - - llvm::verifyFunction(*function.func); + SSAIfBlock branch; + branch.if_block(is_nearest_filter); + LoopFilter(isSimpleShade, true); + branch.else_block(); + LoopFilter(isSimpleShade, false); + branch.end_block(); } -void GlslFixedFunction::codegen_dot() +void DrawSpanCodegen::LoopFilter(bool isSimpleShade, bool isNearestFilter) { - llvm::IRBuilder<> builder(program.context()); - SSAScope ssa_scope(&program.context(), program.module(), &builder); - - SSAFunction function("fragment_dot"); - function.add_parameter(fragment_codegen.get_global_struct_type()); - function.add_parameter(SSAVec4f::llvm_type()); - function.add_parameter(SSAVec4f::llvm_type()); - function.create_private(); - - SSAVec4f a = function.parameter(1); - SSAVec4f b = function.parameter(2); - - SSAVec4f c = a * b; - SSAFloat dot3 = c[0] + c[1] + c[2]; - builder.CreateRet(dot3.v); - - llvm::verifyFunction(*function.func); -} - -void GlslFixedFunction::codegen_mix() -{ - llvm::IRBuilder<> builder(program.context()); - SSAScope ssa_scope(&program.context(), program.module(), &builder); - - SSAFunction function("fragment_mix"); - function.add_parameter(fragment_codegen.get_global_struct_type()); - function.add_parameter(SSAVec4f::llvm_type()); - function.add_parameter(SSAVec4f::llvm_type()); - function.add_parameter(SSAFloat::llvm_type()); - function.create_private(); - - SSAVec4f v1 = function.parameter(1); - SSAVec4f v2 = function.parameter(2); - SSAFloat t = function.parameter(3); - - SSAVec4f b = t; - SSAVec4f a = 1.0f - b; - SSAVec4f mix = v1 * a + v2 * b; - builder.CreateRet(mix.v); - - llvm::verifyFunction(*function.func); -} - -void GlslFixedFunction::codegen_draw_triangles(int num_vertex_in, int num_vertex_out) -{ - llvm::IRBuilder<> builder(program.context()); - SSAScope ssa_scope(&program.context(), program.module(), &builder); - - SSAFunction function("draw_triangles"); - function.add_parameter(SSAInt::llvm_type()); // input_width - function.add_parameter(SSAInt::llvm_type()); // input_height - function.add_parameter(SSAUBytePtr::llvm_type()); // input_data - function.add_parameter(SSAInt::llvm_type()); // output_width - function.add_parameter(SSAInt::llvm_type()); // output_height - function.add_parameter(SSAUBytePtr::llvm_type()); // output_data - function.add_parameter(SSAInt::llvm_type()); // viewport_x - function.add_parameter(SSAInt::llvm_type()); // viewport_y - function.add_parameter(SSAInt::llvm_type()); // viewport_width - function.add_parameter(SSAInt::llvm_type()); // viewport_height - function.add_parameter(SSAVec4fPtr::llvm_type()); // uniforms - function.add_parameter(SSAInt::llvm_type()); // first_vertex - function.add_parameter(SSAInt::llvm_type()); // num_vertices - function.add_parameter(SSAVec4fPtr::llvm_type()->getPointerTo()); // vertex attributes - function.add_parameter(SSAInt::llvm_type()); // core - function.add_parameter(SSAInt::llvm_type()); // num_cores - function.create_public(); - - SSAInt input_width = function.parameter(0); - SSAInt input_height = function.parameter(1); - SSAUBytePtr input_data = function.parameter(2); - SSAInt output_width = function.parameter(3); - SSAInt output_height = function.parameter(4); - SSAUBytePtr output_data = function.parameter(5); - SSAInt viewport_x = function.parameter(6); - SSAInt viewport_y = function.parameter(7); - SSAInt viewport_width = function.parameter(8); - SSAInt viewport_height = function.parameter(9); - SSAVec4fPtr uniforms = function.parameter(10); - SSAInt first_vertex = function.parameter(11); - SSAInt num_vertices = function.parameter(12); - SSAValue vertex_in_ptr = function.parameter(13); - SSAInt core = function.parameter(14); - SSAInt num_cores = function.parameter(15); - - SSAStack stack_vertex_index; - SSAValue vertex_globals_ptr = SSAValue::from_llvm(SSAScope::alloca(vertex_codegen.get_global_struct_type())); - std::vector vertex_outs; - for (int i = 0; i < num_vertex_out; i++) - vertex_outs.push_back(SSAVec4fPtr::from_llvm(SSAScope::builder().CreateAlloca(SSAVec4f::llvm_type(), SSAInt(3).v))); - - int num_uniforms = 1; + SSAIfBlock branch; + branch.if_block(is_64x64); { - llvm::Type *type = llvm::ArrayType::get(llvm::VectorType::get(llvm::Type::getFloatTy(program.context()), 4), 4); - llvm::Value *matrix = llvm::UndefValue::get(type); - for (int col = 0; col < 4; col++) - { - SSAVec4f column = uniforms[col].load_unaligned(); - std::vector indexes; - indexes.push_back(col); - matrix = builder.CreateInsertValue(matrix, column.v, indexes); - } - vertex_globals_ptr[0][0].store(matrix); + SSAInt sseLength = Loop4x(isSimpleShade, isNearestFilter, true); + Loop(sseLength * 4, isSimpleShade, isNearestFilter, true); } - - stack_vertex_index.store(0); - SSAForBlock loop; - SSAInt vertex_index = stack_vertex_index.load(); - loop.loop_block(vertex_index + 2 < num_vertices); - for (int v = 0; v < 3; v++) + branch.else_block(); { - for (int i = 0; i < num_vertex_in; i++) + SSAInt sseLength = Loop4x(isSimpleShade, isNearestFilter, false); + Loop(sseLength * 4, isSimpleShade, isNearestFilter, false); + } + branch.end_block(); +} + +SSAInt DrawSpanCodegen::Loop4x(bool isSimpleShade, bool isNearestFilter, bool is64x64) +{ + SSAInt sseLength = count / 4; + stack_index.store(0); + { + SSAForBlock loop; + SSAInt index = stack_index.load(); + loop.loop_block(index < sseLength); + + SSAVec4i colors[4]; + for (int i = 0; i < 4; i++) { - SSAValue attribute_ptr = vertex_in_ptr[i].load(); - SSAVec4f vertex_in = SSAVec4f::shuffle(SSAVec4fPtr(attribute_ptr)[first_vertex + vertex_index + v].load_unaligned(), 0, 1, 2, 3); - vertex_globals_ptr[0][num_uniforms + i].store(vertex_in.v); + SSAInt xfrac = stack_xfrac.load(); + SSAInt yfrac = stack_yfrac.load(); + + SSAVec4i fg = Sample(xfrac, yfrac, isNearestFilter, is64x64); + if (isSimpleShade) + colors[i] = shade_bgra_simple(fg, light); + else + colors[i] = shade_bgra_advanced(fg, light, shade_constants); + + stack_xfrac.store(xfrac + xstep); + stack_yfrac.store(yfrac + ystep); } - SSAScope::builder().CreateCall(SSAScope::module()->getFunction((vertex_codegen.shader_prefix() + "main").c_str()), vertex_globals_ptr.v); - for (int i = 0; i < num_vertex_out; i++) + + SSAVec16ub ssecolors(SSAVec8s(colors[0], colors[1]), SSAVec8s(colors[2], colors[3])); + data[index * 16].store_unaligned_vec16ub(ssecolors); + + stack_index.store(index + 1); + loop.end_block(); + } + return sseLength; +} + +void DrawSpanCodegen::Loop(SSAInt start, bool isSimpleShade, bool isNearestFilter, bool is64x64) +{ + stack_index.store(start); + { + SSAForBlock loop; + SSAInt index = stack_index.load(); + loop.loop_block(index < count); + + SSAInt xfrac = stack_xfrac.load(); + SSAInt yfrac = stack_yfrac.load(); + + SSAVec4i fg = Sample(xfrac, yfrac, isNearestFilter, is64x64); + SSAVec4i color; + if (isSimpleShade) + color = shade_bgra_simple(fg, light); + else + color = shade_bgra_advanced(fg, light, shade_constants); + + data[index * 4].store_vec4ub(color); + + stack_index.store(index + 1); + stack_xfrac.store(xfrac + xstep); + stack_yfrac.store(yfrac + ystep); + loop.end_block(); + } +} + +SSAVec4i DrawSpanCodegen::Sample(SSAInt xfrac, SSAInt yfrac, bool isNearestFilter, bool is64x64) +{ + if (isNearestFilter) + { + SSAInt spot; + if (is64x64) + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + else + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + return source[spot * 4].load_vec4ub(); + } + else + { + if (is64x64) { - vertex_outs[i][v].store(vertex_globals_ptr[0][num_uniforms + num_vertex_in + i].load()); + return sample_linear(source, xfrac, yfrac, 26, 26); + } + else + { + return sample_linear(source, xfrac, yfrac, 32 - xbits, 32 - ybits); } } - - render_polygon(input_width, input_height, input_data, output_width, output_height, output_data, viewport_x, viewport_y, viewport_width, viewport_height, 3, vertex_outs, core, num_cores); - - stack_vertex_index.store(vertex_index + 3); - loop.end_block(); - - builder.CreateRetVoid(); - llvm::verifyFunction(*function.func); } -void GlslFixedFunction::codegen_calc_window_positions() +///////////////////////////////////////////////////////////////////////////// + +SSAInt DrawerCodegen::calc_light_multiplier(SSAInt light) { - llvm::IRBuilder<> builder(program.context()); - SSAScope ssa_scope(&program.context(), program.module(), &builder); - - SSAFunction function("calc_window_positions"); - function.add_parameter(SSAInt::llvm_type()); // viewport_x - function.add_parameter(SSAInt::llvm_type()); // viewport_y - function.add_parameter(SSAInt::llvm_type()); // viewport_width - function.add_parameter(SSAInt::llvm_type()); // viewport_height - function.add_parameter(SSAInt::llvm_type()); // num_vertices - function.add_parameter(SSAVec4fPtr::llvm_type()); // gl_Position - function.add_parameter(SSAVec4fPtr::llvm_type()); // window_pos - function.create_private(); - SSAInt viewport_x = function.parameter(0); - SSAInt viewport_y = function.parameter(1); - SSAInt viewport_width = function.parameter(2); - SSAInt viewport_height = function.parameter(3); - SSAInt num_vertices = function.parameter(4); - SSAVec4fPtr clip_positions = function.parameter(5); - SSAVec4fPtr window_positions = function.parameter(6); - - SSAViewport viewport(viewport_x, viewport_y, viewport_width, viewport_height); - SSAStack stack_transform_index; - stack_transform_index.store(0); - SSAForBlock loop_transform; - SSAInt transform_index = stack_transform_index.load(); - loop_transform.loop_block(transform_index < num_vertices); - { - SSAVec4f clip_pos = clip_positions[transform_index].load(); - SSAVec4f window_pos = viewport.clip_to_window(clip_pos); - window_positions[transform_index].store(window_pos); - - stack_transform_index.store(transform_index + 1); - } - loop_transform.end_block(); - - builder.CreateRetVoid(); - llvm::verifyFunction(*function.func); + return 256 - (light >> (FRACBITS - 8)); } -void GlslFixedFunction::codegen_calc_polygon_face_direction() +SSAVec4i DrawerCodegen::shade_pal_index_simple(SSAInt index, SSAInt light, SSAUBytePtr basecolors) { - llvm::IRBuilder<> builder(program.context()); - SSAScope ssa_scope(&program.context(), program.module(), &builder); - - SSAFunction function("calc_polygon_face_direction"); - function.set_return_type(SSABool::llvm_type()); - function.add_parameter(SSAInt::llvm_type()); // num_vertices - function.add_parameter(SSAVec4fPtr::llvm_type()); // window_pos - function.create_private(); - SSAInt num_vertices = function.parameter(0); - SSAVec4fPtr window_positions = function.parameter(1); - - SSAStack stack_face_direction; - SSAStack stack_face_vertex_index; - stack_face_direction.store(0.0f); - stack_face_vertex_index.store(0); - SSAForBlock loop_face_direction; - SSAInt face_vertex_index = stack_face_vertex_index.load(); - loop_face_direction.loop_block(face_vertex_index < num_vertices); - { - SSAVec4f v0 = window_positions[face_vertex_index].load(); - SSAVec4f v1 = window_positions[(face_vertex_index + 1) % num_vertices].load(); - stack_face_direction.store(stack_face_direction.load() + v0[0] * v1[1] - v1[0] * v0[1]); - stack_face_vertex_index.store(face_vertex_index + 1); - } - loop_face_direction.end_block(); - SSABool front_facing_ccw = (stack_face_direction.load() >= 0.0f); - - builder.CreateRet(front_facing_ccw.v); - llvm::verifyFunction(*function.func); + SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index]; + return shade_bgra_simple(color, light); } -void GlslFixedFunction::codegen_calc_polygon_y_range() +SSAVec4i DrawerCodegen::shade_pal_index_advanced(SSAInt index, SSAInt light, const SSAShadeConstants &constants, SSAUBytePtr basecolors) { - llvm::IRBuilder<> builder(program.context()); - SSAScope ssa_scope(&program.context(), program.module(), &builder); - - SSAFunction function("calc_polygon_y_range"); - function.add_parameter(SSAInt::llvm_type()); // viewport_y - function.add_parameter(SSAInt::llvm_type()); // viewport_height - function.add_parameter(SSAInt::llvm_type()); // num_vertices - function.add_parameter(SSAVec4fPtr::llvm_type()); // window_pos - function.add_parameter(SSAInt::llvm_type()->getPointerTo()); // out_y_start - function.add_parameter(SSAInt::llvm_type()->getPointerTo()); // out_y_end - function.create_private(); - SSAInt viewport_y = function.parameter(0); - SSAInt viewport_height = function.parameter(1); - SSAInt num_vertices = function.parameter(2); - SSAVec4fPtr window_positions = function.parameter(3); - SSAValue out_y_start = function.parameter(4); - SSAValue out_y_end = function.parameter(5); - - SSAStack y_start; - SSAStack y_end; - y_start.store(0x7fffffff); - y_end.store(0); - - SSAStack stack_minmax_index; - stack_minmax_index.store(0); - SSAForBlock loop_minmax; - SSAInt minmax_index = stack_minmax_index.load(); - loop_minmax.loop_block(minmax_index < num_vertices); - { - SSAInt y = SSAInt(window_positions[minmax_index].load()[1] + 0.5f); - y_start.store(ssa_min(y_start.load(), y)); - y_end.store(ssa_max(y_end.load(), y)); - stack_minmax_index.store(minmax_index + 1); - } - loop_minmax.end_block(); - - y_start.store(ssa_max(y_start.load(), viewport_y)); - y_end.store(ssa_min(y_end.load(), viewport_y + viewport_height)); - - out_y_start.store(y_start.load().v); - out_y_end.store(y_end.load().v); - builder.CreateRetVoid(); - llvm::verifyFunction(*function.func); + SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index]; + return shade_bgra_advanced(color, light, constants); } -void GlslFixedFunction::codegen_update_polygon_edge() +SSAVec4i DrawerCodegen::shade_bgra_simple(SSAVec4i color, SSAInt light) { - llvm::IRBuilder<> builder(program.context()); - SSAScope ssa_scope(&program.context(), program.module(), &builder); - - SSAFunction function("update_polygon_edge"); - function.add_parameter(SSAFloat::llvm_type()); // y_position - function.add_parameter(SSAInt::llvm_type()); // num_vertices - function.add_parameter(SSAVec4fPtr::llvm_type()); // window_pos - function.add_parameter(SSAInt::llvm_type()->getPointerTo()); // inout left_index - function.add_parameter(SSAInt::llvm_type()->getPointerTo()); // inout right_index - function.create_private(); - SSAFloat float_y = function.parameter(0); - SSAInt num_vertices = function.parameter(1); - SSAVec4fPtr window_positions = function.parameter(2); - SSAValue ptr_left_index = function.parameter(3); - SSAValue ptr_right_index = function.parameter(4); - - SSAStack max_iterate; - max_iterate.store(num_vertices); - SSAForBlock loop_left; - SSAInt left_index = ptr_left_index.load(); - SSAInt right_index = ptr_right_index.load(); - SSAInt next_left_index = (left_index + 1) % num_vertices; - SSAFloat left_y0 = window_positions[left_index].load()[1]; - SSAFloat left_y1 = window_positions[next_left_index].load()[1]; - SSABool in_range = (left_y0 >= float_y && left_y1 < float_y) || (left_y1 >= float_y && left_y0 < float_y); - loop_left.loop_block((left_index == right_index || !in_range) && max_iterate.load() > 0); - ptr_left_index.store(next_left_index.v); - max_iterate.store(max_iterate.load() - 1); - loop_left.end_block(); - - builder.CreateRetVoid(); - llvm::verifyFunction(*function.func); + color = color * light / 256; + return color.insert(3, 255); } -void GlslFixedFunction::render_polygon( - SSAInt input_width, - SSAInt input_height, - SSAUBytePtr input_data, - SSAInt output_width, - SSAInt output_height, - SSAUBytePtr output_data, - SSAInt viewport_x, - SSAInt viewport_y, - SSAInt viewport_width, - SSAInt viewport_height, - SSAInt num_vertices, - std::vector fragment_ins, - SSAInt core, - SSAInt num_cores) +SSAVec4i DrawerCodegen::shade_bgra_advanced(SSAVec4i color, SSAInt light, const SSAShadeConstants &constants) { - SSAVec4fPtr window_positions = SSAVec4fPtr::from_llvm(SSAScope::alloca(SSAVec4f::llvm_type(), num_vertices)); - SSAVec4fPtr left_line_varyings = SSAVec4fPtr::from_llvm(SSAScope::alloca(SSAVec4f::llvm_type(), fragment_ins.size())); - SSAVec4fPtr right_line_varyings = SSAVec4fPtr::from_llvm(SSAScope::alloca(SSAVec4f::llvm_type(), fragment_ins.size())); + SSAInt blue = color[0]; + SSAInt green = color[1]; + SSAInt red = color[2]; + SSAInt alpha = color[3]; - /////////////////////////////////// + SSAInt intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; - llvm::Value *calc_window_positions_args[] = { viewport_x.v, viewport_y.v, viewport_width.v, viewport_height.v, num_vertices.v, fragment_ins[0].v, window_positions.v }; - SSAScope::builder().CreateCall(SSAScope::module()->getFunction("calc_window_positions"), calc_window_positions_args); + SSAVec4i inv_light = 256 - light; + SSAVec4i inv_desaturate = 256 - constants.desaturate; - llvm::Value *calc_polygon_face_direction_args[] = { num_vertices.v, window_positions.v }; - SSABool front_facing_ccw = SSABool::from_llvm(SSAScope::builder().CreateCall(SSAScope::module()->getFunction("calc_polygon_face_direction"), calc_polygon_face_direction_args)); + color = (color * inv_desaturate + intensity) / 256; + color = (constants.fade * inv_light + color * light) / 256; + color = (color * constants.light) / 256; - SSAIfBlock cull_if; - cull_if.if_block(front_facing_ccw); - { - SSAViewport viewport(viewport_x, viewport_y, viewport_width, viewport_height); - - SSAStack y_start; - SSAStack y_end; - - llvm::Value *calc_polygon_y_range_args[] = { viewport_y.v, viewport_height.v, num_vertices.v, window_positions.v, y_start.v, y_end.v }; - SSAScope::builder().CreateCall(SSAScope::module()->getFunction("calc_polygon_y_range"), calc_polygon_y_range_args); - - y_start.store((y_start.load() + num_cores - core - 1) / num_cores * num_cores + core); // find_first_line_for_core - - SSAStack stack_left_index; - SSAStack stack_right_index; - SSAStack stack_int_y; - stack_left_index.store(0); - stack_right_index.store(1); - stack_int_y.store(y_start.load()); - SSAForBlock scanlines_loop; - scanlines_loop.loop_block(stack_int_y.load() < y_end.load()); - { - SSAInt int_y = stack_int_y.load(); - SSAFloat float_y = SSAFloat(int_y) + 0.5f; - - llvm::Value *update_polygon_edge_args0[] = { float_y.v, num_vertices.v, window_positions.v, stack_left_index.v, stack_right_index.v }; - llvm::Value *update_polygon_edge_args1[] = { float_y.v, num_vertices.v, window_positions.v, stack_right_index.v, stack_left_index.v }; - SSAScope::builder().CreateCall(SSAScope::module()->getFunction("update_polygon_edge"), update_polygon_edge_args0); - SSAScope::builder().CreateCall(SSAScope::module()->getFunction("update_polygon_edge"), update_polygon_edge_args1); - - SSAInt left_index = stack_left_index.load(); - SSAInt right_index = stack_right_index.load(); - SSAInt next_left_index = (left_index + 1) % num_vertices; - SSAInt next_right_index = (right_index + 1) % num_vertices; - - SSABarycentricWeight left_weight(viewport, fragment_ins[0][left_index].load(), fragment_ins[0][next_left_index].load()); - SSABarycentricWeight right_weight(viewport, fragment_ins[0][right_index].load(), fragment_ins[0][next_right_index].load()); - - SSAFloat a = left_weight.from_window_y(int_y); - SSAFloat b = right_weight.from_window_y(int_y); - - SSAVec4f left_clip_pos = left_weight.v1 * a + left_weight.v2 * (1.0f - a); - SSAVec4f right_clip_pos = right_weight.v1 * b + right_weight.v2 * (1.0f - b); - - for (size_t i = 0; i + 1 < fragment_ins.size(); i++) - { - left_line_varyings[i].store(fragment_ins[i + 1][left_index].load() * a + fragment_ins[i + 1][next_left_index].load() * (1.0f - a)); - right_line_varyings[i].store(fragment_ins[i + 1][right_index].load() * b + fragment_ins[i + 1][next_right_index].load() * (1.0f - b)); - } - - llvm::Value *render_scanline_args[] = { output_width.v, output_height.v, output_data.v, viewport_x.v, viewport_y.v, viewport_width.v, viewport_height.v, int_y.v, left_clip_pos.v, right_clip_pos.v, left_line_varyings.v, right_line_varyings.v, input_width.v, input_height.v, input_data.v }; - SSAScope::builder().CreateCall(SSAScope::module()->getFunction("render_scanline"), render_scanline_args); - - stack_int_y.store(stack_int_y.load() + num_cores); - } - scanlines_loop.end_block(); - } - cull_if.end_block(); + return color.insert(3, alpha); } -void GlslFixedFunction::codegen_render_scanline(int num_varyings) +SSAVec4i DrawerCodegen::blend_copy(SSAVec4i fg) { - llvm::IRBuilder<> builder(program.context()); - SSAScope ssa_scope(&program.context(), program.module(), &builder); - - SSAFunction function("render_scanline"); - function.add_parameter(SSAInt::llvm_type()); // output_width - function.add_parameter(SSAInt::llvm_type()); // output_height - function.add_parameter(SSAUBytePtr::llvm_type()); // output_data - function.add_parameter(SSAInt::llvm_type()); // viewport_x - function.add_parameter(SSAInt::llvm_type()); // viewport_y - function.add_parameter(SSAInt::llvm_type()); // viewport_width - function.add_parameter(SSAInt::llvm_type()); // viewport_height - function.add_parameter(SSAInt::llvm_type()); // y - function.add_parameter(SSAVec4f::llvm_type()); // left_clip_pos - function.add_parameter(SSAVec4f::llvm_type()); // right_clip_pos - function.add_parameter(SSAVec4fPtr::llvm_type()); // left_line_varyings - function.add_parameter(SSAVec4fPtr::llvm_type()); // right_line_varyings - function.add_parameter(SSAInt::llvm_type()); // input_width - function.add_parameter(SSAInt::llvm_type()); // input_height - function.add_parameter(SSAUBytePtr::llvm_type()); // input_data - function.create_private(); - SSAInt output_width = function.parameter(0); - SSAInt output_height = function.parameter(1); - SSAUBytePtr output_data = function.parameter(2); - SSAInt viewport_x = function.parameter(3); - SSAInt viewport_y = function.parameter(4); - SSAInt viewport_width = function.parameter(5); - SSAInt viewport_height = function.parameter(6); - SSAInt y = function.parameter(7); - SSAVec4f left_clip_pos = function.parameter(8); - SSAVec4f right_clip_pos = function.parameter(9); - SSAVec4fPtr left_line_varyings = function.parameter(10); - SSAVec4fPtr right_line_varyings = function.parameter(11); - SSAInt input_width = function.parameter(12); - SSAInt input_height = function.parameter(13); - SSAUBytePtr input_data = function.parameter(14); - - SSAViewport viewport(viewport_x, viewport_y, viewport_width, viewport_height); - - SSAScopeHint hint; - - SSAStack stack_x; - SSAStack stack_xnormalized; - - //////////////////////////////// - // Prepare to render scanline: - - hint.set("prepare"); - OuterData outer_data; - - SSAVec4f left_window_pos = viewport.clip_to_window(left_clip_pos); - SSAVec4f right_window_pos = viewport.clip_to_window(right_clip_pos); - - SSAFloat x0 = left_window_pos[0]; - SSAFloat x1 = right_window_pos[0]; - SSAInt start(ssa_min(x0, x1)); - SSAInt end(ssa_max(x1, x0) + 0.5f); - - start = ssa_max(start, viewport.x); - end = ssa_min(end, viewport.right); - - SSABarycentricWeight weight_scanline(viewport, left_clip_pos, right_clip_pos); - - outer_data.start = start; - outer_data.end = end; - outer_data.input_width = input_width; - outer_data.input_height = input_height; - outer_data.output_width = output_width; - outer_data.output_height = output_height; - outer_data.input_pixels = input_data; - outer_data.output_pixels_line = output_data[output_width * y * 4]; - - outer_data.viewport_x = SSAFloat(viewport.x); - outer_data.viewport_rcp_half_width = viewport.rcp_half_width; - outer_data.dx = weight_scanline.v2[0] - weight_scanline.v1[0]; - outer_data.dw = weight_scanline.v2[3] - weight_scanline.v1[3]; - outer_data.v1w = weight_scanline.v1[3]; - outer_data.v1x = weight_scanline.v1[0]; - outer_data.sse_left_varying_in = left_line_varyings; - outer_data.sse_right_varying_in = right_line_varyings; - outer_data.num_varyings = num_varyings; - - outer_data.sampler = SSAScope::alloca(get_sampler_struct(SSAScope::context())); - std::vector index_list; - index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); - index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); - llvm::Value *sampler_width_ptr = SSAScope::builder().CreateGEP(outer_data.sampler, index_list); - index_list[1] = llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)1)); - llvm::Value *sampler_height_ptr = SSAScope::builder().CreateGEP(outer_data.sampler, index_list); - index_list[1] = llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)2)); - llvm::Value *sampler_data_ptr = SSAScope::builder().CreateGEP(outer_data.sampler, index_list); - SSAScope::builder().CreateStore(outer_data.input_width.v, sampler_width_ptr, false); - SSAScope::builder().CreateStore(outer_data.input_height.v, sampler_height_ptr, false); - SSAScope::builder().CreateStore(outer_data.input_pixels.v, sampler_data_ptr, false); - - - SSAVec4i xposinit = SSAVec4i(outer_data.start) + SSAVec4i(0, 1, 2, 3); - stack_x.store(outer_data.start); - stack_xnormalized.store((SSAVec4f(xposinit) + 0.5f - outer_data.viewport_x) * outer_data.viewport_rcp_half_width - 1.0f); - - ///////////////////////////////////////////////////////////////////////// - // First pixels: - - hint.set("firstpixels"); - SSAIfBlock if_block; - if_block.if_block(outer_data.end - outer_data.start > 3); - process_first_pixels(outer_data, stack_x, stack_xnormalized); - if_block.end_block(); - - ///////////////////////////////////////////////////////////////////////// - // Start: for (SSAInt x = start; x < end; x += 4) - - hint.set("loopstart"); - - SSAForBlock for_block; - SSAInt x = stack_x.load(); - for_block.loop_block(x + 3 < outer_data.end); - - ///////////////////////////////////////////////////////////////////////// - // Loop body - { - SSAVec4f xnormalized = stack_xnormalized.load(); - - hint.set("blendload"); - SSAVec4i desti[4]; - SSAVec16ub dest_block = outer_data.output_pixels_line[x << 2].load_vec16ub(); - SSAVec4i::extend(dest_block, desti[0], desti[1], desti[2], desti[3]); - - SSAVec4f frag_colors[4]; - inner_block(outer_data, xnormalized, frag_colors); - blend(frag_colors, dest_block); - - hint.set("blendstore"); - outer_data.output_pixels_line[x << 2].store_vec16ub(dest_block); - hint.clear(); - - xnormalized = xnormalized + 4.0f * outer_data.viewport_rcp_half_width; - stack_xnormalized.store(xnormalized); - } - ///////////////////////////////////////////////////////////////////////// - // End: for (SSAInt x = start; x < end; x += 4) - - hint.set("loopend"); - x = x + 4; - stack_x.store(x); - for_block.end_block(); - - ///////////////////////////////////////////////////////////////////////// - // Last pixels: - - hint.set("lastpixels"); - process_last_pixels(outer_data, stack_x, stack_xnormalized); - - builder.CreateRetVoid(); - llvm::verifyFunction(*function.func); + return fg; } -void GlslFixedFunction::process_first_pixels(OuterData &outer_data, SSAStack &stack_x, SSAStack &stack_xnormalized) +SSAVec4i DrawerCodegen::blend_add(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) { - SSAInt x = stack_x.load(); - SSAVec4f xnormalized = stack_xnormalized.load(); - SSAInt offset = x << 2; - - // Find how many pixels we have left until we 16 byte align: - llvm::Value *output_line_align = SSAScope::builder().CreatePtrToInt(outer_data.output_pixels_line.v, llvm::Type::getInt32Ty(SSAScope::context())); - output_line_align = SSAScope::builder().CreateAdd(output_line_align, offset.v); - SSAInt left = 4 - (SSAInt::from_llvm(SSAScope::builder().CreateURem(output_line_align, SSAInt(16).v)) >> 2); - - SSAIfBlock if_block0; - if_block0.if_block(left == 3); - { - SSAVec4i dest[4] = - { - outer_data.output_pixels_line[offset].load_vec4ub(), - outer_data.output_pixels_line[offset + 4].load_vec4ub(), - outer_data.output_pixels_line[offset + 8].load_vec4ub(), - SSAVec4i(0) - }; - - // To do: do this in a less braindead way - SSAVec16ub dest_block(SSAVec8s(dest[0], dest[1]), SSAVec8s(dest[2], dest[3])); - SSAVec4f frag_colors[4]; - inner_block(outer_data, xnormalized, frag_colors); - blend(frag_colors, dest_block); - SSAVec4i::extend(dest_block, dest[0], dest[1], dest[2], dest[3]); - - outer_data.output_pixels_line[offset].store_vec4ub(dest[0]); - outer_data.output_pixels_line[offset + 4].store_vec4ub(dest[1]); - outer_data.output_pixels_line[offset + 8].store_vec4ub(dest[2]); - - stack_x.store(x + 3); - stack_xnormalized.store(xnormalized + 3.0f * outer_data.viewport_rcp_half_width); - } - if_block0.else_block(); - { - SSAIfBlock if_block1; - if_block1.if_block(left == 2); - { - SSAVec4i dest[4] = - { - outer_data.output_pixels_line[offset].load_vec4ub(), - outer_data.output_pixels_line[offset + 4].load_vec4ub(), - SSAVec4i(0), - SSAVec4i(0) - }; - - // To do: do this in a less braindead way - SSAVec16ub dest_block(SSAVec8s(dest[0], dest[1]), SSAVec8s(dest[2], dest[3])); - SSAVec4f frag_colors[4]; - inner_block(outer_data, xnormalized, frag_colors); - blend(frag_colors, dest_block); - SSAVec4i::extend(dest_block, dest[0], dest[1], dest[2], dest[3]); - - outer_data.output_pixels_line[offset].store_vec4ub(dest[0]); - outer_data.output_pixels_line[offset + 4].store_vec4ub(dest[1]); - - stack_x.store(x + 2); - stack_xnormalized.store(xnormalized + 2.0f * outer_data.viewport_rcp_half_width); - } - if_block1.else_block(); - { - SSAIfBlock if_block2; - if_block2.if_block(left == 1); - { - SSAVec4i dest[4] = - { - outer_data.output_pixels_line[offset].load_vec4ub(), - SSAVec4i(0), - SSAVec4i(0), - SSAVec4i(0) - }; - - // To do: do this in a less braindead way - SSAVec16ub dest_block(SSAVec8s(dest[0], dest[1]), SSAVec8s(dest[2], dest[3])); - SSAVec4f frag_colors[4]; - inner_block(outer_data, xnormalized, frag_colors); - blend(frag_colors, dest_block); - SSAVec4i::extend(dest_block, dest[0], dest[1], dest[2], dest[3]); - - outer_data.output_pixels_line[offset].store_vec4ub(dest[0]); - - stack_x.store(x + 1); - stack_xnormalized.store(xnormalized + outer_data.viewport_rcp_half_width); - } - if_block2.end_block(); - } - if_block1.end_block(); - } - if_block0.end_block(); + SSAVec4i color = (fg * srcalpha + bg * destalpha) / 256; + return color.insert(3, 255); } -void GlslFixedFunction::process_last_pixels(OuterData &outer_data, SSAStack &stack_x, SSAStack &stack_xnormalized) +SSAVec4i DrawerCodegen::blend_sub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) { - SSAInt x = stack_x.load(); - SSAVec4f xnormalized = stack_xnormalized.load(); - - SSAInt left = outer_data.end - x; - SSAInt offset = x << 2; - SSAIfBlock if_block0; - SSAIfBlock if_block1; - SSAIfBlock if_block2; - if_block0.if_block(left == 3); - { - SSAVec4i dest[4] = - { - outer_data.output_pixels_line[offset].load_vec4ub(), - outer_data.output_pixels_line[offset + 4].load_vec4ub(), - outer_data.output_pixels_line[offset + 8].load_vec4ub(), - SSAVec4i(0) - }; - - // To do: do this in a less braindead way - SSAVec16ub dest_block(SSAVec8s(dest[0], dest[1]), SSAVec8s(dest[2], dest[3])); - SSAVec4f frag_colors[4]; - inner_block(outer_data, xnormalized, frag_colors); - blend(frag_colors, dest_block); - SSAVec4i::extend(dest_block, dest[0], dest[1], dest[2], dest[3]); - - outer_data.output_pixels_line[offset].store_vec4ub(dest[0]); - outer_data.output_pixels_line[offset + 4].store_vec4ub(dest[1]); - outer_data.output_pixels_line[offset + 8].store_vec4ub(dest[2]); - } - if_block0.else_block(); - if_block1.if_block(left == 2); - { - SSAVec4i dest[4] = - { - outer_data.output_pixels_line[offset].load_vec4ub(), - outer_data.output_pixels_line[offset + 4].load_vec4ub(), - SSAVec4i(0), - SSAVec4i(0) - }; - - // To do: do this in a less braindead way - SSAVec16ub dest_block(SSAVec8s(dest[0], dest[1]), SSAVec8s(dest[2], dest[3])); - SSAVec4f frag_colors[4]; - inner_block(outer_data, xnormalized, frag_colors); - blend(frag_colors, dest_block); - SSAVec4i::extend(dest_block, dest[0], dest[1], dest[2], dest[3]); - - outer_data.output_pixels_line[offset].store_vec4ub(dest[0]); - outer_data.output_pixels_line[offset + 4].store_vec4ub(dest[1]); - } - if_block1.else_block(); - if_block2.if_block(left == 1); - { - SSAVec4i dest[4] = - { - outer_data.output_pixels_line[offset].load_vec4ub(), - SSAVec4i(0), - SSAVec4i(0), - SSAVec4i(0) - }; - - // To do: do this in a less braindead way - SSAVec16ub dest_block(SSAVec8s(dest[0], dest[1]), SSAVec8s(dest[2], dest[3])); - SSAVec4f frag_colors[4]; - inner_block(outer_data, xnormalized, frag_colors); - blend(frag_colors, dest_block); - SSAVec4i::extend(dest_block, dest[0], dest[1], dest[2], dest[3]); - - outer_data.output_pixels_line[offset].store_vec4ub(dest[0]); - } - if_block2.end_block(); - if_block1.end_block(); - if_block0.end_block(); + SSAVec4i color = (bg * destalpha - fg * srcalpha) / 256; + return color.insert(3, 255); } -void GlslFixedFunction::inner_block(OuterData &data, SSAVec4f xnormalized, SSAVec4f *frag_color) +SSAVec4i DrawerCodegen::blend_revsub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) { - SSAScopeHint hint; - hint.set("varying"); - SSAVec4f a = (xnormalized * data.v1w - data.v1x) * SSAVec4f::rcp(data.dx - xnormalized * data.dw); - SSAVec4f one_minus_a = 1.0f - a; - - llvm::Value *globals_ptr[4]; - for (int i = 0; i < 4; i++) - { - globals_ptr[i] = SSAScope::alloca(fragment_codegen.get_global_struct_type()); - - std::vector index_list; - index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); - index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); - llvm::Value *sampler_ptr = SSAScope::builder().CreateGEP(globals_ptr[i], index_list); - SSAScope::builder().CreateStore(data.sampler, sampler_ptr, false); - - for (int j = 0; j < data.num_varyings; j++) - { - SSAVec4f field_value = - data.sse_left_varying_in[j].load() * SSAVec4f::shuffle(one_minus_a, i, i, i, i) + - data.sse_right_varying_in[j].load() * SSAVec4f::shuffle(a, i, i, i, i); - index_list.clear(); - index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); - index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)j+1))); - llvm::Value *field_ptr = SSAScope::builder().CreateGEP(globals_ptr[i], index_list); - SSAScope::builder().CreateStore(field_value.v, field_ptr, false); - } - } - - hint.set("fragprogram"); - for (int i = 0; i < 4; i++) - { - SSAScope::builder().CreateCall(SSAScope::module()->getFunction((fragment_codegen.shader_prefix() + "main").c_str()), globals_ptr[i]); - - std::vector index_list; - index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); - index_list.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)5))); - llvm::Value *field_ptr = SSAScope::builder().CreateGEP(globals_ptr[i], index_list); - frag_color[i] = SSAVec4f::from_llvm(SSAScope::builder().CreateLoad(field_ptr, false)); - } + SSAVec4i color = (fg * srcalpha - bg * destalpha) / 256; + return color.insert(3, 255); } -/* -void GlslFixedFunction::blend(SSAVec4f frag_color[4], SSAVec16ub &dest) + +SSAVec4i DrawerCodegen::blend_alpha_blend(SSAVec4i fg, SSAVec4i bg) { - SSAVec4i desti[4]; - SSAVec4i::extend(dest, desti[0], desti[1], desti[2], desti[3]); - - // Pre-mulitiplied alpha blend: - for (int pixel_index = 0; pixel_index < 4; pixel_index++) - { - SSAVec4f src = SSAVec4f::shuffle(frag_color[pixel_index], 2, 1, 0, 3); - desti[pixel_index] = SSAVec4i(src * 255.0f); - SSAVec4f dest = SSAVec4f(desti[pixel_index]) * (1.0f / 255.0f); - SSAVec4f alpha = SSAVec4f::shuffle(dest, 3, 3, 3, 3); - SSAVec4f resultf = src + dest * (1.0f - alpha); - desti[pixel_index] = SSAVec4i(resultf * 255.0f); - } - - dest = SSAVec16ub(SSAVec8s(desti[0], desti[1]), SSAVec8s(desti[2], desti[3])); + SSAInt alpha = fg[3]; + alpha = alpha + (alpha >> 7); // // 255 -> 256 + SSAInt inv_alpha = 256 - alpha; + SSAVec4i color = (fg * alpha + bg * inv_alpha) / 256; + return color.insert(3, 255); } -*/ -void GlslFixedFunction::blend(SSAVec4f frag_color[4], SSAVec16ub &dest) + +SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height) { - for (int i = 0; i < 4; i++) - frag_color[i] = SSAVec4f::shuffle(frag_color[i], 2, 1, 0, 3); + SSAInt frac_y0 = (texturefracy >> FRACBITS) * height; + SSAInt frac_y1 = ((texturefracy + one) >> FRACBITS) * height; + SSAInt y0 = frac_y0 >> FRACBITS; + SSAInt y1 = frac_y1 >> FRACBITS; - // Pre-mulitiplied alpha blend: - SSAVec8s dest0 = SSAVec8s::extendlo(dest); - SSAVec8s dest1 = SSAVec8s::extendhi(dest); + SSAVec4i p00 = col0[y0].load_vec4ub(); + SSAVec4i p01 = col0[y1].load_vec4ub(); + SSAVec4i p10 = col1[y0].load_vec4ub(); + SSAVec4i p11 = col1[y1].load_vec4ub(); - SSAVec8s src0(SSAVec4i(frag_color[0] * 255.0f), SSAVec4i(frag_color[1] * 255.0f)); - SSAVec8s src1(SSAVec4i(frag_color[2] * 255.0f), SSAVec4i(frag_color[3] * 255.0f)); + SSAInt inv_b = texturefracx; + SSAInt inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; + SSAInt a = 16 - inv_a; + SSAInt b = 16 - inv_b; - // Extract and duplicate alpha components: - SSAVec8s alpha0 = SSAVec8s::shuffle(src0, 3, 3, 3, 3, 7, 7, 7, 7); - SSAVec8s alpha1 = SSAVec8s::shuffle(src1, 3, 3, 3, 3, 7, 7, 7, 7); - - // Convert from 0-255 to 0-256 range: - alpha0 = SSAVec8s::max_sse2(alpha0, 255); - alpha1 = SSAVec8s::max_sse2(alpha1, 255); - alpha0 = alpha0 + (alpha0 >> 7); - alpha1 = alpha1 + (alpha1 >> 7); - - SSAVec8s result0 = src0 + ((dest0 * (256 - alpha0)) >> 8); - SSAVec8s result1 = src1 + ((dest1 * (256 - alpha1)) >> 8); - - dest = SSAVec16ub(result0, result1); + return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; } -#endif +SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits) +{ + SSAInt xshift = (32 - xbits); + SSAInt yshift = (32 - ybits); + SSAInt xmask = (SSAInt(1) << xshift) - 1; + SSAInt ymask = (SSAInt(1) << yshift) - 1; + SSAInt x = xfrac >> xbits; + SSAInt y = yfrac >> ybits; + + SSAVec4i p00 = texture[(y & ymask) + ((x & xmask) << yshift)].load_vec4ub(); + SSAVec4i p01 = texture[((y + 1) & ymask) + ((x & xmask) << yshift)].load_vec4ub(); + SSAVec4i p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)].load_vec4ub(); + SSAVec4i p11 = texture[((y + 1) & ymask) + (((x + 1) & xmask) << yshift)].load_vec4ub(); + + SSAInt inv_b = (xfrac >> (xbits - 4)) & 15; + SSAInt inv_a = (yfrac >> (ybits - 4)) & 15; + SSAInt a = 16 - inv_a; + SSAInt b = 16 - inv_b; + + return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; +} diff --git a/src/r_compiler/fixedfunction/fixedfunction.h b/src/r_compiler/fixedfunction/fixedfunction.h index 40236d233..d9b8f042e 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.h +++ b/src/r_compiler/fixedfunction/fixedfunction.h @@ -1,6 +1,7 @@ #pragma once +#include "r_compiler/ssa/ssa_value.h" #include "r_compiler/ssa/ssa_vec4f.h" #include "r_compiler/ssa/ssa_vec4i.h" #include "r_compiler/ssa/ssa_vec8s.h" @@ -84,16 +85,9 @@ public: SSAInt desaturate; }; -class FixedFunction +class DrawerCodegen { public: - FixedFunction(); - - void(*DrawSpan)(const RenderArgs *) = nullptr; - -private: - void CodegenDrawSpan(); - // LightBgra SSAInt calc_light_multiplier(SSAInt light); SSAVec4i shade_pal_index_simple(SSAInt index, SSAInt light, SSAUBytePtr basecolors); @@ -111,89 +105,57 @@ private: // SampleBgra SSAVec4i sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height); SSAVec4i sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits); +}; + +class DrawSpanCodegen : public DrawerCodegen +{ +public: + void Generate(SSAValue args); + +private: + void LoopShade(bool isSimpleShade); + void LoopFilter(bool isSimpleShade, bool isNearestFilter); + SSAInt Loop4x(bool isSimpleShade, bool isNearestFilter, bool is64x64); + void Loop(SSAInt start, bool isSimpleShade, bool isNearestFilter, bool is64x64); + SSAVec4i Sample(SSAInt xfrac, SSAInt yfrac, bool isNearestFilter, bool is64x64); + + SSAStack stack_index, stack_xfrac, stack_yfrac; + + SSAUBytePtr destorg; + SSAUBytePtr source; + SSAInt destpitch; + SSAInt xstep; + SSAInt ystep; + SSAInt x1; + SSAInt x2; + SSAInt y; + SSAInt xbits; + SSAInt ybits; + SSAInt light; + SSAInt srcalpha; + SSAInt destalpha; + SSAInt count; + SSAUBytePtr data; + SSAInt yshift; + SSAInt xshift; + SSAInt xmask; + SSABool is_64x64; + SSABool is_simple_shade; + SSABool is_nearest_filter; + SSAShadeConstants shade_constants; +}; + +class FixedFunction +{ +public: + FixedFunction(); + + void(*DrawSpan)(const RenderArgs *) = nullptr; + +private: + void CodegenDrawSpan(); static llvm::Type *GetRenderArgsStruct(llvm::LLVMContext &context); RenderProgram mProgram; }; - -#if 0 - -class GlslProgram; -class GlslCodeGen; - -class GlslFixedFunction -{ -public: - GlslFixedFunction(GlslProgram &program, GlslCodeGen &vertex_codegen, GlslCodeGen &fragment_codegen); - void codegen(); - static llvm::Type *get_sampler_struct(llvm::LLVMContext &context); - -private: - void codegen_draw_triangles(int num_vertex_in, int num_vertex_out); - void codegen_calc_window_positions(); - void codegen_calc_polygon_face_direction(); - void codegen_calc_polygon_y_range(); - void codegen_update_polygon_edge(); - void codegen_texture(); - void codegen_normalize(); - void codegen_reflect(); - void codegen_max(); - void codegen_pow(); - void codegen_dot(); - void codegen_mix(); - - struct OuterData - { - OuterData() : sampler() { } - - SSAInt start; - SSAInt end; - SSAInt input_width; - SSAInt input_height; - SSAInt output_width; - SSAInt output_height; - SSAUBytePtr input_pixels; - SSAUBytePtr output_pixels_line; - - SSAVec4fPtr sse_left_varying_in; - SSAVec4fPtr sse_right_varying_in; - int num_varyings; - SSAVec4f viewport_x; - SSAVec4f viewport_rcp_half_width; - SSAVec4f dx; - SSAVec4f dw; - SSAVec4f v1w; - SSAVec4f v1x; - - llvm::Value *sampler; - }; - - void render_polygon( - SSAInt input_width, - SSAInt input_height, - SSAUBytePtr input_data, - SSAInt output_width, - SSAInt output_height, - SSAUBytePtr output_data, - SSAInt viewport_x, - SSAInt viewport_y, - SSAInt viewport_width, - SSAInt viewport_height, - SSAInt num_vertices, - std::vector fragment_ins, - SSAInt core, - SSAInt num_cores); - - void codegen_render_scanline(int num_varyings); - void process_first_pixels(OuterData &outer_data, SSAStack &stack_x, SSAStack &stack_xnormalized); - void process_last_pixels(OuterData &outer_data, SSAStack &stack_x, SSAStack &stack_xnormalized); - void inner_block(OuterData &data, SSAVec4f xnormalized, SSAVec4f *out_frag_colors); - void blend(SSAVec4f frag_colors[4], SSAVec16ub &dest); - - GlslProgram &program; - GlslCodeGen &vertex_codegen; - GlslCodeGen &fragment_codegen; -}; - -#endif diff --git a/src/r_compiler/ssa/ssa_short.cpp b/src/r_compiler/ssa/ssa_short.cpp index fc8de9449..3fa59b688 100644 --- a/src/r_compiler/ssa/ssa_short.cpp +++ b/src/r_compiler/ssa/ssa_short.cpp @@ -32,6 +32,11 @@ llvm::Type *SSAShort::llvm_type() return llvm::Type::getInt16Ty(SSAScope::context()); } +SSAInt SSAShort::zext_int() +{ + return SSAInt::from_llvm(SSAScope::builder().CreateZExt(v, SSAInt::llvm_type(), SSAScope::hint())); +} + SSAShort operator+(const SSAShort &a, const SSAShort &b) { return SSAShort::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); diff --git a/src/r_compiler/ssa/ssa_short.h b/src/r_compiler/ssa/ssa_short.h index ae71a1336..932aafc0e 100644 --- a/src/r_compiler/ssa/ssa_short.h +++ b/src/r_compiler/ssa/ssa_short.h @@ -17,6 +17,8 @@ public: static SSAShort from_llvm(llvm::Value *v) { return SSAShort(v); } static llvm::Type *llvm_type(); + SSAInt zext_int(); + llvm::Value *v; }; diff --git a/src/r_compiler/ssa/ssa_vec4i.cpp b/src/r_compiler/ssa/ssa_vec4i.cpp index d8e31276c..1eed7b269 100644 --- a/src/r_compiler/ssa/ssa_vec4i.cpp +++ b/src/r_compiler/ssa/ssa_vec4i.cpp @@ -49,6 +49,18 @@ SSAVec4i::SSAVec4i(SSAInt i) v = SSAScope::builder().CreateShuffleVector(SSAScope::builder().CreateBitCast(i.v, m1xi32type, SSAScope::hint()), llvm::UndefValue::get(m1xi32type), mask, SSAScope::hint()); } +SSAVec4i::SSAVec4i(SSAInt i0, SSAInt i1, SSAInt i2, SSAInt i3) +: v(0) +{ + std::vector constants; + constants.resize(4, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 0, true))); + v = llvm::ConstantVector::get(constants); + v = SSAScope::builder().CreateInsertElement(v, i0.v, (uint64_t)0, SSAScope::hint()); + v = SSAScope::builder().CreateInsertElement(v, i1.v, (uint64_t)1, SSAScope::hint()); + v = SSAScope::builder().CreateInsertElement(v, i2.v, (uint64_t)2, SSAScope::hint()); + v = SSAScope::builder().CreateInsertElement(v, i3.v, (uint64_t)3, SSAScope::hint()); +} + SSAVec4i::SSAVec4i(SSAVec4f f32) : v(0) { diff --git a/src/r_compiler/ssa/ssa_vec4i.h b/src/r_compiler/ssa/ssa_vec4i.h index a654a87ae..c1c9140d7 100644 --- a/src/r_compiler/ssa/ssa_vec4i.h +++ b/src/r_compiler/ssa/ssa_vec4i.h @@ -16,6 +16,7 @@ public: SSAVec4i(int constant); SSAVec4i(int constant0, int constant1, int constant2, int constant3); SSAVec4i(SSAInt i); + SSAVec4i(SSAInt i0, SSAInt i1, SSAInt i2, SSAInt i3); explicit SSAVec4i(llvm::Value *v); SSAVec4i(SSAVec4f f32); SSAInt operator[](SSAInt index); diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 975739095..665e6b84e 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -300,50 +300,43 @@ void DrawerCommandQueue::StopThreads() ///////////////////////////////////////////////////////////////////////////// -class DrawSpanFFCommand : public DrawerCommand +class DrawSpanLLVMCommand : public DrawerCommand { - fixed_t _xfrac; - fixed_t _yfrac; - fixed_t _xstep; - fixed_t _ystep; - int _x1; - int _x2; - int _y; - int _xbits; - int _ybits; - BYTE * RESTRICT _destorg; - - const uint32_t * RESTRICT _source; - uint32_t _light; - ShadeConstants _shade_constants; - bool _nearest_filter; - - uint32_t _srcalpha; - uint32_t _destalpha; - + RenderArgs args; FixedFunction *_ff; public: - DrawSpanFFCommand() + DrawSpanLLVMCommand() { - _xfrac = ds_xfrac; - _yfrac = ds_yfrac; - _xstep = ds_xstep; - _ystep = ds_ystep; - _x1 = ds_x1; - _x2 = ds_x2; - _y = ds_y; - _xbits = ds_xbits; - _ybits = ds_ybits; - _destorg = dc_destorg; - - _source = (const uint32_t*)ds_source; - _light = LightBgra::calc_light_multiplier(ds_light); - _shade_constants = ds_shade_constants; - _nearest_filter = !SampleBgra::span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep, ds_source_mipmapped); - - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); + args.xfrac = ds_xfrac; + args.yfrac = ds_yfrac; + args.xstep = ds_xstep; + args.ystep = ds_ystep; + args.x1 = ds_x1; + args.x2 = ds_x2; + args.y = ds_y; + args.xbits = ds_xbits; + args.ybits = ds_ybits; + args.destorg = (uint32_t*)dc_destorg; + args.destpitch = dc_pitch; + args.source = (const uint32_t*)ds_source; + args.light = LightBgra::calc_light_multiplier(ds_light); + args.light_red = ds_shade_constants.light_red; + args.light_green = ds_shade_constants.light_green; + args.light_blue = ds_shade_constants.light_blue; + args.light_alpha = ds_shade_constants.light_alpha; + args.fade_red = ds_shade_constants.fade_red; + args.fade_green = ds_shade_constants.fade_green; + args.fade_blue = ds_shade_constants.fade_blue; + args.fade_alpha = ds_shade_constants.fade_alpha; + args.desaturate = ds_shade_constants.desaturate; + args.srcalpha = dc_srcalpha >> (FRACBITS - 8); + args.destalpha = dc_destalpha >> (FRACBITS - 8); + args.flags = 0; + if (ds_shade_constants.simple_shade) + args.flags |= RenderArgs::simple_shade; + if (!SampleBgra::span_sampler_setup(args.source, args.xbits, args.ybits, args.xstep, args.ystep, ds_source_mipmapped)) + args.flags |= RenderArgs::nearest_filter; static FixedFunction ff; _ff = &ff; @@ -351,25 +344,8 @@ public: void Execute(DrawerThread *thread) override { - if (thread->skipped_by_thread(_y)) + if (thread->skipped_by_thread(args.y)) return; - - RenderArgs args; - args.destorg = (uint32_t *)_destorg; - args.source = _source; - args.destpitch = dc_pitch; - args.xfrac = _xfrac; - args.yfrac = _yfrac; - args.xstep = _xstep; - args.ystep = _ystep; - args.x1 = _x1; - args.x2 = _x2; - args.y = _y; - args.xbits = _xbits; - args.ybits = _ybits; - args.light = _light; - args.srcalpha = _srcalpha; - args.destalpha = _destalpha; _ff->DrawSpan(&args); } }; @@ -2777,7 +2753,7 @@ void R_DrawRevSubClampTranslatedColumn_rgba() void R_DrawSpan_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); /* #ifdef NO_SSE DrawerCommandQueue::QueueCommand(); From bfa291b02f9242f41bfddb1d6a93994ce9b1b6c3 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 29 Sep 2016 02:10:14 +0200 Subject: [PATCH 0999/1509] Create LLVMDrawers class as the external interface to the drawers --- src/CMakeLists.txt | 1 + .../fixedfunction/fixedfunction.cpp | 145 ----------- src/r_compiler/fixedfunction/fixedfunction.h | 76 +----- src/r_compiler/llvmdrawers.cpp | 232 ++++++++++++++++++ src/r_compiler/llvmdrawers.h | 52 ++++ src/r_draw_rgba.cpp | 8 +- src/r_swrenderer.cpp | 11 + src/r_swrenderer.h | 3 + 8 files changed, 302 insertions(+), 226 deletions(-) create mode 100644 src/r_compiler/llvmdrawers.cpp create mode 100644 src/r_compiler/llvmdrawers.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4b81a24f4..508951510 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1426,6 +1426,7 @@ set (PCH_SOURCES fragglescript/t_spec.cpp fragglescript/t_variable.cpp fragglescript/t_cmd.cpp + r_compiler/llvmdrawers.cpp r_compiler/ssa/ssa_bool.cpp r_compiler/ssa/ssa_float.cpp r_compiler/ssa/ssa_float_ptr.cpp diff --git a/src/r_compiler/fixedfunction/fixedfunction.cpp b/src/r_compiler/fixedfunction/fixedfunction.cpp index cc53a069a..fffd2c885 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.cpp +++ b/src/r_compiler/fixedfunction/fixedfunction.cpp @@ -11,151 +11,6 @@ #include "r_compiler/ssa/ssa_value.h" #include "r_compiler/ssa/ssa_barycentric_weight.h" -RenderProgram::RenderProgram() -{ - using namespace llvm; - - install_fatal_error_handler([](void *user_data, const std::string& reason, bool gen_crash_diag) { - I_FatalError("LLVM fatal error: %s", reason.c_str()); - }); - - InitializeNativeTarget(); - InitializeNativeTargetAsmPrinter(); - InitializeNativeTargetAsmParser(); - - std::string errorstring; - - std::string targetTriple = sys::getProcessTriple(); - std::string cpuName = sys::getHostCPUName(); - StringMap cpuFeatures; - sys::getHostCPUFeatures(cpuFeatures); - std::string cpuFeaturesStr; - for (const auto &it : cpuFeatures) - { - if (!cpuFeaturesStr.empty()) - cpuFeaturesStr.push_back(' '); - cpuFeaturesStr.push_back(it.getValue() ? '+' : '-'); - cpuFeaturesStr += it.getKey(); - } - - //Printf("LLVM target triple: %s\n", targetTriple.c_str()); - //Printf("LLVM CPU and features: %s, %s\n", cpuName.c_str(), cpuFeaturesStr.c_str()); - - const Target *target = TargetRegistry::lookupTarget(targetTriple, errorstring); - if (!target) - I_FatalError("Could not find LLVM target: %s", errorstring.c_str()); - - TargetOptions opt; - auto relocModel = Optional(Reloc::Static); - TargetMachine *machine = target->createTargetMachine(targetTriple, cpuName, cpuFeaturesStr, opt, relocModel, CodeModel::Default, CodeGenOpt::Aggressive); - if (!machine) - I_FatalError("Could not create LLVM target machine"); - - mContext = std::make_unique(); - - auto moduleOwner = std::make_unique("render", context()); - mModule = moduleOwner.get(); - mModule->setTargetTriple(targetTriple); - mModule->setDataLayout(machine->createDataLayout()); - - EngineBuilder engineBuilder(std::move(moduleOwner)); - engineBuilder.setErrorStr(&errorstring); - engineBuilder.setOptLevel(CodeGenOpt::Aggressive); - engineBuilder.setRelocationModel(Reloc::Static); - engineBuilder.setEngineKind(EngineKind::JIT); - mEngine.reset(engineBuilder.create(machine)); - if (!mEngine) - I_FatalError("Could not create LLVM execution engine: %s", errorstring.c_str()); - - mModulePassManager = std::make_unique(); - mFunctionPassManager = std::make_unique(mModule); - - PassManagerBuilder passManagerBuilder; - passManagerBuilder.OptLevel = 3; - passManagerBuilder.SizeLevel = 0; - passManagerBuilder.Inliner = createFunctionInliningPass(); - passManagerBuilder.populateModulePassManager(*mModulePassManager.get()); - passManagerBuilder.populateFunctionPassManager(*mFunctionPassManager.get()); -} - -RenderProgram::~RenderProgram() -{ - mEngine.reset(); - mContext.reset(); -} - -void *RenderProgram::PointerToFunction(const char *name) -{ - llvm::Function *function = mModule->getFunction(name); - if (!function) - return nullptr; - return mEngine->getPointerToFunction(function); -} - -///////////////////////////////////////////////////////////////////////////// - -FixedFunction::FixedFunction() -{ - CodegenDrawSpan(); - mProgram.engine()->finalizeObject(); - mProgram.modulePassManager()->run(*mProgram.module()); - - DrawSpan = mProgram.GetProcAddress("DrawSpan"); -} - -void FixedFunction::CodegenDrawSpan() -{ - llvm::IRBuilder<> builder(mProgram.context()); - SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); - - SSAFunction function("DrawSpan"); - function.add_parameter(GetRenderArgsStruct(mProgram.context())); - function.create_public(); - - DrawSpanCodegen codegen; - codegen.Generate(function.parameter(0)); - - builder.CreateRetVoid(); - - if (llvm::verifyFunction(*function.func)) - I_FatalError("verifyFunction failed for " __FUNCTION__); - - mProgram.functionPassManager()->run(*function.func); -} - -llvm::Type *FixedFunction::GetRenderArgsStruct(llvm::LLVMContext &context) -{ - std::vector elements; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *destorg; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *source; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t destpitch; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xfrac; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t yfrac; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xstep; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ystep; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x1; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x2; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t y; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xbits; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ybits; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - return llvm::StructType::get(context, elements, false)->getPointerTo(); -} - -///////////////////////////////////////////////////////////////////////////// - void DrawSpanCodegen::Generate(SSAValue args) { destorg = args[0][0].load(); diff --git a/src/r_compiler/fixedfunction/fixedfunction.h b/src/r_compiler/fixedfunction/fixedfunction.h index d9b8f042e..4b5bfc8b7 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.h +++ b/src/r_compiler/fixedfunction/fixedfunction.h @@ -1,6 +1,7 @@ #pragma once +#include "r_compiler/llvmdrawers.h" #include "r_compiler/ssa/ssa_value.h" #include "r_compiler/ssa/ssa_vec4f.h" #include "r_compiler/ssa/ssa_vec4i.h" @@ -17,66 +18,6 @@ #include "r_compiler/ssa/ssa_barycentric_weight.h" #include "r_compiler/llvm_include.h" -class RenderProgram -{ -public: - RenderProgram(); - ~RenderProgram(); - - template - Func *GetProcAddress(const char *name) { return reinterpret_cast(PointerToFunction(name)); } - - llvm::LLVMContext &context() { return *mContext; } - llvm::Module *module() { return mModule; } - llvm::ExecutionEngine *engine() { return mEngine.get(); } - llvm::legacy::PassManager *modulePassManager() { return mModulePassManager.get(); } - llvm::legacy::FunctionPassManager *functionPassManager() { return mFunctionPassManager.get(); } - -private: - void *PointerToFunction(const char *name); - - std::unique_ptr mContext; - llvm::Module *mModule; - std::unique_ptr mEngine; - std::unique_ptr mModulePassManager; - std::unique_ptr mFunctionPassManager; -}; - -struct RenderArgs -{ - uint32_t *destorg; - const uint32_t *source; - int32_t destpitch; - int32_t xfrac; - int32_t yfrac; - int32_t xstep; - int32_t ystep; - int32_t x1; - int32_t x2; - int32_t y; - int32_t xbits; - int32_t ybits; - uint32_t light; - uint32_t srcalpha; - uint32_t destalpha; - - uint16_t light_alpha; - uint16_t light_red; - uint16_t light_green; - uint16_t light_blue; - uint16_t fade_alpha; - uint16_t fade_red; - uint16_t fade_green; - uint16_t fade_blue; - uint16_t desaturate; - uint32_t flags; - enum Flags - { - simple_shade = 1, - nearest_filter = 2 - }; -}; - class SSAShadeConstants { public: @@ -144,18 +85,3 @@ private: SSABool is_nearest_filter; SSAShadeConstants shade_constants; }; - -class FixedFunction -{ -public: - FixedFunction(); - - void(*DrawSpan)(const RenderArgs *) = nullptr; - -private: - void CodegenDrawSpan(); - - static llvm::Type *GetRenderArgsStruct(llvm::LLVMContext &context); - - RenderProgram mProgram; -}; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp new file mode 100644 index 000000000..408213707 --- /dev/null +++ b/src/r_compiler/llvmdrawers.cpp @@ -0,0 +1,232 @@ + +#include "i_system.h" +#include "r_compiler/fixedfunction/fixedfunction.h" +#include "r_compiler/ssa/ssa_function.h" +#include "r_compiler/ssa/ssa_scope.h" +#include "r_compiler/ssa/ssa_for_block.h" +#include "r_compiler/ssa/ssa_if_block.h" +#include "r_compiler/ssa/ssa_stack.h" +#include "r_compiler/ssa/ssa_function.h" +#include "r_compiler/ssa/ssa_struct_type.h" +#include "r_compiler/ssa/ssa_value.h" +#include "r_compiler/ssa/ssa_barycentric_weight.h" + +class LLVMProgram +{ +public: + LLVMProgram(); + ~LLVMProgram(); + + void StopLogFatalErrors(); + + template + Func *GetProcAddress(const char *name) { return reinterpret_cast(PointerToFunction(name)); } + + llvm::LLVMContext &context() { return *mContext; } + llvm::Module *module() { return mModule; } + llvm::ExecutionEngine *engine() { return mEngine.get(); } + llvm::legacy::PassManager *modulePassManager() { return mModulePassManager.get(); } + llvm::legacy::FunctionPassManager *functionPassManager() { return mFunctionPassManager.get(); } + +private: + void *PointerToFunction(const char *name); + + std::unique_ptr mContext; + llvm::Module *mModule; + std::unique_ptr mEngine; + std::unique_ptr mModulePassManager; + std::unique_ptr mFunctionPassManager; +}; + +class LLVMDrawersImpl : public LLVMDrawers +{ +public: + LLVMDrawersImpl(); + +private: + void CodegenDrawSpan(); + static llvm::Type *GetRenderArgsStruct(llvm::LLVMContext &context); + + LLVMProgram mProgram; +}; + +///////////////////////////////////////////////////////////////////////////// + +LLVMDrawers *LLVMDrawers::Singleton = nullptr; + +void LLVMDrawers::Create() +{ + if (!Singleton) + Singleton = new LLVMDrawersImpl(); +} + +void LLVMDrawers::Destroy() +{ + delete Singleton; + Singleton = nullptr; +} + +LLVMDrawers *LLVMDrawers::Instance() +{ + return Singleton; +} + +///////////////////////////////////////////////////////////////////////////// + +LLVMDrawersImpl::LLVMDrawersImpl() +{ + CodegenDrawSpan(); + mProgram.engine()->finalizeObject(); + mProgram.modulePassManager()->run(*mProgram.module()); + + DrawSpan = mProgram.GetProcAddress("DrawSpan"); + + mProgram.StopLogFatalErrors(); +} + +void LLVMDrawersImpl::CodegenDrawSpan() +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function("DrawSpan"); + function.add_parameter(GetRenderArgsStruct(mProgram.context())); + function.create_public(); + + DrawSpanCodegen codegen; + codegen.Generate(function.parameter(0)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + I_FatalError("verifyFunction failed for " __FUNCTION__); + + mProgram.functionPassManager()->run(*function.func); +} + +llvm::Type *LLVMDrawersImpl::GetRenderArgsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *destorg; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *source; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t destpitch; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xfrac; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t yfrac; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xstep; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ystep; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x1; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x2; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t y; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xbits; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ybits; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; + return llvm::StructType::get(context, elements, false)->getPointerTo(); +} + +///////////////////////////////////////////////////////////////////////////// + +namespace { static bool LogFatalErrors = false; } + +LLVMProgram::LLVMProgram() +{ + using namespace llvm; + + // We have to extra careful about this because both LLVM and ZDoom made + // the very unwise decision to hook atexit. To top it off, LLVM decided + // to log something in the atexit handler.. + LogFatalErrors = true; + + install_fatal_error_handler([](void *user_data, const std::string& reason, bool gen_crash_diag) { + if (LogFatalErrors) + I_FatalError("LLVM fatal error: %s", reason.c_str()); + }); + + InitializeNativeTarget(); + InitializeNativeTargetAsmPrinter(); + InitializeNativeTargetAsmParser(); + + std::string errorstring; + + std::string targetTriple = sys::getProcessTriple(); + std::string cpuName = sys::getHostCPUName(); + StringMap cpuFeatures; + sys::getHostCPUFeatures(cpuFeatures); + std::string cpuFeaturesStr; + for (const auto &it : cpuFeatures) + { + if (!cpuFeaturesStr.empty()) + cpuFeaturesStr.push_back(' '); + cpuFeaturesStr.push_back(it.getValue() ? '+' : '-'); + cpuFeaturesStr += it.getKey(); + } + + //Printf("LLVM target triple: %s\n", targetTriple.c_str()); + //Printf("LLVM CPU and features: %s, %s\n", cpuName.c_str(), cpuFeaturesStr.c_str()); + + const Target *target = TargetRegistry::lookupTarget(targetTriple, errorstring); + if (!target) + I_FatalError("Could not find LLVM target: %s", errorstring.c_str()); + + TargetOptions opt; + auto relocModel = Optional(Reloc::Static); + TargetMachine *machine = target->createTargetMachine(targetTriple, cpuName, cpuFeaturesStr, opt, relocModel, CodeModel::Default, CodeGenOpt::Aggressive); + if (!machine) + I_FatalError("Could not create LLVM target machine"); + + mContext = std::make_unique(); + + auto moduleOwner = std::make_unique("render", context()); + mModule = moduleOwner.get(); + mModule->setTargetTriple(targetTriple); + mModule->setDataLayout(machine->createDataLayout()); + + EngineBuilder engineBuilder(std::move(moduleOwner)); + engineBuilder.setErrorStr(&errorstring); + engineBuilder.setOptLevel(CodeGenOpt::Aggressive); + engineBuilder.setRelocationModel(Reloc::Static); + engineBuilder.setEngineKind(EngineKind::JIT); + mEngine.reset(engineBuilder.create(machine)); + if (!mEngine) + I_FatalError("Could not create LLVM execution engine: %s", errorstring.c_str()); + + mModulePassManager = std::make_unique(); + mFunctionPassManager = std::make_unique(mModule); + + PassManagerBuilder passManagerBuilder; + passManagerBuilder.OptLevel = 3; + passManagerBuilder.SizeLevel = 0; + passManagerBuilder.Inliner = createFunctionInliningPass(); + passManagerBuilder.populateModulePassManager(*mModulePassManager.get()); + passManagerBuilder.populateFunctionPassManager(*mFunctionPassManager.get()); +} + +LLVMProgram::~LLVMProgram() +{ + mEngine.reset(); + mContext.reset(); +} + +void *LLVMProgram::PointerToFunction(const char *name) +{ + llvm::Function *function = mModule->getFunction(name); + if (!function) + return nullptr; + return mEngine->getPointerToFunction(function); +} + +void LLVMProgram::StopLogFatalErrors() +{ + LogFatalErrors = false; +} diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h new file mode 100644 index 000000000..2ad6c3d52 --- /dev/null +++ b/src/r_compiler/llvmdrawers.h @@ -0,0 +1,52 @@ + +#pragma once + +struct RenderArgs +{ + uint32_t *destorg; + const uint32_t *source; + int32_t destpitch; + int32_t xfrac; + int32_t yfrac; + int32_t xstep; + int32_t ystep; + int32_t x1; + int32_t x2; + int32_t y; + int32_t xbits; + int32_t ybits; + uint32_t light; + uint32_t srcalpha; + uint32_t destalpha; + + uint16_t light_alpha; + uint16_t light_red; + uint16_t light_green; + uint16_t light_blue; + uint16_t fade_alpha; + uint16_t fade_red; + uint16_t fade_green; + uint16_t fade_blue; + uint16_t desaturate; + uint32_t flags; + enum Flags + { + simple_shade = 1, + nearest_filter = 2 + }; +}; + +class LLVMDrawers +{ +public: + virtual ~LLVMDrawers() { } + + static void Create(); + static void Destroy(); + static LLVMDrawers *Instance(); + + void(*DrawSpan)(const RenderArgs *) = nullptr; + +private: + static LLVMDrawers *Singleton; +}; diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 665e6b84e..9c2cd6293 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -38,7 +38,7 @@ #include "r_data/colormaps.h" #include "r_plane.h" #include "r_draw_rgba.h" -#include "r_compiler/fixedfunction/fixedfunction.h" +#include "r_compiler/llvmdrawers.h" #include "gi.h" #include "stats.h" @@ -303,7 +303,6 @@ void DrawerCommandQueue::StopThreads() class DrawSpanLLVMCommand : public DrawerCommand { RenderArgs args; - FixedFunction *_ff; public: DrawSpanLLVMCommand() @@ -337,16 +336,13 @@ public: args.flags |= RenderArgs::simple_shade; if (!SampleBgra::span_sampler_setup(args.source, args.xbits, args.ybits, args.xstep, args.ystep, ds_source_mipmapped)) args.flags |= RenderArgs::nearest_filter; - - static FixedFunction ff; - _ff = &ff; } void Execute(DrawerThread *thread) override { if (thread->skipped_by_thread(args.y)) return; - _ff->DrawSpan(&args); + LLVMDrawers::Instance()->DrawSpan(&args); } }; diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 5be847502..b9a9ea7fd 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -43,6 +43,7 @@ #include "textures/textures.h" #include "r_data/voxels.h" #include "r_draw_rgba.h" +#include "r_compiler/llvmdrawers.h" EXTERN_CVAR(Bool, r_shadercolormaps) @@ -51,6 +52,16 @@ void R_SetupColormap(player_t *); void R_SetupFreelook(); void R_InitRenderer(); +FSoftwareRenderer::FSoftwareRenderer() +{ + LLVMDrawers::Create(); +} + +FSoftwareRenderer::~FSoftwareRenderer() +{ + LLVMDrawers::Destroy(); +} + //========================================================================== // // DCanvas :: Init diff --git a/src/r_swrenderer.h b/src/r_swrenderer.h index f9d5609a0..fc3ec2551 100644 --- a/src/r_swrenderer.h +++ b/src/r_swrenderer.h @@ -5,6 +5,9 @@ struct FSoftwareRenderer : public FRenderer { + FSoftwareRenderer(); + ~FSoftwareRenderer(); + // Can be overridden so that the colormaps for sector color/fade won't be built. virtual bool UsesColormap() const override; From efd22346d8ec29dace77fe3b788c59f98b4ab340 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 29 Sep 2016 02:26:36 +0200 Subject: [PATCH 1000/1509] Fix linear sampling bug --- src/r_compiler/fixedfunction/fixedfunction.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/r_compiler/fixedfunction/fixedfunction.cpp b/src/r_compiler/fixedfunction/fixedfunction.cpp index fffd2c885..c205bc45e 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.cpp +++ b/src/r_compiler/fixedfunction/fixedfunction.cpp @@ -256,10 +256,10 @@ SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt SSAInt y0 = frac_y0 >> FRACBITS; SSAInt y1 = frac_y1 >> FRACBITS; - SSAVec4i p00 = col0[y0].load_vec4ub(); - SSAVec4i p01 = col0[y1].load_vec4ub(); - SSAVec4i p10 = col1[y0].load_vec4ub(); - SSAVec4i p11 = col1[y1].load_vec4ub(); + SSAVec4i p00 = col0[y0 * 4].load_vec4ub(); + SSAVec4i p01 = col0[y1 * 4].load_vec4ub(); + SSAVec4i p10 = col1[y0 * 4].load_vec4ub(); + SSAVec4i p11 = col1[y1 * 4].load_vec4ub(); SSAInt inv_b = texturefracx; SSAInt inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; @@ -278,10 +278,10 @@ SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt SSAInt x = xfrac >> xbits; SSAInt y = yfrac >> ybits; - SSAVec4i p00 = texture[(y & ymask) + ((x & xmask) << yshift)].load_vec4ub(); - SSAVec4i p01 = texture[((y + 1) & ymask) + ((x & xmask) << yshift)].load_vec4ub(); - SSAVec4i p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)].load_vec4ub(); - SSAVec4i p11 = texture[((y + 1) & ymask) + (((x + 1) & xmask) << yshift)].load_vec4ub(); + SSAVec4i p00 = texture[((y & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(); + SSAVec4i p01 = texture[(((y + 1) & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(); + SSAVec4i p10 = texture[((y & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(); + SSAVec4i p11 = texture[(((y + 1) & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(); SSAInt inv_b = (xfrac >> (xbits - 4)) & 15; SSAInt inv_a = (yfrac >> (ybits - 4)) & 15; From e5f3c119cdf4c547be763ceacedf629752938014 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 29 Sep 2016 04:01:42 +0200 Subject: [PATCH 1001/1509] Codegen all DrawSpan variants --- .../fixedfunction/fixedfunction.cpp | 94 +++++++++++++------ src/r_compiler/fixedfunction/fixedfunction.h | 25 ++++- src/r_compiler/llvmdrawers.cpp | 29 ++++-- src/r_compiler/llvmdrawers.h | 9 +- src/r_draw_rgba.cpp | 87 +++++++++++++++-- 5 files changed, 193 insertions(+), 51 deletions(-) diff --git a/src/r_compiler/fixedfunction/fixedfunction.cpp b/src/r_compiler/fixedfunction/fixedfunction.cpp index c205bc45e..fc5402a42 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.cpp +++ b/src/r_compiler/fixedfunction/fixedfunction.cpp @@ -11,7 +11,7 @@ #include "r_compiler/ssa/ssa_value.h" #include "r_compiler/ssa/ssa_barycentric_weight.h" -void DrawSpanCodegen::Generate(SSAValue args) +void DrawSpanCodegen::Generate(DrawSpanVariant variant, SSAValue args) { destorg = args[0][0].load(); source = args[0][1].load(); @@ -51,44 +51,44 @@ void DrawSpanCodegen::Generate(SSAValue args) // 64x64 is the most common case by far, so special case it. is_64x64 = xbits == 6 && ybits == 6; - is_simple_shade = (flags & RenderArgs::simple_shade) == RenderArgs::simple_shade; - is_nearest_filter = (flags & RenderArgs::nearest_filter) == RenderArgs::nearest_filter; + is_simple_shade = (flags & DrawSpanArgs::simple_shade) == DrawSpanArgs::simple_shade; + is_nearest_filter = (flags & DrawSpanArgs::nearest_filter) == DrawSpanArgs::nearest_filter; SSAIfBlock branch; branch.if_block(is_simple_shade); - LoopShade(true); + LoopShade(variant, true); branch.else_block(); - LoopShade(false); + LoopShade(variant, false); branch.end_block(); } -void DrawSpanCodegen::LoopShade(bool isSimpleShade) +void DrawSpanCodegen::LoopShade(DrawSpanVariant variant, bool isSimpleShade) { SSAIfBlock branch; branch.if_block(is_nearest_filter); - LoopFilter(isSimpleShade, true); + LoopFilter(variant, isSimpleShade, true); branch.else_block(); - LoopFilter(isSimpleShade, false); + LoopFilter(variant, isSimpleShade, false); branch.end_block(); } -void DrawSpanCodegen::LoopFilter(bool isSimpleShade, bool isNearestFilter) +void DrawSpanCodegen::LoopFilter(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter) { SSAIfBlock branch; branch.if_block(is_64x64); { - SSAInt sseLength = Loop4x(isSimpleShade, isNearestFilter, true); - Loop(sseLength * 4, isSimpleShade, isNearestFilter, true); + SSAInt sseLength = Loop4x(variant, isSimpleShade, isNearestFilter, true); + Loop(sseLength * 4, variant, isSimpleShade, isNearestFilter, true); } branch.else_block(); { - SSAInt sseLength = Loop4x(isSimpleShade, isNearestFilter, false); - Loop(sseLength * 4, isSimpleShade, isNearestFilter, false); + SSAInt sseLength = Loop4x(variant, isSimpleShade, isNearestFilter, false); + Loop(sseLength * 4, variant, isSimpleShade, isNearestFilter, false); } branch.end_block(); } -SSAInt DrawSpanCodegen::Loop4x(bool isSimpleShade, bool isNearestFilter, bool is64x64) +SSAInt DrawSpanCodegen::Loop4x(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64) { SSAInt sseLength = count / 4; stack_index.store(0); @@ -97,24 +97,31 @@ SSAInt DrawSpanCodegen::Loop4x(bool isSimpleShade, bool isNearestFilter, bool is SSAInt index = stack_index.load(); loop.loop_block(index < sseLength); + SSAVec16ub bg = data[index * 16].load_unaligned_vec16ub(); + SSAVec8s bg0 = SSAVec8s::extendlo(bg); + SSAVec8s bg1 = SSAVec8s::extendhi(bg); + SSAVec4i bgcolors[4] = + { + SSAVec4i::extendlo(bg0), + SSAVec4i::extendhi(bg0), + SSAVec4i::extendlo(bg1), + SSAVec4i::extendhi(bg1) + }; + SSAVec4i colors[4]; for (int i = 0; i < 4; i++) { SSAInt xfrac = stack_xfrac.load(); SSAInt yfrac = stack_yfrac.load(); - SSAVec4i fg = Sample(xfrac, yfrac, isNearestFilter, is64x64); - if (isSimpleShade) - colors[i] = shade_bgra_simple(fg, light); - else - colors[i] = shade_bgra_advanced(fg, light, shade_constants); + colors[i] = Blend(Shade(Sample(xfrac, yfrac, isNearestFilter, is64x64), isSimpleShade), bgcolors[i], variant); stack_xfrac.store(xfrac + xstep); stack_yfrac.store(yfrac + ystep); } - SSAVec16ub ssecolors(SSAVec8s(colors[0], colors[1]), SSAVec8s(colors[2], colors[3])); - data[index * 16].store_unaligned_vec16ub(ssecolors); + SSAVec16ub color(SSAVec8s(colors[0], colors[1]), SSAVec8s(colors[2], colors[3])); + data[index * 16].store_unaligned_vec16ub(color); stack_index.store(index + 1); loop.end_block(); @@ -122,7 +129,7 @@ SSAInt DrawSpanCodegen::Loop4x(bool isSimpleShade, bool isNearestFilter, bool is return sseLength; } -void DrawSpanCodegen::Loop(SSAInt start, bool isSimpleShade, bool isNearestFilter, bool is64x64) +void DrawSpanCodegen::Loop(SSAInt start, DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64) { stack_index.store(start); { @@ -133,13 +140,8 @@ void DrawSpanCodegen::Loop(SSAInt start, bool isSimpleShade, bool isNearestFilte SSAInt xfrac = stack_xfrac.load(); SSAInt yfrac = stack_yfrac.load(); - SSAVec4i fg = Sample(xfrac, yfrac, isNearestFilter, is64x64); - SSAVec4i color; - if (isSimpleShade) - color = shade_bgra_simple(fg, light); - else - color = shade_bgra_advanced(fg, light, shade_constants); - + SSAVec4i bgcolor = data[index * 4].load_vec4ub(); + SSAVec4i color = Blend(Shade(Sample(xfrac, yfrac, isNearestFilter, is64x64), isSimpleShade), bgcolor, variant); data[index * 4].store_vec4ub(color); stack_index.store(index + 1); @@ -173,6 +175,32 @@ SSAVec4i DrawSpanCodegen::Sample(SSAInt xfrac, SSAInt yfrac, bool isNearestFilte } } +SSAVec4i DrawSpanCodegen::Shade(SSAVec4i fg, bool isSimpleShade) +{ + if (isSimpleShade) + return shade_bgra_simple(fg, light); + else + return shade_bgra_advanced(fg, light, shade_constants); +} + +SSAVec4i DrawSpanCodegen::Blend(SSAVec4i fg, SSAVec4i bg, DrawSpanVariant variant) +{ + switch (variant) + { + default: + case DrawSpanVariant::Opaque: + return blend_copy(fg); + case DrawSpanVariant::Masked: + return blend_alpha_blend(fg, bg); + case DrawSpanVariant::Translucent: + case DrawSpanVariant::AddClamp: + return blend_add(fg, bg, srcalpha, destalpha); + case DrawSpanVariant::MaskedTranslucent: + case DrawSpanVariant::MaskedAddClamp: + return blend_add(fg, bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + } +} + ///////////////////////////////////////////////////////////////////////////// SSAInt DrawerCodegen::calc_light_multiplier(SSAInt light) @@ -249,6 +277,14 @@ SSAVec4i DrawerCodegen::blend_alpha_blend(SSAVec4i fg, SSAVec4i bg) return color.insert(3, 255); } +SSAInt DrawerCodegen::calc_blend_bgalpha(SSAVec4i fg, SSAInt destalpha) +{ + SSAInt alpha = fg[3]; + alpha = alpha + (alpha >> 7); + SSAInt inv_alpha = 256 - alpha; + return (destalpha * alpha + 256 * inv_alpha + 128) >> 8; +} + SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height) { SSAInt frac_y0 = (texturefracy >> FRACBITS) * height; diff --git a/src/r_compiler/fixedfunction/fixedfunction.h b/src/r_compiler/fixedfunction/fixedfunction.h index 4b5bfc8b7..1c58740d5 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.h +++ b/src/r_compiler/fixedfunction/fixedfunction.h @@ -43,22 +43,37 @@ public: SSAVec4i blend_revsub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha); SSAVec4i blend_alpha_blend(SSAVec4i fg, SSAVec4i bg); + // Calculates the final alpha values to be used when combined with the source texture alpha channel + SSAInt calc_blend_bgalpha(SSAVec4i fg, SSAInt destalpha); + // SampleBgra SSAVec4i sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height); SSAVec4i sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits); }; +enum class DrawSpanVariant +{ + Opaque, + Masked, + Translucent, + MaskedTranslucent, + AddClamp, + MaskedAddClamp +}; + class DrawSpanCodegen : public DrawerCodegen { public: - void Generate(SSAValue args); + void Generate(DrawSpanVariant variant, SSAValue args); private: - void LoopShade(bool isSimpleShade); - void LoopFilter(bool isSimpleShade, bool isNearestFilter); - SSAInt Loop4x(bool isSimpleShade, bool isNearestFilter, bool is64x64); - void Loop(SSAInt start, bool isSimpleShade, bool isNearestFilter, bool is64x64); + void LoopShade(DrawSpanVariant variant, bool isSimpleShade); + void LoopFilter(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter); + SSAInt Loop4x(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64); + void Loop(SSAInt start, DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64); SSAVec4i Sample(SSAInt xfrac, SSAInt yfrac, bool isNearestFilter, bool is64x64); + SSAVec4i Shade(SSAVec4i fg, bool isSimpleShade); + SSAVec4i Blend(SSAVec4i fg, SSAVec4i bg, DrawSpanVariant variant); SSAStack stack_index, stack_xfrac, stack_yfrac; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 408213707..fb4a6d023 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -44,8 +44,8 @@ public: LLVMDrawersImpl(); private: - void CodegenDrawSpan(); - static llvm::Type *GetRenderArgsStruct(llvm::LLVMContext &context); + void CodegenDrawSpan(const char *name, DrawSpanVariant variant); + static llvm::Type *GetDrawSpanArgsStruct(llvm::LLVMContext &context); LLVMProgram mProgram; }; @@ -75,26 +75,37 @@ LLVMDrawers *LLVMDrawers::Instance() LLVMDrawersImpl::LLVMDrawersImpl() { - CodegenDrawSpan(); + CodegenDrawSpan("DrawSpan", DrawSpanVariant::Opaque); + CodegenDrawSpan("DrawSpanMasked", DrawSpanVariant::Masked); + CodegenDrawSpan("DrawSpanTranslucent", DrawSpanVariant::Translucent); + CodegenDrawSpan("DrawSpanMaskedTranslucent", DrawSpanVariant::MaskedTranslucent); + CodegenDrawSpan("DrawSpanAddClamp", DrawSpanVariant::AddClamp); + CodegenDrawSpan("DrawSpanMaskedAddClamp", DrawSpanVariant::MaskedAddClamp); + mProgram.engine()->finalizeObject(); mProgram.modulePassManager()->run(*mProgram.module()); - DrawSpan = mProgram.GetProcAddress("DrawSpan"); + DrawSpan = mProgram.GetProcAddress("DrawSpan"); + DrawSpanMasked = mProgram.GetProcAddress("DrawSpanMasked"); + DrawSpanTranslucent = mProgram.GetProcAddress("DrawSpanTranslucent"); + DrawSpanMaskedTranslucent = mProgram.GetProcAddress("DrawSpanMaskedTranslucent"); + DrawSpanAddClamp = mProgram.GetProcAddress("DrawSpanAddClamp"); + DrawSpanMaskedAddClamp = mProgram.GetProcAddress("DrawSpanMaskedAddClamp"); mProgram.StopLogFatalErrors(); } -void LLVMDrawersImpl::CodegenDrawSpan() +void LLVMDrawersImpl::CodegenDrawSpan(const char *name, DrawSpanVariant variant) { llvm::IRBuilder<> builder(mProgram.context()); SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); - SSAFunction function("DrawSpan"); - function.add_parameter(GetRenderArgsStruct(mProgram.context())); + SSAFunction function(name); + function.add_parameter(GetDrawSpanArgsStruct(mProgram.context())); function.create_public(); DrawSpanCodegen codegen; - codegen.Generate(function.parameter(0)); + codegen.Generate(variant, function.parameter(0)); builder.CreateRetVoid(); @@ -104,7 +115,7 @@ void LLVMDrawersImpl::CodegenDrawSpan() mProgram.functionPassManager()->run(*function.func); } -llvm::Type *LLVMDrawersImpl::GetRenderArgsStruct(llvm::LLVMContext &context) +llvm::Type *LLVMDrawersImpl::GetDrawSpanArgsStruct(llvm::LLVMContext &context) { std::vector elements; elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *destorg; diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 2ad6c3d52..53e64032f 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -1,7 +1,7 @@ #pragma once -struct RenderArgs +struct DrawSpanArgs { uint32_t *destorg; const uint32_t *source; @@ -45,7 +45,12 @@ public: static void Destroy(); static LLVMDrawers *Instance(); - void(*DrawSpan)(const RenderArgs *) = nullptr; + void(*DrawSpan)(const DrawSpanArgs *) = nullptr; + void(*DrawSpanMasked)(const DrawSpanArgs *) = nullptr; + void(*DrawSpanTranslucent)(const DrawSpanArgs *) = nullptr; + void(*DrawSpanMaskedTranslucent)(const DrawSpanArgs *) = nullptr; + void(*DrawSpanAddClamp)(const DrawSpanArgs *) = nullptr; + void(*DrawSpanMaskedAddClamp)(const DrawSpanArgs *) = nullptr; private: static LLVMDrawers *Singleton; diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 9c2cd6293..8a0a6871a 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -302,7 +302,8 @@ void DrawerCommandQueue::StopThreads() class DrawSpanLLVMCommand : public DrawerCommand { - RenderArgs args; +protected: + DrawSpanArgs args; public: DrawSpanLLVMCommand() @@ -333,9 +334,9 @@ public: args.destalpha = dc_destalpha >> (FRACBITS - 8); args.flags = 0; if (ds_shade_constants.simple_shade) - args.flags |= RenderArgs::simple_shade; + args.flags |= DrawSpanArgs::simple_shade; if (!SampleBgra::span_sampler_setup(args.source, args.xbits, args.ybits, args.xstep, args.ystep, ds_source_mipmapped)) - args.flags |= RenderArgs::nearest_filter; + args.flags |= DrawSpanArgs::nearest_filter; } void Execute(DrawerThread *thread) override @@ -346,6 +347,61 @@ public: } }; +class DrawSpanMaskedLLVMCommand : public DrawSpanLLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + if (thread->skipped_by_thread(args.y)) + return; + LLVMDrawers::Instance()->DrawSpanMasked(&args); + } +}; + +class DrawSpanTranslucentLLVMCommand : public DrawSpanLLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + if (thread->skipped_by_thread(args.y)) + return; + LLVMDrawers::Instance()->DrawSpanTranslucent(&args); + } +}; + +class DrawSpanMaskedTranslucentLLVMCommand : public DrawSpanLLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + if (thread->skipped_by_thread(args.y)) + return; + LLVMDrawers::Instance()->DrawSpanMaskedTranslucent(&args); + } +}; + +class DrawSpanAddClampLLVMCommand : public DrawSpanLLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + if (thread->skipped_by_thread(args.y)) + return; + LLVMDrawers::Instance()->DrawSpanAddClamp(&args); + } +}; + +class DrawSpanMaskedAddClampLLVMCommand : public DrawSpanLLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + if (thread->skipped_by_thread(args.y)) + return; + LLVMDrawers::Instance()->DrawSpanMaskedAddClamp(&args); + } +}; + ///////////////////////////////////////////////////////////////////////////// class DrawerColumnCommand : public DrawerCommand @@ -2749,39 +2805,58 @@ void R_DrawRevSubClampTranslatedColumn_rgba() void R_DrawSpan_rgba() { +#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -/* -#ifdef NO_SSE +#elif defined(NO_SSE) DrawerCommandQueue::QueueCommand(); #else DrawerCommandQueue::QueueCommand(); #endif -*/ } void R_DrawSpanMasked_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else DrawerCommandQueue::QueueCommand(); +#endif } void R_DrawSpanTranslucent_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else DrawerCommandQueue::QueueCommand(); +#endif } void R_DrawSpanMaskedTranslucent_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else DrawerCommandQueue::QueueCommand(); +#endif } void R_DrawSpanAddClamp_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else DrawerCommandQueue::QueueCommand(); +#endif } void R_DrawSpanMaskedAddClamp_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else DrawerCommandQueue::QueueCommand(); +#endif } void R_FillSpan_rgba() From 7be25112699a71f0c504607ec90e154bb4fa3a52 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 29 Sep 2016 05:21:43 +0200 Subject: [PATCH 1002/1509] Add codegen files for walls and columns --- src/CMakeLists.txt | 5 +- .../fixedfunction/drawcolumncodegen.cpp | 15 ++ .../fixedfunction/drawcolumncodegen.h | 26 ++++ .../fixedfunction/drawercodegen.cpp | 135 ++++++++++++++++++ .../{fixedfunction.h => drawercodegen.h} | 50 ------- ...{fixedfunction.cpp => drawspancodegen.cpp} | 129 +---------------- .../fixedfunction/drawspancodegen.h | 54 +++++++ .../fixedfunction/drawwallcodegen.cpp | 15 ++ .../fixedfunction/drawwallcodegen.h | 26 ++++ src/r_compiler/llvmdrawers.cpp | 4 +- 10 files changed, 279 insertions(+), 180 deletions(-) create mode 100644 src/r_compiler/fixedfunction/drawcolumncodegen.cpp create mode 100644 src/r_compiler/fixedfunction/drawcolumncodegen.h create mode 100644 src/r_compiler/fixedfunction/drawercodegen.cpp rename src/r_compiler/fixedfunction/{fixedfunction.h => drawercodegen.h} (61%) rename src/r_compiler/fixedfunction/{fixedfunction.cpp => drawspancodegen.cpp} (57%) create mode 100644 src/r_compiler/fixedfunction/drawspancodegen.h create mode 100644 src/r_compiler/fixedfunction/drawwallcodegen.cpp create mode 100644 src/r_compiler/fixedfunction/drawwallcodegen.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 508951510..41829b996 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1447,7 +1447,10 @@ set (PCH_SOURCES r_compiler/ssa/ssa_vec4i_ptr.cpp r_compiler/ssa/ssa_vec8s.cpp r_compiler/ssa/ssa_vec16ub.cpp - r_compiler/fixedfunction/fixedfunction.cpp + r_compiler/fixedfunction/drawercodegen.cpp + r_compiler/fixedfunction/drawspancodegen.cpp + r_compiler/fixedfunction/drawwallcodegen.cpp + r_compiler/fixedfunction/drawcolumncodegen.cpp r_data/sprites.cpp r_data/voxels.cpp r_data/renderstyle.cpp diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp new file mode 100644 index 000000000..4594e2290 --- /dev/null +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp @@ -0,0 +1,15 @@ + +#include "i_system.h" +#include "r_compiler/fixedfunction/drawcolumncodegen.h" +#include "r_compiler/ssa/ssa_function.h" +#include "r_compiler/ssa/ssa_scope.h" +#include "r_compiler/ssa/ssa_for_block.h" +#include "r_compiler/ssa/ssa_if_block.h" +#include "r_compiler/ssa/ssa_stack.h" +#include "r_compiler/ssa/ssa_function.h" +#include "r_compiler/ssa/ssa_struct_type.h" +#include "r_compiler/ssa/ssa_value.h" + +void DrawColumnCodegen::Generate(DrawColumnVariant variant, SSAValue args) +{ +} diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.h b/src/r_compiler/fixedfunction/drawcolumncodegen.h new file mode 100644 index 000000000..0749def7f --- /dev/null +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.h @@ -0,0 +1,26 @@ + +#pragma once + +#include "drawercodegen.h" + +enum class DrawColumnVariant +{ + Opaque, + Fuzz, + Add, + Translated, + TlatedAdd, + Shaded, + AddClamp, + AddClampTranslated, + SubClamp, + SubClampTranslated, + RevSubClamp, + RevSubClampTranslated +}; + +class DrawColumnCodegen : public DrawerCodegen +{ +public: + void Generate(DrawColumnVariant variant, SSAValue args); +}; diff --git a/src/r_compiler/fixedfunction/drawercodegen.cpp b/src/r_compiler/fixedfunction/drawercodegen.cpp new file mode 100644 index 000000000..5da858e27 --- /dev/null +++ b/src/r_compiler/fixedfunction/drawercodegen.cpp @@ -0,0 +1,135 @@ + +#include "i_system.h" +#include "r_compiler/fixedfunction/drawercodegen.h" +#include "r_compiler/ssa/ssa_function.h" +#include "r_compiler/ssa/ssa_scope.h" +#include "r_compiler/ssa/ssa_for_block.h" +#include "r_compiler/ssa/ssa_if_block.h" +#include "r_compiler/ssa/ssa_stack.h" +#include "r_compiler/ssa/ssa_function.h" +#include "r_compiler/ssa/ssa_struct_type.h" +#include "r_compiler/ssa/ssa_value.h" + +SSAInt DrawerCodegen::calc_light_multiplier(SSAInt light) +{ + return 256 - (light >> (FRACBITS - 8)); +} + +SSAVec4i DrawerCodegen::shade_pal_index_simple(SSAInt index, SSAInt light, SSAUBytePtr basecolors) +{ + SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index]; + return shade_bgra_simple(color, light); +} + +SSAVec4i DrawerCodegen::shade_pal_index_advanced(SSAInt index, SSAInt light, const SSAShadeConstants &constants, SSAUBytePtr basecolors) +{ + SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index]; + return shade_bgra_advanced(color, light, constants); +} + +SSAVec4i DrawerCodegen::shade_bgra_simple(SSAVec4i color, SSAInt light) +{ + color = color * light / 256; + return color.insert(3, 255); +} + +SSAVec4i DrawerCodegen::shade_bgra_advanced(SSAVec4i color, SSAInt light, const SSAShadeConstants &constants) +{ + SSAInt blue = color[0]; + SSAInt green = color[1]; + SSAInt red = color[2]; + SSAInt alpha = color[3]; + + SSAInt intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; + + SSAVec4i inv_light = 256 - light; + SSAVec4i inv_desaturate = 256 - constants.desaturate; + + color = (color * inv_desaturate + intensity) / 256; + color = (constants.fade * inv_light + color * light) / 256; + color = (color * constants.light) / 256; + + return color.insert(3, alpha); +} + +SSAVec4i DrawerCodegen::blend_copy(SSAVec4i fg) +{ + return fg; +} + +SSAVec4i DrawerCodegen::blend_add(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) +{ + SSAVec4i color = (fg * srcalpha + bg * destalpha) / 256; + return color.insert(3, 255); +} + +SSAVec4i DrawerCodegen::blend_sub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) +{ + SSAVec4i color = (bg * destalpha - fg * srcalpha) / 256; + return color.insert(3, 255); +} + +SSAVec4i DrawerCodegen::blend_revsub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) +{ + SSAVec4i color = (fg * srcalpha - bg * destalpha) / 256; + return color.insert(3, 255); +} + +SSAVec4i DrawerCodegen::blend_alpha_blend(SSAVec4i fg, SSAVec4i bg) +{ + SSAInt alpha = fg[3]; + alpha = alpha + (alpha >> 7); // // 255 -> 256 + SSAInt inv_alpha = 256 - alpha; + SSAVec4i color = (fg * alpha + bg * inv_alpha) / 256; + return color.insert(3, 255); +} + +SSAInt DrawerCodegen::calc_blend_bgalpha(SSAVec4i fg, SSAInt destalpha) +{ + SSAInt alpha = fg[3]; + alpha = alpha + (alpha >> 7); + SSAInt inv_alpha = 256 - alpha; + return (destalpha * alpha + 256 * inv_alpha + 128) >> 8; +} + +SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height) +{ + SSAInt frac_y0 = (texturefracy >> FRACBITS) * height; + SSAInt frac_y1 = ((texturefracy + one) >> FRACBITS) * height; + SSAInt y0 = frac_y0 >> FRACBITS; + SSAInt y1 = frac_y1 >> FRACBITS; + + SSAVec4i p00 = col0[y0 * 4].load_vec4ub(); + SSAVec4i p01 = col0[y1 * 4].load_vec4ub(); + SSAVec4i p10 = col1[y0 * 4].load_vec4ub(); + SSAVec4i p11 = col1[y1 * 4].load_vec4ub(); + + SSAInt inv_b = texturefracx; + SSAInt inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; + SSAInt a = 16 - inv_a; + SSAInt b = 16 - inv_b; + + return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; +} + +SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits) +{ + SSAInt xshift = (32 - xbits); + SSAInt yshift = (32 - ybits); + SSAInt xmask = (SSAInt(1) << xshift) - 1; + SSAInt ymask = (SSAInt(1) << yshift) - 1; + SSAInt x = xfrac >> xbits; + SSAInt y = yfrac >> ybits; + + SSAVec4i p00 = texture[((y & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(); + SSAVec4i p01 = texture[(((y + 1) & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(); + SSAVec4i p10 = texture[((y & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(); + SSAVec4i p11 = texture[(((y + 1) & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(); + + SSAInt inv_b = (xfrac >> (xbits - 4)) & 15; + SSAInt inv_a = (yfrac >> (ybits - 4)) & 15; + SSAInt a = 16 - inv_a; + SSAInt b = 16 - inv_b; + + return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; +} diff --git a/src/r_compiler/fixedfunction/fixedfunction.h b/src/r_compiler/fixedfunction/drawercodegen.h similarity index 61% rename from src/r_compiler/fixedfunction/fixedfunction.h rename to src/r_compiler/fixedfunction/drawercodegen.h index 1c58740d5..9e0706ed1 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.h +++ b/src/r_compiler/fixedfunction/drawercodegen.h @@ -50,53 +50,3 @@ public: SSAVec4i sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height); SSAVec4i sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits); }; - -enum class DrawSpanVariant -{ - Opaque, - Masked, - Translucent, - MaskedTranslucent, - AddClamp, - MaskedAddClamp -}; - -class DrawSpanCodegen : public DrawerCodegen -{ -public: - void Generate(DrawSpanVariant variant, SSAValue args); - -private: - void LoopShade(DrawSpanVariant variant, bool isSimpleShade); - void LoopFilter(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter); - SSAInt Loop4x(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64); - void Loop(SSAInt start, DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64); - SSAVec4i Sample(SSAInt xfrac, SSAInt yfrac, bool isNearestFilter, bool is64x64); - SSAVec4i Shade(SSAVec4i fg, bool isSimpleShade); - SSAVec4i Blend(SSAVec4i fg, SSAVec4i bg, DrawSpanVariant variant); - - SSAStack stack_index, stack_xfrac, stack_yfrac; - - SSAUBytePtr destorg; - SSAUBytePtr source; - SSAInt destpitch; - SSAInt xstep; - SSAInt ystep; - SSAInt x1; - SSAInt x2; - SSAInt y; - SSAInt xbits; - SSAInt ybits; - SSAInt light; - SSAInt srcalpha; - SSAInt destalpha; - SSAInt count; - SSAUBytePtr data; - SSAInt yshift; - SSAInt xshift; - SSAInt xmask; - SSABool is_64x64; - SSABool is_simple_shade; - SSABool is_nearest_filter; - SSAShadeConstants shade_constants; -}; diff --git a/src/r_compiler/fixedfunction/fixedfunction.cpp b/src/r_compiler/fixedfunction/drawspancodegen.cpp similarity index 57% rename from src/r_compiler/fixedfunction/fixedfunction.cpp rename to src/r_compiler/fixedfunction/drawspancodegen.cpp index fc5402a42..1623c38f2 100644 --- a/src/r_compiler/fixedfunction/fixedfunction.cpp +++ b/src/r_compiler/fixedfunction/drawspancodegen.cpp @@ -1,6 +1,6 @@ #include "i_system.h" -#include "r_compiler/fixedfunction/fixedfunction.h" +#include "r_compiler/fixedfunction/drawspancodegen.h" #include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_scope.h" #include "r_compiler/ssa/ssa_for_block.h" @@ -9,7 +9,6 @@ #include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_struct_type.h" #include "r_compiler/ssa/ssa_value.h" -#include "r_compiler/ssa/ssa_barycentric_weight.h" void DrawSpanCodegen::Generate(DrawSpanVariant variant, SSAValue args) { @@ -200,129 +199,3 @@ SSAVec4i DrawSpanCodegen::Blend(SSAVec4i fg, SSAVec4i bg, DrawSpanVariant varian return blend_add(fg, bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); } } - -///////////////////////////////////////////////////////////////////////////// - -SSAInt DrawerCodegen::calc_light_multiplier(SSAInt light) -{ - return 256 - (light >> (FRACBITS - 8)); -} - -SSAVec4i DrawerCodegen::shade_pal_index_simple(SSAInt index, SSAInt light, SSAUBytePtr basecolors) -{ - SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index]; - return shade_bgra_simple(color, light); -} - -SSAVec4i DrawerCodegen::shade_pal_index_advanced(SSAInt index, SSAInt light, const SSAShadeConstants &constants, SSAUBytePtr basecolors) -{ - SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index]; - return shade_bgra_advanced(color, light, constants); -} - -SSAVec4i DrawerCodegen::shade_bgra_simple(SSAVec4i color, SSAInt light) -{ - color = color * light / 256; - return color.insert(3, 255); -} - -SSAVec4i DrawerCodegen::shade_bgra_advanced(SSAVec4i color, SSAInt light, const SSAShadeConstants &constants) -{ - SSAInt blue = color[0]; - SSAInt green = color[1]; - SSAInt red = color[2]; - SSAInt alpha = color[3]; - - SSAInt intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; - - SSAVec4i inv_light = 256 - light; - SSAVec4i inv_desaturate = 256 - constants.desaturate; - - color = (color * inv_desaturate + intensity) / 256; - color = (constants.fade * inv_light + color * light) / 256; - color = (color * constants.light) / 256; - - return color.insert(3, alpha); -} - -SSAVec4i DrawerCodegen::blend_copy(SSAVec4i fg) -{ - return fg; -} - -SSAVec4i DrawerCodegen::blend_add(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) -{ - SSAVec4i color = (fg * srcalpha + bg * destalpha) / 256; - return color.insert(3, 255); -} - -SSAVec4i DrawerCodegen::blend_sub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) -{ - SSAVec4i color = (bg * destalpha - fg * srcalpha) / 256; - return color.insert(3, 255); -} - -SSAVec4i DrawerCodegen::blend_revsub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) -{ - SSAVec4i color = (fg * srcalpha - bg * destalpha) / 256; - return color.insert(3, 255); -} - -SSAVec4i DrawerCodegen::blend_alpha_blend(SSAVec4i fg, SSAVec4i bg) -{ - SSAInt alpha = fg[3]; - alpha = alpha + (alpha >> 7); // // 255 -> 256 - SSAInt inv_alpha = 256 - alpha; - SSAVec4i color = (fg * alpha + bg * inv_alpha) / 256; - return color.insert(3, 255); -} - -SSAInt DrawerCodegen::calc_blend_bgalpha(SSAVec4i fg, SSAInt destalpha) -{ - SSAInt alpha = fg[3]; - alpha = alpha + (alpha >> 7); - SSAInt inv_alpha = 256 - alpha; - return (destalpha * alpha + 256 * inv_alpha + 128) >> 8; -} - -SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height) -{ - SSAInt frac_y0 = (texturefracy >> FRACBITS) * height; - SSAInt frac_y1 = ((texturefracy + one) >> FRACBITS) * height; - SSAInt y0 = frac_y0 >> FRACBITS; - SSAInt y1 = frac_y1 >> FRACBITS; - - SSAVec4i p00 = col0[y0 * 4].load_vec4ub(); - SSAVec4i p01 = col0[y1 * 4].load_vec4ub(); - SSAVec4i p10 = col1[y0 * 4].load_vec4ub(); - SSAVec4i p11 = col1[y1 * 4].load_vec4ub(); - - SSAInt inv_b = texturefracx; - SSAInt inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; - SSAInt a = 16 - inv_a; - SSAInt b = 16 - inv_b; - - return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; -} - -SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits) -{ - SSAInt xshift = (32 - xbits); - SSAInt yshift = (32 - ybits); - SSAInt xmask = (SSAInt(1) << xshift) - 1; - SSAInt ymask = (SSAInt(1) << yshift) - 1; - SSAInt x = xfrac >> xbits; - SSAInt y = yfrac >> ybits; - - SSAVec4i p00 = texture[((y & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(); - SSAVec4i p01 = texture[(((y + 1) & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(); - SSAVec4i p10 = texture[((y & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(); - SSAVec4i p11 = texture[(((y + 1) & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(); - - SSAInt inv_b = (xfrac >> (xbits - 4)) & 15; - SSAInt inv_a = (yfrac >> (ybits - 4)) & 15; - SSAInt a = 16 - inv_a; - SSAInt b = 16 - inv_b; - - return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; -} diff --git a/src/r_compiler/fixedfunction/drawspancodegen.h b/src/r_compiler/fixedfunction/drawspancodegen.h new file mode 100644 index 000000000..20869ac2f --- /dev/null +++ b/src/r_compiler/fixedfunction/drawspancodegen.h @@ -0,0 +1,54 @@ + +#pragma once + +#include "drawercodegen.h" + +enum class DrawSpanVariant +{ + Opaque, + Masked, + Translucent, + MaskedTranslucent, + AddClamp, + MaskedAddClamp +}; + +class DrawSpanCodegen : public DrawerCodegen +{ +public: + void Generate(DrawSpanVariant variant, SSAValue args); + +private: + void LoopShade(DrawSpanVariant variant, bool isSimpleShade); + void LoopFilter(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter); + SSAInt Loop4x(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64); + void Loop(SSAInt start, DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64); + SSAVec4i Sample(SSAInt xfrac, SSAInt yfrac, bool isNearestFilter, bool is64x64); + SSAVec4i Shade(SSAVec4i fg, bool isSimpleShade); + SSAVec4i Blend(SSAVec4i fg, SSAVec4i bg, DrawSpanVariant variant); + + SSAStack stack_index, stack_xfrac, stack_yfrac; + + SSAUBytePtr destorg; + SSAUBytePtr source; + SSAInt destpitch; + SSAInt xstep; + SSAInt ystep; + SSAInt x1; + SSAInt x2; + SSAInt y; + SSAInt xbits; + SSAInt ybits; + SSAInt light; + SSAInt srcalpha; + SSAInt destalpha; + SSAInt count; + SSAUBytePtr data; + SSAInt yshift; + SSAInt xshift; + SSAInt xmask; + SSABool is_64x64; + SSABool is_simple_shade; + SSABool is_nearest_filter; + SSAShadeConstants shade_constants; +}; diff --git a/src/r_compiler/fixedfunction/drawwallcodegen.cpp b/src/r_compiler/fixedfunction/drawwallcodegen.cpp new file mode 100644 index 000000000..0e94c11ed --- /dev/null +++ b/src/r_compiler/fixedfunction/drawwallcodegen.cpp @@ -0,0 +1,15 @@ + +#include "i_system.h" +#include "r_compiler/fixedfunction/drawwallcodegen.h" +#include "r_compiler/ssa/ssa_function.h" +#include "r_compiler/ssa/ssa_scope.h" +#include "r_compiler/ssa/ssa_for_block.h" +#include "r_compiler/ssa/ssa_if_block.h" +#include "r_compiler/ssa/ssa_stack.h" +#include "r_compiler/ssa/ssa_function.h" +#include "r_compiler/ssa/ssa_struct_type.h" +#include "r_compiler/ssa/ssa_value.h" + +void DrawWallCodegen::Generate(DrawWallVariant variant, SSAValue args) +{ +} diff --git a/src/r_compiler/fixedfunction/drawwallcodegen.h b/src/r_compiler/fixedfunction/drawwallcodegen.h new file mode 100644 index 000000000..f514ca8ca --- /dev/null +++ b/src/r_compiler/fixedfunction/drawwallcodegen.h @@ -0,0 +1,26 @@ + +#pragma once + +#include "drawercodegen.h" + +enum class DrawWallVariant +{ + Opaque1, // vlinec1 + Opaque4, // vlinec4 + Masked1, // mvlinec1 + Masked4, // mvlinec4 + Add1, // tmvline1_add + Add4, // tmvline4_add + AddClamp1, // tmvline1_addclamp + AddClamp4, // tmvline4_addclamp + SubClamp1, // tmvline1_subclamp + SubClamp4, // tmvline4_subclamp + RevSubClamp1, // tmvline1_revsubclamp + RevSubClamp4, // tmvline4_revsubclamp +}; + +class DrawWallCodegen : public DrawerCodegen +{ +public: + void Generate(DrawWallVariant variant, SSAValue args); +}; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index fb4a6d023..320bfb653 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -1,6 +1,8 @@ #include "i_system.h" -#include "r_compiler/fixedfunction/fixedfunction.h" +#include "r_compiler/fixedfunction/drawspancodegen.h" +#include "r_compiler/fixedfunction/drawwallcodegen.h" +#include "r_compiler/fixedfunction/drawcolumncodegen.h" #include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_scope.h" #include "r_compiler/ssa/ssa_for_block.h" From afab45674ba32901d789a631d858757862650d3d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 29 Sep 2016 07:38:33 +0200 Subject: [PATCH 1003/1509] Added half of wall codegen --- .../fixedfunction/drawwallcodegen.cpp | 154 +++++++++++++++++- .../fixedfunction/drawwallcodegen.h | 49 ++++-- src/r_compiler/llvmdrawers.cpp | 70 +++++++- src/r_compiler/llvmdrawers.h | 46 ++++++ 4 files changed, 304 insertions(+), 15 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawwallcodegen.cpp b/src/r_compiler/fixedfunction/drawwallcodegen.cpp index 0e94c11ed..65b2224b5 100644 --- a/src/r_compiler/fixedfunction/drawwallcodegen.cpp +++ b/src/r_compiler/fixedfunction/drawwallcodegen.cpp @@ -10,6 +10,158 @@ #include "r_compiler/ssa/ssa_struct_type.h" #include "r_compiler/ssa/ssa_value.h" -void DrawWallCodegen::Generate(DrawWallVariant variant, SSAValue args) +void DrawWallCodegen::Generate(DrawWallVariant variant, bool fourColumns, SSAValue args) { + dest = args[0][0].load(); + source[0] = args[0][1].load(); + source[1] = args[0][2].load(); + source[2] = args[0][3].load(); + source[3] = args[0][4].load(); + source2[0] = args[0][5].load(); + source2[1] = args[0][6].load(); + source2[2] = args[0][7].load(); + source2[3] = args[0][8].load(); + pitch = args[0][9].load(); + count = args[0][10].load(); + dest_y = args[0][11].load(); + texturefrac[0] = args[0][12].load(); + texturefrac[1] = args[0][13].load(); + texturefrac[2] = args[0][14].load(); + texturefrac[3] = args[0][15].load(); + texturefracx[0] = args[0][16].load(); + texturefracx[1] = args[0][17].load(); + texturefracx[2] = args[0][18].load(); + texturefracx[3] = args[0][19].load(); + iscale[0] = args[0][20].load(); + iscale[1] = args[0][21].load(); + iscale[2] = args[0][22].load(); + iscale[3] = args[0][23].load(); + textureheight[0] = args[0][24].load(); + textureheight[1] = args[0][25].load(); + textureheight[2] = args[0][26].load(); + textureheight[3] = args[0][27].load(); + light[0] = args[0][28].load(); + light[1] = args[0][29].load(); + light[2] = args[0][30].load(); + light[3] = args[0][31].load(); + srcalpha = args[0][32].load(); + destalpha = args[0][33].load(); + SSAShort light_alpha = args[0][34].load(); + SSAShort light_red = args[0][35].load(); + SSAShort light_green = args[0][36].load(); + SSAShort light_blue = args[0][37].load(); + SSAShort fade_alpha = args[0][38].load(); + SSAShort fade_red = args[0][39].load(); + SSAShort fade_green = args[0][40].load(); + SSAShort fade_blue = args[0][41].load(); + SSAShort desaturate = args[0][42].load(); + SSAInt flags = args[0][43].load(); + shade_constants.light = SSAVec4i(light_blue.zext_int(), light_green.zext_int(), light_red.zext_int(), light_alpha.zext_int()); + shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); + shade_constants.desaturate = desaturate.zext_int(); + + is_simple_shade = (flags & DrawWallArgs::simple_shade) == DrawWallArgs::simple_shade; + is_nearest_filter = (flags & DrawWallArgs::nearest_filter) == DrawWallArgs::nearest_filter; + + /* + count = thread->count_for_thread(command->_dest_y, command->_count); + fracstep = command->_iscale * thread->num_cores; + frac = command->_texturefrac + command->_iscale * thread->skipped_by_thread(command->_dest_y); + texturefracx = command->_texturefracx; + dest = thread->dest_for_thread(command->_dest_y, command->_pitch, (uint32_t*)command->_dest); + pitch = command->_pitch * thread->num_cores; + height = command->_textureheight; + one = ((0x80000000 + height - 1) / height) * 2 + 1; + */ + int numColumns = fourColumns ? 4 : 1; + for (int i = 0; i < numColumns; i++) + { + stack_frac[i].store(texturefrac[i] + iscale[i]);// * skipped_by_thread(dest_y); + fracstep[i] = iscale[i];// * num_cores; + one[i] = ((0x80000000 + textureheight[i] - 1) / textureheight[i]) * 2 + 1; + } + + SSAIfBlock branch; + branch.if_block(is_simple_shade); + LoopShade(variant, fourColumns, true); + branch.else_block(); + LoopShade(variant, fourColumns, false); + branch.end_block(); +} + +void DrawWallCodegen::LoopShade(DrawWallVariant variant, bool fourColumns, bool isSimpleShade) +{ + SSAIfBlock branch; + branch.if_block(is_nearest_filter); + Loop(variant, fourColumns, isSimpleShade, true); + branch.else_block(); + Loop(variant, fourColumns, isSimpleShade, false); + branch.end_block(); +} + +void DrawWallCodegen::Loop(DrawWallVariant variant, bool fourColumns, bool isSimpleShade, bool isNearestFilter) +{ + int numColumns = fourColumns ? 4 : 1; + + stack_index.store(0); + { + SSAForBlock loop; + SSAInt index = stack_index.load(); + loop.loop_block(index < count); + + SSAInt frac[4]; + for (int i = 0; i < numColumns; i++) + frac[i] = stack_frac[i].load(); + + SSAInt offset = (dest_y + index) * pitch * 4; + + if (fourColumns) + { + + } + else + { + SSAVec4i bgcolor = dest[offset].load_vec4ub(); + SSAVec4i color = Blend(Shade(Sample(frac[0], isNearestFilter), 0, isSimpleShade), bgcolor, variant); + dest[offset].store_vec4ub(color); + } + + stack_index.store(index + 1); + for (int i = 0; i < numColumns; i++) + stack_frac[i].store(frac[i] + fracstep[i]); + loop.end_block(); + } +} + +SSAVec4i DrawWallCodegen::Sample(SSAInt frac, bool isNearestFilter) +{ + // int sample_index() { return ((frac >> FRACBITS) * height) >> FRACBITS; } + return SSAVec4i(0); +} + +SSAVec4i DrawWallCodegen::Shade(SSAVec4i fg, int index, bool isSimpleShade) +{ + if (isSimpleShade) + return shade_bgra_simple(fg, light[index]); + else + return shade_bgra_advanced(fg, light[index], shade_constants); +} + +SSAVec4i DrawWallCodegen::Blend(SSAVec4i fg, SSAVec4i bg, DrawWallVariant variant) +{ + switch (variant) + { + default: + case DrawWallVariant::Opaque: + return blend_copy(fg); + case DrawWallVariant::Masked: + return blend_alpha_blend(fg, bg); + case DrawWallVariant::Add: + case DrawWallVariant::AddClamp: + return blend_add(fg, bg, srcalpha, destalpha); + case DrawWallVariant::SubClamp: + return blend_sub(fg, bg, srcalpha, destalpha); + case DrawWallVariant::RevSubClamp: + return blend_revsub(fg, bg, srcalpha, destalpha); + } } diff --git a/src/r_compiler/fixedfunction/drawwallcodegen.h b/src/r_compiler/fixedfunction/drawwallcodegen.h index f514ca8ca..eafc8cf69 100644 --- a/src/r_compiler/fixedfunction/drawwallcodegen.h +++ b/src/r_compiler/fixedfunction/drawwallcodegen.h @@ -5,22 +5,45 @@ enum class DrawWallVariant { - Opaque1, // vlinec1 - Opaque4, // vlinec4 - Masked1, // mvlinec1 - Masked4, // mvlinec4 - Add1, // tmvline1_add - Add4, // tmvline4_add - AddClamp1, // tmvline1_addclamp - AddClamp4, // tmvline4_addclamp - SubClamp1, // tmvline1_subclamp - SubClamp4, // tmvline4_subclamp - RevSubClamp1, // tmvline1_revsubclamp - RevSubClamp4, // tmvline4_revsubclamp + Opaque, + Masked, + Add, + AddClamp, + SubClamp, + RevSubClamp }; class DrawWallCodegen : public DrawerCodegen { public: - void Generate(DrawWallVariant variant, SSAValue args); + void Generate(DrawWallVariant variant, bool fourColumns, SSAValue args); + +private: + void LoopShade(DrawWallVariant variant, bool fourColumns, bool isSimpleShade); + void Loop(DrawWallVariant variant, bool fourColumns, bool isSimpleShade, bool isNearestFilter); + SSAVec4i Sample(SSAInt frac, bool isNearestFilter); + SSAVec4i Shade(SSAVec4i fg, int index, bool isSimpleShade); + SSAVec4i Blend(SSAVec4i fg, SSAVec4i bg, DrawWallVariant variant); + + SSAStack stack_index, stack_frac[4]; + + SSAUBytePtr dest; + SSAUBytePtr source[4]; + SSAUBytePtr source2[4]; + SSAInt pitch; + SSAInt count; + SSAInt dest_y; + SSAInt texturefrac[4]; + SSAInt texturefracx[4]; + SSAInt iscale[4]; + SSAInt textureheight[4]; + SSAInt light[4]; + SSAInt srcalpha; + SSAInt destalpha; + SSABool is_simple_shade; + SSABool is_nearest_filter; + SSAShadeConstants shade_constants; + + SSAInt fracstep[4]; + SSAInt one[4]; }; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 320bfb653..57c3293bb 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -47,7 +47,10 @@ public: private: void CodegenDrawSpan(const char *name, DrawSpanVariant variant); + void CodegenDrawWall(const char *name, DrawWallVariant variant, int columns); + static llvm::Type *GetDrawSpanArgsStruct(llvm::LLVMContext &context); + static llvm::Type *GetDrawWallArgsStruct(llvm::LLVMContext &context); LLVMProgram mProgram; }; @@ -83,6 +86,18 @@ LLVMDrawersImpl::LLVMDrawersImpl() CodegenDrawSpan("DrawSpanMaskedTranslucent", DrawSpanVariant::MaskedTranslucent); CodegenDrawSpan("DrawSpanAddClamp", DrawSpanVariant::AddClamp); CodegenDrawSpan("DrawSpanMaskedAddClamp", DrawSpanVariant::MaskedAddClamp); + CodegenDrawWall("vlinec1", DrawWallVariant::Opaque, 1); + CodegenDrawWall("vlinec4", DrawWallVariant::Opaque, 4); + CodegenDrawWall("mvlinec1", DrawWallVariant::Masked, 1); + CodegenDrawWall("mvlinec4", DrawWallVariant::Masked, 4); + CodegenDrawWall("tmvline1_add", DrawWallVariant::Add, 1); + CodegenDrawWall("tmvline4_add", DrawWallVariant::Add, 4); + CodegenDrawWall("tmvline1_addclamp", DrawWallVariant::AddClamp, 1); + CodegenDrawWall("tmvline4_addclamp", DrawWallVariant::AddClamp, 4); + CodegenDrawWall("tmvline1_subclamp", DrawWallVariant::SubClamp, 1); + CodegenDrawWall("tmvline4_subclamp", DrawWallVariant::SubClamp, 4); + CodegenDrawWall("tmvline1_revsubclamp", DrawWallVariant::RevSubClamp, 1); + CodegenDrawWall("tmvline4_revsubclamp", DrawWallVariant::RevSubClamp, 4); mProgram.engine()->finalizeObject(); mProgram.modulePassManager()->run(*mProgram.module()); @@ -93,6 +108,18 @@ LLVMDrawersImpl::LLVMDrawersImpl() DrawSpanMaskedTranslucent = mProgram.GetProcAddress("DrawSpanMaskedTranslucent"); DrawSpanAddClamp = mProgram.GetProcAddress("DrawSpanAddClamp"); DrawSpanMaskedAddClamp = mProgram.GetProcAddress("DrawSpanMaskedAddClamp"); + vlinec1 = mProgram.GetProcAddress("vlinec1"); + vlinec4 = mProgram.GetProcAddress("vlinec4"); + mvlinec1 = mProgram.GetProcAddress("mvlinec1"); + mvlinec4 = mProgram.GetProcAddress("mvlinec4"); + tmvline1_add = mProgram.GetProcAddress("tmvline1_add"); + tmvline4_add = mProgram.GetProcAddress("tmvline4_add"); + tmvline1_addclamp = mProgram.GetProcAddress("tmvline1_addclamp"); + tmvline4_addclamp = mProgram.GetProcAddress("tmvline4_addclamp"); + tmvline1_subclamp = mProgram.GetProcAddress("tmvline1_subclamp"); + tmvline4_subclamp = mProgram.GetProcAddress("tmvline4_subclamp"); + tmvline1_revsubclamp = mProgram.GetProcAddress("tmvline1_revsubclamp"); + tmvline4_revsubclamp = mProgram.GetProcAddress("tmvline4_revsubclamp"); mProgram.StopLogFatalErrors(); } @@ -117,11 +144,31 @@ void LLVMDrawersImpl::CodegenDrawSpan(const char *name, DrawSpanVariant variant) mProgram.functionPassManager()->run(*function.func); } +void LLVMDrawersImpl::CodegenDrawWall(const char *name, DrawWallVariant variant, int columns) +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function(name); + function.add_parameter(GetDrawWallArgsStruct(mProgram.context())); + function.create_public(); + + DrawWallCodegen codegen; + codegen.Generate(variant, columns == 4, function.parameter(0)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + I_FatalError("verifyFunction failed for " __FUNCTION__); + + mProgram.functionPassManager()->run(*function.func); +} + llvm::Type *LLVMDrawersImpl::GetDrawSpanArgsStruct(llvm::LLVMContext &context) { std::vector elements; elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *destorg; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *source; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source; elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t destpitch; elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xfrac; elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t yfrac; @@ -148,6 +195,27 @@ llvm::Type *LLVMDrawersImpl::GetDrawSpanArgsStruct(llvm::LLVMContext &context) return llvm::StructType::get(context, elements, false)->getPointerTo(); } +llvm::Type *LLVMDrawersImpl::GetDrawWallArgsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); + for (int i = 0; i < 8; i++) + elements.push_back(llvm::Type::getInt8PtrTy(context)); + for (int i = 0; i < 25; i++) + elements.push_back(llvm::Type::getInt32Ty(context)); + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; + return llvm::StructType::get(context, elements, false)->getPointerTo(); +} + ///////////////////////////////////////////////////////////////////////////// namespace { static bool LogFatalErrors = false; } diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 53e64032f..92f7e9440 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -1,6 +1,39 @@ #pragma once +struct DrawWallArgs +{ + uint32_t *dest; + const uint32_t *source[4]; + const uint32_t *source2[4]; + int32_t pitch; + int32_t count; + int32_t dest_y; + uint32_t texturefrac[4]; + uint32_t texturefracx[4]; + uint32_t iscale[4]; + uint32_t textureheight[4]; + uint32_t light[4]; + uint32_t srcalpha; + uint32_t destalpha; + + uint16_t light_alpha; + uint16_t light_red; + uint16_t light_green; + uint16_t light_blue; + uint16_t fade_alpha; + uint16_t fade_red; + uint16_t fade_green; + uint16_t fade_blue; + uint16_t desaturate; + uint32_t flags; + enum Flags + { + simple_shade = 1, + nearest_filter = 2 + }; +}; + struct DrawSpanArgs { uint32_t *destorg; @@ -52,6 +85,19 @@ public: void(*DrawSpanAddClamp)(const DrawSpanArgs *) = nullptr; void(*DrawSpanMaskedAddClamp)(const DrawSpanArgs *) = nullptr; + void(*vlinec1)(const DrawWallArgs *) = nullptr; + void(*vlinec4)(const DrawWallArgs *) = nullptr; + void(*mvlinec1)(const DrawWallArgs *) = nullptr; + void(*mvlinec4)(const DrawWallArgs *) = nullptr; + void(*tmvline1_add)(const DrawWallArgs *) = nullptr; + void(*tmvline4_add)(const DrawWallArgs *) = nullptr; + void(*tmvline1_addclamp)(const DrawWallArgs *) = nullptr; + void(*tmvline4_addclamp)(const DrawWallArgs *) = nullptr; + void(*tmvline1_subclamp)(const DrawWallArgs *) = nullptr; + void(*tmvline4_subclamp)(const DrawWallArgs *) = nullptr; + void(*tmvline1_revsubclamp)(const DrawWallArgs *) = nullptr; + void(*tmvline4_revsubclamp)(const DrawWallArgs *) = nullptr; + private: static LLVMDrawers *Singleton; }; From 2987668af848b5780370051f20bbf2bc39e12930 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 29 Sep 2016 06:20:30 -0400 Subject: [PATCH 1004/1509] Non-tiling skies (Heretic/Hexen) now render properly. --- src/r_plane.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 706d6fad7..7c4e44358 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1011,7 +1011,7 @@ static void R_DrawSky (visplane_t *pl) { // The texture does not tile nicely frontyScale *= skyscale; frontiScale = 1 / frontyScale; - //R_DrawSkyStriped (pl); + R_DrawSkyStriped (pl); } } From d58da58aeef3833d79910933acb32c2d2744f811 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 29 Sep 2016 12:20:32 -0400 Subject: [PATCH 1005/1509] - fixed: Prevents too many drawer thread commands from queueing up. Previously, drawing too many columns (which was accumulated by amassing a huge number of sprites) would crash the game. --- src/r_draw_rgba.cpp | 2 ++ src/r_draw_rgba.h | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 0d86ead47..91044d1dd 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -55,6 +55,8 @@ extern int wallshade; // Use multiple threads when drawing CVAR(Bool, r_multithreaded, true, 0); +// [SP] Set Max Threads to a sane amount +CVAR(Int, r_multithreadedmax, 1024, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); // Use linear filtering when scaling up CVAR(Bool, r_magfilter, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index df3d0f233..e5fa88ed0 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -196,6 +196,7 @@ public: EXTERN_CVAR(Bool, r_multithreaded) EXTERN_CVAR(Bool, r_mipmap) +EXTERN_CVAR(Int, r_multithreadedmax) // Manages queueing up commands and executing them on worker threads class DrawerCommandQueue @@ -248,6 +249,14 @@ public: } else { + // [SP] Note: I've put in a hack here to throttle the speed of the rendering if + // the thread queue gets to big. This is one way to prevent too many commands + // going into the thread queue, which is causing crashes when there are too + // many threads (of which, there can be only as many as there are columns on + // the screen - guess what happens when you're too full of sprites!) + if (queue->commands.size() > r_multithreadedmax) + R_EndDrawerCommands(); + void *ptr = AllocMemory(sizeof(T)); if (!ptr) // Out of memory - render what we got { From 7cbaf80a2a7e89cab1a1164c724d29330a6042a1 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 29 Sep 2016 12:49:10 -0400 Subject: [PATCH 1006/1509] - Okay - so - last commit didn't actually fix anything. I think for now, it's better to turn off multi-threading by default until this can be fixed. r_multithreading has been changed to false by default, and is now saved in the user's .ini. --- src/r_draw_rgba.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 91044d1dd..127697356 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -54,7 +54,7 @@ extern float rw_lightstep; extern int wallshade; // Use multiple threads when drawing -CVAR(Bool, r_multithreaded, true, 0); +CVAR(Bool, r_multithreaded, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); // [SP] Set Max Threads to a sane amount CVAR(Int, r_multithreadedmax, 1024, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); From 1560ed07af4fb5a3a03cf7d2051bce334aee2530 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 29 Sep 2016 20:00:00 -0400 Subject: [PATCH 1007/1509] Added a hack that allows maps using fogmap to display properly in the true-color renderer. Unfortunately, this could be implemented better but at least for now it's here. --- src/g_level.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/g_level.cpp b/src/g_level.cpp index e27141ecd..2f4939c62 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1340,6 +1340,7 @@ void G_InitLevelLocals () R_SetDefaultColormap (info->FadeTable); if (strnicmp (info->FadeTable, "COLORMAP", 8) != 0) { + //level.fadeto = 0xff939393; //[SP] Hexen True-color compatibility, just use gray. level.flags |= LEVEL_HASFADETABLE; } /* From bbec9b86a35c847b2fc394117524b3212f10370e Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 29 Sep 2016 20:00:56 -0400 Subject: [PATCH 1008/1509] - fixed: un-commented the line with said hack. oops. --- src/g_level.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_level.cpp b/src/g_level.cpp index 2f4939c62..dc73bdaf8 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1340,7 +1340,7 @@ void G_InitLevelLocals () R_SetDefaultColormap (info->FadeTable); if (strnicmp (info->FadeTable, "COLORMAP", 8) != 0) { - //level.fadeto = 0xff939393; //[SP] Hexen True-color compatibility, just use gray. + level.fadeto = 0xff939393; //[SP] Hexen True-color compatibility, just use gray. level.flags |= LEVEL_HASFADETABLE; } /* From 6e3a49b065b00fb69695cec45601c35e7c0fdccd Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 29 Sep 2016 21:29:40 -0400 Subject: [PATCH 1009/1509] Multilayer skies (Hexen) now properly show in truecolor mode. This is only supported for paletted skies, but it still offers a true-color output. --- src/r_plane.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 7c4e44358..0cfd51ca5 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -920,7 +920,7 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) } else { - return R_GetOneSkyColumn(fronttex, x); + //return R_GetOneSkyColumn(fronttex, x); for (i = 0; i < 4; ++i) { if (lastskycol_bgra[i] == skycol) @@ -939,11 +939,14 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) const uint32_t *front = (const uint32_t *)fronttex->GetColumnBgra(angle1, NULL); const uint32_t *back = (const uint32_t *)backskytex->GetColumnBgra(angle2, NULL); + //[SP] Paletted version is used for comparison only + const BYTE *frontcompare = fronttex->GetColumn(angle1, NULL); + int count = MIN(512, MIN(backskytex->GetHeight(), fronttex->GetHeight())); i = 0; do { - if (front[i]) + if (frontcompare[i]) { composite[i] = front[i]; } From 28bb5da181535e5639d655efc44a0b177be5fa72 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 30 Sep 2016 07:27:25 +0200 Subject: [PATCH 1010/1509] Hooked up LLVM wall drawers --- .../fixedfunction/drawercodegen.cpp | 29 +- src/r_compiler/fixedfunction/drawercodegen.h | 21 ++ .../fixedfunction/drawwallcodegen.cpp | 59 ++-- .../fixedfunction/drawwallcodegen.h | 5 +- src/r_compiler/llvmdrawers.cpp | 36 ++- src/r_compiler/llvmdrawers.h | 32 ++- src/r_compiler/ssa/ssa_int.cpp | 11 + src/r_compiler/ssa/ssa_int.h | 3 + src/r_draw_rgba.cpp | 261 ++++++++++++++++++ 9 files changed, 410 insertions(+), 47 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawercodegen.cpp b/src/r_compiler/fixedfunction/drawercodegen.cpp index 5da858e27..2cba50121 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.cpp +++ b/src/r_compiler/fixedfunction/drawercodegen.cpp @@ -10,6 +10,31 @@ #include "r_compiler/ssa/ssa_struct_type.h" #include "r_compiler/ssa/ssa_value.h" +SSABool DrawerCodegen::line_skipped_by_thread(SSAInt line, SSAWorkerThread thread) +{ + return line < thread.pass_start_y || line >= thread.pass_end_y || !(line % thread.num_cores == thread.core); +} + +SSAInt DrawerCodegen::skipped_by_thread(SSAInt first_line, SSAWorkerThread thread) +{ + SSAInt pass_skip = SSAInt::MAX(thread.pass_start_y - first_line, 0); + SSAInt core_skip = (thread.num_cores - (first_line + pass_skip - thread.core) % thread.num_cores) % thread.num_cores; + return pass_skip + core_skip; +} + +SSAInt DrawerCodegen::count_for_thread(SSAInt first_line, SSAInt count, SSAWorkerThread thread) +{ + SSAInt lines_until_pass_end = SSAInt::MAX(thread.pass_end_y - first_line, 0); + count = SSAInt::MIN(count, lines_until_pass_end); + SSAInt c = (count - skipped_by_thread(first_line, thread) + thread.num_cores - 1) / thread.num_cores; + return SSAInt::MAX(c, 0); +} + +SSAUBytePtr DrawerCodegen::dest_for_thread(SSAInt first_line, SSAInt pitch, SSAUBytePtr dest, SSAWorkerThread thread) +{ + return dest[skipped_by_thread(first_line, thread) * pitch * 4]; +} + SSAInt DrawerCodegen::calc_light_multiplier(SSAInt light) { return 256 - (light >> (FRACBITS - 8)); @@ -105,8 +130,8 @@ SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt SSAVec4i p11 = col1[y1 * 4].load_vec4ub(); SSAInt inv_b = texturefracx; - SSAInt inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; - SSAInt a = 16 - inv_a; + SSAInt a = (frac_y1 >> (FRACBITS - 4)) & 15; + SSAInt inv_a = 16 - a; SSAInt b = 16 - inv_b; return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; diff --git a/src/r_compiler/fixedfunction/drawercodegen.h b/src/r_compiler/fixedfunction/drawercodegen.h index 9e0706ed1..17b36234d 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.h +++ b/src/r_compiler/fixedfunction/drawercodegen.h @@ -18,6 +18,15 @@ #include "r_compiler/ssa/ssa_barycentric_weight.h" #include "r_compiler/llvm_include.h" +class SSAWorkerThread +{ +public: + SSAInt core; + SSAInt num_cores; + SSAInt pass_start_y; + SSAInt pass_end_y; +}; + class SSAShadeConstants { public: @@ -29,6 +38,18 @@ public: class DrawerCodegen { public: + // Checks if a line is rendered by this thread + SSABool line_skipped_by_thread(SSAInt line, SSAWorkerThread thread); + + // The number of lines to skip to reach the first line to be rendered by this thread + SSAInt skipped_by_thread(SSAInt first_line, SSAWorkerThread thread); + + // The number of lines to be rendered by this thread + SSAInt count_for_thread(SSAInt first_line, SSAInt count, SSAWorkerThread thread); + + // Calculate the dest address for the first line to be rendered by this thread + SSAUBytePtr dest_for_thread(SSAInt first_line, SSAInt pitch, SSAUBytePtr dest, SSAWorkerThread thread); + // LightBgra SSAInt calc_light_multiplier(SSAInt light); SSAVec4i shade_pal_index_simple(SSAInt index, SSAInt light, SSAUBytePtr basecolors); diff --git a/src/r_compiler/fixedfunction/drawwallcodegen.cpp b/src/r_compiler/fixedfunction/drawwallcodegen.cpp index 65b2224b5..0ca537723 100644 --- a/src/r_compiler/fixedfunction/drawwallcodegen.cpp +++ b/src/r_compiler/fixedfunction/drawwallcodegen.cpp @@ -10,7 +10,7 @@ #include "r_compiler/ssa/ssa_struct_type.h" #include "r_compiler/ssa/ssa_value.h" -void DrawWallCodegen::Generate(DrawWallVariant variant, bool fourColumns, SSAValue args) +void DrawWallCodegen::Generate(DrawWallVariant variant, bool fourColumns, SSAValue args, SSAValue thread_data) { dest = args[0][0].load(); source[0] = args[0][1].load(); @@ -60,24 +60,24 @@ void DrawWallCodegen::Generate(DrawWallVariant variant, bool fourColumns, SSAVal shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); shade_constants.desaturate = desaturate.zext_int(); + thread.core = thread_data[0][0].load(); + thread.num_cores = thread_data[0][1].load(); + thread.pass_start_y = thread_data[0][2].load(); + thread.pass_end_y = thread_data[0][3].load(); + is_simple_shade = (flags & DrawWallArgs::simple_shade) == DrawWallArgs::simple_shade; is_nearest_filter = (flags & DrawWallArgs::nearest_filter) == DrawWallArgs::nearest_filter; - /* - count = thread->count_for_thread(command->_dest_y, command->_count); - fracstep = command->_iscale * thread->num_cores; - frac = command->_texturefrac + command->_iscale * thread->skipped_by_thread(command->_dest_y); - texturefracx = command->_texturefracx; - dest = thread->dest_for_thread(command->_dest_y, command->_pitch, (uint32_t*)command->_dest); - pitch = command->_pitch * thread->num_cores; - height = command->_textureheight; - one = ((0x80000000 + height - 1) / height) * 2 + 1; - */ + count = count_for_thread(dest_y, count, thread); + dest = dest_for_thread(dest_y, pitch, dest, thread); + + pitch = pitch * thread.num_cores; + int numColumns = fourColumns ? 4 : 1; for (int i = 0; i < numColumns; i++) { - stack_frac[i].store(texturefrac[i] + iscale[i]);// * skipped_by_thread(dest_y); - fracstep[i] = iscale[i];// * num_cores; + stack_frac[i].store(texturefrac[i] + iscale[i] * skipped_by_thread(dest_y, thread)); + fracstep[i] = iscale[i] * thread.num_cores; one[i] = ((0x80000000 + textureheight[i] - 1) / textureheight[i]) * 2 + 1; } @@ -113,16 +113,32 @@ void DrawWallCodegen::Loop(DrawWallVariant variant, bool fourColumns, bool isSim for (int i = 0; i < numColumns; i++) frac[i] = stack_frac[i].load(); - SSAInt offset = (dest_y + index) * pitch * 4; + SSAInt offset = index * pitch * 4; if (fourColumns) { + SSAVec16ub bg = dest[offset].load_unaligned_vec16ub(); + SSAVec8s bg0 = SSAVec8s::extendlo(bg); + SSAVec8s bg1 = SSAVec8s::extendhi(bg); + SSAVec4i bgcolors[4] = + { + SSAVec4i::extendlo(bg0), + SSAVec4i::extendhi(bg0), + SSAVec4i::extendlo(bg1), + SSAVec4i::extendhi(bg1) + }; + SSAVec4i colors[4]; + for (int i = 0; i < 4; i++) + colors[i] = Blend(Shade(Sample(frac[i], i, isNearestFilter), i, isSimpleShade), bgcolors[i], variant); + + SSAVec16ub color(SSAVec8s(colors[0], colors[1]), SSAVec8s(colors[2], colors[3])); + dest[offset].store_unaligned_vec16ub(color); } else { SSAVec4i bgcolor = dest[offset].load_vec4ub(); - SSAVec4i color = Blend(Shade(Sample(frac[0], isNearestFilter), 0, isSimpleShade), bgcolor, variant); + SSAVec4i color = Blend(Shade(Sample(frac[0], 0, isNearestFilter), 0, isSimpleShade), bgcolor, variant); dest[offset].store_vec4ub(color); } @@ -133,10 +149,17 @@ void DrawWallCodegen::Loop(DrawWallVariant variant, bool fourColumns, bool isSim } } -SSAVec4i DrawWallCodegen::Sample(SSAInt frac, bool isNearestFilter) +SSAVec4i DrawWallCodegen::Sample(SSAInt frac, int index, bool isNearestFilter) { - // int sample_index() { return ((frac >> FRACBITS) * height) >> FRACBITS; } - return SSAVec4i(0); + if (isNearestFilter) + { + SSAInt sample_index = ((frac >> FRACBITS) * textureheight[index]) >> FRACBITS; + return source[index][sample_index * 4].load_vec4ub(); + } + else + { + return sample_linear(source[index], source2[index], texturefracx[index], frac, one[index], textureheight[index]); + } } SSAVec4i DrawWallCodegen::Shade(SSAVec4i fg, int index, bool isSimpleShade) diff --git a/src/r_compiler/fixedfunction/drawwallcodegen.h b/src/r_compiler/fixedfunction/drawwallcodegen.h index eafc8cf69..0e1cce5fc 100644 --- a/src/r_compiler/fixedfunction/drawwallcodegen.h +++ b/src/r_compiler/fixedfunction/drawwallcodegen.h @@ -16,12 +16,12 @@ enum class DrawWallVariant class DrawWallCodegen : public DrawerCodegen { public: - void Generate(DrawWallVariant variant, bool fourColumns, SSAValue args); + void Generate(DrawWallVariant variant, bool fourColumns, SSAValue args, SSAValue thread_data); private: void LoopShade(DrawWallVariant variant, bool fourColumns, bool isSimpleShade); void Loop(DrawWallVariant variant, bool fourColumns, bool isSimpleShade, bool isNearestFilter); - SSAVec4i Sample(SSAInt frac, bool isNearestFilter); + SSAVec4i Sample(SSAInt frac, int index, bool isNearestFilter); SSAVec4i Shade(SSAVec4i fg, int index, bool isSimpleShade); SSAVec4i Blend(SSAVec4i fg, SSAVec4i bg, DrawWallVariant variant); @@ -43,6 +43,7 @@ private: SSABool is_simple_shade; SSABool is_nearest_filter; SSAShadeConstants shade_constants; + SSAWorkerThread thread; SSAInt fracstep[4]; SSAInt one[4]; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 57c3293bb..60727744c 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -51,6 +51,7 @@ private: static llvm::Type *GetDrawSpanArgsStruct(llvm::LLVMContext &context); static llvm::Type *GetDrawWallArgsStruct(llvm::LLVMContext &context); + static llvm::Type *GetWorkerThreadDataStruct(llvm::LLVMContext &context); LLVMProgram mProgram; }; @@ -108,18 +109,18 @@ LLVMDrawersImpl::LLVMDrawersImpl() DrawSpanMaskedTranslucent = mProgram.GetProcAddress("DrawSpanMaskedTranslucent"); DrawSpanAddClamp = mProgram.GetProcAddress("DrawSpanAddClamp"); DrawSpanMaskedAddClamp = mProgram.GetProcAddress("DrawSpanMaskedAddClamp"); - vlinec1 = mProgram.GetProcAddress("vlinec1"); - vlinec4 = mProgram.GetProcAddress("vlinec4"); - mvlinec1 = mProgram.GetProcAddress("mvlinec1"); - mvlinec4 = mProgram.GetProcAddress("mvlinec4"); - tmvline1_add = mProgram.GetProcAddress("tmvline1_add"); - tmvline4_add = mProgram.GetProcAddress("tmvline4_add"); - tmvline1_addclamp = mProgram.GetProcAddress("tmvline1_addclamp"); - tmvline4_addclamp = mProgram.GetProcAddress("tmvline4_addclamp"); - tmvline1_subclamp = mProgram.GetProcAddress("tmvline1_subclamp"); - tmvline4_subclamp = mProgram.GetProcAddress("tmvline4_subclamp"); - tmvline1_revsubclamp = mProgram.GetProcAddress("tmvline1_revsubclamp"); - tmvline4_revsubclamp = mProgram.GetProcAddress("tmvline4_revsubclamp"); + vlinec1 = mProgram.GetProcAddress("vlinec1"); + vlinec4 = mProgram.GetProcAddress("vlinec4"); + mvlinec1 = mProgram.GetProcAddress("mvlinec1"); + mvlinec4 = mProgram.GetProcAddress("mvlinec4"); + tmvline1_add = mProgram.GetProcAddress("tmvline1_add"); + tmvline4_add = mProgram.GetProcAddress("tmvline4_add"); + tmvline1_addclamp = mProgram.GetProcAddress("tmvline1_addclamp"); + tmvline4_addclamp = mProgram.GetProcAddress("tmvline4_addclamp"); + tmvline1_subclamp = mProgram.GetProcAddress("tmvline1_subclamp"); + tmvline4_subclamp = mProgram.GetProcAddress("tmvline4_subclamp"); + tmvline1_revsubclamp = mProgram.GetProcAddress("tmvline1_revsubclamp"); + tmvline4_revsubclamp = mProgram.GetProcAddress("tmvline4_revsubclamp"); mProgram.StopLogFatalErrors(); } @@ -151,10 +152,11 @@ void LLVMDrawersImpl::CodegenDrawWall(const char *name, DrawWallVariant variant, SSAFunction function(name); function.add_parameter(GetDrawWallArgsStruct(mProgram.context())); + function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); function.create_public(); DrawWallCodegen codegen; - codegen.Generate(variant, columns == 4, function.parameter(0)); + codegen.Generate(variant, columns == 4, function.parameter(0), function.parameter(1)); builder.CreateRetVoid(); @@ -216,6 +218,14 @@ llvm::Type *LLVMDrawersImpl::GetDrawWallArgsStruct(llvm::LLVMContext &context) return llvm::StructType::get(context, elements, false)->getPointerTo(); } +llvm::Type *LLVMDrawersImpl::GetWorkerThreadDataStruct(llvm::LLVMContext &context) +{ + std::vector elements; + for (int i = 0; i < 4; i++) + elements.push_back(llvm::Type::getInt32Ty(context)); + return llvm::StructType::get(context, elements, false)->getPointerTo(); +} + ///////////////////////////////////////////////////////////////////////////// namespace { static bool LogFatalErrors = false; } diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 92f7e9440..b1039cf49 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -1,6 +1,14 @@ #pragma once +struct WorkerThreadData +{ + int32_t core; + int32_t num_cores; + int32_t pass_start_y; + int32_t pass_end_y; +}; + struct DrawWallArgs { uint32_t *dest; @@ -85,18 +93,18 @@ public: void(*DrawSpanAddClamp)(const DrawSpanArgs *) = nullptr; void(*DrawSpanMaskedAddClamp)(const DrawSpanArgs *) = nullptr; - void(*vlinec1)(const DrawWallArgs *) = nullptr; - void(*vlinec4)(const DrawWallArgs *) = nullptr; - void(*mvlinec1)(const DrawWallArgs *) = nullptr; - void(*mvlinec4)(const DrawWallArgs *) = nullptr; - void(*tmvline1_add)(const DrawWallArgs *) = nullptr; - void(*tmvline4_add)(const DrawWallArgs *) = nullptr; - void(*tmvline1_addclamp)(const DrawWallArgs *) = nullptr; - void(*tmvline4_addclamp)(const DrawWallArgs *) = nullptr; - void(*tmvline1_subclamp)(const DrawWallArgs *) = nullptr; - void(*tmvline4_subclamp)(const DrawWallArgs *) = nullptr; - void(*tmvline1_revsubclamp)(const DrawWallArgs *) = nullptr; - void(*tmvline4_revsubclamp)(const DrawWallArgs *) = nullptr; + void(*vlinec1)(const DrawWallArgs *, const WorkerThreadData *) = nullptr; + void(*vlinec4)(const DrawWallArgs *, const WorkerThreadData *) = nullptr; + void(*mvlinec1)(const DrawWallArgs *, const WorkerThreadData *) = nullptr; + void(*mvlinec4)(const DrawWallArgs *, const WorkerThreadData *) = nullptr; + void(*tmvline1_add)(const DrawWallArgs *, const WorkerThreadData *) = nullptr; + void(*tmvline4_add)(const DrawWallArgs *, const WorkerThreadData *) = nullptr; + void(*tmvline1_addclamp)(const DrawWallArgs *, const WorkerThreadData *) = nullptr; + void(*tmvline4_addclamp)(const DrawWallArgs *, const WorkerThreadData *) = nullptr; + void(*tmvline1_subclamp)(const DrawWallArgs *, const WorkerThreadData *) = nullptr; + void(*tmvline4_subclamp)(const DrawWallArgs *, const WorkerThreadData *) = nullptr; + void(*tmvline1_revsubclamp)(const DrawWallArgs *, const WorkerThreadData *) = nullptr; + void(*tmvline4_revsubclamp)(const DrawWallArgs *, const WorkerThreadData *) = nullptr; private: static LLVMDrawers *Singleton; diff --git a/src/r_compiler/ssa/ssa_int.cpp b/src/r_compiler/ssa/ssa_int.cpp index 674f44350..8d5a32e4c 100644 --- a/src/r_compiler/ssa/ssa_int.cpp +++ b/src/r_compiler/ssa/ssa_int.cpp @@ -1,6 +1,7 @@ #include "ssa_int.h" #include "ssa_float.h" +#include "ssa_bool.h" #include "ssa_scope.h" #include "r_compiler/llvm_include.h" @@ -31,6 +32,16 @@ llvm::Type *SSAInt::llvm_type() return llvm::Type::getInt32Ty(SSAScope::context()); } +SSAInt SSAInt::MIN(SSAInt a, SSAInt b) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateSelect((a < b).v, a.v, b.v, SSAScope::hint())); +} + +SSAInt SSAInt::MAX(SSAInt a, SSAInt b) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateSelect((a > b).v, a.v, b.v, SSAScope::hint())); +} + SSAInt operator+(const SSAInt &a, const SSAInt &b) { return SSAInt::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); diff --git a/src/r_compiler/ssa/ssa_int.h b/src/r_compiler/ssa/ssa_int.h index 5e373c62e..d928c41f2 100644 --- a/src/r_compiler/ssa/ssa_int.h +++ b/src/r_compiler/ssa/ssa_int.h @@ -16,6 +16,9 @@ public: static SSAInt from_llvm(llvm::Value *v) { return SSAInt(v); } static llvm::Type *llvm_type(); + static SSAInt MIN(SSAInt a, SSAInt b); + static SSAInt MAX(SSAInt a, SSAInt b); + llvm::Value *v; }; diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 8a0a6871a..c76c2c3c5 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -404,6 +404,219 @@ public: ///////////////////////////////////////////////////////////////////////////// +class DrawWall4LLVMCommand : public DrawerCommand +{ +protected: + DrawWallArgs args; + + WorkerThreadData ThreadData(DrawerThread *thread) + { + WorkerThreadData d; + d.core = thread->core; + d.num_cores = thread->num_cores; + d.pass_start_y = thread->pass_start_y; + d.pass_end_y = thread->pass_end_y; + return d; + } + +public: + DrawWall4LLVMCommand() + { + args.dest = (uint32_t*)dc_dest; + args.dest_y = _dest_y; + args.count = dc_count; + args.pitch = dc_pitch; + args.light_red = dc_shade_constants.light_red; + args.light_green = dc_shade_constants.light_green; + args.light_blue = dc_shade_constants.light_blue; + args.light_alpha = dc_shade_constants.light_alpha; + args.fade_red = dc_shade_constants.fade_red; + args.fade_green = dc_shade_constants.fade_green; + args.fade_blue = dc_shade_constants.fade_blue; + args.fade_alpha = dc_shade_constants.fade_alpha; + args.desaturate = dc_shade_constants.desaturate; + for (int i = 0; i < 4; i++) + { + args.texturefrac[i] = vplce[i]; + args.iscale[i] = vince[i]; + args.texturefracx[i] = buftexturefracx[i]; + args.textureheight[i] = bufheight[i]; + args.source[i] = (const uint32_t *)bufplce[i]; + args.source2[i] = (const uint32_t *)bufplce2[i]; + args.light[i] = LightBgra::calc_light_multiplier(palookuplight[i]); + } + args.srcalpha = dc_srcalpha >> (FRACBITS - 8); + args.destalpha = dc_destalpha >> (FRACBITS - 8); + args.flags = 0; + if (dc_shade_constants.simple_shade) + args.flags |= DrawWallArgs::simple_shade; + if (args.source2[0] == nullptr) + args.flags |= DrawWallArgs::nearest_filter; + } + + void Execute(DrawerThread *thread) override + { + WorkerThreadData d = ThreadData(thread); + LLVMDrawers::Instance()->vlinec4(&args, &d); + } +}; + +class DrawWallMasked4LLVMCommand : public DrawWall4LLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + WorkerThreadData d = ThreadData(thread); + LLVMDrawers::Instance()->mvlinec4(&args, &d); + } +}; + +class DrawWallAdd4LLVMCommand : public DrawWall4LLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + WorkerThreadData d = ThreadData(thread); + LLVMDrawers::Instance()->tmvline4_add(&args, &d); + } +}; + +class DrawWallAddClamp4LLVMCommand : public DrawWall4LLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + WorkerThreadData d = ThreadData(thread); + LLVMDrawers::Instance()->tmvline4_addclamp(&args, &d); + } +}; + +class DrawWallSubClamp4LLVMCommand : public DrawWall4LLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + WorkerThreadData d = ThreadData(thread); + LLVMDrawers::Instance()->tmvline4_subclamp(&args, &d); + } +}; + +class DrawWallRevSubClamp4LLVMCommand : public DrawWall4LLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + WorkerThreadData d = ThreadData(thread); + LLVMDrawers::Instance()->tmvline4_revsubclamp(&args, &d); + } +}; + +class DrawWall1LLVMCommand : public DrawerCommand +{ +protected: + DrawWallArgs args; + + WorkerThreadData ThreadData(DrawerThread *thread) + { + WorkerThreadData d; + d.core = thread->core; + d.num_cores = thread->num_cores; + d.pass_start_y = thread->pass_start_y; + d.pass_end_y = thread->pass_end_y; + return d; + } + +public: + DrawWall1LLVMCommand() + { + args.dest = (uint32_t*)dc_dest; + args.dest_y = _dest_y; + args.pitch = dc_pitch; + args.count = dc_count; + args.texturefrac[0] = dc_texturefrac; + args.texturefracx[0] = dc_texturefracx; + args.iscale[0] = dc_iscale; + args.textureheight[0] = dc_textureheight; + args.source[0] = (const uint32 *)dc_source; + args.source2[0] = (const uint32 *)dc_source2; + args.light[0] = LightBgra::calc_light_multiplier(dc_light); + args.light_red = dc_shade_constants.light_red; + args.light_green = dc_shade_constants.light_green; + args.light_blue = dc_shade_constants.light_blue; + args.light_alpha = dc_shade_constants.light_alpha; + args.fade_red = dc_shade_constants.fade_red; + args.fade_green = dc_shade_constants.fade_green; + args.fade_blue = dc_shade_constants.fade_blue; + args.fade_alpha = dc_shade_constants.fade_alpha; + args.desaturate = dc_shade_constants.desaturate; + args.srcalpha = dc_srcalpha >> (FRACBITS - 8); + args.destalpha = dc_destalpha >> (FRACBITS - 8); + args.flags = 0; + if (dc_shade_constants.simple_shade) + args.flags |= DrawWallArgs::simple_shade; + if (args.source2[0] == nullptr) + args.flags |= DrawWallArgs::nearest_filter; + } + + void Execute(DrawerThread *thread) override + { + WorkerThreadData d = ThreadData(thread); + LLVMDrawers::Instance()->vlinec1(&args, &d); + } +}; + +class DrawWallMasked1LLVMCommand : public DrawWall1LLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + WorkerThreadData d = ThreadData(thread); + LLVMDrawers::Instance()->mvlinec1(&args, &d); + } +}; + +class DrawWallAdd1LLVMCommand : public DrawWall1LLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + WorkerThreadData d = ThreadData(thread); + LLVMDrawers::Instance()->tmvline1_add(&args, &d); + } +}; + +class DrawWallAddClamp1LLVMCommand : public DrawWall1LLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + WorkerThreadData d = ThreadData(thread); + LLVMDrawers::Instance()->tmvline1_addclamp(&args, &d); + } +}; + +class DrawWallSubClamp1LLVMCommand : public DrawWall1LLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + WorkerThreadData d = ThreadData(thread); + LLVMDrawers::Instance()->tmvline1_subclamp(&args, &d); + } +}; + +class DrawWallRevSubClamp1LLVMCommand : public DrawWall1LLVMCommand +{ +public: + void Execute(DrawerThread *thread) override + { + WorkerThreadData d = ThreadData(thread); + LLVMDrawers::Instance()->tmvline1_revsubclamp(&args, &d); + } +}; + +///////////////////////////////////////////////////////////////////////////// + class DrawerColumnCommand : public DrawerCommand { public: @@ -2901,7 +3114,11 @@ void R_DrawSlab_rgba(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BY DWORD vlinec1_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else DrawerCommandQueue::QueueCommand(); +#endif return dc_texturefrac + dc_count * dc_iscale; } @@ -2920,72 +3137,116 @@ void queue_wallcommand() void vlinec4_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else queue_wallcommand(); +#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } DWORD mvlinec1_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else DrawerCommandQueue::QueueCommand(); +#endif return dc_texturefrac + dc_count * dc_iscale; } void mvlinec4_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else queue_wallcommand(); +#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } fixed_t tmvline1_add_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else DrawerCommandQueue::QueueCommand(); +#endif return dc_texturefrac + dc_count * dc_iscale; } void tmvline4_add_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else queue_wallcommand(); +#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } fixed_t tmvline1_addclamp_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else DrawerCommandQueue::QueueCommand(); +#endif return dc_texturefrac + dc_count * dc_iscale; } void tmvline4_addclamp_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else queue_wallcommand(); +#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } fixed_t tmvline1_subclamp_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else DrawerCommandQueue::QueueCommand(); +#endif return dc_texturefrac + dc_count * dc_iscale; } void tmvline4_subclamp_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else queue_wallcommand(); +#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } fixed_t tmvline1_revsubclamp_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else DrawerCommandQueue::QueueCommand(); +#endif return dc_texturefrac + dc_count * dc_iscale; } void tmvline4_revsubclamp_rgba() { +#if !defined(NO_LLVM) + DrawerCommandQueue::QueueCommand(); +#else queue_wallcommand(); +#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } From 8765cf2016e4a747a7031b0df5c2522d7e4c9bb5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 1 Oct 2016 06:51:55 +0200 Subject: [PATCH 1011/1509] Change Windows build to use a precompiled version of LLVM --- .gitignore | 1 + src/CMakeLists.txt | 98 +++++++++++++++++----------------- src/r_compiler/llvmdrawers.cpp | 5 +- 3 files changed, 51 insertions(+), 53 deletions(-) diff --git a/.gitignore b/.gitignore index 1b078ed63..7cc9d9860 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ /build_vc2015-32 /build_vc2015-64 /build +/llvm diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 41829b996..37dd9b5a8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -255,56 +255,44 @@ if( NOT NO_OPENAL ) endif() endif() -# C:/Development/Environment/Src/llvm-3.9.0/build/lib/cmake/llvm -find_package(LLVM REQUIRED CONFIG) -message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") -message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") -llvm_map_components_to_libnames(llvm_libs - analysis - asmparser - asmprinter - bitreader - bitwriter - codegen - core - executionengine - globalisel - instcombine - ipo - irreader - linker - lto - mc - mcdisassembler - mcjit - mcparser - mirparser - object - objectyaml - orcjit - passes - scalaropts - selectiondag - support - symbolize - tablegen - target - transformutils - vectorize - x86asmparser - x86asmprinter - x86codegen - x86desc - x86info - x86utils - aarch64asmparser - aarch64asmprinter - aarch64codegen - aarch64desc - aarch64info - aarch64utils) -include_directories(${LLVM_INCLUDE_DIRS}) -set( ZDOOM_LIBS ${ZDOOM_LIBS} ${llvm_libs} ) +set( LLVM_COMPONENTS core support asmparser asmprinter bitreader codegen passes ipo + irreader transformutils instrumentation profiledata debuginfocodeview runtimedyld + object instcombine linker analysis selectiondag scalaropts vectorize executionengine + mc mcdisassembler mcparser mcjit target ) +set( LLVM_COMPONENTS_X86 x86asmprinter x86info x86desc x86utils x86codegen ) +set( LLVM_COMPONENTS_X64 aarch64asmprinter aarch64info aarch64desc aarch64utils aarch64codegen ) + +# Path where it looks for the LLVM compiled files on Windows +set( LLVM_PRECOMPILED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" ) + +if( NOT WIN32 ) + # Example LLVM_DIR folder: C:/Development/Environment/Src/llvm-3.9.0/build/lib/cmake/llvm + find_package(LLVM REQUIRED CONFIG) + message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") + message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") + llvm_map_components_to_libnames( llvm_libs ${LLVM_COMPONENTS} ${LLVM_COMPONENTS_X86} ${LLVM_COMPONENTS_X64} ) + include_directories( ${LLVM_INCLUDE_DIRS} ) + set( ZDOOM_LIBS ${ZDOOM_LIBS} ${llvm_libs} ) +else() + include_directories( "${LLVM_PRECOMPILED_DIR}/include" ) + if( X64 ) + include_directories( "${LLVM_PRECOMPILED_DIR}/64bit/include" ) + set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/llvm/64bit" ) + set( LLVM_ALL_COMPONENTS ${LLVM_COMPONENTS} ${LLVM_COMPONENTS_X64} ) + else() + include_directories( "${LLVM_PRECOMPILED_DIR}/32bit/include" ) + set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/32bit" ) + set( LLVM_ALL_COMPONENTS ${LLVM_COMPONENTS} ${LLVM_COMPONENTS_X86} ) + endif() + foreach(buildtype IN ITEMS RELEASE DEBUG) + set( llvm_libs_${buildtype} "${llvm_libs_base}/${buildtype}" ) + set( LLVM_${buildtype}_LIBS "" ) + foreach( llvm_module ${LLVM_ALL_COMPONENTS} ) + find_library( LLVM_${llvm_module}_LIBRARY_${buildtype} LLVM${llvm_module} PATHS ${llvm_libs_${buildtype}} ) + set( LLVM_${buildtype}_LIBS ${LLVM_${buildtype}_LIBS} ${LLVM_${llvm_module}_LIBRARY_${buildtype}} ) + endforeach( llvm_module ) + endforeach(buildtype) +endif() if( NOT NO_FMOD ) # Search for FMOD include files @@ -1513,6 +1501,16 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS") endif() target_link_libraries( zdoom ${ZDOOM_LIBS} gdtoa dumb lzma ) + +if( WIN32 ) + foreach(debuglib ${LLVM_DEBUG_LIBS}) + target_link_libraries( zdoom debug ${debuglib} ) + endforeach(debuglib) + foreach(releaselib ${LLVM_RELEASE_LIBS}) + target_link_libraries( zdoom optimized ${releaselib} ) + endforeach(releaselib) +endif() + include_directories( . g_doom g_heretic diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 60727744c..4f59419ad 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -246,7 +246,6 @@ LLVMProgram::LLVMProgram() InitializeNativeTarget(); InitializeNativeTargetAsmPrinter(); - InitializeNativeTargetAsmParser(); std::string errorstring; @@ -263,8 +262,8 @@ LLVMProgram::LLVMProgram() cpuFeaturesStr += it.getKey(); } - //Printf("LLVM target triple: %s\n", targetTriple.c_str()); - //Printf("LLVM CPU and features: %s, %s\n", cpuName.c_str(), cpuFeaturesStr.c_str()); + DPrintf(DMSG_SPAMMY, "LLVM target triple: %s\n", targetTriple.c_str()); + DPrintf(DMSG_SPAMMY, "LLVM CPU and features: %s, %s\n", cpuName.c_str(), cpuFeaturesStr.c_str()); const Target *target = TargetRegistry::lookupTarget(targetTriple, errorstring); if (!target) From c960742dbd197b9a73ba2ab0b1175e8e5d10655f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 1 Oct 2016 11:47:21 +0200 Subject: [PATCH 1012/1509] Fix 64 bit compile errors --- src/CMakeLists.txt | 24 +++++++++---------- .../fixedfunction/drawcolumncodegen.cpp | 1 + .../fixedfunction/drawercodegen.cpp | 7 +++--- .../fixedfunction/drawspancodegen.cpp | 11 +++++---- .../fixedfunction/drawwallcodegen.cpp | 7 +++--- src/r_compiler/llvm_include.h | 10 ++++++++ src/r_compiler/llvmdrawers.cpp | 1 + src/r_compiler/ssa/ssa_bool.cpp | 2 +- src/r_compiler/ssa/ssa_float.cpp | 2 +- src/r_compiler/ssa/ssa_float.h | 2 +- src/r_compiler/ssa/ssa_float_ptr.cpp | 2 +- src/r_compiler/ssa/ssa_float_ptr.h | 1 + src/r_compiler/ssa/ssa_for_block.cpp | 1 + src/r_compiler/ssa/ssa_for_block.h | 1 - src/r_compiler/ssa/ssa_function.cpp | 2 +- src/r_compiler/ssa/ssa_if_block.cpp | 1 + src/r_compiler/ssa/ssa_if_block.h | 1 - src/r_compiler/ssa/ssa_int.cpp | 2 +- src/r_compiler/ssa/ssa_int.h | 2 +- src/r_compiler/ssa/ssa_int_ptr.cpp | 2 +- src/r_compiler/ssa/ssa_int_ptr.h | 1 + src/r_compiler/ssa/ssa_scope.cpp | 1 + src/r_compiler/ssa/ssa_scope.h | 2 -- src/r_compiler/ssa/ssa_short.cpp | 2 +- src/r_compiler/ssa/ssa_short.h | 2 +- src/r_compiler/ssa/ssa_struct_type.cpp | 1 + src/r_compiler/ssa/ssa_ubyte.cpp | 2 +- src/r_compiler/ssa/ssa_ubyte.h | 2 +- src/r_compiler/ssa/ssa_ubyte_ptr.cpp | 4 ++-- src/r_compiler/ssa/ssa_ubyte_ptr.h | 1 + src/r_compiler/ssa/ssa_value.cpp | 2 +- src/r_compiler/ssa/ssa_vec16ub.cpp | 2 +- src/r_compiler/ssa/ssa_vec16ub.h | 4 ++-- src/r_compiler/ssa/ssa_vec4f.cpp | 7 +++++- src/r_compiler/ssa/ssa_vec4f.h | 5 ++-- src/r_compiler/ssa/ssa_vec4f_ptr.cpp | 2 +- src/r_compiler/ssa/ssa_vec4i.cpp | 18 ++++++++++---- src/r_compiler/ssa/ssa_vec4i.h | 8 ++++--- src/r_compiler/ssa/ssa_vec4i_ptr.cpp | 2 +- src/r_compiler/ssa/ssa_vec4i_ptr.h | 1 + src/r_compiler/ssa/ssa_vec8s.cpp | 6 ++--- src/r_compiler/ssa/ssa_vec8s.h | 4 ++-- 42 files changed, 99 insertions(+), 62 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 37dd9b5a8..ac6de85f6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -258,9 +258,7 @@ endif() set( LLVM_COMPONENTS core support asmparser asmprinter bitreader codegen passes ipo irreader transformutils instrumentation profiledata debuginfocodeview runtimedyld object instcombine linker analysis selectiondag scalaropts vectorize executionengine - mc mcdisassembler mcparser mcjit target ) -set( LLVM_COMPONENTS_X86 x86asmprinter x86info x86desc x86utils x86codegen ) -set( LLVM_COMPONENTS_X64 aarch64asmprinter aarch64info aarch64desc aarch64utils aarch64codegen ) + mc mcdisassembler mcparser mcjit target x86asmprinter x86info x86desc x86utils x86codegen ) # Path where it looks for the LLVM compiled files on Windows set( LLVM_PRECOMPILED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" ) @@ -270,24 +268,22 @@ if( NOT WIN32 ) find_package(LLVM REQUIRED CONFIG) message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") - llvm_map_components_to_libnames( llvm_libs ${LLVM_COMPONENTS} ${LLVM_COMPONENTS_X86} ${LLVM_COMPONENTS_X64} ) + llvm_map_components_to_libnames( llvm_libs ${LLVM_COMPONENTS} ) include_directories( ${LLVM_INCLUDE_DIRS} ) set( ZDOOM_LIBS ${ZDOOM_LIBS} ${llvm_libs} ) else() include_directories( "${LLVM_PRECOMPILED_DIR}/include" ) if( X64 ) - include_directories( "${LLVM_PRECOMPILED_DIR}/64bit/include" ) - set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/llvm/64bit" ) - set( LLVM_ALL_COMPONENTS ${LLVM_COMPONENTS} ${LLVM_COMPONENTS_X64} ) + include_directories( "${LLVM_PRECOMPILED_DIR}/64bit-include" ) + set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/64bit-" ) else() - include_directories( "${LLVM_PRECOMPILED_DIR}/32bit/include" ) - set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/32bit" ) - set( LLVM_ALL_COMPONENTS ${LLVM_COMPONENTS} ${LLVM_COMPONENTS_X86} ) + include_directories( "${LLVM_PRECOMPILED_DIR}/32bit-include" ) + set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/32bit-" ) endif() foreach(buildtype IN ITEMS RELEASE DEBUG) - set( llvm_libs_${buildtype} "${llvm_libs_base}/${buildtype}" ) + set( llvm_libs_${buildtype} "${llvm_libs_base}${buildtype}" ) set( LLVM_${buildtype}_LIBS "" ) - foreach( llvm_module ${LLVM_ALL_COMPONENTS} ) + foreach( llvm_module ${LLVM_COMPONENTS} ) find_library( LLVM_${llvm_module}_LIBRARY_${buildtype} LLVM${llvm_module} PATHS ${llvm_libs_${buildtype}} ) set( LLVM_${buildtype}_LIBS ${LLVM_${buildtype}_LIBS} ${LLVM_${llvm_module}_LIBRARY_${buildtype}} ) endforeach( llvm_module ) @@ -1492,6 +1488,10 @@ set_source_files_properties( sc_man.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRE set_source_files_properties( ${NOT_COMPILED_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE ) if ( WIN32 ) set_source_files_properties( win32/fb_d3d9.cpp win32/fb_d3d9_wipe.cpp PROPERTIES COMPILE_FLAGS ${ZD_FASTMATH_FLAG} ) + + # Supress C4244: 'initializing': conversion from '__int64' to 'unsigned int', possible loss of data + # For some reason using #pragma warning(disable: 4244) is not working.. + set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS /wd4244 ) endif() diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp index 4594e2290..67d801162 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp @@ -1,5 +1,6 @@ #include "i_system.h" +#include "r_compiler/llvm_include.h" #include "r_compiler/fixedfunction/drawcolumncodegen.h" #include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_scope.h" diff --git a/src/r_compiler/fixedfunction/drawercodegen.cpp b/src/r_compiler/fixedfunction/drawercodegen.cpp index 2cba50121..822a81141 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.cpp +++ b/src/r_compiler/fixedfunction/drawercodegen.cpp @@ -1,5 +1,6 @@ #include "i_system.h" +#include "r_compiler/llvm_include.h" #include "r_compiler/fixedfunction/drawercodegen.h" #include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_scope.h" @@ -17,17 +18,17 @@ SSABool DrawerCodegen::line_skipped_by_thread(SSAInt line, SSAWorkerThread threa SSAInt DrawerCodegen::skipped_by_thread(SSAInt first_line, SSAWorkerThread thread) { - SSAInt pass_skip = SSAInt::MAX(thread.pass_start_y - first_line, 0); + SSAInt pass_skip = SSAInt::MAX(thread.pass_start_y - first_line, SSAInt(0)); SSAInt core_skip = (thread.num_cores - (first_line + pass_skip - thread.core) % thread.num_cores) % thread.num_cores; return pass_skip + core_skip; } SSAInt DrawerCodegen::count_for_thread(SSAInt first_line, SSAInt count, SSAWorkerThread thread) { - SSAInt lines_until_pass_end = SSAInt::MAX(thread.pass_end_y - first_line, 0); + SSAInt lines_until_pass_end = SSAInt::MAX(thread.pass_end_y - first_line, SSAInt(0)); count = SSAInt::MIN(count, lines_until_pass_end); SSAInt c = (count - skipped_by_thread(first_line, thread) + thread.num_cores - 1) / thread.num_cores; - return SSAInt::MAX(c, 0); + return SSAInt::MAX(c, SSAInt(0)); } SSAUBytePtr DrawerCodegen::dest_for_thread(SSAInt first_line, SSAInt pitch, SSAUBytePtr dest, SSAWorkerThread thread) diff --git a/src/r_compiler/fixedfunction/drawspancodegen.cpp b/src/r_compiler/fixedfunction/drawspancodegen.cpp index 1623c38f2..70ecb0abd 100644 --- a/src/r_compiler/fixedfunction/drawspancodegen.cpp +++ b/src/r_compiler/fixedfunction/drawspancodegen.cpp @@ -1,5 +1,6 @@ #include "i_system.h" +#include "r_compiler/llvm_include.h" #include "r_compiler/fixedfunction/drawspancodegen.h" #include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_scope.h" @@ -49,9 +50,9 @@ void DrawSpanCodegen::Generate(DrawSpanVariant variant, SSAValue args) xmask = ((SSAInt(1) << xbits) - 1) << ybits; // 64x64 is the most common case by far, so special case it. - is_64x64 = xbits == 6 && ybits == 6; - is_simple_shade = (flags & DrawSpanArgs::simple_shade) == DrawSpanArgs::simple_shade; - is_nearest_filter = (flags & DrawSpanArgs::nearest_filter) == DrawSpanArgs::nearest_filter; + is_64x64 = xbits == SSAInt(6) && ybits == SSAInt(6); + is_simple_shade = (flags & DrawSpanArgs::simple_shade) == SSAInt(DrawSpanArgs::simple_shade); + is_nearest_filter = (flags & DrawSpanArgs::nearest_filter) == SSAInt(DrawSpanArgs::nearest_filter); SSAIfBlock branch; branch.if_block(is_simple_shade); @@ -90,7 +91,7 @@ void DrawSpanCodegen::LoopFilter(DrawSpanVariant variant, bool isSimpleShade, bo SSAInt DrawSpanCodegen::Loop4x(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64) { SSAInt sseLength = count / 4; - stack_index.store(0); + stack_index.store(SSAInt(0)); { SSAForBlock loop; SSAInt index = stack_index.load(); @@ -165,7 +166,7 @@ SSAVec4i DrawSpanCodegen::Sample(SSAInt xfrac, SSAInt yfrac, bool isNearestFilte { if (is64x64) { - return sample_linear(source, xfrac, yfrac, 26, 26); + return sample_linear(source, xfrac, yfrac, SSAInt(26), SSAInt(26)); } else { diff --git a/src/r_compiler/fixedfunction/drawwallcodegen.cpp b/src/r_compiler/fixedfunction/drawwallcodegen.cpp index 0ca537723..55b17dafe 100644 --- a/src/r_compiler/fixedfunction/drawwallcodegen.cpp +++ b/src/r_compiler/fixedfunction/drawwallcodegen.cpp @@ -1,5 +1,6 @@ #include "i_system.h" +#include "r_compiler/llvm_include.h" #include "r_compiler/fixedfunction/drawwallcodegen.h" #include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_scope.h" @@ -65,8 +66,8 @@ void DrawWallCodegen::Generate(DrawWallVariant variant, bool fourColumns, SSAVal thread.pass_start_y = thread_data[0][2].load(); thread.pass_end_y = thread_data[0][3].load(); - is_simple_shade = (flags & DrawWallArgs::simple_shade) == DrawWallArgs::simple_shade; - is_nearest_filter = (flags & DrawWallArgs::nearest_filter) == DrawWallArgs::nearest_filter; + is_simple_shade = (flags & DrawWallArgs::simple_shade) == SSAInt(DrawWallArgs::simple_shade); + is_nearest_filter = (flags & DrawWallArgs::nearest_filter) == SSAInt(DrawWallArgs::nearest_filter); count = count_for_thread(dest_y, count, thread); dest = dest_for_thread(dest_y, pitch, dest, thread); @@ -103,7 +104,7 @@ void DrawWallCodegen::Loop(DrawWallVariant variant, bool fourColumns, bool isSim { int numColumns = fourColumns ? 4 : 1; - stack_index.store(0); + stack_index.store(SSAInt(0)); { SSAForBlock loop; SSAInt index = stack_index.load(); diff --git a/src/r_compiler/llvm_include.h b/src/r_compiler/llvm_include.h index b916bad0e..d1550f38a 100644 --- a/src/r_compiler/llvm_include.h +++ b/src/r_compiler/llvm_include.h @@ -1,6 +1,8 @@ #pragma once +#ifdef _MSC_VER + #if defined(min) #define llvm_min_bug min #undef min @@ -18,6 +20,10 @@ #pragma warning(disable: 4244) // warning C4244: 'return' : conversion from 'uint64_t' to 'unsigned int', possible loss of data #pragma warning(disable: 4141) // warning C4141: 'inline': used more than once #pragma warning(disable: 4291) // warning C4291: 'void *llvm::User::operator new(std::size_t,unsigned int,unsigned int)': no matching operator delete found; memory will not be freed if initialization throws an exception +#pragma warning(disable: 4267) // warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data +#pragma warning(disable: 4244) // warning C4244: 'initializing': conversion from '__int64' to 'unsigned int', possible loss of data + +#endif #include #include @@ -39,6 +45,8 @@ #include #include +#ifdef _MSC_VER + #if defined(llvm_min_bug) #define min llvm_min_bug #undef llvm_min_bug @@ -47,3 +55,5 @@ #define max llvm_max_bug #undef llvm_max_bug #endif + +#endif diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 4f59419ad..7691af35b 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -1,5 +1,6 @@ #include "i_system.h" +#include "r_compiler/llvm_include.h" #include "r_compiler/fixedfunction/drawspancodegen.h" #include "r_compiler/fixedfunction/drawwallcodegen.h" #include "r_compiler/fixedfunction/drawcolumncodegen.h" diff --git a/src/r_compiler/ssa/ssa_bool.cpp b/src/r_compiler/ssa/ssa_bool.cpp index 101323911..bfd9ba5ab 100644 --- a/src/r_compiler/ssa/ssa_bool.cpp +++ b/src/r_compiler/ssa/ssa_bool.cpp @@ -1,7 +1,7 @@ +#include "r_compiler/llvm_include.h" #include "ssa_bool.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSABool::SSABool() : v(0) diff --git a/src/r_compiler/ssa/ssa_float.cpp b/src/r_compiler/ssa/ssa_float.cpp index 87488af74..4ec5c516d 100644 --- a/src/r_compiler/ssa/ssa_float.cpp +++ b/src/r_compiler/ssa/ssa_float.cpp @@ -1,8 +1,8 @@ +#include "r_compiler/llvm_include.h" #include "ssa_float.h" #include "ssa_int.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAFloat::SSAFloat() : v(0) diff --git a/src/r_compiler/ssa/ssa_float.h b/src/r_compiler/ssa/ssa_float.h index 2349ab877..0edbcfcba 100644 --- a/src/r_compiler/ssa/ssa_float.h +++ b/src/r_compiler/ssa/ssa_float.h @@ -11,7 +11,7 @@ class SSAFloat public: SSAFloat(); SSAFloat(SSAInt i); - SSAFloat(float constant); + explicit SSAFloat(float constant); explicit SSAFloat(llvm::Value *v); static SSAFloat from_llvm(llvm::Value *v) { return SSAFloat(v); } static llvm::Type *llvm_type(); diff --git a/src/r_compiler/ssa/ssa_float_ptr.cpp b/src/r_compiler/ssa/ssa_float_ptr.cpp index 6a1409271..582821ca0 100644 --- a/src/r_compiler/ssa/ssa_float_ptr.cpp +++ b/src/r_compiler/ssa/ssa_float_ptr.cpp @@ -1,7 +1,7 @@ +#include "r_compiler/llvm_include.h" #include "ssa_float_ptr.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAFloatPtr::SSAFloatPtr() : v(0) diff --git a/src/r_compiler/ssa/ssa_float_ptr.h b/src/r_compiler/ssa/ssa_float_ptr.h index a4318e027..f29b2de3f 100644 --- a/src/r_compiler/ssa/ssa_float_ptr.h +++ b/src/r_compiler/ssa/ssa_float_ptr.h @@ -16,6 +16,7 @@ public: static SSAFloatPtr from_llvm(llvm::Value *v) { return SSAFloatPtr(v); } static llvm::Type *llvm_type(); SSAFloatPtr operator[](SSAInt index) const; + SSAFloatPtr operator[](int index) const { return (*this)[SSAInt(index)]; } SSAFloat load() const; SSAVec4f load_vec4f() const; SSAVec4f load_unaligned_vec4f() const; diff --git a/src/r_compiler/ssa/ssa_for_block.cpp b/src/r_compiler/ssa/ssa_for_block.cpp index ce9328607..f7cd6ad0b 100644 --- a/src/r_compiler/ssa/ssa_for_block.cpp +++ b/src/r_compiler/ssa/ssa_for_block.cpp @@ -1,4 +1,5 @@ +#include "r_compiler/llvm_include.h" #include "ssa_for_block.h" #include "ssa_scope.h" diff --git a/src/r_compiler/ssa/ssa_for_block.h b/src/r_compiler/ssa/ssa_for_block.h index 58803dee5..4c1952c14 100644 --- a/src/r_compiler/ssa/ssa_for_block.h +++ b/src/r_compiler/ssa/ssa_for_block.h @@ -2,7 +2,6 @@ #pragma once #include "ssa_bool.h" -#include "r_compiler/llvm_include.h" class SSAForBlock { diff --git a/src/r_compiler/ssa/ssa_function.cpp b/src/r_compiler/ssa/ssa_function.cpp index aee4de5a9..a326beaf7 100644 --- a/src/r_compiler/ssa/ssa_function.cpp +++ b/src/r_compiler/ssa/ssa_function.cpp @@ -1,9 +1,9 @@ +#include "r_compiler/llvm_include.h" #include "ssa_function.h" #include "ssa_int.h" #include "ssa_scope.h" #include "ssa_value.h" -#include "r_compiler/llvm_include.h" SSAFunction::SSAFunction(const std::string name) : name(name), return_type(llvm::Type::getVoidTy(SSAScope::context())), func() diff --git a/src/r_compiler/ssa/ssa_if_block.cpp b/src/r_compiler/ssa/ssa_if_block.cpp index e2de9ecad..7187a0759 100644 --- a/src/r_compiler/ssa/ssa_if_block.cpp +++ b/src/r_compiler/ssa/ssa_if_block.cpp @@ -1,4 +1,5 @@ +#include "r_compiler/llvm_include.h" #include "ssa_if_block.h" #include "ssa_scope.h" diff --git a/src/r_compiler/ssa/ssa_if_block.h b/src/r_compiler/ssa/ssa_if_block.h index 98c534a86..4f0c8a26b 100644 --- a/src/r_compiler/ssa/ssa_if_block.h +++ b/src/r_compiler/ssa/ssa_if_block.h @@ -3,7 +3,6 @@ #include "ssa_bool.h" #include "ssa_phi.h" -#include "r_compiler/llvm_include.h" class SSAIfBlock { diff --git a/src/r_compiler/ssa/ssa_int.cpp b/src/r_compiler/ssa/ssa_int.cpp index 8d5a32e4c..3d9cb22bd 100644 --- a/src/r_compiler/ssa/ssa_int.cpp +++ b/src/r_compiler/ssa/ssa_int.cpp @@ -1,9 +1,9 @@ +#include "r_compiler/llvm_include.h" #include "ssa_int.h" #include "ssa_float.h" #include "ssa_bool.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAInt::SSAInt() : v(0) diff --git a/src/r_compiler/ssa/ssa_int.h b/src/r_compiler/ssa/ssa_int.h index d928c41f2..c0f46e4b6 100644 --- a/src/r_compiler/ssa/ssa_int.h +++ b/src/r_compiler/ssa/ssa_int.h @@ -10,7 +10,7 @@ class SSAInt { public: SSAInt(); - SSAInt(int constant); + explicit SSAInt(int constant); SSAInt(SSAFloat f); explicit SSAInt(llvm::Value *v); static SSAInt from_llvm(llvm::Value *v) { return SSAInt(v); } diff --git a/src/r_compiler/ssa/ssa_int_ptr.cpp b/src/r_compiler/ssa/ssa_int_ptr.cpp index 3c2637073..974645d08 100644 --- a/src/r_compiler/ssa/ssa_int_ptr.cpp +++ b/src/r_compiler/ssa/ssa_int_ptr.cpp @@ -1,7 +1,7 @@ +#include "r_compiler/llvm_include.h" #include "ssa_int_ptr.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAIntPtr::SSAIntPtr() : v(0) diff --git a/src/r_compiler/ssa/ssa_int_ptr.h b/src/r_compiler/ssa/ssa_int_ptr.h index 20e024a31..c75ed6a8d 100644 --- a/src/r_compiler/ssa/ssa_int_ptr.h +++ b/src/r_compiler/ssa/ssa_int_ptr.h @@ -16,6 +16,7 @@ public: static SSAIntPtr from_llvm(llvm::Value *v) { return SSAIntPtr(v); } static llvm::Type *llvm_type(); SSAIntPtr operator[](SSAInt index) const; + SSAIntPtr operator[](int index) const { return (*this)[SSAInt(index)]; } SSAInt load() const; SSAVec4i load_vec4i() const; SSAVec4i load_unaligned_vec4i() const; diff --git a/src/r_compiler/ssa/ssa_scope.cpp b/src/r_compiler/ssa/ssa_scope.cpp index f9d16f188..e5d34a203 100644 --- a/src/r_compiler/ssa/ssa_scope.cpp +++ b/src/r_compiler/ssa/ssa_scope.cpp @@ -1,4 +1,5 @@ +#include "r_compiler/llvm_include.h" #include "ssa_scope.h" #include "ssa_int.h" diff --git a/src/r_compiler/ssa/ssa_scope.h b/src/r_compiler/ssa/ssa_scope.h index d184643ad..ad080fde6 100644 --- a/src/r_compiler/ssa/ssa_scope.h +++ b/src/r_compiler/ssa/ssa_scope.h @@ -1,8 +1,6 @@ #pragma once -#include "r_compiler/llvm_include.h" - class SSAInt; class SSAScope diff --git a/src/r_compiler/ssa/ssa_short.cpp b/src/r_compiler/ssa/ssa_short.cpp index 3fa59b688..017f3002a 100644 --- a/src/r_compiler/ssa/ssa_short.cpp +++ b/src/r_compiler/ssa/ssa_short.cpp @@ -1,9 +1,9 @@ +#include "r_compiler/llvm_include.h" #include "ssa_short.h" #include "ssa_float.h" #include "ssa_int.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAShort::SSAShort() : v(0) diff --git a/src/r_compiler/ssa/ssa_short.h b/src/r_compiler/ssa/ssa_short.h index 932aafc0e..4a5343402 100644 --- a/src/r_compiler/ssa/ssa_short.h +++ b/src/r_compiler/ssa/ssa_short.h @@ -11,7 +11,7 @@ class SSAShort { public: SSAShort(); - SSAShort(int constant); + explicit SSAShort(int constant); SSAShort(SSAFloat f); explicit SSAShort(llvm::Value *v); static SSAShort from_llvm(llvm::Value *v) { return SSAShort(v); } diff --git a/src/r_compiler/ssa/ssa_struct_type.cpp b/src/r_compiler/ssa/ssa_struct_type.cpp index 4a79768ce..d4ae2acb1 100644 --- a/src/r_compiler/ssa/ssa_struct_type.cpp +++ b/src/r_compiler/ssa/ssa_struct_type.cpp @@ -1,4 +1,5 @@ +#include "r_compiler/llvm_include.h" #include "ssa_struct_type.h" #include "ssa_scope.h" diff --git a/src/r_compiler/ssa/ssa_ubyte.cpp b/src/r_compiler/ssa/ssa_ubyte.cpp index 04db4fd28..3204d064d 100644 --- a/src/r_compiler/ssa/ssa_ubyte.cpp +++ b/src/r_compiler/ssa/ssa_ubyte.cpp @@ -1,7 +1,7 @@ +#include "r_compiler/llvm_include.h" #include "ssa_ubyte.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAUByte::SSAUByte() : v(0) diff --git a/src/r_compiler/ssa/ssa_ubyte.h b/src/r_compiler/ssa/ssa_ubyte.h index f1e12afba..ef878b325 100644 --- a/src/r_compiler/ssa/ssa_ubyte.h +++ b/src/r_compiler/ssa/ssa_ubyte.h @@ -8,7 +8,7 @@ class SSAUByte { public: SSAUByte(); - SSAUByte(unsigned char constant); + explicit SSAUByte(unsigned char constant); explicit SSAUByte(llvm::Value *v); static SSAUByte from_llvm(llvm::Value *v) { return SSAUByte(v); } static llvm::Type *llvm_type(); diff --git a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp index b2408066e..98bf27c46 100644 --- a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp +++ b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp @@ -1,7 +1,7 @@ +#include "r_compiler/llvm_include.h" #include "ssa_ubyte_ptr.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAUBytePtr::SSAUBytePtr() : v(0) @@ -38,7 +38,7 @@ SSAVec4i SSAUBytePtr::load_vec4ub() const v = SSAScope::builder().CreateInsertElement(v, SSAInt(0).v, SSAInt(3).v, SSAScope::hint()); SSAVec4i v4i = SSAVec4i::from_llvm(v); - SSAVec8s low = SSAVec8s::bitcast(SSAVec16ub::shuffle(SSAVec16ub::bitcast(v4i), 0, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7)); // _mm_unpacklo_epi8 + SSAVec8s low = SSAVec8s::bitcast(SSAVec16ub::shuffle(SSAVec16ub::bitcast(v4i), SSAVec16ub((unsigned char)0), 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7)); // _mm_unpacklo_epi8 return SSAVec4i::extendlo(low); // _mm_unpacklo_epi16 /* llvm::PointerType *m4xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 4)->getPointerTo(); diff --git a/src/r_compiler/ssa/ssa_ubyte_ptr.h b/src/r_compiler/ssa/ssa_ubyte_ptr.h index 5b68ee1ad..c084068bc 100644 --- a/src/r_compiler/ssa/ssa_ubyte_ptr.h +++ b/src/r_compiler/ssa/ssa_ubyte_ptr.h @@ -18,6 +18,7 @@ public: static SSAUBytePtr from_llvm(llvm::Value *v) { return SSAUBytePtr(v); } static llvm::Type *llvm_type(); SSAUBytePtr operator[](SSAInt index) const; + SSAUBytePtr operator[](int index) const { return (*this)[SSAInt(index)]; } SSAUByte load() const; SSAVec4i load_vec4ub() const; SSAVec8s load_vec8s() const; diff --git a/src/r_compiler/ssa/ssa_value.cpp b/src/r_compiler/ssa/ssa_value.cpp index 877420fc5..c37b7f4c1 100644 --- a/src/r_compiler/ssa/ssa_value.cpp +++ b/src/r_compiler/ssa/ssa_value.cpp @@ -1,8 +1,8 @@ +#include "r_compiler/llvm_include.h" #include "ssa_value.h" #include "ssa_int.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAValue SSAValue::load() { diff --git a/src/r_compiler/ssa/ssa_vec16ub.cpp b/src/r_compiler/ssa/ssa_vec16ub.cpp index f18d68718..4a077382e 100644 --- a/src/r_compiler/ssa/ssa_vec16ub.cpp +++ b/src/r_compiler/ssa/ssa_vec16ub.cpp @@ -1,9 +1,9 @@ +#include "r_compiler/llvm_include.h" #include "ssa_vec16ub.h" #include "ssa_vec8s.h" #include "ssa_vec4i.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAVec16ub::SSAVec16ub() : v(0) diff --git a/src/r_compiler/ssa/ssa_vec16ub.h b/src/r_compiler/ssa/ssa_vec16ub.h index e4cfcdc87..8f48c0c49 100644 --- a/src/r_compiler/ssa/ssa_vec16ub.h +++ b/src/r_compiler/ssa/ssa_vec16ub.h @@ -11,8 +11,8 @@ class SSAVec16ub { public: SSAVec16ub(); - SSAVec16ub(unsigned char constant); - SSAVec16ub( + explicit SSAVec16ub(unsigned char constant); + explicit SSAVec16ub( unsigned char constant0, unsigned char constant1, unsigned char constant2, unsigned char constant3, unsigned char constant4, unsigned char constant5, unsigned char constant6, unsigned char constant7, unsigned char constant8, unsigned char constant9, unsigned char constant10, unsigned char constant11, unsigned char constant12, unsigned char constant13, unsigned char constant14, unsigned char constant15); explicit SSAVec16ub(llvm::Value *v); diff --git a/src/r_compiler/ssa/ssa_vec4f.cpp b/src/r_compiler/ssa/ssa_vec4f.cpp index e002018fe..dc6f9a716 100644 --- a/src/r_compiler/ssa/ssa_vec4f.cpp +++ b/src/r_compiler/ssa/ssa_vec4f.cpp @@ -1,10 +1,10 @@ +#include "r_compiler/llvm_include.h" #include "ssa_vec4f.h" #include "ssa_vec4i.h" #include "ssa_float.h" #include "ssa_int.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAVec4f::SSAVec4f() : v(0) @@ -75,6 +75,11 @@ SSAFloat SSAVec4f::operator[](SSAInt index) const return SSAFloat::from_llvm(SSAScope::builder().CreateExtractElement(v, index.v, SSAScope::hint())); } +SSAFloat SSAVec4f::operator[](int index) const +{ + return (*this)[SSAInt(index)]; +} + SSAVec4f SSAVec4f::insert_element(SSAVec4f vec4f, SSAFloat value, int index) { return from_llvm(SSAScope::builder().CreateInsertElement(vec4f.v, value.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)index)))); diff --git a/src/r_compiler/ssa/ssa_vec4f.h b/src/r_compiler/ssa/ssa_vec4f.h index 5e3397e58..6d4ae6335 100644 --- a/src/r_compiler/ssa/ssa_vec4f.h +++ b/src/r_compiler/ssa/ssa_vec4f.h @@ -12,13 +12,14 @@ class SSAVec4f { public: SSAVec4f(); - SSAVec4f(float constant); - SSAVec4f(float constant0, float constant1, float constant2, float constant3); + explicit SSAVec4f(float constant); + explicit SSAVec4f(float constant0, float constant1, float constant2, float constant3); SSAVec4f(SSAFloat f); SSAVec4f(SSAFloat f0, SSAFloat f1, SSAFloat f2, SSAFloat f3); explicit SSAVec4f(llvm::Value *v); SSAVec4f(SSAVec4i i32); SSAFloat operator[](SSAInt index) const; + SSAFloat operator[](int index) const; static SSAVec4f insert_element(SSAVec4f vec4f, SSAFloat value, int index); static SSAVec4f bitcast(SSAVec4i i32); static SSAVec4f sqrt(SSAVec4f f); diff --git a/src/r_compiler/ssa/ssa_vec4f_ptr.cpp b/src/r_compiler/ssa/ssa_vec4f_ptr.cpp index 6a197ec90..e0ed8bc86 100644 --- a/src/r_compiler/ssa/ssa_vec4f_ptr.cpp +++ b/src/r_compiler/ssa/ssa_vec4f_ptr.cpp @@ -1,7 +1,7 @@ +#include "r_compiler/llvm_include.h" #include "ssa_vec4f_ptr.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAVec4fPtr::SSAVec4fPtr() : v(0) diff --git a/src/r_compiler/ssa/ssa_vec4i.cpp b/src/r_compiler/ssa/ssa_vec4i.cpp index 1eed7b269..3b508412f 100644 --- a/src/r_compiler/ssa/ssa_vec4i.cpp +++ b/src/r_compiler/ssa/ssa_vec4i.cpp @@ -1,11 +1,11 @@ +#include "r_compiler/llvm_include.h" #include "ssa_vec4i.h" #include "ssa_vec4f.h" #include "ssa_vec8s.h" #include "ssa_vec16ub.h" #include "ssa_int.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAVec4i::SSAVec4i() : v(0) @@ -67,11 +67,16 @@ SSAVec4i::SSAVec4i(SSAVec4f f32) v = SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_cvttps2dq), f32.v, SSAScope::hint()); } -SSAInt SSAVec4i::operator[](SSAInt index) +SSAInt SSAVec4i::operator[](SSAInt index) const { return SSAInt::from_llvm(SSAScope::builder().CreateExtractElement(v, index.v, SSAScope::hint())); } +SSAInt SSAVec4i::operator[](int index) const +{ + return (*this)[SSAInt(index)]; +} + SSAVec4i SSAVec4i::insert(SSAInt index, SSAInt value) { return SSAVec4i::from_llvm(SSAScope::builder().CreateInsertElement(v, value.v, index.v, SSAScope::hint())); @@ -82,6 +87,11 @@ SSAVec4i SSAVec4i::insert(int index, SSAInt value) return SSAVec4i::from_llvm(SSAScope::builder().CreateInsertElement(v, value.v, index, SSAScope::hint())); } +SSAVec4i SSAVec4i::insert(int index, int value) +{ + return insert(index, SSAInt(value)); +} + llvm::Type *SSAVec4i::llvm_type() { return llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4); @@ -125,12 +135,12 @@ void SSAVec4i::extend(SSAVec16ub a, SSAVec4i &out0, SSAVec4i &out1, SSAVec4i &ou SSAVec4i SSAVec4i::extendhi(SSAVec8s i16) { - return SSAVec4i::bitcast(SSAVec8s::shuffle(i16, 0, 4, 8+4, 5, 8+5, 6, 8+6, 7, 8+7)); // _mm_unpackhi_epi16 + return SSAVec4i::bitcast(SSAVec8s::shuffle(i16, SSAVec8s((short)0), 4, 8+4, 5, 8+5, 6, 8+6, 7, 8+7)); // _mm_unpackhi_epi16 } SSAVec4i SSAVec4i::extendlo(SSAVec8s i16) { - return SSAVec4i::bitcast(SSAVec8s::shuffle(i16, 0, 0, 8+0, 1, 8+1, 2, 8+2, 3, 8+3)); // _mm_unpacklo_epi16 + return SSAVec4i::bitcast(SSAVec8s::shuffle(i16, SSAVec8s((short)0), 0, 8+0, 1, 8+1, 2, 8+2, 3, 8+3)); // _mm_unpacklo_epi16 } SSAVec4i SSAVec4i::combinehi(SSAVec8s a, SSAVec8s b) diff --git a/src/r_compiler/ssa/ssa_vec4i.h b/src/r_compiler/ssa/ssa_vec4i.h index c1c9140d7..89cda1646 100644 --- a/src/r_compiler/ssa/ssa_vec4i.h +++ b/src/r_compiler/ssa/ssa_vec4i.h @@ -13,15 +13,17 @@ class SSAVec4i { public: SSAVec4i(); - SSAVec4i(int constant); - SSAVec4i(int constant0, int constant1, int constant2, int constant3); + explicit SSAVec4i(int constant); + explicit SSAVec4i(int constant0, int constant1, int constant2, int constant3); SSAVec4i(SSAInt i); SSAVec4i(SSAInt i0, SSAInt i1, SSAInt i2, SSAInt i3); explicit SSAVec4i(llvm::Value *v); SSAVec4i(SSAVec4f f32); - SSAInt operator[](SSAInt index); + SSAInt operator[](SSAInt index) const; + SSAInt operator[](int index) const; SSAVec4i insert(SSAInt index, SSAInt value); SSAVec4i insert(int index, SSAInt value); + SSAVec4i insert(int index, int value); static SSAVec4i bitcast(SSAVec4f f32); static SSAVec4i bitcast(SSAVec8s i16); static SSAVec4i shuffle(const SSAVec4i &f0, int index0, int index1, int index2, int index3); diff --git a/src/r_compiler/ssa/ssa_vec4i_ptr.cpp b/src/r_compiler/ssa/ssa_vec4i_ptr.cpp index 7138c30d2..f75ccd43f 100644 --- a/src/r_compiler/ssa/ssa_vec4i_ptr.cpp +++ b/src/r_compiler/ssa/ssa_vec4i_ptr.cpp @@ -1,7 +1,7 @@ +#include "r_compiler/llvm_include.h" #include "ssa_vec4i_ptr.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAVec4iPtr::SSAVec4iPtr() : v(0) diff --git a/src/r_compiler/ssa/ssa_vec4i_ptr.h b/src/r_compiler/ssa/ssa_vec4i_ptr.h index 56937b1cc..257b4e34f 100644 --- a/src/r_compiler/ssa/ssa_vec4i_ptr.h +++ b/src/r_compiler/ssa/ssa_vec4i_ptr.h @@ -15,6 +15,7 @@ public: static SSAVec4iPtr from_llvm(llvm::Value *v) { return SSAVec4iPtr(v); } static llvm::Type *llvm_type(); SSAVec4iPtr operator[](SSAInt index) const; + SSAVec4iPtr operator[](int index) const { return (*this)[SSAInt(index)]; } SSAVec4i load() const; SSAVec4i load_unaligned() const; void store(const SSAVec4i &new_value); diff --git a/src/r_compiler/ssa/ssa_vec8s.cpp b/src/r_compiler/ssa/ssa_vec8s.cpp index d61a4c4a9..6016b551f 100644 --- a/src/r_compiler/ssa/ssa_vec8s.cpp +++ b/src/r_compiler/ssa/ssa_vec8s.cpp @@ -1,9 +1,9 @@ +#include "r_compiler/llvm_include.h" #include "ssa_vec8s.h" #include "ssa_vec4i.h" #include "ssa_vec16ub.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAVec8s::SSAVec8s() : v(0) @@ -77,12 +77,12 @@ SSAVec8s SSAVec8s::shuffle(const SSAVec8s &i0, const SSAVec8s &i1, int index0, i SSAVec8s SSAVec8s::extendhi(SSAVec16ub a) { - return SSAVec8s::bitcast(SSAVec16ub::shuffle(a, 0, 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15)); // _mm_unpackhi_epi8 + return SSAVec8s::bitcast(SSAVec16ub::shuffle(a, SSAVec16ub((unsigned char)0), 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15)); // _mm_unpackhi_epi8 } SSAVec8s SSAVec8s::extendlo(SSAVec16ub a) { - return SSAVec8s::bitcast(SSAVec16ub::shuffle(a, 0, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7)); // _mm_unpacklo_epi8 + return SSAVec8s::bitcast(SSAVec16ub::shuffle(a, SSAVec16ub((unsigned char)0), 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7)); // _mm_unpacklo_epi8 } /* diff --git a/src/r_compiler/ssa/ssa_vec8s.h b/src/r_compiler/ssa/ssa_vec8s.h index aded358dd..40263773b 100644 --- a/src/r_compiler/ssa/ssa_vec8s.h +++ b/src/r_compiler/ssa/ssa_vec8s.h @@ -11,8 +11,8 @@ class SSAVec8s { public: SSAVec8s(); - SSAVec8s(short constant); - SSAVec8s(short constant0, short constant1, short constant2, short constant3, short constant4, short constant5, short constant6, short constant7); + explicit SSAVec8s(short constant); + explicit SSAVec8s(short constant0, short constant1, short constant2, short constant3, short constant4, short constant5, short constant6, short constant7); explicit SSAVec8s(llvm::Value *v); SSAVec8s(SSAVec4i i0, SSAVec4i i1); static SSAVec8s bitcast(SSAVec16ub i8); From cfa6b817b5b3af2c8590aadd133732971c146be0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 1 Oct 2016 21:34:13 +0200 Subject: [PATCH 1013/1509] - made bloom and tonemap settings game specific and save all related CVARs. As was pointed out: "That said, there is one minor problem - different game artstyles can constitute whether Bloom is turned on, which tonemap is used, etc. For example, when playing Doom, I like having my bloom on, but if I am going to start playing the Adventures of Square, the art style and bloom don't mix, in my opinion. For this, I have to remember to switch my bloom settings every time I switch IWad" --- src/gl/renderer/gl_postprocess.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 7ce8be0ad..03bea6d72 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -69,24 +69,24 @@ // CVARs // //========================================================================== -CVAR(Bool, gl_bloom, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); -CUSTOM_CVAR(Float, gl_bloom_amount, 1.4f, 0) +CVAR(Bool, gl_bloom, false, CVAR_ARCHIVE); +CUSTOM_CVAR(Float, gl_bloom_amount, 1.4f, CVAR_ARCHIVE) { if (self < 0.1f) self = 0.1f; } -CVAR(Float, gl_exposure_scale, 1.3f, 0) -CVAR(Float, gl_exposure_min, 0.35f, 0) -CVAR(Float, gl_exposure_base, 0.35f, 0) -CVAR(Float, gl_exposure_speed, 0.05f, 0) +CVAR(Float, gl_exposure_scale, 1.3f, CVAR_ARCHIVE) +CVAR(Float, gl_exposure_min, 0.35f, CVAR_ARCHIVE) +CVAR(Float, gl_exposure_base, 0.35f, CVAR_ARCHIVE) +CVAR(Float, gl_exposure_speed, 0.05f, CVAR_ARCHIVE) -CUSTOM_CVAR(Int, gl_tonemap, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CUSTOM_CVAR(Int, gl_tonemap, 0, CVAR_ARCHIVE) { if (self < 0 || self > 5) self = 0; } -CUSTOM_CVAR(Int, gl_bloom_kernel_size, 7, 0) +CUSTOM_CVAR(Int, gl_bloom_kernel_size, 7, CVAR_ARCHIVE) { if (self < 3 || self > 15 || self % 2 == 0) self = 7; @@ -94,9 +94,9 @@ CUSTOM_CVAR(Int, gl_bloom_kernel_size, 7, 0) CVAR(Bool, gl_lens, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -CVAR(Float, gl_lens_k, -0.12f, 0) -CVAR(Float, gl_lens_kcube, 0.1f, 0) -CVAR(Float, gl_lens_chromatic, 1.12f, 0) +CVAR(Float, gl_lens_k, -0.12f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Float, gl_lens_kcube, 0.1f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Float, gl_lens_chromatic, 1.12f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) From 960d4d6755db3089a8d270c009a7549a9761e76b Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Thu, 22 Sep 2016 20:44:56 -0400 Subject: [PATCH 1014/1509] Create TopBottom3D mode and begin sketching RowInterleaved3D mode. --- src/CMakeLists.txt | 1 + src/gl/stereo3d/gl_interleaved3d.cpp | 71 ++++++++++++++++++++++++++++ src/gl/stereo3d/gl_interleaved3d.h | 58 +++++++++++++++++++++++ src/gl/stereo3d/gl_sidebyside3d.cpp | 38 +++++++++++++++ src/gl/stereo3d/gl_sidebyside3d.h | 8 ++++ src/gl/stereo3d/gl_stereo_cvars.cpp | 7 +++ wadsrc/static/language.enu | 2 + wadsrc/static/menudef.zz | 2 + 8 files changed, 187 insertions(+) create mode 100644 src/gl/stereo3d/gl_interleaved3d.cpp create mode 100644 src/gl/stereo3d/gl_interleaved3d.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 73dba07c4..e768e945f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1116,6 +1116,7 @@ set( FASTMATH_SOURCES gl/stereo3d/gl_anaglyph.cpp gl/stereo3d/gl_quadstereo.cpp gl/stereo3d/gl_sidebyside3d.cpp + gl/stereo3d/gl_interleaved3d.cpp gl/dynlights/gl_dynlight.cpp gl/dynlights/gl_glow.cpp gl/dynlights/gl_dynlight1.cpp diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp new file mode 100644 index 000000000..c811e0d21 --- /dev/null +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -0,0 +1,71 @@ +/* +** gl_interleaved3d.cpp +** Interleaved image stereoscopic 3D modes for GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + +#include "gl_interleaved3d.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderbuffers.h" + +namespace s3d { + +/* static */ +const RowInterleaved3D& RowInterleaved3D::getInstance(float ipd) +{ + static RowInterleaved3D instance(ipd); + return instance; +} + +void RowInterleaved3D::Present() const +{ + GLRenderer->mBuffers->BindOutputFB(); + GLRenderer->ClearBorders(); + + // Compute screen regions to use for left and right eye views + int topHeight = GLRenderer->mOutputLetterbox.height / 2; + int bottomHeight = GLRenderer->mOutputLetterbox.height - topHeight; + GL_IRECT topHalfScreen = GLRenderer->mOutputLetterbox; + topHalfScreen.height = topHeight; + GL_IRECT bottomHalfScreen = GLRenderer->mOutputLetterbox; + bottomHalfScreen.height = bottomHeight; + bottomHalfScreen.top += topHeight; + + GLRenderer->mBuffers->BindEyeTexture(0, 0); + GLRenderer->DrawPresentTexture(topHalfScreen, true); + + GLRenderer->mBuffers->BindEyeTexture(1, 0); + GLRenderer->DrawPresentTexture(bottomHalfScreen, true); +} + + +} /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_interleaved3d.h b/src/gl/stereo3d/gl_interleaved3d.h new file mode 100644 index 000000000..1f22fa356 --- /dev/null +++ b/src/gl/stereo3d/gl_interleaved3d.h @@ -0,0 +1,58 @@ +/* +** gl_interleaved3d.h +** Interleaved stereoscopic 3D modes for GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + +#ifndef GL_INTERLEAVED3D_H_ +#define GL_INTERLEAVED3D_H_ + +#include "gl_stereo3d.h" +#include "gl_stereo_leftright.h" +#include "gl_sidebyside3d.h" +#include "gl/system/gl_system.h" +#include "gl/renderer/gl_renderstate.h" + +namespace s3d { + +class RowInterleaved3D : public TopBottom3D +{ +public: + static const RowInterleaved3D& getInstance(float ipd); + RowInterleaved3D(double ipdMeters) : TopBottom3D(ipdMeters) {} + void Present() const override; +}; + +} /* namespace s3d */ + + +#endif /* GL_INTERLEAVED3D_H_ */ diff --git a/src/gl/stereo3d/gl_sidebyside3d.cpp b/src/gl/stereo3d/gl_sidebyside3d.cpp index c6463d2c8..d2b0cafdd 100644 --- a/src/gl/stereo3d/gl_sidebyside3d.cpp +++ b/src/gl/stereo3d/gl_sidebyside3d.cpp @@ -108,4 +108,42 @@ void SideBySideFull::AdjustPlayerSprites() const /* override */ gl_RenderState.ApplyMatrices(); } +/* static */ +const TopBottom3D& TopBottom3D::getInstance(float ipd) +{ + static TopBottom3D instance(ipd); + return instance; +} + +void TopBottom3D::Present() const +{ + GLRenderer->mBuffers->BindOutputFB(); + GLRenderer->ClearBorders(); + + // Compute screen regions to use for left and right eye views + int topHeight = GLRenderer->mOutputLetterbox.height / 2; + int bottomHeight = GLRenderer->mOutputLetterbox.height - topHeight; + GL_IRECT topHalfScreen = GLRenderer->mOutputLetterbox; + topHalfScreen.height = topHeight; + GL_IRECT bottomHalfScreen = GLRenderer->mOutputLetterbox; + bottomHalfScreen.height = bottomHeight; + bottomHalfScreen.top += topHeight; + + GLRenderer->mBuffers->BindEyeTexture(0, 0); + GLRenderer->DrawPresentTexture(topHalfScreen, true); + + GLRenderer->mBuffers->BindEyeTexture(1, 0); + GLRenderer->DrawPresentTexture(bottomHalfScreen, true); +} + +// AdjustViewports() is called from within FLGRenderer::SetOutputViewport(...) +void TopBottom3D::AdjustViewports() const +{ + // Change size of renderbuffer, and align to screen + GLRenderer->mSceneViewport.height /= 2; + GLRenderer->mSceneViewport.top /= 2; + GLRenderer->mScreenViewport.height /= 2; + GLRenderer->mScreenViewport.top /= 2; +} + } /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_sidebyside3d.h b/src/gl/stereo3d/gl_sidebyside3d.h index 374f255c5..c98f748a0 100644 --- a/src/gl/stereo3d/gl_sidebyside3d.h +++ b/src/gl/stereo3d/gl_sidebyside3d.h @@ -88,6 +88,14 @@ private: SBSFRightEyePose rightEye; }; +class TopBottom3D : public SideBySideSquished +{ +public: + static const TopBottom3D& getInstance(float ipd); + TopBottom3D(double ipdMeters) : SideBySideSquished(ipdMeters) {} + void Present() const override; + virtual void AdjustViewports() const override; +}; } /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index c09a7a974..16296393d 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -30,6 +30,7 @@ #include "gl/stereo3d/gl_anaglyph.h" #include "gl/stereo3d/gl_quadstereo.h" #include "gl/stereo3d/gl_sidebyside3d.h" +#include "gl/stereo3d/gl_interleaved3d.h" #include "gl/system/gl_cvars.h" // Set up 3D-specific console variables: @@ -100,6 +101,12 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() setCurrentMode(AmberBlue::getInstance(vr_ipd)); break; // TODO: 10: HTC Vive/OpenVR + case 11: + setCurrentMode(TopBottom3D::getInstance(vr_ipd)); + break; + case 12: + setCurrentMode(RowInterleaved3D::getInstance(vr_ipd)); + break; case 0: default: setCurrentMode(MonoView::getInstance()); diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 50526a75b..813d6b8f6 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2703,6 +2703,8 @@ OPTVAL_LEFTEYE = "Left Eye"; OPTVAL_RIGHTEYE = "Right Eye"; OPTVAL_SBSFULL = "Side-by-side Full"; OPTVAL_SBSNARROW = "Side-by-side Narrow"; +OPTVAL_TOPBOTTOM = "Top/Bottom"; +OPTVAL_ROWINTERLEAVED = "Row Interleaved"; OPTVAL_QUADBUFFERED = "Quad-buffered"; OPTVAL_UNCHARTED2 = "Uncharted 2"; OPTVAL_HEJLDAWSON = "Hejl Dawson"; diff --git a/wadsrc/static/menudef.zz b/wadsrc/static/menudef.zz index 1ab4f1a6d..6f96ea286 100644 --- a/wadsrc/static/menudef.zz +++ b/wadsrc/static/menudef.zz @@ -169,6 +169,8 @@ OptionValue VRMode 9, "$OPTVAL_AMBERBLUE" 3, "$OPTVAL_SBSFULL" 4, "$OPTVAL_SBSNARROW" + 11, "$OPTVAL_TOPBOTTOM" + 12, "$OPTVAL_ROWINTERLEAVED" 5, "$OPTVAL_LEFTEYE" 6, "$OPTVAL_RIGHTEYE" 7, "$OPTVAL_QUADBUFFERED" From 79046580d586df604aa30be88c0d3efc1ccc7e2d Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Tue, 27 Sep 2016 19:49:24 -0400 Subject: [PATCH 1015/1509] Partial implementation of row interlaced mode. --- src/gl/renderer/gl_renderbuffers.cpp | 20 ++++++++++++++++++++ src/gl/renderer/gl_renderbuffers.h | 2 ++ src/gl/stereo3d/gl_interleaved3d.cpp | 13 +++++-------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index b2471e4b9..31fc36832 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -576,6 +576,26 @@ void FGLRenderBuffers::BlitToEyeTexture(int eye) glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); } +void FGLRenderBuffers::BlitFromEyeTexture(int eye, GL_IRECT* box) +{ + glBindFramebuffer(GL_READ_FRAMEBUFFER, mEyeFBs[eye]); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mOutputFB); + if (box == nullptr) + box = &GLRenderer->mOutputLetterbox; + glBlitFramebuffer(0, 0, mWidth, mHeight, + box->left, box->top, box->width + box->left, box->height + box->top, + GL_COLOR_BUFFER_BIT, GL_NEAREST); + + if ((gl.flags & RFL_INVALIDATE_BUFFER) != 0) + { + GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT }; + glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 2, attachments); + } + + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); +} + void FGLRenderBuffers::BindEyeTexture(int eye, int texunit) { CreateEyeBuffers(eye); diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 4477718f4..043cb8852 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -2,6 +2,7 @@ #define __GL_RENDERBUFFERS_H #include "gl/shaders/gl_shader.h" +#include "gl/renderer/gl_renderer.h" class FGLBloomTextureLevel { @@ -42,6 +43,7 @@ public: void BindOutputFB(); void BlitToEyeTexture(int eye); + void BlitFromEyeTexture(int eye, GL_IRECT* box); void BindEyeTexture(int eye, int texunit); void BindEyeFB(int eye, bool readBuffer = false); diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp index c811e0d21..085efae51 100644 --- a/src/gl/stereo3d/gl_interleaved3d.cpp +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -53,18 +53,15 @@ void RowInterleaved3D::Present() const // Compute screen regions to use for left and right eye views int topHeight = GLRenderer->mOutputLetterbox.height / 2; - int bottomHeight = GLRenderer->mOutputLetterbox.height - topHeight; GL_IRECT topHalfScreen = GLRenderer->mOutputLetterbox; topHalfScreen.height = topHeight; + topHalfScreen.top = topHeight; GL_IRECT bottomHalfScreen = GLRenderer->mOutputLetterbox; - bottomHalfScreen.height = bottomHeight; - bottomHalfScreen.top += topHeight; + bottomHalfScreen.height = topHeight; + bottomHalfScreen.top = 0; - GLRenderer->mBuffers->BindEyeTexture(0, 0); - GLRenderer->DrawPresentTexture(topHalfScreen, true); - - GLRenderer->mBuffers->BindEyeTexture(1, 0); - GLRenderer->DrawPresentTexture(bottomHalfScreen, true); + GLRenderer->mBuffers->BlitFromEyeTexture(0, &topHalfScreen); + GLRenderer->mBuffers->BlitFromEyeTexture(1, &bottomHalfScreen); } From 460b6537096062c904eed7c016871757e11957e5 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sun, 2 Oct 2016 12:24:37 -0400 Subject: [PATCH 1016/1509] Row interlaced 3d might be working, at least in fullscreen 1920x1080 mode. --- src/CMakeLists.txt | 1 + src/gl/renderer/gl_renderer.cpp | 4 ++ src/gl/renderer/gl_renderer.h | 2 + src/gl/shaders/gl_present3dRowshader.cpp | 60 +++++++++++++++++++++ src/gl/shaders/gl_present3dRowshader.h | 51 ++++++++++++++++++ src/gl/stereo3d/gl_interleaved3d.cpp | 49 ++++++++++++++++- src/gl/stereo3d/gl_interleaved3d.h | 4 +- src/gl/stereo3d/gl_sidebyside3d.cpp | 3 +- wadsrc/static/shaders/glsl/present_row3d.fp | 36 +++++++++++++ 9 files changed, 206 insertions(+), 4 deletions(-) create mode 100644 src/gl/shaders/gl_present3dRowshader.cpp create mode 100644 src/gl/shaders/gl_present3dRowshader.h create mode 100644 wadsrc/static/shaders/glsl/present_row3d.fp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e768e945f..7307e6eec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1125,6 +1125,7 @@ set( FASTMATH_SOURCES gl/shaders/gl_texshader.cpp gl/shaders/gl_shaderprogram.cpp gl/shaders/gl_presentshader.cpp + gl/shaders/gl_present3dRowshader.cpp gl/shaders/gl_bloomshader.cpp gl/shaders/gl_blurshader.cpp gl/shaders/gl_colormapshader.cpp diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 42b4a8e1b..fbfa51440 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -57,6 +57,7 @@ #include "gl/shaders/gl_colormapshader.h" #include "gl/shaders/gl_lensshader.h" #include "gl/shaders/gl_presentshader.h" +#include "gl/shaders/gl_present3dRowshader.h" #include "gl/stereo3d/gl_stereo3d.h" #include "gl/textures/gl_texture.h" #include "gl/textures/gl_translate.h" @@ -103,6 +104,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mTonemapPalette = nullptr; mBuffers = nullptr; mPresentShader = nullptr; + mPresent3dRowShader = nullptr; mBloomExtractShader = nullptr; mBloomCombineShader = nullptr; mExposureExtractShader = nullptr; @@ -132,6 +134,7 @@ void FGLRenderer::Initialize(int width, int height) mTonemapPalette = nullptr; mLensShader = new FLensShader(); mPresentShader = new FPresentShader(); + mPresent3dRowShader = new FPresent3DRowShader(); m2DDrawer = new F2DDrawer; // needed for the core profile, because someone decided it was a good idea to remove the default VAO. @@ -184,6 +187,7 @@ FGLRenderer::~FGLRenderer() } if (mBuffers) delete mBuffers; if (mPresentShader) delete mPresentShader; + if (mPresent3dRowShader) delete mPresent3dRowShader; if (mBloomExtractShader) delete mBloomExtractShader; if (mBloomCombineShader) delete mBloomCombineShader; if (mExposureExtractShader) delete mExposureExtractShader; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 71c52474a..460b5685a 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -29,6 +29,7 @@ class FTonemapShader; class FColormapShader; class FLensShader; class FPresentShader; +class FPresent3DRowShader; class F2DDrawer; class FHardwareTexture; @@ -104,6 +105,7 @@ public: FHardwareTexture *mTonemapPalette; FLensShader *mLensShader; FPresentShader *mPresentShader; + FPresent3DRowShader *mPresent3dRowShader; FTexture *gllight; FTexture *glpart2; diff --git a/src/gl/shaders/gl_present3dRowshader.cpp b/src/gl/shaders/gl_present3dRowshader.cpp new file mode 100644 index 000000000..607e4ede6 --- /dev/null +++ b/src/gl/shaders/gl_present3dRowshader.cpp @@ -0,0 +1,60 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// +/* +** gl_3dRowshader.cpp +** Copy rendered texture to back buffer, possibly with gamma correction +** while interleaving rows from two independent viewpoint textures, +** representing the left-eye and right-eye views. +** +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "gl/gl_functions.h" +#include "vectors.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_present3dRowshader.h" + +void FPresent3DRowShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquadscale.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/present_row3d.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/presentRow3d"); + mShader.SetAttribLocation(0, "PositionInProjection"); + mShader.SetAttribLocation(1, "UV"); + LeftEyeTexture.Init(mShader, "LeftEyeTexture"); + RightEyeTexture.Init(mShader, "RightEyeTexture"); + InvGamma.Init(mShader, "InvGamma"); + Contrast.Init(mShader, "Contrast"); + Brightness.Init(mShader, "Brightness"); + Scale.Init(mShader, "UVScale"); + VerticalPixelOffset.Init(mShader, "VerticalPixelOffset"); + } + mShader.Bind(); +} diff --git a/src/gl/shaders/gl_present3dRowshader.h b/src/gl/shaders/gl_present3dRowshader.h new file mode 100644 index 000000000..8e3bd772d --- /dev/null +++ b/src/gl/shaders/gl_present3dRowshader.h @@ -0,0 +1,51 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2015 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// +/* +** gl_present3dRowshader.h +** Final composition and present shader for row-interleaved stereoscopic 3D mode +** +*/ + +#ifndef GL_PRESENT3DROWSHADER_H_ +#define GL_PRESENT3DROWSHADER_H_ + +#include "gl_shaderprogram.h" + +class FPresent3DRowShader +{ +public: + void Bind(); + + FBufferedUniformSampler LeftEyeTexture; + FBufferedUniformSampler RightEyeTexture; + FBufferedUniform1f InvGamma; + FBufferedUniform1f Contrast; + FBufferedUniform1f Brightness; + FBufferedUniform2f Scale; + FBufferedUniform1i VerticalPixelOffset; + +private: + FShaderProgram mShader; +}; + +// GL_PRESENT3DROWSHADER_H_ +#endif \ No newline at end of file diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp index 085efae51..28b9c373e 100644 --- a/src/gl/stereo3d/gl_interleaved3d.cpp +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -36,6 +36,12 @@ #include "gl_interleaved3d.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderbuffers.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/shaders/gl_present3dRowshader.h" + +EXTERN_CVAR(Float, vid_brightness) +EXTERN_CVAR(Float, vid_contrast) namespace s3d { @@ -46,6 +52,10 @@ const RowInterleaved3D& RowInterleaved3D::getInstance(float ipd) return instance; } +RowInterleaved3D::RowInterleaved3D(double ipdMeters) + : TopBottom3D(ipdMeters) +{} + void RowInterleaved3D::Present() const { GLRenderer->mBuffers->BindOutputFB(); @@ -60,8 +70,43 @@ void RowInterleaved3D::Present() const bottomHalfScreen.height = topHeight; bottomHalfScreen.top = 0; - GLRenderer->mBuffers->BlitFromEyeTexture(0, &topHalfScreen); - GLRenderer->mBuffers->BlitFromEyeTexture(1, &bottomHalfScreen); + // Bind each eye texture, for composition in the shader + GLRenderer->mBuffers->BindEyeTexture(0, 0); + GLRenderer->mBuffers->BindEyeTexture(1, 1); + + glActiveTexture(GL_TEXTURE0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glActiveTexture(GL_TEXTURE1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + const GL_IRECT& box = GLRenderer->mOutputLetterbox; + glViewport(box.left, box.top, box.width, box.height); + + bool applyGamma = true; + + GLRenderer->mPresent3dRowShader->Bind(); + GLRenderer->mPresent3dRowShader->LeftEyeTexture.Set(0); + GLRenderer->mPresent3dRowShader->RightEyeTexture.Set(1); + if (!applyGamma || GLRenderer->framebuffer->IsHWGammaActive()) + { + GLRenderer->mPresent3dRowShader->InvGamma.Set(1.0f); + GLRenderer->mPresent3dRowShader->Contrast.Set(1.0f); + GLRenderer->mPresent3dRowShader->Brightness.Set(0.0f); + } + else + { + GLRenderer->mPresent3dRowShader->InvGamma.Set(1.0f / clamp(Gamma, 0.1f, 4.f)); + GLRenderer->mPresent3dRowShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); + GLRenderer->mPresent3dRowShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); + } + GLRenderer->mPresent3dRowShader->Scale.Set( + GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(), + GLRenderer->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight()); + GLRenderer->mPresent3dRowShader->VerticalPixelOffset.Set(0); // fixme: vary with window location + GLRenderer->RenderScreenQuad(); } diff --git a/src/gl/stereo3d/gl_interleaved3d.h b/src/gl/stereo3d/gl_interleaved3d.h index 1f22fa356..30aef7d5a 100644 --- a/src/gl/stereo3d/gl_interleaved3d.h +++ b/src/gl/stereo3d/gl_interleaved3d.h @@ -42,13 +42,15 @@ #include "gl/system/gl_system.h" #include "gl/renderer/gl_renderstate.h" +class FPresent3DRowShader; + namespace s3d { class RowInterleaved3D : public TopBottom3D { public: static const RowInterleaved3D& getInstance(float ipd); - RowInterleaved3D(double ipdMeters) : TopBottom3D(ipdMeters) {} + RowInterleaved3D(double ipdMeters); void Present() const override; }; diff --git a/src/gl/stereo3d/gl_sidebyside3d.cpp b/src/gl/stereo3d/gl_sidebyside3d.cpp index d2b0cafdd..ecb3ec1cc 100644 --- a/src/gl/stereo3d/gl_sidebyside3d.cpp +++ b/src/gl/stereo3d/gl_sidebyside3d.cpp @@ -125,9 +125,10 @@ void TopBottom3D::Present() const int bottomHeight = GLRenderer->mOutputLetterbox.height - topHeight; GL_IRECT topHalfScreen = GLRenderer->mOutputLetterbox; topHalfScreen.height = topHeight; + topHalfScreen.top = topHeight; GL_IRECT bottomHalfScreen = GLRenderer->mOutputLetterbox; bottomHalfScreen.height = bottomHeight; - bottomHalfScreen.top += topHeight; + bottomHalfScreen.top = 0; GLRenderer->mBuffers->BindEyeTexture(0, 0); GLRenderer->DrawPresentTexture(topHalfScreen, true); diff --git a/wadsrc/static/shaders/glsl/present_row3d.fp b/wadsrc/static/shaders/glsl/present_row3d.fp new file mode 100644 index 000000000..18bd3cd11 --- /dev/null +++ b/wadsrc/static/shaders/glsl/present_row3d.fp @@ -0,0 +1,36 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D LeftEyeTexture; +uniform sampler2D RightEyeTexture; +uniform float InvGamma; +uniform float Contrast; +uniform float Brightness; +uniform int VerticalPixelOffset; // top-of-window might not be top-of-screen + +vec4 ApplyGamma(vec4 c) +{ + vec3 val = c.rgb * Contrast - (Contrast - 1.0) * 0.5; + val += Brightness * 0.5; + val = pow(max(val, vec3(0.0)), vec3(InvGamma)); + return vec4(val, c.a); +} + +void main() +{ + // NOTE we assume here that the full screen height is the sum of the left + // and right eye view heights + int screenHeightInPixels = textureSize(LeftEyeTexture, 0).y + textureSize(RightEyeTexture, 0).y; + int thisVerticalPixel = int(TexCoord.y * screenHeightInPixels + 0.5); + bool isLeftEye = (thisVerticalPixel + VerticalPixelOffset) % 2 == 0; + vec4 inputColor; + if (isLeftEye) { + inputColor = texture(LeftEyeTexture, TexCoord); + } + else { + // inputColor = vec4(0, 1, 0, 1); + inputColor = texture(RightEyeTexture, TexCoord); + } + FragColor = ApplyGamma(inputColor); +} From fcbf9342d69a04619042df12c88e857e7d41ee4e Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sun, 2 Oct 2016 13:11:07 -0400 Subject: [PATCH 1017/1509] Compute row location using gl_FragCoord. --- src/gl/shaders/gl_present3dRowshader.cpp | 1 + src/gl/shaders/gl_present3dRowshader.h | 1 + src/gl/stereo3d/gl_interleaved3d.cpp | 13 +++++-------- wadsrc/static/shaders/glsl/present_row3d.fp | 6 ++---- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/gl/shaders/gl_present3dRowshader.cpp b/src/gl/shaders/gl_present3dRowshader.cpp index 607e4ede6..931278aaa 100644 --- a/src/gl/shaders/gl_present3dRowshader.cpp +++ b/src/gl/shaders/gl_present3dRowshader.cpp @@ -54,6 +54,7 @@ void FPresent3DRowShader::Bind() Contrast.Init(mShader, "Contrast"); Brightness.Init(mShader, "Brightness"); Scale.Init(mShader, "UVScale"); + WindowHeight.Init(mShader, "WindowHeight"); VerticalPixelOffset.Init(mShader, "VerticalPixelOffset"); } mShader.Bind(); diff --git a/src/gl/shaders/gl_present3dRowshader.h b/src/gl/shaders/gl_present3dRowshader.h index 8e3bd772d..b7f0d87b2 100644 --- a/src/gl/shaders/gl_present3dRowshader.h +++ b/src/gl/shaders/gl_present3dRowshader.h @@ -41,6 +41,7 @@ public: FBufferedUniform1f Contrast; FBufferedUniform1f Brightness; FBufferedUniform2f Scale; + FBufferedUniform1i WindowHeight; FBufferedUniform1i VerticalPixelOffset; private: diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp index 28b9c373e..5e0281ee6 100644 --- a/src/gl/stereo3d/gl_interleaved3d.cpp +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -61,14 +61,6 @@ void RowInterleaved3D::Present() const GLRenderer->mBuffers->BindOutputFB(); GLRenderer->ClearBorders(); - // Compute screen regions to use for left and right eye views - int topHeight = GLRenderer->mOutputLetterbox.height / 2; - GL_IRECT topHalfScreen = GLRenderer->mOutputLetterbox; - topHalfScreen.height = topHeight; - topHalfScreen.top = topHeight; - GL_IRECT bottomHalfScreen = GLRenderer->mOutputLetterbox; - bottomHalfScreen.height = topHeight; - bottomHalfScreen.top = 0; // Bind each eye texture, for composition in the shader GLRenderer->mBuffers->BindEyeTexture(0, 0); @@ -90,6 +82,7 @@ void RowInterleaved3D::Present() const GLRenderer->mPresent3dRowShader->Bind(); GLRenderer->mPresent3dRowShader->LeftEyeTexture.Set(0); GLRenderer->mPresent3dRowShader->RightEyeTexture.Set(1); + if (!applyGamma || GLRenderer->framebuffer->IsHWGammaActive()) { GLRenderer->mPresent3dRowShader->InvGamma.Set(1.0f); @@ -105,7 +98,11 @@ void RowInterleaved3D::Present() const GLRenderer->mPresent3dRowShader->Scale.Set( GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(), GLRenderer->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight()); + + GLRenderer->mPresent3dRowShader->WindowHeight.Set(0); + GLRenderer->mPresent3dRowShader->VerticalPixelOffset.Set(0); // fixme: vary with window location + GLRenderer->RenderScreenQuad(); } diff --git a/wadsrc/static/shaders/glsl/present_row3d.fp b/wadsrc/static/shaders/glsl/present_row3d.fp index 18bd3cd11..73a01539b 100644 --- a/wadsrc/static/shaders/glsl/present_row3d.fp +++ b/wadsrc/static/shaders/glsl/present_row3d.fp @@ -7,6 +7,7 @@ uniform sampler2D RightEyeTexture; uniform float InvGamma; uniform float Contrast; uniform float Brightness; +uniform int WindowHeight; uniform int VerticalPixelOffset; // top-of-window might not be top-of-screen vec4 ApplyGamma(vec4 c) @@ -19,10 +20,7 @@ vec4 ApplyGamma(vec4 c) void main() { - // NOTE we assume here that the full screen height is the sum of the left - // and right eye view heights - int screenHeightInPixels = textureSize(LeftEyeTexture, 0).y + textureSize(RightEyeTexture, 0).y; - int thisVerticalPixel = int(TexCoord.y * screenHeightInPixels + 0.5); + int thisVerticalPixel = int(gl_FragCoord.y); bool isLeftEye = (thisVerticalPixel + VerticalPixelOffset) % 2 == 0; vec4 inputColor; if (isLeftEye) { From 576619504e63e0385e2d7500da8859980327e058 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sun, 2 Oct 2016 13:12:22 -0400 Subject: [PATCH 1018/1509] Remove unused WindowHeight uniform. --- src/gl/shaders/gl_present3dRowshader.cpp | 1 - src/gl/shaders/gl_present3dRowshader.h | 1 - src/gl/stereo3d/gl_interleaved3d.cpp | 2 -- 3 files changed, 4 deletions(-) diff --git a/src/gl/shaders/gl_present3dRowshader.cpp b/src/gl/shaders/gl_present3dRowshader.cpp index 931278aaa..607e4ede6 100644 --- a/src/gl/shaders/gl_present3dRowshader.cpp +++ b/src/gl/shaders/gl_present3dRowshader.cpp @@ -54,7 +54,6 @@ void FPresent3DRowShader::Bind() Contrast.Init(mShader, "Contrast"); Brightness.Init(mShader, "Brightness"); Scale.Init(mShader, "UVScale"); - WindowHeight.Init(mShader, "WindowHeight"); VerticalPixelOffset.Init(mShader, "VerticalPixelOffset"); } mShader.Bind(); diff --git a/src/gl/shaders/gl_present3dRowshader.h b/src/gl/shaders/gl_present3dRowshader.h index b7f0d87b2..8e3bd772d 100644 --- a/src/gl/shaders/gl_present3dRowshader.h +++ b/src/gl/shaders/gl_present3dRowshader.h @@ -41,7 +41,6 @@ public: FBufferedUniform1f Contrast; FBufferedUniform1f Brightness; FBufferedUniform2f Scale; - FBufferedUniform1i WindowHeight; FBufferedUniform1i VerticalPixelOffset; private: diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp index 5e0281ee6..fd7a6c4c6 100644 --- a/src/gl/stereo3d/gl_interleaved3d.cpp +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -99,8 +99,6 @@ void RowInterleaved3D::Present() const GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(), GLRenderer->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight()); - GLRenderer->mPresent3dRowShader->WindowHeight.Set(0); - GLRenderer->mPresent3dRowShader->VerticalPixelOffset.Set(0); // fixme: vary with window location GLRenderer->RenderScreenQuad(); From 0240cdef18ec31b62fc53ed946d49fc775b4cacb Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sun, 2 Oct 2016 13:49:57 -0400 Subject: [PATCH 1019/1509] Modulate row interleaved stereo 3d offset with window height parity, because gl_FragCoord.y approaches zero at the bottom, not the top of the window. --- src/gl/stereo3d/gl_interleaved3d.cpp | 5 ++++- wadsrc/static/shaders/glsl/present_row3d.fp | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp index fd7a6c4c6..225f52819 100644 --- a/src/gl/stereo3d/gl_interleaved3d.cpp +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -99,7 +99,10 @@ void RowInterleaved3D::Present() const GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(), GLRenderer->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight()); - GLRenderer->mPresent3dRowShader->VerticalPixelOffset.Set(0); // fixme: vary with window location + GLRenderer->mPresent3dRowShader->VerticalPixelOffset.Set( + 0 // fixme: vary with window location + + box.height % 2 // because we want the top pixel offset, but gl_FragCoord.y is the bottom pixel offset + ); GLRenderer->RenderScreenQuad(); } diff --git a/wadsrc/static/shaders/glsl/present_row3d.fp b/wadsrc/static/shaders/glsl/present_row3d.fp index 73a01539b..8ae72d1e0 100644 --- a/wadsrc/static/shaders/glsl/present_row3d.fp +++ b/wadsrc/static/shaders/glsl/present_row3d.fp @@ -7,7 +7,6 @@ uniform sampler2D RightEyeTexture; uniform float InvGamma; uniform float Contrast; uniform float Brightness; -uniform int WindowHeight; uniform int VerticalPixelOffset; // top-of-window might not be top-of-screen vec4 ApplyGamma(vec4 c) @@ -20,8 +19,10 @@ vec4 ApplyGamma(vec4 c) void main() { - int thisVerticalPixel = int(gl_FragCoord.y); - bool isLeftEye = (thisVerticalPixel + VerticalPixelOffset) % 2 == 0; + int thisVerticalPixel = int(gl_FragCoord.y + 1.0); // Bottom row is typically the right eye, when WindowHeight is even + bool isLeftEye = (thisVerticalPixel // because we want to alternate eye view on each row + + VerticalPixelOffset // because the window might not be aligned to the screen + ) % 2 == 0; vec4 inputColor; if (isLeftEye) { inputColor = texture(LeftEyeTexture, TexCoord); From 63b28a1d80a7d055616978de8d9f8c1c77f8dc64 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sun, 2 Oct 2016 16:04:52 -0400 Subject: [PATCH 1020/1509] Retain stereoscopic parity after dragging window in row interleaved 3D mode. --- src/gl/stereo3d/gl_interleaved3d.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp index 225f52819..329dec953 100644 --- a/src/gl/stereo3d/gl_interleaved3d.cpp +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -42,6 +42,8 @@ EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) +EXTERN_CVAR(Bool, fullscreen) +EXTERN_CVAR(Int, win_y) // pixel position of top of display window namespace s3d { @@ -99,8 +101,16 @@ void RowInterleaved3D::Present() const GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(), GLRenderer->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight()); + // Compute absolute offset from top of screen to top of current display window + // because we need screen-relative, not window-relative, scan line parity + int windowVOffset = 0; + if (! fullscreen) { + I_SaveWindowedPos(); // update win_y CVAR + windowVOffset = win_y; + } + GLRenderer->mPresent3dRowShader->VerticalPixelOffset.Set( - 0 // fixme: vary with window location + windowVOffset // fixme: vary with window location + box.height % 2 // because we want the top pixel offset, but gl_FragCoord.y is the bottom pixel offset ); From 5391216756165e0f1e66db3b141c4b4c0c9849fb Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sun, 2 Oct 2016 16:27:43 -0400 Subject: [PATCH 1021/1509] Delete unused new BlitFromEyeTexture() method I ended up not using. --- src/gl/renderer/gl_renderbuffers.cpp | 20 -------------------- src/gl/renderer/gl_renderbuffers.h | 1 - 2 files changed, 21 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 31fc36832..b2471e4b9 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -576,26 +576,6 @@ void FGLRenderBuffers::BlitToEyeTexture(int eye) glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); } -void FGLRenderBuffers::BlitFromEyeTexture(int eye, GL_IRECT* box) -{ - glBindFramebuffer(GL_READ_FRAMEBUFFER, mEyeFBs[eye]); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mOutputFB); - if (box == nullptr) - box = &GLRenderer->mOutputLetterbox; - glBlitFramebuffer(0, 0, mWidth, mHeight, - box->left, box->top, box->width + box->left, box->height + box->top, - GL_COLOR_BUFFER_BIT, GL_NEAREST); - - if ((gl.flags & RFL_INVALIDATE_BUFFER) != 0) - { - GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT }; - glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 2, attachments); - } - - glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); -} - void FGLRenderBuffers::BindEyeTexture(int eye, int texunit) { CreateEyeBuffers(eye); diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 043cb8852..5fe05f5ac 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -43,7 +43,6 @@ public: void BindOutputFB(); void BlitToEyeTexture(int eye); - void BlitFromEyeTexture(int eye, GL_IRECT* box); void BindEyeTexture(int eye, int texunit); void BindEyeFB(int eye, bool readBuffer = false); From c68aa2b24168d6baf373edffc7f1f5b2eb18b2ca Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 25 Sep 2016 12:25:01 +0300 Subject: [PATCH 1022/1509] Added FXAA post-processing Implementation of Fast Approximate Anti-Aliasing is based on nVidia sample: https://github.com/NVIDIAGameWorks/GraphicsSamples/tree/master/samples/es3-kepler/FXAA --- docs/licenses/fxaa.txt | 33 ++ src/CMakeLists.txt | 1 + src/gl/renderer/gl_postprocess.cpp | 54 +++ src/gl/renderer/gl_renderer.cpp | 7 + src/gl/renderer/gl_renderer.h | 5 + src/gl/scene/gl_scene.cpp | 1 + src/gl/shaders/gl_fxaashader.cpp | 99 +++++ src/gl/shaders/gl_fxaashader.h | 66 ++++ wadsrc/static/language.enu | 7 +- wadsrc/static/menudef.zz | 10 + wadsrc/static/shaders/glsl/fxaa.fp | 615 +++++++++++++++++++++++++++++ 11 files changed, 897 insertions(+), 1 deletion(-) create mode 100644 docs/licenses/fxaa.txt create mode 100644 src/gl/shaders/gl_fxaashader.cpp create mode 100644 src/gl/shaders/gl_fxaashader.h create mode 100644 wadsrc/static/shaders/glsl/fxaa.fp diff --git a/docs/licenses/fxaa.txt b/docs/licenses/fxaa.txt new file mode 100644 index 000000000..fbd143c1d --- /dev/null +++ b/docs/licenses/fxaa.txt @@ -0,0 +1,33 @@ +//---------------------------------------------------------------------------------- +// File: es3-kepler\FXAA/FXAA3_11.h +// SDK Version: v3.00 +// Email: gameworks@nvidia.com +// Site: http://developer.nvidia.com/ +// +// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of NVIDIA CORPORATION nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +//---------------------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7307e6eec..19e5c9a0c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1131,6 +1131,7 @@ set( FASTMATH_SOURCES gl/shaders/gl_colormapshader.cpp gl/shaders/gl_tonemapshader.cpp gl/shaders/gl_lensshader.cpp + gl/shaders/gl_fxaashader.cpp gl/system/gl_interface.cpp gl/system/gl_framebuffer.cpp gl/system/gl_debug.cpp diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 03bea6d72..52339e587 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -60,6 +60,7 @@ #include "gl/shaders/gl_tonemapshader.h" #include "gl/shaders/gl_colormapshader.h" #include "gl/shaders/gl_lensshader.h" +#include "gl/shaders/gl_fxaashader.h" #include "gl/shaders/gl_presentshader.h" #include "gl/renderer/gl_2ddrawer.h" #include "gl/stereo3d/gl_stereo3d.h" @@ -98,6 +99,14 @@ CVAR(Float, gl_lens_k, -0.12f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Float, gl_lens_kcube, 0.1f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Float, gl_lens_chromatic, 1.12f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CUSTOM_CVAR(Int, gl_fxaa, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (self < 0 || self >= FFXAAShader::Count) + { + self = 0; + } +} + EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) @@ -447,6 +456,51 @@ void FGLRenderer::LensDistortScene() FGLDebug::PopGroup(); } +//----------------------------------------------------------------------------- +// +// Apply FXAA and place the result in the HUD/2D texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::ApplyFXAA() +{ + if (0 == gl_fxaa) + { + return; + } + + FGLDebug::PushGroup("ApplyFXAA"); + + const GLfloat rpcRes[2] = + { + 1.0f / mBuffers->GetWidth(), + 1.0f / mBuffers->GetHeight() + }; + + FGLPostProcessState savedState; + + mBuffers->BindNextFB(); + mBuffers->BindCurrentTexture(0); + mFXAALumaShader->Bind(); + mFXAALumaShader->InputTexture.Set(0); + RenderScreenQuad(); + mBuffers->NextTexture(); + + mBuffers->BindNextFB(); + mBuffers->BindCurrentTexture(0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mFXAAShader->Bind(); + mFXAAShader->InputTexture.Set(0); + mFXAAShader->ReciprocalResolution.Set(rpcRes); + RenderScreenQuad(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + mBuffers->NextTexture(); + + FGLDebug::PopGroup(); +} + //----------------------------------------------------------------------------- // // Copies the rendered screen to its final destination diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index fbfa51440..be1b96f15 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -56,6 +56,7 @@ #include "gl/shaders/gl_tonemapshader.h" #include "gl/shaders/gl_colormapshader.h" #include "gl/shaders/gl_lensshader.h" +#include "gl/shaders/gl_fxaashader.h" #include "gl/shaders/gl_presentshader.h" #include "gl/shaders/gl_present3dRowshader.h" #include "gl/stereo3d/gl_stereo3d.h" @@ -115,6 +116,8 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mTonemapPalette = nullptr; mColormapShader = nullptr; mLensShader = nullptr; + mFXAAShader = nullptr; + mFXAALumaShader = nullptr; } void gl_LoadModels(); @@ -133,6 +136,8 @@ void FGLRenderer::Initialize(int width, int height) mColormapShader = new FColormapShader(); mTonemapPalette = nullptr; mLensShader = new FLensShader(); + mFXAAShader = new FFXAAShader; + mFXAALumaShader = new FFXAALumaShader; mPresentShader = new FPresentShader(); mPresent3dRowShader = new FPresent3DRowShader(); m2DDrawer = new F2DDrawer; @@ -198,6 +203,8 @@ FGLRenderer::~FGLRenderer() if (mTonemapPalette) delete mTonemapPalette; if (mColormapShader) delete mColormapShader; if (mLensShader) delete mLensShader; + delete mFXAAShader; + delete mFXAALumaShader; } //========================================================================== diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 460b5685a..65e31c52f 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -28,6 +28,8 @@ class FBlurShader; class FTonemapShader; class FColormapShader; class FLensShader; +class FFXAALumaShader; +class FFXAAShader; class FPresentShader; class FPresent3DRowShader; class F2DDrawer; @@ -104,6 +106,8 @@ public: FColormapShader *mColormapShader; FHardwareTexture *mTonemapPalette; FLensShader *mLensShader; + FFXAALumaShader *mFXAALumaShader; + FFXAAShader *mFXAAShader; FPresentShader *mPresentShader; FPresent3DRowShader *mPresent3dRowShader; @@ -180,6 +184,7 @@ public: void BindTonemapPalette(int texunit); void ClearTonemapPalette(); void LensDistortScene(); + void ApplyFXAA(); void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma); void DrawPresentTexture(const GL_IRECT &box, bool applyGamma); void Flush(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 0c76b4bb1..4b7bc762f 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -832,6 +832,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo TonemapScene(); ColormapScene(); LensDistortScene(); + ApplyFXAA(); // This should be done after postprocessing, not before. mBuffers->BindCurrentFB(); diff --git a/src/gl/shaders/gl_fxaashader.cpp b/src/gl/shaders/gl_fxaashader.cpp new file mode 100644 index 000000000..277c7fbb3 --- /dev/null +++ b/src/gl/shaders/gl_fxaashader.cpp @@ -0,0 +1,99 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Alexey Lysiuk +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// + +// +// Fast approXimate Anti-Aliasing (FXAA) post-processing +// + +#include "gl/system/gl_system.h" +#include "gl/shaders/gl_fxaashader.h" + +EXTERN_CVAR(Int, gl_fxaa) + +void FFXAALumaShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/fxaa.fp", "#define FXAA_LUMA_PASS\n", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/fxaa"); + mShader.SetAttribLocation(0, "PositionInProjection"); + InputTexture.Init(mShader, "InputTexture"); + } + + mShader.Bind(); +} + +static int GetMaxVersion() +{ + return gl.glslversion >= 4.f ? 400 : 330; +} + +static FString GetDefines() +{ + int quality; + + switch (gl_fxaa) + { + default: + case FFXAAShader::Low: quality = 10; break; + case FFXAAShader::Medium: quality = 12; break; + case FFXAAShader::High: quality = 29; break; + case FFXAAShader::Extreme: quality = 39; break; + } + + const int gatherAlpha = GetMaxVersion() >= 400 ? 1 : 0; + + // TODO: enable FXAA_GATHER4_ALPHA on OpenGL earlier than 4.0 + // when GL_ARB_gpu_shader5/GL_NV_gpu_shader5 extensions are supported + + FString result; + result.Format( + "#define FXAA_QUALITY__PRESET %i\n" + "#define FXAA_GATHER4_ALPHA %i\n", + quality, gatherAlpha); + + return result; +} + +void FFXAAShader::Bind() +{ + assert(gl_fxaa > 0 && gl_fxaa < Count); + FShaderProgram &shader = mShaders[gl_fxaa]; + + if (!shader) + { + const FString defines = GetDefines(); + const int maxVersion = GetMaxVersion(); + + shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + shader.Compile(FShaderProgram::Fragment, "shaders/glsl/fxaa.fp", defines, maxVersion); + shader.SetFragDataLocation(0, "FragColor"); + shader.Link("shaders/glsl/fxaa"); + shader.SetAttribLocation(0, "PositionInProjection"); + InputTexture.Init(shader, "InputTexture"); + ReciprocalResolution.Init(shader, "ReciprocalResolution"); + } + + shader.Bind(); +} diff --git a/src/gl/shaders/gl_fxaashader.h b/src/gl/shaders/gl_fxaashader.h new file mode 100644 index 000000000..5ebcd232e --- /dev/null +++ b/src/gl/shaders/gl_fxaashader.h @@ -0,0 +1,66 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Alexey Lysiuk +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// + +// +// Fast approXimate Anti-Aliasing (FXAA) post-processing +// + +#ifndef __GL_FXAASHADER_H__ +#define __GL_FXAASHADER_H__ + +#include "gl_shaderprogram.h" + +class FFXAALumaShader +{ +public: + void Bind(); + + FBufferedUniform1i InputTexture; + +private: + FShaderProgram mShader; +}; + + +class FFXAAShader +{ +public: + enum Quality + { + None, + Low, + Medium, + High, + Extreme, + Count + }; + + void Bind(); + + FBufferedUniform1i InputTexture; + FBufferedUniform2f ReciprocalResolution; + +private: + FShaderProgram mShaders[Count]; +}; + +#endif // __GL_FXAASHADER_H__ diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 813d6b8f6..224764a87 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2633,6 +2633,7 @@ GLPREFMNU_MULTISAMPLE = "Multisample"; GLPREFMNU_TONEMAP = "Tonemap Mode"; GLPREFMNU_BLOOM = "Bloom effect"; GLPREFMNU_LENS = "Lens distortion effect"; +GLPREFMNU_FXAA = "FXAA Quality"; // Option Values OPTVAL_SMART = "Smart"; @@ -2709,4 +2710,8 @@ OPTVAL_QUADBUFFERED = "Quad-buffered"; OPTVAL_UNCHARTED2 = "Uncharted 2"; OPTVAL_HEJLDAWSON = "Hejl Dawson"; OPTVAL_REINHARD = "Reinhard"; -OPTVAL_PALETTE = "Palette"; \ No newline at end of file +OPTVAL_PALETTE = "Palette"; +OPTVAL_LOW = "Low"; +OPTVAL_MEDIUM = "Medium"; +OPTVAL_HIGH = "High"; +OPTVAL_EXTREME = "Extreme"; diff --git a/wadsrc/static/menudef.zz b/wadsrc/static/menudef.zz index 6f96ea286..7e798a039 100644 --- a/wadsrc/static/menudef.zz +++ b/wadsrc/static/menudef.zz @@ -42,6 +42,15 @@ OptionValue "TonemapModes" 5, "$OPTVAL_PALETTE" } +OptionValue "FXAAQuality" +{ + 0, "$OPTVAL_OFF" + 1, "$OPTVAL_LOW" + 2, "$OPTVAL_MEDIUM" + 3, "$OPTVAL_HIGH" + 4, "$OPTVAL_EXTREME" +} + OptionValue "TextureFormats" { 0, "$OPTVAL_RGBA8" @@ -228,4 +237,5 @@ OptionMenu "GLPrefOptions" Option "$GLPREFMNU_TONEMAP", gl_tonemap, "TonemapModes" Option "$GLPREFMNU_BLOOM", gl_bloom, "OnOff" Option "$GLPREFMNU_LENS", gl_lens, "OnOff" + Option "$GLPREFMNU_FXAA", gl_fxaa, "FXAAQuality" } diff --git a/wadsrc/static/shaders/glsl/fxaa.fp b/wadsrc/static/shaders/glsl/fxaa.fp new file mode 100644 index 000000000..7fcdf8c81 --- /dev/null +++ b/wadsrc/static/shaders/glsl/fxaa.fp @@ -0,0 +1,615 @@ +//---------------------------------------------------------------------------------- +// File: es3-kepler\FXAA/FXAA3_11.h +// SDK Version: v3.00 +// Email: gameworks@nvidia.com +// Site: http://developer.nvidia.com/ +// +// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of NVIDIA CORPORATION nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +//---------------------------------------------------------------------------------- + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D InputTexture; + +#ifdef FXAA_LUMA_PASS + +void main() +{ + vec3 tex = texture(InputTexture, TexCoord).rgb; + vec3 luma = vec3(0.299, 0.587, 0.114); + FragColor = vec4(tex, dot(tex, luma)); +} + +#else // FXAA itself + +//============================================================================ +// NVIDIA FXAA 3.11 by TIMOTHY LOTTES +//============================================================================ + +#define FXAA_DISCARD 1 + +#define FXAA_GREEN_AS_LUMA 0 + +#define FxaaBool bool +#define FxaaDiscard discard +#define FxaaFloat float +#define FxaaFloat2 vec2 +#define FxaaFloat3 vec3 +#define FxaaFloat4 vec4 +#define FxaaHalf float +#define FxaaHalf2 vec2 +#define FxaaHalf3 vec3 +#define FxaaHalf4 vec4 +#define FxaaInt2 ivec2 +#define FxaaSat(x) clamp(x, 0.0, 1.0) +#define FxaaTex sampler2D + +#define FxaaTexTop(t, p) textureLod(t, p, 0.0) +#define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o) + +#if (FXAA_GATHER4_ALPHA == 1) + #define FxaaTexAlpha4(t, p) textureGather(t, p, 3) + #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3) + #define FxaaTexGreen4(t, p) textureGather(t, p, 1) + #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1) +#endif + +#if (FXAA_GREEN_AS_LUMA == 0) + FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; } +#else + FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; } +#endif + +#if (FXAA_QUALITY__PRESET == 10) + #define FXAA_QUALITY__PS 3 + #define FXAA_QUALITY__P0 1.5 + #define FXAA_QUALITY__P1 3.0 + #define FXAA_QUALITY__P2 12.0 +#elif (FXAA_QUALITY__PRESET == 11) + #define FXAA_QUALITY__PS 4 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.5 + #define FXAA_QUALITY__P2 3.0 + #define FXAA_QUALITY__P3 12.0 +#elif (FXAA_QUALITY__PRESET == 12) + #define FXAA_QUALITY__PS 5 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.5 + #define FXAA_QUALITY__P2 2.0 + #define FXAA_QUALITY__P3 4.0 + #define FXAA_QUALITY__P4 12.0 +#elif (FXAA_QUALITY__PRESET == 13) + #define FXAA_QUALITY__PS 6 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.5 + #define FXAA_QUALITY__P2 2.0 + #define FXAA_QUALITY__P3 2.0 + #define FXAA_QUALITY__P4 4.0 + #define FXAA_QUALITY__P5 12.0 +#elif (FXAA_QUALITY__PRESET == 14) + #define FXAA_QUALITY__PS 7 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.5 + #define FXAA_QUALITY__P2 2.0 + #define FXAA_QUALITY__P3 2.0 + #define FXAA_QUALITY__P4 2.0 + #define FXAA_QUALITY__P5 4.0 + #define FXAA_QUALITY__P6 12.0 +#elif (FXAA_QUALITY__PRESET == 15) + #define FXAA_QUALITY__PS 8 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.5 + #define FXAA_QUALITY__P2 2.0 + #define FXAA_QUALITY__P3 2.0 + #define FXAA_QUALITY__P4 2.0 + #define FXAA_QUALITY__P5 2.0 + #define FXAA_QUALITY__P6 4.0 + #define FXAA_QUALITY__P7 12.0 +#elif (FXAA_QUALITY__PRESET == 20) + #define FXAA_QUALITY__PS 3 + #define FXAA_QUALITY__P0 1.5 + #define FXAA_QUALITY__P1 2.0 + #define FXAA_QUALITY__P2 8.0 +#elif (FXAA_QUALITY__PRESET == 21) + #define FXAA_QUALITY__PS 4 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.5 + #define FXAA_QUALITY__P2 2.0 + #define FXAA_QUALITY__P3 8.0 +#elif (FXAA_QUALITY__PRESET == 22) + #define FXAA_QUALITY__PS 5 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.5 + #define FXAA_QUALITY__P2 2.0 + #define FXAA_QUALITY__P3 2.0 + #define FXAA_QUALITY__P4 8.0 +#elif (FXAA_QUALITY__PRESET == 23) + #define FXAA_QUALITY__PS 6 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.5 + #define FXAA_QUALITY__P2 2.0 + #define FXAA_QUALITY__P3 2.0 + #define FXAA_QUALITY__P4 2.0 + #define FXAA_QUALITY__P5 8.0 +#elif (FXAA_QUALITY__PRESET == 24) + #define FXAA_QUALITY__PS 7 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.5 + #define FXAA_QUALITY__P2 2.0 + #define FXAA_QUALITY__P3 2.0 + #define FXAA_QUALITY__P4 2.0 + #define FXAA_QUALITY__P5 3.0 + #define FXAA_QUALITY__P6 8.0 +#elif (FXAA_QUALITY__PRESET == 25) + #define FXAA_QUALITY__PS 8 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.5 + #define FXAA_QUALITY__P2 2.0 + #define FXAA_QUALITY__P3 2.0 + #define FXAA_QUALITY__P4 2.0 + #define FXAA_QUALITY__P5 2.0 + #define FXAA_QUALITY__P6 4.0 + #define FXAA_QUALITY__P7 8.0 +#elif (FXAA_QUALITY__PRESET == 26) + #define FXAA_QUALITY__PS 9 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.5 + #define FXAA_QUALITY__P2 2.0 + #define FXAA_QUALITY__P3 2.0 + #define FXAA_QUALITY__P4 2.0 + #define FXAA_QUALITY__P5 2.0 + #define FXAA_QUALITY__P6 2.0 + #define FXAA_QUALITY__P7 4.0 + #define FXAA_QUALITY__P8 8.0 +#elif (FXAA_QUALITY__PRESET == 27) + #define FXAA_QUALITY__PS 10 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.5 + #define FXAA_QUALITY__P2 2.0 + #define FXAA_QUALITY__P3 2.0 + #define FXAA_QUALITY__P4 2.0 + #define FXAA_QUALITY__P5 2.0 + #define FXAA_QUALITY__P6 2.0 + #define FXAA_QUALITY__P7 2.0 + #define FXAA_QUALITY__P8 4.0 + #define FXAA_QUALITY__P9 8.0 +#elif (FXAA_QUALITY__PRESET == 28) + #define FXAA_QUALITY__PS 11 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.5 + #define FXAA_QUALITY__P2 2.0 + #define FXAA_QUALITY__P3 2.0 + #define FXAA_QUALITY__P4 2.0 + #define FXAA_QUALITY__P5 2.0 + #define FXAA_QUALITY__P6 2.0 + #define FXAA_QUALITY__P7 2.0 + #define FXAA_QUALITY__P8 2.0 + #define FXAA_QUALITY__P9 4.0 + #define FXAA_QUALITY__P10 8.0 +#elif (FXAA_QUALITY__PRESET == 29) + #define FXAA_QUALITY__PS 12 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.5 + #define FXAA_QUALITY__P2 2.0 + #define FXAA_QUALITY__P3 2.0 + #define FXAA_QUALITY__P4 2.0 + #define FXAA_QUALITY__P5 2.0 + #define FXAA_QUALITY__P6 2.0 + #define FXAA_QUALITY__P7 2.0 + #define FXAA_QUALITY__P8 2.0 + #define FXAA_QUALITY__P9 2.0 + #define FXAA_QUALITY__P10 4.0 + #define FXAA_QUALITY__P11 8.0 +#elif (FXAA_QUALITY__PRESET == 39) + #define FXAA_QUALITY__PS 12 + #define FXAA_QUALITY__P0 1.0 + #define FXAA_QUALITY__P1 1.0 + #define FXAA_QUALITY__P2 1.0 + #define FXAA_QUALITY__P3 1.0 + #define FXAA_QUALITY__P4 1.0 + #define FXAA_QUALITY__P5 1.5 + #define FXAA_QUALITY__P6 2.0 + #define FXAA_QUALITY__P7 2.0 + #define FXAA_QUALITY__P8 2.0 + #define FXAA_QUALITY__P9 2.0 + #define FXAA_QUALITY__P10 4.0 + #define FXAA_QUALITY__P11 8.0 +#endif + +FxaaFloat4 FxaaPixelShader(FxaaFloat2 pos, FxaaTex tex, FxaaFloat2 fxaaQualityRcpFrame, + FxaaFloat fxaaQualitySubpix, FxaaFloat fxaaQualityEdgeThreshold, FxaaFloat fxaaQualityEdgeThresholdMin) +{ + FxaaFloat2 posM; + posM.x = pos.x; + posM.y = pos.y; + #if (FXAA_GATHER4_ALPHA == 1) + #if (FXAA_DISCARD == 0) + FxaaFloat4 rgbyM = FxaaTexTop(tex, posM); + #if (FXAA_GREEN_AS_LUMA == 0) + #define lumaM rgbyM.w + #else + #define lumaM rgbyM.y + #endif + #endif + #if (FXAA_GREEN_AS_LUMA == 0) + FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM); + FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1)); + #else + FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM); + FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1)); + #endif + #if (FXAA_DISCARD == 1) + #define lumaM luma4A.w + #endif + #define lumaE luma4A.z + #define lumaS luma4A.x + #define lumaSE luma4A.y + #define lumaNW luma4B.w + #define lumaN luma4B.z + #define lumaW luma4B.x + #else + FxaaFloat4 rgbyM = FxaaTexTop(tex, posM); + #if (FXAA_GREEN_AS_LUMA == 0) + #define lumaM rgbyM.w + #else + #define lumaM rgbyM.y + #endif + FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy)); + FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy)); + FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy)); + FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy)); + #endif +/*--------------------------------------------------------------------------*/ + FxaaFloat maxSM = max(lumaS, lumaM); + FxaaFloat minSM = min(lumaS, lumaM); + FxaaFloat maxESM = max(lumaE, maxSM); + FxaaFloat minESM = min(lumaE, minSM); + FxaaFloat maxWN = max(lumaN, lumaW); + FxaaFloat minWN = min(lumaN, lumaW); + FxaaFloat rangeMax = max(maxWN, maxESM); + FxaaFloat rangeMin = min(minWN, minESM); + FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold; + FxaaFloat range = rangeMax - rangeMin; + FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled); + FxaaBool earlyExit = range < rangeMaxClamped; +/*--------------------------------------------------------------------------*/ + if(earlyExit) + #if (FXAA_DISCARD == 1) + FxaaDiscard; + #else + return rgbyM; + #endif +/*--------------------------------------------------------------------------*/ + #if (FXAA_GATHER4_ALPHA == 0) + FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy)); + FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy)); + FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy)); + FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy)); + #else + FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy)); + FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy)); + #endif +/*--------------------------------------------------------------------------*/ + FxaaFloat lumaNS = lumaN + lumaS; + FxaaFloat lumaWE = lumaW + lumaE; + FxaaFloat subpixRcpRange = 1.0/range; + FxaaFloat subpixNSWE = lumaNS + lumaWE; + FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS; + FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE; +/*--------------------------------------------------------------------------*/ + FxaaFloat lumaNESE = lumaNE + lumaSE; + FxaaFloat lumaNWNE = lumaNW + lumaNE; + FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE; + FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE; +/*--------------------------------------------------------------------------*/ + FxaaFloat lumaNWSW = lumaNW + lumaSW; + FxaaFloat lumaSWSE = lumaSW + lumaSE; + FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2); + FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2); + FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW; + FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE; + FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4; + FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4; +/*--------------------------------------------------------------------------*/ + FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE; + FxaaFloat lengthSign = fxaaQualityRcpFrame.x; + FxaaBool horzSpan = edgeHorz >= edgeVert; + FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE; +/*--------------------------------------------------------------------------*/ + if(!horzSpan) lumaN = lumaW; + if(!horzSpan) lumaS = lumaE; + if(horzSpan) lengthSign = fxaaQualityRcpFrame.y; + FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM; +/*--------------------------------------------------------------------------*/ + FxaaFloat gradientN = lumaN - lumaM; + FxaaFloat gradientS = lumaS - lumaM; + FxaaFloat lumaNN = lumaN + lumaM; + FxaaFloat lumaSS = lumaS + lumaM; + FxaaBool pairN = abs(gradientN) >= abs(gradientS); + FxaaFloat gradient = max(abs(gradientN), abs(gradientS)); + if(pairN) lengthSign = -lengthSign; + FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange); +/*--------------------------------------------------------------------------*/ + FxaaFloat2 posB; + posB.x = posM.x; + posB.y = posM.y; + FxaaFloat2 offNP; + offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x; + offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y; + if(!horzSpan) posB.x += lengthSign * 0.5; + if( horzSpan) posB.y += lengthSign * 0.5; +/*--------------------------------------------------------------------------*/ + FxaaFloat2 posN; + posN.x = posB.x - offNP.x * FXAA_QUALITY__P0; + posN.y = posB.y - offNP.y * FXAA_QUALITY__P0; + FxaaFloat2 posP; + posP.x = posB.x + offNP.x * FXAA_QUALITY__P0; + posP.y = posB.y + offNP.y * FXAA_QUALITY__P0; + FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0; + FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN)); + FxaaFloat subpixE = subpixC * subpixC; + FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP)); +/*--------------------------------------------------------------------------*/ + if(!pairN) lumaNN = lumaSS; + FxaaFloat gradientScaled = gradient * 1.0/4.0; + FxaaFloat lumaMM = lumaM - lumaNN * 0.5; + FxaaFloat subpixF = subpixD * subpixE; + FxaaBool lumaMLTZero = lumaMM < 0.0; +/*--------------------------------------------------------------------------*/ + lumaEndN -= lumaNN * 0.5; + lumaEndP -= lumaNN * 0.5; + FxaaBool doneN = abs(lumaEndN) >= gradientScaled; + FxaaBool doneP = abs(lumaEndP) >= gradientScaled; + if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P1; + if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P1; + FxaaBool doneNP = (!doneN) || (!doneP); + if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P1; + if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P1; +/*--------------------------------------------------------------------------*/ + if(doneNP) { + if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy)); + if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy)); + if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5; + if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5; + doneN = abs(lumaEndN) >= gradientScaled; + doneP = abs(lumaEndP) >= gradientScaled; + if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P2; + if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P2; + doneNP = (!doneN) || (!doneP); + if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P2; + if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P2; +/*--------------------------------------------------------------------------*/ + #if (FXAA_QUALITY__PS > 3) + if(doneNP) { + if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy)); + if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy)); + if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5; + if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5; + doneN = abs(lumaEndN) >= gradientScaled; + doneP = abs(lumaEndP) >= gradientScaled; + if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P3; + if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P3; + doneNP = (!doneN) || (!doneP); + if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P3; + if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P3; +/*--------------------------------------------------------------------------*/ + #if (FXAA_QUALITY__PS > 4) + if(doneNP) { + if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy)); + if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy)); + if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5; + if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5; + doneN = abs(lumaEndN) >= gradientScaled; + doneP = abs(lumaEndP) >= gradientScaled; + if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P4; + if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P4; + doneNP = (!doneN) || (!doneP); + if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P4; + if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P4; +/*--------------------------------------------------------------------------*/ + #if (FXAA_QUALITY__PS > 5) + if(doneNP) { + if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy)); + if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy)); + if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5; + if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5; + doneN = abs(lumaEndN) >= gradientScaled; + doneP = abs(lumaEndP) >= gradientScaled; + if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P5; + if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P5; + doneNP = (!doneN) || (!doneP); + if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P5; + if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P5; +/*--------------------------------------------------------------------------*/ + #if (FXAA_QUALITY__PS > 6) + if(doneNP) { + if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy)); + if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy)); + if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5; + if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5; + doneN = abs(lumaEndN) >= gradientScaled; + doneP = abs(lumaEndP) >= gradientScaled; + if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P6; + if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P6; + doneNP = (!doneN) || (!doneP); + if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P6; + if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P6; +/*--------------------------------------------------------------------------*/ + #if (FXAA_QUALITY__PS > 7) + if(doneNP) { + if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy)); + if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy)); + if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5; + if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5; + doneN = abs(lumaEndN) >= gradientScaled; + doneP = abs(lumaEndP) >= gradientScaled; + if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P7; + if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P7; + doneNP = (!doneN) || (!doneP); + if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P7; + if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P7; +/*--------------------------------------------------------------------------*/ + #if (FXAA_QUALITY__PS > 8) + if(doneNP) { + if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy)); + if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy)); + if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5; + if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5; + doneN = abs(lumaEndN) >= gradientScaled; + doneP = abs(lumaEndP) >= gradientScaled; + if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P8; + if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P8; + doneNP = (!doneN) || (!doneP); + if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P8; + if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P8; +/*--------------------------------------------------------------------------*/ + #if (FXAA_QUALITY__PS > 9) + if(doneNP) { + if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy)); + if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy)); + if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5; + if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5; + doneN = abs(lumaEndN) >= gradientScaled; + doneP = abs(lumaEndP) >= gradientScaled; + if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P9; + if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P9; + doneNP = (!doneN) || (!doneP); + if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P9; + if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P9; +/*--------------------------------------------------------------------------*/ + #if (FXAA_QUALITY__PS > 10) + if(doneNP) { + if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy)); + if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy)); + if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5; + if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5; + doneN = abs(lumaEndN) >= gradientScaled; + doneP = abs(lumaEndP) >= gradientScaled; + if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P10; + if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P10; + doneNP = (!doneN) || (!doneP); + if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P10; + if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P10; +/*--------------------------------------------------------------------------*/ + #if (FXAA_QUALITY__PS > 11) + if(doneNP) { + if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy)); + if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy)); + if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5; + if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5; + doneN = abs(lumaEndN) >= gradientScaled; + doneP = abs(lumaEndP) >= gradientScaled; + if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P11; + if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P11; + doneNP = (!doneN) || (!doneP); + if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P11; + if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P11; +/*--------------------------------------------------------------------------*/ + #if (FXAA_QUALITY__PS > 12) + if(doneNP) { + if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy)); + if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy)); + if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5; + if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5; + doneN = abs(lumaEndN) >= gradientScaled; + doneP = abs(lumaEndP) >= gradientScaled; + if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P12; + if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P12; + doneNP = (!doneN) || (!doneP); + if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P12; + if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P12; +/*--------------------------------------------------------------------------*/ + } + #endif +/*--------------------------------------------------------------------------*/ + } + #endif +/*--------------------------------------------------------------------------*/ + } + #endif +/*--------------------------------------------------------------------------*/ + } + #endif +/*--------------------------------------------------------------------------*/ + } + #endif +/*--------------------------------------------------------------------------*/ + } + #endif +/*--------------------------------------------------------------------------*/ + } + #endif +/*--------------------------------------------------------------------------*/ + } + #endif +/*--------------------------------------------------------------------------*/ + } + #endif +/*--------------------------------------------------------------------------*/ + } + #endif +/*--------------------------------------------------------------------------*/ + } +/*--------------------------------------------------------------------------*/ + FxaaFloat dstN = posM.x - posN.x; + FxaaFloat dstP = posP.x - posM.x; + if(!horzSpan) dstN = posM.y - posN.y; + if(!horzSpan) dstP = posP.y - posM.y; +/*--------------------------------------------------------------------------*/ + FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero; + FxaaFloat spanLength = (dstP + dstN); + FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero; + FxaaFloat spanLengthRcp = 1.0/spanLength; +/*--------------------------------------------------------------------------*/ + FxaaBool directionN = dstN < dstP; + FxaaFloat dst = min(dstN, dstP); + FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP; + FxaaFloat subpixG = subpixF * subpixF; + FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5; + FxaaFloat subpixH = subpixG * fxaaQualitySubpix; +/*--------------------------------------------------------------------------*/ + FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0; + FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH); + if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign; + if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign; + #if (FXAA_DISCARD == 1) + return FxaaTexTop(tex, posM); + #else + return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM); + #endif +} + +uniform vec2 ReciprocalResolution; + +void main() +{ + FragColor = FxaaPixelShader(TexCoord, InputTexture, ReciprocalResolution, 0.75f, 0.166f, 0.0833f); +} + +#endif // FXAA_LUMA_PASS From 7c4780638201122f6ad8024c5edcce26b6759767 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 3 Oct 2016 09:18:47 +0200 Subject: [PATCH 1023/1509] Fix aspect ratio bug in LensDistortScene --- src/gl/renderer/gl_postprocess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 6c18edd1e..ff65fee6d 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -569,7 +569,7 @@ void FGLRenderer::LensDistortScene() 0.0f }; - float aspect = mSceneViewport.width / mSceneViewport.height; + float aspect = mSceneViewport.width / (float)mSceneViewport.height; // Scale factor to keep sampling within the input texture float r2 = aspect * aspect * 0.25 + 0.25f; From 4eb5f10b02cc2b1844f0a6894f3a7005049d767a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 3 Oct 2016 16:09:32 +0200 Subject: [PATCH 1024/1509] - use normals to have proper light attenuation. So far only implemented for walls and flats. Models are planned but need some thinking about how to efficiently collect all required lights for an object. --- src/gl/data/gl_matrix.cpp | 2 +- src/gl/data/gl_vertexbuffer.cpp | 2 ++ src/gl/data/gl_vertexbuffer.h | 9 +++++- src/gl/models/gl_models.cpp | 2 ++ src/gl/models/gl_voxels.cpp | 2 ++ src/gl/renderer/gl_renderstate.cpp | 5 ++++ src/gl/renderer/gl_renderstate.h | 13 +++++++++ src/gl/scene/gl_flats.cpp | 10 +++++-- src/gl/scene/gl_portal.cpp | 4 +-- src/gl/scene/gl_skydome.cpp | 1 + src/gl/scene/gl_sprite.cpp | 1 + src/gl/scene/gl_wall.h | 9 ++++++ src/gl/scene/gl_walls.cpp | 4 +-- src/gl/scene/gl_walls_draw.cpp | 8 ++--- src/gl/shaders/gl_shader.cpp | 22 +++++++++----- src/gl/shaders/gl_shader.h | 4 ++- wadsrc/static/shaders/glsl/main.fp | 39 +++++++++++++++++++++++-- wadsrc/static/shaders/glsl/main.vp | 7 +++++ wadsrc/static/shaders/glsl/shaderdefs.i | 2 ++ 19 files changed, 122 insertions(+), 24 deletions(-) diff --git a/src/gl/data/gl_matrix.cpp b/src/gl/data/gl_matrix.cpp index d8017ad40..115882857 100644 --- a/src/gl/data/gl_matrix.cpp +++ b/src/gl/data/gl_matrix.cpp @@ -442,7 +442,7 @@ VSMatrix::computeNormalMatrix(const FLOATTYPE *aMatrix) mMat3x3[1] * (mMat3x3[5] * mMat3x3[6] - mMat3x3[8] * mMat3x3[3]) + mMat3x3[2] * (mMat3x3[3] * mMat3x3[7] - mMat3x3[4] * mMat3x3[6]); - invDet = 1.0f/det; + invDet = 1.0/det; mMatrix[0] = (mMat3x3[4] * mMat3x3[8] - mMat3x3[5] * mMat3x3[7]) * invDet; mMatrix[1] = (mMat3x3[5] * mMat3x3[6] - mMat3x3[8] * mMat3x3[3]) * invDet; diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 4e76b51cb..d14599eb8 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -71,6 +71,7 @@ void FSimpleVertexBuffer::BindVBO() glEnableVertexAttribArray(VATTR_TEXCOORD); glEnableVertexAttribArray(VATTR_COLOR); glDisableVertexAttribArray(VATTR_VERTEX2); + glDisableVertexAttribArray(VATTR_NORMAL); } else { @@ -236,6 +237,7 @@ void FFlatVertexBuffer::BindVBO() glEnableVertexAttribArray(VATTR_TEXCOORD); glDisableVertexAttribArray(VATTR_COLOR); glDisableVertexAttribArray(VATTR_VERTEX2); + glDisableVertexAttribArray(VATTR_NORMAL); } else { diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 596de35d9..f777118fd 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -271,6 +271,7 @@ struct FModelVertex { float x, y, z; // world position float u, v; // texture coordinates + unsigned packedNormal; // normal vector as GL_INT_2_10_10_10_REV. void Set(float xx, float yy, float zz, float uu, float vv) { @@ -283,7 +284,13 @@ struct FModelVertex void SetNormal(float nx, float ny, float nz) { - // GZDoom currently doesn't use normals. This function is so that the high level code can pretend it does. + /* + int inx = int(nx * 512); + int iny = int(ny * 512); + int inz = int(nz * 512); + packedNormal = 0x40000000 | ((inx & 1023) << 20) | ((iny & 1023) << 10) | (inz & 1023); + */ + packedNormal = 0; // Per-pixel lighting for models isn't implemented yet so leave this at 0 for now. } }; diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 91bd9131e..f3dfbd569 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -119,6 +119,7 @@ void FModelVertexBuffer::BindVBO() glEnableVertexAttribArray(VATTR_VERTEX); glEnableVertexAttribArray(VATTR_TEXCOORD); glEnableVertexAttribArray(VATTR_VERTEX2); + glEnableVertexAttribArray(VATTR_NORMAL); glDisableVertexAttribArray(VATTR_COLOR); } else @@ -245,6 +246,7 @@ unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int fr glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].x); glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].u); glVertexAttribPointer(VATTR_VERTEX2, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame2].x); + glVertexAttribPointer(VATTR_NORMAL, 4, GL_UNSIGNED_INT_2_10_10_10_REV, false, sizeof(FModelVertex), &VMO[frame2].packedNormal); } else { diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 6213eb006..288b1a9db 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -248,6 +248,7 @@ void FVoxelModel::AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3 FModelVertex vert; unsigned int indx[4]; + vert.packedNormal = 0; // currently this is not being used for voxels. vert.u = (((col & 15) * 255 / 16) + 7) / 255.f; vert.v = (((col / 16) * 255 / 16) + 7) / 255.f; @@ -271,6 +272,7 @@ void FVoxelModel::AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3 vert.y = -z3 + PivotZ; indx[3] = AddVertex(vert, check); + mIndices.Push(indx[0]); mIndices.Push(indx[1]); mIndices.Push(indx[3]); diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 967296cb8..a8c9c5da2 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -141,6 +141,7 @@ bool FRenderState::ApplyShader() } glVertexAttrib4fv(VATTR_COLOR, mColor.vec); + glVertexAttrib4fv(VATTR_NORMAL, mNormal.vec); activeShader->muDesaturation.Set(mDesaturation / 255.f); activeShader->muFogEnabled.Set(fogset); @@ -269,12 +270,16 @@ bool FRenderState::ApplyShader() if (mModelMatrixEnabled) { mModelMatrix.matrixToGL(activeShader->modelmatrix_index); + VSMatrix norm; + norm.computeNormalMatrix(mModelMatrix); + mNormalModelMatrix.matrixToGL(activeShader->normalmodelmatrix_index); activeShader->currentModelMatrixState = true; } else if (activeShader->currentModelMatrixState) { activeShader->currentModelMatrixState = false; identityMatrix.matrixToGL(activeShader->modelmatrix_index); + identityMatrix.matrixToGL(activeShader->normalmodelmatrix_index); } return true; } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 1c0a20348..6a1856910 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -90,6 +90,7 @@ class FRenderState float mShaderTimer; FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; + FStateVec4 mNormal; FStateVec4 mColor; FStateVec4 mCameraPos; FStateVec4 mGlowTop, mGlowBottom; @@ -119,6 +120,8 @@ public: VSMatrix mViewMatrix; VSMatrix mModelMatrix; VSMatrix mTextureMatrix; + VSMatrix mNormalViewMatrix; + VSMatrix mNormalModelMatrix; FRenderState() { @@ -180,6 +183,16 @@ public: void SetClipHeight(float height, float direction); + void SetNormal(FVector3 norm) + { + mNormal.Set(norm.X, norm.Y, norm.Z, 0.f); + } + + void SetNormal(float x, float y, float z) + { + mNormal.Set(x, y, z, 0.f); + } + void SetColor(float r, float g, float b, float a = 1.f, int desat = 0) { mColor.Set(r, g, b, a); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 90f3be66f..394ca1626 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -374,6 +374,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG } #endif + gl_RenderState.SetNormal(plane.plane.Normal().X, plane.plane.Normal().Z, plane.plane.Normal().Y); switch (pass) { @@ -502,6 +503,11 @@ inline void GLFlat::PutFlat(bool fog) void GLFlat::Process(sector_t * model, int whichplane, bool fog) { plane.GetFromSector(model, whichplane); + if (whichplane != int(ceiling)) + { + // Flip the normal if the source plane has a different orientation than what we are about to render. + plane.plane.FlipVert(); + } if (!fog) { @@ -641,7 +647,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) Colormap.CopyFrom3DLight(light); } renderstyle = STYLE_Translucent; - Process(frontsector, false, false); + Process(frontsector, sector_t::floor, false); } } @@ -700,7 +706,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) Colormap.CopyFrom3DLight(light); } renderstyle = STYLE_Translucent; - Process(frontsector, true, false); + Process(frontsector, sector_t::ceiling, false); } } diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 4a7fa9d7a..50693d75c 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -1217,7 +1217,7 @@ void GLEEHorizonPortal::DrawContents() if (sector->GetTexture(sector_t::ceiling) != skyflatnum) { GLHorizonInfo horz; - horz.plane.GetFromSector(sector, true); + horz.plane.GetFromSector(sector, sector_t::ceiling); horz.lightlevel = gl_ClampLight(sector->GetCeilingLight()); horz.colormap = sector->ColorMap; if (portal->mType == PORTS_PLANE) @@ -1230,7 +1230,7 @@ void GLEEHorizonPortal::DrawContents() if (sector->GetTexture(sector_t::floor) != skyflatnum) { GLHorizonInfo horz; - horz.plane.GetFromSector(sector, false); + horz.plane.GetFromSector(sector, sector_t::floor); horz.lightlevel = gl_ClampLight(sector->GetFloorLight()); horz.colormap = sector->ColorMap; if (portal->mType == PORTS_PLANE) diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 1653d2bb8..015b42016 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -114,6 +114,7 @@ void FSkyVertexBuffer::BindVBO() glEnableVertexAttribArray(VATTR_TEXCOORD); glEnableVertexAttribArray(VATTR_COLOR); glDisableVertexAttribArray(VATTR_VERTEX2); + glDisableVertexAttribArray(VATTR_NORMAL); } else { diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 19753f742..ab88f2f9c 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -406,6 +406,7 @@ void GLSprite::Draw(int pass) gl_RenderState.Apply(); FVector3 v[4]; + gl_RenderState.SetNormal(0, 0, 0); CalculateVertices(v); FQuadDrawer qd; diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 32dc6ee5b..143029ba7 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -60,6 +60,15 @@ struct GLSeg float x1,x2; float y1,y2; float fracleft, fracright; // fractional offset of the 2 vertices on the linedef + + FVector3 Normal() const + { + // we do not use the vector math inlines here because they are not optimized for speed but accuracy in the playsim + float x = y2 - y1; + float y = x1 - x2; + float length = sqrt(x*x + y*y); + return FVector3(x / length, 0, y / length); + } }; struct texcoord diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 3a7baec33..db16a941a 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -470,7 +470,7 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) } else { - hi.plane.GetFromSector(fs, true); + hi.plane.GetFromSector(fs, sector_t::ceiling); hi.lightlevel = gl_ClampLight(fs->GetCeilingLight()); hi.colormap = fs->ColorMap; @@ -498,7 +498,7 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) } else { - hi.plane.GetFromSector(fs, false); + hi.plane.GetFromSector(fs, sector_t::floor); hi.lightlevel = gl_ClampLight(fs->GetFloorLight()); hi.colormap = fs->ColorMap; diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index a7884b51a..dbc43fd22 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -254,14 +254,13 @@ void GLWall::RenderMirrorSurface() if (GLRenderer->mirrortexture == NULL) return; // For the sphere map effect we need a normal of the mirror surface, - Vector v(glseg.y2-glseg.y1, 0 ,-glseg.x2+glseg.x1); - v.Normalize(); + FVector3 v = glseg.Normal(); if (!gl.legacyMode) { // we use texture coordinates and texture matrix to pass the normal stuff to the shader so that the default vertex buffer format can be used as is. - tcs[LOLFT].u = tcs[LORGT].u = tcs[UPLFT].u = tcs[UPRGT].u = v.X(); - tcs[LOLFT].v = tcs[LORGT].v = tcs[UPLFT].v = tcs[UPRGT].v = v.Z(); + tcs[LOLFT].u = tcs[LORGT].u = tcs[UPLFT].u = tcs[UPRGT].u = v.X; + tcs[LOLFT].v = tcs[LORGT].v = tcs[UPLFT].v = tcs[UPRGT].v = v.Z; gl_RenderState.EnableTextureMatrix(true); gl_RenderState.mTextureMatrix.computeNormalMatrix(gl_RenderState.mViewMatrix); @@ -414,6 +413,7 @@ void GLWall::RenderTranslucentWall() //========================================================================== void GLWall::Draw(int pass) { + gl_RenderState.SetNormal(glseg.Normal()); switch (pass) { case GLPASS_LIGHTSONLY: diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index d4e05dfa8..8f78e22e4 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -179,6 +179,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * glBindAttribLocation(hShader, VATTR_TEXCOORD, "aTexCoord"); glBindAttribLocation(hShader, VATTR_COLOR, "aColor"); glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2"); + glBindAttribLocation(hShader, VATTR_NORMAL, "aNormal"); glLinkProgram(hShader); @@ -241,6 +242,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * texturematrix_index = glGetUniformLocation(hShader, "TextureMatrix"); vertexmatrix_index = glGetUniformLocation(hShader, "uQuadVertices"); texcoordmatrix_index = glGetUniformLocation(hShader, "uQuadTexCoords"); + normalviewmatrix_index = glGetUniformLocation(hShader, "NormalViewMatrix"); + normalmodelmatrix_index = glGetUniformLocation(hShader, "NormalModelMatrix"); quadmode_index = glGetUniformLocation(hShader, "uQuadMode"); if (!gl.legacyMode && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) @@ -328,14 +331,14 @@ FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath // //========================================================================== -void FShader::ApplyMatrices(VSMatrix *proj, VSMatrix *view) +void FShader::ApplyMatrices(VSMatrix *proj, VSMatrix *view, VSMatrix *norm) { Bind(); glUniformMatrix4fv(projectionmatrix_index, 1, false, proj->get()); glUniformMatrix4fv(viewmatrix_index, 1, false, view->get()); + glUniformMatrix4fv(normalviewmatrix_index, 1, false, norm->get()); } - //========================================================================== // // @@ -556,23 +559,26 @@ void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view) } else { + VSMatrix norm; + norm.computeNormalMatrix(*view); + for (int i = 0; i < 4; i++) { - mTextureEffects[i]->ApplyMatrices(proj, view); - mTextureEffectsNAT[i]->ApplyMatrices(proj, view); + mTextureEffects[i]->ApplyMatrices(proj, view, &norm); + mTextureEffectsNAT[i]->ApplyMatrices(proj, view, &norm); } - mTextureEffects[4]->ApplyMatrices(proj, view); + mTextureEffects[4]->ApplyMatrices(proj, view, &norm); if (gl_fuzztype != 0) { - mTextureEffects[4 + gl_fuzztype]->ApplyMatrices(proj, view); + mTextureEffects[4 + gl_fuzztype]->ApplyMatrices(proj, view, &norm); } for (unsigned i = 12; i < mTextureEffects.Size(); i++) { - mTextureEffects[i]->ApplyMatrices(proj, view); + mTextureEffects[i]->ApplyMatrices(proj, view, &norm); } for (int i = 0; i < MAX_EFFECTS; i++) { - mEffectShaders[i]->ApplyMatrices(proj, view); + mEffectShaders[i]->ApplyMatrices(proj, view, &norm); } if (mActiveShader != NULL) mActiveShader->Bind(); } diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 343942321..679ae1172 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -285,7 +285,9 @@ class FShader int lights_index; int projectionmatrix_index; int viewmatrix_index; + int normalviewmatrix_index; int modelmatrix_index; + int normalmodelmatrix_index; int texturematrix_index; public: int vertexmatrix_index; @@ -318,7 +320,7 @@ public: bool Bind(); unsigned int GetHandle() const { return hShader; } - void ApplyMatrices(VSMatrix *proj, VSMatrix *view); + void ApplyMatrices(VSMatrix *proj, VSMatrix *view, VSMatrix *norm); }; diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 95ac874b7..fb1983fc7 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -1,6 +1,8 @@ in vec4 pixelpos; in vec2 glowdist; +in vec4 vWorldNormal; +in vec4 vEyeNormal; in vec4 vTexCoord; in vec4 vColor; @@ -121,6 +123,37 @@ float R_DoomLightingEquation(float light) return lightscale; } +//=========================================================================== +// +// Standard lambertian diffuse light calculation +// +//=========================================================================== + +float diffuseContribution(vec3 lightDirection, vec3 normal) +{ + return max(dot(normal, lightDirection), 0.0f); +} + +//=========================================================================== +// +// Calculates the brightness of a dynamic point light +// Todo: Find a better way to define which lighting model to use. +// (Specular mode has been removed for now.) +// +//=========================================================================== + +float pointLightAttenuation(vec4 lightpos) +{ + float attenuation = max(lightpos.w - distance(pixelpos.xyz, lightpos.xyz),0.0) / lightpos.w; + #if 0 + return attenuation; + #else + vec3 lightDirection = normalize(lightpos.xyz - pixelpos.xyz); + float diffuseAmount = diffuseContribution(lightDirection, normalize(vWorldNormal.xyz)); + return attenuation * diffuseAmount; + #endif +} + //=========================================================================== // // Calculate light @@ -196,7 +229,7 @@ vec4 getLightColor(float fogdist, float fogfactor) vec4 lightpos = lights[i]; vec4 lightcolor = lights[i+1]; - lightcolor.rgb *= max(lightpos.w - distance(pixelpos.xyz, lightpos.xyz),0.0) / lightpos.w; + lightcolor.rgb *= pointLightAttenuation(lightpos); dynlight.rgb += lightcolor.rgb; } // @@ -207,7 +240,7 @@ vec4 getLightColor(float fogdist, float fogfactor) vec4 lightpos = lights[i]; vec4 lightcolor = lights[i+1]; - lightcolor.rgb *= max(lightpos.w - distance(pixelpos.xyz, lightpos.xyz),0.0) / lightpos.w; + lightcolor.rgb *= pointLightAttenuation(lightpos); dynlight.rgb -= lightcolor.rgb; } } @@ -289,7 +322,7 @@ void main() vec4 lightpos = lights[i]; vec4 lightcolor = lights[i+1]; - lightcolor.rgb *= max(lightpos.w - distance(pixelpos.xyz, lightpos.xyz),0.0) / lightpos.w; + lightcolor.rgb *= pointLightAttenuation(lightpos); addlight.rgb += lightcolor.rgb; } frag.rgb = clamp(frag.rgb + desaturate(addlight).rgb, 0.0, 1.0); diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index a2c1bac5b..1de8854c0 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -4,8 +4,12 @@ in vec2 aTexCoord; in vec4 aColor; #ifndef SIMPLE // we do not need these for simple shaders in vec4 aVertex2; +in vec4 aNormal; out vec4 pixelpos; out vec2 glowdist; + +out vec4 vWorldNormal; +out vec4 vEyeNormal; #endif out vec4 vTexCoord; @@ -54,6 +58,9 @@ void main() gl_ClipDistance[3] = -((uSplitTopPlane.w + uSplitTopPlane.x * worldcoord.x + uSplitTopPlane.y * worldcoord.z) * uSplitTopPlane.z) - worldcoord.y; gl_ClipDistance[4] = worldcoord.y + ((uSplitBottomPlane.w + uSplitBottomPlane.x * worldcoord.x + uSplitBottomPlane.y * worldcoord.z) * uSplitBottomPlane.z); } + + vWorldNormal = NormalModelMatrix * aNormal; + vEyeNormal = NormalViewMatrix * vWorldNormal; #endif #ifdef SPHEREMAP diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 3701694bc..8c5697a66 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -56,5 +56,7 @@ uniform int uQuadMode; uniform mat4 ProjectionMatrix; uniform mat4 ViewMatrix; uniform mat4 ModelMatrix; +uniform mat4 NormalViewMatrix; +uniform mat4 NormalModelMatrix; uniform mat4 TextureMatrix; From 7ab7fc9a57f8d329f53e9643586eb1ed958afb51 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 3 Oct 2016 16:21:50 +0200 Subject: [PATCH 1025/1509] - seems I missed this part... --- src/gl/dynlights/a_dynlight.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 20d0d6078..0e52eedd8 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -391,6 +391,16 @@ void ADynamicLight::UpdateLocation() Prev = target->Pos(); subsector = R_PointInSubsector(Prev); Sector = subsector->sector; + + // Some z-coordinate fudging to prevent the light from getting too close to the floor or ceiling planes. With proper attenuation this would render them invisible. + // A distance of 5 is needed so that the light's effect doesn't become too small. + if (Z() < target->floorz + 5.) SetZ(target->floorz + 5.); + else if (Z() > target->ceilingz - 5.) SetZ(target->ceilingz - 5.); + } + else + { + if (Z() < floorz + 5.) SetZ(floorz + 5.); + else if (Z() > ceilingz - 5.) SetZ(ceilingz - 5.); } From 5d99e7dafe28fbc92978c5b30ebcfed8013a4ff6 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 3 Oct 2016 22:13:33 +0300 Subject: [PATCH 1026/1509] Fixed compilation on platforms other than Windows --- src/g_shared/sbarinfo_commands.cpp | 4 ++-- src/gl/stereo3d/gl_interleaved3d.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index 13c98d833..d105ab818 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -1187,12 +1187,12 @@ class CommandDrawNumber : public CommandDrawString if (!(cvartype == CVAR_Bool || cvartype == CVAR_Int)) { - sc.ScriptMessage("CVar '%s' is not an int or bool", cvarName); + sc.ScriptMessage("CVar '%s' is not an int or bool", cvarName.GetChars()); } } else { - sc.ScriptMessage("CVar '%s' does not exist", cvarName); + sc.ScriptMessage("CVar '%s' does not exist", cvarName.GetChars()); } if (parenthesized) sc.MustGetToken(')'); diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp index 329dec953..036a84b0b 100644 --- a/src/gl/stereo3d/gl_interleaved3d.cpp +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -104,10 +104,13 @@ void RowInterleaved3D::Present() const // Compute absolute offset from top of screen to top of current display window // because we need screen-relative, not window-relative, scan line parity int windowVOffset = 0; + +#ifdef _WIN32 if (! fullscreen) { I_SaveWindowedPos(); // update win_y CVAR windowVOffset = win_y; } +#endif // _WIN32 GLRenderer->mPresent3dRowShader->VerticalPixelOffset.Set( windowVOffset // fixme: vary with window location From dcb6c1ac3a517e77a183d3f915b62a04fecea5ba Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 3 Oct 2016 23:30:00 +0200 Subject: [PATCH 1027/1509] Move ApplyFXAA to PostProcessScene --- src/gl/renderer/gl_postprocess.cpp | 1 + src/gl/scene/gl_scene.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 5c5abf02a..25050c22f 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -137,6 +137,7 @@ void FGLRenderer::PostProcessScene() TonemapScene(); ColormapScene(); LensDistortScene(); + ApplyFXAA(); } //----------------------------------------------------------------------------- diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index d1fdc7177..59d6e0987 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -854,7 +854,6 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo if (mainview && FGLRenderBuffers::IsEnabled()) { PostProcessScene(); - ApplyFXAA(); // This should be done after postprocessing, not before. mBuffers->BindCurrentFB(); From e9d13e5d7440b450eeebbd5fd89322427718fbf9 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 4 Oct 2016 00:25:35 +0200 Subject: [PATCH 1028/1509] Remove gl_light_math (reverts last remains of old lightmath branch) --- src/gl/dynlights/gl_dynlight1.cpp | 26 +------ src/gl/renderer/gl_renderstate.cpp | 1 - src/gl/shaders/gl_shader.cpp | 1 - src/gl/shaders/gl_shader.h | 1 - src/gl/system/gl_cvars.h | 1 - wadsrc/static/menudef.zz | 8 --- wadsrc/static/shaders/glsl/main.fp | 94 +------------------------ wadsrc/static/shaders/glsl/main.vp | 2 +- wadsrc/static/shaders/glsl/shaderdefs.i | 1 - 9 files changed, 7 insertions(+), 128 deletions(-) diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index 5c5e26f03..d20f5c01b 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -60,11 +60,6 @@ CVAR (Bool, gl_lights_checkside, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CVAR (Bool, gl_light_sprites, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CVAR (Bool, gl_light_particles, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); -CUSTOM_CVAR(Int, gl_light_math, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -{ - if (self < 0 || self > 2) self = 0; -} - //========================================================================== // // Sets up the parameters to render one dynamic light onto one plane @@ -113,25 +108,10 @@ bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FD i = 1; } - float worldPos[4] = { (float)pos.X, (float)pos.Z, (float)pos.Y, 1.0f }; - float eyePos[4]; - gl_RenderState.mViewMatrix.multMatrixPoint(worldPos, eyePos); - - if (gl_light_math != 0) - { - // Move light up because flasks/vials have their light source location at/below the floor. - // - // If the point is exactly on the wall plane it might cause some acne as some pixels could - // be in front and some behind. Move light just a tiny bit to avoid this. - eyePos[0] += 0.01f; - eyePos[1] += 5.01f; - eyePos[2] += 0.01f; - } - float *data = &ldata.arrays[i][ldata.arrays[i].Reserve(8)]; - data[0] = eyePos[0]; - data[1] = eyePos[1]; - data[2] = eyePos[2]; + data[0] = pos.X; + data[1] = pos.Z; + data[2] = pos.Y; data[3] = radius; data[4] = r; data[5] = g; diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index cfaaea3cc..fa8237cca 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -158,7 +158,6 @@ bool FRenderState::ApplyShader() activeShader->muTimer.Set(gl_frameMS * mShaderTimer / 1000.f); activeShader->muAlphaThreshold.Set(mAlphaThreshold); activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now - activeShader->muLightMath.Set(gl_light_math); activeShader->muClipSplit.Set(mClipSplit); if (mGlowEnabled) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 9368a268c..9cbd69ce2 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -220,7 +220,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muColormapStart.Init(hShader, "uFixedColormapStart"); muColormapRange.Init(hShader, "uFixedColormapRange"); muLightIndex.Init(hShader, "uLightIndex"); - muLightMath.Init(hShader, "uLightMath"); muFogColor.Init(hShader, "uFogColor"); muDynLightColor.Init(hShader, "uDynLightColor"); muObjectColor.Init(hShader, "uObjectColor"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 934674cbe..acdd530aa 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -266,7 +266,6 @@ class FShader FUniform1i muFixedColormap; FUniform4f muColormapStart; FUniform4f muColormapRange; - FBufferedUniform1i muLightMath; FBufferedUniform1i muLightIndex; FBufferedUniformPE muFogColor; FBufferedUniform4f muDynLightColor; diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index b7ac9e435..836787117 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -26,7 +26,6 @@ EXTERN_CVAR (Bool, gl_attachedlights); EXTERN_CVAR (Bool, gl_lights_checkside); EXTERN_CVAR (Bool, gl_light_sprites); EXTERN_CVAR (Bool, gl_light_particles); -EXTERN_CVAR (Int, gl_light_math); EXTERN_CVAR(Int, gl_fogmode) EXTERN_CVAR(Int, gl_lightmode) diff --git a/wadsrc/static/menudef.zz b/wadsrc/static/menudef.zz index 6eb56be94..d5c2bbc5c 100644 --- a/wadsrc/static/menudef.zz +++ b/wadsrc/static/menudef.zz @@ -25,13 +25,6 @@ OptionValue "FilterModes" 4, "$OPTVAL_TRILINEAR" } -OptionValue "LightMathModes" -{ - 0, "$OPTVAL_LOW" - 1, "$OPTVAL_MEDIUM" - 2, "$OPTVAL_HIGH" -} - OptionValue "HWGammaModes" { 0, "$OPTVAL_ON" @@ -225,7 +218,6 @@ OptionMenu "GLLightOptions" Option "$GLLIGHTMNU_CLIPLIGHTS", gl_lights_checkside, "YesNo" Option "$GLLIGHTMNU_LIGHTSPRITES", gl_light_sprites, "YesNo" Option "$GLLIGHTMNU_LIGHTPARTICLES", gl_light_particles, "YesNo" - Option "$GLLIGHTMNU_LIGHTMATH", gl_light_math, "LightMathModes" } OptionMenu "GLPrefOptions" diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 374edb59c..1f270728d 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -30,88 +30,6 @@ vec4 Process(vec4 color); vec4 ProcessTexel(); vec4 ProcessLight(vec4 color); -// Smoothed normal used for the face, in eye space. Should be converted to an 'in' variable in the future. -vec3 pixelnormal; - -//=========================================================================== -// -// Calculates the face normal vector for the fragment, in eye space -// -//=========================================================================== - -vec3 calculateFaceNormal() -{ -#if __VERSION__ < 450 - vec3 dFdxPos = dFdx(pixelpos.xyz); - vec3 dFdyPos = dFdy(pixelpos.xyz); -#else - vec3 dFdxPos = dFdxCoarse(pixelpos.xyz); - vec3 dFdyPos = dFdyCoarse(pixelpos.xyz); -#endif - return normalize(cross(dFdxPos,dFdyPos)); -} - -//=========================================================================== -// -// Standard lambertian diffuse light calculation -// -//=========================================================================== - -float diffuseContribution(vec3 eyeLightDirection, vec3 eyeNormal) -{ - return max(dot(eyeNormal, eyeLightDirection), 0.0f); -} - -//=========================================================================== -// -// Blinn specular light calculation -// -//=========================================================================== - -float blinnSpecularContribution(float diffuseContribution, vec3 eyeLightDirection, vec3 eyePosition, vec3 eyeNormal, float glossiness, float specularLevel) -{ - if (diffuseContribution > 0.0f) - { - vec3 viewDir = normalize(-eyePosition); - vec3 halfDir = normalize(eyeLightDirection + viewDir); - float specAngle = max(dot(halfDir, eyeNormal), 0.0f); - float phExp = glossiness * 4.0f; - return specularLevel * pow(specAngle, phExp); - } - else - { - return 0.0f; - } -} - -//=========================================================================== -// -// Calculates the brightness of a dynamic point light -// -//=========================================================================== - -float pointLightAttenuation(vec4 lightpos) -{ - float attenuation = max(lightpos.w - distance(pixelpos.xyz, lightpos.xyz),0.0) / lightpos.w; - if (uLightMath == 0) - { - return attenuation; - } - else - { - vec3 lightDirection = normalize(lightpos.xyz - pixelpos.xyz); - float diffuseAmount = diffuseContribution(lightDirection, pixelnormal); - if (uLightMath == 1) - { - return attenuation * diffuseAmount; - } - else - { - float specularAmount = blinnSpecularContribution(diffuseAmount, lightDirection, pixelpos.xyz, pixelnormal, 3.0, 1.2); - return attenuation * (diffuseAmount + specularAmount); - } - } -} //=========================================================================== // @@ -384,13 +302,6 @@ vec3 AmbientOcclusionColor() void main() { vec4 frag = ProcessTexel(); - -#if defined NUM_UBO_LIGHTS || defined SHADER_STORAGE_LIGHTS - if (uLightMath != 0) // Remove this if pixelnormal is converted to an 'in' variable - { - pixelnormal = calculateFaceNormal(); - } -#endif #ifndef NO_ALPHATEST if (frag.a <= uAlphaThreshold) discard; @@ -416,11 +327,12 @@ void main() } else { - fogdist = max(16.0, length(pixelpos.xyz)); + fogdist = max(16.0, distance(pixelpos.xyz, uCameraPos.xyz)); } fogfactor = exp2 (uFogDensity * fogdist); } + frag *= getLightColor(fogdist, fogfactor); #if defined NUM_UBO_LIGHTS || defined SHADER_STORAGE_LIGHTS @@ -486,7 +398,7 @@ void main() } else { - fogdist = max(16.0, length(pixelpos.xyz)); + fogdist = max(16.0, distance(pixelpos.xyz, uCameraPos.xyz)); } fogfactor = exp2 (uFogDensity * fogdist); diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 0baca31f9..1de8854c0 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -47,7 +47,7 @@ void main() vColor = aColor; #ifndef SIMPLE - pixelpos.xyz = eyeCoordPos.xyz; + pixelpos.xyz = worldcoord.xyz; pixelpos.w = -eyeCoordPos.z/eyeCoordPos.w; glowdist.x = -((uGlowTopPlane.w + uGlowTopPlane.x * worldcoord.x + uGlowTopPlane.y * worldcoord.z) * uGlowTopPlane.z) - worldcoord.y; diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 81edd7b04..8c5697a66 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -44,7 +44,6 @@ uniform int uFogEnabled; // dynamic lights uniform int uLightIndex; -uniform int uLightMath; // 0, when using only attenuation, 1 for diffuse light, 2 for blinn specular light // quad drawer stuff #ifdef USE_QUAD_DRAWER From e05ed47fee1599eef2c80066eeb96dfe60a1d34f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 4 Oct 2016 01:36:26 +0200 Subject: [PATCH 1029/1509] Remove C++ and SSE drawers --- src/r_draw_rgba.cpp | 1178 +---------------------------------------- src/r_draw_rgba.h | 12 - src/r_draw_rgba_sse.h | 367 ------------- 3 files changed, 2 insertions(+), 1555 deletions(-) delete mode 100644 src/r_draw_rgba_sse.h diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index ae6c26cfc..c5b1b478e 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -43,10 +43,6 @@ #include "gi.h" #include "stats.h" #include "x86.h" -#ifndef NO_SSE -#include -#include -#endif #include extern "C" short spanend[MAXHEIGHT]; @@ -55,9 +51,7 @@ extern float rw_lightstep; extern int wallshade; // Use multiple threads when drawing -CVAR(Bool, r_multithreaded, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); -// [SP] Set Max Threads to a sane amount -CVAR(Int, r_multithreadedmax, 1024, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR(Bool, r_multithreaded, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); // Use linear filtering when scaling up CVAR(Bool, r_magfilter, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); @@ -68,48 +62,8 @@ CVAR(Bool, r_minfilter, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); // Use mipmapped textures CVAR(Bool, r_mipmap, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); -#ifndef NO_SSE - -#ifdef _MSC_VER -#pragma warning(disable: 4101) // warning C4101: unreferenced local variable -#endif - -// Generate SSE drawers: -#define VecCommand(name) name##_SSE_Command -#define VEC_SHADE_VARS SSE_SHADE_VARS -#define VEC_SHADE_SIMPLE_INIT SSE_SHADE_SIMPLE_INIT -#define VEC_SHADE_SIMPLE_INIT4 SSE_SHADE_SIMPLE_INIT4 -#define VEC_SHADE_SIMPLE SSE_SHADE_SIMPLE -#define VEC_SHADE_INIT SSE_SHADE_INIT -#define VEC_SHADE_INIT4 SSE_SHADE_INIT4 -#define VEC_SHADE SSE_SHADE -#include "r_draw_rgba_sse.h" -/* -// Generate AVX drawers: -#undef VecCommand -#undef VEC_SHADE_SIMPLE_INIT -#undef VEC_SHADE_SIMPLE_INIT4 -#undef VEC_SHADE_SIMPLE -#undef VEC_SHADE_INIT -#undef VEC_SHADE_INIT4 -#undef VEC_SHADE -#define VecCommand(name) name##_AVX_Command -#define VEC_SHADE_SIMPLE_INIT AVX_LINEAR_SHADE_SIMPLE_INIT -#define VEC_SHADE_SIMPLE_INIT4 AVX_LINEAR_SHADE_SIMPLE_INIT4 -#define VEC_SHADE_SIMPLE AVX_LINEAR_SHADE_SIMPLE -#define VEC_SHADE_INIT AVX_LINEAR_SHADE_INIT -#define VEC_SHADE_INIT4 AVX_LINEAR_SHADE_INIT4 -#define VEC_SHADE AVX_LINEAR_SHADE -#include "r_draw_rgba_sse.h" -*/ -#endif - ///////////////////////////////////////////////////////////////////////////// -#ifndef NO_SSE -__m128i SampleBgra::samplertable[256 * 2]; -#endif - DrawerCommandQueue *DrawerCommandQueue::Instance() { static DrawerCommandQueue queue; @@ -118,27 +72,6 @@ DrawerCommandQueue *DrawerCommandQueue::Instance() DrawerCommandQueue::DrawerCommandQueue() { -#ifndef NO_SSE - for (int inv_b = 0; inv_b < 16; inv_b++) - { - for (int inv_a = 0; inv_a < 16; inv_a++) - { - int a = 16 - inv_a; - int b = 16 - inv_b; - - int ab = a * b; - int invab = inv_a * b; - int ainvb = a * inv_b; - int invainvb = inv_a * inv_b; - - __m128i ab_invab = _mm_set_epi16(invab, invab, invab, invab, ab, ab, ab, ab); - __m128i ainvb_invainvb = _mm_set_epi16(invainvb, invainvb, invainvb, invainvb, ainvb, ainvb, ainvb, ainvb); - - _mm_store_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2, ab_invab); - _mm_store_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2 + 1, ainvb_invainvb); - } - } -#endif } DrawerCommandQueue::~DrawerCommandQueue() @@ -200,7 +133,7 @@ void DrawerCommandQueue::Finish() DrawerThread thread; thread.core = 0; - thread.num_cores = queue->threads.size() + 1; + thread.num_cores = (int)(queue->threads.size() + 1); for (int pass = 0; pass < queue->num_passes; pass++) { @@ -1249,310 +1182,6 @@ public: } }; -///////////////////////////////////////////////////////////////////////////// - -class DrawerSpanCommand : public DrawerCommand -{ -public: - fixed_t _xfrac; - fixed_t _yfrac; - fixed_t _xstep; - fixed_t _ystep; - int _x1; - int _x2; - int _y; - int _xbits; - int _ybits; - BYTE * RESTRICT _destorg; - - const uint32_t * RESTRICT _source; - uint32_t _light; - ShadeConstants _shade_constants; - bool _nearest_filter; - - uint32_t _srcalpha; - uint32_t _destalpha; - - DrawerSpanCommand() - { - _xfrac = ds_xfrac; - _yfrac = ds_yfrac; - _xstep = ds_xstep; - _ystep = ds_ystep; - _x1 = ds_x1; - _x2 = ds_x2; - _y = ds_y; - _xbits = ds_xbits; - _ybits = ds_ybits; - _destorg = dc_destorg; - - _source = (const uint32_t*)ds_source; - _light = LightBgra::calc_light_multiplier(ds_light); - _shade_constants = ds_shade_constants; - _nearest_filter = !SampleBgra::span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep, ds_source_mipmapped); - - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - } - - class LoopIterator - { - public: - uint32_t *dest; - int count; - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - BYTE yshift; - BYTE xshift; - int xmask; - bool is_64x64; - bool skipped; - - LoopIterator(DrawerSpanCommand *command, DrawerThread *thread) - { - dest = ylookup[command->_y] + command->_x1 + (uint32_t*)command->_destorg; - count = command->_x2 - command->_x1 + 1; - xfrac = command->_xfrac; - yfrac = command->_yfrac; - xstep = command->_xstep; - ystep = command->_ystep; - yshift = 32 - command->_ybits; - xshift = yshift - command->_xbits; - xmask = ((1 << command->_xbits) - 1) << command->_ybits; - is_64x64 = command->_xbits == 6 && command->_ybits == 6; - skipped = thread->line_skipped_by_thread(command->_y); - } - - // 64x64 is the most common case by far, so special case it. - int spot64() - { - return ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - } - - int spot() - { - return ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - } - - explicit operator bool() - { - return !skipped && count > 0; - } - - bool next() - { - dest++; - xfrac += xstep; - yfrac += ystep; - return (--count) != 0; - } - }; -}; - -class DrawSpanRGBACommand : public DrawerSpanCommand -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - - if (_nearest_filter) - { - if (loop.is_64x64) - { - do - { - *loop.dest = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); - } while (loop.next()); - } - else - { - do - { - *loop.dest = LightBgra::shade_bgra(_source[loop.spot()], _light, _shade_constants); - } while (loop.next()); - } - } - else - { - if (loop.is_64x64) - { - do - { - *loop.dest = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, loop.xfrac, loop.yfrac, 26, 26), _light, _shade_constants); - } while (loop.next()); - } - else - { - do - { - *loop.dest = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, loop.xfrac, loop.yfrac, 32 - _xbits, 32 - _ybits), _light, _shade_constants); - } while (loop.next()); - } - } - } -}; - -class DrawSpanMaskedRGBACommand : public DrawerSpanCommand -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - - if (_nearest_filter) - { - if (loop.is_64x64) - { - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); - *loop.dest = BlendBgra::alpha_blend(fg, *loop.dest); - } while (loop.next()); - } - else - { - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.spot()], _light, _shade_constants); - *loop.dest = BlendBgra::alpha_blend(fg, *loop.dest); - } while (loop.next()); - } - } - else - { - if (loop.is_64x64) - { - do - { - uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, loop.xfrac, loop.yfrac, 26, 26), _light, _shade_constants); - *loop.dest = BlendBgra::alpha_blend(fg, *loop.dest); - } while (loop.next()); - } - else - { - do - { - uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, loop.xfrac, loop.yfrac, 32 - _xbits, 32 - _ybits), _light, _shade_constants); - *loop.dest = BlendBgra::alpha_blend(fg, *loop.dest); - } while (loop.next()); - } - } - } -}; - -class DrawSpanTranslucentRGBACommand : public DrawerSpanCommand -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - - if (loop.is_64x64) - { - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } - else - { - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.spot()], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } - } -}; - -class DrawSpanMaskedTranslucentRGBACommand : public DrawerSpanCommand -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - - if (loop.is_64x64) - { - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); - } while (loop.next()); - } - else - { - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.spot()], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); - } while (loop.next()); - } - } -}; - -class DrawSpanAddClampRGBACommand : public DrawerSpanCommand -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - - if (loop.is_64x64) - { - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } - else - { - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.spot()], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } - } -}; - -class DrawSpanMaskedAddClampRGBACommand : public DrawerSpanCommand -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - - if (loop.is_64x64) - { - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.spot64()], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); - } while (loop.next()); - } - else - { - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.spot()], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); - } while (loop.next()); - } - } -}; - class FillSpanRGBACommand : public DrawerCommand { int _x1; @@ -1708,735 +1337,6 @@ public: ///////////////////////////////////////////////////////////////////////////// -class DrawerWall1Command : public DrawerCommand -{ -public: - BYTE * RESTRICT _dest; - int _pitch; - int _count; - DWORD _texturefrac; - uint32_t _texturefracx; - DWORD _iscale; - uint32_t _textureheight; - - const uint32 * RESTRICT _source; - const uint32 * RESTRICT _source2; - uint32_t _light; - ShadeConstants _shade_constants; - - uint32_t _srcalpha; - uint32_t _destalpha; - - DrawerWall1Command() - { - _dest = dc_dest; - _pitch = dc_pitch; - _count = dc_count; - _texturefrac = dc_texturefrac; - _texturefracx = dc_texturefracx; - _iscale = dc_iscale; - _textureheight = dc_textureheight; - - _source = (const uint32 *)dc_source; - _source2 = (const uint32 *)dc_source2; - _light = LightBgra::calc_light_multiplier(dc_light); - _shade_constants = dc_shade_constants; - - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - } - - class LoopIterator - { - public: - uint32_t *dest; - int pitch; - int count; - uint32_t fracstep; - uint32_t frac; - uint32_t texturefracx; - uint32_t height; - uint32_t one; - - LoopIterator(DrawerWall1Command *command, DrawerThread *thread) - { - count = thread->count_for_thread(command->_dest_y, command->_count); - if (count <= 0) - return; - - fracstep = command->_iscale * thread->num_cores; - frac = command->_texturefrac + command->_iscale * thread->skipped_by_thread(command->_dest_y); - texturefracx = command->_texturefracx; - dest = thread->dest_for_thread(command->_dest_y, command->_pitch, (uint32_t*)command->_dest); - pitch = command->_pitch * thread->num_cores; - - height = command->_textureheight; - one = ((0x80000000 + height - 1) / height) * 2 + 1; - } - - explicit operator bool() - { - return count > 0; - } - - int sample_index() - { - return ((frac >> FRACBITS) * height) >> FRACBITS; - } - - bool next() - { - frac += fracstep; - dest += pitch; - return (--count) != 0; - } - }; -}; - -class DrawerWall4Command : public DrawerCommand -{ -public: - BYTE * RESTRICT _dest; - int _count; - int _pitch; - ShadeConstants _shade_constants; - uint32_t _vplce[4]; - uint32_t _vince[4]; - uint32_t _buftexturefracx[4]; - uint32_t _bufheight[4]; - const uint32_t * RESTRICT _bufplce[4]; - const uint32_t * RESTRICT _bufplce2[4]; - uint32_t _light[4]; - - uint32_t _srcalpha; - uint32_t _destalpha; - - DrawerWall4Command() - { - _dest = dc_dest; - _count = dc_count; - _pitch = dc_pitch; - _shade_constants = dc_shade_constants; - for (int i = 0; i < 4; i++) - { - _vplce[i] = vplce[i]; - _vince[i] = vince[i]; - _buftexturefracx[i] = buftexturefracx[i]; - _bufheight[i] = bufheight[i]; - _bufplce[i] = (const uint32_t *)bufplce[i]; - _bufplce2[i] = (const uint32_t *)bufplce2[i]; - _light[i] = LightBgra::calc_light_multiplier(palookuplight[i]); - } - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - } - - class LoopIterator - { - public: - uint32_t *dest; - int pitch; - int count; - uint32_t vplce[4]; - uint32_t vince[4]; - uint32_t height[4]; - uint32_t one[4]; - - LoopIterator(DrawerWall4Command *command, DrawerThread *thread) - { - count = thread->count_for_thread(command->_dest_y, command->_count); - if (count <= 0) - return; - - dest = thread->dest_for_thread(command->_dest_y, command->_pitch, (uint32_t*)command->_dest); - pitch = command->_pitch * thread->num_cores; - - int skipped = thread->skipped_by_thread(command->_dest_y); - for (int i = 0; i < 4; i++) - { - vplce[i] = command->_vplce[i] + command->_vince[i] * skipped; - vince[i] = command->_vince[i] * thread->num_cores; - height[i] = command->_bufheight[i]; - one[i] = ((0x80000000 + height[i] - 1) / height[i]) * 2 + 1; - } - } - - explicit operator bool() - { - return count > 0; - } - - int sample_index(int col) - { - return ((vplce[col] >> FRACBITS) * height[col]) >> FRACBITS; - } - - bool next() - { - vplce[0] += vince[0]; - vplce[1] += vince[1]; - vplce[2] += vince[2]; - vplce[3] += vince[3]; - dest += pitch; - return (--count) != 0; - } - }; - -#ifdef NO_SSE - struct NearestSampler - { - FORCEINLINE static uint32_t Sample1(DrawerWall4Command &cmd, LoopIterator &loop, int index) - { - return cmd._bufplce[index][loop.sample_index(index)]; - } - }; - struct LinearSampler - { - FORCEINLINE static uint32_t Sample1(DrawerWall4Command &cmd, LoopIterator &loop, int index) - { - return SampleBgra::sample_bilinear(cmd._bufplce[index], cmd._bufplce2[index], cmd._buftexturefracx[index], loop.vplce[index], loop.one[index], loop.height[index]); - } - }; -#else - struct NearestSampler - { - FORCEINLINE static __m128i Sample4(DrawerWall4Command &cmd, LoopIterator &loop) - { - return _mm_set_epi32(cmd._bufplce[3][loop.sample_index(3)], cmd._bufplce[2][loop.sample_index(2)], cmd._bufplce[1][loop.sample_index(1)], cmd._bufplce[0][loop.sample_index(0)]); - } - }; - - struct LinearSampler - { - FORCEINLINE static __m128i Sample4(DrawerWall4Command &cmd, LoopIterator &loop) - { - __m128i fg; - VEC_SAMPLE_BILINEAR4_COLUMN(fg, cmd._bufplce, cmd._bufplce2, cmd._buftexturefracx, loop.vplce, loop.one, loop.height); - return fg; - } - }; -#endif - -#ifdef NO_SSE - template - struct Copy - { - Copy(DrawerWall4Command &cmd, LoopIterator &loop) - { - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_bgra(Sampler::Sample1(cmd, loop, i), cmd._light[i], cmd._shade_constants); - loop.dest[i] = BlendBgra::copy(fg); - } - } - }; - - template - struct Mask - { - Mask(DrawerWall4Command &cmd, LoopIterator &loop) - { - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_bgra(Sampler::Sample1(cmd, loop, i), cmd._light[i], cmd._shade_constants); - loop.dest[i] = BlendBgra::alpha_blend(fg, loop.dest[i]); - } - } - }; - - template - struct TMaskAdd - { - TMaskAdd(DrawerWall4Command &cmd, LoopIterator &loop) - { - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_bgra(Sampler::Sample1(cmd, loop, i), cmd._light[i], cmd._shade_constants); - loop.dest[i] = BlendBgra::add(fg, loop.dest[i], cmd._srcalpha, calc_blend_bgalpha(fg, cmd._destalpha)); - } - } - }; - - template - struct TMaskSub - { - TMaskSub(DrawerWall4Command &cmd, LoopIterator &loop) - { - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_bgra(Sampler::Sample1(cmd, loop, i), cmd._light[i], cmd._shade_constants); - loop.dest[i] = BlendBgra::sub(fg, loop.dest[i], cmd._srcalpha, calc_blend_bgalpha(fg, cmd._destalpha)); - } - } - }; - - template - struct TMaskRevSub - { - TMaskRevSub(DrawerWall4Command &cmd, LoopIterator &loop) - { - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_bgra(Sampler::Sample1(cmd, loop, i), cmd._light[i], cmd._shade_constants); - loop.dest[i] = BlendBgra::revsub(fg, loop.dest[i], cmd._srcalpha, calc_blend_bgalpha(fg, cmd._destalpha)); - } - } - }; - - typedef Copy CopyNearestSimple; - typedef Copy CopyLinearSimple; - typedef Copy CopyNearest; - typedef Copy CopyLinear; - typedef Mask MaskNearestSimple; - typedef Mask MaskLinearSimple; - typedef Mask MaskNearest; - typedef Mask MaskLinear; - typedef TMaskAdd TMaskAddNearestSimple; - typedef TMaskAdd TMaskAddLinearSimple; - typedef TMaskAdd TMaskAddNearest; - typedef TMaskAdd TMaskAddLinear; - typedef TMaskSub TMaskSubNearestSimple; - typedef TMaskSub TMaskSubLinearSimple; - typedef TMaskSub TMaskSubNearest; - typedef TMaskSub TMaskSubLinear; - typedef TMaskRevSub TMaskRevSubNearestSimple; - typedef TMaskRevSub TMaskRevSubLinearSimple; - typedef TMaskRevSub TMaskRevSubNearest; - typedef TMaskRevSub TMaskRevSubLinear; -#else - template - struct CopySimple - { - VEC_SHADE_VARS(); - CopySimple(DrawerWall4Command &cmd, LoopIterator &loop) - { - VEC_SHADE_SIMPLE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0]); - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - __m128i fg = Sampler::Sample4(cmd, loop); - VEC_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)loop.dest, fg); - } - }; - - template - struct Copy - { - VEC_SHADE_VARS(); - Copy(DrawerWall4Command &cmd, LoopIterator &loop) - { - VEC_SHADE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0], cmd._shade_constants); - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - __m128i fg = Sampler::Sample4(cmd, loop); - VEC_SHADE(fg, cmd._shade_constants); - _mm_storeu_si128((__m128i*)loop.dest, fg); - } - }; - - template - struct MaskSimple - { - VEC_SHADE_VARS(); - MaskSimple(DrawerWall4Command &cmd, LoopIterator &loop) - { - VEC_SHADE_SIMPLE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0]); - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - __m128i fg = Sampler::Sample4(cmd, loop); - __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); - VEC_SHADE_SIMPLE(fg); - VEC_ALPHA_BLEND(fg, bg); - _mm_storeu_si128((__m128i*)loop.dest, fg); - } - }; - - template - struct Mask - { - VEC_SHADE_VARS(); - Mask(DrawerWall4Command &cmd, LoopIterator &loop) - { - VEC_SHADE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0], cmd._shade_constants); - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - __m128i fg = Sampler::Sample4(cmd, loop); - __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); - VEC_SHADE(fg, cmd._shade_constants); - VEC_ALPHA_BLEND(fg, bg); - _mm_storeu_si128((__m128i*)loop.dest, fg); - } - }; - - template - struct TMaskAddSimple - { - VEC_SHADE_VARS(); - VEC_CALC_BLEND_ALPHA_VARS(); - TMaskAddSimple(DrawerWall4Command &cmd, LoopIterator &loop) - { - VEC_SHADE_SIMPLE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0]); - VEC_CALC_BLEND_ALPHA_INIT(cmd._srcalpha, cmd._destalpha); - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - __m128i fg = Sampler::Sample4(cmd, loop); - __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); - - VEC_CALC_BLEND_ALPHA(fg); - VEC_SHADE_SIMPLE(fg); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - __m128i out_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); - __m128i out_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); - __m128i out = _mm_packus_epi16(out_lo, out_hi); - - _mm_storeu_si128((__m128i*)loop.dest, out); - } - }; - - template - struct TMaskAdd - { - VEC_SHADE_VARS(); - VEC_CALC_BLEND_ALPHA_VARS(); - TMaskAdd(DrawerWall4Command &cmd, LoopIterator &loop) - { - VEC_SHADE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0], cmd._shade_constants); - VEC_CALC_BLEND_ALPHA_INIT(cmd._srcalpha, cmd._destalpha); - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - __m128i fg = Sampler::Sample4(cmd, loop); - __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); - - VEC_CALC_BLEND_ALPHA(fg); - VEC_SHADE_SIMPLE(fg); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - __m128i out_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); - __m128i out_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); - __m128i out = _mm_packus_epi16(out_lo, out_hi); - - _mm_storeu_si128((__m128i*)loop.dest, out); - } - }; - - template - struct TMaskSubSimple - { - VEC_SHADE_VARS(); - VEC_CALC_BLEND_ALPHA_VARS(); - TMaskSubSimple(DrawerWall4Command &cmd, LoopIterator &loop) - { - VEC_SHADE_SIMPLE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0]); - VEC_CALC_BLEND_ALPHA_INIT(cmd._srcalpha, cmd._destalpha); - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - __m128i fg = Sampler::Sample4(cmd, loop); - __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); - - VEC_CALC_BLEND_ALPHA(fg); - VEC_SHADE_SIMPLE(fg); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_hi, bg_alpha_hi), _mm_mullo_epi16(fg_hi, fg_alpha_hi)), 8); - __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_lo, bg_alpha_lo), _mm_mullo_epi16(fg_lo, fg_alpha_lo)), 8); - __m128i out = _mm_packus_epi16(out_lo, out_hi); - - _mm_storeu_si128((__m128i*)loop.dest, out); - } - }; - - template - struct TMaskSub - { - VEC_SHADE_VARS(); - VEC_CALC_BLEND_ALPHA_VARS(); - TMaskSub(DrawerWall4Command &cmd, LoopIterator &loop) - { - VEC_SHADE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0], cmd._shade_constants); - VEC_CALC_BLEND_ALPHA_INIT(cmd._srcalpha, cmd._destalpha); - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - __m128i fg = Sampler::Sample4(cmd, loop); - __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); - - VEC_CALC_BLEND_ALPHA(fg); - VEC_SHADE_SIMPLE(fg); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_hi, bg_alpha_hi), _mm_mullo_epi16(fg_hi, fg_alpha_hi)), 8); - __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_lo, bg_alpha_lo), _mm_mullo_epi16(fg_lo, fg_alpha_lo)), 8); - __m128i out = _mm_packus_epi16(out_lo, out_hi); - - _mm_storeu_si128((__m128i*)loop.dest, out); - } - }; - - template - struct TMaskRevSubSimple - { - VEC_SHADE_VARS(); - VEC_CALC_BLEND_ALPHA_VARS(); - TMaskRevSubSimple(DrawerWall4Command &cmd, LoopIterator &loop) - { - VEC_SHADE_SIMPLE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0]); - VEC_CALC_BLEND_ALPHA_INIT(cmd._srcalpha, cmd._destalpha); - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - __m128i fg = Sampler::Sample4(cmd, loop); - __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); - - VEC_CALC_BLEND_ALPHA(fg); - VEC_SHADE_SIMPLE(fg); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); - __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); - __m128i out = _mm_packus_epi16(out_lo, out_hi); - - _mm_storeu_si128((__m128i*)loop.dest, out); - } - }; - - template - struct TMaskRevSub - { - VEC_SHADE_VARS(); - VEC_CALC_BLEND_ALPHA_VARS(); - TMaskRevSub(DrawerWall4Command &cmd, LoopIterator &loop) - { - VEC_SHADE_INIT4(cmd._light[3], cmd._light[2], cmd._light[1], cmd._light[0], cmd._shade_constants); - VEC_CALC_BLEND_ALPHA_INIT(cmd._srcalpha, cmd._destalpha); - } - void Blend(DrawerWall4Command &cmd, LoopIterator &loop) - { - __m128i fg = Sampler::Sample4(cmd, loop); - __m128i bg = _mm_loadu_si128((const __m128i*)loop.dest); - - VEC_CALC_BLEND_ALPHA(fg); - VEC_SHADE_SIMPLE(fg); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - __m128i out_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_hi, fg_alpha_hi), _mm_mullo_epi16(bg_hi, bg_alpha_hi)), 8); - __m128i out_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_lo, fg_alpha_lo), _mm_mullo_epi16(bg_lo, bg_alpha_lo)), 8); - __m128i out = _mm_packus_epi16(out_lo, out_hi); - - _mm_storeu_si128((__m128i*)loop.dest, out); - } - }; - - typedef CopySimple CopyNearestSimple; - typedef CopySimple CopyLinearSimple; - typedef Copy CopyNearest; - typedef Copy CopyLinear; - typedef MaskSimple MaskNearestSimple; - typedef MaskSimple MaskLinearSimple; - typedef Mask MaskNearest; - typedef Mask MaskLinear; - typedef TMaskAddSimple TMaskAddNearestSimple; - typedef TMaskAddSimple TMaskAddLinearSimple; - typedef TMaskAdd TMaskAddNearest; - typedef TMaskAdd TMaskAddLinear; - typedef TMaskSubSimple TMaskSubNearestSimple; - typedef TMaskSubSimple TMaskSubLinearSimple; - typedef TMaskSub TMaskSubNearest; - typedef TMaskSub TMaskSubLinear; - typedef TMaskRevSubSimple TMaskRevSubNearestSimple; - typedef TMaskRevSubSimple TMaskRevSubLinearSimple; - typedef TMaskRevSub TMaskRevSubNearest; - typedef TMaskRevSub TMaskRevSubLinear; -#endif -}; - -typedef DrawerBlendCommand Vlinec4NearestSimpleRGBACommand; -typedef DrawerBlendCommand Vlinec4NearestRGBACommand; -typedef DrawerBlendCommand Vlinec4LinearSimpleRGBACommand; -typedef DrawerBlendCommand Vlinec4LinearRGBACommand; -typedef DrawerBlendCommand Mvlinec4NearestSimpleRGBACommand; -typedef DrawerBlendCommand Mvlinec4NearestRGBACommand; -typedef DrawerBlendCommand Mvlinec4LinearSimpleRGBACommand; -typedef DrawerBlendCommand Mvlinec4LinearRGBACommand; -typedef DrawerBlendCommand Tmvline4AddNearestSimpleRGBACommand; -typedef DrawerBlendCommand Tmvline4AddNearestRGBACommand; -typedef DrawerBlendCommand Tmvline4AddLinearSimpleRGBACommand; -typedef DrawerBlendCommand Tmvline4AddLinearRGBACommand; -typedef DrawerBlendCommand Tmvline4AddClampNearestSimpleRGBACommand; -typedef DrawerBlendCommand Tmvline4AddClampNearestRGBACommand; -typedef DrawerBlendCommand Tmvline4AddClampLinearSimpleRGBACommand; -typedef DrawerBlendCommand Tmvline4AddClampLinearRGBACommand; -typedef DrawerBlendCommand Tmvline4SubClampNearestSimpleRGBACommand; -typedef DrawerBlendCommand Tmvline4SubClampNearestRGBACommand; -typedef DrawerBlendCommand Tmvline4SubClampLinearSimpleRGBACommand; -typedef DrawerBlendCommand Tmvline4SubClampLinearRGBACommand; -typedef DrawerBlendCommand Tmvline4RevSubClampNearestSimpleRGBACommand; -typedef DrawerBlendCommand Tmvline4RevSubClampNearestRGBACommand; -typedef DrawerBlendCommand Tmvline4RevSubClampLinearSimpleRGBACommand; -typedef DrawerBlendCommand Tmvline4RevSubClampLinearRGBACommand; - -class Vlinec1RGBACommand : public DrawerWall1Command -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - - if (_source2 == nullptr) - { - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.sample_index()], _light, _shade_constants); - *loop.dest = BlendBgra::copy(fg); - } while (loop.next()); - } - else - { - do - { - uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, _source2, loop.texturefracx, loop.frac, loop.one, loop.height), _light, _shade_constants); - *loop.dest = BlendBgra::copy(fg); - } while (loop.next()); - } - } -}; - -class Mvlinec1RGBACommand : public DrawerWall1Command -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - - if (_source2 == nullptr) - { - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.sample_index()], _light, _shade_constants); - *loop.dest = BlendBgra::alpha_blend(fg, *loop.dest); - } while (loop.next()); - } - else - { - do - { - uint32_t fg = LightBgra::shade_bgra(SampleBgra::sample_bilinear(_source, _source2, loop.texturefracx, loop.frac, loop.one, loop.height), _light, _shade_constants); - *loop.dest = BlendBgra::alpha_blend(fg, *loop.dest); - } while (loop.next()); - } - } -}; - -class Tmvline1AddRGBACommand : public DrawerWall1Command -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.sample_index()], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); - } while (loop.next()); - } -}; - -class Tmvline1AddClampRGBACommand : public DrawerWall1Command -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.sample_index()], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); - } while (loop.next()); - } -}; - -class Tmvline1SubClampRGBACommand : public DrawerWall1Command -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.sample_index()], _light, _shade_constants); - *loop.dest = BlendBgra::sub(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); - } while (loop.next()); - } -}; - -class Tmvline1RevSubClampRGBACommand : public DrawerWall1Command -{ -public: - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_bgra(_source[loop.sample_index()], _light, _shade_constants); - *loop.dest = BlendBgra::revsub(fg, *loop.dest, _srcalpha, calc_blend_bgalpha(fg, _destalpha)); - } while (loop.next()); - } -}; - -///////////////////////////////////////////////////////////////////////////// - class DrawFogBoundaryLineRGBACommand : public DrawerCommand { int _y; @@ -3020,58 +1920,32 @@ void R_DrawRevSubClampTranslatedColumn_rgba() void R_DrawSpan_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#elif defined(NO_SSE) - DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif } void R_DrawSpanMasked_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif } void R_DrawSpanTranslucent_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif } void R_DrawSpanMaskedTranslucent_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif } void R_DrawSpanAddClamp_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif } void R_DrawSpanMaskedAddClamp_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif } void R_FillSpan_rgba() @@ -3116,11 +1990,7 @@ void R_DrawSlab_rgba(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BY DWORD vlinec1_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif return dc_texturefrac + dc_count * dc_iscale; } @@ -3139,116 +2009,72 @@ void queue_wallcommand() void vlinec4_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - queue_wallcommand(); -#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } DWORD mvlinec1_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif return dc_texturefrac + dc_count * dc_iscale; } void mvlinec4_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - queue_wallcommand(); -#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } fixed_t tmvline1_add_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif return dc_texturefrac + dc_count * dc_iscale; } void tmvline4_add_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - queue_wallcommand(); -#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } fixed_t tmvline1_addclamp_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif return dc_texturefrac + dc_count * dc_iscale; } void tmvline4_addclamp_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - queue_wallcommand(); -#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } fixed_t tmvline1_subclamp_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif return dc_texturefrac + dc_count * dc_iscale; } void tmvline4_subclamp_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - queue_wallcommand(); -#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } fixed_t tmvline1_revsubclamp_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - DrawerCommandQueue::QueueCommand(); -#endif return dc_texturefrac + dc_count * dc_iscale; } void tmvline4_revsubclamp_rgba() { -#if !defined(NO_LLVM) DrawerCommandQueue::QueueCommand(); -#else - queue_wallcommand(); -#endif for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index e5fa88ed0..34b874179 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -249,14 +249,6 @@ public: } else { - // [SP] Note: I've put in a hack here to throttle the speed of the rendering if - // the thread queue gets to big. This is one way to prevent too many commands - // going into the thread queue, which is causing crashes when there are too - // many threads (of which, there can be only as many as there are columns on - // the screen - guess what happens when you're too full of sprites!) - if (queue->commands.size() > r_multithreadedmax) - R_EndDrawerCommands(); - void *ptr = AllocMemory(sizeof(T)); if (!ptr) // Out of memory - render what we got { @@ -569,10 +561,6 @@ public: return (alpha << 24) | (red << 16) | (green << 8) | blue; } - -#ifndef NO_SSE - static __m128i samplertable[256 * 2]; -#endif }; ///////////////////////////////////////////////////////////////////////////// diff --git a/src/r_draw_rgba_sse.h b/src/r_draw_rgba_sse.h deleted file mode 100644 index 4ee557693..000000000 --- a/src/r_draw_rgba_sse.h +++ /dev/null @@ -1,367 +0,0 @@ -// -// SSE/AVX intrinsics based drawers for the r_draw family of drawers. -// -// Note: This header file is intentionally not guarded by a __R_DRAW_RGBA_SSE__ define. -// It is because the code is nearly identical for SSE vs AVX. The file is included -// multiple times by r_draw_rgba.cpp with different defines that changes the class -// names outputted and the type of intrinsics used. - -#ifdef _MSC_VER -#pragma warning(disable: 4752) // warning C4752: found Intel(R) Advanced Vector Extensions; consider using /arch:AVX -#endif - -class VecCommand(DrawSpanRGBA) : public DrawerCommand -{ - const uint32_t * RESTRICT _source; - fixed_t _xfrac; - fixed_t _yfrac; - fixed_t _xstep; - fixed_t _ystep; - int _x1; - int _x2; - int _y; - int _xbits; - int _ybits; - BYTE * RESTRICT _destorg; - fixed_t _light; - ShadeConstants _shade_constants; - bool _nearest_filter; - -public: - VecCommand(DrawSpanRGBA)() - { - _source = (const uint32_t*)ds_source; - _xfrac = ds_xfrac; - _yfrac = ds_yfrac; - _xstep = ds_xstep; - _ystep = ds_ystep; - _x1 = ds_x1; - _x2 = ds_x2; - _y = ds_y; - _xbits = ds_xbits; - _ybits = ds_ybits; - _destorg = dc_destorg; - _light = ds_light; - _shade_constants = ds_shade_constants; - _nearest_filter = !SampleBgra::span_sampler_setup(_source, _xbits, _ybits, _xstep, _ystep, ds_source_mipmapped); - } - - void Execute(DrawerThread *thread) override - { - if (thread->line_skipped_by_thread(_y)) - return; - - dsfixed_t xfrac; - dsfixed_t yfrac; - dsfixed_t xstep; - dsfixed_t ystep; - uint32_t* dest; - const uint32_t* source = _source; - int count; - int spot; - - xfrac = _xfrac; - yfrac = _yfrac; - - dest = ylookup[_y] + _x1 + (uint32_t*)_destorg; - - count = _x2 - _x1 + 1; - - xstep = _xstep; - ystep = _ystep; - - uint32_t light = LightBgra::calc_light_multiplier(_light); - ShadeConstants shade_constants = _shade_constants; - - if (_nearest_filter) - { - if (_xbits == 6 && _ybits == 6) - { - // 64x64 is the most common case by far, so special case it. - - int sse_count = count / 4; - count -= sse_count * 4; - - if (shade_constants.simple_shade) - { - VEC_SHADE_VARS(); - VEC_SHADE_SIMPLE_INIT(light); - - while (sse_count--) - { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p0 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p1 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p2 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p3 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - VEC_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - - // Next step in u,v. - dest += 4; - } - } - else - { - VEC_SHADE_VARS(); - VEC_SHADE_INIT(light, shade_constants); - - while (sse_count--) - { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p0 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p1 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p2 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t p3 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - // Lookup pixel from flat texture tile, - // re-index using light/colormap. - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - VEC_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - - // Next step in u,v. - dest += 4; - } - } - - if (count == 0) - return; - - do - { - // Current texture index in u,v. - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - - // Lookup pixel from flat texture tile - *dest++ = LightBgra::shade_bgra(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - else - { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; - - int sse_count = count / 4; - count -= sse_count * 4; - - if (shade_constants.simple_shade) - { - VEC_SHADE_VARS(); - VEC_SHADE_SIMPLE_INIT(light); - - while (sse_count--) - { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p0 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p1 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p2 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p3 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - // Lookup pixel from flat texture tile - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - VEC_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += 4; - } - } - else - { - VEC_SHADE_VARS(); - VEC_SHADE_INIT(light, shade_constants); - - while (sse_count--) - { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p0 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p1 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p2 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t p3 = source[spot]; - xfrac += xstep; - yfrac += ystep; - - // Lookup pixel from flat texture tile - __m128i fg = _mm_set_epi32(p3, p2, p1, p0); - VEC_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - dest += 4; - } - } - - if (count == 0) - return; - - do - { - // Current texture index in u,v. - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - - // Lookup pixel from flat texture tile - *dest++ = LightBgra::shade_bgra(source[spot], light, shade_constants); - - // Next step in u,v. - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - } - else - { - if (_xbits == 6 && _ybits == 6) - { - // 64x64 is the most common case by far, so special case it. - - int sse_count = count / 4; - count -= sse_count * 4; - - if (shade_constants.simple_shade) - { - VEC_SHADE_VARS(); - VEC_SHADE_SIMPLE_INIT(light); - while (sse_count--) - { - __m128i fg; - VEC_SAMPLE_BILINEAR4_SPAN(fg, source, xfrac, yfrac, xstep, ystep, 26, 26); - VEC_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += 4; - } - } - else - { - VEC_SHADE_VARS(); - VEC_SHADE_INIT(light, shade_constants); - while (sse_count--) - { - __m128i fg; - VEC_SAMPLE_BILINEAR4_SPAN(fg, source, xfrac, yfrac, xstep, ystep, 26, 26); - VEC_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - dest += 4; - } - } - - if (count == 0) - return; - - do - { - *dest++ = LightBgra::shade_bgra(SampleBgra::sample_bilinear(source, xfrac, yfrac, 26, 26), light, shade_constants); - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - else - { - int sse_count = count / 4; - count -= sse_count * 4; - - if (shade_constants.simple_shade) - { - VEC_SHADE_VARS(); - VEC_SHADE_SIMPLE_INIT(light); - while (sse_count--) - { - __m128i fg; - int tmpx = 32 - _xbits; - int tmpy = 32 - _ybits; - VEC_SAMPLE_BILINEAR4_SPAN(fg, source, xfrac, yfrac, xstep, ystep, tmpx, tmpy); - VEC_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - dest += 4; - } - } - else - { - VEC_SHADE_VARS(); - VEC_SHADE_INIT(light, shade_constants); - while (sse_count--) - { - __m128i fg; - int tmpx = 32 - _xbits; - int tmpy = 32 - _ybits; - VEC_SAMPLE_BILINEAR4_SPAN(fg, source, xfrac, yfrac, xstep, ystep, tmpx, tmpy); - VEC_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - dest += 4; - } - } - - if (count == 0) - return; - - do - { - *dest++ = LightBgra::shade_bgra(SampleBgra::sample_bilinear(source, xfrac, yfrac, 32 - _xbits, 32 - _ybits), light, shade_constants); - xfrac += xstep; - yfrac += ystep; - } while (--count); - } - } - } -}; From f9795a25334f0deff827f17b29dac0158cbf5c34 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Mon, 3 Oct 2016 21:39:15 -0400 Subject: [PATCH 1030/1509] Revert "Remove linear sky again" This reverts commit 21390e91b8a28c71ba44bf62ee3c7545508a74e2. - also set r_linearsky to "false" by default. --- src/r_plane.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 0cfd51ca5..cfc30e1c7 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -859,16 +859,30 @@ static DWORD lastskycol_bgra[4]; static int skycolplace; static int skycolplace_bgra; +CVAR(Bool, r_linearsky, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); + // Get a column of sky when there is only one sky texture. static const BYTE *R_GetOneSkyColumn (FTexture *fronttex, int x) { - angle_t column = (skyangle + xtoviewangle[x]) ^ skyflip; - int tx = (UMulScale16(column, frontcyl) + frontpos) >> FRACBITS; + int tx; + if (r_linearsky) + { + angle_t xangle = (angle_t)((0.5 - x / (double)viewwidth) * FocalTangent * ANGLE_90); + angle_t column = (skyangle + xangle) ^ skyflip; + tx = (UMulScale16(column, frontcyl) + frontpos) >> FRACBITS; + } + else + { + angle_t column = (skyangle + xtoviewangle[x]) ^ skyflip; + tx = (UMulScale16(column, frontcyl) + frontpos) >> FRACBITS; + } if (!r_swtruecolor) return fronttex->GetColumn(tx, NULL); else + { return (const BYTE *)fronttex->GetColumnBgra(tx, NULL); + } } // Get a column of sky when there are two overlapping sky textures From b9a644e7622a10eea4c72a50f3108aa917948718 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Mon, 3 Oct 2016 21:41:37 -0400 Subject: [PATCH 1031/1509] Added menu option for Linear sky. --- wadsrc/static/menudef.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 589407262..4a1146269 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -690,6 +690,7 @@ OptionMenu "VideoOptions" } Option "$DSPLYMNU_STRETCHSKY", "r_stretchsky", "OnOff" + Option "$DSPLYMNU_LINEARSKY", "r_linearsky", "OnOff" Option "$DSPLYMNU_DRAWFUZZ", "r_drawfuzz", "Fuzziness" Slider "$DSPLYMNU_TRANSSOUL", "transsouls", 0.25, 1.0, 0.05, 2 Option "$DSPLYMNU_FAKECONTRAST", "r_fakecontrast", "Contrast" From 4d1ea5c47727b1213015fd42cc2961b4159a1e63 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Mon, 3 Oct 2016 21:52:25 -0400 Subject: [PATCH 1032/1509] Added language entry for Linear skies. (oops) --- wadsrc/static/language.enu | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 89b38329c..9aa3b7439 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1789,6 +1789,7 @@ DSPLYMNU_SHOWENDOOM = "Show ENDOOM screen"; DSPLYMNU_PALLETEHACK = "DirectDraw palette hack"; // Not used DSPLYMNU_ATTACHEDSURFACES = "Use attached surfaces"; // Not used DSPLYMNU_STRETCHSKY = "Stretch short skies"; +DSPLYMNU_LINEARSKY = "Linear skies"; DSPLYMNU_DRAWFUZZ = "Use fuzz effect"; DSPLYMNU_TRANSSOUL = "Lost Soul translucency"; DSPLYMNU_FAKECONTRAST = "Use fake contrast"; From 0e9f808c8a3000b376aa607a987a8d96a969a45f Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Tue, 4 Oct 2016 10:04:33 -0500 Subject: [PATCH 1033/1509] Fixed: FLATSPRITES were drawn backwards. --- src/gl/scene/gl_sprite.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index ab88f2f9c..e9748fba6 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -138,10 +138,10 @@ void GLSprite::CalculateVertices(FVector3 *v) mat.Rotate(0, 1, 0, - actor->Angles.Roll.Degrees); mat.Translate(-x, -z, -y); } - v[0] = mat * FVector3(x1, z, y2); - v[1] = mat * FVector3(x2, z, y2); - v[2] = mat * FVector3(x1, z, y1); - v[3] = mat * FVector3(x2, z, y1); + v[0] = mat * FVector3(x2, z, y2); + v[1] = mat * FVector3(x1, z, y2); + v[2] = mat * FVector3(x2, z, y1); + v[3] = mat * FVector3(x1, z, y1); return; } From 490dd612b3d662b4f190f34dc37e4367fddedc61 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 5 Oct 2016 03:56:58 +0200 Subject: [PATCH 1034/1509] Keep using render buffers when ssao is off, for better performance --- src/gl/renderer/gl_renderbuffers.cpp | 91 ++++++++++++++++++++-------- src/gl/renderer/gl_renderbuffers.h | 4 +- 2 files changed, 70 insertions(+), 25 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 54d597c4d..9915b024c 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -83,9 +83,18 @@ void FGLRenderBuffers::ClearScene() { DeleteFrameBuffer(mSceneFB); DeleteFrameBuffer(mSceneDataFB); - DeleteTexture(mSceneMultisample); - DeleteTexture(mSceneData); - DeleteTexture(mSceneDepthStencil); + if (mSceneUsesTextures) + { + DeleteTexture(mSceneMultisample); + DeleteTexture(mSceneData); + DeleteTexture(mSceneDepthStencil); + } + else + { + DeleteRenderBuffer(mSceneMultisample); + DeleteRenderBuffer(mSceneData); + DeleteRenderBuffer(mSceneDepthStencil); + } } void FGLRenderBuffers::ClearPipeline() @@ -188,6 +197,7 @@ bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei I_FatalError("Requested invalid render buffer sizes: screen = %dx%d", width, height); int samples = clamp((int)gl_multisample, 0, mMaxSamples); + bool needsSceneTextures = (gl_ssao != 0); GLint activeTex; GLint textureBinding; @@ -195,19 +205,16 @@ bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei glActiveTexture(GL_TEXTURE0); glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); - if (width == mWidth && height == mHeight && mSamples != samples) - { - CreateScene(mWidth, mHeight, samples); - mSamples = samples; - } - else if (width != mWidth || height != mHeight) - { + if (width != mWidth || height != mHeight) CreatePipeline(width, height); - CreateScene(width, height, samples); - mWidth = width; - mHeight = height; - mSamples = samples; - } + + if (width != mWidth || height != mHeight || mSamples != samples || mSceneUsesTextures != needsSceneTextures) + CreateScene(width, height, samples, needsSceneTextures); + + mWidth = width; + mHeight = height; + mSamples = samples; + mSceneUsesTextures = needsSceneTextures; // Bloom bluring buffers need to match the scene to avoid bloom bleeding artifacts if (mSceneWidth != sceneWidth || mSceneHeight != sceneHeight) @@ -247,24 +254,44 @@ bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei // //========================================================================== -void FGLRenderBuffers::CreateScene(int width, int height, int samples) +void FGLRenderBuffers::CreateScene(int width, int height, int samples, bool needsSceneTextures) { ClearScene(); if (samples > 1) { - mSceneMultisample = Create2DMultisampleTexture("SceneMultisample", GL_RGBA16F, width, height, samples, false); - mSceneDepthStencil = Create2DMultisampleTexture("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height, samples, false); - mSceneData = Create2DMultisampleTexture("SceneSSAOData", GL_RGBA8, width, height, samples, false); + if (needsSceneTextures) + { + mSceneMultisample = Create2DMultisampleTexture("SceneMultisample", GL_RGBA16F, width, height, samples, false); + mSceneDepthStencil = Create2DMultisampleTexture("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height, samples, false); + mSceneData = Create2DMultisampleTexture("SceneSSAOData", GL_RGBA8, width, height, samples, false); + mSceneFB = CreateFrameBuffer("SceneFB", mSceneMultisample, 0, mSceneDepthStencil, true); + mSceneDataFB = CreateFrameBuffer("SSAOSceneFB", mSceneMultisample, mSceneData, mSceneDepthStencil, true); + } + else + { + mSceneMultisample = CreateRenderBuffer("SceneMultisample", GL_RGBA16F, width, height, samples); + mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height, samples); + mSceneFB = CreateFrameBuffer("SceneFB", mSceneMultisample, mSceneDepthStencil, true); + mSceneDataFB = CreateFrameBuffer("SSAOSceneFB", mSceneMultisample, mSceneDepthStencil, true); + } } else { - mSceneDepthStencil = Create2DTexture("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height); - mSceneData = Create2DTexture("SceneSSAOData", GL_RGBA8, width, height); + if (needsSceneTextures) + { + mSceneDepthStencil = Create2DTexture("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height); + mSceneData = Create2DTexture("SceneSSAOData", GL_RGBA8, width, height); + mSceneFB = CreateFrameBuffer("SceneFB", mPipelineTexture[0], 0, mSceneDepthStencil, false); + mSceneDataFB = CreateFrameBuffer("SSAOSceneFB", mPipelineTexture[0], mSceneData, mSceneDepthStencil, false); + } + else + { + mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height); + mSceneFB = CreateFrameBuffer("SceneFB", mPipelineTexture[0], mSceneDepthStencil, false); + mSceneDataFB = CreateFrameBuffer("SSAOSceneFB", mPipelineTexture[0], mSceneDepthStencil, false); + } } - - mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], 0, mSceneDepthStencil, samples > 1); - mSceneDataFB = CreateFrameBuffer("SSAOSceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneData, mSceneDepthStencil, samples > 1); } //========================================================================== @@ -517,6 +544,22 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff return handle; } +GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer) +{ + GLuint handle = 0; + glGenFramebuffers(1, &handle); + glBindFramebuffer(GL_FRAMEBUFFER, handle); + FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); + if (colorIsARenderBuffer) + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); + else + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil); + if (CheckFrameBufferCompleteness()) + ClearFrameBuffer(true, true); + return handle; +} + GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer0, GLuint colorbuffer1, GLuint depthstencil, bool multisample) { GLuint handle = 0; diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 2ca58149f..3fcc2c07b 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -81,7 +81,7 @@ private: void ClearBloom(); void ClearExposureLevels(); void ClearAmbientOcclusion(); - void CreateScene(int width, int height, int samples); + void CreateScene(int width, int height, int samples, bool needsSceneTextures); void CreatePipeline(int width, int height); void CreateBloom(int width, int height); void CreateExposureLevels(int width, int height); @@ -92,6 +92,7 @@ private: GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height); GLuint CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer); + GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer0, GLuint colorbuffer1, GLuint depthstencil, bool multisample); bool CheckFrameBufferCompleteness(); void ClearFrameBuffer(bool stencil, bool depth); @@ -115,6 +116,7 @@ private: GLuint mSceneData = 0; GLuint mSceneFB = 0; GLuint mSceneDataFB = 0; + bool mSceneUsesTextures = false; // Effect/HUD buffers GLuint mPipelineTexture[NumPipelineTextures]; From 00e72028efd9145eb54704fa974c57d2034b7cec Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 5 Oct 2016 07:57:27 +0200 Subject: [PATCH 1035/1509] Add another gbuffer with normal data and make ssao pass use it --- src/gl/renderer/gl_postprocess.cpp | 58 ++++++----- src/gl/renderer/gl_postprocessstate.cpp | 55 +++++----- src/gl/renderer/gl_postprocessstate.h | 7 +- src/gl/renderer/gl_renderbuffers.cpp | 54 +++++++--- src/gl/renderer/gl_renderbuffers.h | 8 +- src/gl/scene/gl_scene.cpp | 8 +- src/gl/shaders/gl_ambientshader.cpp | 121 +++++++++++++--------- src/gl/shaders/gl_ambientshader.h | 45 ++++---- src/gl/shaders/gl_shader.cpp | 3 +- src/gl/system/gl_cvars.h | 2 +- wadsrc/static/shaders/glsl/main.fp | 6 +- wadsrc/static/shaders/glsl/ssao.fp | 23 +++- wadsrc/static/shaders/glsl/ssaocombine.fp | 12 +-- 13 files changed, 241 insertions(+), 161 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index fde8da353..ac5a6336d 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -121,7 +121,7 @@ CUSTOM_CVAR(Int, gl_ssao_portals, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) } CVAR(Float, gl_ssao_strength, 0.7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -CVAR(Bool, gl_ssao_debug, false, 0) +CVAR(Int, gl_ssao_debug, 0, 0) CVAR(Float, gl_ssao_bias, 0.5f, 0) CVAR(Float, gl_ssao_radius, 100.0f, 0) CUSTOM_CVAR(Float, gl_ssao_blur_amount, 4.0f, 0) @@ -162,13 +162,12 @@ void FGLRenderer::AmbientOccludeScene() FGLDebug::PushGroup("AmbientOccludeScene"); FGLPostProcessState savedState; - savedState.SaveTextureBinding1(); + savedState.SaveTextureBindings(3); float bias = gl_ssao_bias; float aoRadius = gl_ssao_radius; const float blurAmount = gl_ssao_blur_amount; float aoStrength = gl_ssao_strength; - bool multisample = gl_multisample > 1; //float tanHalfFovy = tan(fovy * (M_PI / 360.0f)); float tanHalfFovy = 1.0f / gl_RenderState.mProjectionMatrix.get()[5]; @@ -189,16 +188,16 @@ void FGLRenderer::AmbientOccludeScene() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glActiveTexture(GL_TEXTURE0); - mLinearDepthShader->Bind(multisample); - mLinearDepthShader->DepthTexture[multisample].Set(0); - mLinearDepthShader->ColorTexture[multisample].Set(1); - if (multisample) mLinearDepthShader->SampleCount[multisample].Set(gl_multisample); - mLinearDepthShader->LinearizeDepthA[multisample].Set(1.0f / GetZFar() - 1.0f / GetZNear()); - mLinearDepthShader->LinearizeDepthB[multisample].Set(MAX(1.0f / GetZNear(), 1.e-8f)); - mLinearDepthShader->InverseDepthRangeA[multisample].Set(1.0f); - mLinearDepthShader->InverseDepthRangeB[multisample].Set(0.0f); - mLinearDepthShader->Scale[multisample].Set(mBuffers->AmbientWidth * 2.0f / (float)mScreenViewport.width, mBuffers->AmbientHeight * 2.0f / (float)mScreenViewport.height); - mLinearDepthShader->Offset[multisample].Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); + mLinearDepthShader->Bind(); + mLinearDepthShader->DepthTexture.Set(0); + mLinearDepthShader->ColorTexture.Set(1); + if (gl_multisample > 1) mLinearDepthShader->SampleCount.Set(gl_multisample); + mLinearDepthShader->LinearizeDepthA.Set(1.0f / GetZFar() - 1.0f / GetZNear()); + mLinearDepthShader->LinearizeDepthB.Set(MAX(1.0f / GetZNear(), 1.e-8f)); + mLinearDepthShader->InverseDepthRangeA.Set(1.0f); + mLinearDepthShader->InverseDepthRangeB.Set(0.0f); + mLinearDepthShader->Scale.Set(mBuffers->AmbientWidth * 2.0f / (float)mScreenViewport.width, mBuffers->AmbientHeight * 2.0f / (float)mScreenViewport.height); + mLinearDepthShader->Offset.Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); RenderScreenQuad(); // Apply ambient occlusion @@ -212,10 +211,14 @@ void FGLRenderer::AmbientOccludeScene() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + mBuffers->BindSceneNormalTexture(2); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glActiveTexture(GL_TEXTURE0); mSSAOShader->Bind(); mSSAOShader->DepthTexture.Set(0); mSSAOShader->RandomTexture.Set(1); + mSSAOShader->NormalTexture.Set(2); mSSAOShader->UVToViewA.Set(2.0f * invFocalLenX, -2.0f * invFocalLenY); mSSAOShader->UVToViewB.Set(-invFocalLenX, invFocalLenY); mSSAOShader->InvFullResolution.Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); @@ -246,26 +249,29 @@ void FGLRenderer::AmbientOccludeScene() // Add SSAO back to scene texture: mBuffers->BindSceneFB(false); - GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; - glDrawBuffers(1, buffers); glViewport(mSceneViewport.left, mSceneViewport.top, mSceneViewport.width, mSceneViewport.height); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); - if (gl_ssao_debug) + if (gl_ssao_debug > 1) glBlendFunc(GL_ONE, GL_ZERO); else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + if (gl_ssao_debug == 1) + { + glClearColor(1.0f, 1.0f, 1.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + } glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - mBuffers->BindSceneDataTexture(1); - mSSAOCombineShader->Bind(multisample); - mSSAOCombineShader->AODepthTexture[multisample].Set(0); - mSSAOCombineShader->SceneDataTexture[multisample].Set(1); - if (multisample) mSSAOCombineShader->SampleCount[multisample].Set(gl_multisample); - mSSAOCombineShader->Scale[multisample].Set(mBuffers->AmbientWidth * 2.0f / (float)mScreenViewport.width, mBuffers->AmbientHeight * 2.0f / (float)mScreenViewport.height); - mSSAOCombineShader->Offset[multisample].Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); + mBuffers->BindSceneFogTexture(1); + mSSAOCombineShader->Bind(); + mSSAOCombineShader->AODepthTexture.Set(0); + mSSAOCombineShader->SceneFogTexture.Set(1); + if (gl_multisample > 1) mSSAOCombineShader->SampleCount.Set(gl_multisample); + mSSAOCombineShader->Scale.Set(mBuffers->AmbientWidth * 2.0f / (float)mScreenViewport.width, mBuffers->AmbientHeight * 2.0f / (float)mScreenViewport.height); + mSSAOCombineShader->Offset.Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); RenderScreenQuad(); FGLDebug::PopGroup(); @@ -285,7 +291,7 @@ void FGLRenderer::UpdateCameraExposure() FGLDebug::PushGroup("UpdateCameraExposure"); FGLPostProcessState savedState; - savedState.SaveTextureBinding1(); + savedState.SaveTextureBindings(2); // Extract light level from scene texture: const auto &level0 = mBuffers->ExposureLevels[0]; @@ -358,7 +364,7 @@ void FGLRenderer::BloomScene() FGLDebug::PushGroup("BloomScene"); FGLPostProcessState savedState; - savedState.SaveTextureBinding1(); + savedState.SaveTextureBindings(2); const float blurAmount = gl_bloom_amount; int sampleCount = gl_bloom_kernel_size; @@ -461,7 +467,7 @@ void FGLRenderer::TonemapScene() } else { - savedState.SaveTextureBinding1(); + savedState.SaveTextureBindings(2); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, mBuffers->ExposureTexture); glActiveTexture(GL_TEXTURE0); diff --git a/src/gl/renderer/gl_postprocessstate.cpp b/src/gl/renderer/gl_postprocessstate.cpp index 57b7862f5..fead1435a 100644 --- a/src/gl/renderer/gl_postprocessstate.cpp +++ b/src/gl/renderer/gl_postprocessstate.cpp @@ -45,17 +45,7 @@ FGLPostProcessState::FGLPostProcessState() { glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); glActiveTexture(GL_TEXTURE0); - glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding[0]); - glBindTexture(GL_TEXTURE_2D, 0); - if (gl.flags & RFL_SAMPLER_OBJECTS) - { - glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding[0]); - glBindSampler(0, 0); - glActiveTexture(GL_TEXTURE0 + 1); - glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding[1]); - glBindSampler(1, 0); - glActiveTexture(GL_TEXTURE0); - } + SaveTextureBindings(1); glGetBooleanv(GL_BLEND, &blendEnabled); glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); @@ -75,12 +65,26 @@ FGLPostProcessState::FGLPostProcessState() glDisable(GL_BLEND); } -void FGLPostProcessState::SaveTextureBinding1() +void FGLPostProcessState::SaveTextureBindings(unsigned int numUnits) { - glActiveTexture(GL_TEXTURE1); - glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding[1]); - glBindTexture(GL_TEXTURE_2D, 0); - textureBinding1Saved = true; + while (textureBinding.Size() < numUnits) + { + unsigned int i = textureBinding.Size(); + + GLint texture; + glActiveTexture(GL_TEXTURE0 + i); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &texture); + glBindTexture(GL_TEXTURE_2D, 0); + textureBinding.Push(texture); + + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + GLint sampler; + glGetIntegerv(GL_SAMPLER_BINDING, &sampler); + glBindSampler(i, 0); + samplerBinding.Push(sampler); + } + } glActiveTexture(GL_TEXTURE0); } @@ -117,25 +121,22 @@ FGLPostProcessState::~FGLPostProcessState() glUseProgram(currentProgram); - if (textureBinding1Saved) + // Fully unbind to avoid incomplete texture warnings from Nvidia's driver when gl_debug_level 4 is active + for (unsigned int i = 0; i < textureBinding.Size(); i++) { - glActiveTexture(GL_TEXTURE1); + glActiveTexture(GL_TEXTURE0 + i); glBindTexture(GL_TEXTURE_2D, 0); } - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, 0); - if (gl.flags & RFL_SAMPLER_OBJECTS) + for (unsigned int i = 0; i < samplerBinding.Size(); i++) { - glBindSampler(0, samplerBinding[0]); - glBindSampler(1, samplerBinding[1]); + glBindSampler(i, samplerBinding[i]); } - glBindTexture(GL_TEXTURE_2D, textureBinding[0]); - if (textureBinding1Saved) + for (unsigned int i = 0; i < textureBinding.Size(); i++) { - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, textureBinding[1]); + glActiveTexture(GL_TEXTURE0 + i); + glBindTexture(GL_TEXTURE_2D, textureBinding[i]); } glActiveTexture(activeTex); diff --git a/src/gl/renderer/gl_postprocessstate.h b/src/gl/renderer/gl_postprocessstate.h index bf53aa7de..795a7d4ba 100644 --- a/src/gl/renderer/gl_postprocessstate.h +++ b/src/gl/renderer/gl_postprocessstate.h @@ -14,15 +14,15 @@ public: FGLPostProcessState(); ~FGLPostProcessState(); - void SaveTextureBinding1(); + void SaveTextureBindings(unsigned int numUnits); private: FGLPostProcessState(const FGLPostProcessState &) = delete; FGLPostProcessState &operator=(const FGLPostProcessState &) = delete; GLint activeTex; - GLint textureBinding[2]; - GLint samplerBinding[2]; + TArray textureBinding; + TArray samplerBinding; GLboolean blendEnabled; GLboolean scissorEnabled; GLboolean depthEnabled; @@ -34,7 +34,6 @@ private: GLint blendSrcAlpha; GLint blendDestRgb; GLint blendDestAlpha; - bool textureBinding1Saved = false; }; #endif diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 9915b024c..1a1509d7a 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -86,13 +86,15 @@ void FGLRenderBuffers::ClearScene() if (mSceneUsesTextures) { DeleteTexture(mSceneMultisample); - DeleteTexture(mSceneData); + DeleteTexture(mSceneFog); + DeleteTexture(mSceneNormal); DeleteTexture(mSceneDepthStencil); } else { DeleteRenderBuffer(mSceneMultisample); - DeleteRenderBuffer(mSceneData); + DeleteRenderBuffer(mSceneFog); + DeleteRenderBuffer(mSceneNormal); DeleteRenderBuffer(mSceneDepthStencil); } } @@ -264,16 +266,17 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples, bool need { mSceneMultisample = Create2DMultisampleTexture("SceneMultisample", GL_RGBA16F, width, height, samples, false); mSceneDepthStencil = Create2DMultisampleTexture("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height, samples, false); - mSceneData = Create2DMultisampleTexture("SceneSSAOData", GL_RGBA8, width, height, samples, false); - mSceneFB = CreateFrameBuffer("SceneFB", mSceneMultisample, 0, mSceneDepthStencil, true); - mSceneDataFB = CreateFrameBuffer("SSAOSceneFB", mSceneMultisample, mSceneData, mSceneDepthStencil, true); + mSceneFog = Create2DMultisampleTexture("SceneFog", GL_RGBA8, width, height, samples, false); + mSceneNormal = Create2DMultisampleTexture("SceneNormal", GL_RGB10_A2, width, height, samples, false); + mSceneFB = CreateFrameBuffer("SceneFB", mSceneMultisample, 0, 0, mSceneDepthStencil, true); + mSceneDataFB = CreateFrameBuffer("SceneGBufferFB", mSceneMultisample, mSceneFog, mSceneNormal, mSceneDepthStencil, true); } else { mSceneMultisample = CreateRenderBuffer("SceneMultisample", GL_RGBA16F, width, height, samples); mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height, samples); mSceneFB = CreateFrameBuffer("SceneFB", mSceneMultisample, mSceneDepthStencil, true); - mSceneDataFB = CreateFrameBuffer("SSAOSceneFB", mSceneMultisample, mSceneDepthStencil, true); + mSceneDataFB = CreateFrameBuffer("SceneGBufferFB", mSceneMultisample, mSceneDepthStencil, true); } } else @@ -281,15 +284,16 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples, bool need if (needsSceneTextures) { mSceneDepthStencil = Create2DTexture("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height); - mSceneData = Create2DTexture("SceneSSAOData", GL_RGBA8, width, height); - mSceneFB = CreateFrameBuffer("SceneFB", mPipelineTexture[0], 0, mSceneDepthStencil, false); - mSceneDataFB = CreateFrameBuffer("SSAOSceneFB", mPipelineTexture[0], mSceneData, mSceneDepthStencil, false); + mSceneFog = Create2DTexture("SceneFog", GL_RGBA8, width, height); + mSceneNormal = Create2DTexture("SceneNormal", GL_RGB10_A2, width, height); + mSceneFB = CreateFrameBuffer("SceneFB", mPipelineTexture[0], 0, 0, mSceneDepthStencil, false); + mSceneDataFB = CreateFrameBuffer("SceneGBufferFB", mPipelineTexture[0], mSceneFog, mSceneNormal, mSceneDepthStencil, false); } else { mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height); mSceneFB = CreateFrameBuffer("SceneFB", mPipelineTexture[0], mSceneDepthStencil, false); - mSceneDataFB = CreateFrameBuffer("SSAOSceneFB", mPipelineTexture[0], mSceneDepthStencil, false); + mSceneDataFB = CreateFrameBuffer("SceneGBufferFB", mPipelineTexture[0], mSceneDepthStencil, false); } } } @@ -471,6 +475,7 @@ GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int case GL_RGBA32F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; case GL_R32F: dataformat = GL_RED; datatype = GL_FLOAT; break; case GL_RG32F: dataformat = GL_RG; datatype = GL_FLOAT; break; + case GL_RGB10_A2: dataformat = GL_RGBA; datatype = GL_UNSIGNED_INT_10_10_10_2; break; case GL_DEPTH_COMPONENT24: dataformat = GL_DEPTH_COMPONENT; datatype = GL_FLOAT; break; case GL_STENCIL_INDEX8: dataformat = GL_STENCIL_INDEX; datatype = GL_INT; break; case GL_DEPTH24_STENCIL8: dataformat = GL_DEPTH_STENCIL; datatype = GL_UNSIGNED_INT_24_8; break; @@ -560,7 +565,7 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff return handle; } -GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer0, GLuint colorbuffer1, GLuint depthstencil, bool multisample) +GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer0, GLuint colorbuffer1, GLuint colorbuffer2, GLuint depthstencil, bool multisample) { GLuint handle = 0; glGenFramebuffers(1, &handle); @@ -571,6 +576,8 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, colorbuffer0, 0); if (colorbuffer1 != 0) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D_MULTISAMPLE, colorbuffer1, 0); + if (colorbuffer2 != 0) + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D_MULTISAMPLE, colorbuffer2, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D_MULTISAMPLE, depthstencil, 0); } else @@ -578,6 +585,8 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer0, 0); if (colorbuffer1 != 0) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, colorbuffer1, 0); + if (colorbuffer2 != 0) + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, colorbuffer2, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthstencil, 0); } if (CheckFrameBufferCompleteness()) @@ -742,17 +751,32 @@ void FGLRenderBuffers::BindSceneColorTexture(int index) //========================================================================== // -// Binds the scene data texture to the specified texture unit +// Binds the scene fog data texture to the specified texture unit // //========================================================================== -void FGLRenderBuffers::BindSceneDataTexture(int index) +void FGLRenderBuffers::BindSceneFogTexture(int index) { glActiveTexture(GL_TEXTURE0 + index); if (mSamples > 1) - glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mSceneData); + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mSceneFog); else - glBindTexture(GL_TEXTURE_2D, mSceneData); + glBindTexture(GL_TEXTURE_2D, mSceneFog); +} + +//========================================================================== +// +// Binds the scene normal data texture to the specified texture unit +// +//========================================================================== + +void FGLRenderBuffers::BindSceneNormalTexture(int index) +{ + glActiveTexture(GL_TEXTURE0 + index); + if (mSamples > 1) + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mSceneNormal); + else + glBindTexture(GL_TEXTURE_2D, mSceneNormal); } //========================================================================== diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 3fcc2c07b..9508f7009 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -34,7 +34,8 @@ public: void BindSceneFB(bool sceneData); void BindSceneColorTexture(int index); - void BindSceneDataTexture(int index); + void BindSceneFogTexture(int index); + void BindSceneNormalTexture(int index); void BindSceneDepthTexture(int index); void BlitSceneToTexture(); @@ -93,7 +94,7 @@ private: GLuint CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer); - GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer0, GLuint colorbuffer1, GLuint depthstencil, bool multisample); + GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer0, GLuint colorbuffer1, GLuint colorbuffer2, GLuint depthstencil, bool multisample); bool CheckFrameBufferCompleteness(); void ClearFrameBuffer(bool stencil, bool depth); void DeleteTexture(GLuint &handle); @@ -113,7 +114,8 @@ private: // Buffers for the scene GLuint mSceneMultisample = 0; GLuint mSceneDepthStencil = 0; - GLuint mSceneData = 0; + GLuint mSceneFog = 0; + GLuint mSceneNormal = 0; GLuint mSceneFB = 0; GLuint mSceneDataFB = 0; bool mSceneUsesTextures = false; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index b6120f940..13b210d91 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -160,8 +160,8 @@ void FGLRenderer::Set3DViewport(bool mainview) { bool useSSAO = (gl_ssao != 0); mBuffers->BindSceneFB(useSSAO); - GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; - glDrawBuffers(useSSAO ? 2 : 1, buffers); + GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 }; + glDrawBuffers(useSSAO ? 3 : 1, buffers); gl_RenderState.SetPassType(useSSAO ? GBUFFER_PASS : NORMAL_PASS); gl_RenderState.Apply(); } @@ -507,8 +507,8 @@ void FGLRenderer::DrawScene(int drawmode) // If SSAO is active, switch to gbuffer shaders and use the framebuffer with gbuffers if (applySSAO) { - GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; - glDrawBuffers(2, buffers); + GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 }; + glDrawBuffers(3, buffers); gl_RenderState.SetPassType(GBUFFER_PASS); gl_RenderState.Apply(); gl_RenderState.ApplyMatrices(); diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index 43adb5c0e..6348d24cd 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -31,54 +31,65 @@ #include "gl/system/gl_cvars.h" #include "gl/shaders/gl_ambientshader.h" -void FLinearDepthShader::Bind(bool multisample) +void FLinearDepthShader::Bind() { - auto &shader = mShader[multisample]; - if (!shader) + bool multisample = (gl_multisample > 1); + if (mMultisample != multisample) + mShader.reset(); + + if (!mShader) { - shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); - shader.Compile(FShaderProgram::Fragment, "shaders/glsl/lineardepth.fp", multisample ? "#define MULTISAMPLE\n" : "", 330); - shader.SetFragDataLocation(0, "FragColor"); - shader.Link("shaders/glsl/lineardepth"); - shader.SetAttribLocation(0, "PositionInProjection"); - DepthTexture[multisample].Init(shader, "DepthTexture"); - ColorTexture[multisample].Init(shader, "ColorTexture"); - SampleCount[multisample].Init(shader, "SampleCount"); - LinearizeDepthA[multisample].Init(shader, "LinearizeDepthA"); - LinearizeDepthB[multisample].Init(shader, "LinearizeDepthB"); - InverseDepthRangeA[multisample].Init(shader, "InverseDepthRangeA"); - InverseDepthRangeB[multisample].Init(shader, "InverseDepthRangeB"); - Scale[multisample].Init(shader, "Scale"); - Offset[multisample].Init(shader, "Offset"); + mShader = std::make_unique(); + mShader->Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader->Compile(FShaderProgram::Fragment, "shaders/glsl/lineardepth.fp", multisample ? "#define MULTISAMPLE\n" : "", 330); + mShader->SetFragDataLocation(0, "FragColor"); + mShader->Link("shaders/glsl/lineardepth"); + mShader->SetAttribLocation(0, "PositionInProjection"); + DepthTexture.Init(*mShader, "DepthTexture"); + ColorTexture.Init(*mShader, "ColorTexture"); + SampleCount.Init(*mShader, "SampleCount"); + LinearizeDepthA.Init(*mShader, "LinearizeDepthA"); + LinearizeDepthB.Init(*mShader, "LinearizeDepthB"); + InverseDepthRangeA.Init(*mShader, "InverseDepthRangeA"); + InverseDepthRangeB.Init(*mShader, "InverseDepthRangeB"); + Scale.Init(*mShader, "Scale"); + Offset.Init(*mShader, "Offset"); + mMultisample = multisample; } - shader.Bind(); + mShader->Bind(); } void FSSAOShader::Bind() { - auto &shader = mShader[gl_ssao]; - if (!shader) + bool multisample = (gl_multisample > 1); + if (mCurrentQuality != gl_ssao || mMultisample != multisample) + mShader.reset(); + + if (!mShader) { - shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); - shader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssao.fp", GetDefines(gl_ssao), 330); - shader.SetFragDataLocation(0, "FragColor"); - shader.Link("shaders/glsl/ssao"); - shader.SetAttribLocation(0, "PositionInProjection"); - DepthTexture.Init(shader, "DepthTexture"); - RandomTexture.Init(shader, "RandomTexture"); - UVToViewA.Init(shader, "UVToViewA"); - UVToViewB.Init(shader, "UVToViewB"); - InvFullResolution.Init(shader, "InvFullResolution"); - NDotVBias.Init(shader, "NDotVBias"); - NegInvR2.Init(shader, "NegInvR2"); - RadiusToScreen.Init(shader, "RadiusToScreen"); - AOMultiplier.Init(shader, "AOMultiplier"); - AOStrength.Init(shader, "AOStrength"); + mShader = std::make_unique(); + mShader->Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader->Compile(FShaderProgram::Fragment, "shaders/glsl/ssao.fp", GetDefines(gl_ssao, multisample), 330); + mShader->SetFragDataLocation(0, "FragColor"); + mShader->Link("shaders/glsl/ssao"); + mShader->SetAttribLocation(0, "PositionInProjection"); + DepthTexture.Init(*mShader, "DepthTexture"); + NormalTexture.Init(*mShader, "NormalTexture"); + RandomTexture.Init(*mShader, "RandomTexture"); + UVToViewA.Init(*mShader, "UVToViewA"); + UVToViewB.Init(*mShader, "UVToViewB"); + InvFullResolution.Init(*mShader, "InvFullResolution"); + NDotVBias.Init(*mShader, "NDotVBias"); + NegInvR2.Init(*mShader, "NegInvR2"); + RadiusToScreen.Init(*mShader, "RadiusToScreen"); + AOMultiplier.Init(*mShader, "AOMultiplier"); + AOStrength.Init(*mShader, "AOStrength"); + mMultisample = multisample; } - shader.Bind(); + mShader->Bind(); } -FString FSSAOShader::GetDefines(int mode) +FString FSSAOShader::GetDefines(int mode, bool multisample) { int numDirections, numSteps; switch (gl_ssao) @@ -96,6 +107,9 @@ FString FSSAOShader::GetDefines(int mode) #define NUM_DIRECTIONS %d.0 #define NUM_STEPS %d.0 )", numDirections, numSteps); + + if (multisample) + defines += "\n#define MULTISAMPLE\n"; return defines; } @@ -117,21 +131,26 @@ void FDepthBlurShader::Bind(bool vertical) shader.Bind(); } -void FSSAOCombineShader::Bind(bool multisample) +void FSSAOCombineShader::Bind() { - auto &shader = mShader[multisample]; - if (!shader) + bool multisample = (gl_multisample > 1); + if (mMultisample != multisample) + mShader.reset(); + + if (!mShader) { - shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); - shader.Compile(FShaderProgram::Fragment, "shaders/glsl/ssaocombine.fp", multisample ? "#define MULTISAMPLE\n" : "", 330); - shader.SetFragDataLocation(0, "FragColor"); - shader.Link("shaders/glsl/ssaocombine"); - shader.SetAttribLocation(0, "PositionInProjection"); - AODepthTexture[multisample].Init(shader, "AODepthTexture"); - SceneDataTexture[multisample].Init(shader, "SceneDataTexture"); - SampleCount[multisample].Init(shader, "SampleCount"); - Scale[multisample].Init(shader, "Scale"); - Offset[multisample].Init(shader, "Offset"); + mShader = std::make_unique(); + mShader->Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader->Compile(FShaderProgram::Fragment, "shaders/glsl/ssaocombine.fp", multisample ? "#define MULTISAMPLE\n" : "", 330); + mShader->SetFragDataLocation(0, "FragColor"); + mShader->Link("shaders/glsl/ssaocombine"); + mShader->SetAttribLocation(0, "PositionInProjection"); + AODepthTexture.Init(*mShader, "AODepthTexture"); + SceneFogTexture.Init(*mShader, "SceneFogTexture"); + SampleCount.Init(*mShader, "SampleCount"); + Scale.Init(*mShader, "Scale"); + Offset.Init(*mShader, "Offset"); + mMultisample = multisample; } - shader.Bind(); + mShader->Bind(); } diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index 704729b24..5c68892c3 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -6,20 +6,21 @@ class FLinearDepthShader { public: - void Bind(bool multisample); + void Bind(); - FBufferedUniformSampler DepthTexture[2]; - FBufferedUniformSampler ColorTexture[2]; - FBufferedUniform1i SampleCount[2]; - FBufferedUniform1f LinearizeDepthA[2]; - FBufferedUniform1f LinearizeDepthB[2]; - FBufferedUniform1f InverseDepthRangeA[2]; - FBufferedUniform1f InverseDepthRangeB[2]; - FBufferedUniform2f Scale[2]; - FBufferedUniform2f Offset[2]; + FBufferedUniformSampler DepthTexture; + FBufferedUniformSampler ColorTexture; + FBufferedUniform1i SampleCount; + FBufferedUniform1f LinearizeDepthA; + FBufferedUniform1f LinearizeDepthB; + FBufferedUniform1f InverseDepthRangeA; + FBufferedUniform1f InverseDepthRangeB; + FBufferedUniform2f Scale; + FBufferedUniform2f Offset; private: - FShaderProgram mShader[2]; + std::unique_ptr mShader; + bool mMultisample = false; }; class FSSAOShader @@ -28,6 +29,7 @@ public: void Bind(); FBufferedUniformSampler DepthTexture; + FBufferedUniformSampler NormalTexture; FBufferedUniformSampler RandomTexture; FBufferedUniform2f UVToViewA; FBufferedUniform2f UVToViewB; @@ -48,9 +50,11 @@ private: NumQualityModes }; - FString GetDefines(int mode); + FString GetDefines(int mode, bool multisample); - FShaderProgram mShader[NumQualityModes]; + std::unique_ptr mShader; + Quality mCurrentQuality = Off; + bool mMultisample = false; }; class FDepthBlurShader @@ -70,16 +74,17 @@ private: class FSSAOCombineShader { public: - void Bind(bool multisample); + void Bind(); - FBufferedUniformSampler AODepthTexture[2]; - FBufferedUniformSampler SceneDataTexture[2]; - FBufferedUniform1i SampleCount[2]; - FBufferedUniform2f Scale[2]; - FBufferedUniform2f Offset[2]; + FBufferedUniformSampler AODepthTexture; + FBufferedUniformSampler SceneFogTexture; + FBufferedUniform1i SampleCount; + FBufferedUniform2f Scale; + FBufferedUniform2f Offset; private: - FShaderProgram mShader[2]; + std::unique_ptr mShader; + bool mMultisample = false; }; #endif \ No newline at end of file diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 9cbd69ce2..b7d8335f8 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -182,7 +182,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * glBindAttribLocation(hShader, VATTR_NORMAL, "aNormal"); glBindFragDataLocation(hShader, 0, "FragColor"); - glBindFragDataLocation(hShader, 1, "FragData"); + glBindFragDataLocation(hShader, 1, "FragFog"); + glBindFragDataLocation(hShader, 2, "FragNormal"); glLinkProgram(hShader); diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index 836787117..3b425d261 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -53,7 +53,7 @@ EXTERN_CVAR(Float, gl_lens_chromatic) EXTERN_CVAR(Int, gl_ssao) EXTERN_CVAR(Int, gl_ssao_portals) EXTERN_CVAR(Float, gl_ssao_strength) -EXTERN_CVAR(Bool, gl_ssao_debug) +EXTERN_CVAR(Int, gl_ssao_debug) EXTERN_CVAR(Float, gl_ssao_bias) EXTERN_CVAR(Float, gl_ssao_radius) EXTERN_CVAR(Float, gl_ssao_blur_amount) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 1f270728d..e26b2fd4a 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -8,7 +8,8 @@ in vec4 vColor; out vec4 FragColor; #ifdef GBUFFER_PASS -out vec4 FragData; +out vec4 FragFog; +out vec4 FragNormal; #endif #ifdef SHADER_STORAGE_LIGHTS @@ -408,7 +409,8 @@ void main() } FragColor = frag; #ifdef GBUFFER_PASS - FragData = vec4(AmbientOcclusionColor(), 1.0); + FragFog = vec4(AmbientOcclusionColor(), 1.0); + FragNormal = vec4(vEyeNormal.xyz * 0.5 + 0.5, 1.0); #endif } diff --git a/wadsrc/static/shaders/glsl/ssao.fp b/wadsrc/static/shaders/glsl/ssao.fp index e0d972c57..758f7dbaa 100644 --- a/wadsrc/static/shaders/glsl/ssao.fp +++ b/wadsrc/static/shaders/glsl/ssao.fp @@ -15,6 +15,12 @@ uniform float AOStrength; uniform sampler2D DepthTexture; +#if defined(MULTISAMPLE) +uniform sampler2DMS NormalTexture; +#else +uniform sampler2D NormalTexture; +#endif + #if defined(USE_RANDOM_TEXTURE) uniform sampler2D RandomTexture; #endif @@ -28,6 +34,20 @@ vec3 FetchViewPos(vec2 uv) return vec3((UVToViewA * uv + UVToViewB) * z, z); } +#if defined(MULTISAMPLE) +vec3 FetchNormal(vec2 uv) +{ + ivec2 texSize = textureSize(NormalTexture); + ivec2 ipos = ivec2(uv * vec2(texSize)); + return normalize(texelFetch(NormalTexture, ipos, 0).xyz * 2.0 - 1.0); +} +#else +vec3 FetchNormal(vec2 uv) +{ + return normalize(texture(NormalTexture, uv).xyz * 2.0 - 1.0); +} +#endif + vec3 MinDiff(vec3 p, vec3 pr, vec3 pl) { vec3 v1 = pr - p; @@ -106,7 +126,8 @@ float ComputeAO(vec3 viewPosition, vec3 viewNormal) void main() { vec3 viewPosition = FetchViewPos(TexCoord); - vec3 viewNormal = ReconstructNormal(viewPosition); + //vec3 viewNormal = ReconstructNormal(viewPosition); + vec3 viewNormal = FetchNormal(TexCoord); float occlusion = ComputeAO(viewPosition, viewNormal) * AOStrength + (1.0 - AOStrength); FragColor = vec4(occlusion, viewPosition.z, 0.0, 1.0); } diff --git a/wadsrc/static/shaders/glsl/ssaocombine.fp b/wadsrc/static/shaders/glsl/ssaocombine.fp index 7cd096276..377516587 100644 --- a/wadsrc/static/shaders/glsl/ssaocombine.fp +++ b/wadsrc/static/shaders/glsl/ssaocombine.fp @@ -5,10 +5,10 @@ out vec4 FragColor; uniform sampler2D AODepthTexture; #if defined(MULTISAMPLE) -uniform sampler2DMS SceneDataTexture; +uniform sampler2DMS SceneFogTexture; uniform int SampleCount; #else -uniform sampler2D SceneDataTexture; +uniform sampler2D SceneFogTexture; #endif uniform vec2 Scale; @@ -18,19 +18,19 @@ void main() { vec2 uv = Offset + TexCoord * Scale; #if defined(MULTISAMPLE) - ivec2 texSize = textureSize(SceneDataTexture); + ivec2 texSize = textureSize(SceneFogTexture); #else - ivec2 texSize = textureSize(SceneDataTexture, 0); + ivec2 texSize = textureSize(SceneFogTexture, 0); #endif ivec2 ipos = ivec2(max(floor(uv * vec2(texSize) - 0.75), vec2(0.0))); #if defined(MULTISAMPLE) vec3 fogColor = vec3(0.0); for (int i = 0; i < SampleCount; i++) - fogColor += texelFetch(SceneDataTexture, ipos, i).rgb; + fogColor += texelFetch(SceneFogTexture, ipos, i).rgb; fogColor /= float(SampleCount); #else - vec3 fogColor = texelFetch(SceneDataTexture, ipos, 0).rgb; + vec3 fogColor = texelFetch(SceneFogTexture, ipos, 0).rgb; #endif float attenutation = texture(AODepthTexture, TexCoord).x; From bb79dcb6349c694e441a875b5ff015de127da065 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 6 Oct 2016 07:36:49 +0200 Subject: [PATCH 1036/1509] SSAO math bug fixes --- src/gl/renderer/gl_postprocess.cpp | 65 +++++++++++++---------- src/gl/renderer/gl_renderbuffers.cpp | 44 +++++++++------ src/gl/renderer/gl_renderbuffers.h | 3 +- src/gl/shaders/gl_ambientshader.cpp | 3 ++ src/gl/shaders/gl_ambientshader.h | 2 + wadsrc/static/shaders/glsl/depthblur.fp | 2 +- wadsrc/static/shaders/glsl/lineardepth.fp | 33 ++++++++---- wadsrc/static/shaders/glsl/ssao.fp | 56 ++++++++++--------- 8 files changed, 125 insertions(+), 83 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index ac5a6336d..97e2c3be9 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -124,7 +124,7 @@ CVAR(Float, gl_ssao_strength, 0.7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Int, gl_ssao_debug, 0, 0) CVAR(Float, gl_ssao_bias, 0.5f, 0) CVAR(Float, gl_ssao_radius, 100.0f, 0) -CUSTOM_CVAR(Float, gl_ssao_blur_amount, 4.0f, 0) +CUSTOM_CVAR(Float, gl_ssao_blur_amount, 16.0f, 0) { if (self < 0.1f) self = 0.1f; } @@ -178,6 +178,13 @@ void FGLRenderer::AmbientOccludeScene() float blurSharpness = 1.0f / blurAmount; + float sceneScaleX = mSceneViewport.width / (float)mScreenViewport.width; + float sceneScaleY = mSceneViewport.height / (float)mScreenViewport.height; + float sceneOffsetX = mSceneViewport.left / (float)mScreenViewport.width; + float sceneOffsetY = mSceneViewport.top / (float)mScreenViewport.height; + + int randomTexture = clamp(gl_ssao - 1, 0, FGLRenderBuffers::NumAmbientRandomTextures - 1); + // Calculate linear depth values glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB0); glViewport(0, 0, mBuffers->AmbientWidth, mBuffers->AmbientHeight); @@ -196,8 +203,8 @@ void FGLRenderer::AmbientOccludeScene() mLinearDepthShader->LinearizeDepthB.Set(MAX(1.0f / GetZNear(), 1.e-8f)); mLinearDepthShader->InverseDepthRangeA.Set(1.0f); mLinearDepthShader->InverseDepthRangeB.Set(0.0f); - mLinearDepthShader->Scale.Set(mBuffers->AmbientWidth * 2.0f / (float)mScreenViewport.width, mBuffers->AmbientHeight * 2.0f / (float)mScreenViewport.height); - mLinearDepthShader->Offset.Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); + mLinearDepthShader->Scale.Set(sceneScaleX, sceneScaleY); + mLinearDepthShader->Offset.Set(sceneOffsetX, sceneOffsetY); RenderScreenQuad(); // Apply ambient occlusion @@ -206,7 +213,7 @@ void FGLRenderer::AmbientOccludeScene() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientRandomTexture); + glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientRandomTexture[randomTexture]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); @@ -219,44 +226,46 @@ void FGLRenderer::AmbientOccludeScene() mSSAOShader->DepthTexture.Set(0); mSSAOShader->RandomTexture.Set(1); mSSAOShader->NormalTexture.Set(2); - mSSAOShader->UVToViewA.Set(2.0f * invFocalLenX, -2.0f * invFocalLenY); - mSSAOShader->UVToViewB.Set(-invFocalLenX, invFocalLenY); + mSSAOShader->UVToViewA.Set(2.0f * invFocalLenX, 2.0f * invFocalLenY); + mSSAOShader->UVToViewB.Set(-invFocalLenX, -invFocalLenY); mSSAOShader->InvFullResolution.Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); mSSAOShader->NDotVBias.Set(nDotVBias); mSSAOShader->NegInvR2.Set(-1.0f / r2); mSSAOShader->RadiusToScreen.Set(aoRadius * 0.5 / tanHalfFovy * mBuffers->AmbientHeight); mSSAOShader->AOMultiplier.Set(1.0f / (1.0f - nDotVBias)); mSSAOShader->AOStrength.Set(aoStrength); + mSSAOShader->Scale.Set(sceneScaleX, sceneScaleY); + mSSAOShader->Offset.Set(sceneOffsetX, sceneOffsetY); RenderScreenQuad(); // Blur SSAO texture - glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB0); - glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture1); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - mDepthBlurShader->Bind(false); - mDepthBlurShader->BlurSharpness[false].Set(blurSharpness); - mDepthBlurShader->InvFullResolution[false].Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); - RenderScreenQuad(); + if (gl_ssao_debug < 2) + { + glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB0); + glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + mDepthBlurShader->Bind(false); + mDepthBlurShader->BlurSharpness[false].Set(blurSharpness); + mDepthBlurShader->InvFullResolution[false].Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); + RenderScreenQuad(); - glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB1); - glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture0); - mDepthBlurShader->Bind(true); - mDepthBlurShader->BlurSharpness[true].Set(blurSharpness); - mDepthBlurShader->InvFullResolution[true].Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); - mDepthBlurShader->PowExponent[true].Set(1.8f); - RenderScreenQuad(); + glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB1); + glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture0); + mDepthBlurShader->Bind(true); + mDepthBlurShader->BlurSharpness[true].Set(blurSharpness); + mDepthBlurShader->InvFullResolution[true].Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); + mDepthBlurShader->PowExponent[true].Set(1.8f); + RenderScreenQuad(); + } // Add SSAO back to scene texture: mBuffers->BindSceneFB(false); glViewport(mSceneViewport.left, mSceneViewport.top, mSceneViewport.width, mSceneViewport.height); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); - if (gl_ssao_debug > 1) - glBlendFunc(GL_ONE, GL_ZERO); - else - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - if (gl_ssao_debug == 1) + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + if (gl_ssao_debug != 0) { glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); @@ -270,8 +279,8 @@ void FGLRenderer::AmbientOccludeScene() mSSAOCombineShader->AODepthTexture.Set(0); mSSAOCombineShader->SceneFogTexture.Set(1); if (gl_multisample > 1) mSSAOCombineShader->SampleCount.Set(gl_multisample); - mSSAOCombineShader->Scale.Set(mBuffers->AmbientWidth * 2.0f / (float)mScreenViewport.width, mBuffers->AmbientHeight * 2.0f / (float)mScreenViewport.height); - mSSAOCombineShader->Offset.Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); + mSSAOCombineShader->Scale.Set(sceneScaleX, sceneScaleY); + mSSAOCombineShader->Offset.Set(sceneOffsetX, sceneOffsetY); RenderScreenQuad(); FGLDebug::PopGroup(); diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 1a1509d7a..a24596562 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -59,6 +59,11 @@ FGLRenderBuffers::FGLRenderBuffers() mPipelineFB[i] = 0; } + for (int i = 0; i < NumAmbientRandomTextures; i++) + { + AmbientRandomTexture[i] = 0; + } + glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&mOutputFB); glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples); } @@ -151,7 +156,8 @@ void FGLRenderBuffers::ClearAmbientOcclusion() DeleteFrameBuffer(AmbientFB1); DeleteTexture(AmbientTexture0); DeleteTexture(AmbientTexture1); - DeleteTexture(AmbientRandomTexture); + for (int i = 0; i < NumAmbientRandomTextures; i++) + DeleteTexture(AmbientRandomTexture[i]); } void FGLRenderBuffers::DeleteTexture(GLuint &handle) @@ -368,25 +374,31 @@ void FGLRenderBuffers::CreateAmbientOcclusion(int width, int height) AmbientFB0 = CreateFrameBuffer("AmbientFB0", AmbientTexture0); AmbientFB1 = CreateFrameBuffer("AmbientFB1", AmbientTexture1); - int16_t randomValues[16 * 4]; + // Must match quality enum in FSSAOShader::GetDefines + double numDirections[NumAmbientRandomTextures] = { 2.0, 4.0, 8.0 }; + std::mt19937 generator(1337); - std::uniform_real_distribution distribution(-1.0, 1.0); - for (int i = 0; i < 16; i++) + std::uniform_real_distribution distribution(0.0, 1.0); + for (int quality = 0; quality < NumAmbientRandomTextures; quality++) { - double num_directions = 8.0; // Must be same as the define in ssao.fp - double angle = 2.0 * M_PI * distribution(generator) / num_directions; - double x = cos(angle); - double y = sin(angle); - double z = distribution(generator); - double w = distribution(generator); + int16_t randomValues[16 * 4]; - randomValues[i * 4 + 0] = (int16_t)clamp(x * 32767.0, -32768.0, 32767.0); - randomValues[i * 4 + 1] = (int16_t)clamp(y * 32767.0, -32768.0, 32767.0); - randomValues[i * 4 + 2] = (int16_t)clamp(z * 32767.0, -32768.0, 32767.0); - randomValues[i * 4 + 3] = (int16_t)clamp(w * 32767.0, -32768.0, 32767.0); + for (int i = 0; i < 16; i++) + { + double angle = 2.0 * M_PI * distribution(generator) / numDirections[quality]; + double x = cos(angle); + double y = sin(angle); + double z = distribution(generator); + double w = distribution(generator); + + randomValues[i * 4 + 0] = (int16_t)clamp(x * 32767.0, -32768.0, 32767.0); + randomValues[i * 4 + 1] = (int16_t)clamp(y * 32767.0, -32768.0, 32767.0); + randomValues[i * 4 + 2] = (int16_t)clamp(z * 32767.0, -32768.0, 32767.0); + randomValues[i * 4 + 3] = (int16_t)clamp(w * 32767.0, -32768.0, 32767.0); + } + + AmbientRandomTexture[quality] = Create2DTexture("AmbientRandomTexture", GL_RGBA16_SNORM, 4, 4, randomValues); } - - AmbientRandomTexture = Create2DTexture("AmbientRandomTexture", GL_RGBA16_SNORM, 4, 4, randomValues); } //========================================================================== diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 9508f7009..d593b0248 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -65,7 +65,8 @@ public: GLuint AmbientFB1 = 0; int AmbientWidth = 0; int AmbientHeight = 0; - GLuint AmbientRandomTexture = 0; + enum { NumAmbientRandomTextures = 3 }; + GLuint AmbientRandomTexture[NumAmbientRandomTextures]; static bool IsEnabled(); diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index 6348d24cd..0d08e1258 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -84,6 +84,8 @@ void FSSAOShader::Bind() RadiusToScreen.Init(*mShader, "RadiusToScreen"); AOMultiplier.Init(*mShader, "AOMultiplier"); AOStrength.Init(*mShader, "AOStrength"); + Scale.Init(*mShader, "Scale"); + Offset.Init(*mShader, "Offset"); mMultisample = multisample; } mShader->Bind(); @@ -91,6 +93,7 @@ void FSSAOShader::Bind() FString FSSAOShader::GetDefines(int mode, bool multisample) { + // Must match quality values in FGLRenderBuffers::CreateAmbientOcclusion int numDirections, numSteps; switch (gl_ssao) { diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index 5c68892c3..95dfd6bac 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -39,6 +39,8 @@ public: FBufferedUniform1f RadiusToScreen; FBufferedUniform1f AOMultiplier; FBufferedUniform1f AOStrength; + FBufferedUniform2f Scale; + FBufferedUniform2f Offset; private: enum Quality diff --git a/wadsrc/static/shaders/glsl/depthblur.fp b/wadsrc/static/shaders/glsl/depthblur.fp index c4f4438d3..7e3dad074 100644 --- a/wadsrc/static/shaders/glsl/depthblur.fp +++ b/wadsrc/static/shaders/glsl/depthblur.fp @@ -7,7 +7,7 @@ uniform float BlurSharpness; uniform vec2 InvFullResolution; uniform float PowExponent; -#define KERNEL_RADIUS 7.0 +#define KERNEL_RADIUS 3.0 float CrossBilateralWeight(float r, float sampleDepth, float centerDepth) { diff --git a/wadsrc/static/shaders/glsl/lineardepth.fp b/wadsrc/static/shaders/glsl/lineardepth.fp index 558738bd9..fa71c9de0 100644 --- a/wadsrc/static/shaders/glsl/lineardepth.fp +++ b/wadsrc/static/shaders/glsl/lineardepth.fp @@ -18,6 +18,12 @@ uniform float InverseDepthRangeB; uniform vec2 Scale; uniform vec2 Offset; +float normalizeDepth(float depth) +{ + float normalizedDepth = clamp(InverseDepthRangeA * depth + InverseDepthRangeB, 0.0, 1.0); + return 1.0 / (normalizedDepth * LinearizeDepthA + LinearizeDepthB); +} + void main() { vec2 uv = Offset + TexCoord * Scale; @@ -28,19 +34,24 @@ void main() ivec2 texSize = textureSize(DepthTexture, 0); #endif - // Use floor here because as we downscale the sampling error has to remain uniform to prevent - // noise in the depth values. - ivec2 ipos = ivec2(max(floor(uv * vec2(texSize) - 0.75), vec2(0.0))); + ivec2 ipos = ivec2(max(uv * vec2(texSize), vec2(0.0))); #if defined(MULTISAMPLE) - float depth = 0.0; - for (int i = 0; i < SampleCount; i++) - depth += texelFetch(ColorTexture, ipos, i).a != 0.0 ? texelFetch(DepthTexture, ipos, i).x : 1.0; - depth /= float(SampleCount); + float depth = normalizeDepth(texelFetch(ColorTexture, ipos, 0).a != 0.0 ? texelFetch(DepthTexture, ipos, 0).x : 1.0); + float sampleIndex = 0.0; + for (int i = 1; i < SampleCount; i++) + { + float hardwareDepth = texelFetch(ColorTexture, ipos, i).a != 0.0 ? texelFetch(DepthTexture, ipos, i).x : 1.0; + float sampleDepth = normalizeDepth(hardwareDepth); + if (sampleDepth < depth) + { + depth = sampleDepth; + sampleIndex = float(i); + } + } + FragColor = vec4(depth, sampleIndex, 0.0, 1.0); #else - float depth = texelFetch(ColorTexture, ipos, 0).a != 0.0 ? texelFetch(DepthTexture, ipos, 0).x : 1.0; + float depth = normalizeDepth(texelFetch(ColorTexture, ipos, 0).a != 0.0 ? texelFetch(DepthTexture, ipos, 0).x : 1.0); + FragColor = vec4(depth, 0.0, 0.0, 1.0); #endif - - float normalizedDepth = clamp(InverseDepthRangeA * depth + InverseDepthRangeB, 0.0, 1.0); - FragColor = vec4(1.0 / (normalizedDepth * LinearizeDepthA + LinearizeDepthB), 0.0, 0.0, 1.0); } diff --git a/wadsrc/static/shaders/glsl/ssao.fp b/wadsrc/static/shaders/glsl/ssao.fp index 758f7dbaa..f895ddc25 100644 --- a/wadsrc/static/shaders/glsl/ssao.fp +++ b/wadsrc/static/shaders/glsl/ssao.fp @@ -13,6 +13,9 @@ uniform float AOMultiplier; uniform float AOStrength; +uniform vec2 Scale; +uniform vec2 Offset; + uniform sampler2D DepthTexture; #if defined(MULTISAMPLE) @@ -27,42 +30,42 @@ uniform sampler2D RandomTexture; #define PI 3.14159265358979323846 -// Calculate eye space position for the specified texture coordinate -vec3 FetchViewPos(vec2 uv) +// Calculate eye space position for the specified texture coordinate and depth +vec3 FetchViewPos(vec2 uv, float z) { - float z = texture(DepthTexture, uv).x; return vec3((UVToViewA * uv + UVToViewB) * z, z); } #if defined(MULTISAMPLE) -vec3 FetchNormal(vec2 uv) +vec3 SampleNormal(vec2 uv, float samplerIndex) { ivec2 texSize = textureSize(NormalTexture); ivec2 ipos = ivec2(uv * vec2(texSize)); - return normalize(texelFetch(NormalTexture, ipos, 0).xyz * 2.0 - 1.0); + return texelFetch(NormalTexture, ipos, int(samplerIndex)).xyz * 2.0 - 1.0; } #else -vec3 FetchNormal(vec2 uv) +vec3 SampleNormal(vec2 uv, float samplerIndex) { - return normalize(texture(NormalTexture, uv).xyz * 2.0 - 1.0); + ivec2 texSize = textureSize(NormalTexture, 0); + ivec2 ipos = ivec2(uv * vec2(texSize)); + return texelFetch(NormalTexture, ipos, 0).xyz * 2.0 - 1.0; } #endif -vec3 MinDiff(vec3 p, vec3 pr, vec3 pl) +// Look up the eye space normal for the specified texture coordinate +vec3 FetchNormal(vec2 uv, float samplerIndex) { - vec3 v1 = pr - p; - vec3 v2 = p - pl; - return (dot(v1, v1) < dot(v2, v2)) ? v1 : v2; -} - -// Reconstruct eye space normal from nearest neighbors -vec3 ReconstructNormal(vec3 p) -{ - vec3 pr = FetchViewPos(TexCoord + vec2(InvFullResolution.x, 0)); - vec3 pl = FetchViewPos(TexCoord + vec2(-InvFullResolution.x, 0)); - vec3 pt = FetchViewPos(TexCoord + vec2(0, InvFullResolution.y)); - vec3 pb = FetchViewPos(TexCoord + vec2(0, -InvFullResolution.y)); - return normalize(cross(MinDiff(p, pr, pl), MinDiff(p, pt, pb))); + vec3 normal = SampleNormal(Offset + uv * Scale, samplerIndex); + if (length(normal) > 0.1) + { + normal = normalize(normal); + normal.z = -normal.z; + return normal; + } + else + { + return vec3(0.0); + } } // Compute normalized 2D direction @@ -113,7 +116,7 @@ float ComputeAO(vec3 viewPosition, vec3 viewNormal) for (float StepIndex = 0.0; StepIndex < NUM_STEPS; ++StepIndex) { vec2 sampleUV = round(rayPixels * direction) * InvFullResolution + TexCoord; - vec3 samplePos = FetchViewPos(sampleUV); + vec3 samplePos = FetchViewPos(sampleUV, texture(DepthTexture, sampleUV).x); ao += ComputeSampleAO(viewPosition, viewNormal, samplePos); rayPixels += stepSizePixels; } @@ -125,9 +128,10 @@ float ComputeAO(vec3 viewPosition, vec3 viewNormal) void main() { - vec3 viewPosition = FetchViewPos(TexCoord); - //vec3 viewNormal = ReconstructNormal(viewPosition); - vec3 viewNormal = FetchNormal(TexCoord); - float occlusion = ComputeAO(viewPosition, viewNormal) * AOStrength + (1.0 - AOStrength); + vec2 depthData = texture(DepthTexture, TexCoord).xy; + vec3 viewPosition = FetchViewPos(TexCoord, depthData.x); + vec3 viewNormal = FetchNormal(TexCoord, depthData.y); + float occlusion = viewNormal != vec3(0.0) ? ComputeAO(viewPosition, viewNormal) * AOStrength + (1.0 - AOStrength) : 1.0; + FragColor = vec4(occlusion, viewPosition.z, 0.0, 1.0); } From c1e859dbca3e6301bf570bf1bdc467f90c415d4e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 7 Oct 2016 03:38:43 +0200 Subject: [PATCH 1037/1509] Added codegen for column drawers --- .../fixedfunction/drawcolumncodegen.cpp | 147 +++- .../fixedfunction/drawcolumncodegen.h | 57 +- src/r_compiler/llvmdrawers.cpp | 86 +++ src/r_compiler/llvmdrawers.h | 51 ++ src/r_compiler/ssa/ssa_ubyte.cpp | 6 + src/r_compiler/ssa/ssa_ubyte.h | 4 + src/r_compiler/ssa/ssa_ubyte_ptr.cpp | 16 +- src/r_compiler/ssa/ssa_vec4i.cpp | 13 + src/r_compiler/ssa/ssa_vec4i.h | 1 + src/r_draw_rgba.cpp | 718 +++--------------- 10 files changed, 449 insertions(+), 650 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp index 67d801162..116744f1c 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp @@ -11,6 +11,151 @@ #include "r_compiler/ssa/ssa_struct_type.h" #include "r_compiler/ssa/ssa_value.h" -void DrawColumnCodegen::Generate(DrawColumnVariant variant, SSAValue args) +void DrawColumnCodegen::Generate(DrawColumnVariant variant, SSAValue args, SSAValue thread_data) { + dest = args[0][0].load(); + source = args[0][1].load(); + colormap = args[0][2].load(); + translation = args[0][3].load(); + basecolors = args[0][4].load(); + pitch = args[0][5].load(); + count = args[0][6].load(); + dest_y = args[0][7].load(); + iscale = args[0][8].load(); + texturefrac = args[0][9].load(); + light = args[0][10].load(); + color = SSAVec4i::unpack(args[0][11].load()); + srccolor = SSAVec4i::unpack(args[0][12].load()); + srcalpha = args[0][13].load(); + destalpha = args[0][14].load(); + SSAShort light_alpha = args[0][15].load(); + SSAShort light_red = args[0][16].load(); + SSAShort light_green = args[0][17].load(); + SSAShort light_blue = args[0][18].load(); + SSAShort fade_alpha = args[0][19].load(); + SSAShort fade_red = args[0][20].load(); + SSAShort fade_green = args[0][21].load(); + SSAShort fade_blue = args[0][22].load(); + SSAShort desaturate = args[0][23].load(); + SSAInt flags = args[0][24].load(); + shade_constants.light = SSAVec4i(light_blue.zext_int(), light_green.zext_int(), light_red.zext_int(), light_alpha.zext_int()); + shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); + shade_constants.desaturate = desaturate.zext_int(); + + thread.core = thread_data[0][0].load(); + thread.num_cores = thread_data[0][1].load(); + thread.pass_start_y = thread_data[0][2].load(); + thread.pass_end_y = thread_data[0][3].load(); + + is_simple_shade = (flags & DrawColumnArgs::simple_shade) == SSAInt(DrawColumnArgs::simple_shade); + + count = count_for_thread(dest_y, count, thread); + dest = dest_for_thread(dest_y, pitch, dest, thread); + pitch = pitch * thread.num_cores; + stack_frac.store(texturefrac + iscale * skipped_by_thread(dest_y, thread)); + iscale = iscale * thread.num_cores; + + SSAIfBlock branch; + branch.if_block(is_simple_shade); + Loop(variant, true); + branch.else_block(); + Loop(variant, false); + branch.end_block(); +} + +void DrawColumnCodegen::Loop(DrawColumnVariant variant, bool isSimpleShade) +{ + stack_index.store(SSAInt(0)); + { + SSAForBlock loop; + SSAInt index = stack_index.load(); + loop.loop_block(index < count); + + SSAInt frac = stack_frac.load(); + + SSAInt offset = index * pitch * 4; + SSAVec4i bgcolor = dest[offset].load_vec4ub(); + + SSAInt alpha, inv_alpha; + SSAVec4i outcolor; + switch (variant) + { + default: + case DrawColumnVariant::Draw: + outcolor = blend_copy(Shade(ColormapSample(frac), isSimpleShade)); + break; + case DrawColumnVariant::DrawAdd: + case DrawColumnVariant::DrawAddClamp: + outcolor = blend_add(Shade(ColormapSample(frac), isSimpleShade), bgcolor, srcalpha, destalpha); + break; + case DrawColumnVariant::DrawShaded: + alpha = SSAInt::MAX(SSAInt::MIN(ColormapSample(frac), SSAInt(64)), SSAInt(0)) * 4; + inv_alpha = 256 - alpha; + outcolor = blend_add(color, bgcolor, alpha, inv_alpha); + break; + case DrawColumnVariant::DrawSubClamp: + outcolor = blend_sub(Shade(ColormapSample(frac), isSimpleShade), bgcolor, srcalpha, destalpha); + break; + case DrawColumnVariant::DrawRevSubClamp: + outcolor = blend_revsub(Shade(ColormapSample(frac), isSimpleShade), bgcolor, srcalpha, destalpha); + break; + case DrawColumnVariant::DrawTranslated: + outcolor = blend_copy(Shade(TranslateSample(frac), isSimpleShade)); + break; + case DrawColumnVariant::DrawTlatedAdd: + case DrawColumnVariant::DrawAddClampTranslated: + outcolor = blend_add(Shade(TranslateSample(frac), isSimpleShade), bgcolor, srcalpha, destalpha); + break; + case DrawColumnVariant::DrawSubClampTranslated: + outcolor = blend_sub(Shade(TranslateSample(frac), isSimpleShade), bgcolor, srcalpha, destalpha); + break; + case DrawColumnVariant::DrawRevSubClampTranslated: + outcolor = blend_revsub(Shade(TranslateSample(frac), isSimpleShade), bgcolor, srcalpha, destalpha); + break; + case DrawColumnVariant::Fill: + outcolor = blend_copy(color); + break; + case DrawColumnVariant::FillAdd: + alpha = srccolor[3]; + alpha = alpha + (alpha >> 7); + inv_alpha = 256 - alpha; + outcolor = blend_add(srccolor, bgcolor, alpha, inv_alpha); + break; + case DrawColumnVariant::FillAddClamp: + outcolor = blend_add(srccolor, bgcolor, srcalpha, destalpha); + break; + case DrawColumnVariant::FillSubClamp: + outcolor = blend_sub(srccolor, bgcolor, srcalpha, destalpha); + break; + case DrawColumnVariant::FillRevSubClamp: + outcolor = blend_revsub(srccolor, bgcolor, srcalpha, destalpha); + break; + } + + dest[offset].store_vec4ub(outcolor); + + stack_index.store(index + 1); + stack_frac.store(frac + iscale); + loop.end_block(); + } +} + +SSAInt DrawColumnCodegen::ColormapSample(SSAInt frac) +{ + SSAInt sample_index = frac >> FRACBITS; + return colormap[source[sample_index].load().zext_int()].load().zext_int(); +} + +SSAInt DrawColumnCodegen::TranslateSample(SSAInt frac) +{ + SSAInt sample_index = frac >> FRACBITS; + return translation[source[sample_index].load().zext_int()].load().zext_int(); +} + +SSAVec4i DrawColumnCodegen::Shade(SSAInt palIndex, bool isSimpleShade) +{ + if (isSimpleShade) + return shade_pal_index_simple(palIndex, light, basecolors); + else + return shade_pal_index_advanced(palIndex, light, shade_constants, basecolors); } diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.h b/src/r_compiler/fixedfunction/drawcolumncodegen.h index 0749def7f..488c36295 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.h +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.h @@ -5,22 +5,53 @@ enum class DrawColumnVariant { - Opaque, - Fuzz, - Add, - Translated, - TlatedAdd, - Shaded, - AddClamp, - AddClampTranslated, - SubClamp, - SubClampTranslated, - RevSubClamp, - RevSubClampTranslated + Fill, + FillAdd, + FillAddClamp, + FillSubClamp, + FillRevSubClamp, + Draw, + DrawAdd, + DrawTranslated, + DrawTlatedAdd, + DrawShaded, + DrawAddClamp, + DrawAddClampTranslated, + DrawSubClamp, + DrawSubClampTranslated, + DrawRevSubClamp, + DrawRevSubClampTranslated }; class DrawColumnCodegen : public DrawerCodegen { public: - void Generate(DrawColumnVariant variant, SSAValue args); + void Generate(DrawColumnVariant variant, SSAValue args, SSAValue thread_data); + +private: + void Loop(DrawColumnVariant variant, bool isSimpleShade); + SSAInt ColormapSample(SSAInt frac); + SSAInt TranslateSample(SSAInt frac); + SSAVec4i Shade(SSAInt palIndex, bool isSimpleShade); + + SSAStack stack_index, stack_frac; + + SSAUBytePtr dest; + SSAUBytePtr source; + SSAUBytePtr colormap; + SSAUBytePtr translation; + SSAUBytePtr basecolors; + SSAInt pitch; + SSAInt count; + SSAInt dest_y; + SSAInt iscale; + SSAInt texturefrac; + SSAInt light; + SSAVec4i color; + SSAVec4i srccolor; + SSAInt srcalpha; + SSAInt destalpha; + SSABool is_simple_shade; + SSAShadeConstants shade_constants; + SSAWorkerThread thread; }; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 7691af35b..6ab4f5a4f 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -47,9 +47,11 @@ public: LLVMDrawersImpl(); private: + void CodegenDrawColumn(const char *name, DrawColumnVariant variant); void CodegenDrawSpan(const char *name, DrawSpanVariant variant); void CodegenDrawWall(const char *name, DrawWallVariant variant, int columns); + static llvm::Type *GetDrawColumnArgsStruct(llvm::LLVMContext &context); static llvm::Type *GetDrawSpanArgsStruct(llvm::LLVMContext &context); static llvm::Type *GetDrawWallArgsStruct(llvm::LLVMContext &context); static llvm::Type *GetWorkerThreadDataStruct(llvm::LLVMContext &context); @@ -82,6 +84,22 @@ LLVMDrawers *LLVMDrawers::Instance() LLVMDrawersImpl::LLVMDrawersImpl() { + CodegenDrawColumn("FillColumn", DrawColumnVariant::Fill); + CodegenDrawColumn("FillColumnAdd", DrawColumnVariant::FillAdd); + CodegenDrawColumn("FillColumnAddClamp", DrawColumnVariant::FillAddClamp); + CodegenDrawColumn("FillColumnSubClamp", DrawColumnVariant::FillSubClamp); + CodegenDrawColumn("FillColumnRevSubClamp", DrawColumnVariant::FillRevSubClamp); + CodegenDrawColumn("DrawColumn", DrawColumnVariant::Draw); + CodegenDrawColumn("DrawColumnAdd", DrawColumnVariant::DrawAdd); + CodegenDrawColumn("DrawColumnTranslated", DrawColumnVariant::DrawTranslated); + CodegenDrawColumn("DrawColumnTlatedAdd", DrawColumnVariant::DrawTlatedAdd); + CodegenDrawColumn("DrawColumnShaded", DrawColumnVariant::DrawShaded); + CodegenDrawColumn("DrawColumnAddClamp", DrawColumnVariant::DrawAddClamp); + CodegenDrawColumn("DrawColumnAddClampTranslated", DrawColumnVariant::DrawAddClampTranslated); + CodegenDrawColumn("DrawColumnSubClamp", DrawColumnVariant::DrawSubClamp); + CodegenDrawColumn("DrawColumnSubClampTranslated", DrawColumnVariant::DrawSubClampTranslated); + CodegenDrawColumn("DrawColumnRevSubClamp", DrawColumnVariant::DrawRevSubClamp); + CodegenDrawColumn("DrawColumnRevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated); CodegenDrawSpan("DrawSpan", DrawSpanVariant::Opaque); CodegenDrawSpan("DrawSpanMasked", DrawSpanVariant::Masked); CodegenDrawSpan("DrawSpanTranslucent", DrawSpanVariant::Translucent); @@ -104,6 +122,22 @@ LLVMDrawersImpl::LLVMDrawersImpl() mProgram.engine()->finalizeObject(); mProgram.modulePassManager()->run(*mProgram.module()); + FillColumn = mProgram.GetProcAddress("FillColumn"); + FillColumnAdd = mProgram.GetProcAddress("FillColumnAdd"); + FillColumnAddClamp = mProgram.GetProcAddress("FillColumnAddClamp"); + FillColumnSubClamp = mProgram.GetProcAddress("FillColumnSubClamp"); + FillColumnRevSubClamp = mProgram.GetProcAddress("FillColumnRevSubClamp"); + DrawColumn = mProgram.GetProcAddress("DrawColumn"); + DrawColumnAdd = mProgram.GetProcAddress("DrawColumnAdd"); + DrawColumnTranslated = mProgram.GetProcAddress("DrawColumnTranslated"); + DrawColumnTlatedAdd = mProgram.GetProcAddress("DrawColumnTlatedAdd"); + DrawColumnShaded = mProgram.GetProcAddress("DrawColumnShaded"); + DrawColumnAddClamp = mProgram.GetProcAddress("DrawColumnAddClamp"); + DrawColumnAddClampTranslated = mProgram.GetProcAddress("DrawColumnAddClampTranslated"); + DrawColumnSubClamp = mProgram.GetProcAddress("DrawColumnSubClamp"); + DrawColumnSubClampTranslated = mProgram.GetProcAddress("DrawColumnSubClampTranslated"); + DrawColumnRevSubClamp = mProgram.GetProcAddress("DrawColumnRevSubClamp"); + DrawColumnRevSubClampTranslated = mProgram.GetProcAddress("DrawColumnRevSubClampTranslated"); DrawSpan = mProgram.GetProcAddress("DrawSpan"); DrawSpanMasked = mProgram.GetProcAddress("DrawSpanMasked"); DrawSpanTranslucent = mProgram.GetProcAddress("DrawSpanTranslucent"); @@ -126,6 +160,27 @@ LLVMDrawersImpl::LLVMDrawersImpl() mProgram.StopLogFatalErrors(); } +void LLVMDrawersImpl::CodegenDrawColumn(const char *name, DrawColumnVariant variant) +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function(name); + function.add_parameter(GetDrawColumnArgsStruct(mProgram.context())); + function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); + function.create_public(); + + DrawColumnCodegen codegen; + codegen.Generate(variant, function.parameter(0), function.parameter(1)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + I_FatalError("verifyFunction failed for " __FUNCTION__); + + mProgram.functionPassManager()->run(*function.func); +} + void LLVMDrawersImpl::CodegenDrawSpan(const char *name, DrawSpanVariant variant) { llvm::IRBuilder<> builder(mProgram.context()); @@ -167,6 +222,37 @@ void LLVMDrawersImpl::CodegenDrawWall(const char *name, DrawWallVariant variant, mProgram.functionPassManager()->run(*function.func); } +llvm::Type *LLVMDrawersImpl::GetDrawColumnArgsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint32_t *dest; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *colormap; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *translation; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *basecolors; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t pitch; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t count; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t dest_y; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t iscale; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t texturefrac; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t color; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srccolor; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; + return llvm::StructType::get(context, elements, false)->getPointerTo(); +} + llvm::Type *LLVMDrawersImpl::GetDrawSpanArgsStruct(llvm::LLVMContext &context) { std::vector elements; diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index b1039cf49..2ce4c5230 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -77,6 +77,40 @@ struct DrawSpanArgs }; }; +struct DrawColumnArgs +{ + uint32_t *dest; + const uint8_t *source; + uint8_t *colormap; + uint8_t *translation; + const uint32_t *basecolors; + int32_t pitch; + int32_t count; + int32_t dest_y; + uint32_t iscale; + uint32_t texturefrac; + uint32_t light; + uint32_t color; + uint32_t srccolor; + uint32_t srcalpha; + uint32_t destalpha; + + uint16_t light_alpha; + uint16_t light_red; + uint16_t light_green; + uint16_t light_blue; + uint16_t fade_alpha; + uint16_t fade_red; + uint16_t fade_green; + uint16_t fade_blue; + uint16_t desaturate; + uint32_t flags; + enum Flags + { + simple_shade = 1 + }; +}; + class LLVMDrawers { public: @@ -86,6 +120,23 @@ public: static void Destroy(); static LLVMDrawers *Instance(); + void(*DrawColumn)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnAdd)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnTlatedAdd)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnShaded)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnAddClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnAddClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnSubClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRevSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRevSubClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*FillColumn)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*FillColumnAdd)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*FillColumnAddClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*FillColumnSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*FillColumnRevSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawSpan)(const DrawSpanArgs *) = nullptr; void(*DrawSpanMasked)(const DrawSpanArgs *) = nullptr; void(*DrawSpanTranslucent)(const DrawSpanArgs *) = nullptr; diff --git a/src/r_compiler/ssa/ssa_ubyte.cpp b/src/r_compiler/ssa/ssa_ubyte.cpp index 3204d064d..6fe9c3bb1 100644 --- a/src/r_compiler/ssa/ssa_ubyte.cpp +++ b/src/r_compiler/ssa/ssa_ubyte.cpp @@ -1,6 +1,7 @@ #include "r_compiler/llvm_include.h" #include "ssa_ubyte.h" +#include "ssa_int.h" #include "ssa_scope.h" SSAUByte::SSAUByte() @@ -24,6 +25,11 @@ llvm::Type *SSAUByte::llvm_type() return llvm::Type::getInt8Ty(SSAScope::context()); } +SSAInt SSAUByte::zext_int() +{ + return SSAInt::from_llvm(SSAScope::builder().CreateZExt(v, SSAInt::llvm_type(), SSAScope::hint())); +} + SSAUByte operator+(const SSAUByte &a, const SSAUByte &b) { return SSAUByte::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); diff --git a/src/r_compiler/ssa/ssa_ubyte.h b/src/r_compiler/ssa/ssa_ubyte.h index ef878b325..41ed3939b 100644 --- a/src/r_compiler/ssa/ssa_ubyte.h +++ b/src/r_compiler/ssa/ssa_ubyte.h @@ -4,6 +4,8 @@ namespace llvm { class Value; } namespace llvm { class Type; } +class SSAInt; + class SSAUByte { public: @@ -13,6 +15,8 @@ public: static SSAUByte from_llvm(llvm::Value *v) { return SSAUByte(v); } static llvm::Type *llvm_type(); + SSAInt zext_int(); + llvm::Value *v; }; diff --git a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp index 98bf27c46..34de0ab88 100644 --- a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp +++ b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp @@ -30,22 +30,8 @@ SSAUByte SSAUBytePtr::load() const SSAVec4i SSAUBytePtr::load_vec4ub() const { - // _mm_cvtsi32_si128 as implemented by clang: SSAInt i32 = SSAInt::from_llvm(SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, llvm::Type::getInt32PtrTy(SSAScope::context()), SSAScope::hint()), false, SSAScope::hint())); - llvm::Value *v = SSAScope::builder().CreateInsertElement(llvm::UndefValue::get(SSAVec4i::llvm_type()), i32.v, SSAInt(0).v, SSAScope::hint()); - v = SSAScope::builder().CreateInsertElement(v, SSAInt(0).v, SSAInt(1).v, SSAScope::hint()); - v = SSAScope::builder().CreateInsertElement(v, SSAInt(0).v, SSAInt(2).v, SSAScope::hint()); - v = SSAScope::builder().CreateInsertElement(v, SSAInt(0).v, SSAInt(3).v, SSAScope::hint()); - SSAVec4i v4i = SSAVec4i::from_llvm(v); - - SSAVec8s low = SSAVec8s::bitcast(SSAVec16ub::shuffle(SSAVec16ub::bitcast(v4i), SSAVec16ub((unsigned char)0), 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7)); // _mm_unpacklo_epi8 - return SSAVec4i::extendlo(low); // _mm_unpacklo_epi16 -/* - llvm::PointerType *m4xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 4)->getPointerTo(); - llvm::Type *m4xint32type = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4); - llvm::Value *v4ub = SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, m4xint8typeptr, SSAScope::hint()), false, SSAScope::hint()); - return SSAVec4i::from_llvm(SSAScope::builder().CreateZExt(v4ub, m4xint32type)); -*/ + return SSAVec4i::unpack(i32); } SSAVec16ub SSAUBytePtr::load_vec16ub() const diff --git a/src/r_compiler/ssa/ssa_vec4i.cpp b/src/r_compiler/ssa/ssa_vec4i.cpp index 3b508412f..3be0ec194 100644 --- a/src/r_compiler/ssa/ssa_vec4i.cpp +++ b/src/r_compiler/ssa/ssa_vec4i.cpp @@ -97,6 +97,19 @@ llvm::Type *SSAVec4i::llvm_type() return llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4); } +SSAVec4i SSAVec4i::unpack(SSAInt i32) +{ + // _mm_cvtsi32_si128 as implemented by clang: + llvm::Value *v = SSAScope::builder().CreateInsertElement(llvm::UndefValue::get(SSAVec4i::llvm_type()), i32.v, SSAInt(0).v, SSAScope::hint()); + v = SSAScope::builder().CreateInsertElement(v, SSAInt(0).v, SSAInt(1).v, SSAScope::hint()); + v = SSAScope::builder().CreateInsertElement(v, SSAInt(0).v, SSAInt(2).v, SSAScope::hint()); + v = SSAScope::builder().CreateInsertElement(v, SSAInt(0).v, SSAInt(3).v, SSAScope::hint()); + SSAVec4i v4i = SSAVec4i::from_llvm(v); + + SSAVec8s low = SSAVec8s::bitcast(SSAVec16ub::shuffle(SSAVec16ub::bitcast(v4i), SSAVec16ub((unsigned char)0), 0, 16 + 0, 1, 16 + 1, 2, 16 + 2, 3, 16 + 3, 4, 16 + 4, 5, 16 + 5, 6, 16 + 6, 7, 16 + 7)); // _mm_unpacklo_epi8 + return SSAVec4i::extendlo(low); // _mm_unpacklo_epi16 +} + SSAVec4i SSAVec4i::bitcast(SSAVec4f f32) { return SSAVec4i::from_llvm(SSAScope::builder().CreateBitCast(f32.v, llvm_type(), SSAScope::hint())); diff --git a/src/r_compiler/ssa/ssa_vec4i.h b/src/r_compiler/ssa/ssa_vec4i.h index 89cda1646..f8ef92f1e 100644 --- a/src/r_compiler/ssa/ssa_vec4i.h +++ b/src/r_compiler/ssa/ssa_vec4i.h @@ -24,6 +24,7 @@ public: SSAVec4i insert(SSAInt index, SSAInt value); SSAVec4i insert(int index, SSAInt value); SSAVec4i insert(int index, int value); + static SSAVec4i unpack(SSAInt value); static SSAVec4i bitcast(SSAVec4f f32); static SSAVec4i bitcast(SSAVec8s i16); static SSAVec4i shuffle(const SSAVec4i &f0, int index0, int index1, int index2, int index3); diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index c5b1b478e..7da2f183f 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -396,56 +396,6 @@ public: } }; -class DrawWallMasked4LLVMCommand : public DrawWall4LLVMCommand -{ -public: - void Execute(DrawerThread *thread) override - { - WorkerThreadData d = ThreadData(thread); - LLVMDrawers::Instance()->mvlinec4(&args, &d); - } -}; - -class DrawWallAdd4LLVMCommand : public DrawWall4LLVMCommand -{ -public: - void Execute(DrawerThread *thread) override - { - WorkerThreadData d = ThreadData(thread); - LLVMDrawers::Instance()->tmvline4_add(&args, &d); - } -}; - -class DrawWallAddClamp4LLVMCommand : public DrawWall4LLVMCommand -{ -public: - void Execute(DrawerThread *thread) override - { - WorkerThreadData d = ThreadData(thread); - LLVMDrawers::Instance()->tmvline4_addclamp(&args, &d); - } -}; - -class DrawWallSubClamp4LLVMCommand : public DrawWall4LLVMCommand -{ -public: - void Execute(DrawerThread *thread) override - { - WorkerThreadData d = ThreadData(thread); - LLVMDrawers::Instance()->tmvline4_subclamp(&args, &d); - } -}; - -class DrawWallRevSubClamp4LLVMCommand : public DrawWall4LLVMCommand -{ -public: - void Execute(DrawerThread *thread) override - { - WorkerThreadData d = ThreadData(thread); - LLVMDrawers::Instance()->tmvline4_revsubclamp(&args, &d); - } -}; - class DrawWall1LLVMCommand : public DrawerCommand { protected: @@ -500,575 +450,101 @@ public: } }; -class DrawWallMasked1LLVMCommand : public DrawWall1LLVMCommand +class DrawColumnLLVMCommand : public DrawerCommand { +protected: + DrawColumnArgs args; + + WorkerThreadData ThreadData(DrawerThread *thread) + { + WorkerThreadData d; + d.core = thread->core; + d.num_cores = thread->num_cores; + d.pass_start_y = thread->pass_start_y; + d.pass_end_y = thread->pass_end_y; + return d; + } + public: + DrawColumnLLVMCommand() + { + args.dest = (uint32_t*)dc_dest; + args.source = dc_source; + args.colormap = dc_colormap; + args.translation = dc_translation; + args.basecolors = (const uint32_t *)GPalette.BaseColors; + args.pitch = dc_pitch; + args.count = dc_count; + args.dest_y = _dest_y; + args.iscale = dc_iscale; + args.texturefrac = dc_texturefrac; + args.light = LightBgra::calc_light_multiplier(dc_light); + args.color = LightBgra::shade_pal_index_simple(dc_color, args.light); + args.srccolor = dc_srccolor_bgra; + args.srcalpha = dc_srcalpha >> (FRACBITS - 8); + args.destalpha = dc_destalpha >> (FRACBITS - 8); + args.light_red = dc_shade_constants.light_red; + args.light_green = dc_shade_constants.light_green; + args.light_blue = dc_shade_constants.light_blue; + args.light_alpha = dc_shade_constants.light_alpha; + args.fade_red = dc_shade_constants.fade_red; + args.fade_green = dc_shade_constants.fade_green; + args.fade_blue = dc_shade_constants.fade_blue; + args.fade_alpha = dc_shade_constants.fade_alpha; + args.desaturate = dc_shade_constants.desaturate; + args.flags = 0; + if (dc_shade_constants.simple_shade) + args.flags |= DrawColumnArgs::simple_shade; + } + void Execute(DrawerThread *thread) override { WorkerThreadData d = ThreadData(thread); - LLVMDrawers::Instance()->mvlinec1(&args, &d); + LLVMDrawers::Instance()->DrawColumn(&args, &d); } }; -class DrawWallAdd1LLVMCommand : public DrawWall1LLVMCommand -{ -public: - void Execute(DrawerThread *thread) override - { - WorkerThreadData d = ThreadData(thread); - LLVMDrawers::Instance()->tmvline1_add(&args, &d); - } +#define DECLARE_DRAW_COMMAND(name, func, base) \ +class name##LLVMCommand : public base \ +{ \ +public: \ + void Execute(DrawerThread *thread) override \ + { \ + WorkerThreadData d = ThreadData(thread); \ + LLVMDrawers::Instance()->func(&args, &d); \ + } \ }; -class DrawWallAddClamp1LLVMCommand : public DrawWall1LLVMCommand -{ -public: - void Execute(DrawerThread *thread) override - { - WorkerThreadData d = ThreadData(thread); - LLVMDrawers::Instance()->tmvline1_addclamp(&args, &d); - } -}; +//DECLARE_DRAW_COMMAND(name, func, DrawSpanLLVMCommand); -class DrawWallSubClamp1LLVMCommand : public DrawWall1LLVMCommand -{ -public: - void Execute(DrawerThread *thread) override - { - WorkerThreadData d = ThreadData(thread); - LLVMDrawers::Instance()->tmvline1_subclamp(&args, &d); - } -}; - -class DrawWallRevSubClamp1LLVMCommand : public DrawWall1LLVMCommand -{ -public: - void Execute(DrawerThread *thread) override - { - WorkerThreadData d = ThreadData(thread); - LLVMDrawers::Instance()->tmvline1_revsubclamp(&args, &d); - } -}; +DECLARE_DRAW_COMMAND(DrawWallMasked4, mvlinec4, DrawWall4LLVMCommand); +DECLARE_DRAW_COMMAND(DrawWallAdd4, tmvline4_add, DrawWall4LLVMCommand); +DECLARE_DRAW_COMMAND(DrawWallAddClamp4, tmvline4_addclamp, DrawWall4LLVMCommand); +DECLARE_DRAW_COMMAND(DrawWallSubClamp4, tmvline4_subclamp, DrawWall4LLVMCommand); +DECLARE_DRAW_COMMAND(DrawWallRevSubClamp4, tmvline4_revsubclamp, DrawWall4LLVMCommand); +DECLARE_DRAW_COMMAND(DrawWallMasked1, mvlinec1, DrawWall1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawWallAdd1, tmvline1_add, DrawWall1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawWallAddClamp1, tmvline1_addclamp, DrawWall1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawWallSubClamp1, tmvline1_subclamp, DrawWall1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawWallRevSubClamp1, tmvline1_revsubclamp, DrawWall1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnAdd, DrawColumnAdd, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnTranslated, DrawColumnTranslated, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnTlatedAdd, DrawColumnTlatedAdd, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnShaded, DrawColumnShaded, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnAddClamp, DrawColumnAddClamp, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnAddClampTranslated, DrawColumnAddClampTranslated, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnSubClamp, DrawColumnSubClamp, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnSubClampTranslated, DrawColumnSubClampTranslated, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRevSubClamp, DrawColumnRevSubClamp, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRevSubClampTranslated, DrawColumnRevSubClampTranslated, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(FillColumn, FillColumn, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(FillColumnAdd, FillColumnAdd, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(FillColumnAddClamp, FillColumnAddClamp, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(FillColumnSubClamp, FillColumnSubClamp, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(FillColumnRevSubClamp, FillColumnRevSubClamp, DrawColumnLLVMCommand); ///////////////////////////////////////////////////////////////////////////// -class DrawerColumnCommand : public DrawerCommand -{ -public: - int _count; - BYTE * RESTRICT _dest; - int _pitch; - DWORD _iscale; - DWORD _texturefrac; - - DrawerColumnCommand() - { - _count = dc_count; - _dest = dc_dest; - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _pitch = dc_pitch; - } - - class LoopIterator - { - public: - int count; - uint32_t *dest; - int pitch; - fixed_t fracstep; - fixed_t frac; - - LoopIterator(DrawerColumnCommand *command, DrawerThread *thread) - { - count = thread->count_for_thread(command->_dest_y, command->_count); - if (count <= 0) - return; - - dest = thread->dest_for_thread(command->_dest_y, command->_pitch, (uint32_t*)command->_dest); - pitch = command->_pitch * thread->num_cores; - - fracstep = command->_iscale * thread->num_cores; - frac = command->_texturefrac + command->_iscale * thread->skipped_by_thread(command->_dest_y); - } - - uint32_t sample_index() - { - return frac >> FRACBITS; - } - - explicit operator bool() - { - return count > 0; - } - - bool next() - { - dest += pitch; - frac += fracstep; - return (--count) != 0; - } - }; -}; - -class DrawColumnRGBACommand : public DrawerColumnCommand -{ - uint32_t _light; - const BYTE * RESTRICT _source; - ShadeConstants _shade_constants; - BYTE * RESTRICT _colormap; - -public: - DrawColumnRGBACommand() - { - _light = LightBgra::calc_light_multiplier(dc_light); - _shade_constants = dc_shade_constants; - _source = dc_source; - _colormap = dc_colormap; - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(_colormap[_source[loop.sample_index()]], _light, _shade_constants); - *loop.dest = BlendBgra::copy(fg); - } while (loop.next()); - } -}; - -class FillColumnRGBACommand : public DrawerColumnCommand -{ - uint32_t _color; - -public: - FillColumnRGBACommand() - { - uint32_t light = LightBgra::calc_light_multiplier(dc_light); - _color = LightBgra::shade_pal_index_simple(dc_color, light); - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - *loop.dest = BlendBgra::copy(_color); - } while (loop.next()); - } -}; - -class FillAddColumnRGBACommand : public DrawerColumnCommand -{ - uint32_t _srccolor; - -public: - FillAddColumnRGBACommand() - { - _srccolor = dc_srccolor_bgra; - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - - uint32_t alpha = APART(_srccolor); - alpha += alpha >> 7; - - do - { - *loop.dest = BlendBgra::add(_srccolor, *loop.dest, alpha, 256 - alpha); - } while (loop.next()); - } -}; - -class FillAddClampColumnRGBACommand : public DrawerColumnCommand -{ - int _color; - uint32_t _srccolor; - uint32_t _srcalpha; - uint32_t _destalpha; - -public: - FillAddClampColumnRGBACommand() - { - _color = dc_color; - _srccolor = dc_srccolor_bgra; - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - *loop.dest = BlendBgra::add(_srccolor, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - -class FillSubClampColumnRGBACommand : public DrawerColumnCommand -{ - uint32_t _srccolor; - uint32_t _srcalpha; - uint32_t _destalpha; - -public: - FillSubClampColumnRGBACommand() - { - _srccolor = dc_srccolor_bgra; - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - *loop.dest = BlendBgra::sub(_srccolor, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - -class FillRevSubClampColumnRGBACommand : public DrawerColumnCommand -{ - uint32_t _srccolor; - uint32_t _srcalpha; - uint32_t _destalpha; - -public: - FillRevSubClampColumnRGBACommand() - { - _srccolor = dc_srccolor_bgra; - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - *loop.dest = BlendBgra::revsub(_srccolor, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - -class DrawAddColumnRGBACommand : public DrawerColumnCommand -{ - const BYTE * RESTRICT _source; - uint32_t _light; - ShadeConstants _shade_constants; - uint32_t _srcalpha; - uint32_t _destalpha; - BYTE * RESTRICT _colormap; - -public: - DrawAddColumnRGBACommand() - { - _source = dc_source; - _light = LightBgra::calc_light_multiplier(dc_light); - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - _colormap = dc_colormap; - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(_colormap[_source[loop.sample_index()]], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - -class DrawTranslatedColumnRGBACommand : public DrawerColumnCommand -{ - fixed_t _light; - ShadeConstants _shade_constants; - BYTE * RESTRICT _translation; - const BYTE * RESTRICT _source; - -public: - DrawTranslatedColumnRGBACommand() - { - _light = LightBgra::calc_light_multiplier(dc_light); - _shade_constants = dc_shade_constants; - _translation = dc_translation; - _source = dc_source; - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(_translation[_source[loop.sample_index()]], _light, _shade_constants); - *loop.dest = BlendBgra::copy(fg); - } while (loop.next()); - } -}; - -class DrawTlatedAddColumnRGBACommand : public DrawerColumnCommand -{ - fixed_t _light; - ShadeConstants _shade_constants; - BYTE * RESTRICT _translation; - const BYTE * RESTRICT _source; - uint32_t _srcalpha; - uint32_t _destalpha; - -public: - DrawTlatedAddColumnRGBACommand() - { - _light = LightBgra::calc_light_multiplier(dc_light); - _shade_constants = dc_shade_constants; - _translation = dc_translation; - _source = dc_source; - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(_translation[_source[loop.sample_index()]], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - -class DrawShadedColumnRGBACommand : public DrawerColumnCommand -{ -private: - const BYTE * RESTRICT _source; - lighttable_t * RESTRICT _colormap; - uint32_t _color; - -public: - DrawShadedColumnRGBACommand() - { - _source = dc_source; - _colormap = dc_colormap; - _color = LightBgra::shade_pal_index_simple(dc_color, LightBgra::calc_light_multiplier(dc_light)); - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t alpha = clamp(_colormap[_source[loop.sample_index()]], 0, 64) * 4; - uint32_t inv_alpha = 256 - alpha; - *loop.dest = BlendBgra::add(_color, *loop.dest, alpha, inv_alpha); - } while (loop.next()); - } -}; - -class DrawAddClampColumnRGBACommand : public DrawerColumnCommand -{ - const BYTE * RESTRICT _source; - uint32_t _light; - ShadeConstants _shade_constants; - uint32_t _srcalpha; - uint32_t _destalpha; - -public: - DrawAddClampColumnRGBACommand() - { - _source = dc_source; - _light = LightBgra::calc_light_multiplier(dc_light); - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(_source[loop.sample_index()], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - -class DrawAddClampTranslatedColumnRGBACommand : public DrawerColumnCommand -{ - BYTE * RESTRICT _translation; - const BYTE * RESTRICT _source; - uint32_t _light; - ShadeConstants _shade_constants; - uint32_t _srcalpha; - uint32_t _destalpha; - -public: - DrawAddClampTranslatedColumnRGBACommand() - { - _translation = dc_translation; - _source = dc_source; - _light = LightBgra::calc_light_multiplier(dc_light); - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(_translation[_source[loop.sample_index()]], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - -class DrawSubClampColumnRGBACommand : public DrawerColumnCommand -{ - const BYTE * RESTRICT _source; - uint32_t _light; - ShadeConstants _shade_constants; - uint32_t _srcalpha; - uint32_t _destalpha; - -public: - DrawSubClampColumnRGBACommand() - { - _source = dc_source; - _light = LightBgra::calc_light_multiplier(dc_light); - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(_source[loop.sample_index()], _light, _shade_constants); - *loop.dest = BlendBgra::sub(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - -class DrawSubClampTranslatedColumnRGBACommand : public DrawerColumnCommand -{ - const BYTE * RESTRICT _source; - uint32_t _light; - ShadeConstants _shade_constants; - uint32_t _srcalpha; - uint32_t _destalpha; - BYTE * RESTRICT _translation; - -public: - DrawSubClampTranslatedColumnRGBACommand() - { - _source = dc_source; - _light = LightBgra::calc_light_multiplier(dc_light); - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - _translation = dc_translation; - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(_translation[_source[loop.sample_index()]], _light, _shade_constants); - *loop.dest = BlendBgra::sub(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - -class DrawRevSubClampColumnRGBACommand : public DrawerColumnCommand -{ - const BYTE * RESTRICT _source; - uint32_t _light; - ShadeConstants _shade_constants; - uint32_t _srcalpha; - uint32_t _destalpha; - -public: - DrawRevSubClampColumnRGBACommand() - { - _source = dc_source; - _light = LightBgra::calc_light_multiplier(dc_light); - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(_source[loop.sample_index()], _light, _shade_constants); - *loop.dest = BlendBgra::revsub(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - -class DrawRevSubClampTranslatedColumnRGBACommand : public DrawerColumnCommand -{ - const BYTE * RESTRICT _source; - uint32_t _light; - ShadeConstants _shade_constants; - uint32_t _srcalpha; - uint32_t _destalpha; - BYTE * RESTRICT _translation; - -public: - DrawRevSubClampTranslatedColumnRGBACommand() - { - _source = dc_source; - _light = LightBgra::calc_light_multiplier(dc_light); - _shade_constants = dc_shade_constants; - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - _translation = dc_translation; - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(_translation[_source[loop.sample_index()]], _light, _shade_constants); - *loop.dest = BlendBgra::revsub(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - class DrawFuzzColumnRGBACommand : public DrawerCommand { int _x; @@ -1830,32 +1306,32 @@ void R_EndDrawerCommands() void R_DrawColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_FillColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_FillAddColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_FillAddClampColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_FillSubClampColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_FillRevSubClampColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_DrawFuzzColumn_rgba() @@ -1870,52 +1346,52 @@ void R_DrawFuzzColumn_rgba() void R_DrawAddColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_DrawTranslatedColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_DrawTlatedAddColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_DrawShadedColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_DrawAddClampColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_DrawAddClampTranslatedColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_DrawSubClampColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_DrawSubClampTranslatedColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_DrawRevSubClampColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_DrawRevSubClampTranslatedColumn_rgba() { - DrawerCommandQueue::QueueCommand(); + DrawerCommandQueue::QueueCommand(); } void R_DrawSpan_rgba() From 584220edf01cc776169c4524295943276b0a0433 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 7 Oct 2016 04:01:38 +0200 Subject: [PATCH 1038/1509] Move DrawerCommandQueue to its own file --- src/CMakeLists.txt | 1 + src/r_draw_rgba.cpp | 184 ----------------------------------------- src/r_draw_rgba.h | 165 ++----------------------------------- src/r_thread.cpp | 196 ++++++++++++++++++++++++++++++++++++++++++++ src/r_thread.h | 157 +++++++++++++++++++++++++++++++++++ 5 files changed, 359 insertions(+), 344 deletions(-) create mode 100644 src/r_thread.cpp create mode 100644 src/r_thread.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index acbec1612..9f2ee2e28 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1033,6 +1033,7 @@ set( FASTMATH_PCH_SOURCES r_draw_rgba.cpp r_drawt.cpp r_drawt_rgba.cpp + r_thread.cpp r_main.cpp r_plane.cpp r_segs.cpp diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 7da2f183f..43075d0a6 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -50,9 +50,6 @@ extern float rw_light; extern float rw_lightstep; extern int wallshade; -// Use multiple threads when drawing -CVAR(Bool, r_multithreaded, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); - // Use linear filtering when scaling up CVAR(Bool, r_magfilter, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); @@ -64,177 +61,6 @@ CVAR(Bool, r_mipmap, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); ///////////////////////////////////////////////////////////////////////////// -DrawerCommandQueue *DrawerCommandQueue::Instance() -{ - static DrawerCommandQueue queue; - return &queue; -} - -DrawerCommandQueue::DrawerCommandQueue() -{ -} - -DrawerCommandQueue::~DrawerCommandQueue() -{ - StopThreads(); -} - -void* DrawerCommandQueue::AllocMemory(size_t size) -{ - // Make sure allocations remain 16-byte aligned - size = (size + 15) / 16 * 16; - - auto queue = Instance(); - if (queue->memorypool_pos + size > memorypool_size) - return nullptr; - - void *data = queue->memorypool + queue->memorypool_pos; - queue->memorypool_pos += size; - return data; -} - -void DrawerCommandQueue::Begin() -{ - auto queue = Instance(); - queue->Finish(); - queue->threaded_render++; -} - -void DrawerCommandQueue::End() -{ - auto queue = Instance(); - queue->Finish(); - if (queue->threaded_render > 0) - queue->threaded_render--; -} - -void DrawerCommandQueue::WaitForWorkers() -{ - Instance()->Finish(); -} - -void DrawerCommandQueue::Finish() -{ - auto queue = Instance(); - if (queue->commands.empty()) - return; - - // Give worker threads something to do: - - std::unique_lock start_lock(queue->start_mutex); - queue->active_commands.swap(queue->commands); - queue->run_id++; - start_lock.unlock(); - - queue->StartThreads(); - queue->start_condition.notify_all(); - - // Do one thread ourselves: - - DrawerThread thread; - thread.core = 0; - thread.num_cores = (int)(queue->threads.size() + 1); - - for (int pass = 0; pass < queue->num_passes; pass++) - { - thread.pass_start_y = pass * queue->rows_in_pass; - thread.pass_end_y = (pass + 1) * queue->rows_in_pass; - if (pass + 1 == queue->num_passes) - thread.pass_end_y = MAX(thread.pass_end_y, MAXHEIGHT); - - size_t size = queue->active_commands.size(); - for (size_t i = 0; i < size; i++) - { - auto &command = queue->active_commands[i]; - command->Execute(&thread); - } - } - - // Wait for everyone to finish: - - std::unique_lock end_lock(queue->end_mutex); - queue->end_condition.wait(end_lock, [&]() { return queue->finished_threads == queue->threads.size(); }); - - // Clean up batch: - - for (auto &command : queue->active_commands) - command->~DrawerCommand(); - queue->active_commands.clear(); - queue->memorypool_pos = 0; - queue->finished_threads = 0; -} - -void DrawerCommandQueue::StartThreads() -{ - if (!threads.empty()) - return; - - int num_threads = std::thread::hardware_concurrency(); - if (num_threads == 0) - num_threads = 4; - - threads.resize(num_threads - 1); - - for (int i = 0; i < num_threads - 1; i++) - { - DrawerCommandQueue *queue = this; - DrawerThread *thread = &threads[i]; - thread->core = i + 1; - thread->num_cores = num_threads; - thread->thread = std::thread([=]() - { - int run_id = 0; - while (true) - { - // Wait until we are signalled to run: - std::unique_lock start_lock(queue->start_mutex); - queue->start_condition.wait(start_lock, [&]() { return queue->run_id != run_id || queue->shutdown_flag; }); - if (queue->shutdown_flag) - break; - run_id = queue->run_id; - start_lock.unlock(); - - // Do the work: - for (int pass = 0; pass < queue->num_passes; pass++) - { - thread->pass_start_y = pass * queue->rows_in_pass; - thread->pass_end_y = (pass + 1) * queue->rows_in_pass; - if (pass + 1 == queue->num_passes) - thread->pass_end_y = MAX(thread->pass_end_y, MAXHEIGHT); - - size_t size = queue->active_commands.size(); - for (size_t i = 0; i < size; i++) - { - auto &command = queue->active_commands[i]; - command->Execute(thread); - } - } - - // Notify main thread that we finished: - std::unique_lock end_lock(queue->end_mutex); - queue->finished_threads++; - end_lock.unlock(); - queue->end_condition.notify_all(); - } - }); - } -} - -void DrawerCommandQueue::StopThreads() -{ - std::unique_lock lock(start_mutex); - shutdown_flag = true; - lock.unlock(); - start_condition.notify_all(); - for (auto &thread : threads) - thread.thread.join(); - threads.clear(); - lock.lock(); - shutdown_flag = false; -} - -///////////////////////////////////////////////////////////////////////////// - class DrawSpanLLVMCommand : public DrawerCommand { protected: @@ -1294,16 +1120,6 @@ void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) ///////////////////////////////////////////////////////////////////////////// -void R_BeginDrawerCommands() -{ - DrawerCommandQueue::Begin(); -} - -void R_EndDrawerCommands() -{ - DrawerCommandQueue::End(); -} - void R_DrawColumn_rgba() { DrawerCommandQueue::QueueCommand(); diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 34b874179..8b704c0a6 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -25,16 +25,16 @@ #include "r_draw.h" #include "v_palette.h" -#include -#include -#include -#include -#include +#include "r_thread.h" #ifndef NO_SSE #include #endif +struct FSpecialColormap; + +EXTERN_CVAR(Bool, r_mipmap) + ///////////////////////////////////////////////////////////////////////////// // Drawer functions: @@ -118,161 +118,6 @@ void tmvline4_revsubclamp_rgba(); void R_FillColumnHoriz_rgba(); void R_FillSpan_rgba(); -///////////////////////////////////////////////////////////////////////////// -// Multithreaded rendering infrastructure: - -// Redirect drawer commands to worker threads -void R_BeginDrawerCommands(); - -// Wait until all drawers finished executing -void R_EndDrawerCommands(); - -struct FSpecialColormap; -class DrawerCommandQueue; - -// Worker data for each thread executing drawer commands -class DrawerThread -{ -public: - std::thread thread; - - // Thread line index of this thread - int core = 0; - - // Number of active threads - int num_cores = 1; - - // Range of rows processed this pass - int pass_start_y = 0; - int pass_end_y = MAXHEIGHT; - - uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT * 4]; - uint32_t *dc_temp_rgba; - - // Checks if a line is rendered by this thread - bool line_skipped_by_thread(int line) - { - return line < pass_start_y || line >= pass_end_y || line % num_cores != core; - } - - // The number of lines to skip to reach the first line to be rendered by this thread - int skipped_by_thread(int first_line) - { - int pass_skip = MAX(pass_start_y - first_line, 0); - int core_skip = (num_cores - (first_line + pass_skip - core) % num_cores) % num_cores; - return pass_skip + core_skip; - } - - // The number of lines to be rendered by this thread - int count_for_thread(int first_line, int count) - { - int lines_until_pass_end = MAX(pass_end_y - first_line, 0); - count = MIN(count, lines_until_pass_end); - int c = (count - skipped_by_thread(first_line) + num_cores - 1) / num_cores; - return MAX(c, 0); - } - - // Calculate the dest address for the first line to be rendered by this thread - uint32_t *dest_for_thread(int first_line, int pitch, uint32_t *dest) - { - return dest + skipped_by_thread(first_line) * pitch; - } -}; - -// Task to be executed by each worker thread -class DrawerCommand -{ -protected: - int _dest_y; - -public: - DrawerCommand() - { - _dest_y = static_cast((dc_dest - dc_destorg) / (dc_pitch * 4)); - } - - virtual void Execute(DrawerThread *thread) = 0; -}; - -EXTERN_CVAR(Bool, r_multithreaded) -EXTERN_CVAR(Bool, r_mipmap) -EXTERN_CVAR(Int, r_multithreadedmax) - -// Manages queueing up commands and executing them on worker threads -class DrawerCommandQueue -{ - enum { memorypool_size = 16 * 1024 * 1024 }; - char memorypool[memorypool_size]; - size_t memorypool_pos = 0; - - std::vector commands; - - std::vector threads; - - std::mutex start_mutex; - std::condition_variable start_condition; - std::vector active_commands; - bool shutdown_flag = false; - int run_id = 0; - - std::mutex end_mutex; - std::condition_variable end_condition; - size_t finished_threads = 0; - - int threaded_render = 0; - DrawerThread single_core_thread; - int num_passes = 1; - int rows_in_pass = MAXHEIGHT; - - void StartThreads(); - void StopThreads(); - void Finish(); - - static DrawerCommandQueue *Instance(); - - DrawerCommandQueue(); - ~DrawerCommandQueue(); - -public: - // Allocate memory valid for the duration of a command execution - static void* AllocMemory(size_t size); - - // Queue command to be executed by drawer worker threads - template - static void QueueCommand(Types &&... args) - { - auto queue = Instance(); - if (queue->threaded_render == 0 || !r_multithreaded) - { - T command(std::forward(args)...); - command.Execute(&queue->single_core_thread); - } - else - { - void *ptr = AllocMemory(sizeof(T)); - if (!ptr) // Out of memory - render what we got - { - queue->Finish(); - ptr = AllocMemory(sizeof(T)); - if (!ptr) - return; - } - T *command = new (ptr)T(std::forward(args)...); - queue->commands.push_back(command); - } - } - - // Redirects all drawing commands to worker threads until End is called - // Begin/End blocks can be nested. - static void Begin(); - - // End redirection and wait until all worker threads finished executing - static void End(); - - // Waits until all worker threads finished executing - static void WaitForWorkers(); -}; - ///////////////////////////////////////////////////////////////////////////// // Drawer commands: diff --git a/src/r_thread.cpp b/src/r_thread.cpp new file mode 100644 index 000000000..dec0b8c6c --- /dev/null +++ b/src/r_thread.cpp @@ -0,0 +1,196 @@ + +#include +#include "templates.h" +#include "doomdef.h" +#include "i_system.h" +#include "w_wad.h" +#include "r_local.h" +#include "v_video.h" +#include "doomstat.h" +#include "st_stuff.h" +#include "g_game.h" +#include "g_level.h" +#include "r_thread.h" + +CVAR(Bool, r_multithreaded, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); + +void R_BeginDrawerCommands() +{ + DrawerCommandQueue::Begin(); +} + +void R_EndDrawerCommands() +{ + DrawerCommandQueue::End(); +} + +///////////////////////////////////////////////////////////////////////////// + +DrawerCommandQueue *DrawerCommandQueue::Instance() +{ + static DrawerCommandQueue queue; + return &queue; +} + +DrawerCommandQueue::DrawerCommandQueue() +{ +} + +DrawerCommandQueue::~DrawerCommandQueue() +{ + StopThreads(); +} + +void* DrawerCommandQueue::AllocMemory(size_t size) +{ + // Make sure allocations remain 16-byte aligned + size = (size + 15) / 16 * 16; + + auto queue = Instance(); + if (queue->memorypool_pos + size > memorypool_size) + return nullptr; + + void *data = queue->memorypool + queue->memorypool_pos; + queue->memorypool_pos += size; + return data; +} + +void DrawerCommandQueue::Begin() +{ + auto queue = Instance(); + queue->Finish(); + queue->threaded_render++; +} + +void DrawerCommandQueue::End() +{ + auto queue = Instance(); + queue->Finish(); + if (queue->threaded_render > 0) + queue->threaded_render--; +} + +void DrawerCommandQueue::WaitForWorkers() +{ + Instance()->Finish(); +} + +void DrawerCommandQueue::Finish() +{ + auto queue = Instance(); + if (queue->commands.empty()) + return; + + // Give worker threads something to do: + + std::unique_lock start_lock(queue->start_mutex); + queue->active_commands.swap(queue->commands); + queue->run_id++; + start_lock.unlock(); + + queue->StartThreads(); + queue->start_condition.notify_all(); + + // Do one thread ourselves: + + DrawerThread thread; + thread.core = 0; + thread.num_cores = (int)(queue->threads.size() + 1); + + for (int pass = 0; pass < queue->num_passes; pass++) + { + thread.pass_start_y = pass * queue->rows_in_pass; + thread.pass_end_y = (pass + 1) * queue->rows_in_pass; + if (pass + 1 == queue->num_passes) + thread.pass_end_y = MAX(thread.pass_end_y, MAXHEIGHT); + + size_t size = queue->active_commands.size(); + for (size_t i = 0; i < size; i++) + { + auto &command = queue->active_commands[i]; + command->Execute(&thread); + } + } + + // Wait for everyone to finish: + + std::unique_lock end_lock(queue->end_mutex); + queue->end_condition.wait(end_lock, [&]() { return queue->finished_threads == queue->threads.size(); }); + + // Clean up batch: + + for (auto &command : queue->active_commands) + command->~DrawerCommand(); + queue->active_commands.clear(); + queue->memorypool_pos = 0; + queue->finished_threads = 0; +} + +void DrawerCommandQueue::StartThreads() +{ + if (!threads.empty()) + return; + + int num_threads = std::thread::hardware_concurrency(); + if (num_threads == 0) + num_threads = 4; + + threads.resize(num_threads - 1); + + for (int i = 0; i < num_threads - 1; i++) + { + DrawerCommandQueue *queue = this; + DrawerThread *thread = &threads[i]; + thread->core = i + 1; + thread->num_cores = num_threads; + thread->thread = std::thread([=]() + { + int run_id = 0; + while (true) + { + // Wait until we are signalled to run: + std::unique_lock start_lock(queue->start_mutex); + queue->start_condition.wait(start_lock, [&]() { return queue->run_id != run_id || queue->shutdown_flag; }); + if (queue->shutdown_flag) + break; + run_id = queue->run_id; + start_lock.unlock(); + + // Do the work: + for (int pass = 0; pass < queue->num_passes; pass++) + { + thread->pass_start_y = pass * queue->rows_in_pass; + thread->pass_end_y = (pass + 1) * queue->rows_in_pass; + if (pass + 1 == queue->num_passes) + thread->pass_end_y = MAX(thread->pass_end_y, MAXHEIGHT); + + size_t size = queue->active_commands.size(); + for (size_t i = 0; i < size; i++) + { + auto &command = queue->active_commands[i]; + command->Execute(thread); + } + } + + // Notify main thread that we finished: + std::unique_lock end_lock(queue->end_mutex); + queue->finished_threads++; + end_lock.unlock(); + queue->end_condition.notify_all(); + } + }); + } +} + +void DrawerCommandQueue::StopThreads() +{ + std::unique_lock lock(start_mutex); + shutdown_flag = true; + lock.unlock(); + start_condition.notify_all(); + for (auto &thread : threads) + thread.thread.join(); + threads.clear(); + lock.lock(); + shutdown_flag = false; +} diff --git a/src/r_thread.h b/src/r_thread.h new file mode 100644 index 000000000..312c5ad22 --- /dev/null +++ b/src/r_thread.h @@ -0,0 +1,157 @@ + +#pragma once + +#include "r_draw.h" +#include +#include +#include +#include +#include + +// Use multiple threads when drawing +EXTERN_CVAR(Bool, r_multithreaded) + +// Redirect drawer commands to worker threads +void R_BeginDrawerCommands(); + +// Wait until all drawers finished executing +void R_EndDrawerCommands(); + +// Worker data for each thread executing drawer commands +class DrawerThread +{ +public: + std::thread thread; + + // Thread line index of this thread + int core = 0; + + // Number of active threads + int num_cores = 1; + + // Range of rows processed this pass + int pass_start_y = 0; + int pass_end_y = MAXHEIGHT; + + uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT * 4]; + uint32_t *dc_temp_rgba; + + // Checks if a line is rendered by this thread + bool line_skipped_by_thread(int line) + { + return line < pass_start_y || line >= pass_end_y || line % num_cores != core; + } + + // The number of lines to skip to reach the first line to be rendered by this thread + int skipped_by_thread(int first_line) + { + int pass_skip = MAX(pass_start_y - first_line, 0); + int core_skip = (num_cores - (first_line + pass_skip - core) % num_cores) % num_cores; + return pass_skip + core_skip; + } + + // The number of lines to be rendered by this thread + int count_for_thread(int first_line, int count) + { + int lines_until_pass_end = MAX(pass_end_y - first_line, 0); + count = MIN(count, lines_until_pass_end); + int c = (count - skipped_by_thread(first_line) + num_cores - 1) / num_cores; + return MAX(c, 0); + } + + // Calculate the dest address for the first line to be rendered by this thread + uint32_t *dest_for_thread(int first_line, int pitch, uint32_t *dest) + { + return dest + skipped_by_thread(first_line) * pitch; + } +}; + +// Task to be executed by each worker thread +class DrawerCommand +{ +protected: + int _dest_y; + +public: + DrawerCommand() + { + _dest_y = static_cast((dc_dest - dc_destorg) / (dc_pitch * 4)); + } + + virtual void Execute(DrawerThread *thread) = 0; +}; + +// Manages queueing up commands and executing them on worker threads +class DrawerCommandQueue +{ + enum { memorypool_size = 16 * 1024 * 1024 }; + char memorypool[memorypool_size]; + size_t memorypool_pos = 0; + + std::vector commands; + + std::vector threads; + + std::mutex start_mutex; + std::condition_variable start_condition; + std::vector active_commands; + bool shutdown_flag = false; + int run_id = 0; + + std::mutex end_mutex; + std::condition_variable end_condition; + size_t finished_threads = 0; + + int threaded_render = 0; + DrawerThread single_core_thread; + int num_passes = 1; + int rows_in_pass = MAXHEIGHT; + + void StartThreads(); + void StopThreads(); + void Finish(); + + static DrawerCommandQueue *Instance(); + + DrawerCommandQueue(); + ~DrawerCommandQueue(); + +public: + // Allocate memory valid for the duration of a command execution + static void* AllocMemory(size_t size); + + // Queue command to be executed by drawer worker threads + template + static void QueueCommand(Types &&... args) + { + auto queue = Instance(); + if (queue->threaded_render == 0 || !r_multithreaded) + { + T command(std::forward(args)...); + command.Execute(&queue->single_core_thread); + } + else + { + void *ptr = AllocMemory(sizeof(T)); + if (!ptr) // Out of memory - render what we got + { + queue->Finish(); + ptr = AllocMemory(sizeof(T)); + if (!ptr) + return; + } + T *command = new (ptr)T(std::forward(args)...); + queue->commands.push_back(command); + } + } + + // Redirects all drawing commands to worker threads until End is called + // Begin/End blocks can be nested. + static void Begin(); + + // End redirection and wait until all worker threads finished executing + static void End(); + + // Waits until all worker threads finished executing + static void WaitForWorkers(); +}; From 9dc51b27437c6221d1ede9d15808590d9a2a3c58 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 6 Oct 2016 08:50:46 +0200 Subject: [PATCH 1039/1509] - rewrote AActor::DestroyAllInventory so that it clears the item's link to its owner and the owner's inventory list before destroying them. There have been reports about crashes in here with Linux that point to some of the code that gets called here doing unwanted things on the owner, so with these links cleared that should no longer be possible. --- src/p_mobj.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 496f52e86..022504919 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -685,11 +685,30 @@ bool AActor::TakeInventory(PClassActor *itemclass, int amount, bool fromdecorate void AActor::DestroyAllInventory () { - while (Inventory != NULL) + AInventory *inv = Inventory; + if (inv != nullptr) { - AInventory *item = Inventory; - item->Destroy (); - assert (item != Inventory); + TArray toDelete; + + // Delete the list in a two stage approach. + // This is necessary because an item may destroy another item (e.g. sister weapons) + // which would break the list and leave parts of it undestroyed, maybe doing bad things later. + while (inv != nullptr) + { + toDelete.Push(inv); + AInventory *item = inv->Inventory; + inv->Inventory = nullptr; + inv->Owner = nullptr; + inv = item; + } + for (auto p : toDelete) + { + // the item may already have been deleted by another one, so check this here to avoid problems. + if (!(p->ObjectFlags & OF_EuthanizeMe)) + { + p->Destroy(); + } + } } } From f89d47d03ea34fda644f3a618ae61f9bebd9c1f6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 6 Oct 2016 12:08:38 +0200 Subject: [PATCH 1040/1509] - fixed: ZCC_OpInfoType::FindBestProto was missing checks for exact match of the required conversion before testing if it is a F32->F64 conversion. Of course, since 0 means that there is no conversion it also means that there is no data that could be checked. --- src/zscript/zcc_expr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zscript/zcc_expr.cpp b/src/zscript/zcc_expr.cpp index 0cd399d64..e1a091b18 100644 --- a/src/zscript/zcc_expr.cpp +++ b/src/zscript/zcc_expr.cpp @@ -162,11 +162,11 @@ ZCC_OpProto *ZCC_OpInfoType::FindBestProto( // [[float32 (op) int]] will choose the integer version instead of the floating point // version, which we do not want. int test_dist1 = dist1, test_dist2 = dist2; - if (routes[0][cur_route1][0]->ConvertConstant == FtoD) + if (test_dist1 > 0 && routes[0][cur_route1][0]->ConvertConstant == FtoD) { test_dist1--; } - if (routes[1][cur_route2][0]->ConvertConstant == FtoD) + if (test_dist2 > 0 && routes[1][cur_route2][0]->ConvertConstant == FtoD) { test_dist2--; } From 2e78d34046adbe191cd75425e1fbb649d2368958 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 6 Oct 2016 21:20:49 +0200 Subject: [PATCH 1041/1509] - fixed: DCeiling's main constructor could leave some fields uninitialized. --- src/p_ceiling.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index 32e5d62be..e90dd2096 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -214,6 +214,12 @@ DCeiling::DCeiling (sector_t *sec, double speed1, double speed2, int silent) m_Speed = m_Speed1 = speed1; m_Speed2 = speed2; m_Silent = silent; + m_BottomHeight = 0; + m_TopHeight = 0; + m_Direction = 0; + m_Texture = FNullTextureID(); + m_Tag = 0; + m_OldDirection = 0; } //============================================================================ From a80c67c2ca1df6e0a0977eb8e950d5248916dc82 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 6 Oct 2016 20:01:20 -0400 Subject: [PATCH 1042/1509] - Backported blood_fade_scalar from Skulltag - Added new pickup_fade_scalar which works the same way for pickups - Default for blood_fade_scalar is 1.0 instead of 0.5 from Skulltag. --- src/v_blend.cpp | 11 +++++++++-- wadsrc/static/menudef.txt | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/v_blend.cpp b/src/v_blend.cpp index e1552105f..c13ed547c 100644 --- a/src/v_blend.cpp +++ b/src/v_blend.cpp @@ -52,7 +52,8 @@ #include "v_palette.h" #include "d_player.h" - +CVAR( Float, blood_fade_scalar, 1.0f, CVAR_ARCHIVE ) // [SP] Pulled from Skulltag - changed default from 0.5 to 1.0 +CVAR( Float, pickup_fade_scalar, 1.0f, CVAR_ARCHIVE ) // [SP] Uses same logic as blood_fade_scalar except for pickups // [RH] Amount of red flash for up to 114 damage points. Calculated by hand // using a logarithmic scale and my trusty HP48G. @@ -113,6 +114,9 @@ void V_AddPlayerBlend (player_t *CPlayer, float blend[4], float maxinvalpha, int if (CPlayer->bonuscount) { cnt = CPlayer->bonuscount << 3; + + // [SP] Allow player to tone down intensity of pickup flash. + cnt = (int)( cnt * pickup_fade_scalar ); V_AddBlend (RPART(gameinfo.pickupcolor)/255.f, GPART(gameinfo.pickupcolor)/255.f, BPART(gameinfo.pickupcolor)/255.f, cnt > 128 ? 0.5f : cnt / 255.f, blend); @@ -124,7 +128,10 @@ void V_AddPlayerBlend (player_t *CPlayer, float blend[4], float maxinvalpha, int if (painFlash.a != 0) { cnt = DamageToAlpha[MIN (113, CPlayer->damagecount * painFlash.a / 255)]; - + + // [BC] Allow users to tone down the intensity of the blood on the screen. + cnt = (int)( cnt * blood_fade_scalar ); + if (cnt) { if (cnt > maxpainblend) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 36a5918e1..715eff63b 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -674,6 +674,9 @@ OptionMenu "VideoOptions" Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff" Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn" + Slider "$DSPLYMNU_BLOODFADE", "blood_fade_scalar", 0.0, 1.0, 0.05, 1 + Slider "$DSPLYMNU_PICKUPFADE", "pickup_fade_scalar", 0.0, 1.0, 0.05, 1 + Option "$DSPLYMNU_COLUMNMETHOD", "r_columnmethod", "ColumnMethods" Option "$DSPLYMNU_TRUECOLOR", "swtruecolor", "OnOff" Option "$DSPLYMNU_MINFILTER", "r_minfilter", "OnOff" Option "$DSPLYMNU_MAGFILTER", "r_magfilter", "OnOff" @@ -710,6 +713,7 @@ OptionMenu "VideoOptions" Slider "$DSPLYMNU_MOVEBOB", "movebob", 0, 1.0, 0.05, 2 Slider "$DSPLYMNU_STILLBOB", "stillbob", 0, 1.0, 0.05, 2 Slider "$DSPLYMNU_BOBSPEED", "wbobspeed", 0, 2.0, 0.1, 2 + } //------------------------------------------------------------------------------------------- From e75cf427566008ef0793079075b32ebf670d0904 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 6 Oct 2016 20:05:30 -0400 Subject: [PATCH 1043/1509] - Forgot to add language entries. --- wadsrc/static/language.enu | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index a0f1f9245..c76414c8a 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1786,6 +1786,8 @@ DSPLYMNU_MAGFILTER = "Linear filter when upscaling"; DSPLYMNU_MIPMAP = "Use mipmapped textures"; DSPLYMNU_WIPETYPE = "Screen wipe style"; DSPLYMNU_SHOWENDOOM = "Show ENDOOM screen"; +DSPLYMNU_BLOODFADE = "Blood Flash Intensity"; +DSPLYMNU_PICKUPFADE = "Pickup Flash Intensity"; DSPLYMNU_PALLETEHACK = "DirectDraw palette hack"; // Not used DSPLYMNU_ATTACHEDSURFACES = "Use attached surfaces"; // Not used DSPLYMNU_STRETCHSKY = "Stretch short skies"; From 8c259f50b10c7b797f3e10e794436df75f522503 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 7 Oct 2016 06:40:29 +0200 Subject: [PATCH 1044/1509] Add codegen for rt column drawers --- .../fixedfunction/drawcolumncodegen.cpp | 182 +++++++++++------- .../fixedfunction/drawcolumncodegen.h | 13 +- src/r_compiler/fixedfunction/drawercodegen.h | 1 + src/r_compiler/llvmdrawers.cpp | 75 +++++--- src/r_compiler/llvmdrawers.h | 23 ++- src/r_draw_rgba.cpp | 1 + src/r_drawt_rgba.cpp | 134 +++++++++---- 7 files changed, 292 insertions(+), 137 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp index 116744f1c..601358274 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp @@ -11,7 +11,7 @@ #include "r_compiler/ssa/ssa_struct_type.h" #include "r_compiler/ssa/ssa_value.h" -void DrawColumnCodegen::Generate(DrawColumnVariant variant, SSAValue args, SSAValue thread_data) +void DrawColumnCodegen::Generate(DrawColumnVariant variant, DrawColumnMethod method, SSAValue args, SSAValue thread_data) { dest = args[0][0].load(); source = args[0][1].load(); @@ -21,7 +21,8 @@ void DrawColumnCodegen::Generate(DrawColumnVariant variant, SSAValue args, SSAVa pitch = args[0][5].load(); count = args[0][6].load(); dest_y = args[0][7].load(); - iscale = args[0][8].load(); + if (method == DrawColumnMethod::Normal) + iscale = args[0][8].load(); texturefrac = args[0][9].load(); light = args[0][10].load(); color = SSAVec4i::unpack(args[0][11].load()); @@ -46,109 +47,148 @@ void DrawColumnCodegen::Generate(DrawColumnVariant variant, SSAValue args, SSAVa thread.num_cores = thread_data[0][1].load(); thread.pass_start_y = thread_data[0][2].load(); thread.pass_end_y = thread_data[0][3].load(); + thread.temp = thread_data[0][4].load(); is_simple_shade = (flags & DrawColumnArgs::simple_shade) == SSAInt(DrawColumnArgs::simple_shade); count = count_for_thread(dest_y, count, thread); dest = dest_for_thread(dest_y, pitch, dest, thread); pitch = pitch * thread.num_cores; - stack_frac.store(texturefrac + iscale * skipped_by_thread(dest_y, thread)); - iscale = iscale * thread.num_cores; + if (method == DrawColumnMethod::Normal) + { + stack_frac.store(texturefrac + iscale * skipped_by_thread(dest_y, thread)); + iscale = iscale * thread.num_cores; + } + else + { + source = thread.temp[((dest_y + skipped_by_thread(dest_y, thread)) * 4 + texturefrac) * 4]; + } SSAIfBlock branch; branch.if_block(is_simple_shade); - Loop(variant, true); + Loop(variant, method, true); branch.else_block(); - Loop(variant, false); + Loop(variant, method, false); branch.end_block(); } -void DrawColumnCodegen::Loop(DrawColumnVariant variant, bool isSimpleShade) +void DrawColumnCodegen::Loop(DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade) { + SSAInt sincr; + if (method != DrawColumnMethod::Normal) + sincr = thread.num_cores * 4; + stack_index.store(SSAInt(0)); { SSAForBlock loop; SSAInt index = stack_index.load(); loop.loop_block(index < count); - SSAInt frac = stack_frac.load(); - - SSAInt offset = index * pitch * 4; - SSAVec4i bgcolor = dest[offset].load_vec4ub(); - - SSAInt alpha, inv_alpha; - SSAVec4i outcolor; - switch (variant) + SSAInt sample_index, frac; + if (method == DrawColumnMethod::Normal) { - default: - case DrawColumnVariant::Draw: - outcolor = blend_copy(Shade(ColormapSample(frac), isSimpleShade)); - break; - case DrawColumnVariant::DrawAdd: - case DrawColumnVariant::DrawAddClamp: - outcolor = blend_add(Shade(ColormapSample(frac), isSimpleShade), bgcolor, srcalpha, destalpha); - break; - case DrawColumnVariant::DrawShaded: - alpha = SSAInt::MAX(SSAInt::MIN(ColormapSample(frac), SSAInt(64)), SSAInt(0)) * 4; - inv_alpha = 256 - alpha; - outcolor = blend_add(color, bgcolor, alpha, inv_alpha); - break; - case DrawColumnVariant::DrawSubClamp: - outcolor = blend_sub(Shade(ColormapSample(frac), isSimpleShade), bgcolor, srcalpha, destalpha); - break; - case DrawColumnVariant::DrawRevSubClamp: - outcolor = blend_revsub(Shade(ColormapSample(frac), isSimpleShade), bgcolor, srcalpha, destalpha); - break; - case DrawColumnVariant::DrawTranslated: - outcolor = blend_copy(Shade(TranslateSample(frac), isSimpleShade)); - break; - case DrawColumnVariant::DrawTlatedAdd: - case DrawColumnVariant::DrawAddClampTranslated: - outcolor = blend_add(Shade(TranslateSample(frac), isSimpleShade), bgcolor, srcalpha, destalpha); - break; - case DrawColumnVariant::DrawSubClampTranslated: - outcolor = blend_sub(Shade(TranslateSample(frac), isSimpleShade), bgcolor, srcalpha, destalpha); - break; - case DrawColumnVariant::DrawRevSubClampTranslated: - outcolor = blend_revsub(Shade(TranslateSample(frac), isSimpleShade), bgcolor, srcalpha, destalpha); - break; - case DrawColumnVariant::Fill: - outcolor = blend_copy(color); - break; - case DrawColumnVariant::FillAdd: - alpha = srccolor[3]; - alpha = alpha + (alpha >> 7); - inv_alpha = 256 - alpha; - outcolor = blend_add(srccolor, bgcolor, alpha, inv_alpha); - break; - case DrawColumnVariant::FillAddClamp: - outcolor = blend_add(srccolor, bgcolor, srcalpha, destalpha); - break; - case DrawColumnVariant::FillSubClamp: - outcolor = blend_sub(srccolor, bgcolor, srcalpha, destalpha); - break; - case DrawColumnVariant::FillRevSubClamp: - outcolor = blend_revsub(srccolor, bgcolor, srcalpha, destalpha); - break; + frac = stack_frac.load(); + sample_index = frac >> FRACBITS; + } + else + { + sample_index = index * sincr * 4; } - dest[offset].store_vec4ub(outcolor); + SSAInt offset = index * pitch * 4; + SSAVec4i bgcolor[4]; + + int numColumns = (method == DrawColumnMethod::Rt4) ? 4 : 1; + + if (numColumns == 4) + { + SSAVec16ub bg = dest[offset].load_unaligned_vec16ub(); + SSAVec8s bg0 = SSAVec8s::extendlo(bg); + SSAVec8s bg1 = SSAVec8s::extendhi(bg); + bgcolor[0] = SSAVec4i::extendlo(bg0); + bgcolor[1] = SSAVec4i::extendhi(bg0); + bgcolor[2] = SSAVec4i::extendlo(bg1); + bgcolor[3] = SSAVec4i::extendhi(bg1); + } + else + { + bgcolor[0] = dest[offset].load_vec4ub(); + } + + SSAVec4i outcolor[4]; + for (int i = 0; i < numColumns; i++) + outcolor[i] = ProcessPixel(sample_index + i * 4, bgcolor[i], variant, isSimpleShade); + + if (numColumns == 4) + { + SSAVec16ub packedcolor(SSAVec8s(outcolor[0], outcolor[1]), SSAVec8s(outcolor[2], outcolor[3])); + dest[offset].store_unaligned_vec16ub(packedcolor); + } + else + { + dest[offset].store_vec4ub(outcolor[0]); + } stack_index.store(index + 1); - stack_frac.store(frac + iscale); + if (method == DrawColumnMethod::Normal) + stack_frac.store(frac + iscale); loop.end_block(); } } -SSAInt DrawColumnCodegen::ColormapSample(SSAInt frac) +SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade) +{ + SSAInt alpha, inv_alpha; + switch (variant) + { + default: + case DrawColumnVariant::DrawCopy: + return blend_copy(basecolors[ColormapSample(sample_index) * 4].load_vec4ub()); + case DrawColumnVariant::Draw: + return blend_copy(Shade(ColormapSample(sample_index), isSimpleShade)); + case DrawColumnVariant::DrawAdd: + case DrawColumnVariant::DrawAddClamp: + return blend_add(Shade(ColormapSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + case DrawColumnVariant::DrawShaded: + alpha = SSAInt::MAX(SSAInt::MIN(ColormapSample(sample_index), SSAInt(64)), SSAInt(0)) * 4; + inv_alpha = 256 - alpha; + return blend_add(color, bgcolor, alpha, inv_alpha); + case DrawColumnVariant::DrawSubClamp: + return blend_sub(Shade(ColormapSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + case DrawColumnVariant::DrawRevSubClamp: + return blend_revsub(Shade(ColormapSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + case DrawColumnVariant::DrawTranslated: + return blend_copy(Shade(TranslateSample(sample_index), isSimpleShade)); + case DrawColumnVariant::DrawTlatedAdd: + case DrawColumnVariant::DrawAddClampTranslated: + return blend_add(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + case DrawColumnVariant::DrawSubClampTranslated: + return blend_sub(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + case DrawColumnVariant::DrawRevSubClampTranslated: + return blend_revsub(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + case DrawColumnVariant::Fill: + return blend_copy(color); + case DrawColumnVariant::FillAdd: + alpha = srccolor[3]; + alpha = alpha + (alpha >> 7); + inv_alpha = 256 - alpha; + return blend_add(srccolor, bgcolor, alpha, inv_alpha); + case DrawColumnVariant::FillAddClamp: + return blend_add(srccolor, bgcolor, srcalpha, destalpha); + case DrawColumnVariant::FillSubClamp: + return blend_sub(srccolor, bgcolor, srcalpha, destalpha); + case DrawColumnVariant::FillRevSubClamp: + return blend_revsub(srccolor, bgcolor, srcalpha, destalpha); + } +} + +SSAInt DrawColumnCodegen::ColormapSample(SSAInt sample_index) { - SSAInt sample_index = frac >> FRACBITS; return colormap[source[sample_index].load().zext_int()].load().zext_int(); } -SSAInt DrawColumnCodegen::TranslateSample(SSAInt frac) +SSAInt DrawColumnCodegen::TranslateSample(SSAInt sample_index) { - SSAInt sample_index = frac >> FRACBITS; return translation[source[sample_index].load().zext_int()].load().zext_int(); } diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.h b/src/r_compiler/fixedfunction/drawcolumncodegen.h index 488c36295..675a5ea67 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.h +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.h @@ -10,6 +10,7 @@ enum class DrawColumnVariant FillAddClamp, FillSubClamp, FillRevSubClamp, + DrawCopy, Draw, DrawAdd, DrawTranslated, @@ -23,13 +24,21 @@ enum class DrawColumnVariant DrawRevSubClampTranslated }; +enum class DrawColumnMethod +{ + Normal, + Rt1, + Rt4 +}; + class DrawColumnCodegen : public DrawerCodegen { public: - void Generate(DrawColumnVariant variant, SSAValue args, SSAValue thread_data); + void Generate(DrawColumnVariant variant, DrawColumnMethod method, SSAValue args, SSAValue thread_data); private: - void Loop(DrawColumnVariant variant, bool isSimpleShade); + void Loop(DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade); + SSAVec4i ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade); SSAInt ColormapSample(SSAInt frac); SSAInt TranslateSample(SSAInt frac); SSAVec4i Shade(SSAInt palIndex, bool isSimpleShade); diff --git a/src/r_compiler/fixedfunction/drawercodegen.h b/src/r_compiler/fixedfunction/drawercodegen.h index 17b36234d..27dc6f21d 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.h +++ b/src/r_compiler/fixedfunction/drawercodegen.h @@ -25,6 +25,7 @@ public: SSAInt num_cores; SSAInt pass_start_y; SSAInt pass_end_y; + SSAUBytePtr temp; }; class SSAShadeConstants diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 6ab4f5a4f..3108b8c6a 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -47,7 +47,7 @@ public: LLVMDrawersImpl(); private: - void CodegenDrawColumn(const char *name, DrawColumnVariant variant); + void CodegenDrawColumn(const char *name, DrawColumnVariant variant, DrawColumnMethod method); void CodegenDrawSpan(const char *name, DrawSpanVariant variant); void CodegenDrawWall(const char *name, DrawWallVariant variant, int columns); @@ -84,22 +84,36 @@ LLVMDrawers *LLVMDrawers::Instance() LLVMDrawersImpl::LLVMDrawersImpl() { - CodegenDrawColumn("FillColumn", DrawColumnVariant::Fill); - CodegenDrawColumn("FillColumnAdd", DrawColumnVariant::FillAdd); - CodegenDrawColumn("FillColumnAddClamp", DrawColumnVariant::FillAddClamp); - CodegenDrawColumn("FillColumnSubClamp", DrawColumnVariant::FillSubClamp); - CodegenDrawColumn("FillColumnRevSubClamp", DrawColumnVariant::FillRevSubClamp); - CodegenDrawColumn("DrawColumn", DrawColumnVariant::Draw); - CodegenDrawColumn("DrawColumnAdd", DrawColumnVariant::DrawAdd); - CodegenDrawColumn("DrawColumnTranslated", DrawColumnVariant::DrawTranslated); - CodegenDrawColumn("DrawColumnTlatedAdd", DrawColumnVariant::DrawTlatedAdd); - CodegenDrawColumn("DrawColumnShaded", DrawColumnVariant::DrawShaded); - CodegenDrawColumn("DrawColumnAddClamp", DrawColumnVariant::DrawAddClamp); - CodegenDrawColumn("DrawColumnAddClampTranslated", DrawColumnVariant::DrawAddClampTranslated); - CodegenDrawColumn("DrawColumnSubClamp", DrawColumnVariant::DrawSubClamp); - CodegenDrawColumn("DrawColumnSubClampTranslated", DrawColumnVariant::DrawSubClampTranslated); - CodegenDrawColumn("DrawColumnRevSubClamp", DrawColumnVariant::DrawRevSubClamp); - CodegenDrawColumn("DrawColumnRevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated); + CodegenDrawColumn("FillColumn", DrawColumnVariant::Fill, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnAdd", DrawColumnVariant::FillAdd, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnAddClamp", DrawColumnVariant::FillAddClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnSubClamp", DrawColumnVariant::FillSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnRevSubClamp", DrawColumnVariant::FillRevSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumn", DrawColumnVariant::Draw, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnAdd", DrawColumnVariant::DrawAdd, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnShaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnAddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnSubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnRevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnTranslated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnTlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnAddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnSubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnRevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnRt1", DrawColumnVariant::Draw, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt4", DrawColumnVariant::Draw, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt4); CodegenDrawSpan("DrawSpan", DrawSpanVariant::Opaque); CodegenDrawSpan("DrawSpanMasked", DrawSpanVariant::Masked); CodegenDrawSpan("DrawSpanTranslucent", DrawSpanVariant::Translucent); @@ -129,15 +143,29 @@ LLVMDrawersImpl::LLVMDrawersImpl() FillColumnRevSubClamp = mProgram.GetProcAddress("FillColumnRevSubClamp"); DrawColumn = mProgram.GetProcAddress("DrawColumn"); DrawColumnAdd = mProgram.GetProcAddress("DrawColumnAdd"); - DrawColumnTranslated = mProgram.GetProcAddress("DrawColumnTranslated"); - DrawColumnTlatedAdd = mProgram.GetProcAddress("DrawColumnTlatedAdd"); DrawColumnShaded = mProgram.GetProcAddress("DrawColumnShaded"); DrawColumnAddClamp = mProgram.GetProcAddress("DrawColumnAddClamp"); - DrawColumnAddClampTranslated = mProgram.GetProcAddress("DrawColumnAddClampTranslated"); DrawColumnSubClamp = mProgram.GetProcAddress("DrawColumnSubClamp"); - DrawColumnSubClampTranslated = mProgram.GetProcAddress("DrawColumnSubClampTranslated"); DrawColumnRevSubClamp = mProgram.GetProcAddress("DrawColumnRevSubClamp"); + DrawColumnTranslated = mProgram.GetProcAddress("DrawColumnTranslated"); + DrawColumnTlatedAdd = mProgram.GetProcAddress("DrawColumnTlatedAdd"); + DrawColumnAddClampTranslated = mProgram.GetProcAddress("DrawColumnAddClampTranslated"); + DrawColumnSubClampTranslated = mProgram.GetProcAddress("DrawColumnSubClampTranslated"); DrawColumnRevSubClampTranslated = mProgram.GetProcAddress("DrawColumnRevSubClampTranslated"); + DrawColumnRt1 = mProgram.GetProcAddress("DrawColumnRt1"); + DrawColumnRt1Copy = mProgram.GetProcAddress("DrawColumnRt1Copy"); + DrawColumnRt1Add = mProgram.GetProcAddress("DrawColumnRt1Add"); + DrawColumnRt1Shaded = mProgram.GetProcAddress("DrawColumnRt1Shaded"); + DrawColumnRt1AddClamp = mProgram.GetProcAddress("DrawColumnRt1AddClamp"); + DrawColumnRt1SubClamp = mProgram.GetProcAddress("DrawColumnRt1SubClamp"); + DrawColumnRt1RevSubClamp = mProgram.GetProcAddress("DrawColumnRt1RevSubClamp"); + DrawColumnRt4 = mProgram.GetProcAddress("DrawColumnRt4"); + DrawColumnRt4Copy = mProgram.GetProcAddress("DrawColumnRt4Copy"); + DrawColumnRt4Add = mProgram.GetProcAddress("DrawColumnRt4Add"); + DrawColumnRt4Shaded = mProgram.GetProcAddress("DrawColumnRt4Shaded"); + DrawColumnRt4AddClamp = mProgram.GetProcAddress("DrawColumnRt4AddClamp"); + DrawColumnRt4SubClamp = mProgram.GetProcAddress("DrawColumnRt4SubClamp"); + DrawColumnRt4RevSubClamp = mProgram.GetProcAddress("DrawColumnRt4RevSubClamp"); DrawSpan = mProgram.GetProcAddress("DrawSpan"); DrawSpanMasked = mProgram.GetProcAddress("DrawSpanMasked"); DrawSpanTranslucent = mProgram.GetProcAddress("DrawSpanTranslucent"); @@ -160,7 +188,7 @@ LLVMDrawersImpl::LLVMDrawersImpl() mProgram.StopLogFatalErrors(); } -void LLVMDrawersImpl::CodegenDrawColumn(const char *name, DrawColumnVariant variant) +void LLVMDrawersImpl::CodegenDrawColumn(const char *name, DrawColumnVariant variant, DrawColumnMethod method) { llvm::IRBuilder<> builder(mProgram.context()); SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); @@ -171,7 +199,7 @@ void LLVMDrawersImpl::CodegenDrawColumn(const char *name, DrawColumnVariant vari function.create_public(); DrawColumnCodegen codegen; - codegen.Generate(variant, function.parameter(0), function.parameter(1)); + codegen.Generate(variant, method, function.parameter(0), function.parameter(1)); builder.CreateRetVoid(); @@ -310,6 +338,7 @@ llvm::Type *LLVMDrawersImpl::GetWorkerThreadDataStruct(llvm::LLVMContext &contex std::vector elements; for (int i = 0; i < 4; i++) elements.push_back(llvm::Type::getInt32Ty(context)); + elements.push_back(llvm::Type::getInt8PtrTy(context)); return llvm::StructType::get(context, elements, false)->getPointerTo(); } diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 2ce4c5230..549825e4f 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -7,6 +7,7 @@ struct WorkerThreadData int32_t num_cores; int32_t pass_start_y; int32_t pass_end_y; + uint32_t *temp; }; struct DrawWallArgs @@ -122,20 +123,34 @@ public: void(*DrawColumn)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawColumnAdd)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnTlatedAdd)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawColumnShaded)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawColumnAddClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnAddClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawColumnSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnSubClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawColumnRevSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnTlatedAdd)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnAddClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnSubClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawColumnRevSubClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*FillColumn)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*FillColumnAdd)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*FillColumnAddClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*FillColumnSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*FillColumnRevSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt1)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt1Copy)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt1Add)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt1Shaded)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt1AddClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt1SubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt1RevSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt4)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt4Copy)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt4Add)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt4Shaded)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt4AddClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt4SubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt4RevSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawSpan)(const DrawSpanArgs *) = nullptr; void(*DrawSpanMasked)(const DrawSpanArgs *) = nullptr; diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 43075d0a6..b875bd413 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -334,6 +334,7 @@ public: class name##LLVMCommand : public base \ { \ public: \ + using base::base; \ void Execute(DrawerThread *thread) override \ { \ WorkerThreadData d = ThreadData(thread); \ diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 45bd5c029..a73ba643c 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -43,6 +43,7 @@ #include "r_things.h" #include "v_video.h" #include "r_draw_rgba.h" +#include "r_compiler/llvmdrawers.h" #ifndef NO_SSE #include #endif @@ -89,6 +90,89 @@ extern unsigned int *horizspan[4]; ///////////////////////////////////////////////////////////////////////////// +class DrawColumnRt1LLVMCommand : public DrawerCommand +{ +protected: + DrawColumnArgs args; + + WorkerThreadData ThreadData(DrawerThread *thread) + { + WorkerThreadData d; + d.core = thread->core; + d.num_cores = thread->num_cores; + d.pass_start_y = thread->pass_start_y; + d.pass_end_y = thread->pass_end_y; + d.temp = thread->dc_temp_rgba; + return d; + } + +public: + DrawColumnRt1LLVMCommand(int hx, int sx, int yl, int yh) + { + args.dest = (uint32_t*)dc_destorg + ylookup[yl] + sx; + args.source = nullptr; + args.colormap = dc_colormap; + args.translation = dc_translation; + args.basecolors = (const uint32_t *)GPalette.BaseColors; + args.pitch = dc_pitch; + args.count = yh - yl + 1; + args.dest_y = yl; + args.iscale = dc_iscale; + args.texturefrac = hx; + args.light = LightBgra::calc_light_multiplier(dc_light); + args.color = LightBgra::shade_pal_index_simple(dc_color, args.light); + args.srccolor = dc_srccolor_bgra; + args.srcalpha = dc_srcalpha >> (FRACBITS - 8); + args.destalpha = dc_destalpha >> (FRACBITS - 8); + args.light_red = dc_shade_constants.light_red; + args.light_green = dc_shade_constants.light_green; + args.light_blue = dc_shade_constants.light_blue; + args.light_alpha = dc_shade_constants.light_alpha; + args.fade_red = dc_shade_constants.fade_red; + args.fade_green = dc_shade_constants.fade_green; + args.fade_blue = dc_shade_constants.fade_blue; + args.fade_alpha = dc_shade_constants.fade_alpha; + args.desaturate = dc_shade_constants.desaturate; + args.flags = 0; + if (dc_shade_constants.simple_shade) + args.flags |= DrawColumnArgs::simple_shade; + } + + void Execute(DrawerThread *thread) override + { + WorkerThreadData d = ThreadData(thread); + LLVMDrawers::Instance()->DrawColumnRt1(&args, &d); + } +}; + +#define DECLARE_DRAW_COMMAND(name, func, base) \ +class name##LLVMCommand : public base \ +{ \ +public: \ + using base::base; \ + void Execute(DrawerThread *thread) override \ + { \ + WorkerThreadData d = ThreadData(thread); \ + LLVMDrawers::Instance()->func(&args, &d); \ + } \ +}; + +DECLARE_DRAW_COMMAND(DrawColumnRt1Copy, DrawColumnRt1Copy, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt1Add, DrawColumnRt1Add, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt1Shaded, DrawColumnRt1Shaded, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt1AddClamp, DrawColumnRt1AddClamp, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt1SubClamp, DrawColumnRt1SubClamp, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt1RevSubClamp, DrawColumnRt1RevSubClamp, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt4, DrawColumnRt4, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt4Copy, DrawColumnRt4Copy, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt4Add, DrawColumnRt4Add, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt4Shaded, DrawColumnRt4Shaded, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt4AddClamp, DrawColumnRt4AddClamp, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt4SubClamp, DrawColumnRt4SubClamp, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt4RevSubClamp, DrawColumnRt4RevSubClamp, DrawColumnRt1LLVMCommand); + +///////////////////////////////////////////////////////////////////////////// + class DrawerRt1colCommand : public DrawerCommand { public: @@ -756,7 +840,7 @@ public: // Copies one span at hx to the screen at sx. void rt_copy1col_rgba (int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Copies all four spans to the screen starting at sx. @@ -772,17 +856,13 @@ void rt_copy4cols_rgba (int sx, int yl, int yh) // Maps one span at hx to the screen at sx. void rt_map1col_rgba (int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Maps all four spans to the screen starting at sx. void rt_map4cols_rgba (int sx, int yl, int yh) { -#ifdef NO_SSE - DrawerCommandQueue::QueueCommand(sx, yl, yh); -#else - DrawerCommandQueue::QueueCommand(sx, yl, yh); -#endif + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } void rt_Translate1col_rgba(const BYTE *translation, int hx, int yl, int yh) @@ -812,17 +892,13 @@ void rt_tlate4cols_rgba (int sx, int yl, int yh) // Adds one span at hx to the screen at sx without clamping. void rt_add1col_rgba (int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Adds all four spans to the screen starting at sx without clamping. void rt_add4cols_rgba (int sx, int yl, int yh) { -#ifdef NO_SSE - DrawerCommandQueue::QueueCommand(sx, yl, yh); -#else - DrawerCommandQueue::QueueCommand(sx, yl, yh); -#endif + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Translates and adds one span at hx to the screen at sx without clamping. @@ -842,33 +918,25 @@ void rt_tlateadd4cols_rgba(int sx, int yl, int yh) // Shades one span at hx to the screen at sx. void rt_shaded1col_rgba (int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Shades all four spans to the screen starting at sx. void rt_shaded4cols_rgba (int sx, int yl, int yh) { -#ifdef NO_SSE - DrawerCommandQueue::QueueCommand(sx, yl, yh); -#else - DrawerCommandQueue::QueueCommand(sx, yl, yh); -#endif + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Adds one span at hx to the screen at sx with clamping. void rt_addclamp1col_rgba (int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Adds all four spans to the screen starting at sx with clamping. void rt_addclamp4cols_rgba (int sx, int yl, int yh) { -#ifdef NO_SSE - DrawerCommandQueue::QueueCommand(sx, yl, yh); -#else - DrawerCommandQueue::QueueCommand(sx, yl, yh); -#endif + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Translates and adds one span at hx to the screen at sx with clamping. @@ -888,17 +956,13 @@ void rt_tlateaddclamp4cols_rgba (int sx, int yl, int yh) // Subtracts one span at hx to the screen at sx with clamping. void rt_subclamp1col_rgba (int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Subtracts all four spans to the screen starting at sx with clamping. void rt_subclamp4cols_rgba (int sx, int yl, int yh) { -#ifdef NO_SSE - DrawerCommandQueue::QueueCommand(sx, yl, yh); -#else - DrawerCommandQueue::QueueCommand(sx, yl, yh); -#endif + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Translates and subtracts one span at hx to the screen at sx with clamping. @@ -918,17 +982,13 @@ void rt_tlatesubclamp4cols_rgba (int sx, int yl, int yh) // Subtracts one span at hx from the screen at sx with clamping. void rt_revsubclamp1col_rgba (int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Subtracts all four spans from the screen starting at sx with clamping. void rt_revsubclamp4cols_rgba (int sx, int yl, int yh) { -#ifdef NO_SSE - DrawerCommandQueue::QueueCommand(sx, yl, yh); -#else - DrawerCommandQueue::QueueCommand(sx, yl, yh); -#endif + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Translates and subtracts one span at hx from the screen at sx with clamping. From 78415461b90ad7e406507ddb93d26707ae57874b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 7 Oct 2016 06:56:20 +0200 Subject: [PATCH 1045/1509] Removed old SSE macros and drawers --- src/r_draw_rgba.cpp | 35 +- src/r_draw_rgba.h | 550 ------------------------------ src/r_drawt_rgba.cpp | 446 ------------------------ src/r_drawt_rgba_sse.h | 757 ----------------------------------------- 4 files changed, 31 insertions(+), 1757 deletions(-) delete mode 100644 src/r_drawt_rgba_sse.h diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index b875bd413..424d3140b 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -63,9 +63,6 @@ CVAR(Bool, r_mipmap, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); class DrawSpanLLVMCommand : public DrawerCommand { -protected: - DrawSpanArgs args; - public: DrawSpanLLVMCommand() { @@ -96,7 +93,7 @@ public: args.flags = 0; if (ds_shade_constants.simple_shade) args.flags |= DrawSpanArgs::simple_shade; - if (!SampleBgra::span_sampler_setup(args.source, args.xbits, args.ybits, args.xstep, args.ystep, ds_source_mipmapped)) + if (!sampler_setup(args.source, args.xbits, args.ybits, args.xstep, args.ystep, ds_source_mipmapped)) args.flags |= DrawSpanArgs::nearest_filter; } @@ -106,6 +103,36 @@ public: return; LLVMDrawers::Instance()->DrawSpan(&args); } + +protected: + DrawSpanArgs args; + +private: + inline static bool sampler_setup(const uint32_t * &source, int &xbits, int &ybits, fixed_t xstep, fixed_t ystep, bool mipmapped) + { + // Is this a magfilter or minfilter? + fixed_t xmagnitude = abs(xstep) >> (32 - xbits - FRACBITS); + fixed_t ymagnitude = abs(ystep) >> (32 - ybits - FRACBITS); + fixed_t magnitude = (xmagnitude + ymagnitude) * 2 + (1 << (FRACBITS - 1)); + bool magnifying = (magnitude >> FRACBITS == 0); + + if (r_mipmap && mipmapped) + { + int level = magnitude >> (FRACBITS + 1); + while (level != 0) + { + if (xbits <= 2 || ybits <= 2) + break; + + source += (1 << (xbits)) * (1 << (ybits)); + xbits -= 1; + ybits -= 1; + level >>= 1; + } + } + + return (magnifying && r_magfilter) || (!magnifying && r_minfilter); + } }; class DrawSpanMaskedLLVMCommand : public DrawSpanLLVMCommand diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 8b704c0a6..d3ad0613a 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -283,554 +283,4 @@ public: } }; -class BlendBgra -{ -public: - FORCEINLINE static uint32_t copy(uint32_t fg) - { - return fg; - } - - FORCEINLINE static uint32_t add(uint32_t fg, uint32_t bg, uint32_t srcalpha, uint32_t destalpha) - { - uint32_t red = MIN((RPART(fg) * srcalpha + RPART(bg) * destalpha) >> 8, 255); - uint32_t green = MIN((GPART(fg) * srcalpha + GPART(bg) * destalpha) >> 8, 255); - uint32_t blue = MIN((BPART(fg) * srcalpha + BPART(bg) * destalpha) >> 8, 255); - return 0xff000000 | (red << 16) | (green << 8) | blue; - } - - FORCEINLINE static uint32_t sub(uint32_t fg, uint32_t bg, uint32_t srcalpha, uint32_t destalpha) - { - uint32_t red = clamp((0x10000 - RPART(fg) * srcalpha + RPART(bg) * destalpha) >> 8, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 - GPART(fg) * srcalpha + GPART(bg) * destalpha) >> 8, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 - BPART(fg) * srcalpha + BPART(bg) * destalpha) >> 8, 256, 256 + 255) - 256; - return 0xff000000 | (red << 16) | (green << 8) | blue; - } - - FORCEINLINE static uint32_t revsub(uint32_t fg, uint32_t bg, uint32_t srcalpha, uint32_t destalpha) - { - uint32_t red = clamp((0x10000 + RPART(fg) * srcalpha - RPART(bg) * destalpha) >> 8, 256, 256 + 255) - 256; - uint32_t green = clamp((0x10000 + GPART(fg) * srcalpha - GPART(bg) * destalpha) >> 8, 256, 256 + 255) - 256; - uint32_t blue = clamp((0x10000 + BPART(fg) * srcalpha - BPART(bg) * destalpha) >> 8, 256, 256 + 255) - 256; - return 0xff000000 | (red << 16) | (green << 8) | blue; - } - - FORCEINLINE static uint32_t alpha_blend(uint32_t fg, uint32_t bg) - { - uint32_t alpha = APART(fg) + (APART(fg) >> 7); // 255 -> 256 - uint32_t inv_alpha = 256 - alpha; - uint32_t red = MIN(RPART(fg) * alpha + (RPART(bg) * inv_alpha) / 256, 255); - uint32_t green = MIN(GPART(fg) * alpha + (GPART(bg) * inv_alpha) / 256, 255); - uint32_t blue = MIN(BPART(fg) * alpha + (BPART(bg) * inv_alpha) / 256, 255); - return 0xff000000 | (red << 16) | (green << 8) | blue; - } -}; - -class SampleBgra -{ -public: - inline static bool span_sampler_setup(const uint32_t * RESTRICT &source, int &xbits, int &ybits, fixed_t xstep, fixed_t ystep, bool mipmapped) - { - // Is this a magfilter or minfilter? - fixed_t xmagnitude = abs(xstep) >> (32 - xbits - FRACBITS); - fixed_t ymagnitude = abs(ystep) >> (32 - ybits - FRACBITS); - fixed_t magnitude = (xmagnitude + ymagnitude) * 2 + (1 << (FRACBITS - 1)); - bool magnifying = (magnitude >> FRACBITS == 0); - - if (r_mipmap && mipmapped) - { - int level = magnitude >> (FRACBITS + 1); - while (level != 0) - { - if (xbits <= 2 || ybits <= 2) - break; - - source += (1 << (xbits)) * (1 << (ybits)); - xbits -= 1; - ybits -= 1; - level >>= 1; - } - } - - return (magnifying && r_magfilter) || (!magnifying && r_minfilter); - } - - FORCEINLINE static uint32_t sample_bilinear(const uint32_t *col0, const uint32_t *col1, uint32_t texturefracx, uint32_t texturefracy, uint32_t one, uint32_t height) - { - uint32_t frac_y0 = (texturefracy >> FRACBITS) * height; - uint32_t frac_y1 = ((texturefracy + one) >> FRACBITS) * height; - uint32_t y0 = frac_y0 >> FRACBITS; - uint32_t y1 = frac_y1 >> FRACBITS; - - uint32_t p00 = col0[y0]; - uint32_t p01 = col0[y1]; - uint32_t p10 = col1[y0]; - uint32_t p11 = col1[y1]; - - uint32_t inv_b = texturefracx; - uint32_t inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; - uint32_t a = 16 - inv_a; - uint32_t b = 16 - inv_b; - - uint32_t red = (RPART(p00) * a * b + RPART(p01) * inv_a * b + RPART(p10) * a * inv_b + RPART(p11) * inv_a * inv_b + 127) >> 8; - uint32_t green = (GPART(p00) * a * b + GPART(p01) * inv_a * b + GPART(p10) * a * inv_b + GPART(p11) * inv_a * inv_b + 127) >> 8; - uint32_t blue = (BPART(p00) * a * b + BPART(p01) * inv_a * b + BPART(p10) * a * inv_b + BPART(p11) * inv_a * inv_b + 127) >> 8; - uint32_t alpha = (APART(p00) * a * b + APART(p01) * inv_a * b + APART(p10) * a * inv_b + APART(p11) * inv_a * inv_b + 127) >> 8; - - return (alpha << 24) | (red << 16) | (green << 8) | blue; - } - - FORCEINLINE static uint32_t sample_bilinear(const uint32_t *texture, dsfixed_t xfrac, dsfixed_t yfrac, int xbits, int ybits) - { - int xshift = (32 - xbits); - int yshift = (32 - ybits); - int xmask = (1 << xshift) - 1; - int ymask = (1 << yshift) - 1; - uint32_t x = xfrac >> xbits; - uint32_t y = yfrac >> ybits; - - uint32_t p00 = texture[(y & ymask) + ((x & xmask) << yshift)]; - uint32_t p01 = texture[((y + 1) & ymask) + ((x & xmask) << yshift)]; - uint32_t p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)]; - uint32_t p11 = texture[((y + 1) & ymask) + (((x + 1) & xmask) << yshift)]; - - uint32_t inv_b = (xfrac >> (xbits - 4)) & 15; - uint32_t inv_a = (yfrac >> (ybits - 4)) & 15; - uint32_t a = 16 - inv_a; - uint32_t b = 16 - inv_b; - - uint32_t red = (RPART(p00) * a * b + RPART(p01) * inv_a * b + RPART(p10) * a * inv_b + RPART(p11) * inv_a * inv_b + 127) >> 8; - uint32_t green = (GPART(p00) * a * b + GPART(p01) * inv_a * b + GPART(p10) * a * inv_b + GPART(p11) * inv_a * inv_b + 127) >> 8; - uint32_t blue = (BPART(p00) * a * b + BPART(p01) * inv_a * b + BPART(p10) * a * inv_b + BPART(p11) * inv_a * inv_b + 127) >> 8; - uint32_t alpha = (APART(p00) * a * b + APART(p01) * inv_a * b + APART(p10) * a * inv_b + APART(p11) * inv_a * inv_b + 127) >> 8; - - return (alpha << 24) | (red << 16) | (green << 8) | blue; - } -}; - -///////////////////////////////////////////////////////////////////////////// -// SSE/AVX shading macros: - -#define AVX2_SAMPLE_BILINEAR4_COLUMN_INIT(col0, col1, one, height, texturefracx) \ - const uint32_t *baseptr = col0[0]; \ - __m128i coloffsets0 = _mm_setr_epi32(col0[0] - baseptr, col0[1] - baseptr, col0[2] - baseptr, col0[3] - baseptr); \ - __m128i coloffsets1 = _mm_setr_epi32(col1[0] - baseptr, col1[1] - baseptr, col1[2] - baseptr, col1[3] - baseptr); \ - __m128i mone = _mm_loadu_si128((const __m128i*)one); \ - __m128i m127 = _mm_set1_epi16(127); \ - __m128i m16 = _mm_set1_epi32(16); \ - __m128i m15 = _mm_set1_epi32(15); \ - __m128i mheight = _mm_loadu_si128((const __m128i*)height); \ - __m128i mtexturefracx = _mm_loadu_si128((const __m128i*)texturefracx); - -#define AVX2_SAMPLE_BILINEAR4_COLUMN(fg, texturefracy) { \ - __m128i mtexturefracy = _mm_loadu_si128((const __m128i*)texturefracy); \ - __m128i multmp0 = _mm_srli_epi32(mtexturefracy, FRACBITS); \ - __m128i multmp1 = _mm_srli_epi32(_mm_add_epi32(mtexturefracy, mone), FRACBITS); \ - __m128i frac_y0 = _mm_or_si128(_mm_mul_epu32(multmp0, mheight), _mm_slli_si128(_mm_mul_epu32(_mm_srli_si128(multmp0, 4), _mm_srli_si128(mheight, 4)), 4)); \ - __m128i frac_y1 = _mm_or_si128(_mm_mul_epu32(multmp1, mheight), _mm_slli_si128(_mm_mul_epu32(_mm_srli_si128(multmp1, 4), _mm_srli_si128(mheight, 4)), 4)); \ - __m128i y0 = _mm_srli_epi32(frac_y0, FRACBITS); \ - __m128i y1 = _mm_srli_epi32(frac_y1, FRACBITS); \ - __m128i inv_b = mtexturefracx; \ - __m128i inv_a = _mm_and_si128(_mm_srli_epi32(frac_y1, FRACBITS - 4), m15); \ - __m128i a = _mm_sub_epi32(m16, inv_a); \ - __m128i b = _mm_sub_epi32(m16, inv_b); \ - __m128i ab = _mm_mullo_epi16(a, b); \ - __m128i invab = _mm_mullo_epi16(inv_a, b); \ - __m128i ainvb = _mm_mullo_epi16(a, inv_b); \ - __m128i invainvb = _mm_mullo_epi16(inv_a, inv_b); \ - __m128i ab_lo = _mm_shuffle_epi32(ab, _MM_SHUFFLE(1, 1, 0, 0)); \ - __m128i ab_hi = _mm_shuffle_epi32(ab, _MM_SHUFFLE(3, 3, 2, 2)); \ - __m128i invab_lo = _mm_shuffle_epi32(invab, _MM_SHUFFLE(1, 1, 0, 0)); \ - __m128i invab_hi = _mm_shuffle_epi32(invab, _MM_SHUFFLE(3, 3, 2, 2)); \ - __m128i ainvb_lo = _mm_shuffle_epi32(ainvb, _MM_SHUFFLE(1, 1, 0, 0)); \ - __m128i ainvb_hi = _mm_shuffle_epi32(ainvb, _MM_SHUFFLE(3, 3, 2, 2)); \ - __m128i invainvb_lo = _mm_shuffle_epi32(invainvb, _MM_SHUFFLE(1, 1, 0, 0)); \ - __m128i invainvb_hi = _mm_shuffle_epi32(invainvb, _MM_SHUFFLE(3, 3, 2, 2)); \ - ab_lo = _mm_or_si128(ab_lo, _mm_slli_epi32(ab_lo, 16)); \ - ab_hi = _mm_or_si128(ab_hi, _mm_slli_epi32(ab_hi, 16)); \ - invab_lo = _mm_or_si128(invab_lo, _mm_slli_epi32(invab_lo, 16)); \ - invab_hi = _mm_or_si128(invab_hi, _mm_slli_epi32(invab_hi, 16)); \ - ainvb_lo = _mm_or_si128(ainvb_lo, _mm_slli_epi32(ainvb_lo, 16)); \ - ainvb_hi = _mm_or_si128(ainvb_hi, _mm_slli_epi32(ainvb_hi, 16)); \ - invainvb_lo = _mm_or_si128(invainvb_lo, _mm_slli_epi32(invainvb_lo, 16)); \ - invainvb_hi = _mm_or_si128(invainvb_hi, _mm_slli_epi32(invainvb_hi, 16)); \ - __m128i p00 = _mm_i32gather_epi32((const int *)baseptr, _mm_add_epi32(y0, coloffsets0), 4); \ - __m128i p01 = _mm_i32gather_epi32((const int *)baseptr, _mm_add_epi32(y1, coloffsets0), 4); \ - __m128i p10 = _mm_i32gather_epi32((const int *)baseptr, _mm_add_epi32(y0, coloffsets1), 4); \ - __m128i p11 = _mm_i32gather_epi32((const int *)baseptr, _mm_add_epi32(y1, coloffsets1), 4); \ - __m128i p00_lo = _mm_mullo_epi16(_mm_unpacklo_epi8(p00, _mm_setzero_si128()), ab_lo); \ - __m128i p01_lo = _mm_mullo_epi16(_mm_unpacklo_epi8(p01, _mm_setzero_si128()), invab_lo); \ - __m128i p10_lo = _mm_mullo_epi16(_mm_unpacklo_epi8(p10, _mm_setzero_si128()), ainvb_lo); \ - __m128i p11_lo = _mm_mullo_epi16(_mm_unpacklo_epi8(p11, _mm_setzero_si128()), invainvb_lo); \ - __m128i p00_hi = _mm_mullo_epi16(_mm_unpackhi_epi8(p00, _mm_setzero_si128()), ab_hi); \ - __m128i p01_hi = _mm_mullo_epi16(_mm_unpackhi_epi8(p01, _mm_setzero_si128()), invab_hi); \ - __m128i p10_hi = _mm_mullo_epi16(_mm_unpackhi_epi8(p10, _mm_setzero_si128()), ainvb_hi); \ - __m128i p11_hi = _mm_mullo_epi16(_mm_unpackhi_epi8(p11, _mm_setzero_si128()), invainvb_hi); \ - __m128i fg_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_adds_epu16(p00_lo, p01_lo), _mm_adds_epu16(p10_lo, p11_lo)), m127), 8); \ - __m128i fg_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_adds_epu16(p00_hi, p01_hi), _mm_adds_epu16(p10_hi, p11_hi)), m127), 8); \ - fg = _mm_packus_epi16(fg_lo, fg_hi); \ -} - -#define VEC_SAMPLE_BILINEAR4_COLUMN(fg, col0, col1, texturefracx, texturefracy, one, height) { \ - __m128i m127 = _mm_set1_epi16(127); \ - fg = _mm_setzero_si128(); \ - for (int i = 0; i < 4; i++) \ - { \ - uint32_t frac_y0 = (texturefracy[i] >> FRACBITS) * height[i]; \ - uint32_t frac_y1 = ((texturefracy[i] + one[i]) >> FRACBITS) * height[i]; \ - uint32_t y0 = (frac_y0 >> FRACBITS); \ - uint32_t y1 = (frac_y1 >> FRACBITS); \ - \ - uint32_t inv_b = texturefracx[i]; \ - uint32_t inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; \ - \ - __m128i ab_invab = _mm_load_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2); \ - __m128i ainvb_invainvb = _mm_load_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2 + 1); \ - \ - __m128i gather = _mm_set_epi32(col1[i][y1], col1[i][y0], col0[i][y1], col0[i][y0]); \ - __m128i p0 = _mm_unpacklo_epi8(gather, _mm_setzero_si128()); \ - __m128i p1 = _mm_unpackhi_epi8(gather, _mm_setzero_si128()); \ - \ - __m128i tmp = _mm_adds_epu16(_mm_mullo_epi16(p0, ab_invab), _mm_mullo_epi16(p1, ainvb_invainvb)); \ - __m128i color = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_srli_si128(tmp, 8), tmp), m127), 8); \ - \ - fg = _mm_or_si128(_mm_srli_si128(fg, 4), _mm_slli_si128(_mm_packus_epi16(color, _mm_setzero_si128()), 12)); \ - } \ -} - -#define VEC_SAMPLE_MIP_NEAREST4_COLUMN(fg, col0, col1, mipfrac, texturefracy, height0, height1) { \ - uint32_t y0[4], y1[4]; \ - for (int i = 0; i < 4; i++) \ - { \ - y0[i] = (texturefracy[i] >> FRACBITS) * height0[i]; \ - y1[i] = (texturefracy[i] >> FRACBITS) * height1[i]; \ - } \ - __m128i p0 = _mm_set_epi32(col0[y0[3]], col0[y0[2]], col0[y0[1]], col0[y0[0]]); \ - __m128i p1 = _mm_set_epi32(col1[y1[3]], col1[y1[2]], col1[y1[1]], col1[y1[0]]); \ - __m128i t = _mm_loadu_si128((const __m128i*)mipfrac); \ - __m128i inv_t = _mm_sub_epi32(_mm_set1_epi32(256), mipfrac); \ - __m128i p0_lo = _mm_unpacklo_epi8(p0, _mm_setzero_si128()); \ - __m128i p0_hi = _mm_unpackhi_epi8(p0, _mm_setzero_si128()); \ - __m128i p1_lo = _mm_unpacklo_epi8(p1, _mm_setzero_si128()); \ - __m128i p1_hi = _mm_unpackhi_epi8(p1, _mm_setzero_si128()); \ - __m128i fg_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(p0_lo, t), _mm_mullo_epi16(p1_lo, inv_t)), 8); \ - __m128i fg_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(p0_hi, t), _mm_mullo_epi16(p1_hi, inv_t)), 8); \ - fg = _mm_packus_epi16(fg_lo, fg_hi); \ -} - -#define VEC_SAMPLE_BILINEAR4_SPAN(fg, texture, xfrac, yfrac, xstep, ystep, xbits, ybits) { \ - int xshift = (32 - xbits); \ - int yshift = (32 - ybits); \ - int xmask = (1 << xshift) - 1; \ - int ymask = (1 << yshift) - 1; \ - \ - __m128i m127 = _mm_set1_epi16(127); \ - fg = _mm_setzero_si128(); \ - for (int i = 0; i < 4; i++) \ - { \ - uint32_t x = xfrac >> xbits; \ - uint32_t y = yfrac >> ybits; \ - \ - uint32_t p00 = texture[(y & ymask) + ((x & xmask) << yshift)]; \ - uint32_t p01 = texture[((y + 1) & ymask) + ((x & xmask) << yshift)]; \ - uint32_t p10 = texture[(y & ymask) + (((x + 1) & xmask) << yshift)]; \ - uint32_t p11 = texture[((y + 1) & ymask) + (((x + 1) & xmask) << yshift)]; \ - \ - uint32_t inv_b = (xfrac >> (xbits - 4)) & 15; \ - uint32_t inv_a = (yfrac >> (ybits - 4)) & 15; \ - \ - __m128i ab_invab = _mm_load_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2); \ - __m128i ainvb_invainvb = _mm_load_si128(SampleBgra::samplertable + inv_b * 32 + inv_a * 2 + 1); \ - \ - __m128i p0 = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, p01, p00), _mm_setzero_si128()); \ - __m128i p1 = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, p11, p10), _mm_setzero_si128()); \ - \ - __m128i tmp = _mm_adds_epu16(_mm_mullo_epi16(p0, ab_invab), _mm_mullo_epi16(p1, ainvb_invainvb)); \ - __m128i color = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_srli_si128(tmp, 8), tmp), m127), 8); \ - \ - fg = _mm_or_si128(_mm_srli_si128(fg, 4), _mm_slli_si128(_mm_packus_epi16(color, _mm_setzero_si128()), 12)); \ - \ - xfrac += xstep; \ - yfrac += ystep; \ - } \ -} - -// Calculate constants for a simple shade with gamma correction -#define AVX_LINEAR_SHADE_SIMPLE_INIT(light) \ - __m256 mlight_hi = _mm256_set_ps(1.0f, light * (1.0f/256.0f), light * (1.0f/256.0f), light * (1.0f/256.0f), 1.0f, light * (1.0f/256.0f), light * (1.0f/256.0f), light * (1.0f/256.0f)); \ - mlight_hi = _mm256_mul_ps(mlight_hi, mlight_hi); \ - __m256 mlight_lo = mlight_hi; \ - __m256 mrcp_255 = _mm256_set1_ps(1.0f/255.0f); \ - __m256 m255 = _mm256_set1_ps(255.0f); - -// Calculate constants for a simple shade with different light levels for each pixel and gamma correction -#define AVX_LINEAR_SHADE_SIMPLE_INIT4(light3, light2, light1, light0) \ - __m256 mlight_hi = _mm256_set_ps(1.0f, light1 * (1.0f/256.0f), light1 * (1.0f/256.0f), light1 * (1.0f/256.0f), 1.0f, light0 * (1.0f/256.0f), light0 * (1.0f/256.0f), light0 * (1.0f/256.0f)); \ - __m256 mlight_lo = _mm256_set_ps(1.0f, light3 * (1.0f/256.0f), light3 * (1.0f/256.0f), light3 * (1.0f/256.0f), 1.0f, light2 * (1.0f/256.0f), light2 * (1.0f/256.0f), light2 * (1.0f/256.0f)); \ - mlight_hi = _mm256_mul_ps(mlight_hi, mlight_hi); \ - mlight_lo = _mm256_mul_ps(mlight_lo, mlight_lo); \ - __m256 mrcp_255 = _mm256_set1_ps(1.0f/255.0f); \ - __m256 m255 = _mm256_set1_ps(255.0f); - -// Simple shade 4 pixels with gamma correction -#define AVX_LINEAR_SHADE_SIMPLE(fg) { \ - __m256i fg_16 = _mm256_set_m128i(_mm_unpackhi_epi8(fg, _mm_setzero_si128()), _mm_unpacklo_epi8(fg, _mm_setzero_si128())); \ - __m256 fg_hi = _mm256_cvtepi32_ps(_mm256_unpackhi_epi16(fg_16, _mm256_setzero_si256())); \ - __m256 fg_lo = _mm256_cvtepi32_ps(_mm256_unpacklo_epi16(fg_16, _mm256_setzero_si256())); \ - fg_hi = _mm256_mul_ps(fg_hi, mrcp_255); \ - fg_hi = _mm256_mul_ps(fg_hi, fg_hi); \ - fg_hi = _mm256_mul_ps(fg_hi, mlight_hi); \ - fg_hi = _mm256_sqrt_ps(fg_hi); \ - fg_hi = _mm256_mul_ps(fg_hi, m255); \ - fg_lo = _mm256_mul_ps(fg_lo, mrcp_255); \ - fg_lo = _mm256_mul_ps(fg_lo, fg_lo); \ - fg_lo = _mm256_mul_ps(fg_lo, mlight_lo); \ - fg_lo = _mm256_sqrt_ps(fg_lo); \ - fg_lo = _mm256_mul_ps(fg_lo, m255); \ - fg_16 = _mm256_packus_epi32(_mm256_cvtps_epi32(fg_lo), _mm256_cvtps_epi32(fg_hi)); \ - fg = _mm_packus_epi16(_mm256_extractf128_si256(fg_16, 0), _mm256_extractf128_si256(fg_16, 1)); \ -} - -// Calculate constants for a complex shade with gamma correction -#define AVX_LINEAR_SHADE_INIT(light, shade_constants) \ - __m256 mlight_hi = _mm256_set_ps(1.0f, light * (1.0f/256.0f), light * (1.0f/256.0f), light * (1.0f/256.0f), 1.0f, light * (1.0f/256.0f), light * (1.0f/256.0f), light * (1.0f/256.0f)); \ - mlight_hi = _mm256_mul_ps(mlight_hi, mlight_hi); \ - __m256 mlight_lo = mlight_hi; \ - __m256 mrcp_255 = _mm256_set1_ps(1.0f/255.0f); \ - __m256 m255 = _mm256_set1_ps(255.0f); \ - __m256 color = _mm256_set_ps( \ - 1.0f, shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f), \ - 1.0f, shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f)); \ - __m256 fade = _mm256_set_ps( \ - 0.0f, shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f), \ - 0.0f, shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f)); \ - __m256 fade_amount_hi = _mm256_mul_ps(fade, _mm256_sub_ps(_mm256_set1_ps(1.0f), mlight_hi)); \ - __m256 fade_amount_lo = _mm256_mul_ps(fade, _mm256_sub_ps(_mm256_set1_ps(1.0f), mlight_lo)); \ - __m256 inv_desaturate = _mm256_set1_ps((256 - shade_constants.desaturate) * (1.0f/256.0f)); \ - __m128 ss_desaturate = _mm_set_ss(shade_constants.desaturate * (1.0f/256.0f)); \ - __m128 intensity_weight = _mm_set_ps(0.0f, 77.0f/256.0f, 143.0f/256.0f, 37.0f/256.0f); - -// Calculate constants for a complex shade with different light levels for each pixel and gamma correction -#define AVX_LINEAR_SHADE_INIT4(light3, light2, light1, light0, shade_constants) \ - __m256 mlight_hi = _mm256_set_ps(1.0f, light1 * (1.0f/256.0f), light1 * (1.0f/256.0f), light1 * (1.0f/256.0f), 1.0f, light0 * (1.0f/256.0f), light0 * (1.0f/256.0f), light0 * (1.0f/256.0f)); \ - __m256 mlight_lo = _mm256_set_ps(1.0f, light3 * (1.0f/256.0f), light3 * (1.0f/256.0f), light3 * (1.0f/256.0f), 1.0f, light2 * (1.0f/256.0f), light2 * (1.0f/256.0f), light2 * (1.0f/256.0f)); \ - mlight_hi = _mm256_mul_ps(mlight_hi, mlight_hi); \ - mlight_lo = _mm256_mul_ps(mlight_lo, mlight_lo); \ - __m256 mrcp_255 = _mm256_set1_ps(1.0f/255.0f); \ - __m256 m255 = _mm256_set1_ps(255.0f); \ - __m256 color = _mm256_set_ps( \ - 1.0f, shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f), \ - 1.0f, shade_constants.light_red * (1.0f/256.0f), shade_constants.light_green * (1.0f/256.0f), shade_constants.light_blue * (1.0f/256.0f)); \ - __m256 fade = _mm256_set_ps( \ - 0.0f, shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f), \ - 0.0f, shade_constants.fade_red * (1.0f/256.0f), shade_constants.fade_green * (1.0f/256.0f), shade_constants.fade_blue * (1.0f/256.0f)); \ - __m256 fade_amount_hi = _mm256_mul_ps(fade, _mm256_sub_ps(_mm256_set1_ps(1.0f), mlight_hi)); \ - __m256 fade_amount_lo = _mm256_mul_ps(fade, _mm256_sub_ps(_mm256_set1_ps(1.0f), mlight_lo)); \ - __m256 inv_desaturate = _mm256_set1_ps((256 - shade_constants.desaturate) * (1.0f/256.0f)); \ - __m128 ss_desaturate = _mm_set_ss(shade_constants.desaturate * (1.0f/256.0f)); \ - __m128 intensity_weight = _mm_set_ps(0.0f, 77.0f/256.0f, 143.0f/256.0f, 37.0f/256.0f); - -// Complex shade 4 pixels with gamma correction -#define AVX_LINEAR_SHADE(fg, shade_constants) { \ - __m256i fg_16 = _mm256_set_m128i(_mm_unpackhi_epi8(fg, _mm_setzero_si128()), _mm_unpacklo_epi8(fg, _mm_setzero_si128())); \ - __m256 fg_hi = _mm256_cvtepi32_ps(_mm256_unpackhi_epi16(fg_16, _mm256_setzero_si256())); \ - __m256 fg_lo = _mm256_cvtepi32_ps(_mm256_unpacklo_epi16(fg_16, _mm256_setzero_si256())); \ - fg_hi = _mm256_mul_ps(fg_hi, mrcp_255); \ - fg_hi = _mm256_mul_ps(fg_hi, fg_hi); \ - fg_lo = _mm256_mul_ps(fg_lo, mrcp_255); \ - fg_lo = _mm256_mul_ps(fg_lo, fg_lo); \ - \ - __m128 intensity_hi0 = _mm_mul_ps(_mm256_extractf128_ps(fg_hi, 0), intensity_weight); \ - __m128 intensity_hi1 = _mm_mul_ps(_mm256_extractf128_ps(fg_hi, 1), intensity_weight); \ - intensity_hi0 = _mm_mul_ss(_mm_add_ss(_mm_add_ss(intensity_hi0, _mm_shuffle_ps(intensity_hi0, intensity_hi0, _MM_SHUFFLE(1,1,1,1))), _mm_shuffle_ps(intensity_hi0, intensity_hi0, _MM_SHUFFLE(2,2,2,2))), ss_desaturate); \ - intensity_hi0 = _mm_shuffle_ps(intensity_hi0, intensity_hi0, _MM_SHUFFLE(0,0,0,0)); \ - intensity_hi1 = _mm_mul_ss(_mm_add_ss(_mm_add_ss(intensity_hi1, _mm_shuffle_ps(intensity_hi1, intensity_hi1, _MM_SHUFFLE(1,1,1,1))), _mm_shuffle_ps(intensity_hi1, intensity_hi1, _MM_SHUFFLE(2,2,2,2))), ss_desaturate); \ - intensity_hi1 = _mm_shuffle_ps(intensity_hi1, intensity_hi1, _MM_SHUFFLE(0,0,0,0)); \ - __m256 intensity_hi = _mm256_set_m128(intensity_hi1, intensity_hi0); \ - \ - fg_hi = _mm256_add_ps(_mm256_mul_ps(fg_hi, inv_desaturate), intensity_hi); \ - fg_hi = _mm256_add_ps(_mm256_mul_ps(fg_hi, mlight_hi), fade_amount_hi); \ - fg_hi = _mm256_mul_ps(fg_hi, color); \ - \ - __m128 intensity_lo0 = _mm_mul_ps(_mm256_extractf128_ps(fg_lo, 0), intensity_weight); \ - __m128 intensity_lo1 = _mm_mul_ps(_mm256_extractf128_ps(fg_lo, 1), intensity_weight); \ - intensity_lo0 = _mm_mul_ss(_mm_add_ss(_mm_add_ss(intensity_lo0, _mm_shuffle_ps(intensity_lo0, intensity_lo0, _MM_SHUFFLE(1,1,1,1))), _mm_shuffle_ps(intensity_lo0, intensity_lo0, _MM_SHUFFLE(2,2,2,2))), ss_desaturate); \ - intensity_lo0 = _mm_shuffle_ps(intensity_lo0, intensity_lo0, _MM_SHUFFLE(0,0,0,0)); \ - intensity_lo1 = _mm_mul_ss(_mm_add_ss(_mm_add_ss(intensity_lo1, _mm_shuffle_ps(intensity_lo1, intensity_lo1, _MM_SHUFFLE(1,1,1,1))), _mm_shuffle_ps(intensity_lo1, intensity_lo1, _MM_SHUFFLE(2,2,2,2))), ss_desaturate); \ - intensity_lo1 = _mm_shuffle_ps(intensity_lo1, intensity_lo1, _MM_SHUFFLE(0,0,0,0)); \ - __m256 intensity_lo = _mm256_set_m128(intensity_lo1, intensity_lo0); \ - \ - fg_lo = _mm256_add_ps(_mm256_mul_ps(fg_lo, inv_desaturate), intensity_lo); \ - fg_lo = _mm256_add_ps(_mm256_mul_ps(fg_lo, mlight_lo), fade_amount_lo); \ - fg_lo = _mm256_mul_ps(fg_lo, color); \ - \ - fg_hi = _mm256_sqrt_ps(fg_hi); \ - fg_hi = _mm256_mul_ps(fg_hi, m255); \ - fg_lo = _mm256_sqrt_ps(fg_lo); \ - fg_lo = _mm256_mul_ps(fg_lo, m255); \ - fg_16 = _mm256_packus_epi32(_mm256_cvtps_epi32(fg_lo), _mm256_cvtps_epi32(fg_hi)); \ - fg = _mm_packus_epi16(_mm256_extractf128_si256(fg_16, 0), _mm256_extractf128_si256(fg_16, 1)); \ -} - -/* -// Complex shade 8 pixels -#define AVX_SHADE(fg, shade_constants) { \ - __m256i fg_hi = _mm256_unpackhi_epi8(fg, _mm256_setzero_si256()); \ - __m256i fg_lo = _mm256_unpacklo_epi8(fg, _mm256_setzero_si256()); \ - \ - __m256i intensity_hi = _mm256_mullo_epi16(fg_hi, _mm256_set_epi16(0, 77, 143, 37, 0, 77, 143, 37, 0, 77, 143, 37, 0, 77, 143, 37)); \ - __m256i intensity_lo = _mm256_mullo_epi16(fg_lo, _mm256_set_epi16(0, 77, 143, 37, 0, 77, 143, 37, 0, 77, 143, 37, 0, 77, 143, 37)); \ - __m256i intensity = _mm256_mullo_epi16(_mm256_srli_epi16(_mm256_hadd_epi16(_mm256_hadd_epi16(intensity_lo, intensity_hi), _mm256_setzero_si256()), 8), desaturate); \ - intensity = _mm256_unpacklo_epi16(intensity, intensity); \ - intensity_hi = _mm256_unpackhi_epi32(intensity, intensity); \ - intensity_lo = _mm256_unpacklo_epi32(intensity, intensity); \ - \ - fg_hi = _mm256_srli_epi16(_mm256_adds_epu16(_mm256_mullo_epi16(fg_hi, inv_desaturate), intensity_hi), 8); \ - fg_hi = _mm256_srli_epi16(_mm256_adds_epu16(_mm256_mullo_epi16(fg_hi, mlight), fade_amount), 8); \ - fg_hi = _mm256_srli_epi16(_mm256_mullo_epi16(fg_hi, color), 8); \ - \ - fg_lo = _mm256_srli_epi16(_mm256_adds_epu16(_mm256_mullo_epi16(fg_lo, inv_desaturate), intensity_lo), 8); \ - fg_lo = _mm256_srli_epi16(_mm256_adds_epu16(_mm256_mullo_epi16(fg_lo, mlight), fade_amount), 8); \ - fg_lo = _mm256_srli_epi16(_mm256_mullo_epi16(fg_lo, color), 8); \ - \ - fg = _mm256_packus_epi16(fg_lo, fg_hi); \ -} -*/ - -// Normal premultiplied alpha blend using the alpha from fg -#define VEC_ALPHA_BLEND(fg,bg) { \ - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); \ - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); \ - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); \ - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); \ - __m128i m256 = _mm_set1_epi16(256); \ - __m128i alpha_hi = _mm_shufflehi_epi16(_mm_shufflelo_epi16(fg_hi, _MM_SHUFFLE(3,3,3,3)), _MM_SHUFFLE(3,3,3,3)); \ - __m128i alpha_lo = _mm_shufflehi_epi16(_mm_shufflelo_epi16(fg_lo, _MM_SHUFFLE(3,3,3,3)), _MM_SHUFFLE(3,3,3,3)); \ - alpha_hi = _mm_add_epi16(alpha_hi, _mm_srli_epi16(alpha_hi, 7)); \ - alpha_lo = _mm_add_epi16(alpha_lo, _mm_srli_epi16(alpha_lo, 7)); \ - __m128i inv_alpha_hi = _mm_sub_epi16(m256, alpha_hi); \ - __m128i inv_alpha_lo = _mm_sub_epi16(m256, alpha_lo); \ - fg_hi = _mm_mullo_epi16(fg_hi, alpha_hi); \ - fg_hi = _mm_srli_epi16(fg_hi, 8); \ - fg_lo = _mm_mullo_epi16(fg_lo, alpha_lo); \ - fg_lo = _mm_srli_epi16(fg_lo, 8); \ - fg = _mm_packus_epi16(fg_lo, fg_hi); \ - bg_hi = _mm_mullo_epi16(bg_hi, inv_alpha_hi); \ - bg_hi = _mm_srli_epi16(bg_hi, 8); \ - bg_lo = _mm_mullo_epi16(bg_lo, inv_alpha_lo); \ - bg_lo = _mm_srli_epi16(bg_lo, 8); \ - bg = _mm_packus_epi16(bg_lo, bg_hi); \ - fg = _mm_adds_epu8(fg, bg); \ -} - -// Calculates the final alpha values to be used when combined with the source texture alpha channel -FORCEINLINE uint32_t calc_blend_bgalpha(uint32_t fg, uint32_t dest_alpha) -{ - uint32_t alpha = fg >> 24; - alpha += alpha >> 7; - uint32_t inv_alpha = 256 - alpha; - return (dest_alpha * alpha + 256 * inv_alpha + 128) >> 8; -} - -#define VEC_CALC_BLEND_ALPHA_VARS() __m128i msrc_alpha, mdest_alpha, m256, m255, m128; - -#define VEC_CALC_BLEND_ALPHA_INIT(src_alpha, dest_alpha) \ - msrc_alpha = _mm_set1_epi16(src_alpha); \ - mdest_alpha = _mm_set1_epi16(dest_alpha * 255 / 256); \ - m256 = _mm_set1_epi16(256); \ - m255 = _mm_set1_epi16(255); \ - m128 = _mm_set1_epi16(128); - -// Calculates the final alpha values to be used when combined with the source texture alpha channel -#define VEC_CALC_BLEND_ALPHA(fg) \ - __m128i fg_alpha_hi, fg_alpha_lo, bg_alpha_hi, bg_alpha_lo; { \ - __m128i alpha_hi = _mm_shufflehi_epi16(_mm_shufflelo_epi16(_mm_unpackhi_epi8(fg, _mm_setzero_si128()), _MM_SHUFFLE(3, 3, 3, 3)), _MM_SHUFFLE(3, 3, 3, 3)); \ - __m128i alpha_lo = _mm_shufflehi_epi16(_mm_shufflelo_epi16(_mm_unpacklo_epi8(fg, _mm_setzero_si128()), _MM_SHUFFLE(3, 3, 3, 3)), _MM_SHUFFLE(3, 3, 3, 3)); \ - alpha_hi = _mm_add_epi16(alpha_hi, _mm_srli_epi16(alpha_hi, 7)); \ - alpha_lo = _mm_add_epi16(alpha_lo, _mm_srli_epi16(alpha_lo, 7)); \ - bg_alpha_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_mullo_epi16(mdest_alpha, alpha_hi), _mm_mullo_epi16(m255, _mm_sub_epi16(m256, alpha_hi))), m128), 8); \ - bg_alpha_hi = _mm_add_epi16(bg_alpha_hi, _mm_srli_epi16(bg_alpha_hi, 7)); \ - bg_alpha_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_adds_epu16(_mm_mullo_epi16(mdest_alpha, alpha_lo), _mm_mullo_epi16(m255, _mm_sub_epi16(m256, alpha_lo))), m128), 8); \ - bg_alpha_lo = _mm_add_epi16(bg_alpha_lo, _mm_srli_epi16(bg_alpha_lo, 7)); \ - fg_alpha_hi = msrc_alpha; \ - fg_alpha_lo = msrc_alpha; \ - } - -#define SSE_SHADE_VARS() __m128i mlight_hi, mlight_lo, color, fade, fade_amount_hi, fade_amount_lo, inv_desaturate; - -// Calculate constants for a simple shade -#define SSE_SHADE_SIMPLE_INIT(light) \ - mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ - mlight_lo = mlight_hi; - -// Calculate constants for a simple shade with different light levels for each pixel -#define SSE_SHADE_SIMPLE_INIT4(light3, light2, light1, light0) \ - mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); \ - mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); - -// Simple shade 4 pixels -#define SSE_SHADE_SIMPLE(fg) { \ - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); \ - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); \ - fg_hi = _mm_mullo_epi16(fg_hi, mlight_hi); \ - fg_hi = _mm_srli_epi16(fg_hi, 8); \ - fg_lo = _mm_mullo_epi16(fg_lo, mlight_lo); \ - fg_lo = _mm_srli_epi16(fg_lo, 8); \ - fg = _mm_packus_epi16(fg_lo, fg_hi); \ -} - -// Calculate constants for a complex shade -#define SSE_SHADE_INIT(light, shade_constants) \ - mlight_hi = _mm_set_epi16(256, light, light, light, 256, light, light, light); \ - mlight_lo = mlight_hi; \ - color = _mm_set_epi16( \ - 256, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ - 256, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ - fade = _mm_set_epi16( \ - 0, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ - 0, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ - fade_amount_hi = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_hi)); \ - fade_amount_lo = fade_amount_hi; \ - inv_desaturate = _mm_set1_epi16(256 - shade_constants.desaturate); \ - -// Calculate constants for a complex shade with different light levels for each pixel -#define SSE_SHADE_INIT4(light3, light2, light1, light0, shade_constants) \ - mlight_hi = _mm_set_epi16(256, light1, light1, light1, 256, light0, light0, light0); \ - mlight_lo = _mm_set_epi16(256, light3, light3, light3, 256, light2, light2, light2); \ - color = _mm_set_epi16( \ - 256, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, \ - 256, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue); \ - fade = _mm_set_epi16( \ - 0, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, \ - 0, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue); \ - fade_amount_hi = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_hi)); \ - fade_amount_lo = _mm_mullo_epi16(fade, _mm_subs_epu16(_mm_set1_epi16(256), mlight_lo)); \ - inv_desaturate = _mm_set1_epi16(256 - shade_constants.desaturate); \ - -// Complex shade 4 pixels -#define SSE_SHADE(fg, shade_constants) { \ - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); \ - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); \ - \ - __m128i intensity_hi = _mm_mullo_epi16(fg_hi, _mm_set_epi16(0, 77, 143, 37, 0, 77, 143, 37)); \ - uint16_t intensity_hi0 = ((_mm_extract_epi16(intensity_hi, 2) + _mm_extract_epi16(intensity_hi, 1) + _mm_extract_epi16(intensity_hi, 0)) >> 8) * shade_constants.desaturate; \ - uint16_t intensity_hi1 = ((_mm_extract_epi16(intensity_hi, 6) + _mm_extract_epi16(intensity_hi, 5) + _mm_extract_epi16(intensity_hi, 4)) >> 8) * shade_constants.desaturate; \ - intensity_hi = _mm_set_epi16(intensity_hi1, intensity_hi1, intensity_hi1, intensity_hi1, intensity_hi0, intensity_hi0, intensity_hi0, intensity_hi0); \ - \ - fg_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, inv_desaturate), intensity_hi), 8); \ - fg_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mlight_hi), fade_amount_hi), 8); \ - fg_hi = _mm_srli_epi16(_mm_mullo_epi16(fg_hi, color), 8); \ - \ - __m128i intensity_lo = _mm_mullo_epi16(fg_lo, _mm_set_epi16(0, 77, 143, 37, 0, 77, 143, 37)); \ - uint16_t intensity_lo0 = ((_mm_extract_epi16(intensity_lo, 2) + _mm_extract_epi16(intensity_lo, 1) + _mm_extract_epi16(intensity_lo, 0)) >> 8) * shade_constants.desaturate; \ - uint16_t intensity_lo1 = ((_mm_extract_epi16(intensity_lo, 6) + _mm_extract_epi16(intensity_lo, 5) + _mm_extract_epi16(intensity_lo, 4)) >> 8) * shade_constants.desaturate; \ - intensity_lo = _mm_set_epi16(intensity_lo1, intensity_lo1, intensity_lo1, intensity_lo1, intensity_lo0, intensity_lo0, intensity_lo0, intensity_lo0); \ - \ - fg_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, inv_desaturate), intensity_lo), 8); \ - fg_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mlight_lo), fade_amount_lo), 8); \ - fg_lo = _mm_srli_epi16(_mm_mullo_epi16(fg_lo, color), 8); \ - \ - fg = _mm_packus_epi16(fg_lo, fg_hi); \ -} - #endif diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index a73ba643c..98d8c2242 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -44,50 +44,11 @@ #include "v_video.h" #include "r_draw_rgba.h" #include "r_compiler/llvmdrawers.h" -#ifndef NO_SSE -#include -#endif extern unsigned int dc_tspans[4][MAXHEIGHT]; extern unsigned int *dc_ctspan[4]; extern unsigned int *horizspan[4]; -#ifndef NO_SSE - -#ifdef _MSC_VER -#pragma warning(disable: 4101) // warning C4101: unreferenced local variable -#endif - -// Generate SSE drawers: -#define VecCommand(name) name##_SSE_Command -#define VEC_SHADE_VARS SSE_SHADE_VARS -#define VEC_SHADE_SIMPLE_INIT SSE_SHADE_SIMPLE_INIT -#define VEC_SHADE_SIMPLE_INIT4 SSE_SHADE_SIMPLE_INIT4 -#define VEC_SHADE_SIMPLE SSE_SHADE_SIMPLE -#define VEC_SHADE_INIT SSE_SHADE_INIT -#define VEC_SHADE_INIT4 SSE_SHADE_INIT4 -#define VEC_SHADE SSE_SHADE -#include "r_drawt_rgba_sse.h" -/* -// Generate AVX drawers: -#undef VecCommand -#undef VEC_SHADE_SIMPLE_INIT -#undef VEC_SHADE_SIMPLE_INIT4 -#undef VEC_SHADE_SIMPLE -#undef VEC_SHADE_INIT -#undef VEC_SHADE_INIT4 -#undef VEC_SHADE -#define VecCommand(name) name##_AVX_Command -#define VEC_SHADE_SIMPLE_INIT AVX_LINEAR_SHADE_SIMPLE_INIT -#define VEC_SHADE_SIMPLE_INIT4 AVX_LINEAR_SHADE_SIMPLE_INIT4 -#define VEC_SHADE_SIMPLE AVX_LINEAR_SHADE_SIMPLE -#define VEC_SHADE_INIT AVX_LINEAR_SHADE_INIT -#define VEC_SHADE_INIT4 AVX_LINEAR_SHADE_INIT4 -#define VEC_SHADE AVX_LINEAR_SHADE -#include "r_drawt_rgba_sse.h" -*/ -#endif - ///////////////////////////////////////////////////////////////////////////// class DrawColumnRt1LLVMCommand : public DrawerCommand @@ -173,413 +134,6 @@ DECLARE_DRAW_COMMAND(DrawColumnRt4RevSubClamp, DrawColumnRt4RevSubClamp, DrawCol ///////////////////////////////////////////////////////////////////////////// -class DrawerRt1colCommand : public DrawerCommand -{ -public: - int hx; - int sx; - int yl; - int yh; - BYTE * RESTRICT _destorg; - int _pitch; - - uint32_t _light; - ShadeConstants _shade_constants; - BYTE * RESTRICT _colormap; - - uint32_t _srcalpha; - uint32_t _destalpha; - - DrawerRt1colCommand(int hx, int sx, int yl, int yh) - { - this->hx = hx; - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _destorg = dc_destorg; - _pitch = dc_pitch; - - _light = LightBgra::calc_light_multiplier(dc_light); - _shade_constants = dc_shade_constants; - _colormap = dc_colormap; - - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - } - - class LoopIterator - { - public: - uint32_t *source; - uint32_t *dest; - int count; - int pitch, sincr; - - LoopIterator(DrawerRt1colCommand *command, DrawerThread *thread) - { - count = thread->count_for_thread(command->yl, (command->yh - command->yl + 1)); - if (count <= 0) - return; - - dest = thread->dest_for_thread(command->yl, command->_pitch, ylookup[command->yl] + command->sx + (uint32_t*)command->_destorg); - source = &thread->dc_temp_rgba[command->yl * 4 + command->hx] + thread->skipped_by_thread(command->yl) * 4; - pitch = command->_pitch * thread->num_cores; - sincr = thread->num_cores * 4; - } - - explicit operator bool() - { - return count > 0; - } - - bool next() - { - dest += pitch; - source += sincr; - return (--count) != 0; - } - }; -}; - -class DrawerRt4colsCommand : public DrawerCommand -{ -public: - int sx; - int yl; - int yh; - uint32_t _light; - ShadeConstants _shade_constants; - BYTE * RESTRICT _destorg; - int _pitch; - BYTE * RESTRICT _colormap; - uint32_t _srcalpha; - uint32_t _destalpha; - - DrawerRt4colsCommand(int sx, int yl, int yh) - { - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _light = LightBgra::calc_light_multiplier(dc_light); - _shade_constants = dc_shade_constants; - _destorg = dc_destorg; - _pitch = dc_pitch; - _colormap = dc_colormap; - - _srcalpha = dc_srcalpha >> (FRACBITS - 8); - _destalpha = dc_destalpha >> (FRACBITS - 8); - } - - class LoopIterator - { - public: - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - LoopIterator(DrawerRt4colsCommand *command, DrawerThread *thread) - { - count = thread->count_for_thread(command->yl, command->yh - command->yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(command->yl, command->_pitch, ylookup[command->yl] + command->sx + (uint32_t*)command->_destorg); - source = &thread->dc_temp_rgba[command->yl * 4] + thread->skipped_by_thread(command->yl) * 4; - pitch = command->_pitch * thread->num_cores; - sincr = thread->num_cores * 4; - } - - explicit operator bool() - { - return count > 0; - } - - bool next() - { - dest += pitch; - source += sincr; - return (--count) != 0; - } - }; -}; - -class RtCopy1colRGBACommand : public DrawerRt1colCommand -{ -public: - RtCopy1colRGBACommand(int hx, int sx, int yl, int yh) : DrawerRt1colCommand(hx, sx, yl, yh) - { - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = GPalette.BaseColors[*loop.source]; - *loop.dest = BlendBgra::copy(fg); - } while (loop.next()); - } -}; - -class RtMap1colRGBACommand : public DrawerRt1colCommand -{ -public: - RtMap1colRGBACommand(int hx, int sx, int yl, int yh) : DrawerRt1colCommand(hx, sx, yl, yh) - { - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(_colormap[*loop.source], _light, _shade_constants); - *loop.dest = BlendBgra::copy(fg); - } while (loop.next()); - } -}; - -class RtMap4colsRGBACommand : public DrawerRt4colsCommand -{ -public: - RtMap4colsRGBACommand(int sx, int yl, int yh) : DrawerRt4colsCommand(sx, yl, yh) - { - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_pal_index(_colormap[loop.source[i]], _light, _shade_constants); - loop.dest[i] = BlendBgra::copy(fg); - } - } while (loop.next()); - } -}; - -class RtAdd1colRGBACommand : public DrawerRt1colCommand -{ -public: - RtAdd1colRGBACommand(int hx, int sx, int yl, int yh) : DrawerRt1colCommand(hx, sx, yl, yh) - { - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(_colormap[*loop.source], _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - -class RtAdd4colsRGBACommand : public DrawerRt4colsCommand -{ -public: - RtAdd4colsRGBACommand(int sx, int yl, int yh) : DrawerRt4colsCommand(sx, yl, yh) - { - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_pal_index(_colormap[loop.source[i]], _light, _shade_constants); - loop.dest[i] = BlendBgra::add(fg, loop.dest[i], _srcalpha, _destalpha); - } - } while (loop.next()); - } -}; - -class RtShaded1colRGBACommand : public DrawerRt1colCommand -{ - uint32_t _color; - -public: - RtShaded1colRGBACommand(int hx, int sx, int yl, int yh) : DrawerRt1colCommand(hx, sx, yl, yh) - { - _color = LightBgra::shade_pal_index(dc_color, _light, _shade_constants); - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t alpha = _colormap[*loop.source] * 4; - uint32_t inv_alpha = 256 - alpha; - *loop.dest = BlendBgra::add(_color, *loop.dest, alpha, inv_alpha); - } while (loop.next()); - } -}; - -class RtShaded4colsRGBACommand : public DrawerRt4colsCommand -{ - uint32_t _color; - -public: - RtShaded4colsRGBACommand(int sx, int yl, int yh) : DrawerRt4colsCommand(sx, yl, yh) - { - _color = LightBgra::shade_pal_index(dc_color, _light, _shade_constants); - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - for (int i = 0; i < 4; i++) - { - uint32_t alpha = _colormap[loop.source[i]] * 4; - uint32_t inv_alpha = 256 - alpha; - loop.dest[i] = BlendBgra::add(_color, loop.dest[i], alpha, inv_alpha); - } - } while (loop.next()); - } -}; - -class RtAddClamp1colRGBACommand : public DrawerRt1colCommand -{ -public: - RtAddClamp1colRGBACommand(int hx, int sx, int yl, int yh) : DrawerRt1colCommand(hx, sx, yl, yh) - { - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(*loop.source, _light, _shade_constants); - *loop.dest = BlendBgra::add(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - -class RtAddClamp4colsRGBACommand : public DrawerRt4colsCommand -{ -public: - RtAddClamp4colsRGBACommand(int sx, int yl, int yh) : DrawerRt4colsCommand(sx, yl, yh) - { - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_pal_index(loop.source[i], _light, _shade_constants); - loop.dest[i] = BlendBgra::add(fg, loop.dest[i], _srcalpha, _destalpha); - } - } while (loop.next()); - } -}; - -class RtSubClamp1colRGBACommand : public DrawerRt1colCommand -{ -public: - RtSubClamp1colRGBACommand(int hx, int sx, int yl, int yh) : DrawerRt1colCommand(hx, sx, yl, yh) - { - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(*loop.source, _light, _shade_constants); - *loop.dest = BlendBgra::sub(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - -class RtSubClamp4colsRGBACommand : public DrawerRt4colsCommand -{ -public: - RtSubClamp4colsRGBACommand(int sx, int yl, int yh) : DrawerRt4colsCommand(sx, yl, yh) - { - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_pal_index(loop.source[i], _light, _shade_constants); - loop.dest[i] = BlendBgra::sub(fg, loop.dest[i], _srcalpha, _destalpha); - } - } while (loop.next()); - } -}; - -class RtRevSubClamp1colRGBACommand : public DrawerRt1colCommand -{ -public: - RtRevSubClamp1colRGBACommand(int hx, int sx, int yl, int yh) : DrawerRt1colCommand(hx, sx, yl, yh) - { - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - uint32_t fg = LightBgra::shade_pal_index(*loop.source, _light, _shade_constants); - *loop.dest = BlendBgra::revsub(fg, *loop.dest, _srcalpha, _destalpha); - } while (loop.next()); - } -}; - -class RtRevSubClamp4colsRGBACommand : public DrawerRt4colsCommand -{ -public: - RtRevSubClamp4colsRGBACommand(int sx, int yl, int yh) : DrawerRt4colsCommand(sx, yl, yh) - { - } - - void Execute(DrawerThread *thread) override - { - LoopIterator loop(this, thread); - if (!loop) return; - do - { - for (int i = 0; i < 4; i++) - { - uint32_t fg = LightBgra::shade_pal_index(loop.source[i], _light, _shade_constants); - loop.dest[i] = BlendBgra::revsub(fg, loop.dest[i], _srcalpha, _destalpha); - } - } while (loop.next()); - } -}; - class RtTranslate1colRGBACommand : public DrawerCommand { const BYTE * RESTRICT translation; diff --git a/src/r_drawt_rgba_sse.h b/src/r_drawt_rgba_sse.h deleted file mode 100644 index 7a02f2282..000000000 --- a/src/r_drawt_rgba_sse.h +++ /dev/null @@ -1,757 +0,0 @@ -// -// SSE/AVX intrinsics based drawers for the r_drawt family of drawers. -// -// Note: This header file is intentionally not guarded by a __R_DRAWT_RGBA_SSE__ define. -// It is because the code is nearly identical for SSE vs AVX. The file is included -// multiple times by r_drawt_rgba.cpp with different defines that changes the class -// names outputted and the type of intrinsics used. - -#ifdef _MSC_VER -#pragma warning(disable: 4752) // warning C4752: found Intel(R) Advanced Vector Extensions; consider using /arch:AVX -#endif - -class VecCommand(RtMap4colsRGBA) : public DrawerCommand -{ - int sx; - int yl; - int yh; - fixed_t _light; - ShadeConstants _shade_constants; - BYTE * RESTRICT _destorg; - int _pitch; - BYTE * RESTRICT _colormap; - -public: - VecCommand(RtMap4colsRGBA)(int sx, int yl, int yh) - { - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _light = dc_light; - _shade_constants = dc_shade_constants; - _destorg = dc_destorg; - _pitch = dc_pitch; - _colormap = dc_colormap; - } - - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - ShadeConstants shade_constants = _shade_constants; - uint32_t light = LightBgra::calc_light_multiplier(_light); - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = thread->num_cores * 4; - - BYTE *colormap = _colormap; - - if (shade_constants.simple_shade) - { - VEC_SHADE_VARS(); - VEC_SHADE_SIMPLE_INIT(light); - - if (count & 1) { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - VEC_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - - source += sincr; - dest += pitch; - } - if (!(count >>= 1)) - return; - - do { - // shade_pal_index 0-3 - { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - VEC_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)dest, fg); - } - - // shade_pal_index 4-7 (pitch) - { - uint32_t p0 = colormap[source[sincr]]; - uint32_t p1 = colormap[source[sincr + 1]]; - uint32_t p2 = colormap[source[sincr + 2]]; - uint32_t p3 = colormap[source[sincr + 3]]; - - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - VEC_SHADE_SIMPLE(fg); - _mm_storeu_si128((__m128i*)(dest + pitch), fg); - } - - source += sincr * 2; - dest += pitch * 2; - } while (--count); - } - else - { - VEC_SHADE_VARS(); - VEC_SHADE_INIT(light, shade_constants); - - if (count & 1) { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - VEC_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - - source += sincr; - dest += pitch; - } - if (!(count >>= 1)) - return; - - do { - // shade_pal_index 0-3 - { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - VEC_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)dest, fg); - } - - // shade_pal_index 4-7 (pitch) - { - uint32_t p0 = colormap[source[sincr]]; - uint32_t p1 = colormap[source[sincr + 1]]; - uint32_t p2 = colormap[source[sincr + 2]]; - uint32_t p3 = colormap[source[sincr + 3]]; - - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - VEC_SHADE(fg, shade_constants); - _mm_storeu_si128((__m128i*)(dest + pitch), fg); - } - - source += sincr * 2; - dest += pitch * 2; - } while (--count); - } - } -}; - -class VecCommand(RtAdd4colsRGBA) : public DrawerCommand -{ - int sx; - int yl; - int yh; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; - ShadeConstants _shade_constants; - BYTE * RESTRICT _colormap; - fixed_t _srcalpha; - fixed_t _destalpha; - -public: - VecCommand(RtAdd4colsRGBA)(int sx, int yl, int yh) - { - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _destorg = dc_destorg; - _pitch = dc_pitch; - _light = dc_light; - _shade_constants = dc_shade_constants; - _colormap = dc_colormap; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - } - - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t light = LightBgra::calc_light_multiplier(_light); - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - BYTE *colormap = _colormap; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - ShadeConstants shade_constants = _shade_constants; - - if (shade_constants.simple_shade) - { - VEC_SHADE_VARS(); - VEC_SHADE_SIMPLE_INIT(light); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - VEC_SHADE_SIMPLE(fg); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += sincr; - dest += pitch; - } while (--count); - } - else - { - VEC_SHADE_VARS(); - VEC_SHADE_INIT(light, shade_constants); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - VEC_SHADE(fg, shade_constants); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += sincr; - dest += pitch; - } while (--count); - } - } -}; - -class VecCommand(RtShaded4colsRGBA) : public DrawerCommand -{ - int sx; - int yl; - int yh; - lighttable_t * RESTRICT _colormap; - int _color; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; - -public: - VecCommand(RtShaded4colsRGBA)(int sx, int yl, int yh) - { - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _colormap = dc_colormap; - _color = dc_color; - _destorg = dc_destorg; - _pitch = dc_pitch; - _light = dc_light; - } - - void Execute(DrawerThread *thread) override - { - BYTE *colormap; - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - colormap = _colormap; - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - __m128i fg = _mm_unpackhi_epi8(_mm_set1_epi32(LightBgra::shade_pal_index_simple(_color, LightBgra::calc_light_multiplier(_light))), _mm_setzero_si128()); - __m128i alpha_one = _mm_set1_epi16(64); - - do { - uint32_t p0 = colormap[source[0]]; - uint32_t p1 = colormap[source[1]]; - uint32_t p2 = colormap[source[2]]; - uint32_t p3 = colormap[source[3]]; - - __m128i alpha_hi = _mm_set_epi16(64, p3, p3, p3, 64, p2, p2, p2); - __m128i alpha_lo = _mm_set_epi16(64, p1, p1, p1, 64, p0, p0, p0); - __m128i inv_alpha_hi = _mm_subs_epu16(alpha_one, alpha_hi); - __m128i inv_alpha_lo = _mm_subs_epu16(alpha_one, alpha_lo); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * alpha + bg_red * inv_alpha) / 64: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg, alpha_hi), _mm_mullo_epi16(bg_hi, inv_alpha_hi)), 6); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg, alpha_lo), _mm_mullo_epi16(bg_lo, inv_alpha_lo)), 6); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += sincr; - dest += pitch; - } while (--count); - } -}; - -class VecCommand(RtAddClamp4colsRGBA) : public DrawerCommand -{ - int sx; - int yl; - int yh; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; - fixed_t _srcalpha; - fixed_t _destalpha; - ShadeConstants _shade_constants; - -public: - VecCommand(RtAddClamp4colsRGBA)(int sx, int yl, int yh) - { - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _destorg = dc_destorg; - _pitch = dc_pitch; - _light = dc_light; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - _shade_constants = dc_shade_constants; - } - - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t light = LightBgra::calc_light_multiplier(_light); - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - ShadeConstants shade_constants = _shade_constants; - - if (shade_constants.simple_shade) - { - VEC_SHADE_VARS(); - VEC_SHADE_SIMPLE_INIT(light); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - VEC_SHADE_SIMPLE(fg); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += sincr; - dest += pitch; - } while (--count); - } - else - { - VEC_SHADE_VARS(); - VEC_SHADE_INIT(light, shade_constants); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - VEC_SHADE(fg, shade_constants); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * fg_alpha + bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_adds_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += sincr; - dest += pitch; - } while (--count); - } - } -}; - -class VecCommand(RtSubClamp4colsRGBA) : public DrawerCommand -{ - int sx; - int yl; - int yh; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; - fixed_t _srcalpha; - fixed_t _destalpha; - ShadeConstants _shade_constants; - -public: - VecCommand(RtSubClamp4colsRGBA)(int sx, int yl, int yh) - { - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _destorg = dc_destorg; - _pitch = dc_pitch; - _light = dc_light; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - _shade_constants = dc_shade_constants; - } - - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t light = LightBgra::calc_light_multiplier(_light); - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - if (shade_constants.simple_shade) - { - VEC_SHADE_VARS(); - VEC_SHADE_SIMPLE_INIT(light); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - VEC_SHADE_SIMPLE(fg); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (bg_red * bg_alpha - fg_red * fg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_hi, mbg_alpha), _mm_mullo_epi16(fg_hi, mfg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_lo, mbg_alpha), _mm_mullo_epi16(fg_lo, mfg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += sincr; - dest += pitch; - } while (--count); - } - else - { - VEC_SHADE_VARS(); - VEC_SHADE_INIT(light, shade_constants); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - VEC_SHADE(fg, shade_constants); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (bg_red * bg_alpha - fg_red * fg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_hi, mbg_alpha), _mm_mullo_epi16(fg_hi, mfg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(bg_lo, mbg_alpha), _mm_mullo_epi16(fg_lo, mfg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += sincr; - dest += pitch; - } while (--count); - } - } -}; - -class VecCommand(RtRevSubClamp4colsRGBA) : public DrawerCommand -{ - int sx; - int yl; - int yh; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; - fixed_t _srcalpha; - fixed_t _destalpha; - ShadeConstants _shade_constants; - -public: - VecCommand(RtRevSubClamp4colsRGBA)(int sx, int yl, int yh) - { - this->sx = sx; - this->yl = yl; - this->yh = yh; - - _destorg = dc_destorg; - _pitch = dc_pitch; - _light = dc_light; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - _shade_constants = dc_shade_constants; - } - - void Execute(DrawerThread *thread) override - { - uint32_t *source; - uint32_t *dest; - int count; - int pitch; - int sincr; - - count = thread->count_for_thread(yl, yh - yl + 1); - if (count <= 0) - return; - - dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + sx + (uint32_t*)_destorg); - source = &thread->dc_temp_rgba[yl * 4] + thread->skipped_by_thread(yl) * 4; - pitch = _pitch * thread->num_cores; - sincr = 4 * thread->num_cores; - - uint32_t light = LightBgra::calc_light_multiplier(_light); - uint32_t *palette = (uint32_t*)GPalette.BaseColors; - ShadeConstants shade_constants = _shade_constants; - - uint32_t fg_alpha = _srcalpha >> (FRACBITS - 8); - uint32_t bg_alpha = _destalpha >> (FRACBITS - 8); - - if (shade_constants.simple_shade) - { - VEC_SHADE_VARS(); - VEC_SHADE_SIMPLE_INIT(light); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - VEC_SHADE_SIMPLE(fg); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * fg_alpha - bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += sincr; - dest += pitch; - } while (--count); - } - else - { - VEC_SHADE_VARS(); - VEC_SHADE_INIT(light, shade_constants); - - __m128i mfg_alpha = _mm_set_epi16(256, fg_alpha, fg_alpha, fg_alpha, 256, fg_alpha, fg_alpha, fg_alpha); - __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); - - do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; - - // shade_pal_index: - __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); - VEC_SHADE(fg, shade_constants); - - __m128i fg_hi = _mm_unpackhi_epi8(fg, _mm_setzero_si128()); - __m128i fg_lo = _mm_unpacklo_epi8(fg, _mm_setzero_si128()); - - // unpack bg: - __m128i bg = _mm_loadu_si128((const __m128i*)dest); - __m128i bg_hi = _mm_unpackhi_epi8(bg, _mm_setzero_si128()); - __m128i bg_lo = _mm_unpacklo_epi8(bg, _mm_setzero_si128()); - - // (fg_red * fg_alpha - bg_red * bg_alpha) / 256: - __m128i color_hi = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_hi, mfg_alpha), _mm_mullo_epi16(bg_hi, mbg_alpha)), 8); - __m128i color_lo = _mm_srli_epi16(_mm_subs_epu16(_mm_mullo_epi16(fg_lo, mfg_alpha), _mm_mullo_epi16(bg_lo, mbg_alpha)), 8); - - __m128i color = _mm_packus_epi16(color_lo, color_hi); - _mm_storeu_si128((__m128i*)dest, color); - - source += sincr; - dest += pitch; - } while (--count); - } - } -}; From 6512068005ebbd618a7791fe0500ab5428a7083c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 7 Oct 2016 07:03:13 +0200 Subject: [PATCH 1046/1509] Remove unused queue_wallcommand --- src/r_draw_rgba.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 424d3140b..953a07858 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -1314,19 +1314,6 @@ DWORD vlinec1_rgba() return dc_texturefrac + dc_count * dc_iscale; } -template -void queue_wallcommand() -{ - if (bufplce2[0] == nullptr && dc_shade_constants.simple_shade) - DrawerCommandQueue::QueueCommand(); - else if (bufplce2[0] == nullptr) - DrawerCommandQueue::QueueCommand(); - else if (dc_shade_constants.simple_shade) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); -} - void vlinec4_rgba() { DrawerCommandQueue::QueueCommand(); From a4ccbddfd699104a7fdf32a1860253971f52265b Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Fri, 7 Oct 2016 02:38:08 -0400 Subject: [PATCH 1047/1509] - Menudef: Split Truecolor options into their own menu. --- wadsrc/static/language.enu | 18 ++++++++++++++---- wadsrc/static/menudef.txt | 16 ++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index c76414c8a..b7d887727 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1780,10 +1780,6 @@ DSPLYMNU_BRIGHTNESS = "Brightness"; DSPLYMNU_VSYNC = "Vertical Sync"; DSPLYMNU_CAPFPS = "Rendering Interpolation"; DSPLYMNU_COLUMNMETHOD = "Column render mode"; -DSPLYMNU_TRUECOLOR = "True color output"; -DSPLYMNU_MINFILTER = "Linear filter when downscaling"; -DSPLYMNU_MAGFILTER = "Linear filter when upscaling"; -DSPLYMNU_MIPMAP = "Use mipmapped textures"; DSPLYMNU_WIPETYPE = "Screen wipe style"; DSPLYMNU_SHOWENDOOM = "Show ENDOOM screen"; DSPLYMNU_BLOODFADE = "Blood Flash Intensity"; @@ -2726,3 +2722,17 @@ OPTVAL_LOW = "Low"; OPTVAL_MEDIUM = "Medium"; OPTVAL_HIGH = "High"; OPTVAL_EXTREME = "Extreme"; + +// QZDoom exclusive: + +DSPLYMNU_TCOPT = "TrueColor Options"; + +TCMNU_TITLE = "TRUECOLOR OPTIONS"; + + +TCMNU_MULTITHREADED = "Multithreaded Drawing"; +TCMNU_TRUECOLOR = "True color output"; +TCMNU_MINFILTER = "Linear filter when downscaling"; +TCMNU_MAGFILTER = "Linear filter when upscaling"; +TCMNU_MIPMAP = "Use mipmapped textures"; + diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 715eff63b..ac4e02be9 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -658,11 +658,23 @@ OptionMenu "OpenGLOptions" Submenu "$GLMNU_PREFS", "GLPrefOptions" } +OptionMenu "TrueColorOptions" +{ + Title "$TCMNU_TITLE" + Option "$TCMNU_MULTITHREADED", "r_multithreaded", "OnOff" + StaticText " " + Option "$TCMNU_TRUECOLOR", "swtruecolor", "OnOff" + Option "$TCMNU_MINFILTER", "r_minfilter", "OnOff" + Option "$TCMNU_MAGFILTER", "r_magfilter", "OnOff" + Option "$TCMNU_MIPMAP", "r_mipmap", "OnOff" +} + OptionMenu "VideoOptions" { Title "$DSPLYMNU_TITLE" Submenu "$DSPLYMNU_GLOPT", "OpenGLOptions" + Submenu "$DSPLYMNU_TCOPT", "TrueColorOptions" Submenu "$DSPLYMNU_SCOREBOARD", "ScoreboardOptions" StaticText " " Slider "$DSPLYMNU_SCREENSIZE", "screenblocks", 3.0, 12.0, 1.0, 0 @@ -677,10 +689,6 @@ OptionMenu "VideoOptions" Slider "$DSPLYMNU_BLOODFADE", "blood_fade_scalar", 0.0, 1.0, 0.05, 1 Slider "$DSPLYMNU_PICKUPFADE", "pickup_fade_scalar", 0.0, 1.0, 0.05, 1 Option "$DSPLYMNU_COLUMNMETHOD", "r_columnmethod", "ColumnMethods" - Option "$DSPLYMNU_TRUECOLOR", "swtruecolor", "OnOff" - Option "$DSPLYMNU_MINFILTER", "r_minfilter", "OnOff" - Option "$DSPLYMNU_MAGFILTER", "r_magfilter", "OnOff" - Option "$DSPLYMNU_MIPMAP", "r_mipmap", "OnOff" StaticText " " Option "$DSPLYMNU_WIPETYPE", "wipetype", "Wipes" From aae4571c95c52feab20172ecf5a39b21327cac01 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 7 Oct 2016 12:45:21 +0200 Subject: [PATCH 1048/1509] Changed column drawers to use true color textures --- .../fixedfunction/drawcolumncodegen.cpp | 108 ++++++++++- .../fixedfunction/drawcolumncodegen.h | 6 +- src/r_compiler/llvmdrawers.cpp | 20 ++ src/r_compiler/llvmdrawers.h | 10 + src/r_draw.cpp | 10 + src/r_drawt.cpp | 3 +- src/r_drawt_rgba.cpp | 182 +++--------------- src/r_main.h | 2 +- src/r_segs.cpp | 6 +- src/r_things.cpp | 26 ++- src/v_draw.cpp | 18 +- 11 files changed, 215 insertions(+), 176 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp index 601358274..e920fb73a 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp @@ -89,6 +89,8 @@ void DrawColumnCodegen::Loop(DrawColumnVariant variant, DrawColumnMethod method, { frac = stack_frac.load(); sample_index = frac >> FRACBITS; + if (!IsPaletteInput(variant)) + sample_index = sample_index * 4; } else { @@ -136,6 +138,33 @@ void DrawColumnCodegen::Loop(DrawColumnVariant variant, DrawColumnMethod method, } } +bool DrawColumnCodegen::IsPaletteInput(DrawColumnVariant variant) +{ + switch (variant) + { + default: + case DrawColumnVariant::DrawCopy: + case DrawColumnVariant::Draw: + case DrawColumnVariant::DrawAdd: + case DrawColumnVariant::DrawAddClamp: + case DrawColumnVariant::DrawSubClamp: + case DrawColumnVariant::DrawRevSubClamp: + case DrawColumnVariant::Fill: + case DrawColumnVariant::FillAdd: + case DrawColumnVariant::FillAddClamp: + case DrawColumnVariant::FillSubClamp: + case DrawColumnVariant::FillRevSubClamp: + return false; + case DrawColumnVariant::DrawShaded: + case DrawColumnVariant::DrawTranslated: + case DrawColumnVariant::DrawTlatedAdd: + case DrawColumnVariant::DrawAddClampTranslated: + case DrawColumnVariant::DrawSubClampTranslated: + case DrawColumnVariant::DrawRevSubClampTranslated: + return true; + } +} + SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade) { SSAInt alpha, inv_alpha; @@ -143,29 +172,29 @@ SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, { default: case DrawColumnVariant::DrawCopy: - return blend_copy(basecolors[ColormapSample(sample_index) * 4].load_vec4ub()); + return blend_copy(Sample(sample_index)); case DrawColumnVariant::Draw: - return blend_copy(Shade(ColormapSample(sample_index), isSimpleShade)); + return blend_copy(Shade(Sample(sample_index), isSimpleShade)); case DrawColumnVariant::DrawAdd: case DrawColumnVariant::DrawAddClamp: - return blend_add(Shade(ColormapSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_add(Shade(Sample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawShaded: alpha = SSAInt::MAX(SSAInt::MIN(ColormapSample(sample_index), SSAInt(64)), SSAInt(0)) * 4; inv_alpha = 256 - alpha; return blend_add(color, bgcolor, alpha, inv_alpha); case DrawColumnVariant::DrawSubClamp: - return blend_sub(Shade(ColormapSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_sub(Shade(Sample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawRevSubClamp: - return blend_revsub(Shade(ColormapSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_revsub(Shade(Sample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawTranslated: - return blend_copy(Shade(TranslateSample(sample_index), isSimpleShade)); + return blend_copy(ShadePal(TranslateSample(sample_index), isSimpleShade)); case DrawColumnVariant::DrawTlatedAdd: case DrawColumnVariant::DrawAddClampTranslated: - return blend_add(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_add(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawSubClampTranslated: - return blend_sub(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_sub(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawRevSubClampTranslated: - return blend_revsub(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_revsub(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::Fill: return blend_copy(color); case DrawColumnVariant::FillAdd: @@ -182,6 +211,57 @@ SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, } } +SSAVec4i DrawColumnCodegen::ProcessPixelPal(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade) +{ + SSAInt alpha, inv_alpha; + switch (variant) + { + default: + case DrawColumnVariant::DrawCopy: + return blend_copy(basecolors[ColormapSample(sample_index) * 4].load_vec4ub()); + case DrawColumnVariant::Draw: + return blend_copy(ShadePal(ColormapSample(sample_index), isSimpleShade)); + case DrawColumnVariant::DrawAdd: + case DrawColumnVariant::DrawAddClamp: + return blend_add(ShadePal(ColormapSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + case DrawColumnVariant::DrawShaded: + alpha = SSAInt::MAX(SSAInt::MIN(ColormapSample(sample_index), SSAInt(64)), SSAInt(0)) * 4; + inv_alpha = 256 - alpha; + return blend_add(color, bgcolor, alpha, inv_alpha); + case DrawColumnVariant::DrawSubClamp: + return blend_sub(ShadePal(ColormapSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + case DrawColumnVariant::DrawRevSubClamp: + return blend_revsub(ShadePal(ColormapSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + case DrawColumnVariant::DrawTranslated: + return blend_copy(ShadePal(TranslateSample(sample_index), isSimpleShade)); + case DrawColumnVariant::DrawTlatedAdd: + case DrawColumnVariant::DrawAddClampTranslated: + return blend_add(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + case DrawColumnVariant::DrawSubClampTranslated: + return blend_sub(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + case DrawColumnVariant::DrawRevSubClampTranslated: + return blend_revsub(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + case DrawColumnVariant::Fill: + return blend_copy(color); + case DrawColumnVariant::FillAdd: + alpha = srccolor[3]; + alpha = alpha + (alpha >> 7); + inv_alpha = 256 - alpha; + return blend_add(srccolor, bgcolor, alpha, inv_alpha); + case DrawColumnVariant::FillAddClamp: + return blend_add(srccolor, bgcolor, srcalpha, destalpha); + case DrawColumnVariant::FillSubClamp: + return blend_sub(srccolor, bgcolor, srcalpha, destalpha); + case DrawColumnVariant::FillRevSubClamp: + return blend_revsub(srccolor, bgcolor, srcalpha, destalpha); + } +} + +SSAVec4i DrawColumnCodegen::Sample(SSAInt sample_index) +{ + return source[sample_index].load_vec4ub(); +} + SSAInt DrawColumnCodegen::ColormapSample(SSAInt sample_index) { return colormap[source[sample_index].load().zext_int()].load().zext_int(); @@ -192,7 +272,15 @@ SSAInt DrawColumnCodegen::TranslateSample(SSAInt sample_index) return translation[source[sample_index].load().zext_int()].load().zext_int(); } -SSAVec4i DrawColumnCodegen::Shade(SSAInt palIndex, bool isSimpleShade) +SSAVec4i DrawColumnCodegen::Shade(SSAVec4i fg, bool isSimpleShade) +{ + if (isSimpleShade) + return shade_bgra_simple(fg, light); + else + return shade_bgra_advanced(fg, light, shade_constants); +} + +SSAVec4i DrawColumnCodegen::ShadePal(SSAInt palIndex, bool isSimpleShade) { if (isSimpleShade) return shade_pal_index_simple(palIndex, light, basecolors); diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.h b/src/r_compiler/fixedfunction/drawcolumncodegen.h index 675a5ea67..ffba50a15 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.h +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.h @@ -39,9 +39,13 @@ public: private: void Loop(DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade); SSAVec4i ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade); + SSAVec4i ProcessPixelPal(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade); + SSAVec4i Sample(SSAInt frac); SSAInt ColormapSample(SSAInt frac); SSAInt TranslateSample(SSAInt frac); - SSAVec4i Shade(SSAInt palIndex, bool isSimpleShade); + SSAVec4i Shade(SSAVec4i fgcolor, bool isSimpleShade); + SSAVec4i ShadePal(SSAInt palIndex, bool isSimpleShade); + bool IsPaletteInput(DrawColumnVariant variant); SSAStack stack_index, stack_frac; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 3108b8c6a..ac0633058 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -107,6 +107,11 @@ LLVMDrawersImpl::LLVMDrawersImpl() CodegenDrawColumn("DrawColumnRt1AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt1); CodegenDrawColumn("DrawColumnRt1SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt1); CodegenDrawColumn("DrawColumnRt1RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt1); CodegenDrawColumn("DrawColumnRt4", DrawColumnVariant::Draw, DrawColumnMethod::Rt4); CodegenDrawColumn("DrawColumnRt4Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt4); CodegenDrawColumn("DrawColumnRt4Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt4); @@ -114,6 +119,11 @@ LLVMDrawersImpl::LLVMDrawersImpl() CodegenDrawColumn("DrawColumnRt4AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt4); CodegenDrawColumn("DrawColumnRt4SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt4); CodegenDrawColumn("DrawColumnRt4RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt4); CodegenDrawSpan("DrawSpan", DrawSpanVariant::Opaque); CodegenDrawSpan("DrawSpanMasked", DrawSpanVariant::Masked); CodegenDrawSpan("DrawSpanTranslucent", DrawSpanVariant::Translucent); @@ -159,6 +169,11 @@ LLVMDrawersImpl::LLVMDrawersImpl() DrawColumnRt1AddClamp = mProgram.GetProcAddress("DrawColumnRt1AddClamp"); DrawColumnRt1SubClamp = mProgram.GetProcAddress("DrawColumnRt1SubClamp"); DrawColumnRt1RevSubClamp = mProgram.GetProcAddress("DrawColumnRt1RevSubClamp"); + DrawColumnRt1Translated = mProgram.GetProcAddress("DrawColumnRt1Translated"); + DrawColumnRt1TlatedAdd = mProgram.GetProcAddress("DrawColumnRt1TlatedAdd"); + DrawColumnRt1AddClampTranslated = mProgram.GetProcAddress("DrawColumnRt1AddClampTranslated"); + DrawColumnRt1SubClampTranslated = mProgram.GetProcAddress("DrawColumnRt1SubClampTranslated"); + DrawColumnRt1RevSubClampTranslated = mProgram.GetProcAddress("DrawColumnRt1RevSubClampTranslated"); DrawColumnRt4 = mProgram.GetProcAddress("DrawColumnRt4"); DrawColumnRt4Copy = mProgram.GetProcAddress("DrawColumnRt4Copy"); DrawColumnRt4Add = mProgram.GetProcAddress("DrawColumnRt4Add"); @@ -166,6 +181,11 @@ LLVMDrawersImpl::LLVMDrawersImpl() DrawColumnRt4AddClamp = mProgram.GetProcAddress("DrawColumnRt4AddClamp"); DrawColumnRt4SubClamp = mProgram.GetProcAddress("DrawColumnRt4SubClamp"); DrawColumnRt4RevSubClamp = mProgram.GetProcAddress("DrawColumnRt4RevSubClamp"); + DrawColumnRt4Translated = mProgram.GetProcAddress("DrawColumnRt4Translated"); + DrawColumnRt4TlatedAdd = mProgram.GetProcAddress("DrawColumnRt4TlatedAdd"); + DrawColumnRt4AddClampTranslated = mProgram.GetProcAddress("DrawColumnRt4AddClampTranslated"); + DrawColumnRt4SubClampTranslated = mProgram.GetProcAddress("DrawColumnRt4SubClampTranslated"); + DrawColumnRt4RevSubClampTranslated = mProgram.GetProcAddress("DrawColumnRt4RevSubClampTranslated"); DrawSpan = mProgram.GetProcAddress("DrawSpan"); DrawSpanMasked = mProgram.GetProcAddress("DrawSpanMasked"); DrawSpanTranslucent = mProgram.GetProcAddress("DrawSpanTranslucent"); diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 549825e4f..60a6c799a 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -144,6 +144,11 @@ public: void(*DrawColumnRt1AddClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawColumnRt1SubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawColumnRt1RevSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt1Translated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt1TlatedAdd)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt1AddClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt1SubClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt1RevSubClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawColumnRt4)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawColumnRt4Copy)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawColumnRt4Add)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; @@ -151,6 +156,11 @@ public: void(*DrawColumnRt4AddClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawColumnRt4SubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawColumnRt4RevSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt4Translated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt4TlatedAdd)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt4AddClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt4SubClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; + void(*DrawColumnRt4RevSubClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawSpan)(const DrawSpanArgs *) = nullptr; void(*DrawSpanMasked)(const DrawSpanArgs *) = nullptr; diff --git a/src/r_draw.cpp b/src/r_draw.cpp index f255352f5..11c7020b4 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -191,6 +191,8 @@ FDynamicColormap ShadeFakeColormap[16]; BYTE identitymap[256]; FDynamicColormap identitycolormap; +bool drawer_needs_pal_input; + EXTERN_CVAR (Int, r_columnmethod) void R_InitShadeMaps() @@ -2516,6 +2518,7 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) colfunc = transcolfunc; hcolfunc_post1 = rt_tlate1col; hcolfunc_post4 = rt_tlate4cols; + drawer_needs_pal_input = true; } return true; } @@ -2566,6 +2569,7 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) colfunc = R_DrawTlatedAddColumn; hcolfunc_post1 = rt_tlateadd1col; hcolfunc_post4 = rt_tlateadd4cols; + drawer_needs_pal_input = true; } } else @@ -2587,6 +2591,7 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) colfunc = R_DrawAddClampTranslatedColumn; hcolfunc_post1 = rt_tlateaddclamp1col; hcolfunc_post4 = rt_tlateaddclamp4cols; + drawer_needs_pal_input = true; } } return true; @@ -2609,6 +2614,7 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) colfunc = R_DrawSubClampTranslatedColumn; hcolfunc_post1 = rt_tlatesubclamp1col; hcolfunc_post4 = rt_tlatesubclamp4cols; + drawer_needs_pal_input = true; } return true; @@ -2634,6 +2640,7 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) colfunc = R_DrawRevSubClampTranslatedColumn; hcolfunc_post1 = rt_tlaterevsubclamp1col; hcolfunc_post4 = rt_tlaterevsubclamp4cols; + drawer_needs_pal_input = true; } return true; @@ -2658,6 +2665,8 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, { fixed_t fglevel, bglevel; + drawer_needs_pal_input = false; + style.CheckFuzz(); if (style.BlendOp == STYLEOP_Shadow) @@ -2706,6 +2715,7 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, colfunc = R_DrawShadedColumn; hcolfunc_post1 = rt_shaded1col; hcolfunc_post4 = rt_shaded4cols; + drawer_needs_pal_input = true; dc_color = fixedcolormap ? fixedcolormap->Maps[APART(color)] : basecolormap->Maps[APART(color)]; basecolormap = &ShadeFakeColormap[16-alpha]; if (fixedlightlev >= 0 && fixedcolormap == NULL) diff --git a/src/r_drawt.cpp b/src/r_drawt.cpp index 837093044..43354bfd5 100644 --- a/src/r_drawt.cpp +++ b/src/r_drawt.cpp @@ -1121,6 +1121,7 @@ void R_FillColumnHorizP_C (void) void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span) { int pixelsize = r_swtruecolor ? 4 : 1; + int inputpixelsize = (r_swtruecolor && !drawer_needs_pal_input) ? 4 : 1; const fixed_t texturemid = FLOAT2FIXED(dc_texturemid); while (span->Length != 0) { @@ -1189,7 +1190,7 @@ void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span) endfrac -= dc_iscale; } } - dc_source = column + top; + dc_source = column + top * inputpixelsize; dc_dest = (ylookup[dc_yl] + dc_x) * pixelsize + dc_destorg; dc_count = dc_yh - dc_yl + 1; hcolfunc_pre (); diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 98d8c2242..18ae228e4 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -124,6 +124,11 @@ DECLARE_DRAW_COMMAND(DrawColumnRt1Shaded, DrawColumnRt1Shaded, DrawColumnRt1LLVM DECLARE_DRAW_COMMAND(DrawColumnRt1AddClamp, DrawColumnRt1AddClamp, DrawColumnRt1LLVMCommand); DECLARE_DRAW_COMMAND(DrawColumnRt1SubClamp, DrawColumnRt1SubClamp, DrawColumnRt1LLVMCommand); DECLARE_DRAW_COMMAND(DrawColumnRt1RevSubClamp, DrawColumnRt1RevSubClamp, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt1Translated, DrawColumnRt1Translated, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt1TlatedAdd, DrawColumnRt1TlatedAdd, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt1AddClampTranslated, DrawColumnRt1AddClampTranslated, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt1SubClampTranslated, DrawColumnRt1SubClampTranslated, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt1RevSubClampTranslated, DrawColumnRt1RevSubClampTranslated, DrawColumnRt1LLVMCommand); DECLARE_DRAW_COMMAND(DrawColumnRt4, DrawColumnRt4, DrawColumnRt1LLVMCommand); DECLARE_DRAW_COMMAND(DrawColumnRt4Copy, DrawColumnRt4Copy, DrawColumnRt1LLVMCommand); DECLARE_DRAW_COMMAND(DrawColumnRt4Add, DrawColumnRt4Add, DrawColumnRt1LLVMCommand); @@ -131,129 +136,14 @@ DECLARE_DRAW_COMMAND(DrawColumnRt4Shaded, DrawColumnRt4Shaded, DrawColumnRt1LLVM DECLARE_DRAW_COMMAND(DrawColumnRt4AddClamp, DrawColumnRt4AddClamp, DrawColumnRt1LLVMCommand); DECLARE_DRAW_COMMAND(DrawColumnRt4SubClamp, DrawColumnRt4SubClamp, DrawColumnRt1LLVMCommand); DECLARE_DRAW_COMMAND(DrawColumnRt4RevSubClamp, DrawColumnRt4RevSubClamp, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt4Translated, DrawColumnRt4Translated, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt4TlatedAdd, DrawColumnRt4TlatedAdd, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt4AddClampTranslated, DrawColumnRt4AddClampTranslated, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt4SubClampTranslated, DrawColumnRt4SubClampTranslated, DrawColumnRt1LLVMCommand); +DECLARE_DRAW_COMMAND(DrawColumnRt4RevSubClampTranslated, DrawColumnRt4RevSubClampTranslated, DrawColumnRt1LLVMCommand); ///////////////////////////////////////////////////////////////////////////// -class RtTranslate1colRGBACommand : public DrawerCommand -{ - const BYTE * RESTRICT translation; - int hx; - int yl; - int yh; - -public: - RtTranslate1colRGBACommand(const BYTE *translation, int hx, int yl, int yh) - { - this->translation = translation; - this->hx = hx; - this->yl = yl; - this->yh = yh; - } - - void Execute(DrawerThread *thread) override - { - int count = yh - yl + 1; - uint32_t *source = &thread->dc_temp_rgba[yl*4 + hx]; - - // Things we do to hit the compiler's optimizer with a clue bat: - // 1. Parallelism is explicitly spelled out by using a separate - // C instruction for each assembly instruction. GCC lets me - // have four temporaries, but VC++ spills to the stack with - // more than two. Two is probably optimal, anyway. - // 2. The results of the translation lookups are explicitly - // stored in byte-sized variables. This causes the VC++ code - // to use byte mov instructions in most cases; for apparently - // random reasons, it will use movzx for some places. GCC - // ignores this and uses movzx always. - - // Do 8 rows at a time. - for (int count8 = count >> 3; count8; --count8) - { - int c0, c1; - BYTE b0, b1; - - c0 = source[0]; c1 = source[4]; - b0 = translation[c0]; b1 = translation[c1]; - source[0] = b0; source[4] = b1; - - c0 = source[8]; c1 = source[12]; - b0 = translation[c0]; b1 = translation[c1]; - source[8] = b0; source[12] = b1; - - c0 = source[16]; c1 = source[20]; - b0 = translation[c0]; b1 = translation[c1]; - source[16] = b0; source[20] = b1; - - c0 = source[24]; c1 = source[28]; - b0 = translation[c0]; b1 = translation[c1]; - source[24] = b0; source[28] = b1; - - source += 32; - } - // Finish by doing 1 row at a time. - for (count &= 7; count; --count, source += 4) - { - source[0] = translation[source[0]]; - } - } -}; - -class RtTranslate4colsRGBACommand : public DrawerCommand -{ - const BYTE * RESTRICT translation; - int yl; - int yh; - -public: - RtTranslate4colsRGBACommand(const BYTE *translation, int yl, int yh) - { - this->translation = translation; - this->yl = yl; - this->yh = yh; - } - - void Execute(DrawerThread *thread) override - { - int count = yh - yl + 1; - uint32_t *source = &thread->dc_temp_rgba[yl*4]; - int c0, c1; - BYTE b0, b1; - - // Do 2 rows at a time. - for (int count8 = count >> 1; count8; --count8) - { - c0 = source[0]; c1 = source[1]; - b0 = translation[c0]; b1 = translation[c1]; - source[0] = b0; source[1] = b1; - - c0 = source[2]; c1 = source[3]; - b0 = translation[c0]; b1 = translation[c1]; - source[2] = b0; source[3] = b1; - - c0 = source[4]; c1 = source[5]; - b0 = translation[c0]; b1 = translation[c1]; - source[4] = b0; source[5] = b1; - - c0 = source[6]; c1 = source[7]; - b0 = translation[c0]; b1 = translation[c1]; - source[6] = b0; source[7] = b1; - - source += 8; - } - // Do the final row if count was odd. - if (count & 1) - { - c0 = source[0]; c1 = source[1]; - b0 = translation[c0]; b1 = translation[c1]; - source[0] = b0; source[1] = b1; - - c0 = source[2]; c1 = source[3]; - b0 = translation[c0]; b1 = translation[c1]; - source[2] = b0; source[3] = b1; - } - } -}; - class RtInitColsRGBACommand : public DrawerCommand { BYTE * RESTRICT buff; @@ -270,12 +160,13 @@ public: } }; +template class DrawColumnHorizRGBACommand : public DrawerCommand { int _count; fixed_t _iscale; fixed_t _texturefrac; - const BYTE * RESTRICT _source; + const InputPixelType * RESTRICT _source; int _x; int _yl; int _yh; @@ -286,7 +177,7 @@ public: _count = dc_count; _iscale = dc_iscale; _texturefrac = dc_texturefrac; - _source = dc_source; + _source = (const InputPixelType *)dc_source; _x = dc_x; _yl = dc_yl; _yh = dc_yh; @@ -309,7 +200,7 @@ public: fracstep = _iscale; frac = _texturefrac; - const BYTE *source = _source; + const InputPixelType *source = _source; if (count & 1) { *dest = source[frac >> FRACBITS]; dest += 4; frac += fracstep; @@ -419,28 +310,16 @@ void rt_map4cols_rgba (int sx, int yl, int yh) DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } -void rt_Translate1col_rgba(const BYTE *translation, int hx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(translation, hx, yl, yh); -} - -void rt_Translate4cols_rgba(const BYTE *translation, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(translation, yl, yh); -} - // Translates one span at hx to the screen at sx. void rt_tlate1col_rgba (int hx, int sx, int yl, int yh) { - rt_Translate1col_rgba(dc_translation, hx, yl, yh); - rt_map1col(hx, sx, yl, yh); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Translates all four spans to the screen starting at sx. void rt_tlate4cols_rgba (int sx, int yl, int yh) { - rt_Translate4cols_rgba(dc_translation, yl, yh); - rt_map4cols(sx, yl, yh); + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Adds one span at hx to the screen at sx without clamping. @@ -458,15 +337,13 @@ void rt_add4cols_rgba (int sx, int yl, int yh) // Translates and adds one span at hx to the screen at sx without clamping. void rt_tlateadd1col_rgba (int hx, int sx, int yl, int yh) { - rt_Translate1col_rgba(dc_translation, hx, yl, yh); - rt_add1col(hx, sx, yl, yh); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Translates and adds all four spans to the screen starting at sx without clamping. void rt_tlateadd4cols_rgba(int sx, int yl, int yh) { - rt_Translate4cols_rgba(dc_translation, yl, yh); - rt_add4cols(sx, yl, yh); + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Shades one span at hx to the screen at sx. @@ -496,15 +373,13 @@ void rt_addclamp4cols_rgba (int sx, int yl, int yh) // Translates and adds one span at hx to the screen at sx with clamping. void rt_tlateaddclamp1col_rgba (int hx, int sx, int yl, int yh) { - rt_Translate1col_rgba(dc_translation, hx, yl, yh); - rt_addclamp1col_rgba(hx, sx, yl, yh); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Translates and adds all four spans to the screen starting at sx with clamping. void rt_tlateaddclamp4cols_rgba (int sx, int yl, int yh) { - rt_Translate4cols_rgba(dc_translation, yl, yh); - rt_addclamp4cols(sx, yl, yh); + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Subtracts one span at hx to the screen at sx with clamping. @@ -522,15 +397,13 @@ void rt_subclamp4cols_rgba (int sx, int yl, int yh) // Translates and subtracts one span at hx to the screen at sx with clamping. void rt_tlatesubclamp1col_rgba (int hx, int sx, int yl, int yh) { - rt_Translate1col_rgba(dc_translation, hx, yl, yh); - rt_subclamp1col_rgba(hx, sx, yl, yh); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Translates and subtracts all four spans to the screen starting at sx with clamping. void rt_tlatesubclamp4cols_rgba (int sx, int yl, int yh) { - rt_Translate4cols_rgba(dc_translation, yl, yh); - rt_subclamp4cols_rgba(sx, yl, yh); + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Subtracts one span at hx from the screen at sx with clamping. @@ -548,15 +421,13 @@ void rt_revsubclamp4cols_rgba (int sx, int yl, int yh) // Translates and subtracts one span at hx from the screen at sx with clamping. void rt_tlaterevsubclamp1col_rgba (int hx, int sx, int yl, int yh) { - rt_Translate1col_rgba(dc_translation, hx, yl, yh); - rt_revsubclamp1col_rgba(hx, sx, yl, yh); + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Translates and subtracts all four spans from the screen starting at sx with clamping. void rt_tlaterevsubclamp4cols_rgba (int sx, int yl, int yh) { - rt_Translate4cols_rgba(dc_translation, yl, yh); - rt_revsubclamp4cols_rgba(sx, yl, yh); + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Before each pass through a rendering loop that uses these routines, @@ -590,7 +461,10 @@ void R_DrawColumnHoriz_rgba (void) (*span)[1] = dc_yh; *span += 2; - DrawerCommandQueue::QueueCommand(); + if (drawer_needs_pal_input) + DrawerCommandQueue::QueueCommand>(); + else + DrawerCommandQueue::QueueCommand>(); } // [RH] Just fills a column with a given color diff --git a/src/r_main.h b/src/r_main.h index 8d1867526..6a802e799 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -126,7 +126,7 @@ extern void (*hcolfunc_pre) (void); extern void (*hcolfunc_post1) (int hx, int sx, int yl, int yh); extern void (*hcolfunc_post2) (int hx, int sx, int yl, int yh); extern void (*hcolfunc_post4) (int sx, int yl, int yh); - +extern bool drawer_needs_pal_input; void R_InitTextureMapping (); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 078f1d921..92e6a447a 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -197,7 +197,11 @@ static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FText // draw the texture const FTexture::Span *spans; - const BYTE *pixels = tex->GetColumn (maskedtexturecol[dc_x] >> FRACBITS, &spans); + const BYTE *pixels; + if (r_swtruecolor && !drawer_needs_pal_input) + pixels = (const BYTE *)tex->GetColumnBgra(maskedtexturecol[dc_x] >> FRACBITS, &spans); + else + pixels = tex->GetColumn(maskedtexturecol[dc_x] >> FRACBITS, &spans); blastfunc (pixels, spans); rw_light += rw_lightstep; spryscale += rw_scalestep; diff --git a/src/r_things.cpp b/src/r_things.cpp index 639ed725e..8e306e04f 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -253,6 +253,7 @@ bool sprflipvert; void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span) { int pixelsize = r_swtruecolor ? 4 : 1; + int inputpixelsize = (r_swtruecolor && !drawer_needs_pal_input) ? 4 : 1; const fixed_t centeryfrac = FLOAT2FIXED(CenterY); const fixed_t texturemid = FLOAT2FIXED(dc_texturemid); while (span->Length != 0) @@ -322,7 +323,7 @@ void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span) endfrac -= dc_iscale; } } - dc_source = column + top; + dc_source = column + top * inputpixelsize; dc_dest = (ylookup[dc_yl] + dc_x) * pixelsize + dc_destorg; dc_count = dc_yh - dc_yl + 1; colfunc (); @@ -469,7 +470,11 @@ void R_DrawVisSprite (vissprite_t *vis) { while ((dc_x < stop4) && (dc_x & 3)) { - pixels = tex->GetColumn (frac >> FRACBITS, &spans); + if (r_swtruecolor && !drawer_needs_pal_input) + pixels = (const BYTE *)tex->GetColumnBgra (frac >> FRACBITS, &spans); + else + pixels = tex->GetColumn (frac >> FRACBITS, &spans); + if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) R_DrawMaskedColumn (pixels, spans); dc_x++; @@ -481,7 +486,11 @@ void R_DrawVisSprite (vissprite_t *vis) rt_initcols(nullptr); for (int zz = 4; zz; --zz) { - pixels = tex->GetColumn (frac >> FRACBITS, &spans); + if (r_swtruecolor && !drawer_needs_pal_input) + pixels = (const BYTE *)tex->GetColumnBgra (frac >> FRACBITS, &spans); + else + pixels = tex->GetColumn (frac >> FRACBITS, &spans); + if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) R_DrawMaskedColumnHoriz (pixels, spans); dc_x++; @@ -492,7 +501,11 @@ void R_DrawVisSprite (vissprite_t *vis) while (dc_x < x2) { - pixels = tex->GetColumn (frac >> FRACBITS, &spans); + if (r_swtruecolor && !drawer_needs_pal_input) + pixels = (const BYTE *)tex->GetColumnBgra (frac >> FRACBITS, &spans); + else + pixels = tex->GetColumn (frac >> FRACBITS, &spans); + if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) R_DrawMaskedColumn (pixels, spans); dc_x++; @@ -650,7 +663,10 @@ void R_WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Sp const BYTE *column; const FTexture::Span *spans; - column = WallSpriteTile->GetColumn (lwall[dc_x] >> FRACBITS, &spans); + if (r_swtruecolor && !drawer_needs_pal_input) + column = (const BYTE *)WallSpriteTile->GetColumnBgra (lwall[dc_x] >> FRACBITS, &spans); + else + column = WallSpriteTile->GetColumn (lwall[dc_x] >> FRACBITS, &spans); dc_texturefrac = 0; drawfunc (column, spans); rw_light += rw_lightstep; diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 37ced09d5..1c23523d6 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -305,7 +305,11 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) { while ((dc_x < stop4) && (dc_x & 3)) { - pixels = img->GetColumn(frac >> FRACBITS, spanptr); + if (r_swtruecolor && !drawer_needs_pal_input) + pixels = (const BYTE *)img->GetColumnBgra(frac >> FRACBITS, spanptr); + else + pixels = img->GetColumn(frac >> FRACBITS, spanptr); + R_DrawMaskedColumn(pixels, spans); dc_x++; frac += xiscale_i; @@ -316,7 +320,11 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) rt_initcols(nullptr); for (int zz = 4; zz; --zz) { - pixels = img->GetColumn(frac >> FRACBITS, spanptr); + if (r_swtruecolor && !drawer_needs_pal_input) + pixels = (const BYTE *)img->GetColumnBgra(frac >> FRACBITS, spanptr); + else + pixels = img->GetColumn(frac >> FRACBITS, spanptr); + R_DrawMaskedColumnHoriz(pixels, spans); dc_x++; frac += xiscale_i; @@ -326,7 +334,11 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) while (dc_x < x2_i) { - pixels = img->GetColumn(frac >> FRACBITS, spanptr); + if (r_swtruecolor && !drawer_needs_pal_input) + pixels = (const BYTE *)img->GetColumnBgra(frac >> FRACBITS, spanptr); + else + pixels = img->GetColumn(frac >> FRACBITS, spanptr); + R_DrawMaskedColumn(pixels, spans); dc_x++; frac += xiscale_i; From 606b7f5a0067d3edf9c32f462567ede04ea189a7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 8 Oct 2016 04:59:24 +0200 Subject: [PATCH 1049/1509] Run module level LLVM optimization passes before calling finalizeObject --- src/r_compiler/llvmdrawers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index ac0633058..ae9dcb662 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -143,8 +143,8 @@ LLVMDrawersImpl::LLVMDrawersImpl() CodegenDrawWall("tmvline1_revsubclamp", DrawWallVariant::RevSubClamp, 1); CodegenDrawWall("tmvline4_revsubclamp", DrawWallVariant::RevSubClamp, 4); - mProgram.engine()->finalizeObject(); mProgram.modulePassManager()->run(*mProgram.module()); + mProgram.engine()->finalizeObject(); FillColumn = mProgram.GetProcAddress("FillColumn"); FillColumnAdd = mProgram.GetProcAddress("FillColumnAdd"); From b3be0d22ccd6f1cb89e0dd8e3ca42b942139b19e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 8 Oct 2016 06:50:33 +0200 Subject: [PATCH 1050/1509] Unroll loops by 8 and enable some additional passes --- src/r_compiler/llvmdrawers.cpp | 3 +++ src/r_compiler/ssa/ssa_for_block.cpp | 17 +++++++++++++++-- src/r_compiler/ssa/ssa_for_block.h | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index ae9dcb662..9391e7e20 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -434,6 +434,9 @@ LLVMProgram::LLVMProgram() passManagerBuilder.OptLevel = 3; passManagerBuilder.SizeLevel = 0; passManagerBuilder.Inliner = createFunctionInliningPass(); + passManagerBuilder.SLPVectorize = true; + passManagerBuilder.LoopVectorize = true; + passManagerBuilder.LoadCombine = true; passManagerBuilder.populateModulePassManager(*mModulePassManager.get()); passManagerBuilder.populateFunctionPassManager(*mFunctionPassManager.get()); } diff --git a/src/r_compiler/ssa/ssa_for_block.cpp b/src/r_compiler/ssa/ssa_for_block.cpp index f7cd6ad0b..0f7e01e19 100644 --- a/src/r_compiler/ssa/ssa_for_block.cpp +++ b/src/r_compiler/ssa/ssa_for_block.cpp @@ -13,9 +13,22 @@ SSAForBlock::SSAForBlock() SSAScope::builder().SetInsertPoint(if_basic_block); } -void SSAForBlock::loop_block(SSABool true_condition) +void SSAForBlock::loop_block(SSABool true_condition, int unroll_count) { - SSAScope::builder().CreateCondBr(true_condition.v, loop_basic_block, end_basic_block); + auto branch = SSAScope::builder().CreateCondBr(true_condition.v, loop_basic_block, end_basic_block); + if (unroll_count > 0) + { + using namespace llvm; + auto md_unroll_enable = MDNode::get(SSAScope::context(), { + MDString::get(SSAScope::context(), "llvm.loop.unroll.enable") + }); + auto md_unroll_count = MDNode::get(SSAScope::context(), { + MDString::get(SSAScope::context(), "llvm.loop.unroll.count"), + ConstantAsMetadata::get(ConstantInt::get(SSAScope::context(), APInt(32, unroll_count))) + }); + auto md_loop = MDNode::getDistinct(SSAScope::context(), { md_unroll_enable, md_unroll_count }); + branch->setMetadata(LLVMContext::MD_loop, md_loop); + } SSAScope::builder().SetInsertPoint(loop_basic_block); } diff --git a/src/r_compiler/ssa/ssa_for_block.h b/src/r_compiler/ssa/ssa_for_block.h index 4c1952c14..9dddef4d6 100644 --- a/src/r_compiler/ssa/ssa_for_block.h +++ b/src/r_compiler/ssa/ssa_for_block.h @@ -7,7 +7,7 @@ class SSAForBlock { public: SSAForBlock(); - void loop_block(SSABool true_condition); + void loop_block(SSABool true_condition, int unroll_count = 8); void end_block(); private: From fc07a253068d26b043cd40492a7c16874505ed15 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 8 Oct 2016 09:29:26 +0200 Subject: [PATCH 1051/1509] Add aliasing meta data to loads and stores --- .../fixedfunction/drawcolumncodegen.cpp | 74 ++++++------- .../fixedfunction/drawercodegen.cpp | 20 ++-- .../fixedfunction/drawspancodegen.cpp | 60 +++++----- .../fixedfunction/drawwallcodegen.cpp | 104 +++++++++--------- src/r_compiler/ssa/ssa_float_ptr.cpp | 30 +++-- src/r_compiler/ssa/ssa_float_ptr.h | 6 +- src/r_compiler/ssa/ssa_int.cpp | 5 + src/r_compiler/ssa/ssa_int.h | 2 + src/r_compiler/ssa/ssa_int_ptr.cpp | 30 +++-- src/r_compiler/ssa/ssa_int_ptr.h | 6 +- src/r_compiler/ssa/ssa_pixelformat4f.h | 4 +- src/r_compiler/ssa/ssa_pixelformat4ub.h | 4 +- .../ssa/ssa_pixelformat4ub_argb_rev.h | 4 +- src/r_compiler/ssa/ssa_pixelformat4ub_rev.h | 4 +- src/r_compiler/ssa/ssa_scope.cpp | 9 ++ src/r_compiler/ssa/ssa_scope.h | 4 + src/r_compiler/ssa/ssa_ubyte_ptr.cpp | 36 ++++-- src/r_compiler/ssa/ssa_ubyte_ptr.h | 9 +- src/r_compiler/ssa/ssa_value.cpp | 10 +- src/r_compiler/ssa/ssa_value.h | 4 +- src/r_compiler/ssa/ssa_vec4f_ptr.cpp | 20 +++- src/r_compiler/ssa/ssa_vec4f_ptr.h | 4 +- 22 files changed, 260 insertions(+), 189 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp index e920fb73a..721c85dd8 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp @@ -13,41 +13,41 @@ void DrawColumnCodegen::Generate(DrawColumnVariant variant, DrawColumnMethod method, SSAValue args, SSAValue thread_data) { - dest = args[0][0].load(); - source = args[0][1].load(); - colormap = args[0][2].load(); - translation = args[0][3].load(); - basecolors = args[0][4].load(); - pitch = args[0][5].load(); - count = args[0][6].load(); - dest_y = args[0][7].load(); + dest = args[0][0].load(true); + source = args[0][1].load(true); + colormap = args[0][2].load(true); + translation = args[0][3].load(true); + basecolors = args[0][4].load(true); + pitch = args[0][5].load(true); + count = args[0][6].load(true); + dest_y = args[0][7].load(true); if (method == DrawColumnMethod::Normal) - iscale = args[0][8].load(); - texturefrac = args[0][9].load(); - light = args[0][10].load(); - color = SSAVec4i::unpack(args[0][11].load()); - srccolor = SSAVec4i::unpack(args[0][12].load()); - srcalpha = args[0][13].load(); - destalpha = args[0][14].load(); - SSAShort light_alpha = args[0][15].load(); - SSAShort light_red = args[0][16].load(); - SSAShort light_green = args[0][17].load(); - SSAShort light_blue = args[0][18].load(); - SSAShort fade_alpha = args[0][19].load(); - SSAShort fade_red = args[0][20].load(); - SSAShort fade_green = args[0][21].load(); - SSAShort fade_blue = args[0][22].load(); - SSAShort desaturate = args[0][23].load(); - SSAInt flags = args[0][24].load(); + iscale = args[0][8].load(true); + texturefrac = args[0][9].load(true); + light = args[0][10].load(true); + color = SSAVec4i::unpack(args[0][11].load(true)); + srccolor = SSAVec4i::unpack(args[0][12].load(true)); + srcalpha = args[0][13].load(true); + destalpha = args[0][14].load(true); + SSAShort light_alpha = args[0][15].load(true); + SSAShort light_red = args[0][16].load(true); + SSAShort light_green = args[0][17].load(true); + SSAShort light_blue = args[0][18].load(true); + SSAShort fade_alpha = args[0][19].load(true); + SSAShort fade_red = args[0][20].load(true); + SSAShort fade_green = args[0][21].load(true); + SSAShort fade_blue = args[0][22].load(true); + SSAShort desaturate = args[0][23].load(true); + SSAInt flags = args[0][24].load(true); shade_constants.light = SSAVec4i(light_blue.zext_int(), light_green.zext_int(), light_red.zext_int(), light_alpha.zext_int()); shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); shade_constants.desaturate = desaturate.zext_int(); - thread.core = thread_data[0][0].load(); - thread.num_cores = thread_data[0][1].load(); - thread.pass_start_y = thread_data[0][2].load(); - thread.pass_end_y = thread_data[0][3].load(); - thread.temp = thread_data[0][4].load(); + thread.core = thread_data[0][0].load(true); + thread.num_cores = thread_data[0][1].load(true); + thread.pass_start_y = thread_data[0][2].load(true); + thread.pass_end_y = thread_data[0][3].load(true); + thread.temp = thread_data[0][4].load(true); is_simple_shade = (flags & DrawColumnArgs::simple_shade) == SSAInt(DrawColumnArgs::simple_shade); @@ -104,7 +104,7 @@ void DrawColumnCodegen::Loop(DrawColumnVariant variant, DrawColumnMethod method, if (numColumns == 4) { - SSAVec16ub bg = dest[offset].load_unaligned_vec16ub(); + SSAVec16ub bg = dest[offset].load_unaligned_vec16ub(false); SSAVec8s bg0 = SSAVec8s::extendlo(bg); SSAVec8s bg1 = SSAVec8s::extendhi(bg); bgcolor[0] = SSAVec4i::extendlo(bg0); @@ -114,7 +114,7 @@ void DrawColumnCodegen::Loop(DrawColumnVariant variant, DrawColumnMethod method, } else { - bgcolor[0] = dest[offset].load_vec4ub(); + bgcolor[0] = dest[offset].load_vec4ub(false); } SSAVec4i outcolor[4]; @@ -131,7 +131,7 @@ void DrawColumnCodegen::Loop(DrawColumnVariant variant, DrawColumnMethod method, dest[offset].store_vec4ub(outcolor[0]); } - stack_index.store(index + 1); + stack_index.store(index.add(SSAInt(1), true, true)); if (method == DrawColumnMethod::Normal) stack_frac.store(frac + iscale); loop.end_block(); @@ -218,7 +218,7 @@ SSAVec4i DrawColumnCodegen::ProcessPixelPal(SSAInt sample_index, SSAVec4i bgcolo { default: case DrawColumnVariant::DrawCopy: - return blend_copy(basecolors[ColormapSample(sample_index) * 4].load_vec4ub()); + return blend_copy(basecolors[ColormapSample(sample_index) * 4].load_vec4ub(true)); case DrawColumnVariant::Draw: return blend_copy(ShadePal(ColormapSample(sample_index), isSimpleShade)); case DrawColumnVariant::DrawAdd: @@ -259,17 +259,17 @@ SSAVec4i DrawColumnCodegen::ProcessPixelPal(SSAInt sample_index, SSAVec4i bgcolo SSAVec4i DrawColumnCodegen::Sample(SSAInt sample_index) { - return source[sample_index].load_vec4ub(); + return source[sample_index].load_vec4ub(true); } SSAInt DrawColumnCodegen::ColormapSample(SSAInt sample_index) { - return colormap[source[sample_index].load().zext_int()].load().zext_int(); + return colormap[source[sample_index].load(true).zext_int()].load(true).zext_int(); } SSAInt DrawColumnCodegen::TranslateSample(SSAInt sample_index) { - return translation[source[sample_index].load().zext_int()].load().zext_int(); + return translation[source[sample_index].load(true).zext_int()].load(true).zext_int(); } SSAVec4i DrawColumnCodegen::Shade(SSAVec4i fg, bool isSimpleShade) diff --git a/src/r_compiler/fixedfunction/drawercodegen.cpp b/src/r_compiler/fixedfunction/drawercodegen.cpp index 822a81141..3916c29ab 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.cpp +++ b/src/r_compiler/fixedfunction/drawercodegen.cpp @@ -43,13 +43,13 @@ SSAInt DrawerCodegen::calc_light_multiplier(SSAInt light) SSAVec4i DrawerCodegen::shade_pal_index_simple(SSAInt index, SSAInt light, SSAUBytePtr basecolors) { - SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index]; + SSAVec4i color = basecolors[index * 4].load_vec4ub(true); // = GPalette.BaseColors[index]; return shade_bgra_simple(color, light); } SSAVec4i DrawerCodegen::shade_pal_index_advanced(SSAInt index, SSAInt light, const SSAShadeConstants &constants, SSAUBytePtr basecolors) { - SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index]; + SSAVec4i color = basecolors[index * 4].load_vec4ub(true); // = GPalette.BaseColors[index]; return shade_bgra_advanced(color, light, constants); } @@ -125,10 +125,10 @@ SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt SSAInt y0 = frac_y0 >> FRACBITS; SSAInt y1 = frac_y1 >> FRACBITS; - SSAVec4i p00 = col0[y0 * 4].load_vec4ub(); - SSAVec4i p01 = col0[y1 * 4].load_vec4ub(); - SSAVec4i p10 = col1[y0 * 4].load_vec4ub(); - SSAVec4i p11 = col1[y1 * 4].load_vec4ub(); + SSAVec4i p00 = col0[y0 * 4].load_vec4ub(true); + SSAVec4i p01 = col0[y1 * 4].load_vec4ub(true); + SSAVec4i p10 = col1[y0 * 4].load_vec4ub(true); + SSAVec4i p11 = col1[y1 * 4].load_vec4ub(true); SSAInt inv_b = texturefracx; SSAInt a = (frac_y1 >> (FRACBITS - 4)) & 15; @@ -147,10 +147,10 @@ SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt SSAInt x = xfrac >> xbits; SSAInt y = yfrac >> ybits; - SSAVec4i p00 = texture[((y & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(); - SSAVec4i p01 = texture[(((y + 1) & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(); - SSAVec4i p10 = texture[((y & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(); - SSAVec4i p11 = texture[(((y + 1) & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(); + SSAVec4i p00 = texture[((y & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(true); + SSAVec4i p01 = texture[(((y + 1) & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(true); + SSAVec4i p10 = texture[((y & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(true); + SSAVec4i p11 = texture[(((y + 1) & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(true); SSAInt inv_b = (xfrac >> (xbits - 4)) & 15; SSAInt inv_a = (yfrac >> (ybits - 4)) & 15; diff --git a/src/r_compiler/fixedfunction/drawspancodegen.cpp b/src/r_compiler/fixedfunction/drawspancodegen.cpp index 70ecb0abd..4404456ab 100644 --- a/src/r_compiler/fixedfunction/drawspancodegen.cpp +++ b/src/r_compiler/fixedfunction/drawspancodegen.cpp @@ -13,31 +13,31 @@ void DrawSpanCodegen::Generate(DrawSpanVariant variant, SSAValue args) { - destorg = args[0][0].load(); - source = args[0][1].load(); - destpitch = args[0][2].load(); - stack_xfrac.store(args[0][3].load()); - stack_yfrac.store(args[0][4].load()); - xstep = args[0][5].load(); - ystep = args[0][6].load(); - x1 = args[0][7].load(); - x2 = args[0][8].load(); - y = args[0][9].load(); - xbits = args[0][10].load(); - ybits = args[0][11].load(); - light = args[0][12].load(); - srcalpha = args[0][13].load(); - destalpha = args[0][14].load(); - SSAShort light_alpha = args[0][15].load(); - SSAShort light_red = args[0][16].load(); - SSAShort light_green = args[0][17].load(); - SSAShort light_blue = args[0][18].load(); - SSAShort fade_alpha = args[0][19].load(); - SSAShort fade_red = args[0][20].load(); - SSAShort fade_green = args[0][21].load(); - SSAShort fade_blue = args[0][22].load(); - SSAShort desaturate = args[0][23].load(); - SSAInt flags = args[0][24].load(); + destorg = args[0][0].load(true); + source = args[0][1].load(true); + destpitch = args[0][2].load(true); + stack_xfrac.store(args[0][3].load(true)); + stack_yfrac.store(args[0][4].load(true)); + xstep = args[0][5].load(true); + ystep = args[0][6].load(true); + x1 = args[0][7].load(true); + x2 = args[0][8].load(true); + y = args[0][9].load(true); + xbits = args[0][10].load(true); + ybits = args[0][11].load(true); + light = args[0][12].load(true); + srcalpha = args[0][13].load(true); + destalpha = args[0][14].load(true); + SSAShort light_alpha = args[0][15].load(true); + SSAShort light_red = args[0][16].load(true); + SSAShort light_green = args[0][17].load(true); + SSAShort light_blue = args[0][18].load(true); + SSAShort fade_alpha = args[0][19].load(true); + SSAShort fade_red = args[0][20].load(true); + SSAShort fade_green = args[0][21].load(true); + SSAShort fade_blue = args[0][22].load(true); + SSAShort desaturate = args[0][23].load(true); + SSAInt flags = args[0][24].load(true); shade_constants.light = SSAVec4i(light_blue.zext_int(), light_green.zext_int(), light_red.zext_int(), light_alpha.zext_int()); shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); shade_constants.desaturate = desaturate.zext_int(); @@ -97,7 +97,7 @@ SSAInt DrawSpanCodegen::Loop4x(DrawSpanVariant variant, bool isSimpleShade, bool SSAInt index = stack_index.load(); loop.loop_block(index < sseLength); - SSAVec16ub bg = data[index * 16].load_unaligned_vec16ub(); + SSAVec16ub bg = data[index * 16].load_unaligned_vec16ub(false); SSAVec8s bg0 = SSAVec8s::extendlo(bg); SSAVec8s bg1 = SSAVec8s::extendhi(bg); SSAVec4i bgcolors[4] = @@ -123,7 +123,7 @@ SSAInt DrawSpanCodegen::Loop4x(DrawSpanVariant variant, bool isSimpleShade, bool SSAVec16ub color(SSAVec8s(colors[0], colors[1]), SSAVec8s(colors[2], colors[3])); data[index * 16].store_unaligned_vec16ub(color); - stack_index.store(index + 1); + stack_index.store(index.add(SSAInt(1), true, true)); loop.end_block(); } return sseLength; @@ -140,11 +140,11 @@ void DrawSpanCodegen::Loop(SSAInt start, DrawSpanVariant variant, bool isSimpleS SSAInt xfrac = stack_xfrac.load(); SSAInt yfrac = stack_yfrac.load(); - SSAVec4i bgcolor = data[index * 4].load_vec4ub(); + SSAVec4i bgcolor = data[index * 4].load_vec4ub(false); SSAVec4i color = Blend(Shade(Sample(xfrac, yfrac, isNearestFilter, is64x64), isSimpleShade), bgcolor, variant); data[index * 4].store_vec4ub(color); - stack_index.store(index + 1); + stack_index.store(index.add(SSAInt(1), true, true)); stack_xfrac.store(xfrac + xstep); stack_yfrac.store(yfrac + ystep); loop.end_block(); @@ -160,7 +160,7 @@ SSAVec4i DrawSpanCodegen::Sample(SSAInt xfrac, SSAInt yfrac, bool isNearestFilte spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); else spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - return source[spot * 4].load_vec4ub(); + return source[spot * 4].load_vec4ub(true); } else { diff --git a/src/r_compiler/fixedfunction/drawwallcodegen.cpp b/src/r_compiler/fixedfunction/drawwallcodegen.cpp index 55b17dafe..56d99e78e 100644 --- a/src/r_compiler/fixedfunction/drawwallcodegen.cpp +++ b/src/r_compiler/fixedfunction/drawwallcodegen.cpp @@ -13,58 +13,58 @@ void DrawWallCodegen::Generate(DrawWallVariant variant, bool fourColumns, SSAValue args, SSAValue thread_data) { - dest = args[0][0].load(); - source[0] = args[0][1].load(); - source[1] = args[0][2].load(); - source[2] = args[0][3].load(); - source[3] = args[0][4].load(); - source2[0] = args[0][5].load(); - source2[1] = args[0][6].load(); - source2[2] = args[0][7].load(); - source2[3] = args[0][8].load(); - pitch = args[0][9].load(); - count = args[0][10].load(); - dest_y = args[0][11].load(); - texturefrac[0] = args[0][12].load(); - texturefrac[1] = args[0][13].load(); - texturefrac[2] = args[0][14].load(); - texturefrac[3] = args[0][15].load(); - texturefracx[0] = args[0][16].load(); - texturefracx[1] = args[0][17].load(); - texturefracx[2] = args[0][18].load(); - texturefracx[3] = args[0][19].load(); - iscale[0] = args[0][20].load(); - iscale[1] = args[0][21].load(); - iscale[2] = args[0][22].load(); - iscale[3] = args[0][23].load(); - textureheight[0] = args[0][24].load(); - textureheight[1] = args[0][25].load(); - textureheight[2] = args[0][26].load(); - textureheight[3] = args[0][27].load(); - light[0] = args[0][28].load(); - light[1] = args[0][29].load(); - light[2] = args[0][30].load(); - light[3] = args[0][31].load(); - srcalpha = args[0][32].load(); - destalpha = args[0][33].load(); - SSAShort light_alpha = args[0][34].load(); - SSAShort light_red = args[0][35].load(); - SSAShort light_green = args[0][36].load(); - SSAShort light_blue = args[0][37].load(); - SSAShort fade_alpha = args[0][38].load(); - SSAShort fade_red = args[0][39].load(); - SSAShort fade_green = args[0][40].load(); - SSAShort fade_blue = args[0][41].load(); - SSAShort desaturate = args[0][42].load(); - SSAInt flags = args[0][43].load(); + dest = args[0][0].load(true); + source[0] = args[0][1].load(true); + source[1] = args[0][2].load(true); + source[2] = args[0][3].load(true); + source[3] = args[0][4].load(true); + source2[0] = args[0][5].load(true); + source2[1] = args[0][6].load(true); + source2[2] = args[0][7].load(true); + source2[3] = args[0][8].load(true); + pitch = args[0][9].load(true); + count = args[0][10].load(true); + dest_y = args[0][11].load(true); + texturefrac[0] = args[0][12].load(true); + texturefrac[1] = args[0][13].load(true); + texturefrac[2] = args[0][14].load(true); + texturefrac[3] = args[0][15].load(true); + texturefracx[0] = args[0][16].load(true); + texturefracx[1] = args[0][17].load(true); + texturefracx[2] = args[0][18].load(true); + texturefracx[3] = args[0][19].load(true); + iscale[0] = args[0][20].load(true); + iscale[1] = args[0][21].load(true); + iscale[2] = args[0][22].load(true); + iscale[3] = args[0][23].load(true); + textureheight[0] = args[0][24].load(true); + textureheight[1] = args[0][25].load(true); + textureheight[2] = args[0][26].load(true); + textureheight[3] = args[0][27].load(true); + light[0] = args[0][28].load(true); + light[1] = args[0][29].load(true); + light[2] = args[0][30].load(true); + light[3] = args[0][31].load(true); + srcalpha = args[0][32].load(true); + destalpha = args[0][33].load(true); + SSAShort light_alpha = args[0][34].load(true); + SSAShort light_red = args[0][35].load(true); + SSAShort light_green = args[0][36].load(true); + SSAShort light_blue = args[0][37].load(true); + SSAShort fade_alpha = args[0][38].load(true); + SSAShort fade_red = args[0][39].load(true); + SSAShort fade_green = args[0][40].load(true); + SSAShort fade_blue = args[0][41].load(true); + SSAShort desaturate = args[0][42].load(true); + SSAInt flags = args[0][43].load(true); shade_constants.light = SSAVec4i(light_blue.zext_int(), light_green.zext_int(), light_red.zext_int(), light_alpha.zext_int()); shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); shade_constants.desaturate = desaturate.zext_int(); - thread.core = thread_data[0][0].load(); - thread.num_cores = thread_data[0][1].load(); - thread.pass_start_y = thread_data[0][2].load(); - thread.pass_end_y = thread_data[0][3].load(); + thread.core = thread_data[0][0].load(true); + thread.num_cores = thread_data[0][1].load(true); + thread.pass_start_y = thread_data[0][2].load(true); + thread.pass_end_y = thread_data[0][3].load(true); is_simple_shade = (flags & DrawWallArgs::simple_shade) == SSAInt(DrawWallArgs::simple_shade); is_nearest_filter = (flags & DrawWallArgs::nearest_filter) == SSAInt(DrawWallArgs::nearest_filter); @@ -118,7 +118,7 @@ void DrawWallCodegen::Loop(DrawWallVariant variant, bool fourColumns, bool isSim if (fourColumns) { - SSAVec16ub bg = dest[offset].load_unaligned_vec16ub(); + SSAVec16ub bg = dest[offset].load_unaligned_vec16ub(false); SSAVec8s bg0 = SSAVec8s::extendlo(bg); SSAVec8s bg1 = SSAVec8s::extendhi(bg); SSAVec4i bgcolors[4] = @@ -138,12 +138,12 @@ void DrawWallCodegen::Loop(DrawWallVariant variant, bool fourColumns, bool isSim } else { - SSAVec4i bgcolor = dest[offset].load_vec4ub(); + SSAVec4i bgcolor = dest[offset].load_vec4ub(false); SSAVec4i color = Blend(Shade(Sample(frac[0], 0, isNearestFilter), 0, isSimpleShade), bgcolor, variant); dest[offset].store_vec4ub(color); } - stack_index.store(index + 1); + stack_index.store(index.add(SSAInt(1), true, true)); for (int i = 0; i < numColumns; i++) stack_frac[i].store(frac[i] + fracstep[i]); loop.end_block(); @@ -155,7 +155,7 @@ SSAVec4i DrawWallCodegen::Sample(SSAInt frac, int index, bool isNearestFilter) if (isNearestFilter) { SSAInt sample_index = ((frac >> FRACBITS) * textureheight[index]) >> FRACBITS; - return source[index][sample_index * 4].load_vec4ub(); + return source[index][sample_index * 4].load_vec4ub(false); } else { diff --git a/src/r_compiler/ssa/ssa_float_ptr.cpp b/src/r_compiler/ssa/ssa_float_ptr.cpp index 582821ca0..f694be15d 100644 --- a/src/r_compiler/ssa/ssa_float_ptr.cpp +++ b/src/r_compiler/ssa/ssa_float_ptr.cpp @@ -23,36 +23,48 @@ SSAFloatPtr SSAFloatPtr::operator[](SSAInt index) const return SSAFloatPtr::from_llvm(SSAScope::builder().CreateGEP(v, index.v, SSAScope::hint())); } -SSAFloat SSAFloatPtr::load() const +SSAFloat SSAFloatPtr::load(bool constantScopeDomain) const { - return SSAFloat::from_llvm(SSAScope::builder().CreateLoad(v, false, SSAScope::hint())); + auto loadInst = SSAScope::builder().CreateLoad(v, false, SSAScope::hint()); + if (constantScopeDomain) + loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); + return SSAFloat::from_llvm(loadInst); } -SSAVec4f SSAFloatPtr::load_vec4f() const +SSAVec4f SSAFloatPtr::load_vec4f(bool constantScopeDomain) const { llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); - return SSAVec4f::from_llvm(SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), false, SSAScope::hint())); + auto loadInst = SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), false, SSAScope::hint()); + if (constantScopeDomain) + loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); + return SSAVec4f::from_llvm(loadInst); } -SSAVec4f SSAFloatPtr::load_unaligned_vec4f() const +SSAVec4f SSAFloatPtr::load_unaligned_vec4f(bool constantScopeDomain) const { llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); - return SSAVec4f::from_llvm(SSAScope::builder().Insert(new llvm::LoadInst(SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), SSAScope::hint(), false, 4), SSAScope::hint())); + auto loadInst = SSAScope::builder().CreateAlignedLoad(SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), 4, false, SSAScope::hint()); + if (constantScopeDomain) + loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); + return SSAVec4f::from_llvm(loadInst); } void SSAFloatPtr::store(const SSAFloat &new_value) { - SSAScope::builder().CreateStore(new_value.v, v, false); + auto inst = SSAScope::builder().CreateStore(new_value.v, v, false); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } void SSAFloatPtr::store_vec4f(const SSAVec4f &new_value) { llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); - SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint())); + auto inst = SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint())); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } void SSAFloatPtr::store_unaligned_vec4f(const SSAVec4f &new_value) { llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); - SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), 4); + auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), 4); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } diff --git a/src/r_compiler/ssa/ssa_float_ptr.h b/src/r_compiler/ssa/ssa_float_ptr.h index f29b2de3f..a9953eb81 100644 --- a/src/r_compiler/ssa/ssa_float_ptr.h +++ b/src/r_compiler/ssa/ssa_float_ptr.h @@ -17,9 +17,9 @@ public: static llvm::Type *llvm_type(); SSAFloatPtr operator[](SSAInt index) const; SSAFloatPtr operator[](int index) const { return (*this)[SSAInt(index)]; } - SSAFloat load() const; - SSAVec4f load_vec4f() const; - SSAVec4f load_unaligned_vec4f() const; + SSAFloat load(bool constantScopeDomain) const; + SSAVec4f load_vec4f(bool constantScopeDomain) const; + SSAVec4f load_unaligned_vec4f(bool constantScopeDomain) const; void store(const SSAFloat &new_value); void store_vec4f(const SSAVec4f &new_value); void store_unaligned_vec4f(const SSAVec4f &new_value); diff --git a/src/r_compiler/ssa/ssa_int.cpp b/src/r_compiler/ssa/ssa_int.cpp index 3d9cb22bd..1815985c5 100644 --- a/src/r_compiler/ssa/ssa_int.cpp +++ b/src/r_compiler/ssa/ssa_int.cpp @@ -42,6 +42,11 @@ SSAInt SSAInt::MAX(SSAInt a, SSAInt b) return SSAInt::from_llvm(SSAScope::builder().CreateSelect((a > b).v, a.v, b.v, SSAScope::hint())); } +SSAInt SSAInt::add(SSAInt b, bool no_unsigned_wrap, bool no_signed_wrap) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateAdd(v, b.v, SSAScope::hint(), no_unsigned_wrap, no_signed_wrap)); +} + SSAInt operator+(const SSAInt &a, const SSAInt &b) { return SSAInt::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); diff --git a/src/r_compiler/ssa/ssa_int.h b/src/r_compiler/ssa/ssa_int.h index c0f46e4b6..e9ce978c4 100644 --- a/src/r_compiler/ssa/ssa_int.h +++ b/src/r_compiler/ssa/ssa_int.h @@ -19,6 +19,8 @@ public: static SSAInt MIN(SSAInt a, SSAInt b); static SSAInt MAX(SSAInt a, SSAInt b); + SSAInt add(SSAInt b, bool no_unsigned_wrap, bool no_signed_wrap); + llvm::Value *v; }; diff --git a/src/r_compiler/ssa/ssa_int_ptr.cpp b/src/r_compiler/ssa/ssa_int_ptr.cpp index 974645d08..d9441088e 100644 --- a/src/r_compiler/ssa/ssa_int_ptr.cpp +++ b/src/r_compiler/ssa/ssa_int_ptr.cpp @@ -23,36 +23,48 @@ SSAIntPtr SSAIntPtr::operator[](SSAInt index) const return SSAIntPtr::from_llvm(SSAScope::builder().CreateGEP(v, index.v, SSAScope::hint())); } -SSAInt SSAIntPtr::load() const +SSAInt SSAIntPtr::load(bool constantScopeDomain) const { - return SSAInt::from_llvm(SSAScope::builder().CreateLoad(v, false, SSAScope::hint())); + auto loadInst = SSAScope::builder().CreateLoad(v, false, SSAScope::hint()); + if (constantScopeDomain) + loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); + return SSAInt::from_llvm(loadInst); } -SSAVec4i SSAIntPtr::load_vec4i() const +SSAVec4i SSAIntPtr::load_vec4i(bool constantScopeDomain) const { llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); - return SSAVec4i::from_llvm(SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), false, SSAScope::hint())); + auto loadInst = SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), false, SSAScope::hint()); + if (constantScopeDomain) + loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); + return SSAVec4i::from_llvm(loadInst); } -SSAVec4i SSAIntPtr::load_unaligned_vec4i() const +SSAVec4i SSAIntPtr::load_unaligned_vec4i(bool constantScopeDomain) const { llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); - return SSAVec4i::from_llvm(SSAScope::builder().Insert(new llvm::LoadInst(SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), SSAScope::hint(), false, 4), SSAScope::hint())); + auto loadInst = SSAScope::builder().CreateAlignedLoad(SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 4, false, SSAScope::hint()); + if (constantScopeDomain) + loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); + return SSAVec4i::from_llvm(loadInst); } void SSAIntPtr::store(const SSAInt &new_value) { - SSAScope::builder().CreateStore(new_value.v, v, false); + auto inst = SSAScope::builder().CreateStore(new_value.v, v, false); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } void SSAIntPtr::store_vec4i(const SSAVec4i &new_value) { llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); - SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint())); + auto inst = SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint())); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } void SSAIntPtr::store_unaligned_vec4i(const SSAVec4i &new_value) { llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); - SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 4); + auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 4); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } diff --git a/src/r_compiler/ssa/ssa_int_ptr.h b/src/r_compiler/ssa/ssa_int_ptr.h index c75ed6a8d..968528365 100644 --- a/src/r_compiler/ssa/ssa_int_ptr.h +++ b/src/r_compiler/ssa/ssa_int_ptr.h @@ -17,9 +17,9 @@ public: static llvm::Type *llvm_type(); SSAIntPtr operator[](SSAInt index) const; SSAIntPtr operator[](int index) const { return (*this)[SSAInt(index)]; } - SSAInt load() const; - SSAVec4i load_vec4i() const; - SSAVec4i load_unaligned_vec4i() const; + SSAInt load(bool constantScopeDomain) const; + SSAVec4i load_vec4i(bool constantScopeDomain) const; + SSAVec4i load_unaligned_vec4i(bool constantScopeDomain) const; void store(const SSAInt &new_value); void store_vec4i(const SSAVec4i &new_value); void store_unaligned_vec4i(const SSAVec4i &new_value); diff --git a/src/r_compiler/ssa/ssa_pixelformat4f.h b/src/r_compiler/ssa/ssa_pixelformat4f.h index 507e95b5d..9cefb517b 100644 --- a/src/r_compiler/ssa/ssa_pixelformat4f.h +++ b/src/r_compiler/ssa/ssa_pixelformat4f.h @@ -13,9 +13,9 @@ public: SSAFloatPtr pixels() { return _pixels; } SSAFloatPtr pixels() const { return _pixels; } - SSAVec4f get4f(SSAInt index) const + SSAVec4f get4f(SSAInt index, bool constantScopeDomain) const { - return _pixels[index * 4].load_vec4f(); + return _pixels[index * 4].load_vec4f(constantScopeDomain); } void set4f(SSAInt index, const SSAVec4f &pixel) diff --git a/src/r_compiler/ssa/ssa_pixelformat4ub.h b/src/r_compiler/ssa/ssa_pixelformat4ub.h index fdf98c4aa..91b04557c 100644 --- a/src/r_compiler/ssa/ssa_pixelformat4ub.h +++ b/src/r_compiler/ssa/ssa_pixelformat4ub.h @@ -13,9 +13,9 @@ public: SSAUBytePtr pixels() { return _pixels; } SSAUBytePtr pixels() const { return _pixels; } - SSAVec4f get4f(SSAInt index) const + SSAVec4f get4f(SSAInt index, bool constantScopeDomain) const { - return SSAVec4f(_pixels[index * 4].load_vec4ub()) * (1.0f / 255.0f); + return SSAVec4f(_pixels[index * 4].load_vec4ub(constantScopeDomain)) * (1.0f / 255.0f); } void set4f(SSAInt index, const SSAVec4f &pixel) diff --git a/src/r_compiler/ssa/ssa_pixelformat4ub_argb_rev.h b/src/r_compiler/ssa/ssa_pixelformat4ub_argb_rev.h index 4601eeb3c..1f7e4eb0f 100644 --- a/src/r_compiler/ssa/ssa_pixelformat4ub_argb_rev.h +++ b/src/r_compiler/ssa/ssa_pixelformat4ub_argb_rev.h @@ -20,9 +20,9 @@ public: out_pixel2 = SSAVec4f::shuffle(SSAVec4f(SSAVec4i::extendhi(p)) * (1.0f / 255.0f), 2, 1, 0, 3); } */ - SSAVec4f get4f(SSAInt index) const + SSAVec4f get4f(SSAInt index, bool constantScopeDomain) const { - return SSAVec4f::shuffle(SSAVec4f(_pixels[index * 4].load_vec4ub()) * (1.0f / 255.0f), 2, 1, 0, 3); + return SSAVec4f::shuffle(SSAVec4f(_pixels[index * 4].load_vec4ub(constantScopeDomain)) * (1.0f / 255.0f), 2, 1, 0, 3); } void set4f(SSAInt index, const SSAVec4f &pixel) diff --git a/src/r_compiler/ssa/ssa_pixelformat4ub_rev.h b/src/r_compiler/ssa/ssa_pixelformat4ub_rev.h index 402480c49..9b50ec00f 100644 --- a/src/r_compiler/ssa/ssa_pixelformat4ub_rev.h +++ b/src/r_compiler/ssa/ssa_pixelformat4ub_rev.h @@ -13,9 +13,9 @@ public: SSAUBytePtr pixels() { return _pixels; } SSAUBytePtr pixels() const { return _pixels; } - SSAVec4f get4f(SSAInt index) const + SSAVec4f get4f(SSAInt index, bool constantScopeDomain) const { - return SSAVec4f::shuffle(SSAVec4f(_pixels[index * 4].load_vec4ub()) * (1.0f / 255.0f), 3, 2, 1, 0); + return SSAVec4f::shuffle(SSAVec4f(_pixels[index * 4].load_vec4ub(constantScopeDomain)) * (1.0f / 255.0f), 3, 2, 1, 0); } void set4f(SSAInt index, const SSAVec4f &pixel) diff --git a/src/r_compiler/ssa/ssa_scope.cpp b/src/r_compiler/ssa/ssa_scope.cpp index e5d34a203..520f301a4 100644 --- a/src/r_compiler/ssa/ssa_scope.cpp +++ b/src/r_compiler/ssa/ssa_scope.cpp @@ -7,6 +7,10 @@ SSAScope::SSAScope(llvm::LLVMContext *context, llvm::Module *module, llvm::IRBui : _context(context), _module(module), _builder(builder) { instance = this; + + _constant_scope_domain = llvm::MDNode::get(SSAScope::context(), { llvm::MDString::get(SSAScope::context(), "ConstantScopeDomain") }); + _constant_scope = llvm::MDNode::getDistinct(SSAScope::context(), { _constant_scope_domain }); + _constant_scope_list = llvm::MDNode::get(SSAScope::context(), { _constant_scope }); } SSAScope::~SSAScope() @@ -50,6 +54,11 @@ llvm::Value *SSAScope::alloca(llvm::Type *type, SSAInt size) return alloca_builder.CreateAlloca(type, size.v, hint()); } +llvm::MDNode *SSAScope::constant_scope_list() +{ + return instance->_constant_scope_list; +} + const std::string &SSAScope::hint() { return instance->_hint; diff --git a/src/r_compiler/ssa/ssa_scope.h b/src/r_compiler/ssa/ssa_scope.h index ad080fde6..c942a7c37 100644 --- a/src/r_compiler/ssa/ssa_scope.h +++ b/src/r_compiler/ssa/ssa_scope.h @@ -14,6 +14,7 @@ public: static llvm::Function *intrinsic(llvm::Intrinsic::ID id, llvm::ArrayRef parameter_types = llvm::ArrayRef()); static llvm::Value *alloca(llvm::Type *type); static llvm::Value *alloca(llvm::Type *type, SSAInt size); + static llvm::MDNode *constant_scope_list(); static const std::string &hint(); static void set_hint(const std::string &hint); @@ -22,6 +23,9 @@ private: llvm::LLVMContext *_context; llvm::Module *_module; llvm::IRBuilder<> *_builder; + llvm::MDNode *_constant_scope_domain; + llvm::MDNode *_constant_scope; + llvm::MDNode *_constant_scope_list; std::string _hint; }; diff --git a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp index 34de0ab88..1ce4a6ae2 100644 --- a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp +++ b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp @@ -23,32 +23,45 @@ SSAUBytePtr SSAUBytePtr::operator[](SSAInt index) const return SSAUBytePtr::from_llvm(SSAScope::builder().CreateGEP(v, index.v, SSAScope::hint())); } -SSAUByte SSAUBytePtr::load() const +SSAUByte SSAUBytePtr::load(bool constantScopeDomain) const { - return SSAUByte::from_llvm(SSAScope::builder().CreateLoad(v, false, SSAScope::hint())); + auto loadInst = SSAScope::builder().CreateLoad(v, false, SSAScope::hint()); + if (constantScopeDomain) + loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); + return SSAUByte::from_llvm(loadInst); } -SSAVec4i SSAUBytePtr::load_vec4ub() const +SSAVec4i SSAUBytePtr::load_vec4ub(bool constantScopeDomain) const { - SSAInt i32 = SSAInt::from_llvm(SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, llvm::Type::getInt32PtrTy(SSAScope::context()), SSAScope::hint()), false, SSAScope::hint())); + auto loadInst = SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, llvm::Type::getInt32PtrTy(SSAScope::context()), SSAScope::hint()), false, SSAScope::hint()); + if (constantScopeDomain) + loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); + SSAInt i32 = SSAInt::from_llvm(loadInst); return SSAVec4i::unpack(i32); } -SSAVec16ub SSAUBytePtr::load_vec16ub() const +SSAVec16ub SSAUBytePtr::load_vec16ub(bool constantScopeDomain) const { llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); - return SSAVec16ub::from_llvm(SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), false, SSAScope::hint())); + auto loadInst = SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), false, SSAScope::hint()); + if (constantScopeDomain) + loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); + return SSAVec16ub::from_llvm(loadInst); } -SSAVec16ub SSAUBytePtr::load_unaligned_vec16ub() const +SSAVec16ub SSAUBytePtr::load_unaligned_vec16ub(bool constantScopeDomain) const { llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); - return SSAVec16ub::from_llvm(SSAScope::builder().Insert(new llvm::LoadInst(SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), SSAScope::hint(), false, 4), SSAScope::hint())); + auto loadInst = SSAScope::builder().CreateAlignedLoad(SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), 4, false, SSAScope::hint()); + if (constantScopeDomain) + loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); + return SSAVec16ub::from_llvm(loadInst); } void SSAUBytePtr::store(const SSAUByte &new_value) { - SSAScope::builder().CreateStore(new_value.v, v, false); + auto inst = SSAScope::builder().CreateStore(new_value.v, v, false); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } void SSAUBytePtr::store_vec4ub(const SSAVec4i &new_value) @@ -66,13 +79,15 @@ void SSAUBytePtr::store_vec4ub(const SSAVec4i &new_value) constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 3))); llvm::Value *mask = llvm::ConstantVector::get(constants); llvm::Value *val_vector = SSAScope::builder().CreateShuffleVector(v16ub.v, llvm::UndefValue::get(m16xint8type), mask, SSAScope::hint()); - SSAScope::builder().CreateStore(val_vector, SSAScope::builder().CreateBitCast(v, m4xint8typeptr, SSAScope::hint()), false); + llvm::StoreInst *inst = SSAScope::builder().CreateStore(val_vector, SSAScope::builder().CreateBitCast(v, m4xint8typeptr, SSAScope::hint()), false); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } void SSAUBytePtr::store_vec16ub(const SSAVec16ub &new_value) { llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); llvm::StoreInst *inst = SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint())); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); // The following generates _mm_stream_si128, maybe! // llvm::MDNode *node = llvm::MDNode::get(SSAScope::context(), SSAScope::builder().getInt32(1)); @@ -83,4 +98,5 @@ void SSAUBytePtr::store_unaligned_vec16ub(const SSAVec16ub &new_value) { llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); llvm::StoreInst *inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), 4); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } diff --git a/src/r_compiler/ssa/ssa_ubyte_ptr.h b/src/r_compiler/ssa/ssa_ubyte_ptr.h index c084068bc..167a5877d 100644 --- a/src/r_compiler/ssa/ssa_ubyte_ptr.h +++ b/src/r_compiler/ssa/ssa_ubyte_ptr.h @@ -19,11 +19,10 @@ public: static llvm::Type *llvm_type(); SSAUBytePtr operator[](SSAInt index) const; SSAUBytePtr operator[](int index) const { return (*this)[SSAInt(index)]; } - SSAUByte load() const; - SSAVec4i load_vec4ub() const; - SSAVec8s load_vec8s() const; - SSAVec16ub load_vec16ub() const; - SSAVec16ub load_unaligned_vec16ub() const; + SSAUByte load(bool constantScopeDomain) const; + SSAVec4i load_vec4ub(bool constantScopeDomain) const; + SSAVec16ub load_vec16ub(bool constantScopeDomain) const; + SSAVec16ub load_unaligned_vec16ub(bool constantScopeDomain) const; void store(const SSAUByte &new_value); void store_vec4ub(const SSAVec4i &new_value); void store_vec16ub(const SSAVec16ub &new_value); diff --git a/src/r_compiler/ssa/ssa_value.cpp b/src/r_compiler/ssa/ssa_value.cpp index c37b7f4c1..65f9da15d 100644 --- a/src/r_compiler/ssa/ssa_value.cpp +++ b/src/r_compiler/ssa/ssa_value.cpp @@ -4,14 +4,18 @@ #include "ssa_int.h" #include "ssa_scope.h" -SSAValue SSAValue::load() +SSAValue SSAValue::load(bool constantScopeDomain) { - return SSAValue::from_llvm(SSAScope::builder().CreateLoad(v, false)); + auto loadInst = SSAScope::builder().CreateLoad(v, false); + if (constantScopeDomain) + loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); + return SSAValue::from_llvm(loadInst); } void SSAValue::store(llvm::Value *value) { - SSAScope::builder().CreateStore(value, v, false); + auto inst = SSAScope::builder().CreateStore(value, v, false); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } SSAIndexLookup SSAValue::operator[](int index) diff --git a/src/r_compiler/ssa/ssa_value.h b/src/r_compiler/ssa/ssa_value.h index ec156a452..d0d73043c 100644 --- a/src/r_compiler/ssa/ssa_value.h +++ b/src/r_compiler/ssa/ssa_value.h @@ -15,7 +15,7 @@ public: static SSAValue from_llvm(llvm::Value *v) { SSAValue val; val.v = v; return val; } - SSAValue load(); + SSAValue load(bool constantScopeDomain); void store(llvm::Value *v); template @@ -38,7 +38,7 @@ public: llvm::Value *v; std::vector indexes; - SSAValue load() { SSAValue value = *this; return value.load(); } + SSAValue load(bool constantScopeDomain) { SSAValue value = *this; return value.load(constantScopeDomain); } void store(llvm::Value *v) { SSAValue value = *this; return value.store(v); } template diff --git a/src/r_compiler/ssa/ssa_vec4f_ptr.cpp b/src/r_compiler/ssa/ssa_vec4f_ptr.cpp index e0ed8bc86..e8bac71f1 100644 --- a/src/r_compiler/ssa/ssa_vec4f_ptr.cpp +++ b/src/r_compiler/ssa/ssa_vec4f_ptr.cpp @@ -23,22 +23,30 @@ SSAVec4fPtr SSAVec4fPtr::operator[](SSAInt index) const return SSAVec4fPtr::from_llvm(SSAScope::builder().CreateGEP(v, index.v, SSAScope::hint())); } -SSAVec4f SSAVec4fPtr::load() const +SSAVec4f SSAVec4fPtr::load(bool constantScopeDomain) const { - return SSAVec4f::from_llvm(SSAScope::builder().CreateLoad(v, false, SSAScope::hint())); + auto loadInst = SSAScope::builder().CreateLoad(v, false, SSAScope::hint()); + if (constantScopeDomain) + loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); + return SSAVec4f::from_llvm(loadInst); } -SSAVec4f SSAVec4fPtr::load_unaligned() const +SSAVec4f SSAVec4fPtr::load_unaligned(bool constantScopeDomain) const { - return SSAVec4f::from_llvm(SSAScope::builder().Insert(new llvm::LoadInst(v, SSAScope::hint(), false, 4), SSAScope::hint())); + auto loadInst = SSAScope::builder().CreateAlignedLoad(v, 4, false, SSAScope::hint()); + if (constantScopeDomain) + loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); + return SSAVec4f::from_llvm(loadInst); } void SSAVec4fPtr::store(const SSAVec4f &new_value) { - SSAScope::builder().CreateStore(new_value.v, v, false); + auto inst = SSAScope::builder().CreateStore(new_value.v, v, false); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } void SSAVec4fPtr::store_unaligned(const SSAVec4f &new_value) { - SSAScope::builder().CreateAlignedStore(new_value.v, v, 4, false); + auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, v, 4, false); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } diff --git a/src/r_compiler/ssa/ssa_vec4f_ptr.h b/src/r_compiler/ssa/ssa_vec4f_ptr.h index ab4e84190..15192352a 100644 --- a/src/r_compiler/ssa/ssa_vec4f_ptr.h +++ b/src/r_compiler/ssa/ssa_vec4f_ptr.h @@ -15,8 +15,8 @@ public: static SSAVec4fPtr from_llvm(llvm::Value *v) { return SSAVec4fPtr(v); } static llvm::Type *llvm_type(); SSAVec4fPtr operator[](SSAInt index) const; - SSAVec4f load() const; - SSAVec4f load_unaligned() const; + SSAVec4f load(bool constantScopeDomain) const; + SSAVec4f load_unaligned(bool constantScopeDomain) const; void store(const SSAVec4f &new_value); void store_unaligned(const SSAVec4f &new_value); From 1b7c42f45f9c9bf524d065505a758c023560a172 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 9 Oct 2016 06:17:48 +0200 Subject: [PATCH 1052/1509] Multisampling ssao bug fixes and split linear depth to its own buffer --- src/gl/renderer/gl_postprocess.cpp | 22 ++++++++++++------- src/gl/renderer/gl_renderbuffers.cpp | 26 ++++++++++++++--------- src/gl/renderer/gl_renderbuffers.h | 4 +++- src/gl/shaders/gl_ambientshader.cpp | 3 ++- src/gl/shaders/gl_ambientshader.h | 3 ++- wadsrc/static/shaders/glsl/lineardepth.fp | 19 ++++------------- wadsrc/static/shaders/glsl/ssao.fp | 23 ++++++++++---------- wadsrc/static/shaders/glsl/ssaocombine.fp | 3 ++- 8 files changed, 55 insertions(+), 48 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 97e2c3be9..dd8bccc8b 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -122,9 +122,14 @@ CUSTOM_CVAR(Int, gl_ssao_portals, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Float, gl_ssao_strength, 0.7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Int, gl_ssao_debug, 0, 0) -CVAR(Float, gl_ssao_bias, 0.5f, 0) -CVAR(Float, gl_ssao_radius, 100.0f, 0) -CUSTOM_CVAR(Float, gl_ssao_blur_amount, 16.0f, 0) +CVAR(Float, gl_ssao_bias, 0.2f, 0) +CVAR(Float, gl_ssao_radius, 80.0f, 0) +CUSTOM_CVAR(Float, gl_ssao_blur, 16.0f, 0) +{ + if (self < 0.1f) self = 0.1f; +} + +CUSTOM_CVAR(Float, gl_ssao_exponent, 1.8f, 0) { if (self < 0.1f) self = 0.1f; } @@ -166,7 +171,7 @@ void FGLRenderer::AmbientOccludeScene() float bias = gl_ssao_bias; float aoRadius = gl_ssao_radius; - const float blurAmount = gl_ssao_blur_amount; + const float blurAmount = gl_ssao_blur; float aoStrength = gl_ssao_strength; //float tanHalfFovy = tan(fovy * (M_PI / 360.0f)); @@ -186,7 +191,7 @@ void FGLRenderer::AmbientOccludeScene() int randomTexture = clamp(gl_ssao - 1, 0, FGLRenderBuffers::NumAmbientRandomTextures - 1); // Calculate linear depth values - glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB0); + glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->LinearDepthFB); glViewport(0, 0, mBuffers->AmbientWidth, mBuffers->AmbientHeight); mBuffers->BindSceneDepthTexture(0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -198,7 +203,7 @@ void FGLRenderer::AmbientOccludeScene() mLinearDepthShader->Bind(); mLinearDepthShader->DepthTexture.Set(0); mLinearDepthShader->ColorTexture.Set(1); - if (gl_multisample > 1) mLinearDepthShader->SampleCount.Set(gl_multisample); + if (gl_multisample > 1) mLinearDepthShader->SampleIndex.Set(0); mLinearDepthShader->LinearizeDepthA.Set(1.0f / GetZFar() - 1.0f / GetZNear()); mLinearDepthShader->LinearizeDepthB.Set(MAX(1.0f / GetZNear(), 1.e-8f)); mLinearDepthShader->InverseDepthRangeA.Set(1.0f); @@ -209,7 +214,7 @@ void FGLRenderer::AmbientOccludeScene() // Apply ambient occlusion glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB1); - glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientTexture0); + glBindTexture(GL_TEXTURE_2D, mBuffers->LinearDepthTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glActiveTexture(GL_TEXTURE1); @@ -226,6 +231,7 @@ void FGLRenderer::AmbientOccludeScene() mSSAOShader->DepthTexture.Set(0); mSSAOShader->RandomTexture.Set(1); mSSAOShader->NormalTexture.Set(2); + if (gl_multisample > 1) mSSAOShader->SampleIndex.Set(0); mSSAOShader->UVToViewA.Set(2.0f * invFocalLenX, 2.0f * invFocalLenY); mSSAOShader->UVToViewB.Set(-invFocalLenX, -invFocalLenY); mSSAOShader->InvFullResolution.Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); @@ -255,7 +261,7 @@ void FGLRenderer::AmbientOccludeScene() mDepthBlurShader->Bind(true); mDepthBlurShader->BlurSharpness[true].Set(blurSharpness); mDepthBlurShader->InvFullResolution[true].Set(1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight); - mDepthBlurShader->PowExponent[true].Set(1.8f); + mDepthBlurShader->PowExponent[true].Set(gl_ssao_exponent); RenderScreenQuad(); } diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index a24596562..b14ee9852 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -152,8 +152,10 @@ void FGLRenderBuffers::ClearEyeBuffers() void FGLRenderBuffers::ClearAmbientOcclusion() { + DeleteFrameBuffer(LinearDepthFB); DeleteFrameBuffer(AmbientFB0); DeleteFrameBuffer(AmbientFB1); + DeleteTexture(LinearDepthTexture); DeleteTexture(AmbientTexture0); DeleteTexture(AmbientTexture1); for (int i = 0; i < NumAmbientRandomTextures; i++) @@ -336,13 +338,13 @@ void FGLRenderBuffers::CreateBloom(int width, int height) if (width <= 0 || height <= 0) return; - int bloomWidth = MAX(width / 2, 1); - int bloomHeight = MAX(height / 2, 1); + int bloomWidth = (width + 1) / 2; + int bloomHeight = (height + 1) / 2; for (int i = 0; i < NumBloomLevels; i++) { auto &level = BloomLevels[i]; - level.Width = MAX(bloomWidth / 2, 1); - level.Height = MAX(bloomHeight / 2, 1); + level.Width = (bloomWidth + 1) / 2; + level.Height = (bloomHeight + 1) / 2; level.VTexture = Create2DTexture("Bloom.VTexture", GL_RGBA16F, level.Width, level.Height); level.HTexture = Create2DTexture("Bloom.HTexture", GL_RGBA16F, level.Width, level.Height); @@ -367,10 +369,12 @@ void FGLRenderBuffers::CreateAmbientOcclusion(int width, int height) if (width <= 0 || height <= 0) return; - AmbientWidth = width / 2; - AmbientHeight = height / 2; - AmbientTexture0 = Create2DTexture("AmbientTexture0", GL_RG32F, AmbientWidth, AmbientHeight); - AmbientTexture1 = Create2DTexture("AmbientTexture1", GL_RG32F, AmbientWidth, AmbientHeight); + AmbientWidth = (width + 1) / 2; + AmbientHeight = (height + 1) / 2; + LinearDepthTexture = Create2DTexture("LinearDepthTexture", GL_R32F, AmbientWidth, AmbientHeight); + AmbientTexture0 = Create2DTexture("AmbientTexture0", GL_RG16F, AmbientWidth, AmbientHeight); + AmbientTexture1 = Create2DTexture("AmbientTexture1", GL_RG16F, AmbientWidth, AmbientHeight); + LinearDepthFB = CreateFrameBuffer("LinearDepthFB", LinearDepthTexture); AmbientFB0 = CreateFrameBuffer("AmbientFB0", AmbientTexture0); AmbientFB1 = CreateFrameBuffer("AmbientFB1", AmbientTexture1); @@ -485,13 +489,15 @@ GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int case GL_RGBA16: dataformat = GL_RGBA; datatype = GL_UNSIGNED_SHORT; break; case GL_RGBA16F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; case GL_RGBA32F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; + case GL_RGBA16_SNORM: dataformat = GL_RGBA; datatype = GL_SHORT; break; case GL_R32F: dataformat = GL_RED; datatype = GL_FLOAT; break; + case GL_R16F: dataformat = GL_RED; datatype = GL_FLOAT; break; case GL_RG32F: dataformat = GL_RG; datatype = GL_FLOAT; break; + case GL_RG16F: dataformat = GL_RG; datatype = GL_FLOAT; break; case GL_RGB10_A2: dataformat = GL_RGBA; datatype = GL_UNSIGNED_INT_10_10_10_2; break; case GL_DEPTH_COMPONENT24: dataformat = GL_DEPTH_COMPONENT; datatype = GL_FLOAT; break; case GL_STENCIL_INDEX8: dataformat = GL_STENCIL_INDEX; datatype = GL_INT; break; case GL_DEPTH24_STENCIL8: dataformat = GL_DEPTH_STENCIL; datatype = GL_UNSIGNED_INT_24_8; break; - case GL_RGBA16_SNORM: dataformat = GL_RGBA; datatype = GL_SHORT; break; default: I_FatalError("Unknown format passed to FGLRenderBuffers.Create2DTexture"); } @@ -530,7 +536,7 @@ GLuint FGLRenderBuffers::CreateRenderBuffer(const FString &name, GLuint format, return handle; } -GLuint FGLRenderBuffers::CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height) +GLuint FGLRenderBuffers::CreateRenderBuffer(const FString &name, GLuint format, int width, int height, int samples) { if (samples <= 1) return CreateRenderBuffer(name, format, width, height); diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index d593b0248..efa61f3e2 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -59,6 +59,8 @@ public: bool FirstExposureFrame = true; // Ambient occlusion buffers + GLuint LinearDepthTexture = 0; + GLuint LinearDepthFB = 0; GLuint AmbientTexture0 = 0; GLuint AmbientTexture1 = 0; GLuint AmbientFB0 = 0; @@ -92,7 +94,7 @@ private: GLuint Create2DTexture(const FString &name, GLuint format, int width, int height, const void *data = nullptr); GLuint Create2DMultisampleTexture(const FString &name, GLuint format, int width, int height, int samples, bool fixedSampleLocations); GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height); - GLuint CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height); + GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height, int samples); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer0, GLuint colorbuffer1, GLuint colorbuffer2, GLuint depthstencil, bool multisample); diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index 0d08e1258..effde2496 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -47,7 +47,7 @@ void FLinearDepthShader::Bind() mShader->SetAttribLocation(0, "PositionInProjection"); DepthTexture.Init(*mShader, "DepthTexture"); ColorTexture.Init(*mShader, "ColorTexture"); - SampleCount.Init(*mShader, "SampleCount"); + SampleIndex.Init(*mShader, "SampleIndex"); LinearizeDepthA.Init(*mShader, "LinearizeDepthA"); LinearizeDepthB.Init(*mShader, "LinearizeDepthB"); InverseDepthRangeA.Init(*mShader, "InverseDepthRangeA"); @@ -86,6 +86,7 @@ void FSSAOShader::Bind() AOStrength.Init(*mShader, "AOStrength"); Scale.Init(*mShader, "Scale"); Offset.Init(*mShader, "Offset"); + SampleIndex.Init(*mShader, "SampleIndex"); mMultisample = multisample; } mShader->Bind(); diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index 95dfd6bac..d3310c3d6 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -10,7 +10,7 @@ public: FBufferedUniformSampler DepthTexture; FBufferedUniformSampler ColorTexture; - FBufferedUniform1i SampleCount; + FBufferedUniform1i SampleIndex; FBufferedUniform1f LinearizeDepthA; FBufferedUniform1f LinearizeDepthB; FBufferedUniform1f InverseDepthRangeA; @@ -41,6 +41,7 @@ public: FBufferedUniform1f AOStrength; FBufferedUniform2f Scale; FBufferedUniform2f Offset; + FBufferedUniform1i SampleIndex; private: enum Quality diff --git a/wadsrc/static/shaders/glsl/lineardepth.fp b/wadsrc/static/shaders/glsl/lineardepth.fp index fa71c9de0..3e2b3eb95 100644 --- a/wadsrc/static/shaders/glsl/lineardepth.fp +++ b/wadsrc/static/shaders/glsl/lineardepth.fp @@ -5,7 +5,7 @@ out vec4 FragColor; #if defined(MULTISAMPLE) uniform sampler2DMS DepthTexture; uniform sampler2DMS ColorTexture; -uniform int SampleCount; +uniform int SampleIndex; #else uniform sampler2D DepthTexture; uniform sampler2D ColorTexture; @@ -37,21 +37,10 @@ void main() ivec2 ipos = ivec2(max(uv * vec2(texSize), vec2(0.0))); #if defined(MULTISAMPLE) - float depth = normalizeDepth(texelFetch(ColorTexture, ipos, 0).a != 0.0 ? texelFetch(DepthTexture, ipos, 0).x : 1.0); - float sampleIndex = 0.0; - for (int i = 1; i < SampleCount; i++) - { - float hardwareDepth = texelFetch(ColorTexture, ipos, i).a != 0.0 ? texelFetch(DepthTexture, ipos, i).x : 1.0; - float sampleDepth = normalizeDepth(hardwareDepth); - if (sampleDepth < depth) - { - depth = sampleDepth; - sampleIndex = float(i); - } - } - FragColor = vec4(depth, sampleIndex, 0.0, 1.0); + float depth = normalizeDepth(texelFetch(ColorTexture, ipos, SampleIndex).a != 0.0 ? texelFetch(DepthTexture, ipos, SampleIndex).x : 1.0); #else float depth = normalizeDepth(texelFetch(ColorTexture, ipos, 0).a != 0.0 ? texelFetch(DepthTexture, ipos, 0).x : 1.0); - FragColor = vec4(depth, 0.0, 0.0, 1.0); #endif + + FragColor = vec4(depth, 0.0, 0.0, 1.0); } diff --git a/wadsrc/static/shaders/glsl/ssao.fp b/wadsrc/static/shaders/glsl/ssao.fp index f895ddc25..3b2db6005 100644 --- a/wadsrc/static/shaders/glsl/ssao.fp +++ b/wadsrc/static/shaders/glsl/ssao.fp @@ -20,6 +20,7 @@ uniform sampler2D DepthTexture; #if defined(MULTISAMPLE) uniform sampler2DMS NormalTexture; +uniform int SampleIndex; #else uniform sampler2D NormalTexture; #endif @@ -30,21 +31,22 @@ uniform sampler2D RandomTexture; #define PI 3.14159265358979323846 -// Calculate eye space position for the specified texture coordinate and depth -vec3 FetchViewPos(vec2 uv, float z) +// Calculate eye space position for the specified texture coordinate +vec3 FetchViewPos(vec2 uv) { + float z = texture(DepthTexture, uv).x; return vec3((UVToViewA * uv + UVToViewB) * z, z); } #if defined(MULTISAMPLE) -vec3 SampleNormal(vec2 uv, float samplerIndex) +vec3 SampleNormal(vec2 uv) { ivec2 texSize = textureSize(NormalTexture); ivec2 ipos = ivec2(uv * vec2(texSize)); - return texelFetch(NormalTexture, ipos, int(samplerIndex)).xyz * 2.0 - 1.0; + return texelFetch(NormalTexture, ipos, SampleIndex).xyz * 2.0 - 1.0; } #else -vec3 SampleNormal(vec2 uv, float samplerIndex) +vec3 SampleNormal(vec2 uv) { ivec2 texSize = textureSize(NormalTexture, 0); ivec2 ipos = ivec2(uv * vec2(texSize)); @@ -53,9 +55,9 @@ vec3 SampleNormal(vec2 uv, float samplerIndex) #endif // Look up the eye space normal for the specified texture coordinate -vec3 FetchNormal(vec2 uv, float samplerIndex) +vec3 FetchNormal(vec2 uv) { - vec3 normal = SampleNormal(Offset + uv * Scale, samplerIndex); + vec3 normal = SampleNormal(Offset + uv * Scale); if (length(normal) > 0.1) { normal = normalize(normal); @@ -116,7 +118,7 @@ float ComputeAO(vec3 viewPosition, vec3 viewNormal) for (float StepIndex = 0.0; StepIndex < NUM_STEPS; ++StepIndex) { vec2 sampleUV = round(rayPixels * direction) * InvFullResolution + TexCoord; - vec3 samplePos = FetchViewPos(sampleUV, texture(DepthTexture, sampleUV).x); + vec3 samplePos = FetchViewPos(sampleUV); ao += ComputeSampleAO(viewPosition, viewNormal, samplePos); rayPixels += stepSizePixels; } @@ -128,9 +130,8 @@ float ComputeAO(vec3 viewPosition, vec3 viewNormal) void main() { - vec2 depthData = texture(DepthTexture, TexCoord).xy; - vec3 viewPosition = FetchViewPos(TexCoord, depthData.x); - vec3 viewNormal = FetchNormal(TexCoord, depthData.y); + vec3 viewPosition = FetchViewPos(TexCoord); + vec3 viewNormal = FetchNormal(TexCoord); float occlusion = viewNormal != vec3(0.0) ? ComputeAO(viewPosition, viewNormal) * AOStrength + (1.0 - AOStrength) : 1.0; FragColor = vec4(occlusion, viewPosition.z, 0.0, 1.0); diff --git a/wadsrc/static/shaders/glsl/ssaocombine.fp b/wadsrc/static/shaders/glsl/ssaocombine.fp index 377516587..4ca64421b 100644 --- a/wadsrc/static/shaders/glsl/ssaocombine.fp +++ b/wadsrc/static/shaders/glsl/ssaocombine.fp @@ -17,12 +17,13 @@ uniform vec2 Offset; void main() { vec2 uv = Offset + TexCoord * Scale; + #if defined(MULTISAMPLE) ivec2 texSize = textureSize(SceneFogTexture); #else ivec2 texSize = textureSize(SceneFogTexture, 0); #endif - ivec2 ipos = ivec2(max(floor(uv * vec2(texSize) - 0.75), vec2(0.0))); + ivec2 ipos = ivec2(uv * vec2(texSize)); #if defined(MULTISAMPLE) vec3 fogColor = vec3(0.0); From 5f0088ab8b8885279407104093aed13e45cbfb0b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 9 Oct 2016 12:50:57 +0200 Subject: [PATCH 1053/1509] Created new OpenGL framebuffer using the software renderer's hardware acceleration --- src/CMakeLists.txt | 1 + src/gl/system/gl_swframebuffer.cpp | 3357 ++++++++++++++++++++++++++++ src/gl/system/gl_swframebuffer.h | 470 ++++ src/textures/textures.h | 1 + 4 files changed, 3829 insertions(+) create mode 100644 src/gl/system/gl_swframebuffer.cpp create mode 100644 src/gl/system/gl_swframebuffer.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de3316ced..dd241a3d7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1151,6 +1151,7 @@ set( FASTMATH_SOURCES gl/shaders/gl_fxaashader.cpp gl/system/gl_interface.cpp gl/system/gl_framebuffer.cpp + gl/system/gl_swframebuffer.cpp gl/system/gl_debug.cpp gl/system/gl_menu.cpp gl/system/gl_wipe.cpp diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp new file mode 100644 index 000000000..e0ff2be47 --- /dev/null +++ b/src/gl/system/gl_swframebuffer.cpp @@ -0,0 +1,3357 @@ +/* +** gl_swframebuffer.cpp +** Code to let ZDoom use OpenGL as a simple framebuffer +** +**--------------------------------------------------------------------------- +** Copyright 1998-2011 Randy Heit +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** This file does _not_ implement hardware-acclerated 3D rendering. It is +** just a means of getting the pixel data to the screen in a more reliable +** method on modern hardware by copying the entire frame to a texture, +** drawing that to the screen, and presenting. +** +** That said, it does implement hardware-accelerated 2D rendering. +*/ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "doomstat.h" +#include "m_png.h" +#include "m_crc32.h" +#include "vectors.h" +#include "v_palette.h" +#include "templates.h" + +#include "c_dispatch.h" +#include "templates.h" +#include "i_system.h" +#include "i_video.h" +#include "i_input.h" +#include "v_pfx.h" +#include "stats.h" +#include "doomerrors.h" +#include "r_main.h" +#include "r_data/r_translate.h" +#include "f_wipe.h" +#include "sbar.h" +#include "w_wad.h" +#include "r_data/colormaps.h" + +#include "gl/system/gl_interface.h" +#include "gl/system/gl_swframebuffer.h" +#include "gl/data/gl_data.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_templates.h" +#include "gl/gl_functions.h" + +CVAR(Bool, gl_antilag, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Int, gl_showpacks, 0, 0) +#ifndef WIN32 // Defined in fb_d3d9 for Windows +CVAR(Bool, vid_hwaalines, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +#else +EXTERN_CVAR(Bool, vid_hwaalines) +#endif + +EXTERN_CVAR(Bool, vid_hw2d) +EXTERN_CVAR(Bool, fullscreen) +EXTERN_CVAR(Float, Gamma) +EXTERN_CVAR(Bool, vid_vsync) +EXTERN_CVAR(Float, transsouls) +EXTERN_CVAR(Int, vid_refreshrate) + +extern cycle_t BlitCycles; + +IMPLEMENT_CLASS(OpenGLSWFrameBuffer) + +const char *const OpenGLSWFrameBuffer::ShaderNames[OpenGLSWFrameBuffer::NUM_SHADERS] = +{ + "NormalColor.fp", + "NormalColorPal.fp", + "NormalColorInv.fp", + "NormalColorPalInv.fp", + + "RedToAlpha.fp", + "RedToAlphaInv.fp", + + "VertexColor.fp", + + "SpecialColormap.fp", + "SpecialColorMapPal.fp", + + "InGameColormap.fp", + "InGameColormapDesat.fp", + "InGameColormapInv.fp", + "InGameColormapInvDesat.fp", + "InGameColormapPal.fp", + "InGameColormapPalDesat.fp", + "InGameColormapPalInv.fp", + "InGameColormapPalInvDesat.fp", + + "BurnWipe.fp", + "GammaCorrection.fp", +}; + +OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : + Super(hMonitor, width, height, bits, refreshHz, fullscreen) +{ + // SetVSync needs to be at the very top to workaround a bug in Nvidia's OpenGL driver. + // If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed! + SetVSync(vid_vsync); + + VertexBuffer = nullptr; + IndexBuffer = nullptr; + FBTexture = nullptr; + TempRenderTexture = nullptr; + RenderTexture[0] = nullptr; + RenderTexture[1] = nullptr; + InitialWipeScreen = nullptr; + ScreenshotTexture = nullptr; + ScreenshotSurface = nullptr; + FinalWipeScreen = nullptr; + PaletteTexture = nullptr; + GammaTexture = nullptr; + FrontCopySurface = nullptr; + for (int i = 0; i < NUM_SHADERS; ++i) + { + Shaders[i] = nullptr; + } + GammaShader = nullptr; + BlockSurface[0] = nullptr; + BlockSurface[1] = nullptr; + VSync = vid_vsync; + BlendingRect.left = 0; + BlendingRect.top = 0; + BlendingRect.right = FBWidth; + BlendingRect.bottom = FBHeight; + In2D = 0; + Palettes = nullptr; + Textures = nullptr; + Accel2D = true; + GatheringWipeScreen = false; + ScreenWipe = nullptr; + InScene = false; + QuadExtra = new BufferedTris[MAX_QUAD_BATCH]; + Atlases = nullptr; + PixelDoubling = 0; + SkipAt = -1; + CurrRenderTexture = 0; + RenderTextureToggle = 0; + + Gamma = 1.0; + FlashColor0 = 0; + FlashColor1 = 0xFFFFFFFF; + FlashColor = 0; + FlashAmount = 0; + + NeedGammaUpdate = false; + NeedPalUpdate = false; + + if (MemBuffer == nullptr) + { + return; + } + + memcpy(SourcePalette, GPalette.BaseColors, sizeof(PalEntry) * 256); + + Windowed = !(static_cast(Video)->GoFullscreen(fullscreen)); + + TrueHeight = height; + /*if (fullscreen) + { + for (Win32Video::ModeInfo *mode = static_cast(Video)->m_Modes; mode != nullptr; mode = mode->next) + { + if (mode->width == Width && mode->height == Height) + { + TrueHeight = mode->realheight; + PixelDoubling = mode->doubling; + break; + } + } + }*/ + // Offset from top of screen to top of letterboxed screen + LBOffsetI = (TrueHeight - Height) / 2; + LBOffset = float(LBOffsetI); + + CreateResources(); + SetInitialState(); +} + +OpenGLSWFrameBuffer::~OpenGLSWFrameBuffer() +{ + ReleaseResources(); + delete[] QuadExtra; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: SetInitialState +// +// Called after initial device creation and reset, when everything is set +// to OpenGL's defaults. +// +//========================================================================== + +void OpenGLSWFrameBuffer::SetInitialState() +{ + AlphaBlendEnabled = FALSE; + AlphaBlendOp = GL_FUNC_ADD; + AlphaSrcBlend = 0; + AlphaDestBlend = 0; + + CurPixelShader = nullptr; + memset(Constant, 0, sizeof(Constant)); + + for (unsigned i = 0; i < countof(Texture); ++i) + { + Texture[i] = nullptr; + SamplerWrapS[i] = GL_CLAMP_TO_EDGE; + SamplerWrapT[i] = GL_CLAMP_TO_EDGE; + } + + NeedGammaUpdate = true; + NeedPalUpdate = true; + OldRenderTarget = nullptr; + + // This constant is used for grayscaling weights (.xyz) and color inversion (.w) + float weights[4] = { 77 / 256.f, 143 / 256.f, 37 / 256.f, 1 }; + SetPixelShaderConstantF(PSCONST_Weights, weights, 1); + + AlphaTestEnabled = FALSE; + + CurBorderColor = 0; + + // Clear to black, just in case it wasn't done already. + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: CreateResources +// +//========================================================================== + +bool OpenGLSWFrameBuffer::CreateResources() +{ + Atlases = nullptr; + if (!LoadShaders()) + { + return false; + } + if (!CreateFBTexture() || + !CreatePaletteTexture()) + { + return false; + } + if (!CreateVertexes()) + { + return false; + } + CreateGammaTexture(); + CreateBlockSurfaces(); + return true; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: LoadShaders +// +// Returns true if all required shaders were loaded. (Gamma and burn wipe +// are the only ones not considered "required".) +// +//========================================================================== + +bool OpenGLSWFrameBuffer::LoadShaders() +{ + static const char models[][4] = { "30/", "20/", "14/" }; + FString shaderdir, shaderpath; + unsigned model, i; + int lump; + + // We determine the best available model simply by trying them all in + // order of decreasing preference. + for (model = 0; model < countof(models); ++model) + { + shaderdir = "shaders/gl/sm"; + shaderdir += models[model]; + for (i = 0; i < NUM_SHADERS; ++i) + { + shaderpath = shaderdir; + shaderpath += ShaderNames[i]; + lump = Wads.CheckNumForFullName(shaderpath); + if (lump >= 0) + { + FMemLump data = Wads.ReadLump(lump); + if (!CreatePixelShader((uint32_t *)data.GetMem(), &Shaders[i]) && i < SHADER_BurnWipe) + { + break; + } + } + } + if (i == NUM_SHADERS) + { // Success! + return true; + } + // Failure. Release whatever managed to load (which is probably nothing.) + for (i = 0; i < NUM_SHADERS; ++i) + { + SafeRelease(Shaders[i]); + } + } + return false; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: ReleaseResources +// +//========================================================================== + +void OpenGLSWFrameBuffer::ReleaseResources() +{ + I_SaveWindowedPos(); + KillNativeTexs(); + KillNativePals(); + ReleaseDefaultPoolItems(); + SafeRelease(ScreenshotSurface); + SafeRelease(ScreenshotTexture); + SafeRelease(PaletteTexture); + for (int i = 0; i < NUM_SHADERS; ++i) + { + SafeRelease(Shaders[i]); + } + GammaShader = nullptr; + if (ScreenWipe != nullptr) + { + delete ScreenWipe; + ScreenWipe = nullptr; + } + Atlas *pack, *next; + for (pack = Atlases; pack != nullptr; pack = next) + { + next = pack->Next; + delete pack; + } + GatheringWipeScreen = false; +} + +void OpenGLSWFrameBuffer::ReleaseDefaultPoolItems() +{ + SafeRelease(FBTexture); + SafeRelease(FinalWipeScreen); + SafeRelease(RenderTexture[0]); + SafeRelease(RenderTexture[1]); + SafeRelease(InitialWipeScreen); + SafeRelease(VertexBuffer); + SafeRelease(IndexBuffer); + SafeRelease(BlockSurface[0]); + SafeRelease(BlockSurface[1]); + SafeRelease(FrontCopySurface); +} + +bool OpenGLSWFrameBuffer::Reset() +{ + ReleaseDefaultPoolItems(); + if (!CreateFBTexture() || !CreateVertexes()) + { + return false; + } + CreateBlockSurfaces(); + SetInitialState(); + return true; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: CreateBlockSurfaces +// +// Create blocking surfaces for antilag. It's okay if these can't be +// created; antilag just won't work. +// +//========================================================================== + +void OpenGLSWFrameBuffer::CreateBlockSurfaces() +{ + BlockNum = 0; + if (CreateOffscreenPlainSurface(16, 16, GL_RGBA8, &BlockSurface[0])) + { + if (!CreateOffscreenPlainSurface(16, 16, GL_RGBA8, &BlockSurface[1])) + { + SafeRelease(BlockSurface[0]); + } + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: KillNativePals +// +// Frees all native palettes. +// +//========================================================================== + +void OpenGLSWFrameBuffer::KillNativePals() +{ + while (Palettes != nullptr) + { + delete Palettes; + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: KillNativeTexs +// +// Frees all native textures. +// +//========================================================================== + +void OpenGLSWFrameBuffer::KillNativeTexs() +{ + while (Textures != nullptr) + { + delete Textures; + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: CreateFBTexture +// +// Creates the "Framebuffer" texture. With the advent of hardware-assisted +// 2D, this is something of a misnomer now. The FBTexture is only used for +// uploading the software 3D image to video memory so that it can be drawn +// to the real frame buffer. +// +// It also creates the TempRenderTexture, since this seemed like a +// convenient place to do so. +// +//========================================================================== + +bool OpenGLSWFrameBuffer::CreateFBTexture() +{ + if (!CreateTexture(Width, Height, 1, GL_R8, &FBTexture)) + { + int pow2width, pow2height, i; + + for (i = 1; i < Width; i <<= 1) {} pow2width = i; + for (i = 1; i < Height; i <<= 1) {} pow2height = i; + + if (!CreateTexture(pow2width, pow2height, 1, GL_R8, &FBTexture)) + { + return false; + } + else + { + FBWidth = pow2width; + FBHeight = pow2height; + } + } + else + { + FBWidth = Width; + FBHeight = Height; + } + RenderTextureToggle = 0; + RenderTexture[0] = nullptr; + RenderTexture[1] = nullptr; + if (!CreateTexture(FBWidth, FBHeight, 1, GL_RGBA8, &RenderTexture[0])) + { + return false; + } + if (Windowed || PixelDoubling) + { + // Windowed or pixel doubling: Create another render texture so we can flip between them. + RenderTextureToggle = 1; + if (!CreateTexture(FBWidth, FBHeight, 1, GL_RGBA8, &RenderTexture[1])) + { + return false; + } + } + else + { + // Fullscreen and not pixel doubling: Create a render target to have the back buffer copied to. + if (!CreateRenderTarget(Width, Height, GL_RGBA8, &FrontCopySurface)) + { + return false; + } + } + // Initialize the TempRenderTextures to black. + for (int i = 0; i <= RenderTextureToggle; ++i) + { + HWSurface *surf; + if (RenderTexture[i]->GetSurfaceLevel(0, &surf)) + { + ColorFill(surf, 0.0f, 0.0f, 0.0f); + delete surf; + } + } + TempRenderTexture = RenderTexture[0]; + CurrRenderTexture = 0; + return true; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: CreatePaletteTexture +// +//========================================================================== + +bool OpenGLSWFrameBuffer::CreatePaletteTexture() +{ + if (!CreateTexture(256, 1, 1, GL_RGBA8, &PaletteTexture)) + { + return false; + } + return true; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: CreateGammaTexture +// +//========================================================================== + +bool OpenGLSWFrameBuffer::CreateGammaTexture() +{ + return false; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: CreateVertexes +// +//========================================================================== + +bool OpenGLSWFrameBuffer::CreateVertexes() +{ + VertexPos = -1; + IndexPos = -1; + QuadBatchPos = -1; + BatchType = BATCH_None; + if (!CreateVertexBuffer(sizeof(FBVERTEX)*NUM_VERTS, &VertexBuffer)) + { + return false; + } + if (!CreateIndexBuffer(sizeof(uint16_t)*NUM_INDEXES, &IndexBuffer)) + { + return false; + } + return true; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: CalcFullscreenCoords +// +//========================================================================== + +void OpenGLSWFrameBuffer::CalcFullscreenCoords(FBVERTEX verts[4], bool viewarea_only, bool can_double, uint32_t color0, uint32_t color1) const +{ + float offset = OldRenderTarget != nullptr ? 0 : LBOffset; + float top = offset - 0.5f; + float texright = float(Width) / float(FBWidth); + float texbot = float(Height) / float(FBHeight); + float mxl, mxr, myt, myb, tmxl, tmxr, tmyt, tmyb; + + if (viewarea_only) + { // Just calculate vertices for the viewarea/BlendingRect + mxl = float(BlendingRect.left) - 0.5f; + mxr = float(BlendingRect.right) - 0.5f; + myt = float(BlendingRect.top) + top; + myb = float(BlendingRect.bottom) + top; + tmxl = float(BlendingRect.left) / float(Width) * texright; + tmxr = float(BlendingRect.right) / float(Width) * texright; + tmyt = float(BlendingRect.top) / float(Height) * texbot; + tmyb = float(BlendingRect.bottom) / float(Height) * texbot; + } + else + { // Calculate vertices for the whole screen + mxl = -0.5f; + mxr = float(Width << (can_double ? PixelDoubling : 0)) - 0.5f; + myt = top; + myb = float(Height << (can_double ? PixelDoubling : 0)) + top; + tmxl = 0; + tmxr = texright; + tmyt = 0; + tmyb = texbot; + } + + //{ mxl, myt, 0, 1, 0, 0xFFFFFFFF, tmxl, tmyt }, + //{ mxr, myt, 0, 1, 0, 0xFFFFFFFF, tmxr, tmyt }, + //{ mxr, myb, 0, 1, 0, 0xFFFFFFFF, tmxr, tmyb }, + //{ mxl, myb, 0, 1, 0, 0xFFFFFFFF, tmxl, tmyb }, + + verts[0].x = mxl; + verts[0].y = myt; + verts[0].z = 0; + verts[0].rhw = 1; + verts[0].color0 = color0; + verts[0].color1 = color1; + verts[0].tu = tmxl; + verts[0].tv = tmyt; + + verts[1].x = mxr; + verts[1].y = myt; + verts[1].z = 0; + verts[1].rhw = 1; + verts[1].color0 = color0; + verts[1].color1 = color1; + verts[1].tu = tmxr; + verts[1].tv = tmyt; + + verts[2].x = mxr; + verts[2].y = myb; + verts[2].z = 0; + verts[2].rhw = 1; + verts[2].color0 = color0; + verts[2].color1 = color1; + verts[2].tu = tmxr; + verts[2].tv = tmyb; + + verts[3].x = mxl; + verts[3].y = myb; + verts[3].z = 0; + verts[3].rhw = 1; + verts[3].color0 = color0; + verts[3].color1 = color1; + verts[3].tu = tmxl; + verts[3].tv = tmyb; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: GetPageCount +// +//========================================================================== + +int OpenGLSWFrameBuffer::GetPageCount() +{ + return 1; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: PaletteChanged +// +//========================================================================== + +void OpenGLSWFrameBuffer::PaletteChanged() +{ +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: QueryNewPalette +// +//========================================================================== + +int OpenGLSWFrameBuffer::QueryNewPalette() +{ + return 0; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: IsValid +// +//========================================================================== + +bool OpenGLSWFrameBuffer::IsValid() +{ + return true; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: IsFullscreen +// +//========================================================================== + +bool OpenGLSWFrameBuffer::IsFullscreen() +{ + return !Windowed; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Lock +// +//========================================================================== + +bool OpenGLSWFrameBuffer::Lock(bool buffered) +{ + if (LockCount++ > 0) + { + return false; + } + assert(!In2D); + Accel2D = vid_hw2d; + Buffer = MemBuffer; + return false; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Unlock +// +//========================================================================== + +void OpenGLSWFrameBuffer::Unlock() +{ + LOG1("Unlock <%d>\n", LockCount); + + if (LockCount == 0) + { + return; + } + + if (UpdatePending && LockCount == 1) + { + Update(); + } + else if (--LockCount == 0) + { + Buffer = nullptr; + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Update +// +// When In2D == 0: Copy buffer to screen and present +// When In2D == 1: Copy buffer to screen but do not present +// When In2D == 2: Set up for 2D drawing but do not draw anything +// When In2D == 3: Present and set In2D to 0 +// +//========================================================================== + +void OpenGLSWFrameBuffer::Update() +{ + if (In2D == 3) + { + if (InScene) + { + DrawRateStuff(); + DrawPackedTextures(gl_showpacks); + EndBatch(); // Make sure all batched primitives are drawn. + Flip(); + } + In2D = 0; + return; + } + + if (LockCount != 1) + { + I_FatalError("Framebuffer must have exactly 1 lock to be updated"); + if (LockCount > 0) + { + UpdatePending = true; + --LockCount; + } + return; + } + + if (In2D == 0) + { + DrawRateStuff(); + } + + if (NeedGammaUpdate) + { + float psgamma[4]; + float igamma; + + NeedGammaUpdate = false; + igamma = 1 / Gamma; + if (!Windowed) + { + GammaRamp ramp; + + for (int i = 0; i < 256; ++i) + { + ramp.blue[i] = ramp.green[i] = ramp.red[i] = uint16_t(65535.f * powf(i / 255.f, igamma)); + } + LOG("SetGammaRamp\n"); + SetGammaRamp(&ramp); + } + else + { + if (igamma != 1) + { + UpdateGammaTexture(igamma); + GammaShader = Shaders[SHADER_GammaCorrection]; + } + else + { + GammaShader = nullptr; + } + } + psgamma[2] = psgamma[1] = psgamma[0] = igamma; + psgamma[3] = 0.5; // For SM14 version + SetPixelShaderConstantF(PSCONST_Gamma, psgamma, 1); + } + + if (NeedPalUpdate) + { + UploadPalette(); + } + + BlitCycles.Reset(); + BlitCycles.Clock(); + + LockCount = 0; + Draw3DPart(In2D <= 1); + if (In2D == 0) + { + Flip(); + } + + BlitCycles.Unclock(); + //LOG1 ("cycles = %d\n", BlitCycles); + + Buffer = nullptr; + UpdatePending = false; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Flip +// +//========================================================================== + +void OpenGLSWFrameBuffer::Flip() +{ + assert(InScene); + + DrawLetterbox(); + DoWindowedGamma(); + + CopyNextFrontBuffer(); + + // Attempt to counter input lag. + if (gl_antilag && BlockSurface[0] != nullptr) + { + LockedRect lr; + volatile int dummy; + ColorFill(BlockSurface[BlockNum], 0.0f, 0x20/255.0f, 0x50/255.0f); + BlockNum ^= 1; + if (BlockSurface[BlockNum]->LockRect(&lr, nullptr, false)) + { + dummy = *(int *)lr.pBits; + BlockSurface[BlockNum]->UnlockRect(); + } + } + // Limiting the frame rate is as simple as waiting for the timer to signal this event. + if (FPSLimitEvent != nullptr) + { + WaitForSingleObject(FPSLimitEvent, 1000); + } + Present(); + InScene = false; + + if (RenderTextureToggle) + { + // Flip the TempRenderTexture to the other one now. + CurrRenderTexture ^= RenderTextureToggle; + TempRenderTexture = RenderTexture[CurrRenderTexture]; + } + + if (Windowed) + { + int clientWidth = GetClientWidth(); + int clientHeight = GetClientHeight(); + if (clientWidth > 0 && clientHeight > 0 && (Width != clientWidth || Height != clientHeight)) + { + Resize(clientWidth, clientHeight); + + TrueHeight = Height; + PixelDoubling = 0; + LBOffsetI = 0; + LBOffset = 0.0f; + Reset(); + + V_OutputResized(Width, Height); + } + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: CopyNextFrontBuffer +// +// Duplicates the contents of the back buffer that will become the front +// buffer upon Present into FrontCopySurface so that we can get the +// contents of the display without wasting time in GetFrontBufferData(). +// +//========================================================================== + +void OpenGLSWFrameBuffer::CopyNextFrontBuffer() +{ + HWSurface *backbuff; + + if (Windowed || PixelDoubling) + { + // Windowed mode or pixel doubling: TempRenderTexture has what we want + SafeRelease(FrontCopySurface); + if (TempRenderTexture->GetSurfaceLevel(0, &backbuff)) + { + FrontCopySurface = backbuff; + } + } + else + { + // Fullscreen, not pixel doubled: The back buffer has what we want, + // but it might be letter boxed. + if (GetBackBuffer(&backbuff)) + { + LTRBRect srcrect = { 0, LBOffsetI, Width, LBOffsetI + Height }; + StretchRect(backbuff, &srcrect, FrontCopySurface); + delete backbuff; + } + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: PaintToWindow +// +//========================================================================== + +bool OpenGLSWFrameBuffer::PaintToWindow() +{ + if (LockCount != 0) + { + return false; + } + Draw3DPart(true); + return true; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Draw3DPart +// +// The software 3D part, to be exact. +// +//========================================================================== + +void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) +{ + if (copy3d) + { + LTRBRect texrect = { 0, 0, Width, Height }; + LockedRect lockrect; + + if ((FBWidth == Width && FBHeight == Height && + FBTexture->LockRect(&lockrect, nullptr, true)) || + FBTexture->LockRect(&lockrect, &texrect, false)) + { + if (lockrect.Pitch == Pitch && Pitch == Width) + { + memcpy(lockrect.pBits, MemBuffer, Width * Height); + } + else + { + uint8_t *dest = (uint8_t *)lockrect.pBits; + uint8_t *src = MemBuffer; + for (int y = 0; y < Height; y++) + { + memcpy(dest, src, Width); + dest += lockrect.Pitch; + src += Pitch; + } + } + FBTexture->UnlockRect(); + } + } + InScene = true; + if (vid_hwaalines) + glEnable(GL_LINE_SMOOTH); + else + glDisable(GL_LINE_SMOOTH); + assert(OldRenderTarget == nullptr); + if (TempRenderTexture != nullptr && + ((Windowed && TempRenderTexture != FinalWipeScreen) || GatheringWipeScreen || PixelDoubling)) + { + HWSurface *targetsurf; + if (TempRenderTexture->GetSurfaceLevel(0, &targetsurf)) + { + if (GetRenderTarget(0, &OldRenderTarget)) + { + SetRenderTarget(0, targetsurf); + } + delete targetsurf; + } + } + + SetTexture(0, FBTexture); + SetPaletteTexture(PaletteTexture, 256, BorderColor); + memset(Constant, 0, sizeof(Constant)); + SetAlphaBlend(0); + EnableAlphaTest(FALSE); + SetPixelShader(Shaders[SHADER_NormalColorPal]); + if (copy3d) + { + FBVERTEX verts[4]; + uint32_t color0, color1; + if (Accel2D) + { + if (realfixedcolormap == nullptr) + { + color0 = 0; + color1 = 0xFFFFFFF; + } + else + { + color0 = ColorValue(realfixedcolormap->ColorizeStart[0] / 2, + realfixedcolormap->ColorizeStart[1] / 2, realfixedcolormap->ColorizeStart[2] / 2, 0); + color1 = ColorValue(realfixedcolormap->ColorizeEnd[0] / 2, + realfixedcolormap->ColorizeEnd[1] / 2, realfixedcolormap->ColorizeEnd[2] / 2, 1); + SetPixelShader(Shaders[SHADER_SpecialColormapPal]); + } + } + else + { + color0 = FlashColor0; + color1 = FlashColor1; + } + CalcFullscreenCoords(verts, Accel2D, false, color0, color1); + DrawTriangleFans(2, verts); + } + SetPixelShader(Shaders[SHADER_NormalColorPal]); +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: DrawLetterbox +// +// Draws the black bars at the top and bottom of the screen for letterboxed +// modes. +// +//========================================================================== + +void OpenGLSWFrameBuffer::DrawLetterbox() +{ + if (LBOffsetI != 0) + { + glEnable(GL_SCISSOR_TEST); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glScissor(0, 0, Width, LBOffsetI); + glClear(GL_COLOR_BUFFER_BIT); + glScissor(0, Height + LBOffsetI, Width, TrueHeight - Height + LBOffsetI); + glClear(GL_COLOR_BUFFER_BIT); + glDisable(GL_SCISSOR_TEST); + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: DoWindowedGamma +// +// Draws the render target texture to the real back buffer using a gamma- +// correcting pixel shader. +// +//========================================================================== + +void OpenGLSWFrameBuffer::DoWindowedGamma() +{ + if (OldRenderTarget != nullptr) + { + FBVERTEX verts[4]; + + CalcFullscreenCoords(verts, false, true, 0, 0xFFFFFFFF); + SetRenderTarget(0, OldRenderTarget); + SetTexture(0, TempRenderTexture); + SetPixelShader(Windowed && GammaShader ? GammaShader : Shaders[SHADER_NormalColor]); + SetAlphaBlend(0); + EnableAlphaTest(FALSE); + DrawTriangleFans(2, verts); + delete OldRenderTarget; + OldRenderTarget = nullptr; + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: UpdateGammaTexture +// +// Updates the gamma texture used by the PS14 shader. We only use the first +// half of the texture so that we needn't worry about imprecision causing +// it to grab from the border. +// +//========================================================================== + +void OpenGLSWFrameBuffer::UpdateGammaTexture(float igamma) +{ + LockedRect lockrect; + + if (GammaTexture != nullptr && GammaTexture->LockRect(&lockrect, nullptr, false)) + { + uint8_t *pix = (uint8_t *)lockrect.pBits; + for (int i = 0; i <= 128; ++i) + { + pix[i * 4 + 2] = pix[i * 4 + 1] = pix[i * 4] = uint8_t(255.f * powf(i / 128.f, igamma)); + pix[i * 4 + 3] = 255; + } + GammaTexture->UnlockRect(); + } +} + +void OpenGLSWFrameBuffer::UploadPalette() +{ + LockedRect lockrect; + + if (SkipAt < 0) + { + SkipAt = 256; + } + if (PaletteTexture->LockRect(&lockrect, nullptr, false)) + { + uint8_t *pix = (uint8_t *)lockrect.pBits; + int i; + + for (i = 0; i < SkipAt; ++i, pix += 4) + { + pix[0] = SourcePalette[i].b; + pix[1] = SourcePalette[i].g; + pix[2] = SourcePalette[i].r; + pix[3] = (i == 0 ? 0 : 255); + // To let masked textures work, the first palette entry's alpha is 0. + } + pix += 4; + for (; i < 255; ++i, pix += 4) + { + pix[0] = SourcePalette[i].b; + pix[1] = SourcePalette[i].g; + pix[2] = SourcePalette[i].r; + pix[3] = 255; + } + PaletteTexture->UnlockRect(); + BorderColor = ColorXRGB(SourcePalette[255].r, SourcePalette[255].g, SourcePalette[255].b); + } +} + +PalEntry *OpenGLSWFrameBuffer::GetPalette() +{ + return SourcePalette; +} + +void OpenGLSWFrameBuffer::UpdatePalette() +{ + NeedPalUpdate = true; +} + +bool OpenGLSWFrameBuffer::SetGamma(float gamma) +{ + LOG1("SetGamma %g\n", gamma); + Gamma = gamma; + NeedGammaUpdate = true; + return true; +} + +bool OpenGLSWFrameBuffer::SetFlash(PalEntry rgb, int amount) +{ + FlashColor = rgb; + FlashAmount = amount; + + // Fill in the constants for the pixel shader to do linear interpolation between the palette and the flash: + float r = rgb.r / 255.f, g = rgb.g / 255.f, b = rgb.b / 255.f, a = amount / 256.f; + FlashColor0 = ColorValue(r * a, g * a, b * a, 0); + a = 1 - a; + FlashColor1 = ColorValue(a, a, a, 1); + return true; +} + +void OpenGLSWFrameBuffer::GetFlash(PalEntry &rgb, int &amount) +{ + rgb = FlashColor; + amount = FlashAmount; +} + +void OpenGLSWFrameBuffer::GetFlashedPalette(PalEntry pal[256]) +{ + memcpy(pal, SourcePalette, 256 * sizeof(PalEntry)); + if (FlashAmount) + { + DoBlending(pal, pal, 256, FlashColor.r, FlashColor.g, FlashColor.b, FlashAmount); + } +} + +void OpenGLSWFrameBuffer::SetVSync(bool vsync) +{ + if (VSync != vsync) + { + VSync = vsync; + Reset(); + } +} + +void OpenGLSWFrameBuffer::NewRefreshRate() +{ + if (!Windowed) + { + Reset(); + } +} + +void OpenGLSWFrameBuffer::Blank() +{ +} + +void OpenGLSWFrameBuffer::SetBlendingRect(int x1, int y1, int x2, int y2) +{ + BlendingRect.left = x1; + BlendingRect.top = y1; + BlendingRect.right = x2; + BlendingRect.bottom = y2; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: GetScreenshotBuffer +// +// Returns a pointer into a surface holding the current screen data. +// +//========================================================================== + +void OpenGLSWFrameBuffer::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &color_type) +{ + LockedRect lrect; + + if (!Accel2D) + { + Super::GetScreenshotBuffer(buffer, pitch, color_type); + return; + } + buffer = nullptr; + if ((ScreenshotTexture = GetCurrentScreen()) != nullptr) + { + if (!ScreenshotTexture->GetSurfaceLevel(0, &ScreenshotSurface)) + { + delete ScreenshotTexture; + ScreenshotTexture = nullptr; + } + else if (!ScreenshotSurface->LockRect(&lrect, nullptr, false)) + { + delete ScreenshotSurface; + ScreenshotSurface = nullptr; + delete ScreenshotTexture; + ScreenshotTexture = nullptr; + } + else + { + buffer = (const uint8_t *)lrect.pBits; + pitch = lrect.Pitch; + color_type = SS_BGRA; + } + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: ReleaseScreenshotBuffer +// +//========================================================================== + +void OpenGLSWFrameBuffer::ReleaseScreenshotBuffer() +{ + if (LockCount > 0) + { + Super::ReleaseScreenshotBuffer(); + } + if (ScreenshotSurface != nullptr) + { + ScreenshotSurface->UnlockRect(); + delete ScreenshotSurface; + ScreenshotSurface = nullptr; + } + SafeRelease(ScreenshotTexture); +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: GetCurrentScreen +// +// Returns a texture containing the pixels currently visible on-screen. +// +//========================================================================== + +OpenGLSWFrameBuffer::HWTexture *OpenGLSWFrameBuffer::GetCurrentScreen() +{ + HWTexture *tex; + HWSurface *surf; + bool hr; + + if (FrontCopySurface == nullptr) + { + return nullptr; + } + + hr = CreateTexture(FBWidth, FBHeight, 1, GL_RGBA8, &tex); + + if (!hr) + { + return nullptr; + } + if (!tex->GetSurfaceLevel(0, &surf)) + { + delete tex; + return nullptr; + } + + // Video -> System memory : use GetRenderTargetData + GetRenderTargetData(FrontCopySurface, surf); + delete surf; + + if (!hr) + { + delete tex; + return nullptr; + } + return tex; +} + +/**************************************************************************/ +/* 2D Stuff */ +/**************************************************************************/ + +//========================================================================== +// +// OpenGLSWFrameBuffer :: DrawPackedTextures +// +// DEBUG: Draws the texture atlases to the screen, starting with the +// 1-based packnum. Ignores atlases that are flagged for use by one +// texture only. +// +//========================================================================== + +void OpenGLSWFrameBuffer::DrawPackedTextures(int packnum) +{ + uint32_t empty_colors[8] = + { + 0x50FF0000, 0x5000FF00, 0x500000FF, 0x50FFFF00, + 0x50FF00FF, 0x5000FFFF, 0x50FF8000, 0x500080FF + }; + Atlas *pack; + int x = 8, y = 8; + + if (packnum <= 0) + { + return; + } + pack = Atlases; + // Find the first texture atlas that is an actual atlas. + while (pack != nullptr && pack->OneUse) + { // Skip textures that aren't used as atlases + pack = pack->Next; + } + // Skip however many atlases we would have otherwise drawn + // until we've skipped of them. + while (pack != nullptr && packnum != 1) + { + if (!pack->OneUse) + { // Skip textures that aren't used as atlases + packnum--; + } + pack = pack->Next; + } + // Draw atlases until we run out of room on the screen. + while (pack != nullptr) + { + if (pack->OneUse) + { // Skip textures that aren't used as atlases + pack = pack->Next; + continue; + } + + AddColorOnlyRect(x - 1, y - 1 - LBOffsetI, 258, 258, ColorXRGB(255, 255, 0)); + int back = 0; + for (PackedTexture *box = pack->UsedList; box != nullptr; box = box->Next) + { + AddColorOnlyQuad( + x + box->Area.left * 256 / pack->Width, + y + box->Area.top * 256 / pack->Height, + (box->Area.right - box->Area.left) * 256 / pack->Width, + (box->Area.bottom - box->Area.top) * 256 / pack->Height, empty_colors[back]); + back = (back + 1) & 7; + } + // AddColorOnlyQuad(x, y-LBOffsetI, 256, 256, ColorARGB(180,0,0,0)); + + CheckQuadBatch(); + + BufferedTris *quad = &QuadExtra[QuadBatchPos]; + FBVERTEX *vert = &VertexData[VertexPos]; + + quad->Group1 = 0; + if (pack->Format == GL_R8/* && !tex->IsGray*/) + { + quad->Flags = BQF_WrapUV | BQF_GamePalette/* | BQF_DisableAlphaTest*/; + quad->ShaderNum = BQS_PalTex; + } + else + { + quad->Flags = BQF_WrapUV/* | BQF_DisableAlphaTest*/; + quad->ShaderNum = BQS_Plain; + } + quad->Palette = nullptr; + quad->Texture = pack->Tex; + quad->NumVerts = 4; + quad->NumTris = 2; + + float x0 = float(x) - 0.5f; + float y0 = float(y) - 0.5f; + float x1 = x0 + 256.f; + float y1 = y0 + 256.f; + + vert[0].x = x0; + vert[0].y = y0; + vert[0].z = 0; + vert[0].rhw = 1; + vert[0].color0 = 0; + vert[0].color1 = 0xFFFFFFFF; + vert[0].tu = 0; + vert[0].tv = 0; + + vert[1].x = x1; + vert[1].y = y0; + vert[1].z = 0; + vert[1].rhw = 1; + vert[1].color0 = 0; + vert[1].color1 = 0xFFFFFFFF; + vert[1].tu = 1; + vert[1].tv = 0; + + vert[2].x = x1; + vert[2].y = y1; + vert[2].z = 0; + vert[2].rhw = 1; + vert[2].color0 = 0; + vert[2].color1 = 0xFFFFFFFF; + vert[2].tu = 1; + vert[2].tv = 1; + + vert[3].x = x0; + vert[3].y = y1; + vert[3].z = 0; + vert[3].rhw = 1; + vert[3].color0 = 0; + vert[3].color1 = 0xFFFFFFFF; + vert[3].tu = 0; + vert[3].tv = 1; + + IndexData[IndexPos] = VertexPos; + IndexData[IndexPos + 1] = VertexPos + 1; + IndexData[IndexPos + 2] = VertexPos + 2; + IndexData[IndexPos + 3] = VertexPos; + IndexData[IndexPos + 4] = VertexPos + 2; + IndexData[IndexPos + 5] = VertexPos + 3; + + QuadBatchPos++; + VertexPos += 4; + IndexPos += 6; + + x += 256 + 8; + if (x > Width - 256) + { + x = 8; + y += 256 + 8; + if (y > TrueHeight - 256) + { + return; + } + } + pack = pack->Next; + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: AllocPackedTexture +// +// Finds space to pack an image inside a texture atlas and returns it. +// Large images and those that need to wrap always get their own textures. +// +//========================================================================== + +OpenGLSWFrameBuffer::PackedTexture *OpenGLSWFrameBuffer::AllocPackedTexture(int w, int h, bool wrapping, int format) +{ + Atlas *pack; + Rect box; + bool padded; + + // The - 2 to account for padding + if (w > 256 - 2 || h > 256 - 2 || wrapping) + { // Create a new texture atlas. + pack = new Atlas(this, w, h, format); + pack->OneUse = true; + box = pack->Packer.Insert(w, h); + padded = false; + } + else + { // Try to find space in an existing texture atlas. + w += 2; // Add padding + h += 2; + for (pack = Atlases; pack != nullptr; pack = pack->Next) + { + // Use the first atlas it fits in. + if (pack->Format == format) + { + box = pack->Packer.Insert(w, h); + if (box.width != 0) + { + break; + } + } + } + if (pack == nullptr) + { // Create a new texture atlas. + pack = new Atlas(this, DEF_ATLAS_WIDTH, DEF_ATLAS_HEIGHT, format); + box = pack->Packer.Insert(w, h); + } + padded = true; + } + assert(box.width != 0 && box.height != 0); + return pack->AllocateImage(box, padded); +} + +//========================================================================== +// +// Atlas Constructor +// +//========================================================================== + +OpenGLSWFrameBuffer::Atlas::Atlas(OpenGLSWFrameBuffer *fb, int w, int h, int format) + : Packer(w, h, true) +{ + Tex = nullptr; + Format = format; + UsedList = nullptr; + OneUse = false; + Width = 0; + Height = 0; + Next = nullptr; + + // Attach to the end of the atlas list + Atlas **prev = &fb->Atlases; + while (*prev != nullptr) + { + prev = &((*prev)->Next); + } + *prev = this; + + fb->CreateTexture(w, h, 1, format, &Tex); + Width = w; + Height = h; +} + +//========================================================================== +// +// Atlas Destructor +// +//========================================================================== + +OpenGLSWFrameBuffer::Atlas::~Atlas() +{ + PackedTexture *box, *next; + + SafeRelease(Tex); + for (box = UsedList; box != nullptr; box = next) + { + next = box->Next; + delete box; + } +} + +//========================================================================== +// +// Atlas :: AllocateImage +// +// Moves the box from the empty list to the used list, sizing it to the +// requested dimensions and adding additional boxes to the empty list if +// needed. +// +// The passed box *MUST* be in this texture atlas's empty list. +// +//========================================================================== + +OpenGLSWFrameBuffer::PackedTexture *OpenGLSWFrameBuffer::Atlas::AllocateImage(const Rect &rect, bool padded) +{ + PackedTexture *box = new PackedTexture; + + box->Owner = this; + box->Area.left = rect.x; + box->Area.top = rect.y; + box->Area.right = rect.x + rect.width; + box->Area.bottom = rect.y + rect.height; + + box->Left = float(box->Area.left + padded) / Width; + box->Right = float(box->Area.right - padded) / Width; + box->Top = float(box->Area.top + padded) / Height; + box->Bottom = float(box->Area.bottom - padded) / Height; + + box->Padded = padded; + + // Add it to the used list. + box->Next = UsedList; + if (box->Next != nullptr) + { + box->Next->Prev = &box->Next; + } + UsedList = box; + box->Prev = &UsedList; + + return box; +} + +//========================================================================== +// +// Atlas :: FreeBox +// +// Removes a box from the used list and deletes it. Space is returned to the +// waste list. Once all boxes for this atlas are freed, the entire bin +// packer is reinitialized for maximum efficiency. +// +//========================================================================== + +void OpenGLSWFrameBuffer::Atlas::FreeBox(OpenGLSWFrameBuffer::PackedTexture *box) +{ + *(box->Prev) = box->Next; + if (box->Next != nullptr) + { + box->Next->Prev = box->Prev; + } + Rect waste; + waste.x = box->Area.left; + waste.y = box->Area.top; + waste.width = box->Area.right - box->Area.left; + waste.height = box->Area.bottom - box->Area.top; + box->Owner->Packer.AddWaste(waste); + delete box; + if (UsedList == nullptr) + { + Packer.Init(Width, Height, true); + } +} + +//========================================================================== +// +// OpenGLTex Constructor +// +//========================================================================== + +OpenGLSWFrameBuffer::OpenGLTex::OpenGLTex(FTexture *tex, OpenGLSWFrameBuffer *fb, bool wrapping) +{ + // Attach to the texture list for the OpenGLSWFrameBuffer + Next = fb->Textures; + if (Next != nullptr) + { + Next->Prev = &Next; + } + Prev = &fb->Textures; + fb->Textures = this; + + GameTex = tex; + Box = nullptr; + IsGray = false; + + Create(fb, wrapping); +} + +//========================================================================== +// +// OpenGLTex Destructor +// +//========================================================================== + +OpenGLSWFrameBuffer::OpenGLTex::~OpenGLTex() +{ + if (Box != nullptr) + { + Box->Owner->FreeBox(Box); + Box = nullptr; + } + // Detach from the texture list + *Prev = Next; + if (Next != nullptr) + { + Next->Prev = Prev; + } + // Remove link from the game texture + if (GameTex != nullptr) + { + GameTex->Native = nullptr; + } +} + +//========================================================================== +// +// OpenGLTex :: CheckWrapping +// +// Returns true if the texture is compatible with the specified wrapping +// mode. +// +//========================================================================== + +bool OpenGLSWFrameBuffer::OpenGLTex::CheckWrapping(bool wrapping) +{ + // If it doesn't need to wrap, then it works. + if (!wrapping) + { + return true; + } + // If it needs to wrap, then it can't be packed inside another texture. + return Box->Owner->OneUse; +} + +//========================================================================== +// +// OpenGLTex :: Create +// +// Creates an HWTexture for the texture and copies the image data +// to it. Note that unlike FTexture, this image is row-major. +// +//========================================================================== + +bool OpenGLSWFrameBuffer::OpenGLTex::Create(OpenGLSWFrameBuffer *fb, bool wrapping) +{ + assert(Box == nullptr); + if (Box != nullptr) + { + Box->Owner->FreeBox(Box); + } + + Box = fb->AllocPackedTexture(GameTex->GetWidth(), GameTex->GetHeight(), wrapping, GetTexFormat()); + + if (Box == nullptr) + { + return false; + } + if (!Update()) + { + Box->Owner->FreeBox(Box); + Box = nullptr; + return false; + } + return true; +} + +//========================================================================== +// +// OpenGLTex :: Update +// +// Copies image data from the underlying FTexture to the OpenGL texture. +// +//========================================================================== + +bool OpenGLSWFrameBuffer::OpenGLTex::Update() +{ + LockedRect lrect; + LTRBRect rect; + uint8_t *dest; + + assert(Box != nullptr); + assert(Box->Owner != nullptr); + assert(Box->Owner->Tex != nullptr); + assert(GameTex != nullptr); + + int format = Box->Owner->Tex->Format; + + rect = Box->Area; + if (!Box->Owner->Tex->LockRect(&lrect, &rect, false)) + { + return false; + } + dest = (uint8_t *)lrect.pBits; + if (Box->Padded) + { + dest += lrect.Pitch + (format == GL_R8 ? 1 : 4); + } + GameTex->FillBuffer(dest, lrect.Pitch, GameTex->GetHeight(), ToTexFmt(format)); + if (Box->Padded) + { + // Clear top padding row. + dest = (uint8_t *)lrect.pBits; + int numbytes = GameTex->GetWidth() + 2; + if (format != GL_R8) + { + numbytes <<= 2; + } + memset(dest, 0, numbytes); + dest += lrect.Pitch; + // Clear left and right padding columns. + if (format == GL_R8) + { + for (int y = Box->Area.bottom - Box->Area.top - 2; y > 0; --y) + { + dest[0] = 0; + dest[numbytes - 1] = 0; + dest += lrect.Pitch; + } + } + else + { + for (int y = Box->Area.bottom - Box->Area.top - 2; y > 0; --y) + { + *(uint32_t *)dest = 0; + *(uint32_t *)(dest + numbytes - 4) = 0; + dest += lrect.Pitch; + } + } + // Clear bottom padding row. + memset(dest, 0, numbytes); + } + Box->Owner->Tex->UnlockRect(); + return true; +} + +//========================================================================== +// +// OpenGLTex :: GetTexFormat +// +// Returns the texture format that would best fit this texture. +// +//========================================================================== + +int OpenGLSWFrameBuffer::OpenGLTex::GetTexFormat() +{ + FTextureFormat fmt = GameTex->GetFormat(); + + IsGray = false; + + switch (fmt) + { + case TEX_Pal: return GL_R8; + case TEX_Gray: IsGray = true; return GL_R8; + case TEX_RGB: return GL_RGBA8; + case TEX_DXT1: return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; + case TEX_DXT2: return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + case TEX_DXT3: return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + case TEX_DXT4: return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; // Doesn't exist in OpenGL. Closest match is DXT5. + case TEX_DXT5: return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + default: I_FatalError("GameTex->GetFormat() returned invalid format."); + } + return GL_R8; +} + +//========================================================================== +// +// OpenGLTex :: ToTexFmt +// +// Converts an OpenGL internal format constant to something the FTexture system +// understands. +// +//========================================================================== + +FTextureFormat OpenGLSWFrameBuffer::OpenGLTex::ToTexFmt(int fmt) +{ + switch (fmt) + { + case GL_R8: return IsGray ? TEX_Gray : TEX_Pal; + case GL_RGBA8: return TEX_RGB; + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: return TEX_DXT1; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return TEX_DXT2; + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: return TEX_DXT3; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return TEX_DXT5; + default: + assert(0); // LOL WUT? + return TEX_Pal; + } +} + +//========================================================================== +// +// OpenGLPal Constructor +// +//========================================================================== + +OpenGLSWFrameBuffer::OpenGLPal::OpenGLPal(FRemapTable *remap, OpenGLSWFrameBuffer *fb) + : Tex(nullptr), Remap(remap) +{ + int count; + + // Attach to the palette list for the OpenGLSWFrameBuffer + Next = fb->Palettes; + if (Next != nullptr) + { + Next->Prev = &Next; + } + Prev = &fb->Palettes; + fb->Palettes = this; + + int pow2count; + + // Round up to the nearest power of 2. + for (pow2count = 1; pow2count < remap->NumEntries; pow2count <<= 1) + { + } + count = pow2count; + DoColorSkip = false; + + BorderColor = 0; + RoundedPaletteSize = count; + if (fb->CreateTexture(count, 1, 1, GL_RGBA8, &Tex)) + { + if (!Update()) + { + delete Tex; + Tex = nullptr; + } + } +} + +//========================================================================== +// +// OpenGLPal Destructor +// +//========================================================================== + +OpenGLSWFrameBuffer::OpenGLPal::~OpenGLPal() +{ + SafeRelease(Tex); + // Detach from the palette list + *Prev = Next; + if (Next != nullptr) + { + Next->Prev = Prev; + } + // Remove link from the remap table + if (Remap != nullptr) + { + Remap->Native = nullptr; + } +} + +//========================================================================== +// +// OpenGLPal :: Update +// +// Copies the palette to the texture. +// +//========================================================================== + +bool OpenGLSWFrameBuffer::OpenGLPal::Update() +{ + LockedRect lrect; + uint32_t *buff; + const PalEntry *pal; + int skipat, i; + + assert(Tex != nullptr); + + if (!Tex->LockRect(&lrect, nullptr, 0)) + { + return false; + } + buff = (uint32_t *)lrect.pBits; + pal = Remap->Palette; + + // See explanation in UploadPalette() for skipat rationale. + skipat = MIN(Remap->NumEntries, DoColorSkip ? 256 - 8 : 256); + + for (i = 0; i < skipat; ++i) + { + buff[i] = ColorARGB(pal[i].a, pal[i].r, pal[i].g, pal[i].b); + } + for (++i; i < Remap->NumEntries; ++i) + { + buff[i] = ColorARGB(pal[i].a, pal[i - 1].r, pal[i - 1].g, pal[i - 1].b); + } + BorderColor = ColorARGB(pal[i].a, pal[i - 1].r, pal[i - 1].g, pal[i - 1].b); + + Tex->UnlockRect(); + return true; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Begin2D +// +// Begins 2D mode drawing operations. In particular, DrawTexture is +// rerouted to use Direct3D instead of the software renderer. +// +//========================================================================== + +bool OpenGLSWFrameBuffer::Begin2D(bool copy3d) +{ + if (!Accel2D) + { + return false; + } + if (In2D) + { + return true; + } + In2D = 2 - copy3d; + Update(); + In2D = 3; + + return true; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: DrawBlendingRect +// +// Call after Begin2D to blend the 3D view. +// +//========================================================================== + +void OpenGLSWFrameBuffer::DrawBlendingRect() +{ + if (!In2D || !Accel2D) + { + return; + } + Dim(FlashColor, FlashAmount / 256.f, viewwindowx, viewwindowy, viewwidth, viewheight); +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: CreateTexture +// +// Returns a native texture that wraps a FTexture. +// +//========================================================================== + +FNativeTexture *OpenGLSWFrameBuffer::CreateTexture(FTexture *gametex, bool wrapping) +{ + OpenGLTex *tex = new OpenGLTex(gametex, this, wrapping); + if (tex->Box == nullptr) + { + delete tex; + return nullptr; + } + return tex; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: CreatePalette +// +// Returns a native texture that contains a palette. +// +//========================================================================== + +FNativePalette *OpenGLSWFrameBuffer::CreatePalette(FRemapTable *remap) +{ + OpenGLPal *tex = new OpenGLPal(remap, this); + if (tex->Tex == nullptr) + { + delete tex; + return nullptr; + } + return tex; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Clear +// +// Fills the specified region with a color. +// +//========================================================================== + +void OpenGLSWFrameBuffer::Clear(int left, int top, int right, int bottom, int palcolor, uint32 color) +{ + if (In2D < 2) + { + Super::Clear(left, top, right, bottom, palcolor, color); + return; + } + if (!InScene) + { + return; + } + if (palcolor >= 0 && color == 0) + { + color = GPalette.BaseColors[palcolor]; + } + else if (APART(color) < 255) + { + Dim(color, APART(color) / 255.f, left, top, right - left, bottom - top); + return; + } + AddColorOnlyQuad(left, top, right - left, bottom - top, color | 0xFF000000); +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Dim +// +//========================================================================== + +void OpenGLSWFrameBuffer::Dim(PalEntry color, float amount, int x1, int y1, int w, int h) +{ + if (amount <= 0) + { + return; + } + if (In2D < 2) + { + Super::Dim(color, amount, x1, y1, w, h); + return; + } + if (!InScene) + { + return; + } + if (amount > 1) + { + amount = 1; + } + AddColorOnlyQuad(x1, y1, w, h, color | (int(amount * 255) << 24)); +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: BeginLineBatch +// +//========================================================================== + +void OpenGLSWFrameBuffer::BeginLineBatch() +{ + if (In2D < 2 || !InScene || BatchType == BATCH_Lines) + { + return; + } + EndQuadBatch(); // Make sure all quads have been drawn first. + VertexData = VertexBuffer->Lock(); + VertexPos = 0; + BatchType = BATCH_Lines; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: EndLineBatch +// +//========================================================================== + +void OpenGLSWFrameBuffer::EndLineBatch() +{ + if (In2D < 2 || !InScene || BatchType != BATCH_Lines) + { + return; + } + VertexBuffer->Unlock(); + if (VertexPos > 0) + { + SetPixelShader(Shaders[SHADER_VertexColor]); + SetAlphaBlend(GL_FUNC_ADD, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + SetStreamSource(VertexBuffer); + DrawLineList(VertexPos / 2); + } + VertexPos = -1; + BatchType = BATCH_None; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: DrawLine +// +//========================================================================== + +void OpenGLSWFrameBuffer::DrawLine(int x0, int y0, int x1, int y1, int palcolor, uint32 color) +{ + if (In2D < 2) + { + Super::DrawLine(x0, y0, x1, y1, palcolor, color); + return; + } + if (!InScene) + { + return; + } + if (BatchType != BATCH_Lines) + { + BeginLineBatch(); + } + if (VertexPos == NUM_VERTS) + { // Flush the buffer and refill it. + EndLineBatch(); + BeginLineBatch(); + } + // Add the endpoints to the vertex buffer. + VertexData[VertexPos].x = float(x0); + VertexData[VertexPos].y = float(y0) + LBOffset; + VertexData[VertexPos].z = 0; + VertexData[VertexPos].rhw = 1; + VertexData[VertexPos].color0 = color; + VertexData[VertexPos].color1 = 0; + VertexData[VertexPos].tu = 0; + VertexData[VertexPos].tv = 0; + + VertexData[VertexPos + 1].x = float(x1); + VertexData[VertexPos + 1].y = float(y1) + LBOffset; + VertexData[VertexPos + 1].z = 0; + VertexData[VertexPos + 1].rhw = 1; + VertexData[VertexPos + 1].color0 = color; + VertexData[VertexPos + 1].color1 = 0; + VertexData[VertexPos + 1].tu = 0; + VertexData[VertexPos + 1].tv = 0; + + VertexPos += 2; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: DrawPixel +// +//========================================================================== + +void OpenGLSWFrameBuffer::DrawPixel(int x, int y, int palcolor, uint32 color) +{ + if (In2D < 2) + { + Super::DrawPixel(x, y, palcolor, color); + return; + } + if (!InScene) + { + return; + } + FBVERTEX pt = + { + float(x), float(y), 0, 1, color + }; + EndBatch(); // Draw out any batched operations. + SetPixelShader(Shaders[SHADER_VertexColor]); + SetAlphaBlend(GL_FUNC_ADD, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + DrawPoints(1, &pt); +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: DrawTextureV +// +// If not in 2D mode, just call the normal software version. +// If in 2D mode, then use Direct3D calls to perform the drawing. +// +//========================================================================== + +void OpenGLSWFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) +{ + if (In2D < 2) + { + Super::DrawTextureParms(img, parms); + return; + } + if (!InScene) + { + return; + } + + OpenGLTex *tex = static_cast(img->GetNative(false)); + + if (tex == nullptr) + { + assert(tex != nullptr); + return; + } + + CheckQuadBatch(); + + double xscale = parms.destwidth / parms.texwidth; + double yscale = parms.destheight / parms.texheight; + double x0 = parms.x - parms.left * xscale; + double y0 = parms.y - parms.top * yscale; + double x1 = x0 + parms.destwidth; + double y1 = y0 + parms.destheight; + float u0 = tex->Box->Left; + float v0 = tex->Box->Top; + float u1 = tex->Box->Right; + float v1 = tex->Box->Bottom; + double uscale = 1.f / tex->Box->Owner->Width; + bool scissoring = false; + FBVERTEX *vert; + float yoffs; + + if (parms.flipX) + { + swapvalues(u0, u1); + } + if (parms.windowleft > 0 || parms.windowright < parms.texwidth) + { + double wi = MIN(parms.windowright, parms.texwidth); + x0 += parms.windowleft * xscale; + u0 = float(u0 + parms.windowleft * uscale); + x1 -= (parms.texwidth - wi) * xscale; + u1 = float(u1 - (parms.texwidth - wi) * uscale); + } + +#if 0 + float vscale = 1.f / tex->Box->Owner->Height / yscale; + if (y0 < parms.uclip) + { + v0 += (float(parms.uclip) - y0) * vscale; + y0 = float(parms.uclip); + } + if (y1 > parms.dclip) + { + v1 -= (y1 - float(parms.dclip)) * vscale; + y1 = float(parms.dclip); + } + if (x0 < parms.lclip) + { + u0 += float(parms.lclip - x0) * uscale / xscale * 2; + x0 = float(parms.lclip); + } + if (x1 > parms.rclip) + { + u1 -= (x1 - parms.rclip) * uscale / xscale * 2; + x1 = float(parms.rclip); + } +#else + // Use a scissor test because the math above introduces some jitter + // that is noticeable at low resolutions. Unfortunately, this means this + // quad has to be in a batch by itself. + if (y0 < parms.uclip || y1 > parms.dclip || x0 < parms.lclip || x1 > parms.rclip) + { + scissoring = true; + if (QuadBatchPos > 0) + { + EndQuadBatch(); + BeginQuadBatch(); + } + glEnable(GL_SCISSOR_TEST); + glScissor(parms.lclip, parms.uclip + LBOffsetI, parms.rclip - parms.lclip, parms.dclip - parms.uclip); + } +#endif + parms.bilinear = false; + + uint32_t color0, color1; + BufferedTris *quad = &QuadExtra[QuadBatchPos]; + + if (!SetStyle(tex, parms, color0, color1, *quad)) + { + goto done; + } + + quad->Texture = tex->Box->Owner->Tex; + if (parms.bilinear) + { + quad->Flags |= BQF_Bilinear; + } + quad->NumTris = 2; + quad->NumVerts = 4; + + yoffs = GatheringWipeScreen ? 0.5f : 0.5f - LBOffset; + +#if 0 + // Coordinates are truncated to integers, because that's effectively + // what the software renderer does. The hardware will instead round + // to nearest, it seems. + x0 = floorf(x0) - 0.5f; + y0 = floorf(y0) - yoffs; + x1 = floorf(x1) - 0.5f; + y1 = floorf(y1) - yoffs; +#else + x0 = x0 - 0.5f; + y0 = y0 - yoffs; + x1 = x1 - 0.5f; + y1 = y1 - yoffs; +#endif + + vert = &VertexData[VertexPos]; + + // Fill the vertex buffer. + vert[0].x = float(x0); + vert[0].y = float(y0); + vert[0].z = 0; + vert[0].rhw = 1; + vert[0].color0 = color0; + vert[0].color1 = color1; + vert[0].tu = u0; + vert[0].tv = v0; + + vert[1].x = float(x1); + vert[1].y = float(y0); + vert[1].z = 0; + vert[1].rhw = 1; + vert[1].color0 = color0; + vert[1].color1 = color1; + vert[1].tu = u1; + vert[1].tv = v0; + + vert[2].x = float(x1); + vert[2].y = float(y1); + vert[2].z = 0; + vert[2].rhw = 1; + vert[2].color0 = color0; + vert[2].color1 = color1; + vert[2].tu = u1; + vert[2].tv = v1; + + vert[3].x = float(x0); + vert[3].y = float(y1); + vert[3].z = 0; + vert[3].rhw = 1; + vert[3].color0 = color0; + vert[3].color1 = color1; + vert[3].tu = u0; + vert[3].tv = v1; + + // Fill the vertex index buffer. + IndexData[IndexPos] = VertexPos; + IndexData[IndexPos + 1] = VertexPos + 1; + IndexData[IndexPos + 2] = VertexPos + 2; + IndexData[IndexPos + 3] = VertexPos; + IndexData[IndexPos + 4] = VertexPos + 2; + IndexData[IndexPos + 5] = VertexPos + 3; + + // Batch the quad. + QuadBatchPos++; + VertexPos += 4; + IndexPos += 6; +done: + if (scissoring) + { + EndQuadBatch(); + glDisable(GL_SCISSOR_TEST); + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: FlatFill +// +// Fills an area with a repeating copy of the texture. +// +//========================================================================== + +void OpenGLSWFrameBuffer::FlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin) +{ + if (In2D < 2) + { + Super::FlatFill(left, top, right, bottom, src, local_origin); + return; + } + if (!InScene) + { + return; + } + OpenGLTex *tex = static_cast(src->GetNative(true)); + if (tex == nullptr) + { + return; + } + float yoffs = GatheringWipeScreen ? 0.5f : 0.5f - LBOffset; + float x0 = float(left); + float y0 = float(top); + float x1 = float(right); + float y1 = float(bottom); + float itw = 1.f / float(src->GetWidth()); + float ith = 1.f / float(src->GetHeight()); + float xo = local_origin ? x0 : 0; + float yo = local_origin ? y0 : 0; + float u0 = (x0 - xo) * itw; + float v0 = (y0 - yo) * ith; + float u1 = (x1 - xo) * itw; + float v1 = (y1 - yo) * ith; + x0 -= 0.5f; + y0 -= yoffs; + x1 -= 0.5f; + y1 -= yoffs; + + CheckQuadBatch(); + + BufferedTris *quad = &QuadExtra[QuadBatchPos]; + FBVERTEX *vert = &VertexData[VertexPos]; + + quad->Group1 = 0; + if (tex->GetTexFormat() == GL_R8 && !tex->IsGray) + { + quad->Flags = BQF_WrapUV | BQF_GamePalette; // | BQF_DisableAlphaTest; + quad->ShaderNum = BQS_PalTex; + } + else + { + quad->Flags = BQF_WrapUV; // | BQF_DisableAlphaTest; + quad->ShaderNum = BQS_Plain; + } + quad->Palette = nullptr; + quad->Texture = tex->Box->Owner->Tex; + quad->NumVerts = 4; + quad->NumTris = 2; + + vert[0].x = x0; + vert[0].y = y0; + vert[0].z = 0; + vert[0].rhw = 1; + vert[0].color0 = 0; + vert[0].color1 = 0xFFFFFFFF; + vert[0].tu = u0; + vert[0].tv = v0; + + vert[1].x = x1; + vert[1].y = y0; + vert[1].z = 0; + vert[1].rhw = 1; + vert[1].color0 = 0; + vert[1].color1 = 0xFFFFFFFF; + vert[1].tu = u1; + vert[1].tv = v0; + + vert[2].x = x1; + vert[2].y = y1; + vert[2].z = 0; + vert[2].rhw = 1; + vert[2].color0 = 0; + vert[2].color1 = 0xFFFFFFFF; + vert[2].tu = u1; + vert[2].tv = v1; + + vert[3].x = x0; + vert[3].y = y1; + vert[3].z = 0; + vert[3].rhw = 1; + vert[3].color0 = 0; + vert[3].color1 = 0xFFFFFFFF; + vert[3].tu = u0; + vert[3].tv = v1; + + IndexData[IndexPos] = VertexPos; + IndexData[IndexPos + 1] = VertexPos + 1; + IndexData[IndexPos + 2] = VertexPos + 2; + IndexData[IndexPos + 3] = VertexPos; + IndexData[IndexPos + 4] = VertexPos + 2; + IndexData[IndexPos + 5] = VertexPos + 3; + + QuadBatchPos++; + VertexPos += 4; + IndexPos += 6; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: FillSimplePoly +// +// Here, "simple" means that a simple triangle fan can draw it. +// +//========================================================================== + +void OpenGLSWFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, + double originx, double originy, double scalex, double scaley, + DAngle rotation, FDynamicColormap *colormap, int lightlevel) +{ + // Use an equation similar to player sprites to determine shade + double fadelevel = clamp((LIGHT2SHADE(lightlevel) / 65536. - 12) / NUMCOLORMAPS, 0.0, 1.0); + + BufferedTris *quad; + FBVERTEX *verts; + OpenGLTex *tex; + float yoffs, uscale, vscale; + int i, ipos; + uint32_t color0, color1; + float ox, oy; + float cosrot, sinrot; + bool dorotate = rotation != 0; + + if (npoints < 3) + { // This is no polygon. + return; + } + if (In2D < 2) + { + Super::FillSimplePoly(texture, points, npoints, originx, originy, scalex, scaley, rotation, colormap, lightlevel); + return; + } + if (!InScene) + { + return; + } + tex = static_cast(texture->GetNative(true)); + if (tex == nullptr) + { + return; + } + + cosrot = (float)cos(rotation.Radians()); + sinrot = (float)sin(rotation.Radians()); + + CheckQuadBatch(npoints - 2, npoints); + quad = &QuadExtra[QuadBatchPos]; + verts = &VertexData[VertexPos]; + + color0 = 0; + color1 = 0xFFFFFFFF; + + quad->Group1 = 0; + if (tex->GetTexFormat() == GL_R8 && !tex->IsGray) + { + quad->Flags = BQF_WrapUV | BQF_GamePalette | BQF_DisableAlphaTest; + quad->ShaderNum = BQS_PalTex; + if (colormap != nullptr) + { + if (colormap->Desaturate != 0) + { + quad->Flags |= BQF_Desaturated; + } + quad->ShaderNum = BQS_InGameColormap; + quad->Desat = colormap->Desaturate; + color0 = ColorARGB(255, colormap->Color.r, colormap->Color.g, colormap->Color.b); + color1 = ColorARGB(uint32_t((1 - fadelevel) * 255), + uint32_t(colormap->Fade.r * fadelevel), + uint32_t(colormap->Fade.g * fadelevel), + uint32_t(colormap->Fade.b * fadelevel)); + } + } + else + { + quad->Flags = BQF_WrapUV | BQF_DisableAlphaTest; + quad->ShaderNum = BQS_Plain; + } + quad->Palette = nullptr; + quad->Texture = tex->Box->Owner->Tex; + quad->NumVerts = npoints; + quad->NumTris = npoints - 2; + + yoffs = GatheringWipeScreen ? 0 : LBOffset; + uscale = float(1.f / (texture->GetScaledWidth() * scalex)); + vscale = float(1.f / (texture->GetScaledHeight() * scaley)); + ox = float(originx); + oy = float(originy); + + for (i = 0; i < npoints; ++i) + { + verts[i].x = points[i].X; + verts[i].y = points[i].Y + yoffs; + verts[i].z = 0; + verts[i].rhw = 1; + verts[i].color0 = color0; + verts[i].color1 = color1; + float u = points[i].X - 0.5f - ox; + float v = points[i].Y - 0.5f - oy; + if (dorotate) + { + float t = u; + u = t * cosrot - v * sinrot; + v = v * cosrot + t * sinrot; + } + verts[i].tu = u * uscale; + verts[i].tv = v * vscale; + } + for (ipos = IndexPos, i = 2; i < npoints; ++i, ipos += 3) + { + IndexData[ipos] = VertexPos; + IndexData[ipos + 1] = VertexPos + i - 1; + IndexData[ipos + 2] = VertexPos + i; + } + + QuadBatchPos++; + VertexPos += npoints; + IndexPos = ipos; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: AddColorOnlyQuad +// +// Adds a single-color, untextured quad to the batch. +// +//========================================================================== + +void OpenGLSWFrameBuffer::AddColorOnlyQuad(int left, int top, int width, int height, uint32_t color) +{ + BufferedTris *quad; + FBVERTEX *verts; + + CheckQuadBatch(); + quad = &QuadExtra[QuadBatchPos]; + verts = &VertexData[VertexPos]; + + float x = float(left) - 0.5f; + float y = float(top) - 0.5f + (GatheringWipeScreen ? 0 : LBOffset); + + quad->Group1 = 0; + quad->ShaderNum = BQS_ColorOnly; + if ((color & 0xFF000000) != 0xFF000000) + { + quad->BlendOp = GL_FUNC_ADD; + quad->SrcBlend = GL_SRC_ALPHA; + quad->DestBlend = GL_ONE_MINUS_SRC_ALPHA; + } + quad->Palette = nullptr; + quad->Texture = nullptr; + quad->NumVerts = 4; + quad->NumTris = 2; + + verts[0].x = x; + verts[0].y = y; + verts[0].z = 0; + verts[0].rhw = 1; + verts[0].color0 = color; + verts[0].color1 = 0; + verts[0].tu = 0; + verts[0].tv = 0; + + verts[1].x = x + width; + verts[1].y = y; + verts[1].z = 0; + verts[1].rhw = 1; + verts[1].color0 = color; + verts[1].color1 = 0; + verts[1].tu = 0; + verts[1].tv = 0; + + verts[2].x = x + width; + verts[2].y = y + height; + verts[2].z = 0; + verts[2].rhw = 1; + verts[2].color0 = color; + verts[2].color1 = 0; + verts[2].tu = 0; + verts[2].tv = 0; + + verts[3].x = x; + verts[3].y = y + height; + verts[3].z = 0; + verts[3].rhw = 1; + verts[3].color0 = color; + verts[3].color1 = 0; + verts[3].tu = 0; + verts[3].tv = 0; + + IndexData[IndexPos] = VertexPos; + IndexData[IndexPos + 1] = VertexPos + 1; + IndexData[IndexPos + 2] = VertexPos + 2; + IndexData[IndexPos + 3] = VertexPos; + IndexData[IndexPos + 4] = VertexPos + 2; + IndexData[IndexPos + 5] = VertexPos + 3; + + QuadBatchPos++; + VertexPos += 4; + IndexPos += 6; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: AddColorOnlyRect +// +// Like AddColorOnlyQuad, except it's hollow. +// +//========================================================================== + +void OpenGLSWFrameBuffer::AddColorOnlyRect(int left, int top, int width, int height, uint32_t color) +{ + AddColorOnlyQuad(left, top, width - 1, 1, color); // top + AddColorOnlyQuad(left + width - 1, top, 1, height - 1, color); // right + AddColorOnlyQuad(left + 1, top + height - 1, width - 1, 1, color); // bottom + AddColorOnlyQuad(left, top + 1, 1, height - 1, color); // left +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: CheckQuadBatch +// +// Make sure there's enough room in the batch for one more set of triangles. +// +//========================================================================== + +void OpenGLSWFrameBuffer::CheckQuadBatch(int numtris, int numverts) +{ + if (BatchType == BATCH_Lines) + { + EndLineBatch(); + } + else if (QuadBatchPos == MAX_QUAD_BATCH || + VertexPos + numverts > NUM_VERTS || + IndexPos + numtris * 3 > NUM_INDEXES) + { + EndQuadBatch(); + } + if (QuadBatchPos < 0) + { + BeginQuadBatch(); + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: BeginQuadBatch +// +// Locks the vertex buffer for quads and sets the cursor to 0. +// +//========================================================================== + +void OpenGLSWFrameBuffer::BeginQuadBatch() +{ + if (In2D < 2 || !InScene || QuadBatchPos >= 0) + { + return; + } + EndLineBatch(); // Make sure all lines have been drawn first. + VertexData = VertexBuffer->Lock(); + IndexData = IndexBuffer->Lock(); + VertexPos = 0; + IndexPos = 0; + QuadBatchPos = 0; + BatchType = BATCH_Quads; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: EndQuadBatch +// +// Draws all the quads that have been batched up. +// +//========================================================================== + +void OpenGLSWFrameBuffer::EndQuadBatch() +{ + if (In2D < 2 || !InScene || BatchType != BATCH_Quads) + { + return; + } + BatchType = BATCH_None; + VertexBuffer->Unlock(); + IndexBuffer->Unlock(); + if (QuadBatchPos == 0) + { + QuadBatchPos = -1; + VertexPos = -1; + IndexPos = -1; + return; + } + SetStreamSource(VertexBuffer); + SetIndices(IndexBuffer); + bool uv_wrapped = false; + bool uv_should_wrap; + int indexpos, vertpos; + + indexpos = vertpos = 0; + for (int i = 0; i < QuadBatchPos; ) + { + const BufferedTris *quad = &QuadExtra[i]; + int j; + + int startindex = indexpos; + int startvertex = vertpos; + + indexpos += quad->NumTris * 3; + vertpos += quad->NumVerts; + + // Quads with matching parameters should be done with a single + // DrawPrimitive call. + for (j = i + 1; j < QuadBatchPos; ++j) + { + const BufferedTris *q2 = &QuadExtra[j]; + if (quad->Texture != q2->Texture || + quad->Group1 != q2->Group1 || + quad->Palette != q2->Palette) + { + break; + } + if (quad->ShaderNum == BQS_InGameColormap && (quad->Flags & BQF_Desaturated) && quad->Desat != q2->Desat) + { + break; + } + indexpos += q2->NumTris * 3; + vertpos += q2->NumVerts; + } + + // Set the palette (if one) + if ((quad->Flags & BQF_Paletted) == BQF_GamePalette) + { + SetPaletteTexture(PaletteTexture, 256, BorderColor); + } + else if ((quad->Flags & BQF_Paletted) == BQF_CustomPalette) + { + assert(quad->Palette != nullptr); + SetPaletteTexture(quad->Palette->Tex, quad->Palette->RoundedPaletteSize, quad->Palette->BorderColor); + } + + // Set the alpha blending + SetAlphaBlend(quad->BlendOp, quad->SrcBlend, quad->DestBlend); + + // Set the alpha test + EnableAlphaTest(!(quad->Flags & BQF_DisableAlphaTest)); + + // Set the pixel shader + if (quad->ShaderNum == BQS_PalTex) + { + SetPixelShader(Shaders[(quad->Flags & BQF_InvertSource) ? + SHADER_NormalColorPalInv : SHADER_NormalColorPal]); + } + else if (quad->ShaderNum == BQS_Plain) + { + SetPixelShader(Shaders[(quad->Flags & BQF_InvertSource) ? + SHADER_NormalColorInv : SHADER_NormalColor]); + } + else if (quad->ShaderNum == BQS_RedToAlpha) + { + SetPixelShader(Shaders[(quad->Flags & BQF_InvertSource) ? + SHADER_RedToAlphaInv : SHADER_RedToAlpha]); + } + else if (quad->ShaderNum == BQS_ColorOnly) + { + SetPixelShader(Shaders[SHADER_VertexColor]); + } + else if (quad->ShaderNum == BQS_SpecialColormap) + { + int select; + + select = !!(quad->Flags & BQF_Paletted); + SetPixelShader(Shaders[SHADER_SpecialColormap + select]); + } + else if (quad->ShaderNum == BQS_InGameColormap) + { + int select; + + select = !!(quad->Flags & BQF_Desaturated); + select |= !!(quad->Flags & BQF_InvertSource) << 1; + select |= !!(quad->Flags & BQF_Paletted) << 2; + if (quad->Flags & BQF_Desaturated) + { + SetConstant(PSCONST_Desaturation, quad->Desat / 255.f, (255 - quad->Desat) / 255.f, 0, 0); + } + SetPixelShader(Shaders[SHADER_InGameColormap + select]); + } + + // Set the texture clamp addressing mode + uv_should_wrap = !!(quad->Flags & BQF_WrapUV); + if (uv_wrapped != uv_should_wrap) + { + uint32_t mode = uv_should_wrap ? GL_REPEAT : GL_CLAMP_TO_EDGE; + uv_wrapped = uv_should_wrap; + SetSamplerWrapS(0, mode); + SetSamplerWrapT(0, mode); + } + + // Set the texture + if (quad->Texture != nullptr) + { + SetTexture(0, quad->Texture); + } + + // Draw the quad + DrawTriangleList( + startvertex, // MinIndex + vertpos - startvertex, // NumVertices + startindex, // StartIndex + (indexpos - startindex) / 3 // PrimitiveCount + /*4 * i, 4 * (j - i), 6 * i, 2 * (j - i)*/); + i = j; + } + if (uv_wrapped) + { + SetSamplerWrapS(0, GL_CLAMP_TO_EDGE); + SetSamplerWrapT(0, GL_CLAMP_TO_EDGE); + } + QuadBatchPos = -1; + VertexPos = -1; + IndexPos = -1; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: EndBatch +// +// Draws whichever type of primitive is currently being batched. +// +//========================================================================== + +void OpenGLSWFrameBuffer::EndBatch() +{ + if (BatchType == BATCH_Quads) + { + EndQuadBatch(); + } + else if (BatchType == BATCH_Lines) + { + EndLineBatch(); + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: SetStyle +// +// Patterned after R_SetPatchStyle. +// +//========================================================================== + +bool OpenGLSWFrameBuffer::SetStyle(OpenGLTex *tex, DrawParms &parms, uint32_t &color0, uint32_t &color1, BufferedTris &quad) +{ + int fmt = tex->GetTexFormat(); + FRenderStyle style = parms.style; + float alpha; + bool stencilling; + + if (style.Flags & STYLEF_TransSoulsAlpha) + { + alpha = transsouls; + } + else if (style.Flags & STYLEF_Alpha1) + { + alpha = 1; + } + else + { + alpha = clamp(parms.Alpha, 0.f, 1.f); + } + + style.CheckFuzz(); + if (style.BlendOp == STYLEOP_Shadow) + { + style = LegacyRenderStyles[STYLE_TranslucentStencil]; + alpha = 0.3f; + parms.fillcolor = 0; + } + + // FIXME: Fuzz effect is not written + if (style.BlendOp == STYLEOP_FuzzOrAdd || style.BlendOp == STYLEOP_Fuzz) + { + style.BlendOp = STYLEOP_Add; + } + else if (style.BlendOp == STYLEOP_FuzzOrSub) + { + style.BlendOp = STYLEOP_Sub; + } + else if (style.BlendOp == STYLEOP_FuzzOrRevSub) + { + style.BlendOp = STYLEOP_RevSub; + } + + stencilling = false; + quad.Palette = nullptr; + quad.Flags = 0; + quad.Desat = 0; + + switch (style.BlendOp) + { + default: + case STYLEOP_Add: quad.BlendOp = GL_FUNC_ADD; break; + case STYLEOP_Sub: quad.BlendOp = GL_FUNC_SUBTRACT; break; + case STYLEOP_RevSub: quad.BlendOp = GL_FUNC_REVERSE_SUBTRACT; break; + case STYLEOP_None: return false; + } + quad.SrcBlend = GetStyleAlpha(style.SrcAlpha); + quad.DestBlend = GetStyleAlpha(style.DestAlpha); + + if (style.Flags & STYLEF_InvertOverlay) + { + // Only the overlay color is inverted, not the overlay alpha. + parms.colorOverlay = ColorARGB(APART(parms.colorOverlay), + 255 - RPART(parms.colorOverlay), 255 - GPART(parms.colorOverlay), + 255 - BPART(parms.colorOverlay)); + } + + SetColorOverlay(parms.colorOverlay, alpha, color0, color1); + + if (style.Flags & STYLEF_ColorIsFixed) + { + if (style.Flags & STYLEF_InvertSource) + { // Since the source color is a constant, we can invert it now + // without spending time doing it in the shader. + parms.fillcolor = ColorXRGB(255 - RPART(parms.fillcolor), + 255 - GPART(parms.fillcolor), 255 - BPART(parms.fillcolor)); + } + // Set up the color mod to replace the color from the image data. + color0 = (color0 & ColorRGBA(0, 0, 0, 255)) | (parms.fillcolor & ColorRGBA(255, 255, 255, 0)); + color1 &= ColorRGBA(0, 0, 0, 255); + + if (style.Flags & STYLEF_RedIsAlpha) + { + // Note that if the source texture is paletted, the palette is ignored. + quad.Flags = 0; + quad.ShaderNum = BQS_RedToAlpha; + } + else if (fmt == GL_R8) + { + quad.Flags = BQF_GamePalette; + quad.ShaderNum = BQS_PalTex; + } + else + { + quad.Flags = 0; + quad.ShaderNum = BQS_Plain; + } + } + else + { + if (style.Flags & STYLEF_RedIsAlpha) + { + quad.Flags = 0; + quad.ShaderNum = BQS_RedToAlpha; + } + else if (fmt == GL_R8) + { + if (parms.remap != nullptr) + { + quad.Flags = BQF_CustomPalette; + quad.Palette = reinterpret_cast(parms.remap->GetNative()); + quad.ShaderNum = BQS_PalTex; + } + else if (tex->IsGray) + { + quad.Flags = 0; + quad.ShaderNum = BQS_Plain; + } + else + { + quad.Flags = BQF_GamePalette; + quad.ShaderNum = BQS_PalTex; + } + } + else + { + quad.Flags = 0; + quad.ShaderNum = BQS_Plain; + } + if (style.Flags & STYLEF_InvertSource) + { + quad.Flags |= BQF_InvertSource; + } + + if (parms.specialcolormap != nullptr) + { // Emulate an invulnerability or similar colormap. + float *start, *end; + start = parms.specialcolormap->ColorizeStart; + end = parms.specialcolormap->ColorizeEnd; + if (quad.Flags & BQF_InvertSource) + { + quad.Flags &= ~BQF_InvertSource; + swapvalues(start, end); + } + quad.ShaderNum = BQS_SpecialColormap; + color0 = ColorRGBA(uint32_t(start[0] / 2 * 255), uint32_t(start[1] / 2 * 255), uint32_t(start[2] / 2 * 255), color0 >> 24); + color1 = ColorRGBA(uint32_t(end[0] / 2 * 255), uint32_t(end[1] / 2 * 255), uint32_t(end[2] / 2 * 255), color1 >> 24); + } + else if (parms.colormapstyle != nullptr) + { // Emulate the fading from an in-game colormap (colorized, faded, and desaturated) + if (parms.colormapstyle->Desaturate != 0) + { + quad.Flags |= BQF_Desaturated; + } + quad.ShaderNum = BQS_InGameColormap; + quad.Desat = parms.colormapstyle->Desaturate; + color0 = ColorARGB(color1 >> 24, + parms.colormapstyle->Color.r, + parms.colormapstyle->Color.g, + parms.colormapstyle->Color.b); + double fadelevel = parms.colormapstyle->FadeLevel; + color1 = ColorARGB(uint32_t((1 - fadelevel) * 255), + uint32_t(parms.colormapstyle->Fade.r * fadelevel), + uint32_t(parms.colormapstyle->Fade.g * fadelevel), + uint32_t(parms.colormapstyle->Fade.b * fadelevel)); + } + } + + // For unmasked images, force the alpha from the image data to be ignored. + if (!parms.masked && quad.ShaderNum != BQS_InGameColormap) + { + color0 = (color0 & ColorRGBA(255, 255, 255, 0)) | ColorValue(0, 0, 0, alpha); + color1 &= ColorRGBA(255, 255, 255, 0); + + // If our alpha is one and we are doing normal adding, then we can turn the blend off completely. + if (quad.BlendOp == GL_FUNC_ADD && + ((alpha == 1 && quad.SrcBlend == GL_SRC_ALPHA) || quad.SrcBlend == GL_ONE) && + ((alpha == 1 && quad.DestBlend == GL_ONE_MINUS_SRC_ALPHA) || quad.DestBlend == GL_ZERO)) + { + quad.BlendOp = 0; + } + quad.Flags |= BQF_DisableAlphaTest; + } + return true; +} + +int OpenGLSWFrameBuffer::GetStyleAlpha(int type) +{ + switch (type) + { + case STYLEALPHA_Zero: return GL_ZERO; + case STYLEALPHA_One: return GL_ONE; + case STYLEALPHA_Src: return GL_SRC_ALPHA; + case STYLEALPHA_InvSrc: return GL_ONE_MINUS_SRC_ALPHA; + default: return GL_ZERO; + } +} + + +void OpenGLSWFrameBuffer::SetColorOverlay(uint32_t color, float alpha, uint32_t &color0, uint32_t &color1) +{ + if (APART(color) != 0) + { + int a = APART(color) * 256 / 255; + color0 = ColorRGBA( + (RPART(color) * a) >> 8, + (GPART(color) * a) >> 8, + (BPART(color) * a) >> 8, + 0); + a = 256 - a; + color1 = ColorRGBA(a, a, a, int(alpha * 255)); + } + else + { + color0 = 0; + color1 = ColorValue(1, 1, 1, alpha); + } +} + +void OpenGLSWFrameBuffer::EnableAlphaTest(BOOL enabled) +{ + if (enabled != AlphaTestEnabled) + { + AlphaTestEnabled = enabled; + //glEnable(GL_ALPHA_TEST); // To do: move to shader as this is only in the compatibility profile + } +} + +void OpenGLSWFrameBuffer::SetAlphaBlend(int op, int srcblend, int destblend) +{ + if (op == 0) + { // Disable alpha blend + if (AlphaBlendEnabled) + { + AlphaBlendEnabled = FALSE; + glDisable(GL_BLEND); + } + } + else + { // Enable alpha blend + assert(srcblend != 0); + assert(destblend != 0); + + if (!AlphaBlendEnabled) + { + AlphaBlendEnabled = TRUE; + glEnable(GL_BLEND); + } + if (AlphaBlendOp != op) + { + AlphaBlendOp = op; + glBlendEquation(op); + } + if (AlphaSrcBlend != srcblend || AlphaDestBlend != destblend) + { + AlphaSrcBlend = srcblend; + AlphaDestBlend = destblend; + glBlendFunc(srcblend, destblend); + } + } +} + +void OpenGLSWFrameBuffer::SetConstant(int cnum, float r, float g, float b, float a) +{ + if (Constant[cnum][0] != r || + Constant[cnum][1] != g || + Constant[cnum][2] != b || + Constant[cnum][3] != a) + { + Constant[cnum][0] = r; + Constant[cnum][1] = g; + Constant[cnum][2] = b; + Constant[cnum][3] = a; + SetPixelShaderConstantF(cnum, Constant[cnum], 1); + } +} + +void OpenGLSWFrameBuffer::SetPixelShader(HWPixelShader *shader) +{ + if (CurPixelShader != shader) + { + CurPixelShader = shader; + SetHWPixelShader(shader); + } +} + +void OpenGLSWFrameBuffer::SetTexture(int tnum, HWTexture *texture) +{ + assert(unsigned(tnum) < countof(Texture)); + if (texture) + { + if (Texture[tnum] != texture || SamplerWrapS[tnum] != texture->WrapS || SamplerWrapT[tnum] != texture->WrapT) + { + Texture[tnum] = texture; + glActiveTexture(GL_TEXTURE0 + tnum); + glBindTexture(GL_TEXTURE_2D, texture->Handle); + if (Texture[tnum]->WrapS != SamplerWrapS[tnum]) + { + Texture[tnum]->WrapS = SamplerWrapS[tnum]; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, SamplerWrapS[tnum]); + } + if (Texture[tnum]->WrapT != SamplerWrapT[tnum]) + { + Texture[tnum]->WrapT = SamplerWrapT[tnum]; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, SamplerWrapT[tnum]); + } + } + } + else if (Texture[tnum] != texture) + { + Texture[tnum] = texture; + glActiveTexture(GL_TEXTURE0 + tnum); + glBindTexture(GL_TEXTURE_2D, 0); + } +} + +void OpenGLSWFrameBuffer::SetSamplerWrapS(int tnum, int mode) +{ + assert(unsigned(tnum) < countof(Texture)); + if (Texture[tnum] && SamplerWrapS[tnum] != mode) + { + SamplerWrapS[tnum] = mode; + Texture[tnum]->WrapS = mode; + glActiveTexture(GL_TEXTURE0 + tnum); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, SamplerWrapS[tnum]); + } +} + +void OpenGLSWFrameBuffer::SetSamplerWrapT(int tnum, int mode) +{ + assert(unsigned(tnum) < countof(Texture)); + if (Texture[tnum] && SamplerWrapT[tnum] != mode) + { + SamplerWrapT[tnum] = mode; + Texture[tnum]->WrapT = mode; + glActiveTexture(GL_TEXTURE0 + tnum); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, SamplerWrapT[tnum]); + } +} + +void OpenGLSWFrameBuffer::SetPaletteTexture(HWTexture *texture, int count, uint32_t border_color) +{ + // The pixel shader receives color indexes in the range [0.0,1.0]. + // The palette texture is also addressed in the range [0.0,1.0], + // HOWEVER the coordinate 1.0 is the right edge of the texture and + // not actually the texture itself. We need to scale and shift + // the palette indexes so they lie exactly in the center of each + // texel. For a normal palette with 256 entries, that means the + // range we use should be [0.5,255.5], adjusted so the coordinate + // is still within [0.0,1.0]. + // + // The constant register c2 is used to hold the multiplier in the + // x part and the adder in the y part. + float fcount = 1 / float(count); + SetConstant(PSCONST_PaletteMod, 255 * fcount, 0.5f * fcount, 0, 0); + SetTexture(1, texture); +} diff --git a/src/gl/system/gl_swframebuffer.h b/src/gl/system/gl_swframebuffer.h new file mode 100644 index 000000000..30e7715ab --- /dev/null +++ b/src/gl/system/gl_swframebuffer.h @@ -0,0 +1,470 @@ +#ifndef __GL_SWFRAMEBUFFER +#define __GL_SWFRAMEBUFFER + +#ifdef _WIN32 +#include "win32iface.h" +#include "win32gliface.h" +#endif + +#include "SkylineBinPack.h" + +#include + +class FGLDebug; + +#ifdef _WIN32 +class OpenGLSWFrameBuffer : public Win32GLFrameBuffer +{ + typedef Win32GLFrameBuffer Super; + DECLARE_CLASS(OpenGLSWFrameBuffer, Win32GLFrameBuffer) +#else +#include "sdlglvideo.h" +class OpenGLFrameBuffer : public SDLGLFB +{ +// typedef SDLGLFB Super; //[C]commented, DECLARE_CLASS defines this in linux + DECLARE_CLASS(OpenGLSWFrameBuffer, SDLGLFB) +#endif + + +public: + + explicit OpenGLSWFrameBuffer() {} + OpenGLSWFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen); + ~OpenGLSWFrameBuffer(); + + bool IsValid() override; + bool Lock(bool buffered) override; + void Unlock() override; + void Update() override; + PalEntry *GetPalette() override; + void GetFlashedPalette(PalEntry palette[256]) override; + void UpdatePalette() override; + bool SetGamma(float gamma) override; + bool SetFlash(PalEntry rgb, int amount) override; + void GetFlash(PalEntry &rgb, int &amount) override; + int GetPageCount() override; + bool IsFullscreen() override; + void PaletteChanged() override; + int QueryNewPalette() override; + void Blank() override; + bool PaintToWindow() override; + void SetVSync(bool vsync) override; + void NewRefreshRate() override; + void GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &color_type) override; + void ReleaseScreenshotBuffer() override; + void SetBlendingRect(int x1, int y1, int x2, int y2) override; + bool Begin2D(bool copy3d) override; + void DrawBlendingRect() override; + FNativeTexture *CreateTexture(FTexture *gametex, bool wrapping) override; + FNativePalette *CreatePalette(FRemapTable *remap) override; + void DrawTextureParms(FTexture *img, DrawParms &parms) override; + void Clear(int left, int top, int right, int bottom, int palcolor, uint32 color) override; + void Dim(PalEntry color, float amount, int x1, int y1, int w, int h) override; + void FlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin) override; + void DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 realcolor) override; + void DrawPixel(int x, int y, int palcolor, uint32 rgbcolor) override; + void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, DAngle rotation, FDynamicColormap *colormap, int lightlevel) override; + //bool WipeStartScreen(int type) override; + //void WipeEndScreen() override; + //bool WipeDo(int ticks) override; + //void WipeCleanup() override; + bool Is8BitMode() override { return false; } + int GetTrueHeight() override { return TrueHeight; } + +private: + struct FBVERTEX + { + FLOAT x, y, z, rhw; + uint32_t color0, color1; + FLOAT tu, tv; + }; + //#define D3DFVF_FBVERTEX (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1) + + struct GammaRamp + { + uint16_t red[256], green[256], blue[256]; + }; + + struct LockedRect + { + int Pitch; + void *pBits; + }; + + struct LTRBRect + { + int left, top, right, bottom; + }; + + class HWSurface + { + public: + bool LockRect(LockedRect *outRect, LTRBRect *srcRect, bool discard) { outRect->Pitch = 0; outRect->pBits = nullptr; return false; } + void UnlockRect() { } + }; + + class HWTexture + { + public: + bool LockRect(LockedRect *outRect, LTRBRect *srcRect, bool discard) { outRect->Pitch = 0; outRect->pBits = nullptr; return false; } + void UnlockRect() { } + bool GetSurfaceLevel(int level, HWSurface **outSurface) { *outSurface = nullptr; return false; } + + int Handle = 0; + int WrapS = 0; + int WrapT = 0; + int Format = 0; + }; + + class HWVertexBuffer + { + public: + FBVERTEX *Lock() { return nullptr; } + void Unlock() { } + }; + + class HWIndexBuffer + { + public: + uint16_t *Lock() { return nullptr; } + void Unlock() { } + }; + + class HWPixelShader + { + public: + }; + + bool CreatePixelShader(const void *src, HWPixelShader **outShader) { *outShader = nullptr; return false; } + bool CreateVertexBuffer(int size, HWVertexBuffer **outVertexBuffer) { *outVertexBuffer = nullptr; return false; } + bool CreateIndexBuffer(int size, HWIndexBuffer **outIndexBuffer) { *outIndexBuffer = nullptr; return false; } + bool CreateOffscreenPlainSurface(int width, int height, int format, HWSurface **outSurface) { *outSurface = nullptr; return false; } + bool CreateTexture(int width, int height, int levels, int format, HWTexture **outTexture) { *outTexture = nullptr; return false; } + bool CreateRenderTarget(int width, int height, int format, HWSurface **outSurface) { *outSurface = nullptr; return false; } + bool GetBackBuffer(HWSurface **outSurface) { *outSurface = nullptr; return false; } + bool GetRenderTarget(int index, HWSurface **outSurface) { *outSurface = nullptr; return false; } + void GetRenderTargetData(HWSurface *a, HWSurface *b) { } + void ColorFill(HWSurface *surface, float red, float green, float blue) { } + void StretchRect(HWSurface *src, const LTRBRect *srcrect, HWSurface *dest) { } + bool SetRenderTarget(int index, HWSurface *surface) { return true; } + void SetGammaRamp(const GammaRamp *ramp) { } + void SetPixelShaderConstantF(int uniformIndex, const float *data, int vec4fcount) { } + void SetHWPixelShader(HWPixelShader *shader) { } + void SetStreamSource(HWVertexBuffer *vertexBuffer) { } + void SetIndices(HWIndexBuffer *indexBuffer) { } + void DrawTriangleFans(int count, const FBVERTEX *vertices) { } + void DrawPoints(int count, const FBVERTEX *vertices) { } + void DrawLineList(int count) { } + void DrawTriangleList(int minIndex, int numVertices, int startIndex, int primitiveCount) { } + void Present() { } + + static uint32_t ColorARGB(uint32_t a, uint32_t r, uint32_t g, uint32_t b) { return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | ((b) & 0xff); } + static uint32_t ColorRGBA(uint32_t a, uint32_t r, uint32_t g, uint32_t b) { return ColorARGB(a, r, g, b); } + static uint32_t ColorXRGB(uint32_t r, uint32_t g, uint32_t b) { return ColorARGB(0xff, r, g, b); } + static uint32_t ColorValue(float r, float g, float b, float a) { return ColorRGBA((uint32_t)(r * 255.0f), (uint32_t)(g * 255.0f), (uint32_t)(b * 255.0f), (uint32_t)(a * 255.0f)); } + + // The number of points for the vertex buffer. + enum { NUM_VERTS = 10240 }; + + // The number of indices for the index buffer. + enum { NUM_INDEXES = ((NUM_VERTS * 6) / 4) }; + + // The number of quads we can batch together. + enum { MAX_QUAD_BATCH = (NUM_INDEXES / 6) }; + + // The default size for a texture atlas. + enum { DEF_ATLAS_WIDTH = 512 }; + enum { DEF_ATLAS_HEIGHT = 512 }; + + // TYPES ------------------------------------------------------------------- + + struct Atlas; + + struct PackedTexture + { + Atlas *Owner; + + PackedTexture **Prev, *Next; + + // Pixels this image covers + LTRBRect Area; + + // Texture coordinates for this image + float Left, Top, Right, Bottom; + + // Texture has extra space on the border? + bool Padded; + }; + + struct Atlas + { + Atlas(OpenGLSWFrameBuffer *fb, int width, int height, int format); + ~Atlas(); + + PackedTexture *AllocateImage(const Rect &rect, bool padded); + void FreeBox(PackedTexture *box); + + SkylineBinPack Packer; + Atlas *Next; + HWTexture *Tex; + int Format; + PackedTexture *UsedList; // Boxes that contain images + int Width, Height; + bool OneUse; + }; + + class OpenGLTex : public FNativeTexture + { + public: + OpenGLTex(FTexture *tex, OpenGLSWFrameBuffer *fb, bool wrapping); + ~OpenGLTex(); + + FTexture *GameTex; + PackedTexture *Box; + + OpenGLTex **Prev; + OpenGLTex *Next; + + bool IsGray; + + bool Create(OpenGLSWFrameBuffer *fb, bool wrapping); + bool Update(); + bool CheckWrapping(bool wrapping); + int GetTexFormat(); + FTextureFormat ToTexFmt(int fmt); + }; + + class OpenGLPal : public FNativePalette + { + public: + OpenGLPal(FRemapTable *remap, OpenGLSWFrameBuffer *fb); + ~OpenGLPal(); + + OpenGLPal **Prev; + OpenGLPal *Next; + + HWTexture *Tex; + uint32_t BorderColor; + bool DoColorSkip; + + bool Update(); + + FRemapTable *Remap; + int RoundedPaletteSize; + }; + + // Flags for a buffered quad + enum + { + BQF_GamePalette = 1, + BQF_CustomPalette = 7, + BQF_Paletted = 7, + BQF_Bilinear = 8, + BQF_WrapUV = 16, + BQF_InvertSource = 32, + BQF_DisableAlphaTest = 64, + BQF_Desaturated = 128, + }; + + // Shaders for a buffered quad + enum + { + BQS_PalTex, + BQS_Plain, + BQS_RedToAlpha, + BQS_ColorOnly, + BQS_SpecialColormap, + BQS_InGameColormap, + }; + + struct PackedTexture; + struct Atlas; + + struct BufferedTris + { + union + { + struct + { + uint8_t Flags; + uint8_t ShaderNum : 4; + int BlendOp; + int SrcBlend, DestBlend; + }; + uint32_t Group1; + }; + uint8_t Desat; + OpenGLPal *Palette; + HWTexture *Texture; + uint16_t NumVerts; // Number of _unique_ vertices used by this set. + uint16_t NumTris; // Number of triangles used by this set. + }; + + enum + { + PSCONST_Desaturation = 1, + PSCONST_PaletteMod = 2, + PSCONST_Weights = 6, + PSCONST_Gamma = 7, + }; + enum + { + SHADER_NormalColor, + SHADER_NormalColorPal, + SHADER_NormalColorInv, + SHADER_NormalColorPalInv, + + SHADER_RedToAlpha, + SHADER_RedToAlphaInv, + + SHADER_VertexColor, + + SHADER_SpecialColormap, + SHADER_SpecialColormapPal, + + SHADER_InGameColormap, + SHADER_InGameColormapDesat, + SHADER_InGameColormapInv, + SHADER_InGameColormapInvDesat, + SHADER_InGameColormapPal, + SHADER_InGameColormapPalDesat, + SHADER_InGameColormapPalInv, + SHADER_InGameColormapPalInvDesat, + + SHADER_BurnWipe, + SHADER_GammaCorrection, + + NUM_SHADERS + }; + static const char *const ShaderNames[NUM_SHADERS]; + + void Flip(); + void SetInitialState(); + bool CreateResources(); + void ReleaseResources(); + bool LoadShaders(); + void CreateBlockSurfaces(); + bool CreateFBTexture(); + bool CreatePaletteTexture(); + bool CreateGammaTexture(); + bool CreateVertexes(); + void UploadPalette(); + void UpdateGammaTexture(float igamma); + void CalcFullscreenCoords(FBVERTEX verts[4], bool viewarea_only, bool can_double, uint32_t color0, uint32_t color1) const; + bool Reset(); + HWTexture *GetCurrentScreen(); + void ReleaseDefaultPoolItems(); + void KillNativePals(); + void KillNativeTexs(); + PackedTexture *AllocPackedTexture(int width, int height, bool wrapping, int format); + void DrawPackedTextures(int packnum); + void DrawLetterbox(); + void Draw3DPart(bool copy3d); + bool SetStyle(OpenGLTex *tex, DrawParms &parms, uint32_t &color0, uint32_t &color1, BufferedTris &quad); + static int GetStyleAlpha(int type); + static void SetColorOverlay(uint32_t color, float alpha, uint32_t &color0, uint32_t &color1); + void DoWindowedGamma(); + void AddColorOnlyQuad(int left, int top, int width, int height, uint32_t color); + void AddColorOnlyRect(int left, int top, int width, int height, uint32_t color); + void CheckQuadBatch(int numtris = 2, int numverts = 4); + void BeginQuadBatch(); + void EndQuadBatch(); + void BeginLineBatch(); + void EndLineBatch(); + void EndBatch(); + void CopyNextFrontBuffer(); + + // State + void EnableAlphaTest(BOOL enabled); + void SetAlphaBlend(int op, int srcblend = 0, int destblend = 0); + void SetConstant(int cnum, float r, float g, float b, float a); + void SetPixelShader(HWPixelShader *shader); + void SetTexture(int tnum, HWTexture *texture); + void SetSamplerWrapS(int tnum, int mode); + void SetSamplerWrapT(int tnum, int mode); + void SetPaletteTexture(HWTexture *texture, int count, uint32_t border_color); + + template static void SafeRelease(T &x) { if (x != nullptr) { delete x; x = nullptr; } } + + BOOL AlphaTestEnabled; + BOOL AlphaBlendEnabled; + int AlphaBlendOp; + int AlphaSrcBlend; + int AlphaDestBlend; + float Constant[3][4]; + uint32_t CurBorderColor; + HWPixelShader *CurPixelShader; + HWTexture *Texture[5]; + int SamplerWrapS[5], SamplerWrapT[5]; + + PalEntry SourcePalette[256]; + uint32_t BorderColor; + uint32_t FlashColor0, FlashColor1; + PalEntry FlashColor; + int FlashAmount; + int TrueHeight; + int PixelDoubling; + int SkipAt; + int LBOffsetI; + int RenderTextureToggle; + int CurrRenderTexture; + float LBOffset; + float Gamma; + bool UpdatePending; + bool NeedPalUpdate; + bool NeedGammaUpdate; + int FBWidth, FBHeight; + bool VSync; + LTRBRect BlendingRect; + int In2D; + bool InScene; + bool GatheringWipeScreen; + bool AALines; + uint8_t BlockNum; + OpenGLPal *Palettes; + OpenGLTex *Textures; + Atlas *Atlases; + + HWTexture *FBTexture; + HWTexture *TempRenderTexture, *RenderTexture[2]; + HWTexture *PaletteTexture; + HWTexture *GammaTexture; + HWTexture *ScreenshotTexture; + HWSurface *ScreenshotSurface; + HWSurface *FrontCopySurface; + + HWVertexBuffer *VertexBuffer; + FBVERTEX *VertexData; + HWIndexBuffer *IndexBuffer; + uint16_t *IndexData; + BufferedTris *QuadExtra; + int VertexPos; + int IndexPos; + int QuadBatchPos; + enum { BATCH_None, BATCH_Quads, BATCH_Lines } BatchType; + + HWPixelShader *Shaders[NUM_SHADERS]; + HWPixelShader *GammaShader; + + HWSurface *BlockSurface[2]; + HWSurface *OldRenderTarget; + HWTexture *InitialWipeScreen, *FinalWipeScreen; + + class Wiper + { + public: + virtual ~Wiper(); + virtual bool Run(int ticks, OpenGLSWFrameBuffer *fb) = 0; + + //void DrawScreen(OpenGLSWFrameBuffer *fb, HWTexture *tex, int blendop = 0, uint32_t color0 = 0, uint32_t color1 = 0xFFFFFFF); + }; + + class Wiper_Melt; friend class Wiper_Melt; + class Wiper_Burn; friend class Wiper_Burn; + class Wiper_Crossfade; friend class Wiper_Crossfade; + + Wiper *ScreenWipe; +}; + + +#endif //__GL_SWFRAMEBUFFER diff --git a/src/textures/textures.h b/src/textures/textures.h index 477c39ecc..af72dabc0 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -292,6 +292,7 @@ public: static void FlipNonSquareBlockRemap (BYTE *blockto, const BYTE *blockfrom, int x, int y, int srcpitch, const BYTE *remap); friend class D3DTex; + friend class OpenGLSWFrameBuffer; public: From 779e6acb7bed8b0fa265c85fc63e28d039808512 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sun, 9 Oct 2016 13:05:50 -0400 Subject: [PATCH 1054/1509] Create "final" two non-VR 3D modes: Column-interleaved and checkerboard. --- src/gl/renderer/gl_renderbuffers.h | 1 - src/gl/renderer/gl_renderer.cpp | 6 + src/gl/renderer/gl_renderer.h | 4 + src/gl/shaders/gl_present3dRowshader.cpp | 40 ++++-- src/gl/shaders/gl_present3dRowshader.h | 33 +++-- src/gl/shaders/gl_presentshader.cpp | 25 ++-- src/gl/shaders/gl_presentshader.h | 16 ++- src/gl/stereo3d/gl_interleaved3d.cpp | 133 +++++++++++++++--- src/gl/stereo3d/gl_interleaved3d.h | 21 ++- src/gl/stereo3d/gl_stereo_cvars.cpp | 6 + wadsrc/static/language.enu | 2 + wadsrc/static/menudef.zz | 2 + .../static/shaders/glsl/present_checker3d.fp | 37 +++++ .../static/shaders/glsl/present_column3d.fp | 35 +++++ wadsrc/static/shaders/glsl/present_row3d.fp | 6 +- 15 files changed, 300 insertions(+), 67 deletions(-) create mode 100644 wadsrc/static/shaders/glsl/present_checker3d.fp create mode 100644 wadsrc/static/shaders/glsl/present_column3d.fp diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 5fe05f5ac..4477718f4 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -2,7 +2,6 @@ #define __GL_RENDERBUFFERS_H #include "gl/shaders/gl_shader.h" -#include "gl/renderer/gl_renderer.h" class FGLBloomTextureLevel { diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index be1b96f15..0ffafef49 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -105,6 +105,8 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mTonemapPalette = nullptr; mBuffers = nullptr; mPresentShader = nullptr; + mPresent3dCheckerShader = nullptr; + mPresent3dColumnShader = nullptr; mPresent3dRowShader = nullptr; mBloomExtractShader = nullptr; mBloomCombineShader = nullptr; @@ -139,6 +141,8 @@ void FGLRenderer::Initialize(int width, int height) mFXAAShader = new FFXAAShader; mFXAALumaShader = new FFXAALumaShader; mPresentShader = new FPresentShader(); + mPresent3dCheckerShader = new FPresent3DCheckerShader(); + mPresent3dColumnShader = new FPresent3DColumnShader(); mPresent3dRowShader = new FPresent3DRowShader(); m2DDrawer = new F2DDrawer; @@ -192,6 +196,8 @@ FGLRenderer::~FGLRenderer() } if (mBuffers) delete mBuffers; if (mPresentShader) delete mPresentShader; + if (mPresent3dCheckerShader) delete mPresent3dCheckerShader; + if (mPresent3dColumnShader) delete mPresent3dColumnShader; if (mPresent3dRowShader) delete mPresent3dRowShader; if (mBloomExtractShader) delete mBloomExtractShader; if (mBloomCombineShader) delete mBloomCombineShader; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 65e31c52f..19bc93af0 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -31,6 +31,8 @@ class FLensShader; class FFXAALumaShader; class FFXAAShader; class FPresentShader; +class FPresent3DCheckerShader; +class FPresent3DColumnShader; class FPresent3DRowShader; class F2DDrawer; class FHardwareTexture; @@ -109,6 +111,8 @@ public: FFXAALumaShader *mFXAALumaShader; FFXAAShader *mFXAAShader; FPresentShader *mPresentShader; + FPresent3DCheckerShader *mPresent3dCheckerShader; + FPresent3DColumnShader *mPresent3dColumnShader; FPresent3DRowShader *mPresent3dRowShader; FTexture *gllight; diff --git a/src/gl/shaders/gl_present3dRowshader.cpp b/src/gl/shaders/gl_present3dRowshader.cpp index 607e4ede6..d8369a3b6 100644 --- a/src/gl/shaders/gl_present3dRowshader.cpp +++ b/src/gl/shaders/gl_present3dRowshader.cpp @@ -38,23 +38,37 @@ #include "gl/system/gl_cvars.h" #include "gl/shaders/gl_present3dRowshader.h" +void FPresentStereoShaderBase::Init(const char * vtx_shader_name, const char * program_name) +{ + FPresentShaderBase::Init(vtx_shader_name, program_name); + LeftEyeTexture.Init(mShader, "LeftEyeTexture"); + RightEyeTexture.Init(mShader, "RightEyeTexture"); + WindowPositionParity.Init(mShader, "WindowPositionParity"); +} + +void FPresent3DCheckerShader::Bind() +{ + if (!mShader) + { + Init("shaders/glsl/present_checker3d.fp", "shaders/glsl/presentChecker3d"); + } + mShader.Bind(); +} + +void FPresent3DColumnShader::Bind() +{ + if (!mShader) + { + Init("shaders/glsl/present_column3d.fp", "shaders/glsl/presentColumn3d"); + } + mShader.Bind(); +} + void FPresent3DRowShader::Bind() { if (!mShader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquadscale.vp", "", 330); - mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/present_row3d.fp", "", 330); - mShader.SetFragDataLocation(0, "FragColor"); - mShader.Link("shaders/glsl/presentRow3d"); - mShader.SetAttribLocation(0, "PositionInProjection"); - mShader.SetAttribLocation(1, "UV"); - LeftEyeTexture.Init(mShader, "LeftEyeTexture"); - RightEyeTexture.Init(mShader, "RightEyeTexture"); - InvGamma.Init(mShader, "InvGamma"); - Contrast.Init(mShader, "Contrast"); - Brightness.Init(mShader, "Brightness"); - Scale.Init(mShader, "UVScale"); - VerticalPixelOffset.Init(mShader, "VerticalPixelOffset"); + Init("shaders/glsl/present_row3d.fp", "shaders/glsl/presentRow3d"); } mShader.Bind(); } diff --git a/src/gl/shaders/gl_present3dRowshader.h b/src/gl/shaders/gl_present3dRowshader.h index 8e3bd772d..10419d7f5 100644 --- a/src/gl/shaders/gl_present3dRowshader.h +++ b/src/gl/shaders/gl_present3dRowshader.h @@ -29,22 +29,35 @@ #define GL_PRESENT3DROWSHADER_H_ #include "gl_shaderprogram.h" +#include "gl_presentshader.h" -class FPresent3DRowShader +class FPresentStereoShaderBase : public FPresentShaderBase { public: - void Bind(); - FBufferedUniformSampler LeftEyeTexture; FBufferedUniformSampler RightEyeTexture; - FBufferedUniform1f InvGamma; - FBufferedUniform1f Contrast; - FBufferedUniform1f Brightness; - FBufferedUniform2f Scale; - FBufferedUniform1i VerticalPixelOffset; + FBufferedUniform1i WindowPositionParity; -private: - FShaderProgram mShader; +protected: + void Init(const char * vtx_shader_name, const char * program_name) override; +}; + +class FPresent3DCheckerShader : public FPresentStereoShaderBase +{ +public: + void Bind() override; +}; + +class FPresent3DColumnShader : public FPresentStereoShaderBase +{ +public: + void Bind() override; +}; + +class FPresent3DRowShader : public FPresentStereoShaderBase +{ +public: + void Bind() override; }; // GL_PRESENT3DROWSHADER_H_ diff --git a/src/gl/shaders/gl_presentshader.cpp b/src/gl/shaders/gl_presentshader.cpp index 39d20d0fc..15acc74fb 100644 --- a/src/gl/shaders/gl_presentshader.cpp +++ b/src/gl/shaders/gl_presentshader.cpp @@ -36,21 +36,26 @@ #include "gl/system/gl_cvars.h" #include "gl/shaders/gl_presentshader.h" +void FPresentShaderBase::Init(const char * vtx_shader_name, const char * program_name) +{ + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquadscale.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, vtx_shader_name, "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link(program_name); + mShader.SetAttribLocation(0, "PositionInProjection"); + mShader.SetAttribLocation(1, "UV"); + InvGamma.Init(mShader, "InvGamma"); + Contrast.Init(mShader, "Contrast"); + Brightness.Init(mShader, "Brightness"); + Scale.Init(mShader, "UVScale"); +} + void FPresentShader::Bind() { if (!mShader) { - mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquadscale.vp", "", 330); - mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/present.fp", "", 330); - mShader.SetFragDataLocation(0, "FragColor"); - mShader.Link("shaders/glsl/present"); - mShader.SetAttribLocation(0, "PositionInProjection"); - mShader.SetAttribLocation(1, "UV"); + Init("shaders/glsl/present.fp", "shaders/glsl/present"); InputTexture.Init(mShader, "InputTexture"); - InvGamma.Init(mShader, "InvGamma"); - Contrast.Init(mShader, "Contrast"); - Brightness.Init(mShader, "Brightness"); - Scale.Init(mShader, "UVScale"); } mShader.Bind(); } diff --git a/src/gl/shaders/gl_presentshader.h b/src/gl/shaders/gl_presentshader.h index 6f4e899bb..6f9e1bfd7 100644 --- a/src/gl/shaders/gl_presentshader.h +++ b/src/gl/shaders/gl_presentshader.h @@ -3,19 +3,27 @@ #include "gl_shaderprogram.h" -class FPresentShader +class FPresentShaderBase { public: - void Bind(); + virtual void Bind() = 0; - FBufferedUniformSampler InputTexture; FBufferedUniform1f InvGamma; FBufferedUniform1f Contrast; FBufferedUniform1f Brightness; FBufferedUniform2f Scale; -private: +protected: + virtual void Init(const char * vtx_shader_name, const char * program_name); FShaderProgram mShader; }; +class FPresentShader : public FPresentShaderBase +{ +public: + void Bind() override; + + FBufferedUniformSampler InputTexture; +}; + #endif \ No newline at end of file diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp index 036a84b0b..029d233e4 100644 --- a/src/gl/stereo3d/gl_interleaved3d.cpp +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -43,10 +43,25 @@ EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) EXTERN_CVAR(Bool, fullscreen) -EXTERN_CVAR(Int, win_y) // pixel position of top of display window +EXTERN_CVAR(Int, win_x) // screen pixel position of left of display window +EXTERN_CVAR(Int, win_y) // screen pixel position of top of display window namespace s3d { +/* static */ +const CheckerInterleaved3D& CheckerInterleaved3D::getInstance(float ipd) +{ + static CheckerInterleaved3D instance(ipd); + return instance; +} + +/* static */ +const ColumnInterleaved3D& ColumnInterleaved3D::getInstance(float ipd) +{ + static ColumnInterleaved3D instance(ipd); + return instance; +} + /* static */ const RowInterleaved3D& RowInterleaved3D::getInstance(float ipd) { @@ -54,11 +69,7 @@ const RowInterleaved3D& RowInterleaved3D::getInstance(float ipd) return instance; } -RowInterleaved3D::RowInterleaved3D(double ipdMeters) - : TopBottom3D(ipdMeters) -{} - -void RowInterleaved3D::Present() const +static void prepareInterleavedPresent(FPresentStereoShaderBase& shader) { GLRenderer->mBuffers->BindOutputFB(); GLRenderer->ClearBorders(); @@ -79,27 +90,102 @@ void RowInterleaved3D::Present() const const GL_IRECT& box = GLRenderer->mOutputLetterbox; glViewport(box.left, box.top, box.width, box.height); - bool applyGamma = true; + shader.Bind(); + shader.LeftEyeTexture.Set(0); + shader.RightEyeTexture.Set(1); - GLRenderer->mPresent3dRowShader->Bind(); - GLRenderer->mPresent3dRowShader->LeftEyeTexture.Set(0); - GLRenderer->mPresent3dRowShader->RightEyeTexture.Set(1); - - if (!applyGamma || GLRenderer->framebuffer->IsHWGammaActive()) + if ( GLRenderer->framebuffer->IsHWGammaActive() ) { - GLRenderer->mPresent3dRowShader->InvGamma.Set(1.0f); - GLRenderer->mPresent3dRowShader->Contrast.Set(1.0f); - GLRenderer->mPresent3dRowShader->Brightness.Set(0.0f); + shader.InvGamma.Set(1.0f); + shader.Contrast.Set(1.0f); + shader.Brightness.Set(0.0f); } else { - GLRenderer->mPresent3dRowShader->InvGamma.Set(1.0f / clamp(Gamma, 0.1f, 4.f)); - GLRenderer->mPresent3dRowShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); - GLRenderer->mPresent3dRowShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); + shader.InvGamma.Set(1.0f / clamp(Gamma, 0.1f, 4.f)); + shader.Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); + shader.Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); } - GLRenderer->mPresent3dRowShader->Scale.Set( + shader.Scale.Set( GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(), GLRenderer->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight()); +} + +// fixme: I don't know how to get absolute window position on Mac and Linux +// fixme: I don't know how to get window border decoration size anywhere +// So for now I'll hard code the border effect on my test machine. +// Workaround for others is to fuss with vr_swap_eyes CVAR until it looks right. +// Presumably the top/left window border on my test machine has an odd number of pixels +// in the horizontal direction, and an even number in the vertical direction. +#define WINDOW_BORDER_HORIZONTAL_PARITY 1 +#define WINDOW_BORDER_VERTICAL_PARITY 0 + +void CheckerInterleaved3D::Present() const +{ + prepareInterleavedPresent(*GLRenderer->mPresent3dCheckerShader); + + // Compute absolute offset from top of screen to top of current display window + // because we need screen-relative, not window-relative, scan line parity + int windowVOffset = 0; + int windowHOffset = 0; + +#ifdef _WIN32 + if (!fullscreen) { + I_SaveWindowedPos(); // update win_y CVAR + windowHOffset = (win_x + WINDOW_BORDER_HORIZONTAL_PARITY) % 2; + windowVOffset = (win_y + WINDOW_BORDER_VERTICAL_PARITY) % 2; + } +#endif // _WIN32 + + GLRenderer->mPresent3dCheckerShader->WindowPositionParity.Set( + (windowVOffset + + windowHOffset + + GLRenderer->mOutputLetterbox.height + 1 // +1 because of origin at bottom + ) % 2 // because we want the top pixel offset, but gl_FragCoord.y is the bottom pixel offset + ); + + GLRenderer->RenderScreenQuad(); +} + +void s3d::CheckerInterleaved3D::AdjustViewports() const +{ + // decrease the total pixel count by 2, but keep the same aspect ratio + const float sqrt2 = 1.41421356237f; + // Change size of renderbuffer, and align to screen + GLRenderer->mSceneViewport.height /= sqrt2; + GLRenderer->mSceneViewport.top /= sqrt2; + GLRenderer->mSceneViewport.width /= sqrt2; + GLRenderer->mSceneViewport.left /= sqrt2; + + GLRenderer->mScreenViewport.height /= sqrt2; + GLRenderer->mScreenViewport.top /= sqrt2; + GLRenderer->mScreenViewport.width /= sqrt2; + GLRenderer->mScreenViewport.left /= sqrt2; +} + +void ColumnInterleaved3D::Present() const +{ + prepareInterleavedPresent(*GLRenderer->mPresent3dColumnShader); + + // Compute absolute offset from top of screen to top of current display window + // because we need screen-relative, not window-relative, scan line parity + int windowHOffset = 0; + +#ifdef _WIN32 + if (!fullscreen) { + I_SaveWindowedPos(); // update win_y CVAR + windowHOffset = (win_x + WINDOW_BORDER_HORIZONTAL_PARITY) % 2; + } +#endif // _WIN32 + + GLRenderer->mPresent3dColumnShader->WindowPositionParity.Set(windowHOffset); + + GLRenderer->RenderScreenQuad(); +} + +void RowInterleaved3D::Present() const +{ + prepareInterleavedPresent(*GLRenderer->mPresent3dRowShader); // Compute absolute offset from top of screen to top of current display window // because we need screen-relative, not window-relative, scan line parity @@ -108,13 +194,14 @@ void RowInterleaved3D::Present() const #ifdef _WIN32 if (! fullscreen) { I_SaveWindowedPos(); // update win_y CVAR - windowVOffset = win_y; + windowVOffset = (win_y + WINDOW_BORDER_VERTICAL_PARITY) % 2; } #endif // _WIN32 - GLRenderer->mPresent3dRowShader->VerticalPixelOffset.Set( - windowVOffset // fixme: vary with window location - + box.height % 2 // because we want the top pixel offset, but gl_FragCoord.y is the bottom pixel offset + GLRenderer->mPresent3dRowShader->WindowPositionParity.Set( + (windowVOffset + + GLRenderer->mOutputLetterbox.height + 1 // +1 because of origin at bottom + ) % 2 ); GLRenderer->RenderScreenQuad(); diff --git a/src/gl/stereo3d/gl_interleaved3d.h b/src/gl/stereo3d/gl_interleaved3d.h index 30aef7d5a..78bd19483 100644 --- a/src/gl/stereo3d/gl_interleaved3d.h +++ b/src/gl/stereo3d/gl_interleaved3d.h @@ -42,15 +42,30 @@ #include "gl/system/gl_system.h" #include "gl/renderer/gl_renderstate.h" -class FPresent3DRowShader; - namespace s3d { +class CheckerInterleaved3D : public SideBySideSquished +{ +public: + static const CheckerInterleaved3D& getInstance(float ipd); + CheckerInterleaved3D(double ipdMeters) : SideBySideSquished(ipdMeters) {} + void Present() const override; + void AdjustViewports() const override; +}; + +class ColumnInterleaved3D : public SideBySideSquished +{ +public: + static const ColumnInterleaved3D& getInstance(float ipd); + ColumnInterleaved3D(double ipdMeters) : SideBySideSquished(ipdMeters) {} + void Present() const override; +}; + class RowInterleaved3D : public TopBottom3D { public: static const RowInterleaved3D& getInstance(float ipd); - RowInterleaved3D(double ipdMeters); + RowInterleaved3D(double ipdMeters) : TopBottom3D(ipdMeters) {} void Present() const override; }; diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index 16296393d..fe5ae3261 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -107,6 +107,12 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() case 12: setCurrentMode(RowInterleaved3D::getInstance(vr_ipd)); break; + case 13: + setCurrentMode(ColumnInterleaved3D::getInstance(vr_ipd)); + break; + case 14: + setCurrentMode(CheckerInterleaved3D::getInstance(vr_ipd)); + break; case 0: default: setCurrentMode(MonoView::getInstance()); diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 83cddb8c5..a5ffb4a2c 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2707,6 +2707,8 @@ OPTVAL_SBSFULL = "Side-by-side Full"; OPTVAL_SBSNARROW = "Side-by-side Narrow"; OPTVAL_TOPBOTTOM = "Top/Bottom"; OPTVAL_ROWINTERLEAVED = "Row Interleaved"; +OPTVAL_COLUMNINTERLEAVED = "Column Interleaved"; +OPTVAL_CHECKERBOARD = "Checkerboard"; OPTVAL_QUADBUFFERED = "Quad-buffered"; OPTVAL_UNCHARTED2 = "Uncharted 2"; OPTVAL_HEJLDAWSON = "Hejl Dawson"; diff --git a/wadsrc/static/menudef.zz b/wadsrc/static/menudef.zz index 7e798a039..253f984eb 100644 --- a/wadsrc/static/menudef.zz +++ b/wadsrc/static/menudef.zz @@ -180,6 +180,8 @@ OptionValue VRMode 4, "$OPTVAL_SBSNARROW" 11, "$OPTVAL_TOPBOTTOM" 12, "$OPTVAL_ROWINTERLEAVED" + 13, "$OPTVAL_COLUMNINTERLEAVED" + 14, "$OPTVAL_CHECKERBOARD" 5, "$OPTVAL_LEFTEYE" 6, "$OPTVAL_RIGHTEYE" 7, "$OPTVAL_QUADBUFFERED" diff --git a/wadsrc/static/shaders/glsl/present_checker3d.fp b/wadsrc/static/shaders/glsl/present_checker3d.fp new file mode 100644 index 000000000..5247261e0 --- /dev/null +++ b/wadsrc/static/shaders/glsl/present_checker3d.fp @@ -0,0 +1,37 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D LeftEyeTexture; +uniform sampler2D RightEyeTexture; +uniform float InvGamma; +uniform float Contrast; +uniform float Brightness; +uniform int WindowPositionParity; // top-of-window might not be top-of-screen + +vec4 ApplyGamma(vec4 c) +{ + vec3 val = c.rgb * Contrast - (Contrast - 1.0) * 0.5; + val += Brightness * 0.5; + val = pow(max(val, vec3(0.0)), vec3(InvGamma)); + return vec4(val, c.a); +} + +void main() +{ + int thisVerticalPixel = int(gl_FragCoord.y); // Bottom row is typically the right eye, when WindowHeight is even + int thisHorizontalPixel = int(gl_FragCoord.x); // column + bool isLeftEye = (thisVerticalPixel // because we want to alternate eye view on each row + + thisHorizontalPixel // and each column + + WindowPositionParity // because the window might not be aligned to the screen + ) % 2 == 0; + vec4 inputColor; + if (isLeftEye) { + inputColor = texture(LeftEyeTexture, TexCoord); + } + else { + // inputColor = vec4(0, 1, 0, 1); + inputColor = texture(RightEyeTexture, TexCoord); + } + FragColor = ApplyGamma(inputColor); +} diff --git a/wadsrc/static/shaders/glsl/present_column3d.fp b/wadsrc/static/shaders/glsl/present_column3d.fp new file mode 100644 index 000000000..b46246cf0 --- /dev/null +++ b/wadsrc/static/shaders/glsl/present_column3d.fp @@ -0,0 +1,35 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D LeftEyeTexture; +uniform sampler2D RightEyeTexture; +uniform float InvGamma; +uniform float Contrast; +uniform float Brightness; +uniform int WindowPositionParity; // top-of-window might not be top-of-screen + +vec4 ApplyGamma(vec4 c) +{ + vec3 val = c.rgb * Contrast - (Contrast - 1.0) * 0.5; + val += Brightness * 0.5; + val = pow(max(val, vec3(0.0)), vec3(InvGamma)); + return vec4(val, c.a); +} + +void main() +{ + int thisHorizontalPixel = int(gl_FragCoord.x); // zero-based column index from left + bool isLeftEye = (thisHorizontalPixel // because we want to alternate eye view on each column + + WindowPositionParity // because the window might not be aligned to the screen + ) % 2 == 0; + vec4 inputColor; + if (isLeftEye) { + inputColor = texture(LeftEyeTexture, TexCoord); + } + else { + // inputColor = vec4(0, 1, 0, 1); + inputColor = texture(RightEyeTexture, TexCoord); + } + FragColor = ApplyGamma(inputColor); +} diff --git a/wadsrc/static/shaders/glsl/present_row3d.fp b/wadsrc/static/shaders/glsl/present_row3d.fp index 8ae72d1e0..50b27ac26 100644 --- a/wadsrc/static/shaders/glsl/present_row3d.fp +++ b/wadsrc/static/shaders/glsl/present_row3d.fp @@ -7,7 +7,7 @@ uniform sampler2D RightEyeTexture; uniform float InvGamma; uniform float Contrast; uniform float Brightness; -uniform int VerticalPixelOffset; // top-of-window might not be top-of-screen +uniform int WindowPositionParity; // top-of-window might not be top-of-screen vec4 ApplyGamma(vec4 c) { @@ -19,9 +19,9 @@ vec4 ApplyGamma(vec4 c) void main() { - int thisVerticalPixel = int(gl_FragCoord.y + 1.0); // Bottom row is typically the right eye, when WindowHeight is even + int thisVerticalPixel = int(gl_FragCoord.y); // Bottom row is typically the right eye, when WindowHeight is even bool isLeftEye = (thisVerticalPixel // because we want to alternate eye view on each row - + VerticalPixelOffset // because the window might not be aligned to the screen + + WindowPositionParity // because the window might not be aligned to the screen ) % 2 == 0; vec4 inputColor; if (isLeftEye) { From 1fab0cc5142e83958e70334ff6efc3395554c789 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Mon, 26 Sep 2016 07:24:37 -0400 Subject: [PATCH 1055/1509] - Added: PlayerPawn property "Player.ViewBob" which acts as a MoveBob/StillBob multiplier. --- src/d_player.h | 3 +++ src/p_pspr.cpp | 5 +++-- src/p_user.cpp | 8 +++++--- src/thingdef/thingdef_properties.cpp | 20 ++++++++++++++++++++ wadsrc/static/actors/shared/player.txt | 1 + 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index e944d6734..7f57837c7 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -168,6 +168,9 @@ public: // [CW] Fades for when you are being damaged. PalEntry DamageFade; + // [SP] ViewBob Multiplier + double ViewBob; + bool UpdateWaterLevel (bool splash); bool ResetAirSupply (bool playgasp = true); diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index fab7e38d8..e97d2c020 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -582,8 +582,9 @@ void P_BobWeapon (player_t *player, float *x, float *y, double ticfrac) if (curbob != 0) { - float bobx = float(player->bob * Rangex); - float boby = float(player->bob * Rangey); + //[SP] Added in decorate player.viewbob checks + float bobx = float(player->bob * Rangex * (float)player->mo->ViewBob); + float boby = float(player->bob * Rangey * (float)player->mo->ViewBob); switch (bobstyle) { case AWeapon::BobNormal: diff --git a/src/p_user.cpp b/src/p_user.cpp index 0f3b6a516..845cf9a5f 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -651,7 +651,8 @@ void APlayerPawn::Serialize(FSerializer &arc) ("fallingscreammaxn", FallingScreamMaxSpeed, def->FallingScreamMaxSpeed) ("userange", UseRange, def->UseRange) ("aircapacity", AirCapacity, def->AirCapacity) - ("viewheight", ViewHeight, def->ViewHeight); + ("viewheight", ViewHeight, def->ViewHeight) + ("viewbob", ViewBob, def->ViewBob); } //=========================================================================== @@ -1844,11 +1845,12 @@ void P_CalcHeight (player_t *player) return; } + //[SP] Added (x*player->mo->ViewBob) to allow DECORATE changes to view bobbing speed. if (still) { if (player->health > 0) { - angle = level.time / (120 * TICRATE / 35.) * 360.; + angle = level.time / (120 * TICRATE / 35.) * 360. * player->mo->ViewBob; bob = player->userinfo.GetStillBob() * angle.Sin(); } else @@ -1858,7 +1860,7 @@ void P_CalcHeight (player_t *player) } else { - angle = level.time / (20 * TICRATE / 35.) * 360.; + angle = level.time / (20 * TICRATE / 35.) * 360. * player->mo->ViewBob; bob = player->bob * angle.Sin() * (player->mo->waterlevel > 1 ? 0.25f : 0.5f); } diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index d60cda823..5b014bf28 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -2945,6 +2945,26 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, weaponslot, ISsssssssssssssssssssssssssssss } } +//========================================================================== +// +// [SP] Player.Viewbob +// +//========================================================================== +DEFINE_CLASS_PROPERTY_PREFIX(player, viewbob, F, PlayerPawn) +{ + PROP_DOUBLE_PARM(z, 0); + // [SP] Hard limits. This is to prevent terrywads from making players sick. + // Remember - this messes with a user option who probably has it set a + // certain way for a reason. I think a 1.5 limit is pretty generous, but + // it may be safe to increase it. I really need opinions from people who + // could be affected by this. + if (z < 0.0 || z > 1.5) + { + I_Error("ViewBob must be between 0.0 and 1.5."); + } + defaults->ViewBob = z; +} + //========================================================================== // //========================================================================== diff --git a/wadsrc/static/actors/shared/player.txt b/wadsrc/static/actors/shared/player.txt index ac5ceb0a7..08d9a252a 100644 --- a/wadsrc/static/actors/shared/player.txt +++ b/wadsrc/static/actors/shared/player.txt @@ -33,6 +33,7 @@ Actor PlayerPawn : Actor native Player.MugShotMaxHealth 0 Player.FlechetteType "ArtiPoisonBag3" Player.AirCapacity 1 + Player.ViewBob 1 Obituary "$OB_MPDEFAULT" } From 40df46f94e250000f471870229931a00a027b32f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 10 Oct 2016 07:39:02 +0200 Subject: [PATCH 1056/1509] Implement OpenGL versions of GPU objects --- src/gl/system/gl_swframebuffer.cpp | 313 +++++++++++++++++++++++++---- src/gl/system/gl_swframebuffer.h | 75 ++++--- 2 files changed, 327 insertions(+), 61 deletions(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index e0ff2be47..e03f1fd9c 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -92,30 +92,30 @@ IMPLEMENT_CLASS(OpenGLSWFrameBuffer) const char *const OpenGLSWFrameBuffer::ShaderNames[OpenGLSWFrameBuffer::NUM_SHADERS] = { - "NormalColor.fp", - "NormalColorPal.fp", - "NormalColorInv.fp", - "NormalColorPalInv.fp", + "NormalColor", + "NormalColorPal", + "NormalColorInv", + "NormalColorPalInv", - "RedToAlpha.fp", - "RedToAlphaInv.fp", + "RedToAlpha", + "RedToAlphaInv", - "VertexColor.fp", + "VertexColor", - "SpecialColormap.fp", - "SpecialColorMapPal.fp", + "SpecialColormap", + "SpecialColorMapPal", - "InGameColormap.fp", - "InGameColormapDesat.fp", - "InGameColormapInv.fp", - "InGameColormapInvDesat.fp", - "InGameColormapPal.fp", - "InGameColormapPalDesat.fp", - "InGameColormapPalInv.fp", - "InGameColormapPalInvDesat.fp", + "InGameColormap", + "InGameColormapDesat", + "InGameColormapInv", + "InGameColormapInvDesat", + "InGameColormapPal", + "InGameColormapPalDesat", + "InGameColormapPalInv", + "InGameColormapPalInvDesat", - "BurnWipe.fp", - "GammaCorrection.fp", + "BurnWipe", + "GammaCorrection", }; OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : @@ -209,6 +209,256 @@ OpenGLSWFrameBuffer::~OpenGLSWFrameBuffer() delete[] QuadExtra; } +bool OpenGLSWFrameBuffer::CreatePixelShader(const void *vertexsrc, const void *fragmentsrc, HWPixelShader **outShader) +{ + auto shader = std::make_unique(); + + shader->Program = glCreateProgram(); + shader->VertexShader = glCreateShader(GL_VERTEX_SHADER); + shader->FragmentShader = glCreateShader(GL_FRAGMENT_SHADER); + + { + int lengths[1] = { (int)strlen((const char*)vertexsrc) }; + const char *sources[1] = { (const char*)vertexsrc }; + glShaderSource(shader->VertexShader, 1, sources, lengths); + glCompileShader(shader->VertexShader); + } + + { + int lengths[1] = { (int)strlen((const char*)fragmentsrc) }; + const char *sources[1] = { (const char*)fragmentsrc }; + glShaderSource(shader->FragmentShader, 1, sources, lengths); + glCompileShader(shader->FragmentShader); + } + + GLint status = 0; + glGetShaderiv(shader->VertexShader, GL_COMPILE_STATUS, &status); + if (status != GL_FALSE) glGetShaderiv(shader->FragmentShader, GL_COMPILE_STATUS, &status); + if (status == GL_FALSE) + { + *outShader = nullptr; + return false; + } + + glAttachShader(shader->Program, shader->VertexShader); + glAttachShader(shader->Program, shader->FragmentShader); + glBindFragDataLocation(shader->Program, 0, "FragColor"); + glLinkProgram(shader->Program); + glGetProgramiv(shader->Program, GL_LINK_STATUS, &status); + if (status == GL_FALSE) + { + *outShader = nullptr; + return false; + } + glBindAttribLocation(shader->Program, 0, "Position"); + glBindAttribLocation(shader->Program, 1, "Color0"); + glBindAttribLocation(shader->Program, 2, "Color1"); + glBindAttribLocation(shader->Program, 3, "TexCoord"); + + *outShader = shader.release(); + return true; +} + +bool OpenGLSWFrameBuffer::CreateVertexBuffer(int size, HWVertexBuffer **outVertexBuffer) +{ + auto obj = std::make_unique(); + + GLint oldBinding = 0; + glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &oldBinding); + + glGenVertexArrays(1, (GLuint*)&obj->VertexArray); + glGenBuffers(1, (GLuint*)&obj->Buffer); + glBindVertexArray(obj->VertexArray); + glBindBuffer(GL_ARRAY_BUFFER, obj->Buffer); + glBufferData(GL_ARRAY_BUFFER, size, nullptr, GL_STREAM_DRAW); + glEnableVertexAttribArray(0); + glEnableVertexAttribArray(1); + glEnableVertexAttribArray(2); + glEnableVertexAttribArray(3); + glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(FBVERTEX), (const GLvoid*)offsetof(FBVERTEX, x)); + glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(FBVERTEX), (const GLvoid*)offsetof(FBVERTEX, color0)); + glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(FBVERTEX), (const GLvoid*)offsetof(FBVERTEX, color1)); + glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(FBVERTEX), (const GLvoid*)offsetof(FBVERTEX, tu)); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(oldBinding); + + *outVertexBuffer = obj.release(); + return true; +} + +bool OpenGLSWFrameBuffer::CreateIndexBuffer(int size, HWIndexBuffer **outIndexBuffer) +{ + auto obj = std::make_unique(); + + GLint oldBinding = 0; + glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &oldBinding); + + glGenBuffers(1, (GLuint*)&obj->Buffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, obj->Buffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, nullptr, GL_STREAM_DRAW); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, oldBinding); + + *outIndexBuffer = obj.release(); + return true; +} + +bool OpenGLSWFrameBuffer::CreateTexture(int width, int height, int levels, int format, HWTexture **outTexture) +{ + auto obj = std::make_unique(); + + GLint oldBinding = 0; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldBinding); + + glGenTextures(1, (GLuint*)&obj->Texture); + glBindTexture(GL_TEXTURE_2D, obj->Texture); + GLenum srcformat; + switch (format) + { + case GL_R8: srcformat = GL_RED; break; + case GL_RGBA8: srcformat = GL_RGBA; break; + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: srcformat = GL_RGB; break; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: srcformat = GL_RGBA; break; + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: srcformat = GL_RGBA; break; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: srcformat = GL_RGBA; break; + default: + I_FatalError("Unknown format passed to CreateTexture"); + return false; + } + glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, srcformat, GL_UNSIGNED_BYTE, nullptr); + + glBindTexture(GL_TEXTURE_2D, oldBinding); + + *outTexture = obj.release(); + return true; +} + +bool OpenGLSWFrameBuffer::CreateOffscreenPlainSurface(int width, int height, int format, HWSurface **outSurface) { *outSurface = nullptr; return false; } +bool OpenGLSWFrameBuffer::CreateRenderTarget(int width, int height, int format, HWSurface **outSurface) { *outSurface = nullptr; return false; } +bool OpenGLSWFrameBuffer::GetBackBuffer(HWSurface **outSurface) { *outSurface = nullptr; return false; } +bool OpenGLSWFrameBuffer::GetRenderTarget(int index, HWSurface **outSurface) { *outSurface = nullptr; return false; } +void OpenGLSWFrameBuffer::GetRenderTargetData(HWSurface *a, HWSurface *b) { } + +void OpenGLSWFrameBuffer::ColorFill(HWSurface *surface, float red, float green, float blue) { } +void OpenGLSWFrameBuffer::StretchRect(HWSurface *src, const LTRBRect *srcrect, HWSurface *dest) { } +bool OpenGLSWFrameBuffer::SetRenderTarget(int index, HWSurface *surface) { return true; } +void OpenGLSWFrameBuffer::SetGammaRamp(const GammaRamp *ramp) { } + +void OpenGLSWFrameBuffer::SetPixelShaderConstantF(int uniformIndex, const float *data, int vec4fcount) +{ + glUniform4fv(uniformIndex, vec4fcount, data); +} + +void OpenGLSWFrameBuffer::SetHWPixelShader(HWPixelShader *shader) +{ + if (shader) + glUseProgram(shader->Program); + else + glUseProgram(0); +} + +void OpenGLSWFrameBuffer::SetStreamSource(HWVertexBuffer *vertexBuffer) +{ + if (vertexBuffer) + glBindVertexArray(vertexBuffer->VertexArray); + else + glBindVertexArray(0); +} + +void OpenGLSWFrameBuffer::SetIndices(HWIndexBuffer *indexBuffer) +{ + if (indexBuffer) + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer->Buffer); + else + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); +} + +void OpenGLSWFrameBuffer::DrawTriangleFans(int count, const FBVERTEX *vertices) +{ + GLint oldBinding = 0; + glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &oldBinding); + + if (!StreamVertexBuffer) + { + StreamVertexBuffer = std::make_unique(); + glGenVertexArrays(1, (GLuint*)&StreamVertexBuffer->VertexArray); + glGenBuffers(1, (GLuint*)&StreamVertexBuffer->Buffer); + glBindVertexArray(StreamVertexBuffer->VertexArray); + glBindBuffer(GL_ARRAY_BUFFER, StreamVertexBuffer->Buffer); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(FBVERTEX), vertices, GL_STREAM_DRAW); + glEnableVertexAttribArray(0); + glEnableVertexAttribArray(1); + glEnableVertexAttribArray(2); + glEnableVertexAttribArray(3); + glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(FBVERTEX), (const GLvoid*)offsetof(FBVERTEX, x)); + glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(FBVERTEX), (const GLvoid*)offsetof(FBVERTEX, color0)); + glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(FBVERTEX), (const GLvoid*)offsetof(FBVERTEX, color1)); + glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(FBVERTEX), (const GLvoid*)offsetof(FBVERTEX, tu)); + } + else + { + glBindVertexArray(StreamVertexBuffer->VertexArray); + glBindBuffer(GL_ARRAY_BUFFER, StreamVertexBuffer->Buffer); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(FBVERTEX), vertices, GL_STREAM_DRAW); + } + + glDrawArrays(GL_TRIANGLE_FAN, 0, count); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(oldBinding); +} + +void OpenGLSWFrameBuffer::DrawPoints(int count, const FBVERTEX *vertices) +{ + GLint oldBinding = 0; + glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &oldBinding); + + if (!StreamVertexBuffer) + { + StreamVertexBuffer = std::make_unique(); + glGenVertexArrays(1, (GLuint*)&StreamVertexBuffer->VertexArray); + glGenBuffers(1, (GLuint*)&StreamVertexBuffer->Buffer); + glBindVertexArray(StreamVertexBuffer->VertexArray); + glBindBuffer(GL_ARRAY_BUFFER, StreamVertexBuffer->Buffer); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(FBVERTEX), vertices, GL_STREAM_DRAW); + glEnableVertexAttribArray(0); + glEnableVertexAttribArray(1); + glEnableVertexAttribArray(2); + glEnableVertexAttribArray(3); + glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(FBVERTEX), (const GLvoid*)offsetof(FBVERTEX, x)); + glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(FBVERTEX), (const GLvoid*)offsetof(FBVERTEX, color0)); + glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(FBVERTEX), (const GLvoid*)offsetof(FBVERTEX, color1)); + glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(FBVERTEX), (const GLvoid*)offsetof(FBVERTEX, tu)); + } + else + { + glBindVertexArray(StreamVertexBuffer->VertexArray); + glBindBuffer(GL_ARRAY_BUFFER, StreamVertexBuffer->Buffer); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(FBVERTEX), vertices, GL_STREAM_DRAW); + } + + glDrawArrays(GL_POINTS, 0, count); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(oldBinding); +} + +void OpenGLSWFrameBuffer::DrawLineList(int count) +{ + glDrawArrays(GL_LINES, 0, count); +} + +void OpenGLSWFrameBuffer::DrawTriangleList(int minIndex, int numVertices, int startIndex, int primitiveCount) +{ + glDrawRangeElements(GL_TRIANGLES, minIndex, minIndex + numVertices - 1, primitiveCount * 3, GL_UNSIGNED_SHORT, (const void*)(startIndex * sizeof(uint16_t))); +} + +void OpenGLSWFrameBuffer::Present() +{ + SwapBuffers(); +} + //========================================================================== // // OpenGLSWFrameBuffer :: SetInitialState @@ -274,7 +524,6 @@ bool OpenGLSWFrameBuffer::CreateResources() { return false; } - CreateGammaTexture(); CreateBlockSurfaces(); return true; } @@ -293,7 +542,7 @@ bool OpenGLSWFrameBuffer::LoadShaders() static const char models[][4] = { "30/", "20/", "14/" }; FString shaderdir, shaderpath; unsigned model, i; - int lump; + int lump, lumpvert; // We determine the best available model simply by trying them all in // order of decreasing preference. @@ -304,12 +553,13 @@ bool OpenGLSWFrameBuffer::LoadShaders() for (i = 0; i < NUM_SHADERS; ++i) { shaderpath = shaderdir; - shaderpath += ShaderNames[i]; - lump = Wads.CheckNumForFullName(shaderpath); - if (lump >= 0) + lump = Wads.CheckNumForFullName(shaderpath + ShaderNames[i] + ".fp"); + lumpvert = Wads.CheckNumForFullName(shaderpath + ShaderNames[i] + ".vp"); + if (lump >= 0 && lumpvert >= 0) { FMemLump data = Wads.ReadLump(lump); - if (!CreatePixelShader((uint32_t *)data.GetMem(), &Shaders[i]) && i < SHADER_BurnWipe) + FMemLump datavert = Wads.ReadLump(lumpvert); + if (!CreatePixelShader(datavert.GetMem(), data.GetMem(), &Shaders[i]) && i < SHADER_BurnWipe) { break; } @@ -533,17 +783,6 @@ bool OpenGLSWFrameBuffer::CreatePaletteTexture() return true; } -//========================================================================== -// -// OpenGLSWFrameBuffer :: CreateGammaTexture -// -//========================================================================== - -bool OpenGLSWFrameBuffer::CreateGammaTexture() -{ - return false; -} - //========================================================================== // // OpenGLSWFrameBuffer :: CreateVertexes @@ -3293,7 +3532,7 @@ void OpenGLSWFrameBuffer::SetTexture(int tnum, HWTexture *texture) { Texture[tnum] = texture; glActiveTexture(GL_TEXTURE0 + tnum); - glBindTexture(GL_TEXTURE_2D, texture->Handle); + glBindTexture(GL_TEXTURE_2D, texture->Texture); if (Texture[tnum]->WrapS != SamplerWrapS[tnum]) { Texture[tnum]->WrapS = SamplerWrapS[tnum]; diff --git a/src/gl/system/gl_swframebuffer.h b/src/gl/system/gl_swframebuffer.h index 30e7715ab..14ed2ec13 100644 --- a/src/gl/system/gl_swframebuffer.h +++ b/src/gl/system/gl_swframebuffer.h @@ -110,7 +110,7 @@ private: void UnlockRect() { } bool GetSurfaceLevel(int level, HWSurface **outSurface) { *outSurface = nullptr; return false; } - int Handle = 0; + int Texture = 0; int WrapS = 0; int WrapT = 0; int Format = 0; @@ -119,44 +119,70 @@ private: class HWVertexBuffer { public: + ~HWVertexBuffer() + { + if (Buffer != 0) glDeleteVertexArrays(1, (GLuint*)&VertexArray); + if (Buffer != 0) glDeleteBuffers(1, (GLuint*)&Buffer); + } + FBVERTEX *Lock() { return nullptr; } void Unlock() { } + + int Buffer = 0; + int VertexArray = 0; }; class HWIndexBuffer { public: + ~HWIndexBuffer() + { + if (Buffer != 0) glDeleteBuffers(1, (GLuint*)&Buffer); + } + uint16_t *Lock() { return nullptr; } void Unlock() { } + + int Buffer = 0; }; class HWPixelShader { public: + ~HWPixelShader() + { + if (Program != 0) glDeleteProgram(Program); + if (VertexShader != 0) glDeleteShader(VertexShader); + if (FragmentShader != 0) glDeleteShader(FragmentShader); + } + + int Program = 0; + int VertexShader = 0; + int FragmentShader = 0; }; - bool CreatePixelShader(const void *src, HWPixelShader **outShader) { *outShader = nullptr; return false; } - bool CreateVertexBuffer(int size, HWVertexBuffer **outVertexBuffer) { *outVertexBuffer = nullptr; return false; } - bool CreateIndexBuffer(int size, HWIndexBuffer **outIndexBuffer) { *outIndexBuffer = nullptr; return false; } - bool CreateOffscreenPlainSurface(int width, int height, int format, HWSurface **outSurface) { *outSurface = nullptr; return false; } - bool CreateTexture(int width, int height, int levels, int format, HWTexture **outTexture) { *outTexture = nullptr; return false; } - bool CreateRenderTarget(int width, int height, int format, HWSurface **outSurface) { *outSurface = nullptr; return false; } - bool GetBackBuffer(HWSurface **outSurface) { *outSurface = nullptr; return false; } - bool GetRenderTarget(int index, HWSurface **outSurface) { *outSurface = nullptr; return false; } - void GetRenderTargetData(HWSurface *a, HWSurface *b) { } - void ColorFill(HWSurface *surface, float red, float green, float blue) { } - void StretchRect(HWSurface *src, const LTRBRect *srcrect, HWSurface *dest) { } - bool SetRenderTarget(int index, HWSurface *surface) { return true; } - void SetGammaRamp(const GammaRamp *ramp) { } - void SetPixelShaderConstantF(int uniformIndex, const float *data, int vec4fcount) { } - void SetHWPixelShader(HWPixelShader *shader) { } - void SetStreamSource(HWVertexBuffer *vertexBuffer) { } - void SetIndices(HWIndexBuffer *indexBuffer) { } - void DrawTriangleFans(int count, const FBVERTEX *vertices) { } - void DrawPoints(int count, const FBVERTEX *vertices) { } - void DrawLineList(int count) { } - void DrawTriangleList(int minIndex, int numVertices, int startIndex, int primitiveCount) { } - void Present() { } + bool CreatePixelShader(const void *vertexsrc, const void *fragmentsrc, HWPixelShader **outShader); + bool CreateVertexBuffer(int size, HWVertexBuffer **outVertexBuffer); + bool CreateIndexBuffer(int size, HWIndexBuffer **outIndexBuffer); + bool CreateOffscreenPlainSurface(int width, int height, int format, HWSurface **outSurface); + bool CreateTexture(int width, int height, int levels, int format, HWTexture **outTexture); + bool CreateRenderTarget(int width, int height, int format, HWSurface **outSurface); + bool GetBackBuffer(HWSurface **outSurface); + bool GetRenderTarget(int index, HWSurface **outSurface); + void GetRenderTargetData(HWSurface *a, HWSurface *b); + void ColorFill(HWSurface *surface, float red, float green, float blue); + void StretchRect(HWSurface *src, const LTRBRect *srcrect, HWSurface *dest); + bool SetRenderTarget(int index, HWSurface *surface); + void SetGammaRamp(const GammaRamp *ramp); + void SetPixelShaderConstantF(int uniformIndex, const float *data, int vec4fcount); + void SetHWPixelShader(HWPixelShader *shader); + void SetStreamSource(HWVertexBuffer *vertexBuffer); + void SetIndices(HWIndexBuffer *indexBuffer); + void DrawTriangleFans(int count, const FBVERTEX *vertices); + void DrawPoints(int count, const FBVERTEX *vertices); + void DrawLineList(int count); + void DrawTriangleList(int minIndex, int numVertices, int startIndex, int primitiveCount); + void Present(); static uint32_t ColorARGB(uint32_t a, uint32_t r, uint32_t g, uint32_t b) { return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | ((b) & 0xff); } static uint32_t ColorRGBA(uint32_t a, uint32_t r, uint32_t g, uint32_t b) { return ColorARGB(a, r, g, b); } @@ -346,7 +372,6 @@ private: void CreateBlockSurfaces(); bool CreateFBTexture(); bool CreatePaletteTexture(); - bool CreateGammaTexture(); bool CreateVertexes(); void UploadPalette(); void UpdateGammaTexture(float igamma); @@ -386,6 +411,8 @@ private: template static void SafeRelease(T &x) { if (x != nullptr) { delete x; x = nullptr; } } + std::unique_ptr StreamVertexBuffer; + BOOL AlphaTestEnabled; BOOL AlphaBlendEnabled; int AlphaBlendOp; From f4308b3184ea1f5ad15f3883c60be7cf2f6515bc Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 10 Oct 2016 21:03:55 +0200 Subject: [PATCH 1057/1509] Add glsl shader version of the d3d9 shaders and get enough of it working for it to boot without errors --- src/gl/system/gl_swframebuffer.cpp | 616 ++++++++++--------------- src/gl/system/gl_swframebuffer.h | 99 ++-- src/win32/hardware.cpp | 5 +- src/win32/win32gliface.cpp | 6 +- wadsrc/static/shaders/glsl/swshader.fp | 146 ++++++ wadsrc/static/shaders/glsl/swshader.vp | 17 + 6 files changed, 435 insertions(+), 454 deletions(-) create mode 100644 wadsrc/static/shaders/glsl/swshader.fp create mode 100644 wadsrc/static/shaders/glsl/swshader.vp diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index e03f1fd9c..895508d8b 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -71,7 +71,6 @@ #include "gl/utility/gl_templates.h" #include "gl/gl_functions.h" -CVAR(Bool, gl_antilag, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Int, gl_showpacks, 0, 0) #ifndef WIN32 // Defined in fb_d3d9 for Windows CVAR(Bool, vid_hwaalines, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) @@ -88,63 +87,66 @@ EXTERN_CVAR(Int, vid_refreshrate) extern cycle_t BlitCycles; +void gl_LoadExtensions(); + IMPLEMENT_CLASS(OpenGLSWFrameBuffer) -const char *const OpenGLSWFrameBuffer::ShaderNames[OpenGLSWFrameBuffer::NUM_SHADERS] = +const char *const OpenGLSWFrameBuffer::ShaderDefines[OpenGLSWFrameBuffer::NUM_SHADERS] = { - "NormalColor", - "NormalColorPal", - "NormalColorInv", - "NormalColorPalInv", + "#define ENORMALCOLOR\n#define PALTEX 0\n#define DINVERT 0", // NormalColor + "#define ENORMALCOLOR\n#define PALTEX 1\n#define INVERT 0", // NormalColorPal + "#define ENORMALCOLOR\n#define PALTEX 0\n#define INVERT 1", // NormalColorInv + "#define ENORMALCOLOR\n#define PALTEX 1\n#define INVERT 1", // NormalColorPalInv - "RedToAlpha", - "RedToAlphaInv", + "#define EREDTOALPHA\n#define INVERT 0", // RedToAlpha + "#define EREDTOALPHA\n#define INVERT 1", // RedToAlphaInv - "VertexColor", + "#define EVERTEXCOLOR", // VertexColor - "SpecialColormap", - "SpecialColorMapPal", + "#define ESPECIALCOLORMAP\n#define PALTEX 0\n#define INVERT 0", // SpecialColormap + "#define ESPECIALCOLORMAP\n#define PALTEX 1\n#define INVERT 0", // SpecialColorMapPal - "InGameColormap", - "InGameColormapDesat", - "InGameColormapInv", - "InGameColormapInvDesat", - "InGameColormapPal", - "InGameColormapPalDesat", - "InGameColormapPalInv", - "InGameColormapPalInvDesat", + "#define EINGAMECOLORMAP\n#define PALTEX 0\n#define INVERT 0\n#define DESAT 0", // InGameColormap + "#define EINGAMECOLORMAP\n#define PALTEX 0\n#define INVERT 0\n#define DESAT 1", // InGameColormapDesat + "#define EINGAMECOLORMAP\n#define PALTEX 0\n#define INVERT 1\n#define DESAT 0", // InGameColormapInv + "#define EINGAMECOLORMAP\n#define PALTEX 0\n#define INVERT 1\n#define DESAT 1", // InGameColormapInvDesat + "#define EINGAMECOLORMAP\n#define PALTEX 1\n#define INVERT 0\n#define DESAT 0", // InGameColormapPal + "#define EINGAMECOLORMAP\n#define PALTEX 1\n#define INVERT 0\n#define DESAT 1", // InGameColormapPalDesat + "#define EINGAMECOLORMAP\n#define PALTEX 1\n#define INVERT 1\n#define DESAT 0", // InGameColormapPalInv + "#define EINGAMECOLORMAP\n#define PALTEX 1\n#define INVERT 1\n#define DESAT 1", // InGameColormapPalInvDesat - "BurnWipe", - "GammaCorrection", + "#define EBURNWIPE", // BurnWipe + "#define EGAMMACORRECTION", // GammaCorrection }; OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : Super(hMonitor, width, height, bits, refreshHz, fullscreen) { + // To do: this needs to cooperate with the same static in OpenGLFrameBuffer::InitializeState + static bool first = true; + if (first) + { + ogl_LoadFunctions(); + } + gl_LoadExtensions(); + Super::InitializeState(); + // SetVSync needs to be at the very top to workaround a bug in Nvidia's OpenGL driver. // If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed! - SetVSync(vid_vsync); + //SetVSync(vid_vsync); VertexBuffer = nullptr; IndexBuffer = nullptr; FBTexture = nullptr; - TempRenderTexture = nullptr; - RenderTexture[0] = nullptr; - RenderTexture[1] = nullptr; InitialWipeScreen = nullptr; ScreenshotTexture = nullptr; - ScreenshotSurface = nullptr; FinalWipeScreen = nullptr; PaletteTexture = nullptr; - GammaTexture = nullptr; - FrontCopySurface = nullptr; for (int i = 0; i < NUM_SHADERS; ++i) { Shaders[i] = nullptr; } GammaShader = nullptr; - BlockSurface[0] = nullptr; - BlockSurface[1] = nullptr; VSync = vid_vsync; BlendingRect.left = 0; BlendingRect.top = 0; @@ -160,9 +162,6 @@ OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, QuadExtra = new BufferedTris[MAX_QUAD_BATCH]; Atlases = nullptr; PixelDoubling = 0; - SkipAt = -1; - CurrRenderTexture = 0; - RenderTextureToggle = 0; Gamma = 1.0; FlashColor0 = 0; @@ -180,7 +179,7 @@ OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, memcpy(SourcePalette, GPalette.BaseColors, sizeof(PalEntry) * 256); - Windowed = !(static_cast(Video)->GoFullscreen(fullscreen)); + //Windowed = !(static_cast(Video)->GoFullscreen(fullscreen)); TrueHeight = height; /*if (fullscreen) @@ -209,7 +208,56 @@ OpenGLSWFrameBuffer::~OpenGLSWFrameBuffer() delete[] QuadExtra; } -bool OpenGLSWFrameBuffer::CreatePixelShader(const void *vertexsrc, const void *fragmentsrc, HWPixelShader **outShader) +OpenGLSWFrameBuffer::HWTexture::~HWTexture() +{ + if (Texture != 0) glDeleteTextures(1, (GLuint*)&Texture); + if (Buffer != 0) glDeleteBuffers(1, (GLuint*)&Buffer); +} + +OpenGLSWFrameBuffer::HWVertexBuffer::~HWVertexBuffer() +{ + if (VertexArray != 0) glDeleteVertexArrays(1, (GLuint*)&VertexArray); + if (Buffer != 0) glDeleteBuffers(1, (GLuint*)&Buffer); +} + +OpenGLSWFrameBuffer::FBVERTEX *OpenGLSWFrameBuffer::HWVertexBuffer::Lock() +{ + glBindBuffer(GL_ARRAY_BUFFER, Buffer); + return (FBVERTEX*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); +} + +void OpenGLSWFrameBuffer::HWVertexBuffer::Unlock() +{ + glUnmapBuffer(GL_ARRAY_BUFFER); + glBindBuffer(GL_ARRAY_BUFFER, 0); +} + +OpenGLSWFrameBuffer::HWIndexBuffer::~HWIndexBuffer() +{ + if (Buffer != 0) glDeleteBuffers(1, (GLuint*)&Buffer); +} + +uint16_t *OpenGLSWFrameBuffer::HWIndexBuffer::Lock() +{ + glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &LockedOldBinding); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, Buffer); + return (uint16_t*)glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); +} + +void OpenGLSWFrameBuffer::HWIndexBuffer::Unlock() +{ + glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, LockedOldBinding); +} + +OpenGLSWFrameBuffer::HWPixelShader::~HWPixelShader() +{ + if (Program != 0) glDeleteProgram(Program); + if (VertexShader != 0) glDeleteShader(VertexShader); + if (FragmentShader != 0) glDeleteShader(FragmentShader); +} + +bool OpenGLSWFrameBuffer::CreatePixelShader(FString vertexsrc, FString fragmentsrc, const FString &defines, HWPixelShader **outShader) { auto shader = std::make_unique(); @@ -217,25 +265,34 @@ bool OpenGLSWFrameBuffer::CreatePixelShader(const void *vertexsrc, const void *f shader->VertexShader = glCreateShader(GL_VERTEX_SHADER); shader->FragmentShader = glCreateShader(GL_FRAGMENT_SHADER); + vertexsrc = "#version 130\n" + defines + "\n#line 0\n" + vertexsrc; + fragmentsrc = "#version 130\n" + defines + "\n#line 0\n" + fragmentsrc; + { - int lengths[1] = { (int)strlen((const char*)vertexsrc) }; - const char *sources[1] = { (const char*)vertexsrc }; + int lengths[1] = { (int)vertexsrc.Len() }; + const char *sources[1] = { vertexsrc.GetChars() }; glShaderSource(shader->VertexShader, 1, sources, lengths); glCompileShader(shader->VertexShader); } { - int lengths[1] = { (int)strlen((const char*)fragmentsrc) }; - const char *sources[1] = { (const char*)fragmentsrc }; + int lengths[1] = { (int)fragmentsrc.Len() }; + const char *sources[1] = { fragmentsrc.GetChars() }; glShaderSource(shader->FragmentShader, 1, sources, lengths); glCompileShader(shader->FragmentShader); } GLint status = 0; + int errorShader = shader->VertexShader; glGetShaderiv(shader->VertexShader, GL_COMPILE_STATUS, &status); - if (status != GL_FALSE) glGetShaderiv(shader->FragmentShader, GL_COMPILE_STATUS, &status); + if (status != GL_FALSE) { errorShader = shader->FragmentShader; glGetShaderiv(shader->FragmentShader, GL_COMPILE_STATUS, &status); } if (status == GL_FALSE) { + static char buffer[10000]; + GLsizei length = 0; + buffer[0] = 0; + glGetShaderInfoLog(errorShader, 10000, &length, buffer); + *outShader = nullptr; return false; } @@ -308,6 +365,8 @@ bool OpenGLSWFrameBuffer::CreateTexture(int width, int height, int levels, int f { auto obj = std::make_unique(); + obj->Format = format; + GLint oldBinding = 0; glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldBinding); @@ -317,7 +376,7 @@ bool OpenGLSWFrameBuffer::CreateTexture(int width, int height, int levels, int f switch (format) { case GL_R8: srcformat = GL_RED; break; - case GL_RGBA8: srcformat = GL_RGBA; break; + case GL_RGBA8: srcformat = GL_BGRA; break; case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: srcformat = GL_RGB; break; case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: srcformat = GL_RGBA; break; case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: srcformat = GL_RGBA; break; @@ -327,6 +386,8 @@ bool OpenGLSWFrameBuffer::CreateTexture(int width, int height, int levels, int f return false; } glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, srcformat, GL_UNSIGNED_BYTE, nullptr); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, oldBinding); @@ -334,16 +395,9 @@ bool OpenGLSWFrameBuffer::CreateTexture(int width, int height, int levels, int f return true; } -bool OpenGLSWFrameBuffer::CreateOffscreenPlainSurface(int width, int height, int format, HWSurface **outSurface) { *outSurface = nullptr; return false; } -bool OpenGLSWFrameBuffer::CreateRenderTarget(int width, int height, int format, HWSurface **outSurface) { *outSurface = nullptr; return false; } -bool OpenGLSWFrameBuffer::GetBackBuffer(HWSurface **outSurface) { *outSurface = nullptr; return false; } -bool OpenGLSWFrameBuffer::GetRenderTarget(int index, HWSurface **outSurface) { *outSurface = nullptr; return false; } -void OpenGLSWFrameBuffer::GetRenderTargetData(HWSurface *a, HWSurface *b) { } - -void OpenGLSWFrameBuffer::ColorFill(HWSurface *surface, float red, float green, float blue) { } -void OpenGLSWFrameBuffer::StretchRect(HWSurface *src, const LTRBRect *srcrect, HWSurface *dest) { } -bool OpenGLSWFrameBuffer::SetRenderTarget(int index, HWSurface *surface) { return true; } -void OpenGLSWFrameBuffer::SetGammaRamp(const GammaRamp *ramp) { } +void OpenGLSWFrameBuffer::SetGammaRamp(const GammaRamp *ramp) +{ +} void OpenGLSWFrameBuffer::SetPixelShaderConstantF(int uniformIndex, const float *data, int vec4fcount) { @@ -487,7 +541,6 @@ void OpenGLSWFrameBuffer::SetInitialState() NeedGammaUpdate = true; NeedPalUpdate = true; - OldRenderTarget = nullptr; // This constant is used for grayscaling weights (.xyz) and color inversion (.w) float weights[4] = { 77 / 256.f, 143 / 256.f, 37 / 256.f, 1 }; @@ -524,7 +577,6 @@ bool OpenGLSWFrameBuffer::CreateResources() { return false; } - CreateBlockSurfaces(); return true; } @@ -539,42 +591,36 @@ bool OpenGLSWFrameBuffer::CreateResources() bool OpenGLSWFrameBuffer::LoadShaders() { - static const char models[][4] = { "30/", "20/", "14/" }; + int lumpvert = Wads.CheckNumForFullName("shaders/glsl/swshader.vp"); + int lumpfrag = Wads.CheckNumForFullName("shaders/glsl/swshader.fp"); + if (lumpvert < 0 || lumpfrag < 0) + return false; + + FString vertsource = Wads.ReadLump(lumpvert).GetString(); + FString fragsource = Wads.ReadLump(lumpfrag).GetString(); + FString shaderdir, shaderpath; - unsigned model, i; - int lump, lumpvert; + unsigned int i; // We determine the best available model simply by trying them all in // order of decreasing preference. - for (model = 0; model < countof(models); ++model) + for (i = 0; i < NUM_SHADERS; ++i) { - shaderdir = "shaders/gl/sm"; - shaderdir += models[model]; - for (i = 0; i < NUM_SHADERS; ++i) + shaderpath = shaderdir; + if (!CreatePixelShader(vertsource, fragsource, ShaderDefines[i], &Shaders[i]) && i < SHADER_BurnWipe) { - shaderpath = shaderdir; - lump = Wads.CheckNumForFullName(shaderpath + ShaderNames[i] + ".fp"); - lumpvert = Wads.CheckNumForFullName(shaderpath + ShaderNames[i] + ".vp"); - if (lump >= 0 && lumpvert >= 0) - { - FMemLump data = Wads.ReadLump(lump); - FMemLump datavert = Wads.ReadLump(lumpvert); - if (!CreatePixelShader(datavert.GetMem(), data.GetMem(), &Shaders[i]) && i < SHADER_BurnWipe) - { - break; - } - } - } - if (i == NUM_SHADERS) - { // Success! - return true; - } - // Failure. Release whatever managed to load (which is probably nothing.) - for (i = 0; i < NUM_SHADERS; ++i) - { - SafeRelease(Shaders[i]); + break; } } + if (i == NUM_SHADERS) + { // Success! + return true; + } + // Failure. Release whatever managed to load (which is probably nothing.) + for (i = 0; i < NUM_SHADERS; ++i) + { + SafeRelease(Shaders[i]); + } return false; } @@ -590,7 +636,6 @@ void OpenGLSWFrameBuffer::ReleaseResources() KillNativeTexs(); KillNativePals(); ReleaseDefaultPoolItems(); - SafeRelease(ScreenshotSurface); SafeRelease(ScreenshotTexture); SafeRelease(PaletteTexture); for (int i = 0; i < NUM_SHADERS; ++i) @@ -616,14 +661,9 @@ void OpenGLSWFrameBuffer::ReleaseDefaultPoolItems() { SafeRelease(FBTexture); SafeRelease(FinalWipeScreen); - SafeRelease(RenderTexture[0]); - SafeRelease(RenderTexture[1]); SafeRelease(InitialWipeScreen); SafeRelease(VertexBuffer); SafeRelease(IndexBuffer); - SafeRelease(BlockSurface[0]); - SafeRelease(BlockSurface[1]); - SafeRelease(FrontCopySurface); } bool OpenGLSWFrameBuffer::Reset() @@ -633,32 +673,10 @@ bool OpenGLSWFrameBuffer::Reset() { return false; } - CreateBlockSurfaces(); SetInitialState(); return true; } -//========================================================================== -// -// OpenGLSWFrameBuffer :: CreateBlockSurfaces -// -// Create blocking surfaces for antilag. It's okay if these can't be -// created; antilag just won't work. -// -//========================================================================== - -void OpenGLSWFrameBuffer::CreateBlockSurfaces() -{ - BlockNum = 0; - if (CreateOffscreenPlainSurface(16, 16, GL_RGBA8, &BlockSurface[0])) - { - if (!CreateOffscreenPlainSurface(16, 16, GL_RGBA8, &BlockSurface[1])) - { - SafeRelease(BlockSurface[0]); - } - } -} - //========================================================================== // // OpenGLSWFrameBuffer :: KillNativePals @@ -691,80 +709,11 @@ void OpenGLSWFrameBuffer::KillNativeTexs() } } -//========================================================================== -// -// OpenGLSWFrameBuffer :: CreateFBTexture -// -// Creates the "Framebuffer" texture. With the advent of hardware-assisted -// 2D, this is something of a misnomer now. The FBTexture is only used for -// uploading the software 3D image to video memory so that it can be drawn -// to the real frame buffer. -// -// It also creates the TempRenderTexture, since this seemed like a -// convenient place to do so. -// -//========================================================================== - bool OpenGLSWFrameBuffer::CreateFBTexture() { - if (!CreateTexture(Width, Height, 1, GL_R8, &FBTexture)) - { - int pow2width, pow2height, i; - - for (i = 1; i < Width; i <<= 1) {} pow2width = i; - for (i = 1; i < Height; i <<= 1) {} pow2height = i; - - if (!CreateTexture(pow2width, pow2height, 1, GL_R8, &FBTexture)) - { - return false; - } - else - { - FBWidth = pow2width; - FBHeight = pow2height; - } - } - else - { - FBWidth = Width; - FBHeight = Height; - } - RenderTextureToggle = 0; - RenderTexture[0] = nullptr; - RenderTexture[1] = nullptr; - if (!CreateTexture(FBWidth, FBHeight, 1, GL_RGBA8, &RenderTexture[0])) - { - return false; - } - if (Windowed || PixelDoubling) - { - // Windowed or pixel doubling: Create another render texture so we can flip between them. - RenderTextureToggle = 1; - if (!CreateTexture(FBWidth, FBHeight, 1, GL_RGBA8, &RenderTexture[1])) - { - return false; - } - } - else - { - // Fullscreen and not pixel doubling: Create a render target to have the back buffer copied to. - if (!CreateRenderTarget(Width, Height, GL_RGBA8, &FrontCopySurface)) - { - return false; - } - } - // Initialize the TempRenderTextures to black. - for (int i = 0; i <= RenderTextureToggle; ++i) - { - HWSurface *surf; - if (RenderTexture[i]->GetSurfaceLevel(0, &surf)) - { - ColorFill(surf, 0.0f, 0.0f, 0.0f); - delete surf; - } - } - TempRenderTexture = RenderTexture[0]; - CurrRenderTexture = 0; + CreateTexture(Width, Height, 1, GL_R8, &FBTexture); + FBWidth = Width; + FBHeight = Height; return true; } @@ -814,7 +763,7 @@ bool OpenGLSWFrameBuffer::CreateVertexes() void OpenGLSWFrameBuffer::CalcFullscreenCoords(FBVERTEX verts[4], bool viewarea_only, bool can_double, uint32_t color0, uint32_t color1) const { - float offset = OldRenderTarget != nullptr ? 0 : LBOffset; + float offset = LBOffset;//OldRenderTarget != nullptr ? 0 : LBOffset; float top = offset - 0.5f; float texright = float(Width) / float(FBWidth); float texbot = float(Height) / float(FBHeight); @@ -1042,18 +991,6 @@ void OpenGLSWFrameBuffer::Update() LOG("SetGammaRamp\n"); SetGammaRamp(&ramp); } - else - { - if (igamma != 1) - { - UpdateGammaTexture(igamma); - GammaShader = Shaders[SHADER_GammaCorrection]; - } - else - { - GammaShader = nullptr; - } - } psgamma[2] = psgamma[1] = psgamma[0] = igamma; psgamma[3] = 0.5; // For SM14 version SetPixelShaderConstantF(PSCONST_Gamma, psgamma, 1); @@ -1094,21 +1031,6 @@ void OpenGLSWFrameBuffer::Flip() DrawLetterbox(); DoWindowedGamma(); - CopyNextFrontBuffer(); - - // Attempt to counter input lag. - if (gl_antilag && BlockSurface[0] != nullptr) - { - LockedRect lr; - volatile int dummy; - ColorFill(BlockSurface[BlockNum], 0.0f, 0x20/255.0f, 0x50/255.0f); - BlockNum ^= 1; - if (BlockSurface[BlockNum]->LockRect(&lr, nullptr, false)) - { - dummy = *(int *)lr.pBits; - BlockSurface[BlockNum]->UnlockRect(); - } - } // Limiting the frame rate is as simple as waiting for the timer to signal this event. if (FPSLimitEvent != nullptr) { @@ -1117,13 +1039,6 @@ void OpenGLSWFrameBuffer::Flip() Present(); InScene = false; - if (RenderTextureToggle) - { - // Flip the TempRenderTexture to the other one now. - CurrRenderTexture ^= RenderTextureToggle; - TempRenderTexture = RenderTexture[CurrRenderTexture]; - } - if (Windowed) { int clientWidth = GetClientWidth(); @@ -1143,42 +1058,6 @@ void OpenGLSWFrameBuffer::Flip() } } -//========================================================================== -// -// OpenGLSWFrameBuffer :: CopyNextFrontBuffer -// -// Duplicates the contents of the back buffer that will become the front -// buffer upon Present into FrontCopySurface so that we can get the -// contents of the display without wasting time in GetFrontBufferData(). -// -//========================================================================== - -void OpenGLSWFrameBuffer::CopyNextFrontBuffer() -{ - HWSurface *backbuff; - - if (Windowed || PixelDoubling) - { - // Windowed mode or pixel doubling: TempRenderTexture has what we want - SafeRelease(FrontCopySurface); - if (TempRenderTexture->GetSurfaceLevel(0, &backbuff)) - { - FrontCopySurface = backbuff; - } - } - else - { - // Fullscreen, not pixel doubled: The back buffer has what we want, - // but it might be letter boxed. - if (GetBackBuffer(&backbuff)) - { - LTRBRect srcrect = { 0, LBOffsetI, Width, LBOffsetI + Height }; - StretchRect(backbuff, &srcrect, FrontCopySurface); - delete backbuff; - } - } -} - //========================================================================== // // OpenGLSWFrameBuffer :: PaintToWindow @@ -1207,50 +1086,49 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) { if (copy3d) { - LTRBRect texrect = { 0, 0, Width, Height }; - LockedRect lockrect; - - if ((FBWidth == Width && FBHeight == Height && - FBTexture->LockRect(&lockrect, nullptr, true)) || - FBTexture->LockRect(&lockrect, &texrect, false)) + if (FBTexture->Buffer == 0) { - if (lockrect.Pitch == Pitch && Pitch == Width) + glGenBuffers(1, (GLuint*)&FBTexture->Buffer); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffer); + glBufferData(GL_PIXEL_UNPACK_BUFFER, Width * Height, nullptr, GL_STREAM_DRAW); + } + else + { + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffer); + } + + uint8_t *dest = (uint8_t*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); + if (dest) + { + if (Pitch == Width) { - memcpy(lockrect.pBits, MemBuffer, Width * Height); + memcpy(dest, MemBuffer, Width * Height); } else { - uint8_t *dest = (uint8_t *)lockrect.pBits; uint8_t *src = MemBuffer; for (int y = 0; y < Height; y++) { memcpy(dest, src, Width); - dest += lockrect.Pitch; + dest += Width; src += Pitch; } } - FBTexture->UnlockRect(); + glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); + GLint oldBinding = 0; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldBinding); + glBindTexture(GL_TEXTURE_2D, FBTexture->Texture); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Width, Height, GL_R8, GL_UNSIGNED_BYTE, 0); + glBindTexture(GL_TEXTURE_2D, oldBinding); } + + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); } InScene = true; if (vid_hwaalines) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH); - assert(OldRenderTarget == nullptr); - if (TempRenderTexture != nullptr && - ((Windowed && TempRenderTexture != FinalWipeScreen) || GatheringWipeScreen || PixelDoubling)) - { - HWSurface *targetsurf; - if (TempRenderTexture->GetSurfaceLevel(0, &targetsurf)) - { - if (GetRenderTarget(0, &OldRenderTarget)) - { - SetRenderTarget(0, targetsurf); - } - delete targetsurf; - } - } SetTexture(0, FBTexture); SetPaletteTexture(PaletteTexture, 256, BorderColor); @@ -1271,10 +1149,8 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) } else { - color0 = ColorValue(realfixedcolormap->ColorizeStart[0] / 2, - realfixedcolormap->ColorizeStart[1] / 2, realfixedcolormap->ColorizeStart[2] / 2, 0); - color1 = ColorValue(realfixedcolormap->ColorizeEnd[0] / 2, - realfixedcolormap->ColorizeEnd[1] / 2, realfixedcolormap->ColorizeEnd[2] / 2, 1); + color0 = ColorValue(realfixedcolormap->ColorizeStart[0] / 2, realfixedcolormap->ColorizeStart[1] / 2, realfixedcolormap->ColorizeStart[2] / 2, 0); + color1 = ColorValue(realfixedcolormap->ColorizeEnd[0] / 2, realfixedcolormap->ColorizeEnd[1] / 2, realfixedcolormap->ColorizeEnd[2] / 2, 1); SetPixelShader(Shaders[SHADER_SpecialColormapPal]); } } @@ -1323,7 +1199,7 @@ void OpenGLSWFrameBuffer::DrawLetterbox() void OpenGLSWFrameBuffer::DoWindowedGamma() { - if (OldRenderTarget != nullptr) + /*if (OldRenderTarget != nullptr) { FBVERTEX verts[4]; @@ -1336,49 +1212,28 @@ void OpenGLSWFrameBuffer::DoWindowedGamma() DrawTriangleFans(2, verts); delete OldRenderTarget; OldRenderTarget = nullptr; - } -} - -//========================================================================== -// -// OpenGLSWFrameBuffer :: UpdateGammaTexture -// -// Updates the gamma texture used by the PS14 shader. We only use the first -// half of the texture so that we needn't worry about imprecision causing -// it to grab from the border. -// -//========================================================================== - -void OpenGLSWFrameBuffer::UpdateGammaTexture(float igamma) -{ - LockedRect lockrect; - - if (GammaTexture != nullptr && GammaTexture->LockRect(&lockrect, nullptr, false)) - { - uint8_t *pix = (uint8_t *)lockrect.pBits; - for (int i = 0; i <= 128; ++i) - { - pix[i * 4 + 2] = pix[i * 4 + 1] = pix[i * 4] = uint8_t(255.f * powf(i / 128.f, igamma)); - pix[i * 4 + 3] = 255; - } - GammaTexture->UnlockRect(); - } + }*/ } void OpenGLSWFrameBuffer::UploadPalette() { - LockedRect lockrect; - - if (SkipAt < 0) + if (PaletteTexture->Buffer == 0) { - SkipAt = 256; + glGenBuffers(1, (GLuint*)&PaletteTexture->Buffer); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, PaletteTexture->Buffer); + glBufferData(GL_PIXEL_UNPACK_BUFFER, 256 * 4, nullptr, GL_STREAM_DRAW); } - if (PaletteTexture->LockRect(&lockrect, nullptr, false)) + else + { + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, PaletteTexture->Buffer); + } + + uint8_t *pix = (uint8_t *)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); + if (pix) { - uint8_t *pix = (uint8_t *)lockrect.pBits; int i; - for (i = 0; i < SkipAt; ++i, pix += 4) + for (i = 0; i < 256; ++i, pix += 4) { pix[0] = SourcePalette[i].b; pix[1] = SourcePalette[i].g; @@ -1394,9 +1249,16 @@ void OpenGLSWFrameBuffer::UploadPalette() pix[2] = SourcePalette[i].r; pix[3] = 255; } - PaletteTexture->UnlockRect(); + glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); + GLint oldBinding = 0; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldBinding); + glBindTexture(GL_TEXTURE_2D, PaletteTexture->Texture); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 1, GL_BGRA, GL_UNSIGNED_BYTE, 0); + glBindTexture(GL_TEXTURE_2D, oldBinding); BorderColor = ColorXRGB(SourcePalette[255].r, SourcePalette[255].g, SourcePalette[255].b); } + + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); } PalEntry *OpenGLSWFrameBuffer::GetPalette() @@ -1484,6 +1346,8 @@ void OpenGLSWFrameBuffer::SetBlendingRect(int x1, int y1, int x2, int y2) void OpenGLSWFrameBuffer::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &color_type) { + Super::GetScreenshotBuffer(buffer, pitch, color_type); + /* LockedRect lrect; if (!Accel2D) @@ -1513,6 +1377,7 @@ void OpenGLSWFrameBuffer::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch color_type = SS_BGRA; } } + */ } //========================================================================== @@ -1527,58 +1392,9 @@ void OpenGLSWFrameBuffer::ReleaseScreenshotBuffer() { Super::ReleaseScreenshotBuffer(); } - if (ScreenshotSurface != nullptr) - { - ScreenshotSurface->UnlockRect(); - delete ScreenshotSurface; - ScreenshotSurface = nullptr; - } SafeRelease(ScreenshotTexture); } -//========================================================================== -// -// OpenGLSWFrameBuffer :: GetCurrentScreen -// -// Returns a texture containing the pixels currently visible on-screen. -// -//========================================================================== - -OpenGLSWFrameBuffer::HWTexture *OpenGLSWFrameBuffer::GetCurrentScreen() -{ - HWTexture *tex; - HWSurface *surf; - bool hr; - - if (FrontCopySurface == nullptr) - { - return nullptr; - } - - hr = CreateTexture(FBWidth, FBHeight, 1, GL_RGBA8, &tex); - - if (!hr) - { - return nullptr; - } - if (!tex->GetSurfaceLevel(0, &surf)) - { - delete tex; - return nullptr; - } - - // Video -> System memory : use GetRenderTargetData - GetRenderTargetData(FrontCopySurface, surf); - delete surf; - - if (!hr) - { - delete tex; - return nullptr; - } - return tex; -} - /**************************************************************************/ /* 2D Stuff */ /**************************************************************************/ @@ -2013,7 +1829,6 @@ bool OpenGLSWFrameBuffer::OpenGLTex::Create(OpenGLSWFrameBuffer *fb, bool wrappi bool OpenGLSWFrameBuffer::OpenGLTex::Update() { - LockedRect lrect; LTRBRect rect; uint8_t *dest; @@ -2025,27 +1840,44 @@ bool OpenGLSWFrameBuffer::OpenGLTex::Update() int format = Box->Owner->Tex->Format; rect = Box->Area; - if (!Box->Owner->Tex->LockRect(&lrect, &rect, false)) + + if (Box->Owner->Tex->Buffer == 0) + glGenBuffers(1, (GLuint*)&Box->Owner->Tex->Buffer); + + int bytesPerPixel = 4; + switch (format) + { + case GL_R8: bytesPerPixel = 1; break; + case GL_RGBA8: bytesPerPixel = 4; break; + default: return false; + } + + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, Box->Owner->Tex->Buffer); + glBufferData(GL_PIXEL_UNPACK_BUFFER, (rect.right - rect.left) * (rect.bottom - rect.top) * bytesPerPixel, nullptr, GL_STREAM_DRAW); + + int pitch = (rect.right - rect.left) * bytesPerPixel; + uint8_t *bits = (uint8_t *)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); + dest = bits; + if (!dest) { return false; } - dest = (uint8_t *)lrect.pBits; if (Box->Padded) { - dest += lrect.Pitch + (format == GL_R8 ? 1 : 4); + dest += pitch + (format == GL_R8 ? 1 : 4); } - GameTex->FillBuffer(dest, lrect.Pitch, GameTex->GetHeight(), ToTexFmt(format)); + GameTex->FillBuffer(dest, pitch, GameTex->GetHeight(), ToTexFmt(format)); if (Box->Padded) { // Clear top padding row. - dest = (uint8_t *)lrect.pBits; + dest = bits; int numbytes = GameTex->GetWidth() + 2; if (format != GL_R8) { numbytes <<= 2; } memset(dest, 0, numbytes); - dest += lrect.Pitch; + dest += pitch; // Clear left and right padding columns. if (format == GL_R8) { @@ -2053,7 +1885,7 @@ bool OpenGLSWFrameBuffer::OpenGLTex::Update() { dest[0] = 0; dest[numbytes - 1] = 0; - dest += lrect.Pitch; + dest += pitch; } } else @@ -2062,13 +1894,20 @@ bool OpenGLSWFrameBuffer::OpenGLTex::Update() { *(uint32_t *)dest = 0; *(uint32_t *)(dest + numbytes - 4) = 0; - dest += lrect.Pitch; + dest += pitch; } } // Clear bottom padding row. memset(dest, 0, numbytes); } - Box->Owner->Tex->UnlockRect(); + + glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); + GLint oldBinding = 0; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldBinding); + glBindTexture(GL_TEXTURE_2D, Box->Owner->Tex->Texture); + glTexSubImage2D(GL_TEXTURE_2D, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, format == GL_RGBA8 ? GL_BGRA : GL_RED, GL_UNSIGNED_BYTE, 0); + glBindTexture(GL_TEXTURE_2D, oldBinding); + glBindTexture(GL_PIXEL_UNPACK_BUFFER, 0); return true; } @@ -2199,18 +2038,28 @@ OpenGLSWFrameBuffer::OpenGLPal::~OpenGLPal() bool OpenGLSWFrameBuffer::OpenGLPal::Update() { - LockedRect lrect; uint32_t *buff; const PalEntry *pal; int skipat, i; assert(Tex != nullptr); - if (!Tex->LockRect(&lrect, nullptr, 0)) + if (Tex->Buffer == 0) + { + glGenBuffers(1, (GLuint*)&Tex->Buffer); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, Tex->Buffer); + glBufferData(GL_PIXEL_UNPACK_BUFFER, Remap->NumEntries * 4, nullptr, GL_STREAM_DRAW); + } + else + { + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, Tex->Buffer); + } + + buff = (uint32_t *)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); + if (buff == nullptr) { return false; } - buff = (uint32_t *)lrect.pBits; pal = Remap->Palette; // See explanation in UploadPalette() for skipat rationale. @@ -2226,7 +2075,14 @@ bool OpenGLSWFrameBuffer::OpenGLPal::Update() } BorderColor = ColorARGB(pal[i].a, pal[i - 1].r, pal[i - 1].g, pal[i - 1].b); - Tex->UnlockRect(); + glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); + GLint oldBinding = 0; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldBinding); + glBindTexture(GL_TEXTURE_2D, Tex->Texture); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Remap->NumEntries, 1, GL_BGRA, GL_UNSIGNED_BYTE, 0); + glBindTexture(GL_TEXTURE_2D, oldBinding); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); + return true; } diff --git a/src/gl/system/gl_swframebuffer.h b/src/gl/system/gl_swframebuffer.h index 14ed2ec13..eed9b6f7f 100644 --- a/src/gl/system/gl_swframebuffer.h +++ b/src/gl/system/gl_swframebuffer.h @@ -85,32 +85,18 @@ private: uint16_t red[256], green[256], blue[256]; }; - struct LockedRect - { - int Pitch; - void *pBits; - }; - struct LTRBRect { int left, top, right, bottom; }; - class HWSurface - { - public: - bool LockRect(LockedRect *outRect, LTRBRect *srcRect, bool discard) { outRect->Pitch = 0; outRect->pBits = nullptr; return false; } - void UnlockRect() { } - }; - class HWTexture { public: - bool LockRect(LockedRect *outRect, LTRBRect *srcRect, bool discard) { outRect->Pitch = 0; outRect->pBits = nullptr; return false; } - void UnlockRect() { } - bool GetSurfaceLevel(int level, HWSurface **outSurface) { *outSurface = nullptr; return false; } + ~HWTexture(); int Texture = 0; + int Buffer = 0; int WrapS = 0; int WrapT = 0; int Format = 0; @@ -119,60 +105,43 @@ private: class HWVertexBuffer { public: - ~HWVertexBuffer() - { - if (Buffer != 0) glDeleteVertexArrays(1, (GLuint*)&VertexArray); - if (Buffer != 0) glDeleteBuffers(1, (GLuint*)&Buffer); - } + ~HWVertexBuffer(); - FBVERTEX *Lock() { return nullptr; } - void Unlock() { } + FBVERTEX *Lock(); + void Unlock(); - int Buffer = 0; int VertexArray = 0; + int Buffer = 0; }; class HWIndexBuffer { public: - ~HWIndexBuffer() - { - if (Buffer != 0) glDeleteBuffers(1, (GLuint*)&Buffer); - } + ~HWIndexBuffer(); - uint16_t *Lock() { return nullptr; } - void Unlock() { } + uint16_t *Lock(); + void Unlock(); int Buffer = 0; + + private: + int LockedOldBinding = 0; }; class HWPixelShader { public: - ~HWPixelShader() - { - if (Program != 0) glDeleteProgram(Program); - if (VertexShader != 0) glDeleteShader(VertexShader); - if (FragmentShader != 0) glDeleteShader(FragmentShader); - } + ~HWPixelShader(); int Program = 0; int VertexShader = 0; int FragmentShader = 0; }; - bool CreatePixelShader(const void *vertexsrc, const void *fragmentsrc, HWPixelShader **outShader); + bool CreatePixelShader(FString vertexsrc, FString fragmentsrc, const FString &defines, HWPixelShader **outShader); bool CreateVertexBuffer(int size, HWVertexBuffer **outVertexBuffer); bool CreateIndexBuffer(int size, HWIndexBuffer **outIndexBuffer); - bool CreateOffscreenPlainSurface(int width, int height, int format, HWSurface **outSurface); bool CreateTexture(int width, int height, int levels, int format, HWTexture **outTexture); - bool CreateRenderTarget(int width, int height, int format, HWSurface **outSurface); - bool GetBackBuffer(HWSurface **outSurface); - bool GetRenderTarget(int index, HWSurface **outSurface); - void GetRenderTargetData(HWSurface *a, HWSurface *b); - void ColorFill(HWSurface *surface, float red, float green, float blue); - void StretchRect(HWSurface *src, const LTRBRect *srcrect, HWSurface *dest); - bool SetRenderTarget(int index, HWSurface *surface); void SetGammaRamp(const GammaRamp *ramp); void SetPixelShaderConstantF(int uniformIndex, const float *data, int vec4fcount); void SetHWPixelShader(HWPixelShader *shader); @@ -362,19 +331,17 @@ private: NUM_SHADERS }; - static const char *const ShaderNames[NUM_SHADERS]; + static const char *const ShaderDefines[NUM_SHADERS]; void Flip(); void SetInitialState(); bool CreateResources(); void ReleaseResources(); bool LoadShaders(); - void CreateBlockSurfaces(); bool CreateFBTexture(); bool CreatePaletteTexture(); bool CreateVertexes(); void UploadPalette(); - void UpdateGammaTexture(float igamma); void CalcFullscreenCoords(FBVERTEX verts[4], bool viewarea_only, bool can_double, uint32_t color0, uint32_t color1) const; bool Reset(); HWTexture *GetCurrentScreen(); @@ -397,7 +364,6 @@ private: void BeginLineBatch(); void EndLineBatch(); void EndBatch(); - void CopyNextFrontBuffer(); // State void EnableAlphaTest(BOOL enabled); @@ -431,10 +397,7 @@ private: int FlashAmount; int TrueHeight; int PixelDoubling; - int SkipAt; int LBOffsetI; - int RenderTextureToggle; - int CurrRenderTexture; float LBOffset; float Gamma; bool UpdatePending; @@ -448,34 +411,28 @@ private: bool GatheringWipeScreen; bool AALines; uint8_t BlockNum; - OpenGLPal *Palettes; - OpenGLTex *Textures; - Atlas *Atlases; + OpenGLPal *Palettes = nullptr; + OpenGLTex *Textures = nullptr; + Atlas *Atlases = nullptr; - HWTexture *FBTexture; - HWTexture *TempRenderTexture, *RenderTexture[2]; - HWTexture *PaletteTexture; - HWTexture *GammaTexture; - HWTexture *ScreenshotTexture; - HWSurface *ScreenshotSurface; - HWSurface *FrontCopySurface; + HWTexture *FBTexture = nullptr; + HWTexture *PaletteTexture = nullptr; + HWTexture *ScreenshotTexture = nullptr; - HWVertexBuffer *VertexBuffer; - FBVERTEX *VertexData; - HWIndexBuffer *IndexBuffer; - uint16_t *IndexData; - BufferedTris *QuadExtra; + HWVertexBuffer *VertexBuffer = nullptr; + FBVERTEX *VertexData = nullptr; + HWIndexBuffer *IndexBuffer = nullptr; + uint16_t *IndexData = nullptr; + BufferedTris *QuadExtra = nullptr; int VertexPos; int IndexPos; int QuadBatchPos; enum { BATCH_None, BATCH_Quads, BATCH_Lines } BatchType; HWPixelShader *Shaders[NUM_SHADERS]; - HWPixelShader *GammaShader; + HWPixelShader *GammaShader = nullptr; - HWSurface *BlockSurface[2]; - HWSurface *OldRenderTarget; - HWTexture *InitialWipeScreen, *FinalWipeScreen; + HWTexture *InitialWipeScreen = nullptr, *FinalWipeScreen = nullptr; class Wiper { diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 787c0a4f3..2065a9072 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -137,8 +137,9 @@ void I_InitGraphics () ticker.SetGenericRepDefault (val, CVAR_Bool); //currentrenderer = vid_renderer; - if (currentrenderer==1) Video = gl_CreateVideo(); - else Video = new Win32Video (0); + Video = gl_CreateVideo(); + //if (currentrenderer==1) Video = gl_CreateVideo(); + //else Video = new Win32Video (0); if (Video == NULL) I_FatalError ("Failed to initialize display"); diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 5d68d8427..14d49c69b 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -25,6 +25,7 @@ #include "gl/renderer/gl_renderer.h" #include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_swframebuffer.h" extern "C" { _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; @@ -386,7 +387,10 @@ DFrameBuffer *Win32GLVideo::CreateFrameBuffer(int width, int height, bool fs, DF //old->GetFlash(flashColor, flashAmount); delete old; } - fb = new OpenGLFrameBuffer(m_hMonitor, m_DisplayWidth, m_DisplayHeight, m_DisplayBits, m_DisplayHz, fs); + if (vid_renderer == 1) + fb = new OpenGLFrameBuffer(m_hMonitor, m_DisplayWidth, m_DisplayHeight, m_DisplayBits, m_DisplayHz, fs); + else + fb = new OpenGLSWFrameBuffer(m_hMonitor, m_DisplayWidth, m_DisplayHeight, m_DisplayBits, m_DisplayHz, fs); return fb; } diff --git a/wadsrc/static/shaders/glsl/swshader.fp b/wadsrc/static/shaders/glsl/swshader.fp new file mode 100644 index 000000000..22364f460 --- /dev/null +++ b/wadsrc/static/shaders/glsl/swshader.fp @@ -0,0 +1,146 @@ + +in vec4 PixelColor0; +in vec4 PixelColor1; +in vec4 PixelTexCoord0; + +out vec4 FragColor; + +uniform sampler2D Image;// : register(s0); +uniform sampler2D Palette;// : register(s1); +uniform sampler2D NewScreen;// : register(s0); +uniform sampler2D Burn;// : register(s1); + +uniform vec4 Desaturation;// : register(c1); // { Desat, 1 - Desat } +uniform vec4 PaletteMod;// : register(c2); +uniform vec4 Weights;// : register(c6); // RGB->Gray weighting { 77/256.0, 143/256.0, 37/256.0, 1 } +uniform vec4 Gamma;// : register(c7); + +vec4 TextureLookup(vec2 tex_coord) +{ +#if PALTEX + float index = texture(Image, tex_coord).x; + index = index * PaletteMod.x + PaletteMod.y; + return texture(Palette, vec2(index, 0.5)); +#else + return texture(Image, tex_coord); +#endif +} + +vec4 Invert(vec4 rgb) +{ +#if INVERT + rgb.rgb = Weights.www - rgb.xyz; +#endif + return rgb; +} + +float Grayscale(vec4 rgb) +{ + return dot(rgb.rgb, Weights.rgb); +} + +vec4 SampleTexture(vec2 tex_coord) +{ + return Invert(TextureLookup(tex_coord)); +} + +// Normal color calculation for most drawing modes. + +vec4 NormalColor(vec2 tex_coord, vec4 Flash, vec4 InvFlash) +{ + return Flash + SampleTexture(tex_coord) * InvFlash; +} + +// Copy the red channel to the alpha channel. Pays no attention to palettes. + +vec4 RedToAlpha(vec2 tex_coord, vec4 Flash, vec4 InvFlash) +{ + vec4 color = Invert(texture(Image, tex_coord)); + color.a = color.r; + return Flash + color * InvFlash; +} + +// Just return the value of c0. + +vec4 VertexColor(vec4 color) +{ + return color; +} + +// Emulate one of the special colormaps. (Invulnerability, gold, etc.) + +vec4 SpecialColormap(vec2 tex_coord, vec4 start, vec4 end) +{ + vec4 color = SampleTexture(tex_coord); + vec4 range = end - start; + // We can't store values greater than 1.0 in a color register, so we multiply + // the final result by 2 and expect the caller to divide the start and end by 2. + color.rgb = 2 * (start + Grayscale(color) * range).rgb; + // Duplicate alpha semantics of NormalColor. + color.a = start.a + color.a * end.a; + return color; +} + +// In-game colormap effect: fade to a particular color and multiply by another, with +// optional desaturation of the original color. Desaturation is stored in c1. +// Fade level is packed int fade.a. Fade.rgb has been premultiplied by alpha. +// Overall alpha is in color.a. +vec4 InGameColormap(vec2 tex_coord, vec4 color, vec4 fade) +{ + vec4 rgb = SampleTexture(tex_coord); + + // Desaturate +#if DESAT + vec3 intensity; + intensity.rgb = vec3(Grayscale(rgb) * Desaturation.x); + rgb.rgb = intensity.rgb + rgb.rgb * Desaturation.y; +#endif + + // Fade + rgb.rgb = rgb.rgb * fade.aaa + fade.rgb; + + // Shade and Alpha + rgb = rgb * color; + + return rgb; +} + +// Windowed gamma correction. + +vec4 GammaCorrection(vec2 tex_coord) +{ + vec4 color = texture(Image, tex_coord); + color.rgb = pow(color.rgb, Gamma.rgb); + return color; +} + +// The burn wipe effect. + +vec4 BurnWipe(vec4 coord) +{ + vec4 color = texture(NewScreen, coord.xy); + vec4 alpha = texture(Burn, coord.zw); + color.a = alpha.r * 2; + return color; +} + +void main() +{ +#if defined(ENORMALCOLOR) + FragColor = NormalColor(PixelTexCoord0.xy, PixelColor0, PixelColor1); +#elif defined(EREDTOALPHA) + FragColor = RedToAlpha(PixelTexCoord0.xy, PixelColor0, PixelColor1); +#elif defined(EVERTEXCOLOR) + FragColor = VertexColor(PixelColor0); +#elif defined(ESPECIALCOLORMAP) + FragColor = SpecialColormap(PixelTexCoord0.xy, PixelColor0, PixelColor1); +#elif defined(EINGAMECOLORMAP) + FragColor = InGameColormap(PixelTexCoord0.xy, PixelColor0, PixelColor1); +#elif defined(EBURNWIPE) + FragColor = BurnWipe(PixelTexCoord0); +#elif defined(EGAMMACORRECTION) + FragColor = GammaCorrection(PixelTexCoord0.xy); +#else + #error Entry point define is missing +#endif +} diff --git a/wadsrc/static/shaders/glsl/swshader.vp b/wadsrc/static/shaders/glsl/swshader.vp new file mode 100644 index 000000000..4d00296cb --- /dev/null +++ b/wadsrc/static/shaders/glsl/swshader.vp @@ -0,0 +1,17 @@ + +in vec4 AttrPosition; +in vec4 AttrColor0; +in vec4 AttrColor1; +in vec4 AttrTexCoord0; + +out vec4 PixelColor0; +out vec4 PixelColor1; +out vec4 PixelTexCoord0; + +void main() +{ + gl_Position = AttrPosition; + PixelColor0 = AttrColor0; + PixelColor1 = AttrColor1; + PixelTexCoord0 = AttrTexCoord0; +} From 682b040b978f84367eb3aa559b8add3cd265fbbd Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 11 Oct 2016 00:03:46 +0200 Subject: [PATCH 1058/1509] OpenGL based software renderer hardware accel now works for most things --- src/gl/system/gl_swframebuffer.cpp | 84 ++++++++++++++++++++------ src/gl/system/gl_swframebuffer.h | 36 +++++++---- wadsrc/static/shaders/glsl/swshader.fp | 16 ++--- wadsrc/static/shaders/glsl/swshader.vp | 7 ++- 4 files changed, 99 insertions(+), 44 deletions(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 895508d8b..1ff48d13b 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -70,6 +70,7 @@ #include "gl/utility/gl_clock.h" #include "gl/utility/gl_templates.h" #include "gl/gl_functions.h" +#include "gl_debug.h" CVAR(Int, gl_showpacks, 0, 0) #ifndef WIN32 // Defined in fb_d3d9 for Windows @@ -131,6 +132,9 @@ OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, gl_LoadExtensions(); Super::InitializeState(); + Debug = std::make_shared(); + Debug->Update(); + // SetVSync needs to be at the very top to workaround a bug in Nvidia's OpenGL driver. // If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed! //SetVSync(vid_vsync); @@ -160,6 +164,7 @@ OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, ScreenWipe = nullptr; InScene = false; QuadExtra = new BufferedTris[MAX_QUAD_BATCH]; + memset(QuadExtra, 0, sizeof(BufferedTris) * MAX_QUAD_BATCH); Atlases = nullptr; PixelDoubling = 0; @@ -288,10 +293,10 @@ bool OpenGLSWFrameBuffer::CreatePixelShader(FString vertexsrc, FString fragments if (status != GL_FALSE) { errorShader = shader->FragmentShader; glGetShaderiv(shader->FragmentShader, GL_COMPILE_STATUS, &status); } if (status == GL_FALSE) { - static char buffer[10000]; + /*static char buffer[10000]; GLsizei length = 0; buffer[0] = 0; - glGetShaderInfoLog(errorShader, 10000, &length, buffer); + glGetShaderInfoLog(errorShader, 10000, &length, buffer);*/ *outShader = nullptr; return false; @@ -307,10 +312,19 @@ bool OpenGLSWFrameBuffer::CreatePixelShader(FString vertexsrc, FString fragments *outShader = nullptr; return false; } - glBindAttribLocation(shader->Program, 0, "Position"); - glBindAttribLocation(shader->Program, 1, "Color0"); - glBindAttribLocation(shader->Program, 2, "Color1"); - glBindAttribLocation(shader->Program, 3, "TexCoord"); + glBindAttribLocation(shader->Program, 0, "AttrPosition"); + glBindAttribLocation(shader->Program, 1, "AttrColor0"); + glBindAttribLocation(shader->Program, 2, "AttrColor1"); + glBindAttribLocation(shader->Program, 3, "AttrTexCoord0"); + + shader->ConstantLocations[PSCONST_Desaturation] = glGetUniformLocation(shader->Program, "Desaturation"); + shader->ConstantLocations[PSCONST_PaletteMod] = glGetUniformLocation(shader->Program, "PaletteMod"); + shader->ConstantLocations[PSCONST_Weights] = glGetUniformLocation(shader->Program, "Weights"); + shader->ConstantLocations[PSCONST_Gamma] = glGetUniformLocation(shader->Program, "Gamma"); + shader->ImageLocation = glGetUniformLocation(shader->Program, "Image"); + shader->PaletteLocation = glGetUniformLocation(shader->Program, "Palette"); + shader->NewScreenLocation = glGetUniformLocation(shader->Program, "NewScreen"); + shader->BurnLocation = glGetUniformLocation(shader->Program, "Burn"); *outShader = shader.release(); return true; @@ -361,7 +375,7 @@ bool OpenGLSWFrameBuffer::CreateIndexBuffer(int size, HWIndexBuffer **outIndexBu return true; } -bool OpenGLSWFrameBuffer::CreateTexture(int width, int height, int levels, int format, HWTexture **outTexture) +bool OpenGLSWFrameBuffer::CreateTexture(const FString &name, int width, int height, int levels, int format, HWTexture **outTexture) { auto obj = std::make_unique(); @@ -389,6 +403,8 @@ bool OpenGLSWFrameBuffer::CreateTexture(int width, int height, int levels, int f glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + FGLDebug::LabelObject(GL_TEXTURE, obj->Texture, name); + glBindTexture(GL_TEXTURE_2D, oldBinding); *outTexture = obj.release(); @@ -401,15 +417,32 @@ void OpenGLSWFrameBuffer::SetGammaRamp(const GammaRamp *ramp) void OpenGLSWFrameBuffer::SetPixelShaderConstantF(int uniformIndex, const float *data, int vec4fcount) { - glUniform4fv(uniformIndex, vec4fcount, data); + assert(uniformIndex < 4 && vec4fcount == 1); // This emulation of d3d9 only works for very simple stuff + for (int i = 0; i < 4; i++) + ShaderConstants[uniformIndex * 4 + i] = data[i]; + if (CurrentShader && CurrentShader->ConstantLocations[uniformIndex] != -1) + glUniform4fv(CurrentShader->ConstantLocations[uniformIndex], vec4fcount, data); } void OpenGLSWFrameBuffer::SetHWPixelShader(HWPixelShader *shader) { - if (shader) - glUseProgram(shader->Program); - else - glUseProgram(0); + if (shader != CurrentShader) + { + if (shader) + { + glUseProgram(shader->Program); + for (int i = 0; i < 4; i++) + { + if (shader->ConstantLocations[i] != -1) + glUniform4fv(shader->ConstantLocations[i], 1, &ShaderConstants[i * 4]); + } + } + else + { + glUseProgram(0); + } + } + CurrentShader = shader; } void OpenGLSWFrameBuffer::SetStreamSource(HWVertexBuffer *vertexBuffer) @@ -430,6 +463,8 @@ void OpenGLSWFrameBuffer::SetIndices(HWIndexBuffer *indexBuffer) void OpenGLSWFrameBuffer::DrawTriangleFans(int count, const FBVERTEX *vertices) { + count = 2 + count; + GLint oldBinding = 0; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &oldBinding); @@ -500,7 +535,7 @@ void OpenGLSWFrameBuffer::DrawPoints(int count, const FBVERTEX *vertices) void OpenGLSWFrameBuffer::DrawLineList(int count) { - glDrawArrays(GL_LINES, 0, count); + glDrawArrays(GL_LINES, 0, count * 2); } void OpenGLSWFrameBuffer::DrawTriangleList(int minIndex, int numVertices, int startIndex, int primitiveCount) @@ -511,6 +546,8 @@ void OpenGLSWFrameBuffer::DrawTriangleList(int minIndex, int numVertices, int st void OpenGLSWFrameBuffer::Present() { SwapBuffers(); + glViewport(0, 0, GetClientWidth(), GetClientHeight()); + Debug->Update(); } //========================================================================== @@ -611,6 +648,13 @@ bool OpenGLSWFrameBuffer::LoadShaders() { break; } + + glUseProgram(Shaders[i]->Program); + if (Shaders[i]->ImageLocation != -1) glUniform1i(Shaders[i]->ImageLocation, 0); + if (Shaders[i]->PaletteLocation != -1) glUniform1i(Shaders[i]->PaletteLocation, 1); + if (Shaders[i]->NewScreenLocation != -1) glUniform1i(Shaders[i]->NewScreenLocation, 0); + if (Shaders[i]->BurnLocation != -1) glUniform1i(Shaders[i]->BurnLocation, 1); + glUseProgram(0); } if (i == NUM_SHADERS) { // Success! @@ -711,7 +755,7 @@ void OpenGLSWFrameBuffer::KillNativeTexs() bool OpenGLSWFrameBuffer::CreateFBTexture() { - CreateTexture(Width, Height, 1, GL_R8, &FBTexture); + CreateTexture("FBTexture", Width, Height, 1, GL_R8, &FBTexture); FBWidth = Width; FBHeight = Height; return true; @@ -725,7 +769,7 @@ bool OpenGLSWFrameBuffer::CreateFBTexture() bool OpenGLSWFrameBuffer::CreatePaletteTexture() { - if (!CreateTexture(256, 1, 1, GL_RGBA8, &PaletteTexture)) + if (!CreateTexture("PaletteTexture", 256, 1, 1, GL_RGBA8, &PaletteTexture)) { return false; } @@ -1118,7 +1162,7 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) GLint oldBinding = 0; glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldBinding); glBindTexture(GL_TEXTURE_2D, FBTexture->Texture); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Width, Height, GL_R8, GL_UNSIGNED_BYTE, 0); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Width, Height, GL_RED, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, oldBinding); } @@ -1623,7 +1667,7 @@ OpenGLSWFrameBuffer::Atlas::Atlas(OpenGLSWFrameBuffer *fb, int w, int h, int for } *prev = this; - fb->CreateTexture(w, h, 1, format, &Tex); + fb->CreateTexture("Atlas", w, h, 1, format, &Tex); Width = w; Height = h; } @@ -1907,7 +1951,7 @@ bool OpenGLSWFrameBuffer::OpenGLTex::Update() glBindTexture(GL_TEXTURE_2D, Box->Owner->Tex->Texture); glTexSubImage2D(GL_TEXTURE_2D, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, format == GL_RGBA8 ? GL_BGRA : GL_RED, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, oldBinding); - glBindTexture(GL_PIXEL_UNPACK_BUFFER, 0); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); return true; } @@ -1996,7 +2040,7 @@ OpenGLSWFrameBuffer::OpenGLPal::OpenGLPal(FRemapTable *remap, OpenGLSWFrameBuffe BorderColor = 0; RoundedPaletteSize = count; - if (fb->CreateTexture(count, 1, 1, GL_RGBA8, &Tex)) + if (fb->CreateTexture("Pal", count, 1, 1, GL_RGBA8, &Tex)) { if (!Update()) { @@ -3312,7 +3356,7 @@ void OpenGLSWFrameBuffer::SetColorOverlay(uint32_t color, float alpha, uint32_t } } -void OpenGLSWFrameBuffer::EnableAlphaTest(BOOL enabled) +void OpenGLSWFrameBuffer::EnableAlphaTest(bool enabled) { if (enabled != AlphaTestEnabled) { diff --git a/src/gl/system/gl_swframebuffer.h b/src/gl/system/gl_swframebuffer.h index eed9b6f7f..2c50b2e97 100644 --- a/src/gl/system/gl_swframebuffer.h +++ b/src/gl/system/gl_swframebuffer.h @@ -136,12 +136,18 @@ private: int Program = 0; int VertexShader = 0; int FragmentShader = 0; + + int ConstantLocations[4]; + int ImageLocation = -1; + int PaletteLocation = -1; + int NewScreenLocation = -1; + int BurnLocation = -1; }; bool CreatePixelShader(FString vertexsrc, FString fragmentsrc, const FString &defines, HWPixelShader **outShader); bool CreateVertexBuffer(int size, HWVertexBuffer **outVertexBuffer); bool CreateIndexBuffer(int size, HWIndexBuffer **outIndexBuffer); - bool CreateTexture(int width, int height, int levels, int format, HWTexture **outTexture); + bool CreateTexture(const FString &name, int width, int height, int levels, int format, HWTexture **outTexture); void SetGammaRamp(const GammaRamp *ramp); void SetPixelShaderConstantF(int uniformIndex, const float *data, int vec4fcount); void SetHWPixelShader(HWPixelShader *shader); @@ -154,7 +160,7 @@ private: void Present(); static uint32_t ColorARGB(uint32_t a, uint32_t r, uint32_t g, uint32_t b) { return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | ((b) & 0xff); } - static uint32_t ColorRGBA(uint32_t a, uint32_t r, uint32_t g, uint32_t b) { return ColorARGB(a, r, g, b); } + static uint32_t ColorRGBA(uint32_t r, uint32_t g, uint32_t b, uint32_t a) { return ColorARGB(a, r, g, b); } static uint32_t ColorXRGB(uint32_t r, uint32_t g, uint32_t b) { return ColorARGB(0xff, r, g, b); } static uint32_t ColorValue(float r, float g, float b, float a) { return ColorRGBA((uint32_t)(r * 255.0f), (uint32_t)(g * 255.0f), (uint32_t)(b * 255.0f), (uint32_t)(a * 255.0f)); } @@ -297,10 +303,10 @@ private: enum { - PSCONST_Desaturation = 1, - PSCONST_PaletteMod = 2, - PSCONST_Weights = 6, - PSCONST_Gamma = 7, + PSCONST_Desaturation = 0, + PSCONST_PaletteMod = 1, + PSCONST_Weights = 2, + PSCONST_Gamma = 3, }; enum { @@ -366,7 +372,7 @@ private: void EndBatch(); // State - void EnableAlphaTest(BOOL enabled); + void EnableAlphaTest(bool enabled); void SetAlphaBlend(int op, int srcblend = 0, int destblend = 0); void SetConstant(int cnum, float r, float g, float b, float a); void SetPixelShader(HWPixelShader *shader); @@ -377,13 +383,17 @@ private: template static void SafeRelease(T &x) { if (x != nullptr) { delete x; x = nullptr; } } - std::unique_ptr StreamVertexBuffer; + std::shared_ptr Debug; - BOOL AlphaTestEnabled; - BOOL AlphaBlendEnabled; - int AlphaBlendOp; - int AlphaSrcBlend; - int AlphaDestBlend; + std::unique_ptr StreamVertexBuffer; + float ShaderConstants[16]; + HWPixelShader *CurrentShader = nullptr; + + bool AlphaTestEnabled = false; + bool AlphaBlendEnabled = false; + int AlphaBlendOp = 0; + int AlphaSrcBlend = 0; + int AlphaDestBlend = 0; float Constant[3][4]; uint32_t CurBorderColor; HWPixelShader *CurPixelShader; diff --git a/wadsrc/static/shaders/glsl/swshader.fp b/wadsrc/static/shaders/glsl/swshader.fp index 22364f460..639ea92e5 100644 --- a/wadsrc/static/shaders/glsl/swshader.fp +++ b/wadsrc/static/shaders/glsl/swshader.fp @@ -5,15 +5,15 @@ in vec4 PixelTexCoord0; out vec4 FragColor; -uniform sampler2D Image;// : register(s0); -uniform sampler2D Palette;// : register(s1); -uniform sampler2D NewScreen;// : register(s0); -uniform sampler2D Burn;// : register(s1); +uniform sampler2D Image; +uniform sampler2D Palette; +uniform sampler2D NewScreen; +uniform sampler2D Burn; -uniform vec4 Desaturation;// : register(c1); // { Desat, 1 - Desat } -uniform vec4 PaletteMod;// : register(c2); -uniform vec4 Weights;// : register(c6); // RGB->Gray weighting { 77/256.0, 143/256.0, 37/256.0, 1 } -uniform vec4 Gamma;// : register(c7); +uniform vec4 Desaturation; // { Desat, 1 - Desat } +uniform vec4 PaletteMod; +uniform vec4 Weights; // RGB->Gray weighting { 77/256.0, 143/256.0, 37/256.0, 1 } +uniform vec4 Gamma; vec4 TextureLookup(vec2 tex_coord) { diff --git a/wadsrc/static/shaders/glsl/swshader.vp b/wadsrc/static/shaders/glsl/swshader.vp index 4d00296cb..35254a042 100644 --- a/wadsrc/static/shaders/glsl/swshader.vp +++ b/wadsrc/static/shaders/glsl/swshader.vp @@ -10,8 +10,9 @@ out vec4 PixelTexCoord0; void main() { - gl_Position = AttrPosition; - PixelColor0 = AttrColor0; - PixelColor1 = AttrColor1; + gl_Position = vec4(AttrPosition.xy / vec2(1920*2,1080*2) * 2.0 - 1.0, 1.0, 1.0); + gl_Position.y = -gl_Position.y; + PixelColor0 = AttrColor0.bgra; + PixelColor1 = AttrColor1.bgra; PixelTexCoord0 = AttrTexCoord0; } From dde25820e24e6e243eae96d53a9a19e437bc1c6c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 11 Oct 2016 09:08:31 +0200 Subject: [PATCH 1059/1509] - fixed winding of voxel polygons. --- src/gl/models/gl_voxels.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 288b1a9db..6e84bd7ab 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -314,12 +314,12 @@ void FVoxelModel::MakeSlabPolys(int x, int y, kvxslab_t *voxptr, FVoxelMap &chec } if (cull & 4) { - AddFace(x, y, z, x+1, y, z, x, y, z+c, x+1, y, z+c, *col, check); + AddFace(x+1, y, z, x, y, z, x+1, y, z+c, x, y, z+c, *col, check); } if (cull & 8) { - AddFace(x+1, y+1, z, x, y+1, z, x+1, y+1, z+c, x, y+1, z+c, *col, check); - } + AddFace(x, y+1, z, x+1, y+1, z, x, y+1, z+c, x+1, y+1, z+c, *col, check); + } z+=c; col+=c; } From 01dc9de8d15cf5ea43b5742673fac926e4bd5223 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 11 Oct 2016 10:27:18 +0200 Subject: [PATCH 1060/1509] Misc bug fixes and performance improvements --- src/gl/system/gl_swframebuffer.cpp | 112 +++++++++++++++---------- src/gl/system/gl_swframebuffer.h | 59 ++++++++----- src/win32/hardware.cpp | 10 ++- wadsrc/static/shaders/glsl/swshader.vp | 4 +- 4 files changed, 113 insertions(+), 72 deletions(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 1ff48d13b..d2f2e3aee 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -130,14 +130,14 @@ OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, ogl_LoadFunctions(); } gl_LoadExtensions(); - Super::InitializeState(); - - Debug = std::make_shared(); - Debug->Update(); + InitializeState(); // SetVSync needs to be at the very top to workaround a bug in Nvidia's OpenGL driver. // If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed! - //SetVSync(vid_vsync); + Super::SetVSync(vid_vsync); + + Debug = std::make_shared(); + Debug->Update(); VertexBuffer = nullptr; IndexBuffer = nullptr; @@ -216,7 +216,7 @@ OpenGLSWFrameBuffer::~OpenGLSWFrameBuffer() OpenGLSWFrameBuffer::HWTexture::~HWTexture() { if (Texture != 0) glDeleteTextures(1, (GLuint*)&Texture); - if (Buffer != 0) glDeleteBuffers(1, (GLuint*)&Buffer); + if (Buffers[0] != 0) glDeleteBuffers(2, (GLuint*)Buffers); } OpenGLSWFrameBuffer::HWVertexBuffer::~HWVertexBuffer() @@ -228,7 +228,7 @@ OpenGLSWFrameBuffer::HWVertexBuffer::~HWVertexBuffer() OpenGLSWFrameBuffer::FBVERTEX *OpenGLSWFrameBuffer::HWVertexBuffer::Lock() { glBindBuffer(GL_ARRAY_BUFFER, Buffer); - return (FBVERTEX*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); + return (FBVERTEX*)glMapBufferRange(GL_ARRAY_BUFFER, 0, Size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); } void OpenGLSWFrameBuffer::HWVertexBuffer::Unlock() @@ -246,7 +246,7 @@ uint16_t *OpenGLSWFrameBuffer::HWIndexBuffer::Lock() { glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &LockedOldBinding); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, Buffer); - return (uint16_t*)glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); + return (uint16_t*)glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, Size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); } void OpenGLSWFrameBuffer::HWIndexBuffer::Unlock() @@ -321,6 +321,7 @@ bool OpenGLSWFrameBuffer::CreatePixelShader(FString vertexsrc, FString fragments shader->ConstantLocations[PSCONST_PaletteMod] = glGetUniformLocation(shader->Program, "PaletteMod"); shader->ConstantLocations[PSCONST_Weights] = glGetUniformLocation(shader->Program, "Weights"); shader->ConstantLocations[PSCONST_Gamma] = glGetUniformLocation(shader->Program, "Gamma"); + shader->ConstantLocations[PSCONST_ScreenSize] = glGetUniformLocation(shader->Program, "ScreenSize"); shader->ImageLocation = glGetUniformLocation(shader->Program, "Image"); shader->PaletteLocation = glGetUniformLocation(shader->Program, "Palette"); shader->NewScreenLocation = glGetUniformLocation(shader->Program, "NewScreen"); @@ -334,6 +335,8 @@ bool OpenGLSWFrameBuffer::CreateVertexBuffer(int size, HWVertexBuffer **outVerte { auto obj = std::make_unique(); + obj->Size = size; + GLint oldBinding = 0; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &oldBinding); @@ -341,6 +344,7 @@ bool OpenGLSWFrameBuffer::CreateVertexBuffer(int size, HWVertexBuffer **outVerte glGenBuffers(1, (GLuint*)&obj->Buffer); glBindVertexArray(obj->VertexArray); glBindBuffer(GL_ARRAY_BUFFER, obj->Buffer); + FGLDebug::LabelObject(GL_BUFFER, obj->Buffer, "VertexBuffer"); glBufferData(GL_ARRAY_BUFFER, size, nullptr, GL_STREAM_DRAW); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); @@ -362,11 +366,14 @@ bool OpenGLSWFrameBuffer::CreateIndexBuffer(int size, HWIndexBuffer **outIndexBu { auto obj = std::make_unique(); + obj->Size = size; + GLint oldBinding = 0; glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &oldBinding); glGenBuffers(1, (GLuint*)&obj->Buffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, obj->Buffer); + FGLDebug::LabelObject(GL_BUFFER, obj->Buffer, "IndexBuffer"); glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, nullptr, GL_STREAM_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, oldBinding); @@ -417,7 +424,7 @@ void OpenGLSWFrameBuffer::SetGammaRamp(const GammaRamp *ramp) void OpenGLSWFrameBuffer::SetPixelShaderConstantF(int uniformIndex, const float *data, int vec4fcount) { - assert(uniformIndex < 4 && vec4fcount == 1); // This emulation of d3d9 only works for very simple stuff + assert(uniformIndex < NumPSCONST && vec4fcount == 1); // This emulation of d3d9 only works for very simple stuff for (int i = 0; i < 4; i++) ShaderConstants[uniformIndex * 4 + i] = data[i]; if (CurrentShader && CurrentShader->ConstantLocations[uniformIndex] != -1) @@ -431,7 +438,7 @@ void OpenGLSWFrameBuffer::SetHWPixelShader(HWPixelShader *shader) if (shader) { glUseProgram(shader->Program); - for (int i = 0; i < 4; i++) + for (int i = 0; i < NumPSCONST; i++) { if (shader->ConstantLocations[i] != -1) glUniform4fv(shader->ConstantLocations[i], 1, &ShaderConstants[i * 4]); @@ -547,6 +554,8 @@ void OpenGLSWFrameBuffer::Present() { SwapBuffers(); glViewport(0, 0, GetClientWidth(), GetClientHeight()); + float screensize[4] = { (float)GetClientWidth(), (float)GetClientHeight(), 1.0f, 1.0f }; + SetPixelShaderConstantF(PSCONST_ScreenSize, screensize, 1); Debug->Update(); } @@ -561,7 +570,7 @@ void OpenGLSWFrameBuffer::Present() void OpenGLSWFrameBuffer::SetInitialState() { - AlphaBlendEnabled = FALSE; + AlphaBlendEnabled = false; AlphaBlendOp = GL_FUNC_ADD; AlphaSrcBlend = 0; AlphaDestBlend = 0; @@ -583,7 +592,10 @@ void OpenGLSWFrameBuffer::SetInitialState() float weights[4] = { 77 / 256.f, 143 / 256.f, 37 / 256.f, 1 }; SetPixelShaderConstantF(PSCONST_Weights, weights, 1); - AlphaTestEnabled = FALSE; + float screensize[4] = { (float)GetClientWidth(), (float)GetClientHeight(), 1.0f, 1.0f }; + SetPixelShaderConstantF(PSCONST_ScreenSize, screensize, 1); + + AlphaTestEnabled = false; CurBorderColor = 0; @@ -1043,6 +1055,7 @@ void OpenGLSWFrameBuffer::Update() if (NeedPalUpdate) { UploadPalette(); + NeedPalUpdate = false; } BlitCycles.Reset(); @@ -1075,11 +1088,6 @@ void OpenGLSWFrameBuffer::Flip() DrawLetterbox(); DoWindowedGamma(); - // Limiting the frame rate is as simple as waiting for the timer to signal this event. - if (FPSLimitEvent != nullptr) - { - WaitForSingleObject(FPSLimitEvent, 1000); - } Present(); InScene = false; @@ -1130,18 +1138,21 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) { if (copy3d) { - if (FBTexture->Buffer == 0) + if (FBTexture->Buffers[0] == 0) { - glGenBuffers(1, (GLuint*)&FBTexture->Buffer); - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffer); + glGenBuffers(2, (GLuint*)FBTexture->Buffers); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffers[0]); + glBufferData(GL_PIXEL_UNPACK_BUFFER, Width * Height, nullptr, GL_STREAM_DRAW); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffers[1]); glBufferData(GL_PIXEL_UNPACK_BUFFER, Width * Height, nullptr, GL_STREAM_DRAW); } else { - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffer); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffers[FBTexture->CurrentBuffer]); + FBTexture->CurrentBuffer = (FBTexture->CurrentBuffer + 1) & 1; } - uint8_t *dest = (uint8_t*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); + uint8_t *dest = (uint8_t*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, Width * Height, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); if (dest) { if (Pitch == Width) @@ -1178,7 +1189,7 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) SetPaletteTexture(PaletteTexture, 256, BorderColor); memset(Constant, 0, sizeof(Constant)); SetAlphaBlend(0); - EnableAlphaTest(FALSE); + EnableAlphaTest(false); SetPixelShader(Shaders[SHADER_NormalColorPal]); if (copy3d) { @@ -1252,7 +1263,7 @@ void OpenGLSWFrameBuffer::DoWindowedGamma() SetTexture(0, TempRenderTexture); SetPixelShader(Windowed && GammaShader ? GammaShader : Shaders[SHADER_NormalColor]); SetAlphaBlend(0); - EnableAlphaTest(FALSE); + EnableAlphaTest(false); DrawTriangleFans(2, verts); delete OldRenderTarget; OldRenderTarget = nullptr; @@ -1261,18 +1272,21 @@ void OpenGLSWFrameBuffer::DoWindowedGamma() void OpenGLSWFrameBuffer::UploadPalette() { - if (PaletteTexture->Buffer == 0) + if (PaletteTexture->Buffers[0] == 0) { - glGenBuffers(1, (GLuint*)&PaletteTexture->Buffer); - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, PaletteTexture->Buffer); + glGenBuffers(2, (GLuint*)PaletteTexture->Buffers); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, PaletteTexture->Buffers[0]); + glBufferData(GL_PIXEL_UNPACK_BUFFER, 256 * 4, nullptr, GL_STREAM_DRAW); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, PaletteTexture->Buffers[1]); glBufferData(GL_PIXEL_UNPACK_BUFFER, 256 * 4, nullptr, GL_STREAM_DRAW); } else { - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, PaletteTexture->Buffer); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, PaletteTexture->Buffers[PaletteTexture->CurrentBuffer]); + PaletteTexture->CurrentBuffer = (PaletteTexture->CurrentBuffer + 1) & 1; } - uint8_t *pix = (uint8_t *)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); + uint8_t *pix = (uint8_t*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, 256 * 4, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); if (pix) { int i; @@ -1358,6 +1372,7 @@ void OpenGLSWFrameBuffer::SetVSync(bool vsync) VSync = vsync; Reset(); } + Super::SetVSync(vsync); } void OpenGLSWFrameBuffer::NewRefreshRate() @@ -1510,7 +1525,7 @@ void OpenGLSWFrameBuffer::DrawPackedTextures(int packnum) BufferedTris *quad = &QuadExtra[QuadBatchPos]; FBVERTEX *vert = &VertexData[VertexPos]; - quad->Group1 = 0; + quad->ClearSetup(); if (pack->Format == GL_R8/* && !tex->IsGray*/) { quad->Flags = BQF_WrapUV | BQF_GamePalette/* | BQF_DisableAlphaTest*/; @@ -1885,8 +1900,8 @@ bool OpenGLSWFrameBuffer::OpenGLTex::Update() rect = Box->Area; - if (Box->Owner->Tex->Buffer == 0) - glGenBuffers(1, (GLuint*)&Box->Owner->Tex->Buffer); + if (Box->Owner->Tex->Buffers[0] == 0) + glGenBuffers(2, (GLuint*)Box->Owner->Tex->Buffers); int bytesPerPixel = 4; switch (format) @@ -1896,11 +1911,13 @@ bool OpenGLSWFrameBuffer::OpenGLTex::Update() default: return false; } - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, Box->Owner->Tex->Buffer); - glBufferData(GL_PIXEL_UNPACK_BUFFER, (rect.right - rect.left) * (rect.bottom - rect.top) * bytesPerPixel, nullptr, GL_STREAM_DRAW); + int buffersize = (rect.right - rect.left) * (rect.bottom - rect.top) * bytesPerPixel; + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, Box->Owner->Tex->Buffers[Box->Owner->Tex->CurrentBuffer]); + glBufferData(GL_PIXEL_UNPACK_BUFFER, buffersize, nullptr, GL_STREAM_DRAW); + Box->Owner->Tex->CurrentBuffer = (Box->Owner->Tex->CurrentBuffer + 1) & 1; int pitch = (rect.right - rect.left) * bytesPerPixel; - uint8_t *bits = (uint8_t *)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); + uint8_t *bits = (uint8_t *)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, buffersize, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); dest = bits; if (!dest) { @@ -2088,18 +2105,21 @@ bool OpenGLSWFrameBuffer::OpenGLPal::Update() assert(Tex != nullptr); - if (Tex->Buffer == 0) + if (Tex->Buffers[0] == 0) { - glGenBuffers(1, (GLuint*)&Tex->Buffer); - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, Tex->Buffer); + glGenBuffers(2, (GLuint*)Tex->Buffers); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, Tex->Buffers[0]); + glBufferData(GL_PIXEL_UNPACK_BUFFER, Remap->NumEntries * 4, nullptr, GL_STREAM_DRAW); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, Tex->Buffers[1]); glBufferData(GL_PIXEL_UNPACK_BUFFER, Remap->NumEntries * 4, nullptr, GL_STREAM_DRAW); } else { - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, Tex->Buffer); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, Tex->Buffers[Tex->CurrentBuffer]); + Tex->CurrentBuffer = (Tex->CurrentBuffer + 1) & 1; } - buff = (uint32_t *)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); + buff = (uint32_t *)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, Remap->NumEntries * 4, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); if (buff == nullptr) { return false; @@ -2625,7 +2645,7 @@ void OpenGLSWFrameBuffer::FlatFill(int left, int top, int right, int bottom, FTe BufferedTris *quad = &QuadExtra[QuadBatchPos]; FBVERTEX *vert = &VertexData[VertexPos]; - quad->Group1 = 0; + quad->ClearSetup(); if (tex->GetTexFormat() == GL_R8 && !tex->IsGray) { quad->Flags = BQF_WrapUV | BQF_GamePalette; // | BQF_DisableAlphaTest; @@ -2743,7 +2763,7 @@ void OpenGLSWFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, in color0 = 0; color1 = 0xFFFFFFFF; - quad->Group1 = 0; + quad->ClearSetup(); if (tex->GetTexFormat() == GL_R8 && !tex->IsGray) { quad->Flags = BQF_WrapUV | BQF_GamePalette | BQF_DisableAlphaTest; @@ -2830,7 +2850,7 @@ void OpenGLSWFrameBuffer::AddColorOnlyQuad(int left, int top, int width, int hei float x = float(left) - 0.5f; float y = float(top) - 0.5f + (GatheringWipeScreen ? 0 : LBOffset); - quad->Group1 = 0; + quad->ClearSetup(); quad->ShaderNum = BQS_ColorOnly; if ((color & 0xFF000000) != 0xFF000000) { @@ -3004,7 +3024,7 @@ void OpenGLSWFrameBuffer::EndQuadBatch() { const BufferedTris *q2 = &QuadExtra[j]; if (quad->Texture != q2->Texture || - quad->Group1 != q2->Group1 || + !quad->IsSameSetup(*q2) || quad->Palette != q2->Palette) { break; @@ -3371,7 +3391,7 @@ void OpenGLSWFrameBuffer::SetAlphaBlend(int op, int srcblend, int destblend) { // Disable alpha blend if (AlphaBlendEnabled) { - AlphaBlendEnabled = FALSE; + AlphaBlendEnabled = false; glDisable(GL_BLEND); } } @@ -3382,7 +3402,7 @@ void OpenGLSWFrameBuffer::SetAlphaBlend(int op, int srcblend, int destblend) if (!AlphaBlendEnabled) { - AlphaBlendEnabled = TRUE; + AlphaBlendEnabled = true; glEnable(GL_BLEND); } if (AlphaBlendOp != op) diff --git a/src/gl/system/gl_swframebuffer.h b/src/gl/system/gl_swframebuffer.h index 2c50b2e97..fca5c0839 100644 --- a/src/gl/system/gl_swframebuffer.h +++ b/src/gl/system/gl_swframebuffer.h @@ -78,7 +78,16 @@ private: uint32_t color0, color1; FLOAT tu, tv; }; - //#define D3DFVF_FBVERTEX (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1) + + enum + { + PSCONST_Desaturation, + PSCONST_PaletteMod, + PSCONST_Weights, + PSCONST_Gamma, + PSCONST_ScreenSize, + NumPSCONST + }; struct GammaRamp { @@ -93,10 +102,12 @@ private: class HWTexture { public: + HWTexture() { Buffers[0] = 0; Buffers[1] = 0; } ~HWTexture(); int Texture = 0; - int Buffer = 0; + int Buffers[2]; + int CurrentBuffer = 0; int WrapS = 0; int WrapT = 0; int Format = 0; @@ -112,6 +123,7 @@ private: int VertexArray = 0; int Buffer = 0; + int Size = 0; }; class HWIndexBuffer @@ -123,6 +135,7 @@ private: void Unlock(); int Buffer = 0; + int Size = 0; private: int LockedOldBinding = 0; @@ -137,7 +150,7 @@ private: int VertexShader = 0; int FragmentShader = 0; - int ConstantLocations[4]; + int ConstantLocations[NumPSCONST]; int ImageLocation = -1; int PaletteLocation = -1; int NewScreenLocation = -1; @@ -283,31 +296,33 @@ private: struct BufferedTris { - union - { - struct - { - uint8_t Flags; - uint8_t ShaderNum : 4; - int BlendOp; - int SrcBlend, DestBlend; - }; - uint32_t Group1; - }; + uint8_t Flags; + uint8_t ShaderNum; + int BlendOp; + int SrcBlend; + int DestBlend; + uint8_t Desat; OpenGLPal *Palette; HWTexture *Texture; uint16_t NumVerts; // Number of _unique_ vertices used by this set. uint16_t NumTris; // Number of triangles used by this set. + + void ClearSetup() + { + Flags = 0; + ShaderNum = 0; + BlendOp = 0; + SrcBlend = 0; + DestBlend = 0; + } + + bool IsSameSetup(const BufferedTris &other) const + { + return Flags == other.Flags && ShaderNum == other.ShaderNum && BlendOp == other.BlendOp && SrcBlend == other.SrcBlend && DestBlend == other.DestBlend; + } }; - enum - { - PSCONST_Desaturation = 0, - PSCONST_PaletteMod = 1, - PSCONST_Weights = 2, - PSCONST_Gamma = 3, - }; enum { SHADER_NormalColor, @@ -386,7 +401,7 @@ private: std::shared_ptr Debug; std::unique_ptr StreamVertexBuffer; - float ShaderConstants[16]; + float ShaderConstants[NumPSCONST * 4]; HWPixelShader *CurrentShader = nullptr; bool AlphaTestEnabled = false; diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 2065a9072..1d6e65477 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -136,10 +136,14 @@ void I_InitGraphics () val.Bool = !!Args->CheckParm ("-devparm"); ticker.SetGenericRepDefault (val, CVAR_Bool); - //currentrenderer = vid_renderer; +//#define USE_D3D9_VIDEO +#ifdef USE_D3D9_VIDEO + if (currentrenderer == 1) Video = gl_CreateVideo(); + else Video = new Win32Video(0); +#else + currentrenderer = vid_renderer; Video = gl_CreateVideo(); - //if (currentrenderer==1) Video = gl_CreateVideo(); - //else Video = new Win32Video (0); +#endif if (Video == NULL) I_FatalError ("Failed to initialize display"); diff --git a/wadsrc/static/shaders/glsl/swshader.vp b/wadsrc/static/shaders/glsl/swshader.vp index 35254a042..a95be1e1a 100644 --- a/wadsrc/static/shaders/glsl/swshader.vp +++ b/wadsrc/static/shaders/glsl/swshader.vp @@ -8,9 +8,11 @@ out vec4 PixelColor0; out vec4 PixelColor1; out vec4 PixelTexCoord0; +uniform vec4 ScreenSize; + void main() { - gl_Position = vec4(AttrPosition.xy / vec2(1920*2,1080*2) * 2.0 - 1.0, 1.0, 1.0); + gl_Position = vec4(AttrPosition.xy / ScreenSize.xy * 2.0 - 1.0, 1.0, 1.0); gl_Position.y = -gl_Position.y; PixelColor0 = AttrColor0.bgra; PixelColor1 = AttrColor1.bgra; From 7911302ad85d204a8e286ce2282665e5474a9f33 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 11 Oct 2016 13:09:32 +0200 Subject: [PATCH 1061/1509] Hook in gamma shader --- src/gl/system/gl_swframebuffer.cpp | 104 ++++++++++++++++++++--------- src/gl/system/gl_swframebuffer.h | 15 ++++- src/win32/hardware.cpp | 1 - 3 files changed, 86 insertions(+), 34 deletions(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index d2f2e3aee..4f8c25742 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -150,7 +150,6 @@ OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, { Shaders[i] = nullptr; } - GammaShader = nullptr; VSync = vid_vsync; BlendingRect.left = 0; BlendingRect.top = 0; @@ -213,6 +212,12 @@ OpenGLSWFrameBuffer::~OpenGLSWFrameBuffer() delete[] QuadExtra; } +OpenGLSWFrameBuffer::HWFrameBuffer::~HWFrameBuffer() +{ + if (Framebuffer != 0) glDeleteFramebuffers(1, (GLuint*)&Framebuffer); + delete Texture; +} + OpenGLSWFrameBuffer::HWTexture::~HWTexture() { if (Texture != 0) glDeleteTextures(1, (GLuint*)&Texture); @@ -262,6 +267,43 @@ OpenGLSWFrameBuffer::HWPixelShader::~HWPixelShader() if (FragmentShader != 0) glDeleteShader(FragmentShader); } +bool OpenGLSWFrameBuffer::CreateFrameBuffer(const FString &name, int width, int height, HWFrameBuffer **outFramebuffer) +{ + auto fb = std::make_unique(); + + if (!CreateTexture(name, width, height, 1, GL_RGBA16F, &fb->Texture)) + { + outFramebuffer = nullptr; + return false; + } + + glGenFramebuffers(1, (GLuint*)&fb->Framebuffer); + + GLint oldFramebufferBinding = 0, oldTextureBinding = 0; + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFramebufferBinding); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTextureBinding); + + glBindFramebuffer(GL_FRAMEBUFFER, fb->Framebuffer); + FGLDebug::LabelObject(GL_FRAMEBUFFER, fb->Framebuffer, name); + + glBindTexture(GL_TEXTURE_2D, fb->Texture->Texture); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fb->Texture->Texture, 0); + + GLenum result = glCheckFramebufferStatus(GL_FRAMEBUFFER); + + glBindFramebuffer(GL_FRAMEBUFFER, oldFramebufferBinding); + glBindTexture(GL_TEXTURE_2D, oldTextureBinding); + + if (result != GL_FRAMEBUFFER_COMPLETE) + { + outFramebuffer = nullptr; + return false; + } + + *outFramebuffer = fb.release(); + return true; +} + bool OpenGLSWFrameBuffer::CreatePixelShader(FString vertexsrc, FString fragmentsrc, const FString &defines, HWPixelShader **outShader) { auto shader = std::make_unique(); @@ -398,6 +440,7 @@ bool OpenGLSWFrameBuffer::CreateTexture(const FString &name, int width, int heig { case GL_R8: srcformat = GL_RED; break; case GL_RGBA8: srcformat = GL_BGRA; break; + case GL_RGBA16F: srcformat = GL_RGBA; break; case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: srcformat = GL_RGB; break; case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: srcformat = GL_RGBA; break; case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: srcformat = GL_RGBA; break; @@ -552,11 +595,28 @@ void OpenGLSWFrameBuffer::DrawTriangleList(int minIndex, int numVertices, int st void OpenGLSWFrameBuffer::Present() { + glBindFramebuffer(GL_FRAMEBUFFER, 0); + + FBVERTEX verts[4]; + + CalcFullscreenCoords(verts, false, true, 0, 0xFFFFFFFF); + for (int i = 0; i < 4; i++) + verts[i].tv = 1.0f - verts[i].tv; + SetTexture(0, OutputFB->Texture); + SetPixelShader(Shaders[SHADER_GammaCorrection]); + SetAlphaBlend(0); + EnableAlphaTest(false); + DrawTriangleFans(2, verts); + SwapBuffers(); + Debug->Update(); + glViewport(0, 0, GetClientWidth(), GetClientHeight()); + float screensize[4] = { (float)GetClientWidth(), (float)GetClientHeight(), 1.0f, 1.0f }; SetPixelShaderConstantF(PSCONST_ScreenSize, screensize, 1); - Debug->Update(); + + glBindFramebuffer(GL_FRAMEBUFFER, OutputFB->Framebuffer); } //========================================================================== @@ -617,6 +677,11 @@ bool OpenGLSWFrameBuffer::CreateResources() { return false; } + + if (!CreateFrameBuffer("OutputFB", Width, Height, &OutputFB)) + return false; + glBindFramebuffer(GL_FRAMEBUFFER, OutputFB->Framebuffer); + if (!CreateFBTexture() || !CreatePaletteTexture()) { @@ -698,7 +763,6 @@ void OpenGLSWFrameBuffer::ReleaseResources() { SafeRelease(Shaders[i]); } - GammaShader = nullptr; if (ScreenWipe != nullptr) { delete ScreenWipe; @@ -720,11 +784,17 @@ void OpenGLSWFrameBuffer::ReleaseDefaultPoolItems() SafeRelease(InitialWipeScreen); SafeRelease(VertexBuffer); SafeRelease(IndexBuffer); + SafeRelease(OutputFB); } bool OpenGLSWFrameBuffer::Reset() { ReleaseDefaultPoolItems(); + + if (!CreateFrameBuffer("OutputFB", Width, Height, &OutputFB)) + return false; + glBindFramebuffer(GL_FRAMEBUFFER, OutputFB->Framebuffer); + if (!CreateFBTexture() || !CreateVertexes()) { return false; @@ -1086,7 +1156,6 @@ void OpenGLSWFrameBuffer::Flip() assert(InScene); DrawLetterbox(); - DoWindowedGamma(); Present(); InScene = false; @@ -1243,33 +1312,6 @@ void OpenGLSWFrameBuffer::DrawLetterbox() } } -//========================================================================== -// -// OpenGLSWFrameBuffer :: DoWindowedGamma -// -// Draws the render target texture to the real back buffer using a gamma- -// correcting pixel shader. -// -//========================================================================== - -void OpenGLSWFrameBuffer::DoWindowedGamma() -{ - /*if (OldRenderTarget != nullptr) - { - FBVERTEX verts[4]; - - CalcFullscreenCoords(verts, false, true, 0, 0xFFFFFFFF); - SetRenderTarget(0, OldRenderTarget); - SetTexture(0, TempRenderTexture); - SetPixelShader(Windowed && GammaShader ? GammaShader : Shaders[SHADER_NormalColor]); - SetAlphaBlend(0); - EnableAlphaTest(false); - DrawTriangleFans(2, verts); - delete OldRenderTarget; - OldRenderTarget = nullptr; - }*/ -} - void OpenGLSWFrameBuffer::UploadPalette() { if (PaletteTexture->Buffers[0] == 0) diff --git a/src/gl/system/gl_swframebuffer.h b/src/gl/system/gl_swframebuffer.h index fca5c0839..716c77b9c 100644 --- a/src/gl/system/gl_swframebuffer.h +++ b/src/gl/system/gl_swframebuffer.h @@ -113,6 +113,16 @@ private: int Format = 0; }; + class HWFrameBuffer + { + public: + ~HWFrameBuffer(); + + int Framebuffer = 0; + HWTexture *Texture = nullptr; + }; + + class HWVertexBuffer { public: @@ -157,6 +167,7 @@ private: int BurnLocation = -1; }; + bool CreateFrameBuffer(const FString &name, int width, int height, HWFrameBuffer **outFramebuffer); bool CreatePixelShader(FString vertexsrc, FString fragmentsrc, const FString &defines, HWPixelShader **outShader); bool CreateVertexBuffer(int size, HWVertexBuffer **outVertexBuffer); bool CreateIndexBuffer(int size, HWIndexBuffer **outIndexBuffer); @@ -376,7 +387,6 @@ private: bool SetStyle(OpenGLTex *tex, DrawParms &parms, uint32_t &color0, uint32_t &color1, BufferedTris &quad); static int GetStyleAlpha(int type); static void SetColorOverlay(uint32_t color, float alpha, uint32_t &color0, uint32_t &color1); - void DoWindowedGamma(); void AddColorOnlyQuad(int left, int top, int width, int height, uint32_t color); void AddColorOnlyRect(int left, int top, int width, int height, uint32_t color); void CheckQuadBatch(int numtris = 2, int numverts = 4); @@ -404,6 +414,8 @@ private: float ShaderConstants[NumPSCONST * 4]; HWPixelShader *CurrentShader = nullptr; + HWFrameBuffer *OutputFB = nullptr; + bool AlphaTestEnabled = false; bool AlphaBlendEnabled = false; int AlphaBlendOp = 0; @@ -455,7 +467,6 @@ private: enum { BATCH_None, BATCH_Quads, BATCH_Lines } BatchType; HWPixelShader *Shaders[NUM_SHADERS]; - HWPixelShader *GammaShader = nullptr; HWTexture *InitialWipeScreen = nullptr, *FinalWipeScreen = nullptr; diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 1d6e65477..095edc47e 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -141,7 +141,6 @@ void I_InitGraphics () if (currentrenderer == 1) Video = gl_CreateVideo(); else Video = new Win32Video(0); #else - currentrenderer = vid_renderer; Video = gl_CreateVideo(); #endif From 7510ad1635f3c4f26b905d6d10bb95bb7a2c0e88 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 11 Oct 2016 14:52:47 +0300 Subject: [PATCH 1062/1509] Fixed missing fake floors in deferred buffer mode wow.wad is now genuine and authentic... --- src/gl/scene/gl_flats.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 394ca1626..c41e7664f 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -187,21 +187,18 @@ void GLFlat::DrawSubsector(subsector_t * sub) unsigned int vi[4]; vi[0] = 0; - for (unsigned int i = 1; i < sub->numlines-1; i += 2) + for (unsigned int i = 0; i < sub->numlines - 2; i += 2) { - if (i < sub->numlines - 3) + for (unsigned int j = 1; j < 4; j++) { - for (unsigned int j = 1; j < 4; j++) - { - vi[j] = MIN(i + j, sub->numlines - 1); - } - for (unsigned int x = 0; x < 4; x++) - { - vertex_t *vt = sub->firstline[vi[x]].v1; - qd.Set(x, vt->fX(), plane.plane.ZatPoint(vt) + dz, vt->fY(), vt->fX() / 64.f, -vt->fY() / 64.f); - } - qd.Render(GL_TRIANGLE_FAN); + vi[j] = MIN(i + j, sub->numlines - 1); } + for (unsigned int x = 0; x < 4; x++) + { + vertex_t *vt = sub->firstline[vi[x]].v1; + qd.Set(x, vt->fX(), plane.plane.ZatPoint(vt) + dz, vt->fY(), vt->fX() / 64.f, -vt->fY() / 64.f); + } + qd.Render(GL_TRIANGLE_FAN); } } From 3c7d6234cb8e357761aaca8a358ff9ce3fa6e664 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 11 Oct 2016 14:37:57 +0200 Subject: [PATCH 1063/1509] Add wipes --- src/CMakeLists.txt | 1 + src/gl/system/gl_swframebuffer.cpp | 59 ++- src/gl/system/gl_swframebuffer.h | 26 +- src/gl/system/gl_swwipe.cpp | 592 +++++++++++++++++++++++++ wadsrc/static/shaders/glsl/swshader.vp | 2 + 5 files changed, 669 insertions(+), 11 deletions(-) create mode 100644 src/gl/system/gl_swwipe.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dd241a3d7..97bdfe81b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1152,6 +1152,7 @@ set( FASTMATH_SOURCES gl/system/gl_interface.cpp gl/system/gl_framebuffer.cpp gl/system/gl_swframebuffer.cpp + gl/system/gl_swwipe.cpp gl/system/gl_debug.cpp gl/system/gl_menu.cpp gl/system/gl_wipe.cpp diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 4f8c25742..40d76aab1 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -461,6 +461,28 @@ bool OpenGLSWFrameBuffer::CreateTexture(const FString &name, int width, int heig return true; } +OpenGLSWFrameBuffer::HWTexture *OpenGLSWFrameBuffer::CopyCurrentScreen() +{ + auto obj = std::make_unique(); + obj->Format = GL_RGBA16F; + + GLint oldBinding = 0; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldBinding); + + glGenTextures(1, (GLuint*)&obj->Texture); + glBindTexture(GL_TEXTURE_2D, obj->Texture); + + glCopyTexImage2D(GL_TEXTURE_2D, 0, obj->Format, 0, 0, Width, Height, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + FGLDebug::LabelObject(GL_TEXTURE, obj->Texture, "CopyCurrentScreen"); + + glBindTexture(GL_TEXTURE_2D, oldBinding); + + return obj.release(); +} + void OpenGLSWFrameBuffer::SetGammaRamp(const GammaRamp *ramp) { } @@ -548,6 +570,39 @@ void OpenGLSWFrameBuffer::DrawTriangleFans(int count, const FBVERTEX *vertices) glBindVertexArray(oldBinding); } +void OpenGLSWFrameBuffer::DrawTriangleFans(int count, const BURNVERTEX *vertices) +{ + count = 2 + count; + + GLint oldBinding = 0; + glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &oldBinding); + + if (!StreamVertexBufferBurn) + { + StreamVertexBufferBurn = std::make_unique(); + glGenVertexArrays(1, (GLuint*)&StreamVertexBufferBurn->VertexArray); + glGenBuffers(1, (GLuint*)&StreamVertexBufferBurn->Buffer); + glBindVertexArray(StreamVertexBufferBurn->VertexArray); + glBindBuffer(GL_ARRAY_BUFFER, StreamVertexBufferBurn->Buffer); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(BURNVERTEX), vertices, GL_STREAM_DRAW); + glEnableVertexAttribArray(0); + glEnableVertexAttribArray(1); + glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(BURNVERTEX), (const GLvoid*)offsetof(BURNVERTEX, x)); + glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(BURNVERTEX), (const GLvoid*)offsetof(BURNVERTEX, tu0)); + } + else + { + glBindVertexArray(StreamVertexBufferBurn->VertexArray); + glBindBuffer(GL_ARRAY_BUFFER, StreamVertexBufferBurn->Buffer); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(BURNVERTEX), vertices, GL_STREAM_DRAW); + } + + glDrawArrays(GL_TRIANGLE_FAN, 0, count); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(oldBinding); +} + void OpenGLSWFrameBuffer::DrawPoints(int count, const FBVERTEX *vertices) { GLint oldBinding = 0; @@ -600,8 +655,8 @@ void OpenGLSWFrameBuffer::Present() FBVERTEX verts[4]; CalcFullscreenCoords(verts, false, true, 0, 0xFFFFFFFF); - for (int i = 0; i < 4; i++) - verts[i].tv = 1.0f - verts[i].tv; + //for (int i = 0; i < 4; i++) + // verts[i].tv = 1.0f - verts[i].tv; SetTexture(0, OutputFB->Texture); SetPixelShader(Shaders[SHADER_GammaCorrection]); SetAlphaBlend(0); diff --git a/src/gl/system/gl_swframebuffer.h b/src/gl/system/gl_swframebuffer.h index 716c77b9c..1cf0288ce 100644 --- a/src/gl/system/gl_swframebuffer.h +++ b/src/gl/system/gl_swframebuffer.h @@ -64,19 +64,26 @@ public: void DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 realcolor) override; void DrawPixel(int x, int y, int palcolor, uint32 rgbcolor) override; void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, DAngle rotation, FDynamicColormap *colormap, int lightlevel) override; - //bool WipeStartScreen(int type) override; - //void WipeEndScreen() override; - //bool WipeDo(int ticks) override; - //void WipeCleanup() override; + bool WipeStartScreen(int type) override; + void WipeEndScreen() override; + bool WipeDo(int ticks) override; + void WipeCleanup() override; bool Is8BitMode() override { return false; } int GetTrueHeight() override { return TrueHeight; } private: struct FBVERTEX { - FLOAT x, y, z, rhw; + float x, y, z, rhw; uint32_t color0, color1; - FLOAT tu, tv; + float tu, tv; + }; + + struct BURNVERTEX + { + float x, y, z, rhw; + float tu0, tv0; + float tu1, tv1; }; enum @@ -178,6 +185,7 @@ private: void SetStreamSource(HWVertexBuffer *vertexBuffer); void SetIndices(HWIndexBuffer *indexBuffer); void DrawTriangleFans(int count, const FBVERTEX *vertices); + void DrawTriangleFans(int count, const BURNVERTEX *vertices); void DrawPoints(int count, const FBVERTEX *vertices); void DrawLineList(int count); void DrawTriangleList(int minIndex, int numVertices, int startIndex, int primitiveCount); @@ -376,7 +384,7 @@ private: void UploadPalette(); void CalcFullscreenCoords(FBVERTEX verts[4], bool viewarea_only, bool can_double, uint32_t color0, uint32_t color1) const; bool Reset(); - HWTexture *GetCurrentScreen(); + HWTexture *CopyCurrentScreen(); void ReleaseDefaultPoolItems(); void KillNativePals(); void KillNativeTexs(); @@ -410,7 +418,7 @@ private: std::shared_ptr Debug; - std::unique_ptr StreamVertexBuffer; + std::unique_ptr StreamVertexBuffer, StreamVertexBufferBurn; float ShaderConstants[NumPSCONST * 4]; HWPixelShader *CurrentShader = nullptr; @@ -476,7 +484,7 @@ private: virtual ~Wiper(); virtual bool Run(int ticks, OpenGLSWFrameBuffer *fb) = 0; - //void DrawScreen(OpenGLSWFrameBuffer *fb, HWTexture *tex, int blendop = 0, uint32_t color0 = 0, uint32_t color1 = 0xFFFFFFF); + void DrawScreen(OpenGLSWFrameBuffer *fb, HWTexture *tex, int blendop = 0, uint32_t color0 = 0, uint32_t color1 = 0xFFFFFFF); }; class Wiper_Melt; friend class Wiper_Melt; diff --git a/src/gl/system/gl_swwipe.cpp b/src/gl/system/gl_swwipe.cpp new file mode 100644 index 000000000..2f36272b6 --- /dev/null +++ b/src/gl/system/gl_swwipe.cpp @@ -0,0 +1,592 @@ +/* +** gl_swwipe.cpp +** Implements the different screen wipes using OpenGL calls. +** +**--------------------------------------------------------------------------- +** Copyright 1998-2008 Randy Heit +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +// HEADER FILES ------------------------------------------------------------ + +#include "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "doomstat.h" +#include "m_png.h" +#include "m_crc32.h" +#include "vectors.h" +#include "v_palette.h" +#include "templates.h" + +#include "c_dispatch.h" +#include "templates.h" +#include "i_system.h" +#include "i_video.h" +#include "i_input.h" +#include "v_pfx.h" +#include "stats.h" +#include "doomerrors.h" +#include "r_main.h" +#include "r_data/r_translate.h" +#include "f_wipe.h" +#include "sbar.h" +#include "w_wad.h" +#include "r_data/colormaps.h" + +#include "gl/system/gl_interface.h" +#include "gl/system/gl_swframebuffer.h" +#include "gl/data/gl_data.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_templates.h" +#include "gl/gl_functions.h" +#include "gl_debug.h" +#include "m_random.h" + +class OpenGLSWFrameBuffer::Wiper_Crossfade : public OpenGLSWFrameBuffer::Wiper +{ +public: + Wiper_Crossfade(); + bool Run(int ticks, OpenGLSWFrameBuffer *fb); + +private: + int Clock; +}; + +class OpenGLSWFrameBuffer::Wiper_Melt : public OpenGLSWFrameBuffer::Wiper +{ +public: + Wiper_Melt(); + bool Run(int ticks, OpenGLSWFrameBuffer *fb); + +private: + // Match the strip sizes that oldschool Doom used. + static const int WIDTH = 160, HEIGHT = 200; + int y[WIDTH]; +}; + +class OpenGLSWFrameBuffer::Wiper_Burn : public OpenGLSWFrameBuffer::Wiper +{ +public: + Wiper_Burn(OpenGLSWFrameBuffer *fb); + ~Wiper_Burn(); + bool Run(int ticks, OpenGLSWFrameBuffer *fb); + +private: + static const int WIDTH = 64, HEIGHT = 64; + uint8_t BurnArray[WIDTH * (HEIGHT + 5)]; + HWTexture *BurnTexture; + int Density; + int BurnTime; +}; + +//========================================================================== +// +// OpenGLSWFrameBuffer :: WipeStartScreen +// +// Called before the current screen has started rendering. This needs to +// save what was drawn the previous frame so that it can be animated into +// what gets drawn this frame. +// +// In fullscreen mode, we use GetFrontBufferData() to grab the data that +// is visible on screen right now. +// +// In windowed mode, we can't do that because we'll get the whole desktop. +// Instead, we can conveniently use the TempRenderTexture, which is normally +// used for gamma-correcting copying the image to the back buffer. +// +//========================================================================== + +bool OpenGLSWFrameBuffer::WipeStartScreen(int type) +{ + if (!Accel2D) + { + return Super::WipeStartScreen(type); + } + + switch (type) + { + case wipe_Melt: + ScreenWipe = new Wiper_Melt; + break; + + case wipe_Burn: + ScreenWipe = new Wiper_Burn(this); + break; + + case wipe_Fade: + ScreenWipe = new Wiper_Crossfade; + break; + + default: + return false; + } + + InitialWipeScreen = CopyCurrentScreen(); + + // Make even fullscreen model render to the TempRenderTexture, so + // we can have a copy of the new screen readily available. + GatheringWipeScreen = true; + return true; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: WipeEndScreen +// +// The screen we want to animate to has just been drawn. This function is +// called in place of Update(), so it has not been Presented yet. +// +//========================================================================== + +void OpenGLSWFrameBuffer::WipeEndScreen() +{ + if (!Accel2D) + { + Super::WipeEndScreen(); + return; + } + + // Don't do anything if there is no starting point. + if (InitialWipeScreen == NULL) + { + return; + } + + // If the whole screen was drawn without 2D accel, get it in to + // video memory now. + if (!In2D) + { + Begin2D(true); + } + + EndBatch(); // Make sure all batched primitives have been drawn. + + FinalWipeScreen = CopyCurrentScreen(); + + // At this point, InitialWipeScreen holds the screen we are wiping from. + // FinalWipeScreen holds the screen we are wiping to, which may be the + // same texture as TempRenderTexture. +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: WipeDo +// +// Perform the actual wipe animation. The number of tics since the last +// time this function was called is passed in. Returns true when the wipe +// is over. The first time this function has been called, the screen is +// still locked from before and EndScene() still has not been called. +// Successive times need to call BeginScene(). +// +//========================================================================== + +bool OpenGLSWFrameBuffer::WipeDo(int ticks) +{ + if (!Accel2D) + { + return Super::WipeDo(ticks); + } + + // Sanity checks. + if (InitialWipeScreen == NULL || FinalWipeScreen == NULL) + { + return true; + } + if (GatheringWipeScreen) + { // This is the first time we've been called for this wipe. + GatheringWipeScreen = false; + } + else + { // This is the second or later time we've been called for this wipe. + InScene = true; + } + + In2D = 3; + + EnableAlphaTest(false); + bool done = ScreenWipe->Run(ticks, this); + DrawLetterbox(); + return done; +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: WipeCleanup +// +// Release any resources that were specifically created for the wipe. +// +//========================================================================== + +void OpenGLSWFrameBuffer::WipeCleanup() +{ + if (ScreenWipe != NULL) + { + delete ScreenWipe; + ScreenWipe = NULL; + } + SafeRelease( InitialWipeScreen ); + SafeRelease( FinalWipeScreen ); + GatheringWipeScreen = false; + if (!Accel2D) + { + Super::WipeCleanup(); + return; + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Wiper Constructor +// +//========================================================================== + +OpenGLSWFrameBuffer::Wiper::~Wiper() +{ +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Wiper :: DrawScreen +// +// Draw either the initial or target screen completely to the screen. +// +//========================================================================== + +void OpenGLSWFrameBuffer::Wiper::DrawScreen(OpenGLSWFrameBuffer *fb, HWTexture *tex, + int blendop, uint32_t color0, uint32_t color1) +{ + FBVERTEX verts[4]; + + fb->CalcFullscreenCoords(verts, false, false, color0, color1); + fb->SetTexture(0, tex); + fb->SetAlphaBlend(blendop, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + fb->SetPixelShader(fb->Shaders[SHADER_NormalColor]); + fb->DrawTriangleFans(2, verts); +} + +// WIPE: CROSSFADE --------------------------------------------------------- + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Wiper_Crossfade Constructor +// +//========================================================================== + +OpenGLSWFrameBuffer::Wiper_Crossfade::Wiper_Crossfade() +: Clock(0) +{ +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Wiper_Crossfade :: Run +// +// Fades the old screen into the new one over 32 ticks. +// +//========================================================================== + +bool OpenGLSWFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLSWFrameBuffer *fb) +{ + Clock += ticks; + + // Put the initial screen back to the buffer. + DrawScreen(fb, fb->InitialWipeScreen); + + // Draw the new screen on top of it. + DrawScreen(fb, fb->FinalWipeScreen, GL_FUNC_ADD, ColorValue(0,0,0,Clock / 32.f), ColorRGBA(255,255,255,0)); + + return Clock >= 32; +} + +// WIPE: MELT -------------------------------------------------------------- + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Wiper_Melt Constructor +// +//========================================================================== + +OpenGLSWFrameBuffer::Wiper_Melt::Wiper_Melt() +{ + int i, r; + + // setup initial column positions + // (y<0 => not ready to scroll yet) + y[0] = -(M_Random() & 15); + for (i = 1; i < WIDTH; ++i) + { + r = (M_Random()%3) - 1; + y[i] = clamp(y[i-1] + r, -15, 0); + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Wiper_Melt :: Run +// +// Fades the old screen into the new one over 32 ticks. +// +//========================================================================== + +bool OpenGLSWFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLSWFrameBuffer *fb) +{ + // Draw the new screen on the bottom. + DrawScreen(fb, fb->FinalWipeScreen); + + int i, dy; + int fbwidth = fb->Width; + int fbheight = fb->Height; + bool done = true; + + // Copy the old screen in vertical strips on top of the new one. + while (ticks--) + { + done = true; + for (i = 0; i < WIDTH; i++) + { + if (y[i] < 0) + { + y[i]++; + done = false; + } + else if (y[i] < HEIGHT) + { + dy = (y[i] < 16) ? y[i]+1 : 8; + y[i] = MIN(y[i] + dy, HEIGHT); + done = false; + } + if (ticks == 0) + { // Only draw for the final tick. + RECT rect; + POINT dpt; + + dpt.x = i * fbwidth / WIDTH; + dpt.y = MAX(0, y[i] * fbheight / HEIGHT); + rect.left = dpt.x; + rect.top = 0; + rect.right = (i + 1) * fbwidth / WIDTH; + rect.bottom = fbheight - dpt.y; + if (rect.bottom > rect.top) + { + fb->CheckQuadBatch(); + + BufferedTris *quad = &fb->QuadExtra[fb->QuadBatchPos]; + FBVERTEX *vert = &fb->VertexData[fb->VertexPos]; + WORD *index = &fb->IndexData[fb->IndexPos]; + + quad->ClearSetup(); + quad->Flags = BQF_DisableAlphaTest; + quad->ShaderNum = BQS_Plain; + quad->Palette = NULL; + quad->Texture = fb->InitialWipeScreen; + quad->NumVerts = 4; + quad->NumTris = 2; + + // Fill the vertex buffer. + float u0 = rect.left / float(fb->FBWidth); + float v0 = 0; + float u1 = rect.right / float(fb->FBWidth); + float v1 = (rect.bottom - rect.top) / float(fb->FBHeight); + + float x0 = float(rect.left) - 0.5f; + float x1 = float(rect.right) - 0.5f; + float y0 = float(dpt.y + fb->LBOffsetI) - 0.5f; + float y1 = float(fbheight + fb->LBOffsetI) - 0.5f; + + vert[0].x = x0; + vert[0].y = y0; + vert[0].z = 0; + vert[0].rhw = 1; + vert[0].color0 = 0; + vert[0].color1 = 0xFFFFFFF; + vert[0].tu = u0; + vert[0].tv = v0; + + vert[1].x = x1; + vert[1].y = y0; + vert[1].z = 0; + vert[1].rhw = 1; + vert[1].color0 = 0; + vert[1].color1 = 0xFFFFFFF; + vert[1].tu = u1; + vert[1].tv = v0; + + vert[2].x = x1; + vert[2].y = y1; + vert[2].z = 0; + vert[2].rhw = 1; + vert[2].color0 = 0; + vert[2].color1 = 0xFFFFFFF; + vert[2].tu = u1; + vert[2].tv = v1; + + vert[3].x = x0; + vert[3].y = y1; + vert[3].z = 0; + vert[3].rhw = 1; + vert[3].color0 = 0; + vert[3].color1 = 0xFFFFFFF; + vert[3].tu = u0; + vert[3].tv = v1; + + // Fill the vertex index buffer. + index[0] = fb->VertexPos; + index[1] = fb->VertexPos + 1; + index[2] = fb->VertexPos + 2; + index[3] = fb->VertexPos; + index[4] = fb->VertexPos + 2; + index[5] = fb->VertexPos + 3; + + // Batch the quad. + fb->QuadBatchPos++; + fb->VertexPos += 4; + fb->IndexPos += 6; + } + } + } + } + fb->EndQuadBatch(); + return done; +} + +// WIPE: BURN -------------------------------------------------------------- + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Wiper_Burn Constructor +// +//========================================================================== + +OpenGLSWFrameBuffer::Wiper_Burn::Wiper_Burn(OpenGLSWFrameBuffer *fb) +{ + Density = 4; + BurnTime = 0; + memset(BurnArray, 0, sizeof(BurnArray)); + if (fb->Shaders[SHADER_BurnWipe] == NULL || !fb->CreateTexture("BurnWipe", WIDTH, HEIGHT, 1, GL_R8, &BurnTexture)) + { + BurnTexture = NULL; + } +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Wiper_Burn Destructor +// +//========================================================================== + +OpenGLSWFrameBuffer::Wiper_Burn::~Wiper_Burn() +{ + SafeRelease( BurnTexture ); +} + +//========================================================================== +// +// OpenGLSWFrameBuffer :: Wiper_Burn :: Run +// +//========================================================================== + +bool OpenGLSWFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLSWFrameBuffer *fb) +{ + bool done; + + BurnTime += ticks; + ticks *= 2; + + // Make the fire burn + done = false; + while (!done && ticks--) + { + Density = wipe_CalcBurn(BurnArray, WIDTH, HEIGHT, Density); + done = (Density < 0); + } + + // Update the burn texture with the new burn data + + if (BurnTexture->Buffers[0] == 0) + { + glGenBuffers(2, (GLuint*)BurnTexture->Buffers); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, BurnTexture->Buffers[0]); + glBufferData(GL_PIXEL_UNPACK_BUFFER, WIDTH * HEIGHT, nullptr, GL_STREAM_DRAW); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, BurnTexture->Buffers[1]); + glBufferData(GL_PIXEL_UNPACK_BUFFER, WIDTH * HEIGHT, nullptr, GL_STREAM_DRAW); + } + else + { + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, BurnTexture->Buffers[BurnTexture->CurrentBuffer]); + BurnTexture->CurrentBuffer = (BurnTexture->CurrentBuffer + 1) & 1; + } + + uint8_t *dest = (uint8_t*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, WIDTH * HEIGHT, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + if (dest) + { + memcpy(dest, BurnArray, WIDTH * HEIGHT); + glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); + + GLint oldBinding = 0; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldBinding); + glBindTexture(GL_TEXTURE_2D, BurnTexture->Texture); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, WIDTH, HEIGHT, GL_RED, GL_UNSIGNED_BYTE, 0); + glBindTexture(GL_TEXTURE_2D, oldBinding); + + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); + } + + // Put the initial screen back to the buffer. + DrawScreen(fb, fb->InitialWipeScreen); + + // Burn the new screen on top of it. + float top = fb->LBOffset - 0.5f; + float right = float(fb->Width) - 0.5f; + float bot = float(fb->Height) + top; + float texright = float(fb->Width) / float(fb->FBWidth); + float texbot = float(fb->Height) / float(fb->FBHeight); + + BURNVERTEX verts[4] = + { + { -0.5f, top, 0.5f, 1.f, 0.f, 0.f, 0, 0 }, + { right, top, 0.5f, 1.f, texright, 0.f, 1, 0 }, + { right, bot, 0.5f, 1.f, texright, texbot, 1, 1 }, + { -0.5f, bot, 0.5f, 1.f, 0.f, texbot, 0, 1 } + }; + + fb->SetTexture(0, fb->FinalWipeScreen); + fb->SetTexture(1, BurnTexture); + fb->SetAlphaBlend(GL_FUNC_ADD, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + fb->SetPixelShader(fb->Shaders[SHADER_BurnWipe]); + glActiveTexture(GL_TEXTURE1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + fb->DrawTriangleFans(2, verts); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glActiveTexture(GL_TEXTURE0); + + // The fire may not always stabilize, so the wipe is forced to end + // after an arbitrary maximum time. + return done || (BurnTime > 40); +} diff --git a/wadsrc/static/shaders/glsl/swshader.vp b/wadsrc/static/shaders/glsl/swshader.vp index a95be1e1a..a317025aa 100644 --- a/wadsrc/static/shaders/glsl/swshader.vp +++ b/wadsrc/static/shaders/glsl/swshader.vp @@ -13,7 +13,9 @@ uniform vec4 ScreenSize; void main() { gl_Position = vec4(AttrPosition.xy / ScreenSize.xy * 2.0 - 1.0, 1.0, 1.0); +#if defined(EGAMMACORRECTION) gl_Position.y = -gl_Position.y; +#endif PixelColor0 = AttrColor0.bgra; PixelColor1 = AttrColor1.bgra; PixelTexCoord0 = AttrTexCoord0; From f37ee3a024ca08a76182e4b1168c4e97affa9821 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 11 Oct 2016 15:43:12 +0200 Subject: [PATCH 1064/1509] Add bgra support to OpenGLSWFrameBuffer --- src/gl/system/gl_framebuffer.cpp | 2 +- src/gl/system/gl_swframebuffer.cpp | 43 ++++++++++++++++++++---------- src/gl/system/gl_swframebuffer.h | 2 +- src/posix/cocoa/i_video.mm | 4 +-- src/posix/cocoa/sdlglvideo.h | 2 +- src/posix/sdl/sdlglvideo.cpp | 4 +-- src/posix/sdl/sdlglvideo.h | 2 +- src/win32/win32gliface.cpp | 8 +++--- src/win32/win32gliface.h | 4 +-- 9 files changed, 44 insertions(+), 27 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 6264352f6..57e0cd679 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -79,7 +79,7 @@ CUSTOM_CVAR(Int, vid_hwgamma, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITC //========================================================================== OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : - Super(hMonitor, width, height, bits, refreshHz, fullscreen) + Super(hMonitor, width, height, bits, refreshHz, fullscreen, false) { // SetVSync needs to be at the very top to workaround a bug in Nvidia's OpenGL driver. // If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed! diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 40d76aab1..286066fc9 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -120,8 +120,8 @@ const char *const OpenGLSWFrameBuffer::ShaderDefines[OpenGLSWFrameBuffer::NUM_SH "#define EGAMMACORRECTION", // GammaCorrection }; -OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : - Super(hMonitor, width, height, bits, refreshHz, fullscreen) +OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen, bool bgra) : + Super(hMonitor, width, height, bits, refreshHz, fullscreen, bgra) { // To do: this needs to cooperate with the same static in OpenGLFrameBuffer::InitializeState static bool first = true; @@ -892,7 +892,7 @@ void OpenGLSWFrameBuffer::KillNativeTexs() bool OpenGLSWFrameBuffer::CreateFBTexture() { - CreateTexture("FBTexture", Width, Height, 1, GL_R8, &FBTexture); + CreateTexture("FBTexture", Width, Height, 1, IsBgra() ? GL_RGBA8 : GL_R8, &FBTexture); FBWidth = Width; FBHeight = Height; return true; @@ -1262,13 +1262,16 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) { if (copy3d) { + int pixelsize = IsBgra() ? 4 : 1; + int size = Width * Height * pixelsize; + if (FBTexture->Buffers[0] == 0) { glGenBuffers(2, (GLuint*)FBTexture->Buffers); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffers[0]); - glBufferData(GL_PIXEL_UNPACK_BUFFER, Width * Height, nullptr, GL_STREAM_DRAW); + glBufferData(GL_PIXEL_UNPACK_BUFFER, size, nullptr, GL_STREAM_DRAW); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffers[1]); - glBufferData(GL_PIXEL_UNPACK_BUFFER, Width * Height, nullptr, GL_STREAM_DRAW); + glBufferData(GL_PIXEL_UNPACK_BUFFER, size, nullptr, GL_STREAM_DRAW); } else { @@ -1276,28 +1279,31 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) FBTexture->CurrentBuffer = (FBTexture->CurrentBuffer + 1) & 1; } - uint8_t *dest = (uint8_t*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, Width * Height, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + uint8_t *dest = (uint8_t*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); if (dest) { if (Pitch == Width) { - memcpy(dest, MemBuffer, Width * Height); + memcpy(dest, MemBuffer, Width * Height * pixelsize); } else { uint8_t *src = MemBuffer; for (int y = 0; y < Height; y++) { - memcpy(dest, src, Width); - dest += Width; - src += Pitch; + memcpy(dest, src, Width * pixelsize); + dest += Width * pixelsize; + src += Pitch * pixelsize; } } glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); GLint oldBinding = 0; glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldBinding); glBindTexture(GL_TEXTURE_2D, FBTexture->Texture); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Width, Height, GL_RED, GL_UNSIGNED_BYTE, 0); + if (IsBgra()) + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Width, Height, GL_BGRA, GL_UNSIGNED_BYTE, 0); + else + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Width, Height, GL_RED, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, oldBinding); } @@ -1314,7 +1320,10 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) memset(Constant, 0, sizeof(Constant)); SetAlphaBlend(0); EnableAlphaTest(false); - SetPixelShader(Shaders[SHADER_NormalColorPal]); + if (IsBgra()) + SetPixelShader(Shaders[SHADER_NormalColor]); + else + SetPixelShader(Shaders[SHADER_NormalColorPal]); if (copy3d) { FBVERTEX verts[4]; @@ -1330,7 +1339,10 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) { color0 = ColorValue(realfixedcolormap->ColorizeStart[0] / 2, realfixedcolormap->ColorizeStart[1] / 2, realfixedcolormap->ColorizeStart[2] / 2, 0); color1 = ColorValue(realfixedcolormap->ColorizeEnd[0] / 2, realfixedcolormap->ColorizeEnd[1] / 2, realfixedcolormap->ColorizeEnd[2] / 2, 1); - SetPixelShader(Shaders[SHADER_SpecialColormapPal]); + if (IsBgra()) + SetPixelShader(Shaders[SHADER_SpecialColormap]); + else + SetPixelShader(Shaders[SHADER_SpecialColormapPal]); } } else @@ -1341,7 +1353,10 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) CalcFullscreenCoords(verts, Accel2D, false, color0, color1); DrawTriangleFans(2, verts); } - SetPixelShader(Shaders[SHADER_NormalColorPal]); + if (IsBgra()) + SetPixelShader(Shaders[SHADER_NormalColor]); + else + SetPixelShader(Shaders[SHADER_NormalColorPal]); } //========================================================================== diff --git a/src/gl/system/gl_swframebuffer.h b/src/gl/system/gl_swframebuffer.h index 1cf0288ce..96e331389 100644 --- a/src/gl/system/gl_swframebuffer.h +++ b/src/gl/system/gl_swframebuffer.h @@ -29,7 +29,7 @@ class OpenGLFrameBuffer : public SDLGLFB public: explicit OpenGLSWFrameBuffer() {} - OpenGLSWFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen); + OpenGLSWFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen, bool bgra); ~OpenGLSWFrameBuffer(); bool IsValid() override; diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 7dc7a6eed..8c773fce9 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -1126,8 +1126,8 @@ void CocoaFrameBuffer::Flip() // --------------------------------------------------------------------------- -SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool fullscreen) -: DFrameBuffer(width, height, false) +SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool fullscreen, bool bgra) +: DFrameBuffer(width, height, bgra) , m_lock(-1) , m_isUpdatePending(false) { diff --git a/src/posix/cocoa/sdlglvideo.h b/src/posix/cocoa/sdlglvideo.h index fcbf23f2a..43f2c9c43 100644 --- a/src/posix/cocoa/sdlglvideo.h +++ b/src/posix/cocoa/sdlglvideo.h @@ -52,7 +52,7 @@ class SDLGLFB : public DFrameBuffer { public: // This must have the same parameters as the Windows version, even if they are not used! - SDLGLFB(void *hMonitor, int width, int height, int, int, bool fullscreen); + SDLGLFB(void *hMonitor, int width, int height, int, int, bool fullscreen, bool bgra); ~SDLGLFB(); virtual bool Lock(bool buffered = true); diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 86371bd49..58cfc9a23 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -314,8 +314,8 @@ bool SDLGLVideo::InitHardware (bool allowsoftware, int multisample) // FrameBuffer implementation ----------------------------------------------- -SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen) - : DFrameBuffer (width, height, false) +SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen, bool bgra) + : DFrameBuffer (width, height, bgra) { int i; diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h index 3b84f83c4..01e70caac 100644 --- a/src/posix/sdl/sdlglvideo.h +++ b/src/posix/sdl/sdlglvideo.h @@ -39,7 +39,7 @@ class SDLGLFB : public DFrameBuffer DECLARE_CLASS(SDLGLFB, DFrameBuffer) public: // this must have the same parameters as the Windows version, even if they are not used! - SDLGLFB (void *hMonitor, int width, int height, int, int, bool fullscreen); + SDLGLFB (void *hMonitor, int width, int height, int, int, bool fullscreen, bool bgra); ~SDLGLFB (); void ForceBuffering (bool force); diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index d46f45a02..0079271a3 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -381,7 +381,8 @@ DFrameBuffer *Win32GLVideo::CreateFrameBuffer(int width, int height, bool bgra, fb->m_Height == m_DisplayHeight && fb->m_Bits == m_DisplayBits && fb->m_RefreshHz == m_DisplayHz && - fb->m_Fullscreen == fs) + fb->m_Fullscreen == fs && + fb->m_Bgra == bgra) { return old; } @@ -391,7 +392,7 @@ DFrameBuffer *Win32GLVideo::CreateFrameBuffer(int width, int height, bool bgra, if (vid_renderer == 1) fb = new OpenGLFrameBuffer(m_hMonitor, m_DisplayWidth, m_DisplayHeight, m_DisplayBits, m_DisplayHz, fs); else - fb = new OpenGLSWFrameBuffer(m_hMonitor, m_DisplayWidth, m_DisplayHeight, m_DisplayBits, m_DisplayHz, fs); + fb = new OpenGLSWFrameBuffer(m_hMonitor, m_DisplayWidth, m_DisplayHeight, m_DisplayBits, m_DisplayHz, fs, bgra); return fb; } @@ -867,13 +868,14 @@ IMPLEMENT_ABSTRACT_CLASS(Win32GLFrameBuffer) // //========================================================================== -Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : BaseWinFB(width, height, false) +Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen, bool bgra) : BaseWinFB(width, height, bgra) { m_Width = width; m_Height = height; m_Bits = bits; m_RefreshHz = refreshHz; m_Fullscreen = fullscreen; + m_Bgra = bgra; m_Lock=0; RECT r; diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index d16c0dcc3..fbaf34bd5 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -101,7 +101,7 @@ public: Win32GLFrameBuffer() {} // Actually, hMonitor is a HMONITOR, but it's passed as a void * as there // look to be some cross-platform bits in the way. - Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen); + Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen, bool bgra); virtual ~Win32GLFrameBuffer(); @@ -143,7 +143,7 @@ protected: float m_Gamma, m_Brightness, m_Contrast; WORD m_origGamma[768]; BOOL m_supportsGamma; - bool m_Fullscreen; + bool m_Fullscreen, m_Bgra; int m_Width, m_Height, m_Bits, m_RefreshHz; int m_Lock; char m_displayDeviceNameBuffer[CCHDEVICENAME]; From 5e458866bc46c52e19de9fe9b7b75bdf34864dbe Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Tue, 11 Oct 2016 17:10:54 -0400 Subject: [PATCH 1065/1509] - Added CVAR handling for vid_used3d - allows to switch software mode canvas between OpenGL and Direct3D upon restart. --- src/win32/hardware.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index cf39975fd..da1ced10f 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -69,8 +69,16 @@ FRenderer *gl_CreateInterface(); void I_RestartRenderer(); int currentrenderer = -1; +int currentcanvas = -1; bool changerenderer; +// Software OpenGL canvas +CUSTOM_CVAR(Bool, vid_used3d, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (self != currentcanvas) + Printf("You must restart " GAMENAME " for this change to take effect.\n"); +} + // [ZDoomGL] CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { @@ -137,13 +145,13 @@ void I_InitGraphics () val.Bool = !!Args->CheckParm ("-devparm"); ticker.SetGenericRepDefault (val, CVAR_Bool); -//#define USE_D3D9_VIDEO -#ifdef USE_D3D9_VIDEO - if (currentrenderer == 1) Video = gl_CreateVideo(); - else Video = new Win32Video(0); -#else - Video = gl_CreateVideo(); -#endif + if (currentcanvas == 1) // Software Canvas: 1 = D3D or DirectDraw, 0 = OpenGL + if (currentrenderer == 1) + Video = gl_CreateVideo(); + else + Video = new Win32Video(0); + else + Video = gl_CreateVideo(); if (Video == NULL) I_FatalError ("Failed to initialize display"); @@ -161,6 +169,7 @@ static void I_DeleteRenderer() void I_CreateRenderer() { currentrenderer = vid_renderer; + currentcanvas = vid_used3d; if (Renderer == NULL) { if (currentrenderer==1) Renderer = gl_CreateInterface(); From 13271cb967779605d59d917891167625e34eab6f Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Tue, 11 Oct 2016 17:42:46 -0400 Subject: [PATCH 1066/1509] - Created menus for all this render-switching insanity. --- wadsrc/static/language.enu | 12 ++++++++++++ wadsrc/static/menudef.txt | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index a662b719e..c603864a7 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2145,6 +2145,12 @@ MODMNU_QUALITY = "Quality"; MODMNU_VOLUMERAMPING = "Volume ramping"; MODMNU_CHIPOMATIC = "Chip-o-matic"; +// Renderer Options +RNDMNU_TITLE = "CHANGE RENDERER"; +RNDMNU_RENDERER = "Hardware Acceleration"; +RNDMNU_TRUECOLOR = "Software Truecolor Mode"; +RNDMNU_CANVAS = "Software Canvas"; + // Video Options VIDMNU_TITLE = "VIDEO MODE"; VIDMNU_FULLSCREEN = "Fullscreen"; @@ -2152,6 +2158,7 @@ VIDMNU_HIDPI = "Retina/HiDPI support"; VIDMNU_ASPECTRATIO = "Aspect ratio"; VIDMNU_FORCEASPECT = "Force aspect ratio"; VIDMNU_5X4ASPECTRATIO = "Enable 5:4 aspect ratio"; +VIDMNU_CHANGERENDER = "Change Rendering Output"; VIDMNU_ENTERTEXT = "Press ENTER to set mode"; VIDMNU_TESTTEXT1 = "T to test mode for 5 seconds"; VIDMNU_TESTTEXT2 = "Please wait 5 seconds..."; @@ -2300,6 +2307,11 @@ OPTVAL_WARNINGS = "Warnings"; OPTVAL_NOTIFICATIONS = "Notifications"; OPTVAL_EVERYTHING = "Everything"; OPTVAL_FULLSCREENONLY = "Fullscreen only"; +OPTVAL_GL = "OpenGL"; +OPTVAL_D3D = "Direct3D"; +OPTVAL_HWPOLY = "OpenGL-Accelerated"; +OPTVAL_SWDOOM = "Doom Software Renderer"; + // Colors C_BRICK = "\cabrick"; C_TAN = "\cbtan"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index cbe3fcb97..b26c4c4a5 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1734,6 +1734,41 @@ OptionMenu ModReplayerOptions // the foo_dumb preferences in foobar2000. } +/*======================================= + * + * Change Renderer Menu + * + *=======================================*/ + +OptionValue "PolyDoom" +{ + 0, "$OPTVAL_SWDOOM" + 1, "$OPTVAL_HWPOLY" +} + +OptionValue "D3DGL" +{ + 0, "$OPTVAL_GL" + 1, "$OPTVAL_D3D" +} + +OptionValue "GLD3D" +{ + 0, "$OPTVAL_D3D" + 1, "$OPTVAL_GL" +} + +OptionMenu RendererMenu +{ + Title "$RNDMNU_TITLE" + Option "$RNDMNU_RENDERER", "vid_renderer", "PolyDoom" + Option "$RNDMNU_TRUECOLOR", "swtruecolor", "OnOff" + IfOption(Windows) + { + Option "$RNDMNU_CANVAS", "vid_used3d", "D3DGL" + } +} + /*======================================= * * Video mode menu @@ -1782,6 +1817,7 @@ OptionMenu VideoModeMenu Option "$VIDMNU_ASPECTRATIO", "menu_screenratios", "Ratios" Option "$VIDMNU_FORCEASPECT", "vid_aspect", "ForceRatios" Option "$VIDMNU_5X4ASPECTRATIO", "vid_tft", "YesNo" + Submenu "$VIDMNU_CHANGERENDER", "RendererMenu" StaticText " " ScreenResolution "res_0" ScreenResolution "res_1" From 41bf9def805cc832fed9d7efa02b6d1a71b9f170 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Tue, 11 Oct 2016 20:15:46 -0500 Subject: [PATCH 1067/1509] GZDoom compatibility for PSPF_FLIP. --- src/gl/scene/gl_weapon.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index cfa5c05d7..a2a12f947 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -129,19 +129,20 @@ void FGLRenderer::DrawPSprite (player_t * player,DPSprite *psp, float sx, float y1 = viewwindowy + vh / 2 - (ftexturemid * scale); y2 = y1 + (r.height * scale) + 1; - if (!mirror) + if (!(mirror) != !(psp->Flags & PSPF_FLIP)) { - fU1=tex->GetSpriteUL(); - fV1=tex->GetSpriteVT(); - fU2=tex->GetSpriteUR(); - fV2=tex->GetSpriteVB(); + fU2 = tex->GetSpriteUL(); + fV1 = tex->GetSpriteVT(); + fU1 = tex->GetSpriteUR(); + fV2 = tex->GetSpriteVB(); } else { - fU2=tex->GetSpriteUL(); - fV1=tex->GetSpriteVT(); - fU1=tex->GetSpriteUR(); - fV2=tex->GetSpriteVB(); + fU1 = tex->GetSpriteUL(); + fV1 = tex->GetSpriteVT(); + fU2 = tex->GetSpriteUR(); + fV2 = tex->GetSpriteVB(); + } if (tex->GetTransparent() || OverrideShader != -1) From 698b05ee699b9c5afbfa0d7835f8a7a791109c49 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 12 Oct 2016 07:34:07 +0200 Subject: [PATCH 1068/1509] Fix pixel center and letter box issues --- src/gl/system/gl_swframebuffer.cpp | 203 +++++++++++++---------------- src/gl/system/gl_swframebuffer.h | 7 +- src/gl/system/gl_swwipe.cpp | 32 ++--- 3 files changed, 105 insertions(+), 137 deletions(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 40d76aab1..252153b54 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -153,8 +153,8 @@ OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, VSync = vid_vsync; BlendingRect.left = 0; BlendingRect.top = 0; - BlendingRect.right = FBWidth; - BlendingRect.bottom = FBHeight; + BlendingRect.right = Width; + BlendingRect.bottom = Height; In2D = 0; Palettes = nullptr; Textures = nullptr; @@ -186,21 +186,6 @@ OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, //Windowed = !(static_cast(Video)->GoFullscreen(fullscreen)); TrueHeight = height; - /*if (fullscreen) - { - for (Win32Video::ModeInfo *mode = static_cast(Video)->m_Modes; mode != nullptr; mode = mode->next) - { - if (mode->width == Width && mode->height == Height) - { - TrueHeight = mode->realheight; - PixelDoubling = mode->doubling; - break; - } - } - }*/ - // Offset from top of screen to top of letterboxed screen - LBOffsetI = (TrueHeight - Height) / 2; - LBOffset = float(LBOffsetI); CreateResources(); SetInitialState(); @@ -650,28 +635,39 @@ void OpenGLSWFrameBuffer::DrawTriangleList(int minIndex, int numVertices, int st void OpenGLSWFrameBuffer::Present() { - glBindFramebuffer(GL_FRAMEBUFFER, 0); + int clientWidth = GetClientWidth(); + int clientHeight = GetClientHeight(); + if (clientWidth > 0 && clientHeight > 0) + { + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glViewport(0, 0, clientWidth, clientHeight); - FBVERTEX verts[4]; + float scale = MIN(clientWidth / (float)Width, clientHeight / (float)Height); + int letterboxWidth = (int)round(Width * scale); + int letterboxHeight = (int)round(Height * scale); + int letterboxX = (clientWidth - letterboxWidth) / 2; + int letterboxY = (clientHeight - letterboxHeight) / 2; - CalcFullscreenCoords(verts, false, true, 0, 0xFFFFFFFF); - //for (int i = 0; i < 4; i++) - // verts[i].tv = 1.0f - verts[i].tv; - SetTexture(0, OutputFB->Texture); - SetPixelShader(Shaders[SHADER_GammaCorrection]); - SetAlphaBlend(0); - EnableAlphaTest(false); - DrawTriangleFans(2, verts); + DrawLetterbox(letterboxX, letterboxY, letterboxWidth, letterboxHeight); + glViewport(letterboxX, letterboxY, letterboxWidth, letterboxHeight); + + FBVERTEX verts[4]; + CalcFullscreenCoords(verts, false, 0, 0xFFFFFFFF); + SetTexture(0, OutputFB->Texture); + SetPixelShader(Shaders[SHADER_GammaCorrection]); + SetAlphaBlend(0); + EnableAlphaTest(false); + DrawTriangleFans(2, verts); + } SwapBuffers(); Debug->Update(); - glViewport(0, 0, GetClientWidth(), GetClientHeight()); - - float screensize[4] = { (float)GetClientWidth(), (float)GetClientHeight(), 1.0f, 1.0f }; + float screensize[4] = { (float)Width, (float)Height, 1.0f, 1.0f }; SetPixelShaderConstantF(PSCONST_ScreenSize, screensize, 1); glBindFramebuffer(GL_FRAMEBUFFER, OutputFB->Framebuffer); + glViewport(0, 0, Width, Height); } //========================================================================== @@ -707,7 +703,7 @@ void OpenGLSWFrameBuffer::SetInitialState() float weights[4] = { 77 / 256.f, 143 / 256.f, 37 / 256.f, 1 }; SetPixelShaderConstantF(PSCONST_Weights, weights, 1); - float screensize[4] = { (float)GetClientWidth(), (float)GetClientHeight(), 1.0f, 1.0f }; + float screensize[4] = { (float)Width, (float)Height, 1.0f, 1.0f }; SetPixelShaderConstantF(PSCONST_ScreenSize, screensize, 1); AlphaTestEnabled = false; @@ -846,14 +842,14 @@ bool OpenGLSWFrameBuffer::Reset() { ReleaseDefaultPoolItems(); - if (!CreateFrameBuffer("OutputFB", Width, Height, &OutputFB)) - return false; - glBindFramebuffer(GL_FRAMEBUFFER, OutputFB->Framebuffer); - - if (!CreateFBTexture() || !CreateVertexes()) + if (!CreateFrameBuffer("OutputFB", Width, Height, &OutputFB) || !CreateFBTexture() || !CreateVertexes()) { return false; } + + glBindFramebuffer(GL_FRAMEBUFFER, OutputFB->Framebuffer); + glViewport(0, 0, Width, Height); + SetInitialState(); return true; } @@ -892,10 +888,7 @@ void OpenGLSWFrameBuffer::KillNativeTexs() bool OpenGLSWFrameBuffer::CreateFBTexture() { - CreateTexture("FBTexture", Width, Height, 1, GL_R8, &FBTexture); - FBWidth = Width; - FBHeight = Height; - return true; + return CreateTexture("FBTexture", Width, Height, 1, GL_R8, &FBTexture); } //========================================================================== @@ -906,11 +899,7 @@ bool OpenGLSWFrameBuffer::CreateFBTexture() bool OpenGLSWFrameBuffer::CreatePaletteTexture() { - if (!CreateTexture("PaletteTexture", 256, 1, 1, GL_RGBA8, &PaletteTexture)) - { - return false; - } - return true; + return CreateTexture("PaletteTexture", 256, 1, 1, GL_RGBA8, &PaletteTexture); } //========================================================================== @@ -942,35 +931,31 @@ bool OpenGLSWFrameBuffer::CreateVertexes() // //========================================================================== -void OpenGLSWFrameBuffer::CalcFullscreenCoords(FBVERTEX verts[4], bool viewarea_only, bool can_double, uint32_t color0, uint32_t color1) const +void OpenGLSWFrameBuffer::CalcFullscreenCoords(FBVERTEX verts[4], bool viewarea_only, uint32_t color0, uint32_t color1) const { - float offset = LBOffset;//OldRenderTarget != nullptr ? 0 : LBOffset; - float top = offset - 0.5f; - float texright = float(Width) / float(FBWidth); - float texbot = float(Height) / float(FBHeight); float mxl, mxr, myt, myb, tmxl, tmxr, tmyt, tmyb; if (viewarea_only) { // Just calculate vertices for the viewarea/BlendingRect - mxl = float(BlendingRect.left) - 0.5f; - mxr = float(BlendingRect.right) - 0.5f; - myt = float(BlendingRect.top) + top; - myb = float(BlendingRect.bottom) + top; - tmxl = float(BlendingRect.left) / float(Width) * texright; - tmxr = float(BlendingRect.right) / float(Width) * texright; - tmyt = float(BlendingRect.top) / float(Height) * texbot; - tmyb = float(BlendingRect.bottom) / float(Height) * texbot; + mxl = float(BlendingRect.left); + mxr = float(BlendingRect.right); + myt = float(BlendingRect.top); + myb = float(BlendingRect.bottom); + tmxl = float(BlendingRect.left) / float(Width); + tmxr = float(BlendingRect.right) / float(Width); + tmyt = float(BlendingRect.top) / float(Height); + tmyb = float(BlendingRect.bottom) / float(Height); } else { // Calculate vertices for the whole screen - mxl = -0.5f; - mxr = float(Width << (can_double ? PixelDoubling : 0)) - 0.5f; - myt = top; - myb = float(Height << (can_double ? PixelDoubling : 0)) + top; + mxl = 0.0f; + mxr = float(Width); + myt = 0.0f; + myb = float(Height); tmxl = 0; - tmxr = texright; + tmxr = 1.0f; tmyt = 0; - tmyb = texbot; + tmyb = 1.0f; } //{ mxl, myt, 0, 1, 0, 0xFFFFFFFF, tmxl, tmyt }, @@ -1210,8 +1195,6 @@ void OpenGLSWFrameBuffer::Flip() { assert(InScene); - DrawLetterbox(); - Present(); InScene = false; @@ -1225,8 +1208,6 @@ void OpenGLSWFrameBuffer::Flip() TrueHeight = Height; PixelDoubling = 0; - LBOffsetI = 0; - LBOffset = 0.0f; Reset(); V_OutputResized(Width, Height); @@ -1338,7 +1319,7 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) color0 = FlashColor0; color1 = FlashColor1; } - CalcFullscreenCoords(verts, Accel2D, false, color0, color1); + CalcFullscreenCoords(verts, Accel2D, color0, color1); DrawTriangleFans(2, verts); } SetPixelShader(Shaders[SHADER_NormalColorPal]); @@ -1353,18 +1334,36 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) // //========================================================================== -void OpenGLSWFrameBuffer::DrawLetterbox() +void OpenGLSWFrameBuffer::DrawLetterbox(int x, int y, int width, int height) { - if (LBOffsetI != 0) + int clientWidth = GetClientWidth(); + int clientHeight = GetClientHeight(); + if (clientWidth == 0 || clientHeight == 0) + return; + + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glEnable(GL_SCISSOR_TEST); + if (x > 0) { - glEnable(GL_SCISSOR_TEST); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glScissor(0, 0, Width, LBOffsetI); + glScissor(0, 0, clientWidth, x); glClear(GL_COLOR_BUFFER_BIT); - glScissor(0, Height + LBOffsetI, Width, TrueHeight - Height + LBOffsetI); - glClear(GL_COLOR_BUFFER_BIT); - glDisable(GL_SCISSOR_TEST); } + if (clientHeight - x - height > 0) + { + glScissor(0, x + height, clientWidth, clientHeight - x - height); + glClear(GL_COLOR_BUFFER_BIT); + } + if (y > 0) + { + glScissor(0, x, y, height); + glClear(GL_COLOR_BUFFER_BIT); + } + if (clientWidth - y - width > 0) + { + glScissor(y + width, x, clientWidth - y - width, height); + glClear(GL_COLOR_BUFFER_BIT); + } + glDisable(GL_SCISSOR_TEST); } void OpenGLSWFrameBuffer::UploadPalette() @@ -1604,7 +1603,7 @@ void OpenGLSWFrameBuffer::DrawPackedTextures(int packnum) continue; } - AddColorOnlyRect(x - 1, y - 1 - LBOffsetI, 258, 258, ColorXRGB(255, 255, 0)); + AddColorOnlyRect(x - 1, y - 1, 258, 258, ColorXRGB(255, 255, 0)); int back = 0; for (PackedTexture *box = pack->UsedList; box != nullptr; box = box->Next) { @@ -1638,8 +1637,8 @@ void OpenGLSWFrameBuffer::DrawPackedTextures(int packnum) quad->NumVerts = 4; quad->NumTris = 2; - float x0 = float(x) - 0.5f; - float y0 = float(y) - 0.5f; + float x0 = float(x); + float y0 = float(y); float x1 = x0 + 256.f; float y1 = y0 + 256.f; @@ -1695,7 +1694,7 @@ void OpenGLSWFrameBuffer::DrawPackedTextures(int packnum) { x = 8; y += 256 + 8; - if (y > TrueHeight - 256) + if (y > Height - 256) { return; } @@ -2457,7 +2456,7 @@ void OpenGLSWFrameBuffer::DrawLine(int x0, int y0, int x1, int y1, int palcolor, } // Add the endpoints to the vertex buffer. VertexData[VertexPos].x = float(x0); - VertexData[VertexPos].y = float(y0) + LBOffset; + VertexData[VertexPos].y = float(y0); VertexData[VertexPos].z = 0; VertexData[VertexPos].rhw = 1; VertexData[VertexPos].color0 = color; @@ -2466,7 +2465,7 @@ void OpenGLSWFrameBuffer::DrawLine(int x0, int y0, int x1, int y1, int palcolor, VertexData[VertexPos].tv = 0; VertexData[VertexPos + 1].x = float(x1); - VertexData[VertexPos + 1].y = float(y1) + LBOffset; + VertexData[VertexPos + 1].y = float(y1); VertexData[VertexPos + 1].z = 0; VertexData[VertexPos + 1].rhw = 1; VertexData[VertexPos + 1].color0 = color; @@ -2548,7 +2547,6 @@ void OpenGLSWFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) double uscale = 1.f / tex->Box->Owner->Width; bool scissoring = false; FBVERTEX *vert; - float yoffs; if (parms.flipX) { @@ -2598,7 +2596,7 @@ void OpenGLSWFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) BeginQuadBatch(); } glEnable(GL_SCISSOR_TEST); - glScissor(parms.lclip, parms.uclip + LBOffsetI, parms.rclip - parms.lclip, parms.dclip - parms.uclip); + glScissor(parms.lclip, parms.uclip, parms.rclip - parms.lclip, parms.dclip - parms.uclip); } #endif parms.bilinear = false; @@ -2619,23 +2617,6 @@ void OpenGLSWFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) quad->NumTris = 2; quad->NumVerts = 4; - yoffs = GatheringWipeScreen ? 0.5f : 0.5f - LBOffset; - -#if 0 - // Coordinates are truncated to integers, because that's effectively - // what the software renderer does. The hardware will instead round - // to nearest, it seems. - x0 = floorf(x0) - 0.5f; - y0 = floorf(y0) - yoffs; - x1 = floorf(x1) - 0.5f; - y1 = floorf(y1) - yoffs; -#else - x0 = x0 - 0.5f; - y0 = y0 - yoffs; - x1 = x1 - 0.5f; - y1 = y1 - yoffs; -#endif - vert = &VertexData[VertexPos]; // Fill the vertex buffer. @@ -2719,7 +2700,6 @@ void OpenGLSWFrameBuffer::FlatFill(int left, int top, int right, int bottom, FTe { return; } - float yoffs = GatheringWipeScreen ? 0.5f : 0.5f - LBOffset; float x0 = float(left); float y0 = float(top); float x1 = float(right); @@ -2732,10 +2712,6 @@ void OpenGLSWFrameBuffer::FlatFill(int left, int top, int right, int bottom, FTe float v0 = (y0 - yo) * ith; float u1 = (x1 - xo) * itw; float v1 = (y1 - yo) * ith; - x0 -= 0.5f; - y0 -= yoffs; - x1 -= 0.5f; - y1 -= yoffs; CheckQuadBatch(); @@ -2824,7 +2800,7 @@ void OpenGLSWFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, in BufferedTris *quad; FBVERTEX *verts; OpenGLTex *tex; - float yoffs, uscale, vscale; + float uscale, vscale; int i, ipos; uint32_t color0, color1; float ox, oy; @@ -2890,7 +2866,6 @@ void OpenGLSWFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, in quad->NumVerts = npoints; quad->NumTris = npoints - 2; - yoffs = GatheringWipeScreen ? 0 : LBOffset; uscale = float(1.f / (texture->GetScaledWidth() * scalex)); vscale = float(1.f / (texture->GetScaledHeight() * scaley)); ox = float(originx); @@ -2899,13 +2874,13 @@ void OpenGLSWFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, in for (i = 0; i < npoints; ++i) { verts[i].x = points[i].X; - verts[i].y = points[i].Y + yoffs; + verts[i].y = points[i].Y; verts[i].z = 0; verts[i].rhw = 1; verts[i].color0 = color0; verts[i].color1 = color1; - float u = points[i].X - 0.5f - ox; - float v = points[i].Y - 0.5f - oy; + float u = points[i].X - ox; + float v = points[i].Y - oy; if (dorotate) { float t = u; @@ -2944,8 +2919,8 @@ void OpenGLSWFrameBuffer::AddColorOnlyQuad(int left, int top, int width, int hei quad = &QuadExtra[QuadBatchPos]; verts = &VertexData[VertexPos]; - float x = float(left) - 0.5f; - float y = float(top) - 0.5f + (GatheringWipeScreen ? 0 : LBOffset); + float x = float(left); + float y = float(top); quad->ClearSetup(); quad->ShaderNum = BQS_ColorOnly; diff --git a/src/gl/system/gl_swframebuffer.h b/src/gl/system/gl_swframebuffer.h index 1cf0288ce..5876c34c6 100644 --- a/src/gl/system/gl_swframebuffer.h +++ b/src/gl/system/gl_swframebuffer.h @@ -382,7 +382,7 @@ private: bool CreatePaletteTexture(); bool CreateVertexes(); void UploadPalette(); - void CalcFullscreenCoords(FBVERTEX verts[4], bool viewarea_only, bool can_double, uint32_t color0, uint32_t color1) const; + void CalcFullscreenCoords(FBVERTEX verts[4], bool viewarea_only, uint32_t color0, uint32_t color1) const; bool Reset(); HWTexture *CopyCurrentScreen(); void ReleaseDefaultPoolItems(); @@ -390,7 +390,7 @@ private: void KillNativeTexs(); PackedTexture *AllocPackedTexture(int width, int height, bool wrapping, int format); void DrawPackedTextures(int packnum); - void DrawLetterbox(); + void DrawLetterbox(int x, int y, int width, int height); void Draw3DPart(bool copy3d); bool SetStyle(OpenGLTex *tex, DrawParms &parms, uint32_t &color0, uint32_t &color1, BufferedTris &quad); static int GetStyleAlpha(int type); @@ -442,13 +442,10 @@ private: int FlashAmount; int TrueHeight; int PixelDoubling; - int LBOffsetI; - float LBOffset; float Gamma; bool UpdatePending; bool NeedPalUpdate; bool NeedGammaUpdate; - int FBWidth, FBHeight; bool VSync; LTRBRect BlendingRect; int In2D; diff --git a/src/gl/system/gl_swwipe.cpp b/src/gl/system/gl_swwipe.cpp index 2f36272b6..148a087c5 100644 --- a/src/gl/system/gl_swwipe.cpp +++ b/src/gl/system/gl_swwipe.cpp @@ -232,7 +232,6 @@ bool OpenGLSWFrameBuffer::WipeDo(int ticks) EnableAlphaTest(false); bool done = ScreenWipe->Run(ticks, this); - DrawLetterbox(); return done; } @@ -284,7 +283,7 @@ void OpenGLSWFrameBuffer::Wiper::DrawScreen(OpenGLSWFrameBuffer *fb, HWTexture * { FBVERTEX verts[4]; - fb->CalcFullscreenCoords(verts, false, false, color0, color1); + fb->CalcFullscreenCoords(verts, false, color0, color1); fb->SetTexture(0, tex); fb->SetAlphaBlend(blendop, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); fb->SetPixelShader(fb->Shaders[SHADER_NormalColor]); @@ -410,15 +409,15 @@ bool OpenGLSWFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLSWFrameBuffer *fb) quad->NumTris = 2; // Fill the vertex buffer. - float u0 = rect.left / float(fb->FBWidth); + float u0 = rect.left / float(fb->Width); float v0 = 0; - float u1 = rect.right / float(fb->FBWidth); - float v1 = (rect.bottom - rect.top) / float(fb->FBHeight); + float u1 = rect.right / float(fb->Width); + float v1 = (rect.bottom - rect.top) / float(fb->Height); - float x0 = float(rect.left) - 0.5f; - float x1 = float(rect.right) - 0.5f; - float y0 = float(dpt.y + fb->LBOffsetI) - 0.5f; - float y1 = float(fbheight + fb->LBOffsetI) - 0.5f; + float x0 = float(rect.left); + float x1 = float(rect.right); + float y0 = float(dpt.y); + float y1 = float(fbheight); vert[0].x = x0; vert[0].y = y0; @@ -562,18 +561,15 @@ bool OpenGLSWFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLSWFrameBuffer *fb) DrawScreen(fb, fb->InitialWipeScreen); // Burn the new screen on top of it. - float top = fb->LBOffset - 0.5f; - float right = float(fb->Width) - 0.5f; - float bot = float(fb->Height) + top; - float texright = float(fb->Width) / float(fb->FBWidth); - float texbot = float(fb->Height) / float(fb->FBHeight); + float right = float(fb->Width); + float bot = float(fb->Height); BURNVERTEX verts[4] = { - { -0.5f, top, 0.5f, 1.f, 0.f, 0.f, 0, 0 }, - { right, top, 0.5f, 1.f, texright, 0.f, 1, 0 }, - { right, bot, 0.5f, 1.f, texright, texbot, 1, 1 }, - { -0.5f, bot, 0.5f, 1.f, 0.f, texbot, 0, 1 } + { 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0, 0 }, + { right, 0.f, 0.f, 1.f, 1.f, 0.f, 1, 0 }, + { right, bot, 0.f, 1.f, 1.f, 1.f, 1, 1 }, + { 0.f, bot, 0.f, 1.f, 0.f, 1.f, 0, 1 } }; fb->SetTexture(0, fb->FinalWipeScreen); From 052f7900c23cd361a99e88461ed9e8b23db58eea Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 12 Oct 2016 08:04:42 +0200 Subject: [PATCH 1069/1509] Fix swapped x and y in DrawLetterbox --- src/gl/system/gl_swframebuffer.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 252153b54..cffee9b91 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -1343,24 +1343,24 @@ void OpenGLSWFrameBuffer::DrawLetterbox(int x, int y, int width, int height) glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glEnable(GL_SCISSOR_TEST); - if (x > 0) - { - glScissor(0, 0, clientWidth, x); - glClear(GL_COLOR_BUFFER_BIT); - } - if (clientHeight - x - height > 0) - { - glScissor(0, x + height, clientWidth, clientHeight - x - height); - glClear(GL_COLOR_BUFFER_BIT); - } if (y > 0) { - glScissor(0, x, y, height); + glScissor(0, 0, clientWidth, y); glClear(GL_COLOR_BUFFER_BIT); } - if (clientWidth - y - width > 0) + if (clientHeight - y - height > 0) { - glScissor(y + width, x, clientWidth - y - width, height); + glScissor(0, y + height, clientWidth, clientHeight - y - height); + glClear(GL_COLOR_BUFFER_BIT); + } + if (x > 0) + { + glScissor(0, y, x, height); + glClear(GL_COLOR_BUFFER_BIT); + } + if (clientWidth - x - width > 0) + { + glScissor(x + width, y, clientWidth - x - width, height); glClear(GL_COLOR_BUFFER_BIT); } glDisable(GL_SCISSOR_TEST); From c5ebfd9e65309744e6cb6e78fafef5d2b33834be Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 12 Oct 2016 08:05:31 +0200 Subject: [PATCH 1070/1509] Add vid_max_width and vid_max_height --- src/gl/system/gl_swframebuffer.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 78e1a5943..344aa827a 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -86,6 +86,15 @@ EXTERN_CVAR(Bool, vid_vsync) EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Int, vid_refreshrate) +CVAR(Int, vid_max_width, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Int, vid_max_height, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) + +namespace +{ + int ClampWidth(int width) { return (vid_max_width == 0 || width < vid_max_width) ? width : vid_max_width; } + int ClampHeight(int height) { return (vid_max_height == 0 || height < vid_max_height) ? height : vid_max_height; } +} + extern cycle_t BlitCycles; void gl_LoadExtensions(); @@ -121,7 +130,7 @@ const char *const OpenGLSWFrameBuffer::ShaderDefines[OpenGLSWFrameBuffer::NUM_SH }; OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen, bool bgra) : - Super(hMonitor, width, height, bits, refreshHz, fullscreen, bgra) + Super(hMonitor, ClampWidth(width), ClampHeight(height), bits, refreshHz, fullscreen, bgra) { // To do: this needs to cooperate with the same static in OpenGLFrameBuffer::InitializeState static bool first = true; @@ -1200,8 +1209,8 @@ void OpenGLSWFrameBuffer::Flip() if (Windowed) { - int clientWidth = GetClientWidth(); - int clientHeight = GetClientHeight(); + int clientWidth = ClampWidth(GetClientWidth()); + int clientHeight = ClampHeight(GetClientHeight()); if (clientWidth > 0 && clientHeight > 0 && (Width != clientWidth || Height != clientHeight)) { Resize(clientWidth, clientHeight); From 27b432a9307811566706dbc2d5f5e07754b6caed Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 12 Oct 2016 13:25:05 +0200 Subject: [PATCH 1071/1509] Improve crash handling in drawers --- src/r_compiler/llvmdrawers.h | 7 +++ src/r_draw_rgba.cpp | 52 ++++++++++++++++ src/r_draw_rgba.h | 1 + src/r_drawt_rgba.cpp | 20 +++++++ src/r_thread.cpp | 111 ++++++++++++++++++++++++++++------- src/r_thread.h | 17 +++++- src/win32/i_crash.cpp | 34 +++++++++++ 7 files changed, 220 insertions(+), 22 deletions(-) diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 60a6c799a..afb3cadf1 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -41,6 +41,13 @@ struct DrawWallArgs simple_shade = 1, nearest_filter = 2 }; + + FString ToString() + { + FString info; + info.Format("dest_y = %i, count = %i, flags = %i", dest_y, count, flags); + return info; + } }; struct DrawSpanArgs diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 953a07858..eb840fa3b 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -104,6 +104,8 @@ public: LLVMDrawers::Instance()->DrawSpan(&args); } + FString DebugInfo() override { return "DrawSpanLLVMCommand"; } + protected: DrawSpanArgs args; @@ -247,6 +249,11 @@ public: WorkerThreadData d = ThreadData(thread); LLVMDrawers::Instance()->vlinec4(&args, &d); } + + FString DebugInfo() override + { + return "DrawWall4LLVMCommand\n" + args.ToString(); + } }; class DrawWall1LLVMCommand : public DrawerCommand @@ -301,6 +308,11 @@ public: WorkerThreadData d = ThreadData(thread); LLVMDrawers::Instance()->vlinec1(&args, &d); } + + FString DebugInfo() override + { + return "DrawWall1LLVMCommand\n" + args.ToString(); + } }; class DrawColumnLLVMCommand : public DrawerCommand @@ -318,6 +330,11 @@ protected: return d; } + FString DebugInfo() override + { + return "DrawColumnLLVMCommand"; + } + public: DrawColumnLLVMCommand() { @@ -510,6 +527,11 @@ public: *dest = 0xff000000 | (red << 16) | (green << 8) | blue; } } + + FString DebugInfo() override + { + return "DrawFuzzColumnRGBACommand"; + } }; class FillSpanRGBACommand : public DrawerCommand @@ -544,6 +566,11 @@ public: for (int i = 0; i < count; i++) dest[i] = color; } + + FString DebugInfo() override + { + return "FillSpanRGBACommand"; + } }; ///////////////////////////////////////////////////////////////////////////// @@ -663,6 +690,11 @@ public: dy--; } } + + FString DebugInfo() override + { + return "DrawSlabRGBACommand"; + } }; ///////////////////////////////////////////////////////////////////////////// @@ -737,6 +769,11 @@ public: dest[x] = 0xff000000 | (red << 16) | (green << 8) | blue; } while (++x <= x2); } + + FString DebugInfo() override + { + return "DrawFogBoundaryLineRGBACommand"; + } }; class DrawTiltedSpanRGBACommand : public DrawerCommand @@ -886,6 +923,11 @@ public: count--; } } + + FString DebugInfo() override + { + return "DrawTiltedSpanRGBACommand"; + } }; class DrawColoredSpanRGBACommand : public DrawerCommand @@ -925,6 +967,11 @@ public: for (int i = 0; i < count; i++) dest[i] = color; } + + FString DebugInfo() override + { + return "DrawColoredSpanRGBACommand"; + } }; class FillTransColumnRGBACommand : public DrawerCommand @@ -992,6 +1039,11 @@ public: dest += spacing; } } + + FString DebugInfo() override + { + return "FillTransColumnRGBACommand"; + } }; ApplySpecialColormapRGBACommand::ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen) diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index d3ad0613a..253315f14 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -137,6 +137,7 @@ class ApplySpecialColormapRGBACommand : public DrawerCommand public: ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen); void Execute(DrawerThread *thread) override; + FString DebugInfo() override { return "ApplySpecialColormapRGBACommand"; } }; template diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 18ae228e4..b4f70592e 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -104,6 +104,11 @@ public: WorkerThreadData d = ThreadData(thread); LLVMDrawers::Instance()->DrawColumnRt1(&args, &d); } + + FString DebugInfo() override + { + return "DrawColumnRt1LLVMCommand"; + } }; #define DECLARE_DRAW_COMMAND(name, func, base) \ @@ -158,6 +163,11 @@ public: { thread->dc_temp_rgba = buff == NULL ? thread->dc_temp_rgbabuff_rgba : (uint32_t*)buff; } + + FString DebugInfo() override + { + return "RtInitColsRGBACommand"; + } }; template @@ -233,6 +243,11 @@ public: dest += 32; } while (--count); } + + FString DebugInfo() override + { + return "DrawColumnHorizRGBACommand"; + } }; class FillColumnHorizRGBACommand : public DrawerCommand @@ -278,6 +293,11 @@ public: dest += 8; } while (--count); } + + FString DebugInfo() override + { + return "FillColumnHorizRGBACommand"; + } }; ///////////////////////////////////////////////////////////////////////////// diff --git a/src/r_thread.cpp b/src/r_thread.cpp index dec0b8c6c..4f10bd8bb 100644 --- a/src/r_thread.cpp +++ b/src/r_thread.cpp @@ -97,26 +97,50 @@ void DrawerCommandQueue::Finish() thread.core = 0; thread.num_cores = (int)(queue->threads.size() + 1); - for (int pass = 0; pass < queue->num_passes; pass++) + struct TryCatchData { - thread.pass_start_y = pass * queue->rows_in_pass; - thread.pass_end_y = (pass + 1) * queue->rows_in_pass; - if (pass + 1 == queue->num_passes) - thread.pass_end_y = MAX(thread.pass_end_y, MAXHEIGHT); + DrawerCommandQueue *queue; + DrawerThread *thread; + size_t command_index; + } data; - size_t size = queue->active_commands.size(); - for (size_t i = 0; i < size; i++) + data.queue = queue; + data.thread = &thread; + data.command_index = 0; + VectoredTryCatch(&data, + [](void *data) + { + TryCatchData *d = (TryCatchData*)data; + + for (int pass = 0; pass < d->queue->num_passes; pass++) { - auto &command = queue->active_commands[i]; - command->Execute(&thread); + d->thread->pass_start_y = pass * d->queue->rows_in_pass; + d->thread->pass_end_y = (pass + 1) * d->queue->rows_in_pass; + if (pass + 1 == d->queue->num_passes) + d->thread->pass_end_y = MAX(d->thread->pass_end_y, MAXHEIGHT); + + size_t size = d->queue->active_commands.size(); + for (d->command_index = 0; d->command_index < size; d->command_index++) + { + auto &command = d->queue->active_commands[d->command_index]; + command->Execute(d->thread); + } } - } + }, + [](void *data) + { + TryCatchData *d = (TryCatchData*)data; + ReportFatalError(d->queue->active_commands[d->command_index], true); + }); // Wait for everyone to finish: std::unique_lock end_lock(queue->end_mutex); queue->end_condition.wait(end_lock, [&]() { return queue->finished_threads == queue->threads.size(); }); + if (!queue->thread_error.IsEmpty()) + I_FatalError("Fatal drawer error: %s", queue->thread_error.GetChars()); + // Clean up batch: for (auto &command : queue->active_commands) @@ -157,20 +181,42 @@ void DrawerCommandQueue::StartThreads() start_lock.unlock(); // Do the work: - for (int pass = 0; pass < queue->num_passes; pass++) - { - thread->pass_start_y = pass * queue->rows_in_pass; - thread->pass_end_y = (pass + 1) * queue->rows_in_pass; - if (pass + 1 == queue->num_passes) - thread->pass_end_y = MAX(thread->pass_end_y, MAXHEIGHT); - size_t size = queue->active_commands.size(); - for (size_t i = 0; i < size; i++) + struct TryCatchData + { + DrawerCommandQueue *queue; + DrawerThread *thread; + size_t command_index; + } data; + + data.queue = queue; + data.thread = thread; + data.command_index = 0; + VectoredTryCatch(&data, + [](void *data) + { + TryCatchData *d = (TryCatchData*)data; + + for (int pass = 0; pass < d->queue->num_passes; pass++) { - auto &command = queue->active_commands[i]; - command->Execute(thread); + d->thread->pass_start_y = pass * d->queue->rows_in_pass; + d->thread->pass_end_y = (pass + 1) * d->queue->rows_in_pass; + if (pass + 1 == d->queue->num_passes) + d->thread->pass_end_y = MAX(d->thread->pass_end_y, MAXHEIGHT); + + size_t size = d->queue->active_commands.size(); + for (d->command_index = 0; d->command_index < size; d->command_index++) + { + auto &command = d->queue->active_commands[d->command_index]; + command->Execute(d->thread); + } } - } + }, + [](void *data) + { + TryCatchData *d = (TryCatchData*)data; + ReportFatalError(d->queue->active_commands[d->command_index], true); + }); // Notify main thread that we finished: std::unique_lock end_lock(queue->end_mutex); @@ -194,3 +240,26 @@ void DrawerCommandQueue::StopThreads() lock.lock(); shutdown_flag = false; } + +void DrawerCommandQueue::ReportFatalError(DrawerCommand *command, bool worker_thread) +{ + if (worker_thread) + { + std::unique_lock end_lock(Instance()->end_mutex); + if (Instance()->thread_error.IsEmpty()) + Instance()->thread_error = command->DebugInfo(); + } + else + { + I_FatalError("Fatal drawer error: %s", command->DebugInfo().GetChars()); + } +} + +#ifndef WIN32 + +void VectoredTryCatch(void *data, void(*tryBlock)(void *data), void(*catchBlock)(void *data)) +{ + tryBlock(data); +} + +#endif diff --git a/src/r_thread.h b/src/r_thread.h index 312c5ad22..5bb413240 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -79,8 +79,11 @@ public: } virtual void Execute(DrawerThread *thread) = 0; + virtual FString DebugInfo() = 0; }; +void VectoredTryCatch(void *data, void(*tryBlock)(void *data), void(*catchBlock)(void *data)); + // Manages queueing up commands and executing them on worker threads class DrawerCommandQueue { @@ -101,6 +104,7 @@ class DrawerCommandQueue std::mutex end_mutex; std::condition_variable end_condition; size_t finished_threads = 0; + FString thread_error; int threaded_render = 0; DrawerThread single_core_thread; @@ -112,6 +116,7 @@ class DrawerCommandQueue void Finish(); static DrawerCommandQueue *Instance(); + static void ReportFatalError(DrawerCommand *command, bool worker_thread); DrawerCommandQueue(); ~DrawerCommandQueue(); @@ -128,7 +133,17 @@ public: if (queue->threaded_render == 0 || !r_multithreaded) { T command(std::forward(args)...); - command.Execute(&queue->single_core_thread); + VectoredTryCatch(&command, + [](void *data) + { + T *c = (T*)data; + c->Execute(&Instance()->single_core_thread); + }, + [](void *data) + { + T *c = (T*)data; + ReportFatalError(c, false); + }); } else { diff --git a/src/win32/i_crash.cpp b/src/win32/i_crash.cpp index d4804ec0e..373f902c5 100644 --- a/src/win32/i_crash.cpp +++ b/src/win32/i_crash.cpp @@ -3399,3 +3399,37 @@ void DisplayCrashLog () } CloseTarFiles (); } + +///////////////////////////////////////////////////////////////////////////// + +namespace +{ + bool __declspec(thread) DrawerExceptionSetJumpResult; + CONTEXT __declspec(thread) DrawerExceptionSetJumpContext; + PVOID __declspec(thread) DrawerExceptionHandlerHandle; + + LONG WINAPI DrawerExceptionHandler(_EXCEPTION_POINTERS *exceptionInfo) + { + //RtlRestoreContext(&DrawerExceptionSetJumpContext, exceptionInfo->ExceptionRecord); + *exceptionInfo->ContextRecord = DrawerExceptionSetJumpContext; + return EXCEPTION_CONTINUE_EXECUTION; + } +} + +void VectoredTryCatch(void *data, void(*tryBlock)(void *data), void(*catchBlock)(void *data)) +{ + DrawerExceptionSetJumpResult = false; + RtlCaptureContext(&DrawerExceptionSetJumpContext); + if (DrawerExceptionSetJumpResult) + { + RemoveVectoredExceptionHandler(DrawerExceptionHandlerHandle); + catchBlock(data); + } + else + { + DrawerExceptionSetJumpResult = true; + DrawerExceptionHandlerHandle = AddVectoredExceptionHandler(1, DrawerExceptionHandler); + tryBlock(data); + RemoveVectoredExceptionHandler(DrawerExceptionHandlerHandle); + } +} From b5b96ee222d0d7e3e2c71589bd58d3634238f513 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 12 Oct 2016 13:49:12 +0200 Subject: [PATCH 1072/1509] Add a little bit more debug information --- src/r_compiler/llvmdrawers.h | 14 ++++++++++++++ src/r_draw_rgba.cpp | 7 +++++-- src/r_drawt_rgba.cpp | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index afb3cadf1..7f5f6658e 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -83,6 +83,13 @@ struct DrawSpanArgs simple_shade = 1, nearest_filter = 2 }; + + FString ToString() + { + FString info; + info.Format("x1 = %i, x2 = %i, y = %i, flags = %i", x1, x2, y, flags); + return info; + } }; struct DrawColumnArgs @@ -117,6 +124,13 @@ struct DrawColumnArgs { simple_shade = 1 }; + + FString ToString() + { + FString info; + info.Format("dest_y = %i, count = %i, flags = %i", dest_y, count, flags); + return info; + } }; class LLVMDrawers diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index eb840fa3b..5114b95f0 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -104,7 +104,10 @@ public: LLVMDrawers::Instance()->DrawSpan(&args); } - FString DebugInfo() override { return "DrawSpanLLVMCommand"; } + FString DebugInfo() override + { + return "DrawSpanLLVMCommand\n" + args.ToString(); + } protected: DrawSpanArgs args; @@ -332,7 +335,7 @@ protected: FString DebugInfo() override { - return "DrawColumnLLVMCommand"; + return "DrawColumnLLVMCommand\n" + args.ToString(); } public: diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index b4f70592e..bf957df3d 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -107,7 +107,7 @@ public: FString DebugInfo() override { - return "DrawColumnRt1LLVMCommand"; + return "DrawColumnRt1LLVMCommand\n" + args.ToString(); } }; From fbbdd403f19eb93c4c7747d1b000c7bea3677ec6 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Wed, 12 Oct 2016 14:37:57 -0400 Subject: [PATCH 1073/1509] - Implemented r_linearsky for dual-layer skies --- src/r_plane.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index cfc30e1c7..f016c9e04 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -888,9 +888,19 @@ static const BYTE *R_GetOneSkyColumn (FTexture *fronttex, int x) // Get a column of sky when there are two overlapping sky textures static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) { - DWORD ang = (skyangle + xtoviewangle[x]) ^ skyflip; - DWORD angle1 = (DWORD)((UMulScale16(ang, frontcyl) + frontpos) >> FRACBITS); - DWORD angle2 = (DWORD)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS); + DWORD ang, angle1, angle2 = (DWORD)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS); + + if (r_linearsky) + { + angle_t xangle = (angle_t)((0.5 - x / (double)viewwidth) * FocalTangent * ANGLE_90); + ang = (skyangle + xangle) ^ skyflip; + } + else + { + ang = (skyangle + xtoviewangle[x]) ^ skyflip; + } + angle1 = (DWORD)((UMulScale16(ang, frontcyl) + frontpos) >> FRACBITS); + angle2 = (DWORD)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS); // Check if this column has already been built. If so, there's // no reason to waste time building it again. From d96ec6c311ba5abf867844c931426f9de2b0f730 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 13 Oct 2016 02:12:48 -0400 Subject: [PATCH 1074/1509] - Expand truecolor sky buffer from 4 columns to 2048 columns. 2048 is probably the max we'll ever need, even with 4k, 8k, or higher resolutions, since the algorithm checks for repeat columns. --- src/r_plane.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index f016c9e04..a3facc342 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -852,10 +852,11 @@ extern FTexture *rw_pic; // since the most anyone can ever see of the sky is 500 pixels. // We need 4 skybufs because wallscan can draw up to 4 columns at a time. // Need two versions - one for true color and one for palette +#define MAXSKYBUF 2048 static BYTE skybuf[4][512]; -static uint32_t skybuf_bgra[4][512]; +static uint32_t skybuf_bgra[MAXSKYBUF][512]; static DWORD lastskycol[4]; -static DWORD lastskycol_bgra[4]; +static DWORD lastskycol_bgra[MAXSKYBUF]; static int skycolplace; static int skycolplace_bgra; @@ -945,7 +946,7 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) else { //return R_GetOneSkyColumn(fronttex, x); - for (i = 0; i < 4; ++i) + for (i = 0; i < MAXSKYBUF; ++i) { if (lastskycol_bgra[i] == skycol) { @@ -955,7 +956,7 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) lastskycol_bgra[skycolplace_bgra] = skycol; uint32_t *composite = skybuf_bgra[skycolplace_bgra]; - skycolplace_bgra = (skycolplace_bgra + 1) & 3; + skycolplace_bgra = (skycolplace_bgra + 1) % MAXSKYBUF; // The ordering of the following code has been tuned to allow VC++ to optimize // it well. In particular, this arrangement lets it keep count in a register From 5d08a812404b463ce6b2008f8b74092a2b501c6e Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 13 Oct 2016 02:37:38 -0400 Subject: [PATCH 1075/1509] - fixed: compiler warning with bad copy-paste - fixed: speed up sky compositing in truecolor mode with large buffers - only the last 4 buffers used are checked. --- src/r_plane.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index a3facc342..d69e8a5c4 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -889,7 +889,7 @@ static const BYTE *R_GetOneSkyColumn (FTexture *fronttex, int x) // Get a column of sky when there are two overlapping sky textures static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) { - DWORD ang, angle1, angle2 = (DWORD)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS); + DWORD ang, angle1, angle2; if (r_linearsky) { @@ -946,11 +946,12 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) else { //return R_GetOneSkyColumn(fronttex, x); - for (i = 0; i < MAXSKYBUF; ++i) + for (i = skycolplace_bgra - 4; i < skycolplace_bgra; ++i) { - if (lastskycol_bgra[i] == skycol) + int ic = (i % MAXSKYBUF); // i "checker" - can wrap around the ends of the array + if (lastskycol_bgra[ic] == skycol) { - return (BYTE*)(skybuf_bgra[i]); + return (BYTE*)(skybuf_bgra[ic]); } } From 3a133946610332bec615f444fff75efaaecf14aa Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 13 Oct 2016 02:47:07 -0400 Subject: [PATCH 1076/1509] - Changed max sky buffer to 3072 from 2048 --- src/r_plane.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index d69e8a5c4..c4d72b1a0 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -852,7 +852,7 @@ extern FTexture *rw_pic; // since the most anyone can ever see of the sky is 500 pixels. // We need 4 skybufs because wallscan can draw up to 4 columns at a time. // Need two versions - one for true color and one for palette -#define MAXSKYBUF 2048 +#define MAXSKYBUF 3072 static BYTE skybuf[4][512]; static uint32_t skybuf_bgra[MAXSKYBUF][512]; static DWORD lastskycol[4]; From d1d443497f0b81818de836c47bef34fec95ffa43 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 13 Oct 2016 11:16:51 +0200 Subject: [PATCH 1077/1509] Fix weird access violation in some of the drawers --- src/r_compiler/llvm_include.h | 1 + src/r_compiler/llvmdrawers.cpp | 129 ++++++++++++++++++--------- src/r_compiler/ssa/ssa_float_ptr.cpp | 8 +- src/r_compiler/ssa/ssa_int_ptr.cpp | 8 +- src/r_compiler/ssa/ssa_ubyte_ptr.cpp | 8 +- src/r_compiler/ssa/ssa_vec4f_ptr.cpp | 8 +- 6 files changed, 104 insertions(+), 58 deletions(-) diff --git a/src/r_compiler/llvm_include.h b/src/r_compiler/llvm_include.h index d1550f38a..adad2827d 100644 --- a/src/r_compiler/llvm_include.h +++ b/src/r_compiler/llvm_include.h @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 9391e7e20..8dcb73a2c 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -18,27 +18,25 @@ class LLVMProgram { public: LLVMProgram(); - ~LLVMProgram(); + void CreateEE(); + std::string DumpModule(); void StopLogFatalErrors(); template Func *GetProcAddress(const char *name) { return reinterpret_cast(PointerToFunction(name)); } llvm::LLVMContext &context() { return *mContext; } - llvm::Module *module() { return mModule; } + llvm::Module *module() { return mModule.get(); } llvm::ExecutionEngine *engine() { return mEngine.get(); } - llvm::legacy::PassManager *modulePassManager() { return mModulePassManager.get(); } - llvm::legacy::FunctionPassManager *functionPassManager() { return mFunctionPassManager.get(); } private: void *PointerToFunction(const char *name); + llvm::TargetMachine *machine = nullptr; std::unique_ptr mContext; - llvm::Module *mModule; + std::unique_ptr mModule; std::unique_ptr mEngine; - std::unique_ptr mModulePassManager; - std::unique_ptr mFunctionPassManager; }; class LLVMDrawersImpl : public LLVMDrawers @@ -143,8 +141,7 @@ LLVMDrawersImpl::LLVMDrawersImpl() CodegenDrawWall("tmvline1_revsubclamp", DrawWallVariant::RevSubClamp, 1); CodegenDrawWall("tmvline4_revsubclamp", DrawWallVariant::RevSubClamp, 4); - mProgram.modulePassManager()->run(*mProgram.module()); - mProgram.engine()->finalizeObject(); + mProgram.CreateEE(); FillColumn = mProgram.GetProcAddress("FillColumn"); FillColumnAdd = mProgram.GetProcAddress("FillColumnAdd"); @@ -205,6 +202,37 @@ LLVMDrawersImpl::LLVMDrawersImpl() tmvline1_revsubclamp = mProgram.GetProcAddress("tmvline1_revsubclamp"); tmvline4_revsubclamp = mProgram.GetProcAddress("tmvline4_revsubclamp"); +#if 0 + std::vector foo(1024 * 4); + std::vector boo(256 * 256 * 4); + DrawColumnArgs args = { 0 }; + WorkerThreadData thread = { 0 }; + thread.core = 0; + thread.num_cores = 1; + thread.pass_start_y = 0; + thread.pass_end_y = 3600; + thread.temp = foo.data(); + foo[125 * 4] = 1234; + foo[126 * 4] = 1234; + for (int i = 0; i < 16; i++) + boo[i] = i; + args.dest = boo.data() + 4; + args.dest_y = 125; + args.pitch = 256; + args.count = 1; + args.texturefrac = 0; + args.flags = 0; + args.iscale = 252769; + args.light = 256; + args.color = 4279179008; + args.srcalpha = 12; + args.destalpha = 256; + args.light_red = 192; + args.light_green = 256; + args.light_blue = 128; + DrawColumnRt4AddClamp(&args, &thread); +#endif + mProgram.StopLogFatalErrors(); } @@ -225,8 +253,6 @@ void LLVMDrawersImpl::CodegenDrawColumn(const char *name, DrawColumnVariant vari if (llvm::verifyFunction(*function.func)) I_FatalError("verifyFunction failed for " __FUNCTION__); - - mProgram.functionPassManager()->run(*function.func); } void LLVMDrawersImpl::CodegenDrawSpan(const char *name, DrawSpanVariant variant) @@ -245,8 +271,6 @@ void LLVMDrawersImpl::CodegenDrawSpan(const char *name, DrawSpanVariant variant) if (llvm::verifyFunction(*function.func)) I_FatalError("verifyFunction failed for " __FUNCTION__); - - mProgram.functionPassManager()->run(*function.func); } void LLVMDrawersImpl::CodegenDrawWall(const char *name, DrawWallVariant variant, int columns) @@ -266,8 +290,6 @@ void LLVMDrawersImpl::CodegenDrawWall(const char *name, DrawWallVariant variant, if (llvm::verifyFunction(*function.func)) I_FatalError("verifyFunction failed for " __FUNCTION__); - - mProgram.functionPassManager()->run(*function.func); } llvm::Type *LLVMDrawersImpl::GetDrawColumnArgsStruct(llvm::LLVMContext &context) @@ -298,7 +320,7 @@ llvm::Type *LLVMDrawersImpl::GetDrawColumnArgsStruct(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - return llvm::StructType::get(context, elements, false)->getPointerTo(); + return llvm::StructType::create(context, elements, "DrawColumnArgs", false)->getPointerTo(); } llvm::Type *LLVMDrawersImpl::GetDrawSpanArgsStruct(llvm::LLVMContext &context) @@ -329,7 +351,7 @@ llvm::Type *LLVMDrawersImpl::GetDrawSpanArgsStruct(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - return llvm::StructType::get(context, elements, false)->getPointerTo(); + return llvm::StructType::create(context, elements, "DrawSpanArgs", false)->getPointerTo(); } llvm::Type *LLVMDrawersImpl::GetDrawWallArgsStruct(llvm::LLVMContext &context) @@ -350,7 +372,7 @@ llvm::Type *LLVMDrawersImpl::GetDrawWallArgsStruct(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - return llvm::StructType::get(context, elements, false)->getPointerTo(); + return llvm::StructType::create(context, elements, "DrawWallArgs", false)->getPointerTo(); } llvm::Type *LLVMDrawersImpl::GetWorkerThreadDataStruct(llvm::LLVMContext &context) @@ -359,7 +381,7 @@ llvm::Type *LLVMDrawersImpl::GetWorkerThreadDataStruct(llvm::LLVMContext &contex for (int i = 0; i < 4; i++) elements.push_back(llvm::Type::getInt32Ty(context)); elements.push_back(llvm::Type::getInt8PtrTy(context)); - return llvm::StructType::get(context, elements, false)->getPointerTo(); + return llvm::StructType::create(context, elements, "ThreadData", false)->getPointerTo(); } ///////////////////////////////////////////////////////////////////////////// @@ -406,29 +428,28 @@ LLVMProgram::LLVMProgram() I_FatalError("Could not find LLVM target: %s", errorstring.c_str()); TargetOptions opt; - auto relocModel = Optional(Reloc::Static); - TargetMachine *machine = target->createTargetMachine(targetTriple, cpuName, cpuFeaturesStr, opt, relocModel, CodeModel::Default, CodeGenOpt::Aggressive); + auto relocModel = Optional(); + machine = target->createTargetMachine(targetTriple, cpuName, cpuFeaturesStr, opt, relocModel, CodeModel::JITDefault, CodeGenOpt::Aggressive); if (!machine) I_FatalError("Could not create LLVM target machine"); mContext = std::make_unique(); - auto moduleOwner = std::make_unique("render", context()); - mModule = moduleOwner.get(); + mModule = std::make_unique("render", context()); mModule->setTargetTriple(targetTriple); mModule->setDataLayout(machine->createDataLayout()); - EngineBuilder engineBuilder(std::move(moduleOwner)); - engineBuilder.setErrorStr(&errorstring); - engineBuilder.setOptLevel(CodeGenOpt::Aggressive); - engineBuilder.setRelocationModel(Reloc::Static); - engineBuilder.setEngineKind(EngineKind::JIT); - mEngine.reset(engineBuilder.create(machine)); - if (!mEngine) - I_FatalError("Could not create LLVM execution engine: %s", errorstring.c_str()); +} - mModulePassManager = std::make_unique(); - mFunctionPassManager = std::make_unique(mModule); +void LLVMProgram::CreateEE() +{ + using namespace llvm; + + legacy::FunctionPassManager PerFunctionPasses(mModule.get()); + legacy::PassManager PerModulePasses; + + PerFunctionPasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); + PerModulePasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); PassManagerBuilder passManagerBuilder; passManagerBuilder.OptLevel = 3; @@ -437,22 +458,46 @@ LLVMProgram::LLVMProgram() passManagerBuilder.SLPVectorize = true; passManagerBuilder.LoopVectorize = true; passManagerBuilder.LoadCombine = true; - passManagerBuilder.populateModulePassManager(*mModulePassManager.get()); - passManagerBuilder.populateFunctionPassManager(*mFunctionPassManager.get()); + passManagerBuilder.populateModulePassManager(PerModulePasses); + passManagerBuilder.populateFunctionPassManager(PerFunctionPasses); + + // Run function passes: + PerFunctionPasses.doInitialization(); + for (llvm::Function &func : *mModule.get()) + { + if (!func.isDeclaration()) + PerFunctionPasses.run(func); + } + PerFunctionPasses.doFinalization(); + + // Run module passes: + PerModulePasses.run(*mModule.get()); + + std::string errorstring; + + EngineBuilder engineBuilder(std::move(mModule)); + engineBuilder.setErrorStr(&errorstring); + engineBuilder.setOptLevel(CodeGenOpt::Aggressive); + engineBuilder.setRelocationModel(Reloc::Static); + engineBuilder.setEngineKind(EngineKind::JIT); + mEngine.reset(engineBuilder.create(machine)); + if (!mEngine) + I_FatalError("Could not create LLVM execution engine: %s", errorstring.c_str()); + + mEngine->finalizeObject(); } -LLVMProgram::~LLVMProgram() +std::string LLVMProgram::DumpModule() { - mEngine.reset(); - mContext.reset(); + std::string str; + llvm::raw_string_ostream stream(str); + mModule->print(stream, nullptr, false, true); + return stream.str(); } void *LLVMProgram::PointerToFunction(const char *name) { - llvm::Function *function = mModule->getFunction(name); - if (!function) - return nullptr; - return mEngine->getPointerToFunction(function); + return reinterpret_cast(mEngine->getFunctionAddress(name)); } void LLVMProgram::StopLogFatalErrors() diff --git a/src/r_compiler/ssa/ssa_float_ptr.cpp b/src/r_compiler/ssa/ssa_float_ptr.cpp index f694be15d..9937328f6 100644 --- a/src/r_compiler/ssa/ssa_float_ptr.cpp +++ b/src/r_compiler/ssa/ssa_float_ptr.cpp @@ -34,7 +34,7 @@ SSAFloat SSAFloatPtr::load(bool constantScopeDomain) const SSAVec4f SSAFloatPtr::load_vec4f(bool constantScopeDomain) const { llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); - auto loadInst = SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), false, SSAScope::hint()); + auto loadInst = SSAScope::builder().CreateAlignedLoad(SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), 16, false, SSAScope::hint()); if (constantScopeDomain) loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); return SSAVec4f::from_llvm(loadInst); @@ -43,7 +43,7 @@ SSAVec4f SSAFloatPtr::load_vec4f(bool constantScopeDomain) const SSAVec4f SSAFloatPtr::load_unaligned_vec4f(bool constantScopeDomain) const { llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); - auto loadInst = SSAScope::builder().CreateAlignedLoad(SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), 4, false, SSAScope::hint()); + auto loadInst = SSAScope::builder().CreateAlignedLoad(SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), 1, false, SSAScope::hint()); if (constantScopeDomain) loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); return SSAVec4f::from_llvm(loadInst); @@ -58,13 +58,13 @@ void SSAFloatPtr::store(const SSAFloat &new_value) void SSAFloatPtr::store_vec4f(const SSAVec4f &new_value) { llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); - auto inst = SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint())); + auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), 16); inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } void SSAFloatPtr::store_unaligned_vec4f(const SSAVec4f &new_value) { llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); - auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), 4); + auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), 1); inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } diff --git a/src/r_compiler/ssa/ssa_int_ptr.cpp b/src/r_compiler/ssa/ssa_int_ptr.cpp index d9441088e..daef1e7ab 100644 --- a/src/r_compiler/ssa/ssa_int_ptr.cpp +++ b/src/r_compiler/ssa/ssa_int_ptr.cpp @@ -34,7 +34,7 @@ SSAInt SSAIntPtr::load(bool constantScopeDomain) const SSAVec4i SSAIntPtr::load_vec4i(bool constantScopeDomain) const { llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); - auto loadInst = SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), false, SSAScope::hint()); + auto loadInst = SSAScope::builder().CreateAlignedLoad(SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 16, false, SSAScope::hint()); if (constantScopeDomain) loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); return SSAVec4i::from_llvm(loadInst); @@ -43,7 +43,7 @@ SSAVec4i SSAIntPtr::load_vec4i(bool constantScopeDomain) const SSAVec4i SSAIntPtr::load_unaligned_vec4i(bool constantScopeDomain) const { llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); - auto loadInst = SSAScope::builder().CreateAlignedLoad(SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 4, false, SSAScope::hint()); + auto loadInst = SSAScope::builder().CreateAlignedLoad(SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 1, false, SSAScope::hint()); if (constantScopeDomain) loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); return SSAVec4i::from_llvm(loadInst); @@ -58,13 +58,13 @@ void SSAIntPtr::store(const SSAInt &new_value) void SSAIntPtr::store_vec4i(const SSAVec4i &new_value) { llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); - auto inst = SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint())); + auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 16); inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } void SSAIntPtr::store_unaligned_vec4i(const SSAVec4i &new_value) { llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); - auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 4); + auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 1); inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } diff --git a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp index 1ce4a6ae2..18bafc689 100644 --- a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp +++ b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp @@ -43,7 +43,7 @@ SSAVec4i SSAUBytePtr::load_vec4ub(bool constantScopeDomain) const SSAVec16ub SSAUBytePtr::load_vec16ub(bool constantScopeDomain) const { llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); - auto loadInst = SSAScope::builder().CreateLoad(SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), false, SSAScope::hint()); + auto loadInst = SSAScope::builder().CreateAlignedLoad(SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), 16, false, SSAScope::hint()); if (constantScopeDomain) loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); return SSAVec16ub::from_llvm(loadInst); @@ -52,7 +52,7 @@ SSAVec16ub SSAUBytePtr::load_vec16ub(bool constantScopeDomain) const SSAVec16ub SSAUBytePtr::load_unaligned_vec16ub(bool constantScopeDomain) const { llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); - auto loadInst = SSAScope::builder().CreateAlignedLoad(SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), 4, false, SSAScope::hint()); + auto loadInst = SSAScope::builder().CreateAlignedLoad(SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), 1, false, SSAScope::hint()); if (constantScopeDomain) loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); return SSAVec16ub::from_llvm(loadInst); @@ -86,7 +86,7 @@ void SSAUBytePtr::store_vec4ub(const SSAVec4i &new_value) void SSAUBytePtr::store_vec16ub(const SSAVec16ub &new_value) { llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); - llvm::StoreInst *inst = SSAScope::builder().CreateStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint())); + llvm::StoreInst *inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), 16); inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); // The following generates _mm_stream_si128, maybe! @@ -97,6 +97,6 @@ void SSAUBytePtr::store_vec16ub(const SSAVec16ub &new_value) void SSAUBytePtr::store_unaligned_vec16ub(const SSAVec16ub &new_value) { llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); - llvm::StoreInst *inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), 4); + llvm::StoreInst *inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), 1); inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } diff --git a/src/r_compiler/ssa/ssa_vec4f_ptr.cpp b/src/r_compiler/ssa/ssa_vec4f_ptr.cpp index e8bac71f1..31c23f2bd 100644 --- a/src/r_compiler/ssa/ssa_vec4f_ptr.cpp +++ b/src/r_compiler/ssa/ssa_vec4f_ptr.cpp @@ -25,7 +25,7 @@ SSAVec4fPtr SSAVec4fPtr::operator[](SSAInt index) const SSAVec4f SSAVec4fPtr::load(bool constantScopeDomain) const { - auto loadInst = SSAScope::builder().CreateLoad(v, false, SSAScope::hint()); + auto loadInst = SSAScope::builder().CreateAlignedLoad(v, 16, false, SSAScope::hint()); if (constantScopeDomain) loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); return SSAVec4f::from_llvm(loadInst); @@ -33,7 +33,7 @@ SSAVec4f SSAVec4fPtr::load(bool constantScopeDomain) const SSAVec4f SSAVec4fPtr::load_unaligned(bool constantScopeDomain) const { - auto loadInst = SSAScope::builder().CreateAlignedLoad(v, 4, false, SSAScope::hint()); + auto loadInst = SSAScope::builder().CreateAlignedLoad(v, 1, false, SSAScope::hint()); if (constantScopeDomain) loadInst->setMetadata(llvm::LLVMContext::MD_alias_scope, SSAScope::constant_scope_list()); return SSAVec4f::from_llvm(loadInst); @@ -41,12 +41,12 @@ SSAVec4f SSAVec4fPtr::load_unaligned(bool constantScopeDomain) const void SSAVec4fPtr::store(const SSAVec4f &new_value) { - auto inst = SSAScope::builder().CreateStore(new_value.v, v, false); + auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, v, 16, false); inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } void SSAVec4fPtr::store_unaligned(const SSAVec4f &new_value) { - auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, v, 4, false); + auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, v, 1, false); inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } From 660a45a0e07882f28b7261b563b593f50f2bd024 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 13 Oct 2016 18:04:00 +0200 Subject: [PATCH 1078/1509] Add normals to decals --- src/gl/scene/gl_decal.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 651cb7aa9..7fb680f8e 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -316,6 +316,8 @@ void GLWall::DrawDecal(DBaseDecal *decal) gl_RenderState.SetFog(0,-1); } + gl_RenderState.SetNormal(glseg.Normal()); + FQuadDrawer qd; for (i = 0; i < 4; i++) { From 14c1a77f8a0278f5a25d50d61de8f0728145294f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 13 Oct 2016 18:08:04 +0200 Subject: [PATCH 1079/1509] Fix AmbientOcclusionColor bug where pixelpos was assumed to be in eye space coordinates --- wadsrc/static/shaders/glsl/main.fp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index e26b2fd4a..5ab9f1118 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -287,7 +287,7 @@ vec3 AmbientOcclusionColor() } else { - fogdist = max(16.0, length(pixelpos.xyz)); + fogdist = max(16.0, distance(pixelpos.xyz, uCameraPos.xyz)); } fogfactor = exp2 (uFogDensity * fogdist); From 366d494b181d3eb3f976e320bebbf061c89965c9 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 14 Oct 2016 08:33:59 +0200 Subject: [PATCH 1080/1509] Merged R_DrawMaskedColumnHoriz into R_DrawMaskedColumn --- src/r_draw.h | 2 +- src/r_drawt.cpp | 115 +++++++---------------------------------------- src/r_segs.cpp | 24 +++++----- src/r_things.cpp | 26 ++++++----- src/r_things.h | 4 +- src/v_draw.cpp | 6 +-- 6 files changed, 49 insertions(+), 128 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index 204f2a493..0708b8714 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -143,7 +143,6 @@ extern void (*R_DrawSpanMaskedAddClamp)(void); // [RH] Span blit into an interleaved intermediate buffer extern void (*R_DrawColumnHoriz)(void); -void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *spans); // [RH] Initialize the above pointers void R_InitColumnDrawers (); @@ -225,6 +224,7 @@ extern void (*rt_tlaterevsubclamp4cols)(int sx, int yl, int yh); extern void (*rt_initcols)(BYTE *buffer); extern void (*rt_span_coverage)(int x, int start, int stop); +void rt_flip_posts(); void rt_draw4cols (int sx); // [RH] Preps the temporary horizontal buffer. diff --git a/src/r_drawt.cpp b/src/r_drawt.cpp index 43354bfd5..0baf6d38c 100644 --- a/src/r_drawt.cpp +++ b/src/r_drawt.cpp @@ -839,6 +839,21 @@ void rt_tlaterevsubclamp4cols_c (int sx, int yl, int yh) rt_revsubclamp4cols(sx, yl, yh); } +// Reorder the posts so that they get drawn top-to-bottom instead of bottom-to-top. +void rt_flip_posts() +{ + unsigned int *front = horizspan[dc_x & 3]; + unsigned int *back = dc_ctspan[dc_x & 3] - 2; + + while (front < back) + { + swapvalues(front[0], back[0]); + swapvalues(front[1], back[1]); + front += 2; + back -= 2; + } +} + // Copies all spans in all four columns to the screen starting at sx. // sx should be dword-aligned. void rt_draw4cols (int sx) @@ -1115,103 +1130,3 @@ void R_FillColumnHorizP_C (void) dest += 8; } while (--count); } - -// Same as R_DrawMaskedColumn() except that it always uses R_DrawColumnHoriz(). - -void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span) -{ - int pixelsize = r_swtruecolor ? 4 : 1; - int inputpixelsize = (r_swtruecolor && !drawer_needs_pal_input) ? 4 : 1; - const fixed_t texturemid = FLOAT2FIXED(dc_texturemid); - while (span->Length != 0) - { - const int length = span->Length; - const int top = span->TopOffset; - - // calculate unclipped screen coordinates for post - dc_yl = xs_RoundToInt(sprtopscreen + spryscale * top); - dc_yh = xs_RoundToInt(sprtopscreen + spryscale * (top + length) - 1); - - if (sprflipvert) - { - swapvalues (dc_yl, dc_yh); - } - - if (dc_yh >= mfloorclip[dc_x]) - { - dc_yh = mfloorclip[dc_x] - 1; - } - if (dc_yl < mceilingclip[dc_x]) - { - dc_yl = mceilingclip[dc_x]; - } - - if (dc_yl <= dc_yh) - { - if (sprflipvert) - { - dc_texturefrac = (dc_yl*dc_iscale) - (top << FRACBITS) - - fixed_t(CenterY * dc_iscale) - texturemid; - const fixed_t maxfrac = length << FRACBITS; - while (dc_texturefrac >= maxfrac) - { - if (++dc_yl > dc_yh) - goto nextpost; - dc_texturefrac += dc_iscale; - } - fixed_t endfrac = dc_texturefrac + (dc_yh-dc_yl)*dc_iscale; - while (endfrac < 0) - { - if (--dc_yh < dc_yl) - goto nextpost; - endfrac -= dc_iscale; - } - } - else - { - dc_texturefrac = texturemid - (top << FRACBITS) - + (dc_yl*dc_iscale) - fixed_t((CenterY-1) * dc_iscale); - while (dc_texturefrac < 0) - { - if (++dc_yl > dc_yh) - goto nextpost; - dc_texturefrac += dc_iscale; - } - fixed_t endfrac = dc_texturefrac + (dc_yh-dc_yl)*dc_iscale; - const fixed_t maxfrac = length << FRACBITS; - if (dc_yh < mfloorclip[dc_x]-1 && endfrac < maxfrac - dc_iscale) - { - dc_yh++; - } - else while (endfrac >= maxfrac) - { - if (--dc_yh < dc_yl) - goto nextpost; - endfrac -= dc_iscale; - } - } - dc_source = column + top * inputpixelsize; - dc_dest = (ylookup[dc_yl] + dc_x) * pixelsize + dc_destorg; - dc_count = dc_yh - dc_yl + 1; - hcolfunc_pre (); - } -nextpost: - span++; - } - - if (sprflipvert) - { - unsigned int *front = horizspan[dc_x&3]; - unsigned int *back = dc_ctspan[dc_x&3] - 2; - - // Reorder the posts so that they get drawn top-to-bottom - // instead of bottom-to-top. - while (front < back) - { - swapvalues (front[0], back[0]); - swapvalues (front[1], back[1]); - front += 2; - back -= 2; - } - } -} diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 92e6a447a..cbff7d6e9 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -173,7 +173,7 @@ CVAR(Bool, r_drawmirrors, true, 0) float *MaskedSWall; float MaskedScaleY; -static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FTexture::Span *spans), FTexture *tex) +static void BlastMaskedColumn (FTexture *tex, bool useRt) { // calculate lighting if (fixedcolormap == NULL && fixedlightlev < 0) @@ -202,7 +202,7 @@ static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FText pixels = (const BYTE *)tex->GetColumnBgra(maskedtexturecol[dc_x] >> FRACBITS, &spans); else pixels = tex->GetColumn(maskedtexturecol[dc_x] >> FRACBITS, &spans); - blastfunc (pixels, spans); + R_DrawMaskedColumn(pixels, spans, useRt); rw_light += rw_lightstep; spryscale += rw_scalestep; } @@ -445,7 +445,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) { for (dc_x = x1; dc_x < x2; ++dc_x) { - BlastMaskedColumn (R_DrawMaskedColumn, tex); + BlastMaskedColumn (tex, false); } } else @@ -460,24 +460,24 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) while ((dc_x < stop) && (dc_x & 3)) { - BlastMaskedColumn (R_DrawMaskedColumn, tex); + BlastMaskedColumn (tex, false); dc_x++; } while (dc_x < stop) { rt_initcols(nullptr); - BlastMaskedColumn (R_DrawMaskedColumnHoriz, tex); dc_x++; - BlastMaskedColumn (R_DrawMaskedColumnHoriz, tex); dc_x++; - BlastMaskedColumn (R_DrawMaskedColumnHoriz, tex); dc_x++; - BlastMaskedColumn (R_DrawMaskedColumnHoriz, tex); + BlastMaskedColumn (tex, true); dc_x++; + BlastMaskedColumn (tex, true); dc_x++; + BlastMaskedColumn (tex, true); dc_x++; + BlastMaskedColumn (tex, true); rt_draw4cols (dc_x - 3); dc_x++; } while (dc_x < x2) { - BlastMaskedColumn (R_DrawMaskedColumn, tex); + BlastMaskedColumn (tex, false); dc_x++; } } @@ -3218,7 +3218,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { // calculate lighting R_SetColorMapLight(usecolormap, rw_light, wallshade); } - R_WallSpriteColumn (R_DrawMaskedColumn); + R_WallSpriteColumn (false); dc_x++; } @@ -3231,7 +3231,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rt_initcols(nullptr); for (int zz = 4; zz; --zz) { - R_WallSpriteColumn (R_DrawMaskedColumnHoriz); + R_WallSpriteColumn (true); dc_x++; } rt_draw4cols (dc_x - 4); @@ -3243,7 +3243,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { // calculate lighting R_SetColorMapLight(usecolormap, rw_light, wallshade); } - R_WallSpriteColumn (R_DrawMaskedColumn); + R_WallSpriteColumn (false); dc_x++; } } diff --git a/src/r_things.cpp b/src/r_things.cpp index dbe66da5e..6119a1402 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -250,7 +250,7 @@ double sprtopscreen; bool sprflipvert; -void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span) +void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span, bool useRt) { int pixelsize = r_swtruecolor ? 4 : 1; int inputpixelsize = (r_swtruecolor && !drawer_needs_pal_input) ? 4 : 1; @@ -326,11 +326,17 @@ void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span) dc_source = column + top * inputpixelsize; dc_dest = (ylookup[dc_yl] + dc_x) * pixelsize + dc_destorg; dc_count = dc_yh - dc_yl + 1; - colfunc (); + if (useRt) + hcolfunc_pre(); + else + colfunc (); } nextpost: span++; } + + if (sprflipvert && useRt) + rt_flip_posts(); } // [ZZ] @@ -476,7 +482,7 @@ void R_DrawVisSprite (vissprite_t *vis) pixels = tex->GetColumn (frac >> FRACBITS, &spans); if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (pixels, spans); + R_DrawMaskedColumn (pixels, spans, false); dc_x++; frac += xiscale; } @@ -492,7 +498,7 @@ void R_DrawVisSprite (vissprite_t *vis) pixels = tex->GetColumn (frac >> FRACBITS, &spans); if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumnHoriz (pixels, spans); + R_DrawMaskedColumn (pixels, spans, true); dc_x++; frac += xiscale; } @@ -507,7 +513,7 @@ void R_DrawVisSprite (vissprite_t *vis) pixels = tex->GetColumn (frac >> FRACBITS, &spans); if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (pixels, spans); + R_DrawMaskedColumn (pixels, spans, false); dc_x++; frac += xiscale; } @@ -617,7 +623,7 @@ void R_DrawWallSprite(vissprite_t *spr) R_SetColorMapLight(usecolormap, rw_light, shade); } if (!R_ClipSpriteColumnWithPortals(spr)) - R_WallSpriteColumn(R_DrawMaskedColumn); + R_WallSpriteColumn(false); dc_x++; } @@ -631,7 +637,7 @@ void R_DrawWallSprite(vissprite_t *spr) for (int zz = 4; zz; --zz) { if (!R_ClipSpriteColumnWithPortals(spr)) - R_WallSpriteColumn(R_DrawMaskedColumnHoriz); + R_WallSpriteColumn(true); dc_x++; } rt_draw4cols(dc_x - 4); @@ -644,14 +650,14 @@ void R_DrawWallSprite(vissprite_t *spr) R_SetColorMapLight(usecolormap, rw_light, shade); } if (!R_ClipSpriteColumnWithPortals(spr)) - R_WallSpriteColumn(R_DrawMaskedColumn); + R_WallSpriteColumn(false); dc_x++; } } R_FinishSetPatchStyle(); } -void R_WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans)) +void R_WallSpriteColumn (bool useRt) { float iscale = swall[dc_x] * MaskedScaleY; dc_iscale = FLOAT2FIXED(iscale); @@ -668,7 +674,7 @@ void R_WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Sp else column = WallSpriteTile->GetColumn (lwall[dc_x] >> FRACBITS, &spans); dc_texturefrac = 0; - drawfunc (column, spans); + R_DrawMaskedColumn(column, spans, useRt); rw_light += rw_lightstep; } diff --git a/src/r_things.h b/src/r_things.h index cbe34015f..fa2db50f7 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -126,8 +126,8 @@ extern double pspriteyscale; extern FTexture *WallSpriteTile; -void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *spans); -void R_WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans)); +void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *spans, bool usrRt); +void R_WallSpriteColumn (bool useRt); void R_CacheSprite (spritedef_t *sprite); void R_SortVisSprites (int (*compare)(const void *, const void *), size_t first); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 1c23523d6..a89a0865d 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -310,7 +310,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) else pixels = img->GetColumn(frac >> FRACBITS, spanptr); - R_DrawMaskedColumn(pixels, spans); + R_DrawMaskedColumn(pixels, spans, false); dc_x++; frac += xiscale_i; } @@ -325,7 +325,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) else pixels = img->GetColumn(frac >> FRACBITS, spanptr); - R_DrawMaskedColumnHoriz(pixels, spans); + R_DrawMaskedColumn(pixels, spans, true); dc_x++; frac += xiscale_i; } @@ -339,7 +339,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) else pixels = img->GetColumn(frac >> FRACBITS, spanptr); - R_DrawMaskedColumn(pixels, spans); + R_DrawMaskedColumn(pixels, spans, false); dc_x++; frac += xiscale_i; } From f05e2337c22cebd6fa77d6a762471df3dbf9c265 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 14 Oct 2016 11:24:03 +0200 Subject: [PATCH 1081/1509] Fix SkyViewpoint skyboxes not being rendered --- src/r_plane.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index ff23492ab..07001bf1b 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1314,7 +1314,7 @@ void R_DrawPortals () vissprite_p = firstvissprite; visplaneStack.Pop (pl); - if (pl->Alpha > 0) + if (pl->Alpha > 0 && pl->picnum != skyflatnum) { R_DrawSinglePlane (pl, pl->Alpha, pl->Additive, true); } From f82195bc494eec48ebb05620e55ca6640ab4bc02 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 14 Oct 2016 12:10:11 +0200 Subject: [PATCH 1082/1509] Switch to true color for translated sprites --- .../fixedfunction/drawcolumncodegen.cpp | 23 +++++++++++-------- .../fixedfunction/drawcolumncodegen.h | 3 ++- src/r_draw.cpp | 5 +++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp index 721c85dd8..df35fd53c 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp @@ -187,14 +187,14 @@ SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, case DrawColumnVariant::DrawRevSubClamp: return blend_revsub(Shade(Sample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawTranslated: - return blend_copy(ShadePal(TranslateSample(sample_index), isSimpleShade)); + return blend_copy(Shade(TranslateSample(sample_index), isSimpleShade)); case DrawColumnVariant::DrawTlatedAdd: case DrawColumnVariant::DrawAddClampTranslated: - return blend_add(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_add(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawSubClampTranslated: - return blend_sub(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_sub(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawRevSubClampTranslated: - return blend_revsub(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_revsub(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::Fill: return blend_copy(color); case DrawColumnVariant::FillAdd: @@ -233,14 +233,14 @@ SSAVec4i DrawColumnCodegen::ProcessPixelPal(SSAInt sample_index, SSAVec4i bgcolo case DrawColumnVariant::DrawRevSubClamp: return blend_revsub(ShadePal(ColormapSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawTranslated: - return blend_copy(ShadePal(TranslateSample(sample_index), isSimpleShade)); + return blend_copy(ShadePal(TranslateSamplePal(sample_index), isSimpleShade)); case DrawColumnVariant::DrawTlatedAdd: case DrawColumnVariant::DrawAddClampTranslated: - return blend_add(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_add(ShadePal(TranslateSamplePal(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawSubClampTranslated: - return blend_sub(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_sub(ShadePal(TranslateSamplePal(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawRevSubClampTranslated: - return blend_revsub(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_revsub(ShadePal(TranslateSamplePal(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::Fill: return blend_copy(color); case DrawColumnVariant::FillAdd: @@ -267,7 +267,12 @@ SSAInt DrawColumnCodegen::ColormapSample(SSAInt sample_index) return colormap[source[sample_index].load(true).zext_int()].load(true).zext_int(); } -SSAInt DrawColumnCodegen::TranslateSample(SSAInt sample_index) +SSAVec4i DrawColumnCodegen::TranslateSample(SSAInt sample_index) +{ + return translation[source[sample_index].load(true).zext_int() * 4].load_vec4ub(true); +} + +SSAInt DrawColumnCodegen::TranslateSamplePal(SSAInt sample_index) { return translation[source[sample_index].load(true).zext_int()].load(true).zext_int(); } diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.h b/src/r_compiler/fixedfunction/drawcolumncodegen.h index ffba50a15..5f2ad737d 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.h +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.h @@ -42,7 +42,8 @@ private: SSAVec4i ProcessPixelPal(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade); SSAVec4i Sample(SSAInt frac); SSAInt ColormapSample(SSAInt frac); - SSAInt TranslateSample(SSAInt frac); + SSAVec4i TranslateSample(SSAInt frac); + SSAInt TranslateSamplePal(SSAInt frac); SSAVec4i Shade(SSAVec4i fgcolor, bool isSimpleShade); SSAVec4i ShadePal(SSAInt palIndex, bool isSimpleShade); bool IsPaletteInput(DrawColumnVariant variant); diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 11c7020b4..03515c8a1 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -2695,7 +2695,10 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, FRemapTable *table = TranslationToTable(translation); if (table != NULL && !table->Inactive) { - dc_translation = table->Remap; + if (r_swtruecolor) + dc_translation = (BYTE*)table->Palette; + else + dc_translation = table->Remap; } } basecolormapsave = basecolormap; From 2a4a61d4d0393bb9ee3bd3c9c98021e41399945f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 14 Oct 2016 15:23:23 +0200 Subject: [PATCH 1083/1509] Fix divide by zero if yscale is too small a number --- src/r_things.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index ab75c15b0..99ca68b60 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -408,7 +408,7 @@ void R_DrawVisSprite (vissprite_t *vis) ESPSResult mode; bool ispsprite = (!vis->sector && vis->gpos != FVector3(0, 0, 0)); - if (vis->xscale == 0 || vis->yscale == 0) + if (vis->xscale == 0 || fabs(vis->yscale) < (1.0f / 32000.0f)) { // scaled to 0; can't see return; } From 58d44e89c95b1b2b2252ba1f24ebba8961e6d6c3 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 14 Oct 2016 17:03:26 +0300 Subject: [PATCH 1084/1509] Use single helper for xBRZ scalers --- src/gl/textures/gl_hqresize.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index fe523c79d..866a41f2a 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -266,21 +266,10 @@ static unsigned char *xbrzHelper( void (*xbrzFunction) ( size_t, const uint32_t* return newBuffer; } -static unsigned char *xbrzoldHelper( void (*xbrzFunction) ( size_t factor, const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz_old::ScalerCfg& cfg, int yFirst, int yLast ), - const int N, - unsigned char *inputBuffer, - const int inWidth, - const int inHeight, - int &outWidth, - int &outHeight ) +static void xbrzOldScale(size_t factor, const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, xbrz::ColorFormat colFmt, const xbrz::ScalerCfg& cfg, int yFirst, int yLast) { - outWidth = N * inWidth; - outHeight = N *inHeight; - - unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; - xbrzFunction(N, reinterpret_cast(inputBuffer), reinterpret_cast(newBuffer), inWidth, inHeight, xbrz_old::ScalerCfg(), 0, std::numeric_limits::max()); - delete[] inputBuffer; - return newBuffer; + static_assert(sizeof(xbrz::ScalerCfg) == sizeof(xbrz_old::ScalerCfg), "ScalerCfg classes have different layout"); + xbrz_old::scale(factor, src, trg, srcWidth, srcHeight, reinterpret_cast(cfg), yFirst, yLast); } @@ -372,7 +361,7 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u case 13: case 14: case 15: - return xbrzoldHelper(xbrz_old::scale, type - 11, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + return xbrzHelper(xbrzOldScale, type - 11, inputBuffer, inWidth, inHeight, outWidth, outHeight ); } } From c3ced5842ac2b103ca332dbe8ff1e01916af6cde Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 14 Oct 2016 17:14:49 +0300 Subject: [PATCH 1085/1509] Added multithreaded upscaling with xBRZ (macOS only) --- src/gl/textures/gl_hqresize.cpp | 52 ++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 866a41f2a..253d91f4b 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -46,6 +46,17 @@ #include "gl/xbr/xbrz.h" #include "gl/xbr/xbrz_old.h" +#ifdef __APPLE__ +# include +# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 +# define GZ_USE_LIBDISPATCH +# endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 +#endif // __APPLE__ + +#ifdef GZ_USE_LIBDISPATCH +# include +#endif // GZ_USE_LIBDISPATCH + CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { if (self < 0 || self > 16) @@ -76,6 +87,22 @@ CVAR (Flag, gl_texture_hqresize_textures, gl_texture_hqresize_targets, 1); CVAR (Flag, gl_texture_hqresize_sprites, gl_texture_hqresize_targets, 2); CVAR (Flag, gl_texture_hqresize_fonts, gl_texture_hqresize_targets, 4); +#ifdef GZ_USE_LIBDISPATCH +CVAR(Bool, gl_texture_hqresize_multithread, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); + +CUSTOM_CVAR(Int, gl_texture_hqresize_mt_width, 16, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (self < 2) self = 2; + if (self > 1024) self = 1024; +} + +CUSTOM_CVAR(Int, gl_texture_hqresize_mt_height, 4, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (self < 2) self = 2; + if (self > 1024) self = 1024; +} +#endif // GZ_USE_LIBDISPATCH + static void scale2x ( uint32* inputBuffer, uint32* outputBuffer, int inWidth, int inHeight ) { @@ -261,7 +288,30 @@ static unsigned char *xbrzHelper( void (*xbrzFunction) ( size_t, const uint32_t* outHeight = N *inHeight; unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; - xbrzFunction(N, reinterpret_cast(inputBuffer), reinterpret_cast(newBuffer), inWidth, inHeight, xbrz::ARGB, xbrz::ScalerCfg(), 0, std::numeric_limits::max()); + +#ifdef GZ_USE_LIBDISPATCH + const int thresholdWidth = gl_texture_hqresize_mt_width; + const int thresholdHeight = gl_texture_hqresize_mt_height; + + if (gl_texture_hqresize_multithread + && inWidth > thresholdWidth + && inHeight > thresholdHeight) + { + const dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); + + dispatch_apply(inHeight / thresholdHeight + 1, queue, ^(size_t sliceY) + { + xbrzFunction(N, reinterpret_cast(inputBuffer), reinterpret_cast(newBuffer), + inWidth, inHeight, xbrz::ARGB, xbrz::ScalerCfg(), sliceY * thresholdHeight, (sliceY + 1) * thresholdHeight); + }); + } + else +#endif // GZ_USE_LIBDISPATCH + { + xbrzFunction(N, reinterpret_cast(inputBuffer), reinterpret_cast(newBuffer), + inWidth, inHeight, xbrz::ARGB, xbrz::ScalerCfg(), 0, std::numeric_limits::max()); + } + delete[] inputBuffer; return newBuffer; } From 6608678ad837324e1f01c26a6470dc8c6c2ce653 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Fri, 14 Oct 2016 18:11:49 -0400 Subject: [PATCH 1086/1509] - Fullbright sprites and decals now defy sector colormaps as they do in GZDoom. This is controlled by the setting "r_fullbrightignoresectorcolor". --- src/r_things.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 86186721c..bb8be4c6b 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -100,6 +100,7 @@ EXTERN_CVAR (Bool, st_scale) EXTERN_CVAR(Bool, r_shadercolormaps) EXTERN_CVAR(Int, r_drawfuzz) EXTERN_CVAR(Bool, r_deathcamera); +CVAR(Bool, r_fullbrightignoresectorcolor, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); // // Sprite rotation 0 is facing the viewer, @@ -569,7 +570,7 @@ void R_DrawWallSprite(vissprite_t *spr) else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) - R_SetColorMapLight(usecolormap, 0, 0); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &NormalLight : usecolormap, 0, 0); else calclighting = true; @@ -1088,7 +1089,8 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor vis->deltax = float(pos.X - ViewPos.X); vis->deltay = float(pos.Y - ViewPos.Y); vis->renderflags = renderflags; - if(thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D + if(thing->flags5 & MF5_BRIGHT) + vis->renderflags |= RF_FULLBRIGHT; // kg3D vis->Style.RenderStyle = thing->RenderStyle; vis->FillColor = thing->fillcolor; vis->Translation = thing->Translation; // [RH] thing translation table @@ -1164,7 +1166,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor } else if (!foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) { // full bright - vis->Style.BaseColormap = mybasecolormap; + vis->Style.BaseColormap = (r_fullbrightignoresectorcolor) ? &NormalLight : mybasecolormap; vis->Style.ColormapNum = 0; } else From 3122538006140bbaddecd66a9d861d5bc7c159b7 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Fri, 14 Oct 2016 18:16:22 -0400 Subject: [PATCH 1087/1509] Added menu entry for "r_fullbrightignoresectorcolor" --- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index c603864a7..b1b790235 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1788,6 +1788,7 @@ DSPLYMNU_PALLETEHACK = "DirectDraw palette hack"; // Not used DSPLYMNU_ATTACHEDSURFACES = "Use attached surfaces"; // Not used DSPLYMNU_STRETCHSKY = "Stretch short skies"; DSPLYMNU_LINEARSKY = "Linear skies"; +DSPLYMNU_GZDFULLBRIGHT = "Emulate GZDoom FullBright"; DSPLYMNU_DRAWFUZZ = "Use fuzz effect"; DSPLYMNU_TRANSSOUL = "Lost Soul translucency"; DSPLYMNU_FAKECONTRAST = "Use fake contrast"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index b26c4c4a5..ceae53d82 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -702,6 +702,7 @@ OptionMenu "VideoOptions" Option "$DSPLYMNU_STRETCHSKY", "r_stretchsky", "OnOff" Option "$DSPLYMNU_LINEARSKY", "r_linearsky", "OnOff" + Option "$DSPLYMNU_GZDFULLBRIGHT", "r_fullbrightignoresectorcolor", "OnOff" Option "$DSPLYMNU_DRAWFUZZ", "r_drawfuzz", "Fuzziness" Slider "$DSPLYMNU_TRANSSOUL", "transsouls", 0.25, 1.0, 0.05, 2 Option "$DSPLYMNU_FAKECONTRAST", "r_fakecontrast", "Contrast" From 491a4e28c0161fa860fa7e632ad83bfac0bb3282 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 15 Oct 2016 15:04:14 +0200 Subject: [PATCH 1088/1509] Move true color sky drawing to its own drawers and chamge r_stretchsky to false as the new drawers can fade to a solid color --- src/CMakeLists.txt | 1 + .../fixedfunction/drawskycodegen.cpp | 127 +++++++++++++ src/r_compiler/fixedfunction/drawskycodegen.h | 39 ++++ src/r_compiler/llvmdrawers.cpp | 41 +++++ src/r_compiler/llvmdrawers.h | 28 +++ src/r_compiler/ssa/ssa_int.cpp | 5 + src/r_compiler/ssa/ssa_int.h | 1 + src/r_compiler/ssa/ssa_vec4i.cpp | 14 -- src/r_compiler/ssa/ssa_vec4i.h | 2 - src/r_draw.h | 5 + src/r_draw_rgba.cpp | 65 +++++++ src/r_plane.cpp | 169 ++++++++++++++++++ src/r_sky.cpp | 2 +- 13 files changed, 482 insertions(+), 17 deletions(-) create mode 100644 src/r_compiler/fixedfunction/drawskycodegen.cpp create mode 100644 src/r_compiler/fixedfunction/drawskycodegen.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 40aa5ae37..a900b6352 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1459,6 +1459,7 @@ set (PCH_SOURCES r_compiler/fixedfunction/drawspancodegen.cpp r_compiler/fixedfunction/drawwallcodegen.cpp r_compiler/fixedfunction/drawcolumncodegen.cpp + r_compiler/fixedfunction/drawskycodegen.cpp r_data/sprites.cpp r_data/voxels.cpp r_data/renderstyle.cpp diff --git a/src/r_compiler/fixedfunction/drawskycodegen.cpp b/src/r_compiler/fixedfunction/drawskycodegen.cpp new file mode 100644 index 000000000..f2ba148fd --- /dev/null +++ b/src/r_compiler/fixedfunction/drawskycodegen.cpp @@ -0,0 +1,127 @@ + +#include "i_system.h" +#include "r_compiler/llvm_include.h" +#include "r_compiler/fixedfunction/drawskycodegen.h" +#include "r_compiler/ssa/ssa_function.h" +#include "r_compiler/ssa/ssa_scope.h" +#include "r_compiler/ssa/ssa_for_block.h" +#include "r_compiler/ssa/ssa_if_block.h" +#include "r_compiler/ssa/ssa_stack.h" +#include "r_compiler/ssa/ssa_function.h" +#include "r_compiler/ssa/ssa_struct_type.h" +#include "r_compiler/ssa/ssa_value.h" + +void DrawSkyCodegen::Generate(DrawSkyVariant variant, bool fourColumns, SSAValue args, SSAValue thread_data) +{ + dest = args[0][0].load(true); + source0[0] = args[0][1].load(true); + source0[1] = args[0][2].load(true); + source0[2] = args[0][3].load(true); + source0[3] = args[0][4].load(true); + source1[0] = args[0][5].load(true); + source1[1] = args[0][6].load(true); + source1[2] = args[0][7].load(true); + source1[3] = args[0][8].load(true); + pitch = args[0][9].load(true); + count = args[0][10].load(true); + dest_y = args[0][11].load(true); + texturefrac[0] = args[0][12].load(true); + texturefrac[1] = args[0][13].load(true); + texturefrac[2] = args[0][14].load(true); + texturefrac[3] = args[0][15].load(true); + iscale[0] = args[0][16].load(true); + iscale[1] = args[0][17].load(true); + iscale[2] = args[0][18].load(true); + iscale[3] = args[0][19].load(true); + textureheight0 = args[0][20].load(true); + textureheight1 = args[0][21].load(true); + top_color = SSAVec4i::unpack(args[0][22].load(true)); + bottom_color = SSAVec4i::unpack(args[0][23].load(true)); + + thread.core = thread_data[0][0].load(true); + thread.num_cores = thread_data[0][1].load(true); + thread.pass_start_y = thread_data[0][2].load(true); + thread.pass_end_y = thread_data[0][3].load(true); + + count = count_for_thread(dest_y, count, thread); + dest = dest_for_thread(dest_y, pitch, dest, thread); + + pitch = pitch * thread.num_cores; + + int numColumns = fourColumns ? 4 : 1; + for (int i = 0; i < numColumns; i++) + { + stack_frac[i].store(texturefrac[i] + iscale[i] * skipped_by_thread(dest_y, thread)); + fracstep[i] = iscale[i] * thread.num_cores; + } + + Loop(variant, fourColumns); +} + +void DrawSkyCodegen::Loop(DrawSkyVariant variant, bool fourColumns) +{ + int numColumns = fourColumns ? 4 : 1; + + stack_index.store(SSAInt(0)); + { + SSAForBlock loop; + SSAInt index = stack_index.load(); + loop.loop_block(index < count); + + SSAInt frac[4]; + for (int i = 0; i < numColumns; i++) + frac[i] = stack_frac[i].load(); + + SSAInt offset = index * pitch * 4; + + if (fourColumns) + { + SSAVec4i colors[4]; + for (int i = 0; i < 4; i++) + colors[i] = FadeOut(frac[i], Sample(frac[i], i, variant)); + + SSAVec16ub color(SSAVec8s(colors[0], colors[1]), SSAVec8s(colors[2], colors[3])); + dest[offset].store_unaligned_vec16ub(color); + } + else + { + SSAVec4i color = FadeOut(frac[0], Sample(frac[0], 0, variant)); + dest[offset].store_vec4ub(color); + } + + stack_index.store(index.add(SSAInt(1), true, true)); + for (int i = 0; i < numColumns; i++) + stack_frac[i].store(frac[i] + fracstep[i]); + loop.end_block(); + } +} + +SSAVec4i DrawSkyCodegen::Sample(SSAInt frac, int index, DrawSkyVariant variant) +{ + SSAInt sample_index = (((frac << 8) >> FRACBITS) * textureheight0) >> FRACBITS; + if (variant == DrawSkyVariant::Single) + { + return source0[index][sample_index * 4].load_vec4ub(false); + } + else + { + SSAInt sample_index2 = SSAInt::MIN(sample_index, textureheight1); + SSAVec4i color0 = source0[index][sample_index * 4].load_vec4ub(false); + SSAVec4i color1 = source1[index][sample_index2 * 4].load_vec4ub(false); + return blend_alpha_blend(color0, color1); + } +} + +SSAVec4i DrawSkyCodegen::FadeOut(SSAInt frac, SSAVec4i color) +{ + int start_fade = 2; // How fast it should fade out + + SSAInt alpha_top = SSAInt::MAX(SSAInt::MIN(frac.ashr(16 - start_fade), SSAInt(256)), SSAInt(0)); + SSAInt alpha_bottom = SSAInt::MAX(SSAInt::MIN(((2 << 24) - frac).ashr(16 - start_fade), SSAInt(256)), SSAInt(0)); + SSAInt inv_alpha_top = 256 - alpha_top; + SSAInt inv_alpha_bottom = 256 - alpha_bottom; + + color = (color * alpha_top + top_color * inv_alpha_top) / 256; + color = (color * alpha_bottom + bottom_color * inv_alpha_bottom) / 256; + return color.insert(3, 255); +} diff --git a/src/r_compiler/fixedfunction/drawskycodegen.h b/src/r_compiler/fixedfunction/drawskycodegen.h new file mode 100644 index 000000000..2b90b2a9d --- /dev/null +++ b/src/r_compiler/fixedfunction/drawskycodegen.h @@ -0,0 +1,39 @@ + +#pragma once + +#include "drawercodegen.h" + +enum class DrawSkyVariant +{ + Single, + Double +}; + +class DrawSkyCodegen : public DrawerCodegen +{ +public: + void Generate(DrawSkyVariant variant, bool fourColumns, SSAValue args, SSAValue thread_data); + +private: + void Loop(DrawSkyVariant variant, bool fourColumns); + SSAVec4i Sample(SSAInt frac, int index, DrawSkyVariant variant); + SSAVec4i FadeOut(SSAInt frac, SSAVec4i color); + + SSAStack stack_index, stack_frac[4]; + + SSAUBytePtr dest; + SSAUBytePtr source0[4]; + SSAUBytePtr source1[4]; + SSAInt pitch; + SSAInt count; + SSAInt dest_y; + SSAInt texturefrac[4]; + SSAInt iscale[4]; + SSAInt textureheight0; + SSAInt textureheight1; + SSAVec4i top_color; + SSAVec4i bottom_color; + SSAWorkerThread thread; + + SSAInt fracstep[4]; +}; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 8dcb73a2c..4d4aeccbe 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -4,6 +4,7 @@ #include "r_compiler/fixedfunction/drawspancodegen.h" #include "r_compiler/fixedfunction/drawwallcodegen.h" #include "r_compiler/fixedfunction/drawcolumncodegen.h" +#include "r_compiler/fixedfunction/drawskycodegen.h" #include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_scope.h" #include "r_compiler/ssa/ssa_for_block.h" @@ -48,10 +49,12 @@ private: void CodegenDrawColumn(const char *name, DrawColumnVariant variant, DrawColumnMethod method); void CodegenDrawSpan(const char *name, DrawSpanVariant variant); void CodegenDrawWall(const char *name, DrawWallVariant variant, int columns); + void CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns); static llvm::Type *GetDrawColumnArgsStruct(llvm::LLVMContext &context); static llvm::Type *GetDrawSpanArgsStruct(llvm::LLVMContext &context); static llvm::Type *GetDrawWallArgsStruct(llvm::LLVMContext &context); + static llvm::Type *GetDrawSkyArgsStruct(llvm::LLVMContext &context); static llvm::Type *GetWorkerThreadDataStruct(llvm::LLVMContext &context); LLVMProgram mProgram; @@ -140,6 +143,10 @@ LLVMDrawersImpl::LLVMDrawersImpl() CodegenDrawWall("tmvline4_subclamp", DrawWallVariant::SubClamp, 4); CodegenDrawWall("tmvline1_revsubclamp", DrawWallVariant::RevSubClamp, 1); CodegenDrawWall("tmvline4_revsubclamp", DrawWallVariant::RevSubClamp, 4); + CodegenDrawSky("DrawSky1", DrawSkyVariant::Single, 1); + CodegenDrawSky("DrawSky4", DrawSkyVariant::Single, 4); + CodegenDrawSky("DrawDoubleSky1", DrawSkyVariant::Double, 1); + CodegenDrawSky("DrawDoubleSky4", DrawSkyVariant::Double, 4); mProgram.CreateEE(); @@ -201,6 +208,10 @@ LLVMDrawersImpl::LLVMDrawersImpl() tmvline4_subclamp = mProgram.GetProcAddress("tmvline4_subclamp"); tmvline1_revsubclamp = mProgram.GetProcAddress("tmvline1_revsubclamp"); tmvline4_revsubclamp = mProgram.GetProcAddress("tmvline4_revsubclamp"); + DrawSky1 = mProgram.GetProcAddress("DrawSky1"); + DrawSky4 = mProgram.GetProcAddress("DrawSky4"); + DrawDoubleSky1 = mProgram.GetProcAddress("DrawDoubleSky1"); + DrawDoubleSky4 = mProgram.GetProcAddress("DrawDoubleSky4"); #if 0 std::vector foo(1024 * 4); @@ -292,6 +303,25 @@ void LLVMDrawersImpl::CodegenDrawWall(const char *name, DrawWallVariant variant, I_FatalError("verifyFunction failed for " __FUNCTION__); } +void LLVMDrawersImpl::CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns) +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function(name); + function.add_parameter(GetDrawSkyArgsStruct(mProgram.context())); + function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); + function.create_public(); + + DrawSkyCodegen codegen; + codegen.Generate(variant, columns == 4, function.parameter(0), function.parameter(1)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + I_FatalError("verifyFunction failed for " __FUNCTION__); +} + llvm::Type *LLVMDrawersImpl::GetDrawColumnArgsStruct(llvm::LLVMContext &context) { std::vector elements; @@ -375,6 +405,17 @@ llvm::Type *LLVMDrawersImpl::GetDrawWallArgsStruct(llvm::LLVMContext &context) return llvm::StructType::create(context, elements, "DrawWallArgs", false)->getPointerTo(); } +llvm::Type *LLVMDrawersImpl::GetDrawSkyArgsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); + for (int i = 0; i < 8; i++) + elements.push_back(llvm::Type::getInt8PtrTy(context)); + for (int i = 0; i < 15; i++) + elements.push_back(llvm::Type::getInt32Ty(context)); + return llvm::StructType::create(context, elements, "DrawSkyArgs", false)->getPointerTo(); +} + llvm::Type *LLVMDrawersImpl::GetWorkerThreadDataStruct(llvm::LLVMContext &context) { std::vector elements; diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 7f5f6658e..64d73eeee 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -133,6 +133,29 @@ struct DrawColumnArgs } }; +struct DrawSkyArgs +{ + uint32_t *dest; + const uint32_t *source0[4]; + const uint32_t *source1[4]; + int32_t pitch; + int32_t count; + int32_t dest_y; + uint32_t texturefrac[4]; + uint32_t iscale[4]; + uint32_t textureheight0; + uint32_t textureheight1; + uint32_t top_color; + uint32_t bottom_color; + + FString ToString() + { + FString info; + info.Format("dest_y = %i, count = %i", dest_y, count); + return info; + } +}; + class LLVMDrawers { public: @@ -203,6 +226,11 @@ public: void(*tmvline1_revsubclamp)(const DrawWallArgs *, const WorkerThreadData *) = nullptr; void(*tmvline4_revsubclamp)(const DrawWallArgs *, const WorkerThreadData *) = nullptr; + void(*DrawSky1)(const DrawSkyArgs *, const WorkerThreadData *) = nullptr; + void(*DrawSky4)(const DrawSkyArgs *, const WorkerThreadData *) = nullptr; + void(*DrawDoubleSky1)(const DrawSkyArgs *, const WorkerThreadData *) = nullptr; + void(*DrawDoubleSky4)(const DrawSkyArgs *, const WorkerThreadData *) = nullptr; + private: static LLVMDrawers *Singleton; }; diff --git a/src/r_compiler/ssa/ssa_int.cpp b/src/r_compiler/ssa/ssa_int.cpp index 1815985c5..6f2afce7f 100644 --- a/src/r_compiler/ssa/ssa_int.cpp +++ b/src/r_compiler/ssa/ssa_int.cpp @@ -47,6 +47,11 @@ SSAInt SSAInt::add(SSAInt b, bool no_unsigned_wrap, bool no_signed_wrap) return SSAInt::from_llvm(SSAScope::builder().CreateAdd(v, b.v, SSAScope::hint(), no_unsigned_wrap, no_signed_wrap)); } +SSAInt SSAInt::ashr(int bits) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateAShr(v, bits, SSAScope::hint())); +} + SSAInt operator+(const SSAInt &a, const SSAInt &b) { return SSAInt::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); diff --git a/src/r_compiler/ssa/ssa_int.h b/src/r_compiler/ssa/ssa_int.h index e9ce978c4..ef71e064a 100644 --- a/src/r_compiler/ssa/ssa_int.h +++ b/src/r_compiler/ssa/ssa_int.h @@ -20,6 +20,7 @@ public: static SSAInt MAX(SSAInt a, SSAInt b); SSAInt add(SSAInt b, bool no_unsigned_wrap, bool no_signed_wrap); + SSAInt ashr(int bits); llvm::Value *v; }; diff --git a/src/r_compiler/ssa/ssa_vec4i.cpp b/src/r_compiler/ssa/ssa_vec4i.cpp index 3be0ec194..60d6161a5 100644 --- a/src/r_compiler/ssa/ssa_vec4i.cpp +++ b/src/r_compiler/ssa/ssa_vec4i.cpp @@ -171,20 +171,6 @@ SSAVec4i SSAVec4i::sqrt(SSAVec4i f) return SSAVec4i::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_sqrt_pd), f.v, SSAScope::hint())); } -/* -SSAVec4i SSAVec4i::min_sse41(SSAVec4i a, SSAVec4i b) -{ - llvm::Value *values[2] = { a.v, b.v }; - return SSAVec4i::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse41_pminsd), values, SSAScope::hint())); -} - -SSAVec4i SSAVec4i::max_sse41(SSAVec4i a, SSAVec4i b) -{ - llvm::Value *values[2] = { a.v, b.v }; - return SSAVec4i::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse41_pmaxsd), values, SSAScope::hint())); -} -*/ - SSAVec4i operator+(const SSAVec4i &a, const SSAVec4i &b) { return SSAVec4i::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); diff --git a/src/r_compiler/ssa/ssa_vec4i.h b/src/r_compiler/ssa/ssa_vec4i.h index f8ef92f1e..420ab021e 100644 --- a/src/r_compiler/ssa/ssa_vec4i.h +++ b/src/r_compiler/ssa/ssa_vec4i.h @@ -35,8 +35,6 @@ public: static SSAVec4i combinehi(SSAVec8s v0, SSAVec8s v1); static SSAVec4i combinelo(SSAVec8s v0, SSAVec8s v1); static SSAVec4i sqrt(SSAVec4i f); - //static SSAVec4i min_sse41(SSAVec4i a, SSAVec4i b); - //static SSAVec4i max_sse41(SSAVec4i a, SSAVec4i b); static SSAVec4i from_llvm(llvm::Value *v) { return SSAVec4i(v); } static llvm::Type *llvm_type(); diff --git a/src/r_draw.h b/src/r_draw.h index 0708b8714..4c478a726 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -381,6 +381,11 @@ void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade); void R_SetTranslationMap(lighttable_t *translation); +void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom); +void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); +void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom); +void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); + extern bool r_swtruecolor; EXTERN_CVAR(Bool, r_multithreaded); diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 5114b95f0..4b3d98c04 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -377,6 +377,47 @@ public: } }; +class DrawSkyLLVMCommand : public DrawerCommand +{ +protected: + DrawSkyArgs args; + + WorkerThreadData ThreadData(DrawerThread *thread) + { + WorkerThreadData d; + d.core = thread->core; + d.num_cores = thread->num_cores; + d.pass_start_y = thread->pass_start_y; + d.pass_end_y = thread->pass_end_y; + return d; + } + +public: + DrawSkyLLVMCommand(uint32_t solid_top, uint32_t solid_bottom) + { + args.dest = (uint32_t*)dc_dest; + args.dest_y = _dest_y; + args.count = dc_count; + args.pitch = dc_pitch; + for (int i = 0; i < 4; i++) + { + args.texturefrac[i] = vplce[i]; + args.iscale[i] = vince[i]; + args.source0[i] = (const uint32_t *)bufplce[i]; + args.source1[i] = (const uint32_t *)bufplce2[i]; + } + args.textureheight0 = bufheight[0]; + args.textureheight1 = bufheight[1]; + args.top_color = solid_top; + args.bottom_color = solid_bottom; + } + + FString DebugInfo() override + { + return "DrawSkyLLVMCommand\n" + args.ToString(); + } +}; + #define DECLARE_DRAW_COMMAND(name, func, base) \ class name##LLVMCommand : public base \ { \ @@ -416,6 +457,10 @@ DECLARE_DRAW_COMMAND(FillColumnAdd, FillColumnAdd, DrawColumnLLVMCommand); DECLARE_DRAW_COMMAND(FillColumnAddClamp, FillColumnAddClamp, DrawColumnLLVMCommand); DECLARE_DRAW_COMMAND(FillColumnSubClamp, FillColumnSubClamp, DrawColumnLLVMCommand); DECLARE_DRAW_COMMAND(FillColumnRevSubClamp, FillColumnRevSubClamp, DrawColumnLLVMCommand); +DECLARE_DRAW_COMMAND(DrawSingleSky1, DrawSky1, DrawSkyLLVMCommand); +DECLARE_DRAW_COMMAND(DrawSingleSky4, DrawSky4, DrawSkyLLVMCommand); +DECLARE_DRAW_COMMAND(DrawDoubleSky1, DrawDoubleSky1, DrawSkyLLVMCommand); +DECLARE_DRAW_COMMAND(DrawDoubleSky4, DrawDoubleSky4, DrawSkyLLVMCommand); ///////////////////////////////////////////////////////////////////////////// @@ -1203,6 +1248,26 @@ void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) ///////////////////////////////////////////////////////////////////////////// +void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) +{ + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); +} + +void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom) +{ + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); +} + +void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) +{ + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); +} + +void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom) +{ + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); +} + void R_DrawColumn_rgba() { DrawerCommandQueue::QueueCommand(); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 0d87be4b9..8f2a7f630 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -985,8 +985,177 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) } } +static void R_DrawSkyColumn(int start_x, int y1, int y2, int columns) +{ + uint32_t height = frontskytex->GetHeight(); + + for (int i = 0; i < columns; i++) + { + int x = start_x + i; + + int uv_fracbits = 24 - frontskytex->HeightBits; + double uv_stepd = skyiscale * frontskytex->Scale.Y; + double v = (skymid * frontskytex->Scale.Y + uv_stepd * (y1 - CenterY + 0.5)) / height; + v = v + 1.0f; + v *= height; + v *= (1 << uv_fracbits); + uint32_t uv_pos = (uint32_t)v; + uint32_t uv_step = xs_ToFixed(uv_fracbits, uv_stepd); + if (uv_step == 0) // To prevent divide by zero elsewhere + uv_step = 1; + + if (MirrorFlags & RF_XFLIP) + x = (viewwidth - x); + + DWORD ang, angle1, angle2; + + if (r_linearsky) + { + angle_t xangle = (angle_t)((0.5 - x / (double)viewwidth) * FocalTangent * ANGLE_90); + ang = (skyangle + xangle) ^ skyflip; + } + else + { + ang = (skyangle + xtoviewangle[x]) ^ skyflip; + } + angle1 = (DWORD)((UMulScale16(ang, frontcyl) + frontpos) >> FRACBITS); + angle2 = (DWORD)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS); + + bufplce[i] = (const BYTE *)frontskytex->GetColumnBgra(angle1, nullptr); + bufplce2[i] = backskytex ? (const BYTE *)backskytex->GetColumnBgra(angle2, nullptr) : nullptr; + buftexturefracx[i] = 0; + vince[i] = uv_step; + vplce[i] = uv_pos; + } + + bufheight[0] = height; + bufheight[1] = backskytex ? backskytex->GetHeight() : height; + dc_dest = (ylookup[y1] + start_x) * 4 + dc_destorg; + dc_count = y2 - y1; + + // To do: figure out how GZDoom calculates the solid top and bottom colors + uint32_t solid_top = 0xff7f7f7f; + uint32_t solid_bottom = 0xff3f3f3f; + + if (columns == 4) + if (!backskytex) + R_DrawSingleSkyCol4(solid_top, solid_bottom); + else + R_DrawDoubleSkyCol4(solid_top, solid_bottom); + else + if (!backskytex) + R_DrawSingleSkyCol1(solid_top, solid_bottom); + else + R_DrawDoubleSkyCol1(solid_top, solid_bottom); +} + +static void R_DrawTruecolorSky(visplane_t *pl) +{ + R_SetColorMapLight(fixedcolormap, 0, 0); + palookupoffse[0] = dc_colormap; + palookupoffse[1] = dc_colormap; + palookupoffse[2] = dc_colormap; + palookupoffse[3] = dc_colormap; + palookuplight[0] = 0; + palookuplight[1] = 0; + palookuplight[2] = 0; + palookuplight[3] = 0; + setupvline(FRACBITS); + + int x1 = pl->left; + int x2 = pl->right; + short *uwal = (short *)pl->top; + short *dwal = (short *)pl->bottom; + + // Calculate where 4 column alignment begins and ends: + int aligned_x1 = clamp((x1 + 3) / 4 * 4, x1, x2); + int aligned_x2 = clamp(x2 / 4 * 4, x1, x2); + + // First unaligned columns: + for (int x = x1; x < aligned_x1; x++) + { + int y1 = uwal[x]; + int y2 = dwal[x]; + if (y2 <= y1) + continue; + + R_DrawSkyColumn(x, y1, y2, 1); + } + + // The aligned columns + for (int x = aligned_x1; x < aligned_x2; x += 4) + { + // Find y1, y2, light and uv values for four columns: + int y1[4] = { uwal[x], uwal[x + 1], uwal[x + 2], uwal[x + 3] }; + int y2[4] = { dwal[x], dwal[x + 1], dwal[x + 2], dwal[x + 3] }; + + // Figure out where we vertically can start and stop drawing 4 columns in one go + int middle_y1 = y1[0]; + int middle_y2 = y2[0]; + for (int i = 1; i < 4; i++) + { + middle_y1 = MAX(y1[i], middle_y1); + middle_y2 = MIN(y2[i], middle_y2); + } + + // If we got an empty column in our set we cannot draw 4 columns in one go: + bool empty_column_in_set = false; + for (int i = 0; i < 4; i++) + { + if (y2[i] <= y1[i]) + empty_column_in_set = true; + } + + if (empty_column_in_set || middle_y2 <= middle_y1) + { + for (int i = 0; i < 4; i++) + { + if (y2[i] <= y1[i]) + continue; + + R_DrawSkyColumn(x + i, y1[i], y2[i], 1); + } + continue; + } + + // Draw the first rows where not all 4 columns are active + for (int i = 0; i < 4; i++) + { + if (y1[i] < middle_y1) + R_DrawSkyColumn(x + i, y1[i], middle_y1, 1); + } + + // Draw the area where all 4 columns are active + R_DrawSkyColumn(x, middle_y1, middle_y2, 4); + + // Draw the last rows where not all 4 columns are active + for (int i = 0; i < 4; i++) + { + if (middle_y2 < y2[i]) + R_DrawSkyColumn(x + i, middle_y2, y2[i], 1); + } + } + + // The last unaligned columns: + for (int x = aligned_x2; x < x2; x++) + { + int y1 = uwal[x]; + int y2 = dwal[x]; + if (y2 <= y1) + continue; + + R_DrawSkyColumn(x, y1, y2, 1); + } +} + static void R_DrawSky (visplane_t *pl) { + if (r_swtruecolor) + { + R_DrawTruecolorSky(pl); + return; + } + int x; float swal; diff --git a/src/r_sky.cpp b/src/r_sky.cpp index 9ea44db48..cf3f37367 100644 --- a/src/r_sky.cpp +++ b/src/r_sky.cpp @@ -49,7 +49,7 @@ fixed_t sky1cyl, sky2cyl; double sky1pos, sky2pos; // [RH] Stretch sky texture if not taller than 128 pixels? -CUSTOM_CVAR (Bool, r_stretchsky, true, CVAR_ARCHIVE) +CUSTOM_CVAR (Bool, r_stretchsky, false, CVAR_ARCHIVE) { R_InitSkyMap (); } From b3e4ba13ba4e0a96212d4c5f57a0e2b16765cee5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 15 Oct 2016 21:53:45 +0200 Subject: [PATCH 1089/1509] Use GetSkyCapColor to pick the sky solid color --- src/r_plane.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 8f2a7f630..4e18815ba 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1033,9 +1033,8 @@ static void R_DrawSkyColumn(int start_x, int y1, int y2, int columns) dc_dest = (ylookup[y1] + start_x) * 4 + dc_destorg; dc_count = y2 - y1; - // To do: figure out how GZDoom calculates the solid top and bottom colors - uint32_t solid_top = 0xff7f7f7f; - uint32_t solid_bottom = 0xff3f3f3f; + uint32_t solid_top = frontskytex->GetSkyCapColor(false); + uint32_t solid_bottom = frontskytex->GetSkyCapColor(true); if (columns == 4) if (!backskytex) From 59576e6d23f0d3a47c6397b970bb34f41a047416 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 16 Oct 2016 09:12:43 +0200 Subject: [PATCH 1090/1509] - use the newly added OF_Transient flag to avoid writing out the owned dynamic lights to savegames instead of destroying and recreating them each time. --- src/gl/dynlights/gl_dynlight.cpp | 1 + src/gl/scene/gl_scene.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index 3fffe3641..ae19ecf60 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -1081,6 +1081,7 @@ void gl_AttachLight(AActor *actor, unsigned int count, const FLightDefaults *lig light = Spawn(actor->Pos(), NO_REPLACE); light->target = actor; light->owned = true; + light->ObjectFlags |= OF_Transient; actor->dynamiclights.Push(light); } light->flags2&=~MF2_DORMANT; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 4b7bc762f..b53be4aaa 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -1199,7 +1199,6 @@ void FGLInterface::StateChanged(AActor *actor) void FGLInterface::StartSerialize(FSerializer &arc) { - gl_DeleteAllAttachedLights(); if (arc.BeginObject("glinfo")) { arc("fogdensity", fogdensity) @@ -1211,8 +1210,11 @@ void FGLInterface::StartSerialize(FSerializer &arc) void FGLInterface::EndSerialize(FSerializer &arc) { - gl_RecreateAllAttachedLights(); - if (arc.isReading()) gl_InitPortals(); + if (arc.isReading()) + { + gl_RecreateAllAttachedLights(); + gl_InitPortals(); + } } //=========================================================================== From 1711f13eeb642a1080524a6b29fa2ddb27489b5c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 16 Oct 2016 13:08:06 +0200 Subject: [PATCH 1091/1509] Fix off-by-one bug --- src/r_compiler/fixedfunction/drawskycodegen.cpp | 5 +++-- src/r_compiler/fixedfunction/drawskycodegen.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawskycodegen.cpp b/src/r_compiler/fixedfunction/drawskycodegen.cpp index f2ba148fd..f96d9fc1d 100644 --- a/src/r_compiler/fixedfunction/drawskycodegen.cpp +++ b/src/r_compiler/fixedfunction/drawskycodegen.cpp @@ -34,7 +34,8 @@ void DrawSkyCodegen::Generate(DrawSkyVariant variant, bool fourColumns, SSAValue iscale[2] = args[0][18].load(true); iscale[3] = args[0][19].load(true); textureheight0 = args[0][20].load(true); - textureheight1 = args[0][21].load(true); + SSAInt textureheight1 = args[0][21].load(true); + maxtextureheight1 = textureheight1 - 1; top_color = SSAVec4i::unpack(args[0][22].load(true)); bottom_color = SSAVec4i::unpack(args[0][23].load(true)); @@ -105,7 +106,7 @@ SSAVec4i DrawSkyCodegen::Sample(SSAInt frac, int index, DrawSkyVariant variant) } else { - SSAInt sample_index2 = SSAInt::MIN(sample_index, textureheight1); + SSAInt sample_index2 = SSAInt::MIN(sample_index, maxtextureheight1); SSAVec4i color0 = source0[index][sample_index * 4].load_vec4ub(false); SSAVec4i color1 = source1[index][sample_index2 * 4].load_vec4ub(false); return blend_alpha_blend(color0, color1); diff --git a/src/r_compiler/fixedfunction/drawskycodegen.h b/src/r_compiler/fixedfunction/drawskycodegen.h index 2b90b2a9d..a02f8dc2b 100644 --- a/src/r_compiler/fixedfunction/drawskycodegen.h +++ b/src/r_compiler/fixedfunction/drawskycodegen.h @@ -30,7 +30,7 @@ private: SSAInt texturefrac[4]; SSAInt iscale[4]; SSAInt textureheight0; - SSAInt textureheight1; + SSAInt maxtextureheight1; SSAVec4i top_color; SSAVec4i bottom_color; SSAWorkerThread thread; From 42138a6ab9f40d269a5b424e9732eb3c53df3832 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 16 Oct 2016 13:08:52 +0200 Subject: [PATCH 1092/1509] Fix hexen sky stretching --- src/r_plane.cpp | 63 +++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 4e18815ba..cbe1a358f 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -64,6 +64,8 @@ #pragma warning(disable:4244) #endif +CVAR(Bool, r_capsky, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); + //EXTERN_CVAR (Int, tx) //EXTERN_CVAR (Int, ty) @@ -985,25 +987,20 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) } } -static void R_DrawSkyColumn(int start_x, int y1, int y2, int columns) +static void R_DrawSkyColumnStripe(int start_x, int y1, int y2, int columns, double scale, double texturemid, double yrepeat) { uint32_t height = frontskytex->GetHeight(); for (int i = 0; i < columns; i++) { + double uv_stepd = skyiscale * yrepeat; + double v = (texturemid + uv_stepd * (y1 - CenterY + 0.5)) / height + 1.0f; + double v_step = uv_stepd / height; + + uint32_t uv_pos = (uint32_t)(v * 0x01000000); + uint32_t uv_step = (uint32_t)(v_step * 0x01000000); + int x = start_x + i; - - int uv_fracbits = 24 - frontskytex->HeightBits; - double uv_stepd = skyiscale * frontskytex->Scale.Y; - double v = (skymid * frontskytex->Scale.Y + uv_stepd * (y1 - CenterY + 0.5)) / height; - v = v + 1.0f; - v *= height; - v *= (1 << uv_fracbits); - uint32_t uv_pos = (uint32_t)v; - uint32_t uv_step = xs_ToFixed(uv_fracbits, uv_stepd); - if (uv_step == 0) // To prevent divide by zero elsewhere - uv_step = 1; - if (MirrorFlags & RF_XFLIP) x = (viewwidth - x); @@ -1023,7 +1020,6 @@ static void R_DrawSkyColumn(int start_x, int y1, int y2, int columns) bufplce[i] = (const BYTE *)frontskytex->GetColumnBgra(angle1, nullptr); bufplce2[i] = backskytex ? (const BYTE *)backskytex->GetColumnBgra(angle2, nullptr) : nullptr; - buftexturefracx[i] = 0; vince[i] = uv_step; vplce[i] = uv_pos; } @@ -1048,18 +1044,30 @@ static void R_DrawSkyColumn(int start_x, int y1, int y2, int columns) R_DrawDoubleSkyCol1(solid_top, solid_bottom); } -static void R_DrawTruecolorSky(visplane_t *pl) +static void R_DrawSkyColumn(int start_x, int y1, int y2, int columns) { - R_SetColorMapLight(fixedcolormap, 0, 0); - palookupoffse[0] = dc_colormap; - palookupoffse[1] = dc_colormap; - palookupoffse[2] = dc_colormap; - palookupoffse[3] = dc_colormap; - palookuplight[0] = 0; - palookuplight[1] = 0; - palookuplight[2] = 0; - palookuplight[3] = 0; - setupvline(FRACBITS); + if (1 << frontskytex->HeightBits == frontskytex->GetHeight()) + { + double texturemid = skymid * frontskytex->Scale.Y; + R_DrawSkyColumnStripe(start_x, y1, y2, columns, frontskytex->Scale.Y, texturemid, frontskytex->Scale.Y); + } + else + { + double yrepeat = frontskytex->Scale.Y; + double scale = frontskytex->Scale.Y * skyscale; + double iscale = 1 / scale; + short drawheight = short(frontskytex->GetHeight() * scale); + double topfrac = fmod(skymid + iscale * (1 - CenterY), frontskytex->GetHeight()); + if (topfrac < 0) topfrac += frontskytex->GetHeight(); + double texturemid = topfrac - iscale * (1 - CenterY); + R_DrawSkyColumnStripe(start_x, y1, y2, columns, scale, texturemid, yrepeat); + } +} + +static void R_DrawCapSky(visplane_t *pl) +{ + if (!r_swtruecolor) + R_SetColorMapLight(fixedcolormap, 0, 0); int x1 = pl->left; int x2 = pl->right; @@ -1104,7 +1112,6 @@ static void R_DrawTruecolorSky(visplane_t *pl) if (y2[i] <= y1[i]) empty_column_in_set = true; } - if (empty_column_in_set || middle_y2 <= middle_y1) { for (int i = 0; i < 4; i++) @@ -1149,9 +1156,9 @@ static void R_DrawTruecolorSky(visplane_t *pl) static void R_DrawSky (visplane_t *pl) { - if (r_swtruecolor) + if (r_swtruecolor && r_capsky) { - R_DrawTruecolorSky(pl); + R_DrawCapSky(pl); return; } From 204c037017d2ed73e3550ffda484c7bc03db9179 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 16 Oct 2016 15:41:47 +0200 Subject: [PATCH 1093/1509] Fix blending modes --- .../fixedfunction/drawcolumncodegen.cpp | 19 +++++++++++++------ .../fixedfunction/drawercodegen.cpp | 3 ++- .../fixedfunction/drawwallcodegen.cpp | 6 +++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp index df35fd53c..71cdf8195 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp @@ -168,6 +168,7 @@ bool DrawColumnCodegen::IsPaletteInput(DrawColumnVariant variant) SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade) { SSAInt alpha, inv_alpha; + SSAVec4i fg; switch (variant) { default: @@ -177,24 +178,30 @@ SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, return blend_copy(Shade(Sample(sample_index), isSimpleShade)); case DrawColumnVariant::DrawAdd: case DrawColumnVariant::DrawAddClamp: - return blend_add(Shade(Sample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + fg = Shade(Sample(sample_index), isSimpleShade); + return blend_add(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha)); case DrawColumnVariant::DrawShaded: alpha = SSAInt::MAX(SSAInt::MIN(ColormapSample(sample_index), SSAInt(64)), SSAInt(0)) * 4; inv_alpha = 256 - alpha; return blend_add(color, bgcolor, alpha, inv_alpha); case DrawColumnVariant::DrawSubClamp: - return blend_sub(Shade(Sample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + fg = Shade(Sample(sample_index), isSimpleShade); + return blend_sub(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha)); case DrawColumnVariant::DrawRevSubClamp: - return blend_revsub(Shade(Sample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + fg = Shade(Sample(sample_index), isSimpleShade); + return blend_revsub(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha)); case DrawColumnVariant::DrawTranslated: return blend_copy(Shade(TranslateSample(sample_index), isSimpleShade)); case DrawColumnVariant::DrawTlatedAdd: case DrawColumnVariant::DrawAddClampTranslated: - return blend_add(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + fg = Shade(TranslateSample(sample_index), isSimpleShade); + return blend_add(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha)); case DrawColumnVariant::DrawSubClampTranslated: - return blend_sub(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + fg = Shade(TranslateSample(sample_index), isSimpleShade); + return blend_sub(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha)); case DrawColumnVariant::DrawRevSubClampTranslated: - return blend_revsub(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + fg = Shade(TranslateSample(sample_index), isSimpleShade); + return blend_revsub(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha)); case DrawColumnVariant::Fill: return blend_copy(color); case DrawColumnVariant::FillAdd: diff --git a/src/r_compiler/fixedfunction/drawercodegen.cpp b/src/r_compiler/fixedfunction/drawercodegen.cpp index 3916c29ab..a4009c1f7 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.cpp +++ b/src/r_compiler/fixedfunction/drawercodegen.cpp @@ -55,8 +55,9 @@ SSAVec4i DrawerCodegen::shade_pal_index_advanced(SSAInt index, SSAInt light, con SSAVec4i DrawerCodegen::shade_bgra_simple(SSAVec4i color, SSAInt light) { + SSAInt alpha = color[3]; color = color * light / 256; - return color.insert(3, 255); + return color.insert(3, alpha); } SSAVec4i DrawerCodegen::shade_bgra_advanced(SSAVec4i color, SSAInt light, const SSAShadeConstants &constants) diff --git a/src/r_compiler/fixedfunction/drawwallcodegen.cpp b/src/r_compiler/fixedfunction/drawwallcodegen.cpp index 56d99e78e..b820274ef 100644 --- a/src/r_compiler/fixedfunction/drawwallcodegen.cpp +++ b/src/r_compiler/fixedfunction/drawwallcodegen.cpp @@ -182,10 +182,10 @@ SSAVec4i DrawWallCodegen::Blend(SSAVec4i fg, SSAVec4i bg, DrawWallVariant varian return blend_alpha_blend(fg, bg); case DrawWallVariant::Add: case DrawWallVariant::AddClamp: - return blend_add(fg, bg, srcalpha, destalpha); + return blend_add(fg, bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); case DrawWallVariant::SubClamp: - return blend_sub(fg, bg, srcalpha, destalpha); + return blend_sub(fg, bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); case DrawWallVariant::RevSubClamp: - return blend_revsub(fg, bg, srcalpha, destalpha); + return blend_revsub(fg, bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); } } From 49e890f212fbf3299549ec521e7dfd5c3e9176c8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 16 Oct 2016 15:48:34 +0200 Subject: [PATCH 1094/1509] Fix hexen sky cap offset --- src/r_plane.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index cbe1a358f..5dea6a03a 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -994,7 +994,7 @@ static void R_DrawSkyColumnStripe(int start_x, int y1, int y2, int columns, doub for (int i = 0; i < columns; i++) { double uv_stepd = skyiscale * yrepeat; - double v = (texturemid + uv_stepd * (y1 - CenterY + 0.5)) / height + 1.0f; + double v = (texturemid + uv_stepd * (y1 - CenterY + 0.5)) / height; double v_step = uv_stepd / height; uint32_t uv_pos = (uint32_t)(v * 0x01000000); @@ -1048,7 +1048,7 @@ static void R_DrawSkyColumn(int start_x, int y1, int y2, int columns) { if (1 << frontskytex->HeightBits == frontskytex->GetHeight()) { - double texturemid = skymid * frontskytex->Scale.Y; + double texturemid = skymid * frontskytex->Scale.Y + frontskytex->GetHeight(); R_DrawSkyColumnStripe(start_x, y1, y2, columns, frontskytex->Scale.Y, texturemid, frontskytex->Scale.Y); } else From 2534e80a1915422042c2c2a0338f1d33d41857a5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 16 Oct 2016 16:14:54 +0200 Subject: [PATCH 1095/1509] Fix vid_hw2d 0 rendering glitch --- src/r_draw.cpp | 29 +++++++++++++++++++---------- src/v_draw.cpp | 25 +++++++++++++++++++------ 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 03515c8a1..6b68cf81b 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -2689,16 +2689,19 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, alpha = clamp (alpha, 0, OPAQUE); } - dc_translation = NULL; - if (translation != 0) + if (translation != -1) { - FRemapTable *table = TranslationToTable(translation); - if (table != NULL && !table->Inactive) + dc_translation = NULL; + if (translation != 0) { - if (r_swtruecolor) - dc_translation = (BYTE*)table->Palette; - else - dc_translation = table->Remap; + FRemapTable *table = TranslationToTable(translation); + if (table != NULL && !table->Inactive) + { + if (r_swtruecolor) + dc_translation = (BYTE*)table->Palette; + else + dc_translation = table->Remap; + } } } basecolormapsave = basecolormap; @@ -2801,10 +2804,11 @@ bool R_GetTransMaskDrawers (fixed_t (**tmvline1)(), void (**tmvline4)()) void R_SetTranslationMap(lighttable_t *translation) { - dc_fcolormap = nullptr; - dc_colormap = translation; if (r_swtruecolor) { + dc_fcolormap = nullptr; + dc_colormap = nullptr; + dc_translation = translation; dc_shade_constants.light_red = 256; dc_shade_constants.light_green = 256; dc_shade_constants.light_blue = 256; @@ -2817,6 +2821,11 @@ void R_SetTranslationMap(lighttable_t *translation) dc_shade_constants.simple_shade = true; dc_light = 0; } + else + { + dc_fcolormap = nullptr; + dc_colormap = translation; + } } void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index a89a0865d..921896296 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -169,13 +169,19 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) parms.colorOverlay = PalEntry(parms.colorOverlay).InverseColor(); } // Note that this overrides DTA_Translation in software, but not in hardware. - FDynamicColormap *colormap = GetSpecialLights(MAKERGB(255,255,255), - parms.colorOverlay & MAKEARGB(0,255,255,255), 0); - translation = &colormap->Maps[(APART(parms.colorOverlay)*NUMCOLORMAPS/255)*256]; + if (!r_swtruecolor) + { + FDynamicColormap *colormap = GetSpecialLights(MAKERGB(255, 255, 255), + parms.colorOverlay & MAKEARGB(0, 255, 255, 255), 0); + translation = &colormap->Maps[(APART(parms.colorOverlay)*NUMCOLORMAPS / 255) * 256]; + } } else if (parms.remap != NULL) { - translation = parms.remap->Remap; + if (r_swtruecolor) + translation = (const BYTE*)parms.remap->Palette; + else + translation = parms.remap->Remap; } if (translation != NULL) @@ -184,11 +190,18 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) } else { - R_SetTranslationMap(identitymap); + if (r_swtruecolor) + R_SetTranslationMap(nullptr); + else + R_SetTranslationMap(identitymap); } fixedcolormap = dc_fcolormap; - ESPSResult mode = R_SetPatchStyle (parms.style, parms.Alpha, 0, parms.fillcolor); + ESPSResult mode; + if (r_swtruecolor) + mode = R_SetPatchStyle(parms.style, parms.Alpha, -1, parms.fillcolor); + else + mode = R_SetPatchStyle(parms.style, parms.Alpha, 0, parms.fillcolor); BYTE *destorgsave = dc_destorg; dc_destorg = screen->GetBuffer(); From f81d0d3964b429c96fea5bba427a828ec1479f18 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 16 Oct 2016 22:40:08 +0200 Subject: [PATCH 1096/1509] macOS support and Intel driver bug fixes --- src/gl/system/gl_swframebuffer.cpp | 181 ++++++++++++++----------- src/gl/system/gl_swframebuffer.h | 20 +-- src/gl/system/gl_swwipe.cpp | 4 +- src/posix/cocoa/i_video.mm | 6 +- wadsrc/static/shaders/glsl/swshader.fp | 6 +- 5 files changed, 120 insertions(+), 97 deletions(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index cffee9b91..affcb86f9 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -75,46 +75,62 @@ CVAR(Int, gl_showpacks, 0, 0) #ifndef WIN32 // Defined in fb_d3d9 for Windows CVAR(Bool, vid_hwaalines, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CUSTOM_CVAR(Bool, vid_hw2d, true, CVAR_NOINITCALL) +{ + V_SetBorderNeedRefresh(); + ST_SetNeedRefresh(); +} #else EXTERN_CVAR(Bool, vid_hwaalines) +EXTERN_CVAR(Bool, vid_hw2d) #endif -EXTERN_CVAR(Bool, vid_hw2d) EXTERN_CVAR(Bool, fullscreen) EXTERN_CVAR(Float, Gamma) EXTERN_CVAR(Bool, vid_vsync) EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Int, vid_refreshrate) +#ifdef WIN32 extern cycle_t BlitCycles; +#endif void gl_LoadExtensions(); +void gl_PrintStartupLog(); + +#ifndef WIN32 +// This has to be in this file because system headers conflict Doom headers +DFrameBuffer *CreateGLSWFrameBuffer(int width, int height, bool fullscreen) +{ + return new OpenGLSWFrameBuffer(NULL, width, height, 32, 60, fullscreen); +} +#endif IMPLEMENT_CLASS(OpenGLSWFrameBuffer) const char *const OpenGLSWFrameBuffer::ShaderDefines[OpenGLSWFrameBuffer::NUM_SHADERS] = { - "#define ENORMALCOLOR\n#define PALTEX 0\n#define DINVERT 0", // NormalColor - "#define ENORMALCOLOR\n#define PALTEX 1\n#define INVERT 0", // NormalColorPal - "#define ENORMALCOLOR\n#define PALTEX 0\n#define INVERT 1", // NormalColorInv - "#define ENORMALCOLOR\n#define PALTEX 1\n#define INVERT 1", // NormalColorPalInv + "#define ENORMALCOLOR", // NormalColor + "#define ENORMALCOLOR\n#define PALTEX", // NormalColorPal + "#define ENORMALCOLOR\n#define INVERT", // NormalColorInv + "#define ENORMALCOLOR\n#define PALTEX\n#define INVERT", // NormalColorPalInv - "#define EREDTOALPHA\n#define INVERT 0", // RedToAlpha - "#define EREDTOALPHA\n#define INVERT 1", // RedToAlphaInv + "#define EREDTOALPHA", // RedToAlpha + "#define EREDTOALPHA\n#define INVERT", // RedToAlphaInv "#define EVERTEXCOLOR", // VertexColor - "#define ESPECIALCOLORMAP\n#define PALTEX 0\n#define INVERT 0", // SpecialColormap - "#define ESPECIALCOLORMAP\n#define PALTEX 1\n#define INVERT 0", // SpecialColorMapPal + "#define ESPECIALCOLORMAP\n", // SpecialColormap + "#define ESPECIALCOLORMAP\n#define PALTEX", // SpecialColorMapPal - "#define EINGAMECOLORMAP\n#define PALTEX 0\n#define INVERT 0\n#define DESAT 0", // InGameColormap - "#define EINGAMECOLORMAP\n#define PALTEX 0\n#define INVERT 0\n#define DESAT 1", // InGameColormapDesat - "#define EINGAMECOLORMAP\n#define PALTEX 0\n#define INVERT 1\n#define DESAT 0", // InGameColormapInv - "#define EINGAMECOLORMAP\n#define PALTEX 0\n#define INVERT 1\n#define DESAT 1", // InGameColormapInvDesat - "#define EINGAMECOLORMAP\n#define PALTEX 1\n#define INVERT 0\n#define DESAT 0", // InGameColormapPal - "#define EINGAMECOLORMAP\n#define PALTEX 1\n#define INVERT 0\n#define DESAT 1", // InGameColormapPalDesat - "#define EINGAMECOLORMAP\n#define PALTEX 1\n#define INVERT 1\n#define DESAT 0", // InGameColormapPalInv - "#define EINGAMECOLORMAP\n#define PALTEX 1\n#define INVERT 1\n#define DESAT 1", // InGameColormapPalInvDesat + "#define EINGAMECOLORMAP", // InGameColormap + "#define EINGAMECOLORMAP\n#define DESAT", // InGameColormapDesat + "#define EINGAMECOLORMAP\n#define INVERT", // InGameColormapInv + "#define EINGAMECOLORMAP\n#define INVERT\n#define DESAT", // InGameColormapInvDesat + "#define EINGAMECOLORMAP\n#define PALTEX\n", // InGameColormapPal + "#define EINGAMECOLORMAP\n#define PALTEX\n#define DESAT", // InGameColormapPalDesat + "#define EINGAMECOLORMAP\n#define PALTEX\n#define INVERT", // InGameColormapPalInv + "#define EINGAMECOLORMAP\n#define PALTEX\n#define INVERT\n#define DESAT", // InGameColormapPalInvDesat "#define EBURNWIPE", // BurnWipe "#define EGAMMACORRECTION", // GammaCorrection @@ -131,6 +147,11 @@ OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, } gl_LoadExtensions(); InitializeState(); + if (first) + { + gl_PrintStartupLog(); + first = false; + } // SetVSync needs to be at the very top to workaround a bug in Nvidia's OpenGL driver. // If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed! @@ -197,6 +218,19 @@ OpenGLSWFrameBuffer::~OpenGLSWFrameBuffer() delete[] QuadExtra; } +void *OpenGLSWFrameBuffer::MapBuffer(int target, int size) +{ + if (glMapBufferRange) + { + return (FBVERTEX*)glMapBufferRange(target, 0, size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + } + else + { + glBufferData(target, size, nullptr, GL_STREAM_DRAW); + return glMapBuffer(target, GL_WRITE_ONLY); + } +} + OpenGLSWFrameBuffer::HWFrameBuffer::~HWFrameBuffer() { if (Framebuffer != 0) glDeleteFramebuffers(1, (GLuint*)&Framebuffer); @@ -218,7 +252,7 @@ OpenGLSWFrameBuffer::HWVertexBuffer::~HWVertexBuffer() OpenGLSWFrameBuffer::FBVERTEX *OpenGLSWFrameBuffer::HWVertexBuffer::Lock() { glBindBuffer(GL_ARRAY_BUFFER, Buffer); - return (FBVERTEX*)glMapBufferRange(GL_ARRAY_BUFFER, 0, Size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + return (FBVERTEX*)MapBuffer(GL_ARRAY_BUFFER, Size); } void OpenGLSWFrameBuffer::HWVertexBuffer::Unlock() @@ -236,7 +270,7 @@ uint16_t *OpenGLSWFrameBuffer::HWIndexBuffer::Lock() { glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &LockedOldBinding); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, Buffer); - return (uint16_t*)glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, Size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + return (uint16_t*)MapBuffer(GL_ELEMENT_ARRAY_BUFFER, Size); } void OpenGLSWFrameBuffer::HWIndexBuffer::Unlock() @@ -281,6 +315,7 @@ bool OpenGLSWFrameBuffer::CreateFrameBuffer(const FString &name, int width, int if (result != GL_FRAMEBUFFER_COMPLETE) { + //Printf("Framebuffer is not complete"); outFramebuffer = nullptr; return false; } @@ -296,9 +331,15 @@ bool OpenGLSWFrameBuffer::CreatePixelShader(FString vertexsrc, FString fragments shader->Program = glCreateProgram(); shader->VertexShader = glCreateShader(GL_VERTEX_SHADER); shader->FragmentShader = glCreateShader(GL_FRAGMENT_SHADER); - - vertexsrc = "#version 130\n" + defines + "\n#line 0\n" + vertexsrc; - fragmentsrc = "#version 130\n" + defines + "\n#line 0\n" + fragmentsrc; + + int maxGlslVersion = 330; + int shaderVersion = MIN((int)round(gl.glslversion * 10) * 10, maxGlslVersion); + + FString prefix; + prefix.AppendFormat("#version %d\n%s\n#line 0\n", shaderVersion, defines.GetChars()); + + vertexsrc = prefix + vertexsrc; + fragmentsrc = prefix + fragmentsrc; { int lengths[1] = { (int)vertexsrc.Len() }; @@ -320,10 +361,11 @@ bool OpenGLSWFrameBuffer::CreatePixelShader(FString vertexsrc, FString fragments if (status != GL_FALSE) { errorShader = shader->FragmentShader; glGetShaderiv(shader->FragmentShader, GL_COMPILE_STATUS, &status); } if (status == GL_FALSE) { - /*static char buffer[10000]; + static char buffer[10000]; GLsizei length = 0; buffer[0] = 0; - glGetShaderInfoLog(errorShader, 10000, &length, buffer);*/ + glGetShaderInfoLog(errorShader, 10000, &length, buffer); + //Printf("Shader compile failed: %s", buffer); *outShader = nullptr; return false; @@ -332,17 +374,23 @@ bool OpenGLSWFrameBuffer::CreatePixelShader(FString vertexsrc, FString fragments glAttachShader(shader->Program, shader->VertexShader); glAttachShader(shader->Program, shader->FragmentShader); glBindFragDataLocation(shader->Program, 0, "FragColor"); - glLinkProgram(shader->Program); - glGetProgramiv(shader->Program, GL_LINK_STATUS, &status); - if (status == GL_FALSE) - { - *outShader = nullptr; - return false; - } glBindAttribLocation(shader->Program, 0, "AttrPosition"); glBindAttribLocation(shader->Program, 1, "AttrColor0"); glBindAttribLocation(shader->Program, 2, "AttrColor1"); glBindAttribLocation(shader->Program, 3, "AttrTexCoord0"); + glLinkProgram(shader->Program); + glGetProgramiv(shader->Program, GL_LINK_STATUS, &status); + if (status == GL_FALSE) + { + static char buffer[10000]; + GLsizei length = 0; + buffer[0] = 0; + glGetProgramInfoLog(shader->Program, 10000, &length, buffer); + //Printf("Shader compile failed: %s", buffer); + + *outShader = nullptr; + return false; + } shader->ConstantLocations[PSCONST_Desaturation] = glGetUniformLocation(shader->Program, "Desaturation"); shader->ConstantLocations[PSCONST_PaletteMod] = glGetUniformLocation(shader->Program, "PaletteMod"); @@ -767,8 +815,6 @@ bool OpenGLSWFrameBuffer::LoadShaders() FString shaderdir, shaderpath; unsigned int i; - // We determine the best available model simply by trying them all in - // order of decreasing preference. for (i = 0; i < NUM_SHADERS; ++i) { shaderpath = shaderdir; @@ -804,7 +850,9 @@ bool OpenGLSWFrameBuffer::LoadShaders() void OpenGLSWFrameBuffer::ReleaseResources() { +#ifdef WIN32 I_SaveWindowedPos(); +#endif KillNativeTexs(); KillNativePals(); ReleaseDefaultPoolItems(); @@ -1011,27 +1059,6 @@ int OpenGLSWFrameBuffer::GetPageCount() return 1; } -//========================================================================== -// -// OpenGLSWFrameBuffer :: PaletteChanged -// -//========================================================================== - -void OpenGLSWFrameBuffer::PaletteChanged() -{ -} - -//========================================================================== -// -// OpenGLSWFrameBuffer :: QueryNewPalette -// -//========================================================================== - -int OpenGLSWFrameBuffer::QueryNewPalette() -{ - return 0; -} - //========================================================================== // // OpenGLSWFrameBuffer :: IsValid @@ -1043,17 +1070,6 @@ bool OpenGLSWFrameBuffer::IsValid() return true; } -//========================================================================== -// -// OpenGLSWFrameBuffer :: IsFullscreen -// -//========================================================================== - -bool OpenGLSWFrameBuffer::IsFullscreen() -{ - return !Windowed; -} - //========================================================================== // // OpenGLSWFrameBuffer :: Lock @@ -1080,8 +1096,6 @@ bool OpenGLSWFrameBuffer::Lock(bool buffered) void OpenGLSWFrameBuffer::Unlock() { - LOG1("Unlock <%d>\n", LockCount); - if (LockCount == 0) { return; @@ -1146,7 +1160,7 @@ void OpenGLSWFrameBuffer::Update() NeedGammaUpdate = false; igamma = 1 / Gamma; - if (!Windowed) + if (IsFullscreen()) { GammaRamp ramp; @@ -1154,7 +1168,6 @@ void OpenGLSWFrameBuffer::Update() { ramp.blue[i] = ramp.green[i] = ramp.red[i] = uint16_t(65535.f * powf(i / 255.f, igamma)); } - LOG("SetGammaRamp\n"); SetGammaRamp(&ramp); } psgamma[2] = psgamma[1] = psgamma[0] = igamma; @@ -1168,8 +1181,10 @@ void OpenGLSWFrameBuffer::Update() NeedPalUpdate = false; } +#ifdef WIN32 BlitCycles.Reset(); BlitCycles.Clock(); +#endif LockCount = 0; Draw3DPart(In2D <= 1); @@ -1178,8 +1193,10 @@ void OpenGLSWFrameBuffer::Update() Flip(); } +#ifdef WIN32 BlitCycles.Unclock(); //LOG1 ("cycles = %d\n", BlitCycles); +#endif Buffer = nullptr; UpdatePending = false; @@ -1198,7 +1215,7 @@ void OpenGLSWFrameBuffer::Flip() Present(); InScene = false; - if (Windowed) + if (!IsFullscreen()) { int clientWidth = GetClientWidth(); int clientHeight = GetClientHeight(); @@ -1221,6 +1238,8 @@ void OpenGLSWFrameBuffer::Flip() // //========================================================================== +#ifdef WIN32 + bool OpenGLSWFrameBuffer::PaintToWindow() { if (LockCount != 0) @@ -1231,6 +1250,8 @@ bool OpenGLSWFrameBuffer::PaintToWindow() return true; } +#endif + //========================================================================== // // OpenGLSWFrameBuffer :: Draw3DPart @@ -1257,7 +1278,7 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) FBTexture->CurrentBuffer = (FBTexture->CurrentBuffer + 1) & 1; } - uint8_t *dest = (uint8_t*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, Width * Height, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + uint8_t *dest = (uint8_t*)MapBuffer(GL_PIXEL_UNPACK_BUFFER, Width * Height); if (dest) { if (Pitch == Width) @@ -1382,7 +1403,7 @@ void OpenGLSWFrameBuffer::UploadPalette() PaletteTexture->CurrentBuffer = (PaletteTexture->CurrentBuffer + 1) & 1; } - uint8_t *pix = (uint8_t*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, 256 * 4, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + uint8_t *pix = (uint8_t*)MapBuffer(GL_PIXEL_UNPACK_BUFFER, 256 * 4); if (pix) { int i; @@ -1427,7 +1448,6 @@ void OpenGLSWFrameBuffer::UpdatePalette() bool OpenGLSWFrameBuffer::SetGamma(float gamma) { - LOG1("SetGamma %g\n", gamma); Gamma = gamma; NeedGammaUpdate = true; return true; @@ -1473,16 +1493,12 @@ void OpenGLSWFrameBuffer::SetVSync(bool vsync) void OpenGLSWFrameBuffer::NewRefreshRate() { - if (!Windowed) + if (IsFullscreen()) { Reset(); } } -void OpenGLSWFrameBuffer::Blank() -{ -} - void OpenGLSWFrameBuffer::SetBlendingRect(int x1, int y1, int x2, int y2) { BlendingRect.left = x1; @@ -2013,7 +2029,7 @@ bool OpenGLSWFrameBuffer::OpenGLTex::Update() Box->Owner->Tex->CurrentBuffer = (Box->Owner->Tex->CurrentBuffer + 1) & 1; int pitch = (rect.right - rect.left) * bytesPerPixel; - uint8_t *bits = (uint8_t *)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, buffersize, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + uint8_t *bits = (uint8_t *)MapBuffer(GL_PIXEL_UNPACK_BUFFER, buffersize); dest = bits; if (!dest) { @@ -2062,7 +2078,10 @@ bool OpenGLSWFrameBuffer::OpenGLTex::Update() GLint oldBinding = 0; glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldBinding); glBindTexture(GL_TEXTURE_2D, Box->Owner->Tex->Texture); - glTexSubImage2D(GL_TEXTURE_2D, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, format == GL_RGBA8 ? GL_BGRA : GL_RED, GL_UNSIGNED_BYTE, 0); + if (format == GL_RGBA8) + glTexSubImage2D(GL_TEXTURE_2D, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, GL_BGRA, GL_UNSIGNED_BYTE, 0); + else + glTexSubImage2D(GL_TEXTURE_2D, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, GL_RED, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, oldBinding); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); return true; @@ -2215,7 +2234,7 @@ bool OpenGLSWFrameBuffer::OpenGLPal::Update() Tex->CurrentBuffer = (Tex->CurrentBuffer + 1) & 1; } - buff = (uint32_t *)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, Remap->NumEntries * 4, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + buff = (uint32_t *)MapBuffer(GL_PIXEL_UNPACK_BUFFER, Remap->NumEntries * 4); if (buff == nullptr) { return false; diff --git a/src/gl/system/gl_swframebuffer.h b/src/gl/system/gl_swframebuffer.h index 5876c34c6..51c7ae134 100644 --- a/src/gl/system/gl_swframebuffer.h +++ b/src/gl/system/gl_swframebuffer.h @@ -19,7 +19,7 @@ class OpenGLSWFrameBuffer : public Win32GLFrameBuffer DECLARE_CLASS(OpenGLSWFrameBuffer, Win32GLFrameBuffer) #else #include "sdlglvideo.h" -class OpenGLFrameBuffer : public SDLGLFB +class OpenGLSWFrameBuffer : public SDLGLFB { // typedef SDLGLFB Super; //[C]commented, DECLARE_CLASS defines this in linux DECLARE_CLASS(OpenGLSWFrameBuffer, SDLGLFB) @@ -32,6 +32,7 @@ public: OpenGLSWFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen); ~OpenGLSWFrameBuffer(); + bool IsValid() override; bool Lock(bool buffered) override; void Unlock() override; @@ -43,11 +44,6 @@ public: bool SetFlash(PalEntry rgb, int amount) override; void GetFlash(PalEntry &rgb, int &amount) override; int GetPageCount() override; - bool IsFullscreen() override; - void PaletteChanged() override; - int QueryNewPalette() override; - void Blank() override; - bool PaintToWindow() override; void SetVSync(bool vsync) override; void NewRefreshRate() override; void GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &color_type) override; @@ -68,8 +64,15 @@ public: void WipeEndScreen() override; bool WipeDo(int ticks) override; void WipeCleanup() override; + +#ifdef WIN32 + void PaletteChanged() override { } + int QueryNewPalette() override { return 0; } + void Blank() override { } + bool PaintToWindow() override; bool Is8BitMode() override { return false; } int GetTrueHeight() override { return TrueHeight; } +#endif private: struct FBVERTEX @@ -195,6 +198,8 @@ private: static uint32_t ColorRGBA(uint32_t r, uint32_t g, uint32_t b, uint32_t a) { return ColorARGB(a, r, g, b); } static uint32_t ColorXRGB(uint32_t r, uint32_t g, uint32_t b) { return ColorARGB(0xff, r, g, b); } static uint32_t ColorValue(float r, float g, float b, float a) { return ColorRGBA((uint32_t)(r * 255.0f), (uint32_t)(g * 255.0f), (uint32_t)(b * 255.0f), (uint32_t)(a * 255.0f)); } + + static void *MapBuffer(int target, int size); // The number of points for the vertex buffer. enum { NUM_VERTS = 10240 }; @@ -310,9 +315,6 @@ private: BQS_InGameColormap, }; - struct PackedTexture; - struct Atlas; - struct BufferedTris { uint8_t Flags; diff --git a/src/gl/system/gl_swwipe.cpp b/src/gl/system/gl_swwipe.cpp index 148a087c5..44c2203b4 100644 --- a/src/gl/system/gl_swwipe.cpp +++ b/src/gl/system/gl_swwipe.cpp @@ -383,8 +383,8 @@ bool OpenGLSWFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLSWFrameBuffer *fb) } if (ticks == 0) { // Only draw for the final tick. - RECT rect; - POINT dpt; + LTRBRect rect; + struct Point { int x, y; } dpt; dpt.x = i * fbwidth / WIDTH; dpt.y = MAX(0, y[i] * fbheight / HEIGHT); diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 08a563b25..6c61b1148 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -101,6 +101,7 @@ @end +DFrameBuffer *CreateGLSWFrameBuffer(int width, int height, bool fullscreen); EXTERN_CVAR(Bool, ticker ) EXTERN_CVAR(Bool, vid_vsync) @@ -483,7 +484,7 @@ NSOpenGLPixelFormat* CreatePixelFormat(const OpenGLProfile profile) attributes[i++] = NSOpenGLPFAAllowOfflineRenderers; } - if (NSAppKitVersionNumber >= AppKit10_7 && OpenGLProfile::Core == profile && 1 == vid_renderer) + if (NSAppKitVersionNumber >= AppKit10_7 && OpenGLProfile::Core == profile) { NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersion3_2Core; const char* const glversion = Args->CheckValue("-glversion"); @@ -622,7 +623,8 @@ DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, c } else { - fb = new CocoaFrameBuffer(width, height, fullscreen); + //fb = new CocoaFrameBuffer(width, height, fullscreen); + fb = CreateGLSWFrameBuffer(width, height, fullscreen); } fb->SetFlash(flashColor, flashAmount); diff --git a/wadsrc/static/shaders/glsl/swshader.fp b/wadsrc/static/shaders/glsl/swshader.fp index 639ea92e5..01d539c88 100644 --- a/wadsrc/static/shaders/glsl/swshader.fp +++ b/wadsrc/static/shaders/glsl/swshader.fp @@ -17,7 +17,7 @@ uniform vec4 Gamma; vec4 TextureLookup(vec2 tex_coord) { -#if PALTEX +#if defined(PALTEX) float index = texture(Image, tex_coord).x; index = index * PaletteMod.x + PaletteMod.y; return texture(Palette, vec2(index, 0.5)); @@ -28,7 +28,7 @@ vec4 TextureLookup(vec2 tex_coord) vec4 Invert(vec4 rgb) { -#if INVERT +#if defined(INVERT) rgb.rgb = Weights.www - rgb.xyz; #endif return rgb; @@ -90,7 +90,7 @@ vec4 InGameColormap(vec2 tex_coord, vec4 color, vec4 fade) vec4 rgb = SampleTexture(tex_coord); // Desaturate -#if DESAT +#if defined(DESAT) vec3 intensity; intensity.rgb = vec3(Grayscale(rgb) * Desaturation.x); rgb.rgb = intensity.rgb + rgb.rgb * Desaturation.y; From dfed525e18f80a73288e7ba6c6807faa550b0e86 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 16 Oct 2016 23:18:56 +0200 Subject: [PATCH 1097/1509] macOS warnings and build fix --- src/CMakeLists.txt | 4 ++-- src/r_segs.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a900b6352..89341cfa7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -272,8 +272,8 @@ if( NOT NO_OPENAL ) endif() endif() -set( LLVM_COMPONENTS core support asmparser asmprinter bitreader codegen passes ipo - irreader transformutils instrumentation profiledata debuginfocodeview runtimedyld +set( LLVM_COMPONENTS core support asmparser asmprinter bitreader codegen ipo + irreader transformutils instrumentation profiledata runtimedyld object instcombine linker analysis selectiondag scalaropts vectorize executionengine mc mcdisassembler mcparser mcjit target x86asmprinter x86info x86desc x86utils x86codegen ) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index cbff7d6e9..0f723f9be 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1142,7 +1142,7 @@ WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xof } else { - double magnitude = abs(uv_stepd * 2); + double magnitude = fabs(uv_stepd * 2); bool magnifying = magnitude < 1.0f; int mipmap_offset = 0; From d654301bc2dc27f11d75fa99e1546f4162f4f8bd Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 17 Oct 2016 00:19:07 +0200 Subject: [PATCH 1098/1509] macOS compile fixes and support for slightly older versions of LLVM (to allow Mac users to brew install llvm) --- src/r_compiler/fixedfunction/drawercodegen.h | 2 +- src/r_compiler/llvm_include.h | 15 +- src/r_compiler/llvmdrawers.cpp | 24 +- src/r_compiler/ssa/ssa_for_block.cpp | 2 + src/r_compiler/ssa/ssa_pixelformat4f.h | 28 - src/r_compiler/ssa/ssa_pixelformat4ub.h | 28 - .../ssa/ssa_pixelformat4ub_argb_rev.h | 35 -- src/r_compiler/ssa/ssa_pixelformat4ub_rev.h | 28 - src/r_compiler/ssa/ssa_pixels.h | 39 -- src/r_compiler/ssa/ssa_pixeltype.h | 498 ------------------ src/r_compiler/ssa/ssa_scope.cpp | 6 +- src/r_compiler/ssa/ssa_scope.h | 4 +- src/r_compiler/ssa/ssa_stack.h | 4 +- src/r_compiler/ssa/ssa_vec4i.cpp | 11 + 14 files changed, 55 insertions(+), 669 deletions(-) delete mode 100644 src/r_compiler/ssa/ssa_pixelformat4f.h delete mode 100644 src/r_compiler/ssa/ssa_pixelformat4ub.h delete mode 100644 src/r_compiler/ssa/ssa_pixelformat4ub_argb_rev.h delete mode 100644 src/r_compiler/ssa/ssa_pixelformat4ub_rev.h delete mode 100644 src/r_compiler/ssa/ssa_pixels.h delete mode 100644 src/r_compiler/ssa/ssa_pixeltype.h diff --git a/src/r_compiler/fixedfunction/drawercodegen.h b/src/r_compiler/fixedfunction/drawercodegen.h index 27dc6f21d..98451e150 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.h +++ b/src/r_compiler/fixedfunction/drawercodegen.h @@ -13,8 +13,8 @@ #include "r_compiler/ssa/ssa_ubyte_ptr.h" #include "r_compiler/ssa/ssa_vec4f_ptr.h" #include "r_compiler/ssa/ssa_vec4i_ptr.h" -#include "r_compiler/ssa/ssa_pixels.h" #include "r_compiler/ssa/ssa_stack.h" +#include "r_compiler/ssa/ssa_bool.h" #include "r_compiler/ssa/ssa_barycentric_weight.h" #include "r_compiler/llvm_include.h" diff --git a/src/r_compiler/llvm_include.h b/src/r_compiler/llvm_include.h index adad2827d..c51143c58 100644 --- a/src/r_compiler/llvm_include.h +++ b/src/r_compiler/llvm_include.h @@ -25,12 +25,19 @@ #endif +#ifdef __APPLE__ +#define __STDC_LIMIT_MACROS // DataTypes.h:57:3: error: "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h" +#define __STDC_CONSTANT_MACROS // DataTypes.h:61:3: error: "Must #define __STDC_CONSTANT_MACROS before " "#including Support/DataTypes.h" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wredundant-move" +#endif + #include #include #include #include #include -#include +//#include #include #include #include @@ -43,8 +50,14 @@ #include #include #include +#include #include #include +#include + +#ifdef __APPLE__ +#pragma clang diagnostic pop +#endif #ifdef _MSC_VER diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 4d4aeccbe..cddf6ec9d 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -263,7 +263,7 @@ void LLVMDrawersImpl::CodegenDrawColumn(const char *name, DrawColumnVariant vari builder.CreateRetVoid(); if (llvm::verifyFunction(*function.func)) - I_FatalError("verifyFunction failed for " __FUNCTION__); + I_FatalError("verifyFunction failed for CodegenDrawColumn()"); } void LLVMDrawersImpl::CodegenDrawSpan(const char *name, DrawSpanVariant variant) @@ -281,7 +281,7 @@ void LLVMDrawersImpl::CodegenDrawSpan(const char *name, DrawSpanVariant variant) builder.CreateRetVoid(); if (llvm::verifyFunction(*function.func)) - I_FatalError("verifyFunction failed for " __FUNCTION__); + I_FatalError("verifyFunction failed for CodegenDrawSpan()"); } void LLVMDrawersImpl::CodegenDrawWall(const char *name, DrawWallVariant variant, int columns) @@ -300,7 +300,7 @@ void LLVMDrawersImpl::CodegenDrawWall(const char *name, DrawWallVariant variant, builder.CreateRetVoid(); if (llvm::verifyFunction(*function.func)) - I_FatalError("verifyFunction failed for " __FUNCTION__); + I_FatalError("verifyFunction failed for CodegenDrawWall()"); } void LLVMDrawersImpl::CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns) @@ -319,7 +319,7 @@ void LLVMDrawersImpl::CodegenDrawSky(const char *name, DrawSkyVariant variant, i builder.CreateRetVoid(); if (llvm::verifyFunction(*function.func)) - I_FatalError("verifyFunction failed for " __FUNCTION__); + I_FatalError("verifyFunction failed for CodegenDrawSky()"); } llvm::Type *LLVMDrawersImpl::GetDrawColumnArgsStruct(llvm::LLVMContext &context) @@ -469,7 +469,11 @@ LLVMProgram::LLVMProgram() I_FatalError("Could not find LLVM target: %s", errorstring.c_str()); TargetOptions opt; +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) + Reloc::Model relocModel = Reloc::Default; +#else auto relocModel = Optional(); +#endif machine = target->createTargetMachine(targetTriple, cpuName, cpuFeaturesStr, opt, relocModel, CodeModel::JITDefault, CodeGenOpt::Aggressive); if (!machine) I_FatalError("Could not create LLVM target machine"); @@ -478,7 +482,11 @@ LLVMProgram::LLVMProgram() mModule = std::make_unique("render", context()); mModule->setTargetTriple(targetTriple); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) + mModule->setDataLayout(new DataLayout(*machine->getSubtargetImpl()->getDataLayout())); +#else mModule->setDataLayout(machine->createDataLayout()); +#endif } @@ -489,8 +497,10 @@ void LLVMProgram::CreateEE() legacy::FunctionPassManager PerFunctionPasses(mModule.get()); legacy::PassManager PerModulePasses; +#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9) PerFunctionPasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); PerModulePasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); +#endif PassManagerBuilder passManagerBuilder; passManagerBuilder.OptLevel = 3; @@ -532,13 +542,17 @@ std::string LLVMProgram::DumpModule() { std::string str; llvm::raw_string_ostream stream(str); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) + mModule->print(stream, nullptr); +#else mModule->print(stream, nullptr, false, true); +#endif return stream.str(); } void *LLVMProgram::PointerToFunction(const char *name) { - return reinterpret_cast(mEngine->getFunctionAddress(name)); + return reinterpret_cast(mEngine->getFunctionAddress(name)); } void LLVMProgram::StopLogFatalErrors() diff --git a/src/r_compiler/ssa/ssa_for_block.cpp b/src/r_compiler/ssa/ssa_for_block.cpp index 0f7e01e19..6039dab1f 100644 --- a/src/r_compiler/ssa/ssa_for_block.cpp +++ b/src/r_compiler/ssa/ssa_for_block.cpp @@ -16,6 +16,7 @@ SSAForBlock::SSAForBlock() void SSAForBlock::loop_block(SSABool true_condition, int unroll_count) { auto branch = SSAScope::builder().CreateCondBr(true_condition.v, loop_basic_block, end_basic_block); +#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9) if (unroll_count > 0) { using namespace llvm; @@ -29,6 +30,7 @@ void SSAForBlock::loop_block(SSABool true_condition, int unroll_count) auto md_loop = MDNode::getDistinct(SSAScope::context(), { md_unroll_enable, md_unroll_count }); branch->setMetadata(LLVMContext::MD_loop, md_loop); } +#endif SSAScope::builder().SetInsertPoint(loop_basic_block); } diff --git a/src/r_compiler/ssa/ssa_pixelformat4f.h b/src/r_compiler/ssa/ssa_pixelformat4f.h deleted file mode 100644 index 9cefb517b..000000000 --- a/src/r_compiler/ssa/ssa_pixelformat4f.h +++ /dev/null @@ -1,28 +0,0 @@ - -#pragma once - -#include "ssa_int.h" -#include "ssa_float_ptr.h" - -class SSAPixelFormat4f -{ -public: - SSAPixelFormat4f() { } - SSAPixelFormat4f(SSAFloatPtr pixels, SSAInt width, SSAInt height) : _pixels(pixels) { } - - SSAFloatPtr pixels() { return _pixels; } - SSAFloatPtr pixels() const { return _pixels; } - - SSAVec4f get4f(SSAInt index, bool constantScopeDomain) const - { - return _pixels[index * 4].load_vec4f(constantScopeDomain); - } - - void set4f(SSAInt index, const SSAVec4f &pixel) - { - _pixels[index * 4].store_vec4f(pixel); - } - -protected: - SSAFloatPtr _pixels; -}; diff --git a/src/r_compiler/ssa/ssa_pixelformat4ub.h b/src/r_compiler/ssa/ssa_pixelformat4ub.h deleted file mode 100644 index 91b04557c..000000000 --- a/src/r_compiler/ssa/ssa_pixelformat4ub.h +++ /dev/null @@ -1,28 +0,0 @@ - -#pragma once - -#include "ssa_int.h" -#include "ssa_ubyte_ptr.h" - -class SSAPixelFormat4ub -{ -public: - SSAPixelFormat4ub() { } - SSAPixelFormat4ub(SSAUBytePtr pixels, SSAInt width, SSAInt height) : _pixels(pixels) { } - - SSAUBytePtr pixels() { return _pixels; } - SSAUBytePtr pixels() const { return _pixels; } - - SSAVec4f get4f(SSAInt index, bool constantScopeDomain) const - { - return SSAVec4f(_pixels[index * 4].load_vec4ub(constantScopeDomain)) * (1.0f / 255.0f); - } - - void set4f(SSAInt index, const SSAVec4f &pixel) - { - _pixels[index * 4].store_vec4ub(SSAVec4i(pixel * 255.0f)); - } - -private: - SSAUBytePtr _pixels; -}; diff --git a/src/r_compiler/ssa/ssa_pixelformat4ub_argb_rev.h b/src/r_compiler/ssa/ssa_pixelformat4ub_argb_rev.h deleted file mode 100644 index 1f7e4eb0f..000000000 --- a/src/r_compiler/ssa/ssa_pixelformat4ub_argb_rev.h +++ /dev/null @@ -1,35 +0,0 @@ - -#pragma once - -#include "ssa_int.h" -#include "ssa_ubyte_ptr.h" - -class SSAPixelFormat4ub_argb_rev -{ -public: - SSAPixelFormat4ub_argb_rev() { } - SSAPixelFormat4ub_argb_rev(SSAUBytePtr pixels, SSAInt width, SSAInt height) : _pixels(pixels) { } - - SSAUBytePtr pixels() { return _pixels; } - SSAUBytePtr pixels() const { return _pixels; } -/* - void get4f(SSAInt index, SSAVec4f &out_pixel1, SSAVec4f &out_pixel2) const - { - SSAVec8s p = _pixels[index * 4].load_vec8s(); - out_pixel1 = SSAVec4f::shuffle(SSAVec4f(SSAVec4i::extendlo(p)) * (1.0f / 255.0f), 2, 1, 0, 3); - out_pixel2 = SSAVec4f::shuffle(SSAVec4f(SSAVec4i::extendhi(p)) * (1.0f / 255.0f), 2, 1, 0, 3); - } -*/ - SSAVec4f get4f(SSAInt index, bool constantScopeDomain) const - { - return SSAVec4f::shuffle(SSAVec4f(_pixels[index * 4].load_vec4ub(constantScopeDomain)) * (1.0f / 255.0f), 2, 1, 0, 3); - } - - void set4f(SSAInt index, const SSAVec4f &pixel) - { - _pixels[index * 4].store_vec4ub(SSAVec4i(SSAVec4f::shuffle(pixel * 255.0f, 2, 1, 0, 3))); - } - -public: - SSAUBytePtr _pixels; -}; diff --git a/src/r_compiler/ssa/ssa_pixelformat4ub_rev.h b/src/r_compiler/ssa/ssa_pixelformat4ub_rev.h deleted file mode 100644 index 9b50ec00f..000000000 --- a/src/r_compiler/ssa/ssa_pixelformat4ub_rev.h +++ /dev/null @@ -1,28 +0,0 @@ - -#pragma once - -#include "ssa_int.h" -#include "ssa_ubyte_ptr.h" - -class SSAPixelFormat4ub_rev -{ -public: - SSAPixelFormat4ub_rev() { } - SSAPixelFormat4ub_rev(SSAUBytePtr pixels, SSAInt width, SSAInt height) : _pixels(pixels) { } - - SSAUBytePtr pixels() { return _pixels; } - SSAUBytePtr pixels() const { return _pixels; } - - SSAVec4f get4f(SSAInt index, bool constantScopeDomain) const - { - return SSAVec4f::shuffle(SSAVec4f(_pixels[index * 4].load_vec4ub(constantScopeDomain)) * (1.0f / 255.0f), 3, 2, 1, 0); - } - - void set4f(SSAInt index, const SSAVec4f &pixel) - { - _pixels[index * 4].store_vec4ub(SSAVec4i(SSAVec4f::shuffle(pixel * 255.0f, 3, 2, 1, 0))); - } - -public: - SSAUBytePtr _pixels; -}; diff --git a/src/r_compiler/ssa/ssa_pixels.h b/src/r_compiler/ssa/ssa_pixels.h deleted file mode 100644 index a4209d439..000000000 --- a/src/r_compiler/ssa/ssa_pixels.h +++ /dev/null @@ -1,39 +0,0 @@ - -#pragma once - -#include "ssa_ubyte.h" -#include "ssa_ubyte_ptr.h" -#include "ssa_float.h" -#include "ssa_float_ptr.h" -#include "ssa_int.h" -#include "ssa_pixeltype.h" -//#include "ssa_pixelformat1f.h" -//#include "ssa_pixelformat2f.h" -//#include "ssa_pixelformat3f.h" -#include "ssa_pixelformat4f.h" -//#include "ssa_pixelformat1ub.h" -//#include "ssa_pixelformat2ub.h" -//#include "ssa_pixelformat3ub.h" -//#include "ssa_pixelformat3ub_rev.h" -#include "ssa_pixelformat4ub.h" -//#include "ssa_pixelformat4ub_argb.h" -#include "ssa_pixelformat4ub_rev.h" -#include "ssa_pixelformat4ub_argb_rev.h" -//#include "ssa_pixelformat4ub_channel.h" - -//typedef SSAPixelType SSAPixels1f; -//typedef SSAPixelType SSAPixels2f; -//typedef SSAPixelType SSAPixels3f; -typedef SSAPixelType SSAPixels4f; - -//typedef SSAPixelType SSAPixels1ub; -//typedef SSAPixelType SSAPixels2ub; -//typedef SSAPixelType SSAPixels3ub; -typedef SSAPixelType SSAPixels4ub; -//typedef SSAPixelType SSAPixels4ub_argb; - -//typedef SSAPixelType SSAPixels3ub_rev; -typedef SSAPixelType SSAPixels4ub_rev; -typedef SSAPixelType SSAPixels4ub_argb_rev; - -//typedef SSAPixelType SSAPixels4ub_channel; diff --git a/src/r_compiler/ssa/ssa_pixeltype.h b/src/r_compiler/ssa/ssa_pixeltype.h deleted file mode 100644 index 8614f171d..000000000 --- a/src/r_compiler/ssa/ssa_pixeltype.h +++ /dev/null @@ -1,498 +0,0 @@ - -#pragma once - -#include "ssa_int.h" -#include "ssa_float.h" -#include "ssa_vec4f.h" -#include "ssa_bool.h" -#include "ssa_if_block.h" -#include "ssa_phi.h" - -template -class SSAPixelType : public PixelFormat -{ -public: - SSAPixelType() - { - } - - SSAPixelType(SSAInt width, SSAInt height, PixelType pixels) - : PixelFormat(pixels, width, height), _width(width), _height(height) - { - _width32 = SSAVec4i(_width); - SSAVec4i height32(_height); - _widthps = SSAVec4f(_width32); - _heightps = SSAVec4f(height32); - _width16 = SSAVec8s(_width32, _width32); - - _widthheight = SSAVec4i::shuffle(_width32, height32, 0, 0, 4, 4); - _widthheightps = SSAVec4i::shuffle(_widthps, _heightps, 0, 0, 4, 4); - } - - SSAInt width() const { return _width; } - SSAInt height() const { return _height; } - SSAInt size() const { return _width * _height; } - - SSABool in_bounds(SSAInt i) const { return i >= 0 && i < _width * _height; } - SSABool in_bounds(SSAInt x, SSAInt y) const { return x>= 0 && x < _width && y >= 0 && y < _height; } - //void throw_if_out_of_bounds(SSAInt i) const { if (!in_bounds(i)) throw clan::Exception("Out of bounds"); } - //void throw_if_out_of_bounds(SSAInt x, SSAInt y) const { if (!in_bounds(x, y)) throw clan::Exception("Out of bounds"); } - - SSAInt s_to_x(SSAFloat s) const { return round(s * SSAFloat(_width)); } - SSAInt t_to_y(SSAFloat t) const { return round(t * SSAFloat(_height)); } - SSAInt clamp_x(SSAInt x) const { return clamp(x, _width); } - SSAInt clamp_y(SSAInt y) const { return clamp(y, _height); } - SSAInt repeat_x(SSAInt x) const { return repeat(x,_width); } - SSAInt repeat_y(SSAInt y) const { return repeat(y, _height); } - SSAInt mirror_x(SSAInt x) const { return mirror(x, _width); } - SSAInt mirror_y(SSAInt y) const { return mirror(y, _height); } - - static SSAInt int_min(SSAInt a, SSAInt b) - { - SSAPhi phi; - SSAIfBlock branch; - branch.if_block(a <= b); - phi.add_incoming(a); - branch.else_block(); - phi.add_incoming(b); - branch.end_block(); - return phi.create(); - } - - static SSAInt int_max(SSAInt a, SSAInt b) - { - SSAPhi phi; - SSAIfBlock branch; - branch.if_block(a >= b); - phi.add_incoming(a); - branch.else_block(); - phi.add_incoming(b); - branch.end_block(); - return phi.create(); - } - - static SSAInt clamp(SSAInt v, SSAInt size) - { - return int_max(int_min(v, size - 1), 0); - } - - static SSAInt repeat(SSAInt v, SSAInt size) - { - SSAPhi phi; - SSAIfBlock branch; - branch.if_block(v >= 0); - phi.add_incoming(v % size); - branch.else_block(); - phi.add_incoming(size - 1 + v % size); - branch.end_block(); - return phi.create(); - } - - static SSAInt mirror(SSAInt v, SSAInt size) - { - SSAInt size2 = size * 2; - v = repeat(v, size2); - - SSAPhi phi; - SSAIfBlock branch; - branch.if_block(v < size); - phi.add_incoming(v); - branch.else_block(); - phi.add_incoming(size2 - v - 1); - branch.end_block(); - return phi.create(); - } - - static SSAInt round(SSAFloat v) - { - SSAPhi phi; - SSAIfBlock branch; - branch.if_block(v >= 0.0f); - phi.add_incoming(v + 0.5f); - branch.else_block(); - phi.add_incoming(v - 0.5f); - branch.end_block(); - return SSAInt(phi.create()); - } - - // To do: fix this: - static SSAInt int_floor(SSAFloat v) - { - return SSAInt(v); - } - static SSAFloat fract(SSAFloat v) { return v - SSAFloat(int_floor(v)); } - - SSAVec4f get4f(SSAInt x, SSAInt y) const { return PixelFormat::get4f(x + y * _width); } - void set4f(SSAInt x, SSAInt y, const SSAVec4f &pixel) { PixelFormat::set4f(x + y * _width, pixel); } - - SSAVec4f get_clamp4f(SSAInt x, SSAInt y) const { return get4f(clamp_x(x), clamp_y(y)); } - SSAVec4f get_repeat4f(SSAInt x, SSAInt y) const { return get4f(repeat_x(x), repeat_y(y)); } - SSAVec4f get_mirror4f(SSAInt x, SSAInt y) const { return get4f(mirror_x(x), mirror_y(y)); } - - SSAVec4f linear_interpolate4f(SSAFloat s, SSAFloat t, const SSAVec4f *samples) const - { - SSAFloat a = fract(s * SSAFloat(_width) - 0.5f); - SSAFloat b = fract(t * SSAFloat(_height) - 0.5f); - SSAFloat inv_a = 1.0f - a; - SSAFloat inv_b = 1.0f - b; - return - samples[0] * (inv_a * inv_b) + - samples[1] * (a * inv_b) + - samples[2] * (inv_a * b) + - samples[3] * (a * b); - } - - void gather_clamp4f(SSAFloat s, SSAFloat t, SSAVec4f *out_pixels) const - { - SSAInt x = int_floor(s * SSAFloat(_width) - 0.5f); - SSAInt y = int_floor(t * SSAFloat(_height) - 0.5f); - out_pixels[0] = get_clamp4f(x, y); - out_pixels[1] = get_clamp4f(x + 1, y); - out_pixels[2] = get_clamp4f(x, y + 1); - out_pixels[3] = get_clamp4f(x + 1, y + 1); - /* - SSAInt x0 = clamp_x(x); - SSAInt x1 = clamp_x(x + 1); - SSAInt y0 = clamp_y(y); - SSAInt y1 = clamp_y(y + 1); - SSAInt offset0 = y0 * _width; - SSAInt offset1 = y1 * _width; - SSAPhi phi0; - SSAPhi phi1; - SSAPhi phi2; - SSAPhi phi3; - SSAIfBlock if0; - if0.if_block(x0 + 1 == x1); - phi0.add_incoming(PixelFormat::get4f(x0 + offset0)); - phi1.add_incoming(PixelFormat::get4f(x1 + offset0)); - phi2.add_incoming(PixelFormat::get4f(x0 + offset1)); - phi3.add_incoming(PixelFormat::get4f(x1 + offset1)); - if0.else_block(); - phi0.add_incoming(PixelFormat::get4f(x0 + offset0)); - phi1.add_incoming(PixelFormat::get4f(x1 + offset0)); - phi2.add_incoming(PixelFormat::get4f(x0 + offset1)); - phi3.add_incoming(PixelFormat::get4f(x1 + offset1)); - if0.end_block(); - out_pixels[0] = phi0.create(); - out_pixels[1] = phi1.create(); - out_pixels[2] = phi2.create(); - out_pixels[3] = phi3.create(); - */ - } - - void gather_repeat4f(SSAFloat s, SSAFloat t, SSAVec4f *out_pixels) const - { - SSAInt x = int_floor(s * SSAFloat(_width) - 0.5f); - SSAInt y = int_floor(t * SSAFloat(_height) - 0.5f); - out_pixels[0] = get_repeat4f(x, y); - out_pixels[1] = get_repeat4f(x + 1, y); - out_pixels[2] = get_repeat4f(x, y + 1); - out_pixels[3] = get_repeat4f(x + 1, y + 1); - } - - void gather_mirror4f(SSAFloat s, SSAFloat t, SSAVec4f *out_pixels) const - { - SSAInt x = int_floor(s * SSAFloat(_width) - 0.5f); - SSAInt y = int_floor(t * SSAFloat(_height) - 0.5f); - out_pixels[0] = get_mirror4f(x, y); - out_pixels[1] = get_mirror4f(x + 1, y); - out_pixels[2] = get_mirror4f(x, y + 1); - out_pixels[3] = get_mirror4f(x + 1, y + 1); - } - - SSAVec4f nearest_clamp4f(SSAFloat s, SSAFloat t) const { return get_clamp4f(s_to_x(s), t_to_y(t)); } - SSAVec4f nearest_repeat4f(SSAFloat s, SSAFloat t) const { return get_repeat4f(s_to_x(s), t_to_y(t)); } - SSAVec4f nearest_mirror4f(SSAFloat s, SSAFloat t) const { return get_mirror4f(s_to_x(s), t_to_y(t)); } - - SSAVec4f linear_clamp4f(SSAFloat s, SSAFloat t) const - { - SSAVec4f samples[4]; - gather_clamp4f(s, t, samples); - return linear_interpolate4f(s, t, samples); - } - - SSAVec4f linear_repeat4f(SSAFloat s, SSAFloat t) const - { - SSAVec4f samples[4]; - gather_repeat4f(s, t, samples); - return linear_interpolate4f(s, t, samples); - } - - SSAVec4f linear_mirror4f(SSAFloat s, SSAFloat t) const - { - SSAVec4f samples[4]; - gather_mirror4f(s, t, samples); - return linear_interpolate4f(s, t, samples); - } - - ///////////////////////////////////////////////////////////////////////// - // Packed versions: - - SSAVec4i s_to_x(SSAVec4f s) const { return round(s * SSAVec4f(_width)); } - SSAVec4i t_to_y(SSAVec4f t) const { return round(t * SSAVec4f(_height)); } - SSAVec4i clamp_x(SSAVec4i x) const { return clamp(x, _width); } - SSAVec4i clamp_y(SSAVec4i y) const { return clamp(y, _height); } - SSAVec4i repeat_x(SSAVec4i x) const { return repeat(x,_width); } - SSAVec4i repeat_y(SSAVec4i y) const { return repeat(y, _height); } - SSAVec4i mirror_x(SSAVec4i x) const { return mirror(x, _width); } - SSAVec4i mirror_y(SSAVec4i y) const { return mirror(y, _height); } - - static SSAVec4i clamp(SSAVec4i v, SSAInt size) - { - return SSAVec4i::max_sse41(SSAVec4i::min_sse41(v, size - 1), 0); - } - - static SSAVec4i repeat(SSAVec4i v, SSAInt size) - { - return clamp(v, size); - /*SSAPhi phi; - SSAIfBlock branch; - branch.if_block(v >= 0); - phi.add_incoming(v % size); - branch.else_block(); - phi.add_incoming(size - 1 + v % size); - branch.end_block(); - return phi.create();*/ - } - - static SSAVec4i mirror(SSAVec4i v, SSAInt size) - { - return clamp(v, size); - /*SSAInt size2 = size * 2; - v = repeat(v, size2); - - SSAPhi phi; - SSAIfBlock branch; - branch.if_block(v < size); - phi.add_incoming(v); - branch.else_block(); - phi.add_incoming(size2 - v - 1); - branch.end_block(); - return phi.create();*/ - } - - static SSAVec4i round(SSAVec4f v) - { - // Maybe we should use the normal round SSE function (but that requires the rounding mode is set the round to nearest before the code runs) - SSAVec4i signbit = (SSAVec4i::bitcast(v) & 0x80000000); - SSAVec4f signed_half = SSAVec4f::bitcast(signbit | SSAVec4i::bitcast(SSAVec4f(0.5f))); - return v + signed_half; - } - - static SSAVec4i int_floor(SSAVec4f v) - { - return SSAVec4i(v) - (SSAVec4i::bitcast(v) >> 31); - } - - static SSAVec4f fract(SSAVec4f v) - { - // return v - SSAVec4f::floor_sse4(v); - return v - SSAVec4f(int_floor(v)); - } - - template - SSAVec4f nearest_helper4f(SSAVec4f s, SSAVec4f t, int index, WrapXFunctor wrap_x, WrapYFunctor wrap_y) const - { - SSAVec4i x = int_floor(s * _widthps - 0.5f); - SSAVec4i y = int_floor(t * _heightps - 0.5f); - SSAVec8s y16 = SSAVec8s(wrap_y(y), wrap_y(y)); - SSAVec8s offsethi = SSAVec8s::mulhi(y16, _width16); - SSAVec8s offsetlo = y16 * _width16; - SSAVec4i offset = SSAVec4i::combinelo(offsetlo, offsethi) + x; - return PixelFormat::get4f(offset[index]); - } - - SSAVec4f nearest_clamp4f(SSAVec4f s, SSAVec4f t, int index) const - { - struct WrapX { WrapX(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->clamp_x(v); } const SSAPixelType *self; }; - struct WrapY { WrapY(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->clamp_y(v); } const SSAPixelType *self; }; - return nearest_helper4f(s, t, index, WrapX(this), WrapY(this)); - /* - return nearest_helper4f( - s, t, index, - [this](SSAVec4i v) -> SSAVec4i { return clamp_x(v); }, - [this](SSAVec4i v) -> SSAVec4i { return clamp_y(v); }); - */ - } - - SSAVec4f nearest_repeat4f(SSAVec4f s, SSAVec4f t, int index) const - { - struct WrapX { WrapX(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->repeat_x(v); } const SSAPixelType *self; }; - struct WrapY { WrapY(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->repeat_y(v); } const SSAPixelType *self; }; - return nearest_helper4f(s, t, index, WrapX(this), WrapY(this)); - /* - return nearest_helper4f( - s, t, index, - [this](SSAVec4i v) -> SSAVec4i { return repeat_x(v); }, - [this](SSAVec4i v) -> SSAVec4i { return repeat_y(v); }); - */ - } - - SSAVec4f nearest_mirror4f(SSAVec4f s, SSAVec4f t, int index) const - { - struct WrapX { WrapX(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->mirror_x(v); } const SSAPixelType *self; }; - struct WrapY { WrapY(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->mirror_y(v); } const SSAPixelType *self; }; - return nearest_helper4f(s, t, index, WrapX(this), WrapY(this)); - /* - return nearest_helper4f( - s, t, index, - [this](SSAVec4i v) -> SSAVec4i { return mirror_x(v); }, - [this](SSAVec4i v) -> SSAVec4i { return mirror_y(v); }); - */ - } - - template - void gather_helper4f(SSAVec4f s, SSAVec4f t, int index, SSAVec4f *out_pixels, WrapXFunctor wrap_x, WrapYFunctor wrap_y) const - { - SSAVec4i x = int_floor(s * _widthps - 0.5f); - SSAVec4i y = int_floor(t * _heightps - 0.5f); - SSAVec8s y16 = SSAVec8s(wrap_y(y + 1), wrap_y(y)); - SSAVec8s offsethi = SSAVec8s::mulhi(y16, _width16); - SSAVec8s offsetlo = y16 * _width16; - SSAVec4i x0 = wrap_x(x); - SSAVec4i x1 = wrap_x(x + 1); - SSAVec4i line0 = SSAVec4i::combinehi(offsetlo, offsethi); - SSAVec4i line1 = SSAVec4i::combinelo(offsetlo, offsethi); - SSAVec4i offset0 = x0 + line0; - SSAVec4i offset1 = x1 + line0; - SSAVec4i offset2 = x0 + line1; - SSAVec4i offset3 = x1 + line1; - out_pixels[0] = PixelFormat::get4f(offset0[index]); - out_pixels[1] = PixelFormat::get4f(offset1[index]); - out_pixels[2] = PixelFormat::get4f(offset2[index]); - out_pixels[3] = PixelFormat::get4f(offset3[index]); - } - - void gather_clamp4f(SSAVec4f s, SSAVec4f t, int index, SSAVec4f *out_pixels) const - { - struct WrapX { WrapX(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->clamp_x(v); } const SSAPixelType *self; }; - struct WrapY { WrapY(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->clamp_y(v); } const SSAPixelType *self; }; - return gather_helper4f(s, t, index, out_pixels, WrapX(this), WrapY(this)); - /* - gather_helper4f( - s, t, index, out_pixels, - [this](SSAVec4i v) -> SSAVec4i { return clamp_x(v); }, - [this](SSAVec4i v) -> SSAVec4i { return clamp_y(v); }); - */ - } - - void gather_repeat4f(SSAVec4f s, SSAVec4f t, int index, SSAVec4f *out_pixels) const - { - struct WrapX { WrapX(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->repeat_x(v); } const SSAPixelType *self; }; - struct WrapY { WrapY(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->repeat_y(v); } const SSAPixelType *self; }; - return gather_helper4f(s, t, index, out_pixels, WrapX(this), WrapY(this)); - /* - gather_helper4f( - s, t, index, out_pixels, - [this](SSAVec4i v) -> SSAVec4i { return repeat_x(v); }, - [this](SSAVec4i v) -> SSAVec4i { return repeat_y(v); }); - */ - } - - void gather_mirror4f(SSAVec4f s, SSAVec4f t, int index, SSAVec4f *out_pixels) const - { - struct WrapX { WrapX(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->mirror_x(v); } const SSAPixelType *self; }; - struct WrapY { WrapY(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i v) { return self->mirror_y(v); } const SSAPixelType *self; }; - return gather_helper4f(s, t, index, out_pixels, WrapX(this), WrapY(this)); - /* - gather_helper4f( - s, t, index, out_pixels, - [this](SSAVec4i v) -> SSAVec4i { return mirror_x(v); }, - [this](SSAVec4i v) -> SSAVec4i { return mirror_y(v); }); - */ - } - - SSAVec4f linear_clamp4f(SSAVec4f s, SSAVec4f t, int index) const - { - SSAScopeHint hint("linearclamp"); - SSAVec4f samples[4]; - gather_clamp4f(s, t, index, samples); - return linear_interpolate4f(s, t, index, samples); - } - - SSAVec4f linear_repeat4f(SSAVec4f s, SSAVec4f t, int index) const - { - SSAVec4f samples[4]; - gather_repeat4f(s, t, index, samples); - return linear_interpolate4f(s, t, index, samples); - } - - SSAVec4f linear_mirror4f(SSAVec4f s, SSAVec4f t, int index) const - { - SSAVec4f samples[4]; - gather_mirror4f(s, t, index, samples); - return linear_interpolate4f(s, t, index, samples); - } - - SSAVec4f linear_interpolate4f(SSAVec4f s, SSAVec4f t, int index, const SSAVec4f *samples) const - { - SSAVec4f a = fract(s * _widthps - 0.5f); - SSAVec4f b = fract(t * _heightps - 0.5f); - SSAVec4f inv_a = 1.0f - a; - SSAVec4f inv_b = 1.0f - b; - return - samples[0] * SSAVec4f::shuffle(inv_a * inv_b, index, index, index, index) + - samples[1] * SSAVec4f::shuffle(a * inv_b, index, index, index, index) + - samples[2] * SSAVec4f::shuffle(inv_a * b, index, index, index, index) + - samples[3] * SSAVec4f::shuffle(a * b, index, index, index, index); - } - - ///////////////////////////////////////////////////////////////////////// - - SSAVec4i clamp(SSAVec4i sstt) const - { - return SSAVec4i::max_sse41(SSAVec4i::min_sse41(sstt, _widthheight - 1), 0); - } - - template - void gather_helper4f(SSAVec4f st, SSAVec4f *out_pixels, WrapFunctor wrap) const - { - SSAVec4f sstt = SSAVec4f::shuffle(st, 0, 0, 1, 1); - SSAVec4i xxyy = wrap(int_floor(sstt * _widthheightps - 0.5f) + SSAVec4i(0, 1, 0, 1)); - SSAVec4i xxoffset = SSAVec4f::shuffle(xxyy, xxyy * _width32, 0, 1, 6, 7); - SSAVec4i offsets = SSAVec4i::shuffle(xxoffset, 0, 1, 0, 1) + SSAVec4i::shuffle(xxoffset, 2, 2, 3, 3); - out_pixels[0] = PixelFormat::get4f(offsets[0]); - out_pixels[1] = PixelFormat::get4f(offsets[1]); - out_pixels[2] = PixelFormat::get4f(offsets[2]); - out_pixels[3] = PixelFormat::get4f(offsets[3]); - } - - void gather_clamp4f(SSAVec4f st, SSAVec4f *out_pixels) const - { - struct Wrap { Wrap(const SSAPixelType *self) : self(self) { } SSAVec4i operator()(SSAVec4i sstt) { return self->clamp(sstt); } const SSAPixelType *self; }; - return gather_helper4f(st, out_pixels, Wrap(this)); - } - - SSAVec4f linear_clamp4f(SSAVec4f st) const - { - SSAScopeHint hint("linearclamp"); - SSAVec4f samples[4]; - gather_clamp4f(st, samples); - return linear_interpolate4f(st, samples); - } - - SSAVec4f linear_interpolate4f(SSAVec4f st, const SSAVec4f *samples) const - { - SSAVec4f sstt = SSAVec4f::shuffle(st, 0, 0, 1, 1); - SSAVec4f aabb = fract(sstt * _widthheightps - 0.5f); - SSAVec4f inv_aabb = 1.0f - aabb; - SSAVec4f ab_inv_ab = SSAVec4f::shuffle(aabb, inv_aabb, 0, 2, 4, 6); - SSAVec4f ab__inv_a_b__inv_a_inv_b__a_invb = ab_inv_ab * SSAVec4f::shuffle(ab_inv_ab, 1, 2, 3, 0); - return - samples[0] * SSAVec4f::shuffle(ab__inv_a_b__inv_a_inv_b__a_invb, 2, 2, 2, 2) + - samples[1] * SSAVec4f::shuffle(ab__inv_a_b__inv_a_inv_b__a_invb, 3, 3, 3, 3) + - samples[2] * SSAVec4f::shuffle(ab__inv_a_b__inv_a_inv_b__a_invb, 1, 1, 1, 1) + - samples[3] * SSAVec4f::shuffle(ab__inv_a_b__inv_a_inv_b__a_invb, 0, 0, 0, 0); - } - -public: - SSAInt _width; - SSAInt _height; - SSAVec4i _width32; - SSAVec8s _width16; - SSAVec4f _widthps; - SSAVec4f _heightps; - - SSAVec4i _widthheight; - SSAVec4f _widthheightps; -}; diff --git a/src/r_compiler/ssa/ssa_scope.cpp b/src/r_compiler/ssa/ssa_scope.cpp index 520f301a4..7c6f090fe 100644 --- a/src/r_compiler/ssa/ssa_scope.cpp +++ b/src/r_compiler/ssa/ssa_scope.cpp @@ -41,12 +41,12 @@ llvm::Function *SSAScope::intrinsic(llvm::Intrinsic::ID id, llvm::ArrayRefgetParent()->getEntryBlock(); diff --git a/src/r_compiler/ssa/ssa_scope.h b/src/r_compiler/ssa/ssa_scope.h index c942a7c37..1c9dfb362 100644 --- a/src/r_compiler/ssa/ssa_scope.h +++ b/src/r_compiler/ssa/ssa_scope.h @@ -12,8 +12,8 @@ public: static llvm::Module *module(); static llvm::IRBuilder<> &builder(); static llvm::Function *intrinsic(llvm::Intrinsic::ID id, llvm::ArrayRef parameter_types = llvm::ArrayRef()); - static llvm::Value *alloca(llvm::Type *type); - static llvm::Value *alloca(llvm::Type *type, SSAInt size); + static llvm::Value *alloc_stack(llvm::Type *type); + static llvm::Value *alloc_stack(llvm::Type *type, SSAInt size); static llvm::MDNode *constant_scope_list(); static const std::string &hint(); static void set_hint(const std::string &hint); diff --git a/src/r_compiler/ssa/ssa_stack.h b/src/r_compiler/ssa/ssa_stack.h index 435530be1..d072f181e 100644 --- a/src/r_compiler/ssa/ssa_stack.h +++ b/src/r_compiler/ssa/ssa_stack.h @@ -1,6 +1,8 @@ #pragma once +#include "ssa_scope.h" + template class SSAStack { @@ -8,7 +10,7 @@ public: SSAStack() : v(0) { - v = SSAScope::alloca(SSAVariable::llvm_type()); + v = SSAScope::alloc_stack(SSAVariable::llvm_type()); } SSAVariable load() const diff --git a/src/r_compiler/ssa/ssa_vec4i.cpp b/src/r_compiler/ssa/ssa_vec4i.cpp index 60d6161a5..ac36172f0 100644 --- a/src/r_compiler/ssa/ssa_vec4i.cpp +++ b/src/r_compiler/ssa/ssa_vec4i.cpp @@ -55,10 +55,17 @@ SSAVec4i::SSAVec4i(SSAInt i0, SSAInt i1, SSAInt i2, SSAInt i3) std::vector constants; constants.resize(4, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 0, true))); v = llvm::ConstantVector::get(constants); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) + v = SSAScope::builder().CreateInsertElement(v, i0.v, SSAInt(0).v, SSAScope::hint()); + v = SSAScope::builder().CreateInsertElement(v, i1.v, SSAInt(1).v, SSAScope::hint()); + v = SSAScope::builder().CreateInsertElement(v, i2.v, SSAInt(2).v, SSAScope::hint()); + v = SSAScope::builder().CreateInsertElement(v, i3.v, SSAInt(3).v, SSAScope::hint()); +#else v = SSAScope::builder().CreateInsertElement(v, i0.v, (uint64_t)0, SSAScope::hint()); v = SSAScope::builder().CreateInsertElement(v, i1.v, (uint64_t)1, SSAScope::hint()); v = SSAScope::builder().CreateInsertElement(v, i2.v, (uint64_t)2, SSAScope::hint()); v = SSAScope::builder().CreateInsertElement(v, i3.v, (uint64_t)3, SSAScope::hint()); +#endif } SSAVec4i::SSAVec4i(SSAVec4f f32) @@ -84,7 +91,11 @@ SSAVec4i SSAVec4i::insert(SSAInt index, SSAInt value) SSAVec4i SSAVec4i::insert(int index, SSAInt value) { +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) + return SSAVec4i::from_llvm(SSAScope::builder().CreateInsertElement(v, value.v, SSAInt(index).v, SSAScope::hint())); +#else return SSAVec4i::from_llvm(SSAScope::builder().CreateInsertElement(v, value.v, index, SSAScope::hint())); +#endif } SSAVec4i SSAVec4i::insert(int index, int value) From f8f710d9e27eb0649546af6d65069a82b61b6fc9 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 17 Oct 2016 01:17:48 +0200 Subject: [PATCH 1099/1509] Fix linker errors on Windows --- src/CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 89341cfa7..9a5aec83b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -272,15 +272,16 @@ if( NOT NO_OPENAL ) endif() endif() -set( LLVM_COMPONENTS core support asmparser asmprinter bitreader codegen ipo - irreader transformutils instrumentation profiledata runtimedyld - object instcombine linker analysis selectiondag scalaropts vectorize executionengine - mc mcdisassembler mcparser mcjit target x86asmprinter x86info x86desc x86utils x86codegen ) # Path where it looks for the LLVM compiled files on Windows set( LLVM_PRECOMPILED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" ) if( NOT WIN32 ) + set( LLVM_COMPONENTS core support asmparser asmprinter bitreader codegen ipo + irreader transformutils instrumentation profiledata runtimedyld + object instcombine linker analysis selectiondag scalaropts vectorize executionengine + mc mcdisassembler mcparser mcjit target x86asmprinter x86info x86desc x86utils x86codegen ) + # Example LLVM_DIR folder: C:/Development/Environment/Src/llvm-3.9.0/build/lib/cmake/llvm find_package(LLVM REQUIRED CONFIG) message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") @@ -289,6 +290,11 @@ if( NOT WIN32 ) include_directories( ${LLVM_INCLUDE_DIRS} ) set( ZDOOM_LIBS ${ZDOOM_LIBS} ${llvm_libs} ) else() + set( LLVM_COMPONENTS core support asmparser asmprinter bitreader codegen passes ipo + irreader transformutils instrumentation profiledata debuginfocodeview runtimedyld + object instcombine linker analysis selectiondag scalaropts vectorize executionengine + mc mcdisassembler mcparser mcjit target x86asmprinter x86info x86desc x86utils x86codegen ) + include_directories( "${LLVM_PRECOMPILED_DIR}/include" ) if( X64 ) include_directories( "${LLVM_PRECOMPILED_DIR}/64bit-include" ) From 931d2410566dd54355ac92849b3018366ee5f92e Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Mon, 17 Oct 2016 01:13:58 -0400 Subject: [PATCH 1100/1509] - Change "vid_used3d" to true by default, in Windows. --- src/win32/hardware.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index da1ced10f..d9de96566 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -73,7 +73,7 @@ int currentcanvas = -1; bool changerenderer; // Software OpenGL canvas -CUSTOM_CVAR(Bool, vid_used3d, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR(Bool, vid_used3d, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { if (self != currentcanvas) Printf("You must restart " GAMENAME " for this change to take effect.\n"); From c9a9e93c66cd875ed30a7df408ed8486f612c118 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 17 Oct 2016 11:54:03 +0200 Subject: [PATCH 1101/1509] Fix warning C4805: '!=': unsafe mix of type 'bool' and type 'int' in operation --- src/win32/hardware.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index d9de96566..e67d11842 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -75,7 +75,7 @@ bool changerenderer; // Software OpenGL canvas CUSTOM_CVAR(Bool, vid_used3d, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { - if (self != currentcanvas) + if ((self ? 1 : 0) != currentcanvas) Printf("You must restart " GAMENAME " for this change to take effect.\n"); } From af937366d1208e4c5cfa5163ac176796d3b231cc Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 17 Oct 2016 12:36:01 +0200 Subject: [PATCH 1102/1509] Added DetectRangeError function --- src/r_draw.cpp | 1 + src/r_draw.h | 1 + src/r_draw_rgba.cpp | 8 ++++++++ src/r_drawt_rgba.cpp | 2 ++ src/r_main.cpp | 1 + src/r_thread.h | 24 ++++++++++++++++++++++++ src/v_draw.cpp | 3 +++ 7 files changed, 40 insertions(+) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 6b68cf81b..9d7160d01 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -64,6 +64,7 @@ BYTE* viewimage; extern "C" { int ylookup[MAXHEIGHT]; BYTE *dc_destorg; +int dc_destheight; } int scaledviewwidth; diff --git a/src/r_draw.h b/src/r_draw.h index 4c478a726..2b664897d 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -76,6 +76,7 @@ extern "C" const BYTE* dc_source2; extern "C" uint32_t dc_texturefracx; extern "C" BYTE *dc_dest, *dc_destorg; +extern "C" int dc_destheight; extern "C" int dc_count; extern "C" DWORD vplce[4]; diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 4b3d98c04..a2c4fb9ae 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -245,6 +245,8 @@ public: args.flags |= DrawWallArgs::simple_shade; if (args.source2[0] == nullptr) args.flags |= DrawWallArgs::nearest_filter; + + DetectRangeError(args.dest, args.dest_y, args.count); } void Execute(DrawerThread *thread) override @@ -304,6 +306,8 @@ public: args.flags |= DrawWallArgs::simple_shade; if (args.source2[0] == nullptr) args.flags |= DrawWallArgs::nearest_filter; + + DetectRangeError(args.dest, args.dest_y, args.count); } void Execute(DrawerThread *thread) override @@ -368,6 +372,8 @@ public: args.flags = 0; if (dc_shade_constants.simple_shade) args.flags |= DrawColumnArgs::simple_shade; + + DetectRangeError(args.dest, args.dest_y, args.count); } void Execute(DrawerThread *thread) override @@ -410,6 +416,8 @@ public: args.textureheight1 = bufheight[1]; args.top_color = solid_top; args.bottom_color = solid_bottom; + + DetectRangeError(args.dest, args.dest_y, args.count); } FString DebugInfo() override diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index bf957df3d..a3849b9af 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -97,6 +97,8 @@ public: args.flags = 0; if (dc_shade_constants.simple_shade) args.flags |= DrawColumnArgs::simple_shade; + + DetectRangeError(args.dest, args.dest_y, args.count); } void Execute(DrawerThread *thread) override diff --git a/src/r_main.cpp b/src/r_main.cpp index ba3c4e846..684073046 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -823,6 +823,7 @@ void R_SetupBuffer () #endif } dc_destorg = lineptr; + dc_destheight = RenderTarget->GetHeight() - viewwindowy; for (int i = 0; i < RenderTarget->GetHeight(); i++) { ylookup[i] = i * pitch; diff --git a/src/r_thread.h b/src/r_thread.h index 5bb413240..63c442442 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -72,6 +72,30 @@ class DrawerCommand protected: int _dest_y; + void DetectRangeError(uint32_t *&dest, int &dest_y, int &count) + { +#if defined(_MSC_VER) && defined(_DEBUG) + if (dest_y < 0 || count < 0 || dest_y + count > dc_destheight) + __debugbreak(); // Buffer overrun detected! +#endif + + if (dest_y < 0) + { + count += dest_y; + dest_y = 0; + dest = (uint32_t*)dc_destorg; + } + else if (dest_y >= dc_destheight) + { + dest_y = 0; + count = 0; + } + + if (count < 0 || count > MAXHEIGHT) count = 0; + if (dest_y + count >= dc_destheight) + count = dc_destheight - dest_y; + } + public: DrawerCommand() { diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 921896296..1a3262eab 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -204,7 +204,9 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) mode = R_SetPatchStyle(parms.style, parms.Alpha, 0, parms.fillcolor); BYTE *destorgsave = dc_destorg; + int destheightsave = dc_destheight; dc_destorg = screen->GetBuffer(); + dc_destheight = screen->GetHeight(); if (dc_destorg == NULL) { I_FatalError("Attempt to write to buffer of hardware canvas"); @@ -362,6 +364,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) R_FinishSetPatchStyle (); dc_destorg = destorgsave; + dc_destheight = destheightsave; if (ticdup != 0 && menuactive == MENU_Off) { From f32a2547bc365fdd40158d65fa87e518182424d5 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Mon, 17 Oct 2016 16:05:14 -0400 Subject: [PATCH 1103/1509] - Fixed LLVM compile for LLVM 3.8 (Ubuntu) --- src/r_compiler/llvmdrawers.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index cddf6ec9d..d5078a6c0 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -482,7 +482,7 @@ LLVMProgram::LLVMProgram() mModule = std::make_unique("render", context()); mModule->setTargetTriple(targetTriple); -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) mModule->setDataLayout(new DataLayout(*machine->getSubtargetImpl()->getDataLayout())); #else mModule->setDataLayout(machine->createDataLayout()); @@ -497,7 +497,7 @@ void LLVMProgram::CreateEE() legacy::FunctionPassManager PerFunctionPasses(mModule.get()); legacy::PassManager PerModulePasses; -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9) +#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8) PerFunctionPasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); PerModulePasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); #endif @@ -542,7 +542,7 @@ std::string LLVMProgram::DumpModule() { std::string str; llvm::raw_string_ostream stream(str); -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) mModule->print(stream, nullptr); #else mModule->print(stream, nullptr, false, true); From df3f5ae882c888c12ed73323292f5237538d108c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 18 Oct 2016 01:16:36 +0200 Subject: [PATCH 1104/1509] Use OpenGL to allocate the canvas buffer to avoid a costly memcpy --- src/gl/system/gl_swframebuffer.cpp | 110 +++++++++++++++++++---------- src/gl/system/gl_swframebuffer.h | 4 ++ 2 files changed, 77 insertions(+), 37 deletions(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index a239f9d57..b6d163044 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -1093,7 +1093,24 @@ bool OpenGLSWFrameBuffer::Lock(bool buffered) } assert(!In2D); Accel2D = vid_hw2d; - Buffer = MemBuffer; + if (UseMappedMemBuffer) + { + if (!MappedMemBuffer) + { + BindFBBuffer(); + + MappedMemBuffer = glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE); + Pitch = Width; + if (MappedMemBuffer == nullptr) + return true; + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); + } + Buffer = (uint8_t*)MappedMemBuffer; + } + else + { + Buffer = MemBuffer; + } return false; } @@ -1269,54 +1286,73 @@ bool OpenGLSWFrameBuffer::PaintToWindow() // //========================================================================== +void OpenGLSWFrameBuffer::BindFBBuffer() +{ + int usage = UseMappedMemBuffer ? GL_DYNAMIC_DRAW : GL_STREAM_DRAW; + + int pixelsize = IsBgra() ? 4 : 1; + int size = Width * Height * pixelsize; + + if (FBTexture->Buffers[0] == 0) + { + glGenBuffers(2, (GLuint*)FBTexture->Buffers); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffers[1]); + glBufferData(GL_PIXEL_UNPACK_BUFFER, size, nullptr, usage); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffers[0]); + glBufferData(GL_PIXEL_UNPACK_BUFFER, size, nullptr, usage); + } + else + { + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffers[FBTexture->CurrentBuffer]); + } +} + void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) { if (copy3d) { - int pixelsize = IsBgra() ? 4 : 1; - int size = Width * Height * pixelsize; + BindFBBuffer(); + FBTexture->CurrentBuffer = (FBTexture->CurrentBuffer + 1) & 1; - if (FBTexture->Buffers[0] == 0) + if (!UseMappedMemBuffer) { - glGenBuffers(2, (GLuint*)FBTexture->Buffers); - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffers[0]); - glBufferData(GL_PIXEL_UNPACK_BUFFER, size, nullptr, GL_STREAM_DRAW); - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffers[1]); - glBufferData(GL_PIXEL_UNPACK_BUFFER, size, nullptr, GL_STREAM_DRAW); - } - else - { - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, FBTexture->Buffers[FBTexture->CurrentBuffer]); - FBTexture->CurrentBuffer = (FBTexture->CurrentBuffer + 1) & 1; - } + int pixelsize = IsBgra() ? 4 : 1; + int size = Width * Height * pixelsize; - uint8_t *dest = (uint8_t*)MapBuffer(GL_PIXEL_UNPACK_BUFFER, size); - if (dest) - { - if (Pitch == Width) + uint8_t *dest = (uint8_t*)MapBuffer(GL_PIXEL_UNPACK_BUFFER, size); + if (dest) { - memcpy(dest, MemBuffer, Width * Height * pixelsize); - } - else - { - uint8_t *src = MemBuffer; - for (int y = 0; y < Height; y++) + if (Pitch == Width) { - memcpy(dest, src, Width * pixelsize); - dest += Width * pixelsize; - src += Pitch * pixelsize; + memcpy(dest, MemBuffer, Width * Height * pixelsize); } + else + { + uint8_t *src = MemBuffer; + for (int y = 0; y < Height; y++) + { + memcpy(dest, src, Width * pixelsize); + dest += Width * pixelsize; + src += Pitch * pixelsize; + } + } + glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); } - glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); - GLint oldBinding = 0; - glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldBinding); - glBindTexture(GL_TEXTURE_2D, FBTexture->Texture); - if (IsBgra()) - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Width, Height, GL_BGRA, GL_UNSIGNED_BYTE, 0); - else - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Width, Height, GL_RED, GL_UNSIGNED_BYTE, 0); - glBindTexture(GL_TEXTURE_2D, oldBinding); } + else if (MappedMemBuffer) + { + glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); + MappedMemBuffer = nullptr; + } + + GLint oldBinding = 0; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldBinding); + glBindTexture(GL_TEXTURE_2D, FBTexture->Texture); + if (IsBgra()) + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Width, Height, GL_BGRA, GL_UNSIGNED_BYTE, 0); + else + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Width, Height, GL_RED, GL_UNSIGNED_BYTE, 0); + glBindTexture(GL_TEXTURE_2D, oldBinding); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); } diff --git a/src/gl/system/gl_swframebuffer.h b/src/gl/system/gl_swframebuffer.h index 315101fde..226d8cca7 100644 --- a/src/gl/system/gl_swframebuffer.h +++ b/src/gl/system/gl_swframebuffer.h @@ -194,6 +194,10 @@ private: void DrawTriangleList(int minIndex, int numVertices, int startIndex, int primitiveCount); void Present(); + void BindFBBuffer(); + void *MappedMemBuffer = nullptr; + bool UseMappedMemBuffer = true; + static uint32_t ColorARGB(uint32_t a, uint32_t r, uint32_t g, uint32_t b) { return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | ((b) & 0xff); } static uint32_t ColorRGBA(uint32_t r, uint32_t g, uint32_t b, uint32_t a) { return ColorARGB(a, r, g, b); } static uint32_t ColorXRGB(uint32_t r, uint32_t g, uint32_t b) { return ColorARGB(0xff, r, g, b); } From 79b14bbc0854f9f813e6478b8db6f3b4db737154 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Tue, 18 Oct 2016 11:38:35 -0400 Subject: [PATCH 1105/1509] - Updated version.h for beta tag --- src/version.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/version.h b/src/version.h index c7a95e66e..99caa0ad7 100644 --- a/src/version.h +++ b/src/version.h @@ -41,12 +41,12 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "0.0pre" +#define VERSIONSTR "0.1beta" // The version as seen in the Windows resource -#define RC_FILEVERSION 0,0,9999,0 -#define RC_PRODUCTVERSION 0,0,9999,0 -#define RC_PRODUCTVERSION2 "0.0pre" +#define RC_FILEVERSION 0,1,0,0 +#define RC_PRODUCTVERSION 0,1,0,0 +#define RC_PRODUCTVERSION2 "0.1beta" // Version identifier for network games. // Bump it every time you do a release unless you're certain you From 694cae054cb088784221e7df29e17337d3ba1d57 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 18 Oct 2016 18:23:56 +0200 Subject: [PATCH 1106/1509] Add some experimental draw triangle code --- src/r_draw_rgba.cpp | 249 +++++++++++++++++++++++++++++++++++++++++++ src/r_swrenderer.cpp | 5 + 2 files changed, 254 insertions(+) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index a2c4fb9ae..cb1eb3fc0 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -1256,6 +1256,255 @@ void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) ///////////////////////////////////////////////////////////////////////////// +struct TriVertex +{ + enum { NumVarying = 3 }; + float x, y, z, w; + float varying[NumVarying]; +}; + +float gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) +{ + float top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); + float bottom = (x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2); + return top / bottom; +} + +float grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) +{ + float top = (c1 - c2) * (x0 - x2) - (c0 - c2) * (x1 - x2); + float bottom = -((x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2)); + return top / bottom; +} + +void triangle(uint32_t *dest, int pitch, const TriVertex &v1, const TriVertex &v2, const TriVertex &v3) +{ + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int minx = (MIN(MIN(X1, X2), X3) + 0xF) >> 4; + int maxx = (MAX(MAX(X1, X2), X3) + 0xF) >> 4; + int miny = (MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4; + int maxy = (MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + dest += miny * pitch; + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // Gradients + float gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + float gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + float startW = v1.w + gradWX * (minx - v1.x) + gradWY * (miny - v1.y); + float gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (minx - v1.x) + gradVaryingY[i] * (miny - v1.y); + } + + // Loop through blocks + for (int y = miny; y < maxy; y += q) + { + for (int x = minx; x < maxx; x += q) + { + // Corners of block + int x0 = x << 4; + int x1 = (x + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; + bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; + bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; + bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; + int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); + + bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; + bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; + bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; + bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; + int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); + + bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; + bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; + bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; + bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; + int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + + // Skip block when outside an edge + if (a == 0x0 || b == 0x0 || c == 0x0) continue; + + // Calculate varying variables for affine block + float offx0 = (x - minx) + 0.5f; + float offy0 = (y - miny) + 0.5f; + float offx1 = offx0 + q; + float offy1 = offy0 + q; + float rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); + float rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); + float rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); + float rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); + float varyingTL[TriVertex::NumVarying]; + float varyingTR[TriVertex::NumVarying]; + float varyingBL[TriVertex::NumVarying]; + float varyingBR[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; + varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; + varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); + varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); + } + + uint32_t *buffer = dest; + + // Accept whole block when totally covered + if (a == 0xF && b == 0xF && c == 0xF) + { + for (int iy = 0; iy < q; iy++) + { + float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varying[i] = varyingTL[i] + varyingBL[i] * iy; + varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + } + + for (int ix = x; ix < x + q; ix++) + { + uint32_t red = (uint32_t)clamp(varying[0] * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t green = (uint32_t)clamp(varying[1] * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t blue = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); + + buffer[ix] = 0xff000000 | (red << 16) | (green << 8) | blue; + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + } + + buffer += pitch; + } + } + else // Partially covered block + { + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; + + for (int iy = 0; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varying[i] = varyingTL[i] + varyingBL[i] * iy; + varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + } + + for (int ix = x; ix < x + q; ix++) + { + if (CX1 > 0 && CX2 > 0 && CX3 > 0) + { + uint32_t red = (uint32_t)clamp(varying[0] * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t green = (uint32_t)clamp(varying[1] * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t blue = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); + + buffer[ix] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + + buffer += pitch; + } + } + } + + dest += q * pitch; + } +} + +void R_DrawTriangle() +{ + TriVertex trivert[6]; + + trivert[0].x = 100; + trivert[0].y = 350; + trivert[0].w = 1.0f; + trivert[0].varying[0] = 0.0f; + trivert[0].varying[1] = 1.0f; + trivert[0].varying[2] = 0.0f; + trivert[1].x = 400; + trivert[1].y = 500; + trivert[1].w = 1.0f; + trivert[1].varying[0] = 1.0f; + trivert[1].varying[1] = 0.0f; + trivert[1].varying[2] = 0.0f; + trivert[2].x = 200; + trivert[2].y = 200; + trivert[2].w = 1.0f; + trivert[2].varying[0] = 0.0f; + trivert[2].varying[1] = 0.0f; + trivert[2].varying[2] = 1.0f; + + triangle((uint32_t*)dc_destorg, dc_pitch, trivert[0], trivert[1], trivert[2]); +} + +///////////////////////////////////////////////////////////////////////////// + void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) { DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 372f23acc..49eb0ef27 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -47,10 +47,13 @@ EXTERN_CVAR(Bool, r_shadercolormaps) +CVAR(Bool, r_drawtriangle, false, 0) + void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio); void R_SetupColormap(player_t *); void R_SetupFreelook(); void R_InitRenderer(); +void R_DrawTriangle(); FSoftwareRenderer::FSoftwareRenderer() { @@ -192,6 +195,8 @@ void FSoftwareRenderer::RenderView(player_t *player) } R_EndDrawerCommands(); + if (r_swtruecolor && r_drawtriangle) + R_DrawTriangle(); } //========================================================================== From 226287875bf7b4cb517d2b200ef403abd301a8a2 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Tue, 18 Oct 2016 14:07:44 -0400 Subject: [PATCH 1107/1509] Creating 0.2pre tag --- src/version.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/version.h b/src/version.h index 99caa0ad7..837ef4eee 100644 --- a/src/version.h +++ b/src/version.h @@ -41,17 +41,17 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "0.1beta" +#define VERSIONSTR "0.2pre" // The version as seen in the Windows resource -#define RC_FILEVERSION 0,1,0,0 -#define RC_PRODUCTVERSION 0,1,0,0 -#define RC_PRODUCTVERSION2 "0.1beta" +#define RC_FILEVERSION 0,1,9999,0 +#define RC_PRODUCTVERSION 0,1,9999,0 +#define RC_PRODUCTVERSION2 "0.2pre" // Version identifier for network games. // Bump it every time you do a release unless you're certain you // didn't change anything that will affect sync. -#define NETGAMEVERSION 232 +#define NETGAMEVERSION 233 // Version stored in the ini's [LastRun] section. // Bump it if you made some configuration change that you want to From 68efdf5cefcbad4588b59a143f6746ec54b18341 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Tue, 18 Oct 2016 18:21:22 -0400 Subject: [PATCH 1108/1509] - Fixed: Added linker flags for Linux to prevent crashes using LLVM. Using fix found by dpJudas. --- src/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9a5aec83b..8ce02cdd2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -610,6 +610,11 @@ if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) set( CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++ ${CMAKE_EXE_LINKER_FLAGS}" ) endif () + # Linux - add these flags for LLVM compatibility to prevent crashing + if ( UNIX AND NOT APPLE ) + set( CMAKE_EXE_LINKER_FLAGS "-Wl,--exclude-libs,ALL ${CMAKE_EXE_LINKER_FLAGS}" ) + endif() + # Remove extra warnings when using the official DirectX headers. # Also, TDM-GCC 4.4.0 no longer accepts glibc-style printf formats as valid, # which is a royal pain. The previous version I had been using was fine with them. From ef70ba09852f44e8116c4120956e8eb61187853b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 19 Oct 2016 03:49:42 +0200 Subject: [PATCH 1109/1509] More triangle rendering --- src/r_draw_rgba.cpp | 229 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 205 insertions(+), 24 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index cb1eb3fc0..7048c9be8 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -39,6 +39,7 @@ #include "r_plane.h" #include "r_draw_rgba.h" #include "r_compiler/llvmdrawers.h" +#include "gl/data/gl_matrix.h" #include "gi.h" #include "stats.h" @@ -1258,6 +1259,9 @@ void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) struct TriVertex { + TriVertex() { } + TriVertex(float x, float y, float z, float w, float u, float v, float light) : x(x), y(y), z(z), w(w) { varying[0] = u; varying[1] = v; varying[2] = light; } + enum { NumVarying = 3 }; float x, y, z, w; float varying[NumVarying]; @@ -1307,10 +1311,12 @@ void triangle(uint32_t *dest, int pitch, const TriVertex &v1, const TriVertex &v const int FDY31 = DY31 << 4; // Bounding rectangle - int minx = (MIN(MIN(X1, X2), X3) + 0xF) >> 4; - int maxx = (MAX(MAX(X1, X2), X3) + 0xF) >> 4; - int miny = (MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4; - int maxy = (MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4; + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, 0); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, viewwidth); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, 0); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, viewheight); + if (minx >= maxx || miny >= maxy) + return; // Block size, standard 8x8 (must be power of two) const int q = 8; @@ -1477,30 +1483,205 @@ void triangle(uint32_t *dest, int pitch, const TriVertex &v1, const TriVertex &v } } +bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2) +{ + if (clipdistance1 < 0.0f && clipdistance2 < 0.0f) + return true; + + if (clipdistance1 < 0.0f) + t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), t1); + + if (clipdistance2 < 0.0f) + t2 = MIN(1.0f - clipdistance2 / (clipdistance1 - clipdistance2), t2); + + return false; +} + +void clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert) +{ + // Clip and cull so that the following is true for all vertices: + // -v.w <= v.x <= v.w + // -v.w <= v.y <= v.w + // -v.w <= v.z <= v.w + + float t1 = 0.0f, t2 = 1.0f; + bool culled = + cullhalfspace(v1.x + v1.w, v2.x + v2.w, t1, t2) || + cullhalfspace(v1.w - v1.x, v2.w - v2.x, t1, t2) || + cullhalfspace(v1.y + v1.w, v2.y + v2.w, t1, t2) || + cullhalfspace(v1.w - v1.y, v2.w - v2.y, t1, t2) || + cullhalfspace(v1.z + v1.w, v2.z + v2.w, t1, t2) || + cullhalfspace(v1.w - v1.z, v2.w - v2.z, t1, t2); + if (culled) + return; + + if (t1 == 0.0f) + { + clippedvert[numclipvert++] = v1; + } + else + { + auto &v = clippedvert[numclipvert++]; + v.x = v1.x * (1.0f - t1) + v2.x * t1; + v.y = v1.y * (1.0f - t1) + v2.y * t1; + v.z = v1.z * (1.0f - t1) + v2.z * t1; + v.w = v1.w * (1.0f - t1) + v2.w * t1; + for (int i = 0; i < TriVertex::NumVarying; i++) + v.varying[i] = v1.varying[i] * (1.0f - t1) + v2.varying[i] * t1; + } + + if (t2 != 1.0f) + { + auto &v = clippedvert[numclipvert++]; + v.x = v1.x * (1.0f - t2) + v2.x * t2; + v.y = v1.y * (1.0f - t2) + v2.y * t2; + v.z = v1.z * (1.0f - t2) + v2.z * t2; + v.w = v1.w * (1.0f - t2) + v2.w * t2; + for (int i = 0; i < TriVertex::NumVarying; i++) + v.varying[i] = v1.varying[i] * (1.0f - t2) + v2.varying[i] * t2; + } +} + void R_DrawTriangle() { - TriVertex trivert[6]; + TriVertex cube[6 * 6] = + { + {-1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - trivert[0].x = 100; - trivert[0].y = 350; - trivert[0].w = 1.0f; - trivert[0].varying[0] = 0.0f; - trivert[0].varying[1] = 1.0f; - trivert[0].varying[2] = 0.0f; - trivert[1].x = 400; - trivert[1].y = 500; - trivert[1].w = 1.0f; - trivert[1].varying[0] = 1.0f; - trivert[1].varying[1] = 0.0f; - trivert[1].varying[2] = 0.0f; - trivert[2].x = 200; - trivert[2].y = 200; - trivert[2].w = 1.0f; - trivert[2].varying[0] = 0.0f; - trivert[2].varying[1] = 0.0f; - trivert[2].varying[2] = 1.0f; + { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + {-1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + {-1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - triangle((uint32_t*)dc_destorg, dc_pitch, trivert[0], trivert[1], trivert[2]); + + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + {-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + {-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + {-1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + {-1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + {-1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + {-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + + {-1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + {-1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + {-1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + + { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + + {-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + {-1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + {-1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + {-1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + {-1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + {-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f } + }; + + for (int i = 0; i < 6; i++) + { + cube[i * 6 + 0].varying[0] = 1.0f; + cube[i * 6 + 1].varying[1] = 1.0f; + cube[i * 6 + 2].varying[2] = 1.0f; + cube[i * 6 + 3].varying[2] = 1.0f; + cube[i * 6 + 4].varying[0] = 1.0f; + cube[i * 6 + 4].varying[1] = 1.0f; + cube[i * 6 + 4].varying[2] = 1.0f; + cube[i * 6 + 5].varying[0] = 1.0f; + } + + static float angle = 0.0f; + angle = fmod(angle + 0.5f, 360.0f); + VSMatrix objectToWorld(0); + objectToWorld.translate((float)ViewPos.X, (float)ViewPos.Y + 5.0f, (float)ViewPos.Z); + objectToWorld.rotate(angle, 0.57735f, 0.57735f, 0.57735f); + + TriVertex *vinput = cube; + for (int i = 0; i < 6 * 6 / 3; i++) + { + TriVertex vert[3]; + + // Vertex shader stuff: + for (int j = 0; j < 3; j++) + { + auto &v = vert[j]; + v = *(vinput++); + + // Apply object to world transform: + const float *matrix = objectToWorld.get(); + float vx = matrix[0 * 4 + 0] * v.x + matrix[1 * 4 + 0] * v.y + matrix[2 * 4 + 0] * v.z + matrix[3 * 4 + 0] * v.w; + float vy = matrix[0 * 4 + 1] * v.x + matrix[1 * 4 + 1] * v.y + matrix[2 * 4 + 1] * v.z + matrix[3 * 4 + 1] * v.w; + float vz = matrix[0 * 4 + 2] * v.x + matrix[1 * 4 + 2] * v.y + matrix[2 * 4 + 2] * v.z + matrix[3 * 4 + 2] * v.w; + float vw = matrix[0 * 4 + 3] * v.x + matrix[1 * 4 + 3] * v.y + matrix[2 * 4 + 3] * v.z + matrix[3 * 4 + 3] * v.w; + v.x = vx; + v.y = vy; + v.z = vz; + v.w = vw; + + // The software renderer world to clip transform: + double nearp = 5.0f; + double farp = 65536.f; + double tr_x = v.x - ViewPos.X; + double tr_y = v.y - ViewPos.Y; + double tr_z = v.z - ViewPos.Z; + double tx = tr_x * ViewSin - tr_y * ViewCos; + double tz = tr_x * ViewTanCos + tr_y * ViewTanSin; + v.x = (float)tx; + v.y = (float)tr_z; + v.z = (float)(-tz * (farp + nearp) / (nearp - farp) + (2.0f * farp * nearp) / (nearp - farp)); + v.w = (float)tz; + } + + // Cull, clip and generate additional vertices as needed + TriVertex clippedvert[6]; + int numclipvert = 0; + clipedge(vert[0], vert[1], clippedvert, numclipvert); + clipedge(vert[1], vert[2], clippedvert, numclipvert); + clipedge(vert[2], vert[0], clippedvert, numclipvert); + + // Map to 2D viewport: + for (int j = 0; j < numclipvert; j++) + { + auto &v = clippedvert[j]; + + // Calculate normalized device coordinates: + v.w = 1.0f / v.w; + v.x *= v.w; + v.y *= v.w; + v.z *= v.w; + + // Apply viewport scale to get screen coordinates: + v.x = (float)(CenterX + v.x * CenterX); + v.y = (float)(CenterY - v.y * InvZtoScale); + } + + for (int i = numclipvert; i > 1; i--) + { + triangle((uint32_t*)dc_destorg, dc_pitch, clippedvert[numclipvert - 1], clippedvert[i - 1], clippedvert[i - 2]); + } + } } ///////////////////////////////////////////////////////////////////////////// From 6a7bb43ce1853b95c970bae02d9581c6d4454123 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 19 Oct 2016 14:32:28 +0200 Subject: [PATCH 1110/1509] Fix clipping bug --- src/r_draw_rgba.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 7048c9be8..f8697bac4 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -1492,7 +1492,7 @@ bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), t1); if (clipdistance2 < 0.0f) - t2 = MIN(1.0f - clipdistance2 / (clipdistance1 - clipdistance2), t2); + t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2); return false; } From ea72152c312842d7b59e30a0286e69a6b0de05af Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 19 Oct 2016 15:43:10 +0200 Subject: [PATCH 1111/1509] Add doom style column clipping to triangle drawer --- src/r_draw_rgba.cpp | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index f8697bac4..b07813166 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -1281,7 +1281,7 @@ float grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0 return top / bottom; } -void triangle(uint32_t *dest, int pitch, const TriVertex &v1, const TriVertex &v2, const TriVertex &v3) +void triangle(uint32_t *dest, int pitch, const TriVertex &v1, const TriVertex &v2, const TriVertex &v3, int clipleft, int clipright, const short *cliptop, const short *clipbottom) { // 28.4 fixed-point coordinates const int Y1 = (int)round(16.0f * v1.y); @@ -1311,10 +1311,17 @@ void triangle(uint32_t *dest, int pitch, const TriVertex &v1, const TriVertex &v const int FDY31 = DY31 << 4; // Bounding rectangle - int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, 0); - int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, viewwidth); - int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, 0); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, viewheight); + int clipymin = cliptop[clipleft]; + int clipymax = clipbottom[clipleft]; + for (int i = clipleft + 1; i <= clipright; i++) + { + clipymin = MIN(clipymin, (int)cliptop[i]); + clipymax = MAX(clipymax, (int)clipbottom[i]); + } + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, clipymin); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipymax); if (minx >= maxx || miny >= maxy) return; @@ -1382,6 +1389,13 @@ void triangle(uint32_t *dest, int pitch, const TriVertex &v1, const TriVertex &v // Skip block when outside an edge if (a == 0x0 || b == 0x0 || c == 0x0) continue; + // Check if block needs clipping + int clipcount = 0; + for (int ix = 0; ix < q; ix++) + { + clipcount += (cliptop[x + ix] > y) || (clipbottom[x + ix] < y + q - 1); + } + // Calculate varying variables for affine block float offx0 = (x - minx) + 0.5f; float offy0 = (y - miny) + 0.5f; @@ -1406,7 +1420,7 @@ void triangle(uint32_t *dest, int pitch, const TriVertex &v1, const TriVertex &v uint32_t *buffer = dest; // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF) + if (a == 0xF && b == 0xF && c == 0xF && clipcount == 0) { for (int iy = 0; iy < q; iy++) { @@ -1453,7 +1467,9 @@ void triangle(uint32_t *dest, int pitch, const TriVertex &v1, const TriVertex &v for (int ix = x; ix < x + q; ix++) { - if (CX1 > 0 && CX2 > 0 && CX3 > 0) + bool visible = (cliptop[ix] <= y + iy) && (clipbottom[ix] >= y + iy); + + if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) { uint32_t red = (uint32_t)clamp(varying[0] * 255.0f + 0.5f, 0.0f, 255.0f); uint32_t green = (uint32_t)clamp(varying[1] * 255.0f + 0.5f, 0.0f, 255.0f); @@ -1544,6 +1560,16 @@ void clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, void R_DrawTriangle() { + int clipleft = 0; + int clipright = viewwidth - 1; + short cliptop[MAXWIDTH]; + short clipbottom[MAXWIDTH]; + for (int i = clipleft; i < clipright; i++) + { + cliptop[i] = (i - clipleft) / 4; + clipbottom[i] = viewheight - 1 - (i - clipleft) / 4; + } + TriVertex cube[6 * 6] = { {-1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, @@ -1615,8 +1641,9 @@ void R_DrawTriangle() static float angle = 0.0f; angle = fmod(angle + 0.5f, 360.0f); VSMatrix objectToWorld(0); - objectToWorld.translate((float)ViewPos.X, (float)ViewPos.Y + 5.0f, (float)ViewPos.Z); + objectToWorld.translate((float)ViewPos.X, (float)ViewPos.Y + 50.0f, (float)ViewPos.Z); objectToWorld.rotate(angle, 0.57735f, 0.57735f, 0.57735f); + objectToWorld.scale(10.0f, 10.0f, 10.0f); TriVertex *vinput = cube; for (int i = 0; i < 6 * 6 / 3; i++) @@ -1679,7 +1706,7 @@ void R_DrawTriangle() for (int i = numclipvert; i > 1; i--) { - triangle((uint32_t*)dc_destorg, dc_pitch, clippedvert[numclipvert - 1], clippedvert[i - 1], clippedvert[i - 2]); + triangle((uint32_t*)dc_destorg, dc_pitch, clippedvert[numclipvert - 1], clippedvert[i - 1], clippedvert[i - 2], clipleft, clipright, cliptop, clipbottom); } } } From d5865a46a0684420df276fb9d95ccc66eefb953e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 19 Oct 2016 17:44:50 +0200 Subject: [PATCH 1112/1509] Move triangle drawer into a command and change the sky code to use it if r_cubesky is enabled --- src/r_draw.h | 13 + src/r_draw_rgba.cpp | 803 +++++++++++++++++++++---------------------- src/r_plane.cpp | 99 +++++- src/r_swrenderer.cpp | 5 - src/r_thread.h | 3 + 5 files changed, 505 insertions(+), 418 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index 2b664897d..7b12c43bb 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -387,6 +387,19 @@ void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom); void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); +struct TriVertex +{ + TriVertex() { } + TriVertex(float x, float y, float z, float w, float u, float v, float light) : x(x), y(y), z(z), w(w) { varying[0] = u; varying[1] = v; varying[2] = light; } + + enum { NumVarying = 3 }; + float x, y, z, w; + float varying[NumVarying]; +}; + +class VSMatrix; +void R_DrawTriangles(const VSMatrix &objectToWorld, const TriVertex *vertices, int count, int clipleft, int clipright, const short *cliptop, const short *clipbottom); + extern bool r_swtruecolor; EXTERN_CVAR(Bool, r_multithreaded); diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index b07813166..9b15d06ce 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -1257,458 +1257,437 @@ void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) ///////////////////////////////////////////////////////////////////////////// -struct TriVertex +class DrawTrianglesCommand : public DrawerCommand { - TriVertex() { } - TriVertex(float x, float y, float z, float w, float u, float v, float light) : x(x), y(y), z(z), w(w) { varying[0] = u; varying[1] = v; varying[2] = light; } - - enum { NumVarying = 3 }; - float x, y, z, w; - float varying[NumVarying]; -}; - -float gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) -{ - float top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); - float bottom = (x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2); - return top / bottom; -} - -float grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) -{ - float top = (c1 - c2) * (x0 - x2) - (c0 - c2) * (x1 - x2); - float bottom = -((x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2)); - return top / bottom; -} - -void triangle(uint32_t *dest, int pitch, const TriVertex &v1, const TriVertex &v2, const TriVertex &v3, int clipleft, int clipright, const short *cliptop, const short *clipbottom) -{ - // 28.4 fixed-point coordinates - const int Y1 = (int)round(16.0f * v1.y); - const int Y2 = (int)round(16.0f * v2.y); - const int Y3 = (int)round(16.0f * v3.y); - - const int X1 = (int)round(16.0f * v1.x); - const int X2 = (int)round(16.0f * v2.x); - const int X3 = (int)round(16.0f * v3.x); - - // Deltas - const int DX12 = X1 - X2; - const int DX23 = X2 - X3; - const int DX31 = X3 - X1; - - const int DY12 = Y1 - Y2; - const int DY23 = Y2 - Y3; - const int DY31 = Y3 - Y1; - - // Fixed-point deltas - const int FDX12 = DX12 << 4; - const int FDX23 = DX23 << 4; - const int FDX31 = DX31 << 4; - - const int FDY12 = DY12 << 4; - const int FDY23 = DY23 << 4; - const int FDY31 = DY31 << 4; - - // Bounding rectangle - int clipymin = cliptop[clipleft]; - int clipymax = clipbottom[clipleft]; - for (int i = clipleft + 1; i <= clipright; i++) +public: + DrawTrianglesCommand(const VSMatrix &objectToWorld, const TriVertex *vertices, int count, int clipleft, int clipright, const short *clipdata) + : objectToWorld(objectToWorld), vertices(vertices), count(count), clipleft(clipleft), clipright(clipright), clipdata(clipdata) { - clipymin = MIN(clipymin, (int)cliptop[i]); - clipymax = MAX(clipymax, (int)clipbottom[i]); - } - int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); - int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright); - int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, clipymin); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipymax); - if (minx >= maxx || miny >= maxy) - return; - - // Block size, standard 8x8 (must be power of two) - const int q = 8; - - // Start in corner of 8x8 block - minx &= ~(q - 1); - miny &= ~(q - 1); - - dest += miny * pitch; - - // Half-edge constants - int C1 = DY12 * X1 - DX12 * Y1; - int C2 = DY23 * X2 - DX23 * Y2; - int C3 = DY31 * X3 - DX31 * Y3; - - // Correct for fill convention - if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; - if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; - if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; - - // Gradients - float gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - float gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - float startW = v1.w + gradWX * (minx - v1.x) + gradWY * (miny - v1.y); - float gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (minx - v1.x) + gradVaryingY[i] * (miny - v1.y); } - // Loop through blocks - for (int y = miny; y < maxy; y += q) + void Execute(DrawerThread *thread) override { - for (int x = minx; x < maxx; x += q) + int cliplength = clipright - clipleft + 1; + for (int i = 0; i < cliplength; i++) { - // Corners of block - int x0 = x << 4; - int x1 = (x + q - 1) << 4; - int y0 = y << 4; - int y1 = (y + q - 1) << 4; + thread->triangle_clip_top[clipleft + i] = clipdata[i]; + thread->triangle_clip_bottom[clipleft + i] = clipdata[cliplength + i]; + } - // Evaluate half-space functions - bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; - bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; - bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; - bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; - int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); + draw_triangles(objectToWorld, vertices, count, clipleft, clipright, thread->triangle_clip_top, thread->triangle_clip_bottom, thread); + } - bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; - bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; - bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; - bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; - int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); + FString DebugInfo() override + { + return "DrawTrianglesCommand"; + } - bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; - bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; - bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; - bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; - int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); +private: + float gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) + { + float top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); + float bottom = (x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2); + return top / bottom; + } - // Skip block when outside an edge - if (a == 0x0 || b == 0x0 || c == 0x0) continue; + float grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) + { + float top = (c1 - c2) * (x0 - x2) - (c0 - c2) * (x1 - x2); + float bottom = -((x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2)); + return top / bottom; + } - // Check if block needs clipping - int clipcount = 0; - for (int ix = 0; ix < q; ix++) + void triangle(uint32_t *dest, int pitch, const TriVertex &v1, const TriVertex &v2, const TriVertex &v3, int clipleft, int clipright, const short *cliptop, const short *clipbottom, DrawerThread *thread) + { + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int clipymin = cliptop[clipleft]; + int clipymax = clipbottom[clipleft]; + for (int i = clipleft + 1; i <= clipright; i++) + { + clipymin = MIN(clipymin, (int)cliptop[i]); + clipymax = MAX(clipymax, (int)clipbottom[i]); + } + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, clipymin); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipymax); + if (minx >= maxx || miny >= maxy) + return; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + dest += miny * pitch; + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // Gradients + float gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + float gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + float startW = v1.w + gradWX * (minx - v1.x) + gradWY * (miny - v1.y); + float gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (minx - v1.x) + gradVaryingY[i] * (miny - v1.y); + } + + // Loop through blocks + for (int y = miny; y < maxy; y += q) + { + for (int x = minx; x < maxx; x += q) { - clipcount += (cliptop[x + ix] > y) || (clipbottom[x + ix] < y + q - 1); - } + // Corners of block + int x0 = x << 4; + int x1 = (x + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; - // Calculate varying variables for affine block - float offx0 = (x - minx) + 0.5f; - float offy0 = (y - miny) + 0.5f; - float offx1 = offx0 + q; - float offy1 = offy0 + q; - float rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); - float rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); - float rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); - float rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); - float varyingTL[TriVertex::NumVarying]; - float varyingTR[TriVertex::NumVarying]; - float varyingBL[TriVertex::NumVarying]; - float varyingBR[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; - varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; - varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); - varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); - } + // Evaluate half-space functions + bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; + bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; + bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; + bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; + int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); - uint32_t *buffer = dest; + bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; + bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; + bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; + bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; + int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); - // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && clipcount == 0) - { - for (int iy = 0; iy < q; iy++) + bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; + bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; + bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; + bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; + int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + + // Skip block when outside an edge + if (a == 0x0 || b == 0x0 || c == 0x0) continue; + + // Check if block needs clipping + int clipcount = 0; + for (int ix = 0; ix < q; ix++) { - float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - varying[i] = varyingTL[i] + varyingBL[i] * iy; - varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); - } - - for (int ix = x; ix < x + q; ix++) - { - uint32_t red = (uint32_t)clamp(varying[0] * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t green = (uint32_t)clamp(varying[1] * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t blue = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); - - buffer[ix] = 0xff000000 | (red << 16) | (green << 8) | blue; - - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; - } - - buffer += pitch; + clipcount += (cliptop[x + ix] > y) || (clipbottom[x + ix] < y + q - 1); } - } - else // Partially covered block - { - int CY1 = C1 + DX12 * y0 - DY12 * x0; - int CY2 = C2 + DX23 * y0 - DY23 * x0; - int CY3 = C3 + DX31 * y0 - DY31 * x0; - for (int iy = 0; iy < q; iy++) + // Calculate varying variables for affine block + float offx0 = (x - minx) + 0.5f; + float offy0 = (y - miny) + 0.5f; + float offx1 = offx0 + q; + float offy1 = offy0 + q; + float rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); + float rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); + float rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); + float rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); + float varyingTL[TriVertex::NumVarying]; + float varyingTR[TriVertex::NumVarying]; + float varyingBL[TriVertex::NumVarying]; + float varyingBR[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) { - int CX1 = CY1; - int CX2 = CY2; - int CX3 = CY3; + varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; + varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; + varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); + varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); + } - float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) + uint32_t *buffer = dest; + + // Accept whole block when totally covered + if (a == 0xF && b == 0xF && c == 0xF && clipcount == 0) + { + for (int iy = 0; iy < q; iy++) { - varying[i] = varyingTL[i] + varyingBL[i] * iy; - varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); - } - - for (int ix = x; ix < x + q; ix++) - { - bool visible = (cliptop[ix] <= y + iy) && (clipbottom[ix] >= y + iy); - - if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) + float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) { - uint32_t red = (uint32_t)clamp(varying[0] * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t green = (uint32_t)clamp(varying[1] * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t blue = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); - - buffer[ix] = 0xff000000 | (red << 16) | (green << 8) | blue; + varying[i] = varyingTL[i] + varyingBL[i] * iy; + varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); } - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; + if (!thread->skipped_by_thread(y + iy)) + { + for (int ix = x; ix < x + q; ix++) + { + uint32_t red = (uint32_t)clamp(varying[0] * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t green = (uint32_t)clamp(varying[1] * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t blue = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); - CX1 -= FDY12; - CX2 -= FDY23; - CX3 -= FDY31; + buffer[ix] = 0xff000000 | (red << 16) | (green << 8) | blue; + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + } + } + + buffer += pitch; } + } + else // Partially covered block + { + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; - CY1 += FDX12; - CY2 += FDX23; - CY3 += FDX31; + for (int iy = 0; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; - buffer += pitch; + float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varying[i] = varyingTL[i] + varyingBL[i] * iy; + varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + } + + if (!thread->skipped_by_thread(y + iy)) + { + for (int ix = x; ix < x + q; ix++) + { + bool visible = (cliptop[ix] <= y + iy) && (clipbottom[ix] >= y + iy); + + if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) + { + uint32_t red = (uint32_t)clamp(varying[0] * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t green = (uint32_t)clamp(varying[1] * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t blue = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); + + buffer[ix] = 0xff000000 | (red << 16) | (green << 8) | blue; + } + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + + buffer += pitch; + } + } + } + + dest += q * pitch; + } + } + + bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2) + { + if (clipdistance1 < 0.0f && clipdistance2 < 0.0f) + return true; + + if (clipdistance1 < 0.0f) + t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), t1); + + if (clipdistance2 < 0.0f) + t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2); + + return false; + } + + void clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert) + { + // Clip and cull so that the following is true for all vertices: + // -v.w <= v.x <= v.w + // -v.w <= v.y <= v.w + // -v.w <= v.z <= v.w + + float t1 = 0.0f, t2 = 1.0f; + bool culled = + cullhalfspace(v1.x + v1.w, v2.x + v2.w, t1, t2) || + cullhalfspace(v1.w - v1.x, v2.w - v2.x, t1, t2) || + cullhalfspace(v1.y + v1.w, v2.y + v2.w, t1, t2) || + cullhalfspace(v1.w - v1.y, v2.w - v2.y, t1, t2) || + cullhalfspace(v1.z + v1.w, v2.z + v2.w, t1, t2) || + cullhalfspace(v1.w - v1.z, v2.w - v2.z, t1, t2); + if (culled) + return; + + if (t1 == 0.0f) + { + clippedvert[numclipvert++] = v1; + } + else + { + auto &v = clippedvert[numclipvert++]; + v.x = v1.x * (1.0f - t1) + v2.x * t1; + v.y = v1.y * (1.0f - t1) + v2.y * t1; + v.z = v1.z * (1.0f - t1) + v2.z * t1; + v.w = v1.w * (1.0f - t1) + v2.w * t1; + for (int i = 0; i < TriVertex::NumVarying; i++) + v.varying[i] = v1.varying[i] * (1.0f - t1) + v2.varying[i] * t1; + } + + if (t2 != 1.0f) + { + auto &v = clippedvert[numclipvert++]; + v.x = v1.x * (1.0f - t2) + v2.x * t2; + v.y = v1.y * (1.0f - t2) + v2.y * t2; + v.z = v1.z * (1.0f - t2) + v2.z * t2; + v.w = v1.w * (1.0f - t2) + v2.w * t2; + for (int i = 0; i < TriVertex::NumVarying; i++) + v.varying[i] = v1.varying[i] * (1.0f - t2) + v2.varying[i] * t2; + } + } + + void draw_triangles(const VSMatrix &objectToWorld, const TriVertex *vinput, int vcount, int clipleft, int clipright, const short *cliptop, const short *clipbottom, DrawerThread *thread) + { + for (int i = 0; i < vcount / 3; i++) + { + TriVertex vert[3]; + + // Vertex shader stuff: + for (int j = 0; j < 3; j++) + { + auto &v = vert[j]; + v = *(vinput++); + + // Apply object to world transform: + const float *matrix = objectToWorld.get(); + float vx = matrix[0 * 4 + 0] * v.x + matrix[1 * 4 + 0] * v.y + matrix[2 * 4 + 0] * v.z + matrix[3 * 4 + 0] * v.w; + float vy = matrix[0 * 4 + 1] * v.x + matrix[1 * 4 + 1] * v.y + matrix[2 * 4 + 1] * v.z + matrix[3 * 4 + 1] * v.w; + float vz = matrix[0 * 4 + 2] * v.x + matrix[1 * 4 + 2] * v.y + matrix[2 * 4 + 2] * v.z + matrix[3 * 4 + 2] * v.w; + float vw = matrix[0 * 4 + 3] * v.x + matrix[1 * 4 + 3] * v.y + matrix[2 * 4 + 3] * v.z + matrix[3 * 4 + 3] * v.w; + v.x = vx; + v.y = vy; + v.z = vz; + v.w = vw; + + // The software renderer world to clip transform: + double nearp = 5.0f; + double farp = 65536.f; + double tr_x = v.x - ViewPos.X; + double tr_y = v.y - ViewPos.Y; + double tr_z = v.z - ViewPos.Z; + double tx = tr_x * ViewSin - tr_y * ViewCos; + double tz = tr_x * ViewTanCos + tr_y * ViewTanSin; + v.x = (float)tx; + v.y = (float)tr_z; + v.z = (float)(-tz * (farp + nearp) / (nearp - farp) + (2.0f * farp * nearp) / (nearp - farp)); + v.w = (float)tz; + } + + // Cull, clip and generate additional vertices as needed + TriVertex clippedvert[6]; + int numclipvert = 0; + clipedge(vert[0], vert[1], clippedvert, numclipvert); + clipedge(vert[1], vert[2], clippedvert, numclipvert); + clipedge(vert[2], vert[0], clippedvert, numclipvert); + + // Map to 2D viewport: + for (int j = 0; j < numclipvert; j++) + { + auto &v = clippedvert[j]; + + // Calculate normalized device coordinates: + v.w = 1.0f / v.w; + v.x *= v.w; + v.y *= v.w; + v.z *= v.w; + + // Apply viewport scale to get screen coordinates: + v.x = (float)(CenterX + v.x * CenterX); + v.y = (float)(CenterY - v.y * InvZtoScale); + } + + // Draw screen triangles + bool ccw = false; + if (ccw) + { + for (int i = numclipvert; i > 1; i--) + { + triangle((uint32_t*)dc_destorg, dc_pitch, clippedvert[numclipvert - 1], clippedvert[i - 1], clippedvert[i - 2], clipleft, clipright, cliptop, clipbottom, thread); + } + } + else + { + for (int i = 2; i < numclipvert; i++) + { + triangle((uint32_t*)dc_destorg, dc_pitch, clippedvert[0], clippedvert[i - 1], clippedvert[i], clipleft, clipright, cliptop, clipbottom, thread); } } } - - dest += q * pitch; } -} -bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2) + VSMatrix objectToWorld; + const TriVertex *vertices; + int count; + int clipleft; + int clipright; + const short *clipdata; +}; + +void R_DrawTriangles(const VSMatrix &objectToWorld, const TriVertex *vertices, int count, int clipleft, int clipright, const short *cliptop, const short *clipbottom) { - if (clipdistance1 < 0.0f && clipdistance2 < 0.0f) - return true; - - if (clipdistance1 < 0.0f) - t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), t1); - - if (clipdistance2 < 0.0f) - t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2); - - return false; -} - -void clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert) -{ - // Clip and cull so that the following is true for all vertices: - // -v.w <= v.x <= v.w - // -v.w <= v.y <= v.w - // -v.w <= v.z <= v.w - - float t1 = 0.0f, t2 = 1.0f; - bool culled = - cullhalfspace(v1.x + v1.w, v2.x + v2.w, t1, t2) || - cullhalfspace(v1.w - v1.x, v2.w - v2.x, t1, t2) || - cullhalfspace(v1.y + v1.w, v2.y + v2.w, t1, t2) || - cullhalfspace(v1.w - v1.y, v2.w - v2.y, t1, t2) || - cullhalfspace(v1.z + v1.w, v2.z + v2.w, t1, t2) || - cullhalfspace(v1.w - v1.z, v2.w - v2.z, t1, t2); - if (culled) + if (clipright < clipleft || clipleft < 0 || clipright > MAXWIDTH) return; - if (t1 == 0.0f) + int cliplength = clipright - clipleft + 1; + short *clipdata = (short*)DrawerCommandQueue::AllocMemory(cliplength * 2 * sizeof(short)); + if (!clipdata) { - clippedvert[numclipvert++] = v1; - } - else - { - auto &v = clippedvert[numclipvert++]; - v.x = v1.x * (1.0f - t1) + v2.x * t1; - v.y = v1.y * (1.0f - t1) + v2.y * t1; - v.z = v1.z * (1.0f - t1) + v2.z * t1; - v.w = v1.w * (1.0f - t1) + v2.w * t1; - for (int i = 0; i < TriVertex::NumVarying; i++) - v.varying[i] = v1.varying[i] * (1.0f - t1) + v2.varying[i] * t1; + DrawerCommandQueue::WaitForWorkers(); + clipdata = (short*)DrawerCommandQueue::AllocMemory(cliplength * 2 * sizeof(short)); + if (!clipdata) + return; } - if (t2 != 1.0f) - { - auto &v = clippedvert[numclipvert++]; - v.x = v1.x * (1.0f - t2) + v2.x * t2; - v.y = v1.y * (1.0f - t2) + v2.y * t2; - v.z = v1.z * (1.0f - t2) + v2.z * t2; - v.w = v1.w * (1.0f - t2) + v2.w * t2; - for (int i = 0; i < TriVertex::NumVarying; i++) - v.varying[i] = v1.varying[i] * (1.0f - t2) + v2.varying[i] * t2; - } -} + for (int i = 0; i < cliplength; i++) + clipdata[i] = cliptop[clipleft + i]; + for (int i = 0; i < cliplength; i++) + clipdata[cliplength + i] = clipbottom[clipleft + i]; -void R_DrawTriangle() -{ - int clipleft = 0; - int clipright = viewwidth - 1; - short cliptop[MAXWIDTH]; - short clipbottom[MAXWIDTH]; - for (int i = clipleft; i < clipright; i++) - { - cliptop[i] = (i - clipleft) / 4; - clipbottom[i] = viewheight - 1 - (i - clipleft) / 4; - } - - TriVertex cube[6 * 6] = - { - {-1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - - { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - {-1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - {-1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - - - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - {-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - - {-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - {-1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - - - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - {-1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - - {-1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - {-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - - - {-1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - {-1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - {-1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - - - { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - - - {-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - {-1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - {-1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - - {-1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - {-1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - {-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f } - }; - - for (int i = 0; i < 6; i++) - { - cube[i * 6 + 0].varying[0] = 1.0f; - cube[i * 6 + 1].varying[1] = 1.0f; - cube[i * 6 + 2].varying[2] = 1.0f; - cube[i * 6 + 3].varying[2] = 1.0f; - cube[i * 6 + 4].varying[0] = 1.0f; - cube[i * 6 + 4].varying[1] = 1.0f; - cube[i * 6 + 4].varying[2] = 1.0f; - cube[i * 6 + 5].varying[0] = 1.0f; - } - - static float angle = 0.0f; - angle = fmod(angle + 0.5f, 360.0f); - VSMatrix objectToWorld(0); - objectToWorld.translate((float)ViewPos.X, (float)ViewPos.Y + 50.0f, (float)ViewPos.Z); - objectToWorld.rotate(angle, 0.57735f, 0.57735f, 0.57735f); - objectToWorld.scale(10.0f, 10.0f, 10.0f); - - TriVertex *vinput = cube; - for (int i = 0; i < 6 * 6 / 3; i++) - { - TriVertex vert[3]; - - // Vertex shader stuff: - for (int j = 0; j < 3; j++) - { - auto &v = vert[j]; - v = *(vinput++); - - // Apply object to world transform: - const float *matrix = objectToWorld.get(); - float vx = matrix[0 * 4 + 0] * v.x + matrix[1 * 4 + 0] * v.y + matrix[2 * 4 + 0] * v.z + matrix[3 * 4 + 0] * v.w; - float vy = matrix[0 * 4 + 1] * v.x + matrix[1 * 4 + 1] * v.y + matrix[2 * 4 + 1] * v.z + matrix[3 * 4 + 1] * v.w; - float vz = matrix[0 * 4 + 2] * v.x + matrix[1 * 4 + 2] * v.y + matrix[2 * 4 + 2] * v.z + matrix[3 * 4 + 2] * v.w; - float vw = matrix[0 * 4 + 3] * v.x + matrix[1 * 4 + 3] * v.y + matrix[2 * 4 + 3] * v.z + matrix[3 * 4 + 3] * v.w; - v.x = vx; - v.y = vy; - v.z = vz; - v.w = vw; - - // The software renderer world to clip transform: - double nearp = 5.0f; - double farp = 65536.f; - double tr_x = v.x - ViewPos.X; - double tr_y = v.y - ViewPos.Y; - double tr_z = v.z - ViewPos.Z; - double tx = tr_x * ViewSin - tr_y * ViewCos; - double tz = tr_x * ViewTanCos + tr_y * ViewTanSin; - v.x = (float)tx; - v.y = (float)tr_z; - v.z = (float)(-tz * (farp + nearp) / (nearp - farp) + (2.0f * farp * nearp) / (nearp - farp)); - v.w = (float)tz; - } - - // Cull, clip and generate additional vertices as needed - TriVertex clippedvert[6]; - int numclipvert = 0; - clipedge(vert[0], vert[1], clippedvert, numclipvert); - clipedge(vert[1], vert[2], clippedvert, numclipvert); - clipedge(vert[2], vert[0], clippedvert, numclipvert); - - // Map to 2D viewport: - for (int j = 0; j < numclipvert; j++) - { - auto &v = clippedvert[j]; - - // Calculate normalized device coordinates: - v.w = 1.0f / v.w; - v.x *= v.w; - v.y *= v.w; - v.z *= v.w; - - // Apply viewport scale to get screen coordinates: - v.x = (float)(CenterX + v.x * CenterX); - v.y = (float)(CenterY - v.y * InvZtoScale); - } - - for (int i = numclipvert; i > 1; i--) - { - triangle((uint32_t*)dc_destorg, dc_pitch, clippedvert[numclipvert - 1], clippedvert[i - 1], clippedvert[i - 2], clipleft, clipright, cliptop, clipbottom); - } - } + DrawerCommandQueue::QueueCommand(objectToWorld, vertices, count, clipleft, clipright, clipdata); } ///////////////////////////////////////////////////////////////////////////// diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 5dea6a03a..b8cda2fcb 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -59,12 +59,14 @@ #include "v_palette.h" #include "r_data/colormaps.h" #include "r_draw_rgba.h" +#include "gl/data/gl_matrix.h" #ifdef _MSC_VER #pragma warning(disable:4244) #endif CVAR(Bool, r_capsky, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR(Bool, r_cubesky, false, 0) //EXTERN_CVAR (Int, tx) //EXTERN_CVAR (Int, ty) @@ -1154,9 +1156,104 @@ static void R_DrawCapSky(visplane_t *pl) } } +static void R_DrawCubeSky(visplane_t *pl) +{ + int x1 = pl->left; + int x2 = pl->right; + short *uwal = (short *)pl->top; + short *dwal = (short *)pl->bottom; + + static TriVertex cube[6 * 6] = + { + { -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + { -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + + { -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + + { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + + { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + + { -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f } + }; + + static bool first_time = true; + if (first_time) + { + for (int i = 0; i < 6; i++) + { + cube[i * 6 + 0].varying[0] = 1.0f; + cube[i * 6 + 1].varying[1] = 1.0f; + cube[i * 6 + 2].varying[2] = 1.0f; + cube[i * 6 + 3].varying[2] = 1.0f; + cube[i * 6 + 4].varying[0] = 1.0f; + cube[i * 6 + 4].varying[1] = 1.0f; + cube[i * 6 + 4].varying[2] = 1.0f; + cube[i * 6 + 5].varying[0] = 1.0f; + } + first_time = false; + } + + //static float angle = 0.0f; + //angle = fmod(angle + 0.5f, 360.0f); + VSMatrix objectToWorld(0); + objectToWorld.translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); + //objectToWorld.rotate(angle, 0.57735f, 0.57735f, 0.57735f); + objectToWorld.scale(100.0f, 100.0f, 100.0f); + + R_DrawTriangles(objectToWorld, cube, 6 * 6, x1, x2 - 1, uwal, dwal); +} + static void R_DrawSky (visplane_t *pl) { - if (r_swtruecolor && r_capsky) + if (r_swtruecolor && r_cubesky) + { + R_DrawCubeSky(pl); + return; + } + else if (r_swtruecolor && r_capsky) { R_DrawCapSky(pl); return; diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 49eb0ef27..372f23acc 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -47,13 +47,10 @@ EXTERN_CVAR(Bool, r_shadercolormaps) -CVAR(Bool, r_drawtriangle, false, 0) - void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio); void R_SetupColormap(player_t *); void R_SetupFreelook(); void R_InitRenderer(); -void R_DrawTriangle(); FSoftwareRenderer::FSoftwareRenderer() { @@ -195,8 +192,6 @@ void FSoftwareRenderer::RenderView(player_t *player) } R_EndDrawerCommands(); - if (r_swtruecolor && r_drawtriangle) - R_DrawTriangle(); } //========================================================================== diff --git a/src/r_thread.h b/src/r_thread.h index 63c442442..a2cc8b973 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -36,6 +36,9 @@ public: uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT * 4]; uint32_t *dc_temp_rgba; + short triangle_clip_top[MAXWIDTH]; + short triangle_clip_bottom[MAXWIDTH]; + // Checks if a line is rendered by this thread bool line_skipped_by_thread(int line) { From 4ccb69fa614ebb9a276a4e093022de44db31466c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 19 Oct 2016 23:21:09 +0200 Subject: [PATCH 1113/1509] Palette version of sky drawers --- src/r_draw.cpp | 240 ++++++++++++++++++++++++++++++++++++++++++++ src/r_draw.h | 5 + src/r_draw_rgba.cpp | 8 +- src/r_plane.cpp | 47 +++++++-- 4 files changed, 285 insertions(+), 15 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 9d7160d01..45758ee61 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -2235,6 +2235,246 @@ void tmvline4_revsubclamp_C () } while (--count); } +void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) +{ + uint8_t *dest = dc_dest; + int count = dc_count; + int pitch = dc_pitch; + const uint8_t *source0 = bufplce[0]; + int textureheight0 = bufheight[0]; + + int32_t frac = vplce[0]; + int32_t fracstep = vince[0]; + + int start_fade = 2; // How fast it should fade out + + int solid_top_r = RPART(solid_top); + int solid_top_g = GPART(solid_top); + int solid_top_b = BPART(solid_top); + int solid_bottom_r = RPART(solid_bottom); + int solid_bottom_g = GPART(solid_bottom); + int solid_bottom_b = BPART(solid_bottom); + + for (int index = 0; index < count; index++) + { + uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; + uint8_t fg = source0[sample_index]; + + int alpha_top = MAX(MIN(frac >> (16 - start_fade), 256), 0); + int alpha_bottom = MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0); + + if (alpha_top == 256 && alpha_bottom == 256) + { + *dest = fg; + } + else + { + int inv_alpha_top = 256 - alpha_top; + int inv_alpha_bottom = 256 - alpha_bottom; + + const auto &c = GPalette.BaseColors[fg]; + int c_red = c.r; + int c_green = c.g; + int c_blue = c.b; + c_red = (c_red * alpha_top + solid_top_r * inv_alpha_top) >> 8; + c_green = (c_green * alpha_top + solid_top_g * inv_alpha_top) >> 8; + c_blue = (c_blue * alpha_top + solid_top_b * inv_alpha_top) >> 8; + c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; + c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; + c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; + *dest = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + } + + frac += fracstep; + dest += pitch; + } +} + +void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom) +{ + for (int col = 0; col < 4; col++) + { + uint8_t *dest = dc_dest + col; + int count = dc_count; + int pitch = dc_pitch; + const uint8_t *source0 = bufplce[col]; + int textureheight0 = bufheight[0]; + + int32_t frac = vplce[col]; + int32_t fracstep = vince[col]; + + int start_fade = 2; // How fast it should fade out + + int solid_top_r = RPART(solid_top); + int solid_top_g = GPART(solid_top); + int solid_top_b = BPART(solid_top); + int solid_bottom_r = RPART(solid_bottom); + int solid_bottom_g = GPART(solid_bottom); + int solid_bottom_b = BPART(solid_bottom); + + for (int index = 0; index < count; index++) + { + uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; + uint8_t fg = source0[sample_index]; + + int alpha_top = MAX(MIN(frac >> (16 - start_fade), 256), 0); + int alpha_bottom = MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0); + + if (alpha_top == 256 && alpha_bottom == 256) + { + *dest = fg; + } + else + { + int inv_alpha_top = 256 - alpha_top; + int inv_alpha_bottom = 256 - alpha_bottom; + + const auto &c = GPalette.BaseColors[fg]; + int c_red = c.r; + int c_green = c.g; + int c_blue = c.b; + c_red = (c_red * alpha_top + solid_top_r * inv_alpha_top) >> 8; + c_green = (c_green * alpha_top + solid_top_g * inv_alpha_top) >> 8; + c_blue = (c_blue * alpha_top + solid_top_b * inv_alpha_top) >> 8; + c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; + c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; + c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; + *dest = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + } + + frac += fracstep; + dest += pitch; + } + } +} + +void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) +{ + uint8_t *dest = dc_dest; + int count = dc_count; + int pitch = dc_pitch; + const uint8_t *source0 = bufplce[0]; + const uint8_t *source1 = bufplce2[0]; + int textureheight0 = bufheight[0]; + uint32_t maxtextureheight1 = bufheight[1] - 1; + + int32_t frac = vplce[0]; + int32_t fracstep = vince[0]; + + int start_fade = 2; // How fast it should fade out + + int solid_top_r = RPART(solid_top); + int solid_top_g = GPART(solid_top); + int solid_top_b = BPART(solid_top); + int solid_bottom_r = RPART(solid_bottom); + int solid_bottom_g = GPART(solid_bottom); + int solid_bottom_b = BPART(solid_bottom); + + for (int index = 0; index < count; index++) + { + uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; + uint8_t fg = source0[sample_index]; + if (fg == 0) + { + uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + fg = source1[sample_index2]; + } + + int alpha_top = MAX(MIN(frac >> (16 - start_fade), 256), 0); + int alpha_bottom = MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0); + + if (alpha_top == 256 && alpha_bottom == 256) + { + *dest = fg; + } + else + { + int inv_alpha_top = 256 - alpha_top; + int inv_alpha_bottom = 256 - alpha_bottom; + + const auto &c = GPalette.BaseColors[fg]; + int c_red = c.r; + int c_green = c.g; + int c_blue = c.b; + c_red = (c_red * alpha_top + solid_top_r * inv_alpha_top) >> 8; + c_green = (c_green * alpha_top + solid_top_g * inv_alpha_top) >> 8; + c_blue = (c_blue * alpha_top + solid_top_b * inv_alpha_top) >> 8; + c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; + c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; + c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; + *dest = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + } + + frac += fracstep; + dest += pitch; + } +} + +void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom) +{ + for (int col = 0; col < 4; col++) + { + uint8_t *dest = dc_dest + col; + int count = dc_count; + int pitch = dc_pitch; + const uint8_t *source0 = bufplce[col]; + const uint8_t *source1 = bufplce2[col]; + int textureheight0 = bufheight[0]; + uint32_t maxtextureheight1 = bufheight[1] - 1; + + int32_t frac = vplce[col]; + int32_t fracstep = vince[col]; + + int start_fade = 2; // How fast it should fade out + + int solid_top_r = RPART(solid_top); + int solid_top_g = GPART(solid_top); + int solid_top_b = BPART(solid_top); + int solid_bottom_r = RPART(solid_bottom); + int solid_bottom_g = GPART(solid_bottom); + int solid_bottom_b = BPART(solid_bottom); + + for (int index = 0; index < count; index++) + { + uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; + uint8_t fg = source0[sample_index]; + if (fg == 0) + { + uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + fg = source1[sample_index2]; + } + + int alpha_top = MAX(MIN(frac >> (16 - start_fade), 256), 0); + int alpha_bottom = MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0); + + if (alpha_top == 256 && alpha_bottom == 256) + { + *dest = fg; + } + else + { + int inv_alpha_top = 256 - alpha_top; + int inv_alpha_bottom = 256 - alpha_bottom; + + const auto &c = GPalette.BaseColors[fg]; + int c_red = c.r; + int c_green = c.g; + int c_blue = c.b; + c_red = (c_red * alpha_top + solid_top_r * inv_alpha_top) >> 8; + c_green = (c_green * alpha_top + solid_top_g * inv_alpha_top) >> 8; + c_blue = (c_blue * alpha_top + solid_top_b * inv_alpha_top) >> 8; + c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; + c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; + c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; + *dest = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + } + + frac += fracstep; + dest += pitch; + } + } +} + //========================================================================== // // R_GetColumn diff --git a/src/r_draw.h b/src/r_draw.h index 7b12c43bb..601962809 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -387,6 +387,11 @@ void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom); void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); +void R_DrawSingleSkyCol1_rgba(uint32_t solid_top, uint32_t solid_bottom); +void R_DrawSingleSkyCol4_rgba(uint32_t solid_top, uint32_t solid_bottom); +void R_DrawDoubleSkyCol1_rgba(uint32_t solid_top, uint32_t solid_bottom); +void R_DrawDoubleSkyCol4_rgba(uint32_t solid_top, uint32_t solid_bottom); + struct TriVertex { TriVertex() { } diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 9b15d06ce..2b9eb86e7 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -1692,22 +1692,22 @@ void R_DrawTriangles(const VSMatrix &objectToWorld, const TriVertex *vertices, i ///////////////////////////////////////////////////////////////////////////// -void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) +void R_DrawSingleSkyCol1_rgba(uint32_t solid_top, uint32_t solid_bottom) { DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); } -void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom) +void R_DrawSingleSkyCol4_rgba(uint32_t solid_top, uint32_t solid_bottom) { DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); } -void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) +void R_DrawDoubleSkyCol1_rgba(uint32_t solid_top, uint32_t solid_bottom) { DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); } -void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom) +void R_DrawDoubleSkyCol4_rgba(uint32_t solid_top, uint32_t solid_bottom) { DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); } diff --git a/src/r_plane.cpp b/src/r_plane.cpp index b8cda2fcb..e8fc31ec1 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1020,30 +1020,55 @@ static void R_DrawSkyColumnStripe(int start_x, int y1, int y2, int columns, doub angle1 = (DWORD)((UMulScale16(ang, frontcyl) + frontpos) >> FRACBITS); angle2 = (DWORD)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS); - bufplce[i] = (const BYTE *)frontskytex->GetColumnBgra(angle1, nullptr); - bufplce2[i] = backskytex ? (const BYTE *)backskytex->GetColumnBgra(angle2, nullptr) : nullptr; + if (r_swtruecolor) + { + bufplce[i] = (const BYTE *)frontskytex->GetColumnBgra(angle1, nullptr); + bufplce2[i] = backskytex ? (const BYTE *)backskytex->GetColumnBgra(angle2, nullptr) : nullptr; + } + else + { + bufplce[i] = (const BYTE *)frontskytex->GetColumn(angle1, nullptr); + bufplce2[i] = backskytex ? (const BYTE *)backskytex->GetColumn(angle2, nullptr) : nullptr; + } vince[i] = uv_step; vplce[i] = uv_pos; } bufheight[0] = height; bufheight[1] = backskytex ? backskytex->GetHeight() : height; - dc_dest = (ylookup[y1] + start_x) * 4 + dc_destorg; + int pixelsize = r_swtruecolor ? 4 : 1; + dc_dest = (ylookup[y1] + start_x) * pixelsize + dc_destorg; dc_count = y2 - y1; uint32_t solid_top = frontskytex->GetSkyCapColor(false); uint32_t solid_bottom = frontskytex->GetSkyCapColor(true); - if (columns == 4) - if (!backskytex) - R_DrawSingleSkyCol4(solid_top, solid_bottom); + if (r_swtruecolor) + { + if (columns == 4) + if (!backskytex) + R_DrawSingleSkyCol4_rgba(solid_top, solid_bottom); + else + R_DrawDoubleSkyCol4_rgba(solid_top, solid_bottom); else - R_DrawDoubleSkyCol4(solid_top, solid_bottom); + if (!backskytex) + R_DrawSingleSkyCol1_rgba(solid_top, solid_bottom); + else + R_DrawDoubleSkyCol1_rgba(solid_top, solid_bottom); + } else - if (!backskytex) - R_DrawSingleSkyCol1(solid_top, solid_bottom); + { + if (columns == 4) + if (!backskytex) + R_DrawSingleSkyCol4(solid_top, solid_bottom); + else + R_DrawDoubleSkyCol4(solid_top, solid_bottom); else - R_DrawDoubleSkyCol1(solid_top, solid_bottom); + if (!backskytex) + R_DrawSingleSkyCol1(solid_top, solid_bottom); + else + R_DrawDoubleSkyCol1(solid_top, solid_bottom); + } } static void R_DrawSkyColumn(int start_x, int y1, int y2, int columns) @@ -1253,7 +1278,7 @@ static void R_DrawSky (visplane_t *pl) R_DrawCubeSky(pl); return; } - else if (r_swtruecolor && r_capsky) + else if (r_capsky) { R_DrawCapSky(pl); return; From 96437d95fa62e0694e1c8bf4e289df0d0f320523 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 20 Oct 2016 10:36:23 +0200 Subject: [PATCH 1114/1509] - use the new ZDoom code for retrieving a sky's cap color to avoid redundancies. --- src/gl/textures/gl_texture.cpp | 37 +--------------------------------- src/gl/textures/gl_texture.h | 1 - src/textures/textures.h | 4 ---- 3 files changed, 1 insertion(+), 41 deletions(-) diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index ce6ff398c..8aaa98ae6 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -167,7 +167,7 @@ void gl_GenerateGlobalBrightmapFromColormap() // component becomes one. // //=========================================================================== -PalEntry averageColor(const DWORD *data, int size, int maxout) +static PalEntry averageColor(const DWORD *data, int size, int maxout) { int i; unsigned int r, g, b; @@ -216,10 +216,7 @@ FTexture::MiscGLInfo::MiscGLInfo() throw() GlowColor = 0; GlowHeight = 128; bSkybox = false; - FloorSkyColor = 0; - CeilingSkyColor = 0; bFullbright = false; - bSkyColorDone = false; bBrightmapChecked = false; bDisableFullbright = false; bNoFilter = false; @@ -326,38 +323,6 @@ void FTexture::GetGlowColor(float *data) data[2]=gl_info.GlowColor.b/255.0f; } -//=========================================================================== -// -// Gets the average color of a texture for use as a sky cap color -// -//=========================================================================== - -PalEntry FTexture::GetSkyCapColor(bool bottom) -{ - PalEntry col; - int w; - int h; - - if (!gl_info.bSkyColorDone) - { - gl_info.bSkyColorDone = true; - - unsigned char *buffer = GLRenderer->GetTextureBuffer(this, w, h); - - if (buffer) - { - gl_info.CeilingSkyColor = averageColor((DWORD *) buffer, w * MIN(30, h), 0); - if (h>30) - { - gl_info.FloorSkyColor = averageColor(((DWORD *) buffer)+(h-30)*w, w * 30, 0); - } - else gl_info.FloorSkyColor = gl_info.CeilingSkyColor; - delete[] buffer; - } - } - return bottom? gl_info.FloorSkyColor : gl_info.CeilingSkyColor; -} - //=========================================================================== // // Finds gaps in the texture which can be skipped by the renderer diff --git a/src/gl/textures/gl_texture.h b/src/gl/textures/gl_texture.h index 9ee9b27f9..455678f85 100644 --- a/src/gl/textures/gl_texture.h +++ b/src/gl/textures/gl_texture.h @@ -24,7 +24,6 @@ protected: void gl_GenerateGlobalBrightmapFromColormap(); -PalEntry averageColor(const DWORD *data, int size, int maxout); diff --git a/src/textures/textures.h b/src/textures/textures.h index 518787dc0..cc5bba389 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -307,8 +307,6 @@ public: FGLTexture *SystemTexture[2]; FTexture *Brightmap; PalEntry GlowColor; - PalEntry FloorSkyColor; - PalEntry CeilingSkyColor; int GlowHeight; FloatRect *areas; int areacount; @@ -318,7 +316,6 @@ public: bool bGlowing:1; // Texture glows bool bFullbright:1; // always draw fullbright bool bSkybox:1; // This is a skybox - bool bSkyColorDone:1; // Fill color for sky char bBrightmapChecked:1; // Set to 1 if brightmap has been checked bool bDisableFullbright:1; // This texture will not be displayed as fullbright sprite bool bNoFilter:1; @@ -331,7 +328,6 @@ public: MiscGLInfo gl_info; void GetGlowColor(float *data); - PalEntry GetSkyCapColor(bool bottom); bool isGlowing() { return gl_info.bGlowing; } bool isFullbright() { return gl_info.bFullbright; } void CreateDefaultBrightmap(); From 1c2dcad36e6b2d568225884f46f3257b820a73da Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 20 Oct 2016 15:16:02 +0200 Subject: [PATCH 1115/1509] Fix linear skies --- src/r_plane.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index be8247d26..3ba6feaf7 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1098,7 +1098,15 @@ static void R_DrawSkyColumnStripe(int start_x, int y1, int y2, int columns, doub DWORD ang, angle1, angle2; - ang = (skyangle + xtoviewangle[x]) ^ skyflip; + if (r_linearsky) + { + angle_t xangle = (angle_t)((0.5 - x / (double)viewwidth) * FocalTangent * ANGLE_90); + ang = (skyangle + xangle) ^ skyflip; + } + else + { + ang = (skyangle + xtoviewangle[x]) ^ skyflip; + } angle1 = (DWORD)((UMulScale16(ang, frontcyl) + frontpos) >> FRACBITS); angle2 = (DWORD)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS); From 1cd27ca98a01bf9737c721750ffc4b0070aca848 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 20 Oct 2016 21:57:45 +0200 Subject: [PATCH 1116/1509] Change how the LLVM execution engine to constructed and printf which target triple and CPU is being used --- src/r_compiler/llvmdrawers.cpp | 64 +++++++++++++++------------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index d5078a6c0..c936d6260 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -446,10 +446,18 @@ LLVMProgram::LLVMProgram() InitializeNativeTarget(); InitializeNativeTargetAsmPrinter(); + mContext = std::make_unique(); + mModule = std::make_unique("render", context()); +} + +void LLVMProgram::CreateEE() +{ + using namespace llvm; + std::string errorstring; +#if 0 std::string targetTriple = sys::getProcessTriple(); - std::string cpuName = sys::getHostCPUName(); StringMap cpuFeatures; sys::getHostCPUFeatures(cpuFeatures); std::string cpuFeaturesStr; @@ -461,40 +469,32 @@ LLVMProgram::LLVMProgram() cpuFeaturesStr += it.getKey(); } - DPrintf(DMSG_SPAMMY, "LLVM target triple: %s\n", targetTriple.c_str()); - DPrintf(DMSG_SPAMMY, "LLVM CPU and features: %s, %s\n", cpuName.c_str(), cpuFeaturesStr.c_str()); - - const Target *target = TargetRegistry::lookupTarget(targetTriple, errorstring); - if (!target) - I_FatalError("Could not find LLVM target: %s", errorstring.c_str()); - - TargetOptions opt; -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) - Reloc::Model relocModel = Reloc::Default; -#else - auto relocModel = Optional(); + Printf("LLVM CPU features: %s\n", cpuFeaturesStr.c_str()); #endif - machine = target->createTargetMachine(targetTriple, cpuName, cpuFeaturesStr, opt, relocModel, CodeModel::JITDefault, CodeGenOpt::Aggressive); + + llvm::Module *module = mModule.get(); + EngineBuilder engineBuilder(std::move(mModule)); + engineBuilder.setErrorStr(&errorstring); + engineBuilder.setOptLevel(CodeGenOpt::Aggressive); + engineBuilder.setEngineKind(EngineKind::JIT); + engineBuilder.setMCPU(sys::getHostCPUName()); + machine = engineBuilder.selectTarget(); if (!machine) I_FatalError("Could not create LLVM target machine"); - mContext = std::make_unique(); + std::string targetTriple = machine->getTargetTriple().getTriple(); + std::string cpuName = machine->getTargetCPU(); + Printf("LLVM target triple: %s\n", targetTriple.c_str()); + Printf("LLVM target CPU: %s\n", cpuName.c_str()); - mModule = std::make_unique("render", context()); - mModule->setTargetTriple(targetTriple); + module->setTargetTriple(targetTriple); #if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - mModule->setDataLayout(new DataLayout(*machine->getSubtargetImpl()->getDataLayout())); + module->setDataLayout(new DataLayout(*machine->getSubtargetImpl()->getDataLayout())); #else - mModule->setDataLayout(machine->createDataLayout()); + module->setDataLayout(machine->createDataLayout()); #endif -} - -void LLVMProgram::CreateEE() -{ - using namespace llvm; - - legacy::FunctionPassManager PerFunctionPasses(mModule.get()); + legacy::FunctionPassManager PerFunctionPasses(module); legacy::PassManager PerModulePasses; #if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8) @@ -514,7 +514,7 @@ void LLVMProgram::CreateEE() // Run function passes: PerFunctionPasses.doInitialization(); - for (llvm::Function &func : *mModule.get()) + for (llvm::Function &func : *module) { if (!func.isDeclaration()) PerFunctionPasses.run(func); @@ -522,15 +522,9 @@ void LLVMProgram::CreateEE() PerFunctionPasses.doFinalization(); // Run module passes: - PerModulePasses.run(*mModule.get()); + PerModulePasses.run(*module); - std::string errorstring; - - EngineBuilder engineBuilder(std::move(mModule)); - engineBuilder.setErrorStr(&errorstring); - engineBuilder.setOptLevel(CodeGenOpt::Aggressive); - engineBuilder.setRelocationModel(Reloc::Static); - engineBuilder.setEngineKind(EngineKind::JIT); + // Create execution engine and generate machine code mEngine.reset(engineBuilder.create(machine)); if (!mEngine) I_FatalError("Could not create LLVM execution engine: %s", errorstring.c_str()); From b327a3312e021a186f6396f3eb0701b455a15375 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Wed, 19 Oct 2016 02:02:37 -0400 Subject: [PATCH 1117/1509] - Fully Implemented GZDoom fullbright emulation --- src/r_bsp.cpp | 5 +++-- src/r_data/colormaps.cpp | 4 ++++ src/r_data/colormaps.h | 1 + src/r_main.cpp | 7 +++++++ src/r_segs.cpp | 11 ++++++----- src/r_things.cpp | 17 +++++++++++------ 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 934d2d3e5..8d423b3b3 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -105,6 +105,7 @@ TArray WallPortals(1000); // note: this array needs to go away as subsector_t *InSubsector; CVAR (Bool, r_drawflat, false, 0) // [RH] Don't texture segs? +EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); void R_StoreWallRange (int start, int stop); @@ -1108,7 +1109,7 @@ void R_Subsector (subsector_t *sub) } else { - basecolormap = frontsector->ColorMap; + basecolormap = (r_fullbrightignoresectorcolor && fixedlightlev >= 0) ? &FullNormalLight : frontsector->ColorMap; } portal = frontsector->ValidatePortal(sector_t::ceiling); @@ -1142,7 +1143,7 @@ void R_Subsector (subsector_t *sub) } else { - basecolormap = frontsector->ColorMap; + basecolormap = (r_fullbrightignoresectorcolor && fixedlightlev >= 0) ? &FullNormalLight : frontsector->ColorMap; } // killough 3/7/98: Add (x,y) offsets to flats, add deep water check diff --git a/src/r_data/colormaps.cpp b/src/r_data/colormaps.cpp index 3bfc89b4b..16ac0291e 100644 --- a/src/r_data/colormaps.cpp +++ b/src/r_data/colormaps.cpp @@ -59,6 +59,7 @@ static bool R_CheckForFixedLights(const BYTE *colormaps); extern "C" { FDynamicColormap NormalLight; +FDynamicColormap FullNormalLight; //[SP] Emulate GZDoom brightness } bool NormalLightHasFixedLights; @@ -547,6 +548,9 @@ void R_InitColormaps () NormalLight.Color = PalEntry (255, 255, 255); NormalLight.Fade = 0; NormalLight.Maps = realcolormaps.Maps; + FullNormalLight.Color = PalEntry (255, 255, 255); + FullNormalLight.Fade = 0; + FullNormalLight.Maps = realcolormaps.Maps; NormalLightHasFixedLights = R_CheckForFixedLights(realcolormaps.Maps); numfakecmaps = fakecmaps.Size(); diff --git a/src/r_data/colormaps.h b/src/r_data/colormaps.h index ca1574893..8b0bf187b 100644 --- a/src/r_data/colormaps.h +++ b/src/r_data/colormaps.h @@ -89,6 +89,7 @@ extern BYTE DesaturateColormap[31][256]; extern "C" { extern FDynamicColormap NormalLight; +extern FDynamicColormap FullNormalLight; } extern bool NormalLightHasFixedLights; diff --git a/src/r_main.cpp b/src/r_main.cpp index 684073046..9a582616e 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -451,6 +451,8 @@ void R_CopyStackedViewParameters() // //========================================================================== +EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) + void R_SetupColormap(player_t *player) { realfixedcolormap = NULL; @@ -477,6 +479,11 @@ void R_SetupColormap(player_t *player) else if (player->fixedlightlevel >= 0 && player->fixedlightlevel < NUMCOLORMAPS) { fixedlightlev = player->fixedlightlevel * 256; + // [SP] Emulate GZDoom's light-amp goggles. + if (r_fullbrightignoresectorcolor && fixedlightlev >= 0) + { + fixedcolormap = &FullNormalLight; + } } } // [RH] Inverse light for shooting the Sigil diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 0f723f9be..859bc8f1b 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -58,6 +58,7 @@ CVAR(Bool, r_np2, true, 0) +EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); //CVAR (Int, ty, 8, 0) //CVAR (Int, tx, 8, 0) @@ -318,7 +319,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) rw_scalestep = ds->iscalestep; if (fixedlightlev >= 0) - R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); @@ -635,7 +636,7 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) } if (fixedlightlev >= 0) - R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); @@ -1762,7 +1763,7 @@ void R_RenderSegLoop () fixed_t xoffset = rw_offset; if (fixedlightlev >= 0) - R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); @@ -3161,11 +3162,11 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rw_light = rw_lightleft + (x1 - WallC.sx1) * rw_lightstep; if (fixedlightlev >= 0) - R_SetColorMapLight(usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT)) - R_SetColorMapLight(usecolormap, 0, 0); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0); else calclighting = true; diff --git a/src/r_things.cpp b/src/r_things.cpp index bb8be4c6b..95ffc3703 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -570,7 +570,7 @@ void R_DrawWallSprite(vissprite_t *spr) else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) - R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &NormalLight : usecolormap, 0, 0); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0); else calclighting = true; @@ -1166,7 +1166,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor } else if (!foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) { // full bright - vis->Style.BaseColormap = (r_fullbrightignoresectorcolor) ? &NormalLight : mybasecolormap; + vis->Style.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; vis->Style.ColormapNum = 0; } else @@ -1489,12 +1489,12 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double } if (fixedlightlev >= 0) { - vis->Style.BaseColormap = mybasecolormap; + vis->Style.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; vis->Style.ColormapNum = fixedlightlev >> COLORMAPSHIFT; } else if (!foggy && pspr->GetState()->GetFullbright()) { // full bright - vis->Style.BaseColormap = mybasecolormap; // [RH] use basecolormap + vis->Style.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; // [RH] use basecolormap vis->Style.ColormapNum = 0; } else @@ -1546,6 +1546,11 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double { noaccel = true; } + // [SP] If emulating GZDoom fullbright, disable acceleration + if (r_fullbrightignoresectorcolor && fixedlightlev >= 0) + mybasecolormap = &FullNormalLight; + if (r_fullbrightignoresectorcolor && !foggy && pspr->GetState()->GetFullbright()) + mybasecolormap = &FullNormalLight; colormap_to_use = mybasecolormap; } else @@ -2088,7 +2093,7 @@ void R_DrawSprite (vissprite_t *spr) } else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) { // full bright - spr->Style.BaseColormap = mybasecolormap; + spr->Style.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; spr->Style.ColormapNum = 0; } else @@ -2652,7 +2657,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, } else if (particle->bright) { - vis->Style.BaseColormap = map; + vis->Style.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : map; vis->Style.ColormapNum = 0; } else From ec9dd3f5afe605a6dedfc24468a01bfae18e4032 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Fri, 21 Oct 2016 07:53:32 -0400 Subject: [PATCH 1118/1509] - Fixed compiler errors with r_fullbrightignoresectorcolor merge --- src/r_data/colormaps.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/r_data/colormaps.cpp b/src/r_data/colormaps.cpp index f2f84a8ea..d64327e79 100644 --- a/src/r_data/colormaps.cpp +++ b/src/r_data/colormaps.cpp @@ -457,11 +457,6 @@ void R_DeinitColormaps () SpecialColormaps.Clear(); fakecmaps.Clear(); delete[] realcolormaps.Maps; - if (realfbcolormaps != NULL) - { - delete[] realfbcolormaps; - realfbcolormaps = NULL; - } delete[] realfbcolormaps.Maps; FreeSpecialLights(); } @@ -554,10 +549,10 @@ void R_InitColormaps () } // [SP] Create a copy of the colormap - if (!realfbcolormaps) + if (!realfbcolormaps.Maps) { - realfbcolormaps = new BYTE[256*NUMCOLORMAPS*fakecmaps.Size()]; - memcpy(realfbcolormaps, realcolormaps, 256*NUMCOLORMAPS*fakecmaps.Size()); + realfbcolormaps.Maps = new BYTE[256*NUMCOLORMAPS*fakecmaps.Size()]; + memcpy(realfbcolormaps.Maps, realcolormaps.Maps, 256*NUMCOLORMAPS*fakecmaps.Size()); } NormalLight.Color = PalEntry (255, 255, 255); From 16fded31e1c29732272e4cba1f924547a05f20fc Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 21 Oct 2016 17:53:21 -0400 Subject: [PATCH 1119/1509] - Show current renderer on startup. This is for diagnostic purposes when we ask people for their startup logs so we know what key settings are being used when there is a problem. --- src/win32/hardware.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index e67d11842..b7c74fbd0 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -170,6 +170,16 @@ void I_CreateRenderer() { currentrenderer = vid_renderer; currentcanvas = vid_used3d; + if (currentrenderer == 1) + Printf("Renderer: OpenGL\n"); + else if (currentcanvas == 0) + Printf("Renderer: Software on OpenGL\n"); + else if (currentcanvas == 1 && vid_forceddraw == false) + Printf("Renderer: Software on Direct3D\n"); + else if (currentcanvas == 1) + Printf("Renderer: Software on DirectDraw\n"); + else + Printf("Renderer: Unknown\n"); if (Renderer == NULL) { if (currentrenderer==1) Renderer = gl_CreateInterface(); From e891911a991672c6fff8008b013928648fef793c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 22 Oct 2016 00:09:06 +0200 Subject: [PATCH 1120/1509] Fix broken SSAO portal rendering and let FRenderState do the glDrawBuffers calls --- src/gl/renderer/gl_renderstate.h | 17 ++++++++++++++ src/gl/scene/gl_scene.cpp | 35 ++++++++--------------------- src/gl/scene/gl_walls_draw.cpp | 2 ++ src/gl/stereo3d/scoped_color_mask.h | 2 ++ 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 3276502f1..76e2c791c 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -120,6 +120,7 @@ class FRenderState FShader *activeShader; EPassType mPassType = NORMAL_PASS; + int mNumDrawBuffers = 1; bool ApplyShader(); @@ -491,6 +492,22 @@ public: return mPassType; } + void EnableDrawBuffers(int count) + { + count = MIN(count, 3); + if (mNumDrawBuffers != count) + { + static GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 }; + glDrawBuffers(count, buffers); + mNumDrawBuffers = count; + } + } + + int GetPassDrawBufferCount() + { + return mPassType == GBUFFER_PASS ? 3 : 1; + } + // Backwards compatibility crap follows void ApplyFixedFunction(); void DrawColormapOverlay(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 13eb254ce..b1876c5be 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -160,9 +160,8 @@ void FGLRenderer::Set3DViewport(bool mainview) { bool useSSAO = (gl_ssao != 0); mBuffers->BindSceneFB(useSSAO); - GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 }; - glDrawBuffers(useSSAO ? 3 : 1, buffers); gl_RenderState.SetPassType(useSSAO ? GBUFFER_PASS : NORMAL_PASS); + gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount()); gl_RenderState.Apply(); } @@ -479,6 +478,11 @@ void FGLRenderer::DrawScene(int drawmode) static int recursion=0; static int ssao_portals_available = 0; + if (drawmode == DM_MAINVIEW) + ssao_portals_available = gl_ssao_portals + 1; + else if (drawmode == DM_OFFSCREEN) + ssao_portals_available = 0; + if (camera != nullptr) { ActorRenderFlags savedflags = camera->renderflags; @@ -495,35 +499,14 @@ void FGLRenderer::DrawScene(int drawmode) } GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. - // Decide if we need to do ssao for this scene - bool applySSAO = gl_ssao != 0 && FGLRenderBuffers::IsEnabled(); - switch (drawmode) - { - case DM_MAINVIEW: ssao_portals_available = gl_ssao_portals; break; - case DM_OFFSCREEN: ssao_portals_available = 0; applySSAO = false; break; - case DM_PORTAL: applySSAO = applySSAO && (ssao_portals_available > 0); ssao_portals_available--; break; - } - - // If SSAO is active, switch to gbuffer shaders and use the framebuffer with gbuffers - if (applySSAO) - { - GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 }; - glDrawBuffers(3, buffers); - gl_RenderState.SetPassType(GBUFFER_PASS); - gl_RenderState.Apply(); - gl_RenderState.ApplyMatrices(); - } - RenderScene(recursion); - // Apply ambient occlusion and switch back to shaders without gbuffer output - if (applySSAO) + if (ssao_portals_available > 0 && gl_RenderState.GetPassType() == GBUFFER_PASS) { - GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; - glDrawBuffers(1, buffers); + gl_RenderState.EnableDrawBuffers(1); AmbientOccludeScene(); mBuffers->BindSceneFB(true); - gl_RenderState.SetPassType(NORMAL_PASS); + gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount()); gl_RenderState.Apply(); gl_RenderState.ApplyMatrices(); } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index dbc43fd22..480ce4e86 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -227,6 +227,7 @@ void GLWall::RenderFogBoundary() { int rel = rellight + getExtraLight(); gl_SetFog(lightlevel, rel, &Colormap, false); + gl_RenderState.EnableDrawBuffers(1); gl_RenderState.SetEffect(EFF_FOGBOUNDARY); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); glEnable(GL_POLYGON_OFFSET_FILL); @@ -235,6 +236,7 @@ void GLWall::RenderFogBoundary() glPolygonOffset(0.0f, 0.0f); glDisable(GL_POLYGON_OFFSET_FILL); gl_RenderState.SetEffect(EFF_NONE); + gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount()); } else { diff --git a/src/gl/stereo3d/scoped_color_mask.h b/src/gl/stereo3d/scoped_color_mask.h index 42c02db3a..e55772092 100644 --- a/src/gl/stereo3d/scoped_color_mask.h +++ b/src/gl/stereo3d/scoped_color_mask.h @@ -41,8 +41,10 @@ public: gl_RenderState.GetColorMask(saved[0], saved[1], saved[2], saved[3]); gl_RenderState.SetColorMask(r, g, b, a); gl_RenderState.ApplyColorMask(); + gl_RenderState.EnableDrawBuffers(1); } ~ScopedColorMask() { + gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount()); gl_RenderState.SetColorMask(saved[0], saved[1], saved[2], saved[3]); gl_RenderState.ApplyColorMask(); } From 11a98bec7e265260402bfded2a9967f42834f1e5 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 21 Oct 2016 18:18:48 -0400 Subject: [PATCH 1121/1509] - fixed: Compiler error in hardware.cpp (vid_forceddraw) --- src/win32/hardware.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index b7c74fbd0..609f56647 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -53,6 +53,7 @@ EXTERN_CVAR (Bool, ticker) EXTERN_CVAR (Bool, fullscreen) EXTERN_CVAR (Bool, swtruecolor) EXTERN_CVAR (Float, vid_winscale) +EXTERN_CVAR (Bool, vid_forceddraw) CVAR(Int, win_x, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Int, win_y, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) From 9ee34254c86380b13256268ce6acc89d39210b63 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 21 Oct 2016 19:26:05 -0400 Subject: [PATCH 1122/1509] - fixed: Crashing when using the "restart" ccmd --- src/r_data/colormaps.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/r_data/colormaps.cpp b/src/r_data/colormaps.cpp index d64327e79..659470a23 100644 --- a/src/r_data/colormaps.cpp +++ b/src/r_data/colormaps.cpp @@ -457,7 +457,11 @@ void R_DeinitColormaps () SpecialColormaps.Clear(); fakecmaps.Clear(); delete[] realcolormaps.Maps; - delete[] realfbcolormaps.Maps; + if (realfbcolormaps.Maps) + { + delete[] realfbcolormaps.Maps; + realfbcolormaps.Maps = nullptr; + } FreeSpecialLights(); } From a3e19bf3375616583030d75bb3ef042b2b2b5427 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 22 Oct 2016 21:25:29 +0200 Subject: [PATCH 1123/1509] Fixed gl_ssao_portals not having effect --- src/gl/scene/gl_scene.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index b1876c5be..c214dfce7 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -509,6 +509,7 @@ void FGLRenderer::DrawScene(int drawmode) gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount()); gl_RenderState.Apply(); gl_RenderState.ApplyMatrices(); + ssao_portals_available--; } // Handle all portals after rendering the opaque objects but before From 6c1c0d297216bfeca3c6606d86aaf9bc22180aa7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 22 Oct 2016 21:35:49 +0200 Subject: [PATCH 1124/1509] Improve scene selection for SSAO so that the mainview drawmode always takes precedence --- src/gl/scene/gl_scene.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index c214dfce7..f05213773 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -478,10 +478,21 @@ void FGLRenderer::DrawScene(int drawmode) static int recursion=0; static int ssao_portals_available = 0; + bool applySSAO = false; if (drawmode == DM_MAINVIEW) - ssao_portals_available = gl_ssao_portals + 1; + { + ssao_portals_available = gl_ssao_portals; + applySSAO = true; + } else if (drawmode == DM_OFFSCREEN) + { ssao_portals_available = 0; + } + else if (ssao_portals_available > 0) + { + applySSAO = true; + ssao_portals_available--; + } if (camera != nullptr) { @@ -501,7 +512,7 @@ void FGLRenderer::DrawScene(int drawmode) RenderScene(recursion); - if (ssao_portals_available > 0 && gl_RenderState.GetPassType() == GBUFFER_PASS) + if (applySSAO && gl_RenderState.GetPassType() == GBUFFER_PASS) { gl_RenderState.EnableDrawBuffers(1); AmbientOccludeScene(); @@ -509,7 +520,6 @@ void FGLRenderer::DrawScene(int drawmode) gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount()); gl_RenderState.Apply(); gl_RenderState.ApplyMatrices(); - ssao_portals_available--; } // Handle all portals after rendering the opaque objects but before From edf2556ea3d92d75484c0de5f7aefb7d97652d25 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 23 Oct 2016 06:06:59 -0400 Subject: [PATCH 1125/1509] - Implemented sv_singleplayerrespawn --- src/g_game.cpp | 3 ++- src/g_level.cpp | 4 +++- src/p_mobj.cpp | 5 +++-- src/p_user.cpp | 5 ++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 48bda24f5..b0c8775fc 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1655,9 +1655,10 @@ static void G_QueueBody (AActor *body) // // G_DoReborn // +EXTERN_CVAR(Bool, sv_singleplayerrespawn) void G_DoReborn (int playernum, bool freshbot) { - if (!multiplayer && !(level.flags2 & LEVEL2_ALLOWRESPAWN)) + if (!multiplayer && !(level.flags2 & LEVEL2_ALLOWRESPAWN) && !sv_singleplayerrespawn) { if (BackupSaveName.Len() > 0 && FileExists (BackupSaveName.GetChars())) { // Load game from the last point it was saved diff --git a/src/g_level.cpp b/src/g_level.cpp index 4c4b56324..2a1e0e70c 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -526,6 +526,8 @@ static bool unloading; // //========================================================================== +EXTERN_CVAR(Bool, sv_singleplayerrespawn) + void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill) { level_info_t *nextinfo = NULL; @@ -634,7 +636,7 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill // If this is co-op, respawn any dead players now so they can // keep their inventory on the next map. - if ((multiplayer || level.flags2 & LEVEL2_ALLOWRESPAWN) && !deathmatch && player->playerstate == PST_DEAD) + if ((multiplayer || level.flags2 & LEVEL2_ALLOWRESPAWN || sv_singleplayerrespawn) && !deathmatch && player->playerstate == PST_DEAD) { // Copied from the end of P_DeathThink [[ player->cls = NULL; // Force a new class if the player is using a random class diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 8f926ea77..3e2011878 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1,4 +1,4 @@ -// Emacs style mode select -*- C++ -*- +// Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // // $Id:$ @@ -4495,6 +4495,7 @@ void AActor::AdjustFloorClip () // Most of the player structure stays unchanged between levels. // EXTERN_CVAR (Bool, chasedemo) +EXTERN_CVAR(Bool, sv_singleplayerrespawn) extern bool demonew; @@ -4682,7 +4683,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) { // Give all cards in death match mode. p->mo->GiveDeathmatchInventory (); } - else if ((multiplayer || (level.flags2 & LEVEL2_ALLOWRESPAWN)) && state == PST_REBORN && oldactor != NULL) + else if ((multiplayer || (level.flags2 & LEVEL2_ALLOWRESPAWN) || sv_singleplayerrespawn) && state == PST_REBORN && oldactor != NULL) { // Special inventory handling for respawning in coop p->mo->FilterCoopRespawnInventory (oldactor); } diff --git a/src/p_user.cpp b/src/p_user.cpp index dec769025..450d794b6 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -68,6 +68,7 @@ static FRandom pr_skullpop ("SkullPop"); // Variables for prediction CVAR (Bool, cl_noprediction, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, cl_predict_specials, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, sv_singleplayerrespawn, false, CVAR_SERVERINFO | CVAR_LATCH) CUSTOM_CVAR(Float, cl_predict_lerpscale, 0.05f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { @@ -2212,7 +2213,9 @@ void P_DeathThink (player_t *player) if (level.time >= player->respawn_time || ((player->cmd.ucmd.buttons & BT_USE) && player->Bot == NULL)) { player->cls = NULL; // Force a new class if the player is using a random class - player->playerstate = (multiplayer || (level.flags2 & LEVEL2_ALLOWRESPAWN)) ? PST_REBORN : PST_ENTER; + player->playerstate = + (multiplayer || (level.flags2 & LEVEL2_ALLOWRESPAWN) || sv_singleplayerrespawn) + ? PST_REBORN : PST_ENTER; if (player->mo->special1 > 2) { player->mo->special1 = 0; From a39807eb9aee0d97403fbf4a12843896e1c47e4c Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 23 Oct 2016 06:06:59 -0400 Subject: [PATCH 1126/1509] - Implemented sv_singleplayerrespawn --- src/g_game.cpp | 3 ++- src/g_level.cpp | 4 +++- src/p_mobj.cpp | 5 +++-- src/p_user.cpp | 5 ++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 48bda24f5..b0c8775fc 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1655,9 +1655,10 @@ static void G_QueueBody (AActor *body) // // G_DoReborn // +EXTERN_CVAR(Bool, sv_singleplayerrespawn) void G_DoReborn (int playernum, bool freshbot) { - if (!multiplayer && !(level.flags2 & LEVEL2_ALLOWRESPAWN)) + if (!multiplayer && !(level.flags2 & LEVEL2_ALLOWRESPAWN) && !sv_singleplayerrespawn) { if (BackupSaveName.Len() > 0 && FileExists (BackupSaveName.GetChars())) { // Load game from the last point it was saved diff --git a/src/g_level.cpp b/src/g_level.cpp index 119cde378..d3a8c4015 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -526,6 +526,8 @@ static bool unloading; // //========================================================================== +EXTERN_CVAR(Bool, sv_singleplayerrespawn) + void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill) { level_info_t *nextinfo = NULL; @@ -634,7 +636,7 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill // If this is co-op, respawn any dead players now so they can // keep their inventory on the next map. - if ((multiplayer || level.flags2 & LEVEL2_ALLOWRESPAWN) && !deathmatch && player->playerstate == PST_DEAD) + if ((multiplayer || level.flags2 & LEVEL2_ALLOWRESPAWN || sv_singleplayerrespawn) && !deathmatch && player->playerstate == PST_DEAD) { // Copied from the end of P_DeathThink [[ player->cls = NULL; // Force a new class if the player is using a random class diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 8f926ea77..3e2011878 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1,4 +1,4 @@ -// Emacs style mode select -*- C++ -*- +// Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // // $Id:$ @@ -4495,6 +4495,7 @@ void AActor::AdjustFloorClip () // Most of the player structure stays unchanged between levels. // EXTERN_CVAR (Bool, chasedemo) +EXTERN_CVAR(Bool, sv_singleplayerrespawn) extern bool demonew; @@ -4682,7 +4683,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) { // Give all cards in death match mode. p->mo->GiveDeathmatchInventory (); } - else if ((multiplayer || (level.flags2 & LEVEL2_ALLOWRESPAWN)) && state == PST_REBORN && oldactor != NULL) + else if ((multiplayer || (level.flags2 & LEVEL2_ALLOWRESPAWN) || sv_singleplayerrespawn) && state == PST_REBORN && oldactor != NULL) { // Special inventory handling for respawning in coop p->mo->FilterCoopRespawnInventory (oldactor); } diff --git a/src/p_user.cpp b/src/p_user.cpp index e48712042..6ac39c2a5 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -68,6 +68,7 @@ static FRandom pr_skullpop ("SkullPop"); // Variables for prediction CVAR (Bool, cl_noprediction, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, cl_predict_specials, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, sv_singleplayerrespawn, false, CVAR_SERVERINFO | CVAR_LATCH) CUSTOM_CVAR(Float, cl_predict_lerpscale, 0.05f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { @@ -2211,7 +2212,9 @@ void P_DeathThink (player_t *player) if (level.time >= player->respawn_time || ((player->cmd.ucmd.buttons & BT_USE) && player->Bot == NULL)) { player->cls = NULL; // Force a new class if the player is using a random class - player->playerstate = (multiplayer || (level.flags2 & LEVEL2_ALLOWRESPAWN)) ? PST_REBORN : PST_ENTER; + player->playerstate = + (multiplayer || (level.flags2 & LEVEL2_ALLOWRESPAWN) || sv_singleplayerrespawn) + ? PST_REBORN : PST_ENTER; if (player->mo->special1 > 2) { player->mo->special1 = 0; From 1e9d3b1917d8c877d0307efa9694b30964a8de76 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 23 Oct 2016 08:14:54 -0400 Subject: [PATCH 1127/1509] - Putting the CVAR definition right in the middle of prediction stuff probably wasn't the best idea. --- src/p_user.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_user.cpp b/src/p_user.cpp index 6ac39c2a5..b7bd4c2ec 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -65,10 +65,12 @@ static FRandom pr_skullpop ("SkullPop"); // [RH] # of ticks to complete a turn180 #define TURN180_TICKS ((TICRATE / 4) + 1) +// [SP] Allows respawn in single player +CVAR(Bool, sv_singleplayerrespawn, false, CVAR_SERVERINFO | CVAR_LATCH) + // Variables for prediction CVAR (Bool, cl_noprediction, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, cl_predict_specials, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -CVAR(Bool, sv_singleplayerrespawn, false, CVAR_SERVERINFO | CVAR_LATCH) CUSTOM_CVAR(Float, cl_predict_lerpscale, 0.05f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { From 4934fc50705e075fd6f8b3909d6af380d1ef6e2e Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 23 Oct 2016 08:19:29 -0400 Subject: [PATCH 1128/1509] - Removed duplicate definition from ZDoom merge --- src/p_user.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_user.cpp b/src/p_user.cpp index b54a0ea62..232214bfd 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -71,7 +71,6 @@ CVAR(Bool, sv_singleplayerrespawn, false, CVAR_SERVERINFO | CVAR_LATCH) // Variables for prediction CVAR (Bool, cl_noprediction, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, cl_predict_specials, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -CVAR(Bool, sv_singleplayerrespawn, false, CVAR_SERVERINFO | CVAR_LATCH) CUSTOM_CVAR(Float, cl_predict_lerpscale, 0.05f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { From 86f36b3081cd3d96f86d43c7cfda367cac7350ba Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 23 Oct 2016 17:43:18 +0200 Subject: [PATCH 1129/1509] Add function returning the generated assembly for a given llvm module --- src/r_compiler/llvmdrawers.cpp | 89 +++++++++++++++++++++++++++------- 1 file changed, 72 insertions(+), 17 deletions(-) diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index c936d6260..ba1fb4efc 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -20,7 +20,9 @@ class LLVMProgram public: LLVMProgram(); + void CreateModule(); void CreateEE(); + std::string GenerateAssembly(std::string cpuName); std::string DumpModule(); void StopLogFatalErrors(); @@ -85,6 +87,8 @@ LLVMDrawers *LLVMDrawers::Instance() LLVMDrawersImpl::LLVMDrawersImpl() { + mProgram.CreateModule(); + CodegenDrawColumn("FillColumn", DrawColumnVariant::Fill, DrawColumnMethod::Normal); CodegenDrawColumn("FillColumnAdd", DrawColumnVariant::FillAdd, DrawColumnMethod::Normal); CodegenDrawColumn("FillColumnAddClamp", DrawColumnVariant::FillAddClamp, DrawColumnMethod::Normal); @@ -447,7 +451,11 @@ LLVMProgram::LLVMProgram() InitializeNativeTargetAsmPrinter(); mContext = std::make_unique(); - mModule = std::make_unique("render", context()); +} + +void LLVMProgram::CreateModule() +{ + mModule = std::make_unique("render", context()); } void LLVMProgram::CreateEE() @@ -456,22 +464,6 @@ void LLVMProgram::CreateEE() std::string errorstring; -#if 0 - std::string targetTriple = sys::getProcessTriple(); - StringMap cpuFeatures; - sys::getHostCPUFeatures(cpuFeatures); - std::string cpuFeaturesStr; - for (const auto &it : cpuFeatures) - { - if (!cpuFeaturesStr.empty()) - cpuFeaturesStr.push_back(' '); - cpuFeaturesStr.push_back(it.getValue() ? '+' : '-'); - cpuFeaturesStr += it.getKey(); - } - - Printf("LLVM CPU features: %s\n", cpuFeaturesStr.c_str()); -#endif - llvm::Module *module = mModule.get(); EngineBuilder engineBuilder(std::move(mModule)); engineBuilder.setErrorStr(&errorstring); @@ -532,6 +524,69 @@ void LLVMProgram::CreateEE() mEngine->finalizeObject(); } +std::string LLVMProgram::GenerateAssembly(std::string cpuName) +{ + using namespace llvm; + + std::string errorstring; + + llvm::Module *module = mModule.get(); + EngineBuilder engineBuilder(std::move(mModule)); + engineBuilder.setErrorStr(&errorstring); + engineBuilder.setOptLevel(CodeGenOpt::Aggressive); + engineBuilder.setEngineKind(EngineKind::JIT); + engineBuilder.setMCPU(cpuName); + machine = engineBuilder.selectTarget(); + if (!machine) + I_FatalError("Could not create LLVM target machine"); + + std::string targetTriple = machine->getTargetTriple().getTriple(); + + module->setTargetTriple(targetTriple); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + module->setDataLayout(new DataLayout(*machine->getSubtargetImpl()->getDataLayout())); +#else + module->setDataLayout(machine->createDataLayout()); +#endif + + legacy::FunctionPassManager PerFunctionPasses(module); + legacy::PassManager PerModulePasses; + +#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8) + PerFunctionPasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); + PerModulePasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); +#endif + + SmallString<16*1024> str; + raw_svector_ostream stream(str); + machine->addPassesToEmitFile(PerModulePasses, stream, TargetMachine::CGFT_AssemblyFile); + PerModulePasses.add(createPrintMIRPass(stream)); + + PassManagerBuilder passManagerBuilder; + passManagerBuilder.OptLevel = 3; + passManagerBuilder.SizeLevel = 0; + passManagerBuilder.Inliner = createFunctionInliningPass(); + passManagerBuilder.SLPVectorize = true; + passManagerBuilder.LoopVectorize = true; + passManagerBuilder.LoadCombine = true; + passManagerBuilder.populateModulePassManager(PerModulePasses); + passManagerBuilder.populateFunctionPassManager(PerFunctionPasses); + + // Run function passes: + PerFunctionPasses.doInitialization(); + for (llvm::Function &func : *module) + { + if (!func.isDeclaration()) + PerFunctionPasses.run(func); + } + PerFunctionPasses.doFinalization(); + + // Run module passes: + PerModulePasses.run(*module); + + return str.c_str(); +} + std::string LLVMProgram::DumpModule() { std::string str; From fbe2b76705a8e08a1bf6898780bf9e6b2a2e50e0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 23 Oct 2016 19:08:43 +0200 Subject: [PATCH 1130/1509] - fixed checks in sprite sorting logic. There were some missing parentheses. --- src/gl/scene/gl_drawinfo.cpp | 2 +- src/gl/scene/gl_wall.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index d1dd60c4f..e4722b3db 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -536,7 +536,7 @@ void GLDrawList::SortSpriteIntoWall(SortNode * head,SortNode * sort) const bool drawBillboardFacingCamera = gl_billboard_faces_camera; // [Nash] has +ROLLSPRITE - const bool rotated = (ss->actor != nullptr && ss->actor->renderflags & RF_ROLLSPRITE | RF_WALLSPRITE | RF_FLATSPRITE); + const bool rotated = (ss->actor != nullptr && ss->actor->renderflags & (RF_ROLLSPRITE | RF_WALLSPRITE | RF_FLATSPRITE)); // cannot sort them at the moment. This requires more complex splitting. if (drawWithXYBillboard || drawBillboardFacingCamera || rotated) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 143029ba7..bdee5761f 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -66,7 +66,7 @@ struct GLSeg // we do not use the vector math inlines here because they are not optimized for speed but accuracy in the playsim float x = y2 - y1; float y = x1 - x2; - float length = sqrt(x*x + y*y); + float length = sqrtf(x*x + y*y); return FVector3(x / length, 0, y / length); } }; From bea625a42c9aa0d854ae98e55a8a55945709730d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 23 Oct 2016 20:42:48 +0200 Subject: [PATCH 1131/1509] - added an ATTENUATE flag to dynamic lights, this is set by default for attached lights. For placed lights this is off, because it'd interfere with many existing maps that depend on unattenuated lights. --- src/gl/dynlights/gl_dynlight.cpp | 1 + src/gl/dynlights/gl_dynlight.h | 1 + src/gl/dynlights/gl_dynlight1.cpp | 2 +- wadsrc/static/shaders/glsl/main.fp | 17 ++++++++++------- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index ae19ecf60..40008e3ad 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -1082,6 +1082,7 @@ void gl_AttachLight(AActor *actor, unsigned int count, const FLightDefaults *lig light->target = actor; light->owned = true; light->ObjectFlags |= OF_Transient; + light->flags4 |= MF4_ATTENUATE; actor->dynamiclights.Push(light); } light->flags2&=~MF2_DORMANT; diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index 84965e318..c51e0c79d 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -50,6 +50,7 @@ enum #define MF4_SUBTRACTIVE MF4_MISSILEEVENMORE #define MF4_ADDITIVE MF4_MISSILEMORE #define MF4_DONTLIGHTSELF MF4_SEESDAGGERS +#define MF4_ATTENUATE MF4_INCOMBAT enum ELightType { diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index d20f5c01b..2f8ef44ed 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -116,7 +116,7 @@ bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FD data[4] = r; data[5] = g; data[6] = b; - data[7] = 0; + data[7] = !!(light->flags4 & MF4_ATTENUATE); return true; } diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index fb1983fc7..36db31f68 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -142,16 +142,19 @@ float diffuseContribution(vec3 lightDirection, vec3 normal) // //=========================================================================== -float pointLightAttenuation(vec4 lightpos) +float pointLightAttenuation(vec4 lightpos, float attenuate) { float attenuation = max(lightpos.w - distance(pixelpos.xyz, lightpos.xyz),0.0) / lightpos.w; - #if 0 + if (attenuate == 0.0) + { return attenuation; - #else + } + else + { vec3 lightDirection = normalize(lightpos.xyz - pixelpos.xyz); float diffuseAmount = diffuseContribution(lightDirection, normalize(vWorldNormal.xyz)); return attenuation * diffuseAmount; - #endif + } } //=========================================================================== @@ -229,7 +232,7 @@ vec4 getLightColor(float fogdist, float fogfactor) vec4 lightpos = lights[i]; vec4 lightcolor = lights[i+1]; - lightcolor.rgb *= pointLightAttenuation(lightpos); + lightcolor.rgb *= pointLightAttenuation(lightpos, lightcolor.a); dynlight.rgb += lightcolor.rgb; } // @@ -240,7 +243,7 @@ vec4 getLightColor(float fogdist, float fogfactor) vec4 lightpos = lights[i]; vec4 lightcolor = lights[i+1]; - lightcolor.rgb *= pointLightAttenuation(lightpos); + lightcolor.rgb *= pointLightAttenuation(lightpos, lightcolor.a); dynlight.rgb -= lightcolor.rgb; } } @@ -322,7 +325,7 @@ void main() vec4 lightpos = lights[i]; vec4 lightcolor = lights[i+1]; - lightcolor.rgb *= pointLightAttenuation(lightpos); + lightcolor.rgb *= pointLightAttenuation(lightpos, lightcolor.a); addlight.rgb += lightcolor.rgb; } frag.rgb = clamp(frag.rgb + desaturate(addlight).rgb, 0.0, 1.0); From 08a90a13f4b8701f93698aea0174ed46e93ec971 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 26 Oct 2016 00:38:59 -0400 Subject: [PATCH 1132/1509] - Moved renderer menu to options menu. Removed duplicate swtruecolor entry in "Truecolor Options" --- wadsrc/static/language.enu | 2 +- wadsrc/static/menudef.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 3ac8d2ce8..ed17f587a 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1656,6 +1656,7 @@ OPTMNU_NETWORK = "Network Options"; OPTMNU_SOUND = "Sound Options"; OPTMNU_DISPLAY = "Display Options"; OPTMNU_VIDEO = "Set video mode"; +OPTMNU_CHANGERENDER = "Change Rendering Output"; OPTMNU_DEFAULTS = "Reset to defaults"; OPTMNU_RESETTOSAVED = "Reset to last saved"; OPTMNU_CONSOLE = "Go to console"; @@ -2159,7 +2160,6 @@ VIDMNU_HIDPI = "Retina/HiDPI support"; VIDMNU_ASPECTRATIO = "Aspect ratio"; VIDMNU_FORCEASPECT = "Force aspect ratio"; VIDMNU_5X4ASPECTRATIO = "Enable 5:4 aspect ratio"; -VIDMNU_CHANGERENDER = "Change Rendering Output"; VIDMNU_ENTERTEXT = "Press ENTER to set mode"; VIDMNU_TESTTEXT1 = "T to test mode for 5 seconds"; VIDMNU_TESTTEXT2 = "Please wait 5 seconds..."; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 8c1bb5481..42fb35fef 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -345,6 +345,7 @@ OptionMenu "OptionsMenu" Submenu "$OPTMNU_SOUND", "SoundOptions" Submenu "$OPTMNU_DISPLAY", "VideoOptions" Submenu "$OPTMNU_VIDEO", "VideoModeMenu" + Submenu "$OPTMNU_CHANGERENDER", "RendererMenu" StaticText " " SafeCommand "$OPTMNU_DEFAULTS", "reset2defaults" SafeCommand "$OPTMNU_RESETTOSAVED", "reset2saved" @@ -670,7 +671,7 @@ OptionMenu "TrueColorOptions" Title "$TCMNU_TITLE" Option "$TCMNU_MULTITHREADED", "r_multithreaded", "OnOff" StaticText " " - Option "$TCMNU_TRUECOLOR", "swtruecolor", "OnOff" + //Option "$TCMNU_TRUECOLOR", "swtruecolor", "OnOff" Option "$TCMNU_MINFILTER", "r_minfilter", "OnOff" Option "$TCMNU_MAGFILTER", "r_magfilter", "OnOff" Option "$TCMNU_MIPMAP", "r_mipmap", "OnOff" @@ -1825,7 +1826,6 @@ OptionMenu VideoModeMenu Option "$VIDMNU_ASPECTRATIO", "menu_screenratios", "Ratios" Option "$VIDMNU_FORCEASPECT", "vid_aspect", "ForceRatios" Option "$VIDMNU_5X4ASPECTRATIO", "vid_tft", "YesNo" - Submenu "$VIDMNU_CHANGERENDER", "RendererMenu" StaticText " " ScreenResolution "res_0" ScreenResolution "res_1" From 2838e1b5de8f96604e36c0e3d6c87afb63f4124a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 26 Oct 2016 07:21:19 +0200 Subject: [PATCH 1133/1509] Compile fix for macOS --- src/r_compiler/llvm_include.h | 4 ++++ src/r_compiler/llvmdrawers.cpp | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/r_compiler/llvm_include.h b/src/r_compiler/llvm_include.h index c51143c58..75952d1f9 100644 --- a/src/r_compiler/llvm_include.h +++ b/src/r_compiler/llvm_include.h @@ -55,6 +55,10 @@ #include #include +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) +#include +#endif + #ifdef __APPLE__ #pragma clang diagnostic pop #endif diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index ba1fb4efc..2f8609f68 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -474,7 +474,11 @@ void LLVMProgram::CreateEE() if (!machine) I_FatalError("Could not create LLVM target machine"); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + std::string targetTriple = machine->getTargetTriple(); +#else std::string targetTriple = machine->getTargetTriple().getTriple(); +#endif std::string cpuName = machine->getTargetCPU(); Printf("LLVM target triple: %s\n", targetTriple.c_str()); Printf("LLVM target CPU: %s\n", cpuName.c_str()); @@ -540,7 +544,11 @@ std::string LLVMProgram::GenerateAssembly(std::string cpuName) if (!machine) I_FatalError("Could not create LLVM target machine"); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + std::string targetTriple = machine->getTargetTriple(); +#else std::string targetTriple = machine->getTargetTriple().getTriple(); +#endif module->setTargetTriple(targetTriple); #if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) @@ -558,9 +566,13 @@ std::string LLVMProgram::GenerateAssembly(std::string cpuName) #endif SmallString<16*1024> str; +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + raw_svector_ostream vecstream(str); + formatted_raw_ostream stream(vecstream); +#else raw_svector_ostream stream(str); +#endif machine->addPassesToEmitFile(PerModulePasses, stream, TargetMachine::CGFT_AssemblyFile); - PerModulePasses.add(createPrintMIRPass(stream)); PassManagerBuilder passManagerBuilder; passManagerBuilder.OptLevel = 3; From 767c3a2edd9693ea62940797fc0a584af25eb9bd Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 28 Oct 2016 01:55:59 +0200 Subject: [PATCH 1134/1509] Fix dancing sprites due to texture coordinate calculations not taking pixel centers into account --- src/r_things.cpp | 67 +++++++++--------------------------------------- 1 file changed, 12 insertions(+), 55 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 95ffc3703..215626668 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -255,17 +255,15 @@ void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span, bool us { int pixelsize = r_swtruecolor ? 4 : 1; int inputpixelsize = (r_swtruecolor && !drawer_needs_pal_input) ? 4 : 1; - const fixed_t centeryfrac = FLOAT2FIXED(CenterY); - const fixed_t texturemid = FLOAT2FIXED(dc_texturemid); while (span->Length != 0) { const int length = span->Length; const int top = span->TopOffset; // calculate unclipped screen coordinates for post - dc_yl = xs_RoundToInt(sprtopscreen + spryscale * top); - dc_yh = xs_RoundToInt(sprtopscreen + spryscale * (top + length)) - 1; - + dc_yl = (int)(sprtopscreen + spryscale * top); + dc_yh = (int)(sprtopscreen + spryscale * (top + length)) - 1; + if (sprflipvert) { swapvalues (dc_yl, dc_yh); @@ -282,49 +280,8 @@ void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span, bool us if (dc_yl <= dc_yh) { - if (sprflipvert) - { - dc_texturefrac = (dc_yl*dc_iscale) - (top << FRACBITS) - - FixedMul (centeryfrac, dc_iscale) - texturemid; - const fixed_t maxfrac = length << FRACBITS; - while (dc_texturefrac >= maxfrac) - { - if (++dc_yl > dc_yh) - goto nextpost; - dc_texturefrac += dc_iscale; - } - fixed_t endfrac = dc_texturefrac + (dc_yh-dc_yl)*dc_iscale; - while (endfrac < 0) - { - if (--dc_yh < dc_yl) - goto nextpost; - endfrac -= dc_iscale; - } - } - else - { - dc_texturefrac = texturemid - (top << FRACBITS) - + (dc_yl*dc_iscale) - FixedMul (centeryfrac-FRACUNIT, dc_iscale); - while (dc_texturefrac < 0) - { - if (++dc_yl > dc_yh) - goto nextpost; - dc_texturefrac += dc_iscale; - } - fixed_t endfrac = dc_texturefrac + (dc_yh-dc_yl)*dc_iscale; - const fixed_t maxfrac = length << FRACBITS; - if (dc_yh < mfloorclip[dc_x]-1 && endfrac < maxfrac - dc_iscale) - { - dc_yh++; - } - else while (endfrac >= maxfrac) - { - if (--dc_yh < dc_yl) - goto nextpost; - endfrac -= dc_iscale; - } - } - dc_source = column + top * inputpixelsize; + dc_texturefrac = FLOAT2FIXED((dc_yl + 0.5 - sprtopscreen) / spryscale); + dc_source = column; dc_dest = (ylookup[dc_yl] + dc_x) * pixelsize + dc_destorg; dc_count = dc_yh - dc_yl + 1; if (useRt) @@ -332,7 +289,6 @@ void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span, bool us else colfunc (); } -nextpost: span++; } @@ -1006,21 +962,23 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor const double thingxscalemul = spriteScale.X / tex->Scale.X; tx -= ((renderflags & RF_XFLIP) ? (tex->GetWidth() - tex->LeftOffset - 1) : tex->LeftOffset) * thingxscalemul; - x1 = centerx + xs_RoundToInt(tx * xscale); + double dtx1 = tx * xscale; + x1 = centerx + xs_RoundToInt(dtx1); // off the right side? if (x1 >= WindowRight) return; tx += tex->GetWidth() * thingxscalemul; - x2 = centerx + xs_RoundToInt(tx * xscale); + double dtx2 = tx * xscale; + x2 = centerx + xs_RoundToInt(dtx2); // off the left side or too small? if ((x2 < WindowLeft || x2 <= x1)) return; xscale = spriteScale.X * xscale / tex->Scale.X; - iscale = (tex->GetWidth() << FRACBITS) / (x2 - x1); + iscale = (fixed_t)(tex->GetWidth() / (dtx2 - dtx1) * FRACUNIT); double yscale = spriteScale.Y / tex->Scale.Y; @@ -1047,9 +1005,8 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor vis->startfrac = 0; vis->xiscale = iscale; } - - if (vis->x1 > x1) - vis->startfrac += vis->xiscale * (vis->x1 - x1); + + vis->startfrac += (fixed_t)(vis->xiscale * (vis->x1 - centerx - dtx1 + 0.5 * thingxscalemul)); } else { From 54c94f6e58841717424cbe655cc2e7924be9a685 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 28 Oct 2016 02:41:14 +0200 Subject: [PATCH 1135/1509] Fix pinkie having the blues --- src/r_drawt_rgba.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index a3849b9af..0a213418b 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -258,14 +258,14 @@ class FillColumnHorizRGBACommand : public DrawerCommand int _yl; int _yh; int _count; - int _color; + uint32_t _color; public: FillColumnHorizRGBACommand() { _x = dc_x; _count = dc_count; - _color = dc_color; + _color = GPalette.BaseColors[dc_color].d | (uint32_t)0xff000000; _yl = dc_yl; _yh = dc_yh; } @@ -273,7 +273,7 @@ public: void Execute(DrawerThread *thread) override { int count = _count; - int color = _color; + uint32_t color = _color; uint32_t *dest; if (count <= 0) From ea9b45d988d3c35811c4a204154da380b17a9fb7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 29 Oct 2016 06:50:09 +0200 Subject: [PATCH 1136/1509] Change read access violations to be non-fatal --- src/r_thread.cpp | 35 +++++++++++++------ src/r_thread.h | 9 ++--- src/win32/i_crash.cpp | 80 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 107 insertions(+), 17 deletions(-) diff --git a/src/r_thread.cpp b/src/r_thread.cpp index 4f10bd8bb..4d0a2100c 100644 --- a/src/r_thread.cpp +++ b/src/r_thread.cpp @@ -127,10 +127,10 @@ void DrawerCommandQueue::Finish() } } }, - [](void *data) + [](void *data, const char *reason, bool fatal) { TryCatchData *d = (TryCatchData*)data; - ReportFatalError(d->queue->active_commands[d->command_index], true); + ReportDrawerError(d->queue->active_commands[d->command_index], true, reason, fatal); }); // Wait for everyone to finish: @@ -139,7 +139,14 @@ void DrawerCommandQueue::Finish() queue->end_condition.wait(end_lock, [&]() { return queue->finished_threads == queue->threads.size(); }); if (!queue->thread_error.IsEmpty()) - I_FatalError("Fatal drawer error: %s", queue->thread_error.GetChars()); + { + static bool first = true; + if (queue->thread_error_fatal) + I_FatalError("%s", queue->thread_error.GetChars()); + else if (first) + Printf("%s\n", queue->thread_error.GetChars()); + first = false; + } // Clean up batch: @@ -212,10 +219,10 @@ void DrawerCommandQueue::StartThreads() } } }, - [](void *data) + [](void *data, const char *reason, bool fatal) { TryCatchData *d = (TryCatchData*)data; - ReportFatalError(d->queue->active_commands[d->command_index], true); + ReportDrawerError(d->queue->active_commands[d->command_index], true, reason, fatal); }); // Notify main thread that we finished: @@ -241,23 +248,31 @@ void DrawerCommandQueue::StopThreads() shutdown_flag = false; } -void DrawerCommandQueue::ReportFatalError(DrawerCommand *command, bool worker_thread) +void DrawerCommandQueue::ReportDrawerError(DrawerCommand *command, bool worker_thread, const char *reason, bool fatal) { if (worker_thread) { std::unique_lock end_lock(Instance()->end_mutex); - if (Instance()->thread_error.IsEmpty()) - Instance()->thread_error = command->DebugInfo(); + if (Instance()->thread_error.IsEmpty() || (!Instance()->thread_error_fatal && fatal)) + { + Instance()->thread_error = reason + (FString)": " + command->DebugInfo(); + Instance()->thread_error_fatal = fatal; + } } else { - I_FatalError("Fatal drawer error: %s", command->DebugInfo().GetChars()); + static bool first = true; + if (fatal) + I_FatalError("%s: %s", reason, command->DebugInfo().GetChars()); + else if (first) + Printf("%s: %s\n", reason, command->DebugInfo().GetChars()); + first = false; } } #ifndef WIN32 -void VectoredTryCatch(void *data, void(*tryBlock)(void *data), void(*catchBlock)(void *data)) +void VectoredTryCatch(void *data, void(*tryBlock)(void *data), void(*catchBlock)(void *data, const char *reason, bool fatal)) { tryBlock(data); } diff --git a/src/r_thread.h b/src/r_thread.h index a2cc8b973..e0aca2a01 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -109,7 +109,7 @@ public: virtual FString DebugInfo() = 0; }; -void VectoredTryCatch(void *data, void(*tryBlock)(void *data), void(*catchBlock)(void *data)); +void VectoredTryCatch(void *data, void(*tryBlock)(void *data), void(*catchBlock)(void *data, const char *reason, bool fatal)); // Manages queueing up commands and executing them on worker threads class DrawerCommandQueue @@ -132,6 +132,7 @@ class DrawerCommandQueue std::condition_variable end_condition; size_t finished_threads = 0; FString thread_error; + bool thread_error_fatal = false; int threaded_render = 0; DrawerThread single_core_thread; @@ -143,7 +144,7 @@ class DrawerCommandQueue void Finish(); static DrawerCommandQueue *Instance(); - static void ReportFatalError(DrawerCommand *command, bool worker_thread); + static void ReportDrawerError(DrawerCommand *command, bool worker_thread, const char *reason, bool fatal); DrawerCommandQueue(); ~DrawerCommandQueue(); @@ -166,10 +167,10 @@ public: T *c = (T*)data; c->Execute(&Instance()->single_core_thread); }, - [](void *data) + [](void *data, const char *reason, bool fatal) { T *c = (T*)data; - ReportFatalError(c, false); + ReportDrawerError(c, false, reason, fatal); }); } else diff --git a/src/win32/i_crash.cpp b/src/win32/i_crash.cpp index 373f902c5..c80d74f8a 100644 --- a/src/win32/i_crash.cpp +++ b/src/win32/i_crash.cpp @@ -3407,23 +3407,97 @@ namespace bool __declspec(thread) DrawerExceptionSetJumpResult; CONTEXT __declspec(thread) DrawerExceptionSetJumpContext; PVOID __declspec(thread) DrawerExceptionHandlerHandle; + char __declspec(thread) *DrawerExceptionReason; + bool __declspec(thread) DrawerExceptionFatal; LONG WINAPI DrawerExceptionHandler(_EXCEPTION_POINTERS *exceptionInfo) { - //RtlRestoreContext(&DrawerExceptionSetJumpContext, exceptionInfo->ExceptionRecord); *exceptionInfo->ContextRecord = DrawerExceptionSetJumpContext; + + DrawerExceptionFatal = false; + switch (exceptionInfo->ExceptionRecord->ExceptionCode) + { + default: DrawerExceptionReason = "Unknown exception code"; break; + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: DrawerExceptionReason = "Array bounds exceeded"; break; + case EXCEPTION_BREAKPOINT: DrawerExceptionReason = "Breakpoint"; break; + case EXCEPTION_DATATYPE_MISALIGNMENT: DrawerExceptionReason = "Datatype misalignment"; break; + case EXCEPTION_FLT_DENORMAL_OPERAND: DrawerExceptionReason = "Float denormal operand"; break; + case EXCEPTION_FLT_DIVIDE_BY_ZERO: DrawerExceptionReason = "Float divide by zero"; break; + case EXCEPTION_FLT_INEXACT_RESULT: DrawerExceptionReason = "Float inexact result"; break; + case EXCEPTION_FLT_INVALID_OPERATION: DrawerExceptionReason = "Float invalid operation"; break; + case EXCEPTION_FLT_OVERFLOW: DrawerExceptionReason = "Float overflow"; break; + case EXCEPTION_FLT_STACK_CHECK: DrawerExceptionReason = "Float stack check"; break; + case EXCEPTION_FLT_UNDERFLOW: DrawerExceptionReason = "Float underflow"; break; + case EXCEPTION_INT_DIVIDE_BY_ZERO: DrawerExceptionReason = "Int divide by zero"; break; + case EXCEPTION_INT_OVERFLOW: DrawerExceptionReason = "Int overflow"; break; + case EXCEPTION_INVALID_DISPOSITION: DrawerExceptionReason = "Invalid disposition"; break; + case EXCEPTION_NONCONTINUABLE_EXCEPTION: DrawerExceptionReason = "Noncontinuable exception"; break; + case EXCEPTION_PRIV_INSTRUCTION: DrawerExceptionReason = "Priv instruction"; break; + case EXCEPTION_SINGLE_STEP: DrawerExceptionReason = "Single step"; break; + case EXCEPTION_STACK_OVERFLOW: DrawerExceptionReason = "Stack overflow"; break; + + case EXCEPTION_ILLEGAL_INSTRUCTION: + DrawerExceptionReason = "Illegal instruction"; + DrawerExceptionFatal = true; + break; + + case EXCEPTION_ACCESS_VIOLATION: + if (exceptionInfo->ExceptionRecord->ExceptionInformation[0] == 0) + { + DrawerExceptionReason = "Read access violation"; + } + else if (exceptionInfo->ExceptionRecord->ExceptionInformation[0] == 1) + { + DrawerExceptionReason = "Write access violation"; + DrawerExceptionFatal = true; + } + else if (exceptionInfo->ExceptionRecord->ExceptionInformation[0] == 8) + { + DrawerExceptionReason = "User-mode data execution prevention (DEP) violation"; + DrawerExceptionFatal = true; + } + else + { + DrawerExceptionReason = "Unknown access violation"; + DrawerExceptionFatal = true; + } + break; + + case EXCEPTION_IN_PAGE_ERROR: + if (exceptionInfo->ExceptionRecord->ExceptionInformation[0] == 0) + { + DrawerExceptionReason = "In page read error"; + } + else if (exceptionInfo->ExceptionRecord->ExceptionInformation[0] == 1) + { + DrawerExceptionReason = "In page write error"; + DrawerExceptionFatal = true; + } + else if (exceptionInfo->ExceptionRecord->ExceptionInformation[0] == 8) + { + DrawerExceptionReason = "In page user-mode data execution prevention (DEP) error"; + DrawerExceptionFatal = true; + } + else + { + DrawerExceptionReason = "Unknown in page read error"; + DrawerExceptionFatal = true; + } + break; + } + return EXCEPTION_CONTINUE_EXECUTION; } } -void VectoredTryCatch(void *data, void(*tryBlock)(void *data), void(*catchBlock)(void *data)) +void VectoredTryCatch(void *data, void(*tryBlock)(void *data), void(*catchBlock)(void *data, const char *reason, bool fatal)) { DrawerExceptionSetJumpResult = false; RtlCaptureContext(&DrawerExceptionSetJumpContext); if (DrawerExceptionSetJumpResult) { RemoveVectoredExceptionHandler(DrawerExceptionHandlerHandle); - catchBlock(data); + catchBlock(data, DrawerExceptionReason, DrawerExceptionFatal); } else { From ea44a445afd06f4d9642767ef01368b69322cdf4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 29 Oct 2016 07:20:16 +0200 Subject: [PATCH 1137/1509] Improve drawer debug info details --- src/r_compiler/llvmdrawers.h | 4 ++-- src/r_draw_rgba.cpp | 26 +++++++++++++------------- src/r_drawt_rgba.cpp | 8 ++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 64d73eeee..e7386678e 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -45,7 +45,7 @@ struct DrawWallArgs FString ToString() { FString info; - info.Format("dest_y = %i, count = %i, flags = %i", dest_y, count, flags); + info.Format("dest_y = %i, count = %i, flags = %i, texturefrac[0] = %u, textureheight[0] = %u", dest_y, count, flags, texturefrac[0], textureheight[0]); return info; } }; @@ -128,7 +128,7 @@ struct DrawColumnArgs FString ToString() { FString info; - info.Format("dest_y = %i, count = %i, flags = %i", dest_y, count, flags); + info.Format("dest_y = %i, count = %i, flags = %i, iscale = %i (%f), texturefrac = %i (%f)", dest_y, count, flags, iscale, ((fixed_t)iscale) / (float)FRACUNIT, texturefrac, ((fixed_t)texturefrac) / (float)FRACUNIT); return info; } }; diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 2b9eb86e7..1b46489a5 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -107,7 +107,7 @@ public: FString DebugInfo() override { - return "DrawSpanLLVMCommand\n" + args.ToString(); + return "DrawSpan\n" + args.ToString(); } protected: @@ -258,7 +258,7 @@ public: FString DebugInfo() override { - return "DrawWall4LLVMCommand\n" + args.ToString(); + return "DrawWall4\n" + args.ToString(); } }; @@ -319,7 +319,7 @@ public: FString DebugInfo() override { - return "DrawWall1LLVMCommand\n" + args.ToString(); + return "DrawWall1\n" + args.ToString(); } }; @@ -340,7 +340,7 @@ protected: FString DebugInfo() override { - return "DrawColumnLLVMCommand\n" + args.ToString(); + return "DrawColumn\n" + args.ToString(); } public: @@ -423,7 +423,7 @@ public: FString DebugInfo() override { - return "DrawSkyLLVMCommand\n" + args.ToString(); + return "DrawSky\n" + args.ToString(); } }; @@ -587,7 +587,7 @@ public: FString DebugInfo() override { - return "DrawFuzzColumnRGBACommand"; + return "DrawFuzzColumn"; } }; @@ -626,7 +626,7 @@ public: FString DebugInfo() override { - return "FillSpanRGBACommand"; + return "FillSpan"; } }; @@ -750,7 +750,7 @@ public: FString DebugInfo() override { - return "DrawSlabRGBACommand"; + return "DrawSlab"; } }; @@ -829,7 +829,7 @@ public: FString DebugInfo() override { - return "DrawFogBoundaryLineRGBACommand"; + return "DrawFogBoundaryLine"; } }; @@ -983,7 +983,7 @@ public: FString DebugInfo() override { - return "DrawTiltedSpanRGBACommand"; + return "DrawTiltedSpan"; } }; @@ -1027,7 +1027,7 @@ public: FString DebugInfo() override { - return "DrawColoredSpanRGBACommand"; + return "DrawColoredSpan"; } }; @@ -1099,7 +1099,7 @@ public: FString DebugInfo() override { - return "FillTransColumnRGBACommand"; + return "FillTransColumn"; } }; @@ -1279,7 +1279,7 @@ public: FString DebugInfo() override { - return "DrawTrianglesCommand"; + return "DrawTriangles"; } private: diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 0a213418b..2963d2fc1 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -109,7 +109,7 @@ public: FString DebugInfo() override { - return "DrawColumnRt1LLVMCommand\n" + args.ToString(); + return "DrawColumnRt\n" + args.ToString(); } }; @@ -168,7 +168,7 @@ public: FString DebugInfo() override { - return "RtInitColsRGBACommand"; + return "RtInitCols"; } }; @@ -248,7 +248,7 @@ public: FString DebugInfo() override { - return "DrawColumnHorizRGBACommand"; + return "DrawColumnHoriz"; } }; @@ -298,7 +298,7 @@ public: FString DebugInfo() override { - return "FillColumnHorizRGBACommand"; + return "FillColumnHoriz"; } }; From 09961abeea0871d97dbcae067c2b58167fa86a4b Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 29 Oct 2016 21:44:30 -0400 Subject: [PATCH 1138/1509] - Version 0.1.1 tag --- src/version.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/version.h b/src/version.h index 837ef4eee..3ff0d7fa9 100644 --- a/src/version.h +++ b/src/version.h @@ -41,17 +41,17 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "0.2pre" +#define VERSIONSTR "0.1.1" // The version as seen in the Windows resource -#define RC_FILEVERSION 0,1,9999,0 -#define RC_PRODUCTVERSION 0,1,9999,0 -#define RC_PRODUCTVERSION2 "0.2pre" +#define RC_FILEVERSION 0,1,1,0 +#define RC_PRODUCTVERSION 0,1,1,0 +#define RC_PRODUCTVERSION2 "0.1.1" // Version identifier for network games. // Bump it every time you do a release unless you're certain you // didn't change anything that will affect sync. -#define NETGAMEVERSION 233 +#define NETGAMEVERSION 234 // Version stored in the ini's [LastRun] section. // Bump it if you made some configuration change that you want to From e2fa16c99e7ecf4f6d95ce1584edc8f1cc1fa4ce Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 29 Oct 2016 21:51:43 -0400 Subject: [PATCH 1139/1509] Actually - changed our minds - this is going to be 1.0. :) --- src/version.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/version.h b/src/version.h index 3ff0d7fa9..8d88b6ed1 100644 --- a/src/version.h +++ b/src/version.h @@ -41,12 +41,12 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "0.1.1" +#define VERSIONSTR "1.0" // The version as seen in the Windows resource -#define RC_FILEVERSION 0,1,1,0 -#define RC_PRODUCTVERSION 0,1,1,0 -#define RC_PRODUCTVERSION2 "0.1.1" +#define RC_FILEVERSION 1,0,0,0 +#define RC_PRODUCTVERSION 1,0,0,0 +#define RC_PRODUCTVERSION2 "1.0" // Version identifier for network games. // Bump it every time you do a release unless you're certain you From 6ea0baac3aa00df85360d95cf8718f1431bfc4cf Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 29 Oct 2016 22:49:34 -0400 Subject: [PATCH 1140/1509] - Next "pre" tag. --- src/version.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/version.h b/src/version.h index 8d88b6ed1..37f3b1dd4 100644 --- a/src/version.h +++ b/src/version.h @@ -41,12 +41,12 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "1.0" +#define VERSIONSTR "1.1pre" // The version as seen in the Windows resource -#define RC_FILEVERSION 1,0,0,0 -#define RC_PRODUCTVERSION 1,0,0,0 -#define RC_PRODUCTVERSION2 "1.0" +#define RC_FILEVERSION 1,0,9999,0 +#define RC_PRODUCTVERSION 1,0,9999,0 +#define RC_PRODUCTVERSION2 "1.1pre" // Version identifier for network games. // Bump it every time you do a release unless you're certain you From a7d06ddd77586a6b3dd9434245aefdae4ae73d67 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 30 Oct 2016 08:18:55 +0100 Subject: [PATCH 1141/1509] Add texturing to triangle drawer --- src/r_draw.h | 2 +- src/r_draw_rgba.cpp | 71 ++++++++++++++++------------ src/r_plane.cpp | 111 ++++++++++++++++++-------------------------- 3 files changed, 89 insertions(+), 95 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index 601962809..2fa662a95 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -403,7 +403,7 @@ struct TriVertex }; class VSMatrix; -void R_DrawTriangles(const VSMatrix &objectToWorld, const TriVertex *vertices, int count, int clipleft, int clipright, const short *cliptop, const short *clipbottom); +void R_DrawTriangles(const VSMatrix &objectToWorld, const TriVertex *vertices, int count, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture); extern bool r_swtruecolor; diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 1b46489a5..c65718de2 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -1260,8 +1260,8 @@ void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) class DrawTrianglesCommand : public DrawerCommand { public: - DrawTrianglesCommand(const VSMatrix &objectToWorld, const TriVertex *vertices, int count, int clipleft, int clipright, const short *clipdata) - : objectToWorld(objectToWorld), vertices(vertices), count(count), clipleft(clipleft), clipright(clipright), clipdata(clipdata) + DrawTrianglesCommand(const VSMatrix &transform, const TriVertex *vertices, int count, int clipleft, int clipright, const short *clipdata, const uint32_t *texturePixels, int textureWidth, int textureHeight) + : transform(transform), vertices(vertices), count(count), clipleft(clipleft), clipright(clipright), clipdata(clipdata), texturePixels(texturePixels), textureWidth(textureWidth), textureHeight(textureHeight) { } @@ -1274,7 +1274,7 @@ public: thread->triangle_clip_bottom[clipleft + i] = clipdata[cliplength + i]; } - draw_triangles(objectToWorld, vertices, count, clipleft, clipright, thread->triangle_clip_top, thread->triangle_clip_bottom, thread); + draw_triangles(transform, vertices, count, clipleft, clipright, thread->triangle_clip_top, thread->triangle_clip_bottom, thread); } FString DebugInfo() override @@ -1337,7 +1337,7 @@ private: int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright); int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, clipymin); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipymax); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipymax - 1); if (minx >= maxx || miny >= maxy) return; @@ -1407,9 +1407,9 @@ private: // Check if block needs clipping int clipcount = 0; - for (int ix = 0; ix < q; ix++) + for (int ix = x; ix < x + q; ix++) { - clipcount += (cliptop[x + ix] > y) || (clipbottom[x + ix] < y + q - 1); + clipcount += (clipleft > ix) || (clipright < ix) || (cliptop[ix] > y) || (clipbottom[ix] <= y + q - 1); } // Calculate varying variables for affine block @@ -1451,11 +1451,15 @@ private: { for (int ix = x; ix < x + q; ix++) { - uint32_t red = (uint32_t)clamp(varying[0] * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t green = (uint32_t)clamp(varying[1] * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t blue = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); + uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); - buffer[ix] = 0xff000000 | (red << 16) | (green << 8) | blue; + uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; + uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; + uint32_t uvoffset = upos * textureHeight + vpos; + + buffer[ix] = texturePixels[uvoffset]; for (int i = 0; i < TriVertex::NumVarying; i++) varying[i] += varyingStep[i]; @@ -1488,15 +1492,19 @@ private: { for (int ix = x; ix < x + q; ix++) { - bool visible = (cliptop[ix] <= y + iy) && (clipbottom[ix] >= y + iy); + bool visible = ix >= clipleft && ix <= clipright && (cliptop[ix] <= y + iy) && (clipbottom[ix] > y + iy); if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) { - uint32_t red = (uint32_t)clamp(varying[0] * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t green = (uint32_t)clamp(varying[1] * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t blue = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); + uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); - buffer[ix] = 0xff000000 | (red << 16) | (green << 8) | blue; + uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; + uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; + uint32_t uvoffset = upos * textureHeight + vpos; + + buffer[ix] = texturePixels[uvoffset]; } for (int i = 0; i < TriVertex::NumVarying; i++) @@ -1523,13 +1531,15 @@ private: bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2) { - if (clipdistance1 < 0.0f && clipdistance2 < 0.0f) + float d1 = clipdistance1 * (1.0f - t1) + clipdistance2 * t1; + float d2 = clipdistance1 * (1.0f - t2) + clipdistance2 * t2; + if (d1 < 0.0f && d2 < 0.0f) return true; - if (clipdistance1 < 0.0f) + if (d1 < 0.0f) t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), t1); - if (clipdistance2 < 0.0f) + if (d2 < 0.0f) t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2); return false; @@ -1580,7 +1590,7 @@ private: } } - void draw_triangles(const VSMatrix &objectToWorld, const TriVertex *vinput, int vcount, int clipleft, int clipright, const short *cliptop, const short *clipbottom, DrawerThread *thread) + void draw_triangles(const VSMatrix &transform, const TriVertex *vinput, int vcount, int clipleft, int clipright, const short *cliptop, const short *clipbottom, DrawerThread *thread) { for (int i = 0; i < vcount / 3; i++) { @@ -1592,8 +1602,8 @@ private: auto &v = vert[j]; v = *(vinput++); - // Apply object to world transform: - const float *matrix = objectToWorld.get(); + // Apply transform to get world coordinates: + const float *matrix = transform.get(); float vx = matrix[0 * 4 + 0] * v.x + matrix[1 * 4 + 0] * v.y + matrix[2 * 4 + 0] * v.z + matrix[3 * 4 + 0] * v.w; float vy = matrix[0 * 4 + 1] * v.x + matrix[1 * 4 + 1] * v.y + matrix[2 * 4 + 1] * v.z + matrix[3 * 4 + 1] * v.w; float vz = matrix[0 * 4 + 2] * v.x + matrix[1 * 4 + 2] * v.y + matrix[2 * 4 + 2] * v.z + matrix[3 * 4 + 2] * v.w; @@ -1611,9 +1621,9 @@ private: double tr_z = v.z - ViewPos.Z; double tx = tr_x * ViewSin - tr_y * ViewCos; double tz = tr_x * ViewTanCos + tr_y * ViewTanSin; - v.x = (float)tx; - v.y = (float)tr_z; - v.z = (float)(-tz * (farp + nearp) / (nearp - farp) + (2.0f * farp * nearp) / (nearp - farp)); + v.x = (float)tx * 0.5f; + v.y = (float)tr_z * 0.5f; + v.z = (float)((-tz * (farp + nearp) / (nearp - farp) + (2.0f * farp * nearp) / (nearp - farp))); v.w = (float)tz; } @@ -1636,8 +1646,8 @@ private: v.z *= v.w; // Apply viewport scale to get screen coordinates: - v.x = (float)(CenterX + v.x * CenterX); - v.y = (float)(CenterY - v.y * InvZtoScale); + v.x = (float)(CenterX + v.x * 2.0f * CenterX); + v.y = (float)(CenterY - v.y * 2.0f * InvZtoScale); } // Draw screen triangles @@ -1659,15 +1669,18 @@ private: } } - VSMatrix objectToWorld; + VSMatrix transform; const TriVertex *vertices; int count; int clipleft; int clipright; const short *clipdata; + const uint32_t *texturePixels; + int textureWidth; + int textureHeight; }; -void R_DrawTriangles(const VSMatrix &objectToWorld, const TriVertex *vertices, int count, int clipleft, int clipright, const short *cliptop, const short *clipbottom) +void R_DrawTriangles(const VSMatrix &transform, const TriVertex *vertices, int count, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture) { if (clipright < clipleft || clipleft < 0 || clipright > MAXWIDTH) return; @@ -1687,7 +1700,7 @@ void R_DrawTriangles(const VSMatrix &objectToWorld, const TriVertex *vertices, i for (int i = 0; i < cliplength; i++) clipdata[cliplength + i] = clipbottom[clipleft + i]; - DrawerCommandQueue::QueueCommand(objectToWorld, vertices, count, clipleft, clipright, clipdata); + DrawerCommandQueue::QueueCommand(transform, vertices, count, clipleft, clipright, clipdata, texture->GetPixelsBgra(), texture->GetWidth(), texture->GetHeight()); } ///////////////////////////////////////////////////////////////////////////// diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 3ba6feaf7..6c1cecdb5 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -998,85 +998,66 @@ static void R_DrawCubeSky(visplane_t *pl) static TriVertex cube[6 * 6] = { - { -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + // Top + { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + { 1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.1f, 1.0f }, - { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.1f, 1.0f }, + { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.1f, 1.0f }, + { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + // Bottom + { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.9f, 1.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f }, + { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.9f, 1.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.9f, 1.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + // Front + { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, + { 1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + { -1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + { -1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + // Back + { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, - { -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, + { -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, + { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + // Right + { 1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + { 1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, - { -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, + { 1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, + // Left + { -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, + { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + { -1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, - - { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - - - { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - - { -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f } + { -1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f } }; - static bool first_time = true; - if (first_time) - { - for (int i = 0; i < 6; i++) - { - cube[i * 6 + 0].varying[0] = 1.0f; - cube[i * 6 + 1].varying[1] = 1.0f; - cube[i * 6 + 2].varying[2] = 1.0f; - cube[i * 6 + 3].varying[2] = 1.0f; - cube[i * 6 + 4].varying[0] = 1.0f; - cube[i * 6 + 4].varying[1] = 1.0f; - cube[i * 6 + 4].varying[2] = 1.0f; - cube[i * 6 + 5].varying[0] = 1.0f; - } - first_time = false; - } + VSMatrix transform(0); + transform.translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); + transform.scale(1000.0f, 1000.0f, 1000.0f); - //static float angle = 0.0f; - //angle = fmod(angle + 0.5f, 360.0f); - VSMatrix objectToWorld(0); - objectToWorld.translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); - //objectToWorld.rotate(angle, 0.57735f, 0.57735f, 0.57735f); - objectToWorld.scale(100.0f, 100.0f, 100.0f); - - R_DrawTriangles(objectToWorld, cube, 6 * 6, x1, x2 - 1, uwal, dwal); + R_DrawTriangles(transform, cube, 6 * 6, x1, x2 - 1, uwal, dwal, frontskytex); } static void R_DrawSkyColumnStripe(int start_x, int y1, int y2, int columns, double scale, double texturemid, double yrepeat) From 4c5723c10a391edb1bfad512b64f094cecf906cd Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 31 Oct 2016 00:29:15 -0400 Subject: [PATCH 1142/1509] - Implemented "mpmap", "mpopen", and "mprecordmap". All 3 commands do exactly as their non-"mp" counterparts do, except they turn on multiplayer (botmode) emulation before doing so. --- src/doomstat.h | 3 ++ src/g_game.cpp | 1 + src/g_level.cpp | 116 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 119 insertions(+), 1 deletion(-) diff --git a/src/doomstat.h b/src/doomstat.h index bbb323c7e..70869b5a2 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -71,6 +71,9 @@ extern bool netgame; // Bot game? Like netgame, but doesn't involve network communication. extern bool multiplayer; +// [SP] MPMap implementation - invokes fake multiplayer without bots +extern bool multiplayernext; + // Flag: true only if started as net deathmatch. EXTERN_CVAR (Int, deathmatch) diff --git a/src/g_game.cpp b/src/g_game.cpp index b0c8775fc..5d7b1c153 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -164,6 +164,7 @@ bool viewactive; bool netgame; // only true if packets are broadcast bool multiplayer; +bool multiplayernext; // [SP] MPMap implementation player_t players[MAXPLAYERS]; bool playeringame[MAXPLAYERS]; diff --git a/src/g_level.cpp b/src/g_level.cpp index 2a1e0e70c..4b05188f4 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -268,6 +268,119 @@ CCMD (open) } } +//========================================================================== +// +// +//========================================================================== + +CCMD (mpmap) +{ + if (netgame) + { + Printf ("Use " TEXTCOLOR_BOLD "changemap" TEXTCOLOR_NORMAL " instead. " TEXTCOLOR_BOLD "Map" + TEXTCOLOR_NORMAL " is for single-player only.\n"); + return; + } + if (argv.argc() > 1) + { + try + { + if (!P_CheckMapData(argv[1])) + { + Printf ("No map %s\n", argv[1]); + } + else + { + multiplayernext = true; + G_DeferedInitNew (argv[1]); + } + } + catch(CRecoverableError &error) + { + if (error.GetMessage()) + Printf("%s", error.GetMessage()); + } + } + else + { + Printf ("Usage: map \n"); + } +} + +//========================================================================== +// +// +//========================================================================== + +CCMD(mprecordmap) +{ + if (netgame) + { + Printf("You cannot record a new game while in a netgame."); + return; + } + if (argv.argc() > 2) + { + try + { + if (!P_CheckMapData(argv[2])) + { + Printf("No map %s\n", argv[2]); + } + else + { + multiplayernext = true; + G_DeferedInitNew(argv[2]); + gameaction = ga_recordgame; + newdemoname = argv[1]; + newdemomap = argv[2]; + } + } + catch (CRecoverableError &error) + { + if (error.GetMessage()) + Printf("%s", error.GetMessage()); + } + } + else + { + Printf("Usage: recordmap \n"); + } +} + +//========================================================================== +// +// +//========================================================================== + +CCMD (mpopen) +{ + if (netgame) + { + Printf ("You cannot use open in multiplayer games.\n"); + return; + } + if (argv.argc() > 1) + { + d_mapname = "file:"; + d_mapname += argv[1]; + if (!P_CheckMapData(d_mapname)) + { + Printf ("No map %s\n", d_mapname.GetChars()); + } + else + { + gameaction = ga_newgame2; + d_skill = -1; + multiplayernext = true; + } + } + else + { + Printf ("Usage: open \n"); + } +} + //========================================================================== // @@ -293,7 +406,8 @@ void G_NewInit () G_ClearSnapshots (); ST_SetNeedRefresh(); netgame = false; - multiplayer = false; + multiplayer = multiplayernext; + multiplayernext = false; if (demoplayback) { C_RestoreCVars (); From 49cccfae4290a51bf5e84ef2871337ba53b57cbe Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 31 Oct 2016 00:42:02 -0400 Subject: [PATCH 1143/1509] - Added initial state for "multiplayernext" to prevent possible initialization errors. --- src/g_game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 5d7b1c153..2c827e639 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -164,7 +164,7 @@ bool viewactive; bool netgame; // only true if packets are broadcast bool multiplayer; -bool multiplayernext; // [SP] MPMap implementation +bool multiplayernext = false; // [SP] MPMap implementation player_t players[MAXPLAYERS]; bool playeringame[MAXPLAYERS]; From bc319dce1d284fb0e374c30d2d6b58aae747d1a8 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 31 Oct 2016 00:29:15 -0400 Subject: [PATCH 1144/1509] - Corrected syntax error messages for mpmap, mpopen, mprecordmap - Added initial state for "multiplayernext" to prevent possible initialization errors. - Implemented "mpmap", "mpopen", and "mprecordmap". All 3 commands do exactly as their non-"mp" counterparts do, except they turn on multiplayer (botmode) emulation before doing so. --- src/doomstat.h | 3 ++ src/g_game.cpp | 1 + src/g_level.cpp | 116 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 119 insertions(+), 1 deletion(-) diff --git a/src/doomstat.h b/src/doomstat.h index bbb323c7e..70869b5a2 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -71,6 +71,9 @@ extern bool netgame; // Bot game? Like netgame, but doesn't involve network communication. extern bool multiplayer; +// [SP] MPMap implementation - invokes fake multiplayer without bots +extern bool multiplayernext; + // Flag: true only if started as net deathmatch. EXTERN_CVAR (Int, deathmatch) diff --git a/src/g_game.cpp b/src/g_game.cpp index b0c8775fc..2c827e639 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -164,6 +164,7 @@ bool viewactive; bool netgame; // only true if packets are broadcast bool multiplayer; +bool multiplayernext = false; // [SP] MPMap implementation player_t players[MAXPLAYERS]; bool playeringame[MAXPLAYERS]; diff --git a/src/g_level.cpp b/src/g_level.cpp index d3a8c4015..05a85ba63 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -268,6 +268,119 @@ CCMD (open) } } +//========================================================================== +// +// +//========================================================================== + +CCMD (mpmap) +{ + if (netgame) + { + Printf ("Use " TEXTCOLOR_BOLD "changemap" TEXTCOLOR_NORMAL " instead. " TEXTCOLOR_BOLD "Map" + TEXTCOLOR_NORMAL " is for single-player only.\n"); + return; + } + if (argv.argc() > 1) + { + try + { + if (!P_CheckMapData(argv[1])) + { + Printf ("No map %s\n", argv[1]); + } + else + { + multiplayernext = true; + G_DeferedInitNew (argv[1]); + } + } + catch(CRecoverableError &error) + { + if (error.GetMessage()) + Printf("%s", error.GetMessage()); + } + } + else + { + Printf ("Usage: mpmap \n"); + } +} + +//========================================================================== +// +// +//========================================================================== + +CCMD(mprecordmap) +{ + if (netgame) + { + Printf("You cannot record a new game while in a netgame."); + return; + } + if (argv.argc() > 2) + { + try + { + if (!P_CheckMapData(argv[2])) + { + Printf("No map %s\n", argv[2]); + } + else + { + multiplayernext = true; + G_DeferedInitNew(argv[2]); + gameaction = ga_recordgame; + newdemoname = argv[1]; + newdemomap = argv[2]; + } + } + catch (CRecoverableError &error) + { + if (error.GetMessage()) + Printf("%s", error.GetMessage()); + } + } + else + { + Printf("Usage: mprecordmap \n"); + } +} + +//========================================================================== +// +// +//========================================================================== + +CCMD (mpopen) +{ + if (netgame) + { + Printf ("You cannot use open in multiplayer games.\n"); + return; + } + if (argv.argc() > 1) + { + d_mapname = "file:"; + d_mapname += argv[1]; + if (!P_CheckMapData(d_mapname)) + { + Printf ("No map %s\n", d_mapname.GetChars()); + } + else + { + gameaction = ga_newgame2; + d_skill = -1; + multiplayernext = true; + } + } + else + { + Printf ("Usage: mpopen \n"); + } +} + //========================================================================== // @@ -293,7 +406,8 @@ void G_NewInit () G_ClearSnapshots (); ST_SetNeedRefresh(); netgame = false; - multiplayer = false; + multiplayer = multiplayernext; + multiplayernext = false; if (demoplayback) { C_RestoreCVars (); From a1ba371eede7d365ae5139866f4685cd8faa86ba Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 31 Oct 2016 06:09:46 +0100 Subject: [PATCH 1145/1509] Added triangle drawer to the software renderer --- src/CMakeLists.txt | 1 + src/r_triangle.cpp | 715 +++++++++++++++++++++++++++++++++++++++++++++ src/r_triangle.h | 96 ++++++ 3 files changed, 812 insertions(+) create mode 100644 src/r_triangle.cpp create mode 100644 src/r_triangle.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 09e220143..bb00af82d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -936,6 +936,7 @@ set( FASTMATH_PCH_SOURCES r_segs.cpp r_sky.cpp r_things.cpp + r_triangle.cpp s_advsound.cpp s_environment.cpp s_playlist.cpp diff --git a/src/r_triangle.cpp b/src/r_triangle.cpp new file mode 100644 index 000000000..429f4a62a --- /dev/null +++ b/src/r_triangle.cpp @@ -0,0 +1,715 @@ +/* +** Triangle drawers +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "i_system.h" +#include "w_wad.h" +#include "r_local.h" +#include "v_video.h" +#include "doomstat.h" +#include "st_stuff.h" +#include "g_game.h" +#include "g_level.h" +#include "r_data/r_translate.h" +#include "v_palette.h" +#include "r_data/colormaps.h" +#include "r_triangle.h" + +void TriangleDrawer::draw(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture) +{ + draw_any(objectToWorld, vinput, vcount, ccw, clipleft, clipright, cliptop, clipbottom, texture, 0, &ScreenTriangleDrawer::draw); +} + +void TriangleDrawer::fill(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor) +{ + draw_any(objectToWorld, vinput, vcount, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, solidcolor, &ScreenTriangleDrawer::fill); +} + +void TriangleDrawer::draw_any(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture, int solidcolor, void(*drawfunc)(const ScreenTriangleDrawerArgs *)) +{ + for (int i = 0; i < vcount / 3; i++) + { + TriVertex vert[3]; + + // Vertex shader stuff: + for (int j = 0; j < 3; j++) + { + auto &v = vert[j]; + v = *(vinput++); + + // Apply transform to get world coordinates: + v = objectToWorld * v; + + // The software renderer world to clip transform: + double nearp = 5.0f; + double farp = 65536.f; + double tr_x = v.x - ViewPos.X; + double tr_y = v.y - ViewPos.Y; + double tr_z = v.z - ViewPos.Z; + double tx = tr_x * ViewSin - tr_y * ViewCos; + double tz = tr_x * ViewTanCos + tr_y * ViewTanSin; + v.x = (float)tx * 0.5f; + v.y = (float)tr_z * 0.5f; + v.z = (float)((-tz * (farp + nearp) / (nearp - farp) + (2.0f * farp * nearp) / (nearp - farp))); + v.w = (float)tz; + } + + // Cull, clip and generate additional vertices as needed + TriVertex clippedvert[6]; + int numclipvert = 0; + clipedge(vert[0], vert[1], clippedvert, numclipvert); + clipedge(vert[1], vert[2], clippedvert, numclipvert); + clipedge(vert[2], vert[0], clippedvert, numclipvert); + + // Map to 2D viewport: + for (int j = 0; j < numclipvert; j++) + { + auto &v = clippedvert[j]; + + // Calculate normalized device coordinates: + v.w = 1.0f / v.w; + v.x *= v.w; + v.y *= v.w; + v.z *= v.w; + + // Apply viewport scale to get screen coordinates: + v.x = (float)(CenterX + v.x * 2.0f * CenterX); + v.y = (float)(CenterY - v.y * 2.0f * InvZtoScale); + } + + // Draw screen triangles + + ScreenTriangleDrawerArgs args; + args.dest = dc_destorg; + args.pitch = dc_pitch; + args.clipleft = clipleft; + args.clipright = clipright; + args.cliptop = cliptop; + args.clipbottom = clipbottom; + if (texture) + { + args.textureWidth = texture->GetWidth(); + args.textureHeight = texture->GetHeight(); + args.texturePixels = texture->GetPixels(); + } + else + { + args.textureWidth = 0; + args.textureHeight = 0; + args.texturePixels = nullptr; + } + args.solidcolor = solidcolor; + + if (ccw) + { + for (int i = numclipvert; i > 1; i--) + { + args.v1 = &clippedvert[numclipvert - 1]; + args.v2 = &clippedvert[i - 1]; + args.v3 = &clippedvert[i - 2]; + drawfunc(&args); + } + } + else + { + for (int i = 2; i < numclipvert; i++) + { + args.v1 = &clippedvert[0]; + args.v2 = &clippedvert[i - 1]; + args.v3 = &clippedvert[i]; + drawfunc(&args); + } + } + } +} + +bool TriangleDrawer::cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2) +{ + float d1 = clipdistance1 * (1.0f - t1) + clipdistance2 * t1; + float d2 = clipdistance1 * (1.0f - t2) + clipdistance2 * t2; + if (d1 < 0.0f && d2 < 0.0f) + return true; + + if (d1 < 0.0f) + t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), t1); + + if (d2 < 0.0f) + t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2); + + return false; +} + +void TriangleDrawer::clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert) +{ + // Clip and cull so that the following is true for all vertices: + // -v.w <= v.x <= v.w + // -v.w <= v.y <= v.w + // -v.w <= v.z <= v.w + + float t1 = 0.0f, t2 = 1.0f; + bool culled = + cullhalfspace(v1.x + v1.w, v2.x + v2.w, t1, t2) || + cullhalfspace(v1.w - v1.x, v2.w - v2.x, t1, t2) || + cullhalfspace(v1.y + v1.w, v2.y + v2.w, t1, t2) || + cullhalfspace(v1.w - v1.y, v2.w - v2.y, t1, t2) || + cullhalfspace(v1.z + v1.w, v2.z + v2.w, t1, t2) || + cullhalfspace(v1.w - v1.z, v2.w - v2.z, t1, t2); + if (culled) + return; + + if (t1 == 0.0f) + { + clippedvert[numclipvert++] = v1; + } + else + { + auto &v = clippedvert[numclipvert++]; + v.x = v1.x * (1.0f - t1) + v2.x * t1; + v.y = v1.y * (1.0f - t1) + v2.y * t1; + v.z = v1.z * (1.0f - t1) + v2.z * t1; + v.w = v1.w * (1.0f - t1) + v2.w * t1; + for (int i = 0; i < TriVertex::NumVarying; i++) + v.varying[i] = v1.varying[i] * (1.0f - t1) + v2.varying[i] * t1; + } + + if (t2 != 1.0f) + { + auto &v = clippedvert[numclipvert++]; + v.x = v1.x * (1.0f - t2) + v2.x * t2; + v.y = v1.y * (1.0f - t2) + v2.y * t2; + v.z = v1.z * (1.0f - t2) + v2.z * t2; + v.w = v1.w * (1.0f - t2) + v2.w * t2; + for (int i = 0; i < TriVertex::NumVarying; i++) + v.varying[i] = v1.varying[i] * (1.0f - t2) + v2.varying[i] * t2; + } +} + +///////////////////////////////////////////////////////////////////////////// + +void ScreenTriangleDrawer::draw(const ScreenTriangleDrawerArgs *args) +{ + uint8_t *dest = args->dest; + int pitch = args->pitch; + const TriVertex &v1 = *args->v1; + const TriVertex &v2 = *args->v2; + const TriVertex &v3 = *args->v3; + int clipleft = args->clipleft; + int clipright = args->clipright; + const short *cliptop = args->cliptop; + const short *clipbottom = args->clipbottom; + const uint8_t *texturePixels = args->texturePixels; + int textureWidth = args->textureWidth; + int textureHeight = args->textureHeight; + + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int clipymin = cliptop[clipleft]; + int clipymax = clipbottom[clipleft]; + for (int i = clipleft + 1; i <= clipright; i++) + { + clipymin = MIN(clipymin, (int)cliptop[i]); + clipymax = MAX(clipymax, (int)clipbottom[i]); + } + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, clipymin); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipymax - 1); + if (minx >= maxx || miny >= maxy) + return; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + dest += miny * pitch; + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // Gradients + float gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + float gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + float startW = v1.w + gradWX * (minx - v1.x) + gradWY * (miny - v1.y); + float gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (minx - v1.x) + gradVaryingY[i] * (miny - v1.y); + } + + // Loop through blocks + for (int y = miny; y < maxy; y += q) + { + for (int x = minx; x < maxx; x += q) + { + // Corners of block + int x0 = x << 4; + int x1 = (x + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; + bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; + bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; + bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; + int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); + + bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; + bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; + bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; + bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; + int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); + + bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; + bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; + bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; + bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; + int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + + // Skip block when outside an edge + if (a == 0x0 || b == 0x0 || c == 0x0) continue; + + // Check if block needs clipping + int clipcount = 0; + for (int ix = x; ix < x + q; ix++) + { + clipcount += (clipleft > ix) || (clipright < ix) || (cliptop[ix] > y) || (clipbottom[ix] <= y + q - 1); + } + + // Calculate varying variables for affine block + float offx0 = (x - minx) + 0.5f; + float offy0 = (y - miny) + 0.5f; + float offx1 = offx0 + q; + float offy1 = offy0 + q; + float rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); + float rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); + float rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); + float rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); + float varyingTL[TriVertex::NumVarying]; + float varyingTR[TriVertex::NumVarying]; + float varyingBL[TriVertex::NumVarying]; + float varyingBR[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; + varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; + varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); + varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); + } + + uint8_t *buffer = dest; + + // Accept whole block when totally covered + if (a == 0xF && b == 0xF && c == 0xF && clipcount == 0) + { + for (int iy = 0; iy < q; iy++) + { + float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varying[i] = varyingTL[i] + varyingBL[i] * iy; + varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + } + + for (int ix = x; ix < x + q; ix++) + { + uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); + uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); + + uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; + uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; + uint32_t uvoffset = upos * textureHeight + vpos; + + buffer[ix] = texturePixels[uvoffset]; + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + } + + buffer += pitch; + } + } + else // Partially covered block + { + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; + + for (int iy = 0; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varying[i] = varyingTL[i] + varyingBL[i] * iy; + varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + } + + for (int ix = x; ix < x + q; ix++) + { + bool visible = ix >= clipleft && ix <= clipright && (cliptop[ix] <= y + iy) && (clipbottom[ix] > y + iy); + + if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) + { + uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); + uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); + + uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; + uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; + uint32_t uvoffset = upos * textureHeight + vpos; + + buffer[ix] = texturePixels[uvoffset]; + } + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + + buffer += pitch; + } + } + } + + dest += q * pitch; + } +} + +void ScreenTriangleDrawer::fill(const ScreenTriangleDrawerArgs *args) +{ + uint8_t *dest = args->dest; + int pitch = args->pitch; + const TriVertex &v1 = *args->v1; + const TriVertex &v2 = *args->v2; + const TriVertex &v3 = *args->v3; + int clipleft = args->clipleft; + int clipright = args->clipright; + const short *cliptop = args->cliptop; + const short *clipbottom = args->clipbottom; + int solidcolor = args->solidcolor; + + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int clipymin = cliptop[clipleft]; + int clipymax = clipbottom[clipleft]; + for (int i = clipleft + 1; i <= clipright; i++) + { + clipymin = MIN(clipymin, (int)cliptop[i]); + clipymax = MAX(clipymax, (int)clipbottom[i]); + } + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, clipymin); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipymax - 1); + if (minx >= maxx || miny >= maxy) + return; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + dest += miny * pitch; + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // Loop through blocks + for (int y = miny; y < maxy; y += q) + { + for (int x = minx; x < maxx; x += q) + { + // Corners of block + int x0 = x << 4; + int x1 = (x + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; + bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; + bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; + bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; + int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); + + bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; + bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; + bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; + bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; + int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); + + bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; + bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; + bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; + bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; + int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + + // Skip block when outside an edge + if (a == 0x0 || b == 0x0 || c == 0x0) continue; + + // Check if block needs clipping + int clipcount = 0; + for (int ix = x; ix < x + q; ix++) + { + clipcount += (clipleft > ix) || (clipright < ix) || (cliptop[ix] > y) || (clipbottom[ix] <= y + q - 1); + } + + uint8_t *buffer = dest; + + // Accept whole block when totally covered + if (a == 0xF && b == 0xF && c == 0xF && clipcount == 0) + { + for (int iy = 0; iy < q; iy++) + { + for (int ix = x; ix < x + q; ix++) + { + buffer[ix] = solidcolor; + } + + buffer += pitch; + } + } + else // Partially covered block + { + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; + + for (int iy = 0; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + for (int ix = x; ix < x + q; ix++) + { + bool visible = ix >= clipleft && ix <= clipright && (cliptop[ix] <= y + iy) && (clipbottom[ix] > y + iy); + + if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) + { + buffer[ix] = solidcolor; + } + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + + buffer += pitch; + } + } + } + + dest += q * pitch; + } +} + +float ScreenTriangleDrawer::gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) +{ + float top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); + float bottom = (x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2); + return top / bottom; +} + +float ScreenTriangleDrawer::grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) +{ + float top = (c1 - c2) * (x0 - x2) - (c0 - c2) * (x1 - x2); + float bottom = -((x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2)); + return top / bottom; +} + +///////////////////////////////////////////////////////////////////////////// + +TriMatrix TriMatrix::null() +{ + TriMatrix m; + memset(m.matrix, 0, sizeof(m.matrix)); + return m; +} + +TriMatrix TriMatrix::identity() +{ + TriMatrix m = null(); + m.matrix[0] = 1.0f; + m.matrix[5] = 1.0f; + m.matrix[10] = 1.0f; + m.matrix[15] = 1.0f; + return m; +} + +TriMatrix TriMatrix::translate(float x, float y, float z) +{ + TriMatrix m = identity(); + m.matrix[0 + 3 * 4] = x; + m.matrix[1 + 3 * 4] = y; + m.matrix[2 + 3 * 4] = z; + return m; +} + +TriMatrix TriMatrix::scale(float x, float y, float z) +{ + TriMatrix m = null(); + m.matrix[0 + 0 * 4] = x; + m.matrix[1 + 1 * 4] = y; + m.matrix[2 + 2 * 4] = z; + m.matrix[3 + 3 * 4] = 1; + return m; +} + +TriMatrix TriMatrix::rotate(float angle, float x, float y, float z) +{ + float c = cosf(angle); + float s = sinf(angle); + TriMatrix m = null(); + m.matrix[0 + 0 * 4] = (x*x*(1.0f - c) + c); + m.matrix[0 + 1 * 4] = (x*y*(1.0f - c) - z*s); + m.matrix[0 + 2 * 4] = (x*z*(1.0f - c) + y*s); + m.matrix[1 + 0 * 4] = (y*x*(1.0f - c) + z*s); + m.matrix[1 + 1 * 4] = (y*y*(1.0f - c) + c); + m.matrix[1 + 2 * 4] = (y*z*(1.0f - c) - x*s); + m.matrix[2 + 0 * 4] = (x*z*(1.0f - c) - y*s); + m.matrix[2 + 1 * 4] = (y*z*(1.0f - c) + x*s); + m.matrix[2 + 2 * 4] = (z*z*(1.0f - c) + c); + m.matrix[3 + 3 * 4] = 1.0f; + return m; +} + +TriMatrix TriMatrix::operator*(const TriMatrix &mult) const +{ + TriMatrix result; + for (int x = 0; x < 4; x++) + { + for (int y = 0; y < 4; y++) + { + result.matrix[x + y * 4] = + matrix[0 * 4 + x] * mult.matrix[y * 4 + 0] + + matrix[1 * 4 + x] * mult.matrix[y * 4 + 1] + + matrix[2 * 4 + x] * mult.matrix[y * 4 + 2] + + matrix[3 * 4 + x] * mult.matrix[y * 4 + 3]; + } + } + return result; +} + +TriVertex TriMatrix::operator*(TriVertex v) const +{ + float vx = matrix[0 * 4 + 0] * v.x + matrix[1 * 4 + 0] * v.y + matrix[2 * 4 + 0] * v.z + matrix[3 * 4 + 0] * v.w; + float vy = matrix[0 * 4 + 1] * v.x + matrix[1 * 4 + 1] * v.y + matrix[2 * 4 + 1] * v.z + matrix[3 * 4 + 1] * v.w; + float vz = matrix[0 * 4 + 2] * v.x + matrix[1 * 4 + 2] * v.y + matrix[2 * 4 + 2] * v.z + matrix[3 * 4 + 2] * v.w; + float vw = matrix[0 * 4 + 3] * v.x + matrix[1 * 4 + 3] * v.y + matrix[2 * 4 + 3] * v.z + matrix[3 * 4 + 3] * v.w; + v.x = vx; + v.y = vy; + v.z = vz; + v.w = vw; + return v; +} diff --git a/src/r_triangle.h b/src/r_triangle.h new file mode 100644 index 000000000..2cd98bdd6 --- /dev/null +++ b/src/r_triangle.h @@ -0,0 +1,96 @@ +/* +** Triangle drawers +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + + +#ifndef __R_TRIANGLE__ +#define __R_TRIANGLE__ + +#include "r_draw.h" + +class FTexture; +struct ScreenTriangleDrawerArgs; + +struct TriVertex +{ + TriVertex() { } + TriVertex(float x, float y, float z, float w, float u, float v, float light) : x(x), y(y), z(z), w(w) { varying[0] = u; varying[1] = v; varying[2] = light; } + + enum { NumVarying = 3 }; + float x, y, z, w; + float varying[NumVarying]; +}; + +struct TriMatrix +{ + static TriMatrix null(); + static TriMatrix identity(); + static TriMatrix translate(float x, float y, float z); + static TriMatrix scale(float x, float y, float z); + static TriMatrix rotate(float angle, float x, float y, float z); + + TriVertex operator*(TriVertex v) const; + TriMatrix operator*(const TriMatrix &m) const; + + float matrix[16]; +}; + +class TriangleDrawer +{ +public: + static void draw(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture); + static void fill(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor); + +private: + static void draw_any(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture, int solidcolor, void(*drawfunc)(const ScreenTriangleDrawerArgs *)); + static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); + static void clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert); +}; + +struct ScreenTriangleDrawerArgs +{ + uint8_t *dest; + int pitch; + TriVertex *v1; + TriVertex *v2; + TriVertex *v3; + int clipleft; + int clipright; + const short *cliptop; + const short *clipbottom; + const uint8_t *texturePixels; + int textureWidth; + int textureHeight; + int solidcolor; +}; + +class ScreenTriangleDrawer +{ +public: + static void draw(const ScreenTriangleDrawerArgs *args); + static void fill(const ScreenTriangleDrawerArgs *args); + +private: + static float gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); + static float grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); +}; + +#endif From 7a9c674f83379ec8ea9b714afd049660a58c06f5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 31 Oct 2016 08:30:08 +0100 Subject: [PATCH 1146/1509] Add triangle fan and strip --- src/r_triangle.cpp | 203 ++++++++++++++++++++++++++------------------- src/r_triangle.h | 15 +++- 2 files changed, 130 insertions(+), 88 deletions(-) diff --git a/src/r_triangle.cpp b/src/r_triangle.cpp index 429f4a62a..b6e7b1b2b 100644 --- a/src/r_triangle.cpp +++ b/src/r_triangle.cpp @@ -36,110 +36,143 @@ #include "r_data/colormaps.h" #include "r_triangle.h" -void TriangleDrawer::draw(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture) +void TriangleDrawer::draw(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture) { - draw_any(objectToWorld, vinput, vcount, ccw, clipleft, clipright, cliptop, clipbottom, texture, 0, &ScreenTriangleDrawer::draw); + draw_arrays(objectToWorld, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texture, 0, &ScreenTriangleDrawer::draw); } -void TriangleDrawer::fill(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor) +void TriangleDrawer::fill(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor) { - draw_any(objectToWorld, vinput, vcount, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, solidcolor, &ScreenTriangleDrawer::fill); + draw_arrays(objectToWorld, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, solidcolor, &ScreenTriangleDrawer::fill); } -void TriangleDrawer::draw_any(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture, int solidcolor, void(*drawfunc)(const ScreenTriangleDrawerArgs *)) +void TriangleDrawer::draw_arrays(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture, int solidcolor, void(*drawfunc)(const ScreenTriangleDrawerArgs *)) { - for (int i = 0; i < vcount / 3; i++) + if (vcount < 3) + return; + + ScreenTriangleDrawerArgs args; + args.dest = dc_destorg; + args.pitch = dc_pitch; + args.clipleft = clipleft; + args.clipright = clipright; + args.cliptop = cliptop; + args.clipbottom = clipbottom; + if (texture) { - TriVertex vert[3]; + args.textureWidth = texture->GetWidth(); + args.textureHeight = texture->GetHeight(); + args.texturePixels = texture->GetPixels(); + } + else + { + args.textureWidth = 0; + args.textureHeight = 0; + args.texturePixels = nullptr; + } + args.solidcolor = solidcolor; - // Vertex shader stuff: - for (int j = 0; j < 3; j++) + TriVertex vert[3]; + if (mode == TriangleDrawMode::Normal) + { + for (int i = 0; i < vcount / 3; i++) { - auto &v = vert[j]; - v = *(vinput++); - - // Apply transform to get world coordinates: - v = objectToWorld * v; - - // The software renderer world to clip transform: - double nearp = 5.0f; - double farp = 65536.f; - double tr_x = v.x - ViewPos.X; - double tr_y = v.y - ViewPos.Y; - double tr_z = v.z - ViewPos.Z; - double tx = tr_x * ViewSin - tr_y * ViewCos; - double tz = tr_x * ViewTanCos + tr_y * ViewTanSin; - v.x = (float)tx * 0.5f; - v.y = (float)tr_z * 0.5f; - v.z = (float)((-tz * (farp + nearp) / (nearp - farp) + (2.0f * farp * nearp) / (nearp - farp))); - v.w = (float)tz; + for (int j = 0; j < 3; j++) + vert[j] = shade_vertex(objectToWorld, *(vinput++)); + draw_shaded_triangle(vert, ccw, &args, drawfunc); } - - // Cull, clip and generate additional vertices as needed - TriVertex clippedvert[6]; - int numclipvert = 0; - clipedge(vert[0], vert[1], clippedvert, numclipvert); - clipedge(vert[1], vert[2], clippedvert, numclipvert); - clipedge(vert[2], vert[0], clippedvert, numclipvert); - - // Map to 2D viewport: - for (int j = 0; j < numclipvert; j++) + } + else if (mode == TriangleDrawMode::Fan) + { + vert[0] = shade_vertex(objectToWorld, *(vinput++)); + vert[1] = shade_vertex(objectToWorld, *(vinput++)); + for (int i = 2; i < vcount; i++) { - auto &v = clippedvert[j]; - - // Calculate normalized device coordinates: - v.w = 1.0f / v.w; - v.x *= v.w; - v.y *= v.w; - v.z *= v.w; - - // Apply viewport scale to get screen coordinates: - v.x = (float)(CenterX + v.x * 2.0f * CenterX); - v.y = (float)(CenterY - v.y * 2.0f * InvZtoScale); + vert[2] = shade_vertex(objectToWorld, *(vinput++)); + draw_shaded_triangle(vert, ccw, &args, drawfunc); + vert[1] = vert[2]; } - - // Draw screen triangles - - ScreenTriangleDrawerArgs args; - args.dest = dc_destorg; - args.pitch = dc_pitch; - args.clipleft = clipleft; - args.clipright = clipright; - args.cliptop = cliptop; - args.clipbottom = clipbottom; - if (texture) + } + else // TriangleDrawMode::Strip + { + vert[0] = shade_vertex(objectToWorld, *(vinput++)); + vert[1] = shade_vertex(objectToWorld, *(vinput++)); + for (int i = 2; i < vcount; i++) { - args.textureWidth = texture->GetWidth(); - args.textureHeight = texture->GetHeight(); - args.texturePixels = texture->GetPixels(); + vert[2] = shade_vertex(objectToWorld, *(vinput++)); + draw_shaded_triangle(vert, ccw, &args, drawfunc); + vert[0] = vert[1]; + vert[1] = vert[2]; + ccw = !ccw; } - else - { - args.textureWidth = 0; - args.textureHeight = 0; - args.texturePixels = nullptr; - } - args.solidcolor = solidcolor; + } +} - if (ccw) +TriVertex TriangleDrawer::shade_vertex(const TriMatrix &objectToWorld, TriVertex v) +{ + // Apply transform to get world coordinates: + v = objectToWorld * v; + + // The software renderer world to clip transform: + double nearp = 5.0f; + double farp = 65536.f; + double tr_x = v.x - ViewPos.X; + double tr_y = v.y - ViewPos.Y; + double tr_z = v.z - ViewPos.Z; + double tx = tr_x * ViewSin - tr_y * ViewCos; + double tz = tr_x * ViewTanCos + tr_y * ViewTanSin; + v.x = (float)tx * 0.5f; + v.y = (float)tr_z * 0.5f; + v.z = (float)((-tz * (farp + nearp) / (nearp - farp) + (2.0f * farp * nearp) / (nearp - farp))); + v.w = (float)tz; + + return v; +} + +void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenTriangleDrawerArgs *args, void(*drawfunc)(const ScreenTriangleDrawerArgs *)) +{ + // Cull, clip and generate additional vertices as needed + TriVertex clippedvert[6]; + int numclipvert = 0; + clipedge(vert[0], vert[1], clippedvert, numclipvert); + clipedge(vert[1], vert[2], clippedvert, numclipvert); + clipedge(vert[2], vert[0], clippedvert, numclipvert); + + // Map to 2D viewport: + for (int j = 0; j < numclipvert; j++) + { + auto &v = clippedvert[j]; + + // Calculate normalized device coordinates: + v.w = 1.0f / v.w; + v.x *= v.w; + v.y *= v.w; + v.z *= v.w; + + // Apply viewport scale to get screen coordinates: + v.x = (float)(CenterX + v.x * 2.0f * CenterX); + v.y = (float)(CenterY - v.y * 2.0f * InvZtoScale); + } + + // Draw screen triangles + if (ccw) + { + for (int i = numclipvert; i > 1; i--) { - for (int i = numclipvert; i > 1; i--) - { - args.v1 = &clippedvert[numclipvert - 1]; - args.v2 = &clippedvert[i - 1]; - args.v3 = &clippedvert[i - 2]; - drawfunc(&args); - } + args->v1 = &clippedvert[numclipvert - 1]; + args->v2 = &clippedvert[i - 1]; + args->v3 = &clippedvert[i - 2]; + drawfunc(args); } - else + } + else + { + for (int i = 2; i < numclipvert; i++) { - for (int i = 2; i < numclipvert; i++) - { - args.v1 = &clippedvert[0]; - args.v2 = &clippedvert[i - 1]; - args.v3 = &clippedvert[i]; - drawfunc(&args); - } + args->v1 = &clippedvert[0]; + args->v2 = &clippedvert[i - 1]; + args->v3 = &clippedvert[i]; + drawfunc(args); } } } diff --git a/src/r_triangle.h b/src/r_triangle.h index 2cd98bdd6..f1ff220b6 100644 --- a/src/r_triangle.h +++ b/src/r_triangle.h @@ -53,14 +53,23 @@ struct TriMatrix float matrix[16]; }; +enum class TriangleDrawMode +{ + Normal, + Fan, + Strip +}; + class TriangleDrawer { public: - static void draw(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture); - static void fill(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor); + static void draw(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture); + static void fill(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor); private: - static void draw_any(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture, int solidcolor, void(*drawfunc)(const ScreenTriangleDrawerArgs *)); + static TriVertex shade_vertex(const TriMatrix &objectToWorld, TriVertex v); + static void draw_arrays(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture, int solidcolor, void(*drawfunc)(const ScreenTriangleDrawerArgs *)); + static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenTriangleDrawerArgs *args, void(*drawfunc)(const ScreenTriangleDrawerArgs *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert); }; From cdf8264dc3e77f6681ef187565be7961bf341125 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 31 Oct 2016 08:30:39 +0100 Subject: [PATCH 1147/1509] Cube and dome sky modes --- src/r_plane.cpp | 250 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 250 insertions(+) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 07efb84b4..023de80d3 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -58,6 +58,7 @@ #include "r_3dfloors.h" #include "v_palette.h" #include "r_data/colormaps.h" +#include "r_triangle.h" #ifdef _MSC_VER #pragma warning(disable:4244) @@ -900,6 +901,245 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) return composite; } +static void R_DrawCubeSky(visplane_t *pl) +{ + int x1 = pl->left; + int x2 = pl->right; + short *uwal = (short *)pl->top; + short *dwal = (short *)pl->bottom; + + static TriVertex cube[6 * 6] = + { + // Top + { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + { 1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.1f, 1.0f }, + + { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.1f, 1.0f }, + { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.1f, 1.0f }, + { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + + // Bottom + { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.9f, 1.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f }, + + { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f }, + { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.9f, 1.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.9f, 1.0f }, + + // Front + { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, + { 1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + { -1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + + { -1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, + + // Back + { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, + + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, + { -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, + { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + + // Right + { 1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + { 1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, + + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, + { 1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + + // Left + { -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, + { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + { -1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + + { -1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f } + }; + + TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z) * TriMatrix::scale(1000.0f, 1000.0f, 1000.0f); + + uint32_t solid_top = frontskytex->GetSkyCapColor(false); + uint32_t solid_bottom = frontskytex->GetSkyCapColor(true); + + solid_top = RGB32k.RGB[(RPART(solid_top) >> 3)][(GPART(solid_top) >> 3)][(BPART(solid_top) >> 3)]; + solid_bottom = RGB32k.RGB[(RPART(solid_bottom) >> 3)][(GPART(solid_bottom) >> 3)][(BPART(solid_bottom) >> 3)]; + + TriangleDrawer::fill(objectToWorld, cube, 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, solid_top); + TriangleDrawer::fill(objectToWorld, cube + 6, 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, solid_bottom); + TriangleDrawer::draw(objectToWorld, cube + 2 * 6, 4 * 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, frontskytex); +} + +namespace +{ + class SkyDome + { + public: + SkyDome() { CreateDome(); } + void Render(visplane_t *pl); + + private: + TArray mVertices; + TArray mPrimStart; + int mRows, mColumns; + + void SkyVertex(int r, int c, bool yflip); + void CreateSkyHemisphere(bool zflip); + void CreateDome(); + void RenderRow(int row, visplane_t *pl); + void RenderCapColorRow(int row, bool bottomCap, visplane_t *pl); + + TriVertex SetVertex(float xx, float yy, float zz, float uu = 0, float vv = 0); + TriVertex SetVertexXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0); + }; + + TriVertex SkyDome::SetVertex(float xx, float yy, float zz, float uu, float vv) + { + TriVertex v; + v.x = xx; + v.y = yy; + v.z = zz; + v.w = 1.0f; + v.varying[0] = uu; + v.varying[1] = vv; + v.varying[2] = 1.0f; + return v; + } + + TriVertex SkyDome::SetVertexXYZ(float xx, float yy, float zz, float uu, float vv) + { + TriVertex v; + v.x = xx; + v.y = zz; + v.z = yy; + v.w = 1.0f; + v.varying[0] = uu; + v.varying[1] = vv; + v.varying[2] = 1.0f; + return v; + } + + void SkyDome::SkyVertex(int r, int c, bool zflip) + { + static const FAngle maxSideAngle = 60.f; + static const float scale = 10000.; + + FAngle topAngle = (c / (float)mColumns * 360.f); + FAngle sideAngle = maxSideAngle * (mRows - r) / mRows; + float height = sideAngle.Sin(); + float realRadius = scale * sideAngle.Cos(); + FVector2 pos = topAngle.ToVector(realRadius); + float z = (!zflip) ? scale * height : -scale * height; + + float u, v; + //uint32_t color = r == 0 ? 0xffffff : 0xffffffff; + + // And the texture coordinates. + if (!zflip) // Flipped Y is for the lower hemisphere. + { + u = (-c / (float)mColumns); + v = (r / (float)mRows); + } + else + { + u = (-c / (float)mColumns); + v = 1.0f + ((mRows - r) / (float)mRows); + } + + if (r != 4) z += 300; + + // And finally the vertex. + TriVertex vert; + vert = SetVertexXYZ(-pos.X, z - 1.f, pos.Y, u * 4.0f, v + 0.5f/*, color*/); + mVertices.Push(vert); + } + + void SkyDome::CreateSkyHemisphere(bool zflip) + { + int r, c; + + mPrimStart.Push(mVertices.Size()); + + for (c = 0; c < mColumns; c++) + { + SkyVertex(1, c, zflip); + } + + // The total number of triangles per hemisphere can be calculated + // as follows: rows * columns * 2 + 2 (for the top cap). + for (r = 0; r < mRows; r++) + { + mPrimStart.Push(mVertices.Size()); + for (c = 0; c <= mColumns; c++) + { + SkyVertex(r + zflip, c, zflip); + SkyVertex(r + 1 - zflip, c, zflip); + } + } + } + + void SkyDome::CreateDome() + { + mColumns = 128; + mRows = 4; + CreateSkyHemisphere(false); + CreateSkyHemisphere(true); + mPrimStart.Push(mVertices.Size()); + } + + void SkyDome::RenderRow(int row, visplane_t *pl) + { + int x1 = pl->left; + int x2 = pl->right; + short *uwal = (short *)pl->top; + short *dwal = (short *)pl->bottom; + TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); + TriangleDrawer::draw(objectToWorld, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Strip, false, x1, x2 - 1, uwal, dwal, frontskytex); + } + + void SkyDome::RenderCapColorRow(int row, bool bottomCap, visplane_t *pl) + { + uint32_t solid = frontskytex->GetSkyCapColor(bottomCap); + solid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)]; + + int x1 = pl->left; + int x2 = pl->right; + short *uwal = (short *)pl->top; + short *dwal = (short *)pl->bottom; + TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); + TriangleDrawer::fill(objectToWorld, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Fan, bottomCap, x1, x2 - 1, uwal, dwal, solid); + } + + void SkyDome::Render(visplane_t *pl) + { + int rc = mRows + 1; + + // No need to draw this as the software renderer can't look that high anyway + //RenderCapColorRow(0, false, pl); + //RenderCapColorRow(rc, true, pl); + + for (int i = 1; i <= mRows; i++) + { + RenderRow(i, pl); + RenderRow(rc + i, pl); + } + } +} + +static void R_DrawDomeSky(visplane_t *pl) +{ + static SkyDome skydome; + skydome.Render(pl); +} + static void R_DrawSkyColumnStripe(int start_x, int y1, int y2, int columns, double scale, double texturemid, double yrepeat) { uint32_t height = frontskytex->GetHeight(); @@ -1064,6 +1304,16 @@ static void R_DrawSky (visplane_t *pl) R_DrawCapSky(pl); return; } + else if (r_skymode == 3) + { + R_DrawCubeSky(pl); + return; + } + else if (r_skymode == 4) + { + R_DrawDomeSky(pl); + return; + } int x; float swal; From 429aed85e15fee727fa7ae8d63f43b24a262b29d Mon Sep 17 00:00:00 2001 From: Marisa Heit Date: Tue, 1 Nov 2016 00:18:56 -0500 Subject: [PATCH 1148/1509] Fixed: Masked midtexture yscale incorrectly used the texture's X scale --- src/r_segs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index dc8a8fb83..8c00faa7f 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -2495,7 +2495,7 @@ void R_StoreWallRange (int start, int stop) lwal = (fixed_t *)(openings + ds_p->maskedtexturecol); swal = (float *)(openings + ds_p->swall); FTexture *pic = TexMan(sidedef->GetTexture(side_t::mid), true); - double yscale = pic->Scale.X * sidedef->GetTextureYScale(side_t::mid); + double yscale = pic->Scale.Y * sidedef->GetTextureYScale(side_t::mid); fixed_t xoffset = FLOAT2FIXED(sidedef->GetTextureXOffset(side_t::mid)); if (pic->bWorldPanning) From 3102668dfa40dcb66a1d851caff315144643314a Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 1 Nov 2016 03:21:19 -0400 Subject: [PATCH 1149/1509] - Removed mp### commands, extended map, recordmap, and open commands to accept "dm/coop" as an extra parameter - to open maps in multiplayer mode with the respective ruleset. --- src/g_level.cpp | 151 +++++++++++------------------------------------- 1 file changed, 35 insertions(+), 116 deletions(-) diff --git a/src/g_level.cpp b/src/g_level.cpp index 7588473a3..ebcb000ac 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -90,6 +90,8 @@ #include "g_hub.h" +#include + void STAT_StartNewGame(const char *lev); void STAT_ChangeLevel(const char *newl); @@ -181,6 +183,16 @@ CCMD (map) } else { + if (argv.argc() > 2 && strcmp(argv[2], "coop") == 0) + { + deathmatch = false; + multiplayernext = true; + } + else if (argv.argc() > 2 && strcmp(argv[2], "dm") == 0) + { + deathmatch = true; + multiplayernext = true; + } G_DeferedInitNew (argv[1]); } } @@ -192,7 +204,7 @@ CCMD (map) } else { - Printf ("Usage: map \n"); + Printf ("Usage: map [coop|dm]\n"); } } @@ -218,6 +230,16 @@ CCMD(recordmap) } else { + if (argv.argc() > 3 && strcmp(argv[3], "coop") == 0) + { + deathmatch = false; + multiplayernext = true; + } + else if (argv.argc() > 3 && strcmp(argv[3], "dm") == 0) + { + deathmatch = true; + multiplayernext = true; + } G_DeferedInitNew(argv[2]); gameaction = ga_recordgame; newdemoname = argv[1]; @@ -232,7 +254,7 @@ CCMD(recordmap) } else { - Printf("Usage: recordmap \n"); + Printf("Usage: recordmap [coop|dm]\n"); } } @@ -258,126 +280,23 @@ CCMD (open) } else { + if (argv.argc() > 2 && strcmp(argv[2], "coop") == 0) + { + deathmatch = false; + multiplayernext = true; + } + else if (argv.argc() > 2 && strcmp(argv[2], "dm") == 0) + { + deathmatch = true; + multiplayernext = true; + } gameaction = ga_newgame2; d_skill = -1; } } else { - Printf ("Usage: open \n"); - } -} - -//========================================================================== -// -// -//========================================================================== - -CCMD (mpmap) -{ - if (netgame) - { - Printf ("Use " TEXTCOLOR_BOLD "changemap" TEXTCOLOR_NORMAL " instead. " TEXTCOLOR_BOLD "Map" - TEXTCOLOR_NORMAL " is for single-player only.\n"); - return; - } - if (argv.argc() > 1) - { - try - { - if (!P_CheckMapData(argv[1])) - { - Printf ("No map %s\n", argv[1]); - } - else - { - multiplayernext = true; - G_DeferedInitNew (argv[1]); - } - } - catch(CRecoverableError &error) - { - if (error.GetMessage()) - Printf("%s", error.GetMessage()); - } - } - else - { - Printf ("Usage: mpmap \n"); - } -} - -//========================================================================== -// -// -//========================================================================== - -CCMD(mprecordmap) -{ - if (netgame) - { - Printf("You cannot record a new game while in a netgame."); - return; - } - if (argv.argc() > 2) - { - try - { - if (!P_CheckMapData(argv[2])) - { - Printf("No map %s\n", argv[2]); - } - else - { - multiplayernext = true; - G_DeferedInitNew(argv[2]); - gameaction = ga_recordgame; - newdemoname = argv[1]; - newdemomap = argv[2]; - } - } - catch (CRecoverableError &error) - { - if (error.GetMessage()) - Printf("%s", error.GetMessage()); - } - } - else - { - Printf("Usage: mprecordmap \n"); - } -} - -//========================================================================== -// -// -//========================================================================== - -CCMD (mpopen) -{ - if (netgame) - { - Printf ("You cannot use open in multiplayer games.\n"); - return; - } - if (argv.argc() > 1) - { - d_mapname = "file:"; - d_mapname += argv[1]; - if (!P_CheckMapData(d_mapname)) - { - Printf ("No map %s\n", d_mapname.GetChars()); - } - else - { - gameaction = ga_newgame2; - d_skill = -1; - multiplayernext = true; - } - } - else - { - Printf ("Usage: mpopen \n"); + Printf ("Usage: open [coop|dm]\n"); } } From 33637dda23564facb946b4d893bf3b808a3d9ed7 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 1 Nov 2016 09:47:01 -0400 Subject: [PATCH 1150/1509] - fixed: map commands will now take capslock DM/COOP as arguments --- src/doomstat.h | 2 +- src/g_game.cpp | 2 +- src/g_level.cpp | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index 70869b5a2..22ee4fdb4 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -71,7 +71,7 @@ extern bool netgame; // Bot game? Like netgame, but doesn't involve network communication. extern bool multiplayer; -// [SP] MPMap implementation - invokes fake multiplayer without bots +// [SP] Map dm/coop implementation - invokes fake multiplayer without bots extern bool multiplayernext; // Flag: true only if started as net deathmatch. diff --git a/src/g_game.cpp b/src/g_game.cpp index 2c827e639..ec79d59e6 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -164,7 +164,7 @@ bool viewactive; bool netgame; // only true if packets are broadcast bool multiplayer; -bool multiplayernext = false; // [SP] MPMap implementation +bool multiplayernext = false; // [SP] Map coop/dm implementation player_t players[MAXPLAYERS]; bool playeringame[MAXPLAYERS]; diff --git a/src/g_level.cpp b/src/g_level.cpp index ebcb000ac..3136a254d 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -183,12 +183,12 @@ CCMD (map) } else { - if (argv.argc() > 2 && strcmp(argv[2], "coop") == 0) + if (argv.argc() > 2 && stricmp(argv[2], "coop") == 0) { deathmatch = false; multiplayernext = true; } - else if (argv.argc() > 2 && strcmp(argv[2], "dm") == 0) + else if (argv.argc() > 2 && stricmp(argv[2], "dm") == 0) { deathmatch = true; multiplayernext = true; @@ -230,12 +230,12 @@ CCMD(recordmap) } else { - if (argv.argc() > 3 && strcmp(argv[3], "coop") == 0) + if (argv.argc() > 3 && stricmp(argv[3], "coop") == 0) { deathmatch = false; multiplayernext = true; } - else if (argv.argc() > 3 && strcmp(argv[3], "dm") == 0) + else if (argv.argc() > 3 && stricmp(argv[3], "dm") == 0) { deathmatch = true; multiplayernext = true; @@ -280,12 +280,12 @@ CCMD (open) } else { - if (argv.argc() > 2 && strcmp(argv[2], "coop") == 0) + if (argv.argc() > 2 && stricmp(argv[2], "coop") == 0) { deathmatch = false; multiplayernext = true; } - else if (argv.argc() > 2 && strcmp(argv[2], "dm") == 0) + else if (argv.argc() > 2 && stricmp(argv[2], "dm") == 0) { deathmatch = true; multiplayernext = true; From bfb8886e93864b0e076a7774b3ce8add44abb8fb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 1 Nov 2016 13:33:18 +0100 Subject: [PATCH 1151/1509] - fixed: RapidJSON in ASCII mode cannot handle extended 8 bit character sets and will produce broken data if the input contains some. This means we need to perform the conversion to UTF-8 on ZDoom's side and run RapidJSON in UTF-8 mode. Daedalus triggers this with a 0x85 character which in Windows CP 1252 is the ellipsis (...) The converter will assume ISO-8859-1, though, but cannot do anything with these characters because they map to the font being used here. --- src/p_acs.cpp | 4 ++ src/serializer.cpp | 173 ++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 160 insertions(+), 17 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index f36aaaf69..d82e6590c 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -791,6 +791,10 @@ void ACSStringPool::WriteStrings(FSerializer &file, const char *key) const { if (file.BeginObject(nullptr)) { + if (i == 430) + { + int a = 0; + } file("index", i) ("string", entry->Str) ("lockcount", entry->LockCount) diff --git a/src/serializer.cpp b/src/serializer.cpp index 49226ce80..dec81e86f 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -67,6 +67,143 @@ char nulspace[1024 * 1024 * 4]; bool save_full = false; // for testing. Should be removed afterward. +int utf8_encode(int32_t codepoint, char *buffer, int *size) +{ + if (codepoint < 0) + return -1; + else if (codepoint < 0x80) + { + buffer[0] = (char)codepoint; + *size = 1; + } + else if (codepoint < 0x800) + { + buffer[0] = 0xC0 + ((codepoint & 0x7C0) >> 6); + buffer[1] = 0x80 + ((codepoint & 0x03F)); + *size = 2; + } + else if (codepoint < 0x10000) + { + buffer[0] = 0xE0 + ((codepoint & 0xF000) >> 12); + buffer[1] = 0x80 + ((codepoint & 0x0FC0) >> 6); + buffer[2] = 0x80 + ((codepoint & 0x003F)); + *size = 3; + } + else if (codepoint <= 0x10FFFF) + { + buffer[0] = 0xF0 + ((codepoint & 0x1C0000) >> 18); + buffer[1] = 0x80 + ((codepoint & 0x03F000) >> 12); + buffer[2] = 0x80 + ((codepoint & 0x000FC0) >> 6); + buffer[3] = 0x80 + ((codepoint & 0x00003F)); + *size = 4; + } + else + return -1; + + return 0; +} + +int utf8_decode(const char *src, int *size) +{ + int c = src[0] & 255; + int r; + + *size = 1; + if ((c & 0x80) == 0) + { + return c; + } + + int c1 = src[1] & 255; + + if ((c & 0xE0) == 0xC0) + { + r = ((c & 0x1F) << 6) | c1; + if (r >= 128) + { + *size = 2; + return r; + } + return -1; + } + + int c2 = src[2] & 255; + + if ((c & 0xF0) == 0xE0) + { + r = ((c & 0x0F) << 12) | (c1 << 6) | c2; + if (r >= 2048 && (r < 55296 || r > 57343)) + { + *size = 3; + return r; + } + return -1; + } + + int c3 = src[3] & 255; + + if ((c & 0xF8) == 0xF0) + { + r = ((c & 0x07) << 18) | (c1 << 12) | (c2 << 6) | c3; + if (r >= 65536 && r <= 1114111) + { + *size = 4; + return r; + } + } + return -1; +} + +static TArray out; +static const char *StringToUnicode(const char *cc, int size = -1) +{ + int ch; + const char *c = cc; + int count = 0; + int count1 = 0; + out.Clear(); + while (ch = (*c++) & 255) + { + count1++; + if (ch >= 128) + { + if (ch < 0x800) count += 2; + else count += 3; + // The source cannot contain 4-byte chars. + } + else count++; + if (count1 == size && size > 0) break; + } + if (count == count1) return cc; // string is pure ASCII. + // we need to convert + out.Resize(count + 1); + out.Last() = 0; + c = cc; + int i = 0; + while (ch = (*c++) & 255) + { + utf8_encode(ch, &out[i], &count1); + i += count1; + } + return &out[0]; +} + +static const char *UnicodeToString(const char *cc) +{ + out.Resize((unsigned)strlen(cc) + 1); + int ndx = 0; + while (*cc != 0) + { + int size; + int c = utf8_decode(cc, &size); + if (c < 0 || c > 255) c = '?'; + out[ndx++] = c; + cc += size; + } + out[ndx] = 0; + return &out[0]; +} + //========================================================================== // // @@ -99,8 +236,8 @@ struct FJSONObject struct FWriter { - typedef rapidjson::Writer > Writer; - typedef rapidjson::PrettyWriter > PrettyWriter; + typedef rapidjson::Writer > Writer; + typedef rapidjson::PrettyWriter > PrettyWriter; Writer *mWriter1; PrettyWriter *mWriter2; @@ -173,14 +310,16 @@ struct FWriter void String(const char *k) { + k = StringToUnicode(k); if (mWriter1) mWriter1->String(k); else if (mWriter2) mWriter2->String(k); } void String(const char *k, int size) { - if (mWriter1) mWriter1->String(k, size); - else if (mWriter2) mWriter2->String(k, size); + k = StringToUnicode(k, size); + if (mWriter1) mWriter1->String(k); + else if (mWriter2) mWriter2->String(k); } void Bool(bool k) @@ -602,7 +741,7 @@ FSerializer &FSerializer::Args(const char *key, int *args, int *defargs, int spe } else if (i == 0 && aval.IsString()) { - args[i] = -FName(aval.GetString()); + args[i] = -FName(UnicodeToString(aval.GetString())); } else { @@ -654,7 +793,7 @@ FSerializer &FSerializer::ScriptNum(const char *key, int &num) } else if (val->IsString()) { - num = -FName(val->GetString()); + num = -FName(UnicodeToString(val->GetString())); } else { @@ -709,7 +848,7 @@ FSerializer &FSerializer::Sprite(const char *key, int32_t &spritenum, int32_t *d { if (val->IsString()) { - uint32_t name = *reinterpret_cast(val->GetString()); + uint32_t name = *reinterpret_cast(UnicodeToString(val->GetString())); for (auto hint = NumStdSprites; hint-- != 0; ) { if (sprites[hint].dwName == name) @@ -747,7 +886,7 @@ FSerializer &FSerializer::StringPtr(const char *key, const char *&charptr) { if (val->IsString()) { - charptr = val->GetString(); + charptr = UnicodeToString(val->GetString()); } else { @@ -1403,7 +1542,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FTextureID &value, FTe assert(nameval.IsString() && typeval.IsInt()); if (nameval.IsString() && typeval.IsInt()) { - value = TexMan.GetTexture(nameval.GetString(), typeval.GetInt()); + value = TexMan.GetTexture(UnicodeToString(nameval.GetString()), typeval.GetInt()); } else { @@ -1553,7 +1692,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FName &value, FName *d assert(val->IsString()); if (val->IsString()) { - value = val->GetString(); + value = UnicodeToString(val->GetString()); } else { @@ -1638,7 +1777,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FSoundID &sid, FSoundI assert(val->IsString() || val->IsNull()); if (val->IsString()) { - sid = val->GetString(); + sid = UnicodeToString(val->GetString()); } else if (val->IsNull()) { @@ -1687,7 +1826,7 @@ template<> FSerializer &Serialize(FSerializer &arc, const char *key, PClassActor assert(val->IsString() || val->IsNull()); if (val->IsString()) { - clst = PClass::FindActor(val->GetString()); + clst = PClass::FindActor(UnicodeToString(val->GetString())); } else if (val->IsNull()) { @@ -1735,7 +1874,7 @@ template<> FSerializer &Serialize(FSerializer &arc, const char *key, PClass *&cl { if (val->IsString()) { - clst = PClass::FindClass(val->GetString()); + clst = PClass::FindClass(UnicodeToString(val->GetString())); } else if (val->IsNull()) { @@ -1810,7 +1949,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FState *&state, FState assert(cls.IsString() && ndx.IsUint()); if (cls.IsString() && ndx.IsUint()) { - PClassActor *clas = PClass::FindActor(cls.GetString()); + PClassActor *clas = PClass::FindActor(UnicodeToString(cls.GetString())); if (clas && ndx.GetUint() < (unsigned)clas->NumOwnedStates) { state = clas->OwnedStates + ndx.GetUint(); @@ -1932,7 +2071,7 @@ template<> FSerializer &Serialize(FSerializer &arc, const char *key, FString *&p } else if (val->IsString()) { - pstr = AActor::mStringPropertyData.Alloc(val->GetString()); + pstr = AActor::mStringPropertyData.Alloc(UnicodeToString(val->GetString())); } else { @@ -1974,7 +2113,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FString &pstr, FString } else if (val->IsString()) { - pstr = val->GetString(); + pstr = UnicodeToString(val->GetString()); } else { @@ -2023,7 +2162,7 @@ template<> FSerializer &Serialize(FSerializer &arc, const char *key, char *&pstr } else if (val->IsString()) { - pstr = copystring(val->GetString()); + pstr = copystring(UnicodeToString(val->GetString())); } else { From 48229837ed0c09ee57fa7bedf53d671c1e202067 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 1 Nov 2016 13:36:33 +0100 Subject: [PATCH 1152/1509] - fixed: ACSStringPool::AddString did not check for NULL pointers as input. Let's just map them to the empty string, that's a lot better than crashing. --- src/p_acs.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index d82e6590c..9281bfad0 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -375,6 +375,7 @@ void ACSStringPool::Clear() int ACSStringPool::AddString(const char *str) { + if (str == nullptr) str = ""; size_t len = strlen(str); unsigned int h = SuperFastHash(str, len); unsigned int bucketnum = h % NUM_BUCKETS; From f619e8ece11341f6dc90eb7cd62e26362095004a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 1 Nov 2016 13:48:56 +0100 Subject: [PATCH 1153/1509] - fixed numeric output precision for a few sliders. --- wadsrc/static/menudef.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 42fb35fef..06acc6fdf 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -694,8 +694,8 @@ OptionMenu "VideoOptions" Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff" Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn" - Slider "$DSPLYMNU_BLOODFADE", "blood_fade_scalar", 0.0, 1.0, 0.05, 1 - Slider "$DSPLYMNU_PICKUPFADE", "pickup_fade_scalar", 0.0, 1.0, 0.05, 1 + Slider "$DSPLYMNU_BLOODFADE", "blood_fade_scalar", 0.0, 1.0, 0.05, 2 + Slider "$DSPLYMNU_PICKUPFADE", "pickup_fade_scalar", 0.0, 1.0, 0.05, 2 Option "$DSPLYMNU_COLUMNMETHOD", "r_columnmethod", "ColumnMethods" StaticText " " @@ -728,7 +728,7 @@ OptionMenu "VideoOptions" ColorPicker "$DSPLYMNU_DIMCOLOR", "dimcolor" Slider "$DSPLYMNU_MOVEBOB", "movebob", 0, 1.0, 0.05, 2 Slider "$DSPLYMNU_STILLBOB", "stillbob", 0, 1.0, 0.05, 2 - Slider "$DSPLYMNU_BOBSPEED", "wbobspeed", 0, 2.0, 0.1, 2 + Slider "$DSPLYMNU_BOBSPEED", "wbobspeed", 0, 2.0, 0.1 } @@ -1270,7 +1270,7 @@ OptionMenu GameplayOptions Title "$GMPLYMNU_TITLE" //Indent 222 Option "$GMPLYMNU_TEAMPLAY", "teamplay", "OnOff" - Slider "$GMPLYMNU_TEAMDAMAGE", "teamdamage", 0, 1, 0.05 + Slider "$GMPLYMNU_TEAMDAMAGE", "teamdamage", 0, 1, 0.05,2 StaticText " " Option "$GMPLYMNU_SMARTAUTOAIM", "sv_smartaim", "SmartAim" StaticText " " @@ -1855,7 +1855,7 @@ OptionMenu NetworkOptions StaticText "$NETMNU_LOCALOPTIONS", 1 Option "$NETMNU_MOVEPREDICTION", "cl_noprediction", "OffOn" Option "$NETMNU_LINESPECIALPREDICTION", "cl_predict_specials", "OnOff" - Slider "$NETMNU_PREDICTIONLERPSCALE", "cl_predict_lerpscale", 0.0, 0.5, 0.05 + Slider "$NETMNU_PREDICTIONLERPSCALE", "cl_predict_lerpscale", 0.0, 0.5, 0.05, 2 Slider "$NETMNU_LERPTHRESHOLD", "cl_predict_lerpthreshold", 0.1, 16.0, 0.1 StaticText " " StaticText "$NETMNU_HOSTOPTIONS", 1 From 578bf9b09c97d6d4b59e58104e958aff98930050 Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Sun, 16 Oct 2016 02:50:21 +0800 Subject: [PATCH 1154/1509] Added "local" parameters to A_PlaySound and ACS PlaySound --- src/p_acs.cpp | 7 ++++--- src/p_actionfunctions.cpp | 5 +++-- src/s_sound.cpp | 26 ++++++++++++++++++++++++++ src/s_sound.h | 3 +++ wadsrc/static/actors/actor.txt | 2 +- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 9281bfad0..1a60a0c4f 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -5350,7 +5350,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args) case ACSF_PlaySound: case ACSF_PlayActorSound: - // PlaySound(tid, "SoundName", channel, volume, looping, attenuation) + // PlaySound(tid, "SoundName", channel, volume, looping, attenuation, local) { FSoundID sid; @@ -5371,6 +5371,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args) float vol = argCount > 3 ? ACSToFloat(args[3]) : 1.f; INTBOOL looping = argCount > 4 ? args[4] : false; float atten = argCount > 5 ? ACSToFloat(args[5]) : ATTN_NORM; + INTBOOL local = argCount > 6 ? args[6] : false; if (args[0] == 0) { @@ -5387,11 +5388,11 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) { if (!looping) { - S_Sound(spot, chan, sid, vol, atten); + S_PlaySound(spot, chan, sid, vol, atten, local); } else if (!S_IsActorPlayingSomething(spot, chan & 7, sid)) { - S_Sound(spot, chan | CHAN_LOOP, sid, vol, atten); + S_PlaySound(spot, chan | CHAN_LOOP, sid, vol, atten, local); } } } diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index c6bc8215b..73cade49a 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -1032,16 +1032,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlaySound) PARAM_FLOAT_OPT (volume) { volume = 1; } PARAM_BOOL_OPT (looping) { looping = false; } PARAM_FLOAT_OPT (attenuation) { attenuation = ATTN_NORM; } + PARAM_BOOL_OPT (local) { local = false; } if (!looping) { - S_Sound (self, channel, soundid, (float)volume, (float)attenuation); + S_PlaySound(self, channel, soundid, (float)volume, (float)attenuation, local); } else { if (!S_IsActorPlayingSomething (self, channel&7, soundid)) { - S_Sound (self, channel | CHAN_LOOP, soundid, (float)volume, (float)attenuation); + S_PlaySound(self, channel | CHAN_LOOP, soundid, (float)volume, (float)attenuation, local); } } return 0; diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 524b12175..a51a7101b 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1301,6 +1301,32 @@ void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, fl S_StartSound (NULL, sec, NULL, NULL, channel, sfxid, volume, attenuation); } +//========================================================================== +// +// S_PlaySound - Subfunction used by ACS and DECORATE +// +// Has a local parameter to make the sound audible only to the source +// +//========================================================================== + +void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool local) +{ + if (a == nullptr) + return; + + if (!local) + { + S_Sound(a, chan, sid, vol, atten); + } + else + { + if (a->CheckLocalView(consoleplayer)) + { + S_Sound(chan, sid, vol, ATTN_NONE); + } + } +} + //========================================================================== // // S_LoadSound diff --git a/src/s_sound.h b/src/s_sound.h index 9b917e25c..d6d2a5403 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -241,6 +241,9 @@ void S_Sound (const FPolyObj *poly, int channel, FSoundID sfxid, float volume, f void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, float attenuation); void S_Sound(const DVector3 &pos, int channel, FSoundID sfxid, float volume, float attenuation); +// [Nash] Used by ACS and DECORATE +void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool local); + // sound channels // channel 0 never willingly overrides // other channels (1-7) always override a playing sound on that channel diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index eecc843d3..71e82f613 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -191,7 +191,7 @@ ACTOR Actor native //: Thinker action native A_ComboAttack(); action native A_BulletAttack(); action native A_WolfAttack(int flags = 0, sound whattoplay = "weapons/pistol", float snipe = 1.0, int maxdamage = 64, int blocksize = 128, int pointblank = 2, int longrange = 4, float runspeed = 160.0, class pufftype = "BulletPuff"); - action native A_PlaySound(sound whattoplay = "weapons/pistol", int slot = CHAN_BODY, float volume = 1.0, bool looping = false, float attenuation = ATTN_NORM); + action native A_PlaySound(sound whattoplay = "weapons/pistol", int slot = CHAN_BODY, float volume = 1.0, bool looping = false, float attenuation = ATTN_NORM, bool local = false); native void A_PlayWeaponSound(sound whattoplay); action native A_FLoopActiveSound(); action native A_LoopActiveSound(); From 477fb6d676d31ec7704be646a180f38088dd698d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 1 Nov 2016 21:44:33 +0100 Subject: [PATCH 1155/1509] Added missing copyrights --- .../fixedfunction/drawcolumncodegen.cpp | 21 +++++++++++++++++++ .../fixedfunction/drawcolumncodegen.h | 21 +++++++++++++++++++ .../fixedfunction/drawercodegen.cpp | 21 +++++++++++++++++++ src/r_compiler/fixedfunction/drawercodegen.h | 21 +++++++++++++++++++ .../fixedfunction/drawskycodegen.cpp | 21 +++++++++++++++++++ src/r_compiler/fixedfunction/drawskycodegen.h | 21 +++++++++++++++++++ .../fixedfunction/drawspancodegen.cpp | 21 +++++++++++++++++++ .../fixedfunction/drawspancodegen.h | 21 +++++++++++++++++++ .../fixedfunction/drawwallcodegen.cpp | 21 +++++++++++++++++++ .../fixedfunction/drawwallcodegen.h | 21 +++++++++++++++++++ src/r_compiler/llvm_include.h | 21 +++++++++++++++++++ src/r_compiler/llvmdrawers.cpp | 21 +++++++++++++++++++ src/r_compiler/llvmdrawers.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_barycentric_weight.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_bool.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_bool.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_float.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_float.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_float_ptr.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_float_ptr.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_for_block.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_for_block.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_function.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_function.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_if_block.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_if_block.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_int.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_int.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_int_ptr.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_int_ptr.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_phi.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_scope.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_scope.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_short.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_short.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_stack.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_struct_type.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_struct_type.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_ubyte.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_ubyte.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_ubyte_ptr.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_ubyte_ptr.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_value.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_value.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_vec16ub.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_vec16ub.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_vec4f.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_vec4f.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_vec4f_ptr.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_vec4f_ptr.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_vec4i.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_vec4i.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_vec4i_ptr.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_vec4i_ptr.h | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_vec8s.cpp | 21 +++++++++++++++++++ src/r_compiler/ssa/ssa_vec8s.h | 21 +++++++++++++++++++ src/r_swrenderer2.cpp | 21 +++++++++++++++++++ src/r_swrenderer2.h | 21 +++++++++++++++++++ src/r_thread.cpp | 21 +++++++++++++++++++ src/r_thread.h | 21 +++++++++++++++++++ 60 files changed, 1260 insertions(+) diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp index 71cdf8195..0ed58b943 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp @@ -1,3 +1,24 @@ +/* +** DrawColumn code generation +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "i_system.h" #include "r_compiler/llvm_include.h" diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.h b/src/r_compiler/fixedfunction/drawcolumncodegen.h index 5f2ad737d..ba453a076 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.h +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.h @@ -1,3 +1,24 @@ +/* +** DrawColumn code generation +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/fixedfunction/drawercodegen.cpp b/src/r_compiler/fixedfunction/drawercodegen.cpp index a4009c1f7..812ccafd7 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.cpp +++ b/src/r_compiler/fixedfunction/drawercodegen.cpp @@ -1,3 +1,24 @@ +/* +** Drawer code generation +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "i_system.h" #include "r_compiler/llvm_include.h" diff --git a/src/r_compiler/fixedfunction/drawercodegen.h b/src/r_compiler/fixedfunction/drawercodegen.h index 98451e150..4dda370fe 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.h +++ b/src/r_compiler/fixedfunction/drawercodegen.h @@ -1,3 +1,24 @@ +/* +** Drawer code generation +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/fixedfunction/drawskycodegen.cpp b/src/r_compiler/fixedfunction/drawskycodegen.cpp index f96d9fc1d..ae5b45032 100644 --- a/src/r_compiler/fixedfunction/drawskycodegen.cpp +++ b/src/r_compiler/fixedfunction/drawskycodegen.cpp @@ -1,3 +1,24 @@ +/* +** DrawSky code generation +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "i_system.h" #include "r_compiler/llvm_include.h" diff --git a/src/r_compiler/fixedfunction/drawskycodegen.h b/src/r_compiler/fixedfunction/drawskycodegen.h index a02f8dc2b..aaf4bdfeb 100644 --- a/src/r_compiler/fixedfunction/drawskycodegen.h +++ b/src/r_compiler/fixedfunction/drawskycodegen.h @@ -1,3 +1,24 @@ +/* +** DrawSky code generation +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/fixedfunction/drawspancodegen.cpp b/src/r_compiler/fixedfunction/drawspancodegen.cpp index 4404456ab..fac8411cc 100644 --- a/src/r_compiler/fixedfunction/drawspancodegen.cpp +++ b/src/r_compiler/fixedfunction/drawspancodegen.cpp @@ -1,3 +1,24 @@ +/* +** DrawSpan code generation +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "i_system.h" #include "r_compiler/llvm_include.h" diff --git a/src/r_compiler/fixedfunction/drawspancodegen.h b/src/r_compiler/fixedfunction/drawspancodegen.h index 20869ac2f..9ef3edd38 100644 --- a/src/r_compiler/fixedfunction/drawspancodegen.h +++ b/src/r_compiler/fixedfunction/drawspancodegen.h @@ -1,3 +1,24 @@ +/* +** DrawSpan code generation +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/fixedfunction/drawwallcodegen.cpp b/src/r_compiler/fixedfunction/drawwallcodegen.cpp index b820274ef..7c042f9be 100644 --- a/src/r_compiler/fixedfunction/drawwallcodegen.cpp +++ b/src/r_compiler/fixedfunction/drawwallcodegen.cpp @@ -1,3 +1,24 @@ +/* +** DrawWall code generation +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "i_system.h" #include "r_compiler/llvm_include.h" diff --git a/src/r_compiler/fixedfunction/drawwallcodegen.h b/src/r_compiler/fixedfunction/drawwallcodegen.h index 0e1cce5fc..6591fb9b6 100644 --- a/src/r_compiler/fixedfunction/drawwallcodegen.h +++ b/src/r_compiler/fixedfunction/drawwallcodegen.h @@ -1,3 +1,24 @@ +/* +** DrawWall code generation +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/llvm_include.h b/src/r_compiler/llvm_include.h index 75952d1f9..fa23f0c0c 100644 --- a/src/r_compiler/llvm_include.h +++ b/src/r_compiler/llvm_include.h @@ -1,3 +1,24 @@ +/* +** LLVM includes +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 2f8609f68..4ac2bf00f 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -1,3 +1,24 @@ +/* +** LLVM code generated drawers +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "i_system.h" #include "r_compiler/llvm_include.h" diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index e7386678e..5cbd05e4a 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -1,3 +1,24 @@ +/* +** LLVM code generated drawers +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_barycentric_weight.h b/src/r_compiler/ssa/ssa_barycentric_weight.h index 52117ccc6..1a07d6c75 100644 --- a/src/r_compiler/ssa/ssa_barycentric_weight.h +++ b/src/r_compiler/ssa/ssa_barycentric_weight.h @@ -1,3 +1,24 @@ +/* +** SSA barycentric weight and viewport calculations +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_bool.cpp b/src/r_compiler/ssa/ssa_bool.cpp index bfd9ba5ab..c3c4c72b4 100644 --- a/src/r_compiler/ssa/ssa_bool.cpp +++ b/src/r_compiler/ssa/ssa_bool.cpp @@ -1,3 +1,24 @@ +/* +** SSA boolean +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_bool.h" diff --git a/src/r_compiler/ssa/ssa_bool.h b/src/r_compiler/ssa/ssa_bool.h index 2ef79e49b..df8b66d51 100644 --- a/src/r_compiler/ssa/ssa_bool.h +++ b/src/r_compiler/ssa/ssa_bool.h @@ -1,3 +1,24 @@ +/* +** SSA boolean +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_float.cpp b/src/r_compiler/ssa/ssa_float.cpp index 4ec5c516d..07f18fb56 100644 --- a/src/r_compiler/ssa/ssa_float.cpp +++ b/src/r_compiler/ssa/ssa_float.cpp @@ -1,3 +1,24 @@ +/* +** SSA float32 +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_float.h" diff --git a/src/r_compiler/ssa/ssa_float.h b/src/r_compiler/ssa/ssa_float.h index 0edbcfcba..8f2f22ba6 100644 --- a/src/r_compiler/ssa/ssa_float.h +++ b/src/r_compiler/ssa/ssa_float.h @@ -1,3 +1,24 @@ +/* +** SSA float32 +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_float_ptr.cpp b/src/r_compiler/ssa/ssa_float_ptr.cpp index 9937328f6..5f97a75c5 100644 --- a/src/r_compiler/ssa/ssa_float_ptr.cpp +++ b/src/r_compiler/ssa/ssa_float_ptr.cpp @@ -1,3 +1,24 @@ +/* +** SSA float32 pointer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_float_ptr.h" diff --git a/src/r_compiler/ssa/ssa_float_ptr.h b/src/r_compiler/ssa/ssa_float_ptr.h index a9953eb81..66e462539 100644 --- a/src/r_compiler/ssa/ssa_float_ptr.h +++ b/src/r_compiler/ssa/ssa_float_ptr.h @@ -1,3 +1,24 @@ +/* +** SSA float32 pointer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_for_block.cpp b/src/r_compiler/ssa/ssa_for_block.cpp index 6039dab1f..45ffdd9a3 100644 --- a/src/r_compiler/ssa/ssa_for_block.cpp +++ b/src/r_compiler/ssa/ssa_for_block.cpp @@ -1,3 +1,24 @@ +/* +** LLVM for loop branching +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_for_block.h" diff --git a/src/r_compiler/ssa/ssa_for_block.h b/src/r_compiler/ssa/ssa_for_block.h index 9dddef4d6..b65fb1c8b 100644 --- a/src/r_compiler/ssa/ssa_for_block.h +++ b/src/r_compiler/ssa/ssa_for_block.h @@ -1,3 +1,24 @@ +/* +** LLVM for loop branching +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_function.cpp b/src/r_compiler/ssa/ssa_function.cpp index a326beaf7..751932e15 100644 --- a/src/r_compiler/ssa/ssa_function.cpp +++ b/src/r_compiler/ssa/ssa_function.cpp @@ -1,3 +1,24 @@ +/* +** LLVM function +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_function.h" diff --git a/src/r_compiler/ssa/ssa_function.h b/src/r_compiler/ssa/ssa_function.h index f1969c35b..faa8b03fe 100644 --- a/src/r_compiler/ssa/ssa_function.h +++ b/src/r_compiler/ssa/ssa_function.h @@ -1,3 +1,24 @@ +/* +** LLVM function +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_if_block.cpp b/src/r_compiler/ssa/ssa_if_block.cpp index 7187a0759..c95d7e350 100644 --- a/src/r_compiler/ssa/ssa_if_block.cpp +++ b/src/r_compiler/ssa/ssa_if_block.cpp @@ -1,3 +1,24 @@ +/* +** LLVM if statement branching +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_if_block.h" diff --git a/src/r_compiler/ssa/ssa_if_block.h b/src/r_compiler/ssa/ssa_if_block.h index 4f0c8a26b..e46276575 100644 --- a/src/r_compiler/ssa/ssa_if_block.h +++ b/src/r_compiler/ssa/ssa_if_block.h @@ -1,3 +1,24 @@ +/* +** LLVM if statement branching +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_int.cpp b/src/r_compiler/ssa/ssa_int.cpp index 6f2afce7f..78ea01595 100644 --- a/src/r_compiler/ssa/ssa_int.cpp +++ b/src/r_compiler/ssa/ssa_int.cpp @@ -1,3 +1,24 @@ +/* +** SSA int32 +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_int.h" diff --git a/src/r_compiler/ssa/ssa_int.h b/src/r_compiler/ssa/ssa_int.h index ef71e064a..a8700f80b 100644 --- a/src/r_compiler/ssa/ssa_int.h +++ b/src/r_compiler/ssa/ssa_int.h @@ -1,3 +1,24 @@ +/* +** SSA int32 +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_int_ptr.cpp b/src/r_compiler/ssa/ssa_int_ptr.cpp index daef1e7ab..f8acd1a19 100644 --- a/src/r_compiler/ssa/ssa_int_ptr.cpp +++ b/src/r_compiler/ssa/ssa_int_ptr.cpp @@ -1,3 +1,24 @@ +/* +** SSA int32 pointer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_int_ptr.h" diff --git a/src/r_compiler/ssa/ssa_int_ptr.h b/src/r_compiler/ssa/ssa_int_ptr.h index 968528365..04075c15e 100644 --- a/src/r_compiler/ssa/ssa_int_ptr.h +++ b/src/r_compiler/ssa/ssa_int_ptr.h @@ -1,3 +1,24 @@ +/* +** SSA int32 pointer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_phi.h b/src/r_compiler/ssa/ssa_phi.h index 89cbc8cf0..66f233b6d 100644 --- a/src/r_compiler/ssa/ssa_phi.h +++ b/src/r_compiler/ssa/ssa_phi.h @@ -1,3 +1,24 @@ +/* +** SSA phi node +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_scope.cpp b/src/r_compiler/ssa/ssa_scope.cpp index 7c6f090fe..64b7fad05 100644 --- a/src/r_compiler/ssa/ssa_scope.cpp +++ b/src/r_compiler/ssa/ssa_scope.cpp @@ -1,3 +1,24 @@ +/* +** SSA scope data +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_scope.h" diff --git a/src/r_compiler/ssa/ssa_scope.h b/src/r_compiler/ssa/ssa_scope.h index 1c9dfb362..0b0228558 100644 --- a/src/r_compiler/ssa/ssa_scope.h +++ b/src/r_compiler/ssa/ssa_scope.h @@ -1,3 +1,24 @@ +/* +** SSA scope data +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_short.cpp b/src/r_compiler/ssa/ssa_short.cpp index 017f3002a..8fe3f24e6 100644 --- a/src/r_compiler/ssa/ssa_short.cpp +++ b/src/r_compiler/ssa/ssa_short.cpp @@ -1,3 +1,24 @@ +/* +** SSA int16 +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_short.h" diff --git a/src/r_compiler/ssa/ssa_short.h b/src/r_compiler/ssa/ssa_short.h index 4a5343402..efb782b85 100644 --- a/src/r_compiler/ssa/ssa_short.h +++ b/src/r_compiler/ssa/ssa_short.h @@ -1,3 +1,24 @@ +/* +** SSA int16 +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_stack.h b/src/r_compiler/ssa/ssa_stack.h index d072f181e..24c807a8a 100644 --- a/src/r_compiler/ssa/ssa_stack.h +++ b/src/r_compiler/ssa/ssa_stack.h @@ -1,3 +1,24 @@ +/* +** LLVM stack variable +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_struct_type.cpp b/src/r_compiler/ssa/ssa_struct_type.cpp index d4ae2acb1..e97fd6d56 100644 --- a/src/r_compiler/ssa/ssa_struct_type.cpp +++ b/src/r_compiler/ssa/ssa_struct_type.cpp @@ -1,3 +1,24 @@ +/* +** LLVM struct +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_struct_type.h" diff --git a/src/r_compiler/ssa/ssa_struct_type.h b/src/r_compiler/ssa/ssa_struct_type.h index 67b056b32..f21dc92c3 100644 --- a/src/r_compiler/ssa/ssa_struct_type.h +++ b/src/r_compiler/ssa/ssa_struct_type.h @@ -1,3 +1,24 @@ +/* +** LLVM struct +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_ubyte.cpp b/src/r_compiler/ssa/ssa_ubyte.cpp index 6fe9c3bb1..628973ff2 100644 --- a/src/r_compiler/ssa/ssa_ubyte.cpp +++ b/src/r_compiler/ssa/ssa_ubyte.cpp @@ -1,3 +1,24 @@ +/* +** SSA uint8 +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_ubyte.h" diff --git a/src/r_compiler/ssa/ssa_ubyte.h b/src/r_compiler/ssa/ssa_ubyte.h index 41ed3939b..ef1390162 100644 --- a/src/r_compiler/ssa/ssa_ubyte.h +++ b/src/r_compiler/ssa/ssa_ubyte.h @@ -1,3 +1,24 @@ +/* +** SSA uint8 +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp index 18bafc689..5c0de68e3 100644 --- a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp +++ b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp @@ -1,3 +1,24 @@ +/* +** SSA uint8 pointer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_ubyte_ptr.h" diff --git a/src/r_compiler/ssa/ssa_ubyte_ptr.h b/src/r_compiler/ssa/ssa_ubyte_ptr.h index 167a5877d..b4567597e 100644 --- a/src/r_compiler/ssa/ssa_ubyte_ptr.h +++ b/src/r_compiler/ssa/ssa_ubyte_ptr.h @@ -1,3 +1,24 @@ +/* +** SSA uint8 pointer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_value.cpp b/src/r_compiler/ssa/ssa_value.cpp index 65f9da15d..33e293e6a 100644 --- a/src/r_compiler/ssa/ssa_value.cpp +++ b/src/r_compiler/ssa/ssa_value.cpp @@ -1,3 +1,24 @@ +/* +** SSA value +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_value.h" diff --git a/src/r_compiler/ssa/ssa_value.h b/src/r_compiler/ssa/ssa_value.h index d0d73043c..1df94b267 100644 --- a/src/r_compiler/ssa/ssa_value.h +++ b/src/r_compiler/ssa/ssa_value.h @@ -1,3 +1,24 @@ +/* +** SSA value +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_vec16ub.cpp b/src/r_compiler/ssa/ssa_vec16ub.cpp index 4a077382e..f3ad73294 100644 --- a/src/r_compiler/ssa/ssa_vec16ub.cpp +++ b/src/r_compiler/ssa/ssa_vec16ub.cpp @@ -1,3 +1,24 @@ +/* +** SSA vec16 uint8 +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_vec16ub.h" diff --git a/src/r_compiler/ssa/ssa_vec16ub.h b/src/r_compiler/ssa/ssa_vec16ub.h index 8f48c0c49..42f4ef3ee 100644 --- a/src/r_compiler/ssa/ssa_vec16ub.h +++ b/src/r_compiler/ssa/ssa_vec16ub.h @@ -1,3 +1,24 @@ +/* +** SSA vec16 uint8 +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_vec4f.cpp b/src/r_compiler/ssa/ssa_vec4f.cpp index dc6f9a716..5e3c37c2d 100644 --- a/src/r_compiler/ssa/ssa_vec4f.cpp +++ b/src/r_compiler/ssa/ssa_vec4f.cpp @@ -1,3 +1,24 @@ +/* +** SSA vec4 float +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_vec4f.h" diff --git a/src/r_compiler/ssa/ssa_vec4f.h b/src/r_compiler/ssa/ssa_vec4f.h index 6d4ae6335..d8a2c5d01 100644 --- a/src/r_compiler/ssa/ssa_vec4f.h +++ b/src/r_compiler/ssa/ssa_vec4f.h @@ -1,3 +1,24 @@ +/* +** SSA vec4 float +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_vec4f_ptr.cpp b/src/r_compiler/ssa/ssa_vec4f_ptr.cpp index 31c23f2bd..37f97faff 100644 --- a/src/r_compiler/ssa/ssa_vec4f_ptr.cpp +++ b/src/r_compiler/ssa/ssa_vec4f_ptr.cpp @@ -1,3 +1,24 @@ +/* +** SSA vec4 float pointer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_vec4f_ptr.h" diff --git a/src/r_compiler/ssa/ssa_vec4f_ptr.h b/src/r_compiler/ssa/ssa_vec4f_ptr.h index 15192352a..46f31ef6d 100644 --- a/src/r_compiler/ssa/ssa_vec4f_ptr.h +++ b/src/r_compiler/ssa/ssa_vec4f_ptr.h @@ -1,3 +1,24 @@ +/* +** SSA vec4 float pointer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_vec4i.cpp b/src/r_compiler/ssa/ssa_vec4i.cpp index ac36172f0..17abaf37d 100644 --- a/src/r_compiler/ssa/ssa_vec4i.cpp +++ b/src/r_compiler/ssa/ssa_vec4i.cpp @@ -1,3 +1,24 @@ +/* +** SSA vec4 int32 +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_vec4i.h" diff --git a/src/r_compiler/ssa/ssa_vec4i.h b/src/r_compiler/ssa/ssa_vec4i.h index 420ab021e..2035b5457 100644 --- a/src/r_compiler/ssa/ssa_vec4i.h +++ b/src/r_compiler/ssa/ssa_vec4i.h @@ -1,3 +1,24 @@ +/* +** SSA vec4 int32 +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_vec4i_ptr.cpp b/src/r_compiler/ssa/ssa_vec4i_ptr.cpp index f75ccd43f..793d88fb5 100644 --- a/src/r_compiler/ssa/ssa_vec4i_ptr.cpp +++ b/src/r_compiler/ssa/ssa_vec4i_ptr.cpp @@ -1,3 +1,24 @@ +/* +** SSA vec4 int32 pointer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_vec4i_ptr.h" diff --git a/src/r_compiler/ssa/ssa_vec4i_ptr.h b/src/r_compiler/ssa/ssa_vec4i_ptr.h index 257b4e34f..e4d8134bb 100644 --- a/src/r_compiler/ssa/ssa_vec4i_ptr.h +++ b/src/r_compiler/ssa/ssa_vec4i_ptr.h @@ -1,3 +1,24 @@ +/* +** SSA vec4 int32 pointer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_compiler/ssa/ssa_vec8s.cpp b/src/r_compiler/ssa/ssa_vec8s.cpp index 6016b551f..51bb5adca 100644 --- a/src/r_compiler/ssa/ssa_vec8s.cpp +++ b/src/r_compiler/ssa/ssa_vec8s.cpp @@ -1,3 +1,24 @@ +/* +** SSA vec8 int16 +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include "r_compiler/llvm_include.h" #include "ssa_vec8s.h" diff --git a/src/r_compiler/ssa/ssa_vec8s.h b/src/r_compiler/ssa/ssa_vec8s.h index 40263773b..be320804e 100644 --- a/src/r_compiler/ssa/ssa_vec8s.h +++ b/src/r_compiler/ssa/ssa_vec8s.h @@ -1,3 +1,24 @@ +/* +** SSA vec8 int16 +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_swrenderer2.cpp b/src/r_swrenderer2.cpp index f7fb6afb9..8fcf90ac9 100644 --- a/src/r_swrenderer2.cpp +++ b/src/r_swrenderer2.cpp @@ -1,3 +1,24 @@ +/* +** Experimental Doom software renderer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include #include "templates.h" diff --git a/src/r_swrenderer2.h b/src/r_swrenderer2.h index 1004b66bd..eaa734c87 100644 --- a/src/r_swrenderer2.h +++ b/src/r_swrenderer2.h @@ -1,3 +1,24 @@ +/* +** Experimental Doom software renderer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once diff --git a/src/r_thread.cpp b/src/r_thread.cpp index 4d0a2100c..bbb3faf3f 100644 --- a/src/r_thread.cpp +++ b/src/r_thread.cpp @@ -1,3 +1,24 @@ +/* +** Renderer multithreading framework +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #include #include "templates.h" diff --git a/src/r_thread.h b/src/r_thread.h index e0aca2a01..3271d8050 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -1,3 +1,24 @@ +/* +** Renderer multithreading framework +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ #pragma once From 5814270980c027a5a21fe311e2fb61a9a67b86c6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 1 Nov 2016 22:58:53 +0100 Subject: [PATCH 1156/1509] Fix wrapping and scaling issue for the U texture coordinate for sprites --- src/r_things.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index cad434fa5..6ef4e8027 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -954,15 +954,14 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor return; tx += tex->GetWidth() * thingxscalemul; - double dtx2 = tx * xscale; - x2 = centerx + xs_RoundToInt(dtx2); + x2 = centerx + xs_RoundToInt(tx * xscale); // off the left side or too small? if ((x2 < WindowLeft || x2 <= x1)) return; xscale = spriteScale.X * xscale / tex->Scale.X; - iscale = (fixed_t)(tex->GetWidth() / (dtx2 - dtx1) * FRACUNIT); + iscale = (fixed_t)(FRACUNIT / xscale); // Round towards zero to avoid wrapping in edge cases double yscale = spriteScale.Y / tex->Scale.Y; @@ -990,7 +989,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor vis->xiscale = iscale; } - vis->startfrac += (fixed_t)(vis->xiscale * (vis->x1 - centerx - dtx1 + 0.5 * thingxscalemul)); + vis->startfrac += (fixed_t)(vis->xiscale * (vis->x1 - centerx + 0.5 - dtx1)); } else { From 356830a8c836647154784e62823a8ce5a1d4f35b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 3 Nov 2016 12:02:07 +0100 Subject: [PATCH 1157/1509] Add CPU misdetection workaround for the Pentium G840 and a llvm_cpu CVAR that can force codegen to a specific CPU architecture --- src/r_compiler/llvmdrawers.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 4ac2bf00f..ce5024bba 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -35,6 +35,14 @@ #include "r_compiler/ssa/ssa_struct_type.h" #include "r_compiler/ssa/ssa_value.h" #include "r_compiler/ssa/ssa_barycentric_weight.h" +#include "x86.h" +#include "c_cvars.h" +#include "version.h" + +CUSTOM_CVAR(String, llvm_cpu, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL) +{ + Printf("You must restart " GAMENAME " for this change to take effect.\n"); +} class LLVMProgram { @@ -485,12 +493,22 @@ void LLVMProgram::CreateEE() std::string errorstring; + std::string mcpu = sys::getHostCPUName(); + if (std::string(CPU.CPUString).find("G840") && mcpu == "sandybridge") + mcpu = "westmere"; // Pentium G840 is misdetected as a sandy bridge CPU + + if (stricmp(llvm_cpu, "auto") != 0) + { + mcpu = llvm_cpu; + Printf("Overriding LLVM CPU target to %s\n", mcpu.c_str()); + } + llvm::Module *module = mModule.get(); EngineBuilder engineBuilder(std::move(mModule)); engineBuilder.setErrorStr(&errorstring); engineBuilder.setOptLevel(CodeGenOpt::Aggressive); engineBuilder.setEngineKind(EngineKind::JIT); - engineBuilder.setMCPU(sys::getHostCPUName()); + engineBuilder.setMCPU(mcpu); machine = engineBuilder.selectTarget(); if (!machine) I_FatalError("Could not create LLVM target machine"); From 90c8b3370a0e0915e512705c5752e734c2b05eb5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 3 Nov 2016 12:51:07 +0100 Subject: [PATCH 1158/1509] Fix mipmap sampling bug --- src/r_draw.cpp | 2 +- src/r_segs.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 45758ee61..0a2c8553e 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -1073,7 +1073,7 @@ extern "C" BYTE *ds_curcolormap, *ds_cursource, *ds_curtiltedsource; void R_SetSpanSource(FTexture *tex) { ds_source = r_swtruecolor ? (const BYTE*)tex->GetPixelsBgra() : tex->GetPixels(); - ds_source_mipmapped = tex->Mipmapped(); + ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1; #ifdef X86_ASM if (!r_swtruecolor && ds_cursource != ds_source) { diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 108463e38..a8267a663 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1159,12 +1159,12 @@ WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xof int mipmap_offset = 0; int mip_width = texture->GetWidth(); int mip_height = texture->GetHeight(); - if (r_mipmap && texture->Mipmapped()) + if (r_mipmap && texture->Mipmapped() && mip_width > 1 && mip_height > 1) { uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width); double texture_bias = 1.7f; double level = MAX(magnitude - 3.0, 0.0); - while (level > texture_bias) + while (level > texture_bias && mip_width > 1 && mip_height > 1) { mipmap_offset += mip_width * mip_height; level *= 0.5f; From 6ef5cdebb29093727838858632de4a999c7c6421 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 3 Nov 2016 19:41:51 +0100 Subject: [PATCH 1159/1509] - slider fixes. --- wadsrc/static/menudef.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 6bbf8d5da..658e729da 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -675,7 +675,7 @@ OptionMenu "VideoOptions" Slider "$DSPLYMNU_SCREENSIZE", "screenblocks", 3.0, 12.0, 1.0, 0 Slider "$DSPLYMNU_GAMMA", "Gamma", 0.75, 3.0, 0.05, 2 - Slider "$DSPLYMNU_BRIGHTNESS", "vid_brightness", -0.8,0.8, 0.05 + Slider "$DSPLYMNU_BRIGHTNESS", "vid_brightness", -0.8,0.8, 0.05,2 Slider "$DSPLYMNU_CONTRAST", "vid_contrast", 0.1, 3.0, 0.1 Option "$DSPLYMNU_HWGAMMA", "vid_hwgamma", "HWGammaModes" From 12a1755edf1587fd8ee095aaa5d8978af01f37cc Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 4 Nov 2016 01:39:53 +0100 Subject: [PATCH 1160/1509] Move texture info to R_DrawMaskedColumn and add bounds checking --- src/r_segs.cpp | 8 +------ src/r_things.cpp | 60 ++++++++++++++++++++++++++---------------------- src/r_things.h | 2 +- src/v_draw.cpp | 42 +++------------------------------ 4 files changed, 37 insertions(+), 75 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index a8267a663..e1925f66a 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -197,13 +197,7 @@ static void BlastMaskedColumn (FTexture *tex, bool useRt) // when forming multipatched textures (see r_data.c). // draw the texture - const FTexture::Span *spans; - const BYTE *pixels; - if (r_swtruecolor && !drawer_needs_pal_input) - pixels = (const BYTE *)tex->GetColumnBgra(maskedtexturecol[dc_x] >> FRACBITS, &spans); - else - pixels = tex->GetColumn(maskedtexturecol[dc_x] >> FRACBITS, &spans); - R_DrawMaskedColumn(pixels, spans, useRt); + R_DrawMaskedColumn(tex, maskedtexturecol[dc_x], useRt); rw_light += rw_lightstep; spryscale += rw_scalestep; } diff --git a/src/r_things.cpp b/src/r_things.cpp index bde2bfc66..a04676492 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -251,9 +251,27 @@ double sprtopscreen; bool sprflipvert; -void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span, bool useRt) +void R_DrawMaskedColumn (FTexture *tex, fixed_t col, bool useRt, bool unmasked) { + const FTexture::Span *span; + const BYTE *column; + if (r_swtruecolor && !drawer_needs_pal_input) + column = (const BYTE *)tex->GetColumnBgra(col >> FRACBITS, &span); + else + column = tex->GetColumn(col >> FRACBITS, &span); + + FTexture::Span unmaskedSpan[2]; + if (unmasked) + { + span = unmaskedSpan; + unmaskedSpan[0].TopOffset = 0; + unmaskedSpan[0].Length = tex->GetHeight(); + unmaskedSpan[1].TopOffset = 0; + unmaskedSpan[1].Length = 0; + } + int pixelsize = r_swtruecolor ? 4 : 1; + while (span->Length != 0) { const int length = span->Length; @@ -283,6 +301,15 @@ void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span, bool us dc_source = column; dc_dest = (ylookup[dc_yl] + dc_x) * pixelsize + dc_destorg; dc_count = dc_yh - dc_yl + 1; + + fixed_t maxfrac = ((top + length) << FRACBITS) - 1; + dc_texturefrac = MAX(dc_texturefrac, 0); + dc_texturefrac = MIN(dc_texturefrac, maxfrac); + if (dc_iscale > 0) + dc_count = MIN(dc_count, (maxfrac - dc_texturefrac + dc_iscale - 1) / dc_iscale); + else if (dc_iscale < 0) + dc_count = MIN(dc_count, (dc_texturefrac - dc_iscale) / (-dc_iscale)); + if (useRt) hcolfunc_pre(); else @@ -364,8 +391,6 @@ static inline bool R_ClipSpriteColumnWithPortals(vissprite_t* spr) // void R_DrawVisSprite (vissprite_t *vis) { - const BYTE *pixels; - const FTexture::Span *spans; fixed_t frac; FTexture *tex; int x2, stop4; @@ -432,13 +457,8 @@ void R_DrawVisSprite (vissprite_t *vis) { while ((dc_x < stop4) && (dc_x & 3)) { - if (r_swtruecolor && !drawer_needs_pal_input) - pixels = (const BYTE *)tex->GetColumnBgra (frac >> FRACBITS, &spans); - else - pixels = tex->GetColumn (frac >> FRACBITS, &spans); - if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (pixels, spans, false); + R_DrawMaskedColumn (tex, frac, false); dc_x++; frac += xiscale; } @@ -448,13 +468,8 @@ void R_DrawVisSprite (vissprite_t *vis) rt_initcols(nullptr); for (int zz = 4; zz; --zz) { - if (r_swtruecolor && !drawer_needs_pal_input) - pixels = (const BYTE *)tex->GetColumnBgra (frac >> FRACBITS, &spans); - else - pixels = tex->GetColumn (frac >> FRACBITS, &spans); - if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (pixels, spans, true); + R_DrawMaskedColumn (tex, frac, true); dc_x++; frac += xiscale; } @@ -463,13 +478,8 @@ void R_DrawVisSprite (vissprite_t *vis) while (dc_x < x2) { - if (r_swtruecolor && !drawer_needs_pal_input) - pixels = (const BYTE *)tex->GetColumnBgra (frac >> FRACBITS, &spans); - else - pixels = tex->GetColumn (frac >> FRACBITS, &spans); - if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (pixels, spans, false); + R_DrawMaskedColumn (tex, frac, false); dc_x++; frac += xiscale; } @@ -623,14 +633,8 @@ void R_WallSpriteColumn (bool useRt) else sprtopscreen = CenterY - dc_texturemid * spryscale; - const BYTE *column; - const FTexture::Span *spans; - if (r_swtruecolor && !drawer_needs_pal_input) - column = (const BYTE *)WallSpriteTile->GetColumnBgra (lwall[dc_x] >> FRACBITS, &spans); - else - column = WallSpriteTile->GetColumn (lwall[dc_x] >> FRACBITS, &spans); dc_texturefrac = 0; - R_DrawMaskedColumn(column, spans, useRt); + R_DrawMaskedColumn(WallSpriteTile, lwall[dc_x], useRt); rw_light += rw_lightstep; } diff --git a/src/r_things.h b/src/r_things.h index e8ffbf5ca..e35489892 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -126,7 +126,7 @@ extern double pspriteyscale; extern FTexture *WallSpriteTile; -void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *spans, bool useRt); +void R_DrawMaskedColumn (FTexture *texture, fixed_t column, bool useRt, bool unmasked = false); void R_WallSpriteColumn (bool useRt); void R_CacheSprite (spritedef_t *sprite); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index ddcbb381c..2397fc48c 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -133,8 +133,6 @@ void DCanvas::DrawTexture (FTexture *img, double x, double y, int tags_first, .. void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) { #ifndef NO_SWRENDER - FTexture::Span unmaskedSpan[2]; - const FTexture::Span **spanptr, *spans; static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH]; const BYTE *translation = NULL; @@ -144,15 +142,6 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) R_InitColumnDrawers(); } - if (parms.masked) - { - spanptr = &spans; - } - else - { - spanptr = NULL; - } - if (APART(parms.colorOverlay) != 0) { // The software renderer cannot invert the source without inverting the overlay @@ -217,18 +206,8 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) if (mode != DontDraw) { - const BYTE *pixels; int stop4; - if (spanptr == NULL) - { // Create a single span for forced unmasked images - spans = unmaskedSpan; - unmaskedSpan[0].TopOffset = 0; - unmaskedSpan[0].Length = img->GetHeight(); - unmaskedSpan[1].TopOffset = 0; - unmaskedSpan[1].Length = 0; - } - double centeryback = CenterY; CenterY = 0; @@ -320,12 +299,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) { while ((dc_x < stop4) && (dc_x & 3)) { - if (r_swtruecolor && !drawer_needs_pal_input) - pixels = (const BYTE *)img->GetColumnBgra(frac >> FRACBITS, spanptr); - else - pixels = img->GetColumn(frac >> FRACBITS, spanptr); - - R_DrawMaskedColumn(pixels, spans, false); + R_DrawMaskedColumn(img, frac, false, !parms.masked); dc_x++; frac += xiscale_i; } @@ -335,12 +309,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) rt_initcols(nullptr); for (int zz = 4; zz; --zz) { - if (r_swtruecolor && !drawer_needs_pal_input) - pixels = (const BYTE *)img->GetColumnBgra(frac >> FRACBITS, spanptr); - else - pixels = img->GetColumn(frac >> FRACBITS, spanptr); - - R_DrawMaskedColumn(pixels, spans, true); + R_DrawMaskedColumn(img, frac, true, !parms.masked); dc_x++; frac += xiscale_i; } @@ -349,12 +318,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) while (dc_x < x2_i) { - if (r_swtruecolor && !drawer_needs_pal_input) - pixels = (const BYTE *)img->GetColumnBgra(frac >> FRACBITS, spanptr); - else - pixels = img->GetColumn(frac >> FRACBITS, spanptr); - - R_DrawMaskedColumn(pixels, spans, false); + R_DrawMaskedColumn(img, frac, false, !parms.masked); dc_x++; frac += xiscale_i; } From 4b18530047085cf480b873198dda3010037c4854 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 5 Nov 2016 11:29:50 +0100 Subject: [PATCH 1161/1509] Add linear filtering to column drawers and fix offsetting bug with wall/span linear filters --- .../fixedfunction/drawcolumncodegen.cpp | 142 +++++++++++++----- .../fixedfunction/drawcolumncodegen.h | 13 +- .../fixedfunction/drawercodegen.cpp | 42 ------ src/r_compiler/fixedfunction/drawercodegen.h | 4 - .../fixedfunction/drawspancodegen.cpp | 28 +++- .../fixedfunction/drawspancodegen.h | 1 + .../fixedfunction/drawwallcodegen.cpp | 25 ++- .../fixedfunction/drawwallcodegen.h | 1 + src/r_compiler/llvmdrawers.cpp | 3 + src/r_compiler/llvmdrawers.h | 6 +- src/r_draw.cpp | 6 +- src/r_draw_rgba.cpp | 5 + src/r_drawt_rgba.cpp | 3 + src/r_segs.cpp | 1 + src/r_things.cpp | 125 +++++++++++++++ 15 files changed, 310 insertions(+), 95 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp index 0ed58b943..45a75cdcb 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp @@ -36,30 +36,35 @@ void DrawColumnCodegen::Generate(DrawColumnVariant variant, DrawColumnMethod met { dest = args[0][0].load(true); source = args[0][1].load(true); - colormap = args[0][2].load(true); - translation = args[0][3].load(true); - basecolors = args[0][4].load(true); - pitch = args[0][5].load(true); - count = args[0][6].load(true); - dest_y = args[0][7].load(true); + source2 = args[0][2].load(true); + colormap = args[0][3].load(true); + translation = args[0][4].load(true); + basecolors = args[0][5].load(true); + pitch = args[0][6].load(true); + count = args[0][7].load(true); + dest_y = args[0][8].load(true); if (method == DrawColumnMethod::Normal) - iscale = args[0][8].load(true); - texturefrac = args[0][9].load(true); - light = args[0][10].load(true); - color = SSAVec4i::unpack(args[0][11].load(true)); - srccolor = SSAVec4i::unpack(args[0][12].load(true)); - srcalpha = args[0][13].load(true); - destalpha = args[0][14].load(true); - SSAShort light_alpha = args[0][15].load(true); - SSAShort light_red = args[0][16].load(true); - SSAShort light_green = args[0][17].load(true); - SSAShort light_blue = args[0][18].load(true); - SSAShort fade_alpha = args[0][19].load(true); - SSAShort fade_red = args[0][20].load(true); - SSAShort fade_green = args[0][21].load(true); - SSAShort fade_blue = args[0][22].load(true); - SSAShort desaturate = args[0][23].load(true); - SSAInt flags = args[0][24].load(true); + { + iscale = args[0][9].load(true); + texturefracx = args[0][10].load(true); + textureheight = args[0][11].load(true); + } + texturefrac = args[0][12].load(true); + light = args[0][13].load(true); + color = SSAVec4i::unpack(args[0][14].load(true)); + srccolor = SSAVec4i::unpack(args[0][15].load(true)); + srcalpha = args[0][16].load(true); + destalpha = args[0][17].load(true); + SSAShort light_alpha = args[0][18].load(true); + SSAShort light_red = args[0][19].load(true); + SSAShort light_green = args[0][20].load(true); + SSAShort light_blue = args[0][21].load(true); + SSAShort fade_alpha = args[0][22].load(true); + SSAShort fade_red = args[0][23].load(true); + SSAShort fade_green = args[0][24].load(true); + SSAShort fade_blue = args[0][25].load(true); + SSAShort desaturate = args[0][26].load(true); + SSAInt flags = args[0][27].load(true); shade_constants.light = SSAVec4i(light_blue.zext_int(), light_green.zext_int(), light_red.zext_int(), light_alpha.zext_int()); shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); shade_constants.desaturate = desaturate.zext_int(); @@ -71,6 +76,7 @@ void DrawColumnCodegen::Generate(DrawColumnVariant variant, DrawColumnMethod met thread.temp = thread_data[0][4].load(true); is_simple_shade = (flags & DrawColumnArgs::simple_shade) == SSAInt(DrawColumnArgs::simple_shade); + is_nearest_filter = (flags & DrawColumnArgs::nearest_filter) == SSAInt(DrawColumnArgs::nearest_filter); count = count_for_thread(dest_y, count, thread); dest = dest_for_thread(dest_y, pitch, dest, thread); @@ -79,21 +85,40 @@ void DrawColumnCodegen::Generate(DrawColumnVariant variant, DrawColumnMethod met { stack_frac.store(texturefrac + iscale * skipped_by_thread(dest_y, thread)); iscale = iscale * thread.num_cores; + one = (1 << 30) / textureheight; + + SSAIfBlock branch; + branch.if_block(is_simple_shade); + LoopShade(variant, method, true); + branch.else_block(); + LoopShade(variant, method, false); + branch.end_block(); } else { source = thread.temp[((dest_y + skipped_by_thread(dest_y, thread)) * 4 + texturefrac) * 4]; - } + SSAIfBlock branch; + branch.if_block(is_simple_shade); + Loop(variant, method, true, true); + branch.else_block(); + Loop(variant, method, false, true); + branch.end_block(); + } +} + +void DrawColumnCodegen::LoopShade(DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade) +{ SSAIfBlock branch; - branch.if_block(is_simple_shade); - Loop(variant, method, true); + branch.if_block(is_nearest_filter); + Loop(variant, method, isSimpleShade, true); branch.else_block(); - Loop(variant, method, false); + stack_frac.store(stack_frac.load() - (one >> 1)); + Loop(variant, method, isSimpleShade, false); branch.end_block(); } -void DrawColumnCodegen::Loop(DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade) +void DrawColumnCodegen::Loop(DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade, bool isNearestFilter) { SSAInt sincr; if (method != DrawColumnMethod::Normal) @@ -109,9 +134,10 @@ void DrawColumnCodegen::Loop(DrawColumnVariant variant, DrawColumnMethod method, if (method == DrawColumnMethod::Normal) { frac = stack_frac.load(); - sample_index = frac >> FRACBITS; - if (!IsPaletteInput(variant)) - sample_index = sample_index * 4; + if (IsPaletteInput(variant)) + sample_index = frac >> FRACBITS; + else + sample_index = frac; } else { @@ -140,7 +166,7 @@ void DrawColumnCodegen::Loop(DrawColumnVariant variant, DrawColumnMethod method, SSAVec4i outcolor[4]; for (int i = 0; i < numColumns; i++) - outcolor[i] = ProcessPixel(sample_index + i * 4, bgcolor[i], variant, isSimpleShade); + outcolor[i] = ProcessPixel(sample_index + i * 4, bgcolor[i], variant, method, isSimpleShade, isNearestFilter); if (numColumns == 4) { @@ -186,7 +212,7 @@ bool DrawColumnCodegen::IsPaletteInput(DrawColumnVariant variant) } } -SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade) +SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade, bool isNearestFilter) { SSAInt alpha, inv_alpha; SSAVec4i fg; @@ -194,22 +220,22 @@ SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, { default: case DrawColumnVariant::DrawCopy: - return blend_copy(Sample(sample_index)); + return blend_copy(Sample(sample_index, method, isNearestFilter)); case DrawColumnVariant::Draw: - return blend_copy(Shade(Sample(sample_index), isSimpleShade)); + return blend_copy(Shade(Sample(sample_index, method, isNearestFilter), isSimpleShade)); case DrawColumnVariant::DrawAdd: case DrawColumnVariant::DrawAddClamp: - fg = Shade(Sample(sample_index), isSimpleShade); + fg = Shade(Sample(sample_index, method, isNearestFilter), isSimpleShade); return blend_add(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha)); case DrawColumnVariant::DrawShaded: alpha = SSAInt::MAX(SSAInt::MIN(ColormapSample(sample_index), SSAInt(64)), SSAInt(0)) * 4; inv_alpha = 256 - alpha; return blend_add(color, bgcolor, alpha, inv_alpha); case DrawColumnVariant::DrawSubClamp: - fg = Shade(Sample(sample_index), isSimpleShade); + fg = Shade(Sample(sample_index, method, isNearestFilter), isSimpleShade); return blend_sub(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha)); case DrawColumnVariant::DrawRevSubClamp: - fg = Shade(Sample(sample_index), isSimpleShade); + fg = Shade(Sample(sample_index, method, isNearestFilter), isSimpleShade); return blend_revsub(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha)); case DrawColumnVariant::DrawTranslated: return blend_copy(Shade(TranslateSample(sample_index), isSimpleShade)); @@ -285,9 +311,45 @@ SSAVec4i DrawColumnCodegen::ProcessPixelPal(SSAInt sample_index, SSAVec4i bgcolo } } -SSAVec4i DrawColumnCodegen::Sample(SSAInt sample_index) +SSAVec4i DrawColumnCodegen::Sample(SSAInt frac, DrawColumnMethod method, bool isNearestFilter) { - return source[sample_index].load_vec4ub(true); + if (method == DrawColumnMethod::Normal) + { + if (isNearestFilter) + { + SSAInt sample_index = (((frac << 2) >> FRACBITS) * textureheight) >> FRACBITS; + return source[sample_index * 4].load_vec4ub(false); + } + else + { + return SampleLinear(source, source2, texturefracx, frac, one, textureheight); + } + } + else + { + return source[frac].load_vec4ub(true); + } +} + +SSAVec4i DrawColumnCodegen::SampleLinear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height) +{ + // Clamp to edge + SSAInt frac_y0 = (SSAInt::MAX(SSAInt::MIN(texturefracy, SSAInt((1 << 30) - 1)), SSAInt(0)) >> (FRACBITS - 2)) * height; + SSAInt frac_y1 = (SSAInt::MAX(SSAInt::MIN(texturefracy + one, SSAInt((1 << 30) - 1)), SSAInt(0)) >> (FRACBITS - 2)) * height; + SSAInt y0 = frac_y0 >> FRACBITS; + SSAInt y1 = frac_y1 >> FRACBITS; + + SSAVec4i p00 = col0[y0 * 4].load_vec4ub(true); + SSAVec4i p01 = col0[y1 * 4].load_vec4ub(true); + SSAVec4i p10 = col1[y0 * 4].load_vec4ub(true); + SSAVec4i p11 = col1[y1 * 4].load_vec4ub(true); + + SSAInt inv_b = texturefracx; + SSAInt inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; + SSAInt a = 16 - inv_a; + SSAInt b = 16 - inv_b; + + return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; } SSAInt DrawColumnCodegen::ColormapSample(SSAInt sample_index) diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.h b/src/r_compiler/fixedfunction/drawcolumncodegen.h index ba453a076..2c44edc5c 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.h +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.h @@ -58,10 +58,12 @@ public: void Generate(DrawColumnVariant variant, DrawColumnMethod method, SSAValue args, SSAValue thread_data); private: - void Loop(DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade); - SSAVec4i ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade); + void LoopShade(DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade); + void Loop(DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade, bool isNearestFilter); + SSAVec4i ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade, bool isNearestFilter); SSAVec4i ProcessPixelPal(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade); - SSAVec4i Sample(SSAInt frac); + SSAVec4i Sample(SSAInt frac, DrawColumnMethod method, bool isNearestFilter); + SSAVec4i SampleLinear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height); SSAInt ColormapSample(SSAInt frac); SSAVec4i TranslateSample(SSAInt frac); SSAInt TranslateSamplePal(SSAInt frac); @@ -73,6 +75,7 @@ private: SSAUBytePtr dest; SSAUBytePtr source; + SSAUBytePtr source2; SSAUBytePtr colormap; SSAUBytePtr translation; SSAUBytePtr basecolors; @@ -80,6 +83,9 @@ private: SSAInt count; SSAInt dest_y; SSAInt iscale; + SSAInt texturefracx; + SSAInt textureheight; + SSAInt one; SSAInt texturefrac; SSAInt light; SSAVec4i color; @@ -87,6 +93,7 @@ private: SSAInt srcalpha; SSAInt destalpha; SSABool is_simple_shade; + SSABool is_nearest_filter; SSAShadeConstants shade_constants; SSAWorkerThread thread; }; diff --git a/src/r_compiler/fixedfunction/drawercodegen.cpp b/src/r_compiler/fixedfunction/drawercodegen.cpp index 812ccafd7..761023cef 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.cpp +++ b/src/r_compiler/fixedfunction/drawercodegen.cpp @@ -139,45 +139,3 @@ SSAInt DrawerCodegen::calc_blend_bgalpha(SSAVec4i fg, SSAInt destalpha) SSAInt inv_alpha = 256 - alpha; return (destalpha * alpha + 256 * inv_alpha + 128) >> 8; } - -SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height) -{ - SSAInt frac_y0 = (texturefracy >> FRACBITS) * height; - SSAInt frac_y1 = ((texturefracy + one) >> FRACBITS) * height; - SSAInt y0 = frac_y0 >> FRACBITS; - SSAInt y1 = frac_y1 >> FRACBITS; - - SSAVec4i p00 = col0[y0 * 4].load_vec4ub(true); - SSAVec4i p01 = col0[y1 * 4].load_vec4ub(true); - SSAVec4i p10 = col1[y0 * 4].load_vec4ub(true); - SSAVec4i p11 = col1[y1 * 4].load_vec4ub(true); - - SSAInt inv_b = texturefracx; - SSAInt a = (frac_y1 >> (FRACBITS - 4)) & 15; - SSAInt inv_a = 16 - a; - SSAInt b = 16 - inv_b; - - return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; -} - -SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits) -{ - SSAInt xshift = (32 - xbits); - SSAInt yshift = (32 - ybits); - SSAInt xmask = (SSAInt(1) << xshift) - 1; - SSAInt ymask = (SSAInt(1) << yshift) - 1; - SSAInt x = xfrac >> xbits; - SSAInt y = yfrac >> ybits; - - SSAVec4i p00 = texture[((y & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(true); - SSAVec4i p01 = texture[(((y + 1) & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(true); - SSAVec4i p10 = texture[((y & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(true); - SSAVec4i p11 = texture[(((y + 1) & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(true); - - SSAInt inv_b = (xfrac >> (xbits - 4)) & 15; - SSAInt inv_a = (yfrac >> (ybits - 4)) & 15; - SSAInt a = 16 - inv_a; - SSAInt b = 16 - inv_b; - - return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; -} diff --git a/src/r_compiler/fixedfunction/drawercodegen.h b/src/r_compiler/fixedfunction/drawercodegen.h index 4dda370fe..5de52dca1 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.h +++ b/src/r_compiler/fixedfunction/drawercodegen.h @@ -88,8 +88,4 @@ public: // Calculates the final alpha values to be used when combined with the source texture alpha channel SSAInt calc_blend_bgalpha(SSAVec4i fg, SSAInt destalpha); - - // SampleBgra - SSAVec4i sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height); - SSAVec4i sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits); }; diff --git a/src/r_compiler/fixedfunction/drawspancodegen.cpp b/src/r_compiler/fixedfunction/drawspancodegen.cpp index fac8411cc..0c6bd683f 100644 --- a/src/r_compiler/fixedfunction/drawspancodegen.cpp +++ b/src/r_compiler/fixedfunction/drawspancodegen.cpp @@ -89,6 +89,8 @@ void DrawSpanCodegen::LoopShade(DrawSpanVariant variant, bool isSimpleShade) branch.if_block(is_nearest_filter); LoopFilter(variant, isSimpleShade, true); branch.else_block(); + stack_xfrac.store(stack_xfrac.load() - (SSAInt(1) << (31 - xbits))); + stack_yfrac.store(stack_yfrac.load() - (SSAInt(1) << (31 - ybits))); LoopFilter(variant, isSimpleShade, false); branch.end_block(); } @@ -187,15 +189,37 @@ SSAVec4i DrawSpanCodegen::Sample(SSAInt xfrac, SSAInt yfrac, bool isNearestFilte { if (is64x64) { - return sample_linear(source, xfrac, yfrac, SSAInt(26), SSAInt(26)); + return SampleLinear(source, xfrac, yfrac, SSAInt(26), SSAInt(26)); } else { - return sample_linear(source, xfrac, yfrac, 32 - xbits, 32 - ybits); + return SampleLinear(source, xfrac, yfrac, 32 - xbits, 32 - ybits); } } } +SSAVec4i DrawSpanCodegen::SampleLinear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits) +{ + SSAInt xshift = (32 - xbits); + SSAInt yshift = (32 - ybits); + SSAInt xmask = (SSAInt(1) << xshift) - 1; + SSAInt ymask = (SSAInt(1) << yshift) - 1; + SSAInt x = xfrac >> xbits; + SSAInt y = yfrac >> ybits; + + SSAVec4i p00 = texture[((y & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(true); + SSAVec4i p01 = texture[(((y + 1) & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(true); + SSAVec4i p10 = texture[((y & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(true); + SSAVec4i p11 = texture[(((y + 1) & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(true); + + SSAInt inv_b = (xfrac >> (xbits - 4)) & 15; + SSAInt inv_a = (yfrac >> (ybits - 4)) & 15; + SSAInt a = 16 - inv_a; + SSAInt b = 16 - inv_b; + + return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; +} + SSAVec4i DrawSpanCodegen::Shade(SSAVec4i fg, bool isSimpleShade) { if (isSimpleShade) diff --git a/src/r_compiler/fixedfunction/drawspancodegen.h b/src/r_compiler/fixedfunction/drawspancodegen.h index 9ef3edd38..48c86040b 100644 --- a/src/r_compiler/fixedfunction/drawspancodegen.h +++ b/src/r_compiler/fixedfunction/drawspancodegen.h @@ -45,6 +45,7 @@ private: SSAInt Loop4x(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64); void Loop(SSAInt start, DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64); SSAVec4i Sample(SSAInt xfrac, SSAInt yfrac, bool isNearestFilter, bool is64x64); + SSAVec4i SampleLinear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits); SSAVec4i Shade(SSAVec4i fg, bool isSimpleShade); SSAVec4i Blend(SSAVec4i fg, SSAVec4i bg, DrawSpanVariant variant); diff --git a/src/r_compiler/fixedfunction/drawwallcodegen.cpp b/src/r_compiler/fixedfunction/drawwallcodegen.cpp index 7c042f9be..ec30a8298 100644 --- a/src/r_compiler/fixedfunction/drawwallcodegen.cpp +++ b/src/r_compiler/fixedfunction/drawwallcodegen.cpp @@ -117,6 +117,9 @@ void DrawWallCodegen::LoopShade(DrawWallVariant variant, bool fourColumns, bool branch.if_block(is_nearest_filter); Loop(variant, fourColumns, isSimpleShade, true); branch.else_block(); + int numColumns = fourColumns ? 4 : 1; + for (int i = 0; i < numColumns; i++) + stack_frac[i].store(stack_frac[i].load() - (one[i] / 2)); Loop(variant, fourColumns, isSimpleShade, false); branch.end_block(); } @@ -180,10 +183,30 @@ SSAVec4i DrawWallCodegen::Sample(SSAInt frac, int index, bool isNearestFilter) } else { - return sample_linear(source[index], source2[index], texturefracx[index], frac, one[index], textureheight[index]); + return SampleLinear(source[index], source2[index], texturefracx[index], frac, one[index], textureheight[index]); } } +SSAVec4i DrawWallCodegen::SampleLinear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height) +{ + SSAInt frac_y0 = (texturefracy >> FRACBITS) * height; + SSAInt frac_y1 = ((texturefracy + one) >> FRACBITS) * height; + SSAInt y0 = frac_y0 >> FRACBITS; + SSAInt y1 = frac_y1 >> FRACBITS; + + SSAVec4i p00 = col0[y0 * 4].load_vec4ub(true); + SSAVec4i p01 = col0[y1 * 4].load_vec4ub(true); + SSAVec4i p10 = col1[y0 * 4].load_vec4ub(true); + SSAVec4i p11 = col1[y1 * 4].load_vec4ub(true); + + SSAInt inv_b = texturefracx; + SSAInt a = (frac_y1 >> (FRACBITS - 4)) & 15; + SSAInt inv_a = 16 - a; + SSAInt b = 16 - inv_b; + + return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; +} + SSAVec4i DrawWallCodegen::Shade(SSAVec4i fg, int index, bool isSimpleShade) { if (isSimpleShade) diff --git a/src/r_compiler/fixedfunction/drawwallcodegen.h b/src/r_compiler/fixedfunction/drawwallcodegen.h index 6591fb9b6..4a1599063 100644 --- a/src/r_compiler/fixedfunction/drawwallcodegen.h +++ b/src/r_compiler/fixedfunction/drawwallcodegen.h @@ -43,6 +43,7 @@ private: void LoopShade(DrawWallVariant variant, bool fourColumns, bool isSimpleShade); void Loop(DrawWallVariant variant, bool fourColumns, bool isSimpleShade, bool isNearestFilter); SSAVec4i Sample(SSAInt frac, int index, bool isNearestFilter); + SSAVec4i SampleLinear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height); SSAVec4i Shade(SSAVec4i fg, int index, bool isSimpleShade); SSAVec4i Blend(SSAVec4i fg, SSAVec4i bg, DrawWallVariant variant); diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index ce5024bba..c39019799 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -360,6 +360,7 @@ llvm::Type *LLVMDrawersImpl::GetDrawColumnArgsStruct(llvm::LLVMContext &context) std::vector elements; elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint32_t *dest; elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source2; elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *colormap; elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *translation; elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *basecolors; @@ -367,6 +368,8 @@ llvm::Type *LLVMDrawersImpl::GetDrawColumnArgsStruct(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t count; elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t dest_y; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t iscale; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t texturefracx; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureheight; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t texturefrac; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t color; diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 5cbd05e4a..b2978cabf 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -117,6 +117,7 @@ struct DrawColumnArgs { uint32_t *dest; const uint8_t *source; + const uint8_t *source2; uint8_t *colormap; uint8_t *translation; const uint32_t *basecolors; @@ -124,6 +125,8 @@ struct DrawColumnArgs int32_t count; int32_t dest_y; uint32_t iscale; + uint32_t texturefracx; + uint32_t textureheight; uint32_t texturefrac; uint32_t light; uint32_t color; @@ -143,7 +146,8 @@ struct DrawColumnArgs uint32_t flags; enum Flags { - simple_shade = 1 + simple_shade = 1, + nearest_filter = 2 }; FString ToString() diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 0a2c8553e..0ff047238 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -2973,7 +2973,8 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, { R_SetColorMapLight(basecolormap, 0, 0); } - return r_columnmethod ? DoDraw1 : DoDraw0; + bool active_columnmethod = r_columnmethod && !r_swtruecolor; + return active_columnmethod ? DoDraw1 : DoDraw0; } fglevel = GetAlpha(style.SrcAlpha, alpha); @@ -3006,7 +3007,8 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, { return DontDraw; } - return r_columnmethod ? DoDraw1 : DoDraw0; + bool active_columnmethod = r_columnmethod && !r_swtruecolor; + return active_columnmethod ? DoDraw1 : DoDraw0; } void R_FinishSetPatchStyle () diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index c65718de2..2f1f6d17a 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -348,6 +348,7 @@ public: { args.dest = (uint32_t*)dc_dest; args.source = dc_source; + args.source2 = dc_source2; args.colormap = dc_colormap; args.translation = dc_translation; args.basecolors = (const uint32_t *)GPalette.BaseColors; @@ -355,6 +356,8 @@ public: args.count = dc_count; args.dest_y = _dest_y; args.iscale = dc_iscale; + args.texturefracx = dc_texturefracx; + args.textureheight = dc_textureheight; args.texturefrac = dc_texturefrac; args.light = LightBgra::calc_light_multiplier(dc_light); args.color = LightBgra::shade_pal_index_simple(dc_color, args.light); @@ -373,6 +376,8 @@ public: args.flags = 0; if (dc_shade_constants.simple_shade) args.flags |= DrawColumnArgs::simple_shade; + if (args.source2 == nullptr) + args.flags |= DrawWallArgs::nearest_filter; DetectRangeError(args.dest, args.dest_y, args.count); } diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 2963d2fc1..04f216c0c 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -72,6 +72,7 @@ public: { args.dest = (uint32_t*)dc_destorg + ylookup[yl] + sx; args.source = nullptr; + args.source2 = nullptr; args.colormap = dc_colormap; args.translation = dc_translation; args.basecolors = (const uint32_t *)GPalette.BaseColors; @@ -97,6 +98,8 @@ public: args.flags = 0; if (dc_shade_constants.simple_shade) args.flags |= DrawColumnArgs::simple_shade; + if (args.source2 == nullptr) + args.flags |= DrawWallArgs::nearest_filter; DetectRangeError(args.dest, args.dest_y, args.count); } diff --git a/src/r_segs.cpp b/src/r_segs.cpp index e1925f66a..ea3debb18 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1183,6 +1183,7 @@ WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xof } else { + xoffset -= FRACUNIT / 2; int tx0 = (xoffset >> FRACBITS) % mip_width; if (tx0 < 0) tx0 += mip_width; diff --git a/src/r_things.cpp b/src/r_things.cpp index a04676492..ef5208848 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -251,8 +251,133 @@ double sprtopscreen; bool sprflipvert; +void R_DrawMaskedColumnBgra(FTexture *tex, fixed_t col, bool useRt, bool unmasked) +{ + fixed_t saved_iscale = dc_iscale; // Save this because we need to modify it for mipmaps + + // Normalize to 0-1 range: + double uv_stepd = FIXED2DBL(dc_iscale); + double v_step = uv_stepd / tex->GetHeight(); + + // Convert to uint32: + dc_iscale = (uint32_t)(v_step * (1 << 30)); + + // Texture mipmap and filter selection: + fixed_t xoffset = col; + double magnitude = fabs(uv_stepd * 2); + bool magnifying = magnitude < 1.0f; + + int mipmap_offset = 0; + int mip_width = tex->GetWidth(); + int mip_height = tex->GetHeight(); + if (r_mipmap && tex->Mipmapped() && mip_width > 1 && mip_height > 1) + { + uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width); + double texture_bias = 1.7f; + double level = MAX(magnitude - 3.0, 0.0); + while (level > texture_bias && mip_width > 1 && mip_height > 1) + { + mipmap_offset += mip_width * mip_height; + level *= 0.5f; + mip_width = MAX(mip_width >> 1, 1); + mip_height = MAX(mip_height >> 1, 1); + } + xoffset = (xpos >> FRACBITS) * mip_width; + } + + const uint32_t *pixels = tex->GetPixelsBgra() + mipmap_offset; + + bool filter_nearest = (magnifying && !r_magfilter) || (!magnifying && !r_minfilter); + if (filter_nearest) + { + xoffset = MAX(MIN(xoffset, (mip_width << FRACBITS) - 1), 0); + + int tx = xoffset >> FRACBITS; + dc_source = (BYTE*)(pixels + tx * mip_height); + dc_source2 = nullptr; + dc_textureheight = mip_height; + dc_texturefracx = 0; + } + else + { + xoffset = MAX(MIN(xoffset - (FRACUNIT / 2), (mip_width << FRACBITS) - 1), 0); + + int tx0 = xoffset >> FRACBITS; + int tx1 = MIN(tx0 + 1, mip_width - 1); + dc_source = (BYTE*)(pixels + tx0 * mip_height); + dc_source2 = (BYTE*)(pixels + tx1 * mip_height); + dc_textureheight = mip_height; + dc_texturefracx = (xoffset >> (FRACBITS - 4)) & 15; + } + + // Grab the posts we need to draw + const FTexture::Span *span; + tex->GetColumnBgra(col >> FRACBITS, &span); + FTexture::Span unmaskedSpan[2]; + if (unmasked) + { + span = unmaskedSpan; + unmaskedSpan[0].TopOffset = 0; + unmaskedSpan[0].Length = tex->GetHeight(); + unmaskedSpan[1].TopOffset = 0; + unmaskedSpan[1].Length = 0; + } + + // Draw each span post + while (span->Length != 0) + { + const int length = span->Length; + const int top = span->TopOffset; + + // calculate unclipped screen coordinates for post + dc_yl = (int)(sprtopscreen + spryscale * top + 0.5); + dc_yh = (int)(sprtopscreen + spryscale * (top + length) + 0.5) - 1; + + if (sprflipvert) + { + swapvalues(dc_yl, dc_yh); + } + + if (dc_yh >= mfloorclip[dc_x]) + { + dc_yh = mfloorclip[dc_x] - 1; + } + if (dc_yl < mceilingclip[dc_x]) + { + dc_yl = mceilingclip[dc_x]; + } + + if (dc_yl <= dc_yh) + { + dc_dest = (ylookup[dc_yl] + dc_x) * 4 + dc_destorg; + dc_count = dc_yh - dc_yl + 1; + + double v = ((dc_yl + 0.5 - sprtopscreen) / spryscale) / tex->GetHeight(); + dc_texturefrac = (uint32_t)(v * (1 << 30)); + + if (useRt) + hcolfunc_pre(); + else + colfunc(); + } + span++; + } + + dc_iscale = saved_iscale; + + if (sprflipvert && useRt) + rt_flip_posts(); +} + void R_DrawMaskedColumn (FTexture *tex, fixed_t col, bool useRt, bool unmasked) { + // Handle the linear filtered version in a different function to reduce chances of merge conflicts from zdoom. + if (r_swtruecolor && !drawer_needs_pal_input && !useRt) // To do: add support to R_DrawColumnHoriz_rgba + { + R_DrawMaskedColumnBgra(tex, col, useRt, unmasked); + return; + } + const FTexture::Span *span; const BYTE *column; if (r_swtruecolor && !drawer_needs_pal_input) From d084f775467f31c875ba9b22e8a7257c8d4fedbf Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 5 Nov 2016 16:12:59 +0100 Subject: [PATCH 1162/1509] Fix mipmap generation bug Fix crash due to dc_source2 not always being set Add r_lod_bias to control mipmap selection Improve LOD calculations to take the U texture coordinate into account --- src/r_draw.h | 1 + src/r_draw_rgba.cpp | 5 ++++- src/r_draw_rgba.h | 1 + src/r_drawt_rgba.cpp | 2 +- src/r_segs.cpp | 36 +++++++++++++++++++++++++----------- src/r_things.cpp | 18 ++++++++++++------ src/textures/texture.cpp | 12 ++++++------ 7 files changed, 50 insertions(+), 25 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index 2fa662a95..005897de6 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -411,5 +411,6 @@ EXTERN_CVAR(Bool, r_multithreaded); EXTERN_CVAR(Bool, r_magfilter); EXTERN_CVAR(Bool, r_minfilter); EXTERN_CVAR(Bool, r_mipmap); +EXTERN_CVAR(Float, r_lod_bias); #endif diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 2f1f6d17a..34c79b3aa 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -60,6 +60,9 @@ CVAR(Bool, r_minfilter, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); // Use mipmapped textures CVAR(Bool, r_mipmap, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +// Level of detail texture bias +CVAR(Float, r_lod_bias, -1.5, 0); // To do: add CVAR_ARCHIVE | CVAR_GLOBALCONFIG when a good default has been decided + ///////////////////////////////////////////////////////////////////////////// class DrawSpanLLVMCommand : public DrawerCommand @@ -377,7 +380,7 @@ public: if (dc_shade_constants.simple_shade) args.flags |= DrawColumnArgs::simple_shade; if (args.source2 == nullptr) - args.flags |= DrawWallArgs::nearest_filter; + args.flags |= DrawColumnArgs::nearest_filter; DetectRangeError(args.dest, args.dest_y, args.count); } diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 253315f14..4aa1a02af 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -34,6 +34,7 @@ struct FSpecialColormap; EXTERN_CVAR(Bool, r_mipmap) +EXTERN_CVAR(Float, r_lod_bias) ///////////////////////////////////////////////////////////////////////////// // Drawer functions: diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 04f216c0c..29a315a8c 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -99,7 +99,7 @@ public: if (dc_shade_constants.simple_shade) args.flags |= DrawColumnArgs::simple_shade; if (args.source2 == nullptr) - args.flags |= DrawWallArgs::nearest_filter; + args.flags |= DrawColumnArgs::nearest_filter; DetectRangeError(args.dest, args.dest_y, args.count); } diff --git a/src/r_segs.cpp b/src/r_segs.cpp index ea3debb18..adbd5a3f9 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1070,7 +1070,7 @@ EXTERN_CVAR(Bool, r_mipmap) struct WallscanSampler { WallscanSampler() { } - WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)); + WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)); uint32_t uv_pos; uint32_t uv_step; @@ -1082,8 +1082,10 @@ struct WallscanSampler uint32_t height; }; -WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)) +WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)) { + xoffset += FLOAT2FIXED(xmagnitude * 0.5); + if (!r_swtruecolor) { height = texture->GetHeight(); @@ -1147,8 +1149,11 @@ WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xof } else { - double magnitude = fabs(uv_stepd * 2); - bool magnifying = magnitude < 1.0f; + double ymagnitude = fabs(uv_stepd); + double magnitude = MAX(ymagnitude, xmagnitude); + double min_lod = -1000.0; + double lod = MAX(log2(magnitude) + r_lod_bias, min_lod); + bool magnifying = lod < 0.0f; int mipmap_offset = 0; int mip_width = texture->GetWidth(); @@ -1156,12 +1161,12 @@ WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xof if (r_mipmap && texture->Mipmapped() && mip_width > 1 && mip_height > 1) { uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width); - double texture_bias = 1.7f; - double level = MAX(magnitude - 3.0, 0.0); - while (level > texture_bias && mip_width > 1 && mip_height > 1) + + int level = (int)lod; + while (level > 0 && mip_width > 1 && mip_height > 1) { mipmap_offset += mip_width * mip_height; - level *= 0.5f; + level--; mip_width = MAX(mip_width >> 1, 1); mip_height = MAX(mip_height >> 1, 1); } @@ -1411,6 +1416,8 @@ void wallscan_any( int aligned_x1 = clamp((x1 + 3) / 4 * 4, x1, x2); int aligned_x2 = clamp(x2 / 4 * 4, x1, x2); + double xmagnitude = 1.0; + // First unaligned columns: for (int x = x1; x < aligned_x1; x++, light += rw_lightstep) { @@ -1422,7 +1429,9 @@ void wallscan_any( if (!fixed) R_SetColorMapLight(basecolormap, light, wallshade); - WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, rw_pic, getcol); + if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); + + WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); wallscan_drawcol1(x, y1, y2, sampler, draw1column); } @@ -1442,7 +1451,10 @@ void wallscan_any( WallscanSampler sampler[4]; for (int i = 0; i < 4; i++) - sampler[i] = WallscanSampler(y1[i], swal[x + i], yrepeat, lwal[x + i] + xoffset, rw_pic, getcol); + { + if (x + i + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + i + 1]) - FIXED2DBL(lwal[x + i])); + sampler[i] = WallscanSampler(y1[i], swal[x + i], yrepeat, lwal[x + i] + xoffset, xmagnitude, rw_pic, getcol); + } // Figure out where we vertically can start and stop drawing 4 columns in one go int middle_y1 = y1[0]; @@ -1529,7 +1541,9 @@ void wallscan_any( if (!fixed) R_SetColorMapLight(basecolormap, light, wallshade); - WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, rw_pic, getcol); + if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); + + WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); wallscan_drawcol1(x, y1, y2, sampler, draw1column); } diff --git a/src/r_things.cpp b/src/r_things.cpp index ef5208848..4f6d5fcc2 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -264,8 +264,13 @@ void R_DrawMaskedColumnBgra(FTexture *tex, fixed_t col, bool useRt, bool unmaske // Texture mipmap and filter selection: fixed_t xoffset = col; - double magnitude = fabs(uv_stepd * 2); - bool magnifying = magnitude < 1.0f; + + double xmagnitude = 1.0; // To do: pass this into R_DrawMaskedColumn + double ymagnitude = fabs(uv_stepd); + double magnitude = MAX(ymagnitude, xmagnitude); + double min_lod = -1000.0; + double lod = MAX(log2(magnitude) + r_lod_bias, min_lod); + bool magnifying = lod < 0.0f; int mipmap_offset = 0; int mip_width = tex->GetWidth(); @@ -273,12 +278,11 @@ void R_DrawMaskedColumnBgra(FTexture *tex, fixed_t col, bool useRt, bool unmaske if (r_mipmap && tex->Mipmapped() && mip_width > 1 && mip_height > 1) { uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width); - double texture_bias = 1.7f; - double level = MAX(magnitude - 3.0, 0.0); - while (level > texture_bias && mip_width > 1 && mip_height > 1) + int level = (int)lod; + while (level > 0 && mip_width > 1 && mip_height > 1) { mipmap_offset += mip_width * mip_height; - level *= 0.5f; + level--; mip_width = MAX(mip_width >> 1, 1); mip_height = MAX(mip_height >> 1, 1); } @@ -424,6 +428,7 @@ void R_DrawMaskedColumn (FTexture *tex, fixed_t col, bool useRt, bool unmasked) { dc_texturefrac = FLOAT2FIXED((dc_yl + 0.5 - sprtopscreen) / spryscale); dc_source = column; + dc_source2 = nullptr; dc_dest = (ylookup[dc_yl] + dc_x) * pixelsize + dc_destorg; dc_count = dc_yh - dc_yl + 1; @@ -3215,6 +3220,7 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, dc_x = lxt + x; rt_initcols(OffscreenColorBuffer + (dc_x & ~3) * OffscreenBufferHeight); dc_source = col; + dc_source2 = nullptr; dc_texturefrac = yplc[xxl]; hcolfunc_pre(); } diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 5774a0048..01906ac7b 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -456,7 +456,7 @@ void FTexture::GenerateBgraMipmaps() Color4f src11 = src[sy1 + sx1 * srch]; Color4f c = (src00 + src01 + src10 + src11) * 0.25f; - dest[y + x * h] = src00; + dest[y + x * h] = c; } } @@ -483,7 +483,7 @@ void FTexture::GenerateBgraMipmaps() smoothed[y + x * h] = c; } } - float k = 0.04f; + float k = 0.08f; for (int j = 0; j < w * h; j++) dest[j] = dest[j] + (dest[j] - smoothed[j]) * k; @@ -502,10 +502,10 @@ void FTexture::GenerateBgraMipmaps() int h = MAX(Height >> i, 1); for (int j = 0; j < w * h; j++) { - uint32_t a = (uint32_t)clamp(powf(src[j].a, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t r = (uint32_t)clamp(powf(src[j].r, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t g = (uint32_t)clamp(powf(src[j].g, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t b = (uint32_t)clamp(powf(src[j].b, 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t a = (uint32_t)clamp(powf(MAX(src[j].a, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t r = (uint32_t)clamp(powf(MAX(src[j].r, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t g = (uint32_t)clamp(powf(MAX(src[j].g, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t b = (uint32_t)clamp(powf(MAX(src[j].b, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); dest[j] = (a << 24) | (r << 16) | (g << 8) | b; } src += w * h; From 70d4097b3449f14bb7792fb60f6a1280de57eba4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 6 Nov 2016 07:33:17 +0100 Subject: [PATCH 1163/1509] Fix clamping bug when r_mipmap is off --- src/r_things.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 4f6d5fcc2..8f91b1740 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -275,9 +275,9 @@ void R_DrawMaskedColumnBgra(FTexture *tex, fixed_t col, bool useRt, bool unmaske int mipmap_offset = 0; int mip_width = tex->GetWidth(); int mip_height = tex->GetHeight(); + uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width); if (r_mipmap && tex->Mipmapped() && mip_width > 1 && mip_height > 1) { - uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width); int level = (int)lod; while (level > 0 && mip_width > 1 && mip_height > 1) { @@ -286,8 +286,8 @@ void R_DrawMaskedColumnBgra(FTexture *tex, fixed_t col, bool useRt, bool unmaske mip_width = MAX(mip_width >> 1, 1); mip_height = MAX(mip_height >> 1, 1); } - xoffset = (xpos >> FRACBITS) * mip_width; } + xoffset = (xpos >> FRACBITS) * mip_width; const uint32_t *pixels = tex->GetPixelsBgra() + mipmap_offset; From aad2cde332dcf07cbb5a56d935495627ae8d3cd2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 6 Nov 2016 07:37:18 +0100 Subject: [PATCH 1164/1509] Oops, forced all sandy bridge CPUs to westmere instead of just Pentium G840 --- src/r_compiler/llvmdrawers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index c39019799..871e3c5ca 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -497,7 +497,7 @@ void LLVMProgram::CreateEE() std::string errorstring; std::string mcpu = sys::getHostCPUName(); - if (std::string(CPU.CPUString).find("G840") && mcpu == "sandybridge") + if (std::string(CPU.CPUString).find("G840") != std::string::npos && mcpu == "sandybridge") mcpu = "westmere"; // Pentium G840 is misdetected as a sandy bridge CPU if (stricmp(llvm_cpu, "auto") != 0) From 3a7532fd9bd702858431d8ecaffaf6cbab93bc1c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 6 Nov 2016 11:39:28 +0100 Subject: [PATCH 1165/1509] Improve flat mipmap selection --- src/r_draw.cpp | 1 + src/r_draw.h | 1 + src/r_draw_rgba.cpp | 17 ++++++----------- src/r_plane.cpp | 10 ++++++++++ 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 0ff047238..bd53889a1 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -1046,6 +1046,7 @@ dsfixed_t ds_xstep; dsfixed_t ds_ystep; int ds_xbits; int ds_ybits; +double ds_lod; // start of a floor/ceiling tile image const BYTE* ds_source; diff --git a/src/r_draw.h b/src/r_draw.h index 005897de6..196e26bea 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -316,6 +316,7 @@ extern "C" dsfixed_t ds_ystep; extern "C" int ds_xbits; extern "C" int ds_ybits; extern "C" fixed_t ds_alpha; +extern "C" double ds_lod; // start of a 64*64 tile image extern "C" const BYTE* ds_source; diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 34c79b3aa..a649572cc 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -97,7 +97,7 @@ public: args.flags = 0; if (ds_shade_constants.simple_shade) args.flags |= DrawSpanArgs::simple_shade; - if (!sampler_setup(args.source, args.xbits, args.ybits, args.xstep, args.ystep, ds_source_mipmapped)) + if (!sampler_setup(args.source, args.xbits, args.ybits, ds_source_mipmapped)) args.flags |= DrawSpanArgs::nearest_filter; } @@ -117,18 +117,13 @@ protected: DrawSpanArgs args; private: - inline static bool sampler_setup(const uint32_t * &source, int &xbits, int &ybits, fixed_t xstep, fixed_t ystep, bool mipmapped) + inline static bool sampler_setup(const uint32_t * &source, int &xbits, int &ybits, bool mipmapped) { - // Is this a magfilter or minfilter? - fixed_t xmagnitude = abs(xstep) >> (32 - xbits - FRACBITS); - fixed_t ymagnitude = abs(ystep) >> (32 - ybits - FRACBITS); - fixed_t magnitude = (xmagnitude + ymagnitude) * 2 + (1 << (FRACBITS - 1)); - bool magnifying = (magnitude >> FRACBITS == 0); - + bool magnifying = ds_lod < 0.0f; if (r_mipmap && mipmapped) { - int level = magnitude >> (FRACBITS + 1); - while (level != 0) + int level = (int)ds_lod; + while (level > 0) { if (xbits <= 2 || ybits <= 2) break; @@ -136,7 +131,7 @@ private: source += (1 << (xbits)) * (1 << (ybits)); xbits -= 1; ybits -= 1; - level >>= 1; + level--; } } diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 21cea7bcf..96225729b 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -245,6 +245,16 @@ void R_MapPlane (int y, int x1) ds_yfrac = 0; } + if (r_swtruecolor) + { + double distance2 = planeheight * yslope[(y + 1 < viewheight) ? y + 1 : y - 1]; + double xmagnitude = fabs(ystepscale * (distance2 - distance) * FocalLengthX); + double ymagnitude = fabs(xstepscale * (distance2 - distance) * FocalLengthX); + double magnitude = MAX(ymagnitude, xmagnitude); + double min_lod = -1000.0; + ds_lod = MAX(log2(magnitude) + r_lod_bias, min_lod); + } + if (plane_shade) { // Determine lighting based on the span's distance from the viewer. From 9f9e4ea19d6a82dd728993116cbae09ecf91918e Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 6 Nov 2016 08:58:06 -0500 Subject: [PATCH 1166/1509] - Added randi's "bottomclip" parameter to dpJudas's OpenGLSWFrameBuffer::FillSimplePoly implementation. The code refused to compile because of the new changes. Note that this is not tested on Linux or Mac, and will likely need changes there as well. --- src/gl/system/gl_swframebuffer.cpp | 4 ++-- src/gl/system/gl_swframebuffer.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index b6d163044..0d82aa221 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -2871,7 +2871,7 @@ void OpenGLSWFrameBuffer::FlatFill(int left, int top, int right, int bottom, FTe void OpenGLSWFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, - DAngle rotation, FDynamicColormap *colormap, int lightlevel) + DAngle rotation, FDynamicColormap *colormap, int lightlevel, int bottomclip) { // Use an equation similar to player sprites to determine shade double fadelevel = clamp((LIGHT2SHADE(lightlevel) / 65536. - 12) / NUMCOLORMAPS, 0.0, 1.0); @@ -2892,7 +2892,7 @@ void OpenGLSWFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, in } if (In2D < 2) { - Super::FillSimplePoly(texture, points, npoints, originx, originy, scalex, scaley, rotation, colormap, lightlevel); + Super::FillSimplePoly(texture, points, npoints, originx, originy, scalex, scaley, rotation, colormap, lightlevel, bottomclip); return; } if (!InScene) diff --git a/src/gl/system/gl_swframebuffer.h b/src/gl/system/gl_swframebuffer.h index 226d8cca7..a4ba4e426 100644 --- a/src/gl/system/gl_swframebuffer.h +++ b/src/gl/system/gl_swframebuffer.h @@ -59,7 +59,7 @@ public: void FlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin) override; void DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 realcolor) override; void DrawPixel(int x, int y, int palcolor, uint32 rgbcolor) override; - void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, DAngle rotation, FDynamicColormap *colormap, int lightlevel) override; + void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, DAngle rotation, FDynamicColormap *colormap, int lightlevel, int bottomclip) override; bool WipeStartScreen(int type) override; void WipeEndScreen() override; bool WipeDo(int ticks) override; From 3ea9d7cf0464ac5a3e4d7010f2087448357cc86c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 7 Nov 2016 03:34:59 +0100 Subject: [PATCH 1167/1509] Move software renderer transform to TriMatrix --- src/r_plane.cpp | 15 +++++--- src/r_triangle.cpp | 88 +++++++++++++++++++++++++++++----------------- src/r_triangle.h | 12 ++++--- 3 files changed, 74 insertions(+), 41 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 023de80d3..5176d2c36 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -966,6 +966,9 @@ static void R_DrawCubeSky(visplane_t *pl) }; TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z) * TriMatrix::scale(1000.0f, 1000.0f, 1000.0f); + TriMatrix objectToClip = TriMatrix::viewToClip() * TriMatrix::worldToView() * objectToWorld; + //TriMatrix objectToWorld = TriMatrix::scale(1000.0f, 1000.0f, 1000.0f); + //TriMatrix objectToClip = TriMatrix::viewToClip() * objectToWorld; uint32_t solid_top = frontskytex->GetSkyCapColor(false); uint32_t solid_bottom = frontskytex->GetSkyCapColor(true); @@ -973,9 +976,9 @@ static void R_DrawCubeSky(visplane_t *pl) solid_top = RGB32k.RGB[(RPART(solid_top) >> 3)][(GPART(solid_top) >> 3)][(BPART(solid_top) >> 3)]; solid_bottom = RGB32k.RGB[(RPART(solid_bottom) >> 3)][(GPART(solid_bottom) >> 3)][(BPART(solid_bottom) >> 3)]; - TriangleDrawer::fill(objectToWorld, cube, 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, solid_top); - TriangleDrawer::fill(objectToWorld, cube + 6, 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, solid_bottom); - TriangleDrawer::draw(objectToWorld, cube + 2 * 6, 4 * 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, frontskytex); + TriangleDrawer::fill(objectToClip, cube, 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, solid_top); + TriangleDrawer::fill(objectToClip, cube + 6, 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, solid_bottom); + TriangleDrawer::draw(objectToClip, cube + 2 * 6, 4 * 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, frontskytex); } namespace @@ -1102,7 +1105,8 @@ namespace short *uwal = (short *)pl->top; short *dwal = (short *)pl->bottom; TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); - TriangleDrawer::draw(objectToWorld, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Strip, false, x1, x2 - 1, uwal, dwal, frontskytex); + TriMatrix objectToClip = TriMatrix::viewToClip() * TriMatrix::worldToView() * objectToWorld; + TriangleDrawer::draw(objectToClip, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Strip, false, x1, x2 - 1, uwal, dwal, frontskytex); } void SkyDome::RenderCapColorRow(int row, bool bottomCap, visplane_t *pl) @@ -1115,7 +1119,8 @@ namespace short *uwal = (short *)pl->top; short *dwal = (short *)pl->bottom; TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); - TriangleDrawer::fill(objectToWorld, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Fan, bottomCap, x1, x2 - 1, uwal, dwal, solid); + TriMatrix objectToClip = TriMatrix::viewToClip() * TriMatrix::worldToView() * objectToWorld; + TriangleDrawer::fill(objectToClip, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Fan, bottomCap, x1, x2 - 1, uwal, dwal, solid); } void SkyDome::Render(visplane_t *pl) diff --git a/src/r_triangle.cpp b/src/r_triangle.cpp index b6e7b1b2b..b039ed1ff 100644 --- a/src/r_triangle.cpp +++ b/src/r_triangle.cpp @@ -36,17 +36,17 @@ #include "r_data/colormaps.h" #include "r_triangle.h" -void TriangleDrawer::draw(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture) +void TriangleDrawer::draw(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture) { - draw_arrays(objectToWorld, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texture, 0, &ScreenTriangleDrawer::draw); + draw_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texture, 0, &ScreenTriangleDrawer::draw); } -void TriangleDrawer::fill(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor) +void TriangleDrawer::fill(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor) { - draw_arrays(objectToWorld, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, solidcolor, &ScreenTriangleDrawer::fill); + draw_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, solidcolor, &ScreenTriangleDrawer::fill); } -void TriangleDrawer::draw_arrays(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture, int solidcolor, void(*drawfunc)(const ScreenTriangleDrawerArgs *)) +void TriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture, int solidcolor, void(*drawfunc)(const ScreenTriangleDrawerArgs *)) { if (vcount < 3) return; @@ -78,28 +78,28 @@ void TriangleDrawer::draw_arrays(const TriMatrix &objectToWorld, const TriVertex for (int i = 0; i < vcount / 3; i++) { for (int j = 0; j < 3; j++) - vert[j] = shade_vertex(objectToWorld, *(vinput++)); + vert[j] = shade_vertex(objectToClip, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, drawfunc); } } else if (mode == TriangleDrawMode::Fan) { - vert[0] = shade_vertex(objectToWorld, *(vinput++)); - vert[1] = shade_vertex(objectToWorld, *(vinput++)); + vert[0] = shade_vertex(objectToClip, *(vinput++)); + vert[1] = shade_vertex(objectToClip, *(vinput++)); for (int i = 2; i < vcount; i++) { - vert[2] = shade_vertex(objectToWorld, *(vinput++)); + vert[2] = shade_vertex(objectToClip, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, drawfunc); vert[1] = vert[2]; } } else // TriangleDrawMode::Strip { - vert[0] = shade_vertex(objectToWorld, *(vinput++)); - vert[1] = shade_vertex(objectToWorld, *(vinput++)); + vert[0] = shade_vertex(objectToClip, *(vinput++)); + vert[1] = shade_vertex(objectToClip, *(vinput++)); for (int i = 2; i < vcount; i++) { - vert[2] = shade_vertex(objectToWorld, *(vinput++)); + vert[2] = shade_vertex(objectToClip, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, drawfunc); vert[0] = vert[1]; vert[1] = vert[2]; @@ -108,25 +108,10 @@ void TriangleDrawer::draw_arrays(const TriMatrix &objectToWorld, const TriVertex } } -TriVertex TriangleDrawer::shade_vertex(const TriMatrix &objectToWorld, TriVertex v) +TriVertex TriangleDrawer::shade_vertex(const TriMatrix &objectToClip, TriVertex v) { - // Apply transform to get world coordinates: - v = objectToWorld * v; - - // The software renderer world to clip transform: - double nearp = 5.0f; - double farp = 65536.f; - double tr_x = v.x - ViewPos.X; - double tr_y = v.y - ViewPos.Y; - double tr_z = v.z - ViewPos.Z; - double tx = tr_x * ViewSin - tr_y * ViewCos; - double tz = tr_x * ViewTanCos + tr_y * ViewTanSin; - v.x = (float)tx * 0.5f; - v.y = (float)tr_z * 0.5f; - v.z = (float)((-tz * (farp + nearp) / (nearp - farp) + (2.0f * farp * nearp) / (nearp - farp))); - v.w = (float)tz; - - return v; + // Apply transform to get clip coordinates: + return objectToClip * v; } void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenTriangleDrawerArgs *args, void(*drawfunc)(const ScreenTriangleDrawerArgs *)) @@ -150,8 +135,8 @@ void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, Scree v.z *= v.w; // Apply viewport scale to get screen coordinates: - v.x = (float)(CenterX + v.x * 2.0f * CenterX); - v.y = (float)(CenterY - v.y * 2.0f * InvZtoScale); + v.x = viewwidth * (1.0f + v.x) * 0.5f; + v.y = viewheight * (1.0f - v.y) * 0.5f; } // Draw screen triangles @@ -717,6 +702,45 @@ TriMatrix TriMatrix::rotate(float angle, float x, float y, float z) return m; } +TriMatrix TriMatrix::frustum(float left, float right, float bottom, float top, float near, float far) +{ + float a = (right + left) / (right - left); + float b = (top + bottom) / (top - bottom); + float c = -(far + near) / (far - near); + float d = -(2.0f * far) / (far - near); + TriMatrix m = null(); + m.matrix[0 + 0 * 4] = 2.0f * near / (right - left); + m.matrix[1 + 1 * 4] = 2.0f * near / (top - bottom); + m.matrix[0 + 2 * 4] = a; + m.matrix[1 + 2 * 4] = b; + m.matrix[2 + 2 * 4] = c; + m.matrix[2 + 3 * 4] = d; + m.matrix[3 + 2 * 4] = -1; + return m; +} + +TriMatrix TriMatrix::worldToView() +{ + TriMatrix m = null(); + m.matrix[0 + 0 * 4] = (float)ViewSin; + m.matrix[0 + 1 * 4] = (float)-ViewCos; + m.matrix[1 + 2 * 4] = 1.0f; + m.matrix[2 + 0 * 4] = (float)-ViewCos; + m.matrix[2 + 1 * 4] = (float)-ViewSin; + m.matrix[3 + 3 * 4] = 1.0f; + return m * translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); +} + +TriMatrix TriMatrix::viewToClip() +{ + float near = 5.0f; + float far = 65536.0f; + float width = (float)(FocalTangent * near); + float top = (float)(CenterY / InvZtoScale * near); + float bottom = (float)(top - viewheight / InvZtoScale * near); + return frustum(-width, width, bottom, top, near, far); +} + TriMatrix TriMatrix::operator*(const TriMatrix &mult) const { TriMatrix result; diff --git a/src/r_triangle.h b/src/r_triangle.h index f1ff220b6..05cfada98 100644 --- a/src/r_triangle.h +++ b/src/r_triangle.h @@ -46,6 +46,10 @@ struct TriMatrix static TriMatrix translate(float x, float y, float z); static TriMatrix scale(float x, float y, float z); static TriMatrix rotate(float angle, float x, float y, float z); + static TriMatrix frustum(float left, float right, float bottom, float top, float near, float far); + + static TriMatrix worldToView(); // Software renderer world to view space transform + static TriMatrix viewToClip(); // Software renderer shearing projection TriVertex operator*(TriVertex v) const; TriMatrix operator*(const TriMatrix &m) const; @@ -63,12 +67,12 @@ enum class TriangleDrawMode class TriangleDrawer { public: - static void draw(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture); - static void fill(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor); + static void draw(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture); + static void fill(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor); private: - static TriVertex shade_vertex(const TriMatrix &objectToWorld, TriVertex v); - static void draw_arrays(const TriMatrix &objectToWorld, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture, int solidcolor, void(*drawfunc)(const ScreenTriangleDrawerArgs *)); + static TriVertex shade_vertex(const TriMatrix &objectToClip, TriVertex v); + static void draw_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture, int solidcolor, void(*drawfunc)(const ScreenTriangleDrawerArgs *)); static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenTriangleDrawerArgs *args, void(*drawfunc)(const ScreenTriangleDrawerArgs *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert); From 92be8f401c11a9471fa0fd36b8f80fb829d59b31 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 7 Nov 2016 04:27:55 +0100 Subject: [PATCH 1168/1509] Remove old triangle version --- src/r_draw.h | 13 -------- src/r_draw_rgba.cpp | 2 ++ src/r_plane.cpp | 79 +-------------------------------------------- 3 files changed, 3 insertions(+), 91 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index 196e26bea..7556575bd 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -393,19 +393,6 @@ void R_DrawSingleSkyCol4_rgba(uint32_t solid_top, uint32_t solid_bottom); void R_DrawDoubleSkyCol1_rgba(uint32_t solid_top, uint32_t solid_bottom); void R_DrawDoubleSkyCol4_rgba(uint32_t solid_top, uint32_t solid_bottom); -struct TriVertex -{ - TriVertex() { } - TriVertex(float x, float y, float z, float w, float u, float v, float light) : x(x), y(y), z(z), w(w) { varying[0] = u; varying[1] = v; varying[2] = light; } - - enum { NumVarying = 3 }; - float x, y, z, w; - float varying[NumVarying]; -}; - -class VSMatrix; -void R_DrawTriangles(const VSMatrix &objectToWorld, const TriVertex *vertices, int count, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture); - extern bool r_swtruecolor; EXTERN_CVAR(Bool, r_multithreaded); diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index a649572cc..452de7962 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -1260,6 +1260,7 @@ void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) ///////////////////////////////////////////////////////////////////////////// +#if 0 class DrawTrianglesCommand : public DrawerCommand { public: @@ -1705,6 +1706,7 @@ void R_DrawTriangles(const VSMatrix &transform, const TriVertex *vertices, int c DrawerCommandQueue::QueueCommand(transform, vertices, count, clipleft, clipright, clipdata, texture->GetPixelsBgra(), texture->GetWidth(), texture->GetHeight()); } +#endif ///////////////////////////////////////////////////////////////////////////// diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 96225729b..f39360b59 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -66,7 +66,6 @@ #endif EXTERN_CVAR(Int, r_skymode) -CVAR(Bool, r_cubesky, false, 0) //EXTERN_CVAR (Int, tx) //EXTERN_CVAR (Int, ty) @@ -1016,77 +1015,6 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) } } -static void R_DrawCubeSky(visplane_t *pl) -{ - int x1 = pl->left; - int x2 = pl->right; - short *uwal = (short *)pl->top; - short *dwal = (short *)pl->bottom; - - static TriVertex cube[6 * 6] = - { - // Top - { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, - { 1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, - { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.1f, 1.0f }, - - { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.1f, 1.0f }, - { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.1f, 1.0f }, - { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, - - // Bottom - { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.9f, 1.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f }, - - { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f }, - { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.9f, 1.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.9f, 1.0f }, - - // Front - { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, - { 1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, - { -1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, - - { -1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, - - // Back - { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, - { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, - - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, - { -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, - { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, - - // Right - { 1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, - { 1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, - - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, - { 1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, - - // Left - { -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, - { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, - { -1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, - - { -1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, - { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f } - }; - - VSMatrix transform(0); - transform.translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); - transform.scale(1000.0f, 1000.0f, 1000.0f); - - R_DrawTriangles(transform, cube, 6 * 6, x1, x2 - 1, uwal, dwal, frontskytex); -} - static void R_DrawSkyColumnStripe(int start_x, int y1, int y2, int columns, double scale, double texturemid, double yrepeat) { uint32_t height = frontskytex->GetHeight(); @@ -1279,12 +1207,7 @@ static void R_DrawCapSky(visplane_t *pl) static void R_DrawSky (visplane_t *pl) { - if (r_swtruecolor && r_cubesky) - { - R_DrawCubeSky(pl); - return; - } - else if (r_skymode == 2) + if (r_skymode == 2) { R_DrawCapSky(pl); return; From 47cc110498f6db86a857d018b847139d5767157a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 7 Nov 2016 05:24:17 +0100 Subject: [PATCH 1169/1509] Add true color triangle drawer --- src/r_draw_rgba.cpp | 450 -------------------------------------- src/r_triangle.cpp | 513 ++++++++++++++++++++++++++++++++++++++++++-- src/r_triangle.h | 39 +++- 3 files changed, 525 insertions(+), 477 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 452de7962..b7be3ceed 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -1260,456 +1260,6 @@ void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) ///////////////////////////////////////////////////////////////////////////// -#if 0 -class DrawTrianglesCommand : public DrawerCommand -{ -public: - DrawTrianglesCommand(const VSMatrix &transform, const TriVertex *vertices, int count, int clipleft, int clipright, const short *clipdata, const uint32_t *texturePixels, int textureWidth, int textureHeight) - : transform(transform), vertices(vertices), count(count), clipleft(clipleft), clipright(clipright), clipdata(clipdata), texturePixels(texturePixels), textureWidth(textureWidth), textureHeight(textureHeight) - { - } - - void Execute(DrawerThread *thread) override - { - int cliplength = clipright - clipleft + 1; - for (int i = 0; i < cliplength; i++) - { - thread->triangle_clip_top[clipleft + i] = clipdata[i]; - thread->triangle_clip_bottom[clipleft + i] = clipdata[cliplength + i]; - } - - draw_triangles(transform, vertices, count, clipleft, clipright, thread->triangle_clip_top, thread->triangle_clip_bottom, thread); - } - - FString DebugInfo() override - { - return "DrawTriangles"; - } - -private: - float gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) - { - float top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); - float bottom = (x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2); - return top / bottom; - } - - float grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) - { - float top = (c1 - c2) * (x0 - x2) - (c0 - c2) * (x1 - x2); - float bottom = -((x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2)); - return top / bottom; - } - - void triangle(uint32_t *dest, int pitch, const TriVertex &v1, const TriVertex &v2, const TriVertex &v3, int clipleft, int clipright, const short *cliptop, const short *clipbottom, DrawerThread *thread) - { - // 28.4 fixed-point coordinates - const int Y1 = (int)round(16.0f * v1.y); - const int Y2 = (int)round(16.0f * v2.y); - const int Y3 = (int)round(16.0f * v3.y); - - const int X1 = (int)round(16.0f * v1.x); - const int X2 = (int)round(16.0f * v2.x); - const int X3 = (int)round(16.0f * v3.x); - - // Deltas - const int DX12 = X1 - X2; - const int DX23 = X2 - X3; - const int DX31 = X3 - X1; - - const int DY12 = Y1 - Y2; - const int DY23 = Y2 - Y3; - const int DY31 = Y3 - Y1; - - // Fixed-point deltas - const int FDX12 = DX12 << 4; - const int FDX23 = DX23 << 4; - const int FDX31 = DX31 << 4; - - const int FDY12 = DY12 << 4; - const int FDY23 = DY23 << 4; - const int FDY31 = DY31 << 4; - - // Bounding rectangle - int clipymin = cliptop[clipleft]; - int clipymax = clipbottom[clipleft]; - for (int i = clipleft + 1; i <= clipright; i++) - { - clipymin = MIN(clipymin, (int)cliptop[i]); - clipymax = MAX(clipymax, (int)clipbottom[i]); - } - int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); - int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright); - int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, clipymin); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipymax - 1); - if (minx >= maxx || miny >= maxy) - return; - - // Block size, standard 8x8 (must be power of two) - const int q = 8; - - // Start in corner of 8x8 block - minx &= ~(q - 1); - miny &= ~(q - 1); - - dest += miny * pitch; - - // Half-edge constants - int C1 = DY12 * X1 - DX12 * Y1; - int C2 = DY23 * X2 - DX23 * Y2; - int C3 = DY31 * X3 - DX31 * Y3; - - // Correct for fill convention - if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; - if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; - if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; - - // Gradients - float gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - float gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - float startW = v1.w + gradWX * (minx - v1.x) + gradWY * (miny - v1.y); - float gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (minx - v1.x) + gradVaryingY[i] * (miny - v1.y); - } - - // Loop through blocks - for (int y = miny; y < maxy; y += q) - { - for (int x = minx; x < maxx; x += q) - { - // Corners of block - int x0 = x << 4; - int x1 = (x + q - 1) << 4; - int y0 = y << 4; - int y1 = (y + q - 1) << 4; - - // Evaluate half-space functions - bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; - bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; - bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; - bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; - int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); - - bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; - bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; - bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; - bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; - int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); - - bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; - bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; - bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; - bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; - int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); - - // Skip block when outside an edge - if (a == 0x0 || b == 0x0 || c == 0x0) continue; - - // Check if block needs clipping - int clipcount = 0; - for (int ix = x; ix < x + q; ix++) - { - clipcount += (clipleft > ix) || (clipright < ix) || (cliptop[ix] > y) || (clipbottom[ix] <= y + q - 1); - } - - // Calculate varying variables for affine block - float offx0 = (x - minx) + 0.5f; - float offy0 = (y - miny) + 0.5f; - float offx1 = offx0 + q; - float offy1 = offy0 + q; - float rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); - float rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); - float rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); - float rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); - float varyingTL[TriVertex::NumVarying]; - float varyingTR[TriVertex::NumVarying]; - float varyingBL[TriVertex::NumVarying]; - float varyingBR[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; - varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; - varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); - varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); - } - - uint32_t *buffer = dest; - - // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && clipcount == 0) - { - for (int iy = 0; iy < q; iy++) - { - float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - varying[i] = varyingTL[i] + varyingBL[i] * iy; - varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); - } - - if (!thread->skipped_by_thread(y + iy)) - { - for (int ix = x; ix < x + q; ix++) - { - uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); - uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); - //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); - - uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; - uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; - uint32_t uvoffset = upos * textureHeight + vpos; - - buffer[ix] = texturePixels[uvoffset]; - - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; - } - } - - buffer += pitch; - } - } - else // Partially covered block - { - int CY1 = C1 + DX12 * y0 - DY12 * x0; - int CY2 = C2 + DX23 * y0 - DY23 * x0; - int CY3 = C3 + DX31 * y0 - DY31 * x0; - - for (int iy = 0; iy < q; iy++) - { - int CX1 = CY1; - int CX2 = CY2; - int CX3 = CY3; - - float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - varying[i] = varyingTL[i] + varyingBL[i] * iy; - varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); - } - - if (!thread->skipped_by_thread(y + iy)) - { - for (int ix = x; ix < x + q; ix++) - { - bool visible = ix >= clipleft && ix <= clipright && (cliptop[ix] <= y + iy) && (clipbottom[ix] > y + iy); - - if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) - { - uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); - uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); - //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); - - uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; - uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; - uint32_t uvoffset = upos * textureHeight + vpos; - - buffer[ix] = texturePixels[uvoffset]; - } - - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; - - CX1 -= FDY12; - CX2 -= FDY23; - CX3 -= FDY31; - } - } - - CY1 += FDX12; - CY2 += FDX23; - CY3 += FDX31; - - buffer += pitch; - } - } - } - - dest += q * pitch; - } - } - - bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2) - { - float d1 = clipdistance1 * (1.0f - t1) + clipdistance2 * t1; - float d2 = clipdistance1 * (1.0f - t2) + clipdistance2 * t2; - if (d1 < 0.0f && d2 < 0.0f) - return true; - - if (d1 < 0.0f) - t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), t1); - - if (d2 < 0.0f) - t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2); - - return false; - } - - void clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert) - { - // Clip and cull so that the following is true for all vertices: - // -v.w <= v.x <= v.w - // -v.w <= v.y <= v.w - // -v.w <= v.z <= v.w - - float t1 = 0.0f, t2 = 1.0f; - bool culled = - cullhalfspace(v1.x + v1.w, v2.x + v2.w, t1, t2) || - cullhalfspace(v1.w - v1.x, v2.w - v2.x, t1, t2) || - cullhalfspace(v1.y + v1.w, v2.y + v2.w, t1, t2) || - cullhalfspace(v1.w - v1.y, v2.w - v2.y, t1, t2) || - cullhalfspace(v1.z + v1.w, v2.z + v2.w, t1, t2) || - cullhalfspace(v1.w - v1.z, v2.w - v2.z, t1, t2); - if (culled) - return; - - if (t1 == 0.0f) - { - clippedvert[numclipvert++] = v1; - } - else - { - auto &v = clippedvert[numclipvert++]; - v.x = v1.x * (1.0f - t1) + v2.x * t1; - v.y = v1.y * (1.0f - t1) + v2.y * t1; - v.z = v1.z * (1.0f - t1) + v2.z * t1; - v.w = v1.w * (1.0f - t1) + v2.w * t1; - for (int i = 0; i < TriVertex::NumVarying; i++) - v.varying[i] = v1.varying[i] * (1.0f - t1) + v2.varying[i] * t1; - } - - if (t2 != 1.0f) - { - auto &v = clippedvert[numclipvert++]; - v.x = v1.x * (1.0f - t2) + v2.x * t2; - v.y = v1.y * (1.0f - t2) + v2.y * t2; - v.z = v1.z * (1.0f - t2) + v2.z * t2; - v.w = v1.w * (1.0f - t2) + v2.w * t2; - for (int i = 0; i < TriVertex::NumVarying; i++) - v.varying[i] = v1.varying[i] * (1.0f - t2) + v2.varying[i] * t2; - } - } - - void draw_triangles(const VSMatrix &transform, const TriVertex *vinput, int vcount, int clipleft, int clipright, const short *cliptop, const short *clipbottom, DrawerThread *thread) - { - for (int i = 0; i < vcount / 3; i++) - { - TriVertex vert[3]; - - // Vertex shader stuff: - for (int j = 0; j < 3; j++) - { - auto &v = vert[j]; - v = *(vinput++); - - // Apply transform to get world coordinates: - const float *matrix = transform.get(); - float vx = matrix[0 * 4 + 0] * v.x + matrix[1 * 4 + 0] * v.y + matrix[2 * 4 + 0] * v.z + matrix[3 * 4 + 0] * v.w; - float vy = matrix[0 * 4 + 1] * v.x + matrix[1 * 4 + 1] * v.y + matrix[2 * 4 + 1] * v.z + matrix[3 * 4 + 1] * v.w; - float vz = matrix[0 * 4 + 2] * v.x + matrix[1 * 4 + 2] * v.y + matrix[2 * 4 + 2] * v.z + matrix[3 * 4 + 2] * v.w; - float vw = matrix[0 * 4 + 3] * v.x + matrix[1 * 4 + 3] * v.y + matrix[2 * 4 + 3] * v.z + matrix[3 * 4 + 3] * v.w; - v.x = vx; - v.y = vy; - v.z = vz; - v.w = vw; - - // The software renderer world to clip transform: - double nearp = 5.0f; - double farp = 65536.f; - double tr_x = v.x - ViewPos.X; - double tr_y = v.y - ViewPos.Y; - double tr_z = v.z - ViewPos.Z; - double tx = tr_x * ViewSin - tr_y * ViewCos; - double tz = tr_x * ViewTanCos + tr_y * ViewTanSin; - v.x = (float)tx * 0.5f; - v.y = (float)tr_z * 0.5f; - v.z = (float)((-tz * (farp + nearp) / (nearp - farp) + (2.0f * farp * nearp) / (nearp - farp))); - v.w = (float)tz; - } - - // Cull, clip and generate additional vertices as needed - TriVertex clippedvert[6]; - int numclipvert = 0; - clipedge(vert[0], vert[1], clippedvert, numclipvert); - clipedge(vert[1], vert[2], clippedvert, numclipvert); - clipedge(vert[2], vert[0], clippedvert, numclipvert); - - // Map to 2D viewport: - for (int j = 0; j < numclipvert; j++) - { - auto &v = clippedvert[j]; - - // Calculate normalized device coordinates: - v.w = 1.0f / v.w; - v.x *= v.w; - v.y *= v.w; - v.z *= v.w; - - // Apply viewport scale to get screen coordinates: - v.x = (float)(CenterX + v.x * 2.0f * CenterX); - v.y = (float)(CenterY - v.y * 2.0f * InvZtoScale); - } - - // Draw screen triangles - bool ccw = false; - if (ccw) - { - for (int i = numclipvert; i > 1; i--) - { - triangle((uint32_t*)dc_destorg, dc_pitch, clippedvert[numclipvert - 1], clippedvert[i - 1], clippedvert[i - 2], clipleft, clipright, cliptop, clipbottom, thread); - } - } - else - { - for (int i = 2; i < numclipvert; i++) - { - triangle((uint32_t*)dc_destorg, dc_pitch, clippedvert[0], clippedvert[i - 1], clippedvert[i], clipleft, clipright, cliptop, clipbottom, thread); - } - } - } - } - - VSMatrix transform; - const TriVertex *vertices; - int count; - int clipleft; - int clipright; - const short *clipdata; - const uint32_t *texturePixels; - int textureWidth; - int textureHeight; -}; - -void R_DrawTriangles(const VSMatrix &transform, const TriVertex *vertices, int count, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture) -{ - if (clipright < clipleft || clipleft < 0 || clipright > MAXWIDTH) - return; - - int cliplength = clipright - clipleft + 1; - short *clipdata = (short*)DrawerCommandQueue::AllocMemory(cliplength * 2 * sizeof(short)); - if (!clipdata) - { - DrawerCommandQueue::WaitForWorkers(); - clipdata = (short*)DrawerCommandQueue::AllocMemory(cliplength * 2 * sizeof(short)); - if (!clipdata) - return; - } - - for (int i = 0; i < cliplength; i++) - clipdata[i] = cliptop[clipleft + i]; - for (int i = 0; i < cliplength; i++) - clipdata[cliplength + i] = clipbottom[clipleft + i]; - - DrawerCommandQueue::QueueCommand(transform, vertices, count, clipleft, clipright, clipdata, texture->GetPixelsBgra(), texture->GetWidth(), texture->GetHeight()); -} -#endif - -///////////////////////////////////////////////////////////////////////////// - void R_DrawSingleSkyCol1_rgba(uint32_t solid_top, uint32_t solid_bottom) { DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); diff --git a/src/r_triangle.cpp b/src/r_triangle.cpp index b039ed1ff..59a446407 100644 --- a/src/r_triangle.cpp +++ b/src/r_triangle.cpp @@ -38,15 +38,44 @@ void TriangleDrawer::draw(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture) { - draw_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texture, 0, &ScreenTriangleDrawer::draw); + if (r_swtruecolor) + queue_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, (const uint8_t*)texture->GetPixelsBgra(), texture->GetWidth(), texture->GetHeight(), 0); + else + draw_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texture->GetPixels(), texture->GetWidth(), texture->GetHeight(), 0, nullptr, &ScreenTriangleDrawer::draw); } void TriangleDrawer::fill(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor) { - draw_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, solidcolor, &ScreenTriangleDrawer::fill); + if (r_swtruecolor) + queue_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor); + else + draw_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor, nullptr, &ScreenTriangleDrawer::fill); } -void TriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture, int solidcolor, void(*drawfunc)(const ScreenTriangleDrawerArgs *)) +void TriangleDrawer::queue_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) +{ + if (clipright < clipleft || clipleft < 0 || clipright > MAXWIDTH) + return; + + int cliplength = clipright - clipleft + 1; + short *clipdata = (short*)DrawerCommandQueue::AllocMemory(cliplength * 2 * sizeof(short)); + if (!clipdata) + { + DrawerCommandQueue::WaitForWorkers(); + clipdata = (short*)DrawerCommandQueue::AllocMemory(cliplength * 2 * sizeof(short)); + if (!clipdata) + return; + } + + for (int i = 0; i < cliplength; i++) + clipdata[i] = cliptop[clipleft + i]; + for (int i = 0; i < cliplength; i++) + clipdata[cliplength + i] = clipbottom[clipleft + i]; + + DrawerCommandQueue::QueueCommand(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, clipdata, texturePixels, textureWidth, textureHeight, solidcolor); +} + +void TriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)) { if (vcount < 3) return; @@ -58,18 +87,9 @@ void TriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVertex args.clipright = clipright; args.cliptop = cliptop; args.clipbottom = clipbottom; - if (texture) - { - args.textureWidth = texture->GetWidth(); - args.textureHeight = texture->GetHeight(); - args.texturePixels = texture->GetPixels(); - } - else - { - args.textureWidth = 0; - args.textureHeight = 0; - args.texturePixels = nullptr; - } + args.texturePixels = texturePixels; + args.textureWidth = textureWidth; + args.textureHeight = textureHeight; args.solidcolor = solidcolor; TriVertex vert[3]; @@ -79,7 +99,7 @@ void TriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVertex { for (int j = 0; j < 3; j++) vert[j] = shade_vertex(objectToClip, *(vinput++)); - draw_shaded_triangle(vert, ccw, &args, drawfunc); + draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); } } else if (mode == TriangleDrawMode::Fan) @@ -89,7 +109,7 @@ void TriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVertex for (int i = 2; i < vcount; i++) { vert[2] = shade_vertex(objectToClip, *(vinput++)); - draw_shaded_triangle(vert, ccw, &args, drawfunc); + draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); vert[1] = vert[2]; } } @@ -100,7 +120,7 @@ void TriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVertex for (int i = 2; i < vcount; i++) { vert[2] = shade_vertex(objectToClip, *(vinput++)); - draw_shaded_triangle(vert, ccw, &args, drawfunc); + draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); vert[0] = vert[1]; vert[1] = vert[2]; ccw = !ccw; @@ -114,7 +134,7 @@ TriVertex TriangleDrawer::shade_vertex(const TriMatrix &objectToClip, TriVertex return objectToClip * v; } -void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenTriangleDrawerArgs *args, void(*drawfunc)(const ScreenTriangleDrawerArgs *)) +void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)) { // Cull, clip and generate additional vertices as needed TriVertex clippedvert[6]; @@ -147,7 +167,7 @@ void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, Scree args->v1 = &clippedvert[numclipvert - 1]; args->v2 = &clippedvert[i - 1]; args->v3 = &clippedvert[i - 2]; - drawfunc(args); + drawfunc(args, thread); } } else @@ -157,7 +177,7 @@ void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, Scree args->v1 = &clippedvert[0]; args->v2 = &clippedvert[i - 1]; args->v3 = &clippedvert[i]; - drawfunc(args); + drawfunc(args, thread); } } } @@ -225,7 +245,7 @@ void TriangleDrawer::clipedge(const TriVertex &v1, const TriVertex &v2, TriVerte ///////////////////////////////////////////////////////////////////////////// -void ScreenTriangleDrawer::draw(const ScreenTriangleDrawerArgs *args) +void ScreenTriangleDrawer::draw(const ScreenTriangleDrawerArgs *args, DrawerThread *thread) { uint8_t *dest = args->dest; int pitch = args->pitch; @@ -464,7 +484,7 @@ void ScreenTriangleDrawer::draw(const ScreenTriangleDrawerArgs *args) } } -void ScreenTriangleDrawer::fill(const ScreenTriangleDrawerArgs *args) +void ScreenTriangleDrawer::fill(const ScreenTriangleDrawerArgs *args, DrawerThread *thread) { uint8_t *dest = args->dest; int pitch = args->pitch; @@ -632,6 +652,425 @@ void ScreenTriangleDrawer::fill(const ScreenTriangleDrawerArgs *args) } } +void ScreenTriangleDrawer::draw32(const ScreenTriangleDrawerArgs *args, DrawerThread *thread) +{ + uint32_t *dest = (uint32_t *)args->dest; + int pitch = args->pitch; + const TriVertex &v1 = *args->v1; + const TriVertex &v2 = *args->v2; + const TriVertex &v3 = *args->v3; + int clipleft = args->clipleft; + int clipright = args->clipright; + const short *cliptop = args->cliptop; + const short *clipbottom = args->clipbottom; + const uint32_t *texturePixels = (const uint32_t *)args->texturePixels; + int textureWidth = args->textureWidth; + int textureHeight = args->textureHeight; + + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int clipymin = cliptop[clipleft]; + int clipymax = clipbottom[clipleft]; + for (int i = clipleft + 1; i <= clipright; i++) + { + clipymin = MIN(clipymin, (int)cliptop[i]); + clipymax = MAX(clipymax, (int)clipbottom[i]); + } + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, clipymin); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipymax - 1); + if (minx >= maxx || miny >= maxy) + return; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + dest += miny * pitch; + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // Gradients + float gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + float gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + float startW = v1.w + gradWX * (minx - v1.x) + gradWY * (miny - v1.y); + float gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (minx - v1.x) + gradVaryingY[i] * (miny - v1.y); + } + + // Loop through blocks + for (int y = miny; y < maxy; y += q) + { + for (int x = minx; x < maxx; x += q) + { + // Corners of block + int x0 = x << 4; + int x1 = (x + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; + bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; + bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; + bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; + int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); + + bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; + bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; + bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; + bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; + int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); + + bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; + bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; + bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; + bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; + int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + + // Skip block when outside an edge + if (a == 0x0 || b == 0x0 || c == 0x0) continue; + + // Check if block needs clipping + int clipcount = 0; + for (int ix = x; ix < x + q; ix++) + { + clipcount += (clipleft > ix) || (clipright < ix) || (cliptop[ix] > y) || (clipbottom[ix] <= y + q - 1); + } + + // Calculate varying variables for affine block + float offx0 = (x - minx) + 0.5f; + float offy0 = (y - miny) + 0.5f; + float offx1 = offx0 + q; + float offy1 = offy0 + q; + float rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); + float rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); + float rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); + float rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); + float varyingTL[TriVertex::NumVarying]; + float varyingTR[TriVertex::NumVarying]; + float varyingBL[TriVertex::NumVarying]; + float varyingBR[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; + varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; + varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); + varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); + } + + uint32_t *buffer = dest; + + // Accept whole block when totally covered + if (a == 0xF && b == 0xF && c == 0xF && clipcount == 0) + { + for (int iy = 0; iy < q; iy++) + { + float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varying[i] = varyingTL[i] + varyingBL[i] * iy; + varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + } + + if (!thread->skipped_by_thread(y + iy)) + { + for (int ix = x; ix < x + q; ix++) + { + uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); + uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); + + uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; + uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; + uint32_t uvoffset = upos * textureHeight + vpos; + + buffer[ix] = texturePixels[uvoffset]; + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + } + } + + buffer += pitch; + } + } + else // Partially covered block + { + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; + + for (int iy = 0; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varying[i] = varyingTL[i] + varyingBL[i] * iy; + varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + } + + if (!thread->skipped_by_thread(y + iy)) + { + for (int ix = x; ix < x + q; ix++) + { + bool visible = ix >= clipleft && ix <= clipright && (cliptop[ix] <= y + iy) && (clipbottom[ix] > y + iy); + + if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) + { + uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); + uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); + + uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; + uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; + uint32_t uvoffset = upos * textureHeight + vpos; + + buffer[ix] = texturePixels[uvoffset]; + } + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + + buffer += pitch; + } + } + } + + dest += q * pitch; + } +} + +void ScreenTriangleDrawer::fill32(const ScreenTriangleDrawerArgs *args, DrawerThread *thread) +{ + uint32_t *dest = (uint32_t *)args->dest; + int pitch = args->pitch; + const TriVertex &v1 = *args->v1; + const TriVertex &v2 = *args->v2; + const TriVertex &v3 = *args->v3; + int clipleft = args->clipleft; + int clipright = args->clipright; + const short *cliptop = args->cliptop; + const short *clipbottom = args->clipbottom; + int solidcolor = args->solidcolor; + + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int clipymin = cliptop[clipleft]; + int clipymax = clipbottom[clipleft]; + for (int i = clipleft + 1; i <= clipright; i++) + { + clipymin = MIN(clipymin, (int)cliptop[i]); + clipymax = MAX(clipymax, (int)clipbottom[i]); + } + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, clipymin); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipymax - 1); + if (minx >= maxx || miny >= maxy) + return; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + dest += miny * pitch; + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // Loop through blocks + for (int y = miny; y < maxy; y += q) + { + for (int x = minx; x < maxx; x += q) + { + // Corners of block + int x0 = x << 4; + int x1 = (x + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; + bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; + bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; + bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; + int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); + + bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; + bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; + bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; + bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; + int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); + + bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; + bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; + bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; + bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; + int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + + // Skip block when outside an edge + if (a == 0x0 || b == 0x0 || c == 0x0) continue; + + // Check if block needs clipping + int clipcount = 0; + for (int ix = x; ix < x + q; ix++) + { + clipcount += (clipleft > ix) || (clipright < ix) || (cliptop[ix] > y) || (clipbottom[ix] <= y + q - 1); + } + + uint32_t *buffer = dest; + + // Accept whole block when totally covered + if (a == 0xF && b == 0xF && c == 0xF && clipcount == 0) + { + for (int iy = 0; iy < q; iy++) + { + if (!thread->skipped_by_thread(y + iy)) + { + for (int ix = x; ix < x + q; ix++) + { + buffer[ix] = solidcolor; + } + } + + buffer += pitch; + } + } + else // Partially covered block + { + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; + + for (int iy = 0; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + if (!thread->skipped_by_thread(y + iy)) + { + for (int ix = x; ix < x + q; ix++) + { + bool visible = ix >= clipleft && ix <= clipright && (cliptop[ix] <= y + iy) && (clipbottom[ix] > y + iy); + + if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) + { + buffer[ix] = solidcolor; + } + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + + buffer += pitch; + } + } + } + + dest += q * pitch; + } +} + float ScreenTriangleDrawer::gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) { float top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); @@ -770,3 +1209,31 @@ TriVertex TriMatrix::operator*(TriVertex v) const v.w = vw; return v; } + +///////////////////////////////////////////////////////////////////////////// + +DrawTrianglesCommand::DrawTrianglesCommand(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *clipdata, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) + : objectToClip(objectToClip), vinput(vinput), vcount(vcount), mode(mode), ccw(ccw), clipleft(clipleft), clipright(clipright), clipdata(clipdata), texturePixels(texturePixels), textureWidth(textureWidth), textureHeight(textureHeight), solidcolor(solidcolor) +{ +} + +void DrawTrianglesCommand::Execute(DrawerThread *thread) +{ + int cliplength = clipright - clipleft + 1; + for (int i = 0; i < cliplength; i++) + { + thread->triangle_clip_top[clipleft + i] = clipdata[i]; + thread->triangle_clip_bottom[clipleft + i] = clipdata[cliplength + i]; + } + + TriangleDrawer::draw_arrays( + objectToClip, vinput, vcount, mode, ccw, + clipleft, clipright, thread->triangle_clip_top, thread->triangle_clip_bottom, + texturePixels, textureWidth, textureHeight, solidcolor, + thread, texturePixels ? ScreenTriangleDrawer::draw32 : ScreenTriangleDrawer::fill32); +} + +FString DrawTrianglesCommand::DebugInfo() +{ + return "DrawTriangles"; +} diff --git a/src/r_triangle.h b/src/r_triangle.h index 05cfada98..8335f1f93 100644 --- a/src/r_triangle.h +++ b/src/r_triangle.h @@ -25,6 +25,7 @@ #define __R_TRIANGLE__ #include "r_draw.h" +#include "r_thread.h" class FTexture; struct ScreenTriangleDrawerArgs; @@ -72,10 +73,14 @@ public: private: static TriVertex shade_vertex(const TriMatrix &objectToClip, TriVertex v); - static void draw_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture, int solidcolor, void(*drawfunc)(const ScreenTriangleDrawerArgs *)); - static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenTriangleDrawerArgs *args, void(*drawfunc)(const ScreenTriangleDrawerArgs *)); + static void draw_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)); + static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert); + + static void queue_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); + + friend class DrawTrianglesCommand; }; struct ScreenTriangleDrawerArgs @@ -98,12 +103,38 @@ struct ScreenTriangleDrawerArgs class ScreenTriangleDrawer { public: - static void draw(const ScreenTriangleDrawerArgs *args); - static void fill(const ScreenTriangleDrawerArgs *args); + static void draw(const ScreenTriangleDrawerArgs *args, DrawerThread *thread); + static void fill(const ScreenTriangleDrawerArgs *args, DrawerThread *thread); + + static void draw32(const ScreenTriangleDrawerArgs *args, DrawerThread *thread); + static void fill32(const ScreenTriangleDrawerArgs *args, DrawerThread *thread); private: static float gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); static float grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); }; +class DrawTrianglesCommand : public DrawerCommand +{ +public: + DrawTrianglesCommand(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *clipdata, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); + + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + +private: + TriMatrix objectToClip; + const TriVertex *vinput; + int vcount; + TriangleDrawMode mode; + bool ccw; + int clipleft; + int clipright; + const short *clipdata; + const uint8_t *texturePixels; + int textureWidth; + int textureHeight; + int solidcolor; +}; + #endif From 237f54f4be930874cce88a7c8097b75b8b9e7dab Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 7 Nov 2016 09:25:12 +0100 Subject: [PATCH 1170/1509] Toying with triangle drawer and GL BSP nodes --- src/CMakeLists.txt | 1 + src/r_main.cpp | 17 +- src/r_poly.cpp | 852 +++++++++++++++++++++++++++++++++++++++++++++ src/r_poly.h | 140 ++++++++ src/r_triangle.cpp | 22 ++ src/r_triangle.h | 2 + 6 files changed, 1030 insertions(+), 4 deletions(-) create mode 100644 src/r_poly.cpp create mode 100644 src/r_poly.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 723b95412..91553e275 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1051,6 +1051,7 @@ set( NOT_COMPILED_SOURCE_FILES set( FASTMATH_PCH_SOURCES r_swrenderer.cpp r_swrenderer2.cpp + r_poly.cpp r_3dfloors.cpp r_bsp.cpp r_draw.cpp diff --git a/src/r_main.cpp b/src/r_main.cpp index dfbcf2e71..5983e538b 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -60,8 +60,17 @@ #include "r_data/colormaps.h" #include "p_maputl.h" #include "r_swrenderer2.h" +#include "r_poly.h" +#include "p_setup.h" +#include "version.h" -CVAR(Bool, r_newrenderer, 0, 0); +CUSTOM_CVAR(Bool, r_newrenderer, 0, CVAR_NOINITCALL) +{ + if (self == 1 && !hasglnodes) + { + Printf("No GL BSP detected. You must enable automap texturing and then restart the map\n"); + } +} // MACROS ------------------------------------------------------------------ @@ -907,13 +916,13 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) // Link the polyobjects right before drawing the scene to reduce the amounts of calls to this function PO_LinkToSubsectors(); InSubsector = NULL; - if (!r_newrenderer || !r_swtruecolor) + if (!r_newrenderer) { R_RenderBSPNode(nodes + numnodes - 1); // The head node is the last node output. } else { - RenderBsp bsp; + RenderPolyBsp bsp; bsp.Render(); } R_3D_ResetClip(); // reset clips (floor/ceiling) @@ -925,7 +934,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) if (viewactive) { PlaneCycles.Clock(); - if (!r_newrenderer || !r_swtruecolor) + if (!r_newrenderer) { R_DrawPlanes(); R_DrawPortals(); diff --git a/src/r_poly.cpp b/src/r_poly.cpp new file mode 100644 index 000000000..a1b099f63 --- /dev/null +++ b/src/r_poly.cpp @@ -0,0 +1,852 @@ +/* +** Experimental Doom software renderer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "sbar.h" +#include "r_data/r_translate.h" +#include "r_poly.h" +#include "r_draw.h" +#include "r_plane.h" // for yslope +#include "r_sky.h" // for skyflatnum +#include "r_things.h" // for pspritexscale + +EXTERN_CVAR(Bool, r_drawplayersprites) +EXTERN_CVAR(Bool, r_deathcamera) +EXTERN_CVAR(Bool, st_scale) + +namespace +{ + short cliptop[MAXWIDTH], clipbottom[MAXWIDTH]; +} + +///////////////////////////////////////////////////////////////////////////// + +void RenderPolyBsp::Render() +{ + PolyVertexBuffer::Clear(); + + for (int i = 0; i < viewwidth; i++) + { + cliptop[i] = 0; + clipbottom[i] = viewheight; + } + + // Perspective correct: + float ratio = WidescreenRatio; + float fovratio = (WidescreenRatio >= 1.3f) ? 1.333333f : ratio; + float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(FieldOfView.Radians() / 2) / fovratio)).Degrees); + TriMatrix worldToView = + TriMatrix::scale(1.0f, (float)YaspectMul, 1.0f) * + TriMatrix::rotate((float)ViewPitch.Radians(), 1.0f, 0.0f, 0.0f) * + TriMatrix::rotate((float)(ViewAngle - 90).Radians(), 0.0f, -1.0f, 0.0f) * + TriMatrix::swapYZ() * + TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); + worldToClip = TriMatrix::perspective(fovy, ratio, 5.0, 65535.0f) * worldToView; + + // Y shearing like the Doom renderer: + //worldToClip = TriMatrix::viewToClip() * TriMatrix::worldToView(); + + // Cull front to back (ok, so we dont cull yet, but we should during this!): + if (numnodes == 0) + PvsSectors.push_back(subsectors); // RenderSubsector(subsectors); + else + RenderNode(nodes + numnodes - 1); // The head node is the last node output. + + // Render back to front (we don't have a zbuffer at the moment, sniff!): + for (auto it = PvsSectors.rbegin(); it != PvsSectors.rend(); ++it) + RenderSubsector(*it); + + RenderPlayerSprites(); + RenderScreenSprites(); // To do: should be called by FSoftwareRenderer::DrawRemainingPlayerSprites instead of here +} + +void RenderPolyBsp::RenderScreenSprites() +{ + for (auto &sprite : ScreenSprites) + sprite.Render(); +} + +void RenderPolyBsp::RenderSubsector(subsector_t *sub) +{ + sector_t *frontsector = sub->sector; + frontsector->MoreFlags |= SECF_DRAWN; + + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + if (line->sidedef == NULL || !(line->sidedef->Flags & WALLF_POLYOBJ)) + AddLine(line, frontsector); + } + + TriVertex *floorVertices = PolyVertexBuffer::GetVertices(sub->numlines); + TriVertex *ceilVertices = PolyVertexBuffer::GetVertices(sub->numlines); + if (floorVertices == nullptr || ceilVertices == nullptr) + return; + + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + int j = sub->numlines - 1 - i; + ceilVertices[j].x = (float)line->v1->fPos().X; + ceilVertices[j].y = (float)line->v1->fPos().Y; + ceilVertices[j].z = (float)frontsector->ceilingplane.ZatPoint(line->v1); + ceilVertices[j].w = 1.0f; + ceilVertices[j].varying[0] = ceilVertices[j].x / 64.0f; + ceilVertices[j].varying[1] = ceilVertices[j].y / 64.0f; + ceilVertices[j].varying[2] = 1.0f; + + floorVertices[i].x = (float)line->v1->fPos().X; + floorVertices[i].y = (float)line->v1->fPos().Y; + floorVertices[i].z = (float)frontsector->floorplane.ZatPoint(line->v1); + floorVertices[i].w = 1.0f; + floorVertices[i].varying[0] = floorVertices[i].x / 64.0f; + floorVertices[i].varying[1] = floorVertices[i].y / 64.0f; + floorVertices[i].varying[2] = 1.0f; + } + + FTexture *floortex = TexMan(frontsector->GetTexture(sector_t::floor)); + if (floortex->UseType != FTexture::TEX_Null) + TriangleDrawer::draw(worldToClip, floorVertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, cliptop, clipbottom, floortex); + + FTexture *ceiltex = TexMan(frontsector->GetTexture(sector_t::ceiling)); + if (ceiltex->UseType != FTexture::TEX_Null) + TriangleDrawer::draw(worldToClip, ceilVertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, cliptop, clipbottom, ceiltex); + + /*for (AActor *thing = sub->sector->thinglist; thing != nullptr; thing = thing->snext) + { + if ((thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) + AddWallSprite(thing); + else + AddSprite(thing); + }*/ +} + +void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector) +{ + // Reject lines not facing viewer + DVector2 pt1 = line->v1->fPos() - ViewPos; + DVector2 pt2 = line->v2->fPos() - ViewPos; + if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0) + return; + + double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1); + double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1); + double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2); + double frontfloorz2 = frontsector->floorplane.ZatPoint(line->v2); + + //VisiblePlaneKey ceilingPlaneKey(frontsector->GetTexture(sector_t::ceiling), frontsector->ColorMap, frontsector->lightlevel, frontsector->ceilingplane, frontsector->planes[sector_t::ceiling].xform); + //VisiblePlaneKey floorPlaneKey(frontsector->GetTexture(sector_t::floor), frontsector->ColorMap, frontsector->lightlevel, frontsector->floorplane, frontsector->planes[sector_t::floor].xform); + + RenderPolyWall wall; + wall.Line = line; + wall.Colormap = frontsector->ColorMap; + wall.Masked = false; + + if (line->backsector == nullptr) + { + wall.SetCoords(line->v1->fPos(), line->v2->fPos(), frontceilz1, frontfloorz1, frontceilz2, frontfloorz2); + wall.TopZ = frontceilz1; + wall.BottomZ = frontfloorz1; + wall.UnpeggedCeil = frontceilz1; + wall.Texpart = side_t::mid; + wall.Render(worldToClip); + } + else + { + sector_t *backsector = (line->backsector != line->frontsector) ? line->backsector : line->frontsector; + + double backceilz1 = backsector->ceilingplane.ZatPoint(line->v1); + double backfloorz1 = backsector->floorplane.ZatPoint(line->v1); + double backceilz2 = backsector->ceilingplane.ZatPoint(line->v2); + double backfloorz2 = backsector->floorplane.ZatPoint(line->v2); + + double topceilz1 = frontceilz1; + double topceilz2 = frontceilz2; + double topfloorz1 = MIN(backceilz1, frontceilz1); + double topfloorz2 = MIN(backceilz2, frontceilz2); + double bottomceilz1 = MAX(frontfloorz1, backfloorz1); + double bottomceilz2 = MAX(frontfloorz2, backfloorz2); + double bottomfloorz1 = frontfloorz1; + double bottomfloorz2 = frontfloorz2; + double middleceilz1 = topfloorz1; + double middleceilz2 = topfloorz2; + double middlefloorz1 = MIN(bottomceilz1, middleceilz1); + double middlefloorz2 = MIN(bottomceilz2, middleceilz2); + + bool bothSkyCeiling = false;// frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum; + bool bothSkyFloor = false;// frontsector->GetTexture(sector_t::floor) == skyflatnum && backsector->GetTexture(sector_t::floor) == skyflatnum; + + if ((topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && !bothSkyCeiling && line->sidedef) + { + wall.SetCoords(line->v1->fPos(), line->v2->fPos(), topceilz1, topfloorz1, topceilz2, topfloorz2); + wall.TopZ = topceilz1; + wall.BottomZ = topfloorz1; + wall.UnpeggedCeil = topceilz1; + wall.Texpart = side_t::top; + wall.Render(worldToClip); + } + + if ((bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && !bothSkyFloor && line->sidedef) + { + wall.SetCoords(line->v1->fPos(), line->v2->fPos(), bottomceilz1, bottomfloorz2, bottomceilz2, bottomfloorz2); + wall.TopZ = bottomceilz1; + wall.BottomZ = bottomfloorz2; + wall.UnpeggedCeil = topceilz1; + wall.Texpart = side_t::bottom; + wall.Render(worldToClip); + } + + if (line->sidedef) + { + FTexture *midtex = TexMan(line->sidedef->GetTexture(side_t::mid), true); + if (midtex && midtex->UseType != FTexture::TEX_Null) + { + wall.SetCoords(line->v1->fPos(), line->v2->fPos(), middleceilz1, middlefloorz1, middleceilz2, middlefloorz2); + wall.TopZ = middleceilz1; + wall.BottomZ = middlefloorz1; + wall.UnpeggedCeil = topceilz1; + wall.Texpart = side_t::mid; + wall.Masked = true; + wall.Render(worldToClip); + } + } + } +} + +void RenderPolyBsp::RenderNode(void *node) +{ + while (!((size_t)node & 1)) // Keep going until found a subsector + { + node_t *bsp = (node_t *)node; + + // Decide which side the view point is on. + int side = PointOnSide(ViewPos, bsp); + + // Recursively divide front space (toward the viewer). + RenderNode(bsp->children[side]); + + // Possibly divide back space (away from the viewer). + side ^= 1; + if (!CheckBBox(bsp->bbox[side])) + return; + + node = bsp->children[side]; + } + PvsSectors.push_back((subsector_t *)((BYTE *)node - 1)); + //RenderSubsector((subsector_t *)((BYTE *)node - 1)); +} + +void RenderPolyBsp::RenderPlayerSprites() +{ + if (!r_drawplayersprites || + !camera || + !camera->player || + (players[consoleplayer].cheats & CF_CHASECAM) || + (r_deathcamera && camera->health <= 0)) + return; + + float bobx, boby; + P_BobWeapon(camera->player, &bobx, &boby, r_TicFracF); + + // Interpolate the main weapon layer once so as to be able to add it to other layers. + double wx, wy; + DPSprite *weapon = camera->player->FindPSprite(PSP_WEAPON); + if (weapon) + { + if (weapon->firstTic) + { + wx = weapon->x; + wy = weapon->y; + } + else + { + wx = weapon->oldx + (weapon->x - weapon->oldx) * r_TicFracF; + wy = weapon->oldy + (weapon->y - weapon->oldy) * r_TicFracF; + } + } + else + { + wx = 0; + wy = 0; + } + + for (DPSprite *sprite = camera->player->psprites; sprite != nullptr; sprite = sprite->GetNext()) + { + // [RH] Don't draw the targeter's crosshair if the player already has a crosshair set. + // It's possible this psprite's caller is now null but the layer itself hasn't been destroyed + // because it didn't tick yet (if we typed 'take all' while in the console for example). + // In this case let's simply not draw it to avoid crashing. + if ((sprite->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr) && sprite->GetCaller() != nullptr) + { + RenderPlayerSprite(sprite, camera, bobx, boby, wx, wy, r_TicFracF); + } + } +} + +void RenderPolyBsp::RenderPlayerSprite(DPSprite *sprite, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac) +{ + // decide which patch to use + if ((unsigned)sprite->GetSprite() >= (unsigned)sprites.Size()) + { + DPrintf(DMSG_ERROR, "RenderPlayerSprite: invalid sprite number %i\n", sprite->GetSprite()); + return; + } + + spritedef_t *def = &sprites[sprite->GetSprite()]; + if (sprite->GetFrame() >= def->numframes) + { + DPrintf(DMSG_ERROR, "RenderPlayerSprite: invalid sprite frame %i : %i\n", sprite->GetSprite(), sprite->GetFrame()); + return; + } + + spriteframe_t *frame = &SpriteFrames[def->spriteframes + sprite->GetFrame()]; + FTextureID picnum = frame->Texture[0]; + bool flip = (frame->Flip & 1) != 0; + + FTexture *tex = TexMan(picnum); + if (tex->UseType == FTexture::TEX_Null) + return; + + // Can't interpolate the first tic. + if (sprite->firstTic) + { + sprite->firstTic = false; + sprite->oldx = sprite->x; + sprite->oldy = sprite->y; + } + + double sx = sprite->oldx + (sprite->x - sprite->oldx) * ticfrac; + double sy = sprite->oldy + (sprite->y - sprite->oldy) * ticfrac; + + if (sprite->Flags & PSPF_ADDBOB) + { + sx += bobx; + sy += boby; + } + + if (sprite->Flags & PSPF_ADDWEAPON && sprite->GetID() != PSP_WEAPON) + { + sx += wx; + sy += wy; + } + + // calculate edges of the shape + double tx = sx - BaseXCenter; + + tx -= tex->GetScaledLeftOffset(); + int x1 = xs_RoundToInt(CenterX + tx * pspritexscale); + + // off the right side + if (x1 > viewwidth) + return; + + tx += tex->GetScaledWidth(); + int x2 = xs_RoundToInt(CenterX + tx * pspritexscale); + + // off the left side + if (x2 <= 0) + return; + + double texturemid = (BaseYCenter - sy) * tex->Scale.Y + tex->TopOffset; + + // Adjust PSprite for fullscreen views + if (camera->player && (RenderTarget != screen || viewheight == RenderTarget->GetHeight() || (RenderTarget->GetWidth() > (BaseXCenter * 2) && !st_scale))) + { + AWeapon *weapon = dyn_cast(sprite->GetCaller()); + if (weapon != nullptr && weapon->YAdjust != 0) + { + if (RenderTarget != screen || viewheight == RenderTarget->GetHeight()) + { + texturemid -= weapon->YAdjust; + } + else + { + texturemid -= StatusBar->GetDisplacement() * weapon->YAdjust; + } + } + } + + // Move the weapon down for 1280x1024. + if (sprite->GetID() < PSP_TARGETCENTER) + { + texturemid -= AspectPspriteOffset(WidescreenRatio); + } + + int clipped_x1 = MAX(x1, 0); + int clipped_x2 = MIN(x2, viewwidth); + double xscale = pspritexscale / tex->Scale.X; + double yscale = pspriteyscale / tex->Scale.Y; + uint32_t translation = 0; // [RH] Use default colors + + double xiscale, startfrac; + if (flip) + { + xiscale = -pspritexiscale * tex->Scale.X; + startfrac = 1; + } + else + { + xiscale = pspritexiscale * tex->Scale.X; + startfrac = 0; + } + + if (clipped_x1 > x1) + startfrac += xiscale * (clipped_x1 - x1); + + bool noaccel = false; + + FDynamicColormap *basecolormap = viewsector->ColorMap; + FDynamicColormap *colormap_to_use = basecolormap; + + visstyle_t visstyle; + visstyle.ColormapNum = 0; + visstyle.BaseColormap = basecolormap; + visstyle.Alpha = 0; + visstyle.RenderStyle = STYLE_Normal; + + bool foggy = false; + int actualextralight = foggy ? 0 : extralight << 4; + int spriteshade = LIGHT2SHADE(owner->Sector->lightlevel + actualextralight); + double minz = double((2048 * 4) / double(1 << 20)); + visstyle.ColormapNum = GETPALOOKUP(r_SpriteVisibility / minz, spriteshade); + + if (sprite->GetID() < PSP_TARGETCENTER) + { + // Lots of complicated style and noaccel stuff + } + + // Check for hardware-assisted 2D. If it's available, and this sprite is not + // fuzzy, don't draw it until after the switch to 2D mode. + if (!noaccel && RenderTarget == screen && (DFrameBuffer *)screen->Accel2D) + { + FRenderStyle style = visstyle.RenderStyle; + style.CheckFuzz(); + if (style.BlendOp != STYLEOP_Fuzz) + { + PolyScreenSprite screenSprite; + screenSprite.Pic = tex; + screenSprite.X1 = viewwindowx + x1; + screenSprite.Y1 = viewwindowy + viewheight / 2 - texturemid * yscale - 0.5; + screenSprite.Width = tex->GetWidth() * xscale; + screenSprite.Height = tex->GetHeight() * yscale; + screenSprite.Translation = TranslationToTable(translation); + screenSprite.Flip = xiscale < 0; + screenSprite.visstyle = visstyle; + screenSprite.Colormap = colormap_to_use; + ScreenSprites.push_back(screenSprite); + return; + } + } + + //R_DrawVisSprite(vis); +} + +int RenderPolyBsp::PointOnSide(const DVector2 &pos, const node_t *node) +{ + return DMulScale32(FLOAT2FIXED(pos.Y) - node->y, node->dx, node->x - FLOAT2FIXED(pos.X), node->dy) > 0; +} + +bool RenderPolyBsp::CheckBBox(float *bspcoord) +{ + static const int checkcoord[12][4] = + { + { 3,0,2,1 }, + { 3,0,2,0 }, + { 3,1,2,0 }, + { 0 }, + { 2,0,2,1 }, + { 0,0,0,0 }, + { 3,1,3,0 }, + { 0 }, + { 2,0,3,1 }, + { 2,1,3,1 }, + { 2,1,3,0 } + }; + + int boxx; + int boxy; + int boxpos; + + double x1, y1, x2, y2; + double rx1, ry1, rx2, ry2; + int sx1, sx2; + + // Find the corners of the box + // that define the edges from current viewpoint. + if (ViewPos.X <= bspcoord[BOXLEFT]) + boxx = 0; + else if (ViewPos.X < bspcoord[BOXRIGHT]) + boxx = 1; + else + boxx = 2; + + if (ViewPos.Y >= bspcoord[BOXTOP]) + boxy = 0; + else if (ViewPos.Y > bspcoord[BOXBOTTOM]) + boxy = 1; + else + boxy = 2; + + boxpos = (boxy << 2) + boxx; + if (boxpos == 5) + return true; + + x1 = bspcoord[checkcoord[boxpos][0]] - ViewPos.X; + y1 = bspcoord[checkcoord[boxpos][1]] - ViewPos.Y; + x2 = bspcoord[checkcoord[boxpos][2]] - ViewPos.X; + y2 = bspcoord[checkcoord[boxpos][3]] - ViewPos.Y; + + // check clip list for an open space + + // Sitting on a line? + if (y1 * (x1 - x2) + x1 * (y2 - y1) >= -EQUAL_EPSILON) + return true; + + rx1 = x1 * ViewSin - y1 * ViewCos; + rx2 = x2 * ViewSin - y2 * ViewCos; + ry1 = x1 * ViewTanCos + y1 * ViewTanSin; + ry2 = x2 * ViewTanCos + y2 * ViewTanSin; + + /*if (MirrorFlags & RF_XFLIP) + { + double t = -rx1; + rx1 = -rx2; + rx2 = t; + swapvalues(ry1, ry2); + }*/ + + if (rx1 >= -ry1) + { + if (rx1 > ry1) return false; // left edge is off the right side + if (ry1 == 0) return false; + sx1 = xs_RoundToInt(CenterX + rx1 * CenterX / ry1); + } + else + { + if (rx2 < -ry2) return false; // wall is off the left side + if (rx1 - rx2 - ry2 + ry1 == 0) return false; // wall does not intersect view volume + sx1 = 0; + } + + if (rx2 <= ry2) + { + if (rx2 < -ry2) return false; // right edge is off the left side + if (ry2 == 0) return false; + sx2 = xs_RoundToInt(CenterX + rx2 * CenterX / ry2); + } + else + { + if (rx1 > ry1) return false; // wall is off the right side + if (ry2 - ry1 - rx2 + rx1 == 0) return false; // wall does not intersect view volume + sx2 = viewwidth; + } + + // Find the first clippost that touches the source post + // (adjacent pixels are touching). + + // Does not cross a pixel. + if (sx2 <= sx1) + return false; + + return true; +} + +///////////////////////////////////////////////////////////////////////////// + +void RenderPolyWall::Render(const TriMatrix &worldToClip) +{ + FTexture *tex = GetTexture(); + if (!tex) + return; + + PolyWallTextureCoords texcoords(tex, Line, Texpart, TopZ, BottomZ, UnpeggedCeil); + + TriVertex *vertices = PolyVertexBuffer::GetVertices(4); + if (!vertices) + return; + + vertices[0].x = (float)v1.X; + vertices[0].y = (float)v1.Y; + vertices[0].z = (float)ceil1; + vertices[0].w = 1.0f; + vertices[0].varying[0] = (float)texcoords.u1; + vertices[0].varying[1] = (float)texcoords.v1; + vertices[0].varying[2] = 1.0f; + + vertices[1].x = (float)v2.X; + vertices[1].y = (float)v2.Y; + vertices[1].z = (float)ceil2; + vertices[1].w = 1.0f; + vertices[1].varying[0] = (float)texcoords.u2; + vertices[1].varying[1] = (float)texcoords.v1; + vertices[1].varying[2] = 1.0f; + + vertices[2].x = (float)v2.X; + vertices[2].y = (float)v2.Y; + vertices[2].z = (float)floor2; + vertices[2].w = 1.0f; + vertices[2].varying[0] = (float)texcoords.u2; + vertices[2].varying[1] = (float)texcoords.v2; + vertices[2].varying[2] = 1.0f; + + vertices[3].x = (float)v1.X; + vertices[3].y = (float)v1.Y; + vertices[3].z = (float)floor1; + vertices[3].w = 1.0f; + vertices[3].varying[0] = (float)texcoords.u1; + vertices[3].varying[1] = (float)texcoords.v2; + vertices[3].varying[2] = 1.0f; + + TriangleDrawer::draw(worldToClip, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, cliptop, clipbottom, tex); +} + +FTexture *RenderPolyWall::GetTexture() +{ + FTexture *tex = TexMan(Line->sidedef->GetTexture(Texpart), true); + if (tex == nullptr || tex->UseType == FTexture::TEX_Null) + return nullptr; + else + return tex; +} + +int RenderPolyWall::GetShade() +{ + if (fixedlightlev >= 0 || fixedcolormap) + { + return 0; + } + else + { + bool foggy = false; + int actualextralight = foggy ? 0 : extralight << 4; + int shade = LIGHT2SHADE(Line->sidedef->GetLightLevel(foggy, Line->frontsector->lightlevel) + actualextralight); + return shade; + } +} + +/* +float RenderPolyWall::GetLight(short x) +{ + if (fixedlightlev >= 0 || fixedcolormap) + return 0.0f; + else + return (float)(r_WallVisibility / Coords.Z(x)); +} +*/ + +///////////////////////////////////////////////////////////////////////////// + +PolyWallTextureCoords::PolyWallTextureCoords(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil) +{ + CalcU(tex, line, texpart); + CalcV(tex, line, texpart, topz, bottomz, unpeggedceil); +} + +void PolyWallTextureCoords::CalcU(FTexture *tex, const seg_t *line, side_t::ETexpart texpart) +{ + double lineLength = line->sidedef->TexelLength; + double lineStart = 0.0; + + bool entireSegment = ((line->linedef->v1 == line->v1) && (line->linedef->v2 == line->v2) || (line->linedef->v2 == line->v1) && (line->linedef->v1 == line->v2)); + if (!entireSegment) + { + lineLength = (line->v2->fPos() - line->v1->fPos()).Length(); + lineStart = (line->v1->fPos() - line->linedef->v1->fPos()).Length(); + } + + int texWidth = tex->GetWidth(); + double uscale = line->sidedef->GetTextureXScale(texpart) * tex->Scale.X; + u1 = lineStart + line->sidedef->GetTextureXOffset(texpart); + u2 = u1 + lineLength; + u1 *= uscale; + u2 *= uscale; + u1 /= texWidth; + u2 /= texWidth; +} + +void PolyWallTextureCoords::CalcV(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil) +{ + double vscale = line->sidedef->GetTextureYScale(texpart) * tex->Scale.Y; + + double yoffset = line->sidedef->GetTextureYOffset(texpart); + if (tex->bWorldPanning) + yoffset *= vscale; + + switch (texpart) + { + default: + case side_t::mid: + CalcVMidPart(tex, line, topz, bottomz, vscale, yoffset); + break; + case side_t::top: + CalcVTopPart(tex, line, topz, bottomz, vscale, yoffset); + break; + case side_t::bottom: + CalcVBottomPart(tex, line, topz, bottomz, unpeggedceil, vscale, yoffset); + break; + } + + int texHeight = tex->GetHeight(); + v1 /= texHeight; + v2 /= texHeight; +} + +void PolyWallTextureCoords::CalcVTopPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset) +{ + bool pegged = (line->linedef->flags & ML_DONTPEGTOP) == 0; + if (pegged) // bottom to top + { + int texHeight = tex->GetHeight(); + v1 = -yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + v1 = texHeight - v1; + v2 = texHeight - v2; + std::swap(v1, v2); + } + else // top to bottom + { + v1 = yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + } +} + +void PolyWallTextureCoords::CalcVMidPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset) +{ + bool pegged = (line->linedef->flags & ML_DONTPEGBOTTOM) == 0; + if (pegged) // top to bottom + { + v1 = yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + } + else // bottom to top + { + int texHeight = tex->GetHeight(); + v1 = yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + v1 = texHeight - v1; + v2 = texHeight - v2; + std::swap(v1, v2); + } +} + +void PolyWallTextureCoords::CalcVBottomPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double unpeggedceil, double vscale, double yoffset) +{ + bool pegged = (line->linedef->flags & ML_DONTPEGBOTTOM) == 0; + if (pegged) // top to bottom + { + v1 = yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + } + else + { + v1 = yoffset + (unpeggedceil - topz); + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + } +} + +///////////////////////////////////////////////////////////////////////////// + +void PolyScreenSprite::Render() +{ + FSpecialColormap *special = nullptr; + FColormapStyle colormapstyle; + PalEntry overlay = 0; + bool usecolormapstyle = false; + if (visstyle.BaseColormap >= &SpecialColormaps[0] && + visstyle.BaseColormap < &SpecialColormaps[SpecialColormaps.Size()]) + { + special = static_cast(visstyle.BaseColormap); + } + else if (Colormap->Color == PalEntry(255, 255, 255) && + Colormap->Desaturate == 0) + { + overlay = Colormap->Fade; + overlay.a = BYTE(visstyle.ColormapNum * 255 / NUMCOLORMAPS); + } + else + { + usecolormapstyle = true; + colormapstyle.Color = Colormap->Color; + colormapstyle.Fade = Colormap->Fade; + colormapstyle.Desaturate = Colormap->Desaturate; + colormapstyle.FadeLevel = visstyle.ColormapNum / float(NUMCOLORMAPS); + } + + screen->DrawTexture(Pic, + X1, + Y1, + DTA_DestWidthF, Width, + DTA_DestHeightF, Height, + DTA_Translation, Translation, + DTA_FlipX, Flip, + DTA_TopOffset, 0, + DTA_LeftOffset, 0, + DTA_ClipLeft, viewwindowx, + DTA_ClipTop, viewwindowy, + DTA_ClipRight, viewwindowx + viewwidth, + DTA_ClipBottom, viewwindowy + viewheight, + DTA_AlphaF, visstyle.Alpha, + DTA_RenderStyle, visstyle.RenderStyle, + DTA_FillColor, FillColor, + DTA_SpecialColormap, special, + DTA_ColorOverlay, overlay.d, + DTA_ColormapStyle, usecolormapstyle ? &colormapstyle : NULL, + TAG_DONE); +} + +///////////////////////////////////////////////////////////////////////////// + +namespace +{ + int NextBufferVertex = 0; +} + +TriVertex *PolyVertexBuffer::GetVertices(int count) +{ + enum { VertexBufferSize = 16 * 1024 }; + static TriVertex Vertex[VertexBufferSize]; + + if (NextBufferVertex + count > VertexBufferSize) + return nullptr; + TriVertex *v = Vertex + NextBufferVertex; + NextBufferVertex += count; + return v; +} + +void PolyVertexBuffer::Clear() +{ + NextBufferVertex = 0; +} diff --git a/src/r_poly.h b/src/r_poly.h new file mode 100644 index 000000000..48bd2985a --- /dev/null +++ b/src/r_poly.h @@ -0,0 +1,140 @@ +/* +** Experimental Doom software renderer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +#include +#include +#include +#include +#include "doomdata.h" +#include "r_utility.h" +#include "r_main.h" +#include "r_triangle.h" + +// DScreen accelerated sprite to be rendered +class PolyScreenSprite +{ +public: + void Render(); + + FTexture *Pic = nullptr; + double X1 = 0.0; + double Y1 = 0.0; + double Width = 0.0; + double Height = 0.0; + FRemapTable *Translation = nullptr; + bool Flip = false; + visstyle_t visstyle; + uint32_t FillColor = 0; + FDynamicColormap *Colormap = nullptr; +}; + +// Renders a GL BSP tree in a scene +class RenderPolyBsp +{ +public: + void Render(); + void RenderScreenSprites(); + +private: + void RenderNode(void *node); + void RenderSubsector(subsector_t *sub); + void AddLine(seg_t *line, sector_t *frontsector); + + void RenderPlayerSprites(); + void RenderPlayerSprite(DPSprite *sprite, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac); + + int PointOnSide(const DVector2 &pos, const node_t *node); + + // Checks BSP node/subtree bounding box. + // Returns true if some part of the bbox might be visible. + bool CheckBBox(float *bspcoord); + + std::vector PvsSectors; + TriMatrix worldToClip; + + std::vector ScreenSprites; + + const int BaseXCenter = 160; + const int BaseYCenter = 100; +}; + +class RenderPolyWall +{ +public: + void Render(const TriMatrix &worldToClip); + + void SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2) + { + this->v1 = v1; + this->v2 = v2; + this->ceil1 = ceil1; + this->floor1 = floor1; + this->ceil2 = ceil2; + this->floor2 = floor2; + } + + DVector2 v1; + DVector2 v2; + double ceil1 = 0.0; + double floor1 = 0.0; + double ceil2 = 0.0; + double floor2 = 0.0; + + const seg_t *Line = nullptr; + side_t::ETexpart Texpart = side_t::mid; + double TopZ = 0.0; + double BottomZ = 0.0; + double UnpeggedCeil = 0.0; + FSWColormap *Colormap = nullptr; + bool Masked = false; + +private: + FTexture *GetTexture(); + int GetShade(); + //float GetLight(short x); +}; + +// Texture coordinates for a wall +class PolyWallTextureCoords +{ +public: + PolyWallTextureCoords(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil); + + double u1, u2; + double v1, v2; + +private: + void CalcU(FTexture *tex, const seg_t *line, side_t::ETexpart texpart); + void CalcV(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil); + void CalcVTopPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset); + void CalcVMidPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset); + void CalcVBottomPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double unpeggedceil, double vscale, double yoffset); +}; + +class PolyVertexBuffer +{ +public: + static TriVertex *GetVertices(int count); + static void Clear(); +}; diff --git a/src/r_triangle.cpp b/src/r_triangle.cpp index 59a446407..653a46f31 100644 --- a/src/r_triangle.cpp +++ b/src/r_triangle.cpp @@ -1141,6 +1141,28 @@ TriMatrix TriMatrix::rotate(float angle, float x, float y, float z) return m; } +TriMatrix TriMatrix::swapYZ() +{ + TriMatrix m = null(); + m.matrix[0 + 0 * 4] = 1.0f; + m.matrix[1 + 2 * 4] = 1.0f; + m.matrix[2 + 1 * 4] = -1.0f; + m.matrix[3 + 3 * 4] = 1.0f; + return m; +} + +TriMatrix TriMatrix::perspective(float fovy, float aspect, float z_near, float z_far) +{ + float f = (float)(1.0 / tan(fovy * M_PI / 360.0)); + TriMatrix m = null(); + m.matrix[0 + 0 * 4] = f / aspect; + m.matrix[1 + 1 * 4] = f; + m.matrix[2 + 2 * 4] = (z_far + z_near) / (z_near - z_far); + m.matrix[2 + 3 * 4] = (2.0f * z_far * z_near) / (z_near - z_far); + m.matrix[3 + 2 * 4] = -1.0f; + return m; +} + TriMatrix TriMatrix::frustum(float left, float right, float bottom, float top, float near, float far) { float a = (right + left) / (right - left); diff --git a/src/r_triangle.h b/src/r_triangle.h index 8335f1f93..98fa25db0 100644 --- a/src/r_triangle.h +++ b/src/r_triangle.h @@ -47,6 +47,8 @@ struct TriMatrix static TriMatrix translate(float x, float y, float z); static TriMatrix scale(float x, float y, float z); static TriMatrix rotate(float angle, float x, float y, float z); + static TriMatrix swapYZ(); + static TriMatrix perspective(float fovy, float aspect, float near, float far); static TriMatrix frustum(float left, float right, float bottom, float top, float near, float far); static TriMatrix worldToView(); // Software renderer world to view space transform From b9d6fc68566d63e8faaffa3f03987d7bbd31a40d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 8 Nov 2016 02:48:14 +0100 Subject: [PATCH 1171/1509] Add some light and transparency --- src/r_poly.cpp | 65 ++++++++++++++++++++++++++++------------------ src/r_poly.h | 4 +-- src/r_triangle.cpp | 22 +++++++++++++--- 3 files changed, 60 insertions(+), 31 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index a1b099f63..7bb54712f 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -62,7 +62,7 @@ void RenderPolyBsp::Render() TriMatrix::rotate((float)(ViewAngle - 90).Radians(), 0.0f, -1.0f, 0.0f) * TriMatrix::swapYZ() * TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); - worldToClip = TriMatrix::perspective(fovy, ratio, 5.0, 65535.0f) * worldToView; + worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; // Y shearing like the Doom renderer: //worldToClip = TriMatrix::viewToClip() * TriMatrix::worldToView(); @@ -87,6 +87,36 @@ void RenderPolyBsp::RenderScreenSprites() sprite.Render(); } +TriVertex RenderPolyBsp::PlaneVertex(vertex_t *v1, sector_t *sector, const secplane_t &plane) +{ + TriVertex v; + v.x = (float)v1->fPos().X; + v.y = (float)v1->fPos().Y; + v.z = (float)plane.ZatPoint(v1); + v.w = 1.0f; + v.varying[0] = v.x / 64.0f; + v.varying[1] = v.y / 64.0f; + + if (fixedlightlev >= 0) + v.varying[2] = fixedlightlev / 255.0f; + else if (fixedcolormap) + v.varying[2] = 1.0f; + else + v.varying[2] = sector->lightlevel / 255.0f; + + /* + double vis = r_FloorVisibility / (plane.Zat0() - ViewPos.Z); + if (fixedlightlev >= 0) + R_SetDSColorMapLight(sector->ColorMap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + else if (fixedcolormap) + R_SetDSColorMapLight(fixedcolormap, 0, 0); + else + R_SetDSColorMapLight(sector->ColorMap, (float)(vis * fabs(CenterY - y)), LIGHT2SHADE(sector->lightlevel)); + */ + + return v; +} + void RenderPolyBsp::RenderSubsector(subsector_t *sub) { sector_t *frontsector = sub->sector; @@ -107,22 +137,8 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) for (uint32_t i = 0; i < sub->numlines; i++) { seg_t *line = &sub->firstline[i]; - int j = sub->numlines - 1 - i; - ceilVertices[j].x = (float)line->v1->fPos().X; - ceilVertices[j].y = (float)line->v1->fPos().Y; - ceilVertices[j].z = (float)frontsector->ceilingplane.ZatPoint(line->v1); - ceilVertices[j].w = 1.0f; - ceilVertices[j].varying[0] = ceilVertices[j].x / 64.0f; - ceilVertices[j].varying[1] = ceilVertices[j].y / 64.0f; - ceilVertices[j].varying[2] = 1.0f; - - floorVertices[i].x = (float)line->v1->fPos().X; - floorVertices[i].y = (float)line->v1->fPos().Y; - floorVertices[i].z = (float)frontsector->floorplane.ZatPoint(line->v1); - floorVertices[i].w = 1.0f; - floorVertices[i].varying[0] = floorVertices[i].x / 64.0f; - floorVertices[i].varying[1] = floorVertices[i].y / 64.0f; - floorVertices[i].varying[2] = 1.0f; + ceilVertices[sub->numlines - 1 - i] = PlaneVertex(line->v1, frontsector, frontsector->ceilingplane); + floorVertices[i] = PlaneVertex(line->v1, frontsector, frontsector->floorplane); } FTexture *floortex = TexMan(frontsector->GetTexture(sector_t::floor)); @@ -592,7 +608,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) vertices[0].w = 1.0f; vertices[0].varying[0] = (float)texcoords.u1; vertices[0].varying[1] = (float)texcoords.v1; - vertices[0].varying[2] = 1.0f; + vertices[0].varying[2] = GetLightLevel() / 255.0f; vertices[1].x = (float)v2.X; vertices[1].y = (float)v2.Y; @@ -600,7 +616,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) vertices[1].w = 1.0f; vertices[1].varying[0] = (float)texcoords.u2; vertices[1].varying[1] = (float)texcoords.v1; - vertices[1].varying[2] = 1.0f; + vertices[1].varying[2] = GetLightLevel() / 255.0f; vertices[2].x = (float)v2.X; vertices[2].y = (float)v2.Y; @@ -608,7 +624,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) vertices[2].w = 1.0f; vertices[2].varying[0] = (float)texcoords.u2; vertices[2].varying[1] = (float)texcoords.v2; - vertices[2].varying[2] = 1.0f; + vertices[2].varying[2] = GetLightLevel() / 255.0f; vertices[3].x = (float)v1.X; vertices[3].y = (float)v1.Y; @@ -616,7 +632,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) vertices[3].w = 1.0f; vertices[3].varying[0] = (float)texcoords.u1; vertices[3].varying[1] = (float)texcoords.v2; - vertices[3].varying[2] = 1.0f; + vertices[3].varying[2] = GetLightLevel() / 255.0f; TriangleDrawer::draw(worldToClip, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, cliptop, clipbottom, tex); } @@ -630,18 +646,17 @@ FTexture *RenderPolyWall::GetTexture() return tex; } -int RenderPolyWall::GetShade() +int RenderPolyWall::GetLightLevel() { if (fixedlightlev >= 0 || fixedcolormap) { - return 0; + return 255; } else { bool foggy = false; int actualextralight = foggy ? 0 : extralight << 4; - int shade = LIGHT2SHADE(Line->sidedef->GetLightLevel(foggy, Line->frontsector->lightlevel) + actualextralight); - return shade; + return Line->sidedef->GetLightLevel(foggy, Line->frontsector->lightlevel) + actualextralight; } } diff --git a/src/r_poly.h b/src/r_poly.h index 48bd2985a..2ec9a8274 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -60,6 +60,7 @@ private: void RenderNode(void *node); void RenderSubsector(subsector_t *sub); void AddLine(seg_t *line, sector_t *frontsector); + TriVertex PlaneVertex(vertex_t *v1, sector_t *sector, const secplane_t &plane); void RenderPlayerSprites(); void RenderPlayerSprite(DPSprite *sprite, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac); @@ -111,8 +112,7 @@ public: private: FTexture *GetTexture(); - int GetShade(); - //float GetLight(short x); + int GetLightLevel(); }; // Texture coordinates for a wall diff --git a/src/r_triangle.cpp b/src/r_triangle.cpp index 653a46f31..26e393323 100644 --- a/src/r_triangle.cpp +++ b/src/r_triangle.cpp @@ -821,13 +821,20 @@ void ScreenTriangleDrawer::draw32(const ScreenTriangleDrawerArgs *args, DrawerTh { uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); - //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t light = (uint32_t)clamp(varying[2] * 256.0f + 0.5f, 0.0f, 256.0f); uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; uint32_t uvoffset = upos * textureHeight + vpos; - buffer[ix] = texturePixels[uvoffset]; + uint32_t fg = texturePixels[uvoffset]; + uint32_t fg_red = (RPART(fg) * light) >> 8; + uint32_t fg_green = (GPART(fg) * light) >> 8; + uint32_t fg_blue = (BPART(fg) * light) >> 8; + uint32_t fg_alpha = APART(fg); + + if (fg_alpha > 127) + buffer[ix] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; for (int i = 0; i < TriVertex::NumVarying; i++) varying[i] += varyingStep[i]; @@ -866,13 +873,20 @@ void ScreenTriangleDrawer::draw32(const ScreenTriangleDrawerArgs *args, DrawerTh { uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); - //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t light = (uint32_t)clamp(varying[2] * 256.0f + 0.5f, 0.0f, 256.0f); uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; uint32_t uvoffset = upos * textureHeight + vpos; - buffer[ix] = texturePixels[uvoffset]; + uint32_t fg = texturePixels[uvoffset]; + uint32_t fg_red = (RPART(fg) * light) >> 8; + uint32_t fg_green = (GPART(fg) * light) >> 8; + uint32_t fg_blue = (BPART(fg) * light) >> 8; + uint32_t fg_alpha = APART(fg); + + if (fg_alpha > 127) + buffer[ix] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; } for (int i = 0; i < TriVertex::NumVarying; i++) From d0f0500f0ddd196c7ffec2d1ce2024c73faa5de9 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 8 Nov 2016 05:17:29 +0100 Subject: [PATCH 1172/1509] Draw things --- src/r_poly.cpp | 251 ++++++++++++++++++++++++++++++++++++++++++++++++- src/r_poly.h | 6 ++ 2 files changed, 255 insertions(+), 2 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 7bb54712f..e9edacae1 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -149,13 +149,13 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) if (ceiltex->UseType != FTexture::TEX_Null) TriangleDrawer::draw(worldToClip, ceilVertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, cliptop, clipbottom, ceiltex); - /*for (AActor *thing = sub->sector->thinglist; thing != nullptr; thing = thing->snext) + for (AActor *thing = sub->sector->thinglist; thing != nullptr; thing = thing->snext) { if ((thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) AddWallSprite(thing); else AddSprite(thing); - }*/ + } } void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector) @@ -250,6 +250,253 @@ void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector) } } +bool RenderPolyBsp::IsThingCulled(AActor *thing) +{ + FIntCVar *cvar = thing->GetClass()->distancecheck; + if (cvar != nullptr && *cvar >= 0) + { + double dist = (thing->Pos() - ViewPos).LengthSquared(); + double check = (double)**cvar; + if (dist >= check * check) + return true; + } + + // Don't waste time projecting sprites that are definitely not visible. + if (thing == nullptr || + (thing->renderflags & RF_INVISIBLE) || + !thing->RenderStyle.IsVisible(thing->Alpha) || + !thing->IsVisibleToPlayer()) + { + return true; + } + + return false; +} + +void RenderPolyBsp::AddSprite(AActor *thing) +{ + if (IsThingCulled(thing)) + return; + + DVector3 pos = thing->InterpolatedPosition(r_TicFracF); + pos.Z += thing->GetBobOffset(r_TicFracF); + + bool flipTextureX = false; + FTexture *tex = GetSpriteTexture(thing, flipTextureX); + if (tex == nullptr) + return; + DVector2 spriteScale = thing->Scale; + double thingxscalemul = spriteScale.X / tex->Scale.X; + double thingyscalemul = spriteScale.Y / tex->Scale.Y; + + if (flipTextureX) + pos.X -= (tex->GetWidth() - tex->LeftOffset) * thingxscalemul; + else + pos.X -= tex->LeftOffset * thingxscalemul; + + //pos.Z -= tex->TopOffset * thingyscalemul; + pos.Z -= (tex->GetHeight() - tex->TopOffset) * thingyscalemul + thing->Floorclip; + + double spriteHalfWidth = thingxscalemul * tex->GetWidth() * 0.5; + double spriteHeight = thingyscalemul * tex->GetHeight(); + + pos.X += spriteHalfWidth; + + DVector2 points[2] = + { + { pos.X - ViewSin * spriteHalfWidth, pos.Y + ViewCos * spriteHalfWidth }, + { pos.X + ViewSin * spriteHalfWidth, pos.Y - ViewCos * spriteHalfWidth } + }; + + //double depth = 1.0; + //visstyle_t visstyle = GetSpriteVisStyle(thing, depth); + // Rumor has it that AlterWeaponSprite needs to be called with visstyle passed in somewhere around here.. + //R_SetColorMapLight(visstyle.BaseColormap, 0, visstyle.ColormapNum << FRACBITS); + + TriVertex *vertices = PolyVertexBuffer::GetVertices(4); + if (!vertices) + return; + + bool foggy = false; + int actualextralight = foggy ? 0 : extralight << 4; + + std::pair offsets[4] = + { + { 0.0f, 1.0f }, + { 1.0f, 1.0f }, + { 1.0f, 0.0f }, + { 0.0f, 0.0f }, + }; + + for (int i = 0; i < 4; i++) + { + auto &p = (i == 0 || i == 3) ? points[0] : points[1]; + + vertices[i].x = (float)p.X; + vertices[i].y = (float)p.Y; + vertices[i].z = (float)(pos.Z + spriteHeight * offsets[i].second); + vertices[i].w = 1.0f; + vertices[i].varying[0] = (float)(offsets[i].first * tex->Scale.X); + vertices[i].varying[1] = (float)((1.0f - offsets[i].second) * tex->Scale.Y); + if (flipTextureX) + vertices[i].varying[0] = 1.0f - vertices[i].varying[0]; + vertices[i].varying[2] = (thing->Sector->lightlevel + actualextralight) / 255.0f; + } + + TriangleDrawer::draw(worldToClip, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, cliptop, clipbottom, tex); + TriangleDrawer::draw(worldToClip, vertices, 4, TriangleDrawMode::Fan, false, 0, viewwidth, cliptop, clipbottom, tex); +} + +void RenderPolyBsp::AddWallSprite(AActor *thing) +{ + if (IsThingCulled(thing)) + return; +} + +visstyle_t RenderPolyBsp::GetSpriteVisStyle(AActor *thing, double z) +{ + visstyle_t visstyle; + + bool foggy = false; + int actualextralight = foggy ? 0 : extralight << 4; + int spriteshade = LIGHT2SHADE(thing->Sector->lightlevel + actualextralight); + + visstyle.RenderStyle = thing->RenderStyle; + visstyle.Alpha = float(thing->Alpha); + visstyle.ColormapNum = 0; + + // The software renderer cannot invert the source without inverting the overlay + // too. That means if the source is inverted, we need to do the reverse of what + // the invert overlay flag says to do. + bool invertcolormap = (visstyle.RenderStyle.Flags & STYLEF_InvertOverlay) != 0; + + if (visstyle.RenderStyle.Flags & STYLEF_InvertSource) + { + invertcolormap = !invertcolormap; + } + + FDynamicColormap *mybasecolormap = thing->Sector->ColorMap; + + // Sprites that are added to the scene must fade to black. + if (visstyle.RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0) + { + mybasecolormap = GetSpecialLights(mybasecolormap->Color, 0, mybasecolormap->Desaturate); + } + + if (visstyle.RenderStyle.Flags & STYLEF_FadeToBlack) + { + if (invertcolormap) + { // Fade to white + mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(255, 255, 255), mybasecolormap->Desaturate); + invertcolormap = false; + } + else + { // Fade to black + mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(0, 0, 0), mybasecolormap->Desaturate); + } + } + + // get light level + if (fixedcolormap != NULL) + { // fixed map + visstyle.BaseColormap = fixedcolormap; + visstyle.ColormapNum = 0; + } + else + { + if (invertcolormap) + { + mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate); + } + if (fixedlightlev >= 0) + { + visstyle.BaseColormap = mybasecolormap; + visstyle.ColormapNum = fixedlightlev >> COLORMAPSHIFT; + } + else if (!foggy && ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) + { // full bright + visstyle.BaseColormap = mybasecolormap; + visstyle.ColormapNum = 0; + } + else + { // diminished light + double minz = double((2048 * 4) / double(1 << 20)); + visstyle.ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(z, minz), spriteshade); + visstyle.BaseColormap = mybasecolormap; + } + } + + return visstyle; +} + +FTexture *RenderPolyBsp::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX) +{ + flipX = false; + if (thing->picnum.isValid()) + { + FTexture *tex = TexMan(thing->picnum); + if (tex->UseType == FTexture::TEX_Null) + { + return nullptr; + } + + if (tex->Rotations != 0xFFFF) + { + // choose a different rotation based on player view + spriteframe_t *sprframe = &SpriteFrames[tex->Rotations]; + DVector3 pos = thing->InterpolatedPosition(r_TicFracF); + pos.Z += thing->GetBobOffset(r_TicFracF); + DAngle ang = (pos - ViewPos).Angle(); + angle_t rot; + if (sprframe->Texture[0] == sprframe->Texture[1]) + { + rot = (ang - thing->Angles.Yaw + 45.0 / 2 * 9).BAMs() >> 28; + } + else + { + rot = (ang - thing->Angles.Yaw + (45.0 / 2 * 9 - 180.0 / 16)).BAMs() >> 28; + } + flipX = (sprframe->Flip & (1 << rot)) != 0; + tex = TexMan[sprframe->Texture[rot]]; // Do not animate the rotation + } + return tex; + } + else + { + // decide which texture to use for the sprite + int spritenum = thing->sprite; + if (spritenum >= (signed)sprites.Size() || spritenum < 0) + return nullptr; + + spritedef_t *sprdef = &sprites[spritenum]; + if (thing->frame >= sprdef->numframes) + { + // If there are no frames at all for this sprite, don't draw it. + return nullptr; + } + else + { + //picnum = SpriteFrames[sprdef->spriteframes + thing->frame].Texture[0]; + // choose a different rotation based on player view + spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + thing->frame]; + DVector3 pos = thing->InterpolatedPosition(r_TicFracF); + pos.Z += thing->GetBobOffset(r_TicFracF); + DAngle ang = (pos - ViewPos).Angle(); + angle_t rot; + if (sprframe->Texture[0] == sprframe->Texture[1]) + { + rot = (ang - thing->Angles.Yaw + 45.0 / 2 * 9).BAMs() >> 28; + } + else + { + rot = (ang - thing->Angles.Yaw + (45.0 / 2 * 9 - 180.0 / 16)).BAMs() >> 28; + } + flipX = (sprframe->Flip & (1 << rot)) != 0; + return TexMan[sprframe->Texture[rot]]; // Do not animate the rotation + } + } +} + void RenderPolyBsp::RenderNode(void *node) { while (!((size_t)node & 1)) // Keep going until found a subsector diff --git a/src/r_poly.h b/src/r_poly.h index 2ec9a8274..1baaeddfb 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -62,6 +62,12 @@ private: void AddLine(seg_t *line, sector_t *frontsector); TriVertex PlaneVertex(vertex_t *v1, sector_t *sector, const secplane_t &plane); + void AddSprite(AActor *thing); + void AddWallSprite(AActor *thing); + bool IsThingCulled(AActor *thing); + visstyle_t GetSpriteVisStyle(AActor *thing, double z); + FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); + void RenderPlayerSprites(); void RenderPlayerSprite(DPSprite *sprite, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac); From 2e2d6da00fd12f38649d7ea691d44c12777b60bf Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 8 Nov 2016 05:48:45 +0100 Subject: [PATCH 1173/1509] Only draw thing if its in the subsector --- src/r_poly.cpp | 22 ++++++++++++++++++---- src/r_poly.h | 4 ++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index e9edacae1..184498692 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -152,9 +152,9 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) for (AActor *thing = sub->sector->thinglist; thing != nullptr; thing = thing->snext) { if ((thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) - AddWallSprite(thing); + AddWallSprite(thing, sub); else - AddSprite(thing); + AddSprite(thing, sub); } } @@ -273,7 +273,7 @@ bool RenderPolyBsp::IsThingCulled(AActor *thing) return false; } -void RenderPolyBsp::AddSprite(AActor *thing) +void RenderPolyBsp::AddSprite(AActor *thing, subsector_t *sub) { if (IsThingCulled(thing)) return; @@ -308,6 +308,20 @@ void RenderPolyBsp::AddSprite(AActor *thing) { pos.X + ViewSin * spriteHalfWidth, pos.Y - ViewCos * spriteHalfWidth } }; + // Is this sprite inside? (To do: clip the points) + for (int i = 0; i < 2; i++) + { + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + double nx = line->v1->fY() - line->v2->fY(); + double ny = line->v2->fX() - line->v1->fX(); + double d = -(line->v1->fX() * nx + line->v1->fY() * ny); + if (pos.X * nx + pos.Y * ny + d > 0.0) + return; + } + } + //double depth = 1.0; //visstyle_t visstyle = GetSpriteVisStyle(thing, depth); // Rumor has it that AlterWeaponSprite needs to be called with visstyle passed in somewhere around here.. @@ -347,7 +361,7 @@ void RenderPolyBsp::AddSprite(AActor *thing) TriangleDrawer::draw(worldToClip, vertices, 4, TriangleDrawMode::Fan, false, 0, viewwidth, cliptop, clipbottom, tex); } -void RenderPolyBsp::AddWallSprite(AActor *thing) +void RenderPolyBsp::AddWallSprite(AActor *thing, subsector_t *sub) { if (IsThingCulled(thing)) return; diff --git a/src/r_poly.h b/src/r_poly.h index 1baaeddfb..cd1cd1215 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -62,8 +62,8 @@ private: void AddLine(seg_t *line, sector_t *frontsector); TriVertex PlaneVertex(vertex_t *v1, sector_t *sector, const secplane_t &plane); - void AddSprite(AActor *thing); - void AddWallSprite(AActor *thing); + void AddSprite(AActor *thing, subsector_t *sub); + void AddWallSprite(AActor *thing, subsector_t *sub); bool IsThingCulled(AActor *thing); visstyle_t GetSpriteVisStyle(AActor *thing, double z); FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); From dffba5267d8064e6bafab9e754a8e8f8ab709dbe Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 8 Nov 2016 00:44:15 -0500 Subject: [PATCH 1174/1509] - Full freelook is now enabled if r_newrenderer is set to true. --- src/r_swrenderer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 372f23acc..ad9752db9 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -250,9 +250,12 @@ void FSoftwareRenderer::DrawRemainingPlayerSprites() #define MAX_DN_ANGLE 56 // Max looking down angle #define MAX_UP_ANGLE 32 // Max looking up angle +EXTERN_CVAR(Bool, r_newrenderer) // [SP] dpJudas's new renderer +EXTERN_CVAR(Float, maxviewpitch) // [SP] CVAR from GZDoom + int FSoftwareRenderer::GetMaxViewPitch(bool down) { - return down ? MAX_DN_ANGLE : MAX_UP_ANGLE; + return (r_newrenderer) ? int(maxviewpitch) : (down ? MAX_DN_ANGLE : MAX_UP_ANGLE); } //========================================================================== From cb4b74e0c34a8eb2b0eba43a8fec8ec14452f368 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 8 Nov 2016 14:28:58 +0100 Subject: [PATCH 1175/1509] Double render speed of triangle drawer in the poly version by removing sprite clip and assigning whole blocks to threads --- src/CMakeLists.txt | 1 + src/r_poly.cpp | 20 +- src/r_poly.h | 2 +- src/r_poly_triangle.cpp | 1054 +++++++++++++++++++++++++++++++++++++++ src/r_poly_triangle.h | 104 ++++ 5 files changed, 1164 insertions(+), 17 deletions(-) create mode 100644 src/r_poly_triangle.cpp create mode 100644 src/r_poly_triangle.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 91553e275..e6ee761b0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1052,6 +1052,7 @@ set( FASTMATH_PCH_SOURCES r_swrenderer.cpp r_swrenderer2.cpp r_poly.cpp + r_poly_triangle.cpp r_3dfloors.cpp r_bsp.cpp r_draw.cpp diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 184498692..6542afcfb 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -35,23 +35,12 @@ EXTERN_CVAR(Bool, r_drawplayersprites) EXTERN_CVAR(Bool, r_deathcamera) EXTERN_CVAR(Bool, st_scale) -namespace -{ - short cliptop[MAXWIDTH], clipbottom[MAXWIDTH]; -} - ///////////////////////////////////////////////////////////////////////////// void RenderPolyBsp::Render() { PolyVertexBuffer::Clear(); - for (int i = 0; i < viewwidth; i++) - { - cliptop[i] = 0; - clipbottom[i] = viewheight; - } - // Perspective correct: float ratio = WidescreenRatio; float fovratio = (WidescreenRatio >= 1.3f) ? 1.333333f : ratio; @@ -143,11 +132,11 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) FTexture *floortex = TexMan(frontsector->GetTexture(sector_t::floor)); if (floortex->UseType != FTexture::TEX_Null) - TriangleDrawer::draw(worldToClip, floorVertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, cliptop, clipbottom, floortex); + PolyTriangleDrawer::draw(worldToClip, floorVertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, floortex); FTexture *ceiltex = TexMan(frontsector->GetTexture(sector_t::ceiling)); if (ceiltex->UseType != FTexture::TEX_Null) - TriangleDrawer::draw(worldToClip, ceilVertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, cliptop, clipbottom, ceiltex); + PolyTriangleDrawer::draw(worldToClip, ceilVertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, ceiltex); for (AActor *thing = sub->sector->thinglist; thing != nullptr; thing = thing->snext) { @@ -357,8 +346,7 @@ void RenderPolyBsp::AddSprite(AActor *thing, subsector_t *sub) vertices[i].varying[2] = (thing->Sector->lightlevel + actualextralight) / 255.0f; } - TriangleDrawer::draw(worldToClip, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, cliptop, clipbottom, tex); - TriangleDrawer::draw(worldToClip, vertices, 4, TriangleDrawMode::Fan, false, 0, viewwidth, cliptop, clipbottom, tex); + PolyTriangleDrawer::draw(worldToClip, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex); } void RenderPolyBsp::AddWallSprite(AActor *thing, subsector_t *sub) @@ -895,7 +883,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) vertices[3].varying[1] = (float)texcoords.v2; vertices[3].varying[2] = GetLightLevel() / 255.0f; - TriangleDrawer::draw(worldToClip, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, cliptop, clipbottom, tex); + PolyTriangleDrawer::draw(worldToClip, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex); } FTexture *RenderPolyWall::GetTexture() diff --git a/src/r_poly.h b/src/r_poly.h index cd1cd1215..7a143cf67 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -29,7 +29,7 @@ #include "doomdata.h" #include "r_utility.h" #include "r_main.h" -#include "r_triangle.h" +#include "r_poly_triangle.h" // DScreen accelerated sprite to be rendered class PolyScreenSprite diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp new file mode 100644 index 000000000..73c33d024 --- /dev/null +++ b/src/r_poly_triangle.cpp @@ -0,0 +1,1054 @@ +/* +** Triangle drawers +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "i_system.h" +#include "w_wad.h" +#include "r_local.h" +#include "v_video.h" +#include "doomstat.h" +#include "st_stuff.h" +#include "g_game.h" +#include "g_level.h" +#include "r_data/r_translate.h" +#include "v_palette.h" +#include "r_data/colormaps.h" +#include "r_poly_triangle.h" + +void PolyTriangleDrawer::draw(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, FTexture *texture) +{ + if (r_swtruecolor) + queue_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, (const uint8_t*)texture->GetPixelsBgra(), texture->GetWidth(), texture->GetHeight(), 0); + else + draw_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texture->GetPixels(), texture->GetWidth(), texture->GetHeight(), 0, nullptr, &ScreenPolyTriangleDrawer::draw); +} + +void PolyTriangleDrawer::fill(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int solidcolor) +{ + if (r_swtruecolor) + queue_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor); + else + draw_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor, nullptr, &ScreenPolyTriangleDrawer::fill); +} + +void PolyTriangleDrawer::queue_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) +{ + if (clipright < clipleft || clipleft < 0 || clipright > MAXWIDTH || clipbottom < cliptop || cliptop < 0 || clipbottom > MAXHEIGHT) + return; + + DrawerCommandQueue::QueueCommand(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texturePixels, textureWidth, textureHeight, solidcolor); +} + +void PolyTriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)) +{ + if (vcount < 3) + return; + + ScreenPolyTriangleDrawerArgs args; + args.dest = dc_destorg; + args.pitch = dc_pitch; + args.clipleft = clipleft; + args.clipright = clipright; + args.cliptop = cliptop; + args.clipbottom = clipbottom; + args.texturePixels = texturePixels; + args.textureWidth = textureWidth; + args.textureHeight = textureHeight; + args.solidcolor = solidcolor; + + TriVertex vert[3]; + if (mode == TriangleDrawMode::Normal) + { + for (int i = 0; i < vcount / 3; i++) + { + for (int j = 0; j < 3; j++) + vert[j] = shade_vertex(objectToClip, *(vinput++)); + draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); + } + } + else if (mode == TriangleDrawMode::Fan) + { + vert[0] = shade_vertex(objectToClip, *(vinput++)); + vert[1] = shade_vertex(objectToClip, *(vinput++)); + for (int i = 2; i < vcount; i++) + { + vert[2] = shade_vertex(objectToClip, *(vinput++)); + draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); + vert[1] = vert[2]; + } + } + else // TriangleDrawMode::Strip + { + vert[0] = shade_vertex(objectToClip, *(vinput++)); + vert[1] = shade_vertex(objectToClip, *(vinput++)); + for (int i = 2; i < vcount; i++) + { + vert[2] = shade_vertex(objectToClip, *(vinput++)); + draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); + vert[0] = vert[1]; + vert[1] = vert[2]; + ccw = !ccw; + } + } +} + +TriVertex PolyTriangleDrawer::shade_vertex(const TriMatrix &objectToClip, TriVertex v) +{ + // Apply transform to get clip coordinates: + return objectToClip * v; +} + +void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)) +{ + // Cull, clip and generate additional vertices as needed + TriVertex clippedvert[6]; + int numclipvert = 0; + clipedge(vert[0], vert[1], clippedvert, numclipvert); + clipedge(vert[1], vert[2], clippedvert, numclipvert); + clipedge(vert[2], vert[0], clippedvert, numclipvert); + + // Map to 2D viewport: + for (int j = 0; j < numclipvert; j++) + { + auto &v = clippedvert[j]; + + // Calculate normalized device coordinates: + v.w = 1.0f / v.w; + v.x *= v.w; + v.y *= v.w; + v.z *= v.w; + + // Apply viewport scale to get screen coordinates: + v.x = viewwidth * (1.0f + v.x) * 0.5f; + v.y = viewheight * (1.0f - v.y) * 0.5f; + } + + // Draw screen triangles + if (ccw) + { + for (int i = numclipvert; i > 1; i--) + { + args->v1 = &clippedvert[numclipvert - 1]; + args->v2 = &clippedvert[i - 1]; + args->v3 = &clippedvert[i - 2]; + drawfunc(args, thread); + } + } + else + { + for (int i = 2; i < numclipvert; i++) + { + args->v1 = &clippedvert[0]; + args->v2 = &clippedvert[i - 1]; + args->v3 = &clippedvert[i]; + drawfunc(args, thread); + } + } +} + +bool PolyTriangleDrawer::cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2) +{ + float d1 = clipdistance1 * (1.0f - t1) + clipdistance2 * t1; + float d2 = clipdistance1 * (1.0f - t2) + clipdistance2 * t2; + if (d1 < 0.0f && d2 < 0.0f) + return true; + + if (d1 < 0.0f) + t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), t1); + + if (d2 < 0.0f) + t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2); + + return false; +} + +void PolyTriangleDrawer::clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert) +{ + // Clip and cull so that the following is true for all vertices: + // -v.w <= v.x <= v.w + // -v.w <= v.y <= v.w + // -v.w <= v.z <= v.w + + float t1 = 0.0f, t2 = 1.0f; + bool culled = + cullhalfspace(v1.x + v1.w, v2.x + v2.w, t1, t2) || + cullhalfspace(v1.w - v1.x, v2.w - v2.x, t1, t2) || + cullhalfspace(v1.y + v1.w, v2.y + v2.w, t1, t2) || + cullhalfspace(v1.w - v1.y, v2.w - v2.y, t1, t2) || + cullhalfspace(v1.z + v1.w, v2.z + v2.w, t1, t2) || + cullhalfspace(v1.w - v1.z, v2.w - v2.z, t1, t2); + if (culled) + return; + + if (t1 == 0.0f) + { + clippedvert[numclipvert++] = v1; + } + else + { + auto &v = clippedvert[numclipvert++]; + v.x = v1.x * (1.0f - t1) + v2.x * t1; + v.y = v1.y * (1.0f - t1) + v2.y * t1; + v.z = v1.z * (1.0f - t1) + v2.z * t1; + v.w = v1.w * (1.0f - t1) + v2.w * t1; + for (int i = 0; i < TriVertex::NumVarying; i++) + v.varying[i] = v1.varying[i] * (1.0f - t1) + v2.varying[i] * t1; + } + + if (t2 != 1.0f) + { + auto &v = clippedvert[numclipvert++]; + v.x = v1.x * (1.0f - t2) + v2.x * t2; + v.y = v1.y * (1.0f - t2) + v2.y * t2; + v.z = v1.z * (1.0f - t2) + v2.z * t2; + v.w = v1.w * (1.0f - t2) + v2.w * t2; + for (int i = 0; i < TriVertex::NumVarying; i++) + v.varying[i] = v1.varying[i] * (1.0f - t2) + v2.varying[i] * t2; + } +} + +///////////////////////////////////////////////////////////////////////////// + +void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread) +{ + uint8_t *dest = args->dest; + int pitch = args->pitch; + const TriVertex &v1 = *args->v1; + const TriVertex &v2 = *args->v2; + const TriVertex &v3 = *args->v3; + int clipleft = args->clipleft; + int clipright = args->clipright; + int cliptop = args->cliptop; + int clipbottom = args->clipbottom; + const uint8_t *texturePixels = args->texturePixels; + int textureWidth = args->textureWidth; + int textureHeight = args->textureHeight; + + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, cliptop); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); + if (minx >= maxx || miny >= maxy) + return; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + dest += miny * pitch; + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // Gradients + float gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + float gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + float startW = v1.w + gradWX * (minx - v1.x) + gradWY * (miny - v1.y); + float gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (minx - v1.x) + gradVaryingY[i] * (miny - v1.y); + } + + // Loop through blocks + for (int y = miny; y < maxy; y += q, dest += q * pitch) + { + // Is this row of blocks done by this thread? + if (thread->skipped_by_thread(y / q)) continue; + + for (int x = minx; x < maxx; x += q) + { + // Corners of block + int x0 = x << 4; + int x1 = (x + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; + bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; + bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; + bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; + int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); + + bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; + bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; + bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; + bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; + int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); + + bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; + bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; + bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; + bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; + int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + + // Skip block when outside an edge + if (a == 0x0 || b == 0x0 || c == 0x0) continue; + + // Check if block needs clipping + bool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); + + // Calculate varying variables for affine block + float offx0 = (x - minx) + 0.5f; + float offy0 = (y - miny) + 0.5f; + float offx1 = offx0 + q; + float offy1 = offy0 + q; + float rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); + float rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); + float rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); + float rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); + float varyingTL[TriVertex::NumVarying]; + float varyingTR[TriVertex::NumVarying]; + float varyingBL[TriVertex::NumVarying]; + float varyingBR[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; + varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; + varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); + varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); + } + + uint8_t *buffer = dest; + + // Accept whole block when totally covered + if (a == 0xF && b == 0xF && c == 0xF && !clipneeded) + { + for (int iy = 0; iy < q; iy++) + { + float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varying[i] = varyingTL[i] + varyingBL[i] * iy; + varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + } + + for (int ix = x; ix < x + q; ix++) + { + uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); + uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); + + uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; + uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; + uint32_t uvoffset = upos * textureHeight + vpos; + + buffer[ix] = texturePixels[uvoffset]; + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + } + + buffer += pitch; + } + } + else // Partially covered block + { + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; + + for (int iy = 0; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varying[i] = varyingTL[i] + varyingBL[i] * iy; + varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + } + + for (int ix = x; ix < x + q; ix++) + { + bool visible = ix >= clipleft && ix <= clipright && (cliptop <= y + iy) && (clipbottom > y + iy); + + if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) + { + uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); + uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); + + uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; + uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; + uint32_t uvoffset = upos * textureHeight + vpos; + + buffer[ix] = texturePixels[uvoffset]; + } + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + + buffer += pitch; + } + } + } + } +} + +void ScreenPolyTriangleDrawer::fill(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread) +{ + uint8_t *dest = args->dest; + int pitch = args->pitch; + const TriVertex &v1 = *args->v1; + const TriVertex &v2 = *args->v2; + const TriVertex &v3 = *args->v3; + int clipleft = args->clipleft; + int clipright = args->clipright; + int cliptop = args->cliptop; + int clipbottom = args->clipbottom; + int solidcolor = args->solidcolor; + + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, cliptop); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); + if (minx >= maxx || miny >= maxy) + return; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + dest += miny * pitch; + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // Loop through blocks + for (int y = miny; y < maxy; y += q, dest += q * pitch) + { + // Is this row of blocks done by this thread? + if (thread->skipped_by_thread(y / q)) continue; + + for (int x = minx; x < maxx; x += q) + { + // Corners of block + int x0 = x << 4; + int x1 = (x + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; + bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; + bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; + bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; + int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); + + bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; + bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; + bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; + bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; + int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); + + bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; + bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; + bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; + bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; + int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + + // Skip block when outside an edge + if (a == 0x0 || b == 0x0 || c == 0x0) continue; + + // Check if block needs clipping + bool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); + + uint8_t *buffer = dest; + + // Accept whole block when totally covered + if (a == 0xF && b == 0xF && c == 0xF && !clipneeded) + { + for (int iy = 0; iy < q; iy++) + { + for (int ix = x; ix < x + q; ix++) + { + buffer[ix] = solidcolor; + } + + buffer += pitch; + } + } + else // Partially covered block + { + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; + + for (int iy = 0; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + for (int ix = x; ix < x + q; ix++) + { + bool visible = ix >= clipleft && ix <= clipright && (cliptop <= y + iy) && (clipbottom > y + iy); + + if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) + { + buffer[ix] = solidcolor; + } + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + + buffer += pitch; + } + } + } + } +} + +void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread) +{ + uint32_t *dest = (uint32_t *)args->dest; + int pitch = args->pitch; + const TriVertex &v1 = *args->v1; + const TriVertex &v2 = *args->v2; + const TriVertex &v3 = *args->v3; + int clipleft = args->clipleft; + int clipright = args->clipright; + int cliptop = args->cliptop; + int clipbottom = args->clipbottom; + const uint32_t *texturePixels = (const uint32_t *)args->texturePixels; + int textureWidth = args->textureWidth; + int textureHeight = args->textureHeight; + + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, cliptop); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); + if (minx >= maxx || miny >= maxy) + return; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + dest += miny * pitch; + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // Gradients + float gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + float gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + float startW = v1.w + gradWX * (minx - v1.x) + gradWY * (miny - v1.y); + float gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (minx - v1.x) + gradVaryingY[i] * (miny - v1.y); + } + + // Loop through blocks + for (int y = miny; y < maxy; y += q, dest += q * pitch) + { + // Is this row of blocks done by this thread? + if (thread->skipped_by_thread(y / q)) continue; + + for (int x = minx; x < maxx; x += q) + { + // Corners of block + int x0 = x << 4; + int x1 = (x + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; + bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; + bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; + bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; + int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); + + bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; + bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; + bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; + bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; + int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); + + bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; + bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; + bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; + bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; + int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + + // Skip block when outside an edge + if (a == 0x0 || b == 0x0 || c == 0x0) continue; + + // Check if block needs clipping + bool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); + + // Calculate varying variables for affine block + float offx0 = (x - minx) + 0.5f; + float offy0 = (y - miny) + 0.5f; + float offx1 = offx0 + q; + float offy1 = offy0 + q; + float rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); + float rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); + float rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); + float rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); + float varyingTL[TriVertex::NumVarying]; + float varyingTR[TriVertex::NumVarying]; + float varyingBL[TriVertex::NumVarying]; + float varyingBR[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; + varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; + varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); + varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); + } + + uint32_t *buffer = dest; + + // Accept whole block when totally covered + if (a == 0xF && b == 0xF && c == 0xF && !clipneeded) + { + for (int iy = 0; iy < q; iy++) + { + float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varying[i] = varyingTL[i] + varyingBL[i] * iy; + varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + } + + for (int ix = x; ix < x + q; ix++) + { + uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); + uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + uint32_t light = (uint32_t)clamp(varying[2] * 256.0f + 0.5f, 0.0f, 256.0f); + + uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; + uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; + uint32_t uvoffset = upos * textureHeight + vpos; + + uint32_t fg = texturePixels[uvoffset]; + uint32_t fg_red = (RPART(fg) * light) >> 8; + uint32_t fg_green = (GPART(fg) * light) >> 8; + uint32_t fg_blue = (BPART(fg) * light) >> 8; + uint32_t fg_alpha = APART(fg); + + if (fg_alpha > 127) + buffer[ix] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + } + + buffer += pitch; + } + } + else // Partially covered block + { + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; + + for (int iy = 0; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varying[i] = varyingTL[i] + varyingBL[i] * iy; + varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + } + + for (int ix = x; ix < x + q; ix++) + { + bool visible = ix >= clipleft && ix <= clipright && (cliptop <= y + iy) && (clipbottom > y + iy); + + if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) + { + uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); + uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + uint32_t light = (uint32_t)clamp(varying[2] * 256.0f + 0.5f, 0.0f, 256.0f); + + uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; + uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; + uint32_t uvoffset = upos * textureHeight + vpos; + + uint32_t fg = texturePixels[uvoffset]; + uint32_t fg_red = (RPART(fg) * light) >> 8; + uint32_t fg_green = (GPART(fg) * light) >> 8; + uint32_t fg_blue = (BPART(fg) * light) >> 8; + uint32_t fg_alpha = APART(fg); + + if (fg_alpha > 127) + buffer[ix] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; + } + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + + buffer += pitch; + } + } + } + } +} + +void ScreenPolyTriangleDrawer::fill32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread) +{ + uint32_t *dest = (uint32_t *)args->dest; + int pitch = args->pitch; + const TriVertex &v1 = *args->v1; + const TriVertex &v2 = *args->v2; + const TriVertex &v3 = *args->v3; + int clipleft = args->clipleft; + int clipright = args->clipright; + int cliptop = args->cliptop; + int clipbottom = args->clipbottom; + int solidcolor = args->solidcolor; + + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, cliptop); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); + if (minx >= maxx || miny >= maxy) + return; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + dest += miny * pitch; + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // Loop through blocks + for (int y = miny; y < maxy; y += q, dest += q * pitch) + { + // Is this row of blocks done by this thread? + if (thread->skipped_by_thread(y / q)) continue; + + for (int x = minx; x < maxx; x += q) + { + // Corners of block + int x0 = x << 4; + int x1 = (x + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; + bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; + bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; + bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; + int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); + + bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; + bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; + bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; + bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; + int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); + + bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; + bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; + bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; + bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; + int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + + // Skip block when outside an edge + if (a == 0x0 || b == 0x0 || c == 0x0) continue; + + // Check if block needs clipping + bool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); + + uint32_t *buffer = dest; + + // Accept whole block when totally covered + if (a == 0xF && b == 0xF && c == 0xF && !clipneeded) + { + for (int iy = 0; iy < q; iy++) + { + for (int ix = x; ix < x + q; ix++) + { + buffer[ix] = solidcolor; + } + + buffer += pitch; + } + } + else // Partially covered block + { + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; + + for (int iy = 0; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + for (int ix = x; ix < x + q; ix++) + { + bool visible = ix >= clipleft && ix <= clipright && (cliptop <= y + iy) && (clipbottom > y + iy); + + if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) + { + buffer[ix] = solidcolor; + } + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + + buffer += pitch; + } + } + } + } +} + +float ScreenPolyTriangleDrawer::gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) +{ + float top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); + float bottom = (x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2); + return top / bottom; +} + +float ScreenPolyTriangleDrawer::grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) +{ + float top = (c1 - c2) * (x0 - x2) - (c0 - c2) * (x1 - x2); + float bottom = -((x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2)); + return top / bottom; +} + +///////////////////////////////////////////////////////////////////////////// + +DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) + : objectToClip(objectToClip), vinput(vinput), vcount(vcount), mode(mode), ccw(ccw), clipleft(clipleft), clipright(clipright), cliptop(cliptop), clipbottom(clipbottom), texturePixels(texturePixels), textureWidth(textureWidth), textureHeight(textureHeight), solidcolor(solidcolor) +{ +} + +void DrawPolyTrianglesCommand::Execute(DrawerThread *thread) +{ + PolyTriangleDrawer::draw_arrays( + objectToClip, vinput, vcount, mode, ccw, + clipleft, clipright, cliptop, clipbottom, + texturePixels, textureWidth, textureHeight, solidcolor, + thread, texturePixels ? ScreenPolyTriangleDrawer::draw32 : ScreenPolyTriangleDrawer::fill32); +} + +FString DrawPolyTrianglesCommand::DebugInfo() +{ + return "DrawPolyTriangles"; +} diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h new file mode 100644 index 000000000..de9cd543c --- /dev/null +++ b/src/r_poly_triangle.h @@ -0,0 +1,104 @@ +/* +** Triangle drawers +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + + +#ifndef __R_POLY_TRIANGLE__ +#define __R_POLY_TRIANGLE__ + +#include "r_triangle.h" + +struct ScreenPolyTriangleDrawerArgs; + +class PolyTriangleDrawer +{ +public: + static void draw(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, FTexture *texture); + static void fill(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int solidcolor); + +private: + static TriVertex shade_vertex(const TriMatrix &objectToClip, TriVertex v); + static void draw_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)); + static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)); + static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); + static void clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert); + + static void queue_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); + + friend class DrawPolyTrianglesCommand; +}; + +struct ScreenPolyTriangleDrawerArgs +{ + uint8_t *dest; + int pitch; + TriVertex *v1; + TriVertex *v2; + TriVertex *v3; + int clipleft; + int clipright; + int cliptop; + int clipbottom; + const uint8_t *texturePixels; + int textureWidth; + int textureHeight; + int solidcolor; +}; + +class ScreenPolyTriangleDrawer +{ +public: + static void draw(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); + static void fill(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); + + static void draw32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); + static void fill32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); + +private: + static float gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); + static float grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); +}; + +class DrawPolyTrianglesCommand : public DrawerCommand +{ +public: + DrawPolyTrianglesCommand(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); + + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + +private: + TriMatrix objectToClip; + const TriVertex *vinput; + int vcount; + TriangleDrawMode mode; + bool ccw; + int clipleft; + int clipright; + int cliptop; + int clipbottom; + const uint8_t *texturePixels; + int textureWidth; + int textureHeight; + int solidcolor; +}; + +#endif From 6620d99fbb62fb741980323ba0a451f95b2a467f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 8 Nov 2016 15:27:45 +0100 Subject: [PATCH 1176/1509] Fix frame buffer bounds and access errors --- src/r_poly.cpp | 1 + src/r_poly_triangle.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 6542afcfb..bd9003fab 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -67,6 +67,7 @@ void RenderPolyBsp::Render() RenderSubsector(*it); RenderPlayerSprites(); + DrawerCommandQueue::WaitForWorkers(); RenderScreenSprites(); // To do: should be called by FSoftwareRenderer::DrawRemainingPlayerSprites instead of here } diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 73c33d024..d44648551 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -425,7 +425,7 @@ void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, Dr for (int ix = x; ix < x + q; ix++) { - bool visible = ix >= clipleft && ix <= clipright && (cliptop <= y + iy) && (clipbottom > y + iy); + bool visible = ix >= clipleft && ix < clipright && (cliptop <= y + iy) && (clipbottom > y + iy); if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) { @@ -594,7 +594,7 @@ void ScreenPolyTriangleDrawer::fill(const ScreenPolyTriangleDrawerArgs *args, Dr for (int ix = x; ix < x + q; ix++) { - bool visible = ix >= clipleft && ix <= clipright && (cliptop <= y + iy) && (clipbottom > y + iy); + bool visible = ix >= clipleft && ix < clipright && (cliptop <= y + iy) && (clipbottom > y + iy); if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) { @@ -819,7 +819,7 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, for (int ix = x; ix < x + q; ix++) { - bool visible = ix >= clipleft && ix <= clipright && (cliptop <= y + iy) && (clipbottom > y + iy); + bool visible = ix >= clipleft && ix < clipright && (cliptop <= y + iy) && (clipbottom > y + iy); if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) { @@ -995,7 +995,7 @@ void ScreenPolyTriangleDrawer::fill32(const ScreenPolyTriangleDrawerArgs *args, for (int ix = x; ix < x + q; ix++) { - bool visible = ix >= clipleft && ix <= clipright && (cliptop <= y + iy) && (clipbottom > y + iy); + bool visible = ix >= clipleft && ix < clipright && (cliptop <= y + iy) && (clipbottom > y + iy); if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) { From 28d1cdc1ccfe9bd64816ecab0def9db07774abf7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 8 Nov 2016 16:16:24 +0100 Subject: [PATCH 1177/1509] Add TriUniforms and move light to it --- src/r_plane.cpp | 97 +++++++++++++++++++++++------------------ src/r_poly.cpp | 80 +++++++++++++++++++++------------ src/r_poly_triangle.cpp | 48 ++++++++++---------- src/r_poly_triangle.h | 15 ++++--- src/r_triangle.cpp | 48 ++++++++++---------- src/r_triangle.h | 43 ++++++++++++++---- 6 files changed, 194 insertions(+), 137 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 66738346f..17728e80c 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1025,58 +1025,58 @@ static void R_DrawCubeSky(visplane_t *pl) static TriVertex cube[6 * 6] = { // Top - { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, - { 1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, - { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.1f, 1.0f }, + { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, + { 1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.1f }, - { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.1f, 1.0f }, - { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.1f, 1.0f }, - { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.1f }, + { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.1f }, + { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, // Bottom - { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.9f, 1.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.9f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f }, - { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.9f, 1.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.9f, 1.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f }, + { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.9f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.9f }, // Front - { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, - { 1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, - { -1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f }, + { 1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, + { -1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f }, - { -1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, + { -1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f }, // Back - { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, - { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, + { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, + { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, - { -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, - { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f }, + { -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 2.0f }, + { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, // Right - { 1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, - { 1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, + { 1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, + { 1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, - { 1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, + { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f }, + { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 2.0f }, + { 1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, // Left - { -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f }, - { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f, 1.0f }, - { -1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f }, + { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, + { -1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f }, - { -1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f, 1.0f }, - { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f, 1.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f, 1.0f } + { -1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f }, + { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f }, + { -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f } }; TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z) * TriMatrix::scale(1000.0f, 1000.0f, 1000.0f); @@ -1090,9 +1090,14 @@ static void R_DrawCubeSky(visplane_t *pl) solid_top = RGB32k.RGB[(RPART(solid_top) >> 3)][(GPART(solid_top) >> 3)][(BPART(solid_top) >> 3)]; solid_bottom = RGB32k.RGB[(RPART(solid_bottom) >> 3)][(GPART(solid_bottom) >> 3)][(BPART(solid_bottom) >> 3)]; - TriangleDrawer::fill(objectToClip, cube, 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, solid_top); - TriangleDrawer::fill(objectToClip, cube + 6, 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, solid_bottom); - TriangleDrawer::draw(objectToClip, cube + 2 * 6, 4 * 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, frontskytex); + TriUniforms uniforms; + uniforms.objectToClip = objectToClip; + uniforms.light = 256; + uniforms.flags = 0; + + TriangleDrawer::fill(uniforms, cube, 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, solid_top); + TriangleDrawer::fill(uniforms, cube + 6, 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, solid_bottom); + TriangleDrawer::draw(uniforms, cube + 2 * 6, 4 * 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, frontskytex); } namespace @@ -1127,7 +1132,6 @@ namespace v.w = 1.0f; v.varying[0] = uu; v.varying[1] = vv; - v.varying[2] = 1.0f; return v; } @@ -1140,7 +1144,6 @@ namespace v.w = 1.0f; v.varying[0] = uu; v.varying[1] = vv; - v.varying[2] = 1.0f; return v; } @@ -1220,7 +1223,11 @@ namespace short *dwal = (short *)pl->bottom; TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); TriMatrix objectToClip = TriMatrix::viewToClip() * TriMatrix::worldToView() * objectToWorld; - TriangleDrawer::draw(objectToClip, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Strip, false, x1, x2 - 1, uwal, dwal, frontskytex); + TriUniforms uniforms; + uniforms.objectToClip = objectToClip; + uniforms.light = 256; + uniforms.flags = 0; + TriangleDrawer::draw(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Strip, false, x1, x2 - 1, uwal, dwal, frontskytex); } void SkyDome::RenderCapColorRow(int row, bool bottomCap, visplane_t *pl) @@ -1234,7 +1241,11 @@ namespace short *dwal = (short *)pl->bottom; TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); TriMatrix objectToClip = TriMatrix::viewToClip() * TriMatrix::worldToView() * objectToWorld; - TriangleDrawer::fill(objectToClip, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Fan, bottomCap, x1, x2 - 1, uwal, dwal, solid); + TriUniforms uniforms; + uniforms.objectToClip = objectToClip; + uniforms.light = 256; + uniforms.flags = 0; + TriangleDrawer::fill(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Fan, bottomCap, x1, x2 - 1, uwal, dwal, solid); } void SkyDome::Render(visplane_t *pl) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index bd9003fab..03052ab60 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -87,13 +87,6 @@ TriVertex RenderPolyBsp::PlaneVertex(vertex_t *v1, sector_t *sector, const secpl v.varying[0] = v.x / 64.0f; v.varying[1] = v.y / 64.0f; - if (fixedlightlev >= 0) - v.varying[2] = fixedlightlev / 255.0f; - else if (fixedcolormap) - v.varying[2] = 1.0f; - else - v.varying[2] = sector->lightlevel / 255.0f; - /* double vis = r_FloorVisibility / (plane.Zat0() - ViewPos.Z); if (fixedlightlev >= 0) @@ -119,25 +112,53 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) AddLine(line, frontsector); } - TriVertex *floorVertices = PolyVertexBuffer::GetVertices(sub->numlines); - TriVertex *ceilVertices = PolyVertexBuffer::GetVertices(sub->numlines); - if (floorVertices == nullptr || ceilVertices == nullptr) - return; - - for (uint32_t i = 0; i < sub->numlines; i++) - { - seg_t *line = &sub->firstline[i]; - ceilVertices[sub->numlines - 1 - i] = PlaneVertex(line->v1, frontsector, frontsector->ceilingplane); - floorVertices[i] = PlaneVertex(line->v1, frontsector, frontsector->floorplane); - } - FTexture *floortex = TexMan(frontsector->GetTexture(sector_t::floor)); if (floortex->UseType != FTexture::TEX_Null) - PolyTriangleDrawer::draw(worldToClip, floorVertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, floortex); + { + TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); + if (!vertices) + return; + + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + vertices[i] = PlaneVertex(line->v1, frontsector, frontsector->floorplane); + } + + TriUniforms uniforms; + uniforms.objectToClip = worldToClip; + uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f); + if (fixedlightlev >= 0) + uniforms.light = (uint32_t)(fixedlightlev / 255.0f * 256.0f); + else if (fixedcolormap) + uniforms.light = 256; + uniforms.flags = 0; + PolyTriangleDrawer::draw(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, floortex); + } FTexture *ceiltex = TexMan(frontsector->GetTexture(sector_t::ceiling)); if (ceiltex->UseType != FTexture::TEX_Null) - PolyTriangleDrawer::draw(worldToClip, ceilVertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, ceiltex); + { + TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); + if (!vertices) + return; + + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + vertices[sub->numlines - 1 - i] = PlaneVertex(line->v1, frontsector, frontsector->ceilingplane); + } + + TriUniforms uniforms; + uniforms.objectToClip = worldToClip; + uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f); + if (fixedlightlev >= 0) + uniforms.light = (uint32_t)(fixedlightlev / 255.0f * 256.0f); + else if (fixedcolormap) + uniforms.light = 256; + uniforms.flags = 0; + PolyTriangleDrawer::draw(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, ceiltex); + } for (AActor *thing = sub->sector->thinglist; thing != nullptr; thing = thing->snext) { @@ -344,10 +365,13 @@ void RenderPolyBsp::AddSprite(AActor *thing, subsector_t *sub) vertices[i].varying[1] = (float)((1.0f - offsets[i].second) * tex->Scale.Y); if (flipTextureX) vertices[i].varying[0] = 1.0f - vertices[i].varying[0]; - vertices[i].varying[2] = (thing->Sector->lightlevel + actualextralight) / 255.0f; } - PolyTriangleDrawer::draw(worldToClip, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex); + TriUniforms uniforms; + uniforms.objectToClip = worldToClip; + uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f); + uniforms.flags = 0; + PolyTriangleDrawer::draw(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex); } void RenderPolyBsp::AddWallSprite(AActor *thing, subsector_t *sub) @@ -858,7 +882,6 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) vertices[0].w = 1.0f; vertices[0].varying[0] = (float)texcoords.u1; vertices[0].varying[1] = (float)texcoords.v1; - vertices[0].varying[2] = GetLightLevel() / 255.0f; vertices[1].x = (float)v2.X; vertices[1].y = (float)v2.Y; @@ -866,7 +889,6 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) vertices[1].w = 1.0f; vertices[1].varying[0] = (float)texcoords.u2; vertices[1].varying[1] = (float)texcoords.v1; - vertices[1].varying[2] = GetLightLevel() / 255.0f; vertices[2].x = (float)v2.X; vertices[2].y = (float)v2.Y; @@ -874,7 +896,6 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) vertices[2].w = 1.0f; vertices[2].varying[0] = (float)texcoords.u2; vertices[2].varying[1] = (float)texcoords.v2; - vertices[2].varying[2] = GetLightLevel() / 255.0f; vertices[3].x = (float)v1.X; vertices[3].y = (float)v1.Y; @@ -882,9 +903,12 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) vertices[3].w = 1.0f; vertices[3].varying[0] = (float)texcoords.u1; vertices[3].varying[1] = (float)texcoords.v2; - vertices[3].varying[2] = GetLightLevel() / 255.0f; - PolyTriangleDrawer::draw(worldToClip, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex); + TriUniforms uniforms; + uniforms.objectToClip = worldToClip; + uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f); + uniforms.flags = 0; + PolyTriangleDrawer::draw(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex); } FTexture *RenderPolyWall::GetTexture() diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index d44648551..d77919677 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -36,31 +36,31 @@ #include "r_data/colormaps.h" #include "r_poly_triangle.h" -void PolyTriangleDrawer::draw(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, FTexture *texture) +void PolyTriangleDrawer::draw(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, FTexture *texture) { if (r_swtruecolor) - queue_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, (const uint8_t*)texture->GetPixelsBgra(), texture->GetWidth(), texture->GetHeight(), 0); + queue_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, (const uint8_t*)texture->GetPixelsBgra(), texture->GetWidth(), texture->GetHeight(), 0); else - draw_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texture->GetPixels(), texture->GetWidth(), texture->GetHeight(), 0, nullptr, &ScreenPolyTriangleDrawer::draw); + draw_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texture->GetPixels(), texture->GetWidth(), texture->GetHeight(), 0, nullptr, &ScreenPolyTriangleDrawer::draw); } -void PolyTriangleDrawer::fill(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int solidcolor) +void PolyTriangleDrawer::fill(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int solidcolor) { if (r_swtruecolor) - queue_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor); + queue_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor); else - draw_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor, nullptr, &ScreenPolyTriangleDrawer::fill); + draw_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor, nullptr, &ScreenPolyTriangleDrawer::fill); } -void PolyTriangleDrawer::queue_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) +void PolyTriangleDrawer::queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) { if (clipright < clipleft || clipleft < 0 || clipright > MAXWIDTH || clipbottom < cliptop || cliptop < 0 || clipbottom > MAXHEIGHT) return; - DrawerCommandQueue::QueueCommand(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texturePixels, textureWidth, textureHeight, solidcolor); + DrawerCommandQueue::QueueCommand(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texturePixels, textureWidth, textureHeight, solidcolor); } -void PolyTriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)) +void PolyTriangleDrawer::draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)) { if (vcount < 3) return; @@ -76,6 +76,7 @@ void PolyTriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVer args.textureWidth = textureWidth; args.textureHeight = textureHeight; args.solidcolor = solidcolor; + args.uniforms = &uniforms; TriVertex vert[3]; if (mode == TriangleDrawMode::Normal) @@ -83,28 +84,28 @@ void PolyTriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVer for (int i = 0; i < vcount / 3; i++) { for (int j = 0; j < 3; j++) - vert[j] = shade_vertex(objectToClip, *(vinput++)); + vert[j] = shade_vertex(uniforms, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); } } else if (mode == TriangleDrawMode::Fan) { - vert[0] = shade_vertex(objectToClip, *(vinput++)); - vert[1] = shade_vertex(objectToClip, *(vinput++)); + vert[0] = shade_vertex(uniforms, *(vinput++)); + vert[1] = shade_vertex(uniforms, *(vinput++)); for (int i = 2; i < vcount; i++) { - vert[2] = shade_vertex(objectToClip, *(vinput++)); + vert[2] = shade_vertex(uniforms, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); vert[1] = vert[2]; } } else // TriangleDrawMode::Strip { - vert[0] = shade_vertex(objectToClip, *(vinput++)); - vert[1] = shade_vertex(objectToClip, *(vinput++)); + vert[0] = shade_vertex(uniforms, *(vinput++)); + vert[1] = shade_vertex(uniforms, *(vinput++)); for (int i = 2; i < vcount; i++) { - vert[2] = shade_vertex(objectToClip, *(vinput++)); + vert[2] = shade_vertex(uniforms, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); vert[0] = vert[1]; vert[1] = vert[2]; @@ -113,10 +114,10 @@ void PolyTriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVer } } -TriVertex PolyTriangleDrawer::shade_vertex(const TriMatrix &objectToClip, TriVertex v) +TriVertex PolyTriangleDrawer::shade_vertex(const TriUniforms &uniforms, TriVertex v) { // Apply transform to get clip coordinates: - return objectToClip * v; + return uniforms.objectToClip * v; } void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)) @@ -389,7 +390,6 @@ void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, Dr { uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); - //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -431,7 +431,6 @@ void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, Dr { uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); - //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -631,6 +630,7 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, const uint32_t *texturePixels = (const uint32_t *)args->texturePixels; int textureWidth = args->textureWidth; int textureHeight = args->textureHeight; + uint32_t light = args->uniforms->light; // 28.4 fixed-point coordinates const int Y1 = (int)round(16.0f * v1.y); @@ -776,7 +776,6 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, { uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); - uint32_t light = (uint32_t)clamp(varying[2] * 256.0f + 0.5f, 0.0f, 256.0f); uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -825,7 +824,6 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, { uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); - uint32_t light = (uint32_t)clamp(varying[2] * 256.0f + 0.5f, 0.0f, 256.0f); uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -1034,15 +1032,15 @@ float ScreenPolyTriangleDrawer::grady(float x0, float y0, float x1, float y1, fl ///////////////////////////////////////////////////////////////////////////// -DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) - : objectToClip(objectToClip), vinput(vinput), vcount(vcount), mode(mode), ccw(ccw), clipleft(clipleft), clipright(clipright), cliptop(cliptop), clipbottom(clipbottom), texturePixels(texturePixels), textureWidth(textureWidth), textureHeight(textureHeight), solidcolor(solidcolor) +DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) + : uniforms(uniforms), vinput(vinput), vcount(vcount), mode(mode), ccw(ccw), clipleft(clipleft), clipright(clipright), cliptop(cliptop), clipbottom(clipbottom), texturePixels(texturePixels), textureWidth(textureWidth), textureHeight(textureHeight), solidcolor(solidcolor) { } void DrawPolyTrianglesCommand::Execute(DrawerThread *thread) { PolyTriangleDrawer::draw_arrays( - objectToClip, vinput, vcount, mode, ccw, + uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texturePixels, textureWidth, textureHeight, solidcolor, thread, texturePixels ? ScreenPolyTriangleDrawer::draw32 : ScreenPolyTriangleDrawer::fill32); diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index de9cd543c..cba5202b7 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -31,17 +31,17 @@ struct ScreenPolyTriangleDrawerArgs; class PolyTriangleDrawer { public: - static void draw(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, FTexture *texture); - static void fill(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int solidcolor); + static void draw(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, FTexture *texture); + static void fill(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int solidcolor); private: - static TriVertex shade_vertex(const TriMatrix &objectToClip, TriVertex v); - static void draw_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)); + static TriVertex shade_vertex(const TriUniforms &uniforms, TriVertex v); + static void draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)); static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert); - static void queue_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); + static void queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); friend class DrawPolyTrianglesCommand; }; @@ -61,6 +61,7 @@ struct ScreenPolyTriangleDrawerArgs int textureWidth; int textureHeight; int solidcolor; + const TriUniforms *uniforms; }; class ScreenPolyTriangleDrawer @@ -80,13 +81,13 @@ private: class DrawPolyTrianglesCommand : public DrawerCommand { public: - DrawPolyTrianglesCommand(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); + DrawPolyTrianglesCommand(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); void Execute(DrawerThread *thread) override; FString DebugInfo() override; private: - TriMatrix objectToClip; + TriUniforms uniforms; const TriVertex *vinput; int vcount; TriangleDrawMode mode; diff --git a/src/r_triangle.cpp b/src/r_triangle.cpp index 26e393323..a95e6d0db 100644 --- a/src/r_triangle.cpp +++ b/src/r_triangle.cpp @@ -36,23 +36,23 @@ #include "r_data/colormaps.h" #include "r_triangle.h" -void TriangleDrawer::draw(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture) +void TriangleDrawer::draw(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture) { if (r_swtruecolor) - queue_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, (const uint8_t*)texture->GetPixelsBgra(), texture->GetWidth(), texture->GetHeight(), 0); + queue_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, (const uint8_t*)texture->GetPixelsBgra(), texture->GetWidth(), texture->GetHeight(), 0); else - draw_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texture->GetPixels(), texture->GetWidth(), texture->GetHeight(), 0, nullptr, &ScreenTriangleDrawer::draw); + draw_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texture->GetPixels(), texture->GetWidth(), texture->GetHeight(), 0, nullptr, &ScreenTriangleDrawer::draw); } -void TriangleDrawer::fill(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor) +void TriangleDrawer::fill(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor) { if (r_swtruecolor) - queue_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor); + queue_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor); else - draw_arrays(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor, nullptr, &ScreenTriangleDrawer::fill); + draw_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor, nullptr, &ScreenTriangleDrawer::fill); } -void TriangleDrawer::queue_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) +void TriangleDrawer::queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) { if (clipright < clipleft || clipleft < 0 || clipright > MAXWIDTH) return; @@ -72,10 +72,10 @@ void TriangleDrawer::queue_arrays(const TriMatrix &objectToClip, const TriVertex for (int i = 0; i < cliplength; i++) clipdata[cliplength + i] = clipbottom[clipleft + i]; - DrawerCommandQueue::QueueCommand(objectToClip, vinput, vcount, mode, ccw, clipleft, clipright, clipdata, texturePixels, textureWidth, textureHeight, solidcolor); + DrawerCommandQueue::QueueCommand(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, clipdata, texturePixels, textureWidth, textureHeight, solidcolor); } -void TriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)) +void TriangleDrawer::draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)) { if (vcount < 3) return; @@ -91,6 +91,7 @@ void TriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVertex args.textureWidth = textureWidth; args.textureHeight = textureHeight; args.solidcolor = solidcolor; + args.uniforms = &uniforms; TriVertex vert[3]; if (mode == TriangleDrawMode::Normal) @@ -98,28 +99,28 @@ void TriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVertex for (int i = 0; i < vcount / 3; i++) { for (int j = 0; j < 3; j++) - vert[j] = shade_vertex(objectToClip, *(vinput++)); + vert[j] = shade_vertex(uniforms, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); } } else if (mode == TriangleDrawMode::Fan) { - vert[0] = shade_vertex(objectToClip, *(vinput++)); - vert[1] = shade_vertex(objectToClip, *(vinput++)); + vert[0] = shade_vertex(uniforms, *(vinput++)); + vert[1] = shade_vertex(uniforms, *(vinput++)); for (int i = 2; i < vcount; i++) { - vert[2] = shade_vertex(objectToClip, *(vinput++)); + vert[2] = shade_vertex(uniforms, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); vert[1] = vert[2]; } } else // TriangleDrawMode::Strip { - vert[0] = shade_vertex(objectToClip, *(vinput++)); - vert[1] = shade_vertex(objectToClip, *(vinput++)); + vert[0] = shade_vertex(uniforms, *(vinput++)); + vert[1] = shade_vertex(uniforms, *(vinput++)); for (int i = 2; i < vcount; i++) { - vert[2] = shade_vertex(objectToClip, *(vinput++)); + vert[2] = shade_vertex(uniforms, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); vert[0] = vert[1]; vert[1] = vert[2]; @@ -128,10 +129,10 @@ void TriangleDrawer::draw_arrays(const TriMatrix &objectToClip, const TriVertex } } -TriVertex TriangleDrawer::shade_vertex(const TriMatrix &objectToClip, TriVertex v) +TriVertex TriangleDrawer::shade_vertex(const TriUniforms &uniforms, TriVertex v) { // Apply transform to get clip coordinates: - return objectToClip * v; + return uniforms.objectToClip * v; } void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)) @@ -412,7 +413,6 @@ void ScreenTriangleDrawer::draw(const ScreenTriangleDrawerArgs *args, DrawerThre { uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); - //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -454,7 +454,6 @@ void ScreenTriangleDrawer::draw(const ScreenTriangleDrawerArgs *args, DrawerThre { uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); - //uint32_t light = (uint32_t)clamp(varying[2] * 255.0f + 0.5f, 0.0f, 255.0f); uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -666,6 +665,7 @@ void ScreenTriangleDrawer::draw32(const ScreenTriangleDrawerArgs *args, DrawerTh const uint32_t *texturePixels = (const uint32_t *)args->texturePixels; int textureWidth = args->textureWidth; int textureHeight = args->textureHeight; + uint32_t light = args->uniforms->light; // 28.4 fixed-point coordinates const int Y1 = (int)round(16.0f * v1.y); @@ -821,7 +821,6 @@ void ScreenTriangleDrawer::draw32(const ScreenTriangleDrawerArgs *args, DrawerTh { uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); - uint32_t light = (uint32_t)clamp(varying[2] * 256.0f + 0.5f, 0.0f, 256.0f); uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -873,7 +872,6 @@ void ScreenTriangleDrawer::draw32(const ScreenTriangleDrawerArgs *args, DrawerTh { uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); - uint32_t light = (uint32_t)clamp(varying[2] * 256.0f + 0.5f, 0.0f, 256.0f); uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -1248,8 +1246,8 @@ TriVertex TriMatrix::operator*(TriVertex v) const ///////////////////////////////////////////////////////////////////////////// -DrawTrianglesCommand::DrawTrianglesCommand(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *clipdata, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) - : objectToClip(objectToClip), vinput(vinput), vcount(vcount), mode(mode), ccw(ccw), clipleft(clipleft), clipright(clipright), clipdata(clipdata), texturePixels(texturePixels), textureWidth(textureWidth), textureHeight(textureHeight), solidcolor(solidcolor) +DrawTrianglesCommand::DrawTrianglesCommand(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *clipdata, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) + : uniforms(uniforms), vinput(vinput), vcount(vcount), mode(mode), ccw(ccw), clipleft(clipleft), clipright(clipright), clipdata(clipdata), texturePixels(texturePixels), textureWidth(textureWidth), textureHeight(textureHeight), solidcolor(solidcolor) { } @@ -1263,7 +1261,7 @@ void DrawTrianglesCommand::Execute(DrawerThread *thread) } TriangleDrawer::draw_arrays( - objectToClip, vinput, vcount, mode, ccw, + uniforms, vinput, vcount, mode, ccw, clipleft, clipright, thread->triangle_clip_top, thread->triangle_clip_bottom, texturePixels, textureWidth, textureHeight, solidcolor, thread, texturePixels ? ScreenTriangleDrawer::draw32 : ScreenTriangleDrawer::fill32); diff --git a/src/r_triangle.h b/src/r_triangle.h index 98fa25db0..254cb5570 100644 --- a/src/r_triangle.h +++ b/src/r_triangle.h @@ -33,9 +33,9 @@ struct ScreenTriangleDrawerArgs; struct TriVertex { TriVertex() { } - TriVertex(float x, float y, float z, float w, float u, float v, float light) : x(x), y(y), z(z), w(w) { varying[0] = u; varying[1] = v; varying[2] = light; } + TriVertex(float x, float y, float z, float w, float u, float v) : x(x), y(y), z(z), w(w) { varying[0] = u; varying[1] = v; } - enum { NumVarying = 3 }; + enum { NumVarying = 2 }; float x, y, z, w; float varying[NumVarying]; }; @@ -60,6 +60,30 @@ struct TriMatrix float matrix[16]; }; +struct TriUniforms +{ + uint32_t light; + + uint16_t light_alpha; + uint16_t light_red; + uint16_t light_green; + uint16_t light_blue; + uint16_t fade_alpha; + uint16_t fade_red; + uint16_t fade_green; + uint16_t fade_blue; + uint16_t desaturate; + uint32_t flags; + enum Flags + { + simple_shade = 1, + nearest_filter = 2, + diminishing_lighting = 4 + }; + + TriMatrix objectToClip; +}; + enum class TriangleDrawMode { Normal, @@ -70,17 +94,17 @@ enum class TriangleDrawMode class TriangleDrawer { public: - static void draw(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture); - static void fill(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor); + static void draw(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture); + static void fill(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor); private: - static TriVertex shade_vertex(const TriMatrix &objectToClip, TriVertex v); - static void draw_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)); + static TriVertex shade_vertex(const TriUniforms &uniforms, TriVertex v); + static void draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)); static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert); - static void queue_arrays(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); + static void queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); friend class DrawTrianglesCommand; }; @@ -100,6 +124,7 @@ struct ScreenTriangleDrawerArgs int textureWidth; int textureHeight; int solidcolor; + const TriUniforms *uniforms; }; class ScreenTriangleDrawer @@ -119,13 +144,13 @@ private: class DrawTrianglesCommand : public DrawerCommand { public: - DrawTrianglesCommand(const TriMatrix &objectToClip, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *clipdata, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); + DrawTrianglesCommand(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *clipdata, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); void Execute(DrawerThread *thread) override; FString DebugInfo() override; private: - TriMatrix objectToClip; + const TriUniforms uniforms; const TriVertex *vinput; int vcount; TriangleDrawMode mode; From 466274d7f6903bf0477d098723e6914b45001139 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 8 Nov 2016 16:46:15 +0100 Subject: [PATCH 1178/1509] Remove floats from the inner block loop --- src/r_poly_triangle.cpp | 52 +++++++++++++++++++++++++---------------- src/r_triangle.cpp | 39 +++++++++++++++++++------------ 2 files changed, 56 insertions(+), 35 deletions(-) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index d77919677..1be35aa26 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -379,17 +379,20 @@ void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, Dr { for (int iy = 0; iy < q; iy++) { - float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) { - varying[i] = varyingTL[i] + varyingBL[i] * iy; - varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + float pos = varyingTL[i] + varyingBL[i] * iy; + float step = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + + varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); + varyingStep[i] = (uint32_t)(step * 0x100000000LL); } for (int ix = x; ix < x + q; ix++) { - uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); - uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + uint32_t ufrac = varying[0]; + uint32_t vfrac = varying[1]; uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -416,11 +419,14 @@ void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, Dr int CX2 = CY2; int CX3 = CY3; - float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) { - varying[i] = varyingTL[i] + varyingBL[i] * iy; - varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + float pos = varyingTL[i] + varyingBL[i] * iy; + float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); + + varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); + varyingStep[i] = (uint32_t)(step * 0x100000000LL); } for (int ix = x; ix < x + q; ix++) @@ -429,8 +435,8 @@ void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, Dr if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) { - uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); - uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + uint32_t ufrac = varying[0]; + uint32_t vfrac = varying[1]; uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -765,17 +771,20 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, { for (int iy = 0; iy < q; iy++) { - float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) { - varying[i] = varyingTL[i] + varyingBL[i] * iy; - varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + float pos = varyingTL[i] + varyingBL[i] * iy; + float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); + + varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); + varyingStep[i] = (uint32_t)(step * 0x100000000LL); } for (int ix = x; ix < x + q; ix++) { - uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); - uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + uint32_t ufrac = varying[0]; + uint32_t vfrac = varying[1]; uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -809,11 +818,14 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, int CX2 = CY2; int CX3 = CY3; - float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) { - varying[i] = varyingTL[i] + varyingBL[i] * iy; - varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + float pos = varyingTL[i] + varyingBL[i] * iy; + float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); + + varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); + varyingStep[i] = (uint32_t)(step * 0x100000000LL); } for (int ix = x; ix < x + q; ix++) @@ -822,8 +834,8 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) { - uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); - uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + uint32_t ufrac = varying[0]; + uint32_t vfrac = varying[1]; uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; diff --git a/src/r_triangle.cpp b/src/r_triangle.cpp index a95e6d0db..95e4e636e 100644 --- a/src/r_triangle.cpp +++ b/src/r_triangle.cpp @@ -402,17 +402,20 @@ void ScreenTriangleDrawer::draw(const ScreenTriangleDrawerArgs *args, DrawerThre { for (int iy = 0; iy < q; iy++) { - float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) { - varying[i] = varyingTL[i] + varyingBL[i] * iy; - varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + float pos = varyingTL[i] + varyingBL[i] * iy; + float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); + + varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); + varyingStep[i] = (uint32_t)(step * 0x100000000LL); } for (int ix = x; ix < x + q; ix++) { - uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); - uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + uint32_t ufrac = varying[0]; + uint32_t vfrac = varying[1]; uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -439,11 +442,14 @@ void ScreenTriangleDrawer::draw(const ScreenTriangleDrawerArgs *args, DrawerThre int CX2 = CY2; int CX3 = CY3; - float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) { - varying[i] = varyingTL[i] + varyingBL[i] * iy; - varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + float pos = varyingTL[i] + varyingBL[i] * iy; + float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); + + varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); + varyingStep[i] = (uint32_t)(step * 0x100000000LL); } for (int ix = x; ix < x + q; ix++) @@ -452,8 +458,8 @@ void ScreenTriangleDrawer::draw(const ScreenTriangleDrawerArgs *args, DrawerThre if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) { - uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); - uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + uint32_t ufrac = varying[0]; + uint32_t vfrac = varying[1]; uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -808,19 +814,22 @@ void ScreenTriangleDrawer::draw32(const ScreenTriangleDrawerArgs *args, DrawerTh { for (int iy = 0; iy < q; iy++) { - float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) { - varying[i] = varyingTL[i] + varyingBL[i] * iy; - varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + float pos = varyingTL[i] + varyingBL[i] * iy; + float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); + + varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); + varyingStep[i] = (uint32_t)(step * 0x100000000LL); } if (!thread->skipped_by_thread(y + iy)) { for (int ix = x; ix < x + q; ix++) { - uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); - uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); + uint32_t ufrac = varying[0]; + uint32_t vfrac = varying[1]; uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; From c1d496c17fac5a77e4d735779028ee5a90d75ff6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 8 Nov 2016 17:38:19 +0100 Subject: [PATCH 1179/1509] A little bit of SSE to speed it slightly more --- src/r_poly_triangle.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 1be35aa26..d20c776a4 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -638,6 +638,10 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, int textureHeight = args->textureHeight; uint32_t light = args->uniforms->light; +#if !defined(NO_SSE) + __m128i mlight = _mm_set1_epi16(light); +#endif + // 28.4 fixed-point coordinates const int Y1 = (int)round(16.0f * v1.y); const int Y2 = (int)round(16.0f * v2.y); @@ -781,6 +785,7 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, varyingStep[i] = (uint32_t)(step * 0x100000000LL); } +#if NO_SSE for (int ix = x; ix < x + q; ix++) { uint32_t ufrac = varying[0]; @@ -802,6 +807,34 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, for (int i = 0; i < TriVertex::NumVarying; i++) varying[i] += varyingStep[i]; } +#else + for (int sse = 0; sse < q / 4; sse++) + { + uint32_t fg[4]; + for (int ix = 0; ix < 4; ix++) + { + uint32_t ufrac = varying[0]; + uint32_t vfrac = varying[1]; + uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; + uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; + uint32_t uvoffset = upos * textureHeight + vpos; + fg[ix] = texturePixels[uvoffset]; + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + } + + __m128i mfg = _mm_loadu_si128((const __m128i*)fg); + __m128i mfg0 = _mm_unpacklo_epi8(mfg, _mm_setzero_si128()); + __m128i mfg1 = _mm_unpackhi_epi8(mfg, _mm_setzero_si128()); + __m128i mout0 = _mm_srli_epi16(_mm_mullo_epi16(mfg0, mlight), 8); + __m128i mout1 = _mm_srli_epi16(_mm_mullo_epi16(mfg1, mlight), 8); + __m128i mout = _mm_packus_epi16(mout0, mout1); + __m128i mmask0 = _mm_shufflehi_epi16(_mm_shufflelo_epi16(mfg0, _MM_SHUFFLE(3, 3, 3, 3)), _MM_SHUFFLE(3, 3, 3, 3)); + __m128i mmask1 = _mm_shufflehi_epi16(_mm_shufflelo_epi16(mfg1, _MM_SHUFFLE(3, 3, 3, 3)), _MM_SHUFFLE(3, 3, 3, 3)); + __m128i mmask = _mm_cmplt_epi8(_mm_packus_epi16(mmask0, mmask1), _mm_setzero_si128()); + _mm_maskmoveu_si128(mout, mmask, (char*)(&buffer[x + sse * 4])); + } +#endif buffer += pitch; } From 6ef8fe2da560b5178989fad7d379b5a81fb1fbcd Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 8 Nov 2016 18:08:13 +0100 Subject: [PATCH 1180/1509] Add diminishing lighting --- src/r_poly_triangle.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index d20c776a4..ffb8d82bb 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -638,10 +638,6 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, int textureHeight = args->textureHeight; uint32_t light = args->uniforms->light; -#if !defined(NO_SSE) - __m128i mlight = _mm_set1_epi16(light); -#endif - // 28.4 fixed-point coordinates const int Y1 = (int)round(16.0f * v1.y); const int Y2 = (int)round(16.0f * v2.y); @@ -768,6 +764,16 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); } + float globVis = 1706.0f; + float vis = globVis / rcpWTL; + float shade = 64.0f - (light * 255 / 256 + 12.0f) * 32.0f / 128.0f; + float lightscale = clamp((shade - MIN(24.0f, vis)) / 32.0f, 0.0f, 31.0f / 32.0f); + int diminishedlight = (int)clamp((1.0f - lightscale) * 256.0f + 0.5f, 0.0f, 256.0f); + +#if !defined(NO_SSE) + __m128i mlight = _mm_set1_epi16(diminishedlight); +#endif + uint32_t *buffer = dest; // Accept whole block when totally covered @@ -796,9 +802,9 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, uint32_t uvoffset = upos * textureHeight + vpos; uint32_t fg = texturePixels[uvoffset]; - uint32_t fg_red = (RPART(fg) * light) >> 8; - uint32_t fg_green = (GPART(fg) * light) >> 8; - uint32_t fg_blue = (BPART(fg) * light) >> 8; + uint32_t fg_red = (RPART(fg) * diminishedlight) >> 8; + uint32_t fg_green = (GPART(fg) * diminishedlight) >> 8; + uint32_t fg_blue = (BPART(fg) * diminishedlight) >> 8; uint32_t fg_alpha = APART(fg); if (fg_alpha > 127) @@ -875,9 +881,9 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, uint32_t uvoffset = upos * textureHeight + vpos; uint32_t fg = texturePixels[uvoffset]; - uint32_t fg_red = (RPART(fg) * light) >> 8; - uint32_t fg_green = (GPART(fg) * light) >> 8; - uint32_t fg_blue = (BPART(fg) * light) >> 8; + uint32_t fg_red = (RPART(fg) * diminishedlight) >> 8; + uint32_t fg_green = (GPART(fg) * diminishedlight) >> 8; + uint32_t fg_blue = (BPART(fg) * diminishedlight) >> 8; uint32_t fg_alpha = APART(fg); if (fg_alpha > 127) From d36993a03b8bf46fd47f5c6377834d849ab374c8 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 8 Nov 2016 15:05:23 -0500 Subject: [PATCH 1181/1509] - Textured automap would crash due to an additional parameter in the software renderer to the FillSimplePoly function call, causing stack issues. --- src/gl/renderer/gl_renderer.h | 2 +- src/gl/system/gl_framebuffer.cpp | 2 +- src/gl/system/gl_framebuffer.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 19bc93af0..6ea1e357a 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -206,7 +206,7 @@ public: void FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, - DAngle rotation, FDynamicColormap *colormap, int lightlevel); + DAngle rotation, FDynamicColormap *colormap, int lightlevel, int bottomclip); int PTM_BestColor (const uint32 *pal_in, int r, int g, int b, int first, int num); }; diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 6264352f6..4904cc1f6 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -464,7 +464,7 @@ void OpenGLFrameBuffer::Clear(int left, int top, int right, int bottom, int palc void OpenGLFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, - DAngle rotation, FDynamicColormap *colormap, int lightlevel) + DAngle rotation, FDynamicColormap *colormap, int lightlevel, int bottomclip) { if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr && npoints >= 3) { diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index 5315bb0a9..27c3d1cf9 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -71,7 +71,7 @@ public: void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, - DAngle rotation, FDynamicColormap *colormap, int lightlevel); + DAngle rotation, FDynamicColormap *colormap, int lightlevel, int bottomclip); FNativePalette *CreatePalette(FRemapTable *remap); From 9413ea6edf72a2d478f3c5fad30abf014a3c7109 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 8 Nov 2016 15:05:23 -0500 Subject: [PATCH 1182/1509] - Textured automap would crash due to an additional parameter in the software renderer to the FillSimplePoly function call, causing stack issues. --- src/gl/renderer/gl_renderer.h | 2 +- src/gl/system/gl_framebuffer.cpp | 2 +- src/gl/system/gl_framebuffer.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index c671d7497..5610c034e 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -216,7 +216,7 @@ public: void FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, - DAngle rotation, FDynamicColormap *colormap, int lightlevel); + DAngle rotation, FDynamicColormap *colormap, int lightlevel, int bottomclip); int PTM_BestColor (const uint32 *pal_in, int r, int g, int b, int first, int num); diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 57e0cd679..a286d4568 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -464,7 +464,7 @@ void OpenGLFrameBuffer::Clear(int left, int top, int right, int bottom, int palc void OpenGLFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, - DAngle rotation, FDynamicColormap *colormap, int lightlevel) + DAngle rotation, FDynamicColormap *colormap, int lightlevel, int bottomclip) { if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr && npoints >= 3) { diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index 5315bb0a9..27c3d1cf9 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -71,7 +71,7 @@ public: void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, - DAngle rotation, FDynamicColormap *colormap, int lightlevel); + DAngle rotation, FDynamicColormap *colormap, int lightlevel, int bottomclip); FNativePalette *CreatePalette(FRemapTable *remap); From 7d3e8d14140f8654f31aa7ac78649d89f8f88659 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 8 Nov 2016 23:08:25 +0100 Subject: [PATCH 1183/1509] Fix triangle drawer clipping bug --- src/r_poly_triangle.cpp | 139 +++++++++++++++++++++++++++------------- src/r_poly_triangle.h | 2 +- src/r_triangle.cpp | 135 +++++++++++++++++++++++++------------- src/r_triangle.h | 2 +- 4 files changed, 190 insertions(+), 88 deletions(-) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index ffb8d82bb..34bc74dca 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -36,6 +36,10 @@ #include "r_data/colormaps.h" #include "r_poly_triangle.h" +#ifndef NO_SSE +#include +#endif + void PolyTriangleDrawer::draw(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, FTexture *texture) { if (r_swtruecolor) @@ -124,10 +128,8 @@ void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, S { // Cull, clip and generate additional vertices as needed TriVertex clippedvert[6]; - int numclipvert = 0; - clipedge(vert[0], vert[1], clippedvert, numclipvert); - clipedge(vert[1], vert[2], clippedvert, numclipvert); - clipedge(vert[2], vert[0], clippedvert, numclipvert); + int numclipvert; + clipedge(vert, clippedvert, numclipvert); // Map to 2D viewport: for (int j = 0; j < numclipvert; j++) @@ -170,62 +172,113 @@ void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, S bool PolyTriangleDrawer::cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2) { - float d1 = clipdistance1 * (1.0f - t1) + clipdistance2 * t1; - float d2 = clipdistance1 * (1.0f - t2) + clipdistance2 * t2; - if (d1 < 0.0f && d2 < 0.0f) + if (clipdistance1 < 0.0f && clipdistance2 < 0.0f) return true; - if (d1 < 0.0f) - t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), t1); + if (clipdistance1 < 0.0f) + t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), 0.0f); + else + t1 = 0.0f; - if (d2 < 0.0f) - t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2); + if (clipdistance2 < 0.0f) + t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), 1.0f); + else + t2 = 1.0f; return false; } -void PolyTriangleDrawer::clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert) +void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert) { // Clip and cull so that the following is true for all vertices: // -v.w <= v.x <= v.w // -v.w <= v.y <= v.w // -v.w <= v.z <= v.w - - float t1 = 0.0f, t2 = 1.0f; - bool culled = - cullhalfspace(v1.x + v1.w, v2.x + v2.w, t1, t2) || - cullhalfspace(v1.w - v1.x, v2.w - v2.x, t1, t2) || - cullhalfspace(v1.y + v1.w, v2.y + v2.w, t1, t2) || - cullhalfspace(v1.w - v1.y, v2.w - v2.y, t1, t2) || - cullhalfspace(v1.z + v1.w, v2.z + v2.w, t1, t2) || - cullhalfspace(v1.w - v1.z, v2.w - v2.z, t1, t2); - if (culled) - return; - - if (t1 == 0.0f) + + // use barycentric weights while clipping vertices + float weights[6 * 3 * 2]; + for (int i = 0; i < 3; i++) { - clippedvert[numclipvert++] = v1; + weights[i * 3 + 0] = 0.0f; + weights[i * 3 + 1] = 0.0f; + weights[i * 3 + 2] = 0.0f; + weights[i * 3 + i] = 1.0f; } - else + + // halfspace clip distances + float clipdistance[6 * 3]; + for (int i = 0; i < 3; i++) { - auto &v = clippedvert[numclipvert++]; - v.x = v1.x * (1.0f - t1) + v2.x * t1; - v.y = v1.y * (1.0f - t1) + v2.y * t1; - v.z = v1.z * (1.0f - t1) + v2.z * t1; - v.w = v1.w * (1.0f - t1) + v2.w * t1; - for (int i = 0; i < TriVertex::NumVarying; i++) - v.varying[i] = v1.varying[i] * (1.0f - t1) + v2.varying[i] * t1; + const auto &v = verts[i]; + clipdistance[i * 6 + 0] = v.x + v.w; + clipdistance[i * 6 + 1] = v.w - v.x; + clipdistance[i * 6 + 2] = v.y + v.w; + clipdistance[i * 6 + 3] = v.w - v.y; + clipdistance[i * 6 + 4] = v.z + v.w; + clipdistance[i * 6 + 5] = v.w - v.z; } - - if (t2 != 1.0f) + + // Clip against each halfspace + float *input = weights; + float *output = weights + 6 * 3; + int inputverts = 3; + int outputverts = 0; + for (int p = 0; p < 6; p++) { - auto &v = clippedvert[numclipvert++]; - v.x = v1.x * (1.0f - t2) + v2.x * t2; - v.y = v1.y * (1.0f - t2) + v2.y * t2; - v.z = v1.z * (1.0f - t2) + v2.z * t2; - v.w = v1.w * (1.0f - t2) + v2.w * t2; - for (int i = 0; i < TriVertex::NumVarying; i++) - v.varying[i] = v1.varying[i] * (1.0f - t2) + v2.varying[i] * t2; + // Clip each edge + outputverts = 0; + for (int i = 0; i < inputverts; i++) + { + int j = (i + 1) % inputverts; + float clipdistance1 = + clipdistance[0 * 6 + p] * input[i * 3 + 0] + + clipdistance[1 * 6 + p] * input[i * 3 + 1] + + clipdistance[2 * 6 + p] * input[i * 3 + 2]; + + float clipdistance2 = + clipdistance[0 * 6 + p] * input[j * 3 + 0] + + clipdistance[1 * 6 + p] * input[j * 3 + 1] + + clipdistance[2 * 6 + p] * input[j * 3 + 2]; + + float t1, t2; + if (!cullhalfspace(clipdistance1, clipdistance2, t1, t2)) + { + // add t1 vertex + for (int k = 0; k < 3; k++) + output[outputverts * 3 + k] = input[i * 3 + k] * (1.0f - t1) + input[j * 3 + k] * t1; + outputverts++; + + if (t2 != 1.0f && t2 > t1) + { + // add t2 vertex + for (int k = 0; k < 3; k++) + output[outputverts * 3 + k] = input[i * 3 + k] * (1.0f - t2) + input[j * 3 + k] * t2; + outputverts++; + } + } + } + std::swap(input, output); + std::swap(inputverts, outputverts); + if (inputverts == 0) + break; + } + + // Convert barycentric weights to actual vertices + numclipvert = inputverts; + for (int i = 0; i < numclipvert; i++) + { + auto &v = clippedvert[i]; + memset(&v, 0, sizeof(TriVertex)); + for (int w = 0; w < 3; w++) + { + float weight = input[i * 3 + w]; + v.x += verts[w].x * weight; + v.y += verts[w].y * weight; + v.z += verts[w].z * weight; + v.w += verts[w].w * weight; + for (int iv = 0; iv < TriVertex::NumVarying; iv++) + v.varying[iv] += verts[w].varying[iv] * weight; + } } } diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index cba5202b7..79c8d4a7a 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -39,7 +39,7 @@ private: static void draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)); static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); - static void clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert); + static void clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert); static void queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); diff --git a/src/r_triangle.cpp b/src/r_triangle.cpp index 95e4e636e..340306fec 100644 --- a/src/r_triangle.cpp +++ b/src/r_triangle.cpp @@ -139,10 +139,8 @@ void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, Scree { // Cull, clip and generate additional vertices as needed TriVertex clippedvert[6]; - int numclipvert = 0; - clipedge(vert[0], vert[1], clippedvert, numclipvert); - clipedge(vert[1], vert[2], clippedvert, numclipvert); - clipedge(vert[2], vert[0], clippedvert, numclipvert); + int numclipvert; + clipedge(vert, clippedvert, numclipvert); // Map to 2D viewport: for (int j = 0; j < numclipvert; j++) @@ -185,62 +183,113 @@ void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, Scree bool TriangleDrawer::cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2) { - float d1 = clipdistance1 * (1.0f - t1) + clipdistance2 * t1; - float d2 = clipdistance1 * (1.0f - t2) + clipdistance2 * t2; - if (d1 < 0.0f && d2 < 0.0f) + if (clipdistance1 < 0.0f && clipdistance2 < 0.0f) return true; - if (d1 < 0.0f) - t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), t1); + if (clipdistance1 < 0.0f) + t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), 0.0f); + else + t1 = 0.0f; - if (d2 < 0.0f) - t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2); + if (clipdistance2 < 0.0f) + t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), 1.0f); + else + t2 = 1.0f; return false; } -void TriangleDrawer::clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert) +void TriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert) { // Clip and cull so that the following is true for all vertices: // -v.w <= v.x <= v.w // -v.w <= v.y <= v.w // -v.w <= v.z <= v.w - - float t1 = 0.0f, t2 = 1.0f; - bool culled = - cullhalfspace(v1.x + v1.w, v2.x + v2.w, t1, t2) || - cullhalfspace(v1.w - v1.x, v2.w - v2.x, t1, t2) || - cullhalfspace(v1.y + v1.w, v2.y + v2.w, t1, t2) || - cullhalfspace(v1.w - v1.y, v2.w - v2.y, t1, t2) || - cullhalfspace(v1.z + v1.w, v2.z + v2.w, t1, t2) || - cullhalfspace(v1.w - v1.z, v2.w - v2.z, t1, t2); - if (culled) - return; - - if (t1 == 0.0f) + + // use barycentric weights while clipping vertices + float weights[6 * 3 * 2]; + for (int i = 0; i < 3; i++) { - clippedvert[numclipvert++] = v1; + weights[i * 3 + 0] = 0.0f; + weights[i * 3 + 1] = 0.0f; + weights[i * 3 + 2] = 0.0f; + weights[i * 3 + i] = 1.0f; } - else + + // halfspace clip distances + float clipdistance[6 * 3]; + for (int i = 0; i < 3; i++) { - auto &v = clippedvert[numclipvert++]; - v.x = v1.x * (1.0f - t1) + v2.x * t1; - v.y = v1.y * (1.0f - t1) + v2.y * t1; - v.z = v1.z * (1.0f - t1) + v2.z * t1; - v.w = v1.w * (1.0f - t1) + v2.w * t1; - for (int i = 0; i < TriVertex::NumVarying; i++) - v.varying[i] = v1.varying[i] * (1.0f - t1) + v2.varying[i] * t1; + const auto &v = verts[i]; + clipdistance[i * 6 + 0] = v.x + v.w; + clipdistance[i * 6 + 1] = v.w - v.x; + clipdistance[i * 6 + 2] = v.y + v.w; + clipdistance[i * 6 + 3] = v.w - v.y; + clipdistance[i * 6 + 4] = v.z + v.w; + clipdistance[i * 6 + 5] = v.w - v.z; } - - if (t2 != 1.0f) + + // Clip against each halfspace + float *input = weights; + float *output = weights + 6 * 3; + int inputverts = 3; + int outputverts = 0; + for (int p = 0; p < 6; p++) { - auto &v = clippedvert[numclipvert++]; - v.x = v1.x * (1.0f - t2) + v2.x * t2; - v.y = v1.y * (1.0f - t2) + v2.y * t2; - v.z = v1.z * (1.0f - t2) + v2.z * t2; - v.w = v1.w * (1.0f - t2) + v2.w * t2; - for (int i = 0; i < TriVertex::NumVarying; i++) - v.varying[i] = v1.varying[i] * (1.0f - t2) + v2.varying[i] * t2; + // Clip each edge + outputverts = 0; + for (int i = 0; i < inputverts; i++) + { + int j = (i + 1) % inputverts; + float clipdistance1 = + clipdistance[0 * 6 + p] * input[i * 3 + 0] + + clipdistance[1 * 6 + p] * input[i * 3 + 1] + + clipdistance[2 * 6 + p] * input[i * 3 + 2]; + + float clipdistance2 = + clipdistance[0 * 6 + p] * input[j * 3 + 0] + + clipdistance[1 * 6 + p] * input[j * 3 + 1] + + clipdistance[2 * 6 + p] * input[j * 3 + 2]; + + float t1, t2; + if (!cullhalfspace(clipdistance1, clipdistance2, t1, t2)) + { + // add t1 vertex + for (int k = 0; k < 3; k++) + output[outputverts * 3 + k] = input[i * 3 + k] * (1.0f - t1) + input[j * 3 + k] * t1; + outputverts++; + + if (t2 != 1.0f && t2 > t1) + { + // add t2 vertex + for (int k = 0; k < 3; k++) + output[outputverts * 3 + k] = input[i * 3 + k] * (1.0f - t2) + input[j * 3 + k] * t2; + outputverts++; + } + } + } + std::swap(input, output); + std::swap(inputverts, outputverts); + if (inputverts == 0) + break; + } + + // Convert barycentric weights to actual vertices + numclipvert = inputverts; + for (int i = 0; i < numclipvert; i++) + { + auto &v = clippedvert[i]; + memset(&v, 0, sizeof(TriVertex)); + for (int w = 0; w < 3; w++) + { + float weight = input[i * 3 + w]; + v.x += verts[w].x * weight; + v.y += verts[w].y * weight; + v.z += verts[w].z * weight; + v.w += verts[w].w * weight; + for (int iv = 0; iv < TriVertex::NumVarying; iv++) + v.varying[iv] += verts[w].varying[iv] * weight; + } } } diff --git a/src/r_triangle.h b/src/r_triangle.h index 254cb5570..82b1d2c4d 100644 --- a/src/r_triangle.h +++ b/src/r_triangle.h @@ -102,7 +102,7 @@ private: static void draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)); static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); - static void clipedge(const TriVertex &v1, const TriVertex &v2, TriVertex *clippedvert, int &numclipvert); + static void clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert); static void queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); From 968150ceffbe9f133400c31fb706ea213b917d2c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 9 Nov 2016 00:22:05 +0100 Subject: [PATCH 1184/1509] Seems there could be more than 6 vertices --- src/r_poly_triangle.cpp | 6 +++--- src/r_triangle.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 34bc74dca..168b4378a 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -127,7 +127,7 @@ TriVertex PolyTriangleDrawer::shade_vertex(const TriUniforms &uniforms, TriVerte void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)) { // Cull, clip and generate additional vertices as needed - TriVertex clippedvert[6]; + TriVertex clippedvert[12]; int numclipvert; clipedge(vert, clippedvert, numclipvert); @@ -196,7 +196,7 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert // -v.w <= v.z <= v.w // use barycentric weights while clipping vertices - float weights[6 * 3 * 2]; + float weights[12 * 3 * 2]; for (int i = 0; i < 3; i++) { weights[i * 3 + 0] = 0.0f; @@ -220,7 +220,7 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert // Clip against each halfspace float *input = weights; - float *output = weights + 6 * 3; + float *output = weights + 12 * 3; int inputverts = 3; int outputverts = 0; for (int p = 0; p < 6; p++) diff --git a/src/r_triangle.cpp b/src/r_triangle.cpp index 340306fec..c15817770 100644 --- a/src/r_triangle.cpp +++ b/src/r_triangle.cpp @@ -138,7 +138,7 @@ TriVertex TriangleDrawer::shade_vertex(const TriUniforms &uniforms, TriVertex v) void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)) { // Cull, clip and generate additional vertices as needed - TriVertex clippedvert[6]; + TriVertex clippedvert[12]; int numclipvert; clipedge(vert, clippedvert, numclipvert); @@ -207,7 +207,7 @@ void TriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert, in // -v.w <= v.z <= v.w // use barycentric weights while clipping vertices - float weights[6 * 3 * 2]; + float weights[12 * 3 * 2]; for (int i = 0; i < 3; i++) { weights[i * 3 + 0] = 0.0f; @@ -231,7 +231,7 @@ void TriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert, in // Clip against each halfspace float *input = weights; - float *output = weights + 6 * 3; + float *output = weights + 12 * 3; int inputverts = 3; int outputverts = 0; for (int p = 0; p < 6; p++) From 95df9bf48e51990d71ea65e44a3d842efd8f9a8f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 9 Nov 2016 00:35:41 +0100 Subject: [PATCH 1185/1509] Fix crash bug in 8 bit drawer --- src/r_poly_triangle.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 168b4378a..a9c54bc74 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -369,7 +369,7 @@ void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, Dr for (int y = miny; y < maxy; y += q, dest += q * pitch) { // Is this row of blocks done by this thread? - if (thread->skipped_by_thread(y / q)) continue; + if (thread && thread->skipped_by_thread(y / q)) continue; for (int x = minx; x < maxx; x += q) { @@ -436,7 +436,7 @@ void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, Dr for (int i = 0; i < TriVertex::NumVarying; i++) { float pos = varyingTL[i] + varyingBL[i] * iy; - float step = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); + float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); varyingStep[i] = (uint32_t)(step * 0x100000000LL); @@ -451,7 +451,8 @@ void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, Dr uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; uint32_t uvoffset = upos * textureHeight + vpos; - buffer[ix] = texturePixels[uvoffset]; + if (texturePixels[uvoffset] != 0) + buffer[ix] = texturePixels[uvoffset]; for (int i = 0; i < TriVertex::NumVarying; i++) varying[i] += varyingStep[i]; @@ -495,7 +496,8 @@ void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, Dr uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; uint32_t uvoffset = upos * textureHeight + vpos; - buffer[ix] = texturePixels[uvoffset]; + if (texturePixels[uvoffset] != 0) + buffer[ix] = texturePixels[uvoffset]; } for (int i = 0; i < TriVertex::NumVarying; i++) @@ -588,7 +590,7 @@ void ScreenPolyTriangleDrawer::fill(const ScreenPolyTriangleDrawerArgs *args, Dr for (int y = miny; y < maxy; y += q, dest += q * pitch) { // Is this row of blocks done by this thread? - if (thread->skipped_by_thread(y / q)) continue; + if (thread && thread->skipped_by_thread(y / q)) continue; for (int x = minx; x < maxx; x += q) { From cffdfdf7fdfe453050e67d0ca25b6fc1f7ca092b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 9 Nov 2016 01:33:40 +0100 Subject: [PATCH 1186/1509] Cull bsp using solid segments --- src/r_poly.cpp | 133 +++++++++++++++++++++++++++++++++++++++++++++++-- src/r_poly.h | 13 +++++ 2 files changed, 142 insertions(+), 4 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 03052ab60..a823d94f7 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -35,11 +35,17 @@ EXTERN_CVAR(Bool, r_drawplayersprites) EXTERN_CVAR(Bool, r_deathcamera) EXTERN_CVAR(Bool, st_scale) +CVAR(Bool, r_debug_cull, 0, 0) + ///////////////////////////////////////////////////////////////////////////// void RenderPolyBsp::Render() { PolyVertexBuffer::Clear(); + SolidSegments.clear(); + SolidSegments.reserve(MAXWIDTH / 2 + 2); + SolidSegments.push_back({ -0x7fff, 0 }); + SolidSegments.push_back({ viewwidth, 0x7fff }); // Perspective correct: float ratio = WidescreenRatio; @@ -63,8 +69,16 @@ void RenderPolyBsp::Render() RenderNode(nodes + numnodes - 1); // The head node is the last node output. // Render back to front (we don't have a zbuffer at the moment, sniff!): - for (auto it = PvsSectors.rbegin(); it != PvsSectors.rend(); ++it) - RenderSubsector(*it); + if (!r_debug_cull) + { + for (auto it = PvsSectors.rbegin(); it != PvsSectors.rend(); ++it) + RenderSubsector(*it); + } + else + { + for (auto it = PvsSectors.begin(); it != PvsSectors.end(); ++it) + RenderSubsector(*it); + } RenderPlayerSprites(); DrawerCommandQueue::WaitForWorkers(); @@ -543,8 +557,24 @@ void RenderPolyBsp::RenderNode(void *node) node = bsp->children[side]; } - PvsSectors.push_back((subsector_t *)((BYTE *)node - 1)); - //RenderSubsector((subsector_t *)((BYTE *)node - 1)); + + // Mark that we need to render this + subsector_t *sub = (subsector_t *)((BYTE *)node - 1); + PvsSectors.push_back(sub); + + // Update culling info for further bsp clipping + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + if ((line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) && line->backsector == nullptr) + { + int sx1, sx2; + if (GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2)) + { + MarkSegmentCulled(sx1, sx2); + } + } + } } void RenderPolyBsp::RenderPlayerSprites() @@ -752,6 +782,52 @@ void RenderPolyBsp::RenderPlayerSprite(DPSprite *sprite, AActor *owner, float bo //R_DrawVisSprite(vis); } +bool RenderPolyBsp::IsSegmentCulled(int x1, int x2) const +{ + int next = 0; + while (SolidSegments[next].X2 <= x2) + next++; + return (x1 >= SolidSegments[next].X1 && x2 <= SolidSegments[next].X2); +} + +void RenderPolyBsp::MarkSegmentCulled(int x1, int x2) +{ + if (x1 >= x2) + return; + + int cur = 1; + while (true) + { + if (SolidSegments[cur].X1 <= x1 && SolidSegments[cur].X2 >= x2) // Already fully marked + { + break; + } + else if (cur + 1 != SolidSegments.size() && SolidSegments[cur].X2 >= x1 && SolidSegments[cur].X1 <= x2) // Merge segments + { + // Find last segment + int merge = cur; + while (merge + 2 != SolidSegments.size() && SolidSegments[merge + 1].X1 <= x2) + merge++; + + // Apply new merged range + SolidSegments[cur].X1 = MIN(SolidSegments[cur].X1, x1); + SolidSegments[cur].X2 = MAX(SolidSegments[merge].X2, x2); + + // Remove additional segments we merged with + if (merge > cur) + SolidSegments.erase(SolidSegments.begin() + (cur + 1), SolidSegments.begin() + (merge + 1)); + + break; + } + else if (SolidSegments[cur].X1 > x1) // Insert new segment + { + SolidSegments.insert(SolidSegments.begin() + cur, { x1, x2 }); + break; + } + cur++; + } +} + int RenderPolyBsp::PointOnSide(const DVector2 &pos, const node_t *node) { return DMulScale32(FLOAT2FIXED(pos.Y) - node->y, node->dx, node->x - FLOAT2FIXED(pos.X), node->dy) > 0; @@ -855,6 +931,55 @@ bool RenderPolyBsp::CheckBBox(float *bspcoord) // Find the first clippost that touches the source post // (adjacent pixels are touching). + // Does not cross a pixel. + if (sx2 <= sx1) + return false; + + return !IsSegmentCulled(sx1, sx2); +} + +bool RenderPolyBsp::GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const +{ + x1 = x1 - ViewPos.X; + y1 = y1 - ViewPos.Y; + x2 = x2 - ViewPos.X; + y2 = y2 - ViewPos.Y; + + // Sitting on a line? + if (y1 * (x1 - x2) + x1 * (y2 - y1) >= -EQUAL_EPSILON) + return false; + + double rx1 = x1 * ViewSin - y1 * ViewCos; + double rx2 = x2 * ViewSin - y2 * ViewCos; + double ry1 = x1 * ViewTanCos + y1 * ViewTanSin; + double ry2 = x2 * ViewTanCos + y2 * ViewTanSin; + + if (rx1 >= -ry1) + { + if (rx1 > ry1) return false; // left edge is off the right side + if (ry1 == 0) return false; + sx1 = xs_RoundToInt(CenterX + rx1 * CenterX / ry1); + } + else + { + if (rx2 < -ry2) return false; // wall is off the left side + if (rx1 - rx2 - ry2 + ry1 == 0) return false; // wall does not intersect view volume + sx1 = 0; + } + + if (rx2 <= ry2) + { + if (rx2 < -ry2) return false; // right edge is off the left side + if (ry2 == 0) return false; + sx2 = xs_RoundToInt(CenterX + rx2 * CenterX / ry2); + } + else + { + if (rx1 > ry1) return false; // wall is off the right side + if (ry2 - ry1 - rx2 + rx1 == 0) return false; // wall does not intersect view volume + sx2 = viewwidth; + } + // Does not cross a pixel. if (sx2 <= sx1) return false; diff --git a/src/r_poly.h b/src/r_poly.h index 7a143cf67..6248e02f7 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -77,6 +77,11 @@ private: // Returns true if some part of the bbox might be visible. bool CheckBBox(float *bspcoord); + bool GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const; + + void MarkSegmentCulled(int x1, int x2); + bool IsSegmentCulled(int x1, int x2) const; + std::vector PvsSectors; TriMatrix worldToClip; @@ -84,6 +89,14 @@ private: const int BaseXCenter = 160; const int BaseYCenter = 100; + + struct SolidSegment + { + SolidSegment(int x1, int x2) : X1(x1), X2(x2) { } + int X1, X2; + }; + + std::vector SolidSegments; }; class RenderPolyWall From dc0e6d40a48facd1743606b279db30e5ec002c21 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 9 Nov 2016 11:38:07 +0100 Subject: [PATCH 1187/1509] Distance sort sprites --- src/r_poly.cpp | 28 +++++++++++++++++++++++++++- src/r_poly.h | 24 ++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index a823d94f7..978e0a1f4 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -47,6 +47,10 @@ void RenderPolyBsp::Render() SolidSegments.push_back({ -0x7fff, 0 }); SolidSegments.push_back({ viewwidth, 0x7fff }); + SectorSpriteRanges.clear(); + SectorSpriteRanges.resize(numsectors); + SortedSprites.clear(); + // Perspective correct: float ratio = WidescreenRatio; float fovratio = (WidescreenRatio >= 1.3f) ? 1.333333f : ratio; @@ -174,8 +178,10 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) PolyTriangleDrawer::draw(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, ceiltex); } - for (AActor *thing = sub->sector->thinglist; thing != nullptr; thing = thing->snext) + SpriteRange sprites = GetSpritesForSector(sub->sector); + for (int i = 0; i < sprites.Count; i++) { + AActor *thing = SortedSprites[sprites.Start + i].Thing; if ((thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) AddWallSprite(thing, sub); else @@ -183,6 +189,26 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) } } +SpriteRange RenderPolyBsp::GetSpritesForSector(sector_t *sector) +{ + if (SectorSpriteRanges.size() < sector->sectornum || sector->sectornum < 0) + return SpriteRange(); + + auto &range = SectorSpriteRanges[sector->sectornum]; + if (range.Start == -1) + { + range.Start = (int)SortedSprites.size(); + range.Count = 0; + for (AActor *thing = sector->thinglist; thing != nullptr; thing = thing->snext) + { + SortedSprites.push_back({ thing, (thing->Pos() - ViewPos).LengthSquared() }); + range.Count++; + } + std::stable_sort(SortedSprites.begin() + range.Start, SortedSprites.begin() + range.Start + range.Count); + } + return range; +} + void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector) { // Reject lines not facing viewer diff --git a/src/r_poly.h b/src/r_poly.h index 6248e02f7..7e26f8ce6 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -49,6 +49,26 @@ public: FDynamicColormap *Colormap = nullptr; }; +// Used for sorting things by distance to the camera +class PolySortedSprite +{ +public: + PolySortedSprite(AActor *thing, double distanceSquared) : Thing(thing), DistanceSquared(distanceSquared) { } + bool operator<(const PolySortedSprite &other) const { return DistanceSquared > other.DistanceSquared; } + + AActor *Thing; + double DistanceSquared; +}; + +class SpriteRange +{ +public: + SpriteRange() = default; + SpriteRange(int start, int count) : Start(start), Count(count) { } + int Start = -1; + int Count = 0; +}; + // Renders a GL BSP tree in a scene class RenderPolyBsp { @@ -67,6 +87,7 @@ private: bool IsThingCulled(AActor *thing); visstyle_t GetSpriteVisStyle(AActor *thing, double z); FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); + SpriteRange GetSpritesForSector(sector_t *sector); void RenderPlayerSprites(); void RenderPlayerSprite(DPSprite *sprite, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac); @@ -85,6 +106,9 @@ private: std::vector PvsSectors; TriMatrix worldToClip; + std::vector SectorSpriteRanges; + std::vector SortedSprites; + std::vector ScreenSprites; const int BaseXCenter = 160; From 9820a6cb8883eae953fd6598597671d799bb4f12 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 9 Nov 2016 12:07:07 +0100 Subject: [PATCH 1188/1509] Request GL BSP instead of requiring automap texturing to be on --- src/r_main.cpp | 2 +- src/r_swrenderer.cpp | 5 +++++ src/r_swrenderer.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index 5983e538b..25945012f 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -68,7 +68,7 @@ CUSTOM_CVAR(Bool, r_newrenderer, 0, CVAR_NOINITCALL) { if (self == 1 && !hasglnodes) { - Printf("No GL BSP detected. You must enable automap texturing and then restart the map\n"); + Printf("No GL BSP detected. You must restart the map before rendering will be correct\n"); } } diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index ad9752db9..97a207652 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -258,6 +258,11 @@ int FSoftwareRenderer::GetMaxViewPitch(bool down) return (r_newrenderer) ? int(maxviewpitch) : (down ? MAX_DN_ANGLE : MAX_UP_ANGLE); } +bool FSoftwareRenderer::RequireGLNodes() +{ + return r_newrenderer; +} + //========================================================================== // // OnModeSet diff --git a/src/r_swrenderer.h b/src/r_swrenderer.h index fc3ec2551..5b205b852 100644 --- a/src/r_swrenderer.h +++ b/src/r_swrenderer.h @@ -28,6 +28,7 @@ struct FSoftwareRenderer : public FRenderer virtual void DrawRemainingPlayerSprites() override; virtual int GetMaxViewPitch(bool down) override; + bool RequireGLNodes() override; void OnModeSet () override; void ErrorCleanup () override; From 6c52e1e52bbd5bc8036211afd1b2b5b048df3dac Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 10 Nov 2016 05:01:33 +0100 Subject: [PATCH 1189/1509] Draw sky in a very expensive way --- src/r_poly.cpp | 157 +++++++++++++++++++++++++++++++++++++++++++++++-- src/r_poly.h | 21 +++++++ 2 files changed, 172 insertions(+), 6 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 978e0a1f4..01097fe22 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -72,6 +72,9 @@ void RenderPolyBsp::Render() else RenderNode(nodes + numnodes - 1); // The head node is the last node output. + static PolySkyDome skydome; + skydome.Render(worldToClip); + // Render back to front (we don't have a zbuffer at the moment, sniff!): if (!r_debug_cull) { @@ -130,8 +133,9 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) AddLine(line, frontsector); } - FTexture *floortex = TexMan(frontsector->GetTexture(sector_t::floor)); - if (floortex->UseType != FTexture::TEX_Null) + FTextureID floorpicnum = frontsector->GetTexture(sector_t::floor); + FTexture *floortex = TexMan(floorpicnum); + if (floortex->UseType != FTexture::TEX_Null && floorpicnum != skyflatnum) { TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); if (!vertices) @@ -154,8 +158,9 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) PolyTriangleDrawer::draw(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, floortex); } - FTexture *ceiltex = TexMan(frontsector->GetTexture(sector_t::ceiling)); - if (ceiltex->UseType != FTexture::TEX_Null) + FTextureID ceilpicnum = frontsector->GetTexture(sector_t::ceiling); + FTexture *ceiltex = TexMan(ceilpicnum); + if (ceiltex->UseType != FTexture::TEX_Null && ceilpicnum != skyflatnum) { TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); if (!vertices) @@ -261,8 +266,8 @@ void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector) double middlefloorz1 = MIN(bottomceilz1, middleceilz1); double middlefloorz2 = MIN(bottomceilz2, middleceilz2); - bool bothSkyCeiling = false;// frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum; - bool bothSkyFloor = false;// frontsector->GetTexture(sector_t::floor) == skyflatnum && backsector->GetTexture(sector_t::floor) == skyflatnum; + bool bothSkyCeiling = frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum; + bool bothSkyFloor = frontsector->GetTexture(sector_t::floor) == skyflatnum && backsector->GetTexture(sector_t::floor) == skyflatnum; if ((topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && !bothSkyCeiling && line->sidedef) { @@ -1290,3 +1295,143 @@ void PolyVertexBuffer::Clear() { NextBufferVertex = 0; } + +///////////////////////////////////////////////////////////////////////////// + +TriVertex PolySkyDome::SetVertex(float xx, float yy, float zz, float uu, float vv) +{ + TriVertex v; + v.x = xx; + v.y = yy; + v.z = zz; + v.w = 1.0f; + v.varying[0] = uu; + v.varying[1] = vv; + return v; +} + +TriVertex PolySkyDome::SetVertexXYZ(float xx, float yy, float zz, float uu, float vv) +{ + TriVertex v; + v.x = xx; + v.y = zz; + v.z = yy; + v.w = 1.0f; + v.varying[0] = uu; + v.varying[1] = vv; + return v; +} + +void PolySkyDome::SkyVertex(int r, int c, bool zflip) +{ + static const FAngle maxSideAngle = 60.f; + static const float scale = 10000.; + + FAngle topAngle = (c / (float)mColumns * 360.f); + FAngle sideAngle = maxSideAngle * (float)(mRows - r) / (float)mRows; + float height = sideAngle.Sin(); + float realRadius = scale * sideAngle.Cos(); + FVector2 pos = topAngle.ToVector(realRadius); + float z = (!zflip) ? scale * height : -scale * height; + + float u, v; + //uint32_t color = r == 0 ? 0xffffff : 0xffffffff; + + // And the texture coordinates. + if (!zflip) // Flipped Y is for the lower hemisphere. + { + u = (-c / (float)mColumns); + v = (r / (float)mRows); + } + else + { + u = (-c / (float)mColumns); + v = 1.0f + ((mRows - r) / (float)mRows); + } + + if (r != 4) z += 300; + + // And finally the vertex. + TriVertex vert; + vert = SetVertexXYZ(-pos.X, z - 1.f, pos.Y, u * 4.0f, v + 0.5f/*, color*/); + mVertices.Push(vert); +} + +void PolySkyDome::CreateSkyHemisphere(bool zflip) +{ + int r, c; + + mPrimStart.Push(mVertices.Size()); + + for (c = 0; c < mColumns; c++) + { + SkyVertex(1, c, zflip); + } + + // The total number of triangles per hemisphere can be calculated + // as follows: rows * columns * 2 + 2 (for the top cap). + for (r = 0; r < mRows; r++) + { + mPrimStart.Push(mVertices.Size()); + for (c = 0; c <= mColumns; c++) + { + SkyVertex(r + zflip, c, zflip); + SkyVertex(r + 1 - zflip, c, zflip); + } + } +} + +void PolySkyDome::CreateDome() +{ + mColumns = 128; + mRows = 4; + CreateSkyHemisphere(false); + CreateSkyHemisphere(true); + mPrimStart.Push(mVertices.Size()); +} + +void PolySkyDome::RenderRow(const TriUniforms &uniforms, FTexture *skytex, int row) +{ + PolyTriangleDrawer::draw(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Strip, false, 0, viewwidth, 0, viewheight, skytex); +} + +void PolySkyDome::RenderCapColorRow(const TriUniforms &uniforms, FTexture *skytex, int row, bool bottomCap) +{ + uint32_t solid = skytex->GetSkyCapColor(bottomCap); + if (!r_swtruecolor) + solid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)]; + PolyTriangleDrawer::fill(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Fan, bottomCap, 0, viewwidth, 0, viewheight, solid); +} + +void PolySkyDome::Render(const TriMatrix &worldToClip) +{ + FTextureID sky1tex, sky2tex; + if ((level.flags & LEVEL_SWAPSKIES) && !(level.flags & LEVEL_DOUBLESKY)) + sky1tex = sky2texture; + else + sky1tex = sky1texture; + sky2tex = sky2texture; + + FTexture *frontskytex = TexMan(sky1tex, true); + FTexture *backskytex = nullptr; + if (level.flags & LEVEL_DOUBLESKY) + backskytex = TexMan(sky2tex, true); + + TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); + + TriUniforms uniforms; + uniforms.objectToClip = worldToClip * objectToWorld; + uniforms.light = 256; + uniforms.flags = 0; + + int rc = mRows + 1; + + RenderCapColorRow(uniforms, frontskytex, 0, false); + RenderCapColorRow(uniforms, frontskytex, rc, true); + + for (int i = 1; i <= mRows; i++) + { + RenderRow(uniforms, frontskytex, i); + RenderRow(uniforms, frontskytex, rc + i); + } +} diff --git a/src/r_poly.h b/src/r_poly.h index 7e26f8ce6..ad5fe7bdb 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -181,3 +181,24 @@ public: static TriVertex *GetVertices(int count); static void Clear(); }; + +class PolySkyDome +{ +public: + PolySkyDome() { CreateDome(); } + void Render(const TriMatrix &worldToClip); + +private: + TArray mVertices; + TArray mPrimStart; + int mRows, mColumns; + + void SkyVertex(int r, int c, bool yflip); + void CreateSkyHemisphere(bool zflip); + void CreateDome(); + void RenderRow(const TriUniforms &uniforms, FTexture *skytex, int row); + void RenderCapColorRow(const TriUniforms &uniforms, FTexture *skytex, int row, bool bottomCap); + + TriVertex SetVertex(float xx, float yy, float zz, float uu = 0, float vv = 0); + TriVertex SetVertexXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0); +}; From b94096ffe193320e81b0f2bb7a58ddf951b53f09 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 10 Nov 2016 05:30:33 +0100 Subject: [PATCH 1190/1509] Crash fixes --- src/r_poly.cpp | 21 ++++++++++++--------- src/r_poly_triangle.cpp | 8 ++++---- src/r_poly_triangle.h | 2 ++ src/r_triangle.cpp | 8 ++++---- src/r_triangle.h | 2 ++ 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 01097fe22..1d63630b3 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -129,7 +129,7 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) for (uint32_t i = 0; i < sub->numlines; i++) { seg_t *line = &sub->firstline[i]; - if (line->sidedef == NULL || !(line->sidedef->Flags & WALLF_POLYOBJ)) + if (line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) AddLine(line, frontsector); } @@ -237,12 +237,15 @@ void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector) if (line->backsector == nullptr) { - wall.SetCoords(line->v1->fPos(), line->v2->fPos(), frontceilz1, frontfloorz1, frontceilz2, frontfloorz2); - wall.TopZ = frontceilz1; - wall.BottomZ = frontfloorz1; - wall.UnpeggedCeil = frontceilz1; - wall.Texpart = side_t::mid; - wall.Render(worldToClip); + if (line->sidedef) + { + wall.SetCoords(line->v1->fPos(), line->v2->fPos(), frontceilz1, frontfloorz1, frontceilz2, frontfloorz2); + wall.TopZ = frontceilz1; + wall.BottomZ = frontfloorz1; + wall.UnpeggedCeil = frontceilz1; + wall.Texpart = side_t::mid; + wall.Render(worldToClip); + } } else { @@ -469,7 +472,7 @@ visstyle_t RenderPolyBsp::GetSpriteVisStyle(AActor *thing, double z) } // get light level - if (fixedcolormap != NULL) + if (fixedcolormap != nullptr) { // fixed map visstyle.BaseColormap = fixedcolormap; visstyle.ColormapNum = 0; @@ -1268,7 +1271,7 @@ void PolyScreenSprite::Render() DTA_FillColor, FillColor, DTA_SpecialColormap, special, DTA_ColorOverlay, overlay.d, - DTA_ColormapStyle, usecolormapstyle ? &colormapstyle : NULL, + DTA_ColormapStyle, usecolormapstyle ? &colormapstyle : nullptr, TAG_DONE); } diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index a9c54bc74..4b599f931 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -127,7 +127,7 @@ TriVertex PolyTriangleDrawer::shade_vertex(const TriUniforms &uniforms, TriVerte void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)) { // Cull, clip and generate additional vertices as needed - TriVertex clippedvert[12]; + TriVertex clippedvert[max_additional_vertices]; int numclipvert; clipedge(vert, clippedvert, numclipvert); @@ -196,7 +196,7 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert // -v.w <= v.z <= v.w // use barycentric weights while clipping vertices - float weights[12 * 3 * 2]; + float weights[max_additional_vertices * 3 * 2]; for (int i = 0; i < 3; i++) { weights[i * 3 + 0] = 0.0f; @@ -220,7 +220,7 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert // Clip against each halfspace float *input = weights; - float *output = weights + 12 * 3; + float *output = weights + max_additional_vertices * 3; int inputverts = 3; int outputverts = 0; for (int p = 0; p < 6; p++) @@ -241,7 +241,7 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert clipdistance[2 * 6 + p] * input[j * 3 + 2]; float t1, t2; - if (!cullhalfspace(clipdistance1, clipdistance2, t1, t2)) + if (!cullhalfspace(clipdistance1, clipdistance2, t1, t2) && outputverts + 1 < max_additional_vertices) { // add t1 vertex for (int k = 0; k < 3; k++) diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 79c8d4a7a..a392c3c3a 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -43,6 +43,8 @@ private: static void queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); + enum { max_additional_vertices = 16 }; + friend class DrawPolyTrianglesCommand; }; diff --git a/src/r_triangle.cpp b/src/r_triangle.cpp index c15817770..ff35cc7da 100644 --- a/src/r_triangle.cpp +++ b/src/r_triangle.cpp @@ -138,7 +138,7 @@ TriVertex TriangleDrawer::shade_vertex(const TriUniforms &uniforms, TriVertex v) void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)) { // Cull, clip and generate additional vertices as needed - TriVertex clippedvert[12]; + TriVertex clippedvert[max_additional_vertices]; int numclipvert; clipedge(vert, clippedvert, numclipvert); @@ -207,7 +207,7 @@ void TriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert, in // -v.w <= v.z <= v.w // use barycentric weights while clipping vertices - float weights[12 * 3 * 2]; + float weights[max_additional_vertices * 3 * 2]; for (int i = 0; i < 3; i++) { weights[i * 3 + 0] = 0.0f; @@ -231,7 +231,7 @@ void TriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert, in // Clip against each halfspace float *input = weights; - float *output = weights + 12 * 3; + float *output = weights + max_additional_vertices * 3; int inputverts = 3; int outputverts = 0; for (int p = 0; p < 6; p++) @@ -252,7 +252,7 @@ void TriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert, in clipdistance[2 * 6 + p] * input[j * 3 + 2]; float t1, t2; - if (!cullhalfspace(clipdistance1, clipdistance2, t1, t2)) + if (!cullhalfspace(clipdistance1, clipdistance2, t1, t2) && outputverts + 1 < max_additional_vertices) { // add t1 vertex for (int k = 0; k < 3; k++) diff --git a/src/r_triangle.h b/src/r_triangle.h index 82b1d2c4d..915f06f59 100644 --- a/src/r_triangle.h +++ b/src/r_triangle.h @@ -106,6 +106,8 @@ private: static void queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); + enum { max_additional_vertices = 16 }; + friend class DrawTrianglesCommand; }; From 204d09efde967be92076cd9795d71a558629b2d2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 10 Nov 2016 08:08:37 +0100 Subject: [PATCH 1191/1509] Add a stencil buffer --- src/r_main.cpp | 2 +- src/r_poly.cpp | 12 ++--- src/r_poly.h | 44 +++++++++-------- src/r_poly_triangle.h | 111 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+), 28 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index 25945012f..149353a87 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -922,7 +922,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) } else { - RenderPolyBsp bsp; + static RenderPolyBsp bsp; bsp.Render(); } R_3D_ResetClip(); // reset clips (floor/ceiling) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 1d63630b3..1cfe5c085 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -41,15 +41,19 @@ CVAR(Bool, r_debug_cull, 0, 0) void RenderPolyBsp::Render() { + // Setup working buffers PolyVertexBuffer::Clear(); SolidSegments.clear(); SolidSegments.reserve(MAXWIDTH / 2 + 2); SolidSegments.push_back({ -0x7fff, 0 }); SolidSegments.push_back({ viewwidth, 0x7fff }); - SectorSpriteRanges.clear(); SectorSpriteRanges.resize(numsectors); SortedSprites.clear(); + PvsSectors.clear(); + SectorSpriteRanges.clear(); + ScreenSprites.clear(); + PolyStencilBuffer::Instance()->Clear(viewwidth, viewheight, 0); // Perspective correct: float ratio = WidescreenRatio; @@ -66,13 +70,12 @@ void RenderPolyBsp::Render() // Y shearing like the Doom renderer: //worldToClip = TriMatrix::viewToClip() * TriMatrix::worldToView(); - // Cull front to back (ok, so we dont cull yet, but we should during this!): + // Cull front to back if (numnodes == 0) PvsSectors.push_back(subsectors); // RenderSubsector(subsectors); else RenderNode(nodes + numnodes - 1); // The head node is the last node output. - static PolySkyDome skydome; skydome.Render(worldToClip); // Render back to front (we don't have a zbuffer at the moment, sniff!): @@ -227,9 +230,6 @@ void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector) double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2); double frontfloorz2 = frontsector->floorplane.ZatPoint(line->v2); - //VisiblePlaneKey ceilingPlaneKey(frontsector->GetTexture(sector_t::ceiling), frontsector->ColorMap, frontsector->lightlevel, frontsector->ceilingplane, frontsector->planes[sector_t::ceiling].xform); - //VisiblePlaneKey floorPlaneKey(frontsector->GetTexture(sector_t::floor), frontsector->ColorMap, frontsector->lightlevel, frontsector->floorplane, frontsector->planes[sector_t::floor].xform); - RenderPolyWall wall; wall.Line = line; wall.Colormap = frontsector->ColorMap; diff --git a/src/r_poly.h b/src/r_poly.h index ad5fe7bdb..36cddfa30 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -69,6 +69,27 @@ public: int Count = 0; }; +class PolySkyDome +{ +public: + PolySkyDome() { CreateDome(); } + void Render(const TriMatrix &worldToClip); + +private: + TArray mVertices; + TArray mPrimStart; + int mRows, mColumns; + + void SkyVertex(int r, int c, bool yflip); + void CreateSkyHemisphere(bool zflip); + void CreateDome(); + void RenderRow(const TriUniforms &uniforms, FTexture *skytex, int row); + void RenderCapColorRow(const TriUniforms &uniforms, FTexture *skytex, int row, bool bottomCap); + + TriVertex SetVertex(float xx, float yy, float zz, float uu = 0, float vv = 0); + TriVertex SetVertexXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0); +}; + // Renders a GL BSP tree in a scene class RenderPolyBsp { @@ -121,6 +142,8 @@ private: }; std::vector SolidSegments; + + PolySkyDome skydome; }; class RenderPolyWall @@ -181,24 +204,3 @@ public: static TriVertex *GetVertices(int count); static void Clear(); }; - -class PolySkyDome -{ -public: - PolySkyDome() { CreateDome(); } - void Render(const TriMatrix &worldToClip); - -private: - TArray mVertices; - TArray mPrimStart; - int mRows, mColumns; - - void SkyVertex(int r, int c, bool yflip); - void CreateSkyHemisphere(bool zflip); - void CreateDome(); - void RenderRow(const TriUniforms &uniforms, FTexture *skytex, int row); - void RenderCapColorRow(const TriUniforms &uniforms, FTexture *skytex, int row, bool bottomCap); - - TriVertex SetVertex(float xx, float yy, float zz, float uu = 0, float vv = 0); - TriVertex SetVertexXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0); -}; diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index a392c3c3a..f18361caa 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -48,6 +48,117 @@ private: friend class DrawPolyTrianglesCommand; }; +// 8x8 block of stencil values, plus a mask indicating if values are the same for early out stencil testing +class PolyStencilBlock +{ +public: + PolyStencilBlock(int block, uint8_t *values, uint32_t *masks) : Values(values + block * 64), ValueMask(masks[block]) + { + } + + void Set(int x, int y, uint8_t value) + { + if (ValueMask == 0xffffffff) + { + if (Values[0] == value) + return; + + for (int i = 1; i < 8 * 8 + 4 * 4 + 2 * 2 + 1; i++) + Values[i] = Values[0]; + } + + if (Values[x + y * 8] == value) + return; + + Values[x + y * 8] = value; + + int leveloffset = 0; + for (int i = 1; i < 4; i++) + { + int iy = i + 3; + + x >>= 1; + y >>= 1; + + bool same = + Values[(x << i) + (y << iy)] != value || + Values[((x + 1) << i) + (y << iy)] != value || + Values[(x << i) + ((y + 1) << iy)] != value || + Values[((x + 1) << i) + ((y + 1) << iy)] != value; + + int levelbit = 1 << (leveloffset + x + y * (8 >> i)); + + if (same) + ValueMask = ValueMask & ~levelbit; + else + ValueMask = ValueMask | levelbit; + } + + if (Values[0] != value || Values[4] != value || Values[4 * 8] != value || Values[4 * 8 + 4] != value) + ValueMask = ValueMask & ~(1 << 22); + else + ValueMask = ValueMask | (1 << 22); + } + + uint8_t Get(int x, int y) const + { + if (ValueMask == 0xffffffff) + return Values[0]; + else + return Values[x + y * 8]; + } + + void Clear(uint8_t value) + { + Values[0] = value; + ValueMask = 0xffffffff; + } + +private: + uint8_t *Values; // [8 * 8]; + uint32_t &ValueMask; // 4 * 4 + 2 * 2 + 1 bits indicating is Values are the same +}; + +class PolyStencilBuffer +{ +public: + static PolyStencilBuffer *Instance() + { + static PolyStencilBuffer buffer; + return &buffer; + } + + void Clear(int newwidth, int newheight, uint8_t stencil_value = 0) + { + width = newwidth; + height = newheight; + int count = BlockWidth() * BlockHeight(); + values.resize(count * 64); + masks.resize(count); + + uint8_t *v = Values(); + uint32_t *m = Masks(); + for (int i = 0; i < count; i++) + { + PolyStencilBlock block(i, v, m); + block.Clear(stencil_value); + } + } + + int Width() const { return width; } + int Height() const { return height; } + int BlockWidth() const { return (width + 7) / 8; } + int BlockHeight() const { return (height + 7) / 8; } + uint8_t *Values() { return values.data(); } + uint32_t *Masks() { return masks.data(); } + +private: + int width; + int height; + std::vector values; + std::vector masks; +}; + struct ScreenPolyTriangleDrawerArgs { uint8_t *dest; From 049ceecca51d77f866964fa5a574ca4fe66ce3e2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 10 Nov 2016 10:44:35 +0100 Subject: [PATCH 1192/1509] Toying with stencils --- src/r_poly.cpp | 42 +++++--- src/r_poly.h | 1 + src/r_poly_triangle.cpp | 230 ++++++++++++++++++++++++++++++++++++---- src/r_poly_triangle.h | 37 +++++-- 4 files changed, 262 insertions(+), 48 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 1cfe5c085..473e51c4d 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -51,7 +51,6 @@ void RenderPolyBsp::Render() SectorSpriteRanges.resize(numsectors); SortedSprites.clear(); PvsSectors.clear(); - SectorSpriteRanges.clear(); ScreenSprites.clear(); PolyStencilBuffer::Instance()->Clear(viewwidth, viewheight, 0); @@ -76,10 +75,8 @@ void RenderPolyBsp::Render() else RenderNode(nodes + numnodes - 1); // The head node is the last node output. - skydome.Render(worldToClip); - - // Render back to front (we don't have a zbuffer at the moment, sniff!): - if (!r_debug_cull) + // Render front to back using the stencil buffer + if (r_debug_cull) { for (auto it = PvsSectors.rbegin(); it != PvsSectors.rend(); ++it) RenderSubsector(*it); @@ -90,6 +87,8 @@ void RenderPolyBsp::Render() RenderSubsector(*it); } + skydome.Render(worldToClip); + RenderPlayerSprites(); DrawerCommandQueue::WaitForWorkers(); RenderScreenSprites(); // To do: should be called by FSoftwareRenderer::DrawRemainingPlayerSprites instead of here @@ -138,7 +137,7 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) FTextureID floorpicnum = frontsector->GetTexture(sector_t::floor); FTexture *floortex = TexMan(floorpicnum); - if (floortex->UseType != FTexture::TEX_Null && floorpicnum != skyflatnum) + if (floortex->UseType != FTexture::TEX_Null) { TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); if (!vertices) @@ -158,12 +157,16 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) else if (fixedcolormap) uniforms.light = 256; uniforms.flags = 0; - PolyTriangleDrawer::draw(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, floortex); + + bool isSky = floorpicnum == skyflatnum; + if (!isSky) + PolyTriangleDrawer::draw(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, floortex, 0); + PolyTriangleDrawer::stencil(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, isSky ? 255 : 254); } FTextureID ceilpicnum = frontsector->GetTexture(sector_t::ceiling); FTexture *ceiltex = TexMan(ceilpicnum); - if (ceiltex->UseType != FTexture::TEX_Null && ceilpicnum != skyflatnum) + if (ceiltex->UseType != FTexture::TEX_Null) { TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); if (!vertices) @@ -183,7 +186,11 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) else if (fixedcolormap) uniforms.light = 256; uniforms.flags = 0; - PolyTriangleDrawer::draw(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, ceiltex); + + bool isSky = ceilpicnum == skyflatnum; + if (!isSky) + PolyTriangleDrawer::draw(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, ceiltex, 0); + PolyTriangleDrawer::stencil(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, isSky ? 255 : 254); } SpriteRange sprites = GetSpritesForSector(sub->sector); @@ -272,23 +279,25 @@ void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector) bool bothSkyCeiling = frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum; bool bothSkyFloor = frontsector->GetTexture(sector_t::floor) == skyflatnum && backsector->GetTexture(sector_t::floor) == skyflatnum; - if ((topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && !bothSkyCeiling && line->sidedef) + if ((topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && line->sidedef) { wall.SetCoords(line->v1->fPos(), line->v2->fPos(), topceilz1, topfloorz1, topceilz2, topfloorz2); wall.TopZ = topceilz1; wall.BottomZ = topfloorz1; wall.UnpeggedCeil = topceilz1; wall.Texpart = side_t::top; + wall.IsSky = bothSkyCeiling; wall.Render(worldToClip); } - if ((bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && !bothSkyFloor && line->sidedef) + if ((bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && line->sidedef) { wall.SetCoords(line->v1->fPos(), line->v2->fPos(), bottomceilz1, bottomfloorz2, bottomceilz2, bottomfloorz2); wall.TopZ = bottomceilz1; wall.BottomZ = bottomfloorz2; wall.UnpeggedCeil = topceilz1; wall.Texpart = side_t::bottom; + wall.IsSky = bothSkyFloor; wall.Render(worldToClip); } @@ -419,7 +428,7 @@ void RenderPolyBsp::AddSprite(AActor *thing, subsector_t *sub) uniforms.objectToClip = worldToClip; uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f); uniforms.flags = 0; - PolyTriangleDrawer::draw(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex); + PolyTriangleDrawer::draw(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex, 254); } void RenderPolyBsp::AddWallSprite(AActor *thing, subsector_t *sub) @@ -1067,7 +1076,10 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) uniforms.objectToClip = worldToClip; uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f); uniforms.flags = 0; - PolyTriangleDrawer::draw(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex); + + if (!IsSky) + PolyTriangleDrawer::draw(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex, 0); + PolyTriangleDrawer::stencil(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, IsSky ? 255 : 254); } FTexture *RenderPolyWall::GetTexture() @@ -1395,7 +1407,7 @@ void PolySkyDome::CreateDome() void PolySkyDome::RenderRow(const TriUniforms &uniforms, FTexture *skytex, int row) { - PolyTriangleDrawer::draw(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Strip, false, 0, viewwidth, 0, viewheight, skytex); + PolyTriangleDrawer::draw(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Strip, false, 0, viewwidth, 0, viewheight, skytex, 255); } void PolySkyDome::RenderCapColorRow(const TriUniforms &uniforms, FTexture *skytex, int row, bool bottomCap) @@ -1403,7 +1415,7 @@ void PolySkyDome::RenderCapColorRow(const TriUniforms &uniforms, FTexture *skyte uint32_t solid = skytex->GetSkyCapColor(bottomCap); if (!r_swtruecolor) solid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)]; - PolyTriangleDrawer::fill(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Fan, bottomCap, 0, viewwidth, 0, viewheight, solid); + PolyTriangleDrawer::fill(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Fan, bottomCap, 0, viewwidth, 0, viewheight, solid, 255); } void PolySkyDome::Render(const TriMatrix &worldToClip) diff --git a/src/r_poly.h b/src/r_poly.h index 36cddfa30..d4af108e2 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -175,6 +175,7 @@ public: double UnpeggedCeil = 0.0; FSWColormap *Colormap = nullptr; bool Masked = false; + bool IsSky = false; private: FTexture *GetTexture(); diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 4b599f931..7fb9aafa4 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -40,31 +40,39 @@ #include #endif -void PolyTriangleDrawer::draw(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, FTexture *texture) +void PolyTriangleDrawer::draw(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, FTexture *texture, int stenciltestvalue) { if (r_swtruecolor) - queue_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, (const uint8_t*)texture->GetPixelsBgra(), texture->GetWidth(), texture->GetHeight(), 0); + queue_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, (const uint8_t*)texture->GetPixelsBgra(), texture->GetWidth(), texture->GetHeight(), 0, stenciltestvalue, stenciltestvalue); else - draw_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texture->GetPixels(), texture->GetWidth(), texture->GetHeight(), 0, nullptr, &ScreenPolyTriangleDrawer::draw); + draw_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texture->GetPixels(), texture->GetWidth(), texture->GetHeight(), 0, stenciltestvalue, stenciltestvalue, nullptr, &ScreenPolyTriangleDrawer::draw); } -void PolyTriangleDrawer::fill(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int solidcolor) +void PolyTriangleDrawer::fill(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int solidcolor, int stenciltestvalue) { if (r_swtruecolor) - queue_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor); + queue_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor, stenciltestvalue, stenciltestvalue); else - draw_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor, nullptr, &ScreenPolyTriangleDrawer::fill); + draw_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor, stenciltestvalue, stenciltestvalue, nullptr, &ScreenPolyTriangleDrawer::fill); } -void PolyTriangleDrawer::queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) +void PolyTriangleDrawer::stencil(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int stenciltestvalue, int stencilwritevalue) +{ + if (r_swtruecolor) + queue_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, 0xbeef, stenciltestvalue, stencilwritevalue); + else + draw_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, 0, stenciltestvalue, stencilwritevalue, nullptr, &ScreenPolyTriangleDrawer::stencil); +} + +void PolyTriangleDrawer::queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, int stenciltestvalue, int stencilwritevalue) { if (clipright < clipleft || clipleft < 0 || clipright > MAXWIDTH || clipbottom < cliptop || cliptop < 0 || clipbottom > MAXHEIGHT) return; - DrawerCommandQueue::QueueCommand(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texturePixels, textureWidth, textureHeight, solidcolor); + DrawerCommandQueue::QueueCommand(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texturePixels, textureWidth, textureHeight, solidcolor, stenciltestvalue, stencilwritevalue); } -void PolyTriangleDrawer::draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)) +void PolyTriangleDrawer::draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, int stenciltestvalue, int stencilwritevalue, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)) { if (vcount < 3) return; @@ -81,6 +89,11 @@ void PolyTriangleDrawer::draw_arrays(const TriUniforms &uniforms, const TriVerte args.textureHeight = textureHeight; args.solidcolor = solidcolor; args.uniforms = &uniforms; + args.stencilTestValue = stenciltestvalue; + args.stencilWriteValue = stencilwritevalue; + args.stencilPitch = PolyStencilBuffer::Instance()->BlockWidth(); + args.stencilValues = PolyStencilBuffer::Instance()->Values(); + args.stencilMasks = PolyStencilBuffer::Instance()->Masks(); TriVertex vert[3]; if (mode == TriangleDrawMode::Normal) @@ -677,6 +690,158 @@ void ScreenPolyTriangleDrawer::fill(const ScreenPolyTriangleDrawerArgs *args, Dr } } +void ScreenPolyTriangleDrawer::stencil(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread) +{ + const TriVertex &v1 = *args->v1; + const TriVertex &v2 = *args->v2; + const TriVertex &v3 = *args->v3; + int clipleft = args->clipleft; + int clipright = args->clipright; + int cliptop = args->cliptop; + int clipbottom = args->clipbottom; + int solidcolor = args->solidcolor; + uint8_t *stencilValues = args->stencilValues; + uint32_t *stencilMasks = args->stencilMasks; + int stencilPitch = args->stencilPitch; + uint8_t stencilTestValue = args->stencilTestValue; + uint8_t stencilWriteValue = args->stencilWriteValue; + + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, cliptop); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); + if (minx >= maxx || miny >= maxy) + return; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // Loop through blocks + for (int y = miny; y < maxy; y += q) + { + // Is this row of blocks done by this thread? + if (thread && thread->skipped_by_thread(y / q)) continue; + + for (int x = minx; x < maxx; x += q) + { + // Corners of block + int x0 = x << 4; + int x1 = (x + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; + bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; + bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; + bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; + int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); + + bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; + bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; + bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; + bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; + int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); + + bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; + bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; + bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; + bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; + int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + + // Skip block when outside an edge + if (a == 0x0 || b == 0x0 || c == 0x0) continue; + + // Check if block needs clipping + bool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); + + PolyStencilBlock stencil(x / 8 + y / 8 * stencilPitch, stencilValues, stencilMasks); + + // Accept whole block when totally covered + if (a == 0xF && b == 0xF && c == 0xF && !clipneeded && stencil.IsSingleValue()) + { + // Reject whole block if the stencil test fails + if (stencil.Get(0, 0) != stencilTestValue) + continue; + stencil.Clear(stencilWriteValue); + } + else // Partially covered block + { + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; + + for (int iy = 0; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + for (int ix = 0; ix < q; ix++) + { + bool visible = (ix + x >= clipleft) && (ix + x < clipright) && (cliptop <= y + iy) && (clipbottom > y + iy); + + if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible && stencil.Get(ix, iy) == stencilTestValue) + { + stencil.Set(ix, iy, stencilWriteValue); + } + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + } + } + } + } +} + void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread) { uint32_t *dest = (uint32_t *)args->dest; @@ -692,6 +857,10 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, int textureWidth = args->textureWidth; int textureHeight = args->textureHeight; uint32_t light = args->uniforms->light; + uint8_t *stencilValues = args->stencilValues; + uint32_t *stencilMasks = args->stencilMasks; + int stencilPitch = args->stencilPitch; + uint8_t stencilTestValue = args->stencilTestValue; // 28.4 fixed-point coordinates const int Y1 = (int)round(16.0f * v1.y); @@ -831,9 +1000,15 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, uint32_t *buffer = dest; + PolyStencilBlock stencil(x / 8 + y / 8 * stencilPitch, stencilValues, stencilMasks); + // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && !clipneeded) + if (a == 0xF && b == 0xF && c == 0xF && !clipneeded && stencil.IsSingleValue()) { + // Reject whole block if the stencil test fails + if (stencil.Get(0, 0) != stencilTestValue) + continue; + for (int iy = 0; iy < q; iy++) { uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; @@ -922,11 +1097,11 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, varyingStep[i] = (uint32_t)(step * 0x100000000LL); } - for (int ix = x; ix < x + q; ix++) + for (int ix = 0; ix < q; ix++) { - bool visible = ix >= clipleft && ix < clipright && (cliptop <= y + iy) && (clipbottom > y + iy); + bool visible = (ix + x >= clipleft) && (ix + x < clipright) && (cliptop <= y + iy) && (clipbottom > y + iy); - if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) + if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible && stencil.Get(ix, iy) == stencilTestValue) { uint32_t ufrac = varying[0]; uint32_t vfrac = varying[1]; @@ -942,7 +1117,7 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, uint32_t fg_alpha = APART(fg); if (fg_alpha > 127) - buffer[ix] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; + buffer[ix + x] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; } for (int i = 0; i < TriVertex::NumVarying; i++) @@ -976,6 +1151,10 @@ void ScreenPolyTriangleDrawer::fill32(const ScreenPolyTriangleDrawerArgs *args, int cliptop = args->cliptop; int clipbottom = args->clipbottom; int solidcolor = args->solidcolor; + uint8_t *stencilValues = args->stencilValues; + uint32_t *stencilMasks = args->stencilMasks; + int stencilPitch = args->stencilPitch; + uint8_t stencilTestValue = args->stencilTestValue; // 28.4 fixed-point coordinates const int Y1 = (int)round(16.0f * v1.y); @@ -1072,9 +1251,15 @@ void ScreenPolyTriangleDrawer::fill32(const ScreenPolyTriangleDrawerArgs *args, uint32_t *buffer = dest; + PolyStencilBlock stencil(x / 8 + y / 8 * stencilPitch, stencilValues, stencilMasks); + // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && !clipneeded) + if (a == 0xF && b == 0xF && c == 0xF && !clipneeded && stencil.IsSingleValue()) { + // Reject whole block if the stencil test fails + if (stencil.Get(0, 0) != stencilTestValue) + continue; + for (int iy = 0; iy < q; iy++) { for (int ix = x; ix < x + q; ix++) @@ -1097,13 +1282,13 @@ void ScreenPolyTriangleDrawer::fill32(const ScreenPolyTriangleDrawerArgs *args, int CX2 = CY2; int CX3 = CY3; - for (int ix = x; ix < x + q; ix++) + for (int ix = 0; ix < q; ix++) { - bool visible = ix >= clipleft && ix < clipright && (cliptop <= y + iy) && (clipbottom > y + iy); + bool visible = (ix + x >= clipleft) && (ix + x < clipright) && (cliptop <= y + iy) && (clipbottom > y + iy); - if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) + if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible && stencil.Get(ix, iy) == stencilTestValue) { - buffer[ix] = solidcolor; + buffer[ix + x] = solidcolor; } CX1 -= FDY12; @@ -1138,8 +1323,8 @@ float ScreenPolyTriangleDrawer::grady(float x0, float y0, float x1, float y1, fl ///////////////////////////////////////////////////////////////////////////// -DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) - : uniforms(uniforms), vinput(vinput), vcount(vcount), mode(mode), ccw(ccw), clipleft(clipleft), clipright(clipright), cliptop(cliptop), clipbottom(clipbottom), texturePixels(texturePixels), textureWidth(textureWidth), textureHeight(textureHeight), solidcolor(solidcolor) +DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, int stenciltestvalue, int stencilwritevalue) + : uniforms(uniforms), vinput(vinput), vcount(vcount), mode(mode), ccw(ccw), clipleft(clipleft), clipright(clipright), cliptop(cliptop), clipbottom(clipbottom), texturePixels(texturePixels), textureWidth(textureWidth), textureHeight(textureHeight), solidcolor(solidcolor), stenciltestvalue(stenciltestvalue), stencilwritevalue(stencilwritevalue) { } @@ -1149,7 +1334,8 @@ void DrawPolyTrianglesCommand::Execute(DrawerThread *thread) uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texturePixels, textureWidth, textureHeight, solidcolor, - thread, texturePixels ? ScreenPolyTriangleDrawer::draw32 : ScreenPolyTriangleDrawer::fill32); + stenciltestvalue, stencilwritevalue, + thread, texturePixels ? ScreenPolyTriangleDrawer::draw32 : solidcolor != 0xbeef ? ScreenPolyTriangleDrawer::fill32 : ScreenPolyTriangleDrawer::stencil); } FString DrawPolyTrianglesCommand::DebugInfo() diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index f18361caa..931300169 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -31,17 +31,18 @@ struct ScreenPolyTriangleDrawerArgs; class PolyTriangleDrawer { public: - static void draw(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, FTexture *texture); - static void fill(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int solidcolor); + static void draw(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, FTexture *texture, int stenciltestvalue); + static void fill(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int solidcolor, int stenciltestvalue); + static void stencil(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int stenciltestvalue, int stencilwritevalue); private: static TriVertex shade_vertex(const TriUniforms &uniforms, TriVertex v); - static void draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)); + static void draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, int stenciltestvalue, int stencilwritevalue, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)); static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert); - static void queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); + static void queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, int stenciltestvalue, int stencilwritevalue); enum { max_additional_vertices = 16 }; @@ -75,16 +76,14 @@ public: int leveloffset = 0; for (int i = 1; i < 4; i++) { - int iy = i + 3; - x >>= 1; y >>= 1; bool same = - Values[(x << i) + (y << iy)] != value || - Values[((x + 1) << i) + (y << iy)] != value || - Values[(x << i) + ((y + 1) << iy)] != value || - Values[((x + 1) << i) + ((y + 1) << iy)] != value; + Values[(x << i) + (y << i) * 8] != value || + Values[((x + 1) << i) + (y << i) * 8] != value || + Values[(x << i) + ((y + 1) << i) * 8] != value || + Values[((x + 1) << i) + ((y + 1) << i) * 8] != value; int levelbit = 1 << (leveloffset + x + y * (8 >> i)); @@ -92,6 +91,8 @@ public: ValueMask = ValueMask & ~levelbit; else ValueMask = ValueMask | levelbit; + + leveloffset += (8 >> leveloffset) * (8 >> leveloffset); } if (Values[0] != value || Values[4] != value || Values[4 * 8] != value || Values[4 * 8 + 4] != value) @@ -114,6 +115,11 @@ public: ValueMask = 0xffffffff; } + bool IsSingleValue() const + { + return ValueMask == 0xffffffff; + } + private: uint8_t *Values; // [8 * 8]; uint32_t &ValueMask; // 4 * 4 + 2 * 2 + 1 bits indicating is Values are the same @@ -175,6 +181,11 @@ struct ScreenPolyTriangleDrawerArgs int textureHeight; int solidcolor; const TriUniforms *uniforms; + uint8_t *stencilValues; + uint32_t *stencilMasks; + int stencilPitch; + uint8_t stencilTestValue; + uint8_t stencilWriteValue; }; class ScreenPolyTriangleDrawer @@ -183,6 +194,8 @@ public: static void draw(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); static void fill(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); + static void stencil(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); + static void draw32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); static void fill32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); @@ -194,7 +207,7 @@ private: class DrawPolyTrianglesCommand : public DrawerCommand { public: - DrawPolyTrianglesCommand(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); + DrawPolyTrianglesCommand(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, int stenciltestvalue, int stencilwritevalue); void Execute(DrawerThread *thread) override; FString DebugInfo() override; @@ -213,6 +226,8 @@ private: int textureWidth; int textureHeight; int solidcolor; + int stenciltestvalue; + int stencilwritevalue; }; #endif From 373038231c371b8090b5b0685daac535c3e5cf66 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 10 Nov 2016 13:58:03 +0100 Subject: [PATCH 1193/1509] More stencil sky stuff --- src/r_poly.cpp | 55 ++++++++++++++++++++++++++++------------- src/r_poly.h | 11 ++++++--- src/r_poly_triangle.cpp | 1 + src/r_poly_triangle.h | 27 ++++++++++++++++++++ src/r_triangle.h | 1 + 5 files changed, 75 insertions(+), 20 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 473e51c4d..a1da1f6ab 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -53,6 +53,8 @@ void RenderPolyBsp::Render() PvsSectors.clear(); ScreenSprites.clear(); PolyStencilBuffer::Instance()->Clear(viewwidth, viewheight, 0); + PolySubsectorGBuffer::Instance()->Resize(dc_pitch, viewheight); + NextSubsectorDepth = 0; // Perspective correct: float ratio = WidescreenRatio; @@ -75,7 +77,7 @@ void RenderPolyBsp::Render() else RenderNode(nodes + numnodes - 1); // The head node is the last node output. - // Render front to back using the stencil buffer + // Render front to back if (r_debug_cull) { for (auto it = PvsSectors.rbegin(); it != PvsSectors.rend(); ++it) @@ -128,17 +130,21 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) sector_t *frontsector = sub->sector; frontsector->MoreFlags |= SECF_DRAWN; + uint32_t subsectorDepth = NextSubsectorDepth++; + for (uint32_t i = 0; i < sub->numlines; i++) { seg_t *line = &sub->firstline[i]; if (line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) - AddLine(line, frontsector); + AddLine(line, frontsector, subsectorDepth); } FTextureID floorpicnum = frontsector->GetTexture(sector_t::floor); FTexture *floortex = TexMan(floorpicnum); if (floortex->UseType != FTexture::TEX_Null) { + bool isSky = floorpicnum == skyflatnum; + TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); if (!vertices) return; @@ -157,17 +163,22 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) else if (fixedcolormap) uniforms.light = 256; uniforms.flags = 0; - - bool isSky = floorpicnum == skyflatnum; + uniforms.subsectorDepth = isSky ? SkySubsectorDepth : subsectorDepth; if (!isSky) + { PolyTriangleDrawer::draw(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, floortex, 0); - PolyTriangleDrawer::stencil(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, isSky ? 255 : 254); + PolyTriangleDrawer::stencil(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 1); + } + else + PolyTriangleDrawer::fill(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 0); } FTextureID ceilpicnum = frontsector->GetTexture(sector_t::ceiling); FTexture *ceiltex = TexMan(ceilpicnum); if (ceiltex->UseType != FTexture::TEX_Null) { + bool isSky = ceilpicnum == skyflatnum; + TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); if (!vertices) return; @@ -186,11 +197,14 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) else if (fixedcolormap) uniforms.light = 256; uniforms.flags = 0; - - bool isSky = ceilpicnum == skyflatnum; + uniforms.subsectorDepth = isSky ? SkySubsectorDepth : subsectorDepth; if (!isSky) + { PolyTriangleDrawer::draw(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, ceiltex, 0); - PolyTriangleDrawer::stencil(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, isSky ? 255 : 254); + PolyTriangleDrawer::stencil(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 1); + } + else + PolyTriangleDrawer::fill(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 0); } SpriteRange sprites = GetSpritesForSector(sub->sector); @@ -198,9 +212,9 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) { AActor *thing = SortedSprites[sprites.Start + i].Thing; if ((thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) - AddWallSprite(thing, sub); + AddWallSprite(thing, sub, subsectorDepth); else - AddSprite(thing, sub); + AddSprite(thing, sub, subsectorDepth); } } @@ -224,7 +238,7 @@ SpriteRange RenderPolyBsp::GetSpritesForSector(sector_t *sector) return range; } -void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector) +void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector, uint32_t subsectorDepth) { // Reject lines not facing viewer DVector2 pt1 = line->v1->fPos() - ViewPos; @@ -241,6 +255,7 @@ void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector) wall.Line = line; wall.Colormap = frontsector->ColorMap; wall.Masked = false; + wall.SubsectorDepth = subsectorDepth; if (line->backsector == nullptr) { @@ -341,7 +356,7 @@ bool RenderPolyBsp::IsThingCulled(AActor *thing) return false; } -void RenderPolyBsp::AddSprite(AActor *thing, subsector_t *sub) +void RenderPolyBsp::AddSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) { if (IsThingCulled(thing)) return; @@ -428,10 +443,11 @@ void RenderPolyBsp::AddSprite(AActor *thing, subsector_t *sub) uniforms.objectToClip = worldToClip; uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f); uniforms.flags = 0; - PolyTriangleDrawer::draw(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex, 254); + uniforms.subsectorDepth = subsectorDepth; + PolyTriangleDrawer::draw(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex, 0); } -void RenderPolyBsp::AddWallSprite(AActor *thing, subsector_t *sub) +void RenderPolyBsp::AddWallSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) { if (IsThingCulled(thing)) return; @@ -1076,10 +1092,15 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) uniforms.objectToClip = worldToClip; uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f); uniforms.flags = 0; + uniforms.subsectorDepth = IsSky ? RenderPolyBsp::SkySubsectorDepth : SubsectorDepth; if (!IsSky) + { PolyTriangleDrawer::draw(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex, 0); - PolyTriangleDrawer::stencil(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, IsSky ? 255 : 254); + PolyTriangleDrawer::stencil(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 1); + } + else + PolyTriangleDrawer::fill(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 0); } FTexture *RenderPolyWall::GetTexture() @@ -1407,7 +1428,7 @@ void PolySkyDome::CreateDome() void PolySkyDome::RenderRow(const TriUniforms &uniforms, FTexture *skytex, int row) { - PolyTriangleDrawer::draw(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Strip, false, 0, viewwidth, 0, viewheight, skytex, 255); + PolyTriangleDrawer::draw(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Strip, false, 0, viewwidth, 0, viewheight, skytex, 0); } void PolySkyDome::RenderCapColorRow(const TriUniforms &uniforms, FTexture *skytex, int row, bool bottomCap) @@ -1415,7 +1436,7 @@ void PolySkyDome::RenderCapColorRow(const TriUniforms &uniforms, FTexture *skyte uint32_t solid = skytex->GetSkyCapColor(bottomCap); if (!r_swtruecolor) solid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)]; - PolyTriangleDrawer::fill(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Fan, bottomCap, 0, viewwidth, 0, viewheight, solid, 255); + PolyTriangleDrawer::fill(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Fan, bottomCap, 0, viewwidth, 0, viewheight, solid, 0); } void PolySkyDome::Render(const TriMatrix &worldToClip) diff --git a/src/r_poly.h b/src/r_poly.h index d4af108e2..c312f313b 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -97,14 +97,16 @@ public: void Render(); void RenderScreenSprites(); + static const uint32_t SkySubsectorDepth = 0xffffffff; + private: void RenderNode(void *node); void RenderSubsector(subsector_t *sub); - void AddLine(seg_t *line, sector_t *frontsector); + void AddLine(seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); TriVertex PlaneVertex(vertex_t *v1, sector_t *sector, const secplane_t &plane); - void AddSprite(AActor *thing, subsector_t *sub); - void AddWallSprite(AActor *thing, subsector_t *sub); + void AddSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth); + void AddWallSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth); bool IsThingCulled(AActor *thing); visstyle_t GetSpriteVisStyle(AActor *thing, double z); FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); @@ -125,6 +127,8 @@ private: bool IsSegmentCulled(int x1, int x2) const; std::vector PvsSectors; + uint32_t NextSubsectorDepth = 0; + TriMatrix worldToClip; std::vector SectorSpriteRanges; @@ -176,6 +180,7 @@ public: FSWColormap *Colormap = nullptr; bool Masked = false; bool IsSky = false; + uint32_t SubsectorDepth = 0; private: FTexture *GetTexture(); diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 7fb9aafa4..57165736d 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -94,6 +94,7 @@ void PolyTriangleDrawer::draw_arrays(const TriUniforms &uniforms, const TriVerte args.stencilPitch = PolyStencilBuffer::Instance()->BlockWidth(); args.stencilValues = PolyStencilBuffer::Instance()->Values(); args.stencilMasks = PolyStencilBuffer::Instance()->Masks(); + args.subsectorGBuffer = PolySubsectorGBuffer::Instance()->Values(); TriVertex vert[3]; if (mode == TriangleDrawMode::Normal) diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 931300169..b0b22f8d0 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -125,6 +125,32 @@ private: uint32_t &ValueMask; // 4 * 4 + 2 * 2 + 1 bits indicating is Values are the same }; +class PolySubsectorGBuffer +{ +public: + static PolySubsectorGBuffer *Instance() + { + static PolySubsectorGBuffer buffer; + return &buffer; + } + + void Resize(int newwidth, int newheight) + { + width = newwidth; + height = newheight; + values.resize(width * height); + } + + int Width() const { return width; } + int Height() const { return height; } + uint32_t *Values() { return values.data(); } + +private: + int width; + int height; + std::vector values; +}; + class PolyStencilBuffer { public: @@ -186,6 +212,7 @@ struct ScreenPolyTriangleDrawerArgs int stencilPitch; uint8_t stencilTestValue; uint8_t stencilWriteValue; + uint32_t *subsectorGBuffer; }; class ScreenPolyTriangleDrawer diff --git a/src/r_triangle.h b/src/r_triangle.h index 915f06f59..a3bdca5ed 100644 --- a/src/r_triangle.h +++ b/src/r_triangle.h @@ -63,6 +63,7 @@ struct TriMatrix struct TriUniforms { uint32_t light; + uint32_t subsectorDepth; uint16_t light_alpha; uint16_t light_red; From 529a93b680cc7fda4a5116d2c23e0320d6fc1279 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 11 Nov 2016 10:15:27 +0100 Subject: [PATCH 1194/1509] Sky rendering fixes --- src/r_poly.cpp | 284 +++++++++++++++++++++++++++++++------------------ src/r_poly.h | 6 +- 2 files changed, 185 insertions(+), 105 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index a1da1f6ab..a58cb86a5 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -73,9 +73,17 @@ void RenderPolyBsp::Render() // Cull front to back if (numnodes == 0) - PvsSectors.push_back(subsectors); // RenderSubsector(subsectors); + { + PvsSectors.push_back(subsectors); + MaxCeilingHeight = subsectors->sector->ceilingplane.Zat0(); + MinFloorHeight = subsectors->sector->floorplane.Zat0(); + } else + { + MaxCeilingHeight = 0.0; + MinFloorHeight = 0.0; RenderNode(nodes + numnodes - 1); // The head node is the last node output. + } // Render front to back if (r_debug_cull) @@ -102,29 +110,6 @@ void RenderPolyBsp::RenderScreenSprites() sprite.Render(); } -TriVertex RenderPolyBsp::PlaneVertex(vertex_t *v1, sector_t *sector, const secplane_t &plane) -{ - TriVertex v; - v.x = (float)v1->fPos().X; - v.y = (float)v1->fPos().Y; - v.z = (float)plane.ZatPoint(v1); - v.w = 1.0f; - v.varying[0] = v.x / 64.0f; - v.varying[1] = v.y / 64.0f; - - /* - double vis = r_FloorVisibility / (plane.Zat0() - ViewPos.Z); - if (fixedlightlev >= 0) - R_SetDSColorMapLight(sector->ColorMap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); - else if (fixedcolormap) - R_SetDSColorMapLight(fixedcolormap, 0, 0); - else - R_SetDSColorMapLight(sector->ColorMap, (float)(vis * fabs(CenterY - y)), LIGHT2SHADE(sector->lightlevel)); - */ - - return v; -} - void RenderPolyBsp::RenderSubsector(subsector_t *sub) { sector_t *frontsector = sub->sector; @@ -139,72 +124,10 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) AddLine(line, frontsector, subsectorDepth); } - FTextureID floorpicnum = frontsector->GetTexture(sector_t::floor); - FTexture *floortex = TexMan(floorpicnum); - if (floortex->UseType != FTexture::TEX_Null) + if (sub->sector->CenterFloor() != sub->sector->CenterCeiling()) { - bool isSky = floorpicnum == skyflatnum; - - TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); - if (!vertices) - return; - - for (uint32_t i = 0; i < sub->numlines; i++) - { - seg_t *line = &sub->firstline[i]; - vertices[i] = PlaneVertex(line->v1, frontsector, frontsector->floorplane); - } - - TriUniforms uniforms; - uniforms.objectToClip = worldToClip; - uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f); - if (fixedlightlev >= 0) - uniforms.light = (uint32_t)(fixedlightlev / 255.0f * 256.0f); - else if (fixedcolormap) - uniforms.light = 256; - uniforms.flags = 0; - uniforms.subsectorDepth = isSky ? SkySubsectorDepth : subsectorDepth; - if (!isSky) - { - PolyTriangleDrawer::draw(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, floortex, 0); - PolyTriangleDrawer::stencil(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 1); - } - else - PolyTriangleDrawer::fill(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 0); - } - - FTextureID ceilpicnum = frontsector->GetTexture(sector_t::ceiling); - FTexture *ceiltex = TexMan(ceilpicnum); - if (ceiltex->UseType != FTexture::TEX_Null) - { - bool isSky = ceilpicnum == skyflatnum; - - TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); - if (!vertices) - return; - - for (uint32_t i = 0; i < sub->numlines; i++) - { - seg_t *line = &sub->firstline[i]; - vertices[sub->numlines - 1 - i] = PlaneVertex(line->v1, frontsector, frontsector->ceilingplane); - } - - TriUniforms uniforms; - uniforms.objectToClip = worldToClip; - uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f); - if (fixedlightlev >= 0) - uniforms.light = (uint32_t)(fixedlightlev / 255.0f * 256.0f); - else if (fixedcolormap) - uniforms.light = 256; - uniforms.flags = 0; - uniforms.subsectorDepth = isSky ? SkySubsectorDepth : subsectorDepth; - if (!isSky) - { - PolyTriangleDrawer::draw(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, ceiltex, 0); - PolyTriangleDrawer::stencil(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 1); - } - else - PolyTriangleDrawer::fill(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 0); + RenderPlane(sub, subsectorDepth, true); + RenderPlane(sub, subsectorDepth, false); } SpriteRange sprites = GetSpritesForSector(sub->sector); @@ -218,6 +141,166 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) } } +void RenderPolyBsp::RenderPlane(subsector_t *sub, uint32_t subsectorDepth, bool ceiling) +{ + sector_t *frontsector = sub->sector; + + FTextureID picnum = frontsector->GetTexture(ceiling ? sector_t::ceiling : sector_t::floor); + FTexture *tex = TexMan(picnum); + if (tex->UseType == FTexture::TEX_Null) + return; + + bool isSky = picnum == skyflatnum; + double skyHeight = ceiling ? MaxCeilingHeight : MinFloorHeight; + + TriUniforms uniforms; + uniforms.objectToClip = worldToClip; + uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f); + if (fixedlightlev >= 0) + uniforms.light = (uint32_t)(fixedlightlev / 255.0f * 256.0f); + else if (fixedcolormap) + uniforms.light = 256; + uniforms.flags = 0; + uniforms.subsectorDepth = isSky ? SkySubsectorDepth : subsectorDepth; + + /* + double vis = r_FloorVisibility / (plane.Zat0() - ViewPos.Z); + if (fixedlightlev >= 0) + R_SetDSColorMapLight(sector->ColorMap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + else if (fixedcolormap) + R_SetDSColorMapLight(fixedcolormap, 0, 0); + else + R_SetDSColorMapLight(sector->ColorMap, (float)(vis * fabs(CenterY - y)), LIGHT2SHADE(sector->lightlevel)); + */ + + TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); + if (!vertices) + return; + + if (ceiling) + { + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + vertices[sub->numlines - 1 - i] = PlaneVertex(line->v1, frontsector, isSky ? skyHeight : frontsector->ceilingplane.ZatPoint(line->v1)); + } + } + else + { + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + vertices[i] = PlaneVertex(line->v1, frontsector, isSky ? skyHeight : frontsector->floorplane.ZatPoint(line->v1)); + } + } + + if (!isSky) + { + PolyTriangleDrawer::draw(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex, 0); + PolyTriangleDrawer::stencil(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 1); + } + else + { + PolyTriangleDrawer::stencil(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 255); + + for (uint32_t i = 0; i < sub->numlines; i++) + { + TriVertex *wallvert = PolyVertexBuffer::GetVertices(4); + if (!wallvert) + return; + + seg_t *line = &sub->firstline[i]; + + bool closedSky = false; + if (line->backsector) + { + sector_t *backsector = (line->backsector != line->frontsector) ? line->backsector : line->frontsector; + + double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1); + double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1); + double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2); + double frontfloorz2 = frontsector->floorplane.ZatPoint(line->v2); + + double backceilz1 = backsector->ceilingplane.ZatPoint(line->v1); + double backfloorz1 = backsector->floorplane.ZatPoint(line->v1); + double backceilz2 = backsector->ceilingplane.ZatPoint(line->v2); + double backfloorz2 = backsector->floorplane.ZatPoint(line->v2); + + double topceilz1 = frontceilz1; + double topceilz2 = frontceilz2; + double topfloorz1 = MIN(backceilz1, frontceilz1); + double topfloorz2 = MIN(backceilz2, frontceilz2); + double bottomceilz1 = MAX(frontfloorz1, backfloorz1); + double bottomceilz2 = MAX(frontfloorz2, backfloorz2); + double bottomfloorz1 = frontfloorz1; + double bottomfloorz2 = frontfloorz2; + double middleceilz1 = topfloorz1; + double middleceilz2 = topfloorz2; + double middlefloorz1 = MIN(bottomceilz1, middleceilz1); + double middlefloorz2 = MIN(bottomceilz2, middleceilz2); + + bool bothSkyCeiling = frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum; + bool bothSkyFloor = frontsector->GetTexture(sector_t::floor) == skyflatnum && backsector->GetTexture(sector_t::floor) == skyflatnum; + + bool closedSector = backceilz1 == backfloorz1 && backceilz2 == backfloorz2; + closedSky = (ceiling && bothSkyCeiling && closedSector) || (!ceiling && bothSkyFloor && closedSector); + if (!closedSky) + { + bool topwall = (topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && line->sidedef && !bothSkyCeiling; + bool bottomwall = (bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && line->sidedef && !bothSkyFloor; + if ((ceiling && !topwall) || (!ceiling && !bottomwall)) + continue; + } + } + + if (ceiling) + { + wallvert[0] = PlaneVertex(line->v1, frontsector, skyHeight); + wallvert[1] = PlaneVertex(line->v2, frontsector, skyHeight); + if (!closedSky) + { + wallvert[2] = PlaneVertex(line->v2, frontsector, frontsector->ceilingplane.ZatPoint(line->v2)); + wallvert[3] = PlaneVertex(line->v1, frontsector, frontsector->ceilingplane.ZatPoint(line->v1)); + } + else + { + wallvert[2] = PlaneVertex(line->v2, frontsector, frontsector->floorplane.ZatPoint(line->v2)); + wallvert[3] = PlaneVertex(line->v1, frontsector, frontsector->floorplane.ZatPoint(line->v1)); + } + } + else + { + if (!closedSky) + { + wallvert[0] = PlaneVertex(line->v1, frontsector, frontsector->floorplane.ZatPoint(line->v1)); + wallvert[1] = PlaneVertex(line->v2, frontsector, frontsector->floorplane.ZatPoint(line->v2)); + } + else + { + wallvert[0] = PlaneVertex(line->v1, frontsector, frontsector->ceilingplane.ZatPoint(line->v1)); + wallvert[1] = PlaneVertex(line->v2, frontsector, frontsector->ceilingplane.ZatPoint(line->v2)); + } + wallvert[2] = PlaneVertex(line->v2, frontsector, skyHeight); + wallvert[3] = PlaneVertex(line->v1, frontsector, skyHeight); + } + + PolyTriangleDrawer::stencil(uniforms, wallvert, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 255); + } + } +} + +TriVertex RenderPolyBsp::PlaneVertex(vertex_t *v1, sector_t *sector, double height) +{ + TriVertex v; + v.x = (float)v1->fPos().X; + v.y = (float)v1->fPos().Y; + v.z = (float)height; + v.w = 1.0f; + v.varying[0] = v.x / 64.0f; + v.varying[1] = 1.0f - v.y / 64.0f; + return v; +} + SpriteRange RenderPolyBsp::GetSpritesForSector(sector_t *sector) { if (SectorSpriteRanges.size() < sector->sectornum || sector->sectornum < 0) @@ -294,25 +377,23 @@ void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector, uint32_t subsect bool bothSkyCeiling = frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum; bool bothSkyFloor = frontsector->GetTexture(sector_t::floor) == skyflatnum && backsector->GetTexture(sector_t::floor) == skyflatnum; - if ((topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && line->sidedef) + if ((topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && line->sidedef && !bothSkyCeiling) { wall.SetCoords(line->v1->fPos(), line->v2->fPos(), topceilz1, topfloorz1, topceilz2, topfloorz2); wall.TopZ = topceilz1; wall.BottomZ = topfloorz1; wall.UnpeggedCeil = topceilz1; wall.Texpart = side_t::top; - wall.IsSky = bothSkyCeiling; wall.Render(worldToClip); } - if ((bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && line->sidedef) + if ((bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && line->sidedef && !bothSkyFloor) { wall.SetCoords(line->v1->fPos(), line->v2->fPos(), bottomceilz1, bottomfloorz2, bottomceilz2, bottomfloorz2); wall.TopZ = bottomceilz1; wall.BottomZ = bottomfloorz2; wall.UnpeggedCeil = topceilz1; wall.Texpart = side_t::bottom; - wall.IsSky = bothSkyFloor; wall.Render(worldToClip); } @@ -619,6 +700,8 @@ void RenderPolyBsp::RenderNode(void *node) // Mark that we need to render this subsector_t *sub = (subsector_t *)((BYTE *)node - 1); + MaxCeilingHeight = MAX(MaxCeilingHeight, sub->sector->ceilingplane.Zat0()); + MinFloorHeight = MIN(MinFloorHeight, sub->sector->floorplane.Zat0()); PvsSectors.push_back(sub); // Update culling info for further bsp clipping @@ -1092,15 +1175,10 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) uniforms.objectToClip = worldToClip; uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f); uniforms.flags = 0; - uniforms.subsectorDepth = IsSky ? RenderPolyBsp::SkySubsectorDepth : SubsectorDepth; + uniforms.subsectorDepth = SubsectorDepth; - if (!IsSky) - { - PolyTriangleDrawer::draw(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex, 0); - PolyTriangleDrawer::stencil(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 1); - } - else - PolyTriangleDrawer::fill(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 0); + PolyTriangleDrawer::draw(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex, 0); + PolyTriangleDrawer::stencil(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 1); } FTexture *RenderPolyWall::GetTexture() @@ -1428,7 +1506,7 @@ void PolySkyDome::CreateDome() void PolySkyDome::RenderRow(const TriUniforms &uniforms, FTexture *skytex, int row) { - PolyTriangleDrawer::draw(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Strip, false, 0, viewwidth, 0, viewheight, skytex, 0); + PolyTriangleDrawer::draw(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Strip, false, 0, viewwidth, 0, viewheight, skytex, 255); } void PolySkyDome::RenderCapColorRow(const TriUniforms &uniforms, FTexture *skytex, int row, bool bottomCap) @@ -1436,7 +1514,7 @@ void PolySkyDome::RenderCapColorRow(const TriUniforms &uniforms, FTexture *skyte uint32_t solid = skytex->GetSkyCapColor(bottomCap); if (!r_swtruecolor) solid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)]; - PolyTriangleDrawer::fill(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Fan, bottomCap, 0, viewwidth, 0, viewheight, solid, 0); + PolyTriangleDrawer::fill(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Fan, bottomCap, 0, viewwidth, 0, viewheight, solid, 255); } void PolySkyDome::Render(const TriMatrix &worldToClip) diff --git a/src/r_poly.h b/src/r_poly.h index c312f313b..55a3d16cf 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -102,8 +102,9 @@ public: private: void RenderNode(void *node); void RenderSubsector(subsector_t *sub); + void RenderPlane(subsector_t *sub, uint32_t subsectorDepth, bool ceiling); void AddLine(seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); - TriVertex PlaneVertex(vertex_t *v1, sector_t *sector, const secplane_t &plane); + TriVertex PlaneVertex(vertex_t *v1, sector_t *sector, double height); void AddSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth); void AddWallSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth); @@ -128,6 +129,8 @@ private: std::vector PvsSectors; uint32_t NextSubsectorDepth = 0; + double MaxCeilingHeight = 0.0; + double MinFloorHeight = 0.0; TriMatrix worldToClip; @@ -179,7 +182,6 @@ public: double UnpeggedCeil = 0.0; FSWColormap *Colormap = nullptr; bool Masked = false; - bool IsSky = false; uint32_t SubsectorDepth = 0; private: From 6989b7037e6bf2ee3c92d8688005abb1a0dd527d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 11 Nov 2016 10:25:40 +0100 Subject: [PATCH 1195/1509] Fix stencil write bug --- src/r_poly_triangle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index b0b22f8d0..f0a93eb8c 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -64,7 +64,7 @@ public: if (Values[0] == value) return; - for (int i = 1; i < 8 * 8 + 4 * 4 + 2 * 2 + 1; i++) + for (int i = 1; i < 8 * 8; i++) Values[i] = Values[0]; } From 970c750daa8bcf9f0ace7bb153198b488f4f32e1 Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Fri, 11 Nov 2016 18:08:47 +0800 Subject: [PATCH 1196/1509] Added OpenGL support to the underwater view blend scalar option. --- src/gl/scene/gl_scene.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index b53be4aaa..1437d3fd5 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -82,6 +82,7 @@ CVAR(Bool, gl_sort_textures, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) EXTERN_CVAR (Bool, cl_capfps) EXTERN_CVAR (Bool, r_deathcamera) +EXTERN_CVAR (Float, underwater_fade_scalar) extern int viewpitch; @@ -602,7 +603,11 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) } else if (blendv.a) { - V_AddBlend(blendv.r / 255.f, blendv.g / 255.f, blendv.b / 255.f, blendv.a / 255.0f, blend); + // [Nash] allow user to set blend intensity + int cnt = blendv.a; + cnt = (int)(cnt * underwater_fade_scalar); + + V_AddBlend(blendv.r / 255.f, blendv.g / 255.f, blendv.b / 255.f, cnt / 255.0f, blend); } } From 5a9d4ee9d90e8f8e7122f2171abd7c3832694952 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 11 Nov 2016 18:24:59 +0100 Subject: [PATCH 1197/1509] Simplify argument passing --- src/r_poly.cpp | 95 +++++++++++++++++++++++++++++++++------- src/r_poly.h | 4 +- src/r_poly_triangle.cpp | 96 +++++++++++++++++------------------------ src/r_poly_triangle.h | 64 +++++++++++++++++---------- 4 files changed, 164 insertions(+), 95 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index a58cb86a5..c641702e1 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -194,14 +194,29 @@ void RenderPolyBsp::RenderPlane(subsector_t *sub, uint32_t subsectorDepth, bool } } + PolyDrawArgs args; + args.uniforms = uniforms; + args.vinput = vertices; + args.vcount = sub->numlines; + args.mode = TriangleDrawMode::Fan; + args.ccw = true; + args.clipleft = 0; + args.cliptop = 0; + args.clipright = viewwidth; + args.clipbottom = viewheight; + args.stenciltestvalue = 0; + args.stencilwritevalue = 1; + if (!isSky) { - PolyTriangleDrawer::draw(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex, 0); - PolyTriangleDrawer::stencil(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 1); + args.SetTexture(tex); + PolyTriangleDrawer::draw(args, PolyDrawVariant::Draw); + PolyTriangleDrawer::draw(args, PolyDrawVariant::Stencil); } else { - PolyTriangleDrawer::stencil(uniforms, vertices, sub->numlines, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 255); + args.stencilwritevalue = 255; + PolyTriangleDrawer::draw(args, PolyDrawVariant::Stencil); for (uint32_t i = 0; i < sub->numlines; i++) { @@ -284,7 +299,9 @@ void RenderPolyBsp::RenderPlane(subsector_t *sub, uint32_t subsectorDepth, bool wallvert[3] = PlaneVertex(line->v1, frontsector, skyHeight); } - PolyTriangleDrawer::stencil(uniforms, wallvert, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 255); + args.vinput = wallvert; + args.vcount = 4; + PolyTriangleDrawer::draw(args, PolyDrawVariant::Stencil); } } } @@ -525,7 +542,21 @@ void RenderPolyBsp::AddSprite(AActor *thing, subsector_t *sub, uint32_t subsecto uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f); uniforms.flags = 0; uniforms.subsectorDepth = subsectorDepth; - PolyTriangleDrawer::draw(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex, 0); + + PolyDrawArgs args; + args.uniforms = uniforms; + args.vinput = vertices; + args.vcount = 4; + args.mode = TriangleDrawMode::Fan; + args.ccw = true; + args.clipleft = 0; + args.cliptop = 0; + args.clipright = viewwidth; + args.clipbottom = viewheight; + args.stenciltestvalue = 0; + args.stencilwritevalue = 1; + args.SetTexture(tex); + PolyTriangleDrawer::draw(args, PolyDrawVariant::Draw); } void RenderPolyBsp::AddWallSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) @@ -1177,8 +1208,22 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) uniforms.flags = 0; uniforms.subsectorDepth = SubsectorDepth; - PolyTriangleDrawer::draw(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, tex, 0); - PolyTriangleDrawer::stencil(uniforms, vertices, 4, TriangleDrawMode::Fan, true, 0, viewwidth, 0, viewheight, 0, 1); + PolyDrawArgs args; + args.uniforms = uniforms; + args.vinput = vertices; + args.vcount = 4; + args.mode = TriangleDrawMode::Fan; + args.ccw = true; + args.clipleft = 0; + args.cliptop = 0; + args.clipright = viewwidth; + args.clipbottom = viewheight; + args.stenciltestvalue = 0; + args.stencilwritevalue = 1; + args.SetTexture(tex); + + PolyTriangleDrawer::draw(args, PolyDrawVariant::Draw); + PolyTriangleDrawer::draw(args, PolyDrawVariant::Stencil); } FTexture *RenderPolyWall::GetTexture() @@ -1504,17 +1549,27 @@ void PolySkyDome::CreateDome() mPrimStart.Push(mVertices.Size()); } -void PolySkyDome::RenderRow(const TriUniforms &uniforms, FTexture *skytex, int row) +void PolySkyDome::RenderRow(PolyDrawArgs &args, int row) { - PolyTriangleDrawer::draw(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Strip, false, 0, viewwidth, 0, viewheight, skytex, 255); + args.vinput = &mVertices[mPrimStart[row]]; + args.vcount = mPrimStart[row + 1] - mPrimStart[row]; + args.mode = TriangleDrawMode::Strip; + args.ccw = false; + PolyTriangleDrawer::draw(args, PolyDrawVariant::Draw); } -void PolySkyDome::RenderCapColorRow(const TriUniforms &uniforms, FTexture *skytex, int row, bool bottomCap) +void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap) { uint32_t solid = skytex->GetSkyCapColor(bottomCap); if (!r_swtruecolor) solid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)]; - PolyTriangleDrawer::fill(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Fan, bottomCap, 0, viewwidth, 0, viewheight, solid, 255); + + args.vinput = &mVertices[mPrimStart[row]]; + args.vcount = mPrimStart[row + 1] - mPrimStart[row]; + args.mode = TriangleDrawMode::Fan; + args.ccw = bottomCap; + args.solidcolor = solid; + PolyTriangleDrawer::draw(args, PolyDrawVariant::Fill); } void PolySkyDome::Render(const TriMatrix &worldToClip) @@ -1540,12 +1595,22 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) int rc = mRows + 1; - RenderCapColorRow(uniforms, frontskytex, 0, false); - RenderCapColorRow(uniforms, frontskytex, rc, true); + PolyDrawArgs args; + args.uniforms = uniforms; + args.clipleft = 0; + args.cliptop = 0; + args.clipright = viewwidth; + args.clipbottom = viewheight; + args.stenciltestvalue = 255; + args.stencilwritevalue = 1; + args.SetTexture(frontskytex); + + RenderCapColorRow(args, frontskytex, 0, false); + RenderCapColorRow(args, frontskytex, rc, true); for (int i = 1; i <= mRows; i++) { - RenderRow(uniforms, frontskytex, i); - RenderRow(uniforms, frontskytex, rc + i); + RenderRow(args, i); + RenderRow(args, rc + i); } } diff --git a/src/r_poly.h b/src/r_poly.h index 55a3d16cf..18997c01d 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -83,8 +83,8 @@ private: void SkyVertex(int r, int c, bool yflip); void CreateSkyHemisphere(bool zflip); void CreateDome(); - void RenderRow(const TriUniforms &uniforms, FTexture *skytex, int row); - void RenderCapColorRow(const TriUniforms &uniforms, FTexture *skytex, int row, bool bottomCap); + void RenderRow(PolyDrawArgs &args, int row); + void RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap); TriVertex SetVertex(float xx, float yy, float zz, float uu = 0, float vv = 0); TriVertex SetVertexXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0); diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 57165736d..075b4432f 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -40,90 +40,79 @@ #include #endif -void PolyTriangleDrawer::draw(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, FTexture *texture, int stenciltestvalue) +void PolyTriangleDrawer::draw(const PolyDrawArgs &args, PolyDrawVariant variant) { if (r_swtruecolor) - queue_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, (const uint8_t*)texture->GetPixelsBgra(), texture->GetWidth(), texture->GetHeight(), 0, stenciltestvalue, stenciltestvalue); + DrawerCommandQueue::QueueCommand(args, variant); else - draw_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texture->GetPixels(), texture->GetWidth(), texture->GetHeight(), 0, stenciltestvalue, stenciltestvalue, nullptr, &ScreenPolyTriangleDrawer::draw); + draw_arrays(args, variant, nullptr); } -void PolyTriangleDrawer::fill(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int solidcolor, int stenciltestvalue) +void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, PolyDrawVariant variant, DrawerThread *thread) { - if (r_swtruecolor) - queue_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor, stenciltestvalue, stenciltestvalue); - else - draw_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor, stenciltestvalue, stenciltestvalue, nullptr, &ScreenPolyTriangleDrawer::fill); -} - -void PolyTriangleDrawer::stencil(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int stenciltestvalue, int stencilwritevalue) -{ - if (r_swtruecolor) - queue_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, 0xbeef, stenciltestvalue, stencilwritevalue); - else - draw_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, 0, stenciltestvalue, stencilwritevalue, nullptr, &ScreenPolyTriangleDrawer::stencil); -} - -void PolyTriangleDrawer::queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, int stenciltestvalue, int stencilwritevalue) -{ - if (clipright < clipleft || clipleft < 0 || clipright > MAXWIDTH || clipbottom < cliptop || cliptop < 0 || clipbottom > MAXHEIGHT) + if (drawargs.vcount < 3) return; - DrawerCommandQueue::QueueCommand(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texturePixels, textureWidth, textureHeight, solidcolor, stenciltestvalue, stencilwritevalue); -} - -void PolyTriangleDrawer::draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, int stenciltestvalue, int stencilwritevalue, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)) -{ - if (vcount < 3) - return; + void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *); + switch (variant) + { + default: + case PolyDrawVariant::Draw: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::draw32 : ScreenPolyTriangleDrawer::draw; break; + case PolyDrawVariant::Fill: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::fill32 : ScreenPolyTriangleDrawer::fill; break; + case PolyDrawVariant::Stencil: drawfunc = ScreenPolyTriangleDrawer::stencil; break; + } ScreenPolyTriangleDrawerArgs args; args.dest = dc_destorg; args.pitch = dc_pitch; - args.clipleft = clipleft; - args.clipright = clipright; - args.cliptop = cliptop; - args.clipbottom = clipbottom; - args.texturePixels = texturePixels; - args.textureWidth = textureWidth; - args.textureHeight = textureHeight; - args.solidcolor = solidcolor; - args.uniforms = &uniforms; - args.stencilTestValue = stenciltestvalue; - args.stencilWriteValue = stencilwritevalue; + args.clipleft = drawargs.clipleft; + args.clipright = drawargs.clipright; + args.cliptop = drawargs.cliptop; + args.clipbottom = drawargs.clipbottom; + args.texturePixels = drawargs.texturePixels; + args.textureWidth = drawargs.textureWidth; + args.textureHeight = drawargs.textureHeight; + args.solidcolor = drawargs.solidcolor; + args.uniforms = &drawargs.uniforms; + args.stencilTestValue = drawargs.stenciltestvalue; + args.stencilWriteValue = drawargs.stencilwritevalue; args.stencilPitch = PolyStencilBuffer::Instance()->BlockWidth(); args.stencilValues = PolyStencilBuffer::Instance()->Values(); args.stencilMasks = PolyStencilBuffer::Instance()->Masks(); args.subsectorGBuffer = PolySubsectorGBuffer::Instance()->Values(); + bool ccw = drawargs.ccw; + const TriVertex *vinput = drawargs.vinput; + int vcount = drawargs.vcount; + TriVertex vert[3]; - if (mode == TriangleDrawMode::Normal) + if (drawargs.mode == TriangleDrawMode::Normal) { for (int i = 0; i < vcount / 3; i++) { for (int j = 0; j < 3; j++) - vert[j] = shade_vertex(uniforms, *(vinput++)); + vert[j] = shade_vertex(drawargs.uniforms, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); } } - else if (mode == TriangleDrawMode::Fan) + else if (drawargs.mode == TriangleDrawMode::Fan) { - vert[0] = shade_vertex(uniforms, *(vinput++)); - vert[1] = shade_vertex(uniforms, *(vinput++)); + vert[0] = shade_vertex(drawargs.uniforms, *(vinput++)); + vert[1] = shade_vertex(drawargs.uniforms, *(vinput++)); for (int i = 2; i < vcount; i++) { - vert[2] = shade_vertex(uniforms, *(vinput++)); + vert[2] = shade_vertex(drawargs.uniforms, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); vert[1] = vert[2]; } } else // TriangleDrawMode::Strip { - vert[0] = shade_vertex(uniforms, *(vinput++)); - vert[1] = shade_vertex(uniforms, *(vinput++)); + vert[0] = shade_vertex(drawargs.uniforms, *(vinput++)); + vert[1] = shade_vertex(drawargs.uniforms, *(vinput++)); for (int i = 2; i < vcount; i++) { - vert[2] = shade_vertex(uniforms, *(vinput++)); + vert[2] = shade_vertex(drawargs.uniforms, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); vert[0] = vert[1]; vert[1] = vert[2]; @@ -1324,19 +1313,14 @@ float ScreenPolyTriangleDrawer::grady(float x0, float y0, float x1, float y1, fl ///////////////////////////////////////////////////////////////////////////// -DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, int stenciltestvalue, int stencilwritevalue) - : uniforms(uniforms), vinput(vinput), vcount(vcount), mode(mode), ccw(ccw), clipleft(clipleft), clipright(clipright), cliptop(cliptop), clipbottom(clipbottom), texturePixels(texturePixels), textureWidth(textureWidth), textureHeight(textureHeight), solidcolor(solidcolor), stenciltestvalue(stenciltestvalue), stencilwritevalue(stencilwritevalue) +DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args, PolyDrawVariant variant) + : args(args), variant(variant) { } void DrawPolyTrianglesCommand::Execute(DrawerThread *thread) { - PolyTriangleDrawer::draw_arrays( - uniforms, vinput, vcount, mode, ccw, - clipleft, clipright, cliptop, clipbottom, - texturePixels, textureWidth, textureHeight, solidcolor, - stenciltestvalue, stencilwritevalue, - thread, texturePixels ? ScreenPolyTriangleDrawer::draw32 : solidcolor != 0xbeef ? ScreenPolyTriangleDrawer::fill32 : ScreenPolyTriangleDrawer::stencil); + PolyTriangleDrawer::draw_arrays(args, variant, thread); } FString DrawPolyTrianglesCommand::DebugInfo() diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index f0a93eb8c..d6e1d3341 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -28,22 +28,55 @@ struct ScreenPolyTriangleDrawerArgs; +enum class PolyDrawVariant +{ + Draw, + Fill, + Stencil +}; + +class PolyDrawArgs +{ +public: + TriUniforms uniforms; + const TriVertex *vinput = nullptr; + int vcount = 0; + TriangleDrawMode mode = TriangleDrawMode::Normal; + bool ccw = false; + int clipleft = 0; + int clipright = 0; + int cliptop = 0; + int clipbottom = 0; + const uint8_t *texturePixels = nullptr; + int textureWidth = 0; + int textureHeight = 0; + int solidcolor = 0; + int stenciltestvalue = 0; + int stencilwritevalue = 0; + + void SetTexture(FTexture *texture) + { + textureWidth = texture->GetWidth(); + textureHeight = texture->GetHeight(); + if (r_swtruecolor) + texturePixels = (const uint8_t *)texture->GetPixelsBgra(); + else + texturePixels = texture->GetPixels(); + } +}; + class PolyTriangleDrawer { public: - static void draw(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, FTexture *texture, int stenciltestvalue); - static void fill(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int solidcolor, int stenciltestvalue); - static void stencil(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, int stenciltestvalue, int stencilwritevalue); + static void draw(const PolyDrawArgs &args, PolyDrawVariant variant); private: static TriVertex shade_vertex(const TriUniforms &uniforms, TriVertex v); - static void draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, int stenciltestvalue, int stencilwritevalue, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)); + static void draw_arrays(const PolyDrawArgs &args, PolyDrawVariant variant, DrawerThread *thread); static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert); - static void queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, int stenciltestvalue, int stencilwritevalue); - enum { max_additional_vertices = 16 }; friend class DrawPolyTrianglesCommand; @@ -234,27 +267,14 @@ private: class DrawPolyTrianglesCommand : public DrawerCommand { public: - DrawPolyTrianglesCommand(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, int stenciltestvalue, int stencilwritevalue); + DrawPolyTrianglesCommand(const PolyDrawArgs &args, PolyDrawVariant variant); void Execute(DrawerThread *thread) override; FString DebugInfo() override; private: - TriUniforms uniforms; - const TriVertex *vinput; - int vcount; - TriangleDrawMode mode; - bool ccw; - int clipleft; - int clipright; - int cliptop; - int clipbottom; - const uint8_t *texturePixels; - int textureWidth; - int textureHeight; - int solidcolor; - int stenciltestvalue; - int stencilwritevalue; + PolyDrawArgs args; + PolyDrawVariant variant; }; #endif From 3cc5cec5a0e61df82d618361be31d7dc9a06fb27 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 11 Nov 2016 19:26:28 +0100 Subject: [PATCH 1198/1509] Hook up subsector gbuffer --- src/r_poly.cpp | 33 +++-- src/r_poly.h | 13 +- src/r_poly_triangle.cpp | 287 +++++++++++++++++++++++++++++++++++++++- src/r_poly_triangle.h | 12 +- 4 files changed, 327 insertions(+), 18 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index c641702e1..94805c9c0 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -50,6 +50,7 @@ void RenderPolyBsp::Render() SectorSpriteRanges.clear(); SectorSpriteRanges.resize(numsectors); SortedSprites.clear(); + SubsectoredSprites.clear(); PvsSectors.clear(); ScreenSprites.clear(); PolyStencilBuffer::Instance()->Clear(viewwidth, viewheight, 0); @@ -99,6 +100,8 @@ void RenderPolyBsp::Render() skydome.Render(worldToClip); + RenderSprites(); + RenderPlayerSprites(); DrawerCommandQueue::WaitForWorkers(); RenderScreenSprites(); // To do: should be called by FSoftwareRenderer::DrawRemainingPlayerSprites instead of here @@ -117,6 +120,12 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) uint32_t subsectorDepth = NextSubsectorDepth++; + if (sub->sector->CenterFloor() != sub->sector->CenterCeiling()) + { + RenderPlane(sub, subsectorDepth, true); + RenderPlane(sub, subsectorDepth, false); + } + for (uint32_t i = 0; i < sub->numlines; i++) { seg_t *line = &sub->firstline[i]; @@ -124,20 +133,23 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) AddLine(line, frontsector, subsectorDepth); } - if (sub->sector->CenterFloor() != sub->sector->CenterCeiling()) - { - RenderPlane(sub, subsectorDepth, true); - RenderPlane(sub, subsectorDepth, false); - } - SpriteRange sprites = GetSpritesForSector(sub->sector); for (int i = 0; i < sprites.Count; i++) { AActor *thing = SortedSprites[sprites.Start + i].Thing; - if ((thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) - AddWallSprite(thing, sub, subsectorDepth); + SubsectoredSprites.push_back({ thing, sub, subsectorDepth }); + } +} + +void RenderPolyBsp::RenderSprites() +{ + for (auto it = SubsectoredSprites.rbegin(); it != SubsectoredSprites.rend(); ++it) + { + auto &spr = *it; + if ((spr.thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) + AddWallSprite(spr.thing, spr.sub, spr.subsectorDepth); else - AddSprite(thing, sub, subsectorDepth); + AddSprite(spr.thing, spr.sub, spr.subsectorDepth); } } @@ -556,7 +568,7 @@ void RenderPolyBsp::AddSprite(AActor *thing, subsector_t *sub, uint32_t subsecto args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); - PolyTriangleDrawer::draw(args, PolyDrawVariant::Draw); + PolyTriangleDrawer::draw(args, PolyDrawVariant::DrawSubsector); } void RenderPolyBsp::AddWallSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) @@ -1592,6 +1604,7 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) uniforms.objectToClip = worldToClip * objectToWorld; uniforms.light = 256; uniforms.flags = 0; + uniforms.subsectorDepth = RenderPolyBsp::SkySubsectorDepth; int rc = mRows + 1; diff --git a/src/r_poly.h b/src/r_poly.h index 18997c01d..b957aad59 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -54,12 +54,21 @@ class PolySortedSprite { public: PolySortedSprite(AActor *thing, double distanceSquared) : Thing(thing), DistanceSquared(distanceSquared) { } - bool operator<(const PolySortedSprite &other) const { return DistanceSquared > other.DistanceSquared; } + bool operator<(const PolySortedSprite &other) const { return DistanceSquared < other.DistanceSquared; } AActor *Thing; double DistanceSquared; }; +class PolySubsectoredSprite +{ +public: + PolySubsectoredSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) : thing(thing), sub(sub), subsectorDepth(subsectorDepth) { } + AActor *thing; + subsector_t *sub; + uint32_t subsectorDepth; +}; + class SpriteRange { public: @@ -106,6 +115,7 @@ private: void AddLine(seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); TriVertex PlaneVertex(vertex_t *v1, sector_t *sector, double height); + void RenderSprites(); void AddSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth); void AddWallSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth); bool IsThingCulled(AActor *thing); @@ -136,6 +146,7 @@ private: std::vector SectorSpriteRanges; std::vector SortedSprites; + std::vector SubsectoredSprites; std::vector ScreenSprites; diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 075b4432f..fb1874be2 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -59,6 +59,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, PolyDrawVaria default: case PolyDrawVariant::Draw: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::draw32 : ScreenPolyTriangleDrawer::draw; break; case PolyDrawVariant::Fill: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::fill32 : ScreenPolyTriangleDrawer::fill; break; + case PolyDrawVariant::DrawSubsector: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::drawsubsector32 : ScreenPolyTriangleDrawer::draw; break; case PolyDrawVariant::Stencil: drawfunc = ScreenPolyTriangleDrawer::stencil; break; } @@ -846,11 +847,13 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, const uint32_t *texturePixels = (const uint32_t *)args->texturePixels; int textureWidth = args->textureWidth; int textureHeight = args->textureHeight; - uint32_t light = args->uniforms->light; uint8_t *stencilValues = args->stencilValues; uint32_t *stencilMasks = args->stencilMasks; int stencilPitch = args->stencilPitch; uint8_t stencilTestValue = args->stencilTestValue; + uint32_t light = args->uniforms->light; + uint32_t subsector = args->uniforms->subsectorDepth; + uint32_t *subsectorGBuffer = args->subsectorGBuffer; // 28.4 fixed-point coordinates const int Y1 = (int)round(16.0f * v1.y); @@ -895,6 +898,7 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, miny &= ~(q - 1); dest += miny * pitch; + subsectorGBuffer += miny * pitch; // Half-edge constants int C1 = DY12 * X1 - DX12 * Y1; @@ -919,7 +923,7 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, } // Loop through blocks - for (int y = miny; y < maxy; y += q, dest += q * pitch) + for (int y = miny; y < maxy; y += q, dest += q * pitch, subsectorGBuffer += q * pitch) { // Is this row of blocks done by this thread? if (thread->skipped_by_thread(y / q)) continue; @@ -989,6 +993,7 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, #endif uint32_t *buffer = dest; + uint32_t *subsectorbuffer = subsectorGBuffer; PolyStencilBlock stencil(x / 8 + y / 8 * stencilPitch, stencilValues, stencilMasks); @@ -1028,7 +1033,10 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, uint32_t fg_alpha = APART(fg); if (fg_alpha > 127) + { buffer[ix] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; + subsectorbuffer[ix] = subsector; + } for (int i = 0; i < TriVertex::NumVarying; i++) varying[i] += varyingStep[i]; @@ -1059,10 +1067,14 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, __m128i mmask1 = _mm_shufflehi_epi16(_mm_shufflelo_epi16(mfg1, _MM_SHUFFLE(3, 3, 3, 3)), _MM_SHUFFLE(3, 3, 3, 3)); __m128i mmask = _mm_cmplt_epi8(_mm_packus_epi16(mmask0, mmask1), _mm_setzero_si128()); _mm_maskmoveu_si128(mout, mmask, (char*)(&buffer[x + sse * 4])); + + __m128i msubsector = _mm_set1_epi32(subsector); + _mm_maskmoveu_si128(msubsector, mmask, (char*)(&subsectorbuffer[x + sse * 4])); } #endif buffer += pitch; + subsectorbuffer += pitch; } } else // Partially covered block @@ -1106,6 +1118,276 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, uint32_t fg_blue = (BPART(fg) * diminishedlight) >> 8; uint32_t fg_alpha = APART(fg); + if (fg_alpha > 127) + { + buffer[ix + x] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; + subsectorbuffer[ix + x] = subsector; + } + } + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + + buffer += pitch; + subsectorbuffer += pitch; + } + } + } + } +} + +void ScreenPolyTriangleDrawer::drawsubsector32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread) +{ + uint32_t *dest = (uint32_t *)args->dest; + int pitch = args->pitch; + const TriVertex &v1 = *args->v1; + const TriVertex &v2 = *args->v2; + const TriVertex &v3 = *args->v3; + int clipleft = args->clipleft; + int clipright = args->clipright; + int cliptop = args->cliptop; + int clipbottom = args->clipbottom; + const uint32_t *texturePixels = (const uint32_t *)args->texturePixels; + int textureWidth = args->textureWidth; + int textureHeight = args->textureHeight; + uint32_t light = args->uniforms->light; + uint32_t subsector = args->uniforms->subsectorDepth; + uint32_t *subsectorGBuffer = args->subsectorGBuffer; + + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, cliptop); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); + if (minx >= maxx || miny >= maxy) + return; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + dest += miny * pitch; + subsectorGBuffer += miny * pitch; + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // Gradients + float gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + float gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + float startW = v1.w + gradWX * (minx - v1.x) + gradWY * (miny - v1.y); + float gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (minx - v1.x) + gradVaryingY[i] * (miny - v1.y); + } + + // Loop through blocks + for (int y = miny; y < maxy; y += q, dest += q * pitch, subsectorGBuffer += q * pitch) + { + // Is this row of blocks done by this thread? + if (thread->skipped_by_thread(y / q)) continue; + + for (int x = minx; x < maxx; x += q) + { + // Corners of block + int x0 = x << 4; + int x1 = (x + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; + bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; + bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; + bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; + int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); + + bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; + bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; + bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; + bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; + int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); + + bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; + bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; + bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; + bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; + int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + + // Skip block when outside an edge + if (a == 0x0 || b == 0x0 || c == 0x0) continue; + + // Check if block needs clipping + bool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); + + // Calculate varying variables for affine block + float offx0 = (x - minx) + 0.5f; + float offy0 = (y - miny) + 0.5f; + float offx1 = offx0 + q; + float offy1 = offy0 + q; + float rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); + float rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); + float rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); + float rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); + float varyingTL[TriVertex::NumVarying]; + float varyingTR[TriVertex::NumVarying]; + float varyingBL[TriVertex::NumVarying]; + float varyingBR[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; + varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; + varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); + varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); + } + + float globVis = 1706.0f; + float vis = globVis / rcpWTL; + float shade = 64.0f - (light * 255 / 256 + 12.0f) * 32.0f / 128.0f; + float lightscale = clamp((shade - MIN(24.0f, vis)) / 32.0f, 0.0f, 31.0f / 32.0f); + int diminishedlight = (int)clamp((1.0f - lightscale) * 256.0f + 0.5f, 0.0f, 256.0f); + +#if !defined(NO_SSE) + __m128i mlight = _mm_set1_epi16(diminishedlight); +#endif + + uint32_t *buffer = dest; + uint32_t *subsectorbuffer = subsectorGBuffer; + + // Accept whole block when totally covered + if (a == 0xF && b == 0xF && c == 0xF && !clipneeded) + { + for (int iy = 0; iy < q; iy++) + { + uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + float pos = varyingTL[i] + varyingBL[i] * iy; + float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); + + varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); + varyingStep[i] = (uint32_t)(step * 0x100000000LL); + } + + for (int ix = x; ix < x + q; ix++) + { + if (subsectorbuffer[ix] >= subsector) + { + uint32_t ufrac = varying[0]; + uint32_t vfrac = varying[1]; + + uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; + uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; + uint32_t uvoffset = upos * textureHeight + vpos; + + uint32_t fg = texturePixels[uvoffset]; + uint32_t fg_red = (RPART(fg) * diminishedlight) >> 8; + uint32_t fg_green = (GPART(fg) * diminishedlight) >> 8; + uint32_t fg_blue = (BPART(fg) * diminishedlight) >> 8; + uint32_t fg_alpha = APART(fg); + + if (fg_alpha > 127) + buffer[ix] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; + } + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] += varyingStep[i]; + } + + buffer += pitch; + subsectorbuffer += pitch; + } + } + else // Partially covered block + { + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; + + for (int iy = 0; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + float pos = varyingTL[i] + varyingBL[i] * iy; + float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); + + varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); + varyingStep[i] = (uint32_t)(step * 0x100000000LL); + } + + for (int ix = 0; ix < q; ix++) + { + bool visible = (ix + x >= clipleft) && (ix + x < clipright) && (cliptop <= y + iy) && (clipbottom > y + iy); + + if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible && subsectorbuffer[ix + x] >= subsector) + { + uint32_t ufrac = varying[0]; + uint32_t vfrac = varying[1]; + + uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; + uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; + uint32_t uvoffset = upos * textureHeight + vpos; + + uint32_t fg = texturePixels[uvoffset]; + uint32_t fg_red = (RPART(fg) * diminishedlight) >> 8; + uint32_t fg_green = (GPART(fg) * diminishedlight) >> 8; + uint32_t fg_blue = (BPART(fg) * diminishedlight) >> 8; + uint32_t fg_alpha = APART(fg); + if (fg_alpha > 127) buffer[ix + x] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; } @@ -1123,6 +1405,7 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, CY3 += FDX31; buffer += pitch; + subsectorbuffer += pitch; } } } diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index d6e1d3341..0861e7186 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -32,7 +32,8 @@ enum class PolyDrawVariant { Draw, Fill, - Stencil + DrawSubsector, + Stencil, }; class PolyDrawArgs @@ -50,9 +51,9 @@ public: const uint8_t *texturePixels = nullptr; int textureWidth = 0; int textureHeight = 0; - int solidcolor = 0; - int stenciltestvalue = 0; - int stencilwritevalue = 0; + uint32_t solidcolor = 0; + uint8_t stenciltestvalue = 0; + uint8_t stencilwritevalue = 0; void SetTexture(FTexture *texture) { @@ -238,7 +239,7 @@ struct ScreenPolyTriangleDrawerArgs const uint8_t *texturePixels; int textureWidth; int textureHeight; - int solidcolor; + uint32_t solidcolor; const TriUniforms *uniforms; uint8_t *stencilValues; uint32_t *stencilMasks; @@ -257,6 +258,7 @@ public: static void stencil(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); static void draw32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); + static void drawsubsector32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); static void fill32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); private: From 09384208716417dd4796b935c0620a2c12b0584c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 11 Nov 2016 19:54:27 +0100 Subject: [PATCH 1199/1509] Make triangle drawers compatible with LLVMDrawers --- src/r_compiler/llvmdrawers.h | 79 ++++++++++++++++++++++++++++++++++++ src/r_poly_triangle.cpp | 39 ++++++++++-------- src/r_poly_triangle.h | 40 ++++-------------- src/r_triangle.cpp | 29 ++++++++----- src/r_triangle.h | 68 ++++--------------------------- 5 files changed, 135 insertions(+), 120 deletions(-) diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index b2978cabf..abf9598e3 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -181,6 +181,85 @@ struct DrawSkyArgs } }; +struct TriVertex +{ + TriVertex() { } + TriVertex(float x, float y, float z, float w, float u, float v) : x(x), y(y), z(z), w(w) { varying[0] = u; varying[1] = v; } + + enum { NumVarying = 2 }; + float x, y, z, w; + float varying[NumVarying]; +}; + +struct TriMatrix +{ + static TriMatrix null(); + static TriMatrix identity(); + static TriMatrix translate(float x, float y, float z); + static TriMatrix scale(float x, float y, float z); + static TriMatrix rotate(float angle, float x, float y, float z); + static TriMatrix swapYZ(); + static TriMatrix perspective(float fovy, float aspect, float near, float far); + static TriMatrix frustum(float left, float right, float bottom, float top, float near, float far); + + static TriMatrix worldToView(); // Software renderer world to view space transform + static TriMatrix viewToClip(); // Software renderer shearing projection + + TriVertex operator*(TriVertex v) const; + TriMatrix operator*(const TriMatrix &m) const; + + float matrix[16]; +}; + +struct TriUniforms +{ + uint32_t light; + uint32_t subsectorDepth; + + uint16_t light_alpha; + uint16_t light_red; + uint16_t light_green; + uint16_t light_blue; + uint16_t fade_alpha; + uint16_t fade_red; + uint16_t fade_green; + uint16_t fade_blue; + uint16_t desaturate; + uint32_t flags; + enum Flags + { + simple_shade = 1, + nearest_filter = 2, + diminishing_lighting = 4 + }; + + TriMatrix objectToClip; +}; + +struct ScreenPolyTriangleDrawerArgs +{ + uint8_t *dest; + int pitch; + TriVertex *v1; + TriVertex *v2; + TriVertex *v3; + int clipleft; + int clipright; + int cliptop; + int clipbottom; + const uint8_t *texturePixels; + int textureWidth; + int textureHeight; + uint32_t solidcolor; + const TriUniforms *uniforms; + uint8_t *stencilValues; + uint32_t *stencilMasks; + int stencilPitch; + uint8_t stencilTestValue; + uint8_t stencilWriteValue; + uint32_t *subsectorGBuffer; +}; + class LLVMDrawers { public: diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index fb1874be2..181b011a4 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -48,12 +48,12 @@ void PolyTriangleDrawer::draw(const PolyDrawArgs &args, PolyDrawVariant variant) draw_arrays(args, variant, nullptr); } -void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, PolyDrawVariant variant, DrawerThread *thread) +void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, PolyDrawVariant variant, WorkerThreadData *thread) { if (drawargs.vcount < 3) return; - void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *); + void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, WorkerThreadData *); switch (variant) { default: @@ -128,7 +128,7 @@ TriVertex PolyTriangleDrawer::shade_vertex(const TriUniforms &uniforms, TriVerte return uniforms.objectToClip * v; } -void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)) +void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, WorkerThreadData *)) { // Cull, clip and generate additional vertices as needed TriVertex clippedvert[max_additional_vertices]; @@ -288,7 +288,7 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert ///////////////////////////////////////////////////////////////////////////// -void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread) +void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread) { uint8_t *dest = args->dest; int pitch = args->pitch; @@ -373,7 +373,7 @@ void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, Dr for (int y = miny; y < maxy; y += q, dest += q * pitch) { // Is this row of blocks done by this thread? - if (thread && thread->skipped_by_thread(y / q)) continue; + if (thread && ((y / q) % thread->num_cores != thread->core)) continue; for (int x = minx; x < maxx; x += q) { @@ -523,7 +523,7 @@ void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, Dr } } -void ScreenPolyTriangleDrawer::fill(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread) +void ScreenPolyTriangleDrawer::fill(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread) { uint8_t *dest = args->dest; int pitch = args->pitch; @@ -594,7 +594,7 @@ void ScreenPolyTriangleDrawer::fill(const ScreenPolyTriangleDrawerArgs *args, Dr for (int y = miny; y < maxy; y += q, dest += q * pitch) { // Is this row of blocks done by this thread? - if (thread && thread->skipped_by_thread(y / q)) continue; + if (thread && ((y / q) % thread->num_cores != thread->core)) continue; for (int x = minx; x < maxx; x += q) { @@ -681,7 +681,7 @@ void ScreenPolyTriangleDrawer::fill(const ScreenPolyTriangleDrawerArgs *args, Dr } } -void ScreenPolyTriangleDrawer::stencil(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread) +void ScreenPolyTriangleDrawer::stencil(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread) { const TriVertex &v1 = *args->v1; const TriVertex &v2 = *args->v2; @@ -753,7 +753,7 @@ void ScreenPolyTriangleDrawer::stencil(const ScreenPolyTriangleDrawerArgs *args, for (int y = miny; y < maxy; y += q) { // Is this row of blocks done by this thread? - if (thread && thread->skipped_by_thread(y / q)) continue; + if (thread && ((y / q) % thread->num_cores != thread->core)) continue; for (int x = minx; x < maxx; x += q) { @@ -833,7 +833,7 @@ void ScreenPolyTriangleDrawer::stencil(const ScreenPolyTriangleDrawerArgs *args, } } -void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread) +void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread) { uint32_t *dest = (uint32_t *)args->dest; int pitch = args->pitch; @@ -926,7 +926,7 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, for (int y = miny; y < maxy; y += q, dest += q * pitch, subsectorGBuffer += q * pitch) { // Is this row of blocks done by this thread? - if (thread->skipped_by_thread(y / q)) continue; + if ((y / q) % thread->num_cores != thread->core) continue; for (int x = minx; x < maxx; x += q) { @@ -1145,7 +1145,7 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, } } -void ScreenPolyTriangleDrawer::drawsubsector32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread) +void ScreenPolyTriangleDrawer::drawsubsector32(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread) { uint32_t *dest = (uint32_t *)args->dest; int pitch = args->pitch; @@ -1234,7 +1234,7 @@ void ScreenPolyTriangleDrawer::drawsubsector32(const ScreenPolyTriangleDrawerArg for (int y = miny; y < maxy; y += q, dest += q * pitch, subsectorGBuffer += q * pitch) { // Is this row of blocks done by this thread? - if (thread->skipped_by_thread(y / q)) continue; + if ((y / q) % thread->num_cores != thread->core) continue; for (int x = minx; x < maxx; x += q) { @@ -1412,7 +1412,7 @@ void ScreenPolyTriangleDrawer::drawsubsector32(const ScreenPolyTriangleDrawerArg } } -void ScreenPolyTriangleDrawer::fill32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread) +void ScreenPolyTriangleDrawer::fill32(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread) { uint32_t *dest = (uint32_t *)args->dest; int pitch = args->pitch; @@ -1487,7 +1487,7 @@ void ScreenPolyTriangleDrawer::fill32(const ScreenPolyTriangleDrawerArgs *args, for (int y = miny; y < maxy; y += q, dest += q * pitch) { // Is this row of blocks done by this thread? - if (thread->skipped_by_thread(y / q)) continue; + if ((y / q) % thread->num_cores != thread->core) continue; for (int x = minx; x < maxx; x += q) { @@ -1603,7 +1603,14 @@ DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args, Pol void DrawPolyTrianglesCommand::Execute(DrawerThread *thread) { - PolyTriangleDrawer::draw_arrays(args, variant, thread); + WorkerThreadData thread_data; + thread_data.core = thread->core; + thread_data.num_cores = thread->num_cores; + thread_data.pass_start_y = thread->pass_start_y; + thread_data.pass_end_y = thread->pass_end_y; + thread_data.temp = thread->dc_temp_rgba; + + PolyTriangleDrawer::draw_arrays(args, variant, &thread_data); } FString DrawPolyTrianglesCommand::DebugInfo() diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 0861e7186..f0ffd1865 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -73,8 +73,8 @@ public: private: static TriVertex shade_vertex(const TriUniforms &uniforms, TriVertex v); - static void draw_arrays(const PolyDrawArgs &args, PolyDrawVariant variant, DrawerThread *thread); - static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *)); + static void draw_arrays(const PolyDrawArgs &args, PolyDrawVariant variant, WorkerThreadData *thread); + static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, WorkerThreadData *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert); @@ -225,41 +225,17 @@ private: std::vector masks; }; -struct ScreenPolyTriangleDrawerArgs -{ - uint8_t *dest; - int pitch; - TriVertex *v1; - TriVertex *v2; - TriVertex *v3; - int clipleft; - int clipright; - int cliptop; - int clipbottom; - const uint8_t *texturePixels; - int textureWidth; - int textureHeight; - uint32_t solidcolor; - const TriUniforms *uniforms; - uint8_t *stencilValues; - uint32_t *stencilMasks; - int stencilPitch; - uint8_t stencilTestValue; - uint8_t stencilWriteValue; - uint32_t *subsectorGBuffer; -}; - class ScreenPolyTriangleDrawer { public: - static void draw(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); - static void fill(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); + static void draw(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread); + static void fill(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread); - static void stencil(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); + static void stencil(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread); - static void draw32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); - static void drawsubsector32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); - static void fill32(const ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread); + static void draw32(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread); + static void drawsubsector32(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread); + static void fill32(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread); private: static float gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); diff --git a/src/r_triangle.cpp b/src/r_triangle.cpp index ff35cc7da..13a8ca292 100644 --- a/src/r_triangle.cpp +++ b/src/r_triangle.cpp @@ -75,7 +75,7 @@ void TriangleDrawer::queue_arrays(const TriUniforms &uniforms, const TriVertex * DrawerCommandQueue::QueueCommand(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, clipdata, texturePixels, textureWidth, textureHeight, solidcolor); } -void TriangleDrawer::draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)) +void TriangleDrawer::draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, WorkerThreadData *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, WorkerThreadData *)) { if (vcount < 3) return; @@ -135,7 +135,7 @@ TriVertex TriangleDrawer::shade_vertex(const TriUniforms &uniforms, TriVertex v) return uniforms.objectToClip * v; } -void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)) +void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenTriangleDrawerArgs *args, WorkerThreadData *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, WorkerThreadData *)) { // Cull, clip and generate additional vertices as needed TriVertex clippedvert[max_additional_vertices]; @@ -295,7 +295,7 @@ void TriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert, in ///////////////////////////////////////////////////////////////////////////// -void ScreenTriangleDrawer::draw(const ScreenTriangleDrawerArgs *args, DrawerThread *thread) +void ScreenTriangleDrawer::draw(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread) { uint8_t *dest = args->dest; int pitch = args->pitch; @@ -538,7 +538,7 @@ void ScreenTriangleDrawer::draw(const ScreenTriangleDrawerArgs *args, DrawerThre } } -void ScreenTriangleDrawer::fill(const ScreenTriangleDrawerArgs *args, DrawerThread *thread) +void ScreenTriangleDrawer::fill(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread) { uint8_t *dest = args->dest; int pitch = args->pitch; @@ -706,7 +706,7 @@ void ScreenTriangleDrawer::fill(const ScreenTriangleDrawerArgs *args, DrawerThre } } -void ScreenTriangleDrawer::draw32(const ScreenTriangleDrawerArgs *args, DrawerThread *thread) +void ScreenTriangleDrawer::draw32(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread) { uint32_t *dest = (uint32_t *)args->dest; int pitch = args->pitch; @@ -873,7 +873,7 @@ void ScreenTriangleDrawer::draw32(const ScreenTriangleDrawerArgs *args, DrawerTh varyingStep[i] = (uint32_t)(step * 0x100000000LL); } - if (!thread->skipped_by_thread(y + iy)) + if ((y + iy) % thread->num_cores == thread->core) { for (int ix = x; ix < x + q; ix++) { @@ -920,7 +920,7 @@ void ScreenTriangleDrawer::draw32(const ScreenTriangleDrawerArgs *args, DrawerTh varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); } - if (!thread->skipped_by_thread(y + iy)) + if ((y + iy) % thread->num_cores == thread->core) { for (int ix = x; ix < x + q; ix++) { @@ -967,7 +967,7 @@ void ScreenTriangleDrawer::draw32(const ScreenTriangleDrawerArgs *args, DrawerTh } } -void ScreenTriangleDrawer::fill32(const ScreenTriangleDrawerArgs *args, DrawerThread *thread) +void ScreenTriangleDrawer::fill32(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread) { uint32_t *dest = (uint32_t *)args->dest; int pitch = args->pitch; @@ -1088,7 +1088,7 @@ void ScreenTriangleDrawer::fill32(const ScreenTriangleDrawerArgs *args, DrawerTh { for (int iy = 0; iy < q; iy++) { - if (!thread->skipped_by_thread(y + iy)) + if ((y + iy) % thread->num_cores == thread->core) { for (int ix = x; ix < x + q; ix++) { @@ -1111,7 +1111,7 @@ void ScreenTriangleDrawer::fill32(const ScreenTriangleDrawerArgs *args, DrawerTh int CX2 = CY2; int CX3 = CY3; - if (!thread->skipped_by_thread(y + iy)) + if ((y + iy) % thread->num_cores == thread->core) { for (int ix = x; ix < x + q; ix++) { @@ -1318,11 +1318,18 @@ void DrawTrianglesCommand::Execute(DrawerThread *thread) thread->triangle_clip_bottom[clipleft + i] = clipdata[cliplength + i]; } + WorkerThreadData thread_data; + thread_data.core = thread->core; + thread_data.num_cores = thread->num_cores; + thread_data.pass_start_y = thread->pass_start_y; + thread_data.pass_end_y = thread->pass_end_y; + thread_data.temp = thread->dc_temp_rgba; + TriangleDrawer::draw_arrays( uniforms, vinput, vcount, mode, ccw, clipleft, clipright, thread->triangle_clip_top, thread->triangle_clip_bottom, texturePixels, textureWidth, textureHeight, solidcolor, - thread, texturePixels ? ScreenTriangleDrawer::draw32 : ScreenTriangleDrawer::fill32); + &thread_data, texturePixels ? ScreenTriangleDrawer::draw32 : ScreenTriangleDrawer::fill32); } FString DrawTrianglesCommand::DebugInfo() diff --git a/src/r_triangle.h b/src/r_triangle.h index a3bdca5ed..6ec413d3f 100644 --- a/src/r_triangle.h +++ b/src/r_triangle.h @@ -26,65 +26,11 @@ #include "r_draw.h" #include "r_thread.h" +#include "r_compiler/llvmdrawers.h" class FTexture; struct ScreenTriangleDrawerArgs; -struct TriVertex -{ - TriVertex() { } - TriVertex(float x, float y, float z, float w, float u, float v) : x(x), y(y), z(z), w(w) { varying[0] = u; varying[1] = v; } - - enum { NumVarying = 2 }; - float x, y, z, w; - float varying[NumVarying]; -}; - -struct TriMatrix -{ - static TriMatrix null(); - static TriMatrix identity(); - static TriMatrix translate(float x, float y, float z); - static TriMatrix scale(float x, float y, float z); - static TriMatrix rotate(float angle, float x, float y, float z); - static TriMatrix swapYZ(); - static TriMatrix perspective(float fovy, float aspect, float near, float far); - static TriMatrix frustum(float left, float right, float bottom, float top, float near, float far); - - static TriMatrix worldToView(); // Software renderer world to view space transform - static TriMatrix viewToClip(); // Software renderer shearing projection - - TriVertex operator*(TriVertex v) const; - TriMatrix operator*(const TriMatrix &m) const; - - float matrix[16]; -}; - -struct TriUniforms -{ - uint32_t light; - uint32_t subsectorDepth; - - uint16_t light_alpha; - uint16_t light_red; - uint16_t light_green; - uint16_t light_blue; - uint16_t fade_alpha; - uint16_t fade_red; - uint16_t fade_green; - uint16_t fade_blue; - uint16_t desaturate; - uint32_t flags; - enum Flags - { - simple_shade = 1, - nearest_filter = 2, - diminishing_lighting = 4 - }; - - TriMatrix objectToClip; -}; - enum class TriangleDrawMode { Normal, @@ -100,8 +46,8 @@ public: private: static TriVertex shade_vertex(const TriUniforms &uniforms, TriVertex v); - static void draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)); - static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *)); + static void draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, WorkerThreadData *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, WorkerThreadData *)); + static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenTriangleDrawerArgs *args, WorkerThreadData *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, WorkerThreadData *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert); @@ -133,11 +79,11 @@ struct ScreenTriangleDrawerArgs class ScreenTriangleDrawer { public: - static void draw(const ScreenTriangleDrawerArgs *args, DrawerThread *thread); - static void fill(const ScreenTriangleDrawerArgs *args, DrawerThread *thread); + static void draw(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread); + static void fill(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread); - static void draw32(const ScreenTriangleDrawerArgs *args, DrawerThread *thread); - static void fill32(const ScreenTriangleDrawerArgs *args, DrawerThread *thread); + static void draw32(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread); + static void fill32(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread); private: static float gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); From 667f35bfcea985d2668aaa71b983c201deda2eae Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 11 Nov 2016 20:12:09 +0100 Subject: [PATCH 1200/1509] Declare structs to LLVM --- src/r_compiler/llvmdrawers.cpp | 65 ++++++++++++++++++++++++++++++++++ src/r_compiler/llvmdrawers.h | 18 +++++----- src/r_poly_triangle.cpp | 18 +++++----- src/r_poly_triangle.h | 16 ++++----- 4 files changed, 91 insertions(+), 26 deletions(-) diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 871e3c5ca..aa9a7b4fa 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -87,6 +87,10 @@ private: static llvm::Type *GetDrawWallArgsStruct(llvm::LLVMContext &context); static llvm::Type *GetDrawSkyArgsStruct(llvm::LLVMContext &context); static llvm::Type *GetWorkerThreadDataStruct(llvm::LLVMContext &context); + static llvm::Type *GetTriVertexStruct(llvm::LLVMContext &context); + static llvm::Type *GetTriMatrixStruct(llvm::LLVMContext &context); + static llvm::Type *GetTriUniformsStruct(llvm::LLVMContext &context); + static llvm::Type *GetTriDrawTriangleArgs(llvm::LLVMContext &context); LLVMProgram mProgram; }; @@ -461,6 +465,67 @@ llvm::Type *LLVMDrawersImpl::GetWorkerThreadDataStruct(llvm::LLVMContext &contex return llvm::StructType::create(context, elements, "ThreadData", false)->getPointerTo(); } +llvm::Type *LLVMDrawersImpl::GetTriVertexStruct(llvm::LLVMContext &context) +{ + std::vector elements; + for (int i = 0; i < 6; i++) + elements.push_back(llvm::Type::getFloatTy(context)); + return llvm::StructType::create(context, elements, "TriVertex", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawersImpl::GetTriMatrixStruct(llvm::LLVMContext &context) +{ + std::vector elements; + for (int i = 0; i < 4 * 4; i++) + elements.push_back(llvm::Type::getFloatTy(context)); + return llvm::StructType::create(context, elements, "TriMatrix", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawersImpl::GetTriUniformsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t subsectorDepth; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; + elements.push_back(GetTriMatrixStruct(context)); // TriMatrix objectToClip + return llvm::StructType::create(context, elements, "TriUniforms", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawersImpl::GetTriDrawTriangleArgs(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *dest; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t pitch; + elements.push_back(GetTriVertexStruct(context)->getPointerTo()); // TriVertex *v1; + elements.push_back(GetTriVertexStruct(context)->getPointerTo()); // TriVertex *v2; + elements.push_back(GetTriVertexStruct(context)->getPointerTo()); // TriVertex *v3; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipleft; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipright; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t cliptop; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipbottom; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *texturePixels; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureWidth; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureHeight; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t solidcolor; + elements.push_back(GetTriUniformsStruct(context)->getPointerTo()); // const TriUniforms *uniforms; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *stencilValues; + elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *stencilMasks; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t stencilPitch; + elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilTestValue; + elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilWriteValue; + elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *subsectorGBuffer; + return llvm::StructType::create(context, elements, "TriDrawTriangle", false)->getPointerTo(); +} + ///////////////////////////////////////////////////////////////////////////// namespace { static bool LogFatalErrors = false; } diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index abf9598e3..d0ee3dcb7 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -236,25 +236,25 @@ struct TriUniforms TriMatrix objectToClip; }; -struct ScreenPolyTriangleDrawerArgs +struct TriDrawTriangleArgs { uint8_t *dest; - int pitch; + int32_t pitch; TriVertex *v1; TriVertex *v2; TriVertex *v3; - int clipleft; - int clipright; - int cliptop; - int clipbottom; + int32_t clipleft; + int32_t clipright; + int32_t cliptop; + int32_t clipbottom; const uint8_t *texturePixels; - int textureWidth; - int textureHeight; + uint32_t textureWidth; + uint32_t textureHeight; uint32_t solidcolor; const TriUniforms *uniforms; uint8_t *stencilValues; uint32_t *stencilMasks; - int stencilPitch; + int32_t stencilPitch; uint8_t stencilTestValue; uint8_t stencilWriteValue; uint32_t *subsectorGBuffer; diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 181b011a4..27177fa3e 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -53,7 +53,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, PolyDrawVaria if (drawargs.vcount < 3) return; - void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, WorkerThreadData *); + void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *); switch (variant) { default: @@ -63,7 +63,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, PolyDrawVaria case PolyDrawVariant::Stencil: drawfunc = ScreenPolyTriangleDrawer::stencil; break; } - ScreenPolyTriangleDrawerArgs args; + TriDrawTriangleArgs args; args.dest = dc_destorg; args.pitch = dc_pitch; args.clipleft = drawargs.clipleft; @@ -128,7 +128,7 @@ TriVertex PolyTriangleDrawer::shade_vertex(const TriUniforms &uniforms, TriVerte return uniforms.objectToClip * v; } -void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, WorkerThreadData *)) +void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *)) { // Cull, clip and generate additional vertices as needed TriVertex clippedvert[max_additional_vertices]; @@ -288,7 +288,7 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert ///////////////////////////////////////////////////////////////////////////// -void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread) +void ScreenPolyTriangleDrawer::draw(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { uint8_t *dest = args->dest; int pitch = args->pitch; @@ -523,7 +523,7 @@ void ScreenPolyTriangleDrawer::draw(const ScreenPolyTriangleDrawerArgs *args, Wo } } -void ScreenPolyTriangleDrawer::fill(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread) +void ScreenPolyTriangleDrawer::fill(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { uint8_t *dest = args->dest; int pitch = args->pitch; @@ -681,7 +681,7 @@ void ScreenPolyTriangleDrawer::fill(const ScreenPolyTriangleDrawerArgs *args, Wo } } -void ScreenPolyTriangleDrawer::stencil(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread) +void ScreenPolyTriangleDrawer::stencil(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { const TriVertex &v1 = *args->v1; const TriVertex &v2 = *args->v2; @@ -833,7 +833,7 @@ void ScreenPolyTriangleDrawer::stencil(const ScreenPolyTriangleDrawerArgs *args, } } -void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread) +void ScreenPolyTriangleDrawer::draw32(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { uint32_t *dest = (uint32_t *)args->dest; int pitch = args->pitch; @@ -1145,7 +1145,7 @@ void ScreenPolyTriangleDrawer::draw32(const ScreenPolyTriangleDrawerArgs *args, } } -void ScreenPolyTriangleDrawer::drawsubsector32(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread) +void ScreenPolyTriangleDrawer::drawsubsector32(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { uint32_t *dest = (uint32_t *)args->dest; int pitch = args->pitch; @@ -1412,7 +1412,7 @@ void ScreenPolyTriangleDrawer::drawsubsector32(const ScreenPolyTriangleDrawerArg } } -void ScreenPolyTriangleDrawer::fill32(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread) +void ScreenPolyTriangleDrawer::fill32(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { uint32_t *dest = (uint32_t *)args->dest; int pitch = args->pitch; diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index f0ffd1865..b66df7898 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -26,7 +26,7 @@ #include "r_triangle.h" -struct ScreenPolyTriangleDrawerArgs; +struct TriDrawTriangleArgs; enum class PolyDrawVariant { @@ -74,7 +74,7 @@ public: private: static TriVertex shade_vertex(const TriUniforms &uniforms, TriVertex v); static void draw_arrays(const PolyDrawArgs &args, PolyDrawVariant variant, WorkerThreadData *thread); - static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, WorkerThreadData *)); + static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert); @@ -228,14 +228,14 @@ private: class ScreenPolyTriangleDrawer { public: - static void draw(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread); - static void fill(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread); + static void draw(const TriDrawTriangleArgs *args, WorkerThreadData *thread); + static void fill(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - static void stencil(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread); + static void stencil(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - static void draw32(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread); - static void drawsubsector32(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread); - static void fill32(const ScreenPolyTriangleDrawerArgs *args, WorkerThreadData *thread); + static void draw32(const TriDrawTriangleArgs *args, WorkerThreadData *thread); + static void drawsubsector32(const TriDrawTriangleArgs *args, WorkerThreadData *thread); + static void fill32(const TriDrawTriangleArgs *args, WorkerThreadData *thread); private: static float gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); From c852b6c5e9a9a69c0fb8e57d57aea65b82f57deb Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 12 Nov 2016 00:50:21 +0100 Subject: [PATCH 1201/1509] Add codegen for one of the triangle variants --- src/CMakeLists.txt | 1 + .../fixedfunction/drawtrianglecodegen.cpp | 483 ++++++++++++++++++ .../fixedfunction/drawtrianglecodegen.h | 115 +++++ src/r_compiler/llvmdrawers.cpp | 45 +- src/r_compiler/llvmdrawers.h | 16 + src/r_compiler/ssa/ssa_bool.cpp | 5 + src/r_compiler/ssa/ssa_bool.h | 2 + src/r_compiler/ssa/ssa_float.cpp | 30 ++ src/r_compiler/ssa/ssa_float.h | 5 + src/r_compiler/ssa/ssa_if_block.cpp | 6 + src/r_compiler/ssa/ssa_if_block.h | 1 + src/r_compiler/ssa/ssa_int.cpp | 12 +- src/r_compiler/ssa/ssa_int.h | 3 +- src/r_compiler/ssa/ssa_scope.cpp | 2 +- src/r_poly.cpp | 18 +- src/r_poly.h | 2 +- src/r_poly_triangle.cpp | 15 +- src/r_poly_triangle.h | 16 +- 18 files changed, 739 insertions(+), 38 deletions(-) create mode 100644 src/r_compiler/fixedfunction/drawtrianglecodegen.cpp create mode 100644 src/r_compiler/fixedfunction/drawtrianglecodegen.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e6ee761b0..43a94f91a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1487,6 +1487,7 @@ set (PCH_SOURCES r_compiler/fixedfunction/drawwallcodegen.cpp r_compiler/fixedfunction/drawcolumncodegen.cpp r_compiler/fixedfunction/drawskycodegen.cpp + r_compiler/fixedfunction/drawtrianglecodegen.cpp r_data/sprites.cpp r_data/voxels.cpp r_data/renderstyle.cpp diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp new file mode 100644 index 000000000..13fb40d04 --- /dev/null +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -0,0 +1,483 @@ +/* +** DrawTriangle code generation +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include "i_system.h" +#include "r_compiler/llvm_include.h" +#include "r_compiler/fixedfunction/drawtrianglecodegen.h" +#include "r_compiler/ssa/ssa_function.h" +#include "r_compiler/ssa/ssa_scope.h" +#include "r_compiler/ssa/ssa_for_block.h" +#include "r_compiler/ssa/ssa_if_block.h" +#include "r_compiler/ssa/ssa_stack.h" +#include "r_compiler/ssa/ssa_function.h" +#include "r_compiler/ssa/ssa_struct_type.h" +#include "r_compiler/ssa/ssa_value.h" + +void DrawTriangleCodegen::Generate(TriDrawVariant variant, bool truecolor, SSAValue args, SSAValue thread_data) +{ + LoadArgs(variant, truecolor, args, thread_data); + Setup(variant, truecolor); + LoopBlockY(variant, truecolor); +} + +void DrawTriangleCodegen::Setup(TriDrawVariant variant, bool truecolor) +{ + int pixelsize = truecolor ? 4 : 1; + + // 28.4 fixed-point coordinates + Y1 = SSAInt(SSAFloat::round(16.0f * v1.y), false); + Y2 = SSAInt(SSAFloat::round(16.0f * v2.y), false); + Y3 = SSAInt(SSAFloat::round(16.0f * v3.y), false); + + X1 = SSAInt(SSAFloat::round(16.0f * v1.x), false); + X2 = SSAInt(SSAFloat::round(16.0f * v2.x), false); + X3 = SSAInt(SSAFloat::round(16.0f * v3.x), false); + + // Deltas + DX12 = X1 - X2; + DX23 = X2 - X3; + DX31 = X3 - X1; + + DY12 = Y1 - Y2; + DY23 = Y2 - Y3; + DY31 = Y3 - Y1; + + // Fixed-point deltas + FDX12 = DX12 << 4; + FDX23 = DX23 << 4; + FDX31 = DX31 << 4; + + FDY12 = DY12 << 4; + FDY23 = DY23 << 4; + FDY31 = DY31 << 4; + + // Bounding rectangle + minx = SSAInt::MAX((SSAInt::MIN(SSAInt::MIN(X1, X2), X3) + 0xF) >> 4, clipleft); + maxx = SSAInt::MIN((SSAInt::MAX(SSAInt::MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); + miny = SSAInt::MAX((SSAInt::MIN(SSAInt::MIN(Y1, Y2), Y3) + 0xF) >> 4, cliptop); + maxy = SSAInt::MIN((SSAInt::MAX(SSAInt::MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); + + SSAIfBlock if0; + if0.if_block(minx >= maxx || miny >= maxy); + if0.end_retvoid(); + + // Start in corner of 8x8 block + minx = minx & ~(q - 1); + miny = miny & ~(q - 1); + + dest = dest[miny * pitch * pixelsize]; + subsectorGBuffer = subsectorGBuffer[miny * pitch]; + + // Half-edge constants + C1 = DY12 * X1 - DX12 * Y1; + C2 = DY23 * X2 - DX23 * Y2; + C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + SSAIfBlock if1; + if1.if_block(DY12 < SSAInt(0) || (DY12 == SSAInt(0) && DX12 > SSAInt(0))); + stack_C1.store(C1 + 1); + if1.else_block(); + stack_C1.store(C1); + if1.end_block(); + C1 = stack_C1.load(); + SSAIfBlock if2; + if2.if_block(DY23 < SSAInt(0) || (DY23 == SSAInt(0) && DX23 > SSAInt(0))); + stack_C2.store(C2 + 1); + if2.else_block(); + stack_C2.store(C2); + if2.end_block(); + C2 = stack_C2.load(); + SSAIfBlock if3; + if3.if_block(DY31 < SSAInt(0) || (DY31 == SSAInt(0) && DX31 > SSAInt(0))); + stack_C3.store(C3 + 1); + if3.else_block(); + stack_C3.store(C3); + if3.end_block(); + C3 = stack_C3.load(); + + // Gradients + gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + startW = v1.w + gradWX * (SSAFloat(minx) - v1.x) + gradWY * (SSAFloat(miny) - v1.y); + for (int i = 0; i < TriVertex::NumVarying; i++) + { + gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (SSAFloat(minx) - v1.x) + gradVaryingY[i] * (SSAFloat(miny) - v1.y); + } +} + +SSAFloat DrawTriangleCodegen::gradx(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2) +{ + SSAFloat top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); + SSAFloat bottom = (x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2); + return top / bottom; +} + +SSAFloat DrawTriangleCodegen::grady(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2) +{ + SSAFloat top = (c1 - c2) * (x0 - x2) - (c0 - c2) * (x1 - x2); + SSAFloat bottom = (x0 - x2) * (y1 - y2) - (x1 - x2) * (y0 - y2); + return top / bottom; +} + +void DrawTriangleCodegen::LoopBlockY(TriDrawVariant variant, bool truecolor) +{ + int pixelsize = truecolor ? 4 : 1; + + stack_y.store(miny); + stack_dest.store(dest); + stack_subsectorGBuffer.store(subsectorGBuffer); + + SSAForBlock loop; + y = stack_y.load(); + dest = stack_dest.load(); + subsectorGBuffer = stack_subsectorGBuffer.load(); + loop.loop_block(y < maxy, 0); + { + SSAIfBlock branch; + branch.if_block((y / q) % thread.num_cores == thread.core); + { + LoopBlockX(variant, truecolor); + } + branch.end_block(); + + stack_dest.store(dest[q * pitch * pixelsize]); + stack_subsectorGBuffer.store(subsectorGBuffer[q * pitch]); + stack_y.store(y + q); + } + loop.end_block(); +} + +void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) +{ + stack_x.store(minx); + + SSAForBlock loop; + x = stack_x.load(); + loop.loop_block(x < maxx, 0); + { + // Corners of block + x0 = x << 4; + x1 = (x + q - 1) << 4; + y0 = y << 4; + y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + SSABool a00 = C1 + DX12 * y0 - DY12 * x0 > SSAInt(0); + SSABool a10 = C1 + DX12 * y0 - DY12 * x1 > SSAInt(0); + SSABool a01 = C1 + DX12 * y1 - DY12 * x0 > SSAInt(0); + SSABool a11 = C1 + DX12 * y1 - DY12 * x1 > SSAInt(0); + + SSAInt a = (a00.zext_int() << 0) | (a10.zext_int() << 1) | (a01.zext_int() << 2) | (a11.zext_int() << 3); + + SSABool b00 = C2 + DX23 * y0 - DY23 * x0 > SSAInt(0); + SSABool b10 = C2 + DX23 * y0 - DY23 * x1 > SSAInt(0); + SSABool b01 = C2 + DX23 * y1 - DY23 * x0 > SSAInt(0); + SSABool b11 = C2 + DX23 * y1 - DY23 * x1 > SSAInt(0); + SSAInt b = (b00.zext_int() << 0) | (b10.zext_int() << 1) | (b01.zext_int() << 2) | (b11.zext_int() << 3); + + SSABool c00 = C3 + DX31 * y0 - DY31 * x0 > SSAInt(0); + SSABool c10 = C3 + DX31 * y0 - DY31 * x1 > SSAInt(0); + SSABool c01 = C3 + DX31 * y1 - DY31 * x0 > SSAInt(0); + SSABool c11 = C3 + DX31 * y1 - DY31 * x1 > SSAInt(0); + SSAInt c = (c00.zext_int() << 0) | (c10.zext_int() << 1) | (c01.zext_int() << 2) | (c11.zext_int() << 3); + + // Skip block when outside an edge + SSAIfBlock branch; + branch.if_block(!(a == SSAInt(0) || b == SSAInt(0) || c == SSAInt(0))); + + // Check if block needs clipping + SSABool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); + + // Calculate varying variables for affine block + SSAFloat offx0 = SSAFloat(x - minx) + 0.5f; + SSAFloat offy0 = SSAFloat(y - miny) + 0.5f; + SSAFloat offx1 = offx0 + SSAFloat(q); + SSAFloat offy1 = offy0 + SSAFloat(q); + SSAFloat rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); + SSAFloat rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); + SSAFloat rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); + SSAFloat rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; + varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; + varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); + varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); + } + + SSAFloat globVis = SSAFloat(1706.0f); + SSAFloat vis = globVis / rcpWTL; + SSAFloat shade = 64.0f - (SSAFloat(light * 255 / 256) + 12.0f) * 32.0f / 128.0f; + SSAFloat lightscale = SSAFloat::clamp((shade - SSAFloat::MIN(SSAFloat(24.0f), vis)) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)); + diminishedlight = SSAInt(SSAFloat::clamp((1.0f - lightscale) * 256.0f + 0.5f, SSAFloat(0.0f), SSAFloat(256.0f)), false); + + // Accept whole block when totally covered + SSAIfBlock branch_covered; + branch_covered.if_block(a == SSAInt(0xF) && b == SSAInt(0xF) && c == SSAInt(0xF) && !clipneeded); + { + LoopFullBlock(variant, truecolor); + } + branch_covered.else_block(); + { + LoopPartialBlock(variant, truecolor); + } + branch_covered.end_block(); + + branch.end_block(); + + stack_x.store(x + q); + } + loop.end_block(); +} + +void DrawTriangleCodegen::LoopFullBlock(TriDrawVariant variant, bool truecolor) +{ + int pixelsize = truecolor ? 4 : 1; + + stack_iy.store(SSAInt(0)); + stack_buffer.store(dest); + stack_subsectorbuffer.store(subsectorGBuffer); + + SSAForBlock loopy; + SSAInt iy = stack_iy.load(); + SSAUBytePtr buffer = stack_buffer.load(); + SSAIntPtr subsectorbuffer = stack_subsectorbuffer.load(); + loopy.loop_block(iy < SSAInt(q), q); + { + SSAInt varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + SSAFloat pos = varyingTL[i] + varyingBL[i] * SSAFloat(iy); + SSAFloat step = (varyingTR[i] + varyingBR[i] * SSAFloat(iy) - pos) * (1.0f / q); + + stack_varying[i].store(SSAInt((pos - SSAFloat::floor(pos)) * SSAFloat((float)0x100000000LL), true)); + varyingStep[i] = SSAInt(step * SSAFloat((float)0x100000000LL), true); + } + + stack_ix.store(x); + SSAForBlock loopx; + SSAInt ix = stack_ix.load(); + SSAInt varying[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] = stack_varying[i].load(); + loopx.loop_block(ix < x + q, q); + { + SSAIfBlock branch; + branch.if_block(subsectorbuffer[ix].load(true) >= subsectorDepth); + { + if (truecolor) + ProcessPixel(buffer[ix * 4], subsectorbuffer[ix], varying, variant, truecolor); + else + ProcessPixel(buffer[ix], subsectorbuffer[ix], varying, variant, truecolor); + } + branch.end_block(); + + for (int i = 0; i < TriVertex::NumVarying; i++) + stack_varying[i].store(varying[i] + varyingStep[i]); + + stack_ix.store(ix + 1); + } + loopx.end_block(); + + stack_buffer.store(buffer[pitch * pixelsize]); + stack_subsectorbuffer.store(subsectorbuffer[pitch]); + stack_iy.store(iy + 1); + } + loopy.end_block(); +} + +void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolor) +{ + int pixelsize = truecolor ? 4 : 1; + + stack_CY1.store(C1 + DX12 * y0 - DY12 * x0); + stack_CY2.store(C2 + DX23 * y0 - DY23 * x0); + stack_CY3.store(C3 + DX31 * y0 - DY31 * x0); + stack_iy.store(SSAInt(0)); + stack_buffer.store(dest); + stack_subsectorbuffer.store(subsectorGBuffer); + + SSAForBlock loopy; + SSAInt iy = stack_iy.load(); + SSAUBytePtr buffer = stack_buffer.load(); + SSAIntPtr subsectorbuffer = stack_subsectorbuffer.load(); + SSAInt CY1 = stack_CY1.load(); + SSAInt CY2 = stack_CY2.load(); + SSAInt CY3 = stack_CY3.load(); + loopy.loop_block(iy < SSAInt(q), q); + { + SSAInt varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + SSAFloat pos = varyingTL[i] + varyingBL[i] * SSAFloat(iy); + SSAFloat step = (varyingTR[i] + varyingBR[i] * SSAFloat(iy) - pos) * (1.0f / q); + + stack_varying[i].store(SSAInt((pos - SSAFloat::floor(pos)) * SSAFloat((float)0x100000000LL), true)); + varyingStep[i] = SSAInt(step * SSAFloat((float)0x100000000LL), true); + } + + stack_CX1.store(CY1); + stack_CX2.store(CY2); + stack_CX3.store(CY3); + stack_ix.store(SSAInt(0)); + + SSAForBlock loopx; + SSAInt ix = stack_ix.load(); + SSAInt CX1 = stack_CX1.load(); + SSAInt CX2 = stack_CX2.load(); + SSAInt CX3 = stack_CX3.load(); + SSAInt varying[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] = stack_varying[i].load(); + loopx.loop_block(ix < SSAInt(q), q); + { + SSABool visible = (ix + x >= clipleft) && (ix + x < clipright) && (cliptop <= y + iy) && (clipbottom > y + iy); + + SSAIfBlock branch; + branch.if_block(CX1 > SSAInt(0) && CX2 > SSAInt(0) && CX3 > SSAInt(0) && visible && subsectorbuffer[ix + x].load(true) >= subsectorDepth); + { + if (truecolor) + ProcessPixel(buffer[(ix + x) * 4], subsectorbuffer[ix + x], varying, variant, truecolor); + else + ProcessPixel(buffer[ix + x], subsectorbuffer[ix + x], varying, variant, truecolor); + } + branch.end_block(); + + for (int i = 0; i < TriVertex::NumVarying; i++) + stack_varying[i].store(varying[i] + varyingStep[i]); + + stack_CX1.store(CX1 - FDY12); + stack_CX2.store(CX2 - FDY23); + stack_CX3.store(CX3 - FDY31); + stack_ix.store(ix + 1); + } + loopx.end_block(); + + stack_CY1.store(CY1 + FDX12); + stack_CY2.store(CY2 + FDX23); + stack_CY3.store(CY3 + FDX31); + stack_buffer.store(buffer[pitch * pixelsize]); + stack_subsectorbuffer.store(subsectorbuffer[pitch]); + stack_iy.store(iy + 1); + } + loopy.end_block(); +} + +void DrawTriangleCodegen::ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbuffer, SSAInt *varying, TriDrawVariant variant, bool truecolor) +{ + SSAInt ufrac = varying[0]; + SSAInt vfrac = varying[1]; + + SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; + SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; + SSAInt uvoffset = upos * textureHeight + vpos; + + if (truecolor) + { + SSAVec4i fg = texturePixels[uvoffset * 4].load_vec4ub(true); + SSAInt fg_alpha = fg[3]; + fg = (fg * diminishedlight) >> 8; + fg.insert(3, fg_alpha); + + SSAIfBlock branch_transparency; + branch_transparency.if_block(fg_alpha > SSAInt(127)); + { + buffer.store_vec4ub(fg); + } + branch_transparency.end_block(); + } + else + { + SSAUByte palindex = texturePixels[uvoffset].load(true); + SSAIfBlock branch_transparency; + branch_transparency.if_block(!(palindex.zext_int() == SSAInt(0))); + { + buffer.store(palindex); + } + branch_transparency.end_block(); + } +} + +void DrawTriangleCodegen::LoadArgs(TriDrawVariant variant, bool truecolor, SSAValue args, SSAValue thread_data) +{ + dest = args[0][0].load(true); + pitch = args[0][1].load(true); + v1 = LoadTriVertex(args[0][2].load(true)); + v2 = LoadTriVertex(args[0][3].load(true)); + v3 = LoadTriVertex(args[0][4].load(true)); + clipleft = args[0][5].load(true); + clipright = args[0][6].load(true); + cliptop = args[0][7].load(true); + clipbottom = args[0][8].load(true); + texturePixels = args[0][9].load(true); + textureWidth = args[0][10].load(true); + textureHeight = args[0][11].load(true); + solidcolor = args[0][12].load(true); + LoadUniforms(args[0][13].load(true)); + stencilValues = args[0][14].load(true); + stencilMasks = args[0][15].load(true); + stencilPitch = args[0][16].load(true); + stencilTestValue = args[0][17].load(true); + stencilWriteValue = args[0][18].load(true); + subsectorGBuffer = args[0][19].load(true); + + thread.core = thread_data[0][0].load(true); + thread.num_cores = thread_data[0][1].load(true); +} + +SSATriVertex DrawTriangleCodegen::LoadTriVertex(SSAValue ptr) +{ + SSATriVertex v; + v.x = ptr[0][0].load(true); + v.y = ptr[0][1].load(true); + v.z = ptr[0][2].load(true); + v.w = ptr[0][3].load(true); + for (int i = 0; i < TriVertex::NumVarying; i++) + v.varying[i] = ptr[0][4 + i].load(true); + return v; +} + +void DrawTriangleCodegen::LoadUniforms(SSAValue uniforms) +{ + light = uniforms[0][0].load(true); + subsectorDepth = uniforms[0][1].load(true); + + SSAShort light_alpha = uniforms[0][2].load(true); + SSAShort light_red = uniforms[0][3].load(true); + SSAShort light_green = uniforms[0][4].load(true); + SSAShort light_blue = uniforms[0][5].load(true); + SSAShort fade_alpha = uniforms[0][6].load(true); + SSAShort fade_red = uniforms[0][7].load(true); + SSAShort fade_green = uniforms[0][8].load(true); + SSAShort fade_blue = uniforms[0][9].load(true); + SSAShort desaturate = uniforms[0][10].load(true); + SSAInt flags = uniforms[0][11].load(true); + shade_constants.light = SSAVec4i(light_blue.zext_int(), light_green.zext_int(), light_red.zext_int(), light_alpha.zext_int()); + shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); + shade_constants.desaturate = desaturate.zext_int(); + + is_simple_shade = (flags & TriUniforms::simple_shade) == SSAInt(TriUniforms::simple_shade); + is_nearest_filter = (flags & TriUniforms::nearest_filter) == SSAInt(TriUniforms::nearest_filter); +} diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.h b/src/r_compiler/fixedfunction/drawtrianglecodegen.h new file mode 100644 index 000000000..08b848b91 --- /dev/null +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.h @@ -0,0 +1,115 @@ +/* +** DrawTriangle code generation +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +#include "drawercodegen.h" + +struct SSATriVertex +{ + SSAFloat x, y, z, w; + SSAFloat varying[TriVertex::NumVarying]; +}; + +class DrawTriangleCodegen : public DrawerCodegen +{ +public: + void Generate(TriDrawVariant variant, bool truecolor, SSAValue args, SSAValue thread_data); + +private: + void LoadArgs(TriDrawVariant variant, bool truecolor, SSAValue args, SSAValue thread_data); + SSATriVertex LoadTriVertex(SSAValue v); + void LoadUniforms(SSAValue uniforms); + void Setup(TriDrawVariant variant, bool truecolor); + void LoopBlockY(TriDrawVariant variant, bool truecolor); + void LoopBlockX(TriDrawVariant variant, bool truecolor); + void LoopFullBlock(TriDrawVariant variant, bool truecolor); + void LoopPartialBlock(TriDrawVariant variant, bool truecolor); + + void ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbuffer, SSAInt *varying, TriDrawVariant variant, bool truecolor); + + SSAFloat gradx(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2); + SSAFloat grady(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2); + + SSAStack stack_C1, stack_C2, stack_C3; + SSAStack stack_y; + SSAStack stack_dest; + SSAStack stack_subsectorGBuffer; + SSAStack stack_x; + SSAStack stack_buffer; + SSAStack stack_subsectorbuffer; + SSAStack stack_iy, stack_ix; + SSAStack stack_varying[TriVertex::NumVarying]; + SSAStack stack_CY1, stack_CY2, stack_CY3; + SSAStack stack_CX1, stack_CX2, stack_CX3; + + SSAUBytePtr dest; + SSAInt pitch; + SSATriVertex v1; + SSATriVertex v2; + SSATriVertex v3; + SSAInt clipleft; + SSAInt clipright; + SSAInt cliptop; + SSAInt clipbottom; + SSAUBytePtr texturePixels; + SSAInt textureWidth; + SSAInt textureHeight; + SSAInt solidcolor; + + SSAInt light; + SSAInt subsectorDepth; + SSAShadeConstants shade_constants; + SSABool is_simple_shade; + SSABool is_nearest_filter; + + SSAUBytePtr stencilValues; + SSAIntPtr stencilMasks; + SSAInt stencilPitch; + SSAUByte stencilTestValue; + SSAUByte stencilWriteValue; + SSAIntPtr subsectorGBuffer; + + SSAWorkerThread thread; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + SSAInt Y1, Y2, Y3; + SSAInt X1, X2, X3; + SSAInt DX12, DX23, DX31; + SSAInt DY12, DY23, DY31; + SSAInt FDX12, FDX23, FDX31; + SSAInt FDY12, FDY23, FDY31; + SSAInt minx, maxx, miny, maxy; + SSAInt C1, C2, C3; + SSAFloat gradWX, gradWY, startW; + SSAFloat gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; + + SSAInt x, y; + SSAInt x0, x1, y0, y1; + SSAInt diminishedlight; + SSAFloat varyingTL[TriVertex::NumVarying]; + SSAFloat varyingTR[TriVertex::NumVarying]; + SSAFloat varyingBL[TriVertex::NumVarying]; + SSAFloat varyingBR[TriVertex::NumVarying]; +}; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index aa9a7b4fa..b3d893153 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -26,6 +26,7 @@ #include "r_compiler/fixedfunction/drawwallcodegen.h" #include "r_compiler/fixedfunction/drawcolumncodegen.h" #include "r_compiler/fixedfunction/drawskycodegen.h" +#include "r_compiler/fixedfunction/drawtrianglecodegen.h" #include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_scope.h" #include "r_compiler/ssa/ssa_for_block.h" @@ -81,6 +82,7 @@ private: void CodegenDrawSpan(const char *name, DrawSpanVariant variant); void CodegenDrawWall(const char *name, DrawWallVariant variant, int columns); void CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns); + void CodegenDrawTriangle(const char *name, TriDrawVariant variant, bool truecolor); static llvm::Type *GetDrawColumnArgsStruct(llvm::LLVMContext &context); static llvm::Type *GetDrawSpanArgsStruct(llvm::LLVMContext &context); @@ -184,6 +186,13 @@ LLVMDrawersImpl::LLVMDrawersImpl() CodegenDrawSky("DrawSky4", DrawSkyVariant::Single, 4); CodegenDrawSky("DrawDoubleSky1", DrawSkyVariant::Double, 1); CodegenDrawSky("DrawDoubleSky4", DrawSkyVariant::Double, 4); + CodegenDrawTriangle("TriDraw8", TriDrawVariant::Draw, false); + CodegenDrawTriangle("TriDraw32", TriDrawVariant::Draw, true); + CodegenDrawTriangle("TriDrawSubsector8", TriDrawVariant::DrawSubsector, false); + CodegenDrawTriangle("TriDrawSubsector32", TriDrawVariant::DrawSubsector, true); + CodegenDrawTriangle("TriFill8", TriDrawVariant::Fill, false); + CodegenDrawTriangle("TriFill32", TriDrawVariant::Fill, true); + CodegenDrawTriangle("TriStencil", TriDrawVariant::Stencil, false); mProgram.CreateEE(); @@ -249,6 +258,13 @@ LLVMDrawersImpl::LLVMDrawersImpl() DrawSky4 = mProgram.GetProcAddress("DrawSky4"); DrawDoubleSky1 = mProgram.GetProcAddress("DrawDoubleSky1"); DrawDoubleSky4 = mProgram.GetProcAddress("DrawDoubleSky4"); + TriDraw8 = mProgram.GetProcAddress("TriDraw8"); + TriDraw32 = mProgram.GetProcAddress("TriDraw32"); + TriDrawSubsector8 = mProgram.GetProcAddress("TriDrawSubsector8"); + TriDrawSubsector32 = mProgram.GetProcAddress("TriDrawSubsector32"); + TriFill8 = mProgram.GetProcAddress("TriFill8"); + TriFill32 = mProgram.GetProcAddress("TriFill32"); + TriStencil = mProgram.GetProcAddress("TriStencil"); #if 0 std::vector foo(1024 * 4); @@ -359,6 +375,25 @@ void LLVMDrawersImpl::CodegenDrawSky(const char *name, DrawSkyVariant variant, i I_FatalError("verifyFunction failed for CodegenDrawSky()"); } +void LLVMDrawersImpl::CodegenDrawTriangle(const char *name, TriDrawVariant variant, bool truecolor) +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function(name); + function.add_parameter(GetTriDrawTriangleArgs(mProgram.context())); + function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); + function.create_public(); + + DrawTriangleCodegen codegen; + codegen.Generate(variant, truecolor, function.parameter(0), function.parameter(1)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + I_FatalError("verifyFunction failed for CodegenDrawTriangle()"); +} + llvm::Type *LLVMDrawersImpl::GetDrawColumnArgsStruct(llvm::LLVMContext &context) { std::vector elements; @@ -468,7 +503,7 @@ llvm::Type *LLVMDrawersImpl::GetWorkerThreadDataStruct(llvm::LLVMContext &contex llvm::Type *LLVMDrawersImpl::GetTriVertexStruct(llvm::LLVMContext &context) { std::vector elements; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 4 + TriVertex::NumVarying; i++) elements.push_back(llvm::Type::getFloatTy(context)); return llvm::StructType::create(context, elements, "TriVertex", false)->getPointerTo(); } @@ -505,9 +540,9 @@ llvm::Type *LLVMDrawersImpl::GetTriDrawTriangleArgs(llvm::LLVMContext &context) std::vector elements; elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *dest; elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t pitch; - elements.push_back(GetTriVertexStruct(context)->getPointerTo()); // TriVertex *v1; - elements.push_back(GetTriVertexStruct(context)->getPointerTo()); // TriVertex *v2; - elements.push_back(GetTriVertexStruct(context)->getPointerTo()); // TriVertex *v3; + elements.push_back(GetTriVertexStruct(context)); // TriVertex *v1; + elements.push_back(GetTriVertexStruct(context)); // TriVertex *v2; + elements.push_back(GetTriVertexStruct(context)); // TriVertex *v3; elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipleft; elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipright; elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t cliptop; @@ -516,7 +551,7 @@ llvm::Type *LLVMDrawersImpl::GetTriDrawTriangleArgs(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureWidth; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureHeight; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t solidcolor; - elements.push_back(GetTriUniformsStruct(context)->getPointerTo()); // const TriUniforms *uniforms; + elements.push_back(GetTriUniformsStruct(context)); // const TriUniforms *uniforms; elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *stencilValues; elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *stencilMasks; elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t stencilPitch; diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index d0ee3dcb7..f8b49e9be 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -260,6 +260,14 @@ struct TriDrawTriangleArgs uint32_t *subsectorGBuffer; }; +enum class TriDrawVariant +{ + Draw, + Fill, + DrawSubsector, + Stencil, +}; + class LLVMDrawers { public: @@ -335,6 +343,14 @@ public: void(*DrawDoubleSky1)(const DrawSkyArgs *, const WorkerThreadData *) = nullptr; void(*DrawDoubleSky4)(const DrawSkyArgs *, const WorkerThreadData *) = nullptr; + void(*TriDraw8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + void(*TriDraw32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + void(*TriDrawSubsector8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + void(*TriDrawSubsector32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + void(*TriFill8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + void(*TriFill32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + void(*TriStencil)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + private: static LLVMDrawers *Singleton; }; diff --git a/src/r_compiler/ssa/ssa_bool.cpp b/src/r_compiler/ssa/ssa_bool.cpp index c3c4c72b4..d23d9e8ae 100644 --- a/src/r_compiler/ssa/ssa_bool.cpp +++ b/src/r_compiler/ssa/ssa_bool.cpp @@ -44,6 +44,11 @@ llvm::Type *SSABool::llvm_type() return llvm::Type::getInt1Ty(SSAScope::context()); } +SSAInt SSABool::zext_int() +{ + return SSAInt::from_llvm(SSAScope::builder().CreateZExt(v, SSAInt::llvm_type(), SSAScope::hint())); +} + SSABool operator&&(const SSABool &a, const SSABool &b) { return SSABool::from_llvm(SSAScope::builder().CreateAnd(a.v, b.v, SSAScope::hint())); diff --git a/src/r_compiler/ssa/ssa_bool.h b/src/r_compiler/ssa/ssa_bool.h index df8b66d51..4c04941d5 100644 --- a/src/r_compiler/ssa/ssa_bool.h +++ b/src/r_compiler/ssa/ssa_bool.h @@ -37,6 +37,8 @@ public: static SSABool from_llvm(llvm::Value *v) { return SSABool(v); } static llvm::Type *llvm_type(); + SSAInt zext_int(); + llvm::Value *v; }; diff --git a/src/r_compiler/ssa/ssa_float.cpp b/src/r_compiler/ssa/ssa_float.cpp index 07f18fb56..77cef29ff 100644 --- a/src/r_compiler/ssa/ssa_float.cpp +++ b/src/r_compiler/ssa/ssa_float.cpp @@ -24,6 +24,7 @@ #include "ssa_float.h" #include "ssa_int.h" #include "ssa_scope.h" +#include "ssa_bool.h" SSAFloat::SSAFloat() : v(0) @@ -111,6 +112,35 @@ SSAFloat SSAFloat::fma(SSAFloat a, SSAFloat b, SSAFloat c) return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::fma, params), args, SSAScope::hint())); } +SSAFloat SSAFloat::round(SSAFloat val) +{ + std::vector params; + params.push_back(SSAFloat::llvm_type()); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::round, params), val.v, SSAScope::hint())); +} + +SSAFloat SSAFloat::floor(SSAFloat val) +{ + std::vector params; + params.push_back(SSAFloat::llvm_type()); + return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::floor, params), val.v, SSAScope::hint())); +} + +SSAFloat SSAFloat::MIN(SSAFloat a, SSAFloat b) +{ + return SSAFloat::from_llvm(SSAScope::builder().CreateSelect((a < b).v, a.v, b.v, SSAScope::hint())); +} + +SSAFloat SSAFloat::MAX(SSAFloat a, SSAFloat b) +{ + return SSAFloat::from_llvm(SSAScope::builder().CreateSelect((a > b).v, a.v, b.v, SSAScope::hint())); +} + +SSAFloat SSAFloat::clamp(SSAFloat a, SSAFloat b, SSAFloat c) +{ + return SSAFloat::MAX(SSAFloat::MIN(a, c), b); +} + SSAFloat operator+(const SSAFloat &a, const SSAFloat &b) { return SSAFloat::from_llvm(SSAScope::builder().CreateFAdd(a.v, b.v, SSAScope::hint())); diff --git a/src/r_compiler/ssa/ssa_float.h b/src/r_compiler/ssa/ssa_float.h index 8f2f22ba6..9386db017 100644 --- a/src/r_compiler/ssa/ssa_float.h +++ b/src/r_compiler/ssa/ssa_float.h @@ -43,6 +43,11 @@ public: static SSAFloat exp(SSAFloat val); static SSAFloat log(SSAFloat val); static SSAFloat fma(SSAFloat a, SSAFloat b, SSAFloat c); + static SSAFloat round(SSAFloat val); + static SSAFloat floor(SSAFloat val); + static SSAFloat MIN(SSAFloat a, SSAFloat b); + static SSAFloat MAX(SSAFloat a, SSAFloat b); + static SSAFloat clamp(SSAFloat a, SSAFloat b, SSAFloat c); llvm::Value *v; }; diff --git a/src/r_compiler/ssa/ssa_if_block.cpp b/src/r_compiler/ssa/ssa_if_block.cpp index c95d7e350..6d36faf49 100644 --- a/src/r_compiler/ssa/ssa_if_block.cpp +++ b/src/r_compiler/ssa/ssa_if_block.cpp @@ -50,3 +50,9 @@ void SSAIfBlock::end_block() SSAScope::builder().CreateBr(end_basic_block); SSAScope::builder().SetInsertPoint(end_basic_block); } + +void SSAIfBlock::end_retvoid() +{ + SSAScope::builder().CreateRetVoid(); + SSAScope::builder().SetInsertPoint(end_basic_block); +} diff --git a/src/r_compiler/ssa/ssa_if_block.h b/src/r_compiler/ssa/ssa_if_block.h index e46276575..b958883eb 100644 --- a/src/r_compiler/ssa/ssa_if_block.h +++ b/src/r_compiler/ssa/ssa_if_block.h @@ -32,6 +32,7 @@ public: void if_block(SSABool true_condition); void else_block(); void end_block(); + void end_retvoid(); private: llvm::BasicBlock *if_basic_block; diff --git a/src/r_compiler/ssa/ssa_int.cpp b/src/r_compiler/ssa/ssa_int.cpp index 78ea01595..ac14af8b6 100644 --- a/src/r_compiler/ssa/ssa_int.cpp +++ b/src/r_compiler/ssa/ssa_int.cpp @@ -37,10 +37,13 @@ SSAInt::SSAInt(int constant) v = llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, constant, true)); } -SSAInt::SSAInt(SSAFloat f) +SSAInt::SSAInt(SSAFloat f, bool uint) : v(0) { - v = SSAScope::builder().CreateFPToSI(f.v, llvm::Type::getInt32Ty(SSAScope::context()), SSAScope::hint()); + if (uint) + v = SSAScope::builder().CreateFPToUI(f.v, llvm::Type::getInt32Ty(SSAScope::context()), SSAScope::hint()); + else + v = SSAScope::builder().CreateFPToSI(f.v, llvm::Type::getInt32Ty(SSAScope::context()), SSAScope::hint()); } SSAInt::SSAInt(llvm::Value *v) @@ -63,6 +66,11 @@ SSAInt SSAInt::MAX(SSAInt a, SSAInt b) return SSAInt::from_llvm(SSAScope::builder().CreateSelect((a > b).v, a.v, b.v, SSAScope::hint())); } +SSAInt SSAInt::clamp(SSAInt a, SSAInt b, SSAInt c) +{ + return SSAInt::MAX(SSAInt::MIN(a, c), b); +} + SSAInt SSAInt::add(SSAInt b, bool no_unsigned_wrap, bool no_signed_wrap) { return SSAInt::from_llvm(SSAScope::builder().CreateAdd(v, b.v, SSAScope::hint(), no_unsigned_wrap, no_signed_wrap)); diff --git a/src/r_compiler/ssa/ssa_int.h b/src/r_compiler/ssa/ssa_int.h index a8700f80b..a655e3d2e 100644 --- a/src/r_compiler/ssa/ssa_int.h +++ b/src/r_compiler/ssa/ssa_int.h @@ -32,13 +32,14 @@ class SSAInt public: SSAInt(); explicit SSAInt(int constant); - SSAInt(SSAFloat f); + SSAInt(SSAFloat f, bool uint); explicit SSAInt(llvm::Value *v); static SSAInt from_llvm(llvm::Value *v) { return SSAInt(v); } static llvm::Type *llvm_type(); static SSAInt MIN(SSAInt a, SSAInt b); static SSAInt MAX(SSAInt a, SSAInt b); + static SSAInt clamp(SSAInt a, SSAInt b, SSAInt c); SSAInt add(SSAInt b, bool no_unsigned_wrap, bool no_signed_wrap); SSAInt ashr(int bits); diff --git a/src/r_compiler/ssa/ssa_scope.cpp b/src/r_compiler/ssa/ssa_scope.cpp index 64b7fad05..0dbf3aca0 100644 --- a/src/r_compiler/ssa/ssa_scope.cpp +++ b/src/r_compiler/ssa/ssa_scope.cpp @@ -56,7 +56,7 @@ llvm::IRBuilder<> &SSAScope::builder() llvm::Function *SSAScope::intrinsic(llvm::Intrinsic::ID id, llvm::ArrayRef parameter_types) { - llvm::Function *func = module()->getFunction(llvm::Intrinsic::getName(id)); + llvm::Function *func = module()->getFunction(llvm::Intrinsic::getName(id, parameter_types)); if (func == 0) func = llvm::Function::Create(llvm::Intrinsic::getType(context(), id, parameter_types), llvm::Function::ExternalLinkage, llvm::Intrinsic::getName(id, parameter_types), module()); return func; diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 94805c9c0..2df1a9347 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -222,13 +222,13 @@ void RenderPolyBsp::RenderPlane(subsector_t *sub, uint32_t subsectorDepth, bool if (!isSky) { args.SetTexture(tex); - PolyTriangleDrawer::draw(args, PolyDrawVariant::Draw); - PolyTriangleDrawer::draw(args, PolyDrawVariant::Stencil); + PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); } else { args.stencilwritevalue = 255; - PolyTriangleDrawer::draw(args, PolyDrawVariant::Stencil); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); for (uint32_t i = 0; i < sub->numlines; i++) { @@ -313,7 +313,7 @@ void RenderPolyBsp::RenderPlane(subsector_t *sub, uint32_t subsectorDepth, bool args.vinput = wallvert; args.vcount = 4; - PolyTriangleDrawer::draw(args, PolyDrawVariant::Stencil); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); } } } @@ -568,7 +568,7 @@ void RenderPolyBsp::AddSprite(AActor *thing, subsector_t *sub, uint32_t subsecto args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); - PolyTriangleDrawer::draw(args, PolyDrawVariant::DrawSubsector); + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector); } void RenderPolyBsp::AddWallSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) @@ -1234,8 +1234,8 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) args.stencilwritevalue = 1; args.SetTexture(tex); - PolyTriangleDrawer::draw(args, PolyDrawVariant::Draw); - PolyTriangleDrawer::draw(args, PolyDrawVariant::Stencil); + PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); } FTexture *RenderPolyWall::GetTexture() @@ -1567,7 +1567,7 @@ void PolySkyDome::RenderRow(PolyDrawArgs &args, int row) args.vcount = mPrimStart[row + 1] - mPrimStart[row]; args.mode = TriangleDrawMode::Strip; args.ccw = false; - PolyTriangleDrawer::draw(args, PolyDrawVariant::Draw); + PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); } void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap) @@ -1581,7 +1581,7 @@ void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int ro args.mode = TriangleDrawMode::Fan; args.ccw = bottomCap; args.solidcolor = solid; - PolyTriangleDrawer::draw(args, PolyDrawVariant::Fill); + PolyTriangleDrawer::draw(args, TriDrawVariant::Fill); } void PolySkyDome::Render(const TriMatrix &worldToClip) diff --git a/src/r_poly.h b/src/r_poly.h index b957aad59..a9ae5e33d 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -106,7 +106,7 @@ public: void Render(); void RenderScreenSprites(); - static const uint32_t SkySubsectorDepth = 0xffffffff; + static const uint32_t SkySubsectorDepth = 0x7fffffff; private: void RenderNode(void *node); diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 27177fa3e..ed1ed0b51 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -40,7 +40,7 @@ #include #endif -void PolyTriangleDrawer::draw(const PolyDrawArgs &args, PolyDrawVariant variant) +void PolyTriangleDrawer::draw(const PolyDrawArgs &args, TriDrawVariant variant) { if (r_swtruecolor) DrawerCommandQueue::QueueCommand(args, variant); @@ -48,19 +48,20 @@ void PolyTriangleDrawer::draw(const PolyDrawArgs &args, PolyDrawVariant variant) draw_arrays(args, variant, nullptr); } -void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, PolyDrawVariant variant, WorkerThreadData *thread) +void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVariant variant, WorkerThreadData *thread) { if (drawargs.vcount < 3) return; + auto llvm = LLVMDrawers::Instance(); void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *); switch (variant) { default: - case PolyDrawVariant::Draw: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::draw32 : ScreenPolyTriangleDrawer::draw; break; - case PolyDrawVariant::Fill: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::fill32 : ScreenPolyTriangleDrawer::fill; break; - case PolyDrawVariant::DrawSubsector: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::drawsubsector32 : ScreenPolyTriangleDrawer::draw; break; - case PolyDrawVariant::Stencil: drawfunc = ScreenPolyTriangleDrawer::stencil; break; + case TriDrawVariant::Draw: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::draw32 : ScreenPolyTriangleDrawer::draw; break; + case TriDrawVariant::Fill: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::fill32 : ScreenPolyTriangleDrawer::fill; break; + case TriDrawVariant::DrawSubsector: drawfunc = r_swtruecolor ? llvm->TriDrawSubsector32 : llvm->TriDrawSubsector8; break; + case TriDrawVariant::Stencil: drawfunc = ScreenPolyTriangleDrawer::stencil; break; } TriDrawTriangleArgs args; @@ -1596,7 +1597,7 @@ float ScreenPolyTriangleDrawer::grady(float x0, float y0, float x1, float y1, fl ///////////////////////////////////////////////////////////////////////////// -DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args, PolyDrawVariant variant) +DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant) : args(args), variant(variant) { } diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index b66df7898..1996308ca 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -28,14 +28,6 @@ struct TriDrawTriangleArgs; -enum class PolyDrawVariant -{ - Draw, - Fill, - DrawSubsector, - Stencil, -}; - class PolyDrawArgs { public: @@ -69,11 +61,11 @@ public: class PolyTriangleDrawer { public: - static void draw(const PolyDrawArgs &args, PolyDrawVariant variant); + static void draw(const PolyDrawArgs &args, TriDrawVariant variant); private: static TriVertex shade_vertex(const TriUniforms &uniforms, TriVertex v); - static void draw_arrays(const PolyDrawArgs &args, PolyDrawVariant variant, WorkerThreadData *thread); + static void draw_arrays(const PolyDrawArgs &args, TriDrawVariant variant, WorkerThreadData *thread); static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert); @@ -245,14 +237,14 @@ private: class DrawPolyTrianglesCommand : public DrawerCommand { public: - DrawPolyTrianglesCommand(const PolyDrawArgs &args, PolyDrawVariant variant); + DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant); void Execute(DrawerThread *thread) override; FString DebugInfo() override; private: PolyDrawArgs args; - PolyDrawVariant variant; + TriDrawVariant variant; }; #endif From eb4021b9978f5aea024951268ea9963c41b27ef1 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 12 Nov 2016 10:21:02 +0100 Subject: [PATCH 1202/1509] Codegen for all triangle variants --- .../fixedfunction/drawtrianglecodegen.cpp | 305 ++++++++++++++---- .../fixedfunction/drawtrianglecodegen.h | 10 + src/r_compiler/llvmdrawers.h | 1 + src/r_compiler/ssa/ssa_bool.cpp | 39 +++ src/r_compiler/ssa/ssa_bool.h | 9 + src/r_compiler/ssa/ssa_int.cpp | 5 + src/r_compiler/ssa/ssa_int.h | 1 + src/r_poly.cpp | 2 +- src/r_poly_triangle.cpp | 6 +- src/r_poly_triangle.h | 4 +- 10 files changed, 309 insertions(+), 73 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index 13fb40d04..5c8b9a736 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -233,9 +233,17 @@ void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) SSAFloat lightscale = SSAFloat::clamp((shade - SSAFloat::MIN(SSAFloat(24.0f), vis)) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)); diminishedlight = SSAInt(SSAFloat::clamp((1.0f - lightscale) * 256.0f + 0.5f, SSAFloat(0.0f), SSAFloat(256.0f)), false); + SetStencilBlock(x / 8 + y / 8 * stencilPitch); + + SSABool covered = a == SSAInt(0xF) && b == SSAInt(0xF) && c == SSAInt(0xF) && !clipneeded; + if (variant != TriDrawVariant::DrawSubsector) + { + covered = covered && StencilIsSingleValue(); + } + // Accept whole block when totally covered SSAIfBlock branch_covered; - branch_covered.if_block(a == SSAInt(0xF) && b == SSAInt(0xF) && c == SSAInt(0xF) && !clipneeded); + branch_covered.if_block(covered); { LoopFullBlock(variant, truecolor); } @@ -254,58 +262,86 @@ void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) void DrawTriangleCodegen::LoopFullBlock(TriDrawVariant variant, bool truecolor) { - int pixelsize = truecolor ? 4 : 1; - - stack_iy.store(SSAInt(0)); - stack_buffer.store(dest); - stack_subsectorbuffer.store(subsectorGBuffer); - - SSAForBlock loopy; - SSAInt iy = stack_iy.load(); - SSAUBytePtr buffer = stack_buffer.load(); - SSAIntPtr subsectorbuffer = stack_subsectorbuffer.load(); - loopy.loop_block(iy < SSAInt(q), q); + SSAIfBlock branch_stenciltest; + if (variant != TriDrawVariant::DrawSubsector) { - SSAInt varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - SSAFloat pos = varyingTL[i] + varyingBL[i] * SSAFloat(iy); - SSAFloat step = (varyingTR[i] + varyingBR[i] * SSAFloat(iy) - pos) * (1.0f / q); + branch_stenciltest.if_block(StencilGetSingle() == stencilTestValue); + } + + if (variant == TriDrawVariant::Stencil) + { + StencilClear(stencilWriteValue); + } + else + { + int pixelsize = truecolor ? 4 : 1; - stack_varying[i].store(SSAInt((pos - SSAFloat::floor(pos)) * SSAFloat((float)0x100000000LL), true)); - varyingStep[i] = SSAInt(step * SSAFloat((float)0x100000000LL), true); - } + stack_iy.store(SSAInt(0)); + stack_buffer.store(dest); + stack_subsectorbuffer.store(subsectorGBuffer); - stack_ix.store(x); - SSAForBlock loopx; - SSAInt ix = stack_ix.load(); - SSAInt varying[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] = stack_varying[i].load(); - loopx.loop_block(ix < x + q, q); + SSAForBlock loopy; + SSAInt iy = stack_iy.load(); + SSAUBytePtr buffer = stack_buffer.load(); + SSAIntPtr subsectorbuffer = stack_subsectorbuffer.load(); + loopy.loop_block(iy < SSAInt(q), q); { - SSAIfBlock branch; - branch.if_block(subsectorbuffer[ix].load(true) >= subsectorDepth); + SSAInt varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) { - if (truecolor) - ProcessPixel(buffer[ix * 4], subsectorbuffer[ix], varying, variant, truecolor); - else - ProcessPixel(buffer[ix], subsectorbuffer[ix], varying, variant, truecolor); + SSAFloat pos = varyingTL[i] + varyingBL[i] * SSAFloat(iy); + SSAFloat step = (varyingTR[i] + varyingBR[i] * SSAFloat(iy) - pos) * (1.0f / q); + + stack_varying[i].store(SSAInt((pos - SSAFloat::floor(pos)) * SSAFloat((float)0x100000000LL), true)); + varyingStep[i] = SSAInt(step * SSAFloat((float)0x100000000LL), true); } - branch.end_block(); + stack_ix.store(x); + SSAForBlock loopx; + SSAInt ix = stack_ix.load(); + SSAInt varying[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) - stack_varying[i].store(varying[i] + varyingStep[i]); + varying[i] = stack_varying[i].load(); + loopx.loop_block(ix < x + q, q); + { + if (variant == TriDrawVariant::DrawSubsector) + { + SSAIfBlock branch; + branch.if_block(subsectorbuffer[ix].load(true) >= subsectorDepth); + { + if (truecolor) + ProcessPixel(buffer[ix * 4], subsectorbuffer[ix], varying, variant, truecolor); + else + ProcessPixel(buffer[ix], subsectorbuffer[ix], varying, variant, truecolor); + } + branch.end_block(); + } + else + { + if (truecolor) + ProcessPixel(buffer[ix * 4], subsectorbuffer[ix], varying, variant, truecolor); + else + ProcessPixel(buffer[ix], subsectorbuffer[ix], varying, variant, truecolor); + } + + for (int i = 0; i < TriVertex::NumVarying; i++) + stack_varying[i].store(varying[i] + varyingStep[i]); + + stack_ix.store(ix + 1); + } + loopx.end_block(); - stack_ix.store(ix + 1); + stack_buffer.store(buffer[pitch * pixelsize]); + stack_subsectorbuffer.store(subsectorbuffer[pitch]); + stack_iy.store(iy + 1); } - loopx.end_block(); + loopy.end_block(); + } - stack_buffer.store(buffer[pitch * pixelsize]); - stack_subsectorbuffer.store(subsectorbuffer[pitch]); - stack_iy.store(iy + 1); + if (variant != TriDrawVariant::DrawSubsector) + { + branch_stenciltest.end_block(); } - loopy.end_block(); } void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolor) @@ -354,14 +390,31 @@ void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolo loopx.loop_block(ix < SSAInt(q), q); { SSABool visible = (ix + x >= clipleft) && (ix + x < clipright) && (cliptop <= y + iy) && (clipbottom > y + iy); + SSABool covered = CX1 > SSAInt(0) && CX2 > SSAInt(0) && CX3 > SSAInt(0) && visible; + + if (variant == TriDrawVariant::DrawSubsector) + { + covered = covered && subsectorbuffer[ix + x].load(true) >= subsectorDepth; + } + else + { + covered = covered && StencilGet(ix, iy) == stencilTestValue; + } SSAIfBlock branch; - branch.if_block(CX1 > SSAInt(0) && CX2 > SSAInt(0) && CX3 > SSAInt(0) && visible && subsectorbuffer[ix + x].load(true) >= subsectorDepth); + branch.if_block(covered); { - if (truecolor) - ProcessPixel(buffer[(ix + x) * 4], subsectorbuffer[ix + x], varying, variant, truecolor); + if (variant == TriDrawVariant::Stencil) + { + StencilSet(ix, iy, stencilWriteValue); + } else - ProcessPixel(buffer[ix + x], subsectorbuffer[ix + x], varying, variant, truecolor); + { + if (truecolor) + ProcessPixel(buffer[(ix + x) * 4], subsectorbuffer[ix + x], varying, variant, truecolor); + else + ProcessPixel(buffer[ix + x], subsectorbuffer[ix + x], varying, variant, truecolor); + } } branch.end_block(); @@ -387,39 +440,157 @@ void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolo void DrawTriangleCodegen::ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbuffer, SSAInt *varying, TriDrawVariant variant, bool truecolor) { - SSAInt ufrac = varying[0]; - SSAInt vfrac = varying[1]; - - SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; - SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; - SSAInt uvoffset = upos * textureHeight + vpos; - - if (truecolor) + if (variant == TriDrawVariant::Fill) { - SSAVec4i fg = texturePixels[uvoffset * 4].load_vec4ub(true); - SSAInt fg_alpha = fg[3]; - fg = (fg * diminishedlight) >> 8; - fg.insert(3, fg_alpha); - - SSAIfBlock branch_transparency; - branch_transparency.if_block(fg_alpha > SSAInt(127)); + if (truecolor) { - buffer.store_vec4ub(fg); + buffer.store_vec4ub(SSAVec4i::unpack(solidcolor)); } - branch_transparency.end_block(); + else + { + //buffer.store(solidcolor); + } + subsectorbuffer.store(subsectorDepth); } else { - SSAUByte palindex = texturePixels[uvoffset].load(true); - SSAIfBlock branch_transparency; - branch_transparency.if_block(!(palindex.zext_int() == SSAInt(0))); + SSAInt ufrac = varying[0]; + SSAInt vfrac = varying[1]; + + SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; + SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; + SSAInt uvoffset = upos * textureHeight + vpos; + + if (truecolor) { - buffer.store(palindex); + SSAVec4i fg = texturePixels[uvoffset * 4].load_vec4ub(true); + SSAInt fg_alpha = fg[3]; + fg = (fg * diminishedlight) >> 8; + fg.insert(3, fg_alpha); + + if (variant == TriDrawVariant::DrawMasked || variant == TriDrawVariant::DrawSubsector) + { + SSAIfBlock branch_transparency; + branch_transparency.if_block(fg_alpha > SSAInt(127)); + { + buffer.store_vec4ub(fg); + if (variant != TriDrawVariant::DrawSubsector) + subsectorbuffer.store(subsectorDepth); + } + branch_transparency.end_block(); + } + else + { + buffer.store_vec4ub(fg); + subsectorbuffer.store(subsectorDepth); + } + } + else + { + SSAUByte palindex = texturePixels[uvoffset].load(true); + + if (variant == TriDrawVariant::DrawMasked || variant == TriDrawVariant::DrawSubsector) + { + SSAIfBlock branch_transparency; + branch_transparency.if_block(!(palindex.zext_int() == SSAInt(0))); + { + buffer.store(palindex); + if (variant != TriDrawVariant::DrawSubsector) + subsectorbuffer.store(subsectorDepth); + } + branch_transparency.end_block(); + } + else + { + buffer.store(palindex); + subsectorbuffer.store(subsectorDepth); + } } - branch_transparency.end_block(); } } +void DrawTriangleCodegen::SetStencilBlock(SSAInt block) +{ + StencilBlock = stencilValues[block * 64]; + StencilBlockMask = stencilMasks[block]; +} + +void DrawTriangleCodegen::StencilSet(SSAInt x, SSAInt y, SSAUByte value) +{ + SSAInt mask = StencilBlockMask.load(false); + + SSAIfBlock branchNeedsUpdate; + branchNeedsUpdate.if_block(!(mask == SSAInt(0xffffffff) && StencilBlock[0].load(false) == value)); + + SSAIfBlock branchFirstSet; + branchFirstSet.if_block(mask == SSAInt(0xffffffff)); + { + SSAUByte val0 = StencilBlock[0].load(false); + for (int i = 1; i < 8 * 8; i++) + StencilBlock[i].store(val0); + } + branchFirstSet.end_block(); + + SSAIfBlock branchNeedsUpdate2; + branchNeedsUpdate2.if_block(!(StencilBlock[x + y * 8].load(false) == value)); + + StencilBlock[x + y * 8].store(value); + + SSAInt leveloffset = SSAInt(0); + for (int i = 1; i < 4; i++) + { + x = x >> 1; + y = y >> 1; + + SSABool differs = + !(StencilBlock[(x << i) + (y << i) * 8].load(false) == value && + StencilBlock[((x + 1) << i) + (y << i) * 8].load(false) == value && + StencilBlock[(x << i) + ((y + 1) << i) * 8].load(false) == value && + StencilBlock[((x + 1) << i) + ((y + 1) << i) * 8].load(false) == value); + + SSAInt levelbit = SSAInt(1) << (leveloffset + x + y * (8 >> i)); + + mask = differs.select(mask & ~levelbit, mask | levelbit); + + leveloffset = leveloffset + (SSAInt(8) >> leveloffset) * (SSAInt(8) >> leveloffset); + } + + SSABool differs = + !(StencilBlock[0].load(false) == value && + StencilBlock[4].load(false) == value && + StencilBlock[4 * 8].load(false) == value && + StencilBlock[4 * 8 + 4].load(false) == value); + + mask = differs.select(mask & ~(1 << 22), mask | (1 << 22)); + + StencilBlockMask.store(mask); + + branchNeedsUpdate2.end_block(); + branchNeedsUpdate.end_block(); +} + +SSAUByte DrawTriangleCodegen::StencilGet(SSAInt x, SSAInt y) +{ + SSABool oneValueBlock = StencilBlockMask.load(false) == SSAInt(0xffffffff); + return oneValueBlock.select(StencilBlock[0].load(false), StencilBlock[x + y * 8].load(false)); +} + +SSAUByte DrawTriangleCodegen::StencilGetSingle() +{ + return StencilBlock[0].load(false); +} + +void DrawTriangleCodegen::StencilClear(SSAUByte value) +{ + StencilBlock[0].store(value); + StencilBlockMask.store(SSAInt(0xffffffff)); +} + +SSABool DrawTriangleCodegen::StencilIsSingleValue() +{ + return StencilBlockMask.load(false) == SSAInt(0xffffffff); +} + void DrawTriangleCodegen::LoadArgs(TriDrawVariant variant, bool truecolor, SSAValue args, SSAValue thread_data) { dest = args[0][0].load(true); diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.h b/src/r_compiler/fixedfunction/drawtrianglecodegen.h index 08b848b91..6f9a6c32a 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.h +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.h @@ -47,6 +47,13 @@ private: void ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbuffer, SSAInt *varying, TriDrawVariant variant, bool truecolor); + void SetStencilBlock(SSAInt block); + void StencilSet(SSAInt x, SSAInt y, SSAUByte value); + void StencilClear(SSAUByte value); + SSAUByte StencilGet(SSAInt x, SSAInt y); + SSAUByte StencilGetSingle(); + SSABool StencilIsSingleValue(); + SSAFloat gradx(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2); SSAFloat grady(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2); @@ -112,4 +119,7 @@ private: SSAFloat varyingTR[TriVertex::NumVarying]; SSAFloat varyingBL[TriVertex::NumVarying]; SSAFloat varyingBR[TriVertex::NumVarying]; + + SSAUBytePtr StencilBlock; + SSAIntPtr StencilBlockMask; }; diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index f8b49e9be..b68c23fe1 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -263,6 +263,7 @@ struct TriDrawTriangleArgs enum class TriDrawVariant { Draw, + DrawMasked, Fill, DrawSubsector, Stencil, diff --git a/src/r_compiler/ssa/ssa_bool.cpp b/src/r_compiler/ssa/ssa_bool.cpp index d23d9e8ae..65cc25c90 100644 --- a/src/r_compiler/ssa/ssa_bool.cpp +++ b/src/r_compiler/ssa/ssa_bool.cpp @@ -22,6 +22,8 @@ #include "r_compiler/llvm_include.h" #include "ssa_bool.h" +#include "ssa_ubyte.h" +#include "ssa_value.h" #include "ssa_scope.h" SSABool::SSABool() @@ -49,6 +51,16 @@ SSAInt SSABool::zext_int() return SSAInt::from_llvm(SSAScope::builder().CreateZExt(v, SSAInt::llvm_type(), SSAScope::hint())); } +SSAInt SSABool::select(SSAInt a, SSAInt b) +{ + return SSAValue::from_llvm(SSAScope::builder().CreateSelect(v, a.v, b.v, SSAScope::hint())); +} + +SSAUByte SSABool::select(SSAUByte a, SSAUByte b) +{ + return SSAValue::from_llvm(SSAScope::builder().CreateSelect(v, a.v, b.v, SSAScope::hint())); +} + SSABool operator&&(const SSABool &a, const SSABool &b) { return SSABool::from_llvm(SSAScope::builder().CreateAnd(a.v, b.v, SSAScope::hint())); @@ -91,6 +103,33 @@ SSABool operator>(const SSAInt &a, const SSAInt &b) ///////////////////////////////////////////////////////////////////////////// +SSABool operator<(const SSAUByte &a, const SSAUByte &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateICmpSLT(a.v, b.v, SSAScope::hint())); +} + +SSABool operator<=(const SSAUByte &a, const SSAUByte &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateICmpSLE(a.v, b.v, SSAScope::hint())); +} + +SSABool operator==(const SSAUByte &a, const SSAUByte &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateICmpEQ(a.v, b.v, SSAScope::hint())); +} + +SSABool operator>=(const SSAUByte &a, const SSAUByte &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateICmpSGE(a.v, b.v, SSAScope::hint())); +} + +SSABool operator>(const SSAUByte &a, const SSAUByte &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateICmpSGT(a.v, b.v, SSAScope::hint())); +} + +///////////////////////////////////////////////////////////////////////////// + SSABool operator<(const SSAFloat &a, const SSAFloat &b) { return SSABool::from_llvm(SSAScope::builder().CreateFCmpOLT(a.v, b.v, SSAScope::hint())); diff --git a/src/r_compiler/ssa/ssa_bool.h b/src/r_compiler/ssa/ssa_bool.h index 4c04941d5..2ed6e7d4a 100644 --- a/src/r_compiler/ssa/ssa_bool.h +++ b/src/r_compiler/ssa/ssa_bool.h @@ -23,6 +23,7 @@ #pragma once #include "ssa_int.h" +#include "ssa_ubyte.h" #include "ssa_float.h" namespace llvm { class Value; } @@ -38,6 +39,8 @@ public: static llvm::Type *llvm_type(); SSAInt zext_int(); + SSAInt select(SSAInt a, SSAInt b); + SSAUByte select(SSAUByte a, SSAUByte b); llvm::Value *v; }; @@ -53,6 +56,12 @@ SSABool operator==(const SSAInt &a, const SSAInt &b); SSABool operator>=(const SSAInt &a, const SSAInt &b); SSABool operator>(const SSAInt &a, const SSAInt &b); +SSABool operator<(const SSAUByte &a, const SSAUByte &b); +SSABool operator<=(const SSAUByte &a, const SSAUByte &b); +SSABool operator==(const SSAUByte &a, const SSAUByte &b); +SSABool operator>=(const SSAUByte &a, const SSAUByte &b); +SSABool operator>(const SSAUByte &a, const SSAUByte &b); + SSABool operator<(const SSAFloat &a, const SSAFloat &b); SSABool operator<=(const SSAFloat &a, const SSAFloat &b); SSABool operator==(const SSAFloat &a, const SSAFloat &b); diff --git a/src/r_compiler/ssa/ssa_int.cpp b/src/r_compiler/ssa/ssa_int.cpp index ac14af8b6..01ad92e3f 100644 --- a/src/r_compiler/ssa/ssa_int.cpp +++ b/src/r_compiler/ssa/ssa_int.cpp @@ -195,3 +195,8 @@ SSAInt operator|(const SSAInt &a, const SSAInt &b) { return SSAInt::from_llvm(SSAScope::builder().CreateOr(a.v, b.v, SSAScope::hint())); } + +SSAInt operator~(const SSAInt &a) +{ + return SSAInt::from_llvm(SSAScope::builder().CreateNot(a.v, SSAScope::hint())); +} diff --git a/src/r_compiler/ssa/ssa_int.h b/src/r_compiler/ssa/ssa_int.h index a655e3d2e..ae6e6074f 100644 --- a/src/r_compiler/ssa/ssa_int.h +++ b/src/r_compiler/ssa/ssa_int.h @@ -74,3 +74,4 @@ SSAInt operator&(const SSAInt &a, int b); SSAInt operator&(const SSAInt &a, const SSAInt &b); SSAInt operator|(const SSAInt &a, int b); SSAInt operator|(const SSAInt &a, const SSAInt &b); +SSAInt operator~(const SSAInt &a); diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 2df1a9347..403adeec0 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -1524,7 +1524,7 @@ void PolySkyDome::SkyVertex(int r, int c, bool zflip) // And finally the vertex. TriVertex vert; - vert = SetVertexXYZ(-pos.X, z - 1.f, pos.Y, u * 4.0f, v + 0.5f/*, color*/); + vert = SetVertexXYZ(-pos.X, z - 1.f, pos.Y, u * 4.0f, v * 1.2f + 0.5f/*, color*/); mVertices.Push(vert); } diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index ed1ed0b51..2b8c166dc 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -58,10 +58,10 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian switch (variant) { default: - case TriDrawVariant::Draw: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::draw32 : ScreenPolyTriangleDrawer::draw; break; - case TriDrawVariant::Fill: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::fill32 : ScreenPolyTriangleDrawer::fill; break; + case TriDrawVariant::Draw: drawfunc = r_swtruecolor ? llvm->TriDraw32: llvm->TriDraw8; break; + case TriDrawVariant::Fill: drawfunc = r_swtruecolor ? llvm->TriFill32 : llvm->TriFill8; break; case TriDrawVariant::DrawSubsector: drawfunc = r_swtruecolor ? llvm->TriDrawSubsector32 : llvm->TriDrawSubsector8; break; - case TriDrawVariant::Stencil: drawfunc = ScreenPolyTriangleDrawer::stencil; break; + case TriDrawVariant::Stencil: drawfunc = ScreenPolyTriangleDrawer::stencil/*llvm->TriStencil*/; break; } TriDrawTriangleArgs args; diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 1996308ca..a21ff1d6d 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -105,7 +105,7 @@ public: x >>= 1; y >>= 1; - bool same = + bool differs = Values[(x << i) + (y << i) * 8] != value || Values[((x + 1) << i) + (y << i) * 8] != value || Values[(x << i) + ((y + 1) << i) * 8] != value || @@ -113,7 +113,7 @@ public: int levelbit = 1 << (leveloffset + x + y * (8 >> i)); - if (same) + if (differs) ValueMask = ValueMask & ~levelbit; else ValueMask = ValueMask | levelbit; From e3dc9c93b91e43229676c24800fef8ff5a020c17 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 12 Nov 2016 13:50:28 +0100 Subject: [PATCH 1203/1509] Use a simpler algorithm for the stencil buffer as the old one was too slow --- .../fixedfunction/drawtrianglecodegen.cpp | 52 ++++--------------- src/r_compiler/ssa/ssa_int.cpp | 6 +++ src/r_compiler/ssa/ssa_int.h | 3 ++ src/r_poly.cpp | 3 ++ src/r_poly_triangle.cpp | 13 ++++- src/r_poly_triangle.h | 52 ++++--------------- 6 files changed, 44 insertions(+), 85 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index 5c8b9a736..4819a28cf 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -520,75 +520,41 @@ void DrawTriangleCodegen::StencilSet(SSAInt x, SSAInt y, SSAUByte value) SSAInt mask = StencilBlockMask.load(false); SSAIfBlock branchNeedsUpdate; - branchNeedsUpdate.if_block(!(mask == SSAInt(0xffffffff) && StencilBlock[0].load(false) == value)); + branchNeedsUpdate.if_block(!(mask == (SSAInt(0xffffff00) | value.zext_int()))); SSAIfBlock branchFirstSet; - branchFirstSet.if_block(mask == SSAInt(0xffffffff)); + branchFirstSet.if_block((mask & SSAInt(0xffffff00)) == SSAInt(0xffffff00)); { - SSAUByte val0 = StencilBlock[0].load(false); - for (int i = 1; i < 8 * 8; i++) + SSAUByte val0 = mask.trunc_ubyte(); + for (int i = 0; i < 8 * 8; i++) StencilBlock[i].store(val0); + StencilBlockMask.store(SSAInt(0)); } branchFirstSet.end_block(); - SSAIfBlock branchNeedsUpdate2; - branchNeedsUpdate2.if_block(!(StencilBlock[x + y * 8].load(false) == value)); - StencilBlock[x + y * 8].store(value); - SSAInt leveloffset = SSAInt(0); - for (int i = 1; i < 4; i++) - { - x = x >> 1; - y = y >> 1; - - SSABool differs = - !(StencilBlock[(x << i) + (y << i) * 8].load(false) == value && - StencilBlock[((x + 1) << i) + (y << i) * 8].load(false) == value && - StencilBlock[(x << i) + ((y + 1) << i) * 8].load(false) == value && - StencilBlock[((x + 1) << i) + ((y + 1) << i) * 8].load(false) == value); - - SSAInt levelbit = SSAInt(1) << (leveloffset + x + y * (8 >> i)); - - mask = differs.select(mask & ~levelbit, mask | levelbit); - - leveloffset = leveloffset + (SSAInt(8) >> leveloffset) * (SSAInt(8) >> leveloffset); - } - - SSABool differs = - !(StencilBlock[0].load(false) == value && - StencilBlock[4].load(false) == value && - StencilBlock[4 * 8].load(false) == value && - StencilBlock[4 * 8 + 4].load(false) == value); - - mask = differs.select(mask & ~(1 << 22), mask | (1 << 22)); - - StencilBlockMask.store(mask); - - branchNeedsUpdate2.end_block(); branchNeedsUpdate.end_block(); } SSAUByte DrawTriangleCodegen::StencilGet(SSAInt x, SSAInt y) { - SSABool oneValueBlock = StencilBlockMask.load(false) == SSAInt(0xffffffff); - return oneValueBlock.select(StencilBlock[0].load(false), StencilBlock[x + y * 8].load(false)); + return StencilIsSingleValue().select(StencilBlockMask.load(false).trunc_ubyte(), StencilBlock[x + y * 8].load(false)); } SSAUByte DrawTriangleCodegen::StencilGetSingle() { - return StencilBlock[0].load(false); + return StencilBlockMask.load(false).trunc_ubyte(); } void DrawTriangleCodegen::StencilClear(SSAUByte value) { - StencilBlock[0].store(value); - StencilBlockMask.store(SSAInt(0xffffffff)); + StencilBlockMask.store(SSAInt(0xffffff00) | value.zext_int()); } SSABool DrawTriangleCodegen::StencilIsSingleValue() { - return StencilBlockMask.load(false) == SSAInt(0xffffffff); + return (StencilBlockMask.load(false) & SSAInt(0xffffff00)) == SSAInt(0xffffff00); } void DrawTriangleCodegen::LoadArgs(TriDrawVariant variant, bool truecolor, SSAValue args, SSAValue thread_data) diff --git a/src/r_compiler/ssa/ssa_int.cpp b/src/r_compiler/ssa/ssa_int.cpp index 01ad92e3f..b0cd26821 100644 --- a/src/r_compiler/ssa/ssa_int.cpp +++ b/src/r_compiler/ssa/ssa_int.cpp @@ -23,6 +23,7 @@ #include "r_compiler/llvm_include.h" #include "ssa_int.h" #include "ssa_float.h" +#include "ssa_ubyte.h" #include "ssa_bool.h" #include "ssa_scope.h" @@ -81,6 +82,11 @@ SSAInt SSAInt::ashr(int bits) return SSAInt::from_llvm(SSAScope::builder().CreateAShr(v, bits, SSAScope::hint())); } +SSAUByte SSAInt::trunc_ubyte() +{ + return SSAUByte::from_llvm(SSAScope::builder().CreateTrunc(v, SSAUByte::llvm_type(), SSAScope::hint())); +} + SSAInt operator+(const SSAInt &a, const SSAInt &b) { return SSAInt::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); diff --git a/src/r_compiler/ssa/ssa_int.h b/src/r_compiler/ssa/ssa_int.h index ae6e6074f..dab8adcb9 100644 --- a/src/r_compiler/ssa/ssa_int.h +++ b/src/r_compiler/ssa/ssa_int.h @@ -26,6 +26,7 @@ namespace llvm { class Value; } namespace llvm { class Type; } class SSAFloat; +class SSAUByte; class SSAInt { @@ -44,6 +45,8 @@ public: SSAInt add(SSAInt b, bool no_unsigned_wrap, bool no_signed_wrap); SSAInt ashr(int bits); + SSAUByte trunc_ubyte(); + llvm::Value *v; }; diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 403adeec0..a4141b94c 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -41,6 +41,9 @@ CVAR(Bool, r_debug_cull, 0, 0) void RenderPolyBsp::Render() { + if (!r_swtruecolor) // Disable pal rendering for now + return; + // Setup working buffers PolyVertexBuffer::Clear(); SolidSegments.clear(); diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 2b8c166dc..3d444d2ad 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -55,14 +55,25 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian auto llvm = LLVMDrawers::Instance(); void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *); +#if 1 switch (variant) { default: case TriDrawVariant::Draw: drawfunc = r_swtruecolor ? llvm->TriDraw32: llvm->TriDraw8; break; case TriDrawVariant::Fill: drawfunc = r_swtruecolor ? llvm->TriFill32 : llvm->TriFill8; break; case TriDrawVariant::DrawSubsector: drawfunc = r_swtruecolor ? llvm->TriDrawSubsector32 : llvm->TriDrawSubsector8; break; - case TriDrawVariant::Stencil: drawfunc = ScreenPolyTriangleDrawer::stencil/*llvm->TriStencil*/; break; + case TriDrawVariant::Stencil: drawfunc = llvm->TriStencil; break; } +#else + switch (variant) + { + default: + case TriDrawVariant::Draw: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::draw32 : ScreenPolyTriangleDrawer::draw; break; + case TriDrawVariant::Fill: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::fill32 : ScreenPolyTriangleDrawer::fill; break; + case TriDrawVariant::DrawSubsector: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::drawsubsector32 : llvm->TriDrawSubsector8; break; + case TriDrawVariant::Stencil: drawfunc = ScreenPolyTriangleDrawer::stencil; break; + } +#endif TriDrawTriangleArgs args; args.dest = dc_destorg; diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index a21ff1d6d..f3f63f8f1 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -85,70 +85,40 @@ public: void Set(int x, int y, uint8_t value) { - if (ValueMask == 0xffffffff) + if ((ValueMask & 0xffffff00) == 0xffffff00) { - if (Values[0] == value) + if ((ValueMask & 0xff) == value) return; - for (int i = 1; i < 8 * 8; i++) - Values[i] = Values[0]; + for (int i = 0; i < 8 * 8; i++) + Values[i] = (ValueMask & 0xff); + ValueMask = 0; } - if (Values[x + y * 8] == value) - return; - Values[x + y * 8] = value; - - int leveloffset = 0; - for (int i = 1; i < 4; i++) - { - x >>= 1; - y >>= 1; - - bool differs = - Values[(x << i) + (y << i) * 8] != value || - Values[((x + 1) << i) + (y << i) * 8] != value || - Values[(x << i) + ((y + 1) << i) * 8] != value || - Values[((x + 1) << i) + ((y + 1) << i) * 8] != value; - - int levelbit = 1 << (leveloffset + x + y * (8 >> i)); - - if (differs) - ValueMask = ValueMask & ~levelbit; - else - ValueMask = ValueMask | levelbit; - - leveloffset += (8 >> leveloffset) * (8 >> leveloffset); - } - - if (Values[0] != value || Values[4] != value || Values[4 * 8] != value || Values[4 * 8 + 4] != value) - ValueMask = ValueMask & ~(1 << 22); - else - ValueMask = ValueMask | (1 << 22); } uint8_t Get(int x, int y) const { - if (ValueMask == 0xffffffff) - return Values[0]; + if (IsSingleValue()) + return ValueMask & 0xff; else return Values[x + y * 8]; } void Clear(uint8_t value) { - Values[0] = value; - ValueMask = 0xffffffff; + ValueMask = 0xffffff00 | (uint32_t)value; } bool IsSingleValue() const { - return ValueMask == 0xffffffff; + return (ValueMask & 0xffffff00) == 0xffffff00; } private: - uint8_t *Values; // [8 * 8]; - uint32_t &ValueMask; // 4 * 4 + 2 * 2 + 1 bits indicating is Values are the same + uint8_t *Values; + uint32_t &ValueMask; }; class PolySubsectorGBuffer From 402227d6b6fee59d3358a42cdc852a0cd3f4b863 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 12 Nov 2016 14:55:14 +0100 Subject: [PATCH 1204/1509] Add some intersection tests useful for culling --- src/CMakeLists.txt | 1 + src/r_poly.cpp | 103 +++++----------- src/r_poly.h | 2 + src/r_poly_intersection.cpp | 235 ++++++++++++++++++++++++++++++++++++ src/r_poly_intersection.h | 167 +++++++++++++++++++++++++ 5 files changed, 437 insertions(+), 71 deletions(-) create mode 100644 src/r_poly_intersection.cpp create mode 100644 src/r_poly_intersection.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 43a94f91a..b2cf47945 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1053,6 +1053,7 @@ set( FASTMATH_PCH_SOURCES r_swrenderer2.cpp r_poly.cpp r_poly_triangle.cpp + r_poly_intersection.cpp r_3dfloors.cpp r_bsp.cpp r_draw.cpp diff --git a/src/r_poly.cpp b/src/r_poly.cpp index a4141b94c..e8a34544b 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -75,6 +75,8 @@ void RenderPolyBsp::Render() // Y shearing like the Doom renderer: //worldToClip = TriMatrix::viewToClip() * TriMatrix::worldToView(); + frustumPlanes = FrustumPlanes(worldToClip); + // Cull front to back if (numnodes == 0) { @@ -1023,28 +1025,20 @@ int RenderPolyBsp::PointOnSide(const DVector2 &pos, const node_t *node) bool RenderPolyBsp::CheckBBox(float *bspcoord) { - static const int checkcoord[12][4] = - { - { 3,0,2,1 }, - { 3,0,2,0 }, - { 3,1,2,0 }, - { 0 }, - { 2,0,2,1 }, - { 0,0,0,0 }, - { 3,1,3,0 }, - { 0 }, - { 2,0,3,1 }, - { 2,1,3,1 }, - { 2,1,3,0 } - }; + // Start using a quick frustum AABB test: + + AxisAlignedBoundingBox aabb(Vec3f(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM], -1000.0f), Vec3f(bspcoord[BOXRIGHT], bspcoord[BOXTOP], 1000.0f)); + auto result = IntersectionTest::frustum_aabb(frustumPlanes, aabb); + if (result == IntersectionTest::outside) + return false; + + // Occlusion test using solid segments (which seems to be quite broken, actually): int boxx; int boxy; int boxpos; double x1, y1, x2, y2; - double rx1, ry1, rx2, ry2; - int sx1, sx2; // Find the corners of the box // that define the edges from current viewpoint. @@ -1066,64 +1060,31 @@ bool RenderPolyBsp::CheckBBox(float *bspcoord) if (boxpos == 5) return true; - x1 = bspcoord[checkcoord[boxpos][0]] - ViewPos.X; - y1 = bspcoord[checkcoord[boxpos][1]] - ViewPos.Y; - x2 = bspcoord[checkcoord[boxpos][2]] - ViewPos.X; - y2 = bspcoord[checkcoord[boxpos][3]] - ViewPos.Y; + static const int checkcoord[12][4] = + { + { 3,0,2,1 }, + { 3,0,2,0 }, + { 3,1,2,0 }, + { 0 }, + { 2,0,2,1 }, + { 0,0,0,0 }, + { 3,1,3,0 }, + { 0 }, + { 2,0,3,1 }, + { 2,1,3,1 }, + { 2,1,3,0 } + }; - // check clip list for an open space + x1 = bspcoord[checkcoord[boxpos][0]]; + y1 = bspcoord[checkcoord[boxpos][1]]; + x2 = bspcoord[checkcoord[boxpos][2]]; + y2 = bspcoord[checkcoord[boxpos][3]]; - // Sitting on a line? - if (y1 * (x1 - x2) + x1 * (y2 - y1) >= -EQUAL_EPSILON) + int sx1, sx2; + if (GetSegmentRangeForLine(x1, y1, x2, y2, sx1, sx2)) + return !IsSegmentCulled(sx1, sx2); + else return true; - - rx1 = x1 * ViewSin - y1 * ViewCos; - rx2 = x2 * ViewSin - y2 * ViewCos; - ry1 = x1 * ViewTanCos + y1 * ViewTanSin; - ry2 = x2 * ViewTanCos + y2 * ViewTanSin; - - /*if (MirrorFlags & RF_XFLIP) - { - double t = -rx1; - rx1 = -rx2; - rx2 = t; - swapvalues(ry1, ry2); - }*/ - - if (rx1 >= -ry1) - { - if (rx1 > ry1) return false; // left edge is off the right side - if (ry1 == 0) return false; - sx1 = xs_RoundToInt(CenterX + rx1 * CenterX / ry1); - } - else - { - if (rx2 < -ry2) return false; // wall is off the left side - if (rx1 - rx2 - ry2 + ry1 == 0) return false; // wall does not intersect view volume - sx1 = 0; - } - - if (rx2 <= ry2) - { - if (rx2 < -ry2) return false; // right edge is off the left side - if (ry2 == 0) return false; - sx2 = xs_RoundToInt(CenterX + rx2 * CenterX / ry2); - } - else - { - if (rx1 > ry1) return false; // wall is off the right side - if (ry2 - ry1 - rx2 + rx1 == 0) return false; // wall does not intersect view volume - sx2 = viewwidth; - } - - // Find the first clippost that touches the source post - // (adjacent pixels are touching). - - // Does not cross a pixel. - if (sx2 <= sx1) - return false; - - return !IsSegmentCulled(sx1, sx2); } bool RenderPolyBsp::GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const diff --git a/src/r_poly.h b/src/r_poly.h index a9ae5e33d..f1718f266 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -30,6 +30,7 @@ #include "r_utility.h" #include "r_main.h" #include "r_poly_triangle.h" +#include "r_poly_intersection.h" // DScreen accelerated sprite to be rendered class PolyScreenSprite @@ -143,6 +144,7 @@ private: double MinFloorHeight = 0.0; TriMatrix worldToClip; + FrustumPlanes frustumPlanes; std::vector SectorSpriteRanges; std::vector SortedSprites; diff --git a/src/r_poly_intersection.cpp b/src/r_poly_intersection.cpp new file mode 100644 index 000000000..5e7ad374b --- /dev/null +++ b/src/r_poly_intersection.cpp @@ -0,0 +1,235 @@ +/* +** Various 3D intersection tests +** Copyright (c) 1997-2015 The UICore Team +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "r_poly_intersection.h" + +IntersectionTest::Result IntersectionTest::plane_aabb(const Vec4f &plane, const AxisAlignedBoundingBox &aabb) +{ + Vec3f center = aabb.center(); + Vec3f extents = aabb.extents(); + float e = extents.x * std::abs(plane.x) + extents.y * std::abs(plane.y) + extents.z * std::abs(plane.z); + float s = center.x * plane.x + center.y * plane.y + center.z * plane.z + plane.w; + if (s - e > 0) + return inside; + else if (s + e < 0) + return outside; + else + return intersecting; +} + +IntersectionTest::Result IntersectionTest::plane_obb(const Vec4f &plane, const OrientedBoundingBox &obb) +{ + Vec3f n(plane); + float d = plane.w; + float e = obb.extents.x * std::abs(Vec3f::dot(obb.axis_x, n)) + obb.extents.y * std::abs(Vec3f::dot(obb.axis_y, n)) + obb.extents.z * std::abs(Vec3f::dot(obb.axis_z, n)); + float s = Vec3f::dot(obb.center, n) + d; + if (s - e > 0) + return inside; + else if (s + e < 0) + return outside; + else + return intersecting; +} + +IntersectionTest::OverlapResult IntersectionTest::sphere(const Vec3f ¢er1, float radius1, const Vec3f ¢er2, float radius2) +{ + Vec3f h = center1 - center2; + float square_distance = Vec3f::dot(h, h); + float radius_sum = radius1 + radius2; + if (square_distance > radius_sum * radius_sum) + return disjoint; + else + return overlap; +} + +IntersectionTest::OverlapResult IntersectionTest::sphere_aabb(const Vec3f ¢er, float radius, const AxisAlignedBoundingBox &aabb) +{ + Vec3f a = aabb.aabb_min - center; + Vec3f b = center - aabb.aabb_max; + a.x = std::max(a.x, 0.0f); + a.y = std::max(a.y, 0.0f); + a.z = std::max(a.z, 0.0f); + b.x = std::max(b.x, 0.0f); + b.y = std::max(b.y, 0.0f); + b.z = std::max(b.z, 0.0f); + Vec3f e = a + b; + float d = Vec3f::dot(e, e); + if (d > radius * radius) + return disjoint; + else + return overlap; +} + +IntersectionTest::OverlapResult IntersectionTest::aabb(const AxisAlignedBoundingBox &a, const AxisAlignedBoundingBox &b) +{ + if (a.aabb_min.x > b.aabb_max.x || b.aabb_min.x > a.aabb_max.x || + a.aabb_min.y > b.aabb_max.y || b.aabb_min.y > a.aabb_max.y || + a.aabb_min.z > b.aabb_max.z || b.aabb_min.z > a.aabb_max.z) + { + return disjoint; + } + else + { + return overlap; + } +} + +IntersectionTest::Result IntersectionTest::frustum_aabb(const FrustumPlanes &frustum, const AxisAlignedBoundingBox &box) +{ + bool is_intersecting = false; + for (int i = 0; i < 6; i++) + { + Result result = plane_aabb(frustum.planes[i], box); + if (result == outside) + return outside; + else if (result == intersecting) + is_intersecting = true; + break; + } + if (is_intersecting) + return intersecting; + else + return inside; +} + +IntersectionTest::Result IntersectionTest::frustum_obb(const FrustumPlanes &frustum, const OrientedBoundingBox &box) +{ + bool is_intersecting = false; + for (int i = 0; i < 6; i++) + { + Result result = plane_obb(frustum.planes[i], box); + if (result == outside) + return outside; + else if (result == intersecting) + is_intersecting = true; + } + if (is_intersecting) + return intersecting; + else + return inside; +} + +IntersectionTest::OverlapResult IntersectionTest::ray_aabb(const Vec3f &ray_start, const Vec3f &ray_end, const AxisAlignedBoundingBox &aabb) +{ + Vec3f c = (ray_start + ray_end) * 0.5f; + Vec3f w = ray_end - c; + Vec3f h = aabb.extents(); + + c -= aabb.center(); + + Vec3f v(std::abs(w.x), std::abs(w.y), std::abs(w.z)); + + if (std::abs(c.x) > v.x + h.x || std::abs(c.y) > v.y + h.y || std::abs(c.z) > v.z + h.z) + return disjoint; + + if (std::abs(c.y * w.z - c.z * w.y) > h.y * v.z + h.z * v.y || + std::abs(c.x * w.z - c.z * w.x) > h.x * v.z + h.z * v.x || + std::abs(c.x * w.y - c.y * w.x) > h.x * v.y + h.y * v.x) + return disjoint; + + return overlap; +} + +///////////////////////////////////////////////////////////////////////////// + +FrustumPlanes::FrustumPlanes() +{ +} + +FrustumPlanes::FrustumPlanes(const Mat4f &world_to_projection) +{ + planes[0] = near_frustum_plane(world_to_projection); + planes[1] = far_frustum_plane(world_to_projection); + planes[2] = left_frustum_plane(world_to_projection); + planes[3] = right_frustum_plane(world_to_projection); + planes[4] = top_frustum_plane(world_to_projection); + planes[5] = bottom_frustum_plane(world_to_projection); +} + +Vec4f FrustumPlanes::left_frustum_plane(const Mat4f &m) +{ + Vec4f plane( + m.matrix[3 + 0 * 4] + m.matrix[0 + 0 * 4], + m.matrix[3 + 1 * 4] + m.matrix[0 + 1 * 4], + m.matrix[3 + 2 * 4] + m.matrix[0 + 2 * 4], + m.matrix[3 + 3 * 4] + m.matrix[0 + 3 * 4]); + plane /= plane.length3(); + return plane; +} + +Vec4f FrustumPlanes::right_frustum_plane(const Mat4f &m) +{ + Vec4f plane( + m.matrix[3 + 0 * 4] - m.matrix[0 + 0 * 4], + m.matrix[3 + 1 * 4] - m.matrix[0 + 1 * 4], + m.matrix[3 + 2 * 4] - m.matrix[0 + 2 * 4], + m.matrix[3 + 3 * 4] - m.matrix[0 + 3 * 4]); + plane /= plane.length3(); + return plane; +} + +Vec4f FrustumPlanes::top_frustum_plane(const Mat4f &m) +{ + Vec4f plane( + m.matrix[3 + 0 * 4] - m.matrix[1 + 0 * 4], + m.matrix[3 + 1 * 4] - m.matrix[1 + 1 * 4], + m.matrix[3 + 2 * 4] - m.matrix[1 + 2 * 4], + m.matrix[3 + 3 * 4] - m.matrix[1 + 3 * 4]); + plane /= plane.length3(); + return plane; +} + +Vec4f FrustumPlanes::bottom_frustum_plane(const Mat4f &m) +{ + Vec4f plane( + m.matrix[3 + 0 * 4] + m.matrix[1 + 0 * 4], + m.matrix[3 + 1 * 4] + m.matrix[1 + 1 * 4], + m.matrix[3 + 2 * 4] + m.matrix[1 + 2 * 4], + m.matrix[3 + 3 * 4] + m.matrix[1 + 3 * 4]); + plane /= plane.length3(); + return plane; +} + +Vec4f FrustumPlanes::near_frustum_plane(const Mat4f &m) +{ + Vec4f plane( + m.matrix[3 + 0 * 4] + m.matrix[2 + 0 * 4], + m.matrix[3 + 1 * 4] + m.matrix[2 + 1 * 4], + m.matrix[3 + 2 * 4] + m.matrix[2 + 2 * 4], + m.matrix[3 + 3 * 4] + m.matrix[2 + 3 * 4]); + plane /= plane.length3(); + return plane; +} + +Vec4f FrustumPlanes::far_frustum_plane(const Mat4f &m) +{ + Vec4f plane( + m.matrix[3 + 0 * 4] - m.matrix[2 + 0 * 4], + m.matrix[3 + 1 * 4] - m.matrix[2 + 1 * 4], + m.matrix[3 + 2 * 4] - m.matrix[2 + 2 * 4], + m.matrix[3 + 3 * 4] - m.matrix[2 + 3 * 4]); + plane /= plane.length3(); + return plane; +} diff --git a/src/r_poly_intersection.h b/src/r_poly_intersection.h new file mode 100644 index 000000000..16f30201c --- /dev/null +++ b/src/r_poly_intersection.h @@ -0,0 +1,167 @@ +/* +** Various 3D intersection tests +** Copyright (c) 1997-2015 The UICore Team +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +#include "r_triangle.h" +#include + +class Vec4f +{ +public: + Vec4f() = default; + Vec4f(const Vec4f &) = default; + Vec4f(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) { } + Vec4f(float v) : x(v), y(v), z(v), w(v) { } + + static float dot(const Vec4f &a, const Vec4f &b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } + static float dot3(const Vec4f &a, const Vec4f &b) { return a.x * b.x + a.y * b.y + a.z * b.z; } + float length3() const { return std::sqrt(dot3(*this, *this)); } + float magnitude() const { return std::sqrt(dot(*this, *this)); } + + Vec4f &operator+=(const Vec4f &b) { *this = Vec4f(x + b.x, y + b.y, z + b.z, w + b.w); return *this; } + Vec4f &operator-=(const Vec4f &b) { *this = Vec4f(x - b.x, y - b.y, z - b.z, w - b.w); return *this; } + Vec4f &operator*=(const Vec4f &b) { *this = Vec4f(x * b.x, y * b.y, z * b.z, w * b.w); return *this; } + Vec4f &operator/=(const Vec4f &b) { *this = Vec4f(x / b.x, y / b.y, z / b.z, w / b.w); return *this; } + Vec4f &operator+=(float b) { *this = Vec4f(x + b, y + b, z + b, w + b); return *this; } + Vec4f &operator-=(float b) { *this = Vec4f(x - b, y - b, z - b, w - b); return *this; } + Vec4f &operator*=(float b) { *this = Vec4f(x * b, y * b, z * b, w * b); return *this; } + Vec4f &operator/=(float b) { *this = Vec4f(x / b, y / b, z / b, w / b); return *this; } + + float x, y, z, w; +}; + +class Vec3f +{ +public: + Vec3f() = default; + Vec3f(const Vec3f &) = default; + Vec3f(const Vec4f &v) : x(v.x), y(v.y), z(v.z) { } + Vec3f(float x, float y, float z) : x(x), y(y), z(z) { } + Vec3f(float v) : x(v), y(v), z(v) { } + + static float dot(const Vec3f &a, const Vec3f &b) { return a.x * b.x + a.y * b.y + a.z * b.z; } + float length() const { return std::sqrt(dot(*this, *this)); } + + Vec3f &operator+=(const Vec3f &b) { *this = Vec3f(x + b.x, y + b.y, z + b.z); return *this; } + Vec3f &operator-=(const Vec3f &b) { *this = Vec3f(x - b.x, y - b.y, z - b.z); return *this; } + Vec3f &operator*=(const Vec3f &b) { *this = Vec3f(x * b.x, y * b.y, z * b.z); return *this; } + Vec3f &operator/=(const Vec3f &b) { *this = Vec3f(x / b.x, y / b.y, z / b.z); return *this; } + Vec3f &operator+=(float b) { *this = Vec3f(x + b, y + b, z + b); return *this; } + Vec3f &operator-=(float b) { *this = Vec3f(x - b, y - b, z - b); return *this; } + Vec3f &operator*=(float b) { *this = Vec3f(x * b, y * b, z * b); return *this; } + Vec3f &operator/=(float b) { *this = Vec3f(x / b, y / b, z / b); return *this; } + + float x, y, z; +}; + +inline Vec3f operator+(const Vec3f &a, const Vec3f &b) { return Vec3f(a.x + b.x, a.y + b.y, a.z + b.z); } +inline Vec3f operator-(const Vec3f &a, const Vec3f &b) { return Vec3f(a.x - b.x, a.y - b.y, a.z - b.z); } +inline Vec3f operator*(const Vec3f &a, const Vec3f &b) { return Vec3f(a.x * b.x, a.y * b.y, a.z * b.z); } +inline Vec3f operator/(const Vec3f &a, const Vec3f &b) { return Vec3f(a.x / b.x, a.y / b.y, a.z / b.z); } + +inline Vec3f operator+(const Vec3f &a, float b) { return Vec3f(a.x + b, a.y + b, a.z + b); } +inline Vec3f operator-(const Vec3f &a, float b) { return Vec3f(a.x - b, a.y - b, a.z - b); } +inline Vec3f operator*(const Vec3f &a, float b) { return Vec3f(a.x * b, a.y * b, a.z * b); } +inline Vec3f operator/(const Vec3f &a, float b) { return Vec3f(a.x / b, a.y / b, a.z / b); } + +inline Vec3f operator+(float a, const Vec3f &b) { return Vec3f(a + b.x, a + b.y, a + b.z); } +inline Vec3f operator-(float a, const Vec3f &b) { return Vec3f(a - b.x, a - b.y, a - b.z); } +inline Vec3f operator*(float a, const Vec3f &b) { return Vec3f(a * b.x, a * b.y, a * b.z); } +inline Vec3f operator/(float a, const Vec3f &b) { return Vec3f(a / b.x, a / b.y, a / b.z); } + +typedef TriMatrix Mat4f; + +class AxisAlignedBoundingBox +{ +public: + AxisAlignedBoundingBox() : aabb_min(), aabb_max() {} + AxisAlignedBoundingBox(const Vec3f &aabb_min, const Vec3f &aabb_max) : aabb_min(aabb_min), aabb_max(aabb_max) { } + AxisAlignedBoundingBox(const AxisAlignedBoundingBox &aabb, const Vec3f &barycentric_min, const Vec3f &barycentric_max) + : aabb_min(mix(aabb.aabb_min, aabb.aabb_max, barycentric_min)), aabb_max(mix(aabb.aabb_min, aabb.aabb_max, barycentric_max)) { } + + Vec3f center() const { return (aabb_max + aabb_min) * 0.5f; } + Vec3f extents() const { return (aabb_max - aabb_min) * 0.5f; } + + Vec3f aabb_min; + Vec3f aabb_max; + +private: + template + inline A mix(A a, B b, C mix) + { + return a * (C(1) - mix) + b * mix; + } +}; + +class OrientedBoundingBox +{ +public: + Vec3f center; + Vec3f extents; + Vec3f axis_x; + Vec3f axis_y; + Vec3f axis_z; +}; + +class FrustumPlanes +{ +public: + FrustumPlanes(); + explicit FrustumPlanes(const Mat4f &world_to_projection); + + Vec4f planes[6]; + +private: + static Vec4f left_frustum_plane(const Mat4f &matrix); + static Vec4f right_frustum_plane(const Mat4f &matrix); + static Vec4f top_frustum_plane(const Mat4f &matrix); + static Vec4f bottom_frustum_plane(const Mat4f &matrix); + static Vec4f near_frustum_plane(const Mat4f &matrix); + static Vec4f far_frustum_plane(const Mat4f &matrix); +}; + +class IntersectionTest +{ +public: + enum Result + { + outside, + inside, + intersecting, + }; + + enum OverlapResult + { + disjoint, + overlap + }; + + static Result plane_aabb(const Vec4f &plane, const AxisAlignedBoundingBox &aabb); + static Result plane_obb(const Vec4f &plane, const OrientedBoundingBox &obb); + static OverlapResult sphere(const Vec3f ¢er1, float radius1, const Vec3f ¢er2, float radius2); + static OverlapResult sphere_aabb(const Vec3f ¢er, float radius, const AxisAlignedBoundingBox &aabb); + static OverlapResult aabb(const AxisAlignedBoundingBox &a, const AxisAlignedBoundingBox &b); + static Result frustum_aabb(const FrustumPlanes &frustum, const AxisAlignedBoundingBox &box); + static Result frustum_obb(const FrustumPlanes &frustum, const OrientedBoundingBox &box); + static OverlapResult ray_aabb(const Vec3f &ray_start, const Vec3f &ray_end, const AxisAlignedBoundingBox &box); +}; From b16e6725d7067397a0a3a5b4531882d63cdfa3dd Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 12 Nov 2016 18:09:05 +0200 Subject: [PATCH 1205/1509] Added missing #include to fix build with GCC/Clang --- src/r_poly_intersection.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/r_poly_intersection.h b/src/r_poly_intersection.h index 16f30201c..48ebef031 100644 --- a/src/r_poly_intersection.h +++ b/src/r_poly_intersection.h @@ -24,6 +24,7 @@ #include "r_triangle.h" #include +#include class Vec4f { From af7a7ab7d71780fd171a22948dda56bc3caae4bc Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 13 Nov 2016 08:57:29 +0100 Subject: [PATCH 1206/1509] Remove use of the llvm.round intrinsic as it apparently doesn't work in some environments --- .../fixedfunction/drawtrianglecodegen.cpp | 19 +++++++++++++------ .../fixedfunction/drawtrianglecodegen.h | 1 + src/r_compiler/ssa/ssa_float.cpp | 3 +++ src/r_compiler/ssa/ssa_float.h | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index 4819a28cf..013969bbb 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -39,18 +39,25 @@ void DrawTriangleCodegen::Generate(TriDrawVariant variant, bool truecolor, SSAVa LoopBlockY(variant, truecolor); } +SSAInt DrawTriangleCodegen::FloatTo28_4(SSAFloat v) +{ + // SSAInt(SSAFloat::round(16.0f * v), false); + SSAInt a = SSAInt(v * 32.0f, false); + return (a + (a.ashr(31) | SSAInt(1))).ashr(1); +} + void DrawTriangleCodegen::Setup(TriDrawVariant variant, bool truecolor) { int pixelsize = truecolor ? 4 : 1; // 28.4 fixed-point coordinates - Y1 = SSAInt(SSAFloat::round(16.0f * v1.y), false); - Y2 = SSAInt(SSAFloat::round(16.0f * v2.y), false); - Y3 = SSAInt(SSAFloat::round(16.0f * v3.y), false); + Y1 = FloatTo28_4(v1.y); + Y2 = FloatTo28_4(v2.y); + Y3 = FloatTo28_4(v3.y); - X1 = SSAInt(SSAFloat::round(16.0f * v1.x), false); - X2 = SSAInt(SSAFloat::round(16.0f * v2.x), false); - X3 = SSAInt(SSAFloat::round(16.0f * v3.x), false); + X1 = FloatTo28_4(v1.x); + X2 = FloatTo28_4(v2.x); + X3 = FloatTo28_4(v3.x); // Deltas DX12 = X1 - X2; diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.h b/src/r_compiler/fixedfunction/drawtrianglecodegen.h index 6f9a6c32a..eba1caf4f 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.h +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.h @@ -40,6 +40,7 @@ private: SSATriVertex LoadTriVertex(SSAValue v); void LoadUniforms(SSAValue uniforms); void Setup(TriDrawVariant variant, bool truecolor); + SSAInt FloatTo28_4(SSAFloat v); void LoopBlockY(TriDrawVariant variant, bool truecolor); void LoopBlockX(TriDrawVariant variant, bool truecolor); void LoopFullBlock(TriDrawVariant variant, bool truecolor); diff --git a/src/r_compiler/ssa/ssa_float.cpp b/src/r_compiler/ssa/ssa_float.cpp index 77cef29ff..a45bee613 100644 --- a/src/r_compiler/ssa/ssa_float.cpp +++ b/src/r_compiler/ssa/ssa_float.cpp @@ -112,12 +112,15 @@ SSAFloat SSAFloat::fma(SSAFloat a, SSAFloat b, SSAFloat c) return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::fma, params), args, SSAScope::hint())); } +/* This intrinsic isn't always available.. SSAFloat SSAFloat::round(SSAFloat val) { + std::vector params; params.push_back(SSAFloat::llvm_type()); return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::round, params), val.v, SSAScope::hint())); } +*/ SSAFloat SSAFloat::floor(SSAFloat val) { diff --git a/src/r_compiler/ssa/ssa_float.h b/src/r_compiler/ssa/ssa_float.h index 9386db017..69fb81a75 100644 --- a/src/r_compiler/ssa/ssa_float.h +++ b/src/r_compiler/ssa/ssa_float.h @@ -43,7 +43,7 @@ public: static SSAFloat exp(SSAFloat val); static SSAFloat log(SSAFloat val); static SSAFloat fma(SSAFloat a, SSAFloat b, SSAFloat c); - static SSAFloat round(SSAFloat val); + //static SSAFloat round(SSAFloat val); static SSAFloat floor(SSAFloat val); static SSAFloat MIN(SSAFloat a, SSAFloat b); static SSAFloat MAX(SSAFloat a, SSAFloat b); From 27eb8e36aea92f32a7506ae97b4695820e239e25 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 13 Nov 2016 11:44:07 +0100 Subject: [PATCH 1207/1509] Fix solid segment culling --- src/r_poly.cpp | 72 +++++++++++++++++++++++--------------------------- src/r_poly.h | 1 + 2 files changed, 34 insertions(+), 39 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index e8a34544b..e54452e10 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -47,9 +47,9 @@ void RenderPolyBsp::Render() // Setup working buffers PolyVertexBuffer::Clear(); SolidSegments.clear(); - SolidSegments.reserve(MAXWIDTH / 2 + 2); - SolidSegments.push_back({ -0x7fff, 0 }); - SolidSegments.push_back({ viewwidth, 0x7fff }); + SolidSegments.reserve(SolidCullScale + 2); + SolidSegments.push_back({ -0x7fff, -SolidCullScale }); + SolidSegments.push_back({ SolidCullScale , 0x7fff }); SectorSpriteRanges.clear(); SectorSpriteRanges.resize(numsectors); SortedSprites.clear(); @@ -1027,12 +1027,12 @@ bool RenderPolyBsp::CheckBBox(float *bspcoord) { // Start using a quick frustum AABB test: - AxisAlignedBoundingBox aabb(Vec3f(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM], -1000.0f), Vec3f(bspcoord[BOXRIGHT], bspcoord[BOXTOP], 1000.0f)); + AxisAlignedBoundingBox aabb(Vec3f(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM], (float)ViewPos.Z - 1000.0f), Vec3f(bspcoord[BOXRIGHT], bspcoord[BOXTOP], (float)ViewPos.Z + 1000.0f)); auto result = IntersectionTest::frustum_aabb(frustumPlanes, aabb); if (result == IntersectionTest::outside) return false; - // Occlusion test using solid segments (which seems to be quite broken, actually): + // Occlusion test using solid segments: int boxx; int boxy; @@ -1089,51 +1089,45 @@ bool RenderPolyBsp::CheckBBox(float *bspcoord) bool RenderPolyBsp::GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const { + double znear = 5.0; + + // Transform to 2D view space: x1 = x1 - ViewPos.X; y1 = y1 - ViewPos.Y; x2 = x2 - ViewPos.X; y2 = y2 - ViewPos.Y; - - // Sitting on a line? - if (y1 * (x1 - x2) + x1 * (y2 - y1) >= -EQUAL_EPSILON) - return false; - double rx1 = x1 * ViewSin - y1 * ViewCos; double rx2 = x2 * ViewSin - y2 * ViewCos; - double ry1 = x1 * ViewTanCos + y1 * ViewTanSin; - double ry2 = x2 * ViewTanCos + y2 * ViewTanSin; + double ry1 = x1 * ViewCos + y1 * ViewSin; + double ry2 = x2 * ViewCos + y2 * ViewSin; - if (rx1 >= -ry1) + // Cull if line is entirely behind view + if (ry1 < znear && ry2 < znear) return false; + + // Clip line, if needed + double t1 = 0.0f, t2 = 1.0f; + if (ry1 < znear) + t1 = clamp((znear - ry1) / (ry2 - ry1), 0.0, 1.0); + if (ry2 < znear) + t2 = clamp((znear - ry1) / (ry2 - ry1), 0.0, 1.0); + if (t1 != 0.0 || t2 != 1.0) { - if (rx1 > ry1) return false; // left edge is off the right side - if (ry1 == 0) return false; - sx1 = xs_RoundToInt(CenterX + rx1 * CenterX / ry1); - } - else - { - if (rx2 < -ry2) return false; // wall is off the left side - if (rx1 - rx2 - ry2 + ry1 == 0) return false; // wall does not intersect view volume - sx1 = 0; + double nx1 = rx1 * (1.0 - t1) + rx2 * t1; + double ny1 = ry1 * (1.0 - t1) + ry2 * t1; + double nx2 = rx1 * (1.0 - t2) + rx2 * t2; + double ny2 = ry1 * (1.0 - t2) + ry2 * t2; + rx1 = nx1; + rx2 = nx2; + ry1 = ny1; + ry2 = ny2; } - if (rx2 <= ry2) - { - if (rx2 < -ry2) return false; // right edge is off the left side - if (ry2 == 0) return false; - sx2 = xs_RoundToInt(CenterX + rx2 * CenterX / ry2); - } - else - { - if (rx1 > ry1) return false; // wall is off the right side - if (ry2 - ry1 - rx2 + rx1 == 0) return false; // wall does not intersect view volume - sx2 = viewwidth; - } + sx1 = (int)floor(clamp(rx1 / ry1 * (SolidCullScale / 3), (double)-SolidCullScale, (double)SolidCullScale)); + sx2 = (int)floor(clamp(rx2 / ry2 * (SolidCullScale / 3), (double)-SolidCullScale, (double)SolidCullScale)); - // Does not cross a pixel. - if (sx2 <= sx1) - return false; - - return true; + if (sx1 > sx2) + std::swap(sx1, sx2); + return sx1 != sx2; } ///////////////////////////////////////////////////////////////////////////// diff --git a/src/r_poly.h b/src/r_poly.h index f1718f266..45cbcf864 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -162,6 +162,7 @@ private: }; std::vector SolidSegments; + const int SolidCullScale = 3000; PolySkyDome skydome; }; From c914a7a7fea6a54c0ab3f5b5231978a512a278b7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 13 Nov 2016 13:24:36 +0100 Subject: [PATCH 1208/1509] Cull walls --- src/r_poly.cpp | 22 ++++++++++++++++++---- src/r_poly.h | 3 +-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index e54452e10..a34853e2e 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -46,10 +46,7 @@ void RenderPolyBsp::Render() // Setup working buffers PolyVertexBuffer::Clear(); - SolidSegments.clear(); - SolidSegments.reserve(SolidCullScale + 2); - SolidSegments.push_back({ -0x7fff, -SolidCullScale }); - SolidSegments.push_back({ SolidCullScale , 0x7fff }); + ClearSolidSegments(); SectorSpriteRanges.clear(); SectorSpriteRanges.resize(numsectors); SortedSprites.clear(); @@ -92,6 +89,7 @@ void RenderPolyBsp::Render() } // Render front to back + ClearSolidSegments(); if (r_debug_cull) { for (auto it = PvsSectors.rbegin(); it != PvsSectors.rend(); ++it) @@ -363,6 +361,12 @@ void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector, uint32_t subsect if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0) return; + // Cull wall if not visible + int sx1, sx2; + bool hasSegmentRange = GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2); + if (hasSegmentRange && IsSegmentCulled(sx1, sx2)) + return; + double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1); double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1); double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2); @@ -384,6 +388,8 @@ void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector, uint32_t subsect wall.UnpeggedCeil = frontceilz1; wall.Texpart = side_t::mid; wall.Render(worldToClip); + if (hasSegmentRange) + MarkSegmentCulled(sx1, sx2); } } else @@ -972,6 +978,14 @@ void RenderPolyBsp::RenderPlayerSprite(DPSprite *sprite, AActor *owner, float bo //R_DrawVisSprite(vis); } +void RenderPolyBsp::ClearSolidSegments() +{ + SolidSegments.clear(); + SolidSegments.reserve(SolidCullScale + 2); + SolidSegments.push_back({ -0x7fff, -SolidCullScale }); + SolidSegments.push_back({ SolidCullScale , 0x7fff }); +} + bool RenderPolyBsp::IsSegmentCulled(int x1, int x2) const { int next = 0; diff --git a/src/r_poly.h b/src/r_poly.h index 45cbcf864..b2a024488 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -132,11 +132,10 @@ private: // Checks BSP node/subtree bounding box. // Returns true if some part of the bbox might be visible. bool CheckBBox(float *bspcoord); - bool GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const; - void MarkSegmentCulled(int x1, int x2); bool IsSegmentCulled(int x1, int x2) const; + void ClearSolidSegments(); std::vector PvsSectors; uint32_t NextSubsectorDepth = 0; From 411eb579527f5ebc543ab11f24fea5383218bac5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 13 Nov 2016 15:16:55 +0100 Subject: [PATCH 1209/1509] Fix rendering of masked walls --- src/r_poly.cpp | 36 +++++++++++++------- src/r_poly.h | 92 +++++++++++++++++++++++++++----------------------- 2 files changed, 73 insertions(+), 55 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index a34853e2e..94e27cd43 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -50,7 +50,7 @@ void RenderPolyBsp::Render() SectorSpriteRanges.clear(); SectorSpriteRanges.resize(numsectors); SortedSprites.clear(); - SubsectoredSprites.clear(); + TranslucentObjects.clear(); PvsSectors.clear(); ScreenSprites.clear(); PolyStencilBuffer::Instance()->Clear(viewwidth, viewheight, 0); @@ -103,7 +103,7 @@ void RenderPolyBsp::Render() skydome.Render(worldToClip); - RenderSprites(); + RenderTranslucent(); RenderPlayerSprites(); DrawerCommandQueue::WaitForWorkers(); @@ -140,19 +140,24 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) for (int i = 0; i < sprites.Count; i++) { AActor *thing = SortedSprites[sprites.Start + i].Thing; - SubsectoredSprites.push_back({ thing, sub, subsectorDepth }); + TranslucentObjects.push_back({ thing, sub, subsectorDepth }); } + + TranslucentObjects.insert(TranslucentObjects.end(), TempTranslucentWalls.begin(), TempTranslucentWalls.end()); + TempTranslucentWalls.clear(); } -void RenderPolyBsp::RenderSprites() +void RenderPolyBsp::RenderTranslucent() { - for (auto it = SubsectoredSprites.rbegin(); it != SubsectoredSprites.rend(); ++it) + for (auto it = TranslucentObjects.rbegin(); it != TranslucentObjects.rend(); ++it) { - auto &spr = *it; - if ((spr.thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) - AddWallSprite(spr.thing, spr.sub, spr.subsectorDepth); + auto &obj = *it; + if (!obj.thing) + obj.wall.Render(worldToClip); + else if ((obj.thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) + AddWallSprite(obj.thing, obj.sub, obj.subsectorDepth); else - AddSprite(spr.thing, spr.sub, spr.subsectorDepth); + AddSprite(obj.thing, obj.sub, obj.subsectorDepth); } } @@ -448,7 +453,7 @@ void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector, uint32_t subsect wall.UnpeggedCeil = topceilz1; wall.Texpart = side_t::mid; wall.Masked = true; - wall.Render(worldToClip); + TempTranslucentWalls.push_back({ wall }); } } } @@ -1206,8 +1211,15 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) args.stencilwritevalue = 1; args.SetTexture(tex); - PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); + if (!Masked) + { + PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); + } + else + { + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector); + } } FTexture *RenderPolyWall::GetTexture() diff --git a/src/r_poly.h b/src/r_poly.h index b2a024488..6c5051904 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -50,6 +50,42 @@ public: FDynamicColormap *Colormap = nullptr; }; +class RenderPolyWall +{ +public: + void Render(const TriMatrix &worldToClip); + + void SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2) + { + this->v1 = v1; + this->v2 = v2; + this->ceil1 = ceil1; + this->floor1 = floor1; + this->ceil2 = ceil2; + this->floor2 = floor2; + } + + DVector2 v1; + DVector2 v2; + double ceil1 = 0.0; + double floor1 = 0.0; + double ceil2 = 0.0; + double floor2 = 0.0; + + const seg_t *Line = nullptr; + side_t::ETexpart Texpart = side_t::mid; + double TopZ = 0.0; + double BottomZ = 0.0; + double UnpeggedCeil = 0.0; + FSWColormap *Colormap = nullptr; + bool Masked = false; + uint32_t SubsectorDepth = 0; + +private: + FTexture *GetTexture(); + int GetLightLevel(); +}; + // Used for sorting things by distance to the camera class PolySortedSprite { @@ -61,13 +97,17 @@ public: double DistanceSquared; }; -class PolySubsectoredSprite +class PolyTranslucentObject { public: - PolySubsectoredSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) : thing(thing), sub(sub), subsectorDepth(subsectorDepth) { } - AActor *thing; - subsector_t *sub; - uint32_t subsectorDepth; + PolyTranslucentObject(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) : thing(thing), sub(sub), subsectorDepth(subsectorDepth) { } + PolyTranslucentObject(RenderPolyWall wall) : wall(wall) { } + + AActor *thing = nullptr; + subsector_t *sub = nullptr; + uint32_t subsectorDepth = 0; + + RenderPolyWall wall; }; class SpriteRange @@ -116,7 +156,7 @@ private: void AddLine(seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); TriVertex PlaneVertex(vertex_t *v1, sector_t *sector, double height); - void RenderSprites(); + void RenderTranslucent(); void AddSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth); void AddWallSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth); bool IsThingCulled(AActor *thing); @@ -147,7 +187,9 @@ private: std::vector SectorSpriteRanges; std::vector SortedSprites; - std::vector SubsectoredSprites; + std::vector TranslucentObjects; + + std::vector TempTranslucentWalls; std::vector ScreenSprites; @@ -166,42 +208,6 @@ private: PolySkyDome skydome; }; -class RenderPolyWall -{ -public: - void Render(const TriMatrix &worldToClip); - - void SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2) - { - this->v1 = v1; - this->v2 = v2; - this->ceil1 = ceil1; - this->floor1 = floor1; - this->ceil2 = ceil2; - this->floor2 = floor2; - } - - DVector2 v1; - DVector2 v2; - double ceil1 = 0.0; - double floor1 = 0.0; - double ceil2 = 0.0; - double floor2 = 0.0; - - const seg_t *Line = nullptr; - side_t::ETexpart Texpart = side_t::mid; - double TopZ = 0.0; - double BottomZ = 0.0; - double UnpeggedCeil = 0.0; - FSWColormap *Colormap = nullptr; - bool Masked = false; - uint32_t SubsectorDepth = 0; - -private: - FTexture *GetTexture(); - int GetLightLevel(); -}; - // Texture coordinates for a wall class PolyWallTextureCoords { From f25579849af52cf999b0b825f2027de2759cd49f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 13 Nov 2016 15:43:54 +0100 Subject: [PATCH 1210/1509] Minor variable optimization --- .../fixedfunction/drawtrianglecodegen.cpp | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index 013969bbb..bd6b26268 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -284,8 +284,8 @@ void DrawTriangleCodegen::LoopFullBlock(TriDrawVariant variant, bool truecolor) int pixelsize = truecolor ? 4 : 1; stack_iy.store(SSAInt(0)); - stack_buffer.store(dest); - stack_subsectorbuffer.store(subsectorGBuffer); + stack_buffer.store(dest[x * pixelsize]); + stack_subsectorbuffer.store(subsectorGBuffer[x]); SSAForBlock loopy; SSAInt iy = stack_iy.load(); @@ -303,32 +303,26 @@ void DrawTriangleCodegen::LoopFullBlock(TriDrawVariant variant, bool truecolor) varyingStep[i] = SSAInt(step * SSAFloat((float)0x100000000LL), true); } - stack_ix.store(x); + stack_ix.store(SSAInt(0)); SSAForBlock loopx; SSAInt ix = stack_ix.load(); SSAInt varying[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) varying[i] = stack_varying[i].load(); - loopx.loop_block(ix < x + q, q); + loopx.loop_block(ix < SSAInt(q), q); { if (variant == TriDrawVariant::DrawSubsector) { SSAIfBlock branch; branch.if_block(subsectorbuffer[ix].load(true) >= subsectorDepth); { - if (truecolor) - ProcessPixel(buffer[ix * 4], subsectorbuffer[ix], varying, variant, truecolor); - else - ProcessPixel(buffer[ix], subsectorbuffer[ix], varying, variant, truecolor); + ProcessPixel(buffer[ix * pixelsize], subsectorbuffer[ix], varying, variant, truecolor); } branch.end_block(); } else { - if (truecolor) - ProcessPixel(buffer[ix * 4], subsectorbuffer[ix], varying, variant, truecolor); - else - ProcessPixel(buffer[ix], subsectorbuffer[ix], varying, variant, truecolor); + ProcessPixel(buffer[ix * pixelsize], subsectorbuffer[ix], varying, variant, truecolor); } for (int i = 0; i < TriVertex::NumVarying; i++) @@ -359,8 +353,8 @@ void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolo stack_CY2.store(C2 + DX23 * y0 - DY23 * x0); stack_CY3.store(C3 + DX31 * y0 - DY31 * x0); stack_iy.store(SSAInt(0)); - stack_buffer.store(dest); - stack_subsectorbuffer.store(subsectorGBuffer); + stack_buffer.store(dest[x * pixelsize]); + stack_subsectorbuffer.store(subsectorGBuffer[x]); SSAForBlock loopy; SSAInt iy = stack_iy.load(); @@ -401,7 +395,7 @@ void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolo if (variant == TriDrawVariant::DrawSubsector) { - covered = covered && subsectorbuffer[ix + x].load(true) >= subsectorDepth; + covered = covered && subsectorbuffer[ix].load(true) >= subsectorDepth; } else { @@ -417,10 +411,7 @@ void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolo } else { - if (truecolor) - ProcessPixel(buffer[(ix + x) * 4], subsectorbuffer[ix + x], varying, variant, truecolor); - else - ProcessPixel(buffer[ix + x], subsectorbuffer[ix + x], varying, variant, truecolor); + ProcessPixel(buffer[ix * pixelsize], subsectorbuffer[ix], varying, variant, truecolor); } } branch.end_block(); From acb2e821f01ffb4d5264f3a6e977e8ae8ce0ebe8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 13 Nov 2016 16:36:47 +0100 Subject: [PATCH 1211/1509] Evict floats from the block code (too bad it didn't make any difference to the speed) --- .../fixedfunction/drawtrianglecodegen.cpp | 32 +++++++++++-------- .../fixedfunction/drawtrianglecodegen.h | 8 ++--- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index bd6b26268..257b550ce 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -228,10 +228,20 @@ void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) SSAFloat rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); for (int i = 0; i < TriVertex::NumVarying; i++) { - varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; - varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; - varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); - varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); + SSAFloat varyingTL = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; + SSAFloat varyingTR = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; + SSAFloat varyingBL = (startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL; + SSAFloat varyingBR = (startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR; + + SSAFloat pos = varyingTL; + SSAFloat stepPos = (varyingBL - varyingTL) * (1.0f / q); + SSAFloat startStepX = (varyingTR - varyingTL) * (1.0f / q); + SSAFloat incrStepX = (varyingBR - varyingBL) * (1.0f / q) - startStepX; + + varyingPos[i] = SSAInt(pos * SSAFloat((float)0x01000000), false); + varyingStepPos[i] = SSAInt(stepPos * SSAFloat((float)0x01000000), false); + varyingStartStepX[i] = SSAInt(startStepX * SSAFloat((float)0x01000000), false); + varyingIncrStepX[i] = SSAInt(incrStepX * SSAFloat((float)0x01000000), false); } SSAFloat globVis = SSAFloat(1706.0f); @@ -296,11 +306,8 @@ void DrawTriangleCodegen::LoopFullBlock(TriDrawVariant variant, bool truecolor) SSAInt varyingStep[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) { - SSAFloat pos = varyingTL[i] + varyingBL[i] * SSAFloat(iy); - SSAFloat step = (varyingTR[i] + varyingBR[i] * SSAFloat(iy) - pos) * (1.0f / q); - - stack_varying[i].store(SSAInt((pos - SSAFloat::floor(pos)) * SSAFloat((float)0x100000000LL), true)); - varyingStep[i] = SSAInt(step * SSAFloat((float)0x100000000LL), true); + stack_varying[i].store((varyingPos[i] + varyingStepPos[i] * iy) << 8); + varyingStep[i] = (varyingStartStepX[i] + varyingIncrStepX[i] * iy) << 8; } stack_ix.store(SSAInt(0)); @@ -368,11 +375,8 @@ void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolo SSAInt varyingStep[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) { - SSAFloat pos = varyingTL[i] + varyingBL[i] * SSAFloat(iy); - SSAFloat step = (varyingTR[i] + varyingBR[i] * SSAFloat(iy) - pos) * (1.0f / q); - - stack_varying[i].store(SSAInt((pos - SSAFloat::floor(pos)) * SSAFloat((float)0x100000000LL), true)); - varyingStep[i] = SSAInt(step * SSAFloat((float)0x100000000LL), true); + stack_varying[i].store((varyingPos[i] + varyingStepPos[i] * iy) << 8); + varyingStep[i] = (varyingStartStepX[i] + varyingIncrStepX[i] * iy) << 8; } stack_CX1.store(CY1); diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.h b/src/r_compiler/fixedfunction/drawtrianglecodegen.h index eba1caf4f..c9fb61e67 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.h +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.h @@ -116,10 +116,10 @@ private: SSAInt x, y; SSAInt x0, x1, y0, y1; SSAInt diminishedlight; - SSAFloat varyingTL[TriVertex::NumVarying]; - SSAFloat varyingTR[TriVertex::NumVarying]; - SSAFloat varyingBL[TriVertex::NumVarying]; - SSAFloat varyingBR[TriVertex::NumVarying]; + SSAInt varyingPos[TriVertex::NumVarying]; + SSAInt varyingStepPos[TriVertex::NumVarying]; + SSAInt varyingStartStepX[TriVertex::NumVarying]; + SSAInt varyingIncrStepX[TriVertex::NumVarying]; SSAUBytePtr StencilBlock; SSAIntPtr StencilBlockMask; From 1442f7fb7bfe4a5b693b3a7c4c228037dfb9479f Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sun, 13 Nov 2016 16:53:18 +0100 Subject: [PATCH 1212/1509] - Fixed Clang on Linux compilation. --- src/r_compiler/llvm_include.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_compiler/llvm_include.h b/src/r_compiler/llvm_include.h index fa23f0c0c..ad58666e3 100644 --- a/src/r_compiler/llvm_include.h +++ b/src/r_compiler/llvm_include.h @@ -46,7 +46,7 @@ #endif -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__clang__) #define __STDC_LIMIT_MACROS // DataTypes.h:57:3: error: "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h" #define __STDC_CONSTANT_MACROS // DataTypes.h:61:3: error: "Must #define __STDC_CONSTANT_MACROS before " "#including Support/DataTypes.h" #pragma clang diagnostic push @@ -80,7 +80,7 @@ #include #endif -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__clang__) #pragma clang diagnostic pop #endif From c06798bca1a51b1fcc40bba874353022669ad81a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 13 Nov 2016 17:58:03 +0100 Subject: [PATCH 1213/1509] Adjust texture coordinates --- src/r_compiler/fixedfunction/drawtrianglecodegen.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index 257b550ce..77076b072 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -123,6 +123,12 @@ void DrawTriangleCodegen::Setup(TriDrawVariant variant, bool truecolor) C3 = stack_C3.load(); // Gradients + v1.x = SSAFloat(X1) * 0.0625f; + v2.x = SSAFloat(X2) * 0.0625f; + v3.x = SSAFloat(X3) * 0.0625f; + v1.y = SSAFloat(Y1) * 0.0625f; + v2.y = SSAFloat(Y2) * 0.0625f; + v3.y = SSAFloat(Y3) * 0.0625f; gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); startW = v1.w + gradWX * (SSAFloat(minx) - v1.x) + gradWY * (SSAFloat(miny) - v1.y); @@ -218,8 +224,8 @@ void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) SSABool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); // Calculate varying variables for affine block - SSAFloat offx0 = SSAFloat(x - minx) + 0.5f; - SSAFloat offy0 = SSAFloat(y - miny) + 0.5f; + SSAFloat offx0 = SSAFloat(x - minx); + SSAFloat offy0 = SSAFloat(y - miny); SSAFloat offx1 = offx0 + SSAFloat(q); SSAFloat offy1 = offy0 + SSAFloat(q); SSAFloat rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); From 3673338644f9b4cfd372a332869896ac25287fdc Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 14 Nov 2016 14:19:48 +0100 Subject: [PATCH 1214/1509] Split r_poly into multiple files handling each aspect of rendering a scene --- src/CMakeLists.txt | 8 + src/r_main.cpp | 6 +- src/r_poly.cpp | 1482 +---------------------------------- src/r_poly.h | 159 +--- src/r_poly_cull.cpp | 259 ++++++ src/r_poly_cull.h | 61 ++ src/r_poly_particle.cpp | 33 + src/r_poly_particle.h | 29 + src/r_poly_plane.cpp | 196 +++++ src/r_poly_plane.h | 34 + src/r_poly_playersprite.cpp | 299 +++++++ src/r_poly_playersprite.h | 59 ++ src/r_poly_sky.cpp | 193 +++++ src/r_poly_sky.h | 45 ++ src/r_poly_sprite.cpp | 301 +++++++ src/r_poly_sprite.h | 37 + src/r_poly_wall.cpp | 334 ++++++++ src/r_poly_wall.h | 82 ++ src/r_poly_wallsprite.cpp | 35 + src/r_poly_wallsprite.h | 31 + src/r_swrenderer.cpp | 15 +- 21 files changed, 2107 insertions(+), 1591 deletions(-) create mode 100644 src/r_poly_cull.cpp create mode 100644 src/r_poly_cull.h create mode 100644 src/r_poly_particle.cpp create mode 100644 src/r_poly_particle.h create mode 100644 src/r_poly_plane.cpp create mode 100644 src/r_poly_plane.h create mode 100644 src/r_poly_playersprite.cpp create mode 100644 src/r_poly_playersprite.h create mode 100644 src/r_poly_sky.cpp create mode 100644 src/r_poly_sky.h create mode 100644 src/r_poly_sprite.cpp create mode 100644 src/r_poly_sprite.h create mode 100644 src/r_poly_wall.cpp create mode 100644 src/r_poly_wall.h create mode 100644 src/r_poly_wallsprite.cpp create mode 100644 src/r_poly_wallsprite.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index afe89f568..7933f80a7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1070,6 +1070,14 @@ set( FASTMATH_PCH_SOURCES r_swrenderer.cpp r_swrenderer2.cpp r_poly.cpp + r_poly_cull.cpp + r_poly_particle.cpp + r_poly_plane.cpp + r_poly_playersprite.cpp + r_poly_wall.cpp + r_poly_wallsprite.cpp + r_poly_sprite.cpp + r_poly_sky.cpp r_poly_triangle.cpp r_poly_intersection.cpp r_3dfloors.cpp diff --git a/src/r_main.cpp b/src/r_main.cpp index 149353a87..1ba89eecd 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -59,7 +59,6 @@ #include "v_font.h" #include "r_data/colormaps.h" #include "p_maputl.h" -#include "r_swrenderer2.h" #include "r_poly.h" #include "p_setup.h" #include "version.h" @@ -922,8 +921,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) } else { - static RenderPolyBsp bsp; - bsp.Render(); + RenderPolyScene::Instance()->Render(); } R_3D_ResetClip(); // reset clips (floor/ceiling) camera->renderflags = savedflags; @@ -955,7 +953,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) NetUpdate (); MaskedCycles.Clock(); - if (!r_newrenderer || !r_swtruecolor) + if (!r_newrenderer) R_DrawMasked (); MaskedCycles.Unclock(); diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 94e27cd43..42cc84e5f 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -1,5 +1,5 @@ /* -** Experimental Doom software renderer +** Polygon Doom software renderer ** Copyright (c) 2016 Magnus Norddahl ** ** This software is provided 'as-is', without any express or implied @@ -26,38 +26,27 @@ #include "sbar.h" #include "r_data/r_translate.h" #include "r_poly.h" -#include "r_draw.h" -#include "r_plane.h" // for yslope -#include "r_sky.h" // for skyflatnum -#include "r_things.h" // for pspritexscale - -EXTERN_CVAR(Bool, r_drawplayersprites) -EXTERN_CVAR(Bool, r_deathcamera) -EXTERN_CVAR(Bool, st_scale) CVAR(Bool, r_debug_cull, 0, 0) ///////////////////////////////////////////////////////////////////////////// -void RenderPolyBsp::Render() +void RenderPolyScene::Render() { if (!r_swtruecolor) // Disable pal rendering for now return; // Setup working buffers PolyVertexBuffer::Clear(); - ClearSolidSegments(); SectorSpriteRanges.clear(); SectorSpriteRanges.resize(numsectors); SortedSprites.clear(); TranslucentObjects.clear(); - PvsSectors.clear(); - ScreenSprites.clear(); PolyStencilBuffer::Instance()->Clear(viewwidth, viewheight, 0); PolySubsectorGBuffer::Instance()->Resize(dc_pitch, viewheight); NextSubsectorDepth = 0; - // Perspective correct: + // Setup perspective matrix: float ratio = WidescreenRatio; float fovratio = (WidescreenRatio >= 1.3f) ? 1.333333f : ratio; float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(FieldOfView.Radians() / 2) / fovratio)).Degrees); @@ -67,56 +56,35 @@ void RenderPolyBsp::Render() TriMatrix::rotate((float)(ViewAngle - 90).Radians(), 0.0f, -1.0f, 0.0f) * TriMatrix::swapYZ() * TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); - worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; + WorldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; - // Y shearing like the Doom renderer: - //worldToClip = TriMatrix::viewToClip() * TriMatrix::worldToView(); - - frustumPlanes = FrustumPlanes(worldToClip); - - // Cull front to back - if (numnodes == 0) - { - PvsSectors.push_back(subsectors); - MaxCeilingHeight = subsectors->sector->ceilingplane.Zat0(); - MinFloorHeight = subsectors->sector->floorplane.Zat0(); - } - else - { - MaxCeilingHeight = 0.0; - MinFloorHeight = 0.0; - RenderNode(nodes + numnodes - 1); // The head node is the last node output. - } - - // Render front to back - ClearSolidSegments(); + Cull.CullScene(WorldToClip); if (r_debug_cull) { - for (auto it = PvsSectors.rbegin(); it != PvsSectors.rend(); ++it) + for (auto it = Cull.PvsSectors.rbegin(); it != Cull.PvsSectors.rend(); ++it) RenderSubsector(*it); } else { - for (auto it = PvsSectors.begin(); it != PvsSectors.end(); ++it) + for (auto it = Cull.PvsSectors.begin(); it != Cull.PvsSectors.end(); ++it) RenderSubsector(*it); } - skydome.Render(worldToClip); + skydome.Render(WorldToClip); RenderTranslucent(); - RenderPlayerSprites(); + PlayerSprites.Render(); DrawerCommandQueue::WaitForWorkers(); - RenderScreenSprites(); // To do: should be called by FSoftwareRenderer::DrawRemainingPlayerSprites instead of here + RenderRemainingPlayerSprites(); // To do: should be called by FSoftwareRenderer::DrawRemainingPlayerSprites instead of here } -void RenderPolyBsp::RenderScreenSprites() +void RenderPolyScene::RenderRemainingPlayerSprites() { - for (auto &sprite : ScreenSprites) - sprite.Render(); + PlayerSprites.RenderRemainingSprites(); } -void RenderPolyBsp::RenderSubsector(subsector_t *sub) +void RenderPolyScene::RenderSubsector(subsector_t *sub) { sector_t *frontsector = sub->sector; frontsector->MoreFlags |= SECF_DRAWN; @@ -125,15 +93,16 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) if (sub->sector->CenterFloor() != sub->sector->CenterCeiling()) { - RenderPlane(sub, subsectorDepth, true); - RenderPlane(sub, subsectorDepth, false); + RenderPolyPlane plane; + plane.Render(WorldToClip, sub, subsectorDepth, true, Cull.MaxCeilingHeight); + plane.Render(WorldToClip, sub, subsectorDepth, false, Cull.MinFloorHeight); } for (uint32_t i = 0; i < sub->numlines; i++) { seg_t *line = &sub->firstline[i]; if (line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) - AddLine(line, frontsector, subsectorDepth); + RenderLine(line, frontsector, subsectorDepth); } SpriteRange sprites = GetSpritesForSector(sub->sector); @@ -143,202 +112,11 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub) TranslucentObjects.push_back({ thing, sub, subsectorDepth }); } - TranslucentObjects.insert(TranslucentObjects.end(), TempTranslucentWalls.begin(), TempTranslucentWalls.end()); - TempTranslucentWalls.clear(); + TranslucentObjects.insert(TranslucentObjects.end(), SubsectorTranslucentWalls.begin(), SubsectorTranslucentWalls.end()); + SubsectorTranslucentWalls.clear(); } -void RenderPolyBsp::RenderTranslucent() -{ - for (auto it = TranslucentObjects.rbegin(); it != TranslucentObjects.rend(); ++it) - { - auto &obj = *it; - if (!obj.thing) - obj.wall.Render(worldToClip); - else if ((obj.thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) - AddWallSprite(obj.thing, obj.sub, obj.subsectorDepth); - else - AddSprite(obj.thing, obj.sub, obj.subsectorDepth); - } -} - -void RenderPolyBsp::RenderPlane(subsector_t *sub, uint32_t subsectorDepth, bool ceiling) -{ - sector_t *frontsector = sub->sector; - - FTextureID picnum = frontsector->GetTexture(ceiling ? sector_t::ceiling : sector_t::floor); - FTexture *tex = TexMan(picnum); - if (tex->UseType == FTexture::TEX_Null) - return; - - bool isSky = picnum == skyflatnum; - double skyHeight = ceiling ? MaxCeilingHeight : MinFloorHeight; - - TriUniforms uniforms; - uniforms.objectToClip = worldToClip; - uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f); - if (fixedlightlev >= 0) - uniforms.light = (uint32_t)(fixedlightlev / 255.0f * 256.0f); - else if (fixedcolormap) - uniforms.light = 256; - uniforms.flags = 0; - uniforms.subsectorDepth = isSky ? SkySubsectorDepth : subsectorDepth; - - /* - double vis = r_FloorVisibility / (plane.Zat0() - ViewPos.Z); - if (fixedlightlev >= 0) - R_SetDSColorMapLight(sector->ColorMap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); - else if (fixedcolormap) - R_SetDSColorMapLight(fixedcolormap, 0, 0); - else - R_SetDSColorMapLight(sector->ColorMap, (float)(vis * fabs(CenterY - y)), LIGHT2SHADE(sector->lightlevel)); - */ - - TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); - if (!vertices) - return; - - if (ceiling) - { - for (uint32_t i = 0; i < sub->numlines; i++) - { - seg_t *line = &sub->firstline[i]; - vertices[sub->numlines - 1 - i] = PlaneVertex(line->v1, frontsector, isSky ? skyHeight : frontsector->ceilingplane.ZatPoint(line->v1)); - } - } - else - { - for (uint32_t i = 0; i < sub->numlines; i++) - { - seg_t *line = &sub->firstline[i]; - vertices[i] = PlaneVertex(line->v1, frontsector, isSky ? skyHeight : frontsector->floorplane.ZatPoint(line->v1)); - } - } - - PolyDrawArgs args; - args.uniforms = uniforms; - args.vinput = vertices; - args.vcount = sub->numlines; - args.mode = TriangleDrawMode::Fan; - args.ccw = true; - args.clipleft = 0; - args.cliptop = 0; - args.clipright = viewwidth; - args.clipbottom = viewheight; - args.stenciltestvalue = 0; - args.stencilwritevalue = 1; - - if (!isSky) - { - args.SetTexture(tex); - PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); - } - else - { - args.stencilwritevalue = 255; - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); - - for (uint32_t i = 0; i < sub->numlines; i++) - { - TriVertex *wallvert = PolyVertexBuffer::GetVertices(4); - if (!wallvert) - return; - - seg_t *line = &sub->firstline[i]; - - bool closedSky = false; - if (line->backsector) - { - sector_t *backsector = (line->backsector != line->frontsector) ? line->backsector : line->frontsector; - - double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1); - double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1); - double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2); - double frontfloorz2 = frontsector->floorplane.ZatPoint(line->v2); - - double backceilz1 = backsector->ceilingplane.ZatPoint(line->v1); - double backfloorz1 = backsector->floorplane.ZatPoint(line->v1); - double backceilz2 = backsector->ceilingplane.ZatPoint(line->v2); - double backfloorz2 = backsector->floorplane.ZatPoint(line->v2); - - double topceilz1 = frontceilz1; - double topceilz2 = frontceilz2; - double topfloorz1 = MIN(backceilz1, frontceilz1); - double topfloorz2 = MIN(backceilz2, frontceilz2); - double bottomceilz1 = MAX(frontfloorz1, backfloorz1); - double bottomceilz2 = MAX(frontfloorz2, backfloorz2); - double bottomfloorz1 = frontfloorz1; - double bottomfloorz2 = frontfloorz2; - double middleceilz1 = topfloorz1; - double middleceilz2 = topfloorz2; - double middlefloorz1 = MIN(bottomceilz1, middleceilz1); - double middlefloorz2 = MIN(bottomceilz2, middleceilz2); - - bool bothSkyCeiling = frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum; - bool bothSkyFloor = frontsector->GetTexture(sector_t::floor) == skyflatnum && backsector->GetTexture(sector_t::floor) == skyflatnum; - - bool closedSector = backceilz1 == backfloorz1 && backceilz2 == backfloorz2; - closedSky = (ceiling && bothSkyCeiling && closedSector) || (!ceiling && bothSkyFloor && closedSector); - if (!closedSky) - { - bool topwall = (topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && line->sidedef && !bothSkyCeiling; - bool bottomwall = (bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && line->sidedef && !bothSkyFloor; - if ((ceiling && !topwall) || (!ceiling && !bottomwall)) - continue; - } - } - - if (ceiling) - { - wallvert[0] = PlaneVertex(line->v1, frontsector, skyHeight); - wallvert[1] = PlaneVertex(line->v2, frontsector, skyHeight); - if (!closedSky) - { - wallvert[2] = PlaneVertex(line->v2, frontsector, frontsector->ceilingplane.ZatPoint(line->v2)); - wallvert[3] = PlaneVertex(line->v1, frontsector, frontsector->ceilingplane.ZatPoint(line->v1)); - } - else - { - wallvert[2] = PlaneVertex(line->v2, frontsector, frontsector->floorplane.ZatPoint(line->v2)); - wallvert[3] = PlaneVertex(line->v1, frontsector, frontsector->floorplane.ZatPoint(line->v1)); - } - } - else - { - if (!closedSky) - { - wallvert[0] = PlaneVertex(line->v1, frontsector, frontsector->floorplane.ZatPoint(line->v1)); - wallvert[1] = PlaneVertex(line->v2, frontsector, frontsector->floorplane.ZatPoint(line->v2)); - } - else - { - wallvert[0] = PlaneVertex(line->v1, frontsector, frontsector->ceilingplane.ZatPoint(line->v1)); - wallvert[1] = PlaneVertex(line->v2, frontsector, frontsector->ceilingplane.ZatPoint(line->v2)); - } - wallvert[2] = PlaneVertex(line->v2, frontsector, skyHeight); - wallvert[3] = PlaneVertex(line->v1, frontsector, skyHeight); - } - - args.vinput = wallvert; - args.vcount = 4; - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); - } - } -} - -TriVertex RenderPolyBsp::PlaneVertex(vertex_t *v1, sector_t *sector, double height) -{ - TriVertex v; - v.x = (float)v1->fPos().X; - v.y = (float)v1->fPos().Y; - v.z = (float)height; - v.w = 1.0f; - v.varying[0] = v.x / 64.0f; - v.varying[1] = 1.0f - v.y / 64.0f; - return v; -} - -SpriteRange RenderPolyBsp::GetSpritesForSector(sector_t *sector) +SpriteRange RenderPolyScene::GetSpritesForSector(sector_t *sector) { if (SectorSpriteRanges.size() < sector->sectornum || sector->sectornum < 0) return SpriteRange(); @@ -358,7 +136,7 @@ SpriteRange RenderPolyBsp::GetSpritesForSector(sector_t *sector) return range; } -void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector, uint32_t subsectorDepth) +void RenderPolyScene::RenderLine(seg_t *line, sector_t *frontsector, uint32_t subsectorDepth) { // Reject lines not facing viewer DVector2 pt1 = line->v1->fPos() - ViewPos; @@ -368,1063 +146,44 @@ void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector, uint32_t subsect // Cull wall if not visible int sx1, sx2; - bool hasSegmentRange = GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2); - if (hasSegmentRange && IsSegmentCulled(sx1, sx2)) + bool hasSegmentRange = Cull.GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2); + if (hasSegmentRange && Cull.IsSegmentCulled(sx1, sx2)) return; - double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1); - double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1); - double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2); - double frontfloorz2 = frontsector->floorplane.ZatPoint(line->v2); - - RenderPolyWall wall; - wall.Line = line; - wall.Colormap = frontsector->ColorMap; - wall.Masked = false; - wall.SubsectorDepth = subsectorDepth; - - if (line->backsector == nullptr) + // Render wall, and update culling info if its an occlusion blocker + if (RenderPolyWall::RenderLine(WorldToClip, line, frontsector, subsectorDepth, SubsectorTranslucentWalls)) { - if (line->sidedef) - { - wall.SetCoords(line->v1->fPos(), line->v2->fPos(), frontceilz1, frontfloorz1, frontceilz2, frontfloorz2); - wall.TopZ = frontceilz1; - wall.BottomZ = frontfloorz1; - wall.UnpeggedCeil = frontceilz1; - wall.Texpart = side_t::mid; - wall.Render(worldToClip); - if (hasSegmentRange) - MarkSegmentCulled(sx1, sx2); - } - } - else - { - sector_t *backsector = (line->backsector != line->frontsector) ? line->backsector : line->frontsector; - - double backceilz1 = backsector->ceilingplane.ZatPoint(line->v1); - double backfloorz1 = backsector->floorplane.ZatPoint(line->v1); - double backceilz2 = backsector->ceilingplane.ZatPoint(line->v2); - double backfloorz2 = backsector->floorplane.ZatPoint(line->v2); - - double topceilz1 = frontceilz1; - double topceilz2 = frontceilz2; - double topfloorz1 = MIN(backceilz1, frontceilz1); - double topfloorz2 = MIN(backceilz2, frontceilz2); - double bottomceilz1 = MAX(frontfloorz1, backfloorz1); - double bottomceilz2 = MAX(frontfloorz2, backfloorz2); - double bottomfloorz1 = frontfloorz1; - double bottomfloorz2 = frontfloorz2; - double middleceilz1 = topfloorz1; - double middleceilz2 = topfloorz2; - double middlefloorz1 = MIN(bottomceilz1, middleceilz1); - double middlefloorz2 = MIN(bottomceilz2, middleceilz2); - - bool bothSkyCeiling = frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum; - bool bothSkyFloor = frontsector->GetTexture(sector_t::floor) == skyflatnum && backsector->GetTexture(sector_t::floor) == skyflatnum; - - if ((topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && line->sidedef && !bothSkyCeiling) - { - wall.SetCoords(line->v1->fPos(), line->v2->fPos(), topceilz1, topfloorz1, topceilz2, topfloorz2); - wall.TopZ = topceilz1; - wall.BottomZ = topfloorz1; - wall.UnpeggedCeil = topceilz1; - wall.Texpart = side_t::top; - wall.Render(worldToClip); - } - - if ((bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && line->sidedef && !bothSkyFloor) - { - wall.SetCoords(line->v1->fPos(), line->v2->fPos(), bottomceilz1, bottomfloorz2, bottomceilz2, bottomfloorz2); - wall.TopZ = bottomceilz1; - wall.BottomZ = bottomfloorz2; - wall.UnpeggedCeil = topceilz1; - wall.Texpart = side_t::bottom; - wall.Render(worldToClip); - } - - if (line->sidedef) - { - FTexture *midtex = TexMan(line->sidedef->GetTexture(side_t::mid), true); - if (midtex && midtex->UseType != FTexture::TEX_Null) - { - wall.SetCoords(line->v1->fPos(), line->v2->fPos(), middleceilz1, middlefloorz1, middleceilz2, middlefloorz2); - wall.TopZ = middleceilz1; - wall.BottomZ = middlefloorz1; - wall.UnpeggedCeil = topceilz1; - wall.Texpart = side_t::mid; - wall.Masked = true; - TempTranslucentWalls.push_back({ wall }); - } - } + if (hasSegmentRange) + Cull.MarkSegmentCulled(sx1, sx2); } } -bool RenderPolyBsp::IsThingCulled(AActor *thing) +void RenderPolyScene::RenderTranslucent() { - FIntCVar *cvar = thing->GetClass()->distancecheck; - if (cvar != nullptr && *cvar >= 0) + for (auto it = TranslucentObjects.rbegin(); it != TranslucentObjects.rend(); ++it) { - double dist = (thing->Pos() - ViewPos).LengthSquared(); - double check = (double)**cvar; - if (dist >= check * check) - return true; - } - - // Don't waste time projecting sprites that are definitely not visible. - if (thing == nullptr || - (thing->renderflags & RF_INVISIBLE) || - !thing->RenderStyle.IsVisible(thing->Alpha) || - !thing->IsVisibleToPlayer()) - { - return true; - } - - return false; -} - -void RenderPolyBsp::AddSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) -{ - if (IsThingCulled(thing)) - return; - - DVector3 pos = thing->InterpolatedPosition(r_TicFracF); - pos.Z += thing->GetBobOffset(r_TicFracF); - - bool flipTextureX = false; - FTexture *tex = GetSpriteTexture(thing, flipTextureX); - if (tex == nullptr) - return; - DVector2 spriteScale = thing->Scale; - double thingxscalemul = spriteScale.X / tex->Scale.X; - double thingyscalemul = spriteScale.Y / tex->Scale.Y; - - if (flipTextureX) - pos.X -= (tex->GetWidth() - tex->LeftOffset) * thingxscalemul; - else - pos.X -= tex->LeftOffset * thingxscalemul; - - //pos.Z -= tex->TopOffset * thingyscalemul; - pos.Z -= (tex->GetHeight() - tex->TopOffset) * thingyscalemul + thing->Floorclip; - - double spriteHalfWidth = thingxscalemul * tex->GetWidth() * 0.5; - double spriteHeight = thingyscalemul * tex->GetHeight(); - - pos.X += spriteHalfWidth; - - DVector2 points[2] = - { - { pos.X - ViewSin * spriteHalfWidth, pos.Y + ViewCos * spriteHalfWidth }, - { pos.X + ViewSin * spriteHalfWidth, pos.Y - ViewCos * spriteHalfWidth } - }; - - // Is this sprite inside? (To do: clip the points) - for (int i = 0; i < 2; i++) - { - for (uint32_t i = 0; i < sub->numlines; i++) + auto &obj = *it; + if (!obj.thing) { - seg_t *line = &sub->firstline[i]; - double nx = line->v1->fY() - line->v2->fY(); - double ny = line->v2->fX() - line->v1->fX(); - double d = -(line->v1->fX() * nx + line->v1->fY() * ny); - if (pos.X * nx + pos.Y * ny + d > 0.0) - return; + obj.wall.Render(WorldToClip); } - } - - //double depth = 1.0; - //visstyle_t visstyle = GetSpriteVisStyle(thing, depth); - // Rumor has it that AlterWeaponSprite needs to be called with visstyle passed in somewhere around here.. - //R_SetColorMapLight(visstyle.BaseColormap, 0, visstyle.ColormapNum << FRACBITS); - - TriVertex *vertices = PolyVertexBuffer::GetVertices(4); - if (!vertices) - return; - - bool foggy = false; - int actualextralight = foggy ? 0 : extralight << 4; - - std::pair offsets[4] = - { - { 0.0f, 1.0f }, - { 1.0f, 1.0f }, - { 1.0f, 0.0f }, - { 0.0f, 0.0f }, - }; - - for (int i = 0; i < 4; i++) - { - auto &p = (i == 0 || i == 3) ? points[0] : points[1]; - - vertices[i].x = (float)p.X; - vertices[i].y = (float)p.Y; - vertices[i].z = (float)(pos.Z + spriteHeight * offsets[i].second); - vertices[i].w = 1.0f; - vertices[i].varying[0] = (float)(offsets[i].first * tex->Scale.X); - vertices[i].varying[1] = (float)((1.0f - offsets[i].second) * tex->Scale.Y); - if (flipTextureX) - vertices[i].varying[0] = 1.0f - vertices[i].varying[0]; - } - - TriUniforms uniforms; - uniforms.objectToClip = worldToClip; - uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f); - uniforms.flags = 0; - uniforms.subsectorDepth = subsectorDepth; - - PolyDrawArgs args; - args.uniforms = uniforms; - args.vinput = vertices; - args.vcount = 4; - args.mode = TriangleDrawMode::Fan; - args.ccw = true; - args.clipleft = 0; - args.cliptop = 0; - args.clipright = viewwidth; - args.clipbottom = viewheight; - args.stenciltestvalue = 0; - args.stencilwritevalue = 1; - args.SetTexture(tex); - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector); -} - -void RenderPolyBsp::AddWallSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) -{ - if (IsThingCulled(thing)) - return; -} - -visstyle_t RenderPolyBsp::GetSpriteVisStyle(AActor *thing, double z) -{ - visstyle_t visstyle; - - bool foggy = false; - int actualextralight = foggy ? 0 : extralight << 4; - int spriteshade = LIGHT2SHADE(thing->Sector->lightlevel + actualextralight); - - visstyle.RenderStyle = thing->RenderStyle; - visstyle.Alpha = float(thing->Alpha); - visstyle.ColormapNum = 0; - - // The software renderer cannot invert the source without inverting the overlay - // too. That means if the source is inverted, we need to do the reverse of what - // the invert overlay flag says to do. - bool invertcolormap = (visstyle.RenderStyle.Flags & STYLEF_InvertOverlay) != 0; - - if (visstyle.RenderStyle.Flags & STYLEF_InvertSource) - { - invertcolormap = !invertcolormap; - } - - FDynamicColormap *mybasecolormap = thing->Sector->ColorMap; - - // Sprites that are added to the scene must fade to black. - if (visstyle.RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0) - { - mybasecolormap = GetSpecialLights(mybasecolormap->Color, 0, mybasecolormap->Desaturate); - } - - if (visstyle.RenderStyle.Flags & STYLEF_FadeToBlack) - { - if (invertcolormap) - { // Fade to white - mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(255, 255, 255), mybasecolormap->Desaturate); - invertcolormap = false; - } - else - { // Fade to black - mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(0, 0, 0), mybasecolormap->Desaturate); - } - } - - // get light level - if (fixedcolormap != nullptr) - { // fixed map - visstyle.BaseColormap = fixedcolormap; - visstyle.ColormapNum = 0; - } - else - { - if (invertcolormap) + else if ((obj.thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) { - mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate); - } - if (fixedlightlev >= 0) - { - visstyle.BaseColormap = mybasecolormap; - visstyle.ColormapNum = fixedlightlev >> COLORMAPSHIFT; - } - else if (!foggy && ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) - { // full bright - visstyle.BaseColormap = mybasecolormap; - visstyle.ColormapNum = 0; - } - else - { // diminished light - double minz = double((2048 * 4) / double(1 << 20)); - visstyle.ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(z, minz), spriteshade); - visstyle.BaseColormap = mybasecolormap; - } - } - - return visstyle; -} - -FTexture *RenderPolyBsp::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX) -{ - flipX = false; - if (thing->picnum.isValid()) - { - FTexture *tex = TexMan(thing->picnum); - if (tex->UseType == FTexture::TEX_Null) - { - return nullptr; - } - - if (tex->Rotations != 0xFFFF) - { - // choose a different rotation based on player view - spriteframe_t *sprframe = &SpriteFrames[tex->Rotations]; - DVector3 pos = thing->InterpolatedPosition(r_TicFracF); - pos.Z += thing->GetBobOffset(r_TicFracF); - DAngle ang = (pos - ViewPos).Angle(); - angle_t rot; - if (sprframe->Texture[0] == sprframe->Texture[1]) - { - rot = (ang - thing->Angles.Yaw + 45.0 / 2 * 9).BAMs() >> 28; - } - else - { - rot = (ang - thing->Angles.Yaw + (45.0 / 2 * 9 - 180.0 / 16)).BAMs() >> 28; - } - flipX = (sprframe->Flip & (1 << rot)) != 0; - tex = TexMan[sprframe->Texture[rot]]; // Do not animate the rotation - } - return tex; - } - else - { - // decide which texture to use for the sprite - int spritenum = thing->sprite; - if (spritenum >= (signed)sprites.Size() || spritenum < 0) - return nullptr; - - spritedef_t *sprdef = &sprites[spritenum]; - if (thing->frame >= sprdef->numframes) - { - // If there are no frames at all for this sprite, don't draw it. - return nullptr; + RenderPolyWallSprite wallspr; + wallspr.Render(obj.thing, obj.sub, obj.subsectorDepth); } else { - //picnum = SpriteFrames[sprdef->spriteframes + thing->frame].Texture[0]; - // choose a different rotation based on player view - spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + thing->frame]; - DVector3 pos = thing->InterpolatedPosition(r_TicFracF); - pos.Z += thing->GetBobOffset(r_TicFracF); - DAngle ang = (pos - ViewPos).Angle(); - angle_t rot; - if (sprframe->Texture[0] == sprframe->Texture[1]) - { - rot = (ang - thing->Angles.Yaw + 45.0 / 2 * 9).BAMs() >> 28; - } - else - { - rot = (ang - thing->Angles.Yaw + (45.0 / 2 * 9 - 180.0 / 16)).BAMs() >> 28; - } - flipX = (sprframe->Flip & (1 << rot)) != 0; - return TexMan[sprframe->Texture[rot]]; // Do not animate the rotation + RenderPolySprite spr; + spr.Render(WorldToClip, obj.thing, obj.sub, obj.subsectorDepth); } } } -void RenderPolyBsp::RenderNode(void *node) +RenderPolyScene *RenderPolyScene::Instance() { - while (!((size_t)node & 1)) // Keep going until found a subsector - { - node_t *bsp = (node_t *)node; - - // Decide which side the view point is on. - int side = PointOnSide(ViewPos, bsp); - - // Recursively divide front space (toward the viewer). - RenderNode(bsp->children[side]); - - // Possibly divide back space (away from the viewer). - side ^= 1; - if (!CheckBBox(bsp->bbox[side])) - return; - - node = bsp->children[side]; - } - - // Mark that we need to render this - subsector_t *sub = (subsector_t *)((BYTE *)node - 1); - MaxCeilingHeight = MAX(MaxCeilingHeight, sub->sector->ceilingplane.Zat0()); - MinFloorHeight = MIN(MinFloorHeight, sub->sector->floorplane.Zat0()); - PvsSectors.push_back(sub); - - // Update culling info for further bsp clipping - for (uint32_t i = 0; i < sub->numlines; i++) - { - seg_t *line = &sub->firstline[i]; - if ((line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) && line->backsector == nullptr) - { - int sx1, sx2; - if (GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2)) - { - MarkSegmentCulled(sx1, sx2); - } - } - } -} - -void RenderPolyBsp::RenderPlayerSprites() -{ - if (!r_drawplayersprites || - !camera || - !camera->player || - (players[consoleplayer].cheats & CF_CHASECAM) || - (r_deathcamera && camera->health <= 0)) - return; - - float bobx, boby; - P_BobWeapon(camera->player, &bobx, &boby, r_TicFracF); - - // Interpolate the main weapon layer once so as to be able to add it to other layers. - double wx, wy; - DPSprite *weapon = camera->player->FindPSprite(PSP_WEAPON); - if (weapon) - { - if (weapon->firstTic) - { - wx = weapon->x; - wy = weapon->y; - } - else - { - wx = weapon->oldx + (weapon->x - weapon->oldx) * r_TicFracF; - wy = weapon->oldy + (weapon->y - weapon->oldy) * r_TicFracF; - } - } - else - { - wx = 0; - wy = 0; - } - - for (DPSprite *sprite = camera->player->psprites; sprite != nullptr; sprite = sprite->GetNext()) - { - // [RH] Don't draw the targeter's crosshair if the player already has a crosshair set. - // It's possible this psprite's caller is now null but the layer itself hasn't been destroyed - // because it didn't tick yet (if we typed 'take all' while in the console for example). - // In this case let's simply not draw it to avoid crashing. - if ((sprite->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr) && sprite->GetCaller() != nullptr) - { - RenderPlayerSprite(sprite, camera, bobx, boby, wx, wy, r_TicFracF); - } - } -} - -void RenderPolyBsp::RenderPlayerSprite(DPSprite *sprite, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac) -{ - // decide which patch to use - if ((unsigned)sprite->GetSprite() >= (unsigned)sprites.Size()) - { - DPrintf(DMSG_ERROR, "RenderPlayerSprite: invalid sprite number %i\n", sprite->GetSprite()); - return; - } - - spritedef_t *def = &sprites[sprite->GetSprite()]; - if (sprite->GetFrame() >= def->numframes) - { - DPrintf(DMSG_ERROR, "RenderPlayerSprite: invalid sprite frame %i : %i\n", sprite->GetSprite(), sprite->GetFrame()); - return; - } - - spriteframe_t *frame = &SpriteFrames[def->spriteframes + sprite->GetFrame()]; - FTextureID picnum = frame->Texture[0]; - bool flip = (frame->Flip & 1) != 0; - - FTexture *tex = TexMan(picnum); - if (tex->UseType == FTexture::TEX_Null) - return; - - // Can't interpolate the first tic. - if (sprite->firstTic) - { - sprite->firstTic = false; - sprite->oldx = sprite->x; - sprite->oldy = sprite->y; - } - - double sx = sprite->oldx + (sprite->x - sprite->oldx) * ticfrac; - double sy = sprite->oldy + (sprite->y - sprite->oldy) * ticfrac; - - if (sprite->Flags & PSPF_ADDBOB) - { - sx += bobx; - sy += boby; - } - - if (sprite->Flags & PSPF_ADDWEAPON && sprite->GetID() != PSP_WEAPON) - { - sx += wx; - sy += wy; - } - - // calculate edges of the shape - double tx = sx - BaseXCenter; - - tx -= tex->GetScaledLeftOffset(); - int x1 = xs_RoundToInt(CenterX + tx * pspritexscale); - - // off the right side - if (x1 > viewwidth) - return; - - tx += tex->GetScaledWidth(); - int x2 = xs_RoundToInt(CenterX + tx * pspritexscale); - - // off the left side - if (x2 <= 0) - return; - - double texturemid = (BaseYCenter - sy) * tex->Scale.Y + tex->TopOffset; - - // Adjust PSprite for fullscreen views - if (camera->player && (RenderTarget != screen || viewheight == RenderTarget->GetHeight() || (RenderTarget->GetWidth() > (BaseXCenter * 2) && !st_scale))) - { - AWeapon *weapon = dyn_cast(sprite->GetCaller()); - if (weapon != nullptr && weapon->YAdjust != 0) - { - if (RenderTarget != screen || viewheight == RenderTarget->GetHeight()) - { - texturemid -= weapon->YAdjust; - } - else - { - texturemid -= StatusBar->GetDisplacement() * weapon->YAdjust; - } - } - } - - // Move the weapon down for 1280x1024. - if (sprite->GetID() < PSP_TARGETCENTER) - { - texturemid -= AspectPspriteOffset(WidescreenRatio); - } - - int clipped_x1 = MAX(x1, 0); - int clipped_x2 = MIN(x2, viewwidth); - double xscale = pspritexscale / tex->Scale.X; - double yscale = pspriteyscale / tex->Scale.Y; - uint32_t translation = 0; // [RH] Use default colors - - double xiscale, startfrac; - if (flip) - { - xiscale = -pspritexiscale * tex->Scale.X; - startfrac = 1; - } - else - { - xiscale = pspritexiscale * tex->Scale.X; - startfrac = 0; - } - - if (clipped_x1 > x1) - startfrac += xiscale * (clipped_x1 - x1); - - bool noaccel = false; - - FDynamicColormap *basecolormap = viewsector->ColorMap; - FDynamicColormap *colormap_to_use = basecolormap; - - visstyle_t visstyle; - visstyle.ColormapNum = 0; - visstyle.BaseColormap = basecolormap; - visstyle.Alpha = 0; - visstyle.RenderStyle = STYLE_Normal; - - bool foggy = false; - int actualextralight = foggy ? 0 : extralight << 4; - int spriteshade = LIGHT2SHADE(owner->Sector->lightlevel + actualextralight); - double minz = double((2048 * 4) / double(1 << 20)); - visstyle.ColormapNum = GETPALOOKUP(r_SpriteVisibility / minz, spriteshade); - - if (sprite->GetID() < PSP_TARGETCENTER) - { - // Lots of complicated style and noaccel stuff - } - - // Check for hardware-assisted 2D. If it's available, and this sprite is not - // fuzzy, don't draw it until after the switch to 2D mode. - if (!noaccel && RenderTarget == screen && (DFrameBuffer *)screen->Accel2D) - { - FRenderStyle style = visstyle.RenderStyle; - style.CheckFuzz(); - if (style.BlendOp != STYLEOP_Fuzz) - { - PolyScreenSprite screenSprite; - screenSprite.Pic = tex; - screenSprite.X1 = viewwindowx + x1; - screenSprite.Y1 = viewwindowy + viewheight / 2 - texturemid * yscale - 0.5; - screenSprite.Width = tex->GetWidth() * xscale; - screenSprite.Height = tex->GetHeight() * yscale; - screenSprite.Translation = TranslationToTable(translation); - screenSprite.Flip = xiscale < 0; - screenSprite.visstyle = visstyle; - screenSprite.Colormap = colormap_to_use; - ScreenSprites.push_back(screenSprite); - return; - } - } - - //R_DrawVisSprite(vis); -} - -void RenderPolyBsp::ClearSolidSegments() -{ - SolidSegments.clear(); - SolidSegments.reserve(SolidCullScale + 2); - SolidSegments.push_back({ -0x7fff, -SolidCullScale }); - SolidSegments.push_back({ SolidCullScale , 0x7fff }); -} - -bool RenderPolyBsp::IsSegmentCulled(int x1, int x2) const -{ - int next = 0; - while (SolidSegments[next].X2 <= x2) - next++; - return (x1 >= SolidSegments[next].X1 && x2 <= SolidSegments[next].X2); -} - -void RenderPolyBsp::MarkSegmentCulled(int x1, int x2) -{ - if (x1 >= x2) - return; - - int cur = 1; - while (true) - { - if (SolidSegments[cur].X1 <= x1 && SolidSegments[cur].X2 >= x2) // Already fully marked - { - break; - } - else if (cur + 1 != SolidSegments.size() && SolidSegments[cur].X2 >= x1 && SolidSegments[cur].X1 <= x2) // Merge segments - { - // Find last segment - int merge = cur; - while (merge + 2 != SolidSegments.size() && SolidSegments[merge + 1].X1 <= x2) - merge++; - - // Apply new merged range - SolidSegments[cur].X1 = MIN(SolidSegments[cur].X1, x1); - SolidSegments[cur].X2 = MAX(SolidSegments[merge].X2, x2); - - // Remove additional segments we merged with - if (merge > cur) - SolidSegments.erase(SolidSegments.begin() + (cur + 1), SolidSegments.begin() + (merge + 1)); - - break; - } - else if (SolidSegments[cur].X1 > x1) // Insert new segment - { - SolidSegments.insert(SolidSegments.begin() + cur, { x1, x2 }); - break; - } - cur++; - } -} - -int RenderPolyBsp::PointOnSide(const DVector2 &pos, const node_t *node) -{ - return DMulScale32(FLOAT2FIXED(pos.Y) - node->y, node->dx, node->x - FLOAT2FIXED(pos.X), node->dy) > 0; -} - -bool RenderPolyBsp::CheckBBox(float *bspcoord) -{ - // Start using a quick frustum AABB test: - - AxisAlignedBoundingBox aabb(Vec3f(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM], (float)ViewPos.Z - 1000.0f), Vec3f(bspcoord[BOXRIGHT], bspcoord[BOXTOP], (float)ViewPos.Z + 1000.0f)); - auto result = IntersectionTest::frustum_aabb(frustumPlanes, aabb); - if (result == IntersectionTest::outside) - return false; - - // Occlusion test using solid segments: - - int boxx; - int boxy; - int boxpos; - - double x1, y1, x2, y2; - - // Find the corners of the box - // that define the edges from current viewpoint. - if (ViewPos.X <= bspcoord[BOXLEFT]) - boxx = 0; - else if (ViewPos.X < bspcoord[BOXRIGHT]) - boxx = 1; - else - boxx = 2; - - if (ViewPos.Y >= bspcoord[BOXTOP]) - boxy = 0; - else if (ViewPos.Y > bspcoord[BOXBOTTOM]) - boxy = 1; - else - boxy = 2; - - boxpos = (boxy << 2) + boxx; - if (boxpos == 5) - return true; - - static const int checkcoord[12][4] = - { - { 3,0,2,1 }, - { 3,0,2,0 }, - { 3,1,2,0 }, - { 0 }, - { 2,0,2,1 }, - { 0,0,0,0 }, - { 3,1,3,0 }, - { 0 }, - { 2,0,3,1 }, - { 2,1,3,1 }, - { 2,1,3,0 } - }; - - x1 = bspcoord[checkcoord[boxpos][0]]; - y1 = bspcoord[checkcoord[boxpos][1]]; - x2 = bspcoord[checkcoord[boxpos][2]]; - y2 = bspcoord[checkcoord[boxpos][3]]; - - int sx1, sx2; - if (GetSegmentRangeForLine(x1, y1, x2, y2, sx1, sx2)) - return !IsSegmentCulled(sx1, sx2); - else - return true; -} - -bool RenderPolyBsp::GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const -{ - double znear = 5.0; - - // Transform to 2D view space: - x1 = x1 - ViewPos.X; - y1 = y1 - ViewPos.Y; - x2 = x2 - ViewPos.X; - y2 = y2 - ViewPos.Y; - double rx1 = x1 * ViewSin - y1 * ViewCos; - double rx2 = x2 * ViewSin - y2 * ViewCos; - double ry1 = x1 * ViewCos + y1 * ViewSin; - double ry2 = x2 * ViewCos + y2 * ViewSin; - - // Cull if line is entirely behind view - if (ry1 < znear && ry2 < znear) return false; - - // Clip line, if needed - double t1 = 0.0f, t2 = 1.0f; - if (ry1 < znear) - t1 = clamp((znear - ry1) / (ry2 - ry1), 0.0, 1.0); - if (ry2 < znear) - t2 = clamp((znear - ry1) / (ry2 - ry1), 0.0, 1.0); - if (t1 != 0.0 || t2 != 1.0) - { - double nx1 = rx1 * (1.0 - t1) + rx2 * t1; - double ny1 = ry1 * (1.0 - t1) + ry2 * t1; - double nx2 = rx1 * (1.0 - t2) + rx2 * t2; - double ny2 = ry1 * (1.0 - t2) + ry2 * t2; - rx1 = nx1; - rx2 = nx2; - ry1 = ny1; - ry2 = ny2; - } - - sx1 = (int)floor(clamp(rx1 / ry1 * (SolidCullScale / 3), (double)-SolidCullScale, (double)SolidCullScale)); - sx2 = (int)floor(clamp(rx2 / ry2 * (SolidCullScale / 3), (double)-SolidCullScale, (double)SolidCullScale)); - - if (sx1 > sx2) - std::swap(sx1, sx2); - return sx1 != sx2; -} - -///////////////////////////////////////////////////////////////////////////// - -void RenderPolyWall::Render(const TriMatrix &worldToClip) -{ - FTexture *tex = GetTexture(); - if (!tex) - return; - - PolyWallTextureCoords texcoords(tex, Line, Texpart, TopZ, BottomZ, UnpeggedCeil); - - TriVertex *vertices = PolyVertexBuffer::GetVertices(4); - if (!vertices) - return; - - vertices[0].x = (float)v1.X; - vertices[0].y = (float)v1.Y; - vertices[0].z = (float)ceil1; - vertices[0].w = 1.0f; - vertices[0].varying[0] = (float)texcoords.u1; - vertices[0].varying[1] = (float)texcoords.v1; - - vertices[1].x = (float)v2.X; - vertices[1].y = (float)v2.Y; - vertices[1].z = (float)ceil2; - vertices[1].w = 1.0f; - vertices[1].varying[0] = (float)texcoords.u2; - vertices[1].varying[1] = (float)texcoords.v1; - - vertices[2].x = (float)v2.X; - vertices[2].y = (float)v2.Y; - vertices[2].z = (float)floor2; - vertices[2].w = 1.0f; - vertices[2].varying[0] = (float)texcoords.u2; - vertices[2].varying[1] = (float)texcoords.v2; - - vertices[3].x = (float)v1.X; - vertices[3].y = (float)v1.Y; - vertices[3].z = (float)floor1; - vertices[3].w = 1.0f; - vertices[3].varying[0] = (float)texcoords.u1; - vertices[3].varying[1] = (float)texcoords.v2; - - TriUniforms uniforms; - uniforms.objectToClip = worldToClip; - uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f); - uniforms.flags = 0; - uniforms.subsectorDepth = SubsectorDepth; - - PolyDrawArgs args; - args.uniforms = uniforms; - args.vinput = vertices; - args.vcount = 4; - args.mode = TriangleDrawMode::Fan; - args.ccw = true; - args.clipleft = 0; - args.cliptop = 0; - args.clipright = viewwidth; - args.clipbottom = viewheight; - args.stenciltestvalue = 0; - args.stencilwritevalue = 1; - args.SetTexture(tex); - - if (!Masked) - { - PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); - } - else - { - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector); - } -} - -FTexture *RenderPolyWall::GetTexture() -{ - FTexture *tex = TexMan(Line->sidedef->GetTexture(Texpart), true); - if (tex == nullptr || tex->UseType == FTexture::TEX_Null) - return nullptr; - else - return tex; -} - -int RenderPolyWall::GetLightLevel() -{ - if (fixedlightlev >= 0 || fixedcolormap) - { - return 255; - } - else - { - bool foggy = false; - int actualextralight = foggy ? 0 : extralight << 4; - return Line->sidedef->GetLightLevel(foggy, Line->frontsector->lightlevel) + actualextralight; - } -} - -/* -float RenderPolyWall::GetLight(short x) -{ - if (fixedlightlev >= 0 || fixedcolormap) - return 0.0f; - else - return (float)(r_WallVisibility / Coords.Z(x)); -} -*/ - -///////////////////////////////////////////////////////////////////////////// - -PolyWallTextureCoords::PolyWallTextureCoords(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil) -{ - CalcU(tex, line, texpart); - CalcV(tex, line, texpart, topz, bottomz, unpeggedceil); -} - -void PolyWallTextureCoords::CalcU(FTexture *tex, const seg_t *line, side_t::ETexpart texpart) -{ - double lineLength = line->sidedef->TexelLength; - double lineStart = 0.0; - - bool entireSegment = ((line->linedef->v1 == line->v1) && (line->linedef->v2 == line->v2) || (line->linedef->v2 == line->v1) && (line->linedef->v1 == line->v2)); - if (!entireSegment) - { - lineLength = (line->v2->fPos() - line->v1->fPos()).Length(); - lineStart = (line->v1->fPos() - line->linedef->v1->fPos()).Length(); - } - - int texWidth = tex->GetWidth(); - double uscale = line->sidedef->GetTextureXScale(texpart) * tex->Scale.X; - u1 = lineStart + line->sidedef->GetTextureXOffset(texpart); - u2 = u1 + lineLength; - u1 *= uscale; - u2 *= uscale; - u1 /= texWidth; - u2 /= texWidth; -} - -void PolyWallTextureCoords::CalcV(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil) -{ - double vscale = line->sidedef->GetTextureYScale(texpart) * tex->Scale.Y; - - double yoffset = line->sidedef->GetTextureYOffset(texpart); - if (tex->bWorldPanning) - yoffset *= vscale; - - switch (texpart) - { - default: - case side_t::mid: - CalcVMidPart(tex, line, topz, bottomz, vscale, yoffset); - break; - case side_t::top: - CalcVTopPart(tex, line, topz, bottomz, vscale, yoffset); - break; - case side_t::bottom: - CalcVBottomPart(tex, line, topz, bottomz, unpeggedceil, vscale, yoffset); - break; - } - - int texHeight = tex->GetHeight(); - v1 /= texHeight; - v2 /= texHeight; -} - -void PolyWallTextureCoords::CalcVTopPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset) -{ - bool pegged = (line->linedef->flags & ML_DONTPEGTOP) == 0; - if (pegged) // bottom to top - { - int texHeight = tex->GetHeight(); - v1 = -yoffset; - v2 = v1 + (topz - bottomz); - v1 *= vscale; - v2 *= vscale; - v1 = texHeight - v1; - v2 = texHeight - v2; - std::swap(v1, v2); - } - else // top to bottom - { - v1 = yoffset; - v2 = v1 + (topz - bottomz); - v1 *= vscale; - v2 *= vscale; - } -} - -void PolyWallTextureCoords::CalcVMidPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset) -{ - bool pegged = (line->linedef->flags & ML_DONTPEGBOTTOM) == 0; - if (pegged) // top to bottom - { - v1 = yoffset; - v2 = v1 + (topz - bottomz); - v1 *= vscale; - v2 *= vscale; - } - else // bottom to top - { - int texHeight = tex->GetHeight(); - v1 = yoffset; - v2 = v1 + (topz - bottomz); - v1 *= vscale; - v2 *= vscale; - v1 = texHeight - v1; - v2 = texHeight - v2; - std::swap(v1, v2); - } -} - -void PolyWallTextureCoords::CalcVBottomPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double unpeggedceil, double vscale, double yoffset) -{ - bool pegged = (line->linedef->flags & ML_DONTPEGBOTTOM) == 0; - if (pegged) // top to bottom - { - v1 = yoffset; - v2 = v1 + (topz - bottomz); - v1 *= vscale; - v2 *= vscale; - } - else - { - v1 = yoffset + (unpeggedceil - topz); - v2 = v1 + (topz - bottomz); - v1 *= vscale; - v2 *= vscale; - } -} - -///////////////////////////////////////////////////////////////////////////// - -void PolyScreenSprite::Render() -{ - FSpecialColormap *special = nullptr; - FColormapStyle colormapstyle; - PalEntry overlay = 0; - bool usecolormapstyle = false; - if (visstyle.BaseColormap >= &SpecialColormaps[0] && - visstyle.BaseColormap < &SpecialColormaps[SpecialColormaps.Size()]) - { - special = static_cast(visstyle.BaseColormap); - } - else if (Colormap->Color == PalEntry(255, 255, 255) && - Colormap->Desaturate == 0) - { - overlay = Colormap->Fade; - overlay.a = BYTE(visstyle.ColormapNum * 255 / NUMCOLORMAPS); - } - else - { - usecolormapstyle = true; - colormapstyle.Color = Colormap->Color; - colormapstyle.Fade = Colormap->Fade; - colormapstyle.Desaturate = Colormap->Desaturate; - colormapstyle.FadeLevel = visstyle.ColormapNum / float(NUMCOLORMAPS); - } - - screen->DrawTexture(Pic, - X1, - Y1, - DTA_DestWidthF, Width, - DTA_DestHeightF, Height, - DTA_Translation, Translation, - DTA_FlipX, Flip, - DTA_TopOffset, 0, - DTA_LeftOffset, 0, - DTA_ClipLeft, viewwindowx, - DTA_ClipTop, viewwindowy, - DTA_ClipRight, viewwindowx + viewwidth, - DTA_ClipBottom, viewwindowy + viewheight, - DTA_AlphaF, visstyle.Alpha, - DTA_RenderStyle, visstyle.RenderStyle, - DTA_FillColor, FillColor, - DTA_SpecialColormap, special, - DTA_ColorOverlay, overlay.d, - DTA_ColormapStyle, usecolormapstyle ? &colormapstyle : nullptr, - TAG_DONE); + static RenderPolyScene scene; + return &scene; } ///////////////////////////////////////////////////////////////////////////// @@ -1450,164 +209,3 @@ void PolyVertexBuffer::Clear() { NextBufferVertex = 0; } - -///////////////////////////////////////////////////////////////////////////// - -TriVertex PolySkyDome::SetVertex(float xx, float yy, float zz, float uu, float vv) -{ - TriVertex v; - v.x = xx; - v.y = yy; - v.z = zz; - v.w = 1.0f; - v.varying[0] = uu; - v.varying[1] = vv; - return v; -} - -TriVertex PolySkyDome::SetVertexXYZ(float xx, float yy, float zz, float uu, float vv) -{ - TriVertex v; - v.x = xx; - v.y = zz; - v.z = yy; - v.w = 1.0f; - v.varying[0] = uu; - v.varying[1] = vv; - return v; -} - -void PolySkyDome::SkyVertex(int r, int c, bool zflip) -{ - static const FAngle maxSideAngle = 60.f; - static const float scale = 10000.; - - FAngle topAngle = (c / (float)mColumns * 360.f); - FAngle sideAngle = maxSideAngle * (float)(mRows - r) / (float)mRows; - float height = sideAngle.Sin(); - float realRadius = scale * sideAngle.Cos(); - FVector2 pos = topAngle.ToVector(realRadius); - float z = (!zflip) ? scale * height : -scale * height; - - float u, v; - //uint32_t color = r == 0 ? 0xffffff : 0xffffffff; - - // And the texture coordinates. - if (!zflip) // Flipped Y is for the lower hemisphere. - { - u = (-c / (float)mColumns); - v = (r / (float)mRows); - } - else - { - u = (-c / (float)mColumns); - v = 1.0f + ((mRows - r) / (float)mRows); - } - - if (r != 4) z += 300; - - // And finally the vertex. - TriVertex vert; - vert = SetVertexXYZ(-pos.X, z - 1.f, pos.Y, u * 4.0f, v * 1.2f + 0.5f/*, color*/); - mVertices.Push(vert); -} - -void PolySkyDome::CreateSkyHemisphere(bool zflip) -{ - int r, c; - - mPrimStart.Push(mVertices.Size()); - - for (c = 0; c < mColumns; c++) - { - SkyVertex(1, c, zflip); - } - - // The total number of triangles per hemisphere can be calculated - // as follows: rows * columns * 2 + 2 (for the top cap). - for (r = 0; r < mRows; r++) - { - mPrimStart.Push(mVertices.Size()); - for (c = 0; c <= mColumns; c++) - { - SkyVertex(r + zflip, c, zflip); - SkyVertex(r + 1 - zflip, c, zflip); - } - } -} - -void PolySkyDome::CreateDome() -{ - mColumns = 128; - mRows = 4; - CreateSkyHemisphere(false); - CreateSkyHemisphere(true); - mPrimStart.Push(mVertices.Size()); -} - -void PolySkyDome::RenderRow(PolyDrawArgs &args, int row) -{ - args.vinput = &mVertices[mPrimStart[row]]; - args.vcount = mPrimStart[row + 1] - mPrimStart[row]; - args.mode = TriangleDrawMode::Strip; - args.ccw = false; - PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); -} - -void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap) -{ - uint32_t solid = skytex->GetSkyCapColor(bottomCap); - if (!r_swtruecolor) - solid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)]; - - args.vinput = &mVertices[mPrimStart[row]]; - args.vcount = mPrimStart[row + 1] - mPrimStart[row]; - args.mode = TriangleDrawMode::Fan; - args.ccw = bottomCap; - args.solidcolor = solid; - PolyTriangleDrawer::draw(args, TriDrawVariant::Fill); -} - -void PolySkyDome::Render(const TriMatrix &worldToClip) -{ - FTextureID sky1tex, sky2tex; - if ((level.flags & LEVEL_SWAPSKIES) && !(level.flags & LEVEL_DOUBLESKY)) - sky1tex = sky2texture; - else - sky1tex = sky1texture; - sky2tex = sky2texture; - - FTexture *frontskytex = TexMan(sky1tex, true); - FTexture *backskytex = nullptr; - if (level.flags & LEVEL_DOUBLESKY) - backskytex = TexMan(sky2tex, true); - - TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); - - TriUniforms uniforms; - uniforms.objectToClip = worldToClip * objectToWorld; - uniforms.light = 256; - uniforms.flags = 0; - uniforms.subsectorDepth = RenderPolyBsp::SkySubsectorDepth; - - int rc = mRows + 1; - - PolyDrawArgs args; - args.uniforms = uniforms; - args.clipleft = 0; - args.cliptop = 0; - args.clipright = viewwidth; - args.clipbottom = viewheight; - args.stenciltestvalue = 255; - args.stencilwritevalue = 1; - args.SetTexture(frontskytex); - - RenderCapColorRow(args, frontskytex, 0, false); - RenderCapColorRow(args, frontskytex, rc, true); - - for (int i = 1; i <= mRows; i++) - { - RenderRow(args, i); - RenderRow(args, rc + i); - } -} diff --git a/src/r_poly.h b/src/r_poly.h index 6c5051904..b182a582d 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -1,5 +1,5 @@ /* -** Experimental Doom software renderer +** Polygon Doom software renderer ** Copyright (c) 2016 Magnus Norddahl ** ** This software is provided 'as-is', without any express or implied @@ -31,60 +31,13 @@ #include "r_main.h" #include "r_poly_triangle.h" #include "r_poly_intersection.h" - -// DScreen accelerated sprite to be rendered -class PolyScreenSprite -{ -public: - void Render(); - - FTexture *Pic = nullptr; - double X1 = 0.0; - double Y1 = 0.0; - double Width = 0.0; - double Height = 0.0; - FRemapTable *Translation = nullptr; - bool Flip = false; - visstyle_t visstyle; - uint32_t FillColor = 0; - FDynamicColormap *Colormap = nullptr; -}; - -class RenderPolyWall -{ -public: - void Render(const TriMatrix &worldToClip); - - void SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2) - { - this->v1 = v1; - this->v2 = v2; - this->ceil1 = ceil1; - this->floor1 = floor1; - this->ceil2 = ceil2; - this->floor2 = floor2; - } - - DVector2 v1; - DVector2 v2; - double ceil1 = 0.0; - double floor1 = 0.0; - double ceil2 = 0.0; - double floor2 = 0.0; - - const seg_t *Line = nullptr; - side_t::ETexpart Texpart = side_t::mid; - double TopZ = 0.0; - double BottomZ = 0.0; - double UnpeggedCeil = 0.0; - FSWColormap *Colormap = nullptr; - bool Masked = false; - uint32_t SubsectorDepth = 0; - -private: - FTexture *GetTexture(); - int GetLightLevel(); -}; +#include "r_poly_wall.h" +#include "r_poly_sprite.h" +#include "r_poly_wallsprite.h" +#include "r_poly_playersprite.h" +#include "r_poly_plane.h" +#include "r_poly_sky.h" +#include "r_poly_cull.h" // Used for sorting things by distance to the camera class PolySortedSprite @@ -119,110 +72,34 @@ public: int Count = 0; }; -class PolySkyDome -{ -public: - PolySkyDome() { CreateDome(); } - void Render(const TriMatrix &worldToClip); - -private: - TArray mVertices; - TArray mPrimStart; - int mRows, mColumns; - - void SkyVertex(int r, int c, bool yflip); - void CreateSkyHemisphere(bool zflip); - void CreateDome(); - void RenderRow(PolyDrawArgs &args, int row); - void RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap); - - TriVertex SetVertex(float xx, float yy, float zz, float uu = 0, float vv = 0); - TriVertex SetVertexXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0); -}; - -// Renders a GL BSP tree in a scene -class RenderPolyBsp +// Renders a scene +class RenderPolyScene { public: void Render(); - void RenderScreenSprites(); + void RenderRemainingPlayerSprites(); static const uint32_t SkySubsectorDepth = 0x7fffffff; + static RenderPolyScene *Instance(); + private: - void RenderNode(void *node); void RenderSubsector(subsector_t *sub); - void RenderPlane(subsector_t *sub, uint32_t subsectorDepth, bool ceiling); - void AddLine(seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); - TriVertex PlaneVertex(vertex_t *v1, sector_t *sector, double height); + void RenderLine(seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); void RenderTranslucent(); - void AddSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth); - void AddWallSprite(AActor *thing, subsector_t *sub, uint32_t subsectorDepth); - bool IsThingCulled(AActor *thing); - visstyle_t GetSpriteVisStyle(AActor *thing, double z); - FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); SpriteRange GetSpritesForSector(sector_t *sector); - void RenderPlayerSprites(); - void RenderPlayerSprite(DPSprite *sprite, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac); - - int PointOnSide(const DVector2 &pos, const node_t *node); - - // Checks BSP node/subtree bounding box. - // Returns true if some part of the bbox might be visible. - bool CheckBBox(float *bspcoord); - bool GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const; - void MarkSegmentCulled(int x1, int x2); - bool IsSegmentCulled(int x1, int x2) const; - void ClearSolidSegments(); - - std::vector PvsSectors; + TriMatrix WorldToClip; + PolyCull Cull; uint32_t NextSubsectorDepth = 0; - double MaxCeilingHeight = 0.0; - double MinFloorHeight = 0.0; - - TriMatrix worldToClip; - FrustumPlanes frustumPlanes; - std::vector SectorSpriteRanges; std::vector SortedSprites; std::vector TranslucentObjects; - - std::vector TempTranslucentWalls; - - std::vector ScreenSprites; - - const int BaseXCenter = 160; - const int BaseYCenter = 100; - - struct SolidSegment - { - SolidSegment(int x1, int x2) : X1(x1), X2(x2) { } - int X1, X2; - }; - - std::vector SolidSegments; - const int SolidCullScale = 3000; + std::vector SubsectorTranslucentWalls; PolySkyDome skydome; -}; - -// Texture coordinates for a wall -class PolyWallTextureCoords -{ -public: - PolyWallTextureCoords(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil); - - double u1, u2; - double v1, v2; - -private: - void CalcU(FTexture *tex, const seg_t *line, side_t::ETexpart texpart); - void CalcV(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil); - void CalcVTopPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset); - void CalcVMidPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset); - void CalcVBottomPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double unpeggedceil, double vscale, double yoffset); + RenderPolyPlayerSprites PlayerSprites; }; class PolyVertexBuffer diff --git a/src/r_poly_cull.cpp b/src/r_poly_cull.cpp new file mode 100644 index 000000000..3df07abf9 --- /dev/null +++ b/src/r_poly_cull.cpp @@ -0,0 +1,259 @@ +/* +** Potential visible set (PVS) handling +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "sbar.h" +#include "r_data/r_translate.h" +#include "r_poly_cull.h" +#include "r_poly.h" + +void PolyCull::CullScene(const TriMatrix &worldToClip) +{ + ClearSolidSegments(); + PvsSectors.clear(); + frustumPlanes = FrustumPlanes(worldToClip); + + // Cull front to back + if (numnodes == 0) + { + PvsSectors.push_back(subsectors); + MaxCeilingHeight = subsectors->sector->ceilingplane.Zat0(); + MinFloorHeight = subsectors->sector->floorplane.Zat0(); + } + else + { + MaxCeilingHeight = 0.0; + MinFloorHeight = 0.0; + CullNode(nodes + numnodes - 1); // The head node is the last node output. + } + + ClearSolidSegments(); +} + +void PolyCull::CullNode(void *node) +{ + while (!((size_t)node & 1)) // Keep going until found a subsector + { + node_t *bsp = (node_t *)node; + + // Decide which side the view point is on. + int side = PointOnSide(ViewPos, bsp); + + // Recursively divide front space (toward the viewer). + CullNode(bsp->children[side]); + + // Possibly divide back space (away from the viewer). + side ^= 1; + if (!CheckBBox(bsp->bbox[side])) + return; + + node = bsp->children[side]; + } + + // Mark that we need to render this + subsector_t *sub = (subsector_t *)((BYTE *)node - 1); + MaxCeilingHeight = MAX(MaxCeilingHeight, sub->sector->ceilingplane.Zat0()); + MinFloorHeight = MIN(MinFloorHeight, sub->sector->floorplane.Zat0()); + PvsSectors.push_back(sub); + + // Update culling info for further bsp clipping + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + if ((line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) && line->backsector == nullptr) + { + int sx1, sx2; + if (GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2)) + { + MarkSegmentCulled(sx1, sx2); + } + } + } +} + +void PolyCull::ClearSolidSegments() +{ + SolidSegments.clear(); + SolidSegments.reserve(SolidCullScale + 2); + SolidSegments.push_back({ -0x7fff, -SolidCullScale }); + SolidSegments.push_back({ SolidCullScale , 0x7fff }); +} + +bool PolyCull::IsSegmentCulled(int x1, int x2) const +{ + int next = 0; + while (SolidSegments[next].X2 <= x2) + next++; + return (x1 >= SolidSegments[next].X1 && x2 <= SolidSegments[next].X2); +} + +void PolyCull::MarkSegmentCulled(int x1, int x2) +{ + if (x1 >= x2) + return; + + int cur = 1; + while (true) + { + if (SolidSegments[cur].X1 <= x1 && SolidSegments[cur].X2 >= x2) // Already fully marked + { + break; + } + else if (cur + 1 != SolidSegments.size() && SolidSegments[cur].X2 >= x1 && SolidSegments[cur].X1 <= x2) // Merge segments + { + // Find last segment + int merge = cur; + while (merge + 2 != SolidSegments.size() && SolidSegments[merge + 1].X1 <= x2) + merge++; + + // Apply new merged range + SolidSegments[cur].X1 = MIN(SolidSegments[cur].X1, x1); + SolidSegments[cur].X2 = MAX(SolidSegments[merge].X2, x2); + + // Remove additional segments we merged with + if (merge > cur) + SolidSegments.erase(SolidSegments.begin() + (cur + 1), SolidSegments.begin() + (merge + 1)); + + break; + } + else if (SolidSegments[cur].X1 > x1) // Insert new segment + { + SolidSegments.insert(SolidSegments.begin() + cur, { x1, x2 }); + break; + } + cur++; + } +} + +int PolyCull::PointOnSide(const DVector2 &pos, const node_t *node) +{ + return DMulScale32(FLOAT2FIXED(pos.Y) - node->y, node->dx, node->x - FLOAT2FIXED(pos.X), node->dy) > 0; +} + +bool PolyCull::CheckBBox(float *bspcoord) +{ + // Start using a quick frustum AABB test: + + AxisAlignedBoundingBox aabb(Vec3f(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM], (float)ViewPos.Z - 1000.0f), Vec3f(bspcoord[BOXRIGHT], bspcoord[BOXTOP], (float)ViewPos.Z + 1000.0f)); + auto result = IntersectionTest::frustum_aabb(frustumPlanes, aabb); + if (result == IntersectionTest::outside) + return false; + + // Occlusion test using solid segments: + + int boxx; + int boxy; + int boxpos; + + double x1, y1, x2, y2; + + // Find the corners of the box + // that define the edges from current viewpoint. + if (ViewPos.X <= bspcoord[BOXLEFT]) + boxx = 0; + else if (ViewPos.X < bspcoord[BOXRIGHT]) + boxx = 1; + else + boxx = 2; + + if (ViewPos.Y >= bspcoord[BOXTOP]) + boxy = 0; + else if (ViewPos.Y > bspcoord[BOXBOTTOM]) + boxy = 1; + else + boxy = 2; + + boxpos = (boxy << 2) + boxx; + if (boxpos == 5) + return true; + + static const int checkcoord[12][4] = + { + { 3,0,2,1 }, + { 3,0,2,0 }, + { 3,1,2,0 }, + { 0 }, + { 2,0,2,1 }, + { 0,0,0,0 }, + { 3,1,3,0 }, + { 0 }, + { 2,0,3,1 }, + { 2,1,3,1 }, + { 2,1,3,0 } + }; + + x1 = bspcoord[checkcoord[boxpos][0]]; + y1 = bspcoord[checkcoord[boxpos][1]]; + x2 = bspcoord[checkcoord[boxpos][2]]; + y2 = bspcoord[checkcoord[boxpos][3]]; + + int sx1, sx2; + if (GetSegmentRangeForLine(x1, y1, x2, y2, sx1, sx2)) + return !IsSegmentCulled(sx1, sx2); + else + return true; +} + +bool PolyCull::GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const +{ + double znear = 5.0; + + // Transform to 2D view space: + x1 = x1 - ViewPos.X; + y1 = y1 - ViewPos.Y; + x2 = x2 - ViewPos.X; + y2 = y2 - ViewPos.Y; + double rx1 = x1 * ViewSin - y1 * ViewCos; + double rx2 = x2 * ViewSin - y2 * ViewCos; + double ry1 = x1 * ViewCos + y1 * ViewSin; + double ry2 = x2 * ViewCos + y2 * ViewSin; + + // Cull if line is entirely behind view + if (ry1 < znear && ry2 < znear) return false; + + // Clip line, if needed + double t1 = 0.0f, t2 = 1.0f; + if (ry1 < znear) + t1 = clamp((znear - ry1) / (ry2 - ry1), 0.0, 1.0); + if (ry2 < znear) + t2 = clamp((znear - ry1) / (ry2 - ry1), 0.0, 1.0); + if (t1 != 0.0 || t2 != 1.0) + { + double nx1 = rx1 * (1.0 - t1) + rx2 * t1; + double ny1 = ry1 * (1.0 - t1) + ry2 * t1; + double nx2 = rx1 * (1.0 - t2) + rx2 * t2; + double ny2 = ry1 * (1.0 - t2) + ry2 * t2; + rx1 = nx1; + rx2 = nx2; + ry1 = ny1; + ry2 = ny2; + } + + sx1 = (int)floor(clamp(rx1 / ry1 * (SolidCullScale / 3), (double)-SolidCullScale, (double)SolidCullScale)); + sx2 = (int)floor(clamp(rx2 / ry2 * (SolidCullScale / 3), (double)-SolidCullScale, (double)SolidCullScale)); + + if (sx1 > sx2) + std::swap(sx1, sx2); + return sx1 != sx2; +} diff --git a/src/r_poly_cull.h b/src/r_poly_cull.h new file mode 100644 index 000000000..a79355f68 --- /dev/null +++ b/src/r_poly_cull.h @@ -0,0 +1,61 @@ +/* +** Potential visible set (PVS) handling +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +#include "r_poly_triangle.h" +#include "r_poly_intersection.h" + +class PolyCull +{ +public: + void CullScene(const TriMatrix &worldToClip); + + bool GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const; + void MarkSegmentCulled(int x1, int x2); + bool IsSegmentCulled(int x1, int x2) const; + + std::vector PvsSectors; + double MaxCeilingHeight = 0.0; + double MinFloorHeight = 0.0; + +private: + struct SolidSegment + { + SolidSegment(int x1, int x2) : X1(x1), X2(x2) { } + int X1, X2; + }; + + void CullNode(void *node); + int PointOnSide(const DVector2 &pos, const node_t *node); + + // Checks BSP node/subtree bounding box. + // Returns true if some part of the bbox might be visible. + bool CheckBBox(float *bspcoord); + + void ClearSolidSegments(); + + std::vector SolidSegments; + const int SolidCullScale = 3000; + + FrustumPlanes frustumPlanes; +}; diff --git a/src/r_poly_particle.cpp b/src/r_poly_particle.cpp new file mode 100644 index 000000000..06b963e4f --- /dev/null +++ b/src/r_poly_particle.cpp @@ -0,0 +1,33 @@ +/* +** Particle drawing +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "sbar.h" +#include "r_data/r_translate.h" +#include "r_poly_particle.h" +#include "r_poly.h" + +void RenderPolyParticle::Render() +{ +} diff --git a/src/r_poly_particle.h b/src/r_poly_particle.h new file mode 100644 index 000000000..5573a7e48 --- /dev/null +++ b/src/r_poly_particle.h @@ -0,0 +1,29 @@ +/* +** Handling drawing a particle +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +class RenderPolyParticle +{ +public: + void Render(); +}; diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp new file mode 100644 index 000000000..ac9622110 --- /dev/null +++ b/src/r_poly_plane.cpp @@ -0,0 +1,196 @@ +/* +** Handling drawing a plane (ceiling, floor) +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "sbar.h" +#include "r_data/r_translate.h" +#include "r_poly_plane.h" +#include "r_poly.h" +#include "r_sky.h" // for skyflatnum + +void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, bool ceiling, double skyHeight) +{ + sector_t *frontsector = sub->sector; + + FTextureID picnum = frontsector->GetTexture(ceiling ? sector_t::ceiling : sector_t::floor); + FTexture *tex = TexMan(picnum); + if (tex->UseType == FTexture::TEX_Null) + return; + + bool isSky = picnum == skyflatnum; + + TriUniforms uniforms; + uniforms.objectToClip = worldToClip; + uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f); + if (fixedlightlev >= 0) + uniforms.light = (uint32_t)(fixedlightlev / 255.0f * 256.0f); + else if (fixedcolormap) + uniforms.light = 256; + uniforms.flags = 0; + uniforms.subsectorDepth = isSky ? RenderPolyScene::SkySubsectorDepth : subsectorDepth; + + TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); + if (!vertices) + return; + + if (ceiling) + { + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + vertices[sub->numlines - 1 - i] = PlaneVertex(line->v1, frontsector, isSky ? skyHeight : frontsector->ceilingplane.ZatPoint(line->v1)); + } + } + else + { + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + vertices[i] = PlaneVertex(line->v1, frontsector, isSky ? skyHeight : frontsector->floorplane.ZatPoint(line->v1)); + } + } + + PolyDrawArgs args; + args.uniforms = uniforms; + args.vinput = vertices; + args.vcount = sub->numlines; + args.mode = TriangleDrawMode::Fan; + args.ccw = true; + args.clipleft = 0; + args.cliptop = 0; + args.clipright = viewwidth; + args.clipbottom = viewheight; + args.stenciltestvalue = 0; + args.stencilwritevalue = 1; + + if (!isSky) + { + args.SetTexture(tex); + PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); + } + else + { + args.stencilwritevalue = 255; + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); + + for (uint32_t i = 0; i < sub->numlines; i++) + { + TriVertex *wallvert = PolyVertexBuffer::GetVertices(4); + if (!wallvert) + return; + + seg_t *line = &sub->firstline[i]; + + bool closedSky = false; + if (line->backsector) + { + sector_t *backsector = (line->backsector != line->frontsector) ? line->backsector : line->frontsector; + + double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1); + double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1); + double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2); + double frontfloorz2 = frontsector->floorplane.ZatPoint(line->v2); + + double backceilz1 = backsector->ceilingplane.ZatPoint(line->v1); + double backfloorz1 = backsector->floorplane.ZatPoint(line->v1); + double backceilz2 = backsector->ceilingplane.ZatPoint(line->v2); + double backfloorz2 = backsector->floorplane.ZatPoint(line->v2); + + double topceilz1 = frontceilz1; + double topceilz2 = frontceilz2; + double topfloorz1 = MIN(backceilz1, frontceilz1); + double topfloorz2 = MIN(backceilz2, frontceilz2); + double bottomceilz1 = MAX(frontfloorz1, backfloorz1); + double bottomceilz2 = MAX(frontfloorz2, backfloorz2); + double bottomfloorz1 = frontfloorz1; + double bottomfloorz2 = frontfloorz2; + double middleceilz1 = topfloorz1; + double middleceilz2 = topfloorz2; + double middlefloorz1 = MIN(bottomceilz1, middleceilz1); + double middlefloorz2 = MIN(bottomceilz2, middleceilz2); + + bool bothSkyCeiling = frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum; + bool bothSkyFloor = frontsector->GetTexture(sector_t::floor) == skyflatnum && backsector->GetTexture(sector_t::floor) == skyflatnum; + + bool closedSector = backceilz1 == backfloorz1 && backceilz2 == backfloorz2; + closedSky = (ceiling && bothSkyCeiling && closedSector) || (!ceiling && bothSkyFloor && closedSector); + if (!closedSky) + { + bool topwall = (topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && line->sidedef && !bothSkyCeiling; + bool bottomwall = (bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && line->sidedef && !bothSkyFloor; + if ((ceiling && !topwall) || (!ceiling && !bottomwall)) + continue; + } + } + + if (ceiling) + { + wallvert[0] = PlaneVertex(line->v1, frontsector, skyHeight); + wallvert[1] = PlaneVertex(line->v2, frontsector, skyHeight); + if (!closedSky) + { + wallvert[2] = PlaneVertex(line->v2, frontsector, frontsector->ceilingplane.ZatPoint(line->v2)); + wallvert[3] = PlaneVertex(line->v1, frontsector, frontsector->ceilingplane.ZatPoint(line->v1)); + } + else + { + wallvert[2] = PlaneVertex(line->v2, frontsector, frontsector->floorplane.ZatPoint(line->v2)); + wallvert[3] = PlaneVertex(line->v1, frontsector, frontsector->floorplane.ZatPoint(line->v1)); + } + } + else + { + if (!closedSky) + { + wallvert[0] = PlaneVertex(line->v1, frontsector, frontsector->floorplane.ZatPoint(line->v1)); + wallvert[1] = PlaneVertex(line->v2, frontsector, frontsector->floorplane.ZatPoint(line->v2)); + } + else + { + wallvert[0] = PlaneVertex(line->v1, frontsector, frontsector->ceilingplane.ZatPoint(line->v1)); + wallvert[1] = PlaneVertex(line->v2, frontsector, frontsector->ceilingplane.ZatPoint(line->v2)); + } + wallvert[2] = PlaneVertex(line->v2, frontsector, skyHeight); + wallvert[3] = PlaneVertex(line->v1, frontsector, skyHeight); + } + + args.vinput = wallvert; + args.vcount = 4; + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); + } + } +} + +TriVertex RenderPolyPlane::PlaneVertex(vertex_t *v1, sector_t *sector, double height) +{ + TriVertex v; + v.x = (float)v1->fPos().X; + v.y = (float)v1->fPos().Y; + v.z = (float)height; + v.w = 1.0f; + v.varying[0] = v.x / 64.0f; + v.varying[1] = 1.0f - v.y / 64.0f; + return v; +} diff --git a/src/r_poly_plane.h b/src/r_poly_plane.h new file mode 100644 index 000000000..b4f2087e8 --- /dev/null +++ b/src/r_poly_plane.h @@ -0,0 +1,34 @@ +/* +** Handling drawing a plane (ceiling, floor) +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +#include "r_poly_triangle.h" + +class RenderPolyPlane +{ +public: + void Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, bool ceiling, double skyHeight); + +private: + TriVertex PlaneVertex(vertex_t *v1, sector_t *sector, double height); +}; diff --git a/src/r_poly_playersprite.cpp b/src/r_poly_playersprite.cpp new file mode 100644 index 000000000..1a657d1a2 --- /dev/null +++ b/src/r_poly_playersprite.cpp @@ -0,0 +1,299 @@ +/* +** Handling drawing a player sprite +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "sbar.h" +#include "r_data/r_translate.h" +#include "r_poly_playersprite.h" +#include "r_poly.h" +#include "r_things.h" // for pspritexscale + +EXTERN_CVAR(Bool, r_drawplayersprites) +EXTERN_CVAR(Bool, r_deathcamera) +EXTERN_CVAR(Bool, st_scale) + +void RenderPolyPlayerSprites::Render() +{ + // In theory, everything in this function could be moved to RenderRemainingSprites. + // Just in case there's some hack elsewhere that relies on this happening as part + // of the main rendering we do it exactly as the old software renderer did. + + ScreenSprites.clear(); + + if (!r_drawplayersprites || + !camera || + !camera->player || + (players[consoleplayer].cheats & CF_CHASECAM) || + (r_deathcamera && camera->health <= 0)) + return; + + float bobx, boby; + P_BobWeapon(camera->player, &bobx, &boby, r_TicFracF); + + // Interpolate the main weapon layer once so as to be able to add it to other layers. + double wx, wy; + DPSprite *weapon = camera->player->FindPSprite(PSP_WEAPON); + if (weapon) + { + if (weapon->firstTic) + { + wx = weapon->x; + wy = weapon->y; + } + else + { + wx = weapon->oldx + (weapon->x - weapon->oldx) * r_TicFracF; + wy = weapon->oldy + (weapon->y - weapon->oldy) * r_TicFracF; + } + } + else + { + wx = 0; + wy = 0; + } + + for (DPSprite *sprite = camera->player->psprites; sprite != nullptr; sprite = sprite->GetNext()) + { + // [RH] Don't draw the targeter's crosshair if the player already has a crosshair set. + // It's possible this psprite's caller is now null but the layer itself hasn't been destroyed + // because it didn't tick yet (if we typed 'take all' while in the console for example). + // In this case let's simply not draw it to avoid crashing. + if ((sprite->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr) && sprite->GetCaller() != nullptr) + { + RenderSprite(sprite, camera, bobx, boby, wx, wy, r_TicFracF); + } + } +} + +void RenderPolyPlayerSprites::RenderRemainingSprites() +{ + for (auto &sprite : ScreenSprites) + sprite.Render(); +} + +void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac) +{ + // decide which patch to use + if ((unsigned)sprite->GetSprite() >= (unsigned)sprites.Size()) + { + DPrintf(DMSG_ERROR, "RenderPlayerSprite: invalid sprite number %i\n", sprite->GetSprite()); + return; + } + + spritedef_t *def = &sprites[sprite->GetSprite()]; + if (sprite->GetFrame() >= def->numframes) + { + DPrintf(DMSG_ERROR, "RenderPlayerSprite: invalid sprite frame %i : %i\n", sprite->GetSprite(), sprite->GetFrame()); + return; + } + + spriteframe_t *frame = &SpriteFrames[def->spriteframes + sprite->GetFrame()]; + FTextureID picnum = frame->Texture[0]; + bool flip = (frame->Flip & 1) != 0; + + FTexture *tex = TexMan(picnum); + if (tex->UseType == FTexture::TEX_Null) + return; + + // Can't interpolate the first tic. + if (sprite->firstTic) + { + sprite->firstTic = false; + sprite->oldx = sprite->x; + sprite->oldy = sprite->y; + } + + double sx = sprite->oldx + (sprite->x - sprite->oldx) * ticfrac; + double sy = sprite->oldy + (sprite->y - sprite->oldy) * ticfrac; + + if (sprite->Flags & PSPF_ADDBOB) + { + sx += bobx; + sy += boby; + } + + if (sprite->Flags & PSPF_ADDWEAPON && sprite->GetID() != PSP_WEAPON) + { + sx += wx; + sy += wy; + } + + // calculate edges of the shape + double tx = sx - BaseXCenter; + + tx -= tex->GetScaledLeftOffset(); + int x1 = xs_RoundToInt(CenterX + tx * pspritexscale); + + // off the right side + if (x1 > viewwidth) + return; + + tx += tex->GetScaledWidth(); + int x2 = xs_RoundToInt(CenterX + tx * pspritexscale); + + // off the left side + if (x2 <= 0) + return; + + double texturemid = (BaseYCenter - sy) * tex->Scale.Y + tex->TopOffset; + + // Adjust PSprite for fullscreen views + if (camera->player && (RenderTarget != screen || viewheight == RenderTarget->GetHeight() || (RenderTarget->GetWidth() > (BaseXCenter * 2) && !st_scale))) + { + AWeapon *weapon = dyn_cast(sprite->GetCaller()); + if (weapon != nullptr && weapon->YAdjust != 0) + { + if (RenderTarget != screen || viewheight == RenderTarget->GetHeight()) + { + texturemid -= weapon->YAdjust; + } + else + { + texturemid -= StatusBar->GetDisplacement() * weapon->YAdjust; + } + } + } + + // Move the weapon down for 1280x1024. + if (sprite->GetID() < PSP_TARGETCENTER) + { + texturemid -= AspectPspriteOffset(WidescreenRatio); + } + + int clipped_x1 = MAX(x1, 0); + int clipped_x2 = MIN(x2, viewwidth); + double xscale = pspritexscale / tex->Scale.X; + double yscale = pspriteyscale / tex->Scale.Y; + uint32_t translation = 0; // [RH] Use default colors + + double xiscale, startfrac; + if (flip) + { + xiscale = -pspritexiscale * tex->Scale.X; + startfrac = 1; + } + else + { + xiscale = pspritexiscale * tex->Scale.X; + startfrac = 0; + } + + if (clipped_x1 > x1) + startfrac += xiscale * (clipped_x1 - x1); + + bool noaccel = false; + + FDynamicColormap *basecolormap = viewsector->ColorMap; + FDynamicColormap *colormap_to_use = basecolormap; + + visstyle_t visstyle; + visstyle.ColormapNum = 0; + visstyle.BaseColormap = basecolormap; + visstyle.Alpha = 0; + visstyle.RenderStyle = STYLE_Normal; + + bool foggy = false; + int actualextralight = foggy ? 0 : extralight << 4; + int spriteshade = LIGHT2SHADE(owner->Sector->lightlevel + actualextralight); + double minz = double((2048 * 4) / double(1 << 20)); + visstyle.ColormapNum = GETPALOOKUP(r_SpriteVisibility / minz, spriteshade); + + if (sprite->GetID() < PSP_TARGETCENTER) + { + // Lots of complicated style and noaccel stuff + } + + // Check for hardware-assisted 2D. If it's available, and this sprite is not + // fuzzy, don't draw it until after the switch to 2D mode. + if (!noaccel && RenderTarget == screen && (DFrameBuffer *)screen->Accel2D) + { + FRenderStyle style = visstyle.RenderStyle; + style.CheckFuzz(); + if (style.BlendOp != STYLEOP_Fuzz) + { + PolyScreenSprite screenSprite; + screenSprite.Pic = tex; + screenSprite.X1 = viewwindowx + x1; + screenSprite.Y1 = viewwindowy + viewheight / 2 - texturemid * yscale - 0.5; + screenSprite.Width = tex->GetWidth() * xscale; + screenSprite.Height = tex->GetHeight() * yscale; + screenSprite.Translation = TranslationToTable(translation); + screenSprite.Flip = xiscale < 0; + screenSprite.visstyle = visstyle; + screenSprite.Colormap = colormap_to_use; + ScreenSprites.push_back(screenSprite); + return; + } + } + + //R_DrawVisSprite(vis); +} + +void PolyScreenSprite::Render() +{ + FSpecialColormap *special = nullptr; + FColormapStyle colormapstyle; + PalEntry overlay = 0; + bool usecolormapstyle = false; + if (visstyle.BaseColormap >= &SpecialColormaps[0] && + visstyle.BaseColormap < &SpecialColormaps[SpecialColormaps.Size()]) + { + special = static_cast(visstyle.BaseColormap); + } + else if (Colormap->Color == PalEntry(255, 255, 255) && + Colormap->Desaturate == 0) + { + overlay = Colormap->Fade; + overlay.a = BYTE(visstyle.ColormapNum * 255 / NUMCOLORMAPS); + } + else + { + usecolormapstyle = true; + colormapstyle.Color = Colormap->Color; + colormapstyle.Fade = Colormap->Fade; + colormapstyle.Desaturate = Colormap->Desaturate; + colormapstyle.FadeLevel = visstyle.ColormapNum / float(NUMCOLORMAPS); + } + + screen->DrawTexture(Pic, + X1, + Y1, + DTA_DestWidthF, Width, + DTA_DestHeightF, Height, + DTA_Translation, Translation, + DTA_FlipX, Flip, + DTA_TopOffset, 0, + DTA_LeftOffset, 0, + DTA_ClipLeft, viewwindowx, + DTA_ClipTop, viewwindowy, + DTA_ClipRight, viewwindowx + viewwidth, + DTA_ClipBottom, viewwindowy + viewheight, + DTA_AlphaF, visstyle.Alpha, + DTA_RenderStyle, visstyle.RenderStyle, + DTA_FillColor, FillColor, + DTA_SpecialColormap, special, + DTA_ColorOverlay, overlay.d, + DTA_ColormapStyle, usecolormapstyle ? &colormapstyle : nullptr, + TAG_DONE); +} diff --git a/src/r_poly_playersprite.h b/src/r_poly_playersprite.h new file mode 100644 index 000000000..e7384e200 --- /dev/null +++ b/src/r_poly_playersprite.h @@ -0,0 +1,59 @@ +/* +** Handling drawing a player sprite +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +class PolyScreenSprite; +class DPSprite; + +class RenderPolyPlayerSprites +{ +public: + void Render(); + void RenderRemainingSprites(); + +private: + void RenderSprite(DPSprite *sprite, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac); + + const int BaseXCenter = 160; + const int BaseYCenter = 100; + + std::vector ScreenSprites; +}; + +// DScreen accelerated sprite to be rendered +class PolyScreenSprite +{ +public: + void Render(); + + FTexture *Pic = nullptr; + double X1 = 0.0; + double Y1 = 0.0; + double Width = 0.0; + double Height = 0.0; + FRemapTable *Translation = nullptr; + bool Flip = false; + visstyle_t visstyle; + uint32_t FillColor = 0; + FDynamicColormap *Colormap = nullptr; +}; diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp new file mode 100644 index 000000000..03a4bfdb2 --- /dev/null +++ b/src/r_poly_sky.cpp @@ -0,0 +1,193 @@ +/* +** Sky dome rendering +** Copyright(C) 2003-2016 Christoph Oelckers +** All rights reserved. +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program. If not, see http:**www.gnu.org/licenses/ +** +** Loosely based on the JDoom sky and the ZDoomGL 0.66.2 sky. +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "sbar.h" +#include "r_data/r_translate.h" +#include "r_poly_sky.h" +#include "r_poly.h" +#include "r_sky.h" // for skyflatnum + +PolySkyDome::PolySkyDome() +{ + CreateDome(); +} + +void PolySkyDome::Render(const TriMatrix &worldToClip) +{ + FTextureID sky1tex, sky2tex; + if ((level.flags & LEVEL_SWAPSKIES) && !(level.flags & LEVEL_DOUBLESKY)) + sky1tex = sky2texture; + else + sky1tex = sky1texture; + sky2tex = sky2texture; + + FTexture *frontskytex = TexMan(sky1tex, true); + FTexture *backskytex = nullptr; + if (level.flags & LEVEL_DOUBLESKY) + backskytex = TexMan(sky2tex, true); + + TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); + + TriUniforms uniforms; + uniforms.objectToClip = worldToClip * objectToWorld; + uniforms.light = 256; + uniforms.flags = 0; + uniforms.subsectorDepth = RenderPolyScene::SkySubsectorDepth; + + int rc = mRows + 1; + + PolyDrawArgs args; + args.uniforms = uniforms; + args.clipleft = 0; + args.cliptop = 0; + args.clipright = viewwidth; + args.clipbottom = viewheight; + args.stenciltestvalue = 255; + args.stencilwritevalue = 1; + args.SetTexture(frontskytex); + + RenderCapColorRow(args, frontskytex, 0, false); + RenderCapColorRow(args, frontskytex, rc, true); + + for (int i = 1; i <= mRows; i++) + { + RenderRow(args, i); + RenderRow(args, rc + i); + } +} + +void PolySkyDome::RenderRow(PolyDrawArgs &args, int row) +{ + args.vinput = &mVertices[mPrimStart[row]]; + args.vcount = mPrimStart[row + 1] - mPrimStart[row]; + args.mode = TriangleDrawMode::Strip; + args.ccw = false; + PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); +} + +void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap) +{ + uint32_t solid = skytex->GetSkyCapColor(bottomCap); + if (!r_swtruecolor) + solid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)]; + + args.vinput = &mVertices[mPrimStart[row]]; + args.vcount = mPrimStart[row + 1] - mPrimStart[row]; + args.mode = TriangleDrawMode::Fan; + args.ccw = bottomCap; + args.solidcolor = solid; + PolyTriangleDrawer::draw(args, TriDrawVariant::Fill); +} + +void PolySkyDome::CreateDome() +{ + mColumns = 128; + mRows = 4; + CreateSkyHemisphere(false); + CreateSkyHemisphere(true); + mPrimStart.Push(mVertices.Size()); +} + +void PolySkyDome::CreateSkyHemisphere(bool zflip) +{ + int r, c; + + mPrimStart.Push(mVertices.Size()); + + for (c = 0; c < mColumns; c++) + { + SkyVertex(1, c, zflip); + } + + // The total number of triangles per hemisphere can be calculated + // as follows: rows * columns * 2 + 2 (for the top cap). + for (r = 0; r < mRows; r++) + { + mPrimStart.Push(mVertices.Size()); + for (c = 0; c <= mColumns; c++) + { + SkyVertex(r + zflip, c, zflip); + SkyVertex(r + 1 - zflip, c, zflip); + } + } +} + +TriVertex PolySkyDome::SetVertex(float xx, float yy, float zz, float uu, float vv) +{ + TriVertex v; + v.x = xx; + v.y = yy; + v.z = zz; + v.w = 1.0f; + v.varying[0] = uu; + v.varying[1] = vv; + return v; +} + +TriVertex PolySkyDome::SetVertexXYZ(float xx, float yy, float zz, float uu, float vv) +{ + TriVertex v; + v.x = xx; + v.y = zz; + v.z = yy; + v.w = 1.0f; + v.varying[0] = uu; + v.varying[1] = vv; + return v; +} + +void PolySkyDome::SkyVertex(int r, int c, bool zflip) +{ + static const FAngle maxSideAngle = 60.f; + static const float scale = 10000.; + + FAngle topAngle = (c / (float)mColumns * 360.f); + FAngle sideAngle = maxSideAngle * (float)(mRows - r) / (float)mRows; + float height = sideAngle.Sin(); + float realRadius = scale * sideAngle.Cos(); + FVector2 pos = topAngle.ToVector(realRadius); + float z = (!zflip) ? scale * height : -scale * height; + + float u, v; + //uint32_t color = r == 0 ? 0xffffff : 0xffffffff; + + // And the texture coordinates. + if (!zflip) // Flipped Y is for the lower hemisphere. + { + u = (-c / (float)mColumns); + v = (r / (float)mRows); + } + else + { + u = (-c / (float)mColumns); + v = 1.0f + ((mRows - r) / (float)mRows); + } + + if (r != 4) z += 300; + + // And finally the vertex. + TriVertex vert; + vert = SetVertexXYZ(-pos.X, z - 1.f, pos.Y, u * 4.0f, v * 1.2f + 0.5f/*, color*/); + mVertices.Push(vert); +} diff --git a/src/r_poly_sky.h b/src/r_poly_sky.h new file mode 100644 index 000000000..dd4bd29ca --- /dev/null +++ b/src/r_poly_sky.h @@ -0,0 +1,45 @@ +/* +** Sky dome rendering +** Copyright(C) 2003-2016 Christoph Oelckers +** All rights reserved. +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program. If not, see http:**www.gnu.org/licenses/ +** +** Loosely based on the JDoom sky and the ZDoomGL 0.66.2 sky. +*/ + +#pragma once + +#include "r_poly_triangle.h" + +class PolySkyDome +{ +public: + PolySkyDome(); + void Render(const TriMatrix &worldToClip); + +private: + TArray mVertices; + TArray mPrimStart; + int mRows, mColumns; + + void SkyVertex(int r, int c, bool yflip); + void CreateSkyHemisphere(bool zflip); + void CreateDome(); + void RenderRow(PolyDrawArgs &args, int row); + void RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap); + + TriVertex SetVertex(float xx, float yy, float zz, float uu = 0, float vv = 0); + TriVertex SetVertexXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0); +}; diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp new file mode 100644 index 000000000..b3a57ec47 --- /dev/null +++ b/src/r_poly_sprite.cpp @@ -0,0 +1,301 @@ +/* +** Handling drawing a sprite +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "sbar.h" +#include "r_data/r_translate.h" +#include "r_poly_sprite.h" +#include "r_poly.h" + +void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth) +{ + if (IsThingCulled(thing)) + return; + + DVector3 pos = thing->InterpolatedPosition(r_TicFracF); + pos.Z += thing->GetBobOffset(r_TicFracF); + + bool flipTextureX = false; + FTexture *tex = GetSpriteTexture(thing, flipTextureX); + if (tex == nullptr) + return; + DVector2 spriteScale = thing->Scale; + double thingxscalemul = spriteScale.X / tex->Scale.X; + double thingyscalemul = spriteScale.Y / tex->Scale.Y; + + if (flipTextureX) + pos.X -= (tex->GetWidth() - tex->LeftOffset) * thingxscalemul; + else + pos.X -= tex->LeftOffset * thingxscalemul; + + //pos.Z -= tex->TopOffset * thingyscalemul; + pos.Z -= (tex->GetHeight() - tex->TopOffset) * thingyscalemul + thing->Floorclip; + + double spriteHalfWidth = thingxscalemul * tex->GetWidth() * 0.5; + double spriteHeight = thingyscalemul * tex->GetHeight(); + + pos.X += spriteHalfWidth; + + DVector2 points[2] = + { + { pos.X - ViewSin * spriteHalfWidth, pos.Y + ViewCos * spriteHalfWidth }, + { pos.X + ViewSin * spriteHalfWidth, pos.Y - ViewCos * spriteHalfWidth } + }; + + // Is this sprite inside? (To do: clip the points) + for (int i = 0; i < 2; i++) + { + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + double nx = line->v1->fY() - line->v2->fY(); + double ny = line->v2->fX() - line->v1->fX(); + double d = -(line->v1->fX() * nx + line->v1->fY() * ny); + if (pos.X * nx + pos.Y * ny + d > 0.0) + return; + } + } + + //double depth = 1.0; + //visstyle_t visstyle = GetSpriteVisStyle(thing, depth); + // Rumor has it that AlterWeaponSprite needs to be called with visstyle passed in somewhere around here.. + //R_SetColorMapLight(visstyle.BaseColormap, 0, visstyle.ColormapNum << FRACBITS); + + TriVertex *vertices = PolyVertexBuffer::GetVertices(4); + if (!vertices) + return; + + bool foggy = false; + int actualextralight = foggy ? 0 : extralight << 4; + + std::pair offsets[4] = + { + { 0.0f, 1.0f }, + { 1.0f, 1.0f }, + { 1.0f, 0.0f }, + { 0.0f, 0.0f }, + }; + + for (int i = 0; i < 4; i++) + { + auto &p = (i == 0 || i == 3) ? points[0] : points[1]; + + vertices[i].x = (float)p.X; + vertices[i].y = (float)p.Y; + vertices[i].z = (float)(pos.Z + spriteHeight * offsets[i].second); + vertices[i].w = 1.0f; + vertices[i].varying[0] = (float)(offsets[i].first * tex->Scale.X); + vertices[i].varying[1] = (float)((1.0f - offsets[i].second) * tex->Scale.Y); + if (flipTextureX) + vertices[i].varying[0] = 1.0f - vertices[i].varying[0]; + } + + TriUniforms uniforms; + uniforms.objectToClip = worldToClip; + uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f); + uniforms.flags = 0; + uniforms.subsectorDepth = subsectorDepth; + + PolyDrawArgs args; + args.uniforms = uniforms; + args.vinput = vertices; + args.vcount = 4; + args.mode = TriangleDrawMode::Fan; + args.ccw = true; + args.clipleft = 0; + args.cliptop = 0; + args.clipright = viewwidth; + args.clipbottom = viewheight; + args.stenciltestvalue = 0; + args.stencilwritevalue = 1; + args.SetTexture(tex); + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector); +} + +bool RenderPolySprite::IsThingCulled(AActor *thing) +{ + FIntCVar *cvar = thing->GetClass()->distancecheck; + if (cvar != nullptr && *cvar >= 0) + { + double dist = (thing->Pos() - ViewPos).LengthSquared(); + double check = (double)**cvar; + if (dist >= check * check) + return true; + } + + // Don't waste time projecting sprites that are definitely not visible. + if (thing == nullptr || + (thing->renderflags & RF_INVISIBLE) || + !thing->RenderStyle.IsVisible(thing->Alpha) || + !thing->IsVisibleToPlayer()) + { + return true; + } + + return false; +} + +visstyle_t RenderPolySprite::GetSpriteVisStyle(AActor *thing, double z) +{ + visstyle_t visstyle; + + bool foggy = false; + int actualextralight = foggy ? 0 : extralight << 4; + int spriteshade = LIGHT2SHADE(thing->Sector->lightlevel + actualextralight); + + visstyle.RenderStyle = thing->RenderStyle; + visstyle.Alpha = float(thing->Alpha); + visstyle.ColormapNum = 0; + + // The software renderer cannot invert the source without inverting the overlay + // too. That means if the source is inverted, we need to do the reverse of what + // the invert overlay flag says to do. + bool invertcolormap = (visstyle.RenderStyle.Flags & STYLEF_InvertOverlay) != 0; + + if (visstyle.RenderStyle.Flags & STYLEF_InvertSource) + { + invertcolormap = !invertcolormap; + } + + FDynamicColormap *mybasecolormap = thing->Sector->ColorMap; + + // Sprites that are added to the scene must fade to black. + if (visstyle.RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0) + { + mybasecolormap = GetSpecialLights(mybasecolormap->Color, 0, mybasecolormap->Desaturate); + } + + if (visstyle.RenderStyle.Flags & STYLEF_FadeToBlack) + { + if (invertcolormap) + { // Fade to white + mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(255, 255, 255), mybasecolormap->Desaturate); + invertcolormap = false; + } + else + { // Fade to black + mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(0, 0, 0), mybasecolormap->Desaturate); + } + } + + // get light level + if (fixedcolormap != nullptr) + { // fixed map + visstyle.BaseColormap = fixedcolormap; + visstyle.ColormapNum = 0; + } + else + { + if (invertcolormap) + { + mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate); + } + if (fixedlightlev >= 0) + { + visstyle.BaseColormap = mybasecolormap; + visstyle.ColormapNum = fixedlightlev >> COLORMAPSHIFT; + } + else if (!foggy && ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) + { // full bright + visstyle.BaseColormap = mybasecolormap; + visstyle.ColormapNum = 0; + } + else + { // diminished light + double minz = double((2048 * 4) / double(1 << 20)); + visstyle.ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(z, minz), spriteshade); + visstyle.BaseColormap = mybasecolormap; + } + } + + return visstyle; +} + +FTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX) +{ + flipX = false; + if (thing->picnum.isValid()) + { + FTexture *tex = TexMan(thing->picnum); + if (tex->UseType == FTexture::TEX_Null) + { + return nullptr; + } + + if (tex->Rotations != 0xFFFF) + { + // choose a different rotation based on player view + spriteframe_t *sprframe = &SpriteFrames[tex->Rotations]; + DVector3 pos = thing->InterpolatedPosition(r_TicFracF); + pos.Z += thing->GetBobOffset(r_TicFracF); + DAngle ang = (pos - ViewPos).Angle(); + angle_t rot; + if (sprframe->Texture[0] == sprframe->Texture[1]) + { + rot = (ang - thing->Angles.Yaw + 45.0 / 2 * 9).BAMs() >> 28; + } + else + { + rot = (ang - thing->Angles.Yaw + (45.0 / 2 * 9 - 180.0 / 16)).BAMs() >> 28; + } + flipX = (sprframe->Flip & (1 << rot)) != 0; + tex = TexMan[sprframe->Texture[rot]]; // Do not animate the rotation + } + return tex; + } + else + { + // decide which texture to use for the sprite + int spritenum = thing->sprite; + if (spritenum >= (signed)sprites.Size() || spritenum < 0) + return nullptr; + + spritedef_t *sprdef = &sprites[spritenum]; + if (thing->frame >= sprdef->numframes) + { + // If there are no frames at all for this sprite, don't draw it. + return nullptr; + } + else + { + //picnum = SpriteFrames[sprdef->spriteframes + thing->frame].Texture[0]; + // choose a different rotation based on player view + spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + thing->frame]; + DVector3 pos = thing->InterpolatedPosition(r_TicFracF); + pos.Z += thing->GetBobOffset(r_TicFracF); + DAngle ang = (pos - ViewPos).Angle(); + angle_t rot; + if (sprframe->Texture[0] == sprframe->Texture[1]) + { + rot = (ang - thing->Angles.Yaw + 45.0 / 2 * 9).BAMs() >> 28; + } + else + { + rot = (ang - thing->Angles.Yaw + (45.0 / 2 * 9 - 180.0 / 16)).BAMs() >> 28; + } + flipX = (sprframe->Flip & (1 << rot)) != 0; + return TexMan[sprframe->Texture[rot]]; // Do not animate the rotation + } + } +} diff --git a/src/r_poly_sprite.h b/src/r_poly_sprite.h new file mode 100644 index 000000000..d60710d04 --- /dev/null +++ b/src/r_poly_sprite.h @@ -0,0 +1,37 @@ +/* +** Handling drawing a sprite +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +#include "r_poly_triangle.h" + +class RenderPolySprite +{ +public: + void Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth); + + static bool IsThingCulled(AActor *thing); + +private: + visstyle_t GetSpriteVisStyle(AActor *thing, double z); + FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); +}; diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp new file mode 100644 index 000000000..815230052 --- /dev/null +++ b/src/r_poly_wall.cpp @@ -0,0 +1,334 @@ +/* +** Handling drawing a wall +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "sbar.h" +#include "r_data/r_translate.h" +#include "r_poly_wall.h" +#include "r_poly.h" +#include "r_sky.h" // for skyflatnum + +bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, std::vector &translucentWallsOutput) +{ + double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1); + double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1); + double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2); + double frontfloorz2 = frontsector->floorplane.ZatPoint(line->v2); + + RenderPolyWall wall; + wall.Line = line; + wall.Colormap = frontsector->ColorMap; + wall.Masked = false; + wall.SubsectorDepth = subsectorDepth; + + if (line->backsector == nullptr) + { + if (line->sidedef) + { + wall.SetCoords(line->v1->fPos(), line->v2->fPos(), frontceilz1, frontfloorz1, frontceilz2, frontfloorz2); + wall.TopZ = frontceilz1; + wall.BottomZ = frontfloorz1; + wall.UnpeggedCeil = frontceilz1; + wall.Texpart = side_t::mid; + wall.Render(worldToClip); + return true; + } + } + else + { + sector_t *backsector = (line->backsector != line->frontsector) ? line->backsector : line->frontsector; + + double backceilz1 = backsector->ceilingplane.ZatPoint(line->v1); + double backfloorz1 = backsector->floorplane.ZatPoint(line->v1); + double backceilz2 = backsector->ceilingplane.ZatPoint(line->v2); + double backfloorz2 = backsector->floorplane.ZatPoint(line->v2); + + double topceilz1 = frontceilz1; + double topceilz2 = frontceilz2; + double topfloorz1 = MIN(backceilz1, frontceilz1); + double topfloorz2 = MIN(backceilz2, frontceilz2); + double bottomceilz1 = MAX(frontfloorz1, backfloorz1); + double bottomceilz2 = MAX(frontfloorz2, backfloorz2); + double bottomfloorz1 = frontfloorz1; + double bottomfloorz2 = frontfloorz2; + double middleceilz1 = topfloorz1; + double middleceilz2 = topfloorz2; + double middlefloorz1 = MIN(bottomceilz1, middleceilz1); + double middlefloorz2 = MIN(bottomceilz2, middleceilz2); + + bool bothSkyCeiling = frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum; + + if ((topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && line->sidedef && !bothSkyCeiling) + { + wall.SetCoords(line->v1->fPos(), line->v2->fPos(), topceilz1, topfloorz1, topceilz2, topfloorz2); + wall.TopZ = topceilz1; + wall.BottomZ = topfloorz1; + wall.UnpeggedCeil = topceilz1; + wall.Texpart = side_t::top; + wall.Render(worldToClip); + } + + if ((bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && line->sidedef) + { + wall.SetCoords(line->v1->fPos(), line->v2->fPos(), bottomceilz1, bottomfloorz2, bottomceilz2, bottomfloorz2); + wall.TopZ = bottomceilz1; + wall.BottomZ = bottomfloorz2; + wall.UnpeggedCeil = topceilz1; + wall.Texpart = side_t::bottom; + wall.Render(worldToClip); + } + + if (line->sidedef) + { + FTexture *midtex = TexMan(line->sidedef->GetTexture(side_t::mid), true); + if (midtex && midtex->UseType != FTexture::TEX_Null) + { + wall.SetCoords(line->v1->fPos(), line->v2->fPos(), middleceilz1, middlefloorz1, middleceilz2, middlefloorz2); + wall.TopZ = middleceilz1; + wall.BottomZ = middlefloorz1; + wall.UnpeggedCeil = topceilz1; + wall.Texpart = side_t::mid; + wall.Masked = true; + translucentWallsOutput.push_back({ wall }); + } + } + } + return false; +} + +void RenderPolyWall::Render(const TriMatrix &worldToClip) +{ + FTexture *tex = GetTexture(); + if (!tex) + return; + + PolyWallTextureCoords texcoords(tex, Line, Texpart, TopZ, BottomZ, UnpeggedCeil); + + TriVertex *vertices = PolyVertexBuffer::GetVertices(4); + if (!vertices) + return; + + vertices[0].x = (float)v1.X; + vertices[0].y = (float)v1.Y; + vertices[0].z = (float)ceil1; + vertices[0].w = 1.0f; + vertices[0].varying[0] = (float)texcoords.u1; + vertices[0].varying[1] = (float)texcoords.v1; + + vertices[1].x = (float)v2.X; + vertices[1].y = (float)v2.Y; + vertices[1].z = (float)ceil2; + vertices[1].w = 1.0f; + vertices[1].varying[0] = (float)texcoords.u2; + vertices[1].varying[1] = (float)texcoords.v1; + + vertices[2].x = (float)v2.X; + vertices[2].y = (float)v2.Y; + vertices[2].z = (float)floor2; + vertices[2].w = 1.0f; + vertices[2].varying[0] = (float)texcoords.u2; + vertices[2].varying[1] = (float)texcoords.v2; + + vertices[3].x = (float)v1.X; + vertices[3].y = (float)v1.Y; + vertices[3].z = (float)floor1; + vertices[3].w = 1.0f; + vertices[3].varying[0] = (float)texcoords.u1; + vertices[3].varying[1] = (float)texcoords.v2; + + TriUniforms uniforms; + uniforms.objectToClip = worldToClip; + uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f); + uniforms.flags = 0; + uniforms.subsectorDepth = SubsectorDepth; + + PolyDrawArgs args; + args.uniforms = uniforms; + args.vinput = vertices; + args.vcount = 4; + args.mode = TriangleDrawMode::Fan; + args.ccw = true; + args.clipleft = 0; + args.cliptop = 0; + args.clipright = viewwidth; + args.clipbottom = viewheight; + args.stenciltestvalue = 0; + args.stencilwritevalue = 1; + args.SetTexture(tex); + + if (!Masked) + { + PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); + } + else + { + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector); + } +} + +FTexture *RenderPolyWall::GetTexture() +{ + FTexture *tex = TexMan(Line->sidedef->GetTexture(Texpart), true); + if (tex == nullptr || tex->UseType == FTexture::TEX_Null) + return nullptr; + else + return tex; +} + +int RenderPolyWall::GetLightLevel() +{ + if (fixedlightlev >= 0 || fixedcolormap) + { + return 255; + } + else + { + bool foggy = false; + int actualextralight = foggy ? 0 : extralight << 4; + return Line->sidedef->GetLightLevel(foggy, Line->frontsector->lightlevel) + actualextralight; + } +} + +///////////////////////////////////////////////////////////////////////////// + +PolyWallTextureCoords::PolyWallTextureCoords(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil) +{ + CalcU(tex, line, texpart); + CalcV(tex, line, texpart, topz, bottomz, unpeggedceil); +} + +void PolyWallTextureCoords::CalcU(FTexture *tex, const seg_t *line, side_t::ETexpart texpart) +{ + double lineLength = line->sidedef->TexelLength; + double lineStart = 0.0; + + bool entireSegment = ((line->linedef->v1 == line->v1) && (line->linedef->v2 == line->v2) || (line->linedef->v2 == line->v1) && (line->linedef->v1 == line->v2)); + if (!entireSegment) + { + lineLength = (line->v2->fPos() - line->v1->fPos()).Length(); + lineStart = (line->v1->fPos() - line->linedef->v1->fPos()).Length(); + } + + int texWidth = tex->GetWidth(); + double uscale = line->sidedef->GetTextureXScale(texpart) * tex->Scale.X; + u1 = lineStart + line->sidedef->GetTextureXOffset(texpart); + u2 = u1 + lineLength; + u1 *= uscale; + u2 *= uscale; + u1 /= texWidth; + u2 /= texWidth; +} + +void PolyWallTextureCoords::CalcV(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil) +{ + double vscale = line->sidedef->GetTextureYScale(texpart) * tex->Scale.Y; + + double yoffset = line->sidedef->GetTextureYOffset(texpart); + if (tex->bWorldPanning) + yoffset *= vscale; + + switch (texpart) + { + default: + case side_t::mid: + CalcVMidPart(tex, line, topz, bottomz, vscale, yoffset); + break; + case side_t::top: + CalcVTopPart(tex, line, topz, bottomz, vscale, yoffset); + break; + case side_t::bottom: + CalcVBottomPart(tex, line, topz, bottomz, unpeggedceil, vscale, yoffset); + break; + } + + int texHeight = tex->GetHeight(); + v1 /= texHeight; + v2 /= texHeight; +} + +void PolyWallTextureCoords::CalcVTopPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset) +{ + bool pegged = (line->linedef->flags & ML_DONTPEGTOP) == 0; + if (pegged) // bottom to top + { + int texHeight = tex->GetHeight(); + v1 = -yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + v1 = texHeight - v1; + v2 = texHeight - v2; + std::swap(v1, v2); + } + else // top to bottom + { + v1 = yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + } +} + +void PolyWallTextureCoords::CalcVMidPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset) +{ + bool pegged = (line->linedef->flags & ML_DONTPEGBOTTOM) == 0; + if (pegged) // top to bottom + { + v1 = yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + } + else // bottom to top + { + int texHeight = tex->GetHeight(); + v1 = yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + v1 = texHeight - v1; + v2 = texHeight - v2; + std::swap(v1, v2); + } +} + +void PolyWallTextureCoords::CalcVBottomPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double unpeggedceil, double vscale, double yoffset) +{ + bool pegged = (line->linedef->flags & ML_DONTPEGBOTTOM) == 0; + if (pegged) // top to bottom + { + v1 = yoffset; + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + } + else + { + v1 = yoffset + (unpeggedceil - topz); + v2 = v1 + (topz - bottomz); + v1 *= vscale; + v2 *= vscale; + } +} diff --git a/src/r_poly_wall.h b/src/r_poly_wall.h new file mode 100644 index 000000000..c215bb611 --- /dev/null +++ b/src/r_poly_wall.h @@ -0,0 +1,82 @@ +/* +** Handling drawing a wall +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +#include "r_poly_triangle.h" + +class PolyTranslucentObject; + +class RenderPolyWall +{ +public: + static bool RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, std::vector &translucentWallsOutput); + + void Render(const TriMatrix &worldToClip); + + void SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2) + { + this->v1 = v1; + this->v2 = v2; + this->ceil1 = ceil1; + this->floor1 = floor1; + this->ceil2 = ceil2; + this->floor2 = floor2; + } + + DVector2 v1; + DVector2 v2; + double ceil1 = 0.0; + double floor1 = 0.0; + double ceil2 = 0.0; + double floor2 = 0.0; + + const seg_t *Line = nullptr; + side_t::ETexpart Texpart = side_t::mid; + double TopZ = 0.0; + double BottomZ = 0.0; + double UnpeggedCeil = 0.0; + FSWColormap *Colormap = nullptr; + bool Masked = false; + uint32_t SubsectorDepth = 0; + +private: + FTexture *GetTexture(); + int GetLightLevel(); +}; + +// Texture coordinates for a wall +class PolyWallTextureCoords +{ +public: + PolyWallTextureCoords(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil); + + double u1, u2; + double v1, v2; + +private: + void CalcU(FTexture *tex, const seg_t *line, side_t::ETexpart texpart); + void CalcV(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil); + void CalcVTopPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset); + void CalcVMidPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset); + void CalcVBottomPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double unpeggedceil, double vscale, double yoffset); +}; diff --git a/src/r_poly_wallsprite.cpp b/src/r_poly_wallsprite.cpp new file mode 100644 index 000000000..86ddd52a9 --- /dev/null +++ b/src/r_poly_wallsprite.cpp @@ -0,0 +1,35 @@ +/* +** Handling drawing a sprite +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "sbar.h" +#include "r_data/r_translate.h" +#include "r_poly_wallsprite.h" +#include "r_poly.h" + +void RenderPolyWallSprite::Render(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) +{ + if (RenderPolySprite::IsThingCulled(thing)) + return; +} diff --git a/src/r_poly_wallsprite.h b/src/r_poly_wallsprite.h new file mode 100644 index 000000000..ce6917e58 --- /dev/null +++ b/src/r_poly_wallsprite.h @@ -0,0 +1,31 @@ +/* +** Handling drawing a wall sprite +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +#include "r_triangle.h" + +class RenderPolyWallSprite +{ +public: + void Render(AActor *thing, subsector_t *sub, uint32_t subsectorDepth); +}; diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 97a207652..3ddfcb5f2 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -44,8 +44,11 @@ #include "r_data/voxels.h" #include "r_draw_rgba.h" #include "r_compiler/llvmdrawers.h" +#include "r_poly.h" EXTERN_CVAR(Bool, r_shadercolormaps) +EXTERN_CVAR(Bool, r_newrenderer) // [SP] dpJudas's new renderer +EXTERN_CVAR(Float, maxviewpitch) // [SP] CVAR from GZDoom void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio); void R_SetupColormap(player_t *); @@ -239,7 +242,14 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int wi void FSoftwareRenderer::DrawRemainingPlayerSprites() { - R_DrawRemainingPlayerSprites(); + if (!r_newrenderer) + { + R_DrawRemainingPlayerSprites(); + } + else + { + RenderPolyScene::Instance()->RenderRemainingPlayerSprites(); + } } //=========================================================================== @@ -250,9 +260,6 @@ void FSoftwareRenderer::DrawRemainingPlayerSprites() #define MAX_DN_ANGLE 56 // Max looking down angle #define MAX_UP_ANGLE 32 // Max looking up angle -EXTERN_CVAR(Bool, r_newrenderer) // [SP] dpJudas's new renderer -EXTERN_CVAR(Float, maxviewpitch) // [SP] CVAR from GZDoom - int FSoftwareRenderer::GetMaxViewPitch(bool down) { return (r_newrenderer) ? int(maxviewpitch) : (down ? MAX_DN_ANGLE : MAX_UP_ANGLE); From e5f8af2216fa65b8dfb294aeaed56dc3098b792c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 14 Nov 2016 23:22:38 +0100 Subject: [PATCH 1215/1509] Fix sky flood fill for E1M8 and Map11 --- src/r_poly_plane.cpp | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index ac9622110..9ca82cf28 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -103,7 +103,8 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin seg_t *line = &sub->firstline[i]; - bool closedSky = false; + double skyBottomz1 = frontsector->ceilingplane.ZatPoint(line->v1); + double skyBottomz2 = frontsector->ceilingplane.ZatPoint(line->v2); if (line->backsector) { sector_t *backsector = (line->backsector != line->frontsector) ? line->backsector : line->frontsector; @@ -132,14 +133,17 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin double middlefloorz2 = MIN(bottomceilz2, middleceilz2); bool bothSkyCeiling = frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum; - bool bothSkyFloor = frontsector->GetTexture(sector_t::floor) == skyflatnum && backsector->GetTexture(sector_t::floor) == skyflatnum; bool closedSector = backceilz1 == backfloorz1 && backceilz2 == backfloorz2; - closedSky = (ceiling && bothSkyCeiling && closedSector) || (!ceiling && bothSkyFloor && closedSector); - if (!closedSky) + if (ceiling && bothSkyCeiling && closedSector) + { + skyBottomz1 = middlefloorz1; + skyBottomz2 = middlefloorz2; + } + else { bool topwall = (topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && line->sidedef && !bothSkyCeiling; - bool bottomwall = (bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && line->sidedef && !bothSkyFloor; + bool bottomwall = (bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && line->sidedef; if ((ceiling && !topwall) || (!ceiling && !bottomwall)) continue; } @@ -149,29 +153,13 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin { wallvert[0] = PlaneVertex(line->v1, frontsector, skyHeight); wallvert[1] = PlaneVertex(line->v2, frontsector, skyHeight); - if (!closedSky) - { - wallvert[2] = PlaneVertex(line->v2, frontsector, frontsector->ceilingplane.ZatPoint(line->v2)); - wallvert[3] = PlaneVertex(line->v1, frontsector, frontsector->ceilingplane.ZatPoint(line->v1)); - } - else - { - wallvert[2] = PlaneVertex(line->v2, frontsector, frontsector->floorplane.ZatPoint(line->v2)); - wallvert[3] = PlaneVertex(line->v1, frontsector, frontsector->floorplane.ZatPoint(line->v1)); - } + wallvert[2] = PlaneVertex(line->v2, frontsector, skyBottomz2); + wallvert[3] = PlaneVertex(line->v1, frontsector, skyBottomz1); } else { - if (!closedSky) - { - wallvert[0] = PlaneVertex(line->v1, frontsector, frontsector->floorplane.ZatPoint(line->v1)); - wallvert[1] = PlaneVertex(line->v2, frontsector, frontsector->floorplane.ZatPoint(line->v2)); - } - else - { - wallvert[0] = PlaneVertex(line->v1, frontsector, frontsector->ceilingplane.ZatPoint(line->v1)); - wallvert[1] = PlaneVertex(line->v2, frontsector, frontsector->ceilingplane.ZatPoint(line->v2)); - } + wallvert[0] = PlaneVertex(line->v1, frontsector, frontsector->floorplane.ZatPoint(line->v1)); + wallvert[1] = PlaneVertex(line->v2, frontsector, frontsector->floorplane.ZatPoint(line->v2)); wallvert[2] = PlaneVertex(line->v2, frontsector, skyHeight); wallvert[3] = PlaneVertex(line->v1, frontsector, skyHeight); } From a8ac6e4774d2b7c910b1db65e3d7431a1eb2a46e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Nov 2016 11:43:35 +0100 Subject: [PATCH 1216/1509] - converted dynamic light definitions. --- wadsrc/static/actors/shared/dynlights.txt | 102 ---------------------- wadsrc/static/zscript.txt | 1 + 2 files changed, 1 insertion(+), 102 deletions(-) delete mode 100644 wadsrc/static/actors/shared/dynlights.txt diff --git a/wadsrc/static/actors/shared/dynlights.txt b/wadsrc/static/actors/shared/dynlights.txt deleted file mode 100644 index 4a2940be1..000000000 --- a/wadsrc/static/actors/shared/dynlights.txt +++ /dev/null @@ -1,102 +0,0 @@ -ACTOR DynamicLight native -{ - Height 0 - Radius 0.1 - FloatBobPhase 0 - +NOBLOCKMAP - +NOGRAVITY - +FIXMAPTHINGPOS - +INVISIBLE -} - - -ACTOR PointLight : DynamicLight -{ - DynamicLight.Type "Point" -} - -ACTOR PointLightPulse : PointLight -{ - DynamicLight.Type "Pulse" -} - -ACTOR PointLightFlicker : PointLight -{ - DynamicLight.Type "Flicker" -} - -ACTOR SectorPointLight : PointLight -{ - DynamicLight.Type "Sector" -} - -ACTOR PointLightFlickerRandom : PointLight -{ - DynamicLight.Type "RandomFlicker" -} - -// MISSILEMORE and MISSILEEVENMORE are used by the lights for additive and subtractive lights - -ACTOR PointLightAdditive : PointLight -{ - +MISSILEMORE -} - -ACTOR PointLightPulseAdditive : PointLightPulse -{ - +MISSILEMORE -} - -ACTOR PointLightFlickerAdditive : PointLightFlicker -{ - +MISSILEMORE -} - -ACTOR SectorPointLightAdditive : SectorPointLight -{ - +MISSILEMORE -} - -ACTOR PointLightFlickerRandomAdditive :PointLightFlickerRandom -{ - +MISSILEMORE -} - -ACTOR PointLightSubtractive : PointLight -{ - +MISSILEEVENMORE -} - -ACTOR PointLightPulseSubtractive : PointLightPulse -{ - +MISSILEEVENMORE -} - -ACTOR PointLightFlickerSubtractive : PointLightFlicker -{ - +MISSILEEVENMORE -} - -ACTOR SectorPointLightSubtractive : SectorPointLight -{ - +MISSILEEVENMORE -} - -ACTOR PointLightFlickerRandomSubtractive : PointLightFlickerRandom -{ - +MISSILEEVENMORE -} - - -ACTOR VavoomLight : DynamicLight native -{ -} - -ACTOR VavoomLightWhite : VavoomLight native -{ -} - -ACTOR VavoomLightColor : VavoomLight native -{ -} - diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index 42f32a447..047bb1c80 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -31,6 +31,7 @@ zscript/shared/setcolor.txt zscript/shared/sectoraction.txt zscript/shared/ice.txt zscript/shared/dog.txt +zscript/shared/dynlights.txt zscript/doom/doomplayer.txt zscript/doom/possessed.txt From 3a2d0e348630058b5ed46146aa2781171ab3ccf5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Nov 2016 11:49:27 +0100 Subject: [PATCH 1217/1509] - copied all necessary adjustments from the test branch in the QZDoom repo. --- src/gl/dynlights/a_dynlight.cpp | 10 +++++----- src/gl/system/gl_framebuffer.cpp | 2 +- src/posix/sdl/sdlglvideo.cpp | 2 +- src/win32/win32gliface.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 0e52eedd8..5c85fce85 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -62,7 +62,7 @@ #include "p_local.h" #include "c_dispatch.h" #include "g_level.h" -#include "thingdef/thingdef.h" +#include "scripting/thingdef.h" #include "i_system.h" #include "templates.h" #include "doomdata.h" @@ -106,10 +106,10 @@ DEFINE_CLASS_PROPERTY(type, S, DynamicLight) // which is controlled by flags // //========================================================================== -IMPLEMENT_CLASS (ADynamicLight) -IMPLEMENT_CLASS (AVavoomLight) -IMPLEMENT_CLASS (AVavoomLightWhite) -IMPLEMENT_CLASS (AVavoomLightColor) +IMPLEMENT_CLASS (ADynamicLight, false, false, false, false) +IMPLEMENT_CLASS (AVavoomLight, false, false, false, false) +IMPLEMENT_CLASS (AVavoomLightWhite, false, false, false, false) +IMPLEMENT_CLASS (AVavoomLightColor, false, false, false, false) void AVavoomLight::BeginPlay () { diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 4904cc1f6..259cef5e0 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -53,7 +53,7 @@ #include "gl/renderer/gl_2ddrawer.h" #include "gl_debug.h" -IMPLEMENT_CLASS(OpenGLFrameBuffer) +IMPLEMENT_CLASS(OpenGLFrameBuffer, false, false, false, false) EXTERN_CVAR (Float, vid_brightness) EXTERN_CVAR (Float, vid_contrast) EXTERN_CVAR (Bool, vid_vsync) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index d8c00f236..cebd928ee 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -29,7 +29,7 @@ // TYPES ------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(SDLGLFB) +IMPLEMENT_ABSTRACT_CLASS(SDLGLFB, false, false, false, false) struct MiniModeInfo { diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 5d68d8427..6b9e413af 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -854,7 +854,7 @@ bool Win32GLVideo::SetFullscreen(const char *devicename, int w, int h, int bits, // //========================================================================== -IMPLEMENT_ABSTRACT_CLASS(Win32GLFrameBuffer) +IMPLEMENT_CLASS(Win32GLFrameBuffer, true, false, false, false) //========================================================================== // From f143b9b7b05168f15ec4c58faec8c6df936bb272 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 15 Nov 2016 12:31:57 +0100 Subject: [PATCH 1218/1509] Fix midtexture repeat and yoffset bug --- src/r_poly_wall.cpp | 54 +++++++++++++++++++++++++++++++++++---------- src/r_poly_wall.h | 12 ++-------- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index 815230052..77742a8f8 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -117,6 +117,16 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, secto return false; } +void RenderPolyWall::SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2) +{ + this->v1 = v1; + this->v2 = v2; + this->ceil1 = ceil1; + this->floor1 = floor1; + this->ceil2 = ceil2; + this->floor2 = floor2; +} + void RenderPolyWall::Render(const TriMatrix &worldToClip) { FTexture *tex = GetTexture(); @@ -157,6 +167,13 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) vertices[3].varying[0] = (float)texcoords.u1; vertices[3].varying[1] = (float)texcoords.v2; + // Masked walls clamp to the 0-1 range (no texture repeat) + if (Masked) + { + ClampHeight(vertices[0], vertices[3]); + ClampHeight(vertices[1], vertices[2]); + } + TriUniforms uniforms; uniforms.objectToClip = worldToClip; uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f); @@ -188,6 +205,26 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) } } +void RenderPolyWall::ClampHeight(TriVertex &v1, TriVertex &v2) +{ + float top = v1.z; + float bottom = v2.z; + float texv1 = v1.varying[1]; + float texv2 = v2.varying[1]; + float delta = (texv2 - texv1); + + float t1 = texv1 < 0.0f ? -texv1 / delta : 0.0f; + float t2 = texv2 > 1.0f ? (1.0f - texv1) / delta : 1.0f; + float inv_t1 = 1.0f - t1; + float inv_t2 = 1.0f - t2; + + v1.z = top * inv_t1 + bottom * t1; + v1.varying[1] = texv1 * inv_t1 + texv2 * t1; + + v2.z = top * inv_t2 + bottom * t2; + v2.varying[1] = texv1 * inv_t2 + texv2 * t2; +} + FTexture *RenderPolyWall::GetTexture() { FTexture *tex = TexMan(Line->sidedef->GetTexture(Texpart), true); @@ -296,21 +333,14 @@ void PolyWallTextureCoords::CalcVMidPart(FTexture *tex, const seg_t *line, doubl bool pegged = (line->linedef->flags & ML_DONTPEGBOTTOM) == 0; if (pegged) // top to bottom { - v1 = yoffset; - v2 = v1 + (topz - bottomz); - v1 *= vscale; - v2 *= vscale; + v1 = yoffset * vscale; + v2 = (yoffset + (topz - bottomz)) * vscale; } else // bottom to top { int texHeight = tex->GetHeight(); - v1 = yoffset; - v2 = v1 + (topz - bottomz); - v1 *= vscale; - v2 *= vscale; - v1 = texHeight - v1; - v2 = texHeight - v2; - std::swap(v1, v2); + v1 = texHeight - (-yoffset + (topz - bottomz)) * vscale; + v2 = texHeight + yoffset * vscale; } } @@ -326,7 +356,7 @@ void PolyWallTextureCoords::CalcVBottomPart(FTexture *tex, const seg_t *line, do } else { - v1 = yoffset + (unpeggedceil - topz); + v1 = -yoffset + (unpeggedceil - topz); v2 = v1 + (topz - bottomz); v1 *= vscale; v2 *= vscale; diff --git a/src/r_poly_wall.h b/src/r_poly_wall.h index c215bb611..2de1f1c09 100644 --- a/src/r_poly_wall.h +++ b/src/r_poly_wall.h @@ -31,18 +31,9 @@ class RenderPolyWall public: static bool RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, std::vector &translucentWallsOutput); + void SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2); void Render(const TriMatrix &worldToClip); - void SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2) - { - this->v1 = v1; - this->v2 = v2; - this->ceil1 = ceil1; - this->floor1 = floor1; - this->ceil2 = ceil2; - this->floor2 = floor2; - } - DVector2 v1; DVector2 v2; double ceil1 = 0.0; @@ -60,6 +51,7 @@ public: uint32_t SubsectorDepth = 0; private: + void ClampHeight(TriVertex &v1, TriVertex &v2); FTexture *GetTexture(); int GetLightLevel(); }; From 5f1b82252302958922f8deb60e65f5e4e592bd92 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 15 Nov 2016 13:30:30 +0100 Subject: [PATCH 1219/1509] Mark rendered lines in the automap --- src/r_poly.cpp | 11 +++++++++-- src/r_poly.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 42cc84e5f..c95083c1d 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -102,7 +102,7 @@ void RenderPolyScene::RenderSubsector(subsector_t *sub) { seg_t *line = &sub->firstline[i]; if (line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) - RenderLine(line, frontsector, subsectorDepth); + RenderLine(sub, line, frontsector, subsectorDepth); } SpriteRange sprites = GetSpritesForSector(sub->sector); @@ -136,7 +136,7 @@ SpriteRange RenderPolyScene::GetSpritesForSector(sector_t *sector) return range; } -void RenderPolyScene::RenderLine(seg_t *line, sector_t *frontsector, uint32_t subsectorDepth) +void RenderPolyScene::RenderLine(subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth) { // Reject lines not facing viewer DVector2 pt1 = line->v1->fPos() - ViewPos; @@ -150,6 +150,13 @@ void RenderPolyScene::RenderLine(seg_t *line, sector_t *frontsector, uint32_t su if (hasSegmentRange && Cull.IsSegmentCulled(sx1, sx2)) return; + // Tell automap we saw this + if (!r_dontmaplines && line->linedef) + { + line->linedef->flags |= ML_MAPPED; + sub->flags |= SSECF_DRAWN; + } + // Render wall, and update culling info if its an occlusion blocker if (RenderPolyWall::RenderLine(WorldToClip, line, frontsector, subsectorDepth, SubsectorTranslucentWalls)) { diff --git a/src/r_poly.h b/src/r_poly.h index b182a582d..35105e4f9 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -85,7 +85,7 @@ public: private: void RenderSubsector(subsector_t *sub); - void RenderLine(seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); + void RenderLine(subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); void RenderTranslucent(); SpriteRange GetSpritesForSector(sector_t *sector); From d3332b03dba5a35ccb6c314d06723915143d8adc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Nov 2016 13:37:56 +0100 Subject: [PATCH 1220/1509] - dynlights.txt. --- wadsrc/static/zscript/shared/dynlights.txt | 159 +++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 wadsrc/static/zscript/shared/dynlights.txt diff --git a/wadsrc/static/zscript/shared/dynlights.txt b/wadsrc/static/zscript/shared/dynlights.txt new file mode 100644 index 000000000..55698f079 --- /dev/null +++ b/wadsrc/static/zscript/shared/dynlights.txt @@ -0,0 +1,159 @@ +class DynamicLight : Actor native +{ + Default + { + Height 0; + Radius 0.1; + FloatBobPhase 0; + +NOBLOCKMAP + +NOGRAVITY + +FIXMAPTHINGPOS + +INVISIBLE + } +} + + +class PointLight : DynamicLight +{ + Default + { + DynamicLight.Type "Point"; + } +} + +class PointLightPulse : PointLight +{ + Default + { + DynamicLight.Type "Pulse"; + } +} + +class PointLightFlicker : PointLight +{ + Default + { + DynamicLight.Type "Flicker"; + } +} + +class SectorPointLight : PointLight +{ + Default + { + DynamicLight.Type "Sector"; + } +} + +class PointLightFlickerRandom : PointLight +{ + Default + { + DynamicLight.Type "RandomFlicker"; + } +} + +// MISSILEMORE and MISSILEEVENMORE are used by the lights for additive and subtractive lights + +class PointLightAdditive : PointLight +{ + Default + { + +MISSILEMORE + } +} + +class PointLightPulseAdditive : PointLightPulse +{ + Default + { + +MISSILEMORE + } +} + +class PointLightFlickerAdditive : PointLightFlicker +{ + Default + { + +MISSILEMORE + } +} + +class SectorPointLightAdditive : SectorPointLight +{ + Default + { + +MISSILEMORE + } +} + +class PointLightFlickerRandomAdditive :PointLightFlickerRandom +{ + Default + { + +MISSILEMORE + } +} + +class PointLightSubtractive : PointLight +{ + Default + { + +MISSILEEVENMORE + } +} + +class PointLightPulseSubtractive : PointLightPulse +{ + Default + { + +MISSILEEVENMORE + } +} + +class PointLightFlickerSubtractive : PointLightFlicker +{ + Default + { + +MISSILEEVENMORE + } +} + +class SectorPointLightSubtractive : SectorPointLight +{ + Default + { + +MISSILEEVENMORE + } +} + +class PointLightFlickerRandomSubtractive : PointLightFlickerRandom +{ + Default + { + +MISSILEEVENMORE + } +} + + +class VavoomLight : DynamicLight native +{ + Default + { + } +} + +class VavoomLightWhite : VavoomLight native +{ + Default + { + } +} + +class VavoomLightColor : VavoomLight native +{ + Default + { + } +} + From 3b397183ac20286156b46bc3e1a476e1c6a7339d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 15 Nov 2016 15:15:01 +0100 Subject: [PATCH 1221/1509] Clamp segment range --- src/r_poly_cull.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/r_poly_cull.cpp b/src/r_poly_cull.cpp index 3df07abf9..2b97d71bb 100644 --- a/src/r_poly_cull.cpp +++ b/src/r_poly_cull.cpp @@ -102,6 +102,9 @@ void PolyCull::ClearSolidSegments() bool PolyCull::IsSegmentCulled(int x1, int x2) const { + x1 = clamp(x1, -0x7ffe, 0x7ffd); + x2 = clamp(x2, -0x7ffd, 0x7ffe); + int next = 0; while (SolidSegments[next].X2 <= x2) next++; @@ -113,6 +116,9 @@ void PolyCull::MarkSegmentCulled(int x1, int x2) if (x1 >= x2) return; + x1 = clamp(x1, -0x7ffe, 0x7ffd); + x2 = clamp(x2, -0x7ffd, 0x7ffe); + int cur = 1; while (true) { From ee15856786cacbbced069476bb1f4c7306ee2dd1 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 15 Nov 2016 15:15:26 +0100 Subject: [PATCH 1222/1509] Deep water support --- src/r_poly.cpp | 2 +- src/r_poly_plane.cpp | 45 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index c95083c1d..17006b2d0 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -147,7 +147,7 @@ void RenderPolyScene::RenderLine(subsector_t *sub, seg_t *line, sector_t *fronts // Cull wall if not visible int sx1, sx2; bool hasSegmentRange = Cull.GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2); - if (hasSegmentRange && Cull.IsSegmentCulled(sx1, sx2)) + if (!hasSegmentRange || Cull.IsSegmentCulled(sx1, sx2)) return; // Tell automap we saw this diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 9ca82cf28..e6c6dbe28 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -31,9 +31,48 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, bool ceiling, double skyHeight) { - sector_t *frontsector = sub->sector; + sector_t *fakesector = sub->sector->heightsec; + if (fakesector && (fakesector == sub->sector || (fakesector->MoreFlags & SECF_IGNOREHEIGHTSEC) == SECF_IGNOREHEIGHTSEC)) + fakesector = nullptr; + + bool fakeflooronly = fakesector && (fakesector->MoreFlags & SECF_FAKEFLOORONLY) != SECF_FAKEFLOORONLY; + + FTextureID picnum; + bool ccw; + sector_t *frontsector; + if (ceiling && fakesector && ViewPos.Z < fakesector->floorplane.Zat0()) + { + picnum = fakesector->GetTexture(sector_t::ceiling); + ccw = false; + ceiling = false; + frontsector = fakesector; + } + else if (!ceiling && fakesector && ViewPos.Z >= fakesector->floorplane.Zat0()) + { + picnum = fakesector->GetTexture(sector_t::ceiling); + ccw = true; + frontsector = fakesector; + } + else if (ceiling && fakesector && ViewPos.Z > fakesector->ceilingplane.Zat0() && !fakeflooronly) + { + picnum = fakesector->GetTexture(sector_t::floor); + ccw = true; + frontsector = fakesector; + } + else if (!ceiling && fakesector && ViewPos.Z <= fakesector->ceilingplane.Zat0() && !fakeflooronly) + { + picnum = fakesector->GetTexture(sector_t::floor); + ccw = false; + ceiling = true; + frontsector = fakesector; + } + else + { + picnum = sub->sector->GetTexture(ceiling ? sector_t::ceiling : sector_t::floor); + ccw = true; + frontsector = sub->sector; + } - FTextureID picnum = frontsector->GetTexture(ceiling ? sector_t::ceiling : sector_t::floor); FTexture *tex = TexMan(picnum); if (tex->UseType == FTexture::TEX_Null) return; @@ -76,7 +115,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin args.vinput = vertices; args.vcount = sub->numlines; args.mode = TriangleDrawMode::Fan; - args.ccw = true; + args.ccw = ccw; args.clipleft = 0; args.cliptop = 0; args.clipright = viewwidth; From cfc977f9e6557952915bee88eec2b8c573fbf406 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 15 Nov 2016 18:14:18 +0100 Subject: [PATCH 1223/1509] Fix texture coordinate --- src/r_poly_wall.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index 77742a8f8..aeb6985da 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -356,7 +356,7 @@ void PolyWallTextureCoords::CalcVBottomPart(FTexture *tex, const seg_t *line, do } else { - v1 = -yoffset + (unpeggedceil - topz); + v1 = yoffset + (unpeggedceil - topz); v2 = v1 + (topz - bottomz); v1 *= vscale; v2 *= vscale; From a90a22e056afad1ce34bcbcee433d104cac8162a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 15 Nov 2016 19:27:21 +0100 Subject: [PATCH 1224/1509] Fix segment culling bug --- src/r_poly_cull.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_poly_cull.cpp b/src/r_poly_cull.cpp index 2b97d71bb..89c59aa79 100644 --- a/src/r_poly_cull.cpp +++ b/src/r_poly_cull.cpp @@ -119,18 +119,18 @@ void PolyCull::MarkSegmentCulled(int x1, int x2) x1 = clamp(x1, -0x7ffe, 0x7ffd); x2 = clamp(x2, -0x7ffd, 0x7ffe); - int cur = 1; + int cur = 0; while (true) { if (SolidSegments[cur].X1 <= x1 && SolidSegments[cur].X2 >= x2) // Already fully marked { break; } - else if (cur + 1 != SolidSegments.size() && SolidSegments[cur].X2 >= x1 && SolidSegments[cur].X1 <= x2) // Merge segments + else if (SolidSegments[cur].X2 >= x1 && SolidSegments[cur].X1 <= x2) // Merge segments { // Find last segment int merge = cur; - while (merge + 2 != SolidSegments.size() && SolidSegments[merge + 1].X1 <= x2) + while (merge + 1 != SolidSegments.size() && SolidSegments[merge + 1].X1 <= x2) merge++; // Apply new merged range From 1b3d50951a471f2ce413f750d92811dbf7b9c4e2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 15 Nov 2016 22:48:44 +0100 Subject: [PATCH 1225/1509] Fix sky floodfill bug --- src/r_poly_plane.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index e6c6dbe28..3052ebfbc 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -164,8 +164,6 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin double topfloorz2 = MIN(backceilz2, frontceilz2); double bottomceilz1 = MAX(frontfloorz1, backfloorz1); double bottomceilz2 = MAX(frontfloorz2, backfloorz2); - double bottomfloorz1 = frontfloorz1; - double bottomfloorz2 = frontfloorz2; double middleceilz1 = topfloorz1; double middleceilz2 = topfloorz2; double middlefloorz1 = MIN(bottomceilz1, middleceilz1); @@ -179,12 +177,9 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin skyBottomz1 = middlefloorz1; skyBottomz2 = middlefloorz2; } - else + else if (bothSkyCeiling) { - bool topwall = (topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && line->sidedef && !bothSkyCeiling; - bool bottomwall = (bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && line->sidedef; - if ((ceiling && !topwall) || (!ceiling && !bottomwall)) - continue; + continue; } } From a092a03c6dce483c67900310effdd622b8f19e80 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 15 Nov 2016 23:30:42 +0100 Subject: [PATCH 1226/1509] Some basic fixed light support --- .../fixedfunction/drawtrianglecodegen.cpp | 6 ++++-- src/r_compiler/fixedfunction/drawtrianglecodegen.h | 3 ++- src/r_compiler/llvmdrawers.h | 2 +- src/r_poly_plane.cpp | 4 +--- src/r_poly_sprite.cpp | 14 ++++++++++++-- src/r_poly_wall.cpp | 2 +- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index 77076b072..11bdad7e4 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -254,7 +254,8 @@ void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) SSAFloat vis = globVis / rcpWTL; SSAFloat shade = 64.0f - (SSAFloat(light * 255 / 256) + 12.0f) * 32.0f / 128.0f; SSAFloat lightscale = SSAFloat::clamp((shade - SSAFloat::MIN(SSAFloat(24.0f), vis)) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)); - diminishedlight = SSAInt(SSAFloat::clamp((1.0f - lightscale) * 256.0f + 0.5f, SSAFloat(0.0f), SSAFloat(256.0f)), false); + SSAInt diminishedlight = SSAInt(SSAFloat::clamp((1.0f - lightscale) * 256.0f + 0.5f, SSAFloat(0.0f), SSAFloat(256.0f)), false); + currentlight = is_fixed_light.select(light, diminishedlight); SetStencilBlock(x / 8 + y / 8 * stencilPitch); @@ -473,7 +474,7 @@ void DrawTriangleCodegen::ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbu { SSAVec4i fg = texturePixels[uvoffset * 4].load_vec4ub(true); SSAInt fg_alpha = fg[3]; - fg = (fg * diminishedlight) >> 8; + fg = (fg * currentlight) >> 8; fg.insert(3, fg_alpha); if (variant == TriDrawVariant::DrawMasked || variant == TriDrawVariant::DrawSubsector) @@ -625,4 +626,5 @@ void DrawTriangleCodegen::LoadUniforms(SSAValue uniforms) is_simple_shade = (flags & TriUniforms::simple_shade) == SSAInt(TriUniforms::simple_shade); is_nearest_filter = (flags & TriUniforms::nearest_filter) == SSAInt(TriUniforms::nearest_filter); + is_fixed_light = (flags & TriUniforms::fixed_light) == SSAInt(TriUniforms::fixed_light); } diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.h b/src/r_compiler/fixedfunction/drawtrianglecodegen.h index c9fb61e67..8452b250f 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.h +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.h @@ -89,6 +89,7 @@ private: SSAShadeConstants shade_constants; SSABool is_simple_shade; SSABool is_nearest_filter; + SSABool is_fixed_light; SSAUBytePtr stencilValues; SSAIntPtr stencilMasks; @@ -115,7 +116,7 @@ private: SSAInt x, y; SSAInt x0, x1, y0, y1; - SSAInt diminishedlight; + SSAInt currentlight; SSAInt varyingPos[TriVertex::NumVarying]; SSAInt varyingStepPos[TriVertex::NumVarying]; SSAInt varyingStartStepX[TriVertex::NumVarying]; diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index b68c23fe1..38f0f82d1 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -230,7 +230,7 @@ struct TriUniforms { simple_shade = 1, nearest_filter = 2, - diminishing_lighting = 4 + fixed_light = 4 }; TriMatrix objectToClip; diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 3052ebfbc..4ca6f4990 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -82,9 +82,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin TriUniforms uniforms; uniforms.objectToClip = worldToClip; uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f); - if (fixedlightlev >= 0) - uniforms.light = (uint32_t)(fixedlightlev / 255.0f * 256.0f); - else if (fixedcolormap) + if (fixedlightlev >= 0 || fixedcolormap) uniforms.light = 256; uniforms.flags = 0; uniforms.subsectorDepth = isSky ? RenderPolyScene::SkySubsectorDepth : subsectorDepth; diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index b3a57ec47..1701b24ef 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -111,10 +111,20 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse vertices[i].varying[0] = 1.0f - vertices[i].varying[0]; } + bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT)); + TriUniforms uniforms; uniforms.objectToClip = worldToClip; - uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f); - uniforms.flags = 0; + if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) + { + uniforms.light = 256; + uniforms.flags = TriUniforms::fixed_light; + } + else + { + uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f); + uniforms.flags = 0; + } uniforms.subsectorDepth = subsectorDepth; PolyDrawArgs args; diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index aeb6985da..cd932214d 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -244,7 +244,7 @@ int RenderPolyWall::GetLightLevel() { bool foggy = false; int actualextralight = foggy ? 0 : extralight << 4; - return Line->sidedef->GetLightLevel(foggy, Line->frontsector->lightlevel) + actualextralight; + return clamp(Line->sidedef->GetLightLevel(foggy, Line->frontsector->lightlevel) + actualextralight, 0, 255); } } From 449d4963ae23c20f3dc31fa1b6543a28e09e4946 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 16 Nov 2016 01:13:29 +0100 Subject: [PATCH 1227/1509] Mapping error workaround --- src/r_poly_wall.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index cd932214d..6921b1a33 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -229,9 +229,29 @@ FTexture *RenderPolyWall::GetTexture() { FTexture *tex = TexMan(Line->sidedef->GetTexture(Texpart), true); if (tex == nullptr || tex->UseType == FTexture::TEX_Null) - return nullptr; - else - return tex; + { + // Mapping error. Doom floodfills this with a plane. + // This code doesn't do that, but at least it uses the "right" texture.. + + if (Line->linedef && Line->backsector && Line->linedef->sidedef[0] == Line->sidedef) + { + if (Texpart == side_t::top) + tex = TexMan(Line->linedef->backsector->GetTexture(sector_t::ceiling), true); + else if (Texpart == side_t::bottom) + tex = TexMan(Line->linedef->backsector->GetTexture(sector_t::floor), true); + } + if (Line->linedef && Line->backsector && Line->linedef->sidedef[1] == Line->sidedef) + { + if (Texpart == side_t::top) + tex = TexMan(Line->linedef->frontsector->GetTexture(sector_t::ceiling), true); + else if (Texpart == side_t::bottom) + tex = TexMan(Line->linedef->frontsector->GetTexture(sector_t::floor), true); + } + + if (tex == nullptr || tex->UseType == FTexture::TEX_Null) + return nullptr; + } + return tex; } int RenderPolyWall::GetLightLevel() From 9b9ed64360a22273d49faa1d8decaf598a4b469a Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 15 Nov 2016 19:37:30 -0500 Subject: [PATCH 1228/1509] - Implemented sv_overridegetcvar: This will override the return value for GetCVar checks for certain CVars marked with the CVAR_OVERRIDEGET flag. Instead of returning their true value, they only return defaults instead. - Implemented dummy CVar vid_renderer with a default value of 1. This allows mods not designed for the software renderer to run if sv_overridegetcvar is turned on. --- src/c_cvars.cpp | 7 +++++++ src/c_cvars.h | 1 + src/p_acs.cpp | 20 ++++++++++++++++++++ src/p_actionfunctions.cpp | 6 ++++++ 4 files changed, 34 insertions(+) diff --git a/src/c_cvars.cpp b/src/c_cvars.cpp index c8f1ee4c6..1af07e176 100644 --- a/src/c_cvars.cpp +++ b/src/c_cvars.cpp @@ -52,6 +52,13 @@ #include "v_video.h" #include "colormatcher.h" +// [SP] This is a dummy CVAR that needs to be removed in child ports that implement the real version. +CVAR(Int, vid_renderer, 1, CVAR_GLOBALCONFIG | CVAR_OVERRIDEGET | CVAR_ARCHIVE) + +// [SP] Lets the player (arbitrator) choose whether to override GetCVar checks. +// Danger of desync? Can we just make it a client var? This probably *fixes* desyncs, actually... +CVAR(Bool, sv_overridegetcvar, true, CVAR_SERVERINFO | CVAR_GLOBALCONFIG | CVAR_ARCHIVE) + struct FLatchedValue { FBaseCVar *Variable; diff --git a/src/c_cvars.h b/src/c_cvars.h index be7676e89..d74d3b5c9 100644 --- a/src/c_cvars.h +++ b/src/c_cvars.h @@ -63,6 +63,7 @@ enum CVAR_NOSAVE = 4096, // when used with CVAR_SERVERINFO, do not save var to savegame CVAR_MOD = 8192, // cvar was defined by a mod CVAR_IGNORE = 16384,// do not send cvar across the network/inaccesible from ACS (dummy mod cvar) + CVAR_OVERRIDEGET = 32768,// this cvar disguises its return value for GetCVAR }; union UCVarValue diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 1a60a0c4f..1d309307d 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -4549,6 +4549,8 @@ static void DoSetCVar(FBaseCVar *cvar, int value, bool is_string, bool force=fal } } +EXTERN_CVAR(Bool, sv_overridegetcvar) + // Converts floating- to fixed-point as required. static int DoGetCVar(FBaseCVar *cvar, bool is_string) { @@ -4558,6 +4560,24 @@ static int DoGetCVar(FBaseCVar *cvar, bool is_string) { return 0; } + else if (sv_overridegetcvar && (cvar->GetFlags() & CVAR_OVERRIDEGET)) + { + if (is_string) + { + val = cvar->GetGenericRepDefault(CVAR_String); + return GlobalACSStrings.AddString(val.String); + } + else if (cvar->GetRealType() == CVAR_Float) + { + val = cvar->GetGenericRepDefault(CVAR_Float); + return DoubleToACS(val.Float); + } + else + { + val = cvar->GetGenericRepDefault(CVAR_Int); + return val.Int; + } + } else if (is_string) { val = cvar->GetGenericRep(CVAR_String); diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 73cade49a..df5852473 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -621,6 +621,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetCrouchFactor) // //========================================================================== +EXTERN_CVAR(Bool, sv_overridegetcvar) + DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetCVar) { if (numret > 0) @@ -634,6 +636,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetCVar) { ret->SetFloat(0); } + else if (sv_overridegetcvar && (cvar->GetFlags() & CVAR_OVERRIDEGET)) + { + ret->SetFloat(cvar->GetGenericRepDefault(CVAR_Float).Float); + } else { ret->SetFloat(cvar->GetGenericRep(CVAR_Float).Float); From 813030efef234305b53b4032fa6d6dd8326dd7a1 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 15 Nov 2016 19:52:40 -0500 Subject: [PATCH 1229/1509] - Fully implemented CVAR_OVERRIDEGET for vid_renderer from the ZDoom code submission. --- src/c_cvars.cpp | 3 --- src/posix/cocoa/i_video.mm | 2 +- src/posix/sdl/hardware.cpp | 2 +- src/win32/hardware.cpp | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/c_cvars.cpp b/src/c_cvars.cpp index 1af07e176..18648db28 100644 --- a/src/c_cvars.cpp +++ b/src/c_cvars.cpp @@ -52,9 +52,6 @@ #include "v_video.h" #include "colormatcher.h" -// [SP] This is a dummy CVAR that needs to be removed in child ports that implement the real version. -CVAR(Int, vid_renderer, 1, CVAR_GLOBALCONFIG | CVAR_OVERRIDEGET | CVAR_ARCHIVE) - // [SP] Lets the player (arbitrator) choose whether to override GetCVar checks. // Danger of desync? Can we just make it a client var? This probably *fixes* desyncs, actually... CVAR(Bool, sv_overridegetcvar, true, CVAR_SERVERINFO | CVAR_GLOBALCONFIG | CVAR_ARCHIVE) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 08a563b25..edd7de570 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -123,7 +123,7 @@ CUSTOM_CVAR(Bool, vid_autoswitch, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ static int s_currentRenderer; -CUSTOM_CVAR(Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR(Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL | CVAR_OVERRIDEGET) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index f4ac13fc5..5dcf62367 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -64,7 +64,7 @@ void I_RestartRenderer(); int currentrenderer; // [ZDoomGL] -CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL | CVAR_OVERRIDEGET) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 787c0a4f3..e0338c0dd 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -71,7 +71,7 @@ int currentrenderer = -1; bool changerenderer; // [ZDoomGL] -CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL | CVAR_OVERRIDEGET) { // 0: Software renderer // 1: OpenGL renderer From f457f0340c7e9c667c5bdf461e29aaa65c1ebd75 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 16 Nov 2016 11:18:40 +0100 Subject: [PATCH 1230/1509] Add 3D floor planes --- src/r_poly.cpp | 44 ++++++++------ src/r_poly.h | 3 + src/r_poly_plane.cpp | 141 +++++++++++++++++++++++++++++++++++++++---- src/r_poly_plane.h | 6 +- 4 files changed, 162 insertions(+), 32 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 17006b2d0..179df248a 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -36,7 +36,24 @@ void RenderPolyScene::Render() if (!r_swtruecolor) // Disable pal rendering for now return; - // Setup working buffers + ClearBuffers(); + SetupPerspectiveMatrix(); + Cull.CullScene(WorldToClip); + RenderSectors(); + skydome.Render(WorldToClip); + RenderTranslucent(); + PlayerSprites.Render(); + + DrawerCommandQueue::WaitForWorkers(); +} + +void RenderPolyScene::RenderRemainingPlayerSprites() +{ + PlayerSprites.RenderRemainingSprites(); +} + +void RenderPolyScene::ClearBuffers() +{ PolyVertexBuffer::Clear(); SectorSpriteRanges.clear(); SectorSpriteRanges.resize(numsectors); @@ -45,8 +62,10 @@ void RenderPolyScene::Render() PolyStencilBuffer::Instance()->Clear(viewwidth, viewheight, 0); PolySubsectorGBuffer::Instance()->Resize(dc_pitch, viewheight); NextSubsectorDepth = 0; +} - // Setup perspective matrix: +void RenderPolyScene::SetupPerspectiveMatrix() +{ float ratio = WidescreenRatio; float fovratio = (WidescreenRatio >= 1.3f) ? 1.333333f : ratio; float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(FieldOfView.Radians() / 2) / fovratio)).Degrees); @@ -57,8 +76,10 @@ void RenderPolyScene::Render() TriMatrix::swapYZ() * TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); WorldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; +} - Cull.CullScene(WorldToClip); +void RenderPolyScene::RenderSectors() +{ if (r_debug_cull) { for (auto it = Cull.PvsSectors.rbegin(); it != Cull.PvsSectors.rend(); ++it) @@ -69,19 +90,6 @@ void RenderPolyScene::Render() for (auto it = Cull.PvsSectors.begin(); it != Cull.PvsSectors.end(); ++it) RenderSubsector(*it); } - - skydome.Render(WorldToClip); - - RenderTranslucent(); - - PlayerSprites.Render(); - DrawerCommandQueue::WaitForWorkers(); - RenderRemainingPlayerSprites(); // To do: should be called by FSoftwareRenderer::DrawRemainingPlayerSprites instead of here -} - -void RenderPolyScene::RenderRemainingPlayerSprites() -{ - PlayerSprites.RenderRemainingSprites(); } void RenderPolyScene::RenderSubsector(subsector_t *sub) @@ -93,9 +101,7 @@ void RenderPolyScene::RenderSubsector(subsector_t *sub) if (sub->sector->CenterFloor() != sub->sector->CenterCeiling()) { - RenderPolyPlane plane; - plane.Render(WorldToClip, sub, subsectorDepth, true, Cull.MaxCeilingHeight); - plane.Render(WorldToClip, sub, subsectorDepth, false, Cull.MinFloorHeight); + RenderPolyPlane::RenderPlanes(WorldToClip, sub, subsectorDepth, Cull.MaxCeilingHeight, Cull.MinFloorHeight); } for (uint32_t i = 0; i < sub->numlines; i++) diff --git a/src/r_poly.h b/src/r_poly.h index 35105e4f9..4f7eca61d 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -84,6 +84,9 @@ public: static RenderPolyScene *Instance(); private: + void ClearBuffers(); + void SetupPerspectiveMatrix(); + void RenderSectors(); void RenderSubsector(subsector_t *sub); void RenderLine(subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 4ca6f4990..5b0e912a8 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -29,6 +29,125 @@ #include "r_poly.h" #include "r_sky.h" // for skyflatnum +EXTERN_CVAR(Int, r_3dfloors) + +void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, double skyCeilingHeight, double skyFloorHeight) +{ + RenderPolyPlane plane; + + if (r_3dfloors) + { + auto frontsector = sub->sector; + auto &ffloors = frontsector->e->XFloor.ffloors; + + // 3D floor floors + for (int i = 0; i < (int)ffloors.Size(); i++) + { + F3DFloor *fakeFloor = ffloors[i]; + if (!(fakeFloor->flags & FF_EXISTS)) continue; + if (!fakeFloor->model) continue; + if (fakeFloor->bottom.plane->isSlope()) continue; + //if (!(fakeFloor->flags & FF_NOSHADE) || (fakeFloor->flags & (FF_RENDERPLANES | FF_RENDERSIDES))) + // R_3D_AddHeight(fakeFloor->top.plane, frontsector); + if (!(fakeFloor->flags & FF_RENDERPLANES)) continue; + if (fakeFloor->alpha == 0) continue; + if (fakeFloor->flags & FF_THISINSIDE && fakeFloor->flags & FF_INVERTSECTOR) continue; + //fakeFloor->alpha + + double fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->centerspot); + if (fakeHeight < ViewPos.Z && fakeHeight > frontsector->floorplane.ZatPoint(frontsector->centerspot)) + { + plane.Render3DFloor(worldToClip, sub, subsectorDepth, false, fakeFloor); + } + } + + // 3D floor ceilings + for (int i = 0; i < (int)ffloors.Size(); i++) + { + F3DFloor *fakeFloor = ffloors[i]; + if (!(fakeFloor->flags & FF_EXISTS)) continue; + if (!fakeFloor->model) continue; + if (fakeFloor->top.plane->isSlope()) continue; + //if (!(fakeFloor->flags & FF_NOSHADE) || (fakeFloor->flags & (FF_RENDERPLANES | FF_RENDERSIDES))) + // R_3D_AddHeight(fakeFloor->bottom.plane, frontsector); + if (!(fakeFloor->flags & FF_RENDERPLANES)) continue; + if (fakeFloor->alpha == 0) continue; + if (!(fakeFloor->flags & FF_THISINSIDE) && (fakeFloor->flags & (FF_SWIMMABLE | FF_INVERTSECTOR)) == (FF_SWIMMABLE | FF_INVERTSECTOR)) continue; + //fakeFloor->alpha + + double fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot); + if (fakeHeight > ViewPos.Z && fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->centerspot)) + { + plane.Render3DFloor(worldToClip, sub, subsectorDepth, true, fakeFloor); + } + } + } + + plane.Render(worldToClip, sub, subsectorDepth, true, skyCeilingHeight); + plane.Render(worldToClip, sub, subsectorDepth, false, skyFloorHeight); +} + +void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, bool ceiling, F3DFloor *fakeFloor) +{ + FTextureID picnum = ceiling ? *fakeFloor->bottom.texture : *fakeFloor->top.texture; + FTexture *tex = TexMan(picnum); + if (tex->UseType == FTexture::TEX_Null) + return; + + int lightlevel = 255; + if (fixedlightlev < 0 && sub->sector->e->XFloor.lightlist.Size()) + { + lightlist_t *light = P_GetPlaneLight(sub->sector, &sub->sector->ceilingplane, false); + basecolormap = light->extra_colormap; + lightlevel = *light->p_lightlevel; + } + + TriUniforms uniforms; + uniforms.objectToClip = worldToClip; + uniforms.light = (uint32_t)(lightlevel / 255.0f * 256.0f); + if (fixedlightlev >= 0 || fixedcolormap) + uniforms.light = 256; + uniforms.flags = 0; + uniforms.subsectorDepth = subsectorDepth; + + TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); + if (!vertices) + return; + + if (ceiling) + { + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + vertices[sub->numlines - 1 - i] = PlaneVertex(line->v1, fakeFloor->bottom.plane->ZatPoint(line->v1)); + } + } + else + { + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + vertices[i] = PlaneVertex(line->v1, fakeFloor->top.plane->ZatPoint(line->v1)); + } + } + + PolyDrawArgs args; + args.uniforms = uniforms; + args.vinput = vertices; + args.vcount = sub->numlines; + args.mode = TriangleDrawMode::Fan; + args.ccw = true; + args.clipleft = 0; + args.cliptop = 0; + args.clipright = viewwidth; + args.clipbottom = viewheight; + args.stenciltestvalue = 0; + args.stencilwritevalue = 1; + args.SetTexture(tex); + PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); +} + void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, bool ceiling, double skyHeight) { sector_t *fakesector = sub->sector->heightsec; @@ -96,7 +215,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin for (uint32_t i = 0; i < sub->numlines; i++) { seg_t *line = &sub->firstline[i]; - vertices[sub->numlines - 1 - i] = PlaneVertex(line->v1, frontsector, isSky ? skyHeight : frontsector->ceilingplane.ZatPoint(line->v1)); + vertices[sub->numlines - 1 - i] = PlaneVertex(line->v1, isSky ? skyHeight : frontsector->ceilingplane.ZatPoint(line->v1)); } } else @@ -104,7 +223,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin for (uint32_t i = 0; i < sub->numlines; i++) { seg_t *line = &sub->firstline[i]; - vertices[i] = PlaneVertex(line->v1, frontsector, isSky ? skyHeight : frontsector->floorplane.ZatPoint(line->v1)); + vertices[i] = PlaneVertex(line->v1, isSky ? skyHeight : frontsector->floorplane.ZatPoint(line->v1)); } } @@ -183,17 +302,17 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin if (ceiling) { - wallvert[0] = PlaneVertex(line->v1, frontsector, skyHeight); - wallvert[1] = PlaneVertex(line->v2, frontsector, skyHeight); - wallvert[2] = PlaneVertex(line->v2, frontsector, skyBottomz2); - wallvert[3] = PlaneVertex(line->v1, frontsector, skyBottomz1); + wallvert[0] = PlaneVertex(line->v1, skyHeight); + wallvert[1] = PlaneVertex(line->v2, skyHeight); + wallvert[2] = PlaneVertex(line->v2, skyBottomz2); + wallvert[3] = PlaneVertex(line->v1, skyBottomz1); } else { - wallvert[0] = PlaneVertex(line->v1, frontsector, frontsector->floorplane.ZatPoint(line->v1)); - wallvert[1] = PlaneVertex(line->v2, frontsector, frontsector->floorplane.ZatPoint(line->v2)); - wallvert[2] = PlaneVertex(line->v2, frontsector, skyHeight); - wallvert[3] = PlaneVertex(line->v1, frontsector, skyHeight); + wallvert[0] = PlaneVertex(line->v1, frontsector->floorplane.ZatPoint(line->v1)); + wallvert[1] = PlaneVertex(line->v2, frontsector->floorplane.ZatPoint(line->v2)); + wallvert[2] = PlaneVertex(line->v2, skyHeight); + wallvert[3] = PlaneVertex(line->v1, skyHeight); } args.vinput = wallvert; @@ -203,7 +322,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin } } -TriVertex RenderPolyPlane::PlaneVertex(vertex_t *v1, sector_t *sector, double height) +TriVertex RenderPolyPlane::PlaneVertex(vertex_t *v1, double height) { TriVertex v; v.x = (float)v1->fPos().X; diff --git a/src/r_poly_plane.h b/src/r_poly_plane.h index b4f2087e8..fa786ead9 100644 --- a/src/r_poly_plane.h +++ b/src/r_poly_plane.h @@ -27,8 +27,10 @@ class RenderPolyPlane { public: - void Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, bool ceiling, double skyHeight); + static void RenderPlanes(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, double skyCeilingHeight, double skyFloorHeight); private: - TriVertex PlaneVertex(vertex_t *v1, sector_t *sector, double height); + void Render3DFloor(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, bool ceiling, F3DFloor *fakefloor); + void Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, bool ceiling, double skyHeight); + TriVertex PlaneVertex(vertex_t *v1, double height); }; From 712e03257369a9f884a20d3b34839e88da7fd17f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 16 Nov 2016 19:44:11 +0100 Subject: [PATCH 1231/1509] Remove swrenderer2 --- src/CMakeLists.txt | 1 - src/r_swrenderer2.cpp | 1892 ----------------------------------------- src/r_swrenderer2.h | 366 -------- 3 files changed, 2259 deletions(-) delete mode 100644 src/r_swrenderer2.cpp delete mode 100644 src/r_swrenderer2.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7933f80a7..baef29c21 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1068,7 +1068,6 @@ set( NOT_COMPILED_SOURCE_FILES set( FASTMATH_PCH_SOURCES r_swrenderer.cpp - r_swrenderer2.cpp r_poly.cpp r_poly_cull.cpp r_poly_particle.cpp diff --git a/src/r_swrenderer2.cpp b/src/r_swrenderer2.cpp deleted file mode 100644 index 8fcf90ac9..000000000 --- a/src/r_swrenderer2.cpp +++ /dev/null @@ -1,1892 +0,0 @@ -/* -** Experimental Doom software renderer -** Copyright (c) 2016 Magnus Norddahl -** -** This software is provided 'as-is', without any express or implied -** warranty. In no event will the authors be held liable for any damages -** arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, -** including commercial applications, and to alter it and redistribute it -** freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not -** claim that you wrote the original software. If you use this software -** in a product, an acknowledgment in the product documentation would be -** appreciated but is not required. -** 2. Altered source versions must be plainly marked as such, and must not be -** misrepresented as being the original software. -** 3. This notice may not be removed or altered from any source distribution. -** -*/ - -#include -#include "templates.h" -#include "doomdef.h" -#include "sbar.h" -#include "r_data/r_translate.h" -#include "r_swrenderer2.h" -#include "r_draw.h" -#include "r_plane.h" // for yslope -#include "r_sky.h" // for skyflatnum -#include "r_things.h" // for pspritexscale - -EXTERN_CVAR(Bool, r_drawplayersprites) -EXTERN_CVAR(Bool, r_deathcamera) -EXTERN_CVAR(Bool, st_scale) - -DVector3 ViewPosTransform::WorldToEye(const DVector3 &worldPoint) const -{ - double tr_x = worldPoint.X - ViewPos.X; - double tr_y = worldPoint.Y - ViewPos.Y; - double tr_z = worldPoint.Z - ViewPos.Z; - double tx = tr_x * ViewSin - tr_y * ViewCos; - double tz = tr_x * ViewTanCos + tr_y * ViewTanSin; - return DVector3(tx, tr_z, tz); -} - -DVector3 ViewPosTransform::EyeToViewport(const DVector3 &eyePoint) const -{ - double rcp_z = 1.0 / eyePoint.Z; - return DVector3(eyePoint.X * rcp_z, eyePoint.Y * rcp_z, rcp_z); -} - -DVector3 ViewPosTransform::ViewportToScreen(const DVector3 &viewportPoint) const -{ - return DVector3(CenterX + viewportPoint.X * CenterX, CenterY - viewportPoint.Y * InvZtoScale, viewportPoint.Z); -} - -double ViewPosTransform::ScreenXToEye(int x, double z) const -{ - return (x + 0.5 - CenterX) / CenterX * z; -} - -double ViewPosTransform::ScreenYToEye(int y, double z) const -{ - return -(y + 0.5 - CenterY) / InvZtoScale * z; -} - -///////////////////////////////////////////////////////////////////////////// - -WallCoords::WallCoords(const ViewPosTransform &transform, const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2) : Transform(transform) -{ - // Transform wall to eye space - DVector3 top1 = transform.WorldToEye(DVector3(v1, ceil1)); - DVector3 top2 = transform.WorldToEye(DVector3(v2, ceil2)); - DVector3 bottom1 = transform.WorldToEye(DVector3(v1, floor1)); - DVector3 bottom2 = transform.WorldToEye(DVector3(v2, floor2)); - - double clipNearZ = transform.NearZ(); - - // Is entire wall behind znear clipping plane? If so, wall is culled - if ((top1.Z < clipNearZ && top2.Z < clipNearZ)) - return; - - PlaneNormal = (top2 - top1) ^ (top1 - bottom1); - PlaneD = -(PlaneNormal | top1); - - // Clip wall to znear clipping plane - if (top1.Z < clipNearZ) - { - double t = (clipNearZ - top1.Z) / (top2.Z - top1.Z); - top1 = Mix(top1, top2, t); - bottom1 = Mix(bottom1, bottom2, t); - - VaryingXScale = 1.0 - t; - VaryingXOffset = t; - } - else if (top2.Z < clipNearZ) - { - double t = (clipNearZ - top1.Z) / (top2.Z - top1.Z); - top2 = Mix(top1, top2, t); - bottom2 = Mix(bottom1, bottom2, t); - VaryingXScale = t; - VaryingXOffset = 0.0; - } - - NearZ = MIN(top1.Z, top2.Z); - FarZ = MAX(top1.Z, top2.Z); - - // Transform to screen coordinates - ScreenTopLeft = transform.EyeToScreen(top1); - ScreenTopRight = transform.EyeToScreen(top2); - ScreenBottomLeft = transform.EyeToScreen(bottom1); - ScreenBottomRight = transform.EyeToScreen(bottom2); - if (ScreenTopLeft.X > ScreenTopRight.X) - { - std::swap(ScreenTopLeft, ScreenTopRight); - std::swap(ScreenBottomLeft, ScreenBottomRight); - } - - ScreenX1 = xs_RoundToInt(MAX(ScreenTopLeft.X, 0.0)); - ScreenX2 = xs_RoundToInt(MIN(ScreenTopRight.X, (double)viewwidth)); - ScreenY1 = xs_RoundToInt(MAX(MIN(ScreenTopLeft.Y, ScreenTopRight.Y), 0.0)); - ScreenY2 = xs_RoundToInt(MIN(MAX(ScreenBottomLeft.Y, ScreenBottomRight.Y), (double)viewheight)); - - // Cull if nothing of the wall is visible - if (ScreenX2 <= ScreenX1 || ScreenY2 <= ScreenY1) - return; - - RcpDeltaScreenX = 1.0 / (ScreenTopRight.X - ScreenTopLeft.X); - Culled = false; -} - -DVector3 WallCoords::Mix(const DVector3 &a, const DVector3 &b, double t) -{ - double invt = 1.0 - t; - return DVector3(a.X * invt + b.X * t, a.Y * invt + b.Y * t, a.Z * invt + b.Z * t); -} - -double WallCoords::Mix(double a, double b, double t) -{ - return a * (1.0 - t) + b * t; -} - -short WallCoords::Y1(int x) const -{ - double t = (x + 0.5 - ScreenTopLeft.X) * RcpDeltaScreenX; - return (short)MAX(xs_RoundToInt(Mix(ScreenTopLeft.Y, ScreenTopRight.Y, t)), 0); -} - -short WallCoords::Y2(int x) const -{ - double t = (x + 0.5 - ScreenBottomLeft.X) * RcpDeltaScreenX; - return (short)MIN(xs_RoundToInt(Mix(ScreenBottomLeft.Y, ScreenBottomRight.Y, t)), viewheight); -} - -double WallCoords::Z(int x) const -{ - double t = (x + 0.5 - ScreenTopLeft.X) * RcpDeltaScreenX; - double rcp_z = Mix(ScreenTopLeft.Z, ScreenTopRight.Z, t); - return 1.0 / rcp_z; -} - -double WallCoords::VaryingX(int x, double start, double end) const -{ - double t = (x + 0.5 - ScreenTopLeft.X) * RcpDeltaScreenX; - double rcp_z = Mix(ScreenTopLeft.Z, ScreenTopRight.Z, t); - double t2 = VaryingXOffset + t / rcp_z * ScreenTopRight.Z * VaryingXScale; - return Mix(start, end, t2); -} - -double WallCoords::VaryingY(int x, int y, double start, double end) const -{ - double t = (x + 0.5 - ScreenTopLeft.X) * RcpDeltaScreenX; - double y1 = Mix(ScreenTopLeft.Y, ScreenTopRight.Y, t); - double y2 = Mix(ScreenBottomLeft.Y, ScreenBottomRight.Y, t); - if (y1 == y2 || y1 == -y2) - return start; - double t2 = (y + 0.5 - y1) / (y2 - y1); - return Mix(start, end, t2); -} - -///////////////////////////////////////////////////////////////////////////// - -void RenderBsp::Render() -{ - Clip.Clear(0, viewwidth); - Planes.Clear(); - VisibleSprites.clear(); - ScreenSprites.clear(); - - if (numnodes == 0) - RenderSubsector(subsectors); - else - RenderNode(nodes + numnodes - 1); // The head node is the last node output. - - Planes.Render(); - - RenderMaskedObjects(); - RenderPlayerSprites(); - RenderScreenSprites(); // To do: should be called by FSoftwareRenderer::DrawRemainingPlayerSprites instead of here -} - -void RenderBsp::RenderScreenSprites() -{ - for (auto &sprite : ScreenSprites) - sprite.Render(); -} - -void RenderBsp::RenderMaskedObjects() -{ - Clip.DrawMaskedWall = [&](short x1, short x2, int drawIndex, const short *clipTop, const short *clipBottom) - { - VisibleMaskedWalls[drawIndex].RenderMasked(x1, x2, clipTop, clipBottom); - }; - - std::stable_sort(VisibleSprites.begin(), VisibleSprites.end(), [](const auto &a, const auto &b) { return a.EyePos.Z > b.EyePos.Z; }); - - for (auto &sprite : VisibleSprites) - sprite.Render(&Clip); - - Clip.RenderMaskedWalls(); -} - -void RenderBsp::RenderPlayerSprites() -{ - if (!r_drawplayersprites || - !camera || - !camera->player || - (players[consoleplayer].cheats & CF_CHASECAM) || - (r_deathcamera && camera->health <= 0)) - return; - - float bobx, boby; - P_BobWeapon(camera->player, &bobx, &boby, r_TicFracF); - - // Interpolate the main weapon layer once so as to be able to add it to other layers. - double wx, wy; - DPSprite *weapon = camera->player->FindPSprite(PSP_WEAPON); - if (weapon) - { - if (weapon->firstTic) - { - wx = weapon->x; - wy = weapon->y; - } - else - { - wx = weapon->oldx + (weapon->x - weapon->oldx) * r_TicFracF; - wy = weapon->oldy + (weapon->y - weapon->oldy) * r_TicFracF; - } - } - else - { - wx = 0; - wy = 0; - } - - for (DPSprite *sprite = camera->player->psprites; sprite != nullptr; sprite = sprite->GetNext()) - { - // [RH] Don't draw the targeter's crosshair if the player already has a crosshair set. - // It's possible this psprite's caller is now null but the layer itself hasn't been destroyed - // because it didn't tick yet (if we typed 'take all' while in the console for example). - // In this case let's simply not draw it to avoid crashing. - if ((sprite->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr) && sprite->GetCaller() != nullptr) - { - RenderPlayerSprite(sprite, camera, bobx, boby, wx, wy, r_TicFracF); - } - } -} - -void RenderBsp::RenderPlayerSprite(DPSprite *sprite, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac) -{ - // decide which patch to use - if ((unsigned)sprite->GetSprite() >= (unsigned)sprites.Size()) - { - DPrintf(DMSG_ERROR, "RenderPlayerSprite: invalid sprite number %i\n", sprite->GetSprite()); - return; - } - - spritedef_t *def = &sprites[sprite->GetSprite()]; - if (sprite->GetFrame() >= def->numframes) - { - DPrintf(DMSG_ERROR, "RenderPlayerSprite: invalid sprite frame %i : %i\n", sprite->GetSprite(), sprite->GetFrame()); - return; - } - - spriteframe_t *frame = &SpriteFrames[def->spriteframes + sprite->GetFrame()]; - FTextureID picnum = frame->Texture[0]; - bool flip = (frame->Flip & 1) != 0; - - FTexture *tex = TexMan(picnum); - if (tex->UseType == FTexture::TEX_Null) - return; - - // Can't interpolate the first tic. - if (sprite->firstTic) - { - sprite->firstTic = false; - sprite->oldx = sprite->x; - sprite->oldy = sprite->y; - } - - double sx = sprite->oldx + (sprite->x - sprite->oldx) * ticfrac; - double sy = sprite->oldy + (sprite->y - sprite->oldy) * ticfrac; - - if (sprite->Flags & PSPF_ADDBOB) - { - sx += bobx; - sy += boby; - } - - if (sprite->Flags & PSPF_ADDWEAPON && sprite->GetID() != PSP_WEAPON) - { - sx += wx; - sy += wy; - } - - // calculate edges of the shape - double tx = sx - BaseXCenter; - - tx -= tex->GetScaledLeftOffset(); - int x1 = xs_RoundToInt(CenterX + tx * pspritexscale); - - // off the right side - if (x1 > viewwidth) - return; - - tx += tex->GetScaledWidth(); - int x2 = xs_RoundToInt(CenterX + tx * pspritexscale); - - // off the left side - if (x2 <= 0) - return; - - double texturemid = (BaseYCenter - sy) * tex->Scale.Y + tex->TopOffset; - - // Adjust PSprite for fullscreen views - if (camera->player && (RenderTarget != screen || viewheight == RenderTarget->GetHeight() || (RenderTarget->GetWidth() > (BaseXCenter * 2) && !st_scale))) - { - AWeapon *weapon = dyn_cast(sprite->GetCaller()); - if (weapon != nullptr && weapon->YAdjust != 0) - { - if (RenderTarget != screen || viewheight == RenderTarget->GetHeight()) - { - texturemid -= weapon->YAdjust; - } - else - { - texturemid -= StatusBar->GetDisplacement() * weapon->YAdjust; - } - } - } - - // Move the weapon down for 1280x1024. - if (sprite->GetID() < PSP_TARGETCENTER) - { - texturemid -= AspectPspriteOffset(WidescreenRatio); - } - - int clipped_x1 = MAX(x1, 0); - int clipped_x2 = MIN(x2, viewwidth); - double xscale = pspritexscale / tex->Scale.X; - double yscale = pspriteyscale / tex->Scale.Y; - uint32_t translation = 0; // [RH] Use default colors - - double xiscale, startfrac; - if (flip) - { - xiscale = -pspritexiscale * tex->Scale.X; - startfrac = 1; - } - else - { - xiscale = pspritexiscale * tex->Scale.X; - startfrac = 0; - } - - if (clipped_x1 > x1) - startfrac += xiscale * (clipped_x1 - x1); - - bool noaccel = false; - - FDynamicColormap *basecolormap = viewsector->ColorMap; - FDynamicColormap *colormap_to_use = basecolormap; - - visstyle_t visstyle; - visstyle.ColormapNum = 0; - visstyle.BaseColormap = basecolormap; - visstyle.Alpha = 0; - visstyle.RenderStyle = STYLE_Normal; - - bool foggy = false; - int actualextralight = foggy ? 0 : extralight << 4; - int spriteshade = LIGHT2SHADE(owner->Sector->lightlevel + actualextralight); - double minz = double((2048 * 4) / double(1 << 20)); - visstyle.ColormapNum = GETPALOOKUP(r_SpriteVisibility / minz, spriteshade); - - if (sprite->GetID() < PSP_TARGETCENTER) - { - // Lots of complicated style and noaccel stuff - } - - // Check for hardware-assisted 2D. If it's available, and this sprite is not - // fuzzy, don't draw it until after the switch to 2D mode. - if (!noaccel && RenderTarget == screen && (DFrameBuffer *)screen->Accel2D) - { - FRenderStyle style = visstyle.RenderStyle; - style.CheckFuzz(); - if (style.BlendOp != STYLEOP_Fuzz) - { - ScreenSprite screenSprite; - screenSprite.Pic = tex; - screenSprite.X1 = viewwindowx + x1; - screenSprite.Y1 = viewwindowy + viewheight / 2 - texturemid * yscale - 0.5; - screenSprite.Width = tex->GetWidth() * xscale; - screenSprite.Height = tex->GetHeight() * yscale; - screenSprite.Translation = TranslationToTable(translation); - screenSprite.Flip = xiscale < 0; - screenSprite.visstyle = visstyle; - screenSprite.Colormap = colormap_to_use; - ScreenSprites.push_back(screenSprite); - return; - } - } - - //R_DrawVisSprite(vis); -} - -bool RenderBsp::IsThingCulled(AActor *thing) -{ - FIntCVar *cvar = thing->GetClass()->distancecheck; - if (cvar != nullptr && *cvar >= 0) - { - double dist = (thing->Pos() - ViewPos).LengthSquared(); - double check = (double)**cvar; - if (dist >= check * check) - return true; - } - - // Don't waste time projecting sprites that are definitely not visible. - if (thing == nullptr || - (thing->renderflags & RF_INVISIBLE) || - !thing->RenderStyle.IsVisible(thing->Alpha) || - !thing->IsVisibleToPlayer()) - { - return true; - } - - return false; -} - -void RenderBsp::AddSprite(AActor *thing) -{ - if (IsThingCulled(thing)) - return; - - DVector3 pos = thing->InterpolatedPosition(r_TicFracF); - pos.Z += thing->GetBobOffset(r_TicFracF); - - DVector3 eyePos = Transform.WorldToEye(pos); - - // thing is behind view plane? - if (eyePos.Z < Transform.NearZ()) - return; - - // too far off the side? - if (fabs(eyePos.X / 64) > eyePos.Z) - return; - - VisibleSprites.push_back({ thing, eyePos }); -} - -void RenderBsp::AddWallSprite(AActor *thing) -{ - if (IsThingCulled(thing)) - return; -} - -void RenderBsp::RenderSubsector(subsector_t *sub) -{ - sector_t *frontsector = sub->sector; - frontsector->MoreFlags |= SECF_DRAWN; - - for (AActor *thing = sub->sector->thinglist; thing != nullptr; thing = thing->snext) - { - if ((thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) - AddWallSprite(thing); - else - AddSprite(thing); - } - - for (uint32_t i = 0; i < sub->numlines; i++) - { - seg_t *line = &sub->firstline[i]; - if (line->sidedef == NULL || !(line->sidedef->Flags & WALLF_POLYOBJ)) - AddLine(line, frontsector); - } -} - -void RenderBsp::AddLine(seg_t *line, sector_t *frontsector) -{ - // Reject lines not facing viewer - DVector2 pt1 = line->v1->fPos() - ViewPos; - DVector2 pt2 = line->v2->fPos() - ViewPos; - if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0) - return; - - double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1); - double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1); - double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2); - double frontfloorz2 = frontsector->floorplane.ZatPoint(line->v2); - - WallCoords entireWall(Transform, line->v1->fPos(), line->v2->fPos(), frontceilz1, frontfloorz1, frontceilz2, frontfloorz2); - if (entireWall.Culled) - return; - - VisiblePlaneKey ceilingPlaneKey(frontsector->GetTexture(sector_t::ceiling), frontsector->ColorMap, frontsector->lightlevel, frontsector->ceilingplane, frontsector->planes[sector_t::ceiling].xform); - VisiblePlaneKey floorPlaneKey(frontsector->GetTexture(sector_t::floor), frontsector->ColorMap, frontsector->lightlevel, frontsector->floorplane, frontsector->planes[sector_t::floor].xform); - - RenderWall wall; - wall.Line = line; - wall.Colormap = frontsector->ColorMap; - wall.Masked = false; - - if (line->backsector == nullptr) - { - Planes.MarkCeilingPlane(ceilingPlaneKey, Clip, entireWall); - Planes.MarkFloorPlane(floorPlaneKey, Clip, entireWall); - - wall.Coords = entireWall; - wall.TopZ = frontceilz1; - wall.BottomZ = frontfloorz1; - wall.UnpeggedCeil = frontceilz1; - wall.Texpart = side_t::mid; - wall.Render(Clip); - - Clip.MarkSegmentCulled(entireWall, -1); - } - else - { - sector_t *backsector = (line->backsector != line->frontsector) ? line->backsector : line->frontsector; - - double backceilz1 = backsector->ceilingplane.ZatPoint(line->v1); - double backfloorz1 = backsector->floorplane.ZatPoint(line->v1); - double backceilz2 = backsector->ceilingplane.ZatPoint(line->v2); - double backfloorz2 = backsector->floorplane.ZatPoint(line->v2); - - double topceilz1 = frontceilz1; - double topceilz2 = frontceilz2; - double topfloorz1 = MIN(backceilz1, frontceilz1); - double topfloorz2 = MIN(backceilz2, frontceilz2); - double bottomceilz1 = MAX(frontfloorz1, backfloorz1); - double bottomceilz2 = MAX(frontfloorz2, backfloorz2); - double bottomfloorz1 = frontfloorz1; - double bottomfloorz2 = frontfloorz2; - double middleceilz1 = topfloorz1; - double middleceilz2 = topfloorz2; - double middlefloorz1 = MIN(bottomceilz1, middleceilz1); - double middlefloorz2 = MIN(bottomceilz2, middleceilz2); - - bool bothSkyCeiling = frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum; - bool bothSkyFloor = frontsector->GetTexture(sector_t::floor) == skyflatnum && backsector->GetTexture(sector_t::floor) == skyflatnum; - - int maskedWallIndex = -1; - - if ((topceilz1 > topfloorz1 || topceilz2 > topfloorz2) && !bothSkyCeiling && line->sidedef) - { - WallCoords topwall(Transform, line->v1->fPos(), line->v2->fPos(), topceilz1, topfloorz1, topceilz2, topfloorz2); - if (!topwall.Culled) - { - wall.Coords = topwall; - wall.TopZ = topceilz1; - wall.BottomZ = topfloorz1; - wall.UnpeggedCeil = topceilz1; - wall.Texpart = side_t::top; - wall.Render(Clip); - } - } - - if ((bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && !bothSkyFloor && line->sidedef) - { - WallCoords bottomwall(Transform, line->v1->fPos(), line->v2->fPos(), bottomceilz1, bottomfloorz2, bottomceilz2, bottomfloorz2); - if (!bottomwall.Culled) - { - wall.Coords = bottomwall; - wall.TopZ = bottomceilz1; - wall.BottomZ = bottomfloorz2; - wall.UnpeggedCeil = topceilz1; - wall.Texpart = side_t::bottom; - wall.Render(Clip); - } - } - - WallCoords midwall(Transform, line->v1->fPos(), line->v2->fPos(), middleceilz1, middlefloorz1, middleceilz2, middlefloorz2); - if (!midwall.Culled && line->sidedef) - { - FTexture *midtex = TexMan(line->sidedef->GetTexture(side_t::mid), true); - if (midtex && midtex->UseType != FTexture::TEX_Null) - { - DVector3 v1 = Transform.WorldToEye({ line->v1->fPos(), 0.0 }); - DVector3 v2 = Transform.WorldToEye({ line->v2->fPos(), 0.0 }); - wall.Coords = midwall; - wall.TopZ = middleceilz1; - wall.BottomZ = middlefloorz1; - wall.UnpeggedCeil = topceilz1; - wall.Texpart = side_t::mid; - wall.Masked = true; - - maskedWallIndex = (int)VisibleMaskedWalls.size(); - VisibleMaskedWalls.push_back(wall); - } - } - - if (!bothSkyCeiling && !bothSkyFloor) - { - Planes.MarkCeilingPlane(ceilingPlaneKey, Clip, entireWall); - Planes.MarkFloorPlane(floorPlaneKey, Clip, entireWall); - if (!midwall.Culled) - Clip.ClipVertical(midwall, maskedWallIndex); - else - Clip.MarkSegmentCulled(entireWall, maskedWallIndex); - } - else if (bothSkyCeiling) - { - Planes.MarkFloorPlane(floorPlaneKey, Clip, entireWall); - if (!midwall.Culled) - Clip.ClipBottom(midwall, maskedWallIndex); - else - Clip.MarkSegmentCulled(entireWall, maskedWallIndex); - } - else if (bothSkyFloor) - { - Planes.MarkCeilingPlane(ceilingPlaneKey, Clip, entireWall); - if (!midwall.Culled) - Clip.ClipTop(midwall, maskedWallIndex); - else - Clip.MarkSegmentCulled(entireWall, maskedWallIndex); - } - } -} - -void RenderBsp::RenderNode(void *node) -{ - while (!((size_t)node & 1)) // Keep going until found a subsector - { - node_t *bsp = (node_t *)node; - - // Decide which side the view point is on. - int side = PointOnSide(ViewPos, bsp); - - // Recursively divide front space (toward the viewer). - RenderNode(bsp->children[side]); - - // Possibly divide back space (away from the viewer). - side ^= 1; - if (!CheckBBox(bsp->bbox[side])) - return; - - node = bsp->children[side]; - } - RenderSubsector((subsector_t *)((BYTE *)node - 1)); -} - -int RenderBsp::PointOnSide(const DVector2 &pos, const node_t *node) -{ - return DMulScale32(FLOAT2FIXED(pos.Y) - node->y, node->dx, node->x - FLOAT2FIXED(pos.X), node->dy) > 0; -} - -bool RenderBsp::CheckBBox(float *bspcoord) -{ - static const int checkcoord[12][4] = - { - { 3,0,2,1 }, - { 3,0,2,0 }, - { 3,1,2,0 }, - { 0 }, - { 2,0,2,1 }, - { 0,0,0,0 }, - { 3,1,3,0 }, - { 0 }, - { 2,0,3,1 }, - { 2,1,3,1 }, - { 2,1,3,0 } - }; - - int boxx; - int boxy; - int boxpos; - - double x1, y1, x2, y2; - double rx1, ry1, rx2, ry2; - int sx1, sx2; - - // Find the corners of the box - // that define the edges from current viewpoint. - if (ViewPos.X <= bspcoord[BOXLEFT]) - boxx = 0; - else if (ViewPos.X < bspcoord[BOXRIGHT]) - boxx = 1; - else - boxx = 2; - - if (ViewPos.Y >= bspcoord[BOXTOP]) - boxy = 0; - else if (ViewPos.Y > bspcoord[BOXBOTTOM]) - boxy = 1; - else - boxy = 2; - - boxpos = (boxy << 2) + boxx; - if (boxpos == 5) - return true; - - x1 = bspcoord[checkcoord[boxpos][0]] - ViewPos.X; - y1 = bspcoord[checkcoord[boxpos][1]] - ViewPos.Y; - x2 = bspcoord[checkcoord[boxpos][2]] - ViewPos.X; - y2 = bspcoord[checkcoord[boxpos][3]] - ViewPos.Y; - - // check clip list for an open space - - // Sitting on a line? - if (y1 * (x1 - x2) + x1 * (y2 - y1) >= -EQUAL_EPSILON) - return true; - - rx1 = x1 * ViewSin - y1 * ViewCos; - rx2 = x2 * ViewSin - y2 * ViewCos; - ry1 = x1 * ViewTanCos + y1 * ViewTanSin; - ry2 = x2 * ViewTanCos + y2 * ViewTanSin; - - /*if (MirrorFlags & RF_XFLIP) - { - double t = -rx1; - rx1 = -rx2; - rx2 = t; - swapvalues(ry1, ry2); - }*/ - - if (rx1 >= -ry1) - { - if (rx1 > ry1) return false; // left edge is off the right side - if (ry1 == 0) return false; - sx1 = xs_RoundToInt(CenterX + rx1 * CenterX / ry1); - } - else - { - if (rx2 < -ry2) return false; // wall is off the left side - if (rx1 - rx2 - ry2 + ry1 == 0) return false; // wall does not intersect view volume - sx1 = 0; - } - - if (rx2 <= ry2) - { - if (rx2 < -ry2) return false; // right edge is off the left side - if (ry2 == 0) return false; - sx2 = xs_RoundToInt(CenterX + rx2 * CenterX / ry2); - } - else - { - if (rx1 > ry1) return false; // wall is off the right side - if (ry2 - ry1 - rx2 + rx1 == 0) return false; // wall does not intersect view volume - sx2 = viewwidth; - } - - // Find the first clippost that touches the source post - // (adjacent pixels are touching). - - // Does not cross a pixel. - if (sx2 <= sx1) - return false; - - return !Clip.IsSegmentCulled(sx1, sx2); -} - -///////////////////////////////////////////////////////////////////////////// - -WallTextureCoords::WallTextureCoords(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil) -{ - CalcU(tex, line, texpart); - CalcV(tex, line, texpart, topz, bottomz, unpeggedceil); -} - -void WallTextureCoords::CalcU(FTexture *tex, const seg_t *line, side_t::ETexpart texpart) -{ - double lineLength = line->sidedef->TexelLength; - double lineStart = 0.0; - - bool entireSegment = ((line->linedef->v1 == line->v1) && (line->linedef->v2 == line->v2) || (line->linedef->v2 == line->v1) && (line->linedef->v1 == line->v2)); - if (!entireSegment) - { - lineLength = (line->v2->fPos() - line->v1->fPos()).Length(); - lineStart = (line->v1->fPos() - line->linedef->v1->fPos()).Length(); - } - - int texWidth = tex->GetWidth(); - double uscale = line->sidedef->GetTextureXScale(texpart) * tex->Scale.X; - u1 = lineStart + line->sidedef->GetTextureXOffset(texpart); - u2 = u1 + lineLength; - u1 *= uscale; - u2 *= uscale; - u1 /= texWidth; - u2 /= texWidth; -} - -void WallTextureCoords::CalcV(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil) -{ - double vscale = line->sidedef->GetTextureYScale(texpart) * tex->Scale.Y; - - double yoffset = line->sidedef->GetTextureYOffset(texpart); - if (tex->bWorldPanning) - yoffset *= vscale; - - switch (texpart) - { - default: - case side_t::mid: - CalcVMidPart(tex, line, topz, bottomz, vscale, yoffset); - break; - case side_t::top: - CalcVTopPart(tex, line, topz, bottomz, vscale, yoffset); - break; - case side_t::bottom: - CalcVBottomPart(tex, line, topz, bottomz, unpeggedceil, vscale, yoffset); - break; - } - - int texHeight = tex->GetHeight(); - v1 /= texHeight; - v2 /= texHeight; -} - -void WallTextureCoords::CalcVTopPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset) -{ - bool pegged = (line->linedef->flags & ML_DONTPEGTOP) == 0; - if (pegged) // bottom to top - { - int texHeight = tex->GetHeight(); - v1 = -yoffset; - v2 = v1 + (topz - bottomz); - v1 *= vscale; - v2 *= vscale; - v1 = texHeight - v1; - v2 = texHeight - v2; - std::swap(v1, v2); - } - else // top to bottom - { - v1 = yoffset; - v2 = v1 + (topz - bottomz); - v1 *= vscale; - v2 *= vscale; - } -} - -void WallTextureCoords::CalcVMidPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset) -{ - bool pegged = (line->linedef->flags & ML_DONTPEGBOTTOM) == 0; - if (pegged) // top to bottom - { - v1 = yoffset; - v2 = v1 + (topz - bottomz); - v1 *= vscale; - v2 *= vscale; - } - else // bottom to top - { - int texHeight = tex->GetHeight(); - v1 = yoffset; - v2 = v1 + (topz - bottomz); - v1 *= vscale; - v2 *= vscale; - v1 = texHeight - v1; - v2 = texHeight - v2; - std::swap(v1, v2); - } -} - -void WallTextureCoords::CalcVBottomPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double unpeggedceil, double vscale, double yoffset) -{ - bool pegged = (line->linedef->flags & ML_DONTPEGBOTTOM) == 0; - if (pegged) // top to bottom - { - v1 = yoffset; - v2 = v1 + (topz - bottomz); - v1 *= vscale; - v2 *= vscale; - } - else - { - v1 = yoffset + (unpeggedceil - topz); - v2 = v1 + (topz - bottomz); - v1 *= vscale; - v2 *= vscale; - } -} - -///////////////////////////////////////////////////////////////////////////// - -void RenderClipBuffer::Clear(short left, short right) -{ - SolidSegments.clear(); - SolidSegments.reserve(MAXWIDTH / 2 + 2); - SolidSegments.push_back({ -0x7fff, left }); - SolidSegments.push_back({ right, 0x7fff }); - - DrawSegments.clear(); - ClipValues.clear(); - - for (int x = left; x < right; x++) - { - Top[x] = 0; - Bottom[x] = viewheight; - } -} - -bool RenderClipBuffer::IsSegmentCulled(short x1, short x2) const -{ - int next = 0; - while (SolidSegments[next].X2 <= x2) - next++; - return (x1 >= SolidSegments[next].X1 && x2 <= SolidSegments[next].X2); -} - -void RenderClipBuffer::MarkSegmentCulled(const WallCoords &wallCoords, int drawIndex) -{ - if (wallCoords.Culled) - return; - - VisibleSegmentsIterator it(*this, wallCoords.ScreenX1, wallCoords.ScreenX2); - while (it.Step()) - { - for (short x = it.X1; x < it.X2; x++) - { - Bottom[x] = Top[x]; - } - - AddDrawSegment(it.X1, it.X2, wallCoords, true, true, drawIndex); - } - - short x1 = wallCoords.ScreenX1; - short x2 = wallCoords.ScreenX2; - - if (x1 >= x2) - return; - - int cur = 1; - while (true) - { - if (SolidSegments[cur].X1 <= x1 && SolidSegments[cur].X2 >= x2) // Already fully marked - { - break; - } - else if (cur + 1 != SolidSegments.size() && SolidSegments[cur].X2 >= x1 && SolidSegments[cur].X1 <= x2) // Merge segments - { - // Find last segment - int merge = cur; - while (merge + 2 != SolidSegments.size() && SolidSegments[merge + 1].X1 <= x2) - merge++; - - // Apply new merged range - SolidSegments[cur].X1 = MIN(SolidSegments[cur].X1, x1); - SolidSegments[cur].X2 = MAX(SolidSegments[merge].X2, x2); - - // Remove additional segments we merged with - if (merge > cur) - SolidSegments.erase(SolidSegments.begin() + (cur + 1), SolidSegments.begin() + (merge + 1)); - - break; - } - else if (SolidSegments[cur].X1 > x1) // Insert new segment - { - SolidSegments.insert(SolidSegments.begin() + cur, { x1, x2 }); - break; - } - cur++; - } -} - -void RenderClipBuffer::ClipVertical(const WallCoords &wallCoords, int drawIndex) -{ - if (wallCoords.Culled) - return; - - VisibleSegmentsIterator it(*this, wallCoords.ScreenX1, wallCoords.ScreenX2); - while (it.Step()) - { - for (short x = it.X1; x < it.X2; x++) - { - Top[x] = MAX(wallCoords.Y1(x), Top[x]); - Bottom[x] = MIN(wallCoords.Y2(x), Bottom[x]); - } - AddDrawSegment(it.X1, it.X2, wallCoords, true, true, drawIndex); - } -} - -void RenderClipBuffer::ClipTop(const WallCoords &wallCoords, int drawIndex) -{ - if (wallCoords.Culled) - return; - - VisibleSegmentsIterator it(*this, wallCoords.ScreenX1, wallCoords.ScreenX2); - while (it.Step()) - { - for (short x = it.X1; x < it.X2; x++) - { - Top[x] = MAX(wallCoords.Y1(x), Top[x]); - } - AddDrawSegment(it.X1, it.X2, wallCoords, true, false, drawIndex); - } -} - -void RenderClipBuffer::ClipBottom(const WallCoords &wallCoords, int drawIndex) -{ - if (wallCoords.Culled) - return; - - VisibleSegmentsIterator it(*this, wallCoords.ScreenX1, wallCoords.ScreenX2); - while (it.Step()) - { - for (short x = it.X1; x < it.X2; x++) - { - Bottom[x] = MIN(wallCoords.Y2(x), Bottom[x]); - } - AddDrawSegment(it.X1, it.X2, wallCoords, false, true, drawIndex); - } -} - -void RenderClipBuffer::AddDrawSegment(short x1, short x2, const WallCoords &wall, bool clipTop, bool clipBottom, int drawIndex) -{ - if (drawIndex != -1) // DrawMaskedWall needs both clipping ranges - { - clipTop = true; - clipBottom = true; - } - - DrawSegment segment; - segment.X1 = x1; - segment.X2 = x2; - segment.ClipOffset = (int)ClipValues.size(); - segment.ClipTop = clipTop; - segment.ClipBottom = clipBottom; - segment.PlaneNormal = wall.PlaneNormal; - segment.PlaneD = wall.PlaneD; - segment.NearZ = wall.NearZ; - segment.FarZ = wall.FarZ; - segment.DrawIndex = drawIndex; - - if (clipTop) - { - ClipValues.insert(ClipValues.end(), Top + x1, Top + x2); - } - - if (clipBottom) - { - ClipValues.insert(ClipValues.end(), Bottom + x1, Bottom + x2); - } - - DrawSegments.push_back(segment); -} - -void RenderClipBuffer::SetupSpriteClip(short x1, short x2, const DVector3 &pos, bool wallSprite) -{ - for (int i = x1; i < x2; i++) - { - Top[i] = 0; - Bottom[i] = viewheight; - } - - for (auto it = DrawSegments.crbegin(); it != DrawSegments.crend(); ++it) - { - const auto &segment = *it; - - int r1 = MAX(segment.X1, x1); - int r2 = MIN(segment.X2, x2); - if (r2 <= r1) - continue; - - short *clipTop = ClipValues.data() + segment.ClipOffset; - short *clipBottom = segment.ClipTop ? clipTop + (segment.X2 - segment.X1) : clipTop; - - double side = (pos | segment.PlaneNormal) + segment.PlaneD; - bool segBehindSprite; - if (!wallSprite) - segBehindSprite = (segment.NearZ >= pos.Z) || (segment.FarZ >= pos.Z && side <= 0.0); - else - segBehindSprite = side <= 0.0; - - if (segBehindSprite) - { - if (segment.DrawIndex != -1 && DrawMaskedWall) - DrawMaskedWall(r1, r2, segment.DrawIndex, clipTop + (r1 - segment.X1), clipBottom + (r1 - segment.X1)); - - if (segment.ClipTop) - { - for (int i = r1 - segment.X1; i < r2 - segment.X1; i++) - clipTop[i] = 0; - } - - if (segment.ClipBottom) - { - for (int i = r1 - segment.X1; i < r2 - segment.X1; i++) - clipBottom[i] = 0; - } - } - else - { - if (segment.ClipTop) - { - for (int x = r1; x < r2; x++) - Top[x] = MAX(clipTop[x - segment.X1], Top[x]); - } - - if (segment.ClipBottom) - { - for (int x = r1; x < r2; x++) - Bottom[x] = MIN(clipBottom[x - segment.X1], Bottom[x]); - } - } - } -} - -void RenderClipBuffer::RenderMaskedWalls() -{ - for (int i = 0; i < viewwidth; i++) - { - Top[i] = 0; - Bottom[i] = viewheight; - } - - for (auto it = DrawSegments.crbegin(); it != DrawSegments.crend(); ++it) - { - const auto &segment = *it; - if (segment.DrawIndex != -1 && DrawMaskedWall) - { - short *clipTop = ClipValues.data() + segment.ClipOffset; - short *clipBottom = segment.ClipTop ? clipTop + (segment.X2 - segment.X1) : clipTop; - DrawMaskedWall(segment.X1, segment.X2, segment.DrawIndex, clipTop, clipBottom); - } - } -} - -///////////////////////////////////////////////////////////////////////////// - -VisibleSegmentsIterator::VisibleSegmentsIterator(const RenderClipBuffer &buffer, short startx, short endx) : SolidSegments(buffer.SolidSegments), endx(endx) -{ - X1 = startx; - X2 = startx; -} - -bool VisibleSegmentsIterator::Step() -{ - if (next == 0) - { - while (SolidSegments[next].X2 <= X1) - next++; - if (SolidSegments[next].X1 <= X1) - X1 = SolidSegments[next++].X2; - X2 = MIN(SolidSegments[next].X1, endx); - } - else if (X2 == SolidSegments[next].X1 && next + 1 != SolidSegments.size()) - { - X1 = SolidSegments[next++].X2; - X2 = MIN(SolidSegments[next].X1, endx); - } - else - { - X1 = X2; - } - - return X1 < X2; -} - -///////////////////////////////////////////////////////////////////////////// - -RenderVisiblePlane::RenderVisiblePlane(VisiblePlane *plane, FTexture *tex) -{ - const auto &key = plane->Key; - - double xscale = key.Transform.xScale * tex->Scale.X; - double yscale = key.Transform.yScale * tex->Scale.Y; - - double planeang = (key.Transform.Angle + key.Transform.baseAngle).Radians(); - double cosine = cos(planeang); - double sine = sin(planeang); - viewx = (key.Transform.xOffs + ViewPos.X * cosine - ViewPos.Y * sine) * xscale; - viewy = (key.Transform.yOffs - ViewPos.X * sine - ViewPos.Y * cosine) * yscale; - - // left to right mapping - planeang += (ViewAngle - 90).Radians(); - - // Scale will be unit scale at FocalLengthX (normally SCREENWIDTH/2) distance - double xstep = cos(planeang) / FocalLengthX; - double ystep = -sin(planeang) / FocalLengthX; - - // [RH] flip for mirrors - /*if (MirrorFlags & RF_XFLIP) - { - xstep = -xstep; - ystep = -ystep; - }*/ - - planeang += M_PI / 2; - cosine = cos(planeang); - sine = -sin(planeang); - double x = plane->Right - centerx - 0.5; - double rightxfrac = xscale * (cosine + x * xstep); - double rightyfrac = yscale * (sine + x * ystep); - x = plane->Left - centerx - 0.5; - double leftxfrac = xscale * (cosine + x * xstep); - double leftyfrac = yscale * (sine + x * ystep); - - basexfrac = rightxfrac; - baseyfrac = rightyfrac; - xstepscale = (rightxfrac - leftxfrac) / (plane->Right - plane->Left); - ystepscale = (rightyfrac - leftyfrac) / (plane->Right - plane->Left); - - planeheight = fabs(key.Plane.Zat0() - ViewPos.Z); -} - -void RenderVisiblePlane::Step() -{ - basexfrac -= xstepscale; - baseyfrac -= ystepscale; -} - -///////////////////////////////////////////////////////////////////////////// - -void RenderPlanes::Render() -{ - for (int i = 0; i < NumBuckets; i++) - { - VisiblePlane *plane = PlaneBuckets[i].get(); - while (plane) - { - RenderPlane(plane); - plane = plane->Next.get(); - } - } -} - -void RenderPlanes::RenderPlane(VisiblePlane *plane) -{ - FTexture *tex = TexMan(plane->Key.Picnum); - if (tex->UseType == FTexture::TEX_Null) - return; - - RenderVisiblePlane render(plane, tex); - - short spanend[MAXHEIGHT]; - int x = plane->Right - 1; - int t2 = plane->Top[x]; - int b2 = plane->Bottom[x]; - - if (b2 > t2) - { - clearbufshort(spanend + t2, b2 - t2, x); - } - - for (--x; x >= plane->Left; --x) - { - int t1 = plane->Top[x]; - int b1 = plane->Bottom[x]; - const int xr = x + 1; - int stop; - - // Draw any spans that have just closed - stop = MIN(t1, b2); - while (t2 < stop) - { - int y = t2++; - RenderSpan(y, xr, spanend[y], plane->Key, tex, render); - } - stop = MAX(b1, t2); - while (b2 > stop) - { - int y = --b2; - RenderSpan(y, xr, spanend[y], plane->Key, tex, render); - } - - // Mark any spans that have just opened - stop = MIN(t2, b1); - while (t1 < stop) - { - spanend[t1++] = x; - } - stop = MAX(b2, t2); - while (b1 > stop) - { - spanend[--b1] = x; - } - - t2 = plane->Top[x]; - b2 = plane->Bottom[x]; - render.Step(); - } - // Draw any spans that are still open - while (t2 < b2) - { - int y = --b2; - RenderSpan(y, plane->Left, spanend[y], plane->Key, tex, render); - } -} - -void RenderPlanes::RenderSpan(int y, int x1, int x2, const VisiblePlaneKey &key, FTexture *tex, const RenderVisiblePlane &renderInfo) -{ - if (key.Picnum != skyflatnum) - { - double distance = renderInfo.planeheight * yslope[y]; - - double u = distance * renderInfo.basexfrac + renderInfo.viewx; - double v = distance * renderInfo.baseyfrac + renderInfo.viewy; - double uscale = distance * renderInfo.xstepscale; - double vscale = distance * renderInfo.ystepscale; - - double vis = r_FloorVisibility / renderInfo.planeheight; - - if (fixedlightlev >= 0) - R_SetDSColorMapLight(key.ColorMap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); - else if (fixedcolormap) - R_SetDSColorMapLight(fixedcolormap, 0, 0); - else - R_SetDSColorMapLight(key.ColorMap, (float)(vis * fabs(CenterY - y)), LIGHT2SHADE(key.LightLevel)); - - ds_source = (const BYTE *)tex->GetPixelsBgra(); - ds_source_mipmapped = false; - ds_xbits = tex->WidthBits; - ds_ybits = tex->HeightBits; - ds_xfrac = (uint32_t)(u * (1 << (32 - ds_xbits))); - ds_yfrac = (uint32_t)(v * (1 << (32 - ds_ybits))); - ds_xstep = (uint32_t)(uscale * (1 << (32 - ds_xbits))); - ds_ystep = (uint32_t)(vscale * (1 << (32 - ds_ybits))); - ds_y = y; - ds_x1 = x1; - ds_x2 = x2; - R_DrawSpan(); - } - else - { - tex = TexMan(sky1texture, true); - - double xangle1 = ((0.5 - x1 / (double)viewwidth) * FocalTangent * 90.0); - double xangle2 = ((0.5 - x2 / (double)viewwidth) * FocalTangent * 90.0); - - double u1 = sky1pos + (ViewAngle.Degrees + xangle1) * sky1cyl / 360.0; - double u2 = sky1pos + (ViewAngle.Degrees + xangle2) * sky1cyl / 360.0; - double u = u1; - double v = (y - CenterY) * skyiscale + skytexturemid * tex->Scale.Y; - double uscale = (u2 - u1) / (x2 - x1); - double vscale = 0.0; - - if (fixedlightlev >= 0) - R_SetDSColorMapLight(key.ColorMap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); - else if (fixedcolormap) - R_SetDSColorMapLight(fixedcolormap, 0, 0); - else - R_SetDSColorMapLight(key.ColorMap, 0, 0); - - ds_source = (const BYTE *)tex->GetPixelsBgra(); - ds_source_mipmapped = false; - ds_xbits = tex->WidthBits; - ds_ybits = tex->HeightBits; - ds_xfrac = (uint32_t)(u * (1 << (32 - ds_xbits))); - ds_yfrac = (uint32_t)(v * (1 << (32 - ds_ybits))); - ds_xstep = (uint32_t)(uscale * (1 << (32 - ds_xbits))); - ds_ystep = (uint32_t)(vscale * (1 << (32 - ds_ybits))); - ds_y = y; - ds_x1 = x1; - ds_x2 = x2; - R_DrawSpan(); - } -} - -void RenderPlanes::Clear() -{ - for (int i = 0; i < NumBuckets; i++) - { - std::unique_ptr plane = std::move(PlaneBuckets[i]); - while (plane) - { - std::unique_ptr next = std::move(plane->Next); - FreePlanes.push_back(std::move(plane)); - plane = std::move(next); - } - } -} - -void RenderPlanes::MarkCeilingPlane(const VisiblePlaneKey &key, const RenderClipBuffer &clip, const WallCoords &wallCoords) -{ - VisibleSegmentsIterator it(clip, wallCoords.ScreenX1, wallCoords.ScreenX2); - while (it.Step()) - { - VisiblePlane *plane = GetPlaneWithUnsetRange(key, it.X1, it.X2); - - for (short x = it.X1; x < it.X2; x++) - { - short walltop = MAX(wallCoords.Y1(x), clip.Top[x]); - short top = clip.Top[x]; - short bottom = MIN(walltop, clip.Bottom[x]); - if (top < bottom) - { - plane->Top[x] = top; - plane->Bottom[x] = bottom; - } - } - } -} - -void RenderPlanes::MarkFloorPlane(const VisiblePlaneKey &key, const RenderClipBuffer &clip, const WallCoords &wallCoords) -{ - VisibleSegmentsIterator it(clip, wallCoords.ScreenX1, wallCoords.ScreenX2); - while (it.Step()) - { - VisiblePlane *plane = GetPlaneWithUnsetRange(key, it.X1, it.X2); - - for (short x = it.X1; x < it.X2; x++) - { - short wallbottom = MIN(wallCoords.Y2(x), clip.Bottom[x]); - short top = MAX(wallbottom, clip.Top[x]); - short bottom = clip.Bottom[x]; - if (top < bottom) - { - plane->Top[x] = top; - plane->Bottom[x] = bottom; - } - } - } -} - -VisiblePlane *RenderPlanes::GetPlaneWithUnsetRange(const VisiblePlaneKey &key, int start, int stop) -{ - VisiblePlane *plane = GetPlane(key); - - int intrl, intrh; - int unionl, unionh; - - if (start < plane->Left) - { - intrl = plane->Left; - unionl = start; - } - else - { - unionl = plane->Left; - intrl = start; - } - - if (stop > plane->Right) - { - intrh = plane->Right; - unionh = stop; - } - else - { - unionh = plane->Right; - intrh = stop; - } - - // Verify that the entire range has unset values - int x = intrl; - while (x < intrh && plane->Top[x] == VisiblePlane::UnsetValue) - x++; - - if (x >= intrh) // They do. Use the current plane - { - plane->Left = unionl; - plane->Right = unionh; - return plane; - } - else // Create new plane and make sure it is found first - { - auto &bucket = PlaneBuckets[Hash(key)]; - std::unique_ptr newPlane = AllocPlane(key); - newPlane->Left = start; - newPlane->Right = stop; - newPlane->Next = std::move(bucket); - bucket = std::move(newPlane); - return bucket.get(); - } -} - -VisiblePlane *RenderPlanes::GetPlane(const VisiblePlaneKey &key) -{ - auto &bucket = PlaneBuckets[Hash(key)]; - VisiblePlane *plane = bucket.get(); - - while (plane != nullptr) - { - if (plane->Key == key) - return plane; - plane = plane->Next.get(); - } - - std::unique_ptr new_plane = AllocPlane(key); - new_plane->Next = std::move(bucket); - bucket = std::move(new_plane); - return bucket.get(); -} - -std::unique_ptr RenderPlanes::AllocPlane(const VisiblePlaneKey &key) -{ - if (!FreePlanes.empty()) - { - std::unique_ptr plane = std::move(FreePlanes.back()); - FreePlanes.pop_back(); - plane->Clear(key); - return std::move(plane); - } - else - { - return std::make_unique(key); - } -} - -///////////////////////////////////////////////////////////////////////////// - -void RenderWall::Render(const RenderClipBuffer &clip) -{ - FTexture *tex = GetTexture(); - if (!tex) - return; - int texWidth = tex->GetWidth(); - int texHeight = tex->GetHeight(); - - WallTextureCoords texcoords(tex, Line, Texpart, TopZ, BottomZ, UnpeggedCeil); - - VisibleSegmentsIterator it(clip, Coords.ScreenX1, Coords.ScreenX2); - while (it.Step()) - { - for (short x = it.X1; x < it.X2; x++) - { - short y1 = MAX(Coords.Y1(x), clip.Top[x]); - short y2 = MIN(Coords.Y2(x), clip.Bottom[x]); - if (y1 >= y2) - continue; - - double u = Coords.VaryingX(x, texcoords.u1, texcoords.u2); - double v1 = Coords.VaryingY(x, y1, texcoords.v1, texcoords.v2); - double v2 = Coords.VaryingY(x, y2, texcoords.v1, texcoords.v2); - - R_SetColorMapLight(Colormap, GetLight(x), GetShade()); - - dc_source = (const BYTE *)tex->GetColumnBgra((int)(u * texWidth), nullptr); - dc_source2 = nullptr; - dc_textureheight = texHeight; - dc_texturefrac = (uint32_t)(v1 * 0xffffffff); - dc_iscale = (uint32_t)((v2 - v1) / (y2 - y1) * 0xffffffff); - dc_dest = dc_destorg + (ylookup[y1] + x) * 4; - dc_count = y2 - y1; - dovline1(); - } - } -} - -void RenderWall::RenderMasked(short x1, short x2, const short *clipTop, const short *clipBottom) -{ - FTexture *tex = GetTexture(); - if (!tex) - return; - int texWidth = tex->GetWidth(); - int texHeight = tex->GetHeight(); - - WallTextureCoords texcoords(tex, Line, Texpart, TopZ, BottomZ, UnpeggedCeil); - - for (short x = x1; x < x2; x++) - { - short y1 = MAX(Coords.Y1(x), clipTop[x - x1]); - short y2 = MIN(Coords.Y2(x), clipBottom[x - x1]); - if (y1 >= y2) - continue; - - double u = Coords.VaryingX(x, texcoords.u1, texcoords.u2); - double v1 = Coords.VaryingY(x, y1, texcoords.v1, texcoords.v2); - double v2 = Coords.VaryingY(x, y2, texcoords.v1, texcoords.v2); - - R_SetColorMapLight(Colormap, GetLight(x), GetShade()); - - dc_source = (const BYTE *)tex->GetColumnBgra((int)(u * texWidth), nullptr); - dc_source2 = nullptr; - dc_textureheight = texHeight; - dc_texturefrac = (uint32_t)(v1 * 0xffffffff); - dc_iscale = (uint32_t)((v2 - v1) / (y2 - y1) * 0xffffffff); - dc_dest = dc_destorg + (ylookup[y1] + x) * 4; - dc_count = y2 - y1; - domvline1(); - } -} - -FTexture *RenderWall::GetTexture() -{ - FTexture *tex = TexMan(Line->sidedef->GetTexture(Texpart), true); - if (tex == nullptr || tex->UseType == FTexture::TEX_Null) - return nullptr; - else - return tex; -} - -int RenderWall::GetShade() -{ - if (fixedlightlev >= 0 || fixedcolormap) - { - return 0; - } - else - { - bool foggy = false; - int actualextralight = foggy ? 0 : extralight << 4; - int shade = LIGHT2SHADE(Line->sidedef->GetLightLevel(foggy, Line->frontsector->lightlevel) + actualextralight); - return shade; - } -} - -float RenderWall::GetLight(short x) -{ - if (fixedlightlev >= 0 || fixedcolormap) - return 0.0f; - else - return (float)(r_WallVisibility / Coords.Z(x)); -} - -///////////////////////////////////////////////////////////////////////////// - -VisibleSprite::VisibleSprite(AActor *actor, const DVector3 &eyePos) : Actor(actor), EyePos(eyePos) -{ -} - -void VisibleSprite::Render(RenderClipBuffer *clip) -{ - //if (MirrorFlags & RF_XFLIP) - // tx = -tx; - - bool flipTextureX = false; - FTexture *tex = GetSpriteTexture(Actor, flipTextureX); - DVector2 spriteScale = Actor->Scale; - - const double thingxscalemul = spriteScale.X / tex->Scale.X; - - double xscale = CenterX / EyePos.Z; - double yscale = spriteScale.Y / tex->Scale.Y;// spriteScale.Y / tex->Scale.Y * InvZtoScale / EyePos.Z; - - double tx; - if (flipTextureX) - { - tx = EyePos.X - (tex->GetWidth() - tex->LeftOffset - 1) * thingxscalemul; - } - else - { - tx = EyePos.X - tex->LeftOffset * thingxscalemul; - } - - double texturemid = tex->TopOffset + (EyePos.Y - Actor->Floorclip) / yscale; - double y = CenterY - texturemid * (InvZtoScale * yscale / EyePos.Z); - - int x1 = centerx + xs_RoundToInt(tx * xscale); - int x2 = centerx + xs_RoundToInt((tx + tex->GetWidth() * thingxscalemul) * xscale); - int y1 = xs_RoundToInt(y); - int y2 = xs_RoundToInt(y + (InvZtoScale * yscale / EyePos.Z) * tex->GetHeight()); - - xscale = spriteScale.X * xscale / tex->Scale.X; - - int clipped_x1 = clamp(x1, 0, viewwidth - 1); - int clipped_x2 = clamp(x2, 0, viewwidth - 1); - int clipped_y1 = clamp(y1, 0, viewheight - 1); - int clipped_y2 = clamp(y2, 0, viewheight - 1); - if (clipped_x1 >= clipped_x2 || clipped_y1 >= clipped_y2) - return; - - clip->SetupSpriteClip(clipped_x1, clipped_x2, EyePos, false); - - uint32_t texwidth = tex->GetWidth(); - uint32_t texheight = tex->GetHeight(); - - visstyle_t visstyle = GetSpriteVisStyle(Actor, EyePos.Z); - // Rumor has it that AlterWeaponSprite needs to be called with visstyle passed in somewhere around here.. - R_SetColorMapLight(visstyle.BaseColormap, 0, visstyle.ColormapNum << FRACBITS); - - for (int x = clipped_x1; x < clipped_x2; x++) - { - short top = MAX(clipped_y1, clip->Top[x]); - short bottom = MIN(clipped_y2, clip->Bottom[x]); - if (top < bottom) - { - float u = (x - x1) / (float)(x2 - x1); - float v = (top - y1) / (float)(y2 - y1); - if (flipTextureX) - u = 1.0f - u; - u = u - floor(u); - - dc_source = (const BYTE *)tex->GetColumnBgra((int)(u * texwidth), nullptr); - dc_source2 = nullptr; - dc_textureheight = texheight; - dc_texturefrac = (uint32_t)(v * 0xffffffff); - dc_iscale = 0xffffffff / (y2 - y1); - dc_dest = dc_destorg + (ylookup[top] + x) * 4; - dc_count = bottom - top; - domvline1(); - } - } -} - -visstyle_t VisibleSprite::GetSpriteVisStyle(AActor *thing, double z) -{ - visstyle_t visstyle; - - bool foggy = false; - int actualextralight = foggy ? 0 : extralight << 4; - int spriteshade = LIGHT2SHADE(thing->Sector->lightlevel + actualextralight); - - visstyle.RenderStyle = thing->RenderStyle; - visstyle.Alpha = float(thing->Alpha); - visstyle.ColormapNum = 0; - - // The software renderer cannot invert the source without inverting the overlay - // too. That means if the source is inverted, we need to do the reverse of what - // the invert overlay flag says to do. - bool invertcolormap = (visstyle.RenderStyle.Flags & STYLEF_InvertOverlay) != 0; - - if (visstyle.RenderStyle.Flags & STYLEF_InvertSource) - { - invertcolormap = !invertcolormap; - } - - FDynamicColormap *mybasecolormap = thing->Sector->ColorMap; - - // Sprites that are added to the scene must fade to black. - if (visstyle.RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0) - { - mybasecolormap = GetSpecialLights(mybasecolormap->Color, 0, mybasecolormap->Desaturate); - } - - if (visstyle.RenderStyle.Flags & STYLEF_FadeToBlack) - { - if (invertcolormap) - { // Fade to white - mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(255, 255, 255), mybasecolormap->Desaturate); - invertcolormap = false; - } - else - { // Fade to black - mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(0, 0, 0), mybasecolormap->Desaturate); - } - } - - // get light level - if (fixedcolormap != NULL) - { // fixed map - visstyle.BaseColormap = fixedcolormap; - visstyle.ColormapNum = 0; - } - else - { - if (invertcolormap) - { - mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate); - } - if (fixedlightlev >= 0) - { - visstyle.BaseColormap = mybasecolormap; - visstyle.ColormapNum = fixedlightlev >> COLORMAPSHIFT; - } - else if (!foggy && ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) - { // full bright - visstyle.BaseColormap = mybasecolormap; - visstyle.ColormapNum = 0; - } - else - { // diminished light - double minz = double((2048 * 4) / double(1 << 20)); - visstyle.ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(z, minz), spriteshade); - visstyle.BaseColormap = mybasecolormap; - } - } - - return visstyle; -} - -FTexture *VisibleSprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX) -{ - flipX = false; - if (thing->picnum.isValid()) - { - FTexture *tex = TexMan(thing->picnum); - if (tex->UseType == FTexture::TEX_Null) - { - return nullptr; - } - - if (tex->Rotations != 0xFFFF) - { - // choose a different rotation based on player view - spriteframe_t *sprframe = &SpriteFrames[tex->Rotations]; - DVector3 pos = thing->InterpolatedPosition(r_TicFracF); - pos.Z += thing->GetBobOffset(r_TicFracF); - DAngle ang = (pos - ViewPos).Angle(); - angle_t rot; - if (sprframe->Texture[0] == sprframe->Texture[1]) - { - rot = (ang - thing->Angles.Yaw + 45.0 / 2 * 9).BAMs() >> 28; - } - else - { - rot = (ang - thing->Angles.Yaw + (45.0 / 2 * 9 - 180.0 / 16)).BAMs() >> 28; - } - flipX = (sprframe->Flip & (1 << rot)) != 0; - tex = TexMan[sprframe->Texture[rot]]; // Do not animate the rotation - } - return tex; - } - else - { - // decide which texture to use for the sprite - int spritenum = thing->sprite; - if (spritenum >= (signed)sprites.Size() || spritenum < 0) - return nullptr; - - spritedef_t *sprdef = &sprites[spritenum]; - if (thing->frame >= sprdef->numframes) - { - // If there are no frames at all for this sprite, don't draw it. - return nullptr; - } - else - { - //picnum = SpriteFrames[sprdef->spriteframes + thing->frame].Texture[0]; - // choose a different rotation based on player view - spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + thing->frame]; - DVector3 pos = thing->InterpolatedPosition(r_TicFracF); - pos.Z += thing->GetBobOffset(r_TicFracF); - DAngle ang = (pos - ViewPos).Angle(); - angle_t rot; - if (sprframe->Texture[0] == sprframe->Texture[1]) - { - rot = (ang - thing->Angles.Yaw + 45.0 / 2 * 9).BAMs() >> 28; - } - else - { - rot = (ang - thing->Angles.Yaw + (45.0 / 2 * 9 - 180.0 / 16)).BAMs() >> 28; - } - flipX = (sprframe->Flip & (1 << rot)) != 0; - return TexMan[sprframe->Texture[rot]]; // Do not animate the rotation - } - } -} - -///////////////////////////////////////////////////////////////////////////// - -void ScreenSprite::Render() -{ - FSpecialColormap *special = nullptr; - FColormapStyle colormapstyle; - PalEntry overlay = 0; - bool usecolormapstyle = false; - if (visstyle.BaseColormap >= &SpecialColormaps[0] && - visstyle.BaseColormap < &SpecialColormaps[SpecialColormaps.Size()]) - { - special = static_cast(visstyle.BaseColormap); - } - else if (Colormap->Color == PalEntry(255, 255, 255) && - Colormap->Desaturate == 0) - { - overlay = Colormap->Fade; - overlay.a = BYTE(visstyle.ColormapNum * 255 / NUMCOLORMAPS); - } - else - { - usecolormapstyle = true; - colormapstyle.Color = Colormap->Color; - colormapstyle.Fade = Colormap->Fade; - colormapstyle.Desaturate = Colormap->Desaturate; - colormapstyle.FadeLevel = visstyle.ColormapNum / float(NUMCOLORMAPS); - } - - screen->DrawTexture(Pic, - X1, - Y1, - DTA_DestWidthF, Width, - DTA_DestHeightF, Height, - DTA_Translation, Translation, - DTA_FlipX, Flip, - DTA_TopOffset, 0, - DTA_LeftOffset, 0, - DTA_ClipLeft, viewwindowx, - DTA_ClipTop, viewwindowy, - DTA_ClipRight, viewwindowx + viewwidth, - DTA_ClipBottom, viewwindowy + viewheight, - DTA_AlphaF, visstyle.Alpha, - DTA_RenderStyle, visstyle.RenderStyle, - DTA_FillColor, FillColor, - DTA_SpecialColormap, special, - DTA_ColorOverlay, overlay.d, - DTA_ColormapStyle, usecolormapstyle ? &colormapstyle : NULL, - TAG_DONE); -} diff --git a/src/r_swrenderer2.h b/src/r_swrenderer2.h deleted file mode 100644 index eaa734c87..000000000 --- a/src/r_swrenderer2.h +++ /dev/null @@ -1,366 +0,0 @@ -/* -** Experimental Doom software renderer -** Copyright (c) 2016 Magnus Norddahl -** -** This software is provided 'as-is', without any express or implied -** warranty. In no event will the authors be held liable for any damages -** arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, -** including commercial applications, and to alter it and redistribute it -** freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not -** claim that you wrote the original software. If you use this software -** in a product, an acknowledgment in the product documentation would be -** appreciated but is not required. -** 2. Altered source versions must be plainly marked as such, and must not be -** misrepresented as being the original software. -** 3. This notice may not be removed or altered from any source distribution. -** -*/ - -#pragma once - -#include -#include -#include -#include -#include "doomdata.h" -#include "r_utility.h" -#include "r_main.h" - -// Transform for a view position and its viewport -// -// World space uses map coordinates in the XY plane. Z is up. -// Eye space means relative to viewer, Y is up and Z is into the screen. -// Viewport means in normalized device coordinates (-1 to 1 range with perspective division). 0,0 is in the center of the viewport and Y is still up. -// Screen means in final screen coordinates. 0,0 is the upper left corner and Y is down. Z is still 1/z. -// -class ViewPosTransform -{ -public: - DVector3 WorldToEye(const DVector3 &worldPoint) const; - DVector3 WorldToViewport(const DVector3 &worldPoint) const { return EyeToViewport(WorldToEye(worldPoint)); } - DVector3 WorldToScreen(const DVector3 &worldPoint) const { return EyeToScreen(WorldToEye(worldPoint)); } - - DVector3 EyeToViewport(const DVector3 &eyePoint) const; - DVector3 EyeToScreen(const DVector3 &eyePoint) const { return ViewportToScreen(EyeToViewport(eyePoint)); } - - DVector3 ViewportToScreen(const DVector3 &viewportPoint) const; - - double ScreenXToEye(int x, double z) const; - double ScreenYToEye(int y, double z) const; - - double NearZ() const { return 0.0078125; }; -}; - -// Screen space coordinates for a wall -class WallCoords -{ -public: - WallCoords() = default; - WallCoords(const ViewPosTransform &transform, const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2); - - // True if transform and clip culled the wall - bool Culled = true; - - // Plane for wall in eye space - DVector3 PlaneNormal; - double PlaneD = 0.0; - - // Z range of the wall in eye space - double NearZ = 0.0; - double FarZ = 0.0; - - // Screen space bounding box of the wall - int ScreenX1 = 0; - int ScreenX2 = 0; - int ScreenY1 = 0; - int ScreenY2 = 0; - - // Get the Y positions for the given column - short Y1(int x) const; - short Y2(int x) const; - - // Get the depth for a column - double Z(int x) const; - - // Perspective correct interpolation from start to end (used to calculate texture coordinates) - double VaryingX(int x, double start, double end) const; - double VaryingY(int x, int y, double start, double end) const; - -private: - static DVector3 Mix(const DVector3 &a, const DVector3 &b, double t); - static double Mix(double a, double b, double t); - - ViewPosTransform Transform; - DVector3 ScreenTopLeft; - DVector3 ScreenTopRight; - DVector3 ScreenBottomLeft; - DVector3 ScreenBottomRight; - double RcpDeltaScreenX = 0.0; - double VaryingXScale = 1.0; - double VaryingXOffset = 0.0; -}; - -// Texture coordinates for a wall -class WallTextureCoords -{ -public: - WallTextureCoords(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil); - - double u1, u2; - double v1, v2; - -private: - void CalcU(FTexture *tex, const seg_t *line, side_t::ETexpart texpart); - void CalcV(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil); - void CalcVTopPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset); - void CalcVMidPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset); - void CalcVBottomPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double unpeggedceil, double vscale, double yoffset); -}; - -// Clipping buffers used during rendering -class RenderClipBuffer -{ -public: - void Clear(short left, short right); - void MarkSegmentCulled(const WallCoords &wallCoords, int drawIndex); - void ClipVertical(const WallCoords &wallCoords, int drawIndex); - void ClipTop(const WallCoords &wallCoords, int drawIndex); - void ClipBottom(const WallCoords &wallCoords, int drawIndex); - bool IsSegmentCulled(short x1, short x2) const; - - void SetupSpriteClip(short x1, short x2, const DVector3 &pos, bool wallSprite); - void RenderMaskedWalls(); - - short Top[MAXWIDTH]; - short Bottom[MAXWIDTH]; - - std::function DrawMaskedWall; - -private: - void AddDrawSegment(short x1, short x2, const WallCoords &wall, bool clipTop, bool clipBottom, int drawIndex); - - struct SolidSegment - { - SolidSegment(short x1, short x2) : X1(x1), X2(x2) { } - short X1, X2; - }; - - struct DrawSegment - { - short X1; - short X2; - int ClipOffset; - bool ClipTop; - bool ClipBottom; - DVector3 PlaneNormal; - double PlaneD; - double NearZ; - double FarZ; - int DrawIndex; - }; - - std::vector SolidSegments; - std::vector DrawSegments; - std::vector ClipValues; - - friend class VisibleSegmentsIterator; -}; - -// Walks the visible segments in a range -class VisibleSegmentsIterator -{ -public: - VisibleSegmentsIterator(const RenderClipBuffer &buffer, short startx, short endx); - bool Step(); - - short X1; - short X2; - -private: - const std::vector &SolidSegments; - short endx; - int next = 0; -}; - -// Class used to group sector ceilings/floors sharing common properties -class VisiblePlaneKey -{ -public: - VisiblePlaneKey() { } - VisiblePlaneKey(FTextureID picnum, FSWColormap *colormap, int lightlevel, secplane_t plane, const FTransform &xform) : Picnum(picnum), ColorMap(colormap), LightLevel(lightlevel), Plane(plane), Transform(xform) { } - - bool operator==(const VisiblePlaneKey &other) const - { - return Picnum == other.Picnum && LightLevel == other.LightLevel && Plane.fD() == other.Plane.fD(); - } - - FTextureID Picnum; - FSWColormap *ColorMap; - int LightLevel; - secplane_t Plane; - FTransform Transform; -}; - -// Visible plane to be rendered -class VisiblePlane -{ -public: - VisiblePlane(const VisiblePlaneKey &key) { Clear(key); } - - void Clear(const VisiblePlaneKey &key) - { - Key = key; - Left = viewwidth; - Right = 0; - for (int i = 0; i < MAXWIDTH; i++) - { - Top[i] = UnsetValue; - Bottom[i] = 0; - } - } - - VisiblePlaneKey Key; - - enum { UnsetValue = 0x7fff }; - short Left; - short Right; - short Top[MAXWIDTH]; - short Bottom[MAXWIDTH]; - std::unique_ptr Next; -}; - -class RenderVisiblePlane -{ -public: - RenderVisiblePlane(VisiblePlane *plane, FTexture *tex); - void Step(); - - double viewx; - double viewy; - double planeheight; - double basexfrac; - double baseyfrac; - double xstepscale; - double ystepscale; -}; - -// Tracks plane locations and renders them -class RenderPlanes -{ -public: - void Clear(); - void MarkCeilingPlane(const VisiblePlaneKey &key, const RenderClipBuffer &clip, const WallCoords &wallCoords); - void MarkFloorPlane(const VisiblePlaneKey &key, const RenderClipBuffer &clip, const WallCoords &wallCoords); - void Render(); - -private: - void RenderPlane(VisiblePlane *plane); - void RenderSpan(int y, int x1, int x2, const VisiblePlaneKey &key, FTexture *texture, const RenderVisiblePlane &renderInfo); - - VisiblePlane *GetPlaneWithUnsetRange(const VisiblePlaneKey &key, int x0, int x1); - VisiblePlane *GetPlane(const VisiblePlaneKey &key); - std::unique_ptr AllocPlane(const VisiblePlaneKey &key); - static uint32_t Hash(const VisiblePlaneKey &key) { return ((unsigned)((key.Picnum.GetIndex()) * 3 + (key.LightLevel) + (FLOAT2FIXED(key.Plane.fD())) * 7) & (NumBuckets - 1)); } - - enum { NumBuckets = 128 /* must be a power of 2 */ }; - std::unique_ptr PlaneBuckets[NumBuckets]; - std::vector> FreePlanes; -}; - -// Renders a wall texture -class RenderWall -{ -public: - void Render(const RenderClipBuffer &clip); - void RenderMasked(short x1, short x2, const short *clipTop, const short *clipBottom); - - WallCoords Coords; - const seg_t *Line; - side_t::ETexpart Texpart; - double TopZ; - double BottomZ; - double UnpeggedCeil; - FSWColormap *Colormap; - bool Masked; - -private: - FTexture *GetTexture(); - int GetShade(); - float GetLight(short x); -}; - -// Sprite thing to be rendered -class VisibleSprite -{ -public: - VisibleSprite(AActor *actor, const DVector3 &eyePos); - void Render(RenderClipBuffer *clip); - -private: - AActor *Actor; - DVector3 EyePos; - - FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); - visstyle_t GetSpriteVisStyle(AActor *thing, double z); - - friend class RenderBsp; // For sorting -}; - -// DScreen accelerated sprite to be rendered -class ScreenSprite -{ -public: - void Render(); - - FTexture *Pic = nullptr; - double X1 = 0.0; - double Y1 = 0.0; - double Width = 0.0; - double Height = 0.0; - FRemapTable *Translation = nullptr; - bool Flip = false; - visstyle_t visstyle; - uint32_t FillColor = 0; - FDynamicColormap *Colormap = nullptr; -}; - -// Renders a BSP tree in a scene -class RenderBsp -{ -public: - void Render(); - void RenderScreenSprites(); - -private: - void RenderNode(void *node); - void RenderSubsector(subsector_t *sub); - void AddLine(seg_t *line, sector_t *frontsector); - - void AddSprite(AActor *thing); - void AddWallSprite(AActor *thing); - bool IsThingCulled(AActor *thing); - void RenderMaskedObjects(); - - void RenderPlayerSprites(); - void RenderPlayerSprite(DPSprite *sprite, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac); - - int PointOnSide(const DVector2 &pos, const node_t *node); - - // Checks BSP node/subtree bounding box. - // Returns true if some part of the bbox might be visible. - bool CheckBBox(float *bspcoord); - - ViewPosTransform Transform; - RenderClipBuffer Clip; - RenderPlanes Planes; - std::vector VisibleSprites; - std::vector VisibleMaskedWalls; - std::vector ScreenSprites; - - const int BaseXCenter = 160; - const int BaseYCenter = 100; -}; From ae889acaea74e049cb2be670d5b57672c73b0234 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 16 Nov 2016 19:49:46 +0100 Subject: [PATCH 1232/1509] active_con_scale should respect uiscale --- src/c_console.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/c_console.cpp b/src/c_console.cpp index 3064abb0d..68f445542 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -158,10 +158,14 @@ int active_con_scale() int scale = con_scale; if (scale <= 0) { - scale = CleanXfac - 1; - if (scale <= 0) + scale = uiscale; + if (scale == 0) { - scale = 1; + scale = CleanXfac - 1; + if (scale <= 0) + { + scale = 1; + } } } return scale; From 59f7dedfb4e03690ef9228cce3874e424ef496f0 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 16 Nov 2016 22:31:49 +0100 Subject: [PATCH 1233/1509] Added wall sprite support. Unfortunately it would seem that a bullet hole is not a wall sprite.. --- src/r_poly.cpp | 2 +- src/r_poly_sprite.h | 2 +- src/r_poly_wallsprite.cpp | 96 ++++++++++++++++++++++++++++++++++++++- src/r_poly_wallsprite.h | 2 +- 4 files changed, 98 insertions(+), 4 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 179df248a..919b2ff78 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -183,7 +183,7 @@ void RenderPolyScene::RenderTranslucent() else if ((obj.thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) { RenderPolyWallSprite wallspr; - wallspr.Render(obj.thing, obj.sub, obj.subsectorDepth); + wallspr.Render(WorldToClip, obj.thing, obj.sub, obj.subsectorDepth); } else { diff --git a/src/r_poly_sprite.h b/src/r_poly_sprite.h index d60710d04..085d9b570 100644 --- a/src/r_poly_sprite.h +++ b/src/r_poly_sprite.h @@ -30,8 +30,8 @@ public: void Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth); static bool IsThingCulled(AActor *thing); + static FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); private: visstyle_t GetSpriteVisStyle(AActor *thing, double z); - FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); }; diff --git a/src/r_poly_wallsprite.cpp b/src/r_poly_wallsprite.cpp index 86ddd52a9..63472e297 100644 --- a/src/r_poly_wallsprite.cpp +++ b/src/r_poly_wallsprite.cpp @@ -28,8 +28,102 @@ #include "r_poly_wallsprite.h" #include "r_poly.h" -void RenderPolyWallSprite::Render(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) +void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth) { if (RenderPolySprite::IsThingCulled(thing)) return; + + DVector3 pos = thing->InterpolatedPosition(r_TicFracF); + pos.Z += thing->GetBobOffset(r_TicFracF); + + bool flipTextureX = false; + FTexture *tex = RenderPolySprite::GetSpriteTexture(thing, flipTextureX); + if (tex == nullptr) + return; + + DVector2 spriteScale = thing->Scale; + double thingxscalemul = spriteScale.X / tex->Scale.X; + double thingyscalemul = spriteScale.Y / tex->Scale.Y; + double spriteHeight = thingyscalemul * tex->GetHeight(); + + DAngle ang = thing->Angles.Yaw + 90; + double angcos = ang.Cos(); + double angsin = ang.Sin(); + + // Determine left and right edges of sprite. The sprite's angle is its normal, + // so the edges are 90 degrees each side of it. + double x2 = tex->GetScaledWidth() * spriteScale.X; + double x1 = tex->GetScaledLeftOffset() * spriteScale.X; + DVector2 left, right; + left.X = pos.X - x1 * angcos; + left.Y = pos.Y - x1 * angsin; + right.X = left.X + x2 * angcos; + right.Y = right.Y + x2 * angsin; + + //int scaled_to = tex->GetScaledTopOffset(); + //int scaled_bo = scaled_to - tex->GetScaledHeight(); + //gzt = pos.Z + scale.Y * scaled_to; + //gzb = pos.Z + scale.Y * scaled_bo; + + DVector2 points[2] = { right, left }; + + TriVertex *vertices = PolyVertexBuffer::GetVertices(4); + if (!vertices) + return; + + bool foggy = false; + int actualextralight = foggy ? 0 : extralight << 4; + + std::pair offsets[4] = + { + { 0.0f, 1.0f }, + { 1.0f, 1.0f }, + { 1.0f, 0.0f }, + { 0.0f, 0.0f }, + }; + + for (int i = 0; i < 4; i++) + { + auto &p = (i == 0 || i == 3) ? points[0] : points[1]; + + vertices[i].x = (float)p.X; + vertices[i].y = (float)p.Y; + vertices[i].z = (float)(pos.Z + spriteHeight * offsets[i].second); + vertices[i].w = 1.0f; + vertices[i].varying[0] = (float)(offsets[i].first * tex->Scale.X); + vertices[i].varying[1] = (float)((1.0f - offsets[i].second) * tex->Scale.Y); + if (flipTextureX) + vertices[i].varying[0] = 1.0f - vertices[i].varying[0]; + } + + bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT)); + + TriUniforms uniforms; + uniforms.objectToClip = worldToClip; + if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) + { + uniforms.light = 256; + uniforms.flags = TriUniforms::fixed_light; + } + else + { + uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f); + uniforms.flags = 0; + } + uniforms.subsectorDepth = subsectorDepth; + + PolyDrawArgs args; + args.uniforms = uniforms; + args.vinput = vertices; + args.vcount = 4; + args.mode = TriangleDrawMode::Fan; + args.ccw = true; + args.clipleft = 0; + args.cliptop = 0; + args.clipright = viewwidth; + args.clipbottom = viewheight; + args.stenciltestvalue = 0; + args.stencilwritevalue = 1; + args.SetTexture(tex); + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector); } diff --git a/src/r_poly_wallsprite.h b/src/r_poly_wallsprite.h index ce6917e58..dd4ba28da 100644 --- a/src/r_poly_wallsprite.h +++ b/src/r_poly_wallsprite.h @@ -27,5 +27,5 @@ class RenderPolyWallSprite { public: - void Render(AActor *thing, subsector_t *sub, uint32_t subsectorDepth); + void Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth); }; From ff2ab61abc4a87ddbfc69b1b258e4f398908ff41 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 16 Nov 2016 23:34:05 +0100 Subject: [PATCH 1234/1509] Added decals --- src/CMakeLists.txt | 1 + src/r_poly_decal.cpp | 159 ++++++++++++++++++++++++++++++++++++++ src/r_poly_decal.h | 34 ++++++++ src/r_poly_wall.cpp | 3 + src/r_poly_wallsprite.cpp | 2 +- 5 files changed, 198 insertions(+), 1 deletion(-) create mode 100644 src/r_poly_decal.cpp create mode 100644 src/r_poly_decal.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index baef29c21..34e0e72d0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1070,6 +1070,7 @@ set( FASTMATH_PCH_SOURCES r_swrenderer.cpp r_poly.cpp r_poly_cull.cpp + r_poly_decal.cpp r_poly_particle.cpp r_poly_plane.cpp r_poly_playersprite.cpp diff --git a/src/r_poly_decal.cpp b/src/r_poly_decal.cpp new file mode 100644 index 000000000..af9c53a89 --- /dev/null +++ b/src/r_poly_decal.cpp @@ -0,0 +1,159 @@ +/* +** Handling drawing a decal +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "sbar.h" +#include "r_data/r_translate.h" +#include "r_poly_decal.h" +#include "r_poly.h" +#include "a_sharedglobal.h" + +void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const seg_t *line, uint32_t subsectorDepth) +{ + for (DBaseDecal *decal = line->sidedef->AttachedDecals; decal != nullptr; decal = decal->WallNext) + { + RenderPolyDecal render; + render.Render(worldToClip, decal, line, subsectorDepth); + } +} + +void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth) +{ + if (decal->RenderFlags & RF_INVISIBLE || !viewactive || !decal->PicNum.isValid()) + return; + + FTexture *tex = TexMan(decal->PicNum, true); + if (tex == nullptr || tex->UseType == FTexture::TEX_Null) + return; + + double edge_right = tex->GetWidth(); + double edge_left = tex->LeftOffset; + edge_right = (edge_right - edge_left) * decal->ScaleX; + edge_left *= decal->ScaleX; + + double dcx, dcy; + decal->GetXY(line->sidedef, dcx, dcy); + DVector2 decal_pos = { dcx, dcy }; + + DVector2 angvec = (line->v2->fPos() - line->v1->fPos()).Unit(); + DVector2 decal_left = decal_pos - edge_left * angvec; + DVector2 decal_right = decal_pos + edge_right * angvec; + + // Determine actor z + double zpos = decal->Z; + sector_t *front = line->frontsector; + sector_t *back = (line->backsector != nullptr) ? line->backsector : line->frontsector; + switch (decal->RenderFlags & RF_RELMASK) + { + default: + zpos = decal->Z; + break; + case RF_RELUPPER: + if (line->linedef->flags & ML_DONTPEGTOP) + zpos = decal->Z + front->GetPlaneTexZ(sector_t::ceiling); + else + zpos = decal->Z + back->GetPlaneTexZ(sector_t::ceiling); + break; + case RF_RELLOWER: + if (line->linedef->flags & ML_DONTPEGBOTTOM) + zpos = decal->Z + front->GetPlaneTexZ(sector_t::ceiling); + else + zpos = decal->Z + back->GetPlaneTexZ(sector_t::floor); + break; + case RF_RELMID: + if (line->linedef->flags & ML_DONTPEGBOTTOM) + zpos = decal->Z + front->GetPlaneTexZ(sector_t::floor); + else + zpos = decal->Z + front->GetPlaneTexZ(sector_t::ceiling); + } + + DVector2 spriteScale = { decal->ScaleX, decal->ScaleY }; + double thingxscalemul = spriteScale.X / tex->Scale.X; + double thingyscalemul = spriteScale.Y / tex->Scale.Y; + double spriteHeight = thingyscalemul * tex->GetHeight(); + + bool flipTextureX = (decal->RenderFlags & RF_XFLIP) == RF_XFLIP; + + DVector2 points[2] = { decal_left, decal_right }; + + TriVertex *vertices = PolyVertexBuffer::GetVertices(4); + if (!vertices) + return; + + bool foggy = false; + int actualextralight = foggy ? 0 : extralight << 4; + + std::pair offsets[4] = + { + { 0.0f, 1.0f }, + { 1.0f, 1.0f }, + { 1.0f, 0.0f }, + { 0.0f, 0.0f }, + }; + + for (int i = 0; i < 4; i++) + { + auto &p = (i == 0 || i == 3) ? points[0] : points[1]; + + vertices[i].x = (float)p.X; + vertices[i].y = (float)p.Y; + vertices[i].z = (float)(zpos + spriteHeight * offsets[i].second); + vertices[i].w = 1.0f; + vertices[i].varying[0] = (float)(offsets[i].first * tex->Scale.X); + vertices[i].varying[1] = (float)((1.0f - offsets[i].second) * tex->Scale.Y); + if (flipTextureX) + vertices[i].varying[0] = 1.0f - vertices[i].varying[0]; + } + + bool fullbrightSprite = (decal->RenderFlags & RF_FULLBRIGHT) == RF_FULLBRIGHT; + + TriUniforms uniforms; + uniforms.objectToClip = worldToClip; + if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) + { + uniforms.light = 256; + uniforms.flags = TriUniforms::fixed_light; + } + else + { + uniforms.light = (uint32_t)((front->lightlevel + actualextralight) / 255.0f * 256.0f); + uniforms.flags = 0; + } + uniforms.subsectorDepth = subsectorDepth; + + PolyDrawArgs args; + args.uniforms = uniforms; + args.vinput = vertices; + args.vcount = 4; + args.mode = TriangleDrawMode::Fan; + args.ccw = true; + args.clipleft = 0; + args.cliptop = 0; + args.clipright = viewwidth; + args.clipbottom = viewheight; + args.stenciltestvalue = 0; + args.stencilwritevalue = 1; + args.SetTexture(tex); + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector); +} diff --git a/src/r_poly_decal.h b/src/r_poly_decal.h new file mode 100644 index 000000000..39b250abb --- /dev/null +++ b/src/r_poly_decal.h @@ -0,0 +1,34 @@ +/* +** Handling drawing a decal +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +#include "r_triangle.h" + +class RenderPolyDecal +{ +public: + static void RenderWallDecals(const TriMatrix &worldToClip, const seg_t *line, uint32_t subsectorDepth); + +private: + void Render(const TriMatrix &worldToClip, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth); +}; diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index 6921b1a33..2ed225cf2 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -26,6 +26,7 @@ #include "sbar.h" #include "r_data/r_translate.h" #include "r_poly_wall.h" +#include "r_poly_decal.h" #include "r_poly.h" #include "r_sky.h" // for skyflatnum @@ -203,6 +204,8 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) { PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector); } + + RenderPolyDecal::RenderWallDecals(worldToClip, Line, SubsectorDepth); } void RenderPolyWall::ClampHeight(TriVertex &v1, TriVertex &v2) diff --git a/src/r_poly_wallsprite.cpp b/src/r_poly_wallsprite.cpp index 63472e297..c6b3a6569 100644 --- a/src/r_poly_wallsprite.cpp +++ b/src/r_poly_wallsprite.cpp @@ -65,7 +65,7 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, AActor *thing, s //gzt = pos.Z + scale.Y * scaled_to; //gzb = pos.Z + scale.Y * scaled_bo; - DVector2 points[2] = { right, left }; + DVector2 points[2] = { left, right }; TriVertex *vertices = PolyVertexBuffer::GetVertices(4); if (!vertices) From 266924600aa33042d955d4c27c98ea52a132361c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 17 Nov 2016 01:28:51 +0100 Subject: [PATCH 1235/1509] Missing include guard --- src/p_effect.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_effect.h b/src/p_effect.h index 614702a49..eb417d63c 100644 --- a/src/p_effect.h +++ b/src/p_effect.h @@ -31,6 +31,8 @@ ** */ +#pragma once + #include "vectors.h" #define FX_ROCKET 0x00000001 From 511eb59479d13741aa6addc8b9d19b9e770d3822 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 17 Nov 2016 01:29:08 +0100 Subject: [PATCH 1236/1509] Add particle drawing --- .../fixedfunction/drawtrianglecodegen.cpp | 16 +++-- src/r_compiler/llvmdrawers.cpp | 4 ++ src/r_compiler/llvmdrawers.h | 3 + src/r_poly.cpp | 18 ++++- src/r_poly.h | 3 + src/r_poly_particle.cpp | 72 ++++++++++++++++++- src/r_poly_particle.h | 5 +- src/r_poly_triangle.cpp | 2 + 8 files changed, 113 insertions(+), 10 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index 11bdad7e4..7368fa121 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -260,7 +260,7 @@ void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) SetStencilBlock(x / 8 + y / 8 * stencilPitch); SSABool covered = a == SSAInt(0xF) && b == SSAInt(0xF) && c == SSAInt(0xF) && !clipneeded; - if (variant != TriDrawVariant::DrawSubsector) + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector) { covered = covered && StencilIsSingleValue(); } @@ -287,7 +287,7 @@ void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) void DrawTriangleCodegen::LoopFullBlock(TriDrawVariant variant, bool truecolor) { SSAIfBlock branch_stenciltest; - if (variant != TriDrawVariant::DrawSubsector) + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector) { branch_stenciltest.if_block(StencilGetSingle() == stencilTestValue); } @@ -325,7 +325,7 @@ void DrawTriangleCodegen::LoopFullBlock(TriDrawVariant variant, bool truecolor) varying[i] = stack_varying[i].load(); loopx.loop_block(ix < SSAInt(q), q); { - if (variant == TriDrawVariant::DrawSubsector) + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector) { SSAIfBlock branch; branch.if_block(subsectorbuffer[ix].load(true) >= subsectorDepth); @@ -353,7 +353,7 @@ void DrawTriangleCodegen::LoopFullBlock(TriDrawVariant variant, bool truecolor) loopy.end_block(); } - if (variant != TriDrawVariant::DrawSubsector) + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector) { branch_stenciltest.end_block(); } @@ -404,7 +404,7 @@ void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolo SSABool visible = (ix + x >= clipleft) && (ix + x < clipright) && (cliptop <= y + iy) && (clipbottom > y + iy); SSABool covered = CX1 > SSAInt(0) && CX2 > SSAInt(0) && CX3 > SSAInt(0) && visible; - if (variant == TriDrawVariant::DrawSubsector) + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector) { covered = covered && subsectorbuffer[ix].load(true) >= subsectorDepth; } @@ -449,7 +449,7 @@ void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolo void DrawTriangleCodegen::ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbuffer, SSAInt *varying, TriDrawVariant variant, bool truecolor) { - if (variant == TriDrawVariant::Fill) + if (variant == TriDrawVariant::Fill || variant == TriDrawVariant::FillSubsector) { if (truecolor) { @@ -459,7 +459,9 @@ void DrawTriangleCodegen::ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbu { //buffer.store(solidcolor); } - subsectorbuffer.store(subsectorDepth); + + if (variant != TriDrawVariant::FillSubsector) + subsectorbuffer.store(subsectorDepth); } else { diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index b3d893153..e7b9f6e5c 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -190,6 +190,8 @@ LLVMDrawersImpl::LLVMDrawersImpl() CodegenDrawTriangle("TriDraw32", TriDrawVariant::Draw, true); CodegenDrawTriangle("TriDrawSubsector8", TriDrawVariant::DrawSubsector, false); CodegenDrawTriangle("TriDrawSubsector32", TriDrawVariant::DrawSubsector, true); + CodegenDrawTriangle("TriFillSubsector8", TriDrawVariant::FillSubsector, false); + CodegenDrawTriangle("TriFillSubsector32", TriDrawVariant::FillSubsector, true); CodegenDrawTriangle("TriFill8", TriDrawVariant::Fill, false); CodegenDrawTriangle("TriFill32", TriDrawVariant::Fill, true); CodegenDrawTriangle("TriStencil", TriDrawVariant::Stencil, false); @@ -262,6 +264,8 @@ LLVMDrawersImpl::LLVMDrawersImpl() TriDraw32 = mProgram.GetProcAddress("TriDraw32"); TriDrawSubsector8 = mProgram.GetProcAddress("TriDrawSubsector8"); TriDrawSubsector32 = mProgram.GetProcAddress("TriDrawSubsector32"); + TriFillSubsector8 = mProgram.GetProcAddress("TriFillSubsector8"); + TriFillSubsector32 = mProgram.GetProcAddress("TriFillSubsector32"); TriFill8 = mProgram.GetProcAddress("TriFill8"); TriFill32 = mProgram.GetProcAddress("TriFill32"); TriStencil = mProgram.GetProcAddress("TriStencil"); diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 38f0f82d1..e7a34b962 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -266,6 +266,7 @@ enum class TriDrawVariant DrawMasked, Fill, DrawSubsector, + FillSubsector, Stencil, }; @@ -348,6 +349,8 @@ public: void(*TriDraw32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; void(*TriDrawSubsector8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; void(*TriDrawSubsector32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + void(*TriFillSubsector8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + void(*TriFillSubsector32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; void(*TriFill8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; void(*TriFill32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; void(*TriStencil)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 919b2ff78..d4f24be59 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -111,6 +111,17 @@ void RenderPolyScene::RenderSubsector(subsector_t *sub) RenderLine(sub, line, frontsector, subsectorDepth); } + bool mainBSP = ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors); + if (mainBSP) + { + int subsectorIndex = (int)(sub - subsectors); + for (int i = ParticlesInSubsec[subsectorIndex]; i != NO_PARTICLE; i = Particles[i].snext) + { + particle_t *particle = Particles + i; + TranslucentObjects.push_back({ particle, sub, subsectorDepth }); + } + } + SpriteRange sprites = GetSpritesForSector(sub->sector); for (int i = 0; i < sprites.Count; i++) { @@ -176,7 +187,12 @@ void RenderPolyScene::RenderTranslucent() for (auto it = TranslucentObjects.rbegin(); it != TranslucentObjects.rend(); ++it) { auto &obj = *it; - if (!obj.thing) + if (obj.particle) + { + RenderPolyParticle spr; + spr.Render(WorldToClip, obj.particle, obj.sub, obj.subsectorDepth); + } + else if (!obj.thing) { obj.wall.Render(WorldToClip); } diff --git a/src/r_poly.h b/src/r_poly.h index 4f7eca61d..f18f8a3cd 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -35,6 +35,7 @@ #include "r_poly_sprite.h" #include "r_poly_wallsprite.h" #include "r_poly_playersprite.h" +#include "r_poly_particle.h" #include "r_poly_plane.h" #include "r_poly_sky.h" #include "r_poly_cull.h" @@ -53,9 +54,11 @@ public: class PolyTranslucentObject { public: + PolyTranslucentObject(particle_t *particle, subsector_t *sub, uint32_t subsectorDepth) : particle(particle), sub(sub), subsectorDepth(subsectorDepth) { } PolyTranslucentObject(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) : thing(thing), sub(sub), subsectorDepth(subsectorDepth) { } PolyTranslucentObject(RenderPolyWall wall) : wall(wall) { } + particle_t *particle = nullptr; AActor *thing = nullptr; subsector_t *sub = nullptr; uint32_t subsectorDepth = 0; diff --git a/src/r_poly_particle.cpp b/src/r_poly_particle.cpp index 06b963e4f..f0b221988 100644 --- a/src/r_poly_particle.cpp +++ b/src/r_poly_particle.cpp @@ -28,6 +28,76 @@ #include "r_poly_particle.h" #include "r_poly.h" -void RenderPolyParticle::Render() +void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth) { + DVector3 pos = particle->Pos; + double psize = particle->size / 8.0; + double zpos = pos.Z; + + DVector2 points[2] = + { + { pos.X - ViewSin * psize, pos.Y + ViewCos * psize }, + { pos.X + ViewSin * psize, pos.Y - ViewCos * psize } + }; + + TriVertex *vertices = PolyVertexBuffer::GetVertices(4); + if (!vertices) + return; + + bool foggy = false; + int actualextralight = foggy ? 0 : extralight << 4; + + std::pair offsets[4] = + { + { 0.0f, 1.0f }, + { 1.0f, 1.0f }, + { 1.0f, 0.0f }, + { 0.0f, 0.0f }, + }; + + for (int i = 0; i < 4; i++) + { + auto &p = (i == 0 || i == 3) ? points[0] : points[1]; + + vertices[i].x = (float)p.X; + vertices[i].y = (float)p.Y; + vertices[i].z = (float)(zpos + psize * (2.0 * offsets[i].second - 1.0)); + vertices[i].w = 1.0f; + vertices[i].varying[0] = (float)(offsets[i].first); + vertices[i].varying[1] = (float)(1.0f - offsets[i].second); + } + + // int color = (particle->color >> 24) & 0xff; // pal index, I think + bool fullbrightSprite = particle->bright != 0; + + TriUniforms uniforms; + uniforms.objectToClip = worldToClip; + if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) + { + uniforms.light = 256; + uniforms.flags = TriUniforms::fixed_light; + } + else + { + uniforms.light = (uint32_t)((sub->sector->lightlevel + actualextralight) / 255.0f * 256.0f); + uniforms.flags = 0; + } + uniforms.subsectorDepth = subsectorDepth; + + uint32_t alpha = particle->trans; + + PolyDrawArgs args; + args.uniforms = uniforms; + args.vinput = vertices; + args.vcount = 4; + args.mode = TriangleDrawMode::Fan; + args.ccw = true; + args.clipleft = 0; + args.cliptop = 0; + args.clipright = viewwidth; + args.clipbottom = viewheight; + args.stenciltestvalue = 0; + args.stencilwritevalue = 1; + args.solidcolor = (alpha << 24) | (particle->color & 0xffffff); + PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector); } diff --git a/src/r_poly_particle.h b/src/r_poly_particle.h index 5573a7e48..f4218a310 100644 --- a/src/r_poly_particle.h +++ b/src/r_poly_particle.h @@ -22,8 +22,11 @@ #pragma once +#include "r_poly_triangle.h" +#include "p_effect.h" + class RenderPolyParticle { public: - void Render(); + void Render(const TriMatrix &worldToClip, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth); }; diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 3d444d2ad..6426bae4e 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -62,6 +62,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian case TriDrawVariant::Draw: drawfunc = r_swtruecolor ? llvm->TriDraw32: llvm->TriDraw8; break; case TriDrawVariant::Fill: drawfunc = r_swtruecolor ? llvm->TriFill32 : llvm->TriFill8; break; case TriDrawVariant::DrawSubsector: drawfunc = r_swtruecolor ? llvm->TriDrawSubsector32 : llvm->TriDrawSubsector8; break; + case TriDrawVariant::FillSubsector: drawfunc = r_swtruecolor ? llvm->TriFillSubsector32 : llvm->TriFillSubsector8; break; case TriDrawVariant::Stencil: drawfunc = llvm->TriStencil; break; } #else @@ -69,6 +70,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian { default: case TriDrawVariant::Draw: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::draw32 : ScreenPolyTriangleDrawer::draw; break; + case TriDrawVariant::FillSubsector: case TriDrawVariant::Fill: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::fill32 : ScreenPolyTriangleDrawer::fill; break; case TriDrawVariant::DrawSubsector: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::drawsubsector32 : llvm->TriDrawSubsector8; break; case TriDrawVariant::Stencil: drawfunc = ScreenPolyTriangleDrawer::stencil; break; From b02e3d9514af94c39b9125f7408c7e7754c2be8b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 17 Nov 2016 14:28:14 +0100 Subject: [PATCH 1237/1509] Add shaded blend mode for the decals --- .../fixedfunction/drawtrianglecodegen.cpp | 34 +++++++++++++------ src/r_compiler/llvmdrawers.cpp | 4 +++ src/r_compiler/llvmdrawers.h | 3 ++ src/r_poly_decal.cpp | 4 ++- src/r_poly_triangle.cpp | 2 ++ 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index 7368fa121..6f9af51fc 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -260,7 +260,7 @@ void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) SetStencilBlock(x / 8 + y / 8 * stencilPitch); SSABool covered = a == SSAInt(0xF) && b == SSAInt(0xF) && c == SSAInt(0xF) && !clipneeded; - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector) + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::DrawShadedSubsector && variant != TriDrawVariant::FillSubsector) { covered = covered && StencilIsSingleValue(); } @@ -287,7 +287,7 @@ void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) void DrawTriangleCodegen::LoopFullBlock(TriDrawVariant variant, bool truecolor) { SSAIfBlock branch_stenciltest; - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector) + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::DrawShadedSubsector && variant != TriDrawVariant::FillSubsector) { branch_stenciltest.if_block(StencilGetSingle() == stencilTestValue); } @@ -325,7 +325,7 @@ void DrawTriangleCodegen::LoopFullBlock(TriDrawVariant variant, bool truecolor) varying[i] = stack_varying[i].load(); loopx.loop_block(ix < SSAInt(q), q); { - if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector) + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::DrawShadedSubsector || variant == TriDrawVariant::FillSubsector) { SSAIfBlock branch; branch.if_block(subsectorbuffer[ix].load(true) >= subsectorDepth); @@ -353,7 +353,7 @@ void DrawTriangleCodegen::LoopFullBlock(TriDrawVariant variant, bool truecolor) loopy.end_block(); } - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector) + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::DrawShadedSubsector && variant != TriDrawVariant::FillSubsector) { branch_stenciltest.end_block(); } @@ -404,7 +404,7 @@ void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolo SSABool visible = (ix + x >= clipleft) && (ix + x < clipright) && (cliptop <= y + iy) && (clipbottom > y + iy); SSABool covered = CX1 > SSAInt(0) && CX2 > SSAInt(0) && CX3 > SSAInt(0) && visible; - if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector) + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::DrawShadedSubsector || variant == TriDrawVariant::FillSubsector) { covered = covered && subsectorbuffer[ix].load(true) >= subsectorDepth; } @@ -474,13 +474,13 @@ void DrawTriangleCodegen::ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbu if (truecolor) { - SSAVec4i fg = texturePixels[uvoffset * 4].load_vec4ub(true); - SSAInt fg_alpha = fg[3]; - fg = (fg * currentlight) >> 8; - fg.insert(3, fg_alpha); - if (variant == TriDrawVariant::DrawMasked || variant == TriDrawVariant::DrawSubsector) { + SSAVec4i fg = texturePixels[uvoffset * 4].load_vec4ub(true); + SSAInt fg_alpha = fg[3]; + fg = (fg * currentlight) >> 8; + fg.insert(3, fg_alpha); + SSAIfBlock branch_transparency; branch_transparency.if_block(fg_alpha > SSAInt(127)); { @@ -490,8 +490,22 @@ void DrawTriangleCodegen::ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbu } branch_transparency.end_block(); } + else if (variant == TriDrawVariant::DrawShadedSubsector) + { + SSAInt alpha = texturePixels[uvoffset * 4].load(true).zext_int(); + alpha = alpha + (alpha >> 7); // // 255 -> 256 + SSAInt inv_alpha = 256 - alpha; + + SSAVec4i bgcolor = buffer.load_vec4ub(false); + buffer.store_vec4ub(blend_add(shade_bgra_simple(SSAVec4i::unpack(solidcolor), currentlight), bgcolor, alpha, inv_alpha)); + } else { + SSAVec4i fg = texturePixels[uvoffset * 4].load_vec4ub(true); + SSAInt fg_alpha = fg[3]; + fg = (fg * currentlight) >> 8; + fg.insert(3, fg_alpha); + buffer.store_vec4ub(fg); subsectorbuffer.store(subsectorDepth); } diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index e7b9f6e5c..458d90d1a 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -190,6 +190,8 @@ LLVMDrawersImpl::LLVMDrawersImpl() CodegenDrawTriangle("TriDraw32", TriDrawVariant::Draw, true); CodegenDrawTriangle("TriDrawSubsector8", TriDrawVariant::DrawSubsector, false); CodegenDrawTriangle("TriDrawSubsector32", TriDrawVariant::DrawSubsector, true); + CodegenDrawTriangle("TriDrawShadedSubsector8", TriDrawVariant::DrawShadedSubsector, false); + CodegenDrawTriangle("TriDrawShadedSubsector32", TriDrawVariant::DrawShadedSubsector, true); CodegenDrawTriangle("TriFillSubsector8", TriDrawVariant::FillSubsector, false); CodegenDrawTriangle("TriFillSubsector32", TriDrawVariant::FillSubsector, true); CodegenDrawTriangle("TriFill8", TriDrawVariant::Fill, false); @@ -264,6 +266,8 @@ LLVMDrawersImpl::LLVMDrawersImpl() TriDraw32 = mProgram.GetProcAddress("TriDraw32"); TriDrawSubsector8 = mProgram.GetProcAddress("TriDrawSubsector8"); TriDrawSubsector32 = mProgram.GetProcAddress("TriDrawSubsector32"); + TriDrawShadedSubsector8 = mProgram.GetProcAddress("TriDrawShadedSubsector8"); + TriDrawShadedSubsector32 = mProgram.GetProcAddress("TriDrawShadedSubsector32"); TriFillSubsector8 = mProgram.GetProcAddress("TriFillSubsector8"); TriFillSubsector32 = mProgram.GetProcAddress("TriFillSubsector32"); TriFill8 = mProgram.GetProcAddress("TriFill8"); diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index e7a34b962..9c3a3e45f 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -266,6 +266,7 @@ enum class TriDrawVariant DrawMasked, Fill, DrawSubsector, + DrawShadedSubsector, FillSubsector, Stencil, }; @@ -349,6 +350,8 @@ public: void(*TriDraw32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; void(*TriDrawSubsector8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; void(*TriDrawSubsector32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + void(*TriDrawShadedSubsector8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + void(*TriDrawShadedSubsector32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; void(*TriFillSubsector8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; void(*TriFillSubsector32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; void(*TriFill8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; diff --git a/src/r_poly_decal.cpp b/src/r_poly_decal.cpp index af9c53a89..011ce83e4 100644 --- a/src/r_poly_decal.cpp +++ b/src/r_poly_decal.cpp @@ -155,5 +155,7 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector); + args.solidcolor = decal->AlphaColor; + //mode = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawShadedSubsector); } diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 6426bae4e..64611376b 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -62,6 +62,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian case TriDrawVariant::Draw: drawfunc = r_swtruecolor ? llvm->TriDraw32: llvm->TriDraw8; break; case TriDrawVariant::Fill: drawfunc = r_swtruecolor ? llvm->TriFill32 : llvm->TriFill8; break; case TriDrawVariant::DrawSubsector: drawfunc = r_swtruecolor ? llvm->TriDrawSubsector32 : llvm->TriDrawSubsector8; break; + case TriDrawVariant::DrawShadedSubsector: drawfunc = r_swtruecolor ? llvm->TriDrawShadedSubsector32 : llvm->TriDrawShadedSubsector8; break; case TriDrawVariant::FillSubsector: drawfunc = r_swtruecolor ? llvm->TriFillSubsector32 : llvm->TriFillSubsector8; break; case TriDrawVariant::Stencil: drawfunc = llvm->TriStencil; break; } @@ -72,6 +73,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian case TriDrawVariant::Draw: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::draw32 : ScreenPolyTriangleDrawer::draw; break; case TriDrawVariant::FillSubsector: case TriDrawVariant::Fill: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::fill32 : ScreenPolyTriangleDrawer::fill; break; + case TriDrawVariant::DrawShadedSubsector: case TriDrawVariant::DrawSubsector: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::drawsubsector32 : llvm->TriDrawSubsector8; break; case TriDrawVariant::Stencil: drawfunc = ScreenPolyTriangleDrawer::stencil; break; } From 7447c49dc5c87639f1cf88c5bb7285ce44c08cbb Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 17 Nov 2016 02:50:54 -0500 Subject: [PATCH 1238/1509] - Added pixelratio support for the softpoly renderer. --- src/r_poly.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index d4f24be59..25fae638e 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -26,8 +26,10 @@ #include "sbar.h" #include "r_data/r_translate.h" #include "r_poly.h" +#include "gl/data/gl_data.h" CVAR(Bool, r_debug_cull, 0, 0) +void InitGLRMapinfoData(); ///////////////////////////////////////////////////////////////////////////// @@ -66,13 +68,24 @@ void RenderPolyScene::ClearBuffers() void RenderPolyScene::SetupPerspectiveMatrix() { + static bool bDidSetup = false; + + if (!bDidSetup) + { + InitGLRMapinfoData(); + bDidSetup = true; + } + + float pixelstretch = (glset.pixelstretch) ? glset.pixelstretch : 1.2; + float ratio = WidescreenRatio; float fovratio = (WidescreenRatio >= 1.3f) ? 1.333333f : ratio; float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(FieldOfView.Radians() / 2) / fovratio)).Degrees); TriMatrix worldToView = - TriMatrix::scale(1.0f, (float)YaspectMul, 1.0f) * + TriMatrix::scale(1.0f, 1.2f, 1.0f) * TriMatrix::rotate((float)ViewPitch.Radians(), 1.0f, 0.0f, 0.0f) * TriMatrix::rotate((float)(ViewAngle - 90).Radians(), 0.0f, -1.0f, 0.0f) * + TriMatrix::scale(1.0f, pixelstretch, 1.0f) * TriMatrix::swapYZ() * TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); WorldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; From eac9367acee82c78c381c6d8ffe535a24a0c8fc4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 17 Nov 2016 21:07:00 +0100 Subject: [PATCH 1239/1509] Fix perspective when status bar is visible --- src/r_poly.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 25fae638e..dd2df0ee4 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -29,6 +29,7 @@ #include "gl/data/gl_data.h" CVAR(Bool, r_debug_cull, 0, 0) +EXTERN_CVAR(Int, screenblocks) void InitGLRMapinfoData(); ///////////////////////////////////////////////////////////////////////////// @@ -76,17 +77,25 @@ void RenderPolyScene::SetupPerspectiveMatrix() bDidSetup = true; } - float pixelstretch = (glset.pixelstretch) ? glset.pixelstretch : 1.2; + int height; + if (screenblocks >= 10) + { + height = SCREENHEIGHT; + } + else + { + height = (screenblocks*SCREENHEIGHT / 10) & ~7; + } + viewheight = height; // So viewheight was calculated incorrectly. That's just.. wonderful. float ratio = WidescreenRatio; float fovratio = (WidescreenRatio >= 1.3f) ? 1.333333f : ratio; float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(FieldOfView.Radians() / 2) / fovratio)).Degrees); TriMatrix worldToView = - TriMatrix::scale(1.0f, 1.2f, 1.0f) * TriMatrix::rotate((float)ViewPitch.Radians(), 1.0f, 0.0f, 0.0f) * TriMatrix::rotate((float)(ViewAngle - 90).Radians(), 0.0f, -1.0f, 0.0f) * - TriMatrix::scale(1.0f, pixelstretch, 1.0f) * TriMatrix::swapYZ() * + TriMatrix::scale(1.0f, 1.0f, glset.pixelstretch) * TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); WorldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; } From 6be80efa5194f3472afa6d596652099d6020bc0d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 17 Nov 2016 21:19:50 +0100 Subject: [PATCH 1240/1509] Moved scale back to be after pitch - otherwise the the bullets don't end up where you point --- src/r_poly.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index dd2df0ee4..0c05a590a 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -92,10 +92,10 @@ void RenderPolyScene::SetupPerspectiveMatrix() float fovratio = (WidescreenRatio >= 1.3f) ? 1.333333f : ratio; float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(FieldOfView.Radians() / 2) / fovratio)).Degrees); TriMatrix worldToView = + TriMatrix::scale(1.0f, glset.pixelstretch, 1.0f) * TriMatrix::rotate((float)ViewPitch.Radians(), 1.0f, 0.0f, 0.0f) * TriMatrix::rotate((float)(ViewAngle - 90).Radians(), 0.0f, -1.0f, 0.0f) * TriMatrix::swapYZ() * - TriMatrix::scale(1.0f, 1.0f, glset.pixelstretch) * TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); WorldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; } From aa0828567605ebe30703803fd1d8d711ff245b3b Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 17 Nov 2016 16:44:55 -0500 Subject: [PATCH 1241/1509] - Moved scaling before rotation again - this time, using a formula provided by Graf, the rendering pitch is now dynamically scaled based on the aspect ratio, causing pitch aiming to once again be correct. --- src/r_poly.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 0c05a590a..ade89571e 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -88,13 +88,21 @@ void RenderPolyScene::SetupPerspectiveMatrix() } viewheight = height; // So viewheight was calculated incorrectly. That's just.. wonderful. + // Code provided courtesy of Graf Zahl. Now we just have to plug it into the viewmatrix code... + // We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1. + double radPitch = ViewPitch.Normalized180().Radians(); + double angx = cos(radPitch); + double angy = sin(radPitch) * glset.pixelstretch; + double alen = sqrt(angx*angx + angy*angy); + //mAngles.Pitch = (float)RAD2DEG(asin(angy / alen)); + float ratio = WidescreenRatio; float fovratio = (WidescreenRatio >= 1.3f) ? 1.333333f : ratio; float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(FieldOfView.Radians() / 2) / fovratio)).Degrees); TriMatrix worldToView = - TriMatrix::scale(1.0f, glset.pixelstretch, 1.0f) * - TriMatrix::rotate((float)ViewPitch.Radians(), 1.0f, 0.0f, 0.0f) * + TriMatrix::rotate((float)asin(angy / alen), 1.0f, 0.0f, 0.0f) * TriMatrix::rotate((float)(ViewAngle - 90).Radians(), 0.0f, -1.0f, 0.0f) * + TriMatrix::scale(1.0f, glset.pixelstretch, 1.0f) * TriMatrix::swapYZ() * TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); WorldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; From b3b5cb2fa410554edb095fb0515ed6cc17098145 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 17 Nov 2016 23:13:17 +0100 Subject: [PATCH 1242/1509] - fixed: Lines with both sides in the same sector but an active portal may not be discarded early. --- src/gl/scene/gl_bsp.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index 7b9830050..f0ddfd642 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -140,12 +140,15 @@ static void AddLine (seg_t *seg, bool portalclip) { if (currentsector->sectornum == seg->backsector->sectornum) { - FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::mid)); - if (!tex || tex->UseType==FTexture::TEX_Null) + if (!seg->linedef->isVisualPortal()) { - // nothing to do here! - seg->linedef->validcount=validcount; - return; + FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::mid)); + if (!tex || tex->UseType==FTexture::TEX_Null) + { + // nothing to do here! + seg->linedef->validcount=validcount; + return; + } } backsector=currentsector; } From dbb6c7ca27e7fd8017906356c73b50b6a903415a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 18 Nov 2016 01:58:39 +0100 Subject: [PATCH 1243/1509] Add support for specifying a viewport out of screen bounds and fixed statusbar by doing just that! --- .../fixedfunction/drawtrianglecodegen.cpp | 16 ++--- src/r_poly.cpp | 13 ++-- src/r_poly_decal.cpp | 4 -- src/r_poly_particle.cpp | 4 -- src/r_poly_plane.cpp | 8 --- src/r_poly_sky.cpp | 4 -- src/r_poly_sprite.cpp | 4 -- src/r_poly_triangle.cpp | 66 ++++++++++++++----- src/r_poly_triangle.h | 9 +-- src/r_poly_wall.cpp | 4 -- src/r_poly_wallsprite.cpp | 4 -- 11 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index 6f9af51fc..8bf4779e2 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -78,10 +78,10 @@ void DrawTriangleCodegen::Setup(TriDrawVariant variant, bool truecolor) FDY31 = DY31 << 4; // Bounding rectangle - minx = SSAInt::MAX((SSAInt::MIN(SSAInt::MIN(X1, X2), X3) + 0xF) >> 4, clipleft); - maxx = SSAInt::MIN((SSAInt::MAX(SSAInt::MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); - miny = SSAInt::MAX((SSAInt::MIN(SSAInt::MIN(Y1, Y2), Y3) + 0xF) >> 4, cliptop); - maxy = SSAInt::MIN((SSAInt::MAX(SSAInt::MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); + minx = SSAInt::MAX((SSAInt::MIN(SSAInt::MIN(X1, X2), X3) + 0xF).ashr(4), clipleft); + maxx = SSAInt::MIN((SSAInt::MAX(SSAInt::MAX(X1, X2), X3) + 0xF).ashr(4), clipright - 1); + miny = SSAInt::MAX((SSAInt::MIN(SSAInt::MIN(Y1, Y2), Y3) + 0xF).ashr(4), cliptop); + maxy = SSAInt::MIN((SSAInt::MAX(SSAInt::MAX(Y1, Y2), Y3) + 0xF).ashr(4), clipbottom - 1); SSAIfBlock if0; if0.if_block(minx >= maxx || miny >= maxy); @@ -221,7 +221,7 @@ void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) branch.if_block(!(a == SSAInt(0) || b == SSAInt(0) || c == SSAInt(0))); // Check if block needs clipping - SSABool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); + SSABool clipneeded = x < clipleft || (x + q) > clipright || y < cliptop || (y + q) > clipbottom; // Calculate varying variables for affine block SSAFloat offx0 = SSAFloat(x - minx); @@ -401,7 +401,7 @@ void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolo varying[i] = stack_varying[i].load(); loopx.loop_block(ix < SSAInt(q), q); { - SSABool visible = (ix + x >= clipleft) && (ix + x < clipright) && (cliptop <= y + iy) && (clipbottom > y + iy); + SSABool visible = (ix + x >= clipleft) && (ix + x < clipright) && (iy + y >= cliptop) && (iy + y < clipbottom); SSABool covered = CX1 > SSAInt(0) && CX2 > SSAInt(0) && CX3 > SSAInt(0) && visible; if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::DrawShadedSubsector || variant == TriDrawVariant::FillSubsector) @@ -589,9 +589,9 @@ void DrawTriangleCodegen::LoadArgs(TriDrawVariant variant, bool truecolor, SSAVa v1 = LoadTriVertex(args[0][2].load(true)); v2 = LoadTriVertex(args[0][3].load(true)); v3 = LoadTriVertex(args[0][4].load(true)); - clipleft = args[0][5].load(true); + clipleft = SSAInt(0);// args[0][5].load(true); clipright = args[0][6].load(true); - cliptop = args[0][7].load(true); + cliptop = SSAInt(0);// args[0][7].load(true); clipbottom = args[0][8].load(true); texturePixels = args[0][9].load(true); textureWidth = args[0][10].load(true); diff --git a/src/r_poly.cpp b/src/r_poly.cpp index ade89571e..7a06a471e 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -62,8 +62,8 @@ void RenderPolyScene::ClearBuffers() SectorSpriteRanges.resize(numsectors); SortedSprites.clear(); TranslucentObjects.clear(); - PolyStencilBuffer::Instance()->Clear(viewwidth, viewheight, 0); - PolySubsectorGBuffer::Instance()->Resize(dc_pitch, viewheight); + PolyStencilBuffer::Instance()->Clear(screen->GetWidth(), screen->GetHeight(), 0); + PolySubsectorGBuffer::Instance()->Resize(screen->GetPitch(), screen->GetHeight()); NextSubsectorDepth = 0; } @@ -79,14 +79,12 @@ void RenderPolyScene::SetupPerspectiveMatrix() int height; if (screenblocks >= 10) - { height = SCREENHEIGHT; - } else - { height = (screenblocks*SCREENHEIGHT / 10) & ~7; - } - viewheight = height; // So viewheight was calculated incorrectly. That's just.. wonderful. + + int bottom = SCREENHEIGHT - (height + viewwindowy - ((height - viewheight) / 2)); + PolyTriangleDrawer::set_viewport(viewwindowx, SCREENHEIGHT - bottom - height, viewwidth, height, screen); // Code provided courtesy of Graf Zahl. Now we just have to plug it into the viewmatrix code... // We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1. @@ -105,6 +103,7 @@ void RenderPolyScene::SetupPerspectiveMatrix() TriMatrix::scale(1.0f, glset.pixelstretch, 1.0f) * TriMatrix::swapYZ() * TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); + WorldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; } diff --git a/src/r_poly_decal.cpp b/src/r_poly_decal.cpp index 011ce83e4..0c6c427a8 100644 --- a/src/r_poly_decal.cpp +++ b/src/r_poly_decal.cpp @@ -148,10 +148,6 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co args.vcount = 4; args.mode = TriangleDrawMode::Fan; args.ccw = true; - args.clipleft = 0; - args.cliptop = 0; - args.clipright = viewwidth; - args.clipbottom = viewheight; args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); diff --git a/src/r_poly_particle.cpp b/src/r_poly_particle.cpp index f0b221988..be8030071 100644 --- a/src/r_poly_particle.cpp +++ b/src/r_poly_particle.cpp @@ -92,10 +92,6 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *partic args.vcount = 4; args.mode = TriangleDrawMode::Fan; args.ccw = true; - args.clipleft = 0; - args.cliptop = 0; - args.clipright = viewwidth; - args.clipbottom = viewheight; args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.solidcolor = (alpha << 24) | (particle->color & 0xffffff); diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 5b0e912a8..9a425598b 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -137,10 +137,6 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *s args.vcount = sub->numlines; args.mode = TriangleDrawMode::Fan; args.ccw = true; - args.clipleft = 0; - args.cliptop = 0; - args.clipright = viewwidth; - args.clipbottom = viewheight; args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); @@ -233,10 +229,6 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin args.vcount = sub->numlines; args.mode = TriangleDrawMode::Fan; args.ccw = ccw; - args.clipleft = 0; - args.cliptop = 0; - args.clipright = viewwidth; - args.clipbottom = viewheight; args.stenciltestvalue = 0; args.stencilwritevalue = 1; diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp index 03a4bfdb2..fc6963dbb 100644 --- a/src/r_poly_sky.cpp +++ b/src/r_poly_sky.cpp @@ -59,10 +59,6 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) PolyDrawArgs args; args.uniforms = uniforms; - args.clipleft = 0; - args.cliptop = 0; - args.clipright = viewwidth; - args.clipbottom = viewheight; args.stenciltestvalue = 255; args.stencilwritevalue = 1; args.SetTexture(frontskytex); diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index 1701b24ef..e1c6fcc14 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -133,10 +133,6 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse args.vcount = 4; args.mode = TriangleDrawMode::Fan; args.ccw = true; - args.clipleft = 0; - args.cliptop = 0; - args.clipright = viewwidth; - args.clipbottom = viewheight; args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 64611376b..d661fe0d7 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -40,9 +40,41 @@ #include #endif +int PolyTriangleDrawer::viewport_x; +int PolyTriangleDrawer::viewport_y; +int PolyTriangleDrawer::viewport_width; +int PolyTriangleDrawer::viewport_height; +int PolyTriangleDrawer::dest_pitch; +int PolyTriangleDrawer::dest_width; +int PolyTriangleDrawer::dest_height; +uint8_t *PolyTriangleDrawer::dest; +bool PolyTriangleDrawer::dest_bgra; + +void PolyTriangleDrawer::set_viewport(int x, int y, int width, int height, DCanvas *canvas) +{ + dest = (uint8_t*)canvas->GetBuffer(); + dest_width = canvas->GetWidth(); + dest_height = canvas->GetHeight(); + dest_pitch = canvas->GetPitch(); + dest_bgra = canvas->IsBgra(); + + int offsetx = clamp(x, 0, dest_width); + int offsety = clamp(y, 0, dest_height); + int pixelsize = dest_bgra ? 4 : 1; + + viewport_x = x - offsetx; + viewport_y = y - offsety; + viewport_width = width; + viewport_height = height; + + dest += (offsetx + offsety * dest_pitch) * pixelsize; + dest_width = clamp(viewport_x + viewport_width, 0, dest_width - offsetx); + dest_height = clamp(viewport_y + viewport_height, 0, dest_height - offsety); +} + void PolyTriangleDrawer::draw(const PolyDrawArgs &args, TriDrawVariant variant) { - if (r_swtruecolor) + if (dest_bgra) DrawerCommandQueue::QueueCommand(args, variant); else draw_arrays(args, variant, nullptr); @@ -59,33 +91,33 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian switch (variant) { default: - case TriDrawVariant::Draw: drawfunc = r_swtruecolor ? llvm->TriDraw32: llvm->TriDraw8; break; - case TriDrawVariant::Fill: drawfunc = r_swtruecolor ? llvm->TriFill32 : llvm->TriFill8; break; - case TriDrawVariant::DrawSubsector: drawfunc = r_swtruecolor ? llvm->TriDrawSubsector32 : llvm->TriDrawSubsector8; break; - case TriDrawVariant::DrawShadedSubsector: drawfunc = r_swtruecolor ? llvm->TriDrawShadedSubsector32 : llvm->TriDrawShadedSubsector8; break; - case TriDrawVariant::FillSubsector: drawfunc = r_swtruecolor ? llvm->TriFillSubsector32 : llvm->TriFillSubsector8; break; + case TriDrawVariant::Draw: drawfunc = dest_bgra ? llvm->TriDraw32: llvm->TriDraw8; break; + case TriDrawVariant::Fill: drawfunc = dest_bgra ? llvm->TriFill32 : llvm->TriFill8; break; + case TriDrawVariant::DrawSubsector: drawfunc = dest_bgra ? llvm->TriDrawSubsector32 : llvm->TriDrawSubsector8; break; + case TriDrawVariant::DrawShadedSubsector: drawfunc = dest_bgra ? llvm->TriDrawShadedSubsector32 : llvm->TriDrawShadedSubsector8; break; + case TriDrawVariant::FillSubsector: drawfunc = dest_bgra ? llvm->TriFillSubsector32 : llvm->TriFillSubsector8; break; case TriDrawVariant::Stencil: drawfunc = llvm->TriStencil; break; } #else switch (variant) { default: - case TriDrawVariant::Draw: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::draw32 : ScreenPolyTriangleDrawer::draw; break; + case TriDrawVariant::Draw: drawfunc = dest_bgra ? ScreenPolyTriangleDrawer::draw32 : ScreenPolyTriangleDrawer::draw; break; case TriDrawVariant::FillSubsector: - case TriDrawVariant::Fill: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::fill32 : ScreenPolyTriangleDrawer::fill; break; + case TriDrawVariant::Fill: drawfunc = dest_bgra ? ScreenPolyTriangleDrawer::fill32 : ScreenPolyTriangleDrawer::fill; break; case TriDrawVariant::DrawShadedSubsector: - case TriDrawVariant::DrawSubsector: drawfunc = r_swtruecolor ? ScreenPolyTriangleDrawer::drawsubsector32 : llvm->TriDrawSubsector8; break; + case TriDrawVariant::DrawSubsector: drawfunc = dest_bgra ? ScreenPolyTriangleDrawer::drawsubsector32 : llvm->TriDrawSubsector8; break; case TriDrawVariant::Stencil: drawfunc = ScreenPolyTriangleDrawer::stencil; break; } #endif TriDrawTriangleArgs args; - args.dest = dc_destorg; - args.pitch = dc_pitch; - args.clipleft = drawargs.clipleft; - args.clipright = drawargs.clipright; - args.cliptop = drawargs.cliptop; - args.clipbottom = drawargs.clipbottom; + args.dest = dest; + args.pitch = dest_pitch; + args.clipleft = 0; + args.clipright = dest_width; + args.cliptop = 0; + args.clipbottom = dest_height; args.texturePixels = drawargs.texturePixels; args.textureWidth = drawargs.textureWidth; args.textureHeight = drawargs.textureHeight; @@ -163,8 +195,8 @@ void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, T v.z *= v.w; // Apply viewport scale to get screen coordinates: - v.x = viewwidth * (1.0f + v.x) * 0.5f; - v.y = viewheight * (1.0f - v.y) * 0.5f; + v.x = viewport_x + viewport_width * (1.0f + v.x) * 0.5f; + v.y = viewport_y + viewport_height * (1.0f - v.y) * 0.5f; } // Draw screen triangles diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index f3f63f8f1..8f2fcf3d0 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -36,10 +36,6 @@ public: int vcount = 0; TriangleDrawMode mode = TriangleDrawMode::Normal; bool ccw = false; - int clipleft = 0; - int clipright = 0; - int cliptop = 0; - int clipbottom = 0; const uint8_t *texturePixels = nullptr; int textureWidth = 0; int textureHeight = 0; @@ -61,6 +57,7 @@ public: class PolyTriangleDrawer { public: + static void set_viewport(int x, int y, int width, int height, DCanvas *canvas); static void draw(const PolyDrawArgs &args, TriDrawVariant variant); private: @@ -70,6 +67,10 @@ private: static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert); + static int viewport_x, viewport_y, viewport_width, viewport_height, dest_pitch, dest_width, dest_height; + static bool dest_bgra; + static uint8_t *dest; + enum { max_additional_vertices = 16 }; friend class DrawPolyTrianglesCommand; diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index 2ed225cf2..1f1908ab4 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -187,10 +187,6 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) args.vcount = 4; args.mode = TriangleDrawMode::Fan; args.ccw = true; - args.clipleft = 0; - args.cliptop = 0; - args.clipright = viewwidth; - args.clipbottom = viewheight; args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); diff --git a/src/r_poly_wallsprite.cpp b/src/r_poly_wallsprite.cpp index c6b3a6569..e2d1a9e86 100644 --- a/src/r_poly_wallsprite.cpp +++ b/src/r_poly_wallsprite.cpp @@ -118,10 +118,6 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, AActor *thing, s args.vcount = 4; args.mode = TriangleDrawMode::Fan; args.ccw = true; - args.clipleft = 0; - args.cliptop = 0; - args.clipright = viewwidth; - args.clipbottom = viewheight; args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); From 5d6ceb868e80450f2fc14c6e56bbc73953d597a1 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 18 Nov 2016 14:40:53 +0100 Subject: [PATCH 1244/1509] Move viewport stuff to its own function --- src/r_poly.cpp | 30 ++++++++++++++++++------------ src/r_poly.h | 1 + 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 7a06a471e..4dc90027d 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -40,6 +40,7 @@ void RenderPolyScene::Render() return; ClearBuffers(); + SetSceneViewport(); SetupPerspectiveMatrix(); Cull.CullScene(WorldToClip); RenderSectors(); @@ -67,6 +68,18 @@ void RenderPolyScene::ClearBuffers() NextSubsectorDepth = 0; } +void RenderPolyScene::SetSceneViewport() +{ + int height; + if (screenblocks >= 10) + height = SCREENHEIGHT; + else + height = (screenblocks*SCREENHEIGHT / 10) & ~7; + + int bottom = SCREENHEIGHT - (height + viewwindowy - ((height - viewheight) / 2)); + PolyTriangleDrawer::set_viewport(viewwindowx, SCREENHEIGHT - bottom - height, viewwidth, height, screen); +} + void RenderPolyScene::SetupPerspectiveMatrix() { static bool bDidSetup = false; @@ -77,29 +90,22 @@ void RenderPolyScene::SetupPerspectiveMatrix() bDidSetup = true; } - int height; - if (screenblocks >= 10) - height = SCREENHEIGHT; - else - height = (screenblocks*SCREENHEIGHT / 10) & ~7; - - int bottom = SCREENHEIGHT - (height + viewwindowy - ((height - viewheight) / 2)); - PolyTriangleDrawer::set_viewport(viewwindowx, SCREENHEIGHT - bottom - height, viewwidth, height, screen); - // Code provided courtesy of Graf Zahl. Now we just have to plug it into the viewmatrix code... // We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1. double radPitch = ViewPitch.Normalized180().Radians(); double angx = cos(radPitch); double angy = sin(radPitch) * glset.pixelstretch; double alen = sqrt(angx*angx + angy*angy); - //mAngles.Pitch = (float)RAD2DEG(asin(angy / alen)); + float adjustedPitch = (float)asin(angy / alen); + float adjustedViewAngle = (float)(ViewAngle - 90).Radians(); float ratio = WidescreenRatio; float fovratio = (WidescreenRatio >= 1.3f) ? 1.333333f : ratio; float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(FieldOfView.Radians() / 2) / fovratio)).Degrees); + TriMatrix worldToView = - TriMatrix::rotate((float)asin(angy / alen), 1.0f, 0.0f, 0.0f) * - TriMatrix::rotate((float)(ViewAngle - 90).Radians(), 0.0f, -1.0f, 0.0f) * + TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) * + TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) * TriMatrix::scale(1.0f, glset.pixelstretch, 1.0f) * TriMatrix::swapYZ() * TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); diff --git a/src/r_poly.h b/src/r_poly.h index f18f8a3cd..4be49f532 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -88,6 +88,7 @@ public: private: void ClearBuffers(); + void SetSceneViewport(); void SetupPerspectiveMatrix(); void RenderSectors(); void RenderSubsector(subsector_t *sub); From 272fe7f754466bcd7dd940b39a11aed43a12962c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 19 Nov 2016 02:53:32 +0100 Subject: [PATCH 1245/1509] Added blending modes to triangle codegen --- .../fixedfunction/drawtrianglecodegen.cpp | 222 ++++++++++-------- .../fixedfunction/drawtrianglecodegen.h | 26 +- src/r_compiler/llvmdrawers.cpp | 59 ++--- src/r_compiler/llvmdrawers.h | 50 ++-- src/r_poly_decal.cpp | 4 +- src/r_poly_particle.cpp | 5 +- src/r_poly_plane.cpp | 12 +- src/r_poly_sky.cpp | 6 +- src/r_poly_sprite.cpp | 2 +- src/r_poly_triangle.cpp | 42 ++-- src/r_poly_triangle.h | 11 +- src/r_poly_wall.cpp | 6 +- src/r_poly_wallsprite.cpp | 2 +- 13 files changed, 242 insertions(+), 205 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index 8bf4779e2..21995bb63 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -32,11 +32,14 @@ #include "r_compiler/ssa/ssa_struct_type.h" #include "r_compiler/ssa/ssa_value.h" -void DrawTriangleCodegen::Generate(TriDrawVariant variant, bool truecolor, SSAValue args, SSAValue thread_data) +void DrawTriangleCodegen::Generate(TriDrawVariant variant, TriBlendMode blendmode, bool truecolor, SSAValue args, SSAValue thread_data) { - LoadArgs(variant, truecolor, args, thread_data); - Setup(variant, truecolor); - LoopBlockY(variant, truecolor); + this->variant = variant; + this->blendmode = blendmode; + this->truecolor = truecolor; + LoadArgs(args, thread_data); + Setup(); + LoopBlockY(); } SSAInt DrawTriangleCodegen::FloatTo28_4(SSAFloat v) @@ -46,7 +49,7 @@ SSAInt DrawTriangleCodegen::FloatTo28_4(SSAFloat v) return (a + (a.ashr(31) | SSAInt(1))).ashr(1); } -void DrawTriangleCodegen::Setup(TriDrawVariant variant, bool truecolor) +void DrawTriangleCodegen::Setup() { int pixelsize = truecolor ? 4 : 1; @@ -154,7 +157,7 @@ SSAFloat DrawTriangleCodegen::grady(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFl return top / bottom; } -void DrawTriangleCodegen::LoopBlockY(TriDrawVariant variant, bool truecolor) +void DrawTriangleCodegen::LoopBlockY() { int pixelsize = truecolor ? 4 : 1; @@ -171,7 +174,7 @@ void DrawTriangleCodegen::LoopBlockY(TriDrawVariant variant, bool truecolor) SSAIfBlock branch; branch.if_block((y / q) % thread.num_cores == thread.core); { - LoopBlockX(variant, truecolor); + LoopBlockX(); } branch.end_block(); @@ -182,7 +185,7 @@ void DrawTriangleCodegen::LoopBlockY(TriDrawVariant variant, bool truecolor) loop.end_block(); } -void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) +void DrawTriangleCodegen::LoopBlockX() { stack_x.store(minx); @@ -260,7 +263,7 @@ void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) SetStencilBlock(x / 8 + y / 8 * stencilPitch); SSABool covered = a == SSAInt(0xF) && b == SSAInt(0xF) && c == SSAInt(0xF) && !clipneeded; - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::DrawShadedSubsector && variant != TriDrawVariant::FillSubsector) + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) { covered = covered && StencilIsSingleValue(); } @@ -269,11 +272,11 @@ void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) SSAIfBlock branch_covered; branch_covered.if_block(covered); { - LoopFullBlock(variant, truecolor); + LoopFullBlock(); } branch_covered.else_block(); { - LoopPartialBlock(variant, truecolor); + LoopPartialBlock(); } branch_covered.end_block(); @@ -284,10 +287,10 @@ void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor) loop.end_block(); } -void DrawTriangleCodegen::LoopFullBlock(TriDrawVariant variant, bool truecolor) +void DrawTriangleCodegen::LoopFullBlock() { SSAIfBlock branch_stenciltest; - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::DrawShadedSubsector && variant != TriDrawVariant::FillSubsector) + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) { branch_stenciltest.if_block(StencilGetSingle() == stencilTestValue); } @@ -325,18 +328,18 @@ void DrawTriangleCodegen::LoopFullBlock(TriDrawVariant variant, bool truecolor) varying[i] = stack_varying[i].load(); loopx.loop_block(ix < SSAInt(q), q); { - if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::DrawShadedSubsector || variant == TriDrawVariant::FillSubsector) + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) { SSAIfBlock branch; branch.if_block(subsectorbuffer[ix].load(true) >= subsectorDepth); { - ProcessPixel(buffer[ix * pixelsize], subsectorbuffer[ix], varying, variant, truecolor); + ProcessPixel(buffer[ix * pixelsize], subsectorbuffer[ix], varying); } branch.end_block(); } else { - ProcessPixel(buffer[ix * pixelsize], subsectorbuffer[ix], varying, variant, truecolor); + ProcessPixel(buffer[ix * pixelsize], subsectorbuffer[ix], varying); } for (int i = 0; i < TriVertex::NumVarying; i++) @@ -353,13 +356,13 @@ void DrawTriangleCodegen::LoopFullBlock(TriDrawVariant variant, bool truecolor) loopy.end_block(); } - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::DrawShadedSubsector && variant != TriDrawVariant::FillSubsector) + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) { branch_stenciltest.end_block(); } } -void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolor) +void DrawTriangleCodegen::LoopPartialBlock() { int pixelsize = truecolor ? 4 : 1; @@ -404,7 +407,7 @@ void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolo SSABool visible = (ix + x >= clipleft) && (ix + x < clipright) && (iy + y >= cliptop) && (iy + y < clipbottom); SSABool covered = CX1 > SSAInt(0) && CX2 > SSAInt(0) && CX3 > SSAInt(0) && visible; - if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::DrawShadedSubsector || variant == TriDrawVariant::FillSubsector) + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) { covered = covered && subsectorbuffer[ix].load(true) >= subsectorDepth; } @@ -422,7 +425,7 @@ void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolo } else { - ProcessPixel(buffer[ix * pixelsize], subsectorbuffer[ix], varying, variant, truecolor); + ProcessPixel(buffer[ix * pixelsize], subsectorbuffer[ix], varying); } } branch.end_block(); @@ -447,91 +450,101 @@ void DrawTriangleCodegen::LoopPartialBlock(TriDrawVariant variant, bool truecolo loopy.end_block(); } -void DrawTriangleCodegen::ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbuffer, SSAInt *varying, TriDrawVariant variant, bool truecolor) +SSAVec4i DrawTriangleCodegen::TranslateSample(SSAInt uvoffset) { - if (variant == TriDrawVariant::Fill || variant == TriDrawVariant::FillSubsector) + if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + return translation[color * 4].load_vec4ub(true); + else + return translation[texturePixels[uvoffset].load(true).zext_int() * 4].load_vec4ub(true); +} + +SSAVec4i DrawTriangleCodegen::Sample(SSAInt uvoffset) +{ + if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + return SSAVec4i::unpack(color); + else + return texturePixels[uvoffset * 4].load_vec4ub(true); +} + +void DrawTriangleCodegen::ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbuffer, SSAInt *varying) +{ + SSAInt ufrac = varying[0]; + SSAInt vfrac = varying[1]; + + SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; + SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; + SSAInt uvoffset = upos * textureHeight + vpos; + + if (truecolor) { - if (truecolor) + SSAVec4i fg; + SSAVec4i bg = buffer.load_vec4ub(false); + SSAInt alpha, inv_alpha; + SSAVec4i output; + + switch (blendmode) { - buffer.store_vec4ub(SSAVec4i::unpack(solidcolor)); - } - else - { - //buffer.store(solidcolor); + default: + case TriBlendMode::Copy: + fg = Sample(uvoffset); + output = blend_copy(shade_bgra_simple(fg, currentlight)); break; + case TriBlendMode::AlphaBlend: + fg = Sample(uvoffset); + output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); break; + case TriBlendMode::AddSolid: + fg = Sample(uvoffset); + output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, destalpha); break; + case TriBlendMode::Add: + fg = Sample(uvoffset); + output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; + case TriBlendMode::Sub: + fg = Sample(uvoffset); + output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; + case TriBlendMode::RevSub: + fg = Sample(uvoffset); + output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; + case TriBlendMode::Shaded: + fg = Sample(uvoffset); + alpha = fg[0]; + alpha = alpha + (alpha >> 7); // 255 -> 256 + inv_alpha = 256 - alpha; + output = blend_add(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), bg, alpha, inv_alpha); + break; + case TriBlendMode::TranslateCopy: + fg = TranslateSample(uvoffset); + output = blend_copy(shade_bgra_simple(fg, currentlight)); + break; + case TriBlendMode::TranslateAdd: + fg = TranslateSample(uvoffset); + output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; + case TriBlendMode::TranslateSub: + fg = TranslateSample(uvoffset); + output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; + case TriBlendMode::TranslateRevSub: + fg = TranslateSample(uvoffset); + output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; } - if (variant != TriDrawVariant::FillSubsector) - subsectorbuffer.store(subsectorDepth); + buffer.store_vec4ub(output); } else { - SSAInt ufrac = varying[0]; - SSAInt vfrac = varying[1]; - - SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; - SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; - SSAInt uvoffset = upos * textureHeight + vpos; - - if (truecolor) + if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) { - if (variant == TriDrawVariant::DrawMasked || variant == TriDrawVariant::DrawSubsector) - { - SSAVec4i fg = texturePixels[uvoffset * 4].load_vec4ub(true); - SSAInt fg_alpha = fg[3]; - fg = (fg * currentlight) >> 8; - fg.insert(3, fg_alpha); - - SSAIfBlock branch_transparency; - branch_transparency.if_block(fg_alpha > SSAInt(127)); - { - buffer.store_vec4ub(fg); - if (variant != TriDrawVariant::DrawSubsector) - subsectorbuffer.store(subsectorDepth); - } - branch_transparency.end_block(); - } - else if (variant == TriDrawVariant::DrawShadedSubsector) - { - SSAInt alpha = texturePixels[uvoffset * 4].load(true).zext_int(); - alpha = alpha + (alpha >> 7); // // 255 -> 256 - SSAInt inv_alpha = 256 - alpha; - - SSAVec4i bgcolor = buffer.load_vec4ub(false); - buffer.store_vec4ub(blend_add(shade_bgra_simple(SSAVec4i::unpack(solidcolor), currentlight), bgcolor, alpha, inv_alpha)); - } - else - { - SSAVec4i fg = texturePixels[uvoffset * 4].load_vec4ub(true); - SSAInt fg_alpha = fg[3]; - fg = (fg * currentlight) >> 8; - fg.insert(3, fg_alpha); - - buffer.store_vec4ub(fg); - subsectorbuffer.store(subsectorDepth); - } + buffer.store(color.trunc_ubyte()); } else { - SSAUByte palindex = texturePixels[uvoffset].load(true); - - if (variant == TriDrawVariant::DrawMasked || variant == TriDrawVariant::DrawSubsector) - { - SSAIfBlock branch_transparency; - branch_transparency.if_block(!(palindex.zext_int() == SSAInt(0))); - { - buffer.store(palindex); - if (variant != TriDrawVariant::DrawSubsector) - subsectorbuffer.store(subsectorDepth); - } - branch_transparency.end_block(); - } - else - { - buffer.store(palindex); - subsectorbuffer.store(subsectorDepth); - } + SSAUByte fg = texturePixels[uvoffset].load(true); + buffer.store(fg); } } + + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) + subsectorbuffer.store(subsectorDepth); } void DrawTriangleCodegen::SetStencilBlock(SSAInt block) @@ -582,7 +595,7 @@ SSABool DrawTriangleCodegen::StencilIsSingleValue() return (StencilBlockMask.load(false) & SSAInt(0xffffff00)) == SSAInt(0xffffff00); } -void DrawTriangleCodegen::LoadArgs(TriDrawVariant variant, bool truecolor, SSAValue args, SSAValue thread_data) +void DrawTriangleCodegen::LoadArgs(SSAValue args, SSAValue thread_data) { dest = args[0][0].load(true); pitch = args[0][1].load(true); @@ -596,7 +609,7 @@ void DrawTriangleCodegen::LoadArgs(TriDrawVariant variant, bool truecolor, SSAVa texturePixels = args[0][9].load(true); textureWidth = args[0][10].load(true); textureHeight = args[0][11].load(true); - solidcolor = args[0][12].load(true); + translation = args[0][12].load(true); LoadUniforms(args[0][13].load(true)); stencilValues = args[0][14].load(true); stencilMasks = args[0][15].load(true); @@ -625,17 +638,20 @@ void DrawTriangleCodegen::LoadUniforms(SSAValue uniforms) { light = uniforms[0][0].load(true); subsectorDepth = uniforms[0][1].load(true); + color = uniforms[0][2].load(true); + srcalpha = uniforms[0][3].load(true); + destalpha = uniforms[0][4].load(true); - SSAShort light_alpha = uniforms[0][2].load(true); - SSAShort light_red = uniforms[0][3].load(true); - SSAShort light_green = uniforms[0][4].load(true); - SSAShort light_blue = uniforms[0][5].load(true); - SSAShort fade_alpha = uniforms[0][6].load(true); - SSAShort fade_red = uniforms[0][7].load(true); - SSAShort fade_green = uniforms[0][8].load(true); - SSAShort fade_blue = uniforms[0][9].load(true); - SSAShort desaturate = uniforms[0][10].load(true); - SSAInt flags = uniforms[0][11].load(true); + SSAShort light_alpha = uniforms[0][5].load(true); + SSAShort light_red = uniforms[0][6].load(true); + SSAShort light_green = uniforms[0][7].load(true); + SSAShort light_blue = uniforms[0][8].load(true); + SSAShort fade_alpha = uniforms[0][9].load(true); + SSAShort fade_red = uniforms[0][10].load(true); + SSAShort fade_green = uniforms[0][11].load(true); + SSAShort fade_blue = uniforms[0][12].load(true); + SSAShort desaturate = uniforms[0][13].load(true); + SSAInt flags = uniforms[0][14].load(true); shade_constants.light = SSAVec4i(light_blue.zext_int(), light_green.zext_int(), light_red.zext_int(), light_alpha.zext_int()); shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); shade_constants.desaturate = desaturate.zext_int(); diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.h b/src/r_compiler/fixedfunction/drawtrianglecodegen.h index 8452b250f..d5539ef22 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.h +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.h @@ -33,20 +33,23 @@ struct SSATriVertex class DrawTriangleCodegen : public DrawerCodegen { public: - void Generate(TriDrawVariant variant, bool truecolor, SSAValue args, SSAValue thread_data); + void Generate(TriDrawVariant variant, TriBlendMode blendmode, bool truecolor, SSAValue args, SSAValue thread_data); private: - void LoadArgs(TriDrawVariant variant, bool truecolor, SSAValue args, SSAValue thread_data); + void LoadArgs(SSAValue args, SSAValue thread_data); SSATriVertex LoadTriVertex(SSAValue v); void LoadUniforms(SSAValue uniforms); - void Setup(TriDrawVariant variant, bool truecolor); + void Setup(); SSAInt FloatTo28_4(SSAFloat v); - void LoopBlockY(TriDrawVariant variant, bool truecolor); - void LoopBlockX(TriDrawVariant variant, bool truecolor); - void LoopFullBlock(TriDrawVariant variant, bool truecolor); - void LoopPartialBlock(TriDrawVariant variant, bool truecolor); + void LoopBlockY(); + void LoopBlockX(); + void LoopFullBlock(); + void LoopPartialBlock(); - void ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbuffer, SSAInt *varying, TriDrawVariant variant, bool truecolor); + void ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbuffer, SSAInt *varying); + + SSAVec4i TranslateSample(SSAInt uvoffset); + SSAVec4i Sample(SSAInt uvoffset); void SetStencilBlock(SSAInt block); void StencilSet(SSAInt x, SSAInt y, SSAUByte value); @@ -58,6 +61,10 @@ private: SSAFloat gradx(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2); SSAFloat grady(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2); + TriDrawVariant variant; + TriBlendMode blendmode; + bool truecolor; + SSAStack stack_C1, stack_C2, stack_C3; SSAStack stack_y; SSAStack stack_dest; @@ -82,7 +89,8 @@ private: SSAUBytePtr texturePixels; SSAInt textureWidth; SSAInt textureHeight; - SSAInt solidcolor; + SSAUBytePtr translation; + SSAInt color, srcalpha, destalpha; SSAInt light; SSAInt subsectorDepth; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 458d90d1a..d9a43d3d7 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -57,7 +57,7 @@ public: void StopLogFatalErrors(); template - Func *GetProcAddress(const char *name) { return reinterpret_cast(PointerToFunction(name)); } + Func *GetProcAddress(const std::string &name) { return reinterpret_cast(PointerToFunction(name.c_str())); } llvm::LLVMContext &context() { return *mContext; } llvm::Module *module() { return mModule.get(); } @@ -82,7 +82,7 @@ private: void CodegenDrawSpan(const char *name, DrawSpanVariant variant); void CodegenDrawWall(const char *name, DrawWallVariant variant, int columns); void CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns); - void CodegenDrawTriangle(const char *name, TriDrawVariant variant, bool truecolor); + void CodegenDrawTriangle(const std::string &name, TriDrawVariant variant, TriBlendMode blendmode, bool truecolor); static llvm::Type *GetDrawColumnArgsStruct(llvm::LLVMContext &context); static llvm::Type *GetDrawSpanArgsStruct(llvm::LLVMContext &context); @@ -186,17 +186,18 @@ LLVMDrawersImpl::LLVMDrawersImpl() CodegenDrawSky("DrawSky4", DrawSkyVariant::Single, 4); CodegenDrawSky("DrawDoubleSky1", DrawSkyVariant::Double, 1); CodegenDrawSky("DrawDoubleSky4", DrawSkyVariant::Double, 4); - CodegenDrawTriangle("TriDraw8", TriDrawVariant::Draw, false); - CodegenDrawTriangle("TriDraw32", TriDrawVariant::Draw, true); - CodegenDrawTriangle("TriDrawSubsector8", TriDrawVariant::DrawSubsector, false); - CodegenDrawTriangle("TriDrawSubsector32", TriDrawVariant::DrawSubsector, true); - CodegenDrawTriangle("TriDrawShadedSubsector8", TriDrawVariant::DrawShadedSubsector, false); - CodegenDrawTriangle("TriDrawShadedSubsector32", TriDrawVariant::DrawShadedSubsector, true); - CodegenDrawTriangle("TriFillSubsector8", TriDrawVariant::FillSubsector, false); - CodegenDrawTriangle("TriFillSubsector32", TriDrawVariant::FillSubsector, true); - CodegenDrawTriangle("TriFill8", TriDrawVariant::Fill, false); - CodegenDrawTriangle("TriFill32", TriDrawVariant::Fill, true); - CodegenDrawTriangle("TriStencil", TriDrawVariant::Stencil, false); + for (int i = 0; i < NumTriBlendModes(); i++) + { + CodegenDrawTriangle("TriDraw8_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, false); + CodegenDrawTriangle("TriDraw32_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, true); + CodegenDrawTriangle("TriFill8_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, false); + CodegenDrawTriangle("TriFill32_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, true); + CodegenDrawTriangle("TriDrawSubsector8_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, false); + CodegenDrawTriangle("TriDrawSubsector32_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, true); + CodegenDrawTriangle("TriFillSubsector8_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, false); + CodegenDrawTriangle("TriFillSubsector32_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, true); + } + CodegenDrawTriangle("TriStencil", TriDrawVariant::Stencil, TriBlendMode::Copy, false); mProgram.CreateEE(); @@ -262,16 +263,17 @@ LLVMDrawersImpl::LLVMDrawersImpl() DrawSky4 = mProgram.GetProcAddress("DrawSky4"); DrawDoubleSky1 = mProgram.GetProcAddress("DrawDoubleSky1"); DrawDoubleSky4 = mProgram.GetProcAddress("DrawDoubleSky4"); - TriDraw8 = mProgram.GetProcAddress("TriDraw8"); - TriDraw32 = mProgram.GetProcAddress("TriDraw32"); - TriDrawSubsector8 = mProgram.GetProcAddress("TriDrawSubsector8"); - TriDrawSubsector32 = mProgram.GetProcAddress("TriDrawSubsector32"); - TriDrawShadedSubsector8 = mProgram.GetProcAddress("TriDrawShadedSubsector8"); - TriDrawShadedSubsector32 = mProgram.GetProcAddress("TriDrawShadedSubsector32"); - TriFillSubsector8 = mProgram.GetProcAddress("TriFillSubsector8"); - TriFillSubsector32 = mProgram.GetProcAddress("TriFillSubsector32"); - TriFill8 = mProgram.GetProcAddress("TriFill8"); - TriFill32 = mProgram.GetProcAddress("TriFill32"); + for (int i = 0; i < NumTriBlendModes(); i++) + { + TriDrawNormal8.push_back(mProgram.GetProcAddress("TriDraw8_" + std::to_string(i))); + TriDrawNormal32.push_back(mProgram.GetProcAddress("TriDraw32_" + std::to_string(i))); + TriFillNormal8.push_back(mProgram.GetProcAddress("TriFill8_" + std::to_string(i))); + TriFillNormal32.push_back(mProgram.GetProcAddress("TriFill32_" + std::to_string(i))); + TriDrawSubsector8.push_back(mProgram.GetProcAddress("TriDrawSubsector8_" + std::to_string(i))); + TriDrawSubsector32.push_back(mProgram.GetProcAddress("TriDrawSubsector32_" + std::to_string(i))); + TriFillSubsector8.push_back(mProgram.GetProcAddress("TriFillSubsector8_" + std::to_string(i))); + TriFillSubsector32.push_back(mProgram.GetProcAddress("TriFillSubsector32_" + std::to_string(i))); + } TriStencil = mProgram.GetProcAddress("TriStencil"); #if 0 @@ -383,7 +385,7 @@ void LLVMDrawersImpl::CodegenDrawSky(const char *name, DrawSkyVariant variant, i I_FatalError("verifyFunction failed for CodegenDrawSky()"); } -void LLVMDrawersImpl::CodegenDrawTriangle(const char *name, TriDrawVariant variant, bool truecolor) +void LLVMDrawersImpl::CodegenDrawTriangle(const std::string &name, TriDrawVariant variant, TriBlendMode blendmode, bool truecolor) { llvm::IRBuilder<> builder(mProgram.context()); SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); @@ -394,12 +396,12 @@ void LLVMDrawersImpl::CodegenDrawTriangle(const char *name, TriDrawVariant varia function.create_public(); DrawTriangleCodegen codegen; - codegen.Generate(variant, truecolor, function.parameter(0), function.parameter(1)); + codegen.Generate(variant, blendmode, truecolor, function.parameter(0), function.parameter(1)); builder.CreateRetVoid(); if (llvm::verifyFunction(*function.func)) - I_FatalError("verifyFunction failed for CodegenDrawTriangle()"); + I_FatalError("verifyFunction failed for CodegenDrawTriangle(%d, %d, %d)", (int)variant, (int)blendmode, (int)truecolor); } llvm::Type *LLVMDrawersImpl::GetDrawColumnArgsStruct(llvm::LLVMContext &context) @@ -529,6 +531,9 @@ llvm::Type *LLVMDrawersImpl::GetTriUniformsStruct(llvm::LLVMContext &context) std::vector elements; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t subsectorDepth; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t color; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; @@ -558,7 +563,7 @@ llvm::Type *LLVMDrawersImpl::GetTriDrawTriangleArgs(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *texturePixels; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureWidth; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureHeight; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t solidcolor; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *translation; elements.push_back(GetTriUniformsStruct(context)); // const TriUniforms *uniforms; elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *stencilValues; elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *stencilMasks; diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 9c3a3e45f..3b1396283 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -215,7 +215,9 @@ struct TriUniforms { uint32_t light; uint32_t subsectorDepth; - + uint32_t color; + uint32_t srcalpha; + uint32_t destalpha; uint16_t light_alpha; uint16_t light_red; uint16_t light_green; @@ -250,7 +252,7 @@ struct TriDrawTriangleArgs const uint8_t *texturePixels; uint32_t textureWidth; uint32_t textureHeight; - uint32_t solidcolor; + const uint8_t *translation; const TriUniforms *uniforms; uint8_t *stencilValues; uint32_t *stencilMasks; @@ -262,15 +264,31 @@ struct TriDrawTriangleArgs enum class TriDrawVariant { - Draw, - DrawMasked, - Fill, + DrawNormal, + FillNormal, DrawSubsector, - DrawShadedSubsector, FillSubsector, - Stencil, + FuzzSubsector, + Stencil }; +enum class TriBlendMode +{ + Copy, // blend_copy(shade(fg)) + AlphaBlend, // blend_alpha_blend(shade(fg), bg) + AddSolid, // blend_add(shade(fg), bg, srcalpha, destalpha) + Add, // blend_add(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) + Sub, // blend_sub(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) + RevSub, // blend_revsub(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) + Shaded, // blend_add(color, bg, fg.a, 1 - fg.a) + TranslateCopy, // blend_copy(shade(translate(fg))) + TranslateAdd, // blend_add(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) + TranslateSub, // blend_sub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) + TranslateRevSub // blend_revsub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) +}; + +inline int NumTriBlendModes() { return (int)TriBlendMode::TranslateRevSub + 1; } + class LLVMDrawers { public: @@ -346,16 +364,14 @@ public: void(*DrawDoubleSky1)(const DrawSkyArgs *, const WorkerThreadData *) = nullptr; void(*DrawDoubleSky4)(const DrawSkyArgs *, const WorkerThreadData *) = nullptr; - void(*TriDraw8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; - void(*TriDraw32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; - void(*TriDrawSubsector8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; - void(*TriDrawSubsector32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; - void(*TriDrawShadedSubsector8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; - void(*TriDrawShadedSubsector32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; - void(*TriFillSubsector8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; - void(*TriFillSubsector32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; - void(*TriFill8)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; - void(*TriFill32)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + std::vector TriDrawNormal8; + std::vector TriDrawNormal32; + std::vector TriFillNormal8; + std::vector TriFillNormal32; + std::vector TriDrawSubsector8; + std::vector TriDrawSubsector32; + std::vector TriFillSubsector8; + std::vector TriFillSubsector32; void(*TriStencil)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; private: diff --git a/src/r_poly_decal.cpp b/src/r_poly_decal.cpp index 0c6c427a8..5641bfcd1 100644 --- a/src/r_poly_decal.cpp +++ b/src/r_poly_decal.cpp @@ -141,6 +141,7 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co uniforms.flags = 0; } uniforms.subsectorDepth = subsectorDepth; + uniforms.color = decal->AlphaColor; PolyDrawArgs args; args.uniforms = uniforms; @@ -151,7 +152,6 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); - args.solidcolor = decal->AlphaColor; //mode = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawShadedSubsector); + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Shaded); } diff --git a/src/r_poly_particle.cpp b/src/r_poly_particle.cpp index be8030071..e5797a108 100644 --- a/src/r_poly_particle.cpp +++ b/src/r_poly_particle.cpp @@ -83,8 +83,8 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *partic uniforms.flags = 0; } uniforms.subsectorDepth = subsectorDepth; - uint32_t alpha = particle->trans; + uniforms.color = (alpha << 24) | (particle->color & 0xffffff); PolyDrawArgs args; args.uniforms = uniforms; @@ -94,6 +94,5 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *partic args.ccw = true; args.stenciltestvalue = 0; args.stencilwritevalue = 1; - args.solidcolor = (alpha << 24) | (particle->color & 0xffffff); - PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector); + PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector, TriBlendMode::AlphaBlend); } diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 9a425598b..9005e32f1 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -140,8 +140,8 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *s args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); - PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); } void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, bool ceiling, double skyHeight) @@ -235,13 +235,13 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin if (!isSky) { args.SetTexture(tex); - PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); } else { args.stencilwritevalue = 255; - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); for (uint32_t i = 0; i < sub->numlines; i++) { @@ -309,7 +309,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin args.vinput = wallvert; args.vcount = 4; - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); } } } diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp index fc6963dbb..b0b06f262 100644 --- a/src/r_poly_sky.cpp +++ b/src/r_poly_sky.cpp @@ -79,7 +79,7 @@ void PolySkyDome::RenderRow(PolyDrawArgs &args, int row) args.vcount = mPrimStart[row + 1] - mPrimStart[row]; args.mode = TriangleDrawMode::Strip; args.ccw = false; - PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy); } void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap) @@ -92,8 +92,8 @@ void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int ro args.vcount = mPrimStart[row + 1] - mPrimStart[row]; args.mode = TriangleDrawMode::Fan; args.ccw = bottomCap; - args.solidcolor = solid; - PolyTriangleDrawer::draw(args, TriDrawVariant::Fill); + args.uniforms.color = solid; + PolyTriangleDrawer::draw(args, TriDrawVariant::FillNormal, TriBlendMode::Copy); } void PolySkyDome::CreateDome() diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index e1c6fcc14..43bdf40af 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -136,7 +136,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector); + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend); } bool RenderPolySprite::IsThingCulled(AActor *thing) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index d661fe0d7..07a4566dd 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -72,44 +72,32 @@ void PolyTriangleDrawer::set_viewport(int x, int y, int width, int height, DCanv dest_height = clamp(viewport_y + viewport_height, 0, dest_height - offsety); } -void PolyTriangleDrawer::draw(const PolyDrawArgs &args, TriDrawVariant variant) +void PolyTriangleDrawer::draw(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode) { if (dest_bgra) - DrawerCommandQueue::QueueCommand(args, variant); + DrawerCommandQueue::QueueCommand(args, variant, blendmode); else - draw_arrays(args, variant, nullptr); + draw_arrays(args, variant, blendmode, nullptr); } -void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVariant variant, WorkerThreadData *thread) +void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVariant variant, TriBlendMode blendmode, WorkerThreadData *thread) { if (drawargs.vcount < 3) return; auto llvm = LLVMDrawers::Instance(); void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *); -#if 1 + int bmode = (int)blendmode; switch (variant) { default: - case TriDrawVariant::Draw: drawfunc = dest_bgra ? llvm->TriDraw32: llvm->TriDraw8; break; - case TriDrawVariant::Fill: drawfunc = dest_bgra ? llvm->TriFill32 : llvm->TriFill8; break; - case TriDrawVariant::DrawSubsector: drawfunc = dest_bgra ? llvm->TriDrawSubsector32 : llvm->TriDrawSubsector8; break; - case TriDrawVariant::DrawShadedSubsector: drawfunc = dest_bgra ? llvm->TriDrawShadedSubsector32 : llvm->TriDrawShadedSubsector8; break; - case TriDrawVariant::FillSubsector: drawfunc = dest_bgra ? llvm->TriFillSubsector32 : llvm->TriFillSubsector8; break; + case TriDrawVariant::DrawNormal: drawfunc = dest_bgra ? llvm->TriDrawNormal32[bmode] : llvm->TriDrawNormal8[bmode]; break; + case TriDrawVariant::FillNormal: drawfunc = dest_bgra ? llvm->TriFillNormal32[bmode] : llvm->TriFillNormal8[bmode]; break; + case TriDrawVariant::DrawSubsector: drawfunc = dest_bgra ? llvm->TriDrawSubsector32[bmode] : llvm->TriDrawSubsector8[bmode]; break; + case TriDrawVariant::FuzzSubsector: + case TriDrawVariant::FillSubsector: drawfunc = dest_bgra ? llvm->TriFillSubsector32[bmode] : llvm->TriFillSubsector8[bmode]; break; case TriDrawVariant::Stencil: drawfunc = llvm->TriStencil; break; } -#else - switch (variant) - { - default: - case TriDrawVariant::Draw: drawfunc = dest_bgra ? ScreenPolyTriangleDrawer::draw32 : ScreenPolyTriangleDrawer::draw; break; - case TriDrawVariant::FillSubsector: - case TriDrawVariant::Fill: drawfunc = dest_bgra ? ScreenPolyTriangleDrawer::fill32 : ScreenPolyTriangleDrawer::fill; break; - case TriDrawVariant::DrawShadedSubsector: - case TriDrawVariant::DrawSubsector: drawfunc = dest_bgra ? ScreenPolyTriangleDrawer::drawsubsector32 : llvm->TriDrawSubsector8; break; - case TriDrawVariant::Stencil: drawfunc = ScreenPolyTriangleDrawer::stencil; break; - } -#endif TriDrawTriangleArgs args; args.dest = dest; @@ -121,7 +109,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian args.texturePixels = drawargs.texturePixels; args.textureWidth = drawargs.textureWidth; args.textureHeight = drawargs.textureHeight; - args.solidcolor = drawargs.solidcolor; + args.translation = drawargs.translation; args.uniforms = &drawargs.uniforms; args.stencilTestValue = drawargs.stenciltestvalue; args.stencilWriteValue = drawargs.stencilwritevalue; @@ -336,6 +324,7 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert ///////////////////////////////////////////////////////////////////////////// +#if 0 void ScreenPolyTriangleDrawer::draw(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { uint8_t *dest = args->dest; @@ -1641,11 +1630,12 @@ float ScreenPolyTriangleDrawer::grady(float x0, float y0, float x1, float y1, fl float bottom = -((x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2)); return top / bottom; } +#endif ///////////////////////////////////////////////////////////////////////////// -DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant) - : args(args), variant(variant) +DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode) + : args(args), variant(variant), blendmode(blendmode) { } @@ -1658,7 +1648,7 @@ void DrawPolyTrianglesCommand::Execute(DrawerThread *thread) thread_data.pass_end_y = thread->pass_end_y; thread_data.temp = thread->dc_temp_rgba; - PolyTriangleDrawer::draw_arrays(args, variant, &thread_data); + PolyTriangleDrawer::draw_arrays(args, variant, blendmode, &thread_data); } FString DrawPolyTrianglesCommand::DebugInfo() diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 8f2fcf3d0..cc8558985 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -39,7 +39,7 @@ public: const uint8_t *texturePixels = nullptr; int textureWidth = 0; int textureHeight = 0; - uint32_t solidcolor = 0; + const uint8_t *translation = nullptr; uint8_t stenciltestvalue = 0; uint8_t stencilwritevalue = 0; @@ -58,11 +58,11 @@ class PolyTriangleDrawer { public: static void set_viewport(int x, int y, int width, int height, DCanvas *canvas); - static void draw(const PolyDrawArgs &args, TriDrawVariant variant); + static void draw(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode); private: static TriVertex shade_vertex(const TriUniforms &uniforms, TriVertex v); - static void draw_arrays(const PolyDrawArgs &args, TriDrawVariant variant, WorkerThreadData *thread); + static void draw_arrays(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode, WorkerThreadData *thread); static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert); @@ -188,6 +188,7 @@ private: std::vector masks; }; +#if 0 class ScreenPolyTriangleDrawer { public: @@ -204,11 +205,12 @@ private: static float gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); static float grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); }; +#endif class DrawPolyTrianglesCommand : public DrawerCommand { public: - DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant); + DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode); void Execute(DrawerThread *thread) override; FString DebugInfo() override; @@ -216,6 +218,7 @@ public: private: PolyDrawArgs args; TriDrawVariant variant; + TriBlendMode blendmode; }; #endif diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index 1f1908ab4..e8bad52a7 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -193,12 +193,12 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) if (!Masked) { - PolyTriangleDrawer::draw(args, TriDrawVariant::Draw); - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil); + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); } else { - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector); + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend); } RenderPolyDecal::RenderWallDecals(worldToClip, Line, SubsectorDepth); diff --git a/src/r_poly_wallsprite.cpp b/src/r_poly_wallsprite.cpp index e2d1a9e86..ccebe5f0e 100644 --- a/src/r_poly_wallsprite.cpp +++ b/src/r_poly_wallsprite.cpp @@ -121,5 +121,5 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, AActor *thing, s args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector); + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend); } From 17ed585c1f1edc94fa3a0c695bbedf40447a95de Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 19 Nov 2016 12:30:58 +0100 Subject: [PATCH 1246/1509] Fix vsync not working --- src/gl/system/gl_swframebuffer.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 0d82aa221..38d7d3679 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -1543,20 +1543,21 @@ void OpenGLSWFrameBuffer::GetFlashedPalette(PalEntry pal[256]) void OpenGLSWFrameBuffer::SetVSync(bool vsync) { - if (VSync != vsync) - { - VSync = vsync; - Reset(); - } + // Switch to the default frame buffer because Nvidia's driver associates the vsync state with the bound FB object. + GLint oldDrawFramebufferBinding = 0, oldReadFramebufferBinding = 0; + glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldDrawFramebufferBinding); + glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &oldReadFramebufferBinding); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + Super::SetVSync(vsync); + + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, oldDrawFramebufferBinding); + glBindFramebuffer(GL_READ_FRAMEBUFFER, oldReadFramebufferBinding); } void OpenGLSWFrameBuffer::NewRefreshRate() { - if (IsFullscreen()) - { - Reset(); - } } void OpenGLSWFrameBuffer::SetBlendingRect(int x1, int y1, int x2, int y2) From 114fda1ed5bf6445b25ed668d3a7c326f79327d8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 19 Nov 2016 13:32:57 +0100 Subject: [PATCH 1247/1509] Added missing TranslateAlphaBlend and created a helper function for specifying the translation --- .../fixedfunction/drawtrianglecodegen.cpp | 4 ++++ src/r_compiler/llvmdrawers.h | 1 + src/r_poly_sprite.cpp | 9 +++++-- src/r_poly_triangle.h | 24 +++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index 21995bb63..1ad98a8fb 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -514,6 +514,10 @@ void DrawTriangleCodegen::ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbu fg = TranslateSample(uvoffset); output = blend_copy(shade_bgra_simple(fg, currentlight)); break; + case TriBlendMode::TranslateAlphaBlend: + fg = TranslateSample(uvoffset); + output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); break; + break; case TriBlendMode::TranslateAdd: fg = TranslateSample(uvoffset); output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 3b1396283..e42153743 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -282,6 +282,7 @@ enum class TriBlendMode RevSub, // blend_revsub(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) Shaded, // blend_add(color, bg, fg.a, 1 - fg.a) TranslateCopy, // blend_copy(shade(translate(fg))) + TranslateAlphaBlend, // blend_alpha_blend(shade(translate(fg)), bg) TranslateAdd, // blend_add(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) TranslateSub, // blend_sub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) TranslateRevSub // blend_revsub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index 43bdf40af..ff102366a 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -135,8 +135,13 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse args.ccw = true; args.stenciltestvalue = 0; args.stencilwritevalue = 1; - args.SetTexture(tex); - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend); + args.translation = nullptr; + args.SetTexture(tex, thing->Translation); + + if (args.translation) + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAlphaBlend); + else + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend); } bool RenderPolySprite::IsThingCulled(AActor *thing) diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index cc8558985..ad00d1a67 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -25,6 +25,7 @@ #define __R_POLY_TRIANGLE__ #include "r_triangle.h" +#include "r_data/r_translate.h" struct TriDrawTriangleArgs; @@ -51,6 +52,29 @@ public: texturePixels = (const uint8_t *)texture->GetPixelsBgra(); else texturePixels = texture->GetPixels(); + translation = nullptr; + } + + void SetTexture(FTexture *texture, uint32_t translationID) + { + if (translationID != -1 && translationID != 0) + { + FRemapTable *table = TranslationToTable(translationID); + if (table != nullptr && !table->Inactive) + { + if (r_swtruecolor) + translation = (uint8_t*)table->Palette; + else + translation = table->Remap; + + textureWidth = texture->GetWidth(); + textureHeight = texture->GetHeight(); + texturePixels = texture->GetPixels(); + return; + } + } + + SetTexture(texture); } }; From d197ebca781bcf9e06b9a06a7cca39ba6d59da26 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 19 Nov 2016 14:07:39 +0100 Subject: [PATCH 1248/1509] Remove redundant line --- src/r_poly_sprite.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index ff102366a..8c74d0d1a 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -135,7 +135,6 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse args.ccw = true; args.stenciltestvalue = 0; args.stencilwritevalue = 1; - args.translation = nullptr; args.SetTexture(tex, thing->Translation); if (args.translation) From b4eb49678ab7c4ad25200acf249cbb8fcccf62b8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 19 Nov 2016 17:14:37 +0100 Subject: [PATCH 1249/1509] Cache the optimized bitcode (note: this adds LLVMBitWriter as a dependency) --- src/CMakeLists.txt | 4 +- src/r_compiler/llvm_include.h | 1 + src/r_compiler/llvmdrawers.cpp | 294 +++++++++++++++++++++------------ 3 files changed, 190 insertions(+), 109 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 34e0e72d0..8c2e36220 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -294,7 +294,7 @@ endif() set( LLVM_PRECOMPILED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" ) if( NOT WIN32 ) - set( LLVM_COMPONENTS core support asmparser asmprinter bitreader codegen ipo + set( LLVM_COMPONENTS core support asmparser asmprinter bitreader bitwriter codegen ipo irreader transformutils instrumentation profiledata runtimedyld object instcombine linker analysis selectiondag scalaropts vectorize executionengine mc mcdisassembler mcparser mcjit target x86asmprinter x86info x86desc x86utils x86codegen ) @@ -307,7 +307,7 @@ if( NOT WIN32 ) include_directories( ${LLVM_INCLUDE_DIRS} ) set( ZDOOM_LIBS ${ZDOOM_LIBS} ${llvm_libs} ) else() - set( LLVM_COMPONENTS core support asmparser asmprinter bitreader codegen passes ipo + set( LLVM_COMPONENTS core support asmparser asmprinter bitreader bitwriter codegen passes ipo irreader transformutils instrumentation profiledata debuginfocodeview runtimedyld object instcombine linker analysis selectiondag scalaropts vectorize executionengine mc mcdisassembler mcparser mcjit target x86asmprinter x86info x86desc x86utils x86codegen ) diff --git a/src/r_compiler/llvm_include.h b/src/r_compiler/llvm_include.h index ad58666e3..323eef014 100644 --- a/src/r_compiler/llvm_include.h +++ b/src/r_compiler/llvm_include.h @@ -75,6 +75,7 @@ #include #include #include +#include #if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) #include diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index d9a43d3d7..a3432eae6 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -39,6 +39,7 @@ #include "x86.h" #include "c_cvars.h" #include "version.h" +#include "m_misc.h" CUSTOM_CVAR(String, llvm_cpu, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL) { @@ -51,7 +52,9 @@ public: LLVMProgram(); void CreateModule(); - void CreateEE(); + std::string GetTargetCPU(); + bool LoadCachedModule(int version, std::string targetCPU); + void CreateEE(int version, std::string targetCPU, bool optimize); std::string GenerateAssembly(std::string cpuName); std::string DumpModule(); void StopLogFatalErrors(); @@ -64,6 +67,8 @@ public: llvm::ExecutionEngine *engine() { return mEngine.get(); } private: + void SaveCachedModule(llvm::Module *module, int version, std::string targetCPU); + FString GetDrawerCacheFilename(int version, FString cpu); void *PointerToFunction(const char *name); llvm::TargetMachine *machine = nullptr; @@ -122,84 +127,90 @@ LLVMDrawers *LLVMDrawers::Instance() LLVMDrawersImpl::LLVMDrawersImpl() { - mProgram.CreateModule(); - - CodegenDrawColumn("FillColumn", DrawColumnVariant::Fill, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnAdd", DrawColumnVariant::FillAdd, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnAddClamp", DrawColumnVariant::FillAddClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnSubClamp", DrawColumnVariant::FillSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnRevSubClamp", DrawColumnVariant::FillRevSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumn", DrawColumnVariant::Draw, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnAdd", DrawColumnVariant::DrawAdd, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnShaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnAddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnSubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnRevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnTranslated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnTlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnAddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnSubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnRevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnRt1", DrawColumnVariant::Draw, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt4", DrawColumnVariant::Draw, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt4); - CodegenDrawSpan("DrawSpan", DrawSpanVariant::Opaque); - CodegenDrawSpan("DrawSpanMasked", DrawSpanVariant::Masked); - CodegenDrawSpan("DrawSpanTranslucent", DrawSpanVariant::Translucent); - CodegenDrawSpan("DrawSpanMaskedTranslucent", DrawSpanVariant::MaskedTranslucent); - CodegenDrawSpan("DrawSpanAddClamp", DrawSpanVariant::AddClamp); - CodegenDrawSpan("DrawSpanMaskedAddClamp", DrawSpanVariant::MaskedAddClamp); - CodegenDrawWall("vlinec1", DrawWallVariant::Opaque, 1); - CodegenDrawWall("vlinec4", DrawWallVariant::Opaque, 4); - CodegenDrawWall("mvlinec1", DrawWallVariant::Masked, 1); - CodegenDrawWall("mvlinec4", DrawWallVariant::Masked, 4); - CodegenDrawWall("tmvline1_add", DrawWallVariant::Add, 1); - CodegenDrawWall("tmvline4_add", DrawWallVariant::Add, 4); - CodegenDrawWall("tmvline1_addclamp", DrawWallVariant::AddClamp, 1); - CodegenDrawWall("tmvline4_addclamp", DrawWallVariant::AddClamp, 4); - CodegenDrawWall("tmvline1_subclamp", DrawWallVariant::SubClamp, 1); - CodegenDrawWall("tmvline4_subclamp", DrawWallVariant::SubClamp, 4); - CodegenDrawWall("tmvline1_revsubclamp", DrawWallVariant::RevSubClamp, 1); - CodegenDrawWall("tmvline4_revsubclamp", DrawWallVariant::RevSubClamp, 4); - CodegenDrawSky("DrawSky1", DrawSkyVariant::Single, 1); - CodegenDrawSky("DrawSky4", DrawSkyVariant::Single, 4); - CodegenDrawSky("DrawDoubleSky1", DrawSkyVariant::Double, 1); - CodegenDrawSky("DrawDoubleSky4", DrawSkyVariant::Double, 4); - for (int i = 0; i < NumTriBlendModes(); i++) + int version = 1; // Increment this number if the drawer codegen is modified (forces recreation of the module). + std::string targetCPU = mProgram.GetTargetCPU(); + bool loaded = mProgram.LoadCachedModule(version, targetCPU); + if (!loaded) { - CodegenDrawTriangle("TriDraw8_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, false); - CodegenDrawTriangle("TriDraw32_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, true); - CodegenDrawTriangle("TriFill8_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, false); - CodegenDrawTriangle("TriFill32_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, true); - CodegenDrawTriangle("TriDrawSubsector8_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, false); - CodegenDrawTriangle("TriDrawSubsector32_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, true); - CodegenDrawTriangle("TriFillSubsector8_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, false); - CodegenDrawTriangle("TriFillSubsector32_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, true); - } - CodegenDrawTriangle("TriStencil", TriDrawVariant::Stencil, TriBlendMode::Copy, false); + mProgram.CreateModule(); - mProgram.CreateEE(); + CodegenDrawColumn("FillColumn", DrawColumnVariant::Fill, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnAdd", DrawColumnVariant::FillAdd, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnAddClamp", DrawColumnVariant::FillAddClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnSubClamp", DrawColumnVariant::FillSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnRevSubClamp", DrawColumnVariant::FillRevSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumn", DrawColumnVariant::Draw, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnAdd", DrawColumnVariant::DrawAdd, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnShaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnAddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnSubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnRevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnTranslated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnTlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnAddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnSubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnRevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnRt1", DrawColumnVariant::Draw, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt4", DrawColumnVariant::Draw, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt4); + CodegenDrawSpan("DrawSpan", DrawSpanVariant::Opaque); + CodegenDrawSpan("DrawSpanMasked", DrawSpanVariant::Masked); + CodegenDrawSpan("DrawSpanTranslucent", DrawSpanVariant::Translucent); + CodegenDrawSpan("DrawSpanMaskedTranslucent", DrawSpanVariant::MaskedTranslucent); + CodegenDrawSpan("DrawSpanAddClamp", DrawSpanVariant::AddClamp); + CodegenDrawSpan("DrawSpanMaskedAddClamp", DrawSpanVariant::MaskedAddClamp); + CodegenDrawWall("vlinec1", DrawWallVariant::Opaque, 1); + CodegenDrawWall("vlinec4", DrawWallVariant::Opaque, 4); + CodegenDrawWall("mvlinec1", DrawWallVariant::Masked, 1); + CodegenDrawWall("mvlinec4", DrawWallVariant::Masked, 4); + CodegenDrawWall("tmvline1_add", DrawWallVariant::Add, 1); + CodegenDrawWall("tmvline4_add", DrawWallVariant::Add, 4); + CodegenDrawWall("tmvline1_addclamp", DrawWallVariant::AddClamp, 1); + CodegenDrawWall("tmvline4_addclamp", DrawWallVariant::AddClamp, 4); + CodegenDrawWall("tmvline1_subclamp", DrawWallVariant::SubClamp, 1); + CodegenDrawWall("tmvline4_subclamp", DrawWallVariant::SubClamp, 4); + CodegenDrawWall("tmvline1_revsubclamp", DrawWallVariant::RevSubClamp, 1); + CodegenDrawWall("tmvline4_revsubclamp", DrawWallVariant::RevSubClamp, 4); + CodegenDrawSky("DrawSky1", DrawSkyVariant::Single, 1); + CodegenDrawSky("DrawSky4", DrawSkyVariant::Single, 4); + CodegenDrawSky("DrawDoubleSky1", DrawSkyVariant::Double, 1); + CodegenDrawSky("DrawDoubleSky4", DrawSkyVariant::Double, 4); + for (int i = 0; i < NumTriBlendModes(); i++) + { + CodegenDrawTriangle("TriDraw8_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, false); + CodegenDrawTriangle("TriDraw32_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, true); + CodegenDrawTriangle("TriFill8_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, false); + CodegenDrawTriangle("TriFill32_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, true); + CodegenDrawTriangle("TriDrawSubsector8_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, false); + CodegenDrawTriangle("TriDrawSubsector32_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, true); + CodegenDrawTriangle("TriFillSubsector8_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, false); + CodegenDrawTriangle("TriFillSubsector32_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, true); + } + CodegenDrawTriangle("TriStencil", TriDrawVariant::Stencil, TriBlendMode::Copy, false); + } + + mProgram.CreateEE(version, targetCPU, !loaded); FillColumn = mProgram.GetProcAddress("FillColumn"); FillColumnAdd = mProgram.GetProcAddress("FillColumnAdd"); @@ -603,12 +614,64 @@ void LLVMProgram::CreateModule() mModule = std::make_unique("render", context()); } -void LLVMProgram::CreateEE() +bool LLVMProgram::LoadCachedModule(int version, std::string targetCPU) +{ + FString filename = GetDrawerCacheFilename(version, targetCPU.c_str()); + FILE *file = fopen(filename, "rb"); + if (!file) + return false; + + bool success = false; + std::string data; + + fseek(file, 0, SEEK_END); + int length = ftell(file); + fseek(file, 0, SEEK_SET); + if (length > 0) + { + data.resize(length); + success = fread(&data[0], length, 1, file) == 1; + } + + fclose(file); + if (!success) + return false; + + auto result = llvm::parseBitcodeFile(llvm::MemoryBufferRef(data, filename.GetChars()), *mContext.get()); + if (!result) + return false; + + mModule = std::move(result.get()); + return true; +} + +void LLVMProgram::SaveCachedModule(llvm::Module *module, int version, std::string targetCPU) +{ + std::string str; + llvm::raw_string_ostream stream(str); + llvm::WriteBitcodeToFile(module, stream); + std::string data = stream.str(); + + FString filename = GetDrawerCacheFilename(version, targetCPU.c_str()); + FILE *file = fopen(filename, "wb"); + if (file) + { + fwrite(data.data(), data.size(), 1, file); + fclose(file); + } +} + +FString LLVMProgram::GetDrawerCacheFilename(int version, FString cpu) +{ + FString path = M_GetCachePath(true); + FString filename; + filename.Format("%s/LLVMDrawers-%d-%s.bc", path.GetChars(), version, cpu.GetChars()); + return filename; +} + +std::string LLVMProgram::GetTargetCPU() { using namespace llvm; - - std::string errorstring; - std::string mcpu = sys::getHostCPUName(); if (std::string(CPU.CPUString).find("G840") != std::string::npos && mcpu == "sandybridge") mcpu = "westmere"; // Pentium G840 is misdetected as a sandy bridge CPU @@ -618,13 +681,21 @@ void LLVMProgram::CreateEE() mcpu = llvm_cpu; Printf("Overriding LLVM CPU target to %s\n", mcpu.c_str()); } + return mcpu; +} + +void LLVMProgram::CreateEE(int version, std::string targetCPU, bool optimize) +{ + using namespace llvm; + + std::string errorstring; llvm::Module *module = mModule.get(); EngineBuilder engineBuilder(std::move(mModule)); engineBuilder.setErrorStr(&errorstring); engineBuilder.setOptLevel(CodeGenOpt::Aggressive); engineBuilder.setEngineKind(EngineKind::JIT); - engineBuilder.setMCPU(mcpu); + engineBuilder.setMCPU(targetCPU); machine = engineBuilder.selectTarget(); if (!machine) I_FatalError("Could not create LLVM target machine"); @@ -638,42 +709,51 @@ void LLVMProgram::CreateEE() Printf("LLVM target triple: %s\n", targetTriple.c_str()); Printf("LLVM target CPU: %s\n", cpuName.c_str()); - module->setTargetTriple(targetTriple); + if (optimize) + { + Printf("Optimizing drawers..\n"); + + module->setTargetTriple(targetTriple); #if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - module->setDataLayout(new DataLayout(*machine->getSubtargetImpl()->getDataLayout())); + module->setDataLayout(new DataLayout(*machine->getSubtargetImpl()->getDataLayout())); #else - module->setDataLayout(machine->createDataLayout()); + module->setDataLayout(machine->createDataLayout()); #endif - legacy::FunctionPassManager PerFunctionPasses(module); - legacy::PassManager PerModulePasses; + legacy::FunctionPassManager PerFunctionPasses(module); + legacy::PassManager PerModulePasses; #if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8) - PerFunctionPasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); - PerModulePasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); + PerFunctionPasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); + PerModulePasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); #endif - PassManagerBuilder passManagerBuilder; - passManagerBuilder.OptLevel = 3; - passManagerBuilder.SizeLevel = 0; - passManagerBuilder.Inliner = createFunctionInliningPass(); - passManagerBuilder.SLPVectorize = true; - passManagerBuilder.LoopVectorize = true; - passManagerBuilder.LoadCombine = true; - passManagerBuilder.populateModulePassManager(PerModulePasses); - passManagerBuilder.populateFunctionPassManager(PerFunctionPasses); + PassManagerBuilder passManagerBuilder; + passManagerBuilder.OptLevel = 3; + passManagerBuilder.SizeLevel = 0; + passManagerBuilder.Inliner = createFunctionInliningPass(); + passManagerBuilder.SLPVectorize = true; + passManagerBuilder.LoopVectorize = true; + passManagerBuilder.LoadCombine = true; + passManagerBuilder.populateModulePassManager(PerModulePasses); + passManagerBuilder.populateFunctionPassManager(PerFunctionPasses); - // Run function passes: - PerFunctionPasses.doInitialization(); - for (llvm::Function &func : *module) - { - if (!func.isDeclaration()) - PerFunctionPasses.run(func); + // Run function passes: + PerFunctionPasses.doInitialization(); + for (llvm::Function &func : *module) + { + if (!func.isDeclaration()) + PerFunctionPasses.run(func); + } + PerFunctionPasses.doFinalization(); + + // Run module passes: + PerModulePasses.run(*module); + + SaveCachedModule(module, version, targetCPU); } - PerFunctionPasses.doFinalization(); - // Run module passes: - PerModulePasses.run(*module); + Printf("Compiling drawers..\n"); // Create execution engine and generate machine code mEngine.reset(engineBuilder.create(machine)); From 08c4f2ac18b40b6fd07a7d88aaebd9140555d8f2 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 19 Nov 2016 17:08:08 -0500 Subject: [PATCH 1250/1509] - Added a tool to clear the LLVM cache, if ever there is corruption or it needs rebuilt. --- tools/DelLLVMCache.cmd | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tools/DelLLVMCache.cmd diff --git a/tools/DelLLVMCache.cmd b/tools/DelLLVMCache.cmd new file mode 100644 index 000000000..d7c3b1525 --- /dev/null +++ b/tools/DelLLVMCache.cmd @@ -0,0 +1,9 @@ +@echo off +if not exist %localappdata%\zdoom\cache\llvm* goto :eof +echo QZDoom's LLVM drawers may take some time to create at startup. Because of this, +echo the program uses a cache to temporarily store bitcode for faster startups. If +echo this cache is ever corrupted, this program has been created to solve the +echo problem. +echo. +echo Are you SURE you wish to destroy the cache? +del /p %localappdata%\zdoom\cache\llvm* From 845bf93c95bc69d5942ffa838d910fd04966005d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 20 Nov 2016 01:29:19 +0100 Subject: [PATCH 1251/1509] Change triangle full block to use vectored load and store --- .../fixedfunction/drawtrianglecodegen.cpp | 242 ++++++++++-------- .../fixedfunction/drawtrianglecodegen.h | 3 +- src/r_compiler/llvmdrawers.cpp | 2 +- src/r_compiler/ssa/ssa_bool.cpp | 6 + src/r_compiler/ssa/ssa_bool.h | 3 + 5 files changed, 152 insertions(+), 104 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index 1ad98a8fb..fbbca7517 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -303,57 +303,80 @@ void DrawTriangleCodegen::LoopFullBlock() { int pixelsize = truecolor ? 4 : 1; - stack_iy.store(SSAInt(0)); - stack_buffer.store(dest[x * pixelsize]); - stack_subsectorbuffer.store(subsectorGBuffer[x]); - - SSAForBlock loopy; - SSAInt iy = stack_iy.load(); - SSAUBytePtr buffer = stack_buffer.load(); - SSAIntPtr subsectorbuffer = stack_subsectorbuffer.load(); - loopy.loop_block(iy < SSAInt(q), q); + for (int iy = 0; iy < q; iy++) { + SSAUBytePtr buffer = dest[(x + iy * pitch) * pixelsize]; + SSAIntPtr subsectorbuffer = subsectorGBuffer[x + iy * pitch]; + + SSAInt varying[TriVertex::NumVarying]; SSAInt varyingStep[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) { - stack_varying[i].store((varyingPos[i] + varyingStepPos[i] * iy) << 8); + varying[i] = (varyingPos[i] + varyingStepPos[i] * iy) << 8; varyingStep[i] = (varyingStartStepX[i] + varyingIncrStepX[i] * iy) << 8; } - stack_ix.store(SSAInt(0)); - SSAForBlock loopx; - SSAInt ix = stack_ix.load(); - SSAInt varying[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] = stack_varying[i].load(); - loopx.loop_block(ix < SSAInt(q), q); + for (int ix = 0; ix < q; ix += 4) { - if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + SSAUBytePtr buf = buffer[ix * pixelsize]; + if (truecolor) { - SSAIfBlock branch; - branch.if_block(subsectorbuffer[ix].load(true) >= subsectorDepth); + SSAVec16ub pixels16 = buf.load_unaligned_vec16ub(false); + SSAVec8s pixels8hi = SSAVec8s::extendhi(pixels16); + SSAVec8s pixels8lo = SSAVec8s::extendlo(pixels16); + SSAVec4i pixels[4] = { - ProcessPixel(buffer[ix * pixelsize], subsectorbuffer[ix], varying); + SSAVec4i::extendlo(pixels8lo), + SSAVec4i::extendhi(pixels8lo), + SSAVec4i::extendlo(pixels8hi), + SSAVec4i::extendhi(pixels8hi) + }; + + for (int sse = 0; sse < 4; sse++) + { + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + { + SSABool subsectorTest = subsectorbuffer[ix].load(true) >= subsectorDepth; + pixels[sse] = subsectorTest.select(ProcessPixel32(pixels[sse], varying), pixels[sse]); + } + else + { + pixels[sse] = ProcessPixel32(pixels[sse], varying); + } + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] = varying[i] + varyingStep[i]; } - branch.end_block(); + + buf.store_unaligned_vec16ub(SSAVec16ub(SSAVec8s(pixels[0], pixels[1]), SSAVec8s(pixels[2], pixels[3]))); } else { - ProcessPixel(buffer[ix * pixelsize], subsectorbuffer[ix], varying); + SSAVec4i pixels = buf.load_vec4ub(false); + + for (int sse = 0; sse < 4; sse++) + { + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + { + SSABool subsectorTest = subsectorbuffer[ix].load(true) >= subsectorDepth; + pixels.insert(sse, subsectorTest.select(ProcessPixel8(pixels[sse], varying), pixels[sse])); + } + else + { + pixels.insert(sse, ProcessPixel8(pixels[sse], varying)); + } + + for (int i = 0; i < TriVertex::NumVarying; i++) + varying[i] = varying[i] + varyingStep[i]; + } + + buf.store_vec4ub(pixels); } - for (int i = 0; i < TriVertex::NumVarying; i++) - stack_varying[i].store(varying[i] + varyingStep[i]); - - stack_ix.store(ix + 1); + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) + subsectorbuffer[ix].store_unaligned_vec4i(SSAVec4i(subsectorDepth)); } - loopx.end_block(); - - stack_buffer.store(buffer[pitch * pixelsize]); - stack_subsectorbuffer.store(subsectorbuffer[pitch]); - stack_iy.store(iy + 1); } - loopy.end_block(); } if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) @@ -425,7 +448,21 @@ void DrawTriangleCodegen::LoopPartialBlock() } else { - ProcessPixel(buffer[ix * pixelsize], subsectorbuffer[ix], varying); + SSAUBytePtr buf = buffer[ix * pixelsize]; + + if (truecolor) + { + SSAVec4i bg = buf.load_vec4ub(false); + buf.store_vec4ub(ProcessPixel32(bg, varying)); + } + else + { + SSAUByte bg = buf.load(false); + buf.store(ProcessPixel8(bg.zext_int(), varying).trunc_ubyte()); + } + + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) + subsectorbuffer[ix].store(subsectorDepth); } } branch.end_block(); @@ -466,7 +503,7 @@ SSAVec4i DrawTriangleCodegen::Sample(SSAInt uvoffset) return texturePixels[uvoffset * 4].load_vec4ub(true); } -void DrawTriangleCodegen::ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbuffer, SSAInt *varying) +SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) { SSAInt ufrac = varying[0]; SSAInt vfrac = varying[1]; @@ -475,80 +512,81 @@ void DrawTriangleCodegen::ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbu SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; SSAInt uvoffset = upos * textureHeight + vpos; - if (truecolor) + SSAVec4i fg; + SSAInt alpha, inv_alpha; + SSAVec4i output; + + switch (blendmode) { - SSAVec4i fg; - SSAVec4i bg = buffer.load_vec4ub(false); - SSAInt alpha, inv_alpha; - SSAVec4i output; + default: + case TriBlendMode::Copy: + fg = Sample(uvoffset); + output = blend_copy(shade_bgra_simple(fg, currentlight)); break; + case TriBlendMode::AlphaBlend: + fg = Sample(uvoffset); + output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); break; + case TriBlendMode::AddSolid: + fg = Sample(uvoffset); + output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, destalpha); break; + case TriBlendMode::Add: + fg = Sample(uvoffset); + output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; + case TriBlendMode::Sub: + fg = Sample(uvoffset); + output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; + case TriBlendMode::RevSub: + fg = Sample(uvoffset); + output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; + case TriBlendMode::Shaded: + fg = Sample(uvoffset); + alpha = fg[0]; + alpha = alpha + (alpha >> 7); // 255 -> 256 + inv_alpha = 256 - alpha; + output = blend_add(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), bg, alpha, inv_alpha); + break; + case TriBlendMode::TranslateCopy: + fg = TranslateSample(uvoffset); + output = blend_copy(shade_bgra_simple(fg, currentlight)); + break; + case TriBlendMode::TranslateAlphaBlend: + fg = TranslateSample(uvoffset); + output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); break; + break; + case TriBlendMode::TranslateAdd: + fg = TranslateSample(uvoffset); + output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; + case TriBlendMode::TranslateSub: + fg = TranslateSample(uvoffset); + output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; + case TriBlendMode::TranslateRevSub: + fg = TranslateSample(uvoffset); + output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; + } - switch (blendmode) - { - default: - case TriBlendMode::Copy: - fg = Sample(uvoffset); - output = blend_copy(shade_bgra_simple(fg, currentlight)); break; - case TriBlendMode::AlphaBlend: - fg = Sample(uvoffset); - output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); break; - case TriBlendMode::AddSolid: - fg = Sample(uvoffset); - output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, destalpha); break; - case TriBlendMode::Add: - fg = Sample(uvoffset); - output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; - case TriBlendMode::Sub: - fg = Sample(uvoffset); - output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; - case TriBlendMode::RevSub: - fg = Sample(uvoffset); - output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; - case TriBlendMode::Shaded: - fg = Sample(uvoffset); - alpha = fg[0]; - alpha = alpha + (alpha >> 7); // 255 -> 256 - inv_alpha = 256 - alpha; - output = blend_add(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), bg, alpha, inv_alpha); - break; - case TriBlendMode::TranslateCopy: - fg = TranslateSample(uvoffset); - output = blend_copy(shade_bgra_simple(fg, currentlight)); - break; - case TriBlendMode::TranslateAlphaBlend: - fg = TranslateSample(uvoffset); - output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); break; - break; - case TriBlendMode::TranslateAdd: - fg = TranslateSample(uvoffset); - output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); - break; - case TriBlendMode::TranslateSub: - fg = TranslateSample(uvoffset); - output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); - break; - case TriBlendMode::TranslateRevSub: - fg = TranslateSample(uvoffset); - output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); - break; - } + return output; +} - buffer.store_vec4ub(output); +SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) +{ + SSAInt ufrac = varying[0]; + SSAInt vfrac = varying[1]; + + SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; + SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; + SSAInt uvoffset = upos * textureHeight + vpos; + + if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + { + return color; } else { - if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) - { - buffer.store(color.trunc_ubyte()); - } - else - { - SSAUByte fg = texturePixels[uvoffset].load(true); - buffer.store(fg); - } + SSAUByte fg = texturePixels[uvoffset].load(true); + return fg.zext_int(); } - - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) - subsectorbuffer.store(subsectorDepth); } void DrawTriangleCodegen::SetStencilBlock(SSAInt block) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.h b/src/r_compiler/fixedfunction/drawtrianglecodegen.h index d5539ef22..e4c22d49c 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.h +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.h @@ -46,7 +46,8 @@ private: void LoopFullBlock(); void LoopPartialBlock(); - void ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbuffer, SSAInt *varying); + SSAVec4i ProcessPixel32(SSAVec4i bg, SSAInt *varying); + SSAInt ProcessPixel8(SSAInt bg, SSAInt *varying); SSAVec4i TranslateSample(SSAInt uvoffset); SSAVec4i Sample(SSAInt uvoffset); diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index a3432eae6..913e5d9b7 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -127,7 +127,7 @@ LLVMDrawers *LLVMDrawers::Instance() LLVMDrawersImpl::LLVMDrawersImpl() { - int version = 1; // Increment this number if the drawer codegen is modified (forces recreation of the module). + int version = 2; // Increment this number if the drawer codegen is modified (forces recreation of the module). std::string targetCPU = mProgram.GetTargetCPU(); bool loaded = mProgram.LoadCachedModule(version, targetCPU); if (!loaded) diff --git a/src/r_compiler/ssa/ssa_bool.cpp b/src/r_compiler/ssa/ssa_bool.cpp index 65cc25c90..916350c59 100644 --- a/src/r_compiler/ssa/ssa_bool.cpp +++ b/src/r_compiler/ssa/ssa_bool.cpp @@ -23,6 +23,7 @@ #include "r_compiler/llvm_include.h" #include "ssa_bool.h" #include "ssa_ubyte.h" +#include "ssa_vec4i.h" #include "ssa_value.h" #include "ssa_scope.h" @@ -61,6 +62,11 @@ SSAUByte SSABool::select(SSAUByte a, SSAUByte b) return SSAValue::from_llvm(SSAScope::builder().CreateSelect(v, a.v, b.v, SSAScope::hint())); } +SSAVec4i SSABool::select(SSAVec4i a, SSAVec4i b) +{ + return SSAValue::from_llvm(SSAScope::builder().CreateSelect(v, a.v, b.v, SSAScope::hint())); +} + SSABool operator&&(const SSABool &a, const SSABool &b) { return SSABool::from_llvm(SSAScope::builder().CreateAnd(a.v, b.v, SSAScope::hint())); diff --git a/src/r_compiler/ssa/ssa_bool.h b/src/r_compiler/ssa/ssa_bool.h index 2ed6e7d4a..372c626c0 100644 --- a/src/r_compiler/ssa/ssa_bool.h +++ b/src/r_compiler/ssa/ssa_bool.h @@ -29,6 +29,8 @@ namespace llvm { class Value; } namespace llvm { class Type; } +class SSAVec4i; + class SSABool { public: @@ -41,6 +43,7 @@ public: SSAInt zext_int(); SSAInt select(SSAInt a, SSAInt b); SSAUByte select(SSAUByte a, SSAUByte b); + SSAVec4i select(SSAVec4i a, SSAVec4i b); llvm::Value *v; }; From f8efe394cc475722ae9e13fdabc61945480dcdbf Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 20 Nov 2016 01:51:08 +0100 Subject: [PATCH 1252/1509] Remove unused code --- src/r_poly_triangle.cpp | 1314 --------------------------------------- src/r_poly_triangle.h | 76 +-- 2 files changed, 4 insertions(+), 1386 deletions(-) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 07a4566dd..ad9f7ff95 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -36,10 +36,6 @@ #include "r_data/colormaps.h" #include "r_poly_triangle.h" -#ifndef NO_SSE -#include -#endif - int PolyTriangleDrawer::viewport_x; int PolyTriangleDrawer::viewport_y; int PolyTriangleDrawer::viewport_width; @@ -324,1316 +320,6 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert ///////////////////////////////////////////////////////////////////////////// -#if 0 -void ScreenPolyTriangleDrawer::draw(const TriDrawTriangleArgs *args, WorkerThreadData *thread) -{ - uint8_t *dest = args->dest; - int pitch = args->pitch; - const TriVertex &v1 = *args->v1; - const TriVertex &v2 = *args->v2; - const TriVertex &v3 = *args->v3; - int clipleft = args->clipleft; - int clipright = args->clipright; - int cliptop = args->cliptop; - int clipbottom = args->clipbottom; - const uint8_t *texturePixels = args->texturePixels; - int textureWidth = args->textureWidth; - int textureHeight = args->textureHeight; - - // 28.4 fixed-point coordinates - const int Y1 = (int)round(16.0f * v1.y); - const int Y2 = (int)round(16.0f * v2.y); - const int Y3 = (int)round(16.0f * v3.y); - - const int X1 = (int)round(16.0f * v1.x); - const int X2 = (int)round(16.0f * v2.x); - const int X3 = (int)round(16.0f * v3.x); - - // Deltas - const int DX12 = X1 - X2; - const int DX23 = X2 - X3; - const int DX31 = X3 - X1; - - const int DY12 = Y1 - Y2; - const int DY23 = Y2 - Y3; - const int DY31 = Y3 - Y1; - - // Fixed-point deltas - const int FDX12 = DX12 << 4; - const int FDX23 = DX23 << 4; - const int FDX31 = DX31 << 4; - - const int FDY12 = DY12 << 4; - const int FDY23 = DY23 << 4; - const int FDY31 = DY31 << 4; - - // Bounding rectangle - int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); - int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); - int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, cliptop); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); - if (minx >= maxx || miny >= maxy) - return; - - // Block size, standard 8x8 (must be power of two) - const int q = 8; - - // Start in corner of 8x8 block - minx &= ~(q - 1); - miny &= ~(q - 1); - - dest += miny * pitch; - - // Half-edge constants - int C1 = DY12 * X1 - DX12 * Y1; - int C2 = DY23 * X2 - DX23 * Y2; - int C3 = DY31 * X3 - DX31 * Y3; - - // Correct for fill convention - if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; - if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; - if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; - - // Gradients - float gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - float gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - float startW = v1.w + gradWX * (minx - v1.x) + gradWY * (miny - v1.y); - float gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (minx - v1.x) + gradVaryingY[i] * (miny - v1.y); - } - - // Loop through blocks - for (int y = miny; y < maxy; y += q, dest += q * pitch) - { - // Is this row of blocks done by this thread? - if (thread && ((y / q) % thread->num_cores != thread->core)) continue; - - for (int x = minx; x < maxx; x += q) - { - // Corners of block - int x0 = x << 4; - int x1 = (x + q - 1) << 4; - int y0 = y << 4; - int y1 = (y + q - 1) << 4; - - // Evaluate half-space functions - bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; - bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; - bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; - bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; - int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); - - bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; - bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; - bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; - bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; - int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); - - bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; - bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; - bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; - bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; - int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); - - // Skip block when outside an edge - if (a == 0x0 || b == 0x0 || c == 0x0) continue; - - // Check if block needs clipping - bool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); - - // Calculate varying variables for affine block - float offx0 = (x - minx) + 0.5f; - float offy0 = (y - miny) + 0.5f; - float offx1 = offx0 + q; - float offy1 = offy0 + q; - float rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); - float rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); - float rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); - float rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); - float varyingTL[TriVertex::NumVarying]; - float varyingTR[TriVertex::NumVarying]; - float varyingBL[TriVertex::NumVarying]; - float varyingBR[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; - varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; - varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); - varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); - } - - uint8_t *buffer = dest; - - // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && !clipneeded) - { - for (int iy = 0; iy < q; iy++) - { - uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - float pos = varyingTL[i] + varyingBL[i] * iy; - float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); - - varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); - varyingStep[i] = (uint32_t)(step * 0x100000000LL); - } - - for (int ix = x; ix < x + q; ix++) - { - uint32_t ufrac = varying[0]; - uint32_t vfrac = varying[1]; - - uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; - uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; - uint32_t uvoffset = upos * textureHeight + vpos; - - if (texturePixels[uvoffset] != 0) - buffer[ix] = texturePixels[uvoffset]; - - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; - } - - buffer += pitch; - } - } - else // Partially covered block - { - int CY1 = C1 + DX12 * y0 - DY12 * x0; - int CY2 = C2 + DX23 * y0 - DY23 * x0; - int CY3 = C3 + DX31 * y0 - DY31 * x0; - - for (int iy = 0; iy < q; iy++) - { - int CX1 = CY1; - int CX2 = CY2; - int CX3 = CY3; - - uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - float pos = varyingTL[i] + varyingBL[i] * iy; - float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); - - varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); - varyingStep[i] = (uint32_t)(step * 0x100000000LL); - } - - for (int ix = x; ix < x + q; ix++) - { - bool visible = ix >= clipleft && ix < clipright && (cliptop <= y + iy) && (clipbottom > y + iy); - - if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) - { - uint32_t ufrac = varying[0]; - uint32_t vfrac = varying[1]; - - uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; - uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; - uint32_t uvoffset = upos * textureHeight + vpos; - - if (texturePixels[uvoffset] != 0) - buffer[ix] = texturePixels[uvoffset]; - } - - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; - - CX1 -= FDY12; - CX2 -= FDY23; - CX3 -= FDY31; - } - - CY1 += FDX12; - CY2 += FDX23; - CY3 += FDX31; - - buffer += pitch; - } - } - } - } -} - -void ScreenPolyTriangleDrawer::fill(const TriDrawTriangleArgs *args, WorkerThreadData *thread) -{ - uint8_t *dest = args->dest; - int pitch = args->pitch; - const TriVertex &v1 = *args->v1; - const TriVertex &v2 = *args->v2; - const TriVertex &v3 = *args->v3; - int clipleft = args->clipleft; - int clipright = args->clipright; - int cliptop = args->cliptop; - int clipbottom = args->clipbottom; - int solidcolor = args->solidcolor; - - // 28.4 fixed-point coordinates - const int Y1 = (int)round(16.0f * v1.y); - const int Y2 = (int)round(16.0f * v2.y); - const int Y3 = (int)round(16.0f * v3.y); - - const int X1 = (int)round(16.0f * v1.x); - const int X2 = (int)round(16.0f * v2.x); - const int X3 = (int)round(16.0f * v3.x); - - // Deltas - const int DX12 = X1 - X2; - const int DX23 = X2 - X3; - const int DX31 = X3 - X1; - - const int DY12 = Y1 - Y2; - const int DY23 = Y2 - Y3; - const int DY31 = Y3 - Y1; - - // Fixed-point deltas - const int FDX12 = DX12 << 4; - const int FDX23 = DX23 << 4; - const int FDX31 = DX31 << 4; - - const int FDY12 = DY12 << 4; - const int FDY23 = DY23 << 4; - const int FDY31 = DY31 << 4; - - // Bounding rectangle - int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); - int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); - int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, cliptop); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); - if (minx >= maxx || miny >= maxy) - return; - - // Block size, standard 8x8 (must be power of two) - const int q = 8; - - // Start in corner of 8x8 block - minx &= ~(q - 1); - miny &= ~(q - 1); - - dest += miny * pitch; - - // Half-edge constants - int C1 = DY12 * X1 - DX12 * Y1; - int C2 = DY23 * X2 - DX23 * Y2; - int C3 = DY31 * X3 - DX31 * Y3; - - // Correct for fill convention - if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; - if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; - if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; - - // Loop through blocks - for (int y = miny; y < maxy; y += q, dest += q * pitch) - { - // Is this row of blocks done by this thread? - if (thread && ((y / q) % thread->num_cores != thread->core)) continue; - - for (int x = minx; x < maxx; x += q) - { - // Corners of block - int x0 = x << 4; - int x1 = (x + q - 1) << 4; - int y0 = y << 4; - int y1 = (y + q - 1) << 4; - - // Evaluate half-space functions - bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; - bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; - bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; - bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; - int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); - - bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; - bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; - bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; - bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; - int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); - - bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; - bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; - bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; - bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; - int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); - - // Skip block when outside an edge - if (a == 0x0 || b == 0x0 || c == 0x0) continue; - - // Check if block needs clipping - bool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); - - uint8_t *buffer = dest; - - // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && !clipneeded) - { - for (int iy = 0; iy < q; iy++) - { - for (int ix = x; ix < x + q; ix++) - { - buffer[ix] = solidcolor; - } - - buffer += pitch; - } - } - else // Partially covered block - { - int CY1 = C1 + DX12 * y0 - DY12 * x0; - int CY2 = C2 + DX23 * y0 - DY23 * x0; - int CY3 = C3 + DX31 * y0 - DY31 * x0; - - for (int iy = 0; iy < q; iy++) - { - int CX1 = CY1; - int CX2 = CY2; - int CX3 = CY3; - - for (int ix = x; ix < x + q; ix++) - { - bool visible = ix >= clipleft && ix < clipright && (cliptop <= y + iy) && (clipbottom > y + iy); - - if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) - { - buffer[ix] = solidcolor; - } - - CX1 -= FDY12; - CX2 -= FDY23; - CX3 -= FDY31; - } - - CY1 += FDX12; - CY2 += FDX23; - CY3 += FDX31; - - buffer += pitch; - } - } - } - } -} - -void ScreenPolyTriangleDrawer::stencil(const TriDrawTriangleArgs *args, WorkerThreadData *thread) -{ - const TriVertex &v1 = *args->v1; - const TriVertex &v2 = *args->v2; - const TriVertex &v3 = *args->v3; - int clipleft = args->clipleft; - int clipright = args->clipright; - int cliptop = args->cliptop; - int clipbottom = args->clipbottom; - int solidcolor = args->solidcolor; - uint8_t *stencilValues = args->stencilValues; - uint32_t *stencilMasks = args->stencilMasks; - int stencilPitch = args->stencilPitch; - uint8_t stencilTestValue = args->stencilTestValue; - uint8_t stencilWriteValue = args->stencilWriteValue; - - // 28.4 fixed-point coordinates - const int Y1 = (int)round(16.0f * v1.y); - const int Y2 = (int)round(16.0f * v2.y); - const int Y3 = (int)round(16.0f * v3.y); - - const int X1 = (int)round(16.0f * v1.x); - const int X2 = (int)round(16.0f * v2.x); - const int X3 = (int)round(16.0f * v3.x); - - // Deltas - const int DX12 = X1 - X2; - const int DX23 = X2 - X3; - const int DX31 = X3 - X1; - - const int DY12 = Y1 - Y2; - const int DY23 = Y2 - Y3; - const int DY31 = Y3 - Y1; - - // Fixed-point deltas - const int FDX12 = DX12 << 4; - const int FDX23 = DX23 << 4; - const int FDX31 = DX31 << 4; - - const int FDY12 = DY12 << 4; - const int FDY23 = DY23 << 4; - const int FDY31 = DY31 << 4; - - // Bounding rectangle - int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); - int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); - int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, cliptop); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); - if (minx >= maxx || miny >= maxy) - return; - - // Block size, standard 8x8 (must be power of two) - const int q = 8; - - // Start in corner of 8x8 block - minx &= ~(q - 1); - miny &= ~(q - 1); - - // Half-edge constants - int C1 = DY12 * X1 - DX12 * Y1; - int C2 = DY23 * X2 - DX23 * Y2; - int C3 = DY31 * X3 - DX31 * Y3; - - // Correct for fill convention - if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; - if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; - if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; - - // Loop through blocks - for (int y = miny; y < maxy; y += q) - { - // Is this row of blocks done by this thread? - if (thread && ((y / q) % thread->num_cores != thread->core)) continue; - - for (int x = minx; x < maxx; x += q) - { - // Corners of block - int x0 = x << 4; - int x1 = (x + q - 1) << 4; - int y0 = y << 4; - int y1 = (y + q - 1) << 4; - - // Evaluate half-space functions - bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; - bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; - bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; - bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; - int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); - - bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; - bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; - bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; - bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; - int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); - - bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; - bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; - bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; - bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; - int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); - - // Skip block when outside an edge - if (a == 0x0 || b == 0x0 || c == 0x0) continue; - - // Check if block needs clipping - bool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); - - PolyStencilBlock stencil(x / 8 + y / 8 * stencilPitch, stencilValues, stencilMasks); - - // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && !clipneeded && stencil.IsSingleValue()) - { - // Reject whole block if the stencil test fails - if (stencil.Get(0, 0) != stencilTestValue) - continue; - stencil.Clear(stencilWriteValue); - } - else // Partially covered block - { - int CY1 = C1 + DX12 * y0 - DY12 * x0; - int CY2 = C2 + DX23 * y0 - DY23 * x0; - int CY3 = C3 + DX31 * y0 - DY31 * x0; - - for (int iy = 0; iy < q; iy++) - { - int CX1 = CY1; - int CX2 = CY2; - int CX3 = CY3; - - for (int ix = 0; ix < q; ix++) - { - bool visible = (ix + x >= clipleft) && (ix + x < clipright) && (cliptop <= y + iy) && (clipbottom > y + iy); - - if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible && stencil.Get(ix, iy) == stencilTestValue) - { - stencil.Set(ix, iy, stencilWriteValue); - } - - CX1 -= FDY12; - CX2 -= FDY23; - CX3 -= FDY31; - } - - CY1 += FDX12; - CY2 += FDX23; - CY3 += FDX31; - } - } - } - } -} - -void ScreenPolyTriangleDrawer::draw32(const TriDrawTriangleArgs *args, WorkerThreadData *thread) -{ - uint32_t *dest = (uint32_t *)args->dest; - int pitch = args->pitch; - const TriVertex &v1 = *args->v1; - const TriVertex &v2 = *args->v2; - const TriVertex &v3 = *args->v3; - int clipleft = args->clipleft; - int clipright = args->clipright; - int cliptop = args->cliptop; - int clipbottom = args->clipbottom; - const uint32_t *texturePixels = (const uint32_t *)args->texturePixels; - int textureWidth = args->textureWidth; - int textureHeight = args->textureHeight; - uint8_t *stencilValues = args->stencilValues; - uint32_t *stencilMasks = args->stencilMasks; - int stencilPitch = args->stencilPitch; - uint8_t stencilTestValue = args->stencilTestValue; - uint32_t light = args->uniforms->light; - uint32_t subsector = args->uniforms->subsectorDepth; - uint32_t *subsectorGBuffer = args->subsectorGBuffer; - - // 28.4 fixed-point coordinates - const int Y1 = (int)round(16.0f * v1.y); - const int Y2 = (int)round(16.0f * v2.y); - const int Y3 = (int)round(16.0f * v3.y); - - const int X1 = (int)round(16.0f * v1.x); - const int X2 = (int)round(16.0f * v2.x); - const int X3 = (int)round(16.0f * v3.x); - - // Deltas - const int DX12 = X1 - X2; - const int DX23 = X2 - X3; - const int DX31 = X3 - X1; - - const int DY12 = Y1 - Y2; - const int DY23 = Y2 - Y3; - const int DY31 = Y3 - Y1; - - // Fixed-point deltas - const int FDX12 = DX12 << 4; - const int FDX23 = DX23 << 4; - const int FDX31 = DX31 << 4; - - const int FDY12 = DY12 << 4; - const int FDY23 = DY23 << 4; - const int FDY31 = DY31 << 4; - - // Bounding rectangle - int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); - int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); - int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, cliptop); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); - if (minx >= maxx || miny >= maxy) - return; - - // Block size, standard 8x8 (must be power of two) - const int q = 8; - - // Start in corner of 8x8 block - minx &= ~(q - 1); - miny &= ~(q - 1); - - dest += miny * pitch; - subsectorGBuffer += miny * pitch; - - // Half-edge constants - int C1 = DY12 * X1 - DX12 * Y1; - int C2 = DY23 * X2 - DX23 * Y2; - int C3 = DY31 * X3 - DX31 * Y3; - - // Correct for fill convention - if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; - if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; - if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; - - // Gradients - float gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - float gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - float startW = v1.w + gradWX * (minx - v1.x) + gradWY * (miny - v1.y); - float gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (minx - v1.x) + gradVaryingY[i] * (miny - v1.y); - } - - // Loop through blocks - for (int y = miny; y < maxy; y += q, dest += q * pitch, subsectorGBuffer += q * pitch) - { - // Is this row of blocks done by this thread? - if ((y / q) % thread->num_cores != thread->core) continue; - - for (int x = minx; x < maxx; x += q) - { - // Corners of block - int x0 = x << 4; - int x1 = (x + q - 1) << 4; - int y0 = y << 4; - int y1 = (y + q - 1) << 4; - - // Evaluate half-space functions - bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; - bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; - bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; - bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; - int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); - - bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; - bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; - bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; - bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; - int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); - - bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; - bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; - bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; - bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; - int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); - - // Skip block when outside an edge - if (a == 0x0 || b == 0x0 || c == 0x0) continue; - - // Check if block needs clipping - bool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); - - // Calculate varying variables for affine block - float offx0 = (x - minx) + 0.5f; - float offy0 = (y - miny) + 0.5f; - float offx1 = offx0 + q; - float offy1 = offy0 + q; - float rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); - float rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); - float rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); - float rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); - float varyingTL[TriVertex::NumVarying]; - float varyingTR[TriVertex::NumVarying]; - float varyingBL[TriVertex::NumVarying]; - float varyingBR[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; - varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; - varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); - varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); - } - - float globVis = 1706.0f; - float vis = globVis / rcpWTL; - float shade = 64.0f - (light * 255 / 256 + 12.0f) * 32.0f / 128.0f; - float lightscale = clamp((shade - MIN(24.0f, vis)) / 32.0f, 0.0f, 31.0f / 32.0f); - int diminishedlight = (int)clamp((1.0f - lightscale) * 256.0f + 0.5f, 0.0f, 256.0f); - -#if !defined(NO_SSE) - __m128i mlight = _mm_set1_epi16(diminishedlight); -#endif - - uint32_t *buffer = dest; - uint32_t *subsectorbuffer = subsectorGBuffer; - - PolyStencilBlock stencil(x / 8 + y / 8 * stencilPitch, stencilValues, stencilMasks); - - // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && !clipneeded && stencil.IsSingleValue()) - { - // Reject whole block if the stencil test fails - if (stencil.Get(0, 0) != stencilTestValue) - continue; - - for (int iy = 0; iy < q; iy++) - { - uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - float pos = varyingTL[i] + varyingBL[i] * iy; - float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); - - varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); - varyingStep[i] = (uint32_t)(step * 0x100000000LL); - } - -#if NO_SSE - for (int ix = x; ix < x + q; ix++) - { - uint32_t ufrac = varying[0]; - uint32_t vfrac = varying[1]; - - uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; - uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; - uint32_t uvoffset = upos * textureHeight + vpos; - - uint32_t fg = texturePixels[uvoffset]; - uint32_t fg_red = (RPART(fg) * diminishedlight) >> 8; - uint32_t fg_green = (GPART(fg) * diminishedlight) >> 8; - uint32_t fg_blue = (BPART(fg) * diminishedlight) >> 8; - uint32_t fg_alpha = APART(fg); - - if (fg_alpha > 127) - { - buffer[ix] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; - subsectorbuffer[ix] = subsector; - } - - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; - } -#else - for (int sse = 0; sse < q / 4; sse++) - { - uint32_t fg[4]; - for (int ix = 0; ix < 4; ix++) - { - uint32_t ufrac = varying[0]; - uint32_t vfrac = varying[1]; - uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; - uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; - uint32_t uvoffset = upos * textureHeight + vpos; - fg[ix] = texturePixels[uvoffset]; - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; - } - - __m128i mfg = _mm_loadu_si128((const __m128i*)fg); - __m128i mfg0 = _mm_unpacklo_epi8(mfg, _mm_setzero_si128()); - __m128i mfg1 = _mm_unpackhi_epi8(mfg, _mm_setzero_si128()); - __m128i mout0 = _mm_srli_epi16(_mm_mullo_epi16(mfg0, mlight), 8); - __m128i mout1 = _mm_srli_epi16(_mm_mullo_epi16(mfg1, mlight), 8); - __m128i mout = _mm_packus_epi16(mout0, mout1); - __m128i mmask0 = _mm_shufflehi_epi16(_mm_shufflelo_epi16(mfg0, _MM_SHUFFLE(3, 3, 3, 3)), _MM_SHUFFLE(3, 3, 3, 3)); - __m128i mmask1 = _mm_shufflehi_epi16(_mm_shufflelo_epi16(mfg1, _MM_SHUFFLE(3, 3, 3, 3)), _MM_SHUFFLE(3, 3, 3, 3)); - __m128i mmask = _mm_cmplt_epi8(_mm_packus_epi16(mmask0, mmask1), _mm_setzero_si128()); - _mm_maskmoveu_si128(mout, mmask, (char*)(&buffer[x + sse * 4])); - - __m128i msubsector = _mm_set1_epi32(subsector); - _mm_maskmoveu_si128(msubsector, mmask, (char*)(&subsectorbuffer[x + sse * 4])); - } -#endif - - buffer += pitch; - subsectorbuffer += pitch; - } - } - else // Partially covered block - { - int CY1 = C1 + DX12 * y0 - DY12 * x0; - int CY2 = C2 + DX23 * y0 - DY23 * x0; - int CY3 = C3 + DX31 * y0 - DY31 * x0; - - for (int iy = 0; iy < q; iy++) - { - int CX1 = CY1; - int CX2 = CY2; - int CX3 = CY3; - - uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - float pos = varyingTL[i] + varyingBL[i] * iy; - float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); - - varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); - varyingStep[i] = (uint32_t)(step * 0x100000000LL); - } - - for (int ix = 0; ix < q; ix++) - { - bool visible = (ix + x >= clipleft) && (ix + x < clipright) && (cliptop <= y + iy) && (clipbottom > y + iy); - - if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible && stencil.Get(ix, iy) == stencilTestValue) - { - uint32_t ufrac = varying[0]; - uint32_t vfrac = varying[1]; - - uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; - uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; - uint32_t uvoffset = upos * textureHeight + vpos; - - uint32_t fg = texturePixels[uvoffset]; - uint32_t fg_red = (RPART(fg) * diminishedlight) >> 8; - uint32_t fg_green = (GPART(fg) * diminishedlight) >> 8; - uint32_t fg_blue = (BPART(fg) * diminishedlight) >> 8; - uint32_t fg_alpha = APART(fg); - - if (fg_alpha > 127) - { - buffer[ix + x] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; - subsectorbuffer[ix + x] = subsector; - } - } - - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; - - CX1 -= FDY12; - CX2 -= FDY23; - CX3 -= FDY31; - } - - CY1 += FDX12; - CY2 += FDX23; - CY3 += FDX31; - - buffer += pitch; - subsectorbuffer += pitch; - } - } - } - } -} - -void ScreenPolyTriangleDrawer::drawsubsector32(const TriDrawTriangleArgs *args, WorkerThreadData *thread) -{ - uint32_t *dest = (uint32_t *)args->dest; - int pitch = args->pitch; - const TriVertex &v1 = *args->v1; - const TriVertex &v2 = *args->v2; - const TriVertex &v3 = *args->v3; - int clipleft = args->clipleft; - int clipright = args->clipright; - int cliptop = args->cliptop; - int clipbottom = args->clipbottom; - const uint32_t *texturePixels = (const uint32_t *)args->texturePixels; - int textureWidth = args->textureWidth; - int textureHeight = args->textureHeight; - uint32_t light = args->uniforms->light; - uint32_t subsector = args->uniforms->subsectorDepth; - uint32_t *subsectorGBuffer = args->subsectorGBuffer; - - // 28.4 fixed-point coordinates - const int Y1 = (int)round(16.0f * v1.y); - const int Y2 = (int)round(16.0f * v2.y); - const int Y3 = (int)round(16.0f * v3.y); - - const int X1 = (int)round(16.0f * v1.x); - const int X2 = (int)round(16.0f * v2.x); - const int X3 = (int)round(16.0f * v3.x); - - // Deltas - const int DX12 = X1 - X2; - const int DX23 = X2 - X3; - const int DX31 = X3 - X1; - - const int DY12 = Y1 - Y2; - const int DY23 = Y2 - Y3; - const int DY31 = Y3 - Y1; - - // Fixed-point deltas - const int FDX12 = DX12 << 4; - const int FDX23 = DX23 << 4; - const int FDX31 = DX31 << 4; - - const int FDY12 = DY12 << 4; - const int FDY23 = DY23 << 4; - const int FDY31 = DY31 << 4; - - // Bounding rectangle - int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); - int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); - int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, cliptop); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); - if (minx >= maxx || miny >= maxy) - return; - - // Block size, standard 8x8 (must be power of two) - const int q = 8; - - // Start in corner of 8x8 block - minx &= ~(q - 1); - miny &= ~(q - 1); - - dest += miny * pitch; - subsectorGBuffer += miny * pitch; - - // Half-edge constants - int C1 = DY12 * X1 - DX12 * Y1; - int C2 = DY23 * X2 - DX23 * Y2; - int C3 = DY31 * X3 - DX31 * Y3; - - // Correct for fill convention - if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; - if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; - if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; - - // Gradients - float gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - float gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - float startW = v1.w + gradWX * (minx - v1.x) + gradWY * (miny - v1.y); - float gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (minx - v1.x) + gradVaryingY[i] * (miny - v1.y); - } - - // Loop through blocks - for (int y = miny; y < maxy; y += q, dest += q * pitch, subsectorGBuffer += q * pitch) - { - // Is this row of blocks done by this thread? - if ((y / q) % thread->num_cores != thread->core) continue; - - for (int x = minx; x < maxx; x += q) - { - // Corners of block - int x0 = x << 4; - int x1 = (x + q - 1) << 4; - int y0 = y << 4; - int y1 = (y + q - 1) << 4; - - // Evaluate half-space functions - bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; - bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; - bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; - bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; - int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); - - bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; - bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; - bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; - bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; - int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); - - bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; - bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; - bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; - bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; - int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); - - // Skip block when outside an edge - if (a == 0x0 || b == 0x0 || c == 0x0) continue; - - // Check if block needs clipping - bool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); - - // Calculate varying variables for affine block - float offx0 = (x - minx) + 0.5f; - float offy0 = (y - miny) + 0.5f; - float offx1 = offx0 + q; - float offy1 = offy0 + q; - float rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); - float rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); - float rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); - float rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); - float varyingTL[TriVertex::NumVarying]; - float varyingTR[TriVertex::NumVarying]; - float varyingBL[TriVertex::NumVarying]; - float varyingBR[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; - varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; - varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); - varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); - } - - float globVis = 1706.0f; - float vis = globVis / rcpWTL; - float shade = 64.0f - (light * 255 / 256 + 12.0f) * 32.0f / 128.0f; - float lightscale = clamp((shade - MIN(24.0f, vis)) / 32.0f, 0.0f, 31.0f / 32.0f); - int diminishedlight = (int)clamp((1.0f - lightscale) * 256.0f + 0.5f, 0.0f, 256.0f); - -#if !defined(NO_SSE) - __m128i mlight = _mm_set1_epi16(diminishedlight); -#endif - - uint32_t *buffer = dest; - uint32_t *subsectorbuffer = subsectorGBuffer; - - // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && !clipneeded) - { - for (int iy = 0; iy < q; iy++) - { - uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - float pos = varyingTL[i] + varyingBL[i] * iy; - float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); - - varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); - varyingStep[i] = (uint32_t)(step * 0x100000000LL); - } - - for (int ix = x; ix < x + q; ix++) - { - if (subsectorbuffer[ix] >= subsector) - { - uint32_t ufrac = varying[0]; - uint32_t vfrac = varying[1]; - - uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; - uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; - uint32_t uvoffset = upos * textureHeight + vpos; - - uint32_t fg = texturePixels[uvoffset]; - uint32_t fg_red = (RPART(fg) * diminishedlight) >> 8; - uint32_t fg_green = (GPART(fg) * diminishedlight) >> 8; - uint32_t fg_blue = (BPART(fg) * diminishedlight) >> 8; - uint32_t fg_alpha = APART(fg); - - if (fg_alpha > 127) - buffer[ix] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; - } - - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; - } - - buffer += pitch; - subsectorbuffer += pitch; - } - } - else // Partially covered block - { - int CY1 = C1 + DX12 * y0 - DY12 * x0; - int CY2 = C2 + DX23 * y0 - DY23 * x0; - int CY3 = C3 + DX31 * y0 - DY31 * x0; - - for (int iy = 0; iy < q; iy++) - { - int CX1 = CY1; - int CX2 = CY2; - int CX3 = CY3; - - uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - float pos = varyingTL[i] + varyingBL[i] * iy; - float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); - - varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); - varyingStep[i] = (uint32_t)(step * 0x100000000LL); - } - - for (int ix = 0; ix < q; ix++) - { - bool visible = (ix + x >= clipleft) && (ix + x < clipright) && (cliptop <= y + iy) && (clipbottom > y + iy); - - if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible && subsectorbuffer[ix + x] >= subsector) - { - uint32_t ufrac = varying[0]; - uint32_t vfrac = varying[1]; - - uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; - uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; - uint32_t uvoffset = upos * textureHeight + vpos; - - uint32_t fg = texturePixels[uvoffset]; - uint32_t fg_red = (RPART(fg) * diminishedlight) >> 8; - uint32_t fg_green = (GPART(fg) * diminishedlight) >> 8; - uint32_t fg_blue = (BPART(fg) * diminishedlight) >> 8; - uint32_t fg_alpha = APART(fg); - - if (fg_alpha > 127) - buffer[ix + x] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; - } - - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; - - CX1 -= FDY12; - CX2 -= FDY23; - CX3 -= FDY31; - } - - CY1 += FDX12; - CY2 += FDX23; - CY3 += FDX31; - - buffer += pitch; - subsectorbuffer += pitch; - } - } - } - } -} - -void ScreenPolyTriangleDrawer::fill32(const TriDrawTriangleArgs *args, WorkerThreadData *thread) -{ - uint32_t *dest = (uint32_t *)args->dest; - int pitch = args->pitch; - const TriVertex &v1 = *args->v1; - const TriVertex &v2 = *args->v2; - const TriVertex &v3 = *args->v3; - int clipleft = args->clipleft; - int clipright = args->clipright; - int cliptop = args->cliptop; - int clipbottom = args->clipbottom; - int solidcolor = args->solidcolor; - uint8_t *stencilValues = args->stencilValues; - uint32_t *stencilMasks = args->stencilMasks; - int stencilPitch = args->stencilPitch; - uint8_t stencilTestValue = args->stencilTestValue; - - // 28.4 fixed-point coordinates - const int Y1 = (int)round(16.0f * v1.y); - const int Y2 = (int)round(16.0f * v2.y); - const int Y3 = (int)round(16.0f * v3.y); - - const int X1 = (int)round(16.0f * v1.x); - const int X2 = (int)round(16.0f * v2.x); - const int X3 = (int)round(16.0f * v3.x); - - // Deltas - const int DX12 = X1 - X2; - const int DX23 = X2 - X3; - const int DX31 = X3 - X1; - - const int DY12 = Y1 - Y2; - const int DY23 = Y2 - Y3; - const int DY31 = Y3 - Y1; - - // Fixed-point deltas - const int FDX12 = DX12 << 4; - const int FDX23 = DX23 << 4; - const int FDX31 = DX31 << 4; - - const int FDY12 = DY12 << 4; - const int FDY23 = DY23 << 4; - const int FDY31 = DY31 << 4; - - // Bounding rectangle - int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); - int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); - int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, cliptop); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); - if (minx >= maxx || miny >= maxy) - return; - - // Block size, standard 8x8 (must be power of two) - const int q = 8; - - // Start in corner of 8x8 block - minx &= ~(q - 1); - miny &= ~(q - 1); - - dest += miny * pitch; - - // Half-edge constants - int C1 = DY12 * X1 - DX12 * Y1; - int C2 = DY23 * X2 - DX23 * Y2; - int C3 = DY31 * X3 - DX31 * Y3; - - // Correct for fill convention - if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; - if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; - if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; - - // Loop through blocks - for (int y = miny; y < maxy; y += q, dest += q * pitch) - { - // Is this row of blocks done by this thread? - if ((y / q) % thread->num_cores != thread->core) continue; - - for (int x = minx; x < maxx; x += q) - { - // Corners of block - int x0 = x << 4; - int x1 = (x + q - 1) << 4; - int y0 = y << 4; - int y1 = (y + q - 1) << 4; - - // Evaluate half-space functions - bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; - bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; - bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; - bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; - int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); - - bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; - bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; - bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; - bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; - int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); - - bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; - bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; - bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; - bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; - int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); - - // Skip block when outside an edge - if (a == 0x0 || b == 0x0 || c == 0x0) continue; - - // Check if block needs clipping - bool clipneeded = clipleft > x || clipright < (x + q) || cliptop > y || clipbottom < (y + q); - - uint32_t *buffer = dest; - - PolyStencilBlock stencil(x / 8 + y / 8 * stencilPitch, stencilValues, stencilMasks); - - // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && !clipneeded && stencil.IsSingleValue()) - { - // Reject whole block if the stencil test fails - if (stencil.Get(0, 0) != stencilTestValue) - continue; - - for (int iy = 0; iy < q; iy++) - { - for (int ix = x; ix < x + q; ix++) - { - buffer[ix] = solidcolor; - } - - buffer += pitch; - } - } - else // Partially covered block - { - int CY1 = C1 + DX12 * y0 - DY12 * x0; - int CY2 = C2 + DX23 * y0 - DY23 * x0; - int CY3 = C3 + DX31 * y0 - DY31 * x0; - - for (int iy = 0; iy < q; iy++) - { - int CX1 = CY1; - int CX2 = CY2; - int CX3 = CY3; - - for (int ix = 0; ix < q; ix++) - { - bool visible = (ix + x >= clipleft) && (ix + x < clipright) && (cliptop <= y + iy) && (clipbottom > y + iy); - - if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible && stencil.Get(ix, iy) == stencilTestValue) - { - buffer[ix + x] = solidcolor; - } - - CX1 -= FDY12; - CX2 -= FDY23; - CX3 -= FDY31; - } - - CY1 += FDX12; - CY2 += FDX23; - CY3 += FDX31; - - buffer += pitch; - } - } - } - } -} - -float ScreenPolyTriangleDrawer::gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) -{ - float top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); - float bottom = (x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2); - return top / bottom; -} - -float ScreenPolyTriangleDrawer::grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) -{ - float top = (c1 - c2) * (x0 - x2) - (c0 - c2) * (x1 - x2); - float bottom = -((x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2)); - return top / bottom; -} -#endif - -///////////////////////////////////////////////////////////////////////////// - DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode) : args(args), variant(variant), blendmode(blendmode) { diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index ad00d1a67..f0797460f 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -20,9 +20,7 @@ ** */ - -#ifndef __R_POLY_TRIANGLE__ -#define __R_POLY_TRIANGLE__ +#pragma once #include "r_triangle.h" #include "r_data/r_translate.h" @@ -100,52 +98,6 @@ private: friend class DrawPolyTrianglesCommand; }; -// 8x8 block of stencil values, plus a mask indicating if values are the same for early out stencil testing -class PolyStencilBlock -{ -public: - PolyStencilBlock(int block, uint8_t *values, uint32_t *masks) : Values(values + block * 64), ValueMask(masks[block]) - { - } - - void Set(int x, int y, uint8_t value) - { - if ((ValueMask & 0xffffff00) == 0xffffff00) - { - if ((ValueMask & 0xff) == value) - return; - - for (int i = 0; i < 8 * 8; i++) - Values[i] = (ValueMask & 0xff); - ValueMask = 0; - } - - Values[x + y * 8] = value; - } - - uint8_t Get(int x, int y) const - { - if (IsSingleValue()) - return ValueMask & 0xff; - else - return Values[x + y * 8]; - } - - void Clear(uint8_t value) - { - ValueMask = 0xffffff00 | (uint32_t)value; - } - - bool IsSingleValue() const - { - return (ValueMask & 0xffffff00) == 0xffffff00; - } - -private: - uint8_t *Values; - uint32_t &ValueMask; -}; - class PolySubsectorGBuffer { public: @@ -193,8 +145,7 @@ public: uint32_t *m = Masks(); for (int i = 0; i < count; i++) { - PolyStencilBlock block(i, v, m); - block.Clear(stencil_value); + m[i] = 0xffffff00 | stencil_value; } } @@ -208,29 +159,12 @@ public: private: int width; int height; + + // 8x8 blocks of stencil values, plus a mask for each block indicating if values are the same for early out stencil testing std::vector values; std::vector masks; }; -#if 0 -class ScreenPolyTriangleDrawer -{ -public: - static void draw(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - static void fill(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - - static void stencil(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - - static void draw32(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - static void drawsubsector32(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - static void fill32(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - -private: - static float gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); - static float grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); -}; -#endif - class DrawPolyTrianglesCommand : public DrawerCommand { public: @@ -244,5 +178,3 @@ private: TriDrawVariant variant; TriBlendMode blendmode; }; - -#endif From 7ac0cace7d1eed574de31e0a8b28517e759034a7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 20 Nov 2016 02:07:55 +0100 Subject: [PATCH 1253/1509] Stop copying the matrix and remove r_triangle --- src/CMakeLists.txt | 1 - src/r_compiler/llvmdrawers.h | 2 - src/r_plane.cpp | 266 ------- src/r_poly_decal.cpp | 2 +- src/r_poly_decal.h | 2 +- src/r_poly_intersection.h | 2 +- src/r_poly_particle.cpp | 2 +- src/r_poly_plane.cpp | 4 +- src/r_poly_sky.cpp | 3 +- src/r_poly_sky.h | 1 + src/r_poly_sprite.cpp | 2 +- src/r_poly_triangle.cpp | 165 ++++- src/r_poly_triangle.h | 16 +- src/r_poly_wall.cpp | 2 +- src/r_poly_wallsprite.cpp | 2 +- src/r_poly_wallsprite.h | 2 +- src/r_triangle.cpp | 1338 ---------------------------------- src/r_triangle.h | 116 --- 18 files changed, 183 insertions(+), 1745 deletions(-) delete mode 100644 src/r_triangle.cpp delete mode 100644 src/r_triangle.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8c2e36220..987f23f2f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1092,7 +1092,6 @@ set( FASTMATH_PCH_SOURCES r_segs.cpp r_sky.cpp r_things.cpp - r_triangle.cpp s_advsound.cpp s_environment.cpp s_playlist.cpp diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index e42153743..1db2f5b2a 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -234,8 +234,6 @@ struct TriUniforms nearest_filter = 2, fixed_light = 4 }; - - TriMatrix objectToClip; }; struct TriDrawTriangleArgs diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 17728e80c..ca8547003 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -59,7 +59,6 @@ #include "v_palette.h" #include "r_data/colormaps.h" #include "r_draw_rgba.h" -#include "r_triangle.h" #ifdef _MSC_VER #pragma warning(disable:4244) @@ -1015,261 +1014,6 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) } } -static void R_DrawCubeSky(visplane_t *pl) -{ - int x1 = pl->left; - int x2 = pl->right; - short *uwal = (short *)pl->top; - short *dwal = (short *)pl->bottom; - - static TriVertex cube[6 * 6] = - { - // Top - { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, - { 1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f }, - { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.1f }, - - { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.1f }, - { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.1f }, - { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, - - // Bottom - { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.9f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f }, - - { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f }, - { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.9f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.9f }, - - // Front - { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f }, - { 1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, - { -1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f }, - - { -1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f }, - - // Back - { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, - { 1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f }, - - { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f }, - { -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 2.0f }, - { -1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, - - // Right - { 1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, - { 1.0f, 1.0f, 0.6f, 1.0f, 0.0f, 0.0f }, - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f }, - - { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 2.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 2.0f }, - { 1.0f, -1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, - - // Left - { -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f }, - { -1.0f, 1.0f, 0.6f, 1.0f, 1.0f, 0.0f }, - { -1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f }, - - { -1.0f, -1.0f, 0.6f, 1.0f, 0.0f, 0.0f }, - { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 2.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 2.0f } - }; - - TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z) * TriMatrix::scale(1000.0f, 1000.0f, 1000.0f); - TriMatrix objectToClip = TriMatrix::viewToClip() * TriMatrix::worldToView() * objectToWorld; - //TriMatrix objectToWorld = TriMatrix::scale(1000.0f, 1000.0f, 1000.0f); - //TriMatrix objectToClip = TriMatrix::viewToClip() * objectToWorld; - - uint32_t solid_top = frontskytex->GetSkyCapColor(false); - uint32_t solid_bottom = frontskytex->GetSkyCapColor(true); - - solid_top = RGB32k.RGB[(RPART(solid_top) >> 3)][(GPART(solid_top) >> 3)][(BPART(solid_top) >> 3)]; - solid_bottom = RGB32k.RGB[(RPART(solid_bottom) >> 3)][(GPART(solid_bottom) >> 3)][(BPART(solid_bottom) >> 3)]; - - TriUniforms uniforms; - uniforms.objectToClip = objectToClip; - uniforms.light = 256; - uniforms.flags = 0; - - TriangleDrawer::fill(uniforms, cube, 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, solid_top); - TriangleDrawer::fill(uniforms, cube + 6, 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, solid_bottom); - TriangleDrawer::draw(uniforms, cube + 2 * 6, 4 * 6, TriangleDrawMode::Normal, false, x1, x2 - 1, uwal, dwal, frontskytex); -} - -namespace -{ - class SkyDome - { - public: - SkyDome() { CreateDome(); } - void Render(visplane_t *pl); - - private: - TArray mVertices; - TArray mPrimStart; - int mRows, mColumns; - - void SkyVertex(int r, int c, bool yflip); - void CreateSkyHemisphere(bool zflip); - void CreateDome(); - void RenderRow(int row, visplane_t *pl); - void RenderCapColorRow(int row, bool bottomCap, visplane_t *pl); - - TriVertex SetVertex(float xx, float yy, float zz, float uu = 0, float vv = 0); - TriVertex SetVertexXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0); - }; - - TriVertex SkyDome::SetVertex(float xx, float yy, float zz, float uu, float vv) - { - TriVertex v; - v.x = xx; - v.y = yy; - v.z = zz; - v.w = 1.0f; - v.varying[0] = uu; - v.varying[1] = vv; - return v; - } - - TriVertex SkyDome::SetVertexXYZ(float xx, float yy, float zz, float uu, float vv) - { - TriVertex v; - v.x = xx; - v.y = zz; - v.z = yy; - v.w = 1.0f; - v.varying[0] = uu; - v.varying[1] = vv; - return v; - } - - void SkyDome::SkyVertex(int r, int c, bool zflip) - { - static const FAngle maxSideAngle = 60.f; - static const float scale = 10000.; - - FAngle topAngle = (c / (float)mColumns * 360.f); - FAngle sideAngle = maxSideAngle * (mRows - r) / mRows; - float height = sideAngle.Sin(); - float realRadius = scale * sideAngle.Cos(); - FVector2 pos = topAngle.ToVector(realRadius); - float z = (!zflip) ? scale * height : -scale * height; - - float u, v; - //uint32_t color = r == 0 ? 0xffffff : 0xffffffff; - - // And the texture coordinates. - if (!zflip) // Flipped Y is for the lower hemisphere. - { - u = (-c / (float)mColumns); - v = (r / (float)mRows); - } - else - { - u = (-c / (float)mColumns); - v = 1.0f + ((mRows - r) / (float)mRows); - } - - if (r != 4) z += 300; - - // And finally the vertex. - TriVertex vert; - vert = SetVertexXYZ(-pos.X, z - 1.f, pos.Y, u * 4.0f, v + 0.5f/*, color*/); - mVertices.Push(vert); - } - - void SkyDome::CreateSkyHemisphere(bool zflip) - { - int r, c; - - mPrimStart.Push(mVertices.Size()); - - for (c = 0; c < mColumns; c++) - { - SkyVertex(1, c, zflip); - } - - // The total number of triangles per hemisphere can be calculated - // as follows: rows * columns * 2 + 2 (for the top cap). - for (r = 0; r < mRows; r++) - { - mPrimStart.Push(mVertices.Size()); - for (c = 0; c <= mColumns; c++) - { - SkyVertex(r + zflip, c, zflip); - SkyVertex(r + 1 - zflip, c, zflip); - } - } - } - - void SkyDome::CreateDome() - { - mColumns = 128; - mRows = 4; - CreateSkyHemisphere(false); - CreateSkyHemisphere(true); - mPrimStart.Push(mVertices.Size()); - } - - void SkyDome::RenderRow(int row, visplane_t *pl) - { - int x1 = pl->left; - int x2 = pl->right; - short *uwal = (short *)pl->top; - short *dwal = (short *)pl->bottom; - TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); - TriMatrix objectToClip = TriMatrix::viewToClip() * TriMatrix::worldToView() * objectToWorld; - TriUniforms uniforms; - uniforms.objectToClip = objectToClip; - uniforms.light = 256; - uniforms.flags = 0; - TriangleDrawer::draw(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Strip, false, x1, x2 - 1, uwal, dwal, frontskytex); - } - - void SkyDome::RenderCapColorRow(int row, bool bottomCap, visplane_t *pl) - { - uint32_t solid = frontskytex->GetSkyCapColor(bottomCap); - solid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)]; - - int x1 = pl->left; - int x2 = pl->right; - short *uwal = (short *)pl->top; - short *dwal = (short *)pl->bottom; - TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); - TriMatrix objectToClip = TriMatrix::viewToClip() * TriMatrix::worldToView() * objectToWorld; - TriUniforms uniforms; - uniforms.objectToClip = objectToClip; - uniforms.light = 256; - uniforms.flags = 0; - TriangleDrawer::fill(uniforms, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], TriangleDrawMode::Fan, bottomCap, x1, x2 - 1, uwal, dwal, solid); - } - - void SkyDome::Render(visplane_t *pl) - { - int rc = mRows + 1; - - // No need to draw this as the software renderer can't look that high anyway - //RenderCapColorRow(0, false, pl); - //RenderCapColorRow(rc, true, pl); - - for (int i = 1; i <= mRows; i++) - { - RenderRow(i, pl); - RenderRow(rc + i, pl); - } - } -} - -static void R_DrawDomeSky(visplane_t *pl) -{ - static SkyDome skydome; - skydome.Render(pl); -} - static void R_DrawSkyColumnStripe(int start_x, int y1, int y2, int columns, double scale, double texturemid, double yrepeat) { uint32_t height = frontskytex->GetHeight(); @@ -1467,16 +1211,6 @@ static void R_DrawSky (visplane_t *pl) R_DrawCapSky(pl); return; } - else if (r_skymode == 3) - { - R_DrawCubeSky(pl); - return; - } - else if (r_skymode == 4) - { - R_DrawDomeSky(pl); - return; - } int x; float swal; diff --git a/src/r_poly_decal.cpp b/src/r_poly_decal.cpp index 5641bfcd1..52caae7e2 100644 --- a/src/r_poly_decal.cpp +++ b/src/r_poly_decal.cpp @@ -129,7 +129,6 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co bool fullbrightSprite = (decal->RenderFlags & RF_FULLBRIGHT) == RF_FULLBRIGHT; TriUniforms uniforms; - uniforms.objectToClip = worldToClip; if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) { uniforms.light = 256; @@ -145,6 +144,7 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co PolyDrawArgs args; args.uniforms = uniforms; + args.objectToClip = &worldToClip; args.vinput = vertices; args.vcount = 4; args.mode = TriangleDrawMode::Fan; diff --git a/src/r_poly_decal.h b/src/r_poly_decal.h index 39b250abb..61087a773 100644 --- a/src/r_poly_decal.h +++ b/src/r_poly_decal.h @@ -22,7 +22,7 @@ #pragma once -#include "r_triangle.h" +#include "r_poly_triangle.h" class RenderPolyDecal { diff --git a/src/r_poly_intersection.h b/src/r_poly_intersection.h index 48ebef031..b06bc1200 100644 --- a/src/r_poly_intersection.h +++ b/src/r_poly_intersection.h @@ -22,7 +22,7 @@ #pragma once -#include "r_triangle.h" +#include "r_poly_triangle.h" #include #include diff --git a/src/r_poly_particle.cpp b/src/r_poly_particle.cpp index e5797a108..8448c8f32 100644 --- a/src/r_poly_particle.cpp +++ b/src/r_poly_particle.cpp @@ -71,7 +71,6 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *partic bool fullbrightSprite = particle->bright != 0; TriUniforms uniforms; - uniforms.objectToClip = worldToClip; if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) { uniforms.light = 256; @@ -88,6 +87,7 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *partic PolyDrawArgs args; args.uniforms = uniforms; + args.objectToClip = &worldToClip; args.vinput = vertices; args.vcount = 4; args.mode = TriangleDrawMode::Fan; diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 9005e32f1..a68a4b568 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -103,7 +103,6 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *s } TriUniforms uniforms; - uniforms.objectToClip = worldToClip; uniforms.light = (uint32_t)(lightlevel / 255.0f * 256.0f); if (fixedlightlev >= 0 || fixedcolormap) uniforms.light = 256; @@ -133,6 +132,7 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *s PolyDrawArgs args; args.uniforms = uniforms; + args.objectToClip = &worldToClip; args.vinput = vertices; args.vcount = sub->numlines; args.mode = TriangleDrawMode::Fan; @@ -195,7 +195,6 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin bool isSky = picnum == skyflatnum; TriUniforms uniforms; - uniforms.objectToClip = worldToClip; uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f); if (fixedlightlev >= 0 || fixedcolormap) uniforms.light = 256; @@ -225,6 +224,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin PolyDrawArgs args; args.uniforms = uniforms; + args.objectToClip = &worldToClip; args.vinput = vertices; args.vcount = sub->numlines; args.mode = TriangleDrawMode::Fan; diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp index b0b06f262..a60b3f460 100644 --- a/src/r_poly_sky.cpp +++ b/src/r_poly_sky.cpp @@ -48,9 +48,9 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) backskytex = TexMan(sky2tex, true); TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); + objectToClip = worldToClip * objectToWorld; TriUniforms uniforms; - uniforms.objectToClip = worldToClip * objectToWorld; uniforms.light = 256; uniforms.flags = 0; uniforms.subsectorDepth = RenderPolyScene::SkySubsectorDepth; @@ -59,6 +59,7 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) PolyDrawArgs args; args.uniforms = uniforms; + args.objectToClip = &objectToClip; args.stenciltestvalue = 255; args.stencilwritevalue = 1; args.SetTexture(frontskytex); diff --git a/src/r_poly_sky.h b/src/r_poly_sky.h index dd4bd29ca..95ec27ed6 100644 --- a/src/r_poly_sky.h +++ b/src/r_poly_sky.h @@ -33,6 +33,7 @@ private: TArray mVertices; TArray mPrimStart; int mRows, mColumns; + TriMatrix objectToClip; void SkyVertex(int r, int c, bool yflip); void CreateSkyHemisphere(bool zflip); diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index 8c74d0d1a..84ff8e221 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -114,7 +114,6 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT)); TriUniforms uniforms; - uniforms.objectToClip = worldToClip; if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) { uniforms.light = 256; @@ -129,6 +128,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse PolyDrawArgs args; args.uniforms = uniforms; + args.objectToClip = &worldToClip; args.vinput = vertices; args.vcount = 4; args.mode = TriangleDrawMode::Fan; diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index ad9f7ff95..5574251e6 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -124,28 +124,28 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian for (int i = 0; i < vcount / 3; i++) { for (int j = 0; j < 3; j++) - vert[j] = shade_vertex(drawargs.uniforms, *(vinput++)); + vert[j] = shade_vertex(*drawargs.objectToClip, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); } } else if (drawargs.mode == TriangleDrawMode::Fan) { - vert[0] = shade_vertex(drawargs.uniforms, *(vinput++)); - vert[1] = shade_vertex(drawargs.uniforms, *(vinput++)); + vert[0] = shade_vertex(*drawargs.objectToClip, *(vinput++)); + vert[1] = shade_vertex(*drawargs.objectToClip, *(vinput++)); for (int i = 2; i < vcount; i++) { - vert[2] = shade_vertex(drawargs.uniforms, *(vinput++)); + vert[2] = shade_vertex(*drawargs.objectToClip, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); vert[1] = vert[2]; } } else // TriangleDrawMode::Strip { - vert[0] = shade_vertex(drawargs.uniforms, *(vinput++)); - vert[1] = shade_vertex(drawargs.uniforms, *(vinput++)); + vert[0] = shade_vertex(*drawargs.objectToClip, *(vinput++)); + vert[1] = shade_vertex(*drawargs.objectToClip, *(vinput++)); for (int i = 2; i < vcount; i++) { - vert[2] = shade_vertex(drawargs.uniforms, *(vinput++)); + vert[2] = shade_vertex(*drawargs.objectToClip, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); vert[0] = vert[1]; vert[1] = vert[2]; @@ -154,10 +154,10 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian } } -TriVertex PolyTriangleDrawer::shade_vertex(const TriUniforms &uniforms, TriVertex v) +TriVertex PolyTriangleDrawer::shade_vertex(const TriMatrix &objectToClip, TriVertex v) { // Apply transform to get clip coordinates: - return uniforms.objectToClip * v; + return objectToClip * v; } void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *)) @@ -341,3 +341,150 @@ FString DrawPolyTrianglesCommand::DebugInfo() { return "DrawPolyTriangles"; } + +///////////////////////////////////////////////////////////////////////////// + +TriMatrix TriMatrix::null() +{ + TriMatrix m; + memset(m.matrix, 0, sizeof(m.matrix)); + return m; +} + +TriMatrix TriMatrix::identity() +{ + TriMatrix m = null(); + m.matrix[0] = 1.0f; + m.matrix[5] = 1.0f; + m.matrix[10] = 1.0f; + m.matrix[15] = 1.0f; + return m; +} + +TriMatrix TriMatrix::translate(float x, float y, float z) +{ + TriMatrix m = identity(); + m.matrix[0 + 3 * 4] = x; + m.matrix[1 + 3 * 4] = y; + m.matrix[2 + 3 * 4] = z; + return m; +} + +TriMatrix TriMatrix::scale(float x, float y, float z) +{ + TriMatrix m = null(); + m.matrix[0 + 0 * 4] = x; + m.matrix[1 + 1 * 4] = y; + m.matrix[2 + 2 * 4] = z; + m.matrix[3 + 3 * 4] = 1; + return m; +} + +TriMatrix TriMatrix::rotate(float angle, float x, float y, float z) +{ + float c = cosf(angle); + float s = sinf(angle); + TriMatrix m = null(); + m.matrix[0 + 0 * 4] = (x*x*(1.0f - c) + c); + m.matrix[0 + 1 * 4] = (x*y*(1.0f - c) - z*s); + m.matrix[0 + 2 * 4] = (x*z*(1.0f - c) + y*s); + m.matrix[1 + 0 * 4] = (y*x*(1.0f - c) + z*s); + m.matrix[1 + 1 * 4] = (y*y*(1.0f - c) + c); + m.matrix[1 + 2 * 4] = (y*z*(1.0f - c) - x*s); + m.matrix[2 + 0 * 4] = (x*z*(1.0f - c) - y*s); + m.matrix[2 + 1 * 4] = (y*z*(1.0f - c) + x*s); + m.matrix[2 + 2 * 4] = (z*z*(1.0f - c) + c); + m.matrix[3 + 3 * 4] = 1.0f; + return m; +} + +TriMatrix TriMatrix::swapYZ() +{ + TriMatrix m = null(); + m.matrix[0 + 0 * 4] = 1.0f; + m.matrix[1 + 2 * 4] = 1.0f; + m.matrix[2 + 1 * 4] = -1.0f; + m.matrix[3 + 3 * 4] = 1.0f; + return m; +} + +TriMatrix TriMatrix::perspective(float fovy, float aspect, float z_near, float z_far) +{ + float f = (float)(1.0 / tan(fovy * M_PI / 360.0)); + TriMatrix m = null(); + m.matrix[0 + 0 * 4] = f / aspect; + m.matrix[1 + 1 * 4] = f; + m.matrix[2 + 2 * 4] = (z_far + z_near) / (z_near - z_far); + m.matrix[2 + 3 * 4] = (2.0f * z_far * z_near) / (z_near - z_far); + m.matrix[3 + 2 * 4] = -1.0f; + return m; +} + +TriMatrix TriMatrix::frustum(float left, float right, float bottom, float top, float near, float far) +{ + float a = (right + left) / (right - left); + float b = (top + bottom) / (top - bottom); + float c = -(far + near) / (far - near); + float d = -(2.0f * far) / (far - near); + TriMatrix m = null(); + m.matrix[0 + 0 * 4] = 2.0f * near / (right - left); + m.matrix[1 + 1 * 4] = 2.0f * near / (top - bottom); + m.matrix[0 + 2 * 4] = a; + m.matrix[1 + 2 * 4] = b; + m.matrix[2 + 2 * 4] = c; + m.matrix[2 + 3 * 4] = d; + m.matrix[3 + 2 * 4] = -1; + return m; +} + +TriMatrix TriMatrix::worldToView() +{ + TriMatrix m = null(); + m.matrix[0 + 0 * 4] = (float)ViewSin; + m.matrix[0 + 1 * 4] = (float)-ViewCos; + m.matrix[1 + 2 * 4] = 1.0f; + m.matrix[2 + 0 * 4] = (float)-ViewCos; + m.matrix[2 + 1 * 4] = (float)-ViewSin; + m.matrix[3 + 3 * 4] = 1.0f; + return m * translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); +} + +TriMatrix TriMatrix::viewToClip() +{ + float near = 5.0f; + float far = 65536.0f; + float width = (float)(FocalTangent * near); + float top = (float)(CenterY / InvZtoScale * near); + float bottom = (float)(top - viewheight / InvZtoScale * near); + return frustum(-width, width, bottom, top, near, far); +} + +TriMatrix TriMatrix::operator*(const TriMatrix &mult) const +{ + TriMatrix result; + for (int x = 0; x < 4; x++) + { + for (int y = 0; y < 4; y++) + { + result.matrix[x + y * 4] = + matrix[0 * 4 + x] * mult.matrix[y * 4 + 0] + + matrix[1 * 4 + x] * mult.matrix[y * 4 + 1] + + matrix[2 * 4 + x] * mult.matrix[y * 4 + 2] + + matrix[3 * 4 + x] * mult.matrix[y * 4 + 3]; + } + } + return result; +} + +TriVertex TriMatrix::operator*(TriVertex v) const +{ + float vx = matrix[0 * 4 + 0] * v.x + matrix[1 * 4 + 0] * v.y + matrix[2 * 4 + 0] * v.z + matrix[3 * 4 + 0] * v.w; + float vy = matrix[0 * 4 + 1] * v.x + matrix[1 * 4 + 1] * v.y + matrix[2 * 4 + 1] * v.z + matrix[3 * 4 + 1] * v.w; + float vz = matrix[0 * 4 + 2] * v.x + matrix[1 * 4 + 2] * v.y + matrix[2 * 4 + 2] * v.z + matrix[3 * 4 + 2] * v.w; + float vw = matrix[0 * 4 + 3] * v.x + matrix[1 * 4 + 3] * v.y + matrix[2 * 4 + 3] * v.z + matrix[3 * 4 + 3] * v.w; + v.x = vx; + v.y = vy; + v.z = vz; + v.w = vw; + return v; +} diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index f0797460f..db6719de9 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -22,15 +22,27 @@ #pragma once -#include "r_triangle.h" +#include "r_draw.h" +#include "r_thread.h" +#include "r_compiler/llvmdrawers.h" #include "r_data/r_translate.h" +class FTexture; + +enum class TriangleDrawMode +{ + Normal, + Fan, + Strip +}; + struct TriDrawTriangleArgs; class PolyDrawArgs { public: TriUniforms uniforms; + const TriMatrix *objectToClip = nullptr; const TriVertex *vinput = nullptr; int vcount = 0; TriangleDrawMode mode = TriangleDrawMode::Normal; @@ -83,7 +95,7 @@ public: static void draw(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode); private: - static TriVertex shade_vertex(const TriUniforms &uniforms, TriVertex v); + static TriVertex shade_vertex(const TriMatrix &objectToClip, TriVertex v); static void draw_arrays(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode, WorkerThreadData *thread); static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index e8bad52a7..f0eb33c32 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -176,13 +176,13 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) } TriUniforms uniforms; - uniforms.objectToClip = worldToClip; uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f); uniforms.flags = 0; uniforms.subsectorDepth = SubsectorDepth; PolyDrawArgs args; args.uniforms = uniforms; + args.objectToClip = &worldToClip; args.vinput = vertices; args.vcount = 4; args.mode = TriangleDrawMode::Fan; diff --git a/src/r_poly_wallsprite.cpp b/src/r_poly_wallsprite.cpp index ccebe5f0e..cd331dcb5 100644 --- a/src/r_poly_wallsprite.cpp +++ b/src/r_poly_wallsprite.cpp @@ -99,7 +99,6 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, AActor *thing, s bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT)); TriUniforms uniforms; - uniforms.objectToClip = worldToClip; if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) { uniforms.light = 256; @@ -114,6 +113,7 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, AActor *thing, s PolyDrawArgs args; args.uniforms = uniforms; + args.objectToClip = &worldToClip; args.vinput = vertices; args.vcount = 4; args.mode = TriangleDrawMode::Fan; diff --git a/src/r_poly_wallsprite.h b/src/r_poly_wallsprite.h index dd4ba28da..66a92b033 100644 --- a/src/r_poly_wallsprite.h +++ b/src/r_poly_wallsprite.h @@ -22,7 +22,7 @@ #pragma once -#include "r_triangle.h" +#include "r_poly_triangle.h" class RenderPolyWallSprite { diff --git a/src/r_triangle.cpp b/src/r_triangle.cpp deleted file mode 100644 index 13a8ca292..000000000 --- a/src/r_triangle.cpp +++ /dev/null @@ -1,1338 +0,0 @@ -/* -** Triangle drawers -** Copyright (c) 2016 Magnus Norddahl -** -** This software is provided 'as-is', without any express or implied -** warranty. In no event will the authors be held liable for any damages -** arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, -** including commercial applications, and to alter it and redistribute it -** freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not -** claim that you wrote the original software. If you use this software -** in a product, an acknowledgment in the product documentation would be -** appreciated but is not required. -** 2. Altered source versions must be plainly marked as such, and must not be -** misrepresented as being the original software. -** 3. This notice may not be removed or altered from any source distribution. -** -*/ - -#include -#include "templates.h" -#include "doomdef.h" -#include "i_system.h" -#include "w_wad.h" -#include "r_local.h" -#include "v_video.h" -#include "doomstat.h" -#include "st_stuff.h" -#include "g_game.h" -#include "g_level.h" -#include "r_data/r_translate.h" -#include "v_palette.h" -#include "r_data/colormaps.h" -#include "r_triangle.h" - -void TriangleDrawer::draw(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture) -{ - if (r_swtruecolor) - queue_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, (const uint8_t*)texture->GetPixelsBgra(), texture->GetWidth(), texture->GetHeight(), 0); - else - draw_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, texture->GetPixels(), texture->GetWidth(), texture->GetHeight(), 0, nullptr, &ScreenTriangleDrawer::draw); -} - -void TriangleDrawer::fill(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor) -{ - if (r_swtruecolor) - queue_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor); - else - draw_arrays(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, cliptop, clipbottom, nullptr, 0, 0, solidcolor, nullptr, &ScreenTriangleDrawer::fill); -} - -void TriangleDrawer::queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) -{ - if (clipright < clipleft || clipleft < 0 || clipright > MAXWIDTH) - return; - - int cliplength = clipright - clipleft + 1; - short *clipdata = (short*)DrawerCommandQueue::AllocMemory(cliplength * 2 * sizeof(short)); - if (!clipdata) - { - DrawerCommandQueue::WaitForWorkers(); - clipdata = (short*)DrawerCommandQueue::AllocMemory(cliplength * 2 * sizeof(short)); - if (!clipdata) - return; - } - - for (int i = 0; i < cliplength; i++) - clipdata[i] = cliptop[clipleft + i]; - for (int i = 0; i < cliplength; i++) - clipdata[cliplength + i] = clipbottom[clipleft + i]; - - DrawerCommandQueue::QueueCommand(uniforms, vinput, vcount, mode, ccw, clipleft, clipright, clipdata, texturePixels, textureWidth, textureHeight, solidcolor); -} - -void TriangleDrawer::draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, WorkerThreadData *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, WorkerThreadData *)) -{ - if (vcount < 3) - return; - - ScreenTriangleDrawerArgs args; - args.dest = dc_destorg; - args.pitch = dc_pitch; - args.clipleft = clipleft; - args.clipright = clipright; - args.cliptop = cliptop; - args.clipbottom = clipbottom; - args.texturePixels = texturePixels; - args.textureWidth = textureWidth; - args.textureHeight = textureHeight; - args.solidcolor = solidcolor; - args.uniforms = &uniforms; - - TriVertex vert[3]; - if (mode == TriangleDrawMode::Normal) - { - for (int i = 0; i < vcount / 3; i++) - { - for (int j = 0; j < 3; j++) - vert[j] = shade_vertex(uniforms, *(vinput++)); - draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); - } - } - else if (mode == TriangleDrawMode::Fan) - { - vert[0] = shade_vertex(uniforms, *(vinput++)); - vert[1] = shade_vertex(uniforms, *(vinput++)); - for (int i = 2; i < vcount; i++) - { - vert[2] = shade_vertex(uniforms, *(vinput++)); - draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); - vert[1] = vert[2]; - } - } - else // TriangleDrawMode::Strip - { - vert[0] = shade_vertex(uniforms, *(vinput++)); - vert[1] = shade_vertex(uniforms, *(vinput++)); - for (int i = 2; i < vcount; i++) - { - vert[2] = shade_vertex(uniforms, *(vinput++)); - draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); - vert[0] = vert[1]; - vert[1] = vert[2]; - ccw = !ccw; - } - } -} - -TriVertex TriangleDrawer::shade_vertex(const TriUniforms &uniforms, TriVertex v) -{ - // Apply transform to get clip coordinates: - return uniforms.objectToClip * v; -} - -void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenTriangleDrawerArgs *args, WorkerThreadData *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, WorkerThreadData *)) -{ - // Cull, clip and generate additional vertices as needed - TriVertex clippedvert[max_additional_vertices]; - int numclipvert; - clipedge(vert, clippedvert, numclipvert); - - // Map to 2D viewport: - for (int j = 0; j < numclipvert; j++) - { - auto &v = clippedvert[j]; - - // Calculate normalized device coordinates: - v.w = 1.0f / v.w; - v.x *= v.w; - v.y *= v.w; - v.z *= v.w; - - // Apply viewport scale to get screen coordinates: - v.x = viewwidth * (1.0f + v.x) * 0.5f; - v.y = viewheight * (1.0f - v.y) * 0.5f; - } - - // Draw screen triangles - if (ccw) - { - for (int i = numclipvert; i > 1; i--) - { - args->v1 = &clippedvert[numclipvert - 1]; - args->v2 = &clippedvert[i - 1]; - args->v3 = &clippedvert[i - 2]; - drawfunc(args, thread); - } - } - else - { - for (int i = 2; i < numclipvert; i++) - { - args->v1 = &clippedvert[0]; - args->v2 = &clippedvert[i - 1]; - args->v3 = &clippedvert[i]; - drawfunc(args, thread); - } - } -} - -bool TriangleDrawer::cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2) -{ - if (clipdistance1 < 0.0f && clipdistance2 < 0.0f) - return true; - - if (clipdistance1 < 0.0f) - t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), 0.0f); - else - t1 = 0.0f; - - if (clipdistance2 < 0.0f) - t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), 1.0f); - else - t2 = 1.0f; - - return false; -} - -void TriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert) -{ - // Clip and cull so that the following is true for all vertices: - // -v.w <= v.x <= v.w - // -v.w <= v.y <= v.w - // -v.w <= v.z <= v.w - - // use barycentric weights while clipping vertices - float weights[max_additional_vertices * 3 * 2]; - for (int i = 0; i < 3; i++) - { - weights[i * 3 + 0] = 0.0f; - weights[i * 3 + 1] = 0.0f; - weights[i * 3 + 2] = 0.0f; - weights[i * 3 + i] = 1.0f; - } - - // halfspace clip distances - float clipdistance[6 * 3]; - for (int i = 0; i < 3; i++) - { - const auto &v = verts[i]; - clipdistance[i * 6 + 0] = v.x + v.w; - clipdistance[i * 6 + 1] = v.w - v.x; - clipdistance[i * 6 + 2] = v.y + v.w; - clipdistance[i * 6 + 3] = v.w - v.y; - clipdistance[i * 6 + 4] = v.z + v.w; - clipdistance[i * 6 + 5] = v.w - v.z; - } - - // Clip against each halfspace - float *input = weights; - float *output = weights + max_additional_vertices * 3; - int inputverts = 3; - int outputverts = 0; - for (int p = 0; p < 6; p++) - { - // Clip each edge - outputverts = 0; - for (int i = 0; i < inputverts; i++) - { - int j = (i + 1) % inputverts; - float clipdistance1 = - clipdistance[0 * 6 + p] * input[i * 3 + 0] + - clipdistance[1 * 6 + p] * input[i * 3 + 1] + - clipdistance[2 * 6 + p] * input[i * 3 + 2]; - - float clipdistance2 = - clipdistance[0 * 6 + p] * input[j * 3 + 0] + - clipdistance[1 * 6 + p] * input[j * 3 + 1] + - clipdistance[2 * 6 + p] * input[j * 3 + 2]; - - float t1, t2; - if (!cullhalfspace(clipdistance1, clipdistance2, t1, t2) && outputverts + 1 < max_additional_vertices) - { - // add t1 vertex - for (int k = 0; k < 3; k++) - output[outputverts * 3 + k] = input[i * 3 + k] * (1.0f - t1) + input[j * 3 + k] * t1; - outputverts++; - - if (t2 != 1.0f && t2 > t1) - { - // add t2 vertex - for (int k = 0; k < 3; k++) - output[outputverts * 3 + k] = input[i * 3 + k] * (1.0f - t2) + input[j * 3 + k] * t2; - outputverts++; - } - } - } - std::swap(input, output); - std::swap(inputverts, outputverts); - if (inputverts == 0) - break; - } - - // Convert barycentric weights to actual vertices - numclipvert = inputverts; - for (int i = 0; i < numclipvert; i++) - { - auto &v = clippedvert[i]; - memset(&v, 0, sizeof(TriVertex)); - for (int w = 0; w < 3; w++) - { - float weight = input[i * 3 + w]; - v.x += verts[w].x * weight; - v.y += verts[w].y * weight; - v.z += verts[w].z * weight; - v.w += verts[w].w * weight; - for (int iv = 0; iv < TriVertex::NumVarying; iv++) - v.varying[iv] += verts[w].varying[iv] * weight; - } - } -} - -///////////////////////////////////////////////////////////////////////////// - -void ScreenTriangleDrawer::draw(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread) -{ - uint8_t *dest = args->dest; - int pitch = args->pitch; - const TriVertex &v1 = *args->v1; - const TriVertex &v2 = *args->v2; - const TriVertex &v3 = *args->v3; - int clipleft = args->clipleft; - int clipright = args->clipright; - const short *cliptop = args->cliptop; - const short *clipbottom = args->clipbottom; - const uint8_t *texturePixels = args->texturePixels; - int textureWidth = args->textureWidth; - int textureHeight = args->textureHeight; - - // 28.4 fixed-point coordinates - const int Y1 = (int)round(16.0f * v1.y); - const int Y2 = (int)round(16.0f * v2.y); - const int Y3 = (int)round(16.0f * v3.y); - - const int X1 = (int)round(16.0f * v1.x); - const int X2 = (int)round(16.0f * v2.x); - const int X3 = (int)round(16.0f * v3.x); - - // Deltas - const int DX12 = X1 - X2; - const int DX23 = X2 - X3; - const int DX31 = X3 - X1; - - const int DY12 = Y1 - Y2; - const int DY23 = Y2 - Y3; - const int DY31 = Y3 - Y1; - - // Fixed-point deltas - const int FDX12 = DX12 << 4; - const int FDX23 = DX23 << 4; - const int FDX31 = DX31 << 4; - - const int FDY12 = DY12 << 4; - const int FDY23 = DY23 << 4; - const int FDY31 = DY31 << 4; - - // Bounding rectangle - int clipymin = cliptop[clipleft]; - int clipymax = clipbottom[clipleft]; - for (int i = clipleft + 1; i <= clipright; i++) - { - clipymin = MIN(clipymin, (int)cliptop[i]); - clipymax = MAX(clipymax, (int)clipbottom[i]); - } - int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); - int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright); - int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, clipymin); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipymax - 1); - if (minx >= maxx || miny >= maxy) - return; - - // Block size, standard 8x8 (must be power of two) - const int q = 8; - - // Start in corner of 8x8 block - minx &= ~(q - 1); - miny &= ~(q - 1); - - dest += miny * pitch; - - // Half-edge constants - int C1 = DY12 * X1 - DX12 * Y1; - int C2 = DY23 * X2 - DX23 * Y2; - int C3 = DY31 * X3 - DX31 * Y3; - - // Correct for fill convention - if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; - if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; - if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; - - // Gradients - float gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - float gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - float startW = v1.w + gradWX * (minx - v1.x) + gradWY * (miny - v1.y); - float gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (minx - v1.x) + gradVaryingY[i] * (miny - v1.y); - } - - // Loop through blocks - for (int y = miny; y < maxy; y += q) - { - for (int x = minx; x < maxx; x += q) - { - // Corners of block - int x0 = x << 4; - int x1 = (x + q - 1) << 4; - int y0 = y << 4; - int y1 = (y + q - 1) << 4; - - // Evaluate half-space functions - bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; - bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; - bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; - bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; - int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); - - bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; - bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; - bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; - bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; - int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); - - bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; - bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; - bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; - bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; - int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); - - // Skip block when outside an edge - if (a == 0x0 || b == 0x0 || c == 0x0) continue; - - // Check if block needs clipping - int clipcount = 0; - for (int ix = x; ix < x + q; ix++) - { - clipcount += (clipleft > ix) || (clipright < ix) || (cliptop[ix] > y) || (clipbottom[ix] <= y + q - 1); - } - - // Calculate varying variables for affine block - float offx0 = (x - minx) + 0.5f; - float offy0 = (y - miny) + 0.5f; - float offx1 = offx0 + q; - float offy1 = offy0 + q; - float rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); - float rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); - float rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); - float rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); - float varyingTL[TriVertex::NumVarying]; - float varyingTR[TriVertex::NumVarying]; - float varyingBL[TriVertex::NumVarying]; - float varyingBR[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; - varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; - varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); - varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); - } - - uint8_t *buffer = dest; - - // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && clipcount == 0) - { - for (int iy = 0; iy < q; iy++) - { - uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - float pos = varyingTL[i] + varyingBL[i] * iy; - float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); - - varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); - varyingStep[i] = (uint32_t)(step * 0x100000000LL); - } - - for (int ix = x; ix < x + q; ix++) - { - uint32_t ufrac = varying[0]; - uint32_t vfrac = varying[1]; - - uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; - uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; - uint32_t uvoffset = upos * textureHeight + vpos; - - buffer[ix] = texturePixels[uvoffset]; - - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; - } - - buffer += pitch; - } - } - else // Partially covered block - { - int CY1 = C1 + DX12 * y0 - DY12 * x0; - int CY2 = C2 + DX23 * y0 - DY23 * x0; - int CY3 = C3 + DX31 * y0 - DY31 * x0; - - for (int iy = 0; iy < q; iy++) - { - int CX1 = CY1; - int CX2 = CY2; - int CX3 = CY3; - - uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - float pos = varyingTL[i] + varyingBL[i] * iy; - float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); - - varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); - varyingStep[i] = (uint32_t)(step * 0x100000000LL); - } - - for (int ix = x; ix < x + q; ix++) - { - bool visible = ix >= clipleft && ix <= clipright && (cliptop[ix] <= y + iy) && (clipbottom[ix] > y + iy); - - if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) - { - uint32_t ufrac = varying[0]; - uint32_t vfrac = varying[1]; - - uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; - uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; - uint32_t uvoffset = upos * textureHeight + vpos; - - buffer[ix] = texturePixels[uvoffset]; - } - - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; - - CX1 -= FDY12; - CX2 -= FDY23; - CX3 -= FDY31; - } - - CY1 += FDX12; - CY2 += FDX23; - CY3 += FDX31; - - buffer += pitch; - } - } - } - - dest += q * pitch; - } -} - -void ScreenTriangleDrawer::fill(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread) -{ - uint8_t *dest = args->dest; - int pitch = args->pitch; - const TriVertex &v1 = *args->v1; - const TriVertex &v2 = *args->v2; - const TriVertex &v3 = *args->v3; - int clipleft = args->clipleft; - int clipright = args->clipright; - const short *cliptop = args->cliptop; - const short *clipbottom = args->clipbottom; - int solidcolor = args->solidcolor; - - // 28.4 fixed-point coordinates - const int Y1 = (int)round(16.0f * v1.y); - const int Y2 = (int)round(16.0f * v2.y); - const int Y3 = (int)round(16.0f * v3.y); - - const int X1 = (int)round(16.0f * v1.x); - const int X2 = (int)round(16.0f * v2.x); - const int X3 = (int)round(16.0f * v3.x); - - // Deltas - const int DX12 = X1 - X2; - const int DX23 = X2 - X3; - const int DX31 = X3 - X1; - - const int DY12 = Y1 - Y2; - const int DY23 = Y2 - Y3; - const int DY31 = Y3 - Y1; - - // Fixed-point deltas - const int FDX12 = DX12 << 4; - const int FDX23 = DX23 << 4; - const int FDX31 = DX31 << 4; - - const int FDY12 = DY12 << 4; - const int FDY23 = DY23 << 4; - const int FDY31 = DY31 << 4; - - // Bounding rectangle - int clipymin = cliptop[clipleft]; - int clipymax = clipbottom[clipleft]; - for (int i = clipleft + 1; i <= clipright; i++) - { - clipymin = MIN(clipymin, (int)cliptop[i]); - clipymax = MAX(clipymax, (int)clipbottom[i]); - } - int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); - int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright); - int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, clipymin); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipymax - 1); - if (minx >= maxx || miny >= maxy) - return; - - // Block size, standard 8x8 (must be power of two) - const int q = 8; - - // Start in corner of 8x8 block - minx &= ~(q - 1); - miny &= ~(q - 1); - - dest += miny * pitch; - - // Half-edge constants - int C1 = DY12 * X1 - DX12 * Y1; - int C2 = DY23 * X2 - DX23 * Y2; - int C3 = DY31 * X3 - DX31 * Y3; - - // Correct for fill convention - if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; - if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; - if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; - - // Loop through blocks - for (int y = miny; y < maxy; y += q) - { - for (int x = minx; x < maxx; x += q) - { - // Corners of block - int x0 = x << 4; - int x1 = (x + q - 1) << 4; - int y0 = y << 4; - int y1 = (y + q - 1) << 4; - - // Evaluate half-space functions - bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; - bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; - bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; - bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; - int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); - - bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; - bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; - bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; - bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; - int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); - - bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; - bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; - bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; - bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; - int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); - - // Skip block when outside an edge - if (a == 0x0 || b == 0x0 || c == 0x0) continue; - - // Check if block needs clipping - int clipcount = 0; - for (int ix = x; ix < x + q; ix++) - { - clipcount += (clipleft > ix) || (clipright < ix) || (cliptop[ix] > y) || (clipbottom[ix] <= y + q - 1); - } - - uint8_t *buffer = dest; - - // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && clipcount == 0) - { - for (int iy = 0; iy < q; iy++) - { - for (int ix = x; ix < x + q; ix++) - { - buffer[ix] = solidcolor; - } - - buffer += pitch; - } - } - else // Partially covered block - { - int CY1 = C1 + DX12 * y0 - DY12 * x0; - int CY2 = C2 + DX23 * y0 - DY23 * x0; - int CY3 = C3 + DX31 * y0 - DY31 * x0; - - for (int iy = 0; iy < q; iy++) - { - int CX1 = CY1; - int CX2 = CY2; - int CX3 = CY3; - - for (int ix = x; ix < x + q; ix++) - { - bool visible = ix >= clipleft && ix <= clipright && (cliptop[ix] <= y + iy) && (clipbottom[ix] > y + iy); - - if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) - { - buffer[ix] = solidcolor; - } - - CX1 -= FDY12; - CX2 -= FDY23; - CX3 -= FDY31; - } - - CY1 += FDX12; - CY2 += FDX23; - CY3 += FDX31; - - buffer += pitch; - } - } - } - - dest += q * pitch; - } -} - -void ScreenTriangleDrawer::draw32(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread) -{ - uint32_t *dest = (uint32_t *)args->dest; - int pitch = args->pitch; - const TriVertex &v1 = *args->v1; - const TriVertex &v2 = *args->v2; - const TriVertex &v3 = *args->v3; - int clipleft = args->clipleft; - int clipright = args->clipright; - const short *cliptop = args->cliptop; - const short *clipbottom = args->clipbottom; - const uint32_t *texturePixels = (const uint32_t *)args->texturePixels; - int textureWidth = args->textureWidth; - int textureHeight = args->textureHeight; - uint32_t light = args->uniforms->light; - - // 28.4 fixed-point coordinates - const int Y1 = (int)round(16.0f * v1.y); - const int Y2 = (int)round(16.0f * v2.y); - const int Y3 = (int)round(16.0f * v3.y); - - const int X1 = (int)round(16.0f * v1.x); - const int X2 = (int)round(16.0f * v2.x); - const int X3 = (int)round(16.0f * v3.x); - - // Deltas - const int DX12 = X1 - X2; - const int DX23 = X2 - X3; - const int DX31 = X3 - X1; - - const int DY12 = Y1 - Y2; - const int DY23 = Y2 - Y3; - const int DY31 = Y3 - Y1; - - // Fixed-point deltas - const int FDX12 = DX12 << 4; - const int FDX23 = DX23 << 4; - const int FDX31 = DX31 << 4; - - const int FDY12 = DY12 << 4; - const int FDY23 = DY23 << 4; - const int FDY31 = DY31 << 4; - - // Bounding rectangle - int clipymin = cliptop[clipleft]; - int clipymax = clipbottom[clipleft]; - for (int i = clipleft + 1; i <= clipright; i++) - { - clipymin = MIN(clipymin, (int)cliptop[i]); - clipymax = MAX(clipymax, (int)clipbottom[i]); - } - int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); - int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright); - int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, clipymin); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipymax - 1); - if (minx >= maxx || miny >= maxy) - return; - - // Block size, standard 8x8 (must be power of two) - const int q = 8; - - // Start in corner of 8x8 block - minx &= ~(q - 1); - miny &= ~(q - 1); - - dest += miny * pitch; - - // Half-edge constants - int C1 = DY12 * X1 - DX12 * Y1; - int C2 = DY23 * X2 - DX23 * Y2; - int C3 = DY31 * X3 - DX31 * Y3; - - // Correct for fill convention - if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; - if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; - if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; - - // Gradients - float gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - float gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - float startW = v1.w + gradWX * (minx - v1.x) + gradWY * (miny - v1.y); - float gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (minx - v1.x) + gradVaryingY[i] * (miny - v1.y); - } - - // Loop through blocks - for (int y = miny; y < maxy; y += q) - { - for (int x = minx; x < maxx; x += q) - { - // Corners of block - int x0 = x << 4; - int x1 = (x + q - 1) << 4; - int y0 = y << 4; - int y1 = (y + q - 1) << 4; - - // Evaluate half-space functions - bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; - bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; - bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; - bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; - int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); - - bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; - bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; - bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; - bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; - int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); - - bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; - bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; - bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; - bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; - int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); - - // Skip block when outside an edge - if (a == 0x0 || b == 0x0 || c == 0x0) continue; - - // Check if block needs clipping - int clipcount = 0; - for (int ix = x; ix < x + q; ix++) - { - clipcount += (clipleft > ix) || (clipright < ix) || (cliptop[ix] > y) || (clipbottom[ix] <= y + q - 1); - } - - // Calculate varying variables for affine block - float offx0 = (x - minx) + 0.5f; - float offy0 = (y - miny) + 0.5f; - float offx1 = offx0 + q; - float offy1 = offy0 + q; - float rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); - float rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); - float rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); - float rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); - float varyingTL[TriVertex::NumVarying]; - float varyingTR[TriVertex::NumVarying]; - float varyingBL[TriVertex::NumVarying]; - float varyingBR[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - varyingTL[i] = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; - varyingTR[i] = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; - varyingBL[i] = ((startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL - varyingTL[i]) * (1.0f / q); - varyingBR[i] = ((startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR - varyingTR[i]) * (1.0f / q); - } - - uint32_t *buffer = dest; - - // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && clipcount == 0) - { - for (int iy = 0; iy < q; iy++) - { - uint32_t varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - float pos = varyingTL[i] + varyingBL[i] * iy; - float step = (varyingTR[i] + varyingBR[i] * iy - pos) * (1.0f / q); - - varying[i] = (uint32_t)((pos - floor(pos)) * 0x100000000LL); - varyingStep[i] = (uint32_t)(step * 0x100000000LL); - } - - if ((y + iy) % thread->num_cores == thread->core) - { - for (int ix = x; ix < x + q; ix++) - { - uint32_t ufrac = varying[0]; - uint32_t vfrac = varying[1]; - - uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; - uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; - uint32_t uvoffset = upos * textureHeight + vpos; - - uint32_t fg = texturePixels[uvoffset]; - uint32_t fg_red = (RPART(fg) * light) >> 8; - uint32_t fg_green = (GPART(fg) * light) >> 8; - uint32_t fg_blue = (BPART(fg) * light) >> 8; - uint32_t fg_alpha = APART(fg); - - if (fg_alpha > 127) - buffer[ix] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; - - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; - } - } - - buffer += pitch; - } - } - else // Partially covered block - { - int CY1 = C1 + DX12 * y0 - DY12 * x0; - int CY2 = C2 + DX23 * y0 - DY23 * x0; - int CY3 = C3 + DX31 * y0 - DY31 * x0; - - for (int iy = 0; iy < q; iy++) - { - int CX1 = CY1; - int CX2 = CY2; - int CX3 = CY3; - - float varying[TriVertex::NumVarying], varyingStep[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - { - varying[i] = varyingTL[i] + varyingBL[i] * iy; - varyingStep[i] = (varyingTR[i] + varyingBR[i] * iy - varying[i]) * (1.0f / q); - } - - if ((y + iy) % thread->num_cores == thread->core) - { - for (int ix = x; ix < x + q; ix++) - { - bool visible = ix >= clipleft && ix <= clipright && (cliptop[ix] <= y + iy) && (clipbottom[ix] > y + iy); - - if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) - { - uint32_t ufrac = (uint32_t)((varying[0] - floor(varying[0])) * 0x100000000LL); - uint32_t vfrac = (uint32_t)((varying[1] - floor(varying[1])) * 0x100000000LL); - - uint32_t upos = ((ufrac >> 16) * textureWidth) >> 16; - uint32_t vpos = ((vfrac >> 16) * textureHeight) >> 16; - uint32_t uvoffset = upos * textureHeight + vpos; - - uint32_t fg = texturePixels[uvoffset]; - uint32_t fg_red = (RPART(fg) * light) >> 8; - uint32_t fg_green = (GPART(fg) * light) >> 8; - uint32_t fg_blue = (BPART(fg) * light) >> 8; - uint32_t fg_alpha = APART(fg); - - if (fg_alpha > 127) - buffer[ix] = 0xff000000 | (fg_red << 16) | (fg_green << 8) | fg_blue; - } - - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] += varyingStep[i]; - - CX1 -= FDY12; - CX2 -= FDY23; - CX3 -= FDY31; - } - } - - CY1 += FDX12; - CY2 += FDX23; - CY3 += FDX31; - - buffer += pitch; - } - } - } - - dest += q * pitch; - } -} - -void ScreenTriangleDrawer::fill32(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread) -{ - uint32_t *dest = (uint32_t *)args->dest; - int pitch = args->pitch; - const TriVertex &v1 = *args->v1; - const TriVertex &v2 = *args->v2; - const TriVertex &v3 = *args->v3; - int clipleft = args->clipleft; - int clipright = args->clipright; - const short *cliptop = args->cliptop; - const short *clipbottom = args->clipbottom; - int solidcolor = args->solidcolor; - - // 28.4 fixed-point coordinates - const int Y1 = (int)round(16.0f * v1.y); - const int Y2 = (int)round(16.0f * v2.y); - const int Y3 = (int)round(16.0f * v3.y); - - const int X1 = (int)round(16.0f * v1.x); - const int X2 = (int)round(16.0f * v2.x); - const int X3 = (int)round(16.0f * v3.x); - - // Deltas - const int DX12 = X1 - X2; - const int DX23 = X2 - X3; - const int DX31 = X3 - X1; - - const int DY12 = Y1 - Y2; - const int DY23 = Y2 - Y3; - const int DY31 = Y3 - Y1; - - // Fixed-point deltas - const int FDX12 = DX12 << 4; - const int FDX23 = DX23 << 4; - const int FDX31 = DX31 << 4; - - const int FDY12 = DY12 << 4; - const int FDY23 = DY23 << 4; - const int FDY31 = DY31 << 4; - - // Bounding rectangle - int clipymin = cliptop[clipleft]; - int clipymax = clipbottom[clipleft]; - for (int i = clipleft + 1; i <= clipright; i++) - { - clipymin = MIN(clipymin, (int)cliptop[i]); - clipymax = MAX(clipymax, (int)clipbottom[i]); - } - int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, clipleft); - int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright); - int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, clipymin); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipymax - 1); - if (minx >= maxx || miny >= maxy) - return; - - // Block size, standard 8x8 (must be power of two) - const int q = 8; - - // Start in corner of 8x8 block - minx &= ~(q - 1); - miny &= ~(q - 1); - - dest += miny * pitch; - - // Half-edge constants - int C1 = DY12 * X1 - DX12 * Y1; - int C2 = DY23 * X2 - DX23 * Y2; - int C3 = DY31 * X3 - DX31 * Y3; - - // Correct for fill convention - if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; - if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; - if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; - - // Loop through blocks - for (int y = miny; y < maxy; y += q) - { - for (int x = minx; x < maxx; x += q) - { - // Corners of block - int x0 = x << 4; - int x1 = (x + q - 1) << 4; - int y0 = y << 4; - int y1 = (y + q - 1) << 4; - - // Evaluate half-space functions - bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; - bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; - bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; - bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; - int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); - - bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; - bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; - bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; - bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; - int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); - - bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; - bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; - bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; - bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; - int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); - - // Skip block when outside an edge - if (a == 0x0 || b == 0x0 || c == 0x0) continue; - - // Check if block needs clipping - int clipcount = 0; - for (int ix = x; ix < x + q; ix++) - { - clipcount += (clipleft > ix) || (clipright < ix) || (cliptop[ix] > y) || (clipbottom[ix] <= y + q - 1); - } - - uint32_t *buffer = dest; - - // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && clipcount == 0) - { - for (int iy = 0; iy < q; iy++) - { - if ((y + iy) % thread->num_cores == thread->core) - { - for (int ix = x; ix < x + q; ix++) - { - buffer[ix] = solidcolor; - } - } - - buffer += pitch; - } - } - else // Partially covered block - { - int CY1 = C1 + DX12 * y0 - DY12 * x0; - int CY2 = C2 + DX23 * y0 - DY23 * x0; - int CY3 = C3 + DX31 * y0 - DY31 * x0; - - for (int iy = 0; iy < q; iy++) - { - int CX1 = CY1; - int CX2 = CY2; - int CX3 = CY3; - - if ((y + iy) % thread->num_cores == thread->core) - { - for (int ix = x; ix < x + q; ix++) - { - bool visible = ix >= clipleft && ix <= clipright && (cliptop[ix] <= y + iy) && (clipbottom[ix] > y + iy); - - if (CX1 > 0 && CX2 > 0 && CX3 > 0 && visible) - { - buffer[ix] = solidcolor; - } - - CX1 -= FDY12; - CX2 -= FDY23; - CX3 -= FDY31; - } - } - - CY1 += FDX12; - CY2 += FDX23; - CY3 += FDX31; - - buffer += pitch; - } - } - } - - dest += q * pitch; - } -} - -float ScreenTriangleDrawer::gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) -{ - float top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); - float bottom = (x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2); - return top / bottom; -} - -float ScreenTriangleDrawer::grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) -{ - float top = (c1 - c2) * (x0 - x2) - (c0 - c2) * (x1 - x2); - float bottom = -((x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2)); - return top / bottom; -} - -///////////////////////////////////////////////////////////////////////////// - -TriMatrix TriMatrix::null() -{ - TriMatrix m; - memset(m.matrix, 0, sizeof(m.matrix)); - return m; -} - -TriMatrix TriMatrix::identity() -{ - TriMatrix m = null(); - m.matrix[0] = 1.0f; - m.matrix[5] = 1.0f; - m.matrix[10] = 1.0f; - m.matrix[15] = 1.0f; - return m; -} - -TriMatrix TriMatrix::translate(float x, float y, float z) -{ - TriMatrix m = identity(); - m.matrix[0 + 3 * 4] = x; - m.matrix[1 + 3 * 4] = y; - m.matrix[2 + 3 * 4] = z; - return m; -} - -TriMatrix TriMatrix::scale(float x, float y, float z) -{ - TriMatrix m = null(); - m.matrix[0 + 0 * 4] = x; - m.matrix[1 + 1 * 4] = y; - m.matrix[2 + 2 * 4] = z; - m.matrix[3 + 3 * 4] = 1; - return m; -} - -TriMatrix TriMatrix::rotate(float angle, float x, float y, float z) -{ - float c = cosf(angle); - float s = sinf(angle); - TriMatrix m = null(); - m.matrix[0 + 0 * 4] = (x*x*(1.0f - c) + c); - m.matrix[0 + 1 * 4] = (x*y*(1.0f - c) - z*s); - m.matrix[0 + 2 * 4] = (x*z*(1.0f - c) + y*s); - m.matrix[1 + 0 * 4] = (y*x*(1.0f - c) + z*s); - m.matrix[1 + 1 * 4] = (y*y*(1.0f - c) + c); - m.matrix[1 + 2 * 4] = (y*z*(1.0f - c) - x*s); - m.matrix[2 + 0 * 4] = (x*z*(1.0f - c) - y*s); - m.matrix[2 + 1 * 4] = (y*z*(1.0f - c) + x*s); - m.matrix[2 + 2 * 4] = (z*z*(1.0f - c) + c); - m.matrix[3 + 3 * 4] = 1.0f; - return m; -} - -TriMatrix TriMatrix::swapYZ() -{ - TriMatrix m = null(); - m.matrix[0 + 0 * 4] = 1.0f; - m.matrix[1 + 2 * 4] = 1.0f; - m.matrix[2 + 1 * 4] = -1.0f; - m.matrix[3 + 3 * 4] = 1.0f; - return m; -} - -TriMatrix TriMatrix::perspective(float fovy, float aspect, float z_near, float z_far) -{ - float f = (float)(1.0 / tan(fovy * M_PI / 360.0)); - TriMatrix m = null(); - m.matrix[0 + 0 * 4] = f / aspect; - m.matrix[1 + 1 * 4] = f; - m.matrix[2 + 2 * 4] = (z_far + z_near) / (z_near - z_far); - m.matrix[2 + 3 * 4] = (2.0f * z_far * z_near) / (z_near - z_far); - m.matrix[3 + 2 * 4] = -1.0f; - return m; -} - -TriMatrix TriMatrix::frustum(float left, float right, float bottom, float top, float near, float far) -{ - float a = (right + left) / (right - left); - float b = (top + bottom) / (top - bottom); - float c = -(far + near) / (far - near); - float d = -(2.0f * far) / (far - near); - TriMatrix m = null(); - m.matrix[0 + 0 * 4] = 2.0f * near / (right - left); - m.matrix[1 + 1 * 4] = 2.0f * near / (top - bottom); - m.matrix[0 + 2 * 4] = a; - m.matrix[1 + 2 * 4] = b; - m.matrix[2 + 2 * 4] = c; - m.matrix[2 + 3 * 4] = d; - m.matrix[3 + 2 * 4] = -1; - return m; -} - -TriMatrix TriMatrix::worldToView() -{ - TriMatrix m = null(); - m.matrix[0 + 0 * 4] = (float)ViewSin; - m.matrix[0 + 1 * 4] = (float)-ViewCos; - m.matrix[1 + 2 * 4] = 1.0f; - m.matrix[2 + 0 * 4] = (float)-ViewCos; - m.matrix[2 + 1 * 4] = (float)-ViewSin; - m.matrix[3 + 3 * 4] = 1.0f; - return m * translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); -} - -TriMatrix TriMatrix::viewToClip() -{ - float near = 5.0f; - float far = 65536.0f; - float width = (float)(FocalTangent * near); - float top = (float)(CenterY / InvZtoScale * near); - float bottom = (float)(top - viewheight / InvZtoScale * near); - return frustum(-width, width, bottom, top, near, far); -} - -TriMatrix TriMatrix::operator*(const TriMatrix &mult) const -{ - TriMatrix result; - for (int x = 0; x < 4; x++) - { - for (int y = 0; y < 4; y++) - { - result.matrix[x + y * 4] = - matrix[0 * 4 + x] * mult.matrix[y * 4 + 0] + - matrix[1 * 4 + x] * mult.matrix[y * 4 + 1] + - matrix[2 * 4 + x] * mult.matrix[y * 4 + 2] + - matrix[3 * 4 + x] * mult.matrix[y * 4 + 3]; - } - } - return result; -} - -TriVertex TriMatrix::operator*(TriVertex v) const -{ - float vx = matrix[0 * 4 + 0] * v.x + matrix[1 * 4 + 0] * v.y + matrix[2 * 4 + 0] * v.z + matrix[3 * 4 + 0] * v.w; - float vy = matrix[0 * 4 + 1] * v.x + matrix[1 * 4 + 1] * v.y + matrix[2 * 4 + 1] * v.z + matrix[3 * 4 + 1] * v.w; - float vz = matrix[0 * 4 + 2] * v.x + matrix[1 * 4 + 2] * v.y + matrix[2 * 4 + 2] * v.z + matrix[3 * 4 + 2] * v.w; - float vw = matrix[0 * 4 + 3] * v.x + matrix[1 * 4 + 3] * v.y + matrix[2 * 4 + 3] * v.z + matrix[3 * 4 + 3] * v.w; - v.x = vx; - v.y = vy; - v.z = vz; - v.w = vw; - return v; -} - -///////////////////////////////////////////////////////////////////////////// - -DrawTrianglesCommand::DrawTrianglesCommand(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *clipdata, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor) - : uniforms(uniforms), vinput(vinput), vcount(vcount), mode(mode), ccw(ccw), clipleft(clipleft), clipright(clipright), clipdata(clipdata), texturePixels(texturePixels), textureWidth(textureWidth), textureHeight(textureHeight), solidcolor(solidcolor) -{ -} - -void DrawTrianglesCommand::Execute(DrawerThread *thread) -{ - int cliplength = clipright - clipleft + 1; - for (int i = 0; i < cliplength; i++) - { - thread->triangle_clip_top[clipleft + i] = clipdata[i]; - thread->triangle_clip_bottom[clipleft + i] = clipdata[cliplength + i]; - } - - WorkerThreadData thread_data; - thread_data.core = thread->core; - thread_data.num_cores = thread->num_cores; - thread_data.pass_start_y = thread->pass_start_y; - thread_data.pass_end_y = thread->pass_end_y; - thread_data.temp = thread->dc_temp_rgba; - - TriangleDrawer::draw_arrays( - uniforms, vinput, vcount, mode, ccw, - clipleft, clipright, thread->triangle_clip_top, thread->triangle_clip_bottom, - texturePixels, textureWidth, textureHeight, solidcolor, - &thread_data, texturePixels ? ScreenTriangleDrawer::draw32 : ScreenTriangleDrawer::fill32); -} - -FString DrawTrianglesCommand::DebugInfo() -{ - return "DrawTriangles"; -} diff --git a/src/r_triangle.h b/src/r_triangle.h deleted file mode 100644 index 6ec413d3f..000000000 --- a/src/r_triangle.h +++ /dev/null @@ -1,116 +0,0 @@ -/* -** Triangle drawers -** Copyright (c) 2016 Magnus Norddahl -** -** This software is provided 'as-is', without any express or implied -** warranty. In no event will the authors be held liable for any damages -** arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, -** including commercial applications, and to alter it and redistribute it -** freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not -** claim that you wrote the original software. If you use this software -** in a product, an acknowledgment in the product documentation would be -** appreciated but is not required. -** 2. Altered source versions must be plainly marked as such, and must not be -** misrepresented as being the original software. -** 3. This notice may not be removed or altered from any source distribution. -** -*/ - - -#ifndef __R_TRIANGLE__ -#define __R_TRIANGLE__ - -#include "r_draw.h" -#include "r_thread.h" -#include "r_compiler/llvmdrawers.h" - -class FTexture; -struct ScreenTriangleDrawerArgs; - -enum class TriangleDrawMode -{ - Normal, - Fan, - Strip -}; - -class TriangleDrawer -{ -public: - static void draw(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, FTexture *texture); - static void fill(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, int solidcolor); - -private: - static TriVertex shade_vertex(const TriUniforms &uniforms, TriVertex v); - static void draw_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor, WorkerThreadData *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, WorkerThreadData *)); - static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, ScreenTriangleDrawerArgs *args, WorkerThreadData *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, WorkerThreadData *)); - static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); - static void clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert); - - static void queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); - - enum { max_additional_vertices = 16 }; - - friend class DrawTrianglesCommand; -}; - -struct ScreenTriangleDrawerArgs -{ - uint8_t *dest; - int pitch; - TriVertex *v1; - TriVertex *v2; - TriVertex *v3; - int clipleft; - int clipright; - const short *cliptop; - const short *clipbottom; - const uint8_t *texturePixels; - int textureWidth; - int textureHeight; - int solidcolor; - const TriUniforms *uniforms; -}; - -class ScreenTriangleDrawer -{ -public: - static void draw(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread); - static void fill(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread); - - static void draw32(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread); - static void fill32(const ScreenTriangleDrawerArgs *args, WorkerThreadData *thread); - -private: - static float gradx(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); - static float grady(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); -}; - -class DrawTrianglesCommand : public DrawerCommand -{ -public: - DrawTrianglesCommand(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *clipdata, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor); - - void Execute(DrawerThread *thread) override; - FString DebugInfo() override; - -private: - const TriUniforms uniforms; - const TriVertex *vinput; - int vcount; - TriangleDrawMode mode; - bool ccw; - int clipleft; - int clipright; - const short *clipdata; - const uint8_t *texturePixels; - int textureWidth; - int textureHeight; - int solidcolor; -}; - -#endif From 6761e8639a07cca24ca88f66be7e1be5edd2f27c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 20 Nov 2016 04:06:21 +0100 Subject: [PATCH 1254/1509] Add palette support --- .../fixedfunction/drawtrianglecodegen.cpp | 46 +++++++++++++++---- .../fixedfunction/drawtrianglecodegen.h | 7 +++ src/r_compiler/llvmdrawers.cpp | 7 ++- src/r_compiler/llvmdrawers.h | 5 ++ src/r_poly.cpp | 9 ++-- src/r_poly_decal.cpp | 1 + src/r_poly_particle.cpp | 1 + src/r_poly_plane.cpp | 2 + src/r_poly_sky.cpp | 1 + src/r_poly_sprite.cpp | 1 + src/r_poly_triangle.cpp | 10 ++-- src/r_poly_triangle.h | 21 +++++++++ src/r_poly_wall.cpp | 1 + src/r_poly_wallsprite.cpp | 1 + 14 files changed, 94 insertions(+), 19 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index fbbca7517..c59992d3b 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -258,7 +258,18 @@ void DrawTriangleCodegen::LoopBlockX() SSAFloat shade = 64.0f - (SSAFloat(light * 255 / 256) + 12.0f) * 32.0f / 128.0f; SSAFloat lightscale = SSAFloat::clamp((shade - SSAFloat::MIN(SSAFloat(24.0f), vis)) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)); SSAInt diminishedlight = SSAInt(SSAFloat::clamp((1.0f - lightscale) * 256.0f + 0.5f, SSAFloat(0.0f), SSAFloat(256.0f)), false); - currentlight = is_fixed_light.select(light, diminishedlight); + + if (!truecolor) + { + SSAInt diminishedindex = SSAInt(lightscale * 32.0f, false); + SSAInt lightindex = SSAInt::MIN((256 - light) * 32 / 256, SSAInt(31)); + SSAInt colormapindex = is_fixed_light.select(lightindex, diminishedindex); + currentcolormap = Colormaps[colormapindex << 8]; + } + else + { + currentlight = is_fixed_light.select(light, diminishedlight); + } SetStencilBlock(x / 8 + y / 8 * stencilPitch); @@ -352,25 +363,32 @@ void DrawTriangleCodegen::LoopFullBlock() } else { - SSAVec4i pixels = buf.load_vec4ub(false); + SSAVec4i pixelsvec = buf.load_vec4ub(false); + SSAInt pixels[4] = + { + pixelsvec[0], + pixelsvec[1], + pixelsvec[2], + pixelsvec[3] + }; for (int sse = 0; sse < 4; sse++) { if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) { SSABool subsectorTest = subsectorbuffer[ix].load(true) >= subsectorDepth; - pixels.insert(sse, subsectorTest.select(ProcessPixel8(pixels[sse], varying), pixels[sse])); + pixels[sse] = subsectorTest.select(ProcessPixel8(pixels[sse], varying), pixels[sse]); } else { - pixels.insert(sse, ProcessPixel8(pixels[sse], varying)); + pixels[sse] = ProcessPixel8(pixels[sse], varying); } for (int i = 0; i < TriVertex::NumVarying; i++) varying[i] = varying[i] + varyingStep[i]; } - buf.store_vec4ub(pixels); + buf.store_vec4ub(SSAVec4i(pixels[0], pixels[1], pixels[2], pixels[3])); } if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) @@ -580,12 +598,16 @@ SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) { - return color; + return currentcolormap[color].load(true).zext_int(); } else { - SSAUByte fg = texturePixels[uvoffset].load(true); - return fg.zext_int(); + SSAInt index = texturePixels[uvoffset].load(true).zext_int(); + SSAInt fg = currentcolormap[index].load(true).zext_int(); + if (blendmode != TriBlendMode::AlphaBlend) + return fg; + else + return (index == SSAInt(0)).select(bg, fg); } } @@ -659,6 +681,14 @@ void DrawTriangleCodegen::LoadArgs(SSAValue args, SSAValue thread_data) stencilTestValue = args[0][17].load(true); stencilWriteValue = args[0][18].load(true); subsectorGBuffer = args[0][19].load(true); + if (!truecolor) + { + Colormaps = args[0][20].load(true); + RGB32k = args[0][21].load(true); + Col2RGB8 = args[0][22].load(true); + Col2RGB8_LessPrecision = args[0][23].load(true); + Col2RGB8_Inverse = args[0][24].load(true); + } thread.core = thread_data[0][0].load(true); thread.num_cores = thread_data[0][1].load(true); diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.h b/src/r_compiler/fixedfunction/drawtrianglecodegen.h index e4c22d49c..d2ff95e02 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.h +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.h @@ -107,6 +107,12 @@ private: SSAUByte stencilWriteValue; SSAIntPtr subsectorGBuffer; + SSAUBytePtr Colormaps; + SSAUBytePtr RGB32k; + SSAIntPtr Col2RGB8; + SSAIntPtr Col2RGB8_LessPrecision; + SSAIntPtr Col2RGB8_Inverse; + SSAWorkerThread thread; // Block size, standard 8x8 (must be power of two) @@ -126,6 +132,7 @@ private: SSAInt x, y; SSAInt x0, x1, y0, y1; SSAInt currentlight; + SSAUBytePtr currentcolormap; SSAInt varyingPos[TriVertex::NumVarying]; SSAInt varyingStepPos[TriVertex::NumVarying]; SSAInt varyingStartStepX[TriVertex::NumVarying]; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 913e5d9b7..869a24c2c 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -127,7 +127,7 @@ LLVMDrawers *LLVMDrawers::Instance() LLVMDrawersImpl::LLVMDrawersImpl() { - int version = 2; // Increment this number if the drawer codegen is modified (forces recreation of the module). + int version = 3; // Increment this number if the drawer codegen is modified (forces recreation of the module). std::string targetCPU = mProgram.GetTargetCPU(); bool loaded = mProgram.LoadCachedModule(version, targetCPU); if (!loaded) @@ -582,6 +582,11 @@ llvm::Type *LLVMDrawersImpl::GetTriDrawTriangleArgs(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilTestValue; elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilWriteValue; elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *subsectorGBuffer; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *colormaps; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *RGB32k; + elements.push_back(llvm::Type::getInt32PtrTy(context)); // const uint32_t *Col2RGB8; + elements.push_back(llvm::Type::getInt32PtrTy(context)); // const uint32_t *Col2RGB8_LessPrecision; + elements.push_back(llvm::Type::getInt32PtrTy(context)); // const uint32_t *Col2RGB8_Inverse; return llvm::StructType::create(context, elements, "TriDrawTriangle", false)->getPointerTo(); } diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 1db2f5b2a..873f98c73 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -258,6 +258,11 @@ struct TriDrawTriangleArgs uint8_t stencilTestValue; uint8_t stencilWriteValue; uint32_t *subsectorGBuffer; + const uint8_t *colormaps; + const uint8_t *RGB32k; + const uint32_t *Col2RGB8; + const uint32_t *Col2RGB8_LessPrecision; + const uint32_t *Col2RGB8_Inverse; }; enum class TriDrawVariant diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 4dc90027d..680d77c52 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -36,9 +36,6 @@ void InitGLRMapinfoData(); void RenderPolyScene::Render() { - if (!r_swtruecolor) // Disable pal rendering for now - return; - ClearBuffers(); SetSceneViewport(); SetupPerspectiveMatrix(); @@ -63,8 +60,8 @@ void RenderPolyScene::ClearBuffers() SectorSpriteRanges.resize(numsectors); SortedSprites.clear(); TranslucentObjects.clear(); - PolyStencilBuffer::Instance()->Clear(screen->GetWidth(), screen->GetHeight(), 0); - PolySubsectorGBuffer::Instance()->Resize(screen->GetPitch(), screen->GetHeight()); + PolyStencilBuffer::Instance()->Clear(RenderTarget->GetWidth(), RenderTarget->GetHeight(), 0); + PolySubsectorGBuffer::Instance()->Resize(RenderTarget->GetPitch(), RenderTarget->GetHeight()); NextSubsectorDepth = 0; } @@ -77,7 +74,7 @@ void RenderPolyScene::SetSceneViewport() height = (screenblocks*SCREENHEIGHT / 10) & ~7; int bottom = SCREENHEIGHT - (height + viewwindowy - ((height - viewheight) / 2)); - PolyTriangleDrawer::set_viewport(viewwindowx, SCREENHEIGHT - bottom - height, viewwidth, height, screen); + PolyTriangleDrawer::set_viewport(viewwindowx, SCREENHEIGHT - bottom - height, viewwidth, height, RenderTarget); } void RenderPolyScene::SetupPerspectiveMatrix() diff --git a/src/r_poly_decal.cpp b/src/r_poly_decal.cpp index 52caae7e2..fa77b25a4 100644 --- a/src/r_poly_decal.cpp +++ b/src/r_poly_decal.cpp @@ -152,6 +152,7 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); + args.SetColormap(line->frontsector->ColorMap); //mode = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Shaded); } diff --git a/src/r_poly_particle.cpp b/src/r_poly_particle.cpp index 8448c8f32..619b3e146 100644 --- a/src/r_poly_particle.cpp +++ b/src/r_poly_particle.cpp @@ -94,5 +94,6 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *partic args.ccw = true; args.stenciltestvalue = 0; args.stencilwritevalue = 1; + args.SetColormap(sub->sector->ColorMap); PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector, TriBlendMode::AlphaBlend); } diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index a68a4b568..a64dfaaf5 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -140,6 +140,7 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *s args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); + args.SetColormap(sub->sector->ColorMap); PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy); PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); } @@ -231,6 +232,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin args.ccw = ccw; args.stenciltestvalue = 0; args.stencilwritevalue = 1; + args.SetColormap(frontsector->ColorMap); if (!isSky) { diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp index a60b3f460..a8e7b23d6 100644 --- a/src/r_poly_sky.cpp +++ b/src/r_poly_sky.cpp @@ -63,6 +63,7 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) args.stenciltestvalue = 255; args.stencilwritevalue = 1; args.SetTexture(frontskytex); + args.SetColormap(&NormalLight); RenderCapColorRow(args, frontskytex, 0, false); RenderCapColorRow(args, frontskytex, rc, true); diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index 84ff8e221..737707c74 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -136,6 +136,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex, thing->Translation); + args.SetColormap(sub->sector->ColorMap); if (args.translation) PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAlphaBlend); diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 5574251e6..a00ea90eb 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -70,10 +70,7 @@ void PolyTriangleDrawer::set_viewport(int x, int y, int width, int height, DCanv void PolyTriangleDrawer::draw(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode) { - if (dest_bgra) - DrawerCommandQueue::QueueCommand(args, variant, blendmode); - else - draw_arrays(args, variant, blendmode, nullptr); + DrawerCommandQueue::QueueCommand(args, variant, blendmode); } void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVariant variant, TriBlendMode blendmode, WorkerThreadData *thread) @@ -113,6 +110,11 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian args.stencilValues = PolyStencilBuffer::Instance()->Values(); args.stencilMasks = PolyStencilBuffer::Instance()->Masks(); args.subsectorGBuffer = PolySubsectorGBuffer::Instance()->Values(); + args.colormaps = drawargs.colormaps; + args.RGB32k = RGB32k.All; + args.Col2RGB8 = (const uint32_t*)Col2RGB8; + args.Col2RGB8_Inverse = (const uint32_t*)Col2RGB8_Inverse; + args.Col2RGB8_LessPrecision = (const uint32_t*)Col2RGB8_LessPrecision; bool ccw = drawargs.ccw; const TriVertex *vinput = drawargs.vinput; diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index db6719de9..5736e2c9d 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -26,6 +26,7 @@ #include "r_thread.h" #include "r_compiler/llvmdrawers.h" #include "r_data/r_translate.h" +#include "r_data/colormaps.h" class FTexture; @@ -53,6 +54,7 @@ public: const uint8_t *translation = nullptr; uint8_t stenciltestvalue = 0; uint8_t stencilwritevalue = 0; + const uint8_t *colormaps = nullptr; void SetTexture(FTexture *texture) { @@ -86,6 +88,25 @@ public: SetTexture(texture); } + + void SetColormap(FSWColormap *base_colormap) + { + uniforms.light_red = base_colormap->Color.r * 256 / 255; + uniforms.light_green = base_colormap->Color.g * 256 / 255; + uniforms.light_blue = base_colormap->Color.b * 256 / 255; + uniforms.light_alpha = base_colormap->Color.a * 256 / 255; + uniforms.fade_red = base_colormap->Fade.r; + uniforms.fade_green = base_colormap->Fade.g; + uniforms.fade_blue = base_colormap->Fade.b; + uniforms.fade_alpha = base_colormap->Fade.a; + uniforms.desaturate = MIN(abs(base_colormap->Desaturate), 255) * 255 / 256; + bool simple_shade = (base_colormap->Color.d == 0x00ffffff && base_colormap->Fade.d == 0x00000000 && base_colormap->Desaturate == 0); + if (simple_shade) + uniforms.flags |= TriUniforms::simple_shade; + else + uniforms.flags &= ~TriUniforms::simple_shade; + colormaps = base_colormap->Maps; + } }; class PolyTriangleDrawer diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index f0eb33c32..92c669ebf 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -190,6 +190,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); + args.SetColormap(Line->frontsector->ColorMap); if (!Masked) { diff --git a/src/r_poly_wallsprite.cpp b/src/r_poly_wallsprite.cpp index cd331dcb5..6ed009c33 100644 --- a/src/r_poly_wallsprite.cpp +++ b/src/r_poly_wallsprite.cpp @@ -121,5 +121,6 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, AActor *thing, s args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); + args.SetColormap(sub->sector->ColorMap); PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend); } From bd9ec843dd8d8e9af66179b3a11de68f7e26bdad Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 20 Nov 2016 16:42:53 +0100 Subject: [PATCH 1255/1509] Add palette version of the blend modes --- .../fixedfunction/drawtrianglecodegen.cpp | 153 ++++++++++++++---- .../fixedfunction/drawtrianglecodegen.h | 13 +- src/r_compiler/llvmdrawers.cpp | 6 +- src/r_compiler/llvmdrawers.h | 4 +- src/r_poly_particle.cpp | 14 +- src/r_poly_triangle.cpp | 4 +- 6 files changed, 142 insertions(+), 52 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index c59992d3b..da6933149 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -505,7 +505,7 @@ void DrawTriangleCodegen::LoopPartialBlock() loopy.end_block(); } -SSAVec4i DrawTriangleCodegen::TranslateSample(SSAInt uvoffset) +SSAVec4i DrawTriangleCodegen::TranslateSample32(SSAInt uvoffset) { if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) return translation[color * 4].load_vec4ub(true); @@ -513,7 +513,15 @@ SSAVec4i DrawTriangleCodegen::TranslateSample(SSAInt uvoffset) return translation[texturePixels[uvoffset].load(true).zext_int() * 4].load_vec4ub(true); } -SSAVec4i DrawTriangleCodegen::Sample(SSAInt uvoffset) +SSAInt DrawTriangleCodegen::TranslateSample8(SSAInt uvoffset) +{ + if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + return translation[color].load(true).zext_int(); + else + return translation[texturePixels[uvoffset].load(true).zext_int()].load(true).zext_int(); +} + +SSAVec4i DrawTriangleCodegen::Sample32(SSAInt uvoffset) { if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) return SSAVec4i::unpack(color); @@ -521,6 +529,19 @@ SSAVec4i DrawTriangleCodegen::Sample(SSAInt uvoffset) return texturePixels[uvoffset * 4].load_vec4ub(true); } +SSAInt DrawTriangleCodegen::Sample8(SSAInt uvoffset) +{ + if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + return color; + else + return texturePixels[uvoffset].load(true).zext_int(); +} + +SSAInt DrawTriangleCodegen::Shade8(SSAInt c) +{ + return currentcolormap[c].load(true).zext_int(); +} + SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) { SSAInt ufrac = varying[0]; @@ -538,48 +559,54 @@ SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) { default: case TriBlendMode::Copy: - fg = Sample(uvoffset); - output = blend_copy(shade_bgra_simple(fg, currentlight)); break; + fg = Sample32(uvoffset); + output = blend_copy(shade_bgra_simple(fg, currentlight)); + break; case TriBlendMode::AlphaBlend: - fg = Sample(uvoffset); - output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); break; + fg = Sample32(uvoffset); + output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); + break; case TriBlendMode::AddSolid: - fg = Sample(uvoffset); - output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, destalpha); break; + fg = Sample32(uvoffset); + output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, destalpha); + break; case TriBlendMode::Add: - fg = Sample(uvoffset); - output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; + fg = Sample32(uvoffset); + output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; case TriBlendMode::Sub: - fg = Sample(uvoffset); - output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; + fg = Sample32(uvoffset); + output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; case TriBlendMode::RevSub: - fg = Sample(uvoffset); - output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; + fg = Sample32(uvoffset); + output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; case TriBlendMode::Shaded: - fg = Sample(uvoffset); + fg = Sample32(uvoffset); alpha = fg[0]; alpha = alpha + (alpha >> 7); // 255 -> 256 inv_alpha = 256 - alpha; output = blend_add(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), bg, alpha, inv_alpha); break; case TriBlendMode::TranslateCopy: - fg = TranslateSample(uvoffset); + fg = TranslateSample32(uvoffset); output = blend_copy(shade_bgra_simple(fg, currentlight)); break; case TriBlendMode::TranslateAlphaBlend: - fg = TranslateSample(uvoffset); - output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); break; + fg = TranslateSample32(uvoffset); + output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); break; case TriBlendMode::TranslateAdd: - fg = TranslateSample(uvoffset); + fg = TranslateSample32(uvoffset); output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; case TriBlendMode::TranslateSub: - fg = TranslateSample(uvoffset); + fg = TranslateSample32(uvoffset); output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; case TriBlendMode::TranslateRevSub: - fg = TranslateSample(uvoffset); + fg = TranslateSample32(uvoffset); output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; } @@ -587,6 +614,18 @@ SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) return output; } +SSAVec4i DrawTriangleCodegen::ToBgra(SSAInt index) +{ + SSAVec4i c = BaseColors[index * 4].load_vec4ub(true); + c = c.insert(3, 255); + return c; +} + +SSAInt DrawTriangleCodegen::ToPal8(SSAVec4i c) +{ + return RGB32k[((c[2] >> 3) * 32 + (c[1] >> 3)) * 32 + (c[0] >> 3)].load(true).zext_int(); +} + SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) { SSAInt ufrac = varying[0]; @@ -596,19 +635,65 @@ SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; SSAInt uvoffset = upos * textureHeight + vpos; - if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + SSAVec4i fg; + SSAInt alpha, inv_alpha; + SSAInt output; + SSAInt palindex; + + switch (blendmode) { - return currentcolormap[color].load(true).zext_int(); - } - else - { - SSAInt index = texturePixels[uvoffset].load(true).zext_int(); - SSAInt fg = currentcolormap[index].load(true).zext_int(); - if (blendmode != TriBlendMode::AlphaBlend) - return fg; - else - return (index == SSAInt(0)).select(bg, fg); + default: + case TriBlendMode::Copy: + output = Shade8(Sample8(uvoffset)); + break; + case TriBlendMode::AlphaBlend: + palindex = Sample8(uvoffset); + output = (palindex == SSAInt(0)).select(bg, Shade8(palindex)); + break; + case TriBlendMode::AddSolid: + fg = ToBgra(Shade8(Sample8(uvoffset))); + output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, destalpha)); + break; + case TriBlendMode::Add: + fg = ToBgra(Shade8(Sample8(uvoffset))); + output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + break; + case TriBlendMode::Sub: + fg = ToBgra(Shade8(Sample8(uvoffset))); + output = ToPal8(blend_sub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + break; + case TriBlendMode::RevSub: + fg = ToBgra(Shade8(Sample8(uvoffset))); + output = ToPal8(blend_revsub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + break; + case TriBlendMode::Shaded: + alpha = Sample8(uvoffset); + alpha = alpha + (alpha >> 7); // 255 -> 256 + inv_alpha = 256 - alpha; + output = ToPal8(blend_add(ToBgra(Shade8(color)), ToBgra(bg), alpha, inv_alpha)); + break; + case TriBlendMode::TranslateCopy: + output = Shade8(TranslateSample8(uvoffset)); + break; + case TriBlendMode::TranslateAlphaBlend: + palindex = TranslateSample8(uvoffset); + output = (palindex == SSAInt(0)).select(bg, Shade8(palindex)); + break; + case TriBlendMode::TranslateAdd: + fg = ToBgra(Shade8(Sample8(uvoffset))); + output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + break; + case TriBlendMode::TranslateSub: + fg = ToBgra(Shade8(Sample8(uvoffset))); + output = ToPal8(blend_sub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + break; + case TriBlendMode::TranslateRevSub: + fg = ToBgra(Shade8(Sample8(uvoffset))); + output = ToPal8(blend_revsub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + break; } + + return output; } void DrawTriangleCodegen::SetStencilBlock(SSAInt block) @@ -685,9 +770,7 @@ void DrawTriangleCodegen::LoadArgs(SSAValue args, SSAValue thread_data) { Colormaps = args[0][20].load(true); RGB32k = args[0][21].load(true); - Col2RGB8 = args[0][22].load(true); - Col2RGB8_LessPrecision = args[0][23].load(true); - Col2RGB8_Inverse = args[0][24].load(true); + BaseColors = args[0][22].load(true); } thread.core = thread_data[0][0].load(true); diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.h b/src/r_compiler/fixedfunction/drawtrianglecodegen.h index d2ff95e02..74358f99a 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.h +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.h @@ -49,8 +49,13 @@ private: SSAVec4i ProcessPixel32(SSAVec4i bg, SSAInt *varying); SSAInt ProcessPixel8(SSAInt bg, SSAInt *varying); - SSAVec4i TranslateSample(SSAInt uvoffset); - SSAVec4i Sample(SSAInt uvoffset); + SSAVec4i TranslateSample32(SSAInt uvoffset); + SSAInt TranslateSample8(SSAInt uvoffset); + SSAVec4i Sample32(SSAInt uvoffset); + SSAInt Sample8(SSAInt uvoffset); + SSAInt Shade8(SSAInt c); + SSAVec4i ToBgra(SSAInt index); + SSAInt ToPal8(SSAVec4i c); void SetStencilBlock(SSAInt block); void StencilSet(SSAInt x, SSAInt y, SSAUByte value); @@ -109,9 +114,7 @@ private: SSAUBytePtr Colormaps; SSAUBytePtr RGB32k; - SSAIntPtr Col2RGB8; - SSAIntPtr Col2RGB8_LessPrecision; - SSAIntPtr Col2RGB8_Inverse; + SSAUBytePtr BaseColors; SSAWorkerThread thread; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 869a24c2c..dea72a1ac 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -127,7 +127,7 @@ LLVMDrawers *LLVMDrawers::Instance() LLVMDrawersImpl::LLVMDrawersImpl() { - int version = 3; // Increment this number if the drawer codegen is modified (forces recreation of the module). + int version = 4; // Increment this number if the drawer codegen is modified (forces recreation of the module). std::string targetCPU = mProgram.GetTargetCPU(); bool loaded = mProgram.LoadCachedModule(version, targetCPU); if (!loaded) @@ -584,9 +584,7 @@ llvm::Type *LLVMDrawersImpl::GetTriDrawTriangleArgs(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *subsectorGBuffer; elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *colormaps; elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *RGB32k; - elements.push_back(llvm::Type::getInt32PtrTy(context)); // const uint32_t *Col2RGB8; - elements.push_back(llvm::Type::getInt32PtrTy(context)); // const uint32_t *Col2RGB8_LessPrecision; - elements.push_back(llvm::Type::getInt32PtrTy(context)); // const uint32_t *Col2RGB8_Inverse; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *BaseColors; return llvm::StructType::create(context, elements, "TriDrawTriangle", false)->getPointerTo(); } diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 873f98c73..1cbafa11a 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -260,9 +260,7 @@ struct TriDrawTriangleArgs uint32_t *subsectorGBuffer; const uint8_t *colormaps; const uint8_t *RGB32k; - const uint32_t *Col2RGB8; - const uint32_t *Col2RGB8_LessPrecision; - const uint32_t *Col2RGB8_Inverse; + const uint8_t *BaseColors; }; enum class TriDrawVariant diff --git a/src/r_poly_particle.cpp b/src/r_poly_particle.cpp index 619b3e146..9b1dbaf1c 100644 --- a/src/r_poly_particle.cpp +++ b/src/r_poly_particle.cpp @@ -82,8 +82,18 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *partic uniforms.flags = 0; } uniforms.subsectorDepth = subsectorDepth; - uint32_t alpha = particle->trans; - uniforms.color = (alpha << 24) | (particle->color & 0xffffff); + + if (r_swtruecolor) + { + uint32_t alpha = particle->trans; + uniforms.color = (alpha << 24) | (particle->color & 0xffffff); + } + else + { + uniforms.color = ((uint32_t)particle->color) >> 24; + uniforms.srcalpha = particle->trans; + uniforms.destalpha = 255 - particle->trans; + } PolyDrawArgs args; args.uniforms = uniforms; diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index a00ea90eb..2ba3336d1 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -112,9 +112,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian args.subsectorGBuffer = PolySubsectorGBuffer::Instance()->Values(); args.colormaps = drawargs.colormaps; args.RGB32k = RGB32k.All; - args.Col2RGB8 = (const uint32_t*)Col2RGB8; - args.Col2RGB8_Inverse = (const uint32_t*)Col2RGB8_Inverse; - args.Col2RGB8_LessPrecision = (const uint32_t*)Col2RGB8_LessPrecision; + args.BaseColors = (const uint8_t *)GPalette.BaseColors; bool ccw = drawargs.ccw; const TriVertex *vinput = drawargs.vinput; From ebd810d843330f30300201ec0a18276ea5f7af30 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 20 Nov 2016 16:43:13 +0100 Subject: [PATCH 1256/1509] Fix decal vertical position being wrong --- src/r_poly_decal.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/r_poly_decal.cpp b/src/r_poly_decal.cpp index fa77b25a4..5035b4529 100644 --- a/src/r_poly_decal.cpp +++ b/src/r_poly_decal.cpp @@ -118,7 +118,7 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co vertices[i].x = (float)p.X; vertices[i].y = (float)p.Y; - vertices[i].z = (float)(zpos + spriteHeight * offsets[i].second); + vertices[i].z = (float)(zpos + spriteHeight * offsets[i].second - spriteHeight * 0.5); vertices[i].w = 1.0f; vertices[i].varying[0] = (float)(offsets[i].first * tex->Scale.X); vertices[i].varying[1] = (float)((1.0f - offsets[i].second) * tex->Scale.Y); @@ -140,7 +140,15 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co uniforms.flags = 0; } uniforms.subsectorDepth = subsectorDepth; - uniforms.color = decal->AlphaColor; + + if (r_swtruecolor) + { + uniforms.color = 0xff000000 | decal->AlphaColor; + } + else + { + uniforms.color = ((uint32_t)decal->AlphaColor) >> 24; + } PolyDrawArgs args; args.uniforms = uniforms; @@ -152,7 +160,7 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co args.stenciltestvalue = 0; args.stencilwritevalue = 1; args.SetTexture(tex); - args.SetColormap(line->frontsector->ColorMap); + args.SetColormap(front->ColorMap); //mode = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Shaded); } From 4ed548a189b16676d1350e7429c1db05ac9b015f Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 20 Nov 2016 17:07:58 -0500 Subject: [PATCH 1257/1509] - Implemented some sprite blend modes. --- src/r_poly_sprite.cpp | 103 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 100 insertions(+), 3 deletions(-) diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index 737707c74..6de63bbdc 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -28,6 +28,9 @@ #include "r_poly_sprite.h" #include "r_poly.h" +EXTERN_CVAR(Float, transsouls) +EXTERN_CVAR(Int, r_drawfuzz) + void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth) { if (IsThingCulled(thing)) @@ -138,10 +141,104 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse args.SetTexture(tex, thing->Translation); args.SetColormap(sub->sector->ColorMap); - if (args.translation) - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAlphaBlend); + if (thing->RenderStyle == LegacyRenderStyles[STYLE_Normal] || + (r_drawfuzz == 0 && thing->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])) + { + args.uniforms.destalpha = 0; + args.uniforms.srcalpha = 256; + (args.translation) ? + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAdd) : + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); + } + else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Add]) + { + args.uniforms.destalpha = (uint32_t)(1.0 * 256); + args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); + (args.translation) ? + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAdd) : + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); + } + else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Subtract]) + { + args.uniforms.destalpha = (uint32_t)(1.0 * 256); + args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); + (args.translation) ? + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateSub) : + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Sub); + } + else if (thing->RenderStyle == LegacyRenderStyles[STYLE_SoulTrans]) + { + args.uniforms.destalpha = (uint32_t)(256 - transsouls * 256); + args.uniforms.srcalpha = (uint32_t)(transsouls * 256); + (args.translation) ? + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAdd) : + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); + } + else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Fuzzy] || + (r_drawfuzz == 2 && thing->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])) + { // NYI - Fuzzy - for now, just a copy of "Shadow" + args.uniforms.destalpha = 160; + args.uniforms.srcalpha = 0; + (args.translation) ? + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAdd) : + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); + + } + else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Shadow] || + (r_drawfuzz == 1 && thing->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])) + { + args.uniforms.destalpha = 160; + args.uniforms.srcalpha = 0; + (args.translation) ? + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAdd) : + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); + + } + else if (thing->RenderStyle == LegacyRenderStyles[STYLE_TranslucentStencil]) + { + // NYI + args.uniforms.destalpha = (uint32_t)(256 - thing->Alpha * 256); + args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); + args.uniforms.color = 0xff000000 | thing->fillcolor; + (args.translation) ? + PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector, TriBlendMode::TranslateAdd) : + PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector, TriBlendMode::Add); + } + else if (thing->RenderStyle == LegacyRenderStyles[STYLE_AddStencil]) + { + // NYI + args.uniforms.destalpha = 256; + args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); + args.uniforms.color = 0xff000000 | thing->fillcolor; + (args.translation) ? + PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector, TriBlendMode::TranslateAdd) : + PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector, TriBlendMode::Add); + } + else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Shaded]) + { + args.uniforms.destalpha = 256; + args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); + args.SetTexture(tex, false); + uniforms.flags |= TriUniforms::simple_shade; + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Shaded); + } + else if (thing->RenderStyle == LegacyRenderStyles[STYLE_AddShaded]) + { // NYI? + args.uniforms.destalpha = 256; + args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); + args.SetTexture(tex, false); + uniforms.flags |= TriUniforms::simple_shade; + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Shaded); + } else - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend); + { + args.uniforms.destalpha = (uint32_t)(256 - thing->Alpha * 256); + args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); + (args.translation) ? + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAdd) : + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); + } + } bool RenderPolySprite::IsThingCulled(AActor *thing) From dadee080e4b6ed0363bc2a09d1eeec90b2caa903 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 20 Nov 2016 18:36:26 -0500 Subject: [PATCH 1258/1509] - Implemented Wall blend modes - fixed: set color for "shaded" modes - though it's still not yet properly implemented. --- src/r_poly_sprite.cpp | 2 ++ src/r_poly_wall.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index 6de63bbdc..e4738ab26 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -219,6 +219,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse args.uniforms.destalpha = 256; args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); args.SetTexture(tex, false); + args.uniforms.color = 0; uniforms.flags |= TriUniforms::simple_shade; PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Shaded); } @@ -227,6 +228,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse args.uniforms.destalpha = 256; args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); args.SetTexture(tex, false); + args.uniforms.color = 0; uniforms.flags |= TriUniforms::simple_shade; PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Shaded); } diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index 92c669ebf..2cdcb3019 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -199,7 +199,12 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) } else { - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend); + args.uniforms.destalpha = (Line->linedef->flags & ML_ADDTRANS) ? 256 : (uint32_t)(256 - Line->linedef->alpha * 256); + args.uniforms.srcalpha = (uint32_t)(Line->linedef->alpha * 256); + if (args.uniforms.destalpha == 0 && args.uniforms.srcalpha == 256) + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend); + else + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); } RenderPolyDecal::RenderWallDecals(worldToClip, Line, SubsectorDepth); From 29005b5ce6b44436d8840d55790452a9609d918d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 21 Nov 2016 01:40:08 +0100 Subject: [PATCH 1259/1509] Compile fix for older versions of LLVM --- src/r_compiler/llvmdrawers.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index dea72a1ac..82cac4a18 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -644,7 +644,11 @@ bool LLVMProgram::LoadCachedModule(int version, std::string targetCPU) if (!result) return false; +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + mModule.reset(result.get()); +#else mModule = std::move(result.get()); +#endif return true; } From 144c7f413928e33447f24cc146b839429dab6d09 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 21 Nov 2016 01:56:54 +0100 Subject: [PATCH 1260/1509] Flip sub and revsub TC drawers in the old renderer --- src/r_draw.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index bd53889a1..d04b1dcf6 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -2521,6 +2521,9 @@ void R_InitColumnDrawers () dovline4_saved = dovline4; domvline4_saved = domvline4; } + + // This code intentionally flips sub and revsub for all the classic drawer functions + // because the renderer swapped sub and revsub! R_DrawColumnHoriz = R_DrawColumnHoriz_rgba; R_DrawColumn = R_DrawColumn_rgba; @@ -2537,16 +2540,16 @@ void R_InitColumnDrawers () R_FillColumn = R_FillColumn_rgba; R_FillAddColumn = R_FillAddColumn_rgba; R_FillAddClampColumn = R_FillAddClampColumn_rgba; - R_FillSubClampColumn = R_FillSubClampColumn_rgba; - R_FillRevSubClampColumn = R_FillRevSubClampColumn_rgba; + R_FillSubClampColumn = R_FillRevSubClampColumn_rgba; + R_FillRevSubClampColumn = R_FillSubClampColumn_rgba; R_DrawAddColumn = R_DrawAddColumn_rgba; R_DrawTlatedAddColumn = R_DrawTlatedAddColumn_rgba; R_DrawAddClampColumn = R_DrawAddClampColumn_rgba; R_DrawAddClampTranslatedColumn = R_DrawAddClampTranslatedColumn_rgba; - R_DrawSubClampColumn = R_DrawSubClampColumn_rgba; - R_DrawSubClampTranslatedColumn = R_DrawSubClampTranslatedColumn_rgba; - R_DrawRevSubClampColumn = R_DrawRevSubClampColumn_rgba; - R_DrawRevSubClampTranslatedColumn = R_DrawRevSubClampTranslatedColumn_rgba; + R_DrawSubClampColumn = R_DrawRevSubClampColumn_rgba; + R_DrawSubClampTranslatedColumn = R_DrawRevSubClampTranslatedColumn_rgba; + R_DrawRevSubClampColumn = R_DrawSubClampColumn_rgba; + R_DrawRevSubClampTranslatedColumn = R_DrawSubClampTranslatedColumn_rgba; R_FillSpan = R_FillSpan_rgba; R_DrawFogBoundary = R_DrawFogBoundary_rgba; R_FillColumnHoriz = R_FillColumnHoriz_rgba; @@ -2578,20 +2581,20 @@ void R_InitColumnDrawers () rt_add4cols = rt_add4cols_rgba; rt_addclamp1col = rt_addclamp1col_rgba; rt_addclamp4cols = rt_addclamp4cols_rgba; - rt_subclamp1col = rt_subclamp1col_rgba; - rt_revsubclamp1col = rt_revsubclamp1col_rgba; + rt_subclamp1col = rt_revsubclamp1col_rgba; + rt_revsubclamp1col = rt_subclamp1col_rgba; rt_tlate1col = rt_tlate1col_rgba; rt_tlateadd1col = rt_tlateadd1col_rgba; rt_tlateaddclamp1col = rt_tlateaddclamp1col_rgba; - rt_tlatesubclamp1col = rt_tlatesubclamp1col_rgba; - rt_tlaterevsubclamp1col = rt_tlaterevsubclamp1col_rgba; - rt_subclamp4cols = rt_subclamp4cols_rgba; - rt_revsubclamp4cols = rt_revsubclamp4cols_rgba; + rt_tlatesubclamp1col = rt_tlaterevsubclamp1col_rgba; + rt_tlaterevsubclamp1col = rt_tlatesubclamp1col_rgba; + rt_subclamp4cols = rt_revsubclamp4cols_rgba; + rt_revsubclamp4cols = rt_subclamp4cols_rgba; rt_tlate4cols = rt_tlate4cols_rgba; rt_tlateadd4cols = rt_tlateadd4cols_rgba; rt_tlateaddclamp4cols = rt_tlateaddclamp4cols_rgba; - rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_rgba; - rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_rgba; + rt_tlatesubclamp4cols = rt_tlaterevsubclamp4cols_rgba; + rt_tlaterevsubclamp4cols = rt_tlatesubclamp4cols_rgba; rt_initcols = rt_initcols_rgba; rt_span_coverage = rt_span_coverage_rgba; From 2ba2dc7611f1891ed7cf13f9aca6694004905de1 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 21 Nov 2016 03:49:55 +0100 Subject: [PATCH 1261/1509] Change shaded blend mode use srcalpha and destalpha. Fix blending error in add/sub/revsub --- .../fixedfunction/drawercodegen.cpp | 23 +++++- src/r_compiler/fixedfunction/drawercodegen.h | 1 + .../fixedfunction/drawtrianglecodegen.cpp | 11 +-- src/r_compiler/llvmdrawers.h | 2 +- src/r_poly_decal.cpp | 21 ++--- src/r_poly_sprite.cpp | 79 ++++++++----------- 6 files changed, 68 insertions(+), 69 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawercodegen.cpp b/src/r_compiler/fixedfunction/drawercodegen.cpp index 761023cef..65b726b93 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.cpp +++ b/src/r_compiler/fixedfunction/drawercodegen.cpp @@ -107,18 +107,27 @@ SSAVec4i DrawerCodegen::blend_copy(SSAVec4i fg) SSAVec4i DrawerCodegen::blend_add(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) { + SSAInt alpha = fg[3]; + alpha = alpha + (alpha >> 7); // 255 -> 256 + srcalpha = (alpha * srcalpha + 128) >> 8; SSAVec4i color = (fg * srcalpha + bg * destalpha) / 256; return color.insert(3, 255); } SSAVec4i DrawerCodegen::blend_sub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) { + SSAInt alpha = fg[3]; + alpha = alpha + (alpha >> 7); // 255 -> 256 + srcalpha = (alpha * srcalpha + 128) >> 8; SSAVec4i color = (bg * destalpha - fg * srcalpha) / 256; return color.insert(3, 255); } SSAVec4i DrawerCodegen::blend_revsub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) { + SSAInt alpha = fg[3]; + alpha = alpha + (alpha >> 7); // 255 -> 256 + srcalpha = (alpha * srcalpha + 128) >> 8; SSAVec4i color = (fg * srcalpha - bg * destalpha) / 256; return color.insert(3, 255); } @@ -126,7 +135,7 @@ SSAVec4i DrawerCodegen::blend_revsub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAVec4i DrawerCodegen::blend_alpha_blend(SSAVec4i fg, SSAVec4i bg) { SSAInt alpha = fg[3]; - alpha = alpha + (alpha >> 7); // // 255 -> 256 + alpha = alpha + (alpha >> 7); // 255 -> 256 SSAInt inv_alpha = 256 - alpha; SSAVec4i color = (fg * alpha + bg * inv_alpha) / 256; return color.insert(3, 255); @@ -139,3 +148,15 @@ SSAInt DrawerCodegen::calc_blend_bgalpha(SSAVec4i fg, SSAInt destalpha) SSAInt inv_alpha = 256 - alpha; return (destalpha * alpha + 256 * inv_alpha + 128) >> 8; } + +SSAVec4i DrawerCodegen::blend_stencil(SSAVec4i stencilcolor, SSAInt fgalpha, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha) +{ + fgalpha = fgalpha + (fgalpha >> 7); // 255 -> 256 + SSAInt inv_fgalpha = 256 - fgalpha; + + srcalpha = (fgalpha * srcalpha + 128) >> 8; + destalpha = (destalpha * fgalpha + 256 * inv_fgalpha + 128) >> 8; + + SSAVec4i color = (stencilcolor * srcalpha + bg * destalpha) / 256; + return color.insert(3, 255); +} diff --git a/src/r_compiler/fixedfunction/drawercodegen.h b/src/r_compiler/fixedfunction/drawercodegen.h index 5de52dca1..ef6e8d11e 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.h +++ b/src/r_compiler/fixedfunction/drawercodegen.h @@ -85,6 +85,7 @@ public: SSAVec4i blend_sub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha); SSAVec4i blend_revsub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha); SSAVec4i blend_alpha_blend(SSAVec4i fg, SSAVec4i bg); + SSAVec4i blend_stencil(SSAVec4i color, SSAInt fgalpha, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha); // Calculates the final alpha values to be used when combined with the source texture alpha channel SSAInt calc_blend_bgalpha(SSAVec4i fg, SSAInt destalpha); diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index da6933149..4ee444067 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -552,7 +552,6 @@ SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) SSAInt uvoffset = upos * textureHeight + vpos; SSAVec4i fg; - SSAInt alpha, inv_alpha; SSAVec4i output; switch (blendmode) @@ -584,10 +583,7 @@ SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) break; case TriBlendMode::Shaded: fg = Sample32(uvoffset); - alpha = fg[0]; - alpha = alpha + (alpha >> 7); // 255 -> 256 - inv_alpha = 256 - alpha; - output = blend_add(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), bg, alpha, inv_alpha); + output = blend_stencil(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), fg[3], bg, srcalpha, destalpha); break; case TriBlendMode::TranslateCopy: fg = TranslateSample32(uvoffset); @@ -667,10 +663,7 @@ SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) output = ToPal8(blend_revsub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); break; case TriBlendMode::Shaded: - alpha = Sample8(uvoffset); - alpha = alpha + (alpha >> 7); // 255 -> 256 - inv_alpha = 256 - alpha; - output = ToPal8(blend_add(ToBgra(Shade8(color)), ToBgra(bg), alpha, inv_alpha)); + output = ToPal8(blend_stencil(ToBgra(Shade8(color)), Sample8(uvoffset), ToBgra(bg), srcalpha, destalpha)); break; case TriBlendMode::TranslateCopy: output = Shade8(TranslateSample8(uvoffset)); diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 1cbafa11a..dbaef8b47 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -281,7 +281,7 @@ enum class TriBlendMode Add, // blend_add(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) Sub, // blend_sub(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) RevSub, // blend_revsub(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) - Shaded, // blend_add(color, bg, fg.a, 1 - fg.a) + Shaded, // blend_stencil(shade(color), fg, bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) TranslateCopy, // blend_copy(shade(translate(fg))) TranslateAlphaBlend, // blend_alpha_blend(shade(translate(fg)), bg) TranslateAdd, // blend_add(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) diff --git a/src/r_poly_decal.cpp b/src/r_poly_decal.cpp index 5035b4529..f23ca2863 100644 --- a/src/r_poly_decal.cpp +++ b/src/r_poly_decal.cpp @@ -128,30 +128,31 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co bool fullbrightSprite = (decal->RenderFlags & RF_FULLBRIGHT) == RF_FULLBRIGHT; - TriUniforms uniforms; + PolyDrawArgs args; + args.uniforms.flags = 0; if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) { - uniforms.light = 256; - uniforms.flags = TriUniforms::fixed_light; + args.uniforms.light = 256; + args.uniforms.flags |= TriUniforms::fixed_light; } else { - uniforms.light = (uint32_t)((front->lightlevel + actualextralight) / 255.0f * 256.0f); - uniforms.flags = 0; + args.uniforms.light = (uint32_t)((front->lightlevel + actualextralight) / 255.0f * 256.0f); } - uniforms.subsectorDepth = subsectorDepth; + args.uniforms.subsectorDepth = subsectorDepth; if (r_swtruecolor) { - uniforms.color = 0xff000000 | decal->AlphaColor; + args.uniforms.color = 0xff000000 | decal->AlphaColor; } else { - uniforms.color = ((uint32_t)decal->AlphaColor) >> 24; + args.uniforms.color = ((uint32_t)decal->AlphaColor) >> 24; } + + args.uniforms.srcalpha = 256; + args.uniforms.destalpha = 0; - PolyDrawArgs args; - args.uniforms = uniforms; args.objectToClip = &worldToClip; args.vinput = vertices; args.vcount = 4; diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index e4738ab26..bc032b91c 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -116,21 +116,19 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT)); - TriUniforms uniforms; + PolyDrawArgs args; + args.uniforms.flags = 0; if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) { - uniforms.light = 256; - uniforms.flags = TriUniforms::fixed_light; + args.uniforms.light = 256; + args.uniforms.flags |= TriUniforms::fixed_light; } else { - uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f); - uniforms.flags = 0; + args.uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f); } - uniforms.subsectorDepth = subsectorDepth; + args.uniforms.subsectorDepth = subsectorDepth; - PolyDrawArgs args; - args.uniforms = uniforms; args.objectToClip = &worldToClip; args.vinput = vertices; args.vcount = 4; @@ -141,106 +139,91 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse args.SetTexture(tex, thing->Translation); args.SetColormap(sub->sector->ColorMap); + TriBlendMode blendmode; + if (thing->RenderStyle == LegacyRenderStyles[STYLE_Normal] || (r_drawfuzz == 0 && thing->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])) { args.uniforms.destalpha = 0; args.uniforms.srcalpha = 256; - (args.translation) ? - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAdd) : - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); + blendmode = args.translation ? TriBlendMode::TranslateAdd : TriBlendMode::Add; } else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Add]) { args.uniforms.destalpha = (uint32_t)(1.0 * 256); args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); - (args.translation) ? - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAdd) : - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); + blendmode = args.translation ? TriBlendMode::TranslateAdd : TriBlendMode::Add; } else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Subtract]) { args.uniforms.destalpha = (uint32_t)(1.0 * 256); args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); - (args.translation) ? - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateSub) : - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Sub); + blendmode = args.translation ? TriBlendMode::TranslateSub : TriBlendMode::Sub; } else if (thing->RenderStyle == LegacyRenderStyles[STYLE_SoulTrans]) { args.uniforms.destalpha = (uint32_t)(256 - transsouls * 256); args.uniforms.srcalpha = (uint32_t)(transsouls * 256); - (args.translation) ? - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAdd) : - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); + blendmode = args.translation ? TriBlendMode::TranslateAdd : TriBlendMode::Add; } else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Fuzzy] || (r_drawfuzz == 2 && thing->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])) { // NYI - Fuzzy - for now, just a copy of "Shadow" args.uniforms.destalpha = 160; args.uniforms.srcalpha = 0; - (args.translation) ? - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAdd) : - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); - + blendmode = args.translation ? TriBlendMode::TranslateAdd : TriBlendMode::Add; } else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Shadow] || (r_drawfuzz == 1 && thing->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])) { args.uniforms.destalpha = 160; args.uniforms.srcalpha = 0; - (args.translation) ? - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAdd) : - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); - + blendmode = args.translation ? TriBlendMode::TranslateAdd : TriBlendMode::Add; } else if (thing->RenderStyle == LegacyRenderStyles[STYLE_TranslucentStencil]) { - // NYI args.uniforms.destalpha = (uint32_t)(256 - thing->Alpha * 256); args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); args.uniforms.color = 0xff000000 | thing->fillcolor; - (args.translation) ? - PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector, TriBlendMode::TranslateAdd) : - PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector, TriBlendMode::Add); + blendmode = TriBlendMode::Shaded; } else if (thing->RenderStyle == LegacyRenderStyles[STYLE_AddStencil]) { - // NYI args.uniforms.destalpha = 256; - args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); + args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256) * 2; // Don't know this needs to be multiplied by two.. args.uniforms.color = 0xff000000 | thing->fillcolor; - (args.translation) ? - PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector, TriBlendMode::TranslateAdd) : - PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector, TriBlendMode::Add); + blendmode = TriBlendMode::Shaded; } else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Shaded]) { - args.uniforms.destalpha = 256; args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); - args.SetTexture(tex, false); + args.uniforms.destalpha = 256 - args.uniforms.srcalpha; args.uniforms.color = 0; - uniforms.flags |= TriUniforms::simple_shade; - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Shaded); + blendmode = TriBlendMode::Shaded; } else if (thing->RenderStyle == LegacyRenderStyles[STYLE_AddShaded]) - { // NYI? + { args.uniforms.destalpha = 256; args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); - args.SetTexture(tex, false); args.uniforms.color = 0; - uniforms.flags |= TriUniforms::simple_shade; - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Shaded); + blendmode = TriBlendMode::Shaded; } else { args.uniforms.destalpha = (uint32_t)(256 - thing->Alpha * 256); args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); - (args.translation) ? - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::TranslateAdd) : - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); + blendmode = args.translation ? TriBlendMode::TranslateAdd : TriBlendMode::Add; + } + + if (!r_swtruecolor) + { + uint32_t r = (args.uniforms.color >> 16) & 0xff; + uint32_t g = (args.uniforms.color >> 8) & 0xff; + uint32_t b = args.uniforms.color & 0xff; + args.uniforms.color = RGB32k.RGB[r >> 3][g >> 3][b >> 3]; } + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, blendmode); } bool RenderPolySprite::IsThingCulled(AActor *thing) From e7d64a380a69a988bb77d699866d8a3bee59ce39 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 21 Nov 2016 05:09:53 +0100 Subject: [PATCH 1262/1509] Fix AABB culling bug --- src/r_poly_cull.cpp | 84 ++++++++++++++++++------------------------- src/r_poly_triangle.h | 2 +- 2 files changed, 36 insertions(+), 50 deletions(-) diff --git a/src/r_poly_cull.cpp b/src/r_poly_cull.cpp index 89c59aa79..dff8b7688 100644 --- a/src/r_poly_cull.cpp +++ b/src/r_poly_cull.cpp @@ -130,7 +130,7 @@ void PolyCull::MarkSegmentCulled(int x1, int x2) { // Find last segment int merge = cur; - while (merge + 1 != SolidSegments.size() && SolidSegments[merge + 1].X1 <= x2) + while (merge + 1 != (int)SolidSegments.size() && SolidSegments[merge + 1].X1 <= x2) merge++; // Apply new merged range @@ -168,57 +168,43 @@ bool PolyCull::CheckBBox(float *bspcoord) // Occlusion test using solid segments: - int boxx; - int boxy; - int boxpos; - - double x1, y1, x2, y2; - - // Find the corners of the box - // that define the edges from current viewpoint. - if (ViewPos.X <= bspcoord[BOXLEFT]) - boxx = 0; - else if (ViewPos.X < bspcoord[BOXRIGHT]) - boxx = 1; - else - boxx = 2; - - if (ViewPos.Y >= bspcoord[BOXTOP]) - boxy = 0; - else if (ViewPos.Y > bspcoord[BOXBOTTOM]) - boxy = 1; - else - boxy = 2; - - boxpos = (boxy << 2) + boxx; - if (boxpos == 5) - return true; - - static const int checkcoord[12][4] = + static const int lines[4][4] = { - { 3,0,2,1 }, - { 3,0,2,0 }, - { 3,1,2,0 }, - { 0 }, - { 2,0,2,1 }, - { 0,0,0,0 }, - { 3,1,3,0 }, - { 0 }, - { 2,0,3,1 }, - { 2,1,3,1 }, - { 2,1,3,0 } + { BOXLEFT, BOXBOTTOM, BOXRIGHT, BOXBOTTOM }, + { BOXRIGHT, BOXBOTTOM, BOXRIGHT, BOXTOP }, + { BOXRIGHT, BOXTOP, BOXLEFT, BOXTOP }, + { BOXLEFT, BOXTOP, BOXLEFT, BOXBOTTOM } }; - x1 = bspcoord[checkcoord[boxpos][0]]; - y1 = bspcoord[checkcoord[boxpos][1]]; - x2 = bspcoord[checkcoord[boxpos][2]]; - y2 = bspcoord[checkcoord[boxpos][3]]; - - int sx1, sx2; - if (GetSegmentRangeForLine(x1, y1, x2, y2, sx1, sx2)) - return !IsSegmentCulled(sx1, sx2); - else - return true; + bool foundline = false; + int minsx1, maxsx2; + for (int i = 0; i < 4; i++) + { + int j = i < 3 ? i + 1 : 0; + int x1 = bspcoord[lines[i][0]]; + int y1 = bspcoord[lines[i][1]]; + int x2 = bspcoord[lines[i][2]]; + int y2 = bspcoord[lines[i][3]]; + int sx1, sx2; + if (GetSegmentRangeForLine(x1, y1, x2, y2, sx1, sx2)) + { + if (foundline) + { + minsx1 = MIN(minsx1, sx1); + maxsx2 = MAX(maxsx2, sx2); + } + else + { + minsx1 = sx1; + maxsx2 = sx2; + foundline = true; + } + } + } + if (!foundline) + return false; + + return !IsSegmentCulled(minsx1, maxsx2); } bool PolyCull::GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 5736e2c9d..9fd8b7a9a 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -69,7 +69,7 @@ public: void SetTexture(FTexture *texture, uint32_t translationID) { - if (translationID != -1 && translationID != 0) + if (translationID != 0xffffffff && translationID != 0) { FRemapTable *table = TranslationToTable(translationID); if (table != nullptr && !table->Inactive) From 5e9c9c825dd13216e2ce832a9d220564d1c21429 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 21 Nov 2016 05:52:02 +0100 Subject: [PATCH 1263/1509] Add stencil blend mode as apparently the shaded mode uses indices whiles stencil uses mask/alpha.. --- .../fixedfunction/drawtrianglecodegen.cpp | 8 +++++++- src/r_compiler/llvmdrawers.cpp | 2 +- src/r_compiler/llvmdrawers.h | 3 ++- src/r_poly_decal.cpp | 8 ++++---- src/r_poly_sprite.cpp | 9 +++++++-- src/r_poly_triangle.h | 15 ++++++++++++--- 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index 4ee444067..3dca72544 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -581,10 +581,13 @@ SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) fg = Sample32(uvoffset); output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; - case TriBlendMode::Shaded: + case TriBlendMode::Stencil: fg = Sample32(uvoffset); output = blend_stencil(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), fg[3], bg, srcalpha, destalpha); break; + case TriBlendMode::Shaded: + output = blend_stencil(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), Sample8(uvoffset), bg, srcalpha, destalpha); + break; case TriBlendMode::TranslateCopy: fg = TranslateSample32(uvoffset); output = blend_copy(shade_bgra_simple(fg, currentlight)); @@ -662,6 +665,9 @@ SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) fg = ToBgra(Shade8(Sample8(uvoffset))); output = ToPal8(blend_revsub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); break; + case TriBlendMode::Stencil: + output = ToPal8(blend_stencil(ToBgra(Shade8(color)), (Sample8(uvoffset) == SSAInt(0)).select(SSAInt(0), SSAInt(256)), ToBgra(bg), srcalpha, destalpha)); + break; case TriBlendMode::Shaded: output = ToPal8(blend_stencil(ToBgra(Shade8(color)), Sample8(uvoffset), ToBgra(bg), srcalpha, destalpha)); break; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 82cac4a18..6745af8e4 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -127,7 +127,7 @@ LLVMDrawers *LLVMDrawers::Instance() LLVMDrawersImpl::LLVMDrawersImpl() { - int version = 4; // Increment this number if the drawer codegen is modified (forces recreation of the module). + int version = 5; // Increment this number if the drawer codegen is modified (forces recreation of the module). std::string targetCPU = mProgram.GetTargetCPU(); bool loaded = mProgram.LoadCachedModule(version, targetCPU); if (!loaded) diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index dbaef8b47..6113b1d04 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -281,7 +281,8 @@ enum class TriBlendMode Add, // blend_add(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) Sub, // blend_sub(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) RevSub, // blend_revsub(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) - Shaded, // blend_stencil(shade(color), fg, bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) + Stencil, // blend_stencil(shade(color), fg.a, bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) + Shaded, // blend_stencil(shade(color), fg.index, bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) TranslateCopy, // blend_copy(shade(translate(fg))) TranslateAlphaBlend, // blend_alpha_blend(shade(translate(fg)), bg) TranslateAdd, // blend_add(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) diff --git a/src/r_poly_decal.cpp b/src/r_poly_decal.cpp index f23ca2863..ef20c9de7 100644 --- a/src/r_poly_decal.cpp +++ b/src/r_poly_decal.cpp @@ -130,6 +130,8 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co PolyDrawArgs args; args.uniforms.flags = 0; + args.SetColormap(front->ColorMap); + args.SetTexture(tex, decal->Translation, true); if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) { args.uniforms.light = 256; @@ -150,8 +152,8 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co args.uniforms.color = ((uint32_t)decal->AlphaColor) >> 24; } - args.uniforms.srcalpha = 256; - args.uniforms.destalpha = 0; + args.uniforms.srcalpha = (uint32_t)(decal->Alpha * 256.0 + 0.5); + args.uniforms.destalpha = 256 - args.uniforms.srcalpha; args.objectToClip = &worldToClip; args.vinput = vertices; @@ -160,8 +162,6 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co args.ccw = true; args.stenciltestvalue = 0; args.stencilwritevalue = 1; - args.SetTexture(tex); - args.SetColormap(front->ColorMap); //mode = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Shaded); } diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index bc032b91c..38ddd46df 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -185,14 +185,14 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse args.uniforms.destalpha = (uint32_t)(256 - thing->Alpha * 256); args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); args.uniforms.color = 0xff000000 | thing->fillcolor; - blendmode = TriBlendMode::Shaded; + blendmode = TriBlendMode::Stencil; } else if (thing->RenderStyle == LegacyRenderStyles[STYLE_AddStencil]) { args.uniforms.destalpha = 256; args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256) * 2; // Don't know this needs to be multiplied by two.. args.uniforms.color = 0xff000000 | thing->fillcolor; - blendmode = TriBlendMode::Shaded; + blendmode = TriBlendMode::Stencil; } else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Shaded]) { @@ -215,6 +215,11 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse blendmode = args.translation ? TriBlendMode::TranslateAdd : TriBlendMode::Add; } + if (blendmode == TriBlendMode::Shaded) + { + args.SetTexture(tex, thing->Translation, true); + } + if (!r_swtruecolor) { uint32_t r = (args.uniforms.color >> 16) & 0xff; diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 9fd8b7a9a..7d58ed5ed 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -67,7 +67,7 @@ public: translation = nullptr; } - void SetTexture(FTexture *texture, uint32_t translationID) + void SetTexture(FTexture *texture, uint32_t translationID, bool forcePal = false) { if (translationID != 0xffffffff && translationID != 0) { @@ -85,8 +85,17 @@ public: return; } } - - SetTexture(texture); + + if (forcePal) + { + textureWidth = texture->GetWidth(); + textureHeight = texture->GetHeight(); + texturePixels = texture->GetPixels(); + } + else + { + SetTexture(texture); + } } void SetColormap(FSWColormap *base_colormap) From fabac78ea877be05c26e3f5de880b3725c5ba83b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 21 Nov 2016 15:19:24 +0100 Subject: [PATCH 1264/1509] Add poly renderer to the menus --- src/r_main.cpp | 8 ++++---- src/r_swrenderer.cpp | 8 ++++---- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.txt | 1 + 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index 1ba89eecd..e0773718f 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -63,7 +63,7 @@ #include "p_setup.h" #include "version.h" -CUSTOM_CVAR(Bool, r_newrenderer, 0, CVAR_NOINITCALL) +CUSTOM_CVAR(Bool, r_polyrenderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { if (self == 1 && !hasglnodes) { @@ -915,7 +915,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) // Link the polyobjects right before drawing the scene to reduce the amounts of calls to this function PO_LinkToSubsectors(); InSubsector = NULL; - if (!r_newrenderer) + if (!r_polyrenderer) { R_RenderBSPNode(nodes + numnodes - 1); // The head node is the last node output. } @@ -932,7 +932,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) if (viewactive) { PlaneCycles.Clock(); - if (!r_newrenderer) + if (!r_polyrenderer) { R_DrawPlanes(); R_DrawPortals(); @@ -953,7 +953,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) NetUpdate (); MaskedCycles.Clock(); - if (!r_newrenderer) + if (!r_polyrenderer) R_DrawMasked (); MaskedCycles.Unclock(); diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 3ddfcb5f2..708b465e1 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -47,7 +47,7 @@ #include "r_poly.h" EXTERN_CVAR(Bool, r_shadercolormaps) -EXTERN_CVAR(Bool, r_newrenderer) // [SP] dpJudas's new renderer +EXTERN_CVAR(Bool, r_polyrenderer) // [SP] dpJudas's new renderer EXTERN_CVAR(Float, maxviewpitch) // [SP] CVAR from GZDoom void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio); @@ -242,7 +242,7 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int wi void FSoftwareRenderer::DrawRemainingPlayerSprites() { - if (!r_newrenderer) + if (!r_polyrenderer) { R_DrawRemainingPlayerSprites(); } @@ -262,12 +262,12 @@ void FSoftwareRenderer::DrawRemainingPlayerSprites() int FSoftwareRenderer::GetMaxViewPitch(bool down) { - return (r_newrenderer) ? int(maxviewpitch) : (down ? MAX_DN_ANGLE : MAX_UP_ANGLE); + return (r_polyrenderer) ? int(maxviewpitch) : (down ? MAX_DN_ANGLE : MAX_UP_ANGLE); } bool FSoftwareRenderer::RequireGLNodes() { - return r_newrenderer; + return r_polyrenderer; } //========================================================================== diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 881cde31f..177d63521 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2152,6 +2152,7 @@ MODMNU_CHIPOMATIC = "Chip-o-matic"; RNDMNU_TITLE = "CHANGE RENDERER"; RNDMNU_RENDERER = "Hardware Acceleration"; RNDMNU_TRUECOLOR = "Software Truecolor Mode"; +RNDMNU_POLY = "Poly Renderer (experimental)"; RNDMNU_CANVAS = "Software Canvas"; // Video Options diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 81c18a522..1c9d42de1 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1773,6 +1773,7 @@ OptionMenu RendererMenu Title "$RNDMNU_TITLE" Option "$RNDMNU_RENDERER", "vid_renderer", "PolyDoom" Option "$RNDMNU_TRUECOLOR", "swtruecolor", "OnOff" + Option "$RNDMNU_POLY", "r_polyrenderer", "OnOff" IfOption(Windows) { Option "$RNDMNU_CANVAS", "vid_used3d", "D3DGL" From 0108ff89d79be0404eea8b05b2ae726ed81a8c90 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 21 Nov 2016 15:20:07 +0100 Subject: [PATCH 1265/1509] Bug fixes --- src/r_poly_cull.cpp | 8 ++++---- src/r_poly_sprite.cpp | 2 +- src/r_poly_triangle.cpp | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/r_poly_cull.cpp b/src/r_poly_cull.cpp index dff8b7688..79b8d151d 100644 --- a/src/r_poly_cull.cpp +++ b/src/r_poly_cull.cpp @@ -181,10 +181,10 @@ bool PolyCull::CheckBBox(float *bspcoord) for (int i = 0; i < 4; i++) { int j = i < 3 ? i + 1 : 0; - int x1 = bspcoord[lines[i][0]]; - int y1 = bspcoord[lines[i][1]]; - int x2 = bspcoord[lines[i][2]]; - int y2 = bspcoord[lines[i][3]]; + float x1 = bspcoord[lines[i][0]]; + float y1 = bspcoord[lines[i][1]]; + float x2 = bspcoord[lines[i][2]]; + float y2 = bspcoord[lines[i][3]]; int sx1, sx2; if (GetSegmentRangeForLine(x1, y1, x2, y2, sx1, sx2)) { diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index 38ddd46df..87d52b98f 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -190,7 +190,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse else if (thing->RenderStyle == LegacyRenderStyles[STYLE_AddStencil]) { args.uniforms.destalpha = 256; - args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256) * 2; // Don't know this needs to be multiplied by two.. + args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); args.uniforms.color = 0xff000000 | thing->fillcolor; blendmode = TriBlendMode::Stencil; } diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 2ba3336d1..88ee02a36 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -339,7 +339,40 @@ void DrawPolyTrianglesCommand::Execute(DrawerThread *thread) FString DrawPolyTrianglesCommand::DebugInfo() { - return "DrawPolyTriangles"; + FString variantstr; + switch (variant) + { + default: variantstr = "Unknown"; break; + case TriDrawVariant::DrawNormal: variantstr = "DrawNormal"; break; + case TriDrawVariant::FillNormal: variantstr = "FillNormal"; break; + case TriDrawVariant::DrawSubsector: variantstr = "DrawSubsector"; break; + case TriDrawVariant::FillSubsector: variantstr = "FillSubsector"; break; + case TriDrawVariant::FuzzSubsector: variantstr = "FuzzSubsector"; break; + case TriDrawVariant::Stencil: variantstr = "Stencil"; break; + } + + FString blendmodestr; + switch (blendmode) + { + default: blendmodestr = "Unknown"; break; + case TriBlendMode::Copy: blendmodestr = "Copy"; break; + case TriBlendMode::AlphaBlend: blendmodestr = "AlphaBlend"; break; + case TriBlendMode::AddSolid: blendmodestr = "AddSolid"; break; + case TriBlendMode::Add: blendmodestr = "Add"; break; + case TriBlendMode::Sub: blendmodestr = "Sub"; break; + case TriBlendMode::RevSub: blendmodestr = "RevSub"; break; + case TriBlendMode::Stencil: blendmodestr = "Stencil"; break; + case TriBlendMode::Shaded: blendmodestr = "Shaded"; break; + case TriBlendMode::TranslateCopy: blendmodestr = "TranslateCopy"; break; + case TriBlendMode::TranslateAlphaBlend: blendmodestr = "TranslateAlphaBlend"; break; + case TriBlendMode::TranslateAdd: blendmodestr = "TranslateAdd"; break; + case TriBlendMode::TranslateSub: blendmodestr = "TranslateSub"; break; + case TriBlendMode::TranslateRevSub: blendmodestr = "TranslateRevSub"; break; + } + + FString info; + info.Format("DrawPolyTriangles: variant = %s, blend mode = %s, color = %d", variantstr.GetChars(), blendmodestr.GetChars(), args.uniforms.color); + return info; } ///////////////////////////////////////////////////////////////////////////// From ddb0161f9c4448e198659ad53cd7e89c14bc0a89 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 21 Nov 2016 15:40:42 +0100 Subject: [PATCH 1266/1509] Sub pinkie crashes the pal drawer :( --- src/r_poly_sprite.cpp | 3 +++ src/r_poly_triangle.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index 87d52b98f..453ab2d00 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -226,6 +226,9 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse uint32_t g = (args.uniforms.color >> 8) & 0xff; uint32_t b = args.uniforms.color & 0xff; args.uniforms.color = RGB32k.RGB[r >> 3][g >> 3][b >> 3]; + + if (blendmode == TriBlendMode::Sub) // Sub crashes in pal mode for some weird reason. + blendmode = TriBlendMode::Add; } PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, blendmode); diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 88ee02a36..367d3df40 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -371,7 +371,9 @@ FString DrawPolyTrianglesCommand::DebugInfo() } FString info; - info.Format("DrawPolyTriangles: variant = %s, blend mode = %s, color = %d", variantstr.GetChars(), blendmodestr.GetChars(), args.uniforms.color); + info.Format("DrawPolyTriangles: variant = %s, blend mode = %s, color = %d, light = %d, textureWidth = %d, textureHeight = %d, texture = %s, translation = %s, colormaps = %s", + variantstr.GetChars(), blendmodestr.GetChars(), args.uniforms.color, args.uniforms.light, args.textureWidth, args.textureHeight, + args.texturePixels ? "ptr" : "null", args.translation ? "ptr" : "null", args.colormaps ? "ptr" : "null"); return info; } From 7af504df586e0fe1ccc8af425c72e1ddf67ad765 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 21 Nov 2016 20:50:54 +0100 Subject: [PATCH 1267/1509] Draw 3d floor sides --- src/r_poly.cpp | 15 +++++++ src/r_poly_decal.cpp | 3 ++ src/r_poly_wall.cpp | 104 ++++++++++++++++++++++++++----------------- src/r_poly_wall.h | 17 ++++--- 4 files changed, 92 insertions(+), 47 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 680d77c52..04e5becde 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -140,7 +140,9 @@ void RenderPolyScene::RenderSubsector(subsector_t *sub) { seg_t *line = &sub->firstline[i]; if (line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) + { RenderLine(sub, line, frontsector, subsectorDepth); + } } bool mainBSP = ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors); @@ -206,6 +208,19 @@ void RenderPolyScene::RenderLine(subsector_t *sub, seg_t *line, sector_t *fronts sub->flags |= SSECF_DRAWN; } + // Render 3D floor sides + if (line->backsector && frontsector->e && line->backsector->e->XFloor.ffloors.Size()) + { + for (unsigned int i = 0; i < line->backsector->e->XFloor.ffloors.Size(); i++) + { + F3DFloor *fakeFloor = line->backsector->e->XFloor.ffloors[i]; + if (!(fakeFloor->flags & FF_EXISTS)) continue; + if (!(fakeFloor->flags & FF_RENDERPLANES)) continue; + if (!fakeFloor->model) continue; + RenderPolyWall::Render3DFloorLine(WorldToClip, line, frontsector, subsectorDepth, fakeFloor, SubsectorTranslucentWalls); + } + } + // Render wall, and update culling info if its an occlusion blocker if (RenderPolyWall::RenderLine(WorldToClip, line, frontsector, subsectorDepth, SubsectorTranslucentWalls)) { diff --git a/src/r_poly_decal.cpp b/src/r_poly_decal.cpp index ef20c9de7..206eb9862 100644 --- a/src/r_poly_decal.cpp +++ b/src/r_poly_decal.cpp @@ -31,6 +31,9 @@ void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const seg_t *line, uint32_t subsectorDepth) { + if (line->linedef == nullptr && line->sidedef == nullptr) + return; + for (DBaseDecal *decal = line->sidedef->AttachedDecals; decal != nullptr; decal = decal->WallNext) { RenderPolyDecal render; diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index 2cdcb3019..075a6f2a2 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -32,17 +32,19 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, std::vector &translucentWallsOutput) { + RenderPolyWall wall; + wall.LineSeg = line; + wall.Line = line->linedef; + wall.Side = line->sidedef; + wall.Colormap = frontsector->ColorMap; + wall.Masked = false; + wall.SubsectorDepth = subsectorDepth; + double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1); double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1); double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2); double frontfloorz2 = frontsector->floorplane.ZatPoint(line->v2); - RenderPolyWall wall; - wall.Line = line; - wall.Colormap = frontsector->ColorMap; - wall.Masked = false; - wall.SubsectorDepth = subsectorDepth; - if (line->backsector == nullptr) { if (line->sidedef) @@ -118,6 +120,28 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, secto return false; } +void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, F3DFloor *fakeFloor, std::vector &translucentWallsOutput) +{ + double frontceilz1 = fakeFloor->top.plane->ZatPoint(line->v1); + double frontfloorz1 = fakeFloor->bottom.plane->ZatPoint(line->v1); + double frontceilz2 = fakeFloor->top.plane->ZatPoint(line->v2); + double frontfloorz2 = fakeFloor->bottom.plane->ZatPoint(line->v2); + + RenderPolyWall wall; + wall.LineSeg = line; + wall.Line = fakeFloor->master; + wall.Side = fakeFloor->master->sidedef[0]; + wall.Colormap = frontsector->ColorMap; + wall.Masked = false; + wall.SubsectorDepth = subsectorDepth; + wall.SetCoords(line->v1->fPos(), line->v2->fPos(), frontceilz1, frontfloorz1, frontceilz2, frontfloorz2); + wall.TopZ = frontceilz1; + wall.BottomZ = frontfloorz1; + wall.UnpeggedCeil = frontceilz1; + wall.Texpart = side_t::mid; + wall.Render(worldToClip); +} + void RenderPolyWall::SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2) { this->v1 = v1; @@ -134,7 +158,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) if (!tex) return; - PolyWallTextureCoords texcoords(tex, Line, Texpart, TopZ, BottomZ, UnpeggedCeil); + PolyWallTextureCoords texcoords(tex, LineSeg, Line, Side, Texpart, TopZ, BottomZ, UnpeggedCeil); TriVertex *vertices = PolyVertexBuffer::GetVertices(4); if (!vertices) @@ -199,15 +223,15 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) } else { - args.uniforms.destalpha = (Line->linedef->flags & ML_ADDTRANS) ? 256 : (uint32_t)(256 - Line->linedef->alpha * 256); - args.uniforms.srcalpha = (uint32_t)(Line->linedef->alpha * 256); + args.uniforms.destalpha = (Line->flags & ML_ADDTRANS) ? 256 : (uint32_t)(256 - Line->alpha * 256); + args.uniforms.srcalpha = (uint32_t)(Line->alpha * 256); if (args.uniforms.destalpha == 0 && args.uniforms.srcalpha == 256) PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend); else PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); } - RenderPolyDecal::RenderWallDecals(worldToClip, Line, SubsectorDepth); + RenderPolyDecal::RenderWallDecals(worldToClip, LineSeg, SubsectorDepth); } void RenderPolyWall::ClampHeight(TriVertex &v1, TriVertex &v2) @@ -232,25 +256,25 @@ void RenderPolyWall::ClampHeight(TriVertex &v1, TriVertex &v2) FTexture *RenderPolyWall::GetTexture() { - FTexture *tex = TexMan(Line->sidedef->GetTexture(Texpart), true); + FTexture *tex = TexMan(Side->GetTexture(Texpart), true); if (tex == nullptr || tex->UseType == FTexture::TEX_Null) { // Mapping error. Doom floodfills this with a plane. // This code doesn't do that, but at least it uses the "right" texture.. - if (Line->linedef && Line->backsector && Line->linedef->sidedef[0] == Line->sidedef) + if (Line && Line->backsector && Line->sidedef[0] == Side) { if (Texpart == side_t::top) - tex = TexMan(Line->linedef->backsector->GetTexture(sector_t::ceiling), true); + tex = TexMan(Line->backsector->GetTexture(sector_t::ceiling), true); else if (Texpart == side_t::bottom) - tex = TexMan(Line->linedef->backsector->GetTexture(sector_t::floor), true); + tex = TexMan(Line->backsector->GetTexture(sector_t::floor), true); } - if (Line->linedef && Line->backsector && Line->linedef->sidedef[1] == Line->sidedef) + if (Line && Line->backsector && Line->sidedef[1] == Side) { if (Texpart == side_t::top) - tex = TexMan(Line->linedef->frontsector->GetTexture(sector_t::ceiling), true); + tex = TexMan(Line->frontsector->GetTexture(sector_t::ceiling), true); else if (Texpart == side_t::bottom) - tex = TexMan(Line->linedef->frontsector->GetTexture(sector_t::floor), true); + tex = TexMan(Line->frontsector->GetTexture(sector_t::floor), true); } if (tex == nullptr || tex->UseType == FTexture::TEX_Null) @@ -269,33 +293,33 @@ int RenderPolyWall::GetLightLevel() { bool foggy = false; int actualextralight = foggy ? 0 : extralight << 4; - return clamp(Line->sidedef->GetLightLevel(foggy, Line->frontsector->lightlevel) + actualextralight, 0, 255); + return clamp(Side->GetLightLevel(foggy, LineSeg->frontsector->lightlevel) + actualextralight, 0, 255); } } ///////////////////////////////////////////////////////////////////////////// -PolyWallTextureCoords::PolyWallTextureCoords(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil) +PolyWallTextureCoords::PolyWallTextureCoords(FTexture *tex, const seg_t *lineseg, const line_t *line, const side_t *side, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil) { - CalcU(tex, line, texpart); - CalcV(tex, line, texpart, topz, bottomz, unpeggedceil); + CalcU(tex, lineseg, line, side, texpart); + CalcV(tex, line, side, texpart, topz, bottomz, unpeggedceil); } -void PolyWallTextureCoords::CalcU(FTexture *tex, const seg_t *line, side_t::ETexpart texpart) +void PolyWallTextureCoords::CalcU(FTexture *tex, const seg_t *lineseg, const line_t *line, const side_t *side, side_t::ETexpart texpart) { - double lineLength = line->sidedef->TexelLength; + double lineLength = side->TexelLength; double lineStart = 0.0; - bool entireSegment = ((line->linedef->v1 == line->v1) && (line->linedef->v2 == line->v2) || (line->linedef->v2 == line->v1) && (line->linedef->v1 == line->v2)); + bool entireSegment = ((lineseg->v1 == line->v1) && (lineseg->v2 == line->v2) || (lineseg->v2 == line->v1) && (lineseg->v1 == line->v2)); if (!entireSegment) { - lineLength = (line->v2->fPos() - line->v1->fPos()).Length(); - lineStart = (line->v1->fPos() - line->linedef->v1->fPos()).Length(); + lineLength = (lineseg->v2->fPos() - lineseg->v1->fPos()).Length(); + lineStart = (lineseg->v1->fPos() - lineseg->v1->fPos()).Length(); } int texWidth = tex->GetWidth(); - double uscale = line->sidedef->GetTextureXScale(texpart) * tex->Scale.X; - u1 = lineStart + line->sidedef->GetTextureXOffset(texpart); + double uscale = side->GetTextureXScale(texpart) * tex->Scale.X; + u1 = lineStart + side->GetTextureXOffset(texpart); u2 = u1 + lineLength; u1 *= uscale; u2 *= uscale; @@ -303,11 +327,11 @@ void PolyWallTextureCoords::CalcU(FTexture *tex, const seg_t *line, side_t::ETex u2 /= texWidth; } -void PolyWallTextureCoords::CalcV(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil) +void PolyWallTextureCoords::CalcV(FTexture *tex, const line_t *line, const side_t *side, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil) { - double vscale = line->sidedef->GetTextureYScale(texpart) * tex->Scale.Y; + double vscale = side->GetTextureYScale(texpart) * tex->Scale.Y; - double yoffset = line->sidedef->GetTextureYOffset(texpart); + double yoffset = side->GetTextureYOffset(texpart); if (tex->bWorldPanning) yoffset *= vscale; @@ -315,13 +339,13 @@ void PolyWallTextureCoords::CalcV(FTexture *tex, const seg_t *line, side_t::ETex { default: case side_t::mid: - CalcVMidPart(tex, line, topz, bottomz, vscale, yoffset); + CalcVMidPart(tex, line, side, topz, bottomz, vscale, yoffset); break; case side_t::top: - CalcVTopPart(tex, line, topz, bottomz, vscale, yoffset); + CalcVTopPart(tex, line, side, topz, bottomz, vscale, yoffset); break; case side_t::bottom: - CalcVBottomPart(tex, line, topz, bottomz, unpeggedceil, vscale, yoffset); + CalcVBottomPart(tex, line, side, topz, bottomz, unpeggedceil, vscale, yoffset); break; } @@ -330,9 +354,9 @@ void PolyWallTextureCoords::CalcV(FTexture *tex, const seg_t *line, side_t::ETex v2 /= texHeight; } -void PolyWallTextureCoords::CalcVTopPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset) +void PolyWallTextureCoords::CalcVTopPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double vscale, double yoffset) { - bool pegged = (line->linedef->flags & ML_DONTPEGTOP) == 0; + bool pegged = (line->flags & ML_DONTPEGTOP) == 0; if (pegged) // bottom to top { int texHeight = tex->GetHeight(); @@ -353,9 +377,9 @@ void PolyWallTextureCoords::CalcVTopPart(FTexture *tex, const seg_t *line, doubl } } -void PolyWallTextureCoords::CalcVMidPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset) +void PolyWallTextureCoords::CalcVMidPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double vscale, double yoffset) { - bool pegged = (line->linedef->flags & ML_DONTPEGBOTTOM) == 0; + bool pegged = (line->flags & ML_DONTPEGBOTTOM) == 0; if (pegged) // top to bottom { v1 = yoffset * vscale; @@ -369,9 +393,9 @@ void PolyWallTextureCoords::CalcVMidPart(FTexture *tex, const seg_t *line, doubl } } -void PolyWallTextureCoords::CalcVBottomPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double unpeggedceil, double vscale, double yoffset) +void PolyWallTextureCoords::CalcVBottomPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double unpeggedceil, double vscale, double yoffset) { - bool pegged = (line->linedef->flags & ML_DONTPEGBOTTOM) == 0; + bool pegged = (line->flags & ML_DONTPEGBOTTOM) == 0; if (pegged) // top to bottom { v1 = yoffset; diff --git a/src/r_poly_wall.h b/src/r_poly_wall.h index 2de1f1c09..d89731911 100644 --- a/src/r_poly_wall.h +++ b/src/r_poly_wall.h @@ -30,6 +30,7 @@ class RenderPolyWall { public: static bool RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, std::vector &translucentWallsOutput); + static void Render3DFloorLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, F3DFloor *fakeFloor, std::vector &translucentWallsOutput); void SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2); void Render(const TriMatrix &worldToClip); @@ -41,7 +42,9 @@ public: double ceil2 = 0.0; double floor2 = 0.0; - const seg_t *Line = nullptr; + const seg_t *LineSeg = nullptr; + const line_t *Line = nullptr; + const side_t *Side = nullptr; side_t::ETexpart Texpart = side_t::mid; double TopZ = 0.0; double BottomZ = 0.0; @@ -60,15 +63,15 @@ private: class PolyWallTextureCoords { public: - PolyWallTextureCoords(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil); + PolyWallTextureCoords(FTexture *tex, const seg_t *lineseg, const line_t *line, const side_t *side, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil); double u1, u2; double v1, v2; private: - void CalcU(FTexture *tex, const seg_t *line, side_t::ETexpart texpart); - void CalcV(FTexture *tex, const seg_t *line, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil); - void CalcVTopPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset); - void CalcVMidPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double vscale, double yoffset); - void CalcVBottomPart(FTexture *tex, const seg_t *line, double topz, double bottomz, double unpeggedceil, double vscale, double yoffset); + void CalcU(FTexture *tex, const seg_t *lineseg, const line_t *line, const side_t *side, side_t::ETexpart texpart); + void CalcV(FTexture *tex, const line_t *line, const side_t *side, side_t::ETexpart texpart, double topz, double bottomz, double unpeggedceil); + void CalcVTopPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double vscale, double yoffset); + void CalcVMidPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double vscale, double yoffset); + void CalcVBottomPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double unpeggedceil, double vscale, double yoffset); }; From dacb985878d37ab4e993f93cde67b24ab05635c4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 22 Nov 2016 01:59:28 +0100 Subject: [PATCH 1268/1509] Fix texture mapping bug --- src/r_poly_wall.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index 075a6f2a2..63f35ccd5 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -314,7 +314,7 @@ void PolyWallTextureCoords::CalcU(FTexture *tex, const seg_t *lineseg, const lin if (!entireSegment) { lineLength = (lineseg->v2->fPos() - lineseg->v1->fPos()).Length(); - lineStart = (lineseg->v1->fPos() - lineseg->v1->fPos()).Length(); + lineStart = (lineseg->v1->fPos() - line->v1->fPos()).Length(); } int texWidth = tex->GetWidth(); From 7beac654716bea57230c04c5266863dfa3705499 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 23 Nov 2016 00:55:07 +0100 Subject: [PATCH 1269/1509] Add Linux support for GLSWFrameBuffer --- src/posix/sdl/hardware.cpp | 4 +++- src/posix/sdl/sdlglvideo.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index f4ac13fc5..b8ca0ee21 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -55,6 +55,8 @@ EXTERN_CVAR (Bool, ticker) EXTERN_CVAR (Bool, fullscreen) EXTERN_CVAR (Float, vid_winscale) +CVAR (Bool, vid_sdl, 0, 0); + IVideo *Video; extern int NewWidth, NewHeight, NewBits, DisplayBits; @@ -119,7 +121,7 @@ void I_InitGraphics () ticker.SetGenericRepDefault (val, CVAR_Bool); //currentrenderer = vid_renderer; - if (currentrenderer==1) Video = new SDLGLVideo(0); + if (currentrenderer==1 || vid_sdl==0) Video = new SDLGLVideo(0); else Video = new SDLVideo (0); if (Video == NULL) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index d8c00f236..ef9eef0b4 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -52,6 +52,8 @@ EXTERN_CVAR (Int, vid_renderer) EXTERN_CVAR (Int, vid_maxfps) EXTERN_CVAR (Bool, cl_capfps) +DFrameBuffer *CreateGLSWFrameBuffer(int width, int height, bool fullscreen); + // PUBLIC DATA DEFINITIONS ------------------------------------------------- CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) @@ -194,7 +196,12 @@ DFrameBuffer *SDLGLVideo::CreateFrameBuffer (int width, int height, bool fullscr // flashAmount = 0; } - SDLGLFB *fb = new OpenGLFrameBuffer (0, width, height, 32, 60, fullscreen); + SDLGLFB *fb; + if (vid_renderer == 1) + fb = new OpenGLFrameBuffer (0, width, height, 32, 60, fullscreen); + else + fb = (SDLGLFB*)CreateGLSWFrameBuffer (width, height, fullscreen); + retry = 0; // If we could not create the framebuffer, try again with slightly From ff738de279c2a19b79969e6d3e0de7ade7e3c983 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 23 Nov 2016 01:01:28 +0100 Subject: [PATCH 1270/1509] Bgra support --- src/posix/sdl/sdlglvideo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index a07f7c0f5..92773801f 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -52,7 +52,7 @@ EXTERN_CVAR (Int, vid_renderer) EXTERN_CVAR (Int, vid_maxfps) EXTERN_CVAR (Bool, cl_capfps) -DFrameBuffer *CreateGLSWFrameBuffer(int width, int height, bool fullscreen); +DFrameBuffer *CreateGLSWFrameBuffer(int width, int height, bool bgra, bool fullscreen); // PUBLIC DATA DEFINITIONS ------------------------------------------------- @@ -200,7 +200,7 @@ DFrameBuffer *SDLGLVideo::CreateFrameBuffer (int width, int height, bool bgra, b if (vid_renderer == 1) fb = new OpenGLFrameBuffer (0, width, height, 32, 60, fullscreen); else - fb = (SDLGLFB*)CreateGLSWFrameBuffer (width, height, fullscreen); + fb = (SDLGLFB*)CreateGLSWFrameBuffer (width, height, bgra, fullscreen); retry = 0; From 91d180bec65cefbe271b54902f5c37839df9111e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 23 Nov 2016 21:10:19 +0100 Subject: [PATCH 1271/1509] Fix render to texture --- src/r_poly.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 04e5becde..d51d01f9b 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -67,14 +67,21 @@ void RenderPolyScene::ClearBuffers() void RenderPolyScene::SetSceneViewport() { - int height; - if (screenblocks >= 10) - height = SCREENHEIGHT; - else - height = (screenblocks*SCREENHEIGHT / 10) & ~7; + if (RenderTarget == screen) // Rendering to screen + { + int height; + if (screenblocks >= 10) + height = SCREENHEIGHT; + else + height = (screenblocks*SCREENHEIGHT / 10) & ~7; - int bottom = SCREENHEIGHT - (height + viewwindowy - ((height - viewheight) / 2)); - PolyTriangleDrawer::set_viewport(viewwindowx, SCREENHEIGHT - bottom - height, viewwidth, height, RenderTarget); + int bottom = SCREENHEIGHT - (height + viewwindowy - ((height - viewheight) / 2)); + PolyTriangleDrawer::set_viewport(viewwindowx, SCREENHEIGHT - bottom - height, viewwidth, height, RenderTarget); + } + else // Rendering to camera texture + { + PolyTriangleDrawer::set_viewport(0, 0, RenderTarget->GetWidth(), RenderTarget->GetHeight(), RenderTarget); + } } void RenderPolyScene::SetupPerspectiveMatrix() From 8bd92a2c482f7c8302421eea373a2ad35c4c5ae2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 23 Nov 2016 22:55:24 +0100 Subject: [PATCH 1272/1509] Fix interpolation bug in the affine texturing block --- .../fixedfunction/drawtrianglecodegen.cpp | 62 +++++++++++++------ .../fixedfunction/drawtrianglecodegen.h | 4 +- src/r_compiler/llvmdrawers.cpp | 2 +- 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index 3dca72544..d8a436101 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -242,15 +242,15 @@ void DrawTriangleCodegen::LoopBlockX() SSAFloat varyingBL = (startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL; SSAFloat varyingBR = (startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR; - SSAFloat pos = varyingTL; - SSAFloat stepPos = (varyingBL - varyingTL) * (1.0f / q); SSAFloat startStepX = (varyingTR - varyingTL) * (1.0f / q); - SSAFloat incrStepX = (varyingBR - varyingBL) * (1.0f / q) - startStepX; + SSAFloat endStepX = (varyingBR - varyingBL) * (1.0f / q); + SSAFloat incrStepX = (endStepX - startStepX) * (1.0f / q); + SSAFloat stepY = (varyingBL - varyingTL) * (1.0f / q); - varyingPos[i] = SSAInt(pos * SSAFloat((float)0x01000000), false); - varyingStepPos[i] = SSAInt(stepPos * SSAFloat((float)0x01000000), false); - varyingStartStepX[i] = SSAInt(startStepX * SSAFloat((float)0x01000000), false); - varyingIncrStepX[i] = SSAInt(incrStepX * SSAFloat((float)0x01000000), false); + varyingPos[i] = SSAInt(varyingTL * SSAFloat((float)0x01000000), false) << 8; + varyingStepY[i] = SSAInt(stepY * SSAFloat((float)0x01000000), false) << 8; + varyingStartStepX[i] = SSAInt(startStepX * SSAFloat((float)0x01000000), false) << 8; + varyingIncrStepX[i] = SSAInt(incrStepX * SSAFloat((float)0x01000000), false) << 8; } SSAFloat globVis = SSAFloat(1706.0f); @@ -314,18 +314,22 @@ void DrawTriangleCodegen::LoopFullBlock() { int pixelsize = truecolor ? 4 : 1; + SSAInt varyingLine[TriVertex::NumVarying]; + SSAInt varyingStepX[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varyingLine[i] = varyingPos[i]; + varyingStepX[i] = varyingStartStepX[i]; + } + for (int iy = 0; iy < q; iy++) { SSAUBytePtr buffer = dest[(x + iy * pitch) * pixelsize]; SSAIntPtr subsectorbuffer = subsectorGBuffer[x + iy * pitch]; SSAInt varying[TriVertex::NumVarying]; - SSAInt varyingStep[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) - { - varying[i] = (varyingPos[i] + varyingStepPos[i] * iy) << 8; - varyingStep[i] = (varyingStartStepX[i] + varyingIncrStepX[i] * iy) << 8; - } + varying[i] = varyingLine[i]; for (int ix = 0; ix < q; ix += 4) { @@ -356,7 +360,7 @@ void DrawTriangleCodegen::LoopFullBlock() } for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] = varying[i] + varyingStep[i]; + varying[i] = varying[i] + varyingStepX[i]; } buf.store_unaligned_vec16ub(SSAVec16ub(SSAVec8s(pixels[0], pixels[1]), SSAVec8s(pixels[2], pixels[3]))); @@ -385,7 +389,7 @@ void DrawTriangleCodegen::LoopFullBlock() } for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] = varying[i] + varyingStep[i]; + varying[i] = varying[i] + varyingStepX[i]; } buf.store_vec4ub(SSAVec4i(pixels[0], pixels[1], pixels[2], pixels[3])); @@ -394,6 +398,12 @@ void DrawTriangleCodegen::LoopFullBlock() if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) subsectorbuffer[ix].store_unaligned_vec4i(SSAVec4i(subsectorDepth)); } + + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varyingLine[i] = varyingLine[i] + varyingStepY[i]; + varyingStepX[i] = varyingStepX[i] + varyingIncrStepX[i]; + } } } @@ -413,6 +423,11 @@ void DrawTriangleCodegen::LoopPartialBlock() stack_iy.store(SSAInt(0)); stack_buffer.store(dest[x * pixelsize]); stack_subsectorbuffer.store(subsectorGBuffer[x]); + for (int i = 0; i < TriVertex::NumVarying; i++) + { + stack_varyingLine[i].store(varyingPos[i]); + stack_varyingStep[i].store(varyingStartStepX[i]); + } SSAForBlock loopy; SSAInt iy = stack_iy.load(); @@ -421,14 +436,17 @@ void DrawTriangleCodegen::LoopPartialBlock() SSAInt CY1 = stack_CY1.load(); SSAInt CY2 = stack_CY2.load(); SSAInt CY3 = stack_CY3.load(); + SSAInt varyingLine[TriVertex::NumVarying]; + SSAInt varyingStep[TriVertex::NumVarying]; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + varyingLine[i] = stack_varyingLine[i].load(); + varyingStep[i] = stack_varyingStep[i].load(); + } loopy.loop_block(iy < SSAInt(q), q); { - SSAInt varyingStep[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) - { - stack_varying[i].store((varyingPos[i] + varyingStepPos[i] * iy) << 8); - varyingStep[i] = (varyingStartStepX[i] + varyingIncrStepX[i] * iy) << 8; - } + stack_varying[i].store(varyingLine[i]); stack_CX1.store(CY1); stack_CX2.store(CY2); @@ -495,6 +513,12 @@ void DrawTriangleCodegen::LoopPartialBlock() } loopx.end_block(); + for (int i = 0; i < TriVertex::NumVarying; i++) + { + stack_varyingLine[i].store(varyingLine[i] + varyingStepY[i]); + stack_varyingStep[i].store(varyingStep[i] + varyingIncrStepX[i]); + } + stack_CY1.store(CY1 + FDX12); stack_CY2.store(CY2 + FDX23); stack_CY3.store(CY3 + FDX31); diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.h b/src/r_compiler/fixedfunction/drawtrianglecodegen.h index 74358f99a..bb6df455e 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.h +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.h @@ -79,6 +79,8 @@ private: SSAStack stack_buffer; SSAStack stack_subsectorbuffer; SSAStack stack_iy, stack_ix; + SSAStack stack_varyingLine[TriVertex::NumVarying]; + SSAStack stack_varyingStep[TriVertex::NumVarying]; SSAStack stack_varying[TriVertex::NumVarying]; SSAStack stack_CY1, stack_CY2, stack_CY3; SSAStack stack_CX1, stack_CX2, stack_CX3; @@ -137,7 +139,7 @@ private: SSAInt currentlight; SSAUBytePtr currentcolormap; SSAInt varyingPos[TriVertex::NumVarying]; - SSAInt varyingStepPos[TriVertex::NumVarying]; + SSAInt varyingStepY[TriVertex::NumVarying]; SSAInt varyingStartStepX[TriVertex::NumVarying]; SSAInt varyingIncrStepX[TriVertex::NumVarying]; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 6745af8e4..3abf732c0 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -127,7 +127,7 @@ LLVMDrawers *LLVMDrawers::Instance() LLVMDrawersImpl::LLVMDrawersImpl() { - int version = 5; // Increment this number if the drawer codegen is modified (forces recreation of the module). + int version = 6; // Increment this number if the drawer codegen is modified (forces recreation of the module). std::string targetCPU = mProgram.GetTargetCPU(); bool loaded = mProgram.LoadCachedModule(version, targetCPU); if (!loaded) From 80a5f81f9a0dae20ea54d4a69c091ca20c7351b7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 23 Nov 2016 23:29:53 +0100 Subject: [PATCH 1273/1509] Fix typo affecting walls on sloped floors --- src/r_poly_wall.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index 63f35ccd5..a4dd62e4b 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -94,7 +94,7 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, secto if ((bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && line->sidedef) { - wall.SetCoords(line->v1->fPos(), line->v2->fPos(), bottomceilz1, bottomfloorz2, bottomceilz2, bottomfloorz2); + wall.SetCoords(line->v1->fPos(), line->v2->fPos(), bottomceilz1, bottomfloorz1, bottomceilz2, bottomfloorz2); wall.TopZ = bottomceilz1; wall.BottomZ = bottomfloorz2; wall.UnpeggedCeil = topceilz1; From 0361e912cbe820965bf02c7c4773b2fc39f2c9a8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 24 Nov 2016 01:01:02 +0100 Subject: [PATCH 1274/1509] Minor bug fix --- src/r_poly_cull.cpp | 22 ++++++++++++---------- src/r_poly_cull.h | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/r_poly_cull.cpp b/src/r_poly_cull.cpp index 79b8d151d..ff349690c 100644 --- a/src/r_poly_cull.cpp +++ b/src/r_poly_cull.cpp @@ -35,18 +35,12 @@ void PolyCull::CullScene(const TriMatrix &worldToClip) frustumPlanes = FrustumPlanes(worldToClip); // Cull front to back + MaxCeilingHeight = 0.0; + MinFloorHeight = 0.0; if (numnodes == 0) - { - PvsSectors.push_back(subsectors); - MaxCeilingHeight = subsectors->sector->ceilingplane.Zat0(); - MinFloorHeight = subsectors->sector->floorplane.Zat0(); - } + CullSubsector(subsectors); else - { - MaxCeilingHeight = 0.0; - MinFloorHeight = 0.0; CullNode(nodes + numnodes - 1); // The head node is the last node output. - } ClearSolidSegments(); } @@ -65,16 +59,24 @@ void PolyCull::CullNode(void *node) // Possibly divide back space (away from the viewer). side ^= 1; + if (!CheckBBox(bsp->bbox[side])) return; node = bsp->children[side]; } - // Mark that we need to render this subsector_t *sub = (subsector_t *)((BYTE *)node - 1); + CullSubsector(sub); +} + +void PolyCull::CullSubsector(subsector_t *sub) +{ + // Update sky heights for the scene MaxCeilingHeight = MAX(MaxCeilingHeight, sub->sector->ceilingplane.Zat0()); MinFloorHeight = MIN(MinFloorHeight, sub->sector->floorplane.Zat0()); + + // Mark that we need to render this PvsSectors.push_back(sub); // Update culling info for further bsp clipping diff --git a/src/r_poly_cull.h b/src/r_poly_cull.h index a79355f68..e011ef583 100644 --- a/src/r_poly_cull.h +++ b/src/r_poly_cull.h @@ -46,6 +46,7 @@ private: }; void CullNode(void *node); + void CullSubsector(subsector_t *sub); int PointOnSide(const DVector2 &pos, const node_t *node); // Checks BSP node/subtree bounding box. From 2316658dfc35a66a662782a992ba7157f9d1101f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 24 Nov 2016 02:11:35 +0100 Subject: [PATCH 1275/1509] Fix kdizd blinking issue because the vertex buffer was too small --- src/r_poly.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index d51d01f9b..964ec2ae7 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -278,7 +278,7 @@ namespace TriVertex *PolyVertexBuffer::GetVertices(int count) { - enum { VertexBufferSize = 16 * 1024 }; + enum { VertexBufferSize = 64 * 1024 }; static TriVertex Vertex[VertexBufferSize]; if (NextBufferVertex + count > VertexBufferSize) From 47aaf781c6c3321c8a8bf74fc8213d8bd4fcfb37 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 24 Nov 2016 05:51:37 +0100 Subject: [PATCH 1276/1509] Split RenderPolyScene into two to allow rendering from multiple viewpoints --- src/CMakeLists.txt | 1 + src/r_poly.cpp | 196 ++----------------------------------- src/r_poly.h | 69 +------------ src/r_poly_plane.cpp | 3 +- src/r_poly_portal.cpp | 210 ++++++++++++++++++++++++++++++++++++++++ src/r_poly_portal.h | 105 ++++++++++++++++++++ src/r_poly_sky.cpp | 4 +- src/r_poly_triangle.cpp | 24 +++++ src/r_poly_triangle.h | 7 ++ 9 files changed, 364 insertions(+), 255 deletions(-) create mode 100644 src/r_poly_portal.cpp create mode 100644 src/r_poly_portal.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e53a2dbe9..f1dcb88c1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1061,6 +1061,7 @@ set( NOT_COMPILED_SOURCE_FILES set( FASTMATH_PCH_SOURCES r_swrenderer.cpp r_poly.cpp + r_poly_portal.cpp r_poly_cull.cpp r_poly_decal.cpp r_poly_particle.cpp diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 964ec2ae7..171d7e0ad 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -28,21 +28,26 @@ #include "r_poly.h" #include "gl/data/gl_data.h" -CVAR(Bool, r_debug_cull, 0, 0) EXTERN_CVAR(Int, screenblocks) void InitGLRMapinfoData(); ///////////////////////////////////////////////////////////////////////////// +RenderPolyScene *RenderPolyScene::Instance() +{ + static RenderPolyScene scene; + return &scene; +} + void RenderPolyScene::Render() { ClearBuffers(); SetSceneViewport(); SetupPerspectiveMatrix(); - Cull.CullScene(WorldToClip); - RenderSectors(); - skydome.Render(WorldToClip); - RenderTranslucent(); + MainPortal.SetViewpoint(WorldToClip, 0); + MainPortal.Render(); + Skydome.Render(WorldToClip); + MainPortal.RenderTranslucent(); PlayerSprites.Render(); DrawerCommandQueue::WaitForWorkers(); @@ -56,13 +61,8 @@ void RenderPolyScene::RenderRemainingPlayerSprites() void RenderPolyScene::ClearBuffers() { PolyVertexBuffer::Clear(); - SectorSpriteRanges.clear(); - SectorSpriteRanges.resize(numsectors); - SortedSprites.clear(); - TranslucentObjects.clear(); PolyStencilBuffer::Instance()->Clear(RenderTarget->GetWidth(), RenderTarget->GetHeight(), 0); PolySubsectorGBuffer::Instance()->Resize(RenderTarget->GetPitch(), RenderTarget->GetHeight()); - NextSubsectorDepth = 0; } void RenderPolyScene::SetSceneViewport() @@ -116,179 +116,3 @@ void RenderPolyScene::SetupPerspectiveMatrix() WorldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; } - -void RenderPolyScene::RenderSectors() -{ - if (r_debug_cull) - { - for (auto it = Cull.PvsSectors.rbegin(); it != Cull.PvsSectors.rend(); ++it) - RenderSubsector(*it); - } - else - { - for (auto it = Cull.PvsSectors.begin(); it != Cull.PvsSectors.end(); ++it) - RenderSubsector(*it); - } -} - -void RenderPolyScene::RenderSubsector(subsector_t *sub) -{ - sector_t *frontsector = sub->sector; - frontsector->MoreFlags |= SECF_DRAWN; - - uint32_t subsectorDepth = NextSubsectorDepth++; - - if (sub->sector->CenterFloor() != sub->sector->CenterCeiling()) - { - RenderPolyPlane::RenderPlanes(WorldToClip, sub, subsectorDepth, Cull.MaxCeilingHeight, Cull.MinFloorHeight); - } - - for (uint32_t i = 0; i < sub->numlines; i++) - { - seg_t *line = &sub->firstline[i]; - if (line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) - { - RenderLine(sub, line, frontsector, subsectorDepth); - } - } - - bool mainBSP = ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors); - if (mainBSP) - { - int subsectorIndex = (int)(sub - subsectors); - for (int i = ParticlesInSubsec[subsectorIndex]; i != NO_PARTICLE; i = Particles[i].snext) - { - particle_t *particle = Particles + i; - TranslucentObjects.push_back({ particle, sub, subsectorDepth }); - } - } - - SpriteRange sprites = GetSpritesForSector(sub->sector); - for (int i = 0; i < sprites.Count; i++) - { - AActor *thing = SortedSprites[sprites.Start + i].Thing; - TranslucentObjects.push_back({ thing, sub, subsectorDepth }); - } - - TranslucentObjects.insert(TranslucentObjects.end(), SubsectorTranslucentWalls.begin(), SubsectorTranslucentWalls.end()); - SubsectorTranslucentWalls.clear(); -} - -SpriteRange RenderPolyScene::GetSpritesForSector(sector_t *sector) -{ - if (SectorSpriteRanges.size() < sector->sectornum || sector->sectornum < 0) - return SpriteRange(); - - auto &range = SectorSpriteRanges[sector->sectornum]; - if (range.Start == -1) - { - range.Start = (int)SortedSprites.size(); - range.Count = 0; - for (AActor *thing = sector->thinglist; thing != nullptr; thing = thing->snext) - { - SortedSprites.push_back({ thing, (thing->Pos() - ViewPos).LengthSquared() }); - range.Count++; - } - std::stable_sort(SortedSprites.begin() + range.Start, SortedSprites.begin() + range.Start + range.Count); - } - return range; -} - -void RenderPolyScene::RenderLine(subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth) -{ - // Reject lines not facing viewer - DVector2 pt1 = line->v1->fPos() - ViewPos; - DVector2 pt2 = line->v2->fPos() - ViewPos; - if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0) - return; - - // Cull wall if not visible - int sx1, sx2; - bool hasSegmentRange = Cull.GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2); - if (!hasSegmentRange || Cull.IsSegmentCulled(sx1, sx2)) - return; - - // Tell automap we saw this - if (!r_dontmaplines && line->linedef) - { - line->linedef->flags |= ML_MAPPED; - sub->flags |= SSECF_DRAWN; - } - - // Render 3D floor sides - if (line->backsector && frontsector->e && line->backsector->e->XFloor.ffloors.Size()) - { - for (unsigned int i = 0; i < line->backsector->e->XFloor.ffloors.Size(); i++) - { - F3DFloor *fakeFloor = line->backsector->e->XFloor.ffloors[i]; - if (!(fakeFloor->flags & FF_EXISTS)) continue; - if (!(fakeFloor->flags & FF_RENDERPLANES)) continue; - if (!fakeFloor->model) continue; - RenderPolyWall::Render3DFloorLine(WorldToClip, line, frontsector, subsectorDepth, fakeFloor, SubsectorTranslucentWalls); - } - } - - // Render wall, and update culling info if its an occlusion blocker - if (RenderPolyWall::RenderLine(WorldToClip, line, frontsector, subsectorDepth, SubsectorTranslucentWalls)) - { - if (hasSegmentRange) - Cull.MarkSegmentCulled(sx1, sx2); - } -} - -void RenderPolyScene::RenderTranslucent() -{ - for (auto it = TranslucentObjects.rbegin(); it != TranslucentObjects.rend(); ++it) - { - auto &obj = *it; - if (obj.particle) - { - RenderPolyParticle spr; - spr.Render(WorldToClip, obj.particle, obj.sub, obj.subsectorDepth); - } - else if (!obj.thing) - { - obj.wall.Render(WorldToClip); - } - else if ((obj.thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) - { - RenderPolyWallSprite wallspr; - wallspr.Render(WorldToClip, obj.thing, obj.sub, obj.subsectorDepth); - } - else - { - RenderPolySprite spr; - spr.Render(WorldToClip, obj.thing, obj.sub, obj.subsectorDepth); - } - } -} - -RenderPolyScene *RenderPolyScene::Instance() -{ - static RenderPolyScene scene; - return &scene; -} - -///////////////////////////////////////////////////////////////////////////// - -namespace -{ - int NextBufferVertex = 0; -} - -TriVertex *PolyVertexBuffer::GetVertices(int count) -{ - enum { VertexBufferSize = 64 * 1024 }; - static TriVertex Vertex[VertexBufferSize]; - - if (NextBufferVertex + count > VertexBufferSize) - return nullptr; - TriVertex *v = Vertex + NextBufferVertex; - NextBufferVertex += count; - return v; -} - -void PolyVertexBuffer::Clear() -{ - NextBufferVertex = 0; -} diff --git a/src/r_poly.h b/src/r_poly.h index 4be49f532..99e86307b 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -29,51 +29,9 @@ #include "doomdata.h" #include "r_utility.h" #include "r_main.h" -#include "r_poly_triangle.h" -#include "r_poly_intersection.h" -#include "r_poly_wall.h" -#include "r_poly_sprite.h" -#include "r_poly_wallsprite.h" +#include "r_poly_portal.h" #include "r_poly_playersprite.h" -#include "r_poly_particle.h" -#include "r_poly_plane.h" #include "r_poly_sky.h" -#include "r_poly_cull.h" - -// Used for sorting things by distance to the camera -class PolySortedSprite -{ -public: - PolySortedSprite(AActor *thing, double distanceSquared) : Thing(thing), DistanceSquared(distanceSquared) { } - bool operator<(const PolySortedSprite &other) const { return DistanceSquared < other.DistanceSquared; } - - AActor *Thing; - double DistanceSquared; -}; - -class PolyTranslucentObject -{ -public: - PolyTranslucentObject(particle_t *particle, subsector_t *sub, uint32_t subsectorDepth) : particle(particle), sub(sub), subsectorDepth(subsectorDepth) { } - PolyTranslucentObject(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) : thing(thing), sub(sub), subsectorDepth(subsectorDepth) { } - PolyTranslucentObject(RenderPolyWall wall) : wall(wall) { } - - particle_t *particle = nullptr; - AActor *thing = nullptr; - subsector_t *sub = nullptr; - uint32_t subsectorDepth = 0; - - RenderPolyWall wall; -}; - -class SpriteRange -{ -public: - SpriteRange() = default; - SpriteRange(int start, int count) : Start(start), Count(count) { } - int Start = -1; - int Count = 0; -}; // Renders a scene class RenderPolyScene @@ -82,36 +40,15 @@ public: void Render(); void RenderRemainingPlayerSprites(); - static const uint32_t SkySubsectorDepth = 0x7fffffff; - static RenderPolyScene *Instance(); private: void ClearBuffers(); void SetSceneViewport(); void SetupPerspectiveMatrix(); - void RenderSectors(); - void RenderSubsector(subsector_t *sub); - void RenderLine(subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); - - void RenderTranslucent(); - SpriteRange GetSpritesForSector(sector_t *sector); TriMatrix WorldToClip; - PolyCull Cull; - uint32_t NextSubsectorDepth = 0; - std::vector SectorSpriteRanges; - std::vector SortedSprites; - std::vector TranslucentObjects; - std::vector SubsectorTranslucentWalls; - - PolySkyDome skydome; + RenderPolyPortal MainPortal; + PolySkyDome Skydome; RenderPolyPlayerSprites PlayerSprites; }; - -class PolyVertexBuffer -{ -public: - static TriVertex *GetVertices(int count); - static void Clear(); -}; diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index a64dfaaf5..e68487e17 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -26,6 +26,7 @@ #include "sbar.h" #include "r_data/r_translate.h" #include "r_poly_plane.h" +#include "r_poly_portal.h" #include "r_poly.h" #include "r_sky.h" // for skyflatnum @@ -200,7 +201,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin if (fixedlightlev >= 0 || fixedcolormap) uniforms.light = 256; uniforms.flags = 0; - uniforms.subsectorDepth = isSky ? RenderPolyScene::SkySubsectorDepth : subsectorDepth; + uniforms.subsectorDepth = isSky ? RenderPolyPortal::SkySubsectorDepth : subsectorDepth; TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); if (!vertices) diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp new file mode 100644 index 000000000..79468032b --- /dev/null +++ b/src/r_poly_portal.cpp @@ -0,0 +1,210 @@ +/* +** Polygon Doom software renderer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "sbar.h" +#include "r_data/r_translate.h" +#include "r_poly_portal.h" +#include "gl/data/gl_data.h" + +CVAR(Bool, r_debug_cull, 0, 0) + +///////////////////////////////////////////////////////////////////////////// + +void RenderPolyPortal::SetViewpoint(const TriMatrix &worldToClip, uint32_t stencilValue) +{ + WorldToClip = worldToClip; + StencilValue = stencilValue; +} + +void RenderPolyPortal::Render() +{ + ClearBuffers(); + Cull.CullScene(WorldToClip); + RenderSectors(); + for (auto &portal : Portals) + portal->Render(); +} + +void RenderPolyPortal::ClearBuffers() +{ + SectorSpriteRanges.clear(); + SectorSpriteRanges.resize(numsectors); + SortedSprites.clear(); + TranslucentObjects.clear(); + Portals.clear(); + NextSubsectorDepth = 0; +} + +void RenderPolyPortal::RenderSectors() +{ + if (r_debug_cull) + { + for (auto it = Cull.PvsSectors.rbegin(); it != Cull.PvsSectors.rend(); ++it) + RenderSubsector(*it); + } + else + { + for (auto it = Cull.PvsSectors.begin(); it != Cull.PvsSectors.end(); ++it) + RenderSubsector(*it); + } +} + +void RenderPolyPortal::RenderSubsector(subsector_t *sub) +{ + sector_t *frontsector = sub->sector; + frontsector->MoreFlags |= SECF_DRAWN; + + uint32_t subsectorDepth = NextSubsectorDepth++; + + if (sub->sector->CenterFloor() != sub->sector->CenterCeiling()) + { + RenderPolyPlane::RenderPlanes(WorldToClip, sub, subsectorDepth, Cull.MaxCeilingHeight, Cull.MinFloorHeight); + + FSectorPortal *ceilingPortal = frontsector->ValidatePortal(sector_t::ceiling); + FSectorPortal *floorPortal = frontsector->ValidatePortal(sector_t::floor); + } + + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + if (line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) + { + RenderLine(sub, line, frontsector, subsectorDepth); + } + } + + bool mainBSP = ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors); + if (mainBSP) + { + int subsectorIndex = (int)(sub - subsectors); + for (int i = ParticlesInSubsec[subsectorIndex]; i != NO_PARTICLE; i = Particles[i].snext) + { + particle_t *particle = Particles + i; + TranslucentObjects.push_back({ particle, sub, subsectorDepth }); + } + } + + SpriteRange sprites = GetSpritesForSector(sub->sector); + for (int i = 0; i < sprites.Count; i++) + { + AActor *thing = SortedSprites[sprites.Start + i].Thing; + TranslucentObjects.push_back({ thing, sub, subsectorDepth }); + } + + TranslucentObjects.insert(TranslucentObjects.end(), SubsectorTranslucentWalls.begin(), SubsectorTranslucentWalls.end()); + SubsectorTranslucentWalls.clear(); +} + +SpriteRange RenderPolyPortal::GetSpritesForSector(sector_t *sector) +{ + if (SectorSpriteRanges.size() < sector->sectornum || sector->sectornum < 0) + return SpriteRange(); + + auto &range = SectorSpriteRanges[sector->sectornum]; + if (range.Start == -1) + { + range.Start = (int)SortedSprites.size(); + range.Count = 0; + for (AActor *thing = sector->thinglist; thing != nullptr; thing = thing->snext) + { + SortedSprites.push_back({ thing, (thing->Pos() - ViewPos).LengthSquared() }); + range.Count++; + } + std::stable_sort(SortedSprites.begin() + range.Start, SortedSprites.begin() + range.Start + range.Count); + } + return range; +} + +void RenderPolyPortal::RenderLine(subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth) +{ + // Reject lines not facing viewer + DVector2 pt1 = line->v1->fPos() - ViewPos; + DVector2 pt2 = line->v2->fPos() - ViewPos; + if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0) + return; + + // Cull wall if not visible + int sx1, sx2; + bool hasSegmentRange = Cull.GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2); + if (!hasSegmentRange || Cull.IsSegmentCulled(sx1, sx2)) + return; + + // Tell automap we saw this + if (!r_dontmaplines && line->linedef) + { + line->linedef->flags |= ML_MAPPED; + sub->flags |= SSECF_DRAWN; + } + + // Render 3D floor sides + if (line->backsector && frontsector->e && line->backsector->e->XFloor.ffloors.Size()) + { + for (unsigned int i = 0; i < line->backsector->e->XFloor.ffloors.Size(); i++) + { + F3DFloor *fakeFloor = line->backsector->e->XFloor.ffloors[i]; + if (!(fakeFloor->flags & FF_EXISTS)) continue; + if (!(fakeFloor->flags & FF_RENDERPLANES)) continue; + if (!fakeFloor->model) continue; + RenderPolyWall::Render3DFloorLine(WorldToClip, line, frontsector, subsectorDepth, fakeFloor, SubsectorTranslucentWalls); + } + } + + // Render wall, and update culling info if its an occlusion blocker + if (RenderPolyWall::RenderLine(WorldToClip, line, frontsector, subsectorDepth, SubsectorTranslucentWalls)) + { + if (hasSegmentRange) + Cull.MarkSegmentCulled(sx1, sx2); + } +} + +void RenderPolyPortal::RenderTranslucent() +{ + for (auto it = Portals.rbegin(); it != Portals.rend(); ++it) + (*it)->RenderTranslucent(); + + for (auto it = TranslucentObjects.rbegin(); it != TranslucentObjects.rend(); ++it) + { + auto &obj = *it; + if (obj.particle) + { + RenderPolyParticle spr; + spr.Render(WorldToClip, obj.particle, obj.sub, obj.subsectorDepth); + } + else if (!obj.thing) + { + obj.wall.Render(WorldToClip); + } + else if ((obj.thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) + { + RenderPolyWallSprite wallspr; + wallspr.Render(WorldToClip, obj.thing, obj.sub, obj.subsectorDepth); + } + else + { + RenderPolySprite spr; + spr.Render(WorldToClip, obj.thing, obj.sub, obj.subsectorDepth); + } + } +} diff --git a/src/r_poly_portal.h b/src/r_poly_portal.h new file mode 100644 index 000000000..364f2dcfb --- /dev/null +++ b/src/r_poly_portal.h @@ -0,0 +1,105 @@ +/* +** Polygon Doom software renderer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +#include +#include +#include +#include +#include "doomdata.h" +#include "r_utility.h" +#include "r_main.h" +#include "r_poly_triangle.h" +#include "r_poly_intersection.h" +#include "r_poly_wall.h" +#include "r_poly_sprite.h" +#include "r_poly_wallsprite.h" +#include "r_poly_playersprite.h" +#include "r_poly_particle.h" +#include "r_poly_plane.h" +#include "r_poly_cull.h" + +// Used for sorting things by distance to the camera +class PolySortedSprite +{ +public: + PolySortedSprite(AActor *thing, double distanceSquared) : Thing(thing), DistanceSquared(distanceSquared) { } + bool operator<(const PolySortedSprite &other) const { return DistanceSquared < other.DistanceSquared; } + + AActor *Thing; + double DistanceSquared; +}; + +class PolyTranslucentObject +{ +public: + PolyTranslucentObject(particle_t *particle, subsector_t *sub, uint32_t subsectorDepth) : particle(particle), sub(sub), subsectorDepth(subsectorDepth) { } + PolyTranslucentObject(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) : thing(thing), sub(sub), subsectorDepth(subsectorDepth) { } + PolyTranslucentObject(RenderPolyWall wall) : wall(wall) { } + + particle_t *particle = nullptr; + AActor *thing = nullptr; + subsector_t *sub = nullptr; + uint32_t subsectorDepth = 0; + + RenderPolyWall wall; +}; + +class SpriteRange +{ +public: + SpriteRange() = default; + SpriteRange(int start, int count) : Start(start), Count(count) { } + int Start = -1; + int Count = 0; +}; + +// Renders everything from a specific viewpoint +class RenderPolyPortal +{ +public: + void SetViewpoint(const TriMatrix &worldToClip, uint32_t stencilValue); + void Render(); + void RenderTranslucent(); + + static const uint32_t SkySubsectorDepth = 0x7fffffff; + +private: + void ClearBuffers(); + void RenderSectors(); + void RenderSubsector(subsector_t *sub); + void RenderLine(subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); + + SpriteRange GetSpritesForSector(sector_t *sector); + + TriMatrix WorldToClip; + uint32_t StencilValue = 0; + PolyCull Cull; + uint32_t NextSubsectorDepth = 0; + std::vector SectorSpriteRanges; + std::vector SortedSprites; + std::vector TranslucentObjects; + std::vector SubsectorTranslucentWalls; + + std::vector> Portals; +}; diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp index a8e7b23d6..6fc817041 100644 --- a/src/r_poly_sky.cpp +++ b/src/r_poly_sky.cpp @@ -25,7 +25,7 @@ #include "sbar.h" #include "r_data/r_translate.h" #include "r_poly_sky.h" -#include "r_poly.h" +#include "r_poly_portal.h" #include "r_sky.h" // for skyflatnum PolySkyDome::PolySkyDome() @@ -53,7 +53,7 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) TriUniforms uniforms; uniforms.light = 256; uniforms.flags = 0; - uniforms.subsectorDepth = RenderPolyScene::SkySubsectorDepth; + uniforms.subsectorDepth = RenderPolyPortal::SkySubsectorDepth; int rc = mRows + 1; diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 367d3df40..9a389777a 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -523,3 +523,27 @@ TriVertex TriMatrix::operator*(TriVertex v) const v.w = vw; return v; } + +///////////////////////////////////////////////////////////////////////////// + +namespace +{ + int NextBufferVertex = 0; +} + +TriVertex *PolyVertexBuffer::GetVertices(int count) +{ + enum { VertexBufferSize = 256 * 1024 }; + static TriVertex Vertex[VertexBufferSize]; + + if (NextBufferVertex + count > VertexBufferSize) + return nullptr; + TriVertex *v = Vertex + NextBufferVertex; + NextBufferVertex += count; + return v; +} + +void PolyVertexBuffer::Clear() +{ + NextBufferVertex = 0; +} diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 7d58ed5ed..8fef11e99 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -220,3 +220,10 @@ private: TriDrawVariant variant; TriBlendMode blendmode; }; + +class PolyVertexBuffer +{ +public: + static TriVertex *GetVertices(int count); + static void Clear(); +}; From 33958ca5b2fbd5ed1e721d5f57519fc957e3ad07 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 24 Nov 2016 07:37:15 +0100 Subject: [PATCH 1277/1509] Add vid_vsync support to Linux target --- src/posix/sdl/sdlglvideo.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index d8c00f236..173a84d80 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -442,6 +442,16 @@ void SDLGLFB::SetVSync( bool vsync ) #if defined (__APPLE__) const GLint value = vsync ? 1 : 0; CGLSetParameter( CGLGetCurrentContext(), kCGLCPSwapInterval, &value ); +#else + if (vsync) + { + if (SDL_GL_SetSwapInterval(-1) == -1) + SDL_GL_SetSwapInterval(1); + } + else + { + SDL_GL_SetSwapInterval(0); + } #endif } From cff72fb07251851928253da9943b69130edb7015 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 24 Nov 2016 08:23:50 +0100 Subject: [PATCH 1278/1509] Add stencil value to decal, particle, plane, port, sky, sprite, wall and wallsprite classes --- src/r_poly_decal.cpp | 10 +++++----- src/r_poly_decal.h | 4 ++-- src/r_poly_particle.cpp | 6 +++--- src/r_poly_particle.h | 2 +- src/r_poly_plane.cpp | 22 +++++++++++----------- src/r_poly_plane.h | 6 +++--- src/r_poly_portal.cpp | 12 ++++++------ src/r_poly_sky.cpp | 2 +- src/r_poly_sprite.cpp | 6 +++--- src/r_poly_sprite.h | 2 +- src/r_poly_wall.cpp | 10 +++++----- src/r_poly_wall.h | 5 +++-- src/r_poly_wallsprite.cpp | 6 +++--- src/r_poly_wallsprite.h | 2 +- 14 files changed, 48 insertions(+), 47 deletions(-) diff --git a/src/r_poly_decal.cpp b/src/r_poly_decal.cpp index 206eb9862..ded64a095 100644 --- a/src/r_poly_decal.cpp +++ b/src/r_poly_decal.cpp @@ -29,7 +29,7 @@ #include "r_poly.h" #include "a_sharedglobal.h" -void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const seg_t *line, uint32_t subsectorDepth) +void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue) { if (line->linedef == nullptr && line->sidedef == nullptr) return; @@ -37,11 +37,11 @@ void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const seg_t for (DBaseDecal *decal = line->sidedef->AttachedDecals; decal != nullptr; decal = decal->WallNext) { RenderPolyDecal render; - render.Render(worldToClip, decal, line, subsectorDepth); + render.Render(worldToClip, decal, line, subsectorDepth, stencilValue); } } -void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth) +void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue) { if (decal->RenderFlags & RF_INVISIBLE || !viewactive || !decal->PicNum.isValid()) return; @@ -163,8 +163,8 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co args.vcount = 4; args.mode = TriangleDrawMode::Fan; args.ccw = true; - args.stenciltestvalue = 0; - args.stencilwritevalue = 1; + args.stenciltestvalue = stencilValue; + args.stencilwritevalue = stencilValue; //mode = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Shaded); } diff --git a/src/r_poly_decal.h b/src/r_poly_decal.h index 61087a773..c836a0cd7 100644 --- a/src/r_poly_decal.h +++ b/src/r_poly_decal.h @@ -27,8 +27,8 @@ class RenderPolyDecal { public: - static void RenderWallDecals(const TriMatrix &worldToClip, const seg_t *line, uint32_t subsectorDepth); + static void RenderWallDecals(const TriMatrix &worldToClip, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue); private: - void Render(const TriMatrix &worldToClip, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth); + void Render(const TriMatrix &worldToClip, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue); }; diff --git a/src/r_poly_particle.cpp b/src/r_poly_particle.cpp index 9b1dbaf1c..e69803e1e 100644 --- a/src/r_poly_particle.cpp +++ b/src/r_poly_particle.cpp @@ -28,7 +28,7 @@ #include "r_poly_particle.h" #include "r_poly.h" -void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth) +void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) { DVector3 pos = particle->Pos; double psize = particle->size / 8.0; @@ -102,8 +102,8 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *partic args.vcount = 4; args.mode = TriangleDrawMode::Fan; args.ccw = true; - args.stenciltestvalue = 0; - args.stencilwritevalue = 1; + args.stenciltestvalue = stencilValue; + args.stencilwritevalue = stencilValue; args.SetColormap(sub->sector->ColorMap); PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector, TriBlendMode::AlphaBlend); } diff --git a/src/r_poly_particle.h b/src/r_poly_particle.h index f4218a310..3fbb2d2ab 100644 --- a/src/r_poly_particle.h +++ b/src/r_poly_particle.h @@ -28,5 +28,5 @@ class RenderPolyParticle { public: - void Render(const TriMatrix &worldToClip, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth); + void Render(const TriMatrix &worldToClip, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); }; diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index e68487e17..68a56c69b 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -32,7 +32,7 @@ EXTERN_CVAR(Int, r_3dfloors) -void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, double skyCeilingHeight, double skyFloorHeight) +void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight) { RenderPolyPlane plane; @@ -58,7 +58,7 @@ void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, subsector_t *su double fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->centerspot); if (fakeHeight < ViewPos.Z && fakeHeight > frontsector->floorplane.ZatPoint(frontsector->centerspot)) { - plane.Render3DFloor(worldToClip, sub, subsectorDepth, false, fakeFloor); + plane.Render3DFloor(worldToClip, sub, subsectorDepth, stencilValue, false, fakeFloor); } } @@ -79,16 +79,16 @@ void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, subsector_t *su double fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot); if (fakeHeight > ViewPos.Z && fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->centerspot)) { - plane.Render3DFloor(worldToClip, sub, subsectorDepth, true, fakeFloor); + plane.Render3DFloor(worldToClip, sub, subsectorDepth, stencilValue, true, fakeFloor); } } } - plane.Render(worldToClip, sub, subsectorDepth, true, skyCeilingHeight); - plane.Render(worldToClip, sub, subsectorDepth, false, skyFloorHeight); + plane.Render(worldToClip, sub, subsectorDepth, stencilValue, true, skyCeilingHeight); + plane.Render(worldToClip, sub, subsectorDepth, stencilValue, false, skyFloorHeight); } -void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, bool ceiling, F3DFloor *fakeFloor) +void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakeFloor) { FTextureID picnum = ceiling ? *fakeFloor->bottom.texture : *fakeFloor->top.texture; FTexture *tex = TexMan(picnum); @@ -138,15 +138,15 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *s args.vcount = sub->numlines; args.mode = TriangleDrawMode::Fan; args.ccw = true; - args.stenciltestvalue = 0; - args.stencilwritevalue = 1; + args.stenciltestvalue = stencilValue; + args.stencilwritevalue = stencilValue + 1; args.SetTexture(tex); args.SetColormap(sub->sector->ColorMap); PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy); PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); } -void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, bool ceiling, double skyHeight) +void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight) { sector_t *fakesector = sub->sector->heightsec; if (fakesector && (fakesector == sub->sector || (fakesector->MoreFlags & SECF_IGNOREHEIGHTSEC) == SECF_IGNOREHEIGHTSEC)) @@ -231,8 +231,8 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin args.vcount = sub->numlines; args.mode = TriangleDrawMode::Fan; args.ccw = ccw; - args.stenciltestvalue = 0; - args.stencilwritevalue = 1; + args.stenciltestvalue = stencilValue; + args.stencilwritevalue = stencilValue + 1; args.SetColormap(frontsector->ColorMap); if (!isSky) diff --git a/src/r_poly_plane.h b/src/r_poly_plane.h index fa786ead9..d36bb70dc 100644 --- a/src/r_poly_plane.h +++ b/src/r_poly_plane.h @@ -27,10 +27,10 @@ class RenderPolyPlane { public: - static void RenderPlanes(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, double skyCeilingHeight, double skyFloorHeight); + static void RenderPlanes(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight); private: - void Render3DFloor(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, bool ceiling, F3DFloor *fakefloor); - void Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, bool ceiling, double skyHeight); + void Render3DFloor(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakefloor); + void Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight); TriVertex PlaneVertex(vertex_t *v1, double height); }; diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 79468032b..6b37d6424 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -80,7 +80,7 @@ void RenderPolyPortal::RenderSubsector(subsector_t *sub) if (sub->sector->CenterFloor() != sub->sector->CenterCeiling()) { - RenderPolyPlane::RenderPlanes(WorldToClip, sub, subsectorDepth, Cull.MaxCeilingHeight, Cull.MinFloorHeight); + RenderPolyPlane::RenderPlanes(WorldToClip, sub, subsectorDepth, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight); FSectorPortal *ceilingPortal = frontsector->ValidatePortal(sector_t::ceiling); FSectorPortal *floorPortal = frontsector->ValidatePortal(sector_t::floor); @@ -167,12 +167,12 @@ void RenderPolyPortal::RenderLine(subsector_t *sub, seg_t *line, sector_t *front if (!(fakeFloor->flags & FF_EXISTS)) continue; if (!(fakeFloor->flags & FF_RENDERPLANES)) continue; if (!fakeFloor->model) continue; - RenderPolyWall::Render3DFloorLine(WorldToClip, line, frontsector, subsectorDepth, fakeFloor, SubsectorTranslucentWalls); + RenderPolyWall::Render3DFloorLine(WorldToClip, line, frontsector, subsectorDepth, StencilValue, fakeFloor, SubsectorTranslucentWalls); } } // Render wall, and update culling info if its an occlusion blocker - if (RenderPolyWall::RenderLine(WorldToClip, line, frontsector, subsectorDepth, SubsectorTranslucentWalls)) + if (RenderPolyWall::RenderLine(WorldToClip, line, frontsector, subsectorDepth, StencilValue, SubsectorTranslucentWalls)) { if (hasSegmentRange) Cull.MarkSegmentCulled(sx1, sx2); @@ -190,7 +190,7 @@ void RenderPolyPortal::RenderTranslucent() if (obj.particle) { RenderPolyParticle spr; - spr.Render(WorldToClip, obj.particle, obj.sub, obj.subsectorDepth); + spr.Render(WorldToClip, obj.particle, obj.sub, obj.subsectorDepth, StencilValue + 1); } else if (!obj.thing) { @@ -199,12 +199,12 @@ void RenderPolyPortal::RenderTranslucent() else if ((obj.thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) { RenderPolyWallSprite wallspr; - wallspr.Render(WorldToClip, obj.thing, obj.sub, obj.subsectorDepth); + wallspr.Render(WorldToClip, obj.thing, obj.sub, obj.subsectorDepth, StencilValue + 1); } else { RenderPolySprite spr; - spr.Render(WorldToClip, obj.thing, obj.sub, obj.subsectorDepth); + spr.Render(WorldToClip, obj.thing, obj.sub, obj.subsectorDepth, StencilValue + 1); } } } diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp index 6fc817041..ad8d4b861 100644 --- a/src/r_poly_sky.cpp +++ b/src/r_poly_sky.cpp @@ -61,7 +61,7 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) args.uniforms = uniforms; args.objectToClip = &objectToClip; args.stenciltestvalue = 255; - args.stencilwritevalue = 1; + args.stencilwritevalue = 255; args.SetTexture(frontskytex); args.SetColormap(&NormalLight); diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index 453ab2d00..0bacd6eb2 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -31,7 +31,7 @@ EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Int, r_drawfuzz) -void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth) +void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) { if (IsThingCulled(thing)) return; @@ -134,8 +134,8 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse args.vcount = 4; args.mode = TriangleDrawMode::Fan; args.ccw = true; - args.stenciltestvalue = 0; - args.stencilwritevalue = 1; + args.stenciltestvalue = stencilValue; + args.stencilwritevalue = stencilValue; args.SetTexture(tex, thing->Translation); args.SetColormap(sub->sector->ColorMap); diff --git a/src/r_poly_sprite.h b/src/r_poly_sprite.h index 085d9b570..e23d0d09d 100644 --- a/src/r_poly_sprite.h +++ b/src/r_poly_sprite.h @@ -27,7 +27,7 @@ class RenderPolySprite { public: - void Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth); + void Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); static bool IsThingCulled(AActor *thing); static FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index a4dd62e4b..f49908965 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -30,7 +30,7 @@ #include "r_poly.h" #include "r_sky.h" // for skyflatnum -bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, std::vector &translucentWallsOutput) +bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput) { RenderPolyWall wall; wall.LineSeg = line; @@ -120,7 +120,7 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, secto return false; } -void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, F3DFloor *fakeFloor, std::vector &translucentWallsOutput) +void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput) { double frontceilz1 = fakeFloor->top.plane->ZatPoint(line->v1); double frontfloorz1 = fakeFloor->bottom.plane->ZatPoint(line->v1); @@ -211,8 +211,8 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) args.vcount = 4; args.mode = TriangleDrawMode::Fan; args.ccw = true; - args.stenciltestvalue = 0; - args.stencilwritevalue = 1; + args.stenciltestvalue = StencilValue; + args.stencilwritevalue = StencilValue + 1; args.SetTexture(tex); args.SetColormap(Line->frontsector->ColorMap); @@ -231,7 +231,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); } - RenderPolyDecal::RenderWallDecals(worldToClip, LineSeg, SubsectorDepth); + RenderPolyDecal::RenderWallDecals(worldToClip, LineSeg, SubsectorDepth, StencilValue); } void RenderPolyWall::ClampHeight(TriVertex &v1, TriVertex &v2) diff --git a/src/r_poly_wall.h b/src/r_poly_wall.h index d89731911..3d2f89f84 100644 --- a/src/r_poly_wall.h +++ b/src/r_poly_wall.h @@ -29,8 +29,8 @@ class PolyTranslucentObject; class RenderPolyWall { public: - static bool RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, std::vector &translucentWallsOutput); - static void Render3DFloorLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, F3DFloor *fakeFloor, std::vector &translucentWallsOutput); + static bool RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput); + static void Render3DFloorLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput); void SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2); void Render(const TriMatrix &worldToClip); @@ -52,6 +52,7 @@ public: FSWColormap *Colormap = nullptr; bool Masked = false; uint32_t SubsectorDepth = 0; + uint32_t StencilValue = 0; private: void ClampHeight(TriVertex &v1, TriVertex &v2); diff --git a/src/r_poly_wallsprite.cpp b/src/r_poly_wallsprite.cpp index 6ed009c33..553235957 100644 --- a/src/r_poly_wallsprite.cpp +++ b/src/r_poly_wallsprite.cpp @@ -28,7 +28,7 @@ #include "r_poly_wallsprite.h" #include "r_poly.h" -void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth) +void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) { if (RenderPolySprite::IsThingCulled(thing)) return; @@ -118,8 +118,8 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, AActor *thing, s args.vcount = 4; args.mode = TriangleDrawMode::Fan; args.ccw = true; - args.stenciltestvalue = 0; - args.stencilwritevalue = 1; + args.stenciltestvalue = stencilValue; + args.stencilwritevalue = stencilValue; args.SetTexture(tex); args.SetColormap(sub->sector->ColorMap); PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend); diff --git a/src/r_poly_wallsprite.h b/src/r_poly_wallsprite.h index 66a92b033..2942d6994 100644 --- a/src/r_poly_wallsprite.h +++ b/src/r_poly_wallsprite.h @@ -27,5 +27,5 @@ class RenderPolyWallSprite { public: - void Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth); + void Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); }; From 4eb32a50e3151968e1b2285688ce98da98fedd9f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 24 Nov 2016 07:37:15 +0100 Subject: [PATCH 1279/1509] Add vid_vsync support to Linux target --- src/posix/sdl/sdlglvideo.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index d8c00f236..173a84d80 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -442,6 +442,16 @@ void SDLGLFB::SetVSync( bool vsync ) #if defined (__APPLE__) const GLint value = vsync ? 1 : 0; CGLSetParameter( CGLGetCurrentContext(), kCGLCPSwapInterval, &value ); +#else + if (vsync) + { + if (SDL_GL_SetSwapInterval(-1) == -1) + SDL_GL_SetSwapInterval(1); + } + else + { + SDL_GL_SetSwapInterval(0); + } #endif } From 558a4bcdca5adf8edc0d00b51b7fca6caa1ef652 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 24 Nov 2016 23:08:36 +0100 Subject: [PATCH 1280/1509] Partial sky portal support --- src/r_poly_plane.cpp | 38 +++++++++++--- src/r_poly_plane.h | 6 ++- src/r_poly_portal.cpp | 117 +++++++++++++++++++++++++++++++++++++++--- src/r_poly_portal.h | 36 ++++++++++++- src/r_poly_wall.cpp | 2 + 5 files changed, 181 insertions(+), 18 deletions(-) diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 68a56c69b..57db62600 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -32,7 +32,7 @@ EXTERN_CVAR(Int, r_3dfloors) -void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight) +void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals) { RenderPolyPlane plane; @@ -84,8 +84,8 @@ void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, subsector_t *su } } - plane.Render(worldToClip, sub, subsectorDepth, stencilValue, true, skyCeilingHeight); - plane.Render(worldToClip, sub, subsectorDepth, stencilValue, false, skyFloorHeight); + plane.Render(worldToClip, sub, subsectorDepth, stencilValue, true, skyCeilingHeight, sectorPortals); + plane.Render(worldToClip, sub, subsectorDepth, stencilValue, false, skyFloorHeight, sectorPortals); } void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakeFloor) @@ -146,8 +146,14 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *s PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); } -void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight) +void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals) { + FSectorPortal *portal = sub->sector->ValidatePortal(ceiling ? sector_t::ceiling : sector_t::floor); + if (portal && sectorPortals.empty()) + { + sectorPortals.push_back(std::make_unique(portal, ceiling)); + } + sector_t *fakesector = sub->sector->heightsec; if (fakesector && (fakesector == sub->sector || (fakesector->MoreFlags & SECF_IGNOREHEIGHTSEC) == SECF_IGNOREHEIGHTSEC)) fakesector = nullptr; @@ -237,13 +243,29 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin if (!isSky) { - args.SetTexture(tex); - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy); - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + if (!portal) + { + args.SetTexture(tex); + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + } + else + { + args.stencilwritevalue = 252; + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + } } else { - args.stencilwritevalue = 255; + if (portal) + { + args.stencilwritevalue = 252; + } + else + { + args.stencilwritevalue = 255; + } + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); for (uint32_t i = 0; i < sub->numlines; i++) diff --git a/src/r_poly_plane.h b/src/r_poly_plane.h index d36bb70dc..6e418bf50 100644 --- a/src/r_poly_plane.h +++ b/src/r_poly_plane.h @@ -24,13 +24,15 @@ #include "r_poly_triangle.h" +class PolyDrawSectorPortal; + class RenderPolyPlane { public: - static void RenderPlanes(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight); + static void RenderPlanes(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals); private: void Render3DFloor(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakefloor); - void Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight); + void Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals); TriVertex PlaneVertex(vertex_t *v1, double height); }; diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 6b37d6424..aad43986b 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -29,9 +29,18 @@ #include "gl/data/gl_data.h" CVAR(Bool, r_debug_cull, 0, 0) +EXTERN_CVAR(Int, r_portal_recursions) ///////////////////////////////////////////////////////////////////////////// +RenderPolyPortal::RenderPolyPortal() +{ +} + +RenderPolyPortal::~RenderPolyPortal() +{ +} + void RenderPolyPortal::SetViewpoint(const TriMatrix &worldToClip, uint32_t stencilValue) { WorldToClip = worldToClip; @@ -43,7 +52,9 @@ void RenderPolyPortal::Render() ClearBuffers(); Cull.CullScene(WorldToClip); RenderSectors(); - for (auto &portal : Portals) + for (auto &portal : SectorPortals) + portal->Render(); + for (auto &portal : LinePortals) portal->Render(); } @@ -53,7 +64,8 @@ void RenderPolyPortal::ClearBuffers() SectorSpriteRanges.resize(numsectors); SortedSprites.clear(); TranslucentObjects.clear(); - Portals.clear(); + SectorPortals.clear(); + LinePortals.clear(); NextSubsectorDepth = 0; } @@ -80,10 +92,7 @@ void RenderPolyPortal::RenderSubsector(subsector_t *sub) if (sub->sector->CenterFloor() != sub->sector->CenterCeiling()) { - RenderPolyPlane::RenderPlanes(WorldToClip, sub, subsectorDepth, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight); - - FSectorPortal *ceilingPortal = frontsector->ValidatePortal(sector_t::ceiling); - FSectorPortal *floorPortal = frontsector->ValidatePortal(sector_t::floor); + RenderPolyPlane::RenderPlanes(WorldToClip, sub, subsectorDepth, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, SectorPortals); } for (uint32_t i = 0; i < sub->numlines; i++) @@ -181,7 +190,10 @@ void RenderPolyPortal::RenderLine(subsector_t *sub, seg_t *line, sector_t *front void RenderPolyPortal::RenderTranslucent() { - for (auto it = Portals.rbegin(); it != Portals.rend(); ++it) + for (auto it = SectorPortals.rbegin(); it != SectorPortals.rend(); ++it) + (*it)->RenderTranslucent(); + + for (auto it = LinePortals.rbegin(); it != LinePortals.rend(); ++it) (*it)->RenderTranslucent(); for (auto it = TranslucentObjects.rbegin(); it != TranslucentObjects.rend(); ++it) @@ -208,3 +220,94 @@ void RenderPolyPortal::RenderTranslucent() } } } + +///////////////////////////////////////////////////////////////////////////// + +PolyDrawSectorPortal::PolyDrawSectorPortal(FSectorPortal *portal, bool ceiling) : Portal(portal), Ceiling(ceiling) +{ +} + +void PolyDrawSectorPortal::Render() +{ + if (Portal->mType != PORTS_SKYVIEWPOINT) + return; + + static int recursion = 0; + if (recursion >= 1/*r_portal_recursions*/) + return; + recursion++; + + int savedextralight = extralight; + DVector3 savedpos = ViewPos; + DAngle savedangle = ViewAngle; + double savedvisibility = R_GetVisibility(); + AActor *savedcamera = camera; + sector_t *savedsector = viewsector; + + // Don't let gun flashes brighten the sky box + ASkyViewpoint *sky = barrier_cast(Portal->mSkybox); + extralight = 0; + R_SetVisibility(sky->args[0] * 0.25f); + ViewPos = sky->InterpolatedPosition(r_TicFracF); + ViewAngle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF); + + camera = nullptr; + viewsector = Portal->mDestination; + R_SetViewAngle(); + + // To do: get this information from RenderPolyScene instead of duplicating the code.. + double radPitch = ViewPitch.Normalized180().Radians(); + double angx = cos(radPitch); + double angy = sin(radPitch) * glset.pixelstretch; + double alen = sqrt(angx*angx + angy*angy); + float adjustedPitch = (float)asin(angy / alen); + float adjustedViewAngle = (float)(ViewAngle - 90).Radians(); + float ratio = WidescreenRatio; + float fovratio = (WidescreenRatio >= 1.3f) ? 1.333333f : ratio; + float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(FieldOfView.Radians() / 2) / fovratio)).Degrees); + TriMatrix worldToView = + TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) * + TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) * + TriMatrix::scale(1.0f, glset.pixelstretch, 1.0f) * + TriMatrix::swapYZ() * + TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); + TriMatrix worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; + + RenderPortal.SetViewpoint(worldToClip, 252); + RenderPortal.Render(); + + camera = savedcamera; + viewsector = savedsector; + ViewPos = savedpos; + R_SetVisibility(savedvisibility); + extralight = savedextralight; + ViewAngle = savedangle; + R_SetViewAngle(); + + recursion--; +} + +void PolyDrawSectorPortal::RenderTranslucent() +{ + /*if (Portal->mType != PORTS_SKYVIEWPOINT) + return; + + RenderPortal.RenderTranslucent();*/ +} + +///////////////////////////////////////////////////////////////////////////// + +PolyDrawLinePortal::PolyDrawLinePortal(line_t *src, line_t *dest, bool mirror) : Src(src), Dest(dest) +{ + // To do: do what R_EnterPortal and PortalDrawseg does +} + +void PolyDrawLinePortal::Render() +{ + RenderPortal.Render(); +} + +void PolyDrawLinePortal::RenderTranslucent() +{ + RenderPortal.RenderTranslucent(); +} diff --git a/src/r_poly_portal.h b/src/r_poly_portal.h index 364f2dcfb..34e4666f7 100644 --- a/src/r_poly_portal.h +++ b/src/r_poly_portal.h @@ -74,10 +74,15 @@ public: int Count = 0; }; +class PolyDrawSectorPortal; +class PolyDrawLinePortal; + // Renders everything from a specific viewpoint class RenderPolyPortal { public: + RenderPolyPortal(); + ~RenderPolyPortal(); void SetViewpoint(const TriMatrix &worldToClip, uint32_t stencilValue); void Render(); void RenderTranslucent(); @@ -101,5 +106,34 @@ private: std::vector TranslucentObjects; std::vector SubsectorTranslucentWalls; - std::vector> Portals; + std::vector> SectorPortals; + std::vector> LinePortals; +}; + +class PolyDrawSectorPortal +{ +public: + PolyDrawSectorPortal(FSectorPortal *portal, bool ceiling); + + void Render(); + void RenderTranslucent(); + +private: + FSectorPortal *Portal; + bool Ceiling; + RenderPolyPortal RenderPortal; +}; + +class PolyDrawLinePortal +{ +public: + PolyDrawLinePortal(line_t *src, line_t *dest, bool mirror); + + void Render(); + void RenderTranslucent(); + +private: + line_t *Src; + line_t *Dest; + RenderPolyPortal RenderPortal; }; diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index f49908965..a417784d3 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -39,6 +39,7 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, secto wall.Colormap = frontsector->ColorMap; wall.Masked = false; wall.SubsectorDepth = subsectorDepth; + wall.StencilValue = stencilValue; double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1); double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1); @@ -134,6 +135,7 @@ void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, seg_t *line wall.Colormap = frontsector->ColorMap; wall.Masked = false; wall.SubsectorDepth = subsectorDepth; + wall.StencilValue = stencilValue; wall.SetCoords(line->v1->fPos(), line->v2->fPos(), frontceilz1, frontfloorz1, frontceilz2, frontfloorz2); wall.TopZ = frontceilz1; wall.BottomZ = frontfloorz1; From 1def7b3eaea3dc34617f3fb8659ba8aeb21788dc Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 25 Nov 2016 01:08:25 +0100 Subject: [PATCH 1281/1509] More portal handling stuff --- src/r_poly_plane.cpp | 24 ++++++++-- src/r_poly_portal.cpp | 101 ++++++++++++++++++++++++++++++------------ src/r_poly_portal.h | 24 +++++++++- src/r_poly_wall.cpp | 2 +- 4 files changed, 118 insertions(+), 33 deletions(-) diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 57db62600..0c19d9832 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -149,11 +149,24 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *s void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals) { FSectorPortal *portal = sub->sector->ValidatePortal(ceiling ? sector_t::ceiling : sector_t::floor); - if (portal && sectorPortals.empty()) + PolyDrawSectorPortal *polyportal = nullptr; + if (portal) { - sectorPortals.push_back(std::make_unique(portal, ceiling)); + for (auto &p : sectorPortals) + { + if (p->Portal == portal) // To do: what other criterias do we need to check for? + { + polyportal = p.get(); + break; + } + } + if (!portal) + { + sectorPortals.push_back(std::make_unique(portal, ceiling)); + polyportal = sectorPortals.back().get(); + } } - + sector_t *fakesector = sub->sector->heightsec; if (fakesector && (fakesector == sub->sector || (fakesector->MoreFlags & SECF_IGNOREHEIGHTSEC) == SECF_IGNOREHEIGHTSEC)) fakesector = nullptr; @@ -253,6 +266,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin { args.stencilwritevalue = 252; PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw }); } } else @@ -260,6 +274,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin if (portal) { args.stencilwritevalue = 252; + polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw }); } else { @@ -335,6 +350,9 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin args.vinput = wallvert; args.vcount = 4; PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + + if (portal) + polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw }); } } } diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index aad43986b..e500e24d1 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -128,7 +128,7 @@ void RenderPolyPortal::RenderSubsector(subsector_t *sub) SpriteRange RenderPolyPortal::GetSpritesForSector(sector_t *sector) { - if (SectorSpriteRanges.size() < sector->sectornum || sector->sectornum < 0) + if ((int)SectorSpriteRanges.size() < sector->sectornum || sector->sectornum < 0) return SpriteRange(); auto &range = SectorSpriteRanges[sector->sectornum]; @@ -191,10 +191,38 @@ void RenderPolyPortal::RenderLine(subsector_t *sub, seg_t *line, sector_t *front void RenderPolyPortal::RenderTranslucent() { for (auto it = SectorPortals.rbegin(); it != SectorPortals.rend(); ++it) + { (*it)->RenderTranslucent(); + + PolyDrawArgs args; + args.objectToClip = &WorldToClip; + args.stenciltestvalue = 253; + args.stencilwritevalue = 1; + for (const auto &verts : (*it)->Shape) + { + args.vinput = verts.Vertices; + args.vcount = verts.Count; + args.ccw = verts.Ccw; + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + } + } for (auto it = LinePortals.rbegin(); it != LinePortals.rend(); ++it) + { (*it)->RenderTranslucent(); + + PolyDrawArgs args; + args.objectToClip = &WorldToClip; + args.stenciltestvalue = 253; + args.stencilwritevalue = 1; + for (const auto &verts : (*it)->Shape) + { + args.vinput = verts.Vertices; + args.vcount = verts.Count; + args.ccw = verts.Ccw; + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + } + } for (auto it = TranslucentObjects.rbegin(); it != TranslucentObjects.rend(); ++it) { @@ -237,23 +265,7 @@ void PolyDrawSectorPortal::Render() return; recursion++; - int savedextralight = extralight; - DVector3 savedpos = ViewPos; - DAngle savedangle = ViewAngle; - double savedvisibility = R_GetVisibility(); - AActor *savedcamera = camera; - sector_t *savedsector = viewsector; - - // Don't let gun flashes brighten the sky box - ASkyViewpoint *sky = barrier_cast(Portal->mSkybox); - extralight = 0; - R_SetVisibility(sky->args[0] * 0.25f); - ViewPos = sky->InterpolatedPosition(r_TicFracF); - ViewAngle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF); - - camera = nullptr; - viewsector = Portal->mDestination; - R_SetViewAngle(); + SaveGlobals(); // To do: get this information from RenderPolyScene instead of duplicating the code.. double radPitch = ViewPitch.Normalized180().Radians(); @@ -275,7 +287,50 @@ void PolyDrawSectorPortal::Render() RenderPortal.SetViewpoint(worldToClip, 252); RenderPortal.Render(); + + RestoreGlobals(); + + recursion--; +} +void PolyDrawSectorPortal::RenderTranslucent() +{ + if (Portal->mType != PORTS_SKYVIEWPOINT) + return; + + static int recursion = 0; + if (recursion >= 1/*r_portal_recursions*/) + return; + recursion++; + + RenderPortal.RenderTranslucent(); + + recursion--; +} + +void PolyDrawSectorPortal::SaveGlobals() +{ + int savedextralight = extralight; + DVector3 savedpos = ViewPos; + DAngle savedangle = ViewAngle; + double savedvisibility = R_GetVisibility(); + AActor *savedcamera = camera; + sector_t *savedsector = viewsector; + + // Don't let gun flashes brighten the sky box + ASkyViewpoint *sky = barrier_cast(Portal->mSkybox); + extralight = 0; + R_SetVisibility(sky->args[0] * 0.25f); + ViewPos = sky->InterpolatedPosition(r_TicFracF); + ViewAngle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF); + + camera = nullptr; + viewsector = Portal->mDestination; + R_SetViewAngle(); +} + +void PolyDrawSectorPortal::RestoreGlobals() +{ camera = savedcamera; viewsector = savedsector; ViewPos = savedpos; @@ -283,16 +338,6 @@ void PolyDrawSectorPortal::Render() extralight = savedextralight; ViewAngle = savedangle; R_SetViewAngle(); - - recursion--; -} - -void PolyDrawSectorPortal::RenderTranslucent() -{ - /*if (Portal->mType != PORTS_SKYVIEWPOINT) - return; - - RenderPortal.RenderTranslucent();*/ } ///////////////////////////////////////////////////////////////////////////// diff --git a/src/r_poly_portal.h b/src/r_poly_portal.h index 34e4666f7..6042d5938 100644 --- a/src/r_poly_portal.h +++ b/src/r_poly_portal.h @@ -110,6 +110,14 @@ private: std::vector> LinePortals; }; +struct PolyPortalVertexRange +{ + PolyPortalVertexRange(const TriVertex *vertices, int count, bool ccw) : Vertices(vertices), Count(count), Ccw(ccw) { } + const TriVertex *Vertices; + int Count; + bool Ccw; +}; + class PolyDrawSectorPortal { public: @@ -117,11 +125,23 @@ public: void Render(); void RenderTranslucent(); + + FSectorPortal *Portal; + std::vector Shape; private: - FSectorPortal *Portal; + void SaveGlobals(); + void RestoreGlobals(); + bool Ceiling; RenderPolyPortal RenderPortal; + + int savedextralight; + DVector3 savedpos; + DAngle savedangle; + double savedvisibility; + AActor *savedcamera; + sector_t *savedsector; }; class PolyDrawLinePortal @@ -132,6 +152,8 @@ public: void Render(); void RenderTranslucent(); + std::vector Shape; + private: line_t *Src; line_t *Dest; diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index a417784d3..8f3fb05d7 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -312,7 +312,7 @@ void PolyWallTextureCoords::CalcU(FTexture *tex, const seg_t *lineseg, const lin double lineLength = side->TexelLength; double lineStart = 0.0; - bool entireSegment = ((lineseg->v1 == line->v1) && (lineseg->v2 == line->v2) || (lineseg->v2 == line->v1) && (lineseg->v1 == line->v2)); + bool entireSegment = ((lineseg->v1 == line->v1) && (lineseg->v2 == line->v2)) || ((lineseg->v2 == line->v1) && (lineseg->v1 == line->v2)); if (!entireSegment) { lineLength = (lineseg->v2->fPos() - lineseg->v1->fPos()).Length(); From e642ed099a644ed052e3d52abc73133d31204946 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 25 Nov 2016 03:26:15 +0100 Subject: [PATCH 1282/1509] Fix palette blending --- .../fixedfunction/drawtrianglecodegen.cpp | 41 ++++++++++++++----- src/r_compiler/llvmdrawers.cpp | 2 +- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index d8a436101..b34f34799 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -671,48 +671,67 @@ SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) break; case TriBlendMode::AlphaBlend: palindex = Sample8(uvoffset); - output = (palindex == SSAInt(0)).select(bg, Shade8(palindex)); + output = Shade8(palindex); + output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::AddSolid: - fg = ToBgra(Shade8(Sample8(uvoffset))); + palindex = Sample8(uvoffset); + fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, destalpha)); + output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::Add: - fg = ToBgra(Shade8(Sample8(uvoffset))); + palindex = Sample8(uvoffset); + fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::Sub: - fg = ToBgra(Shade8(Sample8(uvoffset))); + palindex = Sample8(uvoffset); + fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_sub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::RevSub: - fg = ToBgra(Shade8(Sample8(uvoffset))); + palindex = Sample8(uvoffset); + fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_revsub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::Stencil: output = ToPal8(blend_stencil(ToBgra(Shade8(color)), (Sample8(uvoffset) == SSAInt(0)).select(SSAInt(0), SSAInt(256)), ToBgra(bg), srcalpha, destalpha)); break; case TriBlendMode::Shaded: - output = ToPal8(blend_stencil(ToBgra(Shade8(color)), Sample8(uvoffset), ToBgra(bg), srcalpha, destalpha)); + palindex = Sample8(uvoffset); + output = ToPal8(blend_stencil(ToBgra(Shade8(color)), palindex, ToBgra(bg), srcalpha, destalpha)); break; case TriBlendMode::TranslateCopy: - output = Shade8(TranslateSample8(uvoffset)); + palindex = TranslateSample8(uvoffset); + output = Shade8(palindex); + output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::TranslateAlphaBlend: palindex = TranslateSample8(uvoffset); - output = (palindex == SSAInt(0)).select(bg, Shade8(palindex)); + output = Shade8(palindex); + output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::TranslateAdd: - fg = ToBgra(Shade8(Sample8(uvoffset))); + palindex = TranslateSample8(uvoffset); + fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::TranslateSub: - fg = ToBgra(Shade8(Sample8(uvoffset))); + palindex = TranslateSample8(uvoffset); + fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_sub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::TranslateRevSub: - fg = ToBgra(Shade8(Sample8(uvoffset))); + palindex = TranslateSample8(uvoffset); + fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_revsub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + output = (palindex == SSAInt(0)).select(bg, output); break; } diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 3abf732c0..fc44f67bd 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -127,7 +127,7 @@ LLVMDrawers *LLVMDrawers::Instance() LLVMDrawersImpl::LLVMDrawersImpl() { - int version = 6; // Increment this number if the drawer codegen is modified (forces recreation of the module). + int version = 7; // Increment this number if the drawer codegen is modified (forces recreation of the module). std::string targetCPU = mProgram.GetTargetCPU(); bool loaded = mProgram.LoadCachedModule(version, targetCPU); if (!loaded) From b2ad26d2d5868cf9d66de3dc8b093b5e03be982f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 25 Nov 2016 07:44:51 +0100 Subject: [PATCH 1283/1509] Sealing off portal entrances for the transparency pass --- .../fixedfunction/drawtrianglecodegen.cpp | 40 ++++++++++++++----- src/r_compiler/llvmdrawers.cpp | 4 +- src/r_compiler/llvmdrawers.h | 4 +- src/r_compiler/ssa/ssa_bool.cpp | 5 +++ src/r_compiler/ssa/ssa_bool.h | 2 + src/r_poly_plane.cpp | 8 ++-- src/r_poly_portal.cpp | 20 ++++++---- src/r_poly_portal.h | 3 +- src/r_poly_triangle.cpp | 1 + 9 files changed, 61 insertions(+), 26 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp index b34f34799..09d3a618e 100644 --- a/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp +++ b/src/r_compiler/fixedfunction/drawtrianglecodegen.cpp @@ -273,11 +273,7 @@ void DrawTriangleCodegen::LoopBlockX() SetStencilBlock(x / 8 + y / 8 * stencilPitch); - SSABool covered = a == SSAInt(0xF) && b == SSAInt(0xF) && c == SSAInt(0xF) && !clipneeded; - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) - { - covered = covered && StencilIsSingleValue(); - } + SSABool covered = a == SSAInt(0xF) && b == SSAInt(0xF) && c == SSAInt(0xF) && !clipneeded && StencilIsSingleValue(); // Accept whole block when totally covered SSAIfBlock branch_covered; @@ -301,7 +297,11 @@ void DrawTriangleCodegen::LoopBlockX() void DrawTriangleCodegen::LoopFullBlock() { SSAIfBlock branch_stenciltest; - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector || variant == TriDrawVariant::StencilClose) + { + branch_stenciltest.if_block(SSABool::compare_uge(StencilGetSingle(), stencilTestValue)); + } + else { branch_stenciltest.if_block(StencilGetSingle() == stencilTestValue); } @@ -310,6 +310,18 @@ void DrawTriangleCodegen::LoopFullBlock() { StencilClear(stencilWriteValue); } + else if (variant == TriDrawVariant::StencilClose) + { + StencilClear(stencilWriteValue); + for (int iy = 0; iy < q; iy++) + { + SSAIntPtr subsectorbuffer = subsectorGBuffer[x + iy * pitch]; + for (int ix = 0; ix < q; ix += 4) + { + subsectorbuffer[ix].store_unaligned_vec4i(SSAVec4i(subsectorDepth)); + } + } + } else { int pixelsize = truecolor ? 4 : 1; @@ -407,10 +419,7 @@ void DrawTriangleCodegen::LoopFullBlock() } } - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) - { - branch_stenciltest.end_block(); - } + branch_stenciltest.end_block(); } void DrawTriangleCodegen::LoopPartialBlock() @@ -468,7 +477,11 @@ void DrawTriangleCodegen::LoopPartialBlock() if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) { - covered = covered && subsectorbuffer[ix].load(true) >= subsectorDepth; + covered = covered && SSABool::compare_uge(StencilGet(ix, iy), stencilTestValue) && subsectorbuffer[ix].load(true) >= subsectorDepth; + } + else if (variant == TriDrawVariant::StencilClose) + { + covered = covered && SSABool::compare_uge(StencilGet(ix, iy), stencilTestValue); } else { @@ -482,6 +495,11 @@ void DrawTriangleCodegen::LoopPartialBlock() { StencilSet(ix, iy, stencilWriteValue); } + else if (variant == TriDrawVariant::StencilClose) + { + StencilSet(ix, iy, stencilWriteValue); + subsectorbuffer[ix].store(subsectorDepth); + } else { SSAUBytePtr buf = buffer[ix * pixelsize]; diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index fc44f67bd..babb7c6e7 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -127,7 +127,7 @@ LLVMDrawers *LLVMDrawers::Instance() LLVMDrawersImpl::LLVMDrawersImpl() { - int version = 7; // Increment this number if the drawer codegen is modified (forces recreation of the module). + int version = 8; // Increment this number if the drawer codegen is modified (forces recreation of the module). std::string targetCPU = mProgram.GetTargetCPU(); bool loaded = mProgram.LoadCachedModule(version, targetCPU); if (!loaded) @@ -208,6 +208,7 @@ LLVMDrawersImpl::LLVMDrawersImpl() CodegenDrawTriangle("TriFillSubsector32_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, true); } CodegenDrawTriangle("TriStencil", TriDrawVariant::Stencil, TriBlendMode::Copy, false); + CodegenDrawTriangle("TriStencilClose", TriDrawVariant::StencilClose, TriBlendMode::Copy, false); } mProgram.CreateEE(version, targetCPU, !loaded); @@ -286,6 +287,7 @@ LLVMDrawersImpl::LLVMDrawersImpl() TriFillSubsector32.push_back(mProgram.GetProcAddress("TriFillSubsector32_" + std::to_string(i))); } TriStencil = mProgram.GetProcAddress("TriStencil"); + TriStencilClose = mProgram.GetProcAddress("TriStencilClose"); #if 0 std::vector foo(1024 * 4); diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 6113b1d04..4ce3a3a03 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -270,7 +270,8 @@ enum class TriDrawVariant DrawSubsector, FillSubsector, FuzzSubsector, - Stencil + Stencil, + StencilClose }; enum class TriBlendMode @@ -376,6 +377,7 @@ public: std::vector TriFillSubsector8; std::vector TriFillSubsector32; void(*TriStencil)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + void(*TriStencilClose)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; private: static LLVMDrawers *Singleton; diff --git a/src/r_compiler/ssa/ssa_bool.cpp b/src/r_compiler/ssa/ssa_bool.cpp index 916350c59..d6ecad4e8 100644 --- a/src/r_compiler/ssa/ssa_bool.cpp +++ b/src/r_compiler/ssa/ssa_bool.cpp @@ -67,6 +67,11 @@ SSAVec4i SSABool::select(SSAVec4i a, SSAVec4i b) return SSAValue::from_llvm(SSAScope::builder().CreateSelect(v, a.v, b.v, SSAScope::hint())); } +SSABool SSABool::compare_uge(const SSAUByte &a, const SSAUByte &b) +{ + return SSABool::from_llvm(SSAScope::builder().CreateICmpUGE(a.v, b.v, SSAScope::hint())); +} + SSABool operator&&(const SSABool &a, const SSABool &b) { return SSABool::from_llvm(SSAScope::builder().CreateAnd(a.v, b.v, SSAScope::hint())); diff --git a/src/r_compiler/ssa/ssa_bool.h b/src/r_compiler/ssa/ssa_bool.h index 372c626c0..9b8a564d8 100644 --- a/src/r_compiler/ssa/ssa_bool.h +++ b/src/r_compiler/ssa/ssa_bool.h @@ -45,6 +45,8 @@ public: SSAUByte select(SSAUByte a, SSAUByte b); SSAVec4i select(SSAVec4i a, SSAVec4i b); + static SSABool compare_uge(const SSAUByte &a, const SSAUByte &b); + llvm::Value *v; }; diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 0c19d9832..c8248bed6 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -160,7 +160,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin break; } } - if (!portal) + if (!polyportal) { sectorPortals.push_back(std::make_unique(portal, ceiling)); polyportal = sectorPortals.back().get(); @@ -266,7 +266,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin { args.stencilwritevalue = 252; PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); - polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw }); + polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, subsectorDepth }); } } else @@ -274,7 +274,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin if (portal) { args.stencilwritevalue = 252; - polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw }); + polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, subsectorDepth }); } else { @@ -352,7 +352,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); if (portal) - polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw }); + polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, subsectorDepth }); } } } diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index e500e24d1..805195835 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -196,6 +196,7 @@ void RenderPolyPortal::RenderTranslucent() PolyDrawArgs args; args.objectToClip = &WorldToClip; + args.mode = TriangleDrawMode::Fan; args.stenciltestvalue = 253; args.stencilwritevalue = 1; for (const auto &verts : (*it)->Shape) @@ -203,7 +204,8 @@ void RenderPolyPortal::RenderTranslucent() args.vinput = verts.Vertices; args.vcount = verts.Count; args.ccw = verts.Ccw; - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + args.uniforms.subsectorDepth = verts.SubsectorDepth; + PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy); } } @@ -213,6 +215,7 @@ void RenderPolyPortal::RenderTranslucent() PolyDrawArgs args; args.objectToClip = &WorldToClip; + args.mode = TriangleDrawMode::Fan; args.stenciltestvalue = 253; args.stencilwritevalue = 1; for (const auto &verts : (*it)->Shape) @@ -220,7 +223,8 @@ void RenderPolyPortal::RenderTranslucent() args.vinput = verts.Vertices; args.vcount = verts.Count; args.ccw = verts.Ccw; - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + args.uniforms.subsectorDepth = verts.SubsectorDepth; + PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy); } } @@ -310,12 +314,12 @@ void PolyDrawSectorPortal::RenderTranslucent() void PolyDrawSectorPortal::SaveGlobals() { - int savedextralight = extralight; - DVector3 savedpos = ViewPos; - DAngle savedangle = ViewAngle; - double savedvisibility = R_GetVisibility(); - AActor *savedcamera = camera; - sector_t *savedsector = viewsector; + savedextralight = extralight; + savedpos = ViewPos; + savedangle = ViewAngle; + savedvisibility = R_GetVisibility(); + savedcamera = camera; + savedsector = viewsector; // Don't let gun flashes brighten the sky box ASkyViewpoint *sky = barrier_cast(Portal->mSkybox); diff --git a/src/r_poly_portal.h b/src/r_poly_portal.h index 6042d5938..8878f496d 100644 --- a/src/r_poly_portal.h +++ b/src/r_poly_portal.h @@ -112,10 +112,11 @@ private: struct PolyPortalVertexRange { - PolyPortalVertexRange(const TriVertex *vertices, int count, bool ccw) : Vertices(vertices), Count(count), Ccw(ccw) { } + PolyPortalVertexRange(const TriVertex *vertices, int count, bool ccw, uint32_t subsectorDepth) : Vertices(vertices), Count(count), Ccw(ccw), SubsectorDepth(subsectorDepth) { } const TriVertex *Vertices; int Count; bool Ccw; + uint32_t SubsectorDepth; }; class PolyDrawSectorPortal diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 9a389777a..298c5f024 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -90,6 +90,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian case TriDrawVariant::FuzzSubsector: case TriDrawVariant::FillSubsector: drawfunc = dest_bgra ? llvm->TriFillSubsector32[bmode] : llvm->TriFillSubsector8[bmode]; break; case TriDrawVariant::Stencil: drawfunc = llvm->TriStencil; break; + case TriDrawVariant::StencilClose: drawfunc = llvm->TriStencilClose; break; } TriDrawTriangleArgs args; From 93af906a1d7a2ed552a3a4f9e460926a7b1f0933 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 25 Nov 2016 17:14:26 +0100 Subject: [PATCH 1284/1509] Add support for multiple portals --- src/r_poly.cpp | 3 ++- src/r_poly.h | 3 +++ src/r_poly_plane.cpp | 4 ++-- src/r_poly_portal.cpp | 24 +++++++++++++++--------- src/r_poly_portal.h | 2 ++ 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 171d7e0ad..13ecd2625 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -44,7 +44,7 @@ void RenderPolyScene::Render() ClearBuffers(); SetSceneViewport(); SetupPerspectiveMatrix(); - MainPortal.SetViewpoint(WorldToClip, 0); + MainPortal.SetViewpoint(WorldToClip, GetNextStencilValue()); MainPortal.Render(); Skydome.Render(WorldToClip); MainPortal.RenderTranslucent(); @@ -63,6 +63,7 @@ void RenderPolyScene::ClearBuffers() PolyVertexBuffer::Clear(); PolyStencilBuffer::Instance()->Clear(RenderTarget->GetWidth(), RenderTarget->GetHeight(), 0); PolySubsectorGBuffer::Instance()->Resize(RenderTarget->GetPitch(), RenderTarget->GetHeight()); + NextStencilValue = 0; } void RenderPolyScene::SetSceneViewport() diff --git a/src/r_poly.h b/src/r_poly.h index 99e86307b..3bd9bb319 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -41,6 +41,8 @@ public: void RenderRemainingPlayerSprites(); static RenderPolyScene *Instance(); + + uint32_t GetNextStencilValue() { uint32_t value = NextStencilValue; NextStencilValue += 2; return value; } private: void ClearBuffers(); @@ -51,4 +53,5 @@ private: RenderPolyPortal MainPortal; PolySkyDome Skydome; RenderPolyPlayerSprites PlayerSprites; + uint32_t NextStencilValue = 0; }; diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index c8248bed6..60b9d7569 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -264,7 +264,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin } else { - args.stencilwritevalue = 252; + args.stencilwritevalue = polyportal->StencilValue; PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, subsectorDepth }); } @@ -273,7 +273,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin { if (portal) { - args.stencilwritevalue = 252; + args.stencilwritevalue = polyportal->StencilValue; polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, subsectorDepth }); } else diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 805195835..4f42ab77e 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -26,6 +26,7 @@ #include "sbar.h" #include "r_data/r_translate.h" #include "r_poly_portal.h" +#include "r_poly.h" #include "gl/data/gl_data.h" CVAR(Bool, r_debug_cull, 0, 0) @@ -192,14 +193,15 @@ void RenderPolyPortal::RenderTranslucent() { for (auto it = SectorPortals.rbegin(); it != SectorPortals.rend(); ++it) { - (*it)->RenderTranslucent(); + auto &portal = *it; + portal->RenderTranslucent(); PolyDrawArgs args; args.objectToClip = &WorldToClip; args.mode = TriangleDrawMode::Fan; - args.stenciltestvalue = 253; - args.stencilwritevalue = 1; - for (const auto &verts : (*it)->Shape) + args.stenciltestvalue = portal->StencilValue + 1; + args.stencilwritevalue = StencilValue; + for (const auto &verts : portal->Shape) { args.vinput = verts.Vertices; args.vcount = verts.Count; @@ -211,14 +213,15 @@ void RenderPolyPortal::RenderTranslucent() for (auto it = LinePortals.rbegin(); it != LinePortals.rend(); ++it) { - (*it)->RenderTranslucent(); + auto &portal = *it; + portal->RenderTranslucent(); PolyDrawArgs args; args.objectToClip = &WorldToClip; args.mode = TriangleDrawMode::Fan; - args.stenciltestvalue = 253; - args.stencilwritevalue = 1; - for (const auto &verts : (*it)->Shape) + args.stenciltestvalue = portal->StencilValue + 1; + args.stencilwritevalue = StencilValue; + for (const auto &verts : portal->Shape) { args.vinput = verts.Vertices; args.vcount = verts.Count; @@ -257,6 +260,7 @@ void RenderPolyPortal::RenderTranslucent() PolyDrawSectorPortal::PolyDrawSectorPortal(FSectorPortal *portal, bool ceiling) : Portal(portal), Ceiling(ceiling) { + StencilValue = RenderPolyScene::Instance()->GetNextStencilValue(); } void PolyDrawSectorPortal::Render() @@ -289,7 +293,7 @@ void PolyDrawSectorPortal::Render() TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); TriMatrix worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; - RenderPortal.SetViewpoint(worldToClip, 252); + RenderPortal.SetViewpoint(worldToClip, StencilValue); RenderPortal.Render(); RestoreGlobals(); @@ -349,6 +353,8 @@ void PolyDrawSectorPortal::RestoreGlobals() PolyDrawLinePortal::PolyDrawLinePortal(line_t *src, line_t *dest, bool mirror) : Src(src), Dest(dest) { // To do: do what R_EnterPortal and PortalDrawseg does + + StencilValue = RenderPolyScene::Instance()->GetNextStencilValue(); } void PolyDrawLinePortal::Render() diff --git a/src/r_poly_portal.h b/src/r_poly_portal.h index 8878f496d..b910034a2 100644 --- a/src/r_poly_portal.h +++ b/src/r_poly_portal.h @@ -128,6 +128,7 @@ public: void RenderTranslucent(); FSectorPortal *Portal; + uint32_t StencilValue = 0; std::vector Shape; private: @@ -153,6 +154,7 @@ public: void Render(); void RenderTranslucent(); + uint32_t StencilValue = 0; std::vector Shape; private: From 864358389e5face04f25e00b87dc49b8012065ff Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 25 Nov 2016 18:15:48 +0100 Subject: [PATCH 1285/1509] Implement portal recursion limit --- src/r_poly.cpp | 4 +- src/r_poly_portal.cpp | 112 ++++++++++++++++++++---------------------- src/r_poly_portal.h | 12 ++--- 3 files changed, 60 insertions(+), 68 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 13ecd2625..729774174 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -45,9 +45,9 @@ void RenderPolyScene::Render() SetSceneViewport(); SetupPerspectiveMatrix(); MainPortal.SetViewpoint(WorldToClip, GetNextStencilValue()); - MainPortal.Render(); + MainPortal.Render(0); Skydome.Render(WorldToClip); - MainPortal.RenderTranslucent(); + MainPortal.RenderTranslucent(0); PlayerSprites.Render(); DrawerCommandQueue::WaitForWorkers(); diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 4f42ab77e..0346a9d7d 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -48,15 +48,18 @@ void RenderPolyPortal::SetViewpoint(const TriMatrix &worldToClip, uint32_t stenc StencilValue = stencilValue; } -void RenderPolyPortal::Render() +void RenderPolyPortal::Render(int portalDepth) { ClearBuffers(); Cull.CullScene(WorldToClip); RenderSectors(); - for (auto &portal : SectorPortals) - portal->Render(); - for (auto &portal : LinePortals) - portal->Render(); + if (portalDepth < r_portal_recursions) + { + for (auto &portal : SectorPortals) + portal->Render(portalDepth + 1); + for (auto &portal : LinePortals) + portal->Render(portalDepth + 1); + } } void RenderPolyPortal::ClearBuffers() @@ -189,45 +192,48 @@ void RenderPolyPortal::RenderLine(subsector_t *sub, seg_t *line, sector_t *front } } -void RenderPolyPortal::RenderTranslucent() +void RenderPolyPortal::RenderTranslucent(int portalDepth) { - for (auto it = SectorPortals.rbegin(); it != SectorPortals.rend(); ++it) + if (portalDepth < r_portal_recursions) { - auto &portal = *it; - portal->RenderTranslucent(); - - PolyDrawArgs args; - args.objectToClip = &WorldToClip; - args.mode = TriangleDrawMode::Fan; - args.stenciltestvalue = portal->StencilValue + 1; - args.stencilwritevalue = StencilValue; - for (const auto &verts : portal->Shape) + for (auto it = SectorPortals.rbegin(); it != SectorPortals.rend(); ++it) { - args.vinput = verts.Vertices; - args.vcount = verts.Count; - args.ccw = verts.Ccw; - args.uniforms.subsectorDepth = verts.SubsectorDepth; - PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy); + auto &portal = *it; + portal->RenderTranslucent(portalDepth + 1); + + PolyDrawArgs args; + args.objectToClip = &WorldToClip; + args.mode = TriangleDrawMode::Fan; + args.stenciltestvalue = portal->StencilValue + 1; + args.stencilwritevalue = StencilValue; + for (const auto &verts : portal->Shape) + { + args.vinput = verts.Vertices; + args.vcount = verts.Count; + args.ccw = verts.Ccw; + args.uniforms.subsectorDepth = verts.SubsectorDepth; + PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy); + } } - } - for (auto it = LinePortals.rbegin(); it != LinePortals.rend(); ++it) - { - auto &portal = *it; - portal->RenderTranslucent(); - - PolyDrawArgs args; - args.objectToClip = &WorldToClip; - args.mode = TriangleDrawMode::Fan; - args.stenciltestvalue = portal->StencilValue + 1; - args.stencilwritevalue = StencilValue; - for (const auto &verts : portal->Shape) + for (auto it = LinePortals.rbegin(); it != LinePortals.rend(); ++it) { - args.vinput = verts.Vertices; - args.vcount = verts.Count; - args.ccw = verts.Ccw; - args.uniforms.subsectorDepth = verts.SubsectorDepth; - PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy); + auto &portal = *it; + portal->RenderTranslucent(portalDepth + 1); + + PolyDrawArgs args; + args.objectToClip = &WorldToClip; + args.mode = TriangleDrawMode::Fan; + args.stenciltestvalue = portal->StencilValue + 1; + args.stencilwritevalue = StencilValue; + for (const auto &verts : portal->Shape) + { + args.vinput = verts.Vertices; + args.vcount = verts.Count; + args.ccw = verts.Ccw; + args.uniforms.subsectorDepth = verts.SubsectorDepth; + PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy); + } } } @@ -263,16 +269,11 @@ PolyDrawSectorPortal::PolyDrawSectorPortal(FSectorPortal *portal, bool ceiling) StencilValue = RenderPolyScene::Instance()->GetNextStencilValue(); } -void PolyDrawSectorPortal::Render() +void PolyDrawSectorPortal::Render(int portalDepth) { if (Portal->mType != PORTS_SKYVIEWPOINT) return; - static int recursion = 0; - if (recursion >= 1/*r_portal_recursions*/) - return; - recursion++; - SaveGlobals(); // To do: get this information from RenderPolyScene instead of duplicating the code.. @@ -294,26 +295,17 @@ void PolyDrawSectorPortal::Render() TriMatrix worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; RenderPortal.SetViewpoint(worldToClip, StencilValue); - RenderPortal.Render(); + RenderPortal.Render(portalDepth); RestoreGlobals(); - - recursion--; } -void PolyDrawSectorPortal::RenderTranslucent() +void PolyDrawSectorPortal::RenderTranslucent(int portalDepth) { if (Portal->mType != PORTS_SKYVIEWPOINT) return; - static int recursion = 0; - if (recursion >= 1/*r_portal_recursions*/) - return; - recursion++; - - RenderPortal.RenderTranslucent(); - - recursion--; + RenderPortal.RenderTranslucent(portalDepth); } void PolyDrawSectorPortal::SaveGlobals() @@ -357,12 +349,12 @@ PolyDrawLinePortal::PolyDrawLinePortal(line_t *src, line_t *dest, bool mirror) : StencilValue = RenderPolyScene::Instance()->GetNextStencilValue(); } -void PolyDrawLinePortal::Render() +void PolyDrawLinePortal::Render(int portalDepth) { - RenderPortal.Render(); + RenderPortal.Render(portalDepth); } -void PolyDrawLinePortal::RenderTranslucent() +void PolyDrawLinePortal::RenderTranslucent(int portalDepth) { - RenderPortal.RenderTranslucent(); + RenderPortal.RenderTranslucent(portalDepth); } diff --git a/src/r_poly_portal.h b/src/r_poly_portal.h index b910034a2..a53a185e3 100644 --- a/src/r_poly_portal.h +++ b/src/r_poly_portal.h @@ -84,8 +84,8 @@ public: RenderPolyPortal(); ~RenderPolyPortal(); void SetViewpoint(const TriMatrix &worldToClip, uint32_t stencilValue); - void Render(); - void RenderTranslucent(); + void Render(int portalDepth); + void RenderTranslucent(int portalDepth); static const uint32_t SkySubsectorDepth = 0x7fffffff; @@ -124,8 +124,8 @@ class PolyDrawSectorPortal public: PolyDrawSectorPortal(FSectorPortal *portal, bool ceiling); - void Render(); - void RenderTranslucent(); + void Render(int portalDepth); + void RenderTranslucent(int portalDepth); FSectorPortal *Portal; uint32_t StencilValue = 0; @@ -151,8 +151,8 @@ class PolyDrawLinePortal public: PolyDrawLinePortal(line_t *src, line_t *dest, bool mirror); - void Render(); - void RenderTranslucent(); + void Render(int portalDepth); + void RenderTranslucent(int portalDepth); uint32_t StencilValue = 0; std::vector Shape; From eaa15f2b74bdacc62937a7d0e0967686821eca0f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 25 Nov 2016 20:19:35 +0100 Subject: [PATCH 1286/1509] Render other sector portal types --- src/r_poly_cull.cpp | 6 ++++++ src/r_poly_plane.cpp | 2 ++ src/r_poly_portal.cpp | 36 ++++++++++++++++++++++++++++-------- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/r_poly_cull.cpp b/src/r_poly_cull.cpp index ff349690c..04d5c3c24 100644 --- a/src/r_poly_cull.cpp +++ b/src/r_poly_cull.cpp @@ -85,6 +85,12 @@ void PolyCull::CullSubsector(subsector_t *sub) seg_t *line = &sub->firstline[i]; if ((line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) && line->backsector == nullptr) { + // Skip lines not facing viewer + DVector2 pt1 = line->v1->fPos() - ViewPos; + DVector2 pt2 = line->v2->fPos() - ViewPos; + if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0) + continue; + int sx1, sx2; if (GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2)) { diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 60b9d7569..e64d085e7 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -150,6 +150,8 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin { FSectorPortal *portal = sub->sector->ValidatePortal(ceiling ? sector_t::ceiling : sector_t::floor); PolyDrawSectorPortal *polyportal = nullptr; + if (portal && (portal->mFlags & PORTSF_INSKYBOX) == PORTSF_INSKYBOX) // Do not recurse into portals we already recursed into + portal = nullptr; if (portal) { for (auto &p : sectorPortals) diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 0346a9d7d..d6a67a317 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -271,7 +271,7 @@ PolyDrawSectorPortal::PolyDrawSectorPortal(FSectorPortal *portal, bool ceiling) void PolyDrawSectorPortal::Render(int portalDepth) { - if (Portal->mType != PORTS_SKYVIEWPOINT) + if (Portal->mType == PORTS_HORIZON || Portal->mType == PORTS_PLANE) return; SaveGlobals(); @@ -302,10 +302,14 @@ void PolyDrawSectorPortal::Render(int portalDepth) void PolyDrawSectorPortal::RenderTranslucent(int portalDepth) { - if (Portal->mType != PORTS_SKYVIEWPOINT) + if (Portal->mType == PORTS_HORIZON || Portal->mType == PORTS_PLANE) return; + + SaveGlobals(); RenderPortal.RenderTranslucent(portalDepth); + + RestoreGlobals(); } void PolyDrawSectorPortal::SaveGlobals() @@ -317,20 +321,36 @@ void PolyDrawSectorPortal::SaveGlobals() savedcamera = camera; savedsector = viewsector; - // Don't let gun flashes brighten the sky box - ASkyViewpoint *sky = barrier_cast(Portal->mSkybox); - extralight = 0; - R_SetVisibility(sky->args[0] * 0.25f); - ViewPos = sky->InterpolatedPosition(r_TicFracF); - ViewAngle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF); + if (Portal->mType == PORTS_SKYVIEWPOINT) + { + // Don't let gun flashes brighten the sky box + ASkyViewpoint *sky = barrier_cast(Portal->mSkybox); + extralight = 0; + R_SetVisibility(sky->args[0] * 0.25f); + ViewPos = sky->InterpolatedPosition(r_TicFracF); + ViewAngle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF); + } + else //if (Portal->mType == PORTS_STACKEDSECTORTHING || Portal->mType == PORTS_PORTAL || Portal->mType == PORTS_LINKEDPORTAL) + { + //extralight = pl->extralight; + //R_SetVisibility(pl->visibility); + ViewPos.X += Portal->mDisplacement.X; + ViewPos.Y += Portal->mDisplacement.Y; + } camera = nullptr; viewsector = Portal->mDestination; R_SetViewAngle(); + + Portal->mFlags |= PORTSF_INSKYBOX; + if (Portal->mPartner > 0) sectorPortals[Portal->mPartner].mFlags |= PORTSF_INSKYBOX; } void PolyDrawSectorPortal::RestoreGlobals() { + Portal->mFlags &= ~PORTSF_INSKYBOX; + if (Portal->mPartner > 0) sectorPortals[Portal->mPartner].mFlags &= ~PORTSF_INSKYBOX; + camera = savedcamera; viewsector = savedsector; ViewPos = savedpos; From cc3ac9ea0536ec201e964156d910d896d2cdd77c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 25 Nov 2016 23:44:55 +0100 Subject: [PATCH 1287/1509] Line portal rendering --- src/r_poly_portal.cpp | 136 ++++++++++++++++++++++++++++++++++++++++-- src/r_poly_portal.h | 20 +++++-- src/r_poly_wall.cpp | 79 +++++++++++++++++++++++- src/r_poly_wall.h | 3 +- 4 files changed, 228 insertions(+), 10 deletions(-) diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index d6a67a317..e4ce5c547 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -23,6 +23,7 @@ #include #include "templates.h" #include "doomdef.h" +#include "p_maputl.h" #include "sbar.h" #include "r_data/r_translate.h" #include "r_poly_portal.h" @@ -32,6 +33,8 @@ CVAR(Bool, r_debug_cull, 0, 0) EXTERN_CVAR(Int, r_portal_recursions) +extern bool r_showviewer; + ///////////////////////////////////////////////////////////////////////////// RenderPolyPortal::RenderPolyPortal() @@ -185,7 +188,7 @@ void RenderPolyPortal::RenderLine(subsector_t *sub, seg_t *line, sector_t *front } // Render wall, and update culling info if its an occlusion blocker - if (RenderPolyWall::RenderLine(WorldToClip, line, frontsector, subsectorDepth, StencilValue, SubsectorTranslucentWalls)) + if (RenderPolyWall::RenderLine(WorldToClip, line, frontsector, subsectorDepth, StencilValue, SubsectorTranslucentWalls, LinePortals)) { if (hasSegmentRange) Cull.MarkSegmentCulled(sx1, sx2); @@ -362,19 +365,144 @@ void PolyDrawSectorPortal::RestoreGlobals() ///////////////////////////////////////////////////////////////////////////// -PolyDrawLinePortal::PolyDrawLinePortal(line_t *src, line_t *dest, bool mirror) : Src(src), Dest(dest) +PolyDrawLinePortal::PolyDrawLinePortal(FLinePortal *portal) : Portal(portal) +{ + StencilValue = RenderPolyScene::Instance()->GetNextStencilValue(); +} + +PolyDrawLinePortal::PolyDrawLinePortal(line_t *mirror) : Mirror(mirror) { - // To do: do what R_EnterPortal and PortalDrawseg does - StencilValue = RenderPolyScene::Instance()->GetNextStencilValue(); } void PolyDrawLinePortal::Render(int portalDepth) { + SaveGlobals(); + + // To do: get this information from RenderPolyScene instead of duplicating the code.. + double radPitch = ViewPitch.Normalized180().Radians(); + double angx = cos(radPitch); + double angy = sin(radPitch) * glset.pixelstretch; + double alen = sqrt(angx*angx + angy*angy); + float adjustedPitch = (float)asin(angy / alen); + float adjustedViewAngle = (float)(ViewAngle - 90).Radians(); + float ratio = WidescreenRatio; + float fovratio = (WidescreenRatio >= 1.3f) ? 1.333333f : ratio; + float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(FieldOfView.Radians() / 2) / fovratio)).Degrees); + TriMatrix worldToView = + TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) * + TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) * + TriMatrix::scale(1.0f, glset.pixelstretch, 1.0f) * + TriMatrix::swapYZ() * + TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); + TriMatrix worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; + + RenderPortal.SetViewpoint(worldToClip, StencilValue); RenderPortal.Render(portalDepth); + + RestoreGlobals(); } void PolyDrawLinePortal::RenderTranslucent(int portalDepth) { + SaveGlobals(); RenderPortal.RenderTranslucent(portalDepth); + RestoreGlobals(); +} + +void PolyDrawLinePortal::SaveGlobals() +{ + savedextralight = extralight; + savedpos = ViewPos; + savedangle = ViewAngle; + savedcamera = camera; + savedsector = viewsector; + savedvisibility = camera ? camera->renderflags & RF_INVISIBLE : ActorRenderFlags::FromInt(0); + savedViewPath[0] = ViewPath[0]; + savedViewPath[1] = ViewPath[1]; + + if (Mirror) + { + DAngle startang = ViewAngle; + DVector3 startpos = ViewPos; + + vertex_t *v1 = Mirror->v1; + + // Reflect the current view behind the mirror. + if (Mirror->Delta().X == 0) + { // vertical mirror + ViewPos.X = v1->fX() - startpos.X + v1->fX(); + } + else if (Mirror->Delta().Y == 0) + { // horizontal mirror + ViewPos.Y = v1->fY() - startpos.Y + v1->fY(); + } + else + { // any mirror + vertex_t *v2 = Mirror->v2; + + double dx = v2->fX() - v1->fX(); + double dy = v2->fY() - v1->fY(); + double x1 = v1->fX(); + double y1 = v1->fY(); + double x = startpos.X; + double y = startpos.Y; + + // the above two cases catch len == 0 + double r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy); + + ViewPos.X = (x1 + r * dx) * 2 - x; + ViewPos.Y = (y1 + r * dy) * 2 - y; + } + ViewAngle = Mirror->Delta().Angle() * 2 - startang; + } + else + { + auto src = Portal->mOrigin; + auto dst = Portal->mDestination; + + P_TranslatePortalXY(src, ViewPos.X, ViewPos.Y); + P_TranslatePortalZ(src, ViewPos.Z); + P_TranslatePortalAngle(src, ViewAngle); + P_TranslatePortalXY(src, ViewPath[0].X, ViewPath[0].Y); + P_TranslatePortalXY(src, ViewPath[1].X, ViewPath[1].Y); + + if (!r_showviewer && camera && P_PointOnLineSidePrecise(ViewPath[0], dst) != P_PointOnLineSidePrecise(ViewPath[1], dst)) + { + double distp = (ViewPath[0] - ViewPath[1]).Length(); + if (distp > EQUAL_EPSILON) + { + double dist1 = (ViewPos - ViewPath[0]).Length(); + double dist2 = (ViewPos - ViewPath[1]).Length(); + + if (dist1 + dist2 < distp + 1) + { + camera->renderflags |= RF_INVISIBLE; + } + } + } + + /*if (Portal->mirror) + { + if (MirrorFlags & RF_XFLIP) MirrorFlags &= ~RF_XFLIP; + else MirrorFlags |= RF_XFLIP; + }*/ + } + + camera = nullptr; + //viewsector = Portal->mDestination; + R_SetViewAngle(); +} + +void PolyDrawLinePortal::RestoreGlobals() +{ + if (!savedvisibility && camera) camera->renderflags &= ~RF_INVISIBLE; + camera = savedcamera; + viewsector = savedsector; + ViewPos = savedpos; + extralight = savedextralight; + ViewAngle = savedangle; + ViewPath[0] = savedViewPath[0]; + ViewPath[1] = savedViewPath[1]; + R_SetViewAngle(); } diff --git a/src/r_poly_portal.h b/src/r_poly_portal.h index a53a185e3..e47277f32 100644 --- a/src/r_poly_portal.h +++ b/src/r_poly_portal.h @@ -127,7 +127,7 @@ public: void Render(int portalDepth); void RenderTranslucent(int portalDepth); - FSectorPortal *Portal; + FSectorPortal *Portal = nullptr; uint32_t StencilValue = 0; std::vector Shape; @@ -149,16 +149,28 @@ private: class PolyDrawLinePortal { public: - PolyDrawLinePortal(line_t *src, line_t *dest, bool mirror); + PolyDrawLinePortal(FLinePortal *portal); + PolyDrawLinePortal(line_t *mirror); void Render(int portalDepth); void RenderTranslucent(int portalDepth); + FLinePortal *Portal = nullptr; + line_t *Mirror = nullptr; uint32_t StencilValue = 0; std::vector Shape; private: - line_t *Src; - line_t *Dest; + void SaveGlobals(); + void RestoreGlobals(); + RenderPolyPortal RenderPortal; + + int savedextralight; + DVector3 savedpos; + DAngle savedangle; + AActor *savedcamera; + sector_t *savedsector; + ActorRenderFlags savedvisibility; + DVector3 savedViewPath[2]; }; diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index 8f3fb05d7..7484fd493 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -23,6 +23,9 @@ #include #include "templates.h" #include "doomdef.h" +#include "doomstat.h" +#include "doomdata.h" +#include "p_lnspec.h" #include "sbar.h" #include "r_data/r_translate.h" #include "r_poly_wall.h" @@ -30,8 +33,82 @@ #include "r_poly.h" #include "r_sky.h" // for skyflatnum -bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput) +EXTERN_CVAR(Bool, r_drawmirrors) + +bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals) { + PolyDrawLinePortal *polyportal = nullptr; + if (line->backsector == nullptr && line->sidedef == line->linedef->sidedef[0] && (line->linedef->special == Line_Mirror && r_drawmirrors)) + { + linePortals.push_back(std::make_unique(line->linedef)); + polyportal = linePortals.back().get(); + } + else if (line->linedef && line->linedef->isVisualPortal()) + { + FLinePortal *portal = line->linedef->getPortal(); + for (auto &p : linePortals) + { + if (p->Portal == portal) // To do: what other criterias do we need to check for? + { + polyportal = p.get(); + break; + } + } + if (!polyportal) + { + linePortals.push_back(std::make_unique(portal)); + polyportal = linePortals.back().get(); + } + } + + if (polyportal) + { + double ceil1 = frontsector->ceilingplane.ZatPoint(line->v1); + double floor1 = frontsector->floorplane.ZatPoint(line->v1); + double ceil2 = frontsector->ceilingplane.ZatPoint(line->v2); + double floor2 = frontsector->floorplane.ZatPoint(line->v2); + DVector2 v1 = line->v1->fPos(); + DVector2 v2 = line->v2->fPos(); + + TriVertex *vertices = PolyVertexBuffer::GetVertices(4); + if (!vertices) + return true; + + vertices[0].x = (float)v1.X; + vertices[0].y = (float)v1.Y; + vertices[0].z = (float)ceil1; + vertices[0].w = 1.0f; + + vertices[1].x = (float)v2.X; + vertices[1].y = (float)v2.Y; + vertices[1].z = (float)ceil2; + vertices[1].w = 1.0f; + + vertices[2].x = (float)v2.X; + vertices[2].y = (float)v2.Y; + vertices[2].z = (float)floor2; + vertices[2].w = 1.0f; + + vertices[3].x = (float)v1.X; + vertices[3].y = (float)v1.Y; + vertices[3].z = (float)floor1; + vertices[3].w = 1.0f; + + PolyDrawArgs args; + args.uniforms.flags = 0; + args.objectToClip = &worldToClip; + args.vinput = vertices; + args.vcount = 4; + args.mode = TriangleDrawMode::Fan; + args.ccw = true; + args.stenciltestvalue = stencilValue; + args.stencilwritevalue = polyportal->StencilValue; + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + + polyportal->Shape.push_back({ vertices, 4, true, subsectorDepth }); + return true; + } + RenderPolyWall wall; wall.LineSeg = line; wall.Line = line->linedef; diff --git a/src/r_poly_wall.h b/src/r_poly_wall.h index 3d2f89f84..31c236dd4 100644 --- a/src/r_poly_wall.h +++ b/src/r_poly_wall.h @@ -25,11 +25,12 @@ #include "r_poly_triangle.h" class PolyTranslucentObject; +class PolyDrawLinePortal; class RenderPolyWall { public: - static bool RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput); + static bool RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals); static void Render3DFloorLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput); void SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2); From 383a59259a5158761e4a26f491965d62d74b8c85 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 25 Nov 2016 21:02:18 -0500 Subject: [PATCH 1288/1509] Revert "Merge commit 'refs/pull/122/head' of https://github.com/coelckers/gzdoom" This reverts commit 71b4f57058eac07c38ce44b1eb057e8f40bd0701, reversing changes made to 449d4963ae23c20f3dc31fa1b6543a28e09e4946. --- src/c_cvars.cpp | 4 ---- src/c_cvars.h | 1 - src/p_acs.cpp | 20 -------------------- src/p_actionfunctions.cpp | 6 ------ src/posix/cocoa/i_video.mm | 2 +- src/posix/sdl/hardware.cpp | 2 +- src/win32/hardware.cpp | 2 +- 7 files changed, 3 insertions(+), 34 deletions(-) diff --git a/src/c_cvars.cpp b/src/c_cvars.cpp index 18648db28..c8f1ee4c6 100644 --- a/src/c_cvars.cpp +++ b/src/c_cvars.cpp @@ -52,10 +52,6 @@ #include "v_video.h" #include "colormatcher.h" -// [SP] Lets the player (arbitrator) choose whether to override GetCVar checks. -// Danger of desync? Can we just make it a client var? This probably *fixes* desyncs, actually... -CVAR(Bool, sv_overridegetcvar, true, CVAR_SERVERINFO | CVAR_GLOBALCONFIG | CVAR_ARCHIVE) - struct FLatchedValue { FBaseCVar *Variable; diff --git a/src/c_cvars.h b/src/c_cvars.h index d74d3b5c9..be7676e89 100644 --- a/src/c_cvars.h +++ b/src/c_cvars.h @@ -63,7 +63,6 @@ enum CVAR_NOSAVE = 4096, // when used with CVAR_SERVERINFO, do not save var to savegame CVAR_MOD = 8192, // cvar was defined by a mod CVAR_IGNORE = 16384,// do not send cvar across the network/inaccesible from ACS (dummy mod cvar) - CVAR_OVERRIDEGET = 32768,// this cvar disguises its return value for GetCVAR }; union UCVarValue diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 1d309307d..1a60a0c4f 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -4549,8 +4549,6 @@ static void DoSetCVar(FBaseCVar *cvar, int value, bool is_string, bool force=fal } } -EXTERN_CVAR(Bool, sv_overridegetcvar) - // Converts floating- to fixed-point as required. static int DoGetCVar(FBaseCVar *cvar, bool is_string) { @@ -4560,24 +4558,6 @@ static int DoGetCVar(FBaseCVar *cvar, bool is_string) { return 0; } - else if (sv_overridegetcvar && (cvar->GetFlags() & CVAR_OVERRIDEGET)) - { - if (is_string) - { - val = cvar->GetGenericRepDefault(CVAR_String); - return GlobalACSStrings.AddString(val.String); - } - else if (cvar->GetRealType() == CVAR_Float) - { - val = cvar->GetGenericRepDefault(CVAR_Float); - return DoubleToACS(val.Float); - } - else - { - val = cvar->GetGenericRepDefault(CVAR_Int); - return val.Int; - } - } else if (is_string) { val = cvar->GetGenericRep(CVAR_String); diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index df5852473..73cade49a 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -621,8 +621,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetCrouchFactor) // //========================================================================== -EXTERN_CVAR(Bool, sv_overridegetcvar) - DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetCVar) { if (numret > 0) @@ -636,10 +634,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetCVar) { ret->SetFloat(0); } - else if (sv_overridegetcvar && (cvar->GetFlags() & CVAR_OVERRIDEGET)) - { - ret->SetFloat(cvar->GetGenericRepDefault(CVAR_Float).Float); - } else { ret->SetFloat(cvar->GetGenericRep(CVAR_Float).Float); diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 8f8cdab84..5875e87b8 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -135,7 +135,7 @@ CUSTOM_CVAR(Bool, vid_autoswitch, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ static int s_currentRenderer; -CUSTOM_CVAR(Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL | CVAR_OVERRIDEGET) +CUSTOM_CVAR(Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 362fadc54..8fbb7c08a 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -67,7 +67,7 @@ void I_RestartRenderer(); int currentrenderer; // [ZDoomGL] -CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL | CVAR_OVERRIDEGET) +CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index cf1ec907e..609f56647 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -81,7 +81,7 @@ CUSTOM_CVAR(Bool, vid_used3d, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOIN } // [ZDoomGL] -CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL | CVAR_OVERRIDEGET) +CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer From 62188d1ea58707d6600608a3ae90501fe5fe1f95 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 26 Nov 2016 07:06:10 +0100 Subject: [PATCH 1289/1509] Change the line portal shape to be determined by the same code that decides the shape of other walls --- src/r_poly_portal.cpp | 61 ++++++++++++++++++++---- src/r_poly_portal.h | 1 + src/r_poly_wall.cpp | 106 +++++++++++++++--------------------------- src/r_poly_wall.h | 1 + 4 files changed, 91 insertions(+), 78 deletions(-) diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index e4ce5c547..715d47582 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -56,13 +56,7 @@ void RenderPolyPortal::Render(int portalDepth) ClearBuffers(); Cull.CullScene(WorldToClip); RenderSectors(); - if (portalDepth < r_portal_recursions) - { - for (auto &portal : SectorPortals) - portal->Render(portalDepth + 1); - for (auto &portal : LinePortals) - portal->Render(portalDepth + 1); - } + RenderPortals(portalDepth); } void RenderPolyPortal::ClearBuffers() @@ -195,6 +189,55 @@ void RenderPolyPortal::RenderLine(subsector_t *sub, seg_t *line, sector_t *front } } +void RenderPolyPortal::RenderPortals(int portalDepth) +{ + if (portalDepth < r_portal_recursions) + { + for (auto &portal : SectorPortals) + portal->Render(portalDepth + 1); + + for (auto &portal : LinePortals) + portal->Render(portalDepth + 1); + } + else // Fill with black + { + PolyDrawArgs args; + args.objectToClip = &WorldToClip; + args.mode = TriangleDrawMode::Fan; + args.uniforms.color = 0; + args.uniforms.light = 256; + args.uniforms.flags = TriUniforms::fixed_light; + + for (auto &portal : SectorPortals) + { + args.stenciltestvalue = portal->StencilValue; + args.stencilwritevalue = portal->StencilValue + 1; + for (const auto &verts : portal->Shape) + { + args.vinput = verts.Vertices; + args.vcount = verts.Count; + args.ccw = verts.Ccw; + args.uniforms.subsectorDepth = verts.SubsectorDepth; + PolyTriangleDrawer::draw(args, TriDrawVariant::FillNormal, TriBlendMode::Copy); + } + } + + for (auto &portal : LinePortals) + { + args.stenciltestvalue = portal->StencilValue; + args.stencilwritevalue = portal->StencilValue + 1; + for (const auto &verts : portal->Shape) + { + args.vinput = verts.Vertices; + args.vcount = verts.Count; + args.ccw = verts.Ccw; + args.uniforms.subsectorDepth = verts.SubsectorDepth; + PolyTriangleDrawer::draw(args, TriDrawVariant::FillNormal, TriBlendMode::Copy); + } + } + } +} + void RenderPolyPortal::RenderTranslucent(int portalDepth) { if (portalDepth < r_portal_recursions) @@ -236,7 +279,7 @@ void RenderPolyPortal::RenderTranslucent(int portalDepth) args.ccw = verts.Ccw; args.uniforms.subsectorDepth = verts.SubsectorDepth; PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy); - } + } } } @@ -490,7 +533,7 @@ void PolyDrawLinePortal::SaveGlobals() } camera = nullptr; - //viewsector = Portal->mDestination; + //viewsector = R_PointInSubsector(ViewPos)->sector; R_SetViewAngle(); } diff --git a/src/r_poly_portal.h b/src/r_poly_portal.h index e47277f32..56a125d2c 100644 --- a/src/r_poly_portal.h +++ b/src/r_poly_portal.h @@ -91,6 +91,7 @@ public: private: void ClearBuffers(); + void RenderPortals(int portalDepth); void RenderSectors(); void RenderSubsector(subsector_t *sub); void RenderLine(subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index 7484fd493..d6ade7279 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -61,54 +61,6 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, secto } } - if (polyportal) - { - double ceil1 = frontsector->ceilingplane.ZatPoint(line->v1); - double floor1 = frontsector->floorplane.ZatPoint(line->v1); - double ceil2 = frontsector->ceilingplane.ZatPoint(line->v2); - double floor2 = frontsector->floorplane.ZatPoint(line->v2); - DVector2 v1 = line->v1->fPos(); - DVector2 v2 = line->v2->fPos(); - - TriVertex *vertices = PolyVertexBuffer::GetVertices(4); - if (!vertices) - return true; - - vertices[0].x = (float)v1.X; - vertices[0].y = (float)v1.Y; - vertices[0].z = (float)ceil1; - vertices[0].w = 1.0f; - - vertices[1].x = (float)v2.X; - vertices[1].y = (float)v2.Y; - vertices[1].z = (float)ceil2; - vertices[1].w = 1.0f; - - vertices[2].x = (float)v2.X; - vertices[2].y = (float)v2.Y; - vertices[2].z = (float)floor2; - vertices[2].w = 1.0f; - - vertices[3].x = (float)v1.X; - vertices[3].y = (float)v1.Y; - vertices[3].z = (float)floor1; - vertices[3].w = 1.0f; - - PolyDrawArgs args; - args.uniforms.flags = 0; - args.objectToClip = &worldToClip; - args.vinput = vertices; - args.vcount = 4; - args.mode = TriangleDrawMode::Fan; - args.ccw = true; - args.stenciltestvalue = stencilValue; - args.stencilwritevalue = polyportal->StencilValue; - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); - - polyportal->Shape.push_back({ vertices, 4, true, subsectorDepth }); - return true; - } - RenderPolyWall wall; wall.LineSeg = line; wall.Line = line->linedef; @@ -132,6 +84,7 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, secto wall.BottomZ = frontfloorz1; wall.UnpeggedCeil = frontceilz1; wall.Texpart = side_t::mid; + wall.Polyportal = polyportal; wall.Render(worldToClip); return true; } @@ -182,20 +135,25 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, secto if (line->sidedef) { + wall.SetCoords(line->v1->fPos(), line->v2->fPos(), middleceilz1, middlefloorz1, middleceilz2, middlefloorz2); + wall.TopZ = middleceilz1; + wall.BottomZ = middlefloorz1; + wall.UnpeggedCeil = topceilz1; + wall.Texpart = side_t::mid; + wall.Masked = true; + FTexture *midtex = TexMan(line->sidedef->GetTexture(side_t::mid), true); if (midtex && midtex->UseType != FTexture::TEX_Null) - { - wall.SetCoords(line->v1->fPos(), line->v2->fPos(), middleceilz1, middlefloorz1, middleceilz2, middlefloorz2); - wall.TopZ = middleceilz1; - wall.BottomZ = middlefloorz1; - wall.UnpeggedCeil = topceilz1; - wall.Texpart = side_t::mid; - wall.Masked = true; translucentWallsOutput.push_back({ wall }); + + if (polyportal) + { + wall.Polyportal = polyportal; + wall.Render(worldToClip); } } } - return false; + return polyportal != nullptr; } void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput) @@ -234,11 +192,9 @@ void RenderPolyWall::SetCoords(const DVector2 &v1, const DVector2 &v2, double ce void RenderPolyWall::Render(const TriMatrix &worldToClip) { FTexture *tex = GetTexture(); - if (!tex) + if (!tex && !Polyportal) return; - PolyWallTextureCoords texcoords(tex, LineSeg, Line, Side, Texpart, TopZ, BottomZ, UnpeggedCeil); - TriVertex *vertices = PolyVertexBuffer::GetVertices(4); if (!vertices) return; @@ -247,29 +203,34 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) vertices[0].y = (float)v1.Y; vertices[0].z = (float)ceil1; vertices[0].w = 1.0f; - vertices[0].varying[0] = (float)texcoords.u1; - vertices[0].varying[1] = (float)texcoords.v1; vertices[1].x = (float)v2.X; vertices[1].y = (float)v2.Y; vertices[1].z = (float)ceil2; vertices[1].w = 1.0f; - vertices[1].varying[0] = (float)texcoords.u2; - vertices[1].varying[1] = (float)texcoords.v1; vertices[2].x = (float)v2.X; vertices[2].y = (float)v2.Y; vertices[2].z = (float)floor2; vertices[2].w = 1.0f; - vertices[2].varying[0] = (float)texcoords.u2; - vertices[2].varying[1] = (float)texcoords.v2; vertices[3].x = (float)v1.X; vertices[3].y = (float)v1.Y; vertices[3].z = (float)floor1; vertices[3].w = 1.0f; - vertices[3].varying[0] = (float)texcoords.u1; - vertices[3].varying[1] = (float)texcoords.v2; + + if (tex) + { + PolyWallTextureCoords texcoords(tex, LineSeg, Line, Side, Texpart, TopZ, BottomZ, UnpeggedCeil); + vertices[0].varying[0] = (float)texcoords.u1; + vertices[0].varying[1] = (float)texcoords.v1; + vertices[1].varying[0] = (float)texcoords.u2; + vertices[1].varying[1] = (float)texcoords.v1; + vertices[2].varying[0] = (float)texcoords.u2; + vertices[2].varying[1] = (float)texcoords.v2; + vertices[3].varying[0] = (float)texcoords.u1; + vertices[3].varying[1] = (float)texcoords.v2; + } // Masked walls clamp to the 0-1 range (no texture repeat) if (Masked) @@ -292,10 +253,17 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) args.ccw = true; args.stenciltestvalue = StencilValue; args.stencilwritevalue = StencilValue + 1; - args.SetTexture(tex); + if (tex) + args.SetTexture(tex); args.SetColormap(Line->frontsector->ColorMap); - if (!Masked) + if (Polyportal) + { + args.stencilwritevalue = Polyportal->StencilValue; + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + Polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, args.uniforms.subsectorDepth }); + } + else if (!Masked) { PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy); PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); diff --git a/src/r_poly_wall.h b/src/r_poly_wall.h index 31c236dd4..d1196df9f 100644 --- a/src/r_poly_wall.h +++ b/src/r_poly_wall.h @@ -54,6 +54,7 @@ public: bool Masked = false; uint32_t SubsectorDepth = 0; uint32_t StencilValue = 0; + PolyDrawLinePortal *Polyportal = nullptr; private: void ClampHeight(TriVertex &v1, TriVertex &v2); From 70181f41466243ea31818b60a94f61a302402582 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 26 Nov 2016 07:35:04 +0100 Subject: [PATCH 1290/1509] Always access args.uniforms directly instead of first creating a TriUniforms variable --- src/r_poly_particle.cpp | 23 +++++++++++------------ src/r_poly_plane.cpp | 24 ++++++++++-------------- src/r_poly_sky.cpp | 9 +++------ src/r_poly_wall.cpp | 9 +++------ src/r_poly_wallsprite.cpp | 14 ++++++-------- 5 files changed, 33 insertions(+), 46 deletions(-) diff --git a/src/r_poly_particle.cpp b/src/r_poly_particle.cpp index e69803e1e..8151d4888 100644 --- a/src/r_poly_particle.cpp +++ b/src/r_poly_particle.cpp @@ -70,33 +70,32 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *partic // int color = (particle->color >> 24) & 0xff; // pal index, I think bool fullbrightSprite = particle->bright != 0; - TriUniforms uniforms; + PolyDrawArgs args; + if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) { - uniforms.light = 256; - uniforms.flags = TriUniforms::fixed_light; + args.uniforms.light = 256; + args.uniforms.flags = TriUniforms::fixed_light; } else { - uniforms.light = (uint32_t)((sub->sector->lightlevel + actualextralight) / 255.0f * 256.0f); - uniforms.flags = 0; + args.uniforms.light = (uint32_t)((sub->sector->lightlevel + actualextralight) / 255.0f * 256.0f); + args.uniforms.flags = 0; } - uniforms.subsectorDepth = subsectorDepth; + args.uniforms.subsectorDepth = subsectorDepth; if (r_swtruecolor) { uint32_t alpha = particle->trans; - uniforms.color = (alpha << 24) | (particle->color & 0xffffff); + args.uniforms.color = (alpha << 24) | (particle->color & 0xffffff); } else { - uniforms.color = ((uint32_t)particle->color) >> 24; - uniforms.srcalpha = particle->trans; - uniforms.destalpha = 255 - particle->trans; + args.uniforms.color = ((uint32_t)particle->color) >> 24; + args.uniforms.srcalpha = particle->trans; + args.uniforms.destalpha = 255 - particle->trans; } - PolyDrawArgs args; - args.uniforms = uniforms; args.objectToClip = &worldToClip; args.vinput = vertices; args.vcount = 4; diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index e64d085e7..8d4067be0 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -103,12 +103,12 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *s lightlevel = *light->p_lightlevel; } - TriUniforms uniforms; - uniforms.light = (uint32_t)(lightlevel / 255.0f * 256.0f); + PolyDrawArgs args; + args.uniforms.light = (uint32_t)(lightlevel / 255.0f * 256.0f); if (fixedlightlev >= 0 || fixedcolormap) - uniforms.light = 256; - uniforms.flags = 0; - uniforms.subsectorDepth = subsectorDepth; + args.uniforms.light = 256; + args.uniforms.flags = 0; + args.uniforms.subsectorDepth = subsectorDepth; TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); if (!vertices) @@ -131,8 +131,6 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *s } } - PolyDrawArgs args; - args.uniforms = uniforms; args.objectToClip = &worldToClip; args.vinput = vertices; args.vcount = sub->numlines; @@ -217,12 +215,12 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin bool isSky = picnum == skyflatnum; - TriUniforms uniforms; - uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f); + PolyDrawArgs args; + args.uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f); if (fixedlightlev >= 0 || fixedcolormap) - uniforms.light = 256; - uniforms.flags = 0; - uniforms.subsectorDepth = isSky ? RenderPolyPortal::SkySubsectorDepth : subsectorDepth; + args.uniforms.light = 256; + args.uniforms.flags = 0; + args.uniforms.subsectorDepth = isSky ? RenderPolyPortal::SkySubsectorDepth : subsectorDepth; TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); if (!vertices) @@ -245,8 +243,6 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin } } - PolyDrawArgs args; - args.uniforms = uniforms; args.objectToClip = &worldToClip; args.vinput = vertices; args.vcount = sub->numlines; diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp index ad8d4b861..97f8203fa 100644 --- a/src/r_poly_sky.cpp +++ b/src/r_poly_sky.cpp @@ -50,15 +50,12 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z); objectToClip = worldToClip * objectToWorld; - TriUniforms uniforms; - uniforms.light = 256; - uniforms.flags = 0; - uniforms.subsectorDepth = RenderPolyPortal::SkySubsectorDepth; - int rc = mRows + 1; PolyDrawArgs args; - args.uniforms = uniforms; + args.uniforms.light = 256; + args.uniforms.flags = 0; + args.uniforms.subsectorDepth = RenderPolyPortal::SkySubsectorDepth; args.objectToClip = &objectToClip; args.stenciltestvalue = 255; args.stencilwritevalue = 255; diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index d6ade7279..6e09faa8a 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -239,13 +239,10 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) ClampHeight(vertices[1], vertices[2]); } - TriUniforms uniforms; - uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f); - uniforms.flags = 0; - uniforms.subsectorDepth = SubsectorDepth; - PolyDrawArgs args; - args.uniforms = uniforms; + args.uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f); + args.uniforms.flags = 0; + args.uniforms.subsectorDepth = SubsectorDepth; args.objectToClip = &worldToClip; args.vinput = vertices; args.vcount = 4; diff --git a/src/r_poly_wallsprite.cpp b/src/r_poly_wallsprite.cpp index 553235957..c8e0abcc4 100644 --- a/src/r_poly_wallsprite.cpp +++ b/src/r_poly_wallsprite.cpp @@ -98,21 +98,19 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, AActor *thing, s bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT)); - TriUniforms uniforms; + PolyDrawArgs args; if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) { - uniforms.light = 256; - uniforms.flags = TriUniforms::fixed_light; + args.uniforms.light = 256; + args.uniforms.flags = TriUniforms::fixed_light; } else { - uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f); - uniforms.flags = 0; + args.uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f); + args.uniforms.flags = 0; } - uniforms.subsectorDepth = subsectorDepth; + args.uniforms.subsectorDepth = subsectorDepth; - PolyDrawArgs args; - args.uniforms = uniforms; args.objectToClip = &worldToClip; args.vinput = vertices; args.vcount = 4; From 8bbb63e91328d37a0f3df8240a7c089f25f03eb5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 26 Nov 2016 09:01:58 +0100 Subject: [PATCH 1291/1509] Add portal plane clipping --- src/r_poly.cpp | 2 +- src/r_poly_cull.cpp | 12 +++++++++++- src/r_poly_cull.h | 3 ++- src/r_poly_intersection.h | 11 +++++++++++ src/r_poly_portal.cpp | 16 ++++++++++++---- src/r_poly_portal.h | 3 ++- 6 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 729774174..b262ca01d 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -44,7 +44,7 @@ void RenderPolyScene::Render() ClearBuffers(); SetSceneViewport(); SetupPerspectiveMatrix(); - MainPortal.SetViewpoint(WorldToClip, GetNextStencilValue()); + MainPortal.SetViewpoint(WorldToClip, Vec4f(0.0f), GetNextStencilValue()); MainPortal.Render(0); Skydome.Render(WorldToClip); MainPortal.RenderTranslucent(0); diff --git a/src/r_poly_cull.cpp b/src/r_poly_cull.cpp index 04d5c3c24..37ddf9103 100644 --- a/src/r_poly_cull.cpp +++ b/src/r_poly_cull.cpp @@ -28,11 +28,12 @@ #include "r_poly_cull.h" #include "r_poly.h" -void PolyCull::CullScene(const TriMatrix &worldToClip) +void PolyCull::CullScene(const TriMatrix &worldToClip, const Vec4f &portalClipPlane) { ClearSolidSegments(); PvsSectors.clear(); frustumPlanes = FrustumPlanes(worldToClip); + PortalClipPlane = portalClipPlane; // Cull front to back MaxCeilingHeight = 0.0; @@ -174,6 +175,11 @@ bool PolyCull::CheckBBox(float *bspcoord) if (result == IntersectionTest::outside) return false; + // Skip if its in front of the portal: + + if (PortalClipPlane != Vec4f(0.0f) && IntersectionTest::plane_aabb(PortalClipPlane, aabb) == IntersectionTest::outside) + return false; + // Occlusion test using solid segments: static const int lines[4][4] = @@ -219,6 +225,10 @@ bool PolyCull::GetSegmentRangeForLine(double x1, double y1, double x2, double y2 { double znear = 5.0; + // Cull if entirely behind the portal clip plane (tbd: should we clip the segment?) + if (Vec4f::dot(PortalClipPlane, Vec4f((float)x1, (float)y1, 0.0f, 1.0f)) < 0.0f && Vec4f::dot(PortalClipPlane, Vec4f((float)x2, (float)y2, 0.0f, 1.0f)) < 0.0f) + return false; + // Transform to 2D view space: x1 = x1 - ViewPos.X; y1 = y1 - ViewPos.Y; diff --git a/src/r_poly_cull.h b/src/r_poly_cull.h index e011ef583..f1fe56ed5 100644 --- a/src/r_poly_cull.h +++ b/src/r_poly_cull.h @@ -28,7 +28,7 @@ class PolyCull { public: - void CullScene(const TriMatrix &worldToClip); + void CullScene(const TriMatrix &worldToClip, const Vec4f &portalClipPlane); bool GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const; void MarkSegmentCulled(int x1, int x2); @@ -59,4 +59,5 @@ private: const int SolidCullScale = 3000; FrustumPlanes frustumPlanes; + Vec4f PortalClipPlane; }; diff --git a/src/r_poly_intersection.h b/src/r_poly_intersection.h index b06bc1200..2ce164e5e 100644 --- a/src/r_poly_intersection.h +++ b/src/r_poly_intersection.h @@ -26,6 +26,8 @@ #include #include +class Vec3f; + class Vec4f { public: @@ -33,6 +35,7 @@ public: Vec4f(const Vec4f &) = default; Vec4f(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) { } Vec4f(float v) : x(v), y(v), z(v), w(v) { } + Vec4f(const Vec3f &xyz, float w); static float dot(const Vec4f &a, const Vec4f &b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } static float dot3(const Vec4f &a, const Vec4f &b) { return a.x * b.x + a.y * b.y + a.z * b.z; } @@ -51,6 +54,9 @@ public: float x, y, z, w; }; +inline bool operator==(const Vec4f &a, const Vec4f &b) { return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w; } +inline bool operator!=(const Vec4f &a, const Vec4f &b) { return a.x != b.x || a.y != b.y || a.z != b.z || a.w == b.w; } + class Vec3f { public: @@ -75,6 +81,9 @@ public: float x, y, z; }; +inline bool operator==(const Vec3f &a, const Vec3f &b) { return a.x == b.x && a.y == b.y && a.z == b.z; } +inline bool operator!=(const Vec3f &a, const Vec3f &b) { return a.x != b.x || a.y != b.y || a.z != b.z; } + inline Vec3f operator+(const Vec3f &a, const Vec3f &b) { return Vec3f(a.x + b.x, a.y + b.y, a.z + b.z); } inline Vec3f operator-(const Vec3f &a, const Vec3f &b) { return Vec3f(a.x - b.x, a.y - b.y, a.z - b.z); } inline Vec3f operator*(const Vec3f &a, const Vec3f &b) { return Vec3f(a.x * b.x, a.y * b.y, a.z * b.z); } @@ -90,6 +99,8 @@ inline Vec3f operator-(float a, const Vec3f &b) { return Vec3f(a - b.x, a - b.y, inline Vec3f operator*(float a, const Vec3f &b) { return Vec3f(a * b.x, a * b.y, a * b.z); } inline Vec3f operator/(float a, const Vec3f &b) { return Vec3f(a / b.x, a / b.y, a / b.z); } +inline Vec4f::Vec4f(const Vec3f &xyz, float w) : x(xyz.x), y(xyz.y), z(xyz.z), w(w) { } + typedef TriMatrix Mat4f; class AxisAlignedBoundingBox diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 715d47582..757285d77 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -45,16 +45,17 @@ RenderPolyPortal::~RenderPolyPortal() { } -void RenderPolyPortal::SetViewpoint(const TriMatrix &worldToClip, uint32_t stencilValue) +void RenderPolyPortal::SetViewpoint(const TriMatrix &worldToClip, const Vec4f &portalPlane, uint32_t stencilValue) { WorldToClip = worldToClip; StencilValue = stencilValue; + PortalPlane = portalPlane; } void RenderPolyPortal::Render(int portalDepth) { ClearBuffers(); - Cull.CullScene(WorldToClip); + Cull.CullScene(WorldToClip, PortalPlane); RenderSectors(); RenderPortals(portalDepth); } @@ -340,7 +341,7 @@ void PolyDrawSectorPortal::Render(int portalDepth) TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); TriMatrix worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; - RenderPortal.SetViewpoint(worldToClip, StencilValue); + RenderPortal.SetViewpoint(worldToClip, Vec4f(0.0f), StencilValue); RenderPortal.Render(portalDepth); RestoreGlobals(); @@ -440,7 +441,14 @@ void PolyDrawLinePortal::Render(int portalDepth) TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); TriMatrix worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; - RenderPortal.SetViewpoint(worldToClip, StencilValue); + // Calculate plane clipping + DVector2 planePos = Portal->mDestination->v1->fPos(); + DVector2 planeNormal = (Portal->mDestination->v2->fPos() - Portal->mDestination->v1->fPos()).Rotated90CW(); + planeNormal.MakeUnit(); + double planeD = -(planeNormal | (planePos + planeNormal * 5.0)); + Vec4f portalPlane((float)planeNormal.X, (float)planeNormal.Y, 0.0f, (float)planeD); + + RenderPortal.SetViewpoint(worldToClip, portalPlane, StencilValue); RenderPortal.Render(portalDepth); RestoreGlobals(); diff --git a/src/r_poly_portal.h b/src/r_poly_portal.h index 56a125d2c..e2b131b32 100644 --- a/src/r_poly_portal.h +++ b/src/r_poly_portal.h @@ -83,7 +83,7 @@ class RenderPolyPortal public: RenderPolyPortal(); ~RenderPolyPortal(); - void SetViewpoint(const TriMatrix &worldToClip, uint32_t stencilValue); + void SetViewpoint(const TriMatrix &worldToClip, const Vec4f &portalPlane, uint32_t stencilValue); void Render(int portalDepth); void RenderTranslucent(int portalDepth); @@ -99,6 +99,7 @@ private: SpriteRange GetSpritesForSector(sector_t *sector); TriMatrix WorldToClip; + Vec4f PortalPlane; uint32_t StencilValue = 0; PolyCull Cull; uint32_t NextSubsectorDepth = 0; From c37ce1fdbc57bb788ce7e2f950edc4a444cd58ed Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 26 Nov 2016 10:49:29 +0100 Subject: [PATCH 1292/1509] Add plane clipping to the triangle drawer --- src/r_compiler/llvmdrawers.h | 20 ---------- src/r_poly.cpp | 2 +- src/r_poly_cull.cpp | 2 +- src/r_poly_decal.cpp | 7 ++-- src/r_poly_decal.h | 6 ++- src/r_poly_particle.cpp | 3 +- src/r_poly_particle.h | 4 +- src/r_poly_plane.cpp | 16 ++++---- src/r_poly_plane.h | 7 ++-- src/r_poly_portal.cpp | 21 +++++----- src/r_poly_sky.cpp | 1 + src/r_poly_sprite.cpp | 4 +- src/r_poly_sprite.h | 4 +- src/r_poly_triangle.cpp | 74 ++++++++++++++++++++---------------- src/r_poly_triangle.h | 41 ++++++++++++++++++-- src/r_poly_wall.cpp | 19 ++++----- src/r_poly_wall.h | 7 ++-- src/r_poly_wallsprite.cpp | 3 +- src/r_poly_wallsprite.h | 4 +- 19 files changed, 146 insertions(+), 99 deletions(-) diff --git a/src/r_compiler/llvmdrawers.h b/src/r_compiler/llvmdrawers.h index 4ce3a3a03..c5eb96f4c 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_compiler/llvmdrawers.h @@ -191,26 +191,6 @@ struct TriVertex float varying[NumVarying]; }; -struct TriMatrix -{ - static TriMatrix null(); - static TriMatrix identity(); - static TriMatrix translate(float x, float y, float z); - static TriMatrix scale(float x, float y, float z); - static TriMatrix rotate(float angle, float x, float y, float z); - static TriMatrix swapYZ(); - static TriMatrix perspective(float fovy, float aspect, float near, float far); - static TriMatrix frustum(float left, float right, float bottom, float top, float near, float far); - - static TriMatrix worldToView(); // Software renderer world to view space transform - static TriMatrix viewToClip(); // Software renderer shearing projection - - TriVertex operator*(TriVertex v) const; - TriMatrix operator*(const TriMatrix &m) const; - - float matrix[16]; -}; - struct TriUniforms { uint32_t light; diff --git a/src/r_poly.cpp b/src/r_poly.cpp index b262ca01d..186077806 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -44,7 +44,7 @@ void RenderPolyScene::Render() ClearBuffers(); SetSceneViewport(); SetupPerspectiveMatrix(); - MainPortal.SetViewpoint(WorldToClip, Vec4f(0.0f), GetNextStencilValue()); + MainPortal.SetViewpoint(WorldToClip, Vec4f(0.0f, 0.0f, 0.0f, 1.0f), GetNextStencilValue()); MainPortal.Render(0); Skydome.Render(WorldToClip); MainPortal.RenderTranslucent(0); diff --git a/src/r_poly_cull.cpp b/src/r_poly_cull.cpp index 37ddf9103..9ee71c28a 100644 --- a/src/r_poly_cull.cpp +++ b/src/r_poly_cull.cpp @@ -177,7 +177,7 @@ bool PolyCull::CheckBBox(float *bspcoord) // Skip if its in front of the portal: - if (PortalClipPlane != Vec4f(0.0f) && IntersectionTest::plane_aabb(PortalClipPlane, aabb) == IntersectionTest::outside) + if (IntersectionTest::plane_aabb(PortalClipPlane, aabb) == IntersectionTest::outside) return false; // Occlusion test using solid segments: diff --git a/src/r_poly_decal.cpp b/src/r_poly_decal.cpp index ded64a095..9d47c014a 100644 --- a/src/r_poly_decal.cpp +++ b/src/r_poly_decal.cpp @@ -29,7 +29,7 @@ #include "r_poly.h" #include "a_sharedglobal.h" -void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue) +void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const Vec4f &clipPlane, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue) { if (line->linedef == nullptr && line->sidedef == nullptr) return; @@ -37,11 +37,11 @@ void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const seg_t for (DBaseDecal *decal = line->sidedef->AttachedDecals; decal != nullptr; decal = decal->WallNext) { RenderPolyDecal render; - render.Render(worldToClip, decal, line, subsectorDepth, stencilValue); + render.Render(worldToClip, clipPlane, decal, line, subsectorDepth, stencilValue); } } -void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue) +void RenderPolyDecal::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue) { if (decal->RenderFlags & RF_INVISIBLE || !viewactive || !decal->PicNum.isValid()) return; @@ -166,5 +166,6 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, DBaseDecal *decal, co args.stenciltestvalue = stencilValue; args.stencilwritevalue = stencilValue; //mode = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); + args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Shaded); } diff --git a/src/r_poly_decal.h b/src/r_poly_decal.h index c836a0cd7..068887d90 100644 --- a/src/r_poly_decal.h +++ b/src/r_poly_decal.h @@ -24,11 +24,13 @@ #include "r_poly_triangle.h" +class Vec4f; + class RenderPolyDecal { public: - static void RenderWallDecals(const TriMatrix &worldToClip, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue); + static void RenderWallDecals(const TriMatrix &worldToClip, const Vec4f &clipPlane, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue); private: - void Render(const TriMatrix &worldToClip, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue); + void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue); }; diff --git a/src/r_poly_particle.cpp b/src/r_poly_particle.cpp index 8151d4888..73e1819d4 100644 --- a/src/r_poly_particle.cpp +++ b/src/r_poly_particle.cpp @@ -28,7 +28,7 @@ #include "r_poly_particle.h" #include "r_poly.h" -void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) +void RenderPolyParticle::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) { DVector3 pos = particle->Pos; double psize = particle->size / 8.0; @@ -104,5 +104,6 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *partic args.stenciltestvalue = stencilValue; args.stencilwritevalue = stencilValue; args.SetColormap(sub->sector->ColorMap); + args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector, TriBlendMode::AlphaBlend); } diff --git a/src/r_poly_particle.h b/src/r_poly_particle.h index 3fbb2d2ab..fd581fa83 100644 --- a/src/r_poly_particle.h +++ b/src/r_poly_particle.h @@ -25,8 +25,10 @@ #include "r_poly_triangle.h" #include "p_effect.h" +class Vec4f; + class RenderPolyParticle { public: - void Render(const TriMatrix &worldToClip, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); + void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); }; diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 8d4067be0..76ede6960 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -32,7 +32,7 @@ EXTERN_CVAR(Int, r_3dfloors) -void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals) +void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals) { RenderPolyPlane plane; @@ -58,7 +58,7 @@ void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, subsector_t *su double fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->centerspot); if (fakeHeight < ViewPos.Z && fakeHeight > frontsector->floorplane.ZatPoint(frontsector->centerspot)) { - plane.Render3DFloor(worldToClip, sub, subsectorDepth, stencilValue, false, fakeFloor); + plane.Render3DFloor(worldToClip, clipPlane, sub, subsectorDepth, stencilValue, false, fakeFloor); } } @@ -79,16 +79,16 @@ void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, subsector_t *su double fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot); if (fakeHeight > ViewPos.Z && fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->centerspot)) { - plane.Render3DFloor(worldToClip, sub, subsectorDepth, stencilValue, true, fakeFloor); + plane.Render3DFloor(worldToClip, clipPlane, sub, subsectorDepth, stencilValue, true, fakeFloor); } } } - plane.Render(worldToClip, sub, subsectorDepth, stencilValue, true, skyCeilingHeight, sectorPortals); - plane.Render(worldToClip, sub, subsectorDepth, stencilValue, false, skyFloorHeight, sectorPortals); + plane.Render(worldToClip, clipPlane, sub, subsectorDepth, stencilValue, true, skyCeilingHeight, sectorPortals); + plane.Render(worldToClip, clipPlane, sub, subsectorDepth, stencilValue, false, skyFloorHeight, sectorPortals); } -void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakeFloor) +void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakeFloor) { FTextureID picnum = ceiling ? *fakeFloor->bottom.texture : *fakeFloor->top.texture; FTexture *tex = TexMan(picnum); @@ -140,11 +140,12 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *s args.stencilwritevalue = stencilValue + 1; args.SetTexture(tex); args.SetColormap(sub->sector->ColorMap); + args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy); PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); } -void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals) +void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals) { FSectorPortal *portal = sub->sector->ValidatePortal(ceiling ? sector_t::ceiling : sector_t::floor); PolyDrawSectorPortal *polyportal = nullptr; @@ -251,6 +252,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin args.stenciltestvalue = stencilValue; args.stencilwritevalue = stencilValue + 1; args.SetColormap(frontsector->ColorMap); + args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); if (!isSky) { diff --git a/src/r_poly_plane.h b/src/r_poly_plane.h index 6e418bf50..3006ce86b 100644 --- a/src/r_poly_plane.h +++ b/src/r_poly_plane.h @@ -25,14 +25,15 @@ #include "r_poly_triangle.h" class PolyDrawSectorPortal; +class Vec4f; class RenderPolyPlane { public: - static void RenderPlanes(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals); + static void RenderPlanes(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals); private: - void Render3DFloor(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakefloor); - void Render(const TriMatrix &worldToClip, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals); + void Render3DFloor(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakefloor); + void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals); TriVertex PlaneVertex(vertex_t *v1, double height); }; diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 757285d77..3257afc70 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -94,7 +94,7 @@ void RenderPolyPortal::RenderSubsector(subsector_t *sub) if (sub->sector->CenterFloor() != sub->sector->CenterCeiling()) { - RenderPolyPlane::RenderPlanes(WorldToClip, sub, subsectorDepth, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, SectorPortals); + RenderPolyPlane::RenderPlanes(WorldToClip, PortalPlane, sub, subsectorDepth, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, SectorPortals); } for (uint32_t i = 0; i < sub->numlines; i++) @@ -178,12 +178,12 @@ void RenderPolyPortal::RenderLine(subsector_t *sub, seg_t *line, sector_t *front if (!(fakeFloor->flags & FF_EXISTS)) continue; if (!(fakeFloor->flags & FF_RENDERPLANES)) continue; if (!fakeFloor->model) continue; - RenderPolyWall::Render3DFloorLine(WorldToClip, line, frontsector, subsectorDepth, StencilValue, fakeFloor, SubsectorTranslucentWalls); + RenderPolyWall::Render3DFloorLine(WorldToClip, PortalPlane, line, frontsector, subsectorDepth, StencilValue, fakeFloor, SubsectorTranslucentWalls); } } // Render wall, and update culling info if its an occlusion blocker - if (RenderPolyWall::RenderLine(WorldToClip, line, frontsector, subsectorDepth, StencilValue, SubsectorTranslucentWalls, LinePortals)) + if (RenderPolyWall::RenderLine(WorldToClip, PortalPlane, line, frontsector, subsectorDepth, StencilValue, SubsectorTranslucentWalls, LinePortals)) { if (hasSegmentRange) Cull.MarkSegmentCulled(sx1, sx2); @@ -208,6 +208,7 @@ void RenderPolyPortal::RenderPortals(int portalDepth) args.uniforms.color = 0; args.uniforms.light = 256; args.uniforms.flags = TriUniforms::fixed_light; + args.SetClipPlane(PortalPlane.x, PortalPlane.y, PortalPlane.z, PortalPlane.w); for (auto &portal : SectorPortals) { @@ -253,6 +254,7 @@ void RenderPolyPortal::RenderTranslucent(int portalDepth) args.mode = TriangleDrawMode::Fan; args.stenciltestvalue = portal->StencilValue + 1; args.stencilwritevalue = StencilValue; + args.SetClipPlane(PortalPlane.x, PortalPlane.y, PortalPlane.z, PortalPlane.w); for (const auto &verts : portal->Shape) { args.vinput = verts.Vertices; @@ -273,6 +275,7 @@ void RenderPolyPortal::RenderTranslucent(int portalDepth) args.mode = TriangleDrawMode::Fan; args.stenciltestvalue = portal->StencilValue + 1; args.stencilwritevalue = StencilValue; + args.SetClipPlane(PortalPlane.x, PortalPlane.y, PortalPlane.z, PortalPlane.w); for (const auto &verts : portal->Shape) { args.vinput = verts.Vertices; @@ -290,21 +293,21 @@ void RenderPolyPortal::RenderTranslucent(int portalDepth) if (obj.particle) { RenderPolyParticle spr; - spr.Render(WorldToClip, obj.particle, obj.sub, obj.subsectorDepth, StencilValue + 1); + spr.Render(WorldToClip, PortalPlane, obj.particle, obj.sub, obj.subsectorDepth, StencilValue + 1); } else if (!obj.thing) { - obj.wall.Render(WorldToClip); + obj.wall.Render(WorldToClip, PortalPlane); } else if ((obj.thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) { RenderPolyWallSprite wallspr; - wallspr.Render(WorldToClip, obj.thing, obj.sub, obj.subsectorDepth, StencilValue + 1); + wallspr.Render(WorldToClip, PortalPlane, obj.thing, obj.sub, obj.subsectorDepth, StencilValue + 1); } else { RenderPolySprite spr; - spr.Render(WorldToClip, obj.thing, obj.sub, obj.subsectorDepth, StencilValue + 1); + spr.Render(WorldToClip, PortalPlane, obj.thing, obj.sub, obj.subsectorDepth, StencilValue + 1); } } } @@ -341,7 +344,7 @@ void PolyDrawSectorPortal::Render(int portalDepth) TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); TriMatrix worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; - RenderPortal.SetViewpoint(worldToClip, Vec4f(0.0f), StencilValue); + RenderPortal.SetViewpoint(worldToClip, Vec4f(0.0f, 0.0f, 0.0f, 1.0f), StencilValue); RenderPortal.Render(portalDepth); RestoreGlobals(); @@ -445,7 +448,7 @@ void PolyDrawLinePortal::Render(int portalDepth) DVector2 planePos = Portal->mDestination->v1->fPos(); DVector2 planeNormal = (Portal->mDestination->v2->fPos() - Portal->mDestination->v1->fPos()).Rotated90CW(); planeNormal.MakeUnit(); - double planeD = -(planeNormal | (planePos + planeNormal * 5.0)); + double planeD = -(planeNormal | (planePos + planeNormal * 0.001)); Vec4f portalPlane((float)planeNormal.X, (float)planeNormal.Y, 0.0f, (float)planeD); RenderPortal.SetViewpoint(worldToClip, portalPlane, StencilValue); diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp index 97f8203fa..c0a219c79 100644 --- a/src/r_poly_sky.cpp +++ b/src/r_poly_sky.cpp @@ -61,6 +61,7 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) args.stencilwritevalue = 255; args.SetTexture(frontskytex); args.SetColormap(&NormalLight); + args.SetClipPlane(0.0f, 0.0f, 0.0f, 0.0f); RenderCapColorRow(args, frontskytex, 0, false); RenderCapColorRow(args, frontskytex, rc, true); diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index 0bacd6eb2..edb46c460 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -27,11 +27,12 @@ #include "r_data/r_translate.h" #include "r_poly_sprite.h" #include "r_poly.h" +#include "r_poly_intersection.h" EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Int, r_drawfuzz) -void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) +void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) { if (IsThingCulled(thing)) return; @@ -138,6 +139,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse args.stencilwritevalue = stencilValue; args.SetTexture(tex, thing->Translation); args.SetColormap(sub->sector->ColorMap); + args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); TriBlendMode blendmode; diff --git a/src/r_poly_sprite.h b/src/r_poly_sprite.h index e23d0d09d..04b0fcb94 100644 --- a/src/r_poly_sprite.h +++ b/src/r_poly_sprite.h @@ -24,10 +24,12 @@ #include "r_poly_triangle.h" +class Vec4f; + class RenderPolySprite { public: - void Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); + void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); static bool IsThingCulled(AActor *thing); static FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 298c5f024..f08d060e8 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -119,34 +119,34 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian const TriVertex *vinput = drawargs.vinput; int vcount = drawargs.vcount; - TriVertex vert[3]; + ShadedTriVertex vert[3]; if (drawargs.mode == TriangleDrawMode::Normal) { for (int i = 0; i < vcount / 3; i++) { for (int j = 0; j < 3; j++) - vert[j] = shade_vertex(*drawargs.objectToClip, *(vinput++)); + vert[j] = shade_vertex(*drawargs.objectToClip, drawargs.clipPlane, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); } } else if (drawargs.mode == TriangleDrawMode::Fan) { - vert[0] = shade_vertex(*drawargs.objectToClip, *(vinput++)); - vert[1] = shade_vertex(*drawargs.objectToClip, *(vinput++)); + vert[0] = shade_vertex(*drawargs.objectToClip, drawargs.clipPlane, *(vinput++)); + vert[1] = shade_vertex(*drawargs.objectToClip, drawargs.clipPlane, *(vinput++)); for (int i = 2; i < vcount; i++) { - vert[2] = shade_vertex(*drawargs.objectToClip, *(vinput++)); + vert[2] = shade_vertex(*drawargs.objectToClip, drawargs.clipPlane, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); vert[1] = vert[2]; } } else // TriangleDrawMode::Strip { - vert[0] = shade_vertex(*drawargs.objectToClip, *(vinput++)); - vert[1] = shade_vertex(*drawargs.objectToClip, *(vinput++)); + vert[0] = shade_vertex(*drawargs.objectToClip, drawargs.clipPlane, *(vinput++)); + vert[1] = shade_vertex(*drawargs.objectToClip, drawargs.clipPlane, *(vinput++)); for (int i = 2; i < vcount; i++) { - vert[2] = shade_vertex(*drawargs.objectToClip, *(vinput++)); + vert[2] = shade_vertex(*drawargs.objectToClip, drawargs.clipPlane, *(vinput++)); draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); vert[0] = vert[1]; vert[1] = vert[2]; @@ -155,13 +155,18 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian } } -TriVertex PolyTriangleDrawer::shade_vertex(const TriMatrix &objectToClip, TriVertex v) +ShadedTriVertex PolyTriangleDrawer::shade_vertex(const TriMatrix &objectToClip, const float *clipPlane, const TriVertex &v) { // Apply transform to get clip coordinates: - return objectToClip * v; + ShadedTriVertex sv = objectToClip * v; + + // Calculate gl_ClipDistance[0] + sv.clipDistance0 = v.x * clipPlane[0] + v.y * clipPlane[1] + v.z * clipPlane[2] + v.w * clipPlane[3]; + + return sv; } -void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *)) +void PolyTriangleDrawer::draw_shaded_triangle(const ShadedTriVertex *vert, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *)) { // Cull, clip and generate additional vertices as needed TriVertex clippedvert[max_additional_vertices]; @@ -225,7 +230,7 @@ bool PolyTriangleDrawer::cullhalfspace(float clipdistance1, float clipdistance2, return false; } -void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert) +void PolyTriangleDrawer::clipedge(const ShadedTriVertex *verts, TriVertex *clippedvert, int &numclipvert) { // Clip and cull so that the following is true for all vertices: // -v.w <= v.x <= v.w @@ -243,16 +248,18 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert } // halfspace clip distances - float clipdistance[6 * 3]; + static const int numclipdistances = 7; + float clipdistance[numclipdistances * 3]; for (int i = 0; i < 3; i++) { const auto &v = verts[i]; - clipdistance[i * 6 + 0] = v.x + v.w; - clipdistance[i * 6 + 1] = v.w - v.x; - clipdistance[i * 6 + 2] = v.y + v.w; - clipdistance[i * 6 + 3] = v.w - v.y; - clipdistance[i * 6 + 4] = v.z + v.w; - clipdistance[i * 6 + 5] = v.w - v.z; + clipdistance[i * numclipdistances + 0] = v.x + v.w; + clipdistance[i * numclipdistances + 1] = v.w - v.x; + clipdistance[i * numclipdistances + 2] = v.y + v.w; + clipdistance[i * numclipdistances + 3] = v.w - v.y; + clipdistance[i * numclipdistances + 4] = v.z + v.w; + clipdistance[i * numclipdistances + 5] = v.w - v.z; + clipdistance[i * numclipdistances + 6] = v.clipDistance0; } // Clip against each halfspace @@ -260,7 +267,7 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert float *output = weights + max_additional_vertices * 3; int inputverts = 3; int outputverts = 0; - for (int p = 0; p < 6; p++) + for (int p = 0; p < numclipdistances; p++) { // Clip each edge outputverts = 0; @@ -268,14 +275,14 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert { int j = (i + 1) % inputverts; float clipdistance1 = - clipdistance[0 * 6 + p] * input[i * 3 + 0] + - clipdistance[1 * 6 + p] * input[i * 3 + 1] + - clipdistance[2 * 6 + p] * input[i * 3 + 2]; + clipdistance[0 * numclipdistances + p] * input[i * 3 + 0] + + clipdistance[1 * numclipdistances + p] * input[i * 3 + 1] + + clipdistance[2 * numclipdistances + p] * input[i * 3 + 2]; float clipdistance2 = - clipdistance[0 * 6 + p] * input[j * 3 + 0] + - clipdistance[1 * 6 + p] * input[j * 3 + 1] + - clipdistance[2 * 6 + p] * input[j * 3 + 2]; + clipdistance[0 * numclipdistances + p] * input[j * 3 + 0] + + clipdistance[1 * numclipdistances + p] * input[j * 3 + 1] + + clipdistance[2 * numclipdistances + p] * input[j * 3 + 2]; float t1, t2; if (!cullhalfspace(clipdistance1, clipdistance2, t1, t2) && outputverts + 1 < max_additional_vertices) @@ -512,17 +519,20 @@ TriMatrix TriMatrix::operator*(const TriMatrix &mult) const return result; } -TriVertex TriMatrix::operator*(TriVertex v) const +ShadedTriVertex TriMatrix::operator*(TriVertex v) const { float vx = matrix[0 * 4 + 0] * v.x + matrix[1 * 4 + 0] * v.y + matrix[2 * 4 + 0] * v.z + matrix[3 * 4 + 0] * v.w; float vy = matrix[0 * 4 + 1] * v.x + matrix[1 * 4 + 1] * v.y + matrix[2 * 4 + 1] * v.z + matrix[3 * 4 + 1] * v.w; float vz = matrix[0 * 4 + 2] * v.x + matrix[1 * 4 + 2] * v.y + matrix[2 * 4 + 2] * v.z + matrix[3 * 4 + 2] * v.w; float vw = matrix[0 * 4 + 3] * v.x + matrix[1 * 4 + 3] * v.y + matrix[2 * 4 + 3] * v.z + matrix[3 * 4 + 3] * v.w; - v.x = vx; - v.y = vy; - v.z = vz; - v.w = vw; - return v; + ShadedTriVertex sv; + sv.x = vx; + sv.y = vy; + sv.z = vz; + sv.w = vw; + for (int i = 0; i < TriVertex::NumVarying; i++) + sv.varying[i] = v.varying[i]; + return sv; } ///////////////////////////////////////////////////////////////////////////// diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 8fef11e99..270dda894 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -38,6 +38,7 @@ enum class TriangleDrawMode }; struct TriDrawTriangleArgs; +struct TriMatrix; class PolyDrawArgs { @@ -55,6 +56,15 @@ public: uint8_t stenciltestvalue = 0; uint8_t stencilwritevalue = 0; const uint8_t *colormaps = nullptr; + float clipPlane[4]; + + void SetClipPlane(float a, float b, float c, float d) + { + clipPlane[0] = a; + clipPlane[1] = b; + clipPlane[2] = c; + clipPlane[3] = d; + } void SetTexture(FTexture *texture) { @@ -118,6 +128,31 @@ public: } }; +struct ShadedTriVertex : public TriVertex +{ + float clipDistance0; +}; + +struct TriMatrix +{ + static TriMatrix null(); + static TriMatrix identity(); + static TriMatrix translate(float x, float y, float z); + static TriMatrix scale(float x, float y, float z); + static TriMatrix rotate(float angle, float x, float y, float z); + static TriMatrix swapYZ(); + static TriMatrix perspective(float fovy, float aspect, float near, float far); + static TriMatrix frustum(float left, float right, float bottom, float top, float near, float far); + + static TriMatrix worldToView(); // Software renderer world to view space transform + static TriMatrix viewToClip(); // Software renderer shearing projection + + ShadedTriVertex operator*(TriVertex v) const; + TriMatrix operator*(const TriMatrix &m) const; + + float matrix[16]; +}; + class PolyTriangleDrawer { public: @@ -125,11 +160,11 @@ public: static void draw(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode); private: - static TriVertex shade_vertex(const TriMatrix &objectToClip, TriVertex v); + static ShadedTriVertex shade_vertex(const TriMatrix &objectToClip, const float *clipPlane, const TriVertex &v); static void draw_arrays(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode, WorkerThreadData *thread); - static void draw_shaded_triangle(const TriVertex *vertices, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *)); + static void draw_shaded_triangle(const ShadedTriVertex *vertices, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *)); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); - static void clipedge(const TriVertex *verts, TriVertex *clippedvert, int &numclipvert); + static void clipedge(const ShadedTriVertex *verts, TriVertex *clippedvert, int &numclipvert); static int viewport_x, viewport_y, viewport_width, viewport_height, dest_pitch, dest_width, dest_height; static bool dest_bgra; diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index 6e09faa8a..cd4d32077 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -35,7 +35,7 @@ EXTERN_CVAR(Bool, r_drawmirrors) -bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals) +bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals) { PolyDrawLinePortal *polyportal = nullptr; if (line->backsector == nullptr && line->sidedef == line->linedef->sidedef[0] && (line->linedef->special == Line_Mirror && r_drawmirrors)) @@ -85,7 +85,7 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, secto wall.UnpeggedCeil = frontceilz1; wall.Texpart = side_t::mid; wall.Polyportal = polyportal; - wall.Render(worldToClip); + wall.Render(worldToClip, clipPlane); return true; } } @@ -120,7 +120,7 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, secto wall.BottomZ = topfloorz1; wall.UnpeggedCeil = topceilz1; wall.Texpart = side_t::top; - wall.Render(worldToClip); + wall.Render(worldToClip, clipPlane); } if ((bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && line->sidedef) @@ -130,7 +130,7 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, secto wall.BottomZ = bottomfloorz2; wall.UnpeggedCeil = topceilz1; wall.Texpart = side_t::bottom; - wall.Render(worldToClip); + wall.Render(worldToClip, clipPlane); } if (line->sidedef) @@ -149,14 +149,14 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, seg_t *line, secto if (polyportal) { wall.Polyportal = polyportal; - wall.Render(worldToClip); + wall.Render(worldToClip, clipPlane); } } } return polyportal != nullptr; } -void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput) +void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput) { double frontceilz1 = fakeFloor->top.plane->ZatPoint(line->v1); double frontfloorz1 = fakeFloor->bottom.plane->ZatPoint(line->v1); @@ -176,7 +176,7 @@ void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, seg_t *line wall.BottomZ = frontfloorz1; wall.UnpeggedCeil = frontceilz1; wall.Texpart = side_t::mid; - wall.Render(worldToClip); + wall.Render(worldToClip, clipPlane); } void RenderPolyWall::SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2) @@ -189,7 +189,7 @@ void RenderPolyWall::SetCoords(const DVector2 &v1, const DVector2 &v2, double ce this->floor2 = floor2; } -void RenderPolyWall::Render(const TriMatrix &worldToClip) +void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane) { FTexture *tex = GetTexture(); if (!tex && !Polyportal) @@ -253,6 +253,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) if (tex) args.SetTexture(tex); args.SetColormap(Line->frontsector->ColorMap); + args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); if (Polyportal) { @@ -275,7 +276,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip) PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); } - RenderPolyDecal::RenderWallDecals(worldToClip, LineSeg, SubsectorDepth, StencilValue); + RenderPolyDecal::RenderWallDecals(worldToClip, clipPlane, LineSeg, SubsectorDepth, StencilValue); } void RenderPolyWall::ClampHeight(TriVertex &v1, TriVertex &v2) diff --git a/src/r_poly_wall.h b/src/r_poly_wall.h index d1196df9f..bcecd5a05 100644 --- a/src/r_poly_wall.h +++ b/src/r_poly_wall.h @@ -26,15 +26,16 @@ class PolyTranslucentObject; class PolyDrawLinePortal; +class Vec4f; class RenderPolyWall { public: - static bool RenderLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals); - static void Render3DFloorLine(const TriMatrix &worldToClip, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput); + static bool RenderLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals); + static void Render3DFloorLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput); void SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2); - void Render(const TriMatrix &worldToClip); + void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane); DVector2 v1; DVector2 v2; diff --git a/src/r_poly_wallsprite.cpp b/src/r_poly_wallsprite.cpp index c8e0abcc4..351e24e36 100644 --- a/src/r_poly_wallsprite.cpp +++ b/src/r_poly_wallsprite.cpp @@ -28,7 +28,7 @@ #include "r_poly_wallsprite.h" #include "r_poly.h" -void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) +void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) { if (RenderPolySprite::IsThingCulled(thing)) return; @@ -120,5 +120,6 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, AActor *thing, s args.stencilwritevalue = stencilValue; args.SetTexture(tex); args.SetColormap(sub->sector->ColorMap); + args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend); } diff --git a/src/r_poly_wallsprite.h b/src/r_poly_wallsprite.h index 2942d6994..51cf28de6 100644 --- a/src/r_poly_wallsprite.h +++ b/src/r_poly_wallsprite.h @@ -24,8 +24,10 @@ #include "r_poly_triangle.h" +class Vec4f; + class RenderPolyWallSprite { public: - void Render(const TriMatrix &worldToClip, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); + void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); }; From 1a16776dff9c927363caa79b56d76be03786764b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 27 Nov 2016 04:39:33 +0100 Subject: [PATCH 1293/1509] Plane texturing adjustments --- src/r_poly_plane.cpp | 148 +++++++++++++++++++++++++++++++------------ src/r_poly_plane.h | 16 ++++- 2 files changed, 123 insertions(+), 41 deletions(-) diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 76ede6960..b17b0ec2c 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -103,6 +103,8 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c lightlevel = *light->p_lightlevel; } + UVTransform xform(ceiling ? fakeFloor->top.model->planes[sector_t::ceiling].xform : fakeFloor->top.model->planes[sector_t::floor].xform, tex); + PolyDrawArgs args; args.uniforms.light = (uint32_t)(lightlevel / 255.0f * 256.0f); if (fixedlightlev >= 0 || fixedcolormap) @@ -119,7 +121,7 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c for (uint32_t i = 0; i < sub->numlines; i++) { seg_t *line = &sub->firstline[i]; - vertices[sub->numlines - 1 - i] = PlaneVertex(line->v1, fakeFloor->bottom.plane->ZatPoint(line->v1)); + vertices[sub->numlines - 1 - i] = PlaneVertex(line->v1, fakeFloor->bottom.plane->ZatPoint(line->v1), xform); } } else @@ -127,7 +129,7 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c for (uint32_t i = 0; i < sub->numlines; i++) { seg_t *line = &sub->firstline[i]; - vertices[i] = PlaneVertex(line->v1, fakeFloor->top.plane->ZatPoint(line->v1)); + vertices[i] = PlaneVertex(line->v1, fakeFloor->top.plane->ZatPoint(line->v1), xform); } } @@ -172,36 +174,65 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan if (fakesector && (fakesector == sub->sector || (fakesector->MoreFlags & SECF_IGNOREHEIGHTSEC) == SECF_IGNOREHEIGHTSEC)) fakesector = nullptr; - bool fakeflooronly = fakesector && (fakesector->MoreFlags & SECF_FAKEFLOORONLY) != SECF_FAKEFLOORONLY; + bool fakeflooronly = fakesector && (fakesector->MoreFlags & SECF_FAKEFLOORONLY) == SECF_FAKEFLOORONLY; FTextureID picnum; bool ccw; sector_t *frontsector; - if (ceiling && fakesector && ViewPos.Z < fakesector->floorplane.Zat0()) + if (fakesector) { - picnum = fakesector->GetTexture(sector_t::ceiling); - ccw = false; - ceiling = false; - frontsector = fakesector; - } - else if (!ceiling && fakesector && ViewPos.Z >= fakesector->floorplane.Zat0()) - { - picnum = fakesector->GetTexture(sector_t::ceiling); - ccw = true; - frontsector = fakesector; - } - else if (ceiling && fakesector && ViewPos.Z > fakesector->ceilingplane.Zat0() && !fakeflooronly) - { - picnum = fakesector->GetTexture(sector_t::floor); - ccw = true; - frontsector = fakesector; - } - else if (!ceiling && fakesector && ViewPos.Z <= fakesector->ceilingplane.Zat0() && !fakeflooronly) - { - picnum = fakesector->GetTexture(sector_t::floor); - ccw = false; - ceiling = true; - frontsector = fakesector; + // Floor and ceiling texture needs to be swapped sometimes? Why?? :( + + if (ViewPos.Z < fakesector->floorplane.Zat0()) // In water + { + if (ceiling) + { + picnum = fakesector->GetTexture(sector_t::ceiling); + ceiling = false; + frontsector = fakesector; + ccw = false; + } + else + { + picnum = fakesector->GetTexture(sector_t::floor); + frontsector = sub->sector; + ccw = true; + } + } + else if (ViewPos.Z >= fakesector->ceilingplane.Zat0() && !fakeflooronly) // In ceiling water + { + if (ceiling) + { + picnum = fakesector->GetTexture(sector_t::ceiling); + frontsector = sub->sector; + ccw = true; + } + else + { + picnum = fakesector->GetTexture(sector_t::floor); + frontsector = fakesector; + ccw = false; + ceiling = true; + } + } + else if (!ceiling) // Water surface + { + picnum = fakesector->GetTexture(sector_t::ceiling); + frontsector = fakesector; + ccw = true; + } + else if (!fakeflooronly) // Ceiling water surface + { + picnum = fakesector->GetTexture(sector_t::floor); + frontsector = fakesector; + ccw = true; + } + else // Upper ceiling + { + picnum = sub->sector->GetTexture(sector_t::ceiling); + ccw = true; + frontsector = sub->sector; + } } else { @@ -216,6 +247,8 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan bool isSky = picnum == skyflatnum; + UVTransform transform(ceiling ? frontsector->planes[sector_t::ceiling].xform : frontsector->planes[sector_t::floor].xform, tex); + PolyDrawArgs args; args.uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f); if (fixedlightlev >= 0 || fixedcolormap) @@ -232,7 +265,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan for (uint32_t i = 0; i < sub->numlines; i++) { seg_t *line = &sub->firstline[i]; - vertices[sub->numlines - 1 - i] = PlaneVertex(line->v1, isSky ? skyHeight : frontsector->ceilingplane.ZatPoint(line->v1)); + vertices[sub->numlines - 1 - i] = PlaneVertex(line->v1, isSky ? skyHeight : frontsector->ceilingplane.ZatPoint(line->v1), transform); } } else @@ -240,7 +273,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan for (uint32_t i = 0; i < sub->numlines; i++) { seg_t *line = &sub->firstline[i]; - vertices[i] = PlaneVertex(line->v1, isSky ? skyHeight : frontsector->floorplane.ZatPoint(line->v1)); + vertices[i] = PlaneVertex(line->v1, isSky ? skyHeight : frontsector->floorplane.ZatPoint(line->v1), transform); } } @@ -334,17 +367,17 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan if (ceiling) { - wallvert[0] = PlaneVertex(line->v1, skyHeight); - wallvert[1] = PlaneVertex(line->v2, skyHeight); - wallvert[2] = PlaneVertex(line->v2, skyBottomz2); - wallvert[3] = PlaneVertex(line->v1, skyBottomz1); + wallvert[0] = PlaneVertex(line->v1, skyHeight, transform); + wallvert[1] = PlaneVertex(line->v2, skyHeight, transform); + wallvert[2] = PlaneVertex(line->v2, skyBottomz2, transform); + wallvert[3] = PlaneVertex(line->v1, skyBottomz1, transform); } else { - wallvert[0] = PlaneVertex(line->v1, frontsector->floorplane.ZatPoint(line->v1)); - wallvert[1] = PlaneVertex(line->v2, frontsector->floorplane.ZatPoint(line->v2)); - wallvert[2] = PlaneVertex(line->v2, skyHeight); - wallvert[3] = PlaneVertex(line->v1, skyHeight); + wallvert[0] = PlaneVertex(line->v1, frontsector->floorplane.ZatPoint(line->v1), transform); + wallvert[1] = PlaneVertex(line->v2, frontsector->floorplane.ZatPoint(line->v2), transform); + wallvert[2] = PlaneVertex(line->v2, skyHeight, transform); + wallvert[3] = PlaneVertex(line->v1, skyHeight, transform); } args.vinput = wallvert; @@ -357,14 +390,49 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan } } -TriVertex RenderPolyPlane::PlaneVertex(vertex_t *v1, double height) +TriVertex RenderPolyPlane::PlaneVertex(vertex_t *v1, double height, const UVTransform &transform) { TriVertex v; v.x = (float)v1->fPos().X; v.y = (float)v1->fPos().Y; v.z = (float)height; v.w = 1.0f; - v.varying[0] = v.x / 64.0f; - v.varying[1] = 1.0f - v.y / 64.0f; + v.varying[0] = transform.GetU(v.x, v.y); + v.varying[1] = transform.GetV(v.x, v.y); return v; } + +RenderPolyPlane::UVTransform::UVTransform(const FTransform &transform, FTexture *tex) +{ + if (tex) + { + xscale = (float)(transform.xScale * tex->Scale.X / tex->GetWidth()); + yscale = (float)(transform.yScale * tex->Scale.Y / tex->GetHeight()); + + double planeang = (transform.Angle + transform.baseAngle).Radians(); + cosine = (float)cos(planeang); + sine = (float)sin(planeang); + + xOffs = (float)transform.xOffs; + yOffs = (float)transform.yOffs; + } + else + { + xscale = 1.0f / 64.0f; + yscale = 1.0f / 64.0f; + cosine = 1.0f; + sine = 0.0f; + xOffs = 0.0f; + yOffs = 0.0f; + } +} + +float RenderPolyPlane::UVTransform::GetU(float x, float y) const +{ + return (xOffs + x * cosine - y * sine) * xscale; +} + +float RenderPolyPlane::UVTransform::GetV(float x, float y) const +{ + return (yOffs - x * sine - y * cosine) * yscale; +} diff --git a/src/r_poly_plane.h b/src/r_poly_plane.h index 3006ce86b..396a9e4a8 100644 --- a/src/r_poly_plane.h +++ b/src/r_poly_plane.h @@ -33,7 +33,21 @@ public: static void RenderPlanes(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals); private: + struct UVTransform + { + UVTransform(const FTransform &transform, FTexture *tex); + + float GetU(float x, float y) const; + float GetV(float x, float y) const; + + float xscale; + float yscale; + float cosine; + float sine; + float xOffs, yOffs; + }; + void Render3DFloor(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakefloor); void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals); - TriVertex PlaneVertex(vertex_t *v1, double height); + TriVertex PlaneVertex(vertex_t *v1, double height, const UVTransform &transform); }; From bea113a908bd2b695e0d15607cb04065dc2810b7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 28 Nov 2016 02:32:57 +0100 Subject: [PATCH 1294/1509] Fix tonemap texture filtering (black screen) regression --- src/gl/renderer/gl_postprocess.cpp | 30 ++++++++++++++---------------- src/gl/renderer/gl_renderer.h | 2 +- src/gl/textures/gl_hwtexture.cpp | 5 +++++ src/gl/textures/gl_hwtexture.h | 1 + 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index dd8bccc8b..f15171c53 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -468,7 +468,10 @@ void FGLRenderer::TonemapScene() FGLDebug::PushGroup("TonemapScene"); + CreateTonemapPalette(); + FGLPostProcessState savedState; + savedState.SaveTextureBindings(2); mBuffers->BindNextFB(); mBuffers->BindCurrentTexture(0); @@ -477,12 +480,18 @@ void FGLRenderer::TonemapScene() if (mTonemapShader->IsPaletteMode()) { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, mTonemapPalette->GetTextureHandle(0)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glActiveTexture(GL_TEXTURE0); + mTonemapShader->PaletteLUT.Set(1); - BindTonemapPalette(1); } else { - savedState.SaveTextureBindings(2); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, mBuffers->ExposureTexture); glActiveTexture(GL_TEXTURE0); @@ -496,13 +505,9 @@ void FGLRenderer::TonemapScene() FGLDebug::PopGroup(); } -void FGLRenderer::BindTonemapPalette(int texunit) +void FGLRenderer::CreateTonemapPalette() { - if (mTonemapPalette) - { - mTonemapPalette->Bind(texunit, 0, false); - } - else + if (!mTonemapPalette) { TArray lut; lut.Resize(512 * 512 * 4); @@ -523,14 +528,7 @@ void FGLRenderer::BindTonemapPalette(int texunit) } mTonemapPalette = new FHardwareTexture(512, 512, true); - mTonemapPalette->CreateTexture(&lut[0], 512, 512, texunit, false, 0, "mTonemapPalette"); - - glActiveTexture(GL_TEXTURE0 + texunit); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glActiveTexture(GL_TEXTURE0); + mTonemapPalette->CreateTexture(&lut[0], 512, 512, 0, false, 0, "mTonemapPalette"); } } diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 7eedd4694..869b46d2d 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -195,7 +195,7 @@ public: void BloomScene(); void TonemapScene(); void ColormapScene(); - void BindTonemapPalette(int texunit); + void CreateTonemapPalette(); void ClearTonemapPalette(); void LensDistortScene(); void ApplyFXAA(); diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index edcda4398..477d1986b 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -374,6 +374,11 @@ unsigned int FHardwareTexture::Bind(int texunit, int translation, bool needmipma return 0; } +unsigned int FHardwareTexture::GetTextureHandle(int translation) +{ + TranslatedTexture *pTex = GetTexID(translation); + return pTex->glTexID; +} void FHardwareTexture::Unbind(int texunit) { diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h index 96eff0264..59fc98169 100644 --- a/src/gl/textures/gl_hwtexture.h +++ b/src/gl/textures/gl_hwtexture.h @@ -83,6 +83,7 @@ public: unsigned int Bind(int texunit, int translation, bool needmipmap); unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, const FString &name); + unsigned int GetTextureHandle(int translation); void Clean(bool all); void CleanUnused(SpriteHits &usedtranslations); From e9e7839133a2e7784f87a47b4f8bf7e97f595b51 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 28 Nov 2016 17:31:56 +0100 Subject: [PATCH 1295/1509] Create drawergen tool --- .gitignore | 2 + src/CMakeLists.txt | 118 +-- src/r_compiler/llvmdrawers.cpp | 866 ------------------ src/r_draw_rgba.cpp | 22 +- src/r_drawers.cpp | 423 +++++++++ src/{r_compiler/llvmdrawers.h => r_drawers.h} | 44 +- src/r_drawt_rgba.cpp | 6 +- src/r_poly_triangle.cpp | 2 +- src/r_poly_triangle.h | 2 +- src/r_swrenderer.cpp | 4 +- tools/CMakeLists.txt | 1 + tools/drawergen/CMakeLists.txt | 133 +++ tools/drawergen/drawergen.cpp | 664 ++++++++++++++ .../fixedfunction/drawcolumncodegen.cpp | 21 +- .../fixedfunction/drawcolumncodegen.h | 0 .../fixedfunction/drawercodegen.cpp | 21 +- .../drawergen}/fixedfunction/drawercodegen.h | 35 +- .../fixedfunction/drawskycodegen.cpp | 21 +- .../drawergen}/fixedfunction/drawskycodegen.h | 0 .../fixedfunction/drawspancodegen.cpp | 21 +- .../fixedfunction/drawspancodegen.h | 0 .../fixedfunction/drawtrianglecodegen.cpp | 21 +- .../fixedfunction/drawtrianglecodegen.h | 0 .../fixedfunction/drawwallcodegen.cpp | 21 +- .../fixedfunction/drawwallcodegen.h | 0 .../drawergen}/llvm_include.h | 0 tools/drawergen/precomp.h | 5 + .../drawergen}/ssa/ssa_barycentric_weight.h | 0 .../drawergen}/ssa/ssa_bool.cpp | 2 +- .../drawergen}/ssa/ssa_bool.h | 0 .../drawergen}/ssa/ssa_float.cpp | 2 +- .../drawergen}/ssa/ssa_float.h | 0 .../drawergen}/ssa/ssa_float_ptr.cpp | 2 +- .../drawergen}/ssa/ssa_float_ptr.h | 0 .../drawergen}/ssa/ssa_for_block.cpp | 2 +- .../drawergen}/ssa/ssa_for_block.h | 0 .../drawergen}/ssa/ssa_function.cpp | 2 +- .../drawergen}/ssa/ssa_function.h | 0 .../drawergen}/ssa/ssa_if_block.cpp | 2 +- .../drawergen}/ssa/ssa_if_block.h | 0 .../drawergen}/ssa/ssa_int.cpp | 2 +- .../drawergen}/ssa/ssa_int.h | 0 .../drawergen}/ssa/ssa_int_ptr.cpp | 2 +- .../drawergen}/ssa/ssa_int_ptr.h | 0 .../drawergen}/ssa/ssa_phi.h | 0 .../drawergen}/ssa/ssa_scope.cpp | 2 +- .../drawergen}/ssa/ssa_scope.h | 0 .../drawergen}/ssa/ssa_short.cpp | 2 +- .../drawergen}/ssa/ssa_short.h | 0 .../drawergen}/ssa/ssa_stack.h | 0 .../drawergen}/ssa/ssa_struct_type.cpp | 2 +- .../drawergen}/ssa/ssa_struct_type.h | 0 .../drawergen}/ssa/ssa_ubyte.cpp | 2 +- .../drawergen}/ssa/ssa_ubyte.h | 0 .../drawergen}/ssa/ssa_ubyte_ptr.cpp | 2 +- .../drawergen}/ssa/ssa_ubyte_ptr.h | 0 .../drawergen}/ssa/ssa_value.cpp | 2 +- .../drawergen}/ssa/ssa_value.h | 0 .../drawergen}/ssa/ssa_vec16ub.cpp | 2 +- .../drawergen}/ssa/ssa_vec16ub.h | 0 .../drawergen}/ssa/ssa_vec4f.cpp | 2 +- .../drawergen}/ssa/ssa_vec4f.h | 0 .../drawergen}/ssa/ssa_vec4f_ptr.cpp | 2 +- .../drawergen}/ssa/ssa_vec4f_ptr.h | 0 .../drawergen}/ssa/ssa_vec4i.cpp | 2 +- .../drawergen}/ssa/ssa_vec4i.h | 0 .../drawergen}/ssa/ssa_vec4i_ptr.cpp | 2 +- .../drawergen}/ssa/ssa_vec4i_ptr.h | 0 .../drawergen}/ssa/ssa_vec8s.cpp | 2 +- .../drawergen}/ssa/ssa_vec8s.h | 0 tools/drawergen/trustinfo.rc | 6 + tools/drawergen/trustinfo.txt | 16 + 72 files changed, 1407 insertions(+), 1108 deletions(-) delete mode 100644 src/r_compiler/llvmdrawers.cpp create mode 100644 src/r_drawers.cpp rename src/{r_compiler/llvmdrawers.h => r_drawers.h} (93%) create mode 100644 tools/drawergen/CMakeLists.txt create mode 100644 tools/drawergen/drawergen.cpp rename {src/r_compiler => tools/drawergen}/fixedfunction/drawcolumncodegen.cpp (96%) rename {src/r_compiler => tools/drawergen}/fixedfunction/drawcolumncodegen.h (100%) rename {src/r_compiler => tools/drawergen}/fixedfunction/drawercodegen.cpp (92%) rename {src/r_compiler => tools/drawergen}/fixedfunction/drawercodegen.h (81%) rename {src/r_compiler => tools/drawergen}/fixedfunction/drawskycodegen.cpp (91%) rename {src/r_compiler => tools/drawergen}/fixedfunction/drawskycodegen.h (100%) rename {src/r_compiler => tools/drawergen}/fixedfunction/drawspancodegen.cpp (94%) rename {src/r_compiler => tools/drawergen}/fixedfunction/drawspancodegen.h (100%) rename {src/r_compiler => tools/drawergen}/fixedfunction/drawtrianglecodegen.cpp (98%) rename {src/r_compiler => tools/drawergen}/fixedfunction/drawtrianglecodegen.h (100%) rename {src/r_compiler => tools/drawergen}/fixedfunction/drawwallcodegen.cpp (94%) rename {src/r_compiler => tools/drawergen}/fixedfunction/drawwallcodegen.h (100%) rename {src/r_compiler => tools/drawergen}/llvm_include.h (100%) create mode 100644 tools/drawergen/precomp.h rename {src/r_compiler => tools/drawergen}/ssa/ssa_barycentric_weight.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_bool.cpp (99%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_bool.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_float.cpp (99%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_float.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_float_ptr.cpp (99%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_float_ptr.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_for_block.cpp (98%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_for_block.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_function.cpp (98%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_function.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_if_block.cpp (98%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_if_block.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_int.cpp (99%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_int.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_int_ptr.cpp (99%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_int_ptr.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_phi.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_scope.cpp (98%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_scope.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_short.cpp (99%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_short.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_stack.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_struct_type.cpp (97%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_struct_type.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_ubyte.cpp (98%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_ubyte.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_ubyte_ptr.cpp (99%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_ubyte_ptr.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_value.cpp (98%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_value.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_vec16ub.cpp (99%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_vec16ub.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_vec4f.cpp (99%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_vec4f.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_vec4f_ptr.cpp (98%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_vec4f_ptr.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_vec4i.cpp (99%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_vec4i.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_vec4i_ptr.cpp (98%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_vec4i_ptr.h (100%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_vec8s.cpp (99%) rename {src/r_compiler => tools/drawergen}/ssa/ssa_vec8s.h (100%) create mode 100644 tools/drawergen/trustinfo.rc create mode 100644 tools/drawergen/trustinfo.txt diff --git a/.gitignore b/.gitignore index 7cc9d9860..a001e38de 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,5 @@ /build_vc2015-64 /build /llvm +/src/r_drawersasm.obj +/src/r_drawersasm.o diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d19951f9f..458acf6ad 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -293,47 +293,6 @@ if( NOT NO_OPENAL ) endif() endif() - -# Path where it looks for the LLVM compiled files on Windows -set( LLVM_PRECOMPILED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" ) - -if( NOT WIN32 ) - set( LLVM_COMPONENTS core support asmparser asmprinter bitreader bitwriter codegen ipo - irreader transformutils instrumentation profiledata runtimedyld - object instcombine linker analysis selectiondag scalaropts vectorize executionengine - mc mcdisassembler mcparser mcjit target x86asmprinter x86info x86desc x86utils x86codegen ) - - # Example LLVM_DIR folder: C:/Development/Environment/Src/llvm-3.9.0/build/lib/cmake/llvm - find_package(LLVM REQUIRED CONFIG) - message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") - message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") - llvm_map_components_to_libnames( llvm_libs ${LLVM_COMPONENTS} ) - include_directories( ${LLVM_INCLUDE_DIRS} ) - set( ZDOOM_LIBS ${ZDOOM_LIBS} ${llvm_libs} ) -else() - set( LLVM_COMPONENTS core support asmparser asmprinter bitreader bitwriter codegen passes ipo - irreader transformutils instrumentation profiledata debuginfocodeview runtimedyld - object instcombine linker analysis selectiondag scalaropts vectorize executionengine - mc mcdisassembler mcparser mcjit target x86asmprinter x86info x86desc x86utils x86codegen ) - - include_directories( "${LLVM_PRECOMPILED_DIR}/include" ) - if( X64 ) - include_directories( "${LLVM_PRECOMPILED_DIR}/64bit-include" ) - set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/64bit-" ) - else() - include_directories( "${LLVM_PRECOMPILED_DIR}/32bit-include" ) - set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/32bit-" ) - endif() - foreach(buildtype IN ITEMS RELEASE DEBUG) - set( llvm_libs_${buildtype} "${llvm_libs_base}${buildtype}" ) - set( LLVM_${buildtype}_LIBS "" ) - foreach( llvm_module ${LLVM_COMPONENTS} ) - find_library( LLVM_${llvm_module}_LIBRARY_${buildtype} LLVM${llvm_module} PATHS ${llvm_libs_${buildtype}} ) - set( LLVM_${buildtype}_LIBS ${LLVM_${buildtype}_LIBS} ${LLVM_${llvm_module}_LIBRARY_${buildtype}} ) - endforeach( llvm_module ) - endforeach(buildtype) -endif() - if( NOT NO_FMOD ) # Search for FMOD include files if( NOT WIN32 ) @@ -644,11 +603,6 @@ if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) set( CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++ ${CMAKE_EXE_LINKER_FLAGS}" ) endif () - # Linux - add these flags for LLVM compatibility to prevent crashing - if ( UNIX AND NOT APPLE ) - set( CMAKE_EXE_LINKER_FLAGS "-Wl,--exclude-libs,ALL ${CMAKE_EXE_LINKER_FLAGS}" ) - endif() - # Remove extra warnings when using the official DirectX headers. # Also, TDM-GCC 4.4.0 no longer accepts glibc-style printf formats as valid, # which is a royal pain. The previous version I had been using was fine with them. @@ -719,6 +673,20 @@ add_custom_target( revision_check ALL WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} DEPENDS updaterevision ) +# Run drawer codegen tool + +if ( WIN32 ) + add_custom_target( drawergen_target ALL + COMMAND drawergen src/r_drawersasm.obj + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS drawergen ) +else() + add_custom_target( drawergen_target ALL + COMMAND drawergen src/r_drawersasm.o + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS drawergen ) +endif() + # Libraries ZDoom needs message( STATUS "Fluid synth libs: ${FLUIDSYNTH_LIBRARIES}" ) @@ -933,9 +901,6 @@ file( GLOB HEADER_FILES posix/*.h posix/cocoa/*.h posix/sdl/*.h - r_compiler/*.h - r_compiler/ssa/*.h - r_compiler/fixedfunction/*.h r_data/*.h resourcefiles/*.h sfmt/*.h @@ -1083,6 +1048,7 @@ set( FASTMATH_PCH_SOURCES r_draw_rgba.cpp r_drawt.cpp r_drawt_rgba.cpp + r_drawers.cpp r_thread.cpp r_main.cpp r_plane.cpp @@ -1485,33 +1451,6 @@ set (PCH_SOURCES fragglescript/t_spec.cpp fragglescript/t_variable.cpp fragglescript/t_cmd.cpp - r_compiler/llvmdrawers.cpp - r_compiler/ssa/ssa_bool.cpp - r_compiler/ssa/ssa_float.cpp - r_compiler/ssa/ssa_float_ptr.cpp - r_compiler/ssa/ssa_for_block.cpp - r_compiler/ssa/ssa_function.cpp - r_compiler/ssa/ssa_if_block.cpp - r_compiler/ssa/ssa_int.cpp - r_compiler/ssa/ssa_int_ptr.cpp - r_compiler/ssa/ssa_short.cpp - r_compiler/ssa/ssa_scope.cpp - r_compiler/ssa/ssa_struct_type.cpp - r_compiler/ssa/ssa_ubyte.cpp - r_compiler/ssa/ssa_ubyte_ptr.cpp - r_compiler/ssa/ssa_value.cpp - r_compiler/ssa/ssa_vec4f.cpp - r_compiler/ssa/ssa_vec4f_ptr.cpp - r_compiler/ssa/ssa_vec4i.cpp - r_compiler/ssa/ssa_vec4i_ptr.cpp - r_compiler/ssa/ssa_vec8s.cpp - r_compiler/ssa/ssa_vec16ub.cpp - r_compiler/fixedfunction/drawercodegen.cpp - r_compiler/fixedfunction/drawspancodegen.cpp - r_compiler/fixedfunction/drawwallcodegen.cpp - r_compiler/fixedfunction/drawcolumncodegen.cpp - r_compiler/fixedfunction/drawskycodegen.cpp - r_compiler/fixedfunction/drawtrianglecodegen.cpp r_data/sprites.cpp r_data/voxels.cpp r_data/renderstyle.cpp @@ -1528,6 +1467,16 @@ set (PCH_SOURCES ) enable_precompiled_headers( g_pch.h PCH_SOURCES ) +if ( WIN32 ) + set (CODEGENOBJ_SOURCES + r_drawersasm.obj + ) +else() + set (CODEGENOBJ_SOURCES + r_drawersasm.o + ) +endif() + add_executable( zdoom WIN32 MACOSX_BUNDLE ${HEADER_FILES} ${NOT_COMPILED_SOURCE_FILES} @@ -1557,8 +1506,11 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE math/tanh.c math/fastsin.cpp zzautozend.cpp + r_drawersasm.obj ) +set_source_files_properties( ${CODEGENOBJ_SOURCES} PROPERTIES EXTERNAL_OBJECT true GENERATED true) + set_source_files_properties( ${FASTMATH_SOURCES} PROPERTIES COMPILE_FLAGS ${ZD_FASTMATH_FLAG} ) set_source_files_properties( xlat/parse_xlat.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c" ) set_source_files_properties( sc_man.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h" ) @@ -1579,15 +1531,6 @@ endif() target_link_libraries( zdoom ${ZDOOM_LIBS} gdtoa dumb lzma ) -if( WIN32 ) - foreach(debuglib ${LLVM_DEBUG_LIBS}) - target_link_libraries( zdoom debug ${debuglib} ) - endforeach(debuglib) - foreach(releaselib ${LLVM_RELEASE_LIBS}) - target_link_libraries( zdoom optimized ${releaselib} ) - endforeach(releaselib) -endif() - include_directories( . g_doom g_heretic @@ -1608,7 +1551,7 @@ include_directories( . ${CMAKE_BINARY_DIR}/gdtoa ${SYSTEM_SOURCES_DIR} ) -add_dependencies( zdoom revision_check ) +add_dependencies( zdoom revision_check drawergen_target ) # Due to some quirks, we need to do this in this order if( NOT ZDOOM_OUTPUT_OLDSTYLE ) @@ -1750,9 +1693,6 @@ source_group("Render Data\\Resource Headers" REGULAR_EXPRESSION "^${CMAKE_CURREN source_group("Render Data\\Resource Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_data/.+\\.cpp$") source_group("Render Data\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/textures/.+") source_group("Render Interface" FILES r_defs.h r_renderer.h r_sky.cpp r_sky.h r_state.h r_utility.cpp r_utility.h) -source_group("Render Compiler" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_compiler/.+") -source_group("Render Compiler\\SSA" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_compiler/ssa/.+") -source_group("Render Compiler\\Fixed Function" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_compiler/fixedfunction/.+") source_group("Resource Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/resourcefiles/.+") source_group("POSIX Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/posix/.+") source_group("Cocoa Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/posix/cocoa/.+") diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp deleted file mode 100644 index babb7c6e7..000000000 --- a/src/r_compiler/llvmdrawers.cpp +++ /dev/null @@ -1,866 +0,0 @@ -/* -** LLVM code generated drawers -** Copyright (c) 2016 Magnus Norddahl -** -** This software is provided 'as-is', without any express or implied -** warranty. In no event will the authors be held liable for any damages -** arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, -** including commercial applications, and to alter it and redistribute it -** freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not -** claim that you wrote the original software. If you use this software -** in a product, an acknowledgment in the product documentation would be -** appreciated but is not required. -** 2. Altered source versions must be plainly marked as such, and must not be -** misrepresented as being the original software. -** 3. This notice may not be removed or altered from any source distribution. -** -*/ - -#include "i_system.h" -#include "r_compiler/llvm_include.h" -#include "r_compiler/fixedfunction/drawspancodegen.h" -#include "r_compiler/fixedfunction/drawwallcodegen.h" -#include "r_compiler/fixedfunction/drawcolumncodegen.h" -#include "r_compiler/fixedfunction/drawskycodegen.h" -#include "r_compiler/fixedfunction/drawtrianglecodegen.h" -#include "r_compiler/ssa/ssa_function.h" -#include "r_compiler/ssa/ssa_scope.h" -#include "r_compiler/ssa/ssa_for_block.h" -#include "r_compiler/ssa/ssa_if_block.h" -#include "r_compiler/ssa/ssa_stack.h" -#include "r_compiler/ssa/ssa_function.h" -#include "r_compiler/ssa/ssa_struct_type.h" -#include "r_compiler/ssa/ssa_value.h" -#include "r_compiler/ssa/ssa_barycentric_weight.h" -#include "x86.h" -#include "c_cvars.h" -#include "version.h" -#include "m_misc.h" - -CUSTOM_CVAR(String, llvm_cpu, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL) -{ - Printf("You must restart " GAMENAME " for this change to take effect.\n"); -} - -class LLVMProgram -{ -public: - LLVMProgram(); - - void CreateModule(); - std::string GetTargetCPU(); - bool LoadCachedModule(int version, std::string targetCPU); - void CreateEE(int version, std::string targetCPU, bool optimize); - std::string GenerateAssembly(std::string cpuName); - std::string DumpModule(); - void StopLogFatalErrors(); - - template - Func *GetProcAddress(const std::string &name) { return reinterpret_cast(PointerToFunction(name.c_str())); } - - llvm::LLVMContext &context() { return *mContext; } - llvm::Module *module() { return mModule.get(); } - llvm::ExecutionEngine *engine() { return mEngine.get(); } - -private: - void SaveCachedModule(llvm::Module *module, int version, std::string targetCPU); - FString GetDrawerCacheFilename(int version, FString cpu); - void *PointerToFunction(const char *name); - - llvm::TargetMachine *machine = nullptr; - std::unique_ptr mContext; - std::unique_ptr mModule; - std::unique_ptr mEngine; -}; - -class LLVMDrawersImpl : public LLVMDrawers -{ -public: - LLVMDrawersImpl(); - -private: - void CodegenDrawColumn(const char *name, DrawColumnVariant variant, DrawColumnMethod method); - void CodegenDrawSpan(const char *name, DrawSpanVariant variant); - void CodegenDrawWall(const char *name, DrawWallVariant variant, int columns); - void CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns); - void CodegenDrawTriangle(const std::string &name, TriDrawVariant variant, TriBlendMode blendmode, bool truecolor); - - static llvm::Type *GetDrawColumnArgsStruct(llvm::LLVMContext &context); - static llvm::Type *GetDrawSpanArgsStruct(llvm::LLVMContext &context); - static llvm::Type *GetDrawWallArgsStruct(llvm::LLVMContext &context); - static llvm::Type *GetDrawSkyArgsStruct(llvm::LLVMContext &context); - static llvm::Type *GetWorkerThreadDataStruct(llvm::LLVMContext &context); - static llvm::Type *GetTriVertexStruct(llvm::LLVMContext &context); - static llvm::Type *GetTriMatrixStruct(llvm::LLVMContext &context); - static llvm::Type *GetTriUniformsStruct(llvm::LLVMContext &context); - static llvm::Type *GetTriDrawTriangleArgs(llvm::LLVMContext &context); - - LLVMProgram mProgram; -}; - -///////////////////////////////////////////////////////////////////////////// - -LLVMDrawers *LLVMDrawers::Singleton = nullptr; - -void LLVMDrawers::Create() -{ - if (!Singleton) - Singleton = new LLVMDrawersImpl(); -} - -void LLVMDrawers::Destroy() -{ - delete Singleton; - Singleton = nullptr; -} - -LLVMDrawers *LLVMDrawers::Instance() -{ - return Singleton; -} - -///////////////////////////////////////////////////////////////////////////// - -LLVMDrawersImpl::LLVMDrawersImpl() -{ - int version = 8; // Increment this number if the drawer codegen is modified (forces recreation of the module). - std::string targetCPU = mProgram.GetTargetCPU(); - bool loaded = mProgram.LoadCachedModule(version, targetCPU); - if (!loaded) - { - mProgram.CreateModule(); - - CodegenDrawColumn("FillColumn", DrawColumnVariant::Fill, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnAdd", DrawColumnVariant::FillAdd, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnAddClamp", DrawColumnVariant::FillAddClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnSubClamp", DrawColumnVariant::FillSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnRevSubClamp", DrawColumnVariant::FillRevSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumn", DrawColumnVariant::Draw, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnAdd", DrawColumnVariant::DrawAdd, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnShaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnAddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnSubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnRevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnTranslated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnTlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnAddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnSubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnRevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnRt1", DrawColumnVariant::Draw, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt4", DrawColumnVariant::Draw, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt4); - CodegenDrawSpan("DrawSpan", DrawSpanVariant::Opaque); - CodegenDrawSpan("DrawSpanMasked", DrawSpanVariant::Masked); - CodegenDrawSpan("DrawSpanTranslucent", DrawSpanVariant::Translucent); - CodegenDrawSpan("DrawSpanMaskedTranslucent", DrawSpanVariant::MaskedTranslucent); - CodegenDrawSpan("DrawSpanAddClamp", DrawSpanVariant::AddClamp); - CodegenDrawSpan("DrawSpanMaskedAddClamp", DrawSpanVariant::MaskedAddClamp); - CodegenDrawWall("vlinec1", DrawWallVariant::Opaque, 1); - CodegenDrawWall("vlinec4", DrawWallVariant::Opaque, 4); - CodegenDrawWall("mvlinec1", DrawWallVariant::Masked, 1); - CodegenDrawWall("mvlinec4", DrawWallVariant::Masked, 4); - CodegenDrawWall("tmvline1_add", DrawWallVariant::Add, 1); - CodegenDrawWall("tmvline4_add", DrawWallVariant::Add, 4); - CodegenDrawWall("tmvline1_addclamp", DrawWallVariant::AddClamp, 1); - CodegenDrawWall("tmvline4_addclamp", DrawWallVariant::AddClamp, 4); - CodegenDrawWall("tmvline1_subclamp", DrawWallVariant::SubClamp, 1); - CodegenDrawWall("tmvline4_subclamp", DrawWallVariant::SubClamp, 4); - CodegenDrawWall("tmvline1_revsubclamp", DrawWallVariant::RevSubClamp, 1); - CodegenDrawWall("tmvline4_revsubclamp", DrawWallVariant::RevSubClamp, 4); - CodegenDrawSky("DrawSky1", DrawSkyVariant::Single, 1); - CodegenDrawSky("DrawSky4", DrawSkyVariant::Single, 4); - CodegenDrawSky("DrawDoubleSky1", DrawSkyVariant::Double, 1); - CodegenDrawSky("DrawDoubleSky4", DrawSkyVariant::Double, 4); - for (int i = 0; i < NumTriBlendModes(); i++) - { - CodegenDrawTriangle("TriDraw8_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, false); - CodegenDrawTriangle("TriDraw32_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, true); - CodegenDrawTriangle("TriFill8_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, false); - CodegenDrawTriangle("TriFill32_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, true); - CodegenDrawTriangle("TriDrawSubsector8_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, false); - CodegenDrawTriangle("TriDrawSubsector32_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, true); - CodegenDrawTriangle("TriFillSubsector8_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, false); - CodegenDrawTriangle("TriFillSubsector32_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, true); - } - CodegenDrawTriangle("TriStencil", TriDrawVariant::Stencil, TriBlendMode::Copy, false); - CodegenDrawTriangle("TriStencilClose", TriDrawVariant::StencilClose, TriBlendMode::Copy, false); - } - - mProgram.CreateEE(version, targetCPU, !loaded); - - FillColumn = mProgram.GetProcAddress("FillColumn"); - FillColumnAdd = mProgram.GetProcAddress("FillColumnAdd"); - FillColumnAddClamp = mProgram.GetProcAddress("FillColumnAddClamp"); - FillColumnSubClamp = mProgram.GetProcAddress("FillColumnSubClamp"); - FillColumnRevSubClamp = mProgram.GetProcAddress("FillColumnRevSubClamp"); - DrawColumn = mProgram.GetProcAddress("DrawColumn"); - DrawColumnAdd = mProgram.GetProcAddress("DrawColumnAdd"); - DrawColumnShaded = mProgram.GetProcAddress("DrawColumnShaded"); - DrawColumnAddClamp = mProgram.GetProcAddress("DrawColumnAddClamp"); - DrawColumnSubClamp = mProgram.GetProcAddress("DrawColumnSubClamp"); - DrawColumnRevSubClamp = mProgram.GetProcAddress("DrawColumnRevSubClamp"); - DrawColumnTranslated = mProgram.GetProcAddress("DrawColumnTranslated"); - DrawColumnTlatedAdd = mProgram.GetProcAddress("DrawColumnTlatedAdd"); - DrawColumnAddClampTranslated = mProgram.GetProcAddress("DrawColumnAddClampTranslated"); - DrawColumnSubClampTranslated = mProgram.GetProcAddress("DrawColumnSubClampTranslated"); - DrawColumnRevSubClampTranslated = mProgram.GetProcAddress("DrawColumnRevSubClampTranslated"); - DrawColumnRt1 = mProgram.GetProcAddress("DrawColumnRt1"); - DrawColumnRt1Copy = mProgram.GetProcAddress("DrawColumnRt1Copy"); - DrawColumnRt1Add = mProgram.GetProcAddress("DrawColumnRt1Add"); - DrawColumnRt1Shaded = mProgram.GetProcAddress("DrawColumnRt1Shaded"); - DrawColumnRt1AddClamp = mProgram.GetProcAddress("DrawColumnRt1AddClamp"); - DrawColumnRt1SubClamp = mProgram.GetProcAddress("DrawColumnRt1SubClamp"); - DrawColumnRt1RevSubClamp = mProgram.GetProcAddress("DrawColumnRt1RevSubClamp"); - DrawColumnRt1Translated = mProgram.GetProcAddress("DrawColumnRt1Translated"); - DrawColumnRt1TlatedAdd = mProgram.GetProcAddress("DrawColumnRt1TlatedAdd"); - DrawColumnRt1AddClampTranslated = mProgram.GetProcAddress("DrawColumnRt1AddClampTranslated"); - DrawColumnRt1SubClampTranslated = mProgram.GetProcAddress("DrawColumnRt1SubClampTranslated"); - DrawColumnRt1RevSubClampTranslated = mProgram.GetProcAddress("DrawColumnRt1RevSubClampTranslated"); - DrawColumnRt4 = mProgram.GetProcAddress("DrawColumnRt4"); - DrawColumnRt4Copy = mProgram.GetProcAddress("DrawColumnRt4Copy"); - DrawColumnRt4Add = mProgram.GetProcAddress("DrawColumnRt4Add"); - DrawColumnRt4Shaded = mProgram.GetProcAddress("DrawColumnRt4Shaded"); - DrawColumnRt4AddClamp = mProgram.GetProcAddress("DrawColumnRt4AddClamp"); - DrawColumnRt4SubClamp = mProgram.GetProcAddress("DrawColumnRt4SubClamp"); - DrawColumnRt4RevSubClamp = mProgram.GetProcAddress("DrawColumnRt4RevSubClamp"); - DrawColumnRt4Translated = mProgram.GetProcAddress("DrawColumnRt4Translated"); - DrawColumnRt4TlatedAdd = mProgram.GetProcAddress("DrawColumnRt4TlatedAdd"); - DrawColumnRt4AddClampTranslated = mProgram.GetProcAddress("DrawColumnRt4AddClampTranslated"); - DrawColumnRt4SubClampTranslated = mProgram.GetProcAddress("DrawColumnRt4SubClampTranslated"); - DrawColumnRt4RevSubClampTranslated = mProgram.GetProcAddress("DrawColumnRt4RevSubClampTranslated"); - DrawSpan = mProgram.GetProcAddress("DrawSpan"); - DrawSpanMasked = mProgram.GetProcAddress("DrawSpanMasked"); - DrawSpanTranslucent = mProgram.GetProcAddress("DrawSpanTranslucent"); - DrawSpanMaskedTranslucent = mProgram.GetProcAddress("DrawSpanMaskedTranslucent"); - DrawSpanAddClamp = mProgram.GetProcAddress("DrawSpanAddClamp"); - DrawSpanMaskedAddClamp = mProgram.GetProcAddress("DrawSpanMaskedAddClamp"); - vlinec1 = mProgram.GetProcAddress("vlinec1"); - vlinec4 = mProgram.GetProcAddress("vlinec4"); - mvlinec1 = mProgram.GetProcAddress("mvlinec1"); - mvlinec4 = mProgram.GetProcAddress("mvlinec4"); - tmvline1_add = mProgram.GetProcAddress("tmvline1_add"); - tmvline4_add = mProgram.GetProcAddress("tmvline4_add"); - tmvline1_addclamp = mProgram.GetProcAddress("tmvline1_addclamp"); - tmvline4_addclamp = mProgram.GetProcAddress("tmvline4_addclamp"); - tmvline1_subclamp = mProgram.GetProcAddress("tmvline1_subclamp"); - tmvline4_subclamp = mProgram.GetProcAddress("tmvline4_subclamp"); - tmvline1_revsubclamp = mProgram.GetProcAddress("tmvline1_revsubclamp"); - tmvline4_revsubclamp = mProgram.GetProcAddress("tmvline4_revsubclamp"); - DrawSky1 = mProgram.GetProcAddress("DrawSky1"); - DrawSky4 = mProgram.GetProcAddress("DrawSky4"); - DrawDoubleSky1 = mProgram.GetProcAddress("DrawDoubleSky1"); - DrawDoubleSky4 = mProgram.GetProcAddress("DrawDoubleSky4"); - for (int i = 0; i < NumTriBlendModes(); i++) - { - TriDrawNormal8.push_back(mProgram.GetProcAddress("TriDraw8_" + std::to_string(i))); - TriDrawNormal32.push_back(mProgram.GetProcAddress("TriDraw32_" + std::to_string(i))); - TriFillNormal8.push_back(mProgram.GetProcAddress("TriFill8_" + std::to_string(i))); - TriFillNormal32.push_back(mProgram.GetProcAddress("TriFill32_" + std::to_string(i))); - TriDrawSubsector8.push_back(mProgram.GetProcAddress("TriDrawSubsector8_" + std::to_string(i))); - TriDrawSubsector32.push_back(mProgram.GetProcAddress("TriDrawSubsector32_" + std::to_string(i))); - TriFillSubsector8.push_back(mProgram.GetProcAddress("TriFillSubsector8_" + std::to_string(i))); - TriFillSubsector32.push_back(mProgram.GetProcAddress("TriFillSubsector32_" + std::to_string(i))); - } - TriStencil = mProgram.GetProcAddress("TriStencil"); - TriStencilClose = mProgram.GetProcAddress("TriStencilClose"); - -#if 0 - std::vector foo(1024 * 4); - std::vector boo(256 * 256 * 4); - DrawColumnArgs args = { 0 }; - WorkerThreadData thread = { 0 }; - thread.core = 0; - thread.num_cores = 1; - thread.pass_start_y = 0; - thread.pass_end_y = 3600; - thread.temp = foo.data(); - foo[125 * 4] = 1234; - foo[126 * 4] = 1234; - for (int i = 0; i < 16; i++) - boo[i] = i; - args.dest = boo.data() + 4; - args.dest_y = 125; - args.pitch = 256; - args.count = 1; - args.texturefrac = 0; - args.flags = 0; - args.iscale = 252769; - args.light = 256; - args.color = 4279179008; - args.srcalpha = 12; - args.destalpha = 256; - args.light_red = 192; - args.light_green = 256; - args.light_blue = 128; - DrawColumnRt4AddClamp(&args, &thread); -#endif - - mProgram.StopLogFatalErrors(); -} - -void LLVMDrawersImpl::CodegenDrawColumn(const char *name, DrawColumnVariant variant, DrawColumnMethod method) -{ - llvm::IRBuilder<> builder(mProgram.context()); - SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); - - SSAFunction function(name); - function.add_parameter(GetDrawColumnArgsStruct(mProgram.context())); - function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); - function.create_public(); - - DrawColumnCodegen codegen; - codegen.Generate(variant, method, function.parameter(0), function.parameter(1)); - - builder.CreateRetVoid(); - - if (llvm::verifyFunction(*function.func)) - I_FatalError("verifyFunction failed for CodegenDrawColumn()"); -} - -void LLVMDrawersImpl::CodegenDrawSpan(const char *name, DrawSpanVariant variant) -{ - llvm::IRBuilder<> builder(mProgram.context()); - SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); - - SSAFunction function(name); - function.add_parameter(GetDrawSpanArgsStruct(mProgram.context())); - function.create_public(); - - DrawSpanCodegen codegen; - codegen.Generate(variant, function.parameter(0)); - - builder.CreateRetVoid(); - - if (llvm::verifyFunction(*function.func)) - I_FatalError("verifyFunction failed for CodegenDrawSpan()"); -} - -void LLVMDrawersImpl::CodegenDrawWall(const char *name, DrawWallVariant variant, int columns) -{ - llvm::IRBuilder<> builder(mProgram.context()); - SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); - - SSAFunction function(name); - function.add_parameter(GetDrawWallArgsStruct(mProgram.context())); - function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); - function.create_public(); - - DrawWallCodegen codegen; - codegen.Generate(variant, columns == 4, function.parameter(0), function.parameter(1)); - - builder.CreateRetVoid(); - - if (llvm::verifyFunction(*function.func)) - I_FatalError("verifyFunction failed for CodegenDrawWall()"); -} - -void LLVMDrawersImpl::CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns) -{ - llvm::IRBuilder<> builder(mProgram.context()); - SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); - - SSAFunction function(name); - function.add_parameter(GetDrawSkyArgsStruct(mProgram.context())); - function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); - function.create_public(); - - DrawSkyCodegen codegen; - codegen.Generate(variant, columns == 4, function.parameter(0), function.parameter(1)); - - builder.CreateRetVoid(); - - if (llvm::verifyFunction(*function.func)) - I_FatalError("verifyFunction failed for CodegenDrawSky()"); -} - -void LLVMDrawersImpl::CodegenDrawTriangle(const std::string &name, TriDrawVariant variant, TriBlendMode blendmode, bool truecolor) -{ - llvm::IRBuilder<> builder(mProgram.context()); - SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); - - SSAFunction function(name); - function.add_parameter(GetTriDrawTriangleArgs(mProgram.context())); - function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); - function.create_public(); - - DrawTriangleCodegen codegen; - codegen.Generate(variant, blendmode, truecolor, function.parameter(0), function.parameter(1)); - - builder.CreateRetVoid(); - - if (llvm::verifyFunction(*function.func)) - I_FatalError("verifyFunction failed for CodegenDrawTriangle(%d, %d, %d)", (int)variant, (int)blendmode, (int)truecolor); -} - -llvm::Type *LLVMDrawersImpl::GetDrawColumnArgsStruct(llvm::LLVMContext &context) -{ - std::vector elements; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint32_t *dest; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source2; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *colormap; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *translation; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *basecolors; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t pitch; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t count; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t dest_y; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t iscale; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t texturefracx; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureheight; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t texturefrac; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t color; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srccolor; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - return llvm::StructType::create(context, elements, "DrawColumnArgs", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawersImpl::GetDrawSpanArgsStruct(llvm::LLVMContext &context) -{ - std::vector elements; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *destorg; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t destpitch; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xfrac; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t yfrac; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xstep; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ystep; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x1; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x2; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t y; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xbits; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ybits; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - return llvm::StructType::create(context, elements, "DrawSpanArgs", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawersImpl::GetDrawWallArgsStruct(llvm::LLVMContext &context) -{ - std::vector elements; - elements.push_back(llvm::Type::getInt8PtrTy(context)); - for (int i = 0; i < 8; i++) - elements.push_back(llvm::Type::getInt8PtrTy(context)); - for (int i = 0; i < 25; i++) - elements.push_back(llvm::Type::getInt32Ty(context)); - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - return llvm::StructType::create(context, elements, "DrawWallArgs", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawersImpl::GetDrawSkyArgsStruct(llvm::LLVMContext &context) -{ - std::vector elements; - elements.push_back(llvm::Type::getInt8PtrTy(context)); - for (int i = 0; i < 8; i++) - elements.push_back(llvm::Type::getInt8PtrTy(context)); - for (int i = 0; i < 15; i++) - elements.push_back(llvm::Type::getInt32Ty(context)); - return llvm::StructType::create(context, elements, "DrawSkyArgs", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawersImpl::GetWorkerThreadDataStruct(llvm::LLVMContext &context) -{ - std::vector elements; - for (int i = 0; i < 4; i++) - elements.push_back(llvm::Type::getInt32Ty(context)); - elements.push_back(llvm::Type::getInt8PtrTy(context)); - return llvm::StructType::create(context, elements, "ThreadData", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawersImpl::GetTriVertexStruct(llvm::LLVMContext &context) -{ - std::vector elements; - for (int i = 0; i < 4 + TriVertex::NumVarying; i++) - elements.push_back(llvm::Type::getFloatTy(context)); - return llvm::StructType::create(context, elements, "TriVertex", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawersImpl::GetTriMatrixStruct(llvm::LLVMContext &context) -{ - std::vector elements; - for (int i = 0; i < 4 * 4; i++) - elements.push_back(llvm::Type::getFloatTy(context)); - return llvm::StructType::create(context, elements, "TriMatrix", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawersImpl::GetTriUniformsStruct(llvm::LLVMContext &context) -{ - std::vector elements; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t subsectorDepth; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t color; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - elements.push_back(GetTriMatrixStruct(context)); // TriMatrix objectToClip - return llvm::StructType::create(context, elements, "TriUniforms", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawersImpl::GetTriDrawTriangleArgs(llvm::LLVMContext &context) -{ - std::vector elements; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *dest; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t pitch; - elements.push_back(GetTriVertexStruct(context)); // TriVertex *v1; - elements.push_back(GetTriVertexStruct(context)); // TriVertex *v2; - elements.push_back(GetTriVertexStruct(context)); // TriVertex *v3; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipleft; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipright; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t cliptop; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipbottom; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *texturePixels; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureWidth; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureHeight; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *translation; - elements.push_back(GetTriUniformsStruct(context)); // const TriUniforms *uniforms; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *stencilValues; - elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *stencilMasks; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t stencilPitch; - elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilTestValue; - elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilWriteValue; - elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *subsectorGBuffer; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *colormaps; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *RGB32k; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *BaseColors; - return llvm::StructType::create(context, elements, "TriDrawTriangle", false)->getPointerTo(); -} - -///////////////////////////////////////////////////////////////////////////// - -namespace { static bool LogFatalErrors = false; } - -LLVMProgram::LLVMProgram() -{ - using namespace llvm; - - // We have to extra careful about this because both LLVM and ZDoom made - // the very unwise decision to hook atexit. To top it off, LLVM decided - // to log something in the atexit handler.. - LogFatalErrors = true; - - install_fatal_error_handler([](void *user_data, const std::string& reason, bool gen_crash_diag) { - if (LogFatalErrors) - I_FatalError("LLVM fatal error: %s", reason.c_str()); - }); - - InitializeNativeTarget(); - InitializeNativeTargetAsmPrinter(); - - mContext = std::make_unique(); -} - -void LLVMProgram::CreateModule() -{ - mModule = std::make_unique("render", context()); -} - -bool LLVMProgram::LoadCachedModule(int version, std::string targetCPU) -{ - FString filename = GetDrawerCacheFilename(version, targetCPU.c_str()); - FILE *file = fopen(filename, "rb"); - if (!file) - return false; - - bool success = false; - std::string data; - - fseek(file, 0, SEEK_END); - int length = ftell(file); - fseek(file, 0, SEEK_SET); - if (length > 0) - { - data.resize(length); - success = fread(&data[0], length, 1, file) == 1; - } - - fclose(file); - if (!success) - return false; - - auto result = llvm::parseBitcodeFile(llvm::MemoryBufferRef(data, filename.GetChars()), *mContext.get()); - if (!result) - return false; - -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - mModule.reset(result.get()); -#else - mModule = std::move(result.get()); -#endif - return true; -} - -void LLVMProgram::SaveCachedModule(llvm::Module *module, int version, std::string targetCPU) -{ - std::string str; - llvm::raw_string_ostream stream(str); - llvm::WriteBitcodeToFile(module, stream); - std::string data = stream.str(); - - FString filename = GetDrawerCacheFilename(version, targetCPU.c_str()); - FILE *file = fopen(filename, "wb"); - if (file) - { - fwrite(data.data(), data.size(), 1, file); - fclose(file); - } -} - -FString LLVMProgram::GetDrawerCacheFilename(int version, FString cpu) -{ - FString path = M_GetCachePath(true); - FString filename; - filename.Format("%s/LLVMDrawers-%d-%s.bc", path.GetChars(), version, cpu.GetChars()); - return filename; -} - -std::string LLVMProgram::GetTargetCPU() -{ - using namespace llvm; - std::string mcpu = sys::getHostCPUName(); - if (std::string(CPU.CPUString).find("G840") != std::string::npos && mcpu == "sandybridge") - mcpu = "westmere"; // Pentium G840 is misdetected as a sandy bridge CPU - - if (stricmp(llvm_cpu, "auto") != 0) - { - mcpu = llvm_cpu; - Printf("Overriding LLVM CPU target to %s\n", mcpu.c_str()); - } - return mcpu; -} - -void LLVMProgram::CreateEE(int version, std::string targetCPU, bool optimize) -{ - using namespace llvm; - - std::string errorstring; - - llvm::Module *module = mModule.get(); - EngineBuilder engineBuilder(std::move(mModule)); - engineBuilder.setErrorStr(&errorstring); - engineBuilder.setOptLevel(CodeGenOpt::Aggressive); - engineBuilder.setEngineKind(EngineKind::JIT); - engineBuilder.setMCPU(targetCPU); - machine = engineBuilder.selectTarget(); - if (!machine) - I_FatalError("Could not create LLVM target machine"); - -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - std::string targetTriple = machine->getTargetTriple(); -#else - std::string targetTriple = machine->getTargetTriple().getTriple(); -#endif - std::string cpuName = machine->getTargetCPU(); - Printf("LLVM target triple: %s\n", targetTriple.c_str()); - Printf("LLVM target CPU: %s\n", cpuName.c_str()); - - if (optimize) - { - Printf("Optimizing drawers..\n"); - - module->setTargetTriple(targetTriple); -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - module->setDataLayout(new DataLayout(*machine->getSubtargetImpl()->getDataLayout())); -#else - module->setDataLayout(machine->createDataLayout()); -#endif - - legacy::FunctionPassManager PerFunctionPasses(module); - legacy::PassManager PerModulePasses; - -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8) - PerFunctionPasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); - PerModulePasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); -#endif - - PassManagerBuilder passManagerBuilder; - passManagerBuilder.OptLevel = 3; - passManagerBuilder.SizeLevel = 0; - passManagerBuilder.Inliner = createFunctionInliningPass(); - passManagerBuilder.SLPVectorize = true; - passManagerBuilder.LoopVectorize = true; - passManagerBuilder.LoadCombine = true; - passManagerBuilder.populateModulePassManager(PerModulePasses); - passManagerBuilder.populateFunctionPassManager(PerFunctionPasses); - - // Run function passes: - PerFunctionPasses.doInitialization(); - for (llvm::Function &func : *module) - { - if (!func.isDeclaration()) - PerFunctionPasses.run(func); - } - PerFunctionPasses.doFinalization(); - - // Run module passes: - PerModulePasses.run(*module); - - SaveCachedModule(module, version, targetCPU); - } - - Printf("Compiling drawers..\n"); - - // Create execution engine and generate machine code - mEngine.reset(engineBuilder.create(machine)); - if (!mEngine) - I_FatalError("Could not create LLVM execution engine: %s", errorstring.c_str()); - - mEngine->finalizeObject(); -} - -std::string LLVMProgram::GenerateAssembly(std::string cpuName) -{ - using namespace llvm; - - std::string errorstring; - - llvm::Module *module = mModule.get(); - EngineBuilder engineBuilder(std::move(mModule)); - engineBuilder.setErrorStr(&errorstring); - engineBuilder.setOptLevel(CodeGenOpt::Aggressive); - engineBuilder.setEngineKind(EngineKind::JIT); - engineBuilder.setMCPU(cpuName); - machine = engineBuilder.selectTarget(); - if (!machine) - I_FatalError("Could not create LLVM target machine"); - -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - std::string targetTriple = machine->getTargetTriple(); -#else - std::string targetTriple = machine->getTargetTriple().getTriple(); -#endif - - module->setTargetTriple(targetTriple); -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - module->setDataLayout(new DataLayout(*machine->getSubtargetImpl()->getDataLayout())); -#else - module->setDataLayout(machine->createDataLayout()); -#endif - - legacy::FunctionPassManager PerFunctionPasses(module); - legacy::PassManager PerModulePasses; - -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8) - PerFunctionPasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); - PerModulePasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); -#endif - - SmallString<16*1024> str; -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - raw_svector_ostream vecstream(str); - formatted_raw_ostream stream(vecstream); -#else - raw_svector_ostream stream(str); -#endif - machine->addPassesToEmitFile(PerModulePasses, stream, TargetMachine::CGFT_AssemblyFile); - - PassManagerBuilder passManagerBuilder; - passManagerBuilder.OptLevel = 3; - passManagerBuilder.SizeLevel = 0; - passManagerBuilder.Inliner = createFunctionInliningPass(); - passManagerBuilder.SLPVectorize = true; - passManagerBuilder.LoopVectorize = true; - passManagerBuilder.LoadCombine = true; - passManagerBuilder.populateModulePassManager(PerModulePasses); - passManagerBuilder.populateFunctionPassManager(PerFunctionPasses); - - // Run function passes: - PerFunctionPasses.doInitialization(); - for (llvm::Function &func : *module) - { - if (!func.isDeclaration()) - PerFunctionPasses.run(func); - } - PerFunctionPasses.doFinalization(); - - // Run module passes: - PerModulePasses.run(*module); - - return str.c_str(); -} - -std::string LLVMProgram::DumpModule() -{ - std::string str; - llvm::raw_string_ostream stream(str); -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - mModule->print(stream, nullptr); -#else - mModule->print(stream, nullptr, false, true); -#endif - return stream.str(); -} - -void *LLVMProgram::PointerToFunction(const char *name) -{ - return reinterpret_cast(mEngine->getFunctionAddress(name)); -} - -void LLVMProgram::StopLogFatalErrors() -{ - LogFatalErrors = false; -} diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index b7be3ceed..716b30c0d 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -38,7 +38,7 @@ #include "r_data/colormaps.h" #include "r_plane.h" #include "r_draw_rgba.h" -#include "r_compiler/llvmdrawers.h" +#include "r_drawers.h" #include "gl/data/gl_matrix.h" #include "gi.h" @@ -105,7 +105,7 @@ public: { if (thread->skipped_by_thread(args.y)) return; - LLVMDrawers::Instance()->DrawSpan(&args); + Drawers::Instance()->DrawSpan(&args); } FString DebugInfo() override @@ -146,7 +146,7 @@ public: { if (thread->skipped_by_thread(args.y)) return; - LLVMDrawers::Instance()->DrawSpanMasked(&args); + Drawers::Instance()->DrawSpanMasked(&args); } }; @@ -157,7 +157,7 @@ public: { if (thread->skipped_by_thread(args.y)) return; - LLVMDrawers::Instance()->DrawSpanTranslucent(&args); + Drawers::Instance()->DrawSpanTranslucent(&args); } }; @@ -168,7 +168,7 @@ public: { if (thread->skipped_by_thread(args.y)) return; - LLVMDrawers::Instance()->DrawSpanMaskedTranslucent(&args); + Drawers::Instance()->DrawSpanMaskedTranslucent(&args); } }; @@ -179,7 +179,7 @@ public: { if (thread->skipped_by_thread(args.y)) return; - LLVMDrawers::Instance()->DrawSpanAddClamp(&args); + Drawers::Instance()->DrawSpanAddClamp(&args); } }; @@ -190,7 +190,7 @@ public: { if (thread->skipped_by_thread(args.y)) return; - LLVMDrawers::Instance()->DrawSpanMaskedAddClamp(&args); + Drawers::Instance()->DrawSpanMaskedAddClamp(&args); } }; @@ -251,7 +251,7 @@ public: void Execute(DrawerThread *thread) override { WorkerThreadData d = ThreadData(thread); - LLVMDrawers::Instance()->vlinec4(&args, &d); + Drawers::Instance()->vlinec4(&args, &d); } FString DebugInfo() override @@ -312,7 +312,7 @@ public: void Execute(DrawerThread *thread) override { WorkerThreadData d = ThreadData(thread); - LLVMDrawers::Instance()->vlinec1(&args, &d); + Drawers::Instance()->vlinec1(&args, &d); } FString DebugInfo() override @@ -383,7 +383,7 @@ public: void Execute(DrawerThread *thread) override { WorkerThreadData d = ThreadData(thread); - LLVMDrawers::Instance()->DrawColumn(&args, &d); + Drawers::Instance()->DrawColumn(&args, &d); } }; @@ -438,7 +438,7 @@ public: \ void Execute(DrawerThread *thread) override \ { \ WorkerThreadData d = ThreadData(thread); \ - LLVMDrawers::Instance()->func(&args, &d); \ + Drawers::Instance()->func(&args, &d); \ } \ }; diff --git a/src/r_drawers.cpp b/src/r_drawers.cpp new file mode 100644 index 000000000..6d4aaa055 --- /dev/null +++ b/src/r_drawers.cpp @@ -0,0 +1,423 @@ +/* +** LLVM code generated drawers +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include "i_system.h" +#include "r_drawers.h" +#include "x86.h" +#include "c_cvars.h" +#include "version.h" +#include "m_misc.h" + +CUSTOM_CVAR(String, llvm_cpu, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL) +{ + Printf("You must restart " GAMENAME " for this change to take effect.\n"); +} + +///////////////////////////////////////////////////////////////////////////// + +extern "C" +{ + void DrawColumn_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnAdd_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnShaded_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnAddClamp_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnSubClamp_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRevSubClamp_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnTranslated_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnTlatedAdd_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnAddClampTranslated_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnSubClampTranslated_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRevSubClampTranslated_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void FillColumn_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void FillColumnAdd_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void FillColumnAddClamp_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void FillColumnSubClamp_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void FillColumnRevSubClamp_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt1_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt1Copy_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt1Add_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt1Shaded_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt1AddClamp_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt1SubClamp_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt1RevSubClamp_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt1Translated_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt1TlatedAdd_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt1AddClampTranslated_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt1SubClampTranslated_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt1RevSubClampTranslated_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt4_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt4Copy_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt4Add_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt4Shaded_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt4AddClamp_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt4SubClamp_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt4RevSubClamp_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt4Translated_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt4TlatedAdd_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt4AddClampTranslated_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt4SubClampTranslated_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawColumnRt4RevSubClampTranslated_SSE2(const DrawColumnArgs *, const WorkerThreadData *); + void DrawSpan_SSE2(const DrawSpanArgs *); + void DrawSpanMasked_SSE2(const DrawSpanArgs *); + void DrawSpanTranslucent_SSE2(const DrawSpanArgs *); + void DrawSpanMaskedTranslucent_SSE2(const DrawSpanArgs *); + void DrawSpanAddClamp_SSE2(const DrawSpanArgs *); + void DrawSpanMaskedAddClamp_SSE2(const DrawSpanArgs *); + void vlinec1_SSE2(const DrawWallArgs *, const WorkerThreadData *); + void vlinec4_SSE2(const DrawWallArgs *, const WorkerThreadData *); + void mvlinec1_SSE2(const DrawWallArgs *, const WorkerThreadData *); + void mvlinec4_SSE2(const DrawWallArgs *, const WorkerThreadData *); + void tmvline1_add_SSE2(const DrawWallArgs *, const WorkerThreadData *); + void tmvline4_add_SSE2(const DrawWallArgs *, const WorkerThreadData *); + void tmvline1_addclamp_SSE2(const DrawWallArgs *, const WorkerThreadData *); + void tmvline4_addclamp_SSE2(const DrawWallArgs *, const WorkerThreadData *); + void tmvline1_subclamp_SSE2(const DrawWallArgs *, const WorkerThreadData *); + void tmvline4_subclamp_SSE2(const DrawWallArgs *, const WorkerThreadData *); + void tmvline1_revsubclamp_SSE2(const DrawWallArgs *, const WorkerThreadData *); + void tmvline4_revsubclamp_SSE2(const DrawWallArgs *, const WorkerThreadData *); + void DrawSky1_SSE2(const DrawSkyArgs *, const WorkerThreadData *); + void DrawSky4_SSE2(const DrawSkyArgs *, const WorkerThreadData *); + void DrawDoubleSky1_SSE2(const DrawSkyArgs *, const WorkerThreadData *); + void DrawDoubleSky4_SSE2(const DrawSkyArgs *, const WorkerThreadData *); + void TriDrawNormal8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal8_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal8_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal8_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal8_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal8_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal8_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal8_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal8_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriStencil_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriStencilClose_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); +} + +///////////////////////////////////////////////////////////////////////////// + +Drawers *Drawers::Instance() +{ + static Drawers drawers; + static bool firstcall = true; + + if (!firstcall) + return &drawers; + + drawers.DrawColumn = DrawColumn_SSE2; + drawers.DrawColumnAdd = DrawColumnAdd_SSE2; + drawers.DrawColumnShaded = DrawColumnShaded_SSE2; + drawers.DrawColumnAddClamp = DrawColumnAddClamp_SSE2; + drawers.DrawColumnSubClamp = DrawColumnSubClamp_SSE2; + drawers.DrawColumnRevSubClamp = DrawColumnRevSubClamp_SSE2; + drawers.DrawColumnTranslated = DrawColumnTranslated_SSE2; + drawers.DrawColumnTlatedAdd = DrawColumnTlatedAdd_SSE2; + drawers.DrawColumnAddClampTranslated = DrawColumnAddClampTranslated_SSE2; + drawers.DrawColumnSubClampTranslated = DrawColumnSubClampTranslated_SSE2; + drawers.DrawColumnRevSubClampTranslated = DrawColumnRevSubClampTranslated_SSE2; + drawers.FillColumn = FillColumn_SSE2; + drawers.FillColumnAdd = FillColumnAdd_SSE2; + drawers.FillColumnAddClamp = FillColumnAddClamp_SSE2; + drawers.FillColumnSubClamp = FillColumnSubClamp_SSE2; + drawers.FillColumnRevSubClamp = FillColumnRevSubClamp_SSE2; + drawers.DrawColumnRt1 = DrawColumnRt1_SSE2; + drawers.DrawColumnRt1Copy = DrawColumnRt1Copy_SSE2; + drawers.DrawColumnRt1Add = DrawColumnRt1Add_SSE2; + drawers.DrawColumnRt1Shaded = DrawColumnRt1Shaded_SSE2; + drawers.DrawColumnRt1AddClamp = DrawColumnRt1AddClamp_SSE2; + drawers.DrawColumnRt1SubClamp = DrawColumnRt1SubClamp_SSE2; + drawers.DrawColumnRt1RevSubClamp = DrawColumnRt1RevSubClamp_SSE2; + drawers.DrawColumnRt1Translated = DrawColumnRt1Translated_SSE2; + drawers.DrawColumnRt1TlatedAdd = DrawColumnRt1TlatedAdd_SSE2; + drawers.DrawColumnRt1AddClampTranslated = DrawColumnRt1AddClampTranslated_SSE2; + drawers.DrawColumnRt1SubClampTranslated = DrawColumnRt1SubClampTranslated_SSE2; + drawers.DrawColumnRt1RevSubClampTranslated = DrawColumnRt1RevSubClampTranslated_SSE2; + drawers.DrawColumnRt4 = DrawColumnRt4_SSE2; + drawers.DrawColumnRt4Copy = DrawColumnRt4Copy_SSE2; + drawers.DrawColumnRt4Add = DrawColumnRt4Add_SSE2; + drawers.DrawColumnRt4Shaded = DrawColumnRt4Shaded_SSE2; + drawers.DrawColumnRt4AddClamp = DrawColumnRt4AddClamp_SSE2; + drawers.DrawColumnRt4SubClamp = DrawColumnRt4SubClamp_SSE2; + drawers.DrawColumnRt4RevSubClamp = DrawColumnRt4RevSubClamp_SSE2; + drawers.DrawColumnRt4Translated = DrawColumnRt4Translated_SSE2; + drawers.DrawColumnRt4TlatedAdd = DrawColumnRt4TlatedAdd_SSE2; + drawers.DrawColumnRt4AddClampTranslated = DrawColumnRt4AddClampTranslated_SSE2; + drawers.DrawColumnRt4SubClampTranslated = DrawColumnRt4SubClampTranslated_SSE2; + drawers.DrawColumnRt4RevSubClampTranslated = DrawColumnRt4RevSubClampTranslated_SSE2; + drawers.DrawSpan = DrawSpan_SSE2; + drawers.DrawSpanMasked = DrawSpanMasked_SSE2; + drawers.DrawSpanTranslucent = DrawSpanTranslucent_SSE2; + drawers.DrawSpanMaskedTranslucent = DrawSpanMaskedTranslucent_SSE2; + drawers.DrawSpanAddClamp = DrawSpanAddClamp_SSE2; + drawers.DrawSpanMaskedAddClamp = DrawSpanMaskedAddClamp_SSE2; + drawers.vlinec1 = vlinec1_SSE2; + drawers.vlinec4 = vlinec4_SSE2; + drawers.mvlinec1 = mvlinec1_SSE2; + drawers.mvlinec4 = mvlinec4_SSE2; + drawers.tmvline1_add = tmvline1_add_SSE2; + drawers.tmvline4_add = tmvline4_add_SSE2; + drawers.tmvline1_addclamp = tmvline1_addclamp_SSE2; + drawers.tmvline4_addclamp = tmvline4_addclamp_SSE2; + drawers.tmvline1_subclamp = tmvline1_subclamp_SSE2; + drawers.tmvline4_subclamp = tmvline4_subclamp_SSE2; + drawers.tmvline1_revsubclamp = tmvline1_revsubclamp_SSE2; + drawers.tmvline4_revsubclamp = tmvline4_revsubclamp_SSE2; + drawers.DrawSky1 = DrawSky1_SSE2; + drawers.DrawSky4 = DrawSky4_SSE2; + drawers.DrawDoubleSky1 = DrawDoubleSky1_SSE2; + drawers.DrawDoubleSky4 = DrawDoubleSky4_SSE2; + drawers.TriDrawNormal8.push_back(TriDrawNormal8_0_SSE2); + drawers.TriDrawNormal8.push_back(TriDrawNormal8_1_SSE2); + drawers.TriDrawNormal8.push_back(TriDrawNormal8_2_SSE2); + drawers.TriDrawNormal8.push_back(TriDrawNormal8_3_SSE2); + drawers.TriDrawNormal8.push_back(TriDrawNormal8_4_SSE2); + drawers.TriDrawNormal8.push_back(TriDrawNormal8_5_SSE2); + drawers.TriDrawNormal8.push_back(TriDrawNormal8_6_SSE2); + drawers.TriDrawNormal8.push_back(TriDrawNormal8_7_SSE2); + drawers.TriDrawNormal8.push_back(TriDrawNormal8_8_SSE2); + drawers.TriDrawNormal8.push_back(TriDrawNormal8_9_SSE2); + drawers.TriDrawNormal8.push_back(TriDrawNormal8_10_SSE2); + drawers.TriDrawNormal8.push_back(TriDrawNormal8_11_SSE2); + drawers.TriDrawNormal8.push_back(TriDrawNormal8_12_SSE2); + drawers.TriDrawNormal32.push_back(TriDrawNormal32_0_SSE2); + drawers.TriDrawNormal32.push_back(TriDrawNormal32_1_SSE2); + drawers.TriDrawNormal32.push_back(TriDrawNormal32_2_SSE2); + drawers.TriDrawNormal32.push_back(TriDrawNormal32_3_SSE2); + drawers.TriDrawNormal32.push_back(TriDrawNormal32_4_SSE2); + drawers.TriDrawNormal32.push_back(TriDrawNormal32_5_SSE2); + drawers.TriDrawNormal32.push_back(TriDrawNormal32_6_SSE2); + drawers.TriDrawNormal32.push_back(TriDrawNormal32_7_SSE2); + drawers.TriDrawNormal32.push_back(TriDrawNormal32_8_SSE2); + drawers.TriDrawNormal32.push_back(TriDrawNormal32_9_SSE2); + drawers.TriDrawNormal32.push_back(TriDrawNormal32_10_SSE2); + drawers.TriDrawNormal32.push_back(TriDrawNormal32_11_SSE2); + drawers.TriDrawNormal32.push_back(TriDrawNormal32_12_SSE2); + drawers.TriFillNormal8.push_back(TriFillNormal8_0_SSE2); + drawers.TriFillNormal8.push_back(TriFillNormal8_1_SSE2); + drawers.TriFillNormal8.push_back(TriFillNormal8_2_SSE2); + drawers.TriFillNormal8.push_back(TriFillNormal8_3_SSE2); + drawers.TriFillNormal8.push_back(TriFillNormal8_4_SSE2); + drawers.TriFillNormal8.push_back(TriFillNormal8_5_SSE2); + drawers.TriFillNormal8.push_back(TriFillNormal8_6_SSE2); + drawers.TriFillNormal8.push_back(TriFillNormal8_7_SSE2); + drawers.TriFillNormal8.push_back(TriFillNormal8_8_SSE2); + drawers.TriFillNormal8.push_back(TriFillNormal8_9_SSE2); + drawers.TriFillNormal8.push_back(TriFillNormal8_10_SSE2); + drawers.TriFillNormal8.push_back(TriFillNormal8_11_SSE2); + drawers.TriFillNormal8.push_back(TriFillNormal8_12_SSE2); + drawers.TriFillNormal32.push_back(TriFillNormal32_0_SSE2); + drawers.TriFillNormal32.push_back(TriFillNormal32_1_SSE2); + drawers.TriFillNormal32.push_back(TriFillNormal32_2_SSE2); + drawers.TriFillNormal32.push_back(TriFillNormal32_3_SSE2); + drawers.TriFillNormal32.push_back(TriFillNormal32_4_SSE2); + drawers.TriFillNormal32.push_back(TriFillNormal32_5_SSE2); + drawers.TriFillNormal32.push_back(TriFillNormal32_6_SSE2); + drawers.TriFillNormal32.push_back(TriFillNormal32_7_SSE2); + drawers.TriFillNormal32.push_back(TriFillNormal32_8_SSE2); + drawers.TriFillNormal32.push_back(TriFillNormal32_9_SSE2); + drawers.TriFillNormal32.push_back(TriFillNormal32_10_SSE2); + drawers.TriFillNormal32.push_back(TriFillNormal32_11_SSE2); + drawers.TriFillNormal32.push_back(TriFillNormal32_12_SSE2); + drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_0_SSE2); + drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_1_SSE2); + drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_2_SSE2); + drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_3_SSE2); + drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_4_SSE2); + drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_5_SSE2); + drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_6_SSE2); + drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_7_SSE2); + drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_8_SSE2); + drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_9_SSE2); + drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_10_SSE2); + drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_11_SSE2); + drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_12_SSE2); + drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_0_SSE2); + drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_1_SSE2); + drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_2_SSE2); + drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_3_SSE2); + drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_4_SSE2); + drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_5_SSE2); + drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_6_SSE2); + drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_7_SSE2); + drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_8_SSE2); + drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_9_SSE2); + drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_10_SSE2); + drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_11_SSE2); + drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_12_SSE2); + drawers.TriFillSubsector8.push_back(TriFillSubsector8_0_SSE2); + drawers.TriFillSubsector8.push_back(TriFillSubsector8_1_SSE2); + drawers.TriFillSubsector8.push_back(TriFillSubsector8_2_SSE2); + drawers.TriFillSubsector8.push_back(TriFillSubsector8_3_SSE2); + drawers.TriFillSubsector8.push_back(TriFillSubsector8_4_SSE2); + drawers.TriFillSubsector8.push_back(TriFillSubsector8_5_SSE2); + drawers.TriFillSubsector8.push_back(TriFillSubsector8_6_SSE2); + drawers.TriFillSubsector8.push_back(TriFillSubsector8_7_SSE2); + drawers.TriFillSubsector8.push_back(TriFillSubsector8_8_SSE2); + drawers.TriFillSubsector8.push_back(TriFillSubsector8_9_SSE2); + drawers.TriFillSubsector8.push_back(TriFillSubsector8_10_SSE2); + drawers.TriFillSubsector8.push_back(TriFillSubsector8_11_SSE2); + drawers.TriFillSubsector8.push_back(TriFillSubsector8_12_SSE2); + drawers.TriFillSubsector32.push_back(TriFillSubsector32_0_SSE2); + drawers.TriFillSubsector32.push_back(TriFillSubsector32_1_SSE2); + drawers.TriFillSubsector32.push_back(TriFillSubsector32_2_SSE2); + drawers.TriFillSubsector32.push_back(TriFillSubsector32_3_SSE2); + drawers.TriFillSubsector32.push_back(TriFillSubsector32_4_SSE2); + drawers.TriFillSubsector32.push_back(TriFillSubsector32_5_SSE2); + drawers.TriFillSubsector32.push_back(TriFillSubsector32_6_SSE2); + drawers.TriFillSubsector32.push_back(TriFillSubsector32_7_SSE2); + drawers.TriFillSubsector32.push_back(TriFillSubsector32_8_SSE2); + drawers.TriFillSubsector32.push_back(TriFillSubsector32_9_SSE2); + drawers.TriFillSubsector32.push_back(TriFillSubsector32_10_SSE2); + drawers.TriFillSubsector32.push_back(TriFillSubsector32_11_SSE2); + drawers.TriFillSubsector32.push_back(TriFillSubsector32_12_SSE2); + drawers.TriStencil = TriStencil_SSE2; + drawers.TriStencilClose = TriStencilClose_SSE2; + + firstcall = false; + return &drawers; +} + +Drawers::Drawers() +{ + // To do: setup pointers +} + +FString DrawWallArgs::ToString() +{ + FString info; + info.Format("dest_y = %i, count = %i, flags = %i, texturefrac[0] = %u, textureheight[0] = %u", dest_y, count, flags, texturefrac[0], textureheight[0]); + return info; +} + +FString DrawSpanArgs::ToString() +{ + FString info; + info.Format("x1 = %i, x2 = %i, y = %i, flags = %i", x1, x2, y, flags); + return info; +} + +FString DrawColumnArgs::ToString() +{ + FString info; + info.Format("dest_y = %i, count = %i, flags = %i, iscale = %i (%f), texturefrac = %i (%f)", dest_y, count, flags, iscale, ((fixed_t)iscale) / (float)FRACUNIT, texturefrac, ((fixed_t)texturefrac) / (float)FRACUNIT); + return info; +} + +FString DrawSkyArgs::ToString() +{ + FString info; + info.Format("dest_y = %i, count = %i", dest_y, count); + return info; +} diff --git a/src/r_compiler/llvmdrawers.h b/src/r_drawers.h similarity index 93% rename from src/r_compiler/llvmdrawers.h rename to src/r_drawers.h index c5eb96f4c..17168b6f3 100644 --- a/src/r_compiler/llvmdrawers.h +++ b/src/r_drawers.h @@ -22,6 +22,11 @@ #pragma once +#include +#include + +class FString; + struct WorkerThreadData { int32_t core; @@ -63,12 +68,7 @@ struct DrawWallArgs nearest_filter = 2 }; - FString ToString() - { - FString info; - info.Format("dest_y = %i, count = %i, flags = %i, texturefrac[0] = %u, textureheight[0] = %u", dest_y, count, flags, texturefrac[0], textureheight[0]); - return info; - } + FString ToString(); }; struct DrawSpanArgs @@ -105,12 +105,7 @@ struct DrawSpanArgs nearest_filter = 2 }; - FString ToString() - { - FString info; - info.Format("x1 = %i, x2 = %i, y = %i, flags = %i", x1, x2, y, flags); - return info; - } + FString ToString(); }; struct DrawColumnArgs @@ -150,12 +145,7 @@ struct DrawColumnArgs nearest_filter = 2 }; - FString ToString() - { - FString info; - info.Format("dest_y = %i, count = %i, flags = %i, iscale = %i (%f), texturefrac = %i (%f)", dest_y, count, flags, iscale, ((fixed_t)iscale) / (float)FRACUNIT, texturefrac, ((fixed_t)texturefrac) / (float)FRACUNIT); - return info; - } + FString ToString(); }; struct DrawSkyArgs @@ -173,12 +163,7 @@ struct DrawSkyArgs uint32_t top_color; uint32_t bottom_color; - FString ToString() - { - FString info; - info.Format("dest_y = %i, count = %i", dest_y, count); - return info; - } + FString ToString(); }; struct TriVertex @@ -273,14 +258,12 @@ enum class TriBlendMode inline int NumTriBlendModes() { return (int)TriBlendMode::TranslateRevSub + 1; } -class LLVMDrawers +class Drawers { public: - virtual ~LLVMDrawers() { } + Drawers(); - static void Create(); - static void Destroy(); - static LLVMDrawers *Instance(); + static Drawers *Instance(); void(*DrawColumn)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawColumnAdd)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; @@ -358,7 +341,4 @@ public: std::vector TriFillSubsector32; void(*TriStencil)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; void(*TriStencilClose)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; - -private: - static LLVMDrawers *Singleton; }; diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 29a315a8c..57de59eba 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -43,7 +43,7 @@ #include "r_things.h" #include "v_video.h" #include "r_draw_rgba.h" -#include "r_compiler/llvmdrawers.h" +#include "r_drawers.h" extern unsigned int dc_tspans[4][MAXHEIGHT]; extern unsigned int *dc_ctspan[4]; @@ -107,7 +107,7 @@ public: void Execute(DrawerThread *thread) override { WorkerThreadData d = ThreadData(thread); - LLVMDrawers::Instance()->DrawColumnRt1(&args, &d); + Drawers::Instance()->DrawColumnRt1(&args, &d); } FString DebugInfo() override @@ -124,7 +124,7 @@ public: \ void Execute(DrawerThread *thread) override \ { \ WorkerThreadData d = ThreadData(thread); \ - LLVMDrawers::Instance()->func(&args, &d); \ + Drawers::Instance()->func(&args, &d); \ } \ }; diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index f08d060e8..ed7ab55b9 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -78,7 +78,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian if (drawargs.vcount < 3) return; - auto llvm = LLVMDrawers::Instance(); + auto llvm = Drawers::Instance(); void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *); int bmode = (int)blendmode; switch (variant) diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 270dda894..1c07ce5bd 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -24,7 +24,7 @@ #include "r_draw.h" #include "r_thread.h" -#include "r_compiler/llvmdrawers.h" +#include "r_drawers.h" #include "r_data/r_translate.h" #include "r_data/colormaps.h" diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 708b465e1..74a6da823 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -43,7 +43,7 @@ #include "textures/textures.h" #include "r_data/voxels.h" #include "r_draw_rgba.h" -#include "r_compiler/llvmdrawers.h" +#include "r_drawers.h" #include "r_poly.h" EXTERN_CVAR(Bool, r_shadercolormaps) @@ -57,12 +57,10 @@ void R_InitRenderer(); FSoftwareRenderer::FSoftwareRenderer() { - LLVMDrawers::Create(); } FSoftwareRenderer::~FSoftwareRenderer() { - LLVMDrawers::Destroy(); } //========================================================================== diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 8a97243bb..f4fe251e1 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -7,5 +7,6 @@ if( WIN32 AND NOT CMAKE_SIZEOF_VOID_P MATCHES "8" ) endif() add_subdirectory( updaterevision ) add_subdirectory( zipdir ) +add_subdirectory( drawergen ) set( CROSS_EXPORTS ${CROSS_EXPORTS} PARENT_SCOPE ) diff --git a/tools/drawergen/CMakeLists.txt b/tools/drawergen/CMakeLists.txt new file mode 100644 index 000000000..eef5a0a94 --- /dev/null +++ b/tools/drawergen/CMakeLists.txt @@ -0,0 +1,133 @@ +cmake_minimum_required( VERSION 2.8.7 ) + +include(../../precompiled_headers.cmake) + +# Path where it looks for the LLVM compiled files on Windows +set( LLVM_PRECOMPILED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../llvm" ) + +if( NOT DRAWERGEN_LIBS ) + set( DRAWERGEN_LIBS "" ) +endif() + +include_directories( . ) + +file( GLOB HEADER_FILES + *.h + ssa/*.h + fixedfunction/*.h +) + +if( NOT WIN32 ) + set( LLVM_COMPONENTS core support asmparser asmprinter bitreader bitwriter codegen ipo + irreader transformutils instrumentation profiledata runtimedyld + object instcombine linker analysis selectiondag scalaropts vectorize executionengine + mc mcdisassembler mcparser mcjit target x86asmprinter x86info x86desc x86utils x86codegen ) + + # Example LLVM_DIR folder: C:/Development/Environment/Src/llvm-3.9.0/build/lib/cmake/llvm + find_package(LLVM REQUIRED CONFIG) + message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") + message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") + llvm_map_components_to_libnames( llvm_libs ${LLVM_COMPONENTS} ) + include_directories( ${LLVM_INCLUDE_DIRS} ) + set( DRAWERGEN_LIBS ${DRAWERGEN_LIBS} ${llvm_libs} ) +else() + set( LLVM_COMPONENTS core support asmparser asmprinter bitreader bitwriter codegen passes ipo + irreader transformutils instrumentation profiledata debuginfocodeview runtimedyld + object instcombine linker analysis selectiondag scalaropts vectorize executionengine + mc mcdisassembler mcparser mcjit target x86asmprinter x86info x86desc x86utils x86codegen ) + + include_directories( "${LLVM_PRECOMPILED_DIR}/include" ) + if( X64 ) + include_directories( "${LLVM_PRECOMPILED_DIR}/64bit-include" ) + set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/64bit-" ) + else() + include_directories( "${LLVM_PRECOMPILED_DIR}/32bit-include" ) + set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/32bit-" ) + endif() + foreach(buildtype IN ITEMS RELEASE DEBUG) + set( llvm_libs_${buildtype} "${llvm_libs_base}${buildtype}" ) + set( LLVM_${buildtype}_LIBS "" ) + foreach( llvm_module ${LLVM_COMPONENTS} ) + find_library( LLVM_${llvm_module}_LIBRARY_${buildtype} LLVM${llvm_module} PATHS ${llvm_libs_${buildtype}} ) + set( LLVM_${buildtype}_LIBS ${LLVM_${buildtype}_LIBS} ${LLVM_${llvm_module}_LIBRARY_${buildtype}} ) + endforeach( llvm_module ) + endforeach(buildtype) +endif() + +if( WIN32 ) + if( MSVC_VERSION GREATER 1399 ) + # VC 8+ adds a manifest automatically to the executable. We need to + # merge ours with it. + set( MT_MERGE ON ) + else() + set( TRUSTINFO trustinfo.rc ) + endif() +else( WIN32 ) + set( TRUSTINFO "" ) +endif() + +set (SOURCES + drawergen.cpp + ssa/ssa_bool.cpp + ssa/ssa_float.cpp + ssa/ssa_float_ptr.cpp + ssa/ssa_for_block.cpp + ssa/ssa_function.cpp + ssa/ssa_if_block.cpp + ssa/ssa_int.cpp + ssa/ssa_int_ptr.cpp + ssa/ssa_short.cpp + ssa/ssa_scope.cpp + ssa/ssa_struct_type.cpp + ssa/ssa_ubyte.cpp + ssa/ssa_ubyte_ptr.cpp + ssa/ssa_value.cpp + ssa/ssa_vec4f.cpp + ssa/ssa_vec4f_ptr.cpp + ssa/ssa_vec4i.cpp + ssa/ssa_vec4i_ptr.cpp + ssa/ssa_vec8s.cpp + ssa/ssa_vec16ub.cpp + fixedfunction/drawercodegen.cpp + fixedfunction/drawspancodegen.cpp + fixedfunction/drawwallcodegen.cpp + fixedfunction/drawcolumncodegen.cpp + fixedfunction/drawskycodegen.cpp + fixedfunction/drawtrianglecodegen.cpp +) +enable_precompiled_headers( precomp.h SOURCES ) + +if( NOT CMAKE_CROSSCOMPILING ) + add_executable( drawergen ${SOURCES} ${TRUSTINFO} ${HEADER_FILES} ) + set( CROSS_EXPORTS ${CROSS_EXPORTS} drawergen PARENT_SCOPE ) +endif() + +if( MT_MERGE ) + add_custom_command(TARGET drawergen POST_BUILD + COMMAND mt -inputresource:$ -manifest ${CMAKE_CURRENT_SOURCE_DIR}/trustinfo.txt -outputresource:$ -nologo + COMMENT "Embedding trustinfo into drawergen" ) +endif() + +# Linux - add these flags for LLVM compatibility to prevent crashing +#if ( UNIX AND NOT APPLE ) +# set( CMAKE_EXE_LINKER_FLAGS "-Wl,--exclude-libs,ALL ${CMAKE_EXE_LINKER_FLAGS}" ) +#endif() + +target_link_libraries( drawergen ${DRAWERGEN_LIBS} ) + +if( WIN32 ) + foreach(debuglib ${LLVM_DEBUG_LIBS}) + target_link_libraries( drawergen debug ${debuglib} ) + endforeach(debuglib) + foreach(releaselib ${LLVM_RELEASE_LIBS}) + target_link_libraries( drawergen optimized ${releaselib} ) + endforeach(releaselib) +endif() + +#source_group("Render Compiler" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_compiler/.+") +#source_group("Render Compiler\\SSA" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_compiler/ssa/.+") +#source_group("Render Compiler\\Fixed Function" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_compiler/fixedfunction/.+") + +source_group("Compiler" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/.+\\.(cpp|h)$") +source_group("Compiler\\SSA" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/ssa/.+") +source_group("Compiler\\Fixed Function" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/fixedfunction/.+") diff --git a/tools/drawergen/drawergen.cpp b/tools/drawergen/drawergen.cpp new file mode 100644 index 000000000..dfe5fc11b --- /dev/null +++ b/tools/drawergen/drawergen.cpp @@ -0,0 +1,664 @@ +/* +** LLVM code generated drawers +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include "precomp.h" +#include "fixedfunction/drawspancodegen.h" +#include "fixedfunction/drawwallcodegen.h" +#include "fixedfunction/drawcolumncodegen.h" +#include "fixedfunction/drawskycodegen.h" +#include "fixedfunction/drawtrianglecodegen.h" +#include "ssa/ssa_function.h" +#include "ssa/ssa_scope.h" +#include "ssa/ssa_for_block.h" +#include "ssa/ssa_if_block.h" +#include "ssa/ssa_stack.h" +#include "ssa/ssa_function.h" +#include "ssa/ssa_struct_type.h" +#include "ssa/ssa_value.h" +#include "ssa/ssa_barycentric_weight.h" +#include + +class Exception : public std::exception +{ +public: + Exception(const std::string &message) : message(message) { } + const char *what() const override { return message.c_str(); } + +private: + std::string message; +}; + +class LLVMProgram +{ +public: + LLVMProgram(); + + void CreateModule(); + std::string GenerateAssembly(std::string cpuName); + std::vector GenerateObjectFile(std::string cpuName); + std::string DumpModule(); + + llvm::LLVMContext &context() { return *mContext; } + llvm::Module *module() { return mModule.get(); } + +private: + llvm::TargetMachine *machine = nullptr; + std::unique_ptr mContext; + std::unique_ptr mModule; +}; + +class LLVMDrawers +{ +public: + LLVMDrawers(const std::string &cpuName, const std::string namePostfix); + + std::vector ObjectFile; + +private: + void CodegenDrawColumn(const char *name, DrawColumnVariant variant, DrawColumnMethod method); + void CodegenDrawSpan(const char *name, DrawSpanVariant variant); + void CodegenDrawWall(const char *name, DrawWallVariant variant, int columns); + void CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns); + void CodegenDrawTriangle(const std::string &name, TriDrawVariant variant, TriBlendMode blendmode, bool truecolor); + + static llvm::Type *GetDrawColumnArgsStruct(llvm::LLVMContext &context); + static llvm::Type *GetDrawSpanArgsStruct(llvm::LLVMContext &context); + static llvm::Type *GetDrawWallArgsStruct(llvm::LLVMContext &context); + static llvm::Type *GetDrawSkyArgsStruct(llvm::LLVMContext &context); + static llvm::Type *GetWorkerThreadDataStruct(llvm::LLVMContext &context); + static llvm::Type *GetTriVertexStruct(llvm::LLVMContext &context); + static llvm::Type *GetTriMatrixStruct(llvm::LLVMContext &context); + static llvm::Type *GetTriUniformsStruct(llvm::LLVMContext &context); + static llvm::Type *GetTriDrawTriangleArgs(llvm::LLVMContext &context); + + LLVMProgram mProgram; + std::string mNamePostfix; +}; + +///////////////////////////////////////////////////////////////////////////// + +LLVMDrawers::LLVMDrawers(const std::string &cpuName, const std::string namePostfix) : mNamePostfix(namePostfix) +{ + mProgram.CreateModule(); + + CodegenDrawColumn("FillColumn", DrawColumnVariant::Fill, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnAdd", DrawColumnVariant::FillAdd, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnAddClamp", DrawColumnVariant::FillAddClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnSubClamp", DrawColumnVariant::FillSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnRevSubClamp", DrawColumnVariant::FillRevSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumn", DrawColumnVariant::Draw, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnAdd", DrawColumnVariant::DrawAdd, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnShaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnAddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnSubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnRevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnTranslated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnTlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnAddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnSubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnRevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnRt1", DrawColumnVariant::Draw, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt4", DrawColumnVariant::Draw, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt4); + CodegenDrawSpan("DrawSpan", DrawSpanVariant::Opaque); + CodegenDrawSpan("DrawSpanMasked", DrawSpanVariant::Masked); + CodegenDrawSpan("DrawSpanTranslucent", DrawSpanVariant::Translucent); + CodegenDrawSpan("DrawSpanMaskedTranslucent", DrawSpanVariant::MaskedTranslucent); + CodegenDrawSpan("DrawSpanAddClamp", DrawSpanVariant::AddClamp); + CodegenDrawSpan("DrawSpanMaskedAddClamp", DrawSpanVariant::MaskedAddClamp); + CodegenDrawWall("vlinec1", DrawWallVariant::Opaque, 1); + CodegenDrawWall("vlinec4", DrawWallVariant::Opaque, 4); + CodegenDrawWall("mvlinec1", DrawWallVariant::Masked, 1); + CodegenDrawWall("mvlinec4", DrawWallVariant::Masked, 4); + CodegenDrawWall("tmvline1_add", DrawWallVariant::Add, 1); + CodegenDrawWall("tmvline4_add", DrawWallVariant::Add, 4); + CodegenDrawWall("tmvline1_addclamp", DrawWallVariant::AddClamp, 1); + CodegenDrawWall("tmvline4_addclamp", DrawWallVariant::AddClamp, 4); + CodegenDrawWall("tmvline1_subclamp", DrawWallVariant::SubClamp, 1); + CodegenDrawWall("tmvline4_subclamp", DrawWallVariant::SubClamp, 4); + CodegenDrawWall("tmvline1_revsubclamp", DrawWallVariant::RevSubClamp, 1); + CodegenDrawWall("tmvline4_revsubclamp", DrawWallVariant::RevSubClamp, 4); + CodegenDrawSky("DrawSky1", DrawSkyVariant::Single, 1); + CodegenDrawSky("DrawSky4", DrawSkyVariant::Single, 4); + CodegenDrawSky("DrawDoubleSky1", DrawSkyVariant::Double, 1); + CodegenDrawSky("DrawDoubleSky4", DrawSkyVariant::Double, 4); + for (int i = 0; i < NumTriBlendModes(); i++) + { + CodegenDrawTriangle("TriDrawNormal8_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, false); + CodegenDrawTriangle("TriDrawNormal32_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, true); + CodegenDrawTriangle("TriFillNormal8_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, false); + CodegenDrawTriangle("TriFillNormal32_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, true); + CodegenDrawTriangle("TriDrawSubsector8_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, false); + CodegenDrawTriangle("TriDrawSubsector32_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, true); + CodegenDrawTriangle("TriFillSubsector8_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, false); + CodegenDrawTriangle("TriFillSubsector32_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, true); + } + CodegenDrawTriangle("TriStencil", TriDrawVariant::Stencil, TriBlendMode::Copy, false); + CodegenDrawTriangle("TriStencilClose", TriDrawVariant::StencilClose, TriBlendMode::Copy, false); + + ObjectFile = mProgram.GenerateObjectFile(cpuName); +} + +void LLVMDrawers::CodegenDrawColumn(const char *name, DrawColumnVariant variant, DrawColumnMethod method) +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function(name + mNamePostfix); + function.add_parameter(GetDrawColumnArgsStruct(mProgram.context())); + function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); + function.create_public(); + + DrawColumnCodegen codegen; + codegen.Generate(variant, method, function.parameter(0), function.parameter(1)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + throw Exception("verifyFunction failed for CodegenDrawColumn()"); +} + +void LLVMDrawers::CodegenDrawSpan(const char *name, DrawSpanVariant variant) +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function(name + mNamePostfix); + function.add_parameter(GetDrawSpanArgsStruct(mProgram.context())); + function.create_public(); + + DrawSpanCodegen codegen; + codegen.Generate(variant, function.parameter(0)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + throw Exception("verifyFunction failed for CodegenDrawSpan()"); +} + +void LLVMDrawers::CodegenDrawWall(const char *name, DrawWallVariant variant, int columns) +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function(name + mNamePostfix); + function.add_parameter(GetDrawWallArgsStruct(mProgram.context())); + function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); + function.create_public(); + + DrawWallCodegen codegen; + codegen.Generate(variant, columns == 4, function.parameter(0), function.parameter(1)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + throw Exception("verifyFunction failed for CodegenDrawWall()"); +} + +void LLVMDrawers::CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns) +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function(name + mNamePostfix); + function.add_parameter(GetDrawSkyArgsStruct(mProgram.context())); + function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); + function.create_public(); + + DrawSkyCodegen codegen; + codegen.Generate(variant, columns == 4, function.parameter(0), function.parameter(1)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + throw Exception("verifyFunction failed for CodegenDrawSky()"); +} + +void LLVMDrawers::CodegenDrawTriangle(const std::string &name, TriDrawVariant variant, TriBlendMode blendmode, bool truecolor) +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function(name + mNamePostfix); + function.add_parameter(GetTriDrawTriangleArgs(mProgram.context())); + function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); + function.create_public(); + + DrawTriangleCodegen codegen; + codegen.Generate(variant, blendmode, truecolor, function.parameter(0), function.parameter(1)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + throw Exception(std::string("verifyFunction failed for CodegenDrawTriangle(") + std::to_string((int)variant) + ", " + std::to_string((int)blendmode) + ", " + std::to_string((int)truecolor) + ")"); +} + +llvm::Type *LLVMDrawers::GetDrawColumnArgsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint32_t *dest; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source2; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *colormap; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *translation; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *basecolors; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t pitch; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t count; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t dest_y; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t iscale; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t texturefracx; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureheight; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t texturefrac; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t color; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srccolor; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; + return llvm::StructType::create(context, elements, "DrawColumnArgs", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetDrawSpanArgsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *destorg; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t destpitch; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xfrac; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t yfrac; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xstep; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ystep; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x1; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x2; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t y; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xbits; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ybits; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; + return llvm::StructType::create(context, elements, "DrawSpanArgs", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetDrawWallArgsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); + for (int i = 0; i < 8; i++) + elements.push_back(llvm::Type::getInt8PtrTy(context)); + for (int i = 0; i < 25; i++) + elements.push_back(llvm::Type::getInt32Ty(context)); + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; + return llvm::StructType::create(context, elements, "DrawWallArgs", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetDrawSkyArgsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); + for (int i = 0; i < 8; i++) + elements.push_back(llvm::Type::getInt8PtrTy(context)); + for (int i = 0; i < 15; i++) + elements.push_back(llvm::Type::getInt32Ty(context)); + return llvm::StructType::create(context, elements, "DrawSkyArgs", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetWorkerThreadDataStruct(llvm::LLVMContext &context) +{ + std::vector elements; + for (int i = 0; i < 4; i++) + elements.push_back(llvm::Type::getInt32Ty(context)); + elements.push_back(llvm::Type::getInt8PtrTy(context)); + return llvm::StructType::create(context, elements, "ThreadData", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetTriVertexStruct(llvm::LLVMContext &context) +{ + std::vector elements; + for (int i = 0; i < 4 + TriVertex::NumVarying; i++) + elements.push_back(llvm::Type::getFloatTy(context)); + return llvm::StructType::create(context, elements, "TriVertex", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetTriMatrixStruct(llvm::LLVMContext &context) +{ + std::vector elements; + for (int i = 0; i < 4 * 4; i++) + elements.push_back(llvm::Type::getFloatTy(context)); + return llvm::StructType::create(context, elements, "TriMatrix", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetTriUniformsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t subsectorDepth; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t color; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; + elements.push_back(GetTriMatrixStruct(context)); // TriMatrix objectToClip + return llvm::StructType::create(context, elements, "TriUniforms", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetTriDrawTriangleArgs(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *dest; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t pitch; + elements.push_back(GetTriVertexStruct(context)); // TriVertex *v1; + elements.push_back(GetTriVertexStruct(context)); // TriVertex *v2; + elements.push_back(GetTriVertexStruct(context)); // TriVertex *v3; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipleft; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipright; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t cliptop; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipbottom; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *texturePixels; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureWidth; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureHeight; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *translation; + elements.push_back(GetTriUniformsStruct(context)); // const TriUniforms *uniforms; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *stencilValues; + elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *stencilMasks; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t stencilPitch; + elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilTestValue; + elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilWriteValue; + elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *subsectorGBuffer; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *colormaps; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *RGB32k; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *BaseColors; + return llvm::StructType::create(context, elements, "TriDrawTriangle", false)->getPointerTo(); +} + +///////////////////////////////////////////////////////////////////////////// + +LLVMProgram::LLVMProgram() +{ + mContext = std::make_unique(); +} + +void LLVMProgram::CreateModule() +{ + mModule = std::make_unique("render", context()); +} + +std::string LLVMProgram::GenerateAssembly(std::string cpuName) +{ + using namespace llvm; + + std::string errorstring; + + llvm::Module *module = mModule.get(); + EngineBuilder engineBuilder(std::move(mModule)); + engineBuilder.setErrorStr(&errorstring); + engineBuilder.setOptLevel(CodeGenOpt::Aggressive); + engineBuilder.setEngineKind(EngineKind::JIT); + engineBuilder.setMCPU(cpuName); + machine = engineBuilder.selectTarget(); + if (!machine) + throw Exception("Could not create LLVM target machine"); + +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + std::string targetTriple = machine->getTargetTriple(); +#else + std::string targetTriple = machine->getTargetTriple().getTriple(); +#endif + + module->setTargetTriple(targetTriple); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + module->setDataLayout(new DataLayout(*machine->getSubtargetImpl()->getDataLayout())); +#else + module->setDataLayout(machine->createDataLayout()); +#endif + + legacy::FunctionPassManager PerFunctionPasses(module); + legacy::PassManager PerModulePasses; + +#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8) + PerFunctionPasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); + PerModulePasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); +#endif + + SmallString<16 * 1024> str; +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + raw_svector_ostream vecstream(str); + formatted_raw_ostream stream(vecstream); +#else + raw_svector_ostream stream(str); +#endif + machine->addPassesToEmitFile(PerModulePasses, stream, TargetMachine::CGFT_AssemblyFile); + + PassManagerBuilder passManagerBuilder; + passManagerBuilder.OptLevel = 3; + passManagerBuilder.SizeLevel = 0; + passManagerBuilder.Inliner = createFunctionInliningPass(); + passManagerBuilder.SLPVectorize = true; + passManagerBuilder.LoopVectorize = true; + passManagerBuilder.LoadCombine = true; + passManagerBuilder.populateModulePassManager(PerModulePasses); + passManagerBuilder.populateFunctionPassManager(PerFunctionPasses); + + // Run function passes: + PerFunctionPasses.doInitialization(); + for (llvm::Function &func : *module) + { + if (!func.isDeclaration()) + PerFunctionPasses.run(func); + } + PerFunctionPasses.doFinalization(); + + // Run module passes: + PerModulePasses.run(*module); + + return str.c_str(); +} + +std::vector LLVMProgram::GenerateObjectFile(std::string cpuName) +{ + using namespace llvm; + + std::string errorstring; + + llvm::Module *module = mModule.get(); + EngineBuilder engineBuilder(std::move(mModule)); + engineBuilder.setErrorStr(&errorstring); + engineBuilder.setOptLevel(CodeGenOpt::Aggressive); + engineBuilder.setEngineKind(EngineKind::JIT); + engineBuilder.setMCPU(cpuName); + machine = engineBuilder.selectTarget(); + if (!machine) + throw Exception("Could not create LLVM target machine"); + +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + std::string targetTriple = machine->getTargetTriple(); +#else + std::string targetTriple = machine->getTargetTriple().getTriple(); +#endif + + module->setTargetTriple(targetTriple); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + module->setDataLayout(new DataLayout(*machine->getSubtargetImpl()->getDataLayout())); +#else + module->setDataLayout(machine->createDataLayout()); +#endif + + legacy::FunctionPassManager PerFunctionPasses(module); + legacy::PassManager PerModulePasses; + +#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8) + PerFunctionPasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); + PerModulePasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); +#endif + + SmallString<16 * 1024> str; +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + raw_svector_ostream vecstream(str); + formatted_raw_ostream stream(vecstream); +#else + raw_svector_ostream stream(str); +#endif + machine->addPassesToEmitFile(PerModulePasses, stream, TargetMachine::CGFT_ObjectFile); + + PassManagerBuilder passManagerBuilder; + passManagerBuilder.OptLevel = 3; + passManagerBuilder.SizeLevel = 0; + passManagerBuilder.Inliner = createFunctionInliningPass(); + passManagerBuilder.SLPVectorize = true; + passManagerBuilder.LoopVectorize = true; + passManagerBuilder.LoadCombine = true; + passManagerBuilder.populateModulePassManager(PerModulePasses); + passManagerBuilder.populateFunctionPassManager(PerFunctionPasses); + + // Run function passes: + PerFunctionPasses.doInitialization(); + for (llvm::Function &func : *module) + { + if (!func.isDeclaration()) + PerFunctionPasses.run(func); + } + PerFunctionPasses.doFinalization(); + + // Run module passes: + PerModulePasses.run(*module); + + // Return the resulting object file + std::vector data; + data.resize(str.size()); + memcpy(data.data(), str.data(), data.size()); + return data; +} + +std::string LLVMProgram::DumpModule() +{ + std::string str; + llvm::raw_string_ostream stream(str); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + mModule->print(stream, nullptr); +#else + mModule->print(stream, nullptr, false, true); +#endif + return stream.str(); +} + +///////////////////////////////////////////////////////////////////////////// + +int main(int argc, char **argv) +{ + if (argc != 2) + { + std::cerr << "Usage: " << argv[0] << "" << std::endl; + return 1; + } + + llvm::install_fatal_error_handler([](void *user_data, const std::string& reason, bool gen_crash_diag) + { + std::cerr << "LLVM fatal error: " << reason; + exit(1); + }); + + llvm::InitializeNativeTarget(); + llvm::InitializeNativeTargetAsmPrinter(); + + std::string cpuName = "pentium4"; + std::cout << "Compiling drawer code for " << cpuName << ".." << std::endl; + + LLVMDrawers drawersSSE2(cpuName, "_SSE2"); + + FILE *file = fopen(argv[1], "wb"); + if (file == nullptr) + { + std::cerr << "Unable to open " << argv[1] << " for writing." << std::endl; + return 1; + } + + int result = fwrite(drawersSSE2.ObjectFile.data(), drawersSSE2.ObjectFile.size(), 1, file); + fclose(file); + + if (result != 1) + { + std::cerr << "Could not write data to " << argv[1] << std::endl; + return 1; + } + + //LLVMDrawers drawersSSE4("core2"); + //LLVMDrawers drawersAVX("sandybridge"); + //LLVMDrawers drawersAVX2("haswell"); + + return 0; +} diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp b/tools/drawergen/fixedfunction/drawcolumncodegen.cpp similarity index 96% rename from src/r_compiler/fixedfunction/drawcolumncodegen.cpp rename to tools/drawergen/fixedfunction/drawcolumncodegen.cpp index 45a75cdcb..0ce34c83c 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp +++ b/tools/drawergen/fixedfunction/drawcolumncodegen.cpp @@ -20,17 +20,16 @@ ** */ -#include "i_system.h" -#include "r_compiler/llvm_include.h" -#include "r_compiler/fixedfunction/drawcolumncodegen.h" -#include "r_compiler/ssa/ssa_function.h" -#include "r_compiler/ssa/ssa_scope.h" -#include "r_compiler/ssa/ssa_for_block.h" -#include "r_compiler/ssa/ssa_if_block.h" -#include "r_compiler/ssa/ssa_stack.h" -#include "r_compiler/ssa/ssa_function.h" -#include "r_compiler/ssa/ssa_struct_type.h" -#include "r_compiler/ssa/ssa_value.h" +#include "precomp.h" +#include "fixedfunction/drawcolumncodegen.h" +#include "ssa/ssa_function.h" +#include "ssa/ssa_scope.h" +#include "ssa/ssa_for_block.h" +#include "ssa/ssa_if_block.h" +#include "ssa/ssa_stack.h" +#include "ssa/ssa_function.h" +#include "ssa/ssa_struct_type.h" +#include "ssa/ssa_value.h" void DrawColumnCodegen::Generate(DrawColumnVariant variant, DrawColumnMethod method, SSAValue args, SSAValue thread_data) { diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.h b/tools/drawergen/fixedfunction/drawcolumncodegen.h similarity index 100% rename from src/r_compiler/fixedfunction/drawcolumncodegen.h rename to tools/drawergen/fixedfunction/drawcolumncodegen.h diff --git a/src/r_compiler/fixedfunction/drawercodegen.cpp b/tools/drawergen/fixedfunction/drawercodegen.cpp similarity index 92% rename from src/r_compiler/fixedfunction/drawercodegen.cpp rename to tools/drawergen/fixedfunction/drawercodegen.cpp index 65b726b93..c1d24f594 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.cpp +++ b/tools/drawergen/fixedfunction/drawercodegen.cpp @@ -20,17 +20,16 @@ ** */ -#include "i_system.h" -#include "r_compiler/llvm_include.h" -#include "r_compiler/fixedfunction/drawercodegen.h" -#include "r_compiler/ssa/ssa_function.h" -#include "r_compiler/ssa/ssa_scope.h" -#include "r_compiler/ssa/ssa_for_block.h" -#include "r_compiler/ssa/ssa_if_block.h" -#include "r_compiler/ssa/ssa_stack.h" -#include "r_compiler/ssa/ssa_function.h" -#include "r_compiler/ssa/ssa_struct_type.h" -#include "r_compiler/ssa/ssa_value.h" +#include "precomp.h" +#include "fixedfunction/drawercodegen.h" +#include "ssa/ssa_function.h" +#include "ssa/ssa_scope.h" +#include "ssa/ssa_for_block.h" +#include "ssa/ssa_if_block.h" +#include "ssa/ssa_stack.h" +#include "ssa/ssa_function.h" +#include "ssa/ssa_struct_type.h" +#include "ssa/ssa_value.h" SSABool DrawerCodegen::line_skipped_by_thread(SSAInt line, SSAWorkerThread thread) { diff --git a/src/r_compiler/fixedfunction/drawercodegen.h b/tools/drawergen/fixedfunction/drawercodegen.h similarity index 81% rename from src/r_compiler/fixedfunction/drawercodegen.h rename to tools/drawergen/fixedfunction/drawercodegen.h index ef6e8d11e..8404f3acd 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.h +++ b/tools/drawergen/fixedfunction/drawercodegen.h @@ -22,22 +22,22 @@ #pragma once -#include "r_compiler/llvmdrawers.h" -#include "r_compiler/ssa/ssa_value.h" -#include "r_compiler/ssa/ssa_vec4f.h" -#include "r_compiler/ssa/ssa_vec4i.h" -#include "r_compiler/ssa/ssa_vec8s.h" -#include "r_compiler/ssa/ssa_vec16ub.h" -#include "r_compiler/ssa/ssa_int.h" -#include "r_compiler/ssa/ssa_int_ptr.h" -#include "r_compiler/ssa/ssa_short.h" -#include "r_compiler/ssa/ssa_ubyte_ptr.h" -#include "r_compiler/ssa/ssa_vec4f_ptr.h" -#include "r_compiler/ssa/ssa_vec4i_ptr.h" -#include "r_compiler/ssa/ssa_stack.h" -#include "r_compiler/ssa/ssa_bool.h" -#include "r_compiler/ssa/ssa_barycentric_weight.h" -#include "r_compiler/llvm_include.h" +#include "precomp.h" +#include "ssa/ssa_value.h" +#include "ssa/ssa_vec4f.h" +#include "ssa/ssa_vec4i.h" +#include "ssa/ssa_vec8s.h" +#include "ssa/ssa_vec16ub.h" +#include "ssa/ssa_int.h" +#include "ssa/ssa_int_ptr.h" +#include "ssa/ssa_short.h" +#include "ssa/ssa_ubyte_ptr.h" +#include "ssa/ssa_vec4f_ptr.h" +#include "ssa/ssa_vec4i_ptr.h" +#include "ssa/ssa_stack.h" +#include "ssa/ssa_bool.h" +#include "ssa/ssa_barycentric_weight.h" +#include "llvm_include.h" class SSAWorkerThread { @@ -90,3 +90,6 @@ public: // Calculates the final alpha values to be used when combined with the source texture alpha channel SSAInt calc_blend_bgalpha(SSAVec4i fg, SSAInt destalpha); }; + +#define FRACBITS 16 +#define FRACUNIT (1< + +1 RT_MANIFEST "trustinfo.txt" diff --git a/tools/drawergen/trustinfo.txt b/tools/drawergen/trustinfo.txt new file mode 100644 index 000000000..5216df650 --- /dev/null +++ b/tools/drawergen/trustinfo.txt @@ -0,0 +1,16 @@ + + + + + Drawergen for the ZDoom source build process. + + + + + + + + From 09891291c2fdbc01052dba332ca33408bf8e506a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 28 Nov 2016 17:34:32 +0100 Subject: [PATCH 1296/1509] Remove empty constructor --- src/r_drawers.cpp | 5 ----- src/r_drawers.h | 2 -- 2 files changed, 7 deletions(-) diff --git a/src/r_drawers.cpp b/src/r_drawers.cpp index 6d4aaa055..b098e50a0 100644 --- a/src/r_drawers.cpp +++ b/src/r_drawers.cpp @@ -389,11 +389,6 @@ Drawers *Drawers::Instance() return &drawers; } -Drawers::Drawers() -{ - // To do: setup pointers -} - FString DrawWallArgs::ToString() { FString info; diff --git a/src/r_drawers.h b/src/r_drawers.h index 17168b6f3..bb541e99c 100644 --- a/src/r_drawers.h +++ b/src/r_drawers.h @@ -261,8 +261,6 @@ inline int NumTriBlendModes() { return (int)TriBlendMode::TranslateRevSub + 1; } class Drawers { public: - Drawers(); - static Drawers *Instance(); void(*DrawColumn)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; From f808bcb8d21ab63c2b80b0c9bc05c1f21976db06 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 28 Nov 2016 23:57:55 +0100 Subject: [PATCH 1297/1509] Remove llvm_cpu cvar --- src/r_drawers.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/r_drawers.cpp b/src/r_drawers.cpp index b098e50a0..72241fe74 100644 --- a/src/r_drawers.cpp +++ b/src/r_drawers.cpp @@ -27,11 +27,6 @@ #include "version.h" #include "m_misc.h" -CUSTOM_CVAR(String, llvm_cpu, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL) -{ - Printf("You must restart " GAMENAME " for this change to take effect.\n"); -} - ///////////////////////////////////////////////////////////////////////////// extern "C" From 1ac0fd1a90d9243f55d7edb8b446add9ab3a12ca Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 29 Nov 2016 01:19:20 +0100 Subject: [PATCH 1298/1509] Add a silly sleep --- tools/drawergen/drawergen.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/drawergen/drawergen.cpp b/tools/drawergen/drawergen.cpp index dfe5fc11b..8709ebb95 100644 --- a/tools/drawergen/drawergen.cpp +++ b/tools/drawergen/drawergen.cpp @@ -617,7 +617,8 @@ std::string LLVMProgram::DumpModule() } ///////////////////////////////////////////////////////////////////////////// - +#include +#include int main(int argc, char **argv) { if (argc != 2) @@ -660,5 +661,8 @@ int main(int argc, char **argv) //LLVMDrawers drawersAVX("sandybridge"); //LLVMDrawers drawersAVX2("haswell"); + using namespace std::chrono_literals; + std::this_thread::sleep_for(2s); // Doh! Silly OS! + return 0; } From 37078f7fefa76430974b3bf15b08387ba53b9035 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 28 Nov 2016 19:48:44 -0500 Subject: [PATCH 1299/1509] - Fixed: CMake now asks DrawerGen to drop its output into the build folder instead of the source folder. Fixes a linker error. --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 458acf6ad..d6714b498 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -678,12 +678,12 @@ add_custom_target( revision_check ALL if ( WIN32 ) add_custom_target( drawergen_target ALL COMMAND drawergen src/r_drawersasm.obj - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} DEPENDS drawergen ) else() add_custom_target( drawergen_target ALL COMMAND drawergen src/r_drawersasm.o - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} DEPENDS drawergen ) endif() From 0bb179c0c2e9cff5b047c1ce566eb05468d04503 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 29 Nov 2016 01:55:45 +0100 Subject: [PATCH 1300/1509] Remove the silly sleep again --- tools/drawergen/drawergen.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tools/drawergen/drawergen.cpp b/tools/drawergen/drawergen.cpp index 8709ebb95..dfe5fc11b 100644 --- a/tools/drawergen/drawergen.cpp +++ b/tools/drawergen/drawergen.cpp @@ -617,8 +617,7 @@ std::string LLVMProgram::DumpModule() } ///////////////////////////////////////////////////////////////////////////// -#include -#include + int main(int argc, char **argv) { if (argc != 2) @@ -661,8 +660,5 @@ int main(int argc, char **argv) //LLVMDrawers drawersAVX("sandybridge"); //LLVMDrawers drawersAVX2("haswell"); - using namespace std::chrono_literals; - std::this_thread::sleep_for(2s); // Doh! Silly OS! - return 0; } From 17c4c4a3841f88c7f6a59befabd7808342ce3e9c Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 28 Nov 2016 20:29:57 -0500 Subject: [PATCH 1301/1509] - Fixed: Linker now searches for r_drawerasm.obj in the proper place. This probably broke on Mac and Linux. :( --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d6714b498..1b84ed3a1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1506,7 +1506,7 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE math/tanh.c math/fastsin.cpp zzautozend.cpp - r_drawersasm.obj + ${CMAKE_BINARY_DIR}/src/r_drawersasm.obj ) set_source_files_properties( ${CODEGENOBJ_SOURCES} PROPERTIES EXTERNAL_OBJECT true GENERATED true) From f4d5fb4c258e903231500c553e03f28fd56fcc4b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 29 Nov 2016 03:32:24 +0100 Subject: [PATCH 1302/1509] Improve drawergen to only recompile the object file if its timestamp does not match --- tools/drawergen/drawergen.cpp | 48 ++++++++++++++++++- .../fixedfunction/drawcolumncodegen.cpp | 1 + .../drawergen/fixedfunction/drawercodegen.cpp | 1 + .../fixedfunction/drawskycodegen.cpp | 1 + .../fixedfunction/drawspancodegen.cpp | 1 + .../fixedfunction/drawtrianglecodegen.cpp | 1 + .../fixedfunction/drawwallcodegen.cpp | 1 + tools/drawergen/timestamp.h | 12 +++++ 8 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 tools/drawergen/timestamp.h diff --git a/tools/drawergen/drawergen.cpp b/tools/drawergen/drawergen.cpp index dfe5fc11b..068fb164f 100644 --- a/tools/drawergen/drawergen.cpp +++ b/tools/drawergen/drawergen.cpp @@ -21,6 +21,7 @@ */ #include "precomp.h" +#include "timestamp.h" #include "fixedfunction/drawspancodegen.h" #include "fixedfunction/drawwallcodegen.h" #include "fixedfunction/drawcolumncodegen.h" @@ -618,6 +619,18 @@ std::string LLVMProgram::DumpModule() ///////////////////////////////////////////////////////////////////////////// +std::string &AllTimestamps() +{ + static std::string timestamps; + return timestamps; +} + +void AddSourceFileTimestamp(const char *timestamp) +{ + if (!AllTimestamps().empty()) AllTimestamps().push_back(' '); + AllTimestamps() += timestamp; +} + int main(int argc, char **argv) { if (argc != 2) @@ -626,6 +639,25 @@ int main(int argc, char **argv) return 1; } + std::string timestamp_filename = argv[1] + std::string(".timestamp"); + + FILE *file = fopen(timestamp_filename.c_str(), "rb"); + if (file != nullptr) + { + char buffer[4096]; + int bytes_read = fread(buffer, 1, 4096, file); + fclose(file); + std::string last_timestamp; + if (bytes_read > 0) + last_timestamp = std::string(buffer, bytes_read); + + if (AllTimestamps() == last_timestamp) + { + std::cout << "Not recompiling drawers because the object file is already up to date." << std::endl; + exit(0); + } + } + llvm::install_fatal_error_handler([](void *user_data, const std::string& reason, bool gen_crash_diag) { std::cerr << "LLVM fatal error: " << reason; @@ -640,7 +672,7 @@ int main(int argc, char **argv) LLVMDrawers drawersSSE2(cpuName, "_SSE2"); - FILE *file = fopen(argv[1], "wb"); + file = fopen(argv[1], "wb"); if (file == nullptr) { std::cerr << "Unable to open " << argv[1] << " for writing." << std::endl; @@ -656,6 +688,20 @@ int main(int argc, char **argv) return 1; } + file = fopen(timestamp_filename.c_str(), "wb"); + if (file == nullptr) + { + std::cerr << "Could not create timestamp file" << std::endl; + return 1; + } + result = fwrite(AllTimestamps().data(), AllTimestamps().length(), 1, file); + fclose(file); + if (result != 1) + { + std::cerr << "Could not write timestamp file" << std::endl; + return 1; + } + //LLVMDrawers drawersSSE4("core2"); //LLVMDrawers drawersAVX("sandybridge"); //LLVMDrawers drawersAVX2("haswell"); diff --git a/tools/drawergen/fixedfunction/drawcolumncodegen.cpp b/tools/drawergen/fixedfunction/drawcolumncodegen.cpp index 0ce34c83c..177074dad 100644 --- a/tools/drawergen/fixedfunction/drawcolumncodegen.cpp +++ b/tools/drawergen/fixedfunction/drawcolumncodegen.cpp @@ -21,6 +21,7 @@ */ #include "precomp.h" +#include "timestamp.h" #include "fixedfunction/drawcolumncodegen.h" #include "ssa/ssa_function.h" #include "ssa/ssa_scope.h" diff --git a/tools/drawergen/fixedfunction/drawercodegen.cpp b/tools/drawergen/fixedfunction/drawercodegen.cpp index c1d24f594..02c6e302a 100644 --- a/tools/drawergen/fixedfunction/drawercodegen.cpp +++ b/tools/drawergen/fixedfunction/drawercodegen.cpp @@ -21,6 +21,7 @@ */ #include "precomp.h" +#include "timestamp.h" #include "fixedfunction/drawercodegen.h" #include "ssa/ssa_function.h" #include "ssa/ssa_scope.h" diff --git a/tools/drawergen/fixedfunction/drawskycodegen.cpp b/tools/drawergen/fixedfunction/drawskycodegen.cpp index 57016a620..3a0581870 100644 --- a/tools/drawergen/fixedfunction/drawskycodegen.cpp +++ b/tools/drawergen/fixedfunction/drawskycodegen.cpp @@ -21,6 +21,7 @@ */ #include "precomp.h" +#include "timestamp.h" #include "fixedfunction/drawskycodegen.h" #include "ssa/ssa_function.h" #include "ssa/ssa_scope.h" diff --git a/tools/drawergen/fixedfunction/drawspancodegen.cpp b/tools/drawergen/fixedfunction/drawspancodegen.cpp index 2e9fd0d85..c6aacc75a 100644 --- a/tools/drawergen/fixedfunction/drawspancodegen.cpp +++ b/tools/drawergen/fixedfunction/drawspancodegen.cpp @@ -21,6 +21,7 @@ */ #include "precomp.h" +#include "timestamp.h" #include "fixedfunction/drawspancodegen.h" #include "ssa/ssa_function.h" #include "ssa/ssa_scope.h" diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index 8b7e8001c..fc2c3db15 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -21,6 +21,7 @@ */ #include "precomp.h" +#include "timestamp.h" #include "fixedfunction/drawtrianglecodegen.h" #include "ssa/ssa_function.h" #include "ssa/ssa_scope.h" diff --git a/tools/drawergen/fixedfunction/drawwallcodegen.cpp b/tools/drawergen/fixedfunction/drawwallcodegen.cpp index 90ca16a61..94b807f40 100644 --- a/tools/drawergen/fixedfunction/drawwallcodegen.cpp +++ b/tools/drawergen/fixedfunction/drawwallcodegen.cpp @@ -21,6 +21,7 @@ */ #include "precomp.h" +#include "timestamp.h" #include "fixedfunction/drawwallcodegen.h" #include "ssa/ssa_function.h" #include "ssa/ssa_scope.h" diff --git a/tools/drawergen/timestamp.h b/tools/drawergen/timestamp.h new file mode 100644 index 000000000..6dd11bcff --- /dev/null +++ b/tools/drawergen/timestamp.h @@ -0,0 +1,12 @@ + +#pragma once + +void AddSourceFileTimestamp(const char *timestamp); + +namespace +{ + struct TimestampSourceFile + { + TimestampSourceFile() { AddSourceFileTimestamp(__TIME__); } + } timestamp; +} From 046f5f2b2e7f99d2fb0d7b4d338e444e9b10ee03 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 29 Nov 2016 13:53:02 +0100 Subject: [PATCH 1303/1509] Catch exceptions and write out their message --- tools/drawergen/drawergen.cpp | 142 ++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 67 deletions(-) diff --git a/tools/drawergen/drawergen.cpp b/tools/drawergen/drawergen.cpp index 068fb164f..8896e3f7b 100644 --- a/tools/drawergen/drawergen.cpp +++ b/tools/drawergen/drawergen.cpp @@ -633,78 +633,86 @@ void AddSourceFileTimestamp(const char *timestamp) int main(int argc, char **argv) { - if (argc != 2) + try { - std::cerr << "Usage: " << argv[0] << "" << std::endl; - return 1; - } - - std::string timestamp_filename = argv[1] + std::string(".timestamp"); - - FILE *file = fopen(timestamp_filename.c_str(), "rb"); - if (file != nullptr) - { - char buffer[4096]; - int bytes_read = fread(buffer, 1, 4096, file); - fclose(file); - std::string last_timestamp; - if (bytes_read > 0) - last_timestamp = std::string(buffer, bytes_read); - - if (AllTimestamps() == last_timestamp) + if (argc != 2) { - std::cout << "Not recompiling drawers because the object file is already up to date." << std::endl; - exit(0); + std::cerr << "Usage: " << argv[0] << "" << std::endl; + return 1; } + + std::string timestamp_filename = argv[1] + std::string(".timestamp"); + + FILE *file = fopen(timestamp_filename.c_str(), "rb"); + if (file != nullptr) + { + char buffer[4096]; + int bytes_read = fread(buffer, 1, 4096, file); + fclose(file); + std::string last_timestamp; + if (bytes_read > 0) + last_timestamp = std::string(buffer, bytes_read); + + if (AllTimestamps() == last_timestamp) + { + std::cout << "Not recompiling drawers because the object file is already up to date." << std::endl; + exit(0); + } + } + + llvm::install_fatal_error_handler([](void *user_data, const std::string& reason, bool gen_crash_diag) + { + std::cerr << "LLVM fatal error: " << reason; + exit(1); + }); + + llvm::InitializeNativeTarget(); + llvm::InitializeNativeTargetAsmPrinter(); + + std::string cpuName = "pentium4"; + std::cout << "Compiling drawer code for " << cpuName << ".." << std::endl; + + LLVMDrawers drawersSSE2(cpuName, "_SSE2"); + + file = fopen(argv[1], "wb"); + if (file == nullptr) + { + std::cerr << "Unable to open " << argv[1] << " for writing." << std::endl; + return 1; + } + + int result = fwrite(drawersSSE2.ObjectFile.data(), drawersSSE2.ObjectFile.size(), 1, file); + fclose(file); + + if (result != 1) + { + std::cerr << "Could not write data to " << argv[1] << std::endl; + return 1; + } + + file = fopen(timestamp_filename.c_str(), "wb"); + if (file == nullptr) + { + std::cerr << "Could not create timestamp file" << std::endl; + return 1; + } + result = fwrite(AllTimestamps().data(), AllTimestamps().length(), 1, file); + fclose(file); + if (result != 1) + { + std::cerr << "Could not write timestamp file" << std::endl; + return 1; + } + + //LLVMDrawers drawersSSE4("core2"); + //LLVMDrawers drawersAVX("sandybridge"); + //LLVMDrawers drawersAVX2("haswell"); + + return 0; } - - llvm::install_fatal_error_handler([](void *user_data, const std::string& reason, bool gen_crash_diag) + catch (const std::exception &e) { - std::cerr << "LLVM fatal error: " << reason; - exit(1); - }); - - llvm::InitializeNativeTarget(); - llvm::InitializeNativeTargetAsmPrinter(); - - std::string cpuName = "pentium4"; - std::cout << "Compiling drawer code for " << cpuName << ".." << std::endl; - - LLVMDrawers drawersSSE2(cpuName, "_SSE2"); - - file = fopen(argv[1], "wb"); - if (file == nullptr) - { - std::cerr << "Unable to open " << argv[1] << " for writing." << std::endl; + std::cerr << e.what() << std::endl; return 1; } - - int result = fwrite(drawersSSE2.ObjectFile.data(), drawersSSE2.ObjectFile.size(), 1, file); - fclose(file); - - if (result != 1) - { - std::cerr << "Could not write data to " << argv[1] << std::endl; - return 1; - } - - file = fopen(timestamp_filename.c_str(), "wb"); - if (file == nullptr) - { - std::cerr << "Could not create timestamp file" << std::endl; - return 1; - } - result = fwrite(AllTimestamps().data(), AllTimestamps().length(), 1, file); - fclose(file); - if (result != 1) - { - std::cerr << "Could not write timestamp file" << std::endl; - return 1; - } - - //LLVMDrawers drawersSSE4("core2"); - //LLVMDrawers drawersAVX("sandybridge"); - //LLVMDrawers drawersAVX2("haswell"); - - return 0; } From b450ac50470c1b469e6a4b2d64f954d6bd6ba6ba Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 29 Nov 2016 13:54:06 +0100 Subject: [PATCH 1304/1509] Remove some multiplications and branching from the triangle drawer --- .../fixedfunction/drawtrianglecodegen.cpp | 140 ++++++++++-------- .../fixedfunction/drawtrianglecodegen.h | 11 +- 2 files changed, 90 insertions(+), 61 deletions(-) diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index fc2c3db15..8178a58cc 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -134,12 +134,20 @@ void DrawTriangleCodegen::Setup() v3.y = SSAFloat(Y3) * 0.0625f; gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - startW = v1.w + gradWX * (SSAFloat(minx) - v1.x) + gradWY * (SSAFloat(miny) - v1.y); + stack_posy_w.store(v1.w + gradWX * (SSAFloat(minx) - v1.x) + gradWY * (SSAFloat(miny) - v1.y)); for (int i = 0; i < TriVertex::NumVarying; i++) { gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - startVarying[i] = v1.varying[i] * v1.w + gradVaryingX[i] * (SSAFloat(minx) - v1.x) + gradVaryingY[i] * (SSAFloat(miny) - v1.y); + stack_posy_varying[i].store(v1.varying[i] * v1.w + gradVaryingX[i] * (SSAFloat(minx) - v1.x) + gradVaryingY[i] * (SSAFloat(miny) - v1.y)); + } + + gradWX = gradWX * (float)q; + gradWY = gradWY * (float)q; + for (int i = 0; i < TriVertex::NumVarying; i++) + { + gradVaryingX[i] = gradVaryingX[i] * (float)q; + gradVaryingY[i] = gradVaryingY[i] * (float)q; } } @@ -161,26 +169,32 @@ void DrawTriangleCodegen::LoopBlockY() { int pixelsize = truecolor ? 4 : 1; - stack_y.store(miny); - stack_dest.store(dest); - stack_subsectorGBuffer.store(subsectorGBuffer); + SSAInt blocks_skipped = skipped_by_thread(miny / q, thread); + stack_y.store(miny + blocks_skipped * q); + stack_dest.store(dest[blocks_skipped * q * pitch * pixelsize]); + stack_subsectorGBuffer.store(subsectorGBuffer[blocks_skipped * q * pitch]); + stack_posy_w.store(stack_posy_w.load() + gradWY * blocks_skipped); + for (int i = 0; i < TriVertex::NumVarying; i++) + stack_posy_varying[i].store(stack_posy_varying[i].load() + gradVaryingY[i] * blocks_skipped); SSAForBlock loop; y = stack_y.load(); dest = stack_dest.load(); subsectorGBuffer = stack_subsectorGBuffer.load(); + posy_w = stack_posy_w.load(); + for (int i = 0; i < TriVertex::NumVarying; i++) + posy_varying[i] = stack_posy_varying[i].load(); loop.loop_block(y < maxy, 0); { - SSAIfBlock branch; - branch.if_block((y / q) % thread.num_cores == thread.core); - { - LoopBlockX(); - } - branch.end_block(); + LoopBlockX(); - stack_dest.store(dest[q * pitch * pixelsize]); - stack_subsectorGBuffer.store(subsectorGBuffer[q * pitch]); - stack_y.store(y + q); + stack_posy_w.store(posy_w + gradWY * thread.num_cores); + for (int i = 0; i < TriVertex::NumVarying; i++) + stack_posy_varying[i].store(posy_varying[i] + gradVaryingY[i] * thread.num_cores); + + stack_dest.store(dest[q * pitch * pixelsize * thread.num_cores]); + stack_subsectorGBuffer.store(subsectorGBuffer[q * pitch * thread.num_cores]); + stack_y.store(y + thread.num_cores * q); } loop.end_block(); } @@ -188,9 +202,15 @@ void DrawTriangleCodegen::LoopBlockY() void DrawTriangleCodegen::LoopBlockX() { stack_x.store(minx); + stack_posx_w.store(posy_w); + for (int i = 0; i < TriVertex::NumVarying; i++) + stack_posx_varying[i].store(stack_posy_varying[i].load()); SSAForBlock loop; x = stack_x.load(); + posx_w = stack_posx_w.load(); + for (int i = 0; i < TriVertex::NumVarying; i++) + posx_varying[i] = stack_posx_varying[i].load(); loop.loop_block(x < maxx, 0); { // Corners of block @@ -226,51 +246,7 @@ void DrawTriangleCodegen::LoopBlockX() // Check if block needs clipping SSABool clipneeded = x < clipleft || (x + q) > clipright || y < cliptop || (y + q) > clipbottom; - // Calculate varying variables for affine block - SSAFloat offx0 = SSAFloat(x - minx); - SSAFloat offy0 = SSAFloat(y - miny); - SSAFloat offx1 = offx0 + SSAFloat(q); - SSAFloat offy1 = offy0 + SSAFloat(q); - SSAFloat rcpWTL = 1.0f / (startW + offx0 * gradWX + offy0 * gradWY); - SSAFloat rcpWTR = 1.0f / (startW + offx1 * gradWX + offy0 * gradWY); - SSAFloat rcpWBL = 1.0f / (startW + offx0 * gradWX + offy1 * gradWY); - SSAFloat rcpWBR = 1.0f / (startW + offx1 * gradWX + offy1 * gradWY); - for (int i = 0; i < TriVertex::NumVarying; i++) - { - SSAFloat varyingTL = (startVarying[i] + offx0 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTL; - SSAFloat varyingTR = (startVarying[i] + offx1 * gradVaryingX[i] + offy0 * gradVaryingY[i]) * rcpWTR; - SSAFloat varyingBL = (startVarying[i] + offx0 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBL; - SSAFloat varyingBR = (startVarying[i] + offx1 * gradVaryingX[i] + offy1 * gradVaryingY[i]) * rcpWBR; - - SSAFloat startStepX = (varyingTR - varyingTL) * (1.0f / q); - SSAFloat endStepX = (varyingBR - varyingBL) * (1.0f / q); - SSAFloat incrStepX = (endStepX - startStepX) * (1.0f / q); - SSAFloat stepY = (varyingBL - varyingTL) * (1.0f / q); - - varyingPos[i] = SSAInt(varyingTL * SSAFloat((float)0x01000000), false) << 8; - varyingStepY[i] = SSAInt(stepY * SSAFloat((float)0x01000000), false) << 8; - varyingStartStepX[i] = SSAInt(startStepX * SSAFloat((float)0x01000000), false) << 8; - varyingIncrStepX[i] = SSAInt(incrStepX * SSAFloat((float)0x01000000), false) << 8; - } - - SSAFloat globVis = SSAFloat(1706.0f); - SSAFloat vis = globVis / rcpWTL; - SSAFloat shade = 64.0f - (SSAFloat(light * 255 / 256) + 12.0f) * 32.0f / 128.0f; - SSAFloat lightscale = SSAFloat::clamp((shade - SSAFloat::MIN(SSAFloat(24.0f), vis)) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)); - SSAInt diminishedlight = SSAInt(SSAFloat::clamp((1.0f - lightscale) * 256.0f + 0.5f, SSAFloat(0.0f), SSAFloat(256.0f)), false); - - if (!truecolor) - { - SSAInt diminishedindex = SSAInt(lightscale * 32.0f, false); - SSAInt lightindex = SSAInt::MIN((256 - light) * 32 / 256, SSAInt(31)); - SSAInt colormapindex = is_fixed_light.select(lightindex, diminishedindex); - currentcolormap = Colormaps[colormapindex << 8]; - } - else - { - currentlight = is_fixed_light.select(light, diminishedlight); - } - + SetupAffineBlock(); SetStencilBlock(x / 8 + y / 8 * stencilPitch); SSABool covered = a == SSAInt(0xF) && b == SSAInt(0xF) && c == SSAInt(0xF) && !clipneeded && StencilIsSingleValue(); @@ -289,11 +265,55 @@ void DrawTriangleCodegen::LoopBlockX() branch.end_block(); + stack_posx_w.store(posx_w + gradWX); + for (int i = 0; i < TriVertex::NumVarying; i++) + stack_posx_varying[i].store(posx_varying[i] + gradVaryingX[i]); + stack_x.store(x + q); } loop.end_block(); } +void DrawTriangleCodegen::SetupAffineBlock() +{ + // Calculate varying variables for affine block + SSAVec4f rcpW = SSAVec4f::rcp(SSAVec4f(posx_w, posx_w + gradWX, posx_w + gradWY, posx_w + gradWX + gradWY)); + for (int i = 0; i < TriVertex::NumVarying; i++) + { + // Top left, top right, bottom left, bottom right: + SSAVec4f varying = SSAVec4f(posx_varying[i], posx_varying[i] + gradVaryingX[i], posx_varying[i] + gradVaryingY[i], posx_varying[i] + gradVaryingX[i] + gradVaryingY[i]) * rcpW; + + SSAFloat startStepX = (varying[1] - varying[0]) * (1.0f / q); + SSAFloat endStepX = (varying[3] - varying[2]) * (1.0f / q); + SSAFloat incrStepX = (endStepX - startStepX) * (1.0f / q); + SSAFloat stepY = (varying[2] - varying[0]) * (1.0f / q); + + SSAVec4i ints = SSAVec4i(SSAVec4f(varying[0], stepY, startStepX, incrStepX) * (float)0x01000000) << 8; + varyingPos[i] = ints[0]; + varyingStepY[i] = ints[1]; + varyingStartStepX[i] = ints[2]; + varyingIncrStepX[i] = ints[3]; + } + + SSAFloat globVis = SSAFloat(1706.0f); + SSAFloat vis = globVis / rcpW[0]; + SSAFloat shade = 64.0f - (SSAFloat(light * 255 / 256) + 12.0f) * 32.0f / 128.0f; + SSAFloat lightscale = SSAFloat::clamp((shade - SSAFloat::MIN(SSAFloat(24.0f), vis)) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)); + SSAInt diminishedlight = SSAInt(SSAFloat::clamp((1.0f - lightscale) * 256.0f + 0.5f, SSAFloat(0.0f), SSAFloat(256.0f)), false); + + if (!truecolor) + { + SSAInt diminishedindex = SSAInt(lightscale * 32.0f, false); + SSAInt lightindex = SSAInt::MIN((256 - light) * 32 / 256, SSAInt(31)); + SSAInt colormapindex = is_fixed_light.select(lightindex, diminishedindex); + currentcolormap = Colormaps[colormapindex << 8]; + } + else + { + currentlight = is_fixed_light.select(light, diminishedlight); + } +} + void DrawTriangleCodegen::LoopFullBlock() { SSAIfBlock branch_stenciltest; @@ -835,6 +855,8 @@ void DrawTriangleCodegen::LoadArgs(SSAValue args, SSAValue thread_data) thread.core = thread_data[0][0].load(true); thread.num_cores = thread_data[0][1].load(true); + thread.pass_start_y = SSAInt(0); + thread.pass_end_y = SSAInt(32000); } SSATriVertex DrawTriangleCodegen::LoadTriVertex(SSAValue ptr) diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.h b/tools/drawergen/fixedfunction/drawtrianglecodegen.h index bb6df455e..3866e3566 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.h +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.h @@ -45,6 +45,7 @@ private: void LoopBlockX(); void LoopFullBlock(); void LoopPartialBlock(); + void SetupAffineBlock(); SSAVec4i ProcessPixel32(SSAVec4i bg, SSAInt *varying); SSAInt ProcessPixel8(SSAInt bg, SSAInt *varying); @@ -85,6 +86,9 @@ private: SSAStack stack_CY1, stack_CY2, stack_CY3; SSAStack stack_CX1, stack_CX2, stack_CX3; + SSAStack stack_posy_w, stack_posy_varying[TriVertex::NumVarying]; + SSAStack stack_posx_w, stack_posx_varying[TriVertex::NumVarying]; + SSAUBytePtr dest; SSAInt pitch; SSATriVertex v1; @@ -131,8 +135,8 @@ private: SSAInt FDY12, FDY23, FDY31; SSAInt minx, maxx, miny, maxy; SSAInt C1, C2, C3; - SSAFloat gradWX, gradWY, startW; - SSAFloat gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying], startVarying[TriVertex::NumVarying]; + SSAFloat gradWX, gradWY; + SSAFloat gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying]; SSAInt x, y; SSAInt x0, x1, y0, y1; @@ -143,6 +147,9 @@ private: SSAInt varyingStartStepX[TriVertex::NumVarying]; SSAInt varyingIncrStepX[TriVertex::NumVarying]; + SSAFloat posy_w, posy_varying[TriVertex::NumVarying]; + SSAFloat posx_w, posx_varying[TriVertex::NumVarying]; + SSAUBytePtr StencilBlock; SSAIntPtr StencilBlockMask; }; From 7474be628405fc0380f909e2d1020687ca1b28b5 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Tue, 29 Nov 2016 19:46:38 +0100 Subject: [PATCH 1305/1509] - Fixed GCC/Clang compiler errors and warnings. --- src/CMakeLists.txt | 2 +- tools/drawergen/CMakeLists.txt | 40 ++++++++++++++++++++++++++++ tools/drawergen/drawergen.cpp | 2 +- tools/drawergen/ssa/ssa_function.cpp | 2 +- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1b84ed3a1..73a3074bb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1506,7 +1506,7 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE math/tanh.c math/fastsin.cpp zzautozend.cpp - ${CMAKE_BINARY_DIR}/src/r_drawersasm.obj + ${CMAKE_BINARY_DIR}/src/${CODEGENOBJ_SOURCES} ) set_source_files_properties( ${CODEGENOBJ_SOURCES} PROPERTIES EXTERNAL_OBJECT true GENERATED true) diff --git a/tools/drawergen/CMakeLists.txt b/tools/drawergen/CMakeLists.txt index eef5a0a94..61944953d 100644 --- a/tools/drawergen/CMakeLists.txt +++ b/tools/drawergen/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required( VERSION 2.8.7 ) +include( CheckCXXCompilerFlag ) + include(../../precompiled_headers.cmake) # Path where it looks for the LLVM compiled files on Windows @@ -54,6 +56,44 @@ else() endforeach(buildtype) endif() +if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.5") + set( CMAKE_C_FLAGS "-Wno-unused-result ${CMAKE_C_FLAGS}" ) + set( CMAKE_CXX_FLAGS "-Wno-unused-result ${CMAKE_CXX_FLAGS}" ) + endif() + if( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) + if( APPLE OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "3.6" ) + set( CMAKE_CXX_FLAGS "-Wno-inconsistent-missing-override ${CMAKE_CXX_FLAGS}" ) + endif() + endif() + set( CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers -ffp-contract=off ${CMAKE_C_FLAGS}" ) + set( CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers -ffp-contract=off ${CMAKE_CXX_FLAGS}" ) + + # Use the highest C++ standard available since VS2015 compiles with C++14 + # but we only require C++11. The recommended way to do this in CMake is to + # probably to use target_compile_features, but I don't feel like maintaining + # a list of features we use. + CHECK_CXX_COMPILER_FLAG( "-std=gnu++14" CAN_DO_CPP14 ) + if ( CAN_DO_CPP14 ) + set ( CMAKE_CXX_FLAGS "-std=gnu++14 ${CMAKE_CXX_FLAGS}" ) + else () + CHECK_CXX_COMPILER_FLAG( "-std=gnu++1y" CAN_DO_CPP1Y ) + if ( CAN_DO_CPP1Y ) + set ( CMAKE_CXX_FLAGS "-std=gnu++1y ${CMAKE_CXX_FLAGS}" ) + else () + CHECK_CXX_COMPILER_FLAG( "-std=gnu++11" CAN_DO_CPP11 ) + if ( CAN_DO_CPP11 ) + set ( CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}" ) + else () + CHECK_CXX_COMPILER_FLAG( "-std=gnu++0x" CAN_DO_CPP0X ) + if ( CAN_DO_CPP0X ) + set ( CMAKE_CXX_FLAGS "-std=gnu++0x ${CMAKE_CXX_FLAGS}" ) + endif () + endif () + endif () + endif () +endif() + if( WIN32 ) if( MSVC_VERSION GREATER 1399 ) # VC 8+ adds a manifest automatically to the executable. We need to diff --git a/tools/drawergen/drawergen.cpp b/tools/drawergen/drawergen.cpp index 8896e3f7b..a37f2f26e 100644 --- a/tools/drawergen/drawergen.cpp +++ b/tools/drawergen/drawergen.cpp @@ -42,7 +42,7 @@ class Exception : public std::exception { public: Exception(const std::string &message) : message(message) { } - const char *what() const override { return message.c_str(); } + const char *what() const noexcept override { return message.c_str(); } private: std::string message; diff --git a/tools/drawergen/ssa/ssa_function.cpp b/tools/drawergen/ssa/ssa_function.cpp index ef01cec44..e21b0b229 100644 --- a/tools/drawergen/ssa/ssa_function.cpp +++ b/tools/drawergen/ssa/ssa_function.cpp @@ -27,7 +27,7 @@ #include "ssa_value.h" SSAFunction::SSAFunction(const std::string name) -: name(name), return_type(llvm::Type::getVoidTy(SSAScope::context())), func() +: func(), name(name), return_type(llvm::Type::getVoidTy(SSAScope::context())) { } From d837f9ab9348e72b17e5058ed8414b0d8fd481e7 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 29 Nov 2016 22:25:13 +0200 Subject: [PATCH 1306/1509] Fixed compilation of drawergen on macOS --- tools/drawergen/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/drawergen/CMakeLists.txt b/tools/drawergen/CMakeLists.txt index 61944953d..dc9fefb17 100644 --- a/tools/drawergen/CMakeLists.txt +++ b/tools/drawergen/CMakeLists.txt @@ -92,6 +92,11 @@ if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) endif () endif () endif () + + if ( APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) + set( CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}" ) + set( CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++ ${CMAKE_EXE_LINKER_FLAGS}" ) + endif () endif() if( WIN32 ) From 00387a72113398814178f863ce904aeb69fb3fa3 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 29 Nov 2016 22:16:40 +0100 Subject: [PATCH 1307/1509] Add bounds check to palette upload buffer size --- src/gl/system/gl_swframebuffer.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index affcb86f9..5eba62d1e 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -2224,9 +2224,9 @@ bool OpenGLSWFrameBuffer::OpenGLPal::Update() { glGenBuffers(2, (GLuint*)Tex->Buffers); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, Tex->Buffers[0]); - glBufferData(GL_PIXEL_UNPACK_BUFFER, Remap->NumEntries * 4, nullptr, GL_STREAM_DRAW); + glBufferData(GL_PIXEL_UNPACK_BUFFER, RoundedPaletteSize * 4, nullptr, GL_STREAM_DRAW); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, Tex->Buffers[1]); - glBufferData(GL_PIXEL_UNPACK_BUFFER, Remap->NumEntries * 4, nullptr, GL_STREAM_DRAW); + glBufferData(GL_PIXEL_UNPACK_BUFFER, RoundedPaletteSize * 4, nullptr, GL_STREAM_DRAW); } else { @@ -2234,7 +2234,9 @@ bool OpenGLSWFrameBuffer::OpenGLPal::Update() Tex->CurrentBuffer = (Tex->CurrentBuffer + 1) & 1; } - buff = (uint32_t *)MapBuffer(GL_PIXEL_UNPACK_BUFFER, Remap->NumEntries * 4); + int numEntries = MIN(Remap->NumEntries, RoundedPaletteSize); + + buff = (uint32_t *)MapBuffer(GL_PIXEL_UNPACK_BUFFER, numEntries * 4); if (buff == nullptr) { return false; @@ -2242,13 +2244,13 @@ bool OpenGLSWFrameBuffer::OpenGLPal::Update() pal = Remap->Palette; // See explanation in UploadPalette() for skipat rationale. - skipat = MIN(Remap->NumEntries, DoColorSkip ? 256 - 8 : 256); + skipat = MIN(numEntries, DoColorSkip ? 256 - 8 : 256); for (i = 0; i < skipat; ++i) { buff[i] = ColorARGB(pal[i].a, pal[i].r, pal[i].g, pal[i].b); } - for (++i; i < Remap->NumEntries; ++i) + for (++i; i < numEntries; ++i) { buff[i] = ColorARGB(pal[i].a, pal[i - 1].r, pal[i - 1].g, pal[i - 1].b); } @@ -2258,7 +2260,7 @@ bool OpenGLSWFrameBuffer::OpenGLPal::Update() GLint oldBinding = 0; glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldBinding); glBindTexture(GL_TEXTURE_2D, Tex->Texture); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Remap->NumEntries, 1, GL_BGRA, GL_UNSIGNED_BYTE, 0); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, numEntries, 1, GL_BGRA, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, oldBinding); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); From cc94381366ef91887e6d0fad61567a4dc73cdb1d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 30 Nov 2016 07:14:24 +0100 Subject: [PATCH 1308/1509] Fix flushing issue in drawergen --- tools/drawergen/drawergen.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/drawergen/drawergen.cpp b/tools/drawergen/drawergen.cpp index a37f2f26e..a306f36af 100644 --- a/tools/drawergen/drawergen.cpp +++ b/tools/drawergen/drawergen.cpp @@ -599,6 +599,10 @@ std::vector LLVMProgram::GenerateObjectFile(std::string cpuName) PerModulePasses.run(*module); // Return the resulting object file + stream.flush(); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + vecstream.flush(); +#endif std::vector data; data.resize(str.size()); memcpy(data.data(), str.data(), data.size()); From 6cc33553c23dbd9f7922201558b5560bfb438e50 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 30 Nov 2016 07:48:40 +0100 Subject: [PATCH 1309/1509] Change object file generation to not use the JIT engine builder --- tools/drawergen/drawergen.cpp | 134 +++++++++++++--------------------- 1 file changed, 51 insertions(+), 83 deletions(-) diff --git a/tools/drawergen/drawergen.cpp b/tools/drawergen/drawergen.cpp index a306f36af..bd3854d54 100644 --- a/tools/drawergen/drawergen.cpp +++ b/tools/drawergen/drawergen.cpp @@ -54,8 +54,7 @@ public: LLVMProgram(); void CreateModule(); - std::string GenerateAssembly(std::string cpuName); - std::vector GenerateObjectFile(std::string cpuName); + std::vector GenerateObjectFile(const std::string &triple, const std::string &cpuName, const std::string &features); std::string DumpModule(); llvm::LLVMContext &context() { return *mContext; } @@ -70,7 +69,7 @@ private: class LLVMDrawers { public: - LLVMDrawers(const std::string &cpuName, const std::string namePostfix); + LLVMDrawers(const std::string &triple, const std::string &cpuName, const std::string &features, const std::string namePostfix); std::vector ObjectFile; @@ -97,7 +96,7 @@ private: ///////////////////////////////////////////////////////////////////////////// -LLVMDrawers::LLVMDrawers(const std::string &cpuName, const std::string namePostfix) : mNamePostfix(namePostfix) +LLVMDrawers::LLVMDrawers(const std::string &triple, const std::string &cpuName, const std::string &features, const std::string namePostfix) : mNamePostfix(namePostfix) { mProgram.CreateModule(); @@ -177,7 +176,7 @@ LLVMDrawers::LLVMDrawers(const std::string &cpuName, const std::string namePostf CodegenDrawTriangle("TriStencil", TriDrawVariant::Stencil, TriBlendMode::Copy, false); CodegenDrawTriangle("TriStencilClose", TriDrawVariant::StencilClose, TriBlendMode::Copy, false); - ObjectFile = mProgram.GenerateObjectFile(cpuName); + ObjectFile = mProgram.GenerateObjectFile(triple, cpuName, features); } void LLVMDrawers::CodegenDrawColumn(const char *name, DrawColumnVariant variant, DrawColumnMethod method) @@ -459,92 +458,57 @@ void LLVMProgram::CreateModule() mModule = std::make_unique("render", context()); } -std::string LLVMProgram::GenerateAssembly(std::string cpuName) +std::vector LLVMProgram::GenerateObjectFile(const std::string &triple, const std::string &cpuName, const std::string &features) { using namespace llvm; std::string errorstring; llvm::Module *module = mModule.get(); - EngineBuilder engineBuilder(std::move(mModule)); - engineBuilder.setErrorStr(&errorstring); - engineBuilder.setOptLevel(CodeGenOpt::Aggressive); - engineBuilder.setEngineKind(EngineKind::JIT); - engineBuilder.setMCPU(cpuName); - machine = engineBuilder.selectTarget(); - if (!machine) - throw Exception("Could not create LLVM target machine"); -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - std::string targetTriple = machine->getTargetTriple(); -#else - std::string targetTriple = machine->getTargetTriple().getTriple(); -#endif + const Target *target = TargetRegistry::lookupTarget(triple, errorstring); + Optional relocationModel = Reloc::PIC_; + CodeModel::Model codeModel = CodeModel::Model::Default; - module->setTargetTriple(targetTriple); -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - module->setDataLayout(new DataLayout(*machine->getSubtargetImpl()->getDataLayout())); -#else - module->setDataLayout(machine->createDataLayout()); -#endif + TargetOptions options; + options.LessPreciseFPMADOption = true; + options.AllowFPOpFusion = FPOpFusion::Fast; + options.Reciprocals = TargetRecip({ "all" }); + options.UnsafeFPMath = true; + options.NoInfsFPMath = true; + options.NoNaNsFPMath = true; + options.HonorSignDependentRoundingFPMathOption = false; + options.NoZerosInBSS = false; + options.GuaranteedTailCallOpt = false; + options.StackAlignmentOverride = 0; + options.StackSymbolOrdering = true; + options.UseInitArray = true; + options.DataSections = false; + options.FunctionSections = false; + options.UniqueSectionNames = true; + options.EmulatedTLS = false; + options.ExceptionModel = ExceptionHandling::None; + options.JTType = JumpTable::Single; // Create a single table for all jumptable functions + options.ThreadModel = ThreadModel::POSIX; + options.EABIVersion = EABI::Default; + options.DebuggerTuning = DebuggerKind::Default; + options.DisableIntegratedAS = false; + options.MCOptions.SanitizeAddress = false; + options.MCOptions.MCRelaxAll = false; // relax all fixups in the emitted object file + options.MCOptions.MCIncrementalLinkerCompatible = false; + options.MCOptions.DwarfVersion = 0; + options.MCOptions.ShowMCInst = false; + options.MCOptions.ABIName = ""; + options.MCOptions.MCFatalWarnings = false; + options.MCOptions.MCNoWarn = false; + options.MCOptions.ShowMCEncoding = false; // Show encoding in .s output + options.MCOptions.MCUseDwarfDirectory = false; + options.MCOptions.AsmVerbose = true; + options.MCOptions.PreserveAsmComments = true; - legacy::FunctionPassManager PerFunctionPasses(module); - legacy::PassManager PerModulePasses; + CodeGenOpt::Level optimizationLevel = CodeGenOpt::Aggressive; + machine = target->createTargetMachine(triple, cpuName, features, options, relocationModel, codeModel, optimizationLevel); -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8) - PerFunctionPasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); - PerModulePasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); -#endif - - SmallString<16 * 1024> str; -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - raw_svector_ostream vecstream(str); - formatted_raw_ostream stream(vecstream); -#else - raw_svector_ostream stream(str); -#endif - machine->addPassesToEmitFile(PerModulePasses, stream, TargetMachine::CGFT_AssemblyFile); - - PassManagerBuilder passManagerBuilder; - passManagerBuilder.OptLevel = 3; - passManagerBuilder.SizeLevel = 0; - passManagerBuilder.Inliner = createFunctionInliningPass(); - passManagerBuilder.SLPVectorize = true; - passManagerBuilder.LoopVectorize = true; - passManagerBuilder.LoadCombine = true; - passManagerBuilder.populateModulePassManager(PerModulePasses); - passManagerBuilder.populateFunctionPassManager(PerFunctionPasses); - - // Run function passes: - PerFunctionPasses.doInitialization(); - for (llvm::Function &func : *module) - { - if (!func.isDeclaration()) - PerFunctionPasses.run(func); - } - PerFunctionPasses.doFinalization(); - - // Run module passes: - PerModulePasses.run(*module); - - return str.c_str(); -} - -std::vector LLVMProgram::GenerateObjectFile(std::string cpuName) -{ - using namespace llvm; - - std::string errorstring; - - llvm::Module *module = mModule.get(); - EngineBuilder engineBuilder(std::move(mModule)); - engineBuilder.setErrorStr(&errorstring); - engineBuilder.setOptLevel(CodeGenOpt::Aggressive); - engineBuilder.setEngineKind(EngineKind::JIT); - engineBuilder.setMCPU(cpuName); - machine = engineBuilder.selectTarget(); - if (!machine) - throw Exception("Could not create LLVM target machine"); #if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) std::string targetTriple = machine->getTargetTriple(); @@ -599,8 +563,8 @@ std::vector LLVMProgram::GenerateObjectFile(std::string cpuName) PerModulePasses.run(*module); // Return the resulting object file - stream.flush(); #if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + stream.flush(); vecstream.flush(); #endif std::vector data; @@ -673,10 +637,14 @@ int main(int argc, char **argv) llvm::InitializeNativeTarget(); llvm::InitializeNativeTargetAsmPrinter(); + std::string triple = llvm::sys::getDefaultTargetTriple(); + std::cout << "Target triple is " << triple << std::endl; + std::string cpuName = "pentium4"; + std::string features; std::cout << "Compiling drawer code for " << cpuName << ".." << std::endl; - LLVMDrawers drawersSSE2(cpuName, "_SSE2"); + LLVMDrawers drawersSSE2(triple, cpuName, features, "_SSE2"); file = fopen(argv[1], "wb"); if (file == nullptr) From 03282c957b28a24b1bc90f430f041a85e2dd9a62 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 30 Nov 2016 07:49:04 +0100 Subject: [PATCH 1310/1509] Add a new blend mode for sprites --- src/r_drawers.cpp | 6 ++++++ src/r_drawers.h | 5 +++-- src/r_poly_sprite.cpp | 6 ++++++ src/r_poly_triangle.cpp | 1 + tools/drawergen/fixedfunction/drawercodegen.cpp | 7 +++++++ tools/drawergen/fixedfunction/drawercodegen.h | 1 + tools/drawergen/fixedfunction/drawtrianglecodegen.cpp | 10 ++++++++++ 7 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/r_drawers.cpp b/src/r_drawers.cpp index 72241fe74..f94f409c4 100644 --- a/src/r_drawers.cpp +++ b/src/r_drawers.cpp @@ -119,6 +119,7 @@ extern "C" void TriDrawNormal32_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawNormal32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawNormal32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); @@ -145,6 +146,7 @@ extern "C" void TriFillNormal32_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); @@ -158,6 +160,7 @@ extern "C" void TriDrawSubsector8_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); @@ -171,6 +174,7 @@ extern "C" void TriDrawSubsector32_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); @@ -184,6 +188,7 @@ extern "C" void TriFillSubsector8_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); @@ -197,6 +202,7 @@ extern "C" void TriFillSubsector32_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriStencil_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriStencilClose_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); } diff --git a/src/r_drawers.h b/src/r_drawers.h index bb541e99c..e986181ab 100644 --- a/src/r_drawers.h +++ b/src/r_drawers.h @@ -253,10 +253,11 @@ enum class TriBlendMode TranslateAlphaBlend, // blend_alpha_blend(shade(translate(fg)), bg) TranslateAdd, // blend_add(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) TranslateSub, // blend_sub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) - TranslateRevSub // blend_revsub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) + TranslateRevSub,// blend_revsub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) + AddSrcColorOneMinusSrcColor // glBlendMode(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR) used by GZDoom's fullbright additive sprites }; -inline int NumTriBlendModes() { return (int)TriBlendMode::TranslateRevSub + 1; } +inline int NumTriBlendModes() { return (int)TriBlendMode::AddSrcColorOneMinusSrcColor + 1; } class Drawers { diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index edb46c460..eb1328b48 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -150,6 +150,12 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla args.uniforms.srcalpha = 256; blendmode = args.translation ? TriBlendMode::TranslateAdd : TriBlendMode::Add; } + else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Add] && fullbrightSprite && thing->Alpha == 1.0 && args.translation == nullptr) + { + args.uniforms.destalpha = 256; + args.uniforms.srcalpha = 256; + blendmode = TriBlendMode::AddSrcColorOneMinusSrcColor; + } else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Add]) { args.uniforms.destalpha = (uint32_t)(1.0 * 256); diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index ed7ab55b9..a3398df2b 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -376,6 +376,7 @@ FString DrawPolyTrianglesCommand::DebugInfo() case TriBlendMode::TranslateAdd: blendmodestr = "TranslateAdd"; break; case TriBlendMode::TranslateSub: blendmodestr = "TranslateSub"; break; case TriBlendMode::TranslateRevSub: blendmodestr = "TranslateRevSub"; break; + case TriBlendMode::AddSrcColorOneMinusSrcColor: blendmodestr = "AddSrcColorOneMinusSrcColor"; break; } FString info; diff --git a/tools/drawergen/fixedfunction/drawercodegen.cpp b/tools/drawergen/fixedfunction/drawercodegen.cpp index 02c6e302a..a4ad1a941 100644 --- a/tools/drawergen/fixedfunction/drawercodegen.cpp +++ b/tools/drawergen/fixedfunction/drawercodegen.cpp @@ -160,3 +160,10 @@ SSAVec4i DrawerCodegen::blend_stencil(SSAVec4i stencilcolor, SSAInt fgalpha, SSA SSAVec4i color = (stencilcolor * srcalpha + bg * destalpha) / 256; return color.insert(3, 255); } + +SSAVec4i DrawerCodegen::blend_add_srccolor_oneminussrccolor(SSAVec4i fg, SSAVec4i bg) +{ + SSAVec4i fgcolor = fg + (fg >> 7); // 255 -> 256 + SSAVec4i inv_fgcolor = SSAVec4i(256) - fgcolor; + return fg + (bg * inv_fgcolor + 128) >> 8; +} diff --git a/tools/drawergen/fixedfunction/drawercodegen.h b/tools/drawergen/fixedfunction/drawercodegen.h index 8404f3acd..d1931e99c 100644 --- a/tools/drawergen/fixedfunction/drawercodegen.h +++ b/tools/drawergen/fixedfunction/drawercodegen.h @@ -86,6 +86,7 @@ public: SSAVec4i blend_revsub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha); SSAVec4i blend_alpha_blend(SSAVec4i fg, SSAVec4i bg); SSAVec4i blend_stencil(SSAVec4i color, SSAInt fgalpha, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha); + SSAVec4i blend_add_srccolor_oneminussrccolor(SSAVec4i fg, SSAVec4i bg); // Calculates the final alpha values to be used when combined with the source texture alpha channel SSAInt calc_blend_bgalpha(SSAVec4i fg, SSAInt destalpha); diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index 8178a58cc..b53a5f791 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -670,6 +670,10 @@ SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) fg = TranslateSample32(uvoffset); output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; + case TriBlendMode::AddSrcColorOneMinusSrcColor: + fg = Sample32(uvoffset); + output = blend_add_srccolor_oneminussrccolor(shade_bgra_simple(fg, currentlight), bg); + break; } return output; @@ -771,6 +775,12 @@ SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) output = ToPal8(blend_revsub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); output = (palindex == SSAInt(0)).select(bg, output); break; + case TriBlendMode::AddSrcColorOneMinusSrcColor: + palindex = Sample8(uvoffset); + fg = ToBgra(Shade8(palindex)); + output = ToPal8(blend_add_srccolor_oneminussrccolor(fg, ToBgra(bg))); + output = (palindex == SSAInt(0)).select(bg, output); + break; } return output; From 8ad2f4508216d741791157ac22d02ba0e002d66e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 30 Nov 2016 08:10:04 +0100 Subject: [PATCH 1311/1509] Fix compile errors for older LLVM --- tools/drawergen/drawergen.cpp | 37 ++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/tools/drawergen/drawergen.cpp b/tools/drawergen/drawergen.cpp index bd3854d54..db4d896ff 100644 --- a/tools/drawergen/drawergen.cpp +++ b/tools/drawergen/drawergen.cpp @@ -467,13 +467,18 @@ std::vector LLVMProgram::GenerateObjectFile(const std::string &triple, llvm::Module *module = mModule.get(); const Target *target = TargetRegistry::lookupTarget(triple, errorstring); + +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + Reloc::Model relocationModel = Reloc::PIC_; +#else Optional relocationModel = Reloc::PIC_; +#endif + CodeModel::Model codeModel = CodeModel::Model::Default; TargetOptions options; options.LessPreciseFPMADOption = true; options.AllowFPOpFusion = FPOpFusion::Fast; - options.Reciprocals = TargetRecip({ "all" }); options.UnsafeFPMath = true; options.NoInfsFPMath = true; options.NoNaNsFPMath = true; @@ -481,30 +486,34 @@ std::vector LLVMProgram::GenerateObjectFile(const std::string &triple, options.NoZerosInBSS = false; options.GuaranteedTailCallOpt = false; options.StackAlignmentOverride = 0; - options.StackSymbolOrdering = true; options.UseInitArray = true; options.DataSections = false; options.FunctionSections = false; - options.UniqueSectionNames = true; - options.EmulatedTLS = false; - options.ExceptionModel = ExceptionHandling::None; options.JTType = JumpTable::Single; // Create a single table for all jumptable functions options.ThreadModel = ThreadModel::POSIX; - options.EABIVersion = EABI::Default; - options.DebuggerTuning = DebuggerKind::Default; options.DisableIntegratedAS = false; options.MCOptions.SanitizeAddress = false; options.MCOptions.MCRelaxAll = false; // relax all fixups in the emitted object file - options.MCOptions.MCIncrementalLinkerCompatible = false; options.MCOptions.DwarfVersion = 0; options.MCOptions.ShowMCInst = false; options.MCOptions.ABIName = ""; options.MCOptions.MCFatalWarnings = false; - options.MCOptions.MCNoWarn = false; options.MCOptions.ShowMCEncoding = false; // Show encoding in .s output options.MCOptions.MCUseDwarfDirectory = false; options.MCOptions.AsmVerbose = true; + +#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8) + options.Reciprocals = TargetRecip({ "all" }); + options.StackSymbolOrdering = true; + options.UniqueSectionNames = true; + options.EmulatedTLS = false; + options.ExceptionModel = ExceptionHandling::None; + options.EABIVersion = EABI::Default; + options.DebuggerTuning = DebuggerKind::Default; + options.MCOptions.MCIncrementalLinkerCompatible = false; + options.MCOptions.MCNoWarn = false; options.MCOptions.PreserveAsmComments = true; +#endif CodeGenOpt::Level optimizationLevel = CodeGenOpt::Aggressive; machine = target->createTargetMachine(triple, cpuName, features, options, relocationModel, codeModel, optimizationLevel); @@ -638,6 +647,16 @@ int main(int argc, char **argv) llvm::InitializeNativeTargetAsmPrinter(); std::string triple = llvm::sys::getDefaultTargetTriple(); + +#ifdef __APPLE__ + // Target triple is x86_64-apple-darwin15.6.0 + auto pos = triple.find("-apple-darwin"); + if (pos != std::string::npos) + { + triple = triple.substr(0, pos) + "-apple-darwin10.11.0"; + } +#endif + std::cout << "Target triple is " << triple << std::endl; std::string cpuName = "pentium4"; From a7a779dd311e2095dfe8a1898353b5fd730af0a5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 30 Nov 2016 08:32:05 +0100 Subject: [PATCH 1312/1509] Fix race condition --- src/r_drawers.cpp | 347 +++++++++++++++++++++++----------------------- src/r_drawers.h | 3 + 2 files changed, 175 insertions(+), 175 deletions(-) diff --git a/src/r_drawers.cpp b/src/r_drawers.cpp index f94f409c4..ab45ad939 100644 --- a/src/r_drawers.cpp +++ b/src/r_drawers.cpp @@ -209,184 +209,181 @@ extern "C" ///////////////////////////////////////////////////////////////////////////// +Drawers::Drawers() +{ + DrawColumn = DrawColumn_SSE2; + DrawColumnAdd = DrawColumnAdd_SSE2; + DrawColumnShaded = DrawColumnShaded_SSE2; + DrawColumnAddClamp = DrawColumnAddClamp_SSE2; + DrawColumnSubClamp = DrawColumnSubClamp_SSE2; + DrawColumnRevSubClamp = DrawColumnRevSubClamp_SSE2; + DrawColumnTranslated = DrawColumnTranslated_SSE2; + DrawColumnTlatedAdd = DrawColumnTlatedAdd_SSE2; + DrawColumnAddClampTranslated = DrawColumnAddClampTranslated_SSE2; + DrawColumnSubClampTranslated = DrawColumnSubClampTranslated_SSE2; + DrawColumnRevSubClampTranslated = DrawColumnRevSubClampTranslated_SSE2; + FillColumn = FillColumn_SSE2; + FillColumnAdd = FillColumnAdd_SSE2; + FillColumnAddClamp = FillColumnAddClamp_SSE2; + FillColumnSubClamp = FillColumnSubClamp_SSE2; + FillColumnRevSubClamp = FillColumnRevSubClamp_SSE2; + DrawColumnRt1 = DrawColumnRt1_SSE2; + DrawColumnRt1Copy = DrawColumnRt1Copy_SSE2; + DrawColumnRt1Add = DrawColumnRt1Add_SSE2; + DrawColumnRt1Shaded = DrawColumnRt1Shaded_SSE2; + DrawColumnRt1AddClamp = DrawColumnRt1AddClamp_SSE2; + DrawColumnRt1SubClamp = DrawColumnRt1SubClamp_SSE2; + DrawColumnRt1RevSubClamp = DrawColumnRt1RevSubClamp_SSE2; + DrawColumnRt1Translated = DrawColumnRt1Translated_SSE2; + DrawColumnRt1TlatedAdd = DrawColumnRt1TlatedAdd_SSE2; + DrawColumnRt1AddClampTranslated = DrawColumnRt1AddClampTranslated_SSE2; + DrawColumnRt1SubClampTranslated = DrawColumnRt1SubClampTranslated_SSE2; + DrawColumnRt1RevSubClampTranslated = DrawColumnRt1RevSubClampTranslated_SSE2; + DrawColumnRt4 = DrawColumnRt4_SSE2; + DrawColumnRt4Copy = DrawColumnRt4Copy_SSE2; + DrawColumnRt4Add = DrawColumnRt4Add_SSE2; + DrawColumnRt4Shaded = DrawColumnRt4Shaded_SSE2; + DrawColumnRt4AddClamp = DrawColumnRt4AddClamp_SSE2; + DrawColumnRt4SubClamp = DrawColumnRt4SubClamp_SSE2; + DrawColumnRt4RevSubClamp = DrawColumnRt4RevSubClamp_SSE2; + DrawColumnRt4Translated = DrawColumnRt4Translated_SSE2; + DrawColumnRt4TlatedAdd = DrawColumnRt4TlatedAdd_SSE2; + DrawColumnRt4AddClampTranslated = DrawColumnRt4AddClampTranslated_SSE2; + DrawColumnRt4SubClampTranslated = DrawColumnRt4SubClampTranslated_SSE2; + DrawColumnRt4RevSubClampTranslated = DrawColumnRt4RevSubClampTranslated_SSE2; + DrawSpan = DrawSpan_SSE2; + DrawSpanMasked = DrawSpanMasked_SSE2; + DrawSpanTranslucent = DrawSpanTranslucent_SSE2; + DrawSpanMaskedTranslucent = DrawSpanMaskedTranslucent_SSE2; + DrawSpanAddClamp = DrawSpanAddClamp_SSE2; + DrawSpanMaskedAddClamp = DrawSpanMaskedAddClamp_SSE2; + vlinec1 = vlinec1_SSE2; + vlinec4 = vlinec4_SSE2; + mvlinec1 = mvlinec1_SSE2; + mvlinec4 = mvlinec4_SSE2; + tmvline1_add = tmvline1_add_SSE2; + tmvline4_add = tmvline4_add_SSE2; + tmvline1_addclamp = tmvline1_addclamp_SSE2; + tmvline4_addclamp = tmvline4_addclamp_SSE2; + tmvline1_subclamp = tmvline1_subclamp_SSE2; + tmvline4_subclamp = tmvline4_subclamp_SSE2; + tmvline1_revsubclamp = tmvline1_revsubclamp_SSE2; + tmvline4_revsubclamp = tmvline4_revsubclamp_SSE2; + DrawSky1 = DrawSky1_SSE2; + DrawSky4 = DrawSky4_SSE2; + DrawDoubleSky1 = DrawDoubleSky1_SSE2; + DrawDoubleSky4 = DrawDoubleSky4_SSE2; + TriDrawNormal8.push_back(TriDrawNormal8_0_SSE2); + TriDrawNormal8.push_back(TriDrawNormal8_1_SSE2); + TriDrawNormal8.push_back(TriDrawNormal8_2_SSE2); + TriDrawNormal8.push_back(TriDrawNormal8_3_SSE2); + TriDrawNormal8.push_back(TriDrawNormal8_4_SSE2); + TriDrawNormal8.push_back(TriDrawNormal8_5_SSE2); + TriDrawNormal8.push_back(TriDrawNormal8_6_SSE2); + TriDrawNormal8.push_back(TriDrawNormal8_7_SSE2); + TriDrawNormal8.push_back(TriDrawNormal8_8_SSE2); + TriDrawNormal8.push_back(TriDrawNormal8_9_SSE2); + TriDrawNormal8.push_back(TriDrawNormal8_10_SSE2); + TriDrawNormal8.push_back(TriDrawNormal8_11_SSE2); + TriDrawNormal8.push_back(TriDrawNormal8_12_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_0_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_1_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_2_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_3_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_4_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_5_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_6_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_7_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_8_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_9_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_10_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_11_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_12_SSE2); + TriFillNormal8.push_back(TriFillNormal8_0_SSE2); + TriFillNormal8.push_back(TriFillNormal8_1_SSE2); + TriFillNormal8.push_back(TriFillNormal8_2_SSE2); + TriFillNormal8.push_back(TriFillNormal8_3_SSE2); + TriFillNormal8.push_back(TriFillNormal8_4_SSE2); + TriFillNormal8.push_back(TriFillNormal8_5_SSE2); + TriFillNormal8.push_back(TriFillNormal8_6_SSE2); + TriFillNormal8.push_back(TriFillNormal8_7_SSE2); + TriFillNormal8.push_back(TriFillNormal8_8_SSE2); + TriFillNormal8.push_back(TriFillNormal8_9_SSE2); + TriFillNormal8.push_back(TriFillNormal8_10_SSE2); + TriFillNormal8.push_back(TriFillNormal8_11_SSE2); + TriFillNormal8.push_back(TriFillNormal8_12_SSE2); + TriFillNormal32.push_back(TriFillNormal32_0_SSE2); + TriFillNormal32.push_back(TriFillNormal32_1_SSE2); + TriFillNormal32.push_back(TriFillNormal32_2_SSE2); + TriFillNormal32.push_back(TriFillNormal32_3_SSE2); + TriFillNormal32.push_back(TriFillNormal32_4_SSE2); + TriFillNormal32.push_back(TriFillNormal32_5_SSE2); + TriFillNormal32.push_back(TriFillNormal32_6_SSE2); + TriFillNormal32.push_back(TriFillNormal32_7_SSE2); + TriFillNormal32.push_back(TriFillNormal32_8_SSE2); + TriFillNormal32.push_back(TriFillNormal32_9_SSE2); + TriFillNormal32.push_back(TriFillNormal32_10_SSE2); + TriFillNormal32.push_back(TriFillNormal32_11_SSE2); + TriFillNormal32.push_back(TriFillNormal32_12_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_0_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_1_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_2_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_3_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_4_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_5_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_6_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_7_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_8_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_9_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_10_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_11_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_12_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_0_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_1_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_2_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_3_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_4_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_5_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_6_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_7_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_8_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_9_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_10_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_11_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_12_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_0_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_1_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_2_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_3_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_4_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_5_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_6_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_7_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_8_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_9_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_10_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_11_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_12_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_0_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_1_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_2_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_3_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_4_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_5_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_6_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_7_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_8_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_9_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_10_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_11_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_12_SSE2); + TriStencil = TriStencil_SSE2; + TriStencilClose = TriStencilClose_SSE2; +} + Drawers *Drawers::Instance() { static Drawers drawers; - static bool firstcall = true; - - if (!firstcall) - return &drawers; - - drawers.DrawColumn = DrawColumn_SSE2; - drawers.DrawColumnAdd = DrawColumnAdd_SSE2; - drawers.DrawColumnShaded = DrawColumnShaded_SSE2; - drawers.DrawColumnAddClamp = DrawColumnAddClamp_SSE2; - drawers.DrawColumnSubClamp = DrawColumnSubClamp_SSE2; - drawers.DrawColumnRevSubClamp = DrawColumnRevSubClamp_SSE2; - drawers.DrawColumnTranslated = DrawColumnTranslated_SSE2; - drawers.DrawColumnTlatedAdd = DrawColumnTlatedAdd_SSE2; - drawers.DrawColumnAddClampTranslated = DrawColumnAddClampTranslated_SSE2; - drawers.DrawColumnSubClampTranslated = DrawColumnSubClampTranslated_SSE2; - drawers.DrawColumnRevSubClampTranslated = DrawColumnRevSubClampTranslated_SSE2; - drawers.FillColumn = FillColumn_SSE2; - drawers.FillColumnAdd = FillColumnAdd_SSE2; - drawers.FillColumnAddClamp = FillColumnAddClamp_SSE2; - drawers.FillColumnSubClamp = FillColumnSubClamp_SSE2; - drawers.FillColumnRevSubClamp = FillColumnRevSubClamp_SSE2; - drawers.DrawColumnRt1 = DrawColumnRt1_SSE2; - drawers.DrawColumnRt1Copy = DrawColumnRt1Copy_SSE2; - drawers.DrawColumnRt1Add = DrawColumnRt1Add_SSE2; - drawers.DrawColumnRt1Shaded = DrawColumnRt1Shaded_SSE2; - drawers.DrawColumnRt1AddClamp = DrawColumnRt1AddClamp_SSE2; - drawers.DrawColumnRt1SubClamp = DrawColumnRt1SubClamp_SSE2; - drawers.DrawColumnRt1RevSubClamp = DrawColumnRt1RevSubClamp_SSE2; - drawers.DrawColumnRt1Translated = DrawColumnRt1Translated_SSE2; - drawers.DrawColumnRt1TlatedAdd = DrawColumnRt1TlatedAdd_SSE2; - drawers.DrawColumnRt1AddClampTranslated = DrawColumnRt1AddClampTranslated_SSE2; - drawers.DrawColumnRt1SubClampTranslated = DrawColumnRt1SubClampTranslated_SSE2; - drawers.DrawColumnRt1RevSubClampTranslated = DrawColumnRt1RevSubClampTranslated_SSE2; - drawers.DrawColumnRt4 = DrawColumnRt4_SSE2; - drawers.DrawColumnRt4Copy = DrawColumnRt4Copy_SSE2; - drawers.DrawColumnRt4Add = DrawColumnRt4Add_SSE2; - drawers.DrawColumnRt4Shaded = DrawColumnRt4Shaded_SSE2; - drawers.DrawColumnRt4AddClamp = DrawColumnRt4AddClamp_SSE2; - drawers.DrawColumnRt4SubClamp = DrawColumnRt4SubClamp_SSE2; - drawers.DrawColumnRt4RevSubClamp = DrawColumnRt4RevSubClamp_SSE2; - drawers.DrawColumnRt4Translated = DrawColumnRt4Translated_SSE2; - drawers.DrawColumnRt4TlatedAdd = DrawColumnRt4TlatedAdd_SSE2; - drawers.DrawColumnRt4AddClampTranslated = DrawColumnRt4AddClampTranslated_SSE2; - drawers.DrawColumnRt4SubClampTranslated = DrawColumnRt4SubClampTranslated_SSE2; - drawers.DrawColumnRt4RevSubClampTranslated = DrawColumnRt4RevSubClampTranslated_SSE2; - drawers.DrawSpan = DrawSpan_SSE2; - drawers.DrawSpanMasked = DrawSpanMasked_SSE2; - drawers.DrawSpanTranslucent = DrawSpanTranslucent_SSE2; - drawers.DrawSpanMaskedTranslucent = DrawSpanMaskedTranslucent_SSE2; - drawers.DrawSpanAddClamp = DrawSpanAddClamp_SSE2; - drawers.DrawSpanMaskedAddClamp = DrawSpanMaskedAddClamp_SSE2; - drawers.vlinec1 = vlinec1_SSE2; - drawers.vlinec4 = vlinec4_SSE2; - drawers.mvlinec1 = mvlinec1_SSE2; - drawers.mvlinec4 = mvlinec4_SSE2; - drawers.tmvline1_add = tmvline1_add_SSE2; - drawers.tmvline4_add = tmvline4_add_SSE2; - drawers.tmvline1_addclamp = tmvline1_addclamp_SSE2; - drawers.tmvline4_addclamp = tmvline4_addclamp_SSE2; - drawers.tmvline1_subclamp = tmvline1_subclamp_SSE2; - drawers.tmvline4_subclamp = tmvline4_subclamp_SSE2; - drawers.tmvline1_revsubclamp = tmvline1_revsubclamp_SSE2; - drawers.tmvline4_revsubclamp = tmvline4_revsubclamp_SSE2; - drawers.DrawSky1 = DrawSky1_SSE2; - drawers.DrawSky4 = DrawSky4_SSE2; - drawers.DrawDoubleSky1 = DrawDoubleSky1_SSE2; - drawers.DrawDoubleSky4 = DrawDoubleSky4_SSE2; - drawers.TriDrawNormal8.push_back(TriDrawNormal8_0_SSE2); - drawers.TriDrawNormal8.push_back(TriDrawNormal8_1_SSE2); - drawers.TriDrawNormal8.push_back(TriDrawNormal8_2_SSE2); - drawers.TriDrawNormal8.push_back(TriDrawNormal8_3_SSE2); - drawers.TriDrawNormal8.push_back(TriDrawNormal8_4_SSE2); - drawers.TriDrawNormal8.push_back(TriDrawNormal8_5_SSE2); - drawers.TriDrawNormal8.push_back(TriDrawNormal8_6_SSE2); - drawers.TriDrawNormal8.push_back(TriDrawNormal8_7_SSE2); - drawers.TriDrawNormal8.push_back(TriDrawNormal8_8_SSE2); - drawers.TriDrawNormal8.push_back(TriDrawNormal8_9_SSE2); - drawers.TriDrawNormal8.push_back(TriDrawNormal8_10_SSE2); - drawers.TriDrawNormal8.push_back(TriDrawNormal8_11_SSE2); - drawers.TriDrawNormal8.push_back(TriDrawNormal8_12_SSE2); - drawers.TriDrawNormal32.push_back(TriDrawNormal32_0_SSE2); - drawers.TriDrawNormal32.push_back(TriDrawNormal32_1_SSE2); - drawers.TriDrawNormal32.push_back(TriDrawNormal32_2_SSE2); - drawers.TriDrawNormal32.push_back(TriDrawNormal32_3_SSE2); - drawers.TriDrawNormal32.push_back(TriDrawNormal32_4_SSE2); - drawers.TriDrawNormal32.push_back(TriDrawNormal32_5_SSE2); - drawers.TriDrawNormal32.push_back(TriDrawNormal32_6_SSE2); - drawers.TriDrawNormal32.push_back(TriDrawNormal32_7_SSE2); - drawers.TriDrawNormal32.push_back(TriDrawNormal32_8_SSE2); - drawers.TriDrawNormal32.push_back(TriDrawNormal32_9_SSE2); - drawers.TriDrawNormal32.push_back(TriDrawNormal32_10_SSE2); - drawers.TriDrawNormal32.push_back(TriDrawNormal32_11_SSE2); - drawers.TriDrawNormal32.push_back(TriDrawNormal32_12_SSE2); - drawers.TriFillNormal8.push_back(TriFillNormal8_0_SSE2); - drawers.TriFillNormal8.push_back(TriFillNormal8_1_SSE2); - drawers.TriFillNormal8.push_back(TriFillNormal8_2_SSE2); - drawers.TriFillNormal8.push_back(TriFillNormal8_3_SSE2); - drawers.TriFillNormal8.push_back(TriFillNormal8_4_SSE2); - drawers.TriFillNormal8.push_back(TriFillNormal8_5_SSE2); - drawers.TriFillNormal8.push_back(TriFillNormal8_6_SSE2); - drawers.TriFillNormal8.push_back(TriFillNormal8_7_SSE2); - drawers.TriFillNormal8.push_back(TriFillNormal8_8_SSE2); - drawers.TriFillNormal8.push_back(TriFillNormal8_9_SSE2); - drawers.TriFillNormal8.push_back(TriFillNormal8_10_SSE2); - drawers.TriFillNormal8.push_back(TriFillNormal8_11_SSE2); - drawers.TriFillNormal8.push_back(TriFillNormal8_12_SSE2); - drawers.TriFillNormal32.push_back(TriFillNormal32_0_SSE2); - drawers.TriFillNormal32.push_back(TriFillNormal32_1_SSE2); - drawers.TriFillNormal32.push_back(TriFillNormal32_2_SSE2); - drawers.TriFillNormal32.push_back(TriFillNormal32_3_SSE2); - drawers.TriFillNormal32.push_back(TriFillNormal32_4_SSE2); - drawers.TriFillNormal32.push_back(TriFillNormal32_5_SSE2); - drawers.TriFillNormal32.push_back(TriFillNormal32_6_SSE2); - drawers.TriFillNormal32.push_back(TriFillNormal32_7_SSE2); - drawers.TriFillNormal32.push_back(TriFillNormal32_8_SSE2); - drawers.TriFillNormal32.push_back(TriFillNormal32_9_SSE2); - drawers.TriFillNormal32.push_back(TriFillNormal32_10_SSE2); - drawers.TriFillNormal32.push_back(TriFillNormal32_11_SSE2); - drawers.TriFillNormal32.push_back(TriFillNormal32_12_SSE2); - drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_0_SSE2); - drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_1_SSE2); - drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_2_SSE2); - drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_3_SSE2); - drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_4_SSE2); - drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_5_SSE2); - drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_6_SSE2); - drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_7_SSE2); - drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_8_SSE2); - drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_9_SSE2); - drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_10_SSE2); - drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_11_SSE2); - drawers.TriDrawSubsector8.push_back(TriDrawSubsector8_12_SSE2); - drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_0_SSE2); - drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_1_SSE2); - drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_2_SSE2); - drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_3_SSE2); - drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_4_SSE2); - drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_5_SSE2); - drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_6_SSE2); - drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_7_SSE2); - drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_8_SSE2); - drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_9_SSE2); - drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_10_SSE2); - drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_11_SSE2); - drawers.TriDrawSubsector32.push_back(TriDrawSubsector32_12_SSE2); - drawers.TriFillSubsector8.push_back(TriFillSubsector8_0_SSE2); - drawers.TriFillSubsector8.push_back(TriFillSubsector8_1_SSE2); - drawers.TriFillSubsector8.push_back(TriFillSubsector8_2_SSE2); - drawers.TriFillSubsector8.push_back(TriFillSubsector8_3_SSE2); - drawers.TriFillSubsector8.push_back(TriFillSubsector8_4_SSE2); - drawers.TriFillSubsector8.push_back(TriFillSubsector8_5_SSE2); - drawers.TriFillSubsector8.push_back(TriFillSubsector8_6_SSE2); - drawers.TriFillSubsector8.push_back(TriFillSubsector8_7_SSE2); - drawers.TriFillSubsector8.push_back(TriFillSubsector8_8_SSE2); - drawers.TriFillSubsector8.push_back(TriFillSubsector8_9_SSE2); - drawers.TriFillSubsector8.push_back(TriFillSubsector8_10_SSE2); - drawers.TriFillSubsector8.push_back(TriFillSubsector8_11_SSE2); - drawers.TriFillSubsector8.push_back(TriFillSubsector8_12_SSE2); - drawers.TriFillSubsector32.push_back(TriFillSubsector32_0_SSE2); - drawers.TriFillSubsector32.push_back(TriFillSubsector32_1_SSE2); - drawers.TriFillSubsector32.push_back(TriFillSubsector32_2_SSE2); - drawers.TriFillSubsector32.push_back(TriFillSubsector32_3_SSE2); - drawers.TriFillSubsector32.push_back(TriFillSubsector32_4_SSE2); - drawers.TriFillSubsector32.push_back(TriFillSubsector32_5_SSE2); - drawers.TriFillSubsector32.push_back(TriFillSubsector32_6_SSE2); - drawers.TriFillSubsector32.push_back(TriFillSubsector32_7_SSE2); - drawers.TriFillSubsector32.push_back(TriFillSubsector32_8_SSE2); - drawers.TriFillSubsector32.push_back(TriFillSubsector32_9_SSE2); - drawers.TriFillSubsector32.push_back(TriFillSubsector32_10_SSE2); - drawers.TriFillSubsector32.push_back(TriFillSubsector32_11_SSE2); - drawers.TriFillSubsector32.push_back(TriFillSubsector32_12_SSE2); - drawers.TriStencil = TriStencil_SSE2; - drawers.TriStencilClose = TriStencilClose_SSE2; - - firstcall = false; return &drawers; } diff --git a/src/r_drawers.h b/src/r_drawers.h index e986181ab..47a145b5a 100644 --- a/src/r_drawers.h +++ b/src/r_drawers.h @@ -340,4 +340,7 @@ public: std::vector TriFillSubsector32; void(*TriStencil)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; void(*TriStencilClose)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + +private: + Drawers(); }; From 34bf5819574b082ce1f89f60e941c7f955ecb946 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 30 Nov 2016 08:51:39 +0100 Subject: [PATCH 1313/1509] Fix new blend mode --- src/r_drawers.cpp | 10 ++++++++++ tools/drawergen/fixedfunction/drawercodegen.cpp | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/r_drawers.cpp b/src/r_drawers.cpp index ab45ad939..66cbdd750 100644 --- a/src/r_drawers.cpp +++ b/src/r_drawers.cpp @@ -106,6 +106,7 @@ extern "C" void TriDrawNormal8_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawNormal8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawNormal8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawNormal32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawNormal32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawNormal32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); @@ -133,6 +134,7 @@ extern "C" void TriFillNormal8_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); @@ -286,6 +288,7 @@ Drawers::Drawers() TriDrawNormal8.push_back(TriDrawNormal8_10_SSE2); TriDrawNormal8.push_back(TriDrawNormal8_11_SSE2); TriDrawNormal8.push_back(TriDrawNormal8_12_SSE2); + TriDrawNormal8.push_back(TriDrawNormal8_13_SSE2); TriDrawNormal32.push_back(TriDrawNormal32_0_SSE2); TriDrawNormal32.push_back(TriDrawNormal32_1_SSE2); TriDrawNormal32.push_back(TriDrawNormal32_2_SSE2); @@ -299,6 +302,7 @@ Drawers::Drawers() TriDrawNormal32.push_back(TriDrawNormal32_10_SSE2); TriDrawNormal32.push_back(TriDrawNormal32_11_SSE2); TriDrawNormal32.push_back(TriDrawNormal32_12_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_13_SSE2); TriFillNormal8.push_back(TriFillNormal8_0_SSE2); TriFillNormal8.push_back(TriFillNormal8_1_SSE2); TriFillNormal8.push_back(TriFillNormal8_2_SSE2); @@ -312,6 +316,7 @@ Drawers::Drawers() TriFillNormal8.push_back(TriFillNormal8_10_SSE2); TriFillNormal8.push_back(TriFillNormal8_11_SSE2); TriFillNormal8.push_back(TriFillNormal8_12_SSE2); + TriFillNormal8.push_back(TriFillNormal8_13_SSE2); TriFillNormal32.push_back(TriFillNormal32_0_SSE2); TriFillNormal32.push_back(TriFillNormal32_1_SSE2); TriFillNormal32.push_back(TriFillNormal32_2_SSE2); @@ -325,6 +330,7 @@ Drawers::Drawers() TriFillNormal32.push_back(TriFillNormal32_10_SSE2); TriFillNormal32.push_back(TriFillNormal32_11_SSE2); TriFillNormal32.push_back(TriFillNormal32_12_SSE2); + TriFillNormal32.push_back(TriFillNormal32_13_SSE2); TriDrawSubsector8.push_back(TriDrawSubsector8_0_SSE2); TriDrawSubsector8.push_back(TriDrawSubsector8_1_SSE2); TriDrawSubsector8.push_back(TriDrawSubsector8_2_SSE2); @@ -338,6 +344,7 @@ Drawers::Drawers() TriDrawSubsector8.push_back(TriDrawSubsector8_10_SSE2); TriDrawSubsector8.push_back(TriDrawSubsector8_11_SSE2); TriDrawSubsector8.push_back(TriDrawSubsector8_12_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_13_SSE2); TriDrawSubsector32.push_back(TriDrawSubsector32_0_SSE2); TriDrawSubsector32.push_back(TriDrawSubsector32_1_SSE2); TriDrawSubsector32.push_back(TriDrawSubsector32_2_SSE2); @@ -351,6 +358,7 @@ Drawers::Drawers() TriDrawSubsector32.push_back(TriDrawSubsector32_10_SSE2); TriDrawSubsector32.push_back(TriDrawSubsector32_11_SSE2); TriDrawSubsector32.push_back(TriDrawSubsector32_12_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_13_SSE2); TriFillSubsector8.push_back(TriFillSubsector8_0_SSE2); TriFillSubsector8.push_back(TriFillSubsector8_1_SSE2); TriFillSubsector8.push_back(TriFillSubsector8_2_SSE2); @@ -364,6 +372,7 @@ Drawers::Drawers() TriFillSubsector8.push_back(TriFillSubsector8_10_SSE2); TriFillSubsector8.push_back(TriFillSubsector8_11_SSE2); TriFillSubsector8.push_back(TriFillSubsector8_12_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_13_SSE2); TriFillSubsector32.push_back(TriFillSubsector32_0_SSE2); TriFillSubsector32.push_back(TriFillSubsector32_1_SSE2); TriFillSubsector32.push_back(TriFillSubsector32_2_SSE2); @@ -377,6 +386,7 @@ Drawers::Drawers() TriFillSubsector32.push_back(TriFillSubsector32_10_SSE2); TriFillSubsector32.push_back(TriFillSubsector32_11_SSE2); TriFillSubsector32.push_back(TriFillSubsector32_12_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_13_SSE2); TriStencil = TriStencil_SSE2; TriStencilClose = TriStencilClose_SSE2; } diff --git a/tools/drawergen/fixedfunction/drawercodegen.cpp b/tools/drawergen/fixedfunction/drawercodegen.cpp index a4ad1a941..ccff40ac0 100644 --- a/tools/drawergen/fixedfunction/drawercodegen.cpp +++ b/tools/drawergen/fixedfunction/drawercodegen.cpp @@ -165,5 +165,5 @@ SSAVec4i DrawerCodegen::blend_add_srccolor_oneminussrccolor(SSAVec4i fg, SSAVec4 { SSAVec4i fgcolor = fg + (fg >> 7); // 255 -> 256 SSAVec4i inv_fgcolor = SSAVec4i(256) - fgcolor; - return fg + (bg * inv_fgcolor + 128) >> 8; + return fg + ((bg * inv_fgcolor + 128) >> 8); } From 837d8f44d1a8c95ac87b5042c4d2ac5c793235ae Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 30 Nov 2016 09:08:49 +0100 Subject: [PATCH 1314/1509] The precision of the SSE2 rcp opcode was a little bit too low --- tools/drawergen/fixedfunction/drawtrianglecodegen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index b53a5f791..2671ac0cf 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -204,7 +204,7 @@ void DrawTriangleCodegen::LoopBlockX() stack_x.store(minx); stack_posx_w.store(posy_w); for (int i = 0; i < TriVertex::NumVarying; i++) - stack_posx_varying[i].store(stack_posy_varying[i].load()); + stack_posx_varying[i].store(posy_varying[i]); SSAForBlock loop; x = stack_x.load(); @@ -277,7 +277,7 @@ void DrawTriangleCodegen::LoopBlockX() void DrawTriangleCodegen::SetupAffineBlock() { // Calculate varying variables for affine block - SSAVec4f rcpW = SSAVec4f::rcp(SSAVec4f(posx_w, posx_w + gradWX, posx_w + gradWY, posx_w + gradWX + gradWY)); + SSAVec4f rcpW = SSAVec4f(1.0f) / SSAVec4f(posx_w, posx_w + gradWX, posx_w + gradWY, posx_w + gradWX + gradWY); for (int i = 0; i < TriVertex::NumVarying; i++) { // Top left, top right, bottom left, bottom right: From 3872e39afc35339d3a6d99e076aeef07b8a5bc04 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 30 Nov 2016 12:56:37 +0100 Subject: [PATCH 1315/1509] Simplify affine texturing a bit --- .../fixedfunction/drawtrianglecodegen.cpp | 133 +++++++----------- .../fixedfunction/drawtrianglecodegen.h | 15 +- 2 files changed, 60 insertions(+), 88 deletions(-) diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index 2671ac0cf..4184dc536 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -143,12 +143,8 @@ void DrawTriangleCodegen::Setup() } gradWX = gradWX * (float)q; - gradWY = gradWY * (float)q; for (int i = 0; i < TriVertex::NumVarying; i++) - { gradVaryingX[i] = gradVaryingX[i] * (float)q; - gradVaryingY[i] = gradVaryingY[i] * (float)q; - } } SSAFloat DrawTriangleCodegen::gradx(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2) @@ -173,9 +169,9 @@ void DrawTriangleCodegen::LoopBlockY() stack_y.store(miny + blocks_skipped * q); stack_dest.store(dest[blocks_skipped * q * pitch * pixelsize]); stack_subsectorGBuffer.store(subsectorGBuffer[blocks_skipped * q * pitch]); - stack_posy_w.store(stack_posy_w.load() + gradWY * blocks_skipped); + stack_posy_w.store(stack_posy_w.load() + gradWY * (q * blocks_skipped)); for (int i = 0; i < TriVertex::NumVarying; i++) - stack_posy_varying[i].store(stack_posy_varying[i].load() + gradVaryingY[i] * blocks_skipped); + stack_posy_varying[i].store(stack_posy_varying[i].load() + gradVaryingY[i] * (blocks_skipped * q)); SSAForBlock loop; y = stack_y.load(); @@ -188,9 +184,9 @@ void DrawTriangleCodegen::LoopBlockY() { LoopBlockX(); - stack_posy_w.store(posy_w + gradWY * thread.num_cores); + stack_posy_w.store(posy_w + gradWY * (q * thread.num_cores)); for (int i = 0; i < TriVertex::NumVarying; i++) - stack_posy_varying[i].store(posy_varying[i] + gradVaryingY[i] * thread.num_cores); + stack_posy_varying[i].store(posy_varying[i] + gradVaryingY[i] * (q * thread.num_cores)); stack_dest.store(dest[q * pitch * pixelsize * thread.num_cores]); stack_subsectorGBuffer.store(subsectorGBuffer[q * pitch * thread.num_cores]); @@ -246,7 +242,24 @@ void DrawTriangleCodegen::LoopBlockX() // Check if block needs clipping SSABool clipneeded = x < clipleft || (x + q) > clipright || y < cliptop || (y + q) > clipbottom; - SetupAffineBlock(); + SSAFloat globVis = SSAFloat(1706.0f); + SSAFloat vis = globVis * posx_w; + SSAFloat shade = 64.0f - (SSAFloat(light * 255 / 256) + 12.0f) * 32.0f / 128.0f; + SSAFloat lightscale = SSAFloat::clamp((shade - SSAFloat::MIN(SSAFloat(24.0f), vis)) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)); + SSAInt diminishedlight = SSAInt(SSAFloat::clamp((1.0f - lightscale) * 256.0f + 0.5f, SSAFloat(0.0f), SSAFloat(256.0f)), false); + + if (!truecolor) + { + SSAInt diminishedindex = SSAInt(lightscale * 32.0f, false); + SSAInt lightindex = SSAInt::MIN((256 - light) * 32 / 256, SSAInt(31)); + SSAInt colormapindex = is_fixed_light.select(lightindex, diminishedindex); + currentcolormap = Colormaps[colormapindex << 8]; + } + else + { + currentlight = is_fixed_light.select(light, diminishedlight); + } + SetStencilBlock(x / 8 + y / 8 * stencilPitch); SSABool covered = a == SSAInt(0xF) && b == SSAInt(0xF) && c == SSAInt(0xF) && !clipneeded && StencilIsSingleValue(); @@ -276,41 +289,15 @@ void DrawTriangleCodegen::LoopBlockX() void DrawTriangleCodegen::SetupAffineBlock() { - // Calculate varying variables for affine block - SSAVec4f rcpW = SSAVec4f(1.0f) / SSAVec4f(posx_w, posx_w + gradWX, posx_w + gradWY, posx_w + gradWX + gradWY); + SSAFloat rcpW0 = (float)0x01000000 / AffineW; + SSAFloat rcpW1 = (float)0x01000000 / (AffineW + gradWX); + for (int i = 0; i < TriVertex::NumVarying; i++) { - // Top left, top right, bottom left, bottom right: - SSAVec4f varying = SSAVec4f(posx_varying[i], posx_varying[i] + gradVaryingX[i], posx_varying[i] + gradVaryingY[i], posx_varying[i] + gradVaryingX[i] + gradVaryingY[i]) * rcpW; - - SSAFloat startStepX = (varying[1] - varying[0]) * (1.0f / q); - SSAFloat endStepX = (varying[3] - varying[2]) * (1.0f / q); - SSAFloat incrStepX = (endStepX - startStepX) * (1.0f / q); - SSAFloat stepY = (varying[2] - varying[0]) * (1.0f / q); - - SSAVec4i ints = SSAVec4i(SSAVec4f(varying[0], stepY, startStepX, incrStepX) * (float)0x01000000) << 8; - varyingPos[i] = ints[0]; - varyingStepY[i] = ints[1]; - varyingStartStepX[i] = ints[2]; - varyingIncrStepX[i] = ints[3]; - } - - SSAFloat globVis = SSAFloat(1706.0f); - SSAFloat vis = globVis / rcpW[0]; - SSAFloat shade = 64.0f - (SSAFloat(light * 255 / 256) + 12.0f) * 32.0f / 128.0f; - SSAFloat lightscale = SSAFloat::clamp((shade - SSAFloat::MIN(SSAFloat(24.0f), vis)) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)); - SSAInt diminishedlight = SSAInt(SSAFloat::clamp((1.0f - lightscale) * 256.0f + 0.5f, SSAFloat(0.0f), SSAFloat(256.0f)), false); - - if (!truecolor) - { - SSAInt diminishedindex = SSAInt(lightscale * 32.0f, false); - SSAInt lightindex = SSAInt::MIN((256 - light) * 32 / 256, SSAInt(31)); - SSAInt colormapindex = is_fixed_light.select(lightindex, diminishedindex); - currentcolormap = Colormaps[colormapindex << 8]; - } - else - { - currentlight = is_fixed_light.select(light, diminishedlight); + AffineVaryingPosX[i] = SSAInt(AffineVaryingPosY[i] * rcpW0, false); + AffineVaryingStepX[i] = (SSAInt((AffineVaryingPosY[i] + gradVaryingX[i]) * rcpW1, false) - AffineVaryingPosX[i]) / q; + AffineVaryingPosX[i] = AffineVaryingPosX[i] << 8; + AffineVaryingStepX[i] = AffineVaryingStepX[i] << 8; } } @@ -346,22 +333,16 @@ void DrawTriangleCodegen::LoopFullBlock() { int pixelsize = truecolor ? 4 : 1; - SSAInt varyingLine[TriVertex::NumVarying]; - SSAInt varyingStepX[TriVertex::NumVarying]; + AffineW = posx_w; for (int i = 0; i < TriVertex::NumVarying; i++) - { - varyingLine[i] = varyingPos[i]; - varyingStepX[i] = varyingStartStepX[i]; - } + AffineVaryingPosY[i] = posx_varying[i]; for (int iy = 0; iy < q; iy++) { SSAUBytePtr buffer = dest[(x + iy * pitch) * pixelsize]; SSAIntPtr subsectorbuffer = subsectorGBuffer[x + iy * pitch]; - SSAInt varying[TriVertex::NumVarying]; - for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] = varyingLine[i]; + SetupAffineBlock(); for (int ix = 0; ix < q; ix += 4) { @@ -384,15 +365,15 @@ void DrawTriangleCodegen::LoopFullBlock() if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) { SSABool subsectorTest = subsectorbuffer[ix].load(true) >= subsectorDepth; - pixels[sse] = subsectorTest.select(ProcessPixel32(pixels[sse], varying), pixels[sse]); + pixels[sse] = subsectorTest.select(ProcessPixel32(pixels[sse], AffineVaryingPosX), pixels[sse]); } else { - pixels[sse] = ProcessPixel32(pixels[sse], varying); + pixels[sse] = ProcessPixel32(pixels[sse], AffineVaryingPosX); } for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] = varying[i] + varyingStepX[i]; + AffineVaryingPosX[i] = AffineVaryingPosX[i] + AffineVaryingStepX[i]; } buf.store_unaligned_vec16ub(SSAVec16ub(SSAVec8s(pixels[0], pixels[1]), SSAVec8s(pixels[2], pixels[3]))); @@ -413,15 +394,15 @@ void DrawTriangleCodegen::LoopFullBlock() if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) { SSABool subsectorTest = subsectorbuffer[ix].load(true) >= subsectorDepth; - pixels[sse] = subsectorTest.select(ProcessPixel8(pixels[sse], varying), pixels[sse]); + pixels[sse] = subsectorTest.select(ProcessPixel8(pixels[sse], AffineVaryingPosX), pixels[sse]); } else { - pixels[sse] = ProcessPixel8(pixels[sse], varying); + pixels[sse] = ProcessPixel8(pixels[sse], AffineVaryingPosX); } for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] = varying[i] + varyingStepX[i]; + AffineVaryingPosX[i] = AffineVaryingPosX[i] + AffineVaryingStepX[i]; } buf.store_vec4ub(SSAVec4i(pixels[0], pixels[1], pixels[2], pixels[3])); @@ -431,11 +412,9 @@ void DrawTriangleCodegen::LoopFullBlock() subsectorbuffer[ix].store_unaligned_vec4i(SSAVec4i(subsectorDepth)); } + AffineW = AffineW + gradWY; for (int i = 0; i < TriVertex::NumVarying; i++) - { - varyingLine[i] = varyingLine[i] + varyingStepY[i]; - varyingStepX[i] = varyingStepX[i] + varyingIncrStepX[i]; - } + AffineVaryingPosY[i] = AffineVaryingPosY[i] + gradVaryingY[i]; } } @@ -452,10 +431,10 @@ void DrawTriangleCodegen::LoopPartialBlock() stack_iy.store(SSAInt(0)); stack_buffer.store(dest[x * pixelsize]); stack_subsectorbuffer.store(subsectorGBuffer[x]); + stack_AffineW.store(posx_w); for (int i = 0; i < TriVertex::NumVarying; i++) { - stack_varyingLine[i].store(varyingPos[i]); - stack_varyingStep[i].store(varyingStartStepX[i]); + stack_AffineVaryingPosY[i].store(posx_varying[i]); } SSAForBlock loopy; @@ -465,17 +444,15 @@ void DrawTriangleCodegen::LoopPartialBlock() SSAInt CY1 = stack_CY1.load(); SSAInt CY2 = stack_CY2.load(); SSAInt CY3 = stack_CY3.load(); - SSAInt varyingLine[TriVertex::NumVarying]; - SSAInt varyingStep[TriVertex::NumVarying]; + AffineW = stack_AffineW.load(); for (int i = 0; i < TriVertex::NumVarying; i++) - { - varyingLine[i] = stack_varyingLine[i].load(); - varyingStep[i] = stack_varyingStep[i].load(); - } + AffineVaryingPosY[i] = stack_AffineVaryingPosY[i].load(); loopy.loop_block(iy < SSAInt(q), q); { + SetupAffineBlock(); + for (int i = 0; i < TriVertex::NumVarying; i++) - stack_varying[i].store(varyingLine[i]); + stack_AffineVaryingPosX[i].store(AffineVaryingPosX[i]); stack_CX1.store(CY1); stack_CX2.store(CY2); @@ -487,9 +464,8 @@ void DrawTriangleCodegen::LoopPartialBlock() SSAInt CX1 = stack_CX1.load(); SSAInt CX2 = stack_CX2.load(); SSAInt CX3 = stack_CX3.load(); - SSAInt varying[TriVertex::NumVarying]; for (int i = 0; i < TriVertex::NumVarying; i++) - varying[i] = stack_varying[i].load(); + AffineVaryingPosX[i] = stack_AffineVaryingPosX[i].load(); loopx.loop_block(ix < SSAInt(q), q); { SSABool visible = (ix + x >= clipleft) && (ix + x < clipright) && (iy + y >= cliptop) && (iy + y < clipbottom); @@ -527,12 +503,12 @@ void DrawTriangleCodegen::LoopPartialBlock() if (truecolor) { SSAVec4i bg = buf.load_vec4ub(false); - buf.store_vec4ub(ProcessPixel32(bg, varying)); + buf.store_vec4ub(ProcessPixel32(bg, AffineVaryingPosX)); } else { SSAUByte bg = buf.load(false); - buf.store(ProcessPixel8(bg.zext_int(), varying).trunc_ubyte()); + buf.store(ProcessPixel8(bg.zext_int(), AffineVaryingPosX).trunc_ubyte()); } if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) @@ -542,7 +518,7 @@ void DrawTriangleCodegen::LoopPartialBlock() branch.end_block(); for (int i = 0; i < TriVertex::NumVarying; i++) - stack_varying[i].store(varying[i] + varyingStep[i]); + stack_AffineVaryingPosX[i].store(AffineVaryingPosX[i] + AffineVaryingStepX[i]); stack_CX1.store(CX1 - FDY12); stack_CX2.store(CX2 - FDY23); @@ -551,12 +527,9 @@ void DrawTriangleCodegen::LoopPartialBlock() } loopx.end_block(); + stack_AffineW.store(AffineW + gradWY); for (int i = 0; i < TriVertex::NumVarying; i++) - { - stack_varyingLine[i].store(varyingLine[i] + varyingStepY[i]); - stack_varyingStep[i].store(varyingStep[i] + varyingIncrStepX[i]); - } - + stack_AffineVaryingPosY[i].store(AffineVaryingPosY[i] + gradVaryingY[i]); stack_CY1.store(CY1 + FDX12); stack_CY2.store(CY2 + FDX23); stack_CY3.store(CY3 + FDX31); diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.h b/tools/drawergen/fixedfunction/drawtrianglecodegen.h index 3866e3566..bc894f1a2 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.h +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.h @@ -80,14 +80,13 @@ private: SSAStack stack_buffer; SSAStack stack_subsectorbuffer; SSAStack stack_iy, stack_ix; - SSAStack stack_varyingLine[TriVertex::NumVarying]; - SSAStack stack_varyingStep[TriVertex::NumVarying]; - SSAStack stack_varying[TriVertex::NumVarying]; SSAStack stack_CY1, stack_CY2, stack_CY3; SSAStack stack_CX1, stack_CX2, stack_CX3; - SSAStack stack_posy_w, stack_posy_varying[TriVertex::NumVarying]; SSAStack stack_posx_w, stack_posx_varying[TriVertex::NumVarying]; + SSAStack stack_AffineW; + SSAStack stack_AffineVaryingPosY[TriVertex::NumVarying]; + SSAStack stack_AffineVaryingPosX[TriVertex::NumVarying]; SSAUBytePtr dest; SSAInt pitch; @@ -142,10 +141,10 @@ private: SSAInt x0, x1, y0, y1; SSAInt currentlight; SSAUBytePtr currentcolormap; - SSAInt varyingPos[TriVertex::NumVarying]; - SSAInt varyingStepY[TriVertex::NumVarying]; - SSAInt varyingStartStepX[TriVertex::NumVarying]; - SSAInt varyingIncrStepX[TriVertex::NumVarying]; + SSAFloat AffineW; + SSAFloat AffineVaryingPosY[TriVertex::NumVarying]; + SSAInt AffineVaryingPosX[TriVertex::NumVarying]; + SSAInt AffineVaryingStepX[TriVertex::NumVarying]; SSAFloat posy_w, posy_varying[TriVertex::NumVarying]; SSAFloat posx_w, posx_varying[TriVertex::NumVarying]; From fdbf2ab5e93ab1531381a8deca2078a6442fd3fb Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 30 Nov 2016 17:37:32 +0100 Subject: [PATCH 1316/1509] Fix compile errors for LLVM 3.8 --- tools/drawergen/drawergen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/drawergen/drawergen.cpp b/tools/drawergen/drawergen.cpp index db4d896ff..c31b0229d 100644 --- a/tools/drawergen/drawergen.cpp +++ b/tools/drawergen/drawergen.cpp @@ -468,7 +468,7 @@ std::vector LLVMProgram::GenerateObjectFile(const std::string &triple, const Target *target = TargetRegistry::lookupTarget(triple, errorstring); -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) Reloc::Model relocationModel = Reloc::PIC_; #else Optional relocationModel = Reloc::PIC_; @@ -502,7 +502,7 @@ std::vector LLVMProgram::GenerateObjectFile(const std::string &triple, options.MCOptions.MCUseDwarfDirectory = false; options.MCOptions.AsmVerbose = true; -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8) +#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9) options.Reciprocals = TargetRecip({ "all" }); options.StackSymbolOrdering = true; options.UniqueSectionNames = true; From 1bed6feadce05b5f41624f5eb6925feae7a43d02 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 1 Dec 2016 00:42:14 +0100 Subject: [PATCH 1317/1509] Detach poly renderer from r_main --- src/r_main.cpp | 28 ++++------------------ src/r_poly.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++-- src/r_poly.h | 6 ++++- src/r_swrenderer.cpp | 41 ++++++++++++++++++++++++++++--- 4 files changed, 102 insertions(+), 30 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index e0773718f..5c7ab39bc 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -59,18 +59,9 @@ #include "v_font.h" #include "r_data/colormaps.h" #include "p_maputl.h" -#include "r_poly.h" #include "p_setup.h" #include "version.h" -CUSTOM_CVAR(Bool, r_polyrenderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ - if (self == 1 && !hasglnodes) - { - Printf("No GL BSP detected. You must restart the map before rendering will be correct\n"); - } -} - // MACROS ------------------------------------------------------------------ #if 0 @@ -915,14 +906,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) // Link the polyobjects right before drawing the scene to reduce the amounts of calls to this function PO_LinkToSubsectors(); InSubsector = NULL; - if (!r_polyrenderer) - { - R_RenderBSPNode(nodes + numnodes - 1); // The head node is the last node output. - } - else - { - RenderPolyScene::Instance()->Render(); - } + R_RenderBSPNode(nodes + numnodes - 1); // The head node is the last node output. R_3D_ResetClip(); // reset clips (floor/ceiling) camera->renderflags = savedflags; WallCycles.Unclock(); @@ -932,11 +916,8 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) if (viewactive) { PlaneCycles.Clock(); - if (!r_polyrenderer) - { - R_DrawPlanes(); - R_DrawPortals(); - } + R_DrawPlanes(); + R_DrawPortals(); PlaneCycles.Unclock(); // [RH] Walk through mirrors @@ -953,8 +934,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) NetUpdate (); MaskedCycles.Clock(); - if (!r_polyrenderer) - R_DrawMasked (); + R_DrawMasked (); MaskedCycles.Unclock(); NetUpdate (); diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 186077806..3809c5639 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -25,11 +25,15 @@ #include "doomdef.h" #include "sbar.h" #include "r_data/r_translate.h" +#include "r_data/r_interpolate.h" #include "r_poly.h" #include "gl/data/gl_data.h" +#include "d_net.h" +#include "po_man.h" EXTERN_CVAR(Int, screenblocks) void InitGLRMapinfoData(); +extern bool r_showviewer; ///////////////////////////////////////////////////////////////////////////// @@ -39,8 +43,50 @@ RenderPolyScene *RenderPolyScene::Instance() return &scene; } -void RenderPolyScene::Render() +void RenderPolyScene::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines) { + const bool savedviewactive = viewactive; + const bool savedoutputformat = r_swtruecolor; + + viewwidth = width; + RenderTarget = canvas; + bRenderingToCanvas = true; + R_SetWindow(12, width, height, height, true); + viewwindowx = x; + viewwindowy = y; + viewactive = true; + r_swtruecolor = canvas->IsBgra(); + + canvas->Lock(true); + + RenderActorView(actor, dontmaplines); + + canvas->Unlock(); + + RenderTarget = screen; + bRenderingToCanvas = false; + R_ExecuteSetViewSize(); + viewactive = savedviewactive; + r_swtruecolor = savedoutputformat; +} + +void RenderPolyScene::RenderActorView(AActor *actor, bool dontmaplines) +{ + NetUpdate(); + + r_dontmaplines = dontmaplines; + + P_FindParticleSubsectors(); + PO_LinkToSubsectors(); + R_SetupFrame(actor); + + ActorRenderFlags savedflags = camera->renderflags; + // Never draw the player unless in chasecam mode + if (!r_showviewer) + camera->renderflags |= RF_INVISIBLE; + + R_BeginDrawerCommands(); + ClearBuffers(); SetSceneViewport(); SetupPerspectiveMatrix(); @@ -50,7 +96,14 @@ void RenderPolyScene::Render() MainPortal.RenderTranslucent(0); PlayerSprites.Render(); - DrawerCommandQueue::WaitForWorkers(); + camera->renderflags = savedflags; + interpolator.RestoreInterpolations (); + + NetUpdate(); + + R_EndDrawerCommands(); + + NetUpdate(); } void RenderPolyScene::RenderRemainingPlayerSprites() diff --git a/src/r_poly.h b/src/r_poly.h index 3bd9bb319..d67e39570 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -33,11 +33,15 @@ #include "r_poly_playersprite.h" #include "r_poly_sky.h" +class AActor; +class DCanvas; + // Renders a scene class RenderPolyScene { public: - void Render(); + void RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines); + void RenderActorView(AActor *actor, bool dontmaplines); void RenderRemainingPlayerSprites(); static RenderPolyScene *Instance(); diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 74a6da823..0f30fc3df 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -45,11 +45,19 @@ #include "r_draw_rgba.h" #include "r_drawers.h" #include "r_poly.h" +#include "p_setup.h" EXTERN_CVAR(Bool, r_shadercolormaps) -EXTERN_CVAR(Bool, r_polyrenderer) // [SP] dpJudas's new renderer EXTERN_CVAR(Float, maxviewpitch) // [SP] CVAR from GZDoom +CUSTOM_CVAR(Bool, r_polyrenderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (self == 1 && !hasglnodes) + { + Printf("No GL BSP detected. You must restart the map before rendering will be correct\n"); + } +} + void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio); void R_SetupColormap(player_t *); void R_SetupFreelook(); @@ -175,6 +183,27 @@ void FSoftwareRenderer::Precache(BYTE *texhitlist, TMap &act void FSoftwareRenderer::RenderView(player_t *player) { + if (r_polyrenderer) + { + bool saved_swtruecolor = r_swtruecolor; + r_swtruecolor = screen->IsBgra(); + + RenderPolyScene::Instance()->RenderActorView(player->mo, false); + FCanvasTextureInfo::UpdateAll(); + + // Apply special colormap if the target cannot do it + if (realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D)) + { + R_BeginDrawerCommands(); + DrawerCommandQueue::QueueCommand(realfixedcolormap, screen); + R_EndDrawerCommands(); + } + + r_swtruecolor = saved_swtruecolor; + + return; + } + if (r_swtruecolor != screen->IsBgra()) { r_swtruecolor = screen->IsBgra(); @@ -223,7 +252,10 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int wi // Take a snapshot of the player's view pic->ObjectFlags |= OF_Fixed; pic->Lock (); - R_RenderViewToCanvas (player->mo, pic, 0, 0, width, height); + if (r_polyrenderer) + RenderPolyScene::Instance()->RenderViewToCanvas(player->mo, pic, 0, 0, width, height, true); + else + R_RenderViewToCanvas (player->mo, pic, 0, 0, width, height); screen->GetFlashedPalette (palette); M_CreatePNG (file, pic->GetBuffer(), palette, SS_PAL, width, height, pic->GetPitch()); pic->Unlock (); @@ -373,7 +405,10 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin DAngle savedfov = FieldOfView; R_SetFOV ((double)fov); - R_RenderViewToCanvas (viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate); + if (r_polyrenderer) + RenderPolyScene::Instance()->RenderViewToCanvas(viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate); + else + R_RenderViewToCanvas (viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate); R_SetFOV (savedfov); if (Canvas->IsBgra()) From 9416d436fed692b5c5d49b9faf992b203fb356c2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 1 Dec 2016 02:38:32 +0100 Subject: [PATCH 1318/1509] Move software renderer into its own namespace to isolate its globals and make any access explicit. This reveals the places in the code where they are being accessed where they shouldn't and prevents accidental usage. --- src/gl/system/gl_swframebuffer.cpp | 7 ++-- src/r_3dfloors.cpp | 8 +++- src/r_3dfloors.h | 8 +++- src/r_bsp.cpp | 10 ++++- src/r_bsp.h | 8 +++- src/r_defs.h | 2 +- src/r_draw.cpp | 14 +++++-- src/r_draw.h | 19 ++++++---- src/r_draw_rgba.cpp | 15 +++++--- src/r_draw_rgba.h | 5 +++ src/r_drawt.cpp | 5 +++ src/r_drawt_rgba.cpp | 5 +++ src/r_main.cpp | 61 +++++++++++++++--------------- src/r_main.h | 12 ++++-- src/r_plane.cpp | 14 ++++--- src/r_plane.h | 5 +++ src/r_poly.cpp | 12 +++--- src/r_poly_decal.cpp | 4 +- src/r_poly_particle.cpp | 4 +- src/r_poly_plane.cpp | 10 ++--- src/r_poly_playersprite.cpp | 14 +++---- src/r_poly_portal.cpp | 10 ++--- src/r_poly_sky.cpp | 2 +- src/r_poly_sprite.cpp | 14 +++---- src/r_poly_triangle.cpp | 4 +- src/r_poly_triangle.h | 4 +- src/r_poly_wall.cpp | 4 +- src/r_poly_wallsprite.cpp | 2 +- src/r_segs.cpp | 29 ++++---------- src/r_segs.h | 5 +++ src/r_state.h | 2 +- src/r_swrenderer.cpp | 7 ++++ src/r_things.cpp | 25 +++++++----- src/r_things.h | 9 ++++- src/r_thread.h | 14 ++++--- src/v_draw.cpp | 6 ++- src/win32/fb_d3d9.cpp | 9 ++--- 37 files changed, 231 insertions(+), 157 deletions(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 4b10326a4..421fe9278 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -1377,15 +1377,16 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d) uint32_t color0, color1; if (Accel2D) { - if (realfixedcolormap == nullptr) + auto &map = swrenderer::realfixedcolormap; + if (map == nullptr) { color0 = 0; color1 = 0xFFFFFFF; } else { - color0 = ColorValue(realfixedcolormap->ColorizeStart[0] / 2, realfixedcolormap->ColorizeStart[1] / 2, realfixedcolormap->ColorizeStart[2] / 2, 0); - color1 = ColorValue(realfixedcolormap->ColorizeEnd[0] / 2, realfixedcolormap->ColorizeEnd[1] / 2, realfixedcolormap->ColorizeEnd[2] / 2, 1); + color0 = ColorValue(map->ColorizeStart[0] / 2, map->ColorizeStart[1] / 2, map->ColorizeStart[2] / 2, 0); + color1 = ColorValue(map->ColorizeEnd[0] / 2, map->ColorizeEnd[1] / 2, map->ColorizeEnd[2] / 2, 1); if (IsBgra()) SetPixelShader(Shaders[SHADER_SpecialColormap]); else diff --git a/src/r_3dfloors.cpp b/src/r_3dfloors.cpp index 61a23187d..4289b7843 100644 --- a/src/r_3dfloors.cpp +++ b/src/r_3dfloors.cpp @@ -15,6 +15,11 @@ #include "c_cvars.h" #include "r_3dfloors.h" +CVAR(Int, r_3dfloors, true, 0); + +namespace swrenderer +{ + // external variables int fake3D; F3DFloor *fakeFloor; @@ -28,8 +33,6 @@ HeightLevel *height_cur = NULL; int CurrentMirror = 0; int CurrentSkybox = 0; -CVAR(Int, r_3dfloors, true, 0); - // private variables int height_max = -1; TArray toplist; @@ -160,3 +163,4 @@ void R_3D_LeaveSkybox() CurrentSkybox--; } +} diff --git a/src/r_3dfloors.h b/src/r_3dfloors.h index cacb97444..a703ae19a 100644 --- a/src/r_3dfloors.h +++ b/src/r_3dfloors.h @@ -3,6 +3,11 @@ #include "p_3dfloors.h" +EXTERN_CVAR(Int, r_3dfloors); + +namespace swrenderer +{ + // special types struct HeightLevel @@ -57,7 +62,6 @@ extern HeightLevel *height_top; extern HeightLevel *height_cur; extern int CurrentMirror; extern int CurrentSkybox; -EXTERN_CVAR(Int, r_3dfloors); // functions void R_3D_DeleteHeights(); @@ -67,4 +71,6 @@ void R_3D_ResetClip(); void R_3D_EnterSkybox(); void R_3D_LeaveSkybox(); +} + #endif diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 8d423b3b3..92581f01b 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -58,6 +58,12 @@ #include "po_man.h" #include "r_data/colormaps.h" +CVAR (Bool, r_drawflat, false, 0) // [RH] Don't texture segs? +EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); + +namespace swrenderer +{ + seg_t* curline; side_t* sidedef; line_t* linedef; @@ -104,8 +110,6 @@ TArray WallPortals(1000); // note: this array needs to go away as subsector_t *InSubsector; -CVAR (Bool, r_drawflat, false, 0) // [RH] Don't texture segs? -EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); void R_StoreWallRange (int start, int stop); @@ -1396,3 +1400,5 @@ void R_RenderBSPNode (void *node) } R_Subsector ((subsector_t *)((BYTE *)node - 1)); } + +} diff --git a/src/r_bsp.h b/src/r_bsp.h index 48ca7565b..e4b518e75 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -27,6 +27,11 @@ #include #include "r_defs.h" +EXTERN_CVAR (Bool, r_drawflat) // [RH] Don't texture segs? + +namespace swrenderer +{ + // The 3072 below is just an arbitrary value picked to avoid // drawing lines the player is too close to that would overflow // the texture calculations. @@ -109,8 +114,6 @@ extern WORD MirrorFlags; typedef void (*drawfunc_t) (int start, int stop); -EXTERN_CVAR (Bool, r_drawflat) // [RH] Don't texture segs? - // BSP? void R_ClearClipSegs (short left, short right); void R_ClearDrawSegs (); @@ -119,5 +122,6 @@ void R_RenderBSPNode (void *node); // killough 4/13/98: fake floors/ceilings for deep water / fake ceilings: sector_t *R_FakeFlat(sector_t *, sector_t *, int *, int *, bool); +} #endif diff --git a/src/r_defs.h b/src/r_defs.h index 97552fb52..8b176da91 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -59,7 +59,7 @@ enum SIL_BOTH }; -extern size_t MaxDrawSegs; +namespace swrenderer { extern size_t MaxDrawSegs; } struct FDisplacement; // diff --git a/src/r_draw.cpp b/src/r_draw.cpp index d04b1dcf6..c1e96b329 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -47,6 +47,14 @@ #undef RANGECHECK +EXTERN_CVAR (Int, r_drawfuzz) +EXTERN_CVAR (Bool, r_drawtrans) +EXTERN_CVAR (Float, transsouls) +EXTERN_CVAR (Int, r_columnmethod) + +namespace swrenderer +{ + // status bar height at bottom of screen // [RH] status bar position at bottom of screen extern int ST_Y; @@ -194,7 +202,6 @@ FDynamicColormap identitycolormap; bool drawer_needs_pal_input; -EXTERN_CVAR (Int, r_columnmethod) void R_InitShadeMaps() { @@ -2734,9 +2741,6 @@ void R_InitColumnDrawers () } // [RH] Choose column drawers in a single place -EXTERN_CVAR (Int, r_drawfuzz) -EXTERN_CVAR (Bool, r_drawtrans) -EXTERN_CVAR (Float, transsouls) static FDynamicColormap *basecolormapsave; @@ -3122,3 +3126,5 @@ void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade) ds_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); } } + +} diff --git a/src/r_draw.h b/src/r_draw.h index 7556575bd..d312ac8fb 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -25,14 +25,23 @@ #include "r_defs.h" +struct FSWColormap; + +EXTERN_CVAR(Bool, r_multithreaded); +EXTERN_CVAR(Bool, r_magfilter); +EXTERN_CVAR(Bool, r_minfilter); +EXTERN_CVAR(Bool, r_mipmap); +EXTERN_CVAR(Float, r_lod_bias); + +namespace swrenderer +{ + // Spectre/Invisibility. #define FUZZTABLE 50 extern "C" int fuzzoffset[FUZZTABLE + 1]; // [RH] +1 for the assembly routine extern "C" int fuzzpos; extern "C" int fuzzviewheight; -struct FSWColormap; - struct ShadeConstants { uint16_t light_alpha; @@ -395,10 +404,6 @@ void R_DrawDoubleSkyCol4_rgba(uint32_t solid_top, uint32_t solid_bottom); extern bool r_swtruecolor; -EXTERN_CVAR(Bool, r_multithreaded); -EXTERN_CVAR(Bool, r_magfilter); -EXTERN_CVAR(Bool, r_minfilter); -EXTERN_CVAR(Bool, r_mipmap); -EXTERN_CVAR(Float, r_lod_bias); +} #endif diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 716b30c0d..61e0a8932 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -46,11 +46,6 @@ #include "x86.h" #include -extern "C" short spanend[MAXHEIGHT]; -extern float rw_light; -extern float rw_lightstep; -extern int wallshade; - // Use linear filtering when scaling up CVAR(Bool, r_magfilter, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); @@ -63,6 +58,14 @@ CVAR(Bool, r_mipmap, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); // Level of detail texture bias CVAR(Float, r_lod_bias, -1.5, 0); // To do: add CVAR_ARCHIVE | CVAR_GLOBALCONFIG when a good default has been decided +namespace swrenderer +{ + +extern "C" short spanend[MAXHEIGHT]; +extern float rw_light; +extern float rw_lightstep; +extern int wallshade; + ///////////////////////////////////////////////////////////////////////////// class DrawSpanLLVMCommand : public DrawerCommand @@ -1622,3 +1625,5 @@ void R_DrawFogBoundary_rgba(int x1, int x2, short *uclip, short *dclip) R_DrawFogBoundarySection_rgba(t2, b2, x1); } } + +} diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 4aa1a02af..8e66b7a72 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -36,6 +36,9 @@ struct FSpecialColormap; EXTERN_CVAR(Bool, r_mipmap) EXTERN_CVAR(Float, r_lod_bias) +namespace swrenderer +{ + ///////////////////////////////////////////////////////////////////////////// // Drawer functions: @@ -285,4 +288,6 @@ public: } }; +} + #endif diff --git a/src/r_drawt.cpp b/src/r_drawt.cpp index 0baf6d38c..d87c8f4c0 100644 --- a/src/r_drawt.cpp +++ b/src/r_drawt.cpp @@ -47,6 +47,9 @@ #include "r_things.h" #include "v_video.h" +namespace swrenderer +{ + // I should have commented this stuff better. // // dc_temp is the buffer R_DrawColumnHoriz writes into. @@ -1130,3 +1133,5 @@ void R_FillColumnHorizP_C (void) dest += 8; } while (--count); } + +} diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 57de59eba..98d27adec 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -45,6 +45,9 @@ #include "r_draw_rgba.h" #include "r_drawers.h" +namespace swrenderer +{ + extern unsigned int dc_tspans[4][MAXHEIGHT]; extern unsigned int *dc_ctspan[4]; extern unsigned int *horizspan[4]; @@ -506,3 +509,5 @@ void R_FillColumnHoriz_rgba (void) DrawerCommandQueue::QueueCommand(); } + +} diff --git a/src/r_main.cpp b/src/r_main.cpp index 5c7ab39bc..b236dc0e7 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -62,6 +62,34 @@ #include "p_setup.h" #include "version.h" +CVAR (String, r_viewsize, "", CVAR_NOSET) +CVAR (Bool, r_shadercolormaps, true, CVAR_ARCHIVE) + +CUSTOM_CVAR (Int, r_columnmethod, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + if (self != 0 && self != 1) + { + self = 1; + } + else + { // Trigger the change + setsizeneeded = true; + } +} + +CVAR(Int, r_portal_recursions, 4, CVAR_ARCHIVE) +CVAR(Bool, r_highlight_portals, false, CVAR_ARCHIVE) + +EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) + +extern cycle_t WallCycles, PlaneCycles, MaskedCycles, WallScanCycles; +extern cycle_t FrameCycles; + +extern bool r_showviewer; + +namespace swrenderer +{ + // MACROS ------------------------------------------------------------------ #if 0 @@ -91,7 +119,6 @@ extern short *openings; extern bool r_fakingunderwater; extern "C" int fuzzviewheight; extern subsector_t *InSubsector; -extern bool r_showviewer; // PRIVATE DATA DECLARATIONS ----------------------------------------------- @@ -103,9 +130,6 @@ bool r_dontmaplines; // PUBLIC DATA DEFINITIONS ------------------------------------------------- -CVAR (String, r_viewsize, "", CVAR_NOSET) -CVAR (Bool, r_shadercolormaps, true, CVAR_ARCHIVE) - bool r_swtruecolor; double r_BaseVisibility; @@ -366,26 +390,6 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, R_SetVisibility(R_GetVisibility()); } -//========================================================================== -// -// CVAR r_columnmethod -// -// Selects which version of the seg renderers to use. -// -//========================================================================== - -CUSTOM_CVAR (Int, r_columnmethod, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -{ - if (self != 0 && self != 1) - { - self = 1; - } - else - { // Trigger the change - setsizeneeded = true; - } -} - //========================================================================== // // R_Init @@ -450,8 +454,6 @@ void R_CopyStackedViewParameters() // //========================================================================== -EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) - void R_SetupColormap(player_t *player) { realfixedcolormap = NULL; @@ -569,9 +571,6 @@ void R_SetupFreelook() // //========================================================================== -CVAR(Int, r_portal_recursions, 4, CVAR_ARCHIVE) -CVAR(Bool, r_highlight_portals, false, CVAR_ARCHIVE) - void R_HighlightPortal (PortalDrawseg* pds) { // [ZZ] NO OVERFLOW CHECKS HERE @@ -1023,8 +1022,6 @@ void R_MultiresInit () // Displays statistics about rendering times // //========================================================================== -extern cycle_t WallCycles, PlaneCycles, MaskedCycles, WallScanCycles; -extern cycle_t FrameCycles; ADD_STAT (fps) { @@ -1104,3 +1101,5 @@ CCMD (clearscancycles) bestscancycles = HUGE_VAL; } #endif + +} diff --git a/src/r_main.h b/src/r_main.h index 6a802e799..f4d0a144a 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -28,6 +28,13 @@ #include "v_palette.h" #include "r_data/colormaps.h" +extern double ViewCos; +extern double ViewSin; +extern int viewwindowx; +extern int viewwindowy; + +namespace swrenderer +{ typedef BYTE lighttable_t; // This could be wider for >8 bit display. @@ -35,16 +42,12 @@ typedef BYTE lighttable_t; // This could be wider for >8 bit display. // POV related. // extern bool bRenderingToCanvas; -extern double ViewCos; -extern double ViewSin; extern fixed_t viewingrangerecip; extern double FocalLengthX, FocalLengthY; extern double InvZtoScale; extern double WallTMapScale2; -extern int viewwindowx; -extern int viewwindowy; extern double CenterX; extern double CenterY; @@ -152,5 +155,6 @@ extern DAngle stacked_angle; extern void R_CopyStackedViewParameters(); +} #endif // __R_MAIN_H__ diff --git a/src/r_plane.cpp b/src/r_plane.cpp index ca8547003..da58ad16c 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -64,10 +64,14 @@ #pragma warning(disable:4244) #endif +CVAR(Bool, r_linearsky, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR(Bool, tilt, false, 0); +CVAR(Bool, r_skyboxes, true, 0) + EXTERN_CVAR(Int, r_skymode) -//EXTERN_CVAR (Int, tx) -//EXTERN_CVAR (Int, ty) +namespace swrenderer +{ extern subsector_t *InSubsector; @@ -889,7 +893,6 @@ static DWORD lastskycol_bgra[MAXSKYBUF]; static int skycolplace; static int skycolplace_bgra; -CVAR(Bool, r_linearsky, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); // Get a column of sky when there is only one sky texture. static const BYTE *R_GetOneSkyColumn (FTexture *fronttex, int x) @@ -1312,8 +1315,6 @@ static void R_DrawSkyStriped (visplane_t *pl) // //========================================================================== -CVAR (Bool, tilt, false, 0); -//CVAR (Int, pa, 0, 0) int R_DrawPlanes () { @@ -1450,7 +1451,6 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske // 9. Put the camera back where it was to begin with. // //========================================================================== -CVAR (Bool, r_skyboxes, true, 0) static int numskyboxes; void R_DrawPortals () @@ -2190,3 +2190,5 @@ bool R_PlaneInitData () return true; } + +} diff --git a/src/r_plane.h b/src/r_plane.h index b199d3477..5e91a4b0b 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -27,6 +27,9 @@ class ASkyViewpoint; +namespace swrenderer +{ + // // The infamous visplane // @@ -121,4 +124,6 @@ bool R_PlaneInitData (void); extern visplane_t* floorplane; extern visplane_t* ceilingplane; +} + #endif // __R_PLANE_H__ diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 3809c5639..cadf92adf 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -46,16 +46,16 @@ RenderPolyScene *RenderPolyScene::Instance() void RenderPolyScene::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines) { const bool savedviewactive = viewactive; - const bool savedoutputformat = r_swtruecolor; + const bool savedoutputformat = swrenderer::r_swtruecolor; viewwidth = width; RenderTarget = canvas; - bRenderingToCanvas = true; + swrenderer::bRenderingToCanvas = true; R_SetWindow(12, width, height, height, true); viewwindowx = x; viewwindowy = y; viewactive = true; - r_swtruecolor = canvas->IsBgra(); + swrenderer::r_swtruecolor = canvas->IsBgra(); canvas->Lock(true); @@ -64,17 +64,17 @@ void RenderPolyScene::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, canvas->Unlock(); RenderTarget = screen; - bRenderingToCanvas = false; + swrenderer::bRenderingToCanvas = false; R_ExecuteSetViewSize(); viewactive = savedviewactive; - r_swtruecolor = savedoutputformat; + swrenderer::r_swtruecolor = savedoutputformat; } void RenderPolyScene::RenderActorView(AActor *actor, bool dontmaplines) { NetUpdate(); - r_dontmaplines = dontmaplines; + //swrenderer::r_dontmaplines = dontmaplines; P_FindParticleSubsectors(); PO_LinkToSubsectors(); diff --git a/src/r_poly_decal.cpp b/src/r_poly_decal.cpp index 9d47c014a..e91e25b58 100644 --- a/src/r_poly_decal.cpp +++ b/src/r_poly_decal.cpp @@ -135,7 +135,7 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan args.uniforms.flags = 0; args.SetColormap(front->ColorMap); args.SetTexture(tex, decal->Translation, true); - if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) + if (fullbrightSprite || swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap) { args.uniforms.light = 256; args.uniforms.flags |= TriUniforms::fixed_light; @@ -146,7 +146,7 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan } args.uniforms.subsectorDepth = subsectorDepth; - if (r_swtruecolor) + if (swrenderer::r_swtruecolor) { args.uniforms.color = 0xff000000 | decal->AlphaColor; } diff --git a/src/r_poly_particle.cpp b/src/r_poly_particle.cpp index 73e1819d4..0d31614d2 100644 --- a/src/r_poly_particle.cpp +++ b/src/r_poly_particle.cpp @@ -72,7 +72,7 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const Vec4f &clipP PolyDrawArgs args; - if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) + if (fullbrightSprite || swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap) { args.uniforms.light = 256; args.uniforms.flags = TriUniforms::fixed_light; @@ -84,7 +84,7 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const Vec4f &clipP } args.uniforms.subsectorDepth = subsectorDepth; - if (r_swtruecolor) + if (swrenderer::r_swtruecolor) { uint32_t alpha = particle->trans; args.uniforms.color = (alpha << 24) | (particle->color & 0xffffff); diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index b17b0ec2c..41898fa8b 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -28,7 +28,7 @@ #include "r_poly_plane.h" #include "r_poly_portal.h" #include "r_poly.h" -#include "r_sky.h" // for skyflatnum +#include "r_sky.h" EXTERN_CVAR(Int, r_3dfloors) @@ -96,10 +96,10 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c return; int lightlevel = 255; - if (fixedlightlev < 0 && sub->sector->e->XFloor.lightlist.Size()) + if (swrenderer::fixedlightlev < 0 && sub->sector->e->XFloor.lightlist.Size()) { lightlist_t *light = P_GetPlaneLight(sub->sector, &sub->sector->ceilingplane, false); - basecolormap = light->extra_colormap; + swrenderer::basecolormap = light->extra_colormap; lightlevel = *light->p_lightlevel; } @@ -107,7 +107,7 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c PolyDrawArgs args; args.uniforms.light = (uint32_t)(lightlevel / 255.0f * 256.0f); - if (fixedlightlev >= 0 || fixedcolormap) + if (swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap) args.uniforms.light = 256; args.uniforms.flags = 0; args.uniforms.subsectorDepth = subsectorDepth; @@ -251,7 +251,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan PolyDrawArgs args; args.uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f); - if (fixedlightlev >= 0 || fixedcolormap) + if (swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap) args.uniforms.light = 256; args.uniforms.flags = 0; args.uniforms.subsectorDepth = isSky ? RenderPolyPortal::SkySubsectorDepth : subsectorDepth; diff --git a/src/r_poly_playersprite.cpp b/src/r_poly_playersprite.cpp index 1a657d1a2..381f2e203 100644 --- a/src/r_poly_playersprite.cpp +++ b/src/r_poly_playersprite.cpp @@ -143,14 +143,14 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa double tx = sx - BaseXCenter; tx -= tex->GetScaledLeftOffset(); - int x1 = xs_RoundToInt(CenterX + tx * pspritexscale); + int x1 = xs_RoundToInt(swrenderer::CenterX + tx * swrenderer::pspritexscale); // off the right side if (x1 > viewwidth) return; tx += tex->GetScaledWidth(); - int x2 = xs_RoundToInt(CenterX + tx * pspritexscale); + int x2 = xs_RoundToInt(swrenderer::CenterX + tx * swrenderer::pspritexscale); // off the left side if (x2 <= 0) @@ -183,19 +183,19 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa int clipped_x1 = MAX(x1, 0); int clipped_x2 = MIN(x2, viewwidth); - double xscale = pspritexscale / tex->Scale.X; - double yscale = pspriteyscale / tex->Scale.Y; + double xscale = swrenderer::pspritexscale / tex->Scale.X; + double yscale = swrenderer::pspriteyscale / tex->Scale.Y; uint32_t translation = 0; // [RH] Use default colors double xiscale, startfrac; if (flip) { - xiscale = -pspritexiscale * tex->Scale.X; + xiscale = -swrenderer::pspritexiscale * tex->Scale.X; startfrac = 1; } else { - xiscale = pspritexiscale * tex->Scale.X; + xiscale = swrenderer::pspritexiscale * tex->Scale.X; startfrac = 0; } @@ -217,7 +217,7 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa int actualextralight = foggy ? 0 : extralight << 4; int spriteshade = LIGHT2SHADE(owner->Sector->lightlevel + actualextralight); double minz = double((2048 * 4) / double(1 << 20)); - visstyle.ColormapNum = GETPALOOKUP(r_SpriteVisibility / minz, spriteshade); + visstyle.ColormapNum = GETPALOOKUP(swrenderer::r_SpriteVisibility / minz, spriteshade); if (sprite->GetID() < PSP_TARGETCENTER) { diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 3257afc70..5c4dbc89f 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -163,7 +163,7 @@ void RenderPolyPortal::RenderLine(subsector_t *sub, seg_t *line, sector_t *front return; // Tell automap we saw this - if (!r_dontmaplines && line->linedef) + if (!swrenderer::r_dontmaplines && line->linedef) { line->linedef->flags |= ML_MAPPED; sub->flags |= SSECF_DRAWN; @@ -367,7 +367,7 @@ void PolyDrawSectorPortal::SaveGlobals() savedextralight = extralight; savedpos = ViewPos; savedangle = ViewAngle; - savedvisibility = R_GetVisibility(); + savedvisibility = swrenderer::R_GetVisibility(); savedcamera = camera; savedsector = viewsector; @@ -376,14 +376,14 @@ void PolyDrawSectorPortal::SaveGlobals() // Don't let gun flashes brighten the sky box ASkyViewpoint *sky = barrier_cast(Portal->mSkybox); extralight = 0; - R_SetVisibility(sky->args[0] * 0.25f); + swrenderer::R_SetVisibility(sky->args[0] * 0.25f); ViewPos = sky->InterpolatedPosition(r_TicFracF); ViewAngle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF); } else //if (Portal->mType == PORTS_STACKEDSECTORTHING || Portal->mType == PORTS_PORTAL || Portal->mType == PORTS_LINKEDPORTAL) { //extralight = pl->extralight; - //R_SetVisibility(pl->visibility); + //swrenderer::R_SetVisibility(pl->visibility); ViewPos.X += Portal->mDisplacement.X; ViewPos.Y += Portal->mDisplacement.Y; } @@ -404,7 +404,7 @@ void PolyDrawSectorPortal::RestoreGlobals() camera = savedcamera; viewsector = savedsector; ViewPos = savedpos; - R_SetVisibility(savedvisibility); + swrenderer::R_SetVisibility(savedvisibility); extralight = savedextralight; ViewAngle = savedangle; R_SetViewAngle(); diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp index c0a219c79..a19e0d40b 100644 --- a/src/r_poly_sky.cpp +++ b/src/r_poly_sky.cpp @@ -85,7 +85,7 @@ void PolySkyDome::RenderRow(PolyDrawArgs &args, int row) void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap) { uint32_t solid = skytex->GetSkyCapColor(bottomCap); - if (!r_swtruecolor) + if (!swrenderer::r_swtruecolor) solid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)]; args.vinput = &mVertices[mPrimStart[row]]; diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index eb1328b48..46c90adc2 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -119,7 +119,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla PolyDrawArgs args; args.uniforms.flags = 0; - if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) + if (fullbrightSprite || swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap) { args.uniforms.light = 256; args.uniforms.flags |= TriUniforms::fixed_light; @@ -228,7 +228,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla args.SetTexture(tex, thing->Translation, true); } - if (!r_swtruecolor) + if (!swrenderer::r_swtruecolor) { uint32_t r = (args.uniforms.color >> 16) & 0xff; uint32_t g = (args.uniforms.color >> 8) & 0xff; @@ -309,9 +309,9 @@ visstyle_t RenderPolySprite::GetSpriteVisStyle(AActor *thing, double z) } // get light level - if (fixedcolormap != nullptr) + if (swrenderer::fixedcolormap != nullptr) { // fixed map - visstyle.BaseColormap = fixedcolormap; + visstyle.BaseColormap = swrenderer::fixedcolormap; visstyle.ColormapNum = 0; } else @@ -320,10 +320,10 @@ visstyle_t RenderPolySprite::GetSpriteVisStyle(AActor *thing, double z) { mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate); } - if (fixedlightlev >= 0) + if (swrenderer::fixedlightlev >= 0) { visstyle.BaseColormap = mybasecolormap; - visstyle.ColormapNum = fixedlightlev >> COLORMAPSHIFT; + visstyle.ColormapNum = swrenderer::fixedlightlev >> COLORMAPSHIFT; } else if (!foggy && ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) { // full bright @@ -333,7 +333,7 @@ visstyle_t RenderPolySprite::GetSpriteVisStyle(AActor *thing, double z) else { // diminished light double minz = double((2048 * 4) / double(1 << 20)); - visstyle.ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(z, minz), spriteshade); + visstyle.ColormapNum = GETPALOOKUP(swrenderer::r_SpriteVisibility / MAX(z, minz), spriteshade); visstyle.BaseColormap = mybasecolormap; } } diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index a3398df2b..4b6e1c344 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -498,8 +498,8 @@ TriMatrix TriMatrix::viewToClip() float near = 5.0f; float far = 65536.0f; float width = (float)(FocalTangent * near); - float top = (float)(CenterY / InvZtoScale * near); - float bottom = (float)(top - viewheight / InvZtoScale * near); + float top = (float)(swrenderer::CenterY / swrenderer::InvZtoScale * near); + float bottom = (float)(top - viewheight / swrenderer::InvZtoScale * near); return frustum(-width, width, bottom, top, near, far); } diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 1c07ce5bd..46948310f 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -70,7 +70,7 @@ public: { textureWidth = texture->GetWidth(); textureHeight = texture->GetHeight(); - if (r_swtruecolor) + if (swrenderer::r_swtruecolor) texturePixels = (const uint8_t *)texture->GetPixelsBgra(); else texturePixels = texture->GetPixels(); @@ -84,7 +84,7 @@ public: FRemapTable *table = TranslationToTable(translationID); if (table != nullptr && !table->Inactive) { - if (r_swtruecolor) + if (swrenderer::r_swtruecolor) translation = (uint8_t*)table->Palette; else translation = table->Remap; diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index cd4d32077..4dd24887d 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -31,7 +31,7 @@ #include "r_poly_wall.h" #include "r_poly_decal.h" #include "r_poly.h" -#include "r_sky.h" // for skyflatnum +#include "r_sky.h" EXTERN_CVAR(Bool, r_drawmirrors) @@ -330,7 +330,7 @@ FTexture *RenderPolyWall::GetTexture() int RenderPolyWall::GetLightLevel() { - if (fixedlightlev >= 0 || fixedcolormap) + if (swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap) { return 255; } diff --git a/src/r_poly_wallsprite.cpp b/src/r_poly_wallsprite.cpp index 351e24e36..0521fb06e 100644 --- a/src/r_poly_wallsprite.cpp +++ b/src/r_poly_wallsprite.cpp @@ -99,7 +99,7 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const Vec4f &cli bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT)); PolyDrawArgs args; - if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap) + if (fullbrightSprite || swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap) { args.uniforms.light = 256; args.uniforms.flags = TriUniforms::fixed_light; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 175768aec..0e59ef0f7 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -56,12 +56,14 @@ #define WALLYREPEAT 8 - CVAR(Bool, r_np2, true, 0) +CVAR(Bool, r_fogboundary, true, 0) +CVAR(Bool, r_drawmirrors, true, 0) EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); +EXTERN_CVAR(Bool, r_mipmap) -//CVAR (Int, ty, 8, 0) -//CVAR (Int, tx, 8, 0) +namespace swrenderer +{ #define HEIGHTBITS 12 #define HEIGHTSHIFT (FRACBITS-HEIGHTBITS) @@ -142,16 +144,6 @@ void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat); static void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, bool mask); -//============================================================================= -// -// CVAR r_fogboundary -// -// If true, makes fog look more "real" by shading the walls separating two -// sectors with different fog. -//============================================================================= - -CVAR(Bool, r_fogboundary, true, 0) - inline bool IsFogBoundary (sector_t *front, sector_t *back) { return r_fogboundary && fixedcolormap == NULL && front->ColorMap->Fade && @@ -159,14 +151,6 @@ inline bool IsFogBoundary (sector_t *front, sector_t *back) (front->GetTexture(sector_t::ceiling) != skyflatnum || back->GetTexture(sector_t::ceiling) != skyflatnum); } -//============================================================================= -// -// CVAR r_drawmirrors -// -// Set to false to disable rendering of mirrors -//============================================================================= - -CVAR(Bool, r_drawmirrors, true, 0) // // R_RenderMaskedSegRange @@ -1065,7 +1049,6 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2) return; } -EXTERN_CVAR(Bool, r_mipmap) struct WallscanSampler { @@ -3162,3 +3145,5 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, done: WallC = savecoord; } + +} diff --git a/src/r_segs.h b/src/r_segs.h index 1fc428c96..7d34a78f4 100644 --- a/src/r_segs.h +++ b/src/r_segs.h @@ -23,6 +23,9 @@ #ifndef __R_SEGS_H__ #define __R_SEGS_H__ +namespace swrenderer +{ + struct drawseg_t; void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2); @@ -70,4 +73,6 @@ extern int CurrentPortalUniq; extern bool CurrentPortalInSkybox; extern TArray WallPortals; +} + #endif diff --git a/src/r_state.h b/src/r_state.h index b66ad57eb..cd4aee4be 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -80,7 +80,7 @@ extern int numgamesubsectors; extern AActor* camera; // [RH] camera instead of viewplayer extern sector_t* viewsector; // [RH] keep track of sector viewing from -extern angle_t xtoviewangle[MAXWIDTH+1]; +namespace swrenderer { extern angle_t xtoviewangle[MAXWIDTH+1]; } extern DAngle FieldOfView; int R_FindSkin (const char *name, int pclass); // [RH] Find a skin diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 0f30fc3df..56820e536 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -58,11 +58,18 @@ CUSTOM_CVAR(Bool, r_polyrenderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOI } } +namespace swrenderer +{ + void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio); void R_SetupColormap(player_t *); void R_SetupFreelook(); void R_InitRenderer(); +} + +using namespace swrenderer; + FSoftwareRenderer::FSoftwareRenderer() { } diff --git a/src/r_things.cpp b/src/r_things.cpp index 8f91b1740..659ad916a 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -66,6 +66,19 @@ #include "p_local.h" #include "p_maputl.h" +EXTERN_CVAR(Bool, st_scale) +EXTERN_CVAR(Bool, r_shadercolormaps) +EXTERN_CVAR(Int, r_drawfuzz) +EXTERN_CVAR(Bool, r_deathcamera); +EXTERN_CVAR(Bool, r_drawplayersprites) +EXTERN_CVAR(Bool, r_drawvoxels) + +CVAR(Bool, r_fullbrightignoresectorcolor, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR(Bool, r_splitsprites, true, CVAR_ARCHIVE) + +namespace swrenderer +{ + // [RH] A c-buffer. Used for keeping track of offscreen voxel spans. struct FCoverageBuffer @@ -96,12 +109,6 @@ extern float MaskedScaleY; #define BASEXCENTER (160) #define BASEYCENTER (100) -EXTERN_CVAR (Bool, st_scale) -EXTERN_CVAR(Bool, r_shadercolormaps) -EXTERN_CVAR(Int, r_drawfuzz) -EXTERN_CVAR(Bool, r_deathcamera); -CVAR(Bool, r_fullbrightignoresectorcolor, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); - // // Sprite rotation 0 is facing the viewer, // rotation 1 is one angle turn CLOCKWISE around the axis. @@ -133,8 +140,6 @@ FTexture *WallSpriteTile; short zeroarray[MAXWIDTH]; short screenheightarray[MAXWIDTH]; -EXTERN_CVAR (Bool, r_drawplayersprites) -EXTERN_CVAR (Bool, r_drawvoxels) // // INITIALIZATION FUNCTIONS @@ -1903,8 +1908,6 @@ static int sd_comparex (const void *arg1, const void *arg2) return (*(drawseg_t **)arg2)->x2 - (*(drawseg_t **)arg1)->x2; } -CVAR (Bool, r_splitsprites, true, CVAR_ARCHIVE) - // Split up vissprites that intersect drawsegs void R_SplitVisSprites () { @@ -3446,3 +3449,5 @@ void R_CheckOffscreenBuffer(int width, int height, bool spansonly) OffscreenBufferWidth = width; OffscreenBufferHeight = height; } + +} diff --git a/src/r_things.h b/src/r_things.h index e35489892..0e036d633 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -25,6 +25,12 @@ #include "r_bsp.h" +struct particle_t; +struct FVoxel; + +namespace swrenderer +{ + // A vissprite_t is a thing // that will be drawn during a refresh. // I.e. a sprite object that is partly visible. @@ -94,8 +100,6 @@ struct vissprite_t vissprite_t() {} }; -struct particle_t; - extern void(*R_DrawParticle)(vissprite_t *); void R_DrawParticle_C (vissprite_t *); void R_DrawParticle_rgba (vissprite_t *); @@ -148,5 +152,6 @@ void R_DrawVoxel(const FVector3 &viewpos, FAngle viewangle, void R_ClipVisSprite (vissprite_t *vis, int xl, int xh); +} #endif diff --git a/src/r_thread.h b/src/r_thread.h index 3271d8050..d80fd0203 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -99,7 +99,7 @@ protected: void DetectRangeError(uint32_t *&dest, int &dest_y, int &count) { #if defined(_MSC_VER) && defined(_DEBUG) - if (dest_y < 0 || count < 0 || dest_y + count > dc_destheight) + if (dest_y < 0 || count < 0 || dest_y + count > swrenderer::dc_destheight) __debugbreak(); // Buffer overrun detected! #endif @@ -107,24 +107,26 @@ protected: { count += dest_y; dest_y = 0; - dest = (uint32_t*)dc_destorg; + dest = (uint32_t*)swrenderer::dc_destorg; } - else if (dest_y >= dc_destheight) + else if (dest_y >= swrenderer::dc_destheight) { dest_y = 0; count = 0; } if (count < 0 || count > MAXHEIGHT) count = 0; - if (dest_y + count >= dc_destheight) - count = dc_destheight - dest_y; + if (dest_y + count >= swrenderer::dc_destheight) + count = swrenderer::dc_destheight - dest_y; } public: DrawerCommand() { - _dest_y = static_cast((dc_dest - dc_destorg) / (dc_pitch * 4)); + _dest_y = static_cast((swrenderer::dc_dest - swrenderer::dc_destorg) / (swrenderer::dc_pitch * 4)); } + + virtual ~DrawerCommand() { } virtual void Execute(DrawerThread *thread) = 0; virtual FString DebugInfo() = 0; diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 05cfdd0dc..985238071 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -133,6 +133,8 @@ void DCanvas::DrawTexture (FTexture *img, double x, double y, int tags_first, .. void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) { #ifndef NO_SWRENDER + using namespace swrenderer; + static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH]; const BYTE *translation = NULL; @@ -1026,7 +1028,7 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) { uint32_t *spot = (uint32_t*)GetBuffer() + oldyyshifted + xx; - uint32_t fg = LightBgra::shade_pal_index_simple(basecolor, LightBgra::calc_light_multiplier(0)); + uint32_t fg = swrenderer::LightBgra::shade_pal_index_simple(basecolor, swrenderer::LightBgra::calc_light_multiplier(0)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -1359,6 +1361,8 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, FDynamicColormap *colormap, int lightlevel, int bottomclip) { #ifndef NO_SWRENDER + using namespace swrenderer; + // Use an equation similar to player sprites to determine shade fixed_t shade = LIGHT2SHADE(lightlevel) - 12*FRACUNIT; float topy, boty, leftx, rightx; diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 3ede15b39..5b8670088 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -1405,17 +1405,16 @@ void D3DFB::Draw3DPart(bool copy3d) D3DCOLOR color0, color1; if (Accel2D) { - if (realfixedcolormap == NULL) + auto &map = swrenderer::realfixedcolormap; + if (map == NULL) { color0 = 0; color1 = 0xFFFFFFF; } else { - color0 = D3DCOLOR_COLORVALUE(realfixedcolormap->ColorizeStart[0]/2, - realfixedcolormap->ColorizeStart[1]/2, realfixedcolormap->ColorizeStart[2]/2, 0); - color1 = D3DCOLOR_COLORVALUE(realfixedcolormap->ColorizeEnd[0]/2, - realfixedcolormap->ColorizeEnd[1]/2, realfixedcolormap->ColorizeEnd[2]/2, 1); + color0 = D3DCOLOR_COLORVALUE(map->ColorizeStart[0]/2, map->ColorizeStart[1]/2, map->ColorizeStart[2]/2, 0); + color1 = D3DCOLOR_COLORVALUE(map->ColorizeEnd[0]/2, map->ColorizeEnd[1]/2, map->ColorizeEnd[2]/2, 1); if (IsBgra()) SetPixelShader(Shaders[SHADER_SpecialColormap]); else From 3890c80b1a1031b2a5b1f90d3b31e428081f6f15 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 1 Dec 2016 08:59:47 +0100 Subject: [PATCH 1319/1509] Fix compile error for msvc --- src/r_main.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_main.h b/src/r_main.h index f4d0a144a..5908667c8 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -33,11 +33,11 @@ extern double ViewSin; extern int viewwindowx; extern int viewwindowy; +typedef BYTE lighttable_t; // This could be wider for >8 bit display. + namespace swrenderer { -typedef BYTE lighttable_t; // This could be wider for >8 bit display. - // // POV related. // From 2203da0c9360611060ee495966ebf29b7479caf2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 1 Dec 2016 09:00:24 +0100 Subject: [PATCH 1320/1509] Minor simplification of the light calculation --- tools/drawergen/fixedfunction/drawtrianglecodegen.cpp | 9 +++++---- tools/drawergen/fixedfunction/drawtrianglecodegen.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index 4184dc536..fd4809e5d 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -145,6 +145,8 @@ void DrawTriangleCodegen::Setup() gradWX = gradWX * (float)q; for (int i = 0; i < TriVertex::NumVarying; i++) gradVaryingX[i] = gradVaryingX[i] * (float)q; + + shade = 64.0f - (SSAFloat(light * 255 / 256) + 12.0f) * 32.0f / 128.0f; } SSAFloat DrawTriangleCodegen::gradx(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2) @@ -244,13 +246,12 @@ void DrawTriangleCodegen::LoopBlockX() SSAFloat globVis = SSAFloat(1706.0f); SSAFloat vis = globVis * posx_w; - SSAFloat shade = 64.0f - (SSAFloat(light * 255 / 256) + 12.0f) * 32.0f / 128.0f; - SSAFloat lightscale = SSAFloat::clamp((shade - SSAFloat::MIN(SSAFloat(24.0f), vis)) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)); - SSAInt diminishedlight = SSAInt(SSAFloat::clamp((1.0f - lightscale) * 256.0f + 0.5f, SSAFloat(0.0f), SSAFloat(256.0f)), false); + SSAInt lightscale = SSAInt(SSAFloat::clamp((shade - SSAFloat::MIN(SSAFloat(24.0f), vis)) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * 256.0f, true); + SSAInt diminishedlight = 256 - lightscale; if (!truecolor) { - SSAInt diminishedindex = SSAInt(lightscale * 32.0f, false); + SSAInt diminishedindex = lightscale / 8; SSAInt lightindex = SSAInt::MIN((256 - light) * 32 / 256, SSAInt(31)); SSAInt colormapindex = is_fixed_light.select(lightindex, diminishedindex); currentcolormap = Colormaps[colormapindex << 8]; diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.h b/tools/drawergen/fixedfunction/drawtrianglecodegen.h index bc894f1a2..584260a4d 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.h +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.h @@ -136,6 +136,7 @@ private: SSAInt C1, C2, C3; SSAFloat gradWX, gradWY; SSAFloat gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying]; + SSAFloat shade; SSAInt x, y; SSAInt x0, x1, y0, y1; From c89e023bd5bd6b1ec4f2462c7fd50c5e476c20c0 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 1 Dec 2016 09:31:43 +0100 Subject: [PATCH 1321/1509] Remove unused left/top clip --- .../fixedfunction/drawtrianglecodegen.cpp | 14 ++++++-------- .../drawergen/fixedfunction/drawtrianglecodegen.h | 2 -- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index fd4809e5d..69aacbbef 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -81,9 +81,9 @@ void DrawTriangleCodegen::Setup() FDY31 = DY31 << 4; // Bounding rectangle - minx = SSAInt::MAX((SSAInt::MIN(SSAInt::MIN(X1, X2), X3) + 0xF).ashr(4), clipleft); + minx = SSAInt::MAX((SSAInt::MIN(SSAInt::MIN(X1, X2), X3) + 0xF).ashr(4), SSAInt(0)); maxx = SSAInt::MIN((SSAInt::MAX(SSAInt::MAX(X1, X2), X3) + 0xF).ashr(4), clipright - 1); - miny = SSAInt::MAX((SSAInt::MIN(SSAInt::MIN(Y1, Y2), Y3) + 0xF).ashr(4), cliptop); + miny = SSAInt::MAX((SSAInt::MIN(SSAInt::MIN(Y1, Y2), Y3) + 0xF).ashr(4), SSAInt(0)); maxy = SSAInt::MIN((SSAInt::MAX(SSAInt::MAX(Y1, Y2), Y3) + 0xF).ashr(4), clipbottom - 1); SSAIfBlock if0; @@ -242,7 +242,7 @@ void DrawTriangleCodegen::LoopBlockX() branch.if_block(!(a == SSAInt(0) || b == SSAInt(0) || c == SSAInt(0))); // Check if block needs clipping - SSABool clipneeded = x < clipleft || (x + q) > clipright || y < cliptop || (y + q) > clipbottom; + SSABool clipneeded = (x + q) > clipright || (y + q) > clipbottom; SSAFloat globVis = SSAFloat(1706.0f); SSAFloat vis = globVis * posx_w; @@ -253,12 +253,12 @@ void DrawTriangleCodegen::LoopBlockX() { SSAInt diminishedindex = lightscale / 8; SSAInt lightindex = SSAInt::MIN((256 - light) * 32 / 256, SSAInt(31)); - SSAInt colormapindex = is_fixed_light.select(lightindex, diminishedindex); + SSAInt colormapindex = (!is_fixed_light).select(diminishedindex, lightindex); currentcolormap = Colormaps[colormapindex << 8]; } else { - currentlight = is_fixed_light.select(light, diminishedlight); + currentlight = (!is_fixed_light).select(diminishedlight, light); } SetStencilBlock(x / 8 + y / 8 * stencilPitch); @@ -469,7 +469,7 @@ void DrawTriangleCodegen::LoopPartialBlock() AffineVaryingPosX[i] = stack_AffineVaryingPosX[i].load(); loopx.loop_block(ix < SSAInt(q), q); { - SSABool visible = (ix + x >= clipleft) && (ix + x < clipright) && (iy + y >= cliptop) && (iy + y < clipbottom); + SSABool visible = (ix + x < clipright) && (iy + y < clipbottom); SSABool covered = CX1 > SSAInt(0) && CX2 > SSAInt(0) && CX3 > SSAInt(0) && visible; if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) @@ -815,9 +815,7 @@ void DrawTriangleCodegen::LoadArgs(SSAValue args, SSAValue thread_data) v1 = LoadTriVertex(args[0][2].load(true)); v2 = LoadTriVertex(args[0][3].load(true)); v3 = LoadTriVertex(args[0][4].load(true)); - clipleft = SSAInt(0);// args[0][5].load(true); clipright = args[0][6].load(true); - cliptop = SSAInt(0);// args[0][7].load(true); clipbottom = args[0][8].load(true); texturePixels = args[0][9].load(true); textureWidth = args[0][10].load(true); diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.h b/tools/drawergen/fixedfunction/drawtrianglecodegen.h index 584260a4d..31df77b95 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.h +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.h @@ -93,9 +93,7 @@ private: SSATriVertex v1; SSATriVertex v2; SSATriVertex v3; - SSAInt clipleft; SSAInt clipright; - SSAInt cliptop; SSAInt clipbottom; SSAUBytePtr texturePixels; SSAInt textureWidth; From e3b3b7a4ce39587ae595c38fbe5fe225c0c311fb Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 1 Dec 2016 10:52:53 +0100 Subject: [PATCH 1322/1509] Masked store experiment (which turned out to be much slower) --- .../fixedfunction/drawtrianglecodegen.cpp | 125 ++++++++++++++++++ tools/drawergen/ssa/ssa_float_ptr.cpp | 2 +- tools/drawergen/ssa/ssa_int_ptr.cpp | 22 ++- tools/drawergen/ssa/ssa_int_ptr.h | 3 + tools/drawergen/ssa/ssa_ubyte_ptr.cpp | 52 +++++++- tools/drawergen/ssa/ssa_ubyte_ptr.h | 4 + tools/drawergen/ssa/ssa_vec4f_ptr.cpp | 2 +- 7 files changed, 206 insertions(+), 4 deletions(-) diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index 69aacbbef..e29e2a122 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -541,6 +541,131 @@ void DrawTriangleCodegen::LoopPartialBlock() loopy.end_block(); } +#if 0 +void DrawTriangleCodegen::LoopMaskedStoreBlock() +{ + if (variant == TriDrawVariant::Stencil) + { + } + else if (variant == TriDrawVariant::StencilClose) + { + } + else + { + int pixelsize = truecolor ? 4 : 1; + + AffineW = posx_w; + for (int i = 0; i < TriVertex::NumVarying; i++) + AffineVaryingPosY[i] = posx_varying[i]; + + SSAInt CY1 = C1 + DX12 * y0 - DY12 * x0; + SSAInt CY2 = C2 + DX23 * y0 - DY23 * x0; + SSAInt CY3 = C3 + DX31 * y0 - DY31 * x0; + + for (int iy = 0; iy < q; iy++) + { + SSAUBytePtr buffer = dest[(x + iy * pitch) * pixelsize]; + SSAIntPtr subsectorbuffer = subsectorGBuffer[x + iy * pitch]; + + SetupAffineBlock(); + + SSAInt CX1 = CY1; + SSAInt CX2 = CY2; + SSAInt CX3 = CY3; + + for (int ix = 0; ix < q; ix += 4) + { + SSABool covered[4]; + for (int maskindex = 0; maskindex < 4; maskindex++) + { + covered[maskindex] = CX1 > SSAInt(0) && CX2 > SSAInt(0) && CX3 > SSAInt(0); + + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + { + auto xx = SSAInt(ix + maskindex); + auto yy = SSAInt(iy); + covered[maskindex] = covered[maskindex] && SSABool::compare_uge(StencilGet(xx, yy), stencilTestValue) && subsectorbuffer[ix + maskindex].load(true) >= subsectorDepth; + } + else if (variant == TriDrawVariant::StencilClose) + { + auto xx = SSAInt(ix + maskindex); + auto yy = SSAInt(iy); + covered[maskindex] = covered[maskindex] && SSABool::compare_uge(StencilGet(xx, yy), stencilTestValue); + } + else + { + auto xx = SSAInt(ix + maskindex); + auto yy = SSAInt(iy); + covered[maskindex] = covered[maskindex] && StencilGet(xx, yy) == stencilTestValue; + } + + CX1 = CX1 - FDY12; + CX2 = CX2 - FDY23; + CX3 = CX3 - FDY31; + } + + SSAUBytePtr buf = buffer[ix * pixelsize]; + if (truecolor) + { + SSAVec16ub pixels16 = buf.load_unaligned_vec16ub(false); + SSAVec8s pixels8hi = SSAVec8s::extendhi(pixels16); + SSAVec8s pixels8lo = SSAVec8s::extendlo(pixels16); + SSAVec4i pixels[4] = + { + SSAVec4i::extendlo(pixels8lo), + SSAVec4i::extendhi(pixels8lo), + SSAVec4i::extendlo(pixels8hi), + SSAVec4i::extendhi(pixels8hi) + }; + + for (int sse = 0; sse < 4; sse++) + { + pixels[sse] = ProcessPixel32(pixels[sse], AffineVaryingPosX); + + for (int i = 0; i < TriVertex::NumVarying; i++) + AffineVaryingPosX[i] = AffineVaryingPosX[i] + AffineVaryingStepX[i]; + } + + buf.store_masked_vec16ub(SSAVec16ub(SSAVec8s(pixels[0], pixels[1]), SSAVec8s(pixels[2], pixels[3])), covered); + } + else + { + SSAVec4i pixelsvec = buf.load_vec4ub(false); + SSAInt pixels[4] = + { + pixelsvec[0], + pixelsvec[1], + pixelsvec[2], + pixelsvec[3] + }; + + for (int sse = 0; sse < 4; sse++) + { + pixels[sse] = ProcessPixel8(pixels[sse], AffineVaryingPosX); + + for (int i = 0; i < TriVertex::NumVarying; i++) + AffineVaryingPosX[i] = AffineVaryingPosX[i] + AffineVaryingStepX[i]; + } + + buf.store_masked_vec4ub(SSAVec4i(pixels[0], pixels[1], pixels[2], pixels[3]), covered); + } + + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) + subsectorbuffer[ix].store_masked_vec4i(SSAVec4i(subsectorDepth), covered); + } + + AffineW = AffineW + gradWY; + for (int i = 0; i < TriVertex::NumVarying; i++) + AffineVaryingPosY[i] = AffineVaryingPosY[i] + gradVaryingY[i]; + + CY1 = CY1 + FDX12; + CY2 = CY2 + FDX23; + CY3 = CY3 + FDX31; + } + } +} +#endif + SSAVec4i DrawTriangleCodegen::TranslateSample32(SSAInt uvoffset) { if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) diff --git a/tools/drawergen/ssa/ssa_float_ptr.cpp b/tools/drawergen/ssa/ssa_float_ptr.cpp index 50507884b..731fbbef8 100644 --- a/tools/drawergen/ssa/ssa_float_ptr.cpp +++ b/tools/drawergen/ssa/ssa_float_ptr.cpp @@ -86,6 +86,6 @@ void SSAFloatPtr::store_vec4f(const SSAVec4f &new_value) void SSAFloatPtr::store_unaligned_vec4f(const SSAVec4f &new_value) { llvm::PointerType *m4xfloattypeptr = llvm::VectorType::get(llvm::Type::getFloatTy(SSAScope::context()), 4)->getPointerTo(); - auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), 1); + auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xfloattypeptr, SSAScope::hint()), 4); inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } diff --git a/tools/drawergen/ssa/ssa_int_ptr.cpp b/tools/drawergen/ssa/ssa_int_ptr.cpp index 9b8b44501..5f60f7358 100644 --- a/tools/drawergen/ssa/ssa_int_ptr.cpp +++ b/tools/drawergen/ssa/ssa_int_ptr.cpp @@ -23,6 +23,7 @@ #include "precomp.h" #include "ssa_int_ptr.h" #include "ssa_scope.h" +#include "ssa_bool.h" SSAIntPtr::SSAIntPtr() : v(0) @@ -86,6 +87,25 @@ void SSAIntPtr::store_vec4i(const SSAVec4i &new_value) void SSAIntPtr::store_unaligned_vec4i(const SSAVec4i &new_value) { llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); - auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 1); + auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 4); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); +} + +void SSAIntPtr::store_masked_vec4i(const SSAVec4i &new_value, SSABool mask[4]) +{ + // Create mask vector + std::vector maskconstants; + maskconstants.resize(4, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(1, 0, false))); + llvm::Value *maskValue = llvm::ConstantVector::get(maskconstants); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) + for (int i = 0; i < 4; i++) + maskValue = SSAScope::builder().CreateInsertElement(maskValue, mask[i].v, SSAInt(i).v, SSAScope::hint()); +#else + for (int i = 0; i < 4; i++) + maskValue = SSAScope::builder().CreateInsertElement(maskValue, mask[i].v, (uint64_t)i, SSAScope::hint()); +#endif + + llvm::PointerType *m4xint32typeptr = llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4)->getPointerTo(); + auto inst = SSAScope::builder().CreateMaskedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m4xint32typeptr, SSAScope::hint()), 1, maskValue); inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } diff --git a/tools/drawergen/ssa/ssa_int_ptr.h b/tools/drawergen/ssa/ssa_int_ptr.h index 04075c15e..da6ecf168 100644 --- a/tools/drawergen/ssa/ssa_int_ptr.h +++ b/tools/drawergen/ssa/ssa_int_ptr.h @@ -29,6 +29,8 @@ namespace llvm { class Value; } namespace llvm { class Type; } +class SSABool; + class SSAIntPtr { public: @@ -44,6 +46,7 @@ public: void store(const SSAInt &new_value); void store_vec4i(const SSAVec4i &new_value); void store_unaligned_vec4i(const SSAVec4i &new_value); + void store_masked_vec4i(const SSAVec4i &new_value, SSABool mask[4]); llvm::Value *v; }; diff --git a/tools/drawergen/ssa/ssa_ubyte_ptr.cpp b/tools/drawergen/ssa/ssa_ubyte_ptr.cpp index c6b835a1c..bde0b5b64 100644 --- a/tools/drawergen/ssa/ssa_ubyte_ptr.cpp +++ b/tools/drawergen/ssa/ssa_ubyte_ptr.cpp @@ -23,6 +23,7 @@ #include "precomp.h" #include "ssa_ubyte_ptr.h" #include "ssa_scope.h" +#include "ssa_bool.h" SSAUBytePtr::SSAUBytePtr() : v(0) @@ -104,6 +105,37 @@ void SSAUBytePtr::store_vec4ub(const SSAVec4i &new_value) inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } +void SSAUBytePtr::store_masked_vec4ub(const SSAVec4i &new_value, SSABool mask[4]) +{ + // Store using saturate: + SSAVec8s v8s(new_value, new_value); + SSAVec16ub v16ub(v8s, v8s); + + // Create mask vector + std::vector maskconstants; + maskconstants.resize(4, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(1, 0, false))); + llvm::Value *maskValue = llvm::ConstantVector::get(maskconstants); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) + for (int i = 0; i < 4; i++) + maskValue = SSAScope::builder().CreateInsertElement(maskValue, mask[i].v, SSAInt(i).v, SSAScope::hint()); +#else + for (int i = 0; i < 4; i++) + maskValue = SSAScope::builder().CreateInsertElement(maskValue, mask[i].v, (uint64_t)i, SSAScope::hint()); +#endif + + llvm::Type *m16xint8type = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16); + llvm::PointerType *m4xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 4)->getPointerTo(); + std::vector constants; + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 0))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 1))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 2))); + constants.push_back(llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, 3))); + llvm::Value *shufflemask = llvm::ConstantVector::get(constants); + llvm::Value *val_vector = SSAScope::builder().CreateShuffleVector(v16ub.v, llvm::UndefValue::get(m16xint8type), shufflemask, SSAScope::hint()); + llvm::CallInst *inst = SSAScope::builder().CreateMaskedStore(val_vector, SSAScope::builder().CreateBitCast(v, m4xint8typeptr, SSAScope::hint()), 1, maskValue); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); +} + void SSAUBytePtr::store_vec16ub(const SSAVec16ub &new_value) { llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); @@ -118,6 +150,24 @@ void SSAUBytePtr::store_vec16ub(const SSAVec16ub &new_value) void SSAUBytePtr::store_unaligned_vec16ub(const SSAVec16ub &new_value) { llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); - llvm::StoreInst *inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), 1); + llvm::StoreInst *inst = SSAScope::builder().CreateAlignedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), 4); + inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); +} + +void SSAUBytePtr::store_masked_vec16ub(const SSAVec16ub &new_value, SSABool mask[4]) +{ + std::vector constants; + constants.resize(16, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(1, 0, false))); + llvm::Value *maskValue = llvm::ConstantVector::get(constants); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) + for (int i = 0; i < 16; i++) + maskValue = SSAScope::builder().CreateInsertElement(maskValue, mask[i / 4].v, SSAInt(i).v, SSAScope::hint()); +#else + for (int i = 0; i < 16; i++) + maskValue = SSAScope::builder().CreateInsertElement(maskValue, mask[i / 4].v, (uint64_t)i, SSAScope::hint()); +#endif + + llvm::PointerType *m16xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 16)->getPointerTo(); + llvm::CallInst *inst = SSAScope::builder().CreateMaskedStore(new_value.v, SSAScope::builder().CreateBitCast(v, m16xint8typeptr, SSAScope::hint()), 1, maskValue); inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } diff --git a/tools/drawergen/ssa/ssa_ubyte_ptr.h b/tools/drawergen/ssa/ssa_ubyte_ptr.h index b4567597e..ba4fb5397 100644 --- a/tools/drawergen/ssa/ssa_ubyte_ptr.h +++ b/tools/drawergen/ssa/ssa_ubyte_ptr.h @@ -31,6 +31,8 @@ namespace llvm { class Value; } namespace llvm { class Type; } +class SSABool; + class SSAUBytePtr { public: @@ -46,8 +48,10 @@ public: SSAVec16ub load_unaligned_vec16ub(bool constantScopeDomain) const; void store(const SSAUByte &new_value); void store_vec4ub(const SSAVec4i &new_value); + void store_masked_vec4ub(const SSAVec4i &new_value, SSABool mask[4]); void store_vec16ub(const SSAVec16ub &new_value); void store_unaligned_vec16ub(const SSAVec16ub &new_value); + void store_masked_vec16ub(const SSAVec16ub &new_value, SSABool mask[4]); llvm::Value *v; }; diff --git a/tools/drawergen/ssa/ssa_vec4f_ptr.cpp b/tools/drawergen/ssa/ssa_vec4f_ptr.cpp index 8cdee930d..866331f84 100644 --- a/tools/drawergen/ssa/ssa_vec4f_ptr.cpp +++ b/tools/drawergen/ssa/ssa_vec4f_ptr.cpp @@ -68,6 +68,6 @@ void SSAVec4fPtr::store(const SSAVec4f &new_value) void SSAVec4fPtr::store_unaligned(const SSAVec4f &new_value) { - auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, v, 1, false); + auto inst = SSAScope::builder().CreateAlignedStore(new_value.v, v, 4, false); inst->setMetadata(llvm::LLVMContext::MD_noalias, SSAScope::constant_scope_list()); } From 06362385d6eed88f69735734082fd55e12355c99 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 1 Dec 2016 11:21:14 +0100 Subject: [PATCH 1323/1509] Improve performance by 30% from using a better stencil block rejection test --- .../fixedfunction/drawtrianglecodegen.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index e29e2a122..772df0f7e 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -236,10 +236,24 @@ void DrawTriangleCodegen::LoopBlockX() SSABool c01 = C3 + DX31 * y1 - DY31 * x0 > SSAInt(0); SSABool c11 = C3 + DX31 * y1 - DY31 * x1 > SSAInt(0); SSAInt c = (c00.zext_int() << 0) | (c10.zext_int() << 1) | (c01.zext_int() << 2) | (c11.zext_int() << 3); - + // Skip block when outside an edge + SSABool process_block = !(a == SSAInt(0) || b == SSAInt(0) || c == SSAInt(0)); + + SetStencilBlock(x / 8 + y / 8 * stencilPitch); + + // Stencil test the whole block, if possible + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector || variant == TriDrawVariant::StencilClose) + { + process_block = process_block && (!StencilIsSingleValue() || SSABool::compare_uge(StencilGetSingle(), stencilTestValue)); + } + else + { + process_block = process_block && (!StencilIsSingleValue() || StencilGetSingle() == stencilTestValue); + } + SSAIfBlock branch; - branch.if_block(!(a == SSAInt(0) || b == SSAInt(0) || c == SSAInt(0))); + branch.if_block(process_block); // Check if block needs clipping SSABool clipneeded = (x + q) > clipright || (y + q) > clipbottom; @@ -261,8 +275,6 @@ void DrawTriangleCodegen::LoopBlockX() currentlight = (!is_fixed_light).select(diminishedlight, light); } - SetStencilBlock(x / 8 + y / 8 * stencilPitch); - SSABool covered = a == SSAInt(0xF) && b == SSAInt(0xF) && c == SSAInt(0xF) && !clipneeded && StencilIsSingleValue(); // Accept whole block when totally covered @@ -304,16 +316,6 @@ void DrawTriangleCodegen::SetupAffineBlock() void DrawTriangleCodegen::LoopFullBlock() { - SSAIfBlock branch_stenciltest; - if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector || variant == TriDrawVariant::StencilClose) - { - branch_stenciltest.if_block(SSABool::compare_uge(StencilGetSingle(), stencilTestValue)); - } - else - { - branch_stenciltest.if_block(StencilGetSingle() == stencilTestValue); - } - if (variant == TriDrawVariant::Stencil) { StencilClear(stencilWriteValue); @@ -418,8 +420,6 @@ void DrawTriangleCodegen::LoopFullBlock() AffineVaryingPosY[i] = AffineVaryingPosY[i] + gradVaryingY[i]; } } - - branch_stenciltest.end_block(); } void DrawTriangleCodegen::LoopPartialBlock() From fc16f6bbbc13acb888c40043ccded712d4069f9a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 1 Dec 2016 13:31:42 +0100 Subject: [PATCH 1324/1509] Further improve early stencil rejection test by restoring stencil blocks to a single value if possible --- .../fixedfunction/drawtrianglecodegen.cpp | 126 ++++++++++++------ .../fixedfunction/drawtrianglecodegen.h | 6 +- tools/drawergen/ssa/ssa_bool.cpp | 5 +- tools/drawergen/ssa/ssa_bool.h | 2 +- 4 files changed, 94 insertions(+), 45 deletions(-) diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index 772df0f7e..df8690821 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -285,7 +285,31 @@ void DrawTriangleCodegen::LoopBlockX() } branch_covered.else_block(); { - LoopPartialBlock(); + SSAIfBlock branch_covered_stencil; + branch_covered_stencil.if_block(StencilIsSingleValue()); + { + SSABool stenciltestpass; + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector || variant == TriDrawVariant::StencilClose) + { + stenciltestpass = SSABool::compare_uge(StencilGetSingle(), stencilTestValue); + } + else + { + stenciltestpass = StencilGetSingle() == stencilTestValue; + } + + SSAIfBlock branch_stenciltestpass; + branch_stenciltestpass.if_block(stenciltestpass); + { + LoopPartialBlock(true); + } + branch_stenciltestpass.end_block(); + } + branch_covered_stencil.else_block(); + { + LoopPartialBlock(false); + } + branch_covered_stencil.end_block(); } branch_covered.end_block(); @@ -422,10 +446,26 @@ void DrawTriangleCodegen::LoopFullBlock() } } -void DrawTriangleCodegen::LoopPartialBlock() +void DrawTriangleCodegen::LoopPartialBlock(bool isSingleStencilValue) { int pixelsize = truecolor ? 4 : 1; + if (variant == TriDrawVariant::Stencil || variant == TriDrawVariant::StencilClose) + { + if (isSingleStencilValue) + { + SSAInt stencilMask = StencilBlockMask.load(false); + SSAUByte val0 = stencilMask.trunc_ubyte(); + for (int i = 0; i < 8 * 8; i++) + StencilBlock[i].store(val0); + StencilBlockMask.store(SSAInt(0)); + } + + SSAUByte lastStencilValue = StencilBlock[0].load(false); + stack_stencilblock_restored.store(SSABool(true)); + stack_stencilblock_lastval.store(lastStencilValue); + } + stack_CY1.store(C1 + DX12 * y0 - DY12 * x0); stack_CY2.store(C2 + DX23 * y0 - DY23 * x0); stack_CY3.store(C3 + DX31 * y0 - DY31 * x0); @@ -461,6 +501,13 @@ void DrawTriangleCodegen::LoopPartialBlock() stack_ix.store(SSAInt(0)); SSAForBlock loopx; + SSABool stencilblock_restored; + SSAUByte lastStencilValue; + if (variant == TriDrawVariant::Stencil || variant == TriDrawVariant::StencilClose) + { + stencilblock_restored = stack_stencilblock_restored.load(); + lastStencilValue = stack_stencilblock_lastval.load(); + } SSAInt ix = stack_ix.load(); SSAInt CX1 = stack_CX1.load(); SSAInt CX2 = stack_CX2.load(); @@ -472,17 +519,26 @@ void DrawTriangleCodegen::LoopPartialBlock() SSABool visible = (ix + x < clipright) && (iy + y < clipbottom); SSABool covered = CX1 > SSAInt(0) && CX2 > SSAInt(0) && CX3 > SSAInt(0) && visible; - if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + if (!isSingleStencilValue) { - covered = covered && SSABool::compare_uge(StencilGet(ix, iy), stencilTestValue) && subsectorbuffer[ix].load(true) >= subsectorDepth; + SSAUByte stencilValue = StencilBlock[ix + iy * 8].load(false); + + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + { + covered = covered && SSABool::compare_uge(stencilValue, stencilTestValue) && subsectorbuffer[ix].load(true) >= subsectorDepth; + } + else if (variant == TriDrawVariant::StencilClose) + { + covered = covered && SSABool::compare_uge(stencilValue, stencilTestValue); + } + else + { + covered = covered && stencilValue == stencilTestValue; + } } - else if (variant == TriDrawVariant::StencilClose) + else if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) { - covered = covered && SSABool::compare_uge(StencilGet(ix, iy), stencilTestValue); - } - else - { - covered = covered && StencilGet(ix, iy) == stencilTestValue; + covered = covered && subsectorbuffer[ix].load(true) >= subsectorDepth; } SSAIfBlock branch; @@ -490,11 +546,11 @@ void DrawTriangleCodegen::LoopPartialBlock() { if (variant == TriDrawVariant::Stencil) { - StencilSet(ix, iy, stencilWriteValue); + StencilBlock[ix + iy * 8].store(stencilWriteValue); } else if (variant == TriDrawVariant::StencilClose) { - StencilSet(ix, iy, stencilWriteValue); + StencilBlock[ix + iy * 8].store(stencilWriteValue); subsectorbuffer[ix].store(subsectorDepth); } else @@ -518,6 +574,13 @@ void DrawTriangleCodegen::LoopPartialBlock() } branch.end_block(); + if (variant == TriDrawVariant::Stencil || variant == TriDrawVariant::StencilClose) + { + SSAUByte newStencilValue = StencilBlock[ix + iy * 8].load(false); + stack_stencilblock_restored.store(stencilblock_restored && newStencilValue == lastStencilValue); + stack_stencilblock_lastval.store(newStencilValue); + } + for (int i = 0; i < TriVertex::NumVarying; i++) stack_AffineVaryingPosX[i].store(AffineVaryingPosX[i] + AffineVaryingStepX[i]); @@ -539,6 +602,18 @@ void DrawTriangleCodegen::LoopPartialBlock() stack_iy.store(iy + 1); } loopy.end_block(); + + if (variant == TriDrawVariant::Stencil || variant == TriDrawVariant::StencilClose) + { + SSAIfBlock branch; + SSABool restored = stack_stencilblock_restored.load(); + branch.if_block(restored); + { + SSAUByte lastStencilValue = stack_stencilblock_lastval.load(); + StencilClear(lastStencilValue); + } + branch.end_block(); + } } #if 0 @@ -891,33 +966,6 @@ void DrawTriangleCodegen::SetStencilBlock(SSAInt block) StencilBlockMask = stencilMasks[block]; } -void DrawTriangleCodegen::StencilSet(SSAInt x, SSAInt y, SSAUByte value) -{ - SSAInt mask = StencilBlockMask.load(false); - - SSAIfBlock branchNeedsUpdate; - branchNeedsUpdate.if_block(!(mask == (SSAInt(0xffffff00) | value.zext_int()))); - - SSAIfBlock branchFirstSet; - branchFirstSet.if_block((mask & SSAInt(0xffffff00)) == SSAInt(0xffffff00)); - { - SSAUByte val0 = mask.trunc_ubyte(); - for (int i = 0; i < 8 * 8; i++) - StencilBlock[i].store(val0); - StencilBlockMask.store(SSAInt(0)); - } - branchFirstSet.end_block(); - - StencilBlock[x + y * 8].store(value); - - branchNeedsUpdate.end_block(); -} - -SSAUByte DrawTriangleCodegen::StencilGet(SSAInt x, SSAInt y) -{ - return StencilIsSingleValue().select(StencilBlockMask.load(false).trunc_ubyte(), StencilBlock[x + y * 8].load(false)); -} - SSAUByte DrawTriangleCodegen::StencilGetSingle() { return StencilBlockMask.load(false).trunc_ubyte(); diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.h b/tools/drawergen/fixedfunction/drawtrianglecodegen.h index 31df77b95..0559efd23 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.h +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.h @@ -44,7 +44,7 @@ private: void LoopBlockY(); void LoopBlockX(); void LoopFullBlock(); - void LoopPartialBlock(); + void LoopPartialBlock(bool isSingleStencilValue); void SetupAffineBlock(); SSAVec4i ProcessPixel32(SSAVec4i bg, SSAInt *varying); @@ -59,9 +59,7 @@ private: SSAInt ToPal8(SSAVec4i c); void SetStencilBlock(SSAInt block); - void StencilSet(SSAInt x, SSAInt y, SSAUByte value); void StencilClear(SSAUByte value); - SSAUByte StencilGet(SSAInt x, SSAInt y); SSAUByte StencilGetSingle(); SSABool StencilIsSingleValue(); @@ -87,6 +85,8 @@ private: SSAStack stack_AffineW; SSAStack stack_AffineVaryingPosY[TriVertex::NumVarying]; SSAStack stack_AffineVaryingPosX[TriVertex::NumVarying]; + SSAStack stack_stencilblock_restored; + SSAStack stack_stencilblock_lastval; SSAUBytePtr dest; SSAInt pitch; diff --git a/tools/drawergen/ssa/ssa_bool.cpp b/tools/drawergen/ssa/ssa_bool.cpp index 38cec124f..7ce99b827 100644 --- a/tools/drawergen/ssa/ssa_bool.cpp +++ b/tools/drawergen/ssa/ssa_bool.cpp @@ -31,12 +31,13 @@ SSABool::SSABool() : v(0) { } -/* + SSABool::SSABool(bool constant) : v(0) { + v = llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(1, constant, false)); } -*/ + SSABool::SSABool(llvm::Value *v) : v(v) { diff --git a/tools/drawergen/ssa/ssa_bool.h b/tools/drawergen/ssa/ssa_bool.h index 9b8a564d8..728c7b7e8 100644 --- a/tools/drawergen/ssa/ssa_bool.h +++ b/tools/drawergen/ssa/ssa_bool.h @@ -35,7 +35,7 @@ class SSABool { public: SSABool(); - //SSABool(bool constant); + explicit SSABool(bool constant); explicit SSABool(llvm::Value *v); static SSABool from_llvm(llvm::Value *v) { return SSABool(v); } static llvm::Type *llvm_type(); From 71350f2c17f011a722279130fff402606c728f39 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 2 Dec 2016 08:12:01 +0100 Subject: [PATCH 1325/1509] Sprite line clipping by subsector --- src/r_poly_portal.cpp | 91 ++++++++++++++++++++++++++++++------------- src/r_poly_portal.h | 44 ++++++++------------- src/r_poly_sprite.cpp | 57 ++++++++++++++++----------- src/r_poly_sprite.h | 1 + 4 files changed, 118 insertions(+), 75 deletions(-) diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 5c4dbc89f..9637d739c 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -62,9 +62,8 @@ void RenderPolyPortal::Render(int portalDepth) void RenderPolyPortal::ClearBuffers() { - SectorSpriteRanges.clear(); - SectorSpriteRanges.resize(numsectors); - SortedSprites.clear(); + SeenSectors.clear(); + SubsectorDepths.clear(); TranslucentObjects.clear(); SectorPortals.clear(); LinePortals.clear(); @@ -117,35 +116,61 @@ void RenderPolyPortal::RenderSubsector(subsector_t *sub) } } - SpriteRange sprites = GetSpritesForSector(sub->sector); - for (int i = 0; i < sprites.Count; i++) - { - AActor *thing = SortedSprites[sprites.Start + i].Thing; - TranslucentObjects.push_back({ thing, sub, subsectorDepth }); - } - - TranslucentObjects.insert(TranslucentObjects.end(), SubsectorTranslucentWalls.begin(), SubsectorTranslucentWalls.end()); - SubsectorTranslucentWalls.clear(); + SeenSectors.insert(sub->sector); + SubsectorDepths[sub] = subsectorDepth; } -SpriteRange RenderPolyPortal::GetSpritesForSector(sector_t *sector) +void RenderPolyPortal::RenderSprite(AActor *thing, double sortDistance, const DVector2 &left, const DVector2 &right) { - if ((int)SectorSpriteRanges.size() < sector->sectornum || sector->sectornum < 0) - return SpriteRange(); + if (numnodes == 0) + RenderSprite(thing, sortDistance, left, right, 0.0, 1.0, subsectors); + else + RenderSprite(thing, sortDistance, left, right, 0.0, 1.0, nodes + numnodes - 1); // The head node is the last node output. +} - auto &range = SectorSpriteRanges[sector->sectornum]; - if (range.Start == -1) +void RenderPolyPortal::RenderSprite(AActor *thing, double sortDistance, DVector2 left, DVector2 right, double t1, double t2, void *node) +{ + while (!((size_t)node & 1)) // Keep going until found a subsector { - range.Start = (int)SortedSprites.size(); - range.Count = 0; - for (AActor *thing = sector->thinglist; thing != nullptr; thing = thing->snext) + node_t *bsp = (node_t *)node; + + DVector2 planePos(FIXED2DBL(bsp->x), FIXED2DBL(bsp->y)); + DVector2 planeNormal = DVector2(FIXED2DBL(-bsp->dy), FIXED2DBL(bsp->dx)); + double planeD = planeNormal | planePos; + + int sideLeft = (left | planeNormal) > planeD; + int sideRight = (right | planeNormal) > planeD; + + if (sideLeft != sideRight) { - SortedSprites.push_back({ thing, (thing->Pos() - ViewPos).LengthSquared() }); - range.Count++; + double dotLeft = planeNormal | left; + double dotRight = planeNormal | right; + double t = (planeD - dotLeft) / (dotRight - dotLeft); + + DVector2 mid = left * (1.0 - t) + right * t; + double tmid = t1 * (1.0 - t) + t2 * t; + + if (sideLeft == 0) + { + RenderSprite(thing, sortDistance, mid, right, tmid, t2, bsp->children[sideRight]); + right = mid; + t2 = tmid; + } + else + { + RenderSprite(thing, sortDistance, left, mid, t1, tmid, bsp->children[sideLeft]); + left = mid; + t1 = tmid; + } } - std::stable_sort(SortedSprites.begin() + range.Start, SortedSprites.begin() + range.Start + range.Count); + node = bsp->children[sideLeft]; } - return range; + + subsector_t *sub = (subsector_t *)((BYTE *)node - 1); + + auto it = SubsectorDepths.find(sub); + if (it != SubsectorDepths.end()) + TranslucentObjects.push_back({ thing, sub, it->second, sortDistance, (float)t1, (float)t2 }); } void RenderPolyPortal::RenderLine(subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth) @@ -178,12 +203,12 @@ void RenderPolyPortal::RenderLine(subsector_t *sub, seg_t *line, sector_t *front if (!(fakeFloor->flags & FF_EXISTS)) continue; if (!(fakeFloor->flags & FF_RENDERPLANES)) continue; if (!fakeFloor->model) continue; - RenderPolyWall::Render3DFloorLine(WorldToClip, PortalPlane, line, frontsector, subsectorDepth, StencilValue, fakeFloor, SubsectorTranslucentWalls); + RenderPolyWall::Render3DFloorLine(WorldToClip, PortalPlane, line, frontsector, subsectorDepth, StencilValue, fakeFloor, TranslucentObjects); } } // Render wall, and update culling info if its an occlusion blocker - if (RenderPolyWall::RenderLine(WorldToClip, PortalPlane, line, frontsector, subsectorDepth, StencilValue, SubsectorTranslucentWalls, LinePortals)) + if (RenderPolyWall::RenderLine(WorldToClip, PortalPlane, line, frontsector, subsectorDepth, StencilValue, TranslucentObjects, LinePortals)) { if (hasSegmentRange) Cull.MarkSegmentCulled(sx1, sx2); @@ -287,6 +312,20 @@ void RenderPolyPortal::RenderTranslucent(int portalDepth) } } + for (sector_t *sector : SeenSectors) + { + for (AActor *thing = sector->thinglist; thing != nullptr; thing = thing->snext) + { + DVector2 left, right; + if (!RenderPolySprite::GetLine(thing, left, right)) + continue; + double distanceSquared = (thing->Pos() - ViewPos).LengthSquared(); + RenderSprite(thing, distanceSquared, left, right); + } + } + + std::stable_sort(TranslucentObjects.begin(), TranslucentObjects.end()); + for (auto it = TranslucentObjects.rbegin(); it != TranslucentObjects.rend(); ++it) { auto &obj = *it; diff --git a/src/r_poly_portal.h b/src/r_poly_portal.h index e2b131b32..8623f8686 100644 --- a/src/r_poly_portal.h +++ b/src/r_poly_portal.h @@ -38,40 +38,31 @@ #include "r_poly_particle.h" #include "r_poly_plane.h" #include "r_poly_cull.h" - -// Used for sorting things by distance to the camera -class PolySortedSprite -{ -public: - PolySortedSprite(AActor *thing, double distanceSquared) : Thing(thing), DistanceSquared(distanceSquared) { } - bool operator<(const PolySortedSprite &other) const { return DistanceSquared < other.DistanceSquared; } - - AActor *Thing; - double DistanceSquared; -}; +#include +#include class PolyTranslucentObject { public: PolyTranslucentObject(particle_t *particle, subsector_t *sub, uint32_t subsectorDepth) : particle(particle), sub(sub), subsectorDepth(subsectorDepth) { } - PolyTranslucentObject(AActor *thing, subsector_t *sub, uint32_t subsectorDepth) : thing(thing), sub(sub), subsectorDepth(subsectorDepth) { } + PolyTranslucentObject(AActor *thing, subsector_t *sub, uint32_t subsectorDepth, double dist, float t1, float t2) : thing(thing), sub(sub), subsectorDepth(subsectorDepth), DistanceSquared(dist), SpriteLeft(t1), SpriteRight(t2) { } PolyTranslucentObject(RenderPolyWall wall) : wall(wall) { } + bool operator<(const PolyTranslucentObject &other) const + { + return subsectorDepth != other.subsectorDepth ? subsectorDepth < other.subsectorDepth : DistanceSquared < other.DistanceSquared; + } + particle_t *particle = nullptr; AActor *thing = nullptr; subsector_t *sub = nullptr; - uint32_t subsectorDepth = 0; RenderPolyWall wall; -}; - -class SpriteRange -{ -public: - SpriteRange() = default; - SpriteRange(int start, int count) : Start(start), Count(count) { } - int Start = -1; - int Count = 0; + + uint32_t subsectorDepth = 0; + double DistanceSquared = 1.e6; + + float SpriteLeft = 0.0f, SpriteRight = 1.0f; }; class PolyDrawSectorPortal; @@ -95,18 +86,17 @@ private: void RenderSectors(); void RenderSubsector(subsector_t *sub); void RenderLine(subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); - - SpriteRange GetSpritesForSector(sector_t *sector); + void RenderSprite(AActor *thing, double sortDistance, const DVector2 &left, const DVector2 &right); + void RenderSprite(AActor *thing, double sortDistance, DVector2 left, DVector2 right, double t1, double t2, void *node); TriMatrix WorldToClip; Vec4f PortalPlane; uint32_t StencilValue = 0; PolyCull Cull; uint32_t NextSubsectorDepth = 0; - std::vector SectorSpriteRanges; - std::vector SortedSprites; + std::set SeenSectors; + std::unordered_map SubsectorDepths; std::vector TranslucentObjects; - std::vector SubsectorTranslucentWalls; std::vector> SectorPortals; std::vector> LinePortals; diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index 46c90adc2..5d4a9ba6c 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -32,11 +32,43 @@ EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Int, r_drawfuzz) -void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) +bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right) { if (IsThingCulled(thing)) - return; + return false; + DVector3 pos = thing->InterpolatedPosition(r_TicFracF); + + bool flipTextureX = false; + FTexture *tex = GetSpriteTexture(thing, flipTextureX); + if (tex == nullptr) + return false; + + DVector2 spriteScale = thing->Scale; + double thingxscalemul = spriteScale.X / tex->Scale.X; + double thingyscalemul = spriteScale.Y / tex->Scale.Y; + + if (flipTextureX) + pos.X -= (tex->GetWidth() - tex->LeftOffset) * thingxscalemul; + else + pos.X -= tex->LeftOffset * thingxscalemul; + + double spriteHalfWidth = thingxscalemul * tex->GetWidth() * 0.5; + double spriteHeight = thingyscalemul * tex->GetHeight(); + + pos.X += spriteHalfWidth; + + left = DVector2(pos.X - ViewSin * spriteHalfWidth, pos.Y + ViewCos * spriteHalfWidth); + right = DVector2(pos.X + ViewSin * spriteHalfWidth, pos.Y - ViewCos * spriteHalfWidth); + return true; +} + +void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) +{ + DVector2 points[2]; + if (!GetLine(thing, points[0], points[1])) + return; + DVector3 pos = thing->InterpolatedPosition(r_TicFracF); pos.Z += thing->GetBobOffset(r_TicFracF); @@ -44,6 +76,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla FTexture *tex = GetSpriteTexture(thing, flipTextureX); if (tex == nullptr) return; + DVector2 spriteScale = thing->Scale; double thingxscalemul = spriteScale.X / tex->Scale.X; double thingyscalemul = spriteScale.Y / tex->Scale.Y; @@ -61,26 +94,6 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla pos.X += spriteHalfWidth; - DVector2 points[2] = - { - { pos.X - ViewSin * spriteHalfWidth, pos.Y + ViewCos * spriteHalfWidth }, - { pos.X + ViewSin * spriteHalfWidth, pos.Y - ViewCos * spriteHalfWidth } - }; - - // Is this sprite inside? (To do: clip the points) - for (int i = 0; i < 2; i++) - { - for (uint32_t i = 0; i < sub->numlines; i++) - { - seg_t *line = &sub->firstline[i]; - double nx = line->v1->fY() - line->v2->fY(); - double ny = line->v2->fX() - line->v1->fX(); - double d = -(line->v1->fX() * nx + line->v1->fY() * ny); - if (pos.X * nx + pos.Y * ny + d > 0.0) - return; - } - } - //double depth = 1.0; //visstyle_t visstyle = GetSpriteVisStyle(thing, depth); // Rumor has it that AlterWeaponSprite needs to be called with visstyle passed in somewhere around here.. diff --git a/src/r_poly_sprite.h b/src/r_poly_sprite.h index 04b0fcb94..8ce9caffd 100644 --- a/src/r_poly_sprite.h +++ b/src/r_poly_sprite.h @@ -31,6 +31,7 @@ class RenderPolySprite public: void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); + static bool GetLine(AActor *thing, DVector2 &left, DVector2 &right); static bool IsThingCulled(AActor *thing); static FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); From 01008f0daa3c147f0d08c0b9d06021f7f7cfb779 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 2 Dec 2016 13:06:16 +0100 Subject: [PATCH 1326/1509] Fix sprite bsp clipping bug and wall sorting bug --- src/r_poly_portal.cpp | 2 +- src/r_poly_portal.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 9637d739c..7d8c385dd 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -158,7 +158,7 @@ void RenderPolyPortal::RenderSprite(AActor *thing, double sortDistance, DVector2 } else { - RenderSprite(thing, sortDistance, left, mid, t1, tmid, bsp->children[sideLeft]); + RenderSprite(thing, sortDistance, left, mid, t1, tmid, bsp->children[sideRight]); left = mid; t1 = tmid; } diff --git a/src/r_poly_portal.h b/src/r_poly_portal.h index 8623f8686..e983ebd46 100644 --- a/src/r_poly_portal.h +++ b/src/r_poly_portal.h @@ -46,7 +46,7 @@ class PolyTranslucentObject public: PolyTranslucentObject(particle_t *particle, subsector_t *sub, uint32_t subsectorDepth) : particle(particle), sub(sub), subsectorDepth(subsectorDepth) { } PolyTranslucentObject(AActor *thing, subsector_t *sub, uint32_t subsectorDepth, double dist, float t1, float t2) : thing(thing), sub(sub), subsectorDepth(subsectorDepth), DistanceSquared(dist), SpriteLeft(t1), SpriteRight(t2) { } - PolyTranslucentObject(RenderPolyWall wall) : wall(wall) { } + PolyTranslucentObject(RenderPolyWall wall) : wall(wall), subsectorDepth(wall.SubsectorDepth), DistanceSquared(1.e6) { } bool operator<(const PolyTranslucentObject &other) const { @@ -60,7 +60,7 @@ public: RenderPolyWall wall; uint32_t subsectorDepth = 0; - double DistanceSquared = 1.e6; + double DistanceSquared = 0.0; float SpriteLeft = 0.0f, SpriteRight = 1.0f; }; From ce6e1e1e472e3b6cef3892007aa6f1170d0f9aec Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 2 Dec 2016 13:24:53 +0100 Subject: [PATCH 1327/1509] Fully hook up sprite clipping by subsector --- src/r_poly_portal.cpp | 17 ++++------------- src/r_poly_sprite.cpp | 20 +++++++++++++------- src/r_poly_sprite.h | 2 +- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 7d8c385dd..1047164cb 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -150,18 +150,9 @@ void RenderPolyPortal::RenderSprite(AActor *thing, double sortDistance, DVector2 DVector2 mid = left * (1.0 - t) + right * t; double tmid = t1 * (1.0 - t) + t2 * t; - if (sideLeft == 0) - { - RenderSprite(thing, sortDistance, mid, right, tmid, t2, bsp->children[sideRight]); - right = mid; - t2 = tmid; - } - else - { - RenderSprite(thing, sortDistance, left, mid, t1, tmid, bsp->children[sideRight]); - left = mid; - t1 = tmid; - } + RenderSprite(thing, sortDistance, mid, right, tmid, t2, bsp->children[sideRight]); + right = mid; + t2 = tmid; } node = bsp->children[sideLeft]; } @@ -346,7 +337,7 @@ void RenderPolyPortal::RenderTranslucent(int portalDepth) else { RenderPolySprite spr; - spr.Render(WorldToClip, PortalPlane, obj.thing, obj.sub, obj.subsectorDepth, StencilValue + 1); + spr.Render(WorldToClip, PortalPlane, obj.thing, obj.sub, obj.subsectorDepth, StencilValue + 1, obj.SpriteLeft, obj.SpriteRight); } } } diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index 5d4a9ba6c..c17bc5909 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -63,10 +63,10 @@ bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right) return true; } -void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) +void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, float t1, float t2) { - DVector2 points[2]; - if (!GetLine(thing, points[0], points[1])) + DVector2 line[2]; + if (!GetLine(thing, line[0], line[1])) return; DVector3 pos = thing->InterpolatedPosition(r_TicFracF); @@ -108,10 +108,16 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla std::pair offsets[4] = { - { 0.0f, 1.0f }, - { 1.0f, 1.0f }, - { 1.0f, 0.0f }, - { 0.0f, 0.0f }, + { t1, 1.0f }, + { t2, 1.0f }, + { t2, 0.0f }, + { t1, 0.0f }, + }; + + DVector2 points[2] = + { + line[0] * (1.0 - t1) + line[1] * t1, + line[0] * (1.0 - t2) + line[1] * t2 }; for (int i = 0; i < 4; i++) diff --git a/src/r_poly_sprite.h b/src/r_poly_sprite.h index 8ce9caffd..085845e50 100644 --- a/src/r_poly_sprite.h +++ b/src/r_poly_sprite.h @@ -29,7 +29,7 @@ class Vec4f; class RenderPolySprite { public: - void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); + void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, float t1, float t2); static bool GetLine(AActor *thing, DVector2 &left, DVector2 &right); static bool IsThingCulled(AActor *thing); From 04e981dba0382838b0af2b55366cd152e56d9d52 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 3 Dec 2016 05:02:34 +0100 Subject: [PATCH 1328/1509] Fix up/down culling issue --- src/r_poly_cull.cpp | 23 +++++++++++++++++------ src/r_poly_cull.h | 9 ++++++++- src/r_poly_portal.cpp | 8 ++++---- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/r_poly_cull.cpp b/src/r_poly_cull.cpp index 9ee71c28a..a688c2644 100644 --- a/src/r_poly_cull.cpp +++ b/src/r_poly_cull.cpp @@ -93,7 +93,7 @@ void PolyCull::CullSubsector(subsector_t *sub) continue; int sx1, sx2; - if (GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2)) + if (GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2) == LineSegmentRange::HasSegment) { MarkSegmentCulled(sx1, sx2); } @@ -200,7 +200,8 @@ bool PolyCull::CheckBBox(float *bspcoord) float x2 = bspcoord[lines[i][2]]; float y2 = bspcoord[lines[i][3]]; int sx1, sx2; - if (GetSegmentRangeForLine(x1, y1, x2, y2, sx1, sx2)) + LineSegmentRange result = GetSegmentRangeForLine(x1, y1, x2, y2, sx1, sx2); + if (result == LineSegmentRange::HasSegment) { if (foundline) { @@ -214,6 +215,10 @@ bool PolyCull::CheckBBox(float *bspcoord) foundline = true; } } + else if (result == LineSegmentRange::AlwaysVisible) + { + return true; + } } if (!foundline) return false; @@ -221,13 +226,14 @@ bool PolyCull::CheckBBox(float *bspcoord) return !IsSegmentCulled(minsx1, maxsx2); } -bool PolyCull::GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const +LineSegmentRange PolyCull::GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const { double znear = 5.0; + double updownnear = -400.0; // Cull if entirely behind the portal clip plane (tbd: should we clip the segment?) if (Vec4f::dot(PortalClipPlane, Vec4f((float)x1, (float)y1, 0.0f, 1.0f)) < 0.0f && Vec4f::dot(PortalClipPlane, Vec4f((float)x2, (float)y2, 0.0f, 1.0f)) < 0.0f) - return false; + return LineSegmentRange::NotVisible; // Transform to 2D view space: x1 = x1 - ViewPos.X; @@ -239,8 +245,13 @@ bool PolyCull::GetSegmentRangeForLine(double x1, double y1, double x2, double y2 double ry1 = x1 * ViewCos + y1 * ViewSin; double ry2 = x2 * ViewCos + y2 * ViewSin; + // Is it potentially visible when looking straight up or down? + if (!(ry1 < updownnear && ry2 < updownnear) && !(ry1 > znear && ry2 > znear)) + return LineSegmentRange::AlwaysVisible; + // Cull if line is entirely behind view - if (ry1 < znear && ry2 < znear) return false; + if (ry1 < znear && ry2 < znear) + return LineSegmentRange::NotVisible; // Clip line, if needed double t1 = 0.0f, t2 = 1.0f; @@ -265,5 +276,5 @@ bool PolyCull::GetSegmentRangeForLine(double x1, double y1, double x2, double y2 if (sx1 > sx2) std::swap(sx1, sx2); - return sx1 != sx2; + return (sx1 != sx2) ? LineSegmentRange::HasSegment : LineSegmentRange::AlwaysVisible; } diff --git a/src/r_poly_cull.h b/src/r_poly_cull.h index f1fe56ed5..fe3cd9f5d 100644 --- a/src/r_poly_cull.h +++ b/src/r_poly_cull.h @@ -25,12 +25,19 @@ #include "r_poly_triangle.h" #include "r_poly_intersection.h" +enum class LineSegmentRange +{ + NotVisible, + HasSegment, + AlwaysVisible +}; + class PolyCull { public: void CullScene(const TriMatrix &worldToClip, const Vec4f &portalClipPlane); - bool GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const; + LineSegmentRange GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const; void MarkSegmentCulled(int x1, int x2); bool IsSegmentCulled(int x1, int x2) const; diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 1047164cb..b5553665c 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -174,12 +174,12 @@ void RenderPolyPortal::RenderLine(subsector_t *sub, seg_t *line, sector_t *front // Cull wall if not visible int sx1, sx2; - bool hasSegmentRange = Cull.GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2); - if (!hasSegmentRange || Cull.IsSegmentCulled(sx1, sx2)) + LineSegmentRange segmentRange = Cull.GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2); + if (segmentRange == LineSegmentRange::NotVisible || (segmentRange == LineSegmentRange::HasSegment && Cull.IsSegmentCulled(sx1, sx2))) return; // Tell automap we saw this - if (!swrenderer::r_dontmaplines && line->linedef) + if (!swrenderer::r_dontmaplines && line->linedef && segmentRange != LineSegmentRange::AlwaysVisible) { line->linedef->flags |= ML_MAPPED; sub->flags |= SSECF_DRAWN; @@ -201,7 +201,7 @@ void RenderPolyPortal::RenderLine(subsector_t *sub, seg_t *line, sector_t *front // Render wall, and update culling info if its an occlusion blocker if (RenderPolyWall::RenderLine(WorldToClip, PortalPlane, line, frontsector, subsectorDepth, StencilValue, TranslucentObjects, LinePortals)) { - if (hasSegmentRange) + if (segmentRange == LineSegmentRange::HasSegment) Cull.MarkSegmentCulled(sx1, sx2); } } From dbacb75617585c504443b15f89bde8ed727a9e96 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 3 Dec 2016 06:58:06 +0100 Subject: [PATCH 1329/1509] Capped sky rendering --- src/r_drawers.cpp | 16 ++++++++++ src/r_drawers.h | 5 +-- src/r_poly_sky.cpp | 27 ++++++---------- src/r_poly_sky.h | 3 +- .../fixedfunction/drawtrianglecodegen.cpp | 31 +++++++++++++++---- .../fixedfunction/drawtrianglecodegen.h | 2 ++ 6 files changed, 56 insertions(+), 28 deletions(-) diff --git a/src/r_drawers.cpp b/src/r_drawers.cpp index 66cbdd750..acbe71de4 100644 --- a/src/r_drawers.cpp +++ b/src/r_drawers.cpp @@ -107,6 +107,7 @@ extern "C" void TriDrawNormal8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawNormal8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawNormal8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal8_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawNormal32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawNormal32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawNormal32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); @@ -121,6 +122,7 @@ extern "C" void TriDrawNormal32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawNormal32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawNormal32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawNormal32_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); @@ -135,6 +137,7 @@ extern "C" void TriFillNormal8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal8_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); @@ -149,6 +152,7 @@ extern "C" void TriFillNormal32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillNormal32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillNormal32_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); @@ -163,6 +167,7 @@ extern "C" void TriDrawSubsector8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector8_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); @@ -177,6 +182,7 @@ extern "C" void TriDrawSubsector32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriDrawSubsector32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDrawSubsector32_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); @@ -191,6 +197,7 @@ extern "C" void TriFillSubsector8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector8_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); @@ -205,6 +212,7 @@ extern "C" void TriFillSubsector32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriFillSubsector32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFillSubsector32_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriStencil_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); void TriStencilClose_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); } @@ -289,6 +297,7 @@ Drawers::Drawers() TriDrawNormal8.push_back(TriDrawNormal8_11_SSE2); TriDrawNormal8.push_back(TriDrawNormal8_12_SSE2); TriDrawNormal8.push_back(TriDrawNormal8_13_SSE2); + TriDrawNormal8.push_back(TriDrawNormal8_14_SSE2); TriDrawNormal32.push_back(TriDrawNormal32_0_SSE2); TriDrawNormal32.push_back(TriDrawNormal32_1_SSE2); TriDrawNormal32.push_back(TriDrawNormal32_2_SSE2); @@ -303,6 +312,7 @@ Drawers::Drawers() TriDrawNormal32.push_back(TriDrawNormal32_11_SSE2); TriDrawNormal32.push_back(TriDrawNormal32_12_SSE2); TriDrawNormal32.push_back(TriDrawNormal32_13_SSE2); + TriDrawNormal32.push_back(TriDrawNormal32_14_SSE2); TriFillNormal8.push_back(TriFillNormal8_0_SSE2); TriFillNormal8.push_back(TriFillNormal8_1_SSE2); TriFillNormal8.push_back(TriFillNormal8_2_SSE2); @@ -317,6 +327,7 @@ Drawers::Drawers() TriFillNormal8.push_back(TriFillNormal8_11_SSE2); TriFillNormal8.push_back(TriFillNormal8_12_SSE2); TriFillNormal8.push_back(TriFillNormal8_13_SSE2); + TriFillNormal8.push_back(TriFillNormal8_14_SSE2); TriFillNormal32.push_back(TriFillNormal32_0_SSE2); TriFillNormal32.push_back(TriFillNormal32_1_SSE2); TriFillNormal32.push_back(TriFillNormal32_2_SSE2); @@ -331,6 +342,7 @@ Drawers::Drawers() TriFillNormal32.push_back(TriFillNormal32_11_SSE2); TriFillNormal32.push_back(TriFillNormal32_12_SSE2); TriFillNormal32.push_back(TriFillNormal32_13_SSE2); + TriFillNormal32.push_back(TriFillNormal32_14_SSE2); TriDrawSubsector8.push_back(TriDrawSubsector8_0_SSE2); TriDrawSubsector8.push_back(TriDrawSubsector8_1_SSE2); TriDrawSubsector8.push_back(TriDrawSubsector8_2_SSE2); @@ -345,6 +357,7 @@ Drawers::Drawers() TriDrawSubsector8.push_back(TriDrawSubsector8_11_SSE2); TriDrawSubsector8.push_back(TriDrawSubsector8_12_SSE2); TriDrawSubsector8.push_back(TriDrawSubsector8_13_SSE2); + TriDrawSubsector8.push_back(TriDrawSubsector8_14_SSE2); TriDrawSubsector32.push_back(TriDrawSubsector32_0_SSE2); TriDrawSubsector32.push_back(TriDrawSubsector32_1_SSE2); TriDrawSubsector32.push_back(TriDrawSubsector32_2_SSE2); @@ -359,6 +372,7 @@ Drawers::Drawers() TriDrawSubsector32.push_back(TriDrawSubsector32_11_SSE2); TriDrawSubsector32.push_back(TriDrawSubsector32_12_SSE2); TriDrawSubsector32.push_back(TriDrawSubsector32_13_SSE2); + TriDrawSubsector32.push_back(TriDrawSubsector32_14_SSE2); TriFillSubsector8.push_back(TriFillSubsector8_0_SSE2); TriFillSubsector8.push_back(TriFillSubsector8_1_SSE2); TriFillSubsector8.push_back(TriFillSubsector8_2_SSE2); @@ -373,6 +387,7 @@ Drawers::Drawers() TriFillSubsector8.push_back(TriFillSubsector8_11_SSE2); TriFillSubsector8.push_back(TriFillSubsector8_12_SSE2); TriFillSubsector8.push_back(TriFillSubsector8_13_SSE2); + TriFillSubsector8.push_back(TriFillSubsector8_14_SSE2); TriFillSubsector32.push_back(TriFillSubsector32_0_SSE2); TriFillSubsector32.push_back(TriFillSubsector32_1_SSE2); TriFillSubsector32.push_back(TriFillSubsector32_2_SSE2); @@ -387,6 +402,7 @@ Drawers::Drawers() TriFillSubsector32.push_back(TriFillSubsector32_11_SSE2); TriFillSubsector32.push_back(TriFillSubsector32_12_SSE2); TriFillSubsector32.push_back(TriFillSubsector32_13_SSE2); + TriFillSubsector32.push_back(TriFillSubsector32_14_SSE2); TriStencil = TriStencil_SSE2; TriStencilClose = TriStencilClose_SSE2; } diff --git a/src/r_drawers.h b/src/r_drawers.h index 47a145b5a..ebe5d9002 100644 --- a/src/r_drawers.h +++ b/src/r_drawers.h @@ -254,10 +254,11 @@ enum class TriBlendMode TranslateAdd, // blend_add(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) TranslateSub, // blend_sub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) TranslateRevSub,// blend_revsub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)) - AddSrcColorOneMinusSrcColor // glBlendMode(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR) used by GZDoom's fullbright additive sprites + AddSrcColorOneMinusSrcColor, // glBlendMode(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR) used by GZDoom's fullbright additive sprites + Skycap // Fade to sky color when the V texture coordinate go beyond the [-1, 1] range }; -inline int NumTriBlendModes() { return (int)TriBlendMode::AddSrcColorOneMinusSrcColor + 1; } +inline int NumTriBlendModes() { return (int)TriBlendMode::Skycap + 1; } class Drawers { diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp index a19e0d40b..2331548b3 100644 --- a/src/r_poly_sky.cpp +++ b/src/r_poly_sky.cpp @@ -66,20 +66,24 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) RenderCapColorRow(args, frontskytex, 0, false); RenderCapColorRow(args, frontskytex, rc, true); + uint32_t topcapcolor = frontskytex->GetSkyCapColor(false); + uint32_t bottomcapcolor = frontskytex->GetSkyCapColor(true); + for (int i = 1; i <= mRows; i++) { - RenderRow(args, i); - RenderRow(args, rc + i); + RenderRow(args, i, topcapcolor); + RenderRow(args, rc + i, bottomcapcolor); } } -void PolySkyDome::RenderRow(PolyDrawArgs &args, int row) +void PolySkyDome::RenderRow(PolyDrawArgs &args, int row, uint32_t capcolor) { args.vinput = &mVertices[mPrimStart[row]]; args.vcount = mPrimStart[row + 1] - mPrimStart[row]; args.mode = TriangleDrawMode::Strip; args.ccw = false; - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy); + args.uniforms.color = capcolor; + PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Skycap); } void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap) @@ -129,18 +133,6 @@ void PolySkyDome::CreateSkyHemisphere(bool zflip) } } -TriVertex PolySkyDome::SetVertex(float xx, float yy, float zz, float uu, float vv) -{ - TriVertex v; - v.x = xx; - v.y = yy; - v.z = zz; - v.w = 1.0f; - v.varying[0] = uu; - v.varying[1] = vv; - return v; -} - TriVertex PolySkyDome::SetVertexXYZ(float xx, float yy, float zz, float uu, float vv) { TriVertex v; @@ -166,7 +158,6 @@ void PolySkyDome::SkyVertex(int r, int c, bool zflip) float z = (!zflip) ? scale * height : -scale * height; float u, v; - //uint32_t color = r == 0 ? 0xffffff : 0xffffffff; // And the texture coordinates. if (!zflip) // Flipped Y is for the lower hemisphere. @@ -184,6 +175,6 @@ void PolySkyDome::SkyVertex(int r, int c, bool zflip) // And finally the vertex. TriVertex vert; - vert = SetVertexXYZ(-pos.X, z - 1.f, pos.Y, u * 4.0f, v * 1.2f + 0.5f/*, color*/); + vert = SetVertexXYZ(-pos.X, z - 1.f, pos.Y, u * 4.0f, v * 1.2f - 0.5f); mVertices.Push(vert); } diff --git a/src/r_poly_sky.h b/src/r_poly_sky.h index 95ec27ed6..1f5a655b9 100644 --- a/src/r_poly_sky.h +++ b/src/r_poly_sky.h @@ -38,9 +38,8 @@ private: void SkyVertex(int r, int c, bool yflip); void CreateSkyHemisphere(bool zflip); void CreateDome(); - void RenderRow(PolyDrawArgs &args, int row); + void RenderRow(PolyDrawArgs &args, int row, uint32_t capcolor); void RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap); - TriVertex SetVertex(float xx, float yy, float zz, float uu = 0, float vv = 0); TriVertex SetVertexXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0); }; diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index df8690821..75acffac9 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -333,8 +333,6 @@ void DrawTriangleCodegen::SetupAffineBlock() { AffineVaryingPosX[i] = SSAInt(AffineVaryingPosY[i] * rcpW0, false); AffineVaryingStepX[i] = (SSAInt((AffineVaryingPosY[i] + gradVaryingX[i]) * rcpW1, false) - AffineVaryingPosX[i]) / q; - AffineVaryingPosX[i] = AffineVaryingPosX[i] << 8; - AffineVaryingStepX[i] = AffineVaryingStepX[i] << 8; } } @@ -780,8 +778,8 @@ SSAInt DrawTriangleCodegen::Shade8(SSAInt c) SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) { - SSAInt ufrac = varying[0]; - SSAInt vfrac = varying[1]; + SSAInt ufrac = varying[0] << 8; + SSAInt vfrac = varying[1] << 8; SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -848,6 +846,10 @@ SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) fg = Sample32(uvoffset); output = blend_add_srccolor_oneminussrccolor(shade_bgra_simple(fg, currentlight), bg); break; + case TriBlendMode::Skycap: + fg = Sample32(uvoffset); + output = FadeOut(varying[1], fg); + break; } return output; @@ -867,8 +869,8 @@ SSAInt DrawTriangleCodegen::ToPal8(SSAVec4i c) SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) { - SSAInt ufrac = varying[0]; - SSAInt vfrac = varying[1]; + SSAInt ufrac = varying[0] << 8; + SSAInt vfrac = varying[1] << 8; SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; @@ -955,11 +957,28 @@ SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) output = ToPal8(blend_add_srccolor_oneminussrccolor(fg, ToBgra(bg))); output = (palindex == SSAInt(0)).select(bg, output); break; + case TriBlendMode::Skycap: + fg = ToBgra(Sample8(uvoffset)); + output = ToPal8(FadeOut(varying[1], fg)); + break; } return output; } +SSAVec4i DrawTriangleCodegen::FadeOut(SSAInt frac, SSAVec4i fg) +{ + int start_fade = 2; // How fast it should fade out + + SSAInt alpha_top = SSAInt::MAX(SSAInt::MIN(frac.ashr(16 - start_fade), SSAInt(256)), SSAInt(0)); + SSAInt alpha_bottom = SSAInt::MAX(SSAInt::MIN(((2 << 24) - frac).ashr(16 - start_fade), SSAInt(256)), SSAInt(0)); + SSAInt alpha = SSAInt::MIN(alpha_top, alpha_bottom); + SSAInt inv_alpha = 256 - alpha; + + fg = (fg * alpha + SSAVec4i::unpack(color) * inv_alpha) / 256; + return fg.insert(3, 255); +} + void DrawTriangleCodegen::SetStencilBlock(SSAInt block) { StencilBlock = stencilValues[block * 64]; diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.h b/tools/drawergen/fixedfunction/drawtrianglecodegen.h index 0559efd23..1f22cf0a8 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.h +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.h @@ -58,6 +58,8 @@ private: SSAVec4i ToBgra(SSAInt index); SSAInt ToPal8(SSAVec4i c); + SSAVec4i FadeOut(SSAInt frac, SSAVec4i color); + void SetStencilBlock(SSAInt block); void StencilClear(SSAUByte value); SSAUByte StencilGetSingle(); From fc2ae9ecc3e30ae3356abcf5b053202f3a0b4663 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 3 Dec 2016 02:18:29 -0500 Subject: [PATCH 1330/1509] Delete DelLLVMCache.cmd This file is now vestigial and no longer needed. --- tools/DelLLVMCache.cmd | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 tools/DelLLVMCache.cmd diff --git a/tools/DelLLVMCache.cmd b/tools/DelLLVMCache.cmd deleted file mode 100644 index d7c3b1525..000000000 --- a/tools/DelLLVMCache.cmd +++ /dev/null @@ -1,9 +0,0 @@ -@echo off -if not exist %localappdata%\zdoom\cache\llvm* goto :eof -echo QZDoom's LLVM drawers may take some time to create at startup. Because of this, -echo the program uses a cache to temporarily store bitcode for faster startups. If -echo this cache is ever corrupted, this program has been created to solve the -echo problem. -echo. -echo Are you SURE you wish to destroy the cache? -del /p %localappdata%\zdoom\cache\llvm* From e09c7d239f57b8bebdc4a5f9046bfcb26ffac7cc Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 3 Dec 2016 14:58:56 +0100 Subject: [PATCH 1331/1509] Adjust class naming to closer match the GZDoom renderer and split portal rendering part to its own file --- src/CMakeLists.txt | 1 + src/r_poly.cpp | 16 +- src/r_poly.h | 7 +- src/r_poly_plane.cpp | 2 +- src/r_poly_portal.cpp | 320 +-------------------------------------- src/r_poly_portal.h | 84 +---------- src/r_poly_scene.cpp | 341 ++++++++++++++++++++++++++++++++++++++++++ src/r_poly_scene.h | 103 +++++++++++++ src/r_poly_sky.cpp | 2 +- src/r_swrenderer.cpp | 8 +- 10 files changed, 470 insertions(+), 414 deletions(-) create mode 100644 src/r_poly_scene.cpp create mode 100644 src/r_poly_scene.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 73a3074bb..ea07dec7b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1030,6 +1030,7 @@ set( NOT_COMPILED_SOURCE_FILES set( FASTMATH_PCH_SOURCES r_swrenderer.cpp r_poly.cpp + r_poly_scene.cpp r_poly_portal.cpp r_poly_cull.cpp r_poly_decal.cpp diff --git a/src/r_poly.cpp b/src/r_poly.cpp index cadf92adf..4ea047925 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -37,13 +37,13 @@ extern bool r_showviewer; ///////////////////////////////////////////////////////////////////////////// -RenderPolyScene *RenderPolyScene::Instance() +PolyRenderer *PolyRenderer::Instance() { - static RenderPolyScene scene; + static PolyRenderer scene; return &scene; } -void RenderPolyScene::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines) +void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines) { const bool savedviewactive = viewactive; const bool savedoutputformat = swrenderer::r_swtruecolor; @@ -70,7 +70,7 @@ void RenderPolyScene::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, swrenderer::r_swtruecolor = savedoutputformat; } -void RenderPolyScene::RenderActorView(AActor *actor, bool dontmaplines) +void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines) { NetUpdate(); @@ -106,12 +106,12 @@ void RenderPolyScene::RenderActorView(AActor *actor, bool dontmaplines) NetUpdate(); } -void RenderPolyScene::RenderRemainingPlayerSprites() +void PolyRenderer::RenderRemainingPlayerSprites() { PlayerSprites.RenderRemainingSprites(); } -void RenderPolyScene::ClearBuffers() +void PolyRenderer::ClearBuffers() { PolyVertexBuffer::Clear(); PolyStencilBuffer::Instance()->Clear(RenderTarget->GetWidth(), RenderTarget->GetHeight(), 0); @@ -119,7 +119,7 @@ void RenderPolyScene::ClearBuffers() NextStencilValue = 0; } -void RenderPolyScene::SetSceneViewport() +void PolyRenderer::SetSceneViewport() { if (RenderTarget == screen) // Rendering to screen { @@ -138,7 +138,7 @@ void RenderPolyScene::SetSceneViewport() } } -void RenderPolyScene::SetupPerspectiveMatrix() +void PolyRenderer::SetupPerspectiveMatrix() { static bool bDidSetup = false; diff --git a/src/r_poly.h b/src/r_poly.h index d67e39570..bc108a8a1 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -36,15 +36,14 @@ class AActor; class DCanvas; -// Renders a scene -class RenderPolyScene +class PolyRenderer { public: void RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines); void RenderActorView(AActor *actor, bool dontmaplines); void RenderRemainingPlayerSprites(); - static RenderPolyScene *Instance(); + static PolyRenderer *Instance(); uint32_t GetNextStencilValue() { uint32_t value = NextStencilValue; NextStencilValue += 2; return value; } @@ -54,7 +53,7 @@ private: void SetupPerspectiveMatrix(); TriMatrix WorldToClip; - RenderPolyPortal MainPortal; + RenderPolyScene MainPortal; PolySkyDome Skydome; RenderPolyPlayerSprites PlayerSprites; uint32_t NextStencilValue = 0; diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 41898fa8b..24b00af00 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -254,7 +254,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan if (swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap) args.uniforms.light = 256; args.uniforms.flags = 0; - args.uniforms.subsectorDepth = isSky ? RenderPolyPortal::SkySubsectorDepth : subsectorDepth; + args.uniforms.subsectorDepth = isSky ? RenderPolyScene::SkySubsectorDepth : subsectorDepth; TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines); if (!vertices) diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index b5553665c..1bb600779 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -30,323 +30,13 @@ #include "r_poly.h" #include "gl/data/gl_data.h" -CVAR(Bool, r_debug_cull, 0, 0) -EXTERN_CVAR(Int, r_portal_recursions) - extern bool r_showviewer; ///////////////////////////////////////////////////////////////////////////// -RenderPolyPortal::RenderPolyPortal() -{ -} - -RenderPolyPortal::~RenderPolyPortal() -{ -} - -void RenderPolyPortal::SetViewpoint(const TriMatrix &worldToClip, const Vec4f &portalPlane, uint32_t stencilValue) -{ - WorldToClip = worldToClip; - StencilValue = stencilValue; - PortalPlane = portalPlane; -} - -void RenderPolyPortal::Render(int portalDepth) -{ - ClearBuffers(); - Cull.CullScene(WorldToClip, PortalPlane); - RenderSectors(); - RenderPortals(portalDepth); -} - -void RenderPolyPortal::ClearBuffers() -{ - SeenSectors.clear(); - SubsectorDepths.clear(); - TranslucentObjects.clear(); - SectorPortals.clear(); - LinePortals.clear(); - NextSubsectorDepth = 0; -} - -void RenderPolyPortal::RenderSectors() -{ - if (r_debug_cull) - { - for (auto it = Cull.PvsSectors.rbegin(); it != Cull.PvsSectors.rend(); ++it) - RenderSubsector(*it); - } - else - { - for (auto it = Cull.PvsSectors.begin(); it != Cull.PvsSectors.end(); ++it) - RenderSubsector(*it); - } -} - -void RenderPolyPortal::RenderSubsector(subsector_t *sub) -{ - sector_t *frontsector = sub->sector; - frontsector->MoreFlags |= SECF_DRAWN; - - uint32_t subsectorDepth = NextSubsectorDepth++; - - if (sub->sector->CenterFloor() != sub->sector->CenterCeiling()) - { - RenderPolyPlane::RenderPlanes(WorldToClip, PortalPlane, sub, subsectorDepth, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, SectorPortals); - } - - for (uint32_t i = 0; i < sub->numlines; i++) - { - seg_t *line = &sub->firstline[i]; - if (line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) - { - RenderLine(sub, line, frontsector, subsectorDepth); - } - } - - bool mainBSP = ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors); - if (mainBSP) - { - int subsectorIndex = (int)(sub - subsectors); - for (int i = ParticlesInSubsec[subsectorIndex]; i != NO_PARTICLE; i = Particles[i].snext) - { - particle_t *particle = Particles + i; - TranslucentObjects.push_back({ particle, sub, subsectorDepth }); - } - } - - SeenSectors.insert(sub->sector); - SubsectorDepths[sub] = subsectorDepth; -} - -void RenderPolyPortal::RenderSprite(AActor *thing, double sortDistance, const DVector2 &left, const DVector2 &right) -{ - if (numnodes == 0) - RenderSprite(thing, sortDistance, left, right, 0.0, 1.0, subsectors); - else - RenderSprite(thing, sortDistance, left, right, 0.0, 1.0, nodes + numnodes - 1); // The head node is the last node output. -} - -void RenderPolyPortal::RenderSprite(AActor *thing, double sortDistance, DVector2 left, DVector2 right, double t1, double t2, void *node) -{ - while (!((size_t)node & 1)) // Keep going until found a subsector - { - node_t *bsp = (node_t *)node; - - DVector2 planePos(FIXED2DBL(bsp->x), FIXED2DBL(bsp->y)); - DVector2 planeNormal = DVector2(FIXED2DBL(-bsp->dy), FIXED2DBL(bsp->dx)); - double planeD = planeNormal | planePos; - - int sideLeft = (left | planeNormal) > planeD; - int sideRight = (right | planeNormal) > planeD; - - if (sideLeft != sideRight) - { - double dotLeft = planeNormal | left; - double dotRight = planeNormal | right; - double t = (planeD - dotLeft) / (dotRight - dotLeft); - - DVector2 mid = left * (1.0 - t) + right * t; - double tmid = t1 * (1.0 - t) + t2 * t; - - RenderSprite(thing, sortDistance, mid, right, tmid, t2, bsp->children[sideRight]); - right = mid; - t2 = tmid; - } - node = bsp->children[sideLeft]; - } - - subsector_t *sub = (subsector_t *)((BYTE *)node - 1); - - auto it = SubsectorDepths.find(sub); - if (it != SubsectorDepths.end()) - TranslucentObjects.push_back({ thing, sub, it->second, sortDistance, (float)t1, (float)t2 }); -} - -void RenderPolyPortal::RenderLine(subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth) -{ - // Reject lines not facing viewer - DVector2 pt1 = line->v1->fPos() - ViewPos; - DVector2 pt2 = line->v2->fPos() - ViewPos; - if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0) - return; - - // Cull wall if not visible - int sx1, sx2; - LineSegmentRange segmentRange = Cull.GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2); - if (segmentRange == LineSegmentRange::NotVisible || (segmentRange == LineSegmentRange::HasSegment && Cull.IsSegmentCulled(sx1, sx2))) - return; - - // Tell automap we saw this - if (!swrenderer::r_dontmaplines && line->linedef && segmentRange != LineSegmentRange::AlwaysVisible) - { - line->linedef->flags |= ML_MAPPED; - sub->flags |= SSECF_DRAWN; - } - - // Render 3D floor sides - if (line->backsector && frontsector->e && line->backsector->e->XFloor.ffloors.Size()) - { - for (unsigned int i = 0; i < line->backsector->e->XFloor.ffloors.Size(); i++) - { - F3DFloor *fakeFloor = line->backsector->e->XFloor.ffloors[i]; - if (!(fakeFloor->flags & FF_EXISTS)) continue; - if (!(fakeFloor->flags & FF_RENDERPLANES)) continue; - if (!fakeFloor->model) continue; - RenderPolyWall::Render3DFloorLine(WorldToClip, PortalPlane, line, frontsector, subsectorDepth, StencilValue, fakeFloor, TranslucentObjects); - } - } - - // Render wall, and update culling info if its an occlusion blocker - if (RenderPolyWall::RenderLine(WorldToClip, PortalPlane, line, frontsector, subsectorDepth, StencilValue, TranslucentObjects, LinePortals)) - { - if (segmentRange == LineSegmentRange::HasSegment) - Cull.MarkSegmentCulled(sx1, sx2); - } -} - -void RenderPolyPortal::RenderPortals(int portalDepth) -{ - if (portalDepth < r_portal_recursions) - { - for (auto &portal : SectorPortals) - portal->Render(portalDepth + 1); - - for (auto &portal : LinePortals) - portal->Render(portalDepth + 1); - } - else // Fill with black - { - PolyDrawArgs args; - args.objectToClip = &WorldToClip; - args.mode = TriangleDrawMode::Fan; - args.uniforms.color = 0; - args.uniforms.light = 256; - args.uniforms.flags = TriUniforms::fixed_light; - args.SetClipPlane(PortalPlane.x, PortalPlane.y, PortalPlane.z, PortalPlane.w); - - for (auto &portal : SectorPortals) - { - args.stenciltestvalue = portal->StencilValue; - args.stencilwritevalue = portal->StencilValue + 1; - for (const auto &verts : portal->Shape) - { - args.vinput = verts.Vertices; - args.vcount = verts.Count; - args.ccw = verts.Ccw; - args.uniforms.subsectorDepth = verts.SubsectorDepth; - PolyTriangleDrawer::draw(args, TriDrawVariant::FillNormal, TriBlendMode::Copy); - } - } - - for (auto &portal : LinePortals) - { - args.stenciltestvalue = portal->StencilValue; - args.stencilwritevalue = portal->StencilValue + 1; - for (const auto &verts : portal->Shape) - { - args.vinput = verts.Vertices; - args.vcount = verts.Count; - args.ccw = verts.Ccw; - args.uniforms.subsectorDepth = verts.SubsectorDepth; - PolyTriangleDrawer::draw(args, TriDrawVariant::FillNormal, TriBlendMode::Copy); - } - } - } -} - -void RenderPolyPortal::RenderTranslucent(int portalDepth) -{ - if (portalDepth < r_portal_recursions) - { - for (auto it = SectorPortals.rbegin(); it != SectorPortals.rend(); ++it) - { - auto &portal = *it; - portal->RenderTranslucent(portalDepth + 1); - - PolyDrawArgs args; - args.objectToClip = &WorldToClip; - args.mode = TriangleDrawMode::Fan; - args.stenciltestvalue = portal->StencilValue + 1; - args.stencilwritevalue = StencilValue; - args.SetClipPlane(PortalPlane.x, PortalPlane.y, PortalPlane.z, PortalPlane.w); - for (const auto &verts : portal->Shape) - { - args.vinput = verts.Vertices; - args.vcount = verts.Count; - args.ccw = verts.Ccw; - args.uniforms.subsectorDepth = verts.SubsectorDepth; - PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy); - } - } - - for (auto it = LinePortals.rbegin(); it != LinePortals.rend(); ++it) - { - auto &portal = *it; - portal->RenderTranslucent(portalDepth + 1); - - PolyDrawArgs args; - args.objectToClip = &WorldToClip; - args.mode = TriangleDrawMode::Fan; - args.stenciltestvalue = portal->StencilValue + 1; - args.stencilwritevalue = StencilValue; - args.SetClipPlane(PortalPlane.x, PortalPlane.y, PortalPlane.z, PortalPlane.w); - for (const auto &verts : portal->Shape) - { - args.vinput = verts.Vertices; - args.vcount = verts.Count; - args.ccw = verts.Ccw; - args.uniforms.subsectorDepth = verts.SubsectorDepth; - PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy); - } - } - } - - for (sector_t *sector : SeenSectors) - { - for (AActor *thing = sector->thinglist; thing != nullptr; thing = thing->snext) - { - DVector2 left, right; - if (!RenderPolySprite::GetLine(thing, left, right)) - continue; - double distanceSquared = (thing->Pos() - ViewPos).LengthSquared(); - RenderSprite(thing, distanceSquared, left, right); - } - } - - std::stable_sort(TranslucentObjects.begin(), TranslucentObjects.end()); - - for (auto it = TranslucentObjects.rbegin(); it != TranslucentObjects.rend(); ++it) - { - auto &obj = *it; - if (obj.particle) - { - RenderPolyParticle spr; - spr.Render(WorldToClip, PortalPlane, obj.particle, obj.sub, obj.subsectorDepth, StencilValue + 1); - } - else if (!obj.thing) - { - obj.wall.Render(WorldToClip, PortalPlane); - } - else if ((obj.thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) - { - RenderPolyWallSprite wallspr; - wallspr.Render(WorldToClip, PortalPlane, obj.thing, obj.sub, obj.subsectorDepth, StencilValue + 1); - } - else - { - RenderPolySprite spr; - spr.Render(WorldToClip, PortalPlane, obj.thing, obj.sub, obj.subsectorDepth, StencilValue + 1, obj.SpriteLeft, obj.SpriteRight); - } - } -} - -///////////////////////////////////////////////////////////////////////////// - PolyDrawSectorPortal::PolyDrawSectorPortal(FSectorPortal *portal, bool ceiling) : Portal(portal), Ceiling(ceiling) { - StencilValue = RenderPolyScene::Instance()->GetNextStencilValue(); + StencilValue = PolyRenderer::Instance()->GetNextStencilValue(); } void PolyDrawSectorPortal::Render(int portalDepth) @@ -356,7 +46,7 @@ void PolyDrawSectorPortal::Render(int portalDepth) SaveGlobals(); - // To do: get this information from RenderPolyScene instead of duplicating the code.. + // To do: get this information from PolyRenderer instead of duplicating the code.. double radPitch = ViewPitch.Normalized180().Radians(); double angx = cos(radPitch); double angy = sin(radPitch) * glset.pixelstretch; @@ -444,19 +134,19 @@ void PolyDrawSectorPortal::RestoreGlobals() PolyDrawLinePortal::PolyDrawLinePortal(FLinePortal *portal) : Portal(portal) { - StencilValue = RenderPolyScene::Instance()->GetNextStencilValue(); + StencilValue = PolyRenderer::Instance()->GetNextStencilValue(); } PolyDrawLinePortal::PolyDrawLinePortal(line_t *mirror) : Mirror(mirror) { - StencilValue = RenderPolyScene::Instance()->GetNextStencilValue(); + StencilValue = PolyRenderer::Instance()->GetNextStencilValue(); } void PolyDrawLinePortal::Render(int portalDepth) { SaveGlobals(); - // To do: get this information from RenderPolyScene instead of duplicating the code.. + // To do: get this information from PolyRenderer instead of duplicating the code.. double radPitch = ViewPitch.Normalized180().Radians(); double angx = cos(radPitch); double angy = sin(radPitch) * glset.pixelstretch; diff --git a/src/r_poly_portal.h b/src/r_poly_portal.h index e983ebd46..7835bb042 100644 --- a/src/r_poly_portal.h +++ b/src/r_poly_portal.h @@ -22,85 +22,7 @@ #pragma once -#include -#include -#include -#include -#include "doomdata.h" -#include "r_utility.h" -#include "r_main.h" -#include "r_poly_triangle.h" -#include "r_poly_intersection.h" -#include "r_poly_wall.h" -#include "r_poly_sprite.h" -#include "r_poly_wallsprite.h" -#include "r_poly_playersprite.h" -#include "r_poly_particle.h" -#include "r_poly_plane.h" -#include "r_poly_cull.h" -#include -#include - -class PolyTranslucentObject -{ -public: - PolyTranslucentObject(particle_t *particle, subsector_t *sub, uint32_t subsectorDepth) : particle(particle), sub(sub), subsectorDepth(subsectorDepth) { } - PolyTranslucentObject(AActor *thing, subsector_t *sub, uint32_t subsectorDepth, double dist, float t1, float t2) : thing(thing), sub(sub), subsectorDepth(subsectorDepth), DistanceSquared(dist), SpriteLeft(t1), SpriteRight(t2) { } - PolyTranslucentObject(RenderPolyWall wall) : wall(wall), subsectorDepth(wall.SubsectorDepth), DistanceSquared(1.e6) { } - - bool operator<(const PolyTranslucentObject &other) const - { - return subsectorDepth != other.subsectorDepth ? subsectorDepth < other.subsectorDepth : DistanceSquared < other.DistanceSquared; - } - - particle_t *particle = nullptr; - AActor *thing = nullptr; - subsector_t *sub = nullptr; - - RenderPolyWall wall; - - uint32_t subsectorDepth = 0; - double DistanceSquared = 0.0; - - float SpriteLeft = 0.0f, SpriteRight = 1.0f; -}; - -class PolyDrawSectorPortal; -class PolyDrawLinePortal; - -// Renders everything from a specific viewpoint -class RenderPolyPortal -{ -public: - RenderPolyPortal(); - ~RenderPolyPortal(); - void SetViewpoint(const TriMatrix &worldToClip, const Vec4f &portalPlane, uint32_t stencilValue); - void Render(int portalDepth); - void RenderTranslucent(int portalDepth); - - static const uint32_t SkySubsectorDepth = 0x7fffffff; - -private: - void ClearBuffers(); - void RenderPortals(int portalDepth); - void RenderSectors(); - void RenderSubsector(subsector_t *sub); - void RenderLine(subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); - void RenderSprite(AActor *thing, double sortDistance, const DVector2 &left, const DVector2 &right); - void RenderSprite(AActor *thing, double sortDistance, DVector2 left, DVector2 right, double t1, double t2, void *node); - - TriMatrix WorldToClip; - Vec4f PortalPlane; - uint32_t StencilValue = 0; - PolyCull Cull; - uint32_t NextSubsectorDepth = 0; - std::set SeenSectors; - std::unordered_map SubsectorDepths; - std::vector TranslucentObjects; - - std::vector> SectorPortals; - std::vector> LinePortals; -}; +#include "r_poly_scene.h" struct PolyPortalVertexRange { @@ -128,7 +50,7 @@ private: void RestoreGlobals(); bool Ceiling; - RenderPolyPortal RenderPortal; + RenderPolyScene RenderPortal; int savedextralight; DVector3 savedpos; @@ -156,7 +78,7 @@ private: void SaveGlobals(); void RestoreGlobals(); - RenderPolyPortal RenderPortal; + RenderPolyScene RenderPortal; int savedextralight; DVector3 savedpos; diff --git a/src/r_poly_scene.cpp b/src/r_poly_scene.cpp new file mode 100644 index 000000000..7304000a6 --- /dev/null +++ b/src/r_poly_scene.cpp @@ -0,0 +1,341 @@ +/* +** Polygon Doom software renderer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "p_maputl.h" +#include "sbar.h" +#include "r_data/r_translate.h" +#include "r_poly_scene.h" +#include "r_poly.h" +#include "gl/data/gl_data.h" + +CVAR(Bool, r_debug_cull, 0, 0) +EXTERN_CVAR(Int, r_portal_recursions) + +///////////////////////////////////////////////////////////////////////////// + +RenderPolyScene::RenderPolyScene() +{ +} + +RenderPolyScene::~RenderPolyScene() +{ +} + +void RenderPolyScene::SetViewpoint(const TriMatrix &worldToClip, const Vec4f &portalPlane, uint32_t stencilValue) +{ + WorldToClip = worldToClip; + StencilValue = stencilValue; + PortalPlane = portalPlane; +} + +void RenderPolyScene::Render(int portalDepth) +{ + ClearBuffers(); + Cull.CullScene(WorldToClip, PortalPlane); + RenderSectors(); + RenderPortals(portalDepth); +} + +void RenderPolyScene::ClearBuffers() +{ + SeenSectors.clear(); + SubsectorDepths.clear(); + TranslucentObjects.clear(); + SectorPortals.clear(); + LinePortals.clear(); + NextSubsectorDepth = 0; +} + +void RenderPolyScene::RenderSectors() +{ + if (r_debug_cull) + { + for (auto it = Cull.PvsSectors.rbegin(); it != Cull.PvsSectors.rend(); ++it) + RenderSubsector(*it); + } + else + { + for (auto it = Cull.PvsSectors.begin(); it != Cull.PvsSectors.end(); ++it) + RenderSubsector(*it); + } +} + +void RenderPolyScene::RenderSubsector(subsector_t *sub) +{ + sector_t *frontsector = sub->sector; + frontsector->MoreFlags |= SECF_DRAWN; + + uint32_t subsectorDepth = NextSubsectorDepth++; + + if (sub->sector->CenterFloor() != sub->sector->CenterCeiling()) + { + RenderPolyPlane::RenderPlanes(WorldToClip, PortalPlane, sub, subsectorDepth, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, SectorPortals); + } + + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + if (line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) + { + RenderLine(sub, line, frontsector, subsectorDepth); + } + } + + bool mainBSP = ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors); + if (mainBSP) + { + int subsectorIndex = (int)(sub - subsectors); + for (int i = ParticlesInSubsec[subsectorIndex]; i != NO_PARTICLE; i = Particles[i].snext) + { + particle_t *particle = Particles + i; + TranslucentObjects.push_back({ particle, sub, subsectorDepth }); + } + } + + SeenSectors.insert(sub->sector); + SubsectorDepths[sub] = subsectorDepth; +} + +void RenderPolyScene::RenderSprite(AActor *thing, double sortDistance, const DVector2 &left, const DVector2 &right) +{ + if (numnodes == 0) + RenderSprite(thing, sortDistance, left, right, 0.0, 1.0, subsectors); + else + RenderSprite(thing, sortDistance, left, right, 0.0, 1.0, nodes + numnodes - 1); // The head node is the last node output. +} + +void RenderPolyScene::RenderSprite(AActor *thing, double sortDistance, DVector2 left, DVector2 right, double t1, double t2, void *node) +{ + while (!((size_t)node & 1)) // Keep going until found a subsector + { + node_t *bsp = (node_t *)node; + + DVector2 planePos(FIXED2DBL(bsp->x), FIXED2DBL(bsp->y)); + DVector2 planeNormal = DVector2(FIXED2DBL(-bsp->dy), FIXED2DBL(bsp->dx)); + double planeD = planeNormal | planePos; + + int sideLeft = (left | planeNormal) > planeD; + int sideRight = (right | planeNormal) > planeD; + + if (sideLeft != sideRight) + { + double dotLeft = planeNormal | left; + double dotRight = planeNormal | right; + double t = (planeD - dotLeft) / (dotRight - dotLeft); + + DVector2 mid = left * (1.0 - t) + right * t; + double tmid = t1 * (1.0 - t) + t2 * t; + + RenderSprite(thing, sortDistance, mid, right, tmid, t2, bsp->children[sideRight]); + right = mid; + t2 = tmid; + } + node = bsp->children[sideLeft]; + } + + subsector_t *sub = (subsector_t *)((BYTE *)node - 1); + + auto it = SubsectorDepths.find(sub); + if (it != SubsectorDepths.end()) + TranslucentObjects.push_back({ thing, sub, it->second, sortDistance, (float)t1, (float)t2 }); +} + +void RenderPolyScene::RenderLine(subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth) +{ + // Reject lines not facing viewer + DVector2 pt1 = line->v1->fPos() - ViewPos; + DVector2 pt2 = line->v2->fPos() - ViewPos; + if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0) + return; + + // Cull wall if not visible + int sx1, sx2; + LineSegmentRange segmentRange = Cull.GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2); + if (segmentRange == LineSegmentRange::NotVisible || (segmentRange == LineSegmentRange::HasSegment && Cull.IsSegmentCulled(sx1, sx2))) + return; + + // Tell automap we saw this + if (!swrenderer::r_dontmaplines && line->linedef && segmentRange != LineSegmentRange::AlwaysVisible) + { + line->linedef->flags |= ML_MAPPED; + sub->flags |= SSECF_DRAWN; + } + + // Render 3D floor sides + if (line->backsector && frontsector->e && line->backsector->e->XFloor.ffloors.Size()) + { + for (unsigned int i = 0; i < line->backsector->e->XFloor.ffloors.Size(); i++) + { + F3DFloor *fakeFloor = line->backsector->e->XFloor.ffloors[i]; + if (!(fakeFloor->flags & FF_EXISTS)) continue; + if (!(fakeFloor->flags & FF_RENDERPLANES)) continue; + if (!fakeFloor->model) continue; + RenderPolyWall::Render3DFloorLine(WorldToClip, PortalPlane, line, frontsector, subsectorDepth, StencilValue, fakeFloor, TranslucentObjects); + } + } + + // Render wall, and update culling info if its an occlusion blocker + if (RenderPolyWall::RenderLine(WorldToClip, PortalPlane, line, frontsector, subsectorDepth, StencilValue, TranslucentObjects, LinePortals)) + { + if (segmentRange == LineSegmentRange::HasSegment) + Cull.MarkSegmentCulled(sx1, sx2); + } +} + +void RenderPolyScene::RenderPortals(int portalDepth) +{ + if (portalDepth < r_portal_recursions) + { + for (auto &portal : SectorPortals) + portal->Render(portalDepth + 1); + + for (auto &portal : LinePortals) + portal->Render(portalDepth + 1); + } + else // Fill with black + { + PolyDrawArgs args; + args.objectToClip = &WorldToClip; + args.mode = TriangleDrawMode::Fan; + args.uniforms.color = 0; + args.uniforms.light = 256; + args.uniforms.flags = TriUniforms::fixed_light; + args.SetClipPlane(PortalPlane.x, PortalPlane.y, PortalPlane.z, PortalPlane.w); + + for (auto &portal : SectorPortals) + { + args.stenciltestvalue = portal->StencilValue; + args.stencilwritevalue = portal->StencilValue + 1; + for (const auto &verts : portal->Shape) + { + args.vinput = verts.Vertices; + args.vcount = verts.Count; + args.ccw = verts.Ccw; + args.uniforms.subsectorDepth = verts.SubsectorDepth; + PolyTriangleDrawer::draw(args, TriDrawVariant::FillNormal, TriBlendMode::Copy); + } + } + + for (auto &portal : LinePortals) + { + args.stenciltestvalue = portal->StencilValue; + args.stencilwritevalue = portal->StencilValue + 1; + for (const auto &verts : portal->Shape) + { + args.vinput = verts.Vertices; + args.vcount = verts.Count; + args.ccw = verts.Ccw; + args.uniforms.subsectorDepth = verts.SubsectorDepth; + PolyTriangleDrawer::draw(args, TriDrawVariant::FillNormal, TriBlendMode::Copy); + } + } + } +} + +void RenderPolyScene::RenderTranslucent(int portalDepth) +{ + if (portalDepth < r_portal_recursions) + { + for (auto it = SectorPortals.rbegin(); it != SectorPortals.rend(); ++it) + { + auto &portal = *it; + portal->RenderTranslucent(portalDepth + 1); + + PolyDrawArgs args; + args.objectToClip = &WorldToClip; + args.mode = TriangleDrawMode::Fan; + args.stenciltestvalue = portal->StencilValue + 1; + args.stencilwritevalue = StencilValue; + args.SetClipPlane(PortalPlane.x, PortalPlane.y, PortalPlane.z, PortalPlane.w); + for (const auto &verts : portal->Shape) + { + args.vinput = verts.Vertices; + args.vcount = verts.Count; + args.ccw = verts.Ccw; + args.uniforms.subsectorDepth = verts.SubsectorDepth; + PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy); + } + } + + for (auto it = LinePortals.rbegin(); it != LinePortals.rend(); ++it) + { + auto &portal = *it; + portal->RenderTranslucent(portalDepth + 1); + + PolyDrawArgs args; + args.objectToClip = &WorldToClip; + args.mode = TriangleDrawMode::Fan; + args.stenciltestvalue = portal->StencilValue + 1; + args.stencilwritevalue = StencilValue; + args.SetClipPlane(PortalPlane.x, PortalPlane.y, PortalPlane.z, PortalPlane.w); + for (const auto &verts : portal->Shape) + { + args.vinput = verts.Vertices; + args.vcount = verts.Count; + args.ccw = verts.Ccw; + args.uniforms.subsectorDepth = verts.SubsectorDepth; + PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy); + } + } + } + + for (sector_t *sector : SeenSectors) + { + for (AActor *thing = sector->thinglist; thing != nullptr; thing = thing->snext) + { + DVector2 left, right; + if (!RenderPolySprite::GetLine(thing, left, right)) + continue; + double distanceSquared = (thing->Pos() - ViewPos).LengthSquared(); + RenderSprite(thing, distanceSquared, left, right); + } + } + + std::stable_sort(TranslucentObjects.begin(), TranslucentObjects.end()); + + for (auto it = TranslucentObjects.rbegin(); it != TranslucentObjects.rend(); ++it) + { + auto &obj = *it; + if (obj.particle) + { + RenderPolyParticle spr; + spr.Render(WorldToClip, PortalPlane, obj.particle, obj.sub, obj.subsectorDepth, StencilValue + 1); + } + else if (!obj.thing) + { + obj.wall.Render(WorldToClip, PortalPlane); + } + else if ((obj.thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) + { + RenderPolyWallSprite wallspr; + wallspr.Render(WorldToClip, PortalPlane, obj.thing, obj.sub, obj.subsectorDepth, StencilValue + 1); + } + else + { + RenderPolySprite spr; + spr.Render(WorldToClip, PortalPlane, obj.thing, obj.sub, obj.subsectorDepth, StencilValue + 1, obj.SpriteLeft, obj.SpriteRight); + } + } +} diff --git a/src/r_poly_scene.h b/src/r_poly_scene.h new file mode 100644 index 000000000..1e3037b12 --- /dev/null +++ b/src/r_poly_scene.h @@ -0,0 +1,103 @@ +/* +** Polygon Doom software renderer +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +#include +#include +#include +#include +#include "doomdata.h" +#include "r_utility.h" +#include "r_main.h" +#include "r_poly_triangle.h" +#include "r_poly_intersection.h" +#include "r_poly_wall.h" +#include "r_poly_sprite.h" +#include "r_poly_wallsprite.h" +#include "r_poly_playersprite.h" +#include "r_poly_particle.h" +#include "r_poly_plane.h" +#include "r_poly_cull.h" +#include +#include + +class PolyTranslucentObject +{ +public: + PolyTranslucentObject(particle_t *particle, subsector_t *sub, uint32_t subsectorDepth) : particle(particle), sub(sub), subsectorDepth(subsectorDepth) { } + PolyTranslucentObject(AActor *thing, subsector_t *sub, uint32_t subsectorDepth, double dist, float t1, float t2) : thing(thing), sub(sub), subsectorDepth(subsectorDepth), DistanceSquared(dist), SpriteLeft(t1), SpriteRight(t2) { } + PolyTranslucentObject(RenderPolyWall wall) : wall(wall), subsectorDepth(wall.SubsectorDepth), DistanceSquared(1.e6) { } + + bool operator<(const PolyTranslucentObject &other) const + { + return subsectorDepth != other.subsectorDepth ? subsectorDepth < other.subsectorDepth : DistanceSquared < other.DistanceSquared; + } + + particle_t *particle = nullptr; + AActor *thing = nullptr; + subsector_t *sub = nullptr; + + RenderPolyWall wall; + + uint32_t subsectorDepth = 0; + double DistanceSquared = 0.0; + + float SpriteLeft = 0.0f, SpriteRight = 1.0f; +}; + +class PolyDrawSectorPortal; +class PolyDrawLinePortal; + +// Renders everything from a specific viewpoint +class RenderPolyScene +{ +public: + RenderPolyScene(); + ~RenderPolyScene(); + void SetViewpoint(const TriMatrix &worldToClip, const Vec4f &portalPlane, uint32_t stencilValue); + void Render(int portalDepth); + void RenderTranslucent(int portalDepth); + + static const uint32_t SkySubsectorDepth = 0x7fffffff; + +private: + void ClearBuffers(); + void RenderPortals(int portalDepth); + void RenderSectors(); + void RenderSubsector(subsector_t *sub); + void RenderLine(subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth); + void RenderSprite(AActor *thing, double sortDistance, const DVector2 &left, const DVector2 &right); + void RenderSprite(AActor *thing, double sortDistance, DVector2 left, DVector2 right, double t1, double t2, void *node); + + TriMatrix WorldToClip; + Vec4f PortalPlane; + uint32_t StencilValue = 0; + PolyCull Cull; + uint32_t NextSubsectorDepth = 0; + std::set SeenSectors; + std::unordered_map SubsectorDepths; + std::vector TranslucentObjects; + + std::vector> SectorPortals; + std::vector> LinePortals; +}; diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp index 2331548b3..dafe1f7ec 100644 --- a/src/r_poly_sky.cpp +++ b/src/r_poly_sky.cpp @@ -55,7 +55,7 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) PolyDrawArgs args; args.uniforms.light = 256; args.uniforms.flags = 0; - args.uniforms.subsectorDepth = RenderPolyPortal::SkySubsectorDepth; + args.uniforms.subsectorDepth = RenderPolyScene::SkySubsectorDepth; args.objectToClip = &objectToClip; args.stenciltestvalue = 255; args.stencilwritevalue = 255; diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 56820e536..0c4925454 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -195,7 +195,7 @@ void FSoftwareRenderer::RenderView(player_t *player) bool saved_swtruecolor = r_swtruecolor; r_swtruecolor = screen->IsBgra(); - RenderPolyScene::Instance()->RenderActorView(player->mo, false); + PolyRenderer::Instance()->RenderActorView(player->mo, false); FCanvasTextureInfo::UpdateAll(); // Apply special colormap if the target cannot do it @@ -260,7 +260,7 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int wi pic->ObjectFlags |= OF_Fixed; pic->Lock (); if (r_polyrenderer) - RenderPolyScene::Instance()->RenderViewToCanvas(player->mo, pic, 0, 0, width, height, true); + PolyRenderer::Instance()->RenderViewToCanvas(player->mo, pic, 0, 0, width, height, true); else R_RenderViewToCanvas (player->mo, pic, 0, 0, width, height); screen->GetFlashedPalette (palette); @@ -285,7 +285,7 @@ void FSoftwareRenderer::DrawRemainingPlayerSprites() } else { - RenderPolyScene::Instance()->RenderRemainingPlayerSprites(); + PolyRenderer::Instance()->RenderRemainingPlayerSprites(); } } @@ -413,7 +413,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin DAngle savedfov = FieldOfView; R_SetFOV ((double)fov); if (r_polyrenderer) - RenderPolyScene::Instance()->RenderViewToCanvas(viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate); + PolyRenderer::Instance()->RenderViewToCanvas(viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate); else R_RenderViewToCanvas (viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate); R_SetFOV (savedfov); From 34970c9b9cb68db1385f84307bdea29748ea8ec7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 3 Dec 2016 18:49:52 +0100 Subject: [PATCH 1332/1509] - removed hexenglobal include from GL files. --- src/gl/renderer/gl_postprocess.cpp | 1 - src/gl/scene/gl_scene.cpp | 1 - src/gl/system/gl_framebuffer.cpp | 2 +- src/win32/win32gliface.cpp | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 52339e587..6d080434d 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -40,7 +40,6 @@ #include "sbar.h" #include "po_man.h" #include "r_utility.h" -#include "a_hexenglobal.h" #include "p_local.h" #include "colormatcher.h" #include "gl/gl_functions.h" diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 1437d3fd5..0cf0fa0a1 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -40,7 +40,6 @@ #include "sbar.h" #include "po_man.h" #include "r_utility.h" -#include "a_hexenglobal.h" #include "p_local.h" #include "gl/gl_functions.h" #include "serializer.h" diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 259cef5e0..7102df72e 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -53,7 +53,7 @@ #include "gl/renderer/gl_2ddrawer.h" #include "gl_debug.h" -IMPLEMENT_CLASS(OpenGLFrameBuffer, false, false, false, false) +IMPLEMENT_CLASS(OpenGLFrameBuffer, false, false) EXTERN_CVAR (Float, vid_brightness) EXTERN_CVAR (Float, vid_contrast) EXTERN_CVAR (Bool, vid_vsync) diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 6b9e413af..aa4755e48 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -854,7 +854,7 @@ bool Win32GLVideo::SetFullscreen(const char *devicename, int w, int h, int bits, // //========================================================================== -IMPLEMENT_CLASS(Win32GLFrameBuffer, true, false, false, false) +IMPLEMENT_CLASS(Win32GLFrameBuffer, true, false) //========================================================================== // From 5dd63a86cf2b585972fd994fa6cc9eac5ac9aa01 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 3 Dec 2016 18:59:28 +0100 Subject: [PATCH 1333/1509] - removed excess arguments for IMPLEMENT_CLASS. --- src/gl/dynlights/a_dynlight.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 5c85fce85..f705a4d5b 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -106,10 +106,10 @@ DEFINE_CLASS_PROPERTY(type, S, DynamicLight) // which is controlled by flags // //========================================================================== -IMPLEMENT_CLASS (ADynamicLight, false, false, false, false) -IMPLEMENT_CLASS (AVavoomLight, false, false, false, false) -IMPLEMENT_CLASS (AVavoomLightWhite, false, false, false, false) -IMPLEMENT_CLASS (AVavoomLightColor, false, false, false, false) +IMPLEMENT_CLASS (ADynamicLight, false, false) +IMPLEMENT_CLASS (AVavoomLight, false, false) +IMPLEMENT_CLASS (AVavoomLightWhite, false, false) +IMPLEMENT_CLASS (AVavoomLightColor, false, false) void AVavoomLight::BeginPlay () { From 834802def36d59ed34a76cdb83817a68546ee917 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 3 Dec 2016 19:49:32 +0100 Subject: [PATCH 1334/1509] - sanitized the old sprite offset adjustment feature and used it to redefine offsets for some sprites that have really bad ones. --- src/gl/data/gl_data.cpp | 27 +- wadsrc/static/filter/doom.doom1/sprofs.txt | 164 +++++++++ wadsrc/static/filter/doom.doom2/sprofs.txt | 164 +++++++++ wadsrc/static/filter/heretic/sprofs.txt | 97 ++++++ wadsrc/static/filter/hexen/sprofs.txt | 377 +++++++++++++++++++++ wadsrc/static/filter/strife/sprofs.txt | 364 ++++++++++++++++++++ 6 files changed, 1180 insertions(+), 13 deletions(-) create mode 100644 wadsrc/static/filter/doom.doom1/sprofs.txt create mode 100644 wadsrc/static/filter/doom.doom2/sprofs.txt create mode 100644 wadsrc/static/filter/heretic/sprofs.txt create mode 100644 wadsrc/static/filter/hexen/sprofs.txt create mode 100644 wadsrc/static/filter/strife/sprofs.txt diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index ad9c824bb..c3516499b 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -85,29 +85,30 @@ void gl_CreateSections(); void AdjustSpriteOffsets() { - static bool done=false; - char name[30]; - - if (done) return; - done=true; - - mysnprintf(name, countof(name), "sprofs/%s.sprofs", GameNames[gameinfo.gametype]); - int lump = Wads.CheckNumForFullName(name); - if (lump>=0) + int lump, lastlump = 0; + while ((lump = Wads.FindLump("SPROFS", &lastlump, false)) != -1) { FScanner sc; sc.OpenLumpNum(lump); + sc.SetCMode(true); GLRenderer->FlushTextures(); int ofslumpno = Wads.GetLumpFile(lump); while (sc.GetString()) { int x,y; + bool iwadonly = false; FTextureID texno = TexMan.CheckForTexture(sc.String, FTexture::TEX_Sprite); - sc.GetNumber(); + sc.MustGetStringName(","); + sc.MustGetNumber(); x=sc.Number; - sc.GetNumber(); + sc.MustGetStringName(","); + sc.MustGetNumber(); y=sc.Number; - + if (sc.CheckString(",")) + { + sc.MustGetString(); + if (sc.Compare("iwad")) iwadonly = true; + } if (texno.isValid()) { FTexture * tex = TexMan[texno]; @@ -117,7 +118,7 @@ void AdjustSpriteOffsets() if (lumpnum >= 0 && lumpnum < Wads.GetNumLumps()) { int wadno = Wads.GetLumpFile(lumpnum); - if (wadno==FWadCollection::IWAD_FILENUM || wadno == ofslumpno) + if ((iwadonly && wadno==FWadCollection::IWAD_FILENUM) || (!iwadonly && wadno == ofslumpno)) { tex->LeftOffset=x; tex->TopOffset=y; diff --git a/wadsrc/static/filter/doom.doom1/sprofs.txt b/wadsrc/static/filter/doom.doom1/sprofs.txt new file mode 100644 index 000000000..eab3dc4ef --- /dev/null +++ b/wadsrc/static/filter/doom.doom1/sprofs.txt @@ -0,0 +1,164 @@ +BAR1A0, 10, 32, iwad +BAR1B0, 10, 32, iwad +BEXPA0, 10, 32, iwad +BEXPB0, 10, 31, iwad +BEXPC0, 19, 36, iwad +BEXPD0, 27, 49, iwad +BEXPE0, 29, 52, iwad +BOS2I0, 20, 71, iwad +BOS2J0, 26, 62, iwad +BOS2K0, 26, 52, iwad +BOS2L0, 29, 33, iwad +BOS2M0, 30, 29, iwad +BOS2N0, 30, 29, iwad +BOS2O0, 30, 29, iwad +BOSSI0, 20, 72, iwad +BOSSJ0, 26, 63, iwad +BOSSK0, 26, 51, iwad +BOSSL0, 29, 33, iwad +BOSSM0, 30, 29, iwad +BOSSN0, 30, 29, iwad +BOSSO0, 30, 29, iwad +BRS1A0, 13, 8, iwad +BSPIJ0, 50, 54, iwad +BSPIK0, 50, 57, iwad +BSPIL0, 47, 52, iwad +BSPIM0, 45, 44, iwad +BSPIN0, 45, 42, iwad +BSPIO0, 45, 30, iwad +BSPIP0, 45, 28, iwad +CBRAA0, 15, 60, iwad +CEYEA0, 21, 59, iwad +CEYEB0, 21, 58, iwad +CEYEC0, 21, 59, iwad +COL1A0, 16, 51, iwad +COL2A0, 16, 39, iwad +COL3A0, 16, 52, iwad +COL4A0, 17, 39, iwad +COL5A0, 16, 44, iwad +COL5B0, 16, 45, iwad +COL6A0, 17, 47, iwad +COLUA0, 9, 45, iwad +CPOSH0, 20, 61, iwad +CPOSI0, 23, 64, iwad +CPOSJ0, 28, 59, iwad +CPOSK0, 30, 48, iwad +CPOSL0, 31, 34, iwad +CPOSM0, 32, 22, iwad +CPOSN0, 32, 18, iwad +CPOSO0, 26, 59, iwad +CPOSP0, 28, 59, iwad +CPOSQ0, 30, 48, iwad +CPOSR0, 32, 40, iwad +CPOSS0, 32, 31, iwad +CPOST0, 32, 19, iwad +CYBRH0, 60, 108, iwad +CYBRI0, 55, 110, iwad +CYBRJ0, 49, 113, iwad +CYBRK0, 56, 114, iwad +CYBRL0, 62, 121, iwad +CYBRM0, 67, 128, iwad +CYBRN0, 70, 132, iwad +CYBRO0, 69, 132, iwad +CYBRP0, 60, 28, iwad +ELECA0, 19, 125, iwad +FATTO0, 35, 43, iwad +FATTP0, 36, 41, iwad +FATTQ0, 36, 40, iwad +FATTR0, 36, 40, iwad +FATTS0, 36, 40, iwad +FATTT0, 36, 39, iwad +FCANA0, 19, 52, iwad +FCANB0, 19, 52, iwad +FCANC0, 19, 50, iwad +PLAYH0, 16, 50, iwad +PLAYI0, 11, 42, iwad +PLAYJ0, 12, 45, iwad +PLAYK0, 17, 37, iwad +PLAYL0, 27, 14, iwad +PLAYM0, 27, 14, iwad +PLAYN0, 27, 14, iwad +POB1A0, 16, 6, iwad +POB2A0, 14, 3, iwad +POL1A0, 22, 65, iwad +POL2A0, 19, 66, iwad +POL3A0, 19, 42, iwad +POL3B0, 19, 42, iwad +POL4A0, 19, 55, iwad +POL5A0, 27, 8, iwad +POL6A0, 17, 65, iwad +POL6B0, 19, 65, iwad +POSSH0, 19, 55, iwad +POSSL0, 22, 14, iwad +SARGI0, 25, 56, iwad +SARGM0, 33, 43, iwad +SARGN0, 33, 29, iwad +SKELM0, 27, 78, iwad +SKELN0, 38, 69, iwad +SKELO0, 28, 55, iwad +SKELP0, 28, 35, iwad +SKELQ0, 40, 20, iwad +SMITA0, 22, 44, iwad +SPIDJ0, 79, 102, iwad +SPIDK0, 95, 95, iwad +SPIDL0, 94, 88, iwad +SPIDM0, 94, 76, iwad +SPIDN0, 98, 71, iwad +SPIDO0, 101, 68, iwad +SPIDP0, 104, 85, iwad +SPIDQ0, 109, 90, iwad +SPIDR0, 110, 111, iwad +SPIDS0, 98, 35, iwad +SPOSH0, 14, 60, iwad +SPOSL0, 24, 15, iwad +SSWVG0, 17, 55, iwad +SSWVH0, 17, 52, iwad +SSWVI0, 18, 54, iwad +SSWVJ0, 15, 44, iwad +SSWVK0, 15, 40, iwad +SSWVL0, 15, 25, iwad +SSWVM0, 24, 13, iwad +SSWVN0, 15, 57, iwad +SSWVO0, 22, 59, iwad +SSWVP0, 25, 58, iwad +TBLUA0, 14, 94, iwad +TBLUB0, 14, 94, iwad +TBLUC0, 14, 94, iwad +TBLUD0, 14, 95, iwad +TGRNA0, 14, 94, iwad +TGRNB0, 14, 89, iwad +TGRNC0, 14, 89, iwad +TGRND0, 14, 95, iwad +TLMPA0, 11, 78, iwad +TLMPB0, 11, 78, iwad +TLMPC0, 11, 78, iwad +TLMPD0, 11, 78, iwad +TLP2A0, 10, 58, iwad +TLP2B0, 10, 58, iwad +TLP2C0, 10, 58, iwad +TLP2D0, 10, 58, iwad +TRE1A0, 25, 67, iwad +TREDA0, 14, 94, iwad +TREDB0, 14, 89, iwad +TREDC0, 14, 89, iwad +TREDD0, 14, 95, iwad +TROOI0, 22, 62, iwad +TROOJ0, 21, 59, iwad +TROOM0, 29, 20, iwad +TROON0, 24, 59, iwad +TROOO0, 20, 61, iwad +TROOP0, 24, 61, iwad +TROOQ0, 24, 61, iwad +TROOR0, 24, 44, iwad +TROOS0, 27, 34, iwad +TROOT0, 27, 31, iwad +TROOU0, 27, 18, iwad +VILER0, 18, 80, iwad +VILES0, 23, 76, iwad +VILET0, 27, 69, iwad +VILEU0, 35, 56, iwad +VILEV0, 34, 45, iwad +VILEW0, 34, 35, iwad +VILEX0, 34, 23, iwad +VILEY0, 34, 20, iwad +VILEZ0, 34, 20, iwad diff --git a/wadsrc/static/filter/doom.doom2/sprofs.txt b/wadsrc/static/filter/doom.doom2/sprofs.txt new file mode 100644 index 000000000..eab3dc4ef --- /dev/null +++ b/wadsrc/static/filter/doom.doom2/sprofs.txt @@ -0,0 +1,164 @@ +BAR1A0, 10, 32, iwad +BAR1B0, 10, 32, iwad +BEXPA0, 10, 32, iwad +BEXPB0, 10, 31, iwad +BEXPC0, 19, 36, iwad +BEXPD0, 27, 49, iwad +BEXPE0, 29, 52, iwad +BOS2I0, 20, 71, iwad +BOS2J0, 26, 62, iwad +BOS2K0, 26, 52, iwad +BOS2L0, 29, 33, iwad +BOS2M0, 30, 29, iwad +BOS2N0, 30, 29, iwad +BOS2O0, 30, 29, iwad +BOSSI0, 20, 72, iwad +BOSSJ0, 26, 63, iwad +BOSSK0, 26, 51, iwad +BOSSL0, 29, 33, iwad +BOSSM0, 30, 29, iwad +BOSSN0, 30, 29, iwad +BOSSO0, 30, 29, iwad +BRS1A0, 13, 8, iwad +BSPIJ0, 50, 54, iwad +BSPIK0, 50, 57, iwad +BSPIL0, 47, 52, iwad +BSPIM0, 45, 44, iwad +BSPIN0, 45, 42, iwad +BSPIO0, 45, 30, iwad +BSPIP0, 45, 28, iwad +CBRAA0, 15, 60, iwad +CEYEA0, 21, 59, iwad +CEYEB0, 21, 58, iwad +CEYEC0, 21, 59, iwad +COL1A0, 16, 51, iwad +COL2A0, 16, 39, iwad +COL3A0, 16, 52, iwad +COL4A0, 17, 39, iwad +COL5A0, 16, 44, iwad +COL5B0, 16, 45, iwad +COL6A0, 17, 47, iwad +COLUA0, 9, 45, iwad +CPOSH0, 20, 61, iwad +CPOSI0, 23, 64, iwad +CPOSJ0, 28, 59, iwad +CPOSK0, 30, 48, iwad +CPOSL0, 31, 34, iwad +CPOSM0, 32, 22, iwad +CPOSN0, 32, 18, iwad +CPOSO0, 26, 59, iwad +CPOSP0, 28, 59, iwad +CPOSQ0, 30, 48, iwad +CPOSR0, 32, 40, iwad +CPOSS0, 32, 31, iwad +CPOST0, 32, 19, iwad +CYBRH0, 60, 108, iwad +CYBRI0, 55, 110, iwad +CYBRJ0, 49, 113, iwad +CYBRK0, 56, 114, iwad +CYBRL0, 62, 121, iwad +CYBRM0, 67, 128, iwad +CYBRN0, 70, 132, iwad +CYBRO0, 69, 132, iwad +CYBRP0, 60, 28, iwad +ELECA0, 19, 125, iwad +FATTO0, 35, 43, iwad +FATTP0, 36, 41, iwad +FATTQ0, 36, 40, iwad +FATTR0, 36, 40, iwad +FATTS0, 36, 40, iwad +FATTT0, 36, 39, iwad +FCANA0, 19, 52, iwad +FCANB0, 19, 52, iwad +FCANC0, 19, 50, iwad +PLAYH0, 16, 50, iwad +PLAYI0, 11, 42, iwad +PLAYJ0, 12, 45, iwad +PLAYK0, 17, 37, iwad +PLAYL0, 27, 14, iwad +PLAYM0, 27, 14, iwad +PLAYN0, 27, 14, iwad +POB1A0, 16, 6, iwad +POB2A0, 14, 3, iwad +POL1A0, 22, 65, iwad +POL2A0, 19, 66, iwad +POL3A0, 19, 42, iwad +POL3B0, 19, 42, iwad +POL4A0, 19, 55, iwad +POL5A0, 27, 8, iwad +POL6A0, 17, 65, iwad +POL6B0, 19, 65, iwad +POSSH0, 19, 55, iwad +POSSL0, 22, 14, iwad +SARGI0, 25, 56, iwad +SARGM0, 33, 43, iwad +SARGN0, 33, 29, iwad +SKELM0, 27, 78, iwad +SKELN0, 38, 69, iwad +SKELO0, 28, 55, iwad +SKELP0, 28, 35, iwad +SKELQ0, 40, 20, iwad +SMITA0, 22, 44, iwad +SPIDJ0, 79, 102, iwad +SPIDK0, 95, 95, iwad +SPIDL0, 94, 88, iwad +SPIDM0, 94, 76, iwad +SPIDN0, 98, 71, iwad +SPIDO0, 101, 68, iwad +SPIDP0, 104, 85, iwad +SPIDQ0, 109, 90, iwad +SPIDR0, 110, 111, iwad +SPIDS0, 98, 35, iwad +SPOSH0, 14, 60, iwad +SPOSL0, 24, 15, iwad +SSWVG0, 17, 55, iwad +SSWVH0, 17, 52, iwad +SSWVI0, 18, 54, iwad +SSWVJ0, 15, 44, iwad +SSWVK0, 15, 40, iwad +SSWVL0, 15, 25, iwad +SSWVM0, 24, 13, iwad +SSWVN0, 15, 57, iwad +SSWVO0, 22, 59, iwad +SSWVP0, 25, 58, iwad +TBLUA0, 14, 94, iwad +TBLUB0, 14, 94, iwad +TBLUC0, 14, 94, iwad +TBLUD0, 14, 95, iwad +TGRNA0, 14, 94, iwad +TGRNB0, 14, 89, iwad +TGRNC0, 14, 89, iwad +TGRND0, 14, 95, iwad +TLMPA0, 11, 78, iwad +TLMPB0, 11, 78, iwad +TLMPC0, 11, 78, iwad +TLMPD0, 11, 78, iwad +TLP2A0, 10, 58, iwad +TLP2B0, 10, 58, iwad +TLP2C0, 10, 58, iwad +TLP2D0, 10, 58, iwad +TRE1A0, 25, 67, iwad +TREDA0, 14, 94, iwad +TREDB0, 14, 89, iwad +TREDC0, 14, 89, iwad +TREDD0, 14, 95, iwad +TROOI0, 22, 62, iwad +TROOJ0, 21, 59, iwad +TROOM0, 29, 20, iwad +TROON0, 24, 59, iwad +TROOO0, 20, 61, iwad +TROOP0, 24, 61, iwad +TROOQ0, 24, 61, iwad +TROOR0, 24, 44, iwad +TROOS0, 27, 34, iwad +TROOT0, 27, 31, iwad +TROOU0, 27, 18, iwad +VILER0, 18, 80, iwad +VILES0, 23, 76, iwad +VILET0, 27, 69, iwad +VILEU0, 35, 56, iwad +VILEV0, 34, 45, iwad +VILEW0, 34, 35, iwad +VILEX0, 34, 23, iwad +VILEY0, 34, 20, iwad +VILEZ0, 34, 20, iwad diff --git a/wadsrc/static/filter/heretic/sprofs.txt b/wadsrc/static/filter/heretic/sprofs.txt new file mode 100644 index 000000000..5f51dcde1 --- /dev/null +++ b/wadsrc/static/filter/heretic/sprofs.txt @@ -0,0 +1,97 @@ +BARLA0, 14, 35, iwad +BEASK0, 37, 77, iwad +BEASM0, 42, 74, iwad +BEASQ0, 29, 11, iwad +BEASU0, 44, 91, iwad +BEASV0, 49, 79, iwad +BEASW0, 51, 68, iwad +BEASX0, 52, 56, iwad +BEASY0, 41, 41, iwad +BEASZ0, 41, 30, iwad +BRPLA0, 28, 128, iwad +CHKNF0, 18, 25, iwad +CHKNG0, 17, 27, iwad +CHKNH0, 18, 30, iwad +CHKNI0, 20, 29, iwad +CHKNJ0, 20, 25, iwad +CHKNK0, 17, 9, iwad +CHKNL0, 13, 4, iwad +CLNKO0, 23, 16, iwad +FDTHA0, 21, 55, iwad +FDTHB0, 21, 60, iwad +FDTHC0, 29, 80, iwad +FDTHD0, 21, 76, iwad +FDTHE0, 22, 75, iwad +FDTHF0, 23, 59, iwad +FDTHG0, 24, 51, iwad +FDTHH0, 23, 48, iwad +FDTHI0, 23, 53, iwad +FDTHJ0, 22, 53, iwad +FDTHK0, 22, 55, iwad +FDTHL0, 23, 56, iwad +FDTHM0, 25, 58, iwad +FDTHN0, 26, 58, iwad +FDTHO0, 24, 59, iwad +IMPXI0, 22, 24, iwad +IMPXJ0, 22, 34, iwad +IMPXK0, 21, 34, iwad +IMPXL0, 22, 9, iwad +IMPXW0, 32, 49, iwad +IMPXX0, 33, 41, iwad +IMPXY0, 33, 25, iwad +IMPXZ0, 33, 11, iwad +KFR1A0, 20, 77, iwad +KFR1B0, 20, 78, iwad +KFR1C0, 20, 81, iwad +KFR1D0, 20, 81, iwad +KFR1E0, 20, 76, iwad +KFR1F0, 20, 78, iwad +KFR1G0, 20, 80, iwad +KFR1H0, 20, 78, iwad +KGZ1A0, 18, 52, iwad +MUMMI0, 33, 64, iwad +MUMMJ0, 34, 66, iwad +MUMMK0, 39, 71, iwad +MUMML0, 40, 66, iwad +MUMMM0, 36, 55, iwad +MUMMN0, 37, 37, iwad +MUMMO0, 38, 19, iwad +MUMMP0, 31, 10, iwad +PLAYS0, 34, 71, iwad +PLAYT0, 35, 68, iwad +PLAYU0, 30, 44, iwad +PLAYV0, 30, 24, iwad +PLAYW0, 30, 23, iwad +PLAYX0, 30, 17, iwad +PLAYY0, 30, 14, iwad +SFFIA0, 5, 20, iwad +SFFIB0, 6, 15, iwad +SFFIC0, 6, 11, iwad +SFFID0, 5, 8, iwad +SFFIE0, 4, 5, iwad +SMPLA0, 14, 37, iwad +SNKEM0, 54, 48, iwad +SNKEN0, 49, 35, iwad +SNKEO0, 48, 23, iwad +SNKEP0, 46, 13, iwad +SRCRE0, 59, 131, iwad +SRCRF0, 52, 120, iwad +SRCRG0, 68, 122, iwad +SRCRH0, 60, 114, iwad +SRCRI0, 63, 105, iwad +SRCRJ0, 67, 76, iwad +SRCRK0, 67, 32, iwad +SRCRL0, 67, 23, iwad +SRCRM0, 67, 28, iwad +SRCRN0, 67, 29, iwad +SRCRO0, 67, 23, iwad +SRCRP0, 67, 17, iwad +SRTCA0, 5, 63, iwad +SRTCB0, 5, 63, iwad +SRTCC0, 5, 61, iwad +STGLA0, 18, 69, iwad +STGSA0, 9, 37, iwad +WZRDJ0, 34, 59, iwad +WZRDK0, 30, 49, iwad +WZRDL0, 29, 26, iwad +WZRDM0, 27, 12, iwad diff --git a/wadsrc/static/filter/hexen/sprofs.txt b/wadsrc/static/filter/hexen/sprofs.txt new file mode 100644 index 000000000..a8d614ca0 --- /dev/null +++ b/wadsrc/static/filter/hexen/sprofs.txt @@ -0,0 +1,377 @@ +ZBARA0, 12, 33, iwad +BDPLA0, 7, 2, iwad +BDSHA0, 8, 6, iwad +BDSHB0, 8, 7, iwad +BDSHC0, 8, 7, iwad +BDSHD0, 9, 5, iwad +BISHK0, 43, 74, iwad +BISHL0, 45, 74, iwad +BISHM0, 45, 65, iwad +BISHN0, 43, 22, iwad +BISHO0, 40, 12, iwad +BISHP0, 30, 9, iwad +BRTRA0, 13, 61, iwad +BRTRB0, 13, 59, iwad +BRTRC0, 13, 57, iwad +BRTRD0, 13, 60, iwad +BRTRE0, 13, 59, iwad +BRTRF0, 13, 54, iwad +BRTRG0, 13, 54, iwad +BRTRH0, 13, 57, iwad +BRTRI0, 13, 60, iwad +BRTRJ0, 13, 62, iwad +BRTRK0, 13, 62, iwad +BRTRL0, 13, 58, iwad +BRTRM0, 13, 59, iwad +BCANA0, 10, 38, iwad +BCANB0, 10, 36, iwad +BCANC0, 10, 35, iwad +BCAND0, 10, 35, iwad +BCANE0, 10, 35, iwad +CDRNA0, 14, 24, iwad +CDRNB0, 14, 24, iwad +CDRNC0, 14, 24, iwad +CDRND0, 14, 24, iwad +CDRNE0, 14, 24, iwad +CDRNF0, 14, 24, iwad +CDRNG0, 14, 24, iwad +CDRNH0, 14, 24, iwad +CENTK0, 42, 73, iwad +CENTN0, 49, 76, iwad +CENTO0, 45, 83, iwad +CENTP0, 47, 80, iwad +CENTQ0, 55, 63, iwad +CENTR0, 53, 38, iwad +CENTS0, 43, 27, iwad +CENTT0, 43, 27, iwad +CLERM0, 28, 51, iwad +CLERN0, 26, 42, iwad +CLERO0, 26, 34, iwad +CLERQ0, 26, 16, iwad +CLERR0, 23, 67, iwad +CLERS0, 30, 67, iwad +CLERT0, 35, 68, iwad +CLERU0, 34, 64, iwad +CLERV0, 35, 61, iwad +CLERW0, 37, 53, iwad +CLERX0, 37, 43, iwad +CLERY0, 38, 30, iwad +CLERZ0, 38, 18, iwad +CLER[0, 38, 12, iwad +CPB1A0, 8, 7, iwad +CPB2A0, 7, 6, iwad +CPB3A0, 12, 4, iwad +CPB4A0, 5, 10, iwad +CPS2A0, 24, 13, iwad +CPS6A0, 22, 36, iwad +CTDPJ0, 21, 9, iwad +DEM2H0, 50, 92, iwad +DEM2I0, 67, 124, iwad +DEM2J0, 60, 121, iwad +DEM2K0, 76, 123, iwad +DEM2L0, 68, 115, iwad +DEM2M0, 71, 105, iwad +DEM2N0, 75, 76, iwad +DEM2O0, 75, 32, iwad +DEM2P0, 75, 17, iwad +DEMNH0, 50, 92, iwad +DEMNI0, 67, 124, iwad +DEMNJ0, 60, 121, iwad +DEMNK0, 76, 123, iwad +DEMNL0, 68, 115, iwad +DEMNM0, 71, 105, iwad +DEMNN0, 75, 76, iwad +DEMNO0, 75, 32, iwad +DEMNP0, 75, 17, iwad +DRAGM0, 45, 22, iwad +ETTBB0, 45, 73, iwad +ETTBC0, 39, 80, iwad +ETTBD0, 45, 87, iwad +ETTBE0, 51, 84, iwad +ETTBF0, 53, 74, iwad +ETTBG0, 48, 70, iwad +ETTBH0, 49, 64, iwad +ETTBI0, 50, 52, iwad +ETTBJ0, 50, 31, iwad +ETTBK0, 50, 22, iwad +ETTBL0, 50, 22, iwad +ETTBM0, 14, 20, iwad +ETTNO0, 42, 46, iwad +ETTNP0, 42, 56, iwad +ETTNQ0, 36, 34, iwad +FDTHA0, 29, 64, iwad +FDTHB0, 29, 64, iwad +FDTHE0, 28, 62, iwad +FDTHF0, 28, 62, iwad +FDTHG0, 29, 80, iwad +FDTHH0, 17, 76, iwad +FDTHI0, 19, 76, iwad +FDTHJ0, 20, 56, iwad +FDTHK0, 21, 51, iwad +FDTHL0, 21, 47, iwad +FDTHM0, 21, 46, iwad +FDTHN0, 21, 47, iwad +FDTHO0, 20, 49, iwad +FDTHP0, 21, 49, iwad +FDTHQ0, 19, 50, iwad +FDTHR0, 20, 51, iwad +FFLGA0, 4, 4, iwad +FFLGB0, 4, 11, iwad +FFLGC0, 6, 24, iwad +FFLGD0, 10, 28, iwad +FFLGE0, 6, 35, iwad +FFLGF0, 7, 40, iwad +FFLGG0, 7, 40, iwad +FFLGH0, 7, 34, iwad +FFLGI0, 7, 33, iwad +FFLGJ0, 7, 28, iwad +FFLGK0, 7, 28, iwad +FFLGL0, 7, 31, iwad +FFLGM0, 7, 34, iwad +FFLGN0, 7, 37, iwad +FFLGO0, 7, 39, iwad +FFLGP0, 7, 40, iwad +FFLGQ0, 7, 33, iwad +FFSMA0, 2, 20, iwad +FFSMB0, 2, 20, iwad +FFSMC0, 2, 18, iwad +FFSMD0, 2, 16, iwad +FFSME0, 2, 17, iwad +FSKLA0, 11, 54, iwad +FSKLB0, 11, 52, iwad +FSKLC0, 11, 50, iwad +FSKLD0, 11, 53, iwad +FSKLE0, 11, 47, iwad +FSKLF0, 11, 47, iwad +FSKLG0, 11, 53, iwad +FSKLH0, 11, 48, iwad +FSKLI0, 11, 51, iwad +GAR1A0, 25, 121, iwad +GAR2A0, 25, 121, iwad +GAR3A0, 25, 121, iwad +GAR4A0, 25, 121, iwad +GAR5A0, 25, 121, iwad +GAR6A0, 25, 75, iwad +GAR7A0, 25, 75, iwad +GAR8A0, 24, 75, iwad +GAR9A0, 25, 75, iwad +GMPDA0, 14, 46, iwad +GMPDB0, 14, 53, iwad +ICM4A0, 2, 23, iwad +IRONA0, 23, 62, iwad +LOGGA0, 20, 55, iwad +MAGEK0, 41, 42, iwad +MAGEL0, 43, 33, iwad +MAGEM0, 43, 21, iwad +MAGEN0, 31, 12, iwad +MAGEO0, 26, 71, iwad +MAGEP0, 30, 72, iwad +MAGEQ0, 33, 66, iwad +MAGER0, 34, 60, iwad +MAGES0, 36, 57, iwad +MAGET0, 37, 50, iwad +MAGEU0, 35, 39, iwad +MAGEV0, 36, 30, iwad +MAGEW0, 35, 18, iwad +MAGEX0, 35, 9, iwad +MSH1A0, 15, 25, iwad +MSH2A0, 13, 25, iwad +MSH3A0, 11, 21, iwad +MSH4A0, 7, 15, iwad +MSH5A0, 7, 11, iwad +MSH6A0, 6, 11, iwad +MSH7A0, 7, 12, iwad +MSH8A0, 5, 16, iwad +PIGYE0, 12, 24, iwad +PIGYF0, 17, 29, iwad +PIGYG0, 22, 41, iwad +PLAYL0, 36, 42, iwad +PLAYM0, 36, 31, iwad +PLAYN0, 40, 17, iwad +PLAYO0, 24, 72, iwad +PLAYP0, 31, 74, iwad +PLAYQ0, 35, 70, iwad +PLAYR0, 38, 64, iwad +PLAYS0, 38, 55, iwad +PLAYT0, 40, 44, iwad +PLAYU0, 40, 34, iwad +PLAYV0, 41, 28, iwad +PLAYW0, 39, 13, iwad +POT1A0, 10, 37, iwad +POT2A0, 10, 30, iwad +POT3A0, 12, 24, iwad +RBL1A0, 21, 9, iwad +RBL2A0, 14, 8, iwad +RBL3A0, 15, 10, iwad +RCK1A0, 7, 7, iwad +RCK2A0, 10, 11, iwad +RCK3A0, 14, 18, iwad +RCK4A0, 24, 22, iwad +RKBKA0, 30, 40, iwad +RKBSA0, 18, 50, iwad +ROKKA0, 11, 16, iwad +ROKKB0, 8, 11, iwad +ROKKC0, 4, 6, iwad +ROKKD0, 6, 6, iwad +ROKKE0, 4, 5, iwad +ROKKG0, 3, 5, iwad +ROKKH0, 3, 3, iwad +SGM1A0, 17, 69, iwad +SGM2A0, 12, 54, iwad +SGM3A0, 14, 44, iwad +SGMPA0, 18, 126, iwad +SHRMA0, 13, 25, iwad +SHRMB0, 15, 26, iwad +SHRMC0, 21, 36, iwad +SHRMD0, 23, 40, iwad +SHRME0, 17, 26, iwad +SHRMF0, 19, 15, iwad +SLTRA0, 23, 52, iwad +SORCH0, 29, 92, iwad +SORCI0, 34, 97, iwad +SORCJ0, 36, 98, iwad +SORCK0, 41, 101, iwad +SORCL0, 48, 97, iwad +SORCM0, 50, 97, iwad +SORCN0, 47, 97, iwad +SORCO0, 46, 97, iwad +SORCP0, 46, 95, iwad +SORCQ0, 34, 95, iwad +SORCR0, 34, 86, iwad +SORCS0, 34, 72, iwad +SORCT0, 34, 50, iwad +SORCU0, 34, 29, iwad +SORCV0, 40, 31, iwad +SORCW0, 52, 41, iwad +SORCX0, 54, 46, iwad +SORCY0, 48, 33, iwad +SORCZ0, 34, 12, iwad +SSPTO0, 36, 66, iwad +SSPTP0, 38, 73, iwad +SSPTQ0, 35, 69, iwad +SSPTR0, 33, 53, iwad +SSPTS0, 34, 52, iwad +SSPTT0, 44, 43, iwad +SSPTU0, 47, 30, iwad +SSPTV0, 41, 35, iwad +SSPTW0, 35, 43, iwad +SSPTX0, 29, 47, iwad +SSPTY0, 24, 33, iwad +SSPTZ0, 27, 17, iwad +SSXDA0, 36, 66, iwad +SSXDB0, 37, 68, iwad +SSXDC0, 52, 68, iwad +SSXDD0, 58, 54, iwad +SSXDE0, 59, 37, iwad +SSXDF0, 61, 22, iwad +SSXDG0, 57, 18, iwad +SSXDH0, 52, 13, iwad +STM1A0, 24, 39, iwad +STM2A0, 25, 32, iwad +STM3A0, 13, 25, iwad +STM4A0, 12, 34, iwad +STT2A0, 25, 121, iwad +STT3A0, 25, 121, iwad +STT4A0, 25, 75, iwad +STT5A0, 25, 75, iwad +STTWA0, 29, 83, iwad +STWNA0, 29, 83, iwad +STWNB0, 29, 83, iwad +ZSUIA0, 18, 80, iwad +ZSUIB0, 8, 8, iwad +ZSUIC0, 6, 11, iwad +ZSUID0, 6, 9, iwad +ZSUIE0, 9, 11, iwad +ZSUIF0, 6, 10, iwad +ZSUIG0, 4, 7, iwad +ZSUIH0, 12, 14, iwad +ZSUII0, 11, 7, iwad +ZSUIJ0, 7, 3, iwad +ZSUIK0, 13, 3, iwad +SWMVA0, 22, 68, iwad +TMS1A0, 19, 52, iwad +TMS2A0, 19, 52, iwad +TMS3A0, 20, 52, iwad +TMS4A0, 16, 58, iwad +TMS5A0, 18, 58, iwad +TMS6A0, 14, 54, iwad +TMS7A0, 15, 54, iwad +TRDTA0, 57, 187, iwad +TRDTB0, 76, 181, iwad +TRDTC0, 88, 153, iwad +TRDTD0, 84, 85, iwad +TRDTE0, 81, 52, iwad +TRDTF0, 61, 31, iwad +TRDTG0, 23, 31, iwad +TRDTH0, 58, 187, iwad +TRDTI0, 77, 183, iwad +TRDTJ0, 89, 191, iwad +TRDTK0, 85, 191, iwad +TRDTL0, 82, 156, iwad +TRDTM0, 62, 141, iwad +TRDTN0, 48, 140, iwad +TRDTO0, 48, 82, iwad +TRDTP0, 38, 39, iwad +TRDTQ0, 26, 39, iwad +ZTREA0, 43, 134, iwad +TRESA0, 51, 179, iwad +TRE4A0, 73, 187, iwad +TRE5A0, 72, 187, iwad +TRE6A0, 56, 122, iwad +TRE7A0, 55, 122, iwad +TSPKB0, 26, 131, iwad +TSPKD0, 22, 9, iwad +TST0A0, 12, 22, iwad +TST1A0, 6, 20, iwad +TST2A0, 6, 16, iwad +TST3A0, 9, 25, iwad +TST4A0, 6, 21, iwad +TST5A0, 6, 25, iwad +TST6A0, 8, 10, iwad +TST7A0, 6, 13, iwad +TST8A0, 6, 10, iwad +TST9A0, 6, 10, iwad +TWTRA0, 14, 79, iwad +TWTRB0, 14, 81, iwad +TWTRC0, 14, 83, iwad +TWTRD0, 14, 83, iwad +TWTRE0, 14, 79, iwad +TWTRF0, 14, 80, iwad +TWTRG0, 14, 82, iwad +TWTRH0, 14, 80, iwad +TWTRI0, 14, 65, iwad +VASEA0, 11, 53, iwad +XMASA0, 23, 150, iwad +XMASB0, 25, 151, iwad +XMASC0, 25, 151, iwad +XMASD0, 30, 151, iwad +XMASE0, 20, 151, iwad +XMASF0, 14, 156, iwad +XMASG0, 5, 163, iwad +XMASH0, 5, 152, iwad +XMASI0, 8, 132, iwad +XMASJ0, 10, 72, iwad +XMASK0, 13, 17, iwad +FHFXN0, 26, 21, iwad +CTDPG0, 15, 15, iwad +CTDPH0, 21, 7, iwad +CTDPI0, 17, 12, iwad +CTDPJ0, 21, 11, iwad +CTDPR0, 18, 12, iwad +CTDPS0, 21, 6, iwad +CTDPT0, 23, 3, iwad +ETTBM0, 14, 15, iwad +ETTBN0, 18, 8, iwad +ETTBO0, 15, 5, iwad +ETTBP0, 13, 8, iwad +ETTBQ0, 9, 16, iwad +ETTBR0, 18, 18, iwad +ETTBS0, 20, 15, iwad +THRWA0, 10, 15, iwad +THRWB0, 10, 18, iwad +THRWC0, 8, 20, iwad +THRWD0, 6, 18, iwad +THRWE0, 6, 16, iwad +THRWF0, 8, 19, iwad +THRWG0, 8, 19, iwad +THRWH0, 11, 19, iwad diff --git a/wadsrc/static/filter/strife/sprofs.txt b/wadsrc/static/filter/strife/sprofs.txt new file mode 100644 index 000000000..d7118297b --- /dev/null +++ b/wadsrc/static/filter/strife/sprofs.txt @@ -0,0 +1,364 @@ +TWAVA0, 47, 20, iwad +TWAVB0, 20, 15, iwad +ZAP5A0, 13, 6, iwad +ZAP5B0, 15, 6, iwad +ZAP5C0, 13, 6, iwad +ZAP5D0, 14, 6, iwad +BARTB0, 11, 31, iwad +BARTC0, 14, 31, iwad +BARTD0, 19, 34, iwad +BARTE0, 23, 36, iwad +BARTF0, 26, 40, iwad +BARTG0, 27, 43, iwad +BARTH0, 27, 44, iwad +BARTI0, 27, 45, iwad +BARTJ0, 27, 46, iwad +BARTK0, 27, 50, iwad +BARTL0, 27, 7, iwad +BARWB0, 12, 30, iwad +BARWC0, 14, 30, iwad +BARWD0, 15, 29, iwad +BARWE0, 15, 26, iwad +BARWF0, 18, 23, iwad +BARWG0, 19, 18, iwad +BARWH0, 19, 11, iwad +FLBEC0, 21, 51, iwad +FLBED0, 24, 77, iwad +DIE1A0, 27, 7, iwad +DEADA0, 31, 11, iwad +SACRA0, 31, 13, iwad +RGIBD0, 27, 48, iwad +RGIBE0, 27, 30, iwad +RGIBF0, 27, 17, iwad +RGIBG0, 27, 12, iwad +RGIBH0, 27, 10, iwad +GIBSM0, 18, 54, iwad +GIBSN0, 23, 58, iwad +GIBSO0, 23, 60, iwad +GIBSP0, 26, 54, iwad +GIBSQ0, 27, 42, iwad +GIBSR0, 27, 29, iwad +GIBSS0, 27, 19, iwad +GIBST0, 27, 11, iwad +GIBSU0, 27, 8, iwad +GIBSV0, 27, 7, iwad +GIBSA0, 28, 58, iwad +GIBSB0, 31, 62, iwad +GIBSC0, 31, 62, iwad +GIBSD0, 31, 60, iwad +GIBSE0, 31, 54, iwad +GIBSF0, 31, 38, iwad +GIBSG0, 31, 22, iwad +GIBSH0, 31, 13, iwad +GIBSI0, 31, 10, iwad +GIBSJ0, 31, 10, iwad +GIBSK0, 31, 10, iwad +GIBSL0, 31, 10, iwad +PLAYG0, 26, 54, iwad +PLAYN0, 24, 28, iwad +PLAYO0, 27, 22, iwad +PLAYP0, 27, 13, iwad +BURNA0, 15, 55, iwad +BURNB0, 23, 58, iwad +BURNC0, 23, 61, iwad +BURND0, 22, 67, iwad +BURNE0, 20, 65, iwad +BURNF0, 18, 69, iwad +BURNQ0, 23, 54, iwad +BURNR0, 23, 22, iwad +BURNS0, 23, 30, iwad +BURNT0, 23, 21, iwad +BURNU0, 23, 13, iwad +BURNV0, 23, 11, iwad +MRSTA0, 11, 59, iwad +MRLKA0, 11, 59, iwad +MRLKB0, 11, 59, iwad +MRBDA0, 11, 59, iwad +MRBDB0, 8, 59, iwad +MRBDC0, 8, 59, iwad +MRBDD0, 8, 59, iwad +MRBDE0, 8, 60, iwad +MRBDF0, 11, 59, iwad +MRYSA0, 16, 55, iwad +MRPNA0, 16, 50, iwad +MRPNB0, 11, 47, iwad +MRPNC0, 11, 43, iwad +MRPND0, 10, 41, iwad +MRGTA0, 17, 59, iwad +MRGTB0, 17, 59, iwad +MRGTC0, 19, 59, iwad +MRGTD0, 17, 59, iwad +MRGTE0, 17, 59, iwad +MRGTF0, 18, 59, iwad +MRGTG0, 16, 59, iwad +MRGTH0, 13, 59, iwad +MRGTI0, 14, 59, iwad +MRNOA0, 11, 59, iwad +MRNOB0, 11, 59, iwad +MRNOC0, 11, 58, iwad +ARMRA0, 31, 68, iwad +PEASG0, 14, 49, iwad +PEASH0, 11, 42, iwad +PEASI0, 12, 45, iwad +PEASJ0, 11, 43, iwad +PEASK0, 14, 37, iwad +PEASL0, 26, 16, iwad +PEASM0, 27, 13, iwad +PEASN0, 27, 13, iwad +BEGRF0, 10, 54, iwad +BEGRG0, 14, 58, iwad +BEGRH0, 18, 60, iwad +BEGRL0, 15, 37, iwad +BEGRM0, 17, 21, iwad +BEGRN0, 19, 10, iwad +HMN1G0, 23, 53, iwad +HMN1H0, 22, 50, iwad +HMN1J0, 20, 49, iwad +HMN1K0, 20, 45, iwad +HMN1L0, 20, 39, iwad +HMN1M0, 20, 24, iwad +HMN1N0, 20, 16, iwad +LEADG0, 26, 52, iwad +LEADH0, 24, 51, iwad +LEADI0, 23, 53, iwad +LEADJ0, 22, 51, iwad +LEADK0, 22, 49, iwad +LEADL0, 22, 47, iwad +LEADM0, 22, 49, iwad +LEADN0, 22, 53, iwad +LEADO0, 22, 50, iwad +LEADP0, 22, 43, iwad +LEADQ0, 31, 40, iwad +LEADR0, 31, 33, iwad +LEADS0, 31, 30, iwad +LEADT0, 31, 27, iwad +LEADU0, 31, 23, iwad +LEADV0, 31, 18, iwad +LEADW0, 31, 13, iwad +LEADX0, 31, 10, iwad +ROB2G0, 40, 67, iwad +ROB2H0, 48, 70, iwad +ROB2I0, 54, 92, iwad +ROB2J0, 48, 92, iwad +ROB2K0, 52, 79, iwad +ROB2L0, 58, 85, iwad +ROB2M0, 55, 92, iwad +ROB2N0, 51, 93, iwad +ROB2O0, 47, 98, iwad +SEWRI0, 46, 48, iwad +SEWRJ0, 29, 30, iwad +DISRA0, 23, 55, iwad +DISRB0, 23, 57, iwad +DISRC0, 22, 57, iwad +DISRD0, 16, 62, iwad +DISRE0, 19, 61, iwad +DISRF0, 19, 59, iwad +DISRG0, 22, 55, iwad +DISRH0, 23, 44, iwad +DISRI0, 23, 38, iwad +DISRJ0, 23, 32, iwad +PRGRA0, 51, 69, iwad +PRGRS0, 51, 28, iwad +PRGRT0, 51, 21, iwad +PRGRU0, 51, 20, iwad +PRGRV0, 51, 19, iwad +PRGRW0, 51, 19, iwad +PRGRX0, 51, 18, iwad +BASEG0, 35, 23, iwad +BASEH0, 35, 23, iwad +SPIDB1, 30, 34, iwad +SPIDB2, 37, 33, iwad +SPIDB3, 26, 34, iwad +SPIDB4, 37, 34, iwad +SPIDB5, 33, 32, iwad +SPIDB6, 37, 34, iwad +SPIDB7, 27, 34, iwad +SPIDB8, 37, 32, iwad +ROB3L0, 60, 122, iwad +ROB3M0, 65, 121, iwad +ROB3N0, 98, 114, iwad +ROB3O0, 94, 105, iwad +RBB3D0, 43, 43, iwad +RBB3E0, 43, 29, iwad +RBB3G0, 33, 46, iwad +RBB3H0, 37, 36, iwad +PGRDI0, 27, 56, iwad +PGRDJ0, 31, 56, iwad +PGRDK0, 35, 60, iwad +PGRDL0, 31, 61, iwad +PGRDM0, 27, 60, iwad +PGRDN0, 27, 63, iwad +PGRDO0, 31, 60, iwad +PGRDP0, 39, 53, iwad +PGRDQ0, 43, 39, iwad +PGRDR0, 43, 32, iwad +PGRDS0, 39, 26, iwad +PGRDT0, 35, 28, iwad +PGRDU0, 35, 28, iwad +PGRDV0, 35, 28, iwad +PGRDW0, 35, 28, iwad +PGRDX0, 35, 28, iwad +PGRDY0, 35, 28, iwad +PGRDZ0, 35, 28, iwad +PGRD[0, 35, 28, iwad +PGRD\0, 35, 28, iwad +PDEDE0, 22, 20, iwad +PDEDF0, 23, 16, iwad +PDEDG0, 23, 15, iwad +PDEDH0, 23, 15, iwad +PDEDI0, 23, 15, iwad +PDEDJ0, 23, 17, iwad +PDEDK0, 23, 20, iwad +PDEDL0, 23, 22, iwad +PDEDM0, 22, 23, iwad +PDEDN0, 22, 26, iwad +PDEDO0, 23, 26, iwad +PDEDP0, 23, 24, iwad +PDEDQ0, 23, 21, iwad +PDEDR0, 23, 15, iwad +PDEDS0, 23, 11, iwad +PDEDT0, 23, 5, iwad +ORCLB0, 23, 77, iwad +ORCLC0, 23, 70, iwad +ORCLD0, 23, 70, iwad +ORCLE0, 23, 70, iwad +ORCLF0, 23, 70, iwad +ORCLG0, 23, 70, iwad +ORCLH0, 23, 70, iwad +ORCLI0, 23, 71, iwad +ORCLJ0, 23, 68, iwad +ORCLK0, 23, 61, iwad +ORCLL0, 23, 53, iwad +ORCLM0, 23, 50, iwad +ORCLN0, 23, 45, iwad +ORCLO0, 23, 42, iwad +ORCLP0, 23, 42, iwad +ORCLQ0, 23, 42, iwad +NEALD0, 14, 48, iwad +NEALE0, 10, 43, iwad +NEALF0, 7, 38, iwad +NEALG0, 4, 35, iwad +NEALH0, 3, 32, iwad +NEALI0, 3, 28, iwad +NEALJ0, 3, 11, iwad +MLDRH0, 41, 131, iwad +MLDRI0, 54, 122, iwad +MLDRJ0, 57, 115, iwad +MLDRK0, 59, 127, iwad +MLDRL0, 72, 126, iwad +MLDRM0, 72, 134, iwad +MLDRN0, 63, 102, iwad +MLDRQ0, 38, 85, iwad +MLDRR0, 59, 61, iwad +MLDRT0, 55, 44, iwad +MLDRU0, 55, 44, iwad +MLDRV0, 55, 46, iwad +TRAYA0, 11, 39, iwad +RUB1A0, 4, 9, iwad +RUB2A0, 4, 10, iwad +RUB5A0, 2, 12, iwad +RUB7A0, 3, 12, iwad +RUB8A0, 4, 11, iwad +SPLHA0, 4, 8, iwad +SPLHB0, 4, 8, iwad +SPLHC0, 4, 8, iwad +SPLHD0, 4, 8, iwad +SPLHE0, 4, 8, iwad +SPLHF0, 4, 8, iwad +SPLHG0, 4, 7, iwad +CNDLA0, 4, 16, iwad +BARLA0, 12, 41, iwad +BARLB0, 12, 41, iwad +BARLC0, 12, 41, iwad +BARLD0, 12, 41, iwad +MUGGA0, 7, 11, iwad +VASEA0, 11, 22, iwad +STATA0, 19, 64, iwad +LTRHA0, 10, 70, iwad +LTRHB0, 10, 65, iwad +LTRHC0, 10, 69, iwad +LTRHD0, 10, 68, iwad +HERTA0, 15, 56, iwad +HERTB0, 15, 56, iwad +HERTC0, 15, 56, iwad +MONIA0, 19, 125, iwad +STELA0, 15, 127, iwad +STLEA0, 15, 40, iwad +VASEB0, 11, 31, iwad +STOLA0, 7, 23, iwad +POT1A0, 7, 13, iwad +LAMPA0, 11, 79, iwad +TUB1A0, 11, 14, iwad +TREEC0, 14, 63, iwad +BUSHA0, 15, 47, iwad +SHRBA0, 23, 63, iwad +BAR1A0, 15, 57, iwad +HUGEA0, 23, 190, iwad +HUGEB0, 23, 190, iwad +HUGEC0, 23, 190, iwad +HUGED0, 23, 190, iwad +STLGB0, 16, 60, iwad +STLGE0, 16, 100, iwad +STLGF0, 6, 31, iwad +TNK1A0, 15, 192, iwad +TNK1B0, 15, 192, iwad +TNK1C0, 15, 192, iwad +TNK2A0, 15, 192, iwad +TNK2B0, 15, 192, iwad +TNK2C0, 15, 192, iwad +TNK4A0, 15, 56, iwad +TNK4B0, 15, 56, iwad +TNK4C0, 15, 56, iwad +TNK3A0, 15, 192, iwad +TNK3B0, 15, 192, iwad +TNK3C0, 15, 192, iwad +TNK5A0, 15, 56, iwad +TNK5B0, 15, 56, iwad +TNK5C0, 15, 56, iwad +TNK6A0, 15, 56, iwad +TNK6B0, 15, 56, iwad +TNK6C0, 15, 56, iwad +APOWA0, 27, 198, iwad +LANTA0, 8, 79, iwad +LMPCA0, 11, 78, iwad +LMPCB0, 11, 78, iwad +LMPCC0, 11, 74, iwad +LMPCD0, 11, 78, iwad +LMPCE0, 11, 78, iwad +STLAA0, 15, 78, iwad +TLMPA0, 10, 63, iwad +TLMPB0, 11, 78, iwad +LOGSA0, 14, 91, iwad +LOGSB0, 14, 93, iwad +LOGSC0, 14, 93, iwad +LOGSD0, 14, 93, iwad +LOGSE0, 14, 93, iwad +HOGNA0, 23, 80, iwad +HOGNB0, 11, 80, iwad +HOGNC0, 2, 80, iwad +PSTNA0, 23, 128, iwad +PSTNB0, 23, 128, iwad +PSTNC0, 23, 128, iwad +PSTND0, 23, 128, iwad +PSTNE0, 23, 128, iwad +FLGRA0, 8, 39, iwad +FLGBA0, 8, 39, iwad +FLGGA0, 8, 39, iwad +PSTNF0, 23, 126, iwad +PSTNG0, 23, 94, iwad +PSTNH0, 23, 63, iwad +PSTNI0, 23, 15, iwad +STAKA0, 17, 127, iwad +COUPA0, 11, 22, iwad +COUPB0, 11, 22, iwad +COUPC0, 11, 22, iwad +AFEDA0, 11, 24, iwad +BOTRA0, 8, 16, iwad +HATRA0, 4, 13, iwad +TOPRA0, 12, 11, iwad +BUBBA0, 15, 127, iwad +BUBFA0, 15, 65, iwad +ASPRA0, 23, 127, iwad +SPDLA0, 30, 52, iwad +SPDLB0, 30, 52, iwad +SPDLC0, 30, 51, iwad From daf1a40521f51ccab5f9188b458b3a41abb0bbf4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 3 Dec 2016 20:09:25 +0100 Subject: [PATCH 1335/1509] - allow swapping the order of gl_finish and SwapBuffers calls, because some cards do not seem to like the correct order. --- src/gl/system/gl_framebuffer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 7102df72e..f20c9e502 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -207,17 +207,20 @@ void OpenGLFrameBuffer::Update() // //========================================================================== +CVAR(Bool, gl_finishbeforeswap, false, 0); + void OpenGLFrameBuffer::Swap() { Finish.Reset(); Finish.Clock(); - if (needsetgamma) + if (gl_finishbeforeswap) glFinish(); + if (needsetgamma) { //DoSetGamma(); needsetgamma = false; } SwapBuffers(); - glFinish(); + if (!gl_finishbeforeswap) glFinish(); Finish.Unclock(); swapped = true; FHardwareTexture::UnbindAll(); From 36f168040edc49bdfe9ee8cd7fcda8db5c32b967 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 4 Dec 2016 03:12:40 +0100 Subject: [PATCH 1336/1509] Fix null pointer crash bug --- src/r_poly_wall.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index 4dd24887d..384529da0 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -38,7 +38,7 @@ EXTERN_CVAR(Bool, r_drawmirrors) bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals) { PolyDrawLinePortal *polyportal = nullptr; - if (line->backsector == nullptr && line->sidedef == line->linedef->sidedef[0] && (line->linedef->special == Line_Mirror && r_drawmirrors)) + if (line->backsector == nullptr && line->linedef && line->sidedef == line->linedef->sidedef[0] && (line->linedef->special == Line_Mirror && r_drawmirrors)) { linePortals.push_back(std::make_unique(line->linedef)); polyportal = linePortals.back().get(); From 2e1e2028124c9bbe106fc9033fcdd78800da8ef2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 4 Dec 2016 05:52:13 +0100 Subject: [PATCH 1337/1509] Add linear filtering --- .../fixedfunction/drawtrianglecodegen.cpp | 154 ++++++++++++------ .../fixedfunction/drawtrianglecodegen.h | 9 +- 2 files changed, 109 insertions(+), 54 deletions(-) diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index 75acffac9..3806d5253 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -334,6 +334,9 @@ void DrawTriangleCodegen::SetupAffineBlock() AffineVaryingPosX[i] = SSAInt(AffineVaryingPosY[i] * rcpW0, false); AffineVaryingStepX[i] = (SSAInt((AffineVaryingPosY[i] + gradVaryingX[i]) * rcpW1, false) - AffineVaryingPosX[i]) / q; } + + // Min filter = linear, Mag filter = nearest: + AffineLinear = (gradVaryingX[0] / AffineW) > SSAFloat(1.0f) || (gradVaryingX[0] / AffineW) < SSAFloat(-1.0f); } void DrawTriangleCodegen::LoopFullBlock() @@ -739,32 +742,97 @@ void DrawTriangleCodegen::LoopMaskedStoreBlock() } #endif -SSAVec4i DrawTriangleCodegen::TranslateSample32(SSAInt uvoffset) +SSAVec4i DrawTriangleCodegen::TranslateSample32(SSAInt *varying) { + SSAInt ufrac = varying[0] << 8; + SSAInt vfrac = varying[1] << 8; + + SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; + SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; + SSAInt uvoffset = upos * textureHeight + vpos; + if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) return translation[color * 4].load_vec4ub(true); else return translation[texturePixels[uvoffset].load(true).zext_int() * 4].load_vec4ub(true); } -SSAInt DrawTriangleCodegen::TranslateSample8(SSAInt uvoffset) +SSAInt DrawTriangleCodegen::TranslateSample8(SSAInt *varying) { + SSAInt ufrac = varying[0] << 8; + SSAInt vfrac = varying[1] << 8; + + SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; + SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; + SSAInt uvoffset = upos * textureHeight + vpos; + if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) return translation[color].load(true).zext_int(); else return translation[texturePixels[uvoffset].load(true).zext_int()].load(true).zext_int(); } -SSAVec4i DrawTriangleCodegen::Sample32(SSAInt uvoffset) +SSAVec4i DrawTriangleCodegen::Sample32(SSAInt *varying) { if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) return SSAVec4i::unpack(color); - else - return texturePixels[uvoffset * 4].load_vec4ub(true); + + SSAInt ufrac = varying[0] << 8; + SSAInt vfrac = varying[1] << 8; + + SSAVec4i nearest; + SSAVec4i linear; + + { + SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; + SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; + SSAInt uvoffset = upos * textureHeight + vpos; + + nearest = texturePixels[uvoffset * 4].load_vec4ub(true); + } + + { + SSAInt uone = (SSAInt(0x01000000) / textureWidth) << 8; + SSAInt vone = (SSAInt(0x01000000) / textureHeight) << 8; + + ufrac = ufrac - (uone >> 1); + vfrac = vfrac - (vone >> 1); + + SSAInt frac_x0 = (ufrac >> FRACBITS) * textureWidth; + SSAInt frac_x1 = ((ufrac + uone) >> FRACBITS) * textureWidth; + SSAInt frac_y0 = (vfrac >> FRACBITS) * textureHeight; + SSAInt frac_y1 = ((vfrac + vone) >> FRACBITS) * textureHeight; + + SSAInt x0 = frac_x0 >> FRACBITS; + SSAInt x1 = frac_x1 >> FRACBITS; + SSAInt y0 = frac_y0 >> FRACBITS; + SSAInt y1 = frac_y1 >> FRACBITS; + + SSAVec4i p00 = texturePixels[(x0 * textureHeight + y0) * 4].load_vec4ub(true); + SSAVec4i p01 = texturePixels[(x0 * textureHeight + y1) * 4].load_vec4ub(true); + SSAVec4i p10 = texturePixels[(x1 * textureHeight + y0) * 4].load_vec4ub(true); + SSAVec4i p11 = texturePixels[(x1 * textureHeight + y1) * 4].load_vec4ub(true); + + SSAInt inv_b = (frac_x1 >> (FRACBITS - 4)) & 15; + SSAInt inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; + SSAInt a = 16 - inv_a; + SSAInt b = 16 - inv_b; + + linear = (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; + } + + return AffineLinear.select(linear, nearest); } -SSAInt DrawTriangleCodegen::Sample8(SSAInt uvoffset) +SSAInt DrawTriangleCodegen::Sample8(SSAInt *varying) { + SSAInt ufrac = varying[0] << 8; + SSAInt vfrac = varying[1] << 8; + + SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; + SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; + SSAInt uvoffset = upos * textureHeight + vpos; + if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) return color; else @@ -778,13 +846,6 @@ SSAInt DrawTriangleCodegen::Shade8(SSAInt c) SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) { - SSAInt ufrac = varying[0] << 8; - SSAInt vfrac = varying[1] << 8; - - SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; - SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; - SSAInt uvoffset = upos * textureHeight + vpos; - SSAVec4i fg; SSAVec4i output; @@ -792,62 +853,62 @@ SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) { default: case TriBlendMode::Copy: - fg = Sample32(uvoffset); + fg = Sample32(varying); output = blend_copy(shade_bgra_simple(fg, currentlight)); break; case TriBlendMode::AlphaBlend: - fg = Sample32(uvoffset); + fg = Sample32(varying); output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); break; case TriBlendMode::AddSolid: - fg = Sample32(uvoffset); + fg = Sample32(varying); output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, destalpha); break; case TriBlendMode::Add: - fg = Sample32(uvoffset); + fg = Sample32(varying); output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; case TriBlendMode::Sub: - fg = Sample32(uvoffset); + fg = Sample32(varying); output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; case TriBlendMode::RevSub: - fg = Sample32(uvoffset); + fg = Sample32(varying); output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; case TriBlendMode::Stencil: - fg = Sample32(uvoffset); + fg = Sample32(varying); output = blend_stencil(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), fg[3], bg, srcalpha, destalpha); break; case TriBlendMode::Shaded: - output = blend_stencil(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), Sample8(uvoffset), bg, srcalpha, destalpha); + output = blend_stencil(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), Sample8(varying), bg, srcalpha, destalpha); break; case TriBlendMode::TranslateCopy: - fg = TranslateSample32(uvoffset); + fg = TranslateSample32(varying); output = blend_copy(shade_bgra_simple(fg, currentlight)); break; case TriBlendMode::TranslateAlphaBlend: - fg = TranslateSample32(uvoffset); + fg = TranslateSample32(varying); output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); break; case TriBlendMode::TranslateAdd: - fg = TranslateSample32(uvoffset); + fg = TranslateSample32(varying); output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; case TriBlendMode::TranslateSub: - fg = TranslateSample32(uvoffset); + fg = TranslateSample32(varying); output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; case TriBlendMode::TranslateRevSub: - fg = TranslateSample32(uvoffset); + fg = TranslateSample32(varying); output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; case TriBlendMode::AddSrcColorOneMinusSrcColor: - fg = Sample32(uvoffset); + fg = Sample32(varying); output = blend_add_srccolor_oneminussrccolor(shade_bgra_simple(fg, currentlight), bg); break; case TriBlendMode::Skycap: - fg = Sample32(uvoffset); + fg = Sample32(varying); output = FadeOut(varying[1], fg); break; } @@ -869,13 +930,6 @@ SSAInt DrawTriangleCodegen::ToPal8(SSAVec4i c) SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) { - SSAInt ufrac = varying[0] << 8; - SSAInt vfrac = varying[1] << 8; - - SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; - SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; - SSAInt uvoffset = upos * textureHeight + vpos; - SSAVec4i fg; SSAInt alpha, inv_alpha; SSAInt output; @@ -885,80 +939,80 @@ SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) { default: case TriBlendMode::Copy: - output = Shade8(Sample8(uvoffset)); + output = Shade8(Sample8(varying)); break; case TriBlendMode::AlphaBlend: - palindex = Sample8(uvoffset); + palindex = Sample8(varying); output = Shade8(palindex); output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::AddSolid: - palindex = Sample8(uvoffset); + palindex = Sample8(varying); fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, destalpha)); output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::Add: - palindex = Sample8(uvoffset); + palindex = Sample8(varying); fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::Sub: - palindex = Sample8(uvoffset); + palindex = Sample8(varying); fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_sub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::RevSub: - palindex = Sample8(uvoffset); + palindex = Sample8(varying); fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_revsub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::Stencil: - output = ToPal8(blend_stencil(ToBgra(Shade8(color)), (Sample8(uvoffset) == SSAInt(0)).select(SSAInt(0), SSAInt(256)), ToBgra(bg), srcalpha, destalpha)); + output = ToPal8(blend_stencil(ToBgra(Shade8(color)), (Sample8(varying) == SSAInt(0)).select(SSAInt(0), SSAInt(256)), ToBgra(bg), srcalpha, destalpha)); break; case TriBlendMode::Shaded: - palindex = Sample8(uvoffset); + palindex = Sample8(varying); output = ToPal8(blend_stencil(ToBgra(Shade8(color)), palindex, ToBgra(bg), srcalpha, destalpha)); break; case TriBlendMode::TranslateCopy: - palindex = TranslateSample8(uvoffset); + palindex = TranslateSample8(varying); output = Shade8(palindex); output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::TranslateAlphaBlend: - palindex = TranslateSample8(uvoffset); + palindex = TranslateSample8(varying); output = Shade8(palindex); output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::TranslateAdd: - palindex = TranslateSample8(uvoffset); + palindex = TranslateSample8(varying); fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::TranslateSub: - palindex = TranslateSample8(uvoffset); + palindex = TranslateSample8(varying); fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_sub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::TranslateRevSub: - palindex = TranslateSample8(uvoffset); + palindex = TranslateSample8(varying); fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_revsub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::AddSrcColorOneMinusSrcColor: - palindex = Sample8(uvoffset); + palindex = Sample8(varying); fg = ToBgra(Shade8(palindex)); output = ToPal8(blend_add_srccolor_oneminussrccolor(fg, ToBgra(bg))); output = (palindex == SSAInt(0)).select(bg, output); break; case TriBlendMode::Skycap: - fg = ToBgra(Sample8(uvoffset)); + fg = ToBgra(Sample8(varying)); output = ToPal8(FadeOut(varying[1], fg)); break; } diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.h b/tools/drawergen/fixedfunction/drawtrianglecodegen.h index 1f22cf0a8..81a5e57d2 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.h +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.h @@ -50,10 +50,10 @@ private: SSAVec4i ProcessPixel32(SSAVec4i bg, SSAInt *varying); SSAInt ProcessPixel8(SSAInt bg, SSAInt *varying); - SSAVec4i TranslateSample32(SSAInt uvoffset); - SSAInt TranslateSample8(SSAInt uvoffset); - SSAVec4i Sample32(SSAInt uvoffset); - SSAInt Sample8(SSAInt uvoffset); + SSAVec4i TranslateSample32(SSAInt *varying); + SSAInt TranslateSample8(SSAInt *varying); + SSAVec4i Sample32(SSAInt *varying); + SSAInt Sample8(SSAInt *varying); SSAInt Shade8(SSAInt c); SSAVec4i ToBgra(SSAInt index); SSAInt ToPal8(SSAVec4i c); @@ -143,6 +143,7 @@ private: SSAInt currentlight; SSAUBytePtr currentcolormap; SSAFloat AffineW; + SSABool AffineLinear; SSAFloat AffineVaryingPosY[TriVertex::NumVarying]; SSAInt AffineVaryingPosX[TriVertex::NumVarying]; SSAInt AffineVaryingStepX[TriVertex::NumVarying]; From c59925085c5a9f59293abd96d2f51f962e2f3d8b Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 4 Dec 2016 10:05:01 -0500 Subject: [PATCH 1338/1509] - Removal of the ASM functions resulted in failed compile when NO_ASM is set. --- src/r_draw.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index 06227167b..290256d58 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -247,6 +247,8 @@ extern void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip); +void R_DrawColumnHorizP_C(void); + #ifdef X86_ASM extern "C" void R_DrawColumnP_Unrolled (void); @@ -258,8 +260,6 @@ extern "C" void R_DrawFuzzColumnP_ASM (void); extern "C" void R_DrawSpanP_ASM (void); extern "C" void R_DrawSpanMaskedP_ASM (void); -void R_DrawColumnHorizP_C(void); - #else void R_DrawColumnP_C (void); From 86c1bbcdeb8706bb3d92004f6d0f0c35dd830240 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 4 Dec 2016 18:19:01 +0100 Subject: [PATCH 1339/1509] Split drawergen file into more files --- tools/drawergen/CMakeLists.txt | 2 + tools/drawergen/drawergen.cpp | 575 +------------------------------- tools/drawergen/exception.h | 36 ++ tools/drawergen/llvmdrawers.cpp | 376 +++++++++++++++++++++ tools/drawergen/llvmdrawers.h | 68 ++++ tools/drawergen/llvmprogram.cpp | 171 ++++++++++ tools/drawergen/llvmprogram.h | 41 +++ 7 files changed, 696 insertions(+), 573 deletions(-) create mode 100644 tools/drawergen/exception.h create mode 100644 tools/drawergen/llvmdrawers.cpp create mode 100644 tools/drawergen/llvmdrawers.h create mode 100644 tools/drawergen/llvmprogram.cpp create mode 100644 tools/drawergen/llvmprogram.h diff --git a/tools/drawergen/CMakeLists.txt b/tools/drawergen/CMakeLists.txt index dc9fefb17..d330e799a 100644 --- a/tools/drawergen/CMakeLists.txt +++ b/tools/drawergen/CMakeLists.txt @@ -113,6 +113,8 @@ endif() set (SOURCES drawergen.cpp + llvmprogram.cpp + llvmdrawers.cpp ssa/ssa_bool.cpp ssa/ssa_float.cpp ssa/ssa_float_ptr.cpp diff --git a/tools/drawergen/drawergen.cpp b/tools/drawergen/drawergen.cpp index c31b0229d..ecf87062e 100644 --- a/tools/drawergen/drawergen.cpp +++ b/tools/drawergen/drawergen.cpp @@ -22,579 +22,8 @@ #include "precomp.h" #include "timestamp.h" -#include "fixedfunction/drawspancodegen.h" -#include "fixedfunction/drawwallcodegen.h" -#include "fixedfunction/drawcolumncodegen.h" -#include "fixedfunction/drawskycodegen.h" -#include "fixedfunction/drawtrianglecodegen.h" -#include "ssa/ssa_function.h" -#include "ssa/ssa_scope.h" -#include "ssa/ssa_for_block.h" -#include "ssa/ssa_if_block.h" -#include "ssa/ssa_stack.h" -#include "ssa/ssa_function.h" -#include "ssa/ssa_struct_type.h" -#include "ssa/ssa_value.h" -#include "ssa/ssa_barycentric_weight.h" -#include - -class Exception : public std::exception -{ -public: - Exception(const std::string &message) : message(message) { } - const char *what() const noexcept override { return message.c_str(); } - -private: - std::string message; -}; - -class LLVMProgram -{ -public: - LLVMProgram(); - - void CreateModule(); - std::vector GenerateObjectFile(const std::string &triple, const std::string &cpuName, const std::string &features); - std::string DumpModule(); - - llvm::LLVMContext &context() { return *mContext; } - llvm::Module *module() { return mModule.get(); } - -private: - llvm::TargetMachine *machine = nullptr; - std::unique_ptr mContext; - std::unique_ptr mModule; -}; - -class LLVMDrawers -{ -public: - LLVMDrawers(const std::string &triple, const std::string &cpuName, const std::string &features, const std::string namePostfix); - - std::vector ObjectFile; - -private: - void CodegenDrawColumn(const char *name, DrawColumnVariant variant, DrawColumnMethod method); - void CodegenDrawSpan(const char *name, DrawSpanVariant variant); - void CodegenDrawWall(const char *name, DrawWallVariant variant, int columns); - void CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns); - void CodegenDrawTriangle(const std::string &name, TriDrawVariant variant, TriBlendMode blendmode, bool truecolor); - - static llvm::Type *GetDrawColumnArgsStruct(llvm::LLVMContext &context); - static llvm::Type *GetDrawSpanArgsStruct(llvm::LLVMContext &context); - static llvm::Type *GetDrawWallArgsStruct(llvm::LLVMContext &context); - static llvm::Type *GetDrawSkyArgsStruct(llvm::LLVMContext &context); - static llvm::Type *GetWorkerThreadDataStruct(llvm::LLVMContext &context); - static llvm::Type *GetTriVertexStruct(llvm::LLVMContext &context); - static llvm::Type *GetTriMatrixStruct(llvm::LLVMContext &context); - static llvm::Type *GetTriUniformsStruct(llvm::LLVMContext &context); - static llvm::Type *GetTriDrawTriangleArgs(llvm::LLVMContext &context); - - LLVMProgram mProgram; - std::string mNamePostfix; -}; - -///////////////////////////////////////////////////////////////////////////// - -LLVMDrawers::LLVMDrawers(const std::string &triple, const std::string &cpuName, const std::string &features, const std::string namePostfix) : mNamePostfix(namePostfix) -{ - mProgram.CreateModule(); - - CodegenDrawColumn("FillColumn", DrawColumnVariant::Fill, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnAdd", DrawColumnVariant::FillAdd, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnAddClamp", DrawColumnVariant::FillAddClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnSubClamp", DrawColumnVariant::FillSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnRevSubClamp", DrawColumnVariant::FillRevSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumn", DrawColumnVariant::Draw, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnAdd", DrawColumnVariant::DrawAdd, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnShaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnAddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnSubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnRevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnTranslated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnTlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnAddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnSubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnRevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnRt1", DrawColumnVariant::Draw, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt4", DrawColumnVariant::Draw, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt4); - CodegenDrawSpan("DrawSpan", DrawSpanVariant::Opaque); - CodegenDrawSpan("DrawSpanMasked", DrawSpanVariant::Masked); - CodegenDrawSpan("DrawSpanTranslucent", DrawSpanVariant::Translucent); - CodegenDrawSpan("DrawSpanMaskedTranslucent", DrawSpanVariant::MaskedTranslucent); - CodegenDrawSpan("DrawSpanAddClamp", DrawSpanVariant::AddClamp); - CodegenDrawSpan("DrawSpanMaskedAddClamp", DrawSpanVariant::MaskedAddClamp); - CodegenDrawWall("vlinec1", DrawWallVariant::Opaque, 1); - CodegenDrawWall("vlinec4", DrawWallVariant::Opaque, 4); - CodegenDrawWall("mvlinec1", DrawWallVariant::Masked, 1); - CodegenDrawWall("mvlinec4", DrawWallVariant::Masked, 4); - CodegenDrawWall("tmvline1_add", DrawWallVariant::Add, 1); - CodegenDrawWall("tmvline4_add", DrawWallVariant::Add, 4); - CodegenDrawWall("tmvline1_addclamp", DrawWallVariant::AddClamp, 1); - CodegenDrawWall("tmvline4_addclamp", DrawWallVariant::AddClamp, 4); - CodegenDrawWall("tmvline1_subclamp", DrawWallVariant::SubClamp, 1); - CodegenDrawWall("tmvline4_subclamp", DrawWallVariant::SubClamp, 4); - CodegenDrawWall("tmvline1_revsubclamp", DrawWallVariant::RevSubClamp, 1); - CodegenDrawWall("tmvline4_revsubclamp", DrawWallVariant::RevSubClamp, 4); - CodegenDrawSky("DrawSky1", DrawSkyVariant::Single, 1); - CodegenDrawSky("DrawSky4", DrawSkyVariant::Single, 4); - CodegenDrawSky("DrawDoubleSky1", DrawSkyVariant::Double, 1); - CodegenDrawSky("DrawDoubleSky4", DrawSkyVariant::Double, 4); - for (int i = 0; i < NumTriBlendModes(); i++) - { - CodegenDrawTriangle("TriDrawNormal8_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, false); - CodegenDrawTriangle("TriDrawNormal32_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, true); - CodegenDrawTriangle("TriFillNormal8_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, false); - CodegenDrawTriangle("TriFillNormal32_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, true); - CodegenDrawTriangle("TriDrawSubsector8_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, false); - CodegenDrawTriangle("TriDrawSubsector32_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, true); - CodegenDrawTriangle("TriFillSubsector8_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, false); - CodegenDrawTriangle("TriFillSubsector32_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, true); - } - CodegenDrawTriangle("TriStencil", TriDrawVariant::Stencil, TriBlendMode::Copy, false); - CodegenDrawTriangle("TriStencilClose", TriDrawVariant::StencilClose, TriBlendMode::Copy, false); - - ObjectFile = mProgram.GenerateObjectFile(triple, cpuName, features); -} - -void LLVMDrawers::CodegenDrawColumn(const char *name, DrawColumnVariant variant, DrawColumnMethod method) -{ - llvm::IRBuilder<> builder(mProgram.context()); - SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); - - SSAFunction function(name + mNamePostfix); - function.add_parameter(GetDrawColumnArgsStruct(mProgram.context())); - function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); - function.create_public(); - - DrawColumnCodegen codegen; - codegen.Generate(variant, method, function.parameter(0), function.parameter(1)); - - builder.CreateRetVoid(); - - if (llvm::verifyFunction(*function.func)) - throw Exception("verifyFunction failed for CodegenDrawColumn()"); -} - -void LLVMDrawers::CodegenDrawSpan(const char *name, DrawSpanVariant variant) -{ - llvm::IRBuilder<> builder(mProgram.context()); - SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); - - SSAFunction function(name + mNamePostfix); - function.add_parameter(GetDrawSpanArgsStruct(mProgram.context())); - function.create_public(); - - DrawSpanCodegen codegen; - codegen.Generate(variant, function.parameter(0)); - - builder.CreateRetVoid(); - - if (llvm::verifyFunction(*function.func)) - throw Exception("verifyFunction failed for CodegenDrawSpan()"); -} - -void LLVMDrawers::CodegenDrawWall(const char *name, DrawWallVariant variant, int columns) -{ - llvm::IRBuilder<> builder(mProgram.context()); - SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); - - SSAFunction function(name + mNamePostfix); - function.add_parameter(GetDrawWallArgsStruct(mProgram.context())); - function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); - function.create_public(); - - DrawWallCodegen codegen; - codegen.Generate(variant, columns == 4, function.parameter(0), function.parameter(1)); - - builder.CreateRetVoid(); - - if (llvm::verifyFunction(*function.func)) - throw Exception("verifyFunction failed for CodegenDrawWall()"); -} - -void LLVMDrawers::CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns) -{ - llvm::IRBuilder<> builder(mProgram.context()); - SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); - - SSAFunction function(name + mNamePostfix); - function.add_parameter(GetDrawSkyArgsStruct(mProgram.context())); - function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); - function.create_public(); - - DrawSkyCodegen codegen; - codegen.Generate(variant, columns == 4, function.parameter(0), function.parameter(1)); - - builder.CreateRetVoid(); - - if (llvm::verifyFunction(*function.func)) - throw Exception("verifyFunction failed for CodegenDrawSky()"); -} - -void LLVMDrawers::CodegenDrawTriangle(const std::string &name, TriDrawVariant variant, TriBlendMode blendmode, bool truecolor) -{ - llvm::IRBuilder<> builder(mProgram.context()); - SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); - - SSAFunction function(name + mNamePostfix); - function.add_parameter(GetTriDrawTriangleArgs(mProgram.context())); - function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); - function.create_public(); - - DrawTriangleCodegen codegen; - codegen.Generate(variant, blendmode, truecolor, function.parameter(0), function.parameter(1)); - - builder.CreateRetVoid(); - - if (llvm::verifyFunction(*function.func)) - throw Exception(std::string("verifyFunction failed for CodegenDrawTriangle(") + std::to_string((int)variant) + ", " + std::to_string((int)blendmode) + ", " + std::to_string((int)truecolor) + ")"); -} - -llvm::Type *LLVMDrawers::GetDrawColumnArgsStruct(llvm::LLVMContext &context) -{ - std::vector elements; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint32_t *dest; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source2; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *colormap; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *translation; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *basecolors; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t pitch; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t count; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t dest_y; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t iscale; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t texturefracx; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureheight; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t texturefrac; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t color; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srccolor; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - return llvm::StructType::create(context, elements, "DrawColumnArgs", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawers::GetDrawSpanArgsStruct(llvm::LLVMContext &context) -{ - std::vector elements; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *destorg; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t destpitch; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xfrac; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t yfrac; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xstep; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ystep; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x1; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x2; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t y; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xbits; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ybits; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - return llvm::StructType::create(context, elements, "DrawSpanArgs", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawers::GetDrawWallArgsStruct(llvm::LLVMContext &context) -{ - std::vector elements; - elements.push_back(llvm::Type::getInt8PtrTy(context)); - for (int i = 0; i < 8; i++) - elements.push_back(llvm::Type::getInt8PtrTy(context)); - for (int i = 0; i < 25; i++) - elements.push_back(llvm::Type::getInt32Ty(context)); - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - return llvm::StructType::create(context, elements, "DrawWallArgs", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawers::GetDrawSkyArgsStruct(llvm::LLVMContext &context) -{ - std::vector elements; - elements.push_back(llvm::Type::getInt8PtrTy(context)); - for (int i = 0; i < 8; i++) - elements.push_back(llvm::Type::getInt8PtrTy(context)); - for (int i = 0; i < 15; i++) - elements.push_back(llvm::Type::getInt32Ty(context)); - return llvm::StructType::create(context, elements, "DrawSkyArgs", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawers::GetWorkerThreadDataStruct(llvm::LLVMContext &context) -{ - std::vector elements; - for (int i = 0; i < 4; i++) - elements.push_back(llvm::Type::getInt32Ty(context)); - elements.push_back(llvm::Type::getInt8PtrTy(context)); - return llvm::StructType::create(context, elements, "ThreadData", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawers::GetTriVertexStruct(llvm::LLVMContext &context) -{ - std::vector elements; - for (int i = 0; i < 4 + TriVertex::NumVarying; i++) - elements.push_back(llvm::Type::getFloatTy(context)); - return llvm::StructType::create(context, elements, "TriVertex", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawers::GetTriMatrixStruct(llvm::LLVMContext &context) -{ - std::vector elements; - for (int i = 0; i < 4 * 4; i++) - elements.push_back(llvm::Type::getFloatTy(context)); - return llvm::StructType::create(context, elements, "TriMatrix", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawers::GetTriUniformsStruct(llvm::LLVMContext &context) -{ - std::vector elements; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t subsectorDepth; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t color; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; - elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - elements.push_back(GetTriMatrixStruct(context)); // TriMatrix objectToClip - return llvm::StructType::create(context, elements, "TriUniforms", false)->getPointerTo(); -} - -llvm::Type *LLVMDrawers::GetTriDrawTriangleArgs(llvm::LLVMContext &context) -{ - std::vector elements; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *dest; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t pitch; - elements.push_back(GetTriVertexStruct(context)); // TriVertex *v1; - elements.push_back(GetTriVertexStruct(context)); // TriVertex *v2; - elements.push_back(GetTriVertexStruct(context)); // TriVertex *v3; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipleft; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipright; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t cliptop; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipbottom; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *texturePixels; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureWidth; - elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureHeight; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *translation; - elements.push_back(GetTriUniformsStruct(context)); // const TriUniforms *uniforms; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *stencilValues; - elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *stencilMasks; - elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t stencilPitch; - elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilTestValue; - elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilWriteValue; - elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *subsectorGBuffer; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *colormaps; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *RGB32k; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *BaseColors; - return llvm::StructType::create(context, elements, "TriDrawTriangle", false)->getPointerTo(); -} - -///////////////////////////////////////////////////////////////////////////// - -LLVMProgram::LLVMProgram() -{ - mContext = std::make_unique(); -} - -void LLVMProgram::CreateModule() -{ - mModule = std::make_unique("render", context()); -} - -std::vector LLVMProgram::GenerateObjectFile(const std::string &triple, const std::string &cpuName, const std::string &features) -{ - using namespace llvm; - - std::string errorstring; - - llvm::Module *module = mModule.get(); - - const Target *target = TargetRegistry::lookupTarget(triple, errorstring); - -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) - Reloc::Model relocationModel = Reloc::PIC_; -#else - Optional relocationModel = Reloc::PIC_; -#endif - - CodeModel::Model codeModel = CodeModel::Model::Default; - - TargetOptions options; - options.LessPreciseFPMADOption = true; - options.AllowFPOpFusion = FPOpFusion::Fast; - options.UnsafeFPMath = true; - options.NoInfsFPMath = true; - options.NoNaNsFPMath = true; - options.HonorSignDependentRoundingFPMathOption = false; - options.NoZerosInBSS = false; - options.GuaranteedTailCallOpt = false; - options.StackAlignmentOverride = 0; - options.UseInitArray = true; - options.DataSections = false; - options.FunctionSections = false; - options.JTType = JumpTable::Single; // Create a single table for all jumptable functions - options.ThreadModel = ThreadModel::POSIX; - options.DisableIntegratedAS = false; - options.MCOptions.SanitizeAddress = false; - options.MCOptions.MCRelaxAll = false; // relax all fixups in the emitted object file - options.MCOptions.DwarfVersion = 0; - options.MCOptions.ShowMCInst = false; - options.MCOptions.ABIName = ""; - options.MCOptions.MCFatalWarnings = false; - options.MCOptions.ShowMCEncoding = false; // Show encoding in .s output - options.MCOptions.MCUseDwarfDirectory = false; - options.MCOptions.AsmVerbose = true; - -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9) - options.Reciprocals = TargetRecip({ "all" }); - options.StackSymbolOrdering = true; - options.UniqueSectionNames = true; - options.EmulatedTLS = false; - options.ExceptionModel = ExceptionHandling::None; - options.EABIVersion = EABI::Default; - options.DebuggerTuning = DebuggerKind::Default; - options.MCOptions.MCIncrementalLinkerCompatible = false; - options.MCOptions.MCNoWarn = false; - options.MCOptions.PreserveAsmComments = true; -#endif - - CodeGenOpt::Level optimizationLevel = CodeGenOpt::Aggressive; - machine = target->createTargetMachine(triple, cpuName, features, options, relocationModel, codeModel, optimizationLevel); - - -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - std::string targetTriple = machine->getTargetTriple(); -#else - std::string targetTriple = machine->getTargetTriple().getTriple(); -#endif - - module->setTargetTriple(targetTriple); -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - module->setDataLayout(new DataLayout(*machine->getSubtargetImpl()->getDataLayout())); -#else - module->setDataLayout(machine->createDataLayout()); -#endif - - legacy::FunctionPassManager PerFunctionPasses(module); - legacy::PassManager PerModulePasses; - -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8) - PerFunctionPasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); - PerModulePasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); -#endif - - SmallString<16 * 1024> str; -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - raw_svector_ostream vecstream(str); - formatted_raw_ostream stream(vecstream); -#else - raw_svector_ostream stream(str); -#endif - machine->addPassesToEmitFile(PerModulePasses, stream, TargetMachine::CGFT_ObjectFile); - - PassManagerBuilder passManagerBuilder; - passManagerBuilder.OptLevel = 3; - passManagerBuilder.SizeLevel = 0; - passManagerBuilder.Inliner = createFunctionInliningPass(); - passManagerBuilder.SLPVectorize = true; - passManagerBuilder.LoopVectorize = true; - passManagerBuilder.LoadCombine = true; - passManagerBuilder.populateModulePassManager(PerModulePasses); - passManagerBuilder.populateFunctionPassManager(PerFunctionPasses); - - // Run function passes: - PerFunctionPasses.doInitialization(); - for (llvm::Function &func : *module) - { - if (!func.isDeclaration()) - PerFunctionPasses.run(func); - } - PerFunctionPasses.doFinalization(); - - // Run module passes: - PerModulePasses.run(*module); - - // Return the resulting object file -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - stream.flush(); - vecstream.flush(); -#endif - std::vector data; - data.resize(str.size()); - memcpy(data.data(), str.data(), data.size()); - return data; -} - -std::string LLVMProgram::DumpModule() -{ - std::string str; - llvm::raw_string_ostream stream(str); -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) - mModule->print(stream, nullptr); -#else - mModule->print(stream, nullptr, false, true); -#endif - return stream.str(); -} - -///////////////////////////////////////////////////////////////////////////// +#include "exception.h" +#include "llvmdrawers.h" std::string &AllTimestamps() { diff --git a/tools/drawergen/exception.h b/tools/drawergen/exception.h new file mode 100644 index 000000000..22d3c18fb --- /dev/null +++ b/tools/drawergen/exception.h @@ -0,0 +1,36 @@ +/* +** LLVM code generated drawers +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +#include +#include + +class Exception : public std::exception +{ +public: + Exception(const std::string &message) : message(message) { } + const char *what() const noexcept override { return message.c_str(); } + +private: + std::string message; +}; diff --git a/tools/drawergen/llvmdrawers.cpp b/tools/drawergen/llvmdrawers.cpp new file mode 100644 index 000000000..49eeb5a46 --- /dev/null +++ b/tools/drawergen/llvmdrawers.cpp @@ -0,0 +1,376 @@ +/* +** LLVM code generated drawers +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include "precomp.h" +#include "timestamp.h" +#include "llvmdrawers.h" +#include "exception.h" + +LLVMDrawers::LLVMDrawers(const std::string &triple, const std::string &cpuName, const std::string &features, const std::string namePostfix) : mNamePostfix(namePostfix) +{ + mProgram.CreateModule(); + + CodegenDrawColumn("FillColumn", DrawColumnVariant::Fill, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnAdd", DrawColumnVariant::FillAdd, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnAddClamp", DrawColumnVariant::FillAddClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnSubClamp", DrawColumnVariant::FillSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("FillColumnRevSubClamp", DrawColumnVariant::FillRevSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumn", DrawColumnVariant::Draw, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnAdd", DrawColumnVariant::DrawAdd, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnShaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnAddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnSubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnRevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnTranslated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnTlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnAddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnSubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnRevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Normal); + CodegenDrawColumn("DrawColumnRt1", DrawColumnVariant::Draw, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt1RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt1); + CodegenDrawColumn("DrawColumnRt4", DrawColumnVariant::Draw, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt4); + CodegenDrawColumn("DrawColumnRt4RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt4); + CodegenDrawSpan("DrawSpan", DrawSpanVariant::Opaque); + CodegenDrawSpan("DrawSpanMasked", DrawSpanVariant::Masked); + CodegenDrawSpan("DrawSpanTranslucent", DrawSpanVariant::Translucent); + CodegenDrawSpan("DrawSpanMaskedTranslucent", DrawSpanVariant::MaskedTranslucent); + CodegenDrawSpan("DrawSpanAddClamp", DrawSpanVariant::AddClamp); + CodegenDrawSpan("DrawSpanMaskedAddClamp", DrawSpanVariant::MaskedAddClamp); + CodegenDrawWall("vlinec1", DrawWallVariant::Opaque, 1); + CodegenDrawWall("vlinec4", DrawWallVariant::Opaque, 4); + CodegenDrawWall("mvlinec1", DrawWallVariant::Masked, 1); + CodegenDrawWall("mvlinec4", DrawWallVariant::Masked, 4); + CodegenDrawWall("tmvline1_add", DrawWallVariant::Add, 1); + CodegenDrawWall("tmvline4_add", DrawWallVariant::Add, 4); + CodegenDrawWall("tmvline1_addclamp", DrawWallVariant::AddClamp, 1); + CodegenDrawWall("tmvline4_addclamp", DrawWallVariant::AddClamp, 4); + CodegenDrawWall("tmvline1_subclamp", DrawWallVariant::SubClamp, 1); + CodegenDrawWall("tmvline4_subclamp", DrawWallVariant::SubClamp, 4); + CodegenDrawWall("tmvline1_revsubclamp", DrawWallVariant::RevSubClamp, 1); + CodegenDrawWall("tmvline4_revsubclamp", DrawWallVariant::RevSubClamp, 4); + CodegenDrawSky("DrawSky1", DrawSkyVariant::Single, 1); + CodegenDrawSky("DrawSky4", DrawSkyVariant::Single, 4); + CodegenDrawSky("DrawDoubleSky1", DrawSkyVariant::Double, 1); + CodegenDrawSky("DrawDoubleSky4", DrawSkyVariant::Double, 4); + for (int i = 0; i < NumTriBlendModes(); i++) + { + CodegenDrawTriangle("TriDrawNormal8_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, false); + CodegenDrawTriangle("TriDrawNormal32_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, true); + CodegenDrawTriangle("TriFillNormal8_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, false); + CodegenDrawTriangle("TriFillNormal32_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, true); + CodegenDrawTriangle("TriDrawSubsector8_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, false); + CodegenDrawTriangle("TriDrawSubsector32_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, true); + CodegenDrawTriangle("TriFillSubsector8_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, false); + CodegenDrawTriangle("TriFillSubsector32_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, true); + } + CodegenDrawTriangle("TriStencil", TriDrawVariant::Stencil, TriBlendMode::Copy, false); + CodegenDrawTriangle("TriStencilClose", TriDrawVariant::StencilClose, TriBlendMode::Copy, false); + + ObjectFile = mProgram.GenerateObjectFile(triple, cpuName, features); +} + +void LLVMDrawers::CodegenDrawColumn(const char *name, DrawColumnVariant variant, DrawColumnMethod method) +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function(name + mNamePostfix); + function.add_parameter(GetDrawColumnArgsStruct(mProgram.context())); + function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); + function.create_public(); + + DrawColumnCodegen codegen; + codegen.Generate(variant, method, function.parameter(0), function.parameter(1)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + throw Exception("verifyFunction failed for CodegenDrawColumn()"); +} + +void LLVMDrawers::CodegenDrawSpan(const char *name, DrawSpanVariant variant) +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function(name + mNamePostfix); + function.add_parameter(GetDrawSpanArgsStruct(mProgram.context())); + function.create_public(); + + DrawSpanCodegen codegen; + codegen.Generate(variant, function.parameter(0)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + throw Exception("verifyFunction failed for CodegenDrawSpan()"); +} + +void LLVMDrawers::CodegenDrawWall(const char *name, DrawWallVariant variant, int columns) +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function(name + mNamePostfix); + function.add_parameter(GetDrawWallArgsStruct(mProgram.context())); + function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); + function.create_public(); + + DrawWallCodegen codegen; + codegen.Generate(variant, columns == 4, function.parameter(0), function.parameter(1)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + throw Exception("verifyFunction failed for CodegenDrawWall()"); +} + +void LLVMDrawers::CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns) +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function(name + mNamePostfix); + function.add_parameter(GetDrawSkyArgsStruct(mProgram.context())); + function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); + function.create_public(); + + DrawSkyCodegen codegen; + codegen.Generate(variant, columns == 4, function.parameter(0), function.parameter(1)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + throw Exception("verifyFunction failed for CodegenDrawSky()"); +} + +void LLVMDrawers::CodegenDrawTriangle(const std::string &name, TriDrawVariant variant, TriBlendMode blendmode, bool truecolor) +{ + llvm::IRBuilder<> builder(mProgram.context()); + SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); + + SSAFunction function(name + mNamePostfix); + function.add_parameter(GetTriDrawTriangleArgs(mProgram.context())); + function.add_parameter(GetWorkerThreadDataStruct(mProgram.context())); + function.create_public(); + + DrawTriangleCodegen codegen; + codegen.Generate(variant, blendmode, truecolor, function.parameter(0), function.parameter(1)); + + builder.CreateRetVoid(); + + if (llvm::verifyFunction(*function.func)) + throw Exception(std::string("verifyFunction failed for CodegenDrawTriangle(") + std::to_string((int)variant) + ", " + std::to_string((int)blendmode) + ", " + std::to_string((int)truecolor) + ")"); +} + +llvm::Type *LLVMDrawers::GetDrawColumnArgsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint32_t *dest; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source2; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *colormap; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *translation; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *basecolors; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t pitch; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t count; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t dest_y; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t iscale; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t texturefracx; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureheight; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t texturefrac; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t color; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srccolor; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; + return llvm::StructType::create(context, elements, "DrawColumnArgs", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetDrawSpanArgsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *destorg; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t destpitch; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xfrac; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t yfrac; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xstep; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ystep; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x1; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x2; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t y; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xbits; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ybits; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; + return llvm::StructType::create(context, elements, "DrawSpanArgs", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetDrawWallArgsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); + for (int i = 0; i < 8; i++) + elements.push_back(llvm::Type::getInt8PtrTy(context)); + for (int i = 0; i < 25; i++) + elements.push_back(llvm::Type::getInt32Ty(context)); + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; + return llvm::StructType::create(context, elements, "DrawWallArgs", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetDrawSkyArgsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); + for (int i = 0; i < 8; i++) + elements.push_back(llvm::Type::getInt8PtrTy(context)); + for (int i = 0; i < 15; i++) + elements.push_back(llvm::Type::getInt32Ty(context)); + return llvm::StructType::create(context, elements, "DrawSkyArgs", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetWorkerThreadDataStruct(llvm::LLVMContext &context) +{ + std::vector elements; + for (int i = 0; i < 4; i++) + elements.push_back(llvm::Type::getInt32Ty(context)); + elements.push_back(llvm::Type::getInt8PtrTy(context)); + return llvm::StructType::create(context, elements, "ThreadData", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetTriVertexStruct(llvm::LLVMContext &context) +{ + std::vector elements; + for (int i = 0; i < 4 + TriVertex::NumVarying; i++) + elements.push_back(llvm::Type::getFloatTy(context)); + return llvm::StructType::create(context, elements, "TriVertex", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetTriMatrixStruct(llvm::LLVMContext &context) +{ + std::vector elements; + for (int i = 0; i < 4 * 4; i++) + elements.push_back(llvm::Type::getFloatTy(context)); + return llvm::StructType::create(context, elements, "TriMatrix", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetTriUniformsStruct(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t subsectorDepth; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t color; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; + elements.push_back(GetTriMatrixStruct(context)); // TriMatrix objectToClip + return llvm::StructType::create(context, elements, "TriUniforms", false)->getPointerTo(); +} + +llvm::Type *LLVMDrawers::GetTriDrawTriangleArgs(llvm::LLVMContext &context) +{ + std::vector elements; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *dest; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t pitch; + elements.push_back(GetTriVertexStruct(context)); // TriVertex *v1; + elements.push_back(GetTriVertexStruct(context)); // TriVertex *v2; + elements.push_back(GetTriVertexStruct(context)); // TriVertex *v3; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipleft; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipright; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t cliptop; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipbottom; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *texturePixels; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureWidth; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureHeight; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *translation; + elements.push_back(GetTriUniformsStruct(context)); // const TriUniforms *uniforms; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *stencilValues; + elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *stencilMasks; + elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t stencilPitch; + elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilTestValue; + elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilWriteValue; + elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *subsectorGBuffer; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *colormaps; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *RGB32k; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *BaseColors; + return llvm::StructType::create(context, elements, "TriDrawTriangle", false)->getPointerTo(); +} diff --git a/tools/drawergen/llvmdrawers.h b/tools/drawergen/llvmdrawers.h new file mode 100644 index 000000000..3eef605df --- /dev/null +++ b/tools/drawergen/llvmdrawers.h @@ -0,0 +1,68 @@ +/* +** LLVM code generated drawers +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +#include "fixedfunction/drawspancodegen.h" +#include "fixedfunction/drawwallcodegen.h" +#include "fixedfunction/drawcolumncodegen.h" +#include "fixedfunction/drawskycodegen.h" +#include "fixedfunction/drawtrianglecodegen.h" +#include "ssa/ssa_function.h" +#include "ssa/ssa_scope.h" +#include "ssa/ssa_for_block.h" +#include "ssa/ssa_if_block.h" +#include "ssa/ssa_stack.h" +#include "ssa/ssa_function.h" +#include "ssa/ssa_struct_type.h" +#include "ssa/ssa_value.h" +#include "ssa/ssa_barycentric_weight.h" +#include "llvmprogram.h" +#include + +class LLVMDrawers +{ +public: + LLVMDrawers(const std::string &triple, const std::string &cpuName, const std::string &features, const std::string namePostfix); + + std::vector ObjectFile; + +private: + void CodegenDrawColumn(const char *name, DrawColumnVariant variant, DrawColumnMethod method); + void CodegenDrawSpan(const char *name, DrawSpanVariant variant); + void CodegenDrawWall(const char *name, DrawWallVariant variant, int columns); + void CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns); + void CodegenDrawTriangle(const std::string &name, TriDrawVariant variant, TriBlendMode blendmode, bool truecolor); + + static llvm::Type *GetDrawColumnArgsStruct(llvm::LLVMContext &context); + static llvm::Type *GetDrawSpanArgsStruct(llvm::LLVMContext &context); + static llvm::Type *GetDrawWallArgsStruct(llvm::LLVMContext &context); + static llvm::Type *GetDrawSkyArgsStruct(llvm::LLVMContext &context); + static llvm::Type *GetWorkerThreadDataStruct(llvm::LLVMContext &context); + static llvm::Type *GetTriVertexStruct(llvm::LLVMContext &context); + static llvm::Type *GetTriMatrixStruct(llvm::LLVMContext &context); + static llvm::Type *GetTriUniformsStruct(llvm::LLVMContext &context); + static llvm::Type *GetTriDrawTriangleArgs(llvm::LLVMContext &context); + + LLVMProgram mProgram; + std::string mNamePostfix; +}; diff --git a/tools/drawergen/llvmprogram.cpp b/tools/drawergen/llvmprogram.cpp new file mode 100644 index 000000000..84094eda6 --- /dev/null +++ b/tools/drawergen/llvmprogram.cpp @@ -0,0 +1,171 @@ +/* +** LLVM code generated drawers +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include "precomp.h" +#include "timestamp.h" +#include "llvmprogram.h" + +LLVMProgram::LLVMProgram() +{ + mContext = std::make_unique(); +} + +void LLVMProgram::CreateModule() +{ + mModule = std::make_unique("render", context()); +} + +std::vector LLVMProgram::GenerateObjectFile(const std::string &triple, const std::string &cpuName, const std::string &features) +{ + using namespace llvm; + + std::string errorstring; + + llvm::Module *module = mModule.get(); + + const Target *target = TargetRegistry::lookupTarget(triple, errorstring); + +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) + Reloc::Model relocationModel = Reloc::PIC_; +#else + Optional relocationModel = Reloc::PIC_; +#endif + + CodeModel::Model codeModel = CodeModel::Model::Default; + + TargetOptions options; + options.LessPreciseFPMADOption = true; + options.AllowFPOpFusion = FPOpFusion::Fast; + options.UnsafeFPMath = true; + options.NoInfsFPMath = true; + options.NoNaNsFPMath = true; + options.HonorSignDependentRoundingFPMathOption = false; + options.NoZerosInBSS = false; + options.GuaranteedTailCallOpt = false; + options.StackAlignmentOverride = 0; + options.UseInitArray = true; + options.DataSections = false; + options.FunctionSections = false; + options.JTType = JumpTable::Single; // Create a single table for all jumptable functions + options.ThreadModel = ThreadModel::POSIX; + options.DisableIntegratedAS = false; + options.MCOptions.SanitizeAddress = false; + options.MCOptions.MCRelaxAll = false; // relax all fixups in the emitted object file + options.MCOptions.DwarfVersion = 0; + options.MCOptions.ShowMCInst = false; + options.MCOptions.ABIName = ""; + options.MCOptions.MCFatalWarnings = false; + options.MCOptions.ShowMCEncoding = false; // Show encoding in .s output + options.MCOptions.MCUseDwarfDirectory = false; + options.MCOptions.AsmVerbose = true; + +#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9) + options.Reciprocals = TargetRecip({ "all" }); + options.StackSymbolOrdering = true; + options.UniqueSectionNames = true; + options.EmulatedTLS = false; + options.ExceptionModel = ExceptionHandling::None; + options.EABIVersion = EABI::Default; + options.DebuggerTuning = DebuggerKind::Default; + options.MCOptions.MCIncrementalLinkerCompatible = false; + options.MCOptions.MCNoWarn = false; + options.MCOptions.PreserveAsmComments = true; +#endif + + CodeGenOpt::Level optimizationLevel = CodeGenOpt::Aggressive; + machine = target->createTargetMachine(triple, cpuName, features, options, relocationModel, codeModel, optimizationLevel); + + +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + std::string targetTriple = machine->getTargetTriple(); +#else + std::string targetTriple = machine->getTargetTriple().getTriple(); +#endif + + module->setTargetTriple(targetTriple); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + module->setDataLayout(new DataLayout(*machine->getSubtargetImpl()->getDataLayout())); +#else + module->setDataLayout(machine->createDataLayout()); +#endif + + legacy::FunctionPassManager PerFunctionPasses(module); + legacy::PassManager PerModulePasses; + +#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8) + PerFunctionPasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); + PerModulePasses.add(createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis())); +#endif + + SmallString<16 * 1024> str; +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + raw_svector_ostream vecstream(str); + formatted_raw_ostream stream(vecstream); +#else + raw_svector_ostream stream(str); +#endif + machine->addPassesToEmitFile(PerModulePasses, stream, TargetMachine::CGFT_ObjectFile); + + PassManagerBuilder passManagerBuilder; + passManagerBuilder.OptLevel = 3; + passManagerBuilder.SizeLevel = 0; + passManagerBuilder.Inliner = createFunctionInliningPass(); + passManagerBuilder.SLPVectorize = true; + passManagerBuilder.LoopVectorize = true; + passManagerBuilder.LoadCombine = true; + passManagerBuilder.populateModulePassManager(PerModulePasses); + passManagerBuilder.populateFunctionPassManager(PerFunctionPasses); + + // Run function passes: + PerFunctionPasses.doInitialization(); + for (llvm::Function &func : *module) + { + if (!func.isDeclaration()) + PerFunctionPasses.run(func); + } + PerFunctionPasses.doFinalization(); + + // Run module passes: + PerModulePasses.run(*module); + + // Return the resulting object file +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + stream.flush(); + vecstream.flush(); +#endif + std::vector data; + data.resize(str.size()); + memcpy(data.data(), str.data(), data.size()); + return data; +} + +std::string LLVMProgram::DumpModule() +{ + std::string str; + llvm::raw_string_ostream stream(str); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + mModule->print(stream, nullptr); +#else + mModule->print(stream, nullptr, false, true); +#endif + return stream.str(); +} diff --git a/tools/drawergen/llvmprogram.h b/tools/drawergen/llvmprogram.h new file mode 100644 index 000000000..30cf33d5a --- /dev/null +++ b/tools/drawergen/llvmprogram.h @@ -0,0 +1,41 @@ +/* +** LLVM code generated drawers +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +class LLVMProgram +{ +public: + LLVMProgram(); + + void CreateModule(); + std::vector GenerateObjectFile(const std::string &triple, const std::string &cpuName, const std::string &features); + std::string DumpModule(); + + llvm::LLVMContext &context() { return *mContext; } + llvm::Module *module() { return mModule.get(); } + +private: + llvm::TargetMachine *machine = nullptr; + std::unique_ptr mContext; + std::unique_ptr mModule; +}; From 28f9216e7bdc58473ae34ce015b74087f8604bf7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 4 Dec 2016 16:57:10 +0100 Subject: [PATCH 1340/1509] - fixed a few prototypes. --- src/r_draw.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index 290256d58..f4f752557 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -252,10 +252,8 @@ void R_DrawColumnHorizP_C(void); #ifdef X86_ASM extern "C" void R_DrawColumnP_Unrolled (void); -extern "C" void R_DrawColumnHorizP_ASM (void); extern "C" void R_DrawColumnP_ASM (void); extern "C" void R_DrawFuzzColumnP_ASM (void); - void R_DrawTranslatedColumnP_C (void); void R_DrawShadedColumnP_C (void); extern "C" void R_DrawSpanP_ASM (void); extern "C" void R_DrawSpanMaskedP_ASM (void); @@ -264,13 +262,14 @@ extern "C" void R_DrawSpanMaskedP_ASM (void); void R_DrawColumnP_C (void); void R_DrawFuzzColumnP_C (void); -void R_DrawTranslatedColumnP_C (void); void R_DrawShadedColumnP_C (void); void R_DrawSpanP_C (void); void R_DrawSpanMaskedP_C (void); #endif +void R_DrawColumnHorizP_C(void); +void R_DrawTranslatedColumnP_C(void); void R_DrawSpanTranslucentP_C (void); void R_DrawSpanMaskedTranslucentP_C (void); From 659abc945173a011a968d74a4cff48ececc608bd Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 4 Dec 2016 19:18:13 -0500 Subject: [PATCH 1341/1509] - Removed vestigial prototype. --- src/r_draw.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index f4f752557..17365f3f5 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -247,8 +247,6 @@ extern void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip); -void R_DrawColumnHorizP_C(void); - #ifdef X86_ASM extern "C" void R_DrawColumnP_Unrolled (void); From 2f3a6da295056e5b1cd0329e3c399ea4832b6343 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 5 Dec 2016 04:05:55 +0100 Subject: [PATCH 1342/1509] Fix buffer overrun --- src/gl/system/gl_swframebuffer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 421fe9278..6b3caa81e 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -2316,7 +2316,11 @@ bool OpenGLSWFrameBuffer::OpenGLPal::Update() { buff[i] = ColorARGB(pal[i].a, pal[i - 1].r, pal[i - 1].g, pal[i - 1].b); } - BorderColor = ColorARGB(pal[i].a, pal[i - 1].r, pal[i - 1].g, pal[i - 1].b); + if (numEntries > 1) + { + i = numEntries - 1; + BorderColor = ColorARGB(pal[i].a, pal[i - 1].r, pal[i - 1].g, pal[i - 1].b); + } glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); GLint oldBinding = 0; From 7ffab207cba5b1218231ef54fde16af785aa3792 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 5 Dec 2016 09:22:45 +0100 Subject: [PATCH 1343/1509] Move rgba drawers to be dispatched by r_draw_tc --- src/r_draw_rgba.cpp | 958 ++++++---------------------- src/r_draw_rgba.h | 658 +++++++++++++++----- src/r_draw_tc.cpp | 1411 ++++++++++++++++++++++++++++++++++++++++++ src/r_draw_tc.h | 239 +++++++ src/r_drawt_rgba.cpp | 365 ++--------- src/r_plane.cpp | 38 +- 6 files changed, 2391 insertions(+), 1278 deletions(-) create mode 100644 src/r_draw_tc.cpp create mode 100644 src/r_draw_tc.h diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 699352a6b..bbedb2622 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -60,18 +60,14 @@ CVAR(Float, r_lod_bias, -1.5, 0); // To do: add CVAR_ARCHIVE | CVAR_GLOBALCONFIG namespace swrenderer { + extern "C" short spanend[MAXHEIGHT]; + extern float rw_light; + extern float rw_lightstep; + extern int wallshade; -extern "C" short spanend[MAXHEIGHT]; -extern float rw_light; -extern float rw_lightstep; -extern int wallshade; + ///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// - -class DrawSpanLLVMCommand : public DrawerCommand -{ -public: - DrawSpanLLVMCommand() + DrawSpanLLVMCommand::DrawSpanLLVMCommand() { using namespace drawerargs; @@ -106,23 +102,19 @@ public: args.flags |= DrawSpanArgs::nearest_filter; } - void Execute(DrawerThread *thread) override + void DrawSpanLLVMCommand::Execute(DrawerThread *thread) { if (thread->skipped_by_thread(args.y)) return; Drawers::Instance()->DrawSpan(&args); } - FString DebugInfo() override + FString DrawSpanLLVMCommand::DebugInfo() { return "DrawSpan\n" + args.ToString(); } -protected: - DrawSpanArgs args; - -private: - inline static bool sampler_setup(const uint32_t * &source, int &xbits, int &ybits, bool mipmapped) + bool DrawSpanLLVMCommand::sampler_setup(const uint32_t * &source, int &xbits, int &ybits, bool mipmapped) { using namespace drawerargs; @@ -144,71 +136,47 @@ private: return (magnifying && r_magfilter) || (!magnifying && r_minfilter); } -}; -class DrawSpanMaskedLLVMCommand : public DrawSpanLLVMCommand -{ -public: - void Execute(DrawerThread *thread) override + ///////////////////////////////////////////////////////////////////////////// + + void DrawSpanMaskedLLVMCommand::Execute(DrawerThread *thread) { if (thread->skipped_by_thread(args.y)) return; Drawers::Instance()->DrawSpanMasked(&args); } -}; -class DrawSpanTranslucentLLVMCommand : public DrawSpanLLVMCommand -{ -public: - void Execute(DrawerThread *thread) override + void DrawSpanTranslucentLLVMCommand::Execute(DrawerThread *thread) { if (thread->skipped_by_thread(args.y)) return; Drawers::Instance()->DrawSpanTranslucent(&args); } -}; -class DrawSpanMaskedTranslucentLLVMCommand : public DrawSpanLLVMCommand -{ -public: - void Execute(DrawerThread *thread) override + void DrawSpanMaskedTranslucentLLVMCommand::Execute(DrawerThread *thread) { if (thread->skipped_by_thread(args.y)) return; Drawers::Instance()->DrawSpanMaskedTranslucent(&args); } -}; -class DrawSpanAddClampLLVMCommand : public DrawSpanLLVMCommand -{ -public: - void Execute(DrawerThread *thread) override + void DrawSpanAddClampLLVMCommand::Execute(DrawerThread *thread) { if (thread->skipped_by_thread(args.y)) return; Drawers::Instance()->DrawSpanAddClamp(&args); } -}; -class DrawSpanMaskedAddClampLLVMCommand : public DrawSpanLLVMCommand -{ -public: - void Execute(DrawerThread *thread) override + void DrawSpanMaskedAddClampLLVMCommand::Execute(DrawerThread *thread) { if (thread->skipped_by_thread(args.y)) return; Drawers::Instance()->DrawSpanMaskedAddClamp(&args); } -}; -///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// -class DrawWall4LLVMCommand : public DrawerCommand -{ -protected: - DrawWallArgs args; - - WorkerThreadData ThreadData(DrawerThread *thread) + WorkerThreadData DrawWall4LLVMCommand::ThreadData(DrawerThread *thread) { WorkerThreadData d; d.core = thread->core; @@ -218,8 +186,7 @@ protected: return d; } -public: - DrawWall4LLVMCommand() + DrawWall4LLVMCommand::DrawWall4LLVMCommand() { using namespace drawerargs; @@ -257,24 +224,20 @@ public: DetectRangeError(args.dest, args.dest_y, args.count); } - void Execute(DrawerThread *thread) override + void DrawWall4LLVMCommand::Execute(DrawerThread *thread) { WorkerThreadData d = ThreadData(thread); Drawers::Instance()->vlinec4(&args, &d); } - FString DebugInfo() override + FString DrawWall4LLVMCommand::DebugInfo() { return "DrawWall4\n" + args.ToString(); } -}; -class DrawWall1LLVMCommand : public DrawerCommand -{ -protected: - DrawWallArgs args; + ///////////////////////////////////////////////////////////////////////////// - WorkerThreadData ThreadData(DrawerThread *thread) + WorkerThreadData DrawWall1LLVMCommand::ThreadData(DrawerThread *thread) { WorkerThreadData d; d.core = thread->core; @@ -284,8 +247,7 @@ protected: return d; } -public: - DrawWall1LLVMCommand() + DrawWall1LLVMCommand::DrawWall1LLVMCommand() { using namespace drawerargs; @@ -320,24 +282,20 @@ public: DetectRangeError(args.dest, args.dest_y, args.count); } - void Execute(DrawerThread *thread) override + void DrawWall1LLVMCommand::Execute(DrawerThread *thread) { WorkerThreadData d = ThreadData(thread); Drawers::Instance()->vlinec1(&args, &d); } - FString DebugInfo() override + FString DrawWall1LLVMCommand::DebugInfo() { return "DrawWall1\n" + args.ToString(); } -}; -class DrawColumnLLVMCommand : public DrawerCommand -{ -protected: - DrawColumnArgs args; + ///////////////////////////////////////////////////////////////////////////// - WorkerThreadData ThreadData(DrawerThread *thread) + WorkerThreadData DrawColumnLLVMCommand::ThreadData(DrawerThread *thread) { WorkerThreadData d; d.core = thread->core; @@ -347,13 +305,12 @@ protected: return d; } - FString DebugInfo() override + FString DrawColumnLLVMCommand::DebugInfo() { return "DrawColumn\n" + args.ToString(); } -public: - DrawColumnLLVMCommand() + DrawColumnLLVMCommand::DrawColumnLLVMCommand() { using namespace drawerargs; @@ -393,19 +350,15 @@ public: DetectRangeError(args.dest, args.dest_y, args.count); } - void Execute(DrawerThread *thread) override + void DrawColumnLLVMCommand::Execute(DrawerThread *thread) { WorkerThreadData d = ThreadData(thread); Drawers::Instance()->DrawColumn(&args, &d); } -}; -class DrawSkyLLVMCommand : public DrawerCommand -{ -protected: - DrawSkyArgs args; + ///////////////////////////////////////////////////////////////////////////// - WorkerThreadData ThreadData(DrawerThread *thread) + WorkerThreadData DrawSkyLLVMCommand::ThreadData(DrawerThread *thread) { WorkerThreadData d; d.core = thread->core; @@ -415,8 +368,7 @@ protected: return d; } -public: - DrawSkyLLVMCommand(uint32_t solid_top, uint32_t solid_bottom) + DrawSkyLLVMCommand::DrawSkyLLVMCommand(uint32_t solid_top, uint32_t solid_bottom) { using namespace drawerargs; @@ -439,70 +391,14 @@ public: DetectRangeError(args.dest, args.dest_y, args.count); } - FString DebugInfo() override + FString DrawSkyLLVMCommand::DebugInfo() { return "DrawSky\n" + args.ToString(); } -}; -#define DECLARE_DRAW_COMMAND(name, func, base) \ -class name##LLVMCommand : public base \ -{ \ -public: \ - using base::base; \ - void Execute(DrawerThread *thread) override \ - { \ - WorkerThreadData d = ThreadData(thread); \ - Drawers::Instance()->func(&args, &d); \ - } \ -}; + ///////////////////////////////////////////////////////////////////////////// -//DECLARE_DRAW_COMMAND(name, func, DrawSpanLLVMCommand); - -DECLARE_DRAW_COMMAND(DrawWallMasked4, mvlinec4, DrawWall4LLVMCommand); -DECLARE_DRAW_COMMAND(DrawWallAdd4, tmvline4_add, DrawWall4LLVMCommand); -DECLARE_DRAW_COMMAND(DrawWallAddClamp4, tmvline4_addclamp, DrawWall4LLVMCommand); -DECLARE_DRAW_COMMAND(DrawWallSubClamp4, tmvline4_subclamp, DrawWall4LLVMCommand); -DECLARE_DRAW_COMMAND(DrawWallRevSubClamp4, tmvline4_revsubclamp, DrawWall4LLVMCommand); -DECLARE_DRAW_COMMAND(DrawWallMasked1, mvlinec1, DrawWall1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawWallAdd1, tmvline1_add, DrawWall1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawWallAddClamp1, tmvline1_addclamp, DrawWall1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawWallSubClamp1, tmvline1_subclamp, DrawWall1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawWallRevSubClamp1, tmvline1_revsubclamp, DrawWall1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnAdd, DrawColumnAdd, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnTranslated, DrawColumnTranslated, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnTlatedAdd, DrawColumnTlatedAdd, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnShaded, DrawColumnShaded, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnAddClamp, DrawColumnAddClamp, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnAddClampTranslated, DrawColumnAddClampTranslated, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnSubClamp, DrawColumnSubClamp, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnSubClampTranslated, DrawColumnSubClampTranslated, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRevSubClamp, DrawColumnRevSubClamp, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRevSubClampTranslated, DrawColumnRevSubClampTranslated, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(FillColumn, FillColumn, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(FillColumnAdd, FillColumnAdd, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(FillColumnAddClamp, FillColumnAddClamp, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(FillColumnSubClamp, FillColumnSubClamp, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(FillColumnRevSubClamp, FillColumnRevSubClamp, DrawColumnLLVMCommand); -DECLARE_DRAW_COMMAND(DrawSingleSky1, DrawSky1, DrawSkyLLVMCommand); -DECLARE_DRAW_COMMAND(DrawSingleSky4, DrawSky4, DrawSkyLLVMCommand); -DECLARE_DRAW_COMMAND(DrawDoubleSky1, DrawDoubleSky1, DrawSkyLLVMCommand); -DECLARE_DRAW_COMMAND(DrawDoubleSky4, DrawDoubleSky4, DrawSkyLLVMCommand); - -///////////////////////////////////////////////////////////////////////////// - -class DrawFuzzColumnRGBACommand : public DrawerCommand -{ - int _x; - int _yl; - int _yh; - BYTE * RESTRICT _destorg; - int _pitch; - int _fuzzpos; - int _fuzzviewheight; - -public: - DrawFuzzColumnRGBACommand() + DrawFuzzColumnRGBACommand::DrawFuzzColumnRGBACommand() { using namespace drawerargs; @@ -515,7 +411,7 @@ public: _fuzzviewheight = fuzzviewheight; } - void Execute(DrawerThread *thread) override + void DrawFuzzColumnRGBACommand::Execute(DrawerThread *thread) { int yl = MAX(_yl, 1); int yh = MIN(_yh, _fuzzviewheight); @@ -605,23 +501,14 @@ public: } } - FString DebugInfo() override + FString DrawFuzzColumnRGBACommand::DebugInfo() { return "DrawFuzzColumn"; } -}; -class FillSpanRGBACommand : public DrawerCommand -{ - int _x1; - int _x2; - int _y; - BYTE * RESTRICT _destorg; - fixed_t _light; - int _color; + ///////////////////////////////////////////////////////////////////////////// -public: - FillSpanRGBACommand() + FillSpanRGBACommand::FillSpanRGBACommand() { using namespace drawerargs; @@ -633,7 +520,7 @@ public: _color = ds_color; } - void Execute(DrawerThread *thread) override + void FillSpanRGBACommand::Execute(DrawerThread *thread) { if (thread->line_skipped_by_thread(_y)) return; @@ -646,30 +533,14 @@ public: dest[i] = color; } - FString DebugInfo() override + FString FillSpanRGBACommand::DebugInfo() { return "FillSpan"; } -}; -///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// -class DrawSlabRGBACommand : public DrawerCommand -{ - int _dx; - fixed_t _v; - int _dy; - fixed_t _vi; - const BYTE *_voxelptr; - uint32_t *_p; - ShadeConstants _shade_constants; - const BYTE *_colormap; - fixed_t _light; - int _pitch; - int _start_y; - -public: - DrawSlabRGBACommand(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p, ShadeConstants shade_constants, const BYTE *colormap, fixed_t light) + DrawSlabRGBACommand::DrawSlabRGBACommand(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p, ShadeConstants shade_constants, const uint8_t *colormap, fixed_t light) { using namespace drawerargs; @@ -687,16 +558,16 @@ public: assert(dx > 0); } - void Execute(DrawerThread *thread) override + void DrawSlabRGBACommand::Execute(DrawerThread *thread) { int dx = _dx; fixed_t v = _v; int dy = _dy; fixed_t vi = _vi; - const BYTE *vptr = _voxelptr; + const uint8_t *vptr = _voxelptr; uint32_t *p = _p; ShadeConstants shade_constants = _shade_constants; - const BYTE *colormap = _colormap; + const uint8_t *colormap = _colormap; uint32_t light = LightBgra::calc_light_multiplier(_light); int pitch = _pitch; int x; @@ -772,25 +643,14 @@ public: } } - FString DebugInfo() override + FString DrawSlabRGBACommand::DebugInfo() { return "DrawSlab"; } -}; -///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// -class DrawFogBoundaryLineRGBACommand : public DrawerCommand -{ - int _y; - int _x; - int _x2; - BYTE * RESTRICT _destorg; - fixed_t _light; - ShadeConstants _shade_constants; - -public: - DrawFogBoundaryLineRGBACommand(int y, int x, int x2) + DrawFogBoundaryLineRGBACommand::DrawFogBoundaryLineRGBACommand(int y, int x, int x2) { using namespace drawerargs; @@ -803,7 +663,7 @@ public: _shade_constants = dc_shade_constants; } - void Execute(DrawerThread *thread) override + void DrawFogBoundaryLineRGBACommand::Execute(DrawerThread *thread) { if (thread->line_skipped_by_thread(_y)) return; @@ -853,34 +713,14 @@ public: } while (++x <= x2); } - FString DebugInfo() override + FString DrawFogBoundaryLineRGBACommand::DebugInfo() { return "DrawFogBoundaryLine"; } -}; -class DrawTiltedSpanRGBACommand : public DrawerCommand -{ - int _x1; - int _x2; - int _y; - BYTE * RESTRICT _destorg; - fixed_t _light; - ShadeConstants _shade_constants; - FVector3 _plane_sz; - FVector3 _plane_su; - FVector3 _plane_sv; - bool _plane_shade; - int _planeshade; - float _planelightfloat; - fixed_t _pviewx; - fixed_t _pviewy; - int _xbits; - int _ybits; - const uint32_t * RESTRICT _source; + ///////////////////////////////////////////////////////////////////////////// -public: - DrawTiltedSpanRGBACommand(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) + DrawTiltedSpanRGBACommand::DrawTiltedSpanRGBACommand(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) { using namespace drawerargs; @@ -903,7 +743,7 @@ public: _ybits = ds_ybits; } - void Execute(DrawerThread *thread) override + void DrawTiltedSpanRGBACommand::Execute(DrawerThread *thread) { if (thread->line_skipped_by_thread(_y)) return; @@ -1009,23 +849,14 @@ public: } } - FString DebugInfo() override + FString DrawTiltedSpanRGBACommand::DebugInfo() { return "DrawTiltedSpan"; } -}; -class DrawColoredSpanRGBACommand : public DrawerCommand -{ - int _y; - int _x1; - int _x2; - BYTE * RESTRICT _destorg; - fixed_t _light; - int _color; + ///////////////////////////////////////////////////////////////////////////// -public: - DrawColoredSpanRGBACommand(int y, int x1, int x2) + DrawColoredSpanRGBACommand::DrawColoredSpanRGBACommand(int y, int x1, int x2) { using namespace drawerargs; @@ -1038,7 +869,7 @@ public: _color = ds_color; } - void Execute(DrawerThread *thread) override + void DrawColoredSpanRGBACommand::Execute(DrawerThread *thread) { if (thread->line_skipped_by_thread(_y)) return; @@ -1055,25 +886,14 @@ public: dest[i] = color; } - FString DebugInfo() override + FString DrawColoredSpanRGBACommand::DebugInfo() { return "DrawColoredSpan"; } -}; -class FillTransColumnRGBACommand : public DrawerCommand -{ - int _x; - int _y1; - int _y2; - int _color; - int _a; - BYTE * RESTRICT _destorg; - int _pitch; - fixed_t _light; + ///////////////////////////////////////////////////////////////////////////// -public: - FillTransColumnRGBACommand(int x, int y1, int y2, int color, int a) + FillTransColumnRGBACommand::FillTransColumnRGBACommand(int x, int y1, int y2, int color, int a) { using namespace drawerargs; @@ -1087,7 +907,7 @@ public: _pitch = dc_pitch; } - void Execute(DrawerThread *thread) override + void FillTransColumnRGBACommand::Execute(DrawerThread *thread) { int x = _x; int y1 = _y1; @@ -1129,553 +949,163 @@ public: } } - FString DebugInfo() override + FString FillTransColumnRGBACommand::DebugInfo() { return "FillTransColumn"; } -}; -ApplySpecialColormapRGBACommand::ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen) -{ - buffer = screen->GetBuffer(); - pitch = screen->GetPitch(); - width = screen->GetWidth(); - height = screen->GetHeight(); + ///////////////////////////////////////////////////////////////////////////// - start_red = (int)(colormap->ColorizeStart[0] * 255); - start_green = (int)(colormap->ColorizeStart[1] * 255); - start_blue = (int)(colormap->ColorizeStart[2] * 255); - end_red = (int)(colormap->ColorizeEnd[0] * 255); - end_green = (int)(colormap->ColorizeEnd[1] * 255); - end_blue = (int)(colormap->ColorizeEnd[2] * 255); -} + ApplySpecialColormapRGBACommand::ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen) + { + buffer = screen->GetBuffer(); + pitch = screen->GetPitch(); + width = screen->GetWidth(); + height = screen->GetHeight(); + + start_red = (int)(colormap->ColorizeStart[0] * 255); + start_green = (int)(colormap->ColorizeStart[1] * 255); + start_blue = (int)(colormap->ColorizeStart[2] * 255); + end_red = (int)(colormap->ColorizeEnd[0] * 255); + end_green = (int)(colormap->ColorizeEnd[1] * 255); + end_blue = (int)(colormap->ColorizeEnd[2] * 255); + } #ifdef NO_SSE -void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) -{ - int y = thread->skipped_by_thread(0); - int count = thread->count_for_thread(0, height); - while (count > 0) + void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) { - BYTE *pixels = buffer + y * pitch * 4; - for (int x = 0; x < width; x++) + int y = thread->skipped_by_thread(0); + int count = thread->count_for_thread(0, height); + while (count > 0) { - int fg_red = pixels[2]; - int fg_green = pixels[1]; - int fg_blue = pixels[0]; + uint8_t *pixels = buffer + y * pitch * 4; + for (int x = 0; x < width; x++) + { + int fg_red = pixels[2]; + int fg_green = pixels[1]; + int fg_blue = pixels[0]; - int gray = (fg_red * 77 + fg_green * 143 + fg_blue * 37) >> 8; - gray += (gray >> 7); // gray*=256/255 - int inv_gray = 256 - gray; + int gray = (fg_red * 77 + fg_green * 143 + fg_blue * 37) >> 8; + gray += (gray >> 7); // gray*=256/255 + int inv_gray = 256 - gray; - int red = clamp((start_red * inv_gray + end_red * gray) >> 8, 0, 255); - int green = clamp((start_green * inv_gray + end_green * gray) >> 8, 0, 255); - int blue = clamp((start_blue * inv_gray + end_blue * gray) >> 8, 0, 255); + int red = clamp((start_red * inv_gray + end_red * gray) >> 8, 0, 255); + int green = clamp((start_green * inv_gray + end_green * gray) >> 8, 0, 255); + int blue = clamp((start_blue * inv_gray + end_blue * gray) >> 8, 0, 255); - pixels[0] = (BYTE)blue; - pixels[1] = (BYTE)green; - pixels[2] = (BYTE)red; - pixels[3] = 0xff; + pixels[0] = (uint8_t)blue; + pixels[1] = (uint8_t)green; + pixels[2] = (uint8_t)red; + pixels[3] = 0xff; - pixels += 4; + pixels += 4; + } + y += thread->num_cores; + count--; } - y += thread->num_cores; - count--; } -} #else -void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) -{ - int y = thread->skipped_by_thread(0); - int count = thread->count_for_thread(0, height); - __m128i gray_weight = _mm_set_epi16(256, 77, 143, 37, 256, 77, 143, 37); - __m128i start_end = _mm_set_epi16(255, start_red, start_green, start_blue, 255, end_red, end_green, end_blue); - while (count > 0) + void ApplySpecialColormapRGBACommand::Execute(DrawerThread *thread) { - BYTE *pixels = buffer + y * pitch * 4; - int sse_length = width / 4; - for (int x = 0; x < sse_length; x++) + int y = thread->skipped_by_thread(0); + int count = thread->count_for_thread(0, height); + __m128i gray_weight = _mm_set_epi16(256, 77, 143, 37, 256, 77, 143, 37); + __m128i start_end = _mm_set_epi16(255, start_red, start_green, start_blue, 255, end_red, end_green, end_blue); + while (count > 0) { - // Unpack to integers: - __m128i p = _mm_loadu_si128((const __m128i*)pixels); + uint8_t *pixels = buffer + y * pitch * 4; + int sse_length = width / 4; + for (int x = 0; x < sse_length; x++) + { + // Unpack to integers: + __m128i p = _mm_loadu_si128((const __m128i*)pixels); - __m128i p16_0 = _mm_unpacklo_epi8(p, _mm_setzero_si128()); - __m128i p16_1 = _mm_unpackhi_epi8(p, _mm_setzero_si128()); + __m128i p16_0 = _mm_unpacklo_epi8(p, _mm_setzero_si128()); + __m128i p16_1 = _mm_unpackhi_epi8(p, _mm_setzero_si128()); - // Add gray weighting to colors - __m128i mullo0 = _mm_mullo_epi16(p16_0, gray_weight); - __m128i mullo1 = _mm_mullo_epi16(p16_1, gray_weight); - __m128i p32_0 = _mm_unpacklo_epi16(mullo0, _mm_setzero_si128()); - __m128i p32_1 = _mm_unpackhi_epi16(mullo0, _mm_setzero_si128()); - __m128i p32_2 = _mm_unpacklo_epi16(mullo1, _mm_setzero_si128()); - __m128i p32_3 = _mm_unpackhi_epi16(mullo1, _mm_setzero_si128()); + // Add gray weighting to colors + __m128i mullo0 = _mm_mullo_epi16(p16_0, gray_weight); + __m128i mullo1 = _mm_mullo_epi16(p16_1, gray_weight); + __m128i p32_0 = _mm_unpacklo_epi16(mullo0, _mm_setzero_si128()); + __m128i p32_1 = _mm_unpackhi_epi16(mullo0, _mm_setzero_si128()); + __m128i p32_2 = _mm_unpacklo_epi16(mullo1, _mm_setzero_si128()); + __m128i p32_3 = _mm_unpackhi_epi16(mullo1, _mm_setzero_si128()); - // Transpose to get color components in individual vectors: - __m128 tmpx = _mm_castsi128_ps(p32_0); - __m128 tmpy = _mm_castsi128_ps(p32_1); - __m128 tmpz = _mm_castsi128_ps(p32_2); - __m128 tmpw = _mm_castsi128_ps(p32_3); - _MM_TRANSPOSE4_PS(tmpx, tmpy, tmpz, tmpw); - __m128i blue = _mm_castps_si128(tmpx); - __m128i green = _mm_castps_si128(tmpy); - __m128i red = _mm_castps_si128(tmpz); - __m128i alpha = _mm_castps_si128(tmpw); + // Transpose to get color components in individual vectors: + __m128 tmpx = _mm_castsi128_ps(p32_0); + __m128 tmpy = _mm_castsi128_ps(p32_1); + __m128 tmpz = _mm_castsi128_ps(p32_2); + __m128 tmpw = _mm_castsi128_ps(p32_3); + _MM_TRANSPOSE4_PS(tmpx, tmpy, tmpz, tmpw); + __m128i blue = _mm_castps_si128(tmpx); + __m128i green = _mm_castps_si128(tmpy); + __m128i red = _mm_castps_si128(tmpz); + __m128i alpha = _mm_castps_si128(tmpw); - // Calculate gray and 256-gray values: - __m128i gray = _mm_srli_epi32(_mm_add_epi32(_mm_add_epi32(red, green), blue), 8); - __m128i inv_gray = _mm_sub_epi32(_mm_set1_epi32(256), gray); + // Calculate gray and 256-gray values: + __m128i gray = _mm_srli_epi32(_mm_add_epi32(_mm_add_epi32(red, green), blue), 8); + __m128i inv_gray = _mm_sub_epi32(_mm_set1_epi32(256), gray); - // p32 = start * inv_gray + end * gray: - __m128i gray0 = _mm_shuffle_epi32(gray, _MM_SHUFFLE(0, 0, 0, 0)); - __m128i gray1 = _mm_shuffle_epi32(gray, _MM_SHUFFLE(1, 1, 1, 1)); - __m128i gray2 = _mm_shuffle_epi32(gray, _MM_SHUFFLE(2, 2, 2, 2)); - __m128i gray3 = _mm_shuffle_epi32(gray, _MM_SHUFFLE(3, 3, 3, 3)); - __m128i inv_gray0 = _mm_shuffle_epi32(inv_gray, _MM_SHUFFLE(0, 0, 0, 0)); - __m128i inv_gray1 = _mm_shuffle_epi32(inv_gray, _MM_SHUFFLE(1, 1, 1, 1)); - __m128i inv_gray2 = _mm_shuffle_epi32(inv_gray, _MM_SHUFFLE(2, 2, 2, 2)); - __m128i inv_gray3 = _mm_shuffle_epi32(inv_gray, _MM_SHUFFLE(3, 3, 3, 3)); - __m128i gray16_0 = _mm_packs_epi32(gray0, inv_gray0); - __m128i gray16_1 = _mm_packs_epi32(gray1, inv_gray1); - __m128i gray16_2 = _mm_packs_epi32(gray2, inv_gray2); - __m128i gray16_3 = _mm_packs_epi32(gray3, inv_gray3); - __m128i gray16_0_mullo = _mm_mullo_epi16(gray16_0, start_end); - __m128i gray16_1_mullo = _mm_mullo_epi16(gray16_1, start_end); - __m128i gray16_2_mullo = _mm_mullo_epi16(gray16_2, start_end); - __m128i gray16_3_mullo = _mm_mullo_epi16(gray16_3, start_end); - __m128i gray16_0_mulhi = _mm_mulhi_epi16(gray16_0, start_end); - __m128i gray16_1_mulhi = _mm_mulhi_epi16(gray16_1, start_end); - __m128i gray16_2_mulhi = _mm_mulhi_epi16(gray16_2, start_end); - __m128i gray16_3_mulhi = _mm_mulhi_epi16(gray16_3, start_end); - p32_0 = _mm_srli_epi32(_mm_add_epi32(_mm_unpacklo_epi16(gray16_0_mullo, gray16_0_mulhi), _mm_unpackhi_epi16(gray16_0_mullo, gray16_0_mulhi)), 8); - p32_1 = _mm_srli_epi32(_mm_add_epi32(_mm_unpacklo_epi16(gray16_1_mullo, gray16_1_mulhi), _mm_unpackhi_epi16(gray16_1_mullo, gray16_1_mulhi)), 8); - p32_2 = _mm_srli_epi32(_mm_add_epi32(_mm_unpacklo_epi16(gray16_2_mullo, gray16_2_mulhi), _mm_unpackhi_epi16(gray16_2_mullo, gray16_2_mulhi)), 8); - p32_3 = _mm_srli_epi32(_mm_add_epi32(_mm_unpacklo_epi16(gray16_3_mullo, gray16_3_mulhi), _mm_unpackhi_epi16(gray16_3_mullo, gray16_3_mulhi)), 8); + // p32 = start * inv_gray + end * gray: + __m128i gray0 = _mm_shuffle_epi32(gray, _MM_SHUFFLE(0, 0, 0, 0)); + __m128i gray1 = _mm_shuffle_epi32(gray, _MM_SHUFFLE(1, 1, 1, 1)); + __m128i gray2 = _mm_shuffle_epi32(gray, _MM_SHUFFLE(2, 2, 2, 2)); + __m128i gray3 = _mm_shuffle_epi32(gray, _MM_SHUFFLE(3, 3, 3, 3)); + __m128i inv_gray0 = _mm_shuffle_epi32(inv_gray, _MM_SHUFFLE(0, 0, 0, 0)); + __m128i inv_gray1 = _mm_shuffle_epi32(inv_gray, _MM_SHUFFLE(1, 1, 1, 1)); + __m128i inv_gray2 = _mm_shuffle_epi32(inv_gray, _MM_SHUFFLE(2, 2, 2, 2)); + __m128i inv_gray3 = _mm_shuffle_epi32(inv_gray, _MM_SHUFFLE(3, 3, 3, 3)); + __m128i gray16_0 = _mm_packs_epi32(gray0, inv_gray0); + __m128i gray16_1 = _mm_packs_epi32(gray1, inv_gray1); + __m128i gray16_2 = _mm_packs_epi32(gray2, inv_gray2); + __m128i gray16_3 = _mm_packs_epi32(gray3, inv_gray3); + __m128i gray16_0_mullo = _mm_mullo_epi16(gray16_0, start_end); + __m128i gray16_1_mullo = _mm_mullo_epi16(gray16_1, start_end); + __m128i gray16_2_mullo = _mm_mullo_epi16(gray16_2, start_end); + __m128i gray16_3_mullo = _mm_mullo_epi16(gray16_3, start_end); + __m128i gray16_0_mulhi = _mm_mulhi_epi16(gray16_0, start_end); + __m128i gray16_1_mulhi = _mm_mulhi_epi16(gray16_1, start_end); + __m128i gray16_2_mulhi = _mm_mulhi_epi16(gray16_2, start_end); + __m128i gray16_3_mulhi = _mm_mulhi_epi16(gray16_3, start_end); + p32_0 = _mm_srli_epi32(_mm_add_epi32(_mm_unpacklo_epi16(gray16_0_mullo, gray16_0_mulhi), _mm_unpackhi_epi16(gray16_0_mullo, gray16_0_mulhi)), 8); + p32_1 = _mm_srli_epi32(_mm_add_epi32(_mm_unpacklo_epi16(gray16_1_mullo, gray16_1_mulhi), _mm_unpackhi_epi16(gray16_1_mullo, gray16_1_mulhi)), 8); + p32_2 = _mm_srli_epi32(_mm_add_epi32(_mm_unpacklo_epi16(gray16_2_mullo, gray16_2_mulhi), _mm_unpackhi_epi16(gray16_2_mullo, gray16_2_mulhi)), 8); + p32_3 = _mm_srli_epi32(_mm_add_epi32(_mm_unpacklo_epi16(gray16_3_mullo, gray16_3_mulhi), _mm_unpackhi_epi16(gray16_3_mullo, gray16_3_mulhi)), 8); - p16_0 = _mm_packs_epi32(p32_0, p32_1); - p16_1 = _mm_packs_epi32(p32_2, p32_3); - p = _mm_packus_epi16(p16_0, p16_1); + p16_0 = _mm_packs_epi32(p32_0, p32_1); + p16_1 = _mm_packs_epi32(p32_2, p32_3); + p = _mm_packus_epi16(p16_0, p16_1); - _mm_storeu_si128((__m128i*)pixels, p); - pixels += 16; + _mm_storeu_si128((__m128i*)pixels, p); + pixels += 16; + } + + for (int x = sse_length * 4; x < width; x++) + { + int fg_red = pixels[2]; + int fg_green = pixels[1]; + int fg_blue = pixels[0]; + + int gray = (fg_red * 77 + fg_green * 143 + fg_blue * 37) >> 8; + gray += (gray >> 7); // gray*=256/255 + int inv_gray = 256 - gray; + + int red = clamp((start_red * inv_gray + end_red * gray) >> 8, 0, 255); + int green = clamp((start_green * inv_gray + end_green * gray) >> 8, 0, 255); + int blue = clamp((start_blue * inv_gray + end_blue * gray) >> 8, 0, 255); + + pixels[0] = (uint8_t)blue; + pixels[1] = (uint8_t)green; + pixels[2] = (uint8_t)red; + pixels[3] = 0xff; + + pixels += 4; + } + + y += thread->num_cores; + count--; } - - for (int x = sse_length * 4; x < width; x++) - { - int fg_red = pixels[2]; - int fg_green = pixels[1]; - int fg_blue = pixels[0]; - - int gray = (fg_red * 77 + fg_green * 143 + fg_blue * 37) >> 8; - gray += (gray >> 7); // gray*=256/255 - int inv_gray = 256 - gray; - - int red = clamp((start_red * inv_gray + end_red * gray) >> 8, 0, 255); - int green = clamp((start_green * inv_gray + end_green * gray) >> 8, 0, 255); - int blue = clamp((start_blue * inv_gray + end_blue * gray) >> 8, 0, 255); - - pixels[0] = (BYTE)blue; - pixels[1] = (BYTE)green; - pixels[2] = (BYTE)red; - pixels[3] = 0xff; - - pixels += 4; - } - - y += thread->num_cores; - count--; } -} #endif -///////////////////////////////////////////////////////////////////////////// - -void R_DrawSingleSkyCol1_rgba(uint32_t solid_top, uint32_t solid_bottom) -{ - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); -} - -void R_DrawSingleSkyCol4_rgba(uint32_t solid_top, uint32_t solid_bottom) -{ - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); -} - -void R_DrawDoubleSkyCol1_rgba(uint32_t solid_top, uint32_t solid_bottom) -{ - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); -} - -void R_DrawDoubleSkyCol4_rgba(uint32_t solid_top, uint32_t solid_bottom) -{ - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); -} - -void R_DrawColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_FillColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_FillAddColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_FillAddClampColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_FillSubClampColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_FillRevSubClampColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawFuzzColumn_rgba() -{ - using namespace drawerargs; - - DrawerCommandQueue::QueueCommand(); - - dc_yl = MAX(dc_yl, 1); - dc_yh = MIN(dc_yh, fuzzviewheight); - if (dc_yl <= dc_yh) - fuzzpos = (fuzzpos + dc_yh - dc_yl + 1) % FUZZTABLE; -} - -void R_DrawAddColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawTranslatedColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawTlatedAddColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawShadedColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawAddClampColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawAddClampTranslatedColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawSubClampColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawSubClampTranslatedColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawRevSubClampColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawRevSubClampTranslatedColumn_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawSpan_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawSpanMasked_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawSpanTranslucent_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawSpanMaskedTranslucent_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawSpanAddClamp_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawSpanMaskedAddClamp_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_FillSpan_rgba() -{ - DrawerCommandQueue::QueueCommand(); -} - -void R_DrawTiltedSpan_rgba(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) -{ - DrawerCommandQueue::QueueCommand(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); -} - -void R_DrawColoredSpan_rgba(int y, int x1, int x2) -{ - DrawerCommandQueue::QueueCommand(y, x1, x2); -} - -static ShadeConstants slab_rgba_shade_constants; -static const BYTE *slab_rgba_colormap; -static fixed_t slab_rgba_light; - -void R_SetupDrawSlab_rgba(FSWColormap *base_colormap, float light, int shade) -{ - slab_rgba_shade_constants.light_red = base_colormap->Color.r * 256 / 255; - slab_rgba_shade_constants.light_green = base_colormap->Color.g * 256 / 255; - slab_rgba_shade_constants.light_blue = base_colormap->Color.b * 256 / 255; - slab_rgba_shade_constants.light_alpha = base_colormap->Color.a * 256 / 255; - slab_rgba_shade_constants.fade_red = base_colormap->Fade.r; - slab_rgba_shade_constants.fade_green = base_colormap->Fade.g; - slab_rgba_shade_constants.fade_blue = base_colormap->Fade.b; - slab_rgba_shade_constants.fade_alpha = base_colormap->Fade.a; - slab_rgba_shade_constants.desaturate = MIN(abs(base_colormap->Desaturate), 255) * 255 / 256; - slab_rgba_shade_constants.simple_shade = (base_colormap->Color.d == 0x00ffffff && base_colormap->Fade.d == 0x00000000 && base_colormap->Desaturate == 0); - slab_rgba_colormap = base_colormap->Maps; - slab_rgba_light = LIGHTSCALE(light, shade); -} - -void R_DrawSlab_rgba(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p) -{ - DrawerCommandQueue::QueueCommand(dx, v, dy, vi, vptr, p, slab_rgba_shade_constants, slab_rgba_colormap, slab_rgba_light); -} - -DWORD vlinec1_rgba() -{ - using namespace drawerargs; - - DrawerCommandQueue::QueueCommand(); - return dc_texturefrac + dc_count * dc_iscale; -} - -void vlinec4_rgba() -{ - using namespace drawerargs; - - DrawerCommandQueue::QueueCommand(); - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; -} - -DWORD mvlinec1_rgba() -{ - using namespace drawerargs; - - DrawerCommandQueue::QueueCommand(); - return dc_texturefrac + dc_count * dc_iscale; -} - -void mvlinec4_rgba() -{ - using namespace drawerargs; - - DrawerCommandQueue::QueueCommand(); - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; -} - -fixed_t tmvline1_add_rgba() -{ - using namespace drawerargs; - - DrawerCommandQueue::QueueCommand(); - return dc_texturefrac + dc_count * dc_iscale; -} - -void tmvline4_add_rgba() -{ - using namespace drawerargs; - - DrawerCommandQueue::QueueCommand(); - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; -} - -fixed_t tmvline1_addclamp_rgba() -{ - using namespace drawerargs; - - DrawerCommandQueue::QueueCommand(); - return dc_texturefrac + dc_count * dc_iscale; -} - -void tmvline4_addclamp_rgba() -{ - using namespace drawerargs; - - DrawerCommandQueue::QueueCommand(); - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; -} - -fixed_t tmvline1_subclamp_rgba() -{ - using namespace drawerargs; - - DrawerCommandQueue::QueueCommand(); - return dc_texturefrac + dc_count * dc_iscale; -} - -void tmvline4_subclamp_rgba() -{ - using namespace drawerargs; - - DrawerCommandQueue::QueueCommand(); - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; -} - -fixed_t tmvline1_revsubclamp_rgba() -{ - using namespace drawerargs; - - DrawerCommandQueue::QueueCommand(); - return dc_texturefrac + dc_count * dc_iscale; -} - -void tmvline4_revsubclamp_rgba() -{ - using namespace drawerargs; - - DrawerCommandQueue::QueueCommand(); - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; -} - -void R_DrawFogBoundarySection_rgba(int y, int y2, int x1) -{ - for (; y < y2; ++y) - { - int x2 = spanend[y]; - DrawerCommandQueue::QueueCommand(y, x1, x2); - } -} - -void R_DrawFogBoundary_rgba(int x1, int x2, short *uclip, short *dclip) -{ - // To do: we do not need to create new spans when using rgba output - instead we should calculate light on a per pixel basis - - // This is essentially the same as R_MapVisPlane but with an extra step - // to create new horizontal spans whenever the light changes enough that - // we need to use a new colormap. - - double lightstep = rw_lightstep; - double light = rw_light + rw_lightstep*(x2 - x1 - 1); - int x = x2 - 1; - int t2 = uclip[x]; - int b2 = dclip[x]; - int rcolormap = GETPALOOKUP(light, wallshade); - int lcolormap; - BYTE *basecolormapdata = basecolormap->Maps; - - if (b2 > t2) - { - clearbufshort(spanend + t2, b2 - t2, x); - } - - R_SetColorMapLight(basecolormap, (float)light, wallshade); - - BYTE *fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); - - for (--x; x >= x1; --x) - { - int t1 = uclip[x]; - int b1 = dclip[x]; - const int xr = x + 1; - int stop; - - light -= rw_lightstep; - lcolormap = GETPALOOKUP(light, wallshade); - if (lcolormap != rcolormap) - { - if (t2 < b2 && rcolormap != 0) - { // Colormap 0 is always the identity map, so rendering it is - // just a waste of time. - R_DrawFogBoundarySection_rgba(t2, b2, xr); - } - if (t1 < t2) t2 = t1; - if (b1 > b2) b2 = b1; - if (t2 < b2) - { - clearbufshort(spanend + t2, b2 - t2, x); - } - rcolormap = lcolormap; - R_SetColorMapLight(basecolormap, (float)light, wallshade); - fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); - } - else - { - if (fake_dc_colormap != basecolormapdata) - { - stop = MIN(t1, b2); - while (t2 < stop) - { - int y = t2++; - DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); - } - stop = MAX(b1, t2); - while (b2 > stop) - { - int y = --b2; - DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); - } - } - else - { - t2 = MAX(t2, MIN(t1, b2)); - b2 = MIN(b2, MAX(b1, t2)); - } - - stop = MIN(t2, b1); - while (t1 < stop) - { - spanend[t1++] = x; - } - stop = MAX(b2, t2); - while (b1 > stop) - { - spanend[--b1] = x; - } - } - - t2 = uclip[x]; - b2 = dclip[x]; - } - if (t2 < b2 && rcolormap != 0) - { - R_DrawFogBoundarySection_rgba(t2, b2, x1); - } -} - } diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 5d159164e..079074068 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -1,31 +1,31 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// $Id:$ -// -// Copyright (C) 1993-1996 by id Software, Inc. -// -// This source is available for distribution and/or modification -// only under the terms of the DOOM Source Code License as -// published by id Software. All rights reserved. -// -// The source is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License -// for more details. -// -// DESCRIPTION: -// System specific interface stuff. -// -//----------------------------------------------------------------------------- +/* +** Drawer commands for the RT family of drawers +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ - -#ifndef __R_DRAW_RGBA__ -#define __R_DRAW_RGBA__ +#pragma once #include "r_draw.h" #include "v_palette.h" #include "r_thread.h" +#include "r_drawers.h" #ifndef NO_SSE #include @@ -38,173 +38,511 @@ EXTERN_CVAR(Float, r_lod_bias) namespace swrenderer { + // Give the compiler a strong hint we want these functions inlined: + #ifndef FORCEINLINE + #if defined(_MSC_VER) + #define FORCEINLINE __forceinline + #elif defined(__GNUC__) + #define FORCEINLINE __attribute__((always_inline)) inline + #else + #define FORCEINLINE inline + #endif + #endif -///////////////////////////////////////////////////////////////////////////// -// Drawer commands: + // Promise compiler we have no aliasing of this pointer + #ifndef RESTRICT + #if defined(_MSC_VER) + #define RESTRICT __restrict + #elif defined(__GNUC__) + #define RESTRICT __restrict__ + #else + #define RESTRICT + #endif + #endif -class ApplySpecialColormapRGBACommand : public DrawerCommand -{ - BYTE *buffer; - int pitch; - int width; - int height; - int start_red; - int start_green; - int start_blue; - int end_red; - int end_green; - int end_blue; + #define DECLARE_DRAW_COMMAND(name, func, base) \ + class name##LLVMCommand : public base \ + { \ + public: \ + using base::base; \ + void Execute(DrawerThread *thread) override \ + { \ + WorkerThreadData d = ThreadData(thread); \ + Drawers::Instance()->func(&args, &d); \ + } \ + }; -public: - ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen); - void Execute(DrawerThread *thread) override; - FString DebugInfo() override { return "ApplySpecialColormapRGBACommand"; } -}; - -template -class DrawerBlendCommand : public CommandType -{ -public: - void Execute(DrawerThread *thread) override + class DrawSpanLLVMCommand : public DrawerCommand { - typename CommandType::LoopIterator loop(this, thread); - if (!loop) return; - BlendMode blend(*this, loop); - do + public: + DrawSpanLLVMCommand(); + + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + + protected: + DrawSpanArgs args; + + private: + inline static bool sampler_setup(const uint32_t * &source, int &xbits, int &ybits, bool mipmapped); + }; + + class DrawSpanMaskedLLVMCommand : public DrawSpanLLVMCommand + { + public: + void Execute(DrawerThread *thread) override; + }; + + class DrawSpanTranslucentLLVMCommand : public DrawSpanLLVMCommand + { + public: + void Execute(DrawerThread *thread) override; + }; + + class DrawSpanMaskedTranslucentLLVMCommand : public DrawSpanLLVMCommand + { + public: + void Execute(DrawerThread *thread) override; + }; + + class DrawSpanAddClampLLVMCommand : public DrawSpanLLVMCommand + { + public: + void Execute(DrawerThread *thread) override; + }; + + class DrawSpanMaskedAddClampLLVMCommand : public DrawSpanLLVMCommand + { + public: + void Execute(DrawerThread *thread) override; + }; + + class DrawWall4LLVMCommand : public DrawerCommand + { + protected: + DrawWallArgs args; + + WorkerThreadData ThreadData(DrawerThread *thread); + + public: + DrawWall4LLVMCommand(); + + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + }; + + class DrawWall1LLVMCommand : public DrawerCommand + { + protected: + DrawWallArgs args; + + WorkerThreadData ThreadData(DrawerThread *thread); + + public: + DrawWall1LLVMCommand(); + + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + }; + + class DrawColumnLLVMCommand : public DrawerCommand + { + protected: + DrawColumnArgs args; + + WorkerThreadData ThreadData(DrawerThread *thread); + FString DebugInfo() override; + + public: + DrawColumnLLVMCommand(); + + void Execute(DrawerThread *thread) override; + }; + + class DrawSkyLLVMCommand : public DrawerCommand + { + protected: + DrawSkyArgs args; + + WorkerThreadData ThreadData(DrawerThread *thread); + + public: + DrawSkyLLVMCommand(uint32_t solid_top, uint32_t solid_bottom); + FString DebugInfo() override; + }; + + DECLARE_DRAW_COMMAND(DrawWallMasked4, mvlinec4, DrawWall4LLVMCommand); + DECLARE_DRAW_COMMAND(DrawWallAdd4, tmvline4_add, DrawWall4LLVMCommand); + DECLARE_DRAW_COMMAND(DrawWallAddClamp4, tmvline4_addclamp, DrawWall4LLVMCommand); + DECLARE_DRAW_COMMAND(DrawWallSubClamp4, tmvline4_subclamp, DrawWall4LLVMCommand); + DECLARE_DRAW_COMMAND(DrawWallRevSubClamp4, tmvline4_revsubclamp, DrawWall4LLVMCommand); + DECLARE_DRAW_COMMAND(DrawWallMasked1, mvlinec1, DrawWall1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawWallAdd1, tmvline1_add, DrawWall1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawWallAddClamp1, tmvline1_addclamp, DrawWall1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawWallSubClamp1, tmvline1_subclamp, DrawWall1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawWallRevSubClamp1, tmvline1_revsubclamp, DrawWall1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnAdd, DrawColumnAdd, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnTranslated, DrawColumnTranslated, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnTlatedAdd, DrawColumnTlatedAdd, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnShaded, DrawColumnShaded, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnAddClamp, DrawColumnAddClamp, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnAddClampTranslated, DrawColumnAddClampTranslated, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnSubClamp, DrawColumnSubClamp, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnSubClampTranslated, DrawColumnSubClampTranslated, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRevSubClamp, DrawColumnRevSubClamp, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRevSubClampTranslated, DrawColumnRevSubClampTranslated, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(FillColumn, FillColumn, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(FillColumnAdd, FillColumnAdd, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(FillColumnAddClamp, FillColumnAddClamp, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(FillColumnSubClamp, FillColumnSubClamp, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(FillColumnRevSubClamp, FillColumnRevSubClamp, DrawColumnLLVMCommand); + DECLARE_DRAW_COMMAND(DrawSingleSky1, DrawSky1, DrawSkyLLVMCommand); + DECLARE_DRAW_COMMAND(DrawSingleSky4, DrawSky4, DrawSkyLLVMCommand); + DECLARE_DRAW_COMMAND(DrawDoubleSky1, DrawDoubleSky1, DrawSkyLLVMCommand); + DECLARE_DRAW_COMMAND(DrawDoubleSky4, DrawDoubleSky4, DrawSkyLLVMCommand); + + class DrawFuzzColumnRGBACommand : public DrawerCommand + { + int _x; + int _yl; + int _yh; + uint8_t * RESTRICT _destorg; + int _pitch; + int _fuzzpos; + int _fuzzviewheight; + + public: + DrawFuzzColumnRGBACommand(); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + }; + + class FillSpanRGBACommand : public DrawerCommand + { + int _x1; + int _x2; + int _y; + uint8_t * RESTRICT _destorg; + fixed_t _light; + int _color; + + public: + FillSpanRGBACommand(); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + }; + + class DrawSlabRGBACommand : public DrawerCommand + { + int _dx; + fixed_t _v; + int _dy; + fixed_t _vi; + const uint8_t *_voxelptr; + uint32_t *_p; + ShadeConstants _shade_constants; + const uint8_t *_colormap; + fixed_t _light; + int _pitch; + int _start_y; + + public: + DrawSlabRGBACommand(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p, ShadeConstants shade_constants, const uint8_t *colormap, fixed_t light); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + }; + + class DrawFogBoundaryLineRGBACommand : public DrawerCommand + { + int _y; + int _x; + int _x2; + uint8_t * RESTRICT _destorg; + fixed_t _light; + ShadeConstants _shade_constants; + + public: + DrawFogBoundaryLineRGBACommand(int y, int x, int x2); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + }; + + class DrawTiltedSpanRGBACommand : public DrawerCommand + { + int _x1; + int _x2; + int _y; + uint8_t * RESTRICT _destorg; + fixed_t _light; + ShadeConstants _shade_constants; + FVector3 _plane_sz; + FVector3 _plane_su; + FVector3 _plane_sv; + bool _plane_shade; + int _planeshade; + float _planelightfloat; + fixed_t _pviewx; + fixed_t _pviewy; + int _xbits; + int _ybits; + const uint32_t * RESTRICT _source; + + public: + DrawTiltedSpanRGBACommand(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + }; + + class DrawColoredSpanRGBACommand : public DrawerCommand + { + int _y; + int _x1; + int _x2; + uint8_t * RESTRICT _destorg; + fixed_t _light; + int _color; + + public: + DrawColoredSpanRGBACommand(int y, int x1, int x2); + + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + }; + + class FillTransColumnRGBACommand : public DrawerCommand + { + int _x; + int _y1; + int _y2; + int _color; + int _a; + uint8_t * RESTRICT _destorg; + int _pitch; + fixed_t _light; + + public: + FillTransColumnRGBACommand(int x, int y1, int y2, int color, int a); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + }; + + class ApplySpecialColormapRGBACommand : public DrawerCommand + { + uint8_t *buffer; + int pitch; + int width; + int height; + int start_red; + int start_green; + int start_blue; + int end_red; + int end_green; + int end_blue; + + public: + ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override { return "ApplySpecialColormapRGBACommand"; } + }; + + template + class DrawerBlendCommand : public CommandType + { + public: + void Execute(DrawerThread *thread) override { - blend.Blend(*this, loop); - } while (loop.next()); - } -}; + typename CommandType::LoopIterator loop(this, thread); + if (!loop) return; + BlendMode blend(*this, loop); + do + { + blend.Blend(*this, loop); + } while (loop.next()); + } + }; -///////////////////////////////////////////////////////////////////////////// -// Pixel shading inline functions: - -// Give the compiler a strong hint we want these functions inlined: -#ifndef FORCEINLINE -#if defined(_MSC_VER) -#define FORCEINLINE __forceinline -#elif defined(__GNUC__) -#define FORCEINLINE __attribute__((always_inline)) inline -#else -#define FORCEINLINE inline -#endif -#endif - -// Promise compiler we have no aliasing of this pointer -#ifndef RESTRICT -#if defined(_MSC_VER) -#define RESTRICT __restrict -#elif defined(__GNUC__) -#define RESTRICT __restrict__ -#else -#define RESTRICT -#endif -#endif - -class LightBgra -{ -public: - // calculates the light constant passed to the shade_pal_index function - FORCEINLINE static uint32_t calc_light_multiplier(dsfixed_t light) + class DrawColumnRt1LLVMCommand : public DrawerCommand { - return 256 - (light >> (FRACBITS - 8)); - } + protected: + DrawColumnArgs args; + WorkerThreadData ThreadData(DrawerThread *thread); - // Calculates a ARGB8 color for the given palette index and light multiplier - FORCEINLINE static uint32_t shade_pal_index_simple(uint32_t index, uint32_t light) + public: + DrawColumnRt1LLVMCommand(int hx, int sx, int yl, int yh); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + }; + + DECLARE_DRAW_COMMAND(DrawColumnRt1Copy, DrawColumnRt1Copy, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt1Add, DrawColumnRt1Add, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt1Shaded, DrawColumnRt1Shaded, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt1AddClamp, DrawColumnRt1AddClamp, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt1SubClamp, DrawColumnRt1SubClamp, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt1RevSubClamp, DrawColumnRt1RevSubClamp, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt1Translated, DrawColumnRt1Translated, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt1TlatedAdd, DrawColumnRt1TlatedAdd, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt1AddClampTranslated, DrawColumnRt1AddClampTranslated, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt1SubClampTranslated, DrawColumnRt1SubClampTranslated, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt1RevSubClampTranslated, DrawColumnRt1RevSubClampTranslated, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt4, DrawColumnRt4, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt4Copy, DrawColumnRt4Copy, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt4Add, DrawColumnRt4Add, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt4Shaded, DrawColumnRt4Shaded, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt4AddClamp, DrawColumnRt4AddClamp, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt4SubClamp, DrawColumnRt4SubClamp, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt4RevSubClamp, DrawColumnRt4RevSubClamp, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt4Translated, DrawColumnRt4Translated, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt4TlatedAdd, DrawColumnRt4TlatedAdd, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt4AddClampTranslated, DrawColumnRt4AddClampTranslated, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt4SubClampTranslated, DrawColumnRt4SubClampTranslated, DrawColumnRt1LLVMCommand); + DECLARE_DRAW_COMMAND(DrawColumnRt4RevSubClampTranslated, DrawColumnRt4RevSubClampTranslated, DrawColumnRt1LLVMCommand); + + ///////////////////////////////////////////////////////////////////////////// + + class RtInitColsRGBACommand : public DrawerCommand { - const PalEntry &color = GPalette.BaseColors[index]; - uint32_t red = color.r; - uint32_t green = color.g; - uint32_t blue = color.b; + BYTE * RESTRICT buff; - red = red * light / 256; - green = green * light / 256; - blue = blue * light / 256; + public: + RtInitColsRGBACommand(BYTE *buff); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + }; - return 0xff000000 | (red << 16) | (green << 8) | blue; - } - - // Calculates a ARGB8 color for the given palette index, light multiplier and dynamic colormap - FORCEINLINE static uint32_t shade_pal_index(uint32_t index, uint32_t light, const ShadeConstants &constants) + template + class DrawColumnHorizRGBACommand : public DrawerCommand { - const PalEntry &color = GPalette.BaseColors[index]; - uint32_t alpha = color.d & 0xff000000; - uint32_t red = color.r; - uint32_t green = color.g; - uint32_t blue = color.b; - if (constants.simple_shade) + int _count; + fixed_t _iscale; + fixed_t _texturefrac; + const InputPixelType * RESTRICT _source; + int _x; + int _yl; + int _yh; + + public: + DrawColumnHorizRGBACommand(); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + }; + + class FillColumnHorizRGBACommand : public DrawerCommand + { + int _x; + int _yl; + int _yh; + int _count; + uint32_t _color; + + public: + FillColumnHorizRGBACommand(); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + }; + + ///////////////////////////////////////////////////////////////////////////// + // Pixel shading inline functions: + + class LightBgra + { + public: + // calculates the light constant passed to the shade_pal_index function + FORCEINLINE static uint32_t calc_light_multiplier(dsfixed_t light) { + return 256 - (light >> (FRACBITS - 8)); + } + + // Calculates a ARGB8 color for the given palette index and light multiplier + FORCEINLINE static uint32_t shade_pal_index_simple(uint32_t index, uint32_t light) + { + const PalEntry &color = GPalette.BaseColors[index]; + uint32_t red = color.r; + uint32_t green = color.g; + uint32_t blue = color.b; + red = red * light / 256; green = green * light / 256; blue = blue * light / 256; + + return 0xff000000 | (red << 16) | (green << 8) | blue; } - else + + // Calculates a ARGB8 color for the given palette index, light multiplier and dynamic colormap + FORCEINLINE static uint32_t shade_pal_index(uint32_t index, uint32_t light, const ShadeConstants &constants) { - uint32_t inv_light = 256 - light; - uint32_t inv_desaturate = 256 - constants.desaturate; + const PalEntry &color = GPalette.BaseColors[index]; + uint32_t alpha = color.d & 0xff000000; + uint32_t red = color.r; + uint32_t green = color.g; + uint32_t blue = color.b; + if (constants.simple_shade) + { + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; + } + else + { + uint32_t inv_light = 256 - light; + uint32_t inv_desaturate = 256 - constants.desaturate; - uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; + uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; - red = (red * inv_desaturate + intensity) / 256; - green = (green * inv_desaturate + intensity) / 256; - blue = (blue * inv_desaturate + intensity) / 256; + red = (red * inv_desaturate + intensity) / 256; + green = (green * inv_desaturate + intensity) / 256; + blue = (blue * inv_desaturate + intensity) / 256; - red = (constants.fade_red * inv_light + red * light) / 256; - green = (constants.fade_green * inv_light + green * light) / 256; - blue = (constants.fade_blue * inv_light + blue * light) / 256; + red = (constants.fade_red * inv_light + red * light) / 256; + green = (constants.fade_green * inv_light + green * light) / 256; + blue = (constants.fade_blue * inv_light + blue * light) / 256; - red = (red * constants.light_red) / 256; - green = (green * constants.light_green) / 256; - blue = (blue * constants.light_blue) / 256; + red = (red * constants.light_red) / 256; + green = (green * constants.light_green) / 256; + blue = (blue * constants.light_blue) / 256; + } + return alpha | (red << 16) | (green << 8) | blue; } - return alpha | (red << 16) | (green << 8) | blue; - } - FORCEINLINE static uint32_t shade_bgra_simple(uint32_t color, uint32_t light) - { - uint32_t red = RPART(color) * light / 256; - uint32_t green = GPART(color) * light / 256; - uint32_t blue = BPART(color) * light / 256; - return 0xff000000 | (red << 16) | (green << 8) | blue; - } - - FORCEINLINE static uint32_t shade_bgra(uint32_t color, uint32_t light, const ShadeConstants &constants) - { - uint32_t alpha = color & 0xff000000; - uint32_t red = (color >> 16) & 0xff; - uint32_t green = (color >> 8) & 0xff; - uint32_t blue = color & 0xff; - if (constants.simple_shade) + FORCEINLINE static uint32_t shade_bgra_simple(uint32_t color, uint32_t light) { - red = red * light / 256; - green = green * light / 256; - blue = blue * light / 256; + uint32_t red = RPART(color) * light / 256; + uint32_t green = GPART(color) * light / 256; + uint32_t blue = BPART(color) * light / 256; + return 0xff000000 | (red << 16) | (green << 8) | blue; } - else + + FORCEINLINE static uint32_t shade_bgra(uint32_t color, uint32_t light, const ShadeConstants &constants) { - uint32_t inv_light = 256 - light; - uint32_t inv_desaturate = 256 - constants.desaturate; + uint32_t alpha = color & 0xff000000; + uint32_t red = (color >> 16) & 0xff; + uint32_t green = (color >> 8) & 0xff; + uint32_t blue = color & 0xff; + if (constants.simple_shade) + { + red = red * light / 256; + green = green * light / 256; + blue = blue * light / 256; + } + else + { + uint32_t inv_light = 256 - light; + uint32_t inv_desaturate = 256 - constants.desaturate; - uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; + uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; - red = (red * inv_desaturate + intensity) / 256; - green = (green * inv_desaturate + intensity) / 256; - blue = (blue * inv_desaturate + intensity) / 256; + red = (red * inv_desaturate + intensity) / 256; + green = (green * inv_desaturate + intensity) / 256; + blue = (blue * inv_desaturate + intensity) / 256; - red = (constants.fade_red * inv_light + red * light) / 256; - green = (constants.fade_green * inv_light + green * light) / 256; - blue = (constants.fade_blue * inv_light + blue * light) / 256; + red = (constants.fade_red * inv_light + red * light) / 256; + green = (constants.fade_green * inv_light + green * light) / 256; + blue = (constants.fade_blue * inv_light + blue * light) / 256; - red = (red * constants.light_red) / 256; - green = (green * constants.light_green) / 256; - blue = (blue * constants.light_blue) / 256; + red = (red * constants.light_red) / 256; + green = (green * constants.light_green) / 256; + blue = (blue * constants.light_blue) / 256; + } + return alpha | (red << 16) | (green << 8) | blue; } - return alpha | (red << 16) | (green << 8) | blue; - } -}; - + }; } - -#endif diff --git a/src/r_draw_tc.cpp b/src/r_draw_tc.cpp new file mode 100644 index 000000000..a531d4aa9 --- /dev/null +++ b/src/r_draw_tc.cpp @@ -0,0 +1,1411 @@ + +#include + +#include "templates.h" +#include "doomdef.h" +#include "i_system.h" +#include "w_wad.h" +#include "r_local.h" +#include "v_video.h" +#include "doomstat.h" +#include "st_stuff.h" +#include "g_game.h" +#include "g_level.h" +#include "r_data/r_translate.h" +#include "v_palette.h" +#include "r_data/colormaps.h" +#include "r_plane.h" +#include "r_draw_tc.h" +#include "r_draw_rgba.h" +#include "r_thread.h" + +namespace swrenderer +{ + // Needed by R_DrawFogBoundary (which probably shouldn't be part of this file) + extern "C" short spanend[MAXHEIGHT]; + extern float rw_light; + extern float rw_lightstep; + extern int wallshade; + + double dc_texturemid; + + int ylookup[MAXHEIGHT]; + uint8_t shadetables[NUMCOLORMAPS * 16 * 256]; + FDynamicColormap ShadeFakeColormap[16]; + uint8_t identitymap[256]; + FDynamicColormap identitycolormap; + int fuzzoffset[FUZZTABLE + 1]; + int fuzzpos; + int fuzzviewheight; + + namespace drawerargs + { + int dc_pitch; + lighttable_t *dc_colormap; + FSWColormap *dc_fcolormap; + ShadeConstants dc_shade_constants; + fixed_t dc_light; + int dc_x; + int dc_yl; + int dc_yh; + fixed_t dc_iscale; + fixed_t dc_texturefrac; + uint32_t dc_textureheight; + int dc_color; + uint32_t dc_srccolor; + uint32_t dc_srccolor_bgra; + uint32_t *dc_srcblend; + uint32_t *dc_destblend; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + const uint8_t *dc_source; + const uint8_t *dc_source2; + uint32_t dc_texturefracx; + uint8_t *dc_translation; + uint8_t *dc_dest; + uint8_t *dc_destorg; + int dc_destheight; + int dc_count; + uint32_t vplce[4]; + uint32_t vince[4]; + uint8_t *palookupoffse[4]; + fixed_t palookuplight[4]; + const uint8_t *bufplce[4]; + const uint8_t *bufplce2[4]; + uint32_t buftexturefracx[4]; + uint32_t bufheight[4]; + int vlinebits; + int mvlinebits; + int tmvlinebits; + int ds_y; + int ds_x1; + int ds_x2; + lighttable_t * ds_colormap; + FSWColormap *ds_fcolormap; + ShadeConstants ds_shade_constants; + dsfixed_t ds_light; + dsfixed_t ds_xfrac; + dsfixed_t ds_yfrac; + dsfixed_t ds_xstep; + dsfixed_t ds_ystep; + int ds_xbits; + int ds_ybits; + fixed_t ds_alpha; + double ds_lod; + const uint8_t *ds_source; + bool ds_source_mipmapped; + int ds_color; + bool drawer_needs_pal_input; + unsigned int dc_tspans[4][MAXHEIGHT]; + unsigned int *dc_ctspan[4]; + unsigned int *horizspan[4]; + } + + void R_InitColumnDrawers() + { + colfunc = basecolfunc = R_DrawColumn; + fuzzcolfunc = R_DrawFuzzColumn; + transcolfunc = R_DrawTranslatedColumn; + spanfunc = R_DrawSpan; + hcolfunc_pre = R_DrawColumnHoriz; + hcolfunc_post1 = rt_map1col; + hcolfunc_post4 = rt_map4cols; + } + + void R_InitShadeMaps() + { + int i, j; + // set up shading tables for shaded columns + // 16 colormap sets, progressing from full alpha to minimum visible alpha + + uint8_t *table = shadetables; + + // Full alpha + for (i = 0; i < 16; ++i) + { + ShadeFakeColormap[i].Color = ~0u; + ShadeFakeColormap[i].Desaturate = ~0u; + ShadeFakeColormap[i].Next = NULL; + ShadeFakeColormap[i].Maps = table; + + for (j = 0; j < NUMCOLORMAPS; ++j) + { + int a = (NUMCOLORMAPS - j) * 256 / NUMCOLORMAPS * (16 - i); + for (int k = 0; k < 256; ++k) + { + uint8_t v = (((k + 2) * a) + 256) >> 14; + table[k] = MIN(v, 64); + } + table += 256; + } + } + for (i = 0; i < NUMCOLORMAPS * 16 * 256; ++i) + { + assert(shadetables[i] <= 64); + } + + // Set up a guaranteed identity map + for (i = 0; i < 256; ++i) + { + identitymap[i] = i; + } + } + + void R_InitFuzzTable(int fuzzoff) + { + /* + FUZZOFF,-FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, + FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, + FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF, + FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, + FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF, + FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF, + FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF + */ + + static const int8_t fuzzinit[FUZZTABLE] = { + 1,-1, 1,-1, 1, 1,-1, + 1, 1,-1, 1, 1, 1,-1, + 1, 1, 1,-1,-1,-1,-1, + 1,-1,-1, 1, 1, 1, 1,-1, + 1,-1, 1, 1,-1,-1, 1, + 1,-1,-1,-1,-1, 1, 1, + 1, 1,-1, 1, 1,-1, 1 + }; + + for (int i = 0; i < FUZZTABLE; i++) + { + fuzzoffset[i] = fuzzinit[i] * fuzzoff; + } + } + + namespace + { + bool R_SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags) + { + using namespace drawerargs; + + // r_drawtrans is a seriously bad thing to turn off. I wonder if I should + // just remove it completely. + if (!r_drawtrans || (op == STYLEOP_Add && fglevel == FRACUNIT && bglevel == 0 && !(flags & STYLEF_InvertSource))) + { + if (flags & STYLEF_ColorIsFixed) + { + colfunc = R_FillColumn; + hcolfunc_post1 = rt_copy1col; + hcolfunc_post4 = rt_copy4cols; + } + else if (dc_translation == NULL) + { + colfunc = basecolfunc; + hcolfunc_post1 = rt_map1col; + hcolfunc_post4 = rt_map4cols; + } + else + { + colfunc = transcolfunc; + hcolfunc_post1 = rt_tlate1col; + hcolfunc_post4 = rt_tlate4cols; + drawer_needs_pal_input = true; + } + return true; + } + if (flags & STYLEF_InvertSource) + { + dc_srcblend = Col2RGB8_Inverse[fglevel >> 10]; + dc_destblend = Col2RGB8_LessPrecision[bglevel >> 10]; + dc_srcalpha = fglevel; + dc_destalpha = bglevel; + } + else if (op == STYLEOP_Add && fglevel + bglevel <= FRACUNIT) + { + dc_srcblend = Col2RGB8[fglevel >> 10]; + dc_destblend = Col2RGB8[bglevel >> 10]; + dc_srcalpha = fglevel; + dc_destalpha = bglevel; + } + else + { + dc_srcblend = Col2RGB8_LessPrecision[fglevel >> 10]; + dc_destblend = Col2RGB8_LessPrecision[bglevel >> 10]; + dc_srcalpha = fglevel; + dc_destalpha = bglevel; + } + switch (op) + { + case STYLEOP_Add: + if (fglevel == 0 && bglevel == FRACUNIT) + { + return false; + } + if (fglevel + bglevel <= FRACUNIT) + { // Colors won't overflow when added + if (flags & STYLEF_ColorIsFixed) + { + colfunc = R_FillAddColumn; + hcolfunc_post1 = rt_add1col; + hcolfunc_post4 = rt_add4cols; + } + else if (dc_translation == NULL) + { + colfunc = R_DrawAddColumn; + hcolfunc_post1 = rt_add1col; + hcolfunc_post4 = rt_add4cols; + } + else + { + colfunc = R_DrawTlatedAddColumn; + hcolfunc_post1 = rt_tlateadd1col; + hcolfunc_post4 = rt_tlateadd4cols; + drawer_needs_pal_input = true; + } + } + else + { // Colors might overflow when added + if (flags & STYLEF_ColorIsFixed) + { + colfunc = R_FillAddClampColumn; + hcolfunc_post1 = rt_addclamp1col; + hcolfunc_post4 = rt_addclamp4cols; + } + else if (dc_translation == NULL) + { + colfunc = R_DrawAddClampColumn; + hcolfunc_post1 = rt_addclamp1col; + hcolfunc_post4 = rt_addclamp4cols; + } + else + { + colfunc = R_DrawAddClampTranslatedColumn; + hcolfunc_post1 = rt_tlateaddclamp1col; + hcolfunc_post4 = rt_tlateaddclamp4cols; + drawer_needs_pal_input = true; + } + } + return true; + + case STYLEOP_Sub: + if (flags & STYLEF_ColorIsFixed) + { + colfunc = R_FillSubClampColumn; + hcolfunc_post1 = rt_subclamp1col; + hcolfunc_post4 = rt_subclamp4cols; + } + else if (dc_translation == NULL) + { + colfunc = R_DrawSubClampColumn; + hcolfunc_post1 = rt_subclamp1col; + hcolfunc_post4 = rt_subclamp4cols; + } + else + { + colfunc = R_DrawSubClampTranslatedColumn; + hcolfunc_post1 = rt_tlatesubclamp1col; + hcolfunc_post4 = rt_tlatesubclamp4cols; + drawer_needs_pal_input = true; + } + return true; + + case STYLEOP_RevSub: + if (fglevel == 0 && bglevel == FRACUNIT) + { + return false; + } + if (flags & STYLEF_ColorIsFixed) + { + colfunc = R_FillRevSubClampColumn; + hcolfunc_post1 = rt_subclamp1col; + hcolfunc_post4 = rt_subclamp4cols; + } + else if (dc_translation == NULL) + { + colfunc = R_DrawRevSubClampColumn; + hcolfunc_post1 = rt_revsubclamp1col; + hcolfunc_post4 = rt_revsubclamp4cols; + } + else + { + colfunc = R_DrawRevSubClampTranslatedColumn; + hcolfunc_post1 = rt_tlaterevsubclamp1col; + hcolfunc_post4 = rt_tlaterevsubclamp4cols; + drawer_needs_pal_input = true; + } + return true; + + default: + return false; + } + } + + fixed_t GetAlpha(int type, fixed_t alpha) + { + switch (type) + { + case STYLEALPHA_Zero: return 0; + case STYLEALPHA_One: return OPAQUE; + case STYLEALPHA_Src: return alpha; + case STYLEALPHA_InvSrc: return OPAQUE - alpha; + default: return 0; + } + } + + FDynamicColormap *basecolormapsave; + } + + ESPSResult R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color) + { + using namespace drawerargs; + + fixed_t fglevel, bglevel; + + drawer_needs_pal_input = false; + + style.CheckFuzz(); + + if (style.BlendOp == STYLEOP_Shadow) + { + style = LegacyRenderStyles[STYLE_TranslucentStencil]; + alpha = TRANSLUC33; + color = 0; + } + + if (style.Flags & STYLEF_TransSoulsAlpha) + { + alpha = fixed_t(transsouls * OPAQUE); + } + else if (style.Flags & STYLEF_Alpha1) + { + alpha = FRACUNIT; + } + else + { + alpha = clamp(alpha, 0, OPAQUE); + } + + if (translation != -1) + { + dc_translation = NULL; + if (translation != 0) + { + FRemapTable *table = TranslationToTable(translation); + if (table != NULL && !table->Inactive) + { + if (r_swtruecolor) + dc_translation = (uint8_t*)table->Palette; + else + dc_translation = table->Remap; + } + } + } + basecolormapsave = basecolormap; + hcolfunc_pre = R_DrawColumnHoriz; + + // Check for special modes + if (style.BlendOp == STYLEOP_Fuzz) + { + colfunc = fuzzcolfunc; + return DoDraw0; + } + else if (style == LegacyRenderStyles[STYLE_Shaded]) + { + // Shaded drawer only gets 16 levels of alpha because it saves memory. + if ((alpha >>= 12) == 0) + return DontDraw; + colfunc = R_DrawShadedColumn; + hcolfunc_post1 = rt_shaded1col; + hcolfunc_post4 = rt_shaded4cols; + drawer_needs_pal_input = true; + dc_color = fixedcolormap ? fixedcolormap->Maps[APART(color)] : basecolormap->Maps[APART(color)]; + basecolormap = &ShadeFakeColormap[16 - alpha]; + if (fixedlightlev >= 0 && fixedcolormap == NULL) + { + R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + } + else + { + R_SetColorMapLight(basecolormap, 0, 0); + } + bool active_columnmethod = r_columnmethod && !r_swtruecolor; + return active_columnmethod ? DoDraw1 : DoDraw0; + } + + fglevel = GetAlpha(style.SrcAlpha, alpha); + bglevel = GetAlpha(style.DestAlpha, alpha); + + if (style.Flags & STYLEF_ColorIsFixed) + { + uint32_t x = fglevel >> 10; + uint32_t r = RPART(color); + uint32_t g = GPART(color); + uint32_t b = BPART(color); + // dc_color is used by the rt_* routines. It is indexed into dc_srcblend. + dc_color = RGB32k.RGB[r >> 3][g >> 3][b >> 3]; + if (style.Flags & STYLEF_InvertSource) + { + r = 255 - r; + g = 255 - g; + b = 255 - b; + } + uint32_t alpha = clamp(fglevel >> (FRACBITS - 8), 0, 255); + dc_srccolor_bgra = (alpha << 24) | (r << 16) | (g << 8) | b; + // dc_srccolor is used by the R_Fill* routines. It is premultiplied + // with the alpha. + dc_srccolor = ((((r*x) >> 4) << 20) | ((g*x) >> 4) | ((((b)*x) >> 4) << 10)) & 0x3feffbff; + hcolfunc_pre = R_FillColumnHoriz; + R_SetColorMapLight(&identitycolormap, 0, 0); + } + + if (!R_SetBlendFunc(style.BlendOp, fglevel, bglevel, style.Flags)) + { + return DontDraw; + } + bool active_columnmethod = r_columnmethod && !r_swtruecolor; + return active_columnmethod ? DoDraw1 : DoDraw0; + } + + ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color) + { + return R_SetPatchStyle(style, FLOAT2FIXED(alpha), translation, color); + } + + void R_FinishSetPatchStyle() + { + basecolormap = basecolormapsave; + } + + const uint8_t *R_GetColumn(FTexture *tex, int col) + { + int width; + + // If the texture's width isn't a power of 2, then we need to make it a + // positive offset for proper clamping. + if (col < 0 && (width = tex->GetWidth()) != (1 << tex->WidthBits)) + { + col = width + (col % width); + } + + if (r_swtruecolor) + return (const uint8_t *)tex->GetColumnBgra(col, nullptr); + else + return tex->GetColumn(col, nullptr); + } + + bool R_GetTransMaskDrawers(fixed_t(**tmvline1)(), void(**tmvline4)()) + { + if (colfunc == R_DrawAddColumn) + { + *tmvline1 = tmvline1_add; + *tmvline4 = tmvline4_add; + return true; + } + if (colfunc == R_DrawAddClampColumn) + { + *tmvline1 = tmvline1_addclamp; + *tmvline4 = tmvline4_addclamp; + return true; + } + if (colfunc == R_DrawSubClampColumn) + { + *tmvline1 = tmvline1_subclamp; + *tmvline4 = tmvline4_subclamp; + return true; + } + if (colfunc == R_DrawRevSubClampColumn) + { + *tmvline1 = tmvline1_revsubclamp; + *tmvline4 = tmvline4_revsubclamp; + return true; + } + return false; + } + + void setupvline(int fracbits) + { + drawerargs::vlinebits = fracbits; + } + + void setupmvline(int fracbits) + { + drawerargs::mvlinebits = fracbits; + } + + void setuptmvline(int fracbits) + { + drawerargs::tmvlinebits = fracbits; + } + + void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade) + { + using namespace drawerargs; + + dc_fcolormap = base_colormap; + if (r_swtruecolor) + { + dc_shade_constants.light_red = dc_fcolormap->Color.r * 256 / 255; + dc_shade_constants.light_green = dc_fcolormap->Color.g * 256 / 255; + dc_shade_constants.light_blue = dc_fcolormap->Color.b * 256 / 255; + dc_shade_constants.light_alpha = dc_fcolormap->Color.a * 256 / 255; + dc_shade_constants.fade_red = dc_fcolormap->Fade.r; + dc_shade_constants.fade_green = dc_fcolormap->Fade.g; + dc_shade_constants.fade_blue = dc_fcolormap->Fade.b; + dc_shade_constants.fade_alpha = dc_fcolormap->Fade.a; + dc_shade_constants.desaturate = MIN(abs(dc_fcolormap->Desaturate), 255) * 255 / 256; + dc_shade_constants.simple_shade = (dc_fcolormap->Color.d == 0x00ffffff && dc_fcolormap->Fade.d == 0x00000000 && dc_fcolormap->Desaturate == 0); + dc_colormap = base_colormap->Maps; + dc_light = LIGHTSCALE(light, shade); + } + else + { + dc_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); + } + } + + void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade) + { + using namespace drawerargs; + + ds_fcolormap = base_colormap; + if (r_swtruecolor) + { + ds_shade_constants.light_red = ds_fcolormap->Color.r * 256 / 255; + ds_shade_constants.light_green = ds_fcolormap->Color.g * 256 / 255; + ds_shade_constants.light_blue = ds_fcolormap->Color.b * 256 / 255; + ds_shade_constants.light_alpha = ds_fcolormap->Color.a * 256 / 255; + ds_shade_constants.fade_red = ds_fcolormap->Fade.r; + ds_shade_constants.fade_green = ds_fcolormap->Fade.g; + ds_shade_constants.fade_blue = ds_fcolormap->Fade.b; + ds_shade_constants.fade_alpha = ds_fcolormap->Fade.a; + ds_shade_constants.desaturate = MIN(abs(ds_fcolormap->Desaturate), 255) * 255 / 256; + ds_shade_constants.simple_shade = (ds_fcolormap->Color.d == 0x00ffffff && ds_fcolormap->Fade.d == 0x00000000 && ds_fcolormap->Desaturate == 0); + ds_colormap = base_colormap->Maps; + ds_light = LIGHTSCALE(light, shade); + } + else + { + ds_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); + } + } + + void R_SetTranslationMap(lighttable_t *translation) + { + using namespace drawerargs; + + if (r_swtruecolor) + { + dc_fcolormap = nullptr; + dc_colormap = nullptr; + dc_translation = translation; + dc_shade_constants.light_red = 256; + dc_shade_constants.light_green = 256; + dc_shade_constants.light_blue = 256; + dc_shade_constants.light_alpha = 256; + dc_shade_constants.fade_red = 0; + dc_shade_constants.fade_green = 0; + dc_shade_constants.fade_blue = 0; + dc_shade_constants.fade_alpha = 256; + dc_shade_constants.desaturate = 0; + dc_shade_constants.simple_shade = true; + dc_light = 0; + } + else + { + dc_fcolormap = nullptr; + dc_colormap = translation; + } + } + + void rt_initcols(uint8_t *buffer) + { + using namespace drawerargs; + + for (int y = 3; y >= 0; y--) + horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0]; + + DrawerCommandQueue::QueueCommand(buffer); + } + + void rt_span_coverage(int x, int start, int stop) + { + using namespace drawerargs; + + unsigned int **tspan = &dc_ctspan[x & 3]; + (*tspan)[0] = start; + (*tspan)[1] = stop; + *tspan += 2; + } + + void rt_flip_posts() + { + using namespace drawerargs; + + unsigned int *front = horizspan[dc_x & 3]; + unsigned int *back = dc_ctspan[dc_x & 3] - 2; + + while (front < back) + { + swapvalues(front[0], back[0]); + swapvalues(front[1], back[1]); + front += 2; + back -= 2; + } + } + + void rt_draw4cols(int sx) + { + using namespace drawerargs; + + int x, bad; + unsigned int maxtop, minbot, minnexttop; + + // Place a dummy "span" in each column. These don't get + // drawn. They're just here to avoid special cases in the + // max/min calculations below. + for (x = 0; x < 4; ++x) + { + dc_ctspan[x][0] = screen->GetHeight()+1; + dc_ctspan[x][1] = screen->GetHeight(); + } + + for (;;) + { + // If a column is out of spans, mark it as such + bad = 0; + minnexttop = 0xffffffff; + for (x = 0; x < 4; ++x) + { + if (horizspan[x] >= dc_ctspan[x]) + { + bad |= 1 << x; + } + else if ((horizspan[x]+2)[0] < minnexttop) + { + minnexttop = (horizspan[x]+2)[0]; + } + } + // Once all columns are out of spans, we're done + if (bad == 15) + { + return; + } + + // Find the largest shared area for the spans in each column + maxtop = MAX (MAX (horizspan[0][0], horizspan[1][0]), + MAX (horizspan[2][0], horizspan[3][0])); + minbot = MIN (MIN (horizspan[0][1], horizspan[1][1]), + MIN (horizspan[2][1], horizspan[3][1])); + + // If there is no shared area with these spans, draw each span + // individually and advance to the next spans until we reach a shared area. + // However, only draw spans down to the highest span in the next set of + // spans. If we allow the entire height of a span to be drawn, it could + // prevent any more shared areas from being drawn in these four columns. + // + // Example: Suppose we have the following arrangement: + // A CD + // A CD + // B D + // B D + // aB D + // aBcD + // aBcD + // aBc + // + // If we draw the entire height of the spans, we end up drawing this first: + // A CD + // A CD + // B D + // B D + // B D + // B D + // B D + // B D + // B + // + // This leaves only the "a" and "c" columns to be drawn, and they are not + // part of a shared area, but if we can include B and D with them, we can + // get a shared area. So we cut off everything in the first set just + // above the "a" column and end up drawing this first: + // A CD + // A CD + // B D + // B D + // + // Then the next time through, we have the following arrangement with an + // easily shared area to draw: + // aB D + // aBcD + // aBcD + // aBc + if (bad != 0 || maxtop > minbot) + { + int drawcount = 0; + for (x = 0; x < 4; ++x) + { + if (!(bad & 1)) + { + if (horizspan[x][1] < minnexttop) + { + hcolfunc_post1 (x, sx+x, horizspan[x][0], horizspan[x][1]); + horizspan[x] += 2; + drawcount++; + } + else if (minnexttop > horizspan[x][0]) + { + hcolfunc_post1 (x, sx+x, horizspan[x][0], minnexttop-1); + horizspan[x][0] = minnexttop; + drawcount++; + } + } + bad >>= 1; + } + // Drawcount *should* always be non-zero. The reality is that some situations + // can make this not true. Unfortunately, I'm not sure what those situations are. + if (drawcount == 0) + { + return; + } + continue; + } + + // Draw any span fragments above the shared area. + for (x = 0; x < 4; ++x) + { + if (maxtop > horizspan[x][0]) + { + hcolfunc_post1 (x, sx+x, horizspan[x][0], maxtop-1); + } + } + + // Draw the shared area. + hcolfunc_post4 (sx, maxtop, minbot); + + // For each column, if part of the span is past the shared area, + // set its top to just below the shared area. Otherwise, advance + // to the next span in that column. + for (x = 0; x < 4; ++x) + { + if (minbot < horizspan[x][1]) + { + horizspan[x][0] = minbot+1; + } + else + { + horizspan[x] += 2; + } + } + } + } + + void R_SetupSpanBits(FTexture *tex) + { + using namespace drawerargs; + + tex->GetWidth(); + ds_xbits = tex->WidthBits; + ds_ybits = tex->HeightBits; + if ((1 << ds_xbits) > tex->GetWidth()) + { + ds_xbits--; + } + if ((1 << ds_ybits) > tex->GetHeight()) + { + ds_ybits--; + } + } + + void R_SetSpanColormap(FDynamicColormap *colormap, int shade) + { + R_SetDSColorMapLight(colormap, 0, shade); + } + + void R_SetSpanSource(FTexture *tex) + { + using namespace drawerargs; + + ds_source = r_swtruecolor ? (const uint8_t*)tex->GetPixelsBgra() : tex->GetPixels(); + ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1; + } + + ///////////////////////////////////////////////////////////////////////// + + void R_FillColumnHoriz() + { + using namespace drawerargs; + + if (dc_count <= 0) + return; + + int x = dc_x & 3; + unsigned int **span = &dc_ctspan[x]; + (*span)[0] = dc_yl; + (*span)[1] = dc_yh; + *span += 2; + + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawColumnHoriz() + { + using namespace drawerargs; + + if (dc_count <= 0) + return; + + int x = dc_x & 3; + unsigned int **span = &dc_ctspan[x]; + (*span)[0] = dc_yl; + (*span)[1] = dc_yh; + *span += 2; + + if (drawer_needs_pal_input) + DrawerCommandQueue::QueueCommand>(); + else + DrawerCommandQueue::QueueCommand>(); + } + + // Copies one span at hx to the screen at sx. + void rt_copy1col(int hx, int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + + // Copies all four spans to the screen starting at sx. + void rt_copy4cols(int sx, int yl, int yh) + { + // To do: we could do this with SSE using __m128i + rt_copy1col(0, sx, yl, yh); + rt_copy1col(1, sx + 1, yl, yh); + rt_copy1col(2, sx + 2, yl, yh); + rt_copy1col(3, sx + 3, yl, yh); + } + + // Maps one span at hx to the screen at sx. + void rt_map1col(int hx, int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + + // Maps all four spans to the screen starting at sx. + void rt_map4cols(int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + + // Translates one span at hx to the screen at sx. + void rt_tlate1col(int hx, int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + + // Translates all four spans to the screen starting at sx. + void rt_tlate4cols(int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + + // Adds one span at hx to the screen at sx without clamping. + void rt_add1col(int hx, int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + + // Adds all four spans to the screen starting at sx without clamping. + void rt_add4cols(int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + + // Translates and adds one span at hx to the screen at sx without clamping. + void rt_tlateadd1col(int hx, int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + + // Translates and adds all four spans to the screen starting at sx without clamping. + void rt_tlateadd4cols(int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + + // Shades one span at hx to the screen at sx. + void rt_shaded1col(int hx, int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + + // Shades all four spans to the screen starting at sx. + void rt_shaded4cols(int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + + // Adds one span at hx to the screen at sx with clamping. + void rt_addclamp1col(int hx, int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + + // Adds all four spans to the screen starting at sx with clamping. + void rt_addclamp4cols(int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + + // Translates and adds one span at hx to the screen at sx with clamping. + void rt_tlateaddclamp1col(int hx, int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + + // Translates and adds all four spans to the screen starting at sx with clamping. + void rt_tlateaddclamp4cols(int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + + // Subtracts one span at hx to the screen at sx with clamping. + void rt_subclamp1col(int hx, int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + + // Subtracts all four spans to the screen starting at sx with clamping. + void rt_subclamp4cols(int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + + // Translates and subtracts one span at hx to the screen at sx with clamping. + void rt_tlatesubclamp1col(int hx, int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + + // Translates and subtracts all four spans to the screen starting at sx with clamping. + void rt_tlatesubclamp4cols(int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + + // Subtracts one span at hx from the screen at sx with clamping. + void rt_revsubclamp1col(int hx, int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + + // Subtracts all four spans from the screen starting at sx with clamping. + void rt_revsubclamp4cols(int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + + // Translates and subtracts one span at hx from the screen at sx with clamping. + void rt_tlaterevsubclamp1col(int hx, int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + + // Translates and subtracts all four spans from the screen starting at sx with clamping. + void rt_tlaterevsubclamp4cols(int sx, int yl, int yh) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + + uint32_t vlinec1() + { + using namespace drawerargs; + + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; + } + + void vlinec4() + { + using namespace drawerargs; + + DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) + vplce[i] += vince[i] * dc_count; + } + + uint32_t mvlinec1() + { + using namespace drawerargs; + + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; + } + + void mvlinec4() + { + using namespace drawerargs; + + DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) + vplce[i] += vince[i] * dc_count; + } + + fixed_t tmvline1_add() + { + using namespace drawerargs; + + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; + } + + void tmvline4_add() + { + using namespace drawerargs; + + DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) + vplce[i] += vince[i] * dc_count; + } + + fixed_t tmvline1_addclamp() + { + using namespace drawerargs; + + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; + } + + void tmvline4_addclamp() + { + using namespace drawerargs; + + DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) + vplce[i] += vince[i] * dc_count; + } + + fixed_t tmvline1_subclamp() + { + using namespace drawerargs; + + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; + } + + void tmvline4_subclamp() + { + using namespace drawerargs; + + DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) + vplce[i] += vince[i] * dc_count; + } + + fixed_t tmvline1_revsubclamp() + { + using namespace drawerargs; + + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; + } + + void tmvline4_revsubclamp() + { + using namespace drawerargs; + + DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) + vplce[i] += vince[i] * dc_count; + } + + void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) + { + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + } + + void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom) + { + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + } + + void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) + { + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + } + + void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom) + { + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + } + + void R_DrawColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_FillColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_FillAddColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_FillAddClampColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_FillSubClampColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_FillRevSubClampColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawFuzzColumn() + { + using namespace drawerargs; + + DrawerCommandQueue::QueueCommand(); + + dc_yl = MAX(dc_yl, 1); + dc_yh = MIN(dc_yh, fuzzviewheight); + if (dc_yl <= dc_yh) + fuzzpos = (fuzzpos + dc_yh - dc_yl + 1) % FUZZTABLE; + } + + void R_DrawAddColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawTranslatedColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawTlatedAddColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawShadedColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawAddClampColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawAddClampTranslatedColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawSubClampColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawSubClampTranslatedColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawRevSubClampColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawRevSubClampTranslatedColumn() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawSpan() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawSpanMasked() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawSpanTranslucent() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawSpanMaskedTranslucent() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawSpanAddClamp() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawSpanMaskedAddClamp() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_FillSpan() + { + DrawerCommandQueue::QueueCommand(); + } + + void R_DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) + { + DrawerCommandQueue::QueueCommand(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); + } + + void R_DrawColoredSpan(int y, int x1, int x2) + { + DrawerCommandQueue::QueueCommand(y, x1, x2); + } + + namespace + { + ShadeConstants slab_rgba_shade_constants; + const uint8_t *slab_rgba_colormap; + fixed_t slab_rgba_light; + } + + void R_SetupDrawSlab(FSWColormap *base_colormap, float light, int shade) + { + slab_rgba_shade_constants.light_red = base_colormap->Color.r * 256 / 255; + slab_rgba_shade_constants.light_green = base_colormap->Color.g * 256 / 255; + slab_rgba_shade_constants.light_blue = base_colormap->Color.b * 256 / 255; + slab_rgba_shade_constants.light_alpha = base_colormap->Color.a * 256 / 255; + slab_rgba_shade_constants.fade_red = base_colormap->Fade.r; + slab_rgba_shade_constants.fade_green = base_colormap->Fade.g; + slab_rgba_shade_constants.fade_blue = base_colormap->Fade.b; + slab_rgba_shade_constants.fade_alpha = base_colormap->Fade.a; + slab_rgba_shade_constants.desaturate = MIN(abs(base_colormap->Desaturate), 255) * 255 / 256; + slab_rgba_shade_constants.simple_shade = (base_colormap->Color.d == 0x00ffffff && base_colormap->Fade.d == 0x00000000 && base_colormap->Desaturate == 0); + slab_rgba_colormap = base_colormap->Maps; + slab_rgba_light = LIGHTSCALE(light, shade); + } + + void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p) + { + DrawerCommandQueue::QueueCommand(dx, v, dy, vi, vptr, p, slab_rgba_shade_constants, slab_rgba_colormap, slab_rgba_light); + } + + void R_DrawFogBoundarySection(int y, int y2, int x1) + { + for (; y < y2; ++y) + { + int x2 = spanend[y]; + DrawerCommandQueue::QueueCommand(y, x1, x2); + } + } + + void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip) + { + // This is essentially the same as R_MapVisPlane but with an extra step + // to create new horizontal spans whenever the light changes enough that + // we need to use a new colormap. + + double lightstep = rw_lightstep; + double light = rw_light + rw_lightstep*(x2 - x1 - 1); + int x = x2 - 1; + int t2 = uclip[x]; + int b2 = dclip[x]; + int rcolormap = GETPALOOKUP(light, wallshade); + int lcolormap; + uint8_t *basecolormapdata = basecolormap->Maps; + + if (b2 > t2) + { + clearbufshort(spanend + t2, b2 - t2, x); + } + + R_SetColorMapLight(basecolormap, (float)light, wallshade); + + uint8_t *fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); + + for (--x; x >= x1; --x) + { + int t1 = uclip[x]; + int b1 = dclip[x]; + const int xr = x + 1; + int stop; + + light -= rw_lightstep; + lcolormap = GETPALOOKUP(light, wallshade); + if (lcolormap != rcolormap) + { + if (t2 < b2 && rcolormap != 0) + { // Colormap 0 is always the identity map, so rendering it is + // just a waste of time. + R_DrawFogBoundarySection(t2, b2, xr); + } + if (t1 < t2) t2 = t1; + if (b1 > b2) b2 = b1; + if (t2 < b2) + { + clearbufshort(spanend + t2, b2 - t2, x); + } + rcolormap = lcolormap; + R_SetColorMapLight(basecolormap, (float)light, wallshade); + fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); + } + else + { + if (fake_dc_colormap != basecolormapdata) + { + stop = MIN(t1, b2); + while (t2 < stop) + { + int y = t2++; + DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); + } + stop = MAX(b1, t2); + while (b2 > stop) + { + int y = --b2; + DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); + } + } + else + { + t2 = MAX(t2, MIN(t1, b2)); + b2 = MIN(b2, MAX(b1, t2)); + } + + stop = MIN(t2, b1); + while (t1 < stop) + { + spanend[t1++] = x; + } + stop = MAX(b2, t2); + while (b1 > stop) + { + spanend[--b1] = x; + } + } + + t2 = uclip[x]; + b2 = dclip[x]; + } + if (t2 < b2 && rcolormap != 0) + { + R_DrawFogBoundarySection(t2, b2, x1); + } + } + + void R_DrawParticle(vissprite_t *sprite) + { + if (r_swtruecolor) + R_DrawParticle_rgba(sprite); + else + R_DrawParticle_C(sprite); + } +} diff --git a/src/r_draw_tc.h b/src/r_draw_tc.h new file mode 100644 index 000000000..8c1af58fc --- /dev/null +++ b/src/r_draw_tc.h @@ -0,0 +1,239 @@ + +#pragma once + +#include "r_defs.h" + +struct FSWColormap; + +EXTERN_CVAR(Bool, r_multithreaded); +EXTERN_CVAR(Bool, r_magfilter); +EXTERN_CVAR(Bool, r_minfilter); +EXTERN_CVAR(Bool, r_mipmap); +EXTERN_CVAR(Float, r_lod_bias); +EXTERN_CVAR(Int, r_drawfuzz); +EXTERN_CVAR(Bool, r_drawtrans); +EXTERN_CVAR(Float, transsouls); +EXTERN_CVAR(Int, r_columnmethod); + +namespace swrenderer +{ + struct vissprite_t; + + struct ShadeConstants + { + uint16_t light_alpha; + uint16_t light_red; + uint16_t light_green; + uint16_t light_blue; + uint16_t fade_alpha; + uint16_t fade_red; + uint16_t fade_green; + uint16_t fade_blue; + uint16_t desaturate; + bool simple_shade; + }; + + extern double dc_texturemid; + + namespace drawerargs + { + extern int dc_pitch; + extern lighttable_t *dc_colormap; + extern FSWColormap *dc_fcolormap; + extern ShadeConstants dc_shade_constants; + extern fixed_t dc_light; + extern int dc_x; + extern int dc_yl; + extern int dc_yh; + extern fixed_t dc_iscale; + extern fixed_t dc_texturefrac; + extern uint32_t dc_textureheight; + extern int dc_color; + extern uint32_t dc_srccolor; + extern uint32_t dc_srccolor_bgra; + extern uint32_t *dc_srcblend; + extern uint32_t *dc_destblend; + extern fixed_t dc_srcalpha; + extern fixed_t dc_destalpha; + extern const uint8_t *dc_source; + extern const uint8_t *dc_source2; + extern uint32_t dc_texturefracx; + extern uint8_t *dc_translation; + extern uint8_t *dc_dest; + extern uint8_t *dc_destorg; + extern int dc_destheight; + extern int dc_count; + + extern bool drawer_needs_pal_input; + + extern uint32_t vplce[4]; + extern uint32_t vince[4]; + extern uint8_t *palookupoffse[4]; + extern fixed_t palookuplight[4]; + extern const uint8_t *bufplce[4]; + extern const uint8_t *bufplce2[4]; + extern uint32_t buftexturefracx[4]; + extern uint32_t bufheight[4]; + extern int vlinebits; + extern int mvlinebits; + extern int tmvlinebits; + + extern int ds_y; + extern int ds_x1; + extern int ds_x2; + extern lighttable_t * ds_colormap; + extern FSWColormap *ds_fcolormap; + extern ShadeConstants ds_shade_constants; + extern dsfixed_t ds_light; + extern dsfixed_t ds_xfrac; + extern dsfixed_t ds_yfrac; + extern dsfixed_t ds_xstep; + extern dsfixed_t ds_ystep; + extern int ds_xbits; + extern int ds_ybits; + extern fixed_t ds_alpha; + extern double ds_lod; + extern const uint8_t *ds_source; + extern bool ds_source_mipmapped; + extern int ds_color; + + extern unsigned int dc_tspans[4][MAXHEIGHT]; + extern unsigned int *dc_ctspan[4]; + extern unsigned int *horizspan[4]; + } + + extern int ylookup[MAXHEIGHT]; + extern uint8_t shadetables[/*NUMCOLORMAPS*16*256*/]; + extern FDynamicColormap ShadeFakeColormap[16]; + extern uint8_t identitymap[256]; + extern FDynamicColormap identitycolormap; + + // Spectre/Invisibility. + #define FUZZTABLE 50 + extern int fuzzoffset[FUZZTABLE + 1]; + extern int fuzzpos; + extern int fuzzviewheight; + + extern bool r_swtruecolor; + + void R_InitColumnDrawers(); + void R_InitShadeMaps(); + void R_InitFuzzTable(int fuzzoff); + + enum ESPSResult + { + DontDraw, // not useful to draw this + DoDraw0, // draw this as if r_columnmethod is 0 + DoDraw1, // draw this as if r_columnmethod is 1 + }; + + ESPSResult R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color); + ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color); + void R_FinishSetPatchStyle(); // Call this after finished drawing the current thing, in case its style was STYLE_Shade + bool R_GetTransMaskDrawers(fixed_t(**tmvline1)(), void(**tmvline4)()); + + const uint8_t *R_GetColumn(FTexture *tex, int col); + void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn); + void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn); + void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn); + + void rt_initcols(uint8_t *buffer = nullptr); + void rt_span_coverage(int x, int start, int stop); + void rt_draw4cols(int sx); + void rt_flip_posts(); + void rt_copy1col(int hx, int sx, int yl, int yh); + void rt_copy4cols(int sx, int yl, int yh); + void rt_shaded1col(int hx, int sx, int yl, int yh); + void rt_shaded4cols(int sx, int yl, int yh); + void rt_map1col(int hx, int sx, int yl, int yh); + void rt_add1col(int hx, int sx, int yl, int yh); + void rt_addclamp1col(int hx, int sx, int yl, int yh); + void rt_subclamp1col(int hx, int sx, int yl, int yh); + void rt_revsubclamp1col(int hx, int sx, int yl, int yh); + void rt_tlate1col(int hx, int sx, int yl, int yh); + void rt_tlateadd1col(int hx, int sx, int yl, int yh); + void rt_tlateaddclamp1col(int hx, int sx, int yl, int yh); + void rt_tlatesubclamp1col(int hx, int sx, int yl, int yh); + void rt_tlaterevsubclamp1col(int hx, int sx, int yl, int yh); + void rt_map4cols(int sx, int yl, int yh); + void rt_add4cols(int sx, int yl, int yh); + void rt_addclamp4cols(int sx, int yl, int yh); + void rt_subclamp4cols(int sx, int yl, int yh); + void rt_revsubclamp4cols(int sx, int yl, int yh); + void rt_tlate4cols(int sx, int yl, int yh); + void rt_tlateadd4cols(int sx, int yl, int yh); + void rt_tlateaddclamp4cols(int sx, int yl, int yh); + void rt_tlatesubclamp4cols(int sx, int yl, int yh); + void rt_tlaterevsubclamp4cols(int sx, int yl, int yh); + void R_DrawColumnHoriz(); + void R_DrawColumn(); + void R_DrawFuzzColumn(); + void R_DrawTranslatedColumn(); + void R_DrawShadedColumn(); + void R_FillColumn(); + void R_FillAddColumn(); + void R_FillAddClampColumn(); + void R_FillSubClampColumn(); + void R_FillRevSubClampColumn(); + void R_DrawAddColumn(); + void R_DrawTlatedAddColumn(); + void R_DrawAddClampColumn(); + void R_DrawAddClampTranslatedColumn(); + void R_DrawSubClampColumn(); + void R_DrawSubClampTranslatedColumn(); + void R_DrawRevSubClampColumn(); + void R_DrawRevSubClampTranslatedColumn(); + void R_DrawSpan(); + void R_DrawSpanMasked(); + void R_DrawSpanTranslucent(); + void R_DrawSpanMaskedTranslucent(); + void R_DrawSpanAddClamp(); + void R_DrawSpanMaskedAddClamp(); + void R_FillSpan(); + void R_DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy); + void R_DrawColoredSpan(int y, int x1, int x2); + void R_SetupDrawSlab(FSWColormap *base_colormap, float light, int shade); + void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p); + void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip); + uint32_t vlinec1(); + void vlinec4(); + uint32_t mvlinec1(); + void mvlinec4(); + fixed_t tmvline1_add(); + void tmvline4_add(); + fixed_t tmvline1_addclamp(); + void tmvline4_addclamp(); + fixed_t tmvline1_subclamp(); + void tmvline4_subclamp(); + fixed_t tmvline1_revsubclamp(); + void tmvline4_revsubclamp(); + void R_FillColumnHoriz(); + void R_FillSpan(); + + inline uint32_t dovline1() { return vlinec1(); } + inline void dovline4() { vlinec4(); } + inline uint32_t domvline1() { return mvlinec1(); } + inline void domvline4() { mvlinec4(); } + + void setupvline(int fracbits); + void setupmvline(int fracbits); + void setuptmvline(int fracbits); + + void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom); + void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); + void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom); + void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); + + // Sets dc_colormap and dc_light to their appropriate values depending on the output format (pal vs true color) + void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade); + void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade); + void R_SetTranslationMap(lighttable_t *translation); + + void R_SetupSpanBits(FTexture *tex); + void R_SetSpanColormap(FDynamicColormap *colormap, int shade); + void R_SetSpanSource(FTexture *tex); + + void R_MapTiltedPlane(int y, int x1); + void R_MapColoredPlane(int y, int x1); + void R_DrawParticle(vissprite_t *); +} diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 539135afe..d5aeed8a9 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -1,37 +1,23 @@ /* -** r_drawt_rgba.cpp -** Faster column drawers for modern processors, true color edition +** Drawer commands for the RT family of drawers +** Copyright (c) 2016 Magnus Norddahl ** -**--------------------------------------------------------------------------- -** Copyright 1998-2006 Randy Heit -** All rights reserved. +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. ** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: ** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. ** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** True color versions of the similar functions in r_drawt.cpp -** Please see r_drawt.cpp for a description of the globals used. */ #include "templates.h" @@ -47,15 +33,7 @@ namespace swrenderer { - -///////////////////////////////////////////////////////////////////////////// - -class DrawColumnRt1LLVMCommand : public DrawerCommand -{ -protected: - DrawColumnArgs args; - - WorkerThreadData ThreadData(DrawerThread *thread) + WorkerThreadData DrawColumnRt1LLVMCommand::ThreadData(DrawerThread *thread) { WorkerThreadData d; d.core = thread->core; @@ -66,8 +44,7 @@ protected: return d; } -public: - DrawColumnRt1LLVMCommand(int hx, int sx, int yl, int yh) + DrawColumnRt1LLVMCommand::DrawColumnRt1LLVMCommand(int hx, int sx, int yl, int yh) { using namespace drawerargs; @@ -105,90 +82,38 @@ public: DetectRangeError(args.dest, args.dest_y, args.count); } - void Execute(DrawerThread *thread) override + void DrawColumnRt1LLVMCommand::Execute(DrawerThread *thread) { WorkerThreadData d = ThreadData(thread); Drawers::Instance()->DrawColumnRt1(&args, &d); } - FString DebugInfo() override + FString DrawColumnRt1LLVMCommand::DebugInfo() { return "DrawColumnRt\n" + args.ToString(); } -}; -#define DECLARE_DRAW_COMMAND(name, func, base) \ -class name##LLVMCommand : public base \ -{ \ -public: \ - using base::base; \ - void Execute(DrawerThread *thread) override \ - { \ - WorkerThreadData d = ThreadData(thread); \ - Drawers::Instance()->func(&args, &d); \ - } \ -}; + ///////////////////////////////////////////////////////////////////////////// -DECLARE_DRAW_COMMAND(DrawColumnRt1Copy, DrawColumnRt1Copy, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt1Add, DrawColumnRt1Add, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt1Shaded, DrawColumnRt1Shaded, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt1AddClamp, DrawColumnRt1AddClamp, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt1SubClamp, DrawColumnRt1SubClamp, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt1RevSubClamp, DrawColumnRt1RevSubClamp, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt1Translated, DrawColumnRt1Translated, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt1TlatedAdd, DrawColumnRt1TlatedAdd, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt1AddClampTranslated, DrawColumnRt1AddClampTranslated, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt1SubClampTranslated, DrawColumnRt1SubClampTranslated, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt1RevSubClampTranslated, DrawColumnRt1RevSubClampTranslated, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt4, DrawColumnRt4, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt4Copy, DrawColumnRt4Copy, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt4Add, DrawColumnRt4Add, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt4Shaded, DrawColumnRt4Shaded, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt4AddClamp, DrawColumnRt4AddClamp, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt4SubClamp, DrawColumnRt4SubClamp, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt4RevSubClamp, DrawColumnRt4RevSubClamp, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt4Translated, DrawColumnRt4Translated, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt4TlatedAdd, DrawColumnRt4TlatedAdd, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt4AddClampTranslated, DrawColumnRt4AddClampTranslated, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt4SubClampTranslated, DrawColumnRt4SubClampTranslated, DrawColumnRt1LLVMCommand); -DECLARE_DRAW_COMMAND(DrawColumnRt4RevSubClampTranslated, DrawColumnRt4RevSubClampTranslated, DrawColumnRt1LLVMCommand); - -///////////////////////////////////////////////////////////////////////////// - -class RtInitColsRGBACommand : public DrawerCommand -{ - BYTE * RESTRICT buff; - -public: - RtInitColsRGBACommand(BYTE *buff) + RtInitColsRGBACommand::RtInitColsRGBACommand(BYTE *buff) { this->buff = buff; } - void Execute(DrawerThread *thread) override + void RtInitColsRGBACommand::Execute(DrawerThread *thread) { thread->dc_temp_rgba = buff == NULL ? thread->dc_temp_rgbabuff_rgba : (uint32_t*)buff; } - FString DebugInfo() override + FString RtInitColsRGBACommand::DebugInfo() { return "RtInitCols"; } -}; -template -class DrawColumnHorizRGBACommand : public DrawerCommand -{ - int _count; - fixed_t _iscale; - fixed_t _texturefrac; - const InputPixelType * RESTRICT _source; - int _x; - int _yl; - int _yh; + ///////////////////////////////////////////////////////////////////////////// -public: - DrawColumnHorizRGBACommand() + template + DrawColumnHorizRGBACommand::DrawColumnHorizRGBACommand() { using namespace drawerargs; @@ -201,7 +126,8 @@ public: _yh = dc_yh; } - void Execute(DrawerThread *thread) override + template + void DrawColumnHorizRGBACommand::Execute(DrawerThread *thread) { int count = _count; uint32_t *dest; @@ -252,22 +178,19 @@ public: } while (--count); } - FString DebugInfo() override + template + FString DrawColumnHorizRGBACommand::DebugInfo() { return "DrawColumnHoriz"; } -}; -class FillColumnHorizRGBACommand : public DrawerCommand -{ - int _x; - int _yl; - int _yh; - int _count; - uint32_t _color; + // Generate code for the versions we use: + template class DrawColumnHorizRGBACommand; + template class DrawColumnHorizRGBACommand; -public: - FillColumnHorizRGBACommand() + ///////////////////////////////////////////////////////////////////////////// + + FillColumnHorizRGBACommand::FillColumnHorizRGBACommand() { using namespace drawerargs; @@ -278,7 +201,7 @@ public: _yh = dc_yh; } - void Execute(DrawerThread *thread) override + void FillColumnHorizRGBACommand::Execute(DrawerThread *thread) { int count = _count; uint32_t color = _color; @@ -304,220 +227,8 @@ public: } while (--count); } - FString DebugInfo() override + FString FillColumnHorizRGBACommand::DebugInfo() { return "FillColumnHoriz"; } -}; - -///////////////////////////////////////////////////////////////////////////// - -// Copies one span at hx to the screen at sx. -void rt_copy1col_rgba (int hx, int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); -} - -// Copies all four spans to the screen starting at sx. -void rt_copy4cols_rgba (int sx, int yl, int yh) -{ - // To do: we could do this with SSE using __m128i - rt_copy1col_rgba(0, sx, yl, yh); - rt_copy1col_rgba(1, sx + 1, yl, yh); - rt_copy1col_rgba(2, sx + 2, yl, yh); - rt_copy1col_rgba(3, sx + 3, yl, yh); -} - -// Maps one span at hx to the screen at sx. -void rt_map1col_rgba (int hx, int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); -} - -// Maps all four spans to the screen starting at sx. -void rt_map4cols_rgba (int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); -} - -// Translates one span at hx to the screen at sx. -void rt_tlate1col_rgba (int hx, int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); -} - -// Translates all four spans to the screen starting at sx. -void rt_tlate4cols_rgba (int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); -} - -// Adds one span at hx to the screen at sx without clamping. -void rt_add1col_rgba (int hx, int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); -} - -// Adds all four spans to the screen starting at sx without clamping. -void rt_add4cols_rgba (int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); -} - -// Translates and adds one span at hx to the screen at sx without clamping. -void rt_tlateadd1col_rgba (int hx, int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); -} - -// Translates and adds all four spans to the screen starting at sx without clamping. -void rt_tlateadd4cols_rgba(int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); -} - -// Shades one span at hx to the screen at sx. -void rt_shaded1col_rgba (int hx, int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); -} - -// Shades all four spans to the screen starting at sx. -void rt_shaded4cols_rgba (int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); -} - -// Adds one span at hx to the screen at sx with clamping. -void rt_addclamp1col_rgba (int hx, int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); -} - -// Adds all four spans to the screen starting at sx with clamping. -void rt_addclamp4cols_rgba (int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); -} - -// Translates and adds one span at hx to the screen at sx with clamping. -void rt_tlateaddclamp1col_rgba (int hx, int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); -} - -// Translates and adds all four spans to the screen starting at sx with clamping. -void rt_tlateaddclamp4cols_rgba (int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); -} - -// Subtracts one span at hx to the screen at sx with clamping. -void rt_subclamp1col_rgba (int hx, int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); -} - -// Subtracts all four spans to the screen starting at sx with clamping. -void rt_subclamp4cols_rgba (int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); -} - -// Translates and subtracts one span at hx to the screen at sx with clamping. -void rt_tlatesubclamp1col_rgba (int hx, int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); -} - -// Translates and subtracts all four spans to the screen starting at sx with clamping. -void rt_tlatesubclamp4cols_rgba (int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); -} - -// Subtracts one span at hx from the screen at sx with clamping. -void rt_revsubclamp1col_rgba (int hx, int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); -} - -// Subtracts all four spans from the screen starting at sx with clamping. -void rt_revsubclamp4cols_rgba (int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); -} - -// Translates and subtracts one span at hx from the screen at sx with clamping. -void rt_tlaterevsubclamp1col_rgba (int hx, int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); -} - -// Translates and subtracts all four spans from the screen starting at sx with clamping. -void rt_tlaterevsubclamp4cols_rgba (int sx, int yl, int yh) -{ - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); -} - -// Before each pass through a rendering loop that uses these routines, -// call this function to set up the span pointers. -void rt_initcols_rgba (BYTE *buff) -{ - using namespace drawerargs; - - for (int y = 3; y >= 0; y--) - horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0]; - - DrawerCommandQueue::QueueCommand(buff); -} - -void rt_span_coverage_rgba(int x, int start, int stop) -{ - using namespace drawerargs; - - unsigned int **tspan = &dc_ctspan[x & 3]; - (*tspan)[0] = start; - (*tspan)[1] = stop; - *tspan += 2; -} - -// Stretches a column into a temporary buffer which is later -// drawn to the screen along with up to three other columns. -void R_DrawColumnHoriz_rgba (void) -{ - using namespace drawerargs; - - if (dc_count <= 0) - return; - - int x = dc_x & 3; - unsigned int **span = &dc_ctspan[x]; - (*span)[0] = dc_yl; - (*span)[1] = dc_yh; - *span += 2; - - if (drawer_needs_pal_input) - DrawerCommandQueue::QueueCommand>(); - else - DrawerCommandQueue::QueueCommand>(); -} - -// [RH] Just fills a column with a given color -void R_FillColumnHoriz_rgba (void) -{ - using namespace drawerargs; - - if (dc_count <= 0) - return; - - int x = dc_x & 3; - unsigned int **span = &dc_ctspan[x]; - (*span)[0] = dc_yl; - (*span)[1] = dc_yh; - *span += 2; - - DrawerCommandQueue::QueueCommand(); -} - } diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 36c2c1da5..c6c7d6d2f 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -511,9 +511,9 @@ void R_MapTiltedPlane_C (int y, int x1) #endif } -void R_MapTiltedPlane_rgba (int y, int x1) +void R_MapTiltedPlane (int y, int x1) { - R_DrawTiltedSpan_rgba(y, x1, spanend[y], plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); + R_DrawTiltedSpan(y, x1, spanend[y], plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); } //========================================================================== @@ -527,9 +527,9 @@ void R_MapColoredPlane_C (int y, int x1) memset (ylookup[y] + x1 + dc_destorg, ds_color, spanend[y] - x1 + 1); } -void R_MapColoredPlane_rgba(int y, int x1) +void R_MapColoredPlane(int y, int x1) { - R_DrawColoredSpan_rgba(y, x1, spanend[y]); + R_DrawColoredSpan(y, x1, spanend[y]); } //========================================================================== @@ -1073,32 +1073,16 @@ static void R_DrawSkyColumnStripe(int start_x, int y1, int y2, int columns, doub uint32_t solid_top = frontskytex->GetSkyCapColor(false); uint32_t solid_bottom = frontskytex->GetSkyCapColor(true); - if (r_swtruecolor) - { - if (columns == 4) - if (!backskytex) - R_DrawSingleSkyCol4_rgba(solid_top, solid_bottom); - else - R_DrawDoubleSkyCol4_rgba(solid_top, solid_bottom); + if (columns == 4) + if (!backskytex) + R_DrawSingleSkyCol4(solid_top, solid_bottom); else - if (!backskytex) - R_DrawSingleSkyCol1_rgba(solid_top, solid_bottom); - else - R_DrawDoubleSkyCol1_rgba(solid_top, solid_bottom); - } + R_DrawDoubleSkyCol4(solid_top, solid_bottom); else - { - if (columns == 4) - if (!backskytex) - R_DrawSingleSkyCol4(solid_top, solid_bottom); - else - R_DrawDoubleSkyCol4(solid_top, solid_bottom); + if (!backskytex) + R_DrawSingleSkyCol1(solid_top, solid_bottom); else - if (!backskytex) - R_DrawSingleSkyCol1(solid_top, solid_bottom); - else - R_DrawDoubleSkyCol1(solid_top, solid_bottom); - } + R_DrawDoubleSkyCol1(solid_top, solid_bottom); } static void R_DrawSkyColumn(int start_x, int y1, int y2, int columns) From dfbd7fd2adefae9a36af210b27a471acf6f334c8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 5 Dec 2016 10:44:24 +0100 Subject: [PATCH 1344/1509] Add drawer commands for pal mode --- src/CMakeLists.txt | 2 + src/r_draw_pal.cpp | 221 +++++++++++++++++++++++++++ src/r_draw_pal.h | 163 ++++++++++++++++++++ src/r_draw_tc.cpp | 365 +++++++++++++++++++++++++++++++++++--------- src/r_drawt_pal.cpp | 113 ++++++++++++++ src/r_things.cpp | 2 + 6 files changed, 795 insertions(+), 71 deletions(-) create mode 100644 src/r_draw_pal.cpp create mode 100644 src/r_draw_pal.h create mode 100644 src/r_drawt_pal.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e62f4d412..d02673048 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1046,6 +1046,8 @@ set( FASTMATH_PCH_SOURCES r_3dfloors.cpp r_bsp.cpp r_draw_tc.cpp + r_draw_pal.cpp + r_drawt_pal.cpp r_draw_rgba.cpp r_drawt_rgba.cpp r_drawers.cpp diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp new file mode 100644 index 000000000..b3ed97dfb --- /dev/null +++ b/src/r_draw_pal.cpp @@ -0,0 +1,221 @@ + +#include "templates.h" +#include "doomtype.h" +#include "doomdef.h" +#include "r_defs.h" +#include "r_draw.h" +#include "r_main.h" +#include "r_things.h" +#include "v_video.h" +#include "r_draw_pal.h" + +namespace swrenderer +{ + PalWall1Command::PalWall1Command() + { + } + + PalWall4Command::PalWall4Command() + { + } + + void DrawWall1PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawWall4PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawWallMasked1PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawWallMasked4PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawWallAdd1PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawWallAdd4PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawWallAddClamp1PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawWallAddClamp4PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawWallSubClamp1PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawWallSubClamp4PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawWallRevSubClamp1PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawWallRevSubClamp4PalCommand::Execute(DrawerThread *thread) + { + } + + PalSkyCommand::PalSkyCommand(uint32_t solid_top, uint32_t solid_bottom) + { + } + + void DrawSingleSky1PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawSingleSky4PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawDoubleSky1PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawDoubleSky4PalCommand::Execute(DrawerThread *thread) + { + } + + PalColumnCommand::PalColumnCommand() + { + } + + void DrawColumnPalCommand::Execute(DrawerThread *thread) + { + } + + void FillColumnPalCommand::Execute(DrawerThread *thread) + { + } + + void FillColumnAddPalCommand::Execute(DrawerThread *thread) + { + } + + void FillColumnAddClampPalCommand::Execute(DrawerThread *thread) + { + } + + void FillColumnSubClampPalCommand::Execute(DrawerThread *thread) + { + } + + void FillColumnRevSubClampPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnAddPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnTranslatedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnTlatedAddPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnShadedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnAddClampPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnAddClampTranslatedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnSubClampPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnSubClampTranslatedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRevSubClampPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRevSubClampTranslatedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawFuzzColumnPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawSpanPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawSpanMaskedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawSpanTranslucentPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawSpanMaskedTranslucentPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawSpanAddClampPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawSpanMaskedAddClampPalCommand::Execute(DrawerThread *thread) + { + } + + void FillSpanPalCommand::Execute(DrawerThread *thread) + { + } + + DrawTiltedSpanPalCommand::DrawTiltedSpanPalCommand(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) + { + } + + void DrawTiltedSpanPalCommand::Execute(DrawerThread *thread) + { + } + + DrawColoredSpanPalCommand::DrawColoredSpanPalCommand(int y, int x1, int x2) + { + } + + void DrawColoredSpanPalCommand::Execute(DrawerThread *thread) + { + } + + DrawSlabPalCommand::DrawSlabPalCommand(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p, const uint8_t *colormap) + { + } + + void DrawSlabPalCommand::Execute(DrawerThread *thread) + { + } + + DrawFogBoundaryLinePalCommand::DrawFogBoundaryLinePalCommand(int y, int y2, int x1) + { + } + + void DrawFogBoundaryLinePalCommand::Execute(DrawerThread *thread) + { + } +} diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h new file mode 100644 index 000000000..3d540f8c6 --- /dev/null +++ b/src/r_draw_pal.h @@ -0,0 +1,163 @@ + +#pragma once + +#include "r_draw.h" +#include "v_palette.h" +#include "r_thread.h" + +namespace swrenderer +{ + class PalWall1Command : public DrawerCommand + { + public: + PalWall1Command(); + FString DebugInfo() override { return "PalWallCommand"; } + }; + + class PalWall4Command : public DrawerCommand + { + public: + PalWall4Command(); + FString DebugInfo() override { return "PalWallCommand"; } + }; + + class DrawWall1PalCommand : public PalWall1Command { public: void Execute(DrawerThread *thread) override; }; + class DrawWall4PalCommand : public PalWall4Command { public: void Execute(DrawerThread *thread) override; }; + class DrawWallMasked1PalCommand : public PalWall1Command { public: void Execute(DrawerThread *thread) override; }; + class DrawWallMasked4PalCommand : public PalWall4Command { public: void Execute(DrawerThread *thread) override; }; + class DrawWallAdd1PalCommand : public PalWall1Command { public: void Execute(DrawerThread *thread) override; }; + class DrawWallAdd4PalCommand : public PalWall4Command { public: void Execute(DrawerThread *thread) override; }; + class DrawWallAddClamp1PalCommand : public PalWall1Command { public: void Execute(DrawerThread *thread) override; }; + class DrawWallAddClamp4PalCommand : public PalWall4Command { public: void Execute(DrawerThread *thread) override; }; + class DrawWallSubClamp1PalCommand : public PalWall1Command { public: void Execute(DrawerThread *thread) override; }; + class DrawWallSubClamp4PalCommand : public PalWall4Command { public: void Execute(DrawerThread *thread) override; }; + class DrawWallRevSubClamp1PalCommand : public PalWall1Command { public: void Execute(DrawerThread *thread) override; }; + class DrawWallRevSubClamp4PalCommand : public PalWall4Command { public: void Execute(DrawerThread *thread) override; }; + + class PalSkyCommand : public DrawerCommand + { + public: + PalSkyCommand(uint32_t solid_top, uint32_t solid_bottom); + FString DebugInfo() override { return "PalSkyCommand"; } + }; + + class DrawSingleSky1PalCommand : public PalSkyCommand { public: using PalSkyCommand::PalSkyCommand; void Execute(DrawerThread *thread) override; }; + class DrawSingleSky4PalCommand : public PalSkyCommand { public: using PalSkyCommand::PalSkyCommand; void Execute(DrawerThread *thread) override; }; + class DrawDoubleSky1PalCommand : public PalSkyCommand { public: using PalSkyCommand::PalSkyCommand; void Execute(DrawerThread *thread) override; }; + class DrawDoubleSky4PalCommand : public PalSkyCommand { public: using PalSkyCommand::PalSkyCommand; void Execute(DrawerThread *thread) override; }; + + class PalColumnCommand : public DrawerCommand + { + public: + PalColumnCommand(); + FString DebugInfo() override { return "PalColumnCommand"; } + }; + + class DrawColumnPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class FillColumnPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class FillColumnAddPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class FillColumnAddClampPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class FillColumnSubClampPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class FillColumnRevSubClampPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawColumnAddPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawColumnTranslatedPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawColumnTlatedAddPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawColumnShadedPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawColumnAddClampPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawColumnAddClampTranslatedPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawColumnSubClampPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawColumnSubClampTranslatedPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawColumnRevSubClampPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawColumnRevSubClampTranslatedPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; + + class DrawFuzzColumnPalCommand : public DrawerCommand + { + public: + void Execute(DrawerThread *thread) override; + FString DebugInfo() override { return "DrawFuzzColumnPalCommand"; } + }; + + class PalSpanCommand : public DrawerCommand + { + public: + FString DebugInfo() override { return "PalSpanCommand"; } + }; + + class DrawSpanPalCommand : public PalSpanCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawSpanMaskedPalCommand : public PalSpanCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawSpanTranslucentPalCommand : public PalSpanCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawSpanMaskedTranslucentPalCommand : public PalSpanCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawSpanAddClampPalCommand : public PalSpanCommand { public: void Execute(DrawerThread *thread) override; }; + class DrawSpanMaskedAddClampPalCommand : public PalSpanCommand { public: void Execute(DrawerThread *thread) override; }; + class FillSpanPalCommand : public PalSpanCommand { public: void Execute(DrawerThread *thread) override; }; + + class DrawTiltedSpanPalCommand : public DrawerCommand + { + public: + DrawTiltedSpanPalCommand(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override { return "DrawTiltedSpanPalCommand"; } + }; + + class DrawColoredSpanPalCommand : public PalSpanCommand + { + public: + DrawColoredSpanPalCommand(int y, int x1, int x2); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override { return "DrawColoredSpanPalCommand"; } + }; + + class DrawSlabPalCommand : public PalSpanCommand + { + public: + DrawSlabPalCommand(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p, const uint8_t *colormap); + void Execute(DrawerThread *thread) override; + }; + + class DrawFogBoundaryLinePalCommand : public PalSpanCommand + { + public: + DrawFogBoundaryLinePalCommand(int y, int y2, int x1); + void Execute(DrawerThread *thread) override; + }; + + //class RtInitColsPalCommand : public DrawerCommand { public: void Execute(DrawerThread *thread) override; }; + //class DrawColumnHorizPalCommand : public DrawerCommand { public: void Execute(DrawerThread *thread) override; }; + class FillColumnHorizPalCommand : public DrawerCommand + { + public: + void Execute(DrawerThread *thread) override; + FString DebugInfo() override { return "FillColumnHorizPalCommand"; } + }; + + class PalRtCommand : public DrawerCommand + { + public: + PalRtCommand(int hx, int sx, int yl, int yh); + FString DebugInfo() override { return "PalRtCommand"; } + }; + + class DrawColumnRt1CopyPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt1PalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt4PalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt1TranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt4TranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt1AddPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt4AddPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt1AddTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt4AddTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt1ShadedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt4ShadedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt1AddClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt4AddClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt1AddClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt4AddClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt1SubClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt4SubClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt1SubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt4SubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt1RevSubClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt4RevSubClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt1RevSubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt4RevSubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; +} diff --git a/src/r_draw_tc.cpp b/src/r_draw_tc.cpp index a531d4aa9..2326cab91 100644 --- a/src/r_draw_tc.cpp +++ b/src/r_draw_tc.cpp @@ -17,6 +17,7 @@ #include "r_plane.h" #include "r_draw_tc.h" #include "r_draw_rgba.h" +#include "r_draw_pal.h" #include "r_thread.h" namespace swrenderer @@ -841,7 +842,10 @@ namespace swrenderer (*span)[1] = dc_yh; *span += 2; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawColumnHoriz() @@ -857,7 +861,7 @@ namespace swrenderer (*span)[1] = dc_yh; *span += 2; - if (drawer_needs_pal_input) + if (drawer_needs_pal_input || !r_swtruecolor) DrawerCommandQueue::QueueCommand>(); else DrawerCommandQueue::QueueCommand>(); @@ -866,7 +870,10 @@ namespace swrenderer // Copies one span at hx to the screen at sx. void rt_copy1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Copies all four spans to the screen starting at sx. @@ -882,140 +889,210 @@ namespace swrenderer // Maps one span at hx to the screen at sx. void rt_map1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Maps all four spans to the screen starting at sx. void rt_map4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Translates one span at hx to the screen at sx. void rt_tlate1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Translates all four spans to the screen starting at sx. void rt_tlate4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Adds one span at hx to the screen at sx without clamping. void rt_add1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Adds all four spans to the screen starting at sx without clamping. void rt_add4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Translates and adds one span at hx to the screen at sx without clamping. void rt_tlateadd1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Translates and adds all four spans to the screen starting at sx without clamping. void rt_tlateadd4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Shades one span at hx to the screen at sx. void rt_shaded1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Shades all four spans to the screen starting at sx. void rt_shaded4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Adds one span at hx to the screen at sx with clamping. void rt_addclamp1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Adds all four spans to the screen starting at sx with clamping. void rt_addclamp4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Translates and adds one span at hx to the screen at sx with clamping. void rt_tlateaddclamp1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Translates and adds all four spans to the screen starting at sx with clamping. void rt_tlateaddclamp4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Subtracts one span at hx to the screen at sx with clamping. void rt_subclamp1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Subtracts all four spans to the screen starting at sx with clamping. void rt_subclamp4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Translates and subtracts one span at hx to the screen at sx with clamping. void rt_tlatesubclamp1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Translates and subtracts all four spans to the screen starting at sx with clamping. void rt_tlatesubclamp4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Subtracts one span at hx from the screen at sx with clamping. void rt_revsubclamp1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Subtracts all four spans from the screen starting at sx with clamping. void rt_revsubclamp4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Translates and subtracts one span at hx from the screen at sx with clamping. void rt_tlaterevsubclamp1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Translates and subtracts all four spans from the screen starting at sx with clamping. void rt_tlaterevsubclamp4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } uint32_t vlinec1() { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; } @@ -1023,7 +1100,11 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } @@ -1032,7 +1113,11 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; } @@ -1040,7 +1125,11 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } @@ -1049,7 +1138,11 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; } @@ -1057,7 +1150,11 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } @@ -1066,7 +1163,11 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; } @@ -1074,7 +1175,11 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } @@ -1083,7 +1188,11 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; } @@ -1091,7 +1200,11 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } @@ -1100,7 +1213,11 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); + return dc_texturefrac + dc_count * dc_iscale; } @@ -1108,66 +1225,103 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); + for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; } void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) { - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + else + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); } void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom) { - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + else + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); } void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) { - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + else + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); } void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom) { - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + else + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); } void R_DrawColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_FillColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_FillAddColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_FillAddClampColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_FillSubClampColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_FillRevSubClampColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawFuzzColumn() { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); dc_yl = MAX(dc_yl, 1); dc_yh = MIN(dc_yh, fuzzviewheight); @@ -1177,97 +1331,154 @@ namespace swrenderer void R_DrawAddColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawTranslatedColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawTlatedAddColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawShadedColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawAddClampColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawAddClampTranslatedColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSubClampColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSubClampTranslatedColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawRevSubClampColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawRevSubClampTranslatedColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSpan() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSpanMasked() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSpanTranslucent() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSpanMaskedTranslucent() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSpanAddClamp() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSpanMaskedAddClamp() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_FillSpan() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) { - DrawerCommandQueue::QueueCommand(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); + else + DrawerCommandQueue::QueueCommand(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); } void R_DrawColoredSpan(int y, int x1, int x2) { - DrawerCommandQueue::QueueCommand(y, x1, x2); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(y, x1, x2); + else + DrawerCommandQueue::QueueCommand(y, x1, x2); } namespace @@ -1295,7 +1506,10 @@ namespace swrenderer void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p) { - DrawerCommandQueue::QueueCommand(dx, v, dy, vi, vptr, p, slab_rgba_shade_constants, slab_rgba_colormap, slab_rgba_light); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(dx, v, dy, vi, vptr, p, slab_rgba_shade_constants, slab_rgba_colormap, slab_rgba_light); + else + DrawerCommandQueue::QueueCommand(dx, v, dy, vi, vptr, p, slab_rgba_colormap); } void R_DrawFogBoundarySection(int y, int y2, int x1) @@ -1303,7 +1517,10 @@ namespace swrenderer for (; y < y2; ++y) { int x2 = spanend[y]; - DrawerCommandQueue::QueueCommand(y, x1, x2); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(y, x1, x2); + else + DrawerCommandQueue::QueueCommand(y, x1, x2); } } @@ -1365,13 +1582,19 @@ namespace swrenderer while (t2 < stop) { int y = t2++; - DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); + else + DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); } stop = MAX(b1, t2); while (b2 > stop) { int y = --b2; - DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); + else + DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); } } else diff --git a/src/r_drawt_pal.cpp b/src/r_drawt_pal.cpp new file mode 100644 index 000000000..b35046285 --- /dev/null +++ b/src/r_drawt_pal.cpp @@ -0,0 +1,113 @@ + +#include "templates.h" +#include "doomtype.h" +#include "doomdef.h" +#include "r_defs.h" +#include "r_draw.h" +#include "r_main.h" +#include "r_things.h" +#include "v_video.h" +#include "r_draw_pal.h" + +namespace swrenderer +{ + PalRtCommand::PalRtCommand(int hx, int sx, int yl, int yh) + { + } + + void FillColumnHorizPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt1CopyPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt1PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt4PalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt1TranslatedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt4TranslatedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt1AddPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt4AddPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt1AddTranslatedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt4AddTranslatedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt1ShadedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt4ShadedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt1AddClampPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt4AddClampPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt1AddClampTranslatedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt4AddClampTranslatedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt1SubClampPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt4SubClampPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt1SubClampTranslatedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt4SubClampTranslatedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt1RevSubClampPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt4RevSubClampPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt1RevSubClampTranslatedPalCommand::Execute(DrawerThread *thread) + { + } + + void DrawColumnRt4RevSubClampTranslatedPalCommand::Execute(DrawerThread *thread) + { + } +} diff --git a/src/r_things.cpp b/src/r_things.cpp index 6869e8341..57e101feb 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2800,6 +2800,8 @@ void R_DrawParticle_C (vissprite_t *vis) R_DrawMaskedSegsBehindParticle (vis); + DrawerCommandQueue::WaitForWorkers(); + // vis->renderflags holds translucency level (0-255) { fixed_t fglevel, bglevel; From 645aed62d10e874df4210486bd65ab90d5f36584 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 5 Dec 2016 11:38:21 +0100 Subject: [PATCH 1345/1509] Add wall drawers --- src/r_draw_pal.cpp | 353 +++++++++++++++++++++++++++++++++++++++++++++ src/r_draw_pal.h | 28 ++++ 2 files changed, 381 insertions(+) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index b3ed97dfb..c4a05281b 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -13,58 +13,411 @@ namespace swrenderer { PalWall1Command::PalWall1Command() { + using namespace drawerargs; + + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _colormap = dc_colormap; + _count = dc_count; + _source = dc_source; + _dest = dc_dest; + _vlinebits = vlinebits; + _mvlinebits = mvlinebits; + _tmvlinebits = tmvlinebits; + _pitch = dc_pitch; + _srcblend = dc_srcblend; + _destblend = dc_destblend; } PalWall4Command::PalWall4Command() { + using namespace drawerargs; + + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + _vlinebits = vlinebits; + _mvlinebits = mvlinebits; + _tmvlinebits = tmvlinebits; + for (int col = 0; col < 4; col++) + { + _palookupoffse[col] = palookupoffse[col]; + _bufplce[col] = bufplce[col]; + _vince[col] = vince[col]; + _vplce[col] = vplce[col]; + } + _srcblend = dc_srcblend; + _destblend = dc_destblend; } void DrawWall1PalCommand::Execute(DrawerThread *thread) { + uint32_t fracstep = _iscale; + uint32_t frac = _texturefrac; + uint8_t *colormap = _colormap; + int count = _count; + const uint8_t *source = _source; + uint8_t *dest = _dest; + int bits = _vlinebits; + int pitch = _pitch; + + do + { + *dest = colormap[source[frac >> bits]]; + frac += fracstep; + dest += pitch; + } while (--count); } void DrawWall4PalCommand::Execute(DrawerThread *thread) { + uint8_t *dest = _dest; + int count = _count; + int bits = _vlinebits; + uint32_t place; + auto pal0 = _palookupoffse[0]; + auto pal1 = _palookupoffse[1]; + auto pal2 = _palookupoffse[2]; + auto pal3 = _palookupoffse[3]; + auto buf0 = _bufplce[0]; + auto buf1 = _bufplce[1]; + auto buf2 = _bufplce[2]; + auto buf3 = _bufplce[3]; + const auto vince0 = _vince[0]; + const auto vince1 = _vince[1]; + const auto vince2 = _vince[2]; + const auto vince3 = _vince[3]; + auto vplce0 = _vplce[0]; + auto vplce1 = _vplce[1]; + auto vplce2 = _vplce[2]; + auto vplce3 = _vplce[3]; + auto pitch = _pitch; + + do + { + dest[0] = pal0[buf0[(place = vplce0) >> bits]]; vplce0 = place + vince0; + dest[1] = pal1[buf1[(place = vplce1) >> bits]]; vplce1 = place + vince1; + dest[2] = pal2[buf2[(place = vplce2) >> bits]]; vplce2 = place + vince2; + dest[3] = pal3[buf3[(place = vplce3) >> bits]]; vplce3 = place + vince3; + dest += pitch; + } while (--count); } void DrawWallMasked1PalCommand::Execute(DrawerThread *thread) { + uint32_t fracstep = _iscale; + uint32_t frac = _texturefrac; + uint8_t *colormap = _colormap; + int count = _count; + const uint8_t *source = _source; + uint8_t *dest = _dest; + int bits = _mvlinebits; + int pitch = _pitch; + + do + { + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + *dest = colormap[pix]; + } + frac += fracstep; + dest += pitch; + } while (--count); } void DrawWallMasked4PalCommand::Execute(DrawerThread *thread) { + uint8_t *dest = _dest; + int count = _count; + int bits = _mvlinebits; + uint32_t place; + auto pal0 = _palookupoffse[0]; + auto pal1 = _palookupoffse[1]; + auto pal2 = _palookupoffse[2]; + auto pal3 = _palookupoffse[3]; + auto buf0 = _bufplce[0]; + auto buf1 = _bufplce[1]; + auto buf2 = _bufplce[2]; + auto buf3 = _bufplce[3]; + const auto vince0 = _vince[0]; + const auto vince1 = _vince[1]; + const auto vince2 = _vince[2]; + const auto vince3 = _vince[3]; + auto vplce0 = _vplce[0]; + auto vplce1 = _vplce[1]; + auto vplce2 = _vplce[2]; + auto vplce3 = _vplce[3]; + auto pitch = _pitch; + + do + { + uint8_t pix; + + pix = buf0[(place = vplce0) >> bits]; if (pix) dest[0] = pal0[pix]; vplce0 = place + vince0; + pix = buf1[(place = vplce1) >> bits]; if (pix) dest[1] = pal1[pix]; vplce1 = place + vince1; + pix = buf2[(place = vplce2) >> bits]; if (pix) dest[2] = pal2[pix]; vplce2 = place + vince2; + pix = buf3[(place = vplce3) >> bits]; if (pix) dest[3] = pal3[pix]; vplce3 = place + vince3; + dest += pitch; + } while (--count); } void DrawWallAdd1PalCommand::Execute(DrawerThread *thread) { + uint32_t fracstep = _iscale; + uint32_t frac = _texturefrac; + uint8_t *colormap = _colormap; + int count = _count; + const uint8_t *source = _source; + uint8_t *dest = _dest; + int bits = _tmvlinebits; + int pitch = _pitch; + + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + + do + { + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t fg = fg2rgb[colormap[pix]]; + uint32_t bg = bg2rgb[*dest]; + fg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg >> 15)]; + } + frac += fracstep; + dest += pitch; + } while (--count); } void DrawWallAdd4PalCommand::Execute(DrawerThread *thread) { + uint8_t *dest = _dest; + int count = _count; + int bits = _tmvlinebits; + + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + + uint32_t vplce[4] = { _vplce[0], _vplce[1], _vplce[2], _vplce[3] }; + + do + { + for (int i = 0; i < 4; ++i) + { + uint8_t pix = _bufplce[i][vplce[i] >> bits]; + if (pix != 0) + { + uint32_t fg = fg2rgb[_palookupoffse[i][pix]]; + uint32_t bg = bg2rgb[dest[i]]; + fg = (fg + bg) | 0x1f07c1f; + dest[i] = RGB32k.All[fg & (fg >> 15)]; + } + vplce[i] += _vince[i]; + } + dest += _pitch; + } while (--count); } void DrawWallAddClamp1PalCommand::Execute(DrawerThread *thread) { + uint32_t fracstep = _iscale; + uint32_t frac = _texturefrac; + uint8_t *colormap = _colormap; + int count = _count; + const uint8_t *source = _source; + uint8_t *dest = _dest; + int bits = _tmvlinebits; + int pitch = _pitch; + + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + + do + { + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t a = fg2rgb[colormap[pix]] + bg2rgb[*dest]; + uint32_t b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a >> 15)]; + } + frac += fracstep; + dest += pitch; + } while (--count); } void DrawWallAddClamp4PalCommand::Execute(DrawerThread *thread) { + uint8_t *dest = _dest; + int count = _count; + int bits = _tmvlinebits; + + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + + uint32_t vplce[4] = { _vplce[0], _vplce[1], _vplce[2], _vplce[3] }; + + do + { + for (int i = 0; i < 4; ++i) + { + uint8_t pix = _bufplce[i][vplce[i] >> bits]; + if (pix != 0) + { + uint32_t a = fg2rgb[_palookupoffse[i][pix]] + bg2rgb[dest[i]]; + uint32_t b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + dest[i] = RGB32k.All[a & (a >> 15)]; + } + vplce[i] += _vince[i]; + } + dest += _pitch; + } while (--count); } void DrawWallSubClamp1PalCommand::Execute(DrawerThread *thread) { + uint32_t fracstep = _iscale; + uint32_t frac = _texturefrac; + uint8_t *colormap = _colormap; + int count = _count; + const uint8_t *source = _source; + uint8_t *dest = _dest; + int bits = _tmvlinebits; + int pitch = _pitch; + + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + + do + { + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t a = (fg2rgb[colormap[pix]] | 0x40100400) - bg2rgb[*dest]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a >> 15)]; + } + frac += fracstep; + dest += pitch; + } while (--count); } void DrawWallSubClamp4PalCommand::Execute(DrawerThread *thread) { + uint8_t *dest = _dest; + int count = _count; + int bits = _tmvlinebits; + + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + + uint32_t vplce[4] = { _vplce[0], _vplce[1], _vplce[2], _vplce[3] }; + + do + { + for (int i = 0; i < 4; ++i) + { + uint8_t pix = _bufplce[i][vplce[i] >> bits]; + if (pix != 0) + { + uint32_t a = (fg2rgb[_palookupoffse[i][pix]] | 0x40100400) - bg2rgb[dest[i]]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[i] = RGB32k.All[a & (a >> 15)]; + } + vplce[i] += _vince[i]; + } + dest += _pitch; + } while (--count); } void DrawWallRevSubClamp1PalCommand::Execute(DrawerThread *thread) { + uint32_t fracstep = _iscale; + uint32_t frac = _texturefrac; + uint8_t *colormap = _colormap; + int count = _count; + const uint8_t *source = _source; + uint8_t *dest = _dest; + int bits = _tmvlinebits; + int pitch = _pitch; + + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + + do + { + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[pix]]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a >> 15)]; + } + frac += fracstep; + dest += pitch; + } while (--count); } void DrawWallRevSubClamp4PalCommand::Execute(DrawerThread *thread) { + uint8_t *dest = _dest; + int count = _count; + int bits = _tmvlinebits; + + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + + uint32_t vplce[4] = { _vplce[0], _vplce[1], _vplce[2], _vplce[3] }; + + do + { + for (int i = 0; i < 4; ++i) + { + uint8_t pix = _bufplce[i][vplce[i] >> bits]; + if (pix != 0) + { + uint32_t a = (bg2rgb[dest[i]] | 0x40100400) - fg2rgb[_palookupoffse[i][pix]]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[i] = RGB32k.All[a & (a >> 15)]; + } + vplce[i] += _vince[i]; + } + dest += _pitch; + } while (--count); } PalSkyCommand::PalSkyCommand(uint32_t solid_top, uint32_t solid_bottom) diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index 3d540f8c6..ea56fb7c0 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -12,6 +12,20 @@ namespace swrenderer public: PalWall1Command(); FString DebugInfo() override { return "PalWallCommand"; } + + protected: + uint32_t _iscale; + uint32_t _texturefrac; + uint8_t *_colormap; + int _count; + const uint8_t *_source; + uint8_t *_dest; + int _vlinebits; + int _mvlinebits; + int _tmvlinebits; + int _pitch; + uint32_t *_srcblend; + uint32_t *_destblend; }; class PalWall4Command : public DrawerCommand @@ -19,6 +33,20 @@ namespace swrenderer public: PalWall4Command(); FString DebugInfo() override { return "PalWallCommand"; } + + protected: + uint8_t *_dest; + int _count; + int _pitch; + int _vlinebits; + int _mvlinebits; + int _tmvlinebits; + uint8_t *_palookupoffse[4]; + const uint8_t *_bufplce[4]; + uint32_t _vince[4]; + uint32_t _vplce[4]; + uint32_t *_srcblend; + uint32_t *_destblend; }; class DrawWall1PalCommand : public PalWall1Command { public: void Execute(DrawerThread *thread) override; }; From 3b2d4fcff26e0db6bf1c15e987da6f4ddb3bb29f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 5 Dec 2016 11:59:48 +0100 Subject: [PATCH 1346/1509] Added span drawers --- src/r_draw_pal.cpp | 415 +++++++++++++++++++++++++++++++++++++++++++++ src/r_draw_pal.h | 18 ++ 2 files changed, 433 insertions(+) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index c4a05281b..80d2fc574 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -420,6 +420,8 @@ namespace swrenderer } while (--count); } + ///////////////////////////////////////////////////////////////////////// + PalSkyCommand::PalSkyCommand(uint32_t solid_top, uint32_t solid_bottom) { } @@ -440,6 +442,8 @@ namespace swrenderer { } + ///////////////////////////////////////////////////////////////////////// + PalColumnCommand::PalColumnCommand() { } @@ -512,34 +516,439 @@ namespace swrenderer { } + ///////////////////////////////////////////////////////////////////////// + + PalSpanCommand::PalSpanCommand() + { + using namespace drawerargs; + + _source = ds_source; + _colormap = ds_colormap; + _xfrac = ds_xfrac; + _yfrac = ds_yfrac; + _y = ds_y; + _x1 = ds_x1; + _x2 = ds_x2; + _destorg = dc_destorg; + _xstep = ds_xstep; + _ystep = ds_ystep; + _xbits = ds_xbits; + _ybits = ds_ybits; + _srcblend = dc_srcblend; + _destblend = dc_destblend; + _color = ds_color; + } + void DrawSpanPalCommand::Execute(DrawerThread *thread) { + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + uint8_t *dest; + const uint8_t *source = _source; + const uint8_t *colormap = _colormap; + int count; + int spot; + + xfrac = _xfrac; + yfrac = _yfrac; + + dest = ylookup[_y] + _x1 + _destorg; + + count = _x2 - _x1 + 1; + + xstep = _xstep; + ystep = _ystep; + + if (_xbits == 6 && _ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + *dest++ = colormap[source[spot]]; + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + uint8_t yshift = 32 - _ybits; + uint8_t xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + + do + { + // Current texture index in u,v. + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + *dest++ = colormap[source[spot]]; + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } void DrawSpanMaskedPalCommand::Execute(DrawerThread *thread) { + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + BYTE *dest; + const BYTE *source = _source; + const BYTE *colormap = _colormap; + int count; + int spot; + + xfrac = _xfrac; + yfrac = _yfrac; + + dest = ylookup[_y] + _x1 + _destorg; + + count = _x2 - _x1 + 1; + + xstep = _xstep; + ystep = _ystep; + + if (_xbits == 6 && _ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + int texdata; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + texdata = source[spot]; + if (texdata != 0) + { + *dest = colormap[texdata]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + int texdata; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + texdata = source[spot]; + if (texdata != 0) + { + *dest = colormap[texdata]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } void DrawSpanTranslucentPalCommand::Execute(DrawerThread *thread) { + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + BYTE *dest; + const BYTE *source = _source; + const BYTE *colormap = _colormap; + int count; + int spot; + DWORD *fg2rgb = _srcblend; + DWORD *bg2rgb = _destblend; + + xfrac = _xfrac; + yfrac = _yfrac; + + dest = ylookup[_y] + _x1 + _destorg; + + count = _x2 - _x1 + 1; + + xstep = _xstep; + ystep = _ystep; + + if (_xbits == 6 && _ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + DWORD fg = colormap[source[spot]]; + DWORD bg = *dest; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest++ = RGB32k.All[fg & (fg >> 15)]; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + DWORD fg = colormap[source[spot]]; + DWORD bg = *dest; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest++ = RGB32k.All[fg & (fg >> 15)]; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } void DrawSpanMaskedTranslucentPalCommand::Execute(DrawerThread *thread) { + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + BYTE *dest; + const BYTE *source = _source; + const BYTE *colormap = _colormap; + int count; + int spot; + DWORD *fg2rgb = _srcblend; + DWORD *bg2rgb = _destblend; + + xfrac = _xfrac; + yfrac = _yfrac; + + dest = ylookup[_y] + _x1 + _destorg; + + count = _x2 - _x1 + 1; + + xstep = _xstep; + ystep = _ystep; + + if (_xbits == 6 && _ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + BYTE texdata; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + texdata = source[spot]; + if (texdata != 0) + { + DWORD fg = colormap[texdata]; + DWORD bg = *dest; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg >> 15)]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + BYTE texdata; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + texdata = source[spot]; + if (texdata != 0) + { + DWORD fg = colormap[texdata]; + DWORD bg = *dest; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg >> 15)]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } void DrawSpanAddClampPalCommand::Execute(DrawerThread *thread) { + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + BYTE *dest; + const BYTE *source = _source; + const BYTE *colormap = _colormap; + int count; + int spot; + DWORD *fg2rgb = _srcblend; + DWORD *bg2rgb = _destblend; + + xfrac = _xfrac; + yfrac = _yfrac; + + dest = ylookup[_y] + _x1 + _destorg; + + count = _x2 - _x1 + 1; + + xstep = _xstep; + ystep = _ystep; + + if (_xbits == 6 && _ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + DWORD a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; + DWORD b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest++ = RGB32k.All[a & (a >> 15)]; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + DWORD a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; + DWORD b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest++ = RGB32k.All[a & (a >> 15)]; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } void DrawSpanMaskedAddClampPalCommand::Execute(DrawerThread *thread) { + dsfixed_t xfrac; + dsfixed_t yfrac; + dsfixed_t xstep; + dsfixed_t ystep; + BYTE *dest; + const BYTE *source = _source; + const BYTE *colormap = _colormap; + int count; + int spot; + DWORD *fg2rgb = _srcblend; + DWORD *bg2rgb = _destblend; + + xfrac = _xfrac; + yfrac = _yfrac; + + dest = ylookup[_y] + _x1 + _destorg; + + count = _x2 - _x1 + 1; + + xstep = _xstep; + ystep = _ystep; + + if (_xbits == 6 && _ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + BYTE texdata; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + texdata = source[spot]; + if (texdata != 0) + { + DWORD a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; + DWORD b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a >> 15)]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + BYTE yshift = 32 - _ybits; + BYTE xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + BYTE texdata; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + texdata = source[spot]; + if (texdata != 0) + { + DWORD a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; + DWORD b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a >> 15)]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } void FillSpanPalCommand::Execute(DrawerThread *thread) { + memset(ylookup[_y] + _x1 + _destorg, _color, _x2 - _x1 + 1); } + ///////////////////////////////////////////////////////////////////////// + DrawTiltedSpanPalCommand::DrawTiltedSpanPalCommand(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) { } @@ -548,6 +957,8 @@ namespace swrenderer { } + ///////////////////////////////////////////////////////////////////////// + DrawColoredSpanPalCommand::DrawColoredSpanPalCommand(int y, int x1, int x2) { } @@ -556,6 +967,8 @@ namespace swrenderer { } + ///////////////////////////////////////////////////////////////////////// + DrawSlabPalCommand::DrawSlabPalCommand(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p, const uint8_t *colormap) { } @@ -564,6 +977,8 @@ namespace swrenderer { } + ///////////////////////////////////////////////////////////////////////// + DrawFogBoundaryLinePalCommand::DrawFogBoundaryLinePalCommand(int y, int y2, int x1) { } diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index ea56fb7c0..bb0e5d1f0 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -108,7 +108,25 @@ namespace swrenderer class PalSpanCommand : public DrawerCommand { public: + PalSpanCommand(); FString DebugInfo() override { return "PalSpanCommand"; } + + protected: + const uint8_t *_source; + const uint8_t *_colormap; + dsfixed_t _xfrac; + dsfixed_t _yfrac; + int _y; + int _x1; + int _x2; + uint8_t *_destorg; + dsfixed_t _xstep; + dsfixed_t _ystep; + int _xbits; + int _ybits; + uint32_t *_srcblend; + uint32_t *_destblend; + int _color; }; class DrawSpanPalCommand : public PalSpanCommand { public: void Execute(DrawerThread *thread) override; }; From b755f489a341767d757c8078c4525aa917f68154 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 5 Dec 2016 12:01:03 +0100 Subject: [PATCH 1347/1509] Fix types --- src/r_draw_pal.cpp | 106 ++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 80d2fc574..765891a87 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -606,9 +606,9 @@ namespace swrenderer dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - BYTE *dest; - const BYTE *source = _source; - const BYTE *colormap = _colormap; + uint8_t *dest; + const uint8_t *source = _source; + const uint8_t *colormap = _colormap; int count; int spot; @@ -642,8 +642,8 @@ namespace swrenderer } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; + uint8_t yshift = 32 - _ybits; + uint8_t xshift = yshift - _xbits; int xmask = ((1 << _xbits) - 1) << _ybits; do { @@ -668,13 +668,13 @@ namespace swrenderer dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - BYTE *dest; - const BYTE *source = _source; - const BYTE *colormap = _colormap; + uint8_t *dest; + const uint8_t *source = _source; + const uint8_t *colormap = _colormap; int count; int spot; - DWORD *fg2rgb = _srcblend; - DWORD *bg2rgb = _destblend; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; xfrac = _xfrac; yfrac = _yfrac; @@ -692,8 +692,8 @@ namespace swrenderer do { spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - DWORD fg = colormap[source[spot]]; - DWORD bg = *dest; + uint32_t fg = colormap[source[spot]]; + uint32_t bg = *dest; fg = fg2rgb[fg]; bg = bg2rgb[bg]; fg = (fg + bg) | 0x1f07c1f; @@ -704,14 +704,14 @@ namespace swrenderer } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; + uint8_t yshift = 32 - _ybits; + uint8_t xshift = yshift - _xbits; int xmask = ((1 << _xbits) - 1) << _ybits; do { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - DWORD fg = colormap[source[spot]]; - DWORD bg = *dest; + uint32_t fg = colormap[source[spot]]; + uint32_t bg = *dest; fg = fg2rgb[fg]; bg = bg2rgb[bg]; fg = (fg + bg) | 0x1f07c1f; @@ -728,13 +728,13 @@ namespace swrenderer dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - BYTE *dest; - const BYTE *source = _source; - const BYTE *colormap = _colormap; + uint8_t *dest; + const uint8_t *source = _source; + const uint8_t *colormap = _colormap; int count; int spot; - DWORD *fg2rgb = _srcblend; - DWORD *bg2rgb = _destblend; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; xfrac = _xfrac; yfrac = _yfrac; @@ -751,14 +751,14 @@ namespace swrenderer // 64x64 is the most common case by far, so special case it. do { - BYTE texdata; + uint8_t texdata; spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); texdata = source[spot]; if (texdata != 0) { - DWORD fg = colormap[texdata]; - DWORD bg = *dest; + uint32_t fg = colormap[texdata]; + uint32_t bg = *dest; fg = fg2rgb[fg]; bg = bg2rgb[bg]; fg = (fg + bg) | 0x1f07c1f; @@ -771,19 +771,19 @@ namespace swrenderer } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; + uint8_t yshift = 32 - _ybits; + uint8_t xshift = yshift - _xbits; int xmask = ((1 << _xbits) - 1) << _ybits; do { - BYTE texdata; + uint8_t texdata; spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); texdata = source[spot]; if (texdata != 0) { - DWORD fg = colormap[texdata]; - DWORD bg = *dest; + uint32_t fg = colormap[texdata]; + uint32_t bg = *dest; fg = fg2rgb[fg]; bg = bg2rgb[bg]; fg = (fg + bg) | 0x1f07c1f; @@ -802,13 +802,13 @@ namespace swrenderer dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - BYTE *dest; - const BYTE *source = _source; - const BYTE *colormap = _colormap; + uint8_t *dest; + const uint8_t *source = _source; + const uint8_t *colormap = _colormap; int count; int spot; - DWORD *fg2rgb = _srcblend; - DWORD *bg2rgb = _destblend; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; xfrac = _xfrac; yfrac = _yfrac; @@ -826,8 +826,8 @@ namespace swrenderer do { spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - DWORD a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; - DWORD b = a; + uint32_t a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; + uint32_t b = a; a |= 0x01f07c1f; b &= 0x40100400; @@ -841,14 +841,14 @@ namespace swrenderer } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; + uint8_t yshift = 32 - _ybits; + uint8_t xshift = yshift - _xbits; int xmask = ((1 << _xbits) - 1) << _ybits; do { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - DWORD a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; - DWORD b = a; + uint32_t a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; + uint32_t b = a; a |= 0x01f07c1f; b &= 0x40100400; @@ -868,13 +868,13 @@ namespace swrenderer dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - BYTE *dest; - const BYTE *source = _source; - const BYTE *colormap = _colormap; + uint8_t *dest; + const uint8_t *source = _source; + const uint8_t *colormap = _colormap; int count; int spot; - DWORD *fg2rgb = _srcblend; - DWORD *bg2rgb = _destblend; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; xfrac = _xfrac; yfrac = _yfrac; @@ -891,14 +891,14 @@ namespace swrenderer // 64x64 is the most common case by far, so special case it. do { - BYTE texdata; + uint8_t texdata; spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); texdata = source[spot]; if (texdata != 0) { - DWORD a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; - DWORD b = a; + uint32_t a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; + uint32_t b = a; a |= 0x01f07c1f; b &= 0x40100400; @@ -914,19 +914,19 @@ namespace swrenderer } else { - BYTE yshift = 32 - _ybits; - BYTE xshift = yshift - _xbits; + uint8_t yshift = 32 - _ybits; + uint8_t xshift = yshift - _xbits; int xmask = ((1 << _xbits) - 1) << _ybits; do { - BYTE texdata; + uint8_t texdata; spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); texdata = source[spot]; if (texdata != 0) { - DWORD a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; - DWORD b = a; + uint32_t a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; + uint32_t b = a; a |= 0x01f07c1f; b &= 0x40100400; From bc66682860ca463429904940001b4aff5f2e0c6a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 5 Dec 2016 12:16:10 +0100 Subject: [PATCH 1348/1509] Add sky drawers --- src/r_draw_pal.cpp | 386 ++++++++++++++++++++++++++++++++++++++++++++- src/r_draw_pal.h | 13 ++ 2 files changed, 398 insertions(+), 1 deletion(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 765891a87..65bfaeb22 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -422,24 +422,408 @@ namespace swrenderer ///////////////////////////////////////////////////////////////////////// - PalSkyCommand::PalSkyCommand(uint32_t solid_top, uint32_t solid_bottom) + PalSkyCommand::PalSkyCommand(uint32_t solid_top, uint32_t solid_bottom) : solid_top(solid_top), solid_bottom(solid_bottom) { + using namespace drawerargs; + + _dest = dc_dest; + _count = dc_count; + _pitch = dc_pitch; + for (int col = 0; col < 4; col++) + { + _bufplce[col] = bufplce[col]; + _bufplce2[col] = bufplce2[col]; + _bufheight[col] = bufheight[col]; + _vince[col] = vince[col]; + _vplce[col] = vplce[col]; + } } void DrawSingleSky1PalCommand::Execute(DrawerThread *thread) { + uint8_t *dest = _dest; + int count = _count; + int pitch = _pitch; + const uint8_t *source0 = _bufplce[0]; + int textureheight0 = _bufheight[0]; + + int32_t frac = _vplce[0]; + int32_t fracstep = _vince[0]; + + int start_fade = 2; // How fast it should fade out + + int solid_top_r = RPART(solid_top); + int solid_top_g = GPART(solid_top); + int solid_top_b = BPART(solid_top); + int solid_bottom_r = RPART(solid_bottom); + int solid_bottom_g = GPART(solid_bottom); + int solid_bottom_b = BPART(solid_bottom); + + for (int index = 0; index < count; index++) + { + uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; + uint8_t fg = source0[sample_index]; + + int alpha_top = MAX(MIN(frac >> (16 - start_fade), 256), 0); + int alpha_bottom = MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0); + + if (alpha_top == 256 && alpha_bottom == 256) + { + *dest = fg; + } + else + { + int inv_alpha_top = 256 - alpha_top; + int inv_alpha_bottom = 256 - alpha_bottom; + + const auto &c = GPalette.BaseColors[fg]; + int c_red = c.r; + int c_green = c.g; + int c_blue = c.b; + c_red = (c_red * alpha_top + solid_top_r * inv_alpha_top) >> 8; + c_green = (c_green * alpha_top + solid_top_g * inv_alpha_top) >> 8; + c_blue = (c_blue * alpha_top + solid_top_b * inv_alpha_top) >> 8; + c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; + c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; + c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; + *dest = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + } + + frac += fracstep; + dest += pitch; + } } void DrawSingleSky4PalCommand::Execute(DrawerThread *thread) { + uint8_t *dest = _dest; + int count = _count; + int pitch = _pitch; + const uint8_t *source0[4] = { _bufplce[0], _bufplce[1], _bufplce[2], _bufplce[3] }; + int textureheight0 = _bufheight[0]; + const uint32_t *palette = (const uint32_t *)GPalette.BaseColors; + int32_t frac[4] = { (int32_t)_vplce[0], (int32_t)_vplce[1], (int32_t)_vplce[2], (int32_t)_vplce[3] }; + int32_t fracstep[4] = { (int32_t)_vince[0], (int32_t)_vince[1], (int32_t)_vince[2], (int32_t)_vince[3] }; + uint8_t output[4]; + + int start_fade = 2; // How fast it should fade out + + int solid_top_r = RPART(solid_top); + int solid_top_g = GPART(solid_top); + int solid_top_b = BPART(solid_top); + int solid_bottom_r = RPART(solid_bottom); + int solid_bottom_g = GPART(solid_bottom); + int solid_bottom_b = BPART(solid_bottom); + uint32_t solid_top_fill = RGB32k.RGB[(solid_top_r >> 3)][(solid_top_g >> 3)][(solid_top_b >> 3)]; + uint32_t solid_bottom_fill = RGB32k.RGB[(solid_bottom_r >> 3)][(solid_bottom_g >> 3)][(solid_bottom_b >> 3)]; + solid_top_fill = (solid_top_fill << 24) | (solid_top_fill << 16) | (solid_top_fill << 8) | solid_top_fill; + solid_bottom_fill = (solid_bottom_fill << 24) | (solid_bottom_fill << 16) | (solid_bottom_fill << 8) | solid_bottom_fill; + + // Find bands for top solid color, top fade, center textured, bottom fade, bottom solid color: + int fade_length = (1 << (24 - start_fade)); + int start_fadetop_y = (-frac[0]) / fracstep[0]; + int end_fadetop_y = (fade_length - frac[0]) / fracstep[0]; + int start_fadebottom_y = ((2 << 24) - fade_length - frac[0]) / fracstep[0]; + int end_fadebottom_y = ((2 << 24) - frac[0]) / fracstep[0]; + for (int col = 1; col < 4; col++) + { + start_fadetop_y = MIN(start_fadetop_y, (-frac[0]) / fracstep[0]); + end_fadetop_y = MAX(end_fadetop_y, (fade_length - frac[0]) / fracstep[0]); + start_fadebottom_y = MIN(start_fadebottom_y, ((2 << 24) - fade_length - frac[0]) / fracstep[0]); + end_fadebottom_y = MAX(end_fadebottom_y, ((2 << 24) - frac[0]) / fracstep[0]); + } + start_fadetop_y = clamp(start_fadetop_y, 0, count); + end_fadetop_y = clamp(end_fadetop_y, 0, count); + start_fadebottom_y = clamp(start_fadebottom_y, 0, count); + end_fadebottom_y = clamp(end_fadebottom_y, 0, count); + + // Top solid color: + for (int index = 0; index < start_fadetop_y; index++) + { + *((uint32_t*)dest) = solid_top_fill; + dest += pitch; + for (int col = 0; col < 4; col++) + frac[col] += fracstep[col]; + } + + // Top fade: + for (int index = start_fadetop_y; index < end_fadetop_y; index++) + { + for (int col = 0; col < 4; col++) + { + uint32_t sample_index = (((((uint32_t)frac[col]) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; + uint8_t fg = source0[col][sample_index]; + + uint32_t c = palette[fg]; + int alpha_top = MAX(MIN(frac[col] >> (16 - start_fade), 256), 0); + int inv_alpha_top = 256 - alpha_top; + int c_red = RPART(c); + int c_green = GPART(c); + int c_blue = BPART(c); + c_red = (c_red * alpha_top + solid_top_r * inv_alpha_top) >> 8; + c_green = (c_green * alpha_top + solid_top_g * inv_alpha_top) >> 8; + c_blue = (c_blue * alpha_top + solid_top_b * inv_alpha_top) >> 8; + output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + + frac[col] += fracstep[col]; + } + *((uint32_t*)dest) = *((uint32_t*)output); + dest += pitch; + } + + // Textured center: + for (int index = end_fadetop_y; index < start_fadebottom_y; index++) + { + for (int col = 0; col < 4; col++) + { + uint32_t sample_index = (((((uint32_t)frac[col]) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; + output[col] = source0[col][sample_index]; + + frac[col] += fracstep[col]; + } + + *((uint32_t*)dest) = *((uint32_t*)output); + dest += pitch; + } + + // Fade bottom: + for (int index = start_fadebottom_y; index < end_fadebottom_y; index++) + { + for (int col = 0; col < 4; col++) + { + uint32_t sample_index = (((((uint32_t)frac[col]) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; + uint8_t fg = source0[col][sample_index]; + + uint32_t c = palette[fg]; + int alpha_bottom = MAX(MIN(((2 << 24) - frac[col]) >> (16 - start_fade), 256), 0); + int inv_alpha_bottom = 256 - alpha_bottom; + int c_red = RPART(c); + int c_green = GPART(c); + int c_blue = BPART(c); + c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; + c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; + c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; + output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + + frac[col] += fracstep[col]; + } + *((uint32_t*)dest) = *((uint32_t*)output); + dest += pitch; + } + + // Bottom solid color: + for (int index = end_fadebottom_y; index < count; index++) + { + *((uint32_t*)dest) = solid_bottom_fill; + dest += pitch; + } } void DrawDoubleSky1PalCommand::Execute(DrawerThread *thread) { + uint8_t *dest = _dest; + int count = _count; + int pitch = _pitch; + const uint8_t *source0 = _bufplce[0]; + const uint8_t *source1 = _bufplce2[0]; + int textureheight0 = _bufheight[0]; + uint32_t maxtextureheight1 = _bufheight[1] - 1; + + int32_t frac = _vplce[0]; + int32_t fracstep = _vince[0]; + + int start_fade = 2; // How fast it should fade out + + int solid_top_r = RPART(solid_top); + int solid_top_g = GPART(solid_top); + int solid_top_b = BPART(solid_top); + int solid_bottom_r = RPART(solid_bottom); + int solid_bottom_g = GPART(solid_bottom); + int solid_bottom_b = BPART(solid_bottom); + + for (int index = 0; index < count; index++) + { + uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; + uint8_t fg = source0[sample_index]; + if (fg == 0) + { + uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + fg = source1[sample_index2]; + } + + int alpha_top = MAX(MIN(frac >> (16 - start_fade), 256), 0); + int alpha_bottom = MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0); + + if (alpha_top == 256 && alpha_bottom == 256) + { + *dest = fg; + } + else + { + int inv_alpha_top = 256 - alpha_top; + int inv_alpha_bottom = 256 - alpha_bottom; + + const auto &c = GPalette.BaseColors[fg]; + int c_red = c.r; + int c_green = c.g; + int c_blue = c.b; + c_red = (c_red * alpha_top + solid_top_r * inv_alpha_top) >> 8; + c_green = (c_green * alpha_top + solid_top_g * inv_alpha_top) >> 8; + c_blue = (c_blue * alpha_top + solid_top_b * inv_alpha_top) >> 8; + c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; + c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; + c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; + *dest = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + } + + frac += fracstep; + dest += pitch; + } } void DrawDoubleSky4PalCommand::Execute(DrawerThread *thread) { + uint8_t *dest = _dest; + int count = _count; + int pitch = _pitch; + const uint8_t *source0[4] = { _bufplce[0], _bufplce[1], _bufplce[2], _bufplce[3] }; + const uint8_t *source1[4] = { _bufplce2[0], _bufplce2[1], _bufplce2[2], _bufplce2[3] }; + int textureheight0 = _bufheight[0]; + uint32_t maxtextureheight1 = _bufheight[1] - 1; + const uint32_t *palette = (const uint32_t *)GPalette.BaseColors; + int32_t frac[4] = { (int32_t)_vplce[0], (int32_t)_vplce[1], (int32_t)_vplce[2], (int32_t)_vplce[3] }; + int32_t fracstep[4] = { (int32_t)_vince[0], (int32_t)_vince[1], (int32_t)_vince[2], (int32_t)_vince[3] }; + uint8_t output[4]; + + int start_fade = 2; // How fast it should fade out + + int solid_top_r = RPART(solid_top); + int solid_top_g = GPART(solid_top); + int solid_top_b = BPART(solid_top); + int solid_bottom_r = RPART(solid_bottom); + int solid_bottom_g = GPART(solid_bottom); + int solid_bottom_b = BPART(solid_bottom); + uint32_t solid_top_fill = RGB32k.RGB[(solid_top_r >> 3)][(solid_top_g >> 3)][(solid_top_b >> 3)]; + uint32_t solid_bottom_fill = RGB32k.RGB[(solid_bottom_r >> 3)][(solid_bottom_g >> 3)][(solid_bottom_b >> 3)]; + solid_top_fill = (solid_top_fill << 24) | (solid_top_fill << 16) | (solid_top_fill << 8) | solid_top_fill; + solid_bottom_fill = (solid_bottom_fill << 24) | (solid_bottom_fill << 16) | (solid_bottom_fill << 8) | solid_bottom_fill; + + // Find bands for top solid color, top fade, center textured, bottom fade, bottom solid color: + int fade_length = (1 << (24 - start_fade)); + int start_fadetop_y = (-frac[0]) / fracstep[0]; + int end_fadetop_y = (fade_length - frac[0]) / fracstep[0]; + int start_fadebottom_y = ((2 << 24) - fade_length - frac[0]) / fracstep[0]; + int end_fadebottom_y = ((2 << 24) - frac[0]) / fracstep[0]; + for (int col = 1; col < 4; col++) + { + start_fadetop_y = MIN(start_fadetop_y, (-frac[0]) / fracstep[0]); + end_fadetop_y = MAX(end_fadetop_y, (fade_length - frac[0]) / fracstep[0]); + start_fadebottom_y = MIN(start_fadebottom_y, ((2 << 24) - fade_length - frac[0]) / fracstep[0]); + end_fadebottom_y = MAX(end_fadebottom_y, ((2 << 24) - frac[0]) / fracstep[0]); + } + start_fadetop_y = clamp(start_fadetop_y, 0, count); + end_fadetop_y = clamp(end_fadetop_y, 0, count); + start_fadebottom_y = clamp(start_fadebottom_y, 0, count); + end_fadebottom_y = clamp(end_fadebottom_y, 0, count); + + // Top solid color: + for (int index = 0; index < start_fadetop_y; index++) + { + *((uint32_t*)dest) = solid_top_fill; + dest += pitch; + for (int col = 0; col < 4; col++) + frac[col] += fracstep[col]; + } + + // Top fade: + for (int index = start_fadetop_y; index < end_fadetop_y; index++) + { + for (int col = 0; col < 4; col++) + { + uint32_t sample_index = (((((uint32_t)frac[col]) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; + uint8_t fg = source0[col][sample_index]; + if (fg == 0) + { + uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + fg = source1[col][sample_index2]; + } + output[col] = fg; + + uint32_t c = palette[fg]; + int alpha_top = MAX(MIN(frac[col] >> (16 - start_fade), 256), 0); + int inv_alpha_top = 256 - alpha_top; + int c_red = RPART(c); + int c_green = GPART(c); + int c_blue = BPART(c); + c_red = (c_red * alpha_top + solid_top_r * inv_alpha_top) >> 8; + c_green = (c_green * alpha_top + solid_top_g * inv_alpha_top) >> 8; + c_blue = (c_blue * alpha_top + solid_top_b * inv_alpha_top) >> 8; + output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + + frac[col] += fracstep[col]; + } + *((uint32_t*)dest) = *((uint32_t*)output); + dest += pitch; + } + + // Textured center: + for (int index = end_fadetop_y; index < start_fadebottom_y; index++) + { + for (int col = 0; col < 4; col++) + { + uint32_t sample_index = (((((uint32_t)frac[col]) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; + uint8_t fg = source0[col][sample_index]; + if (fg == 0) + { + uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + fg = source1[col][sample_index2]; + } + output[col] = fg; + + frac[col] += fracstep[col]; + } + + *((uint32_t*)dest) = *((uint32_t*)output); + dest += pitch; + } + + // Fade bottom: + for (int index = start_fadebottom_y; index < end_fadebottom_y; index++) + { + for (int col = 0; col < 4; col++) + { + uint32_t sample_index = (((((uint32_t)frac[col]) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; + uint8_t fg = source0[col][sample_index]; + if (fg == 0) + { + uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + fg = source1[col][sample_index2]; + } + output[col] = fg; + + uint32_t c = palette[fg]; + int alpha_bottom = MAX(MIN(((2 << 24) - frac[col]) >> (16 - start_fade), 256), 0); + int inv_alpha_bottom = 256 - alpha_bottom; + int c_red = RPART(c); + int c_green = GPART(c); + int c_blue = BPART(c); + c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; + c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; + c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; + output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + + frac[col] += fracstep[col]; + } + *((uint32_t*)dest) = *((uint32_t*)output); + dest += pitch; + } + + // Bottom solid color: + for (int index = end_fadebottom_y; index < count; index++) + { + *((uint32_t*)dest) = solid_bottom_fill; + dest += pitch; + } } ///////////////////////////////////////////////////////////////////////// diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index bb0e5d1f0..2de04367d 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -67,6 +67,19 @@ namespace swrenderer public: PalSkyCommand(uint32_t solid_top, uint32_t solid_bottom); FString DebugInfo() override { return "PalSkyCommand"; } + + protected: + uint32_t solid_top; + uint32_t solid_bottom; + + uint8_t *_dest; + int _count; + int _pitch; + const uint8_t *_bufplce[4]; + const uint8_t *_bufplce2[4]; + int _bufheight[4]; + uint32_t _vince[4]; + uint32_t _vplce[4]; }; class DrawSingleSky1PalCommand : public PalSkyCommand { public: using PalSkyCommand::PalSkyCommand; void Execute(DrawerThread *thread) override; }; From 2ca0238e2f48a416ecd9071448e5e6daecad622a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 5 Dec 2016 12:41:16 +0100 Subject: [PATCH 1349/1509] Add column drawers --- src/r_draw_pal.cpp | 644 +++++++++++++++++++++++++++++++++++++++++++++ src/r_draw_pal.h | 22 ++ 2 files changed, 666 insertions(+) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 65bfaeb22..ea1ae96b8 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -9,6 +9,47 @@ #include "v_video.h" #include "r_draw_pal.h" +/* + [RH] This translucency algorithm is based on DOSDoom 0.65's, but uses + a 32k RGB table instead of an 8k one. At least on my machine, it's + slightly faster (probably because it uses only one shift instead of + two), and it looks considerably less green at the ends of the + translucency range. The extra size doesn't appear to be an issue. + + The following note is from DOSDoom 0.65: + + New translucency algorithm, by Erik Sandberg: + + Basically, we compute the red, green and blue values for each pixel, and + then use a RGB table to check which one of the palette colours that best + represents those RGB values. The RGB table is 8k big, with 4 R-bits, + 5 G-bits and 4 B-bits. A 4k table gives a bit too bad precision, and a 32k + table takes up more memory and results in more cache misses, so an 8k + table seemed to be quite ultimate. + + The computation of the RGB for each pixel is accelerated by using two + 1k tables for each translucency level. + The xth element of one of these tables contains the r, g and b values for + the colour x, weighted for the current translucency level (for example, + the weighted rgb values for background colour at 75% translucency are 1/4 + of the original rgb values). The rgb values are stored as three + low-precision fixed point values, packed into one long per colour: + Bit 0-4: Frac part of blue (5 bits) + Bit 5-8: Int part of blue (4 bits) + Bit 9-13: Frac part of red (5 bits) + Bit 14-17: Int part of red (4 bits) + Bit 18-22: Frac part of green (5 bits) + Bit 23-27: Int part of green (5 bits) + Bit 28-31: All zeros (4 bits) + + The point of this format is that the two colours now can be added, and + then be converted to a RGB table index very easily: First, we just set + all the frac bits and the four upper zero bits to 1. It's now possible + to get the RGB table index by anding the current value >> 5 with the + current value >> 19. When asm-optimised, this should be the fastest + algorithm that uses RGB tables. +*/ + namespace swrenderer { PalWall1Command::PalWall1Command() @@ -830,74 +871,677 @@ namespace swrenderer PalColumnCommand::PalColumnCommand() { + using namespace drawerargs; + + _count = dc_count; + _dest = dc_dest; + _pitch = dc_pitch; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _colormap = dc_colormap; + _source = dc_source; + _translation = dc_translation; + _color = dc_color; + _srcblend = dc_srcblend; + _destblend = dc_destblend; + _srccolor = dc_srccolor; } void DrawColumnPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + fixed_t frac; + fixed_t fracstep; + + count = _count; + + // Zero length, column does not exceed a pixel. + if (count <= 0) + return; + + // Framebuffer destination address. + dest = _dest; + + // Determine scaling, + // which is the only mapping to be done. + fracstep = _iscale; + frac = _texturefrac; + + { + // [RH] Get local copies of these variables so that the compiler + // has a better chance of optimizing this well. + const BYTE *colormap = _colormap; + const BYTE *source = _source; + int pitch = _pitch; + + // Inner loop that does the actual texture mapping, + // e.g. a DDA-lile scaling. + // This is as fast as it gets. + do + { + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + *dest = colormap[source[frac >> FRACBITS]]; + + dest += pitch; + frac += fracstep; + + } while (--count); + } } void FillColumnPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + + count = _count; + + if (count <= 0) + return; + + dest = _dest; + + { + int pitch = _pitch; + BYTE color = _color; + + do + { + *dest = color; + dest += pitch; + } while (--count); + } } void FillColumnAddPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + + count = _count; + if (count <= 0) + return; + + dest = _dest; + DWORD *bg2rgb; + DWORD fg; + + bg2rgb = _destblend; + fg = _srccolor; + int pitch = _pitch; + + do + { + DWORD bg; + bg = (fg + bg2rgb[*dest]) | 0x1f07c1f; + *dest = RGB32k.All[bg & (bg >> 15)]; + dest += pitch; + } while (--count); + } void FillColumnAddClampPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + + count = _count; + if (count <= 0) + return; + + dest = _dest; + DWORD *bg2rgb; + DWORD fg; + + bg2rgb = _destblend; + fg = _srccolor; + int pitch = _pitch; + + do + { + DWORD a = fg + bg2rgb[*dest]; + DWORD b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + } while (--count); } void FillColumnSubClampPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + + count = _count; + if (count <= 0) + return; + + dest = _dest; + DWORD *bg2rgb; + DWORD fg; + + bg2rgb = _destblend; + fg = _srccolor | 0x40100400; + int pitch = _pitch; + + do + { + DWORD a = fg - bg2rgb[*dest]; + DWORD b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + } while (--count); } void FillColumnRevSubClampPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + + count = _count; + if (count <= 0) + return; + + dest = _dest; + DWORD *bg2rgb; + DWORD fg; + + bg2rgb = _destblend; + fg = _srccolor; + int pitch = _pitch; + + do + { + DWORD a = (bg2rgb[*dest] | 0x40100400) - fg; + DWORD b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + } while (--count); } void DrawColumnAddPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + fixed_t frac; + fixed_t fracstep; + + count = _count; + if (count <= 0) + return; + + dest = _dest; + + fracstep = _iscale; + frac = _texturefrac; + + { + DWORD *fg2rgb = _srcblend; + DWORD *bg2rgb = _destblend; + const BYTE *colormap = _colormap; + const BYTE *source = _source; + int pitch = _pitch; + + do + { + DWORD fg = colormap[source[frac >> FRACBITS]]; + DWORD bg = *dest; + + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnTranslatedPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE* dest; + fixed_t frac; + fixed_t fracstep; + + count = _count; + if (count <= 0) + return; + + dest = _dest; + + fracstep = _iscale; + frac = _texturefrac; + + { + // [RH] Local copies of global vars to improve compiler optimizations + const BYTE *colormap = _colormap; + const BYTE *translation = _translation; + const BYTE *source = _source; + int pitch = _pitch; + + do + { + *dest = colormap[translation[source[frac >> FRACBITS]]]; + dest += pitch; + + frac += fracstep; + } while (--count); + } } void DrawColumnTlatedAddPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + fixed_t frac; + fixed_t fracstep; + + count = _count; + if (count <= 0) + return; + + dest = _dest; + + fracstep = _iscale; + frac = _texturefrac; + + { + DWORD *fg2rgb = _srcblend; + DWORD *bg2rgb = _destblend; + const BYTE *translation = _translation; + const BYTE *colormap = _colormap; + const BYTE *source = _source; + int pitch = _pitch; + + do + { + DWORD fg = colormap[translation[source[frac >> FRACBITS]]]; + DWORD bg = *dest; + + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnShadedPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + fixed_t frac, fracstep; + + count = _count; + + if (count <= 0) + return; + + dest = _dest; + + fracstep = _iscale; + frac = _texturefrac; + + { + const BYTE *source = _source; + const BYTE *colormap = _colormap; + int pitch = _pitch; + DWORD *fgstart = &Col2RGB8[0][_color]; + + do + { + DWORD val = colormap[source[frac >> FRACBITS]]; + DWORD fg = fgstart[val << 8]; + val = (Col2RGB8[64 - val][*dest] + fg) | 0x1f07c1f; + *dest = RGB32k.All[val & (val >> 15)]; + + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnAddClampPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + fixed_t frac; + fixed_t fracstep; + + count = _count; + if (count <= 0) + return; + + dest = _dest; + + fracstep = _iscale; + frac = _texturefrac; + + { + const BYTE *colormap = _colormap; + const BYTE *source = _source; + int pitch = _pitch; + DWORD *fg2rgb = _srcblend; + DWORD *bg2rgb = _destblend; + + do + { + DWORD a = fg2rgb[colormap[source[frac >> FRACBITS]]] + bg2rgb[*dest]; + DWORD b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnAddClampTranslatedPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + fixed_t frac; + fixed_t fracstep; + + count = _count; + if (count <= 0) + return; + + dest = _dest; + + fracstep = _iscale; + frac = _texturefrac; + + { + const BYTE *translation = _translation; + const BYTE *colormap = _colormap; + const BYTE *source = _source; + int pitch = _pitch; + DWORD *fg2rgb = _srcblend; + DWORD *bg2rgb = _destblend; + + do + { + DWORD a = fg2rgb[colormap[translation[source[frac >> FRACBITS]]]] + bg2rgb[*dest]; + DWORD b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[(a >> 15) & a]; + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnSubClampPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + fixed_t frac; + fixed_t fracstep; + + count = _count; + if (count <= 0) + return; + + dest = _dest; + + fracstep = _iscale; + frac = _texturefrac; + + { + const BYTE *colormap = _colormap; + const BYTE *source = _source; + int pitch = _pitch; + DWORD *fg2rgb = _srcblend; + DWORD *bg2rgb = _destblend; + + do + { + DWORD a = (fg2rgb[colormap[source[frac >> FRACBITS]]] | 0x40100400) - bg2rgb[*dest]; + DWORD b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnSubClampTranslatedPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + fixed_t frac; + fixed_t fracstep; + + count = _count; + if (count <= 0) + return; + + dest = _dest; + + fracstep = _iscale; + frac = _texturefrac; + + { + const BYTE *translation = _translation; + const BYTE *colormap = _colormap; + const BYTE *source = _source; + int pitch = _pitch; + DWORD *fg2rgb = _srcblend; + DWORD *bg2rgb = _destblend; + + do + { + DWORD a = (fg2rgb[colormap[translation[source[frac >> FRACBITS]]]] | 0x40100400) - bg2rgb[*dest]; + DWORD b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[(a >> 15) & a]; + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnRevSubClampPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + fixed_t frac; + fixed_t fracstep; + + count = _count; + if (count <= 0) + return; + + dest = _dest; + + fracstep = _iscale; + frac = _texturefrac; + + { + const BYTE *colormap = _colormap; + const BYTE *source = _source; + int pitch = _pitch; + DWORD *fg2rgb = _srcblend; + DWORD *bg2rgb = _destblend; + + do + { + DWORD a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[source[frac >> FRACBITS]]]; + DWORD b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnRevSubClampTranslatedPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + fixed_t frac; + fixed_t fracstep; + + count = _count; + if (count <= 0) + return; + + dest = _dest; + + fracstep = _iscale; + frac = _texturefrac; + + { + const BYTE *translation = _translation; + const BYTE *colormap = _colormap; + const BYTE *source = _source; + int pitch = _pitch; + DWORD *fg2rgb = _srcblend; + DWORD *bg2rgb = _destblend; + + do + { + DWORD a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[translation[source[frac >> FRACBITS]]]]; + DWORD b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[(a >> 15) & a]; + dest += pitch; + frac += fracstep; + } while (--count); + } + } + + ///////////////////////////////////////////////////////////////////////// + + DrawFuzzColumnPalCommand::DrawFuzzColumnPalCommand() + { + using namespace drawerargs; + + _yl = dc_yl; + _yh = dc_yh; + _x = dc_x; + _destorg = dc_destorg; + _pitch = dc_pitch; } void DrawFuzzColumnPalCommand::Execute(DrawerThread *thread) { + int count; + BYTE *dest; + + // Adjust borders. Low... + if (_yl == 0) + _yl = 1; + + // .. and high. + if (_yh > fuzzviewheight) + _yh = fuzzviewheight; + + count = _yh - _yl; + + // Zero length. + if (count < 0) + return; + + count++; + + dest = ylookup[_yl] + _x + _destorg; + + // colormap #6 is used for shading (of 0-31, a bit brighter than average) + { + // [RH] Make local copies of global vars to try and improve + // the optimizations made by the compiler. + int pitch = _pitch; + int fuzz = fuzzpos; + int cnt; + BYTE *map = &NormalLight.Maps[6 * 256]; + + // [RH] Split this into three separate loops to minimize + // the number of times fuzzpos needs to be clamped. + if (fuzz) + { + cnt = MIN(FUZZTABLE - fuzz, count); + count -= cnt; + do + { + *dest = map[dest[fuzzoffset[fuzz++]]]; + dest += pitch; + } while (--cnt); + } + if (fuzz == FUZZTABLE || count > 0) + { + while (count >= FUZZTABLE) + { + fuzz = 0; + cnt = FUZZTABLE; + count -= FUZZTABLE; + do + { + *dest = map[dest[fuzzoffset[fuzz++]]]; + dest += pitch; + } while (--cnt); + } + fuzz = 0; + if (count > 0) + { + do + { + *dest = map[dest[fuzzoffset[fuzz++]]]; + dest += pitch; + } while (--count); + } + } + fuzzpos = fuzz; + } } ///////////////////////////////////////////////////////////////////////// diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index 2de04367d..f1297a06b 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -92,6 +92,20 @@ namespace swrenderer public: PalColumnCommand(); FString DebugInfo() override { return "PalColumnCommand"; } + + protected: + int _count; + uint8_t *_dest; + int _pitch; + fixed_t _iscale; + fixed_t _texturefrac; + const uint8_t *_colormap; + const uint8_t *_source; + const uint8_t *_translation; + int _color; + uint32_t *_srcblend; + uint32_t *_destblend; + uint32_t _srccolor; }; class DrawColumnPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; @@ -114,8 +128,16 @@ namespace swrenderer class DrawFuzzColumnPalCommand : public DrawerCommand { public: + DrawFuzzColumnPalCommand(); void Execute(DrawerThread *thread) override; FString DebugInfo() override { return "DrawFuzzColumnPalCommand"; } + + private: + int _yl; + int _yh; + int _x; + uint8_t *_destorg; + int _pitch; }; class PalSpanCommand : public DrawerCommand From d8a3174330b080b8b8bc2502d63ff300c79b95d7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 5 Dec 2016 12:47:43 +0100 Subject: [PATCH 1350/1509] Thread awareness to the span drawers --- src/r_draw_pal.cpp | 21 +++++++++++++++++++++ src/r_thread.h | 5 ++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index ea1ae96b8..66b5dce06 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -1569,6 +1569,9 @@ namespace swrenderer void DrawSpanPalCommand::Execute(DrawerThread *thread) { + if (thread->skipped_by_thread(_dest_y)) + return; + dsfixed_t xfrac; dsfixed_t yfrac; dsfixed_t xstep; @@ -1630,6 +1633,9 @@ namespace swrenderer void DrawSpanMaskedPalCommand::Execute(DrawerThread *thread) { + if (thread->skipped_by_thread(_dest_y)) + return; + dsfixed_t xfrac; dsfixed_t yfrac; dsfixed_t xstep; @@ -1692,6 +1698,9 @@ namespace swrenderer void DrawSpanTranslucentPalCommand::Execute(DrawerThread *thread) { + if (thread->skipped_by_thread(_dest_y)) + return; + dsfixed_t xfrac; dsfixed_t yfrac; dsfixed_t xstep; @@ -1752,6 +1761,9 @@ namespace swrenderer void DrawSpanMaskedTranslucentPalCommand::Execute(DrawerThread *thread) { + if (thread->skipped_by_thread(_dest_y)) + return; + dsfixed_t xfrac; dsfixed_t yfrac; dsfixed_t xstep; @@ -1826,6 +1838,9 @@ namespace swrenderer void DrawSpanAddClampPalCommand::Execute(DrawerThread *thread) { + if (thread->skipped_by_thread(_dest_y)) + return; + dsfixed_t xfrac; dsfixed_t yfrac; dsfixed_t xstep; @@ -1892,6 +1907,9 @@ namespace swrenderer void DrawSpanMaskedAddClampPalCommand::Execute(DrawerThread *thread) { + if (thread->skipped_by_thread(_dest_y)) + return; + dsfixed_t xfrac; dsfixed_t yfrac; dsfixed_t xstep; @@ -1972,6 +1990,9 @@ namespace swrenderer void FillSpanPalCommand::Execute(DrawerThread *thread) { + if (thread->skipped_by_thread(_y)) + return; + memset(ylookup[_y] + _x1 + _destorg, _color, _x2 - _x1 + 1); } diff --git a/src/r_thread.h b/src/r_thread.h index 3077a095f..3217e1904 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -123,7 +123,10 @@ protected: public: DrawerCommand() { - _dest_y = static_cast((swrenderer::drawerargs::dc_dest - swrenderer::drawerargs::dc_destorg) / (swrenderer::drawerargs::dc_pitch * 4)); + if (swrenderer::r_swtruecolor) + _dest_y = static_cast((swrenderer::drawerargs::dc_dest - swrenderer::drawerargs::dc_destorg) / (swrenderer::drawerargs::dc_pitch * 4)); + else + _dest_y = static_cast((swrenderer::drawerargs::dc_dest - swrenderer::drawerargs::dc_destorg) / (swrenderer::drawerargs::dc_pitch)); } virtual ~DrawerCommand() { } From 246d1625e5912f9aa9765260cf52efea631198bc Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 5 Dec 2016 13:05:05 +0100 Subject: [PATCH 1351/1509] Make wall drawers thread aware --- src/r_draw_pal.cpp | 176 +++++++++++++++++++++++++++++++++++++++++---- src/r_thread.h | 3 +- 2 files changed, 163 insertions(+), 16 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 66b5dce06..0c45e629e 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -102,6 +102,15 @@ namespace swrenderer int bits = _vlinebits; int pitch = _pitch; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + do { *dest = colormap[source[frac >> bits]]; @@ -124,16 +133,32 @@ namespace swrenderer auto buf1 = _bufplce[1]; auto buf2 = _bufplce[2]; auto buf3 = _bufplce[3]; - const auto vince0 = _vince[0]; - const auto vince1 = _vince[1]; - const auto vince2 = _vince[2]; - const auto vince3 = _vince[3]; + auto vince0 = _vince[0]; + auto vince1 = _vince[1]; + auto vince2 = _vince[2]; + auto vince3 = _vince[3]; auto vplce0 = _vplce[0]; auto vplce1 = _vplce[1]; auto vplce2 = _vplce[2]; auto vplce3 = _vplce[3]; auto pitch = _pitch; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int skipped = thread->skipped_by_thread(_dest_y); + dest = thread->dest_for_thread(_dest_y, pitch, dest); + vplce0 += vince0 * skipped; + vplce1 += vince1 * skipped; + vplce2 += vince2 * skipped; + vplce3 += vince3 * skipped; + vince0 *= thread->num_cores; + vince1 *= thread->num_cores; + vince2 *= thread->num_cores; + vince3 *= thread->num_cores; + pitch *= thread->num_cores; + do { dest[0] = pal0[buf0[(place = vplce0) >> bits]]; vplce0 = place + vince0; @@ -155,6 +180,15 @@ namespace swrenderer int bits = _mvlinebits; int pitch = _pitch; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + do { uint8_t pix = source[frac >> bits]; @@ -181,16 +215,32 @@ namespace swrenderer auto buf1 = _bufplce[1]; auto buf2 = _bufplce[2]; auto buf3 = _bufplce[3]; - const auto vince0 = _vince[0]; - const auto vince1 = _vince[1]; - const auto vince2 = _vince[2]; - const auto vince3 = _vince[3]; + auto vince0 = _vince[0]; + auto vince1 = _vince[1]; + auto vince2 = _vince[2]; + auto vince3 = _vince[3]; auto vplce0 = _vplce[0]; auto vplce1 = _vplce[1]; auto vplce2 = _vplce[2]; auto vplce3 = _vplce[3]; auto pitch = _pitch; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int skipped = thread->skipped_by_thread(_dest_y); + dest = thread->dest_for_thread(_dest_y, pitch, dest); + vplce0 += vince0 * skipped; + vplce1 += vince1 * skipped; + vplce2 += vince2 * skipped; + vplce3 += vince3 * skipped; + vince0 *= thread->num_cores; + vince1 *= thread->num_cores; + vince2 *= thread->num_cores; + vince3 *= thread->num_cores; + pitch *= thread->num_cores; + do { uint8_t pix; @@ -217,6 +267,15 @@ namespace swrenderer uint32_t *fg2rgb = _srcblend; uint32_t *bg2rgb = _destblend; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + do { uint8_t pix = source[frac >> bits]; @@ -242,6 +301,21 @@ namespace swrenderer uint32_t *bg2rgb = _destblend; uint32_t vplce[4] = { _vplce[0], _vplce[1], _vplce[2], _vplce[3] }; + uint32_t vince[4] = { _vince[0], _vince[1], _vince[2], _vince[3] }; + + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + int skipped = thread->skipped_by_thread(_dest_y); + dest = thread->dest_for_thread(_dest_y, pitch, dest); + for (int i = 0; i < 4; i++) + { + vplce[i] += vince[i] * skipped; + vince[i] *= thread->num_cores; + } + pitch *= thread->num_cores; do { @@ -255,9 +329,9 @@ namespace swrenderer fg = (fg + bg) | 0x1f07c1f; dest[i] = RGB32k.All[fg & (fg >> 15)]; } - vplce[i] += _vince[i]; + vplce[i] += vince[i]; } - dest += _pitch; + dest += pitch; } while (--count); } @@ -275,6 +349,15 @@ namespace swrenderer uint32_t *fg2rgb = _srcblend; uint32_t *bg2rgb = _destblend; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + do { uint8_t pix = source[frac >> bits]; @@ -305,6 +388,21 @@ namespace swrenderer uint32_t *bg2rgb = _destblend; uint32_t vplce[4] = { _vplce[0], _vplce[1], _vplce[2], _vplce[3] }; + uint32_t vince[4] = { _vince[0], _vince[1], _vince[2], _vince[3] }; + + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + int skipped = thread->skipped_by_thread(_dest_y); + dest = thread->dest_for_thread(_dest_y, pitch, dest); + for (int i = 0; i < 4; i++) + { + vplce[i] += vince[i] * skipped; + vince[i] *= thread->num_cores; + } + pitch *= thread->num_cores; do { @@ -323,9 +421,9 @@ namespace swrenderer a |= b; dest[i] = RGB32k.All[a & (a >> 15)]; } - vplce[i] += _vince[i]; + vplce[i] += vince[i]; } - dest += _pitch; + dest += pitch; } while (--count); } @@ -343,6 +441,15 @@ namespace swrenderer uint32_t *fg2rgb = _srcblend; uint32_t *bg2rgb = _destblend; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + do { uint8_t pix = source[frac >> bits]; @@ -372,6 +479,21 @@ namespace swrenderer uint32_t *bg2rgb = _destblend; uint32_t vplce[4] = { _vplce[0], _vplce[1], _vplce[2], _vplce[3] }; + uint32_t vince[4] = { _vince[0], _vince[1], _vince[2], _vince[3] }; + + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + int skipped = thread->skipped_by_thread(_dest_y); + dest = thread->dest_for_thread(_dest_y, pitch, dest); + for (int i = 0; i < 4; i++) + { + vplce[i] += vince[i] * skipped; + vince[i] *= thread->num_cores; + } + pitch *= thread->num_cores; do { @@ -389,9 +511,9 @@ namespace swrenderer a |= 0x01f07c1f; dest[i] = RGB32k.All[a & (a >> 15)]; } - vplce[i] += _vince[i]; + vplce[i] += vince[i]; } - dest += _pitch; + dest += pitch; } while (--count); } @@ -409,6 +531,15 @@ namespace swrenderer uint32_t *fg2rgb = _srcblend; uint32_t *bg2rgb = _destblend; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + do { uint8_t pix = source[frac >> bits]; @@ -438,6 +569,21 @@ namespace swrenderer uint32_t *bg2rgb = _destblend; uint32_t vplce[4] = { _vplce[0], _vplce[1], _vplce[2], _vplce[3] }; + uint32_t vince[4] = { _vince[0], _vince[1], _vince[2], _vince[3] }; + + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + int skipped = thread->skipped_by_thread(_dest_y); + dest = thread->dest_for_thread(_dest_y, pitch, dest); + for (int i = 0; i < 4; i++) + { + vplce[i] += vince[i] * skipped; + vince[i] *= thread->num_cores; + } + pitch *= thread->num_cores; do { @@ -455,7 +601,7 @@ namespace swrenderer a |= 0x01f07c1f; dest[i] = RGB32k.All[a & (a >> 15)]; } - vplce[i] += _vince[i]; + vplce[i] += vince[i]; } dest += _pitch; } while (--count); diff --git a/src/r_thread.h b/src/r_thread.h index 3217e1904..29d971ad3 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -84,7 +84,8 @@ public: } // Calculate the dest address for the first line to be rendered by this thread - uint32_t *dest_for_thread(int first_line, int pitch, uint32_t *dest) + template + T *dest_for_thread(int first_line, int pitch, T *dest) { return dest + skipped_by_thread(first_line) * pitch; } From 836c7a5351c2ebee8fd5ef74a53cb203f57565e9 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 5 Dec 2016 13:23:30 +0100 Subject: [PATCH 1352/1509] Make sky drawers thread aware --- src/r_draw_pal.cpp | 72 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 0c45e629e..84f9772b6 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -646,6 +646,16 @@ namespace swrenderer int solid_bottom_g = GPART(solid_bottom); int solid_bottom_b = BPART(solid_bottom); + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int skipped = thread->skipped_by_thread(_dest_y); + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * skipped; + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + for (int index = 0; index < count; index++) { uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; @@ -724,17 +734,29 @@ namespace swrenderer start_fadebottom_y = clamp(start_fadebottom_y, 0, count); end_fadebottom_y = clamp(end_fadebottom_y, 0, count); + int skipped = thread->skipped_by_thread(_dest_y); + dest = thread->dest_for_thread(_dest_y, pitch, dest); + for (int col = 0; col < 4; col++) + { + frac[col] += fracstep[col] * skipped; + fracstep[col] *= thread->num_cores; + } + pitch *= thread->num_cores; + int num_cores = thread->num_cores; + int index = skipped; + // Top solid color: - for (int index = 0; index < start_fadetop_y; index++) + while (index < start_fadetop_y) { *((uint32_t*)dest) = solid_top_fill; dest += pitch; for (int col = 0; col < 4; col++) frac[col] += fracstep[col]; + index += num_cores; } // Top fade: - for (int index = start_fadetop_y; index < end_fadetop_y; index++) + while (index < end_fadetop_y) { for (int col = 0; col < 4; col++) { @@ -756,10 +778,11 @@ namespace swrenderer } *((uint32_t*)dest) = *((uint32_t*)output); dest += pitch; + index += num_cores; } // Textured center: - for (int index = end_fadetop_y; index < start_fadebottom_y; index++) + while (index < start_fadebottom_y) { for (int col = 0; col < 4; col++) { @@ -771,10 +794,11 @@ namespace swrenderer *((uint32_t*)dest) = *((uint32_t*)output); dest += pitch; + index += num_cores; } // Fade bottom: - for (int index = start_fadebottom_y; index < end_fadebottom_y; index++) + while (index < end_fadebottom_y) { for (int col = 0; col < 4; col++) { @@ -796,13 +820,15 @@ namespace swrenderer } *((uint32_t*)dest) = *((uint32_t*)output); dest += pitch; + index += num_cores; } // Bottom solid color: - for (int index = end_fadebottom_y; index < count; index++) + while (index < count) { *((uint32_t*)dest) = solid_bottom_fill; dest += pitch; + index += num_cores; } } @@ -828,6 +854,16 @@ namespace swrenderer int solid_bottom_g = GPART(solid_bottom); int solid_bottom_b = BPART(solid_bottom); + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int skipped = thread->skipped_by_thread(_dest_y); + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * skipped; + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + for (int index = 0; index < count; index++) { uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; @@ -913,17 +949,29 @@ namespace swrenderer start_fadebottom_y = clamp(start_fadebottom_y, 0, count); end_fadebottom_y = clamp(end_fadebottom_y, 0, count); + int skipped = thread->skipped_by_thread(_dest_y); + dest = thread->dest_for_thread(_dest_y, pitch, dest); + for (int col = 0; col < 4; col++) + { + frac[col] += fracstep[col] * skipped; + fracstep[col] *= thread->num_cores; + } + pitch *= thread->num_cores; + int num_cores = thread->num_cores; + int index = skipped; + // Top solid color: - for (int index = 0; index < start_fadetop_y; index++) + while (index < start_fadetop_y) { *((uint32_t*)dest) = solid_top_fill; dest += pitch; for (int col = 0; col < 4; col++) frac[col] += fracstep[col]; + index += num_cores; } // Top fade: - for (int index = start_fadetop_y; index < end_fadetop_y; index++) + while (index < end_fadetop_y) { for (int col = 0; col < 4; col++) { @@ -951,10 +999,11 @@ namespace swrenderer } *((uint32_t*)dest) = *((uint32_t*)output); dest += pitch; + index += num_cores; } // Textured center: - for (int index = end_fadetop_y; index < start_fadebottom_y; index++) + while (index < start_fadebottom_y) { for (int col = 0; col < 4; col++) { @@ -972,10 +1021,11 @@ namespace swrenderer *((uint32_t*)dest) = *((uint32_t*)output); dest += pitch; + index += num_cores; } // Fade bottom: - for (int index = start_fadebottom_y; index < end_fadebottom_y; index++) + while (index < end_fadebottom_y) { for (int col = 0; col < 4; col++) { @@ -1003,13 +1053,15 @@ namespace swrenderer } *((uint32_t*)dest) = *((uint32_t*)output); dest += pitch; + index += num_cores; } // Bottom solid color: - for (int index = end_fadebottom_y; index < count; index++) + while (index < count) { *((uint32_t*)dest) = solid_bottom_fill; dest += pitch; + index += num_cores; } } From 6122d982b7a024ff001e0ded93d6251834e43e28 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 5 Dec 2016 13:47:30 +0100 Subject: [PATCH 1353/1509] Thread awareness to column drawers --- src/r_draw_pal.cpp | 648 +++++++++++++++++++++++++-------------------- 1 file changed, 356 insertions(+), 292 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 84f9772b6..fbef5153e 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -1088,16 +1088,12 @@ namespace swrenderer void DrawColumnPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; fixed_t frac; fixed_t fracstep; count = _count; - // Zero length, column does not exceed a pixel. - if (count <= 0) - return; - // Framebuffer destination address. dest = _dest; @@ -1106,73 +1102,84 @@ namespace swrenderer fracstep = _iscale; frac = _texturefrac; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + + // [RH] Get local copies of these variables so that the compiler + // has a better chance of optimizing this well. + const uint8_t *colormap = _colormap; + const uint8_t *source = _source; + + // Inner loop that does the actual texture mapping, + // e.g. a DDA-lile scaling. + // This is as fast as it gets. + do { - // [RH] Get local copies of these variables so that the compiler - // has a better chance of optimizing this well. - const BYTE *colormap = _colormap; - const BYTE *source = _source; - int pitch = _pitch; + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + *dest = colormap[source[frac >> FRACBITS]]; - // Inner loop that does the actual texture mapping, - // e.g. a DDA-lile scaling. - // This is as fast as it gets. - do - { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - *dest = colormap[source[frac >> FRACBITS]]; + dest += pitch; + frac += fracstep; - dest += pitch; - frac += fracstep; - - } while (--count); - } + } while (--count); } void FillColumnPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; count = _count; + dest = _dest; + count = thread->count_for_thread(_dest_y, count); if (count <= 0) return; - dest = _dest; + int pitch = _pitch; + dest = thread->dest_for_thread(_dest_y, pitch, dest); + pitch *= thread->num_cores; + uint8_t color = _color; + do { - int pitch = _pitch; - BYTE color = _color; - - do - { - *dest = color; - dest += pitch; - } while (--count); - } + *dest = color; + dest += pitch; + } while (--count); } void FillColumnAddPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; count = _count; - if (count <= 0) - return; - dest = _dest; - DWORD *bg2rgb; - DWORD fg; + uint32_t *bg2rgb; + uint32_t fg; bg2rgb = _destblend; fg = _srccolor; int pitch = _pitch; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + dest = thread->dest_for_thread(_dest_y, pitch, dest); + pitch *= thread->num_cores; + do { - DWORD bg; + uint32_t bg; bg = (fg + bg2rgb[*dest]) | 0x1f07c1f; *dest = RGB32k.All[bg & (bg >> 15)]; dest += pitch; @@ -1183,24 +1190,29 @@ namespace swrenderer void FillColumnAddClampPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; count = _count; - if (count <= 0) - return; dest = _dest; - DWORD *bg2rgb; - DWORD fg; + uint32_t *bg2rgb; + uint32_t fg; bg2rgb = _destblend; fg = _srccolor; int pitch = _pitch; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + dest = thread->dest_for_thread(_dest_y, pitch, dest); + pitch *= thread->num_cores; + do { - DWORD a = fg + bg2rgb[*dest]; - DWORD b = a; + uint32_t a = fg + bg2rgb[*dest]; + uint32_t b = a; a |= 0x01f07c1f; b &= 0x40100400; @@ -1215,24 +1227,29 @@ namespace swrenderer void FillColumnSubClampPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; count = _count; - if (count <= 0) - return; dest = _dest; - DWORD *bg2rgb; - DWORD fg; + uint32_t *bg2rgb; + uint32_t fg; bg2rgb = _destblend; fg = _srccolor | 0x40100400; int pitch = _pitch; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + dest = thread->dest_for_thread(_dest_y, pitch, dest); + pitch *= thread->num_cores; + do { - DWORD a = fg - bg2rgb[*dest]; - DWORD b = a; + uint32_t a = fg - bg2rgb[*dest]; + uint32_t b = a; b &= 0x40100400; b = b - (b >> 5); @@ -1246,24 +1263,31 @@ namespace swrenderer void FillColumnRevSubClampPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; count = _count; if (count <= 0) return; dest = _dest; - DWORD *bg2rgb; - DWORD fg; + uint32_t *bg2rgb; + uint32_t fg; bg2rgb = _destblend; fg = _srccolor; int pitch = _pitch; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + dest = thread->dest_for_thread(_dest_y, pitch, dest); + pitch *= thread->num_cores; + do { - DWORD a = (bg2rgb[*dest] | 0x40100400) - fg; - DWORD b = a; + uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg; + uint32_t b = a; b &= 0x40100400; b = b - (b >> 5); @@ -1277,385 +1301,425 @@ namespace swrenderer void DrawColumnAddPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; fixed_t frac; fixed_t fracstep; count = _count; - if (count <= 0) - return; - dest = _dest; fracstep = _iscale; frac = _texturefrac; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + const uint8_t *colormap = _colormap; + const uint8_t *source = _source; + + do { - DWORD *fg2rgb = _srcblend; - DWORD *bg2rgb = _destblend; - const BYTE *colormap = _colormap; - const BYTE *source = _source; - int pitch = _pitch; + uint32_t fg = colormap[source[frac >> FRACBITS]]; + uint32_t bg = *dest; - do - { - DWORD fg = colormap[source[frac >> FRACBITS]]; - DWORD bg = *dest; - - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg >> 15)]; - dest += pitch; - frac += fracstep; - } while (--count); - } + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); } void DrawColumnTranslatedPalCommand::Execute(DrawerThread *thread) { int count; - BYTE* dest; + uint8_t* dest; fixed_t frac; fixed_t fracstep; count = _count; - if (count <= 0) - return; dest = _dest; fracstep = _iscale; frac = _texturefrac; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + + // [RH] Local copies of global vars to improve compiler optimizations + const uint8_t *colormap = _colormap; + const uint8_t *translation = _translation; + const uint8_t *source = _source; + + do { - // [RH] Local copies of global vars to improve compiler optimizations - const BYTE *colormap = _colormap; - const BYTE *translation = _translation; - const BYTE *source = _source; - int pitch = _pitch; + *dest = colormap[translation[source[frac >> FRACBITS]]]; + dest += pitch; - do - { - *dest = colormap[translation[source[frac >> FRACBITS]]]; - dest += pitch; - - frac += fracstep; - } while (--count); - } + frac += fracstep; + } while (--count); } void DrawColumnTlatedAddPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; fixed_t frac; fixed_t fracstep; count = _count; - if (count <= 0) - return; - dest = _dest; fracstep = _iscale; frac = _texturefrac; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + const uint8_t *translation = _translation; + const uint8_t *colormap = _colormap; + const uint8_t *source = _source; + + do { - DWORD *fg2rgb = _srcblend; - DWORD *bg2rgb = _destblend; - const BYTE *translation = _translation; - const BYTE *colormap = _colormap; - const BYTE *source = _source; - int pitch = _pitch; + uint32_t fg = colormap[translation[source[frac >> FRACBITS]]]; + uint32_t bg = *dest; - do - { - DWORD fg = colormap[translation[source[frac >> FRACBITS]]]; - DWORD bg = *dest; - - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg >> 15)]; - dest += pitch; - frac += fracstep; - } while (--count); - } + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); } void DrawColumnShadedPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; fixed_t frac, fracstep; count = _count; - - if (count <= 0) - return; - dest = _dest; fracstep = _iscale; frac = _texturefrac; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + + const uint8_t *source = _source; + const uint8_t *colormap = _colormap; + uint32_t *fgstart = &Col2RGB8[0][_color]; + + do { - const BYTE *source = _source; - const BYTE *colormap = _colormap; - int pitch = _pitch; - DWORD *fgstart = &Col2RGB8[0][_color]; + uint32_t val = colormap[source[frac >> FRACBITS]]; + uint32_t fg = fgstart[val << 8]; + val = (Col2RGB8[64 - val][*dest] + fg) | 0x1f07c1f; + *dest = RGB32k.All[val & (val >> 15)]; - do - { - DWORD val = colormap[source[frac >> FRACBITS]]; - DWORD fg = fgstart[val << 8]; - val = (Col2RGB8[64 - val][*dest] + fg) | 0x1f07c1f; - *dest = RGB32k.All[val & (val >> 15)]; - - dest += pitch; - frac += fracstep; - } while (--count); - } + dest += pitch; + frac += fracstep; + } while (--count); } void DrawColumnAddClampPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; fixed_t frac; fixed_t fracstep; count = _count; - if (count <= 0) - return; - dest = _dest; fracstep = _iscale; frac = _texturefrac; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + + const uint8_t *colormap = _colormap; + const uint8_t *source = _source; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + + do { - const BYTE *colormap = _colormap; - const BYTE *source = _source; - int pitch = _pitch; - DWORD *fg2rgb = _srcblend; - DWORD *bg2rgb = _destblend; + uint32_t a = fg2rgb[colormap[source[frac >> FRACBITS]]] + bg2rgb[*dest]; + uint32_t b = a; - do - { - DWORD a = fg2rgb[colormap[source[frac >> FRACBITS]]] + bg2rgb[*dest]; - DWORD b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[a & (a >> 15)]; - dest += pitch; - frac += fracstep; - } while (--count); - } + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); } void DrawColumnAddClampTranslatedPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; fixed_t frac; fixed_t fracstep; count = _count; - if (count <= 0) - return; - dest = _dest; fracstep = _iscale; frac = _texturefrac; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + + const uint8_t *translation = _translation; + const uint8_t *colormap = _colormap; + const uint8_t *source = _source; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + + do { - const BYTE *translation = _translation; - const BYTE *colormap = _colormap; - const BYTE *source = _source; - int pitch = _pitch; - DWORD *fg2rgb = _srcblend; - DWORD *bg2rgb = _destblend; + uint32_t a = fg2rgb[colormap[translation[source[frac >> FRACBITS]]]] + bg2rgb[*dest]; + uint32_t b = a; - do - { - DWORD a = fg2rgb[colormap[translation[source[frac >> FRACBITS]]]] + bg2rgb[*dest]; - DWORD b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[(a >> 15) & a]; - dest += pitch; - frac += fracstep; - } while (--count); - } + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[(a >> 15) & a]; + dest += pitch; + frac += fracstep; + } while (--count); } void DrawColumnSubClampPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; fixed_t frac; fixed_t fracstep; count = _count; - if (count <= 0) - return; - dest = _dest; fracstep = _iscale; frac = _texturefrac; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + + const uint8_t *colormap = _colormap; + const uint8_t *source = _source; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + + do { - const BYTE *colormap = _colormap; - const BYTE *source = _source; - int pitch = _pitch; - DWORD *fg2rgb = _srcblend; - DWORD *bg2rgb = _destblend; + uint32_t a = (fg2rgb[colormap[source[frac >> FRACBITS]]] | 0x40100400) - bg2rgb[*dest]; + uint32_t b = a; - do - { - DWORD a = (fg2rgb[colormap[source[frac >> FRACBITS]]] | 0x40100400) - bg2rgb[*dest]; - DWORD b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a >> 15)]; - dest += pitch; - frac += fracstep; - } while (--count); - } + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); } void DrawColumnSubClampTranslatedPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; fixed_t frac; fixed_t fracstep; count = _count; - if (count <= 0) - return; - dest = _dest; fracstep = _iscale; frac = _texturefrac; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + + const uint8_t *translation = _translation; + const uint8_t *colormap = _colormap; + const uint8_t *source = _source; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + + do { - const BYTE *translation = _translation; - const BYTE *colormap = _colormap; - const BYTE *source = _source; - int pitch = _pitch; - DWORD *fg2rgb = _srcblend; - DWORD *bg2rgb = _destblend; + uint32_t a = (fg2rgb[colormap[translation[source[frac >> FRACBITS]]]] | 0x40100400) - bg2rgb[*dest]; + uint32_t b = a; - do - { - DWORD a = (fg2rgb[colormap[translation[source[frac >> FRACBITS]]]] | 0x40100400) - bg2rgb[*dest]; - DWORD b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[(a >> 15) & a]; - dest += pitch; - frac += fracstep; - } while (--count); - } + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[(a >> 15) & a]; + dest += pitch; + frac += fracstep; + } while (--count); } void DrawColumnRevSubClampPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; fixed_t frac; fixed_t fracstep; count = _count; - if (count <= 0) - return; - dest = _dest; fracstep = _iscale; frac = _texturefrac; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + + const uint8_t *colormap = _colormap; + const uint8_t *source = _source; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + + do { - const BYTE *colormap = _colormap; - const BYTE *source = _source; - int pitch = _pitch; - DWORD *fg2rgb = _srcblend; - DWORD *bg2rgb = _destblend; + uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[source[frac >> FRACBITS]]]; + uint32_t b = a; - do - { - DWORD a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[source[frac >> FRACBITS]]]; - DWORD b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a >> 15)]; - dest += pitch; - frac += fracstep; - } while (--count); - } + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); } void DrawColumnRevSubClampTranslatedPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; fixed_t frac; fixed_t fracstep; count = _count; - if (count <= 0) - return; - dest = _dest; fracstep = _iscale; frac = _texturefrac; + count = thread->count_for_thread(_dest_y, count); + if (count <= 0) + return; + + int pitch = _pitch; + dest = thread->dest_for_thread(_dest_y, pitch, dest); + frac += fracstep * thread->skipped_by_thread(_dest_y); + fracstep *= thread->num_cores; + pitch *= thread->num_cores; + + const uint8_t *translation = _translation; + const uint8_t *colormap = _colormap; + const uint8_t *source = _source; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + + do { - const BYTE *translation = _translation; - const BYTE *colormap = _colormap; - const BYTE *source = _source; - int pitch = _pitch; - DWORD *fg2rgb = _srcblend; - DWORD *bg2rgb = _destblend; + uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[translation[source[frac >> FRACBITS]]]]; + uint32_t b = a; - do - { - DWORD a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[translation[source[frac >> FRACBITS]]]]; - DWORD b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[(a >> 15) & a]; - dest += pitch; - frac += fracstep; - } while (--count); - } + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[(a >> 15) & a]; + dest += pitch; + frac += fracstep; + } while (--count); } ///////////////////////////////////////////////////////////////////////// @@ -1674,7 +1738,7 @@ namespace swrenderer void DrawFuzzColumnPalCommand::Execute(DrawerThread *thread) { int count; - BYTE *dest; + uint8_t *dest; // Adjust borders. Low... if (_yl == 0) @@ -1701,7 +1765,7 @@ namespace swrenderer int pitch = _pitch; int fuzz = fuzzpos; int cnt; - BYTE *map = &NormalLight.Maps[6 * 256]; + uint8_t *map = &NormalLight.Maps[6 * 256]; // [RH] Split this into three separate loops to minimize // the number of times fuzzpos needs to be clamped. @@ -1767,7 +1831,7 @@ namespace swrenderer void DrawSpanPalCommand::Execute(DrawerThread *thread) { - if (thread->skipped_by_thread(_dest_y)) + if (thread->skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1831,7 +1895,7 @@ namespace swrenderer void DrawSpanMaskedPalCommand::Execute(DrawerThread *thread) { - if (thread->skipped_by_thread(_dest_y)) + if (thread->skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1896,7 +1960,7 @@ namespace swrenderer void DrawSpanTranslucentPalCommand::Execute(DrawerThread *thread) { - if (thread->skipped_by_thread(_dest_y)) + if (thread->skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1959,7 +2023,7 @@ namespace swrenderer void DrawSpanMaskedTranslucentPalCommand::Execute(DrawerThread *thread) { - if (thread->skipped_by_thread(_dest_y)) + if (thread->skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -2036,7 +2100,7 @@ namespace swrenderer void DrawSpanAddClampPalCommand::Execute(DrawerThread *thread) { - if (thread->skipped_by_thread(_dest_y)) + if (thread->skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -2105,7 +2169,7 @@ namespace swrenderer void DrawSpanMaskedAddClampPalCommand::Execute(DrawerThread *thread) { - if (thread->skipped_by_thread(_dest_y)) + if (thread->skipped_by_thread(_y)) return; dsfixed_t xfrac; From caa0deec105c085532650776ed3ea7f226a9971c Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 5 Dec 2016 16:05:33 -0500 Subject: [PATCH 1354/1509] - r_polyrenderer now notifies the gamesim on change of new pitch limits. --- src/r_swrenderer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 0c4925454..a0f90f5cc 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -56,6 +56,12 @@ CUSTOM_CVAR(Bool, r_polyrenderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOI { Printf("No GL BSP detected. You must restart the map before rendering will be correct\n"); } + + if (usergame) + { + // [SP] Update pitch limits to the netgame/gamesim. + players[consoleplayer].SendPitchLimits(); + } } namespace swrenderer From c53a20aea601b40fef9623b7b83d7125f8894f84 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 5 Dec 2016 16:08:31 -0500 Subject: [PATCH 1355/1509] - Notify gamesim of maxviewpitch change. --- src/gl/data/gl_data.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index ad9c824bb..6dcdd3a54 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -62,6 +62,11 @@ CUSTOM_CVAR(Float, maxviewpitch, 90.f, CVAR_ARCHIVE|CVAR_SERVERINFO) { if (self>90.f) self=90.f; else if (self<-90.f) self=-90.f; + if (usergame) + { + // [SP] Update pitch limits to the netgame/gamesim. + players[consoleplayer].SendPitchLimits(); + } } CUSTOM_CVAR(Bool, gl_notexturefill, false, 0) From 824705eacafa975af9b5ebc3a8c42e63ce3f0680 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 5 Dec 2016 16:22:46 -0500 Subject: [PATCH 1356/1509] - Fixed compile errors with maxviewpitch update --- src/gl/data/gl_data.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 6dcdd3a54..37d348bd8 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -39,6 +39,8 @@ #include "w_wad.h" #include "gi.h" #include "g_level.h" +#include "doomstat.h" +#include "d_player.h" #include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" From bd8b05e10ac90dcffe6d85879230a6dd7fb1480a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 6 Dec 2016 05:07:37 +0100 Subject: [PATCH 1357/1509] Fix compile error --- src/r_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index 1e314f127..a8c766099 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -117,7 +117,7 @@ static void R_ShutdownRenderer(); extern short *openings; extern bool r_fakingunderwater; -extern "C" int fuzzviewheight; +extern int fuzzviewheight; extern subsector_t *InSubsector; From f4172782ed9eaeebe7169fc74dd03b188959e8cf Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 6 Dec 2016 06:22:58 +0100 Subject: [PATCH 1358/1509] Fix compile error in debug builds --- src/r_thread.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/r_thread.h b/src/r_thread.h index 29d971ad3..1e48ff307 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -54,11 +54,11 @@ public: int pass_start_y = 0; int pass_end_y = MAXHEIGHT; - uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT * 4]; - uint32_t *dc_temp_rgba; + uint8_t dc_temp_buff[MAXHEIGHT * 4]; + uint8_t *dc_temp = nullptr; - short triangle_clip_top[MAXWIDTH]; - short triangle_clip_bottom[MAXWIDTH]; + uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT * 4]; + uint32_t *dc_temp_rgba = nullptr; // Checks if a line is rendered by this thread bool line_skipped_by_thread(int line) @@ -100,7 +100,7 @@ protected: void DetectRangeError(uint32_t *&dest, int &dest_y, int &count) { #if defined(_MSC_VER) && defined(_DEBUG) - if (dest_y < 0 || count < 0 || dest_y + count > swrenderer::dc_destheight) + if (dest_y < 0 || count < 0 || dest_y + count > swrenderer::drawerargs::dc_destheight) __debugbreak(); // Buffer overrun detected! #endif From 6a3ae2ce45294a7f5440acdca8726c23de3cf663 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 6 Dec 2016 07:23:55 +0100 Subject: [PATCH 1359/1509] Add Rt drawers --- src/r_draw_pal.h | 66 +++- src/r_draw_tc.cpp | 91 ++++- src/r_drawt_pal.cpp | 801 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 904 insertions(+), 54 deletions(-) diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index f1297a06b..f3b220f82 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -202,43 +202,85 @@ namespace swrenderer void Execute(DrawerThread *thread) override; }; - //class RtInitColsPalCommand : public DrawerCommand { public: void Execute(DrawerThread *thread) override; }; - //class DrawColumnHorizPalCommand : public DrawerCommand { public: void Execute(DrawerThread *thread) override; }; - class FillColumnHorizPalCommand : public DrawerCommand + class RtInitColsPalCommand : public DrawerCommand + { + public: + RtInitColsPalCommand(uint8_t *buff); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override { return "RtInitColsPalCommand"; } + + private: + uint8_t *buff; + }; + + class PalColumnHorizCommand : public DrawerCommand + { + public: + PalColumnHorizCommand(); + + protected: + const uint8_t *_source; + fixed_t _iscale; + fixed_t _texturefrac; + int _count; + int _color; + int _x; + int _yl; + }; + + class DrawColumnHorizPalCommand : public PalColumnHorizCommand { public: void Execute(DrawerThread *thread) override; FString DebugInfo() override { return "FillColumnHorizPalCommand"; } }; - + + class FillColumnHorizPalCommand : public PalColumnHorizCommand + { + public: + void Execute(DrawerThread *thread) override; + FString DebugInfo() override { return "FillColumnHorizPalCommand"; } + }; + class PalRtCommand : public DrawerCommand { public: PalRtCommand(int hx, int sx, int yl, int yh); FString DebugInfo() override { return "PalRtCommand"; } + + protected: + int hx, sx, yl, yh; + uint8_t *_destorg; + int _pitch; + const uint8_t *_colormap; + const uint32_t *_srcblend; + const uint32_t *_destblend; + const uint8_t *_translation; + int _color; }; class DrawColumnRt1CopyPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + class DrawColumnRt4CopyPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; class DrawColumnRt1PalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; class DrawColumnRt4PalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; class DrawColumnRt1TranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; class DrawColumnRt4TranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; class DrawColumnRt1AddPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; class DrawColumnRt4AddPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt1AddTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt4AddTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + //class DrawColumnRt1AddTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + //class DrawColumnRt4AddTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; class DrawColumnRt1ShadedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; class DrawColumnRt4ShadedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; class DrawColumnRt1AddClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; class DrawColumnRt4AddClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt1AddClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt4AddClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + //class DrawColumnRt1AddClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + //class DrawColumnRt4AddClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; class DrawColumnRt1SubClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; class DrawColumnRt4SubClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt1SubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt4SubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + //class DrawColumnRt1SubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + //class DrawColumnRt4SubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; class DrawColumnRt1RevSubClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; class DrawColumnRt4RevSubClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt1RevSubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt4RevSubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + //class DrawColumnRt1RevSubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; + //class DrawColumnRt4RevSubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; } diff --git a/src/r_draw_tc.cpp b/src/r_draw_tc.cpp index 2326cab91..77d450006 100644 --- a/src/r_draw_tc.cpp +++ b/src/r_draw_tc.cpp @@ -622,7 +622,10 @@ namespace swrenderer for (int y = 3; y >= 0; y--) horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0]; - DrawerCommandQueue::QueueCommand(buffer); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(buffer); + else + DrawerCommandQueue::QueueCommand(buffer); } void rt_span_coverage(int x, int start, int stop) @@ -861,10 +864,17 @@ namespace swrenderer (*span)[1] = dc_yh; *span += 2; - if (drawer_needs_pal_input || !r_swtruecolor) - DrawerCommandQueue::QueueCommand>(); + if (r_swtruecolor) + { + if (drawer_needs_pal_input) + DrawerCommandQueue::QueueCommand>(); + else + DrawerCommandQueue::QueueCommand>(); + } else - DrawerCommandQueue::QueueCommand>(); + { + DrawerCommandQueue::QueueCommand(); + } } // Copies one span at hx to the screen at sx. @@ -879,11 +889,18 @@ namespace swrenderer // Copies all four spans to the screen starting at sx. void rt_copy4cols(int sx, int yl, int yh) { - // To do: we could do this with SSE using __m128i - rt_copy1col(0, sx, yl, yh); - rt_copy1col(1, sx + 1, yl, yh); - rt_copy1col(2, sx + 2, yl, yh); - rt_copy1col(3, sx + 3, yl, yh); + if (r_swtruecolor) + { + // To do: we could do this with SSE using __m128i + rt_copy1col(0, sx, yl, yh); + rt_copy1col(1, sx + 1, yl, yh); + rt_copy1col(2, sx + 2, yl, yh); + rt_copy1col(3, sx + 3, yl, yh); + } + else + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } } // Maps one span at hx to the screen at sx. @@ -944,18 +961,28 @@ namespace swrenderer void rt_tlateadd1col(int hx, int sx, int yl, int yh) { if (r_swtruecolor) + { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + rt_add1col(hx, sx, yl, yh); + } } // Translates and adds all four spans to the screen starting at sx without clamping. void rt_tlateadd4cols(int sx, int yl, int yh) { if (r_swtruecolor) + { DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + rt_add4cols(sx, yl, yh); + } } // Shades one span at hx to the screen at sx. @@ -998,18 +1025,28 @@ namespace swrenderer void rt_tlateaddclamp1col(int hx, int sx, int yl, int yh) { if (r_swtruecolor) + { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + rt_addclamp1col(hx, sx, yl, yh); + } } // Translates and adds all four spans to the screen starting at sx with clamping. void rt_tlateaddclamp4cols(int sx, int yl, int yh) { if (r_swtruecolor) + { DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + rt_addclamp4cols(sx, yl, yh); + } } // Subtracts one span at hx to the screen at sx with clamping. @@ -1034,18 +1071,28 @@ namespace swrenderer void rt_tlatesubclamp1col(int hx, int sx, int yl, int yh) { if (r_swtruecolor) + { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + rt_subclamp1col(hx, sx, yl, yh); + } } // Translates and subtracts all four spans to the screen starting at sx with clamping. void rt_tlatesubclamp4cols(int sx, int yl, int yh) { if (r_swtruecolor) + { DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + rt_subclamp4cols(sx, yl, yh); + } } // Subtracts one span at hx from the screen at sx with clamping. @@ -1070,18 +1117,28 @@ namespace swrenderer void rt_tlaterevsubclamp1col(int hx, int sx, int yl, int yh) { if (r_swtruecolor) + { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + rt_revsubclamp1col(hx, sx, yl, yh); + } } // Translates and subtracts all four spans from the screen starting at sx with clamping. void rt_tlaterevsubclamp4cols(int sx, int yl, int yh) { if (r_swtruecolor) + { DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + rt_revsubclamp4cols(sx, yl, yh); + } } uint32_t vlinec1() diff --git a/src/r_drawt_pal.cpp b/src/r_drawt_pal.cpp index b35046285..b9f0c378d 100644 --- a/src/r_drawt_pal.cpp +++ b/src/r_drawt_pal.cpp @@ -1,3 +1,42 @@ +/* +** r_drawt.cpp +** Faster column drawers for modern processors +** +**--------------------------------------------------------------------------- +** Copyright 1998-2006 Randy Heit +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** These functions stretch columns into a temporary buffer and then +** map them to the screen. On modern machines, this is faster than drawing +** them directly to the screen. +** +** Will I be able to even understand any of this if I come back to it later? +** Let's hope so. :-) +*/ #include "templates.h" #include "doomtype.h" @@ -9,105 +48,817 @@ #include "v_video.h" #include "r_draw_pal.h" +// I should have commented this stuff better. +// +// dc_temp is the buffer R_DrawColumnHoriz writes into. +// dc_tspans points into it. +// dc_ctspan points into dc_tspans. +// horizspan also points into dc_tspans. + +// dc_ctspan is advanced while drawing into dc_temp. +// horizspan is advanced up to dc_ctspan when drawing from dc_temp to the screen. + namespace swrenderer { - PalRtCommand::PalRtCommand(int hx, int sx, int yl, int yh) + RtInitColsPalCommand::RtInitColsPalCommand(uint8_t *buff) : buff(buff) { } + void RtInitColsPalCommand::Execute(DrawerThread *thread) + { + thread->dc_temp = buff == nullptr ? thread->dc_temp_buff : buff; + } + + ///////////////////////////////////////////////////////////////////// + + PalColumnHorizCommand::PalColumnHorizCommand() + { + using namespace drawerargs; + + _source = dc_source; + _iscale = dc_iscale; + _texturefrac = dc_texturefrac; + _count = dc_count; + _color = dc_color; + _x = dc_x; + _yl = dc_yl; + } + + void DrawColumnHorizPalCommand::Execute(DrawerThread *thread) + { + int count = _count; + uint8_t *dest; + fixed_t fracstep; + fixed_t frac; + + if (count <= 0) + return; + + { + int x = _x & 3; + dest = &thread->dc_temp[x + 4 * _yl]; + } + fracstep = _iscale; + frac = _texturefrac; + + const uint8_t *source = _source; + + if (count & 1) { + *dest = source[frac >> FRACBITS]; dest += 4; frac += fracstep; + } + if (count & 2) { + dest[0] = source[frac >> FRACBITS]; frac += fracstep; + dest[4] = source[frac >> FRACBITS]; frac += fracstep; + dest += 8; + } + if (count & 4) { + dest[0] = source[frac >> FRACBITS]; frac += fracstep; + dest[4] = source[frac >> FRACBITS]; frac += fracstep; + dest[8] = source[frac >> FRACBITS]; frac += fracstep; + dest[12] = source[frac >> FRACBITS]; frac += fracstep; + dest += 16; + } + count >>= 3; + if (!count) return; + + do + { + dest[0] = source[frac >> FRACBITS]; frac += fracstep; + dest[4] = source[frac >> FRACBITS]; frac += fracstep; + dest[8] = source[frac >> FRACBITS]; frac += fracstep; + dest[12] = source[frac >> FRACBITS]; frac += fracstep; + dest[16] = source[frac >> FRACBITS]; frac += fracstep; + dest[20] = source[frac >> FRACBITS]; frac += fracstep; + dest[24] = source[frac >> FRACBITS]; frac += fracstep; + dest[28] = source[frac >> FRACBITS]; frac += fracstep; + dest += 32; + } while (--count); + } + void FillColumnHorizPalCommand::Execute(DrawerThread *thread) { + int count = _count; + uint8_t color = _color; + uint8_t *dest; + + if (count <= 0) + return; + + { + int x = _x & 3; + dest = &thread->dc_temp[x + 4 * _yl]; + } + + if (count & 1) { + *dest = color; + dest += 4; + } + if (!(count >>= 1)) + return; + do { + dest[0] = color; dest[4] = color; + dest += 8; + } while (--count); + } + + ///////////////////////////////////////////////////////////////////// + + PalRtCommand::PalRtCommand(int hx, int sx, int yl, int yh) : hx(hx), sx(sx), yl(yl), yh(yh) + { + using namespace drawerargs; + + _destorg = dc_destorg; + _pitch = dc_pitch; + _colormap = dc_colormap; + _srcblend = dc_srcblend; + _destblend = dc_destblend; + _translation = dc_translation; + _color = dc_color; } void DrawColumnRt1CopyPalCommand::Execute(DrawerThread *thread) { + uint8_t *source; + uint8_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + dest = ylookup[yl] + sx + _destorg; + source = &thread->dc_temp[yl*4 + hx]; + pitch = _pitch; + + if (count & 1) { + *dest = *source; + source += 4; + dest += pitch; + } + if (count & 2) { + dest[0] = source[0]; + dest[pitch] = source[4]; + source += 8; + dest += pitch*2; + } + if (!(count >>= 2)) + return; + + do { + dest[0] = source[0]; + dest[pitch] = source[4]; + dest[pitch*2] = source[8]; + dest[pitch*3] = source[12]; + source += 16; + dest += pitch*4; + } while (--count); + } + + void DrawColumnRt4CopyPalCommand::Execute(DrawerThread *thread) + { + int *source; + int *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + dest = (int *)(ylookup[yl] + sx + _destorg); + source = (int *)(&thread->dc_temp[yl*4]); + pitch = _pitch/sizeof(int); + + if (count & 1) { + *dest = *source; + source += 4/sizeof(int); + dest += pitch; + } + if (!(count >>= 1)) + return; + + do { + dest[0] = source[0]; + dest[pitch] = source[4/sizeof(int)]; + source += 8/sizeof(int); + dest += pitch*2; + } while (--count); } void DrawColumnRt1PalCommand::Execute(DrawerThread *thread) { + const uint8_t *colormap; + uint8_t *source; + uint8_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + colormap = _colormap; + dest = ylookup[yl] + sx + _destorg; + source = &thread->dc_temp[yl*4 + hx]; + pitch = _pitch; + + if (count & 1) { + *dest = colormap[*source]; + source += 4; + dest += pitch; + } + if (!(count >>= 1)) + return; + + do { + dest[0] = colormap[source[0]]; + dest[pitch] = colormap[source[4]]; + source += 8; + dest += pitch*2; + } while (--count); } void DrawColumnRt4PalCommand::Execute(DrawerThread *thread) { + const uint8_t *colormap; + uint8_t *source; + uint8_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + colormap = _colormap; + dest = ylookup[yl] + sx + _destorg; + source = &thread->dc_temp[yl*4]; + pitch = _pitch; + + if (count & 1) { + dest[0] = colormap[source[0]]; + dest[1] = colormap[source[1]]; + dest[2] = colormap[source[2]]; + dest[3] = colormap[source[3]]; + source += 4; + dest += pitch; + } + if (!(count >>= 1)) + return; + + do { + dest[0] = colormap[source[0]]; + dest[1] = colormap[source[1]]; + dest[2] = colormap[source[2]]; + dest[3] = colormap[source[3]]; + dest[pitch] = colormap[source[4]]; + dest[pitch+1] = colormap[source[5]]; + dest[pitch+2] = colormap[source[6]]; + dest[pitch+3] = colormap[source[7]]; + source += 8; + dest += pitch*2; + } while (--count); } void DrawColumnRt1TranslatedPalCommand::Execute(DrawerThread *thread) { + int count = yh - yl + 1; + uint8_t *source = &thread->dc_temp[yl*4 + hx]; + const uint8_t *translation = _translation; + + // Things we do to hit the compiler's optimizer with a clue bat: + // 1. Parallelism is explicitly spelled out by using a separate + // C instruction for each assembly instruction. GCC lets me + // have four temporaries, but VC++ spills to the stack with + // more than two. Two is probably optimal, anyway. + // 2. The results of the translation lookups are explicitly + // stored in byte-sized variables. This causes the VC++ code + // to use byte mov instructions in most cases; for apparently + // random reasons, it will use movzx for some places. GCC + // ignores this and uses movzx always. + + // Do 8 rows at a time. + for (int count8 = count >> 3; count8; --count8) + { + int c0, c1; + uint8_t b0, b1; + + c0 = source[0]; c1 = source[4]; + b0 = translation[c0]; b1 = translation[c1]; + source[0] = b0; source[4] = b1; + + c0 = source[8]; c1 = source[12]; + b0 = translation[c0]; b1 = translation[c1]; + source[8] = b0; source[12] = b1; + + c0 = source[16]; c1 = source[20]; + b0 = translation[c0]; b1 = translation[c1]; + source[16] = b0; source[20] = b1; + + c0 = source[24]; c1 = source[28]; + b0 = translation[c0]; b1 = translation[c1]; + source[24] = b0; source[28] = b1; + + source += 32; + } + // Finish by doing 1 row at a time. + for (count &= 7; count; --count, source += 4) + { + source[0] = translation[source[0]]; + } } void DrawColumnRt4TranslatedPalCommand::Execute(DrawerThread *thread) { + int count = yh - yl + 1; + uint8_t *source = &thread->dc_temp[yl*4]; + const uint8_t *translation = _translation; + int c0, c1; + uint8_t b0, b1; + + // Do 2 rows at a time. + for (int count8 = count >> 1; count8; --count8) + { + c0 = source[0]; c1 = source[1]; + b0 = translation[c0]; b1 = translation[c1]; + source[0] = b0; source[1] = b1; + + c0 = source[2]; c1 = source[3]; + b0 = translation[c0]; b1 = translation[c1]; + source[2] = b0; source[3] = b1; + + c0 = source[4]; c1 = source[5]; + b0 = translation[c0]; b1 = translation[c1]; + source[4] = b0; source[5] = b1; + + c0 = source[6]; c1 = source[7]; + b0 = translation[c0]; b1 = translation[c1]; + source[6] = b0; source[7] = b1; + + source += 8; + } + // Do the final row if count was odd. + if (count & 1) + { + c0 = source[0]; c1 = source[1]; + b0 = translation[c0]; b1 = translation[c1]; + source[0] = b0; source[1] = b1; + + c0 = source[2]; c1 = source[3]; + b0 = translation[c0]; b1 = translation[c1]; + source[2] = b0; source[3] = b1; + } } void DrawColumnRt1AddPalCommand::Execute(DrawerThread *thread) { + const uint8_t *colormap; + uint8_t *source; + uint8_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + const uint32_t *fg2rgb = _srcblend; + const uint32_t *bg2rgb = _destblend; + dest = ylookup[yl] + sx + _destorg; + source = &thread->dc_temp[yl*4 + hx]; + pitch = _pitch; + colormap = _colormap; + + do { + uint32_t fg = colormap[*source]; + uint32_t bg = *dest; + + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg+bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg>>15)]; + source += 4; + dest += pitch; + } while (--count); } void DrawColumnRt4AddPalCommand::Execute(DrawerThread *thread) { - } + const uint8_t *colormap; + uint8_t *source; + uint8_t *dest; + int count; + int pitch; - void DrawColumnRt1AddTranslatedPalCommand::Execute(DrawerThread *thread) - { - } + count = yh-yl; + if (count < 0) + return; + count++; - void DrawColumnRt4AddTranslatedPalCommand::Execute(DrawerThread *thread) - { + const uint32_t *fg2rgb = _srcblend; + const uint32_t *bg2rgb = _destblend; + dest = ylookup[yl] + sx + _destorg; + source = &thread->dc_temp[yl*4]; + pitch = _pitch; + colormap = _colormap; + + do { + uint32_t fg = colormap[source[0]]; + uint32_t bg = dest[0]; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg+bg) | 0x1f07c1f; + dest[0] = RGB32k.All[fg & (fg>>15)]; + + fg = colormap[source[1]]; + bg = dest[1]; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg+bg) | 0x1f07c1f; + dest[1] = RGB32k.All[fg & (fg>>15)]; + + + fg = colormap[source[2]]; + bg = dest[2]; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg+bg) | 0x1f07c1f; + dest[2] = RGB32k.All[fg & (fg>>15)]; + + fg = colormap[source[3]]; + bg = dest[3]; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg+bg) | 0x1f07c1f; + dest[3] = RGB32k.All[fg & (fg>>15)]; + + source += 4; + dest += pitch; + } while (--count); } void DrawColumnRt1ShadedPalCommand::Execute(DrawerThread *thread) { + uint32_t *fgstart; + const uint8_t *colormap; + uint8_t *source; + uint8_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + fgstart = &Col2RGB8[0][_color]; + colormap = _colormap; + dest = ylookup[yl] + sx + _destorg; + source = &thread->dc_temp[yl*4 + hx]; + pitch = _pitch; + + do { + uint32_t val = colormap[*source]; + uint32_t fg = fgstart[val<<8]; + val = (Col2RGB8[64-val][*dest] + fg) | 0x1f07c1f; + *dest = RGB32k.All[val & (val>>15)]; + source += 4; + dest += pitch; + } while (--count); } void DrawColumnRt4ShadedPalCommand::Execute(DrawerThread *thread) { + uint32_t *fgstart; + const uint8_t *colormap; + uint8_t *source; + uint8_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + fgstart = &Col2RGB8[0][_color]; + colormap = _colormap; + dest = ylookup[yl] + sx + _destorg; + source = &thread->dc_temp[yl*4]; + pitch = _pitch; + + do { + uint32_t val; + + val = colormap[source[0]]; + val = (Col2RGB8[64-val][dest[0]] + fgstart[val<<8]) | 0x1f07c1f; + dest[0] = RGB32k.All[val & (val>>15)]; + + val = colormap[source[1]]; + val = (Col2RGB8[64-val][dest[1]] + fgstart[val<<8]) | 0x1f07c1f; + dest[1] = RGB32k.All[val & (val>>15)]; + + val = colormap[source[2]]; + val = (Col2RGB8[64-val][dest[2]] + fgstart[val<<8]) | 0x1f07c1f; + dest[2] = RGB32k.All[val & (val>>15)]; + + val = colormap[source[3]]; + val = (Col2RGB8[64-val][dest[3]] + fgstart[val<<8]) | 0x1f07c1f; + dest[3] = RGB32k.All[val & (val>>15)]; + + source += 4; + dest += pitch; + } while (--count); } void DrawColumnRt1AddClampPalCommand::Execute(DrawerThread *thread) { + const uint8_t *colormap; + uint8_t *source; + uint8_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + const uint32_t *fg2rgb = _srcblend; + const uint32_t *bg2rgb = _destblend; + dest = ylookup[yl] + sx + _destorg; + source = &thread->dc_temp[yl*4 + hx]; + pitch = _pitch; + colormap = _colormap; + + do { + uint32_t a = fg2rgb[colormap[*source]] + bg2rgb[*dest]; + uint32_t b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[(a>>15) & a]; + source += 4; + dest += pitch; + } while (--count); } void DrawColumnRt4AddClampPalCommand::Execute(DrawerThread *thread) { - } + const uint8_t *colormap; + uint8_t *source; + uint8_t *dest; + int count; + int pitch; - void DrawColumnRt1AddClampTranslatedPalCommand::Execute(DrawerThread *thread) - { - } + count = yh-yl; + if (count < 0) + return; + count++; - void DrawColumnRt4AddClampTranslatedPalCommand::Execute(DrawerThread *thread) - { + dest = ylookup[yl] + sx + _destorg; + source = &thread->dc_temp[yl*4]; + pitch = _pitch; + colormap = _colormap; + + const uint32_t *fg2rgb = _srcblend; + const uint32_t *bg2rgb = _destblend; + + do { + uint32_t a = fg2rgb[colormap[source[0]]] + bg2rgb[dest[0]]; + uint32_t b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + dest[0] = RGB32k.All[(a>>15) & a]; + + a = fg2rgb[colormap[source[1]]] + bg2rgb[dest[1]]; + b = a; + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + dest[1] = RGB32k.All[(a>>15) & a]; + + a = fg2rgb[colormap[source[2]]] + bg2rgb[dest[2]]; + b = a; + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + dest[2] = RGB32k.All[(a>>15) & a]; + + a = fg2rgb[colormap[source[3]]] + bg2rgb[dest[3]]; + b = a; + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + dest[3] = RGB32k.All[(a>>15) & a]; + + source += 4; + dest += pitch; + } while (--count); } void DrawColumnRt1SubClampPalCommand::Execute(DrawerThread *thread) { + const uint8_t *colormap; + uint8_t *source; + uint8_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + const uint32_t *fg2rgb = _srcblend; + const uint32_t *bg2rgb = _destblend; + dest = ylookup[yl] + sx + _destorg; + source = &thread->dc_temp[yl*4 + hx]; + pitch = _pitch; + colormap = _colormap; + + do { + uint32_t a = (fg2rgb[colormap[*source]] | 0x40100400) - bg2rgb[*dest]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[(a>>15) & a]; + source += 4; + dest += pitch; + } while (--count); } void DrawColumnRt4SubClampPalCommand::Execute(DrawerThread *thread) { - } + const uint8_t *colormap; + uint8_t *source; + uint8_t *dest; + int count; + int pitch; - void DrawColumnRt1SubClampTranslatedPalCommand::Execute(DrawerThread *thread) - { - } + count = yh-yl; + if (count < 0) + return; + count++; - void DrawColumnRt4SubClampTranslatedPalCommand::Execute(DrawerThread *thread) - { + const uint32_t *fg2rgb = _srcblend; + const uint32_t *bg2rgb = _destblend; + dest = ylookup[yl] + sx + _destorg; + source = &thread->dc_temp[yl*4]; + pitch = _pitch; + colormap = _colormap; + + do { + uint32_t a = (fg2rgb[colormap[source[0]]] | 0x40100400) - bg2rgb[dest[0]]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[0] = RGB32k.All[(a>>15) & a]; + + a = (fg2rgb[colormap[source[1]]] | 0x40100400) - bg2rgb[dest[1]]; + b = a; + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[1] = RGB32k.All[(a>>15) & a]; + + a = (fg2rgb[colormap[source[2]]] | 0x40100400) - bg2rgb[dest[2]]; + b = a; + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[2] = RGB32k.All[(a>>15) & a]; + + a = (fg2rgb[colormap[source[3]]] | 0x40100400) - bg2rgb[dest[3]]; + b = a; + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[3] = RGB32k.All[(a>>15) & a]; + + source += 4; + dest += pitch; + } while (--count); } void DrawColumnRt1RevSubClampPalCommand::Execute(DrawerThread *thread) { + const uint8_t *colormap; + uint8_t *source; + uint8_t *dest; + int count; + int pitch; + + count = yh-yl; + if (count < 0) + return; + count++; + + const uint32_t *fg2rgb = _srcblend; + const uint32_t *bg2rgb = _destblend; + dest = ylookup[yl] + sx + _destorg; + source = &thread->dc_temp[yl*4 + hx]; + pitch = _pitch; + colormap = _colormap; + + do { + uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[*source]]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[(a>>15) & a]; + source += 4; + dest += pitch; + } while (--count); } void DrawColumnRt4RevSubClampPalCommand::Execute(DrawerThread *thread) { - } + const uint8_t *colormap; + uint8_t *source; + uint8_t *dest; + int count; + int pitch; - void DrawColumnRt1RevSubClampTranslatedPalCommand::Execute(DrawerThread *thread) - { - } + count = yh-yl; + if (count < 0) + return; + count++; - void DrawColumnRt4RevSubClampTranslatedPalCommand::Execute(DrawerThread *thread) - { + const uint32_t *fg2rgb = _srcblend; + const uint32_t *bg2rgb = _destblend; + dest = ylookup[yl] + sx + _destorg; + source = &thread->dc_temp[yl*4]; + pitch = _pitch; + colormap = _colormap; + + do { + uint32_t a = (bg2rgb[dest[0]] | 0x40100400) - fg2rgb[colormap[source[0]]]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[0] = RGB32k.All[(a>>15) & a]; + + a = (bg2rgb[dest[1]] | 0x40100400) - fg2rgb[colormap[source[1]]]; + b = a; + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[1] = RGB32k.All[(a>>15) & a]; + + a = (bg2rgb[dest[2]] | 0x40100400) - fg2rgb[colormap[source[2]]]; + b = a; + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[2] = RGB32k.All[(a>>15) & a]; + + a = (bg2rgb[dest[3]] | 0x40100400) - fg2rgb[colormap[source[3]]]; + b = a; + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[3] = RGB32k.All[(a>>15) & a]; + + source += 4; + dest += pitch; + } while (--count); } } From 17698467d7b9055bc83ee7d007125df28a463434 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 6 Dec 2016 12:58:45 +0100 Subject: [PATCH 1360/1509] - made application of dynamic lights to additively blended surfaces a MAPINFO option. In most cases this is not wanted but sometimes this can be used to good effect so it should be there as an option. --- src/gl/data/gl_data.cpp | 26 ++++++++++++++++++++++++-- src/gl/data/gl_data.h | 10 ++++++---- src/gl/renderer/gl_lightdata.cpp | 1 + src/gl/scene/gl_flats.cpp | 2 +- src/gl/scene/gl_walls_draw.cpp | 2 +- src/gl/scene/gl_weapon.cpp | 2 -- 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index ad9c824bb..47ad63e99 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -57,6 +57,7 @@ long gl_frameCount; EXTERN_CVAR(Int, gl_lightmode) EXTERN_CVAR(Bool, gl_brightfog) +EXTERN_CVAR(Bool, gl_lightadditivesurfaces) CUSTOM_CVAR(Float, maxviewpitch, 90.f, CVAR_ARCHIVE|CVAR_SERVERINFO) { @@ -203,6 +204,7 @@ struct FGLROptions : public FOptionalMapinfoData skyrotatevector = FVector3(0,0,1); skyrotatevector2 = FVector3(0,0,1); pixelstretch = 1.2f; + lightadditivesurfaces = false; } virtual FOptionalMapinfoData *Clone() const { @@ -217,6 +219,7 @@ struct FGLROptions : public FOptionalMapinfoData newopt->skyrotatevector = skyrotatevector; newopt->skyrotatevector2 = skyrotatevector2; newopt->pixelstretch = pixelstretch; + newopt->lightadditivesurfaces = lightadditivesurfaces; return newopt; } int fogdensity; @@ -224,8 +227,9 @@ struct FGLROptions : public FOptionalMapinfoData int skyfog; int lightmode; int brightfog; - SBYTE nocoloredspritelighting; - SBYTE notexturefill; + int8_t lightadditivesurfaces; + int8_t nocoloredspritelighting; + int8_t notexturefill; FVector3 skyrotatevector; FVector3 skyrotatevector2; float pixelstretch; @@ -299,6 +303,20 @@ DEFINE_MAP_OPTION(notexturefill, false) } } +DEFINE_MAP_OPTION(lightadditivesurfaces, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + if (parse.CheckAssign()) + { + parse.sc.MustGetNumber(); + opt->lightadditivesurfaces = !!parse.sc.Number; + } + else + { + opt->lightadditivesurfaces = true; + } +} + DEFINE_MAP_OPTION(skyrotate, false) { FGLROptions *opt = info->GetOptData("gl_renderer"); @@ -353,6 +371,7 @@ void InitGLRMapinfoData() { gl_SetFogParams(opt->fogdensity, level.info->outsidefog, opt->outsidefogdensity, opt->skyfog); glset.map_lightmode = opt->lightmode; + glset.map_lightadditivesurfaces = opt->lightadditivesurfaces; glset.map_brightfog = opt->brightfog; glset.map_nocoloredspritelighting = opt->nocoloredspritelighting; glset.map_notexturefill = opt->notexturefill; @@ -364,6 +383,7 @@ void InitGLRMapinfoData() { gl_SetFogParams(0, level.info->outsidefog, 0, 0); glset.map_lightmode = -1; + glset.map_lightadditivesurfaces = -1; glset.map_brightfog = -1; glset.map_nocoloredspritelighting = -1; glset.map_notexturefill = -1; @@ -380,6 +400,8 @@ void InitGLRMapinfoData() else glset.notexturefill = !!glset.map_notexturefill; if (glset.map_brightfog == -1) glset.brightfog = gl_brightfog; else glset.brightfog = !!glset.map_brightfog; + if (glset.map_lightadditivesurfaces == -1) glset.brightfog = gl_brightfog; + else glset.lightadditivesurfaces = !!glset.map_lightadditivesurfaces; } CCMD(gl_resetmap) diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index f1bc27ee4..d6f789863 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -12,11 +12,13 @@ struct GLRenderSettings bool nocoloredspritelighting; bool notexturefill; bool brightfog; + bool lightadditivesurfaces; - SBYTE map_lightmode; - SBYTE map_nocoloredspritelighting; - SBYTE map_notexturefill; - SBYTE map_brightfog; + int8_t map_lightmode; + int8_t map_nocoloredspritelighting; + int8_t map_notexturefill; + int8_t map_brightfog; + int8_t map_lightadditivesurfaces; FVector3 skyrotatevector; FVector3 skyrotatevector2; diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 288af5c08..37f0a2e85 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -63,6 +63,7 @@ CUSTOM_CVAR(Bool, gl_enhanced_nightvision, true, CVAR_ARCHIVE|CVAR_NOINITCALL) } } CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE); +CVAR(Bool, lightadditivesurfaces, false, CVAR_ARCHIVE); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index c41e7664f..bc47e448b 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -109,7 +109,7 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli) { Plane p; - if (renderstyle == STYLE_Add) return; // no lights on additively blended surfaces. + if (renderstyle == STYLE_Add && !glset.lightadditivesurfaces) return; // no lights on additively blended surfaces. if (dli != NULL && *dli != -1) { diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index dbc43fd22..d392439e7 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -56,7 +56,7 @@ FDynLightData lightdata; void GLWall::SetupLights() { - if (RenderStyle == STYLE_Add) return; // no lights on additively blended surfaces. + if (RenderStyle == STYLE_Add && !glset.lightadditivesurfaces) return; // no lights on additively blended surfaces. // check for wall types which cannot have dynamic lights on them (portal types never get here so they don't need to be checked.) switch (type) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index a2a12f947..7662c7876 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -188,8 +188,6 @@ static bool isBright(DPSprite *psp) // //========================================================================== -EXTERN_CVAR(Bool, gl_brightfog) - void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) { bool brightflash = false; From c16506bf5977aac3e53f763d9e4feb4d120664b7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 6 Dec 2016 15:13:43 +0100 Subject: [PATCH 1361/1509] Add thread awareness to the rt family of drawers --- src/r_draw_tc.cpp | 10 +++ src/r_drawt_pal.cpp | 215 ++++++++++++++++++++++---------------------- src/r_thread.h | 6 ++ 3 files changed, 125 insertions(+), 106 deletions(-) diff --git a/src/r_draw_tc.cpp b/src/r_draw_tc.cpp index 77d450006..ec9129a89 100644 --- a/src/r_draw_tc.cpp +++ b/src/r_draw_tc.cpp @@ -925,18 +925,28 @@ namespace swrenderer void rt_tlate1col(int hx, int sx, int yl, int yh) { if (r_swtruecolor) + { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } else + { DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + rt_map1col(hx, sx, yl, yh); + } } // Translates all four spans to the screen starting at sx. void rt_tlate4cols(int sx, int yl, int yh) { if (r_swtruecolor) + { DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } else + { DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + rt_map4cols(sx, yl, yh); + } } // Adds one span at hx to the screen at sx without clamping. diff --git a/src/r_drawt_pal.cpp b/src/r_drawt_pal.cpp index b9f0c378d..3356592d2 100644 --- a/src/r_drawt_pal.cpp +++ b/src/r_drawt_pal.cpp @@ -91,18 +91,20 @@ namespace swrenderer fixed_t fracstep; fixed_t frac; + count = thread->count_for_thread(_yl, count); if (count <= 0) return; - { - int x = _x & 3; - dest = &thread->dc_temp[x + 4 * _yl]; - } fracstep = _iscale; frac = _texturefrac; const uint8_t *source = _source; + int x = _x & 3; + dest = &thread->dc_temp[x + thread->temp_line_for_thread(_yl) * 4]; + frac += fracstep * thread->skipped_by_thread(_yl); + fracstep *= thread->num_cores; + if (count & 1) { *dest = source[frac >> FRACBITS]; dest += 4; frac += fracstep; } @@ -141,13 +143,12 @@ namespace swrenderer uint8_t color = _color; uint8_t *dest; + count = thread->count_for_thread(_yl, count); if (count <= 0) return; - { - int x = _x & 3; - dest = &thread->dc_temp[x + 4 * _yl]; - } + int x = _x & 3; + dest = &thread->dc_temp[x + thread->temp_line_for_thread(_yl) * 4]; if (count & 1) { *dest = color; @@ -183,14 +184,15 @@ namespace swrenderer int count; int pitch; - count = yh-yl; - if (count < 0) - return; - count++; + count = yh - yl + 1; - dest = ylookup[yl] + sx + _destorg; - source = &thread->dc_temp[yl*4 + hx]; - pitch = _pitch; + count = thread->count_for_thread(yl, count); + if (count <= 0) + return; + + dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; + source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; + pitch = _pitch * thread->num_cores; if (count & 1) { *dest = *source; @@ -223,14 +225,15 @@ namespace swrenderer int count; int pitch; - count = yh-yl; - if (count < 0) - return; - count++; + count = yh - yl + 1; - dest = (int *)(ylookup[yl] + sx + _destorg); - source = (int *)(&thread->dc_temp[yl*4]); - pitch = _pitch/sizeof(int); + count = thread->count_for_thread(yl, count); + if (count <= 0) + return; + + dest = (int *)(ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg); + source = (int *)(&thread->dc_temp[thread->temp_line_for_thread(yl)*4]); + pitch = _pitch*thread->num_cores/sizeof(int); if (count & 1) { *dest = *source; @@ -256,15 +259,16 @@ namespace swrenderer int count; int pitch; - count = yh-yl; - if (count < 0) + count = yh - yl + 1; + + count = thread->count_for_thread(yl, count); + if (count <= 0) return; - count++; colormap = _colormap; - dest = ylookup[yl] + sx + _destorg; - source = &thread->dc_temp[yl*4 + hx]; - pitch = _pitch; + dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; + source = &thread->dc_temp[thread->temp_line_for_thread(yl) *4 + hx]; + pitch = _pitch*thread->num_cores; if (count & 1) { *dest = colormap[*source]; @@ -290,15 +294,16 @@ namespace swrenderer int count; int pitch; - count = yh-yl; - if (count < 0) + count = yh - yl + 1; + + count = thread->count_for_thread(yl, count); + if (count <= 0) return; - count++; colormap = _colormap; - dest = ylookup[yl] + sx + _destorg; - source = &thread->dc_temp[yl*4]; - pitch = _pitch; + dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; + source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; + pitch = _pitch*thread->num_cores; if (count & 1) { dest[0] = colormap[source[0]]; @@ -328,7 +333,11 @@ namespace swrenderer void DrawColumnRt1TranslatedPalCommand::Execute(DrawerThread *thread) { int count = yh - yl + 1; - uint8_t *source = &thread->dc_temp[yl*4 + hx]; + count = thread->count_for_thread(yl, count); + if (count <= 0) + return; + + uint8_t *source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; const uint8_t *translation = _translation; // Things we do to hit the compiler's optimizer with a clue bat: @@ -376,7 +385,11 @@ namespace swrenderer void DrawColumnRt4TranslatedPalCommand::Execute(DrawerThread *thread) { int count = yh - yl + 1; - uint8_t *source = &thread->dc_temp[yl*4]; + count = thread->count_for_thread(yl, count); + if (count <= 0) + return; + + uint8_t *source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; const uint8_t *translation = _translation; int c0, c1; uint8_t b0, b1; @@ -420,19 +433,18 @@ namespace swrenderer const uint8_t *colormap; uint8_t *source; uint8_t *dest; - int count; int pitch; - count = yh-yl; - if (count < 0) + int count = yh - yl + 1; + count = thread->count_for_thread(yl, count); + if (count <= 0) return; - count++; const uint32_t *fg2rgb = _srcblend; const uint32_t *bg2rgb = _destblend; - dest = ylookup[yl] + sx + _destorg; - source = &thread->dc_temp[yl*4 + hx]; - pitch = _pitch; + dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; + source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; + pitch = _pitch * thread->num_cores; colormap = _colormap; do { @@ -453,19 +465,18 @@ namespace swrenderer const uint8_t *colormap; uint8_t *source; uint8_t *dest; - int count; int pitch; - count = yh-yl; - if (count < 0) + int count = yh - yl + 1; + count = thread->count_for_thread(yl, count); + if (count <= 0) return; - count++; const uint32_t *fg2rgb = _srcblend; const uint32_t *bg2rgb = _destblend; - dest = ylookup[yl] + sx + _destorg; - source = &thread->dc_temp[yl*4]; - pitch = _pitch; + dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; + source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; + pitch = _pitch * thread->num_cores; colormap = _colormap; do { @@ -509,19 +520,18 @@ namespace swrenderer const uint8_t *colormap; uint8_t *source; uint8_t *dest; - int count; int pitch; - count = yh-yl; - if (count < 0) + int count = yh - yl + 1; + count = thread->count_for_thread(yl, count); + if (count <= 0) return; - count++; fgstart = &Col2RGB8[0][_color]; colormap = _colormap; - dest = ylookup[yl] + sx + _destorg; - source = &thread->dc_temp[yl*4 + hx]; - pitch = _pitch; + dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; + source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; + pitch = _pitch * thread->num_cores; do { uint32_t val = colormap[*source]; @@ -539,19 +549,18 @@ namespace swrenderer const uint8_t *colormap; uint8_t *source; uint8_t *dest; - int count; int pitch; - count = yh-yl; - if (count < 0) + int count = yh - yl + 1; + count = thread->count_for_thread(yl, count); + if (count <= 0) return; - count++; fgstart = &Col2RGB8[0][_color]; colormap = _colormap; - dest = ylookup[yl] + sx + _destorg; - source = &thread->dc_temp[yl*4]; - pitch = _pitch; + dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; + source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; + pitch = _pitch * thread->num_cores; do { uint32_t val; @@ -582,19 +591,18 @@ namespace swrenderer const uint8_t *colormap; uint8_t *source; uint8_t *dest; - int count; int pitch; - count = yh-yl; - if (count < 0) + int count = yh - yl + 1; + count = thread->count_for_thread(yl, count); + if (count <= 0) return; - count++; const uint32_t *fg2rgb = _srcblend; const uint32_t *bg2rgb = _destblend; - dest = ylookup[yl] + sx + _destorg; - source = &thread->dc_temp[yl*4 + hx]; - pitch = _pitch; + dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; + source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; + pitch = _pitch * thread->num_cores; colormap = _colormap; do { @@ -617,17 +625,16 @@ namespace swrenderer const uint8_t *colormap; uint8_t *source; uint8_t *dest; - int count; int pitch; - count = yh-yl; - if (count < 0) + int count = yh - yl + 1; + count = thread->count_for_thread(yl, count); + if (count <= 0) return; - count++; - dest = ylookup[yl] + sx + _destorg; - source = &thread->dc_temp[yl*4]; - pitch = _pitch; + dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; + source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; + pitch = _pitch * thread->num_cores; colormap = _colormap; const uint32_t *fg2rgb = _srcblend; @@ -681,19 +688,18 @@ namespace swrenderer const uint8_t *colormap; uint8_t *source; uint8_t *dest; - int count; int pitch; - count = yh-yl; - if (count < 0) + int count = yh - yl + 1; + count = thread->count_for_thread(yl, count); + if (count <= 0) return; - count++; const uint32_t *fg2rgb = _srcblend; const uint32_t *bg2rgb = _destblend; - dest = ylookup[yl] + sx + _destorg; - source = &thread->dc_temp[yl*4 + hx]; - pitch = _pitch; + dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; + source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; + pitch = _pitch * thread->num_cores; colormap = _colormap; do { @@ -715,19 +721,18 @@ namespace swrenderer const uint8_t *colormap; uint8_t *source; uint8_t *dest; - int count; int pitch; - count = yh-yl; - if (count < 0) + int count = yh - yl + 1; + count = thread->count_for_thread(yl, count); + if (count <= 0) return; - count++; const uint32_t *fg2rgb = _srcblend; const uint32_t *bg2rgb = _destblend; - dest = ylookup[yl] + sx + _destorg; - source = &thread->dc_temp[yl*4]; - pitch = _pitch; + dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; + source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; + pitch = _pitch * thread->num_cores; colormap = _colormap; do { @@ -774,19 +779,18 @@ namespace swrenderer const uint8_t *colormap; uint8_t *source; uint8_t *dest; - int count; int pitch; - count = yh-yl; - if (count < 0) + int count = yh - yl + 1; + count = thread->count_for_thread(yl, count); + if (count <= 0) return; - count++; const uint32_t *fg2rgb = _srcblend; const uint32_t *bg2rgb = _destblend; - dest = ylookup[yl] + sx + _destorg; - source = &thread->dc_temp[yl*4 + hx]; - pitch = _pitch; + dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; + source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; + pitch = _pitch * thread->num_cores; colormap = _colormap; do { @@ -808,19 +812,18 @@ namespace swrenderer const uint8_t *colormap; uint8_t *source; uint8_t *dest; - int count; int pitch; - count = yh-yl; - if (count < 0) + int count = yh - yl + 1; + count = thread->count_for_thread(yl, count); + if (count <= 0) return; - count++; const uint32_t *fg2rgb = _srcblend; const uint32_t *bg2rgb = _destblend; - dest = ylookup[yl] + sx + _destorg; - source = &thread->dc_temp[yl*4]; - pitch = _pitch; + dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; + source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; + pitch = _pitch * thread->num_cores; colormap = _colormap; do { diff --git a/src/r_thread.h b/src/r_thread.h index 1e48ff307..9a8a5c1b5 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -89,6 +89,12 @@ public: { return dest + skipped_by_thread(first_line) * pitch; } + + // The first line in the dc_temp buffer used this thread + int temp_line_for_thread(int first_line) + { + return (first_line + skipped_by_thread(first_line)) / num_cores; + } }; // Task to be executed by each worker thread From 6054db0d865abf7a0c32bdd347dcb68e4b541965 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 6 Dec 2016 15:29:04 +0100 Subject: [PATCH 1362/1509] Make puzzy pinky fuzzywuzzy about threads --- src/r_draw_pal.cpp | 117 +++++++++++++++++++++++---------------------- src/r_draw_pal.h | 2 + 2 files changed, 63 insertions(+), 56 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index fbef5153e..ab598957d 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -1733,76 +1733,81 @@ namespace swrenderer _x = dc_x; _destorg = dc_destorg; _pitch = dc_pitch; + _fuzzpos = fuzzpos; + _fuzzviewheight = fuzzviewheight; } void DrawFuzzColumnPalCommand::Execute(DrawerThread *thread) { - int count; - uint8_t *dest; + int yl = MAX(_yl, 1); + int yh = MIN(_yh, _fuzzviewheight); - // Adjust borders. Low... - if (_yl == 0) - _yl = 1; - - // .. and high. - if (_yh > fuzzviewheight) - _yh = fuzzviewheight; - - count = _yh - _yl; + int count = thread->count_for_thread(yl, yh - yl + 1); // Zero length. - if (count < 0) + if (count <= 0) return; - count++; + uint8_t *map = &NormalLight.Maps[6 * 256]; - dest = ylookup[_yl] + _x + _destorg; + uint8_t *dest = thread->dest_for_thread(yl, _pitch, ylookup[yl] + _x + _destorg); - // colormap #6 is used for shading (of 0-31, a bit brighter than average) + int pitch = _pitch * thread->num_cores; + int fuzzstep = thread->num_cores; + int fuzz = (_fuzzpos + thread->skipped_by_thread(yl)) % FUZZTABLE; + + yl += thread->skipped_by_thread(yl); + + // Handle the case where we would go out of bounds at the top: + if (yl < fuzzstep) { - // [RH] Make local copies of global vars to try and improve - // the optimizations made by the compiler. - int pitch = _pitch; - int fuzz = fuzzpos; - int cnt; - uint8_t *map = &NormalLight.Maps[6 * 256]; + uint8_t *srcdest = dest + fuzzoffset[fuzz] * fuzzstep + pitch; + //assert(static_cast((srcdest - (uint8_t*)dc_destorg) / (_pitch)) < viewheight); - // [RH] Split this into three separate loops to minimize - // the number of times fuzzpos needs to be clamped. - if (fuzz) + *dest = map[*srcdest]; + dest += pitch; + fuzz += fuzzstep; + fuzz %= FUZZTABLE; + + count--; + if (count == 0) + return; + } + + bool lowerbounds = (yl + (count + fuzzstep - 1) * fuzzstep > _fuzzviewheight); + if (lowerbounds) + count--; + + // Fuzz where fuzzoffset stays within bounds + while (count > 0) + { + int available = (FUZZTABLE - fuzz); + int next_wrap = available / fuzzstep; + if (available % fuzzstep != 0) + next_wrap++; + + int cnt = MIN(count, next_wrap); + count -= cnt; + do { - cnt = MIN(FUZZTABLE - fuzz, count); - count -= cnt; - do - { - *dest = map[dest[fuzzoffset[fuzz++]]]; - dest += pitch; - } while (--cnt); - } - if (fuzz == FUZZTABLE || count > 0) - { - while (count >= FUZZTABLE) - { - fuzz = 0; - cnt = FUZZTABLE; - count -= FUZZTABLE; - do - { - *dest = map[dest[fuzzoffset[fuzz++]]]; - dest += pitch; - } while (--cnt); - } - fuzz = 0; - if (count > 0) - { - do - { - *dest = map[dest[fuzzoffset[fuzz++]]]; - dest += pitch; - } while (--count); - } - } - fuzzpos = fuzz; + uint8_t *srcdest = dest + fuzzoffset[fuzz] * fuzzstep; + //assert(static_cast((srcdest - (uint8_t*)dc_destorg) / (_pitch)) < viewheight); + + *dest = map[*srcdest]; + dest += pitch; + fuzz += fuzzstep; + } while (--cnt); + + fuzz %= FUZZTABLE; + } + + // Handle the case where we would go out of bounds at the bottom + if (lowerbounds) + { + uint8_t *srcdest = dest + fuzzoffset[fuzz] * fuzzstep - pitch; + //assert(static_cast((srcdest - (uint8_t*)dc_destorg) / (_pitch)) < viewheight); + + *dest = map[*srcdest]; } } diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index f3b220f82..d9fb2d489 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -138,6 +138,8 @@ namespace swrenderer int _x; uint8_t *_destorg; int _pitch; + int _fuzzpos; + int _fuzzviewheight; }; class PalSpanCommand : public DrawerCommand From d8f805ddc92df236549b4e35d05790ea2a173941 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 6 Dec 2016 18:31:26 +0100 Subject: [PATCH 1363/1509] Added DrawSlabPalCommand and rewrote the actual for loop so nobody can say it came from build.. --- src/r_draw_pal.cpp | 30 ++++++++++++++++++++++++++++++ src/r_draw_pal.h | 11 +++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index ab598957d..fa4b7df1d 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -2286,11 +2286,41 @@ namespace swrenderer ///////////////////////////////////////////////////////////////////////// DrawSlabPalCommand::DrawSlabPalCommand(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p, const uint8_t *colormap) + : _dx(dx), _v(v), _dy(dy), _vi(vi), _vptr(vptr), _p(p), _colormap(colormap) { + using namespace drawerargs; + _pitch = dc_pitch; + _start_y = static_cast((p - dc_destorg) / dc_pitch); } void DrawSlabPalCommand::Execute(DrawerThread *thread) { + int count = _dy; + uint8_t *dest = _p; + int pitch = _pitch; + int width = _dx; + const uint8_t *colormap = _colormap; + const uint8_t *source = _vptr; + fixed_t fracpos = _v; + fixed_t iscale = _vi; + + count = thread->count_for_thread(_start_y, count); + dest = thread->dest_for_thread(_start_y, pitch, dest); + fracpos += iscale * thread->skipped_by_thread(_start_y); + iscale *= thread->num_cores; + pitch *= thread->num_cores; + + while (count > 0) + { + uint8_t color = colormap[source[fracpos >> FRACBITS]]; + + for (int x = 0; x < width; x++) + dest[x] = color; + + dest += pitch; + fracpos += iscale; + count--; + } } ///////////////////////////////////////////////////////////////////////// diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index d9fb2d489..ba9a953c3 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -195,6 +195,17 @@ namespace swrenderer public: DrawSlabPalCommand(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p, const uint8_t *colormap); void Execute(DrawerThread *thread) override; + + private: + int _dx; + fixed_t _v; + int _dy; + fixed_t _vi; + const uint8_t *_vptr; + uint8_t *_p; + const uint8_t *_colormap; + int _pitch; + int _start_y; }; class DrawFogBoundaryLinePalCommand : public PalSpanCommand From c115c0a5b2dd99a8013c95061f283ee5a5d9beb9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 6 Dec 2016 18:35:34 +0100 Subject: [PATCH 1364/1509] - fixed: Random flicker lights must set up their size on the first tic they are run. If not they will keep the radius of the previous effect which may be too large. --- src/gl/dynlights/a_dynlight.cpp | 21 ++++++++++++--------- src/gl/dynlights/gl_dynlight.cpp | 13 +++++++++++-- src/gl/dynlights/gl_dynlight.h | 7 +------ 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 0e52eedd8..84e1d9ab1 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -67,6 +67,7 @@ #include "templates.h" #include "doomdata.h" #include "r_utility.h" +#include "p_local.h" #include "portal.h" #include "doomstat.h" #include "serializer.h" @@ -192,6 +193,7 @@ void ADynamicLight::BeginPlay() m_Radius[0] = args[LIGHT_INTENSITY]; m_Radius[1] = args[LIGHT_SECONDARY_INTENSITY]; + specialf1 = DAngle(double(SpawnAngle)).Normalized360().Degrees; visibletoplayer = true; } @@ -228,7 +230,7 @@ void ADynamicLight::Activate(AActor *activator) if (lighttype == PulseLight) { - float pulseTime = Angles.Yaw.Degrees / TICRATE; + float pulseTime = specialf1 / TICRATE; m_lastUpdate = level.maptime; m_cycler.SetParams(float(m_Radius[1]), float(m_Radius[0]), pulseTime); @@ -293,7 +295,7 @@ void ADynamicLight::Tick() case FlickerLight: { BYTE rnd = randLight(); - float pct = Angles.Yaw.Degrees / 360.f; + float pct = specialf1 / 360.f; m_currentRadius = float(m_Radius[rnd >= pct * 255]); break; @@ -304,12 +306,13 @@ void ADynamicLight::Tick() int flickerRange = m_Radius[1] - m_Radius[0]; float amt = randLight() / 255.f; - m_tickCount++; - - if (m_tickCount > Angles.Yaw.Degrees) + if (m_tickCount > specialf1) + { + m_tickCount = 0; + } + if (m_tickCount++ == 0 || m_currentRadius > m_Radius[1]) { m_currentRadius = float(m_Radius[0] + (amt * flickerRange)); - m_tickCount = 0; } break; } @@ -319,7 +322,7 @@ void ADynamicLight::Tick() case ColorFlickerLight: { BYTE rnd = randLight(); - float pct = Angles.Yaw.Degrees/360.f; + float pct = specialf1/360.f; m_currentRadius = m_Radius[rnd >= pct * 255]; break; @@ -332,7 +335,7 @@ void ADynamicLight::Tick() m_tickCount++; - if (m_tickCount > Angles.Yaw.Degrees) + if (m_tickCount > specialf1) { m_currentRadius = m_Radius[0] + (amt * flickerRange); m_tickCount = 0; @@ -359,7 +362,6 @@ void ADynamicLight::Tick() m_currentRadius = float(m_Radius[0]); break; } - UpdateLocation(); } @@ -416,6 +418,7 @@ void ADynamicLight::UpdateLocation() intensity = m_currentRadius; } radius = intensity * 2.0f; + assert(radius >= m_currentRadius * 2); if (X() != oldx || Y() != oldy || radius != oldradius) { diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index 40008e3ad..63ddfee60 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -164,7 +164,7 @@ FLightDefaults::FLightDefaults(FName name, ELightType type) void FLightDefaults::ApplyProperties(ADynamicLight * light) const { light->lighttype = m_type; - light->Angles.Yaw.Degrees = m_Param; + light->specialf1 = m_Param; light->SetOffset(m_Pos); light->halo = m_halo; for (int a = 0; a < 3; a++) light->args[a] = clamp((int)(m_Args[a]), 0, 255); @@ -174,6 +174,7 @@ void FLightDefaults::ApplyProperties(ADynamicLight * light) const if (m_subtractive) light->flags4 |= MF4_SUBTRACTIVE; if (m_additive) light->flags4 |= MF4_ADDITIVE; if (m_dontlightself) light->flags4 |= MF4_DONTLIGHTSELF; + light->m_tickCount = 0; } @@ -431,6 +432,14 @@ void gl_ParsePulseLight(FScanner &sc) sc.ScriptError("Unknown tag: %s\n", sc.String); } } + if (defaults->GetArg(LIGHT_INTENSITY) > defaults->GetArg(LIGHT_SECONDARY_INTENSITY)) + { + auto i = defaults->GetArg(LIGHT_INTENSITY); + auto j = defaults->GetArg(LIGHT_SECONDARY_INTENSITY); + defaults->SetArg(LIGHT_INTENSITY, j); + defaults->SetArg(LIGHT_SECONDARY_INTENSITY, i); + } + gl_AddLightDefaults(defaults); } else @@ -1082,7 +1091,7 @@ void gl_AttachLight(AActor *actor, unsigned int count, const FLightDefaults *lig light->target = actor; light->owned = true; light->ObjectFlags |= OF_Transient; - light->flags4 |= MF4_ATTENUATE; + //light->flags4 |= MF4_ATTENUATE; actor->dynamiclights.Push(light); } light->flags2&=~MF2_DORMANT; diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index c51e0c79d..e8448890b 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -128,12 +128,12 @@ private: protected: DVector3 m_off; float m_currentRadius; - int m_tickCount; unsigned int m_lastUpdate; FCycler m_cycler; subsector_t * subsector; public: + int m_tickCount; int m_Radius[2]; BYTE lightflags; BYTE lighttype; @@ -143,11 +143,6 @@ public: bool visibletoplayer; int bufferindex; - // intermediate texture coordinate data - // this is stored in the light object to avoid recalculating it - // several times during rendering of a flat - Vector nearPt, up, right; - float scale; }; From bec5d39ca89366155ef6f9d935538978a4bb799a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 6 Dec 2016 18:58:39 +0100 Subject: [PATCH 1365/1509] ColoredSpan and FogBoundary drawers --- src/r_draw_pal.cpp | 24 ++++++++++++++++++++++-- src/r_draw_pal.h | 14 +++++++++++++- src/r_plane.cpp | 5 ----- src/r_plane.h | 5 ----- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index fa4b7df1d..6eeba9ec7 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -2275,12 +2275,19 @@ namespace swrenderer ///////////////////////////////////////////////////////////////////////// - DrawColoredSpanPalCommand::DrawColoredSpanPalCommand(int y, int x1, int x2) + DrawColoredSpanPalCommand::DrawColoredSpanPalCommand(int y, int x1, int x2) : y(y), x1(x1), x2(x2) { + using namespace drawerargs; + color = ds_color; + destorg = dc_destorg; } void DrawColoredSpanPalCommand::Execute(DrawerThread *thread) { + if (thread->line_skipped_by_thread(y)) + return; + + memset(ylookup[y] + x1 + destorg, color, x2 - x1 + 1); } ///////////////////////////////////////////////////////////////////////// @@ -2325,11 +2332,24 @@ namespace swrenderer ///////////////////////////////////////////////////////////////////////// - DrawFogBoundaryLinePalCommand::DrawFogBoundaryLinePalCommand(int y, int y2, int x1) + DrawFogBoundaryLinePalCommand::DrawFogBoundaryLinePalCommand(int y, int x1, int x2) : y(y), x1(x1), x2(x2) { + using namespace drawerargs; + _colormap = dc_colormap; + _destorg = dc_destorg; } void DrawFogBoundaryLinePalCommand::Execute(DrawerThread *thread) { + if (thread->line_skipped_by_thread(y)) + return; + + const uint8_t *colormap = _colormap; + uint8_t *dest = ylookup[y] + _destorg; + int x = x1; + do + { + dest[x] = colormap[dest[x]]; + } while (++x <= x2); } } diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index ba9a953c3..6fe775568 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -188,6 +188,13 @@ namespace swrenderer DrawColoredSpanPalCommand(int y, int x1, int x2); void Execute(DrawerThread *thread) override; FString DebugInfo() override { return "DrawColoredSpanPalCommand"; } + + private: + int y; + int x1; + int x2; + int color; + uint8_t *destorg; }; class DrawSlabPalCommand : public PalSpanCommand @@ -211,8 +218,13 @@ namespace swrenderer class DrawFogBoundaryLinePalCommand : public PalSpanCommand { public: - DrawFogBoundaryLinePalCommand(int y, int y2, int x1); + DrawFogBoundaryLinePalCommand(int y, int x1, int x2); void Execute(DrawerThread *thread) override; + + private: + int y, x1, x2; + const uint8_t *_colormap; + uint8_t *_destorg; }; class RtInitColsPalCommand : public DrawerCommand diff --git a/src/r_plane.cpp b/src/r_plane.cpp index c6c7d6d2f..3b026b293 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -522,11 +522,6 @@ void R_MapTiltedPlane (int y, int x1) // //========================================================================== -void R_MapColoredPlane_C (int y, int x1) -{ - memset (ylookup[y] + x1 + dc_destorg, ds_color, spanend[y] - x1 + 1); -} - void R_MapColoredPlane(int y, int x1) { R_DrawColoredSpan(y, x1, spanend[y]); diff --git a/src/r_plane.h b/src/r_plane.h index 9141411af..3a067b527 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -96,11 +96,6 @@ void R_DrawNormalPlane (visplane_t *pl, double xscale, double yscale, fixed_t al void R_DrawTiltedPlane (visplane_t *pl, double xscale, double yscale, fixed_t alpha, bool additive, bool masked); void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1)); -void R_MapTiltedPlane_C(int y, int x1); -void R_MapTiltedPlane_rgba(int y, int x); -void R_MapColoredPlane_C(int y, int x1); -void R_MapColoredPlane_rgba(int y, int x1); - visplane_t *R_FindPlane ( const secplane_t &height, FTextureID picnum, From a3ae05299b6b72f11e37f69c4972aaf7b81cd102 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 6 Dec 2016 19:17:02 +0100 Subject: [PATCH 1366/1509] - fixed: glPolygonOffset was not called for flat sprites. --- src/gl/scene/gl_sprite.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index e9748fba6..f79549a39 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -142,6 +142,9 @@ void GLSprite::CalculateVertices(FVector3 *v) v[1] = mat * FVector3(x1, z, y2); v[2] = mat * FVector3(x2, z, y1); v[3] = mat * FVector3(x1, z, y1); + + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); return; } @@ -445,6 +448,11 @@ void GLSprite::Draw(int pass) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.BlendEquation(GL_FUNC_ADD); gl_RenderState.SetTextureMode(TM_MODULATE); + if (actor != nullptr && (actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE) + { + glPolygonOffset(0.0f, 0.0f); + glDisable(GL_POLYGON_OFFSET_FILL); + } } else if (modelframe == nullptr) { From 30ddcfbc8f4be132b16a4f826278fccda9ecd030 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 6 Dec 2016 19:44:28 +0100 Subject: [PATCH 1367/1509] Add tilted plane drawer --- src/r_draw_pal.cpp | 238 +++++++++++++++++++++++++++++++++++++++ src/r_draw_pal.h | 22 ++++ src/r_plane.cpp | 273 +-------------------------------------------- src/r_thread.h | 5 + 4 files changed, 266 insertions(+), 272 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 6eeba9ec7..810192b96 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -2266,11 +2266,249 @@ namespace swrenderer ///////////////////////////////////////////////////////////////////////// DrawTiltedSpanPalCommand::DrawTiltedSpanPalCommand(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) + : y(y), x1(x1), x2(x2), plane_sz(plane_sz), plane_su(plane_su), plane_sv(plane_sv), plane_shade(plane_shade), planeshade(planeshade), planelightfloat(planelightfloat), pviewx(pviewx), pviewy(pviewy) { + using namespace drawerargs; + + _colormap = ds_colormap; + _destorg = dc_destorg; + _ybits = ds_ybits; + _xbits = ds_xbits; + _source = ds_source; + basecolormapdata = basecolormap->Maps; } void DrawTiltedSpanPalCommand::Execute(DrawerThread *thread) { + if (thread->line_skipped_by_thread(y)) + return; + + const uint8_t **tiltlighting = thread->tiltlighting; + + int width = x2 - x1; + double iz, uz, vz; + uint8_t *fb; + uint32_t u, v; + int i; + + iz = plane_sz[2] + plane_sz[1] * (centery - y) + plane_sz[0] * (x1 - centerx); + + // Lighting is simple. It's just linear interpolation from start to end + if (plane_shade) + { + uz = (iz + plane_sz[0] * width) * planelightfloat; + vz = iz * planelightfloat; + CalcTiltedLighting(vz, uz, width, thread); + } + else + { + for (int i = 0; i < width; ++i) + { + tiltlighting[i] = _colormap; + } + } + + uz = plane_su[2] + plane_su[1] * (centery - y) + plane_su[0] * (x1 - centerx); + vz = plane_sv[2] + plane_sv[1] * (centery - y) + plane_sv[0] * (x1 - centerx); + + fb = ylookup[y] + x1 + _destorg; + + uint8_t vshift = 32 - _ybits; + uint8_t ushift = vshift - _xbits; + int umask = ((1 << _xbits) - 1) << _ybits; + + #if 0 + // The "perfect" reference version of this routine. Pretty slow. + // Use it only to see how things are supposed to look. + i = 0; + do + { + double z = 1.f / iz; + + u = int64_t(uz*z) + pviewx; + v = int64_t(vz*z) + pviewy; + R_SetDSColorMapLight(tiltlighting[i], 0, 0); + fb[i++] = ds_colormap[ds_source[(v >> vshift) | ((u >> ushift) & umask)]]; + iz += plane_sz[0]; + uz += plane_su[0]; + vz += plane_sv[0]; + } while (--width >= 0); + #else + //#define SPANSIZE 32 + //#define INVSPAN 0.03125f + //#define SPANSIZE 8 + //#define INVSPAN 0.125f + #define SPANSIZE 16 + #define INVSPAN 0.0625f + + double startz = 1.f / iz; + double startu = uz*startz; + double startv = vz*startz; + double izstep, uzstep, vzstep; + + izstep = plane_sz[0] * SPANSIZE; + uzstep = plane_su[0] * SPANSIZE; + vzstep = plane_sv[0] * SPANSIZE; + x1 = 0; + width++; + + while (width >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + double endz = 1.f / iz; + double endu = uz*endz; + double endv = vz*endz; + uint32_t stepu = (uint32_t)int64_t((endu - startu) * INVSPAN); + uint32_t stepv = (uint32_t)int64_t((endv - startv) * INVSPAN); + u = (uint32_t)(int64_t(startu) + pviewx); + v = (uint32_t)(int64_t(startv) + pviewy); + + for (i = SPANSIZE - 1; i >= 0; i--) + { + fb[x1] = *(tiltlighting[x1] + _source[(v >> vshift) | ((u >> ushift) & umask)]); + x1++; + u += stepu; + v += stepv; + } + startu = endu; + startv = endv; + width -= SPANSIZE; + } + if (width > 0) + { + if (width == 1) + { + u = (uint32_t)int64_t(startu); + v = (uint32_t)int64_t(startv); + fb[x1] = *(tiltlighting[x1] + _source[(v >> vshift) | ((u >> ushift) & umask)]); + } + else + { + double left = width; + iz += plane_sz[0] * left; + uz += plane_su[0] * left; + vz += plane_sv[0] * left; + + double endz = 1.f / iz; + double endu = uz*endz; + double endv = vz*endz; + left = 1.f / left; + uint32_t stepu = (uint32_t)int64_t((endu - startu) * left); + uint32_t stepv = (uint32_t)int64_t((endv - startv) * left); + u = (uint32_t)(int64_t(startu) + pviewx); + v = (uint32_t)(int64_t(startv) + pviewy); + + for (; width != 0; width--) + { + fb[x1] = *(tiltlighting[x1] + _source[(v >> vshift) | ((u >> ushift) & umask)]); + x1++; + u += stepu; + v += stepv; + } + } + } + #endif + } + + // Calculates the lighting for one row of a tilted plane. If the definition + // of GETPALOOKUP changes, this needs to change, too. + void DrawTiltedSpanPalCommand::CalcTiltedLighting(double lval, double lend, int width, DrawerThread *thread) + { + const uint8_t **tiltlighting = thread->tiltlighting; + + double lstep; + uint8_t *lightfiller; + int i = 0; + + if (width == 0 || lval == lend) + { // Constant lighting + lightfiller = basecolormapdata + (GETPALOOKUP(lval, planeshade) << COLORMAPSHIFT); + } + else + { + lstep = (lend - lval) / width; + if (lval >= MAXLIGHTVIS) + { // lval starts "too bright". + lightfiller = basecolormapdata + (GETPALOOKUP(lval, planeshade) << COLORMAPSHIFT); + for (; i <= width && lval >= MAXLIGHTVIS; ++i) + { + tiltlighting[i] = lightfiller; + lval += lstep; + } + } + if (lend >= MAXLIGHTVIS) + { // lend ends "too bright". + lightfiller = basecolormapdata + (GETPALOOKUP(lend, planeshade) << COLORMAPSHIFT); + for (; width > i && lend >= MAXLIGHTVIS; --width) + { + tiltlighting[width] = lightfiller; + lend -= lstep; + } + } + if (width > 0) + { + lval = FIXED2DBL(planeshade) - lval; + lend = FIXED2DBL(planeshade) - lend; + lstep = (lend - lval) / width; + if (lstep < 0) + { // Going from dark to light + if (lval < 1.) + { // All bright + lightfiller = basecolormapdata; + } + else + { + if (lval >= NUMCOLORMAPS) + { // Starts beyond the dark end + uint8_t *clight = basecolormapdata + ((NUMCOLORMAPS - 1) << COLORMAPSHIFT); + while (lval >= NUMCOLORMAPS && i <= width) + { + tiltlighting[i++] = clight; + lval += lstep; + } + if (i > width) + return; + } + while (i <= width && lval >= 0) + { + tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT); + lval += lstep; + } + lightfiller = basecolormapdata; + } + } + else + { // Going from light to dark + if (lval >= (NUMCOLORMAPS - 1)) + { // All dark + lightfiller = basecolormapdata + ((NUMCOLORMAPS - 1) << COLORMAPSHIFT); + } + else + { + while (lval < 0 && i <= width) + { + tiltlighting[i++] = basecolormapdata; + lval += lstep; + } + if (i > width) + return; + while (i <= width && lval < (NUMCOLORMAPS - 1)) + { + tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT); + lval += lstep; + } + lightfiller = basecolormapdata + ((NUMCOLORMAPS - 1) << COLORMAPSHIFT); + } + } + } + } + for (; i <= width; i++) + { + tiltlighting[i] = lightfiller; + } } ///////////////////////////////////////////////////////////////////////// diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index 6fe775568..93c24857b 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -180,6 +180,28 @@ namespace swrenderer DrawTiltedSpanPalCommand(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy); void Execute(DrawerThread *thread) override; FString DebugInfo() override { return "DrawTiltedSpanPalCommand"; } + + private: + void CalcTiltedLighting(double lval, double lend, int width, DrawerThread *thread); + + int y; + int x1; + int x2; + FVector3 plane_sz; + FVector3 plane_su; + FVector3 plane_sv; + bool plane_shade; + int planeshade; + float planelightfloat; + fixed_t pviewx; + fixed_t pviewy; + + const uint8_t *_colormap; + uint8_t *_destorg; + int _ybits; + int _xbits; + const uint8_t *_source; + uint8_t *basecolormapdata; }; class DrawColoredSpanPalCommand : public PalSpanCommand diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 3b026b293..3769dda06 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -138,15 +138,12 @@ extern "C" { // spanend holds the end of a plane span in each screen row // short spanend[MAXHEIGHT]; -BYTE *tiltlighting[MAXWIDTH]; int planeshade; FVector3 plane_sz, plane_su, plane_sv; float planelightfloat; bool plane_shade; fixed_t pviewx, pviewy; - -void R_DrawTiltedPlane_ASM (int y, int x1); } float yslope[MAXHEIGHT]; @@ -154,13 +151,6 @@ static fixed_t xscale, yscale; static double xstepscale, ystepscale; static double basexfrac, baseyfrac; -#ifdef X86_ASM -extern "C" void R_SetSpanSource_ASM (const BYTE *flat); -extern "C" void R_SetSpanSize_ASM (int xbits, int ybits); -extern "C" void R_SetSpanColormap_ASM (BYTE *colormap); -extern "C" void R_SetTiltedSpanSource_ASM (const BYTE *flat); -extern "C" BYTE *ds_curcolormap, *ds_cursource, *ds_curtiltedsource; -#endif void R_DrawSinglePlane (visplane_t *, fixed_t alpha, bool additive, bool masked); //========================================================================== @@ -264,11 +254,6 @@ void R_MapPlane (int y, int x1) R_SetDSColorMapLight(basecolormap, GlobVis * fabs(CenterY - y), planeshade); } -#ifdef X86_ASM - if (!r_swtruecolor && ds_colormap != ds_curcolormap) - R_SetSpanColormap_ASM (ds_colormap); -#endif - ds_y = y; ds_x1 = x1; ds_x2 = x2; @@ -276,241 +261,12 @@ void R_MapPlane (int y, int x1) spanfunc (); } -//========================================================================== -// -// R_CalcTiltedLighting -// -// Calculates the lighting for one row of a tilted plane. If the definition -// of GETPALOOKUP changes, this needs to change, too. -// -//========================================================================== - -extern "C" { -void R_CalcTiltedLighting (double lval, double lend, int width) -{ - double lstep; - BYTE *lightfiller; - BYTE *basecolormapdata = basecolormap->Maps; - int i = 0; - - if (width == 0 || lval == lend) - { // Constant lighting - lightfiller = basecolormapdata + (GETPALOOKUP(lval, planeshade) << COLORMAPSHIFT); - } - else - { - lstep = (lend - lval) / width; - if (lval >= MAXLIGHTVIS) - { // lval starts "too bright". - lightfiller = basecolormapdata + (GETPALOOKUP(lval, planeshade) << COLORMAPSHIFT); - for (; i <= width && lval >= MAXLIGHTVIS; ++i) - { - tiltlighting[i] = lightfiller; - lval += lstep; - } - } - if (lend >= MAXLIGHTVIS) - { // lend ends "too bright". - lightfiller = basecolormapdata + (GETPALOOKUP(lend, planeshade) << COLORMAPSHIFT); - for (; width > i && lend >= MAXLIGHTVIS; --width) - { - tiltlighting[width] = lightfiller; - lend -= lstep; - } - } - if (width > 0) - { - lval = FIXED2DBL(planeshade) - lval; - lend = FIXED2DBL(planeshade) - lend; - lstep = (lend - lval) / width; - if (lstep < 0) - { // Going from dark to light - if (lval < 1.) - { // All bright - lightfiller = basecolormapdata; - } - else - { - if (lval >= NUMCOLORMAPS) - { // Starts beyond the dark end - BYTE *clight = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT); - while (lval >= NUMCOLORMAPS && i <= width) - { - tiltlighting[i++] = clight; - lval += lstep; - } - if (i > width) - return; - } - while (i <= width && lval >= 0) - { - tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT); - lval += lstep; - } - lightfiller = basecolormapdata; - } - } - else - { // Going from light to dark - if (lval >= (NUMCOLORMAPS-1)) - { // All dark - lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT); - } - else - { - while (lval < 0 && i <= width) - { - tiltlighting[i++] = basecolormapdata; - lval += lstep; - } - if (i > width) - return; - while (i <= width && lval < (NUMCOLORMAPS-1)) - { - tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT); - lval += lstep; - } - lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT); - } - } - } - } - for (; i <= width; i++) - { - tiltlighting[i] = lightfiller; - } -} -} // extern "C" - //========================================================================== // // R_MapTiltedPlane // //========================================================================== -void R_MapTiltedPlane_C (int y, int x1) -{ - int x2 = spanend[y]; - int width = x2 - x1; - double iz, uz, vz; - BYTE *fb; - DWORD u, v; - int i; - - iz = plane_sz[2] + plane_sz[1] * (centery - y) + plane_sz[0] * (x1 - centerx); - - // Lighting is simple. It's just linear interpolation from start to end - if (plane_shade) - { - uz = (iz + plane_sz[0] * width) * planelightfloat; - vz = iz * planelightfloat; - R_CalcTiltedLighting(vz, uz, width); - } - - uz = plane_su[2] + plane_su[1] * (centery - y) + plane_su[0] * (x1 - centerx); - vz = plane_sv[2] + plane_sv[1] * (centery - y) + plane_sv[0] * (x1 - centerx); - - fb = ylookup[y] + x1 + dc_destorg; - - BYTE vshift = 32 - ds_ybits; - BYTE ushift = vshift - ds_xbits; - int umask = ((1 << ds_xbits) - 1) << ds_ybits; - -#if 0 // The "perfect" reference version of this routine. Pretty slow. - // Use it only to see how things are supposed to look. - i = 0; - do - { - double z = 1.f/iz; - - u = SQWORD(uz*z) + pviewx; - v = SQWORD(vz*z) + pviewy; - R_SetDSColorMapLight(tiltlighting[i], 0, 0); - fb[i++] = ds_colormap[ds_source[(v >> vshift) | ((u >> ushift) & umask)]]; - iz += plane_sz[0]; - uz += plane_su[0]; - vz += plane_sv[0]; - } while (--width >= 0); -#else -//#define SPANSIZE 32 -//#define INVSPAN 0.03125f -//#define SPANSIZE 8 -//#define INVSPAN 0.125f -#define SPANSIZE 16 -#define INVSPAN 0.0625f - - double startz = 1.f/iz; - double startu = uz*startz; - double startv = vz*startz; - double izstep, uzstep, vzstep; - - izstep = plane_sz[0] * SPANSIZE; - uzstep = plane_su[0] * SPANSIZE; - vzstep = plane_sv[0] * SPANSIZE; - x1 = 0; - width++; - - while (width >= SPANSIZE) - { - iz += izstep; - uz += uzstep; - vz += vzstep; - - double endz = 1.f/iz; - double endu = uz*endz; - double endv = vz*endz; - DWORD stepu = SQWORD((endu - startu) * INVSPAN); - DWORD stepv = SQWORD((endv - startv) * INVSPAN); - u = SQWORD(startu) + pviewx; - v = SQWORD(startv) + pviewy; - - for (i = SPANSIZE-1; i >= 0; i--) - { - fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); - x1++; - u += stepu; - v += stepv; - } - startu = endu; - startv = endv; - width -= SPANSIZE; - } - if (width > 0) - { - if (width == 1) - { - u = SQWORD(startu); - v = SQWORD(startv); - fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); - } - else - { - double left = width; - iz += plane_sz[0] * left; - uz += plane_su[0] * left; - vz += plane_sv[0] * left; - - double endz = 1.f/iz; - double endu = uz*endz; - double endv = vz*endz; - left = 1.f/left; - DWORD stepu = SQWORD((endu - startu) * left); - DWORD stepv = SQWORD((endv - startv) * left); - u = SQWORD(startu) + pviewx; - v = SQWORD(startv) + pviewy; - - for (; width != 0; width--) - { - fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]); - x1++; - u += stepu; - v += stepv; - } - } - } -#endif -} - void R_MapTiltedPlane (int y, int x1) { R_DrawTiltedSpan(y, x1, spanend[y], plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); @@ -1779,13 +1535,6 @@ void R_DrawSkyPlane (visplane_t *pl) void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked) { -#ifdef X86_ASM - if (!r_swtruecolor && ds_source != ds_cursource) - { - R_SetSpanSource_ASM (ds_source); - } -#endif - if (alpha <= 0) { return; @@ -2036,14 +1785,6 @@ void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t plane_shade = true; } - if (!plane_shade) - { - for (int i = 0; i < viewwidth; ++i) - { - tiltlighting[i] = ds_colormap; - } - } - // Hack in support for 1 x Z and Z x 1 texture sizes if (ds_ybits == 0) { @@ -2053,20 +1794,8 @@ void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t { plane_su[2] = plane_su[1] = plane_su[0] = 0; } -#if defined(X86_ASM) - if (!r_swtruecolor) - { - if (ds_source != ds_curtiltedsource) - R_SetTiltedSpanSource_ASM(ds_source); - R_MapVisPlane(pl, R_DrawTiltedPlane_ASM); - } - else - { - R_MapVisPlane(pl, R_MapTiltedPlane); - } -#else + R_MapVisPlane (pl, R_MapTiltedPlane); -#endif } //========================================================================== diff --git a/src/r_thread.h b/src/r_thread.h index 9a8a5c1b5..dbdbf1dde 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -54,12 +54,17 @@ public: int pass_start_y = 0; int pass_end_y = MAXHEIGHT; + // Working buffer used by Rt drawers uint8_t dc_temp_buff[MAXHEIGHT * 4]; uint8_t *dc_temp = nullptr; + // Working buffer used by Rt drawers, true color edition uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT * 4]; uint32_t *dc_temp_rgba = nullptr; + // Working buffer used by the tilted (sloped) span drawer + const uint8_t *tiltlighting[MAXWIDTH]; + // Checks if a line is rendered by this thread bool line_skipped_by_thread(int line) { From 7441521a9604be309ff5d8321cde0a45d64a59b1 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 6 Dec 2016 19:44:56 +0100 Subject: [PATCH 1368/1509] Remove comment about Build code as it is no longer correct (there's no build code left in that file) --- src/r_segs.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 44e6f906f..efc894fc2 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -17,12 +17,6 @@ // DESCRIPTION: // All the clipping: columns, horizontal spans, sky columns. // -// This file contains some code from the Build Engine. -// -// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman -// Ken Silverman's official web site: "http://www.advsys.net/ken" -// See the included license file "BUILDLIC.TXT" for license info. -// //----------------------------------------------------------------------------- #include From 0083c3c5f0eadbf787bdc174475fdde5abbbeeb3 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 6 Dec 2016 21:41:41 +0100 Subject: [PATCH 1369/1509] Fix some typos --- src/r_draw_pal.cpp | 14 +++++++------- src/r_draw_pal.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 810192b96..0264dcbf9 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -1836,7 +1836,7 @@ namespace swrenderer void DrawSpanPalCommand::Execute(DrawerThread *thread) { - if (thread->skipped_by_thread(_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1900,7 +1900,7 @@ namespace swrenderer void DrawSpanMaskedPalCommand::Execute(DrawerThread *thread) { - if (thread->skipped_by_thread(_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -1965,7 +1965,7 @@ namespace swrenderer void DrawSpanTranslucentPalCommand::Execute(DrawerThread *thread) { - if (thread->skipped_by_thread(_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -2028,7 +2028,7 @@ namespace swrenderer void DrawSpanMaskedTranslucentPalCommand::Execute(DrawerThread *thread) { - if (thread->skipped_by_thread(_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -2105,7 +2105,7 @@ namespace swrenderer void DrawSpanAddClampPalCommand::Execute(DrawerThread *thread) { - if (thread->skipped_by_thread(_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -2174,7 +2174,7 @@ namespace swrenderer void DrawSpanMaskedAddClampPalCommand::Execute(DrawerThread *thread) { - if (thread->skipped_by_thread(_y)) + if (thread->line_skipped_by_thread(_y)) return; dsfixed_t xfrac; @@ -2257,7 +2257,7 @@ namespace swrenderer void FillSpanPalCommand::Execute(DrawerThread *thread) { - if (thread->skipped_by_thread(_y)) + if (thread->line_skipped_by_thread(_y)) return; memset(ylookup[_y] + _x1 + _destorg, _color, _x2 - _x1 + 1); diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index 93c24857b..a2400d275 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -279,7 +279,7 @@ namespace swrenderer { public: void Execute(DrawerThread *thread) override; - FString DebugInfo() override { return "FillColumnHorizPalCommand"; } + FString DebugInfo() override { return "DrawColumnHorizPalCommand"; } }; class FillColumnHorizPalCommand : public PalColumnHorizCommand From 3fd4d00a7724816f1c4c2238994ef79f813e0bc9 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 6 Dec 2016 18:13:41 -0500 Subject: [PATCH 1370/1509] - 1.2pre tag --- src/version.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/version.h b/src/version.h index 37f3b1dd4..6e2822492 100644 --- a/src/version.h +++ b/src/version.h @@ -41,17 +41,17 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "1.1pre" +#define VERSIONSTR "1.2pre" // The version as seen in the Windows resource -#define RC_FILEVERSION 1,0,9999,0 -#define RC_PRODUCTVERSION 1,0,9999,0 -#define RC_PRODUCTVERSION2 "1.1pre" +#define RC_FILEVERSION 1,1,9999,0 +#define RC_PRODUCTVERSION 1,1,9999,0 +#define RC_PRODUCTVERSION2 "1.2pre" // Version identifier for network games. // Bump it every time you do a release unless you're certain you // didn't change anything that will affect sync. -#define NETGAMEVERSION 234 +#define NETGAMEVERSION 235 // Version stored in the ini's [LastRun] section. // Bump it if you made some configuration change that you want to From 8a23befd4d64d0c032061d7f8f8270fc10d3591c Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 6 Dec 2016 18:22:36 -0500 Subject: [PATCH 1371/1509] - Fixed abstract class macro in SDLGLFB class. --- src/posix/sdl/sdlglvideo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 7e6dd8930..7858fdad9 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -29,7 +29,7 @@ // TYPES ------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(SDLGLFB, false, false, false, false) +IMPLEMENT_CLASS(SDLGLFB, true, false) struct MiniModeInfo { From c04e0d0df362cec661e9d8516d0bee73dfd05fc2 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 6 Dec 2016 18:44:59 -0500 Subject: [PATCH 1372/1509] - fixed: Whoops. One of those danged macros got away. ;) --- src/gl/system/gl_swframebuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 6b3caa81e..5f142d30c 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -115,7 +115,7 @@ DFrameBuffer *CreateGLSWFrameBuffer(int width, int height, bool bgra, bool fulls } #endif -IMPLEMENT_CLASS(OpenGLSWFrameBuffer) +IMPLEMENT_CLASS(OpenGLSWFrameBuffer, false, false) const char *const OpenGLSWFrameBuffer::ShaderDefines[OpenGLSWFrameBuffer::NUM_SHADERS] = { From 56f67726f021a5ce182ce21e8bb1800717b62612 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 7 Dec 2016 00:54:40 +0100 Subject: [PATCH 1373/1509] - seems a Linux file was missed when refactoring the IMPLEMENT_CLASS macros. --- src/posix/sdl/sdlglvideo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 7eabfcd6a..61f4a7725 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -29,7 +29,7 @@ // TYPES ------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(SDLGLFB, false, false, false, false) +IMPLEMENT_CLASS(SDLGLFB, false, false) struct MiniModeInfo { From 2200f6eda3451c173a28270c148602b8df8a55e0 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 7 Dec 2016 05:05:51 -0500 Subject: [PATCH 1374/1509] - fixed: compile error with SDLGLVideo class macro --- src/posix/sdl/sdlglvideo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 61f4a7725..290dfd6a1 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -29,7 +29,7 @@ // TYPES ------------------------------------------------------------------- -IMPLEMENT_CLASS(SDLGLFB, false, false) +IMPLEMENT_CLASS(SDLGLFB, true, false) struct MiniModeInfo { From e3e90e1a085c85513a53fafbfa3d0a9d1b7457a9 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 7 Dec 2016 18:28:06 +0100 Subject: [PATCH 1375/1509] Merge TC handling back into r_draw --- src/r_draw.cpp | 590 +++++++++++++--- src/r_draw.h | 39 +- src/r_draw_tc.cpp | 1701 --------------------------------------------- src/r_draw_tc.h | 239 ------- 4 files changed, 518 insertions(+), 2051 deletions(-) delete mode 100644 src/r_draw_tc.cpp delete mode 100644 src/r_draw_tc.h diff --git a/src/r_draw.cpp b/src/r_draw.cpp index a2bf412e8..9a79779d8 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -16,6 +16,7 @@ #include "r_data/colormaps.h" #include "r_plane.h" #include "r_draw.h" +#include "r_draw_rgba.h" #include "r_draw_pal.h" #include "r_thread.h" @@ -42,6 +43,9 @@ namespace swrenderer { int dc_pitch; lighttable_t *dc_colormap; + FSWColormap *dc_fcolormap; + ShadeConstants dc_shade_constants; + fixed_t dc_light; int dc_x; int dc_yl; int dc_yh; @@ -78,6 +82,8 @@ namespace swrenderer int ds_x1; int ds_x2; lighttable_t * ds_colormap; + FSWColormap *ds_fcolormap; + ShadeConstants ds_shade_constants; dsfixed_t ds_light; dsfixed_t ds_xfrac; dsfixed_t ds_yfrac; @@ -88,7 +94,9 @@ namespace swrenderer fixed_t ds_alpha; double ds_lod; const uint8_t *ds_source; + bool ds_source_mipmapped; int ds_color; + bool drawer_needs_pal_input; unsigned int dc_tspans[4][MAXHEIGHT]; unsigned int *dc_ctspan[4]; unsigned int *horizspan[4]; @@ -199,6 +207,7 @@ namespace swrenderer colfunc = transcolfunc; hcolfunc_post1 = rt_tlate1col; hcolfunc_post4 = rt_tlate4cols; + drawer_needs_pal_input = true; } return true; } @@ -249,6 +258,7 @@ namespace swrenderer colfunc = R_DrawTlatedAddColumn; hcolfunc_post1 = rt_tlateadd1col; hcolfunc_post4 = rt_tlateadd4cols; + drawer_needs_pal_input = true; } } else @@ -270,6 +280,7 @@ namespace swrenderer colfunc = R_DrawAddClampTranslatedColumn; hcolfunc_post1 = rt_tlateaddclamp1col; hcolfunc_post4 = rt_tlateaddclamp4cols; + drawer_needs_pal_input = true; } } return true; @@ -292,6 +303,7 @@ namespace swrenderer colfunc = R_DrawSubClampTranslatedColumn; hcolfunc_post1 = rt_tlatesubclamp1col; hcolfunc_post4 = rt_tlatesubclamp4cols; + drawer_needs_pal_input = true; } return true; @@ -317,6 +329,7 @@ namespace swrenderer colfunc = R_DrawRevSubClampTranslatedColumn; hcolfunc_post1 = rt_tlaterevsubclamp1col; hcolfunc_post4 = rt_tlaterevsubclamp4cols; + drawer_needs_pal_input = true; } return true; @@ -346,6 +359,8 @@ namespace swrenderer fixed_t fglevel, bglevel; + drawer_needs_pal_input = false; + style.CheckFuzz(); if (style.BlendOp == STYLEOP_Shadow) @@ -376,7 +391,10 @@ namespace swrenderer FRemapTable *table = TranslationToTable(translation); if (table != NULL && !table->Inactive) { - dc_translation = table->Remap; + if (r_swtruecolor) + dc_translation = (uint8_t*)table->Palette; + else + dc_translation = table->Remap; } } } @@ -397,13 +415,19 @@ namespace swrenderer colfunc = R_DrawShadedColumn; hcolfunc_post1 = rt_shaded1col; hcolfunc_post4 = rt_shaded4cols; - dc_color = fixedcolormap ? fixedcolormap[APART(color)] : basecolormap->Maps[APART(color)]; - dc_colormap = (basecolormap = &ShadeFakeColormap[16 - alpha])->Maps; + drawer_needs_pal_input = true; + dc_color = fixedcolormap ? fixedcolormap->Maps[APART(color)] : basecolormap->Maps[APART(color)]; + basecolormap = &ShadeFakeColormap[16 - alpha]; if (fixedlightlev >= 0 && fixedcolormap == NULL) { - dc_colormap += fixedlightlev; + R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); } - return r_columnmethod ? DoDraw1 : DoDraw0; + else + { + R_SetColorMapLight(basecolormap, 0, 0); + } + bool active_columnmethod = r_columnmethod && !r_swtruecolor; + return active_columnmethod ? DoDraw1 : DoDraw0; } fglevel = GetAlpha(style.SrcAlpha, alpha); @@ -429,14 +453,15 @@ namespace swrenderer // with the alpha. dc_srccolor = ((((r*x) >> 4) << 20) | ((g*x) >> 4) | ((((b)*x) >> 4) << 10)) & 0x3feffbff; hcolfunc_pre = R_FillColumnHoriz; - R_SetColorMapLight(identitycolormap.Maps, 0, 0); + R_SetColorMapLight(&identitycolormap, 0, 0); } if (!R_SetBlendFunc(style.BlendOp, fglevel, bglevel, style.Flags)) { return DontDraw; } - return r_columnmethod ? DoDraw1 : DoDraw0; + bool active_columnmethod = r_columnmethod && !r_swtruecolor; + return active_columnmethod ? DoDraw1 : DoDraw0; } ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color) @@ -460,7 +485,10 @@ namespace swrenderer col = width + (col % width); } - return tex->GetColumn(col, nullptr); + if (r_swtruecolor) + return (const uint8_t *)tex->GetColumnBgra(col, nullptr); + else + return tex->GetColumn(col, nullptr); } bool R_GetTransMaskDrawers(fixed_t(**tmvline1)(), void(**tmvline4)()) @@ -507,25 +535,84 @@ namespace swrenderer drawerargs::tmvlinebits = fracbits; } - void R_SetColorMapLight(lighttable_t *base_colormap, float light, int shade) + void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade) { using namespace drawerargs; - dc_colormap = base_colormap + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); + dc_fcolormap = base_colormap; + if (r_swtruecolor) + { + dc_shade_constants.light_red = dc_fcolormap->Color.r * 256 / 255; + dc_shade_constants.light_green = dc_fcolormap->Color.g * 256 / 255; + dc_shade_constants.light_blue = dc_fcolormap->Color.b * 256 / 255; + dc_shade_constants.light_alpha = dc_fcolormap->Color.a * 256 / 255; + dc_shade_constants.fade_red = dc_fcolormap->Fade.r; + dc_shade_constants.fade_green = dc_fcolormap->Fade.g; + dc_shade_constants.fade_blue = dc_fcolormap->Fade.b; + dc_shade_constants.fade_alpha = dc_fcolormap->Fade.a; + dc_shade_constants.desaturate = MIN(abs(dc_fcolormap->Desaturate), 255) * 255 / 256; + dc_shade_constants.simple_shade = (dc_fcolormap->Color.d == 0x00ffffff && dc_fcolormap->Fade.d == 0x00000000 && dc_fcolormap->Desaturate == 0); + dc_colormap = base_colormap->Maps; + dc_light = LIGHTSCALE(light, shade); + } + else + { + dc_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); + } } - void R_SetDSColorMapLight(lighttable_t *base_colormap, float light, int shade) + void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade) { using namespace drawerargs; - ds_colormap = base_colormap + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); + ds_fcolormap = base_colormap; + if (r_swtruecolor) + { + ds_shade_constants.light_red = ds_fcolormap->Color.r * 256 / 255; + ds_shade_constants.light_green = ds_fcolormap->Color.g * 256 / 255; + ds_shade_constants.light_blue = ds_fcolormap->Color.b * 256 / 255; + ds_shade_constants.light_alpha = ds_fcolormap->Color.a * 256 / 255; + ds_shade_constants.fade_red = ds_fcolormap->Fade.r; + ds_shade_constants.fade_green = ds_fcolormap->Fade.g; + ds_shade_constants.fade_blue = ds_fcolormap->Fade.b; + ds_shade_constants.fade_alpha = ds_fcolormap->Fade.a; + ds_shade_constants.desaturate = MIN(abs(ds_fcolormap->Desaturate), 255) * 255 / 256; + ds_shade_constants.simple_shade = (ds_fcolormap->Color.d == 0x00ffffff && ds_fcolormap->Fade.d == 0x00000000 && ds_fcolormap->Desaturate == 0); + ds_colormap = base_colormap->Maps; + ds_light = LIGHTSCALE(light, shade); + } + else + { + ds_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); + } } void R_SetTranslationMap(lighttable_t *translation) { using namespace drawerargs; - dc_colormap = translation; + if (r_swtruecolor) + { + dc_fcolormap = nullptr; + dc_colormap = nullptr; + dc_translation = translation; + dc_shade_constants.light_red = 256; + dc_shade_constants.light_green = 256; + dc_shade_constants.light_blue = 256; + dc_shade_constants.light_alpha = 256; + dc_shade_constants.fade_red = 0; + dc_shade_constants.fade_green = 0; + dc_shade_constants.fade_blue = 0; + dc_shade_constants.fade_alpha = 256; + dc_shade_constants.desaturate = 0; + dc_shade_constants.simple_shade = true; + dc_light = 0; + } + else + { + dc_fcolormap = nullptr; + dc_colormap = translation; + } } void rt_initcols(uint8_t *buffer) @@ -535,7 +622,10 @@ namespace swrenderer for (int y = 3; y >= 0; y--) horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0]; - DrawerCommandQueue::QueueCommand(buffer); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(buffer); + else + DrawerCommandQueue::QueueCommand(buffer); } void rt_span_coverage(int x, int start, int stop) @@ -727,18 +817,17 @@ namespace swrenderer } } - void R_SetSpanColormap(lighttable_t *colormap) + void R_SetSpanColormap(FDynamicColormap *colormap, int shade) { - using namespace drawerargs; - - ds_colormap = colormap; + R_SetDSColorMapLight(colormap, 0, shade); } void R_SetSpanSource(FTexture *tex) { using namespace drawerargs; - ds_source = tex->GetPixels(); + ds_source = r_swtruecolor ? (const uint8_t*)tex->GetPixelsBgra() : tex->GetPixels(); + ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1; } ///////////////////////////////////////////////////////////////////////// @@ -756,7 +845,10 @@ namespace swrenderer (*span)[1] = dc_yh; *span += 2; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawColumnHoriz() @@ -772,168 +864,301 @@ namespace swrenderer (*span)[1] = dc_yh; *span += 2; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + { + if (drawer_needs_pal_input) + DrawerCommandQueue::QueueCommand>(); + else + DrawerCommandQueue::QueueCommand>(); + } + else + { + DrawerCommandQueue::QueueCommand(); + } } // Copies one span at hx to the screen at sx. void rt_copy1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Copies all four spans to the screen starting at sx. void rt_copy4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + { + // To do: we could do this with SSE using __m128i + rt_copy1col(0, sx, yl, yh); + rt_copy1col(1, sx + 1, yl, yh); + rt_copy1col(2, sx + 2, yl, yh); + rt_copy1col(3, sx + 3, yl, yh); + } + else + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } } // Maps one span at hx to the screen at sx. void rt_map1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Maps all four spans to the screen starting at sx. void rt_map4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Translates one span at hx to the screen at sx. void rt_tlate1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_map1col(hx, sx, yl, yh); + if (r_swtruecolor) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + else + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + rt_map1col(hx, sx, yl, yh); + } } // Translates all four spans to the screen starting at sx. void rt_tlate4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_map4cols(sx, yl, yh); + if (r_swtruecolor) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + else + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + rt_map4cols(sx, yl, yh); + } } // Adds one span at hx to the screen at sx without clamping. void rt_add1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Adds all four spans to the screen starting at sx without clamping. void rt_add4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Translates and adds one span at hx to the screen at sx without clamping. void rt_tlateadd1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_add1col(hx, sx, yl, yh); + if (r_swtruecolor) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + else + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + rt_add1col(hx, sx, yl, yh); + } } // Translates and adds all four spans to the screen starting at sx without clamping. void rt_tlateadd4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_add4cols(sx, yl, yh); + if (r_swtruecolor) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + else + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + rt_add4cols(sx, yl, yh); + } } // Shades one span at hx to the screen at sx. void rt_shaded1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Shades all four spans to the screen starting at sx. void rt_shaded4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Adds one span at hx to the screen at sx with clamping. void rt_addclamp1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Adds all four spans to the screen starting at sx with clamping. void rt_addclamp4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Translates and adds one span at hx to the screen at sx with clamping. void rt_tlateaddclamp1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_addclamp1col(hx, sx, yl, yh); + if (r_swtruecolor) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + else + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + rt_addclamp1col(hx, sx, yl, yh); + } } // Translates and adds all four spans to the screen starting at sx with clamping. void rt_tlateaddclamp4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_addclamp4cols(sx, yl, yh); + if (r_swtruecolor) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + else + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + rt_addclamp4cols(sx, yl, yh); + } } // Subtracts one span at hx to the screen at sx with clamping. void rt_subclamp1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Subtracts all four spans to the screen starting at sx with clamping. void rt_subclamp4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Translates and subtracts one span at hx to the screen at sx with clamping. void rt_tlatesubclamp1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_subclamp1col(hx, sx, yl, yh); + if (r_swtruecolor) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + else + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + rt_subclamp1col(hx, sx, yl, yh); + } } // Translates and subtracts all four spans to the screen starting at sx with clamping. void rt_tlatesubclamp4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_subclamp4cols(sx, yl, yh); + if (r_swtruecolor) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + else + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + rt_subclamp4cols(sx, yl, yh); + } } // Subtracts one span at hx from the screen at sx with clamping. void rt_revsubclamp1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); } // Subtracts all four spans from the screen starting at sx with clamping. void rt_revsubclamp4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + else + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); } // Translates and subtracts one span at hx from the screen at sx with clamping. void rt_tlaterevsubclamp1col(int hx, int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_revsubclamp1col(hx, sx, yl, yh); + if (r_swtruecolor) + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + } + else + { + DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); + rt_revsubclamp1col(hx, sx, yl, yh); + } } // Translates and subtracts all four spans from the screen starting at sx with clamping. void rt_tlaterevsubclamp4cols(int sx, int yl, int yh) { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_revsubclamp4cols(sx, yl, yh); + if (r_swtruecolor) + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + } + else + { + DrawerCommandQueue::QueueCommand(0, sx, yl, yh); + rt_revsubclamp4cols(sx, yl, yh); + } } uint32_t vlinec1() { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } @@ -942,7 +1167,10 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -952,7 +1180,10 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } @@ -961,7 +1192,10 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -971,7 +1205,10 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } @@ -980,7 +1217,10 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -990,7 +1230,10 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } @@ -999,7 +1242,10 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -1009,7 +1255,10 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } @@ -1018,7 +1267,10 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -1028,7 +1280,10 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } @@ -1037,7 +1292,10 @@ namespace swrenderer { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -1045,59 +1303,92 @@ namespace swrenderer void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) { - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + else + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); } void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom) { - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + else + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); } void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) { - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + else + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); } void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom) { - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); + else + DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); } void R_DrawColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_FillColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_FillAddColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_FillAddClampColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_FillSubClampColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_FillRevSubClampColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawFuzzColumn() { using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); dc_yl = MAX(dc_yl, 1); dc_yh = MIN(dc_yh, fuzzviewheight); @@ -1107,112 +1398,185 @@ namespace swrenderer void R_DrawAddColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawTranslatedColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawTlatedAddColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawShadedColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawAddClampColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawAddClampTranslatedColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSubClampColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSubClampTranslatedColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawRevSubClampColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawRevSubClampTranslatedColumn() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSpan() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSpanMasked() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSpanTranslucent() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSpanMaskedTranslucent() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSpanAddClamp() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawSpanMaskedAddClamp() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_FillSpan() { - DrawerCommandQueue::QueueCommand(); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) { - DrawerCommandQueue::QueueCommand(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); + else + DrawerCommandQueue::QueueCommand(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); } void R_DrawColoredSpan(int y, int x1, int x2) { - DrawerCommandQueue::QueueCommand(y, x1, x2); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(y, x1, x2); + else + DrawerCommandQueue::QueueCommand(y, x1, x2); } namespace { - const uint8_t *slab_colormap; + ShadeConstants slab_rgba_shade_constants; + const uint8_t *slab_rgba_colormap; + fixed_t slab_rgba_light; } - void R_SetupDrawSlab(uint8_t *colormap) + void R_SetupDrawSlab(FSWColormap *base_colormap, float light, int shade) { - slab_colormap = colormap; + slab_rgba_shade_constants.light_red = base_colormap->Color.r * 256 / 255; + slab_rgba_shade_constants.light_green = base_colormap->Color.g * 256 / 255; + slab_rgba_shade_constants.light_blue = base_colormap->Color.b * 256 / 255; + slab_rgba_shade_constants.light_alpha = base_colormap->Color.a * 256 / 255; + slab_rgba_shade_constants.fade_red = base_colormap->Fade.r; + slab_rgba_shade_constants.fade_green = base_colormap->Fade.g; + slab_rgba_shade_constants.fade_blue = base_colormap->Fade.b; + slab_rgba_shade_constants.fade_alpha = base_colormap->Fade.a; + slab_rgba_shade_constants.desaturate = MIN(abs(base_colormap->Desaturate), 255) * 255 / 256; + slab_rgba_shade_constants.simple_shade = (base_colormap->Color.d == 0x00ffffff && base_colormap->Fade.d == 0x00000000 && base_colormap->Desaturate == 0); + slab_rgba_colormap = base_colormap->Maps; + slab_rgba_light = LIGHTSCALE(light, shade); } void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p) { - DrawerCommandQueue::QueueCommand(dx, v, dy, vi, vptr, p, slab_colormap); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(dx, v, dy, vi, vptr, p, slab_rgba_shade_constants, slab_rgba_colormap, slab_rgba_light); + else + DrawerCommandQueue::QueueCommand(dx, v, dy, vi, vptr, p, slab_rgba_colormap); } void R_DrawFogBoundarySection(int y, int y2, int x1) @@ -1220,7 +1584,10 @@ namespace swrenderer for (; y < y2; ++y) { int x2 = spanend[y]; - DrawerCommandQueue::QueueCommand(y, x1, x2); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(y, x1, x2); + else + DrawerCommandQueue::QueueCommand(y, x1, x2); } } @@ -1244,7 +1611,7 @@ namespace swrenderer clearbufshort(spanend + t2, b2 - t2, x); } - R_SetColorMapLight(basecolormap->Maps, (float)light, wallshade); + R_SetColorMapLight(basecolormap, (float)light, wallshade); uint8_t *fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); @@ -1271,7 +1638,7 @@ namespace swrenderer clearbufshort(spanend + t2, b2 - t2, x); } rcolormap = lcolormap; - R_SetColorMapLight(basecolormap->Maps, (float)light, wallshade); + R_SetColorMapLight(basecolormap, (float)light, wallshade); fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); } else @@ -1282,13 +1649,19 @@ namespace swrenderer while (t2 < stop) { int y = t2++; - DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); + else + DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); } stop = MAX(b1, t2); while (b2 > stop) { int y = --b2; - DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); + if (r_swtruecolor) + DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); + else + DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); } } else @@ -1320,6 +1693,9 @@ namespace swrenderer void R_DrawParticle(vissprite_t *sprite) { - R_DrawParticle_C(sprite); + if (r_swtruecolor) + R_DrawParticle_rgba(sprite); + else + R_DrawParticle_C(sprite); } } diff --git a/src/r_draw.h b/src/r_draw.h index 40b332896..8c1af58fc 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -3,7 +3,13 @@ #include "r_defs.h" +struct FSWColormap; + EXTERN_CVAR(Bool, r_multithreaded); +EXTERN_CVAR(Bool, r_magfilter); +EXTERN_CVAR(Bool, r_minfilter); +EXTERN_CVAR(Bool, r_mipmap); +EXTERN_CVAR(Float, r_lod_bias); EXTERN_CVAR(Int, r_drawfuzz); EXTERN_CVAR(Bool, r_drawtrans); EXTERN_CVAR(Float, transsouls); @@ -13,12 +19,29 @@ namespace swrenderer { struct vissprite_t; + struct ShadeConstants + { + uint16_t light_alpha; + uint16_t light_red; + uint16_t light_green; + uint16_t light_blue; + uint16_t fade_alpha; + uint16_t fade_red; + uint16_t fade_green; + uint16_t fade_blue; + uint16_t desaturate; + bool simple_shade; + }; + extern double dc_texturemid; namespace drawerargs { extern int dc_pitch; extern lighttable_t *dc_colormap; + extern FSWColormap *dc_fcolormap; + extern ShadeConstants dc_shade_constants; + extern fixed_t dc_light; extern int dc_x; extern int dc_yl; extern int dc_yh; @@ -41,6 +64,8 @@ namespace swrenderer extern int dc_destheight; extern int dc_count; + extern bool drawer_needs_pal_input; + extern uint32_t vplce[4]; extern uint32_t vince[4]; extern uint8_t *palookupoffse[4]; @@ -57,6 +82,8 @@ namespace swrenderer extern int ds_x1; extern int ds_x2; extern lighttable_t * ds_colormap; + extern FSWColormap *ds_fcolormap; + extern ShadeConstants ds_shade_constants; extern dsfixed_t ds_light; extern dsfixed_t ds_xfrac; extern dsfixed_t ds_yfrac; @@ -67,6 +94,7 @@ namespace swrenderer extern fixed_t ds_alpha; extern double ds_lod; extern const uint8_t *ds_source; + extern bool ds_source_mipmapped; extern int ds_color; extern unsigned int dc_tspans[4][MAXHEIGHT]; @@ -86,6 +114,8 @@ namespace swrenderer extern int fuzzpos; extern int fuzzviewheight; + extern bool r_swtruecolor; + void R_InitColumnDrawers(); void R_InitShadeMaps(); void R_InitFuzzTable(int fuzzoff); @@ -162,7 +192,7 @@ namespace swrenderer void R_FillSpan(); void R_DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy); void R_DrawColoredSpan(int y, int x1, int x2); - void R_SetupDrawSlab(uint8_t *colormap); + void R_SetupDrawSlab(FSWColormap *base_colormap, float light, int shade); void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p); void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip); uint32_t vlinec1(); @@ -194,12 +224,13 @@ namespace swrenderer void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom); void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); - void R_SetColorMapLight(lighttable_t *base_colormap, float light, int shade); - void R_SetDSColorMapLight(lighttable_t *base_colormap, float light, int shade); + // Sets dc_colormap and dc_light to their appropriate values depending on the output format (pal vs true color) + void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade); + void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade); void R_SetTranslationMap(lighttable_t *translation); void R_SetupSpanBits(FTexture *tex); - void R_SetSpanColormap(lighttable_t *colormap); + void R_SetSpanColormap(FDynamicColormap *colormap, int shade); void R_SetSpanSource(FTexture *tex); void R_MapTiltedPlane(int y, int x1); diff --git a/src/r_draw_tc.cpp b/src/r_draw_tc.cpp deleted file mode 100644 index ec9129a89..000000000 --- a/src/r_draw_tc.cpp +++ /dev/null @@ -1,1701 +0,0 @@ - -#include - -#include "templates.h" -#include "doomdef.h" -#include "i_system.h" -#include "w_wad.h" -#include "r_local.h" -#include "v_video.h" -#include "doomstat.h" -#include "st_stuff.h" -#include "g_game.h" -#include "g_level.h" -#include "r_data/r_translate.h" -#include "v_palette.h" -#include "r_data/colormaps.h" -#include "r_plane.h" -#include "r_draw_tc.h" -#include "r_draw_rgba.h" -#include "r_draw_pal.h" -#include "r_thread.h" - -namespace swrenderer -{ - // Needed by R_DrawFogBoundary (which probably shouldn't be part of this file) - extern "C" short spanend[MAXHEIGHT]; - extern float rw_light; - extern float rw_lightstep; - extern int wallshade; - - double dc_texturemid; - - int ylookup[MAXHEIGHT]; - uint8_t shadetables[NUMCOLORMAPS * 16 * 256]; - FDynamicColormap ShadeFakeColormap[16]; - uint8_t identitymap[256]; - FDynamicColormap identitycolormap; - int fuzzoffset[FUZZTABLE + 1]; - int fuzzpos; - int fuzzviewheight; - - namespace drawerargs - { - int dc_pitch; - lighttable_t *dc_colormap; - FSWColormap *dc_fcolormap; - ShadeConstants dc_shade_constants; - fixed_t dc_light; - int dc_x; - int dc_yl; - int dc_yh; - fixed_t dc_iscale; - fixed_t dc_texturefrac; - uint32_t dc_textureheight; - int dc_color; - uint32_t dc_srccolor; - uint32_t dc_srccolor_bgra; - uint32_t *dc_srcblend; - uint32_t *dc_destblend; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - const uint8_t *dc_source; - const uint8_t *dc_source2; - uint32_t dc_texturefracx; - uint8_t *dc_translation; - uint8_t *dc_dest; - uint8_t *dc_destorg; - int dc_destheight; - int dc_count; - uint32_t vplce[4]; - uint32_t vince[4]; - uint8_t *palookupoffse[4]; - fixed_t palookuplight[4]; - const uint8_t *bufplce[4]; - const uint8_t *bufplce2[4]; - uint32_t buftexturefracx[4]; - uint32_t bufheight[4]; - int vlinebits; - int mvlinebits; - int tmvlinebits; - int ds_y; - int ds_x1; - int ds_x2; - lighttable_t * ds_colormap; - FSWColormap *ds_fcolormap; - ShadeConstants ds_shade_constants; - dsfixed_t ds_light; - dsfixed_t ds_xfrac; - dsfixed_t ds_yfrac; - dsfixed_t ds_xstep; - dsfixed_t ds_ystep; - int ds_xbits; - int ds_ybits; - fixed_t ds_alpha; - double ds_lod; - const uint8_t *ds_source; - bool ds_source_mipmapped; - int ds_color; - bool drawer_needs_pal_input; - unsigned int dc_tspans[4][MAXHEIGHT]; - unsigned int *dc_ctspan[4]; - unsigned int *horizspan[4]; - } - - void R_InitColumnDrawers() - { - colfunc = basecolfunc = R_DrawColumn; - fuzzcolfunc = R_DrawFuzzColumn; - transcolfunc = R_DrawTranslatedColumn; - spanfunc = R_DrawSpan; - hcolfunc_pre = R_DrawColumnHoriz; - hcolfunc_post1 = rt_map1col; - hcolfunc_post4 = rt_map4cols; - } - - void R_InitShadeMaps() - { - int i, j; - // set up shading tables for shaded columns - // 16 colormap sets, progressing from full alpha to minimum visible alpha - - uint8_t *table = shadetables; - - // Full alpha - for (i = 0; i < 16; ++i) - { - ShadeFakeColormap[i].Color = ~0u; - ShadeFakeColormap[i].Desaturate = ~0u; - ShadeFakeColormap[i].Next = NULL; - ShadeFakeColormap[i].Maps = table; - - for (j = 0; j < NUMCOLORMAPS; ++j) - { - int a = (NUMCOLORMAPS - j) * 256 / NUMCOLORMAPS * (16 - i); - for (int k = 0; k < 256; ++k) - { - uint8_t v = (((k + 2) * a) + 256) >> 14; - table[k] = MIN(v, 64); - } - table += 256; - } - } - for (i = 0; i < NUMCOLORMAPS * 16 * 256; ++i) - { - assert(shadetables[i] <= 64); - } - - // Set up a guaranteed identity map - for (i = 0; i < 256; ++i) - { - identitymap[i] = i; - } - } - - void R_InitFuzzTable(int fuzzoff) - { - /* - FUZZOFF,-FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, - FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, - FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF, - FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, - FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF, - FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF, - FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF - */ - - static const int8_t fuzzinit[FUZZTABLE] = { - 1,-1, 1,-1, 1, 1,-1, - 1, 1,-1, 1, 1, 1,-1, - 1, 1, 1,-1,-1,-1,-1, - 1,-1,-1, 1, 1, 1, 1,-1, - 1,-1, 1, 1,-1,-1, 1, - 1,-1,-1,-1,-1, 1, 1, - 1, 1,-1, 1, 1,-1, 1 - }; - - for (int i = 0; i < FUZZTABLE; i++) - { - fuzzoffset[i] = fuzzinit[i] * fuzzoff; - } - } - - namespace - { - bool R_SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags) - { - using namespace drawerargs; - - // r_drawtrans is a seriously bad thing to turn off. I wonder if I should - // just remove it completely. - if (!r_drawtrans || (op == STYLEOP_Add && fglevel == FRACUNIT && bglevel == 0 && !(flags & STYLEF_InvertSource))) - { - if (flags & STYLEF_ColorIsFixed) - { - colfunc = R_FillColumn; - hcolfunc_post1 = rt_copy1col; - hcolfunc_post4 = rt_copy4cols; - } - else if (dc_translation == NULL) - { - colfunc = basecolfunc; - hcolfunc_post1 = rt_map1col; - hcolfunc_post4 = rt_map4cols; - } - else - { - colfunc = transcolfunc; - hcolfunc_post1 = rt_tlate1col; - hcolfunc_post4 = rt_tlate4cols; - drawer_needs_pal_input = true; - } - return true; - } - if (flags & STYLEF_InvertSource) - { - dc_srcblend = Col2RGB8_Inverse[fglevel >> 10]; - dc_destblend = Col2RGB8_LessPrecision[bglevel >> 10]; - dc_srcalpha = fglevel; - dc_destalpha = bglevel; - } - else if (op == STYLEOP_Add && fglevel + bglevel <= FRACUNIT) - { - dc_srcblend = Col2RGB8[fglevel >> 10]; - dc_destblend = Col2RGB8[bglevel >> 10]; - dc_srcalpha = fglevel; - dc_destalpha = bglevel; - } - else - { - dc_srcblend = Col2RGB8_LessPrecision[fglevel >> 10]; - dc_destblend = Col2RGB8_LessPrecision[bglevel >> 10]; - dc_srcalpha = fglevel; - dc_destalpha = bglevel; - } - switch (op) - { - case STYLEOP_Add: - if (fglevel == 0 && bglevel == FRACUNIT) - { - return false; - } - if (fglevel + bglevel <= FRACUNIT) - { // Colors won't overflow when added - if (flags & STYLEF_ColorIsFixed) - { - colfunc = R_FillAddColumn; - hcolfunc_post1 = rt_add1col; - hcolfunc_post4 = rt_add4cols; - } - else if (dc_translation == NULL) - { - colfunc = R_DrawAddColumn; - hcolfunc_post1 = rt_add1col; - hcolfunc_post4 = rt_add4cols; - } - else - { - colfunc = R_DrawTlatedAddColumn; - hcolfunc_post1 = rt_tlateadd1col; - hcolfunc_post4 = rt_tlateadd4cols; - drawer_needs_pal_input = true; - } - } - else - { // Colors might overflow when added - if (flags & STYLEF_ColorIsFixed) - { - colfunc = R_FillAddClampColumn; - hcolfunc_post1 = rt_addclamp1col; - hcolfunc_post4 = rt_addclamp4cols; - } - else if (dc_translation == NULL) - { - colfunc = R_DrawAddClampColumn; - hcolfunc_post1 = rt_addclamp1col; - hcolfunc_post4 = rt_addclamp4cols; - } - else - { - colfunc = R_DrawAddClampTranslatedColumn; - hcolfunc_post1 = rt_tlateaddclamp1col; - hcolfunc_post4 = rt_tlateaddclamp4cols; - drawer_needs_pal_input = true; - } - } - return true; - - case STYLEOP_Sub: - if (flags & STYLEF_ColorIsFixed) - { - colfunc = R_FillSubClampColumn; - hcolfunc_post1 = rt_subclamp1col; - hcolfunc_post4 = rt_subclamp4cols; - } - else if (dc_translation == NULL) - { - colfunc = R_DrawSubClampColumn; - hcolfunc_post1 = rt_subclamp1col; - hcolfunc_post4 = rt_subclamp4cols; - } - else - { - colfunc = R_DrawSubClampTranslatedColumn; - hcolfunc_post1 = rt_tlatesubclamp1col; - hcolfunc_post4 = rt_tlatesubclamp4cols; - drawer_needs_pal_input = true; - } - return true; - - case STYLEOP_RevSub: - if (fglevel == 0 && bglevel == FRACUNIT) - { - return false; - } - if (flags & STYLEF_ColorIsFixed) - { - colfunc = R_FillRevSubClampColumn; - hcolfunc_post1 = rt_subclamp1col; - hcolfunc_post4 = rt_subclamp4cols; - } - else if (dc_translation == NULL) - { - colfunc = R_DrawRevSubClampColumn; - hcolfunc_post1 = rt_revsubclamp1col; - hcolfunc_post4 = rt_revsubclamp4cols; - } - else - { - colfunc = R_DrawRevSubClampTranslatedColumn; - hcolfunc_post1 = rt_tlaterevsubclamp1col; - hcolfunc_post4 = rt_tlaterevsubclamp4cols; - drawer_needs_pal_input = true; - } - return true; - - default: - return false; - } - } - - fixed_t GetAlpha(int type, fixed_t alpha) - { - switch (type) - { - case STYLEALPHA_Zero: return 0; - case STYLEALPHA_One: return OPAQUE; - case STYLEALPHA_Src: return alpha; - case STYLEALPHA_InvSrc: return OPAQUE - alpha; - default: return 0; - } - } - - FDynamicColormap *basecolormapsave; - } - - ESPSResult R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color) - { - using namespace drawerargs; - - fixed_t fglevel, bglevel; - - drawer_needs_pal_input = false; - - style.CheckFuzz(); - - if (style.BlendOp == STYLEOP_Shadow) - { - style = LegacyRenderStyles[STYLE_TranslucentStencil]; - alpha = TRANSLUC33; - color = 0; - } - - if (style.Flags & STYLEF_TransSoulsAlpha) - { - alpha = fixed_t(transsouls * OPAQUE); - } - else if (style.Flags & STYLEF_Alpha1) - { - alpha = FRACUNIT; - } - else - { - alpha = clamp(alpha, 0, OPAQUE); - } - - if (translation != -1) - { - dc_translation = NULL; - if (translation != 0) - { - FRemapTable *table = TranslationToTable(translation); - if (table != NULL && !table->Inactive) - { - if (r_swtruecolor) - dc_translation = (uint8_t*)table->Palette; - else - dc_translation = table->Remap; - } - } - } - basecolormapsave = basecolormap; - hcolfunc_pre = R_DrawColumnHoriz; - - // Check for special modes - if (style.BlendOp == STYLEOP_Fuzz) - { - colfunc = fuzzcolfunc; - return DoDraw0; - } - else if (style == LegacyRenderStyles[STYLE_Shaded]) - { - // Shaded drawer only gets 16 levels of alpha because it saves memory. - if ((alpha >>= 12) == 0) - return DontDraw; - colfunc = R_DrawShadedColumn; - hcolfunc_post1 = rt_shaded1col; - hcolfunc_post4 = rt_shaded4cols; - drawer_needs_pal_input = true; - dc_color = fixedcolormap ? fixedcolormap->Maps[APART(color)] : basecolormap->Maps[APART(color)]; - basecolormap = &ShadeFakeColormap[16 - alpha]; - if (fixedlightlev >= 0 && fixedcolormap == NULL) - { - R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); - } - else - { - R_SetColorMapLight(basecolormap, 0, 0); - } - bool active_columnmethod = r_columnmethod && !r_swtruecolor; - return active_columnmethod ? DoDraw1 : DoDraw0; - } - - fglevel = GetAlpha(style.SrcAlpha, alpha); - bglevel = GetAlpha(style.DestAlpha, alpha); - - if (style.Flags & STYLEF_ColorIsFixed) - { - uint32_t x = fglevel >> 10; - uint32_t r = RPART(color); - uint32_t g = GPART(color); - uint32_t b = BPART(color); - // dc_color is used by the rt_* routines. It is indexed into dc_srcblend. - dc_color = RGB32k.RGB[r >> 3][g >> 3][b >> 3]; - if (style.Flags & STYLEF_InvertSource) - { - r = 255 - r; - g = 255 - g; - b = 255 - b; - } - uint32_t alpha = clamp(fglevel >> (FRACBITS - 8), 0, 255); - dc_srccolor_bgra = (alpha << 24) | (r << 16) | (g << 8) | b; - // dc_srccolor is used by the R_Fill* routines. It is premultiplied - // with the alpha. - dc_srccolor = ((((r*x) >> 4) << 20) | ((g*x) >> 4) | ((((b)*x) >> 4) << 10)) & 0x3feffbff; - hcolfunc_pre = R_FillColumnHoriz; - R_SetColorMapLight(&identitycolormap, 0, 0); - } - - if (!R_SetBlendFunc(style.BlendOp, fglevel, bglevel, style.Flags)) - { - return DontDraw; - } - bool active_columnmethod = r_columnmethod && !r_swtruecolor; - return active_columnmethod ? DoDraw1 : DoDraw0; - } - - ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color) - { - return R_SetPatchStyle(style, FLOAT2FIXED(alpha), translation, color); - } - - void R_FinishSetPatchStyle() - { - basecolormap = basecolormapsave; - } - - const uint8_t *R_GetColumn(FTexture *tex, int col) - { - int width; - - // If the texture's width isn't a power of 2, then we need to make it a - // positive offset for proper clamping. - if (col < 0 && (width = tex->GetWidth()) != (1 << tex->WidthBits)) - { - col = width + (col % width); - } - - if (r_swtruecolor) - return (const uint8_t *)tex->GetColumnBgra(col, nullptr); - else - return tex->GetColumn(col, nullptr); - } - - bool R_GetTransMaskDrawers(fixed_t(**tmvline1)(), void(**tmvline4)()) - { - if (colfunc == R_DrawAddColumn) - { - *tmvline1 = tmvline1_add; - *tmvline4 = tmvline4_add; - return true; - } - if (colfunc == R_DrawAddClampColumn) - { - *tmvline1 = tmvline1_addclamp; - *tmvline4 = tmvline4_addclamp; - return true; - } - if (colfunc == R_DrawSubClampColumn) - { - *tmvline1 = tmvline1_subclamp; - *tmvline4 = tmvline4_subclamp; - return true; - } - if (colfunc == R_DrawRevSubClampColumn) - { - *tmvline1 = tmvline1_revsubclamp; - *tmvline4 = tmvline4_revsubclamp; - return true; - } - return false; - } - - void setupvline(int fracbits) - { - drawerargs::vlinebits = fracbits; - } - - void setupmvline(int fracbits) - { - drawerargs::mvlinebits = fracbits; - } - - void setuptmvline(int fracbits) - { - drawerargs::tmvlinebits = fracbits; - } - - void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade) - { - using namespace drawerargs; - - dc_fcolormap = base_colormap; - if (r_swtruecolor) - { - dc_shade_constants.light_red = dc_fcolormap->Color.r * 256 / 255; - dc_shade_constants.light_green = dc_fcolormap->Color.g * 256 / 255; - dc_shade_constants.light_blue = dc_fcolormap->Color.b * 256 / 255; - dc_shade_constants.light_alpha = dc_fcolormap->Color.a * 256 / 255; - dc_shade_constants.fade_red = dc_fcolormap->Fade.r; - dc_shade_constants.fade_green = dc_fcolormap->Fade.g; - dc_shade_constants.fade_blue = dc_fcolormap->Fade.b; - dc_shade_constants.fade_alpha = dc_fcolormap->Fade.a; - dc_shade_constants.desaturate = MIN(abs(dc_fcolormap->Desaturate), 255) * 255 / 256; - dc_shade_constants.simple_shade = (dc_fcolormap->Color.d == 0x00ffffff && dc_fcolormap->Fade.d == 0x00000000 && dc_fcolormap->Desaturate == 0); - dc_colormap = base_colormap->Maps; - dc_light = LIGHTSCALE(light, shade); - } - else - { - dc_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); - } - } - - void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade) - { - using namespace drawerargs; - - ds_fcolormap = base_colormap; - if (r_swtruecolor) - { - ds_shade_constants.light_red = ds_fcolormap->Color.r * 256 / 255; - ds_shade_constants.light_green = ds_fcolormap->Color.g * 256 / 255; - ds_shade_constants.light_blue = ds_fcolormap->Color.b * 256 / 255; - ds_shade_constants.light_alpha = ds_fcolormap->Color.a * 256 / 255; - ds_shade_constants.fade_red = ds_fcolormap->Fade.r; - ds_shade_constants.fade_green = ds_fcolormap->Fade.g; - ds_shade_constants.fade_blue = ds_fcolormap->Fade.b; - ds_shade_constants.fade_alpha = ds_fcolormap->Fade.a; - ds_shade_constants.desaturate = MIN(abs(ds_fcolormap->Desaturate), 255) * 255 / 256; - ds_shade_constants.simple_shade = (ds_fcolormap->Color.d == 0x00ffffff && ds_fcolormap->Fade.d == 0x00000000 && ds_fcolormap->Desaturate == 0); - ds_colormap = base_colormap->Maps; - ds_light = LIGHTSCALE(light, shade); - } - else - { - ds_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); - } - } - - void R_SetTranslationMap(lighttable_t *translation) - { - using namespace drawerargs; - - if (r_swtruecolor) - { - dc_fcolormap = nullptr; - dc_colormap = nullptr; - dc_translation = translation; - dc_shade_constants.light_red = 256; - dc_shade_constants.light_green = 256; - dc_shade_constants.light_blue = 256; - dc_shade_constants.light_alpha = 256; - dc_shade_constants.fade_red = 0; - dc_shade_constants.fade_green = 0; - dc_shade_constants.fade_blue = 0; - dc_shade_constants.fade_alpha = 256; - dc_shade_constants.desaturate = 0; - dc_shade_constants.simple_shade = true; - dc_light = 0; - } - else - { - dc_fcolormap = nullptr; - dc_colormap = translation; - } - } - - void rt_initcols(uint8_t *buffer) - { - using namespace drawerargs; - - for (int y = 3; y >= 0; y--) - horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0]; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(buffer); - else - DrawerCommandQueue::QueueCommand(buffer); - } - - void rt_span_coverage(int x, int start, int stop) - { - using namespace drawerargs; - - unsigned int **tspan = &dc_ctspan[x & 3]; - (*tspan)[0] = start; - (*tspan)[1] = stop; - *tspan += 2; - } - - void rt_flip_posts() - { - using namespace drawerargs; - - unsigned int *front = horizspan[dc_x & 3]; - unsigned int *back = dc_ctspan[dc_x & 3] - 2; - - while (front < back) - { - swapvalues(front[0], back[0]); - swapvalues(front[1], back[1]); - front += 2; - back -= 2; - } - } - - void rt_draw4cols(int sx) - { - using namespace drawerargs; - - int x, bad; - unsigned int maxtop, minbot, minnexttop; - - // Place a dummy "span" in each column. These don't get - // drawn. They're just here to avoid special cases in the - // max/min calculations below. - for (x = 0; x < 4; ++x) - { - dc_ctspan[x][0] = screen->GetHeight()+1; - dc_ctspan[x][1] = screen->GetHeight(); - } - - for (;;) - { - // If a column is out of spans, mark it as such - bad = 0; - minnexttop = 0xffffffff; - for (x = 0; x < 4; ++x) - { - if (horizspan[x] >= dc_ctspan[x]) - { - bad |= 1 << x; - } - else if ((horizspan[x]+2)[0] < minnexttop) - { - minnexttop = (horizspan[x]+2)[0]; - } - } - // Once all columns are out of spans, we're done - if (bad == 15) - { - return; - } - - // Find the largest shared area for the spans in each column - maxtop = MAX (MAX (horizspan[0][0], horizspan[1][0]), - MAX (horizspan[2][0], horizspan[3][0])); - minbot = MIN (MIN (horizspan[0][1], horizspan[1][1]), - MIN (horizspan[2][1], horizspan[3][1])); - - // If there is no shared area with these spans, draw each span - // individually and advance to the next spans until we reach a shared area. - // However, only draw spans down to the highest span in the next set of - // spans. If we allow the entire height of a span to be drawn, it could - // prevent any more shared areas from being drawn in these four columns. - // - // Example: Suppose we have the following arrangement: - // A CD - // A CD - // B D - // B D - // aB D - // aBcD - // aBcD - // aBc - // - // If we draw the entire height of the spans, we end up drawing this first: - // A CD - // A CD - // B D - // B D - // B D - // B D - // B D - // B D - // B - // - // This leaves only the "a" and "c" columns to be drawn, and they are not - // part of a shared area, but if we can include B and D with them, we can - // get a shared area. So we cut off everything in the first set just - // above the "a" column and end up drawing this first: - // A CD - // A CD - // B D - // B D - // - // Then the next time through, we have the following arrangement with an - // easily shared area to draw: - // aB D - // aBcD - // aBcD - // aBc - if (bad != 0 || maxtop > minbot) - { - int drawcount = 0; - for (x = 0; x < 4; ++x) - { - if (!(bad & 1)) - { - if (horizspan[x][1] < minnexttop) - { - hcolfunc_post1 (x, sx+x, horizspan[x][0], horizspan[x][1]); - horizspan[x] += 2; - drawcount++; - } - else if (minnexttop > horizspan[x][0]) - { - hcolfunc_post1 (x, sx+x, horizspan[x][0], minnexttop-1); - horizspan[x][0] = minnexttop; - drawcount++; - } - } - bad >>= 1; - } - // Drawcount *should* always be non-zero. The reality is that some situations - // can make this not true. Unfortunately, I'm not sure what those situations are. - if (drawcount == 0) - { - return; - } - continue; - } - - // Draw any span fragments above the shared area. - for (x = 0; x < 4; ++x) - { - if (maxtop > horizspan[x][0]) - { - hcolfunc_post1 (x, sx+x, horizspan[x][0], maxtop-1); - } - } - - // Draw the shared area. - hcolfunc_post4 (sx, maxtop, minbot); - - // For each column, if part of the span is past the shared area, - // set its top to just below the shared area. Otherwise, advance - // to the next span in that column. - for (x = 0; x < 4; ++x) - { - if (minbot < horizspan[x][1]) - { - horizspan[x][0] = minbot+1; - } - else - { - horizspan[x] += 2; - } - } - } - } - - void R_SetupSpanBits(FTexture *tex) - { - using namespace drawerargs; - - tex->GetWidth(); - ds_xbits = tex->WidthBits; - ds_ybits = tex->HeightBits; - if ((1 << ds_xbits) > tex->GetWidth()) - { - ds_xbits--; - } - if ((1 << ds_ybits) > tex->GetHeight()) - { - ds_ybits--; - } - } - - void R_SetSpanColormap(FDynamicColormap *colormap, int shade) - { - R_SetDSColorMapLight(colormap, 0, shade); - } - - void R_SetSpanSource(FTexture *tex) - { - using namespace drawerargs; - - ds_source = r_swtruecolor ? (const uint8_t*)tex->GetPixelsBgra() : tex->GetPixels(); - ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1; - } - - ///////////////////////////////////////////////////////////////////////// - - void R_FillColumnHoriz() - { - using namespace drawerargs; - - if (dc_count <= 0) - return; - - int x = dc_x & 3; - unsigned int **span = &dc_ctspan[x]; - (*span)[0] = dc_yl; - (*span)[1] = dc_yh; - *span += 2; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawColumnHoriz() - { - using namespace drawerargs; - - if (dc_count <= 0) - return; - - int x = dc_x & 3; - unsigned int **span = &dc_ctspan[x]; - (*span)[0] = dc_yl; - (*span)[1] = dc_yh; - *span += 2; - - if (r_swtruecolor) - { - if (drawer_needs_pal_input) - DrawerCommandQueue::QueueCommand>(); - else - DrawerCommandQueue::QueueCommand>(); - } - else - { - DrawerCommandQueue::QueueCommand(); - } - } - - // Copies one span at hx to the screen at sx. - void rt_copy1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - - // Copies all four spans to the screen starting at sx. - void rt_copy4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - { - // To do: we could do this with SSE using __m128i - rt_copy1col(0, sx, yl, yh); - rt_copy1col(1, sx + 1, yl, yh); - rt_copy1col(2, sx + 2, yl, yh); - rt_copy1col(3, sx + 3, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - } - - // Maps one span at hx to the screen at sx. - void rt_map1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - - // Maps all four spans to the screen starting at sx. - void rt_map4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - - // Translates one span at hx to the screen at sx. - void rt_tlate1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_map1col(hx, sx, yl, yh); - } - } - - // Translates all four spans to the screen starting at sx. - void rt_tlate4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_map4cols(sx, yl, yh); - } - } - - // Adds one span at hx to the screen at sx without clamping. - void rt_add1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - - // Adds all four spans to the screen starting at sx without clamping. - void rt_add4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - - // Translates and adds one span at hx to the screen at sx without clamping. - void rt_tlateadd1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_add1col(hx, sx, yl, yh); - } - } - - // Translates and adds all four spans to the screen starting at sx without clamping. - void rt_tlateadd4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_add4cols(sx, yl, yh); - } - } - - // Shades one span at hx to the screen at sx. - void rt_shaded1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - - // Shades all four spans to the screen starting at sx. - void rt_shaded4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - - // Adds one span at hx to the screen at sx with clamping. - void rt_addclamp1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - - // Adds all four spans to the screen starting at sx with clamping. - void rt_addclamp4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - - // Translates and adds one span at hx to the screen at sx with clamping. - void rt_tlateaddclamp1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_addclamp1col(hx, sx, yl, yh); - } - } - - // Translates and adds all four spans to the screen starting at sx with clamping. - void rt_tlateaddclamp4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_addclamp4cols(sx, yl, yh); - } - } - - // Subtracts one span at hx to the screen at sx with clamping. - void rt_subclamp1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - - // Subtracts all four spans to the screen starting at sx with clamping. - void rt_subclamp4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - - // Translates and subtracts one span at hx to the screen at sx with clamping. - void rt_tlatesubclamp1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_subclamp1col(hx, sx, yl, yh); - } - } - - // Translates and subtracts all four spans to the screen starting at sx with clamping. - void rt_tlatesubclamp4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_subclamp4cols(sx, yl, yh); - } - } - - // Subtracts one span at hx from the screen at sx with clamping. - void rt_revsubclamp1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - - // Subtracts all four spans from the screen starting at sx with clamping. - void rt_revsubclamp4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - - // Translates and subtracts one span at hx from the screen at sx with clamping. - void rt_tlaterevsubclamp1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_revsubclamp1col(hx, sx, yl, yh); - } - } - - // Translates and subtracts all four spans from the screen starting at sx with clamping. - void rt_tlaterevsubclamp4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_revsubclamp4cols(sx, yl, yh); - } - } - - uint32_t vlinec1() - { - using namespace drawerargs; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - - return dc_texturefrac + dc_count * dc_iscale; - } - - void vlinec4() - { - using namespace drawerargs; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; - } - - uint32_t mvlinec1() - { - using namespace drawerargs; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - - return dc_texturefrac + dc_count * dc_iscale; - } - - void mvlinec4() - { - using namespace drawerargs; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; - } - - fixed_t tmvline1_add() - { - using namespace drawerargs; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - - return dc_texturefrac + dc_count * dc_iscale; - } - - void tmvline4_add() - { - using namespace drawerargs; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; - } - - fixed_t tmvline1_addclamp() - { - using namespace drawerargs; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - - return dc_texturefrac + dc_count * dc_iscale; - } - - void tmvline4_addclamp() - { - using namespace drawerargs; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; - } - - fixed_t tmvline1_subclamp() - { - using namespace drawerargs; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - - return dc_texturefrac + dc_count * dc_iscale; - } - - void tmvline4_subclamp() - { - using namespace drawerargs; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; - } - - fixed_t tmvline1_revsubclamp() - { - using namespace drawerargs; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - - return dc_texturefrac + dc_count * dc_iscale; - } - - void tmvline4_revsubclamp() - { - using namespace drawerargs; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; - } - - void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); - else - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); - } - - void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); - else - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); - } - - void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); - else - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); - } - - void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); - else - DrawerCommandQueue::QueueCommand(solid_top, solid_bottom); - } - - void R_DrawColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_FillColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_FillAddColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_FillAddClampColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_FillSubClampColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_FillRevSubClampColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawFuzzColumn() - { - using namespace drawerargs; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - - dc_yl = MAX(dc_yl, 1); - dc_yh = MIN(dc_yh, fuzzviewheight); - if (dc_yl <= dc_yh) - fuzzpos = (fuzzpos + dc_yh - dc_yl + 1) % FUZZTABLE; - } - - void R_DrawAddColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawTranslatedColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawTlatedAddColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawShadedColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawAddClampColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawAddClampTranslatedColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawSubClampColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawSubClampTranslatedColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawRevSubClampColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawRevSubClampTranslatedColumn() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawSpan() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawSpanMasked() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawSpanTranslucent() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawSpanMaskedTranslucent() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawSpanAddClamp() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawSpanMaskedAddClamp() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_FillSpan() - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); - else - DrawerCommandQueue::QueueCommand(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); - } - - void R_DrawColoredSpan(int y, int x1, int x2) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(y, x1, x2); - else - DrawerCommandQueue::QueueCommand(y, x1, x2); - } - - namespace - { - ShadeConstants slab_rgba_shade_constants; - const uint8_t *slab_rgba_colormap; - fixed_t slab_rgba_light; - } - - void R_SetupDrawSlab(FSWColormap *base_colormap, float light, int shade) - { - slab_rgba_shade_constants.light_red = base_colormap->Color.r * 256 / 255; - slab_rgba_shade_constants.light_green = base_colormap->Color.g * 256 / 255; - slab_rgba_shade_constants.light_blue = base_colormap->Color.b * 256 / 255; - slab_rgba_shade_constants.light_alpha = base_colormap->Color.a * 256 / 255; - slab_rgba_shade_constants.fade_red = base_colormap->Fade.r; - slab_rgba_shade_constants.fade_green = base_colormap->Fade.g; - slab_rgba_shade_constants.fade_blue = base_colormap->Fade.b; - slab_rgba_shade_constants.fade_alpha = base_colormap->Fade.a; - slab_rgba_shade_constants.desaturate = MIN(abs(base_colormap->Desaturate), 255) * 255 / 256; - slab_rgba_shade_constants.simple_shade = (base_colormap->Color.d == 0x00ffffff && base_colormap->Fade.d == 0x00000000 && base_colormap->Desaturate == 0); - slab_rgba_colormap = base_colormap->Maps; - slab_rgba_light = LIGHTSCALE(light, shade); - } - - void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(dx, v, dy, vi, vptr, p, slab_rgba_shade_constants, slab_rgba_colormap, slab_rgba_light); - else - DrawerCommandQueue::QueueCommand(dx, v, dy, vi, vptr, p, slab_rgba_colormap); - } - - void R_DrawFogBoundarySection(int y, int y2, int x1) - { - for (; y < y2; ++y) - { - int x2 = spanend[y]; - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(y, x1, x2); - else - DrawerCommandQueue::QueueCommand(y, x1, x2); - } - } - - void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip) - { - // This is essentially the same as R_MapVisPlane but with an extra step - // to create new horizontal spans whenever the light changes enough that - // we need to use a new colormap. - - double lightstep = rw_lightstep; - double light = rw_light + rw_lightstep*(x2 - x1 - 1); - int x = x2 - 1; - int t2 = uclip[x]; - int b2 = dclip[x]; - int rcolormap = GETPALOOKUP(light, wallshade); - int lcolormap; - uint8_t *basecolormapdata = basecolormap->Maps; - - if (b2 > t2) - { - clearbufshort(spanend + t2, b2 - t2, x); - } - - R_SetColorMapLight(basecolormap, (float)light, wallshade); - - uint8_t *fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); - - for (--x; x >= x1; --x) - { - int t1 = uclip[x]; - int b1 = dclip[x]; - const int xr = x + 1; - int stop; - - light -= rw_lightstep; - lcolormap = GETPALOOKUP(light, wallshade); - if (lcolormap != rcolormap) - { - if (t2 < b2 && rcolormap != 0) - { // Colormap 0 is always the identity map, so rendering it is - // just a waste of time. - R_DrawFogBoundarySection(t2, b2, xr); - } - if (t1 < t2) t2 = t1; - if (b1 > b2) b2 = b1; - if (t2 < b2) - { - clearbufshort(spanend + t2, b2 - t2, x); - } - rcolormap = lcolormap; - R_SetColorMapLight(basecolormap, (float)light, wallshade); - fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); - } - else - { - if (fake_dc_colormap != basecolormapdata) - { - stop = MIN(t1, b2); - while (t2 < stop) - { - int y = t2++; - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); - else - DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); - } - stop = MAX(b1, t2); - while (b2 > stop) - { - int y = --b2; - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); - else - DrawerCommandQueue::QueueCommand(y, xr, spanend[y]); - } - } - else - { - t2 = MAX(t2, MIN(t1, b2)); - b2 = MIN(b2, MAX(b1, t2)); - } - - stop = MIN(t2, b1); - while (t1 < stop) - { - spanend[t1++] = x; - } - stop = MAX(b2, t2); - while (b1 > stop) - { - spanend[--b1] = x; - } - } - - t2 = uclip[x]; - b2 = dclip[x]; - } - if (t2 < b2 && rcolormap != 0) - { - R_DrawFogBoundarySection(t2, b2, x1); - } - } - - void R_DrawParticle(vissprite_t *sprite) - { - if (r_swtruecolor) - R_DrawParticle_rgba(sprite); - else - R_DrawParticle_C(sprite); - } -} diff --git a/src/r_draw_tc.h b/src/r_draw_tc.h deleted file mode 100644 index 8c1af58fc..000000000 --- a/src/r_draw_tc.h +++ /dev/null @@ -1,239 +0,0 @@ - -#pragma once - -#include "r_defs.h" - -struct FSWColormap; - -EXTERN_CVAR(Bool, r_multithreaded); -EXTERN_CVAR(Bool, r_magfilter); -EXTERN_CVAR(Bool, r_minfilter); -EXTERN_CVAR(Bool, r_mipmap); -EXTERN_CVAR(Float, r_lod_bias); -EXTERN_CVAR(Int, r_drawfuzz); -EXTERN_CVAR(Bool, r_drawtrans); -EXTERN_CVAR(Float, transsouls); -EXTERN_CVAR(Int, r_columnmethod); - -namespace swrenderer -{ - struct vissprite_t; - - struct ShadeConstants - { - uint16_t light_alpha; - uint16_t light_red; - uint16_t light_green; - uint16_t light_blue; - uint16_t fade_alpha; - uint16_t fade_red; - uint16_t fade_green; - uint16_t fade_blue; - uint16_t desaturate; - bool simple_shade; - }; - - extern double dc_texturemid; - - namespace drawerargs - { - extern int dc_pitch; - extern lighttable_t *dc_colormap; - extern FSWColormap *dc_fcolormap; - extern ShadeConstants dc_shade_constants; - extern fixed_t dc_light; - extern int dc_x; - extern int dc_yl; - extern int dc_yh; - extern fixed_t dc_iscale; - extern fixed_t dc_texturefrac; - extern uint32_t dc_textureheight; - extern int dc_color; - extern uint32_t dc_srccolor; - extern uint32_t dc_srccolor_bgra; - extern uint32_t *dc_srcblend; - extern uint32_t *dc_destblend; - extern fixed_t dc_srcalpha; - extern fixed_t dc_destalpha; - extern const uint8_t *dc_source; - extern const uint8_t *dc_source2; - extern uint32_t dc_texturefracx; - extern uint8_t *dc_translation; - extern uint8_t *dc_dest; - extern uint8_t *dc_destorg; - extern int dc_destheight; - extern int dc_count; - - extern bool drawer_needs_pal_input; - - extern uint32_t vplce[4]; - extern uint32_t vince[4]; - extern uint8_t *palookupoffse[4]; - extern fixed_t palookuplight[4]; - extern const uint8_t *bufplce[4]; - extern const uint8_t *bufplce2[4]; - extern uint32_t buftexturefracx[4]; - extern uint32_t bufheight[4]; - extern int vlinebits; - extern int mvlinebits; - extern int tmvlinebits; - - extern int ds_y; - extern int ds_x1; - extern int ds_x2; - extern lighttable_t * ds_colormap; - extern FSWColormap *ds_fcolormap; - extern ShadeConstants ds_shade_constants; - extern dsfixed_t ds_light; - extern dsfixed_t ds_xfrac; - extern dsfixed_t ds_yfrac; - extern dsfixed_t ds_xstep; - extern dsfixed_t ds_ystep; - extern int ds_xbits; - extern int ds_ybits; - extern fixed_t ds_alpha; - extern double ds_lod; - extern const uint8_t *ds_source; - extern bool ds_source_mipmapped; - extern int ds_color; - - extern unsigned int dc_tspans[4][MAXHEIGHT]; - extern unsigned int *dc_ctspan[4]; - extern unsigned int *horizspan[4]; - } - - extern int ylookup[MAXHEIGHT]; - extern uint8_t shadetables[/*NUMCOLORMAPS*16*256*/]; - extern FDynamicColormap ShadeFakeColormap[16]; - extern uint8_t identitymap[256]; - extern FDynamicColormap identitycolormap; - - // Spectre/Invisibility. - #define FUZZTABLE 50 - extern int fuzzoffset[FUZZTABLE + 1]; - extern int fuzzpos; - extern int fuzzviewheight; - - extern bool r_swtruecolor; - - void R_InitColumnDrawers(); - void R_InitShadeMaps(); - void R_InitFuzzTable(int fuzzoff); - - enum ESPSResult - { - DontDraw, // not useful to draw this - DoDraw0, // draw this as if r_columnmethod is 0 - DoDraw1, // draw this as if r_columnmethod is 1 - }; - - ESPSResult R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color); - ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color); - void R_FinishSetPatchStyle(); // Call this after finished drawing the current thing, in case its style was STYLE_Shade - bool R_GetTransMaskDrawers(fixed_t(**tmvline1)(), void(**tmvline4)()); - - const uint8_t *R_GetColumn(FTexture *tex, int col); - void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn); - void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn); - void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn); - - void rt_initcols(uint8_t *buffer = nullptr); - void rt_span_coverage(int x, int start, int stop); - void rt_draw4cols(int sx); - void rt_flip_posts(); - void rt_copy1col(int hx, int sx, int yl, int yh); - void rt_copy4cols(int sx, int yl, int yh); - void rt_shaded1col(int hx, int sx, int yl, int yh); - void rt_shaded4cols(int sx, int yl, int yh); - void rt_map1col(int hx, int sx, int yl, int yh); - void rt_add1col(int hx, int sx, int yl, int yh); - void rt_addclamp1col(int hx, int sx, int yl, int yh); - void rt_subclamp1col(int hx, int sx, int yl, int yh); - void rt_revsubclamp1col(int hx, int sx, int yl, int yh); - void rt_tlate1col(int hx, int sx, int yl, int yh); - void rt_tlateadd1col(int hx, int sx, int yl, int yh); - void rt_tlateaddclamp1col(int hx, int sx, int yl, int yh); - void rt_tlatesubclamp1col(int hx, int sx, int yl, int yh); - void rt_tlaterevsubclamp1col(int hx, int sx, int yl, int yh); - void rt_map4cols(int sx, int yl, int yh); - void rt_add4cols(int sx, int yl, int yh); - void rt_addclamp4cols(int sx, int yl, int yh); - void rt_subclamp4cols(int sx, int yl, int yh); - void rt_revsubclamp4cols(int sx, int yl, int yh); - void rt_tlate4cols(int sx, int yl, int yh); - void rt_tlateadd4cols(int sx, int yl, int yh); - void rt_tlateaddclamp4cols(int sx, int yl, int yh); - void rt_tlatesubclamp4cols(int sx, int yl, int yh); - void rt_tlaterevsubclamp4cols(int sx, int yl, int yh); - void R_DrawColumnHoriz(); - void R_DrawColumn(); - void R_DrawFuzzColumn(); - void R_DrawTranslatedColumn(); - void R_DrawShadedColumn(); - void R_FillColumn(); - void R_FillAddColumn(); - void R_FillAddClampColumn(); - void R_FillSubClampColumn(); - void R_FillRevSubClampColumn(); - void R_DrawAddColumn(); - void R_DrawTlatedAddColumn(); - void R_DrawAddClampColumn(); - void R_DrawAddClampTranslatedColumn(); - void R_DrawSubClampColumn(); - void R_DrawSubClampTranslatedColumn(); - void R_DrawRevSubClampColumn(); - void R_DrawRevSubClampTranslatedColumn(); - void R_DrawSpan(); - void R_DrawSpanMasked(); - void R_DrawSpanTranslucent(); - void R_DrawSpanMaskedTranslucent(); - void R_DrawSpanAddClamp(); - void R_DrawSpanMaskedAddClamp(); - void R_FillSpan(); - void R_DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy); - void R_DrawColoredSpan(int y, int x1, int x2); - void R_SetupDrawSlab(FSWColormap *base_colormap, float light, int shade); - void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p); - void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip); - uint32_t vlinec1(); - void vlinec4(); - uint32_t mvlinec1(); - void mvlinec4(); - fixed_t tmvline1_add(); - void tmvline4_add(); - fixed_t tmvline1_addclamp(); - void tmvline4_addclamp(); - fixed_t tmvline1_subclamp(); - void tmvline4_subclamp(); - fixed_t tmvline1_revsubclamp(); - void tmvline4_revsubclamp(); - void R_FillColumnHoriz(); - void R_FillSpan(); - - inline uint32_t dovline1() { return vlinec1(); } - inline void dovline4() { vlinec4(); } - inline uint32_t domvline1() { return mvlinec1(); } - inline void domvline4() { mvlinec4(); } - - void setupvline(int fracbits); - void setupmvline(int fracbits); - void setuptmvline(int fracbits); - - void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom); - void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); - void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom); - void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); - - // Sets dc_colormap and dc_light to their appropriate values depending on the output format (pal vs true color) - void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade); - void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade); - void R_SetTranslationMap(lighttable_t *translation); - - void R_SetupSpanBits(FTexture *tex); - void R_SetSpanColormap(FDynamicColormap *colormap, int shade); - void R_SetSpanSource(FTexture *tex); - - void R_MapTiltedPlane(int y, int x1); - void R_MapColoredPlane(int y, int x1); - void R_DrawParticle(vissprite_t *); -} From 480b22c50eca98383fed42a938cb49d51d6af20d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 7 Dec 2016 18:59:48 +0100 Subject: [PATCH 1376/1509] Add more checks for FTexture::TEX_Null --- src/r_poly_sprite.cpp | 2 +- src/r_poly_wallsprite.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index c17bc5909..e5d8e0ce5 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -74,7 +74,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla bool flipTextureX = false; FTexture *tex = GetSpriteTexture(thing, flipTextureX); - if (tex == nullptr) + if (tex == nullptr || tex->UseType == FTexture::TEX_Null) return; DVector2 spriteScale = thing->Scale; diff --git a/src/r_poly_wallsprite.cpp b/src/r_poly_wallsprite.cpp index 0521fb06e..e7fe267b8 100644 --- a/src/r_poly_wallsprite.cpp +++ b/src/r_poly_wallsprite.cpp @@ -38,7 +38,7 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const Vec4f &cli bool flipTextureX = false; FTexture *tex = RenderPolySprite::GetSpriteTexture(thing, flipTextureX); - if (tex == nullptr) + if (tex == nullptr || tex->UseType == FTexture::TEX_Null) return; DVector2 spriteScale = thing->Scale; From 066158be6993645d754a1f0e267ff015ab3fd102 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 7 Dec 2016 22:26:18 +0100 Subject: [PATCH 1377/1509] Fix mirror --- src/r_poly_portal.cpp | 34 +++++++++++++++++++++++----------- src/r_poly_portal.h | 2 +- src/r_poly_scene.cpp | 9 ++++++++- src/r_poly_triangle.cpp | 14 ++++++++++++-- src/r_poly_triangle.h | 4 +++- 5 files changed, 47 insertions(+), 16 deletions(-) diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 1bb600779..96df9daf0 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -162,11 +162,14 @@ void PolyDrawLinePortal::Render(int portalDepth) TriMatrix::scale(1.0f, glset.pixelstretch, 1.0f) * TriMatrix::swapYZ() * TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); + if (Mirror) + worldToView = TriMatrix::scale(-1.0f, 1.0f, 1.0f) * worldToView; TriMatrix worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; // Calculate plane clipping - DVector2 planePos = Portal->mDestination->v1->fPos(); - DVector2 planeNormal = (Portal->mDestination->v2->fPos() - Portal->mDestination->v1->fPos()).Rotated90CW(); + line_t *clipLine = Portal ? Portal->mDestination : Mirror; + DVector2 planePos = clipLine->v1->fPos(); + DVector2 planeNormal = (clipLine->v2->fPos() - clipLine->v1->fPos()).Rotated90CW(); planeNormal.MakeUnit(); double planeD = -(planeNormal | (planePos + planeNormal * 0.001)); Vec4f portalPlane((float)planeNormal.X, (float)planeNormal.Y, 0.0f, (float)planeD); @@ -191,7 +194,7 @@ void PolyDrawLinePortal::SaveGlobals() savedangle = ViewAngle; savedcamera = camera; savedsector = viewsector; - savedvisibility = camera ? camera->renderflags & RF_INVISIBLE : ActorRenderFlags::FromInt(0); + savedinvisibility = camera ? (camera->renderflags & RF_INVISIBLE) == RF_INVISIBLE : false; savedViewPath[0] = ViewPath[0]; savedViewPath[1] = ViewPath[1]; @@ -229,6 +232,9 @@ void PolyDrawLinePortal::SaveGlobals() ViewPos.Y = (y1 + r * dy) * 2 - y; } ViewAngle = Mirror->Delta().Angle() * 2 - startang; + + if (camera) + camera->renderflags &= ~RF_INVISIBLE; } else { @@ -255,22 +261,25 @@ void PolyDrawLinePortal::SaveGlobals() } } } - - /*if (Portal->mirror) - { - if (MirrorFlags & RF_XFLIP) MirrorFlags &= ~RF_XFLIP; - else MirrorFlags |= RF_XFLIP; - }*/ } - camera = nullptr; + //camera = nullptr; //viewsector = R_PointInSubsector(ViewPos)->sector; R_SetViewAngle(); + + if (Mirror) + PolyTriangleDrawer::toggle_mirror(); } void PolyDrawLinePortal::RestoreGlobals() { - if (!savedvisibility && camera) camera->renderflags &= ~RF_INVISIBLE; + if (camera) + { + if (savedinvisibility) + camera->renderflags |= RF_INVISIBLE; + else + camera->renderflags &= ~RF_INVISIBLE; + } camera = savedcamera; viewsector = savedsector; ViewPos = savedpos; @@ -279,4 +288,7 @@ void PolyDrawLinePortal::RestoreGlobals() ViewPath[0] = savedViewPath[0]; ViewPath[1] = savedViewPath[1]; R_SetViewAngle(); + + if (Mirror) + PolyTriangleDrawer::toggle_mirror(); } diff --git a/src/r_poly_portal.h b/src/r_poly_portal.h index 7835bb042..6cad98ff6 100644 --- a/src/r_poly_portal.h +++ b/src/r_poly_portal.h @@ -85,6 +85,6 @@ private: DAngle savedangle; AActor *savedcamera; sector_t *savedsector; - ActorRenderFlags savedvisibility; + bool savedinvisibility; DVector3 savedViewPath[2]; }; diff --git a/src/r_poly_scene.cpp b/src/r_poly_scene.cpp index 7304000a6..ef2ef5f1b 100644 --- a/src/r_poly_scene.cpp +++ b/src/r_poly_scene.cpp @@ -121,9 +121,16 @@ void RenderPolyScene::RenderSubsector(subsector_t *sub) void RenderPolyScene::RenderSprite(AActor *thing, double sortDistance, const DVector2 &left, const DVector2 &right) { if (numnodes == 0) - RenderSprite(thing, sortDistance, left, right, 0.0, 1.0, subsectors); + { + subsector_t *sub = subsectors; + auto it = SubsectorDepths.find(sub); + if (it != SubsectorDepths.end()) + TranslucentObjects.push_back({ thing, sub, it->second, sortDistance, 0.0f, 1.0f }); + } else + { RenderSprite(thing, sortDistance, left, right, 0.0, 1.0, nodes + numnodes - 1); // The head node is the last node output. + } } void RenderPolyScene::RenderSprite(AActor *thing, double sortDistance, DVector2 left, DVector2 right, double t1, double t2, void *node) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 4b6e1c344..45f244aab 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -45,6 +45,7 @@ int PolyTriangleDrawer::dest_width; int PolyTriangleDrawer::dest_height; uint8_t *PolyTriangleDrawer::dest; bool PolyTriangleDrawer::dest_bgra; +bool PolyTriangleDrawer::mirror; void PolyTriangleDrawer::set_viewport(int x, int y, int width, int height, DCanvas *canvas) { @@ -66,11 +67,18 @@ void PolyTriangleDrawer::set_viewport(int x, int y, int width, int height, DCanv dest += (offsetx + offsety * dest_pitch) * pixelsize; dest_width = clamp(viewport_x + viewport_width, 0, dest_width - offsetx); dest_height = clamp(viewport_y + viewport_height, 0, dest_height - offsety); + + mirror = false; +} + +void PolyTriangleDrawer::toggle_mirror() +{ + mirror = !mirror; } void PolyTriangleDrawer::draw(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode) { - DrawerCommandQueue::QueueCommand(args, variant, blendmode); + DrawerCommandQueue::QueueCommand(args, variant, blendmode, mirror); } void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVariant variant, TriBlendMode blendmode, WorkerThreadData *thread) @@ -328,9 +336,11 @@ void PolyTriangleDrawer::clipedge(const ShadedTriVertex *verts, TriVertex *clipp ///////////////////////////////////////////////////////////////////////////// -DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode) +DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode, bool mirror) : args(args), variant(variant), blendmode(blendmode) { + if (mirror) + this->args.ccw = !this->args.ccw; } void DrawPolyTrianglesCommand::Execute(DrawerThread *thread) diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 46948310f..ecf05a921 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -158,6 +158,7 @@ class PolyTriangleDrawer public: static void set_viewport(int x, int y, int width, int height, DCanvas *canvas); static void draw(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode); + static void toggle_mirror(); private: static ShadedTriVertex shade_vertex(const TriMatrix &objectToClip, const float *clipPlane, const TriVertex &v); @@ -169,6 +170,7 @@ private: static int viewport_x, viewport_y, viewport_width, viewport_height, dest_pitch, dest_width, dest_height; static bool dest_bgra; static uint8_t *dest; + static bool mirror; enum { max_additional_vertices = 16 }; @@ -245,7 +247,7 @@ private: class DrawPolyTrianglesCommand : public DrawerCommand { public: - DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode); + DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode, bool mirror); void Execute(DrawerThread *thread) override; FString DebugInfo() override; From 1e950d75bdb73ea6fcc6cd614c0deb73369393ca Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 7 Dec 2016 23:17:18 +0100 Subject: [PATCH 1378/1509] - made dynamic light attenuation completely opt-in. This can be done either by setting a MAPINFO option for lights that do not automatically specify it and with a light property. The light property will always take precedence, if set. --- src/gl/data/gl_data.cpp | 63 ++++++++++++++-------- src/gl/data/gl_data.h | 2 + src/gl/dynlights/gl_dynlight.cpp | 29 +++++++++- src/gl/renderer/gl_lightdata.cpp | 3 +- wadsrc/static/mapinfo/common.txt | 5 ++ wadsrc/static/zscript/shared/dynlights.txt | 41 ++++++++++++++ 6 files changed, 119 insertions(+), 24 deletions(-) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 606459c7e..eb676de75 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -60,6 +60,8 @@ long gl_frameCount; EXTERN_CVAR(Int, gl_lightmode) EXTERN_CVAR(Bool, gl_brightfog) EXTERN_CVAR(Bool, gl_lightadditivesurfaces) +EXTERN_CVAR(Bool, gl_attenuate) + CUSTOM_CVAR(Float, maxviewpitch, 90.f, CVAR_ARCHIVE|CVAR_SERVERINFO) { @@ -207,6 +209,7 @@ struct FGLROptions : public FOptionalMapinfoData skyfog = 0; brightfog = false; lightmode = -1; + attenuate = -1; nocoloredspritelighting = -1; notexturefill = -1; skyrotatevector = FVector3(0,0,1); @@ -222,6 +225,7 @@ struct FGLROptions : public FOptionalMapinfoData newopt->outsidefogdensity = outsidefogdensity; newopt->skyfog = skyfog; newopt->lightmode = lightmode; + newopt->attenuate = attenuate; newopt->nocoloredspritelighting = nocoloredspritelighting; newopt->notexturefill = notexturefill; newopt->skyrotatevector = skyrotatevector; @@ -235,6 +239,7 @@ struct FGLROptions : public FOptionalMapinfoData int skyfog; int lightmode; int brightfog; + int8_t attenuate; int8_t lightadditivesurfaces; int8_t nocoloredspritelighting; int8_t notexturefill; @@ -325,6 +330,20 @@ DEFINE_MAP_OPTION(lightadditivesurfaces, false) } } +DEFINE_MAP_OPTION(attenuate, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + if (parse.CheckAssign()) + { + parse.sc.MustGetNumber(); + opt->attenuate = !!parse.sc.Number; + } + else + { + opt->attenuate = true; + } +} + DEFINE_MAP_OPTION(skyrotate, false) { FGLROptions *opt = info->GetOptData("gl_renderer"); @@ -371,6 +390,22 @@ bool IsLightmodeValid() return (glset.map_lightmode >= 0 && glset.map_lightmode <= 4) || glset.map_lightmode == 8; } +static void ResetOpts() +{ + if (!IsLightmodeValid()) glset.lightmode = gl_lightmode; + else glset.lightmode = glset.map_lightmode; + if (glset.map_nocoloredspritelighting == -1) glset.nocoloredspritelighting = gl_nocoloredspritelighting; + else glset.nocoloredspritelighting = !!glset.map_nocoloredspritelighting; + if (glset.map_notexturefill == -1) glset.notexturefill = gl_notexturefill; + else glset.notexturefill = !!glset.map_notexturefill; + if (glset.map_brightfog == -1) glset.brightfog = gl_brightfog; + else glset.brightfog = !!glset.map_brightfog; + if (glset.map_lightadditivesurfaces == -1) glset.lightadditivesurfaces = gl_lightadditivesurfaces; + else glset.lightadditivesurfaces = !!glset.map_lightadditivesurfaces; + if (glset.map_attenuate == -1) glset.attenuate = gl_attenuate; + else glset.attenuate = !!glset.map_attenuate; +} + void InitGLRMapinfoData() { FGLROptions *opt = level.info->GetOptData("gl_renderer", false); @@ -380,6 +415,7 @@ void InitGLRMapinfoData() gl_SetFogParams(opt->fogdensity, level.info->outsidefog, opt->outsidefogdensity, opt->skyfog); glset.map_lightmode = opt->lightmode; glset.map_lightadditivesurfaces = opt->lightadditivesurfaces; + glset.map_attenuate = opt->attenuate; glset.map_brightfog = opt->brightfog; glset.map_nocoloredspritelighting = opt->nocoloredspritelighting; glset.map_notexturefill = opt->notexturefill; @@ -393,35 +429,18 @@ void InitGLRMapinfoData() glset.map_lightmode = -1; glset.map_lightadditivesurfaces = -1; glset.map_brightfog = -1; + glset.map_attenuate = -1; glset.map_nocoloredspritelighting = -1; glset.map_notexturefill = -1; - glset.skyrotatevector = FVector3(0,0,1); - glset.skyrotatevector2 = FVector3(0,0,1); + glset.skyrotatevector = FVector3(0, 0, 1); + glset.skyrotatevector2 = FVector3(0, 0, 1); glset.pixelstretch = 1.2f; } - - if (!IsLightmodeValid()) glset.lightmode = gl_lightmode; - else glset.lightmode = glset.map_lightmode; - if (glset.map_nocoloredspritelighting == -1) glset.nocoloredspritelighting = gl_nocoloredspritelighting; - else glset.nocoloredspritelighting = !!glset.map_nocoloredspritelighting; - if (glset.map_notexturefill == -1) glset.notexturefill = gl_notexturefill; - else glset.notexturefill = !!glset.map_notexturefill; - if (glset.map_brightfog == -1) glset.brightfog = gl_brightfog; - else glset.brightfog = !!glset.map_brightfog; - if (glset.map_lightadditivesurfaces == -1) glset.brightfog = gl_brightfog; - else glset.lightadditivesurfaces = !!glset.map_lightadditivesurfaces; + ResetOpts(); } - CCMD(gl_resetmap) { - if (!IsLightmodeValid()) glset.lightmode = gl_lightmode; - else glset.lightmode = glset.map_lightmode; - if (glset.map_nocoloredspritelighting == -1) glset.nocoloredspritelighting = gl_nocoloredspritelighting; - else glset.nocoloredspritelighting = !!glset.map_nocoloredspritelighting; - if (glset.map_notexturefill == -1) glset.notexturefill = gl_notexturefill; - else glset.notexturefill = !!glset.map_notexturefill; - if (glset.map_brightfog == -1) glset.brightfog = gl_brightfog; - else glset.brightfog = !!glset.map_brightfog; + ResetOpts(); } diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index d6f789863..bb57c9139 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -13,12 +13,14 @@ struct GLRenderSettings bool notexturefill; bool brightfog; bool lightadditivesurfaces; + bool attenuate; int8_t map_lightmode; int8_t map_nocoloredspritelighting; int8_t map_notexturefill; int8_t map_brightfog; int8_t map_lightadditivesurfaces; + int8_t map_attenuate; FVector3 skyrotatevector; FVector3 skyrotatevector2; diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index 63ddfee60..18b255999 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -54,6 +54,7 @@ #include "gl/textures/gl_skyboxtexture.h" #include "gl/utility/gl_clock.h" #include "gl/utility/gl_convert.h" +#include "gl/data/gl_data.h" int ScriptDepth; void gl_InitGlow(FScanner &sc); @@ -128,6 +129,7 @@ public: void SetSubtractive(bool subtract) { m_subtractive = subtract; } void SetAdditive(bool add) { m_additive = add; } void SetDontLightSelf(bool add) { m_dontlightself = add; } + void SetAttenuate(bool on) { m_attenuate = on; } void SetHalo(bool halo) { m_halo = halo; } protected: FName m_Name; @@ -135,6 +137,7 @@ protected: double m_Param; DVector3 m_Pos; ELightType m_type; + int8_t m_attenuate; bool m_subtractive, m_additive, m_halo, m_dontlightself; }; @@ -159,6 +162,7 @@ FLightDefaults::FLightDefaults(FName name, ELightType type) m_additive = false; m_halo = false; m_dontlightself = false; + m_attenuate = -1; } void FLightDefaults::ApplyProperties(ADynamicLight * light) const @@ -175,7 +179,13 @@ void FLightDefaults::ApplyProperties(ADynamicLight * light) const if (m_additive) light->flags4 |= MF4_ADDITIVE; if (m_dontlightself) light->flags4 |= MF4_DONTLIGHTSELF; light->m_tickCount = 0; -} + switch (m_attenuate) + { + case 0: light->flags4 &= ~MF4_ATTENUATE; break; + case 1: light->flags4 |= MF4_ATTENUATE; break; + default: if (glset.attenuate) light->flags4 |= MF4_ATTENUATE; else light->flags4 &= ~MF4_ATTENUATE; break; + } + } //========================================================================== @@ -202,6 +212,7 @@ static const char *LightTags[]= "additive", "halo", "dontlightself", + "attenuate", NULL }; @@ -222,6 +233,7 @@ enum { LIGHTTAG_ADDITIVE, LIGHTTAG_HALO, LIGHTTAG_DONTLIGHTSELF, + LIGHTTAG_ATTENUATE }; @@ -349,6 +361,9 @@ void gl_ParsePointLight(FScanner &sc) case LIGHTTAG_DONTLIGHTSELF: defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); break; + case LIGHTTAG_ATTENUATE: + defaults->SetAttenuate(gl_ParseInt(sc) != 0); + break; default: sc.ScriptError("Unknown tag: %s\n", sc.String); } @@ -428,6 +443,9 @@ void gl_ParsePulseLight(FScanner &sc) case LIGHTTAG_DONTLIGHTSELF: defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); break; + case LIGHTTAG_ATTENUATE: + defaults->SetAttenuate(gl_ParseInt(sc) != 0); + break; default: sc.ScriptError("Unknown tag: %s\n", sc.String); } @@ -515,6 +533,9 @@ void gl_ParseFlickerLight(FScanner &sc) case LIGHTTAG_DONTLIGHTSELF: defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); break; + case LIGHTTAG_ATTENUATE: + defaults->SetAttenuate(gl_ParseInt(sc) != 0); + break; default: sc.ScriptError("Unknown tag: %s\n", sc.String); } @@ -594,6 +615,9 @@ void gl_ParseFlickerLight2(FScanner &sc) case LIGHTTAG_DONTLIGHTSELF: defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); break; + case LIGHTTAG_ATTENUATE: + defaults->SetAttenuate(gl_ParseInt(sc) != 0); + break; default: sc.ScriptError("Unknown tag: %s\n", sc.String); } @@ -671,6 +695,9 @@ void gl_ParseSectorLight(FScanner &sc) case LIGHTTAG_DONTLIGHTSELF: defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); break; + case LIGHTTAG_ATTENUATE: + defaults->SetAttenuate(gl_ParseInt(sc) != 0); + break; default: sc.ScriptError("Unknown tag: %s\n", sc.String); } diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 37f0a2e85..0dd180dfb 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -63,7 +63,8 @@ CUSTOM_CVAR(Bool, gl_enhanced_nightvision, true, CVAR_ARCHIVE|CVAR_NOINITCALL) } } CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE); -CVAR(Bool, lightadditivesurfaces, false, CVAR_ARCHIVE); +CVAR(Bool, gl_lightadditivesurfaces, false, CVAR_ARCHIVE); +CVAR(Bool, gl_attenuate, false, CVAR_ARCHIVE); diff --git a/wadsrc/static/mapinfo/common.txt b/wadsrc/static/mapinfo/common.txt index 81a791de6..5782f8808 100644 --- a/wadsrc/static/mapinfo/common.txt +++ b/wadsrc/static/mapinfo/common.txt @@ -104,6 +104,11 @@ DoomEdNums 9823 = SectorPointLightSubtractive 9824 = PointLightFlickerRandomSubtractive 9825 = VavoomLight + 9830 = PointLightAttenuated + 9831 = PointLightPulseAttenuated + 9832 = PointLightFlickerAttenuated + 9833 = SectorPointLightAttenuated + 9834 = PointLightFlickerRandomAttenuated 9982 = SecActEyesAboveC 9983 = SecActEyesBelowC 9988 = CustomSprite diff --git a/wadsrc/static/zscript/shared/dynlights.txt b/wadsrc/static/zscript/shared/dynlights.txt index 55698f079..578354130 100644 --- a/wadsrc/static/zscript/shared/dynlights.txt +++ b/wadsrc/static/zscript/shared/dynlights.txt @@ -157,3 +157,44 @@ class VavoomLightColor : VavoomLight native } } + +class PointLightAttenuated : PointLight +{ + Default + { + +INCOMBAT + } +} + +class PointLightPulseAttenuated : PointLightPulse +{ + Default + { + +INCOMBAT + } +} + +class PointLightFlickerAttenuated : PointLightFlicker +{ + Default + { + +INCOMBAT + } +} + +class SectorPointLightAttenuated : SectorPointLight +{ + Default + { + +INCOMBAT + } +} + +class PointLightFlickerRandomAttenuated :PointLightFlickerRandom +{ + Default + { + +INCOMBAT + } +} + From 12f0b560363c78a660abd5c4383860bd58e50f78 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Dec 2016 00:59:04 +0100 Subject: [PATCH 1379/1509] - fixed: Stepping up through a portal did not work when the step line was two-sided. This special case was only implemented for one-sided lines - fixed: The portal collector set bad flags for collected lower portals. --- src/p_map.cpp | 20 ++++++++++++++++++++ src/portal.cpp | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 16a5933d5..290b84b9e 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -860,6 +860,26 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec FLineOpening open; P_LineOpening(open, tm.thing, ld, ref, &cres.Position, cres.portalflags); + if (!tm.thing->Sector->PortalBlocksMovement(sector_t::ceiling)) + { + sector_t *oppsec = cres.line->frontsector == tm.thing->Sector ? cres.line->backsector : cres.line->frontsector; + if (oppsec->PortalBlocksMovement(sector_t::ceiling)) + { + double portz = tm.thing->Sector->GetPortalPlaneZ(sector_t::ceiling); + if (tm.thing->Z() < portz && tm.thing->Z() + tm.thing->MaxStepHeight >= portz && tm.floorz < portz) + { + // Actor is stepping through a portal. + /* + tm.floorz = portz; + tm.floorsector = oppsec; + tm.floorpic = cres.line->sidedef[0]->GetTexture(side_t::mid); + tm.floorterrain = 0; + */ + tm.portalstep = true; + return true; + } + } + } // [RH] Steep sectors count as dropoffs, if the actor touches the boundary between a steep slope and something else if (!(tm.thing->flags & MF_DROPOFF) && diff --git a/src/portal.cpp b/src/portal.cpp index f1454cdc6..156643cfb 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -1231,8 +1231,8 @@ bool P_CollectConnectedGroups(int startgroup, const DVector3 &position, double u { int othergroup = wsec->GetOppositePortalGroup(sector_t::floor); DVector2 pos = Displacements.getOffset(startgroup, othergroup) + position; - processMask.setBit(othergroup | FPortalGroupArray::LOWER); - out.Add(othergroup); + processMask.setBit(othergroup); + out.Add(othergroup | FPortalGroupArray::LOWER); wsec = P_PointInSector(pos); // get lower sector at the exact spot we want to check and repeat retval = true; } From a1bb6e6b234fa673e5ab732bd845f3aa0273ebed Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 8 Dec 2016 10:29:52 +0100 Subject: [PATCH 1380/1509] Only render line portals once --- src/r_poly.cpp | 12 ++++++++++++ src/r_poly.h | 6 ++++++ src/r_poly_wall.cpp | 28 +++++++++++++++++----------- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 4ea047925..2e100b395 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -117,6 +117,8 @@ void PolyRenderer::ClearBuffers() PolyStencilBuffer::Instance()->Clear(RenderTarget->GetWidth(), RenderTarget->GetHeight(), 0); PolySubsectorGBuffer::Instance()->Resize(RenderTarget->GetPitch(), RenderTarget->GetHeight()); NextStencilValue = 0; + SeenLinePortals.clear(); + SeenMirrors.clear(); } void PolyRenderer::SetSceneViewport() @@ -170,3 +172,13 @@ void PolyRenderer::SetupPerspectiveMatrix() WorldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; } + +bool PolyRenderer::InsertSeenLinePortal(FLinePortal *portal) +{ + return SeenLinePortals.insert(portal).second; +} + +bool PolyRenderer::InsertSeenMirror(line_t *mirrorLine) +{ + return SeenMirrors.insert(mirrorLine).second; +} diff --git a/src/r_poly.h b/src/r_poly.h index bc108a8a1..f34106a4b 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -47,6 +47,9 @@ public: uint32_t GetNextStencilValue() { uint32_t value = NextStencilValue; NextStencilValue += 2; return value; } + bool InsertSeenLinePortal(FLinePortal *portal); + bool InsertSeenMirror(line_t *mirrorLine); + private: void ClearBuffers(); void SetSceneViewport(); @@ -57,4 +60,7 @@ private: PolySkyDome Skydome; RenderPolyPlayerSprites PlayerSprites; uint32_t NextStencilValue = 0; + + std::set SeenLinePortals; + std::set SeenMirrors; }; diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index 384529da0..efc953013 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -40,24 +40,30 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const Vec4f &clipP PolyDrawLinePortal *polyportal = nullptr; if (line->backsector == nullptr && line->linedef && line->sidedef == line->linedef->sidedef[0] && (line->linedef->special == Line_Mirror && r_drawmirrors)) { - linePortals.push_back(std::make_unique(line->linedef)); - polyportal = linePortals.back().get(); + if (PolyRenderer::Instance()->InsertSeenMirror(line->linedef)) + { + linePortals.push_back(std::make_unique(line->linedef)); + polyportal = linePortals.back().get(); + } } else if (line->linedef && line->linedef->isVisualPortal()) { FLinePortal *portal = line->linedef->getPortal(); - for (auto &p : linePortals) + if (PolyRenderer::Instance()->InsertSeenLinePortal(portal)) { - if (p->Portal == portal) // To do: what other criterias do we need to check for? + for (auto &p : linePortals) { - polyportal = p.get(); - break; + if (p->Portal == portal) // To do: what other criterias do we need to check for? + { + polyportal = p.get(); + break; + } + } + if (!polyportal) + { + linePortals.push_back(std::make_unique(portal)); + polyportal = linePortals.back().get(); } - } - if (!polyportal) - { - linePortals.push_back(std::make_unique(portal)); - polyportal = linePortals.back().get(); } } From dc82c19901819ffb239f13c3e7e9e7f1d3d04b54 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 8 Dec 2016 10:35:51 +0100 Subject: [PATCH 1381/1509] Fix sprites/translucent stuff being occluded by portal walls --- src/r_poly_scene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_poly_scene.cpp b/src/r_poly_scene.cpp index ef2ef5f1b..3b03507f1 100644 --- a/src/r_poly_scene.cpp +++ b/src/r_poly_scene.cpp @@ -274,7 +274,7 @@ void RenderPolyScene::RenderTranslucent(int portalDepth) args.objectToClip = &WorldToClip; args.mode = TriangleDrawMode::Fan; args.stenciltestvalue = portal->StencilValue + 1; - args.stencilwritevalue = StencilValue; + args.stencilwritevalue = StencilValue + 1; args.SetClipPlane(PortalPlane.x, PortalPlane.y, PortalPlane.z, PortalPlane.w); for (const auto &verts : portal->Shape) { @@ -295,7 +295,7 @@ void RenderPolyScene::RenderTranslucent(int portalDepth) args.objectToClip = &WorldToClip; args.mode = TriangleDrawMode::Fan; args.stenciltestvalue = portal->StencilValue + 1; - args.stencilwritevalue = StencilValue; + args.stencilwritevalue = StencilValue + 1; args.SetClipPlane(PortalPlane.x, PortalPlane.y, PortalPlane.z, PortalPlane.w); for (const auto &verts : portal->Shape) { From 3aac058022285f01021f011129614c38837c6260 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 8 Dec 2016 12:07:12 +0200 Subject: [PATCH 1382/1509] Fixed loading of Hexen and Strife Names in sprite offsets files for these IWADs contain '[' and '\' characters and such names need to be quoted --- wadsrc/static/filter/hexen/sprofs.txt | 2 +- wadsrc/static/filter/strife/sprofs.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wadsrc/static/filter/hexen/sprofs.txt b/wadsrc/static/filter/hexen/sprofs.txt index a8d614ca0..4408e3b95 100644 --- a/wadsrc/static/filter/hexen/sprofs.txt +++ b/wadsrc/static/filter/hexen/sprofs.txt @@ -57,7 +57,7 @@ CLERW0, 37, 53, iwad CLERX0, 37, 43, iwad CLERY0, 38, 30, iwad CLERZ0, 38, 18, iwad -CLER[0, 38, 12, iwad +"CLER[0", 38, 12, iwad CPB1A0, 8, 7, iwad CPB2A0, 7, 6, iwad CPB3A0, 12, 4, iwad diff --git a/wadsrc/static/filter/strife/sprofs.txt b/wadsrc/static/filter/strife/sprofs.txt index d7118297b..c6dafb581 100644 --- a/wadsrc/static/filter/strife/sprofs.txt +++ b/wadsrc/static/filter/strife/sprofs.txt @@ -200,8 +200,8 @@ PGRDW0, 35, 28, iwad PGRDX0, 35, 28, iwad PGRDY0, 35, 28, iwad PGRDZ0, 35, 28, iwad -PGRD[0, 35, 28, iwad -PGRD\0, 35, 28, iwad +"PGRD[0", 35, 28, iwad +"PGRD\0", 35, 28, iwad PDEDE0, 22, 20, iwad PDEDF0, 23, 16, iwad PDEDG0, 23, 15, iwad From 3558b2234c273abf461f5b3bcd30ad2dfb749daa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Dec 2016 12:49:40 +0100 Subject: [PATCH 1383/1509] - fixed: The dynamic light setup for walls did not portal-translate the light's coordinate. - changed ADynamicLight::CollectWithinRadius to work iteratively to avoid the high stack overhead of 64 bit code. --- src/gl/dynlights/a_dynlight.cpp | 136 +++++++++++++++++++------------- src/gl/scene/gl_walls_draw.cpp | 7 +- 2 files changed, 85 insertions(+), 58 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 45e8bfb14..0ab834505 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -582,81 +582,107 @@ double ADynamicLight::DistToSeg(const DVector3 &pos, seg_t *seg) // to sidedefs and sector parts. // //========================================================================== +struct LightLinkEntry +{ + subsector_t *sub; + DVector3 pos; +}; +static TArray collected_ss; -void ADynamicLight::CollectWithinRadius(const DVector3 &pos, subsector_t *subSec, float radius) +void ADynamicLight::CollectWithinRadius(const DVector3 &opos, subsector_t *subSec, float radius) { if (!subSec) return; - + collected_ss.Clear(); + collected_ss.Push({ subSec, opos }); subSec->validcount = ::validcount; - touching_subsectors = AddLightNode(&subSec->lighthead, subSec, this, touching_subsectors); - if (subSec->sector->validcount != ::validcount) + for (unsigned i = 0; i < collected_ss.Size(); i++) { - touching_sector = AddLightNode(&subSec->render_sector->lighthead, subSec->sector, this, touching_sector); - subSec->sector->validcount = ::validcount; - } + subSec = collected_ss[i].sub; + auto &pos = collected_ss[i].pos; - for (unsigned int i = 0; i < subSec->numlines; i++) - { - seg_t * seg = subSec->firstline + i; - - // check distance from x/y to seg and if within radius add this seg and, if present the opposing subsector (lather/rinse/repeat) - // If out of range we do not need to bother with this seg. - if (DistToSeg(pos, seg) <= radius) + touching_subsectors = AddLightNode(&subSec->lighthead, subSec, this, touching_subsectors); + if (subSec->sector->validcount != ::validcount) { - if (seg->sidedef && seg->linedef && seg->linedef->validcount != ::validcount) + touching_sector = AddLightNode(&subSec->render_sector->lighthead, subSec->sector, this, touching_sector); + subSec->sector->validcount = ::validcount; + } + + for (unsigned int i = 0; i < subSec->numlines; i++) + { + seg_t * seg = subSec->firstline + i; + + // check distance from x/y to seg and if within radius add this seg and, if present the opposing subsector (lather/rinse/repeat) + // If out of range we do not need to bother with this seg. + if (DistToSeg(pos, seg) <= radius) { - // light is in front of the seg - if ((pos.Y - seg->v1->fY()) * (seg->v2->fX() - seg->v1->fX()) + (seg->v1->fX() - pos.X) * (seg->v2->fY() - seg->v1->fY()) <= 0) + if (seg->sidedef && seg->linedef && seg->linedef->validcount != ::validcount) { - seg->linedef->validcount = validcount; - touching_sides = AddLightNode(&seg->sidedef->lighthead, seg->sidedef, this, touching_sides); - } - } - if (seg->linedef) - { - FLinePortal *port = seg->linedef->getPortal(); - if (port && port->mType == PORTT_LINKED) - { - line_t *other = port->mDestination; - if (other->validcount != ::validcount) + // light is in front of the seg + if ((pos.Y - seg->v1->fY()) * (seg->v2->fX() - seg->v1->fX()) + (seg->v1->fX() - pos.X) * (seg->v2->fY() - seg->v1->fY()) <= 0) { - subsector_t *othersub = R_PointInSubsector(other->v1->fPos() + other->Delta() / 2); - if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(other), othersub, radius); + seg->linedef->validcount = validcount; + touching_sides = AddLightNode(&seg->sidedef->lighthead, seg->sidedef, this, touching_sides); + } + } + if (seg->linedef) + { + FLinePortal *port = seg->linedef->getPortal(); + if (port && port->mType == PORTT_LINKED) + { + line_t *other = port->mDestination; + if (other->validcount != ::validcount) + { + subsector_t *othersub = R_PointInSubsector(other->v1->fPos() + other->Delta() / 2); + if (othersub->validcount != ::validcount) + { + othersub->validcount = ::validcount; + collected_ss.Push({ othersub, PosRelative(other) }); + } + } + } + } + + seg_t *partner = seg->PartnerSeg; + if (partner) + { + subsector_t *sub = partner->Subsector; + if (sub != NULL && sub->validcount != ::validcount) + { + sub->validcount = ::validcount; + collected_ss.Push({ sub, pos }); } } } - - seg_t *partner = seg->PartnerSeg; - if (partner) + } + sector_t *sec = subSec->sector; + if (!sec->PortalBlocksSight(sector_t::ceiling)) + { + line_t *other = subSec->firstline->linedef; + if (sec->GetPortalPlaneZ(sector_t::ceiling) < Z() + radius) { - subsector_t *sub = partner->Subsector; - if (sub != NULL && sub->validcount != ::validcount) + DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sec->GetPortalDisplacement(sector_t::ceiling); + subsector_t *othersub = R_PointInSubsector(refpos); + if (othersub->validcount != ::validcount) { - CollectWithinRadius(pos, sub, radius); + othersub->validcount = ::validcount; + collected_ss.Push({ othersub, PosRelative(othersub->sector) }); } } } - } - sector_t *sec = subSec->sector; - if (!sec->PortalBlocksSight(sector_t::ceiling)) - { - line_t *other = subSec->firstline->linedef; - if (sec->GetPortalPlaneZ(sector_t::ceiling) < Z() + radius) + if (!sec->PortalBlocksSight(sector_t::floor)) { - DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sec->GetPortalDisplacement(sector_t::ceiling); - subsector_t *othersub = R_PointInSubsector(refpos); - if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius); - } - } - if (!sec->PortalBlocksSight(sector_t::floor)) - { - line_t *other = subSec->firstline->linedef; - if (sec->GetPortalPlaneZ(sector_t::floor) > Z() - radius) - { - DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sec->GetPortalDisplacement(sector_t::floor); - subsector_t *othersub = R_PointInSubsector(refpos); - if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius); + line_t *other = subSec->firstline->linedef; + if (sec->GetPortalPlaneZ(sector_t::floor) > Z() - radius) + { + DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sec->GetPortalDisplacement(sector_t::floor); + subsector_t *othersub = R_PointInSubsector(refpos); + if (othersub->validcount != ::validcount) + { + othersub->validcount = ::validcount; + collected_ss.Push({ othersub, PosRelative(othersub->sector) }); + } + } } } } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index d392439e7..f166a2ce1 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -102,9 +102,10 @@ void GLWall::SetupLights() Vector fn, pos; - float x = node->lightsource->X(); - float y = node->lightsource->Y(); - float z = node->lightsource->Z(); + DVector3 posrel = node->lightsource->PosRelative(seg->frontsector); + float x = posrel.X; + float y = posrel.Y; + float z = posrel.Z; float dist = fabsf(p.DistToPoint(x, z, y)); float radius = node->lightsource->GetRadius(); float scale = 1.0f / ((2.f * radius) - dist); From 2854e1fe03f847e39857b14c3efa8b4162c7a525 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 8 Dec 2016 13:07:52 +0100 Subject: [PATCH 1384/1509] Fix crash reporter for 64 bit (cherry picked from commit 3a0de8b0c714507823edaa24875bc97b39c76ab6) --- src/win32/i_main.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index db92467bc..0931aff99 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -1184,6 +1184,11 @@ void CALLBACK ExitFatally (ULONG_PTR dummy) // //========================================================================== +namespace +{ + CONTEXT MainThreadContext; +} + LONG WINAPI CatchAllExceptions (LPEXCEPTION_POINTERS info) { #ifdef _DEBUG @@ -1208,11 +1213,7 @@ LONG WINAPI CatchAllExceptions (LPEXCEPTION_POINTERS info) // Otherwise, put the crashing thread to sleep and signal the main thread to clean up. if (GetCurrentThreadId() == MainThreadID) { -#ifndef _M_X64 - info->ContextRecord->Eip = (DWORD_PTR)ExitFatally; -#else - info->ContextRecord->Rip = (DWORD_PTR)ExitFatally; -#endif + *info->ContextRecord = MainThreadContext; } else { @@ -1304,6 +1305,15 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE nothing, LPSTR cmdline, int n if (MainThread != INVALID_HANDLE_VALUE) { SetUnhandledExceptionFilter (CatchAllExceptions); + + static bool setJumpResult = false; + RtlCaptureContext(&MainThreadContext); + if (setJumpResult) + { + ExitFatally(0); + return 0; + } + setJumpResult = true; } #endif From 8f4566408923e8fb952c46fe06725b0c704e6061 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Dec 2016 17:00:15 +0100 Subject: [PATCH 1385/1509] - fixed: Fog boundaries were not drawn on line portals. There's two restrictions, though: * on one-sided-line portals fog boundaries will not be drawn. * the filler sector behind the portal may not have a sky ceiling texture. This is because the drawing code contains several sky checks which get in the way here. --- src/gl/scene/gl_walls.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index db16a941a..30e10b73f 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1654,7 +1654,10 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) /* mid texture */ - bool drawfogboundary = gl_CheckFog(frontsector, backsector); + bool isportal = seg->linedef->isVisualPortal() && seg->sidedef == seg->linedef->sidedef[0]; + sector_t *backsec = isportal? seg->linedef->getPortalDestination()->frontsector : backsector; + + bool drawfogboundary = gl_CheckFog(frontsector, backsec); FTexture *tex = TexMan(seg->sidedef->GetTexture(side_t::mid)); if (tex != NULL) { @@ -1672,7 +1675,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); } - if (seg->linedef->isVisualPortal() && seg->sidedef == seg->linedef->sidedef[0]) + if (isportal) { lineportal = linePortalToGL[seg->linedef->portalindex]; ztop[0] = bch1; From 8a6d3b8e7b485e24460c654e03edca21d7c64840 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Dec 2016 21:05:53 +0100 Subject: [PATCH 1386/1509] - sprites.cpp --- src/r_data/sprites.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index 80c2d9488..3e0cb80cc 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -26,10 +26,8 @@ DWORD NumStdSprites; // The first x sprites that don't belong to skins. struct spriteframewithrotate : public spriteframe_t { int rotate; -} -sprtemp[MAX_SPRITE_FRAMES]; -int maxframe; -char* spritename; +}; + // [RH] skin globals FPlayerSkin *skins; @@ -46,7 +44,7 @@ PalEntry OtherGameSkinPalette[256]; // [RH] Removed checks for coexistance of rotation 0 with other // rotations and made it look more like BOOM's version. // -static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool flipped) +static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool flipped, spriteframewithrotate *sprtemp, int &maxframe) { unsigned rotation; @@ -119,7 +117,7 @@ static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool // [RH] Seperated out of R_InitSpriteDefs() -static void R_InstallSprite (int num) +static void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxframe) { int frame; int framestart; @@ -267,6 +265,8 @@ void R_InitSpriteDefs () unsigned int i, j, smax, vmax; DWORD intname; + spriteframewithrotate sprtemp[MAX_SPRITE_FRAMES]; + // Create a hash table to speed up the process smax = TexMan.NumTextures(); hashes = new Hasher[smax]; @@ -348,7 +348,7 @@ void R_InitSpriteDefs () sprtemp[j].Voxel = NULL; } - maxframe = -1; + int maxframe = -1; intname = sprites[i].dwName; // scan the lumps, filling in the frames for whatever is found @@ -358,10 +358,10 @@ void R_InitSpriteDefs () FTexture *tex = TexMan[hash]; if (TEX_DWNAME(tex) == intname) { - bool res = R_InstallSpriteLump (FTextureID(hash), tex->Name[4] - 'A', tex->Name[5], false); + bool res = R_InstallSpriteLump (FTextureID(hash), tex->Name[4] - 'A', tex->Name[5], false, sprtemp, maxframe); if (tex->Name[6] && res) - R_InstallSpriteLump (FTextureID(hash), tex->Name[6] - 'A', tex->Name[7], true); + R_InstallSpriteLump (FTextureID(hash), tex->Name[6] - 'A', tex->Name[7], true, sprtemp, maxframe); } hash = hashes[hash].Next; } @@ -398,7 +398,7 @@ void R_InitSpriteDefs () hash = vh->Next; } - R_InstallSprite ((int)i); + R_InstallSprite ((int)i, sprtemp, maxframe); } delete[] hashes; @@ -762,13 +762,14 @@ void R_InitSkins (void) for(int spr = 0; spr<2; spr++) { + spriteframewithrotate sprtemp[MAX_SPRITE_FRAMES]; memset (sprtemp, 0xFFFF, sizeof(sprtemp)); for (k = 0; k < MAX_SPRITE_FRAMES; ++k) { sprtemp[k].Flip = 0; sprtemp[k].Voxel = NULL; } - maxframe = -1; + int maxframe = -1; if (spr == 1) { @@ -792,10 +793,10 @@ void R_InitSkins (void) if (lnameint == intname) { FTextureID picnum = TexMan.CreateTexture(k, FTexture::TEX_SkinSprite); - bool res = R_InstallSpriteLump (picnum, lname[4] - 'A', lname[5], false); + bool res = R_InstallSpriteLump (picnum, lname[4] - 'A', lname[5], false, sprtemp, maxframe); if (lname[6] && res) - R_InstallSpriteLump (picnum, lname[6] - 'A', lname[7], true); + R_InstallSpriteLump (picnum, lname[6] - 'A', lname[7], true, sprtemp, maxframe); } } @@ -811,7 +812,7 @@ void R_InitSkins (void) int sprno = (int)sprites.Push (temp); if (spr==0) skins[i].sprite = sprno; else skins[i].crouchsprite = sprno; - R_InstallSprite (sprno); + R_InstallSprite (sprno, sprtemp, maxframe); } } From f1df400cc7c7256530d00b94de37a23767f82b6b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 9 Dec 2016 03:17:35 +0100 Subject: [PATCH 1387/1509] Add some portal segment culling and disable sector portals for now --- src/r_poly_cull.cpp | 15 ++++++++-- src/r_poly_cull.h | 5 ++-- src/r_poly_plane.cpp | 66 +++++++++++++++++++++++++++++++++++++++---- src/r_poly_plane.h | 5 ++-- src/r_poly_portal.cpp | 4 ++- src/r_poly_portal.h | 10 +++++++ src/r_poly_scene.cpp | 22 ++++++++++++--- src/r_poly_scene.h | 3 ++ src/r_poly_wall.cpp | 21 ++++++++------ src/r_poly_wall.h | 7 +++-- 10 files changed, 129 insertions(+), 29 deletions(-) diff --git a/src/r_poly_cull.cpp b/src/r_poly_cull.cpp index a688c2644..59b7c0c5a 100644 --- a/src/r_poly_cull.cpp +++ b/src/r_poly_cull.cpp @@ -30,7 +30,6 @@ void PolyCull::CullScene(const TriMatrix &worldToClip, const Vec4f &portalClipPlane) { - ClearSolidSegments(); PvsSectors.clear(); frustumPlanes = FrustumPlanes(worldToClip); PortalClipPlane = portalClipPlane; @@ -42,8 +41,6 @@ void PolyCull::CullScene(const TriMatrix &worldToClip, const Vec4f &portalClipPl CullSubsector(subsectors); else CullNode(nodes + numnodes - 1); // The head node is the last node output. - - ClearSolidSegments(); } void PolyCull::CullNode(void *node) @@ -109,6 +106,18 @@ void PolyCull::ClearSolidSegments() SolidSegments.push_back({ SolidCullScale , 0x7fff }); } +void PolyCull::InvertSegments() +{ + TempInvertSolidSegments.swap(SolidSegments); + ClearSolidSegments(); + int x = -0x7fff; + for (const auto &segment : TempInvertSolidSegments) + { + MarkSegmentCulled(x, segment.X1 - 1); + x = segment.X2 + 1; + } +} + bool PolyCull::IsSegmentCulled(int x1, int x2) const { x1 = clamp(x1, -0x7ffe, 0x7ffd); diff --git a/src/r_poly_cull.h b/src/r_poly_cull.h index fe3cd9f5d..4c0cfe314 100644 --- a/src/r_poly_cull.h +++ b/src/r_poly_cull.h @@ -35,11 +35,13 @@ enum class LineSegmentRange class PolyCull { public: + void ClearSolidSegments(); void CullScene(const TriMatrix &worldToClip, const Vec4f &portalClipPlane); LineSegmentRange GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const; void MarkSegmentCulled(int x1, int x2); bool IsSegmentCulled(int x1, int x2) const; + void InvertSegments(); std::vector PvsSectors; double MaxCeilingHeight = 0.0; @@ -60,9 +62,8 @@ private: // Returns true if some part of the bbox might be visible. bool CheckBBox(float *bspcoord); - void ClearSolidSegments(); - std::vector SolidSegments; + std::vector TempInvertSolidSegments; const int SolidCullScale = 3000; FrustumPlanes frustumPlanes; diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 24b00af00..c7f011a76 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -32,7 +32,7 @@ EXTERN_CVAR(Int, r_3dfloors) -void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals) +void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals) { RenderPolyPlane plane; @@ -84,8 +84,8 @@ void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const Vec4f &cl } } - plane.Render(worldToClip, clipPlane, sub, subsectorDepth, stencilValue, true, skyCeilingHeight, sectorPortals); - plane.Render(worldToClip, clipPlane, sub, subsectorDepth, stencilValue, false, skyFloorHeight, sectorPortals); + plane.Render(worldToClip, clipPlane, cull, sub, subsectorDepth, stencilValue, true, skyCeilingHeight, sectorPortals); + plane.Render(worldToClip, clipPlane, cull, sub, subsectorDepth, stencilValue, false, skyFloorHeight, sectorPortals); } void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakeFloor) @@ -147,9 +147,10 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); } -void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals) +void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals) { - FSectorPortal *portal = sub->sector->ValidatePortal(ceiling ? sector_t::ceiling : sector_t::floor); + std::vector portalSegments; + FSectorPortal *portal = nullptr;// sub->sector->ValidatePortal(ceiling ? sector_t::ceiling : sector_t::floor); PolyDrawSectorPortal *polyportal = nullptr; if (portal && (portal->mFlags & PORTSF_INSKYBOX) == PORTSF_INSKYBOX) // Do not recurse into portals we already recursed into portal = nullptr; @@ -157,7 +158,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan { for (auto &p : sectorPortals) { - if (p->Portal == portal) // To do: what other criterias do we need to check for? + if (p->Portal == portal) // To do: what other criteria do we need to check for? { polyportal = p.get(); break; @@ -168,6 +169,54 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan sectorPortals.push_back(std::make_unique(portal, ceiling)); polyportal = sectorPortals.back().get(); } + + // Calculate portal clipping + + DVector2 v; + bool inside = true; + double vdist = 1.0e10; + + portalSegments.reserve(sub->numlines); + for (uint32_t i = 0; i < sub->numlines; i++) + { + seg_t *line = &sub->firstline[i]; + + DVector2 pt1 = line->v1->fPos() - ViewPos; + DVector2 pt2 = line->v2->fPos() - ViewPos; + if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0) + inside = false; + + double dist = pt1.LengthSquared(); + if (dist < vdist) + { + v = line->v1->fPos(); + vdist = dist; + } + dist = pt2.LengthSquared(); + if (dist < vdist) + { + v = line->v2->fPos(); + vdist = dist; + } + + int sx1, sx2; + LineSegmentRange range = cull.GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2); + if (range == LineSegmentRange::HasSegment) + portalSegments.push_back({ sx1, sx2 }); + } + + if (inside) + { + polyportal->PortalPlane = Vec4f(0.0f, 0.0f, 0.0f, 1.0f); + } + else if(polyportal->PortalPlane == Vec4f(0.0f) || Vec4f::dot(polyportal->PortalPlane, Vec4f((float)v.X, (float)v.Y, 0.0f, 1.0f)) > 0.0f) + { + DVector2 planePos = v; + DVector2 planeNormal = v - ViewPos; + planeNormal.MakeUnit(); + double planeD = -(planeNormal | (planePos + planeNormal * 0.001)); + polyportal->PortalPlane = Vec4f((float)planeNormal.X, (float)planeNormal.Y, 0.0f, (float)planeD); + } } sector_t *fakesector = sub->sector->heightsec; @@ -300,6 +349,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan args.stencilwritevalue = polyportal->StencilValue; PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, subsectorDepth }); + polyportal->Segments.insert(polyportal->Segments.end(), portalSegments.begin(), portalSegments.end()); } } else @@ -308,6 +358,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan { args.stencilwritevalue = polyportal->StencilValue; polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, subsectorDepth }); + polyportal->Segments.insert(polyportal->Segments.end(), portalSegments.begin(), portalSegments.end()); } else { @@ -385,7 +436,10 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); if (portal) + { polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, subsectorDepth }); + polyportal->Segments.insert(polyportal->Segments.end(), portalSegments.begin(), portalSegments.end()); + } } } } diff --git a/src/r_poly_plane.h b/src/r_poly_plane.h index 396a9e4a8..be307b4e2 100644 --- a/src/r_poly_plane.h +++ b/src/r_poly_plane.h @@ -25,12 +25,13 @@ #include "r_poly_triangle.h" class PolyDrawSectorPortal; +class PolyCull; class Vec4f; class RenderPolyPlane { public: - static void RenderPlanes(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals); + static void RenderPlanes(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals); private: struct UVTransform @@ -48,6 +49,6 @@ private: }; void Render3DFloor(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakefloor); - void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals); + void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals); TriVertex PlaneVertex(vertex_t *v1, double height, const UVTransform &transform); }; diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 96df9daf0..580622c1f 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -64,7 +64,8 @@ void PolyDrawSectorPortal::Render(int portalDepth) TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z); TriMatrix worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; - RenderPortal.SetViewpoint(worldToClip, Vec4f(0.0f, 0.0f, 0.0f, 1.0f), StencilValue); + RenderPortal.SetViewpoint(worldToClip, PortalPlane, StencilValue); + RenderPortal.SetPortalSegments(Segments); RenderPortal.Render(portalDepth); RestoreGlobals(); @@ -175,6 +176,7 @@ void PolyDrawLinePortal::Render(int portalDepth) Vec4f portalPlane((float)planeNormal.X, (float)planeNormal.Y, 0.0f, (float)planeD); RenderPortal.SetViewpoint(worldToClip, portalPlane, StencilValue); + RenderPortal.SetPortalSegments(Segments); RenderPortal.Render(portalDepth); RestoreGlobals(); diff --git a/src/r_poly_portal.h b/src/r_poly_portal.h index 6cad98ff6..4f2356761 100644 --- a/src/r_poly_portal.h +++ b/src/r_poly_portal.h @@ -33,6 +33,13 @@ struct PolyPortalVertexRange uint32_t SubsectorDepth; }; +class PolyPortalSegment +{ +public: + PolyPortalSegment(int x1, int x2) : X1(x1), X2(x2) { } + int X1, X2; +}; + class PolyDrawSectorPortal { public: @@ -44,6 +51,8 @@ public: FSectorPortal *Portal = nullptr; uint32_t StencilValue = 0; std::vector Shape; + std::vector Segments; + Vec4f PortalPlane = Vec4f(0.0f); private: void SaveGlobals(); @@ -73,6 +82,7 @@ public: line_t *Mirror = nullptr; uint32_t StencilValue = 0; std::vector Shape; + std::vector Segments; private: void SaveGlobals(); diff --git a/src/r_poly_scene.cpp b/src/r_poly_scene.cpp index 3b03507f1..c0697f55e 100644 --- a/src/r_poly_scene.cpp +++ b/src/r_poly_scene.cpp @@ -50,10 +50,24 @@ void RenderPolyScene::SetViewpoint(const TriMatrix &worldToClip, const Vec4f &po PortalPlane = portalPlane; } +void RenderPolyScene::SetPortalSegments(const std::vector &segments) +{ + Cull.ClearSolidSegments(); + for (const auto &segment : segments) + { + Cull.MarkSegmentCulled(segment.X1, segment.X2); + } + Cull.InvertSegments(); + PortalSegmentsAdded = true; +} + void RenderPolyScene::Render(int portalDepth) { ClearBuffers(); + if (!PortalSegmentsAdded) + Cull.ClearSolidSegments(); Cull.CullScene(WorldToClip, PortalPlane); + Cull.ClearSolidSegments(); RenderSectors(); RenderPortals(portalDepth); } @@ -91,7 +105,7 @@ void RenderPolyScene::RenderSubsector(subsector_t *sub) if (sub->sector->CenterFloor() != sub->sector->CenterCeiling()) { - RenderPolyPlane::RenderPlanes(WorldToClip, PortalPlane, sub, subsectorDepth, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, SectorPortals); + RenderPolyPlane::RenderPlanes(WorldToClip, PortalPlane, Cull, sub, subsectorDepth, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, SectorPortals); } for (uint32_t i = 0; i < sub->numlines; i++) @@ -199,12 +213,12 @@ void RenderPolyScene::RenderLine(subsector_t *sub, seg_t *line, sector_t *fronts if (!(fakeFloor->flags & FF_EXISTS)) continue; if (!(fakeFloor->flags & FF_RENDERPLANES)) continue; if (!fakeFloor->model) continue; - RenderPolyWall::Render3DFloorLine(WorldToClip, PortalPlane, line, frontsector, subsectorDepth, StencilValue, fakeFloor, TranslucentObjects); + RenderPolyWall::Render3DFloorLine(WorldToClip, PortalPlane, Cull, line, frontsector, subsectorDepth, StencilValue, fakeFloor, TranslucentObjects); } } // Render wall, and update culling info if its an occlusion blocker - if (RenderPolyWall::RenderLine(WorldToClip, PortalPlane, line, frontsector, subsectorDepth, StencilValue, TranslucentObjects, LinePortals)) + if (RenderPolyWall::RenderLine(WorldToClip, PortalPlane, Cull, line, frontsector, subsectorDepth, StencilValue, TranslucentObjects, LinePortals)) { if (segmentRange == LineSegmentRange::HasSegment) Cull.MarkSegmentCulled(sx1, sx2); @@ -332,7 +346,7 @@ void RenderPolyScene::RenderTranslucent(int portalDepth) } else if (!obj.thing) { - obj.wall.Render(WorldToClip, PortalPlane); + obj.wall.Render(WorldToClip, PortalPlane, Cull); } else if ((obj.thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) { diff --git a/src/r_poly_scene.h b/src/r_poly_scene.h index 1e3037b12..00502e53e 100644 --- a/src/r_poly_scene.h +++ b/src/r_poly_scene.h @@ -67,6 +67,7 @@ public: class PolyDrawSectorPortal; class PolyDrawLinePortal; +class PolyPortalSegment; // Renders everything from a specific viewpoint class RenderPolyScene @@ -75,6 +76,7 @@ public: RenderPolyScene(); ~RenderPolyScene(); void SetViewpoint(const TriMatrix &worldToClip, const Vec4f &portalPlane, uint32_t stencilValue); + void SetPortalSegments(const std::vector &segments); void Render(int portalDepth); void RenderTranslucent(int portalDepth); @@ -100,4 +102,5 @@ private: std::vector> SectorPortals; std::vector> LinePortals; + bool PortalSegmentsAdded = false; }; diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index efc953013..bcb5bb16b 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -35,7 +35,7 @@ EXTERN_CVAR(Bool, r_drawmirrors) -bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals) +bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals) { PolyDrawLinePortal *polyportal = nullptr; if (line->backsector == nullptr && line->linedef && line->sidedef == line->linedef->sidedef[0] && (line->linedef->special == Line_Mirror && r_drawmirrors)) @@ -91,7 +91,7 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const Vec4f &clipP wall.UnpeggedCeil = frontceilz1; wall.Texpart = side_t::mid; wall.Polyportal = polyportal; - wall.Render(worldToClip, clipPlane); + wall.Render(worldToClip, clipPlane, cull); return true; } } @@ -126,7 +126,7 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const Vec4f &clipP wall.BottomZ = topfloorz1; wall.UnpeggedCeil = topceilz1; wall.Texpart = side_t::top; - wall.Render(worldToClip, clipPlane); + wall.Render(worldToClip, clipPlane, cull); } if ((bottomfloorz1 < bottomceilz1 || bottomfloorz2 < bottomceilz2) && line->sidedef) @@ -136,7 +136,7 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const Vec4f &clipP wall.BottomZ = bottomfloorz2; wall.UnpeggedCeil = topceilz1; wall.Texpart = side_t::bottom; - wall.Render(worldToClip, clipPlane); + wall.Render(worldToClip, clipPlane, cull); } if (line->sidedef) @@ -155,14 +155,14 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const Vec4f &clipP if (polyportal) { wall.Polyportal = polyportal; - wall.Render(worldToClip, clipPlane); + wall.Render(worldToClip, clipPlane, cull); } } } return polyportal != nullptr; } -void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput) +void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput) { double frontceilz1 = fakeFloor->top.plane->ZatPoint(line->v1); double frontfloorz1 = fakeFloor->bottom.plane->ZatPoint(line->v1); @@ -182,7 +182,7 @@ void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, const Vec4f wall.BottomZ = frontfloorz1; wall.UnpeggedCeil = frontceilz1; wall.Texpart = side_t::mid; - wall.Render(worldToClip, clipPlane); + wall.Render(worldToClip, clipPlane, cull); } void RenderPolyWall::SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2) @@ -195,7 +195,7 @@ void RenderPolyWall::SetCoords(const DVector2 &v1, const DVector2 &v2, double ce this->floor2 = floor2; } -void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane) +void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull) { FTexture *tex = GetTexture(); if (!tex && !Polyportal) @@ -266,6 +266,11 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane args.stencilwritevalue = Polyportal->StencilValue; PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); Polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, args.uniforms.subsectorDepth }); + + int sx1, sx2; + LineSegmentRange range = cull.GetSegmentRangeForLine(v1.X, v1.Y, v2.X, v2.Y, sx1, sx2); + if (range == LineSegmentRange::HasSegment) + Polyportal->Segments.push_back({ sx1, sx2 }); } else if (!Masked) { diff --git a/src/r_poly_wall.h b/src/r_poly_wall.h index bcecd5a05..8443a174a 100644 --- a/src/r_poly_wall.h +++ b/src/r_poly_wall.h @@ -26,16 +26,17 @@ class PolyTranslucentObject; class PolyDrawLinePortal; +class PolyCull; class Vec4f; class RenderPolyWall { public: - static bool RenderLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals); - static void Render3DFloorLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput); + static bool RenderLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals); + static void Render3DFloorLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput); void SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2); - void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane); + void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull); DVector2 v1; DVector2 v2; From 6609403fbe739c52e7a6a83aaf7fd5495d6eebf5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 9 Dec 2016 10:27:18 +0100 Subject: [PATCH 1388/1509] Fix null pointer crash in rt column drawers if rt_init is not called before the first draw --- src/r_thread.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/r_thread.h b/src/r_thread.h index 7962dfc20..e44d872c2 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -42,6 +42,12 @@ void R_EndDrawerCommands(); class DrawerThread { public: + DrawerThread() + { + dc_temp = dc_temp_buff; + dc_temp_rgba = dc_temp_rgbabuff_rgba; + } + std::thread thread; // Thread line index of this thread From 5d210c64e0d0146d4c5c8ea85c07f4e5198b0303 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Dec 2016 00:41:34 +0100 Subject: [PATCH 1389/1509] - got rid of ksgn. Because every bit of Build code that can be removed is a good thing. This was only used in two places, one of which could be done better, the other one in the voxel drawer setup now uses a local C-inline version. (cherry picked from commit 5536184beed578e2b9df9ae673b2e965af92b2c0) --- src/basicinlines.h | 6 ------ src/gccinlines.h | 14 -------------- src/mscinlines.h | 9 --------- src/p_user.cpp | 6 +----- src/r_things.cpp | 7 ++++++- 5 files changed, 7 insertions(+), 35 deletions(-) diff --git a/src/basicinlines.h b/src/basicinlines.h index cc562f2b8..2f81a6c64 100644 --- a/src/basicinlines.h +++ b/src/basicinlines.h @@ -195,9 +195,3 @@ static __forceinline void clearbufshort (void *buff, unsigned int count, WORD cl } } -static __forceinline SDWORD ksgn (SDWORD a) -{ - if (a < 0) return -1; - else if (a > 0) return 1; - else return 0; -} diff --git a/src/gccinlines.h b/src/gccinlines.h index 6cad307f7..7311e9695 100644 --- a/src/gccinlines.h +++ b/src/gccinlines.h @@ -316,17 +316,3 @@ static inline void clearbufshort (void *buff, unsigned int count, WORD clear) :"cc"); } -static inline SDWORD ksgn (SDWORD a) -{ - SDWORD result, dummy; - - asm volatile - ("add %0,%0\n\t" - "sbb %1,%1\n\t" - "cmp %0,%1\n\t" - "adc $0,%1" - :"=r" (dummy), "=r" (result) - :"0" (a) - :"cc"); - return result; -} diff --git a/src/mscinlines.h b/src/mscinlines.h index a8dd5fea7..7befe5395 100644 --- a/src/mscinlines.h +++ b/src/mscinlines.h @@ -339,13 +339,4 @@ __forceinline void clearbufshort (void *buff, unsigned int count, WORD clear) } } -__forceinline SDWORD ksgn (SDWORD a) -{ - __asm mov edx,a - __asm add edx,edx - __asm sbb eax,eax - __asm cmp eax,edx - __asm adc eax,0 -} - #pragma warning (default: 4035) diff --git a/src/p_user.cpp b/src/p_user.cpp index e894fa201..8654009e1 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2610,11 +2610,7 @@ void P_PlayerThink (player_t *player) else if (cmd->ucmd.upmove != 0) { // Clamp the speed to some reasonable maximum. - int magnitude = abs (cmd->ucmd.upmove); - if (magnitude > 0x300) - { - cmd->ucmd.upmove = ksgn (cmd->ucmd.upmove) * 0x300; - } + cmd->ucmd.upmove = clamp(cmd->ucmd.upmove, -0x300, 0x300); if (player->mo->waterlevel >= 2 || (player->mo->flags2 & MF2_FLY) || (player->cheats & CF_NOCLIP2)) { player->mo->Vel.Z = player->mo->Speed * cmd->ucmd.upmove / 128.; diff --git a/src/r_things.cpp b/src/r_things.cpp index 57e101feb..f5c75f012 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2907,6 +2907,11 @@ void R_DrawParticle_rgba(vissprite_t *vis) extern double BaseYaspectMul;; +inline int sgn(int v) +{ + return v < 0 ? -1 : v > 0 ? 1 : 0; +} + void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, const FVector3 &dasprpos, DAngle dasprang, fixed_t daxscale, fixed_t dayscale, FVoxel *voxobj, @@ -3048,7 +3053,7 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, xe += xi; ye += yi; } - i = ksgn(ys-backy)+ksgn(xs-backx)*3+4; + i = sgn(ys - backy) + sgn(xs - backx) * 3 + 4; switch(i) { case 6: case 7: x1 = 0; y1 = 0; break; From 695b08ed4bebb0bb8b08dc34151b06c0715ec983 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Dec 2016 10:31:17 +0100 Subject: [PATCH 1390/1509] - removed some unused functions from m_fixed.h. - removed the Build license note from r_bsp.cpp. This note was for code in R_AddLine which had been both refactored into several subfunctions and completely replaced with a floating point version. What is left is just some basic common math without any traits that resemble anything in Build. (cherry picked from commit 8748b9ef6defc5c8a2d9570da29afcc5dcac8bbf) --- src/m_fixed.h | 57 --------------------------------------------------- src/r_bsp.cpp | 6 ------ 2 files changed, 63 deletions(-) diff --git a/src/m_fixed.h b/src/m_fixed.h index 506b9702c..4719ac468 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -79,63 +79,6 @@ inline SDWORD SafeDivScale32 (SDWORD a, SDWORD b) #define FixedMul MulScale16 #define FixedDiv SafeDivScale16 -inline void qinterpolatedown16 (SDWORD *out, DWORD count, SDWORD val, SDWORD delta) -{ - if (count & 1) - { - out[0] = val >> 16; - val += delta; - } - count >>= 1; - while (count-- != 0) - { - int temp = val + delta; - out[0] = val >> 16; - val = temp + delta; - out[1] = temp >> 16; - out += 2; - } -} - -inline void qinterpolatedown16short (short *out, DWORD count, SDWORD val, SDWORD delta) -{ - if (count) - { - if ((size_t)out & 2) - { // align to dword boundary - *out++ = (short)(val >> 16); - count--; - val += delta; - } - DWORD *o2 = (DWORD *)out; - DWORD c2 = count>>1; - while (c2-- != 0) - { - SDWORD temp = val + delta; - *o2++ = (temp & 0xffff0000) | ((DWORD)val >> 16); - val = temp + delta; - } - if (count & 1) - { - *(short *)o2 = (short)(val >> 16); - } - } -} - - //returns num/den, dmval = num%den -inline SDWORD DivMod (SDWORD num, SDWORD den, SDWORD *dmval) -{ - *dmval = num % den; - return num / den; -} - - //returns num%den, dmval = num/den -inline SDWORD ModDiv (SDWORD num, SDWORD den, SDWORD *dmval) -{ - *dmval = num / den; - return num % den; -} - inline fixed_t FloatToFixed(double f) { return xs_Fix<16>::ToFix(f); diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 8004f0dfc..bb076d72f 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -17,12 +17,6 @@ // DESCRIPTION: // BSP traversal, handling of LineSegs for rendering. // -// This file contains some code from the Build Engine. -// -// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman -// Ken Silverman's official web site: "http://www.advsys.net/ken" -// See the included license file "BUILDLIC.TXT" for license info. -// //----------------------------------------------------------------------------- From c61f30a6274c43041949e44ff1a6b9a7749c45cb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Dec 2016 12:48:10 +0100 Subject: [PATCH 1391/1509] - got rid of clearbuf. This was used in only 4 places, 3 of which could easily be replaced with a memset, and the fourth, in the Strife status bar, suffering from a pointless performance optimization, rendering the code unreadable - the code spent here per frame is utterly insignificant so clarity should win here. (cherry picked from commit 12a99c3f3cc75fa3b241d89a8ebe43c8d3c07809) --- src/basicinlines.h | 9 --------- src/g_strife/strife_sbar.cpp | 10 +++------- src/gccinlines.h | 13 ------------- src/mscinlines.h | 9 --------- src/p_maputl.cpp | 2 +- src/r_data/sprites.cpp | 4 ++-- 6 files changed, 6 insertions(+), 41 deletions(-) diff --git a/src/basicinlines.h b/src/basicinlines.h index 2f81a6c64..488cdf552 100644 --- a/src/basicinlines.h +++ b/src/basicinlines.h @@ -177,15 +177,6 @@ static inline SDWORD DivScale30 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD) static inline SDWORD DivScale31 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 31) / b); } static inline SDWORD DivScale32 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 32) / b); } -static __forceinline void clearbuf (void *buff, unsigned int count, SDWORD clear) -{ - SDWORD *b2 = (SDWORD *)buff; - for (unsigned int i = 0; i != count; ++i) - { - b2[i] = clear; - } -} - static __forceinline void clearbufshort (void *buff, unsigned int count, WORD clear) { SWORD *b2 = (SWORD *)buff; diff --git a/src/g_strife/strife_sbar.cpp b/src/g_strife/strife_sbar.cpp index 355910616..ccf17f8f1 100644 --- a/src/g_strife/strife_sbar.cpp +++ b/src/g_strife/strife_sbar.cpp @@ -169,14 +169,10 @@ void FHealthBar::MakeTexture () void FHealthBar::FillBar (int min, int max, BYTE light, BYTE dark) { -#ifdef __BIG_ENDIAN__ - SDWORD fill = (light << 24) | (dark << 16) | (light << 8) | dark; -#else - SDWORD fill = light | (dark << 8) | (light << 16) | (dark << 24); -#endif - if (max > min) + for (int i = min*2; i < max*2; i++) { - clearbuf (&Pixels[min*4], max - min, fill); + Pixels[i * 2] = light; + Pixels[i * 2 + 1] = dark; } } diff --git a/src/gccinlines.h b/src/gccinlines.h index 7311e9695..54a2448c7 100644 --- a/src/gccinlines.h +++ b/src/gccinlines.h @@ -291,19 +291,6 @@ static inline SDWORD DivScale32 (SDWORD a, SDWORD b) return result; } -static inline void clearbuf (void *buff, int count, SDWORD clear) -{ - int dummy1, dummy2; - asm volatile - ("rep stosl" - :"=D" (dummy1), - "=c" (dummy2) - : "D" (buff), - "c" (count), - "a" (clear) - ); -} - static inline void clearbufshort (void *buff, unsigned int count, WORD clear) { asm volatile diff --git a/src/mscinlines.h b/src/mscinlines.h index 7befe5395..1aded4e7b 100644 --- a/src/mscinlines.h +++ b/src/mscinlines.h @@ -321,15 +321,6 @@ __forceinline SDWORD DivScale32 (SDWORD a, SDWORD b) __asm idiv b } -__forceinline void clearbuf (void *buff, unsigned int count, SDWORD clear) -{ - SDWORD *b2 = (SDWORD *)buff; - for (unsigned int i = 0; i != count; ++i) - { - b2[i] = clear; - } -} - __forceinline void clearbufshort (void *buff, unsigned int count, WORD clear) { SWORD *b2 = (SWORD *)buff; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 31b412598..fdf66e969 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -925,7 +925,7 @@ void FBlockThingsIterator::init(const FBoundingBox &box) void FBlockThingsIterator::ClearHash() { - clearbuf(Buckets, countof(Buckets), -1); + memset(Buckets, -1, sizeof(Buckets)); NumFixedHash = 0; DynHash.Clear(); } diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index 3e0cb80cc..b384211fc 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -270,7 +270,7 @@ void R_InitSpriteDefs () // Create a hash table to speed up the process smax = TexMan.NumTextures(); hashes = new Hasher[smax]; - clearbuf(hashes, sizeof(Hasher)*smax/4, -1); + memset(hashes, -1, sizeof(Hasher)*smax); for (i = 0; i < smax; ++i) { FTexture *tex = TexMan.ByIndex(i); @@ -285,7 +285,7 @@ void R_InitSpriteDefs () // Repeat, for voxels vmax = Wads.GetNumLumps(); vhashes = new VHasher[vmax]; - clearbuf(vhashes, sizeof(VHasher)*vmax/4, -1); + memset(vhashes, -1, sizeof(VHasher)*vmax); for (i = 0; i < vmax; ++i) { if (Wads.GetLumpNamespace(i) == ns_voxels) From cfd6bcec5ea628870de6e6fd1f26adf9ad7c4ac4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Dec 2016 13:04:53 +0100 Subject: [PATCH 1392/1509] - more Build cleanup: Moved clearbufshort out of Build derived headers, removed the inline version for GCC 32 bit which was actually Build derived and renamed the C-version of this function, which does not originate from Build to 'fillshort'. - cleaned out a lot the SafeDivScale stuff in m_fixed.h. The only SafeDivScale variant still in use was #16 for FixedDiv, so all the SafeDivScale stuff has been removed and the 16 variant renamed to FixedDiv because that's the only form in which it is still being used. (2x in R_DrawVoxel and 1x in ACS's FixedDiv PCode.) - removed Build notice from m_fixed.h because aside from the inlines includes there is nothing here from Build anymore. (cherry picked from commit eab06ef0866b0c9ed84f94a8745e747116e2eba7) --- src/basicinlines.h | 9 ----- src/g_shared/a_lightning.cpp | 4 +- src/gccinlines.h | 13 ------- src/m_fixed.h | 73 +++++++----------------------------- src/mscinlines.h | 9 ----- src/p_effect.cpp | 2 +- src/r_bsp.cpp | 4 +- src/r_draw.cpp | 4 +- src/r_main.cpp | 4 +- src/r_plane.cpp | 10 ++--- src/r_segs.cpp | 12 +++--- src/r_things.cpp | 4 +- src/v_draw.cpp | 4 +- 13 files changed, 37 insertions(+), 115 deletions(-) diff --git a/src/basicinlines.h b/src/basicinlines.h index 488cdf552..849257281 100644 --- a/src/basicinlines.h +++ b/src/basicinlines.h @@ -177,12 +177,3 @@ static inline SDWORD DivScale30 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD) static inline SDWORD DivScale31 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 31) / b); } static inline SDWORD DivScale32 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 32) / b); } -static __forceinline void clearbufshort (void *buff, unsigned int count, WORD clear) -{ - SWORD *b2 = (SWORD *)buff; - for (unsigned int i = 0; i != count; ++i) - { - b2[i] = clear; - } -} - diff --git a/src/g_shared/a_lightning.cpp b/src/g_shared/a_lightning.cpp index 3f44f2fdd..bbc663812 100644 --- a/src/g_shared/a_lightning.cpp +++ b/src/g_shared/a_lightning.cpp @@ -23,7 +23,7 @@ DLightningThinker::DLightningThinker () NextLightningFlash = ((pr_lightning()&15)+5)*35; // don't flash at level start LightningLightLevels.Resize(numsectors); - clearbufshort(&LightningLightLevels[0], numsectors, SHRT_MAX); + fillshort(&LightningLightLevels[0], numsectors, SHRT_MAX); } DLightningThinker::~DLightningThinker () @@ -87,7 +87,7 @@ void DLightningThinker::LightningFlash () tempSec->SetLightLevel(LightningLightLevels[j]); } } - clearbufshort(&LightningLightLevels[0], numsectors, SHRT_MAX); + fillshort(&LightningLightLevels[0], numsectors, SHRT_MAX); level.flags &= ~LEVEL_SWAPSKIES; } return; diff --git a/src/gccinlines.h b/src/gccinlines.h index 54a2448c7..eac1f3e6f 100644 --- a/src/gccinlines.h +++ b/src/gccinlines.h @@ -290,16 +290,3 @@ static inline SDWORD DivScale32 (SDWORD a, SDWORD b) : "cc"); return result; } - -static inline void clearbufshort (void *buff, unsigned int count, WORD clear) -{ - asm volatile - ("shr $1,%%ecx\n\t" - "rep stosl\n\t" - "adc %%ecx,%%ecx\n\t" - "rep stosw" - :"=D" (buff), "=c" (count) - :"D" (buff), "c" (count), "a" (clear|(clear<<16)) - :"cc"); -} - diff --git a/src/m_fixed.h b/src/m_fixed.h index 4719ac468..33d339608 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -1,11 +1,3 @@ -// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman -// Ken Silverman's official web site: "http://www.advsys.net/ken" -// See the included license file "BUILDLIC.TXT" for license info. -// -// This file is based on pragmas.h from Ken Silverman's original Build -// source code release and contains routines that were originally -// inline assembly but are not now. - #ifndef __M_FIXED__ #define __M_FIXED__ @@ -20,64 +12,25 @@ #include "basicinlines.h" #endif -#include "xs_Float.h" - -#define MAKESAFEDIVSCALE(x) \ - inline SDWORD SafeDivScale##x (SDWORD a, SDWORD b) \ - { \ - if ((DWORD)abs(a) >> (31-x) >= (DWORD)abs (b)) \ - return (a^b)<0 ? FIXED_MIN : FIXED_MAX; \ - return DivScale##x (a, b); \ - } - -MAKESAFEDIVSCALE(1) -MAKESAFEDIVSCALE(2) -MAKESAFEDIVSCALE(3) -MAKESAFEDIVSCALE(4) -MAKESAFEDIVSCALE(5) -MAKESAFEDIVSCALE(6) -MAKESAFEDIVSCALE(7) -MAKESAFEDIVSCALE(8) -MAKESAFEDIVSCALE(9) -MAKESAFEDIVSCALE(10) -MAKESAFEDIVSCALE(11) -MAKESAFEDIVSCALE(12) -MAKESAFEDIVSCALE(13) -MAKESAFEDIVSCALE(14) -MAKESAFEDIVSCALE(15) -MAKESAFEDIVSCALE(16) -MAKESAFEDIVSCALE(17) -MAKESAFEDIVSCALE(18) -MAKESAFEDIVSCALE(19) -MAKESAFEDIVSCALE(20) -MAKESAFEDIVSCALE(21) -MAKESAFEDIVSCALE(22) -MAKESAFEDIVSCALE(23) -MAKESAFEDIVSCALE(24) -MAKESAFEDIVSCALE(25) -MAKESAFEDIVSCALE(26) -MAKESAFEDIVSCALE(27) -MAKESAFEDIVSCALE(28) -MAKESAFEDIVSCALE(29) -MAKESAFEDIVSCALE(30) -#undef MAKESAFEDIVSCALE - -inline SDWORD SafeDivScale31 (SDWORD a, SDWORD b) +__forceinline void fillshort(void *buff, unsigned int count, WORD clear) { - if ((DWORD)abs(a) >= (DWORD)abs (b)) - return (a^b)<0 ? FIXED_MIN : FIXED_MAX; - return DivScale31 (a, b); + SWORD *b2 = (SWORD *)buff; + for (unsigned int i = 0; i != count; ++i) + { + b2[i] = clear; + } } -inline SDWORD SafeDivScale32 (SDWORD a, SDWORD b) -{ - if ((DWORD)abs(a) >= (DWORD)abs (b) >> 1) - return (a^b)<0 ? FIXED_MIN : FIXED_MAX; - return DivScale32 (a, b); +#include "xs_Float.h" + +inline SDWORD FixedDiv (SDWORD a, SDWORD b) +{ + if ((DWORD)abs(a) >> (31-16) >= (DWORD)abs (b)) + return (a^b)<0 ? FIXED_MIN : FIXED_MAX; + return DivScale16 (a, b); } #define FixedMul MulScale16 -#define FixedDiv SafeDivScale16 inline fixed_t FloatToFixed(double f) { diff --git a/src/mscinlines.h b/src/mscinlines.h index 1aded4e7b..6af2da1de 100644 --- a/src/mscinlines.h +++ b/src/mscinlines.h @@ -321,13 +321,4 @@ __forceinline SDWORD DivScale32 (SDWORD a, SDWORD b) __asm idiv b } -__forceinline void clearbufshort (void *buff, unsigned int count, WORD clear) -{ - SWORD *b2 = (SWORD *)buff; - for (unsigned int i = 0; i != count; ++i) - { - b2[i] = clear; - } -} - #pragma warning (default: 4035) diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 42e82d740..827a457ee 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -198,7 +198,7 @@ void P_FindParticleSubsectors () ParticlesInSubsec.Reserve (numsubsectors - ParticlesInSubsec.Size()); } - clearbufshort (&ParticlesInSubsec[0], numsubsectors, NO_PARTICLE); + fillshort (&ParticlesInSubsec[0], numsubsectors, NO_PARTICLE); if (!r_particles) { diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index bb076d72f..230e16dcc 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -740,8 +740,8 @@ void R_AddLine (seg_t *line) if (line->linedef->special == Line_Horizon) { // Be aware: Line_Horizon does not work properly with sloped planes - clearbufshort (walltop+WallC.sx1, WallC.sx2 - WallC.sx1, centery); - clearbufshort (wallbottom+WallC.sx1, WallC.sx2 - WallC.sx1, centery); + fillshort (walltop+WallC.sx1, WallC.sx2 - WallC.sx1, centery); + fillshort (wallbottom+WallC.sx1, WallC.sx2 - WallC.sx1, centery); } else { diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 766ad8d7a..b23bf4081 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -1641,7 +1641,7 @@ namespace swrenderer if (b2 > t2) { - clearbufshort(spanend + t2, b2 - t2, x); + fillshort(spanend + t2, b2 - t2, x); } R_SetColorMapLight(basecolormap, (float)light, wallshade); @@ -1668,7 +1668,7 @@ namespace swrenderer if (b1 > b2) b2 = b1; if (t2 < b2) { - clearbufshort(spanend + t2, b2 - t2, x); + fillshort(spanend + t2, b2 - t2, x); } rcolormap = lcolormap; R_SetColorMapLight(basecolormap, (float)light, wallshade); diff --git a/src/r_main.cpp b/src/r_main.cpp index 543b7cd59..e79800e49 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -377,7 +377,7 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, pspritexiscale = 1 / pspritexscale; // thing clipping - clearbufshort (screenheightarray, viewwidth, (short)viewheight); + fillshort (screenheightarray, viewwidth, (short)viewheight); R_InitTextureMapping (); @@ -400,7 +400,7 @@ void R_InitRenderer() { atterm(R_ShutdownRenderer); // viewwidth / viewheight are set by the defaults - clearbufshort (zeroarray, MAXWIDTH, 0); + fillshort (zeroarray, MAXWIDTH, 0); R_InitPlanes (); R_InitShadeMaps(); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 3769dda06..f8893dcd7 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -328,9 +328,9 @@ void R_ClearPlanes (bool fullclear) } // opening / clipping determination - clearbufshort (floorclip, viewwidth, viewheight); + fillshort (floorclip, viewwidth, viewheight); // [RH] clip ceiling to console bottom - clearbufshort (ceilingclip, viewwidth, + fillshort (ceilingclip, viewwidth, !screen->Accel2D && ConBottom > viewwindowy && !bRenderingToCanvas ? (ConBottom - viewwindowy) : 0); @@ -503,7 +503,7 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl check->MirrorFlags = MirrorFlags; check->CurrentSkybox = CurrentSkybox; - clearbufshort (check->top, viewwidth, 0x7fff); + fillshort (check->top, viewwidth, 0x7fff); return check; } @@ -588,7 +588,7 @@ visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop) pl = new_pl; pl->left = start; pl->right = stop; - clearbufshort (pl->top, viewwidth, 0x7fff); + fillshort (pl->top, viewwidth, 0x7fff); } return pl; } @@ -1816,7 +1816,7 @@ void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1)) if (b2 > t2) { - clearbufshort (spanend+t2, b2-t2, x); + fillshort (spanend+t2, b2-t2, x); } for (--x; x >= pl->left; --x) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index efc894fc2..c24e7f719 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -531,7 +531,7 @@ clearfog: } else { - clearbufshort(openings + ds->sprtopclip - ds->x1 + x1, x2 - x1, viewheight); + fillshort(openings + ds->sprtopclip - ds->x1 + x1, x2 - x1, viewheight); } } return; @@ -1881,8 +1881,8 @@ void R_RenderSegLoop () call_wallscan(x1, x2, walltop, wallbottom, swall, lwall, yscale, false); } } - clearbufshort (ceilingclip+x1, x2-x1, viewheight); - clearbufshort (floorclip+x1, x2-x1, 0xffff); + fillshort (ceilingclip+x1, x2-x1, viewheight); + fillshort (floorclip+x1, x2-x1, 0xffff); } else { // two sided line @@ -2405,7 +2405,7 @@ void R_StoreWallRange (int start, int stop) { ds_p->sprtopclip = R_NewOpening (stop - start); ds_p->sprbottomclip = R_NewOpening (stop - start); - clearbufshort (openings + ds_p->sprtopclip, stop-start, viewheight); + fillshort (openings + ds_p->sprtopclip, stop-start, viewheight); memset (openings + ds_p->sprbottomclip, -1, (stop-start)*sizeof(short)); ds_p->silhouette = SIL_BOTH; } @@ -2445,7 +2445,7 @@ void R_StoreWallRange (int start, int stop) if (doorclosed || (rw_backfz1 >= rw_frontcz1 && rw_backfz2 >= rw_frontcz2)) { // killough 1/17/98, 2/8/98 ds_p->sprtopclip = R_NewOpening (stop - start); - clearbufshort (openings + ds_p->sprtopclip, stop - start, viewheight); + fillshort (openings + ds_p->sprtopclip, stop - start, viewheight); ds_p->silhouette |= SIL_TOP; } } @@ -2666,7 +2666,7 @@ int WallMostAny(short *mostbuf, double z1, double z2, const FWallCoords *wallc) } else if (y1 > viewheight && y2 > viewheight) // entire line is below screen { - clearbufshort(&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight); + fillshort(&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight); return 12; } diff --git a/src/r_things.cpp b/src/r_things.cpp index f5c75f012..0a9d74c20 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2481,11 +2481,11 @@ void R_DrawSprite (vissprite_t *spr) // for R_DrawVisVoxel(). if (x1 > 0) { - clearbufshort(cliptop, x1, viewheight); + fillshort(cliptop, x1, viewheight); } if (x2 < viewwidth - 1) { - clearbufshort(cliptop + x2, viewwidth - x2, viewheight); + fillshort(cliptop + x2, viewwidth - x2, viewheight); } int minvoxely = spr->gzt <= hzt ? 0 : xs_RoundToInt((spr->gzt - hzt) / spr->yscale); int maxvoxely = spr->gzb > hzb ? INT_MAX : xs_RoundToInt((spr->gzt - hzb) / spr->yscale); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 5c10406bf..a56c63998 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -236,13 +236,13 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) if (bottomclipper[0] != parms.dclip) { - clearbufshort(bottomclipper, screen->GetWidth(), (short)parms.dclip); + fillshort(bottomclipper, screen->GetWidth(), (short)parms.dclip); } if (parms.uclip != 0) { if (topclipper[0] != parms.uclip) { - clearbufshort(topclipper, screen->GetWidth(), (short)parms.uclip); + fillshort(topclipper, screen->GetWidth(), (short)parms.uclip); } mceilingclip = topclipper; } From 1ea559dea4d96cce7e38d2110b736efccba67225 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Dec 2016 13:27:30 +0100 Subject: [PATCH 1393/1509] - removed several unused fixed point math functions from the inlines headers. (cherry picked from commit 86909ecdb2c2a4623bb25408bd61554ac65397fc) --- src/basicinlines.h | 58 ------------------- src/gccinlines.h | 116 ------------------------------------- src/mscinlines.h | 138 --------------------------------------------- 3 files changed, 312 deletions(-) diff --git a/src/basicinlines.h b/src/basicinlines.h index 849257281..135208b81 100644 --- a/src/basicinlines.h +++ b/src/basicinlines.h @@ -20,11 +20,6 @@ static __forceinline SDWORD Scale (SDWORD a, SDWORD b, SDWORD c) return (SDWORD)(((SQWORD)a*b)/c); } -static __forceinline SDWORD MulScale (SDWORD a, SDWORD b, SDWORD c) -{ - return (SDWORD)(((SQWORD)a*b)>>c); -} - static __forceinline SDWORD MulScale1 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 1); } static __forceinline SDWORD MulScale2 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 2); } static __forceinline SDWORD MulScale3 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 3); } @@ -60,11 +55,6 @@ static __forceinline SDWORD MulScale32 (SDWORD a, SDWORD b) { return (SDWORD)((( static __forceinline DWORD UMulScale16 (DWORD a, DWORD b) { return (DWORD)(((QWORD)a * b) >> 16); } -static __forceinline SDWORD DMulScale (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD s) -{ - return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> s); -} - static __forceinline SDWORD DMulScale1 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 1); } static __forceinline SDWORD DMulScale2 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 2); } static __forceinline SDWORD DMulScale3 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 3); } @@ -98,53 +88,6 @@ static __forceinline SDWORD DMulScale30 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) static __forceinline SDWORD DMulScale31 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 31); } static __forceinline SDWORD DMulScale32 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 32); } -static __forceinline SDWORD TMulScale1 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 1); } -static __forceinline SDWORD TMulScale2 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 2); } -static __forceinline SDWORD TMulScale3 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 3); } -static __forceinline SDWORD TMulScale4 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 4); } -static __forceinline SDWORD TMulScale5 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 5); } -static __forceinline SDWORD TMulScale6 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 6); } -static __forceinline SDWORD TMulScale7 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 7); } -static __forceinline SDWORD TMulScale8 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 8); } -static __forceinline SDWORD TMulScale9 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 9); } -static __forceinline SDWORD TMulScale10 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 10); } -static __forceinline SDWORD TMulScale11 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 11); } -static __forceinline SDWORD TMulScale12 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 12); } -static __forceinline SDWORD TMulScale13 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 13); } -static __forceinline SDWORD TMulScale14 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 14); } -static __forceinline SDWORD TMulScale15 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 15); } -static __forceinline SDWORD TMulScale16 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 16); } -static __forceinline SDWORD TMulScale17 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 17); } -static __forceinline SDWORD TMulScale18 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 18); } -static __forceinline SDWORD TMulScale19 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 19); } -static __forceinline SDWORD TMulScale20 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 20); } -static __forceinline SDWORD TMulScale21 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 21); } -static __forceinline SDWORD TMulScale22 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 22); } -static __forceinline SDWORD TMulScale23 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 23); } -static __forceinline SDWORD TMulScale24 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 24); } -static __forceinline SDWORD TMulScale25 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 25); } -static __forceinline SDWORD TMulScale26 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 26); } -static __forceinline SDWORD TMulScale27 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 27); } -static __forceinline SDWORD TMulScale28 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 28); } -static __forceinline SDWORD TMulScale29 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 29); } -static __forceinline SDWORD TMulScale30 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 30); } -static __forceinline SDWORD TMulScale31 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 31); } -static __forceinline SDWORD TMulScale32 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d + (SQWORD)e*f) >> 32); } - -static __forceinline SDWORD BoundMulScale (SDWORD a, SDWORD b, SDWORD c) -{ - SQWORD x = ((SQWORD)a * b) >> c; - return x > 0x7FFFFFFFll ? 0x7FFFFFFF : - x < -0x80000000ll ? 0x80000000 : - (SDWORD)x; -} - -static inline SDWORD DivScale (SDWORD a, SDWORD b, SDWORD c) -{ - return (SDWORD)(((SQWORD)a << c) / b); -} - -static inline SDWORD DivScale1 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 1) / b); } static inline SDWORD DivScale2 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 2) / b); } static inline SDWORD DivScale3 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 3) / b); } static inline SDWORD DivScale4 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 4) / b); } @@ -175,5 +118,4 @@ static inline SDWORD DivScale28 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD) static inline SDWORD DivScale29 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 29) / b); } static inline SDWORD DivScale30 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 30) / b); } static inline SDWORD DivScale31 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 31) / b); } -static inline SDWORD DivScale32 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 32) / b); } diff --git a/src/gccinlines.h b/src/gccinlines.h index eac1f3e6f..925a0037a 100644 --- a/src/gccinlines.h +++ b/src/gccinlines.h @@ -47,23 +47,6 @@ static inline SDWORD Scale (SDWORD a, SDWORD b, SDWORD c) return result; } -static inline SDWORD MulScale (SDWORD a, SDWORD b, SDWORD c) -{ - SDWORD result, dummy; - - asm volatile - ("imull %3\n\t" - "shrdl %b4,%1,%0" - : "=a,a,a,a" (result), - "=d,d,d,d" (dummy) - : "a,a,a,a" (a), - "m,r,m,r" (b), - "c,c,I,I" (c) - : "cc" - ); - return result; -} - #define MAKECONSTMulScale(s) \ static inline SDWORD MulScale##s (SDWORD a, SDWORD b) { return ((SQWORD)a * b) >> s; } @@ -143,92 +126,6 @@ MAKECONSTDMulScale(31) MAKECONSTDMulScale(32) #undef MAKECONSTDMulScale -#define MAKECONSTTMulScale(s) \ - static inline SDWORD TMulScale##s (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD ee) \ - { \ - return (((SQWORD)a * b) + ((SQWORD)c * d) + ((SQWORD)e * ee)) >> s; \ - } - -MAKECONSTTMulScale(1) -MAKECONSTTMulScale(2) -MAKECONSTTMulScale(3) -MAKECONSTTMulScale(4) -MAKECONSTTMulScale(5) -MAKECONSTTMulScale(6) -MAKECONSTTMulScale(7) -MAKECONSTTMulScale(8) -MAKECONSTTMulScale(9) -MAKECONSTTMulScale(10) -MAKECONSTTMulScale(11) -MAKECONSTTMulScale(12) -MAKECONSTTMulScale(13) -MAKECONSTTMulScale(14) -MAKECONSTTMulScale(15) -MAKECONSTTMulScale(16) -MAKECONSTTMulScale(17) -MAKECONSTTMulScale(18) -MAKECONSTTMulScale(19) -MAKECONSTTMulScale(20) -MAKECONSTTMulScale(21) -MAKECONSTTMulScale(22) -MAKECONSTTMulScale(23) -MAKECONSTTMulScale(24) -MAKECONSTTMulScale(25) -MAKECONSTTMulScale(26) -MAKECONSTTMulScale(27) -MAKECONSTTMulScale(28) -MAKECONSTTMulScale(29) -MAKECONSTTMulScale(30) -MAKECONSTTMulScale(31) -MAKECONSTTMulScale(32) -#undef MAKECONSTTMulScale - -static inline SDWORD BoundMulScale (SDWORD a, SDWORD b, SDWORD c) -{ - union { - long long big; - struct - { - int l, h; - }; - } u; - u.big = ((long long)a * b) >> c; - if ((u.h ^ u.l) < 0 || (unsigned int)(u.h+1) > 1) return (u.h >> 31) ^ 0x7fffffff; - return u.l; -} - -static inline SDWORD DivScale (SDWORD a, SDWORD b, SDWORD c) -{ - SDWORD result, dummy; - SDWORD lo = a << c; - SDWORD hi = a >> (-c); - - asm volatile - ("idivl %4" - :"=a" (result), - "=d" (dummy) - : "a" (lo), - "d" (hi), - "r" (b) - : "cc"); - return result; -} - -static inline SDWORD DivScale1 (SDWORD a, SDWORD b) -{ - SDWORD result, dummy; - - asm volatile - ("addl %%eax,%%eax\n\t" - "sbbl %%edx,%%edx\n\t" - "idivl %3" - :"=a,a" (result), - "=&d,d" (dummy) - : "a,a" (a), - "r,m" (b) - : "cc"); - return result; -} #define MAKECONSTDivScale(s) \ static inline SDWORD DivScale##s (SDWORD a, SDWORD b) \ @@ -277,16 +174,3 @@ MAKECONSTDivScale(30) MAKECONSTDivScale(31) #undef MAKECONSTDivScale -static inline SDWORD DivScale32 (SDWORD a, SDWORD b) -{ - SDWORD result = 0, dummy; - - asm volatile - ("idivl %3" - :"+a,a" (result), - "=d,d" (dummy) - : "d,d" (a), - "r,m" (b) - : "cc"); - return result; -} diff --git a/src/mscinlines.h b/src/mscinlines.h index 6af2da1de..3d00e9cb0 100644 --- a/src/mscinlines.h +++ b/src/mscinlines.h @@ -27,14 +27,6 @@ __forceinline SDWORD Scale (SDWORD a, SDWORD b, SDWORD c) __asm idiv c } -__forceinline SDWORD MulScale (SDWORD a, SDWORD b, SDWORD c) -{ - __asm mov eax,a - __asm mov ecx,c - __asm imul b - __asm shrd eax,edx,cl -} - #define MAKECONSTMulScale(s) \ __forceinline SDWORD MulScale##s (SDWORD a, SDWORD b) \ { \ @@ -89,20 +81,6 @@ __forceinline DWORD UMulScale16(DWORD a, DWORD b) __asm shrd eax,edx,16 } -__forceinline SDWORD DMulScale (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD s) -{ - __asm mov eax,a - __asm imul b - __asm mov ebx,eax - __asm mov eax,c - __asm mov esi,edx - __asm mov ecx,s - __asm imul d - __asm add eax,ebx - __asm adc edx,esi - __asm shrd eax,edx,cl -} - #define MAKECONSTDMulScale(s) \ __forceinline SDWORD DMulScale##s (SDWORD a, SDWORD b, SDWORD c, SDWORD d) \ { \ @@ -163,115 +141,6 @@ __forceinline SDWORD DMulScale32 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) __asm mov eax,edx } -#define MAKECONSTTMulScale(s) \ - __forceinline SDWORD TMulScale##s (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) \ - { \ - __asm mov eax,a \ - __asm imul b \ - __asm mov ebx,eax \ - __asm mov eax,d \ - __asm mov ecx,edx \ - __asm imul c \ - __asm add ebx,eax \ - __asm mov eax,e \ - __asm adc ecx,edx \ - __asm imul f \ - __asm add eax,ebx \ - __asm adc edx,ecx \ - __asm shrd eax,edx,s \ - } - -MAKECONSTTMulScale(1) -MAKECONSTTMulScale(2) -MAKECONSTTMulScale(3) -MAKECONSTTMulScale(4) -MAKECONSTTMulScale(5) -MAKECONSTTMulScale(6) -MAKECONSTTMulScale(7) -MAKECONSTTMulScale(8) -MAKECONSTTMulScale(9) -MAKECONSTTMulScale(10) -MAKECONSTTMulScale(11) -MAKECONSTTMulScale(12) -MAKECONSTTMulScale(13) -MAKECONSTTMulScale(14) -MAKECONSTTMulScale(15) -MAKECONSTTMulScale(16) -MAKECONSTTMulScale(17) -MAKECONSTTMulScale(18) -MAKECONSTTMulScale(19) -MAKECONSTTMulScale(20) -MAKECONSTTMulScale(21) -MAKECONSTTMulScale(22) -MAKECONSTTMulScale(23) -MAKECONSTTMulScale(24) -MAKECONSTTMulScale(25) -MAKECONSTTMulScale(26) -MAKECONSTTMulScale(27) -MAKECONSTTMulScale(28) -MAKECONSTTMulScale(29) -MAKECONSTTMulScale(30) -MAKECONSTTMulScale(31) -#undef MAKECONSTTMulScale - -__forceinline SDWORD TMulScale32 (SDWORD a, SDWORD b, SDWORD c, SDWORD d, SDWORD e, SDWORD f) -{ - __asm mov eax,a - __asm imul b - __asm mov ebx,eax - __asm mov eax,c - __asm mov ecx,edx - __asm imul d - __asm add ebx,eax - __asm mov eax,e - __asm adc ecx,edx - __asm imul f - __asm add eax,ebx - __asm adc edx,ecx - __asm mov eax,edx -} - -__forceinline SDWORD BoundMulScale (SDWORD a, SDWORD b, SDWORD c) -{ - __asm mov eax,a - __asm imul b - __asm mov ebx,edx - __asm mov ecx,c - __asm shrd eax,edx,cl - __asm sar edx,cl - __asm xor edx,eax - __asm js checkit - __asm xor edx,eax - __asm jz skipboundit - __asm cmp edx,0xffffffff - __asm je skipboundit -checkit: - __asm mov eax,ebx - __asm sar eax,31 - __asm xor eax,0x7fffffff -skipboundit: - ; -} - -__forceinline SDWORD DivScale (SDWORD a, SDWORD b, SDWORD c) -{ - __asm mov eax,a - __asm mov ecx,c - __asm shl eax,cl - __asm mov edx,a - __asm neg cl - __asm sar edx,cl - __asm idiv b -} - -__forceinline SDWORD DivScale1 (SDWORD a, SDWORD b) -{ - __asm mov eax,a - __asm add eax,eax - __asm sbb edx,edx - __asm idiv b -} - #define MAKECONSTDivScale(s) \ __forceinline SDWORD DivScale##s (SDWORD a, SDWORD b) \ { \ @@ -314,11 +183,4 @@ MAKECONSTDivScale(30) MAKECONSTDivScale(31) #undef MAKECONSTDivScale -__forceinline SDWORD DivScale32 (SDWORD a, SDWORD b) -{ - __asm mov edx,a - __asm xor eax,eax - __asm idiv b -} - #pragma warning (default: 4035) From 15cf9d36a999fbb18e5ffc0ad1ec38c308a56b08 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Dec 2016 11:49:18 +0100 Subject: [PATCH 1394/1509] - moved wallscan code into its own file so that it can get an appropriate copyright notice and does not inflate an already large source file even more. (cherry picked from commit 34d551fe1f3653cbb9447f9169d20f5255a69b9a) # Conflicts: # src/r_segs.cpp --- src/CMakeLists.txt | 1 + src/r_draw.h | 2 - src/r_segs.cpp | 771 +++------------------------------------------ src/r_wallscan.cpp | 583 ++++++++++++++++++++++++++++++++++ 4 files changed, 621 insertions(+), 736 deletions(-) create mode 100644 src/r_wallscan.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a3c63bb0b..5f04effb1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -828,6 +828,7 @@ set( FASTMATH_PCH_SOURCES r_segs.cpp r_sky.cpp r_things.cpp + r_wallscan.cpp s_advsound.cpp s_environment.cpp s_playlist.cpp diff --git a/src/r_draw.h b/src/r_draw.h index 8c1af58fc..e41214640 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -134,8 +134,6 @@ namespace swrenderer const uint8_t *R_GetColumn(FTexture *tex, int col); void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn); - void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn); - void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn); void rt_initcols(uint8_t *buffer = nullptr); void rt_span_coverage(int x, int start, int stop); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index c24e7f719..1880273f9 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -17,6 +17,12 @@ // DESCRIPTION: // All the clipping: columns, horizontal spans, sky columns. // +// This file contains some code from the Build Engine. +// +// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman +// Ken Silverman's official web site: "http://www.advsys.net/ken" +// See the included license file "BUILDLIC.TXT" for license info. +// //----------------------------------------------------------------------------- #include @@ -44,22 +50,24 @@ #include "r_plane.h" #include "r_segs.h" #include "r_3dfloors.h" -#include "r_draw.h" #include "v_palette.h" #include "r_data/colormaps.h" #define WALLYREPEAT 8 -CVAR(Bool, r_np2, true, 0) + CVAR(Bool, r_fogboundary, true, 0) CVAR(Bool, r_drawmirrors, true, 0) EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); -EXTERN_CVAR(Bool, r_mipmap) -namespace swrenderer +namespace swrenderer { using namespace drawerargs; + void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, bool mask); + void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, bool mask); + void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat); + #define HEIGHTBITS 12 #define HEIGHTSHIFT (FRACBITS-HEIGHTBITS) @@ -135,9 +143,6 @@ static fixed_t *maskedtexturecol; static void R_RenderDecal (side_t *wall, DBaseDecal *first, drawseg_t *clipper, int pass); static void WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans)); -void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, bool mask); -static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat); -static void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, bool mask); inline bool IsFogBoundary (sector_t *front, sector_t *back) { @@ -158,7 +163,7 @@ static void BlastMaskedColumn (FTexture *tex, bool useRt) // calculate lighting if (fixedcolormap == NULL && fixedlightlev < 0) { - R_SetColorMapLight(basecolormap, rw_light, wallshade); + dc_colormap = basecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); } dc_iscale = xs_Fix<16>::ToFix(MaskedSWall[dc_x] * MaskedScaleY); @@ -176,7 +181,9 @@ static void BlastMaskedColumn (FTexture *tex, bool useRt) // when forming multipatched textures (see r_data.c). // draw the texture - R_DrawMaskedColumn(tex, maskedtexturecol[dc_x], useRt); + const FTexture::Span *spans; + const BYTE *pixels = tex->GetColumn (maskedtexturecol[dc_x] >> FRACBITS, &spans); + R_DrawMaskedColumn(pixels, spans, useRt); rw_light += rw_lightstep; spryscale += rw_scalestep; } @@ -292,9 +299,9 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) rw_scalestep = ds->iscalestep; if (fixedlightlev >= 0) - R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); else if (fixedcolormap != NULL) - R_SetColorMapLight(fixedcolormap, 0, 0); + dc_colormap = fixedcolormap; // find positioning texheight = tex->GetScaledHeightDouble(); @@ -440,7 +447,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) while (dc_x < stop) { - rt_initcols(nullptr); + rt_initcols(); BlastMaskedColumn (tex, true); dc_x++; BlastMaskedColumn (tex, true); dc_x++; BlastMaskedColumn (tex, true); dc_x++; @@ -531,7 +538,7 @@ clearfog: } else { - fillshort(openings + ds->sprtopclip - ds->x1 + x1, x2 - x1, viewheight); + clearbufshort(openings + ds->sprtopclip - ds->x1 + x1, x2 - x1, viewheight); } } return; @@ -609,9 +616,9 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) } if (fixedlightlev >= 0) - R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); else if (fixedcolormap != NULL) - R_SetColorMapLight(fixedcolormap, 0, 0); + dc_colormap = fixedcolormap; WallC.sz1 = ds->sz1; WallC.sz2 = ds->sz2; @@ -1044,710 +1051,6 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2) return; } - -struct WallscanSampler -{ - WallscanSampler() { } - WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)); - - uint32_t uv_pos; - uint32_t uv_step; - uint32_t uv_max; - - const BYTE *source; - const BYTE *source2; - uint32_t texturefracx; - uint32_t height; -}; - -WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)) -{ - xoffset += FLOAT2FIXED(xmagnitude * 0.5); - - if (!r_swtruecolor) - { - height = texture->GetHeight(); - - int uv_fracbits = 32 - texture->HeightBits; - if (uv_fracbits != 32) - { - uv_max = height << uv_fracbits; - - // Find start uv in [0-base_height[ range. - // Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range. - double uv_stepd = swal * yrepeat; - double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / height; - v = v - floor(v); - v *= height; - v *= (1 << uv_fracbits); - - uv_pos = (uint32_t)v; - uv_step = xs_ToFixed(uv_fracbits, uv_stepd); - if (uv_step == 0) // To prevent divide by zero elsewhere - uv_step = 1; - } - else - { // Hack for one pixel tall textures - uv_pos = 0; - uv_step = 0; - uv_max = 1; - } - - source = getcol(texture, xoffset >> FRACBITS); - source2 = nullptr; - texturefracx = 0; - } - else - { - // Normalize to 0-1 range: - double uv_stepd = swal * yrepeat; - double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / texture->GetHeight(); - v = v - floor(v); - double v_step = uv_stepd / texture->GetHeight(); - - if (isnan(v) || isnan(v_step)) // this should never happen, but it apparently does.. - { - uv_stepd = 0.0; - v = 0.0; - v_step = 0.0; - } - - // Convert to uint32: - uv_pos = (uint32_t)(v * 0x100000000LL); - uv_step = (uint32_t)(v_step * 0x100000000LL); - uv_max = 0; - - // Texture mipmap and filter selection: - if (getcol != R_GetColumn) - { - source = getcol(texture, xoffset >> FRACBITS); - source2 = nullptr; - height = texture->GetHeight(); - texturefracx = 0; - } - else - { - double ymagnitude = fabs(uv_stepd); - double magnitude = MAX(ymagnitude, xmagnitude); - double min_lod = -1000.0; - double lod = MAX(log2(magnitude) + r_lod_bias, min_lod); - bool magnifying = lod < 0.0f; - - int mipmap_offset = 0; - int mip_width = texture->GetWidth(); - int mip_height = texture->GetHeight(); - if (r_mipmap && texture->Mipmapped() && mip_width > 1 && mip_height > 1) - { - uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width); - - int level = (int)lod; - while (level > 0 && mip_width > 1 && mip_height > 1) - { - mipmap_offset += mip_width * mip_height; - level--; - mip_width = MAX(mip_width >> 1, 1); - mip_height = MAX(mip_height >> 1, 1); - } - xoffset = (xpos >> FRACBITS) * mip_width; - } - - const uint32_t *pixels = texture->GetPixelsBgra() + mipmap_offset; - - bool filter_nearest = (magnifying && !r_magfilter) || (!magnifying && !r_minfilter); - if (filter_nearest) - { - int tx = (xoffset >> FRACBITS) % mip_width; - if (tx < 0) - tx += mip_width; - source = (BYTE*)(pixels + tx * mip_height); - source2 = nullptr; - height = mip_height; - texturefracx = 0; - } - else - { - xoffset -= FRACUNIT / 2; - int tx0 = (xoffset >> FRACBITS) % mip_width; - if (tx0 < 0) - tx0 += mip_width; - int tx1 = (tx0 + 1) % mip_width; - source = (BYTE*)(pixels + tx0 * mip_height); - source2 = (BYTE*)(pixels + tx1 * mip_height); - height = mip_height; - texturefracx = (xoffset >> (FRACBITS - 4)) & 15; - } - } - } -} - -// Draw a column with support for non-power-of-two ranges -void wallscan_drawcol1(int x, int y1, int y2, WallscanSampler &sampler, DWORD(*draw1column)()) -{ - if (r_swtruecolor) - { - int count = y2 - y1; - - dc_source = sampler.source; - dc_source2 = sampler.source2; - dc_texturefracx = sampler.texturefracx; - dc_dest = (ylookup[y1] + x) * 4 + dc_destorg; - dc_count = count; - dc_iscale = sampler.uv_step; - dc_texturefrac = sampler.uv_pos; - dc_textureheight = sampler.height; - draw1column(); - - uint64_t step64 = sampler.uv_step; - uint64_t pos64 = sampler.uv_pos; - sampler.uv_pos = (uint32_t)(pos64 + step64 * count); - } - else - { - if (sampler.uv_max == 0 || sampler.uv_step == 0) // power of two - { - int count = y2 - y1; - - dc_source = sampler.source; - dc_source2 = sampler.source2; - dc_texturefracx = sampler.texturefracx; - dc_dest = (ylookup[y1] + x) + dc_destorg; - dc_count = count; - dc_iscale = sampler.uv_step; - dc_texturefrac = sampler.uv_pos; - draw1column(); - - uint64_t step64 = sampler.uv_step; - uint64_t pos64 = sampler.uv_pos; - sampler.uv_pos = (uint32_t)(pos64 + step64 * count); - } - else - { - uint32_t uv_pos = sampler.uv_pos; - - uint32_t left = y2 - y1; - while (left > 0) - { - uint32_t available = sampler.uv_max - uv_pos; - uint32_t next_uv_wrap = available / sampler.uv_step; - if (available % sampler.uv_step != 0) - next_uv_wrap++; - uint32_t count = MIN(left, next_uv_wrap); - - dc_source = sampler.source; - dc_source2 = sampler.source2; - dc_texturefracx = sampler.texturefracx; - dc_dest = (ylookup[y1] + x) + dc_destorg; - dc_count = count; - dc_iscale = sampler.uv_step; - dc_texturefrac = uv_pos; - draw1column(); - - left -= count; - uv_pos += sampler.uv_step * count; - if (uv_pos >= sampler.uv_max) - uv_pos -= sampler.uv_max; - } - - sampler.uv_pos = uv_pos; - } - } -} - -// Draw four columns with support for non-power-of-two ranges -void wallscan_drawcol4(int x, int y1, int y2, WallscanSampler *sampler, void(*draw4columns)()) -{ - if (r_swtruecolor) - { - int count = y2 - y1; - for (int i = 0; i < 4; i++) - { - bufplce[i] = sampler[i].source; - bufplce2[i] = sampler[i].source2; - buftexturefracx[i] = sampler[i].texturefracx; - bufheight[i] = sampler[i].height; - vplce[i] = sampler[i].uv_pos; - vince[i] = sampler[i].uv_step; - - uint64_t step64 = sampler[i].uv_step; - uint64_t pos64 = sampler[i].uv_pos; - sampler[i].uv_pos = (uint32_t)(pos64 + step64 * count); - } - dc_dest = (ylookup[y1] + x) * 4 + dc_destorg; - dc_count = count; - draw4columns(); - } - else - { - if (sampler[0].uv_max == 0 || sampler[0].uv_step == 0) // power of two, no wrap handling needed - { - int count = y2 - y1; - for (int i = 0; i < 4; i++) - { - bufplce[i] = sampler[i].source; - bufplce2[i] = sampler[i].source2; - buftexturefracx[i] = sampler[i].texturefracx; - vplce[i] = sampler[i].uv_pos; - vince[i] = sampler[i].uv_step; - - uint64_t step64 = sampler[i].uv_step; - uint64_t pos64 = sampler[i].uv_pos; - sampler[i].uv_pos = (uint32_t)(pos64 + step64 * count); - } - dc_dest = (ylookup[y1] + x) + dc_destorg; - dc_count = count; - draw4columns(); - } - else - { - dc_dest = (ylookup[y1] + x) + dc_destorg; - for (int i = 0; i < 4; i++) - { - bufplce[i] = sampler[i].source; - bufplce2[i] = sampler[i].source2; - buftexturefracx[i] = sampler[i].texturefracx; - } - - uint32_t left = y2 - y1; - while (left > 0) - { - // Find which column wraps first - uint32_t count = left; - for (int i = 0; i < 4; i++) - { - uint32_t available = sampler[i].uv_max - sampler[i].uv_pos; - uint32_t next_uv_wrap = available / sampler[i].uv_step; - if (available % sampler[i].uv_step != 0) - next_uv_wrap++; - count = MIN(next_uv_wrap, count); - } - - // Draw until that column wraps - for (int i = 0; i < 4; i++) - { - vplce[i] = sampler[i].uv_pos; - vince[i] = sampler[i].uv_step; - } - dc_count = count; - draw4columns(); - - // Wrap the uv position - for (int i = 0; i < 4; i++) - { - sampler[i].uv_pos += sampler[i].uv_step * count; - if (sampler[i].uv_pos >= sampler[i].uv_max) - sampler[i].uv_pos -= sampler[i].uv_max; - } - - left -= count; - } - } - } -} - -typedef DWORD(*Draw1ColumnFuncPtr)(); -typedef void(*Draw4ColumnsFuncPtr)(); - -void wallscan_any( - int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, - const BYTE *(*getcol)(FTexture *tex, int x), - void(setupwallscan(int bits, Draw1ColumnFuncPtr &draw1, Draw4ColumnsFuncPtr &draw2))) -{ - if (rw_pic->UseType == FTexture::TEX_Null) - return; - - fixed_t xoffset = rw_offset; - - rw_pic->GetHeight(); // To ensure that rw_pic->HeightBits has been set - int fracbits = 32 - rw_pic->HeightBits; - if (fracbits == 32) - { // Hack for one pixel tall textures - fracbits = 0; - yrepeat = 0; - dc_texturemid = 0; - } - - DWORD(*draw1column)(); - void(*draw4columns)(); - setupwallscan(r_swtruecolor ? FRACBITS : fracbits, draw1column, draw4columns); - - bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); - if (fixed) - { - palookupoffse[0] = dc_colormap; - palookupoffse[1] = dc_colormap; - palookupoffse[2] = dc_colormap; - palookupoffse[3] = dc_colormap; - palookuplight[0] = 0; - palookuplight[1] = 0; - palookuplight[2] = 0; - palookuplight[3] = 0; - } - - if (fixedcolormap) - R_SetColorMapLight(fixedcolormap, 0, 0); - else - R_SetColorMapLight(basecolormap, 0, 0); - - float light = rw_light; - - // Calculate where 4 column alignment begins and ends: - int aligned_x1 = clamp((x1 + 3) / 4 * 4, x1, x2); - int aligned_x2 = clamp(x2 / 4 * 4, x1, x2); - - double xmagnitude = 1.0; - - // First unaligned columns: - for (int x = x1; x < aligned_x1; x++, light += rw_lightstep) - { - int y1 = uwal[x]; - int y2 = dwal[x]; - if (y2 <= y1) - continue; - - if (!fixed) - R_SetColorMapLight(basecolormap, light, wallshade); - - if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); - - WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); - wallscan_drawcol1(x, y1, y2, sampler, draw1column); - } - - // The aligned columns - for (int x = aligned_x1; x < aligned_x2; x += 4) - { - // Find y1, y2, light and uv values for four columns: - int y1[4] = { uwal[x], uwal[x + 1], uwal[x + 2], uwal[x + 3] }; - int y2[4] = { dwal[x], dwal[x + 1], dwal[x + 2], dwal[x + 3] }; - - float lights[4]; - for (int i = 0; i < 4; i++) - { - lights[i] = light; - light += rw_lightstep; - } - - WallscanSampler sampler[4]; - for (int i = 0; i < 4; i++) - { - if (x + i + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + i + 1]) - FIXED2DBL(lwal[x + i])); - sampler[i] = WallscanSampler(y1[i], swal[x + i], yrepeat, lwal[x + i] + xoffset, xmagnitude, rw_pic, getcol); - } - - // Figure out where we vertically can start and stop drawing 4 columns in one go - int middle_y1 = y1[0]; - int middle_y2 = y2[0]; - for (int i = 1; i < 4; i++) - { - middle_y1 = MAX(y1[i], middle_y1); - middle_y2 = MIN(y2[i], middle_y2); - } - - // If we got an empty column in our set we cannot draw 4 columns in one go: - bool empty_column_in_set = false; - int bilinear_count = 0; - for (int i = 0; i < 4; i++) - { - if (y2[i] <= y1[i]) - empty_column_in_set = true; - if (sampler[i].source2) - bilinear_count++; - } - - if (empty_column_in_set || middle_y2 <= middle_y1 || (bilinear_count > 0 && bilinear_count < 4)) - { - for (int i = 0; i < 4; i++) - { - if (y2[i] <= y1[i]) - continue; - - if (!fixed) - R_SetColorMapLight(basecolormap, lights[i], wallshade); - wallscan_drawcol1(x + i, y1[i], y2[i], sampler[i], draw1column); - } - continue; - } - - // Draw the first rows where not all 4 columns are active - for (int i = 0; i < 4; i++) - { - if (!fixed) - R_SetColorMapLight(basecolormap, lights[i], wallshade); - - if (y1[i] < middle_y1) - wallscan_drawcol1(x + i, y1[i], middle_y1, sampler[i], draw1column); - } - - // Draw the area where all 4 columns are active - if (!fixed) - { - for (int i = 0; i < 4; i++) - { - if (r_swtruecolor) - { - palookupoffse[i] = basecolormap->Maps; - palookuplight[i] = LIGHTSCALE(lights[i], wallshade); - } - else - { - palookupoffse[i] = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); - palookuplight[i] = 0; - } - } - } - wallscan_drawcol4(x, middle_y1, middle_y2, sampler, draw4columns); - - // Draw the last rows where not all 4 columns are active - for (int i = 0; i < 4; i++) - { - if (!fixed) - R_SetColorMapLight(basecolormap, lights[i], wallshade); - - if (middle_y2 < y2[i]) - wallscan_drawcol1(x + i, middle_y2, y2[i], sampler[i], draw1column); - } - } - - // The last unaligned columns: - for (int x = aligned_x2; x < x2; x++, light += rw_lightstep) - { - int y1 = uwal[x]; - int y2 = dwal[x]; - if (y2 <= y1) - continue; - - if (!fixed) - R_SetColorMapLight(basecolormap, light, wallshade); - - if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); - - WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); - wallscan_drawcol1(x, y1, y2, sampler, draw1column); - } - - NetUpdate (); -} - -void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) -{ - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) - { - setupvline(bits); - line1 = dovline1; - line4 = dovline4; - }); -} - -void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) -{ - if (!rw_pic->bMasked) // Textures that aren't masked can use the faster wallscan. - { - wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); - } - else - { - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) - { - setupmvline(bits); - line1 = domvline1; - line4 = domvline4; - }); - } -} - -void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) -{ - static fixed_t(*tmvline1)(); - static void(*tmvline4)(); - if (!R_GetTransMaskDrawers(&tmvline1, &tmvline4)) - { - // The current translucency is unsupported, so draw with regular maskwallscan instead. - maskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); - } - else - { - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) - { - setuptmvline(bits); - line1 = reinterpret_cast(tmvline1); - line4 = tmvline4; - }); - } -} - -void wallscan_striped (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) -{ - FDynamicColormap *startcolormap = basecolormap; - int startshade = wallshade; - bool fogginess = foggy; - - short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; - short *up, *down; - - up = uwal; - down = most1; - - assert(WallC.sx1 <= x1); - assert(WallC.sx2 >= x2); - - // kg3D - fake floors instead of zdoom light list - for (unsigned int i = 0; i < frontsector->e->XFloor.lightlist.Size(); i++) - { - int j = WallMost (most3, frontsector->e->XFloor.lightlist[i].plane, &WallC); - if (j != 3) - { - for (int j = x1; j < x2; ++j) - { - down[j] = clamp (most3[j], up[j], dwal[j]); - } - wallscan (x1, x2, up, down, swal, lwal, yrepeat); - up = down; - down = (down == most1) ? most2 : most1; - } - - lightlist_t *lit = &frontsector->e->XFloor.lightlist[i]; - basecolormap = lit->extra_colormap; - wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(fogginess, - *lit->p_lightlevel, lit->lightsource != NULL) + r_actualextralight); - } - - wallscan (x1, x2, up, dwal, swal, lwal, yrepeat); - basecolormap = startcolormap; - wallshade = startshade; -} - -static void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, bool mask) -{ - if (mask) - { - if (colfunc == basecolfunc) - { - maskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); - } - else - { - transmaskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); - } - } - else - { - if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size())) - { - wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); - } - else - { - wallscan_striped(x1, x2, uwal, dwal, swal, lwal, yrepeat); - } - } -} - -//============================================================================= -// -// wallscan_np2 -// -// This is a wrapper around wallscan that helps it tile textures whose heights -// are not powers of 2. It divides the wall into texture-sized strips and calls -// wallscan for each of those. Since only one repetition of the texture fits -// in each strip, wallscan will not tile. -// -//============================================================================= - -void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, bool mask) -{ - if (!r_np2) - { - call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, mask); - } - else - { - short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; - short *up, *down; - double texheight = rw_pic->GetHeight(); - double partition; - double scaledtexheight = texheight / yrepeat; - - if (yrepeat >= 0) - { // normal orientation: draw strips from top to bottom - partition = top - fmod(top - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); - if (partition == top) - { - partition -= scaledtexheight; - } - up = uwal; - down = most1; - dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; - while (partition > bot) - { - int j = OWallMost(most3, partition - ViewPos.Z, &WallC); - if (j != 3) - { - for (int j = x1; j < x2; ++j) - { - down[j] = clamp(most3[j], up[j], dwal[j]); - } - call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); - up = down; - down = (down == most1) ? most2 : most1; - } - partition -= scaledtexheight; - dc_texturemid -= texheight; - } - call_wallscan(x1, x2, up, dwal, swal, lwal, yrepeat, mask); - } - else - { // upside down: draw strips from bottom to top - partition = bot - fmod(bot - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); - up = most1; - down = dwal; - dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; - while (partition < top) - { - int j = OWallMost(most3, partition - ViewPos.Z, &WallC); - if (j != 12) - { - for (int j = x1; j < x2; ++j) - { - up[j] = clamp(most3[j], uwal[j], down[j]); - } - call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); - down = up; - up = (up == most1) ? most2 : most1; - } - partition -= scaledtexheight; - dc_texturemid -= texheight; - } - call_wallscan(x1, x2, uwal, down, swal, lwal, yrepeat, mask); - } - } -} - -static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) -{ - if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) - { - double frontcz1 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v1); - double frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1); - double frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2); - double frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2); - double top = MAX(frontcz1, frontcz2); - double bot = MIN(frontfz1, frontfz2); - if (fake3D & FAKE3D_CLIPTOP) - { - top = MIN(top, sclipTop); - } - if (fake3D & FAKE3D_CLIPBOTTOM) - { - bot = MAX(bot, sclipBottom); - } - wallscan_np2(x1, x2, uwal, dwal, swal, lwal, yrepeat, top, bot, true); - } - else - { - call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, true); - } -} - // // R_RenderSegLoop // Draws zero, one, or two textures for walls. @@ -1768,9 +1071,9 @@ void R_RenderSegLoop () fixed_t xoffset = rw_offset; if (fixedlightlev >= 0) - R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); else if (fixedcolormap != NULL) - R_SetColorMapLight(fixedcolormap, 0, 0); + dc_colormap = fixedcolormap; // clip wall to the floor and ceiling for (x = x1; x < x2; ++x) @@ -1881,8 +1184,8 @@ void R_RenderSegLoop () call_wallscan(x1, x2, walltop, wallbottom, swall, lwall, yscale, false); } } - fillshort (ceilingclip+x1, x2-x1, viewheight); - fillshort (floorclip+x1, x2-x1, 0xffff); + clearbufshort (ceilingclip+x1, x2-x1, viewheight); + clearbufshort (floorclip+x1, x2-x1, 0xffff); } else { // two sided line @@ -2405,7 +1708,7 @@ void R_StoreWallRange (int start, int stop) { ds_p->sprtopclip = R_NewOpening (stop - start); ds_p->sprbottomclip = R_NewOpening (stop - start); - fillshort (openings + ds_p->sprtopclip, stop-start, viewheight); + clearbufshort (openings + ds_p->sprtopclip, stop-start, viewheight); memset (openings + ds_p->sprbottomclip, -1, (stop-start)*sizeof(short)); ds_p->silhouette = SIL_BOTH; } @@ -2445,7 +1748,7 @@ void R_StoreWallRange (int start, int stop) if (doorclosed || (rw_backfz1 >= rw_frontcz1 && rw_backfz2 >= rw_frontcz2)) { // killough 1/17/98, 2/8/98 ds_p->sprtopclip = R_NewOpening (stop - start); - fillshort (openings + ds_p->sprtopclip, stop - start, viewheight); + clearbufshort (openings + ds_p->sprtopclip, stop - start, viewheight); ds_p->silhouette |= SIL_TOP; } } @@ -2666,7 +1969,7 @@ int WallMostAny(short *mostbuf, double z1, double z2, const FWallCoords *wallc) } else if (y1 > viewheight && y2 > viewheight) // entire line is below screen { - fillshort(&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight); + clearbufshort(&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight); return 12; } @@ -3037,11 +2340,11 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rw_light = rw_lightleft + (x1 - savecoord.sx1) * rw_lightstep; if (fixedlightlev >= 0) - R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (usecolormap->Maps + fixedlightlev); else if (fixedcolormap != NULL) - R_SetColorMapLight(fixedcolormap, 0, 0); + dc_colormap = fixedcolormap; else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT)) - R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0); + dc_colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : usecolormap->Maps; else calclighting = true; @@ -3092,7 +2395,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap, rw_light, wallshade); + dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); } R_WallSpriteColumn (false); dc_x++; @@ -3102,9 +2405,9 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap, rw_light, wallshade); + dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); } - rt_initcols(nullptr); + rt_initcols(); for (int zz = 4; zz; --zz) { R_WallSpriteColumn (true); @@ -3117,7 +2420,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - R_SetColorMapLight(usecolormap, rw_light, wallshade); + dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); } R_WallSpriteColumn (false); dc_x++; @@ -3141,4 +2444,4 @@ done: WallC = savecoord; } -} +} \ No newline at end of file diff --git a/src/r_wallscan.cpp b/src/r_wallscan.cpp new file mode 100644 index 000000000..c5bcb1d26 --- /dev/null +++ b/src/r_wallscan.cpp @@ -0,0 +1,583 @@ +/* +** Replacement for Build's wallscan free of any Build licensing issues. +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include + +#include "doomdef.h" +#include "doomstat.h" +#include "doomdata.h" + +#include "r_local.h" +#include "r_sky.h" +#include "v_video.h" + +#include "m_swap.h" +#include "a_sharedglobal.h" +#include "d_net.h" +#include "g_level.h" +#include "r_draw.h" +#include "r_bsp.h" +#include "r_plane.h" +#include "r_segs.h" +#include "r_3dfloors.h" +#include "v_palette.h" +#include "r_data/colormaps.h" + +namespace swrenderer +{ + using namespace drawerargs; + + extern FTexture *rw_pic; + extern int wallshade; + +struct WallscanSampler +{ + WallscanSampler() { } + WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)); + + uint32_t uv_pos; + uint32_t uv_step; + uint32_t uv_max; + + const BYTE *source; + uint32_t height; +}; + +WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)) +{ + height = texture->GetHeight(); + + int uv_fracbits = 32 - texture->HeightBits; + if (uv_fracbits != 32) + { + uv_max = height << uv_fracbits; + + // Find start uv in [0-base_height[ range. + // Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range. + double uv_stepd = swal * yrepeat; + double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / height; + v = v - floor(v); + v *= height; + v *= (1 << uv_fracbits); + + uv_pos = (uint32_t)v; + uv_step = xs_ToFixed(uv_fracbits, uv_stepd); + if (uv_step == 0) // To prevent divide by zero elsewhere + uv_step = 1; + } + else + { // Hack for one pixel tall textures + uv_pos = 0; + uv_step = 0; + uv_max = 1; + } + + source = getcol(texture, xoffset >> FRACBITS); +} + +// Draw a column with support for non-power-of-two ranges +void wallscan_drawcol1(int x, int y1, int y2, WallscanSampler &sampler, DWORD(*draw1column)()) +{ + if (sampler.uv_max == 0 || sampler.uv_step == 0) // power of two + { + int count = y2 - y1; + + dc_source = sampler.source; + dc_dest = (ylookup[y1] + x) + dc_destorg; + dc_count = count; + dc_iscale = sampler.uv_step; + dc_texturefrac = sampler.uv_pos; + draw1column(); + + uint64_t step64 = sampler.uv_step; + uint64_t pos64 = sampler.uv_pos; + sampler.uv_pos = (uint32_t)(pos64 + step64 * count); + } + else + { + uint32_t uv_pos = sampler.uv_pos; + + uint32_t left = y2 - y1; + while (left > 0) + { + uint32_t available = sampler.uv_max - uv_pos; + uint32_t next_uv_wrap = available / sampler.uv_step; + if (available % sampler.uv_step != 0) + next_uv_wrap++; + uint32_t count = MIN(left, next_uv_wrap); + + dc_source = sampler.source; + dc_dest = (ylookup[y1] + x) + dc_destorg; + dc_count = count; + dc_iscale = sampler.uv_step; + dc_texturefrac = uv_pos; + draw1column(); + + left -= count; + uv_pos += sampler.uv_step * count; + if (uv_pos >= sampler.uv_max) + uv_pos -= sampler.uv_max; + } + + sampler.uv_pos = uv_pos; + } +} + +// Draw four columns with support for non-power-of-two ranges +void wallscan_drawcol4(int x, int y1, int y2, WallscanSampler *sampler, void(*draw4columns)()) +{ + if (sampler[0].uv_max == 0 || sampler[0].uv_step == 0) // power of two, no wrap handling needed + { + int count = y2 - y1; + for (int i = 0; i < 4; i++) + { + bufplce[i] = sampler[i].source; + vplce[i] = sampler[i].uv_pos; + vince[i] = sampler[i].uv_step; + + uint64_t step64 = sampler[i].uv_step; + uint64_t pos64 = sampler[i].uv_pos; + sampler[i].uv_pos = (uint32_t)(pos64 + step64 * count); + } + dc_dest = (ylookup[y1] + x) + dc_destorg; + dc_count = count; + draw4columns(); + } + else + { + dc_dest = (ylookup[y1] + x) + dc_destorg; + for (int i = 0; i < 4; i++) + { + bufplce[i] = sampler[i].source; + } + + uint32_t left = y2 - y1; + while (left > 0) + { + // Find which column wraps first + uint32_t count = left; + for (int i = 0; i < 4; i++) + { + uint32_t available = sampler[i].uv_max - sampler[i].uv_pos; + uint32_t next_uv_wrap = available / sampler[i].uv_step; + if (available % sampler[i].uv_step != 0) + next_uv_wrap++; + count = MIN(next_uv_wrap, count); + } + + // Draw until that column wraps + for (int i = 0; i < 4; i++) + { + vplce[i] = sampler[i].uv_pos; + vince[i] = sampler[i].uv_step; + } + dc_count = count; + draw4columns(); + + // Wrap the uv position + for (int i = 0; i < 4; i++) + { + sampler[i].uv_pos += sampler[i].uv_step * count; + if (sampler[i].uv_pos >= sampler[i].uv_max) + sampler[i].uv_pos -= sampler[i].uv_max; + } + + left -= count; + } + } +} + +typedef DWORD(*Draw1ColumnFuncPtr)(); +typedef void(*Draw4ColumnsFuncPtr)(); + +void wallscan_any( + int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, + const BYTE *(*getcol)(FTexture *tex, int x), + void(setupwallscan(int bits, Draw1ColumnFuncPtr &draw1, Draw4ColumnsFuncPtr &draw2))) +{ + if (rw_pic->UseType == FTexture::TEX_Null) + return; + + fixed_t xoffset = rw_offset; + + rw_pic->GetHeight(); // To ensure that rw_pic->HeightBits has been set + int fracbits = 32 - rw_pic->HeightBits; + if (fracbits == 32) + { // Hack for one pixel tall textures + fracbits = 0; + yrepeat = 0; + dc_texturemid = 0; + } + + DWORD(*draw1column)(); + void(*draw4columns)(); + setupwallscan(fracbits, draw1column, draw4columns); + + bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); + if (fixed) + { + palookupoffse[0] = dc_colormap; + palookupoffse[1] = dc_colormap; + palookupoffse[2] = dc_colormap; + palookupoffse[3] = dc_colormap; + } + + if (fixedcolormap) + dc_colormap = fixedcolormap; + else + dc_colormap = basecolormap->Maps; + + float light = rw_light; + + // Calculate where 4 column alignment begins and ends: + int aligned_x1 = clamp((x1 + 3) / 4 * 4, x1, x2); + int aligned_x2 = clamp(x2 / 4 * 4, x1, x2); + + // First unaligned columns: + for (int x = x1; x < aligned_x1; x++, light += rw_lightstep) + { + int y1 = uwal[x]; + int y2 = dwal[x]; + if (y2 <= y1) + continue; + + if (!fixed) + dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); + + WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, rw_pic, getcol); + wallscan_drawcol1(x, y1, y2, sampler, draw1column); + } + + // The aligned columns + for (int x = aligned_x1; x < aligned_x2; x += 4) + { + // Find y1, y2, light and uv values for four columns: + int y1[4] = { uwal[x], uwal[x + 1], uwal[x + 2], uwal[x + 3] }; + int y2[4] = { dwal[x], dwal[x + 1], dwal[x + 2], dwal[x + 3] }; + + float lights[4]; + for (int i = 0; i < 4; i++) + { + lights[i] = light; + light += rw_lightstep; + } + + WallscanSampler sampler[4]; + for (int i = 0; i < 4; i++) + sampler[i] = WallscanSampler(y1[i], swal[x + i], yrepeat, lwal[x + i] + xoffset, rw_pic, getcol); + + // Figure out where we vertically can start and stop drawing 4 columns in one go + int middle_y1 = y1[0]; + int middle_y2 = y2[0]; + for (int i = 1; i < 4; i++) + { + middle_y1 = MAX(y1[i], middle_y1); + middle_y2 = MIN(y2[i], middle_y2); + } + + // If we got an empty column in our set we cannot draw 4 columns in one go: + bool empty_column_in_set = false; + for (int i = 0; i < 4; i++) + { + if (y2[i] <= y1[i]) + empty_column_in_set = true; + } + + if (empty_column_in_set || middle_y2 <= middle_y1) + { + for (int i = 0; i < 4; i++) + { + if (y2[i] <= y1[i]) + continue; + + if (!fixed) + dc_colormap = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); + wallscan_drawcol1(x + i, y1[i], y2[i], sampler[i], draw1column); + } + continue; + } + + // Draw the first rows where not all 4 columns are active + for (int i = 0; i < 4; i++) + { + if (!fixed) + dc_colormap = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); + + if (y1[i] < middle_y1) + wallscan_drawcol1(x + i, y1[i], middle_y1, sampler[i], draw1column); + } + + // Draw the area where all 4 columns are active + if (!fixed) + { + for (int i = 0; i < 4; i++) + { + palookupoffse[i] = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); + } + } + wallscan_drawcol4(x, middle_y1, middle_y2, sampler, draw4columns); + + // Draw the last rows where not all 4 columns are active + for (int i = 0; i < 4; i++) + { + if (!fixed) + dc_colormap = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); + + if (middle_y2 < y2[i]) + wallscan_drawcol1(x + i, middle_y2, y2[i], sampler[i], draw1column); + } + } + + // The last unaligned columns: + for (int x = aligned_x2; x < x2; x++, light += rw_lightstep) + { + int y1 = uwal[x]; + int y2 = dwal[x]; + if (y2 <= y1) + continue; + + if (!fixed) + dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); + + WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, rw_pic, getcol); + wallscan_drawcol1(x, y1, y2, sampler, draw1column); + } + + NetUpdate(); +} + +void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) +{ + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + { + setupvline(bits); + line1 = dovline1; + line4 = dovline4; + }); +} + +void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn) +{ + if (!rw_pic->bMasked) // Textures that aren't masked can use the faster wallscan. + { + wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); + } + else + { + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + { + setupmvline(bits); + line1 = domvline1; + line4 = domvline4; + }); + } +} + +void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn) +{ + static fixed_t(*tmvline1)(); + static void(*tmvline4)(); + if (!R_GetTransMaskDrawers(&tmvline1, &tmvline4)) + { + // The current translucency is unsupported, so draw with regular maskwallscan instead. + maskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); + } + else + { + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + { + setuptmvline(bits); + line1 = reinterpret_cast(tmvline1); + line4 = tmvline4; + }); + } +} + +void wallscan_striped (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) +{ + FDynamicColormap *startcolormap = basecolormap; + int startshade = wallshade; + bool fogginess = foggy; + + short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; + short *up, *down; + + up = uwal; + down = most1; + + assert(WallC.sx1 <= x1); + assert(WallC.sx2 >= x2); + + // kg3D - fake floors instead of zdoom light list + for (unsigned int i = 0; i < frontsector->e->XFloor.lightlist.Size(); i++) + { + int j = WallMost (most3, frontsector->e->XFloor.lightlist[i].plane, &WallC); + if (j != 3) + { + for (int j = x1; j < x2; ++j) + { + down[j] = clamp (most3[j], up[j], dwal[j]); + } + wallscan (x1, x2, up, down, swal, lwal, yrepeat); + up = down; + down = (down == most1) ? most2 : most1; + } + + lightlist_t *lit = &frontsector->e->XFloor.lightlist[i]; + basecolormap = lit->extra_colormap; + wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(fogginess, + *lit->p_lightlevel, lit->lightsource != NULL) + r_actualextralight); + } + + wallscan (x1, x2, up, dwal, swal, lwal, yrepeat); + basecolormap = startcolormap; + wallshade = startshade; +} + +void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, bool mask) +{ + if (mask) + { + if (colfunc == basecolfunc) + { + maskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); + } + else + { + transmaskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); + } + } + else + { + if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size())) + { + wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); + } + else + { + wallscan_striped(x1, x2, uwal, dwal, swal, lwal, yrepeat); + } + } +} + +//============================================================================= +// +// wallscan_np2 +// +// This is a wrapper around wallscan that helps it tile textures whose heights +// are not powers of 2. It divides the wall into texture-sized strips and calls +// wallscan for each of those. Since only one repetition of the texture fits +// in each strip, wallscan will not tile. +// +//============================================================================= + +void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, bool mask) +{ + short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; + short *up, *down; + double texheight = rw_pic->GetHeight(); + double partition; + double scaledtexheight = texheight / yrepeat; + + if (yrepeat >= 0) + { // normal orientation: draw strips from top to bottom + partition = top - fmod(top - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); + if (partition == top) + { + partition -= scaledtexheight; + } + up = uwal; + down = most1; + dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; + while (partition > bot) + { + int j = OWallMost(most3, partition - ViewPos.Z, &WallC); + if (j != 3) + { + for (int j = x1; j < x2; ++j) + { + down[j] = clamp(most3[j], up[j], dwal[j]); + } + call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); + up = down; + down = (down == most1) ? most2 : most1; + } + partition -= scaledtexheight; + dc_texturemid -= texheight; + } + call_wallscan(x1, x2, up, dwal, swal, lwal, yrepeat, mask); + } + else + { // upside down: draw strips from bottom to top + partition = bot - fmod(bot - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); + up = most1; + down = dwal; + dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; + while (partition < top) + { + int j = OWallMost(most3, partition - ViewPos.Z, &WallC); + if (j != 12) + { + for (int j = x1; j < x2; ++j) + { + up[j] = clamp(most3[j], uwal[j], down[j]); + } + call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); + down = up; + up = (up == most1) ? most2 : most1; + } + partition -= scaledtexheight; + dc_texturemid -= texheight; + } + call_wallscan(x1, x2, uwal, down, swal, lwal, yrepeat, mask); + } +} + +void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) +{ + if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) + { + double frontcz1 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v1); + double frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1); + double frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2); + double frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2); + double top = MAX(frontcz1, frontcz2); + double bot = MIN(frontfz1, frontfz2); + if (fake3D & FAKE3D_CLIPTOP) + { + top = MIN(top, sclipTop); + } + if (fake3D & FAKE3D_CLIPBOTTOM) + { + bot = MAX(bot, sclipBottom); + } + wallscan_np2(x1, x2, uwal, dwal, swal, lwal, yrepeat, top, bot, true); + } + else + { + call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, true); + } +} + + +} \ No newline at end of file From 2b5f9eebba1f508556d4c4f8787399c1d1525e0f Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 9 Dec 2016 08:41:59 -0500 Subject: [PATCH 1395/1509] - Correctly redid commit 34d551fe1f3653cbb9447f9169d20f5255a69b9a. --- src/r_wallscan.cpp | 454 +++++++++++++++++++++++++++++++-------------- 1 file changed, 314 insertions(+), 140 deletions(-) diff --git a/src/r_wallscan.cpp b/src/r_wallscan.cpp index c5bcb1d26..8c5f04d54 100644 --- a/src/r_wallscan.cpp +++ b/src/r_wallscan.cpp @@ -50,63 +50,157 @@ namespace swrenderer extern FTexture *rw_pic; extern int wallshade; + struct WallscanSampler { WallscanSampler() { } - WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)); + WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)); uint32_t uv_pos; uint32_t uv_step; uint32_t uv_max; const BYTE *source; + const BYTE *source2; + uint32_t texturefracx; uint32_t height; }; -WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)) +WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)) { - height = texture->GetHeight(); + xoffset += FLOAT2FIXED(xmagnitude * 0.5); - int uv_fracbits = 32 - texture->HeightBits; - if (uv_fracbits != 32) + if (!r_swtruecolor) { - uv_max = height << uv_fracbits; + height = texture->GetHeight(); - // Find start uv in [0-base_height[ range. - // Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range. - double uv_stepd = swal * yrepeat; - double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / height; - v = v - floor(v); - v *= height; - v *= (1 << uv_fracbits); + int uv_fracbits = 32 - texture->HeightBits; + if (uv_fracbits != 32) + { + uv_max = height << uv_fracbits; - uv_pos = (uint32_t)v; - uv_step = xs_ToFixed(uv_fracbits, uv_stepd); - if (uv_step == 0) // To prevent divide by zero elsewhere - uv_step = 1; + // Find start uv in [0-base_height[ range. + // Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range. + double uv_stepd = swal * yrepeat; + double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / height; + v = v - floor(v); + v *= height; + v *= (1 << uv_fracbits); + + uv_pos = (uint32_t)v; + uv_step = xs_ToFixed(uv_fracbits, uv_stepd); + if (uv_step == 0) // To prevent divide by zero elsewhere + uv_step = 1; + } + else + { // Hack for one pixel tall textures + uv_pos = 0; + uv_step = 0; + uv_max = 1; + } + + source = getcol(texture, xoffset >> FRACBITS); + source2 = nullptr; + texturefracx = 0; } else - { // Hack for one pixel tall textures - uv_pos = 0; - uv_step = 0; - uv_max = 1; - } + { + // Normalize to 0-1 range: + double uv_stepd = swal * yrepeat; + double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / texture->GetHeight(); + v = v - floor(v); + double v_step = uv_stepd / texture->GetHeight(); - source = getcol(texture, xoffset >> FRACBITS); + if (isnan(v) || isnan(v_step)) // this should never happen, but it apparently does.. + { + uv_stepd = 0.0; + v = 0.0; + v_step = 0.0; + } + + // Convert to uint32: + uv_pos = (uint32_t)(v * 0x100000000LL); + uv_step = (uint32_t)(v_step * 0x100000000LL); + uv_max = 0; + + // Texture mipmap and filter selection: + if (getcol != R_GetColumn) + { + source = getcol(texture, xoffset >> FRACBITS); + source2 = nullptr; + height = texture->GetHeight(); + texturefracx = 0; + } + else + { + double ymagnitude = fabs(uv_stepd); + double magnitude = MAX(ymagnitude, xmagnitude); + double min_lod = -1000.0; + double lod = MAX(log2(magnitude) + r_lod_bias, min_lod); + bool magnifying = lod < 0.0f; + + int mipmap_offset = 0; + int mip_width = texture->GetWidth(); + int mip_height = texture->GetHeight(); + if (r_mipmap && texture->Mipmapped() && mip_width > 1 && mip_height > 1) + { + uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width); + + int level = (int)lod; + while (level > 0 && mip_width > 1 && mip_height > 1) + { + mipmap_offset += mip_width * mip_height; + level--; + mip_width = MAX(mip_width >> 1, 1); + mip_height = MAX(mip_height >> 1, 1); + } + xoffset = (xpos >> FRACBITS) * mip_width; + } + + const uint32_t *pixels = texture->GetPixelsBgra() + mipmap_offset; + + bool filter_nearest = (magnifying && !r_magfilter) || (!magnifying && !r_minfilter); + if (filter_nearest) + { + int tx = (xoffset >> FRACBITS) % mip_width; + if (tx < 0) + tx += mip_width; + source = (BYTE*)(pixels + tx * mip_height); + source2 = nullptr; + height = mip_height; + texturefracx = 0; + } + else + { + xoffset -= FRACUNIT / 2; + int tx0 = (xoffset >> FRACBITS) % mip_width; + if (tx0 < 0) + tx0 += mip_width; + int tx1 = (tx0 + 1) % mip_width; + source = (BYTE*)(pixels + tx0 * mip_height); + source2 = (BYTE*)(pixels + tx1 * mip_height); + height = mip_height; + texturefracx = (xoffset >> (FRACBITS - 4)) & 15; + } + } + } } // Draw a column with support for non-power-of-two ranges void wallscan_drawcol1(int x, int y1, int y2, WallscanSampler &sampler, DWORD(*draw1column)()) { - if (sampler.uv_max == 0 || sampler.uv_step == 0) // power of two + if (r_swtruecolor) { int count = y2 - y1; dc_source = sampler.source; - dc_dest = (ylookup[y1] + x) + dc_destorg; + dc_source2 = sampler.source2; + dc_texturefracx = sampler.texturefracx; + dc_dest = (ylookup[y1] + x) * 4 + dc_destorg; dc_count = count; dc_iscale = sampler.uv_step; dc_texturefrac = sampler.uv_pos; + dc_textureheight = sampler.height; draw1column(); uint64_t step64 = sampler.uv_step; @@ -115,43 +209,68 @@ void wallscan_drawcol1(int x, int y1, int y2, WallscanSampler &sampler, DWORD(*d } else { - uint32_t uv_pos = sampler.uv_pos; - - uint32_t left = y2 - y1; - while (left > 0) + if (sampler.uv_max == 0 || sampler.uv_step == 0) // power of two { - uint32_t available = sampler.uv_max - uv_pos; - uint32_t next_uv_wrap = available / sampler.uv_step; - if (available % sampler.uv_step != 0) - next_uv_wrap++; - uint32_t count = MIN(left, next_uv_wrap); + int count = y2 - y1; dc_source = sampler.source; + dc_source2 = sampler.source2; + dc_texturefracx = sampler.texturefracx; dc_dest = (ylookup[y1] + x) + dc_destorg; dc_count = count; dc_iscale = sampler.uv_step; - dc_texturefrac = uv_pos; + dc_texturefrac = sampler.uv_pos; draw1column(); - left -= count; - uv_pos += sampler.uv_step * count; - if (uv_pos >= sampler.uv_max) - uv_pos -= sampler.uv_max; + uint64_t step64 = sampler.uv_step; + uint64_t pos64 = sampler.uv_pos; + sampler.uv_pos = (uint32_t)(pos64 + step64 * count); } + else + { + uint32_t uv_pos = sampler.uv_pos; - sampler.uv_pos = uv_pos; + uint32_t left = y2 - y1; + while (left > 0) + { + uint32_t available = sampler.uv_max - uv_pos; + uint32_t next_uv_wrap = available / sampler.uv_step; + if (available % sampler.uv_step != 0) + next_uv_wrap++; + uint32_t count = MIN(left, next_uv_wrap); + + dc_source = sampler.source; + dc_source2 = sampler.source2; + dc_texturefracx = sampler.texturefracx; + dc_dest = (ylookup[y1] + x) + dc_destorg; + dc_count = count; + dc_iscale = sampler.uv_step; + dc_texturefrac = uv_pos; + draw1column(); + + left -= count; + uv_pos += sampler.uv_step * count; + if (uv_pos >= sampler.uv_max) + uv_pos -= sampler.uv_max; + } + + sampler.uv_pos = uv_pos; + } } } // Draw four columns with support for non-power-of-two ranges void wallscan_drawcol4(int x, int y1, int y2, WallscanSampler *sampler, void(*draw4columns)()) { - if (sampler[0].uv_max == 0 || sampler[0].uv_step == 0) // power of two, no wrap handling needed + if (r_swtruecolor) { int count = y2 - y1; for (int i = 0; i < 4; i++) { bufplce[i] = sampler[i].source; + bufplce2[i] = sampler[i].source2; + buftexturefracx[i] = sampler[i].texturefracx; + bufheight[i] = sampler[i].height; vplce[i] = sampler[i].uv_pos; vince[i] = sampler[i].uv_step; @@ -159,50 +278,74 @@ void wallscan_drawcol4(int x, int y1, int y2, WallscanSampler *sampler, void(*dr uint64_t pos64 = sampler[i].uv_pos; sampler[i].uv_pos = (uint32_t)(pos64 + step64 * count); } - dc_dest = (ylookup[y1] + x) + dc_destorg; + dc_dest = (ylookup[y1] + x) * 4 + dc_destorg; dc_count = count; draw4columns(); } else { - dc_dest = (ylookup[y1] + x) + dc_destorg; - for (int i = 0; i < 4; i++) + if (sampler[0].uv_max == 0 || sampler[0].uv_step == 0) // power of two, no wrap handling needed { - bufplce[i] = sampler[i].source; - } - - uint32_t left = y2 - y1; - while (left > 0) - { - // Find which column wraps first - uint32_t count = left; - for (int i = 0; i < 4; i++) - { - uint32_t available = sampler[i].uv_max - sampler[i].uv_pos; - uint32_t next_uv_wrap = available / sampler[i].uv_step; - if (available % sampler[i].uv_step != 0) - next_uv_wrap++; - count = MIN(next_uv_wrap, count); - } - - // Draw until that column wraps + int count = y2 - y1; for (int i = 0; i < 4; i++) { + bufplce[i] = sampler[i].source; + bufplce2[i] = sampler[i].source2; + buftexturefracx[i] = sampler[i].texturefracx; vplce[i] = sampler[i].uv_pos; vince[i] = sampler[i].uv_step; + + uint64_t step64 = sampler[i].uv_step; + uint64_t pos64 = sampler[i].uv_pos; + sampler[i].uv_pos = (uint32_t)(pos64 + step64 * count); } + dc_dest = (ylookup[y1] + x) + dc_destorg; dc_count = count; draw4columns(); - - // Wrap the uv position + } + else + { + dc_dest = (ylookup[y1] + x) + dc_destorg; for (int i = 0; i < 4; i++) { - sampler[i].uv_pos += sampler[i].uv_step * count; - if (sampler[i].uv_pos >= sampler[i].uv_max) - sampler[i].uv_pos -= sampler[i].uv_max; + bufplce[i] = sampler[i].source; + bufplce2[i] = sampler[i].source2; + buftexturefracx[i] = sampler[i].texturefracx; } - left -= count; + uint32_t left = y2 - y1; + while (left > 0) + { + // Find which column wraps first + uint32_t count = left; + for (int i = 0; i < 4; i++) + { + uint32_t available = sampler[i].uv_max - sampler[i].uv_pos; + uint32_t next_uv_wrap = available / sampler[i].uv_step; + if (available % sampler[i].uv_step != 0) + next_uv_wrap++; + count = MIN(next_uv_wrap, count); + } + + // Draw until that column wraps + for (int i = 0; i < 4; i++) + { + vplce[i] = sampler[i].uv_pos; + vince[i] = sampler[i].uv_step; + } + dc_count = count; + draw4columns(); + + // Wrap the uv position + for (int i = 0; i < 4; i++) + { + sampler[i].uv_pos += sampler[i].uv_step * count; + if (sampler[i].uv_pos >= sampler[i].uv_max) + sampler[i].uv_pos -= sampler[i].uv_max; + } + + left -= count; + } } } } @@ -231,7 +374,7 @@ void wallscan_any( DWORD(*draw1column)(); void(*draw4columns)(); - setupwallscan(fracbits, draw1column, draw4columns); + setupwallscan(r_swtruecolor ? FRACBITS : fracbits, draw1column, draw4columns); bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); if (fixed) @@ -240,12 +383,16 @@ void wallscan_any( palookupoffse[1] = dc_colormap; palookupoffse[2] = dc_colormap; palookupoffse[3] = dc_colormap; + palookuplight[0] = 0; + palookuplight[1] = 0; + palookuplight[2] = 0; + palookuplight[3] = 0; } if (fixedcolormap) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); else - dc_colormap = basecolormap->Maps; + R_SetColorMapLight(basecolormap, 0, 0); float light = rw_light; @@ -253,6 +400,8 @@ void wallscan_any( int aligned_x1 = clamp((x1 + 3) / 4 * 4, x1, x2); int aligned_x2 = clamp(x2 / 4 * 4, x1, x2); + double xmagnitude = 1.0; + // First unaligned columns: for (int x = x1; x < aligned_x1; x++, light += rw_lightstep) { @@ -262,9 +411,11 @@ void wallscan_any( continue; if (!fixed) - dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(basecolormap, light, wallshade); - WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, rw_pic, getcol); + if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); + + WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); wallscan_drawcol1(x, y1, y2, sampler, draw1column); } @@ -284,7 +435,10 @@ void wallscan_any( WallscanSampler sampler[4]; for (int i = 0; i < 4; i++) - sampler[i] = WallscanSampler(y1[i], swal[x + i], yrepeat, lwal[x + i] + xoffset, rw_pic, getcol); + { + if (x + i + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + i + 1]) - FIXED2DBL(lwal[x + i])); + sampler[i] = WallscanSampler(y1[i], swal[x + i], yrepeat, lwal[x + i] + xoffset, xmagnitude, rw_pic, getcol); + } // Figure out where we vertically can start and stop drawing 4 columns in one go int middle_y1 = y1[0]; @@ -297,13 +451,16 @@ void wallscan_any( // If we got an empty column in our set we cannot draw 4 columns in one go: bool empty_column_in_set = false; + int bilinear_count = 0; for (int i = 0; i < 4; i++) { if (y2[i] <= y1[i]) empty_column_in_set = true; + if (sampler[i].source2) + bilinear_count++; } - if (empty_column_in_set || middle_y2 <= middle_y1) + if (empty_column_in_set || middle_y2 <= middle_y1 || (bilinear_count > 0 && bilinear_count < 4)) { for (int i = 0; i < 4; i++) { @@ -311,7 +468,7 @@ void wallscan_any( continue; if (!fixed) - dc_colormap = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(basecolormap, lights[i], wallshade); wallscan_drawcol1(x + i, y1[i], y2[i], sampler[i], draw1column); } continue; @@ -321,7 +478,7 @@ void wallscan_any( for (int i = 0; i < 4; i++) { if (!fixed) - dc_colormap = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(basecolormap, lights[i], wallshade); if (y1[i] < middle_y1) wallscan_drawcol1(x + i, y1[i], middle_y1, sampler[i], draw1column); @@ -332,7 +489,16 @@ void wallscan_any( { for (int i = 0; i < 4; i++) { - palookupoffse[i] = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); + if (r_swtruecolor) + { + palookupoffse[i] = basecolormap->Maps; + palookuplight[i] = LIGHTSCALE(lights[i], wallshade); + } + else + { + palookupoffse[i] = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); + palookuplight[i] = 0; + } } } wallscan_drawcol4(x, middle_y1, middle_y2, sampler, draw4columns); @@ -341,7 +507,7 @@ void wallscan_any( for (int i = 0; i < 4; i++) { if (!fixed) - dc_colormap = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(basecolormap, lights[i], wallshade); if (middle_y2 < y2[i]) wallscan_drawcol1(x + i, middle_y2, y2[i], sampler[i], draw1column); @@ -357,13 +523,15 @@ void wallscan_any( continue; if (!fixed) - dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(basecolormap, light, wallshade); - WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, rw_pic, getcol); + if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); + + WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); wallscan_drawcol1(x, y1, y2, sampler, draw1column); } - NetUpdate(); + NetUpdate (); } void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) @@ -376,7 +544,7 @@ void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lw }); } -void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn) +void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) { if (!rw_pic->bMasked) // Textures that aren't masked can use the faster wallscan. { @@ -393,7 +561,7 @@ void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t } } -void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn) +void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) { static fixed_t(*tmvline1)(); static void(*tmvline4)(); @@ -454,7 +622,7 @@ void wallscan_striped (int x1, int x2, short *uwal, short *dwal, float *swal, fi wallshade = startshade; } -void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, bool mask) +static void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, bool mask) { if (mask) { @@ -493,67 +661,74 @@ void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, bool mask) { - short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; - short *up, *down; - double texheight = rw_pic->GetHeight(); - double partition; - double scaledtexheight = texheight / yrepeat; - - if (yrepeat >= 0) - { // normal orientation: draw strips from top to bottom - partition = top - fmod(top - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); - if (partition == top) - { - partition -= scaledtexheight; - } - up = uwal; - down = most1; - dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; - while (partition > bot) - { - int j = OWallMost(most3, partition - ViewPos.Z, &WallC); - if (j != 3) - { - for (int j = x1; j < x2; ++j) - { - down[j] = clamp(most3[j], up[j], dwal[j]); - } - call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); - up = down; - down = (down == most1) ? most2 : most1; - } - partition -= scaledtexheight; - dc_texturemid -= texheight; - } - call_wallscan(x1, x2, up, dwal, swal, lwal, yrepeat, mask); + if (!r_np2) + { + call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, mask); } else - { // upside down: draw strips from bottom to top - partition = bot - fmod(bot - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); - up = most1; - down = dwal; - dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; - while (partition < top) - { - int j = OWallMost(most3, partition - ViewPos.Z, &WallC); - if (j != 12) + { + short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; + short *up, *down; + double texheight = rw_pic->GetHeight(); + double partition; + double scaledtexheight = texheight / yrepeat; + + if (yrepeat >= 0) + { // normal orientation: draw strips from top to bottom + partition = top - fmod(top - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); + if (partition == top) { - for (int j = x1; j < x2; ++j) - { - up[j] = clamp(most3[j], uwal[j], down[j]); - } - call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); - down = up; - up = (up == most1) ? most2 : most1; + partition -= scaledtexheight; } - partition -= scaledtexheight; - dc_texturemid -= texheight; - } - call_wallscan(x1, x2, uwal, down, swal, lwal, yrepeat, mask); + up = uwal; + down = most1; + dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; + while (partition > bot) + { + int j = OWallMost(most3, partition - ViewPos.Z, &WallC); + if (j != 3) + { + for (int j = x1; j < x2; ++j) + { + down[j] = clamp(most3[j], up[j], dwal[j]); + } + call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); + up = down; + down = (down == most1) ? most2 : most1; + } + partition -= scaledtexheight; + dc_texturemid -= texheight; + } + call_wallscan(x1, x2, up, dwal, swal, lwal, yrepeat, mask); + } + else + { // upside down: draw strips from bottom to top + partition = bot - fmod(bot - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); + up = most1; + down = dwal; + dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; + while (partition < top) + { + int j = OWallMost(most3, partition - ViewPos.Z, &WallC); + if (j != 12) + { + for (int j = x1; j < x2; ++j) + { + up[j] = clamp(most3[j], uwal[j], down[j]); + } + call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); + down = up; + up = (up == most1) ? most2 : most1; + } + partition -= scaledtexheight; + dc_texturemid -= texheight; + } + call_wallscan(x1, x2, uwal, down, swal, lwal, yrepeat, mask); + } } } -void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) +static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) { if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) { @@ -579,5 +754,4 @@ void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, fl } } - } \ No newline at end of file From 56f37185b2c6ebad8945a5a6133da59167299870 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Dec 2016 12:21:27 +0100 Subject: [PATCH 1396/1509] - let's be a bit clearer and not name non-Build stuff with Build terms. (cherry picked from commit f3389ff5b716d7c913c4a5fa8ee27687de520db4) --- src/CMakeLists.txt | 2 +- src/{r_wallscan.cpp => r_walldraw.cpp} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/{r_wallscan.cpp => r_walldraw.cpp} (99%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5f04effb1..aa67b13d1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -828,7 +828,7 @@ set( FASTMATH_PCH_SOURCES r_segs.cpp r_sky.cpp r_things.cpp - r_wallscan.cpp + r_walldraw.cpp s_advsound.cpp s_environment.cpp s_playlist.cpp diff --git a/src/r_wallscan.cpp b/src/r_walldraw.cpp similarity index 99% rename from src/r_wallscan.cpp rename to src/r_walldraw.cpp index 8c5f04d54..de039115a 100644 --- a/src/r_wallscan.cpp +++ b/src/r_walldraw.cpp @@ -1,5 +1,5 @@ /* -** Replacement for Build's wallscan free of any Build licensing issues. +** Wall drawing stuff free of Build pollution ** Copyright (c) 2016 Magnus Norddahl ** ** This software is provided 'as-is', without any express or implied From d1379e26f5049d81267a3568bcabf15aae1f548b Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 9 Dec 2016 09:14:01 -0500 Subject: [PATCH 1397/1509] Revert "- moved wallscan code into its own file so that it can get an appropriate copyright notice and does not inflate an already large source file even more." This reverts commit 15cf9d36a999fbb18e5ffc0ad1ec38c308a56b08. --- src/CMakeLists.txt | 1 - src/r_draw.h | 2 + src/r_segs.cpp | 771 ++++++++++++++++++++++++++++++++++++++++++--- src/r_walldraw.cpp | 757 -------------------------------------------- 4 files changed, 736 insertions(+), 795 deletions(-) delete mode 100644 src/r_walldraw.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aa67b13d1..a3c63bb0b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -828,7 +828,6 @@ set( FASTMATH_PCH_SOURCES r_segs.cpp r_sky.cpp r_things.cpp - r_walldraw.cpp s_advsound.cpp s_environment.cpp s_playlist.cpp diff --git a/src/r_draw.h b/src/r_draw.h index e41214640..8c1af58fc 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -134,6 +134,8 @@ namespace swrenderer const uint8_t *R_GetColumn(FTexture *tex, int col); void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn); + void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn); + void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn); void rt_initcols(uint8_t *buffer = nullptr); void rt_span_coverage(int x, int start, int stop); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 1880273f9..c24e7f719 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -17,12 +17,6 @@ // DESCRIPTION: // All the clipping: columns, horizontal spans, sky columns. // -// This file contains some code from the Build Engine. -// -// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman -// Ken Silverman's official web site: "http://www.advsys.net/ken" -// See the included license file "BUILDLIC.TXT" for license info. -// //----------------------------------------------------------------------------- #include @@ -50,24 +44,22 @@ #include "r_plane.h" #include "r_segs.h" #include "r_3dfloors.h" +#include "r_draw.h" #include "v_palette.h" #include "r_data/colormaps.h" #define WALLYREPEAT 8 - +CVAR(Bool, r_np2, true, 0) CVAR(Bool, r_fogboundary, true, 0) CVAR(Bool, r_drawmirrors, true, 0) EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); +EXTERN_CVAR(Bool, r_mipmap) -namespace swrenderer +namespace swrenderer { using namespace drawerargs; - void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, bool mask); - void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, bool mask); - void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat); - #define HEIGHTBITS 12 #define HEIGHTSHIFT (FRACBITS-HEIGHTBITS) @@ -143,6 +135,9 @@ static fixed_t *maskedtexturecol; static void R_RenderDecal (side_t *wall, DBaseDecal *first, drawseg_t *clipper, int pass); static void WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans)); +void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, bool mask); +static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat); +static void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, bool mask); inline bool IsFogBoundary (sector_t *front, sector_t *back) { @@ -163,7 +158,7 @@ static void BlastMaskedColumn (FTexture *tex, bool useRt) // calculate lighting if (fixedcolormap == NULL && fixedlightlev < 0) { - dc_colormap = basecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(basecolormap, rw_light, wallshade); } dc_iscale = xs_Fix<16>::ToFix(MaskedSWall[dc_x] * MaskedScaleY); @@ -181,9 +176,7 @@ static void BlastMaskedColumn (FTexture *tex, bool useRt) // when forming multipatched textures (see r_data.c). // draw the texture - const FTexture::Span *spans; - const BYTE *pixels = tex->GetColumn (maskedtexturecol[dc_x] >> FRACBITS, &spans); - R_DrawMaskedColumn(pixels, spans, useRt); + R_DrawMaskedColumn(tex, maskedtexturecol[dc_x], useRt); rw_light += rw_lightstep; spryscale += rw_scalestep; } @@ -299,9 +292,9 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) rw_scalestep = ds->iscalestep; if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); // find positioning texheight = tex->GetScaledHeightDouble(); @@ -447,7 +440,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) while (dc_x < stop) { - rt_initcols(); + rt_initcols(nullptr); BlastMaskedColumn (tex, true); dc_x++; BlastMaskedColumn (tex, true); dc_x++; BlastMaskedColumn (tex, true); dc_x++; @@ -538,7 +531,7 @@ clearfog: } else { - clearbufshort(openings + ds->sprtopclip - ds->x1 + x1, x2 - x1, viewheight); + fillshort(openings + ds->sprtopclip - ds->x1 + x1, x2 - x1, viewheight); } } return; @@ -616,9 +609,9 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) } if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); WallC.sz1 = ds->sz1; WallC.sz2 = ds->sz2; @@ -1051,6 +1044,710 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2) return; } + +struct WallscanSampler +{ + WallscanSampler() { } + WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)); + + uint32_t uv_pos; + uint32_t uv_step; + uint32_t uv_max; + + const BYTE *source; + const BYTE *source2; + uint32_t texturefracx; + uint32_t height; +}; + +WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)) +{ + xoffset += FLOAT2FIXED(xmagnitude * 0.5); + + if (!r_swtruecolor) + { + height = texture->GetHeight(); + + int uv_fracbits = 32 - texture->HeightBits; + if (uv_fracbits != 32) + { + uv_max = height << uv_fracbits; + + // Find start uv in [0-base_height[ range. + // Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range. + double uv_stepd = swal * yrepeat; + double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / height; + v = v - floor(v); + v *= height; + v *= (1 << uv_fracbits); + + uv_pos = (uint32_t)v; + uv_step = xs_ToFixed(uv_fracbits, uv_stepd); + if (uv_step == 0) // To prevent divide by zero elsewhere + uv_step = 1; + } + else + { // Hack for one pixel tall textures + uv_pos = 0; + uv_step = 0; + uv_max = 1; + } + + source = getcol(texture, xoffset >> FRACBITS); + source2 = nullptr; + texturefracx = 0; + } + else + { + // Normalize to 0-1 range: + double uv_stepd = swal * yrepeat; + double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / texture->GetHeight(); + v = v - floor(v); + double v_step = uv_stepd / texture->GetHeight(); + + if (isnan(v) || isnan(v_step)) // this should never happen, but it apparently does.. + { + uv_stepd = 0.0; + v = 0.0; + v_step = 0.0; + } + + // Convert to uint32: + uv_pos = (uint32_t)(v * 0x100000000LL); + uv_step = (uint32_t)(v_step * 0x100000000LL); + uv_max = 0; + + // Texture mipmap and filter selection: + if (getcol != R_GetColumn) + { + source = getcol(texture, xoffset >> FRACBITS); + source2 = nullptr; + height = texture->GetHeight(); + texturefracx = 0; + } + else + { + double ymagnitude = fabs(uv_stepd); + double magnitude = MAX(ymagnitude, xmagnitude); + double min_lod = -1000.0; + double lod = MAX(log2(magnitude) + r_lod_bias, min_lod); + bool magnifying = lod < 0.0f; + + int mipmap_offset = 0; + int mip_width = texture->GetWidth(); + int mip_height = texture->GetHeight(); + if (r_mipmap && texture->Mipmapped() && mip_width > 1 && mip_height > 1) + { + uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width); + + int level = (int)lod; + while (level > 0 && mip_width > 1 && mip_height > 1) + { + mipmap_offset += mip_width * mip_height; + level--; + mip_width = MAX(mip_width >> 1, 1); + mip_height = MAX(mip_height >> 1, 1); + } + xoffset = (xpos >> FRACBITS) * mip_width; + } + + const uint32_t *pixels = texture->GetPixelsBgra() + mipmap_offset; + + bool filter_nearest = (magnifying && !r_magfilter) || (!magnifying && !r_minfilter); + if (filter_nearest) + { + int tx = (xoffset >> FRACBITS) % mip_width; + if (tx < 0) + tx += mip_width; + source = (BYTE*)(pixels + tx * mip_height); + source2 = nullptr; + height = mip_height; + texturefracx = 0; + } + else + { + xoffset -= FRACUNIT / 2; + int tx0 = (xoffset >> FRACBITS) % mip_width; + if (tx0 < 0) + tx0 += mip_width; + int tx1 = (tx0 + 1) % mip_width; + source = (BYTE*)(pixels + tx0 * mip_height); + source2 = (BYTE*)(pixels + tx1 * mip_height); + height = mip_height; + texturefracx = (xoffset >> (FRACBITS - 4)) & 15; + } + } + } +} + +// Draw a column with support for non-power-of-two ranges +void wallscan_drawcol1(int x, int y1, int y2, WallscanSampler &sampler, DWORD(*draw1column)()) +{ + if (r_swtruecolor) + { + int count = y2 - y1; + + dc_source = sampler.source; + dc_source2 = sampler.source2; + dc_texturefracx = sampler.texturefracx; + dc_dest = (ylookup[y1] + x) * 4 + dc_destorg; + dc_count = count; + dc_iscale = sampler.uv_step; + dc_texturefrac = sampler.uv_pos; + dc_textureheight = sampler.height; + draw1column(); + + uint64_t step64 = sampler.uv_step; + uint64_t pos64 = sampler.uv_pos; + sampler.uv_pos = (uint32_t)(pos64 + step64 * count); + } + else + { + if (sampler.uv_max == 0 || sampler.uv_step == 0) // power of two + { + int count = y2 - y1; + + dc_source = sampler.source; + dc_source2 = sampler.source2; + dc_texturefracx = sampler.texturefracx; + dc_dest = (ylookup[y1] + x) + dc_destorg; + dc_count = count; + dc_iscale = sampler.uv_step; + dc_texturefrac = sampler.uv_pos; + draw1column(); + + uint64_t step64 = sampler.uv_step; + uint64_t pos64 = sampler.uv_pos; + sampler.uv_pos = (uint32_t)(pos64 + step64 * count); + } + else + { + uint32_t uv_pos = sampler.uv_pos; + + uint32_t left = y2 - y1; + while (left > 0) + { + uint32_t available = sampler.uv_max - uv_pos; + uint32_t next_uv_wrap = available / sampler.uv_step; + if (available % sampler.uv_step != 0) + next_uv_wrap++; + uint32_t count = MIN(left, next_uv_wrap); + + dc_source = sampler.source; + dc_source2 = sampler.source2; + dc_texturefracx = sampler.texturefracx; + dc_dest = (ylookup[y1] + x) + dc_destorg; + dc_count = count; + dc_iscale = sampler.uv_step; + dc_texturefrac = uv_pos; + draw1column(); + + left -= count; + uv_pos += sampler.uv_step * count; + if (uv_pos >= sampler.uv_max) + uv_pos -= sampler.uv_max; + } + + sampler.uv_pos = uv_pos; + } + } +} + +// Draw four columns with support for non-power-of-two ranges +void wallscan_drawcol4(int x, int y1, int y2, WallscanSampler *sampler, void(*draw4columns)()) +{ + if (r_swtruecolor) + { + int count = y2 - y1; + for (int i = 0; i < 4; i++) + { + bufplce[i] = sampler[i].source; + bufplce2[i] = sampler[i].source2; + buftexturefracx[i] = sampler[i].texturefracx; + bufheight[i] = sampler[i].height; + vplce[i] = sampler[i].uv_pos; + vince[i] = sampler[i].uv_step; + + uint64_t step64 = sampler[i].uv_step; + uint64_t pos64 = sampler[i].uv_pos; + sampler[i].uv_pos = (uint32_t)(pos64 + step64 * count); + } + dc_dest = (ylookup[y1] + x) * 4 + dc_destorg; + dc_count = count; + draw4columns(); + } + else + { + if (sampler[0].uv_max == 0 || sampler[0].uv_step == 0) // power of two, no wrap handling needed + { + int count = y2 - y1; + for (int i = 0; i < 4; i++) + { + bufplce[i] = sampler[i].source; + bufplce2[i] = sampler[i].source2; + buftexturefracx[i] = sampler[i].texturefracx; + vplce[i] = sampler[i].uv_pos; + vince[i] = sampler[i].uv_step; + + uint64_t step64 = sampler[i].uv_step; + uint64_t pos64 = sampler[i].uv_pos; + sampler[i].uv_pos = (uint32_t)(pos64 + step64 * count); + } + dc_dest = (ylookup[y1] + x) + dc_destorg; + dc_count = count; + draw4columns(); + } + else + { + dc_dest = (ylookup[y1] + x) + dc_destorg; + for (int i = 0; i < 4; i++) + { + bufplce[i] = sampler[i].source; + bufplce2[i] = sampler[i].source2; + buftexturefracx[i] = sampler[i].texturefracx; + } + + uint32_t left = y2 - y1; + while (left > 0) + { + // Find which column wraps first + uint32_t count = left; + for (int i = 0; i < 4; i++) + { + uint32_t available = sampler[i].uv_max - sampler[i].uv_pos; + uint32_t next_uv_wrap = available / sampler[i].uv_step; + if (available % sampler[i].uv_step != 0) + next_uv_wrap++; + count = MIN(next_uv_wrap, count); + } + + // Draw until that column wraps + for (int i = 0; i < 4; i++) + { + vplce[i] = sampler[i].uv_pos; + vince[i] = sampler[i].uv_step; + } + dc_count = count; + draw4columns(); + + // Wrap the uv position + for (int i = 0; i < 4; i++) + { + sampler[i].uv_pos += sampler[i].uv_step * count; + if (sampler[i].uv_pos >= sampler[i].uv_max) + sampler[i].uv_pos -= sampler[i].uv_max; + } + + left -= count; + } + } + } +} + +typedef DWORD(*Draw1ColumnFuncPtr)(); +typedef void(*Draw4ColumnsFuncPtr)(); + +void wallscan_any( + int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, + const BYTE *(*getcol)(FTexture *tex, int x), + void(setupwallscan(int bits, Draw1ColumnFuncPtr &draw1, Draw4ColumnsFuncPtr &draw2))) +{ + if (rw_pic->UseType == FTexture::TEX_Null) + return; + + fixed_t xoffset = rw_offset; + + rw_pic->GetHeight(); // To ensure that rw_pic->HeightBits has been set + int fracbits = 32 - rw_pic->HeightBits; + if (fracbits == 32) + { // Hack for one pixel tall textures + fracbits = 0; + yrepeat = 0; + dc_texturemid = 0; + } + + DWORD(*draw1column)(); + void(*draw4columns)(); + setupwallscan(r_swtruecolor ? FRACBITS : fracbits, draw1column, draw4columns); + + bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); + if (fixed) + { + palookupoffse[0] = dc_colormap; + palookupoffse[1] = dc_colormap; + palookupoffse[2] = dc_colormap; + palookupoffse[3] = dc_colormap; + palookuplight[0] = 0; + palookuplight[1] = 0; + palookuplight[2] = 0; + palookuplight[3] = 0; + } + + if (fixedcolormap) + R_SetColorMapLight(fixedcolormap, 0, 0); + else + R_SetColorMapLight(basecolormap, 0, 0); + + float light = rw_light; + + // Calculate where 4 column alignment begins and ends: + int aligned_x1 = clamp((x1 + 3) / 4 * 4, x1, x2); + int aligned_x2 = clamp(x2 / 4 * 4, x1, x2); + + double xmagnitude = 1.0; + + // First unaligned columns: + for (int x = x1; x < aligned_x1; x++, light += rw_lightstep) + { + int y1 = uwal[x]; + int y2 = dwal[x]; + if (y2 <= y1) + continue; + + if (!fixed) + R_SetColorMapLight(basecolormap, light, wallshade); + + if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); + + WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); + wallscan_drawcol1(x, y1, y2, sampler, draw1column); + } + + // The aligned columns + for (int x = aligned_x1; x < aligned_x2; x += 4) + { + // Find y1, y2, light and uv values for four columns: + int y1[4] = { uwal[x], uwal[x + 1], uwal[x + 2], uwal[x + 3] }; + int y2[4] = { dwal[x], dwal[x + 1], dwal[x + 2], dwal[x + 3] }; + + float lights[4]; + for (int i = 0; i < 4; i++) + { + lights[i] = light; + light += rw_lightstep; + } + + WallscanSampler sampler[4]; + for (int i = 0; i < 4; i++) + { + if (x + i + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + i + 1]) - FIXED2DBL(lwal[x + i])); + sampler[i] = WallscanSampler(y1[i], swal[x + i], yrepeat, lwal[x + i] + xoffset, xmagnitude, rw_pic, getcol); + } + + // Figure out where we vertically can start and stop drawing 4 columns in one go + int middle_y1 = y1[0]; + int middle_y2 = y2[0]; + for (int i = 1; i < 4; i++) + { + middle_y1 = MAX(y1[i], middle_y1); + middle_y2 = MIN(y2[i], middle_y2); + } + + // If we got an empty column in our set we cannot draw 4 columns in one go: + bool empty_column_in_set = false; + int bilinear_count = 0; + for (int i = 0; i < 4; i++) + { + if (y2[i] <= y1[i]) + empty_column_in_set = true; + if (sampler[i].source2) + bilinear_count++; + } + + if (empty_column_in_set || middle_y2 <= middle_y1 || (bilinear_count > 0 && bilinear_count < 4)) + { + for (int i = 0; i < 4; i++) + { + if (y2[i] <= y1[i]) + continue; + + if (!fixed) + R_SetColorMapLight(basecolormap, lights[i], wallshade); + wallscan_drawcol1(x + i, y1[i], y2[i], sampler[i], draw1column); + } + continue; + } + + // Draw the first rows where not all 4 columns are active + for (int i = 0; i < 4; i++) + { + if (!fixed) + R_SetColorMapLight(basecolormap, lights[i], wallshade); + + if (y1[i] < middle_y1) + wallscan_drawcol1(x + i, y1[i], middle_y1, sampler[i], draw1column); + } + + // Draw the area where all 4 columns are active + if (!fixed) + { + for (int i = 0; i < 4; i++) + { + if (r_swtruecolor) + { + palookupoffse[i] = basecolormap->Maps; + palookuplight[i] = LIGHTSCALE(lights[i], wallshade); + } + else + { + palookupoffse[i] = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); + palookuplight[i] = 0; + } + } + } + wallscan_drawcol4(x, middle_y1, middle_y2, sampler, draw4columns); + + // Draw the last rows where not all 4 columns are active + for (int i = 0; i < 4; i++) + { + if (!fixed) + R_SetColorMapLight(basecolormap, lights[i], wallshade); + + if (middle_y2 < y2[i]) + wallscan_drawcol1(x + i, middle_y2, y2[i], sampler[i], draw1column); + } + } + + // The last unaligned columns: + for (int x = aligned_x2; x < x2; x++, light += rw_lightstep) + { + int y1 = uwal[x]; + int y2 = dwal[x]; + if (y2 <= y1) + continue; + + if (!fixed) + R_SetColorMapLight(basecolormap, light, wallshade); + + if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); + + WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); + wallscan_drawcol1(x, y1, y2, sampler, draw1column); + } + + NetUpdate (); +} + +void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) +{ + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + { + setupvline(bits); + line1 = dovline1; + line4 = dovline4; + }); +} + +void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) +{ + if (!rw_pic->bMasked) // Textures that aren't masked can use the faster wallscan. + { + wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); + } + else + { + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + { + setupmvline(bits); + line1 = domvline1; + line4 = domvline4; + }); + } +} + +void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) +{ + static fixed_t(*tmvline1)(); + static void(*tmvline4)(); + if (!R_GetTransMaskDrawers(&tmvline1, &tmvline4)) + { + // The current translucency is unsupported, so draw with regular maskwallscan instead. + maskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); + } + else + { + wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) + { + setuptmvline(bits); + line1 = reinterpret_cast(tmvline1); + line4 = tmvline4; + }); + } +} + +void wallscan_striped (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) +{ + FDynamicColormap *startcolormap = basecolormap; + int startshade = wallshade; + bool fogginess = foggy; + + short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; + short *up, *down; + + up = uwal; + down = most1; + + assert(WallC.sx1 <= x1); + assert(WallC.sx2 >= x2); + + // kg3D - fake floors instead of zdoom light list + for (unsigned int i = 0; i < frontsector->e->XFloor.lightlist.Size(); i++) + { + int j = WallMost (most3, frontsector->e->XFloor.lightlist[i].plane, &WallC); + if (j != 3) + { + for (int j = x1; j < x2; ++j) + { + down[j] = clamp (most3[j], up[j], dwal[j]); + } + wallscan (x1, x2, up, down, swal, lwal, yrepeat); + up = down; + down = (down == most1) ? most2 : most1; + } + + lightlist_t *lit = &frontsector->e->XFloor.lightlist[i]; + basecolormap = lit->extra_colormap; + wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(fogginess, + *lit->p_lightlevel, lit->lightsource != NULL) + r_actualextralight); + } + + wallscan (x1, x2, up, dwal, swal, lwal, yrepeat); + basecolormap = startcolormap; + wallshade = startshade; +} + +static void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, bool mask) +{ + if (mask) + { + if (colfunc == basecolfunc) + { + maskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); + } + else + { + transmaskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); + } + } + else + { + if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size())) + { + wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); + } + else + { + wallscan_striped(x1, x2, uwal, dwal, swal, lwal, yrepeat); + } + } +} + +//============================================================================= +// +// wallscan_np2 +// +// This is a wrapper around wallscan that helps it tile textures whose heights +// are not powers of 2. It divides the wall into texture-sized strips and calls +// wallscan for each of those. Since only one repetition of the texture fits +// in each strip, wallscan will not tile. +// +//============================================================================= + +void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, bool mask) +{ + if (!r_np2) + { + call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, mask); + } + else + { + short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; + short *up, *down; + double texheight = rw_pic->GetHeight(); + double partition; + double scaledtexheight = texheight / yrepeat; + + if (yrepeat >= 0) + { // normal orientation: draw strips from top to bottom + partition = top - fmod(top - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); + if (partition == top) + { + partition -= scaledtexheight; + } + up = uwal; + down = most1; + dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; + while (partition > bot) + { + int j = OWallMost(most3, partition - ViewPos.Z, &WallC); + if (j != 3) + { + for (int j = x1; j < x2; ++j) + { + down[j] = clamp(most3[j], up[j], dwal[j]); + } + call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); + up = down; + down = (down == most1) ? most2 : most1; + } + partition -= scaledtexheight; + dc_texturemid -= texheight; + } + call_wallscan(x1, x2, up, dwal, swal, lwal, yrepeat, mask); + } + else + { // upside down: draw strips from bottom to top + partition = bot - fmod(bot - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); + up = most1; + down = dwal; + dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; + while (partition < top) + { + int j = OWallMost(most3, partition - ViewPos.Z, &WallC); + if (j != 12) + { + for (int j = x1; j < x2; ++j) + { + up[j] = clamp(most3[j], uwal[j], down[j]); + } + call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); + down = up; + up = (up == most1) ? most2 : most1; + } + partition -= scaledtexheight; + dc_texturemid -= texheight; + } + call_wallscan(x1, x2, uwal, down, swal, lwal, yrepeat, mask); + } + } +} + +static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) +{ + if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) + { + double frontcz1 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v1); + double frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1); + double frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2); + double frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2); + double top = MAX(frontcz1, frontcz2); + double bot = MIN(frontfz1, frontfz2); + if (fake3D & FAKE3D_CLIPTOP) + { + top = MIN(top, sclipTop); + } + if (fake3D & FAKE3D_CLIPBOTTOM) + { + bot = MAX(bot, sclipBottom); + } + wallscan_np2(x1, x2, uwal, dwal, swal, lwal, yrepeat, top, bot, true); + } + else + { + call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, true); + } +} + // // R_RenderSegLoop // Draws zero, one, or two textures for walls. @@ -1071,9 +1768,9 @@ void R_RenderSegLoop () fixed_t xoffset = rw_offset; if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); // clip wall to the floor and ceiling for (x = x1; x < x2; ++x) @@ -1184,8 +1881,8 @@ void R_RenderSegLoop () call_wallscan(x1, x2, walltop, wallbottom, swall, lwall, yscale, false); } } - clearbufshort (ceilingclip+x1, x2-x1, viewheight); - clearbufshort (floorclip+x1, x2-x1, 0xffff); + fillshort (ceilingclip+x1, x2-x1, viewheight); + fillshort (floorclip+x1, x2-x1, 0xffff); } else { // two sided line @@ -1708,7 +2405,7 @@ void R_StoreWallRange (int start, int stop) { ds_p->sprtopclip = R_NewOpening (stop - start); ds_p->sprbottomclip = R_NewOpening (stop - start); - clearbufshort (openings + ds_p->sprtopclip, stop-start, viewheight); + fillshort (openings + ds_p->sprtopclip, stop-start, viewheight); memset (openings + ds_p->sprbottomclip, -1, (stop-start)*sizeof(short)); ds_p->silhouette = SIL_BOTH; } @@ -1748,7 +2445,7 @@ void R_StoreWallRange (int start, int stop) if (doorclosed || (rw_backfz1 >= rw_frontcz1 && rw_backfz2 >= rw_frontcz2)) { // killough 1/17/98, 2/8/98 ds_p->sprtopclip = R_NewOpening (stop - start); - clearbufshort (openings + ds_p->sprtopclip, stop - start, viewheight); + fillshort (openings + ds_p->sprtopclip, stop - start, viewheight); ds_p->silhouette |= SIL_TOP; } } @@ -1969,7 +2666,7 @@ int WallMostAny(short *mostbuf, double z1, double z2, const FWallCoords *wallc) } else if (y1 > viewheight && y2 > viewheight) // entire line is below screen { - clearbufshort(&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight); + fillshort(&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight); return 12; } @@ -2340,11 +3037,11 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rw_light = rw_lightleft + (x1 - savecoord.sx1) * rw_lightstep; if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (usecolormap->Maps + fixedlightlev); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT)) - dc_colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : usecolormap->Maps; + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0); else calclighting = true; @@ -2395,7 +3092,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, wallshade); } R_WallSpriteColumn (false); dc_x++; @@ -2405,9 +3102,9 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, wallshade); } - rt_initcols(); + rt_initcols(nullptr); for (int zz = 4; zz; --zz) { R_WallSpriteColumn (true); @@ -2420,7 +3117,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, wallshade); } R_WallSpriteColumn (false); dc_x++; @@ -2444,4 +3141,4 @@ done: WallC = savecoord; } -} \ No newline at end of file +} diff --git a/src/r_walldraw.cpp b/src/r_walldraw.cpp deleted file mode 100644 index de039115a..000000000 --- a/src/r_walldraw.cpp +++ /dev/null @@ -1,757 +0,0 @@ -/* -** Wall drawing stuff free of Build pollution -** Copyright (c) 2016 Magnus Norddahl -** -** This software is provided 'as-is', without any express or implied -** warranty. In no event will the authors be held liable for any damages -** arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, -** including commercial applications, and to alter it and redistribute it -** freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not -** claim that you wrote the original software. If you use this software -** in a product, an acknowledgment in the product documentation would be -** appreciated but is not required. -** 2. Altered source versions must be plainly marked as such, and must not be -** misrepresented as being the original software. -** 3. This notice may not be removed or altered from any source distribution. -** -*/ - -#include -#include - -#include "doomdef.h" -#include "doomstat.h" -#include "doomdata.h" - -#include "r_local.h" -#include "r_sky.h" -#include "v_video.h" - -#include "m_swap.h" -#include "a_sharedglobal.h" -#include "d_net.h" -#include "g_level.h" -#include "r_draw.h" -#include "r_bsp.h" -#include "r_plane.h" -#include "r_segs.h" -#include "r_3dfloors.h" -#include "v_palette.h" -#include "r_data/colormaps.h" - -namespace swrenderer -{ - using namespace drawerargs; - - extern FTexture *rw_pic; - extern int wallshade; - - -struct WallscanSampler -{ - WallscanSampler() { } - WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)); - - uint32_t uv_pos; - uint32_t uv_step; - uint32_t uv_max; - - const BYTE *source; - const BYTE *source2; - uint32_t texturefracx; - uint32_t height; -}; - -WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)) -{ - xoffset += FLOAT2FIXED(xmagnitude * 0.5); - - if (!r_swtruecolor) - { - height = texture->GetHeight(); - - int uv_fracbits = 32 - texture->HeightBits; - if (uv_fracbits != 32) - { - uv_max = height << uv_fracbits; - - // Find start uv in [0-base_height[ range. - // Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range. - double uv_stepd = swal * yrepeat; - double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / height; - v = v - floor(v); - v *= height; - v *= (1 << uv_fracbits); - - uv_pos = (uint32_t)v; - uv_step = xs_ToFixed(uv_fracbits, uv_stepd); - if (uv_step == 0) // To prevent divide by zero elsewhere - uv_step = 1; - } - else - { // Hack for one pixel tall textures - uv_pos = 0; - uv_step = 0; - uv_max = 1; - } - - source = getcol(texture, xoffset >> FRACBITS); - source2 = nullptr; - texturefracx = 0; - } - else - { - // Normalize to 0-1 range: - double uv_stepd = swal * yrepeat; - double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / texture->GetHeight(); - v = v - floor(v); - double v_step = uv_stepd / texture->GetHeight(); - - if (isnan(v) || isnan(v_step)) // this should never happen, but it apparently does.. - { - uv_stepd = 0.0; - v = 0.0; - v_step = 0.0; - } - - // Convert to uint32: - uv_pos = (uint32_t)(v * 0x100000000LL); - uv_step = (uint32_t)(v_step * 0x100000000LL); - uv_max = 0; - - // Texture mipmap and filter selection: - if (getcol != R_GetColumn) - { - source = getcol(texture, xoffset >> FRACBITS); - source2 = nullptr; - height = texture->GetHeight(); - texturefracx = 0; - } - else - { - double ymagnitude = fabs(uv_stepd); - double magnitude = MAX(ymagnitude, xmagnitude); - double min_lod = -1000.0; - double lod = MAX(log2(magnitude) + r_lod_bias, min_lod); - bool magnifying = lod < 0.0f; - - int mipmap_offset = 0; - int mip_width = texture->GetWidth(); - int mip_height = texture->GetHeight(); - if (r_mipmap && texture->Mipmapped() && mip_width > 1 && mip_height > 1) - { - uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width); - - int level = (int)lod; - while (level > 0 && mip_width > 1 && mip_height > 1) - { - mipmap_offset += mip_width * mip_height; - level--; - mip_width = MAX(mip_width >> 1, 1); - mip_height = MAX(mip_height >> 1, 1); - } - xoffset = (xpos >> FRACBITS) * mip_width; - } - - const uint32_t *pixels = texture->GetPixelsBgra() + mipmap_offset; - - bool filter_nearest = (magnifying && !r_magfilter) || (!magnifying && !r_minfilter); - if (filter_nearest) - { - int tx = (xoffset >> FRACBITS) % mip_width; - if (tx < 0) - tx += mip_width; - source = (BYTE*)(pixels + tx * mip_height); - source2 = nullptr; - height = mip_height; - texturefracx = 0; - } - else - { - xoffset -= FRACUNIT / 2; - int tx0 = (xoffset >> FRACBITS) % mip_width; - if (tx0 < 0) - tx0 += mip_width; - int tx1 = (tx0 + 1) % mip_width; - source = (BYTE*)(pixels + tx0 * mip_height); - source2 = (BYTE*)(pixels + tx1 * mip_height); - height = mip_height; - texturefracx = (xoffset >> (FRACBITS - 4)) & 15; - } - } - } -} - -// Draw a column with support for non-power-of-two ranges -void wallscan_drawcol1(int x, int y1, int y2, WallscanSampler &sampler, DWORD(*draw1column)()) -{ - if (r_swtruecolor) - { - int count = y2 - y1; - - dc_source = sampler.source; - dc_source2 = sampler.source2; - dc_texturefracx = sampler.texturefracx; - dc_dest = (ylookup[y1] + x) * 4 + dc_destorg; - dc_count = count; - dc_iscale = sampler.uv_step; - dc_texturefrac = sampler.uv_pos; - dc_textureheight = sampler.height; - draw1column(); - - uint64_t step64 = sampler.uv_step; - uint64_t pos64 = sampler.uv_pos; - sampler.uv_pos = (uint32_t)(pos64 + step64 * count); - } - else - { - if (sampler.uv_max == 0 || sampler.uv_step == 0) // power of two - { - int count = y2 - y1; - - dc_source = sampler.source; - dc_source2 = sampler.source2; - dc_texturefracx = sampler.texturefracx; - dc_dest = (ylookup[y1] + x) + dc_destorg; - dc_count = count; - dc_iscale = sampler.uv_step; - dc_texturefrac = sampler.uv_pos; - draw1column(); - - uint64_t step64 = sampler.uv_step; - uint64_t pos64 = sampler.uv_pos; - sampler.uv_pos = (uint32_t)(pos64 + step64 * count); - } - else - { - uint32_t uv_pos = sampler.uv_pos; - - uint32_t left = y2 - y1; - while (left > 0) - { - uint32_t available = sampler.uv_max - uv_pos; - uint32_t next_uv_wrap = available / sampler.uv_step; - if (available % sampler.uv_step != 0) - next_uv_wrap++; - uint32_t count = MIN(left, next_uv_wrap); - - dc_source = sampler.source; - dc_source2 = sampler.source2; - dc_texturefracx = sampler.texturefracx; - dc_dest = (ylookup[y1] + x) + dc_destorg; - dc_count = count; - dc_iscale = sampler.uv_step; - dc_texturefrac = uv_pos; - draw1column(); - - left -= count; - uv_pos += sampler.uv_step * count; - if (uv_pos >= sampler.uv_max) - uv_pos -= sampler.uv_max; - } - - sampler.uv_pos = uv_pos; - } - } -} - -// Draw four columns with support for non-power-of-two ranges -void wallscan_drawcol4(int x, int y1, int y2, WallscanSampler *sampler, void(*draw4columns)()) -{ - if (r_swtruecolor) - { - int count = y2 - y1; - for (int i = 0; i < 4; i++) - { - bufplce[i] = sampler[i].source; - bufplce2[i] = sampler[i].source2; - buftexturefracx[i] = sampler[i].texturefracx; - bufheight[i] = sampler[i].height; - vplce[i] = sampler[i].uv_pos; - vince[i] = sampler[i].uv_step; - - uint64_t step64 = sampler[i].uv_step; - uint64_t pos64 = sampler[i].uv_pos; - sampler[i].uv_pos = (uint32_t)(pos64 + step64 * count); - } - dc_dest = (ylookup[y1] + x) * 4 + dc_destorg; - dc_count = count; - draw4columns(); - } - else - { - if (sampler[0].uv_max == 0 || sampler[0].uv_step == 0) // power of two, no wrap handling needed - { - int count = y2 - y1; - for (int i = 0; i < 4; i++) - { - bufplce[i] = sampler[i].source; - bufplce2[i] = sampler[i].source2; - buftexturefracx[i] = sampler[i].texturefracx; - vplce[i] = sampler[i].uv_pos; - vince[i] = sampler[i].uv_step; - - uint64_t step64 = sampler[i].uv_step; - uint64_t pos64 = sampler[i].uv_pos; - sampler[i].uv_pos = (uint32_t)(pos64 + step64 * count); - } - dc_dest = (ylookup[y1] + x) + dc_destorg; - dc_count = count; - draw4columns(); - } - else - { - dc_dest = (ylookup[y1] + x) + dc_destorg; - for (int i = 0; i < 4; i++) - { - bufplce[i] = sampler[i].source; - bufplce2[i] = sampler[i].source2; - buftexturefracx[i] = sampler[i].texturefracx; - } - - uint32_t left = y2 - y1; - while (left > 0) - { - // Find which column wraps first - uint32_t count = left; - for (int i = 0; i < 4; i++) - { - uint32_t available = sampler[i].uv_max - sampler[i].uv_pos; - uint32_t next_uv_wrap = available / sampler[i].uv_step; - if (available % sampler[i].uv_step != 0) - next_uv_wrap++; - count = MIN(next_uv_wrap, count); - } - - // Draw until that column wraps - for (int i = 0; i < 4; i++) - { - vplce[i] = sampler[i].uv_pos; - vince[i] = sampler[i].uv_step; - } - dc_count = count; - draw4columns(); - - // Wrap the uv position - for (int i = 0; i < 4; i++) - { - sampler[i].uv_pos += sampler[i].uv_step * count; - if (sampler[i].uv_pos >= sampler[i].uv_max) - sampler[i].uv_pos -= sampler[i].uv_max; - } - - left -= count; - } - } - } -} - -typedef DWORD(*Draw1ColumnFuncPtr)(); -typedef void(*Draw4ColumnsFuncPtr)(); - -void wallscan_any( - int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, - const BYTE *(*getcol)(FTexture *tex, int x), - void(setupwallscan(int bits, Draw1ColumnFuncPtr &draw1, Draw4ColumnsFuncPtr &draw2))) -{ - if (rw_pic->UseType == FTexture::TEX_Null) - return; - - fixed_t xoffset = rw_offset; - - rw_pic->GetHeight(); // To ensure that rw_pic->HeightBits has been set - int fracbits = 32 - rw_pic->HeightBits; - if (fracbits == 32) - { // Hack for one pixel tall textures - fracbits = 0; - yrepeat = 0; - dc_texturemid = 0; - } - - DWORD(*draw1column)(); - void(*draw4columns)(); - setupwallscan(r_swtruecolor ? FRACBITS : fracbits, draw1column, draw4columns); - - bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); - if (fixed) - { - palookupoffse[0] = dc_colormap; - palookupoffse[1] = dc_colormap; - palookupoffse[2] = dc_colormap; - palookupoffse[3] = dc_colormap; - palookuplight[0] = 0; - palookuplight[1] = 0; - palookuplight[2] = 0; - palookuplight[3] = 0; - } - - if (fixedcolormap) - R_SetColorMapLight(fixedcolormap, 0, 0); - else - R_SetColorMapLight(basecolormap, 0, 0); - - float light = rw_light; - - // Calculate where 4 column alignment begins and ends: - int aligned_x1 = clamp((x1 + 3) / 4 * 4, x1, x2); - int aligned_x2 = clamp(x2 / 4 * 4, x1, x2); - - double xmagnitude = 1.0; - - // First unaligned columns: - for (int x = x1; x < aligned_x1; x++, light += rw_lightstep) - { - int y1 = uwal[x]; - int y2 = dwal[x]; - if (y2 <= y1) - continue; - - if (!fixed) - R_SetColorMapLight(basecolormap, light, wallshade); - - if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); - - WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); - wallscan_drawcol1(x, y1, y2, sampler, draw1column); - } - - // The aligned columns - for (int x = aligned_x1; x < aligned_x2; x += 4) - { - // Find y1, y2, light and uv values for four columns: - int y1[4] = { uwal[x], uwal[x + 1], uwal[x + 2], uwal[x + 3] }; - int y2[4] = { dwal[x], dwal[x + 1], dwal[x + 2], dwal[x + 3] }; - - float lights[4]; - for (int i = 0; i < 4; i++) - { - lights[i] = light; - light += rw_lightstep; - } - - WallscanSampler sampler[4]; - for (int i = 0; i < 4; i++) - { - if (x + i + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + i + 1]) - FIXED2DBL(lwal[x + i])); - sampler[i] = WallscanSampler(y1[i], swal[x + i], yrepeat, lwal[x + i] + xoffset, xmagnitude, rw_pic, getcol); - } - - // Figure out where we vertically can start and stop drawing 4 columns in one go - int middle_y1 = y1[0]; - int middle_y2 = y2[0]; - for (int i = 1; i < 4; i++) - { - middle_y1 = MAX(y1[i], middle_y1); - middle_y2 = MIN(y2[i], middle_y2); - } - - // If we got an empty column in our set we cannot draw 4 columns in one go: - bool empty_column_in_set = false; - int bilinear_count = 0; - for (int i = 0; i < 4; i++) - { - if (y2[i] <= y1[i]) - empty_column_in_set = true; - if (sampler[i].source2) - bilinear_count++; - } - - if (empty_column_in_set || middle_y2 <= middle_y1 || (bilinear_count > 0 && bilinear_count < 4)) - { - for (int i = 0; i < 4; i++) - { - if (y2[i] <= y1[i]) - continue; - - if (!fixed) - R_SetColorMapLight(basecolormap, lights[i], wallshade); - wallscan_drawcol1(x + i, y1[i], y2[i], sampler[i], draw1column); - } - continue; - } - - // Draw the first rows where not all 4 columns are active - for (int i = 0; i < 4; i++) - { - if (!fixed) - R_SetColorMapLight(basecolormap, lights[i], wallshade); - - if (y1[i] < middle_y1) - wallscan_drawcol1(x + i, y1[i], middle_y1, sampler[i], draw1column); - } - - // Draw the area where all 4 columns are active - if (!fixed) - { - for (int i = 0; i < 4; i++) - { - if (r_swtruecolor) - { - palookupoffse[i] = basecolormap->Maps; - palookuplight[i] = LIGHTSCALE(lights[i], wallshade); - } - else - { - palookupoffse[i] = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); - palookuplight[i] = 0; - } - } - } - wallscan_drawcol4(x, middle_y1, middle_y2, sampler, draw4columns); - - // Draw the last rows where not all 4 columns are active - for (int i = 0; i < 4; i++) - { - if (!fixed) - R_SetColorMapLight(basecolormap, lights[i], wallshade); - - if (middle_y2 < y2[i]) - wallscan_drawcol1(x + i, middle_y2, y2[i], sampler[i], draw1column); - } - } - - // The last unaligned columns: - for (int x = aligned_x2; x < x2; x++, light += rw_lightstep) - { - int y1 = uwal[x]; - int y2 = dwal[x]; - if (y2 <= y1) - continue; - - if (!fixed) - R_SetColorMapLight(basecolormap, light, wallshade); - - if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); - - WallscanSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); - wallscan_drawcol1(x, y1, y2, sampler, draw1column); - } - - NetUpdate (); -} - -void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) -{ - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) - { - setupvline(bits); - line1 = dovline1; - line4 = dovline4; - }); -} - -void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) -{ - if (!rw_pic->bMasked) // Textures that aren't masked can use the faster wallscan. - { - wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); - } - else - { - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) - { - setupmvline(bits); - line1 = domvline1; - line4 = domvline4; - }); - } -} - -void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) -{ - static fixed_t(*tmvline1)(); - static void(*tmvline4)(); - if (!R_GetTransMaskDrawers(&tmvline1, &tmvline4)) - { - // The current translucency is unsupported, so draw with regular maskwallscan instead. - maskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); - } - else - { - wallscan_any(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) - { - setuptmvline(bits); - line1 = reinterpret_cast(tmvline1); - line4 = tmvline4; - }); - } -} - -void wallscan_striped (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) -{ - FDynamicColormap *startcolormap = basecolormap; - int startshade = wallshade; - bool fogginess = foggy; - - short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; - short *up, *down; - - up = uwal; - down = most1; - - assert(WallC.sx1 <= x1); - assert(WallC.sx2 >= x2); - - // kg3D - fake floors instead of zdoom light list - for (unsigned int i = 0; i < frontsector->e->XFloor.lightlist.Size(); i++) - { - int j = WallMost (most3, frontsector->e->XFloor.lightlist[i].plane, &WallC); - if (j != 3) - { - for (int j = x1; j < x2; ++j) - { - down[j] = clamp (most3[j], up[j], dwal[j]); - } - wallscan (x1, x2, up, down, swal, lwal, yrepeat); - up = down; - down = (down == most1) ? most2 : most1; - } - - lightlist_t *lit = &frontsector->e->XFloor.lightlist[i]; - basecolormap = lit->extra_colormap; - wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(fogginess, - *lit->p_lightlevel, lit->lightsource != NULL) + r_actualextralight); - } - - wallscan (x1, x2, up, dwal, swal, lwal, yrepeat); - basecolormap = startcolormap; - wallshade = startshade; -} - -static void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, bool mask) -{ - if (mask) - { - if (colfunc == basecolfunc) - { - maskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); - } - else - { - transmaskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); - } - } - else - { - if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size())) - { - wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); - } - else - { - wallscan_striped(x1, x2, uwal, dwal, swal, lwal, yrepeat); - } - } -} - -//============================================================================= -// -// wallscan_np2 -// -// This is a wrapper around wallscan that helps it tile textures whose heights -// are not powers of 2. It divides the wall into texture-sized strips and calls -// wallscan for each of those. Since only one repetition of the texture fits -// in each strip, wallscan will not tile. -// -//============================================================================= - -void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, bool mask) -{ - if (!r_np2) - { - call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, mask); - } - else - { - short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; - short *up, *down; - double texheight = rw_pic->GetHeight(); - double partition; - double scaledtexheight = texheight / yrepeat; - - if (yrepeat >= 0) - { // normal orientation: draw strips from top to bottom - partition = top - fmod(top - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); - if (partition == top) - { - partition -= scaledtexheight; - } - up = uwal; - down = most1; - dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; - while (partition > bot) - { - int j = OWallMost(most3, partition - ViewPos.Z, &WallC); - if (j != 3) - { - for (int j = x1; j < x2; ++j) - { - down[j] = clamp(most3[j], up[j], dwal[j]); - } - call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); - up = down; - down = (down == most1) ? most2 : most1; - } - partition -= scaledtexheight; - dc_texturemid -= texheight; - } - call_wallscan(x1, x2, up, dwal, swal, lwal, yrepeat, mask); - } - else - { // upside down: draw strips from bottom to top - partition = bot - fmod(bot - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight); - up = most1; - down = dwal; - dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight; - while (partition < top) - { - int j = OWallMost(most3, partition - ViewPos.Z, &WallC); - if (j != 12) - { - for (int j = x1; j < x2; ++j) - { - up[j] = clamp(most3[j], uwal[j], down[j]); - } - call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); - down = up; - up = (up == most1) ? most2 : most1; - } - partition -= scaledtexheight; - dc_texturemid -= texheight; - } - call_wallscan(x1, x2, uwal, down, swal, lwal, yrepeat, mask); - } - } -} - -static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) -{ - if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) - { - double frontcz1 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v1); - double frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1); - double frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2); - double frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2); - double top = MAX(frontcz1, frontcz2); - double bot = MIN(frontfz1, frontfz2); - if (fake3D & FAKE3D_CLIPTOP) - { - top = MIN(top, sclipTop); - } - if (fake3D & FAKE3D_CLIPBOTTOM) - { - bot = MAX(bot, sclipBottom); - } - wallscan_np2(x1, x2, uwal, dwal, swal, lwal, yrepeat, top, bot, true); - } - else - { - call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, true); - } -} - -} \ No newline at end of file From 7376414607177794ad9b5f1133daa256b9469ef4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 10 Dec 2016 00:17:18 +0100 Subject: [PATCH 1398/1509] Added some missing static statements --- src/r_walldraw.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_walldraw.cpp b/src/r_walldraw.cpp index 0f2802b01..1570707cc 100644 --- a/src/r_walldraw.cpp +++ b/src/r_walldraw.cpp @@ -552,7 +552,7 @@ WallSampler::WallSampler(int y1, float swal, double yrepeat, fixed_t xoffset, do } // Draw a column with support for non-power-of-two ranges -void Draw1Column(int x, int y1, int y2, WallSampler &sampler, DWORD(*draw1column)()) +static void Draw1Column(int x, int y1, int y2, WallSampler &sampler, DWORD(*draw1column)()) { if (r_swtruecolor) { @@ -625,7 +625,7 @@ void Draw1Column(int x, int y1, int y2, WallSampler &sampler, DWORD(*draw1column } // Draw four columns with support for non-power-of-two ranges -void Draw4Columns(int x, int y1, int y2, WallSampler *sampler, void(*draw4columns)()) +static void Draw4Columns(int x, int y1, int y2, WallSampler *sampler, void(*draw4columns)()) { if (r_swtruecolor) { @@ -718,7 +718,7 @@ void Draw4Columns(int x, int y1, int y2, WallSampler *sampler, void(*draw4column typedef DWORD(*Draw1ColumnFuncPtr)(); typedef void(*Draw4ColumnsFuncPtr)(); -void ProcessWallWorker( +static void ProcessWallWorker( int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x), void(setupProcessNormalWall(int bits, Draw1ColumnFuncPtr &draw1, Draw4ColumnsFuncPtr &draw2))) From 21341b92a5cc61f39d3e40419c2cc06571c502c0 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 11 Dec 2016 17:39:44 +0100 Subject: [PATCH 1399/1509] Experiment with splitting triangle block coverage from block drawing --- src/r_poly_triangle.cpp | 261 ++++++++++++++++++++++++++++++++++++++++ src/r_poly_triangle.h | 46 +++++++ 2 files changed, 307 insertions(+) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 45f244aab..13c04d5ef 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -92,6 +92,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian switch (variant) { default: + //case TriDrawVariant::DrawNormal: drawfunc = &ScreenTriangle::DrawFunc; break; case TriDrawVariant::DrawNormal: drawfunc = dest_bgra ? llvm->TriDrawNormal32[bmode] : llvm->TriDrawNormal8[bmode]; break; case TriDrawVariant::FillNormal: drawfunc = dest_bgra ? llvm->TriFillNormal32[bmode] : llvm->TriFillNormal8[bmode]; break; case TriDrawVariant::DrawSubsector: drawfunc = dest_bgra ? llvm->TriDrawSubsector32[bmode] : llvm->TriDrawSubsector8[bmode]; break; @@ -569,3 +570,263 @@ void PolyVertexBuffer::Clear() { NextBufferVertex = 0; } + +///////////////////////////////////////////////////////////////////////////// + +void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *thread) +{ + const TriVertex &v1 = *args->v1; + const TriVertex &v2 = *args->v2; + const TriVertex &v3 = *args->v3; + int clipright = args->clipright; + int clipbottom = args->clipbottom; + + ScreenTriangleFullSpan *span = FullSpans; + ScreenTrianglePartialBlock *partial = PartialBlocks; + int curSpan = 0; + int curPartial = 0; + span->Length = 0; + + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, 0); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, 0); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); + if (minx >= maxx || miny >= maxy) + return; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // First block line for this thread + int core = thread->core; + int num_cores = thread->num_cores; + int core_skip = (num_cores - ((miny / q) - core) % num_cores) % num_cores; + miny += core_skip * q; + + // Loop through blocks + for (int y = miny; y < maxy; y += q * num_cores) + { + for (int x = minx; x < maxx; x += q) + { + // Corners of block + int x0 = x << 4; + int x1 = (x + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; + bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; + bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; + bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; + int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); + + bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; + bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; + bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; + bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; + int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); + + bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; + bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; + bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; + bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; + int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + + // Skip block when outside an edge + if (a == 0x0 || b == 0x0 || c == 0x0) continue; + + // Accept whole block when totally covered + if (a == 0xF && b == 0xF && c == 0xF && x + q <= clipright && y + q <= clipbottom) + { + if (span->Length != 0) + { + span->Length++; + } + else + { + span->X = x; + span->Y = y; + span->Length = 1; + } + } + else // Partially covered block + { + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; + + uint64_t mask = 0; + + for (int iy = 0; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + for (int ix = x; ix < x + q; ix++) + { + bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && ix < clipright && iy < clipbottom); + mask <<= 1; + mask |= covered; + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + } + + if (mask != 0xffffffffffffffffLL) + { + if (span->Length > 0) + { + curSpan++; + span++; + span->Length = 0; + } + + partial->X = x; + partial->Y = y; + partial->Mask0 = (uint32_t)(mask >> 32); + partial->Mask1 = (uint32_t)mask; + partial++; + curPartial++; + } + else if (span->Length != 0) + { + span->Length++; + } + else + { + span->X = x; + span->Y = y; + span->Length = 1; + } + } + } + + if (span->Length > 0) + { + curSpan++; + span++; + span->Length = 0; + } + } + + NumFullSpans = curSpan; + NumPartialBlocks = curPartial; +} + +void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) +{ + for (int i = 0; i < NumFullSpans; i++) + { + const auto &span = FullSpans[i]; + + uint32_t *dest = (uint32_t*)args->dest + span.X + span.Y * args->pitch; + int pitch = args->pitch; + int width = span.Length * 8; + int height = 8; + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + dest[x] = 0xffffffff; + } + + dest += pitch; + } + } + + for (int i = 0; i < NumPartialBlocks; i++) + { + const auto &block = PartialBlocks[i]; + + uint32_t *dest = (uint32_t*)args->dest + block.X + block.Y * args->pitch; + int pitch = args->pitch; + uint32_t mask0 = block.Mask0; + uint32_t mask1 = block.Mask1; + for (int y = 0; y < 4; y++) + { + for (int x = 0; x < 8; x++) + { + if (mask0 & (1<<31)) + dest[x] = 0xffff0000; + mask0 <<= 1; + } + dest += pitch; + } + for (int y = 4; y < 8; y++) + { + for (int x = 0; x < 8; x++) + { + if (mask1 & (1<<31)) + dest[x] = 0xffff0000; + mask1 <<= 1; + } + dest += pitch; + } + } +} + +void ScreenTriangle::DrawFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) +{ + static ScreenTriangle triangle[8]; + + triangle[thread->core].Setup(args, thread); + triangle[thread->core].Draw(args); +} + +ScreenTriangle::ScreenTriangle() +{ + FullSpansBuffer.resize(MAXWIDTH / 8 * (MAXHEIGHT / 8)); + PartialBlocksBuffer.resize(MAXWIDTH / 8 * (MAXHEIGHT / 8)); + FullSpans = FullSpansBuffer.data(); + PartialBlocks = PartialBlocksBuffer.data(); +} diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index ecf05a921..28c903c0c 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -264,3 +264,49 @@ public: static TriVertex *GetVertices(int count); static void Clear(); }; + +struct ScreenTriangleBlock +{ + float W; + float Varying[TriVertex::NumVarying]; +}; + +struct ScreenTriangleFullSpan +{ + uint16_t X; + uint16_t Y; + uint32_t Length; +}; + +struct ScreenTrianglePartialBlock +{ + uint16_t X; + uint16_t Y; + uint32_t Mask0; + uint32_t Mask1; +}; + +class ScreenTriangle +{ +public: + static void DrawFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); + + ScreenTriangle(); + + void Setup(const TriDrawTriangleArgs *args, WorkerThreadData *thread); + void Draw(const TriDrawTriangleArgs *args); + + ScreenTriangleFullSpan *FullSpans; + ScreenTrianglePartialBlock *PartialBlocks; + int NumFullSpans; + int NumPartialBlocks; + int StartX; + int StartY; + ScreenTriangleBlock Start; + ScreenTriangleBlock GradientX; + ScreenTriangleBlock GradientY; + +private: + std::vector FullSpansBuffer; + std::vector PartialBlocksBuffer; +}; From b2bed88092a402b0da17257adc61c29cb9e4981f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 12 Dec 2016 01:33:51 +0100 Subject: [PATCH 1400/1509] SSE speed test --- src/r_poly_triangle.cpp | 260 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 246 insertions(+), 14 deletions(-) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 13c04d5ef..a8b0154af 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -572,7 +572,223 @@ void PolyVertexBuffer::Clear() } ///////////////////////////////////////////////////////////////////////////// +#if 1 +void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *thread) +{ + const TriVertex &v1 = *args->v1; + const TriVertex &v2 = *args->v2; + const TriVertex &v3 = *args->v3; + int clipright = args->clipright; + int clipbottom = args->clipbottom; + ScreenTriangleFullSpan *span = FullSpans; + ScreenTrianglePartialBlock *partial = PartialBlocks; + span->Length = 0; + + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, 0); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, 0); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); + if (minx >= maxx || miny >= maxy) + return; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // First block line for this thread + int core = thread->core; + int num_cores = thread->num_cores; + int core_skip = (num_cores - ((miny / q) - core) % num_cores) % num_cores; + miny += core_skip * q; + + __m128i mC1 = _mm_set1_epi32(C1); + __m128i mC2 = _mm_set1_epi32(C2); + __m128i mC3 = _mm_set1_epi32(C3); + __m128i mDX12 = _mm_set1_epi32(DX12); + __m128i mDX23 = _mm_set1_epi32(DX23); + __m128i mDX31 = _mm_set1_epi32(DX31); + __m128i mDY12 = _mm_set1_epi32(DY12); + __m128i mDY23 = _mm_set1_epi32(DY23); + __m128i mDY31 = _mm_set1_epi32(DY31); + + // Loop through blocks + for (int y = miny; y < maxy; y += q * num_cores) + { + // Corners of block + int x0 = minx << 4; + int x1 = (minx + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; + + __m128i my0y1 = _mm_set_epi32(y0, y0, y1, y1); + __m128i mx0x1 = _mm_set_epi32(x0, x1, x0, x1); + __m128i mAxx = _mm_add_epi32(mC1, _mm_sub_epi32(_mm_mullo_epi32(mDX12, my0y1), _mm_mullo_epi32(mDY12, mx0x1))); + __m128i mBxx = _mm_add_epi32(mC2, _mm_sub_epi32(_mm_mullo_epi32(mDX23, my0y1), _mm_mullo_epi32(mDY23, mx0x1))); + __m128i mCxx = _mm_add_epi32(mC3, _mm_sub_epi32(_mm_mullo_epi32(mDX31, my0y1), _mm_mullo_epi32(mDY31, mx0x1))); + + for (int x = minx; x < maxx; x += q) + { + // Evaluate half-space functions + int a = _mm_movemask_epi8(_mm_cmpgt_epi32(mAxx, _mm_setzero_si128())); + int b = _mm_movemask_epi8(_mm_cmpgt_epi32(mBxx, _mm_setzero_si128())); + int c = _mm_movemask_epi8(_mm_cmpgt_epi32(mCxx, _mm_setzero_si128())); + + mAxx = _mm_sub_epi32(mAxx, _mm_slli_epi32(mDY12, 7)); + mBxx = _mm_sub_epi32(mBxx, _mm_slli_epi32(mDY23, 7)); + mCxx = _mm_sub_epi32(mCxx, _mm_slli_epi32(mDY31, 7)); + + // Skip block when outside an edge + if (a == 0 || b == 0 || c == 0) continue; + + // Accept whole block when totally covered + if (a == 0xffff && b == 0xffff && c == 0xffff && x + q <= clipright && y + q <= clipbottom) + { + if (span->Length != 0) + { + span->Length++; + } + else + { + span->X = x; + span->Y = y; + span->Length = 1; + } + } + else // Partially covered block + { + x0 = x << 4; + x1 = (x + q - 1) << 4; + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; + + uint32_t mask0 = 0; + uint32_t mask1 = 0; + + for (int iy = 0; iy < 4; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + for (int ix = x; ix < x + q; ix++) + { + bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && ix < clipright && iy < clipbottom); + mask0 <<= 1; + mask0 |= (uint32_t)covered; + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + } + + for (int iy = 4; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + for (int ix = x; ix < x + q; ix++) + { + bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && ix < clipright && iy < clipbottom); + mask1 <<= 1; + mask1 |= (uint32_t)covered; + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + } + + if (mask0 != 0xffffffff || mask1 != 0xffffffff) + { + if (span->Length > 0) + { + span++; + span->Length = 0; + } + + partial->X = x; + partial->Y = y; + partial->Mask0 = mask0; + partial->Mask1 = mask1; + partial++; + } + else if (span->Length != 0) + { + span->Length++; + } + else + { + span->X = x; + span->Y = y; + span->Length = 1; + } + } + } + + if (span->Length > 0) + { + span++; + span->Length = 0; + } + } + + NumFullSpans = (int)(span - FullSpans); + NumPartialBlocks = (int)(partial - PartialBlocks); +} +#else void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { const TriVertex &v1 = *args->v1; @@ -583,8 +799,6 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th ScreenTriangleFullSpan *span = FullSpans; ScreenTrianglePartialBlock *partial = PartialBlocks; - int curSpan = 0; - int curPartial = 0; span->Length = 0; // 28.4 fixed-point coordinates @@ -676,7 +890,15 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); // Skip block when outside an edge - if (a == 0x0 || b == 0x0 || c == 0x0) continue; + if (a == 0x0 || b == 0x0 || c == 0x0) + { + if (span->Length != 0) + { + span++; + span->Length = 0; + } + continue; + } // Accept whole block when totally covered if (a == 0xF && b == 0xF && c == 0xF && x + q <= clipright && y + q <= clipbottom) @@ -710,7 +932,7 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th { bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && ix < clipright && iy < clipbottom); mask <<= 1; - mask |= covered; + mask |= (uint64_t)covered; CX1 -= FDY12; CX2 -= FDY23; @@ -724,9 +946,8 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th if (mask != 0xffffffffffffffffLL) { - if (span->Length > 0) + if (span->Length != 0) { - curSpan++; span++; span->Length = 0; } @@ -736,7 +957,6 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th partial->Mask0 = (uint32_t)(mask >> 32); partial->Mask1 = (uint32_t)mask; partial++; - curPartial++; } else if (span->Length != 0) { @@ -751,20 +971,32 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th } } - if (span->Length > 0) + if (span->Length != 0) { - curSpan++; span++; span->Length = 0; } } - NumFullSpans = curSpan; - NumPartialBlocks = curPartial; + NumFullSpans = (int)(span - FullSpans); + NumPartialBlocks = (int)(partial - PartialBlocks); } +#endif void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) { + float r = args->v1->x / 255.0f; + float g = args->v1->y / 255.0f; + float b = args->v1->z / 255.0f; + r = (r - floor(r)) * 255; + g = (g - floor(g)) * 255; + b = (b - floor(b)) * 255; + + uint32_t red = (uint32_t)r; + uint32_t green = (uint32_t)g; + uint32_t blue = (uint32_t)b; + uint32_t solidcolor = 0xff000000 | (red << 16) | (green << 8) | blue; + for (int i = 0; i < NumFullSpans; i++) { const auto &span = FullSpans[i]; @@ -777,7 +1009,7 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) { for (int x = 0; x < width; x++) { - dest[x] = 0xffffffff; + dest[x] = solidcolor; } dest += pitch; @@ -797,7 +1029,7 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) for (int x = 0; x < 8; x++) { if (mask0 & (1<<31)) - dest[x] = 0xffff0000; + dest[x] = solidcolor; mask0 <<= 1; } dest += pitch; @@ -807,7 +1039,7 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) for (int x = 0; x < 8; x++) { if (mask1 & (1<<31)) - dest[x] = 0xffff0000; + dest[x] = solidcolor; mask1 <<= 1; } dest += pitch; From bee363d79a02caf368452dbf74fddaf4be943afb Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 12 Dec 2016 10:44:34 +0100 Subject: [PATCH 1401/1509] Add stencil testing --- src/r_poly_triangle.cpp | 116 ++++++++++++++++++++++++++++++---------- 1 file changed, 89 insertions(+), 27 deletions(-) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index a8b0154af..be1d5ea75 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -35,6 +35,7 @@ #include "v_palette.h" #include "r_data/colormaps.h" #include "r_poly_triangle.h" +#include int PolyTriangleDrawer::viewport_x; int PolyTriangleDrawer::viewport_y; @@ -572,7 +573,7 @@ void PolyVertexBuffer::Clear() } ///////////////////////////////////////////////////////////////////////////// -#if 1 +#if 0 void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { const TriVertex &v1 = *args->v1; @@ -580,6 +581,11 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th const TriVertex &v3 = *args->v3; int clipright = args->clipright; int clipbottom = args->clipbottom; + + int stencilPitch = args->stencilPitch; + uint8_t *stencilValues = args->stencilValues; + uint32_t *stencilMasks = args->stencilMasks; + uint8_t stencilTestValue = args->stencilTestValue; ScreenTriangleFullSpan *span = FullSpans; ScreenTrianglePartialBlock *partial = PartialBlocks; @@ -678,12 +684,27 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th mAxx = _mm_sub_epi32(mAxx, _mm_slli_epi32(mDY12, 7)); mBxx = _mm_sub_epi32(mBxx, _mm_slli_epi32(mDY23, 7)); mCxx = _mm_sub_epi32(mCxx, _mm_slli_epi32(mDY31, 7)); + + // Stencil test the whole block, if possible + int block = x / 8 + y / 8 * stencilPitch; + uint8_t *stencilBlock = &stencilValues[block * 64]; + uint32_t *stencilBlockMask = &stencilMasks[block]; + bool blockIsSingleStencil = ((*stencilBlockMask) & 0xffffff00) == 0xffffff00; + bool skipBlock = blockIsSingleStencil && ((*stencilBlockMask) & 0xff) != stencilTestValue; // Skip block when outside an edge - if (a == 0 || b == 0 || c == 0) continue; + if (a == 0 || b == 0 || c == 0 || skipBlock) + { + if (span->Length != 0) + { + span++; + span->Length = 0; + } + continue; + } // Accept whole block when totally covered - if (a == 0xffff && b == 0xffff && c == 0xffff && x + q <= clipright && y + q <= clipbottom) + if (a == 0xffff && b == 0xffff && c == 0xffff && x + q <= clipright && y + q <= clipbottom && blockIsSingleStencil) { if (span->Length != 0) { @@ -713,9 +734,10 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th int CX2 = CY2; int CX3 = CY3; - for (int ix = x; ix < x + q; ix++) + for (int ix = 0; ix < q; ix++) { - bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && ix < clipright && iy < clipbottom); + bool passStencilTest = blockIsSingleStencil || stencilBlock[ix + iy * q] == stencilTestValue; + bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && (x + ix) < clipright && (y + iy) < clipbottom && passStencilTest); mask0 <<= 1; mask0 |= (uint32_t)covered; @@ -735,9 +757,10 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th int CX2 = CY2; int CX3 = CY3; - for (int ix = x; ix < x + q; ix++) + for (int ix = 0; ix < q; ix++) { - bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && ix < clipright && iy < clipbottom); + bool passStencilTest = blockIsSingleStencil || stencilBlock[ix + iy * q] == stencilTestValue; + bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && (x + ix) < clipright && (y + iy) < clipbottom && passStencilTest); mask1 <<= 1; mask1 |= (uint32_t)covered; @@ -797,6 +820,11 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th int clipright = args->clipright; int clipbottom = args->clipbottom; + int stencilPitch = args->stencilPitch; + uint8_t *stencilValues = args->stencilValues; + uint32_t *stencilMasks = args->stencilMasks; + uint8_t stencilTestValue = args->stencilTestValue; + ScreenTriangleFullSpan *span = FullSpans; ScreenTrianglePartialBlock *partial = PartialBlocks; span->Length = 0; @@ -889,8 +917,15 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + // Stencil test the whole block, if possible + int block = x / 8 + y / 8 * stencilPitch; + uint8_t *stencilBlock = &stencilValues[block * 64]; + uint32_t *stencilBlockMask = &stencilMasks[block]; + bool blockIsSingleStencil = ((*stencilBlockMask) & 0xffffff00) == 0xffffff00; + bool skipBlock = blockIsSingleStencil && ((*stencilBlockMask) & 0xff) != stencilTestValue; + // Skip block when outside an edge - if (a == 0x0 || b == 0x0 || c == 0x0) + if (a == 0 || b == 0 || c == 0 || skipBlock) { if (span->Length != 0) { @@ -899,9 +934,9 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th } continue; } - + // Accept whole block when totally covered - if (a == 0xF && b == 0xF && c == 0xF && x + q <= clipright && y + q <= clipbottom) + if (a == 0xf && b == 0xf && c == 0xf && x + q <= clipright && y + q <= clipbottom && blockIsSingleStencil) { if (span->Length != 0) { @@ -916,46 +951,73 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th } else // Partially covered block { + x0 = x << 4; + x1 = (x + q - 1) << 4; int CY1 = C1 + DX12 * y0 - DY12 * x0; int CY2 = C2 + DX23 * y0 - DY23 * x0; int CY3 = C3 + DX31 * y0 - DY31 * x0; - - uint64_t mask = 0; - - for (int iy = 0; iy < q; iy++) + + uint32_t mask0 = 0; + uint32_t mask1 = 0; + + for (int iy = 0; iy < 4; iy++) { int CX1 = CY1; int CX2 = CY2; int CX3 = CY3; - - for (int ix = x; ix < x + q; ix++) + + for (int ix = 0; ix < q; ix++) { - bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && ix < clipright && iy < clipbottom); - mask <<= 1; - mask |= (uint64_t)covered; - + bool passStencilTest = blockIsSingleStencil || stencilBlock[ix + iy * q] == stencilTestValue; + bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && (x + ix) < clipright && (y + iy) < clipbottom && passStencilTest); + mask0 <<= 1; + mask0 |= (uint32_t)covered; + CX1 -= FDY12; CX2 -= FDY23; CX3 -= FDY31; } - + CY1 += FDX12; CY2 += FDX23; CY3 += FDX31; } - - if (mask != 0xffffffffffffffffLL) + + for (int iy = 4; iy < q; iy++) { - if (span->Length != 0) + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + for (int ix = 0; ix < q; ix++) + { + bool passStencilTest = blockIsSingleStencil || stencilBlock[ix + iy * q] == stencilTestValue; + bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && (x + ix) < clipright && (y + iy) < clipbottom && passStencilTest); + mask1 <<= 1; + mask1 |= (uint32_t)covered; + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + } + + if (mask0 != 0xffffffff || mask1 != 0xffffffff) + { + if (span->Length > 0) { span++; span->Length = 0; } - + partial->X = x; partial->Y = y; - partial->Mask0 = (uint32_t)(mask >> 32); - partial->Mask1 = (uint32_t)mask; + partial->Mask0 = mask0; + partial->Mask1 = mask1; partial++; } else if (span->Length != 0) From e016a96efe96849b873b68a285ae43e689fadd1b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 12 Dec 2016 12:38:46 +0100 Subject: [PATCH 1402/1509] Use less triangles for the sky --- src/r_poly_sky.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp index dafe1f7ec..e4e0a0144 100644 --- a/src/r_poly_sky.cpp +++ b/src/r_poly_sky.cpp @@ -102,7 +102,7 @@ void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int ro void PolySkyDome::CreateDome() { - mColumns = 128; + mColumns = 16;// 128; mRows = 4; CreateSkyHemisphere(false); CreateSkyHemisphere(true); From 79ad5d2a2a189a2bce65b29dd15dc675abd5111c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 12 Dec 2016 12:39:25 +0100 Subject: [PATCH 1403/1509] Write out subsector info --- src/r_drawers.h | 2 + src/r_poly_triangle.cpp | 285 +++++----------------------------------- 2 files changed, 34 insertions(+), 253 deletions(-) diff --git a/src/r_drawers.h b/src/r_drawers.h index ebe5d9002..2e91d502b 100644 --- a/src/r_drawers.h +++ b/src/r_drawers.h @@ -26,6 +26,7 @@ #include class FString; +class DrawerThread; struct WorkerThreadData { @@ -34,6 +35,7 @@ struct WorkerThreadData int32_t pass_start_y; int32_t pass_end_y; uint32_t *temp; + DrawerThread *drawer_thread; }; struct DrawWallArgs diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index be1d5ea75..37c61655f 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -35,7 +35,6 @@ #include "v_palette.h" #include "r_data/colormaps.h" #include "r_poly_triangle.h" -#include int PolyTriangleDrawer::viewport_x; int PolyTriangleDrawer::viewport_y; @@ -93,7 +92,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian switch (variant) { default: - //case TriDrawVariant::DrawNormal: drawfunc = &ScreenTriangle::DrawFunc; break; + //case TriDrawVariant::DrawNormal: drawfunc = dest_bgra ? &ScreenTriangle::DrawFunc : llvm->TriDrawNormal8[bmode]; break; case TriDrawVariant::DrawNormal: drawfunc = dest_bgra ? llvm->TriDrawNormal32[bmode] : llvm->TriDrawNormal8[bmode]; break; case TriDrawVariant::FillNormal: drawfunc = dest_bgra ? llvm->TriFillNormal32[bmode] : llvm->TriFillNormal8[bmode]; break; case TriDrawVariant::DrawSubsector: drawfunc = dest_bgra ? llvm->TriDrawSubsector32[bmode] : llvm->TriDrawSubsector8[bmode]; break; @@ -573,7 +572,7 @@ void PolyVertexBuffer::Clear() } ///////////////////////////////////////////////////////////////////////////// -#if 0 + void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { const TriVertex &v1 = *args->v1; @@ -586,283 +585,48 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th uint8_t *stencilValues = args->stencilValues; uint32_t *stencilMasks = args->stencilMasks; uint8_t stencilTestValue = args->stencilTestValue; - + ScreenTriangleFullSpan *span = FullSpans; ScreenTrianglePartialBlock *partial = PartialBlocks; - span->Length = 0; - + // 28.4 fixed-point coordinates const int Y1 = (int)round(16.0f * v1.y); const int Y2 = (int)round(16.0f * v2.y); const int Y3 = (int)round(16.0f * v3.y); - + const int X1 = (int)round(16.0f * v1.x); const int X2 = (int)round(16.0f * v2.x); const int X3 = (int)round(16.0f * v3.x); - + // Deltas const int DX12 = X1 - X2; const int DX23 = X2 - X3; const int DX31 = X3 - X1; - + const int DY12 = Y1 - Y2; const int DY23 = Y2 - Y3; const int DY31 = Y3 - Y1; - + // Fixed-point deltas const int FDX12 = DX12 << 4; const int FDX23 = DX23 << 4; const int FDX31 = DX31 << 4; - + const int FDY12 = DY12 << 4; const int FDY23 = DY23 << 4; const int FDY31 = DY31 << 4; - + // Bounding rectangle int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, 0); int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, 0); int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); if (minx >= maxx || miny >= maxy) - return; - - // Block size, standard 8x8 (must be power of two) - const int q = 8; - - // Start in corner of 8x8 block - minx &= ~(q - 1); - miny &= ~(q - 1); - - // Half-edge constants - int C1 = DY12 * X1 - DX12 * Y1; - int C2 = DY23 * X2 - DX23 * Y2; - int C3 = DY31 * X3 - DX31 * Y3; - - // Correct for fill convention - if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; - if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; - if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; - - // First block line for this thread - int core = thread->core; - int num_cores = thread->num_cores; - int core_skip = (num_cores - ((miny / q) - core) % num_cores) % num_cores; - miny += core_skip * q; - - __m128i mC1 = _mm_set1_epi32(C1); - __m128i mC2 = _mm_set1_epi32(C2); - __m128i mC3 = _mm_set1_epi32(C3); - __m128i mDX12 = _mm_set1_epi32(DX12); - __m128i mDX23 = _mm_set1_epi32(DX23); - __m128i mDX31 = _mm_set1_epi32(DX31); - __m128i mDY12 = _mm_set1_epi32(DY12); - __m128i mDY23 = _mm_set1_epi32(DY23); - __m128i mDY31 = _mm_set1_epi32(DY31); - - // Loop through blocks - for (int y = miny; y < maxy; y += q * num_cores) { - // Corners of block - int x0 = minx << 4; - int x1 = (minx + q - 1) << 4; - int y0 = y << 4; - int y1 = (y + q - 1) << 4; - - __m128i my0y1 = _mm_set_epi32(y0, y0, y1, y1); - __m128i mx0x1 = _mm_set_epi32(x0, x1, x0, x1); - __m128i mAxx = _mm_add_epi32(mC1, _mm_sub_epi32(_mm_mullo_epi32(mDX12, my0y1), _mm_mullo_epi32(mDY12, mx0x1))); - __m128i mBxx = _mm_add_epi32(mC2, _mm_sub_epi32(_mm_mullo_epi32(mDX23, my0y1), _mm_mullo_epi32(mDY23, mx0x1))); - __m128i mCxx = _mm_add_epi32(mC3, _mm_sub_epi32(_mm_mullo_epi32(mDX31, my0y1), _mm_mullo_epi32(mDY31, mx0x1))); - - for (int x = minx; x < maxx; x += q) - { - // Evaluate half-space functions - int a = _mm_movemask_epi8(_mm_cmpgt_epi32(mAxx, _mm_setzero_si128())); - int b = _mm_movemask_epi8(_mm_cmpgt_epi32(mBxx, _mm_setzero_si128())); - int c = _mm_movemask_epi8(_mm_cmpgt_epi32(mCxx, _mm_setzero_si128())); - - mAxx = _mm_sub_epi32(mAxx, _mm_slli_epi32(mDY12, 7)); - mBxx = _mm_sub_epi32(mBxx, _mm_slli_epi32(mDY23, 7)); - mCxx = _mm_sub_epi32(mCxx, _mm_slli_epi32(mDY31, 7)); - - // Stencil test the whole block, if possible - int block = x / 8 + y / 8 * stencilPitch; - uint8_t *stencilBlock = &stencilValues[block * 64]; - uint32_t *stencilBlockMask = &stencilMasks[block]; - bool blockIsSingleStencil = ((*stencilBlockMask) & 0xffffff00) == 0xffffff00; - bool skipBlock = blockIsSingleStencil && ((*stencilBlockMask) & 0xff) != stencilTestValue; - - // Skip block when outside an edge - if (a == 0 || b == 0 || c == 0 || skipBlock) - { - if (span->Length != 0) - { - span++; - span->Length = 0; - } - continue; - } - - // Accept whole block when totally covered - if (a == 0xffff && b == 0xffff && c == 0xffff && x + q <= clipright && y + q <= clipbottom && blockIsSingleStencil) - { - if (span->Length != 0) - { - span->Length++; - } - else - { - span->X = x; - span->Y = y; - span->Length = 1; - } - } - else // Partially covered block - { - x0 = x << 4; - x1 = (x + q - 1) << 4; - int CY1 = C1 + DX12 * y0 - DY12 * x0; - int CY2 = C2 + DX23 * y0 - DY23 * x0; - int CY3 = C3 + DX31 * y0 - DY31 * x0; - - uint32_t mask0 = 0; - uint32_t mask1 = 0; - - for (int iy = 0; iy < 4; iy++) - { - int CX1 = CY1; - int CX2 = CY2; - int CX3 = CY3; - - for (int ix = 0; ix < q; ix++) - { - bool passStencilTest = blockIsSingleStencil || stencilBlock[ix + iy * q] == stencilTestValue; - bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && (x + ix) < clipright && (y + iy) < clipbottom && passStencilTest); - mask0 <<= 1; - mask0 |= (uint32_t)covered; - - CX1 -= FDY12; - CX2 -= FDY23; - CX3 -= FDY31; - } - - CY1 += FDX12; - CY2 += FDX23; - CY3 += FDX31; - } - - for (int iy = 4; iy < q; iy++) - { - int CX1 = CY1; - int CX2 = CY2; - int CX3 = CY3; - - for (int ix = 0; ix < q; ix++) - { - bool passStencilTest = blockIsSingleStencil || stencilBlock[ix + iy * q] == stencilTestValue; - bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && (x + ix) < clipright && (y + iy) < clipbottom && passStencilTest); - mask1 <<= 1; - mask1 |= (uint32_t)covered; - - CX1 -= FDY12; - CX2 -= FDY23; - CX3 -= FDY31; - } - - CY1 += FDX12; - CY2 += FDX23; - CY3 += FDX31; - } - - if (mask0 != 0xffffffff || mask1 != 0xffffffff) - { - if (span->Length > 0) - { - span++; - span->Length = 0; - } - - partial->X = x; - partial->Y = y; - partial->Mask0 = mask0; - partial->Mask1 = mask1; - partial++; - } - else if (span->Length != 0) - { - span->Length++; - } - else - { - span->X = x; - span->Y = y; - span->Length = 1; - } - } - } - - if (span->Length > 0) - { - span++; - span->Length = 0; - } - } - - NumFullSpans = (int)(span - FullSpans); - NumPartialBlocks = (int)(partial - PartialBlocks); -} -#else -void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *thread) -{ - const TriVertex &v1 = *args->v1; - const TriVertex &v2 = *args->v2; - const TriVertex &v3 = *args->v3; - int clipright = args->clipright; - int clipbottom = args->clipbottom; - - int stencilPitch = args->stencilPitch; - uint8_t *stencilValues = args->stencilValues; - uint32_t *stencilMasks = args->stencilMasks; - uint8_t stencilTestValue = args->stencilTestValue; - - ScreenTriangleFullSpan *span = FullSpans; - ScreenTrianglePartialBlock *partial = PartialBlocks; - span->Length = 0; - - // 28.4 fixed-point coordinates - const int Y1 = (int)round(16.0f * v1.y); - const int Y2 = (int)round(16.0f * v2.y); - const int Y3 = (int)round(16.0f * v3.y); - - const int X1 = (int)round(16.0f * v1.x); - const int X2 = (int)round(16.0f * v2.x); - const int X3 = (int)round(16.0f * v3.x); - - // Deltas - const int DX12 = X1 - X2; - const int DX23 = X2 - X3; - const int DX31 = X3 - X1; - - const int DY12 = Y1 - Y2; - const int DY23 = Y2 - Y3; - const int DY31 = Y3 - Y1; - - // Fixed-point deltas - const int FDX12 = DX12 << 4; - const int FDX23 = DX23 << 4; - const int FDX31 = DX31 << 4; - - const int FDY12 = DY12 << 4; - const int FDY23 = DY23 << 4; - const int FDY31 = DY31 << 4; - - // Bounding rectangle - int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, 0); - int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); - int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, 0); - int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); - if (minx >= maxx || miny >= maxy) + NumFullSpans = 0; + NumPartialBlocks = 0; return; + } // Block size, standard 8x8 (must be power of two) const int q = 8; @@ -886,7 +650,9 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th int num_cores = thread->num_cores; int core_skip = (num_cores - ((miny / q) - core) % num_cores) % num_cores; miny += core_skip * q; - + + span->Length = 0; + // Loop through blocks for (int y = miny; y < maxy; y += q * num_cores) { @@ -1043,7 +809,6 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th NumFullSpans = (int)(span - FullSpans); NumPartialBlocks = (int)(partial - PartialBlocks); } -#endif void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) { @@ -1059,11 +824,14 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) uint32_t blue = (uint32_t)b; uint32_t solidcolor = 0xff000000 | (red << 16) | (green << 8) | blue; + uint32_t subsectorDepth = args->uniforms->subsectorDepth; + for (int i = 0; i < NumFullSpans; i++) { const auto &span = FullSpans[i]; uint32_t *dest = (uint32_t*)args->dest + span.X + span.Y * args->pitch; + uint32_t *subsector = args->subsectorGBuffer + span.X + span.Y * args->pitch; int pitch = args->pitch; int width = span.Length * 8; int height = 8; @@ -1072,9 +840,11 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) for (int x = 0; x < width; x++) { dest[x] = solidcolor; + subsector[x] = subsectorDepth; } dest += pitch; + subsector += pitch; } } @@ -1083,6 +853,7 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) const auto &block = PartialBlocks[i]; uint32_t *dest = (uint32_t*)args->dest + block.X + block.Y * args->pitch; + uint32_t *subsector = args->subsectorGBuffer + block.X + block.Y * args->pitch; int pitch = args->pitch; uint32_t mask0 = block.Mask0; uint32_t mask1 = block.Mask1; @@ -1090,21 +861,29 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) { for (int x = 0; x < 8; x++) { - if (mask0 & (1<<31)) + if (mask0 & (1 << 31)) + { dest[x] = solidcolor; + subsector[x] = subsectorDepth; + } mask0 <<= 1; } dest += pitch; + subsector += pitch; } for (int y = 4; y < 8; y++) { for (int x = 0; x < 8; x++) { - if (mask1 & (1<<31)) + if (mask1 & (1 << 31)) + { dest[x] = solidcolor; + subsector[x] = subsectorDepth; + } mask1 <<= 1; } dest += pitch; + subsector += pitch; } } } From afb946d58635d33a643db84f7bdea869403d093d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 12 Dec 2016 21:34:22 +0100 Subject: [PATCH 1404/1509] Added texturing --- src/r_poly_triangle.cpp | 178 ++++++++++++++++++++++++++++++++++++---- src/r_poly_triangle.h | 8 +- 2 files changed, 165 insertions(+), 21 deletions(-) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 37c61655f..254fc2ef9 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -198,6 +198,19 @@ void PolyTriangleDrawer::draw_shaded_triangle(const ShadedTriVertex *vert, bool v.y = viewport_y + viewport_height * (1.0f - v.y) * 0.5f; } + // Keep varyings in -128 to 128 range if possible + if (numclipvert > 0) + { + for (int j = 0; j < TriVertex::NumVarying; j++) + { + float newOrigin = floorf(clippedvert[0].varying[j] * 0.1f) * 10.0f; + for (int i = 0; i < numclipvert; i++) + { + clippedvert[i].varying[j] -= newOrigin; + } + } + } + // Draw screen triangles if (ccw) { @@ -651,6 +664,8 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th int core_skip = (num_cores - ((miny / q) - core) % num_cores) % num_cores; miny += core_skip * q; + StartX = minx; + StartY = miny; span->Length = 0; // Loop through blocks @@ -810,39 +825,101 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th NumPartialBlocks = (int)(partial - PartialBlocks); } +float ScreenTriangle::FindGradientX(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) +{ + float top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); + float bottom = (x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2); + return top / bottom; +} + +float ScreenTriangle::FindGradientY(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) +{ + float top = (c1 - c2) * (x0 - x2) - (c0 - c2) * (x1 - x2); + float bottom = (x0 - x2) * (y1 - y2) - (x1 - x2) * (y0 - y2); + return top / bottom; +} + void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) { - float r = args->v1->x / 255.0f; - float g = args->v1->y / 255.0f; - float b = args->v1->z / 255.0f; - r = (r - floor(r)) * 255; - g = (g - floor(g)) * 255; - b = (b - floor(b)) * 255; + // Calculate gradients + const TriVertex &v1 = *args->v1; + const TriVertex &v2 = *args->v2; + const TriVertex &v3 = *args->v3; + ScreenTriangleStepVariables gradientX; + ScreenTriangleStepVariables gradientY; + ScreenTriangleStepVariables start; + gradientX.W = FindGradientX(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + gradientY.W = FindGradientY(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + start.W = v1.w + gradientX.W * (StartX - v1.x) + gradientY.W * (StartY - v1.y); + for (int i = 0; i < TriVertex::NumVarying; i++) + { + gradientX.Varying[i] = FindGradientX(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + gradientY.Varying[i] = FindGradientY(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + start.Varying[i] = v1.varying[i] * v1.w + gradientX.Varying[i] * (StartX - v1.x) + gradientY.Varying[i] * (StartY - v1.y); + } - uint32_t red = (uint32_t)r; - uint32_t green = (uint32_t)g; - uint32_t blue = (uint32_t)b; - uint32_t solidcolor = 0xff000000 | (red << 16) | (green << 8) | blue; + const uint32_t *texPixels = (const uint32_t *)args->texturePixels; + uint32_t texWidth = args->textureWidth; + uint32_t texHeight = args->textureHeight; uint32_t subsectorDepth = args->uniforms->subsectorDepth; for (int i = 0; i < NumFullSpans; i++) { const auto &span = FullSpans[i]; - + uint32_t *dest = (uint32_t*)args->dest + span.X + span.Y * args->pitch; uint32_t *subsector = args->subsectorGBuffer + span.X + span.Y * args->pitch; int pitch = args->pitch; - int width = span.Length * 8; + int width = span.Length; int height = 8; + + ScreenTriangleStepVariables blockPosY; + blockPosY.W = start.W + gradientX.W * (span.X - StartX) + gradientY.W * (span.Y - StartY); + for (int j = 0; j < TriVertex::NumVarying; j++) + blockPosY.Varying[j] = start.Varying[j] + gradientX.Varying[j] * (span.X - StartX) + gradientY.Varying[j] * (span.Y - StartY); + for (int y = 0; y < height; y++) { + ScreenTriangleStepVariables blockPosX = blockPosY; + + float rcpW = 0x01000000 / blockPosX.W; + int32_t varyingPos[TriVertex::NumVarying]; + for (int j = 0; j < TriVertex::NumVarying; j++) + varyingPos[j] = (int32_t)(blockPosX.Varying[j] * rcpW); + for (int x = 0; x < width; x++) { - dest[x] = solidcolor; - subsector[x] = subsectorDepth; + blockPosX.W += gradientX.W * 8; + for (int j = 0; j < TriVertex::NumVarying; j++) + blockPosX.Varying[j] += gradientX.Varying[j] * 8; + + rcpW = 0x01000000 / blockPosX.W; + int32_t varyingStep[TriVertex::NumVarying]; + for (int j = 0; j < TriVertex::NumVarying; j++) + { + int32_t nextPos = (int32_t)(blockPosX.Varying[j] * rcpW); + varyingStep[j] = (nextPos - varyingPos[j]) / 8; + } + + for (int ix = 0; ix < 8; ix++) + { + int texelX = ((((uint32_t)varyingPos[0] << 8) >> 16) * texWidth) >> 16; + int texelY = ((((uint32_t)varyingPos[1] << 8) >> 16) * texHeight) >> 16; + uint32_t fg = texPixels[texelX * texHeight + texelY]; + + dest[x * 8 + ix] = fg; + subsector[x * 8 + ix] = subsectorDepth; + + for (int j = 0; j < TriVertex::NumVarying; j++) + varyingPos[j] += varyingStep[j]; + } } + blockPosY.W += gradientY.W; + for (int j = 0; j < TriVertex::NumVarying; j++) + blockPosY.Varying[j] += gradientY.Varying[j]; + dest += pitch; subsector += pitch; } @@ -851,7 +928,12 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) for (int i = 0; i < NumPartialBlocks; i++) { const auto &block = PartialBlocks[i]; - + + ScreenTriangleStepVariables blockPosY; + blockPosY.W = start.W + gradientX.W * (block.X - StartX) + gradientY.W * (block.Y - StartY); + for (int j = 0; j < TriVertex::NumVarying; j++) + blockPosY.Varying[j] = start.Varying[j] + gradientX.Varying[j] * (block.X - StartX) + gradientY.Varying[j] * (block.Y - StartY); + uint32_t *dest = (uint32_t*)args->dest + block.X + block.Y * args->pitch; uint32_t *subsector = args->subsectorGBuffer + block.X + block.Y * args->pitch; int pitch = args->pitch; @@ -859,29 +941,91 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) uint32_t mask1 = block.Mask1; for (int y = 0; y < 4; y++) { + ScreenTriangleStepVariables blockPosX = blockPosY; + + float rcpW = 0x01000000 / blockPosX.W; + int32_t varyingPos[TriVertex::NumVarying]; + for (int j = 0; j < TriVertex::NumVarying; j++) + varyingPos[j] = (int32_t)(blockPosX.Varying[j] * rcpW); + + blockPosX.W += gradientX.W * 8; + for (int j = 0; j < TriVertex::NumVarying; j++) + blockPosX.Varying[j] += gradientX.Varying[j] * 8; + + rcpW = 0x01000000 / blockPosX.W; + int32_t varyingStep[TriVertex::NumVarying]; + for (int j = 0; j < TriVertex::NumVarying; j++) + { + int32_t nextPos = (int32_t)(blockPosX.Varying[j] * rcpW); + varyingStep[j] = (nextPos - varyingPos[j]) / 8; + } + for (int x = 0; x < 8; x++) { if (mask0 & (1 << 31)) { - dest[x] = solidcolor; + int texelX = ((((uint32_t)varyingPos[0] << 8) >> 16) * texWidth) >> 16; + int texelY = ((((uint32_t)varyingPos[1] << 8) >> 16) * texHeight) >> 16; + uint32_t fg = texPixels[texelX * texHeight + texelY]; + + dest[x] = fg; subsector[x] = subsectorDepth; } mask0 <<= 1; + + for (int j = 0; j < TriVertex::NumVarying; j++) + varyingPos[j] += varyingStep[j]; } + + blockPosY.W += gradientY.W; + for (int j = 0; j < TriVertex::NumVarying; j++) + blockPosY.Varying[j] += gradientY.Varying[j]; + dest += pitch; subsector += pitch; } for (int y = 4; y < 8; y++) { + ScreenTriangleStepVariables blockPosX = blockPosY; + + float rcpW = 0x01000000 / blockPosX.W; + int32_t varyingPos[TriVertex::NumVarying]; + for (int j = 0; j < TriVertex::NumVarying; j++) + varyingPos[j] = (int32_t)(blockPosX.Varying[j] * rcpW); + + blockPosX.W += gradientX.W * 8; + for (int j = 0; j < TriVertex::NumVarying; j++) + blockPosX.Varying[j] += gradientX.Varying[j] * 8; + + rcpW = 0x01000000 / blockPosX.W; + int32_t varyingStep[TriVertex::NumVarying]; + for (int j = 0; j < TriVertex::NumVarying; j++) + { + int32_t nextPos = (int32_t)(blockPosX.Varying[j] * rcpW); + varyingStep[j] = (nextPos - varyingPos[j]) / 8; + } + for (int x = 0; x < 8; x++) { if (mask1 & (1 << 31)) { - dest[x] = solidcolor; + int texelX = ((((uint32_t)varyingPos[0] << 8) >> 16) * texWidth) >> 16; + int texelY = ((((uint32_t)varyingPos[1] << 8) >> 16) * texHeight) >> 16; + uint32_t fg = texPixels[texelX * texHeight + texelY]; + + dest[x] = fg; subsector[x] = subsectorDepth; } mask1 <<= 1; + + for (int j = 0; j < TriVertex::NumVarying; j++) + varyingPos[j] += varyingStep[j]; } + + blockPosY.W += gradientY.W; + for (int j = 0; j < TriVertex::NumVarying; j++) + blockPosY.Varying[j] += gradientY.Varying[j]; + dest += pitch; subsector += pitch; } diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 28c903c0c..e014752ce 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -265,7 +265,7 @@ public: static void Clear(); }; -struct ScreenTriangleBlock +struct ScreenTriangleStepVariables { float W; float Varying[TriVertex::NumVarying]; @@ -302,11 +302,11 @@ public: int NumPartialBlocks; int StartX; int StartY; - ScreenTriangleBlock Start; - ScreenTriangleBlock GradientX; - ScreenTriangleBlock GradientY; private: + float FindGradientX(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); + float FindGradientY(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); + std::vector FullSpansBuffer; std::vector PartialBlocksBuffer; }; From 5277d4ae28b2d20b8ab133efd2abb92a3f1e12aa Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 12 Dec 2016 22:42:42 +0100 Subject: [PATCH 1405/1509] Diminishing light test --- src/r_poly_triangle.cpp | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 254fc2ef9..69b37a5b7 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -864,6 +864,10 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) uint32_t subsectorDepth = args->uniforms->subsectorDepth; + uint32_t light = args->uniforms->light; + float shade = (64.0f - (light * 255 / 256 + 12.0f) * 32.0f / 128.0f) / 32.0f; + float globVis = 1706.0f; + for (int i = 0; i < NumFullSpans; i++) { const auto &span = FullSpans[i]; @@ -890,6 +894,8 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) for (int x = 0; x < width; x++) { + int lightpos = 256 - (int)(clamp(shade - MIN(24.0f, globVis * blockPosX.W) / 32.0f, 0.0f, 31.0f / 32.0f) * 256.0f); + blockPosX.W += gradientX.W * 8; for (int j = 0; j < TriVertex::NumVarying; j++) blockPosX.Varying[j] += gradientX.Varying[j] * 8; @@ -902,17 +908,29 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) varyingStep[j] = (nextPos - varyingPos[j]) / 8; } + int lightnext = 256 - (int)(clamp(shade - MIN(24.0f, globVis * blockPosX.W) / 32.0f, 0.0f, 31.0f / 32.0f) * 256.0f); + int lightstep = (lightnext - lightpos) / 8; + for (int ix = 0; ix < 8; ix++) { int texelX = ((((uint32_t)varyingPos[0] << 8) >> 16) * texWidth) >> 16; int texelY = ((((uint32_t)varyingPos[1] << 8) >> 16) * texHeight) >> 16; uint32_t fg = texPixels[texelX * texHeight + texelY]; + uint32_t r = RPART(fg); + uint32_t g = GPART(fg); + uint32_t b = BPART(fg); + r = r * lightpos / 256; + g = g * lightpos / 256; + b = b * lightpos / 256; + fg = 0xff000000 | (r << 16) | (g << 8) | b; + dest[x * 8 + ix] = fg; subsector[x * 8 + ix] = subsectorDepth; for (int j = 0; j < TriVertex::NumVarying; j++) varyingPos[j] += varyingStep[j]; + lightpos += lightstep; } } @@ -948,6 +966,8 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) for (int j = 0; j < TriVertex::NumVarying; j++) varyingPos[j] = (int32_t)(blockPosX.Varying[j] * rcpW); + int lightpos = 256 - (int)(clamp(shade - MIN(24.0f, globVis * blockPosX.W) / 32.0f, 0.0f, 31.0f / 32.0f) * 256.0f); + blockPosX.W += gradientX.W * 8; for (int j = 0; j < TriVertex::NumVarying; j++) blockPosX.Varying[j] += gradientX.Varying[j] * 8; @@ -960,6 +980,9 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) varyingStep[j] = (nextPos - varyingPos[j]) / 8; } + int lightnext = 256 - (int)(clamp(shade - MIN(24.0f, globVis * blockPosX.W) / 32.0f, 0.0f, 31.0f / 32.0f) * 256.0f); + int lightstep = (lightnext - lightpos) / 8; + for (int x = 0; x < 8; x++) { if (mask0 & (1 << 31)) @@ -968,6 +991,14 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) int texelY = ((((uint32_t)varyingPos[1] << 8) >> 16) * texHeight) >> 16; uint32_t fg = texPixels[texelX * texHeight + texelY]; + uint32_t r = RPART(fg); + uint32_t g = GPART(fg); + uint32_t b = BPART(fg); + r = r * lightpos / 256; + g = g * lightpos / 256; + b = b * lightpos / 256; + fg = 0xff000000 | (r << 16) | (g << 8) | b; + dest[x] = fg; subsector[x] = subsectorDepth; } @@ -975,6 +1006,7 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) for (int j = 0; j < TriVertex::NumVarying; j++) varyingPos[j] += varyingStep[j]; + lightpos += lightstep; } blockPosY.W += gradientY.W; @@ -993,6 +1025,8 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) for (int j = 0; j < TriVertex::NumVarying; j++) varyingPos[j] = (int32_t)(blockPosX.Varying[j] * rcpW); + int lightpos = 256 - (int)(clamp(shade - MIN(24.0f, globVis * blockPosX.W) / 32.0f, 0.0f, 31.0f / 32.0f) * 256.0f); + blockPosX.W += gradientX.W * 8; for (int j = 0; j < TriVertex::NumVarying; j++) blockPosX.Varying[j] += gradientX.Varying[j] * 8; @@ -1005,6 +1039,9 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) varyingStep[j] = (nextPos - varyingPos[j]) / 8; } + int lightnext = 256 - (int)(clamp(shade - MIN(24.0f, globVis * blockPosX.W) / 32.0f, 0.0f, 31.0f / 32.0f) * 256.0f); + int lightstep = (lightnext - lightpos) / 8; + for (int x = 0; x < 8; x++) { if (mask1 & (1 << 31)) @@ -1013,6 +1050,14 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) int texelY = ((((uint32_t)varyingPos[1] << 8) >> 16) * texHeight) >> 16; uint32_t fg = texPixels[texelX * texHeight + texelY]; + uint32_t r = RPART(fg); + uint32_t g = GPART(fg); + uint32_t b = BPART(fg); + r = r * lightpos / 256; + g = g * lightpos / 256; + b = b * lightpos / 256; + fg = 0xff000000 | (r << 16) | (g << 8) | b; + dest[x] = fg; subsector[x] = subsectorDepth; } @@ -1020,6 +1065,7 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) for (int j = 0; j < TriVertex::NumVarying; j++) varyingPos[j] += varyingStep[j]; + lightpos += lightstep; } blockPosY.W += gradientY.W; From 022368d349c7249d76eea17f5226b0e4c614ea75 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 13 Dec 2016 00:55:29 +0100 Subject: [PATCH 1406/1509] Stencil write --- src/r_poly_triangle.cpp | 76 +++++++++++++++++++++++++++++++++++++++-- src/r_poly_triangle.h | 2 ++ 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 69b37a5b7..a3a48445a 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -93,6 +93,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian { default: //case TriDrawVariant::DrawNormal: drawfunc = dest_bgra ? &ScreenTriangle::DrawFunc : llvm->TriDrawNormal8[bmode]; break; + //case TriDrawVariant::Stencil: drawfunc = &ScreenTriangle::StencilFunc; break; case TriDrawVariant::DrawNormal: drawfunc = dest_bgra ? llvm->TriDrawNormal32[bmode] : llvm->TriDrawNormal8[bmode]; break; case TriDrawVariant::FillNormal: drawfunc = dest_bgra ? llvm->TriFillNormal32[bmode] : llvm->TriFillNormal8[bmode]; break; case TriDrawVariant::DrawSubsector: drawfunc = dest_bgra ? llvm->TriDrawSubsector32[bmode] : llvm->TriDrawSubsector8[bmode]; break; @@ -825,6 +826,71 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th NumPartialBlocks = (int)(partial - PartialBlocks); } +void ScreenTriangle::StencilWrite(const TriDrawTriangleArgs *args) +{ + uint8_t *stencilValues = args->stencilValues; + uint32_t *stencilMasks = args->stencilMasks; + uint32_t stencilWriteValue = args->stencilWriteValue; + uint32_t stencilPitch = args->stencilPitch; + + for (int i = 0; i < NumFullSpans; i++) + { + const auto &span = FullSpans[i]; + + int block = span.X / 8 + span.Y / 8 * stencilPitch; + uint8_t *stencilBlock = &stencilValues[block * 64]; + uint32_t *stencilBlockMask = &stencilMasks[block]; + + int width = span.Length; + for (int x = 0; x < width; x++) + stencilBlockMask[x] = 0xffffff00 | stencilWriteValue; + } + + for (int i = 0; i < NumPartialBlocks; i++) + { + const auto &block = PartialBlocks[i]; + + uint32_t mask0 = block.Mask0; + uint32_t mask1 = block.Mask1; + + int sblock = block.X / 8 + block.Y / 8 * stencilPitch; + uint8_t *stencilBlock = &stencilValues[sblock * 64]; + uint32_t *stencilBlockMask = &stencilMasks[sblock]; + + bool isSingleValue = ((*stencilBlockMask) & 0xffffff00) == 0xffffff00; + if (isSingleValue) + { + uint8_t value = (*stencilBlockMask) & 0xff; + for (int v = 0; v < 64; v++) + stencilBlock[v] = value; + *stencilBlockMask = 0; + } + + int count = 0; + for (int v = 0; v < 32; v++) + { + if ((mask0 & (1 << 31)) || stencilBlock[v] == stencilWriteValue) + { + stencilBlock[v] = stencilWriteValue; + count++; + } + mask0 <<= 1; + } + for (int v = 32; v < 64; v++) + { + if ((mask1 & (1 << 31)) || stencilBlock[v] == stencilWriteValue) + { + stencilBlock[v] = stencilWriteValue; + count++; + } + mask1 <<= 1; + } + + if (count == 64) + *stencilBlockMask = 0xffffff00 | stencilWriteValue; + } +} + float ScreenTriangle::FindGradientX(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) { float top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); @@ -1078,14 +1144,20 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) } } +static ScreenTriangle triangle[8]; + void ScreenTriangle::DrawFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { - static ScreenTriangle triangle[8]; - triangle[thread->core].Setup(args, thread); triangle[thread->core].Draw(args); } +void ScreenTriangle::StencilFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) +{ + triangle[thread->core].Setup(args, thread); + triangle[thread->core].StencilWrite(args); +} + ScreenTriangle::ScreenTriangle() { FullSpansBuffer.resize(MAXWIDTH / 8 * (MAXHEIGHT / 8)); diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index e014752ce..6e0508fbb 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -290,11 +290,13 @@ class ScreenTriangle { public: static void DrawFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); + static void StencilFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); ScreenTriangle(); void Setup(const TriDrawTriangleArgs *args, WorkerThreadData *thread); void Draw(const TriDrawTriangleArgs *args); + void StencilWrite(const TriDrawTriangleArgs *args); ScreenTriangleFullSpan *FullSpans; ScreenTrianglePartialBlock *PartialBlocks; From c1e2c25907bb9b36de55b6d940a6728f221ef616 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 13 Dec 2016 02:13:48 +0100 Subject: [PATCH 1407/1509] Stencil close --- src/r_poly_triangle.cpp | 59 +++++++++++++++++++++++++++++++++++++++++ src/r_poly_triangle.h | 2 ++ 2 files changed, 61 insertions(+) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index a3a48445a..3e334b617 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -94,6 +94,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian default: //case TriDrawVariant::DrawNormal: drawfunc = dest_bgra ? &ScreenTriangle::DrawFunc : llvm->TriDrawNormal8[bmode]; break; //case TriDrawVariant::Stencil: drawfunc = &ScreenTriangle::StencilFunc; break; + //case TriDrawVariant::StencilClose: drawfunc = &ScreenTriangle::StencilCloseFunc; break; case TriDrawVariant::DrawNormal: drawfunc = dest_bgra ? llvm->TriDrawNormal32[bmode] : llvm->TriDrawNormal8[bmode]; break; case TriDrawVariant::FillNormal: drawfunc = dest_bgra ? llvm->TriFillNormal32[bmode] : llvm->TriFillNormal8[bmode]; break; case TriDrawVariant::DrawSubsector: drawfunc = dest_bgra ? llvm->TriDrawSubsector32[bmode] : llvm->TriDrawSubsector8[bmode]; break; @@ -891,6 +892,57 @@ void ScreenTriangle::StencilWrite(const TriDrawTriangleArgs *args) } } +void ScreenTriangle::SubsectorWrite(const TriDrawTriangleArgs *args) +{ + uint32_t subsectorDepth = args->uniforms->subsectorDepth; + + for (int i = 0; i < NumFullSpans; i++) + { + const auto &span = FullSpans[i]; + + uint32_t *subsector = args->subsectorGBuffer + span.X + span.Y * args->pitch; + int pitch = args->pitch; + int width = span.Length * 8; + int height = 8; + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + subsector[x] = subsectorDepth; + subsector += pitch; + } + } + + for (int i = 0; i < NumPartialBlocks; i++) + { + const auto &block = PartialBlocks[i]; + + uint32_t *subsector = args->subsectorGBuffer + block.X + block.Y * args->pitch; + int pitch = args->pitch; + uint32_t mask0 = block.Mask0; + uint32_t mask1 = block.Mask1; + for (int y = 0; y < 4; y++) + { + for (int x = 0; x < 8; x++) + { + if (mask0 & (1 << 31)) + subsector[x] = subsectorDepth; + mask0 <<= 1; + } + subsector += pitch; + } + for (int y = 4; y < 8; y++) + { + for (int x = 0; x < 8; x++) + { + if (mask1 & (1 << 31)) + subsector[x] = subsectorDepth; + mask1 <<= 1; + } + subsector += pitch; + } + } +} + float ScreenTriangle::FindGradientX(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) { float top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); @@ -1158,6 +1210,13 @@ void ScreenTriangle::StencilFunc(const TriDrawTriangleArgs *args, WorkerThreadDa triangle[thread->core].StencilWrite(args); } +void ScreenTriangle::StencilCloseFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) +{ + triangle[thread->core].Setup(args, thread); + triangle[thread->core].StencilWrite(args); + triangle[thread->core].SubsectorWrite(args); +} + ScreenTriangle::ScreenTriangle() { FullSpansBuffer.resize(MAXWIDTH / 8 * (MAXHEIGHT / 8)); diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 6e0508fbb..12591425a 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -291,12 +291,14 @@ class ScreenTriangle public: static void DrawFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); static void StencilFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); + static void StencilCloseFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); ScreenTriangle(); void Setup(const TriDrawTriangleArgs *args, WorkerThreadData *thread); void Draw(const TriDrawTriangleArgs *args); void StencilWrite(const TriDrawTriangleArgs *args); + void SubsectorWrite(const TriDrawTriangleArgs *args); ScreenTriangleFullSpan *FullSpans; ScreenTrianglePartialBlock *PartialBlocks; From be357e1c98bed3efb85a6b20569cd2fea74cab68 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 13 Dec 2016 12:57:04 +0100 Subject: [PATCH 1408/1509] Triangle setup function for subsector based drawing --- src/r_poly_triangle.cpp | 306 +++++++++++++++++++++++++++++++++++++++- src/r_poly_triangle.h | 4 +- 2 files changed, 304 insertions(+), 6 deletions(-) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 3e334b617..30876768b 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -92,7 +92,8 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian switch (variant) { default: - //case TriDrawVariant::DrawNormal: drawfunc = dest_bgra ? &ScreenTriangle::DrawFunc : llvm->TriDrawNormal8[bmode]; break; + //case TriDrawVariant::DrawNormal: drawfunc = dest_bgra ? &ScreenTriangle::DrawFunc : llvm->TriDrawNormal8[bmode]; break; + //case TriDrawVariant::DrawSubsector: drawfunc = dest_bgra ? &ScreenTriangle::DrawSubsectorFunc : llvm->TriDrawSubsector8[bmode]; break; //case TriDrawVariant::Stencil: drawfunc = &ScreenTriangle::StencilFunc; break; //case TriDrawVariant::StencilClose: drawfunc = &ScreenTriangle::StencilCloseFunc; break; case TriDrawVariant::DrawNormal: drawfunc = dest_bgra ? llvm->TriDrawNormal32[bmode] : llvm->TriDrawNormal8[bmode]; break; @@ -588,7 +589,7 @@ void PolyVertexBuffer::Clear() ///////////////////////////////////////////////////////////////////////////// -void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *thread) +void ScreenTriangle::SetupNormal(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { const TriVertex &v1 = *args->v1; const TriVertex &v2 = *args->v2; @@ -827,6 +828,295 @@ void ScreenTriangle::Setup(const TriDrawTriangleArgs *args, WorkerThreadData *th NumPartialBlocks = (int)(partial - PartialBlocks); } +void ScreenTriangle::SetupSubsector(const TriDrawTriangleArgs *args, WorkerThreadData *thread) +{ + const TriVertex &v1 = *args->v1; + const TriVertex &v2 = *args->v2; + const TriVertex &v3 = *args->v3; + int clipright = args->clipright; + int clipbottom = args->clipbottom; + + int stencilPitch = args->stencilPitch; + uint8_t *stencilValues = args->stencilValues; + uint32_t *stencilMasks = args->stencilMasks; + uint8_t stencilTestValue = args->stencilTestValue; + + uint32_t subsectorDepth = args->uniforms->subsectorDepth; + int32_t pitch = args->pitch; + + ScreenTriangleFullSpan *span = FullSpans; + ScreenTrianglePartialBlock *partial = PartialBlocks; + + // 28.4 fixed-point coordinates + const int Y1 = (int)round(16.0f * v1.y); + const int Y2 = (int)round(16.0f * v2.y); + const int Y3 = (int)round(16.0f * v3.y); + + const int X1 = (int)round(16.0f * v1.x); + const int X2 = (int)round(16.0f * v2.x); + const int X3 = (int)round(16.0f * v3.x); + + // Deltas + const int DX12 = X1 - X2; + const int DX23 = X2 - X3; + const int DX31 = X3 - X1; + + const int DY12 = Y1 - Y2; + const int DY23 = Y2 - Y3; + const int DY31 = Y3 - Y1; + + // Fixed-point deltas + const int FDX12 = DX12 << 4; + const int FDX23 = DX23 << 4; + const int FDX31 = DX31 << 4; + + const int FDY12 = DY12 << 4; + const int FDY23 = DY23 << 4; + const int FDY31 = DY31 << 4; + + // Bounding rectangle + int minx = MAX((MIN(MIN(X1, X2), X3) + 0xF) >> 4, 0); + int maxx = MIN((MAX(MAX(X1, X2), X3) + 0xF) >> 4, clipright - 1); + int miny = MAX((MIN(MIN(Y1, Y2), Y3) + 0xF) >> 4, 0); + int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); + if (minx >= maxx || miny >= maxy) + { + NumFullSpans = 0; + NumPartialBlocks = 0; + return; + } + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + // Start in corner of 8x8 block + minx &= ~(q - 1); + miny &= ~(q - 1); + + // Half-edge constants + int C1 = DY12 * X1 - DX12 * Y1; + int C2 = DY23 * X2 - DX23 * Y2; + int C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++; + if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++; + if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++; + + // First block line for this thread + int core = thread->core; + int num_cores = thread->num_cores; + int core_skip = (num_cores - ((miny / q) - core) % num_cores) % num_cores; + miny += core_skip * q; + + StartX = minx; + StartY = miny; + span->Length = 0; + + // Loop through blocks + for (int y = miny; y < maxy; y += q * num_cores) + { + for (int x = minx; x < maxx; x += q) + { + // Corners of block + int x0 = x << 4; + int x1 = (x + q - 1) << 4; + int y0 = y << 4; + int y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0; + bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0; + bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0; + bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0; + int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3); + + bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0; + bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0; + bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0; + bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0; + int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3); + + bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0; + bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0; + bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0; + bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0; + int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3); + + // Stencil test the whole block, if possible + int block = x / 8 + y / 8 * stencilPitch; + uint8_t *stencilBlock = &stencilValues[block * 64]; + uint32_t *stencilBlockMask = &stencilMasks[block]; + bool blockIsSingleStencil = ((*stencilBlockMask) & 0xffffff00) == 0xffffff00; + bool skipBlock = blockIsSingleStencil && ((*stencilBlockMask) & 0xff) != stencilTestValue; + + // Skip block when outside an edge + if (a == 0 || b == 0 || c == 0 || skipBlock) + { + if (span->Length != 0) + { + span++; + span->Length = 0; + } + continue; + } + + // Accept whole block when totally covered + if (a == 0xf && b == 0xf && c == 0xf && x + q <= clipright && y + q <= clipbottom && blockIsSingleStencil) + { + // Totally covered block still needs a subsector coverage test: + + uint32_t *subsector = args->subsectorGBuffer + x + y * pitch; + + uint32_t mask0 = 0; + uint32_t mask1 = 0; + + for (int iy = 0; iy < 4; iy++) + { + for (int ix = 0; ix < q; ix++) + { + bool covered = subsector[ix] >= subsectorDepth; + mask0 <<= 1; + mask0 |= (uint32_t)covered; + } + subsector += pitch; + } + + for (int iy = 4; iy < q; iy++) + { + for (int ix = 0; ix < q; ix++) + { + bool covered = subsector[ix] >= subsectorDepth; + mask1 <<= 1; + mask1 |= (uint32_t)covered; + } + subsector += pitch; + } + + if (mask0 != 0xffffffff || mask1 != 0xffffffff) + { + if (span->Length > 0) + { + span++; + span->Length = 0; + } + + partial->X = x; + partial->Y = y; + partial->Mask0 = mask0; + partial->Mask1 = mask1; + partial++; + } + else if (span->Length != 0) + { + span->Length++; + } + else + { + span->X = x; + span->Y = y; + span->Length = 1; + } + } + else // Partially covered block + { + x0 = x << 4; + x1 = (x + q - 1) << 4; + int CY1 = C1 + DX12 * y0 - DY12 * x0; + int CY2 = C2 + DX23 * y0 - DY23 * x0; + int CY3 = C3 + DX31 * y0 - DY31 * x0; + + uint32_t *subsector = args->subsectorGBuffer + x + y * pitch; + + uint32_t mask0 = 0; + uint32_t mask1 = 0; + + for (int iy = 0; iy < 4; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + for (int ix = 0; ix < q; ix++) + { + bool passStencilTest = blockIsSingleStencil || stencilBlock[ix + iy * q] == stencilTestValue; + bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && (x + ix) < clipright && (y + iy) < clipbottom && passStencilTest && subsector[ix] >= subsectorDepth); + mask0 <<= 1; + mask0 |= (uint32_t)covered; + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + subsector += pitch; + } + + for (int iy = 4; iy < q; iy++) + { + int CX1 = CY1; + int CX2 = CY2; + int CX3 = CY3; + + for (int ix = 0; ix < q; ix++) + { + bool passStencilTest = blockIsSingleStencil || stencilBlock[ix + iy * q] == stencilTestValue; + bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && (x + ix) < clipright && (y + iy) < clipbottom && passStencilTest && subsector[ix] >= subsectorDepth); + mask1 <<= 1; + mask1 |= (uint32_t)covered; + + CX1 -= FDY12; + CX2 -= FDY23; + CX3 -= FDY31; + } + + CY1 += FDX12; + CY2 += FDX23; + CY3 += FDX31; + subsector += pitch; + } + + if (mask0 != 0xffffffff || mask1 != 0xffffffff) + { + if (span->Length > 0) + { + span++; + span->Length = 0; + } + + partial->X = x; + partial->Y = y; + partial->Mask0 = mask0; + partial->Mask1 = mask1; + partial++; + } + else if (span->Length != 0) + { + span->Length++; + } + else + { + span->X = x; + span->Y = y; + span->Length = 1; + } + } + } + + if (span->Length != 0) + { + span++; + span->Length = 0; + } + } + + NumFullSpans = (int)(span - FullSpans); + NumPartialBlocks = (int)(partial - PartialBlocks); +} + void ScreenTriangle::StencilWrite(const TriDrawTriangleArgs *args) { uint8_t *stencilValues = args->stencilValues; @@ -1200,19 +1490,25 @@ static ScreenTriangle triangle[8]; void ScreenTriangle::DrawFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { - triangle[thread->core].Setup(args, thread); + triangle[thread->core].SetupNormal(args, thread); + triangle[thread->core].Draw(args); +} + +void ScreenTriangle::DrawSubsectorFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) +{ + triangle[thread->core].SetupSubsector(args, thread); triangle[thread->core].Draw(args); } void ScreenTriangle::StencilFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { - triangle[thread->core].Setup(args, thread); + triangle[thread->core].SetupNormal(args, thread); triangle[thread->core].StencilWrite(args); } void ScreenTriangle::StencilCloseFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { - triangle[thread->core].Setup(args, thread); + triangle[thread->core].SetupNormal(args, thread); triangle[thread->core].StencilWrite(args); triangle[thread->core].SubsectorWrite(args); } diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 12591425a..3fb963fe9 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -290,12 +290,14 @@ class ScreenTriangle { public: static void DrawFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); + static void DrawSubsectorFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); static void StencilFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); static void StencilCloseFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); ScreenTriangle(); - void Setup(const TriDrawTriangleArgs *args, WorkerThreadData *thread); + void SetupNormal(const TriDrawTriangleArgs *args, WorkerThreadData *thread); + void SetupSubsector(const TriDrawTriangleArgs *args, WorkerThreadData *thread); void Draw(const TriDrawTriangleArgs *args); void StencilWrite(const TriDrawTriangleArgs *args); void SubsectorWrite(const TriDrawTriangleArgs *args); From 145c0a6d9eab69c7a3b678efb8f7c14564e18ec0 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 13 Dec 2016 19:26:13 +0100 Subject: [PATCH 1409/1509] Prepare triangle setup to be used by LLVM drawers --- src/r_drawers.h | 25 +++++- src/r_poly_triangle.cpp | 163 ++++++++++++++++++++++------------------ src/r_poly_triangle.h | 41 ++-------- src/r_thread.h | 8 ++ 4 files changed, 126 insertions(+), 111 deletions(-) diff --git a/src/r_drawers.h b/src/r_drawers.h index 2e91d502b..bc776be5b 100644 --- a/src/r_drawers.h +++ b/src/r_drawers.h @@ -26,7 +26,21 @@ #include class FString; -class DrawerThread; + +struct TriFullSpan +{ + uint16_t X; + uint16_t Y; + uint32_t Length; +}; + +struct TriPartialBlock +{ + uint16_t X; + uint16_t Y; + uint32_t Mask0; + uint32_t Mask1; +}; struct WorkerThreadData { @@ -35,7 +49,14 @@ struct WorkerThreadData int32_t pass_start_y; int32_t pass_end_y; uint32_t *temp; - DrawerThread *drawer_thread; + + // Triangle working data: + TriFullSpan *FullSpans; + TriPartialBlock *PartialBlocks; + uint32_t NumFullSpans; + uint32_t NumPartialBlocks; + int32_t StartX; + int32_t StartY; }; struct DrawWallArgs diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 30876768b..a97afaead 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -35,6 +35,7 @@ #include "v_palette.h" #include "r_data/colormaps.h" #include "r_poly_triangle.h" +#include "r_draw_rgba.h" int PolyTriangleDrawer::viewport_x; int PolyTriangleDrawer::viewport_y; @@ -368,6 +369,8 @@ void DrawPolyTrianglesCommand::Execute(DrawerThread *thread) thread_data.pass_start_y = thread->pass_start_y; thread_data.pass_end_y = thread->pass_end_y; thread_data.temp = thread->dc_temp_rgba; + thread_data.FullSpans = thread->FullSpansBuffer.data(); + thread_data.PartialBlocks = thread->PartialBlocksBuffer.data(); PolyTriangleDrawer::draw_arrays(args, variant, blendmode, &thread_data); } @@ -598,12 +601,12 @@ void ScreenTriangle::SetupNormal(const TriDrawTriangleArgs *args, WorkerThreadDa int clipbottom = args->clipbottom; int stencilPitch = args->stencilPitch; - uint8_t *stencilValues = args->stencilValues; - uint32_t *stencilMasks = args->stencilMasks; + uint8_t * RESTRICT stencilValues = args->stencilValues; + uint32_t * RESTRICT stencilMasks = args->stencilMasks; uint8_t stencilTestValue = args->stencilTestValue; - ScreenTriangleFullSpan *span = FullSpans; - ScreenTrianglePartialBlock *partial = PartialBlocks; + TriFullSpan * RESTRICT span = thread->FullSpans; + TriPartialBlock * RESTRICT partial = thread->PartialBlocks; // 28.4 fixed-point coordinates const int Y1 = (int)round(16.0f * v1.y); @@ -639,8 +642,8 @@ void ScreenTriangle::SetupNormal(const TriDrawTriangleArgs *args, WorkerThreadDa int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); if (minx >= maxx || miny >= maxy) { - NumFullSpans = 0; - NumPartialBlocks = 0; + thread->NumFullSpans = 0; + thread->NumPartialBlocks = 0; return; } @@ -667,8 +670,8 @@ void ScreenTriangle::SetupNormal(const TriDrawTriangleArgs *args, WorkerThreadDa int core_skip = (num_cores - ((miny / q) - core) % num_cores) % num_cores; miny += core_skip * q; - StartX = minx; - StartY = miny; + thread->StartX = minx; + thread->StartY = miny; span->Length = 0; // Loop through blocks @@ -824,8 +827,8 @@ void ScreenTriangle::SetupNormal(const TriDrawTriangleArgs *args, WorkerThreadDa } } - NumFullSpans = (int)(span - FullSpans); - NumPartialBlocks = (int)(partial - PartialBlocks); + thread->NumFullSpans = (int)(span - thread->FullSpans); + thread->NumPartialBlocks = (int)(partial - thread->PartialBlocks); } void ScreenTriangle::SetupSubsector(const TriDrawTriangleArgs *args, WorkerThreadData *thread) @@ -837,15 +840,16 @@ void ScreenTriangle::SetupSubsector(const TriDrawTriangleArgs *args, WorkerThrea int clipbottom = args->clipbottom; int stencilPitch = args->stencilPitch; - uint8_t *stencilValues = args->stencilValues; - uint32_t *stencilMasks = args->stencilMasks; + uint8_t * RESTRICT stencilValues = args->stencilValues; + uint32_t * RESTRICT stencilMasks = args->stencilMasks; uint8_t stencilTestValue = args->stencilTestValue; + uint32_t * RESTRICT subsectorGBuffer = args->subsectorGBuffer; uint32_t subsectorDepth = args->uniforms->subsectorDepth; int32_t pitch = args->pitch; - ScreenTriangleFullSpan *span = FullSpans; - ScreenTrianglePartialBlock *partial = PartialBlocks; + TriFullSpan * RESTRICT span = thread->FullSpans; + TriPartialBlock * RESTRICT partial = thread->PartialBlocks; // 28.4 fixed-point coordinates const int Y1 = (int)round(16.0f * v1.y); @@ -881,8 +885,8 @@ void ScreenTriangle::SetupSubsector(const TriDrawTriangleArgs *args, WorkerThrea int maxy = MIN((MAX(MAX(Y1, Y2), Y3) + 0xF) >> 4, clipbottom - 1); if (minx >= maxx || miny >= maxy) { - NumFullSpans = 0; - NumPartialBlocks = 0; + thread->NumFullSpans = 0; + thread->NumPartialBlocks = 0; return; } @@ -909,8 +913,8 @@ void ScreenTriangle::SetupSubsector(const TriDrawTriangleArgs *args, WorkerThrea int core_skip = (num_cores - ((miny / q) - core) % num_cores) % num_cores; miny += core_skip * q; - StartX = minx; - StartY = miny; + thread->StartX = minx; + thread->StartY = miny; span->Length = 0; // Loop through blocks @@ -966,7 +970,7 @@ void ScreenTriangle::SetupSubsector(const TriDrawTriangleArgs *args, WorkerThrea { // Totally covered block still needs a subsector coverage test: - uint32_t *subsector = args->subsectorGBuffer + x + y * pitch; + uint32_t *subsector = subsectorGBuffer + x + y * pitch; uint32_t mask0 = 0; uint32_t mask1 = 0; @@ -1026,7 +1030,7 @@ void ScreenTriangle::SetupSubsector(const TriDrawTriangleArgs *args, WorkerThrea int CY2 = C2 + DX23 * y0 - DY23 * x0; int CY3 = C3 + DX31 * y0 - DY31 * x0; - uint32_t *subsector = args->subsectorGBuffer + x + y * pitch; + uint32_t *subsector = subsectorGBuffer + x + y * pitch; uint32_t mask0 = 0; uint32_t mask1 = 0; @@ -1113,20 +1117,25 @@ void ScreenTriangle::SetupSubsector(const TriDrawTriangleArgs *args, WorkerThrea } } - NumFullSpans = (int)(span - FullSpans); - NumPartialBlocks = (int)(partial - PartialBlocks); + thread->NumFullSpans = (int)(span - thread->FullSpans); + thread->NumPartialBlocks = (int)(partial - thread->PartialBlocks); } -void ScreenTriangle::StencilWrite(const TriDrawTriangleArgs *args) +void ScreenTriangle::StencilWrite(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { - uint8_t *stencilValues = args->stencilValues; - uint32_t *stencilMasks = args->stencilMasks; + uint8_t * RESTRICT stencilValues = args->stencilValues; + uint32_t * RESTRICT stencilMasks = args->stencilMasks; uint32_t stencilWriteValue = args->stencilWriteValue; uint32_t stencilPitch = args->stencilPitch; - for (int i = 0; i < NumFullSpans; i++) + int numSpans = thread->NumFullSpans; + auto fullSpans = thread->FullSpans; + int numBlocks = thread->NumPartialBlocks; + auto partialBlocks = thread->PartialBlocks; + + for (int i = 0; i < numSpans; i++) { - const auto &span = FullSpans[i]; + const auto &span = fullSpans[i]; int block = span.X / 8 + span.Y / 8 * stencilPitch; uint8_t *stencilBlock = &stencilValues[block * 64]; @@ -1137,9 +1146,9 @@ void ScreenTriangle::StencilWrite(const TriDrawTriangleArgs *args) stencilBlockMask[x] = 0xffffff00 | stencilWriteValue; } - for (int i = 0; i < NumPartialBlocks; i++) + for (int i = 0; i < numBlocks; i++) { - const auto &block = PartialBlocks[i]; + const auto &block = partialBlocks[i]; uint32_t mask0 = block.Mask0; uint32_t mask1 = block.Mask1; @@ -1182,16 +1191,22 @@ void ScreenTriangle::StencilWrite(const TriDrawTriangleArgs *args) } } -void ScreenTriangle::SubsectorWrite(const TriDrawTriangleArgs *args) +void ScreenTriangle::SubsectorWrite(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { + uint32_t * RESTRICT subsectorGBuffer = args->subsectorGBuffer; uint32_t subsectorDepth = args->uniforms->subsectorDepth; + int pitch = args->pitch; - for (int i = 0; i < NumFullSpans; i++) + int numSpans = thread->NumFullSpans; + auto fullSpans = thread->FullSpans; + int numBlocks = thread->NumPartialBlocks; + auto partialBlocks = thread->PartialBlocks; + + for (int i = 0; i < numSpans; i++) { - const auto &span = FullSpans[i]; + const auto &span = fullSpans[i]; - uint32_t *subsector = args->subsectorGBuffer + span.X + span.Y * args->pitch; - int pitch = args->pitch; + uint32_t *subsector = subsectorGBuffer + span.X + span.Y * pitch; int width = span.Length * 8; int height = 8; for (int y = 0; y < height; y++) @@ -1202,12 +1217,11 @@ void ScreenTriangle::SubsectorWrite(const TriDrawTriangleArgs *args) } } - for (int i = 0; i < NumPartialBlocks; i++) + for (int i = 0; i < numBlocks; i++) { - const auto &block = PartialBlocks[i]; + const auto &block = partialBlocks[i]; - uint32_t *subsector = args->subsectorGBuffer + block.X + block.Y * args->pitch; - int pitch = args->pitch; + uint32_t *subsector = subsectorGBuffer + block.X + block.Y * pitch; uint32_t mask0 = block.Mask0; uint32_t mask1 = block.Mask1; for (int y = 0; y < 4; y++) @@ -1247,8 +1261,15 @@ float ScreenTriangle::FindGradientY(float x0, float y0, float x1, float y1, floa return top / bottom; } -void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) +void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { + int numSpans = thread->NumFullSpans; + auto fullSpans = thread->FullSpans; + int numBlocks = thread->NumPartialBlocks; + auto partialBlocks = thread->PartialBlocks; + int startX = thread->StartX; + int startY = thread->StartY; + // Calculate gradients const TriVertex &v1 = *args->v1; const TriVertex &v2 = *args->v2; @@ -1258,38 +1279,41 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) ScreenTriangleStepVariables start; gradientX.W = FindGradientX(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); gradientY.W = FindGradientY(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - start.W = v1.w + gradientX.W * (StartX - v1.x) + gradientY.W * (StartY - v1.y); + start.W = v1.w + gradientX.W * (startX - v1.x) + gradientY.W * (startY - v1.y); for (int i = 0; i < TriVertex::NumVarying; i++) { gradientX.Varying[i] = FindGradientX(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); gradientY.Varying[i] = FindGradientY(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - start.Varying[i] = v1.varying[i] * v1.w + gradientX.Varying[i] * (StartX - v1.x) + gradientY.Varying[i] * (StartY - v1.y); + start.Varying[i] = v1.varying[i] * v1.w + gradientX.Varying[i] * (startX - v1.x) + gradientY.Varying[i] * (startY - v1.y); } - const uint32_t *texPixels = (const uint32_t *)args->texturePixels; + const uint32_t * RESTRICT texPixels = (const uint32_t *)args->texturePixels; uint32_t texWidth = args->textureWidth; uint32_t texHeight = args->textureHeight; + uint32_t * RESTRICT destOrg = (uint32_t*)args->dest; + uint32_t * RESTRICT subsectorGBuffer = (uint32_t*)args->subsectorGBuffer; + int pitch = args->pitch; + uint32_t subsectorDepth = args->uniforms->subsectorDepth; uint32_t light = args->uniforms->light; float shade = (64.0f - (light * 255 / 256 + 12.0f) * 32.0f / 128.0f) / 32.0f; float globVis = 1706.0f; - for (int i = 0; i < NumFullSpans; i++) + for (int i = 0; i < numSpans; i++) { - const auto &span = FullSpans[i]; + const auto &span = fullSpans[i]; - uint32_t *dest = (uint32_t*)args->dest + span.X + span.Y * args->pitch; - uint32_t *subsector = args->subsectorGBuffer + span.X + span.Y * args->pitch; - int pitch = args->pitch; + uint32_t *dest = destOrg + span.X + span.Y * pitch; + uint32_t *subsector = subsectorGBuffer + span.X + span.Y * pitch; int width = span.Length; int height = 8; ScreenTriangleStepVariables blockPosY; - blockPosY.W = start.W + gradientX.W * (span.X - StartX) + gradientY.W * (span.Y - StartY); + blockPosY.W = start.W + gradientX.W * (span.X - startX) + gradientY.W * (span.Y - startY); for (int j = 0; j < TriVertex::NumVarying; j++) - blockPosY.Varying[j] = start.Varying[j] + gradientX.Varying[j] * (span.X - StartX) + gradientY.Varying[j] * (span.Y - StartY); + blockPosY.Varying[j] = start.Varying[j] + gradientX.Varying[j] * (span.X - startX) + gradientY.Varying[j] * (span.Y - startY); for (int y = 0; y < height; y++) { @@ -1351,18 +1375,17 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) } } - for (int i = 0; i < NumPartialBlocks; i++) + for (int i = 0; i < numBlocks; i++) { - const auto &block = PartialBlocks[i]; + const auto &block = partialBlocks[i]; ScreenTriangleStepVariables blockPosY; - blockPosY.W = start.W + gradientX.W * (block.X - StartX) + gradientY.W * (block.Y - StartY); + blockPosY.W = start.W + gradientX.W * (block.X - startX) + gradientY.W * (block.Y - startY); for (int j = 0; j < TriVertex::NumVarying; j++) - blockPosY.Varying[j] = start.Varying[j] + gradientX.Varying[j] * (block.X - StartX) + gradientY.Varying[j] * (block.Y - StartY); + blockPosY.Varying[j] = start.Varying[j] + gradientX.Varying[j] * (block.X - startX) + gradientY.Varying[j] * (block.Y - startY); - uint32_t *dest = (uint32_t*)args->dest + block.X + block.Y * args->pitch; - uint32_t *subsector = args->subsectorGBuffer + block.X + block.Y * args->pitch; - int pitch = args->pitch; + uint32_t *dest = destOrg + block.X + block.Y * pitch; + uint32_t *subsector = subsectorGBuffer + block.X + block.Y * pitch; uint32_t mask0 = block.Mask0; uint32_t mask1 = block.Mask1; for (int y = 0; y < 4; y++) @@ -1486,37 +1509,27 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args) } } -static ScreenTriangle triangle[8]; - void ScreenTriangle::DrawFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { - triangle[thread->core].SetupNormal(args, thread); - triangle[thread->core].Draw(args); + SetupNormal(args, thread); + Draw(args, thread); } void ScreenTriangle::DrawSubsectorFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { - triangle[thread->core].SetupSubsector(args, thread); - triangle[thread->core].Draw(args); + SetupSubsector(args, thread); + Draw(args, thread); } void ScreenTriangle::StencilFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { - triangle[thread->core].SetupNormal(args, thread); - triangle[thread->core].StencilWrite(args); + SetupNormal(args, thread); + StencilWrite(args, thread); } void ScreenTriangle::StencilCloseFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { - triangle[thread->core].SetupNormal(args, thread); - triangle[thread->core].StencilWrite(args); - triangle[thread->core].SubsectorWrite(args); -} - -ScreenTriangle::ScreenTriangle() -{ - FullSpansBuffer.resize(MAXWIDTH / 8 * (MAXHEIGHT / 8)); - PartialBlocksBuffer.resize(MAXWIDTH / 8 * (MAXHEIGHT / 8)); - FullSpans = FullSpansBuffer.data(); - PartialBlocks = PartialBlocksBuffer.data(); + SetupNormal(args, thread); + StencilWrite(args, thread); + SubsectorWrite(args, thread); } diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 3fb963fe9..14cfb1335 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -271,21 +271,6 @@ struct ScreenTriangleStepVariables float Varying[TriVertex::NumVarying]; }; -struct ScreenTriangleFullSpan -{ - uint16_t X; - uint16_t Y; - uint32_t Length; -}; - -struct ScreenTrianglePartialBlock -{ - uint16_t X; - uint16_t Y; - uint32_t Mask0; - uint32_t Mask1; -}; - class ScreenTriangle { public: @@ -294,25 +279,13 @@ public: static void StencilFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); static void StencilCloseFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - ScreenTriangle(); - - void SetupNormal(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - void SetupSubsector(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - void Draw(const TriDrawTriangleArgs *args); - void StencilWrite(const TriDrawTriangleArgs *args); - void SubsectorWrite(const TriDrawTriangleArgs *args); - - ScreenTriangleFullSpan *FullSpans; - ScreenTrianglePartialBlock *PartialBlocks; - int NumFullSpans; - int NumPartialBlocks; - int StartX; - int StartY; - private: - float FindGradientX(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); - float FindGradientY(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); + static void SetupNormal(const TriDrawTriangleArgs *args, WorkerThreadData *thread); + static void SetupSubsector(const TriDrawTriangleArgs *args, WorkerThreadData *thread); + static void Draw(const TriDrawTriangleArgs *args, WorkerThreadData *thread); + static void StencilWrite(const TriDrawTriangleArgs *args, WorkerThreadData *thread); + static void SubsectorWrite(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - std::vector FullSpansBuffer; - std::vector PartialBlocksBuffer; + static float FindGradientX(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); + static float FindGradientY(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); }; diff --git a/src/r_thread.h b/src/r_thread.h index 66c9332c3..ea1ceaa29 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -23,6 +23,7 @@ #pragma once #include "r_draw.h" +#include "r_drawers.h" #include #include #include @@ -46,6 +47,9 @@ public: { dc_temp = dc_temp_buff; dc_temp_rgba = dc_temp_rgbabuff_rgba; + + FullSpansBuffer.resize(MAXWIDTH / 8 * (MAXHEIGHT / 8)); + PartialBlocksBuffer.resize(MAXWIDTH / 8 * (MAXHEIGHT / 8)); } std::thread thread; @@ -71,6 +75,10 @@ public: // Working buffer used by the tilted (sloped) span drawer const uint8_t *tiltlighting[MAXWIDTH]; + // Working buffer used by the triangler drawer + std::vector FullSpansBuffer; + std::vector PartialBlocksBuffer; + // Checks if a line is rendered by this thread bool line_skipped_by_thread(int line) { From c643238b86f448911427feb5831e182874483d46 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 15 Dec 2016 01:33:26 +0100 Subject: [PATCH 1410/1509] Rewrote the LLVM triangle drawer to use the data from the triangle setup function --- src/r_poly_sky.cpp | 4 +- src/r_poly_triangle.cpp | 52 +- src/r_poly_triangle.h | 11 +- .../fixedfunction/drawtrianglecodegen.cpp | 960 ++++++++++++------ .../fixedfunction/drawtrianglecodegen.h | 87 ++ tools/drawergen/llvmdrawers.cpp | 85 +- tools/drawergen/llvmdrawers.h | 32 +- 7 files changed, 843 insertions(+), 388 deletions(-) diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp index e4e0a0144..823a510f2 100644 --- a/src/r_poly_sky.cpp +++ b/src/r_poly_sky.cpp @@ -58,7 +58,7 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) args.uniforms.subsectorDepth = RenderPolyScene::SkySubsectorDepth; args.objectToClip = &objectToClip; args.stenciltestvalue = 255; - args.stencilwritevalue = 255; + args.stencilwritevalue = 1; args.SetTexture(frontskytex); args.SetColormap(&NormalLight); args.SetClipPlane(0.0f, 0.0f, 0.0f, 0.0f); @@ -84,6 +84,7 @@ void PolySkyDome::RenderRow(PolyDrawArgs &args, int row, uint32_t capcolor) args.ccw = false; args.uniforms.color = capcolor; PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Skycap); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Skycap); } void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap) @@ -98,6 +99,7 @@ void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int ro args.ccw = bottomCap; args.uniforms.color = solid; PolyTriangleDrawer::draw(args, TriDrawVariant::FillNormal, TriBlendMode::Copy); + PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); } void PolySkyDome::CreateDome() diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index a97afaead..164fc98e2 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -88,22 +88,19 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian return; auto llvm = Drawers::Instance(); - void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *); + PolyDrawFuncPtr setupfunc = nullptr; + PolyDrawFuncPtr drawfunc = nullptr; int bmode = (int)blendmode; switch (variant) { default: - //case TriDrawVariant::DrawNormal: drawfunc = dest_bgra ? &ScreenTriangle::DrawFunc : llvm->TriDrawNormal8[bmode]; break; - //case TriDrawVariant::DrawSubsector: drawfunc = dest_bgra ? &ScreenTriangle::DrawSubsectorFunc : llvm->TriDrawSubsector8[bmode]; break; - //case TriDrawVariant::Stencil: drawfunc = &ScreenTriangle::StencilFunc; break; - //case TriDrawVariant::StencilClose: drawfunc = &ScreenTriangle::StencilCloseFunc; break; - case TriDrawVariant::DrawNormal: drawfunc = dest_bgra ? llvm->TriDrawNormal32[bmode] : llvm->TriDrawNormal8[bmode]; break; - case TriDrawVariant::FillNormal: drawfunc = dest_bgra ? llvm->TriFillNormal32[bmode] : llvm->TriFillNormal8[bmode]; break; - case TriDrawVariant::DrawSubsector: drawfunc = dest_bgra ? llvm->TriDrawSubsector32[bmode] : llvm->TriDrawSubsector8[bmode]; break; + case TriDrawVariant::DrawNormal: setupfunc = &ScreenTriangle::SetupNormal; drawfunc = dest_bgra ? llvm->TriDrawNormal32[bmode] : llvm->TriDrawNormal8[bmode]; break; + case TriDrawVariant::FillNormal: setupfunc = &ScreenTriangle::SetupNormal; drawfunc = dest_bgra ? llvm->TriFillNormal32[bmode] : llvm->TriFillNormal8[bmode]; break; + case TriDrawVariant::DrawSubsector: setupfunc = &ScreenTriangle::SetupSubsector; drawfunc = dest_bgra ? llvm->TriDrawSubsector32[bmode] : llvm->TriDrawSubsector8[bmode]; break; case TriDrawVariant::FuzzSubsector: - case TriDrawVariant::FillSubsector: drawfunc = dest_bgra ? llvm->TriFillSubsector32[bmode] : llvm->TriFillSubsector8[bmode]; break; - case TriDrawVariant::Stencil: drawfunc = llvm->TriStencil; break; - case TriDrawVariant::StencilClose: drawfunc = llvm->TriStencilClose; break; + case TriDrawVariant::FillSubsector: setupfunc = &ScreenTriangle::SetupSubsector; drawfunc = dest_bgra ? llvm->TriFillSubsector32[bmode] : llvm->TriFillSubsector8[bmode]; break; + case TriDrawVariant::Stencil: drawfunc = &ScreenTriangle::StencilFunc; break; + case TriDrawVariant::StencilClose: drawfunc = &ScreenTriangle::StencilCloseFunc; break; } TriDrawTriangleArgs args; @@ -139,7 +136,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian { for (int j = 0; j < 3; j++) vert[j] = shade_vertex(*drawargs.objectToClip, drawargs.clipPlane, *(vinput++)); - draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); + draw_shaded_triangle(vert, ccw, &args, thread, setupfunc, drawfunc); } } else if (drawargs.mode == TriangleDrawMode::Fan) @@ -149,7 +146,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian for (int i = 2; i < vcount; i++) { vert[2] = shade_vertex(*drawargs.objectToClip, drawargs.clipPlane, *(vinput++)); - draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); + draw_shaded_triangle(vert, ccw, &args, thread, setupfunc, drawfunc); vert[1] = vert[2]; } } @@ -160,7 +157,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian for (int i = 2; i < vcount; i++) { vert[2] = shade_vertex(*drawargs.objectToClip, drawargs.clipPlane, *(vinput++)); - draw_shaded_triangle(vert, ccw, &args, thread, drawfunc); + draw_shaded_triangle(vert, ccw, &args, thread, setupfunc, drawfunc); vert[0] = vert[1]; vert[1] = vert[2]; ccw = !ccw; @@ -179,7 +176,7 @@ ShadedTriVertex PolyTriangleDrawer::shade_vertex(const TriMatrix &objectToClip, return sv; } -void PolyTriangleDrawer::draw_shaded_triangle(const ShadedTriVertex *vert, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *)) +void PolyTriangleDrawer::draw_shaded_triangle(const ShadedTriVertex *vert, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, PolyDrawFuncPtr setupfunc, PolyDrawFuncPtr drawfunc) { // Cull, clip and generate additional vertices as needed TriVertex clippedvert[max_additional_vertices]; @@ -223,6 +220,7 @@ void PolyTriangleDrawer::draw_shaded_triangle(const ShadedTriVertex *vert, bool args->v1 = &clippedvert[numclipvert - 1]; args->v2 = &clippedvert[i - 1]; args->v3 = &clippedvert[i - 2]; + if (setupfunc) setupfunc(args, thread); drawfunc(args, thread); } } @@ -233,6 +231,7 @@ void PolyTriangleDrawer::draw_shaded_triangle(const ShadedTriVertex *vert, bool args->v1 = &clippedvert[0]; args->v2 = &clippedvert[i - 1]; args->v3 = &clippedvert[i]; + if (setupfunc) setupfunc(args, thread); drawfunc(args, thread); } } @@ -952,7 +951,7 @@ void ScreenTriangle::SetupSubsector(const TriDrawTriangleArgs *args, WorkerThrea uint8_t *stencilBlock = &stencilValues[block * 64]; uint32_t *stencilBlockMask = &stencilMasks[block]; bool blockIsSingleStencil = ((*stencilBlockMask) & 0xffffff00) == 0xffffff00; - bool skipBlock = blockIsSingleStencil && ((*stencilBlockMask) & 0xff) != stencilTestValue; + bool skipBlock = blockIsSingleStencil && ((*stencilBlockMask) & 0xff) < stencilTestValue; // Skip block when outside an edge if (a == 0 || b == 0 || c == 0 || skipBlock) @@ -1043,7 +1042,7 @@ void ScreenTriangle::SetupSubsector(const TriDrawTriangleArgs *args, WorkerThrea for (int ix = 0; ix < q; ix++) { - bool passStencilTest = blockIsSingleStencil || stencilBlock[ix + iy * q] == stencilTestValue; + bool passStencilTest = blockIsSingleStencil || stencilBlock[ix + iy * q] >= stencilTestValue; bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && (x + ix) < clipright && (y + iy) < clipbottom && passStencilTest && subsector[ix] >= subsectorDepth); mask0 <<= 1; mask0 |= (uint32_t)covered; @@ -1067,7 +1066,7 @@ void ScreenTriangle::SetupSubsector(const TriDrawTriangleArgs *args, WorkerThrea for (int ix = 0; ix < q; ix++) { - bool passStencilTest = blockIsSingleStencil || stencilBlock[ix + iy * q] == stencilTestValue; + bool passStencilTest = blockIsSingleStencil || stencilBlock[ix + iy * q] >= stencilTestValue; bool covered = (CX1 > 0 && CX2 > 0 && CX3 > 0 && (x + ix) < clipright && (y + iy) < clipbottom && passStencilTest && subsector[ix] >= subsectorDepth); mask1 <<= 1; mask1 |= (uint32_t)covered; @@ -1247,6 +1246,7 @@ void ScreenTriangle::SubsectorWrite(const TriDrawTriangleArgs *args, WorkerThrea } } +#if 0 float ScreenTriangle::FindGradientX(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2) { float top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); @@ -1323,11 +1323,10 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, WorkerThreadData *thr int32_t varyingPos[TriVertex::NumVarying]; for (int j = 0; j < TriVertex::NumVarying; j++) varyingPos[j] = (int32_t)(blockPosX.Varying[j] * rcpW); + int lightpos = 256 - (int)(clamp(shade - MIN(24.0f, globVis * blockPosX.W) / 32.0f, 0.0f, 31.0f / 32.0f) * 256.0f); for (int x = 0; x < width; x++) { - int lightpos = 256 - (int)(clamp(shade - MIN(24.0f, globVis * blockPosX.W) / 32.0f, 0.0f, 31.0f / 32.0f) * 256.0f); - blockPosX.W += gradientX.W * 8; for (int j = 0; j < TriVertex::NumVarying; j++) blockPosX.Varying[j] += gradientX.Varying[j] * 8; @@ -1508,18 +1507,7 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, WorkerThreadData *thr } } } - -void ScreenTriangle::DrawFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) -{ - SetupNormal(args, thread); - Draw(args, thread); -} - -void ScreenTriangle::DrawSubsectorFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) -{ - SetupSubsector(args, thread); - Draw(args, thread); -} +#endif void ScreenTriangle::StencilFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) { diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 14cfb1335..59e52ef66 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -153,6 +153,8 @@ struct TriMatrix float matrix[16]; }; +typedef void(*PolyDrawFuncPtr)(const TriDrawTriangleArgs *, WorkerThreadData *); + class PolyTriangleDrawer { public: @@ -163,7 +165,7 @@ public: private: static ShadedTriVertex shade_vertex(const TriMatrix &objectToClip, const float *clipPlane, const TriVertex &v); static void draw_arrays(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode, WorkerThreadData *thread); - static void draw_shaded_triangle(const ShadedTriVertex *vertices, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, void(*drawfunc)(const TriDrawTriangleArgs *, WorkerThreadData *)); + static void draw_shaded_triangle(const ShadedTriVertex *vertices, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, PolyDrawFuncPtr setupfunc, PolyDrawFuncPtr drawfunc); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const ShadedTriVertex *verts, TriVertex *clippedvert, int &numclipvert); @@ -274,18 +276,11 @@ struct ScreenTriangleStepVariables class ScreenTriangle { public: - static void DrawFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - static void DrawSubsectorFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); static void StencilFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); static void StencilCloseFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); -private: static void SetupNormal(const TriDrawTriangleArgs *args, WorkerThreadData *thread); static void SetupSubsector(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - static void Draw(const TriDrawTriangleArgs *args, WorkerThreadData *thread); static void StencilWrite(const TriDrawTriangleArgs *args, WorkerThreadData *thread); static void SubsectorWrite(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - - static float FindGradientX(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); - static float FindGradientY(float x0, float y0, float x1, float y1, float x2, float y2, float c0, float c1, float c2); }; diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index 3806d5253..f38b42350 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -32,6 +32,636 @@ #include "ssa/ssa_struct_type.h" #include "ssa/ssa_value.h" +void DrawTriangleCodegen::Generate(TriDrawVariant variant, TriBlendMode blendmode, bool truecolor, SSAValue args, SSAValue thread_data) +{ + this->variant = variant; + this->blendmode = blendmode; + this->truecolor = truecolor; + pixelsize = truecolor ? 4 : 1; + + LoadArgs(args, thread_data); + CalculateGradients(); + DrawFullSpans(); + DrawPartialBlocks(); +} + +void DrawTriangleCodegen::DrawFullSpans() +{ + stack_i.store(SSAInt(0)); + SSAForBlock loop; + SSAInt i = stack_i.load(); + loop.loop_block(i < numSpans, 0); + { + SSAInt spanX = SSAShort(fullSpans[i][0].load(true).v).zext_int(); + SSAInt spanY = SSAShort(fullSpans[i][1].load(true).v).zext_int(); + SSAInt spanLength = fullSpans[i][2].load(true); + + SSAInt width = spanLength; + SSAInt height = SSAInt(8); + + stack_dest.store(destOrg[(spanX + spanY * pitch) * pixelsize]); + stack_subsector.store(subsectorGBuffer[spanX + spanY * pitch]); + stack_posYW.store(start.W + gradientX.W * (spanX - startX) + gradientY.W * (spanY - startY)); + for (int j = 0; j < TriVertex::NumVarying; j++) + stack_posYVarying[j].store(start.Varying[j] + gradientX.Varying[j] * (spanX - startX) + gradientY.Varying[j] * (spanY - startY)); + stack_y.store(SSAInt(0)); + + SSAForBlock loop_y; + SSAInt y = stack_y.load(); + SSAUBytePtr dest = stack_dest.load(); + SSAIntPtr subsector = stack_subsector.load(); + SSAStepVariables blockPosY; + blockPosY.W = stack_posYW.load(); + for (int j = 0; j < TriVertex::NumVarying; j++) + blockPosY.Varying[j] = stack_posYVarying[j].load(); + loop_y.loop_block(y < height, 0); + { + stack_posXW.store(blockPosY.W); + for (int j = 0; j < TriVertex::NumVarying; j++) + stack_posXVarying[j].store(blockPosY.Varying[j]); + + SSAFloat rcpW = SSAFloat((float)0x01000000) / blockPosY.W; + stack_lightpos.store(FRACUNIT - SSAInt(SSAFloat::clamp(shade - SSAFloat::MIN(SSAFloat(24.0f), globVis * blockPosY.W) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * (float)FRACUNIT, true)); + for (int j = 0; j < TriVertex::NumVarying; j++) + stack_varyingPos[j].store(SSAInt(blockPosY.Varying[j] * rcpW, false)); + stack_x.store(SSAInt(0)); + + SSAForBlock loop_x; + SSAInt x = stack_x.load(); + SSAStepVariables blockPosX; + blockPosX.W = stack_posXW.load(); + for (int j = 0; j < TriVertex::NumVarying; j++) + blockPosX.Varying[j] = stack_posXVarying[j].load(); + SSAInt lightpos = stack_lightpos.load(); + SSAInt varyingPos[TriVertex::NumVarying]; + for (int j = 0; j < TriVertex::NumVarying; j++) + varyingPos[j] = stack_varyingPos[j].load(); + loop_x.loop_block(x < width, 0); + { + blockPosX.W = blockPosX.W + gradientX.W * 8.0f; + for (int j = 0; j < TriVertex::NumVarying; j++) + blockPosX.Varying[j] = blockPosX.Varying[j] + gradientX.Varying[j] * 8.0f; + + rcpW = SSAFloat((float)0x01000000) / blockPosX.W; + SSAInt varyingStep[TriVertex::NumVarying]; + for (int j = 0; j < TriVertex::NumVarying; j++) + { + SSAInt nextPos = SSAInt(blockPosX.Varying[j] * rcpW, false); + varyingStep[j] = (nextPos - varyingPos[j]) / 8; + } + + SSAInt lightnext = FRACUNIT - SSAInt(SSAFloat::clamp(shade - SSAFloat::MIN(SSAFloat(24.0f), globVis * blockPosX.W) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * (float)FRACUNIT, true); + SSAInt lightstep = (lightnext - lightpos) / 8; + + for (int ix = 0; ix < 8; ix++) + { + if (truecolor) + { + currentlight = is_fixed_light.select(light, lightpos >> 8); + + SSAUBytePtr destptr = dest[(x * 8 + ix) * 4]; + destptr.store_vec4ub(ProcessPixel32(destptr.load_vec4ub(false), varyingPos)); + + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) + subsector[x * 8 + ix].store(subsectorDepth); + } + else + { + currentlight = is_fixed_light.select(light, lightpos >> 8); + SSAInt colormapindex = SSAInt::MIN((256 - currentlight) * 32 / 256, SSAInt(31)); + currentcolormap = Colormaps[colormapindex << 8]; + + SSAUBytePtr destptr = dest[(x * 8 + ix)]; + destptr.store(ProcessPixel8(destptr.load(false).zext_int(), varyingPos).trunc_ubyte()); + + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) + subsector[x * 8 + ix].store(subsectorDepth); + } + + for (int j = 0; j < TriVertex::NumVarying; j++) + varyingPos[j] = varyingPos[j] + varyingStep[j]; + lightpos = lightpos + lightstep; + } + + for (int j = 0; j < TriVertex::NumVarying; j++) + stack_varyingPos[j].store(varyingPos[j]); + stack_lightpos.store(lightpos); + stack_posXW.store(blockPosX.W); + for (int j = 0; j < TriVertex::NumVarying; j++) + stack_posXVarying[j].store(blockPosX.Varying[j]); + stack_x.store(x + 1); + } + loop_x.end_block(); + + stack_posYW.store(blockPosY.W + gradientY.W); + for (int j = 0; j < TriVertex::NumVarying; j++) + stack_posYVarying[j].store(blockPosY.Varying[j] + gradientY.Varying[j]); + stack_dest.store(dest[pitch * pixelsize]); + stack_subsector.store(subsector[pitch]); + stack_y.store(y + 1); + } + loop_y.end_block(); + + stack_i.store(i + 1); + } + loop.end_block(); +} + +void DrawTriangleCodegen::DrawPartialBlocks() +{ + stack_i.store(SSAInt(0)); + SSAForBlock loop; + SSAInt i = stack_i.load(); + loop.loop_block(i < numBlocks, 0); + { + SSAInt blockX = SSAShort(partialBlocks[i][0].load(true).v).zext_int(); + SSAInt blockY = SSAShort(partialBlocks[i][1].load(true).v).zext_int(); + SSAInt mask0 = partialBlocks[i][2].load(true); + SSAInt mask1 = partialBlocks[i][3].load(true); + + SSAUBytePtr dest = destOrg[(blockX + blockY * pitch) * pixelsize]; + SSAIntPtr subsector = subsectorGBuffer[blockX + blockY * pitch]; + + SSAStepVariables blockPosY; + blockPosY.W = start.W + gradientX.W * (blockX - startX) + gradientY.W * (blockY - startY); + for (int j = 0; j < TriVertex::NumVarying; j++) + blockPosY.Varying[j] = start.Varying[j] + gradientX.Varying[j] * (blockX - startX) + gradientY.Varying[j] * (blockY - startY); + + for (int maskNum = 0; maskNum < 2; maskNum++) + { + SSAInt mask = (maskNum == 0) ? mask0 : mask1; + + for (int y = 0; y < 4; y++) + { + SSAStepVariables blockPosX = blockPosY; + + SSAFloat rcpW = SSAFloat((float)0x01000000) / blockPosX.W; + SSAInt varyingPos[TriVertex::NumVarying]; + for (int j = 0; j < TriVertex::NumVarying; j++) + varyingPos[j] = SSAInt(blockPosX.Varying[j] * rcpW, false); + + SSAInt lightpos = FRACUNIT - SSAInt(SSAFloat::clamp(shade - SSAFloat::MIN(SSAFloat(24.0f), globVis * blockPosX.W) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * (float)FRACUNIT, true); + + blockPosX.W = blockPosX.W + gradientX.W * 8.0f; + for (int j = 0; j < TriVertex::NumVarying; j++) + blockPosX.Varying[j] = blockPosX.Varying[j] + gradientX.Varying[j] * 8.0f; + + rcpW = SSAFloat((float)0x01000000) / blockPosX.W; + SSAInt varyingStep[TriVertex::NumVarying]; + for (int j = 0; j < TriVertex::NumVarying; j++) + { + SSAInt nextPos = SSAInt(blockPosX.Varying[j] * rcpW, false); + varyingStep[j] = (nextPos - varyingPos[j]) / 8; + } + + SSAInt lightnext = FRACUNIT - SSAInt(SSAFloat::clamp(shade - SSAFloat::MIN(SSAFloat(24.0f), globVis * blockPosX.W) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * (float)FRACUNIT, true); + SSAInt lightstep = (lightnext - lightpos) / 8; + + for (int x = 0; x < 8; x++) + { + SSABool covered = !((mask & (1 << (31 - y * 8 - x))) == SSAInt(0)); + SSAIfBlock branch; + branch.if_block(covered); + { + if (truecolor) + { + currentlight = is_fixed_light.select(light, lightpos >> 8); + + SSAUBytePtr destptr = dest[x * 4]; + destptr.store_vec4ub(ProcessPixel32(destptr.load_vec4ub(false), varyingPos)); + + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) + subsector[x].store(subsectorDepth); + } + else + { + currentlight = is_fixed_light.select(light, lightpos >> 8); + SSAInt colormapindex = SSAInt::MIN((256 - currentlight) * 32 / 256, SSAInt(31)); + currentcolormap = Colormaps[colormapindex << 8]; + + SSAUBytePtr destptr = dest[x]; + destptr.store(ProcessPixel8(destptr.load(false).zext_int(), varyingPos).trunc_ubyte()); + + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) + subsector[x].store(subsectorDepth); + } + } + branch.end_block(); + + for (int j = 0; j < TriVertex::NumVarying; j++) + varyingPos[j] = varyingPos[j] + varyingStep[j]; + lightpos = lightpos + lightstep; + } + + blockPosY.W = blockPosY.W + gradientY.W; + for (int j = 0; j < TriVertex::NumVarying; j++) + blockPosY.Varying[j] = blockPosY.Varying[j] + gradientY.Varying[j]; + + dest = dest[pitch * pixelsize]; + subsector = subsector[pitch]; + } + } + + stack_i.store(i + 1); + } + loop.end_block(); +} + +SSAVec4i DrawTriangleCodegen::TranslateSample32(SSAInt *varying) +{ + SSAInt ufrac = varying[0] << 8; + SSAInt vfrac = varying[1] << 8; + + SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; + SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; + SSAInt uvoffset = upos * textureHeight + vpos; + + if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + return translation[color * 4].load_vec4ub(true); + else + return translation[texturePixels[uvoffset].load(true).zext_int() * 4].load_vec4ub(true); +} + +SSAInt DrawTriangleCodegen::TranslateSample8(SSAInt *varying) +{ + SSAInt ufrac = varying[0] << 8; + SSAInt vfrac = varying[1] << 8; + + SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; + SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; + SSAInt uvoffset = upos * textureHeight + vpos; + + if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + return translation[color].load(true).zext_int(); + else + return translation[texturePixels[uvoffset].load(true).zext_int()].load(true).zext_int(); +} + +SSAVec4i DrawTriangleCodegen::Sample32(SSAInt *varying) +{ + if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + return SSAVec4i::unpack(color); + + SSAInt ufrac = varying[0] << 8; + SSAInt vfrac = varying[1] << 8; + + SSAVec4i nearest; + SSAVec4i linear; + + { + SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; + SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; + SSAInt uvoffset = upos * textureHeight + vpos; + + nearest = texturePixels[uvoffset * 4].load_vec4ub(true); + } + + return nearest; + + /* + { + SSAInt uone = (SSAInt(0x01000000) / textureWidth) << 8; + SSAInt vone = (SSAInt(0x01000000) / textureHeight) << 8; + + ufrac = ufrac - (uone >> 1); + vfrac = vfrac - (vone >> 1); + + SSAInt frac_x0 = (ufrac >> FRACBITS) * textureWidth; + SSAInt frac_x1 = ((ufrac + uone) >> FRACBITS) * textureWidth; + SSAInt frac_y0 = (vfrac >> FRACBITS) * textureHeight; + SSAInt frac_y1 = ((vfrac + vone) >> FRACBITS) * textureHeight; + + SSAInt x0 = frac_x0 >> FRACBITS; + SSAInt x1 = frac_x1 >> FRACBITS; + SSAInt y0 = frac_y0 >> FRACBITS; + SSAInt y1 = frac_y1 >> FRACBITS; + + SSAVec4i p00 = texturePixels[(x0 * textureHeight + y0) * 4].load_vec4ub(true); + SSAVec4i p01 = texturePixels[(x0 * textureHeight + y1) * 4].load_vec4ub(true); + SSAVec4i p10 = texturePixels[(x1 * textureHeight + y0) * 4].load_vec4ub(true); + SSAVec4i p11 = texturePixels[(x1 * textureHeight + y1) * 4].load_vec4ub(true); + + SSAInt inv_b = (frac_x1 >> (FRACBITS - 4)) & 15; + SSAInt inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; + SSAInt a = 16 - inv_a; + SSAInt b = 16 - inv_b; + + linear = (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; + } + + return AffineLinear.select(linear, nearest); + */ +} + +SSAInt DrawTriangleCodegen::Sample8(SSAInt *varying) +{ + SSAInt ufrac = varying[0] << 8; + SSAInt vfrac = varying[1] << 8; + + SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; + SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; + SSAInt uvoffset = upos * textureHeight + vpos; + + if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + return color; + else + return texturePixels[uvoffset].load(true).zext_int(); +} + +SSAInt DrawTriangleCodegen::Shade8(SSAInt c) +{ + return currentcolormap[c].load(true).zext_int(); +} + +SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) +{ + SSAVec4i fg; + SSAVec4i output; + + switch (blendmode) + { + default: + case TriBlendMode::Copy: + fg = Sample32(varying); + output = blend_copy(shade_bgra_simple(fg, currentlight)); + break; + case TriBlendMode::AlphaBlend: + fg = Sample32(varying); + output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); + break; + case TriBlendMode::AddSolid: + fg = Sample32(varying); + output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, destalpha); + break; + case TriBlendMode::Add: + fg = Sample32(varying); + output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; + case TriBlendMode::Sub: + fg = Sample32(varying); + output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; + case TriBlendMode::RevSub: + fg = Sample32(varying); + output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; + case TriBlendMode::Stencil: + fg = Sample32(varying); + output = blend_stencil(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), fg[3], bg, srcalpha, destalpha); + break; + case TriBlendMode::Shaded: + output = blend_stencil(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), Sample8(varying), bg, srcalpha, destalpha); + break; + case TriBlendMode::TranslateCopy: + fg = TranslateSample32(varying); + output = blend_copy(shade_bgra_simple(fg, currentlight)); + break; + case TriBlendMode::TranslateAlphaBlend: + fg = TranslateSample32(varying); + output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); + break; + case TriBlendMode::TranslateAdd: + fg = TranslateSample32(varying); + output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; + case TriBlendMode::TranslateSub: + fg = TranslateSample32(varying); + output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; + case TriBlendMode::TranslateRevSub: + fg = TranslateSample32(varying); + output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + break; + case TriBlendMode::AddSrcColorOneMinusSrcColor: + fg = Sample32(varying); + output = blend_add_srccolor_oneminussrccolor(shade_bgra_simple(fg, currentlight), bg); + break; + case TriBlendMode::Skycap: + fg = Sample32(varying); + output = FadeOut(varying[1], fg); + break; + } + + return output; +} + +SSAVec4i DrawTriangleCodegen::ToBgra(SSAInt index) +{ + SSAVec4i c = BaseColors[index * 4].load_vec4ub(true); + c = c.insert(3, 255); + return c; +} + +SSAInt DrawTriangleCodegen::ToPal8(SSAVec4i c) +{ + return RGB32k[((c[2] >> 3) * 32 + (c[1] >> 3)) * 32 + (c[0] >> 3)].load(true).zext_int(); +} + +SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) +{ + SSAVec4i fg; + SSAInt alpha, inv_alpha; + SSAInt output; + SSAInt palindex; + + switch (blendmode) + { + default: + case TriBlendMode::Copy: + output = Shade8(Sample8(varying)); + break; + case TriBlendMode::AlphaBlend: + palindex = Sample8(varying); + output = Shade8(palindex); + output = (palindex == SSAInt(0)).select(bg, output); + break; + case TriBlendMode::AddSolid: + palindex = Sample8(varying); + fg = ToBgra(Shade8(palindex)); + output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, destalpha)); + output = (palindex == SSAInt(0)).select(bg, output); + break; + case TriBlendMode::Add: + palindex = Sample8(varying); + fg = ToBgra(Shade8(palindex)); + output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + output = (palindex == SSAInt(0)).select(bg, output); + break; + case TriBlendMode::Sub: + palindex = Sample8(varying); + fg = ToBgra(Shade8(palindex)); + output = ToPal8(blend_sub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + output = (palindex == SSAInt(0)).select(bg, output); + break; + case TriBlendMode::RevSub: + palindex = Sample8(varying); + fg = ToBgra(Shade8(palindex)); + output = ToPal8(blend_revsub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + output = (palindex == SSAInt(0)).select(bg, output); + break; + case TriBlendMode::Stencil: + output = ToPal8(blend_stencil(ToBgra(Shade8(color)), (Sample8(varying) == SSAInt(0)).select(SSAInt(0), SSAInt(256)), ToBgra(bg), srcalpha, destalpha)); + break; + case TriBlendMode::Shaded: + palindex = Sample8(varying); + output = ToPal8(blend_stencil(ToBgra(Shade8(color)), palindex, ToBgra(bg), srcalpha, destalpha)); + break; + case TriBlendMode::TranslateCopy: + palindex = TranslateSample8(varying); + output = Shade8(palindex); + output = (palindex == SSAInt(0)).select(bg, output); + break; + case TriBlendMode::TranslateAlphaBlend: + palindex = TranslateSample8(varying); + output = Shade8(palindex); + output = (palindex == SSAInt(0)).select(bg, output); + break; + case TriBlendMode::TranslateAdd: + palindex = TranslateSample8(varying); + fg = ToBgra(Shade8(palindex)); + output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + output = (palindex == SSAInt(0)).select(bg, output); + break; + case TriBlendMode::TranslateSub: + palindex = TranslateSample8(varying); + fg = ToBgra(Shade8(palindex)); + output = ToPal8(blend_sub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + output = (palindex == SSAInt(0)).select(bg, output); + break; + case TriBlendMode::TranslateRevSub: + palindex = TranslateSample8(varying); + fg = ToBgra(Shade8(palindex)); + output = ToPal8(blend_revsub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); + output = (palindex == SSAInt(0)).select(bg, output); + break; + case TriBlendMode::AddSrcColorOneMinusSrcColor: + palindex = Sample8(varying); + fg = ToBgra(Shade8(palindex)); + output = ToPal8(blend_add_srccolor_oneminussrccolor(fg, ToBgra(bg))); + output = (palindex == SSAInt(0)).select(bg, output); + break; + case TriBlendMode::Skycap: + fg = ToBgra(Sample8(varying)); + output = ToPal8(FadeOut(varying[1], fg)); + break; + } + + return output; +} + +SSAVec4i DrawTriangleCodegen::FadeOut(SSAInt frac, SSAVec4i fg) +{ + int start_fade = 2; // How fast it should fade out + + SSAInt alpha_top = SSAInt::MAX(SSAInt::MIN(frac.ashr(16 - start_fade), SSAInt(256)), SSAInt(0)); + SSAInt alpha_bottom = SSAInt::MAX(SSAInt::MIN(((2 << 24) - frac).ashr(16 - start_fade), SSAInt(256)), SSAInt(0)); + SSAInt alpha = SSAInt::MIN(alpha_top, alpha_bottom); + SSAInt inv_alpha = 256 - alpha; + + fg = (fg * alpha + SSAVec4i::unpack(color) * inv_alpha) / 256; + return fg.insert(3, 255); +} + +void DrawTriangleCodegen::CalculateGradients() +{ + gradientX.W = FindGradientX(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + gradientY.W = FindGradientY(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); + start.W = v1.w + gradientX.W * (SSAFloat(startX) - v1.x) + gradientY.W * (SSAFloat(startY) - v1.y); + for (int i = 0; i < TriVertex::NumVarying; i++) + { + gradientX.Varying[i] = FindGradientX(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + gradientY.Varying[i] = FindGradientY(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); + start.Varying[i] = v1.varying[i] * v1.w + gradientX.Varying[i] * (SSAFloat(startX) - v1.x) + gradientY.Varying[i] * (SSAFloat(startY) - v1.y); + } + + shade = (64.0f - (SSAFloat(light * 255 / 256) + 12.0f) * 32.0f / 128.0f) / 32.0f; + globVis = SSAFloat(1706.0f); +} + +void DrawTriangleCodegen::LoadArgs(SSAValue args, SSAValue thread_data) +{ + destOrg = args[0][0].load(true); + pitch = args[0][1].load(true); + v1 = LoadTriVertex(args[0][2].load(true)); + v2 = LoadTriVertex(args[0][3].load(true)); + v3 = LoadTriVertex(args[0][4].load(true)); + texturePixels = args[0][9].load(true); + textureWidth = args[0][10].load(true); + textureHeight = args[0][11].load(true); + translation = args[0][12].load(true); + LoadUniforms(args[0][13].load(true)); + subsectorGBuffer = args[0][19].load(true); + if (!truecolor) + { + Colormaps = args[0][20].load(true); + RGB32k = args[0][21].load(true); + BaseColors = args[0][22].load(true); + } + + fullSpans = thread_data[0][5].load(true); + partialBlocks = thread_data[0][6].load(true); + numSpans = thread_data[0][7].load(true); + numBlocks = thread_data[0][8].load(true); + startX = thread_data[0][9].load(true); + startY = thread_data[0][10].load(true); +} + +SSATriVertex DrawTriangleCodegen::LoadTriVertex(SSAValue ptr) +{ + SSATriVertex v; + v.x = ptr[0][0].load(true); + v.y = ptr[0][1].load(true); + v.z = ptr[0][2].load(true); + v.w = ptr[0][3].load(true); + for (int i = 0; i < TriVertex::NumVarying; i++) + v.varying[i] = ptr[0][4 + i].load(true); + return v; +} + +void DrawTriangleCodegen::LoadUniforms(SSAValue uniforms) +{ + light = uniforms[0][0].load(true); + subsectorDepth = uniforms[0][1].load(true); + color = uniforms[0][2].load(true); + srcalpha = uniforms[0][3].load(true); + destalpha = uniforms[0][4].load(true); + + SSAShort light_alpha = uniforms[0][5].load(true); + SSAShort light_red = uniforms[0][6].load(true); + SSAShort light_green = uniforms[0][7].load(true); + SSAShort light_blue = uniforms[0][8].load(true); + SSAShort fade_alpha = uniforms[0][9].load(true); + SSAShort fade_red = uniforms[0][10].load(true); + SSAShort fade_green = uniforms[0][11].load(true); + SSAShort fade_blue = uniforms[0][12].load(true); + SSAShort desaturate = uniforms[0][13].load(true); + SSAInt flags = uniforms[0][14].load(true); + shade_constants.light = SSAVec4i(light_blue.zext_int(), light_green.zext_int(), light_red.zext_int(), light_alpha.zext_int()); + shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); + shade_constants.desaturate = desaturate.zext_int(); + + is_simple_shade = (flags & TriUniforms::simple_shade) == SSAInt(TriUniforms::simple_shade); + is_nearest_filter = (flags & TriUniforms::nearest_filter) == SSAInt(TriUniforms::nearest_filter); + is_fixed_light = (flags & TriUniforms::fixed_light) == SSAInt(TriUniforms::fixed_light); +} + +SSAFloat DrawTriangleCodegen::FindGradientX(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2) +{ + SSAFloat top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); + SSAFloat bottom = (x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2); + return top / bottom; +} + +SSAFloat DrawTriangleCodegen::FindGradientY(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2) +{ + SSAFloat top = (c1 - c2) * (x0 - x2) - (c0 - c2) * (x1 - x2); + SSAFloat bottom = (x0 - x2) * (y1 - y2) - (x1 - x2) * (y0 - y2); + return top / bottom; +} + + +#if 0 + void DrawTriangleCodegen::Generate(TriDrawVariant variant, TriBlendMode blendmode, bool truecolor, SSAValue args, SSAValue thread_data) { this->variant = variant; @@ -742,297 +1372,6 @@ void DrawTriangleCodegen::LoopMaskedStoreBlock() } #endif -SSAVec4i DrawTriangleCodegen::TranslateSample32(SSAInt *varying) -{ - SSAInt ufrac = varying[0] << 8; - SSAInt vfrac = varying[1] << 8; - - SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; - SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; - SSAInt uvoffset = upos * textureHeight + vpos; - - if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) - return translation[color * 4].load_vec4ub(true); - else - return translation[texturePixels[uvoffset].load(true).zext_int() * 4].load_vec4ub(true); -} - -SSAInt DrawTriangleCodegen::TranslateSample8(SSAInt *varying) -{ - SSAInt ufrac = varying[0] << 8; - SSAInt vfrac = varying[1] << 8; - - SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; - SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; - SSAInt uvoffset = upos * textureHeight + vpos; - - if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) - return translation[color].load(true).zext_int(); - else - return translation[texturePixels[uvoffset].load(true).zext_int()].load(true).zext_int(); -} - -SSAVec4i DrawTriangleCodegen::Sample32(SSAInt *varying) -{ - if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) - return SSAVec4i::unpack(color); - - SSAInt ufrac = varying[0] << 8; - SSAInt vfrac = varying[1] << 8; - - SSAVec4i nearest; - SSAVec4i linear; - - { - SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; - SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; - SSAInt uvoffset = upos * textureHeight + vpos; - - nearest = texturePixels[uvoffset * 4].load_vec4ub(true); - } - - { - SSAInt uone = (SSAInt(0x01000000) / textureWidth) << 8; - SSAInt vone = (SSAInt(0x01000000) / textureHeight) << 8; - - ufrac = ufrac - (uone >> 1); - vfrac = vfrac - (vone >> 1); - - SSAInt frac_x0 = (ufrac >> FRACBITS) * textureWidth; - SSAInt frac_x1 = ((ufrac + uone) >> FRACBITS) * textureWidth; - SSAInt frac_y0 = (vfrac >> FRACBITS) * textureHeight; - SSAInt frac_y1 = ((vfrac + vone) >> FRACBITS) * textureHeight; - - SSAInt x0 = frac_x0 >> FRACBITS; - SSAInt x1 = frac_x1 >> FRACBITS; - SSAInt y0 = frac_y0 >> FRACBITS; - SSAInt y1 = frac_y1 >> FRACBITS; - - SSAVec4i p00 = texturePixels[(x0 * textureHeight + y0) * 4].load_vec4ub(true); - SSAVec4i p01 = texturePixels[(x0 * textureHeight + y1) * 4].load_vec4ub(true); - SSAVec4i p10 = texturePixels[(x1 * textureHeight + y0) * 4].load_vec4ub(true); - SSAVec4i p11 = texturePixels[(x1 * textureHeight + y1) * 4].load_vec4ub(true); - - SSAInt inv_b = (frac_x1 >> (FRACBITS - 4)) & 15; - SSAInt inv_a = (frac_y1 >> (FRACBITS - 4)) & 15; - SSAInt a = 16 - inv_a; - SSAInt b = 16 - inv_b; - - linear = (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; - } - - return AffineLinear.select(linear, nearest); -} - -SSAInt DrawTriangleCodegen::Sample8(SSAInt *varying) -{ - SSAInt ufrac = varying[0] << 8; - SSAInt vfrac = varying[1] << 8; - - SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16; - SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; - SSAInt uvoffset = upos * textureHeight + vpos; - - if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) - return color; - else - return texturePixels[uvoffset].load(true).zext_int(); -} - -SSAInt DrawTriangleCodegen::Shade8(SSAInt c) -{ - return currentcolormap[c].load(true).zext_int(); -} - -SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) -{ - SSAVec4i fg; - SSAVec4i output; - - switch (blendmode) - { - default: - case TriBlendMode::Copy: - fg = Sample32(varying); - output = blend_copy(shade_bgra_simple(fg, currentlight)); - break; - case TriBlendMode::AlphaBlend: - fg = Sample32(varying); - output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); - break; - case TriBlendMode::AddSolid: - fg = Sample32(varying); - output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, destalpha); - break; - case TriBlendMode::Add: - fg = Sample32(varying); - output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); - break; - case TriBlendMode::Sub: - fg = Sample32(varying); - output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); - break; - case TriBlendMode::RevSub: - fg = Sample32(varying); - output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); - break; - case TriBlendMode::Stencil: - fg = Sample32(varying); - output = blend_stencil(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), fg[3], bg, srcalpha, destalpha); - break; - case TriBlendMode::Shaded: - output = blend_stencil(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), Sample8(varying), bg, srcalpha, destalpha); - break; - case TriBlendMode::TranslateCopy: - fg = TranslateSample32(varying); - output = blend_copy(shade_bgra_simple(fg, currentlight)); - break; - case TriBlendMode::TranslateAlphaBlend: - fg = TranslateSample32(varying); - output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); - break; - case TriBlendMode::TranslateAdd: - fg = TranslateSample32(varying); - output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); - break; - case TriBlendMode::TranslateSub: - fg = TranslateSample32(varying); - output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); - break; - case TriBlendMode::TranslateRevSub: - fg = TranslateSample32(varying); - output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); - break; - case TriBlendMode::AddSrcColorOneMinusSrcColor: - fg = Sample32(varying); - output = blend_add_srccolor_oneminussrccolor(shade_bgra_simple(fg, currentlight), bg); - break; - case TriBlendMode::Skycap: - fg = Sample32(varying); - output = FadeOut(varying[1], fg); - break; - } - - return output; -} - -SSAVec4i DrawTriangleCodegen::ToBgra(SSAInt index) -{ - SSAVec4i c = BaseColors[index * 4].load_vec4ub(true); - c = c.insert(3, 255); - return c; -} - -SSAInt DrawTriangleCodegen::ToPal8(SSAVec4i c) -{ - return RGB32k[((c[2] >> 3) * 32 + (c[1] >> 3)) * 32 + (c[0] >> 3)].load(true).zext_int(); -} - -SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) -{ - SSAVec4i fg; - SSAInt alpha, inv_alpha; - SSAInt output; - SSAInt palindex; - - switch (blendmode) - { - default: - case TriBlendMode::Copy: - output = Shade8(Sample8(varying)); - break; - case TriBlendMode::AlphaBlend: - palindex = Sample8(varying); - output = Shade8(palindex); - output = (palindex == SSAInt(0)).select(bg, output); - break; - case TriBlendMode::AddSolid: - palindex = Sample8(varying); - fg = ToBgra(Shade8(palindex)); - output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, destalpha)); - output = (palindex == SSAInt(0)).select(bg, output); - break; - case TriBlendMode::Add: - palindex = Sample8(varying); - fg = ToBgra(Shade8(palindex)); - output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); - output = (palindex == SSAInt(0)).select(bg, output); - break; - case TriBlendMode::Sub: - palindex = Sample8(varying); - fg = ToBgra(Shade8(palindex)); - output = ToPal8(blend_sub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); - output = (palindex == SSAInt(0)).select(bg, output); - break; - case TriBlendMode::RevSub: - palindex = Sample8(varying); - fg = ToBgra(Shade8(palindex)); - output = ToPal8(blend_revsub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); - output = (palindex == SSAInt(0)).select(bg, output); - break; - case TriBlendMode::Stencil: - output = ToPal8(blend_stencil(ToBgra(Shade8(color)), (Sample8(varying) == SSAInt(0)).select(SSAInt(0), SSAInt(256)), ToBgra(bg), srcalpha, destalpha)); - break; - case TriBlendMode::Shaded: - palindex = Sample8(varying); - output = ToPal8(blend_stencil(ToBgra(Shade8(color)), palindex, ToBgra(bg), srcalpha, destalpha)); - break; - case TriBlendMode::TranslateCopy: - palindex = TranslateSample8(varying); - output = Shade8(palindex); - output = (palindex == SSAInt(0)).select(bg, output); - break; - case TriBlendMode::TranslateAlphaBlend: - palindex = TranslateSample8(varying); - output = Shade8(palindex); - output = (palindex == SSAInt(0)).select(bg, output); - break; - case TriBlendMode::TranslateAdd: - palindex = TranslateSample8(varying); - fg = ToBgra(Shade8(palindex)); - output = ToPal8(blend_add(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); - output = (palindex == SSAInt(0)).select(bg, output); - break; - case TriBlendMode::TranslateSub: - palindex = TranslateSample8(varying); - fg = ToBgra(Shade8(palindex)); - output = ToPal8(blend_sub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); - output = (palindex == SSAInt(0)).select(bg, output); - break; - case TriBlendMode::TranslateRevSub: - palindex = TranslateSample8(varying); - fg = ToBgra(Shade8(palindex)); - output = ToPal8(blend_revsub(fg, ToBgra(bg), srcalpha, calc_blend_bgalpha(fg, destalpha))); - output = (palindex == SSAInt(0)).select(bg, output); - break; - case TriBlendMode::AddSrcColorOneMinusSrcColor: - palindex = Sample8(varying); - fg = ToBgra(Shade8(palindex)); - output = ToPal8(blend_add_srccolor_oneminussrccolor(fg, ToBgra(bg))); - output = (palindex == SSAInt(0)).select(bg, output); - break; - case TriBlendMode::Skycap: - fg = ToBgra(Sample8(varying)); - output = ToPal8(FadeOut(varying[1], fg)); - break; - } - - return output; -} - -SSAVec4i DrawTriangleCodegen::FadeOut(SSAInt frac, SSAVec4i fg) -{ - int start_fade = 2; // How fast it should fade out - - SSAInt alpha_top = SSAInt::MAX(SSAInt::MIN(frac.ashr(16 - start_fade), SSAInt(256)), SSAInt(0)); - SSAInt alpha_bottom = SSAInt::MAX(SSAInt::MIN(((2 << 24) - frac).ashr(16 - start_fade), SSAInt(256)), SSAInt(0)); - SSAInt alpha = SSAInt::MIN(alpha_top, alpha_bottom); - SSAInt inv_alpha = 256 - alpha; - - fg = (fg * alpha + SSAVec4i::unpack(color) * inv_alpha) / 256; - return fg.insert(3, 255); -} - void DrawTriangleCodegen::SetStencilBlock(SSAInt block) { StencilBlock = stencilValues[block * 64]; @@ -1087,41 +1426,4 @@ void DrawTriangleCodegen::LoadArgs(SSAValue args, SSAValue thread_data) thread.pass_end_y = SSAInt(32000); } -SSATriVertex DrawTriangleCodegen::LoadTriVertex(SSAValue ptr) -{ - SSATriVertex v; - v.x = ptr[0][0].load(true); - v.y = ptr[0][1].load(true); - v.z = ptr[0][2].load(true); - v.w = ptr[0][3].load(true); - for (int i = 0; i < TriVertex::NumVarying; i++) - v.varying[i] = ptr[0][4 + i].load(true); - return v; -} - -void DrawTriangleCodegen::LoadUniforms(SSAValue uniforms) -{ - light = uniforms[0][0].load(true); - subsectorDepth = uniforms[0][1].load(true); - color = uniforms[0][2].load(true); - srcalpha = uniforms[0][3].load(true); - destalpha = uniforms[0][4].load(true); - - SSAShort light_alpha = uniforms[0][5].load(true); - SSAShort light_red = uniforms[0][6].load(true); - SSAShort light_green = uniforms[0][7].load(true); - SSAShort light_blue = uniforms[0][8].load(true); - SSAShort fade_alpha = uniforms[0][9].load(true); - SSAShort fade_red = uniforms[0][10].load(true); - SSAShort fade_green = uniforms[0][11].load(true); - SSAShort fade_blue = uniforms[0][12].load(true); - SSAShort desaturate = uniforms[0][13].load(true); - SSAInt flags = uniforms[0][14].load(true); - shade_constants.light = SSAVec4i(light_blue.zext_int(), light_green.zext_int(), light_red.zext_int(), light_alpha.zext_int()); - shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); - shade_constants.desaturate = desaturate.zext_int(); - - is_simple_shade = (flags & TriUniforms::simple_shade) == SSAInt(TriUniforms::simple_shade); - is_nearest_filter = (flags & TriUniforms::nearest_filter) == SSAInt(TriUniforms::nearest_filter); - is_fixed_light = (flags & TriUniforms::fixed_light) == SSAInt(TriUniforms::fixed_light); -} +#endif diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.h b/tools/drawergen/fixedfunction/drawtrianglecodegen.h index 81a5e57d2..02db1451c 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.h +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.h @@ -30,6 +30,91 @@ struct SSATriVertex SSAFloat varying[TriVertex::NumVarying]; }; +struct SSAStepVariables +{ + SSAFloat W; + SSAFloat Varying[TriVertex::NumVarying]; +}; + +class DrawTriangleCodegen : public DrawerCodegen +{ +public: + void Generate(TriDrawVariant variant, TriBlendMode blendmode, bool truecolor, SSAValue args, SSAValue thread_data); + +private: + void LoadArgs(SSAValue args, SSAValue thread_data); + SSATriVertex LoadTriVertex(SSAValue v); + void LoadUniforms(SSAValue uniforms); + void CalculateGradients(); + SSAFloat FindGradientX(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2); + SSAFloat FindGradientY(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2); + void DrawFullSpans(); + void DrawPartialBlocks(); + + SSAVec4i ProcessPixel32(SSAVec4i bg, SSAInt *varying); + SSAInt ProcessPixel8(SSAInt bg, SSAInt *varying); + SSAVec4i TranslateSample32(SSAInt *varying); + SSAInt TranslateSample8(SSAInt *varying); + SSAVec4i Sample32(SSAInt *varying); + SSAInt Sample8(SSAInt *varying); + SSAInt Shade8(SSAInt c); + SSAVec4i ToBgra(SSAInt index); + SSAInt ToPal8(SSAVec4i c); + SSAVec4i FadeOut(SSAInt frac, SSAVec4i color); + + SSAStack stack_i, stack_y, stack_x; + SSAStack stack_posYW, stack_posXW; + SSAStack stack_posYVarying[TriVertex::NumVarying]; + SSAStack stack_posXVarying[TriVertex::NumVarying]; + SSAStack stack_varyingPos[TriVertex::NumVarying]; + SSAStack stack_lightpos; + SSAStack stack_dest; + SSAStack stack_subsector; + + SSAStepVariables gradientX, gradientY, start; + SSAFloat shade, globVis; + + SSAInt currentlight; + SSAUBytePtr currentcolormap; + + SSAUBytePtr destOrg; + SSAIntPtr subsectorGBuffer; + SSAInt pitch; + SSATriVertex v1; + SSATriVertex v2; + SSATriVertex v3; + SSAUBytePtr texturePixels; + SSAInt textureWidth; + SSAInt textureHeight; + SSAUBytePtr translation; + SSAInt color, srcalpha, destalpha; + + SSAInt light; + SSAInt subsectorDepth; + SSAShadeConstants shade_constants; + SSABool is_simple_shade; + SSABool is_nearest_filter; + SSABool is_fixed_light; + + SSAUBytePtr Colormaps; + SSAUBytePtr RGB32k; + SSAUBytePtr BaseColors; + + SSAInt numSpans; + SSAInt numBlocks; + SSAInt startX; + SSAInt startY; + SSAValue fullSpans; // TriFullSpan[] + SSAValue partialBlocks; // TriPartialBlock[] + + TriDrawVariant variant; + TriBlendMode blendmode; + bool truecolor; + int pixelsize; +}; + +#if 0 + class DrawTriangleCodegen : public DrawerCodegen { public: @@ -154,3 +239,5 @@ private: SSAUBytePtr StencilBlock; SSAIntPtr StencilBlockMask; }; + +#endif diff --git a/tools/drawergen/llvmdrawers.cpp b/tools/drawergen/llvmdrawers.cpp index 49eeb5a46..83f1b1416 100644 --- a/tools/drawergen/llvmdrawers.cpp +++ b/tools/drawergen/llvmdrawers.cpp @@ -204,6 +204,9 @@ void LLVMDrawers::CodegenDrawTriangle(const std::string &name, TriDrawVariant va llvm::Type *LLVMDrawers::GetDrawColumnArgsStruct(llvm::LLVMContext &context) { + if (DrawColumnArgsStruct) + return DrawColumnArgsStruct; + std::vector elements; elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint32_t *dest; elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source; @@ -233,11 +236,15 @@ llvm::Type *LLVMDrawers::GetDrawColumnArgsStruct(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - return llvm::StructType::create(context, elements, "DrawColumnArgs", false)->getPointerTo(); + DrawColumnArgsStruct = llvm::StructType::create(context, elements, "DrawColumnArgs", false)->getPointerTo(); + return DrawColumnArgsStruct; } llvm::Type *LLVMDrawers::GetDrawSpanArgsStruct(llvm::LLVMContext &context) { + if (DrawSpanArgsStruct) + return DrawSpanArgsStruct; + std::vector elements; elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *destorg; elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source; @@ -264,11 +271,15 @@ llvm::Type *LLVMDrawers::GetDrawSpanArgsStruct(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - return llvm::StructType::create(context, elements, "DrawSpanArgs", false)->getPointerTo(); + DrawSpanArgsStruct = llvm::StructType::create(context, elements, "DrawSpanArgs", false)->getPointerTo(); + return DrawSpanArgsStruct; } llvm::Type *LLVMDrawers::GetDrawWallArgsStruct(llvm::LLVMContext &context) { + if (DrawWallArgsStruct) + return DrawWallArgsStruct; + std::vector elements; elements.push_back(llvm::Type::getInt8PtrTy(context)); for (int i = 0; i < 8; i++) @@ -285,47 +296,71 @@ llvm::Type *LLVMDrawers::GetDrawWallArgsStruct(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; - return llvm::StructType::create(context, elements, "DrawWallArgs", false)->getPointerTo(); + DrawWallArgsStruct = llvm::StructType::create(context, elements, "DrawWallArgs", false)->getPointerTo(); + return DrawWallArgsStruct; } llvm::Type *LLVMDrawers::GetDrawSkyArgsStruct(llvm::LLVMContext &context) { + if (DrawSkyArgsStruct) + return DrawSkyArgsStruct; + std::vector elements; elements.push_back(llvm::Type::getInt8PtrTy(context)); for (int i = 0; i < 8; i++) elements.push_back(llvm::Type::getInt8PtrTy(context)); for (int i = 0; i < 15; i++) elements.push_back(llvm::Type::getInt32Ty(context)); - return llvm::StructType::create(context, elements, "DrawSkyArgs", false)->getPointerTo(); + DrawSkyArgsStruct = llvm::StructType::create(context, elements, "DrawSkyArgs", false)->getPointerTo(); + return DrawSkyArgsStruct; } llvm::Type *LLVMDrawers::GetWorkerThreadDataStruct(llvm::LLVMContext &context) { + if (WorkerThreadDataStruct) + return WorkerThreadDataStruct; + std::vector elements; for (int i = 0; i < 4; i++) elements.push_back(llvm::Type::getInt32Ty(context)); elements.push_back(llvm::Type::getInt8PtrTy(context)); - return llvm::StructType::create(context, elements, "ThreadData", false)->getPointerTo(); + elements.push_back(GetTriFullSpanStruct(context)); + elements.push_back(GetTriPartialBlockStruct(context)); + for (int i = 0; i < 4; i++) + elements.push_back(llvm::Type::getInt32Ty(context)); + WorkerThreadDataStruct = llvm::StructType::create(context, elements, "ThreadData", false)->getPointerTo(); + return WorkerThreadDataStruct; } llvm::Type *LLVMDrawers::GetTriVertexStruct(llvm::LLVMContext &context) { + if (TriVertexStruct) + return TriVertexStruct; + std::vector elements; for (int i = 0; i < 4 + TriVertex::NumVarying; i++) elements.push_back(llvm::Type::getFloatTy(context)); - return llvm::StructType::create(context, elements, "TriVertex", false)->getPointerTo(); + TriVertexStruct = llvm::StructType::create(context, elements, "TriVertex", false)->getPointerTo(); + return TriVertexStruct; } llvm::Type *LLVMDrawers::GetTriMatrixStruct(llvm::LLVMContext &context) { + if (TriMatrixStruct) + return TriMatrixStruct; + std::vector elements; for (int i = 0; i < 4 * 4; i++) elements.push_back(llvm::Type::getFloatTy(context)); - return llvm::StructType::create(context, elements, "TriMatrix", false)->getPointerTo(); + TriMatrixStruct = llvm::StructType::create(context, elements, "TriMatrix", false)->getPointerTo(); + return TriMatrixStruct; } llvm::Type *LLVMDrawers::GetTriUniformsStruct(llvm::LLVMContext &context) { + if (TriUniformsStruct) + return TriUniformsStruct; + std::vector elements; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t subsectorDepth; @@ -343,11 +378,42 @@ llvm::Type *LLVMDrawers::GetTriUniformsStruct(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; elements.push_back(GetTriMatrixStruct(context)); // TriMatrix objectToClip - return llvm::StructType::create(context, elements, "TriUniforms", false)->getPointerTo(); + TriUniformsStruct = llvm::StructType::create(context, elements, "TriUniforms", false)->getPointerTo(); + return TriUniformsStruct; +} + +llvm::Type *LLVMDrawers::GetTriFullSpanStruct(llvm::LLVMContext &context) +{ + if (TriFullSpanStruct) + return TriFullSpanStruct; + + std::vector elements; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint32_t X; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint32_t Y; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t Length; + TriFullSpanStruct = llvm::StructType::create(context, elements, "TriFullSpan", false)->getPointerTo(); + return TriFullSpanStruct; +} + +llvm::Type *LLVMDrawers::GetTriPartialBlockStruct(llvm::LLVMContext &context) +{ + if (TriPartialBlockStruct) + return TriPartialBlockStruct; + + std::vector elements; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint32_t X; + elements.push_back(llvm::Type::getInt16Ty(context)); // uint32_t Y; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t Mask0; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t Mask1; + TriPartialBlockStruct = llvm::StructType::create(context, elements, "TriPartialBlock", false)->getPointerTo(); + return TriPartialBlockStruct; } llvm::Type *LLVMDrawers::GetTriDrawTriangleArgs(llvm::LLVMContext &context) { + if (TriDrawTriangleArgs) + return TriDrawTriangleArgs; + std::vector elements; elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *dest; elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t pitch; @@ -372,5 +438,6 @@ llvm::Type *LLVMDrawers::GetTriDrawTriangleArgs(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *colormaps; elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *RGB32k; elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *BaseColors; - return llvm::StructType::create(context, elements, "TriDrawTriangle", false)->getPointerTo(); + TriDrawTriangleArgs = llvm::StructType::create(context, elements, "TriDrawTriangle", false)->getPointerTo(); + return TriDrawTriangleArgs; } diff --git a/tools/drawergen/llvmdrawers.h b/tools/drawergen/llvmdrawers.h index 3eef605df..df6078f4d 100644 --- a/tools/drawergen/llvmdrawers.h +++ b/tools/drawergen/llvmdrawers.h @@ -53,15 +53,29 @@ private: void CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns); void CodegenDrawTriangle(const std::string &name, TriDrawVariant variant, TriBlendMode blendmode, bool truecolor); - static llvm::Type *GetDrawColumnArgsStruct(llvm::LLVMContext &context); - static llvm::Type *GetDrawSpanArgsStruct(llvm::LLVMContext &context); - static llvm::Type *GetDrawWallArgsStruct(llvm::LLVMContext &context); - static llvm::Type *GetDrawSkyArgsStruct(llvm::LLVMContext &context); - static llvm::Type *GetWorkerThreadDataStruct(llvm::LLVMContext &context); - static llvm::Type *GetTriVertexStruct(llvm::LLVMContext &context); - static llvm::Type *GetTriMatrixStruct(llvm::LLVMContext &context); - static llvm::Type *GetTriUniformsStruct(llvm::LLVMContext &context); - static llvm::Type *GetTriDrawTriangleArgs(llvm::LLVMContext &context); + llvm::Type *GetDrawColumnArgsStruct(llvm::LLVMContext &context); + llvm::Type *GetDrawSpanArgsStruct(llvm::LLVMContext &context); + llvm::Type *GetDrawWallArgsStruct(llvm::LLVMContext &context); + llvm::Type *GetDrawSkyArgsStruct(llvm::LLVMContext &context); + llvm::Type *GetWorkerThreadDataStruct(llvm::LLVMContext &context); + llvm::Type *GetTriVertexStruct(llvm::LLVMContext &context); + llvm::Type *GetTriMatrixStruct(llvm::LLVMContext &context); + llvm::Type *GetTriUniformsStruct(llvm::LLVMContext &context); + llvm::Type *GetTriFullSpanStruct(llvm::LLVMContext &context); + llvm::Type *GetTriPartialBlockStruct(llvm::LLVMContext &context); + llvm::Type *GetTriDrawTriangleArgs(llvm::LLVMContext &context); + + llvm::Type *DrawColumnArgsStruct = nullptr; + llvm::Type *DrawSpanArgsStruct = nullptr; + llvm::Type *DrawWallArgsStruct = nullptr; + llvm::Type *DrawSkyArgsStruct = nullptr; + llvm::Type *WorkerThreadDataStruct = nullptr; + llvm::Type *TriVertexStruct = nullptr; + llvm::Type *TriMatrixStruct = nullptr; + llvm::Type *TriUniformsStruct = nullptr; + llvm::Type *TriFullSpanStruct = nullptr; + llvm::Type *TriPartialBlockStruct = nullptr; + llvm::Type *TriDrawTriangleArgs = nullptr; LLVMProgram mProgram; std::string mNamePostfix; From 823dc6ea00205e339629339d80a040b5c6d1656e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 15 Dec 2016 02:39:55 +0100 Subject: [PATCH 1411/1509] Clamp RGB values in pal mode --- tools/drawergen/fixedfunction/drawtrianglecodegen.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index f38b42350..f1cd25c35 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -454,7 +454,10 @@ SSAVec4i DrawTriangleCodegen::ToBgra(SSAInt index) SSAInt DrawTriangleCodegen::ToPal8(SSAVec4i c) { - return RGB32k[((c[2] >> 3) * 32 + (c[1] >> 3)) * 32 + (c[0] >> 3)].load(true).zext_int(); + SSAInt red = SSAInt::clamp(c[0], SSAInt(0), SSAInt(255)); + SSAInt green = SSAInt::clamp(c[1], SSAInt(0), SSAInt(255)); + SSAInt blue = SSAInt::clamp(c[2], SSAInt(0), SSAInt(255)); + return RGB32k[((blue >> 3) * 32 + (green >> 3)) * 32 + (red >> 3)].load(true).zext_int(); } SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) From 99435f5018c95e3972a566acb161c5229a508b05 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 15 Dec 2016 23:29:31 +0100 Subject: [PATCH 1412/1509] Remove TriDrawVariant from LLVM codegen --- src/r_drawers.cpp | 364 ++++++------------ src/r_drawers.h | 14 +- src/r_poly_triangle.cpp | 78 ++-- src/r_poly_triangle.h | 5 +- .../fixedfunction/drawtrianglecodegen.cpp | 31 +- .../fixedfunction/drawtrianglecodegen.h | 11 +- tools/drawergen/llvmdrawers.cpp | 20 +- tools/drawergen/llvmdrawers.h | 2 +- 8 files changed, 189 insertions(+), 336 deletions(-) diff --git a/src/r_drawers.cpp b/src/r_drawers.cpp index acbe71de4..dd81af109 100644 --- a/src/r_drawers.cpp +++ b/src/r_drawers.cpp @@ -93,128 +93,66 @@ extern "C" void DrawSky4_SSE2(const DrawSkyArgs *, const WorkerThreadData *); void DrawDoubleSky1_SSE2(const DrawSkyArgs *, const WorkerThreadData *); void DrawDoubleSky4_SSE2(const DrawSkyArgs *, const WorkerThreadData *); - void TriDrawNormal8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal8_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal8_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal8_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal8_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal8_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal8_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal8_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal8_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal8_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawNormal32_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal8_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillNormal32_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector8_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriDrawSubsector32_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector8_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriFillSubsector32_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriStencil_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); - void TriStencilClose_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw8_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriDraw32_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill8_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_3_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_4_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_5_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_6_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_7_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_8_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_9_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_10_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); + void TriFill32_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *); } ///////////////////////////////////////////////////////////////////////////// @@ -283,128 +221,66 @@ Drawers::Drawers() DrawSky4 = DrawSky4_SSE2; DrawDoubleSky1 = DrawDoubleSky1_SSE2; DrawDoubleSky4 = DrawDoubleSky4_SSE2; - TriDrawNormal8.push_back(TriDrawNormal8_0_SSE2); - TriDrawNormal8.push_back(TriDrawNormal8_1_SSE2); - TriDrawNormal8.push_back(TriDrawNormal8_2_SSE2); - TriDrawNormal8.push_back(TriDrawNormal8_3_SSE2); - TriDrawNormal8.push_back(TriDrawNormal8_4_SSE2); - TriDrawNormal8.push_back(TriDrawNormal8_5_SSE2); - TriDrawNormal8.push_back(TriDrawNormal8_6_SSE2); - TriDrawNormal8.push_back(TriDrawNormal8_7_SSE2); - TriDrawNormal8.push_back(TriDrawNormal8_8_SSE2); - TriDrawNormal8.push_back(TriDrawNormal8_9_SSE2); - TriDrawNormal8.push_back(TriDrawNormal8_10_SSE2); - TriDrawNormal8.push_back(TriDrawNormal8_11_SSE2); - TriDrawNormal8.push_back(TriDrawNormal8_12_SSE2); - TriDrawNormal8.push_back(TriDrawNormal8_13_SSE2); - TriDrawNormal8.push_back(TriDrawNormal8_14_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_0_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_1_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_2_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_3_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_4_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_5_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_6_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_7_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_8_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_9_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_10_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_11_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_12_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_13_SSE2); - TriDrawNormal32.push_back(TriDrawNormal32_14_SSE2); - TriFillNormal8.push_back(TriFillNormal8_0_SSE2); - TriFillNormal8.push_back(TriFillNormal8_1_SSE2); - TriFillNormal8.push_back(TriFillNormal8_2_SSE2); - TriFillNormal8.push_back(TriFillNormal8_3_SSE2); - TriFillNormal8.push_back(TriFillNormal8_4_SSE2); - TriFillNormal8.push_back(TriFillNormal8_5_SSE2); - TriFillNormal8.push_back(TriFillNormal8_6_SSE2); - TriFillNormal8.push_back(TriFillNormal8_7_SSE2); - TriFillNormal8.push_back(TriFillNormal8_8_SSE2); - TriFillNormal8.push_back(TriFillNormal8_9_SSE2); - TriFillNormal8.push_back(TriFillNormal8_10_SSE2); - TriFillNormal8.push_back(TriFillNormal8_11_SSE2); - TriFillNormal8.push_back(TriFillNormal8_12_SSE2); - TriFillNormal8.push_back(TriFillNormal8_13_SSE2); - TriFillNormal8.push_back(TriFillNormal8_14_SSE2); - TriFillNormal32.push_back(TriFillNormal32_0_SSE2); - TriFillNormal32.push_back(TriFillNormal32_1_SSE2); - TriFillNormal32.push_back(TriFillNormal32_2_SSE2); - TriFillNormal32.push_back(TriFillNormal32_3_SSE2); - TriFillNormal32.push_back(TriFillNormal32_4_SSE2); - TriFillNormal32.push_back(TriFillNormal32_5_SSE2); - TriFillNormal32.push_back(TriFillNormal32_6_SSE2); - TriFillNormal32.push_back(TriFillNormal32_7_SSE2); - TriFillNormal32.push_back(TriFillNormal32_8_SSE2); - TriFillNormal32.push_back(TriFillNormal32_9_SSE2); - TriFillNormal32.push_back(TriFillNormal32_10_SSE2); - TriFillNormal32.push_back(TriFillNormal32_11_SSE2); - TriFillNormal32.push_back(TriFillNormal32_12_SSE2); - TriFillNormal32.push_back(TriFillNormal32_13_SSE2); - TriFillNormal32.push_back(TriFillNormal32_14_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_0_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_1_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_2_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_3_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_4_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_5_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_6_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_7_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_8_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_9_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_10_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_11_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_12_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_13_SSE2); - TriDrawSubsector8.push_back(TriDrawSubsector8_14_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_0_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_1_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_2_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_3_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_4_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_5_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_6_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_7_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_8_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_9_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_10_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_11_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_12_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_13_SSE2); - TriDrawSubsector32.push_back(TriDrawSubsector32_14_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_0_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_1_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_2_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_3_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_4_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_5_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_6_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_7_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_8_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_9_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_10_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_11_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_12_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_13_SSE2); - TriFillSubsector8.push_back(TriFillSubsector8_14_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_0_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_1_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_2_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_3_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_4_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_5_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_6_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_7_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_8_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_9_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_10_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_11_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_12_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_13_SSE2); - TriFillSubsector32.push_back(TriFillSubsector32_14_SSE2); - TriStencil = TriStencil_SSE2; - TriStencilClose = TriStencilClose_SSE2; + TriDraw8.push_back(TriDraw8_0_SSE2); + TriDraw8.push_back(TriDraw8_1_SSE2); + TriDraw8.push_back(TriDraw8_2_SSE2); + TriDraw8.push_back(TriDraw8_3_SSE2); + TriDraw8.push_back(TriDraw8_4_SSE2); + TriDraw8.push_back(TriDraw8_5_SSE2); + TriDraw8.push_back(TriDraw8_6_SSE2); + TriDraw8.push_back(TriDraw8_7_SSE2); + TriDraw8.push_back(TriDraw8_8_SSE2); + TriDraw8.push_back(TriDraw8_9_SSE2); + TriDraw8.push_back(TriDraw8_10_SSE2); + TriDraw8.push_back(TriDraw8_11_SSE2); + TriDraw8.push_back(TriDraw8_12_SSE2); + TriDraw8.push_back(TriDraw8_13_SSE2); + TriDraw8.push_back(TriDraw8_14_SSE2); + TriDraw32.push_back(TriDraw32_0_SSE2); + TriDraw32.push_back(TriDraw32_1_SSE2); + TriDraw32.push_back(TriDraw32_2_SSE2); + TriDraw32.push_back(TriDraw32_3_SSE2); + TriDraw32.push_back(TriDraw32_4_SSE2); + TriDraw32.push_back(TriDraw32_5_SSE2); + TriDraw32.push_back(TriDraw32_6_SSE2); + TriDraw32.push_back(TriDraw32_7_SSE2); + TriDraw32.push_back(TriDraw32_8_SSE2); + TriDraw32.push_back(TriDraw32_9_SSE2); + TriDraw32.push_back(TriDraw32_10_SSE2); + TriDraw32.push_back(TriDraw32_11_SSE2); + TriDraw32.push_back(TriDraw32_12_SSE2); + TriDraw32.push_back(TriDraw32_13_SSE2); + TriDraw32.push_back(TriDraw32_14_SSE2); + TriFill8.push_back(TriFill8_0_SSE2); + TriFill8.push_back(TriFill8_1_SSE2); + TriFill8.push_back(TriFill8_2_SSE2); + TriFill8.push_back(TriFill8_3_SSE2); + TriFill8.push_back(TriFill8_4_SSE2); + TriFill8.push_back(TriFill8_5_SSE2); + TriFill8.push_back(TriFill8_6_SSE2); + TriFill8.push_back(TriFill8_7_SSE2); + TriFill8.push_back(TriFill8_8_SSE2); + TriFill8.push_back(TriFill8_9_SSE2); + TriFill8.push_back(TriFill8_10_SSE2); + TriFill8.push_back(TriFill8_11_SSE2); + TriFill8.push_back(TriFill8_12_SSE2); + TriFill8.push_back(TriFill8_13_SSE2); + TriFill8.push_back(TriFill8_14_SSE2); + TriFill32.push_back(TriFill32_0_SSE2); + TriFill32.push_back(TriFill32_1_SSE2); + TriFill32.push_back(TriFill32_2_SSE2); + TriFill32.push_back(TriFill32_3_SSE2); + TriFill32.push_back(TriFill32_4_SSE2); + TriFill32.push_back(TriFill32_5_SSE2); + TriFill32.push_back(TriFill32_6_SSE2); + TriFill32.push_back(TriFill32_7_SSE2); + TriFill32.push_back(TriFill32_8_SSE2); + TriFill32.push_back(TriFill32_9_SSE2); + TriFill32.push_back(TriFill32_10_SSE2); + TriFill32.push_back(TriFill32_11_SSE2); + TriFill32.push_back(TriFill32_12_SSE2); + TriFill32.push_back(TriFill32_13_SSE2); + TriFill32.push_back(TriFill32_14_SSE2); } Drawers *Drawers::Instance() diff --git a/src/r_drawers.h b/src/r_drawers.h index bc776be5b..543796609 100644 --- a/src/r_drawers.h +++ b/src/r_drawers.h @@ -354,16 +354,10 @@ public: void(*DrawDoubleSky1)(const DrawSkyArgs *, const WorkerThreadData *) = nullptr; void(*DrawDoubleSky4)(const DrawSkyArgs *, const WorkerThreadData *) = nullptr; - std::vector TriDrawNormal8; - std::vector TriDrawNormal32; - std::vector TriFillNormal8; - std::vector TriFillNormal32; - std::vector TriDrawSubsector8; - std::vector TriDrawSubsector32; - std::vector TriFillSubsector8; - std::vector TriFillSubsector32; - void(*TriStencil)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; - void(*TriStencilClose)(const TriDrawTriangleArgs *, WorkerThreadData *) = nullptr; + std::vector TriDraw8; + std::vector TriDraw32; + std::vector TriFill8; + std::vector TriFill32; private: Drawers(); diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 164fc98e2..90f78b639 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -88,19 +88,48 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian return; auto llvm = Drawers::Instance(); - PolyDrawFuncPtr setupfunc = nullptr; - PolyDrawFuncPtr drawfunc = nullptr; + + PolyDrawFuncPtr drawfuncs[3]; + int num_drawfuncs = 0; + int bmode = (int)blendmode; switch (variant) { + case TriDrawVariant::DrawNormal: + drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupNormal; + drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriDraw32[bmode] : llvm->TriDraw8[bmode]; + drawfuncs[num_drawfuncs++] = &ScreenTriangle::SubsectorWrite; + break; + + case TriDrawVariant::FillNormal: + drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupNormal; + drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriFill32[bmode] : llvm->TriFill8[bmode]; + drawfuncs[num_drawfuncs++] = &ScreenTriangle::SubsectorWrite; + break; + + case TriDrawVariant::DrawSubsector: + drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupSubsector; + drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriDraw32[bmode] : llvm->TriDraw8[bmode]; + break; + + case TriDrawVariant::FillSubsector: + drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupSubsector; + drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriFill32[bmode] : llvm->TriFill8[bmode]; + break; + + case TriDrawVariant::Stencil: + drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupNormal; + drawfuncs[num_drawfuncs++] = &ScreenTriangle::StencilWrite; + break; + + case TriDrawVariant::StencilClose: + drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupNormal; + drawfuncs[num_drawfuncs++] = &ScreenTriangle::StencilWrite; + drawfuncs[num_drawfuncs++] = &ScreenTriangle::SubsectorWrite; + break; + default: - case TriDrawVariant::DrawNormal: setupfunc = &ScreenTriangle::SetupNormal; drawfunc = dest_bgra ? llvm->TriDrawNormal32[bmode] : llvm->TriDrawNormal8[bmode]; break; - case TriDrawVariant::FillNormal: setupfunc = &ScreenTriangle::SetupNormal; drawfunc = dest_bgra ? llvm->TriFillNormal32[bmode] : llvm->TriFillNormal8[bmode]; break; - case TriDrawVariant::DrawSubsector: setupfunc = &ScreenTriangle::SetupSubsector; drawfunc = dest_bgra ? llvm->TriDrawSubsector32[bmode] : llvm->TriDrawSubsector8[bmode]; break; - case TriDrawVariant::FuzzSubsector: - case TriDrawVariant::FillSubsector: setupfunc = &ScreenTriangle::SetupSubsector; drawfunc = dest_bgra ? llvm->TriFillSubsector32[bmode] : llvm->TriFillSubsector8[bmode]; break; - case TriDrawVariant::Stencil: drawfunc = &ScreenTriangle::StencilFunc; break; - case TriDrawVariant::StencilClose: drawfunc = &ScreenTriangle::StencilCloseFunc; break; + break; } TriDrawTriangleArgs args; @@ -136,7 +165,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian { for (int j = 0; j < 3; j++) vert[j] = shade_vertex(*drawargs.objectToClip, drawargs.clipPlane, *(vinput++)); - draw_shaded_triangle(vert, ccw, &args, thread, setupfunc, drawfunc); + draw_shaded_triangle(vert, ccw, &args, thread, drawfuncs, num_drawfuncs); } } else if (drawargs.mode == TriangleDrawMode::Fan) @@ -146,7 +175,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian for (int i = 2; i < vcount; i++) { vert[2] = shade_vertex(*drawargs.objectToClip, drawargs.clipPlane, *(vinput++)); - draw_shaded_triangle(vert, ccw, &args, thread, setupfunc, drawfunc); + draw_shaded_triangle(vert, ccw, &args, thread, drawfuncs, num_drawfuncs); vert[1] = vert[2]; } } @@ -157,7 +186,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian for (int i = 2; i < vcount; i++) { vert[2] = shade_vertex(*drawargs.objectToClip, drawargs.clipPlane, *(vinput++)); - draw_shaded_triangle(vert, ccw, &args, thread, setupfunc, drawfunc); + draw_shaded_triangle(vert, ccw, &args, thread, drawfuncs, num_drawfuncs); vert[0] = vert[1]; vert[1] = vert[2]; ccw = !ccw; @@ -176,7 +205,7 @@ ShadedTriVertex PolyTriangleDrawer::shade_vertex(const TriMatrix &objectToClip, return sv; } -void PolyTriangleDrawer::draw_shaded_triangle(const ShadedTriVertex *vert, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, PolyDrawFuncPtr setupfunc, PolyDrawFuncPtr drawfunc) +void PolyTriangleDrawer::draw_shaded_triangle(const ShadedTriVertex *vert, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, PolyDrawFuncPtr *drawfuncs, int num_drawfuncs) { // Cull, clip and generate additional vertices as needed TriVertex clippedvert[max_additional_vertices]; @@ -220,8 +249,9 @@ void PolyTriangleDrawer::draw_shaded_triangle(const ShadedTriVertex *vert, bool args->v1 = &clippedvert[numclipvert - 1]; args->v2 = &clippedvert[i - 1]; args->v3 = &clippedvert[i - 2]; - if (setupfunc) setupfunc(args, thread); - drawfunc(args, thread); + + for (int j = 0; j < num_drawfuncs; j++) + drawfuncs[j](args, thread); } } else @@ -231,8 +261,9 @@ void PolyTriangleDrawer::draw_shaded_triangle(const ShadedTriVertex *vert, bool args->v1 = &clippedvert[0]; args->v2 = &clippedvert[i - 1]; args->v3 = &clippedvert[i]; - if (setupfunc) setupfunc(args, thread); - drawfunc(args, thread); + + for (int j = 0; j < num_drawfuncs; j++) + drawfuncs[j](args, thread); } } } @@ -1508,16 +1539,3 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, WorkerThreadData *thr } } #endif - -void ScreenTriangle::StencilFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) -{ - SetupNormal(args, thread); - StencilWrite(args, thread); -} - -void ScreenTriangle::StencilCloseFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread) -{ - SetupNormal(args, thread); - StencilWrite(args, thread); - SubsectorWrite(args, thread); -} diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 59e52ef66..4fc302eab 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -165,7 +165,7 @@ public: private: static ShadedTriVertex shade_vertex(const TriMatrix &objectToClip, const float *clipPlane, const TriVertex &v); static void draw_arrays(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode, WorkerThreadData *thread); - static void draw_shaded_triangle(const ShadedTriVertex *vertices, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, PolyDrawFuncPtr setupfunc, PolyDrawFuncPtr drawfunc); + static void draw_shaded_triangle(const ShadedTriVertex *vertices, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, PolyDrawFuncPtr *drawfuncs, int num_drawfuncs); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const ShadedTriVertex *verts, TriVertex *clippedvert, int &numclipvert); @@ -276,9 +276,6 @@ struct ScreenTriangleStepVariables class ScreenTriangle { public: - static void StencilFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - static void StencilCloseFunc(const TriDrawTriangleArgs *args, WorkerThreadData *thread); - static void SetupNormal(const TriDrawTriangleArgs *args, WorkerThreadData *thread); static void SetupSubsector(const TriDrawTriangleArgs *args, WorkerThreadData *thread); static void StencilWrite(const TriDrawTriangleArgs *args, WorkerThreadData *thread); diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index f1cd25c35..38e9922c0 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -32,11 +32,11 @@ #include "ssa/ssa_struct_type.h" #include "ssa/ssa_value.h" -void DrawTriangleCodegen::Generate(TriDrawVariant variant, TriBlendMode blendmode, bool truecolor, SSAValue args, SSAValue thread_data) +void DrawTriangleCodegen::Generate(TriBlendMode blendmode, bool truecolor, bool colorfill, SSAValue args, SSAValue thread_data) { - this->variant = variant; this->blendmode = blendmode; this->truecolor = truecolor; + this->colorfill = colorfill; pixelsize = truecolor ? 4 : 1; LoadArgs(args, thread_data); @@ -60,7 +60,6 @@ void DrawTriangleCodegen::DrawFullSpans() SSAInt height = SSAInt(8); stack_dest.store(destOrg[(spanX + spanY * pitch) * pixelsize]); - stack_subsector.store(subsectorGBuffer[spanX + spanY * pitch]); stack_posYW.store(start.W + gradientX.W * (spanX - startX) + gradientY.W * (spanY - startY)); for (int j = 0; j < TriVertex::NumVarying; j++) stack_posYVarying[j].store(start.Varying[j] + gradientX.Varying[j] * (spanX - startX) + gradientY.Varying[j] * (spanY - startY)); @@ -69,7 +68,6 @@ void DrawTriangleCodegen::DrawFullSpans() SSAForBlock loop_y; SSAInt y = stack_y.load(); SSAUBytePtr dest = stack_dest.load(); - SSAIntPtr subsector = stack_subsector.load(); SSAStepVariables blockPosY; blockPosY.W = stack_posYW.load(); for (int j = 0; j < TriVertex::NumVarying; j++) @@ -121,9 +119,6 @@ void DrawTriangleCodegen::DrawFullSpans() SSAUBytePtr destptr = dest[(x * 8 + ix) * 4]; destptr.store_vec4ub(ProcessPixel32(destptr.load_vec4ub(false), varyingPos)); - - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) - subsector[x * 8 + ix].store(subsectorDepth); } else { @@ -133,9 +128,6 @@ void DrawTriangleCodegen::DrawFullSpans() SSAUBytePtr destptr = dest[(x * 8 + ix)]; destptr.store(ProcessPixel8(destptr.load(false).zext_int(), varyingPos).trunc_ubyte()); - - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) - subsector[x * 8 + ix].store(subsectorDepth); } for (int j = 0; j < TriVertex::NumVarying; j++) @@ -157,7 +149,6 @@ void DrawTriangleCodegen::DrawFullSpans() for (int j = 0; j < TriVertex::NumVarying; j++) stack_posYVarying[j].store(blockPosY.Varying[j] + gradientY.Varying[j]); stack_dest.store(dest[pitch * pixelsize]); - stack_subsector.store(subsector[pitch]); stack_y.store(y + 1); } loop_y.end_block(); @@ -180,7 +171,6 @@ void DrawTriangleCodegen::DrawPartialBlocks() SSAInt mask1 = partialBlocks[i][3].load(true); SSAUBytePtr dest = destOrg[(blockX + blockY * pitch) * pixelsize]; - SSAIntPtr subsector = subsectorGBuffer[blockX + blockY * pitch]; SSAStepVariables blockPosY; blockPosY.W = start.W + gradientX.W * (blockX - startX) + gradientY.W * (blockY - startY); @@ -229,9 +219,6 @@ void DrawTriangleCodegen::DrawPartialBlocks() SSAUBytePtr destptr = dest[x * 4]; destptr.store_vec4ub(ProcessPixel32(destptr.load_vec4ub(false), varyingPos)); - - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) - subsector[x].store(subsectorDepth); } else { @@ -241,9 +228,6 @@ void DrawTriangleCodegen::DrawPartialBlocks() SSAUBytePtr destptr = dest[x]; destptr.store(ProcessPixel8(destptr.load(false).zext_int(), varyingPos).trunc_ubyte()); - - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) - subsector[x].store(subsectorDepth); } } branch.end_block(); @@ -258,7 +242,6 @@ void DrawTriangleCodegen::DrawPartialBlocks() blockPosY.Varying[j] = blockPosY.Varying[j] + gradientY.Varying[j]; dest = dest[pitch * pixelsize]; - subsector = subsector[pitch]; } } @@ -276,7 +259,7 @@ SSAVec4i DrawTriangleCodegen::TranslateSample32(SSAInt *varying) SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; SSAInt uvoffset = upos * textureHeight + vpos; - if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + if (colorfill) return translation[color * 4].load_vec4ub(true); else return translation[texturePixels[uvoffset].load(true).zext_int() * 4].load_vec4ub(true); @@ -291,7 +274,7 @@ SSAInt DrawTriangleCodegen::TranslateSample8(SSAInt *varying) SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; SSAInt uvoffset = upos * textureHeight + vpos; - if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + if (colorfill) return translation[color].load(true).zext_int(); else return translation[texturePixels[uvoffset].load(true).zext_int()].load(true).zext_int(); @@ -299,7 +282,7 @@ SSAInt DrawTriangleCodegen::TranslateSample8(SSAInt *varying) SSAVec4i DrawTriangleCodegen::Sample32(SSAInt *varying) { - if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + if (colorfill) return SSAVec4i::unpack(color); SSAInt ufrac = varying[0] << 8; @@ -362,7 +345,7 @@ SSAInt DrawTriangleCodegen::Sample8(SSAInt *varying) SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16; SSAInt uvoffset = upos * textureHeight + vpos; - if (variant == TriDrawVariant::FillNormal || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + if (colorfill) return color; else return texturePixels[uvoffset].load(true).zext_int(); @@ -593,7 +576,6 @@ void DrawTriangleCodegen::LoadArgs(SSAValue args, SSAValue thread_data) textureHeight = args[0][11].load(true); translation = args[0][12].load(true); LoadUniforms(args[0][13].load(true)); - subsectorGBuffer = args[0][19].load(true); if (!truecolor) { Colormaps = args[0][20].load(true); @@ -624,7 +606,6 @@ SSATriVertex DrawTriangleCodegen::LoadTriVertex(SSAValue ptr) void DrawTriangleCodegen::LoadUniforms(SSAValue uniforms) { light = uniforms[0][0].load(true); - subsectorDepth = uniforms[0][1].load(true); color = uniforms[0][2].load(true); srcalpha = uniforms[0][3].load(true); destalpha = uniforms[0][4].load(true); diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.h b/tools/drawergen/fixedfunction/drawtrianglecodegen.h index 02db1451c..8197656fa 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.h +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.h @@ -39,7 +39,7 @@ struct SSAStepVariables class DrawTriangleCodegen : public DrawerCodegen { public: - void Generate(TriDrawVariant variant, TriBlendMode blendmode, bool truecolor, SSAValue args, SSAValue thread_data); + void Generate(TriBlendMode blendmode, bool truecolor, bool colorfill, SSAValue args, SSAValue thread_data); private: void LoadArgs(SSAValue args, SSAValue thread_data); @@ -69,7 +69,6 @@ private: SSAStack stack_varyingPos[TriVertex::NumVarying]; SSAStack stack_lightpos; SSAStack stack_dest; - SSAStack stack_subsector; SSAStepVariables gradientX, gradientY, start; SSAFloat shade, globVis; @@ -78,7 +77,6 @@ private: SSAUBytePtr currentcolormap; SSAUBytePtr destOrg; - SSAIntPtr subsectorGBuffer; SSAInt pitch; SSATriVertex v1; SSATriVertex v2; @@ -90,7 +88,6 @@ private: SSAInt color, srcalpha, destalpha; SSAInt light; - SSAInt subsectorDepth; SSAShadeConstants shade_constants; SSABool is_simple_shade; SSABool is_nearest_filter; @@ -107,9 +104,9 @@ private: SSAValue fullSpans; // TriFullSpan[] SSAValue partialBlocks; // TriPartialBlock[] - TriDrawVariant variant; TriBlendMode blendmode; bool truecolor; + bool colorfill; int pixelsize; }; @@ -160,10 +157,8 @@ private: SSAStack stack_C1, stack_C2, stack_C3; SSAStack stack_y; SSAStack stack_dest; - SSAStack stack_subsectorGBuffer; SSAStack stack_x; SSAStack stack_buffer; - SSAStack stack_subsectorbuffer; SSAStack stack_iy, stack_ix; SSAStack stack_CY1, stack_CY2, stack_CY3; SSAStack stack_CX1, stack_CX2, stack_CX3; @@ -189,7 +184,6 @@ private: SSAInt color, srcalpha, destalpha; SSAInt light; - SSAInt subsectorDepth; SSAShadeConstants shade_constants; SSABool is_simple_shade; SSABool is_nearest_filter; @@ -200,7 +194,6 @@ private: SSAInt stencilPitch; SSAUByte stencilTestValue; SSAUByte stencilWriteValue; - SSAIntPtr subsectorGBuffer; SSAUBytePtr Colormaps; SSAUBytePtr RGB32k; diff --git a/tools/drawergen/llvmdrawers.cpp b/tools/drawergen/llvmdrawers.cpp index 83f1b1416..e0300946c 100644 --- a/tools/drawergen/llvmdrawers.cpp +++ b/tools/drawergen/llvmdrawers.cpp @@ -93,17 +93,11 @@ LLVMDrawers::LLVMDrawers(const std::string &triple, const std::string &cpuName, CodegenDrawSky("DrawDoubleSky4", DrawSkyVariant::Double, 4); for (int i = 0; i < NumTriBlendModes(); i++) { - CodegenDrawTriangle("TriDrawNormal8_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, false); - CodegenDrawTriangle("TriDrawNormal32_" + std::to_string(i), TriDrawVariant::DrawNormal, (TriBlendMode)i, true); - CodegenDrawTriangle("TriFillNormal8_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, false); - CodegenDrawTriangle("TriFillNormal32_" + std::to_string(i), TriDrawVariant::FillNormal, (TriBlendMode)i, true); - CodegenDrawTriangle("TriDrawSubsector8_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, false); - CodegenDrawTriangle("TriDrawSubsector32_" + std::to_string(i), TriDrawVariant::DrawSubsector, (TriBlendMode)i, true); - CodegenDrawTriangle("TriFillSubsector8_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, false); - CodegenDrawTriangle("TriFillSubsector32_" + std::to_string(i), TriDrawVariant::FillSubsector, (TriBlendMode)i, true); + CodegenDrawTriangle("TriDraw8_" + std::to_string(i), (TriBlendMode)i, false, false); + CodegenDrawTriangle("TriDraw32_" + std::to_string(i), (TriBlendMode)i, true, false); + CodegenDrawTriangle("TriFill8_" + std::to_string(i), (TriBlendMode)i, false, true); + CodegenDrawTriangle("TriFill32_" + std::to_string(i), (TriBlendMode)i, true, true); } - CodegenDrawTriangle("TriStencil", TriDrawVariant::Stencil, TriBlendMode::Copy, false); - CodegenDrawTriangle("TriStencilClose", TriDrawVariant::StencilClose, TriBlendMode::Copy, false); ObjectFile = mProgram.GenerateObjectFile(triple, cpuName, features); } @@ -183,7 +177,7 @@ void LLVMDrawers::CodegenDrawSky(const char *name, DrawSkyVariant variant, int c throw Exception("verifyFunction failed for CodegenDrawSky()"); } -void LLVMDrawers::CodegenDrawTriangle(const std::string &name, TriDrawVariant variant, TriBlendMode blendmode, bool truecolor) +void LLVMDrawers::CodegenDrawTriangle(const std::string &name, TriBlendMode blendmode, bool truecolor, bool colorfill) { llvm::IRBuilder<> builder(mProgram.context()); SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); @@ -194,12 +188,12 @@ void LLVMDrawers::CodegenDrawTriangle(const std::string &name, TriDrawVariant va function.create_public(); DrawTriangleCodegen codegen; - codegen.Generate(variant, blendmode, truecolor, function.parameter(0), function.parameter(1)); + codegen.Generate(blendmode, truecolor, colorfill, function.parameter(0), function.parameter(1)); builder.CreateRetVoid(); if (llvm::verifyFunction(*function.func)) - throw Exception(std::string("verifyFunction failed for CodegenDrawTriangle(") + std::to_string((int)variant) + ", " + std::to_string((int)blendmode) + ", " + std::to_string((int)truecolor) + ")"); + throw Exception("verifyFunction failed for CodegenDrawTriangle()"); } llvm::Type *LLVMDrawers::GetDrawColumnArgsStruct(llvm::LLVMContext &context) diff --git a/tools/drawergen/llvmdrawers.h b/tools/drawergen/llvmdrawers.h index df6078f4d..a1b7b5361 100644 --- a/tools/drawergen/llvmdrawers.h +++ b/tools/drawergen/llvmdrawers.h @@ -51,7 +51,7 @@ private: void CodegenDrawSpan(const char *name, DrawSpanVariant variant); void CodegenDrawWall(const char *name, DrawWallVariant variant, int columns); void CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns); - void CodegenDrawTriangle(const std::string &name, TriDrawVariant variant, TriBlendMode blendmode, bool truecolor); + void CodegenDrawTriangle(const std::string &name, TriBlendMode blendmode, bool truecolor, bool colorfill); llvm::Type *GetDrawColumnArgsStruct(llvm::LLVMContext &context); llvm::Type *GetDrawSpanArgsStruct(llvm::LLVMContext &context); From adb65ce72a735997bf98f298332717a14e7619cc Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 16 Dec 2016 00:35:45 +0100 Subject: [PATCH 1413/1509] Remove TriDrawVariant --- src/r_drawers.h | 11 ------ src/r_poly_decal.cpp | 6 +++- src/r_poly_particle.cpp | 6 +++- src/r_poly_plane.cpp | 18 ++++++---- src/r_poly_scene.cpp | 11 +++--- src/r_poly_sky.cpp | 11 +++--- src/r_poly_sprite.cpp | 6 +++- src/r_poly_triangle.cpp | 76 ++++++++++----------------------------- src/r_poly_triangle.h | 14 +++++--- src/r_poly_wall.cpp | 16 ++++++--- src/r_poly_wallsprite.cpp | 6 +++- 11 files changed, 83 insertions(+), 98 deletions(-) diff --git a/src/r_drawers.h b/src/r_drawers.h index 543796609..102d3159f 100644 --- a/src/r_drawers.h +++ b/src/r_drawers.h @@ -251,17 +251,6 @@ struct TriDrawTriangleArgs const uint8_t *BaseColors; }; -enum class TriDrawVariant -{ - DrawNormal, - FillNormal, - DrawSubsector, - FillSubsector, - FuzzSubsector, - Stencil, - StencilClose -}; - enum class TriBlendMode { Copy, // blend_copy(shade(fg)) diff --git a/src/r_poly_decal.cpp b/src/r_poly_decal.cpp index e91e25b58..7718d422e 100644 --- a/src/r_poly_decal.cpp +++ b/src/r_poly_decal.cpp @@ -167,5 +167,9 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan args.stencilwritevalue = stencilValue; //mode = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Shaded); + args.blendmode = TriBlendMode::Shaded; + args.subsectorTest = true; + args.writeStencil = false; + args.writeSubsector = false; + PolyTriangleDrawer::draw(args); } diff --git a/src/r_poly_particle.cpp b/src/r_poly_particle.cpp index 0d31614d2..27888e77b 100644 --- a/src/r_poly_particle.cpp +++ b/src/r_poly_particle.cpp @@ -105,5 +105,9 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const Vec4f &clipP args.stencilwritevalue = stencilValue; args.SetColormap(sub->sector->ColorMap); args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); - PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector, TriBlendMode::AlphaBlend); + args.subsectorTest = true; + args.writeStencil = false; + args.writeSubsector = false; + args.blendmode = TriBlendMode::AlphaBlend; + PolyTriangleDrawer::draw(args); } diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index c7f011a76..e21868dc2 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -143,8 +143,8 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c args.SetTexture(tex); args.SetColormap(sub->sector->ColorMap); args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy); - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + args.blendmode = TriBlendMode::Copy; + PolyTriangleDrawer::draw(args); } void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals) @@ -341,13 +341,15 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan if (!portal) { args.SetTexture(tex); - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy); - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + args.blendmode = TriBlendMode::Copy; + PolyTriangleDrawer::draw(args); } else { args.stencilwritevalue = polyportal->StencilValue; - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + args.writeColor = false; + args.writeSubsector = false; + PolyTriangleDrawer::draw(args); polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, subsectorDepth }); polyportal->Segments.insert(polyportal->Segments.end(), portalSegments.begin(), portalSegments.end()); } @@ -365,7 +367,9 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan args.stencilwritevalue = 255; } - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + args.writeColor = false; + args.writeSubsector = false; + PolyTriangleDrawer::draw(args); for (uint32_t i = 0; i < sub->numlines; i++) { @@ -433,7 +437,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan args.vinput = wallvert; args.vcount = 4; - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + PolyTriangleDrawer::draw(args); if (portal) { diff --git a/src/r_poly_scene.cpp b/src/r_poly_scene.cpp index c0697f55e..cfb858e0b 100644 --- a/src/r_poly_scene.cpp +++ b/src/r_poly_scene.cpp @@ -255,7 +255,8 @@ void RenderPolyScene::RenderPortals(int portalDepth) args.vcount = verts.Count; args.ccw = verts.Ccw; args.uniforms.subsectorDepth = verts.SubsectorDepth; - PolyTriangleDrawer::draw(args, TriDrawVariant::FillNormal, TriBlendMode::Copy); + args.blendmode = TriBlendMode::Copy; + PolyTriangleDrawer::draw(args); } } @@ -269,7 +270,7 @@ void RenderPolyScene::RenderPortals(int portalDepth) args.vcount = verts.Count; args.ccw = verts.Ccw; args.uniforms.subsectorDepth = verts.SubsectorDepth; - PolyTriangleDrawer::draw(args, TriDrawVariant::FillNormal, TriBlendMode::Copy); + PolyTriangleDrawer::draw(args); } } } @@ -296,7 +297,8 @@ void RenderPolyScene::RenderTranslucent(int portalDepth) args.vcount = verts.Count; args.ccw = verts.Ccw; args.uniforms.subsectorDepth = verts.SubsectorDepth; - PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy); + args.writeColor = false; + PolyTriangleDrawer::draw(args); } } @@ -317,7 +319,8 @@ void RenderPolyScene::RenderTranslucent(int portalDepth) args.vcount = verts.Count; args.ccw = verts.Ccw; args.uniforms.subsectorDepth = verts.SubsectorDepth; - PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy); + args.writeColor = false; + PolyTriangleDrawer::draw(args); } } } diff --git a/src/r_poly_sky.cpp b/src/r_poly_sky.cpp index 823a510f2..d2ea632b8 100644 --- a/src/r_poly_sky.cpp +++ b/src/r_poly_sky.cpp @@ -59,13 +59,14 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) args.objectToClip = &objectToClip; args.stenciltestvalue = 255; args.stencilwritevalue = 1; - args.SetTexture(frontskytex); args.SetColormap(&NormalLight); args.SetClipPlane(0.0f, 0.0f, 0.0f, 0.0f); RenderCapColorRow(args, frontskytex, 0, false); RenderCapColorRow(args, frontskytex, rc, true); + args.SetTexture(frontskytex); + uint32_t topcapcolor = frontskytex->GetSkyCapColor(false); uint32_t bottomcapcolor = frontskytex->GetSkyCapColor(true); @@ -83,8 +84,8 @@ void PolySkyDome::RenderRow(PolyDrawArgs &args, int row, uint32_t capcolor) args.mode = TriangleDrawMode::Strip; args.ccw = false; args.uniforms.color = capcolor; - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Skycap); - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Skycap); + args.blendmode = TriBlendMode::Skycap; + PolyTriangleDrawer::draw(args); } void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap) @@ -98,8 +99,8 @@ void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int ro args.mode = TriangleDrawMode::Fan; args.ccw = bottomCap; args.uniforms.color = solid; - PolyTriangleDrawer::draw(args, TriDrawVariant::FillNormal, TriBlendMode::Copy); - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + args.blendmode = TriBlendMode::Copy; + PolyTriangleDrawer::draw(args); } void PolySkyDome::CreateDome() diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index e5d8e0ce5..2cb285298 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -258,7 +258,11 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla blendmode = TriBlendMode::Add; } - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, blendmode); + args.subsectorTest = true; + args.writeSubsector = false; + args.writeStencil = false; + args.blendmode = blendmode; + PolyTriangleDrawer::draw(args); } bool RenderPolySprite::IsThingCulled(AActor *thing) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 90f78b639..1edd73c71 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -77,12 +77,12 @@ void PolyTriangleDrawer::toggle_mirror() mirror = !mirror; } -void PolyTriangleDrawer::draw(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode) +void PolyTriangleDrawer::draw(const PolyDrawArgs &args) { - DrawerCommandQueue::QueueCommand(args, variant, blendmode, mirror); + DrawerCommandQueue::QueueCommand(args, mirror); } -void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVariant variant, TriBlendMode blendmode, WorkerThreadData *thread) +void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, WorkerThreadData *thread) { if (drawargs.vcount < 3) return; @@ -92,46 +92,20 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian PolyDrawFuncPtr drawfuncs[3]; int num_drawfuncs = 0; - int bmode = (int)blendmode; - switch (variant) - { - case TriDrawVariant::DrawNormal: - drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupNormal; + drawfuncs[num_drawfuncs++] = drawargs.subsectorTest ? &ScreenTriangle::SetupSubsector : &ScreenTriangle::SetupNormal; + + int bmode = (int)drawargs.blendmode; + if (drawargs.writeColor && drawargs.texturePixels) drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriDraw32[bmode] : llvm->TriDraw8[bmode]; - drawfuncs[num_drawfuncs++] = &ScreenTriangle::SubsectorWrite; - break; - - case TriDrawVariant::FillNormal: - drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupNormal; + else if (drawargs.writeColor) drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriFill32[bmode] : llvm->TriFill8[bmode]; - drawfuncs[num_drawfuncs++] = &ScreenTriangle::SubsectorWrite; - break; - - case TriDrawVariant::DrawSubsector: - drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupSubsector; - drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriDraw32[bmode] : llvm->TriDraw8[bmode]; - break; - - case TriDrawVariant::FillSubsector: - drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupSubsector; - drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriFill32[bmode] : llvm->TriFill8[bmode]; - break; - - case TriDrawVariant::Stencil: - drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupNormal; - drawfuncs[num_drawfuncs++] = &ScreenTriangle::StencilWrite; - break; - - case TriDrawVariant::StencilClose: - drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupNormal; + + if (drawargs.writeStencil) drawfuncs[num_drawfuncs++] = &ScreenTriangle::StencilWrite; + + if (drawargs.writeSubsector) drawfuncs[num_drawfuncs++] = &ScreenTriangle::SubsectorWrite; - break; - - default: - break; - } - + TriDrawTriangleArgs args; args.dest = dest; args.pitch = dest_pitch; @@ -384,8 +358,8 @@ void PolyTriangleDrawer::clipedge(const ShadedTriVertex *verts, TriVertex *clipp ///////////////////////////////////////////////////////////////////////////// -DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode, bool mirror) - : args(args), variant(variant), blendmode(blendmode) +DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args, bool mirror) + : args(args) { if (mirror) this->args.ccw = !this->args.ccw; @@ -402,25 +376,13 @@ void DrawPolyTrianglesCommand::Execute(DrawerThread *thread) thread_data.FullSpans = thread->FullSpansBuffer.data(); thread_data.PartialBlocks = thread->PartialBlocksBuffer.data(); - PolyTriangleDrawer::draw_arrays(args, variant, blendmode, &thread_data); + PolyTriangleDrawer::draw_arrays(args, &thread_data); } FString DrawPolyTrianglesCommand::DebugInfo() { - FString variantstr; - switch (variant) - { - default: variantstr = "Unknown"; break; - case TriDrawVariant::DrawNormal: variantstr = "DrawNormal"; break; - case TriDrawVariant::FillNormal: variantstr = "FillNormal"; break; - case TriDrawVariant::DrawSubsector: variantstr = "DrawSubsector"; break; - case TriDrawVariant::FillSubsector: variantstr = "FillSubsector"; break; - case TriDrawVariant::FuzzSubsector: variantstr = "FuzzSubsector"; break; - case TriDrawVariant::Stencil: variantstr = "Stencil"; break; - } - FString blendmodestr; - switch (blendmode) + switch (args.blendmode) { default: blendmodestr = "Unknown"; break; case TriBlendMode::Copy: blendmodestr = "Copy"; break; @@ -440,8 +402,8 @@ FString DrawPolyTrianglesCommand::DebugInfo() } FString info; - info.Format("DrawPolyTriangles: variant = %s, blend mode = %s, color = %d, light = %d, textureWidth = %d, textureHeight = %d, texture = %s, translation = %s, colormaps = %s", - variantstr.GetChars(), blendmodestr.GetChars(), args.uniforms.color, args.uniforms.light, args.textureWidth, args.textureHeight, + info.Format("DrawPolyTriangles: blend mode = %s, color = %d, light = %d, textureWidth = %d, textureHeight = %d, texture = %s, translation = %s, colormaps = %s", + blendmodestr.GetChars(), args.uniforms.color, args.uniforms.light, args.textureWidth, args.textureHeight, args.texturePixels ? "ptr" : "null", args.translation ? "ptr" : "null", args.colormaps ? "ptr" : "null"); return info; } diff --git a/src/r_poly_triangle.h b/src/r_poly_triangle.h index 4fc302eab..5b66e80e2 100644 --- a/src/r_poly_triangle.h +++ b/src/r_poly_triangle.h @@ -49,6 +49,11 @@ public: int vcount = 0; TriangleDrawMode mode = TriangleDrawMode::Normal; bool ccw = false; + // bool stencilTest = true; // Always true for now + bool subsectorTest = false; + bool writeStencil = true; + bool writeColor = true; + bool writeSubsector = true; const uint8_t *texturePixels = nullptr; int textureWidth = 0; int textureHeight = 0; @@ -57,6 +62,7 @@ public: uint8_t stencilwritevalue = 0; const uint8_t *colormaps = nullptr; float clipPlane[4]; + TriBlendMode blendmode = TriBlendMode::Copy; void SetClipPlane(float a, float b, float c, float d) { @@ -159,12 +165,12 @@ class PolyTriangleDrawer { public: static void set_viewport(int x, int y, int width, int height, DCanvas *canvas); - static void draw(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode); + static void draw(const PolyDrawArgs &args); static void toggle_mirror(); private: static ShadedTriVertex shade_vertex(const TriMatrix &objectToClip, const float *clipPlane, const TriVertex &v); - static void draw_arrays(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode, WorkerThreadData *thread); + static void draw_arrays(const PolyDrawArgs &args, WorkerThreadData *thread); static void draw_shaded_triangle(const ShadedTriVertex *vertices, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, PolyDrawFuncPtr *drawfuncs, int num_drawfuncs); static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2); static void clipedge(const ShadedTriVertex *verts, TriVertex *clippedvert, int &numclipvert); @@ -249,15 +255,13 @@ private: class DrawPolyTrianglesCommand : public DrawerCommand { public: - DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode, bool mirror); + DrawPolyTrianglesCommand(const PolyDrawArgs &args, bool mirror); void Execute(DrawerThread *thread) override; FString DebugInfo() override; private: PolyDrawArgs args; - TriDrawVariant variant; - TriBlendMode blendmode; }; class PolyVertexBuffer diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index bcb5bb16b..ebb355431 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -264,7 +264,9 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane if (Polyportal) { args.stencilwritevalue = Polyportal->StencilValue; - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + args.writeColor = false; + args.writeSubsector = false; + PolyTriangleDrawer::draw(args); Polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, args.uniforms.subsectorDepth }); int sx1, sx2; @@ -274,17 +276,21 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane } else if (!Masked) { - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy); - PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy); + args.blendmode = TriBlendMode::Copy; + PolyTriangleDrawer::draw(args); } else { args.uniforms.destalpha = (Line->flags & ML_ADDTRANS) ? 256 : (uint32_t)(256 - Line->alpha * 256); args.uniforms.srcalpha = (uint32_t)(Line->alpha * 256); + args.subsectorTest = true; + args.writeSubsector = false; + args.writeStencil = false; if (args.uniforms.destalpha == 0 && args.uniforms.srcalpha == 256) - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend); + args.blendmode = TriBlendMode::AlphaBlend; else - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add); + args.blendmode = TriBlendMode::Add; + PolyTriangleDrawer::draw(args); } RenderPolyDecal::RenderWallDecals(worldToClip, clipPlane, LineSeg, SubsectorDepth, StencilValue); diff --git a/src/r_poly_wallsprite.cpp b/src/r_poly_wallsprite.cpp index e7fe267b8..fe12b271d 100644 --- a/src/r_poly_wallsprite.cpp +++ b/src/r_poly_wallsprite.cpp @@ -121,5 +121,9 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const Vec4f &cli args.SetTexture(tex); args.SetColormap(sub->sector->ColorMap); args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); - PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend); + args.subsectorTest = true; + args.writeSubsector = false; + args.writeStencil = false; + args.blendmode = TriBlendMode::AlphaBlend; + PolyTriangleDrawer::draw(args); } From 9b98c4d51229c42c99317872c07d1098c2357651 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 16 Dec 2016 05:01:49 +0100 Subject: [PATCH 1414/1509] Fix out of bounds bug --- src/r_poly_triangle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 1edd73c71..46b82f517 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -89,7 +89,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, WorkerThreadD auto llvm = Drawers::Instance(); - PolyDrawFuncPtr drawfuncs[3]; + PolyDrawFuncPtr drawfuncs[4]; int num_drawfuncs = 0; drawfuncs[num_drawfuncs++] = drawargs.subsectorTest ? &ScreenTriangle::SetupSubsector : &ScreenTriangle::SetupNormal; From 6d295a25c2d4be25ef743f0fea4fabf1d1632d36 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 16 Dec 2016 06:21:17 +0100 Subject: [PATCH 1415/1509] Minor tweaking --- src/r_poly_triangle.cpp | 32 ++++++++++---- .../fixedfunction/drawtrianglecodegen.cpp | 42 ++++++++++++++----- 2 files changed, 55 insertions(+), 19 deletions(-) diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 46b82f517..e06cf2b7f 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -37,6 +37,8 @@ #include "r_poly_triangle.h" #include "r_draw_rgba.h" +CVAR(Bool, r_debug_trisetup, false, 0); + int PolyTriangleDrawer::viewport_x; int PolyTriangleDrawer::viewport_y; int PolyTriangleDrawer::viewport_width; @@ -93,19 +95,22 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, WorkerThreadD int num_drawfuncs = 0; drawfuncs[num_drawfuncs++] = drawargs.subsectorTest ? &ScreenTriangle::SetupSubsector : &ScreenTriangle::SetupNormal; - - int bmode = (int)drawargs.blendmode; - if (drawargs.writeColor && drawargs.texturePixels) - drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriDraw32[bmode] : llvm->TriDraw8[bmode]; - else if (drawargs.writeColor) - drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriFill32[bmode] : llvm->TriFill8[bmode]; - + + if (!r_debug_trisetup) // For profiling how much time is spent in setup vs drawal + { + int bmode = (int)drawargs.blendmode; + if (drawargs.writeColor && drawargs.texturePixels) + drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriDraw32[bmode] : llvm->TriDraw8[bmode]; + else if (drawargs.writeColor) + drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriFill32[bmode] : llvm->TriFill8[bmode]; + } + if (drawargs.writeStencil) drawfuncs[num_drawfuncs++] = &ScreenTriangle::StencilWrite; - + if (drawargs.writeSubsector) drawfuncs[num_drawfuncs++] = &ScreenTriangle::SubsectorWrite; - + TriDrawTriangleArgs args; args.dest = dest; args.pitch = dest_pitch; @@ -793,6 +798,9 @@ void ScreenTriangle::SetupNormal(const TriDrawTriangleArgs *args, WorkerThreadDa span->Length = 0; } + if (mask0 == 0 && mask1 == 0) + continue; + partial->X = x; partial->Y = y; partial->Mask0 = mask0; @@ -997,6 +1005,9 @@ void ScreenTriangle::SetupSubsector(const TriDrawTriangleArgs *args, WorkerThrea span->Length = 0; } + if (mask0 == 0 && mask1 == 0) + continue; + partial->X = x; partial->Y = y; partial->Mask0 = mask0; @@ -1083,6 +1094,9 @@ void ScreenTriangle::SetupSubsector(const TriDrawTriangleArgs *args, WorkerThrea span->Length = 0; } + if (mask0 == 0 && mask1 == 0) + continue; + partial->X = x; partial->Y = y; partial->Mask0 = mask0; diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index 38e9922c0..8e4ed803f 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -111,16 +111,38 @@ void DrawTriangleCodegen::DrawFullSpans() SSAInt lightnext = FRACUNIT - SSAInt(SSAFloat::clamp(shade - SSAFloat::MIN(SSAFloat(24.0f), globVis * blockPosX.W) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * (float)FRACUNIT, true); SSAInt lightstep = (lightnext - lightpos) / 8; - for (int ix = 0; ix < 8; ix++) + if (truecolor) { - if (truecolor) + for (int ix = 0; ix < 8; ix += 4) { - currentlight = is_fixed_light.select(light, lightpos >> 8); - SSAUBytePtr destptr = dest[(x * 8 + ix) * 4]; - destptr.store_vec4ub(ProcessPixel32(destptr.load_vec4ub(false), varyingPos)); + SSAVec16ub pixels16 = destptr.load_unaligned_vec16ub(false); + SSAVec8s pixels8hi = SSAVec8s::extendhi(pixels16); + SSAVec8s pixels8lo = SSAVec8s::extendlo(pixels16); + SSAVec4i pixels[4] = + { + SSAVec4i::extendlo(pixels8lo), + SSAVec4i::extendhi(pixels8lo), + SSAVec4i::extendlo(pixels8hi), + SSAVec4i::extendhi(pixels8hi) + }; + + for (int sse = 0; sse < 4; sse++) + { + currentlight = is_fixed_light.select(light, lightpos >> 8); + pixels[sse] = ProcessPixel32(pixels[sse], varyingPos); + + for (int j = 0; j < TriVertex::NumVarying; j++) + varyingPos[j] = varyingPos[j] + varyingStep[j]; + lightpos = lightpos + lightstep; + } + + destptr.store_unaligned_vec16ub(SSAVec16ub(SSAVec8s(pixels[0], pixels[1]), SSAVec8s(pixels[2], pixels[3]))); } - else + } + else + { + for (int ix = 0; ix < 8; ix++) { currentlight = is_fixed_light.select(light, lightpos >> 8); SSAInt colormapindex = SSAInt::MIN((256 - currentlight) * 32 / 256, SSAInt(31)); @@ -128,11 +150,11 @@ void DrawTriangleCodegen::DrawFullSpans() SSAUBytePtr destptr = dest[(x * 8 + ix)]; destptr.store(ProcessPixel8(destptr.load(false).zext_int(), varyingPos).trunc_ubyte()); - } - for (int j = 0; j < TriVertex::NumVarying; j++) - varyingPos[j] = varyingPos[j] + varyingStep[j]; - lightpos = lightpos + lightstep; + for (int j = 0; j < TriVertex::NumVarying; j++) + varyingPos[j] = varyingPos[j] + varyingStep[j]; + lightpos = lightpos + lightstep; + } } for (int j = 0; j < TriVertex::NumVarying; j++) From a360a1963f97ba8e4492df85e5b282bdcfd060d5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 16 Dec 2016 15:25:03 +0100 Subject: [PATCH 1416/1509] Move setup triangle stuff to its own file --- tools/drawergen/CMakeLists.txt | 1 + .../fixedfunction/drawtrianglecodegen.cpp | 772 +----------------- .../fixedfunction/drawtrianglecodegen.h | 125 --- .../fixedfunction/setuptrianglecodegen.cpp | 573 +++++++++++++ .../fixedfunction/setuptrianglecodegen.h | 98 +++ 5 files changed, 675 insertions(+), 894 deletions(-) create mode 100644 tools/drawergen/fixedfunction/setuptrianglecodegen.cpp create mode 100644 tools/drawergen/fixedfunction/setuptrianglecodegen.h diff --git a/tools/drawergen/CMakeLists.txt b/tools/drawergen/CMakeLists.txt index d330e799a..12e004e28 100644 --- a/tools/drawergen/CMakeLists.txt +++ b/tools/drawergen/CMakeLists.txt @@ -141,6 +141,7 @@ set (SOURCES fixedfunction/drawcolumncodegen.cpp fixedfunction/drawskycodegen.cpp fixedfunction/drawtrianglecodegen.cpp + fixedfunction/setuptrianglecodegen.cpp ) enable_precompiled_headers( precomp.h SOURCES ) diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index 8e4ed803f..01deb1ce2 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -354,6 +354,9 @@ SSAVec4i DrawTriangleCodegen::Sample32(SSAInt *varying) linear = (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8; } + // // Min filter = linear, Mag filter = nearest: + // AffineLinear = (gradVaryingX[0] / AffineW) > SSAFloat(1.0f) || (gradVaryingX[0] / AffineW) < SSAFloat(-1.0f); + return AffineLinear.select(linear, nearest); */ } @@ -664,772 +667,3 @@ SSAFloat DrawTriangleCodegen::FindGradientY(SSAFloat x0, SSAFloat y0, SSAFloat x SSAFloat bottom = (x0 - x2) * (y1 - y2) - (x1 - x2) * (y0 - y2); return top / bottom; } - - -#if 0 - -void DrawTriangleCodegen::Generate(TriDrawVariant variant, TriBlendMode blendmode, bool truecolor, SSAValue args, SSAValue thread_data) -{ - this->variant = variant; - this->blendmode = blendmode; - this->truecolor = truecolor; - LoadArgs(args, thread_data); - Setup(); - LoopBlockY(); -} - -SSAInt DrawTriangleCodegen::FloatTo28_4(SSAFloat v) -{ - // SSAInt(SSAFloat::round(16.0f * v), false); - SSAInt a = SSAInt(v * 32.0f, false); - return (a + (a.ashr(31) | SSAInt(1))).ashr(1); -} - -void DrawTriangleCodegen::Setup() -{ - int pixelsize = truecolor ? 4 : 1; - - // 28.4 fixed-point coordinates - Y1 = FloatTo28_4(v1.y); - Y2 = FloatTo28_4(v2.y); - Y3 = FloatTo28_4(v3.y); - - X1 = FloatTo28_4(v1.x); - X2 = FloatTo28_4(v2.x); - X3 = FloatTo28_4(v3.x); - - // Deltas - DX12 = X1 - X2; - DX23 = X2 - X3; - DX31 = X3 - X1; - - DY12 = Y1 - Y2; - DY23 = Y2 - Y3; - DY31 = Y3 - Y1; - - // Fixed-point deltas - FDX12 = DX12 << 4; - FDX23 = DX23 << 4; - FDX31 = DX31 << 4; - - FDY12 = DY12 << 4; - FDY23 = DY23 << 4; - FDY31 = DY31 << 4; - - // Bounding rectangle - minx = SSAInt::MAX((SSAInt::MIN(SSAInt::MIN(X1, X2), X3) + 0xF).ashr(4), SSAInt(0)); - maxx = SSAInt::MIN((SSAInt::MAX(SSAInt::MAX(X1, X2), X3) + 0xF).ashr(4), clipright - 1); - miny = SSAInt::MAX((SSAInt::MIN(SSAInt::MIN(Y1, Y2), Y3) + 0xF).ashr(4), SSAInt(0)); - maxy = SSAInt::MIN((SSAInt::MAX(SSAInt::MAX(Y1, Y2), Y3) + 0xF).ashr(4), clipbottom - 1); - - SSAIfBlock if0; - if0.if_block(minx >= maxx || miny >= maxy); - if0.end_retvoid(); - - // Start in corner of 8x8 block - minx = minx & ~(q - 1); - miny = miny & ~(q - 1); - - dest = dest[miny * pitch * pixelsize]; - subsectorGBuffer = subsectorGBuffer[miny * pitch]; - - // Half-edge constants - C1 = DY12 * X1 - DX12 * Y1; - C2 = DY23 * X2 - DX23 * Y2; - C3 = DY31 * X3 - DX31 * Y3; - - // Correct for fill convention - SSAIfBlock if1; - if1.if_block(DY12 < SSAInt(0) || (DY12 == SSAInt(0) && DX12 > SSAInt(0))); - stack_C1.store(C1 + 1); - if1.else_block(); - stack_C1.store(C1); - if1.end_block(); - C1 = stack_C1.load(); - SSAIfBlock if2; - if2.if_block(DY23 < SSAInt(0) || (DY23 == SSAInt(0) && DX23 > SSAInt(0))); - stack_C2.store(C2 + 1); - if2.else_block(); - stack_C2.store(C2); - if2.end_block(); - C2 = stack_C2.load(); - SSAIfBlock if3; - if3.if_block(DY31 < SSAInt(0) || (DY31 == SSAInt(0) && DX31 > SSAInt(0))); - stack_C3.store(C3 + 1); - if3.else_block(); - stack_C3.store(C3); - if3.end_block(); - C3 = stack_C3.load(); - - // Gradients - v1.x = SSAFloat(X1) * 0.0625f; - v2.x = SSAFloat(X2) * 0.0625f; - v3.x = SSAFloat(X3) * 0.0625f; - v1.y = SSAFloat(Y1) * 0.0625f; - v2.y = SSAFloat(Y2) * 0.0625f; - v3.y = SSAFloat(Y3) * 0.0625f; - gradWX = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - gradWY = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w); - stack_posy_w.store(v1.w + gradWX * (SSAFloat(minx) - v1.x) + gradWY * (SSAFloat(miny) - v1.y)); - for (int i = 0; i < TriVertex::NumVarying; i++) - { - gradVaryingX[i] = gradx(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - gradVaryingY[i] = grady(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w); - stack_posy_varying[i].store(v1.varying[i] * v1.w + gradVaryingX[i] * (SSAFloat(minx) - v1.x) + gradVaryingY[i] * (SSAFloat(miny) - v1.y)); - } - - gradWX = gradWX * (float)q; - for (int i = 0; i < TriVertex::NumVarying; i++) - gradVaryingX[i] = gradVaryingX[i] * (float)q; - - shade = 64.0f - (SSAFloat(light * 255 / 256) + 12.0f) * 32.0f / 128.0f; -} - -SSAFloat DrawTriangleCodegen::gradx(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2) -{ - SSAFloat top = (c1 - c2) * (y0 - y2) - (c0 - c2) * (y1 - y2); - SSAFloat bottom = (x1 - x2) * (y0 - y2) - (x0 - x2) * (y1 - y2); - return top / bottom; -} - -SSAFloat DrawTriangleCodegen::grady(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2) -{ - SSAFloat top = (c1 - c2) * (x0 - x2) - (c0 - c2) * (x1 - x2); - SSAFloat bottom = (x0 - x2) * (y1 - y2) - (x1 - x2) * (y0 - y2); - return top / bottom; -} - -void DrawTriangleCodegen::LoopBlockY() -{ - int pixelsize = truecolor ? 4 : 1; - - SSAInt blocks_skipped = skipped_by_thread(miny / q, thread); - stack_y.store(miny + blocks_skipped * q); - stack_dest.store(dest[blocks_skipped * q * pitch * pixelsize]); - stack_subsectorGBuffer.store(subsectorGBuffer[blocks_skipped * q * pitch]); - stack_posy_w.store(stack_posy_w.load() + gradWY * (q * blocks_skipped)); - for (int i = 0; i < TriVertex::NumVarying; i++) - stack_posy_varying[i].store(stack_posy_varying[i].load() + gradVaryingY[i] * (blocks_skipped * q)); - - SSAForBlock loop; - y = stack_y.load(); - dest = stack_dest.load(); - subsectorGBuffer = stack_subsectorGBuffer.load(); - posy_w = stack_posy_w.load(); - for (int i = 0; i < TriVertex::NumVarying; i++) - posy_varying[i] = stack_posy_varying[i].load(); - loop.loop_block(y < maxy, 0); - { - LoopBlockX(); - - stack_posy_w.store(posy_w + gradWY * (q * thread.num_cores)); - for (int i = 0; i < TriVertex::NumVarying; i++) - stack_posy_varying[i].store(posy_varying[i] + gradVaryingY[i] * (q * thread.num_cores)); - - stack_dest.store(dest[q * pitch * pixelsize * thread.num_cores]); - stack_subsectorGBuffer.store(subsectorGBuffer[q * pitch * thread.num_cores]); - stack_y.store(y + thread.num_cores * q); - } - loop.end_block(); -} - -void DrawTriangleCodegen::LoopBlockX() -{ - stack_x.store(minx); - stack_posx_w.store(posy_w); - for (int i = 0; i < TriVertex::NumVarying; i++) - stack_posx_varying[i].store(posy_varying[i]); - - SSAForBlock loop; - x = stack_x.load(); - posx_w = stack_posx_w.load(); - for (int i = 0; i < TriVertex::NumVarying; i++) - posx_varying[i] = stack_posx_varying[i].load(); - loop.loop_block(x < maxx, 0); - { - // Corners of block - x0 = x << 4; - x1 = (x + q - 1) << 4; - y0 = y << 4; - y1 = (y + q - 1) << 4; - - // Evaluate half-space functions - SSABool a00 = C1 + DX12 * y0 - DY12 * x0 > SSAInt(0); - SSABool a10 = C1 + DX12 * y0 - DY12 * x1 > SSAInt(0); - SSABool a01 = C1 + DX12 * y1 - DY12 * x0 > SSAInt(0); - SSABool a11 = C1 + DX12 * y1 - DY12 * x1 > SSAInt(0); - - SSAInt a = (a00.zext_int() << 0) | (a10.zext_int() << 1) | (a01.zext_int() << 2) | (a11.zext_int() << 3); - - SSABool b00 = C2 + DX23 * y0 - DY23 * x0 > SSAInt(0); - SSABool b10 = C2 + DX23 * y0 - DY23 * x1 > SSAInt(0); - SSABool b01 = C2 + DX23 * y1 - DY23 * x0 > SSAInt(0); - SSABool b11 = C2 + DX23 * y1 - DY23 * x1 > SSAInt(0); - SSAInt b = (b00.zext_int() << 0) | (b10.zext_int() << 1) | (b01.zext_int() << 2) | (b11.zext_int() << 3); - - SSABool c00 = C3 + DX31 * y0 - DY31 * x0 > SSAInt(0); - SSABool c10 = C3 + DX31 * y0 - DY31 * x1 > SSAInt(0); - SSABool c01 = C3 + DX31 * y1 - DY31 * x0 > SSAInt(0); - SSABool c11 = C3 + DX31 * y1 - DY31 * x1 > SSAInt(0); - SSAInt c = (c00.zext_int() << 0) | (c10.zext_int() << 1) | (c01.zext_int() << 2) | (c11.zext_int() << 3); - - // Skip block when outside an edge - SSABool process_block = !(a == SSAInt(0) || b == SSAInt(0) || c == SSAInt(0)); - - SetStencilBlock(x / 8 + y / 8 * stencilPitch); - - // Stencil test the whole block, if possible - if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector || variant == TriDrawVariant::StencilClose) - { - process_block = process_block && (!StencilIsSingleValue() || SSABool::compare_uge(StencilGetSingle(), stencilTestValue)); - } - else - { - process_block = process_block && (!StencilIsSingleValue() || StencilGetSingle() == stencilTestValue); - } - - SSAIfBlock branch; - branch.if_block(process_block); - - // Check if block needs clipping - SSABool clipneeded = (x + q) > clipright || (y + q) > clipbottom; - - SSAFloat globVis = SSAFloat(1706.0f); - SSAFloat vis = globVis * posx_w; - SSAInt lightscale = SSAInt(SSAFloat::clamp((shade - SSAFloat::MIN(SSAFloat(24.0f), vis)) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * 256.0f, true); - SSAInt diminishedlight = 256 - lightscale; - - if (!truecolor) - { - SSAInt diminishedindex = lightscale / 8; - SSAInt lightindex = SSAInt::MIN((256 - light) * 32 / 256, SSAInt(31)); - SSAInt colormapindex = (!is_fixed_light).select(diminishedindex, lightindex); - currentcolormap = Colormaps[colormapindex << 8]; - } - else - { - currentlight = (!is_fixed_light).select(diminishedlight, light); - } - - SSABool covered = a == SSAInt(0xF) && b == SSAInt(0xF) && c == SSAInt(0xF) && !clipneeded && StencilIsSingleValue(); - - // Accept whole block when totally covered - SSAIfBlock branch_covered; - branch_covered.if_block(covered); - { - LoopFullBlock(); - } - branch_covered.else_block(); - { - SSAIfBlock branch_covered_stencil; - branch_covered_stencil.if_block(StencilIsSingleValue()); - { - SSABool stenciltestpass; - if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector || variant == TriDrawVariant::StencilClose) - { - stenciltestpass = SSABool::compare_uge(StencilGetSingle(), stencilTestValue); - } - else - { - stenciltestpass = StencilGetSingle() == stencilTestValue; - } - - SSAIfBlock branch_stenciltestpass; - branch_stenciltestpass.if_block(stenciltestpass); - { - LoopPartialBlock(true); - } - branch_stenciltestpass.end_block(); - } - branch_covered_stencil.else_block(); - { - LoopPartialBlock(false); - } - branch_covered_stencil.end_block(); - } - branch_covered.end_block(); - - branch.end_block(); - - stack_posx_w.store(posx_w + gradWX); - for (int i = 0; i < TriVertex::NumVarying; i++) - stack_posx_varying[i].store(posx_varying[i] + gradVaryingX[i]); - - stack_x.store(x + q); - } - loop.end_block(); -} - -void DrawTriangleCodegen::SetupAffineBlock() -{ - SSAFloat rcpW0 = (float)0x01000000 / AffineW; - SSAFloat rcpW1 = (float)0x01000000 / (AffineW + gradWX); - - for (int i = 0; i < TriVertex::NumVarying; i++) - { - AffineVaryingPosX[i] = SSAInt(AffineVaryingPosY[i] * rcpW0, false); - AffineVaryingStepX[i] = (SSAInt((AffineVaryingPosY[i] + gradVaryingX[i]) * rcpW1, false) - AffineVaryingPosX[i]) / q; - } - - // Min filter = linear, Mag filter = nearest: - AffineLinear = (gradVaryingX[0] / AffineW) > SSAFloat(1.0f) || (gradVaryingX[0] / AffineW) < SSAFloat(-1.0f); -} - -void DrawTriangleCodegen::LoopFullBlock() -{ - if (variant == TriDrawVariant::Stencil) - { - StencilClear(stencilWriteValue); - } - else if (variant == TriDrawVariant::StencilClose) - { - StencilClear(stencilWriteValue); - for (int iy = 0; iy < q; iy++) - { - SSAIntPtr subsectorbuffer = subsectorGBuffer[x + iy * pitch]; - for (int ix = 0; ix < q; ix += 4) - { - subsectorbuffer[ix].store_unaligned_vec4i(SSAVec4i(subsectorDepth)); - } - } - } - else - { - int pixelsize = truecolor ? 4 : 1; - - AffineW = posx_w; - for (int i = 0; i < TriVertex::NumVarying; i++) - AffineVaryingPosY[i] = posx_varying[i]; - - for (int iy = 0; iy < q; iy++) - { - SSAUBytePtr buffer = dest[(x + iy * pitch) * pixelsize]; - SSAIntPtr subsectorbuffer = subsectorGBuffer[x + iy * pitch]; - - SetupAffineBlock(); - - for (int ix = 0; ix < q; ix += 4) - { - SSAUBytePtr buf = buffer[ix * pixelsize]; - if (truecolor) - { - SSAVec16ub pixels16 = buf.load_unaligned_vec16ub(false); - SSAVec8s pixels8hi = SSAVec8s::extendhi(pixels16); - SSAVec8s pixels8lo = SSAVec8s::extendlo(pixels16); - SSAVec4i pixels[4] = - { - SSAVec4i::extendlo(pixels8lo), - SSAVec4i::extendhi(pixels8lo), - SSAVec4i::extendlo(pixels8hi), - SSAVec4i::extendhi(pixels8hi) - }; - - for (int sse = 0; sse < 4; sse++) - { - if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) - { - SSABool subsectorTest = subsectorbuffer[ix].load(true) >= subsectorDepth; - pixels[sse] = subsectorTest.select(ProcessPixel32(pixels[sse], AffineVaryingPosX), pixels[sse]); - } - else - { - pixels[sse] = ProcessPixel32(pixels[sse], AffineVaryingPosX); - } - - for (int i = 0; i < TriVertex::NumVarying; i++) - AffineVaryingPosX[i] = AffineVaryingPosX[i] + AffineVaryingStepX[i]; - } - - buf.store_unaligned_vec16ub(SSAVec16ub(SSAVec8s(pixels[0], pixels[1]), SSAVec8s(pixels[2], pixels[3]))); - } - else - { - SSAVec4i pixelsvec = buf.load_vec4ub(false); - SSAInt pixels[4] = - { - pixelsvec[0], - pixelsvec[1], - pixelsvec[2], - pixelsvec[3] - }; - - for (int sse = 0; sse < 4; sse++) - { - if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) - { - SSABool subsectorTest = subsectorbuffer[ix].load(true) >= subsectorDepth; - pixels[sse] = subsectorTest.select(ProcessPixel8(pixels[sse], AffineVaryingPosX), pixels[sse]); - } - else - { - pixels[sse] = ProcessPixel8(pixels[sse], AffineVaryingPosX); - } - - for (int i = 0; i < TriVertex::NumVarying; i++) - AffineVaryingPosX[i] = AffineVaryingPosX[i] + AffineVaryingStepX[i]; - } - - buf.store_vec4ub(SSAVec4i(pixels[0], pixels[1], pixels[2], pixels[3])); - } - - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) - subsectorbuffer[ix].store_unaligned_vec4i(SSAVec4i(subsectorDepth)); - } - - AffineW = AffineW + gradWY; - for (int i = 0; i < TriVertex::NumVarying; i++) - AffineVaryingPosY[i] = AffineVaryingPosY[i] + gradVaryingY[i]; - } - } -} - -void DrawTriangleCodegen::LoopPartialBlock(bool isSingleStencilValue) -{ - int pixelsize = truecolor ? 4 : 1; - - if (variant == TriDrawVariant::Stencil || variant == TriDrawVariant::StencilClose) - { - if (isSingleStencilValue) - { - SSAInt stencilMask = StencilBlockMask.load(false); - SSAUByte val0 = stencilMask.trunc_ubyte(); - for (int i = 0; i < 8 * 8; i++) - StencilBlock[i].store(val0); - StencilBlockMask.store(SSAInt(0)); - } - - SSAUByte lastStencilValue = StencilBlock[0].load(false); - stack_stencilblock_restored.store(SSABool(true)); - stack_stencilblock_lastval.store(lastStencilValue); - } - - stack_CY1.store(C1 + DX12 * y0 - DY12 * x0); - stack_CY2.store(C2 + DX23 * y0 - DY23 * x0); - stack_CY3.store(C3 + DX31 * y0 - DY31 * x0); - stack_iy.store(SSAInt(0)); - stack_buffer.store(dest[x * pixelsize]); - stack_subsectorbuffer.store(subsectorGBuffer[x]); - stack_AffineW.store(posx_w); - for (int i = 0; i < TriVertex::NumVarying; i++) - { - stack_AffineVaryingPosY[i].store(posx_varying[i]); - } - - SSAForBlock loopy; - SSAInt iy = stack_iy.load(); - SSAUBytePtr buffer = stack_buffer.load(); - SSAIntPtr subsectorbuffer = stack_subsectorbuffer.load(); - SSAInt CY1 = stack_CY1.load(); - SSAInt CY2 = stack_CY2.load(); - SSAInt CY3 = stack_CY3.load(); - AffineW = stack_AffineW.load(); - for (int i = 0; i < TriVertex::NumVarying; i++) - AffineVaryingPosY[i] = stack_AffineVaryingPosY[i].load(); - loopy.loop_block(iy < SSAInt(q), q); - { - SetupAffineBlock(); - - for (int i = 0; i < TriVertex::NumVarying; i++) - stack_AffineVaryingPosX[i].store(AffineVaryingPosX[i]); - - stack_CX1.store(CY1); - stack_CX2.store(CY2); - stack_CX3.store(CY3); - stack_ix.store(SSAInt(0)); - - SSAForBlock loopx; - SSABool stencilblock_restored; - SSAUByte lastStencilValue; - if (variant == TriDrawVariant::Stencil || variant == TriDrawVariant::StencilClose) - { - stencilblock_restored = stack_stencilblock_restored.load(); - lastStencilValue = stack_stencilblock_lastval.load(); - } - SSAInt ix = stack_ix.load(); - SSAInt CX1 = stack_CX1.load(); - SSAInt CX2 = stack_CX2.load(); - SSAInt CX3 = stack_CX3.load(); - for (int i = 0; i < TriVertex::NumVarying; i++) - AffineVaryingPosX[i] = stack_AffineVaryingPosX[i].load(); - loopx.loop_block(ix < SSAInt(q), q); - { - SSABool visible = (ix + x < clipright) && (iy + y < clipbottom); - SSABool covered = CX1 > SSAInt(0) && CX2 > SSAInt(0) && CX3 > SSAInt(0) && visible; - - if (!isSingleStencilValue) - { - SSAUByte stencilValue = StencilBlock[ix + iy * 8].load(false); - - if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) - { - covered = covered && SSABool::compare_uge(stencilValue, stencilTestValue) && subsectorbuffer[ix].load(true) >= subsectorDepth; - } - else if (variant == TriDrawVariant::StencilClose) - { - covered = covered && SSABool::compare_uge(stencilValue, stencilTestValue); - } - else - { - covered = covered && stencilValue == stencilTestValue; - } - } - else if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) - { - covered = covered && subsectorbuffer[ix].load(true) >= subsectorDepth; - } - - SSAIfBlock branch; - branch.if_block(covered); - { - if (variant == TriDrawVariant::Stencil) - { - StencilBlock[ix + iy * 8].store(stencilWriteValue); - } - else if (variant == TriDrawVariant::StencilClose) - { - StencilBlock[ix + iy * 8].store(stencilWriteValue); - subsectorbuffer[ix].store(subsectorDepth); - } - else - { - SSAUBytePtr buf = buffer[ix * pixelsize]; - - if (truecolor) - { - SSAVec4i bg = buf.load_vec4ub(false); - buf.store_vec4ub(ProcessPixel32(bg, AffineVaryingPosX)); - } - else - { - SSAUByte bg = buf.load(false); - buf.store(ProcessPixel8(bg.zext_int(), AffineVaryingPosX).trunc_ubyte()); - } - - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) - subsectorbuffer[ix].store(subsectorDepth); - } - } - branch.end_block(); - - if (variant == TriDrawVariant::Stencil || variant == TriDrawVariant::StencilClose) - { - SSAUByte newStencilValue = StencilBlock[ix + iy * 8].load(false); - stack_stencilblock_restored.store(stencilblock_restored && newStencilValue == lastStencilValue); - stack_stencilblock_lastval.store(newStencilValue); - } - - for (int i = 0; i < TriVertex::NumVarying; i++) - stack_AffineVaryingPosX[i].store(AffineVaryingPosX[i] + AffineVaryingStepX[i]); - - stack_CX1.store(CX1 - FDY12); - stack_CX2.store(CX2 - FDY23); - stack_CX3.store(CX3 - FDY31); - stack_ix.store(ix + 1); - } - loopx.end_block(); - - stack_AffineW.store(AffineW + gradWY); - for (int i = 0; i < TriVertex::NumVarying; i++) - stack_AffineVaryingPosY[i].store(AffineVaryingPosY[i] + gradVaryingY[i]); - stack_CY1.store(CY1 + FDX12); - stack_CY2.store(CY2 + FDX23); - stack_CY3.store(CY3 + FDX31); - stack_buffer.store(buffer[pitch * pixelsize]); - stack_subsectorbuffer.store(subsectorbuffer[pitch]); - stack_iy.store(iy + 1); - } - loopy.end_block(); - - if (variant == TriDrawVariant::Stencil || variant == TriDrawVariant::StencilClose) - { - SSAIfBlock branch; - SSABool restored = stack_stencilblock_restored.load(); - branch.if_block(restored); - { - SSAUByte lastStencilValue = stack_stencilblock_lastval.load(); - StencilClear(lastStencilValue); - } - branch.end_block(); - } -} - -#if 0 -void DrawTriangleCodegen::LoopMaskedStoreBlock() -{ - if (variant == TriDrawVariant::Stencil) - { - } - else if (variant == TriDrawVariant::StencilClose) - { - } - else - { - int pixelsize = truecolor ? 4 : 1; - - AffineW = posx_w; - for (int i = 0; i < TriVertex::NumVarying; i++) - AffineVaryingPosY[i] = posx_varying[i]; - - SSAInt CY1 = C1 + DX12 * y0 - DY12 * x0; - SSAInt CY2 = C2 + DX23 * y0 - DY23 * x0; - SSAInt CY3 = C3 + DX31 * y0 - DY31 * x0; - - for (int iy = 0; iy < q; iy++) - { - SSAUBytePtr buffer = dest[(x + iy * pitch) * pixelsize]; - SSAIntPtr subsectorbuffer = subsectorGBuffer[x + iy * pitch]; - - SetupAffineBlock(); - - SSAInt CX1 = CY1; - SSAInt CX2 = CY2; - SSAInt CX3 = CY3; - - for (int ix = 0; ix < q; ix += 4) - { - SSABool covered[4]; - for (int maskindex = 0; maskindex < 4; maskindex++) - { - covered[maskindex] = CX1 > SSAInt(0) && CX2 > SSAInt(0) && CX3 > SSAInt(0); - - if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) - { - auto xx = SSAInt(ix + maskindex); - auto yy = SSAInt(iy); - covered[maskindex] = covered[maskindex] && SSABool::compare_uge(StencilGet(xx, yy), stencilTestValue) && subsectorbuffer[ix + maskindex].load(true) >= subsectorDepth; - } - else if (variant == TriDrawVariant::StencilClose) - { - auto xx = SSAInt(ix + maskindex); - auto yy = SSAInt(iy); - covered[maskindex] = covered[maskindex] && SSABool::compare_uge(StencilGet(xx, yy), stencilTestValue); - } - else - { - auto xx = SSAInt(ix + maskindex); - auto yy = SSAInt(iy); - covered[maskindex] = covered[maskindex] && StencilGet(xx, yy) == stencilTestValue; - } - - CX1 = CX1 - FDY12; - CX2 = CX2 - FDY23; - CX3 = CX3 - FDY31; - } - - SSAUBytePtr buf = buffer[ix * pixelsize]; - if (truecolor) - { - SSAVec16ub pixels16 = buf.load_unaligned_vec16ub(false); - SSAVec8s pixels8hi = SSAVec8s::extendhi(pixels16); - SSAVec8s pixels8lo = SSAVec8s::extendlo(pixels16); - SSAVec4i pixels[4] = - { - SSAVec4i::extendlo(pixels8lo), - SSAVec4i::extendhi(pixels8lo), - SSAVec4i::extendlo(pixels8hi), - SSAVec4i::extendhi(pixels8hi) - }; - - for (int sse = 0; sse < 4; sse++) - { - pixels[sse] = ProcessPixel32(pixels[sse], AffineVaryingPosX); - - for (int i = 0; i < TriVertex::NumVarying; i++) - AffineVaryingPosX[i] = AffineVaryingPosX[i] + AffineVaryingStepX[i]; - } - - buf.store_masked_vec16ub(SSAVec16ub(SSAVec8s(pixels[0], pixels[1]), SSAVec8s(pixels[2], pixels[3])), covered); - } - else - { - SSAVec4i pixelsvec = buf.load_vec4ub(false); - SSAInt pixels[4] = - { - pixelsvec[0], - pixelsvec[1], - pixelsvec[2], - pixelsvec[3] - }; - - for (int sse = 0; sse < 4; sse++) - { - pixels[sse] = ProcessPixel8(pixels[sse], AffineVaryingPosX); - - for (int i = 0; i < TriVertex::NumVarying; i++) - AffineVaryingPosX[i] = AffineVaryingPosX[i] + AffineVaryingStepX[i]; - } - - buf.store_masked_vec4ub(SSAVec4i(pixels[0], pixels[1], pixels[2], pixels[3]), covered); - } - - if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) - subsectorbuffer[ix].store_masked_vec4i(SSAVec4i(subsectorDepth), covered); - } - - AffineW = AffineW + gradWY; - for (int i = 0; i < TriVertex::NumVarying; i++) - AffineVaryingPosY[i] = AffineVaryingPosY[i] + gradVaryingY[i]; - - CY1 = CY1 + FDX12; - CY2 = CY2 + FDX23; - CY3 = CY3 + FDX31; - } - } -} -#endif - -void DrawTriangleCodegen::SetStencilBlock(SSAInt block) -{ - StencilBlock = stencilValues[block * 64]; - StencilBlockMask = stencilMasks[block]; -} - -SSAUByte DrawTriangleCodegen::StencilGetSingle() -{ - return StencilBlockMask.load(false).trunc_ubyte(); -} - -void DrawTriangleCodegen::StencilClear(SSAUByte value) -{ - StencilBlockMask.store(SSAInt(0xffffff00) | value.zext_int()); -} - -SSABool DrawTriangleCodegen::StencilIsSingleValue() -{ - return (StencilBlockMask.load(false) & SSAInt(0xffffff00)) == SSAInt(0xffffff00); -} - -void DrawTriangleCodegen::LoadArgs(SSAValue args, SSAValue thread_data) -{ - dest = args[0][0].load(true); - pitch = args[0][1].load(true); - v1 = LoadTriVertex(args[0][2].load(true)); - v2 = LoadTriVertex(args[0][3].load(true)); - v3 = LoadTriVertex(args[0][4].load(true)); - clipright = args[0][6].load(true); - clipbottom = args[0][8].load(true); - texturePixels = args[0][9].load(true); - textureWidth = args[0][10].load(true); - textureHeight = args[0][11].load(true); - translation = args[0][12].load(true); - LoadUniforms(args[0][13].load(true)); - stencilValues = args[0][14].load(true); - stencilMasks = args[0][15].load(true); - stencilPitch = args[0][16].load(true); - stencilTestValue = args[0][17].load(true); - stencilWriteValue = args[0][18].load(true); - subsectorGBuffer = args[0][19].load(true); - if (!truecolor) - { - Colormaps = args[0][20].load(true); - RGB32k = args[0][21].load(true); - BaseColors = args[0][22].load(true); - } - - thread.core = thread_data[0][0].load(true); - thread.num_cores = thread_data[0][1].load(true); - thread.pass_start_y = SSAInt(0); - thread.pass_end_y = SSAInt(32000); -} - -#endif diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.h b/tools/drawergen/fixedfunction/drawtrianglecodegen.h index 8197656fa..69783e845 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.h +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.h @@ -109,128 +109,3 @@ private: bool colorfill; int pixelsize; }; - -#if 0 - -class DrawTriangleCodegen : public DrawerCodegen -{ -public: - void Generate(TriDrawVariant variant, TriBlendMode blendmode, bool truecolor, SSAValue args, SSAValue thread_data); - -private: - void LoadArgs(SSAValue args, SSAValue thread_data); - SSATriVertex LoadTriVertex(SSAValue v); - void LoadUniforms(SSAValue uniforms); - void Setup(); - SSAInt FloatTo28_4(SSAFloat v); - void LoopBlockY(); - void LoopBlockX(); - void LoopFullBlock(); - void LoopPartialBlock(bool isSingleStencilValue); - void SetupAffineBlock(); - - SSAVec4i ProcessPixel32(SSAVec4i bg, SSAInt *varying); - SSAInt ProcessPixel8(SSAInt bg, SSAInt *varying); - - SSAVec4i TranslateSample32(SSAInt *varying); - SSAInt TranslateSample8(SSAInt *varying); - SSAVec4i Sample32(SSAInt *varying); - SSAInt Sample8(SSAInt *varying); - SSAInt Shade8(SSAInt c); - SSAVec4i ToBgra(SSAInt index); - SSAInt ToPal8(SSAVec4i c); - - SSAVec4i FadeOut(SSAInt frac, SSAVec4i color); - - void SetStencilBlock(SSAInt block); - void StencilClear(SSAUByte value); - SSAUByte StencilGetSingle(); - SSABool StencilIsSingleValue(); - - SSAFloat gradx(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2); - SSAFloat grady(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2); - - TriDrawVariant variant; - TriBlendMode blendmode; - bool truecolor; - - SSAStack stack_C1, stack_C2, stack_C3; - SSAStack stack_y; - SSAStack stack_dest; - SSAStack stack_x; - SSAStack stack_buffer; - SSAStack stack_iy, stack_ix; - SSAStack stack_CY1, stack_CY2, stack_CY3; - SSAStack stack_CX1, stack_CX2, stack_CX3; - SSAStack stack_posy_w, stack_posy_varying[TriVertex::NumVarying]; - SSAStack stack_posx_w, stack_posx_varying[TriVertex::NumVarying]; - SSAStack stack_AffineW; - SSAStack stack_AffineVaryingPosY[TriVertex::NumVarying]; - SSAStack stack_AffineVaryingPosX[TriVertex::NumVarying]; - SSAStack stack_stencilblock_restored; - SSAStack stack_stencilblock_lastval; - - SSAUBytePtr dest; - SSAInt pitch; - SSATriVertex v1; - SSATriVertex v2; - SSATriVertex v3; - SSAInt clipright; - SSAInt clipbottom; - SSAUBytePtr texturePixels; - SSAInt textureWidth; - SSAInt textureHeight; - SSAUBytePtr translation; - SSAInt color, srcalpha, destalpha; - - SSAInt light; - SSAShadeConstants shade_constants; - SSABool is_simple_shade; - SSABool is_nearest_filter; - SSABool is_fixed_light; - - SSAUBytePtr stencilValues; - SSAIntPtr stencilMasks; - SSAInt stencilPitch; - SSAUByte stencilTestValue; - SSAUByte stencilWriteValue; - - SSAUBytePtr Colormaps; - SSAUBytePtr RGB32k; - SSAUBytePtr BaseColors; - - SSAWorkerThread thread; - - // Block size, standard 8x8 (must be power of two) - const int q = 8; - - SSAInt Y1, Y2, Y3; - SSAInt X1, X2, X3; - SSAInt DX12, DX23, DX31; - SSAInt DY12, DY23, DY31; - SSAInt FDX12, FDX23, FDX31; - SSAInt FDY12, FDY23, FDY31; - SSAInt minx, maxx, miny, maxy; - SSAInt C1, C2, C3; - SSAFloat gradWX, gradWY; - SSAFloat gradVaryingX[TriVertex::NumVarying], gradVaryingY[TriVertex::NumVarying]; - SSAFloat shade; - - SSAInt x, y; - SSAInt x0, x1, y0, y1; - SSAInt currentlight; - SSAUBytePtr currentcolormap; - SSAFloat AffineW; - SSABool AffineLinear; - SSAFloat AffineVaryingPosY[TriVertex::NumVarying]; - SSAInt AffineVaryingPosX[TriVertex::NumVarying]; - SSAInt AffineVaryingStepX[TriVertex::NumVarying]; - - SSAFloat posy_w, posy_varying[TriVertex::NumVarying]; - SSAFloat posx_w, posx_varying[TriVertex::NumVarying]; - - SSAUBytePtr StencilBlock; - SSAIntPtr StencilBlockMask; -}; - -#endif diff --git a/tools/drawergen/fixedfunction/setuptrianglecodegen.cpp b/tools/drawergen/fixedfunction/setuptrianglecodegen.cpp new file mode 100644 index 000000000..f29764d9e --- /dev/null +++ b/tools/drawergen/fixedfunction/setuptrianglecodegen.cpp @@ -0,0 +1,573 @@ +/* +** DrawTriangle code generation +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include "precomp.h" +#include "timestamp.h" +#include "fixedfunction/setuptrianglecodegen.h" +#include "ssa/ssa_function.h" +#include "ssa/ssa_scope.h" +#include "ssa/ssa_for_block.h" +#include "ssa/ssa_if_block.h" +#include "ssa/ssa_stack.h" +#include "ssa/ssa_function.h" +#include "ssa/ssa_struct_type.h" +#include "ssa/ssa_value.h" + +void SetupTriangleCodegen::Generate(bool subsectorTest, SSAValue args, SSAValue thread_data) +{ + this->subsectorTest = subsectorTest; + LoadArgs(args, thread_data); + Setup(); + LoopBlockY(); +} + +SSAInt SetupTriangleCodegen::FloatTo28_4(SSAFloat v) +{ + // SSAInt(SSAFloat::round(16.0f * v), false); + SSAInt a = SSAInt(v * 32.0f, false); + return (a + (a.ashr(31) | SSAInt(1))).ashr(1); +} + +void SetupTriangleCodegen::Setup() +{ + // 28.4 fixed-point coordinates + Y1 = FloatTo28_4(v1.y); + Y2 = FloatTo28_4(v2.y); + Y3 = FloatTo28_4(v3.y); + + X1 = FloatTo28_4(v1.x); + X2 = FloatTo28_4(v2.x); + X3 = FloatTo28_4(v3.x); + + // Deltas + DX12 = X1 - X2; + DX23 = X2 - X3; + DX31 = X3 - X1; + + DY12 = Y1 - Y2; + DY23 = Y2 - Y3; + DY31 = Y3 - Y1; + + // Fixed-point deltas + FDX12 = DX12 << 4; + FDX23 = DX23 << 4; + FDX31 = DX31 << 4; + + FDY12 = DY12 << 4; + FDY23 = DY23 << 4; + FDY31 = DY31 << 4; + + // Bounding rectangle + minx = SSAInt::MAX((SSAInt::MIN(SSAInt::MIN(X1, X2), X3) + 0xF).ashr(4), SSAInt(0)); + maxx = SSAInt::MIN((SSAInt::MAX(SSAInt::MAX(X1, X2), X3) + 0xF).ashr(4), clipright - 1); + miny = SSAInt::MAX((SSAInt::MIN(SSAInt::MIN(Y1, Y2), Y3) + 0xF).ashr(4), SSAInt(0)); + maxy = SSAInt::MIN((SSAInt::MAX(SSAInt::MAX(Y1, Y2), Y3) + 0xF).ashr(4), clipbottom - 1); + + SSAIfBlock if0; + if0.if_block(minx >= maxx || miny >= maxy); + if0.end_retvoid(); + + // Start in corner of 8x8 block + minx = minx & ~(q - 1); + miny = miny & ~(q - 1); + + // Half-edge constants + C1 = DY12 * X1 - DX12 * Y1; + C2 = DY23 * X2 - DX23 * Y2; + C3 = DY31 * X3 - DX31 * Y3; + + // Correct for fill convention + SSAIfBlock if1; + if1.if_block(DY12 < SSAInt(0) || (DY12 == SSAInt(0) && DX12 > SSAInt(0))); + stack_C1.store(C1 + 1); + if1.else_block(); + stack_C1.store(C1); + if1.end_block(); + C1 = stack_C1.load(); + SSAIfBlock if2; + if2.if_block(DY23 < SSAInt(0) || (DY23 == SSAInt(0) && DX23 > SSAInt(0))); + stack_C2.store(C2 + 1); + if2.else_block(); + stack_C2.store(C2); + if2.end_block(); + C2 = stack_C2.load(); + SSAIfBlock if3; + if3.if_block(DY31 < SSAInt(0) || (DY31 == SSAInt(0) && DX31 > SSAInt(0))); + stack_C3.store(C3 + 1); + if3.else_block(); + stack_C3.store(C3); + if3.end_block(); + C3 = stack_C3.load(); +} + +void SetupTriangleCodegen::LoopBlockY() +{ + SSAInt blocks_skipped = skipped_by_thread(miny / q, thread); + stack_y.store(miny + blocks_skipped * q); + stack_subsectorGBuffer.store(subsectorGBuffer[blocks_skipped * q * pitch]); + + SSAForBlock loop; + y = stack_y.load(); + subsectorGBuffer = stack_subsectorGBuffer.load(); + loop.loop_block(y < maxy, 0); + { + LoopBlockX(); + + stack_subsectorGBuffer.store(subsectorGBuffer[q * pitch * thread.num_cores]); + stack_y.store(y + thread.num_cores * q); + } + loop.end_block(); +} + +void SetupTriangleCodegen::LoopBlockX() +{ + stack_x.store(minx); + + SSAForBlock loop; + x = stack_x.load(); + loop.loop_block(x < maxx, 0); + { + // Corners of block + x0 = x << 4; + x1 = (x + q - 1) << 4; + y0 = y << 4; + y1 = (y + q - 1) << 4; + + // Evaluate half-space functions + SSABool a00 = C1 + DX12 * y0 - DY12 * x0 > SSAInt(0); + SSABool a10 = C1 + DX12 * y0 - DY12 * x1 > SSAInt(0); + SSABool a01 = C1 + DX12 * y1 - DY12 * x0 > SSAInt(0); + SSABool a11 = C1 + DX12 * y1 - DY12 * x1 > SSAInt(0); + + SSAInt a = (a00.zext_int() << 0) | (a10.zext_int() << 1) | (a01.zext_int() << 2) | (a11.zext_int() << 3); + + SSABool b00 = C2 + DX23 * y0 - DY23 * x0 > SSAInt(0); + SSABool b10 = C2 + DX23 * y0 - DY23 * x1 > SSAInt(0); + SSABool b01 = C2 + DX23 * y1 - DY23 * x0 > SSAInt(0); + SSABool b11 = C2 + DX23 * y1 - DY23 * x1 > SSAInt(0); + SSAInt b = (b00.zext_int() << 0) | (b10.zext_int() << 1) | (b01.zext_int() << 2) | (b11.zext_int() << 3); + + SSABool c00 = C3 + DX31 * y0 - DY31 * x0 > SSAInt(0); + SSABool c10 = C3 + DX31 * y0 - DY31 * x1 > SSAInt(0); + SSABool c01 = C3 + DX31 * y1 - DY31 * x0 > SSAInt(0); + SSABool c11 = C3 + DX31 * y1 - DY31 * x1 > SSAInt(0); + SSAInt c = (c00.zext_int() << 0) | (c10.zext_int() << 1) | (c01.zext_int() << 2) | (c11.zext_int() << 3); + + // Skip block when outside an edge + SSABool process_block = !(a == SSAInt(0) || b == SSAInt(0) || c == SSAInt(0)); + + SetStencilBlock(x / 8 + y / 8 * stencilPitch); + + // Stencil test the whole block, if possible + if (subsectorTest) + { + process_block = process_block && (!StencilIsSingleValue() || SSABool::compare_uge(StencilGetSingle(), stencilTestValue)); + } + else + { + process_block = process_block && (!StencilIsSingleValue() || StencilGetSingle() == stencilTestValue); + } + + SSAIfBlock branch; + branch.if_block(process_block); + + // Check if block needs clipping + SSABool clipneeded = (x + q) > clipright || (y + q) > clipbottom; + + SSABool covered = a == SSAInt(0xF) && b == SSAInt(0xF) && c == SSAInt(0xF) && !clipneeded && StencilIsSingleValue(); + + // Accept whole block when totally covered + SSAIfBlock branch_covered; + branch_covered.if_block(covered); + { + LoopFullBlock(); + } + branch_covered.else_block(); + { + SSAIfBlock branch_covered_stencil; + branch_covered_stencil.if_block(StencilIsSingleValue()); + { + SSABool stenciltestpass; + if (subsectorTest) + { + stenciltestpass = SSABool::compare_uge(StencilGetSingle(), stencilTestValue); + } + else + { + stenciltestpass = StencilGetSingle() == stencilTestValue; + } + + SSAIfBlock branch_stenciltestpass; + branch_stenciltestpass.if_block(stenciltestpass); + { + LoopPartialBlock(true); + } + branch_stenciltestpass.end_block(); + } + branch_covered_stencil.else_block(); + { + LoopPartialBlock(false); + } + branch_covered_stencil.end_block(); + } + branch_covered.end_block(); + + branch.end_block(); + + stack_x.store(x + q); + } + loop.end_block(); +} + +void SetupTriangleCodegen::LoopFullBlock() +{ + /* + if (variant == TriDrawVariant::Stencil) + { + StencilClear(stencilWriteValue); + } + else if (variant == TriDrawVariant::StencilClose) + { + StencilClear(stencilWriteValue); + for (int iy = 0; iy < q; iy++) + { + SSAIntPtr subsectorbuffer = subsectorGBuffer[x + iy * pitch]; + for (int ix = 0; ix < q; ix += 4) + { + subsectorbuffer[ix].store_unaligned_vec4i(SSAVec4i(subsectorDepth)); + } + } + } + else + { + int pixelsize = truecolor ? 4 : 1; + + AffineW = posx_w; + for (int i = 0; i < TriVertex::NumVarying; i++) + AffineVaryingPosY[i] = posx_varying[i]; + + for (int iy = 0; iy < q; iy++) + { + SSAUBytePtr buffer = dest[(x + iy * pitch) * pixelsize]; + SSAIntPtr subsectorbuffer = subsectorGBuffer[x + iy * pitch]; + + SetupAffineBlock(); + + for (int ix = 0; ix < q; ix += 4) + { + SSAUBytePtr buf = buffer[ix * pixelsize]; + if (truecolor) + { + SSAVec16ub pixels16 = buf.load_unaligned_vec16ub(false); + SSAVec8s pixels8hi = SSAVec8s::extendhi(pixels16); + SSAVec8s pixels8lo = SSAVec8s::extendlo(pixels16); + SSAVec4i pixels[4] = + { + SSAVec4i::extendlo(pixels8lo), + SSAVec4i::extendhi(pixels8lo), + SSAVec4i::extendlo(pixels8hi), + SSAVec4i::extendhi(pixels8hi) + }; + + for (int sse = 0; sse < 4; sse++) + { + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + { + SSABool subsectorTest = subsectorbuffer[ix].load(true) >= subsectorDepth; + pixels[sse] = subsectorTest.select(ProcessPixel32(pixels[sse], AffineVaryingPosX), pixels[sse]); + } + else + { + pixels[sse] = ProcessPixel32(pixels[sse], AffineVaryingPosX); + } + + for (int i = 0; i < TriVertex::NumVarying; i++) + AffineVaryingPosX[i] = AffineVaryingPosX[i] + AffineVaryingStepX[i]; + } + + buf.store_unaligned_vec16ub(SSAVec16ub(SSAVec8s(pixels[0], pixels[1]), SSAVec8s(pixels[2], pixels[3]))); + } + else + { + SSAVec4i pixelsvec = buf.load_vec4ub(false); + SSAInt pixels[4] = + { + pixelsvec[0], + pixelsvec[1], + pixelsvec[2], + pixelsvec[3] + }; + + for (int sse = 0; sse < 4; sse++) + { + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + { + SSABool subsectorTest = subsectorbuffer[ix].load(true) >= subsectorDepth; + pixels[sse] = subsectorTest.select(ProcessPixel8(pixels[sse], AffineVaryingPosX), pixels[sse]); + } + else + { + pixels[sse] = ProcessPixel8(pixels[sse], AffineVaryingPosX); + } + + for (int i = 0; i < TriVertex::NumVarying; i++) + AffineVaryingPosX[i] = AffineVaryingPosX[i] + AffineVaryingStepX[i]; + } + + buf.store_vec4ub(SSAVec4i(pixels[0], pixels[1], pixels[2], pixels[3])); + } + + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) + subsectorbuffer[ix].store_unaligned_vec4i(SSAVec4i(subsectorDepth)); + } + + AffineW = AffineW + gradWY; + for (int i = 0; i < TriVertex::NumVarying; i++) + AffineVaryingPosY[i] = AffineVaryingPosY[i] + gradVaryingY[i]; + } + } + */ +} + +void SetupTriangleCodegen::LoopPartialBlock(bool isSingleStencilValue) +{ + /* + int pixelsize = truecolor ? 4 : 1; + + if (variant == TriDrawVariant::Stencil || variant == TriDrawVariant::StencilClose) + { + if (isSingleStencilValue) + { + SSAInt stencilMask = StencilBlockMask.load(false); + SSAUByte val0 = stencilMask.trunc_ubyte(); + for (int i = 0; i < 8 * 8; i++) + StencilBlock[i].store(val0); + StencilBlockMask.store(SSAInt(0)); + } + + SSAUByte lastStencilValue = StencilBlock[0].load(false); + stack_stencilblock_restored.store(SSABool(true)); + stack_stencilblock_lastval.store(lastStencilValue); + } + + stack_CY1.store(C1 + DX12 * y0 - DY12 * x0); + stack_CY2.store(C2 + DX23 * y0 - DY23 * x0); + stack_CY3.store(C3 + DX31 * y0 - DY31 * x0); + stack_iy.store(SSAInt(0)); + stack_buffer.store(dest[x * pixelsize]); + stack_subsectorbuffer.store(subsectorGBuffer[x]); + stack_AffineW.store(posx_w); + for (int i = 0; i < TriVertex::NumVarying; i++) + { + stack_AffineVaryingPosY[i].store(posx_varying[i]); + } + + SSAForBlock loopy; + SSAInt iy = stack_iy.load(); + SSAUBytePtr buffer = stack_buffer.load(); + SSAIntPtr subsectorbuffer = stack_subsectorbuffer.load(); + SSAInt CY1 = stack_CY1.load(); + SSAInt CY2 = stack_CY2.load(); + SSAInt CY3 = stack_CY3.load(); + AffineW = stack_AffineW.load(); + for (int i = 0; i < TriVertex::NumVarying; i++) + AffineVaryingPosY[i] = stack_AffineVaryingPosY[i].load(); + loopy.loop_block(iy < SSAInt(q), q); + { + SetupAffineBlock(); + + for (int i = 0; i < TriVertex::NumVarying; i++) + stack_AffineVaryingPosX[i].store(AffineVaryingPosX[i]); + + stack_CX1.store(CY1); + stack_CX2.store(CY2); + stack_CX3.store(CY3); + stack_ix.store(SSAInt(0)); + + SSAForBlock loopx; + SSABool stencilblock_restored; + SSAUByte lastStencilValue; + if (variant == TriDrawVariant::Stencil || variant == TriDrawVariant::StencilClose) + { + stencilblock_restored = stack_stencilblock_restored.load(); + lastStencilValue = stack_stencilblock_lastval.load(); + } + SSAInt ix = stack_ix.load(); + SSAInt CX1 = stack_CX1.load(); + SSAInt CX2 = stack_CX2.load(); + SSAInt CX3 = stack_CX3.load(); + for (int i = 0; i < TriVertex::NumVarying; i++) + AffineVaryingPosX[i] = stack_AffineVaryingPosX[i].load(); + loopx.loop_block(ix < SSAInt(q), q); + { + SSABool visible = (ix + x < clipright) && (iy + y < clipbottom); + SSABool covered = CX1 > SSAInt(0) && CX2 > SSAInt(0) && CX3 > SSAInt(0) && visible; + + if (!isSingleStencilValue) + { + SSAUByte stencilValue = StencilBlock[ix + iy * 8].load(false); + + if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + { + covered = covered && SSABool::compare_uge(stencilValue, stencilTestValue) && subsectorbuffer[ix].load(true) >= subsectorDepth; + } + else if (variant == TriDrawVariant::StencilClose) + { + covered = covered && SSABool::compare_uge(stencilValue, stencilTestValue); + } + else + { + covered = covered && stencilValue == stencilTestValue; + } + } + else if (variant == TriDrawVariant::DrawSubsector || variant == TriDrawVariant::FillSubsector || variant == TriDrawVariant::FuzzSubsector) + { + covered = covered && subsectorbuffer[ix].load(true) >= subsectorDepth; + } + + SSAIfBlock branch; + branch.if_block(covered); + { + if (variant == TriDrawVariant::Stencil) + { + StencilBlock[ix + iy * 8].store(stencilWriteValue); + } + else if (variant == TriDrawVariant::StencilClose) + { + StencilBlock[ix + iy * 8].store(stencilWriteValue); + subsectorbuffer[ix].store(subsectorDepth); + } + else + { + SSAUBytePtr buf = buffer[ix * pixelsize]; + + if (truecolor) + { + SSAVec4i bg = buf.load_vec4ub(false); + buf.store_vec4ub(ProcessPixel32(bg, AffineVaryingPosX)); + } + else + { + SSAUByte bg = buf.load(false); + buf.store(ProcessPixel8(bg.zext_int(), AffineVaryingPosX).trunc_ubyte()); + } + + if (variant != TriDrawVariant::DrawSubsector && variant != TriDrawVariant::FillSubsector && variant != TriDrawVariant::FuzzSubsector) + subsectorbuffer[ix].store(subsectorDepth); + } + } + branch.end_block(); + + if (variant == TriDrawVariant::Stencil || variant == TriDrawVariant::StencilClose) + { + SSAUByte newStencilValue = StencilBlock[ix + iy * 8].load(false); + stack_stencilblock_restored.store(stencilblock_restored && newStencilValue == lastStencilValue); + stack_stencilblock_lastval.store(newStencilValue); + } + + for (int i = 0; i < TriVertex::NumVarying; i++) + stack_AffineVaryingPosX[i].store(AffineVaryingPosX[i] + AffineVaryingStepX[i]); + + stack_CX1.store(CX1 - FDY12); + stack_CX2.store(CX2 - FDY23); + stack_CX3.store(CX3 - FDY31); + stack_ix.store(ix + 1); + } + loopx.end_block(); + + stack_AffineW.store(AffineW + gradWY); + for (int i = 0; i < TriVertex::NumVarying; i++) + stack_AffineVaryingPosY[i].store(AffineVaryingPosY[i] + gradVaryingY[i]); + stack_CY1.store(CY1 + FDX12); + stack_CY2.store(CY2 + FDX23); + stack_CY3.store(CY3 + FDX31); + stack_buffer.store(buffer[pitch * pixelsize]); + stack_subsectorbuffer.store(subsectorbuffer[pitch]); + stack_iy.store(iy + 1); + } + loopy.end_block(); + + if (variant == TriDrawVariant::Stencil || variant == TriDrawVariant::StencilClose) + { + SSAIfBlock branch; + SSABool restored = stack_stencilblock_restored.load(); + branch.if_block(restored); + { + SSAUByte lastStencilValue = stack_stencilblock_lastval.load(); + StencilClear(lastStencilValue); + } + branch.end_block(); + } + */ +} + +void SetupTriangleCodegen::SetStencilBlock(SSAInt block) +{ + StencilBlock = stencilValues[block * 64]; + StencilBlockMask = stencilMasks[block]; +} + +SSAUByte SetupTriangleCodegen::StencilGetSingle() +{ + return StencilBlockMask.load(false).trunc_ubyte(); +} + +void SetupTriangleCodegen::StencilClear(SSAUByte value) +{ + StencilBlockMask.store(SSAInt(0xffffff00) | value.zext_int()); +} + +SSABool SetupTriangleCodegen::StencilIsSingleValue() +{ + return (StencilBlockMask.load(false) & SSAInt(0xffffff00)) == SSAInt(0xffffff00); +} + +void SetupTriangleCodegen::LoadArgs(SSAValue args, SSAValue thread_data) +{ + pitch = args[0][1].load(true); + v1 = LoadTriVertex(args[0][2].load(true)); + v2 = LoadTriVertex(args[0][3].load(true)); + v3 = LoadTriVertex(args[0][4].load(true)); + clipright = args[0][6].load(true); + clipbottom = args[0][8].load(true); + stencilValues = args[0][14].load(true); + stencilMasks = args[0][15].load(true); + stencilPitch = args[0][16].load(true); + stencilTestValue = args[0][17].load(true); + stencilWriteValue = args[0][18].load(true); + subsectorGBuffer = args[0][19].load(true); + + thread.core = thread_data[0][0].load(true); + thread.num_cores = thread_data[0][1].load(true); + thread.pass_start_y = SSAInt(0); + thread.pass_end_y = SSAInt(32000); +} + +SSASetupVertex SetupTriangleCodegen::LoadTriVertex(SSAValue ptr) +{ + SSASetupVertex v; + v.x = ptr[0][0].load(true); + v.y = ptr[0][1].load(true); + v.z = ptr[0][2].load(true); + v.w = ptr[0][3].load(true); + return v; +} diff --git a/tools/drawergen/fixedfunction/setuptrianglecodegen.h b/tools/drawergen/fixedfunction/setuptrianglecodegen.h new file mode 100644 index 000000000..f8db559a2 --- /dev/null +++ b/tools/drawergen/fixedfunction/setuptrianglecodegen.h @@ -0,0 +1,98 @@ +/* +** SetupTriangle code generation +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +#include "drawercodegen.h" + +struct SSASetupVertex +{ + SSAFloat x, y, z, w; +}; + +class SetupTriangleCodegen : public DrawerCodegen +{ +public: + void Generate(bool subsectorTest, SSAValue args, SSAValue thread_data); + +private: + void LoadArgs(SSAValue args, SSAValue thread_data); + SSASetupVertex LoadTriVertex(SSAValue v); + void Setup(); + SSAInt FloatTo28_4(SSAFloat v); + void LoopBlockY(); + void LoopBlockX(); + void LoopFullBlock(); + void LoopPartialBlock(bool isSingleStencilValue); + + void SetStencilBlock(SSAInt block); + void StencilClear(SSAUByte value); + SSAUByte StencilGetSingle(); + SSABool StencilIsSingleValue(); + + bool subsectorTest; + + SSAStack stack_C1, stack_C2, stack_C3; + SSAStack stack_y; + SSAStack stack_subsectorGBuffer; + SSAStack stack_x; + SSAStack stack_buffer; + SSAStack stack_iy, stack_ix; + SSAStack stack_CY1, stack_CY2, stack_CY3; + SSAStack stack_CX1, stack_CX2, stack_CX3; + //SSAStack stack_stencilblock_restored; + //SSAStack stack_stencilblock_lastval; + + SSAUBytePtr subsectorGBuffer; + SSAInt pitch; + SSASetupVertex v1; + SSASetupVertex v2; + SSASetupVertex v3; + SSAInt clipright; + SSAInt clipbottom; + + SSAUBytePtr stencilValues; + SSAIntPtr stencilMasks; + SSAInt stencilPitch; + SSAUByte stencilTestValue; + SSAUByte stencilWriteValue; + + SSAWorkerThread thread; + + // Block size, standard 8x8 (must be power of two) + const int q = 8; + + SSAInt Y1, Y2, Y3; + SSAInt X1, X2, X3; + SSAInt DX12, DX23, DX31; + SSAInt DY12, DY23, DY31; + SSAInt FDX12, FDX23, FDX31; + SSAInt FDY12, FDY23, FDY31; + SSAInt minx, maxx, miny, maxy; + SSAInt C1, C2, C3; + + SSAInt x, y; + SSAInt x0, x1, y0, y1; + + SSAUBytePtr StencilBlock; + SSAIntPtr StencilBlockMask; +}; From 9302b3b8bf03e9cb399676f86542e261c103be98 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 16 Dec 2016 19:09:17 +0100 Subject: [PATCH 1417/1509] Fix 64 bit building --- tools/drawergen/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/drawergen/CMakeLists.txt b/tools/drawergen/CMakeLists.txt index 12e004e28..6a5804e8a 100644 --- a/tools/drawergen/CMakeLists.txt +++ b/tools/drawergen/CMakeLists.txt @@ -7,6 +7,10 @@ include(../../precompiled_headers.cmake) # Path where it looks for the LLVM compiled files on Windows set( LLVM_PRECOMPILED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../llvm" ) +if( CMAKE_SIZEOF_VOID_P MATCHES "8" ) + set( X64 64 ) +endif() + if( NOT DRAWERGEN_LIBS ) set( DRAWERGEN_LIBS "" ) endif() From e1a874958687a0126b406c606a44fab567805658 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 16 Dec 2016 19:28:25 +0100 Subject: [PATCH 1418/1509] Wrong type --- tools/drawergen/fixedfunction/setuptrianglecodegen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/drawergen/fixedfunction/setuptrianglecodegen.h b/tools/drawergen/fixedfunction/setuptrianglecodegen.h index f8db559a2..dda7b7667 100644 --- a/tools/drawergen/fixedfunction/setuptrianglecodegen.h +++ b/tools/drawergen/fixedfunction/setuptrianglecodegen.h @@ -53,7 +53,7 @@ private: SSAStack stack_C1, stack_C2, stack_C3; SSAStack stack_y; - SSAStack stack_subsectorGBuffer; + SSAStack stack_subsectorGBuffer; SSAStack stack_x; SSAStack stack_buffer; SSAStack stack_iy, stack_ix; @@ -62,7 +62,7 @@ private: //SSAStack stack_stencilblock_restored; //SSAStack stack_stencilblock_lastval; - SSAUBytePtr subsectorGBuffer; + SSAIntPtr subsectorGBuffer; SSAInt pitch; SSASetupVertex v1; SSASetupVertex v2; From b5f3f63b9327706fd92fe78a02da2903a354105b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 16 Dec 2016 20:52:56 +0100 Subject: [PATCH 1419/1509] Minor bug fixes --- src/r_poly.cpp | 2 +- src/r_poly.h | 2 ++ src/r_poly_cull.cpp | 30 ++++++++++++++++++++++++++---- src/r_poly_scene.cpp | 2 +- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 2e100b395..f7fa33979 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -74,7 +74,7 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines) { NetUpdate(); - //swrenderer::r_dontmaplines = dontmaplines; + DontMapLines = dontmaplines; P_FindParticleSubsectors(); PO_LinkToSubsectors(); diff --git a/src/r_poly.h b/src/r_poly.h index f34106a4b..10d2e92aa 100644 --- a/src/r_poly.h +++ b/src/r_poly.h @@ -50,6 +50,8 @@ public: bool InsertSeenLinePortal(FLinePortal *portal); bool InsertSeenMirror(line_t *mirrorLine); + bool DontMapLines = false; + private: void ClearBuffers(); void SetSceneViewport(); diff --git a/src/r_poly_cull.cpp b/src/r_poly_cull.cpp index 59b7c0c5a..02a0f2fc5 100644 --- a/src/r_poly_cull.cpp +++ b/src/r_poly_cull.cpp @@ -239,10 +239,31 @@ LineSegmentRange PolyCull::GetSegmentRangeForLine(double x1, double y1, double x { double znear = 5.0; double updownnear = -400.0; + double sidenear = 400.0; - // Cull if entirely behind the portal clip plane (tbd: should we clip the segment?) - if (Vec4f::dot(PortalClipPlane, Vec4f((float)x1, (float)y1, 0.0f, 1.0f)) < 0.0f && Vec4f::dot(PortalClipPlane, Vec4f((float)x2, (float)y2, 0.0f, 1.0f)) < 0.0f) + // Clip line to the portal clip plane + float distance1 = Vec4f::dot(PortalClipPlane, Vec4f((float)x1, (float)y1, 0.0f, 1.0f)); + float distance2 = Vec4f::dot(PortalClipPlane, Vec4f((float)x2, (float)y2, 0.0f, 1.0f)); + if (distance1 < 0.0f && distance2 < 0.0f) + { return LineSegmentRange::NotVisible; + } + else if (distance1 < 0.0f || distance2 < 0.0f) + { + double t1 = 0.0f, t2 = 1.0f; + if (distance1 < 0.0f) + t1 = clamp(distance1 / (distance1 - distance2), 0.0f, 1.0f); + else + t2 = clamp(distance2 / (distance1 - distance2), 0.0f, 1.0f); + double nx1 = x1 * (1.0 - t1) + x2 * t1; + double ny1 = y1 * (1.0 - t1) + y2 * t1; + double nx2 = x1 * (1.0 - t2) + x2 * t2; + double ny2 = y1 * (1.0 - t2) + y2 * t2; + x1 = nx1; + x2 = nx2; + y1 = ny1; + y2 = ny2; + } // Transform to 2D view space: x1 = x1 - ViewPos.X; @@ -255,7 +276,8 @@ LineSegmentRange PolyCull::GetSegmentRangeForLine(double x1, double y1, double x double ry2 = x2 * ViewCos + y2 * ViewSin; // Is it potentially visible when looking straight up or down? - if (!(ry1 < updownnear && ry2 < updownnear) && !(ry1 > znear && ry2 > znear)) + if (!(ry1 < updownnear && ry2 < updownnear) && !(ry1 > znear && ry2 > znear) && + !(rx1 < -sidenear && rx2 < -sidenear) && !(rx1 > sidenear && rx2 > sidenear)) return LineSegmentRange::AlwaysVisible; // Cull if line is entirely behind view @@ -267,7 +289,7 @@ LineSegmentRange PolyCull::GetSegmentRangeForLine(double x1, double y1, double x if (ry1 < znear) t1 = clamp((znear - ry1) / (ry2 - ry1), 0.0, 1.0); if (ry2 < znear) - t2 = clamp((znear - ry1) / (ry2 - ry1), 0.0, 1.0); + t2 = clamp((znear - ry2) / (ry2 - ry1), 0.0, 1.0); if (t1 != 0.0 || t2 != 1.0) { double nx1 = rx1 * (1.0 - t1) + rx2 * t1; diff --git a/src/r_poly_scene.cpp b/src/r_poly_scene.cpp index cfb858e0b..8bf6d1ce9 100644 --- a/src/r_poly_scene.cpp +++ b/src/r_poly_scene.cpp @@ -198,7 +198,7 @@ void RenderPolyScene::RenderLine(subsector_t *sub, seg_t *line, sector_t *fronts return; // Tell automap we saw this - if (!swrenderer::r_dontmaplines && line->linedef && segmentRange != LineSegmentRange::AlwaysVisible) + if (!PolyRenderer::Instance()->DontMapLines && line->linedef && segmentRange != LineSegmentRange::AlwaysVisible) { line->linedef->flags |= ML_MAPPED; sub->flags |= SSECF_DRAWN; From ecebeed296a4a2b22f3a3c6d32b69a2f6c1d1f4b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 16 Dec 2016 22:16:24 +0100 Subject: [PATCH 1420/1509] Fix player sprites disappearing when a texture camera is visible --- src/r_poly_playersprite.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/r_poly_playersprite.cpp b/src/r_poly_playersprite.cpp index 381f2e203..bf5c2767c 100644 --- a/src/r_poly_playersprite.cpp +++ b/src/r_poly_playersprite.cpp @@ -35,11 +35,8 @@ EXTERN_CVAR(Bool, st_scale) void RenderPolyPlayerSprites::Render() { - // In theory, everything in this function could be moved to RenderRemainingSprites. - // Just in case there's some hack elsewhere that relies on this happening as part - // of the main rendering we do it exactly as the old software renderer did. - - ScreenSprites.clear(); + // This code cannot be moved directly to RenderRemainingSprites because the engine + // draws the canvas textures between this call and the final call to RenderRemainingSprites.. if (!r_drawplayersprites || !camera || @@ -90,6 +87,7 @@ void RenderPolyPlayerSprites::RenderRemainingSprites() { for (auto &sprite : ScreenSprites) sprite.Render(); + ScreenSprites.clear(); } void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac) From 6e8174d9b4cecedbadd2aa56274014bad6bf91c4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 16 Dec 2016 23:02:34 +0100 Subject: [PATCH 1421/1509] More psprite stuff --- src/r_poly_playersprite.cpp | 132 +++++++++++++++++++++++++++++++++++- 1 file changed, 130 insertions(+), 2 deletions(-) diff --git a/src/r_poly_playersprite.cpp b/src/r_poly_playersprite.cpp index bf5c2767c..cd9584b68 100644 --- a/src/r_poly_playersprite.cpp +++ b/src/r_poly_playersprite.cpp @@ -32,6 +32,8 @@ EXTERN_CVAR(Bool, r_drawplayersprites) EXTERN_CVAR(Bool, r_deathcamera) EXTERN_CVAR(Bool, st_scale) +EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) +EXTERN_CVAR(Bool, r_shadercolormaps) void RenderPolyPlayerSprites::Render() { @@ -219,7 +221,113 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa if (sprite->GetID() < PSP_TARGETCENTER) { - // Lots of complicated style and noaccel stuff + visstyle.Alpha = float(owner->Alpha); + visstyle.RenderStyle = owner->RenderStyle; + + // The software renderer cannot invert the source without inverting the overlay + // too. That means if the source is inverted, we need to do the reverse of what + // the invert overlay flag says to do. + INTBOOL invertcolormap = (visstyle.RenderStyle.Flags & STYLEF_InvertOverlay); + + if (visstyle.RenderStyle.Flags & STYLEF_InvertSource) + { + invertcolormap = !invertcolormap; + } + + FDynamicColormap *mybasecolormap = basecolormap; + + if (visstyle.RenderStyle.Flags & STYLEF_FadeToBlack) + { + if (invertcolormap) + { // Fade to white + mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(255, 255, 255), mybasecolormap->Desaturate); + invertcolormap = false; + } + else + { // Fade to black + mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(0, 0, 0), mybasecolormap->Desaturate); + } + } + + /* + if (swrenderer::realfixedcolormap != nullptr && (!swrenderer::r_swtruecolor || (r_shadercolormaps && screen->Accel2D))) + { // fixed color + visstyle.BaseColormap = swrenderer::realfixedcolormap; + visstyle.ColormapNum = 0; + } + else + { + if (invertcolormap) + { + mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate); + } + if (swrenderer::fixedlightlev >= 0) + { + visstyle.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; + visstyle.ColormapNum = swrenderer::fixedlightlev >> COLORMAPSHIFT; + } + else if (!foggy && sprite->GetState()->GetFullbright()) + { // full bright + visstyle.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; // [RH] use basecolormap + visstyle.ColormapNum = 0; + } + else + { // local light + visstyle.BaseColormap = mybasecolormap; + visstyle.ColormapNum = GETPALOOKUP(0, spriteshade); + } + } + */ + + if (camera->Inventory != nullptr) + { + BYTE oldcolormapnum = visstyle.ColormapNum; + FSWColormap *oldcolormap = visstyle.BaseColormap; + camera->Inventory->AlterWeaponSprite(&visstyle); + if (visstyle.BaseColormap != oldcolormap || visstyle.ColormapNum != oldcolormapnum) + { + // The colormap has changed. Is it one we can easily identify? + // If not, then don't bother trying to identify it for + // hardware accelerated drawing. + if (visstyle.BaseColormap < &SpecialColormaps[0] || + visstyle.BaseColormap > &SpecialColormaps.Last()) + { + noaccel = true; + } + // Has the basecolormap changed? If so, we can't hardware accelerate it, + // since we don't know what it is anymore. + else if (visstyle.BaseColormap != mybasecolormap) + { + noaccel = true; + } + } + } + // If we're drawing with a special colormap, but shaders for them are disabled, do + // not accelerate. + if (!r_shadercolormaps && (visstyle.BaseColormap >= &SpecialColormaps[0] && + visstyle.BaseColormap <= &SpecialColormaps.Last())) + { + noaccel = true; + } + // If drawing with a BOOM colormap, disable acceleration. + if (mybasecolormap == &NormalLight && NormalLight.Maps != realcolormaps.Maps) + { + noaccel = true; + } + // If the main colormap has fixed lights, and this sprite is being drawn with that + // colormap, disable acceleration so that the lights can remain fixed. + if (!noaccel && swrenderer::realfixedcolormap == nullptr && + NormalLightHasFixedLights && mybasecolormap == &NormalLight && + tex->UseBasePalette()) + { + noaccel = true; + } + // [SP] If emulating GZDoom fullbright, disable acceleration + if (r_fullbrightignoresectorcolor && swrenderer::fixedlightlev >= 0) + mybasecolormap = &FullNormalLight; + if (r_fullbrightignoresectorcolor && !foggy && sprite->GetState()->GetFullbright()) + mybasecolormap = &FullNormalLight; + colormap_to_use = mybasecolormap; } // Check for hardware-assisted 2D. If it's available, and this sprite is not @@ -245,7 +353,27 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa } } - //R_DrawVisSprite(vis); + // To do: draw sprite same way as R_DrawVisSprite(vis) here + + // Draw the fuzzy weapon: + FRenderStyle style = visstyle.RenderStyle; + style.CheckFuzz(); + if (style.BlendOp == STYLEOP_Fuzz) + { + visstyle.RenderStyle = LegacyRenderStyles[STYLE_Shadow]; + + PolyScreenSprite screenSprite; + screenSprite.Pic = tex; + screenSprite.X1 = viewwindowx + x1; + screenSprite.Y1 = viewwindowy + viewheight / 2 - texturemid * yscale - 0.5; + screenSprite.Width = tex->GetWidth() * xscale; + screenSprite.Height = tex->GetHeight() * yscale; + screenSprite.Translation = TranslationToTable(translation); + screenSprite.Flip = xiscale < 0; + screenSprite.visstyle = visstyle; + screenSprite.Colormap = colormap_to_use; + ScreenSprites.push_back(screenSprite); + } } void PolyScreenSprite::Render() From ddb18d8e3252e41fe5ff466d2400a47da8763291 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 17 Dec 2016 02:10:52 +0100 Subject: [PATCH 1422/1509] Add dynamic colormaps support --- .../fixedfunction/drawtrianglecodegen.cpp | 69 +++++++++++++------ .../fixedfunction/drawtrianglecodegen.h | 7 +- 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index 01deb1ce2..8b5df27c3 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -41,11 +41,30 @@ void DrawTriangleCodegen::Generate(TriBlendMode blendmode, bool truecolor, bool LoadArgs(args, thread_data); CalculateGradients(); - DrawFullSpans(); - DrawPartialBlocks(); + + if (truecolor) + { + SSAIfBlock branch; + branch.if_block(is_simple_shade); + { + DrawFullSpans(true); + DrawPartialBlocks(true); + } + branch.else_block(); + { + DrawFullSpans(false); + DrawPartialBlocks(false); + } + branch.end_block(); + } + else + { + DrawFullSpans(true); + DrawPartialBlocks(true); + } } -void DrawTriangleCodegen::DrawFullSpans() +void DrawTriangleCodegen::DrawFullSpans(bool isSimpleShade) { stack_i.store(SSAInt(0)); SSAForBlock loop; @@ -130,7 +149,7 @@ void DrawTriangleCodegen::DrawFullSpans() for (int sse = 0; sse < 4; sse++) { currentlight = is_fixed_light.select(light, lightpos >> 8); - pixels[sse] = ProcessPixel32(pixels[sse], varyingPos); + pixels[sse] = ProcessPixel32(pixels[sse], varyingPos, isSimpleShade); for (int j = 0; j < TriVertex::NumVarying; j++) varyingPos[j] = varyingPos[j] + varyingStep[j]; @@ -180,7 +199,7 @@ void DrawTriangleCodegen::DrawFullSpans() loop.end_block(); } -void DrawTriangleCodegen::DrawPartialBlocks() +void DrawTriangleCodegen::DrawPartialBlocks(bool isSimpleShade) { stack_i.store(SSAInt(0)); SSAForBlock loop; @@ -240,7 +259,7 @@ void DrawTriangleCodegen::DrawPartialBlocks() currentlight = is_fixed_light.select(light, lightpos >> 8); SSAUBytePtr destptr = dest[x * 4]; - destptr.store_vec4ub(ProcessPixel32(destptr.load_vec4ub(false), varyingPos)); + destptr.store_vec4ub(ProcessPixel32(destptr.load_vec4ub(false), varyingPos, isSimpleShade)); } else { @@ -381,7 +400,15 @@ SSAInt DrawTriangleCodegen::Shade8(SSAInt c) return currentcolormap[c].load(true).zext_int(); } -SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) +SSAVec4i DrawTriangleCodegen::Shade32(SSAVec4i fg, SSAInt light, bool isSimpleShade) +{ + if (isSimpleShade) + return shade_bgra_simple(fg, currentlight); + else + return shade_bgra_advanced(fg, currentlight, shade_constants); +} + +SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying, bool isSimpleShade) { SSAVec4i fg; SSAVec4i output; @@ -391,58 +418,58 @@ SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying) default: case TriBlendMode::Copy: fg = Sample32(varying); - output = blend_copy(shade_bgra_simple(fg, currentlight)); + output = blend_copy(Shade32(fg, currentlight, isSimpleShade)); break; case TriBlendMode::AlphaBlend: fg = Sample32(varying); - output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); + output = blend_alpha_blend(Shade32(fg, currentlight, isSimpleShade), bg); break; case TriBlendMode::AddSolid: fg = Sample32(varying); - output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, destalpha); + output = blend_add(Shade32(fg, currentlight, isSimpleShade), bg, srcalpha, destalpha); break; case TriBlendMode::Add: fg = Sample32(varying); - output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + output = blend_add(Shade32(fg, currentlight, isSimpleShade), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; case TriBlendMode::Sub: fg = Sample32(varying); - output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + output = blend_sub(Shade32(fg, currentlight, isSimpleShade), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; case TriBlendMode::RevSub: fg = Sample32(varying); - output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + output = blend_revsub(Shade32(fg, currentlight, isSimpleShade), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; case TriBlendMode::Stencil: fg = Sample32(varying); - output = blend_stencil(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), fg[3], bg, srcalpha, destalpha); + output = blend_stencil(Shade32(SSAVec4i::unpack(color), currentlight, isSimpleShade), fg[3], bg, srcalpha, destalpha); break; case TriBlendMode::Shaded: - output = blend_stencil(shade_bgra_simple(SSAVec4i::unpack(color), currentlight), Sample8(varying), bg, srcalpha, destalpha); + output = blend_stencil(Shade32(SSAVec4i::unpack(color), currentlight, isSimpleShade), Sample8(varying), bg, srcalpha, destalpha); break; case TriBlendMode::TranslateCopy: fg = TranslateSample32(varying); - output = blend_copy(shade_bgra_simple(fg, currentlight)); + output = blend_copy(Shade32(fg, currentlight, isSimpleShade)); break; case TriBlendMode::TranslateAlphaBlend: fg = TranslateSample32(varying); - output = blend_alpha_blend(shade_bgra_simple(fg, currentlight), bg); + output = blend_alpha_blend(Shade32(fg, currentlight, isSimpleShade), bg); break; case TriBlendMode::TranslateAdd: fg = TranslateSample32(varying); - output = blend_add(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + output = blend_add(Shade32(fg, currentlight, isSimpleShade), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; case TriBlendMode::TranslateSub: fg = TranslateSample32(varying); - output = blend_sub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + output = blend_sub(Shade32(fg, currentlight, isSimpleShade), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; case TriBlendMode::TranslateRevSub: fg = TranslateSample32(varying); - output = blend_revsub(shade_bgra_simple(fg, currentlight), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); + output = blend_revsub(Shade32(fg, currentlight, isSimpleShade), bg, srcalpha, calc_blend_bgalpha(fg, destalpha)); break; case TriBlendMode::AddSrcColorOneMinusSrcColor: fg = Sample32(varying); - output = blend_add_srccolor_oneminussrccolor(shade_bgra_simple(fg, currentlight), bg); + output = blend_add_srccolor_oneminussrccolor(Shade32(fg, currentlight, isSimpleShade), bg); break; case TriBlendMode::Skycap: fg = Sample32(varying); diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.h b/tools/drawergen/fixedfunction/drawtrianglecodegen.h index 69783e845..640a22aea 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.h +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.h @@ -48,15 +48,16 @@ private: void CalculateGradients(); SSAFloat FindGradientX(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2); SSAFloat FindGradientY(SSAFloat x0, SSAFloat y0, SSAFloat x1, SSAFloat y1, SSAFloat x2, SSAFloat y2, SSAFloat c0, SSAFloat c1, SSAFloat c2); - void DrawFullSpans(); - void DrawPartialBlocks(); + void DrawFullSpans(bool isSimpleShade); + void DrawPartialBlocks(bool isSimpleShade); - SSAVec4i ProcessPixel32(SSAVec4i bg, SSAInt *varying); + SSAVec4i ProcessPixel32(SSAVec4i bg, SSAInt *varying, bool isSimpleShade); SSAInt ProcessPixel8(SSAInt bg, SSAInt *varying); SSAVec4i TranslateSample32(SSAInt *varying); SSAInt TranslateSample8(SSAInt *varying); SSAVec4i Sample32(SSAInt *varying); SSAInt Sample8(SSAInt *varying); + SSAVec4i Shade32(SSAVec4i fg, SSAInt light, bool isSimpleShade); SSAInt Shade8(SSAInt c); SSAVec4i ToBgra(SSAInt index); SSAInt ToPal8(SSAVec4i c); From afe5d0fcdc482c51b8fd88d4daf2fc2063387308 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 17 Dec 2016 04:24:28 +0100 Subject: [PATCH 1423/1509] Simplify light calculation slightly --- tools/drawergen/fixedfunction/drawtrianglecodegen.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index 8b5df27c3..674543ff2 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -98,7 +98,7 @@ void DrawTriangleCodegen::DrawFullSpans(bool isSimpleShade) stack_posXVarying[j].store(blockPosY.Varying[j]); SSAFloat rcpW = SSAFloat((float)0x01000000) / blockPosY.W; - stack_lightpos.store(FRACUNIT - SSAInt(SSAFloat::clamp(shade - SSAFloat::MIN(SSAFloat(24.0f), globVis * blockPosY.W) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * (float)FRACUNIT, true)); + stack_lightpos.store(FRACUNIT - SSAInt(SSAFloat::clamp(shade - SSAFloat::MIN(SSAFloat(24.0f / 32.0f), globVis * blockPosY.W), SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * (float)FRACUNIT, true)); for (int j = 0; j < TriVertex::NumVarying; j++) stack_varyingPos[j].store(SSAInt(blockPosY.Varying[j] * rcpW, false)); stack_x.store(SSAInt(0)); @@ -127,7 +127,7 @@ void DrawTriangleCodegen::DrawFullSpans(bool isSimpleShade) varyingStep[j] = (nextPos - varyingPos[j]) / 8; } - SSAInt lightnext = FRACUNIT - SSAInt(SSAFloat::clamp(shade - SSAFloat::MIN(SSAFloat(24.0f), globVis * blockPosX.W) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * (float)FRACUNIT, true); + SSAInt lightnext = FRACUNIT - SSAInt(SSAFloat::clamp(shade - SSAFloat::MIN(SSAFloat(24.0f / 32.0f), globVis * blockPosX.W), SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * (float)FRACUNIT, true); SSAInt lightstep = (lightnext - lightpos) / 8; if (truecolor) @@ -231,7 +231,7 @@ void DrawTriangleCodegen::DrawPartialBlocks(bool isSimpleShade) for (int j = 0; j < TriVertex::NumVarying; j++) varyingPos[j] = SSAInt(blockPosX.Varying[j] * rcpW, false); - SSAInt lightpos = FRACUNIT - SSAInt(SSAFloat::clamp(shade - SSAFloat::MIN(SSAFloat(24.0f), globVis * blockPosX.W) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * (float)FRACUNIT, true); + SSAInt lightpos = FRACUNIT - SSAInt(SSAFloat::clamp(shade - SSAFloat::MIN(SSAFloat(24.0f / 32.0f), globVis * blockPosX.W), SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * (float)FRACUNIT, true); blockPosX.W = blockPosX.W + gradientX.W * 8.0f; for (int j = 0; j < TriVertex::NumVarying; j++) @@ -245,7 +245,7 @@ void DrawTriangleCodegen::DrawPartialBlocks(bool isSimpleShade) varyingStep[j] = (nextPos - varyingPos[j]) / 8; } - SSAInt lightnext = FRACUNIT - SSAInt(SSAFloat::clamp(shade - SSAFloat::MIN(SSAFloat(24.0f), globVis * blockPosX.W) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * (float)FRACUNIT, true); + SSAInt lightnext = FRACUNIT - SSAInt(SSAFloat::clamp(shade - SSAFloat::MIN(SSAFloat(24.0f / 32.0f), globVis * blockPosX.W), SSAFloat(0.0f), SSAFloat(31.0f / 32.0f)) * (float)FRACUNIT, true); SSAInt lightstep = (lightnext - lightpos) / 8; for (int x = 0; x < 8; x++) @@ -613,7 +613,7 @@ void DrawTriangleCodegen::CalculateGradients() } shade = (64.0f - (SSAFloat(light * 255 / 256) + 12.0f) * 32.0f / 128.0f) / 32.0f; - globVis = SSAFloat(1706.0f); + globVis = SSAFloat(1706.0f / 32.0f); } void DrawTriangleCodegen::LoadArgs(SSAValue args, SSAValue thread_data) From 2ba402dc7404116d38b54b2878046fb161ede18a Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 17 Dec 2016 04:11:52 -0500 Subject: [PATCH 1424/1509] - Implementing RGB666 colormatching to replace less precise RGB555 in some parts of the code. --- src/r_draw_pal.cpp | 91 ++++++++++++++++++++++++++++++++++++- src/textures/pngtexture.cpp | 13 ++++++ src/textures/tgatexture.cpp | 12 +++++ src/v_draw.cpp | 2 +- src/v_video.cpp | 11 +++++ src/v_video.h | 10 ++++ 6 files changed, 137 insertions(+), 2 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index cfb55a670..439321e53 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -314,10 +314,17 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { +#ifdef NO_RGB666 uint32_t fg = fg2rgb[colormap[pix]]; uint32_t bg = bg2rgb[*dest]; fg = (fg + bg) | 0x1f07c1f; *dest = RGB32k.All[fg & (fg >> 15)]; +#else + uint32_t r = clamp(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 0, 255); + uint32_t g = clamp(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 0, 255); + uint32_t b = clamp(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 0, 255); + *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; +#endif } frac += fracstep; dest += pitch; @@ -357,10 +364,17 @@ namespace swrenderer uint8_t pix = _bufplce[i][vplce[i] >> bits]; if (pix != 0) { +#ifdef NO_RGB666 uint32_t fg = fg2rgb[_palookupoffse[i][pix]]; uint32_t bg = bg2rgb[dest[i]]; fg = (fg + bg) | 0x1f07c1f; dest[i] = RGB32k.All[fg & (fg >> 15)]; +#else + uint32_t r = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].r + GPalette.BaseColors[dest[i]].r, 0, 255); + uint32_t g = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].g + GPalette.BaseColors[dest[i]].g, 0, 255); + uint32_t b = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].b + GPalette.BaseColors[dest[i]].b, 0, 255); + dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; +#endif } vplce[i] += vince[i]; } @@ -396,6 +410,7 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { +#ifdef NO_RGB666 uint32_t a = fg2rgb[colormap[pix]] + bg2rgb[*dest]; uint32_t b = a; @@ -405,6 +420,12 @@ namespace swrenderer b = b - (b >> 5); a |= b; *dest = RGB32k.All[a & (a >> 15)]; +#else + uint32_t r = clamp(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 0, 255); + uint32_t g = clamp(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 0, 255); + uint32_t b = clamp(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 0, 255); + *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; +#endif } frac += fracstep; dest += pitch; @@ -444,6 +465,7 @@ namespace swrenderer uint8_t pix = _bufplce[i][vplce[i] >> bits]; if (pix != 0) { +#ifdef NO_RGB666 uint32_t a = fg2rgb[_palookupoffse[i][pix]] + bg2rgb[dest[i]]; uint32_t b = a; @@ -453,6 +475,12 @@ namespace swrenderer b = b - (b >> 5); a |= b; dest[i] = RGB32k.All[a & (a >> 15)]; +#else + uint32_t r = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].r + GPalette.BaseColors[dest[i]].r, 0, 255); + uint32_t g = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].g + GPalette.BaseColors[dest[i]].g, 0, 255); + uint32_t b = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].b + GPalette.BaseColors[dest[i]].b, 0, 255); + dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; +#endif } vplce[i] += vince[i]; } @@ -488,6 +516,7 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { +#ifdef NO_RGB666 uint32_t a = (fg2rgb[colormap[pix]] | 0x40100400) - bg2rgb[*dest]; uint32_t b = a; @@ -496,6 +525,12 @@ namespace swrenderer a &= b; a |= 0x01f07c1f; *dest = RGB32k.All[a & (a >> 15)]; +#else + uint32_t r = clamp(-GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 0, 255); + uint32_t g = clamp(-GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 0, 255); + uint32_t b = clamp(-GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 0, 255); + *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; +#endif } frac += fracstep; dest += pitch; @@ -535,6 +570,7 @@ namespace swrenderer uint8_t pix = _bufplce[i][vplce[i] >> bits]; if (pix != 0) { +#ifdef NO_RGB666 uint32_t a = (fg2rgb[_palookupoffse[i][pix]] | 0x40100400) - bg2rgb[dest[i]]; uint32_t b = a; @@ -543,6 +579,12 @@ namespace swrenderer a &= b; a |= 0x01f07c1f; dest[i] = RGB32k.All[a & (a >> 15)]; +#else + uint32_t r = clamp(-GPalette.BaseColors[_palookupoffse[i][pix]].r + GPalette.BaseColors[dest[i]].r, 0, 255); + uint32_t g = clamp(-GPalette.BaseColors[_palookupoffse[i][pix]].g + GPalette.BaseColors[dest[i]].g, 0, 255); + uint32_t b = clamp(-GPalette.BaseColors[_palookupoffse[i][pix]].b + GPalette.BaseColors[dest[i]].b, 0, 255); + dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; +#endif } vplce[i] += vince[i]; } @@ -578,6 +620,7 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { +#ifdef NO_RGB666 uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[pix]]; uint32_t b = a; @@ -586,6 +629,12 @@ namespace swrenderer a &= b; a |= 0x01f07c1f; *dest = RGB32k.All[a & (a >> 15)]; +#else + uint32_t r = clamp(GPalette.BaseColors[colormap[pix]].r - GPalette.BaseColors[*dest].r, 0, 255); + uint32_t g = clamp(GPalette.BaseColors[colormap[pix]].g - GPalette.BaseColors[*dest].g, 0, 255); + uint32_t b = clamp(GPalette.BaseColors[colormap[pix]].b - GPalette.BaseColors[*dest].b, 0, 255); + *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; +#endif } frac += fracstep; dest += pitch; @@ -625,6 +674,7 @@ namespace swrenderer uint8_t pix = _bufplce[i][vplce[i] >> bits]; if (pix != 0) { +#ifdef NO_RGB666 uint32_t a = (bg2rgb[dest[i]] | 0x40100400) - fg2rgb[_palookupoffse[i][pix]]; uint32_t b = a; @@ -633,6 +683,12 @@ namespace swrenderer a &= b; a |= 0x01f07c1f; dest[i] = RGB32k.All[a & (a >> 15)]; +#else + uint32_t r = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].r - GPalette.BaseColors[dest[i]].r, 0, 255); + uint32_t g = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].g - GPalette.BaseColors[dest[i]].g, 0, 255); + uint32_t b = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].b - GPalette.BaseColors[dest[i]].b, 0, 255); + dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; +#endif } vplce[i] += vince[i]; } @@ -716,7 +772,11 @@ namespace swrenderer c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; +#ifdef NO_RGB666 *dest = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; +#else + *dest = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; +#endif } frac += fracstep; @@ -744,8 +804,13 @@ namespace swrenderer int solid_bottom_r = RPART(solid_bottom); int solid_bottom_g = GPART(solid_bottom); int solid_bottom_b = BPART(solid_bottom); +#ifdef NO_RGB666 uint32_t solid_top_fill = RGB32k.RGB[(solid_top_r >> 3)][(solid_top_g >> 3)][(solid_top_b >> 3)]; uint32_t solid_bottom_fill = RGB32k.RGB[(solid_bottom_r >> 3)][(solid_bottom_g >> 3)][(solid_bottom_b >> 3)]; +#else + uint32_t solid_top_fill = RGB256k.RGB[(solid_top_r >> 2)][(solid_top_g >> 2)][(solid_top_b >> 2)]; + uint32_t solid_bottom_fill = RGB256k.RGB[(solid_bottom_r >> 2)][(solid_bottom_g >> 2)][(solid_bottom_b >> 2)]; +#endif solid_top_fill = (solid_top_fill << 24) | (solid_top_fill << 16) | (solid_top_fill << 8) | solid_top_fill; solid_bottom_fill = (solid_bottom_fill << 24) | (solid_bottom_fill << 16) | (solid_bottom_fill << 8) | solid_bottom_fill; @@ -805,8 +870,11 @@ namespace swrenderer c_red = (c_red * alpha_top + solid_top_r * inv_alpha_top) >> 8; c_green = (c_green * alpha_top + solid_top_g * inv_alpha_top) >> 8; c_blue = (c_blue * alpha_top + solid_top_b * inv_alpha_top) >> 8; +#ifdef NO_RGB666 output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; - +#else + output[col] = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; +#endif frac[col] += fracstep[col]; } *((uint32_t*)dest) = *((uint32_t*)output); @@ -847,7 +915,11 @@ namespace swrenderer c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; +#ifdef NO_RGB666 output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; +#else + output[col] = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; +#endif frac[col] += fracstep[col]; } @@ -929,7 +1001,11 @@ namespace swrenderer c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; +#ifdef NO_RGB666 *dest = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; +#else + *dest = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; +#endif } frac += fracstep; @@ -959,8 +1035,13 @@ namespace swrenderer int solid_bottom_r = RPART(solid_bottom); int solid_bottom_g = GPART(solid_bottom); int solid_bottom_b = BPART(solid_bottom); +#ifdef NO_RGB666 uint32_t solid_top_fill = RGB32k.RGB[(solid_top_r >> 3)][(solid_top_g >> 3)][(solid_top_b >> 3)]; uint32_t solid_bottom_fill = RGB32k.RGB[(solid_bottom_r >> 3)][(solid_bottom_g >> 3)][(solid_bottom_b >> 3)]; +#else + uint32_t solid_top_fill = RGB256k.RGB[(solid_top_r >> 2)][(solid_top_g >> 2)][(solid_top_b >> 2)]; + uint32_t solid_bottom_fill = RGB256k.RGB[(solid_bottom_r >> 2)][(solid_bottom_g >> 2)][(solid_bottom_b >> 2)]; +#endif solid_top_fill = (solid_top_fill << 24) | (solid_top_fill << 16) | (solid_top_fill << 8) | solid_top_fill; solid_bottom_fill = (solid_bottom_fill << 24) | (solid_bottom_fill << 16) | (solid_bottom_fill << 8) | solid_bottom_fill; @@ -1026,7 +1107,11 @@ namespace swrenderer c_red = (c_red * alpha_top + solid_top_r * inv_alpha_top) >> 8; c_green = (c_green * alpha_top + solid_top_g * inv_alpha_top) >> 8; c_blue = (c_blue * alpha_top + solid_top_b * inv_alpha_top) >> 8; +#ifdef NO_RGB666 output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; +#else + output[col] = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; +#endif frac[col] += fracstep[col]; } @@ -1080,7 +1165,11 @@ namespace swrenderer c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; +#ifdef NO_RGB666 output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; +#else + output[col] = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; +#endif frac[col] += fracstep[col]; } diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index d24cd92d1..e13944173 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -536,7 +536,12 @@ void FPNGTexture::MakeTexture () { if (!HaveTrans) { +#ifdef NO_RGB666 *out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; +#else + *out++ = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; +#endif + } else { @@ -548,7 +553,11 @@ void FPNGTexture::MakeTexture () } else { +#ifdef NO_RGB666 *out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; +#else + *out++ = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; +#endif } } in += pitch; @@ -593,7 +602,11 @@ void FPNGTexture::MakeTexture () { for (y = Height; y > 0; --y) { +#ifdef NO_RGB666 *out++ = in[3] < 128 ? 0 : RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; +#else + *out++ = in[3] < 128 ? 0 : RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; +#endif in += pitch; } in -= backstep; diff --git a/src/textures/tgatexture.cpp b/src/textures/tgatexture.cpp index b208a51a3..e24b926ca 100644 --- a/src/textures/tgatexture.cpp +++ b/src/textures/tgatexture.cpp @@ -405,7 +405,11 @@ void FTGATexture::MakeTexture () BYTE * p = ptr + y * Pitch; for(int x=0;x>3][p[1]>>3][p[0]>>3]; +#else + Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2]; +#endif p+=step_x; } } @@ -419,7 +423,11 @@ void FTGATexture::MakeTexture () BYTE * p = ptr + y * Pitch; for(int x=0;x>3][p[1]>>3][p[0]>>3]; +#else + Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2]; +#endif p+=step_x; } } @@ -431,7 +439,11 @@ void FTGATexture::MakeTexture () BYTE * p = ptr + y * Pitch; for(int x=0;x= 128? RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3] : 0; +#else + Pixels[x*Height+y] = p[3] >= 128? RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2] : 0; +#endif p+=step_x; } } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 1524c7ba4..bf7ccaab4 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -1031,7 +1031,7 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) DWORD *fg2rgb = Col2RGB8[63-level]; DWORD fg = fg2rgb[basecolor]; DWORD bg = bg2rgb[*spot]; - bg = (fg+bg) | 0x1f07c1f; + bg = (fg+bg) | 0x01f07c1f; *spot = RGB32k.All[bg&(bg>>15)]; } diff --git a/src/v_video.cpp b/src/v_video.cpp index efe93aa04..92992220b 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -144,8 +144,12 @@ DWORD Col2RGB8[65][256]; DWORD *Col2RGB8_LessPrecision[65]; DWORD Col2RGB8_Inverse[65][256]; ColorTable32k RGB32k; +#ifndef NO_RGB666 +ColorTable256k RGB256k; +#endif } + static DWORD Col2RGB8_2[63][256]; // [RH] The framebuffer is no longer a mere byte array. @@ -669,6 +673,13 @@ static void BuildTransTable (const PalEntry *palette) for (g = 0; g < 32; g++) for (b = 0; b < 32; b++) RGB32k.RGB[r][g][b] = ColorMatcher.Pick ((r<<3)|(r>>2), (g<<3)|(g>>2), (b<<3)|(b>>2)); +#ifndef NO_RGB666 + // create the RGB666 lookup table + for (r = 0; r < 64; r++) + for (g = 0; g < 64; g++) + for (b = 0; b < 64; b++) + RGB256k.RGB[r][g][b] = ColorMatcher.Pick ((r<<2)|(r>>4), (g<<2)|(g>>4), (b<<2)|(b>>4)); +#endif int x, y; diff --git a/src/v_video.h b/src/v_video.h index b72f67094..2079ff64b 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -462,6 +462,16 @@ union ColorTable32k }; extern "C" ColorTable32k RGB32k; +// [SP] RGB666 support +#ifndef NO_RGB666 +union ColorTable256k +{ + BYTE RGB[64][64][64]; + BYTE All[64 *64 *64]; +}; +extern "C" ColorTable256k RGB256k; +#endif + // Col2RGB8 is a pre-multiplied palette for color lookup. It is stored in a // special R10B10G10 format for efficient blending computation. // --RRRRRrrr--BBBBBbbb--GGGGGggg-- at level 64 From 179c7dba8315723495b1f08f3dff056f3c1ef446 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 17 Dec 2016 10:25:35 -0500 Subject: [PATCH 1425/1509] - Yeah, it's time to take a break. Have fun with this! :D --- src/r_draw_pal.cpp | 99 ++++++++++------------------------------------ src/r_things.cpp | 39 ++++-------------- src/v_draw.cpp | 33 +++------------- src/v_video.cpp | 30 ++++++-------- 4 files changed, 47 insertions(+), 154 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 439321e53..5a6c94327 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -320,9 +320,9 @@ namespace swrenderer fg = (fg + bg) | 0x1f07c1f; *dest = RGB32k.All[fg & (fg >> 15)]; #else - uint32_t r = clamp(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 0, 255); - uint32_t g = clamp(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 0, 255); - uint32_t b = clamp(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 0, 255); + uint32_t r = MIN(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 255); + uint32_t g = MIN(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 255); + uint32_t b = MIN(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 255); *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; #endif } @@ -370,9 +370,9 @@ namespace swrenderer fg = (fg + bg) | 0x1f07c1f; dest[i] = RGB32k.All[fg & (fg >> 15)]; #else - uint32_t r = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].r + GPalette.BaseColors[dest[i]].r, 0, 255); - uint32_t g = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].g + GPalette.BaseColors[dest[i]].g, 0, 255); - uint32_t b = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].b + GPalette.BaseColors[dest[i]].b, 0, 255); + uint32_t r = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].r + GPalette.BaseColors[dest[i]].r, 255); + uint32_t g = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].g + GPalette.BaseColors[dest[i]].g, 255); + uint32_t b = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].b + GPalette.BaseColors[dest[i]].b, 255); dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; #endif } @@ -410,22 +410,10 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { -#ifdef NO_RGB666 - uint32_t a = fg2rgb[colormap[pix]] + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[a & (a >> 15)]; -#else - uint32_t r = clamp(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 0, 255); - uint32_t g = clamp(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 0, 255); - uint32_t b = clamp(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 0, 255); + uint32_t r = MIN(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 255); + uint32_t g = MIN(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 255); + uint32_t b = MIN(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 255); *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; -#endif } frac += fracstep; dest += pitch; @@ -465,22 +453,10 @@ namespace swrenderer uint8_t pix = _bufplce[i][vplce[i] >> bits]; if (pix != 0) { -#ifdef NO_RGB666 - uint32_t a = fg2rgb[_palookupoffse[i][pix]] + bg2rgb[dest[i]]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[i] = RGB32k.All[a & (a >> 15)]; -#else - uint32_t r = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].r + GPalette.BaseColors[dest[i]].r, 0, 255); - uint32_t g = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].g + GPalette.BaseColors[dest[i]].g, 0, 255); - uint32_t b = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].b + GPalette.BaseColors[dest[i]].b, 0, 255); + uint32_t r = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].r + GPalette.BaseColors[dest[i]].r, 255); + uint32_t g = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].g + GPalette.BaseColors[dest[i]].g, 255); + uint32_t b = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].b + GPalette.BaseColors[dest[i]].b, 255); dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; -#endif } vplce[i] += vince[i]; } @@ -516,21 +492,10 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { -#ifdef NO_RGB666 - uint32_t a = (fg2rgb[colormap[pix]] | 0x40100400) - bg2rgb[*dest]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a >> 15)]; -#else - uint32_t r = clamp(-GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 0, 255); - uint32_t g = clamp(-GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 0, 255); - uint32_t b = clamp(-GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 0, 255); + int r = clamp(-GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 0, 255); + int g = clamp(-GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 0, 255); + int b = clamp(-GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 0, 255); *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; -#endif } frac += fracstep; dest += pitch; @@ -570,21 +535,10 @@ namespace swrenderer uint8_t pix = _bufplce[i][vplce[i] >> bits]; if (pix != 0) { -#ifdef NO_RGB666 - uint32_t a = (fg2rgb[_palookupoffse[i][pix]] | 0x40100400) - bg2rgb[dest[i]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[i] = RGB32k.All[a & (a >> 15)]; -#else - uint32_t r = clamp(-GPalette.BaseColors[_palookupoffse[i][pix]].r + GPalette.BaseColors[dest[i]].r, 0, 255); - uint32_t g = clamp(-GPalette.BaseColors[_palookupoffse[i][pix]].g + GPalette.BaseColors[dest[i]].g, 0, 255); - uint32_t b = clamp(-GPalette.BaseColors[_palookupoffse[i][pix]].b + GPalette.BaseColors[dest[i]].b, 0, 255); + int r = clamp(-GPalette.BaseColors[_palookupoffse[i][pix]].r + GPalette.BaseColors[dest[i]].r, 0, 255); + int g = clamp(-GPalette.BaseColors[_palookupoffse[i][pix]].g + GPalette.BaseColors[dest[i]].g, 0, 255); + int b = clamp(-GPalette.BaseColors[_palookupoffse[i][pix]].b + GPalette.BaseColors[dest[i]].b, 0, 255); dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; -#endif } vplce[i] += vince[i]; } @@ -620,21 +574,10 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { -#ifdef NO_RGB666 - uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[pix]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a >> 15)]; -#else - uint32_t r = clamp(GPalette.BaseColors[colormap[pix]].r - GPalette.BaseColors[*dest].r, 0, 255); - uint32_t g = clamp(GPalette.BaseColors[colormap[pix]].g - GPalette.BaseColors[*dest].g, 0, 255); - uint32_t b = clamp(GPalette.BaseColors[colormap[pix]].b - GPalette.BaseColors[*dest].b, 0, 255); + int r = clamp(GPalette.BaseColors[colormap[pix]].r - GPalette.BaseColors[*dest].r, 0, 255); + int g = clamp(GPalette.BaseColors[colormap[pix]].g - GPalette.BaseColors[*dest].g, 0, 255); + int b = clamp(GPalette.BaseColors[colormap[pix]].b - GPalette.BaseColors[*dest].b, 0, 255); *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; -#endif } frac += fracstep; dest += pitch; diff --git a/src/r_things.cpp b/src/r_things.cpp index 9e9b161cd..7c178ce8b 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2634,10 +2634,8 @@ static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) void R_DrawParticle_C (vissprite_t *vis) { - DWORD *bg2rgb; int spacing; BYTE *dest; - DWORD fg; BYTE color = vis->Style.colormap[vis->startfrac]; int yl = vis->y1; int ycount = vis->y2 - yl + 1; @@ -2649,33 +2647,10 @@ void R_DrawParticle_C (vissprite_t *vis) DrawerCommandQueue::WaitForWorkers(); // vis->renderflags holds translucency level (0-255) - { - fixed_t fglevel, bglevel; - DWORD *fg2rgb; + fixed_t fglevel, bglevel; - fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff; - bglevel = FRACUNIT-fglevel; - fg2rgb = Col2RGB8[fglevel>>10]; - bg2rgb = Col2RGB8[bglevel>>10]; - fg = fg2rgb[color]; - } - - /* - - spacing = RenderTarget->GetPitch() - countbase; - dest = ylookup[yl] + x1 + dc_destorg; - - do - { - int count = countbase; - do - { - DWORD bg = bg2rgb[*dest]; - bg = (fg+bg) | 0x1f07c1f; - *dest++ = RGB32k.All[bg & (bg>>15)]; - } while (--count); - dest += spacing; - } while (--ycount);*/ + fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff; + bglevel = FRACUNIT-fglevel; // original was row-wise // width = countbase @@ -2691,9 +2666,11 @@ void R_DrawParticle_C (vissprite_t *vis) dest = ylookup[yl] + x + dc_destorg; for (int y = 0; y < ycount; y++) { - DWORD bg = bg2rgb[*dest]; - bg = (fg+bg) | 0x1f07c1f; - *dest = RGB32k.All[bg & (bg>>15)]; + int dest_r = (GPalette.BaseColors[*dest].r * bglevel + GPalette.BaseColors[color].r * fglevel) >> 10; + int dest_g = (GPalette.BaseColors[*dest].g * bglevel + GPalette.BaseColors[color].g * fglevel) >> 10; + int dest_b = (GPalette.BaseColors[*dest].b * bglevel + GPalette.BaseColors[color].b * fglevel) >> 10; + + *dest = RGB256k.RGB[dest_r][dest_g][dest_b]; dest += spacing; } } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index bf7ccaab4..34db09356 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -989,27 +989,6 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) static int oldyy; static int oldyyshifted; -#if 0 - if(xx < 32) - cc += 7-(xx>>2); - else if(xx > (finit_width - 32)) - cc += 7-((finit_width-xx) >> 2); -// if(cc==oldcc) //make sure that we don't double fade the corners. -// { - if(yy < 32) - cc += 7-(yy>>2); - else if(yy > (finit_height - 32)) - cc += 7-((finit_height-yy) >> 2); -// } - if(cc > cm && cm != NULL) - { - cc = cm; - } - else if(cc > oldcc+6) // don't let the color escape from the fade table... - { - cc=oldcc+6; - } -#endif if (yy == oldyy+1) { oldyy++; @@ -1027,12 +1006,12 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) } BYTE *spot = GetBuffer() + oldyyshifted + xx; - DWORD *bg2rgb = Col2RGB8[1+level]; - DWORD *fg2rgb = Col2RGB8[63-level]; - DWORD fg = fg2rgb[basecolor]; - DWORD bg = bg2rgb[*spot]; - bg = (fg+bg) | 0x01f07c1f; - *spot = RGB32k.All[bg&(bg>>15)]; + + uint32_t r = (GPalette.BaseColors[*spot].r * (64 - level) + GPalette.BaseColors[basecolor].r * level) / 64; + uint32_t g = (GPalette.BaseColors[*spot].g * (64 - level) + GPalette.BaseColors[basecolor].g * level) / 64; + uint32_t b = (GPalette.BaseColors[*spot].b * (64 - level) + GPalette.BaseColors[basecolor].b * level) / 64; + + *spot = (BYTE)RGB256k.RGB[r][g][b]; } void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 realcolor) diff --git a/src/v_video.cpp b/src/v_video.cpp index 92992220b..6e333f840 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -349,8 +349,6 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) if (damount == 0.f) return; - DWORD *bg2rgb; - DWORD fg; int gap; BYTE *spot; int x, y; @@ -372,28 +370,23 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) return; } - { - int amount; - - amount = (int)(damount * 64); - bg2rgb = Col2RGB8[64-amount]; - - fg = (((color.r * amount) >> 4) << 20) | - ((color.g * amount) >> 4) | - (((color.b * amount) >> 4) << 10); - } spot = Buffer + x1 + y1*Pitch; gap = Pitch - w; + + int alpha = (int)((float)64 * damount); + int ialpha = 64 - alpha; + int dimmedcolor_r = color.r * alpha; + int dimmedcolor_g = color.g * alpha; + int dimmedcolor_b = color.b * alpha; for (y = h; y != 0; y--) { for (x = w; x != 0; x--) { - DWORD bg; - - bg = bg2rgb[(*spot)&0xff]; - bg = (fg+bg) | 0x1f07c1f; - *spot = RGB32k.All[bg&(bg>>15)]; + uint32_t r = (dimmedcolor_r + GPalette.BaseColors[*spot].r * ialpha) >> 8; + uint32_t g = (dimmedcolor_g + GPalette.BaseColors[*spot].g * ialpha) >> 8; + uint32_t b = (dimmedcolor_b + GPalette.BaseColors[*spot].b * ialpha) >> 8; + *spot = (BYTE)RGB256k.RGB[r][g][b]; spot++; } spot += gap; @@ -672,7 +665,8 @@ static void BuildTransTable (const PalEntry *palette) for (r = 0; r < 32; r++) for (g = 0; g < 32; g++) for (b = 0; b < 32; b++) - RGB32k.RGB[r][g][b] = ColorMatcher.Pick ((r<<3)|(r>>2), (g<<3)|(g>>2), (b<<3)|(b>>2)); + //RGB32k.RGB[r][g][b] = ColorMatcher.Pick ((r<<3)|(r>>2), (g<<3)|(g>>2), (b<<3)|(b>>2)); + RGB32k.RGB[r][g][b] = 2; #ifndef NO_RGB666 // create the RGB666 lookup table for (r = 0; r < 64; r++) From 1ec06463d982b22ca3e5617c9fba74fe6e0ef054 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 17 Dec 2016 22:34:36 +0100 Subject: [PATCH 1426/1509] - Set colormap light info using R_SetColorMapLight and R_SetDSColorMapLight rather than manually calculating it - Move texture and span management into R_DrawMaskedColumn --- src/r_draw.cpp | 10 +++++++ src/r_draw.h | 2 ++ src/r_main.h | 3 +++ src/r_plane.cpp | 40 ++++++++++++++++++++-------- src/r_segs.cpp | 40 ++++++++++++++-------------- src/r_things.cpp | 68 +++++++++++++++++++++++++----------------------- src/r_things.h | 2 +- src/v_draw.cpp | 30 +++------------------ 8 files changed, 104 insertions(+), 91 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index a461e1877..25297f6c8 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -548,6 +548,11 @@ namespace swrenderer dc_colormap = base_colormap + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); } + void R_SetColorMapLight(FDynamicColormap *base_colormap, float light, int shade) + { + R_SetColorMapLight(base_colormap->Maps, light, shade); + } + void R_SetDSColorMapLight(lighttable_t *base_colormap, float light, int shade) { using namespace drawerargs; @@ -555,6 +560,11 @@ namespace swrenderer ds_colormap = base_colormap + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); } + void R_SetDSColorMapLight(FDynamicColormap *base_colormap, float light, int shade) + { + R_SetDSColorMapLight(base_colormap->Maps, light, shade); + } + void R_SetTranslationMap(lighttable_t *translation) { using namespace drawerargs; diff --git a/src/r_draw.h b/src/r_draw.h index 58934981b..ab430d2af 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -192,7 +192,9 @@ namespace swrenderer void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); void R_SetColorMapLight(lighttable_t *base_colormap, float light, int shade); + void R_SetColorMapLight(FDynamicColormap *base_colormap, float light, int shade); void R_SetDSColorMapLight(lighttable_t *base_colormap, float light, int shade); + void R_SetDSColorMapLight(FDynamicColormap *base_colormap, float light, int shade); void R_SetTranslationMap(lighttable_t *translation); void R_SetupSpanBits(FTexture *tex); diff --git a/src/r_main.h b/src/r_main.h index 87b56163b..be1c36306 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -85,6 +85,9 @@ extern bool r_dontmaplines; // Change R_CalcTiltedLighting() when this changes. #define GETPALOOKUP(vis,shade) (clamp (((shade)-FLOAT2FIXED(MIN(MAXLIGHTVIS,double(vis))))>>FRACBITS, 0, NUMCOLORMAPS-1)) +// Converts fixedlightlev into a shade value +#define FIXEDLIGHT2SHADE(lightlev) (((lightlev) >> COLORMAPSHIFT) << FRACBITS) + extern double GlobVis; void R_SetVisibility(double visibility); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index eafc9fa26..cd378aec1 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -240,8 +240,7 @@ void R_MapPlane (int y, int x1) if (plane_shade) { // Determine lighting based on the span's distance from the viewer. - ds_colormap = basecolormap->Maps + (GETPALOOKUP ( - GlobVis * fabs(CenterY - y), planeshade) << COLORMAPSHIFT); + R_SetDSColorMapLight(basecolormap, GlobVis * fabs(CenterY - y), planeshade); } ds_y = y; @@ -1043,7 +1042,7 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske R_SetupSpanBits(tex); double xscale = pl->xform.xScale * tex->Scale.X; double yscale = pl->xform.yScale * tex->Scale.Y; - ds_source = tex->GetPixels (); + R_SetSpanSource(tex); basecolormap = pl->colormap; planeshade = LIGHT2SHADE(pl->lightlevel); @@ -1405,12 +1404,13 @@ void R_DrawSkyPlane (visplane_t *pl) bool fakefixed = false; if (fixedcolormap) { - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); } else { fakefixed = true; - fixedcolormap = dc_colormap = NormalLight.Maps; + fixedcolormap = NormalLight.Maps; + R_SetColorMapLight(fixedcolormap, 0, 0); } R_DrawSky (pl); @@ -1484,12 +1484,21 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t planeheight = fabs(pl->height.Zat0() - ViewPos.Z); GlobVis = r_FloorVisibility / planeheight; + ds_light = 0; if (fixedlightlev >= 0) - ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false; + { + R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + plane_shade = false; + } else if (fixedcolormap) - ds_colormap = fixedcolormap, plane_shade = false; + { + R_SetDSColorMapLight(fixedcolormap, 0, 0); + plane_shade = false; + } else + { plane_shade = true; + } if (spanfunc != R_FillSpan) { @@ -1645,11 +1654,20 @@ void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t planelightfloat = -planelightfloat; if (fixedlightlev >= 0) - ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false; + { + R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + plane_shade = false; + } else if (fixedcolormap) - ds_colormap = fixedcolormap, plane_shade = false; + { + R_SetDSColorMapLight(fixedcolormap, 0, 0); + plane_shade = false; + } else - ds_colormap = basecolormap->Maps, plane_shade = true; + { + R_SetDSColorMapLight(basecolormap, 0, 0); + plane_shade = true; + } // Hack in support for 1 x Z and Z x 1 texture sizes if (ds_ybits == 0) @@ -1766,4 +1784,4 @@ bool R_PlaneInitData () return true; } -} \ No newline at end of file +} diff --git a/src/r_segs.cpp b/src/r_segs.cpp index d6ab86aa0..38db1a6b2 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -44,6 +44,7 @@ #include "r_plane.h" #include "r_segs.h" #include "r_3dfloors.h" +#include "r_draw.h" #include "v_palette.h" #include "r_data/colormaps.h" @@ -53,8 +54,9 @@ CVAR(Bool, r_fogboundary, true, 0) CVAR(Bool, r_drawmirrors, true, 0) EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); +EXTERN_CVAR(Bool, r_mipmap) -namespace swrenderer +namespace swrenderer { using namespace drawerargs; @@ -156,7 +158,7 @@ static void BlastMaskedColumn (FTexture *tex, bool useRt) // calculate lighting if (fixedcolormap == NULL && fixedlightlev < 0) { - dc_colormap = basecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(basecolormap, rw_light, wallshade); } dc_iscale = xs_Fix<16>::ToFix(MaskedSWall[dc_x] * MaskedScaleY); @@ -174,9 +176,7 @@ static void BlastMaskedColumn (FTexture *tex, bool useRt) // when forming multipatched textures (see r_data.c). // draw the texture - const FTexture::Span *spans; - const BYTE *pixels = tex->GetColumn (maskedtexturecol[dc_x] >> FRACBITS, &spans); - R_DrawMaskedColumn(pixels, spans, useRt); + R_DrawMaskedColumn(tex, maskedtexturecol[dc_x], useRt); rw_light += rw_lightstep; spryscale += rw_scalestep; } @@ -292,9 +292,9 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) rw_scalestep = ds->iscalestep; if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); // find positioning texheight = tex->GetScaledHeightDouble(); @@ -440,7 +440,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) while (dc_x < stop) { - rt_initcols(); + rt_initcols(nullptr); BlastMaskedColumn (tex, true); dc_x++; BlastMaskedColumn (tex, true); dc_x++; BlastMaskedColumn (tex, true); dc_x++; @@ -609,9 +609,9 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) } if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); WallC.sz1 = ds->sz1; WallC.sz2 = ds->sz2; @@ -1061,9 +1061,9 @@ void R_RenderSegLoop () fixed_t xoffset = rw_offset; if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); // clip wall to the floor and ceiling for (x = x1; x < x2; ++x) @@ -2304,11 +2304,11 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rw_light = rw_lightleft + (x1 - savecoord.sx1) * rw_lightstep; if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (usecolormap->Maps + fixedlightlev); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT)) - dc_colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : usecolormap->Maps; + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0); else calclighting = true; @@ -2359,7 +2359,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, wallshade); } R_WallSpriteColumn (false); dc_x++; @@ -2369,9 +2369,9 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, wallshade); } - rt_initcols(); + rt_initcols(nullptr); for (int zz = 4; zz; --zz) { R_WallSpriteColumn (true); @@ -2384,7 +2384,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, wallshade); } R_WallSpriteColumn (false); dc_x++; @@ -2408,4 +2408,4 @@ done: WallC = savecoord; } -} \ No newline at end of file +} diff --git a/src/r_things.cpp b/src/r_things.cpp index 9e9b161cd..f03bfbae0 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -256,8 +256,23 @@ double sprtopscreen; bool sprflipvert; -void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span, bool useRt) +void R_DrawMaskedColumn (FTexture *tex, fixed_t col, bool useRt, bool unmasked) { + const FTexture::Span *span; + const BYTE *column; + + column = tex->GetColumn(col >> FRACBITS, &span); + + FTexture::Span unmaskedSpan[2]; + if (unmasked) + { + span = unmaskedSpan; + unmaskedSpan[0].TopOffset = 0; + unmaskedSpan[0].Length = tex->GetHeight(); + unmaskedSpan[1].TopOffset = 0; + unmaskedSpan[1].Length = 0; + } + while (span->Length != 0) { const int length = span->Length; @@ -377,8 +392,6 @@ static inline bool R_ClipSpriteColumnWithPortals(vissprite_t* spr) // void R_DrawVisSprite (vissprite_t *vis) { - const BYTE *pixels; - const FTexture::Span *spans; fixed_t frac; FTexture *tex; int x2, stop4; @@ -392,7 +405,7 @@ void R_DrawVisSprite (vissprite_t *vis) } fixed_t centeryfrac = FLOAT2FIXED(CenterY); - dc_colormap = vis->Style.colormap; + R_SetColorMapLight(vis->Style.colormap, 0.0f, 0); mode = R_SetPatchStyle (vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor); @@ -400,7 +413,7 @@ void R_DrawVisSprite (vissprite_t *vis) { // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but // it is the brightest one. We need to get back to the proper light level for // this sprite. - dc_colormap += vis->ColormapNum << COLORMAPSHIFT; + R_SetColorMapLight(dc_colormap, 0, vis->ColormapNum << FRACBITS); } if (mode != DontDraw) @@ -445,21 +458,19 @@ void R_DrawVisSprite (vissprite_t *vis) { while ((dc_x < stop4) && (dc_x & 3)) { - pixels = tex->GetColumn (frac >> FRACBITS, &spans); if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (pixels, spans, false); + R_DrawMaskedColumn (tex, frac, false); dc_x++; frac += xiscale; } while (dc_x < stop4) { - rt_initcols(); + rt_initcols(nullptr); for (int zz = 4; zz; --zz) { - pixels = tex->GetColumn (frac >> FRACBITS, &spans); if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (pixels, spans, true); + R_DrawMaskedColumn (tex, frac, true); dc_x++; frac += xiscale; } @@ -468,9 +479,8 @@ void R_DrawVisSprite (vissprite_t *vis) while (dc_x < x2) { - pixels = tex->GetColumn (frac >> FRACBITS, &spans); if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (pixels, spans, false); + R_DrawMaskedColumn (tex, frac, false); dc_x++; frac += xiscale; } @@ -522,11 +532,11 @@ void R_DrawWallSprite(vissprite_t *spr) rw_lightstep = float((GlobVis / spr->wallc.sz2 - rw_lightleft) / (spr->wallc.sx2 - spr->wallc.sx1)); rw_light = rw_lightleft + (x1 - spr->wallc.sx1) * rw_lightstep; if (fixedlightlev >= 0) - dc_colormap = usecolormap->Maps + fixedlightlev; + R_SetColorMapLight(usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) - dc_colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : usecolormap->Maps; + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0); else calclighting = true; @@ -577,7 +587,7 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, shade); } if (!R_ClipSpriteColumnWithPortals(spr)) R_WallSpriteColumn(false); @@ -588,9 +598,9 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, shade); } - rt_initcols(); + rt_initcols(nullptr); for (int zz = 4; zz; --zz) { if (!R_ClipSpriteColumnWithPortals(spr)) @@ -604,7 +614,7 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, shade); } if (!R_ClipSpriteColumnWithPortals(spr)) R_WallSpriteColumn(false); @@ -624,11 +634,8 @@ void R_WallSpriteColumn (bool useRt) else sprtopscreen = CenterY - dc_texturemid * spryscale; - const BYTE *column; - const FTexture::Span *spans; - column = WallSpriteTile->GetColumn (lwall[dc_x] >> FRACBITS, &spans); dc_texturefrac = 0; - R_DrawMaskedColumn(column, spans, useRt); + R_DrawMaskedColumn(WallSpriteTile, lwall[dc_x], useRt); rw_light += rw_lightstep; } @@ -638,7 +645,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop int flags = 0; // Do setup for blending. - dc_colormap = spr->Style.colormap; + R_SetColorMapLight(spr->Style.colormap, 0.0f, 0); mode = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); if (mode == DontDraw) @@ -689,10 +696,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop } else { - unsigned int **tspan = &dc_ctspan[x & 3]; - (*tspan)[0] = span->Start; - (*tspan)[1] = span->Stop - 1; - *tspan += 2; + rt_span_coverage(x, span->Start, span->Stop - 1); } } if (!(flags & DVF_SPANSONLY) && (x & 3) == 3) @@ -2044,7 +2048,7 @@ void R_DrawSprite (vissprite_t *spr) else { // diminished light spriteshade = LIGHT2SHADE(sec->lightlevel + r_actualextralight); - spr->Style.colormap = mybasecolormap->Maps + (GETPALOOKUP ( + spr->Style.colormap = mybasecolormap->Maps + (GETPALOOKUP( r_SpriteVisibility / MAX(MINZ, (double)spr->depth), spriteshade) << COLORMAPSHIFT); } } @@ -3237,16 +3241,16 @@ void R_CheckOffscreenBuffer(int width, int height, bool spansonly) { if (OffscreenColorBuffer == NULL) { - OffscreenColorBuffer = new BYTE[width * height]; + OffscreenColorBuffer = new BYTE[width * height * 4]; } else if (OffscreenBufferWidth != width || OffscreenBufferHeight != height) { delete[] OffscreenColorBuffer; - OffscreenColorBuffer = new BYTE[width * height]; + OffscreenColorBuffer = new BYTE[width * height * 4]; } } OffscreenBufferWidth = width; OffscreenBufferHeight = height; } -} \ No newline at end of file +} diff --git a/src/r_things.h b/src/r_things.h index bf32b655f..6d694b8fd 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -128,7 +128,7 @@ extern double pspriteyscale; extern FTexture *WallSpriteTile; -void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *spans, bool useRt); +void R_DrawMaskedColumn (FTexture *texture, fixed_t column, bool useRt, bool unmasked = false); void R_WallSpriteColumn (bool useRt); void R_CacheSprite (spritedef_t *sprite); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 1524c7ba4..6f8bc5198 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -135,20 +135,9 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) using namespace swrenderer; using namespace drawerargs; - FTexture::Span unmaskedSpan[2]; - const FTexture::Span **spanptr, *spans; static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH]; const BYTE *translation = NULL; - if (parms.masked) - { - spanptr = &spans; - } - else - { - spanptr = NULL; - } - if (APART(parms.colorOverlay) != 0) { // The software renderer cannot invert the source without inverting the overlay @@ -198,18 +187,8 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) if (mode != DontDraw) { - const BYTE *pixels; int stop4; - if (spanptr == NULL) - { // Create a single span for forced unmasked images - spans = unmaskedSpan; - unmaskedSpan[0].TopOffset = 0; - unmaskedSpan[0].Length = img->GetHeight(); - unmaskedSpan[1].TopOffset = 0; - unmaskedSpan[1].Length = 0; - } - double centeryback = CenterY; CenterY = 0; @@ -301,8 +280,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) { while ((dc_x < stop4) && (dc_x & 3)) { - pixels = img->GetColumn(frac >> FRACBITS, spanptr); - R_DrawMaskedColumn(pixels, spans, false); + R_DrawMaskedColumn(img, frac, false, !parms.masked); dc_x++; frac += xiscale_i; } @@ -312,8 +290,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) rt_initcols(); for (int zz = 4; zz; --zz) { - pixels = img->GetColumn(frac >> FRACBITS, spanptr); - R_DrawMaskedColumn(pixels, spans, true); + R_DrawMaskedColumn(img, frac, true, !parms.masked); dc_x++; frac += xiscale_i; } @@ -322,8 +299,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) while (dc_x < x2_i) { - pixels = img->GetColumn(frac >> FRACBITS, spanptr); - R_DrawMaskedColumn(pixels, spans, false); + R_DrawMaskedColumn(img, frac, false, !parms.masked); dc_x++; frac += xiscale_i; } From bb3fa15bed3f4cf5926b1f1e087a4f2ee21596f6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 17 Dec 2016 22:57:57 +0100 Subject: [PATCH 1427/1509] Removed leftovers from QZDoom --- src/r_segs.cpp | 3 +-- src/r_things.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 38db1a6b2..ccf6ccf20 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -54,9 +54,8 @@ CVAR(Bool, r_fogboundary, true, 0) CVAR(Bool, r_drawmirrors, true, 0) EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); -EXTERN_CVAR(Bool, r_mipmap) -namespace swrenderer +namespace swrenderer { using namespace drawerargs; diff --git a/src/r_things.cpp b/src/r_things.cpp index f03bfbae0..a1ace0d49 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -3241,12 +3241,12 @@ void R_CheckOffscreenBuffer(int width, int height, bool spansonly) { if (OffscreenColorBuffer == NULL) { - OffscreenColorBuffer = new BYTE[width * height * 4]; + OffscreenColorBuffer = new BYTE[width * height]; } else if (OffscreenBufferWidth != width || OffscreenBufferHeight != height) { delete[] OffscreenColorBuffer; - OffscreenColorBuffer = new BYTE[width * height * 4]; + OffscreenColorBuffer = new BYTE[width * height]; } } OffscreenBufferWidth = width; From 6235b12cfcd28e699285af405ca25b1443d4cbd5 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 17 Dec 2016 21:26:08 -0500 Subject: [PATCH 1428/1509] - No matter how many drawers you have, you have more drawers to do. --- src/r_draw_pal.h | 2 + src/r_drawt_pal.cpp | 148 +++++++++-------------------- src/textures/ddstexture.cpp | 8 +- src/textures/jpegtexture.cpp | 4 +- src/textures/multipatchtexture.cpp | 2 +- src/textures/pngtexture.cpp | 13 --- src/textures/tgatexture.cpp | 14 +-- 7 files changed, 53 insertions(+), 138 deletions(-) diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index f2b1f0571..262b70387 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -303,6 +303,8 @@ namespace swrenderer const uint32_t *_srcblend; const uint32_t *_destblend; const uint8_t *_translation; + fixed_t _srcalpha; + fixed_t _destalpha; int _color; }; diff --git a/src/r_drawt_pal.cpp b/src/r_drawt_pal.cpp index 3356592d2..16d24ecaf 100644 --- a/src/r_drawt_pal.cpp +++ b/src/r_drawt_pal.cpp @@ -173,6 +173,8 @@ namespace swrenderer _colormap = dc_colormap; _srcblend = dc_srcblend; _destblend = dc_destblend; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; _translation = dc_translation; _color = dc_color; } @@ -440,8 +442,6 @@ namespace swrenderer if (count <= 0) return; - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; @@ -451,10 +451,10 @@ namespace swrenderer uint32_t fg = colormap[*source]; uint32_t bg = *dest; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg>>15)]; + int r = MIN((GPalette.BaseColors[fg].r * _srcalpha + GPalette.BaseColors[bg].r * _destalpha)>>18, 63); + int g = MIN((GPalette.BaseColors[fg].g * _srcalpha + GPalette.BaseColors[bg].g * _destalpha)>>18, 63); + int b = MIN((GPalette.BaseColors[fg].b * _srcalpha + GPalette.BaseColors[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; source += 4; dest += pitch; } while (--count); @@ -472,42 +472,21 @@ namespace swrenderer if (count <= 0) return; - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; pitch = _pitch * thread->num_cores; colormap = _colormap; do { - uint32_t fg = colormap[source[0]]; - uint32_t bg = dest[0]; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - dest[0] = RGB32k.All[fg & (fg>>15)]; - - fg = colormap[source[1]]; - bg = dest[1]; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - dest[1] = RGB32k.All[fg & (fg>>15)]; - - - fg = colormap[source[2]]; - bg = dest[2]; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - dest[2] = RGB32k.All[fg & (fg>>15)]; - - fg = colormap[source[3]]; - bg = dest[3]; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - dest[3] = RGB32k.All[fg & (fg>>15)]; + for (int ks = 0; ks < 4; ks++) + { // [SP] this 4col function was a block of copy-pasted code. 4 times. I regret nothing. + uint32_t fg = colormap[source[ks]]; + uint32_t bg = dest[ks]; + int r = MIN((GPalette.BaseColors[fg].r * _srcalpha + GPalette.BaseColors[bg].r * _destalpha)>>18, 63); + int g = MIN((GPalette.BaseColors[fg].g * _srcalpha + GPalette.BaseColors[bg].g * _destalpha)>>18, 63); + int b = MIN((GPalette.BaseColors[fg].b * _srcalpha + GPalette.BaseColors[bg].b * _destalpha)>>18, 63); + dest[ks] = RGB256k.RGB[r][g][b]; + } source += 4; dest += pitch; @@ -534,10 +513,11 @@ namespace swrenderer pitch = _pitch * thread->num_cores; do { - uint32_t val = colormap[*source]; - uint32_t fg = fgstart[val<<8]; - val = (Col2RGB8[64-val][*dest] + fg) | 0x1f07c1f; - *dest = RGB32k.All[val & (val>>15)]; + uint32_t val = *source; + int r = (GPalette.BaseColors[*dest].r * (63-val) + GPalette.BaseColors[_color].r * val) >> 8; + int g = (GPalette.BaseColors[*dest].g * (63-val) + GPalette.BaseColors[_color].g * val) >> 8; + int b = (GPalette.BaseColors[*dest].b * (63-val) + GPalette.BaseColors[_color].b * val) >> 8; + *dest = RGB256k.RGB[MIN(r,63)][MIN(g,63)][MIN(b,63)]; source += 4; dest += pitch; } while (--count); @@ -564,22 +544,15 @@ namespace swrenderer do { uint32_t val; - - val = colormap[source[0]]; - val = (Col2RGB8[64-val][dest[0]] + fgstart[val<<8]) | 0x1f07c1f; - dest[0] = RGB32k.All[val & (val>>15)]; - val = colormap[source[1]]; - val = (Col2RGB8[64-val][dest[1]] + fgstart[val<<8]) | 0x1f07c1f; - dest[1] = RGB32k.All[val & (val>>15)]; - - val = colormap[source[2]]; - val = (Col2RGB8[64-val][dest[2]] + fgstart[val<<8]) | 0x1f07c1f; - dest[2] = RGB32k.All[val & (val>>15)]; - - val = colormap[source[3]]; - val = (Col2RGB8[64-val][dest[3]] + fgstart[val<<8]) | 0x1f07c1f; - dest[3] = RGB32k.All[val & (val>>15)]; + for (int ks = 0; ks < 4; ks++) + { + val = source[ks]; + int r = (GPalette.BaseColors[dest[ks]].r * (63-val) + GPalette.BaseColors[_color].r * val) >> 8; + int g = (GPalette.BaseColors[dest[ks]].g * (63-val) + GPalette.BaseColors[_color].g * val) >> 8; + int b = (GPalette.BaseColors[dest[ks]].b * (63-val) + GPalette.BaseColors[_color].b * val) >> 8; + dest[ks] = RGB256k.RGB[MIN(r,63)][MIN(g,63)][MIN(b,63)]; + } source += 4; dest += pitch; @@ -598,23 +571,18 @@ namespace swrenderer if (count <= 0) return; - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; colormap = _colormap; do { - uint32_t a = fg2rgb[colormap[*source]] + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[(a>>15) & a]; + int fg = *source; + int bg = *dest; + int r = MIN((GPalette.BaseColors[fg].r * _srcalpha + GPalette.BaseColors[bg].r * _destalpha)>>18, 63); + int g = MIN((GPalette.BaseColors[fg].g * _srcalpha + GPalette.BaseColors[bg].g * _destalpha)>>18, 63); + int b = MIN((GPalette.BaseColors[fg].b * _srcalpha + GPalette.BaseColors[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; source += 4; dest += pitch; } while (--count); @@ -637,46 +605,16 @@ namespace swrenderer pitch = _pitch * thread->num_cores; colormap = _colormap; - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; - do { - uint32_t a = fg2rgb[colormap[source[0]]] + bg2rgb[dest[0]]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[0] = RGB32k.All[(a>>15) & a]; - - a = fg2rgb[colormap[source[1]]] + bg2rgb[dest[1]]; - b = a; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[1] = RGB32k.All[(a>>15) & a]; - - a = fg2rgb[colormap[source[2]]] + bg2rgb[dest[2]]; - b = a; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[2] = RGB32k.All[(a>>15) & a]; - - a = fg2rgb[colormap[source[3]]] + bg2rgb[dest[3]]; - b = a; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[3] = RGB32k.All[(a>>15) & a]; + for (int ks = 0; ks < 4; ks++) + { + int fg = source[ks]; + int bg = dest[ks]; + int r = MIN((GPalette.BaseColors[fg].r * _srcalpha + GPalette.BaseColors[bg].r * _destalpha)>>18, 63); + int g = MIN((GPalette.BaseColors[fg].g * _srcalpha + GPalette.BaseColors[bg].g * _destalpha)>>18, 63); + int b = MIN((GPalette.BaseColors[fg].b * _srcalpha + GPalette.BaseColors[bg].b * _destalpha)>>18, 63); + dest[ks] = RGB256k.RGB[r][g][b]; + } source += 4; dest += pitch; diff --git a/src/textures/ddstexture.cpp b/src/textures/ddstexture.cpp index 31e748022..a2c69b38b 100644 --- a/src/textures/ddstexture.cpp +++ b/src/textures/ddstexture.cpp @@ -551,7 +551,7 @@ void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf) DWORD r = (c & RMask) << RShiftL; r |= r >> RShiftR; DWORD g = (c & GMask) << GShiftL; g |= g >> GShiftR; DWORD b = (c & BMask) << BShiftL; b |= b >> BShiftR; - *pixelp = RGB32k.RGB[r >> 27][g >> 27][b >> 27]; + *pixelp = RGB256k.RGB[r >> 26][g >> 26][b >> 26]; } else { @@ -637,7 +637,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf) // Pick colors from the palette for each of the four colors. /*if (!tcbuf)*/ for (i = 3; i >= 0; --i) { - palcol[i] = color[i].a ? RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3] : 0; + palcol[i] = color[i].a ? RGB256k.RGB[color[i].r >> 2][color[i].g >> 2][color[i].b >> 2] : 0; } // Now decode this 4x4 block to the pixel buffer. for (y = 0; y < 4; ++y) @@ -717,7 +717,7 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu // Pick colors from the palette for each of the four colors. if (!tcbuf) for (i = 3; i >= 0; --i) { - palcol[i] = RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3]; + palcol[i] = RGB256k.RGB[color[i].r >> 2][color[i].g >> 2][color[i].b >> 2]; } // Now decode this 4x4 block to the pixel buffer. for (y = 0; y < 4; ++y) @@ -822,7 +822,7 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu // Pick colors from the palette for each of the four colors. if (!tcbuf) for (i = 3; i >= 0; --i) { - palcol[i] = RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3]; + palcol[i] = RGB256k.RGB[color[i].r >> 2][color[i].g >> 2][color[i].b >> 2]; } // Now decode this 4x4 block to the pixel buffer. for (y = 0; y < 4; ++y) diff --git a/src/textures/jpegtexture.cpp b/src/textures/jpegtexture.cpp index 225396598..c138edbfa 100644 --- a/src/textures/jpegtexture.cpp +++ b/src/textures/jpegtexture.cpp @@ -406,7 +406,7 @@ void FJPEGTexture::MakeTexture () case JCS_RGB: for (int x = Width; x > 0; --x) { - *out = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; + *out = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; out += Height; in += 3; } @@ -430,7 +430,7 @@ void FJPEGTexture::MakeTexture () int r = in[3] - (((256-in[0])*in[3]) >> 8); int g = in[3] - (((256-in[1])*in[3]) >> 8); int b = in[3] - (((256-in[2])*in[3]) >> 8); - *out = RGB32k.RGB[r >> 3][g >> 3][b >> 3]; + *out = RGB256k.RGB[r >> 2][g >> 2][b >> 2]; out += Height; in += 4; } diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index e68c4e20f..991893845 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -531,7 +531,7 @@ void FMultiPatchTexture::MakeTexture () { if (*out == 0 && in[3] != 0) { - *out = RGB32k.RGB[in[2]>>3][in[1]>>3][in[0]>>3]; + *out = RGB256k.RGB[in[2]>>2][in[1]>>2][in[0]>>2]; } out += Height; in += 4; diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index e13944173..414c424b8 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -536,12 +536,7 @@ void FPNGTexture::MakeTexture () { if (!HaveTrans) { -#ifdef NO_RGB666 - *out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; -#else *out++ = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; -#endif - } else { @@ -553,11 +548,7 @@ void FPNGTexture::MakeTexture () } else { -#ifdef NO_RGB666 - *out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; -#else *out++ = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; -#endif } } in += pitch; @@ -602,11 +593,7 @@ void FPNGTexture::MakeTexture () { for (y = Height; y > 0; --y) { -#ifdef NO_RGB666 - *out++ = in[3] < 128 ? 0 : RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; -#else *out++ = in[3] < 128 ? 0 : RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; -#endif in += pitch; } in -= backstep; diff --git a/src/textures/tgatexture.cpp b/src/textures/tgatexture.cpp index e24b926ca..331747cfe 100644 --- a/src/textures/tgatexture.cpp +++ b/src/textures/tgatexture.cpp @@ -393,7 +393,7 @@ void FTGATexture::MakeTexture () for(int x=0;x>10) & 0x1f][(v>>5) & 0x1f][v & 0x1f]; + Pixels[x*Height+y] = RGB256k.RGB[((v>>10) & 0x1f)*2][((v>>5) & 0x1f)*2][(v & 0x1f)*2]; p+=step_x; } } @@ -405,11 +405,7 @@ void FTGATexture::MakeTexture () BYTE * p = ptr + y * Pitch; for(int x=0;x>3][p[1]>>3][p[0]>>3]; -#else Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2]; -#endif p+=step_x; } } @@ -423,11 +419,7 @@ void FTGATexture::MakeTexture () BYTE * p = ptr + y * Pitch; for(int x=0;x>3][p[1]>>3][p[0]>>3]; -#else Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2]; -#endif p+=step_x; } } @@ -439,11 +431,7 @@ void FTGATexture::MakeTexture () BYTE * p = ptr + y * Pitch; for(int x=0;x= 128? RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3] : 0; -#else Pixels[x*Height+y] = p[3] >= 128? RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2] : 0; -#endif p+=step_x; } } From 9fbd9985c8b77ba4ba1a0613d1d1708e09046763 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 18 Dec 2016 05:33:39 -0500 Subject: [PATCH 1429/1509] - more work on rgb666 --- src/r_draw_pal.cpp | 82 +++--------------- src/r_drawt_pal.cpp | 160 ++++++++++++++---------------------- src/textures/pcxtexture.cpp | 2 +- 3 files changed, 72 insertions(+), 172 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 5a6c94327..33c482934 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -314,17 +314,10 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { -#ifdef NO_RGB666 - uint32_t fg = fg2rgb[colormap[pix]]; - uint32_t bg = bg2rgb[*dest]; - fg = (fg + bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg >> 15)]; -#else uint32_t r = MIN(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 255); uint32_t g = MIN(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 255); uint32_t b = MIN(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 255); *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; -#endif } frac += fracstep; dest += pitch; @@ -364,17 +357,10 @@ namespace swrenderer uint8_t pix = _bufplce[i][vplce[i] >> bits]; if (pix != 0) { -#ifdef NO_RGB666 - uint32_t fg = fg2rgb[_palookupoffse[i][pix]]; - uint32_t bg = bg2rgb[dest[i]]; - fg = (fg + bg) | 0x1f07c1f; - dest[i] = RGB32k.All[fg & (fg >> 15)]; -#else uint32_t r = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].r + GPalette.BaseColors[dest[i]].r, 255); uint32_t g = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].g + GPalette.BaseColors[dest[i]].g, 255); uint32_t b = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].b + GPalette.BaseColors[dest[i]].b, 255); dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; -#endif } vplce[i] += vince[i]; } @@ -617,21 +603,10 @@ namespace swrenderer uint8_t pix = _bufplce[i][vplce[i] >> bits]; if (pix != 0) { -#ifdef NO_RGB666 - uint32_t a = (bg2rgb[dest[i]] | 0x40100400) - fg2rgb[_palookupoffse[i][pix]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[i] = RGB32k.All[a & (a >> 15)]; -#else uint32_t r = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].r - GPalette.BaseColors[dest[i]].r, 0, 255); uint32_t g = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].g - GPalette.BaseColors[dest[i]].g, 0, 255); uint32_t b = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].b - GPalette.BaseColors[dest[i]].b, 0, 255); dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; -#endif } vplce[i] += vince[i]; } @@ -715,11 +690,7 @@ namespace swrenderer c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; -#ifdef NO_RGB666 - *dest = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; -#else *dest = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; -#endif } frac += fracstep; @@ -747,13 +718,8 @@ namespace swrenderer int solid_bottom_r = RPART(solid_bottom); int solid_bottom_g = GPART(solid_bottom); int solid_bottom_b = BPART(solid_bottom); -#ifdef NO_RGB666 - uint32_t solid_top_fill = RGB32k.RGB[(solid_top_r >> 3)][(solid_top_g >> 3)][(solid_top_b >> 3)]; - uint32_t solid_bottom_fill = RGB32k.RGB[(solid_bottom_r >> 3)][(solid_bottom_g >> 3)][(solid_bottom_b >> 3)]; -#else uint32_t solid_top_fill = RGB256k.RGB[(solid_top_r >> 2)][(solid_top_g >> 2)][(solid_top_b >> 2)]; uint32_t solid_bottom_fill = RGB256k.RGB[(solid_bottom_r >> 2)][(solid_bottom_g >> 2)][(solid_bottom_b >> 2)]; -#endif solid_top_fill = (solid_top_fill << 24) | (solid_top_fill << 16) | (solid_top_fill << 8) | solid_top_fill; solid_bottom_fill = (solid_bottom_fill << 24) | (solid_bottom_fill << 16) | (solid_bottom_fill << 8) | solid_bottom_fill; @@ -813,11 +779,7 @@ namespace swrenderer c_red = (c_red * alpha_top + solid_top_r * inv_alpha_top) >> 8; c_green = (c_green * alpha_top + solid_top_g * inv_alpha_top) >> 8; c_blue = (c_blue * alpha_top + solid_top_b * inv_alpha_top) >> 8; -#ifdef NO_RGB666 - output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; -#else output[col] = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; -#endif frac[col] += fracstep[col]; } *((uint32_t*)dest) = *((uint32_t*)output); @@ -858,11 +820,7 @@ namespace swrenderer c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; -#ifdef NO_RGB666 - output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; -#else output[col] = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; -#endif frac[col] += fracstep[col]; } @@ -944,11 +902,7 @@ namespace swrenderer c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; -#ifdef NO_RGB666 - *dest = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; -#else *dest = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; -#endif } frac += fracstep; @@ -978,13 +932,8 @@ namespace swrenderer int solid_bottom_r = RPART(solid_bottom); int solid_bottom_g = GPART(solid_bottom); int solid_bottom_b = BPART(solid_bottom); -#ifdef NO_RGB666 - uint32_t solid_top_fill = RGB32k.RGB[(solid_top_r >> 3)][(solid_top_g >> 3)][(solid_top_b >> 3)]; - uint32_t solid_bottom_fill = RGB32k.RGB[(solid_bottom_r >> 3)][(solid_bottom_g >> 3)][(solid_bottom_b >> 3)]; -#else uint32_t solid_top_fill = RGB256k.RGB[(solid_top_r >> 2)][(solid_top_g >> 2)][(solid_top_b >> 2)]; uint32_t solid_bottom_fill = RGB256k.RGB[(solid_bottom_r >> 2)][(solid_bottom_g >> 2)][(solid_bottom_b >> 2)]; -#endif solid_top_fill = (solid_top_fill << 24) | (solid_top_fill << 16) | (solid_top_fill << 8) | solid_top_fill; solid_bottom_fill = (solid_bottom_fill << 24) | (solid_bottom_fill << 16) | (solid_bottom_fill << 8) | solid_bottom_fill; @@ -1050,11 +999,7 @@ namespace swrenderer c_red = (c_red * alpha_top + solid_top_r * inv_alpha_top) >> 8; c_green = (c_green * alpha_top + solid_top_g * inv_alpha_top) >> 8; c_blue = (c_blue * alpha_top + solid_top_b * inv_alpha_top) >> 8; -#ifdef NO_RGB666 - output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; -#else output[col] = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; -#endif frac[col] += fracstep[col]; } @@ -1108,11 +1053,7 @@ namespace swrenderer c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; -#ifdef NO_RGB666 - output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; -#else output[col] = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; -#endif frac[col] += fracstep[col]; } @@ -1244,9 +1185,12 @@ namespace swrenderer do { - uint32_t bg; - bg = (fg + bg2rgb[*dest]) | 0x1f07c1f; - *dest = RGB32k.All[bg & (bg >> 15)]; + const PalEntry* pal = GPalette.BaseColors; + // *** [SP] this is incomplete, not sure what to do here. + /*int r = clamp((int)pal[_srccolor].r, 0, 255) >> 2; + int g = clamp((int)pal[_srccolor].g, 0, 255) >> 2; + int b = clamp((int)pal[_srccolor].b, 0, 255) >> 2; + *dest = RGB256k.RGB[r][g][b];*/ dest += pitch; } while (--count); @@ -1276,15 +1220,11 @@ namespace swrenderer do { - uint32_t a = fg + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[a & (a >> 15)]; + const PalEntry* pal = GPalette.BaseColors; + int r = clamp(pal[*dest].r + pal[fg].r, 0, 255) >> 2; + int g = clamp(pal[*dest].g + pal[fg].g, 0, 255) >> 2; + int b = clamp(pal[*dest].b + pal[fg].b, 0, 255) >> 2; + *dest = RGB256k.RGB[r][g][b]; dest += pitch; } while (--count); } diff --git a/src/r_drawt_pal.cpp b/src/r_drawt_pal.cpp index 16d24ecaf..156e97ba6 100644 --- a/src/r_drawt_pal.cpp +++ b/src/r_drawt_pal.cpp @@ -446,14 +446,15 @@ namespace swrenderer source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { uint32_t fg = colormap[*source]; uint32_t bg = *dest; - int r = MIN((GPalette.BaseColors[fg].r * _srcalpha + GPalette.BaseColors[bg].r * _destalpha)>>18, 63); - int g = MIN((GPalette.BaseColors[fg].g * _srcalpha + GPalette.BaseColors[bg].g * _destalpha)>>18, 63); - int b = MIN((GPalette.BaseColors[fg].b * _srcalpha + GPalette.BaseColors[bg].b * _destalpha)>>18, 63); + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); *dest = RGB256k.RGB[r][g][b]; source += 4; dest += pitch; @@ -476,15 +477,16 @@ namespace swrenderer source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { for (int ks = 0; ks < 4; ks++) { // [SP] this 4col function was a block of copy-pasted code. 4 times. I regret nothing. uint32_t fg = colormap[source[ks]]; uint32_t bg = dest[ks]; - int r = MIN((GPalette.BaseColors[fg].r * _srcalpha + GPalette.BaseColors[bg].r * _destalpha)>>18, 63); - int g = MIN((GPalette.BaseColors[fg].g * _srcalpha + GPalette.BaseColors[bg].g * _destalpha)>>18, 63); - int b = MIN((GPalette.BaseColors[fg].b * _srcalpha + GPalette.BaseColors[bg].b * _destalpha)>>18, 63); + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); dest[ks] = RGB256k.RGB[r][g][b]; } @@ -511,13 +513,14 @@ namespace swrenderer dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; + const PalEntry *palette = GPalette.BaseColors; do { uint32_t val = *source; - int r = (GPalette.BaseColors[*dest].r * (63-val) + GPalette.BaseColors[_color].r * val) >> 8; - int g = (GPalette.BaseColors[*dest].g * (63-val) + GPalette.BaseColors[_color].g * val) >> 8; - int b = (GPalette.BaseColors[*dest].b * (63-val) + GPalette.BaseColors[_color].b * val) >> 8; - *dest = RGB256k.RGB[MIN(r,63)][MIN(g,63)][MIN(b,63)]; + int r = (palette[*dest].r * (255-val)) >> 10; + int g = (palette[*dest].g * (255-val)) >> 10; + int b = (palette[*dest].b * (255-val)) >> 10; + *dest = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; source += 4; dest += pitch; } while (--count); @@ -541,6 +544,7 @@ namespace swrenderer dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; pitch = _pitch * thread->num_cores; + const PalEntry *palette = GPalette.BaseColors; do { uint32_t val; @@ -548,10 +552,10 @@ namespace swrenderer for (int ks = 0; ks < 4; ks++) { val = source[ks]; - int r = (GPalette.BaseColors[dest[ks]].r * (63-val) + GPalette.BaseColors[_color].r * val) >> 8; - int g = (GPalette.BaseColors[dest[ks]].g * (63-val) + GPalette.BaseColors[_color].g * val) >> 8; - int b = (GPalette.BaseColors[dest[ks]].b * (63-val) + GPalette.BaseColors[_color].b * val) >> 8; - dest[ks] = RGB256k.RGB[MIN(r,63)][MIN(g,63)][MIN(b,63)]; + int r = (palette[dest[ks]].r * (255-val)) >> 10; + int g = (palette[dest[ks]].g * (255-val)) >> 10; + int b = (palette[dest[ks]].b * (255-val)) >> 10; + dest[ks] = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; } source += 4; @@ -575,13 +579,14 @@ namespace swrenderer source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { int fg = *source; int bg = *dest; - int r = MIN((GPalette.BaseColors[fg].r * _srcalpha + GPalette.BaseColors[bg].r * _destalpha)>>18, 63); - int g = MIN((GPalette.BaseColors[fg].g * _srcalpha + GPalette.BaseColors[bg].g * _destalpha)>>18, 63); - int b = MIN((GPalette.BaseColors[fg].b * _srcalpha + GPalette.BaseColors[bg].b * _destalpha)>>18, 63); + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); *dest = RGB256k.RGB[r][g][b]; source += 4; dest += pitch; @@ -604,15 +609,16 @@ namespace swrenderer source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { for (int ks = 0; ks < 4; ks++) { int fg = source[ks]; int bg = dest[ks]; - int r = MIN((GPalette.BaseColors[fg].r * _srcalpha + GPalette.BaseColors[bg].r * _destalpha)>>18, 63); - int g = MIN((GPalette.BaseColors[fg].g * _srcalpha + GPalette.BaseColors[bg].g * _destalpha)>>18, 63); - int b = MIN((GPalette.BaseColors[fg].b * _srcalpha + GPalette.BaseColors[bg].b * _destalpha)>>18, 63); + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); dest[ks] = RGB256k.RGB[r][g][b]; } @@ -639,16 +645,15 @@ namespace swrenderer source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (fg2rgb[colormap[*source]] | 0x40100400) - bg2rgb[*dest]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[(a>>15) & a]; + int fg = *source; + int bg = *dest; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; source += 4; dest += pitch; } while (--count); @@ -672,40 +677,18 @@ namespace swrenderer source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (fg2rgb[colormap[source[0]]] | 0x40100400) - bg2rgb[dest[0]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[0] = RGB32k.All[(a>>15) & a]; - - a = (fg2rgb[colormap[source[1]]] | 0x40100400) - bg2rgb[dest[1]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[1] = RGB32k.All[(a>>15) & a]; - - a = (fg2rgb[colormap[source[2]]] | 0x40100400) - bg2rgb[dest[2]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[2] = RGB32k.All[(a>>15) & a]; - - a = (fg2rgb[colormap[source[3]]] | 0x40100400) - bg2rgb[dest[3]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[3] = RGB32k.All[(a>>15) & a]; + for (int ks = 0; ks < 4; ks++) + { + int fg = source[ks]; + int bg = dest[ks]; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + dest[ks] = RGB256k.RGB[r][g][b]; + } source += 4; dest += pitch; @@ -730,16 +713,15 @@ namespace swrenderer source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[*source]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[(a>>15) & a]; + int fg = *source; + int bg = *dest; + int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; source += 4; dest += pitch; } while (--count); @@ -763,40 +745,18 @@ namespace swrenderer source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (bg2rgb[dest[0]] | 0x40100400) - fg2rgb[colormap[source[0]]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[0] = RGB32k.All[(a>>15) & a]; - - a = (bg2rgb[dest[1]] | 0x40100400) - fg2rgb[colormap[source[1]]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[1] = RGB32k.All[(a>>15) & a]; - - a = (bg2rgb[dest[2]] | 0x40100400) - fg2rgb[colormap[source[2]]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[2] = RGB32k.All[(a>>15) & a]; - - a = (bg2rgb[dest[3]] | 0x40100400) - fg2rgb[colormap[source[3]]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[3] = RGB32k.All[(a>>15) & a]; + for (int ks = 0; ks < 4; ks++) + { + int fg = source[ks]; + int bg = dest[ks]; + int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + dest[ks] = RGB256k.RGB[r][g][b]; + } source += 4; dest += pitch; diff --git a/src/textures/pcxtexture.cpp b/src/textures/pcxtexture.cpp index 0ec5d2933..dda431993 100644 --- a/src/textures/pcxtexture.cpp +++ b/src/textures/pcxtexture.cpp @@ -528,7 +528,7 @@ void FPCXTexture::MakeTexture() { for(int x=0; x < Width; x++) { - Pixels[y+Height*x] = RGB32k.RGB[row[0]>>3][row[1]>>3][row[2]>>3]; + Pixels[y+Height*x] = RGB256k.RGB[row[0]>>2][row[1]>>2][row[2]>>2]; row+=3; } } From e4e0f0bcd912f11b9867ce7e72dd9fa8b43ee032 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 18 Dec 2016 08:34:33 -0500 Subject: [PATCH 1430/1509] - playing a bit with the fill drawers --- src/r_draw_pal.cpp | 15 +++++++++------ src/v_video.cpp | 6 +----- src/v_video.h | 2 -- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 33c482934..9d15460af 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -1183,14 +1183,17 @@ namespace swrenderer dest = thread->dest_for_thread(_dest_y, pitch, dest); pitch *= thread->num_cores; + const PalEntry* pal = GPalette.BaseColors; + int _srcalpha = 32768, _destalpha = 32768; do { - const PalEntry* pal = GPalette.BaseColors; - // *** [SP] this is incomplete, not sure what to do here. - /*int r = clamp((int)pal[_srccolor].r, 0, 255) >> 2; - int g = clamp((int)pal[_srccolor].g, 0, 255) >> 2; - int b = clamp((int)pal[_srccolor].b, 0, 255) >> 2; - *dest = RGB256k.RGB[r][g][b];*/ + int src_r = ((_srccolor << 3) & 0x78) * _srcalpha; + int src_g = ((_srccolor >> 17) & 0x78) * _srcalpha; + int src_b = ((_srccolor >> 7) & 0x78) * _srcalpha; + int r = clamp((src_r + pal[*dest].r * _destalpha)>>18, 0, 255); + int g = clamp((src_g + pal[*dest].g * _destalpha)>>18, 0, 255); + int b = clamp((src_b + pal[*dest].b * _destalpha)>>18, 0, 255); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; } while (--count); diff --git a/src/v_video.cpp b/src/v_video.cpp index 6e333f840..62a587281 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -144,9 +144,7 @@ DWORD Col2RGB8[65][256]; DWORD *Col2RGB8_LessPrecision[65]; DWORD Col2RGB8_Inverse[65][256]; ColorTable32k RGB32k; -#ifndef NO_RGB666 ColorTable256k RGB256k; -#endif } @@ -666,14 +664,12 @@ static void BuildTransTable (const PalEntry *palette) for (g = 0; g < 32; g++) for (b = 0; b < 32; b++) //RGB32k.RGB[r][g][b] = ColorMatcher.Pick ((r<<3)|(r>>2), (g<<3)|(g>>2), (b<<3)|(b>>2)); - RGB32k.RGB[r][g][b] = 2; -#ifndef NO_RGB666 + RGB32k.RGB[r][g][b] = 4; // create the RGB666 lookup table for (r = 0; r < 64; r++) for (g = 0; g < 64; g++) for (b = 0; b < 64; b++) RGB256k.RGB[r][g][b] = ColorMatcher.Pick ((r<<2)|(r>>4), (g<<2)|(g>>4), (b<<2)|(b>>4)); -#endif int x, y; diff --git a/src/v_video.h b/src/v_video.h index 2079ff64b..57d15869c 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -463,14 +463,12 @@ union ColorTable32k extern "C" ColorTable32k RGB32k; // [SP] RGB666 support -#ifndef NO_RGB666 union ColorTable256k { BYTE RGB[64][64][64]; BYTE All[64 *64 *64]; }; extern "C" ColorTable256k RGB256k; -#endif // Col2RGB8 is a pre-multiplied palette for color lookup. It is stored in a // special R10B10G10 format for efficient blending computation. From 1b50620a87d4dc477daf0aef24d0fb0be9a6840b Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 18 Dec 2016 09:05:14 -0500 Subject: [PATCH 1431/1509] - finally decoded _srccolor in the fill drawers. still need to figure out how to get _srcalpha and _destalpha in there. --- src/r_draw_pal.cpp | 19 ++++++++++++------- src/r_draw_pal.h | 2 ++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 9d15460af..81975e23c 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -1187,9 +1187,9 @@ namespace swrenderer int _srcalpha = 32768, _destalpha = 32768; do { - int src_r = ((_srccolor << 3) & 0x78) * _srcalpha; - int src_g = ((_srccolor >> 17) & 0x78) * _srcalpha; - int src_b = ((_srccolor >> 7) & 0x78) * _srcalpha; + int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; + int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; + int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; int r = clamp((src_r + pal[*dest].r * _destalpha)>>18, 0, 255); int g = clamp((src_g + pal[*dest].g * _destalpha)>>18, 0, 255); int b = clamp((src_b + pal[*dest].b * _destalpha)>>18, 0, 255); @@ -1221,12 +1221,17 @@ namespace swrenderer dest = thread->dest_for_thread(_dest_y, pitch, dest); pitch *= thread->num_cores; + const PalEntry* pal = GPalette.BaseColors; + int _srcalpha = 32768, _destalpha = 32768; + do { - const PalEntry* pal = GPalette.BaseColors; - int r = clamp(pal[*dest].r + pal[fg].r, 0, 255) >> 2; - int g = clamp(pal[*dest].g + pal[fg].g, 0, 255) >> 2; - int b = clamp(pal[*dest].b + pal[fg].b, 0, 255) >> 2; + int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; + int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; + int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; + int r = clamp((src_r + pal[*dest].r * _destalpha)>>18, 0, 255); + int g = clamp((src_g + pal[*dest].g * _destalpha)>>18, 0, 255); + int b = clamp((src_b + pal[*dest].b * _destalpha)>>18, 0, 255); *dest = RGB256k.RGB[r][g][b]; dest += pitch; } while (--count); diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index 262b70387..54c74dc15 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -106,6 +106,8 @@ namespace swrenderer uint32_t *_srcblend; uint32_t *_destblend; uint32_t _srccolor; + fixed_t _srcalpha; + fixed_t _destalpha; }; class DrawColumnPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; From d687e52009384105fcf4ef6eb43919e5b76625e0 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 18 Dec 2016 17:08:56 -0500 Subject: [PATCH 1432/1509] - renamed R_DrawParticle_C to R_DrawParticle to remove vestigial ASM hook. - fixed particle crashes, fixed particle color math. --- src/r_draw.cpp | 4 ---- src/r_draw.h | 1 - src/r_things.cpp | 10 ++++++---- src/r_things.h | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index a461e1877..2c5d6fd91 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -1352,8 +1352,4 @@ namespace swrenderer } } - void R_DrawParticle(vissprite_t *sprite) - { - R_DrawParticle_C(sprite); - } } diff --git a/src/r_draw.h b/src/r_draw.h index 58934981b..f47179c51 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -201,5 +201,4 @@ namespace swrenderer void R_MapTiltedPlane(int y, int x1); void R_MapColoredPlane(int y, int x1); - void R_DrawParticle(vissprite_t *); } diff --git a/src/r_things.cpp b/src/r_things.cpp index 7c178ce8b..03900b321 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2632,7 +2632,9 @@ static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) } } -void R_DrawParticle_C (vissprite_t *vis) +//inline int clamp(int x, int y, int z) { return ((x < y) ? x : (z < y) ? z : y); } + +void R_DrawParticle (vissprite_t *vis) { int spacing; BYTE *dest; @@ -2666,9 +2668,9 @@ void R_DrawParticle_C (vissprite_t *vis) dest = ylookup[yl] + x + dc_destorg; for (int y = 0; y < ycount; y++) { - int dest_r = (GPalette.BaseColors[*dest].r * bglevel + GPalette.BaseColors[color].r * fglevel) >> 10; - int dest_g = (GPalette.BaseColors[*dest].g * bglevel + GPalette.BaseColors[color].g * fglevel) >> 10; - int dest_b = (GPalette.BaseColors[*dest].b * bglevel + GPalette.BaseColors[color].b * fglevel) >> 10; + uint32_t dest_r = MIN((GPalette.BaseColors[*dest].r * bglevel + GPalette.BaseColors[color].r * fglevel) >> 18, 63); + uint32_t dest_g = MIN((GPalette.BaseColors[*dest].g * bglevel + GPalette.BaseColors[color].g * fglevel) >> 18, 63); + uint32_t dest_b = MIN((GPalette.BaseColors[*dest].b * bglevel + GPalette.BaseColors[color].b * fglevel) >> 18, 63); *dest = RGB256k.RGB[dest_r][dest_g][dest_b]; dest += spacing; diff --git a/src/r_things.h b/src/r_things.h index bf32b655f..6b789cdc5 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -101,7 +101,7 @@ struct vissprite_t vissprite_t() {} }; -void R_DrawParticle_C (vissprite_t *); +void R_DrawParticle (vissprite_t *); void R_ProjectParticle (particle_t *, const sector_t *sector, int shade, int fakeside); extern int MaxVisSprites; From a4944067e824a1f82b42c5c0bf86e5b35b4b4dcb Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 18 Dec 2016 20:57:27 -0500 Subject: [PATCH 1433/1509] - fixed: whoops, fixed quite a merge faux pas there. --- src/r_segs.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index ccf6ccf20..41a8a9166 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -54,6 +54,7 @@ CVAR(Bool, r_fogboundary, true, 0) CVAR(Bool, r_drawmirrors, true, 0) EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); +EXTERN_CVAR(Bool, r_mipmap) namespace swrenderer { From b7629fcf0e0f2980469b5608567d20783db0bc78 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 19 Dec 2016 03:08:10 -0500 Subject: [PATCH 1434/1509] - This space intentionally left blank. - And white rabbits. --- src/r_draw_pal.cpp | 297 +++++++++++++++++++++------------------------ src/r_draw_pal.h | 2 + 2 files changed, 137 insertions(+), 162 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 81975e23c..9f474911e 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -4,6 +4,7 @@ **--------------------------------------------------------------------------- ** Copyright 1998-2016 Randy Heit ** Copyright 2016 Magnus Norddahl +** Copyright 2016 Rachael Alexanderson ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -1089,6 +1090,8 @@ namespace swrenderer _srcblend = dc_srcblend; _destblend = dc_destblend; _srccolor = dc_srccolor; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void DrawColumnPalCommand::Execute(DrawerThread *thread) @@ -1184,7 +1187,7 @@ namespace swrenderer pitch *= thread->num_cores; const PalEntry* pal = GPalette.BaseColors; - int _srcalpha = 32768, _destalpha = 32768; + do { int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; @@ -1222,7 +1225,6 @@ namespace swrenderer pitch *= thread->num_cores; const PalEntry* pal = GPalette.BaseColors; - int _srcalpha = 32768, _destalpha = 32768; do { @@ -1245,11 +1247,7 @@ namespace swrenderer count = _count; dest = _dest; - uint32_t *bg2rgb; - uint32_t fg; - bg2rgb = _destblend; - fg = _srccolor | 0x40100400; int pitch = _pitch; count = thread->count_for_thread(_dest_y, count); @@ -1259,16 +1257,19 @@ namespace swrenderer dest = thread->dest_for_thread(_dest_y, pitch, dest); pitch *= thread->num_cores; + const PalEntry* palette = GPalette.BaseColors; + do { - uint32_t a = fg - bg2rgb[*dest]; - uint32_t b = a; + int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; + int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; + int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; + int bg = *dest; + int r = MAX((src_r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((src_g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((src_b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a >> 15)]; + *dest = RGB256k.RGB[r][g][b]; dest += pitch; } while (--count); } @@ -1283,11 +1284,7 @@ namespace swrenderer return; dest = _dest; - uint32_t *bg2rgb; - uint32_t fg; - bg2rgb = _destblend; - fg = _srccolor; int pitch = _pitch; count = thread->count_for_thread(_dest_y, count); @@ -1297,16 +1294,19 @@ namespace swrenderer dest = thread->dest_for_thread(_dest_y, pitch, dest); pitch *= thread->num_cores; + const PalEntry *palette = GPalette.BaseColors; + do { - uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg; - uint32_t b = a; + int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; + int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; + int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; + int bg = *dest; + int r = MAX((src_r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((src_g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((src_b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a >> 15)]; + *dest = RGB256k.RGB[r][g][b]; dest += pitch; } while (--count); } @@ -1334,20 +1334,18 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; const uint8_t *colormap = _colormap; const uint8_t *source = _source; + const PalEntry *palette = GPalette.BaseColors; do { uint32_t fg = colormap[source[frac >> FRACBITS]]; uint32_t bg = *dest; - - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg >> 15)]; + uint32_t r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + uint32_t g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + uint32_t b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1414,21 +1412,20 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; const uint8_t *translation = _translation; const uint8_t *colormap = _colormap; const uint8_t *source = _source; + const PalEntry *palette = GPalette.BaseColors; + do { uint32_t fg = colormap[translation[source[frac >> FRACBITS]]]; uint32_t bg = *dest; - - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg >> 15)]; + uint32_t r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + uint32_t g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + uint32_t b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1460,12 +1457,16 @@ namespace swrenderer const uint8_t *colormap = _colormap; uint32_t *fgstart = &Col2RGB8[0][_color]; + const PalEntry *palette = GPalette.BaseColors; + do { - uint32_t val = colormap[source[frac >> FRACBITS]]; - uint32_t fg = fgstart[val << 8]; - val = (Col2RGB8[64 - val][*dest] + fg) | 0x1f07c1f; - *dest = RGB32k.All[val & (val >> 15)]; + uint32_t val = source[frac >> FRACBITS]; + + int r = (palette[*dest].r * (255-val)) >> 10; + int g = (palette[*dest].g * (255-val)) >> 10; + int b = (palette[*dest].b * (255-val)) >> 10; + *dest = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; dest += pitch; frac += fracstep; @@ -1497,20 +1498,16 @@ namespace swrenderer const uint8_t *colormap = _colormap; const uint8_t *source = _source; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = fg2rgb[colormap[source[frac >> FRACBITS]]] + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[a & (a >> 15)]; + int fg = colormap[source[frac >> FRACBITS]]; + int bg = *dest; + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1542,20 +1539,16 @@ namespace swrenderer const uint8_t *translation = _translation; const uint8_t *colormap = _colormap; const uint8_t *source = _source; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = fg2rgb[colormap[translation[source[frac >> FRACBITS]]]] + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[(a >> 15) & a]; + int fg = colormap[translation[source[frac >> FRACBITS]]]; + int bg = *dest; + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1586,19 +1579,16 @@ namespace swrenderer const uint8_t *colormap = _colormap; const uint8_t *source = _source; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (fg2rgb[colormap[source[frac >> FRACBITS]]] | 0x40100400) - bg2rgb[*dest]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a >> 15)]; + int fg = colormap[source[frac >> FRACBITS]]; + int bg = *dest; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1630,19 +1620,16 @@ namespace swrenderer const uint8_t *translation = _translation; const uint8_t *colormap = _colormap; const uint8_t *source = _source; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (fg2rgb[colormap[translation[source[frac >> FRACBITS]]]] | 0x40100400) - bg2rgb[*dest]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[(a >> 15) & a]; + int fg = colormap[translation[source[frac >> FRACBITS]]]; + int bg = *dest; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1673,19 +1660,16 @@ namespace swrenderer const uint8_t *colormap = _colormap; const uint8_t *source = _source; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[source[frac >> FRACBITS]]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a >> 15)]; + int fg = colormap[source[frac >> FRACBITS]]; + int bg = *dest; + int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1717,19 +1701,16 @@ namespace swrenderer const uint8_t *translation = _translation; const uint8_t *colormap = _colormap; const uint8_t *source = _source; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[translation[source[frac >> FRACBITS]]]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[(a >> 15) & a]; + int fg = colormap[translation[source[frac >> FRACBITS]]]; + int bg = *dest; + int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1845,6 +1826,8 @@ namespace swrenderer _srcblend = dc_srcblend; _destblend = dc_destblend; _color = ds_color; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void DrawSpanPalCommand::Execute(DrawerThread *thread) @@ -1990,8 +1973,6 @@ namespace swrenderer const uint8_t *colormap = _colormap; int count; int spot; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; xfrac = _xfrac; yfrac = _yfrac; @@ -2003,6 +1984,8 @@ namespace swrenderer xstep = _xstep; ystep = _ystep; + const PalEntry *palette = GPalette.BaseColors; + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. @@ -2011,10 +1994,11 @@ namespace swrenderer spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); uint32_t fg = colormap[source[spot]]; uint32_t bg = *dest; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest++ = RGB32k.All[fg & (fg >> 15)]; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest++ = RGB256k.RGB[r][g][b]; + xfrac += xstep; yfrac += ystep; } while (--count); @@ -2029,10 +2013,11 @@ namespace swrenderer spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); uint32_t fg = colormap[source[spot]]; uint32_t bg = *dest; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest++ = RGB32k.All[fg & (fg >> 15)]; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest++ = RGB256k.RGB[r][g][b]; + xfrac += xstep; yfrac += ystep; } while (--count); @@ -2053,8 +2038,8 @@ namespace swrenderer const uint8_t *colormap = _colormap; int count; int spot; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + + const PalEntry *palette = GPalette.BaseColors; xfrac = _xfrac; yfrac = _yfrac; @@ -2079,10 +2064,10 @@ namespace swrenderer { uint32_t fg = colormap[texdata]; uint32_t bg = *dest; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg >> 15)]; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; } dest++; xfrac += xstep; @@ -2104,10 +2089,10 @@ namespace swrenderer { uint32_t fg = colormap[texdata]; uint32_t bg = *dest; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg >> 15)]; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; } dest++; xfrac += xstep; @@ -2130,8 +2115,7 @@ namespace swrenderer const uint8_t *colormap = _colormap; int count; int spot; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; xfrac = _xfrac; yfrac = _yfrac; @@ -2149,15 +2133,13 @@ namespace swrenderer do { spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; - uint32_t b = a; + uint32_t fg = colormap[source[spot]]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest++ = RGB256k.RGB[r][g][b]; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest++ = RGB32k.All[a & (a >> 15)]; xfrac += xstep; yfrac += ystep; } while (--count); @@ -2170,15 +2152,13 @@ namespace swrenderer do { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; - uint32_t b = a; + uint32_t fg = colormap[source[spot]]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest++ = RGB256k.RGB[r][g][b]; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest++ = RGB32k.All[a & (a >> 15)]; xfrac += xstep; yfrac += ystep; } while (--count); @@ -2199,8 +2179,7 @@ namespace swrenderer const uint8_t *colormap = _colormap; int count; int spot; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; xfrac = _xfrac; yfrac = _yfrac; @@ -2223,15 +2202,12 @@ namespace swrenderer texdata = source[spot]; if (texdata != 0) { - uint32_t a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[a & (a >> 15)]; + uint32_t fg = colormap[texdata]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; } dest++; xfrac += xstep; @@ -2251,15 +2227,12 @@ namespace swrenderer texdata = source[spot]; if (texdata != 0) { - uint32_t a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[a & (a >> 15)]; + uint32_t fg = colormap[texdata]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; } dest++; xfrac += xstep; diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index 54c74dc15..0b1a5eebf 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -166,6 +166,8 @@ namespace swrenderer uint32_t *_srcblend; uint32_t *_destblend; int _color; + fixed_t _srcalpha; + fixed_t _destalpha; }; class DrawSpanPalCommand : public PalSpanCommand { public: void Execute(DrawerThread *thread) override; }; From c7d4d7cd1db1b5418150b5a74a6bc478c2aa2850 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 19 Dec 2016 03:51:54 -0500 Subject: [PATCH 1435/1509] - fixed: Sometimes it helps to stay positive. Especially when deciding whether to add or subtract the background in the span drawers. --- src/r_draw_pal.cpp | 48 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 9f474911e..a1bddb16b 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -1994,9 +1994,9 @@ namespace swrenderer spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); uint32_t fg = colormap[source[spot]]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest++ = RGB256k.RGB[r][g][b]; xfrac += xstep; @@ -2013,9 +2013,9 @@ namespace swrenderer spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); uint32_t fg = colormap[source[spot]]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest++ = RGB256k.RGB[r][g][b]; xfrac += xstep; @@ -2064,9 +2064,9 @@ namespace swrenderer { uint32_t fg = colormap[texdata]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; } dest++; @@ -2089,9 +2089,9 @@ namespace swrenderer { uint32_t fg = colormap[texdata]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; } dest++; @@ -2135,9 +2135,9 @@ namespace swrenderer spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); uint32_t fg = colormap[source[spot]]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest++ = RGB256k.RGB[r][g][b]; xfrac += xstep; @@ -2154,9 +2154,9 @@ namespace swrenderer spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); uint32_t fg = colormap[source[spot]]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest++ = RGB256k.RGB[r][g][b]; xfrac += xstep; @@ -2204,9 +2204,9 @@ namespace swrenderer { uint32_t fg = colormap[texdata]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; } dest++; @@ -2229,9 +2229,9 @@ namespace swrenderer { uint32_t fg = colormap[texdata]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; } dest++; From 2d0960044c12439f81800628129c4b2b2ec540d1 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 19 Dec 2016 04:01:25 -0500 Subject: [PATCH 1436/1509] - Added colormap checking to some blending drawers that were missing it. --- src/r_drawt_pal.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/r_drawt_pal.cpp b/src/r_drawt_pal.cpp index 156e97ba6..ebf0ea00e 100644 --- a/src/r_drawt_pal.cpp +++ b/src/r_drawt_pal.cpp @@ -582,7 +582,7 @@ namespace swrenderer const PalEntry *palette = GPalette.BaseColors; do { - int fg = *source; + int fg = colormap[*source]; int bg = *dest; int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); @@ -614,7 +614,7 @@ namespace swrenderer do { for (int ks = 0; ks < 4; ks++) { - int fg = source[ks]; + int fg = colormap[source[ks]]; int bg = dest[ks]; int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); @@ -648,7 +648,7 @@ namespace swrenderer const PalEntry *palette = GPalette.BaseColors; do { - int fg = *source; + int fg = colormap[*source]; int bg = *dest; int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); @@ -682,7 +682,7 @@ namespace swrenderer do { for (int ks = 0; ks < 4; ks++) { - int fg = source[ks]; + int fg = colormap[source[ks]]; int bg = dest[ks]; int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); @@ -716,7 +716,7 @@ namespace swrenderer const PalEntry *palette = GPalette.BaseColors; do { - int fg = *source; + int fg = colormap[*source]; int bg = *dest; int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); @@ -750,7 +750,7 @@ namespace swrenderer do { for (int ks = 0; ks < 4; ks++) { - int fg = source[ks]; + int fg = colormap[source[ks]]; int bg = dest[ks]; int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); From e2be28f92556249cae3f610042f5593c88af58bc Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 19 Dec 2016 04:27:56 -0500 Subject: [PATCH 1437/1509] - implemented RGB256k for screen crossfade and burn --- src/f_wipe.cpp | 27 +++++++++++++++++---------- src/r_draw.cpp | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index a3ceb8d50..352122007 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -28,6 +28,7 @@ #include "f_wipe.h" #include "c_cvars.h" #include "templates.h" +#include "v_palette.h" // // SCREEN WIPE PACKAGE @@ -299,12 +300,15 @@ bool wipe_doBurn (int ticks) else { int bglevel = 64-fglevel; - DWORD *fg2rgb = Col2RGB8[fglevel]; - DWORD *bg2rgb = Col2RGB8[bglevel]; - DWORD fg = fg2rgb[fromnew[x]]; - DWORD bg = bg2rgb[fromold[x]]; - fg = (fg+bg) | 0x1f07c1f; - to[x] = RGB32k.All[fg & (fg>>15)]; + + const PalEntry* pal = GPalette.BaseColors; + + DWORD fg = fromnew[x]; + DWORD bg = fromold[x]; + int r = MIN((pal[fg].r * fglevel + pal[bg].r * bglevel) >> 8, 63); + int g = MIN((pal[fg].g * fglevel + pal[bg].g * bglevel) >> 8, 63); + int b = MIN((pal[fg].b * fglevel + pal[bg].b * bglevel) >> 8, 63); + to[x] = RGB256k.RGB[r][g][b]; done = false; } } @@ -347,15 +351,18 @@ bool wipe_doFade (int ticks) BYTE *fromnew = (BYTE *)wipe_scr_end; BYTE *fromold = (BYTE *)wipe_scr_start; BYTE *to = screen->GetBuffer(); + const PalEntry *pal = GPalette.BaseColors; for (y = 0; y < SCREENHEIGHT; y++) { for (x = 0; x < SCREENWIDTH; x++) { - DWORD fg = fg2rgb[fromnew[x]]; - DWORD bg = bg2rgb[fromold[x]]; - fg = (fg+bg) | 0x1f07c1f; - to[x] = RGB32k.All[fg & (fg>>15)]; + DWORD fg = fromnew[x]; + DWORD bg = fromold[x]; + int r = MIN((pal[fg].r * (64-bglevel) + pal[bg].r * bglevel) >> 8, 63); + int g = MIN((pal[fg].g * (64-bglevel) + pal[bg].g * bglevel) >> 8, 63); + int b = MIN((pal[fg].b * (64-bglevel) + pal[bg].b * bglevel) >> 8, 63); + to[x] = RGB256k.RGB[r][g][b]; } fromnew += SCREENWIDTH; fromold += SCREENWIDTH; diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 2c5d6fd91..2d86ee985 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -450,7 +450,7 @@ namespace swrenderer uint32_t g = GPART(color); uint32_t b = BPART(color); // dc_color is used by the rt_* routines. It is indexed into dc_srcblend. - dc_color = RGB32k.RGB[r >> 3][g >> 3][b >> 3]; + dc_color = RGB256k.RGB[r >> 2][g >> 2][b >> 2]; if (style.Flags & STYLEF_InvertSource) { r = 255 - r; From 1e9d48216c6578bbce183252dab32757ec820bb5 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 19 Dec 2016 04:45:08 -0500 Subject: [PATCH 1438/1509] - removed all references to COL2RGB8 and RGB32k. Everything has now been transformed to RGB256k. --- src/f_wipe.cpp | 2 -- src/r_draw.cpp | 6 ------ src/r_draw_pal.cpp | 1 - src/r_drawt_pal.cpp | 2 -- src/r_plane.cpp | 16 ++++++++-------- src/v_video.cpp | 37 ------------------------------------- src/v_video.h | 39 --------------------------------------- 7 files changed, 8 insertions(+), 95 deletions(-) diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index 352122007..8d5f072f6 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -346,8 +346,6 @@ bool wipe_doFade (int ticks) { int x, y; int bglevel = 64 - fade; - DWORD *fg2rgb = Col2RGB8[fade]; - DWORD *bg2rgb = Col2RGB8[bglevel]; BYTE *fromnew = (BYTE *)wipe_scr_end; BYTE *fromold = (BYTE *)wipe_scr_start; BYTE *to = screen->GetBuffer(); diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 2d86ee985..62e92273e 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -238,22 +238,16 @@ namespace swrenderer } if (flags & STYLEF_InvertSource) { - dc_srcblend = Col2RGB8_Inverse[fglevel >> 10]; - dc_destblend = Col2RGB8_LessPrecision[bglevel >> 10]; dc_srcalpha = fglevel; dc_destalpha = bglevel; } else if (op == STYLEOP_Add && fglevel + bglevel <= FRACUNIT) { - dc_srcblend = Col2RGB8[fglevel >> 10]; - dc_destblend = Col2RGB8[bglevel >> 10]; dc_srcalpha = fglevel; dc_destalpha = bglevel; } else { - dc_srcblend = Col2RGB8_LessPrecision[fglevel >> 10]; - dc_destblend = Col2RGB8_LessPrecision[bglevel >> 10]; dc_srcalpha = fglevel; dc_destalpha = bglevel; } diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index a1bddb16b..b99f58f88 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -1455,7 +1455,6 @@ namespace swrenderer const uint8_t *source = _source; const uint8_t *colormap = _colormap; - uint32_t *fgstart = &Col2RGB8[0][_color]; const PalEntry *palette = GPalette.BaseColors; diff --git a/src/r_drawt_pal.cpp b/src/r_drawt_pal.cpp index ebf0ea00e..27c2a4294 100644 --- a/src/r_drawt_pal.cpp +++ b/src/r_drawt_pal.cpp @@ -508,7 +508,6 @@ namespace swrenderer if (count <= 0) return; - fgstart = &Col2RGB8[0][_color]; colormap = _colormap; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; @@ -539,7 +538,6 @@ namespace swrenderer if (count <= 0) return; - fgstart = &Col2RGB8[0][_color]; colormap = _colormap; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index eafc9fa26..1a7758923 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1500,14 +1500,14 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t if (!additive) { spanfunc = R_DrawSpanMaskedTranslucent; - dc_srcblend = Col2RGB8[alpha>>10]; - dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE-alpha; } else { spanfunc = R_DrawSpanMaskedAddClamp; - dc_srcblend = Col2RGB8_LessPrecision[alpha>>10]; - dc_destblend = Col2RGB8_LessPrecision[FRACUNIT>>10]; + dc_srcalpha = alpha; + dc_destalpha = FRACUNIT; } } else @@ -1522,14 +1522,14 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t if (!additive) { spanfunc = R_DrawSpanTranslucent; - dc_srcblend = Col2RGB8[alpha>>10]; - dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE-alpha; } else { spanfunc = R_DrawSpanAddClamp; - dc_srcblend = Col2RGB8_LessPrecision[alpha>>10]; - dc_destblend = Col2RGB8_LessPrecision[FRACUNIT>>10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE-alpha; } } else diff --git a/src/v_video.cpp b/src/v_video.cpp index 62a587281..b639939ee 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -143,7 +143,6 @@ extern "C" { DWORD Col2RGB8[65][256]; DWORD *Col2RGB8_LessPrecision[65]; DWORD Col2RGB8_Inverse[65][256]; -ColorTable32k RGB32k; ColorTable256k RGB256k; } @@ -659,48 +658,12 @@ static void BuildTransTable (const PalEntry *palette) { int r, g, b; - // create the RGB555 lookup table - for (r = 0; r < 32; r++) - for (g = 0; g < 32; g++) - for (b = 0; b < 32; b++) - //RGB32k.RGB[r][g][b] = ColorMatcher.Pick ((r<<3)|(r>>2), (g<<3)|(g>>2), (b<<3)|(b>>2)); - RGB32k.RGB[r][g][b] = 4; // create the RGB666 lookup table for (r = 0; r < 64; r++) for (g = 0; g < 64; g++) for (b = 0; b < 64; b++) RGB256k.RGB[r][g][b] = ColorMatcher.Pick ((r<<2)|(r>>4), (g<<2)|(g>>4), (b<<2)|(b>>4)); - int x, y; - - // create the swizzled palette - for (x = 0; x < 65; x++) - for (y = 0; y < 256; y++) - Col2RGB8[x][y] = (((palette[y].r*x)>>4)<<20) | - ((palette[y].g*x)>>4) | - (((palette[y].b*x)>>4)<<10); - - // create the swizzled palette with the lsb of red and blue forced to 0 - // (for green, a 1 is okay since it never gets added into) - for (x = 1; x < 64; x++) - { - Col2RGB8_LessPrecision[x] = Col2RGB8_2[x-1]; - for (y = 0; y < 256; y++) - { - Col2RGB8_2[x-1][y] = Col2RGB8[x][y] & 0x3feffbff; - } - } - Col2RGB8_LessPrecision[0] = Col2RGB8[0]; - Col2RGB8_LessPrecision[64] = Col2RGB8[64]; - - // create the inverse swizzled palette - for (x = 0; x < 65; x++) - for (y = 0; y < 256; y++) - { - Col2RGB8_Inverse[x][y] = (((((255-palette[y].r)*x)>>4)<<20) | - (((255-palette[y].g)*x)>>4) | - ((((255-palette[y].b)*x)>>4)<<10)) & 0x3feffbff; - } } //========================================================================== diff --git a/src/v_video.h b/src/v_video.h index 57d15869c..0da6b9b50 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -448,20 +448,6 @@ EXTERN_CVAR (Float, Gamma) // Translucency tables -// RGB32k is a normal R5G5B5 -> palette lookup table. - -// Use a union so we can "overflow" without warnings. -// Otherwise, we get stuff like this from Clang (when compiled -// with -fsanitize=bounds) while running: -// src/v_video.cpp:390:12: runtime error: index 1068 out of bounds for type 'BYTE [32]' -// src/r_draw.cpp:273:11: runtime error: index 1057 out of bounds for type 'BYTE [32]' -union ColorTable32k -{ - BYTE RGB[32][32][32]; - BYTE All[32 *32 *32]; -}; -extern "C" ColorTable32k RGB32k; - // [SP] RGB666 support union ColorTable256k { @@ -470,31 +456,6 @@ union ColorTable256k }; extern "C" ColorTable256k RGB256k; -// Col2RGB8 is a pre-multiplied palette for color lookup. It is stored in a -// special R10B10G10 format for efficient blending computation. -// --RRRRRrrr--BBBBBbbb--GGGGGggg-- at level 64 -// --------rrrr------bbbb------gggg at level 1 -extern "C" DWORD Col2RGB8[65][256]; - -// Col2RGB8_LessPrecision is the same as Col2RGB8, but the LSB for red -// and blue are forced to zero, so if the blend overflows, it won't spill -// over into the next component's value. -// --RRRRRrrr-#BBBBBbbb-#GGGGGggg-- at level 64 -// --------rrr#------bbb#------gggg at level 1 -extern "C" DWORD *Col2RGB8_LessPrecision[65]; - -// Col2RGB8_Inverse is the same as Col2RGB8_LessPrecision, except the source -// palette has been inverted. -extern "C" DWORD Col2RGB8_Inverse[65][256]; - -// "Magic" numbers used during the blending: -// --000001111100000111110000011111 = 0x01f07c1f -// -0111111111011111111101111111111 = 0x3FEFFBFF -// -1000000000100000000010000000000 = 0x40100400 -// ------10000000001000000000100000 = 0x40100400 >> 5 -// --11111-----11111-----11111----- = 0x40100400 - (0x40100400 >> 5) aka "white" -// --111111111111111111111111111111 = 0x3FFFFFFF - // Allocates buffer screens, call before R_Init. void V_Init (bool restart); From 42fbe6358493f0cb7587745aa39b59921c565522 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 19 Dec 2016 05:02:44 -0500 Subject: [PATCH 1439/1509] - fixed: blood decals are now red. --- src/r_draw_pal.cpp | 6 +++--- src/r_drawt_pal.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index b99f58f88..fe6c63b6d 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -1462,9 +1462,9 @@ namespace swrenderer { uint32_t val = source[frac >> FRACBITS]; - int r = (palette[*dest].r * (255-val)) >> 10; - int g = (palette[*dest].g * (255-val)) >> 10; - int b = (palette[*dest].b * (255-val)) >> 10; + int r = (palette[*dest].r * (255-val) + palette[_color].r * val) >> 10; + int g = (palette[*dest].g * (255-val) + palette[_color].g * val) >> 10; + int b = (palette[*dest].b * (255-val) + palette[_color].b * val) >> 10; *dest = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; dest += pitch; diff --git a/src/r_drawt_pal.cpp b/src/r_drawt_pal.cpp index 27c2a4294..26cb56221 100644 --- a/src/r_drawt_pal.cpp +++ b/src/r_drawt_pal.cpp @@ -516,9 +516,9 @@ namespace swrenderer do { uint32_t val = *source; - int r = (palette[*dest].r * (255-val)) >> 10; - int g = (palette[*dest].g * (255-val)) >> 10; - int b = (palette[*dest].b * (255-val)) >> 10; + int r = (palette[*dest].r * (255-val) + palette[_color].r * val) >> 10; + int g = (palette[*dest].g * (255-val) + palette[_color].g * val) >> 10; + int b = (palette[*dest].b * (255-val) + palette[_color].b * val) >> 10; *dest = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; source += 4; dest += pitch; @@ -550,9 +550,9 @@ namespace swrenderer for (int ks = 0; ks < 4; ks++) { val = source[ks]; - int r = (palette[dest[ks]].r * (255-val)) >> 10; - int g = (palette[dest[ks]].g * (255-val)) >> 10; - int b = (palette[dest[ks]].b * (255-val)) >> 10; + int r = (palette[dest[ks]].r * (255-val) + palette[_color].r * val) >> 10; + int g = (palette[dest[ks]].g * (255-val) + palette[_color].g * val) >> 10; + int b = (palette[dest[ks]].b * (255-val) + palette[_color].b * val) >> 10; dest[ks] = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; } From 4a95ef93ed07ef6252bd0897ac11dcbab356c902 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 19 Dec 2016 05:19:10 -0500 Subject: [PATCH 1440/1509] - Added names to r_drawt_pal.cpp copyright notice. --- src/r_drawt_pal.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/r_drawt_pal.cpp b/src/r_drawt_pal.cpp index 26cb56221..e2af7bbf1 100644 --- a/src/r_drawt_pal.cpp +++ b/src/r_drawt_pal.cpp @@ -4,6 +4,8 @@ ** **--------------------------------------------------------------------------- ** Copyright 1998-2006 Randy Heit +** Copyright 2016 Magnus Norddahl +** Copyright 2016 Rachael Alexanderson ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without From c1352d6ecb1782cff6ca4899fe4ad5a2444071dd Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 19 Dec 2016 06:06:19 -0500 Subject: [PATCH 1441/1509] - fixed: One of these floors was supposed to be additive, not translucent... --- src/r_plane.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 1a7758923..581e8b732 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1529,7 +1529,7 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t { spanfunc = R_DrawSpanAddClamp; dc_srcalpha = alpha; - dc_destalpha = OPAQUE-alpha; + dc_destalpha = FRACUNIT; } } else From 5ffee5231fc1cd4fdf928d3c5c6e2e6d0d8db9b0 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 19 Dec 2016 11:27:46 -0500 Subject: [PATCH 1442/1509] - Hooking the new RGB256k drawer to triangle drawer in place of RGB32k. --- src/r_drawers.h | 2 +- src/r_poly_triangle.cpp | 2 +- tools/drawergen/fixedfunction/drawtrianglecodegen.cpp | 4 ++-- tools/drawergen/fixedfunction/drawtrianglecodegen.h | 2 +- tools/drawergen/llvmdrawers.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/r_drawers.h b/src/r_drawers.h index 102d3159f..8ac259e11 100644 --- a/src/r_drawers.h +++ b/src/r_drawers.h @@ -247,7 +247,7 @@ struct TriDrawTriangleArgs uint8_t stencilWriteValue; uint32_t *subsectorGBuffer; const uint8_t *colormaps; - const uint8_t *RGB32k; + const uint8_t *RGB256k; const uint8_t *BaseColors; }; diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index e06cf2b7f..72851b6b3 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -130,7 +130,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, WorkerThreadD args.stencilMasks = PolyStencilBuffer::Instance()->Masks(); args.subsectorGBuffer = PolySubsectorGBuffer::Instance()->Values(); args.colormaps = drawargs.colormaps; - args.RGB32k = RGB32k.All; + args.RGB256k = RGB256k.All; args.BaseColors = (const uint8_t *)GPalette.BaseColors; bool ccw = drawargs.ccw; diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index 674543ff2..c5f7405f5 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -492,7 +492,7 @@ SSAInt DrawTriangleCodegen::ToPal8(SSAVec4i c) SSAInt red = SSAInt::clamp(c[0], SSAInt(0), SSAInt(255)); SSAInt green = SSAInt::clamp(c[1], SSAInt(0), SSAInt(255)); SSAInt blue = SSAInt::clamp(c[2], SSAInt(0), SSAInt(255)); - return RGB32k[((blue >> 3) * 32 + (green >> 3)) * 32 + (red >> 3)].load(true).zext_int(); + return RGB256k[((blue >> 2) * 64 + (green >> 2)) * 64 + (red >> 2)].load(true).zext_int(); } SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying) @@ -631,7 +631,7 @@ void DrawTriangleCodegen::LoadArgs(SSAValue args, SSAValue thread_data) if (!truecolor) { Colormaps = args[0][20].load(true); - RGB32k = args[0][21].load(true); + RGB256k = args[0][21].load(true); BaseColors = args[0][22].load(true); } diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.h b/tools/drawergen/fixedfunction/drawtrianglecodegen.h index 640a22aea..71d6ebd58 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.h +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.h @@ -95,7 +95,7 @@ private: SSABool is_fixed_light; SSAUBytePtr Colormaps; - SSAUBytePtr RGB32k; + SSAUBytePtr RGB256k; SSAUBytePtr BaseColors; SSAInt numSpans; diff --git a/tools/drawergen/llvmdrawers.cpp b/tools/drawergen/llvmdrawers.cpp index e0300946c..e68470188 100644 --- a/tools/drawergen/llvmdrawers.cpp +++ b/tools/drawergen/llvmdrawers.cpp @@ -430,7 +430,7 @@ llvm::Type *LLVMDrawers::GetTriDrawTriangleArgs(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilWriteValue; elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *subsectorGBuffer; elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *colormaps; - elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *RGB32k; + elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *RGB256k; elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *BaseColors; TriDrawTriangleArgs = llvm::StructType::create(context, elements, "TriDrawTriangle", false)->getPointerTo(); return TriDrawTriangleArgs; From b3bed807de48069c0454c211ab7f2729d6d41421 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 20 Dec 2016 13:31:38 -0500 Subject: [PATCH 1443/1509] - Mostly implemented Zandronum's IWAD selection box. Currently, this change only affects Windows. --- src/win32/i_system.cpp | 18 ++++++++++++++++++ src/win32/resource.h | 7 +++++++ src/win32/zdoom.rc | 31 +++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index acea7a788..ebb3d8c67 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -127,6 +127,9 @@ static void DestroyCustomCursor(); EXTERN_CVAR(String, language); EXTERN_CVAR (Bool, queryiwad); +// Used on welcome/IWAD screen. +EXTERN_CVAR (Int, vid_renderer) +EXTERN_CVAR (Bool, fullscreen) extern HWND Window, ConWindow, GameTitleWindow; extern HANDLE StdOut; @@ -1159,6 +1162,18 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa newlabel.Format(GAMESIG " %s: %s", GetVersionString(), label); SetWindowText(hDlg, newlabel.GetChars()); } + + // [SP] Upstreamed from Zandronum + char szString[256]; + + // Check the current video settings. + SendDlgItemMessage( hDlg, vid_renderer ? IDC_WELCOME_OPENGL : IDC_WELCOME_SOFTWARE, BM_SETCHECK, BST_CHECKED, 0 ); + SendDlgItemMessage( hDlg, IDC_WELCOME_FULLSCREEN, BM_SETCHECK, fullscreen ? BST_CHECKED : BST_UNCHECKED, 0 ); + + // Set up our version string. + sprintf(szString, "Version %s.", GetVersionString()); + SetDlgItemText (hDlg, IDC_WELCOME_VERSION, szString); + // Populate the list with all the IWADs found ctrl = GetDlgItem(hDlg, IDC_IWADLIST); for (i = 0; i < NumWads; i++) @@ -1192,6 +1207,9 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa (LOWORD(wParam) == IDC_IWADLIST && HIWORD(wParam) == LBN_DBLCLK)) { SetQueryIWad(hDlg); + // [SP] Upstreamed from Zandronum + vid_renderer = SendDlgItemMessage( hDlg, IDC_WELCOME_OPENGL, BM_GETCHECK, 0, 0 ) == BST_CHECKED; + fullscreen = SendDlgItemMessage( hDlg, IDC_WELCOME_FULLSCREEN, BM_GETCHECK, 0, 0 ) == BST_CHECKED; ctrl = GetDlgItem (hDlg, IDC_IWADLIST); EndDialog(hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0)); } diff --git a/src/win32/resource.h b/src/win32/resource.h index 6886e83fd..52db9de2e 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -164,3 +164,10 @@ #define _APS_NEXT_SYMED_VALUE 101 #endif #endif + +// [SP] Upstreamed from Zandronum +#define IDC_WELCOME_VERSION 4019 // [RC] "Welcome" screen. +#define IDC_WELCOME_OPENGL 4020 +#define IDC_WELCOME_SOFTWARE 4021 +#define IDC_WELCOME_FULLSCREEN 4022 +#define IDI_ICONST 151 diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index 1f760d8ea..4d38762e0 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -220,6 +220,7 @@ END // Dialog // +/* IDD_IWADDIALOG DIALOGEX 0, 0, 212, 186 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW @@ -233,6 +234,36 @@ BEGIN LTEXT "ZDoom found more than one IWAD present.",IDC_STATIC,5,5,140,8 LTEXT "Select from the list below to determine which one to use:",IDC_STATIC,5,15,200,8 END +*/ +// [SP] Upstreamed from Zandronum +IDD_IWADDIALOG DIALOGEX 0, 0, 224, 236 +STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | + WS_SYSMENU +EXSTYLE WS_EX_APPWINDOW +CAPTION "Welcome" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + ICON IDI_ICON1,IDC_STATIC,7,7,32,32 + LTEXT "Welcome to QZDoom!",IDC_STATIC,42,8,180,8 + LTEXT "",IDC_WELCOME_VERSION,42,18,180,8 + GROUPBOX "IWAD selection",IDC_STATIC,8,32,224-16,102 + LTEXT "Select which game file (IWAD) to run.", IDC_STATIC,12,32+12,190,8 + LISTBOX IDC_IWADLIST,12,32+24,224-24,72,LBS_NOINTEGRALHEIGHT | + WS_VSCROLL | WS_TABSTOP + GROUPBOX "Video settings",IDC_STATIC,8,138,224-16,48 + LTEXT "Choose how QZDoom will render the game.", IDC_STATIC,12,148,190,8 + CONTROL "Hardware (OpenGL)",IDC_WELCOME_OPENGL,"Button", + BS_AUTORADIOBUTTON,12,170,93,10 + CONTROL "Software (Doom)",IDC_WELCOME_SOFTWARE,"Button", + BS_AUTORADIOBUTTON,12,160,93,10 + CONTROL "Fullscreen",IDC_WELCOME_FULLSCREEN,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP, 124,160,48,10 + CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,72,192,87,10 + DEFPUSHBUTTON "Play QZDoom",IDOK,8,236-18,90,14 + PUSHBUTTON "Exit",IDCANCEL,224-58,236-18,50,14 + +END IDD_EAXPROPERTYLIST DIALOGEX 0, 0, 265, 404 STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VSCROLL From 8a3db6c0036dc0f387afcd4c33ea1db2c87d4424 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 20 Dec 2016 23:21:34 +0100 Subject: [PATCH 1444/1509] Dynamic lights? Did anyone say DYNAMIC LIGHTS? --- src/gl/dynlights/a_dynlight.cpp | 5 --- src/r_draw_rgba.cpp | 25 +++++++++++ src/r_drawers.h | 11 +++++ src/r_poly_wall.cpp | 3 ++ src/r_swrenderer.cpp | 7 +++- src/r_swrenderer.h | 19 +++++++++ .../fixedfunction/drawwallcodegen.cpp | 42 ++++++++++++++++++- .../drawergen/fixedfunction/drawwallcodegen.h | 10 ++++- tools/drawergen/llvmdrawers.cpp | 18 ++++++++ tools/drawergen/llvmdrawers.h | 2 + 10 files changed, 133 insertions(+), 9 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 0ab834505..d2efbe991 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -79,7 +79,6 @@ #include "gl/utility/gl_convert.h" #include "gl/utility/gl_templates.h" -EXTERN_CVAR(Int, vid_renderer) //========================================================================== @@ -260,10 +259,6 @@ void ADynamicLight::Deactivate(AActor *activator) //========================================================================== void ADynamicLight::Tick() { - if (vid_renderer == 0) - { - return; - } if (IsOwned()) { if (!target || !target->state) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 09293d6de..7b4763855 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -221,6 +221,26 @@ namespace swrenderer if (args.source2[0] == nullptr) args.flags |= DrawWallArgs::nearest_filter; + args.dynlights = nullptr; + args.num_dynlights = 0; + /* + static TriLight fakelight; + static bool first = true; + if (first) + { + fakelight.x = 100.0f; + fakelight.y = 0.0f; + fakelight.z = 100.0f; + fakelight.color = 0xffffff00; + fakelight.radius = 256.0f / 1000.0f; + first = false; + } + + args.z = 0.0f; + args.step_z = 1.0f; + args.dynlights = &fakelight; + args.num_dynlights = 1; + */ DetectRangeError(args.dest, args.dest_y, args.count); } @@ -279,6 +299,11 @@ namespace swrenderer if (args.source2[0] == nullptr) args.flags |= DrawWallArgs::nearest_filter; + args.z = 0.0f; + args.step_z = 0.0f; + args.dynlights = nullptr; + args.num_dynlights = 0; + DetectRangeError(args.dest, args.dest_y, args.count); } diff --git a/src/r_drawers.h b/src/r_drawers.h index 8ac259e11..eff6ea370 100644 --- a/src/r_drawers.h +++ b/src/r_drawers.h @@ -59,6 +59,13 @@ struct WorkerThreadData int32_t StartY; }; +struct TriLight +{ + uint32_t color; + float x, y, z; + float radius; +}; + struct DrawWallArgs { uint32_t *dest; @@ -91,6 +98,10 @@ struct DrawWallArgs nearest_filter = 2 }; + float z, step_z; + TriLight *dynlights; + uint32_t num_dynlights; + FString ToString(); }; diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index ebb355431..f9d409b60 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -261,6 +261,9 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane args.SetColormap(Line->frontsector->ColorMap); args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); + //if (Side && Side->lighthead) + // args.uniforms.light = 255; // Make walls touched by a light fullbright! + if (Polyportal) { args.stencilwritevalue = Polyportal->StencilValue; diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index a0f90f5cc..5d94e0442 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -47,6 +47,9 @@ #include "r_poly.h" #include "p_setup.h" +void gl_ParseDefs(); +void gl_InitData(); + EXTERN_CVAR(Bool, r_shadercolormaps) EXTERN_CVAR(Float, maxviewpitch) // [SP] CVAR from GZDoom @@ -92,6 +95,8 @@ FSoftwareRenderer::~FSoftwareRenderer() void FSoftwareRenderer::Init() { + gl_ParseDefs(); + r_swtruecolor = screen->IsBgra(); R_InitRenderer(); } @@ -310,7 +315,7 @@ int FSoftwareRenderer::GetMaxViewPitch(bool down) bool FSoftwareRenderer::RequireGLNodes() { - return r_polyrenderer; + return true; } //========================================================================== diff --git a/src/r_swrenderer.h b/src/r_swrenderer.h index 5b205b852..812ec32b5 100644 --- a/src/r_swrenderer.h +++ b/src/r_swrenderer.h @@ -3,6 +3,10 @@ #include "r_renderer.h" +void gl_SetActorLights(AActor *); +void gl_PreprocessLevel(); +void gl_CleanLevelData(); + struct FSoftwareRenderer : public FRenderer { FSoftwareRenderer(); @@ -40,6 +44,21 @@ struct FSoftwareRenderer : public FRenderer void RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov) override; sector_t *FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel, bool back) override; + void StateChanged(AActor *actor) override + { + gl_SetActorLights(actor); + } + + void PreprocessLevel() override + { + gl_PreprocessLevel(); + } + + void CleanLevelData() override + { + gl_CleanLevelData(); + } + }; diff --git a/tools/drawergen/fixedfunction/drawwallcodegen.cpp b/tools/drawergen/fixedfunction/drawwallcodegen.cpp index 94b807f40..1ec00df76 100644 --- a/tools/drawergen/fixedfunction/drawwallcodegen.cpp +++ b/tools/drawergen/fixedfunction/drawwallcodegen.cpp @@ -78,6 +78,10 @@ void DrawWallCodegen::Generate(DrawWallVariant variant, bool fourColumns, SSAVal SSAShort fade_blue = args[0][41].load(true); SSAShort desaturate = args[0][42].load(true); SSAInt flags = args[0][43].load(true); + start_z = args[0][44].load(true); + step_z = args[0][45].load(true); + dynlights = args[0][46].load(true); + num_dynlights = args[0][47].load(true); shade_constants.light = SSAVec4i(light_blue.zext_int(), light_green.zext_int(), light_red.zext_int(), light_alpha.zext_int()); shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); shade_constants.desaturate = desaturate.zext_int(); @@ -129,9 +133,11 @@ void DrawWallCodegen::Loop(DrawWallVariant variant, bool fourColumns, bool isSim int numColumns = fourColumns ? 4 : 1; stack_index.store(SSAInt(0)); + stack_z.store(start_z); { SSAForBlock loop; SSAInt index = stack_index.load(); + z = stack_z.load(); loop.loop_block(index < count); SSAInt frac[4]; @@ -167,6 +173,7 @@ void DrawWallCodegen::Loop(DrawWallVariant variant, bool fourColumns, bool isSim dest[offset].store_vec4ub(color); } + stack_z.store(z + step_z); stack_index.store(index.add(SSAInt(1), true, true)); for (int i = 0; i < numColumns; i++) stack_frac[i].store(frac[i] + fracstep[i]); @@ -209,10 +216,41 @@ SSAVec4i DrawWallCodegen::SampleLinear(SSAUBytePtr col0, SSAUBytePtr col1, SSAIn SSAVec4i DrawWallCodegen::Shade(SSAVec4i fg, int index, bool isSimpleShade) { + SSAVec4i c; if (isSimpleShade) - return shade_bgra_simple(fg, light[index]); + c = shade_bgra_simple(fg, light[index]); else - return shade_bgra_advanced(fg, light[index], shade_constants); + c = shade_bgra_advanced(fg, light[index], shade_constants); + + stack_lit_color.store(c); + stack_light_index.store(SSAInt(0)); + + SSAForBlock block; + SSAInt light_index = stack_light_index.load(); + SSAVec4i lit_color = stack_lit_color.load(); + block.loop_block(light_index < num_dynlights); + { + SSAVec4i light_color = SSAUBytePtr(dynlights[light_index][0].v).load_vec4ub(true); + SSAFloat light_x = dynlights[light_index][1].load(true); + //SSAFloat light_y = dynlights[light_index][2].load(true); + SSAFloat light_z = dynlights[light_index][3].load(true); + SSAFloat light_rcp_radius = dynlights[light_index][4].load(true); + + // L = light-pos + // dist = sqrt(dot(L, L)) + // attenuation = 1 - MIN(dist * (1/radius), 1) + SSAFloat Lxy2 = light_x; // L.x*L.x + L.y*L.y + SSAFloat Lz = light_z - z; + SSAFloat dist = SSAFloat::sqrt(Lxy2 + Lz * Lz); + SSAInt attenuation = SSAInt(SSAFloat(256.0f) - SSAFloat::MIN(dist * light_rcp_radius, SSAFloat(256.0f)), true); + SSAVec4i contribution = (light_color * fg * attenuation) >> 16; + + stack_lit_color.store(lit_color + contribution); + stack_light_index.store(light_index + 1); + } + block.end_block(); + + return stack_lit_color.load(); } SSAVec4i DrawWallCodegen::Blend(SSAVec4i fg, SSAVec4i bg, DrawWallVariant variant) diff --git a/tools/drawergen/fixedfunction/drawwallcodegen.h b/tools/drawergen/fixedfunction/drawwallcodegen.h index 4a1599063..cb46dcd5f 100644 --- a/tools/drawergen/fixedfunction/drawwallcodegen.h +++ b/tools/drawergen/fixedfunction/drawwallcodegen.h @@ -47,7 +47,9 @@ private: SSAVec4i Shade(SSAVec4i fg, int index, bool isSimpleShade); SSAVec4i Blend(SSAVec4i fg, SSAVec4i bg, DrawWallVariant variant); - SSAStack stack_index, stack_frac[4]; + SSAStack stack_index, stack_frac[4], stack_light_index; + SSAStack stack_lit_color; + SSAStack stack_z; SSAUBytePtr dest; SSAUBytePtr source[4]; @@ -69,4 +71,10 @@ private: SSAInt fracstep[4]; SSAInt one[4]; + + SSAFloat start_z, step_z; + + SSAValue dynlights; // TriLight* + SSAInt num_dynlights; + SSAFloat z; }; diff --git a/tools/drawergen/llvmdrawers.cpp b/tools/drawergen/llvmdrawers.cpp index e68470188..706cfb79f 100644 --- a/tools/drawergen/llvmdrawers.cpp +++ b/tools/drawergen/llvmdrawers.cpp @@ -290,6 +290,11 @@ llvm::Type *LLVMDrawers::GetDrawWallArgsStruct(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; + elements.push_back(llvm::Type::getFloatTy(context)); // float z; + elements.push_back(llvm::Type::getFloatTy(context)); // float step_z; + elements.push_back(GetTriLightStruct(context)); // TriLight *dynlights; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t num_dynlights; + DrawWallArgsStruct = llvm::StructType::create(context, elements, "DrawWallArgs", false)->getPointerTo(); return DrawWallArgsStruct; } @@ -326,6 +331,19 @@ llvm::Type *LLVMDrawers::GetWorkerThreadDataStruct(llvm::LLVMContext &context) return WorkerThreadDataStruct; } +llvm::Type *LLVMDrawers::GetTriLightStruct(llvm::LLVMContext &context) +{ + if (TriLightStruct) + return TriLightStruct; + + std::vector elements; + elements.push_back(llvm::Type::getInt32Ty(context)); + for (int i = 0; i < 4 + TriVertex::NumVarying; i++) + elements.push_back(llvm::Type::getFloatTy(context)); + TriLightStruct = llvm::StructType::create(context, elements, "TriLight", false)->getPointerTo(); + return TriLightStruct; +} + llvm::Type *LLVMDrawers::GetTriVertexStruct(llvm::LLVMContext &context) { if (TriVertexStruct) diff --git a/tools/drawergen/llvmdrawers.h b/tools/drawergen/llvmdrawers.h index a1b7b5361..f546d1dff 100644 --- a/tools/drawergen/llvmdrawers.h +++ b/tools/drawergen/llvmdrawers.h @@ -58,6 +58,7 @@ private: llvm::Type *GetDrawWallArgsStruct(llvm::LLVMContext &context); llvm::Type *GetDrawSkyArgsStruct(llvm::LLVMContext &context); llvm::Type *GetWorkerThreadDataStruct(llvm::LLVMContext &context); + llvm::Type *GetTriLightStruct(llvm::LLVMContext &context); llvm::Type *GetTriVertexStruct(llvm::LLVMContext &context); llvm::Type *GetTriMatrixStruct(llvm::LLVMContext &context); llvm::Type *GetTriUniformsStruct(llvm::LLVMContext &context); @@ -70,6 +71,7 @@ private: llvm::Type *DrawWallArgsStruct = nullptr; llvm::Type *DrawSkyArgsStruct = nullptr; llvm::Type *WorkerThreadDataStruct = nullptr; + llvm::Type *TriLightStruct = nullptr; llvm::Type *TriVertexStruct = nullptr; llvm::Type *TriMatrixStruct = nullptr; llvm::Type *TriUniformsStruct = nullptr; From 578e3270e20f6b0dc6dba7e1001c95a963acc283 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 20 Dec 2016 23:03:06 -0500 Subject: [PATCH 1445/1509] - Implemented Gez's suggestion for disable autoload checkbox on the IWAD selection box. --- src/d_main.cpp | 4 +++- src/win32/i_system.cpp | 6 ++++++ src/win32/resource.h | 3 +++ src/win32/zdoom.rc | 11 ++++++----- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 04ba34cbb..2b8ff7437 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -205,6 +205,8 @@ CUSTOM_CVAR (String, vid_cursor, "None", CVAR_ARCHIVE | CVAR_NOINITCALL) } } +bool disableautoload = false; // [SP] No auto load + bool wantToRestart; bool DrawFSHUD; // [RH] Draw fullscreen HUD? TArray allwads; @@ -2038,7 +2040,7 @@ static void AddAutoloadFiles(const char *autoname) { LumpFilterIWAD.Format("%s.", autoname); // The '.' is appened to simplify parsing the string - if (!(gameinfo.flags & GI_SHAREWARE) && !Args->CheckParm("-noautoload")) + if (!(gameinfo.flags & GI_SHAREWARE) && !Args->CheckParm("-noautoload") && !disableautoload) { FString file; diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index ebb3d8c67..52f054dc2 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -130,6 +130,7 @@ EXTERN_CVAR (Bool, queryiwad); // Used on welcome/IWAD screen. EXTERN_CVAR (Int, vid_renderer) EXTERN_CVAR (Bool, fullscreen) +extern bool disableautoload; extern HWND Window, ConWindow, GameTitleWindow; extern HANDLE StdOut; @@ -1169,6 +1170,7 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa // Check the current video settings. SendDlgItemMessage( hDlg, vid_renderer ? IDC_WELCOME_OPENGL : IDC_WELCOME_SOFTWARE, BM_SETCHECK, BST_CHECKED, 0 ); SendDlgItemMessage( hDlg, IDC_WELCOME_FULLSCREEN, BM_SETCHECK, fullscreen ? BST_CHECKED : BST_UNCHECKED, 0 ); + SendDlgItemMessage( hDlg, IDC_WELCOME_NOAUTOLOAD, BM_SETCHECK, disableautoload ? BST_CHECKED : BST_UNCHECKED, 0 ); // Set up our version string. sprintf(szString, "Version %s.", GetVersionString()); @@ -1210,6 +1212,10 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa // [SP] Upstreamed from Zandronum vid_renderer = SendDlgItemMessage( hDlg, IDC_WELCOME_OPENGL, BM_GETCHECK, 0, 0 ) == BST_CHECKED; fullscreen = SendDlgItemMessage( hDlg, IDC_WELCOME_FULLSCREEN, BM_GETCHECK, 0, 0 ) == BST_CHECKED; + + // [SP] This is our's. + disableautoload = SendDlgItemMessage( hDlg, IDC_WELCOME_NOAUTOLOAD, BM_GETCHECK, 0, 0 ) == BST_CHECKED; + ctrl = GetDlgItem (hDlg, IDC_IWADLIST); EndDialog(hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0)); } diff --git a/src/win32/resource.h b/src/win32/resource.h index 52db9de2e..937a73658 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -171,3 +171,6 @@ #define IDC_WELCOME_SOFTWARE 4021 #define IDC_WELCOME_FULLSCREEN 4022 #define IDI_ICONST 151 + +// [SP] This is our's. +#define IDC_WELCOME_NOAUTOLOAD 4023 diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index 4d38762e0..c5c7bd259 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -236,7 +236,7 @@ BEGIN END */ // [SP] Upstreamed from Zandronum -IDD_IWADDIALOG DIALOGEX 0, 0, 224, 236 +IDD_IWADDIALOG DIALOGEX 0, 0, 224, 246 STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW @@ -258,11 +258,12 @@ BEGIN BS_AUTORADIOBUTTON,12,160,93,10 CONTROL "Fullscreen",IDC_WELCOME_FULLSCREEN,"Button", BS_AUTOCHECKBOX | WS_TABSTOP, 124,160,48,10 - CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button", + CONTROL "Disable autoload",IDC_WELCOME_NOAUTOLOAD,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,72,192,87,10 - DEFPUSHBUTTON "Play QZDoom",IDOK,8,236-18,90,14 - PUSHBUTTON "Exit",IDCANCEL,224-58,236-18,50,14 - + CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,72,202,87,10 + DEFPUSHBUTTON "Play QZDoom",IDOK,8,246-18,90,14 + PUSHBUTTON "Exit",IDCANCEL,224-58,246-18,50,14 END IDD_EAXPROPERTYLIST DIALOGEX 0, 0, 265, 404 From 4e56c9a41acd255e118bb61382f8d3665642a754 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 21 Dec 2016 07:33:28 +0100 Subject: [PATCH 1446/1509] Hooked up dynamic light on walls --- src/r_draw.cpp | 5 ++ src/r_draw.h | 7 ++ src/r_draw_rgba.cpp | 27 ++----- src/r_segs.cpp | 10 ++- src/r_walldraw.cpp | 73 ++++++++++++++++++- .../fixedfunction/drawwallcodegen.cpp | 3 + 6 files changed, 99 insertions(+), 26 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 6e159243a..f476e9538 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -62,6 +62,7 @@ namespace swrenderer extern int wallshade; double dc_texturemid; + FLightNode *dc_light_list; int ylookup[MAXHEIGHT]; uint8_t shadetables[NUMCOLORMAPS * 16 * 256]; @@ -100,6 +101,10 @@ namespace swrenderer uint8_t *dc_destorg; int dc_destheight; int dc_count; + FVector3 dc_viewpos; + FVector3 dc_viewpos_step; + TriLight *dc_lights; + int dc_num_lights; uint32_t dc_wall_texturefrac[4]; uint32_t dc_wall_iscale[4]; uint8_t *dc_wall_colormap[4]; diff --git a/src/r_draw.h b/src/r_draw.h index 88ac2338d..a337b4943 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -4,6 +4,8 @@ #include "r_defs.h" struct FSWColormap; +struct FLightNode; +struct TriLight; EXTERN_CVAR(Bool, r_multithreaded); EXTERN_CVAR(Bool, r_magfilter); @@ -34,6 +36,7 @@ namespace swrenderer }; extern double dc_texturemid; + extern FLightNode *dc_light_list; namespace drawerargs { @@ -63,6 +66,10 @@ namespace swrenderer extern uint8_t *dc_destorg; extern int dc_destheight; extern int dc_count; + extern FVector3 dc_viewpos; + extern FVector3 dc_viewpos_step; + extern TriLight *dc_lights; + extern int dc_num_lights; extern bool drawer_needs_pal_input; diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 7b4763855..2928ac73e 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -221,26 +221,11 @@ namespace swrenderer if (args.source2[0] == nullptr) args.flags |= DrawWallArgs::nearest_filter; + args.z = 0.0f; + args.step_z = 0.0f; args.dynlights = nullptr; args.num_dynlights = 0; - /* - static TriLight fakelight; - static bool first = true; - if (first) - { - fakelight.x = 100.0f; - fakelight.y = 0.0f; - fakelight.z = 100.0f; - fakelight.color = 0xffffff00; - fakelight.radius = 256.0f / 1000.0f; - first = false; - } - args.z = 0.0f; - args.step_z = 1.0f; - args.dynlights = &fakelight; - args.num_dynlights = 1; - */ DetectRangeError(args.dest, args.dest_y, args.count); } @@ -299,10 +284,10 @@ namespace swrenderer if (args.source2[0] == nullptr) args.flags |= DrawWallArgs::nearest_filter; - args.z = 0.0f; - args.step_z = 0.0f; - args.dynlights = nullptr; - args.num_dynlights = 0; + args.z = dc_viewpos.Z; + args.step_z = dc_viewpos_step.Z; + args.dynlights = dc_lights; + args.num_dynlights = dc_num_lights; DetectRangeError(args.dest, args.dest_y, args.count); } diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 41a8a9166..14abcfc24 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -60,7 +60,7 @@ namespace swrenderer { using namespace drawerargs; - void R_DrawWallSegment(FTexture *rw_pic, int x1, int x2, short *walltop, short *wallbottom, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask); + void R_DrawWallSegment(FTexture *rw_pic, int x1, int x2, short *walltop, short *wallbottom, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, FLightNode *light_list = nullptr); void R_DrawDrawSeg(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat); #define HEIGHTBITS 12 @@ -1139,6 +1139,8 @@ void R_RenderSegLoop () } if(fake3D & 7) return; + FLightNode *light_list = (curline && curline->sidedef) ? curline->sidedef->lighthead : nullptr; + // draw the wall tiers if (midtexture) { // one sided line @@ -1165,7 +1167,7 @@ void R_RenderSegLoop () { rw_offset = -rw_offset; } - R_DrawWallSegment(rw_pic, x1, x2, walltop, wallbottom, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_frontfz1, rw_frontfz2), false); + R_DrawWallSegment(rw_pic, x1, x2, walltop, wallbottom, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_frontfz1, rw_frontfz2), false, light_list); } fillshort (ceilingclip+x1, x2-x1, viewheight); fillshort (floorclip+x1, x2-x1, 0xffff); @@ -1201,7 +1203,7 @@ void R_RenderSegLoop () { rw_offset = -rw_offset; } - R_DrawWallSegment(rw_pic, x1, x2, walltop, wallupper, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_backcz1, rw_backcz2), false); + R_DrawWallSegment(rw_pic, x1, x2, walltop, wallupper, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_backcz1, rw_backcz2), false, light_list); } memcpy (ceilingclip+x1, wallupper+x1, (x2-x1)*sizeof(short)); } @@ -1240,7 +1242,7 @@ void R_RenderSegLoop () { rw_offset = -rw_offset; } - R_DrawWallSegment(rw_pic, x1, x2, walllower, wallbottom, swall, lwall, yscale, MAX(rw_backfz1, rw_backfz2), MIN(rw_frontfz1, rw_frontfz2), false); + R_DrawWallSegment(rw_pic, x1, x2, walllower, wallbottom, swall, lwall, yscale, MAX(rw_backfz1, rw_backfz2), MIN(rw_frontfz1, rw_frontfz2), false, light_list); } memcpy (floorclip+x1, walllower+x1, (x2-x1)*sizeof(short)); } diff --git a/src/r_walldraw.cpp b/src/r_walldraw.cpp index dcdfa4b89..ad82f54dc 100644 --- a/src/r_walldraw.cpp +++ b/src/r_walldraw.cpp @@ -42,6 +42,8 @@ #include "r_3dfloors.h" #include "v_palette.h" #include "r_data/colormaps.h" +#include "gl/dynlights/gl_dynlight.h" +#include "r_drawers.h" namespace swrenderer { @@ -537,6 +539,53 @@ static void Draw1Column(int x, int y1, int y2, WallSampler &sampler, void(*draw1 { if (r_swtruecolor) { + // Find column position in view space + float w1 = 1.0f / WallC.sz1; + float w2 = 1.0f / WallC.sz2; + float t = (x - WallC.sx1 + 0.5f) / (WallC.sx2 - WallC.sx1); + float wcol = w1 * (1.0f - t) + w2 * t; + float zcol = 1.0f / wcol; + float xcol = (WallC.tleft.X * w1 * (1.0f - t) + WallC.tright.X * w2 * t) * zcol; + float ycol = (WallC.tleft.Y * w1 * (1.0f - t) + WallC.tright.Y * w2 * t) * zcol; + dc_viewpos.X = xcol; + dc_viewpos.Y = ycol; + dc_viewpos.Z = (float)((CenterY - y1 - 0.5) / InvZtoScale * zcol); + dc_viewpos_step.Z = (float)(-zcol / InvZtoScale); + + static TriLight lightbuffer[64 * 1024]; + static int nextlightindex = 0; + + // Setup lights for column + dc_num_lights = 0; + dc_lights = lightbuffer + nextlightindex; + FLightNode *cur_node = dc_light_list; + while (cur_node && nextlightindex < 64 * 1024) + { + uint32_t red = cur_node->lightsource->GetRed(); + uint32_t green = cur_node->lightsource->GetGreen(); + uint32_t blue = cur_node->lightsource->GetBlue(); + + double lightX = cur_node->lightsource->X() - ViewPos.X; + double lightY = cur_node->lightsource->Y() - ViewPos.Y; + double lightZ = cur_node->lightsource->Z() - ViewPos.Z; + + nextlightindex++; + auto &light = dc_lights[dc_num_lights++]; + light.x = (float)(lightX * ViewSin - lightY * ViewCos) - dc_viewpos.X; + light.y = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; + light.z = (float)lightZ; + light.radius = 256.0f / cur_node->lightsource->GetRadius(); + light.color = 0xff000000 | (red << 16) | (green << 8) | blue; + + // Precalculate the constant part of the dot here so the drawer doesn't have to. + light.x = light.x * light.x + light.y * light.y; + + cur_node = cur_node->nextLight; + } + + if (nextlightindex == 64 * 1024) + nextlightindex = 0; + int count = y2 - y1; dc_source = sampler.source; @@ -738,6 +787,25 @@ static void ProcessWallWorker( float light = rw_light; + double xmagnitude = 1.0; + +#if !defined(NO_DYNAMIC_SWLIGHTS) + for (int x = x1; x < x2; x++, light += rw_lightstep) + { + int y1 = uwal[x]; + int y2 = dwal[x]; + if (y2 <= y1) + continue; + + if (!fixed) + R_SetColorMapLight(basecolormap, light, wallshade); + + if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); + + WallSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); + Draw1Column(x, y1, y2, sampler, draw1column); + } +#else // Calculate where 4 column alignment begins and ends: int aligned_x1 = clamp((x1 + 3) / 4 * 4, x1, x2); int aligned_x2 = clamp(x2 / 4 * 4, x1, x2); @@ -872,6 +940,7 @@ static void ProcessWallWorker( WallSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); Draw1Column(x, y1, y2, sampler, draw1column); } +#endif NetUpdate(); } @@ -1077,8 +1146,9 @@ void R_DrawDrawSeg(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, floa } -void R_DrawWallSegment(FTexture *rw_pic, int x1, int x2, short *walltop, short *wallbottom, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask) +void R_DrawWallSegment(FTexture *rw_pic, int x1, int x2, short *walltop, short *wallbottom, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, FLightNode *light_list) { + dc_light_list = light_list; if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) { ProcessWallNP2(x1, x2, walltop, wallbottom, swall, lwall, yscale, top, bottom, false); @@ -1087,6 +1157,7 @@ void R_DrawWallSegment(FTexture *rw_pic, int x1, int x2, short *walltop, short * { ProcessWall(x1, x2, walltop, wallbottom, swall, lwall, yscale, false); } + dc_light_list = nullptr; } void R_DrawSkySegment(visplane_t *pl, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) diff --git a/tools/drawergen/fixedfunction/drawwallcodegen.cpp b/tools/drawergen/fixedfunction/drawwallcodegen.cpp index 1ec00df76..6f546b9b3 100644 --- a/tools/drawergen/fixedfunction/drawwallcodegen.cpp +++ b/tools/drawergen/fixedfunction/drawwallcodegen.cpp @@ -107,6 +107,9 @@ void DrawWallCodegen::Generate(DrawWallVariant variant, bool fourColumns, SSAVal one[i] = ((0x80000000 + textureheight[i] - 1) / textureheight[i]) * 2 + 1; } + start_z = start_z + step_z * SSAFloat(skipped_by_thread(dest_y, thread)); + step_z = step_z * SSAFloat(thread.num_cores); + SSAIfBlock branch; branch.if_block(is_simple_shade); LoopShade(variant, fourColumns, true); From dcd0ab98cc292d5485578f98589cc17c7c0e487c Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 21 Dec 2016 02:16:44 -0500 Subject: [PATCH 1447/1509] - Added Zandronum-specific copyright notices for IWAD picker. --- src/win32/i_system.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index 52f054dc2..2dc6c4d3d 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -4,6 +4,8 @@ ** **--------------------------------------------------------------------------- ** Copyright 1998-2009 Randy Heit +** Copyright (C) 2007-2012 Skulltag Development Team +** Copyright (C) 2007-2016 Zandronum Development Team ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -17,6 +19,15 @@ ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. +** 4. Redistributions in any form must be accompanied by information on how to +** obtain complete source code for the software and any accompanying software +** that uses the software. The source code must either be included in the +** distribution or be available for no more than the cost of distribution plus +** a nominal fee, and must be freely redistributable under reasonable +** conditions. For an executable file, complete source code means the source +** code for all modules it contains. It does not include source code for +** modules or files that typically accompany the major components of the +** operating system on which the executable file runs. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES From cd3fc2d6b8033f649761f304fc83906caf81b550 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 21 Dec 2016 05:11:29 -0500 Subject: [PATCH 1448/1509] - More options for the IWAD picker. - Rearranged some options around a bit. - Disable auto load is now an archived cvar. --- src/d_main.cpp | 22 ++++++++++++++++++++- src/win32/i_system.cpp | 11 +++++++++-- src/win32/resource.h | 5 +++-- src/win32/zdoom.rc | 45 +++++++++++++++++++----------------------- 4 files changed, 53 insertions(+), 30 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 2b8ff7437..1ea2d2707 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -205,7 +205,10 @@ CUSTOM_CVAR (String, vid_cursor, "None", CVAR_ARCHIVE | CVAR_NOINITCALL) } } -bool disableautoload = false; // [SP] No auto load +// Controlled by startup dialog +CVAR (Bool, disableautoload, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) +CVAR (Bool, autoloadbrightmaps, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) +CVAR (Bool, autoloadlights, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) bool wantToRestart; bool DrawFSHUD; // [RH] Draw fullscreen HUD? @@ -2040,6 +2043,23 @@ static void AddAutoloadFiles(const char *autoname) { LumpFilterIWAD.Format("%s.", autoname); // The '.' is appened to simplify parsing the string + // [SP] Dialog reaction - load lights.pk3 and brightmaps.pk3 based on user choices + if (!(gameinfo.flags & GI_SHAREWARE)) + { + if (autoloadlights) + { + const char *lightswad = BaseFileSearch ("lights.pk3", NULL); + if (lightswad) + D_AddFile (allwads, lightswad); + } + if (autoloadbrightmaps) + { + const char *bmwad = BaseFileSearch ("brightmaps.pk3", NULL); + if (bmwad) + D_AddFile (allwads, bmwad); + } + } + if (!(gameinfo.flags & GI_SHAREWARE) && !Args->CheckParm("-noautoload") && !disableautoload) { FString file; diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index 2dc6c4d3d..f07fb8f1d 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -141,7 +141,9 @@ EXTERN_CVAR (Bool, queryiwad); // Used on welcome/IWAD screen. EXTERN_CVAR (Int, vid_renderer) EXTERN_CVAR (Bool, fullscreen) -extern bool disableautoload; +EXTERN_CVAR (Bool, disableautoload) +EXTERN_CVAR (Bool, autoloadlights) +EXTERN_CVAR (Bool, autoloadbrightmaps) extern HWND Window, ConWindow, GameTitleWindow; extern HANDLE StdOut; @@ -1181,7 +1183,11 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa // Check the current video settings. SendDlgItemMessage( hDlg, vid_renderer ? IDC_WELCOME_OPENGL : IDC_WELCOME_SOFTWARE, BM_SETCHECK, BST_CHECKED, 0 ); SendDlgItemMessage( hDlg, IDC_WELCOME_FULLSCREEN, BM_SETCHECK, fullscreen ? BST_CHECKED : BST_UNCHECKED, 0 ); + + // [SP] This is our's SendDlgItemMessage( hDlg, IDC_WELCOME_NOAUTOLOAD, BM_SETCHECK, disableautoload ? BST_CHECKED : BST_UNCHECKED, 0 ); + SendDlgItemMessage( hDlg, IDC_WELCOME_LIGHTS, BM_SETCHECK, autoloadlights ? BST_CHECKED : BST_UNCHECKED, 0 ); + SendDlgItemMessage( hDlg, IDC_WELCOME_BRIGHTMAPS, BM_SETCHECK, autoloadbrightmaps ? BST_CHECKED : BST_UNCHECKED, 0 ); // Set up our version string. sprintf(szString, "Version %s.", GetVersionString()); @@ -1226,7 +1232,8 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa // [SP] This is our's. disableautoload = SendDlgItemMessage( hDlg, IDC_WELCOME_NOAUTOLOAD, BM_GETCHECK, 0, 0 ) == BST_CHECKED; - + autoloadlights = SendDlgItemMessage( hDlg, IDC_WELCOME_LIGHTS, BM_GETCHECK, 0, 0 ) == BST_CHECKED; + autoloadbrightmaps = SendDlgItemMessage( hDlg, IDC_WELCOME_BRIGHTMAPS, BM_GETCHECK, 0, 0 ) == BST_CHECKED; ctrl = GetDlgItem (hDlg, IDC_IWADLIST); EndDialog(hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0)); } diff --git a/src/win32/resource.h b/src/win32/resource.h index 937a73658..cf41b6f1f 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -158,7 +158,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 150 +#define _APS_NEXT_RESOURCE_VALUE 151 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1084 #define _APS_NEXT_SYMED_VALUE 101 @@ -170,7 +170,8 @@ #define IDC_WELCOME_OPENGL 4020 #define IDC_WELCOME_SOFTWARE 4021 #define IDC_WELCOME_FULLSCREEN 4022 -#define IDI_ICONST 151 // [SP] This is our's. #define IDC_WELCOME_NOAUTOLOAD 4023 +#define IDC_WELCOME_LIGHTS 4024 +#define IDC_WELCOME_BRIGHTMAPS 4025 diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index c5c7bd259..99422e4ad 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -120,9 +120,9 @@ BEGIN IDD_IWADDIALOG, DIALOG BEGIN LEFTMARGIN, 5 - RIGHTMARGIN, 205 + RIGHTMARGIN, 222 TOPMARGIN, 7 - BOTTOMMARGIN, 179 + BOTTOMMARGIN, 242 END IDD_EAXPROPERTYLIST, DIALOG @@ -237,33 +237,28 @@ END */ // [SP] Upstreamed from Zandronum IDD_IWADDIALOG DIALOGEX 0, 0, 224, 246 -STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | - WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW CAPTION "Welcome" FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - ICON IDI_ICON1,IDC_STATIC,7,7,32,32 - LTEXT "Welcome to QZDoom!",IDC_STATIC,42,8,180,8 - LTEXT "",IDC_WELCOME_VERSION,42,18,180,8 - GROUPBOX "IWAD selection",IDC_STATIC,8,32,224-16,102 - LTEXT "Select which game file (IWAD) to run.", IDC_STATIC,12,32+12,190,8 - LISTBOX IDC_IWADLIST,12,32+24,224-24,72,LBS_NOINTEGRALHEIGHT | - WS_VSCROLL | WS_TABSTOP - GROUPBOX "Video settings",IDC_STATIC,8,138,224-16,48 - LTEXT "Choose how QZDoom will render the game.", IDC_STATIC,12,148,190,8 - CONTROL "Hardware (OpenGL)",IDC_WELCOME_OPENGL,"Button", - BS_AUTORADIOBUTTON,12,170,93,10 - CONTROL "Software (Doom)",IDC_WELCOME_SOFTWARE,"Button", - BS_AUTORADIOBUTTON,12,160,93,10 - CONTROL "Fullscreen",IDC_WELCOME_FULLSCREEN,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP, 124,160,48,10 - CONTROL "Disable autoload",IDC_WELCOME_NOAUTOLOAD,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,72,192,87,10 - CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,72,202,87,10 - DEFPUSHBUTTON "Play QZDoom",IDOK,8,246-18,90,14 - PUSHBUTTON "Exit",IDCANCEL,224-58,246-18,50,14 + ICON IDI_ICON1,IDC_STATIC,7,7,21,20 + LTEXT "Welcome to QZDoom!",IDC_STATIC,42,8,180,8 + LTEXT "",IDC_WELCOME_VERSION,42,18,180,8 + GROUPBOX "IWAD selection",IDC_STATIC,8,32,208,102 + LTEXT "Select which game file (IWAD) to run.",IDC_STATIC,12,44,190,8 + LISTBOX IDC_IWADLIST,12,56,200,72,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Video settings",IDC_STATIC,8,138,208,48 + LTEXT "Choose how QZDoom will render the game.",IDC_STATIC,12,148,190,8 + CONTROL "Hardware (OpenGL)",IDC_WELCOME_OPENGL,"Button",BS_AUTORADIOBUTTON,12,170,93,10 + CONTROL "Software (Doom)",IDC_WELCOME_SOFTWARE,"Button",BS_AUTORADIOBUTTON,12,160,93,10 + CONTROL "Fullscreen",IDC_WELCOME_FULLSCREEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,124,160,48,10 + CONTROL "Disable autoload",IDC_WELCOME_NOAUTOLOAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,39,65,10 + CONTROL "Lights.pk3",IDC_WELCOME_LIGHTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,46,192,51,10 + CONTROL "Brightmaps.pk3",IDC_WELCOME_BRIGHTMAPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,111,192,65,10 + CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,73,211,87,10 + DEFPUSHBUTTON "Play QZDoom",IDOK,8,228,90,14 + PUSHBUTTON "Exit",IDCANCEL,166,228,50,14 END IDD_EAXPROPERTYLIST DIALOGEX 0, 0, 265, 404 From 62716c3d917dafd587568da4c507f04864b7b7c5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 21 Dec 2016 18:38:01 +0100 Subject: [PATCH 1449/1509] Fix drawing dormant lights --- src/r_walldraw.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/r_walldraw.cpp b/src/r_walldraw.cpp index ad82f54dc..8645477a3 100644 --- a/src/r_walldraw.cpp +++ b/src/r_walldraw.cpp @@ -561,24 +561,27 @@ static void Draw1Column(int x, int y1, int y2, WallSampler &sampler, void(*draw1 FLightNode *cur_node = dc_light_list; while (cur_node && nextlightindex < 64 * 1024) { - uint32_t red = cur_node->lightsource->GetRed(); - uint32_t green = cur_node->lightsource->GetGreen(); - uint32_t blue = cur_node->lightsource->GetBlue(); + if (!(cur_node->lightsource->flags2&MF2_DORMANT)) + { + uint32_t red = cur_node->lightsource->GetRed(); + uint32_t green = cur_node->lightsource->GetGreen(); + uint32_t blue = cur_node->lightsource->GetBlue(); - double lightX = cur_node->lightsource->X() - ViewPos.X; - double lightY = cur_node->lightsource->Y() - ViewPos.Y; - double lightZ = cur_node->lightsource->Z() - ViewPos.Z; + double lightX = cur_node->lightsource->X() - ViewPos.X; + double lightY = cur_node->lightsource->Y() - ViewPos.Y; + double lightZ = cur_node->lightsource->Z() - ViewPos.Z; - nextlightindex++; - auto &light = dc_lights[dc_num_lights++]; - light.x = (float)(lightX * ViewSin - lightY * ViewCos) - dc_viewpos.X; - light.y = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; - light.z = (float)lightZ; - light.radius = 256.0f / cur_node->lightsource->GetRadius(); - light.color = 0xff000000 | (red << 16) | (green << 8) | blue; + nextlightindex++; + auto &light = dc_lights[dc_num_lights++]; + light.x = (float)(lightX * ViewSin - lightY * ViewCos) - dc_viewpos.X; + light.y = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; + light.z = (float)lightZ; + light.radius = 256.0f / cur_node->lightsource->GetRadius(); + light.color = 0xff000000 | (red << 16) | (green << 8) | blue; - // Precalculate the constant part of the dot here so the drawer doesn't have to. - light.x = light.x * light.x + light.y * light.y; + // Precalculate the constant part of the dot here so the drawer doesn't have to. + light.x = light.x * light.x + light.y * light.y; + } cur_node = cur_node->nextLight; } From 6fe124d9372844871300c9dbddac82c4bfe56e3d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 21 Dec 2016 18:48:26 +0100 Subject: [PATCH 1450/1509] Fixed TriLight struct declaration bug --- tools/drawergen/llvmdrawers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/drawergen/llvmdrawers.cpp b/tools/drawergen/llvmdrawers.cpp index 706cfb79f..f8c5da875 100644 --- a/tools/drawergen/llvmdrawers.cpp +++ b/tools/drawergen/llvmdrawers.cpp @@ -338,7 +338,7 @@ llvm::Type *LLVMDrawers::GetTriLightStruct(llvm::LLVMContext &context) std::vector elements; elements.push_back(llvm::Type::getInt32Ty(context)); - for (int i = 0; i < 4 + TriVertex::NumVarying; i++) + for (int i = 0; i < 4; i++) elements.push_back(llvm::Type::getFloatTy(context)); TriLightStruct = llvm::StructType::create(context, elements, "TriLight", false)->getPointerTo(); return TriLightStruct; From 4551052174bbfcf9aca5690eee7ed93547d31057 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 22 Dec 2016 03:02:58 +0100 Subject: [PATCH 1451/1509] Fix dynamic light calculations to be unaffected by wall clipping --- src/r_walldraw.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/r_walldraw.cpp b/src/r_walldraw.cpp index 8645477a3..ad73c1fa5 100644 --- a/src/r_walldraw.cpp +++ b/src/r_walldraw.cpp @@ -545,10 +545,8 @@ static void Draw1Column(int x, int y1, int y2, WallSampler &sampler, void(*draw1 float t = (x - WallC.sx1 + 0.5f) / (WallC.sx2 - WallC.sx1); float wcol = w1 * (1.0f - t) + w2 * t; float zcol = 1.0f / wcol; - float xcol = (WallC.tleft.X * w1 * (1.0f - t) + WallC.tright.X * w2 * t) * zcol; - float ycol = (WallC.tleft.Y * w1 * (1.0f - t) + WallC.tright.Y * w2 * t) * zcol; - dc_viewpos.X = xcol; - dc_viewpos.Y = ycol; + dc_viewpos.X = (float)((x + 0.5 - CenterX) / CenterX * zcol); + dc_viewpos.Y = zcol; dc_viewpos.Z = (float)((CenterY - y1 - 0.5) / InvZtoScale * zcol); dc_viewpos_step.Z = (float)(-zcol / InvZtoScale); From 5cfe0cc955f0d251b1c0abbdb436761f00180daf Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 22 Dec 2016 05:20:53 +0100 Subject: [PATCH 1452/1509] Remove some whitespace --- src/r_3dfloors.cpp | 2 +- src/r_bsp.cpp | 2 +- src/r_bsp.h | 2 +- src/r_draw_rgba.cpp | 2 +- src/r_draw_rgba.h | 2 +- src/r_drawt_rgba.cpp | 2 +- src/r_main.cpp | 2 +- src/r_main.h | 2 +- src/r_plane.cpp | 2 +- src/r_plane.h | 2 +- src/r_segs.h | 2 +- src/r_swrenderer.cpp | 2 +- src/r_things.h | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/r_3dfloors.cpp b/src/r_3dfloors.cpp index 4289b7843..87c8af618 100644 --- a/src/r_3dfloors.cpp +++ b/src/r_3dfloors.cpp @@ -17,7 +17,7 @@ CVAR(Int, r_3dfloors, true, 0); -namespace swrenderer +namespace swrenderer { // external variables diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 9918e62a9..fef7271e1 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -55,7 +55,7 @@ CVAR (Bool, r_drawflat, false, 0) // [RH] Don't texture segs? EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); -namespace swrenderer +namespace swrenderer { using namespace drawerargs; diff --git a/src/r_bsp.h b/src/r_bsp.h index e4b518e75..e4d70c4cf 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -29,7 +29,7 @@ EXTERN_CVAR (Bool, r_drawflat) // [RH] Don't texture segs? -namespace swrenderer +namespace swrenderer { // The 3072 below is just an arbitrary value picked to avoid diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 2928ac73e..9f8a0c312 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -58,7 +58,7 @@ CVAR(Bool, r_mipmap, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); // Level of detail texture bias CVAR(Float, r_lod_bias, -1.5, 0); // To do: add CVAR_ARCHIVE | CVAR_GLOBALCONFIG when a good default has been decided -namespace swrenderer +namespace swrenderer { extern "C" short spanend[MAXHEIGHT]; extern float rw_light; diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 079074068..afb3bc22d 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -36,7 +36,7 @@ struct FSpecialColormap; EXTERN_CVAR(Bool, r_mipmap) EXTERN_CVAR(Float, r_lod_bias) -namespace swrenderer +namespace swrenderer { // Give the compiler a strong hint we want these functions inlined: #ifndef FORCEINLINE diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index d5aeed8a9..5d3064e5d 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -31,7 +31,7 @@ #include "r_draw_rgba.h" #include "r_drawers.h" -namespace swrenderer +namespace swrenderer { WorkerThreadData DrawColumnRt1LLVMCommand::ThreadData(DrawerThread *thread) { diff --git a/src/r_main.cpp b/src/r_main.cpp index 5242f369f..17b8e682f 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -87,7 +87,7 @@ extern cycle_t FrameCycles; extern bool r_showviewer; -namespace swrenderer +namespace swrenderer { // MACROS ------------------------------------------------------------------ diff --git a/src/r_main.h b/src/r_main.h index c73b59d91..37ead76ce 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -35,7 +35,7 @@ extern int viewwindowy; typedef BYTE lighttable_t; // This could be wider for >8 bit display. -namespace swrenderer +namespace swrenderer { // diff --git a/src/r_plane.cpp b/src/r_plane.cpp index d897ff676..ef9a73540 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -70,7 +70,7 @@ CVAR(Bool, r_skyboxes, true, 0) EXTERN_CVAR(Int, r_skymode) -namespace swrenderer +namespace swrenderer { using namespace drawerargs; diff --git a/src/r_plane.h b/src/r_plane.h index 3a067b527..0e133a7cd 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -27,7 +27,7 @@ class ASkyViewpoint; -namespace swrenderer +namespace swrenderer { // diff --git a/src/r_segs.h b/src/r_segs.h index 6dc08d52c..8f552daee 100644 --- a/src/r_segs.h +++ b/src/r_segs.h @@ -23,7 +23,7 @@ #ifndef __R_SEGS_H__ #define __R_SEGS_H__ -namespace swrenderer +namespace swrenderer { struct drawseg_t; diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 5d94e0442..77cbb28eb 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -67,7 +67,7 @@ CUSTOM_CVAR(Bool, r_polyrenderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOI } } -namespace swrenderer +namespace swrenderer { void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio); diff --git a/src/r_things.h b/src/r_things.h index f777488a5..c1ba2bc40 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -28,7 +28,7 @@ struct particle_t; struct FVoxel; -namespace swrenderer +namespace swrenderer { // A vissprite_t is a thing From fcbacf8cacefa5f4f5464bb295abbeda521abdd6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 22 Dec 2016 07:06:18 +0100 Subject: [PATCH 1453/1509] Plane dynlight setup --- src/r_bsp.cpp | 12 +++++++ src/r_draw.cpp | 1 + src/r_draw.h | 2 ++ src/r_plane.cpp | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ src/r_plane.h | 11 ++++++ 5 files changed, 120 insertions(+) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index fef7271e1..d8a6c2c01 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -1129,6 +1129,9 @@ void R_Subsector (subsector_t *sub) portal ) : NULL; + if (ceilingplane) + R_AddPlaneLights(ceilingplane, frontsector->lighthead); + if (fixedlightlev < 0 && frontsector->e && frontsector->e->XFloor.lightlist.Size()) { light = P_GetPlaneLight(frontsector, &frontsector->floorplane, false); @@ -1166,6 +1169,9 @@ void R_Subsector (subsector_t *sub) portal ) : NULL; + if (floorplane) + R_AddPlaneLights(floorplane, frontsector->lighthead); + // kg3D - fake planes rendering if (r_3dfloors && frontsector->e && frontsector->e->XFloor.ffloors.Size()) { @@ -1223,6 +1229,9 @@ void R_Subsector (subsector_t *sub) frontsector->sky, NULL); + if (floorplane) + R_AddPlaneLights(floorplane, frontsector->lighthead); + R_FakeDrawLoop(sub); fake3D = 0; frontsector = sub->sector; @@ -1284,6 +1293,9 @@ void R_Subsector (subsector_t *sub) frontsector->sky, NULL); + if (ceilingplane) + R_AddPlaneLights(ceilingplane, frontsector->lighthead); + R_FakeDrawLoop(sub); fake3D = 0; frontsector = sub->sector; diff --git a/src/r_draw.cpp b/src/r_draw.cpp index f476e9538..2968ed374 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -63,6 +63,7 @@ namespace swrenderer double dc_texturemid; FLightNode *dc_light_list; + visplane_light *ds_light_list; int ylookup[MAXHEIGHT]; uint8_t shadetables[NUMCOLORMAPS * 16 * 256]; diff --git a/src/r_draw.h b/src/r_draw.h index a337b4943..8b5789b55 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -20,6 +20,7 @@ EXTERN_CVAR(Int, r_columnmethod); namespace swrenderer { struct vissprite_t; + struct visplane_light; struct ShadeConstants { @@ -37,6 +38,7 @@ namespace swrenderer extern double dc_texturemid; extern FLightNode *dc_light_list; + extern visplane_light *ds_light_list; namespace drawerargs { diff --git a/src/r_plane.cpp b/src/r_plane.cpp index ef9a73540..bb42cadef 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -59,6 +59,7 @@ #include "v_palette.h" #include "r_data/colormaps.h" #include "r_draw_rgba.h" +#include "gl/dynlights/gl_dynlight.h" #ifdef _MSC_VER #pragma warning(disable:4244) @@ -255,6 +256,50 @@ void R_MapPlane (int y, int x1) R_SetDSColorMapLight(basecolormap, GlobVis * fabs(CenterY - y), planeshade); } + if (r_swtruecolor) + { + // Find row position in view space + float zspan = (float)((CenterY - y - 0.5) * InvZtoScale / planeheight); + dc_viewpos.X = (float)((x1 + 0.5 - CenterX) / CenterX * zspan); + dc_viewpos.Y = zspan; + dc_viewpos.Z = (float)planeheight; + dc_viewpos_step.X = (float)(-zspan / InvZtoScale); + + static TriLight lightbuffer[64 * 1024]; + static int nextlightindex = 0; + + // Setup lights for column + dc_num_lights = 0; + dc_lights = lightbuffer + nextlightindex; + visplane_light *cur_node = ds_light_list; + while (cur_node && nextlightindex < 64 * 1024) + { + uint32_t red = cur_node->lightsource->GetRed(); + uint32_t green = cur_node->lightsource->GetGreen(); + uint32_t blue = cur_node->lightsource->GetBlue(); + + double lightX = cur_node->lightsource->X() - ViewPos.X; + double lightY = cur_node->lightsource->Y() - ViewPos.Y; + double lightZ = cur_node->lightsource->Z() - ViewPos.Z; + + nextlightindex++; + auto &light = dc_lights[dc_num_lights++]; + light.x = (float)(lightX * ViewSin - lightY * ViewCos); + light.y = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; + light.z = (float)(lightZ - dc_viewpos.Z); + light.radius = 256.0f / cur_node->lightsource->GetRadius(); + light.color = 0xff000000 | (red << 16) | (green << 8) | blue; + + // Precalculate the constant part of the dot here so the drawer doesn't have to. + light.y = light.y * light.y + light.z * light.z; + + cur_node = cur_node->next; + } + + if (nextlightindex == 64 * 1024) + nextlightindex = 0; + } + ds_y = y; ds_x1 = x1; ds_x2 = x2; @@ -284,6 +329,47 @@ void R_MapColoredPlane(int y, int x1) R_DrawColoredSpan(y, x1, spanend[y]); } +//========================================================================== + +namespace +{ + enum { max_plane_lights = 32 * 1024 }; + visplane_light plane_lights[max_plane_lights]; + int next_plane_light = 0; +} + +void R_AddPlaneLights(visplane_t *plane, FLightNode *node) +{ + while (node) + { + if (!(node->lightsource->flags2&MF2_DORMANT)) + { + bool found = false; + visplane_light *light_node = plane->lights; + while (light_node) + { + if (light_node->lightsource == node->lightsource) + { + found = true; + break; + } + light_node = light_node->next; + } + if (!found) + { + if (next_plane_light == max_plane_lights) + return; + + visplane_light *newlight = &plane_lights[next_plane_light++]; + newlight->next = plane->lights; + newlight->lightsource = node->lightsource; + plane->lights = newlight; + } + } + node = node->nextLight; + } +} + //========================================================================== // // R_ClearPlanes @@ -336,6 +422,8 @@ void R_ClearPlanes (bool fullclear) ? (ConBottom - viewwindowy) : 0); lastopening = 0; + + next_plane_light = 0; } } @@ -363,6 +451,8 @@ static visplane_t *new_visplane (unsigned hash) freehead = &freetail; } + check->lights = nullptr; + check->next = visplanes[hash]; visplanes[hash] = check; return check; @@ -1815,6 +1905,8 @@ void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1)) int t2 = pl->top[x]; int b2 = pl->bottom[x]; + ds_light_list = pl->lights; + if (b2 > t2) { fillshort (spanend+t2, b2-t2, x); @@ -1861,6 +1953,8 @@ void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1)) { mapfunc (--b2, pl->left); } + + ds_light_list = nullptr; } //========================================================================== diff --git a/src/r_plane.h b/src/r_plane.h index 0e133a7cd..740020209 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -26,10 +26,18 @@ #include class ASkyViewpoint; +class ADynamicLight; +struct FLightNode; namespace swrenderer { +struct visplane_light +{ + ADynamicLight *lightsource; + visplane_light *next; +}; + // // The infamous visplane // @@ -39,6 +47,7 @@ struct visplane_s FDynamicColormap *colormap; // [RH] Support multiple colormaps FSectorPortal *portal; // [RH] Support sky boxes + visplane_light *lights; FTransform xform; secplane_t height; @@ -89,6 +98,8 @@ void R_InitPlanes (); void R_DeinitPlanes (); void R_ClearPlanes (bool fullclear); +void R_AddPlaneLights(visplane_t *plane, FLightNode *light_head); + int R_DrawPlanes (); void R_DrawPortals (); void R_DrawSkyPlane (visplane_t *pl); From 4f7c1dfdf51e8ca0af6bb8590f688f9b759042e8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 22 Dec 2016 08:42:21 +0100 Subject: [PATCH 1454/1509] Dynamic lights on flats --- src/r_draw_rgba.cpp | 5 +++ src/r_drawers.h | 4 ++ src/r_plane.cpp | 10 ++--- src/r_walldraw.cpp | 2 +- .../fixedfunction/drawspancodegen.cpp | 44 ++++++++++++++++++- .../drawergen/fixedfunction/drawspancodegen.h | 9 +++- tools/drawergen/llvmdrawers.cpp | 4 ++ 7 files changed, 69 insertions(+), 9 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 9f8a0c312..a9fc5c80e 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -100,6 +100,11 @@ namespace swrenderer args.flags |= DrawSpanArgs::simple_shade; if (!sampler_setup(args.source, args.xbits, args.ybits, ds_source_mipmapped)) args.flags |= DrawSpanArgs::nearest_filter; + + args.viewpos_x = dc_viewpos.X; + args.step_viewpos_x = dc_viewpos_step.X; + args.dynlights = dc_lights; + args.num_dynlights = dc_num_lights; } void DrawSpanLLVMCommand::Execute(DrawerThread *thread) diff --git a/src/r_drawers.h b/src/r_drawers.h index eff6ea370..2ff2fd087 100644 --- a/src/r_drawers.h +++ b/src/r_drawers.h @@ -139,6 +139,10 @@ struct DrawSpanArgs nearest_filter = 2 }; + float viewpos_x, step_viewpos_x; + TriLight *dynlights; + uint32_t num_dynlights; + FString ToString(); }; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index bb42cadef..48a5bcb0f 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -259,11 +259,11 @@ void R_MapPlane (int y, int x1) if (r_swtruecolor) { // Find row position in view space - float zspan = (float)((CenterY - y - 0.5) * InvZtoScale / planeheight); + float zspan = planeheight / (fabs(y + 0.5 - CenterY) / InvZtoScale); dc_viewpos.X = (float)((x1 + 0.5 - CenterX) / CenterX * zspan); dc_viewpos.Y = zspan; - dc_viewpos.Z = (float)planeheight; - dc_viewpos_step.X = (float)(-zspan / InvZtoScale); + dc_viewpos.Z = (float)((CenterY - y - 0.5) / InvZtoScale * zspan); + dc_viewpos_step.X = (float)(zspan / CenterX); static TriLight lightbuffer[64 * 1024]; static int nextlightindex = 0; @@ -286,9 +286,9 @@ void R_MapPlane (int y, int x1) auto &light = dc_lights[dc_num_lights++]; light.x = (float)(lightX * ViewSin - lightY * ViewCos); light.y = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; - light.z = (float)(lightZ - dc_viewpos.Z); + light.z = (float)lightZ - dc_viewpos.Z; light.radius = 256.0f / cur_node->lightsource->GetRadius(); - light.color = 0xff000000 | (red << 16) | (green << 8) | blue; + light.color = (red << 16) | (green << 8) | blue; // Precalculate the constant part of the dot here so the drawer doesn't have to. light.y = light.y * light.y + light.z * light.z; diff --git a/src/r_walldraw.cpp b/src/r_walldraw.cpp index ad73c1fa5..f43b8f9d4 100644 --- a/src/r_walldraw.cpp +++ b/src/r_walldraw.cpp @@ -575,7 +575,7 @@ static void Draw1Column(int x, int y1, int y2, WallSampler &sampler, void(*draw1 light.y = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; light.z = (float)lightZ; light.radius = 256.0f / cur_node->lightsource->GetRadius(); - light.color = 0xff000000 | (red << 16) | (green << 8) | blue; + light.color = (red << 16) | (green << 8) | blue; // Precalculate the constant part of the dot here so the drawer doesn't have to. light.x = light.x * light.x + light.y * light.y; diff --git a/tools/drawergen/fixedfunction/drawspancodegen.cpp b/tools/drawergen/fixedfunction/drawspancodegen.cpp index c6aacc75a..ce6ce9bad 100644 --- a/tools/drawergen/fixedfunction/drawspancodegen.cpp +++ b/tools/drawergen/fixedfunction/drawspancodegen.cpp @@ -59,6 +59,10 @@ void DrawSpanCodegen::Generate(DrawSpanVariant variant, SSAValue args) SSAShort fade_blue = args[0][22].load(true); SSAShort desaturate = args[0][23].load(true); SSAInt flags = args[0][24].load(true); + start_viewpos_x = args[0][25].load(true); + step_viewpos_x = args[0][26].load(true); + dynlights = args[0][27].load(true); + num_dynlights = args[0][28].load(true); shade_constants.light = SSAVec4i(light_blue.zext_int(), light_green.zext_int(), light_red.zext_int(), light_alpha.zext_int()); shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); shade_constants.desaturate = desaturate.zext_int(); @@ -115,6 +119,7 @@ SSAInt DrawSpanCodegen::Loop4x(DrawSpanVariant variant, bool isSimpleShade, bool { SSAInt sseLength = count / 4; stack_index.store(SSAInt(0)); + stack_viewpos_x.store(start_viewpos_x); { SSAForBlock loop; SSAInt index = stack_index.load(); @@ -136,9 +141,11 @@ SSAInt DrawSpanCodegen::Loop4x(DrawSpanVariant variant, bool isSimpleShade, bool { SSAInt xfrac = stack_xfrac.load(); SSAInt yfrac = stack_yfrac.load(); + viewpos_x = stack_viewpos_x.load(); colors[i] = Blend(Shade(Sample(xfrac, yfrac, isNearestFilter, is64x64), isSimpleShade), bgcolors[i], variant); + stack_viewpos_x.store(viewpos_x + step_viewpos_x); stack_xfrac.store(xfrac + xstep); stack_yfrac.store(yfrac + ystep); } @@ -158,6 +165,7 @@ void DrawSpanCodegen::Loop(SSAInt start, DrawSpanVariant variant, bool isSimpleS { SSAForBlock loop; SSAInt index = stack_index.load(); + viewpos_x = stack_viewpos_x.load(); loop.loop_block(index < count); SSAInt xfrac = stack_xfrac.load(); @@ -167,6 +175,7 @@ void DrawSpanCodegen::Loop(SSAInt start, DrawSpanVariant variant, bool isSimpleS SSAVec4i color = Blend(Shade(Sample(xfrac, yfrac, isNearestFilter, is64x64), isSimpleShade), bgcolor, variant); data[index * 4].store_vec4ub(color); + stack_viewpos_x.store(viewpos_x + step_viewpos_x); stack_index.store(index.add(SSAInt(1), true, true)); stack_xfrac.store(xfrac + xstep); stack_yfrac.store(yfrac + ystep); @@ -222,10 +231,41 @@ SSAVec4i DrawSpanCodegen::SampleLinear(SSAUBytePtr texture, SSAInt xfrac, SSAInt SSAVec4i DrawSpanCodegen::Shade(SSAVec4i fg, bool isSimpleShade) { + SSAVec4i c; if (isSimpleShade) - return shade_bgra_simple(fg, light); + c = shade_bgra_simple(fg, light); else - return shade_bgra_advanced(fg, light, shade_constants); + c = shade_bgra_advanced(fg, light, shade_constants); + + stack_lit_color.store(c); + stack_light_index.store(SSAInt(0)); + + SSAForBlock block; + SSAInt light_index = stack_light_index.load(); + SSAVec4i lit_color = stack_lit_color.load(); + block.loop_block(light_index < num_dynlights); + { + SSAVec4i light_color = SSAUBytePtr(dynlights[light_index][0].v).load_vec4ub(true); + SSAFloat light_x = dynlights[light_index][1].load(true); + SSAFloat light_y = dynlights[light_index][2].load(true); + //SSAFloat light_z = dynlights[light_index][3].load(true); + SSAFloat light_rcp_radius = dynlights[light_index][4].load(true); + + // L = light-pos + // dist = sqrt(dot(L, L)) + // attenuation = 1 - MIN(dist * (1/radius), 1) + SSAFloat Lyz2 = light_y; // L.y*L.y + L.z*L.z + SSAFloat Lx = light_x - viewpos_x; + SSAFloat dist = SSAFloat::sqrt(Lyz2 + Lx * Lx); + SSAInt attenuation = SSAInt(SSAFloat(256.0f) - SSAFloat::MIN(dist * light_rcp_radius, SSAFloat(256.0f)), true); + SSAVec4i contribution = (light_color * fg * attenuation) >> 16; + + stack_lit_color.store(lit_color + contribution); + stack_light_index.store(light_index + 1); + } + block.end_block(); + + return stack_lit_color.load(); } SSAVec4i DrawSpanCodegen::Blend(SSAVec4i fg, SSAVec4i bg, DrawSpanVariant variant) diff --git a/tools/drawergen/fixedfunction/drawspancodegen.h b/tools/drawergen/fixedfunction/drawspancodegen.h index 48c86040b..9e0c67c41 100644 --- a/tools/drawergen/fixedfunction/drawspancodegen.h +++ b/tools/drawergen/fixedfunction/drawspancodegen.h @@ -49,7 +49,9 @@ private: SSAVec4i Shade(SSAVec4i fg, bool isSimpleShade); SSAVec4i Blend(SSAVec4i fg, SSAVec4i bg, DrawSpanVariant variant); - SSAStack stack_index, stack_xfrac, stack_yfrac; + SSAStack stack_index, stack_xfrac, stack_yfrac, stack_light_index; + SSAStack stack_lit_color; + SSAStack stack_viewpos_x; SSAUBytePtr destorg; SSAUBytePtr source; @@ -73,4 +75,9 @@ private: SSABool is_simple_shade; SSABool is_nearest_filter; SSAShadeConstants shade_constants; + + SSAFloat start_viewpos_x, step_viewpos_x; + SSAValue dynlights; // TriLight* + SSAInt num_dynlights; + SSAFloat viewpos_x; }; diff --git a/tools/drawergen/llvmdrawers.cpp b/tools/drawergen/llvmdrawers.cpp index f8c5da875..5c3bf05a4 100644 --- a/tools/drawergen/llvmdrawers.cpp +++ b/tools/drawergen/llvmdrawers.cpp @@ -265,6 +265,10 @@ llvm::Type *LLVMDrawers::GetDrawSpanArgsStruct(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; + elements.push_back(llvm::Type::getFloatTy(context)); // float viewpos_x; + elements.push_back(llvm::Type::getFloatTy(context)); // float step_viewpos_x; + elements.push_back(GetTriLightStruct(context)); // TriLight *dynlights; + elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t num_dynlights; DrawSpanArgsStruct = llvm::StructType::create(context, elements, "DrawSpanArgs", false)->getPointerTo(); return DrawSpanArgsStruct; } From 62724c21612f3e4cff271d6cbf2ec0eec81277d0 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 22 Dec 2016 08:50:52 +0100 Subject: [PATCH 1455/1509] Fix light color indexing bug --- tools/drawergen/fixedfunction/drawspancodegen.cpp | 2 +- tools/drawergen/fixedfunction/drawwallcodegen.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/drawergen/fixedfunction/drawspancodegen.cpp b/tools/drawergen/fixedfunction/drawspancodegen.cpp index ce6ce9bad..c35198ba8 100644 --- a/tools/drawergen/fixedfunction/drawspancodegen.cpp +++ b/tools/drawergen/fixedfunction/drawspancodegen.cpp @@ -245,7 +245,7 @@ SSAVec4i DrawSpanCodegen::Shade(SSAVec4i fg, bool isSimpleShade) SSAVec4i lit_color = stack_lit_color.load(); block.loop_block(light_index < num_dynlights); { - SSAVec4i light_color = SSAUBytePtr(dynlights[light_index][0].v).load_vec4ub(true); + SSAVec4i light_color = SSAUBytePtr(SSAValue(dynlights[light_index][0]).v).load_vec4ub(true); SSAFloat light_x = dynlights[light_index][1].load(true); SSAFloat light_y = dynlights[light_index][2].load(true); //SSAFloat light_z = dynlights[light_index][3].load(true); diff --git a/tools/drawergen/fixedfunction/drawwallcodegen.cpp b/tools/drawergen/fixedfunction/drawwallcodegen.cpp index 6f546b9b3..5e7f9000d 100644 --- a/tools/drawergen/fixedfunction/drawwallcodegen.cpp +++ b/tools/drawergen/fixedfunction/drawwallcodegen.cpp @@ -233,7 +233,7 @@ SSAVec4i DrawWallCodegen::Shade(SSAVec4i fg, int index, bool isSimpleShade) SSAVec4i lit_color = stack_lit_color.load(); block.loop_block(light_index < num_dynlights); { - SSAVec4i light_color = SSAUBytePtr(dynlights[light_index][0].v).load_vec4ub(true); + SSAVec4i light_color = SSAUBytePtr(SSAValue(dynlights[light_index][0]).v).load_vec4ub(true); SSAFloat light_x = dynlights[light_index][1].load(true); //SSAFloat light_y = dynlights[light_index][2].load(true); SSAFloat light_z = dynlights[light_index][3].load(true); From ea1aeb3cdc37df0666e727353f21ec5a5e49672d Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 22 Dec 2016 03:21:56 -0500 Subject: [PATCH 1456/1509] - reversed sub and revsub in LLVM drawers --- src/r_poly_sprite.cpp | 2 +- tools/drawergen/fixedfunction/drawercodegen.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_poly_sprite.cpp b/src/r_poly_sprite.cpp index 2cb285298..182135753 100644 --- a/src/r_poly_sprite.cpp +++ b/src/r_poly_sprite.cpp @@ -185,7 +185,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla { args.uniforms.destalpha = (uint32_t)(1.0 * 256); args.uniforms.srcalpha = (uint32_t)(thing->Alpha * 256); - blendmode = args.translation ? TriBlendMode::TranslateSub : TriBlendMode::Sub; + blendmode = args.translation ? TriBlendMode::TranslateRevSub : TriBlendMode::RevSub; } else if (thing->RenderStyle == LegacyRenderStyles[STYLE_SoulTrans]) { diff --git a/tools/drawergen/fixedfunction/drawercodegen.cpp b/tools/drawergen/fixedfunction/drawercodegen.cpp index ccff40ac0..f7a67e5a6 100644 --- a/tools/drawergen/fixedfunction/drawercodegen.cpp +++ b/tools/drawergen/fixedfunction/drawercodegen.cpp @@ -119,7 +119,7 @@ SSAVec4i DrawerCodegen::blend_sub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSA SSAInt alpha = fg[3]; alpha = alpha + (alpha >> 7); // 255 -> 256 srcalpha = (alpha * srcalpha + 128) >> 8; - SSAVec4i color = (bg * destalpha - fg * srcalpha) / 256; + SSAVec4i color = (fg * srcalpha - bg * destalpha) / 256; return color.insert(3, 255); } @@ -128,7 +128,7 @@ SSAVec4i DrawerCodegen::blend_revsub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt alpha = fg[3]; alpha = alpha + (alpha >> 7); // 255 -> 256 srcalpha = (alpha * srcalpha + 128) >> 8; - SSAVec4i color = (fg * srcalpha - bg * destalpha) / 256; + SSAVec4i color = (bg * destalpha - fg * srcalpha) / 256; return color.insert(3, 255); } From 36f87b7135afa27dde8e74b457bf03585402c38f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Dec 2016 11:14:13 +0100 Subject: [PATCH 1457/1509] - removed gl_light_ambient. This really serves no use anymore and is mostly a remnant of old times with dark CRT monitors. The default ambient level was set at 20, meaning a sector light level of 40. This is a value actual levels rarely get to, except when using some lighting effects - but it's for those that the ambient clamping did the most damage. --- src/gl/renderer/gl_lightdata.cpp | 11 ----------- wadsrc/static/menudef.zz | 1 - 2 files changed, 12 deletions(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 0dd180dfb..25ad12344 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -46,12 +46,6 @@ int fogdensity; int outsidefogdensity; int skyfog; -CUSTOM_CVAR (Int, gl_light_ambient, 20, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -{ - // ambient of 0 does not work correctly because light level 0 is special. - if (self < 1) self = 1; -} - CVAR(Int, gl_weaponlight, 8, CVAR_ARCHIVE); CUSTOM_CVAR(Bool, gl_enhanced_nightvision, true, CVAR_ARCHIVE|CVAR_NOINITCALL) { @@ -209,11 +203,6 @@ int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon) light=lightlevel; } - if (light>=1; - } return clamp(light+rellight, 0, 255); } diff --git a/wadsrc/static/menudef.zz b/wadsrc/static/menudef.zz index 253f984eb..1261286d6 100644 --- a/wadsrc/static/menudef.zz +++ b/wadsrc/static/menudef.zz @@ -231,7 +231,6 @@ OptionMenu "GLPrefOptions" Option "$GLPREFMNU_SPRBILLBOARD", gl_billboard_mode, "BillboardModes" Option "$GLPREFMNU_SPRBILLFACECAMERA", gl_billboard_faces_camera, "OnOff" Option "$GLPREFMNU_PARTICLESTYLE", gl_particles_style, "Particles" - Slider "$GLPREFMNU_AMBLIGHT", gl_light_ambient, 1.0, 255.0, 5.0 Option "$GLPREFMNU_RENDERQUALITY", gl_render_precise, "Precision" Option "$GLPREFMNU_VRMODE", vr_mode, "VRMode" Option "$GLPREFMNU_VRQUADSTEREO", vr_enable_quadbuffered, "OnOff" From 8a9ea2eda8eeb8e75727cf8fb5f3405545ddc33c Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 20 Dec 2016 13:31:38 -0500 Subject: [PATCH 1458/1509] - Mostly implemented Zandronum's IWAD selection box. Currently, this change only affects Windows. (cherry picked from commit b3bed807de48069c0454c211ab7f2729d6d41421) --- src/win32/i_system.cpp | 18 ++++++++++++++++++ src/win32/resource.h | 7 +++++++ src/win32/zdoom.rc | 31 +++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index acea7a788..ebb3d8c67 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -127,6 +127,9 @@ static void DestroyCustomCursor(); EXTERN_CVAR(String, language); EXTERN_CVAR (Bool, queryiwad); +// Used on welcome/IWAD screen. +EXTERN_CVAR (Int, vid_renderer) +EXTERN_CVAR (Bool, fullscreen) extern HWND Window, ConWindow, GameTitleWindow; extern HANDLE StdOut; @@ -1159,6 +1162,18 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa newlabel.Format(GAMESIG " %s: %s", GetVersionString(), label); SetWindowText(hDlg, newlabel.GetChars()); } + + // [SP] Upstreamed from Zandronum + char szString[256]; + + // Check the current video settings. + SendDlgItemMessage( hDlg, vid_renderer ? IDC_WELCOME_OPENGL : IDC_WELCOME_SOFTWARE, BM_SETCHECK, BST_CHECKED, 0 ); + SendDlgItemMessage( hDlg, IDC_WELCOME_FULLSCREEN, BM_SETCHECK, fullscreen ? BST_CHECKED : BST_UNCHECKED, 0 ); + + // Set up our version string. + sprintf(szString, "Version %s.", GetVersionString()); + SetDlgItemText (hDlg, IDC_WELCOME_VERSION, szString); + // Populate the list with all the IWADs found ctrl = GetDlgItem(hDlg, IDC_IWADLIST); for (i = 0; i < NumWads; i++) @@ -1192,6 +1207,9 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa (LOWORD(wParam) == IDC_IWADLIST && HIWORD(wParam) == LBN_DBLCLK)) { SetQueryIWad(hDlg); + // [SP] Upstreamed from Zandronum + vid_renderer = SendDlgItemMessage( hDlg, IDC_WELCOME_OPENGL, BM_GETCHECK, 0, 0 ) == BST_CHECKED; + fullscreen = SendDlgItemMessage( hDlg, IDC_WELCOME_FULLSCREEN, BM_GETCHECK, 0, 0 ) == BST_CHECKED; ctrl = GetDlgItem (hDlg, IDC_IWADLIST); EndDialog(hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0)); } diff --git a/src/win32/resource.h b/src/win32/resource.h index 6886e83fd..52db9de2e 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -164,3 +164,10 @@ #define _APS_NEXT_SYMED_VALUE 101 #endif #endif + +// [SP] Upstreamed from Zandronum +#define IDC_WELCOME_VERSION 4019 // [RC] "Welcome" screen. +#define IDC_WELCOME_OPENGL 4020 +#define IDC_WELCOME_SOFTWARE 4021 +#define IDC_WELCOME_FULLSCREEN 4022 +#define IDI_ICONST 151 diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index 5e2226c6d..e64f27c4d 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -220,6 +220,7 @@ END // Dialog // +/* IDD_IWADDIALOG DIALOGEX 0, 0, 212, 186 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW @@ -233,6 +234,36 @@ BEGIN LTEXT "ZDoom found more than one IWAD present.",IDC_STATIC,5,5,140,8 LTEXT "Select from the list below to determine which one to use:",IDC_STATIC,5,15,200,8 END +*/ +// [SP] Upstreamed from Zandronum +IDD_IWADDIALOG DIALOGEX 0, 0, 224, 236 +STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | + WS_SYSMENU +EXSTYLE WS_EX_APPWINDOW +CAPTION "Welcome" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + ICON IDI_ICON1,IDC_STATIC,7,7,32,32 + LTEXT "Welcome to QZDoom!",IDC_STATIC,42,8,180,8 + LTEXT "",IDC_WELCOME_VERSION,42,18,180,8 + GROUPBOX "IWAD selection",IDC_STATIC,8,32,224-16,102 + LTEXT "Select which game file (IWAD) to run.", IDC_STATIC,12,32+12,190,8 + LISTBOX IDC_IWADLIST,12,32+24,224-24,72,LBS_NOINTEGRALHEIGHT | + WS_VSCROLL | WS_TABSTOP + GROUPBOX "Video settings",IDC_STATIC,8,138,224-16,48 + LTEXT "Choose how QZDoom will render the game.", IDC_STATIC,12,148,190,8 + CONTROL "Hardware (OpenGL)",IDC_WELCOME_OPENGL,"Button", + BS_AUTORADIOBUTTON,12,170,93,10 + CONTROL "Software (Doom)",IDC_WELCOME_SOFTWARE,"Button", + BS_AUTORADIOBUTTON,12,160,93,10 + CONTROL "Fullscreen",IDC_WELCOME_FULLSCREEN,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP, 124,160,48,10 + CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,72,192,87,10 + DEFPUSHBUTTON "Play QZDoom",IDOK,8,236-18,90,14 + PUSHBUTTON "Exit",IDCANCEL,224-58,236-18,50,14 + +END IDD_EAXPROPERTYLIST DIALOGEX 0, 0, 265, 404 STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VSCROLL From 240f973f0cc3769166fa9f33da6f1ae789526fe9 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 20 Dec 2016 23:03:06 -0500 Subject: [PATCH 1459/1509] - Implemented Gez's suggestion for disable autoload checkbox on the IWAD selection box. (cherry picked from commit 578e3270e20f6b0dc6dba7e1001c95a963acc283) --- src/d_main.cpp | 4 +++- src/win32/i_system.cpp | 6 ++++++ src/win32/resource.h | 3 +++ src/win32/zdoom.rc | 11 ++++++----- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 04ba34cbb..2b8ff7437 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -205,6 +205,8 @@ CUSTOM_CVAR (String, vid_cursor, "None", CVAR_ARCHIVE | CVAR_NOINITCALL) } } +bool disableautoload = false; // [SP] No auto load + bool wantToRestart; bool DrawFSHUD; // [RH] Draw fullscreen HUD? TArray allwads; @@ -2038,7 +2040,7 @@ static void AddAutoloadFiles(const char *autoname) { LumpFilterIWAD.Format("%s.", autoname); // The '.' is appened to simplify parsing the string - if (!(gameinfo.flags & GI_SHAREWARE) && !Args->CheckParm("-noautoload")) + if (!(gameinfo.flags & GI_SHAREWARE) && !Args->CheckParm("-noautoload") && !disableautoload) { FString file; diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index ebb3d8c67..52f054dc2 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -130,6 +130,7 @@ EXTERN_CVAR (Bool, queryiwad); // Used on welcome/IWAD screen. EXTERN_CVAR (Int, vid_renderer) EXTERN_CVAR (Bool, fullscreen) +extern bool disableautoload; extern HWND Window, ConWindow, GameTitleWindow; extern HANDLE StdOut; @@ -1169,6 +1170,7 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa // Check the current video settings. SendDlgItemMessage( hDlg, vid_renderer ? IDC_WELCOME_OPENGL : IDC_WELCOME_SOFTWARE, BM_SETCHECK, BST_CHECKED, 0 ); SendDlgItemMessage( hDlg, IDC_WELCOME_FULLSCREEN, BM_SETCHECK, fullscreen ? BST_CHECKED : BST_UNCHECKED, 0 ); + SendDlgItemMessage( hDlg, IDC_WELCOME_NOAUTOLOAD, BM_SETCHECK, disableautoload ? BST_CHECKED : BST_UNCHECKED, 0 ); // Set up our version string. sprintf(szString, "Version %s.", GetVersionString()); @@ -1210,6 +1212,10 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa // [SP] Upstreamed from Zandronum vid_renderer = SendDlgItemMessage( hDlg, IDC_WELCOME_OPENGL, BM_GETCHECK, 0, 0 ) == BST_CHECKED; fullscreen = SendDlgItemMessage( hDlg, IDC_WELCOME_FULLSCREEN, BM_GETCHECK, 0, 0 ) == BST_CHECKED; + + // [SP] This is our's. + disableautoload = SendDlgItemMessage( hDlg, IDC_WELCOME_NOAUTOLOAD, BM_GETCHECK, 0, 0 ) == BST_CHECKED; + ctrl = GetDlgItem (hDlg, IDC_IWADLIST); EndDialog(hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0)); } diff --git a/src/win32/resource.h b/src/win32/resource.h index 52db9de2e..937a73658 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -171,3 +171,6 @@ #define IDC_WELCOME_SOFTWARE 4021 #define IDC_WELCOME_FULLSCREEN 4022 #define IDI_ICONST 151 + +// [SP] This is our's. +#define IDC_WELCOME_NOAUTOLOAD 4023 diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index e64f27c4d..8b29aef9e 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -236,7 +236,7 @@ BEGIN END */ // [SP] Upstreamed from Zandronum -IDD_IWADDIALOG DIALOGEX 0, 0, 224, 236 +IDD_IWADDIALOG DIALOGEX 0, 0, 224, 246 STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW @@ -258,11 +258,12 @@ BEGIN BS_AUTORADIOBUTTON,12,160,93,10 CONTROL "Fullscreen",IDC_WELCOME_FULLSCREEN,"Button", BS_AUTOCHECKBOX | WS_TABSTOP, 124,160,48,10 - CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button", + CONTROL "Disable autoload",IDC_WELCOME_NOAUTOLOAD,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,72,192,87,10 - DEFPUSHBUTTON "Play QZDoom",IDOK,8,236-18,90,14 - PUSHBUTTON "Exit",IDCANCEL,224-58,236-18,50,14 - + CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,72,202,87,10 + DEFPUSHBUTTON "Play QZDoom",IDOK,8,246-18,90,14 + PUSHBUTTON "Exit",IDCANCEL,224-58,246-18,50,14 END IDD_EAXPROPERTYLIST DIALOGEX 0, 0, 265, 404 From 5fa6094e4f74e62d431179fe6634fe9ca28a3a51 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 20 Dec 2016 23:09:15 -0500 Subject: [PATCH 1460/1509] - Changed QZDoom messages to GZDoom. --- src/win32/zdoom.rc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index 8b29aef9e..123f744a2 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -244,14 +244,14 @@ CAPTION "Welcome" FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN ICON IDI_ICON1,IDC_STATIC,7,7,32,32 - LTEXT "Welcome to QZDoom!",IDC_STATIC,42,8,180,8 + LTEXT "Welcome to GZDoom!",IDC_STATIC,42,8,180,8 LTEXT "",IDC_WELCOME_VERSION,42,18,180,8 GROUPBOX "IWAD selection",IDC_STATIC,8,32,224-16,102 LTEXT "Select which game file (IWAD) to run.", IDC_STATIC,12,32+12,190,8 LISTBOX IDC_IWADLIST,12,32+24,224-24,72,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP GROUPBOX "Video settings",IDC_STATIC,8,138,224-16,48 - LTEXT "Choose how QZDoom will render the game.", IDC_STATIC,12,148,190,8 + LTEXT "Choose how GZDoom will render the game.", IDC_STATIC,12,148,190,8 CONTROL "Hardware (OpenGL)",IDC_WELCOME_OPENGL,"Button", BS_AUTORADIOBUTTON,12,170,93,10 CONTROL "Software (Doom)",IDC_WELCOME_SOFTWARE,"Button", @@ -262,7 +262,7 @@ BEGIN BS_AUTOCHECKBOX | WS_TABSTOP,72,192,87,10 CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,72,202,87,10 - DEFPUSHBUTTON "Play QZDoom",IDOK,8,246-18,90,14 + DEFPUSHBUTTON "Play GZDoom",IDOK,8,246-18,90,14 PUSHBUTTON "Exit",IDCANCEL,224-58,246-18,50,14 END From cb2c1e591a009bb419779e598c6623321643181b Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 21 Dec 2016 02:16:44 -0500 Subject: [PATCH 1461/1509] - Added Zandronum-specific copyright notices for IWAD picker. --- src/win32/i_system.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index 52f054dc2..2dc6c4d3d 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -4,6 +4,8 @@ ** **--------------------------------------------------------------------------- ** Copyright 1998-2009 Randy Heit +** Copyright (C) 2007-2012 Skulltag Development Team +** Copyright (C) 2007-2016 Zandronum Development Team ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -17,6 +19,15 @@ ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. +** 4. Redistributions in any form must be accompanied by information on how to +** obtain complete source code for the software and any accompanying software +** that uses the software. The source code must either be included in the +** distribution or be available for no more than the cost of distribution plus +** a nominal fee, and must be freely redistributable under reasonable +** conditions. For an executable file, complete source code means the source +** code for all modules it contains. It does not include source code for +** modules or files that typically accompany the major components of the +** operating system on which the executable file runs. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES From 38103281939f71adaf28acba1a0a0d7c0c06ff1f Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 21 Dec 2016 05:11:29 -0500 Subject: [PATCH 1462/1509] - More options for the IWAD picker. - Rearranged some options around a bit. - Disable auto load is now an archived cvar. # Conflicts: # src/win32/zdoom.rc --- src/d_main.cpp | 22 ++++++++++++++++++++- src/win32/i_system.cpp | 11 +++++++++-- src/win32/resource.h | 5 +++-- src/win32/zdoom.rc | 45 +++++++++++++++++++----------------------- 4 files changed, 53 insertions(+), 30 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 2b8ff7437..1ea2d2707 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -205,7 +205,10 @@ CUSTOM_CVAR (String, vid_cursor, "None", CVAR_ARCHIVE | CVAR_NOINITCALL) } } -bool disableautoload = false; // [SP] No auto load +// Controlled by startup dialog +CVAR (Bool, disableautoload, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) +CVAR (Bool, autoloadbrightmaps, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) +CVAR (Bool, autoloadlights, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) bool wantToRestart; bool DrawFSHUD; // [RH] Draw fullscreen HUD? @@ -2040,6 +2043,23 @@ static void AddAutoloadFiles(const char *autoname) { LumpFilterIWAD.Format("%s.", autoname); // The '.' is appened to simplify parsing the string + // [SP] Dialog reaction - load lights.pk3 and brightmaps.pk3 based on user choices + if (!(gameinfo.flags & GI_SHAREWARE)) + { + if (autoloadlights) + { + const char *lightswad = BaseFileSearch ("lights.pk3", NULL); + if (lightswad) + D_AddFile (allwads, lightswad); + } + if (autoloadbrightmaps) + { + const char *bmwad = BaseFileSearch ("brightmaps.pk3", NULL); + if (bmwad) + D_AddFile (allwads, bmwad); + } + } + if (!(gameinfo.flags & GI_SHAREWARE) && !Args->CheckParm("-noautoload") && !disableautoload) { FString file; diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index 2dc6c4d3d..f07fb8f1d 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -141,7 +141,9 @@ EXTERN_CVAR (Bool, queryiwad); // Used on welcome/IWAD screen. EXTERN_CVAR (Int, vid_renderer) EXTERN_CVAR (Bool, fullscreen) -extern bool disableautoload; +EXTERN_CVAR (Bool, disableautoload) +EXTERN_CVAR (Bool, autoloadlights) +EXTERN_CVAR (Bool, autoloadbrightmaps) extern HWND Window, ConWindow, GameTitleWindow; extern HANDLE StdOut; @@ -1181,7 +1183,11 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa // Check the current video settings. SendDlgItemMessage( hDlg, vid_renderer ? IDC_WELCOME_OPENGL : IDC_WELCOME_SOFTWARE, BM_SETCHECK, BST_CHECKED, 0 ); SendDlgItemMessage( hDlg, IDC_WELCOME_FULLSCREEN, BM_SETCHECK, fullscreen ? BST_CHECKED : BST_UNCHECKED, 0 ); + + // [SP] This is our's SendDlgItemMessage( hDlg, IDC_WELCOME_NOAUTOLOAD, BM_SETCHECK, disableautoload ? BST_CHECKED : BST_UNCHECKED, 0 ); + SendDlgItemMessage( hDlg, IDC_WELCOME_LIGHTS, BM_SETCHECK, autoloadlights ? BST_CHECKED : BST_UNCHECKED, 0 ); + SendDlgItemMessage( hDlg, IDC_WELCOME_BRIGHTMAPS, BM_SETCHECK, autoloadbrightmaps ? BST_CHECKED : BST_UNCHECKED, 0 ); // Set up our version string. sprintf(szString, "Version %s.", GetVersionString()); @@ -1226,7 +1232,8 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa // [SP] This is our's. disableautoload = SendDlgItemMessage( hDlg, IDC_WELCOME_NOAUTOLOAD, BM_GETCHECK, 0, 0 ) == BST_CHECKED; - + autoloadlights = SendDlgItemMessage( hDlg, IDC_WELCOME_LIGHTS, BM_GETCHECK, 0, 0 ) == BST_CHECKED; + autoloadbrightmaps = SendDlgItemMessage( hDlg, IDC_WELCOME_BRIGHTMAPS, BM_GETCHECK, 0, 0 ) == BST_CHECKED; ctrl = GetDlgItem (hDlg, IDC_IWADLIST); EndDialog(hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0)); } diff --git a/src/win32/resource.h b/src/win32/resource.h index 937a73658..cf41b6f1f 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -158,7 +158,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 150 +#define _APS_NEXT_RESOURCE_VALUE 151 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1084 #define _APS_NEXT_SYMED_VALUE 101 @@ -170,7 +170,8 @@ #define IDC_WELCOME_OPENGL 4020 #define IDC_WELCOME_SOFTWARE 4021 #define IDC_WELCOME_FULLSCREEN 4022 -#define IDI_ICONST 151 // [SP] This is our's. #define IDC_WELCOME_NOAUTOLOAD 4023 +#define IDC_WELCOME_LIGHTS 4024 +#define IDC_WELCOME_BRIGHTMAPS 4025 diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index 123f744a2..5c85a4e21 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -120,9 +120,9 @@ BEGIN IDD_IWADDIALOG, DIALOG BEGIN LEFTMARGIN, 5 - RIGHTMARGIN, 205 + RIGHTMARGIN, 222 TOPMARGIN, 7 - BOTTOMMARGIN, 179 + BOTTOMMARGIN, 242 END IDD_EAXPROPERTYLIST, DIALOG @@ -237,33 +237,28 @@ END */ // [SP] Upstreamed from Zandronum IDD_IWADDIALOG DIALOGEX 0, 0, 224, 246 -STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | - WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW CAPTION "Welcome" FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - ICON IDI_ICON1,IDC_STATIC,7,7,32,32 - LTEXT "Welcome to GZDoom!",IDC_STATIC,42,8,180,8 - LTEXT "",IDC_WELCOME_VERSION,42,18,180,8 - GROUPBOX "IWAD selection",IDC_STATIC,8,32,224-16,102 - LTEXT "Select which game file (IWAD) to run.", IDC_STATIC,12,32+12,190,8 - LISTBOX IDC_IWADLIST,12,32+24,224-24,72,LBS_NOINTEGRALHEIGHT | - WS_VSCROLL | WS_TABSTOP - GROUPBOX "Video settings",IDC_STATIC,8,138,224-16,48 - LTEXT "Choose how GZDoom will render the game.", IDC_STATIC,12,148,190,8 - CONTROL "Hardware (OpenGL)",IDC_WELCOME_OPENGL,"Button", - BS_AUTORADIOBUTTON,12,170,93,10 - CONTROL "Software (Doom)",IDC_WELCOME_SOFTWARE,"Button", - BS_AUTORADIOBUTTON,12,160,93,10 - CONTROL "Fullscreen",IDC_WELCOME_FULLSCREEN,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP, 124,160,48,10 - CONTROL "Disable autoload",IDC_WELCOME_NOAUTOLOAD,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,72,192,87,10 - CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,72,202,87,10 - DEFPUSHBUTTON "Play GZDoom",IDOK,8,246-18,90,14 - PUSHBUTTON "Exit",IDCANCEL,224-58,246-18,50,14 + ICON IDI_ICON1,IDC_STATIC,7,7,21,20 + LTEXT "Welcome to GZDoom!",IDC_STATIC,42,8,180,8 + LTEXT "",IDC_WELCOME_VERSION,42,18,180,8 + GROUPBOX "IWAD selection",IDC_STATIC,8,32,208,102 + LTEXT "Select which game file (IWAD) to run.",IDC_STATIC,12,44,190,8 + LISTBOX IDC_IWADLIST,12,56,200,72,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Video settings",IDC_STATIC,8,138,208,48 + LTEXT "Choose how GZDoom will render the game.",IDC_STATIC,12,148,190,8 + CONTROL "Hardware (OpenGL)",IDC_WELCOME_OPENGL,"Button",BS_AUTORADIOBUTTON,12,170,93,10 + CONTROL "Software (Doom)",IDC_WELCOME_SOFTWARE,"Button",BS_AUTORADIOBUTTON,12,160,93,10 + CONTROL "Fullscreen",IDC_WELCOME_FULLSCREEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,124,160,48,10 + CONTROL "Disable autoload",IDC_WELCOME_NOAUTOLOAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,39,65,10 + CONTROL "Lights.pk3",IDC_WELCOME_LIGHTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,46,192,51,10 + CONTROL "Brightmaps.pk3",IDC_WELCOME_BRIGHTMAPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,111,192,65,10 + CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,73,211,87,10 + DEFPUSHBUTTON "Play GZDoom",IDOK,8,228,90,14 + PUSHBUTTON "Exit",IDCANCEL,166,228,50,14 END IDD_EAXPROPERTYLIST DIALOGEX 0, 0, 265, 404 From 18242ab0cf99dd29c5a6e6013752c6637646257e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Dec 2016 11:28:04 +0100 Subject: [PATCH 1463/1509] - removed obsolete project files from VC++ 2005. --- wadsrc_bm/brightmaps.vcproj | 121 ------------------------------------ wadsrc_lights/lights.vcproj | 121 ------------------------------------ 2 files changed, 242 deletions(-) delete mode 100644 wadsrc_bm/brightmaps.vcproj delete mode 100644 wadsrc_lights/lights.vcproj diff --git a/wadsrc_bm/brightmaps.vcproj b/wadsrc_bm/brightmaps.vcproj deleted file mode 100644 index eaf6a4729..000000000 --- a/wadsrc_bm/brightmaps.vcproj +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/wadsrc_lights/lights.vcproj b/wadsrc_lights/lights.vcproj deleted file mode 100644 index b3b2cc5d4..000000000 --- a/wadsrc_lights/lights.vcproj +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From f6b9944169084ab3841cd5deaeb1cfd46bedcc5e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Dec 2016 11:41:25 +0100 Subject: [PATCH 1464/1509] - light definition update for Doom and Heretic to reduce the use of strong primary light colors. --- wadsrc_lights/static/doomdefs.txt | 130 ++++++++++----------- wadsrc_lights/static/hticdefs.txt | 188 +++++++++++++++--------------- 2 files changed, 159 insertions(+), 159 deletions(-) diff --git a/wadsrc_lights/static/doomdefs.txt b/wadsrc_lights/static/doomdefs.txt index 4e9f1e760..3690120e3 100644 --- a/wadsrc_lights/static/doomdefs.txt +++ b/wadsrc_lights/static/doomdefs.txt @@ -38,7 +38,7 @@ pointlight ROCKET flickerlight ROCKET_X1 { - color 1.0 0.7 0.0 + color 1.0 0.7 0.5 size 64 secondarySize 72 chance 0.3 @@ -46,7 +46,7 @@ flickerlight ROCKET_X1 flickerlight ROCKET_X2 { - color 0.5 0.1 0.0 + color 0.5 0.3 0.2 size 80 secondarySize 88 chance 0.3 @@ -54,7 +54,7 @@ flickerlight ROCKET_X2 flickerlight ROCKET_X3 { - color 0.3 0.0 0.0 + color 0.3 0.1 0.1 size 96 secondarySize 104 chance 0.3 @@ -72,13 +72,13 @@ object Rocket // Plasma pointlight PLASMABALL { - color 0.0 0.1 1.0 + color 0.5 0.5 1.0 size 56 } flickerlight PLASMA_X1 { - color 0.2 0.2 1.0 + color 0.5 0.5 1.0 size 64 secondarySize 72 chance 0.4 @@ -86,7 +86,7 @@ flickerlight PLASMA_X1 flickerlight PLASMA_X2 { - color 0.2 0.2 0.8 + color 0.4 0.4 0.8 size 80 secondarySize 88 chance 0.4 @@ -94,7 +94,7 @@ flickerlight PLASMA_X2 flickerlight PLASMA_X3 { - color 0.1 0.1 0.5 + color 0.25 0.25 0.5 size 64 secondarySize 72 chance 0.4 @@ -102,7 +102,7 @@ flickerlight PLASMA_X3 flickerlight PLASMA_X4 { - color 0.0 0.0 0.2 + color 0.1 0.1 0.2 size 8 secondarySize 16 chance 0.4 @@ -215,13 +215,13 @@ object PlasmaBall2 // BFG pointlight BFGBALL { - color 0.0 1.0 0.0 + color 0.5 1.0 0.5 size 80 } flickerlight BFGBALL_X1 { - color 0.2 1.0 0.2 + color 0.5 1.0 0.5 size 80 secondarySize 88 chance 0.3 @@ -229,7 +229,7 @@ flickerlight BFGBALL_X1 flickerlight BFGBALL_X2 { - color 0.3 1.0 0.3 + color 0.6 1.0 0.6 size 104 secondarySize 112 chance 0.3 @@ -237,7 +237,7 @@ flickerlight BFGBALL_X2 flickerlight BFGBALL_X3 { - color 0.5 1.0 0.5 + color 0.7 1.0 0.7 size 120 secondarySize 128 chance 0.3 @@ -245,7 +245,7 @@ flickerlight BFGBALL_X3 flickerlight BFGBALL_X4 { - color 0.2 0.7 0.2 + color 0.4 0.7 0.4 size 56 secondarySize 64 chance 0.3 @@ -353,7 +353,7 @@ object TechLamp // Tall red torch flickerlight2 BIGREDTORCH { - color 1.0 0.3 0.0 + color 1.0 0.5 0.2 size 64 secondarySize 72 interval 0.1 @@ -368,7 +368,7 @@ object RedTorch // Tall green torch flickerlight2 BIGGREENTORCH { - color 0.0 1.0 0.0 + color 0.3 1.0 0.3 size 64 secondarySize 72 interval 0.1 @@ -383,7 +383,7 @@ object GreenTorch // Tall blue torch flickerlight2 BIGBLUETORCH { - color 0.0 0.0 1.0 + color 0.3 0.3 1.0 size 64 secondarySize 72 interval 0.1 @@ -398,7 +398,7 @@ object BlueTorch // Small red torch flickerlight2 SMALLREDTORCH { - color 1.0 0.3 0.0 + color 1.0 0.5 0.2 size 48 secondarySize 54 interval 0.1 @@ -413,7 +413,7 @@ object ShortRedTorch // Small green torch flickerlight2 SMALLGREENTORCH { - color 0.0 1.0 0.0 + color 0.3 1.0 0.3 size 48 secondarySize 54 interval 0.1 @@ -428,7 +428,7 @@ object ShortGreenTorch // Small blue torch flickerlight2 SMALLBLUETORCH { - color 0.0 0.0 1.0 + color 0.3 0.3 1.0 size 48 secondarySize 54 interval 0.1 @@ -443,7 +443,7 @@ object ShortBlueTorch // Burning barrel flickerlight2 FIREBARREL { - color 1.0 0.9 0.0 + color 1.0 0.9 0.4 size 48 secondarySize 54 interval 0.1 @@ -458,7 +458,7 @@ object BurningBarrel // Skulls w/candles flickerlight2 SKULLCANDLES { - color 1.0 1.0 0.0 + color 1.0 1.0 0.3 size 32 secondarySize 34 interval 0.1 @@ -473,7 +473,7 @@ object HeadCandles // Candle pointlight CANDLE { - color 1.0 1.0 0.0 + color 1.0 1.0 0.3 size 16 offset 0 16 0 } @@ -486,7 +486,7 @@ object Candlestick // Candelabra pointlight CANDELABRA { - color 1.0 1.0 0.0 + color 1.0 1.0 0.3 size 48 offset 0 52 0 } @@ -505,7 +505,7 @@ object Candelabra // Soul Sphere pulselight SOULSPHERE { - color 0.0 0.0 1.0 + color 0.3 0.3 1.0 size 40 secondarySize 42 interval 2.0 @@ -520,7 +520,7 @@ object SoulSphere // Invulnerability Sphere pulselight INVULN { - color 0.0 1.0 0.0 + color 0.3 1.0 0.3 size 40 secondarySize 42 interval 2.0 @@ -595,7 +595,7 @@ object HealthBonus // Armour Helmet pulselight ARMORBONUS { - color 0.0 0.6 0.0 + color 0.2 0.6 0.2 size 16 secondarySize 14 interval 1.0 @@ -735,14 +735,14 @@ object DoomPlayer // Doom Imp Fireball pointlight IMPBALL { - color 1.0 0.5 0.0 + color 1.0 0.7 0.4 size 64 } // Doom imp fireball explosion flickerlight IMPBALL_X1 { - color 0.7 0.2 0.0 + color 0.7 0.4 0.25 size 80 secondarySize 88 chance 0.25 @@ -750,7 +750,7 @@ flickerlight IMPBALL_X1 flickerlight IMPBALL_X2 { - color 0.4 0.0 0.0 + color 0.4 0.2 0.1 size 96 secondarySize 104 chance 0.25 @@ -758,7 +758,7 @@ flickerlight IMPBALL_X2 flickerlight IMPBALL_X3 { - color 0.2 0.0 0.0 + color 0.2 0.1 0.0 size 112 secondarySize 120 chance 0.25 @@ -792,7 +792,7 @@ object Spectre // Cacodemon fireball flickerlight CACOBALL { - color 1.0 0.2 0.6 + color 1.0 0.5 0.8 size 56 secondarySize 64 chance 0.5 @@ -800,7 +800,7 @@ flickerlight CACOBALL flickerlight CACOBALL_X1 { - color 0.9 0.1 0.4 + color 0.9 0.4 0.7 size 72 secondarySize 80 chance 0.25 @@ -808,7 +808,7 @@ flickerlight CACOBALL_X1 flickerlight CACOBALL_X2 { - color 0.6 0.0 0.1 + color 0.6 0.3 0.5 size 88 secondarySize 96 chance 0.25 @@ -816,7 +816,7 @@ flickerlight CACOBALL_X2 flickerlight CACOBALL_X3 { - color 0.3 0.0 0.0 + color 0.3 0.1 0.1 size 104 secondarySize 112 chance 0.25 @@ -841,7 +841,7 @@ pointlight BARONBALL flickerlight BARONBALL_X1 { - color 0.0 0.7 0.0 + color 0.6 0.9 0.6 size 80 secondarySize 88 chance 0.25 @@ -849,7 +849,7 @@ flickerlight BARONBALL_X1 flickerlight BARONBALL_X2 { - color 0.0 0.4 0.0 + color 0.45 0.6 0.45 size 96 secondarySize 104 chance 0.25 @@ -857,7 +857,7 @@ flickerlight BARONBALL_X2 flickerlight BARONBALL_X3 { - color 0.0 0.2 0.0 + color 0.2 0.3 0.2 size 112 secondarySize 120 chance 0.25 @@ -876,7 +876,7 @@ object BaronBall // Lost Soul flickerlight LOSTSOUL { - color 1.0 0.3 0.0 + color 1.0 0.6 0.3 size 56 secondarysize 64 chance 0.1 @@ -884,7 +884,7 @@ flickerlight LOSTSOUL flickerlight LOSTSOUL_X1 { - color 0.8 0.3 0.0 + color 0.8 0.5 0.3 size 72 secondarySize 80 chance 0.25 @@ -892,7 +892,7 @@ flickerlight LOSTSOUL_X1 flickerlight LOSTSOUL_X2 { - color 0.6 0.2 0.0 + color 0.6 0.3 0.2 size 88 secondarySize 96 chance 0.25 @@ -944,13 +944,13 @@ object FatShot // Arachnotron Fireball pointlight ARACHPLAS { - color 0.6 1.0 0.0 + color 0.6 1.0 0.4 size 56 } flickerlight ARACHPLAS_X1 { - color 0.4 0.8 0.0 + color 0.4 0.8 0.3 size 72 secondarySize 80 chance 0.3 @@ -958,7 +958,7 @@ flickerlight ARACHPLAS_X1 flickerlight ARACHPLAS_X2 { - color 0.6 0.6 0.0 + color 0.6 0.6 0.3 size 88 secondarySize 96 chance 0.3 @@ -966,7 +966,7 @@ flickerlight ARACHPLAS_X2 flickerlight ARACHPLAS_X3 { - color 0.4 0.4 0.0 + color 0.4 0.4 0.2 size 48 secondarySize 32 chance 0.3 @@ -974,7 +974,7 @@ flickerlight ARACHPLAS_X3 flickerlight ARACHPLAS_X4 { - color 0.2 0.2 0.0 + color 0.2 0.2 0.1 size 24 secondarySize 16 chance 0.3 @@ -995,13 +995,13 @@ object ArachnotronPlasma // Revenant tracer pointlight TRACER { - color 1.0 0.3 0.0 + color 1.0 0.5 0.3 size 48 } flickerlight TRACER_X1 { - color 1.0 0.2 0.0 + color 1.0 0.5 0.2 size 64 secondarySize 72 chance 0.25 @@ -1009,7 +1009,7 @@ flickerlight TRACER_X1 flickerlight TRACER_X2 { - color 0.6 0.0 0.0 + color 0.6 0.3 0.1 size 80 secondarySize 88 chance 0.25 @@ -1017,7 +1017,7 @@ flickerlight TRACER_X2 flickerlight TRACER_X3 { - color 0.3 0.0 0.0 + color 0.3 0.1 0.0 size 96 secondarySize 104 chance 0.25 @@ -1036,7 +1036,7 @@ object RevenantTracer // Arch Vile Fire flickerlight ARCHFIRE1 { - color 1.0 1.0 0.0 + color 1.0 1.0 0.5 size 24 secondarySize 32 chance 0.3 @@ -1045,7 +1045,7 @@ flickerlight ARCHFIRE1 flickerlight ARCHFIRE2 { - color 1.0 1.0 0.0 + color 1.0 1.0 0.5 size 40 secondarySize 48 chance 0.3 @@ -1054,7 +1054,7 @@ flickerlight ARCHFIRE2 flickerlight ARCHFIRE3 { - color 1.0 1.0 0.0 + color 1.0 1.0 0.5 size 64 secondarySize 72 chance 0.3 @@ -1063,7 +1063,7 @@ flickerlight ARCHFIRE3 flickerlight ARCHFIRE4 { - color 0.8 0.8 0.0 + color 0.8 0.8 0.4 size 64 secondarySize 72 chance 0.3 @@ -1072,7 +1072,7 @@ flickerlight ARCHFIRE4 flickerlight ARCHFIRE5 { - color 0.8 0.8 0.0 + color 0.8 0.8 0.4 size 64 secondarySize 72 chance 0.3 @@ -1081,7 +1081,7 @@ flickerlight ARCHFIRE5 flickerlight ARCHFIRE6 { - color 0.6 0.6 0.0 + color 0.6 0.6 0.3 size 48 secondarySize 56 chance 0.3 @@ -1090,7 +1090,7 @@ flickerlight ARCHFIRE6 flickerlight ARCHFIRE7 { - color 0.4 0.4 0.0 + color 0.4 0.4 0.2 size 32 secondarySize 40 chance 0.3 @@ -1099,7 +1099,7 @@ flickerlight ARCHFIRE7 flickerlight ARCHFIRE8 { - color 0.2 0.2 0.0 + color 0.2 0.2 0.1 size 16 secondarySize 24 chance 0.3 @@ -1121,7 +1121,7 @@ object ArchvileFire // Arch-vile flickerlight ARCHATK1 { - color 1.0 1.0 0.0 + color 1.0 1.0 0.4 size 32 secondarySize 48 chance 0.3 @@ -1130,7 +1130,7 @@ flickerlight ARCHATK1 flickerlight ARCHATK2 { - color 1.0 1.0 0.0 + color 1.0 1.0 0.4 size 56 secondarySize 64 chance 0.3 @@ -1139,7 +1139,7 @@ flickerlight ARCHATK2 flickerlight ARCHATK3 { - color 1.0 1.0 0.0 + color 1.0 1.0 0.4 size 56 secondarySize 64 chance 0.3 @@ -1148,7 +1148,7 @@ flickerlight ARCHATK3 flickerlight ARCHATK4 { - color 1.0 1.0 0.0 + color 1.0 1.0 0.4 size 64 secondarySize 72 chance 0.3 @@ -1157,7 +1157,7 @@ flickerlight ARCHATK4 flickerlight ARCHATK5 { - color 1.0 1.0 0.0 + color 1.0 1.0 0.4 size 80 secondarySize 88 chance 0.3 @@ -1166,7 +1166,7 @@ flickerlight ARCHATK5 flickerlight ARCHATK6 { - color 0.7 0.7 0.0 + color 0.7 0.7 0.3 size 96 secondarySize 104 chance 0.3 @@ -1175,7 +1175,7 @@ flickerlight ARCHATK6 flickerlight ARCHATK7 { - color 0.3 0.3 0.0 + color 0.3 0.3 0.1 size 104 secondarySize 112 chance 0.3 @@ -1184,7 +1184,7 @@ flickerlight ARCHATK7 pulselight ARCHRES { - color 0.6 0.0 0.0 + color 0.6 0.3 0.3 size 64 secondarySize 70 interval 0.5 diff --git a/wadsrc_lights/static/hticdefs.txt b/wadsrc_lights/static/hticdefs.txt index 92fa2852d..b8823db66 100644 --- a/wadsrc_lights/static/hticdefs.txt +++ b/wadsrc_lights/static/hticdefs.txt @@ -9,25 +9,25 @@ // Wand puffs pointlight WANDPUFF1 { - color 1.0 1.0 0.0 + color 0.9 0.9 0.5 size 32 } pointlight WANDPUFF2 { - color 0.7 0.7 0.0 + color 0.6 0.6 0.35 size 24 } pointlight WANDPUFF3 { - color 0.4 0.4 0.0 + color 0.3 0.3 0.2 size 16 } pointlight WANDPUFF4 { - color 0.2 0.2 0.0 + color 0.15 0.15 0.1 size 8 } @@ -48,31 +48,31 @@ object GoldWandPuff2 // Tomed wand projectile pointlight WANDBALL { - color 1.0 1.0 0.0 + color 0.9 0.9 0.5 size 24 } pointlight WANDBALL_X1 { - color 0.8 0.8 0.0 + color 0.72 0.72 0.4 size 32 } pointlight WANDBALL_X2 { - color 0.6 0.6 0.0 + color 0.54 0.54 0.3 size 34 } pointlight WANDBALL_X3 { - color 0.4 0.4 0.0 + color 0.36 0.36 0.2 size 36 } pointlight WANDBALL_X4 { - color 0.2 0.2 0.0 + color 0.18 0.18 0.1 size 38 } @@ -90,13 +90,13 @@ object GoldWandFX2 // Crossbow secondary projectile pointlight SMALLBOWBOLT { - color 0.0 1.0 0.0 + color 0.5 1.0 0.5 size 40 } flickerlight SMALLBOWBOLT_X1 { - color 0.0 0.7 0.0 + color 0.35 0.7 0.35 size 48 secondarySize 52 chance 0.3 @@ -104,7 +104,7 @@ flickerlight SMALLBOWBOLT_X1 flickerlight SMALLBOWBOLT_X2 { - color 0.0 0.4 0.0 + color 0.2 0.4 0.2 size 40 secondarySize 44 chance 0.3 @@ -112,7 +112,7 @@ flickerlight SMALLBOWBOLT_X2 flickerlight SMALLBOWBOLT_X3 { - color 0.0 0.2 0.0 + color 0.1 0.2 0.1 size 32 secondarySize 36 chance 0.3 @@ -130,13 +130,13 @@ object CrossbowFX3 // Crossbow primary proectile pointlight BIGBOWBOLT { - color 0.7 1.0 0.0 + color 0.8 1.0 0.5 size 64 } flickerlight BIGBOWBOLT_X1 { - color 0.4 0.8 0.0 + color 0.48 0.8 0.4 size 72 secondarySize 74 chance 0.3 @@ -144,7 +144,7 @@ flickerlight BIGBOWBOLT_X1 flickerlight BIGBOWBOLT_X2 { - color 0.4 0.6 0.0 + color 0.44 0.6 0.3 size 56 secondarySize 64 chance 0.3 @@ -152,7 +152,7 @@ flickerlight BIGBOWBOLT_X2 flickerlight BIGBOWBOLT_X3 { - color 0.2 0.4 0.0 + color 0.22 0.4 0.2 size 32 secondarySize 40 chance 0.3 @@ -276,13 +276,13 @@ object BlasterFX1 // Hellstaff bolt pointlight HELLSTAFFBALL { - color 1.0 0.2 0.2 + color 1.0 0.5 0.5 size 56 } flickerlight HELLSTAFFBALL_X1 { - color 1.0 0.4 0.4 + color 1.0 0.7 0.7 size 56 secondarySize 64 chance 0.3 @@ -290,7 +290,7 @@ flickerlight HELLSTAFFBALL_X1 flickerlight HELLSTAFFBALL_X2 { - color 0.8 0.3 0.3 + color 0.8 0.5 0.5 size 64 secondarySize 72 chance 0.3 @@ -298,7 +298,7 @@ flickerlight HELLSTAFFBALL_X2 flickerlight HELLSTAFFBALL_X3 { - color 0.6 0.2 0.2 + color 0.6 0.3 0.3 size 80 secondarySize 88 chance 0.3 @@ -306,7 +306,7 @@ flickerlight HELLSTAFFBALL_X3 flickerlight HELLSTAFFBALL_X4 { - color 0.4 0.1 0.1 + color 0.4 0.2 0.2 size 88 secondarySize 96 chance 0.3 @@ -314,7 +314,7 @@ flickerlight HELLSTAFFBALL_X4 flickerlight HELLSTAFFBALL_X5 { - color 0.2 0.0 0.0 + color 0.2 0.1 0.1 size 96 secondarySize 104 chance 0.3 @@ -391,7 +391,7 @@ object RainPillar // Phoenix rod shot pointlight PHOENIXSHOT { - color 1.0 0.6 0.0 + color 1.0 0.6 0.4 size 64 } @@ -405,7 +405,7 @@ flickerlight PHOENIX_X1 flickerlight PHOENIX_X2 { - color 1.0 0.6 0.0 + color 1.0 0.6 0.3 size 88 secondarySize 96 chance 0.3 @@ -413,7 +413,7 @@ flickerlight PHOENIX_X2 flickerlight PHOENIX_X3 { - color 0.8 0.6 0.0 + color 0.8 0.6 0.25 size 72 secondarySize 80 chance 0.3 @@ -421,7 +421,7 @@ flickerlight PHOENIX_X3 flickerlight PHOENIX_X4 { - color 0.6 0.4 0.0 + color 0.6 0.4 0.2 size 56 secondarySize 64 chance 0.3 @@ -429,7 +429,7 @@ flickerlight PHOENIX_X4 flickerlight PHOENIX_X5 { - color 0.4 0.2 0.0 + color 0.4 0.2 0.1 size 40 secondarySize 48 chance 0.3 @@ -437,7 +437,7 @@ flickerlight PHOENIX_X5 flickerlight PHOENIX_X6 { - color 0.2 0.0 0.0 + color 0.2 0.1 0.0 size 24 secondarySize 32 chance 0.3 @@ -460,7 +460,7 @@ object PhoenixFX1 // Phoenix rod flamethrower flickerlight PHOENIXFLAME { - color 0.7 0.4 0.0 + color 0.7 0.4 0.2 size 48 secondarySize 56 chance 0.5 @@ -468,7 +468,7 @@ flickerlight PHOENIXFLAME flickerlight PHOENIXFLAME2 { - color 0.5 0.2 0.0 + color 0.5 0.2 0.1 size 24 secondarySize 32 chance 0.5 @@ -494,7 +494,7 @@ object PhoenixFX2 // Mace ball explosion flickerlight MACEBALL_X1 { - color 0.8 0.8 0.2 + color 0.8 0.8 0.4 size 64 secondarySize 72 chance 0.3 @@ -502,7 +502,7 @@ flickerlight MACEBALL_X1 flickerlight MACEBALL_X2 { - color 0.6 0.6 0.1 + color 0.6 0.6 0.3 size 48 secondarySize 56 chance 0.3 @@ -510,7 +510,7 @@ flickerlight MACEBALL_X2 flickerlight MACEBALL_X3 { - color 0.4 0.4 0.0 + color 0.4 0.4 0.2 size 32 secondarySize 40 chance 0.3 @@ -518,7 +518,7 @@ flickerlight MACEBALL_X3 flickerlight MACEBALL_X4 { - color 0.2 0.2 0.0 + color 0.2 0.2 0.1 size 16 secondarySize 24 chance 0.3 @@ -563,13 +563,13 @@ object MaceFX4 // Heretic imp fireball pointlight HIMPBALL { - color 1.0 0.8 0.0 + color 1.0 0.8 0.4 size 32 } flickerlight HIMPBALL_X1 { - color 0.8 0.5 0.0 + color 0.8 0.5 0.33 size 48 secondarySize 56 chance 0.3 @@ -577,7 +577,7 @@ flickerlight HIMPBALL_X1 flickerlight HIMPBALL_X2 { - color 0.6 0.3 0.0 + color 0.6 0.4 0.27 size 40 secondarySize 48 chance 0.3 @@ -606,7 +606,7 @@ object HereticImpBall // Mummy flickerlight MUMMYATK { - color 1.0 1.0 0.0 + color 1.0 1.0 0.5 size 48 secondarySize 56 chance 0.4 @@ -625,7 +625,7 @@ object MummyLeaderGhost // Mummy fireball flickerlight MUMMYBALL { - color 1.0 1.0 0.0 + color 1.0 1.0 0.5 size 40 secondarySize 48 chance 0.4 @@ -633,7 +633,7 @@ flickerlight MUMMYBALL flickerlight MUMMYBALL_X1 { - color 0.7 0.7 0.0 + color 0.7 0.7 0.35 size 48 secondarySize 56 chance 0.4 @@ -641,7 +641,7 @@ flickerlight MUMMYBALL_X1 flickerlight MUMMYBALL_X2 { - color 0.4 0.4 0.0 + color 0.4 0.4 0.2 size 56 secondarySize 64 chance 0.4 @@ -649,7 +649,7 @@ flickerlight MUMMYBALL_X2 flickerlight MUMMYBALL_X3 { - color 0.2 0.2 0.0 + color 0.2 0.2 0.1 size 64 secondarySize 72 chance 0.4 @@ -669,13 +669,13 @@ object MummyFX1 // Green flying axe pointlight GREENAXE { - color 0.0 1.0 0.0 + color 0.4 1.0 0.4 size 32 } flickerlight GREENAXE_X1 { - color 0.0 0.7 0.0 + color 0.3 0.7 0.3 size 32 secondarySize 48 chance 0.3 @@ -683,7 +683,7 @@ flickerlight GREENAXE_X1 flickerlight GREENAXE_X2 { - color 0.0 0.4 0.0 + color 0.2 0.4 0.2 size 48 secondarySize 56 chance 0.3 @@ -711,13 +711,13 @@ object KnightAxe // Red flying axe pointlight REDAXE { - color 1.0 0.0 0.0 + color 1.0 0.5 0.5 size 32 } flickerlight REDAXE_X1 { - color 0.7 0.0 0.0 + color 0.7 0.3 0.3 size 32 secondarySize 48 chance 0.3 @@ -725,7 +725,7 @@ flickerlight REDAXE_X1 flickerlight REDAXE_X2 { - color 0.4 0.0 0.0 + color 0.4 0.2 0.2 size 48 secondarySize 56 chance 0.3 @@ -733,7 +733,7 @@ flickerlight REDAXE_X2 flickerlight REDAXE_X3 { - color 0.2 0.0 0.0 + color 0.2 0.1 0.1 size 56 secondarySize 64 chance 0.3 @@ -752,7 +752,7 @@ object RedAxe // Disciple fireball flickerlight DISCIPLEBALL { - color 1.0 0.0 1.0 + color 1.0 0.5 1.0 size 32 secondarySize 40 chance 0.3 @@ -760,7 +760,7 @@ flickerlight DISCIPLEBALL flickerlight DISCIPLEBALL_X1 { - color 0.7 0.0 0.7 + color 0.7 0.3 0.7 size 16 secondarySize 24 chance 0.3 @@ -768,7 +768,7 @@ flickerlight DISCIPLEBALL_X1 flickerlight DISCIPLEBALL_X2 { - color 0.3 0.0 0.3 + color 0.3 0.17 0.3 size 8 secondarySize 16 chance 0.3 @@ -852,7 +852,7 @@ pointlight FROSTBALL_X2 pointlight FROSTBALL_X3 { - color 0.0 0.0 0.4 + color 0.1 0.1 0.4 size 48 } @@ -891,7 +891,7 @@ object HeadFX2 // Ironlich fire wall flickerlight LICHFIRE { - color 1.0 0.7 0.0 + color 1.0 0.7 0.4 size 48 secondarySize 56 chance 0.5 @@ -899,7 +899,7 @@ flickerlight LICHFIRE flickerlight LICHFIRE_X1 { - color 0.9 0.4 0.0 + color 0.9 0.4 0.3 size 56 secondarySize 64 chance 0.5 @@ -907,7 +907,7 @@ flickerlight LICHFIRE_X1 flickerlight LICHFIRE_X2 { - color 0.7 0.1 0.0 + color 0.7 0.1 0.2 size 48 secondarySize 56 chance 0.5 @@ -915,7 +915,7 @@ flickerlight LICHFIRE_X2 flickerlight LICHFIRE_X3 { - color 0.4 0.0 0.0 + color 0.4 0.1 0.1 size 40 secondarySize 48 chance 0.5 @@ -1000,7 +1000,7 @@ object Beast // Weredragon fireball flickerlight BEASTBALL { - color 1.0 0.4 0.0 + color 1.0 0.5 0.3 size 48 secondarySize 56 chance 0.3 @@ -1008,7 +1008,7 @@ flickerlight BEASTBALL flickerlight BEASTBALL_X1 { - color 0.8 0.2 0.0 + color 0.8 0.4 0.24 size 48 secondarySize 56 chance 0.3 @@ -1016,7 +1016,7 @@ flickerlight BEASTBALL_X1 flickerlight BEASTBALL_X2 { - color 0.6 0.0 0.0 + color 0.6 0.3 0.2 size 40 secondarySize 48 chance 0.3 @@ -1024,7 +1024,7 @@ flickerlight BEASTBALL_X2 flickerlight BEASTBALL_X3 { - color 0.4 0.0 0.0 + color 0.4 0.2 0.1 size 32 secondarySize 40 chance 0.3 @@ -1067,7 +1067,7 @@ flickerlight SNAKESHOT1_X1 flickerlight SNAKESHOT1_X2 { - color 0.4 0.1 0.7 + color 0.4 0.2 0.7 size 24 secondarySize 26 chance 0.3 @@ -1075,7 +1075,7 @@ flickerlight SNAKESHOT1_X2 flickerlight SNAKESHOT1_X3 { - color 0.3 0.0 0.5 + color 0.3 0.1 0.5 size 28 secondarySize 30 chance 0.3 @@ -1105,13 +1105,13 @@ object SnakeProjA // Large ophidian shot pointlight SNAKESHOT2 { - color 1.0 0.6 0.0 + color 1.0 0.6 0.4 size 32 } flickerlight SNAKESHOT2_X1 { - color 1.0 0.6 0.0 + color 1.0 0.6 0.4 size 40 secondarySize 48 chance 0.3 @@ -1119,7 +1119,7 @@ flickerlight SNAKESHOT2_X1 flickerlight SNAKESHOT2_X2 { - color 0.6 0.3 0.0 + color 0.6 0.3 0.25 size 48 secondarySize 52 chance 0.3 @@ -1127,7 +1127,7 @@ flickerlight SNAKESHOT2_X2 flickerlight SNAKESHOT2_X3 { - color 0.3 0.0 0.0 + color 0.3 0.1 0.1 size 44 secondarySize 48 chance 0.3 @@ -1146,7 +1146,7 @@ object SnakeProjB // Maulotaur fireball flickerlight MAULBALL { - color 1.0 0.7 0.0 + color 1.0 0.7 0.5 size 40 secondarySize 48 chance 0.5 @@ -1154,7 +1154,7 @@ flickerlight MAULBALL flickerlight MAULBALL_X1 { - color 0.8 0.6 0.0 + color 0.8 0.6 0.4 size 56 secondarySize 64 chance 0.3 @@ -1162,7 +1162,7 @@ flickerlight MAULBALL_X1 flickerlight MAULBALL_X2 { - color 0.8 0.4 0.0 + color 0.8 0.4 0.3 size 56 secondarySize 64 chance 0.3 @@ -1170,7 +1170,7 @@ flickerlight MAULBALL_X2 flickerlight MAULBALL_X3 { - color 0.6 0.2 0.0 + color 0.6 0.3 0.2 size 40 secondarySize 48 chance 0.3 @@ -1200,7 +1200,7 @@ object MinotaurFX1 // Maulotaur ground flame pulselight MAULFLAME { - color 1.0 0.7 0.0 + color 1.0 0.7 0.5 size 1 secondarySize 64 interval 6.0 @@ -1208,7 +1208,7 @@ pulselight MAULFLAME flickerlight MAULFLAME_X1 { - color 1.0 0.7 0.0 + color 1.0 0.7 0.5 size 48 secondarySize 56 chance 0.3 @@ -1216,7 +1216,7 @@ flickerlight MAULFLAME_X1 flickerlight MAULFLAME_X2 { - color 1.0 0.7 0.0 + color 1.0 0.7 0.5 size 56 secondarySize 64 chance 0.3 @@ -1224,7 +1224,7 @@ flickerlight MAULFLAME_X2 flickerlight MAULFLAME_X3 { - color 0.7 0.4 0.0 + color 0.7 0.4 0.3 size 64 secondarySize 68 chance 0.3 @@ -1232,7 +1232,7 @@ flickerlight MAULFLAME_X3 flickerlight MAULFLAME_X4 { - color 0.5 0.1 0.0 + color 0.5 0.3 0.1 size 68 secondarySize 72 chance 0.3 @@ -1266,7 +1266,7 @@ object MinotaurFX3 // D'Sparil serpent fireball flickerlight SERPENTBALL { - color 1.0 0.95 0.0 + color 1.0 0.95 0.5 size 56 secondarySize 64 chance 0.5 @@ -1274,7 +1274,7 @@ flickerlight SERPENTBALL flickerlight SERPENTBALL_X1 { - color 1.0 0.95 0.0 + color 1.0 0.95 0.5 size 64 secondarySize 72 chance 0.5 @@ -1282,7 +1282,7 @@ flickerlight SERPENTBALL_X1 flickerlight SERPENTBALL_X2 { - color 0.8 0.8 0.0 + color 0.8 0.8 0.4 size 72 secondarySize 80 chance 0.5 @@ -1290,7 +1290,7 @@ flickerlight SERPENTBALL_X2 flickerlight SERPENTBALL_X3 { - color 0.5 0.5 0.0 + color 0.5 0.5 0.25 size 88 secondarySize 96 chance 0.5 @@ -1298,7 +1298,7 @@ flickerlight SERPENTBALL_X3 flickerlight SERPENTBALL_X4 { - color 0.2 0.2 0.0 + color 0.2 0.2 0.1 size 96 secondarySize 104 chance 0.5 @@ -1320,7 +1320,7 @@ object SorcererFX1 // D'Sparil blue bolt flickerlight DSPARILBALL { - color 0.3 0.3 1.0 + color 0.5 0.5 1.0 size 56 secondarySize 64 chance 0.5 @@ -1328,7 +1328,7 @@ flickerlight DSPARILBALL flickerlight DSPARILBALL_X1 { - color 0.3 0.3 1.0 + color 0.5 0.5 1.0 size 64 secondarySize 72 chance 0.3 @@ -1336,7 +1336,7 @@ flickerlight DSPARILBALL_X1 flickerlight DSPARILBALL_X2 { - color 0.2 0.2 0.8 + color 0.4 0.4 0.8 size 80 secondarySize 88 chance 0.3 @@ -1344,7 +1344,7 @@ flickerlight DSPARILBALL_X2 flickerlight DSPARILBALL_X3 { - color 0.1 0.1 0.6 + color 0.3 0.3 0.6 size 88 secondarySize 92 chance 0.3 @@ -1352,7 +1352,7 @@ flickerlight DSPARILBALL_X3 flickerlight DSPARILBALL_X4 { - color 0.0 0.0 0.4 + color 0.2 0.2 0.4 size 82 secondarySize 86 chance 0.3 @@ -1360,7 +1360,7 @@ flickerlight DSPARILBALL_X4 flickerlight DSPARILBALL_X5 { - color 0.0 0.0 0.2 + color 0.1 0.1 0.2 size 82 secondarySize 86 chance 0.3 @@ -1503,7 +1503,7 @@ object Pod // Big volcano fireball flickerlight VOLCANOBALL1 { - color 1.0 0.5 0.0 + color 1.0 0.7 0.5 size 56 secondarySize 64 chance 0.5 @@ -1574,7 +1574,7 @@ object KeyGizmoGreen // Time bomb explosion flickerlight TIMEBOMB_X1 { - color 1.0 0.6 0.0 + color 1.0 0.6 0.4 size 48 secondarySize 56 chance 0.3 @@ -1582,7 +1582,7 @@ flickerlight TIMEBOMB_X1 flickerlight TIMEBOMB_X1 { - color 0.8 0.4 0.0 + color 0.8 0.4 0.3 size 56 secondarySize 64 chance 0.3 @@ -1590,7 +1590,7 @@ flickerlight TIMEBOMB_X1 flickerlight TIMEBOMB_X1 { - color 0.6 0.2 0.0 + color 0.6 0.3 0.2 size 64 secondarySize 72 chance 0.3 @@ -1598,7 +1598,7 @@ flickerlight TIMEBOMB_X1 flickerlight TIMEBOMB_X1 { - color 0.4 0.0 0.0 + color 0.4 0.2 0.1 size 72 secondarySize 80 chance 0.3 @@ -1606,7 +1606,7 @@ flickerlight TIMEBOMB_X1 flickerlight TIMEBOMB_X1 { - color 0.2 0.0 0.0 + color 0.2 0.1 0.0 size 80 secondarySize 88 chance 0.3 From 9a529192b0a8ea98c88a226110c4ed00ac17bd15 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 22 Dec 2016 21:21:57 +0100 Subject: [PATCH 1465/1509] Switch to the lower precision rsqrtss instruction as it is faster, especially on older Intel architectures and on AMD --- tools/drawergen/fixedfunction/drawspancodegen.cpp | 2 +- tools/drawergen/fixedfunction/drawwallcodegen.cpp | 2 +- tools/drawergen/ssa/ssa_float.cpp | 13 +++++++++++++ tools/drawergen/ssa/ssa_float.h | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/tools/drawergen/fixedfunction/drawspancodegen.cpp b/tools/drawergen/fixedfunction/drawspancodegen.cpp index c35198ba8..2272acf8d 100644 --- a/tools/drawergen/fixedfunction/drawspancodegen.cpp +++ b/tools/drawergen/fixedfunction/drawspancodegen.cpp @@ -256,7 +256,7 @@ SSAVec4i DrawSpanCodegen::Shade(SSAVec4i fg, bool isSimpleShade) // attenuation = 1 - MIN(dist * (1/radius), 1) SSAFloat Lyz2 = light_y; // L.y*L.y + L.z*L.z SSAFloat Lx = light_x - viewpos_x; - SSAFloat dist = SSAFloat::sqrt(Lyz2 + Lx * Lx); + SSAFloat dist = SSAFloat::fastsqrt(Lyz2 + Lx * Lx); SSAInt attenuation = SSAInt(SSAFloat(256.0f) - SSAFloat::MIN(dist * light_rcp_radius, SSAFloat(256.0f)), true); SSAVec4i contribution = (light_color * fg * attenuation) >> 16; diff --git a/tools/drawergen/fixedfunction/drawwallcodegen.cpp b/tools/drawergen/fixedfunction/drawwallcodegen.cpp index 5e7f9000d..898aebdbb 100644 --- a/tools/drawergen/fixedfunction/drawwallcodegen.cpp +++ b/tools/drawergen/fixedfunction/drawwallcodegen.cpp @@ -244,7 +244,7 @@ SSAVec4i DrawWallCodegen::Shade(SSAVec4i fg, int index, bool isSimpleShade) // attenuation = 1 - MIN(dist * (1/radius), 1) SSAFloat Lxy2 = light_x; // L.x*L.x + L.y*L.y SSAFloat Lz = light_z - z; - SSAFloat dist = SSAFloat::sqrt(Lxy2 + Lz * Lz); + SSAFloat dist = SSAFloat::fastsqrt(Lxy2 + Lz * Lz); SSAInt attenuation = SSAInt(SSAFloat(256.0f) - SSAFloat::MIN(dist * light_rcp_radius, SSAFloat(256.0f)), true); SSAVec4i contribution = (light_color * fg * attenuation) >> 16; diff --git a/tools/drawergen/ssa/ssa_float.cpp b/tools/drawergen/ssa/ssa_float.cpp index f587d7b5a..f537792fc 100644 --- a/tools/drawergen/ssa/ssa_float.cpp +++ b/tools/drawergen/ssa/ssa_float.cpp @@ -25,6 +25,7 @@ #include "ssa_int.h" #include "ssa_scope.h" #include "ssa_bool.h" +#include "ssa_vec4f.h" SSAFloat::SSAFloat() : v(0) @@ -60,6 +61,18 @@ SSAFloat SSAFloat::sqrt(SSAFloat f) return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::sqrt, params), f.v, SSAScope::hint())); } +SSAFloat SSAFloat::fastsqrt(SSAFloat f) +{ + return f * rsqrt(f); +} + +SSAFloat SSAFloat::rsqrt(SSAFloat f) +{ + llvm::Value *f_ss = SSAScope::builder().CreateInsertElement(llvm::UndefValue::get(SSAVec4f::llvm_type()), f.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); + f_ss = SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse_rsqrt_ss), f_ss, SSAScope::hint()); + return SSAFloat::from_llvm(SSAScope::builder().CreateExtractElement(f_ss, SSAInt(0).v, SSAScope::hint())); +} + SSAFloat SSAFloat::sin(SSAFloat val) { std::vector params; diff --git a/tools/drawergen/ssa/ssa_float.h b/tools/drawergen/ssa/ssa_float.h index 69fb81a75..f7e2b93ef 100644 --- a/tools/drawergen/ssa/ssa_float.h +++ b/tools/drawergen/ssa/ssa_float.h @@ -37,6 +37,8 @@ public: static SSAFloat from_llvm(llvm::Value *v) { return SSAFloat(v); } static llvm::Type *llvm_type(); static SSAFloat sqrt(SSAFloat f); + static SSAFloat fastsqrt(SSAFloat f); + static SSAFloat rsqrt(SSAFloat f); static SSAFloat sin(SSAFloat val); static SSAFloat cos(SSAFloat val); static SSAFloat pow(SSAFloat val, SSAFloat power); From b0a96af220d3062448a50f1bc6d95ad73e5b0e32 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 22 Dec 2016 21:34:03 +0100 Subject: [PATCH 1466/1509] Improve dynamic light performance by only including lights if they touch a column or span --- src/r_plane.cpp | 32 ++++++++++++++++++++------------ src/r_walldraw.cpp | 32 ++++++++++++++++++++------------ 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 48a5bcb0f..f93e0579f 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -274,24 +274,32 @@ void R_MapPlane (int y, int x1) visplane_light *cur_node = ds_light_list; while (cur_node && nextlightindex < 64 * 1024) { - uint32_t red = cur_node->lightsource->GetRed(); - uint32_t green = cur_node->lightsource->GetGreen(); - uint32_t blue = cur_node->lightsource->GetBlue(); - double lightX = cur_node->lightsource->X() - ViewPos.X; double lightY = cur_node->lightsource->Y() - ViewPos.Y; double lightZ = cur_node->lightsource->Z() - ViewPos.Z; - nextlightindex++; - auto &light = dc_lights[dc_num_lights++]; - light.x = (float)(lightX * ViewSin - lightY * ViewCos); - light.y = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; - light.z = (float)lightZ - dc_viewpos.Z; - light.radius = 256.0f / cur_node->lightsource->GetRadius(); - light.color = (red << 16) | (green << 8) | blue; + float lx = (float)(lightX * ViewSin - lightY * ViewCos); + float ly = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; + float lz = (float)lightZ - dc_viewpos.Z; // Precalculate the constant part of the dot here so the drawer doesn't have to. - light.y = light.y * light.y + light.z * light.z; + float lconstant = ly * ly + lz * lz; + + // Include light only if it touches this row + float radius = cur_node->lightsource->GetRadius(); + if (radius * radius >= lconstant) + { + uint32_t red = cur_node->lightsource->GetRed(); + uint32_t green = cur_node->lightsource->GetGreen(); + uint32_t blue = cur_node->lightsource->GetBlue(); + + nextlightindex++; + auto &light = dc_lights[dc_num_lights++]; + light.x = lx; + light.y = lconstant; + light.radius = 256.0f / radius; + light.color = (red << 16) | (green << 8) | blue; + } cur_node = cur_node->next; } diff --git a/src/r_walldraw.cpp b/src/r_walldraw.cpp index f43b8f9d4..0523d8960 100644 --- a/src/r_walldraw.cpp +++ b/src/r_walldraw.cpp @@ -561,24 +561,32 @@ static void Draw1Column(int x, int y1, int y2, WallSampler &sampler, void(*draw1 { if (!(cur_node->lightsource->flags2&MF2_DORMANT)) { - uint32_t red = cur_node->lightsource->GetRed(); - uint32_t green = cur_node->lightsource->GetGreen(); - uint32_t blue = cur_node->lightsource->GetBlue(); - double lightX = cur_node->lightsource->X() - ViewPos.X; double lightY = cur_node->lightsource->Y() - ViewPos.Y; double lightZ = cur_node->lightsource->Z() - ViewPos.Z; - nextlightindex++; - auto &light = dc_lights[dc_num_lights++]; - light.x = (float)(lightX * ViewSin - lightY * ViewCos) - dc_viewpos.X; - light.y = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; - light.z = (float)lightZ; - light.radius = 256.0f / cur_node->lightsource->GetRadius(); - light.color = (red << 16) | (green << 8) | blue; + float lx = (float)(lightX * ViewSin - lightY * ViewCos) - dc_viewpos.X; + float ly = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; + float lz = (float)lightZ; // Precalculate the constant part of the dot here so the drawer doesn't have to. - light.x = light.x * light.x + light.y * light.y; + float lconstant = lx * lx + ly * ly; + + // Include light only if it touches this column + float radius = cur_node->lightsource->GetRadius(); + if (radius * radius >= lconstant) + { + uint32_t red = cur_node->lightsource->GetRed(); + uint32_t green = cur_node->lightsource->GetGreen(); + uint32_t blue = cur_node->lightsource->GetBlue(); + + nextlightindex++; + auto &light = dc_lights[dc_num_lights++]; + light.x = lconstant; + light.z = lz; + light.radius = 256.0f / cur_node->lightsource->GetRadius(); + light.color = (red << 16) | (green << 8) | blue; + } } cur_node = cur_node->nextLight; From 175701ac5d0df81a9b5560afd30ea5ba4fc96610 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 23 Dec 2016 03:54:57 +0100 Subject: [PATCH 1467/1509] Fix lights not being copied when a visplane is duplicated --- src/r_plane.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index f93e0579f..502d8490d 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -684,6 +684,7 @@ visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop) new_pl->CurrentPortalUniq = pl->CurrentPortalUniq; new_pl->MirrorFlags = pl->MirrorFlags; new_pl->CurrentSkybox = pl->CurrentSkybox; + new_pl->lights = pl->lights; pl = new_pl; pl->left = start; pl->right = stop; From 78737f9bc7b22c8af0c19485bb3d25fe4c6fe4a7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 23 Dec 2016 15:25:39 +0100 Subject: [PATCH 1468/1509] - fixed: The cycler for a pulse light needs to be reinitialized when new light properties get applied. - do not clamp the cycler's output to a byte. --- src/gl/dynlights/a_dynlight.cpp | 2 +- src/gl/dynlights/gl_dynlight.cpp | 13 +++++++++++++ src/gl/dynlights/gl_dynlight.h | 3 ++- src/gl/utility/gl_cycler.cpp | 20 +++++++++++++++----- src/gl/utility/gl_cycler.h | 2 +- 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 0ab834505..4ba95af87 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -236,7 +236,7 @@ void ADynamicLight::Activate(AActor *activator) m_cycler.SetParams(float(m_Radius[1]), float(m_Radius[0]), pulseTime); m_cycler.ShouldCycle(true); m_cycler.SetCycleType(CYCLE_Sin); - m_currentRadius = (BYTE)m_cycler.GetVal(); + m_currentRadius = m_cycler.GetVal(); } } diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index 18b255999..de05bb19f 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -167,6 +167,8 @@ FLightDefaults::FLightDefaults(FName name, ELightType type) void FLightDefaults::ApplyProperties(ADynamicLight * light) const { + auto oldtype = light->lighttype; + light->lighttype = m_type; light->specialf1 = m_Param; light->SetOffset(m_Pos); @@ -179,6 +181,17 @@ void FLightDefaults::ApplyProperties(ADynamicLight * light) const if (m_additive) light->flags4 |= MF4_ADDITIVE; if (m_dontlightself) light->flags4 |= MF4_DONTLIGHTSELF; light->m_tickCount = 0; + if (m_type == PulseLight) + { + float pulseTime = float(m_Param / TICRATE); + + light->m_lastUpdate = level.maptime; + light->m_cycler.SetParams(float(light->m_Radius[1]), float(light->m_Radius[0]), pulseTime, oldtype == PulseLight); + light->m_cycler.ShouldCycle(true); + light->m_cycler.SetCycleType(CYCLE_Sin); + light->m_currentRadius = light->m_cycler.GetVal(); + } + switch (m_attenuate) { case 0: light->flags4 &= ~MF4_ATTENUATE; break; diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index e8448890b..f71f0dfdf 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -33,7 +33,7 @@ EXTERN_CVAR(Bool, gl_attachedlights) class ADynamicLight; class FSerializer; - +class FLightDefaults; enum @@ -91,6 +91,7 @@ struct FLightNode class ADynamicLight : public AActor { + friend class FLightDefaults; DECLARE_CLASS (ADynamicLight, AActor) public: virtual void Tick(); diff --git a/src/gl/utility/gl_cycler.cpp b/src/gl/utility/gl_cycler.cpp index b6d160925..d79770bf3 100644 --- a/src/gl/utility/gl_cycler.cpp +++ b/src/gl/utility/gl_cycler.cpp @@ -83,13 +83,23 @@ FCycler::FCycler() // //========================================================================== -void FCycler::SetParams(float start, float end, float cycle) +void FCycler::SetParams(float start, float end, float cycle, bool update) { - m_cycle = cycle; - m_time = 0.f; - m_start = m_current = start; + if (!update || cycle != m_cycle) + { + m_cycle = cycle; + m_time = 0.f; + m_increment = true; + m_current = start; + } + else + { + // When updating and keeping the same cycle, scale the current light size to the new dimensions. + float fact = (m_current - m_start) / (m_end - m_start); + m_current = start + fact *(end - start); + } + m_start = start; m_end = end; - m_increment = true; } diff --git a/src/gl/utility/gl_cycler.h b/src/gl/utility/gl_cycler.h index 42effce34..bcff7e9de 100644 --- a/src/gl/utility/gl_cycler.h +++ b/src/gl/utility/gl_cycler.h @@ -22,7 +22,7 @@ class FCycler public: FCycler(); void Update(float diff); - void SetParams(float start, float end, float cycle); + void SetParams(float start, float end, float cycle, bool update = false); void ShouldCycle(bool sc) { m_shouldCycle = sc; } void SetCycleType(CycleType ct) { m_cycleType = ct; } float GetVal() { return m_current; } From 821b10a254867350af85e4d273b50fc920ac4577 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 17 Dec 2016 04:11:52 -0500 Subject: [PATCH 1469/1509] - Implementing RGB666 colormatching to replace less precise RGB555 in some parts of the code. --- src/f_wipe.cpp | 29 +- src/r_draw.cpp | 12 +- src/r_draw.h | 1 - src/r_draw_pal.cpp | 436 +++++++++++++---------------- src/r_draw_pal.h | 6 + src/r_drawt_pal.cpp | 272 ++++++------------ src/r_plane.cpp | 16 +- src/r_things.cpp | 43 +-- src/r_things.h | 2 +- src/textures/ddstexture.cpp | 8 +- src/textures/jpegtexture.cpp | 4 +- src/textures/multipatchtexture.cpp | 2 +- src/textures/pcxtexture.cpp | 2 +- src/textures/pngtexture.cpp | 6 +- src/textures/tgatexture.cpp | 8 +- src/v_draw.cpp | 33 +-- src/v_video.cpp | 70 ++--- src/v_video.h | 41 +-- 18 files changed, 366 insertions(+), 625 deletions(-) diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index a3ceb8d50..8d5f072f6 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -28,6 +28,7 @@ #include "f_wipe.h" #include "c_cvars.h" #include "templates.h" +#include "v_palette.h" // // SCREEN WIPE PACKAGE @@ -299,12 +300,15 @@ bool wipe_doBurn (int ticks) else { int bglevel = 64-fglevel; - DWORD *fg2rgb = Col2RGB8[fglevel]; - DWORD *bg2rgb = Col2RGB8[bglevel]; - DWORD fg = fg2rgb[fromnew[x]]; - DWORD bg = bg2rgb[fromold[x]]; - fg = (fg+bg) | 0x1f07c1f; - to[x] = RGB32k.All[fg & (fg>>15)]; + + const PalEntry* pal = GPalette.BaseColors; + + DWORD fg = fromnew[x]; + DWORD bg = fromold[x]; + int r = MIN((pal[fg].r * fglevel + pal[bg].r * bglevel) >> 8, 63); + int g = MIN((pal[fg].g * fglevel + pal[bg].g * bglevel) >> 8, 63); + int b = MIN((pal[fg].b * fglevel + pal[bg].b * bglevel) >> 8, 63); + to[x] = RGB256k.RGB[r][g][b]; done = false; } } @@ -342,20 +346,21 @@ bool wipe_doFade (int ticks) { int x, y; int bglevel = 64 - fade; - DWORD *fg2rgb = Col2RGB8[fade]; - DWORD *bg2rgb = Col2RGB8[bglevel]; BYTE *fromnew = (BYTE *)wipe_scr_end; BYTE *fromold = (BYTE *)wipe_scr_start; BYTE *to = screen->GetBuffer(); + const PalEntry *pal = GPalette.BaseColors; for (y = 0; y < SCREENHEIGHT; y++) { for (x = 0; x < SCREENWIDTH; x++) { - DWORD fg = fg2rgb[fromnew[x]]; - DWORD bg = bg2rgb[fromold[x]]; - fg = (fg+bg) | 0x1f07c1f; - to[x] = RGB32k.All[fg & (fg>>15)]; + DWORD fg = fromnew[x]; + DWORD bg = fromold[x]; + int r = MIN((pal[fg].r * (64-bglevel) + pal[bg].r * bglevel) >> 8, 63); + int g = MIN((pal[fg].g * (64-bglevel) + pal[bg].g * bglevel) >> 8, 63); + int b = MIN((pal[fg].b * (64-bglevel) + pal[bg].b * bglevel) >> 8, 63); + to[x] = RGB256k.RGB[r][g][b]; } fromnew += SCREENWIDTH; fromold += SCREENWIDTH; diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 25297f6c8..20127f50d 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -238,22 +238,16 @@ namespace swrenderer } if (flags & STYLEF_InvertSource) { - dc_srcblend = Col2RGB8_Inverse[fglevel >> 10]; - dc_destblend = Col2RGB8_LessPrecision[bglevel >> 10]; dc_srcalpha = fglevel; dc_destalpha = bglevel; } else if (op == STYLEOP_Add && fglevel + bglevel <= FRACUNIT) { - dc_srcblend = Col2RGB8[fglevel >> 10]; - dc_destblend = Col2RGB8[bglevel >> 10]; dc_srcalpha = fglevel; dc_destalpha = bglevel; } else { - dc_srcblend = Col2RGB8_LessPrecision[fglevel >> 10]; - dc_destblend = Col2RGB8_LessPrecision[bglevel >> 10]; dc_srcalpha = fglevel; dc_destalpha = bglevel; } @@ -450,7 +444,7 @@ namespace swrenderer uint32_t g = GPART(color); uint32_t b = BPART(color); // dc_color is used by the rt_* routines. It is indexed into dc_srcblend. - dc_color = RGB32k.RGB[r >> 3][g >> 3][b >> 3]; + dc_color = RGB256k.RGB[r >> 2][g >> 2][b >> 2]; if (style.Flags & STYLEF_InvertSource) { r = 255 - r; @@ -1362,8 +1356,4 @@ namespace swrenderer } } - void R_DrawParticle(vissprite_t *sprite) - { - R_DrawParticle_C(sprite); - } } diff --git a/src/r_draw.h b/src/r_draw.h index ab430d2af..d9ad7a2da 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -203,5 +203,4 @@ namespace swrenderer void R_MapTiltedPlane(int y, int x1); void R_MapColoredPlane(int y, int x1); - void R_DrawParticle(vissprite_t *); } diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index cfb55a670..fe6c63b6d 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -4,6 +4,7 @@ **--------------------------------------------------------------------------- ** Copyright 1998-2016 Randy Heit ** Copyright 2016 Magnus Norddahl +** Copyright 2016 Rachael Alexanderson ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -314,10 +315,10 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { - uint32_t fg = fg2rgb[colormap[pix]]; - uint32_t bg = bg2rgb[*dest]; - fg = (fg + bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg >> 15)]; + uint32_t r = MIN(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 255); + uint32_t g = MIN(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 255); + uint32_t b = MIN(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 255); + *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; } frac += fracstep; dest += pitch; @@ -357,10 +358,10 @@ namespace swrenderer uint8_t pix = _bufplce[i][vplce[i] >> bits]; if (pix != 0) { - uint32_t fg = fg2rgb[_palookupoffse[i][pix]]; - uint32_t bg = bg2rgb[dest[i]]; - fg = (fg + bg) | 0x1f07c1f; - dest[i] = RGB32k.All[fg & (fg >> 15)]; + uint32_t r = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].r + GPalette.BaseColors[dest[i]].r, 255); + uint32_t g = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].g + GPalette.BaseColors[dest[i]].g, 255); + uint32_t b = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].b + GPalette.BaseColors[dest[i]].b, 255); + dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; } vplce[i] += vince[i]; } @@ -396,15 +397,10 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { - uint32_t a = fg2rgb[colormap[pix]] + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[a & (a >> 15)]; + uint32_t r = MIN(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 255); + uint32_t g = MIN(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 255); + uint32_t b = MIN(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 255); + *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; } frac += fracstep; dest += pitch; @@ -444,15 +440,10 @@ namespace swrenderer uint8_t pix = _bufplce[i][vplce[i] >> bits]; if (pix != 0) { - uint32_t a = fg2rgb[_palookupoffse[i][pix]] + bg2rgb[dest[i]]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[i] = RGB32k.All[a & (a >> 15)]; + uint32_t r = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].r + GPalette.BaseColors[dest[i]].r, 255); + uint32_t g = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].g + GPalette.BaseColors[dest[i]].g, 255); + uint32_t b = MIN(GPalette.BaseColors[_palookupoffse[i][pix]].b + GPalette.BaseColors[dest[i]].b, 255); + dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; } vplce[i] += vince[i]; } @@ -488,14 +479,10 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { - uint32_t a = (fg2rgb[colormap[pix]] | 0x40100400) - bg2rgb[*dest]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a >> 15)]; + int r = clamp(-GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 0, 255); + int g = clamp(-GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 0, 255); + int b = clamp(-GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 0, 255); + *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; } frac += fracstep; dest += pitch; @@ -535,14 +522,10 @@ namespace swrenderer uint8_t pix = _bufplce[i][vplce[i] >> bits]; if (pix != 0) { - uint32_t a = (fg2rgb[_palookupoffse[i][pix]] | 0x40100400) - bg2rgb[dest[i]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[i] = RGB32k.All[a & (a >> 15)]; + int r = clamp(-GPalette.BaseColors[_palookupoffse[i][pix]].r + GPalette.BaseColors[dest[i]].r, 0, 255); + int g = clamp(-GPalette.BaseColors[_palookupoffse[i][pix]].g + GPalette.BaseColors[dest[i]].g, 0, 255); + int b = clamp(-GPalette.BaseColors[_palookupoffse[i][pix]].b + GPalette.BaseColors[dest[i]].b, 0, 255); + dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; } vplce[i] += vince[i]; } @@ -578,14 +561,10 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { - uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[pix]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a >> 15)]; + int r = clamp(GPalette.BaseColors[colormap[pix]].r - GPalette.BaseColors[*dest].r, 0, 255); + int g = clamp(GPalette.BaseColors[colormap[pix]].g - GPalette.BaseColors[*dest].g, 0, 255); + int b = clamp(GPalette.BaseColors[colormap[pix]].b - GPalette.BaseColors[*dest].b, 0, 255); + *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; } frac += fracstep; dest += pitch; @@ -625,14 +604,10 @@ namespace swrenderer uint8_t pix = _bufplce[i][vplce[i] >> bits]; if (pix != 0) { - uint32_t a = (bg2rgb[dest[i]] | 0x40100400) - fg2rgb[_palookupoffse[i][pix]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[i] = RGB32k.All[a & (a >> 15)]; + uint32_t r = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].r - GPalette.BaseColors[dest[i]].r, 0, 255); + uint32_t g = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].g - GPalette.BaseColors[dest[i]].g, 0, 255); + uint32_t b = clamp(GPalette.BaseColors[_palookupoffse[i][pix]].b - GPalette.BaseColors[dest[i]].b, 0, 255); + dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; } vplce[i] += vince[i]; } @@ -716,7 +691,7 @@ namespace swrenderer c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; - *dest = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + *dest = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; } frac += fracstep; @@ -744,8 +719,8 @@ namespace swrenderer int solid_bottom_r = RPART(solid_bottom); int solid_bottom_g = GPART(solid_bottom); int solid_bottom_b = BPART(solid_bottom); - uint32_t solid_top_fill = RGB32k.RGB[(solid_top_r >> 3)][(solid_top_g >> 3)][(solid_top_b >> 3)]; - uint32_t solid_bottom_fill = RGB32k.RGB[(solid_bottom_r >> 3)][(solid_bottom_g >> 3)][(solid_bottom_b >> 3)]; + uint32_t solid_top_fill = RGB256k.RGB[(solid_top_r >> 2)][(solid_top_g >> 2)][(solid_top_b >> 2)]; + uint32_t solid_bottom_fill = RGB256k.RGB[(solid_bottom_r >> 2)][(solid_bottom_g >> 2)][(solid_bottom_b >> 2)]; solid_top_fill = (solid_top_fill << 24) | (solid_top_fill << 16) | (solid_top_fill << 8) | solid_top_fill; solid_bottom_fill = (solid_bottom_fill << 24) | (solid_bottom_fill << 16) | (solid_bottom_fill << 8) | solid_bottom_fill; @@ -805,8 +780,7 @@ namespace swrenderer c_red = (c_red * alpha_top + solid_top_r * inv_alpha_top) >> 8; c_green = (c_green * alpha_top + solid_top_g * inv_alpha_top) >> 8; c_blue = (c_blue * alpha_top + solid_top_b * inv_alpha_top) >> 8; - output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; - + output[col] = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; frac[col] += fracstep[col]; } *((uint32_t*)dest) = *((uint32_t*)output); @@ -847,7 +821,7 @@ namespace swrenderer c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; - output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + output[col] = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; frac[col] += fracstep[col]; } @@ -929,7 +903,7 @@ namespace swrenderer c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; - *dest = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + *dest = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; } frac += fracstep; @@ -959,8 +933,8 @@ namespace swrenderer int solid_bottom_r = RPART(solid_bottom); int solid_bottom_g = GPART(solid_bottom); int solid_bottom_b = BPART(solid_bottom); - uint32_t solid_top_fill = RGB32k.RGB[(solid_top_r >> 3)][(solid_top_g >> 3)][(solid_top_b >> 3)]; - uint32_t solid_bottom_fill = RGB32k.RGB[(solid_bottom_r >> 3)][(solid_bottom_g >> 3)][(solid_bottom_b >> 3)]; + uint32_t solid_top_fill = RGB256k.RGB[(solid_top_r >> 2)][(solid_top_g >> 2)][(solid_top_b >> 2)]; + uint32_t solid_bottom_fill = RGB256k.RGB[(solid_bottom_r >> 2)][(solid_bottom_g >> 2)][(solid_bottom_b >> 2)]; solid_top_fill = (solid_top_fill << 24) | (solid_top_fill << 16) | (solid_top_fill << 8) | solid_top_fill; solid_bottom_fill = (solid_bottom_fill << 24) | (solid_bottom_fill << 16) | (solid_bottom_fill << 8) | solid_bottom_fill; @@ -1026,7 +1000,7 @@ namespace swrenderer c_red = (c_red * alpha_top + solid_top_r * inv_alpha_top) >> 8; c_green = (c_green * alpha_top + solid_top_g * inv_alpha_top) >> 8; c_blue = (c_blue * alpha_top + solid_top_b * inv_alpha_top) >> 8; - output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + output[col] = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; frac[col] += fracstep[col]; } @@ -1080,7 +1054,7 @@ namespace swrenderer c_red = (c_red * alpha_bottom + solid_bottom_r * inv_alpha_bottom) >> 8; c_green = (c_green * alpha_bottom + solid_bottom_g * inv_alpha_bottom) >> 8; c_blue = (c_blue * alpha_bottom + solid_bottom_b * inv_alpha_bottom) >> 8; - output[col] = RGB32k.RGB[(c_red >> 3)][(c_green >> 3)][(c_blue >> 3)]; + output[col] = RGB256k.RGB[(c_red >> 2)][(c_green >> 2)][(c_blue >> 2)]; frac[col] += fracstep[col]; } @@ -1116,6 +1090,8 @@ namespace swrenderer _srcblend = dc_srcblend; _destblend = dc_destblend; _srccolor = dc_srccolor; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void DrawColumnPalCommand::Execute(DrawerThread *thread) @@ -1210,11 +1186,17 @@ namespace swrenderer dest = thread->dest_for_thread(_dest_y, pitch, dest); pitch *= thread->num_cores; + const PalEntry* pal = GPalette.BaseColors; + do { - uint32_t bg; - bg = (fg + bg2rgb[*dest]) | 0x1f07c1f; - *dest = RGB32k.All[bg & (bg >> 15)]; + int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; + int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; + int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; + int r = clamp((src_r + pal[*dest].r * _destalpha)>>18, 0, 255); + int g = clamp((src_g + pal[*dest].g * _destalpha)>>18, 0, 255); + int b = clamp((src_b + pal[*dest].b * _destalpha)>>18, 0, 255); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; } while (--count); @@ -1242,17 +1224,17 @@ namespace swrenderer dest = thread->dest_for_thread(_dest_y, pitch, dest); pitch *= thread->num_cores; + const PalEntry* pal = GPalette.BaseColors; + do { - uint32_t a = fg + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[a & (a >> 15)]; + int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; + int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; + int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; + int r = clamp((src_r + pal[*dest].r * _destalpha)>>18, 0, 255); + int g = clamp((src_g + pal[*dest].g * _destalpha)>>18, 0, 255); + int b = clamp((src_b + pal[*dest].b * _destalpha)>>18, 0, 255); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; } while (--count); } @@ -1265,11 +1247,7 @@ namespace swrenderer count = _count; dest = _dest; - uint32_t *bg2rgb; - uint32_t fg; - bg2rgb = _destblend; - fg = _srccolor | 0x40100400; int pitch = _pitch; count = thread->count_for_thread(_dest_y, count); @@ -1279,16 +1257,19 @@ namespace swrenderer dest = thread->dest_for_thread(_dest_y, pitch, dest); pitch *= thread->num_cores; + const PalEntry* palette = GPalette.BaseColors; + do { - uint32_t a = fg - bg2rgb[*dest]; - uint32_t b = a; + int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; + int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; + int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; + int bg = *dest; + int r = MAX((src_r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((src_g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((src_b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a >> 15)]; + *dest = RGB256k.RGB[r][g][b]; dest += pitch; } while (--count); } @@ -1303,11 +1284,7 @@ namespace swrenderer return; dest = _dest; - uint32_t *bg2rgb; - uint32_t fg; - bg2rgb = _destblend; - fg = _srccolor; int pitch = _pitch; count = thread->count_for_thread(_dest_y, count); @@ -1317,16 +1294,19 @@ namespace swrenderer dest = thread->dest_for_thread(_dest_y, pitch, dest); pitch *= thread->num_cores; + const PalEntry *palette = GPalette.BaseColors; + do { - uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg; - uint32_t b = a; + int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; + int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; + int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; + int bg = *dest; + int r = MAX((src_r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((src_g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((src_b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a >> 15)]; + *dest = RGB256k.RGB[r][g][b]; dest += pitch; } while (--count); } @@ -1354,20 +1334,18 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; const uint8_t *colormap = _colormap; const uint8_t *source = _source; + const PalEntry *palette = GPalette.BaseColors; do { uint32_t fg = colormap[source[frac >> FRACBITS]]; uint32_t bg = *dest; - - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg >> 15)]; + uint32_t r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + uint32_t g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + uint32_t b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1434,21 +1412,20 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; const uint8_t *translation = _translation; const uint8_t *colormap = _colormap; const uint8_t *source = _source; + const PalEntry *palette = GPalette.BaseColors; + do { uint32_t fg = colormap[translation[source[frac >> FRACBITS]]]; uint32_t bg = *dest; - - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg >> 15)]; + uint32_t r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + uint32_t g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + uint32_t b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1478,14 +1455,17 @@ namespace swrenderer const uint8_t *source = _source; const uint8_t *colormap = _colormap; - uint32_t *fgstart = &Col2RGB8[0][_color]; + + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t val = colormap[source[frac >> FRACBITS]]; - uint32_t fg = fgstart[val << 8]; - val = (Col2RGB8[64 - val][*dest] + fg) | 0x1f07c1f; - *dest = RGB32k.All[val & (val >> 15)]; + uint32_t val = source[frac >> FRACBITS]; + + int r = (palette[*dest].r * (255-val) + palette[_color].r * val) >> 10; + int g = (palette[*dest].g * (255-val) + palette[_color].g * val) >> 10; + int b = (palette[*dest].b * (255-val) + palette[_color].b * val) >> 10; + *dest = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; dest += pitch; frac += fracstep; @@ -1517,20 +1497,16 @@ namespace swrenderer const uint8_t *colormap = _colormap; const uint8_t *source = _source; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = fg2rgb[colormap[source[frac >> FRACBITS]]] + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[a & (a >> 15)]; + int fg = colormap[source[frac >> FRACBITS]]; + int bg = *dest; + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1562,20 +1538,16 @@ namespace swrenderer const uint8_t *translation = _translation; const uint8_t *colormap = _colormap; const uint8_t *source = _source; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = fg2rgb[colormap[translation[source[frac >> FRACBITS]]]] + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[(a >> 15) & a]; + int fg = colormap[translation[source[frac >> FRACBITS]]]; + int bg = *dest; + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1606,19 +1578,16 @@ namespace swrenderer const uint8_t *colormap = _colormap; const uint8_t *source = _source; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (fg2rgb[colormap[source[frac >> FRACBITS]]] | 0x40100400) - bg2rgb[*dest]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a >> 15)]; + int fg = colormap[source[frac >> FRACBITS]]; + int bg = *dest; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1650,19 +1619,16 @@ namespace swrenderer const uint8_t *translation = _translation; const uint8_t *colormap = _colormap; const uint8_t *source = _source; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (fg2rgb[colormap[translation[source[frac >> FRACBITS]]]] | 0x40100400) - bg2rgb[*dest]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[(a >> 15) & a]; + int fg = colormap[translation[source[frac >> FRACBITS]]]; + int bg = *dest; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1693,19 +1659,16 @@ namespace swrenderer const uint8_t *colormap = _colormap; const uint8_t *source = _source; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[source[frac >> FRACBITS]]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[a & (a >> 15)]; + int fg = colormap[source[frac >> FRACBITS]]; + int bg = *dest; + int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1737,19 +1700,16 @@ namespace swrenderer const uint8_t *translation = _translation; const uint8_t *colormap = _colormap; const uint8_t *source = _source; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[translation[source[frac >> FRACBITS]]]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[(a >> 15) & a]; + int fg = colormap[translation[source[frac >> FRACBITS]]]; + int bg = *dest; + int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; } while (--count); @@ -1865,6 +1825,8 @@ namespace swrenderer _srcblend = dc_srcblend; _destblend = dc_destblend; _color = ds_color; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; } void DrawSpanPalCommand::Execute(DrawerThread *thread) @@ -2010,8 +1972,6 @@ namespace swrenderer const uint8_t *colormap = _colormap; int count; int spot; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; xfrac = _xfrac; yfrac = _yfrac; @@ -2023,6 +1983,8 @@ namespace swrenderer xstep = _xstep; ystep = _ystep; + const PalEntry *palette = GPalette.BaseColors; + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. @@ -2031,10 +1993,11 @@ namespace swrenderer spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); uint32_t fg = colormap[source[spot]]; uint32_t bg = *dest; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest++ = RGB32k.All[fg & (fg >> 15)]; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest++ = RGB256k.RGB[r][g][b]; + xfrac += xstep; yfrac += ystep; } while (--count); @@ -2049,10 +2012,11 @@ namespace swrenderer spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); uint32_t fg = colormap[source[spot]]; uint32_t bg = *dest; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest++ = RGB32k.All[fg & (fg >> 15)]; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest++ = RGB256k.RGB[r][g][b]; + xfrac += xstep; yfrac += ystep; } while (--count); @@ -2073,8 +2037,8 @@ namespace swrenderer const uint8_t *colormap = _colormap; int count; int spot; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + + const PalEntry *palette = GPalette.BaseColors; xfrac = _xfrac; yfrac = _yfrac; @@ -2099,10 +2063,10 @@ namespace swrenderer { uint32_t fg = colormap[texdata]; uint32_t bg = *dest; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg >> 15)]; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; } dest++; xfrac += xstep; @@ -2124,10 +2088,10 @@ namespace swrenderer { uint32_t fg = colormap[texdata]; uint32_t bg = *dest; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg >> 15)]; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; } dest++; xfrac += xstep; @@ -2150,8 +2114,7 @@ namespace swrenderer const uint8_t *colormap = _colormap; int count; int spot; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; xfrac = _xfrac; yfrac = _yfrac; @@ -2169,15 +2132,13 @@ namespace swrenderer do { spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; - uint32_t b = a; + uint32_t fg = colormap[source[spot]]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest++ = RGB256k.RGB[r][g][b]; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest++ = RGB32k.All[a & (a >> 15)]; xfrac += xstep; yfrac += ystep; } while (--count); @@ -2190,15 +2151,13 @@ namespace swrenderer do { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; - uint32_t b = a; + uint32_t fg = colormap[source[spot]]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest++ = RGB256k.RGB[r][g][b]; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest++ = RGB32k.All[a & (a >> 15)]; xfrac += xstep; yfrac += ystep; } while (--count); @@ -2219,8 +2178,7 @@ namespace swrenderer const uint8_t *colormap = _colormap; int count; int spot; - uint32_t *fg2rgb = _srcblend; - uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; xfrac = _xfrac; yfrac = _yfrac; @@ -2243,15 +2201,12 @@ namespace swrenderer texdata = source[spot]; if (texdata != 0) { - uint32_t a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[a & (a >> 15)]; + uint32_t fg = colormap[texdata]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; } dest++; xfrac += xstep; @@ -2271,15 +2226,12 @@ namespace swrenderer texdata = source[spot]; if (texdata != 0) { - uint32_t a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[a & (a >> 15)]; + uint32_t fg = colormap[texdata]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; } dest++; xfrac += xstep; diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index f2b1f0571..0b1a5eebf 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -106,6 +106,8 @@ namespace swrenderer uint32_t *_srcblend; uint32_t *_destblend; uint32_t _srccolor; + fixed_t _srcalpha; + fixed_t _destalpha; }; class DrawColumnPalCommand : public PalColumnCommand { public: void Execute(DrawerThread *thread) override; }; @@ -164,6 +166,8 @@ namespace swrenderer uint32_t *_srcblend; uint32_t *_destblend; int _color; + fixed_t _srcalpha; + fixed_t _destalpha; }; class DrawSpanPalCommand : public PalSpanCommand { public: void Execute(DrawerThread *thread) override; }; @@ -303,6 +307,8 @@ namespace swrenderer const uint32_t *_srcblend; const uint32_t *_destblend; const uint8_t *_translation; + fixed_t _srcalpha; + fixed_t _destalpha; int _color; }; diff --git a/src/r_drawt_pal.cpp b/src/r_drawt_pal.cpp index 3356592d2..e2af7bbf1 100644 --- a/src/r_drawt_pal.cpp +++ b/src/r_drawt_pal.cpp @@ -4,6 +4,8 @@ ** **--------------------------------------------------------------------------- ** Copyright 1998-2006 Randy Heit +** Copyright 2016 Magnus Norddahl +** Copyright 2016 Rachael Alexanderson ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -173,6 +175,8 @@ namespace swrenderer _colormap = dc_colormap; _srcblend = dc_srcblend; _destblend = dc_destblend; + _srcalpha = dc_srcalpha; + _destalpha = dc_destalpha; _translation = dc_translation; _color = dc_color; } @@ -440,21 +444,20 @@ namespace swrenderer if (count <= 0) return; - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { uint32_t fg = colormap[*source]; uint32_t bg = *dest; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg>>15)]; + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; source += 4; dest += pitch; } while (--count); @@ -472,42 +475,22 @@ namespace swrenderer if (count <= 0) return; - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t fg = colormap[source[0]]; - uint32_t bg = dest[0]; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - dest[0] = RGB32k.All[fg & (fg>>15)]; - - fg = colormap[source[1]]; - bg = dest[1]; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - dest[1] = RGB32k.All[fg & (fg>>15)]; - - - fg = colormap[source[2]]; - bg = dest[2]; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - dest[2] = RGB32k.All[fg & (fg>>15)]; - - fg = colormap[source[3]]; - bg = dest[3]; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - dest[3] = RGB32k.All[fg & (fg>>15)]; + for (int ks = 0; ks < 4; ks++) + { // [SP] this 4col function was a block of copy-pasted code. 4 times. I regret nothing. + uint32_t fg = colormap[source[ks]]; + uint32_t bg = dest[ks]; + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + dest[ks] = RGB256k.RGB[r][g][b]; + } source += 4; dest += pitch; @@ -527,17 +510,18 @@ namespace swrenderer if (count <= 0) return; - fgstart = &Col2RGB8[0][_color]; colormap = _colormap; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t val = colormap[*source]; - uint32_t fg = fgstart[val<<8]; - val = (Col2RGB8[64-val][*dest] + fg) | 0x1f07c1f; - *dest = RGB32k.All[val & (val>>15)]; + uint32_t val = *source; + int r = (palette[*dest].r * (255-val) + palette[_color].r * val) >> 10; + int g = (palette[*dest].g * (255-val) + palette[_color].g * val) >> 10; + int b = (palette[*dest].b * (255-val) + palette[_color].b * val) >> 10; + *dest = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; source += 4; dest += pitch; } while (--count); @@ -556,30 +540,23 @@ namespace swrenderer if (count <= 0) return; - fgstart = &Col2RGB8[0][_color]; colormap = _colormap; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; pitch = _pitch * thread->num_cores; + const PalEntry *palette = GPalette.BaseColors; do { uint32_t val; - - val = colormap[source[0]]; - val = (Col2RGB8[64-val][dest[0]] + fgstart[val<<8]) | 0x1f07c1f; - dest[0] = RGB32k.All[val & (val>>15)]; - val = colormap[source[1]]; - val = (Col2RGB8[64-val][dest[1]] + fgstart[val<<8]) | 0x1f07c1f; - dest[1] = RGB32k.All[val & (val>>15)]; - - val = colormap[source[2]]; - val = (Col2RGB8[64-val][dest[2]] + fgstart[val<<8]) | 0x1f07c1f; - dest[2] = RGB32k.All[val & (val>>15)]; - - val = colormap[source[3]]; - val = (Col2RGB8[64-val][dest[3]] + fgstart[val<<8]) | 0x1f07c1f; - dest[3] = RGB32k.All[val & (val>>15)]; + for (int ks = 0; ks < 4; ks++) + { + val = source[ks]; + int r = (palette[dest[ks]].r * (255-val) + palette[_color].r * val) >> 10; + int g = (palette[dest[ks]].g * (255-val) + palette[_color].g * val) >> 10; + int b = (palette[dest[ks]].b * (255-val) + palette[_color].b * val) >> 10; + dest[ks] = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; + } source += 4; dest += pitch; @@ -598,23 +575,19 @@ namespace swrenderer if (count <= 0) return; - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = fg2rgb[colormap[*source]] + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[(a>>15) & a]; + int fg = colormap[*source]; + int bg = *dest; + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; source += 4; dest += pitch; } while (--count); @@ -636,47 +609,18 @@ namespace swrenderer source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; pitch = _pitch * thread->num_cores; colormap = _colormap; - - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = fg2rgb[colormap[source[0]]] + bg2rgb[dest[0]]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[0] = RGB32k.All[(a>>15) & a]; - - a = fg2rgb[colormap[source[1]]] + bg2rgb[dest[1]]; - b = a; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[1] = RGB32k.All[(a>>15) & a]; - - a = fg2rgb[colormap[source[2]]] + bg2rgb[dest[2]]; - b = a; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[2] = RGB32k.All[(a>>15) & a]; - - a = fg2rgb[colormap[source[3]]] + bg2rgb[dest[3]]; - b = a; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[3] = RGB32k.All[(a>>15) & a]; + for (int ks = 0; ks < 4; ks++) + { + int fg = colormap[source[ks]]; + int bg = dest[ks]; + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + dest[ks] = RGB256k.RGB[r][g][b]; + } source += 4; dest += pitch; @@ -701,16 +645,15 @@ namespace swrenderer source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (fg2rgb[colormap[*source]] | 0x40100400) - bg2rgb[*dest]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[(a>>15) & a]; + int fg = colormap[*source]; + int bg = *dest; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; source += 4; dest += pitch; } while (--count); @@ -734,40 +677,18 @@ namespace swrenderer source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (fg2rgb[colormap[source[0]]] | 0x40100400) - bg2rgb[dest[0]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[0] = RGB32k.All[(a>>15) & a]; - - a = (fg2rgb[colormap[source[1]]] | 0x40100400) - bg2rgb[dest[1]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[1] = RGB32k.All[(a>>15) & a]; - - a = (fg2rgb[colormap[source[2]]] | 0x40100400) - bg2rgb[dest[2]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[2] = RGB32k.All[(a>>15) & a]; - - a = (fg2rgb[colormap[source[3]]] | 0x40100400) - bg2rgb[dest[3]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[3] = RGB32k.All[(a>>15) & a]; + for (int ks = 0; ks < 4; ks++) + { + int fg = colormap[source[ks]]; + int bg = dest[ks]; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + dest[ks] = RGB256k.RGB[r][g][b]; + } source += 4; dest += pitch; @@ -792,16 +713,15 @@ namespace swrenderer source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[*source]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[(a>>15) & a]; + int fg = colormap[*source]; + int bg = *dest; + int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; source += 4; dest += pitch; } while (--count); @@ -825,40 +745,18 @@ namespace swrenderer source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; pitch = _pitch * thread->num_cores; colormap = _colormap; + const PalEntry *palette = GPalette.BaseColors; do { - uint32_t a = (bg2rgb[dest[0]] | 0x40100400) - fg2rgb[colormap[source[0]]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[0] = RGB32k.All[(a>>15) & a]; - - a = (bg2rgb[dest[1]] | 0x40100400) - fg2rgb[colormap[source[1]]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[1] = RGB32k.All[(a>>15) & a]; - - a = (bg2rgb[dest[2]] | 0x40100400) - fg2rgb[colormap[source[2]]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[2] = RGB32k.All[(a>>15) & a]; - - a = (bg2rgb[dest[3]] | 0x40100400) - fg2rgb[colormap[source[3]]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[3] = RGB32k.All[(a>>15) & a]; + for (int ks = 0; ks < 4; ks++) + { + int fg = colormap[source[ks]]; + int bg = dest[ks]; + int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + dest[ks] = RGB256k.RGB[r][g][b]; + } source += 4; dest += pitch; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index cd378aec1..865517dd1 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1509,14 +1509,14 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t if (!additive) { spanfunc = R_DrawSpanMaskedTranslucent; - dc_srcblend = Col2RGB8[alpha>>10]; - dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE-alpha; } else { spanfunc = R_DrawSpanMaskedAddClamp; - dc_srcblend = Col2RGB8_LessPrecision[alpha>>10]; - dc_destblend = Col2RGB8_LessPrecision[FRACUNIT>>10]; + dc_srcalpha = alpha; + dc_destalpha = FRACUNIT; } } else @@ -1531,14 +1531,14 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t if (!additive) { spanfunc = R_DrawSpanTranslucent; - dc_srcblend = Col2RGB8[alpha>>10]; - dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE-alpha; } else { spanfunc = R_DrawSpanAddClamp; - dc_srcblend = Col2RGB8_LessPrecision[alpha>>10]; - dc_destblend = Col2RGB8_LessPrecision[FRACUNIT>>10]; + dc_srcalpha = alpha; + dc_destalpha = FRACUNIT; } } else diff --git a/src/r_things.cpp b/src/r_things.cpp index a1ace0d49..61da979da 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2636,12 +2636,12 @@ static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) } } -void R_DrawParticle_C (vissprite_t *vis) +//inline int clamp(int x, int y, int z) { return ((x < y) ? x : (z < y) ? z : y); } + +void R_DrawParticle (vissprite_t *vis) { - DWORD *bg2rgb; int spacing; BYTE *dest; - DWORD fg; BYTE color = vis->Style.colormap[vis->startfrac]; int yl = vis->y1; int ycount = vis->y2 - yl + 1; @@ -2653,33 +2653,10 @@ void R_DrawParticle_C (vissprite_t *vis) DrawerCommandQueue::WaitForWorkers(); // vis->renderflags holds translucency level (0-255) - { - fixed_t fglevel, bglevel; - DWORD *fg2rgb; + fixed_t fglevel, bglevel; - fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff; - bglevel = FRACUNIT-fglevel; - fg2rgb = Col2RGB8[fglevel>>10]; - bg2rgb = Col2RGB8[bglevel>>10]; - fg = fg2rgb[color]; - } - - /* - - spacing = RenderTarget->GetPitch() - countbase; - dest = ylookup[yl] + x1 + dc_destorg; - - do - { - int count = countbase; - do - { - DWORD bg = bg2rgb[*dest]; - bg = (fg+bg) | 0x1f07c1f; - *dest++ = RGB32k.All[bg & (bg>>15)]; - } while (--count); - dest += spacing; - } while (--ycount);*/ + fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff; + bglevel = FRACUNIT-fglevel; // original was row-wise // width = countbase @@ -2695,9 +2672,11 @@ void R_DrawParticle_C (vissprite_t *vis) dest = ylookup[yl] + x + dc_destorg; for (int y = 0; y < ycount; y++) { - DWORD bg = bg2rgb[*dest]; - bg = (fg+bg) | 0x1f07c1f; - *dest = RGB32k.All[bg & (bg>>15)]; + uint32_t dest_r = MIN((GPalette.BaseColors[*dest].r * bglevel + GPalette.BaseColors[color].r * fglevel) >> 18, 63); + uint32_t dest_g = MIN((GPalette.BaseColors[*dest].g * bglevel + GPalette.BaseColors[color].g * fglevel) >> 18, 63); + uint32_t dest_b = MIN((GPalette.BaseColors[*dest].b * bglevel + GPalette.BaseColors[color].b * fglevel) >> 18, 63); + + *dest = RGB256k.RGB[dest_r][dest_g][dest_b]; dest += spacing; } } diff --git a/src/r_things.h b/src/r_things.h index 6d694b8fd..740af279a 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -101,7 +101,7 @@ struct vissprite_t vissprite_t() {} }; -void R_DrawParticle_C (vissprite_t *); +void R_DrawParticle (vissprite_t *); void R_ProjectParticle (particle_t *, const sector_t *sector, int shade, int fakeside); extern int MaxVisSprites; diff --git a/src/textures/ddstexture.cpp b/src/textures/ddstexture.cpp index 31e748022..a2c69b38b 100644 --- a/src/textures/ddstexture.cpp +++ b/src/textures/ddstexture.cpp @@ -551,7 +551,7 @@ void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf) DWORD r = (c & RMask) << RShiftL; r |= r >> RShiftR; DWORD g = (c & GMask) << GShiftL; g |= g >> GShiftR; DWORD b = (c & BMask) << BShiftL; b |= b >> BShiftR; - *pixelp = RGB32k.RGB[r >> 27][g >> 27][b >> 27]; + *pixelp = RGB256k.RGB[r >> 26][g >> 26][b >> 26]; } else { @@ -637,7 +637,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf) // Pick colors from the palette for each of the four colors. /*if (!tcbuf)*/ for (i = 3; i >= 0; --i) { - palcol[i] = color[i].a ? RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3] : 0; + palcol[i] = color[i].a ? RGB256k.RGB[color[i].r >> 2][color[i].g >> 2][color[i].b >> 2] : 0; } // Now decode this 4x4 block to the pixel buffer. for (y = 0; y < 4; ++y) @@ -717,7 +717,7 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu // Pick colors from the palette for each of the four colors. if (!tcbuf) for (i = 3; i >= 0; --i) { - palcol[i] = RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3]; + palcol[i] = RGB256k.RGB[color[i].r >> 2][color[i].g >> 2][color[i].b >> 2]; } // Now decode this 4x4 block to the pixel buffer. for (y = 0; y < 4; ++y) @@ -822,7 +822,7 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu // Pick colors from the palette for each of the four colors. if (!tcbuf) for (i = 3; i >= 0; --i) { - palcol[i] = RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3]; + palcol[i] = RGB256k.RGB[color[i].r >> 2][color[i].g >> 2][color[i].b >> 2]; } // Now decode this 4x4 block to the pixel buffer. for (y = 0; y < 4; ++y) diff --git a/src/textures/jpegtexture.cpp b/src/textures/jpegtexture.cpp index 225396598..c138edbfa 100644 --- a/src/textures/jpegtexture.cpp +++ b/src/textures/jpegtexture.cpp @@ -406,7 +406,7 @@ void FJPEGTexture::MakeTexture () case JCS_RGB: for (int x = Width; x > 0; --x) { - *out = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; + *out = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; out += Height; in += 3; } @@ -430,7 +430,7 @@ void FJPEGTexture::MakeTexture () int r = in[3] - (((256-in[0])*in[3]) >> 8); int g = in[3] - (((256-in[1])*in[3]) >> 8); int b = in[3] - (((256-in[2])*in[3]) >> 8); - *out = RGB32k.RGB[r >> 3][g >> 3][b >> 3]; + *out = RGB256k.RGB[r >> 2][g >> 2][b >> 2]; out += Height; in += 4; } diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index e68c4e20f..991893845 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -531,7 +531,7 @@ void FMultiPatchTexture::MakeTexture () { if (*out == 0 && in[3] != 0) { - *out = RGB32k.RGB[in[2]>>3][in[1]>>3][in[0]>>3]; + *out = RGB256k.RGB[in[2]>>2][in[1]>>2][in[0]>>2]; } out += Height; in += 4; diff --git a/src/textures/pcxtexture.cpp b/src/textures/pcxtexture.cpp index 0ec5d2933..dda431993 100644 --- a/src/textures/pcxtexture.cpp +++ b/src/textures/pcxtexture.cpp @@ -528,7 +528,7 @@ void FPCXTexture::MakeTexture() { for(int x=0; x < Width; x++) { - Pixels[y+Height*x] = RGB32k.RGB[row[0]>>3][row[1]>>3][row[2]>>3]; + Pixels[y+Height*x] = RGB256k.RGB[row[0]>>2][row[1]>>2][row[2]>>2]; row+=3; } } diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index d24cd92d1..414c424b8 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -536,7 +536,7 @@ void FPNGTexture::MakeTexture () { if (!HaveTrans) { - *out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; + *out++ = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; } else { @@ -548,7 +548,7 @@ void FPNGTexture::MakeTexture () } else { - *out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; + *out++ = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; } } in += pitch; @@ -593,7 +593,7 @@ void FPNGTexture::MakeTexture () { for (y = Height; y > 0; --y) { - *out++ = in[3] < 128 ? 0 : RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; + *out++ = in[3] < 128 ? 0 : RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; in += pitch; } in -= backstep; diff --git a/src/textures/tgatexture.cpp b/src/textures/tgatexture.cpp index b208a51a3..331747cfe 100644 --- a/src/textures/tgatexture.cpp +++ b/src/textures/tgatexture.cpp @@ -393,7 +393,7 @@ void FTGATexture::MakeTexture () for(int x=0;x>10) & 0x1f][(v>>5) & 0x1f][v & 0x1f]; + Pixels[x*Height+y] = RGB256k.RGB[((v>>10) & 0x1f)*2][((v>>5) & 0x1f)*2][(v & 0x1f)*2]; p+=step_x; } } @@ -405,7 +405,7 @@ void FTGATexture::MakeTexture () BYTE * p = ptr + y * Pitch; for(int x=0;x>3][p[1]>>3][p[0]>>3]; + Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2]; p+=step_x; } } @@ -419,7 +419,7 @@ void FTGATexture::MakeTexture () BYTE * p = ptr + y * Pitch; for(int x=0;x>3][p[1]>>3][p[0]>>3]; + Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2]; p+=step_x; } } @@ -431,7 +431,7 @@ void FTGATexture::MakeTexture () BYTE * p = ptr + y * Pitch; for(int x=0;x= 128? RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3] : 0; + Pixels[x*Height+y] = p[3] >= 128? RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2] : 0; p+=step_x; } } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 6f8bc5198..5f0d39d4f 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -965,27 +965,6 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) static int oldyy; static int oldyyshifted; -#if 0 - if(xx < 32) - cc += 7-(xx>>2); - else if(xx > (finit_width - 32)) - cc += 7-((finit_width-xx) >> 2); -// if(cc==oldcc) //make sure that we don't double fade the corners. -// { - if(yy < 32) - cc += 7-(yy>>2); - else if(yy > (finit_height - 32)) - cc += 7-((finit_height-yy) >> 2); -// } - if(cc > cm && cm != NULL) - { - cc = cm; - } - else if(cc > oldcc+6) // don't let the color escape from the fade table... - { - cc=oldcc+6; - } -#endif if (yy == oldyy+1) { oldyy++; @@ -1003,12 +982,12 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) } BYTE *spot = GetBuffer() + oldyyshifted + xx; - DWORD *bg2rgb = Col2RGB8[1+level]; - DWORD *fg2rgb = Col2RGB8[63-level]; - DWORD fg = fg2rgb[basecolor]; - DWORD bg = bg2rgb[*spot]; - bg = (fg+bg) | 0x1f07c1f; - *spot = RGB32k.All[bg&(bg>>15)]; + + uint32_t r = (GPalette.BaseColors[*spot].r * (64 - level) + GPalette.BaseColors[basecolor].r * level) / 64; + uint32_t g = (GPalette.BaseColors[*spot].g * (64 - level) + GPalette.BaseColors[basecolor].g * level) / 64; + uint32_t b = (GPalette.BaseColors[*spot].b * (64 - level) + GPalette.BaseColors[basecolor].b * level) / 64; + + *spot = (BYTE)RGB256k.RGB[r][g][b]; } void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 realcolor) diff --git a/src/v_video.cpp b/src/v_video.cpp index efe93aa04..b639939ee 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -143,9 +143,10 @@ extern "C" { DWORD Col2RGB8[65][256]; DWORD *Col2RGB8_LessPrecision[65]; DWORD Col2RGB8_Inverse[65][256]; -ColorTable32k RGB32k; +ColorTable256k RGB256k; } + static DWORD Col2RGB8_2[63][256]; // [RH] The framebuffer is no longer a mere byte array. @@ -345,8 +346,6 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) if (damount == 0.f) return; - DWORD *bg2rgb; - DWORD fg; int gap; BYTE *spot; int x, y; @@ -368,28 +367,23 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) return; } - { - int amount; - - amount = (int)(damount * 64); - bg2rgb = Col2RGB8[64-amount]; - - fg = (((color.r * amount) >> 4) << 20) | - ((color.g * amount) >> 4) | - (((color.b * amount) >> 4) << 10); - } spot = Buffer + x1 + y1*Pitch; gap = Pitch - w; + + int alpha = (int)((float)64 * damount); + int ialpha = 64 - alpha; + int dimmedcolor_r = color.r * alpha; + int dimmedcolor_g = color.g * alpha; + int dimmedcolor_b = color.b * alpha; for (y = h; y != 0; y--) { for (x = w; x != 0; x--) { - DWORD bg; - - bg = bg2rgb[(*spot)&0xff]; - bg = (fg+bg) | 0x1f07c1f; - *spot = RGB32k.All[bg&(bg>>15)]; + uint32_t r = (dimmedcolor_r + GPalette.BaseColors[*spot].r * ialpha) >> 8; + uint32_t g = (dimmedcolor_g + GPalette.BaseColors[*spot].g * ialpha) >> 8; + uint32_t b = (dimmedcolor_b + GPalette.BaseColors[*spot].b * ialpha) >> 8; + *spot = (BYTE)RGB256k.RGB[r][g][b]; spot++; } spot += gap; @@ -664,42 +658,12 @@ static void BuildTransTable (const PalEntry *palette) { int r, g, b; - // create the RGB555 lookup table - for (r = 0; r < 32; r++) - for (g = 0; g < 32; g++) - for (b = 0; b < 32; b++) - RGB32k.RGB[r][g][b] = ColorMatcher.Pick ((r<<3)|(r>>2), (g<<3)|(g>>2), (b<<3)|(b>>2)); + // create the RGB666 lookup table + for (r = 0; r < 64; r++) + for (g = 0; g < 64; g++) + for (b = 0; b < 64; b++) + RGB256k.RGB[r][g][b] = ColorMatcher.Pick ((r<<2)|(r>>4), (g<<2)|(g>>4), (b<<2)|(b>>4)); - int x, y; - - // create the swizzled palette - for (x = 0; x < 65; x++) - for (y = 0; y < 256; y++) - Col2RGB8[x][y] = (((palette[y].r*x)>>4)<<20) | - ((palette[y].g*x)>>4) | - (((palette[y].b*x)>>4)<<10); - - // create the swizzled palette with the lsb of red and blue forced to 0 - // (for green, a 1 is okay since it never gets added into) - for (x = 1; x < 64; x++) - { - Col2RGB8_LessPrecision[x] = Col2RGB8_2[x-1]; - for (y = 0; y < 256; y++) - { - Col2RGB8_2[x-1][y] = Col2RGB8[x][y] & 0x3feffbff; - } - } - Col2RGB8_LessPrecision[0] = Col2RGB8[0]; - Col2RGB8_LessPrecision[64] = Col2RGB8[64]; - - // create the inverse swizzled palette - for (x = 0; x < 65; x++) - for (y = 0; y < 256; y++) - { - Col2RGB8_Inverse[x][y] = (((((255-palette[y].r)*x)>>4)<<20) | - (((255-palette[y].g)*x)>>4) | - ((((255-palette[y].b)*x)>>4)<<10)) & 0x3feffbff; - } } //========================================================================== diff --git a/src/v_video.h b/src/v_video.h index b72f67094..0da6b9b50 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -448,44 +448,13 @@ EXTERN_CVAR (Float, Gamma) // Translucency tables -// RGB32k is a normal R5G5B5 -> palette lookup table. - -// Use a union so we can "overflow" without warnings. -// Otherwise, we get stuff like this from Clang (when compiled -// with -fsanitize=bounds) while running: -// src/v_video.cpp:390:12: runtime error: index 1068 out of bounds for type 'BYTE [32]' -// src/r_draw.cpp:273:11: runtime error: index 1057 out of bounds for type 'BYTE [32]' -union ColorTable32k +// [SP] RGB666 support +union ColorTable256k { - BYTE RGB[32][32][32]; - BYTE All[32 *32 *32]; + BYTE RGB[64][64][64]; + BYTE All[64 *64 *64]; }; -extern "C" ColorTable32k RGB32k; - -// Col2RGB8 is a pre-multiplied palette for color lookup. It is stored in a -// special R10B10G10 format for efficient blending computation. -// --RRRRRrrr--BBBBBbbb--GGGGGggg-- at level 64 -// --------rrrr------bbbb------gggg at level 1 -extern "C" DWORD Col2RGB8[65][256]; - -// Col2RGB8_LessPrecision is the same as Col2RGB8, but the LSB for red -// and blue are forced to zero, so if the blend overflows, it won't spill -// over into the next component's value. -// --RRRRRrrr-#BBBBBbbb-#GGGGGggg-- at level 64 -// --------rrr#------bbb#------gggg at level 1 -extern "C" DWORD *Col2RGB8_LessPrecision[65]; - -// Col2RGB8_Inverse is the same as Col2RGB8_LessPrecision, except the source -// palette has been inverted. -extern "C" DWORD Col2RGB8_Inverse[65][256]; - -// "Magic" numbers used during the blending: -// --000001111100000111110000011111 = 0x01f07c1f -// -0111111111011111111101111111111 = 0x3FEFFBFF -// -1000000000100000000010000000000 = 0x40100400 -// ------10000000001000000000100000 = 0x40100400 >> 5 -// --11111-----11111-----11111----- = 0x40100400 - (0x40100400 >> 5) aka "white" -// --111111111111111111111111111111 = 0x3FFFFFFF +extern "C" ColorTable256k RGB256k; // Allocates buffer screens, call before R_Init. void V_Init (bool restart); From 2bb2395569701dafade073d41da83fec4cf70300 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 23 Dec 2016 23:44:52 +0100 Subject: [PATCH 1470/1509] Add menu option to enable dynamic lights (independent of the OpenGL setting so that you can have it on in OpenGL and off in Software) --- src/r_draw.cpp | 2 + src/r_draw.h | 1 + src/r_plane.cpp | 90 ++++++++++++++++++--------------- src/r_walldraw.cpp | 101 ++++++++++++++++++++----------------- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.txt | 1 + 6 files changed, 109 insertions(+), 87 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 2968ed374..dabc97ff2 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -53,6 +53,8 @@ #include "r_draw_pal.h" #include "r_thread.h" +CVAR(Bool, r_dynlights, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); + namespace swrenderer { // Needed by R_DrawFogBoundary (which probably shouldn't be part of this file) diff --git a/src/r_draw.h b/src/r_draw.h index 8b5789b55..31d7cdbc0 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -16,6 +16,7 @@ EXTERN_CVAR(Int, r_drawfuzz); EXTERN_CVAR(Bool, r_drawtrans); EXTERN_CVAR(Float, transsouls); EXTERN_CVAR(Int, r_columnmethod); +EXTERN_CVAR(Bool, r_dynlights); namespace swrenderer { diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 502d8490d..074bc39f4 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -258,54 +258,61 @@ void R_MapPlane (int y, int x1) if (r_swtruecolor) { - // Find row position in view space - float zspan = planeheight / (fabs(y + 0.5 - CenterY) / InvZtoScale); - dc_viewpos.X = (float)((x1 + 0.5 - CenterX) / CenterX * zspan); - dc_viewpos.Y = zspan; - dc_viewpos.Z = (float)((CenterY - y - 0.5) / InvZtoScale * zspan); - dc_viewpos_step.X = (float)(zspan / CenterX); - - static TriLight lightbuffer[64 * 1024]; - static int nextlightindex = 0; - - // Setup lights for column - dc_num_lights = 0; - dc_lights = lightbuffer + nextlightindex; - visplane_light *cur_node = ds_light_list; - while (cur_node && nextlightindex < 64 * 1024) + if (r_dynlights) { - double lightX = cur_node->lightsource->X() - ViewPos.X; - double lightY = cur_node->lightsource->Y() - ViewPos.Y; - double lightZ = cur_node->lightsource->Z() - ViewPos.Z; + // Find row position in view space + float zspan = planeheight / (fabs(y + 0.5 - CenterY) / InvZtoScale); + dc_viewpos.X = (float)((x1 + 0.5 - CenterX) / CenterX * zspan); + dc_viewpos.Y = zspan; + dc_viewpos.Z = (float)((CenterY - y - 0.5) / InvZtoScale * zspan); + dc_viewpos_step.X = (float)(zspan / CenterX); - float lx = (float)(lightX * ViewSin - lightY * ViewCos); - float ly = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; - float lz = (float)lightZ - dc_viewpos.Z; + static TriLight lightbuffer[64 * 1024]; + static int nextlightindex = 0; - // Precalculate the constant part of the dot here so the drawer doesn't have to. - float lconstant = ly * ly + lz * lz; - - // Include light only if it touches this row - float radius = cur_node->lightsource->GetRadius(); - if (radius * radius >= lconstant) + // Setup lights for column + dc_num_lights = 0; + dc_lights = lightbuffer + nextlightindex; + visplane_light *cur_node = ds_light_list; + while (cur_node && nextlightindex < 64 * 1024) { - uint32_t red = cur_node->lightsource->GetRed(); - uint32_t green = cur_node->lightsource->GetGreen(); - uint32_t blue = cur_node->lightsource->GetBlue(); + double lightX = cur_node->lightsource->X() - ViewPos.X; + double lightY = cur_node->lightsource->Y() - ViewPos.Y; + double lightZ = cur_node->lightsource->Z() - ViewPos.Z; - nextlightindex++; - auto &light = dc_lights[dc_num_lights++]; - light.x = lx; - light.y = lconstant; - light.radius = 256.0f / radius; - light.color = (red << 16) | (green << 8) | blue; + float lx = (float)(lightX * ViewSin - lightY * ViewCos); + float ly = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; + float lz = (float)lightZ - dc_viewpos.Z; + + // Precalculate the constant part of the dot here so the drawer doesn't have to. + float lconstant = ly * ly + lz * lz; + + // Include light only if it touches this row + float radius = cur_node->lightsource->GetRadius(); + if (radius * radius >= lconstant) + { + uint32_t red = cur_node->lightsource->GetRed(); + uint32_t green = cur_node->lightsource->GetGreen(); + uint32_t blue = cur_node->lightsource->GetBlue(); + + nextlightindex++; + auto &light = dc_lights[dc_num_lights++]; + light.x = lx; + light.y = lconstant; + light.radius = 256.0f / radius; + light.color = (red << 16) | (green << 8) | blue; + } + + cur_node = cur_node->next; } - cur_node = cur_node->next; + if (nextlightindex == 64 * 1024) + nextlightindex = 0; + } + else + { + dc_num_lights = 0; } - - if (nextlightindex == 64 * 1024) - nextlightindex = 0; } ds_y = y; @@ -348,6 +355,9 @@ namespace void R_AddPlaneLights(visplane_t *plane, FLightNode *node) { + if (!r_dynlights) + return; + while (node) { if (!(node->lightsource->flags2&MF2_DORMANT)) diff --git a/src/r_walldraw.cpp b/src/r_walldraw.cpp index 0523d8960..4f532a78e 100644 --- a/src/r_walldraw.cpp +++ b/src/r_walldraw.cpp @@ -539,61 +539,68 @@ static void Draw1Column(int x, int y1, int y2, WallSampler &sampler, void(*draw1 { if (r_swtruecolor) { - // Find column position in view space - float w1 = 1.0f / WallC.sz1; - float w2 = 1.0f / WallC.sz2; - float t = (x - WallC.sx1 + 0.5f) / (WallC.sx2 - WallC.sx1); - float wcol = w1 * (1.0f - t) + w2 * t; - float zcol = 1.0f / wcol; - dc_viewpos.X = (float)((x + 0.5 - CenterX) / CenterX * zcol); - dc_viewpos.Y = zcol; - dc_viewpos.Z = (float)((CenterY - y1 - 0.5) / InvZtoScale * zcol); - dc_viewpos_step.Z = (float)(-zcol / InvZtoScale); - - static TriLight lightbuffer[64 * 1024]; - static int nextlightindex = 0; - - // Setup lights for column - dc_num_lights = 0; - dc_lights = lightbuffer + nextlightindex; - FLightNode *cur_node = dc_light_list; - while (cur_node && nextlightindex < 64 * 1024) + if (r_dynlights) { - if (!(cur_node->lightsource->flags2&MF2_DORMANT)) + // Find column position in view space + float w1 = 1.0f / WallC.sz1; + float w2 = 1.0f / WallC.sz2; + float t = (x - WallC.sx1 + 0.5f) / (WallC.sx2 - WallC.sx1); + float wcol = w1 * (1.0f - t) + w2 * t; + float zcol = 1.0f / wcol; + dc_viewpos.X = (float)((x + 0.5 - CenterX) / CenterX * zcol); + dc_viewpos.Y = zcol; + dc_viewpos.Z = (float)((CenterY - y1 - 0.5) / InvZtoScale * zcol); + dc_viewpos_step.Z = (float)(-zcol / InvZtoScale); + + static TriLight lightbuffer[64 * 1024]; + static int nextlightindex = 0; + + // Setup lights for column + dc_num_lights = 0; + dc_lights = lightbuffer + nextlightindex; + FLightNode *cur_node = dc_light_list; + while (cur_node && nextlightindex < 64 * 1024) { - double lightX = cur_node->lightsource->X() - ViewPos.X; - double lightY = cur_node->lightsource->Y() - ViewPos.Y; - double lightZ = cur_node->lightsource->Z() - ViewPos.Z; - - float lx = (float)(lightX * ViewSin - lightY * ViewCos) - dc_viewpos.X; - float ly = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; - float lz = (float)lightZ; - - // Precalculate the constant part of the dot here so the drawer doesn't have to. - float lconstant = lx * lx + ly * ly; - - // Include light only if it touches this column - float radius = cur_node->lightsource->GetRadius(); - if (radius * radius >= lconstant) + if (!(cur_node->lightsource->flags2&MF2_DORMANT)) { - uint32_t red = cur_node->lightsource->GetRed(); - uint32_t green = cur_node->lightsource->GetGreen(); - uint32_t blue = cur_node->lightsource->GetBlue(); + double lightX = cur_node->lightsource->X() - ViewPos.X; + double lightY = cur_node->lightsource->Y() - ViewPos.Y; + double lightZ = cur_node->lightsource->Z() - ViewPos.Z; - nextlightindex++; - auto &light = dc_lights[dc_num_lights++]; - light.x = lconstant; - light.z = lz; - light.radius = 256.0f / cur_node->lightsource->GetRadius(); - light.color = (red << 16) | (green << 8) | blue; + float lx = (float)(lightX * ViewSin - lightY * ViewCos) - dc_viewpos.X; + float ly = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; + float lz = (float)lightZ; + + // Precalculate the constant part of the dot here so the drawer doesn't have to. + float lconstant = lx * lx + ly * ly; + + // Include light only if it touches this column + float radius = cur_node->lightsource->GetRadius(); + if (radius * radius >= lconstant) + { + uint32_t red = cur_node->lightsource->GetRed(); + uint32_t green = cur_node->lightsource->GetGreen(); + uint32_t blue = cur_node->lightsource->GetBlue(); + + nextlightindex++; + auto &light = dc_lights[dc_num_lights++]; + light.x = lconstant; + light.z = lz; + light.radius = 256.0f / cur_node->lightsource->GetRadius(); + light.color = (red << 16) | (green << 8) | blue; + } } + + cur_node = cur_node->nextLight; } - cur_node = cur_node->nextLight; + if (nextlightindex == 64 * 1024) + nextlightindex = 0; + } + else + { + dc_num_lights = 0; } - - if (nextlightindex == 64 * 1024) - nextlightindex = 0; int count = y2 - y1; diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 177d63521..48e2484fd 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2754,4 +2754,5 @@ TCMNU_TRUECOLOR = "True color output"; TCMNU_MINFILTER = "Linear filter when downscaling"; TCMNU_MAGFILTER = "Linear filter when upscaling"; TCMNU_MIPMAP = "Use mipmapped textures"; +TCMNU_DYNLIGHTS = "Dynamic lights"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 1c9d42de1..3086312a9 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -675,6 +675,7 @@ OptionMenu "TrueColorOptions" Option "$TCMNU_MINFILTER", "r_minfilter", "OnOff" Option "$TCMNU_MAGFILTER", "r_magfilter", "OnOff" Option "$TCMNU_MIPMAP", "r_mipmap", "OnOff" + Option "$TCMNU_DYNLIGHTS", "r_dynlights", "OnOff" } OptionMenu "VideoOptions" From 52892cb7ef21e9bd745b5c9ecf63992245966a08 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 24 Dec 2016 01:50:54 +0100 Subject: [PATCH 1471/1509] Move particle drawing to a command to prevent pipeline stalls --- src/r_draw_rgba.h | 17 +++++++++++++++ src/r_drawt_rgba.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++ src/r_things.cpp | 24 +------------------- 3 files changed, 70 insertions(+), 23 deletions(-) diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index afb3bc22d..6d16558c0 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -440,6 +440,23 @@ namespace swrenderer FString DebugInfo() override; }; + ///////////////////////////////////////////////////////////////////////////// + + class DrawParticleColumnRGBACommand : public DrawerCommand + { + public: + DrawParticleColumnRGBACommand(uint32_t *dest, int dest_y, int pitch, int count, uint32_t fg, uint32_t alpha); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + + private: + uint32_t *_dest; + int _pitch; + int _count; + uint32_t _fg; + uint32_t _alpha; + }; + ///////////////////////////////////////////////////////////////////////////// // Pixel shading inline functions: diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 5d3064e5d..3609956fe 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -231,4 +231,56 @@ namespace swrenderer { return "FillColumnHoriz"; } + + ///////////////////////////////////////////////////////////////////////////// + + DrawParticleColumnRGBACommand::DrawParticleColumnRGBACommand(uint32_t *dest, int dest_y, int pitch, int count, uint32_t fg, uint32_t alpha) + { + _dest = dest; + _pitch = pitch; + _count = count; + _fg = fg; + _alpha = alpha; + _dest_y = dest_y; + } + + void DrawParticleColumnRGBACommand::Execute(DrawerThread *thread) + { + int count = thread->count_for_thread(_dest_y, _count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, _dest); + int pitch = _pitch * thread->num_cores; + + uint32_t alpha = _alpha; + uint32_t inv_alpha = 256 - alpha; + + uint32_t fg_red = (_fg >> 16) & 0xff; + uint32_t fg_green = (_fg >> 8) & 0xff; + uint32_t fg_blue = _fg & 0xff; + + fg_red *= alpha; + fg_green *= alpha; + fg_blue *= alpha; + + for (int y = 0; y < count; y++) + { + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red + bg_red * inv_alpha) / 256; + uint32_t green = (fg_green + bg_green * inv_alpha) / 256; + uint32_t blue = (fg_blue + bg_blue * inv_alpha) / 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + } + } + + FString DrawParticleColumnRGBACommand::DebugInfo() + { + return "DrawParticle"; + } } diff --git a/src/r_things.cpp b/src/r_things.cpp index 6e1261c1b..bbd9eb9cf 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2865,21 +2865,11 @@ void R_DrawParticle_rgba(vissprite_t *vis) R_DrawMaskedSegsBehindParticle(vis); - DrawerCommandQueue::WaitForWorkers(); - uint32_t fg = LightBgra::shade_pal_index_simple(color, LightBgra::calc_light_multiplier(LIGHTSCALE(0, vis->Style.ColormapNum << FRACBITS))); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; // vis->renderflags holds translucency level (0-255) fixed_t fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff; uint32_t alpha = fglevel * 256 / FRACUNIT; - uint32_t inv_alpha = 256 - alpha; - - fg_red *= alpha; - fg_green *= alpha; - fg_blue *= alpha; spacing = RenderTarget->GetPitch(); @@ -2889,19 +2879,7 @@ void R_DrawParticle_rgba(vissprite_t *vis) if (R_ClipSpriteColumnWithPortals(vis)) continue; dest = ylookup[yl] + x + (uint32_t*)dc_destorg; - for (int y = 0; y < ycount; y++) - { - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red + bg_red * inv_alpha) / 256; - uint32_t green = (fg_green + bg_green * inv_alpha) / 256; - uint32_t blue = (fg_blue + bg_blue * inv_alpha) / 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += spacing; - } + DrawerCommandQueue::QueueCommand(dest, yl, spacing, ycount, fg, alpha); } } From 8de11ee81a1c3ff817781afb0e9bf3841e84af1a Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 24 Dec 2016 03:49:56 -0500 Subject: [PATCH 1472/1509] - Begin reimplementing rgb555 again. --- src/r_draw_pal.cpp | 137 ++++++++++++++++++++++++++++++++++----------- src/v_video.cpp | 84 ++++++++++++++++++++++++--- src/v_video.h | 39 +++++++++++++ 3 files changed, 218 insertions(+), 42 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 17e77d39a..c7adc9d87 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -43,6 +43,9 @@ #include "v_video.h" #include "r_draw_pal.h" +// [SP] r_blendmode - false = rgb555 matching (ZDoom classic), true = rgb666 (refactored) +CVAR(Bool, r_blendmode, false, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) + /* [RH] This translucency algorithm is based on DOSDoom 0.65's, but uses a 32k RGB table instead of an 8k one. At least on my machine, it's @@ -303,19 +306,39 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; - do + if (!r_blendmode) { - uint8_t pix = source[frac >> bits]; - if (pix != 0) + do { - uint32_t r = MIN(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 255); - uint32_t g = MIN(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 255); - uint32_t b = MIN(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 255); - *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; - } - frac += fracstep; - dest += pitch; - } while (--count); + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t fg = fg2rgb[colormap[pix]]; + uint32_t bg = bg2rgb[*dest]; + fg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg >> 15)]; + } + frac += fracstep; + dest += pitch; + } while (--count); + + } + else + { + do + { + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t r = MIN(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 255); + uint32_t g = MIN(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 255); + uint32_t b = MIN(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 255); + *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; + } + frac += fracstep; + dest += pitch; + } while (--count); + } } void DrawWallAdd4PalCommand::Execute(DrawerThread *thread) @@ -341,22 +364,44 @@ namespace swrenderer } pitch *= thread->num_cores; - do + if (!r_blendmode) { - for (int i = 0; i < 4; ++i) + do { - uint8_t pix = _source[i][dc_wall_texturefrac[i] >> bits]; - if (pix != 0) + for (int i = 0; i < 4; ++i) { - uint32_t r = MIN(GPalette.BaseColors[_colormap[i][pix]].r + GPalette.BaseColors[dest[i]].r, 255); - uint32_t g = MIN(GPalette.BaseColors[_colormap[i][pix]].g + GPalette.BaseColors[dest[i]].g, 255); - uint32_t b = MIN(GPalette.BaseColors[_colormap[i][pix]].b + GPalette.BaseColors[dest[i]].b, 255); - dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; + uint8_t pix = _source[i][dc_wall_texturefrac[i] >> bits]; + if (pix != 0) + { + uint32_t fg = fg2rgb[_colormap[i][pix]]; + uint32_t bg = bg2rgb[dest[i]]; + fg = (fg + bg) | 0x1f07c1f; + dest[i] = RGB32k.All[fg & (fg >> 15)]; + } + dc_wall_texturefrac[i] += dc_wall_iscale[i]; } - dc_wall_texturefrac[i] += dc_wall_iscale[i]; - } - dest += pitch; - } while (--count); + dest += pitch; + } while (--count); + } + else + { + do + { + for (int i = 0; i < 4; ++i) + { + uint8_t pix = _source[i][dc_wall_texturefrac[i] >> bits]; + if (pix != 0) + { + uint32_t r = MIN(GPalette.BaseColors[_colormap[i][pix]].r + GPalette.BaseColors[dest[i]].r, 255); + uint32_t g = MIN(GPalette.BaseColors[_colormap[i][pix]].g + GPalette.BaseColors[dest[i]].g, 255); + uint32_t b = MIN(GPalette.BaseColors[_colormap[i][pix]].b + GPalette.BaseColors[dest[i]].b, 255); + dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; + } + dc_wall_texturefrac[i] += dc_wall_iscale[i]; + } + dest += pitch; + } while (--count); + } } void DrawWallAddClamp1PalCommand::Execute(DrawerThread *thread) @@ -379,19 +424,43 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; - do + if (!r_blendmode) { - uint8_t pix = source[frac >> bits]; - if (pix != 0) + do { - uint32_t r = MIN(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 255); - uint32_t g = MIN(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 255); - uint32_t b = MIN(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 255); - *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; - } - frac += fracstep; - dest += pitch; - } while (--count); + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t a = fg2rgb[colormap[pix]] + bg2rgb[*dest]; + uint32_t b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a >> 15)]; + } + frac += fracstep; + dest += pitch; + } while (--count); + } + else + { + do + { + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t r = MIN(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 255); + uint32_t g = MIN(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 255); + uint32_t b = MIN(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 255); + *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; + } + frac += fracstep; + dest += pitch; + } while (--count); + } } void DrawWallAddClamp4PalCommand::Execute(DrawerThread *thread) diff --git a/src/v_video.cpp b/src/v_video.cpp index b639939ee..5a8ef10d5 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -143,6 +143,7 @@ extern "C" { DWORD Col2RGB8[65][256]; DWORD *Col2RGB8_LessPrecision[65]; DWORD Col2RGB8_Inverse[65][256]; +ColorTable32k RGB32k; ColorTable256k RGB256k; } @@ -346,6 +347,8 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) if (damount == 0.f) return; + DWORD *bg2rgb; + DWORD fg; int gap; BYTE *spot; int x, y; @@ -367,6 +370,16 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) return; } + { + int amount; + + amount = (int)(damount * 64); + bg2rgb = Col2RGB8[64-amount]; + + fg = (((color.r * amount) >> 4) << 20) | + ((color.g * amount) >> 4) | + (((color.b * amount) >> 4) << 10); + } spot = Buffer + x1 + y1*Pitch; gap = Pitch - w; @@ -376,17 +389,37 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) int dimmedcolor_r = color.r * alpha; int dimmedcolor_g = color.g * alpha; int dimmedcolor_b = color.b * alpha; - for (y = h; y != 0; y--) + + if (!r_blendmode) { - for (x = w; x != 0; x--) + for (y = h; y != 0; y--) { - uint32_t r = (dimmedcolor_r + GPalette.BaseColors[*spot].r * ialpha) >> 8; - uint32_t g = (dimmedcolor_g + GPalette.BaseColors[*spot].g * ialpha) >> 8; - uint32_t b = (dimmedcolor_b + GPalette.BaseColors[*spot].b * ialpha) >> 8; - *spot = (BYTE)RGB256k.RGB[r][g][b]; - spot++; + for (x = w; x != 0; x--) + { + DWORD bg; + + bg = bg2rgb[(*spot)&0xff]; + bg = (fg+bg) | 0x1f07c1f; + *spot = RGB32k.All[bg&(bg>>15)]; + spot++; + } + spot += gap; + } + } + else + { + for (y = h; y != 0; y--) + { + for (x = w; x != 0; x--) + { + uint32_t r = (dimmedcolor_r + GPalette.BaseColors[*spot].r * ialpha) >> 8; + uint32_t g = (dimmedcolor_g + GPalette.BaseColors[*spot].g * ialpha) >> 8; + uint32_t b = (dimmedcolor_b + GPalette.BaseColors[*spot].b * ialpha) >> 8; + *spot = (BYTE)RGB256k.RGB[r][g][b]; + spot++; + } + spot += gap; } - spot += gap; } } @@ -658,12 +691,47 @@ static void BuildTransTable (const PalEntry *palette) { int r, g, b; + // create the RGB555 lookup table + for (r = 0; r < 32; r++) + for (g = 0; g < 32; g++) + for (b = 0; b < 32; b++) + RGB32k.RGB[r][g][b] = ColorMatcher.Pick ((r<<3)|(r>>2), (g<<3)|(g>>2), (b<<3)|(b>>2)); // create the RGB666 lookup table for (r = 0; r < 64; r++) for (g = 0; g < 64; g++) for (b = 0; b < 64; b++) RGB256k.RGB[r][g][b] = ColorMatcher.Pick ((r<<2)|(r>>4), (g<<2)|(g>>4), (b<<2)|(b>>4)); + int x, y; + + // create the swizzled palette + for (x = 0; x < 65; x++) + for (y = 0; y < 256; y++) + Col2RGB8[x][y] = (((palette[y].r*x)>>4)<<20) | + ((palette[y].g*x)>>4) | + (((palette[y].b*x)>>4)<<10); + + // create the swizzled palette with the lsb of red and blue forced to 0 + // (for green, a 1 is okay since it never gets added into) + for (x = 1; x < 64; x++) + { + Col2RGB8_LessPrecision[x] = Col2RGB8_2[x-1]; + for (y = 0; y < 256; y++) + { + Col2RGB8_2[x-1][y] = Col2RGB8[x][y] & 0x3feffbff; + } + } + Col2RGB8_LessPrecision[0] = Col2RGB8[0]; + Col2RGB8_LessPrecision[64] = Col2RGB8[64]; + + // create the inverse swizzled palette + for (x = 0; x < 65; x++) + for (y = 0; y < 256; y++) + { + Col2RGB8_Inverse[x][y] = (((((255-palette[y].r)*x)>>4)<<20) | + (((255-palette[y].g)*x)>>4) | + ((((255-palette[y].b)*x)>>4)<<10)) & 0x3feffbff; + } } //========================================================================== diff --git a/src/v_video.h b/src/v_video.h index 0da6b9b50..57d15869c 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -448,6 +448,20 @@ EXTERN_CVAR (Float, Gamma) // Translucency tables +// RGB32k is a normal R5G5B5 -> palette lookup table. + +// Use a union so we can "overflow" without warnings. +// Otherwise, we get stuff like this from Clang (when compiled +// with -fsanitize=bounds) while running: +// src/v_video.cpp:390:12: runtime error: index 1068 out of bounds for type 'BYTE [32]' +// src/r_draw.cpp:273:11: runtime error: index 1057 out of bounds for type 'BYTE [32]' +union ColorTable32k +{ + BYTE RGB[32][32][32]; + BYTE All[32 *32 *32]; +}; +extern "C" ColorTable32k RGB32k; + // [SP] RGB666 support union ColorTable256k { @@ -456,6 +470,31 @@ union ColorTable256k }; extern "C" ColorTable256k RGB256k; +// Col2RGB8 is a pre-multiplied palette for color lookup. It is stored in a +// special R10B10G10 format for efficient blending computation. +// --RRRRRrrr--BBBBBbbb--GGGGGggg-- at level 64 +// --------rrrr------bbbb------gggg at level 1 +extern "C" DWORD Col2RGB8[65][256]; + +// Col2RGB8_LessPrecision is the same as Col2RGB8, but the LSB for red +// and blue are forced to zero, so if the blend overflows, it won't spill +// over into the next component's value. +// --RRRRRrrr-#BBBBBbbb-#GGGGGggg-- at level 64 +// --------rrr#------bbb#------gggg at level 1 +extern "C" DWORD *Col2RGB8_LessPrecision[65]; + +// Col2RGB8_Inverse is the same as Col2RGB8_LessPrecision, except the source +// palette has been inverted. +extern "C" DWORD Col2RGB8_Inverse[65][256]; + +// "Magic" numbers used during the blending: +// --000001111100000111110000011111 = 0x01f07c1f +// -0111111111011111111101111111111 = 0x3FEFFBFF +// -1000000000100000000010000000000 = 0x40100400 +// ------10000000001000000000100000 = 0x40100400 >> 5 +// --11111-----11111-----11111----- = 0x40100400 - (0x40100400 >> 5) aka "white" +// --111111111111111111111111111111 = 0x3FFFFFFF + // Allocates buffer screens, call before R_Init. void V_Init (bool restart); From 9d2128a4f4af0ea16048addd40bc48917177f837 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 24 Dec 2016 04:01:50 -0500 Subject: [PATCH 1473/1509] - Fixed compile errors. --- src/r_draw_pal.cpp | 12 ++++++++++++ src/v_video.cpp | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index c7adc9d87..6b40621b6 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -297,6 +297,9 @@ namespace swrenderer int bits = _fracbits; int pitch = _pitch; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + count = thread->count_for_thread(_dest_y, count); if (count <= 0) return; @@ -347,6 +350,9 @@ namespace swrenderer int count = _count; int bits = _fracbits; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + uint32_t dc_wall_texturefrac[4] = { _texturefrac[0], _texturefrac[1], _texturefrac[2], _texturefrac[3] }; uint32_t dc_wall_iscale[4] = { _iscale[0], _iscale[1], _iscale[2], _iscale[3] }; @@ -415,6 +421,9 @@ namespace swrenderer int bits = _fracbits; int pitch = _pitch; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + count = thread->count_for_thread(_dest_y, count); if (count <= 0) return; @@ -469,6 +478,9 @@ namespace swrenderer int count = _count; int bits = _fracbits; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + uint32_t dc_wall_texturefrac[4] = { _texturefrac[0], _texturefrac[1], _texturefrac[2], _texturefrac[3] }; uint32_t dc_wall_iscale[4] = { _iscale[0], _iscale[1], _iscale[2], _iscale[3] }; diff --git a/src/v_video.cpp b/src/v_video.cpp index 5a8ef10d5..9abe13f1b 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -66,6 +66,8 @@ #include "menu/menu.h" #include "r_data/voxels.h" +EXTERN_CVAR(Bool, r_blendmode) + int active_con_scale(); FRenderer *Renderer; From 88b60389992bd8919c382accae10ff27b7805372 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 24 Dec 2016 04:35:05 -0500 Subject: [PATCH 1474/1509] - More rgb555 reimplements. --- src/r_draw_pal.cpp | 101 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 78 insertions(+), 23 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 6b40621b6..19015d8e1 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -527,6 +527,9 @@ namespace swrenderer int bits = _fracbits; int pitch = _pitch; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + count = thread->count_for_thread(_dest_y, count); if (count <= 0) return; @@ -536,19 +539,42 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; - do + if (!r_blendmode) { - uint8_t pix = source[frac >> bits]; - if (pix != 0) + do { - int r = clamp(-GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 0, 255); - int g = clamp(-GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 0, 255); - int b = clamp(-GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 0, 255); - *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; - } - frac += fracstep; - dest += pitch; - } while (--count); + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t a = (fg2rgb[colormap[pix]] | 0x40100400) - bg2rgb[*dest]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a >> 15)]; + } + frac += fracstep; + dest += pitch; + } while (--count); + } + else + { + do + { + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + int r = clamp(-GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 0, 255); + int g = clamp(-GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 0, 255); + int b = clamp(-GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 0, 255); + *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; + } + frac += fracstep; + dest += pitch; + } while (--count); + } } void DrawWallSubClamp4PalCommand::Execute(DrawerThread *thread) @@ -557,6 +583,9 @@ namespace swrenderer int count = _count; int bits = _fracbits; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + uint32_t dc_wall_texturefrac[4] = { _texturefrac[0], _texturefrac[1], _texturefrac[2], _texturefrac[3] }; uint32_t dc_wall_iscale[4] = { _iscale[0], _iscale[1], _iscale[2], _iscale[3] }; @@ -574,22 +603,48 @@ namespace swrenderer } pitch *= thread->num_cores; - do + if (!r_blendmode) { - for (int i = 0; i < 4; ++i) + do { - uint8_t pix = _source[i][dc_wall_texturefrac[i] >> bits]; - if (pix != 0) + for (int i = 0; i < 4; ++i) { - int r = clamp(-GPalette.BaseColors[_colormap[i][pix]].r + GPalette.BaseColors[dest[i]].r, 0, 255); - int g = clamp(-GPalette.BaseColors[_colormap[i][pix]].g + GPalette.BaseColors[dest[i]].g, 0, 255); - int b = clamp(-GPalette.BaseColors[_colormap[i][pix]].b + GPalette.BaseColors[dest[i]].b, 0, 255); - dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; + uint8_t pix = _source[i][dc_wall_texturefrac[i] >> bits]; + if (pix != 0) + { + uint32_t a = (fg2rgb[_colormap[i][pix]] | 0x40100400) - bg2rgb[dest[i]]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[i] = RGB32k.All[a & (a >> 15)]; + } + dc_wall_texturefrac[i] += dc_wall_iscale[i]; } - dc_wall_texturefrac[i] += dc_wall_iscale[i]; - } - dest += pitch; - } while (--count); + dest += pitch; + } while (--count); + } + else + { + do + { + for (int i = 0; i < 4; ++i) + { + uint8_t pix = _source[i][dc_wall_texturefrac[i] >> bits]; + if (pix != 0) + { + int r = clamp(-GPalette.BaseColors[_colormap[i][pix]].r + GPalette.BaseColors[dest[i]].r, 0, 255); + int g = clamp(-GPalette.BaseColors[_colormap[i][pix]].g + GPalette.BaseColors[dest[i]].g, 0, 255); + int b = clamp(-GPalette.BaseColors[_colormap[i][pix]].b + GPalette.BaseColors[dest[i]].b, 0, 255); + dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; + } + dc_wall_texturefrac[i] += dc_wall_iscale[i]; + } + dest += pitch; + } while (--count); + } } void DrawWallRevSubClamp1PalCommand::Execute(DrawerThread *thread) From b04ac8f34649caceba547b47546ebeddcbd0df32 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 24 Dec 2016 14:45:56 +0100 Subject: [PATCH 1475/1509] Rounded particles --- src/r_draw_rgba.h | 3 ++- src/r_drawt_rgba.cpp | 48 +++++++++++++++++++++++++++++++++++--------- src/r_things.cpp | 10 +++++++-- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 6d16558c0..d5b269106 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -445,7 +445,7 @@ namespace swrenderer class DrawParticleColumnRGBACommand : public DrawerCommand { public: - DrawParticleColumnRGBACommand(uint32_t *dest, int dest_y, int pitch, int count, uint32_t fg, uint32_t alpha); + DrawParticleColumnRGBACommand(uint32_t *dest, int dest_y, int pitch, int count, uint32_t fg, uint32_t alpha, uint32_t fracposx); void Execute(DrawerThread *thread) override; FString DebugInfo() override; @@ -455,6 +455,7 @@ namespace swrenderer int _count; uint32_t _fg; uint32_t _alpha; + uint32_t _fracposx; }; ///////////////////////////////////////////////////////////////////////////// diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 3609956fe..b5be7a9c3 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -234,13 +234,37 @@ namespace swrenderer ///////////////////////////////////////////////////////////////////////////// - DrawParticleColumnRGBACommand::DrawParticleColumnRGBACommand(uint32_t *dest, int dest_y, int pitch, int count, uint32_t fg, uint32_t alpha) + namespace + { + static uint32_t particle_texture[16 * 16] = + { + 1*1, 2*1, 3*1, 4*1, 5*1, 6*1, 7*1, 8*1, 8*1, 7*1, 6*1, 5*1, 4*1, 3*1, 2*1, 1*1, + 1*2, 2*2, 3*2, 4*2, 5*2, 6*2, 7*2, 8*2, 8*2, 7*2, 6*2, 5*2, 4*2, 3*2, 2*2, 1*2, + 1*3, 2*3, 3*3, 4*3, 5*3, 6*3, 7*3, 8*3, 8*3, 7*3, 6*3, 5*3, 4*3, 3*3, 2*3, 1*3, + 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4, 8*4, 8*4, 7*4, 6*4, 5*4, 4*4, 3*4, 2*4, 1*4, + 1*5, 2*5, 3*5, 4*5, 5*5, 6*5, 7*5, 8*5, 8*5, 7*5, 6*5, 5*5, 4*5, 3*5, 2*5, 1*5, + 1*6, 2*6, 3*6, 4*6, 5*6, 6*6, 7*6, 8*6, 8*6, 7*6, 6*6, 5*6, 4*6, 3*6, 2*6, 1*6, + 1*7, 2*7, 3*7, 4*7, 5*7, 6*7, 7*7, 8*7, 8*7, 7*7, 6*7, 5*7, 4*7, 3*7, 2*7, 1*7, + 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 8*8, 7*8, 6*8, 5*8, 4*8, 3*8, 2*8, 1*8, + 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 8*8, 7*8, 6*8, 5*8, 4*8, 3*8, 2*8, 1*8, + 1*7, 2*7, 3*7, 4*7, 5*7, 6*7, 7*7, 8*7, 8*7, 7*7, 6*7, 5*7, 4*7, 3*7, 2*7, 1*7, + 1*6, 2*6, 3*6, 4*6, 5*6, 6*6, 7*6, 8*6, 8*6, 7*6, 6*6, 5*6, 4*6, 3*6, 2*6, 1*6, + 1*5, 2*5, 3*5, 4*5, 5*5, 6*5, 7*5, 8*5, 8*5, 7*5, 6*5, 5*5, 4*5, 3*5, 2*5, 1*5, + 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4, 8*4, 8*4, 7*4, 6*4, 5*4, 4*4, 3*4, 2*4, 1*4, + 1*3, 2*3, 3*3, 4*3, 5*3, 6*3, 7*3, 8*3, 8*3, 7*3, 6*3, 5*3, 4*3, 3*3, 2*3, 1*3, + 1*2, 2*2, 3*2, 4*2, 5*2, 6*2, 7*2, 8*2, 8*2, 7*2, 6*2, 5*2, 4*2, 3*2, 2*2, 1*2, + 1*1, 2*1, 3*1, 4*1, 5*1, 6*1, 7*1, 8*1, 8*1, 7*1, 6*1, 5*1, 4*1, 3*1, 2*1, 1*1 + }; + } + + DrawParticleColumnRGBACommand::DrawParticleColumnRGBACommand(uint32_t *dest, int dest_y, int pitch, int count, uint32_t fg, uint32_t alpha, uint32_t fracposx) { _dest = dest; _pitch = pitch; _count = count; _fg = fg; _alpha = alpha; + _fracposx = fracposx; _dest_y = dest_y; } @@ -253,29 +277,33 @@ namespace swrenderer uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, _dest); int pitch = _pitch * thread->num_cores; - uint32_t alpha = _alpha; - uint32_t inv_alpha = 256 - alpha; + const uint32_t *source = &particle_texture[(_fracposx >> FRACBITS) * 16]; + uint32_t particle_alpha = _alpha; + + uint32_t fracstep = 16 * FRACUNIT / _count; + uint32_t fracpos = fracstep * thread->skipped_by_thread(_dest_y) + fracstep / 2; + fracstep *= thread->num_cores; uint32_t fg_red = (_fg >> 16) & 0xff; uint32_t fg_green = (_fg >> 8) & 0xff; uint32_t fg_blue = _fg & 0xff; - fg_red *= alpha; - fg_green *= alpha; - fg_blue *= alpha; - for (int y = 0; y < count; y++) { + uint32_t alpha = (source[fracpos >> FRACBITS] * particle_alpha) >> 6; + uint32_t inv_alpha = 256 - alpha; + uint32_t bg_red = (*dest >> 16) & 0xff; uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = (fg_red + bg_red * inv_alpha) / 256; - uint32_t green = (fg_green + bg_green * inv_alpha) / 256; - uint32_t blue = (fg_blue + bg_blue * inv_alpha) / 256; + uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 256; + uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 256; + uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += pitch; + fracpos += fracstep; } } diff --git a/src/r_things.cpp b/src/r_things.cpp index bbd9eb9cf..6e6b95402 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2863,6 +2863,9 @@ void R_DrawParticle_rgba(vissprite_t *vis) int x1 = vis->x1; int countbase = vis->x2 - x1; + if (ycount <= 0 || countbase <= 0) + return; + R_DrawMaskedSegsBehindParticle(vis); uint32_t fg = LightBgra::shade_pal_index_simple(color, LightBgra::calc_light_multiplier(LIGHTSCALE(0, vis->Style.ColormapNum << FRACBITS))); @@ -2873,13 +2876,16 @@ void R_DrawParticle_rgba(vissprite_t *vis) spacing = RenderTarget->GetPitch(); - for (int x = x1; x < (x1 + countbase); x++) + uint32_t fracstepx = 16 * FRACUNIT / countbase; + uint32_t fracposx = fracstepx / 2; + + for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx) { dc_x = x; if (R_ClipSpriteColumnWithPortals(vis)) continue; dest = ylookup[yl] + x + (uint32_t*)dc_destorg; - DrawerCommandQueue::QueueCommand(dest, yl, spacing, ycount, fg, alpha); + DrawerCommandQueue::QueueCommand(dest, yl, spacing, ycount, fg, alpha, fracposx); } } From 80482e98a389c84b12770ffdfcd990065013f35c Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 24 Dec 2016 10:15:02 -0500 Subject: [PATCH 1476/1509] - renamed r_blendmode to r_blendmethod - did another drawer --- src/r_draw_pal.cpp | 59 ++++++++++++++++++++++++++++++++-------------- src/v_video.cpp | 4 ++-- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 19015d8e1..0da9e38be 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -43,8 +43,8 @@ #include "v_video.h" #include "r_draw_pal.h" -// [SP] r_blendmode - false = rgb555 matching (ZDoom classic), true = rgb666 (refactored) -CVAR(Bool, r_blendmode, false, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) +// [SP] r_blendmethod - false = rgb555 matching (ZDoom classic), true = rgb666 (refactored) +CVAR(Bool, r_blendmethod, false, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) /* [RH] This translucency algorithm is based on DOSDoom 0.65's, but uses @@ -309,7 +309,7 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; - if (!r_blendmode) + if (!r_blendmethod) { do { @@ -370,7 +370,7 @@ namespace swrenderer } pitch *= thread->num_cores; - if (!r_blendmode) + if (!r_blendmethod) { do { @@ -433,7 +433,7 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; - if (!r_blendmode) + if (!r_blendmethod) { do { @@ -539,7 +539,7 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; - if (!r_blendmode) + if (!r_blendmethod) { do { @@ -603,7 +603,7 @@ namespace swrenderer } pitch *= thread->num_cores; - if (!r_blendmode) + if (!r_blendmethod) { do { @@ -667,19 +667,42 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; - do + if (!r_blendmethod) { - uint8_t pix = source[frac >> bits]; - if (pix != 0) + do { - int r = clamp(GPalette.BaseColors[colormap[pix]].r - GPalette.BaseColors[*dest].r, 0, 255); - int g = clamp(GPalette.BaseColors[colormap[pix]].g - GPalette.BaseColors[*dest].g, 0, 255); - int b = clamp(GPalette.BaseColors[colormap[pix]].b - GPalette.BaseColors[*dest].b, 0, 255); - *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; - } - frac += fracstep; - dest += pitch; - } while (--count); + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[pix]]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a >> 15)]; + } + frac += fracstep; + dest += pitch; + } while (--count); + } + else + { + do + { + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + int r = clamp(GPalette.BaseColors[colormap[pix]].r - GPalette.BaseColors[*dest].r, 0, 255); + int g = clamp(GPalette.BaseColors[colormap[pix]].g - GPalette.BaseColors[*dest].g, 0, 255); + int b = clamp(GPalette.BaseColors[colormap[pix]].b - GPalette.BaseColors[*dest].b, 0, 255); + *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; + } + frac += fracstep; + dest += pitch; + } while (--count); + } } void DrawWallRevSubClamp4PalCommand::Execute(DrawerThread *thread) diff --git a/src/v_video.cpp b/src/v_video.cpp index 9abe13f1b..2b31415a2 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -66,7 +66,7 @@ #include "menu/menu.h" #include "r_data/voxels.h" -EXTERN_CVAR(Bool, r_blendmode) +EXTERN_CVAR(Bool, r_blendmethod) int active_con_scale(); @@ -392,7 +392,7 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) int dimmedcolor_g = color.g * alpha; int dimmedcolor_b = color.b * alpha; - if (!r_blendmode) + if (!r_blendmethod) { for (y = h; y != 0; y--) { From 101108877acc4bba39668c066fba40793863b326 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 24 Dec 2016 11:40:15 -0500 Subject: [PATCH 1477/1509] - Reimplemented rgb555 into all drawers in r_draw_pal.cpp including span drawers. All that remains now are the 4col drawers in r_drawt_pal.cpp. --- src/r_draw.cpp | 6 + src/r_draw_pal.cpp | 1051 ++++++++++++++++++++++++++++++++------------ src/r_plane.cpp | 8 + src/r_things.cpp | 73 ++- 4 files changed, 847 insertions(+), 291 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index a08a204ca..b44bc5f95 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -236,16 +236,22 @@ namespace swrenderer } if (flags & STYLEF_InvertSource) { + dc_srcblend = Col2RGB8_Inverse[fglevel >> 10]; + dc_destblend = Col2RGB8_LessPrecision[bglevel >> 10]; dc_srcalpha = fglevel; dc_destalpha = bglevel; } else if (op == STYLEOP_Add && fglevel + bglevel <= FRACUNIT) { + dc_srcblend = Col2RGB8[fglevel >> 10]; + dc_destblend = Col2RGB8[bglevel >> 10]; dc_srcalpha = fglevel; dc_destalpha = bglevel; } else { + dc_srcblend = Col2RGB8_LessPrecision[fglevel >> 10]; + dc_destblend = Col2RGB8_LessPrecision[bglevel >> 10]; dc_srcalpha = fglevel; dc_destalpha = bglevel; } diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 0da9e38be..88fe93f85 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -658,6 +658,9 @@ namespace swrenderer int bits = _fracbits; int pitch = _pitch; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + count = thread->count_for_thread(_dest_y, count); if (count <= 0) return; @@ -711,6 +714,9 @@ namespace swrenderer int count = _count; int bits = _fracbits; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; + uint32_t dc_wall_texturefrac[4] = { _texturefrac[0], _texturefrac[1], _texturefrac[2], _texturefrac[3] }; uint32_t dc_wall_iscale[4] = { _iscale[0], _iscale[1], _iscale[2], _iscale[3] }; @@ -728,22 +734,48 @@ namespace swrenderer } pitch *= thread->num_cores; - do + if (!r_blendmethod) { - for (int i = 0; i < 4; ++i) + do { - uint8_t pix = _source[i][dc_wall_texturefrac[i] >> bits]; - if (pix != 0) + for (int i = 0; i < 4; ++i) { - uint32_t r = clamp(GPalette.BaseColors[_colormap[i][pix]].r - GPalette.BaseColors[dest[i]].r, 0, 255); - uint32_t g = clamp(GPalette.BaseColors[_colormap[i][pix]].g - GPalette.BaseColors[dest[i]].g, 0, 255); - uint32_t b = clamp(GPalette.BaseColors[_colormap[i][pix]].b - GPalette.BaseColors[dest[i]].b, 0, 255); - dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; + uint8_t pix = _source[i][dc_wall_texturefrac[i] >> bits]; + if (pix != 0) + { + uint32_t a = (bg2rgb[dest[i]] | 0x40100400) - fg2rgb[_colormap[i][pix]]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[i] = RGB32k.All[a & (a >> 15)]; + } + dc_wall_texturefrac[i] += dc_wall_iscale[i]; } - dc_wall_texturefrac[i] += dc_wall_iscale[i]; - } - dest += _pitch; - } while (--count); + dest += _pitch; + } while (--count); + } + else + { + do + { + for (int i = 0; i < 4; ++i) + { + uint8_t pix = _source[i][dc_wall_texturefrac[i] >> bits]; + if (pix != 0) + { + uint32_t r = clamp(GPalette.BaseColors[_colormap[i][pix]].r - GPalette.BaseColors[dest[i]].r, 0, 255); + uint32_t g = clamp(GPalette.BaseColors[_colormap[i][pix]].g - GPalette.BaseColors[dest[i]].g, 0, 255); + uint32_t b = clamp(GPalette.BaseColors[_colormap[i][pix]].b - GPalette.BaseColors[dest[i]].b, 0, 255); + dest[i] = RGB256k.RGB[r>>2][g>>2][b>>2]; + } + dc_wall_texturefrac[i] += dc_wall_iscale[i]; + } + dest += _pitch; + } while (--count); + } } ///////////////////////////////////////////////////////////////////////// @@ -1319,18 +1351,30 @@ namespace swrenderer const PalEntry* pal = GPalette.BaseColors; - do + if (!r_blendmethod) { - int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; - int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; - int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; - int r = clamp((src_r + pal[*dest].r * _destalpha)>>18, 0, 255); - int g = clamp((src_g + pal[*dest].g * _destalpha)>>18, 0, 255); - int b = clamp((src_b + pal[*dest].b * _destalpha)>>18, 0, 255); - *dest = RGB256k.RGB[r][g][b]; - dest += pitch; - } while (--count); - + do + { + uint32_t bg; + bg = (fg + bg2rgb[*dest]) | 0x1f07c1f; + *dest = RGB32k.All[bg & (bg >> 15)]; + dest += pitch; + } while (--count); + } + else + { + do + { + int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; + int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; + int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; + int r = clamp((src_r + pal[*dest].r * _destalpha)>>18, 0, 255); + int g = clamp((src_g + pal[*dest].g * _destalpha)>>18, 0, 255); + int b = clamp((src_b + pal[*dest].b * _destalpha)>>18, 0, 255); + *dest = RGB256k.RGB[r][g][b]; + dest += pitch; + } while (--count); + } } void FillColumnAddClampPalCommand::Execute(DrawerThread *thread) @@ -1357,17 +1401,36 @@ namespace swrenderer const PalEntry* pal = GPalette.BaseColors; - do + if (!r_blendmethod) { - int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; - int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; - int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; - int r = clamp((src_r + pal[*dest].r * _destalpha)>>18, 0, 255); - int g = clamp((src_g + pal[*dest].g * _destalpha)>>18, 0, 255); - int b = clamp((src_b + pal[*dest].b * _destalpha)>>18, 0, 255); - *dest = RGB256k.RGB[r][g][b]; - dest += pitch; - } while (--count); + do + { + uint32_t a = fg + bg2rgb[*dest]; + uint32_t b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + } while (--count); + } + else + { + do + { + int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; + int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; + int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; + int r = clamp((src_r + pal[*dest].r * _destalpha)>>18, 0, 255); + int g = clamp((src_g + pal[*dest].g * _destalpha)>>18, 0, 255); + int b = clamp((src_b + pal[*dest].b * _destalpha)>>18, 0, 255); + *dest = RGB256k.RGB[r][g][b]; + dest += pitch; + } while (--count); + } } void FillColumnSubClampPalCommand::Execute(DrawerThread *thread) @@ -1378,6 +1441,8 @@ namespace swrenderer count = _count; dest = _dest; + uint32_t *bg2rgb = _destblend; + uint32_t fg = _srccolor; int pitch = _pitch; @@ -1390,19 +1455,37 @@ namespace swrenderer const PalEntry* palette = GPalette.BaseColors; - do + if (!r_blendmethod) { - int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; - int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; - int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; - int bg = *dest; - int r = MAX((src_r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((src_g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((src_b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + do + { + uint32_t a = fg - bg2rgb[*dest]; + uint32_t b = a; - *dest = RGB256k.RGB[r][g][b]; - dest += pitch; - } while (--count); + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + } while (--count); + } + else + { + do + { + int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; + int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; + int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; + int bg = *dest; + int r = MAX((src_r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((src_g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((src_b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + + *dest = RGB256k.RGB[r][g][b]; + dest += pitch; + } while (--count); + } } void FillColumnRevSubClampPalCommand::Execute(DrawerThread *thread) @@ -1415,6 +1498,8 @@ namespace swrenderer return; dest = _dest; + uint32_t *bg2rgb = _destblend; + uint32_t fg = _srccolor; int pitch = _pitch; @@ -1427,19 +1512,37 @@ namespace swrenderer const PalEntry *palette = GPalette.BaseColors; - do + if (!r_blendmethod) { - int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; - int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; - int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; - int bg = *dest; - int r = MAX((src_r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((src_g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((src_b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + do + { + uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg; + uint32_t b = a; - *dest = RGB256k.RGB[r][g][b]; - dest += pitch; - } while (--count); + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + } while (--count); + } + else + { + do + { + int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; + int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; + int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; + int bg = *dest; + int r = MAX((src_r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((src_g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((src_b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + + *dest = RGB256k.RGB[r][g][b]; + dest += pitch; + } while (--count); + } } void DrawColumnAddPalCommand::Execute(DrawerThread *thread) @@ -1465,21 +1568,41 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; const uint8_t *colormap = _colormap; const uint8_t *source = _source; const PalEntry *palette = GPalette.BaseColors; - do + if (!r_blendmethod) { - uint32_t fg = colormap[source[frac >> FRACBITS]]; - uint32_t bg = *dest; - uint32_t r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); - uint32_t g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); - uint32_t b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); - *dest = RGB256k.RGB[r][g][b]; - dest += pitch; - frac += fracstep; - } while (--count); + do + { + uint32_t fg = colormap[source[frac >> FRACBITS]]; + uint32_t bg = *dest; + + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); + } + else + { + do + { + uint32_t fg = colormap[source[frac >> FRACBITS]]; + uint32_t bg = *dest; + uint32_t r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + uint32_t g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + uint32_t b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnTranslatedPalCommand::Execute(DrawerThread *thread) @@ -1543,23 +1666,43 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; const uint8_t *translation = _translation; const uint8_t *colormap = _colormap; const uint8_t *source = _source; const PalEntry *palette = GPalette.BaseColors; - do + if (!r_blendmethod) { - uint32_t fg = colormap[translation[source[frac >> FRACBITS]]]; - uint32_t bg = *dest; - uint32_t r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); - uint32_t g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); - uint32_t b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); - *dest = RGB256k.RGB[r][g][b]; - dest += pitch; - frac += fracstep; - } while (--count); + do + { + uint32_t fg = colormap[translation[source[frac >> FRACBITS]]]; + uint32_t bg = *dest; + + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); + } + else + { + do + { + uint32_t fg = colormap[translation[source[frac >> FRACBITS]]]; + uint32_t bg = *dest; + uint32_t r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + uint32_t g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + uint32_t b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnShadedPalCommand::Execute(DrawerThread *thread) @@ -1586,21 +1729,37 @@ namespace swrenderer const uint8_t *source = _source; const uint8_t *colormap = _colormap; - + uint32_t *fgstart = &Col2RGB8[0][_color]; const PalEntry *palette = GPalette.BaseColors; - do + if (!r_blendmethod) { - uint32_t val = source[frac >> FRACBITS]; + do + { + uint32_t val = colormap[source[frac >> FRACBITS]]; + uint32_t fg = fgstart[val << 8]; + val = (Col2RGB8[64 - val][*dest] + fg) | 0x1f07c1f; + *dest = RGB32k.All[val & (val >> 15)]; - int r = (palette[*dest].r * (255-val) + palette[_color].r * val) >> 10; - int g = (palette[*dest].g * (255-val) + palette[_color].g * val) >> 10; - int b = (palette[*dest].b * (255-val) + palette[_color].b * val) >> 10; - *dest = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; + dest += pitch; + frac += fracstep; + } while (--count); + } + else + { + do + { + uint32_t val = source[frac >> FRACBITS]; - dest += pitch; - frac += fracstep; - } while (--count); + int r = (palette[*dest].r * (255-val) + palette[_color].r * val) >> 10; + int g = (palette[*dest].g * (255-val) + palette[_color].g * val) >> 10; + int b = (palette[*dest].b * (255-val) + palette[_color].b * val) >> 10; + *dest = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; + + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnAddClampPalCommand::Execute(DrawerThread *thread) @@ -1628,19 +1787,41 @@ namespace swrenderer const uint8_t *colormap = _colormap; const uint8_t *source = _source; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; const PalEntry *palette = GPalette.BaseColors; - do + if (!r_blendmethod) { - int fg = colormap[source[frac >> FRACBITS]]; - int bg = *dest; - int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); - int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); - int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); - *dest = RGB256k.RGB[r][g][b]; - dest += pitch; - frac += fracstep; - } while (--count); + do + { + uint32_t a = fg2rgb[colormap[source[frac >> FRACBITS]]] + bg2rgb[*dest]; + uint32_t b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); + } + else + { + do + { + int fg = colormap[source[frac >> FRACBITS]]; + int bg = *dest; + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnAddClampTranslatedPalCommand::Execute(DrawerThread *thread) @@ -1669,19 +1850,41 @@ namespace swrenderer const uint8_t *translation = _translation; const uint8_t *colormap = _colormap; const uint8_t *source = _source; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; const PalEntry *palette = GPalette.BaseColors; - do + if (!r_blendmethod) { - int fg = colormap[translation[source[frac >> FRACBITS]]]; - int bg = *dest; - int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); - int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); - int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); - *dest = RGB256k.RGB[r][g][b]; - dest += pitch; - frac += fracstep; - } while (--count); + do + { + uint32_t a = fg2rgb[colormap[translation[source[frac >> FRACBITS]]]] + bg2rgb[*dest]; + uint32_t b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[(a >> 15) & a]; + dest += pitch; + frac += fracstep; + } while (--count); + } + else + { + do + { + int fg = colormap[translation[source[frac >> FRACBITS]]]; + int bg = *dest; + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnSubClampPalCommand::Execute(DrawerThread *thread) @@ -1709,19 +1912,40 @@ namespace swrenderer const uint8_t *colormap = _colormap; const uint8_t *source = _source; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; const PalEntry *palette = GPalette.BaseColors; - do + if (!r_blendmethod) { - int fg = colormap[source[frac >> FRACBITS]]; - int bg = *dest; - int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); - *dest = RGB256k.RGB[r][g][b]; - dest += pitch; - frac += fracstep; - } while (--count); + do + { + uint32_t a = (fg2rgb[colormap[source[frac >> FRACBITS]]] | 0x40100400) - bg2rgb[*dest]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); + } + else + { + do + { + int fg = colormap[source[frac >> FRACBITS]]; + int bg = *dest; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnSubClampTranslatedPalCommand::Execute(DrawerThread *thread) @@ -1750,19 +1974,40 @@ namespace swrenderer const uint8_t *translation = _translation; const uint8_t *colormap = _colormap; const uint8_t *source = _source; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; const PalEntry *palette = GPalette.BaseColors; - do + if (!r_blendmethod) { - int fg = colormap[translation[source[frac >> FRACBITS]]]; - int bg = *dest; - int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); - *dest = RGB256k.RGB[r][g][b]; - dest += pitch; - frac += fracstep; - } while (--count); + do + { + uint32_t a = (fg2rgb[colormap[translation[source[frac >> FRACBITS]]]] | 0x40100400) - bg2rgb[*dest]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[(a >> 15) & a]; + dest += pitch; + frac += fracstep; + } while (--count); + } + else + { + do + { + int fg = colormap[translation[source[frac >> FRACBITS]]]; + int bg = *dest; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnRevSubClampPalCommand::Execute(DrawerThread *thread) @@ -1790,19 +2035,40 @@ namespace swrenderer const uint8_t *colormap = _colormap; const uint8_t *source = _source; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; const PalEntry *palette = GPalette.BaseColors; - do + if (!r_blendmethod) { - int fg = colormap[source[frac >> FRACBITS]]; - int bg = *dest; - int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); - *dest = RGB256k.RGB[r][g][b]; - dest += pitch; - frac += fracstep; - } while (--count); + do + { + uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[source[frac >> FRACBITS]]]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[a & (a >> 15)]; + dest += pitch; + frac += fracstep; + } while (--count); + } + else + { + do + { + int fg = colormap[source[frac >> FRACBITS]]; + int bg = *dest; + int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; + dest += pitch; + frac += fracstep; + } while (--count); + } } void DrawColumnRevSubClampTranslatedPalCommand::Execute(DrawerThread *thread) @@ -1831,19 +2097,40 @@ namespace swrenderer const uint8_t *translation = _translation; const uint8_t *colormap = _colormap; const uint8_t *source = _source; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; const PalEntry *palette = GPalette.BaseColors; - do + if (!r_blendmethod) { - int fg = colormap[translation[source[frac >> FRACBITS]]]; - int bg = *dest; - int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); - *dest = RGB256k.RGB[r][g][b]; - dest += pitch; - frac += fracstep; - } while (--count); + do + { + uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[translation[source[frac >> FRACBITS]]]]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[(a >> 15) & a]; + dest += pitch; + frac += fracstep; + } while (--count); + } + else + { + do + { + int fg = colormap[translation[source[frac >> FRACBITS]]]; + int bg = *dest; + int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; + dest += pitch; + frac += fracstep; + } while (--count); + } } ///////////////////////////////////////////////////////////////////////// @@ -2103,6 +2390,8 @@ namespace swrenderer const uint8_t *colormap = _colormap; int count; int spot; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; xfrac = _xfrac; yfrac = _yfrac; @@ -2116,41 +2405,81 @@ namespace swrenderer const PalEntry *palette = GPalette.BaseColors; - if (_xbits == 6 && _ybits == 6) + if (!r_blendmethod) { - // 64x64 is the most common case by far, so special case it. - do + if (_xbits == 6 && _ybits == 6) { - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t fg = colormap[source[spot]]; - uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); - *dest++ = RGB256k.RGB[r][g][b]; - - xfrac += xstep; - yfrac += ystep; - } while (--count); + // 64x64 is the most common case by far, so special case it. + do + { + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t fg = colormap[source[spot]]; + uint32_t bg = *dest; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest++ = RGB32k.All[fg & (fg >> 15)]; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + uint8_t yshift = 32 - _ybits; + uint8_t xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t fg = colormap[source[spot]]; + uint32_t bg = *dest; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest++ = RGB32k.All[fg & (fg >> 15)]; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } else { - uint8_t yshift = 32 - _ybits; - uint8_t xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; - do + if (_xbits == 6 && _ybits == 6) { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t fg = colormap[source[spot]]; - uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); - *dest++ = RGB256k.RGB[r][g][b]; + // 64x64 is the most common case by far, so special case it. + do + { + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t fg = colormap[source[spot]]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest++ = RGB256k.RGB[r][g][b]; - xfrac += xstep; - yfrac += ystep; - } while (--count); + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + uint8_t yshift = 32 - _ybits; + uint8_t xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t fg = colormap[source[spot]]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest++ = RGB256k.RGB[r][g][b]; + + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } } @@ -2168,6 +2497,8 @@ namespace swrenderer const uint8_t *colormap = _colormap; int count; int spot; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; const PalEntry *palette = GPalette.BaseColors; @@ -2181,53 +2512,107 @@ namespace swrenderer xstep = _xstep; ystep = _ystep; - if (_xbits == 6 && _ybits == 6) + if (!r_blendmethod) { - // 64x64 is the most common case by far, so special case it. - do + if (_xbits == 6 && _ybits == 6) { - uint8_t texdata; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - texdata = source[spot]; - if (texdata != 0) + // 64x64 is the most common case by far, so special case it. + do { - uint32_t fg = colormap[texdata]; - uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); - *dest = RGB256k.RGB[r][g][b]; - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint8_t texdata; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t fg = colormap[texdata]; + uint32_t bg = *dest; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg >> 15)]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + uint8_t yshift = 32 - _ybits; + uint8_t xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + uint8_t texdata; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t fg = colormap[texdata]; + uint32_t bg = *dest; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg + bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg >> 15)]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } else { - uint8_t yshift = 32 - _ybits; - uint8_t xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; - do + if (_xbits == 6 && _ybits == 6) { - uint8_t texdata; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - texdata = source[spot]; - if (texdata != 0) + // 64x64 is the most common case by far, so special case it. + do { - uint32_t fg = colormap[texdata]; - uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); - *dest = RGB256k.RGB[r][g][b]; - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint8_t texdata; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t fg = colormap[texdata]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + uint8_t yshift = 32 - _ybits; + uint8_t xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + uint8_t texdata; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t fg = colormap[texdata]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } } @@ -2245,6 +2630,8 @@ namespace swrenderer const uint8_t *colormap = _colormap; int count; int spot; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; const PalEntry *palette = GPalette.BaseColors; xfrac = _xfrac; @@ -2257,41 +2644,87 @@ namespace swrenderer xstep = _xstep; ystep = _ystep; - if (_xbits == 6 && _ybits == 6) + if (!r_blendmethod) { - // 64x64 is the most common case by far, so special case it. - do + if (_xbits == 6 && _ybits == 6) { - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t fg = colormap[source[spot]]; - uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); - *dest++ = RGB256k.RGB[r][g][b]; + // 64x64 is the most common case by far, so special case it. + do + { + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; + uint32_t b = a; - xfrac += xstep; - yfrac += ystep; - } while (--count); + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest++ = RGB32k.All[a & (a >> 15)]; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + uint8_t yshift = 32 - _ybits; + uint8_t xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; + uint32_t b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest++ = RGB32k.All[a & (a >> 15)]; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } else { - uint8_t yshift = 32 - _ybits; - uint8_t xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; - do + if (_xbits == 6 && _ybits == 6) { - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t fg = colormap[source[spot]]; - uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); - *dest++ = RGB256k.RGB[r][g][b]; + // 64x64 is the most common case by far, so special case it. + do + { + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + uint32_t fg = colormap[source[spot]]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest++ = RGB256k.RGB[r][g][b]; - xfrac += xstep; - yfrac += ystep; - } while (--count); + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + uint8_t yshift = 32 - _ybits; + uint8_t xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + uint32_t fg = colormap[source[spot]]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest++ = RGB256k.RGB[r][g][b]; + + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } } @@ -2309,6 +2742,8 @@ namespace swrenderer const uint8_t *colormap = _colormap; int count; int spot; + uint32_t *fg2rgb = _srcblend; + uint32_t *bg2rgb = _destblend; const PalEntry *palette = GPalette.BaseColors; xfrac = _xfrac; @@ -2321,53 +2756,113 @@ namespace swrenderer xstep = _xstep; ystep = _ystep; - if (_xbits == 6 && _ybits == 6) + if (!r_columnmethod) { - // 64x64 is the most common case by far, so special case it. - do + if (_xbits == 6 && _ybits == 6) { - uint8_t texdata; - - spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - texdata = source[spot]; - if (texdata != 0) + // 64x64 is the most common case by far, so special case it. + do { - uint32_t fg = colormap[texdata]; - uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); - *dest = RGB256k.RGB[r][g][b]; - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint8_t texdata; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; + uint32_t b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a >> 15)]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + uint8_t yshift = 32 - _ybits; + uint8_t xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + uint8_t texdata; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; + uint32_t b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a >> 15)]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } else { - uint8_t yshift = 32 - _ybits; - uint8_t xshift = yshift - _xbits; - int xmask = ((1 << _xbits) - 1) << _ybits; - do + if (_xbits == 6 && _ybits == 6) { - uint8_t texdata; - - spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - texdata = source[spot]; - if (texdata != 0) + // 64x64 is the most common case by far, so special case it. + do { - uint32_t fg = colormap[texdata]; - uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); - *dest = RGB256k.RGB[r][g][b]; - } - dest++; - xfrac += xstep; - yfrac += ystep; - } while (--count); + uint8_t texdata; + + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t fg = colormap[texdata]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } + else + { + uint8_t yshift = 32 - _ybits; + uint8_t xshift = yshift - _xbits; + int xmask = ((1 << _xbits) - 1) << _ybits; + do + { + uint8_t texdata; + + spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); + texdata = source[spot]; + if (texdata != 0) + { + uint32_t fg = colormap[texdata]; + uint32_t bg = *dest; + int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; + } + dest++; + xfrac += xstep; + yfrac += ystep; + } while (--count); + } } } diff --git a/src/r_plane.cpp b/src/r_plane.cpp index dbecb5247..b8368e73a 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1509,12 +1509,16 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t if (!additive) { spanfunc = R_DrawSpanMaskedTranslucent; + dc_srcblend = Col2RGB8[alpha>>10]; + dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10]; dc_srcalpha = alpha; dc_destalpha = OPAQUE-alpha; } else { spanfunc = R_DrawSpanMaskedAddClamp; + dc_srcblend = Col2RGB8_LessPrecision[alpha>>10]; + dc_destblend = Col2RGB8_LessPrecision[FRACUNIT>>10]; dc_srcalpha = alpha; dc_destalpha = FRACUNIT; } @@ -1531,12 +1535,16 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t if (!additive) { spanfunc = R_DrawSpanTranslucent; + dc_srcblend = Col2RGB8[alpha>>10]; + dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10]; dc_srcalpha = alpha; dc_destalpha = OPAQUE-alpha; } else { spanfunc = R_DrawSpanAddClamp; + dc_srcblend = Col2RGB8_LessPrecision[alpha>>10]; + dc_destblend = Col2RGB8_LessPrecision[FRACUNIT>>10]; dc_srcalpha = alpha; dc_destalpha = FRACUNIT; } diff --git a/src/r_things.cpp b/src/r_things.cpp index 61da979da..95b563c0d 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -72,6 +72,7 @@ EXTERN_CVAR(Int, r_drawfuzz) EXTERN_CVAR(Bool, r_deathcamera); EXTERN_CVAR(Bool, r_drawplayersprites) EXTERN_CVAR(Bool, r_drawvoxels) +EXTERN_CVAR(Bool, r_blendmethod) CVAR(Bool, r_fullbrightignoresectorcolor, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); //CVAR(Bool, r_splitsprites, true, CVAR_ARCHIVE) @@ -2640,8 +2641,10 @@ static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) void R_DrawParticle (vissprite_t *vis) { + DWORD *bg2rgb; int spacing; BYTE *dest; + DWORD fg; BYTE color = vis->Style.colormap[vis->startfrac]; int yl = vis->y1; int ycount = vis->y2 - yl + 1; @@ -2655,8 +2658,32 @@ void R_DrawParticle (vissprite_t *vis) // vis->renderflags holds translucency level (0-255) fixed_t fglevel, bglevel; - fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff; - bglevel = FRACUNIT-fglevel; + { + DWORD *fg2rgb; + + fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff; + bglevel = FRACUNIT-fglevel; + fg2rgb = Col2RGB8[fglevel>>10]; + bg2rgb = Col2RGB8[bglevel>>10]; + fg = fg2rgb[color]; + } + + /* + + spacing = RenderTarget->GetPitch() - countbase; + dest = ylookup[yl] + x1 + dc_destorg; + + do + { + int count = countbase; + do + { + DWORD bg = bg2rgb[*dest]; + bg = (fg+bg) | 0x1f07c1f; + *dest++ = RGB32k.All[bg & (bg>>15)]; + } while (--count); + dest += spacing; + } while (--ycount);*/ // original was row-wise // width = countbase @@ -2664,20 +2691,40 @@ void R_DrawParticle (vissprite_t *vis) spacing = RenderTarget->GetPitch(); - for (int x = x1; x < (x1+countbase); x++) + if (!r_blendmethod) { - dc_x = x; - if (R_ClipSpriteColumnWithPortals(vis)) - continue; - dest = ylookup[yl] + x + dc_destorg; - for (int y = 0; y < ycount; y++) + for (int x = x1; x < (x1+countbase); x++) { - uint32_t dest_r = MIN((GPalette.BaseColors[*dest].r * bglevel + GPalette.BaseColors[color].r * fglevel) >> 18, 63); - uint32_t dest_g = MIN((GPalette.BaseColors[*dest].g * bglevel + GPalette.BaseColors[color].g * fglevel) >> 18, 63); - uint32_t dest_b = MIN((GPalette.BaseColors[*dest].b * bglevel + GPalette.BaseColors[color].b * fglevel) >> 18, 63); + dc_x = x; + if (R_ClipSpriteColumnWithPortals(vis)) + continue; + dest = ylookup[yl] + x + dc_destorg; + for (int y = 0; y < ycount; y++) + { + DWORD bg = bg2rgb[*dest]; + bg = (fg+bg) | 0x1f07c1f; + *dest = RGB32k.All[bg & (bg>>15)]; + dest += spacing; + } + } + } + else + { + for (int x = x1; x < (x1+countbase); x++) + { + dc_x = x; + if (R_ClipSpriteColumnWithPortals(vis)) + continue; + dest = ylookup[yl] + x + dc_destorg; + for (int y = 0; y < ycount; y++) + { + uint32_t dest_r = MIN((GPalette.BaseColors[*dest].r * bglevel + GPalette.BaseColors[color].r * fglevel) >> 18, 63); + uint32_t dest_g = MIN((GPalette.BaseColors[*dest].g * bglevel + GPalette.BaseColors[color].g * fglevel) >> 18, 63); + uint32_t dest_b = MIN((GPalette.BaseColors[*dest].b * bglevel + GPalette.BaseColors[color].b * fglevel) >> 18, 63); - *dest = RGB256k.RGB[dest_r][dest_g][dest_b]; - dest += spacing; + *dest = RGB256k.RGB[dest_r][dest_g][dest_b]; + dest += spacing; + } } } } From 785b58f57a9c8b93ad407a021ab536d5ed3545b7 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 24 Dec 2016 12:30:45 -0500 Subject: [PATCH 1478/1509] - Reimplemented rgb555 for drawers in r_drawt_pal.cpp --- src/r_drawt_pal.cpp | 529 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 415 insertions(+), 114 deletions(-) diff --git a/src/r_drawt_pal.cpp b/src/r_drawt_pal.cpp index d07ecd67a..dcc0a0938 100644 --- a/src/r_drawt_pal.cpp +++ b/src/r_drawt_pal.cpp @@ -50,6 +50,8 @@ #include "v_video.h" #include "r_draw_pal.h" +EXTERN_CVAR(Bool, r_blendmethod) + // I should have commented this stuff better. // // dc_temp is the buffer R_DrawColumnHoriz writes into. @@ -444,23 +446,42 @@ namespace swrenderer if (count <= 0) return; + const uint32_t *fg2rgb = _srcblend; + const uint32_t *bg2rgb = _destblend; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; colormap = _colormap; const PalEntry *palette = GPalette.BaseColors; - do { - uint32_t fg = colormap[*source]; - uint32_t bg = *dest; + if (!r_blendmethod) + { + do { + uint32_t fg = colormap[*source]; + uint32_t bg = *dest; - int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); - int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); - int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); - *dest = RGB256k.RGB[r][g][b]; - source += 4; - dest += pitch; - } while (--count); + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg+bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg>>15)]; + source += 4; + dest += pitch; + } while (--count); + } + else + { + do { + uint32_t fg = colormap[*source]; + uint32_t bg = *dest; + + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; + source += 4; + dest += pitch; + } while (--count); + } } void DrawColumnRt4AddPalCommand::Execute(DrawerThread *thread) @@ -475,30 +496,72 @@ namespace swrenderer if (count <= 0) return; + const uint32_t *fg2rgb = _srcblend; + const uint32_t *bg2rgb = _destblend; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; pitch = _pitch * thread->num_cores; colormap = _colormap; const PalEntry *palette = GPalette.BaseColors; - do { - for (int ks = 0; ks < 4; ks++) - { // [SP] this 4col function was a block of copy-pasted code. 4 times. I regret nothing. - uint32_t fg = colormap[source[ks]]; - uint32_t bg = dest[ks]; - int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); - int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); - int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); - dest[ks] = RGB256k.RGB[r][g][b]; - } + if (!r_blendmethod) + { + do { + uint32_t fg = colormap[source[0]]; + uint32_t bg = dest[0]; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg+bg) | 0x1f07c1f; + dest[0] = RGB32k.All[fg & (fg>>15)]; - source += 4; - dest += pitch; - } while (--count); + fg = colormap[source[1]]; + bg = dest[1]; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg+bg) | 0x1f07c1f; + dest[1] = RGB32k.All[fg & (fg>>15)]; + + + fg = colormap[source[2]]; + bg = dest[2]; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg+bg) | 0x1f07c1f; + dest[2] = RGB32k.All[fg & (fg>>15)]; + + fg = colormap[source[3]]; + bg = dest[3]; + fg = fg2rgb[fg]; + bg = bg2rgb[bg]; + fg = (fg+bg) | 0x1f07c1f; + dest[3] = RGB32k.All[fg & (fg>>15)]; + + source += 4; + dest += pitch; + } while (--count); + } + else + { + do { + for (int ks = 0; ks < 4; ks++) + { // [SP] this 4col function was a block of copy-pasted code. 4 times. I regret nothing. + uint32_t fg = colormap[source[ks]]; + uint32_t bg = dest[ks]; + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + dest[ks] = RGB256k.RGB[r][g][b]; + } + + source += 4; + dest += pitch; + } while (--count); + } } void DrawColumnRt1ShadedPalCommand::Execute(DrawerThread *thread) { + uint32_t *fgstart; const uint8_t *colormap; uint8_t *source; uint8_t *dest; @@ -509,25 +572,41 @@ namespace swrenderer if (count <= 0) return; + fgstart = &Col2RGB8[0][_color]; colormap = _colormap; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; const PalEntry *palette = GPalette.BaseColors; - do { - uint32_t val = *source; - int r = (palette[*dest].r * (255-val) + palette[_color].r * val) >> 10; - int g = (palette[*dest].g * (255-val) + palette[_color].g * val) >> 10; - int b = (palette[*dest].b * (255-val) + palette[_color].b * val) >> 10; - *dest = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; - source += 4; - dest += pitch; - } while (--count); + if (!r_blendmethod) + { + do { + uint32_t val = colormap[*source]; + uint32_t fg = fgstart[val<<8]; + val = (Col2RGB8[64-val][*dest] + fg) | 0x1f07c1f; + *dest = RGB32k.All[val & (val>>15)]; + source += 4; + dest += pitch; + } while (--count); + } + else + { + do { + uint32_t val = *source; + int r = (palette[*dest].r * (255-val) + palette[_color].r * val) >> 10; + int g = (palette[*dest].g * (255-val) + palette[_color].g * val) >> 10; + int b = (palette[*dest].b * (255-val) + palette[_color].b * val) >> 10; + *dest = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; + source += 4; + dest += pitch; + } while (--count); + } } void DrawColumnRt4ShadedPalCommand::Execute(DrawerThread *thread) { + uint32_t *fgstart; const uint8_t *colormap; uint8_t *source; uint8_t *dest; @@ -538,27 +617,56 @@ namespace swrenderer if (count <= 0) return; + fgstart = &Col2RGB8[0][_color]; colormap = _colormap; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; pitch = _pitch * thread->num_cores; const PalEntry *palette = GPalette.BaseColors; - do { - uint32_t val; + if (!r_blendmethod) + { + do { + uint32_t val; + + val = colormap[source[0]]; + val = (Col2RGB8[64-val][dest[0]] + fgstart[val<<8]) | 0x1f07c1f; + dest[0] = RGB32k.All[val & (val>>15)]; - for (int ks = 0; ks < 4; ks++) - { - val = source[ks]; - int r = (palette[dest[ks]].r * (255-val) + palette[_color].r * val) >> 10; - int g = (palette[dest[ks]].g * (255-val) + palette[_color].g * val) >> 10; - int b = (palette[dest[ks]].b * (255-val) + palette[_color].b * val) >> 10; - dest[ks] = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; - } + val = colormap[source[1]]; + val = (Col2RGB8[64-val][dest[1]] + fgstart[val<<8]) | 0x1f07c1f; + dest[1] = RGB32k.All[val & (val>>15)]; - source += 4; - dest += pitch; - } while (--count); + val = colormap[source[2]]; + val = (Col2RGB8[64-val][dest[2]] + fgstart[val<<8]) | 0x1f07c1f; + dest[2] = RGB32k.All[val & (val>>15)]; + + val = colormap[source[3]]; + val = (Col2RGB8[64-val][dest[3]] + fgstart[val<<8]) | 0x1f07c1f; + dest[3] = RGB32k.All[val & (val>>15)]; + + source += 4; + dest += pitch; + } while (--count); + } + else + { + do { + uint32_t val; + + for (int ks = 0; ks < 4; ks++) + { + val = source[ks]; + int r = (palette[dest[ks]].r * (255-val) + palette[_color].r * val) >> 10; + int g = (palette[dest[ks]].g * (255-val) + palette[_color].g * val) >> 10; + int b = (palette[dest[ks]].b * (255-val) + palette[_color].b * val) >> 10; + dest[ks] = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; + } + + source += 4; + dest += pitch; + } while (--count); + } } void DrawColumnRt1AddClampPalCommand::Execute(DrawerThread *thread) @@ -573,22 +681,43 @@ namespace swrenderer if (count <= 0) return; + const uint32_t *fg2rgb = _srcblend; + const uint32_t *bg2rgb = _destblend; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; pitch = _pitch * thread->num_cores; colormap = _colormap; const PalEntry *palette = GPalette.BaseColors; - do { - int fg = colormap[*source]; - int bg = *dest; - int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); - int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); - int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); - *dest = RGB256k.RGB[r][g][b]; - source += 4; - dest += pitch; - } while (--count); + if (!r_blendmethod) + { + do { + uint32_t a = fg2rgb[colormap[*source]] + bg2rgb[*dest]; + uint32_t b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[(a>>15) & a]; + source += 4; + dest += pitch; + } while (--count); + } + else + { + do { + int fg = colormap[*source]; + int bg = *dest; + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + *dest = RGB256k.RGB[r][g][b]; + source += 4; + dest += pitch; + } while (--count); + } } void DrawColumnRt4AddClampPalCommand::Execute(DrawerThread *thread) @@ -609,20 +738,70 @@ namespace swrenderer colormap = _colormap; const PalEntry *palette = GPalette.BaseColors; - do { - for (int ks = 0; ks < 4; ks++) - { - int fg = colormap[source[ks]]; - int bg = dest[ks]; - int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); - int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); - int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); - dest[ks] = RGB256k.RGB[r][g][b]; - } + const uint32_t *fg2rgb = _srcblend; + const uint32_t *bg2rgb = _destblend; - source += 4; - dest += pitch; - } while (--count); + if (!r_blendmethod) + { + do { + uint32_t a = fg2rgb[colormap[source[0]]] + bg2rgb[dest[0]]; + uint32_t b = a; + + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + dest[0] = RGB32k.All[(a>>15) & a]; + + a = fg2rgb[colormap[source[1]]] + bg2rgb[dest[1]]; + b = a; + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + dest[1] = RGB32k.All[(a>>15) & a]; + + a = fg2rgb[colormap[source[2]]] + bg2rgb[dest[2]]; + b = a; + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + dest[2] = RGB32k.All[(a>>15) & a]; + + a = fg2rgb[colormap[source[3]]] + bg2rgb[dest[3]]; + b = a; + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + dest[3] = RGB32k.All[(a>>15) & a]; + + source += 4; + dest += pitch; + } while (--count); + } + else + { + do { + for (int ks = 0; ks < 4; ks++) + { + int fg = colormap[source[ks]]; + int bg = dest[ks]; + int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); + int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); + int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); + dest[ks] = RGB256k.RGB[r][g][b]; + } + + source += 4; + dest += pitch; + } while (--count); + } } void DrawColumnRt1SubClampPalCommand::Execute(DrawerThread *thread) @@ -645,16 +824,34 @@ namespace swrenderer colormap = _colormap; const PalEntry *palette = GPalette.BaseColors; - do { - int fg = colormap[*source]; - int bg = *dest; - int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); - *dest = RGB256k.RGB[r][g][b]; - source += 4; - dest += pitch; - } while (--count); + if (!r_blendmethod) + { + do { + uint32_t a = (fg2rgb[colormap[*source]] | 0x40100400) - bg2rgb[*dest]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[(a>>15) & a]; + source += 4; + dest += pitch; + } while (--count); + } + else + { + do { + int fg = colormap[*source]; + int bg = *dest; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; + source += 4; + dest += pitch; + } while (--count); + } } void DrawColumnRt4SubClampPalCommand::Execute(DrawerThread *thread) @@ -677,20 +874,63 @@ namespace swrenderer colormap = _colormap; const PalEntry *palette = GPalette.BaseColors; - do { - for (int ks = 0; ks < 4; ks++) - { - int fg = colormap[source[ks]]; - int bg = dest[ks]; - int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); - dest[ks] = RGB256k.RGB[r][g][b]; - } + if (!r_blendmethod) + { + do { + uint32_t a = (fg2rgb[colormap[source[0]]] | 0x40100400) - bg2rgb[dest[0]]; + uint32_t b = a; - source += 4; - dest += pitch; - } while (--count); + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[0] = RGB32k.All[(a>>15) & a]; + + a = (fg2rgb[colormap[source[1]]] | 0x40100400) - bg2rgb[dest[1]]; + b = a; + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[1] = RGB32k.All[(a>>15) & a]; + + a = (fg2rgb[colormap[source[2]]] | 0x40100400) - bg2rgb[dest[2]]; + b = a; + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[2] = RGB32k.All[(a>>15) & a]; + + a = (fg2rgb[colormap[source[3]]] | 0x40100400) - bg2rgb[dest[3]]; + b = a; + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[3] = RGB32k.All[(a>>15) & a]; + + source += 4; + dest += pitch; + } while (--count); + } + else + { + do { + for (int ks = 0; ks < 4; ks++) + { + int fg = colormap[source[ks]]; + int bg = dest[ks]; + int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + dest[ks] = RGB256k.RGB[r][g][b]; + } + + source += 4; + dest += pitch; + } while (--count); + } } void DrawColumnRt1RevSubClampPalCommand::Execute(DrawerThread *thread) @@ -713,16 +953,34 @@ namespace swrenderer colormap = _colormap; const PalEntry *palette = GPalette.BaseColors; - do { - int fg = colormap[*source]; - int bg = *dest; - int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); - *dest = RGB256k.RGB[r][g][b]; - source += 4; - dest += pitch; - } while (--count); + if (!r_blendmethod) + { + do { + uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[*source]]; + uint32_t b = a; + + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + *dest = RGB32k.All[(a>>15) & a]; + source += 4; + dest += pitch; + } while (--count); + } + else + { + do { + int fg = colormap[*source]; + int bg = *dest; + int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + *dest = RGB256k.RGB[r][g][b]; + source += 4; + dest += pitch; + } while (--count); + } } void DrawColumnRt4RevSubClampPalCommand::Execute(DrawerThread *thread) @@ -745,19 +1003,62 @@ namespace swrenderer colormap = _colormap; const PalEntry *palette = GPalette.BaseColors; - do { - for (int ks = 0; ks < 4; ks++) - { - int fg = colormap[source[ks]]; - int bg = dest[ks]; - int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); - dest[ks] = RGB256k.RGB[r][g][b]; - } + if (!r_blendmethod) + { + do { + uint32_t a = (bg2rgb[dest[0]] | 0x40100400) - fg2rgb[colormap[source[0]]]; + uint32_t b = a; - source += 4; - dest += pitch; - } while (--count); + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[0] = RGB32k.All[(a>>15) & a]; + + a = (bg2rgb[dest[1]] | 0x40100400) - fg2rgb[colormap[source[1]]]; + b = a; + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[1] = RGB32k.All[(a>>15) & a]; + + a = (bg2rgb[dest[2]] | 0x40100400) - fg2rgb[colormap[source[2]]]; + b = a; + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[2] = RGB32k.All[(a>>15) & a]; + + a = (bg2rgb[dest[3]] | 0x40100400) - fg2rgb[colormap[source[3]]]; + b = a; + b &= 0x40100400; + b = b - (b >> 5); + a &= b; + a |= 0x01f07c1f; + dest[3] = RGB32k.All[(a>>15) & a]; + + source += 4; + dest += pitch; + } while (--count); + } + else + { + do { + for (int ks = 0; ks < 4; ks++) + { + int fg = colormap[source[ks]]; + int bg = dest[ks]; + int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + dest[ks] = RGB256k.RGB[r][g][b]; + } + + source += 4; + dest += pitch; + } while (--count); + } } } From 9ece249dbb02e5897e5cf972fd3cf8b96ea014c7 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 24 Dec 2016 12:42:27 -0500 Subject: [PATCH 1479/1509] - Reimplemented rgb555 into burn/crossfade in f_wipe.cpp. --- src/f_wipe.cpp | 141 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 101 insertions(+), 40 deletions(-) diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index 8d5f072f6..9d487bc9d 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -30,6 +30,8 @@ #include "templates.h" #include "v_palette.h" +EXTERN_CVAR(Bool, r_blendmethod) + // // SCREEN WIPE PACKAGE // @@ -281,42 +283,80 @@ bool wipe_doBurn (int ticks) fromold = (BYTE *)wipe_scr_start; fromnew = (BYTE *)wipe_scr_end; - for (y = 0, firey = 0; y < SCREENHEIGHT; y++, firey += ystep) + if (!r_blendmethod) { - for (x = 0, firex = 0; x < SCREENWIDTH; x++, firex += xstep) + for (y = 0, firey = 0; y < SCREENHEIGHT; y++, firey += ystep) { - int fglevel; - - fglevel = burnarray[(firex>>SHIFT)+(firey>>SHIFT)*FIREWIDTH] / 2; - if (fglevel >= 63) + for (x = 0, firex = 0; x < SCREENWIDTH; x++, firex += xstep) { - to[x] = fromnew[x]; - } - else if (fglevel == 0) - { - to[x] = fromold[x]; - done = false; - } - else - { - int bglevel = 64-fglevel; + int fglevel; - const PalEntry* pal = GPalette.BaseColors; - - DWORD fg = fromnew[x]; - DWORD bg = fromold[x]; - int r = MIN((pal[fg].r * fglevel + pal[bg].r * bglevel) >> 8, 63); - int g = MIN((pal[fg].g * fglevel + pal[bg].g * bglevel) >> 8, 63); - int b = MIN((pal[fg].b * fglevel + pal[bg].b * bglevel) >> 8, 63); - to[x] = RGB256k.RGB[r][g][b]; - done = false; + fglevel = burnarray[(firex>>SHIFT)+(firey>>SHIFT)*FIREWIDTH] / 2; + if (fglevel >= 63) + { + to[x] = fromnew[x]; + } + else if (fglevel == 0) + { + to[x] = fromold[x]; + done = false; + } + else + { + int bglevel = 64-fglevel; + DWORD *fg2rgb = Col2RGB8[fglevel]; + DWORD *bg2rgb = Col2RGB8[bglevel]; + DWORD fg = fg2rgb[fromnew[x]]; + DWORD bg = bg2rgb[fromold[x]]; + fg = (fg+bg) | 0x1f07c1f; + to[x] = RGB32k.All[fg & (fg>>15)]; + done = false; + } } + fromold += SCREENWIDTH; + fromnew += SCREENWIDTH; + to += SCREENPITCH; } - fromold += SCREENWIDTH; - fromnew += SCREENWIDTH; - to += SCREENPITCH; - } + } + else + { + for (y = 0, firey = 0; y < SCREENHEIGHT; y++, firey += ystep) + { + for (x = 0, firex = 0; x < SCREENWIDTH; x++, firex += xstep) + { + int fglevel; + + fglevel = burnarray[(firex>>SHIFT)+(firey>>SHIFT)*FIREWIDTH] / 2; + if (fglevel >= 63) + { + to[x] = fromnew[x]; + } + else if (fglevel == 0) + { + to[x] = fromold[x]; + done = false; + } + else + { + int bglevel = 64-fglevel; + + const PalEntry* pal = GPalette.BaseColors; + + DWORD fg = fromnew[x]; + DWORD bg = fromold[x]; + int r = MIN((pal[fg].r * fglevel + pal[bg].r * bglevel) >> 8, 63); + int g = MIN((pal[fg].g * fglevel + pal[bg].g * bglevel) >> 8, 63); + int b = MIN((pal[fg].b * fglevel + pal[bg].b * bglevel) >> 8, 63); + to[x] = RGB256k.RGB[r][g][b]; + done = false; + } + } + fromold += SCREENWIDTH; + fromnew += SCREENWIDTH; + to += SCREENPITCH; + } + } return done || (burntime > 40); } @@ -346,25 +386,46 @@ bool wipe_doFade (int ticks) { int x, y; int bglevel = 64 - fade; + DWORD *fg2rgb = Col2RGB8[fade]; + DWORD *bg2rgb = Col2RGB8[bglevel]; BYTE *fromnew = (BYTE *)wipe_scr_end; BYTE *fromold = (BYTE *)wipe_scr_start; BYTE *to = screen->GetBuffer(); const PalEntry *pal = GPalette.BaseColors; - for (y = 0; y < SCREENHEIGHT; y++) + if (!r_blendmethod) { - for (x = 0; x < SCREENWIDTH; x++) + for (y = 0; y < SCREENHEIGHT; y++) { - DWORD fg = fromnew[x]; - DWORD bg = fromold[x]; - int r = MIN((pal[fg].r * (64-bglevel) + pal[bg].r * bglevel) >> 8, 63); - int g = MIN((pal[fg].g * (64-bglevel) + pal[bg].g * bglevel) >> 8, 63); - int b = MIN((pal[fg].b * (64-bglevel) + pal[bg].b * bglevel) >> 8, 63); - to[x] = RGB256k.RGB[r][g][b]; + for (x = 0; x < SCREENWIDTH; x++) + { + DWORD fg = fg2rgb[fromnew[x]]; + DWORD bg = bg2rgb[fromold[x]]; + fg = (fg+bg) | 0x1f07c1f; + to[x] = RGB32k.All[fg & (fg>>15)]; + } + fromnew += SCREENWIDTH; + fromold += SCREENWIDTH; + to += SCREENPITCH; + } + } + else + { + for (y = 0; y < SCREENHEIGHT; y++) + { + for (x = 0; x < SCREENWIDTH; x++) + { + DWORD fg = fromnew[x]; + DWORD bg = fromold[x]; + int r = MIN((pal[fg].r * (64-bglevel) + pal[bg].r * bglevel) >> 8, 63); + int g = MIN((pal[fg].g * (64-bglevel) + pal[bg].g * bglevel) >> 8, 63); + int b = MIN((pal[fg].b * (64-bglevel) + pal[bg].b * bglevel) >> 8, 63); + to[x] = RGB256k.RGB[r][g][b]; + } + fromnew += SCREENWIDTH; + fromold += SCREENWIDTH; + to += SCREENPITCH; } - fromnew += SCREENWIDTH; - fromold += SCREENWIDTH; - to += SCREENPITCH; } } return false; From 2fa13396f20f110af422a6d86d7d1c12a5a80f5f Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 24 Dec 2016 12:50:17 -0500 Subject: [PATCH 1480/1509] - Added r_blendmethod to the menu. --- wadsrc/static/language.enu | 4 ++++ wadsrc/static/menudef.txt | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 28db40e64..8c2b733fd 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1780,6 +1780,8 @@ DSPLYMNU_BRIGHTNESS = "Brightness"; DSPLYMNU_VSYNC = "Vertical Sync"; DSPLYMNU_CAPFPS = "Rendering Interpolation"; DSPLYMNU_COLUMNMETHOD = "Column render mode"; +DSPLYMNU_BLENDMETHOD = "Transparency render mode"; + DSPLYMNU_WIPETYPE = "Screen wipe style"; DSPLYMNU_SHOWENDOOM = "Show ENDOOM screen"; DSPLYMNU_BLOODFADE = "Blood Flash Intensity"; @@ -2189,6 +2191,8 @@ OPTVAL_INVERTED = "Inverted"; OPTVAL_NOTINVERTED = "Not Inverted"; OPTVAL_ORIGINAL = "Original"; OPTVAL_OPTIMIZED = "Optimized"; +OPTVAL_CLASSIC = "Classic (Faster)"; +OPTVAL_PRECISE = "Precise"; OPTVAL_NORMAL = "Normal"; OPTVAL_STRETCH = "Stretch"; OPTVAL_CAPPED = "Capped"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 30cad4dd2..73873c776 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -600,6 +600,12 @@ OptionValue ColumnMethods 1.0, "$OPTVAL_OPTIMIZED" } +OptionValue BlendMethods +{ + 0.0, "$OPTVAL_CLASSIC" + 1.0, "$OPTVAL_PRECISE" +} + OptionValue SkyModes { 0.0, "$OPTVAL_NORMAL" @@ -671,6 +677,7 @@ OptionMenu "VideoOptions" Slider "$DSPLYMNU_PICKUPFADE", "pickup_fade_scalar", 0.0, 1.0, 0.05, 2 Slider "$DSPLYMNU_WATERFADE", "underwater_fade_scalar", 0.0, 1.0, 0.05, 2 Option "$DSPLYMNU_COLUMNMETHOD", "r_columnmethod", "ColumnMethods" + Option "$DSPLYMNU_BLENDMETHOD", "r_blendmethod", "BlendMethods" StaticText " " Option "$DSPLYMNU_WIPETYPE", "wipetype", "Wipes" From 62e093a7da977bbaeefd730f8d1788eb301a1ca3 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 24 Dec 2016 14:10:51 -0500 Subject: [PATCH 1481/1509] - fixed: mistyped r_columnmethod instead of r_blendmethod in a span drawer. --- src/r_draw_pal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 88fe93f85..37d38891e 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -2756,7 +2756,7 @@ namespace swrenderer xstep = _xstep; ystep = _ystep; - if (!r_columnmethod) + if (!r_blendmethod) { if (_xbits == 6 && _ybits == 6) { From 8231032f899365a4c87405812452b1944a6e2c54 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 24 Dec 2016 19:22:31 -0500 Subject: [PATCH 1482/1509] - fixed a crash - tried to make MAKETRANSDOT algorithm more consistent with original --- src/v_draw.cpp | 19 ++++++++++--------- src/v_video.cpp | 11 +++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 703a059ef..b529770d6 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -70,6 +70,7 @@ CUSTOM_CVAR(Int, uiscale, 2, CVAR_ARCHIVE | CVAR_NOINITCALL) StatusBar->ScreenSizeChanged(); } } +EXTERN_CVAR(Bool, r_blendmethod) // [RH] Stretch values to make a 320x200 image best fit the screen // without using fractional steppings @@ -1009,17 +1010,17 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) uint32_t *spot = (uint32_t*)GetBuffer() + oldyyshifted + xx; uint32_t fg = swrenderer::LightBgra::shade_pal_index_simple(basecolor, swrenderer::LightBgra::calc_light_multiplier(0)); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; + uint32_t fg_red = (((fg >> 16) & 0xff) * (63 - level)) >> 6; + uint32_t fg_green = (((fg >> 8) & 0xff) * (63 - level)) >> 6; + uint32_t fg_blue = ((fg & 0xff) * (63 - level)) >> 6; - uint32_t bg_red = (*spot >> 16) & 0xff; - uint32_t bg_green = (*spot >> 8) & 0xff; - uint32_t bg_blue = (*spot) & 0xff; + uint32_t bg_red = (((*spot >> 16) & 0xff) * level) >> 6; + uint32_t bg_green = (((*spot >> 8) & 0xff) * level) >> 6; + uint32_t bg_blue = (((*spot) & 0xff) * level) >> 6; - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; + uint32_t red = fg_red + bg_red; + uint32_t green = fg_green + bg_green; + uint32_t blue = fg_blue + bg_blue; *spot = 0xff000000 | (red << 16) | (green << 8) | blue; } diff --git a/src/v_video.cpp b/src/v_video.cpp index bd322bf52..146e2eb02 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -424,6 +424,17 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) if (!r_blendmethod) { + { + int amount; + + amount = (int)(damount * 64); + bg2rgb = Col2RGB8[64 - amount]; + + fg = (((color.r * amount) >> 4) << 20) | + ((color.g * amount) >> 4) | + (((color.b * amount) >> 4) << 10); + } + for (y = h; y != 0; y--) { for (x = w; x != 0; x--) From b0febec986f6f2b9e4e80ff763f23d242ecd0512 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 25 Dec 2016 05:05:53 +0100 Subject: [PATCH 1483/1509] Removed r_columnmethod as its performance gains are too insignificant to justify its complexity on the codebase --- src/r_draw.cpp | 8 ++--- src/r_draw.h | 4 +-- src/r_main.cpp | 12 ------- src/r_segs.cpp | 71 +------------------------------------- src/r_things.cpp | 72 +-------------------------------------- src/v_draw.cpp | 49 +++----------------------- wadsrc/static/menudef.txt | 1 - 7 files changed, 10 insertions(+), 207 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 14b6ec55a..4ec274593 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -445,7 +445,7 @@ namespace swrenderer if (style.BlendOp == STYLEOP_Fuzz) { colfunc = fuzzcolfunc; - return DoDraw0; + return DoDraw; } else if (style == LegacyRenderStyles[STYLE_Shaded]) { @@ -466,8 +466,7 @@ namespace swrenderer { R_SetColorMapLight(basecolormap, 0, 0); } - bool active_columnmethod = r_columnmethod && !r_swtruecolor; - return active_columnmethod ? DoDraw1 : DoDraw0; + return DoDraw; } fglevel = GetAlpha(style.SrcAlpha, alpha); @@ -500,8 +499,7 @@ namespace swrenderer { return DontDraw; } - bool active_columnmethod = r_columnmethod && !r_swtruecolor; - return active_columnmethod ? DoDraw1 : DoDraw0; + return DoDraw; } ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color) diff --git a/src/r_draw.h b/src/r_draw.h index f0aee6f1a..367cba36b 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -15,7 +15,6 @@ EXTERN_CVAR(Float, r_lod_bias); EXTERN_CVAR(Int, r_drawfuzz); EXTERN_CVAR(Bool, r_drawtrans); EXTERN_CVAR(Float, transsouls); -EXTERN_CVAR(Int, r_columnmethod); EXTERN_CVAR(Bool, r_dynlights); namespace swrenderer @@ -131,8 +130,7 @@ namespace swrenderer enum ESPSResult { DontDraw, // not useful to draw this - DoDraw0, // draw this as if r_columnmethod is 0 - DoDraw1, // draw this as if r_columnmethod is 1 + DoDraw // draw this }; ESPSResult R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color); diff --git a/src/r_main.cpp b/src/r_main.cpp index 17b8e682f..c67b48a1b 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -65,18 +65,6 @@ CVAR (String, r_viewsize, "", CVAR_NOSET) CVAR (Bool, r_shadercolormaps, true, CVAR_ARCHIVE) -CUSTOM_CVAR (Int, r_columnmethod, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -{ - if (self != 0 && self != 1) - { - self = 1; - } - else - { // Trigger the change - setsizeneeded = true; - } -} - CVAR(Int, r_portal_recursions, 4, CVAR_ARCHIVE) CVAR(Bool, r_highlight_portals, false, CVAR_ARCHIVE) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 14abcfc24..f171d7933 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -415,46 +415,13 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) mceilingclip = wallupper; // draw the columns one at a time - if (drawmode == DoDraw0) + if (drawmode == DoDraw) { for (dc_x = x1; dc_x < x2; ++dc_x) { BlastMaskedColumn (tex, false); } } - else - { - // [RH] Draw up to four columns at once - int stop = x2 & ~3; - - if (x1 >= x2) - goto clearfog; - - dc_x = x1; - - while ((dc_x < stop) && (dc_x & 3)) - { - BlastMaskedColumn (tex, false); - dc_x++; - } - - while (dc_x < stop) - { - rt_initcols(nullptr); - BlastMaskedColumn (tex, true); dc_x++; - BlastMaskedColumn (tex, true); dc_x++; - BlastMaskedColumn (tex, true); dc_x++; - BlastMaskedColumn (tex, true); - rt_draw4cols (dc_x - 3); - dc_x++; - } - - while (dc_x < x2) - { - BlastMaskedColumn (tex, false); - dc_x++; - } - } } else { // Texture does wrap vertically. @@ -2346,42 +2313,6 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, } else { - int stop4; - - if (mode == DoDraw0) - { // 1 column at a time - stop4 = dc_x; - } - else // DoDraw1 - { // up to 4 columns at a time - stop4 = x2 & ~3; - } - - while ((dc_x < stop4) && (dc_x & 3)) - { - if (calclighting) - { // calculate lighting - R_SetColorMapLight(usecolormap, rw_light, wallshade); - } - R_WallSpriteColumn (false); - dc_x++; - } - - while (dc_x < stop4) - { - if (calclighting) - { // calculate lighting - R_SetColorMapLight(usecolormap, rw_light, wallshade); - } - rt_initcols(nullptr); - for (int zz = 4; zz; --zz) - { - R_WallSpriteColumn (true); - dc_x++; - } - rt_draw4cols (dc_x - 4); - } - while (dc_x < x2) { if (calclighting) diff --git a/src/r_things.cpp b/src/r_things.cpp index 53e3c0589..7b6114d00 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -530,7 +530,7 @@ void R_DrawVisSprite (vissprite_t *vis) { fixed_t frac; FTexture *tex; - int x2, stop4; + int x2; fixed_t xiscale; ESPSResult mode; bool ispsprite = (!vis->sector && vis->gpos != FVector3(0, 0, 0)); @@ -554,17 +554,6 @@ void R_DrawVisSprite (vissprite_t *vis) if (mode != DontDraw) { - if (mode == DoDraw0) - { - // One column at a time - stop4 = vis->x1; - } - else // DoDraw1 - { - // Up to four columns at a time - stop4 = vis->x2 & ~3; - } - tex = vis->pic; spryscale = vis->yscale; sprflipvert = false; @@ -592,27 +581,6 @@ void R_DrawVisSprite (vissprite_t *vis) if (dc_x < x2) { - while ((dc_x < stop4) && (dc_x & 3)) - { - if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (tex, frac, false); - dc_x++; - frac += xiscale; - } - - while (dc_x < stop4) - { - rt_initcols(nullptr); - for (int zz = 4; zz; --zz) - { - if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (tex, frac, true); - dc_x++; - frac += xiscale; - } - rt_draw4cols (dc_x - 4); - } - while (dc_x < x2) { if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) @@ -708,44 +676,6 @@ void R_DrawWallSprite(vissprite_t *spr) } else { - int stop4; - - if (mode == DoDraw0) - { // 1 column at a time - stop4 = dc_x; - } - else // DoDraw1 - { // up to 4 columns at a time - stop4 = x2 & ~3; - } - - while ((dc_x < stop4) && (dc_x & 3)) - { - if (calclighting) - { // calculate lighting - R_SetColorMapLight(usecolormap, rw_light, shade); - } - if (!R_ClipSpriteColumnWithPortals(spr)) - R_WallSpriteColumn(false); - dc_x++; - } - - while (dc_x < stop4) - { - if (calclighting) - { // calculate lighting - R_SetColorMapLight(usecolormap, rw_light, shade); - } - rt_initcols(nullptr); - for (int zz = 4; zz; --zz) - { - if (!R_ClipSpriteColumnWithPortals(spr)) - R_WallSpriteColumn(true); - dc_x++; - } - rt_draw4cols(dc_x - 4); - } - while (dc_x < x2) { if (calclighting) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index b529770d6..0e75bc282 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -210,8 +210,6 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) if (mode != DontDraw) { - int stop4; - double centeryback = CenterY; CenterY = 0; @@ -277,56 +275,17 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) x2 = parms.rclip; } - // Drawing short output ought to fit in the data cache well enough - // if we draw one column at a time, so do that, since it's simpler. - if (parms.destheight < 32 || (parms.dclip - parms.uclip) < 32) - { - mode = DoDraw0; - } - dc_x = int(x0); int x2_i = int(x2); fixed_t xiscale_i = FLOAT2FIXED(xiscale); - if (mode == DoDraw0) + while (dc_x < x2_i) { - // One column at a time - stop4 = dc_x; - } - else // DoDraw1` - { - // Up to four columns at a time - stop4 = x2_i & ~3; + R_DrawMaskedColumn(img, frac, false, !parms.masked); + dc_x++; + frac += xiscale_i; } - if (dc_x < x2_i) - { - while ((dc_x < stop4) && (dc_x & 3)) - { - R_DrawMaskedColumn(img, frac, false, !parms.masked); - dc_x++; - frac += xiscale_i; - } - - while (dc_x < stop4) - { - rt_initcols(nullptr); - for (int zz = 4; zz; --zz) - { - R_DrawMaskedColumn(img, frac, true, !parms.masked); - dc_x++; - frac += xiscale_i; - } - rt_draw4cols(dc_x - 4); - } - - while (dc_x < x2_i) - { - R_DrawMaskedColumn(img, frac, false, !parms.masked); - dc_x++; - frac += xiscale_i; - } - } CenterY = centeryback; } R_FinishSetPatchStyle (); diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 8882c89ae..314534bb7 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -704,7 +704,6 @@ OptionMenu "VideoOptions" Slider "$DSPLYMNU_BLOODFADE", "blood_fade_scalar", 0.0, 1.0, 0.05, 2 Slider "$DSPLYMNU_PICKUPFADE", "pickup_fade_scalar", 0.0, 1.0, 0.05, 2 Slider "$DSPLYMNU_WATERFADE", "underwater_fade_scalar", 0.0, 1.0, 0.05, 2 - Option "$DSPLYMNU_COLUMNMETHOD", "r_columnmethod", "ColumnMethods" Option "$DSPLYMNU_BLENDMETHOD", "r_blendmethod", "BlendMethods" StaticText " " From 57593adeb00df85011dc7a2ac6ab634884deb8e8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 25 Dec 2016 05:15:23 +0100 Subject: [PATCH 1484/1509] Simplify ESPSResult to a boolean --- src/r_draw.cpp | 14 +++++++------- src/r_draw.h | 10 ++-------- src/r_segs.cpp | 26 ++++++++------------------ src/r_things.cpp | 15 ++++++--------- src/v_draw.cpp | 8 ++++---- 5 files changed, 27 insertions(+), 46 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 4ec274593..c7bf95eed 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -393,7 +393,7 @@ namespace swrenderer FDynamicColormap *basecolormapsave; } - ESPSResult R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color) + bool R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color) { using namespace drawerargs; @@ -445,13 +445,13 @@ namespace swrenderer if (style.BlendOp == STYLEOP_Fuzz) { colfunc = fuzzcolfunc; - return DoDraw; + return true; } else if (style == LegacyRenderStyles[STYLE_Shaded]) { // Shaded drawer only gets 16 levels of alpha because it saves memory. if ((alpha >>= 12) == 0) - return DontDraw; + return false; colfunc = R_DrawShadedColumn; hcolfunc_post1 = rt_shaded1col; hcolfunc_post4 = rt_shaded4cols; @@ -466,7 +466,7 @@ namespace swrenderer { R_SetColorMapLight(basecolormap, 0, 0); } - return DoDraw; + return true; } fglevel = GetAlpha(style.SrcAlpha, alpha); @@ -497,12 +497,12 @@ namespace swrenderer if (!R_SetBlendFunc(style.BlendOp, fglevel, bglevel, style.Flags)) { - return DontDraw; + return false; } - return DoDraw; + return true; } - ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color) + bool R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color) { return R_SetPatchStyle(style, FLOAT2FIXED(alpha), translation, color); } diff --git a/src/r_draw.h b/src/r_draw.h index 367cba36b..752647943 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -127,14 +127,8 @@ namespace swrenderer void R_InitShadeMaps(); void R_InitFuzzTable(int fuzzoff); - enum ESPSResult - { - DontDraw, // not useful to draw this - DoDraw // draw this - }; - - ESPSResult R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color); - ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color); + bool R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color); + bool R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color); void R_FinishSetPatchStyle(); // Call this after finished drawing the current thing, in case its style was STYLE_Shade bool R_GetTransMaskDrawers(void(**drawCol1)(), void(**drawCol4)()); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index f171d7933..edad2aecc 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -218,14 +218,10 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) curline = ds->curline; - // killough 4/11/98: draw translucent 2s normal textures - // [RH] modified because we don't use user-definable translucency maps - ESPSResult drawmode; - - drawmode = R_SetPatchStyle (LegacyRenderStyles[curline->linedef->flags & ML_ADDTRANS ? STYLE_Add : STYLE_Translucent], + bool visible = R_SetPatchStyle (LegacyRenderStyles[curline->linedef->flags & ML_ADDTRANS ? STYLE_Add : STYLE_Translucent], (float)MIN(curline->linedef->alpha, 1.), 0, 0); - if ((drawmode == DontDraw && !ds->bFogBoundary && !ds->bFakeBoundary)) + if (!visible && !ds->bFogBoundary && !ds->bFakeBoundary) { return; } @@ -280,7 +276,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) goto clearfog; } } - if ((ds->bFakeBoundary && !(ds->bFakeBoundary & 4)) || drawmode == DontDraw) + if ((ds->bFakeBoundary && !(ds->bFakeBoundary & 4)) || !visible) { goto clearfog; } @@ -415,7 +411,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) mceilingclip = wallupper; // draw the columns one at a time - if (drawmode == DoDraw) + if (visible) { for (dc_x = x1; dc_x < x2; ++dc_x) { @@ -512,11 +508,10 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) double yscale; fixed_t Alpha = Scale(rover->alpha, OPAQUE, 255); - ESPSResult drawmode; - drawmode = R_SetPatchStyle (LegacyRenderStyles[rover->flags & FF_ADDITIVETRANS ? STYLE_Add : STYLE_Translucent], + bool visible = R_SetPatchStyle (LegacyRenderStyles[rover->flags & FF_ADDITIVETRANS ? STYLE_Add : STYLE_Translucent], Alpha, 0, 0); - if(drawmode == DontDraw) { + if(!visible) { R_FinishSetPatchStyle(); return; } @@ -2297,9 +2292,8 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, do { dc_x = x1; - ESPSResult mode; - mode = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); + bool visible = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); // R_SetPatchStyle can modify basecolormap. if (rereadcolormap) @@ -2307,11 +2301,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, usecolormap = basecolormap; } - if (mode == DontDraw) - { - needrepeat = 0; - } - else + if (visible) { while (dc_x < x2) { diff --git a/src/r_things.cpp b/src/r_things.cpp index 7b6114d00..22d6b7ac6 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -532,7 +532,6 @@ void R_DrawVisSprite (vissprite_t *vis) FTexture *tex; int x2; fixed_t xiscale; - ESPSResult mode; bool ispsprite = (!vis->sector && vis->gpos != FVector3(0, 0, 0)); if (vis->xscale == 0 || fabs(vis->yscale) < (1.0f / 32000.0f)) @@ -543,7 +542,7 @@ void R_DrawVisSprite (vissprite_t *vis) fixed_t centeryfrac = FLOAT2FIXED(CenterY); R_SetColorMapLight(vis->Style.BaseColormap, 0, vis->Style.ColormapNum << FRACBITS); - mode = R_SetPatchStyle (vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor); + bool visible = R_SetPatchStyle (vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor); if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Shaded]) { // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but @@ -552,7 +551,7 @@ void R_DrawVisSprite (vissprite_t *vis) R_SetColorMapLight(dc_fcolormap, 0, vis->Style.ColormapNum << FRACBITS); } - if (mode != DontDraw) + if (visible) { tex = vis->pic; spryscale = vis->yscale; @@ -660,9 +659,8 @@ void R_DrawWallSprite(vissprite_t *spr) MaskedScaleY = (float)iyscale; dc_x = x1; - ESPSResult mode; - mode = R_SetPatchStyle (spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); + bool visible = R_SetPatchStyle (spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); // R_SetPatchStyle can modify basecolormap. if (rereadcolormap) @@ -670,7 +668,7 @@ void R_DrawWallSprite(vissprite_t *spr) usecolormap = basecolormap; } - if (mode == DontDraw) + if (!visible) { return; } @@ -707,14 +705,13 @@ void R_WallSpriteColumn (bool useRt) void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop, short *clipbot) { - ESPSResult mode; int flags = 0; // Do setup for blending. R_SetColorMapLight(spr->Style.BaseColormap, 0, spr->Style.ColormapNum << FRACBITS); - mode = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); + bool visible = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); - if (mode == DontDraw) + if (!visible) { return; } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 0e75bc282..df5dd5cf0 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -190,11 +190,11 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) } fixedcolormap = dc_fcolormap; - ESPSResult mode; + bool visible; if (r_swtruecolor) - mode = R_SetPatchStyle(parms.style, parms.Alpha, -1, parms.fillcolor); + visible = R_SetPatchStyle(parms.style, parms.Alpha, -1, parms.fillcolor); else - mode = R_SetPatchStyle(parms.style, parms.Alpha, 0, parms.fillcolor); + visible = R_SetPatchStyle(parms.style, parms.Alpha, 0, parms.fillcolor); BYTE *destorgsave = dc_destorg; int destheightsave = dc_destheight; @@ -208,7 +208,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) double x0 = parms.x - parms.left * parms.destwidth / parms.texwidth; double y0 = parms.y - parms.top * parms.destheight / parms.texheight; - if (mode != DontDraw) + if (visible) { double centeryback = CenterY; CenterY = 0; From ced7bdf94a9ff8ce13501f49066c9330e432c1d7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 25 Dec 2016 05:46:16 +0100 Subject: [PATCH 1485/1509] Remove rt drawer family and the infrastructure supporting it --- src/CMakeLists.txt | 2 - src/r_draw.cpp | 541 --------- src/r_draw.h | 30 - src/r_draw_pal.h | 84 -- src/r_draw_rgba.cpp | 80 ++ src/r_draw_rgba.h | 79 -- src/r_drawers.cpp | 24 - src/r_drawers.h | 24 - src/r_drawt_pal.cpp | 1064 ----------------- src/r_drawt_rgba.cpp | 314 ----- src/r_main.cpp | 11 - src/r_main.h | 6 - src/r_poly_triangle.cpp | 1 - src/r_segs.cpp | 2 - src/r_things.cpp | 20 +- src/r_thread.h | 11 - .../fixedfunction/drawcolumncodegen.cpp | 142 +-- .../fixedfunction/drawcolumncodegen.h | 17 +- tools/drawergen/llvmdrawers.cpp | 60 +- tools/drawergen/llvmdrawers.h | 2 +- 20 files changed, 150 insertions(+), 2364 deletions(-) delete mode 100644 src/r_drawt_pal.cpp delete mode 100644 src/r_drawt_rgba.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aa67b13d1..ede6c9a52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -818,9 +818,7 @@ set( FASTMATH_PCH_SOURCES r_bsp.cpp r_draw.cpp r_draw_pal.cpp - r_drawt_pal.cpp r_draw_rgba.cpp - r_drawt_rgba.cpp r_drawers.cpp r_thread.cpp r_main.cpp diff --git a/src/r_draw.cpp b/src/r_draw.cpp index c7bf95eed..f629c027d 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -147,9 +147,6 @@ namespace swrenderer fuzzcolfunc = R_DrawFuzzColumn; transcolfunc = R_DrawTranslatedColumn; spanfunc = R_DrawSpan; - hcolfunc_pre = R_DrawColumnHoriz; - hcolfunc_post1 = rt_map1col; - hcolfunc_post4 = rt_map4cols; } void R_InitShadeMaps() @@ -233,20 +230,14 @@ namespace swrenderer if (flags & STYLEF_ColorIsFixed) { colfunc = R_FillColumn; - hcolfunc_post1 = rt_copy1col; - hcolfunc_post4 = rt_copy4cols; } else if (dc_translation == NULL) { colfunc = basecolfunc; - hcolfunc_post1 = rt_map1col; - hcolfunc_post4 = rt_map4cols; } else { colfunc = transcolfunc; - hcolfunc_post1 = rt_tlate1col; - hcolfunc_post4 = rt_tlate4cols; drawer_needs_pal_input = true; } return true; @@ -284,20 +275,14 @@ namespace swrenderer if (flags & STYLEF_ColorIsFixed) { colfunc = R_FillAddColumn; - hcolfunc_post1 = rt_add1col; - hcolfunc_post4 = rt_add4cols; } else if (dc_translation == NULL) { colfunc = R_DrawAddColumn; - hcolfunc_post1 = rt_add1col; - hcolfunc_post4 = rt_add4cols; } else { colfunc = R_DrawTlatedAddColumn; - hcolfunc_post1 = rt_tlateadd1col; - hcolfunc_post4 = rt_tlateadd4cols; drawer_needs_pal_input = true; } } @@ -306,20 +291,14 @@ namespace swrenderer if (flags & STYLEF_ColorIsFixed) { colfunc = R_FillAddClampColumn; - hcolfunc_post1 = rt_addclamp1col; - hcolfunc_post4 = rt_addclamp4cols; } else if (dc_translation == NULL) { colfunc = R_DrawAddClampColumn; - hcolfunc_post1 = rt_addclamp1col; - hcolfunc_post4 = rt_addclamp4cols; } else { colfunc = R_DrawAddClampTranslatedColumn; - hcolfunc_post1 = rt_tlateaddclamp1col; - hcolfunc_post4 = rt_tlateaddclamp4cols; drawer_needs_pal_input = true; } } @@ -329,20 +308,14 @@ namespace swrenderer if (flags & STYLEF_ColorIsFixed) { colfunc = R_FillSubClampColumn; - hcolfunc_post1 = rt_subclamp1col; - hcolfunc_post4 = rt_subclamp4cols; } else if (dc_translation == NULL) { colfunc = R_DrawSubClampColumn; - hcolfunc_post1 = rt_subclamp1col; - hcolfunc_post4 = rt_subclamp4cols; } else { colfunc = R_DrawSubClampTranslatedColumn; - hcolfunc_post1 = rt_tlatesubclamp1col; - hcolfunc_post4 = rt_tlatesubclamp4cols; drawer_needs_pal_input = true; } return true; @@ -355,20 +328,14 @@ namespace swrenderer if (flags & STYLEF_ColorIsFixed) { colfunc = R_FillRevSubClampColumn; - hcolfunc_post1 = rt_subclamp1col; - hcolfunc_post4 = rt_subclamp4cols; } else if (dc_translation == NULL) { colfunc = R_DrawRevSubClampColumn; - hcolfunc_post1 = rt_revsubclamp1col; - hcolfunc_post4 = rt_revsubclamp4cols; } else { colfunc = R_DrawRevSubClampTranslatedColumn; - hcolfunc_post1 = rt_tlaterevsubclamp1col; - hcolfunc_post4 = rt_tlaterevsubclamp4cols; drawer_needs_pal_input = true; } return true; @@ -439,7 +406,6 @@ namespace swrenderer } } basecolormapsave = basecolormap; - hcolfunc_pre = R_DrawColumnHoriz; // Check for special modes if (style.BlendOp == STYLEOP_Fuzz) @@ -453,8 +419,6 @@ namespace swrenderer if ((alpha >>= 12) == 0) return false; colfunc = R_DrawShadedColumn; - hcolfunc_post1 = rt_shaded1col; - hcolfunc_post4 = rt_shaded4cols; drawer_needs_pal_input = true; dc_color = fixedcolormap ? fixedcolormap->Maps[APART(color)] : basecolormap->Maps[APART(color)]; basecolormap = &ShadeFakeColormap[16 - alpha]; @@ -491,7 +455,6 @@ namespace swrenderer // dc_srccolor is used by the R_Fill* routines. It is premultiplied // with the alpha. dc_srccolor = ((((r*x) >> 4) << 20) | ((g*x) >> 4) | ((((b)*x) >> 4) << 10)) & 0x3feffbff; - hcolfunc_pre = R_FillColumnHoriz; R_SetColorMapLight(&identitycolormap, 0, 0); } @@ -638,191 +601,6 @@ namespace swrenderer } } - void rt_initcols(uint8_t *buffer) - { - using namespace drawerargs; - - for (int y = 3; y >= 0; y--) - horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0]; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(buffer); - else - DrawerCommandQueue::QueueCommand(buffer); - } - - void rt_span_coverage(int x, int start, int stop) - { - using namespace drawerargs; - - unsigned int **tspan = &dc_ctspan[x & 3]; - (*tspan)[0] = start; - (*tspan)[1] = stop; - *tspan += 2; - } - - void rt_flip_posts() - { - using namespace drawerargs; - - unsigned int *front = horizspan[dc_x & 3]; - unsigned int *back = dc_ctspan[dc_x & 3] - 2; - - while (front < back) - { - swapvalues(front[0], back[0]); - swapvalues(front[1], back[1]); - front += 2; - back -= 2; - } - } - - void rt_draw4cols(int sx) - { - using namespace drawerargs; - - int x, bad; - unsigned int maxtop, minbot, minnexttop; - - // Place a dummy "span" in each column. These don't get - // drawn. They're just here to avoid special cases in the - // max/min calculations below. - for (x = 0; x < 4; ++x) - { - dc_ctspan[x][0] = screen->GetHeight()+1; - dc_ctspan[x][1] = screen->GetHeight(); - } - - for (;;) - { - // If a column is out of spans, mark it as such - bad = 0; - minnexttop = 0xffffffff; - for (x = 0; x < 4; ++x) - { - if (horizspan[x] >= dc_ctspan[x]) - { - bad |= 1 << x; - } - else if ((horizspan[x]+2)[0] < minnexttop) - { - minnexttop = (horizspan[x]+2)[0]; - } - } - // Once all columns are out of spans, we're done - if (bad == 15) - { - return; - } - - // Find the largest shared area for the spans in each column - maxtop = MAX (MAX (horizspan[0][0], horizspan[1][0]), - MAX (horizspan[2][0], horizspan[3][0])); - minbot = MIN (MIN (horizspan[0][1], horizspan[1][1]), - MIN (horizspan[2][1], horizspan[3][1])); - - // If there is no shared area with these spans, draw each span - // individually and advance to the next spans until we reach a shared area. - // However, only draw spans down to the highest span in the next set of - // spans. If we allow the entire height of a span to be drawn, it could - // prevent any more shared areas from being drawn in these four columns. - // - // Example: Suppose we have the following arrangement: - // A CD - // A CD - // B D - // B D - // aB D - // aBcD - // aBcD - // aBc - // - // If we draw the entire height of the spans, we end up drawing this first: - // A CD - // A CD - // B D - // B D - // B D - // B D - // B D - // B D - // B - // - // This leaves only the "a" and "c" columns to be drawn, and they are not - // part of a shared area, but if we can include B and D with them, we can - // get a shared area. So we cut off everything in the first set just - // above the "a" column and end up drawing this first: - // A CD - // A CD - // B D - // B D - // - // Then the next time through, we have the following arrangement with an - // easily shared area to draw: - // aB D - // aBcD - // aBcD - // aBc - if (bad != 0 || maxtop > minbot) - { - int drawcount = 0; - for (x = 0; x < 4; ++x) - { - if (!(bad & 1)) - { - if (horizspan[x][1] < minnexttop) - { - hcolfunc_post1 (x, sx+x, horizspan[x][0], horizspan[x][1]); - horizspan[x] += 2; - drawcount++; - } - else if (minnexttop > horizspan[x][0]) - { - hcolfunc_post1 (x, sx+x, horizspan[x][0], minnexttop-1); - horizspan[x][0] = minnexttop; - drawcount++; - } - } - bad >>= 1; - } - // Drawcount *should* always be non-zero. The reality is that some situations - // can make this not true. Unfortunately, I'm not sure what those situations are. - if (drawcount == 0) - { - return; - } - continue; - } - - // Draw any span fragments above the shared area. - for (x = 0; x < 4; ++x) - { - if (maxtop > horizspan[x][0]) - { - hcolfunc_post1 (x, sx+x, horizspan[x][0], maxtop-1); - } - } - - // Draw the shared area. - hcolfunc_post4 (sx, maxtop, minbot); - - // For each column, if part of the span is past the shared area, - // set its top to just below the shared area. Otherwise, advance - // to the next span in that column. - for (x = 0; x < 4; ++x) - { - if (minbot < horizspan[x][1]) - { - horizspan[x][0] = minbot+1; - } - else - { - horizspan[x] += 2; - } - } - } - } - void R_SetupSpanBits(FTexture *tex) { using namespace drawerargs; @@ -855,325 +633,6 @@ namespace swrenderer ///////////////////////////////////////////////////////////////////////// - void R_FillColumnHoriz() - { - using namespace drawerargs; - - if (dc_count <= 0) - return; - - int x = dc_x & 3; - unsigned int **span = &dc_ctspan[x]; - (*span)[0] = dc_yl; - (*span)[1] = dc_yh; - *span += 2; - - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(); - else - DrawerCommandQueue::QueueCommand(); - } - - void R_DrawColumnHoriz() - { - using namespace drawerargs; - - if (dc_count <= 0) - return; - - int x = dc_x & 3; - unsigned int **span = &dc_ctspan[x]; - (*span)[0] = dc_yl; - (*span)[1] = dc_yh; - *span += 2; - - if (r_swtruecolor) - { - if (drawer_needs_pal_input) - DrawerCommandQueue::QueueCommand>(); - else - DrawerCommandQueue::QueueCommand>(); - } - else - { - DrawerCommandQueue::QueueCommand(); - } - } - - // Copies one span at hx to the screen at sx. - void rt_copy1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - - // Copies all four spans to the screen starting at sx. - void rt_copy4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - { - // To do: we could do this with SSE using __m128i - rt_copy1col(0, sx, yl, yh); - rt_copy1col(1, sx + 1, yl, yh); - rt_copy1col(2, sx + 2, yl, yh); - rt_copy1col(3, sx + 3, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - } - - // Maps one span at hx to the screen at sx. - void rt_map1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - - // Maps all four spans to the screen starting at sx. - void rt_map4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - - // Translates one span at hx to the screen at sx. - void rt_tlate1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_map1col(hx, sx, yl, yh); - } - } - - // Translates all four spans to the screen starting at sx. - void rt_tlate4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_map4cols(sx, yl, yh); - } - } - - // Adds one span at hx to the screen at sx without clamping. - void rt_add1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - - // Adds all four spans to the screen starting at sx without clamping. - void rt_add4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - - // Translates and adds one span at hx to the screen at sx without clamping. - void rt_tlateadd1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_add1col(hx, sx, yl, yh); - } - } - - // Translates and adds all four spans to the screen starting at sx without clamping. - void rt_tlateadd4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_add4cols(sx, yl, yh); - } - } - - // Shades one span at hx to the screen at sx. - void rt_shaded1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - - // Shades all four spans to the screen starting at sx. - void rt_shaded4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - - // Adds one span at hx to the screen at sx with clamping. - void rt_addclamp1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - - // Adds all four spans to the screen starting at sx with clamping. - void rt_addclamp4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - - // Translates and adds one span at hx to the screen at sx with clamping. - void rt_tlateaddclamp1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_addclamp1col(hx, sx, yl, yh); - } - } - - // Translates and adds all four spans to the screen starting at sx with clamping. - void rt_tlateaddclamp4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_addclamp4cols(sx, yl, yh); - } - } - - // Subtracts one span at hx to the screen at sx with clamping. - void rt_subclamp1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - - // Subtracts all four spans to the screen starting at sx with clamping. - void rt_subclamp4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - - // Translates and subtracts one span at hx to the screen at sx with clamping. - void rt_tlatesubclamp1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_subclamp1col(hx, sx, yl, yh); - } - } - - // Translates and subtracts all four spans to the screen starting at sx with clamping. - void rt_tlatesubclamp4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_subclamp4cols(sx, yl, yh); - } - } - - // Subtracts one span at hx from the screen at sx with clamping. - void rt_revsubclamp1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - - // Subtracts all four spans from the screen starting at sx with clamping. - void rt_revsubclamp4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - else - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - - // Translates and subtracts one span at hx from the screen at sx with clamping. - void rt_tlaterevsubclamp1col(int hx, int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(hx, sx, yl, yh); - rt_revsubclamp1col(hx, sx, yl, yh); - } - } - - // Translates and subtracts all four spans from the screen starting at sx with clamping. - void rt_tlaterevsubclamp4cols(int sx, int yl, int yh) - { - if (r_swtruecolor) - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - } - else - { - DrawerCommandQueue::QueueCommand(0, sx, yl, yh); - rt_revsubclamp4cols(sx, yl, yh); - } - } - void R_DrawWallCol1() { if (r_swtruecolor) diff --git a/src/r_draw.h b/src/r_draw.h index 752647943..c508aa268 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -134,35 +134,6 @@ namespace swrenderer const uint8_t *R_GetColumn(FTexture *tex, int col); - void rt_initcols(uint8_t *buffer = nullptr); - void rt_span_coverage(int x, int start, int stop); - void rt_draw4cols(int sx); - void rt_flip_posts(); - void rt_copy1col(int hx, int sx, int yl, int yh); - void rt_copy4cols(int sx, int yl, int yh); - void rt_shaded1col(int hx, int sx, int yl, int yh); - void rt_shaded4cols(int sx, int yl, int yh); - void rt_map1col(int hx, int sx, int yl, int yh); - void rt_add1col(int hx, int sx, int yl, int yh); - void rt_addclamp1col(int hx, int sx, int yl, int yh); - void rt_subclamp1col(int hx, int sx, int yl, int yh); - void rt_revsubclamp1col(int hx, int sx, int yl, int yh); - void rt_tlate1col(int hx, int sx, int yl, int yh); - void rt_tlateadd1col(int hx, int sx, int yl, int yh); - void rt_tlateaddclamp1col(int hx, int sx, int yl, int yh); - void rt_tlatesubclamp1col(int hx, int sx, int yl, int yh); - void rt_tlaterevsubclamp1col(int hx, int sx, int yl, int yh); - void rt_map4cols(int sx, int yl, int yh); - void rt_add4cols(int sx, int yl, int yh); - void rt_addclamp4cols(int sx, int yl, int yh); - void rt_subclamp4cols(int sx, int yl, int yh); - void rt_revsubclamp4cols(int sx, int yl, int yh); - void rt_tlate4cols(int sx, int yl, int yh); - void rt_tlateadd4cols(int sx, int yl, int yh); - void rt_tlateaddclamp4cols(int sx, int yl, int yh); - void rt_tlatesubclamp4cols(int sx, int yl, int yh); - void rt_tlaterevsubclamp4cols(int sx, int yl, int yh); - void R_DrawColumnHoriz(); void R_DrawColumn(); void R_DrawFuzzColumn(); void R_DrawTranslatedColumn(); @@ -192,7 +163,6 @@ namespace swrenderer void R_SetupDrawSlab(FSWColormap *base_colormap, float light, int shade); void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p); void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip); - void R_FillColumnHoriz(); void R_FillSpan(); void R_DrawWallCol1(); diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index 205e0cc28..984849b83 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -248,88 +248,4 @@ namespace swrenderer const uint8_t *_colormap; uint8_t *_destorg; }; - - class RtInitColsPalCommand : public DrawerCommand - { - public: - RtInitColsPalCommand(uint8_t *buff); - void Execute(DrawerThread *thread) override; - FString DebugInfo() override { return "RtInitColsPalCommand"; } - - private: - uint8_t *buff; - }; - - class PalColumnHorizCommand : public DrawerCommand - { - public: - PalColumnHorizCommand(); - - protected: - const uint8_t *_source; - fixed_t _iscale; - fixed_t _texturefrac; - int _count; - int _color; - int _x; - int _yl; - }; - - class DrawColumnHorizPalCommand : public PalColumnHorizCommand - { - public: - void Execute(DrawerThread *thread) override; - FString DebugInfo() override { return "DrawColumnHorizPalCommand"; } - }; - - class FillColumnHorizPalCommand : public PalColumnHorizCommand - { - public: - void Execute(DrawerThread *thread) override; - FString DebugInfo() override { return "FillColumnHorizPalCommand"; } - }; - - class PalRtCommand : public DrawerCommand - { - public: - PalRtCommand(int hx, int sx, int yl, int yh); - FString DebugInfo() override { return "PalRtCommand"; } - - protected: - int hx, sx, yl, yh; - uint8_t *_destorg; - int _pitch; - const uint8_t *_colormap; - const uint32_t *_srcblend; - const uint32_t *_destblend; - const uint8_t *_translation; - fixed_t _srcalpha; - fixed_t _destalpha; - int _color; - }; - - class DrawColumnRt1CopyPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt4CopyPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt1PalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt4PalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt1TranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt4TranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt1AddPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt4AddPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - //class DrawColumnRt1AddTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - //class DrawColumnRt4AddTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt1ShadedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt4ShadedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt1AddClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt4AddClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - //class DrawColumnRt1AddClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - //class DrawColumnRt4AddClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt1SubClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt4SubClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - //class DrawColumnRt1SubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - //class DrawColumnRt4SubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt1RevSubClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - class DrawColumnRt4RevSubClampPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - //class DrawColumnRt1RevSubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; - //class DrawColumnRt4RevSubClampTranslatedPalCommand : public PalRtCommand { public: using PalRtCommand::PalRtCommand; void Execute(DrawerThread *thread) override; }; } diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index a9fc5c80e..4b5685608 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -1123,4 +1123,84 @@ namespace swrenderer } #endif + ///////////////////////////////////////////////////////////////////////////// + + namespace + { + static uint32_t particle_texture[16 * 16] = + { + 1 * 1, 2 * 1, 3 * 1, 4 * 1, 5 * 1, 6 * 1, 7 * 1, 8 * 1, 8 * 1, 7 * 1, 6 * 1, 5 * 1, 4 * 1, 3 * 1, 2 * 1, 1 * 1, + 1 * 2, 2 * 2, 3 * 2, 4 * 2, 5 * 2, 6 * 2, 7 * 2, 8 * 2, 8 * 2, 7 * 2, 6 * 2, 5 * 2, 4 * 2, 3 * 2, 2 * 2, 1 * 2, + 1 * 3, 2 * 3, 3 * 3, 4 * 3, 5 * 3, 6 * 3, 7 * 3, 8 * 3, 8 * 3, 7 * 3, 6 * 3, 5 * 3, 4 * 3, 3 * 3, 2 * 3, 1 * 3, + 1 * 4, 2 * 4, 3 * 4, 4 * 4, 5 * 4, 6 * 4, 7 * 4, 8 * 4, 8 * 4, 7 * 4, 6 * 4, 5 * 4, 4 * 4, 3 * 4, 2 * 4, 1 * 4, + 1 * 5, 2 * 5, 3 * 5, 4 * 5, 5 * 5, 6 * 5, 7 * 5, 8 * 5, 8 * 5, 7 * 5, 6 * 5, 5 * 5, 4 * 5, 3 * 5, 2 * 5, 1 * 5, + 1 * 6, 2 * 6, 3 * 6, 4 * 6, 5 * 6, 6 * 6, 7 * 6, 8 * 6, 8 * 6, 7 * 6, 6 * 6, 5 * 6, 4 * 6, 3 * 6, 2 * 6, 1 * 6, + 1 * 7, 2 * 7, 3 * 7, 4 * 7, 5 * 7, 6 * 7, 7 * 7, 8 * 7, 8 * 7, 7 * 7, 6 * 7, 5 * 7, 4 * 7, 3 * 7, 2 * 7, 1 * 7, + 1 * 8, 2 * 8, 3 * 8, 4 * 8, 5 * 8, 6 * 8, 7 * 8, 8 * 8, 8 * 8, 7 * 8, 6 * 8, 5 * 8, 4 * 8, 3 * 8, 2 * 8, 1 * 8, + 1 * 8, 2 * 8, 3 * 8, 4 * 8, 5 * 8, 6 * 8, 7 * 8, 8 * 8, 8 * 8, 7 * 8, 6 * 8, 5 * 8, 4 * 8, 3 * 8, 2 * 8, 1 * 8, + 1 * 7, 2 * 7, 3 * 7, 4 * 7, 5 * 7, 6 * 7, 7 * 7, 8 * 7, 8 * 7, 7 * 7, 6 * 7, 5 * 7, 4 * 7, 3 * 7, 2 * 7, 1 * 7, + 1 * 6, 2 * 6, 3 * 6, 4 * 6, 5 * 6, 6 * 6, 7 * 6, 8 * 6, 8 * 6, 7 * 6, 6 * 6, 5 * 6, 4 * 6, 3 * 6, 2 * 6, 1 * 6, + 1 * 5, 2 * 5, 3 * 5, 4 * 5, 5 * 5, 6 * 5, 7 * 5, 8 * 5, 8 * 5, 7 * 5, 6 * 5, 5 * 5, 4 * 5, 3 * 5, 2 * 5, 1 * 5, + 1 * 4, 2 * 4, 3 * 4, 4 * 4, 5 * 4, 6 * 4, 7 * 4, 8 * 4, 8 * 4, 7 * 4, 6 * 4, 5 * 4, 4 * 4, 3 * 4, 2 * 4, 1 * 4, + 1 * 3, 2 * 3, 3 * 3, 4 * 3, 5 * 3, 6 * 3, 7 * 3, 8 * 3, 8 * 3, 7 * 3, 6 * 3, 5 * 3, 4 * 3, 3 * 3, 2 * 3, 1 * 3, + 1 * 2, 2 * 2, 3 * 2, 4 * 2, 5 * 2, 6 * 2, 7 * 2, 8 * 2, 8 * 2, 7 * 2, 6 * 2, 5 * 2, 4 * 2, 3 * 2, 2 * 2, 1 * 2, + 1 * 1, 2 * 1, 3 * 1, 4 * 1, 5 * 1, 6 * 1, 7 * 1, 8 * 1, 8 * 1, 7 * 1, 6 * 1, 5 * 1, 4 * 1, 3 * 1, 2 * 1, 1 * 1 + }; + } + + DrawParticleColumnRGBACommand::DrawParticleColumnRGBACommand(uint32_t *dest, int dest_y, int pitch, int count, uint32_t fg, uint32_t alpha, uint32_t fracposx) + { + _dest = dest; + _pitch = pitch; + _count = count; + _fg = fg; + _alpha = alpha; + _fracposx = fracposx; + _dest_y = dest_y; + } + + void DrawParticleColumnRGBACommand::Execute(DrawerThread *thread) + { + int count = thread->count_for_thread(_dest_y, _count); + if (count <= 0) + return; + + uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, _dest); + int pitch = _pitch * thread->num_cores; + + const uint32_t *source = &particle_texture[(_fracposx >> FRACBITS) * 16]; + uint32_t particle_alpha = _alpha; + + uint32_t fracstep = 16 * FRACUNIT / _count; + uint32_t fracpos = fracstep * thread->skipped_by_thread(_dest_y) + fracstep / 2; + fracstep *= thread->num_cores; + + uint32_t fg_red = (_fg >> 16) & 0xff; + uint32_t fg_green = (_fg >> 8) & 0xff; + uint32_t fg_blue = _fg & 0xff; + + for (int y = 0; y < count; y++) + { + uint32_t alpha = (source[fracpos >> FRACBITS] * particle_alpha) >> 6; + uint32_t inv_alpha = 256 - alpha; + + uint32_t bg_red = (*dest >> 16) & 0xff; + uint32_t bg_green = (*dest >> 8) & 0xff; + uint32_t bg_blue = (*dest) & 0xff; + + uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 256; + uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 256; + uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 256; + + *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + dest += pitch; + fracpos += fracstep; + } + } + + FString DrawParticleColumnRGBACommand::DebugInfo() + { + return "DrawParticle"; + } + } diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index d5b269106..1364d537b 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -361,85 +361,6 @@ namespace swrenderer } }; - class DrawColumnRt1LLVMCommand : public DrawerCommand - { - protected: - DrawColumnArgs args; - WorkerThreadData ThreadData(DrawerThread *thread); - - public: - DrawColumnRt1LLVMCommand(int hx, int sx, int yl, int yh); - void Execute(DrawerThread *thread) override; - FString DebugInfo() override; - }; - - DECLARE_DRAW_COMMAND(DrawColumnRt1Copy, DrawColumnRt1Copy, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt1Add, DrawColumnRt1Add, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt1Shaded, DrawColumnRt1Shaded, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt1AddClamp, DrawColumnRt1AddClamp, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt1SubClamp, DrawColumnRt1SubClamp, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt1RevSubClamp, DrawColumnRt1RevSubClamp, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt1Translated, DrawColumnRt1Translated, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt1TlatedAdd, DrawColumnRt1TlatedAdd, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt1AddClampTranslated, DrawColumnRt1AddClampTranslated, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt1SubClampTranslated, DrawColumnRt1SubClampTranslated, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt1RevSubClampTranslated, DrawColumnRt1RevSubClampTranslated, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt4, DrawColumnRt4, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt4Copy, DrawColumnRt4Copy, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt4Add, DrawColumnRt4Add, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt4Shaded, DrawColumnRt4Shaded, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt4AddClamp, DrawColumnRt4AddClamp, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt4SubClamp, DrawColumnRt4SubClamp, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt4RevSubClamp, DrawColumnRt4RevSubClamp, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt4Translated, DrawColumnRt4Translated, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt4TlatedAdd, DrawColumnRt4TlatedAdd, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt4AddClampTranslated, DrawColumnRt4AddClampTranslated, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt4SubClampTranslated, DrawColumnRt4SubClampTranslated, DrawColumnRt1LLVMCommand); - DECLARE_DRAW_COMMAND(DrawColumnRt4RevSubClampTranslated, DrawColumnRt4RevSubClampTranslated, DrawColumnRt1LLVMCommand); - - ///////////////////////////////////////////////////////////////////////////// - - class RtInitColsRGBACommand : public DrawerCommand - { - BYTE * RESTRICT buff; - - public: - RtInitColsRGBACommand(BYTE *buff); - void Execute(DrawerThread *thread) override; - FString DebugInfo() override; - }; - - template - class DrawColumnHorizRGBACommand : public DrawerCommand - { - int _count; - fixed_t _iscale; - fixed_t _texturefrac; - const InputPixelType * RESTRICT _source; - int _x; - int _yl; - int _yh; - - public: - DrawColumnHorizRGBACommand(); - void Execute(DrawerThread *thread) override; - FString DebugInfo() override; - }; - - class FillColumnHorizRGBACommand : public DrawerCommand - { - int _x; - int _yl; - int _yh; - int _count; - uint32_t _color; - - public: - FillColumnHorizRGBACommand(); - void Execute(DrawerThread *thread) override; - FString DebugInfo() override; - }; - ///////////////////////////////////////////////////////////////////////////// class DrawParticleColumnRGBACommand : public DrawerCommand diff --git a/src/r_drawers.cpp b/src/r_drawers.cpp index dd81af109..e61e95183 100644 --- a/src/r_drawers.cpp +++ b/src/r_drawers.cpp @@ -175,30 +175,6 @@ Drawers::Drawers() FillColumnAddClamp = FillColumnAddClamp_SSE2; FillColumnSubClamp = FillColumnSubClamp_SSE2; FillColumnRevSubClamp = FillColumnRevSubClamp_SSE2; - DrawColumnRt1 = DrawColumnRt1_SSE2; - DrawColumnRt1Copy = DrawColumnRt1Copy_SSE2; - DrawColumnRt1Add = DrawColumnRt1Add_SSE2; - DrawColumnRt1Shaded = DrawColumnRt1Shaded_SSE2; - DrawColumnRt1AddClamp = DrawColumnRt1AddClamp_SSE2; - DrawColumnRt1SubClamp = DrawColumnRt1SubClamp_SSE2; - DrawColumnRt1RevSubClamp = DrawColumnRt1RevSubClamp_SSE2; - DrawColumnRt1Translated = DrawColumnRt1Translated_SSE2; - DrawColumnRt1TlatedAdd = DrawColumnRt1TlatedAdd_SSE2; - DrawColumnRt1AddClampTranslated = DrawColumnRt1AddClampTranslated_SSE2; - DrawColumnRt1SubClampTranslated = DrawColumnRt1SubClampTranslated_SSE2; - DrawColumnRt1RevSubClampTranslated = DrawColumnRt1RevSubClampTranslated_SSE2; - DrawColumnRt4 = DrawColumnRt4_SSE2; - DrawColumnRt4Copy = DrawColumnRt4Copy_SSE2; - DrawColumnRt4Add = DrawColumnRt4Add_SSE2; - DrawColumnRt4Shaded = DrawColumnRt4Shaded_SSE2; - DrawColumnRt4AddClamp = DrawColumnRt4AddClamp_SSE2; - DrawColumnRt4SubClamp = DrawColumnRt4SubClamp_SSE2; - DrawColumnRt4RevSubClamp = DrawColumnRt4RevSubClamp_SSE2; - DrawColumnRt4Translated = DrawColumnRt4Translated_SSE2; - DrawColumnRt4TlatedAdd = DrawColumnRt4TlatedAdd_SSE2; - DrawColumnRt4AddClampTranslated = DrawColumnRt4AddClampTranslated_SSE2; - DrawColumnRt4SubClampTranslated = DrawColumnRt4SubClampTranslated_SSE2; - DrawColumnRt4RevSubClampTranslated = DrawColumnRt4RevSubClampTranslated_SSE2; DrawSpan = DrawSpan_SSE2; DrawSpanMasked = DrawSpanMasked_SSE2; DrawSpanTranslucent = DrawSpanTranslucent_SSE2; diff --git a/src/r_drawers.h b/src/r_drawers.h index 2ff2fd087..7a94c82dd 100644 --- a/src/r_drawers.h +++ b/src/r_drawers.h @@ -308,30 +308,6 @@ public: void(*FillColumnAddClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*FillColumnSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*FillColumnRevSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt1)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt1Copy)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt1Add)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt1Shaded)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt1AddClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt1SubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt1RevSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt1Translated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt1TlatedAdd)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt1AddClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt1SubClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt1RevSubClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt4)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt4Copy)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt4Add)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt4Shaded)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt4AddClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt4SubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt4RevSubClamp)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt4Translated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt4TlatedAdd)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt4AddClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt4SubClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; - void(*DrawColumnRt4RevSubClampTranslated)(const DrawColumnArgs *, const WorkerThreadData *) = nullptr; void(*DrawSpan)(const DrawSpanArgs *) = nullptr; void(*DrawSpanMasked)(const DrawSpanArgs *) = nullptr; diff --git a/src/r_drawt_pal.cpp b/src/r_drawt_pal.cpp deleted file mode 100644 index dcc0a0938..000000000 --- a/src/r_drawt_pal.cpp +++ /dev/null @@ -1,1064 +0,0 @@ -/* -** r_drawt.cpp -** Faster column drawers for modern processors -** -**--------------------------------------------------------------------------- -** Copyright 1998-2006 Randy Heit -** Copyright 2016 Magnus Norddahl -** Copyright 2016 Rachael Alexanderson -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** These functions stretch columns into a temporary buffer and then -** map them to the screen. On modern machines, this is faster than drawing -** them directly to the screen. -** -** Will I be able to even understand any of this if I come back to it later? -** Let's hope so. :-) -*/ - -#include "templates.h" -#include "doomtype.h" -#include "doomdef.h" -#include "r_defs.h" -#include "r_draw.h" -#include "r_main.h" -#include "r_things.h" -#include "v_video.h" -#include "r_draw_pal.h" - -EXTERN_CVAR(Bool, r_blendmethod) - -// I should have commented this stuff better. -// -// dc_temp is the buffer R_DrawColumnHoriz writes into. -// dc_tspans points into it. -// dc_ctspan points into dc_tspans. -// horizspan also points into dc_tspans. - -// dc_ctspan is advanced while drawing into dc_temp. -// horizspan is advanced up to dc_ctspan when drawing from dc_temp to the screen. - -namespace swrenderer -{ - RtInitColsPalCommand::RtInitColsPalCommand(uint8_t *buff) : buff(buff) - { - } - - void RtInitColsPalCommand::Execute(DrawerThread *thread) - { - thread->dc_temp = buff == nullptr ? thread->dc_temp_buff : buff; - } - - ///////////////////////////////////////////////////////////////////// - - PalColumnHorizCommand::PalColumnHorizCommand() - { - using namespace drawerargs; - - _source = dc_source; - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _count = dc_count; - _color = dc_color; - _x = dc_x; - _yl = dc_yl; - } - - void DrawColumnHorizPalCommand::Execute(DrawerThread *thread) - { - int count = _count; - uint8_t *dest; - fixed_t fracstep; - fixed_t frac; - - count = thread->count_for_thread(_yl, count); - if (count <= 0) - return; - - fracstep = _iscale; - frac = _texturefrac; - - const uint8_t *source = _source; - - int x = _x & 3; - dest = &thread->dc_temp[x + thread->temp_line_for_thread(_yl) * 4]; - frac += fracstep * thread->skipped_by_thread(_yl); - fracstep *= thread->num_cores; - - if (count & 1) { - *dest = source[frac >> FRACBITS]; dest += 4; frac += fracstep; - } - if (count & 2) { - dest[0] = source[frac >> FRACBITS]; frac += fracstep; - dest[4] = source[frac >> FRACBITS]; frac += fracstep; - dest += 8; - } - if (count & 4) { - dest[0] = source[frac >> FRACBITS]; frac += fracstep; - dest[4] = source[frac >> FRACBITS]; frac += fracstep; - dest[8] = source[frac >> FRACBITS]; frac += fracstep; - dest[12] = source[frac >> FRACBITS]; frac += fracstep; - dest += 16; - } - count >>= 3; - if (!count) return; - - do - { - dest[0] = source[frac >> FRACBITS]; frac += fracstep; - dest[4] = source[frac >> FRACBITS]; frac += fracstep; - dest[8] = source[frac >> FRACBITS]; frac += fracstep; - dest[12] = source[frac >> FRACBITS]; frac += fracstep; - dest[16] = source[frac >> FRACBITS]; frac += fracstep; - dest[20] = source[frac >> FRACBITS]; frac += fracstep; - dest[24] = source[frac >> FRACBITS]; frac += fracstep; - dest[28] = source[frac >> FRACBITS]; frac += fracstep; - dest += 32; - } while (--count); - } - - void FillColumnHorizPalCommand::Execute(DrawerThread *thread) - { - int count = _count; - uint8_t color = _color; - uint8_t *dest; - - count = thread->count_for_thread(_yl, count); - if (count <= 0) - return; - - int x = _x & 3; - dest = &thread->dc_temp[x + thread->temp_line_for_thread(_yl) * 4]; - - if (count & 1) { - *dest = color; - dest += 4; - } - if (!(count >>= 1)) - return; - do { - dest[0] = color; dest[4] = color; - dest += 8; - } while (--count); - } - - ///////////////////////////////////////////////////////////////////// - - PalRtCommand::PalRtCommand(int hx, int sx, int yl, int yh) : hx(hx), sx(sx), yl(yl), yh(yh) - { - using namespace drawerargs; - - _destorg = dc_destorg; - _pitch = dc_pitch; - _colormap = dc_colormap; - _srcblend = dc_srcblend; - _destblend = dc_destblend; - _srcalpha = dc_srcalpha; - _destalpha = dc_destalpha; - _translation = dc_translation; - _color = dc_color; - } - - void DrawColumnRt1CopyPalCommand::Execute(DrawerThread *thread) - { - uint8_t *source; - uint8_t *dest; - int count; - int pitch; - - count = yh - yl + 1; - - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; - source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; - pitch = _pitch * thread->num_cores; - - if (count & 1) { - *dest = *source; - source += 4; - dest += pitch; - } - if (count & 2) { - dest[0] = source[0]; - dest[pitch] = source[4]; - source += 8; - dest += pitch*2; - } - if (!(count >>= 2)) - return; - - do { - dest[0] = source[0]; - dest[pitch] = source[4]; - dest[pitch*2] = source[8]; - dest[pitch*3] = source[12]; - source += 16; - dest += pitch*4; - } while (--count); - } - - void DrawColumnRt4CopyPalCommand::Execute(DrawerThread *thread) - { - int *source; - int *dest; - int count; - int pitch; - - count = yh - yl + 1; - - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - dest = (int *)(ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg); - source = (int *)(&thread->dc_temp[thread->temp_line_for_thread(yl)*4]); - pitch = _pitch*thread->num_cores/sizeof(int); - - if (count & 1) { - *dest = *source; - source += 4/sizeof(int); - dest += pitch; - } - if (!(count >>= 1)) - return; - - do { - dest[0] = source[0]; - dest[pitch] = source[4/sizeof(int)]; - source += 8/sizeof(int); - dest += pitch*2; - } while (--count); - } - - void DrawColumnRt1PalCommand::Execute(DrawerThread *thread) - { - const uint8_t *colormap; - uint8_t *source; - uint8_t *dest; - int count; - int pitch; - - count = yh - yl + 1; - - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - colormap = _colormap; - dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; - source = &thread->dc_temp[thread->temp_line_for_thread(yl) *4 + hx]; - pitch = _pitch*thread->num_cores; - - if (count & 1) { - *dest = colormap[*source]; - source += 4; - dest += pitch; - } - if (!(count >>= 1)) - return; - - do { - dest[0] = colormap[source[0]]; - dest[pitch] = colormap[source[4]]; - source += 8; - dest += pitch*2; - } while (--count); - } - - void DrawColumnRt4PalCommand::Execute(DrawerThread *thread) - { - const uint8_t *colormap; - uint8_t *source; - uint8_t *dest; - int count; - int pitch; - - count = yh - yl + 1; - - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - colormap = _colormap; - dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; - source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; - pitch = _pitch*thread->num_cores; - - if (count & 1) { - dest[0] = colormap[source[0]]; - dest[1] = colormap[source[1]]; - dest[2] = colormap[source[2]]; - dest[3] = colormap[source[3]]; - source += 4; - dest += pitch; - } - if (!(count >>= 1)) - return; - - do { - dest[0] = colormap[source[0]]; - dest[1] = colormap[source[1]]; - dest[2] = colormap[source[2]]; - dest[3] = colormap[source[3]]; - dest[pitch] = colormap[source[4]]; - dest[pitch+1] = colormap[source[5]]; - dest[pitch+2] = colormap[source[6]]; - dest[pitch+3] = colormap[source[7]]; - source += 8; - dest += pitch*2; - } while (--count); - } - - void DrawColumnRt1TranslatedPalCommand::Execute(DrawerThread *thread) - { - int count = yh - yl + 1; - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - uint8_t *source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; - const uint8_t *translation = _translation; - - // Things we do to hit the compiler's optimizer with a clue bat: - // 1. Parallelism is explicitly spelled out by using a separate - // C instruction for each assembly instruction. GCC lets me - // have four temporaries, but VC++ spills to the stack with - // more than two. Two is probably optimal, anyway. - // 2. The results of the translation lookups are explicitly - // stored in byte-sized variables. This causes the VC++ code - // to use byte mov instructions in most cases; for apparently - // random reasons, it will use movzx for some places. GCC - // ignores this and uses movzx always. - - // Do 8 rows at a time. - for (int count8 = count >> 3; count8; --count8) - { - int c0, c1; - uint8_t b0, b1; - - c0 = source[0]; c1 = source[4]; - b0 = translation[c0]; b1 = translation[c1]; - source[0] = b0; source[4] = b1; - - c0 = source[8]; c1 = source[12]; - b0 = translation[c0]; b1 = translation[c1]; - source[8] = b0; source[12] = b1; - - c0 = source[16]; c1 = source[20]; - b0 = translation[c0]; b1 = translation[c1]; - source[16] = b0; source[20] = b1; - - c0 = source[24]; c1 = source[28]; - b0 = translation[c0]; b1 = translation[c1]; - source[24] = b0; source[28] = b1; - - source += 32; - } - // Finish by doing 1 row at a time. - for (count &= 7; count; --count, source += 4) - { - source[0] = translation[source[0]]; - } - } - - void DrawColumnRt4TranslatedPalCommand::Execute(DrawerThread *thread) - { - int count = yh - yl + 1; - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - uint8_t *source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; - const uint8_t *translation = _translation; - int c0, c1; - uint8_t b0, b1; - - // Do 2 rows at a time. - for (int count8 = count >> 1; count8; --count8) - { - c0 = source[0]; c1 = source[1]; - b0 = translation[c0]; b1 = translation[c1]; - source[0] = b0; source[1] = b1; - - c0 = source[2]; c1 = source[3]; - b0 = translation[c0]; b1 = translation[c1]; - source[2] = b0; source[3] = b1; - - c0 = source[4]; c1 = source[5]; - b0 = translation[c0]; b1 = translation[c1]; - source[4] = b0; source[5] = b1; - - c0 = source[6]; c1 = source[7]; - b0 = translation[c0]; b1 = translation[c1]; - source[6] = b0; source[7] = b1; - - source += 8; - } - // Do the final row if count was odd. - if (count & 1) - { - c0 = source[0]; c1 = source[1]; - b0 = translation[c0]; b1 = translation[c1]; - source[0] = b0; source[1] = b1; - - c0 = source[2]; c1 = source[3]; - b0 = translation[c0]; b1 = translation[c1]; - source[2] = b0; source[3] = b1; - } - } - - void DrawColumnRt1AddPalCommand::Execute(DrawerThread *thread) - { - const uint8_t *colormap; - uint8_t *source; - uint8_t *dest; - int pitch; - - int count = yh - yl + 1; - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; - dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; - source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; - pitch = _pitch * thread->num_cores; - colormap = _colormap; - const PalEntry *palette = GPalette.BaseColors; - - if (!r_blendmethod) - { - do { - uint32_t fg = colormap[*source]; - uint32_t bg = *dest; - - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg>>15)]; - source += 4; - dest += pitch; - } while (--count); - } - else - { - do { - uint32_t fg = colormap[*source]; - uint32_t bg = *dest; - - int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); - int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); - int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); - *dest = RGB256k.RGB[r][g][b]; - source += 4; - dest += pitch; - } while (--count); - } - } - - void DrawColumnRt4AddPalCommand::Execute(DrawerThread *thread) - { - const uint8_t *colormap; - uint8_t *source; - uint8_t *dest; - int pitch; - - int count = yh - yl + 1; - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; - dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; - source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; - pitch = _pitch * thread->num_cores; - colormap = _colormap; - const PalEntry *palette = GPalette.BaseColors; - - if (!r_blendmethod) - { - do { - uint32_t fg = colormap[source[0]]; - uint32_t bg = dest[0]; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - dest[0] = RGB32k.All[fg & (fg>>15)]; - - fg = colormap[source[1]]; - bg = dest[1]; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - dest[1] = RGB32k.All[fg & (fg>>15)]; - - - fg = colormap[source[2]]; - bg = dest[2]; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - dest[2] = RGB32k.All[fg & (fg>>15)]; - - fg = colormap[source[3]]; - bg = dest[3]; - fg = fg2rgb[fg]; - bg = bg2rgb[bg]; - fg = (fg+bg) | 0x1f07c1f; - dest[3] = RGB32k.All[fg & (fg>>15)]; - - source += 4; - dest += pitch; - } while (--count); - } - else - { - do { - for (int ks = 0; ks < 4; ks++) - { // [SP] this 4col function was a block of copy-pasted code. 4 times. I regret nothing. - uint32_t fg = colormap[source[ks]]; - uint32_t bg = dest[ks]; - int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); - int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); - int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); - dest[ks] = RGB256k.RGB[r][g][b]; - } - - source += 4; - dest += pitch; - } while (--count); - } - } - - void DrawColumnRt1ShadedPalCommand::Execute(DrawerThread *thread) - { - uint32_t *fgstart; - const uint8_t *colormap; - uint8_t *source; - uint8_t *dest; - int pitch; - - int count = yh - yl + 1; - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - fgstart = &Col2RGB8[0][_color]; - colormap = _colormap; - dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; - source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; - pitch = _pitch * thread->num_cores; - const PalEntry *palette = GPalette.BaseColors; - - if (!r_blendmethod) - { - do { - uint32_t val = colormap[*source]; - uint32_t fg = fgstart[val<<8]; - val = (Col2RGB8[64-val][*dest] + fg) | 0x1f07c1f; - *dest = RGB32k.All[val & (val>>15)]; - source += 4; - dest += pitch; - } while (--count); - } - else - { - do { - uint32_t val = *source; - int r = (palette[*dest].r * (255-val) + palette[_color].r * val) >> 10; - int g = (palette[*dest].g * (255-val) + palette[_color].g * val) >> 10; - int b = (palette[*dest].b * (255-val) + palette[_color].b * val) >> 10; - *dest = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; - source += 4; - dest += pitch; - } while (--count); - } - } - - void DrawColumnRt4ShadedPalCommand::Execute(DrawerThread *thread) - { - uint32_t *fgstart; - const uint8_t *colormap; - uint8_t *source; - uint8_t *dest; - int pitch; - - int count = yh - yl + 1; - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - fgstart = &Col2RGB8[0][_color]; - colormap = _colormap; - dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; - source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; - pitch = _pitch * thread->num_cores; - const PalEntry *palette = GPalette.BaseColors; - - if (!r_blendmethod) - { - do { - uint32_t val; - - val = colormap[source[0]]; - val = (Col2RGB8[64-val][dest[0]] + fgstart[val<<8]) | 0x1f07c1f; - dest[0] = RGB32k.All[val & (val>>15)]; - - val = colormap[source[1]]; - val = (Col2RGB8[64-val][dest[1]] + fgstart[val<<8]) | 0x1f07c1f; - dest[1] = RGB32k.All[val & (val>>15)]; - - val = colormap[source[2]]; - val = (Col2RGB8[64-val][dest[2]] + fgstart[val<<8]) | 0x1f07c1f; - dest[2] = RGB32k.All[val & (val>>15)]; - - val = colormap[source[3]]; - val = (Col2RGB8[64-val][dest[3]] + fgstart[val<<8]) | 0x1f07c1f; - dest[3] = RGB32k.All[val & (val>>15)]; - - source += 4; - dest += pitch; - } while (--count); - } - else - { - do { - uint32_t val; - - for (int ks = 0; ks < 4; ks++) - { - val = source[ks]; - int r = (palette[dest[ks]].r * (255-val) + palette[_color].r * val) >> 10; - int g = (palette[dest[ks]].g * (255-val) + palette[_color].g * val) >> 10; - int b = (palette[dest[ks]].b * (255-val) + palette[_color].b * val) >> 10; - dest[ks] = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)]; - } - - source += 4; - dest += pitch; - } while (--count); - } - } - - void DrawColumnRt1AddClampPalCommand::Execute(DrawerThread *thread) - { - const uint8_t *colormap; - uint8_t *source; - uint8_t *dest; - int pitch; - - int count = yh - yl + 1; - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; - dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; - source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; - pitch = _pitch * thread->num_cores; - colormap = _colormap; - const PalEntry *palette = GPalette.BaseColors; - - if (!r_blendmethod) - { - do { - uint32_t a = fg2rgb[colormap[*source]] + bg2rgb[*dest]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - *dest = RGB32k.All[(a>>15) & a]; - source += 4; - dest += pitch; - } while (--count); - } - else - { - do { - int fg = colormap[*source]; - int bg = *dest; - int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); - int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); - int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); - *dest = RGB256k.RGB[r][g][b]; - source += 4; - dest += pitch; - } while (--count); - } - } - - void DrawColumnRt4AddClampPalCommand::Execute(DrawerThread *thread) - { - const uint8_t *colormap; - uint8_t *source; - uint8_t *dest; - int pitch; - - int count = yh - yl + 1; - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; - source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; - pitch = _pitch * thread->num_cores; - colormap = _colormap; - const PalEntry *palette = GPalette.BaseColors; - - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; - - if (!r_blendmethod) - { - do { - uint32_t a = fg2rgb[colormap[source[0]]] + bg2rgb[dest[0]]; - uint32_t b = a; - - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[0] = RGB32k.All[(a>>15) & a]; - - a = fg2rgb[colormap[source[1]]] + bg2rgb[dest[1]]; - b = a; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[1] = RGB32k.All[(a>>15) & a]; - - a = fg2rgb[colormap[source[2]]] + bg2rgb[dest[2]]; - b = a; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[2] = RGB32k.All[(a>>15) & a]; - - a = fg2rgb[colormap[source[3]]] + bg2rgb[dest[3]]; - b = a; - a |= 0x01f07c1f; - b &= 0x40100400; - a &= 0x3fffffff; - b = b - (b >> 5); - a |= b; - dest[3] = RGB32k.All[(a>>15) & a]; - - source += 4; - dest += pitch; - } while (--count); - } - else - { - do { - for (int ks = 0; ks < 4; ks++) - { - int fg = colormap[source[ks]]; - int bg = dest[ks]; - int r = MIN((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 63); - int g = MIN((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 63); - int b = MIN((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 63); - dest[ks] = RGB256k.RGB[r][g][b]; - } - - source += 4; - dest += pitch; - } while (--count); - } - } - - void DrawColumnRt1SubClampPalCommand::Execute(DrawerThread *thread) - { - const uint8_t *colormap; - uint8_t *source; - uint8_t *dest; - int pitch; - - int count = yh - yl + 1; - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; - dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; - source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; - pitch = _pitch * thread->num_cores; - colormap = _colormap; - const PalEntry *palette = GPalette.BaseColors; - - if (!r_blendmethod) - { - do { - uint32_t a = (fg2rgb[colormap[*source]] | 0x40100400) - bg2rgb[*dest]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[(a>>15) & a]; - source += 4; - dest += pitch; - } while (--count); - } - else - { - do { - int fg = colormap[*source]; - int bg = *dest; - int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); - *dest = RGB256k.RGB[r][g][b]; - source += 4; - dest += pitch; - } while (--count); - } - } - - void DrawColumnRt4SubClampPalCommand::Execute(DrawerThread *thread) - { - const uint8_t *colormap; - uint8_t *source; - uint8_t *dest; - int pitch; - - int count = yh - yl + 1; - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; - dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; - source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; - pitch = _pitch * thread->num_cores; - colormap = _colormap; - const PalEntry *palette = GPalette.BaseColors; - - if (!r_blendmethod) - { - do { - uint32_t a = (fg2rgb[colormap[source[0]]] | 0x40100400) - bg2rgb[dest[0]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[0] = RGB32k.All[(a>>15) & a]; - - a = (fg2rgb[colormap[source[1]]] | 0x40100400) - bg2rgb[dest[1]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[1] = RGB32k.All[(a>>15) & a]; - - a = (fg2rgb[colormap[source[2]]] | 0x40100400) - bg2rgb[dest[2]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[2] = RGB32k.All[(a>>15) & a]; - - a = (fg2rgb[colormap[source[3]]] | 0x40100400) - bg2rgb[dest[3]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[3] = RGB32k.All[(a>>15) & a]; - - source += 4; - dest += pitch; - } while (--count); - } - else - { - do { - for (int ks = 0; ks < 4; ks++) - { - int fg = colormap[source[ks]]; - int bg = dest[ks]; - int r = MAX((palette[fg].r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); - dest[ks] = RGB256k.RGB[r][g][b]; - } - - source += 4; - dest += pitch; - } while (--count); - } - } - - void DrawColumnRt1RevSubClampPalCommand::Execute(DrawerThread *thread) - { - const uint8_t *colormap; - uint8_t *source; - uint8_t *dest; - int pitch; - - int count = yh - yl + 1; - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; - dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; - source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; - pitch = _pitch * thread->num_cores; - colormap = _colormap; - const PalEntry *palette = GPalette.BaseColors; - - if (!r_blendmethod) - { - do { - uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[*source]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - *dest = RGB32k.All[(a>>15) & a]; - source += 4; - dest += pitch; - } while (--count); - } - else - { - do { - int fg = colormap[*source]; - int bg = *dest; - int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); - *dest = RGB256k.RGB[r][g][b]; - source += 4; - dest += pitch; - } while (--count); - } - } - - void DrawColumnRt4RevSubClampPalCommand::Execute(DrawerThread *thread) - { - const uint8_t *colormap; - uint8_t *source; - uint8_t *dest; - int pitch; - - int count = yh - yl + 1; - count = thread->count_for_thread(yl, count); - if (count <= 0) - return; - - const uint32_t *fg2rgb = _srcblend; - const uint32_t *bg2rgb = _destblend; - dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; - source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; - pitch = _pitch * thread->num_cores; - colormap = _colormap; - const PalEntry *palette = GPalette.BaseColors; - - if (!r_blendmethod) - { - do { - uint32_t a = (bg2rgb[dest[0]] | 0x40100400) - fg2rgb[colormap[source[0]]]; - uint32_t b = a; - - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[0] = RGB32k.All[(a>>15) & a]; - - a = (bg2rgb[dest[1]] | 0x40100400) - fg2rgb[colormap[source[1]]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[1] = RGB32k.All[(a>>15) & a]; - - a = (bg2rgb[dest[2]] | 0x40100400) - fg2rgb[colormap[source[2]]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[2] = RGB32k.All[(a>>15) & a]; - - a = (bg2rgb[dest[3]] | 0x40100400) - fg2rgb[colormap[source[3]]]; - b = a; - b &= 0x40100400; - b = b - (b >> 5); - a &= b; - a |= 0x01f07c1f; - dest[3] = RGB32k.All[(a>>15) & a]; - - source += 4; - dest += pitch; - } while (--count); - } - else - { - do { - for (int ks = 0; ks < 4; ks++) - { - int fg = colormap[source[ks]]; - int bg = dest[ks]; - int r = MAX((-palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((-palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((-palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); - dest[ks] = RGB256k.RGB[r][g][b]; - } - - source += 4; - dest += pitch; - } while (--count); - } - } -} diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp deleted file mode 100644 index b5be7a9c3..000000000 --- a/src/r_drawt_rgba.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/* -** Drawer commands for the RT family of drawers -** Copyright (c) 2016 Magnus Norddahl -** -** This software is provided 'as-is', without any express or implied -** warranty. In no event will the authors be held liable for any damages -** arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, -** including commercial applications, and to alter it and redistribute it -** freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not -** claim that you wrote the original software. If you use this software -** in a product, an acknowledgment in the product documentation would be -** appreciated but is not required. -** 2. Altered source versions must be plainly marked as such, and must not be -** misrepresented as being the original software. -** 3. This notice may not be removed or altered from any source distribution. -** -*/ - -#include "templates.h" -#include "doomtype.h" -#include "doomdef.h" -#include "r_defs.h" -#include "r_draw.h" -#include "r_main.h" -#include "r_things.h" -#include "v_video.h" -#include "r_draw_rgba.h" -#include "r_drawers.h" - -namespace swrenderer -{ - WorkerThreadData DrawColumnRt1LLVMCommand::ThreadData(DrawerThread *thread) - { - WorkerThreadData d; - d.core = thread->core; - d.num_cores = thread->num_cores; - d.pass_start_y = thread->pass_start_y; - d.pass_end_y = thread->pass_end_y; - d.temp = thread->dc_temp_rgba; - return d; - } - - DrawColumnRt1LLVMCommand::DrawColumnRt1LLVMCommand(int hx, int sx, int yl, int yh) - { - using namespace drawerargs; - - args.dest = (uint32_t*)dc_destorg + ylookup[yl] + sx; - args.source = nullptr; - args.source2 = nullptr; - args.colormap = dc_colormap; - args.translation = dc_translation; - args.basecolors = (const uint32_t *)GPalette.BaseColors; - args.pitch = dc_pitch; - args.count = yh - yl + 1; - args.dest_y = yl; - args.iscale = dc_iscale; - args.texturefrac = hx; - args.light = LightBgra::calc_light_multiplier(dc_light); - args.color = LightBgra::shade_pal_index_simple(dc_color, args.light); - args.srccolor = dc_srccolor_bgra; - args.srcalpha = dc_srcalpha >> (FRACBITS - 8); - args.destalpha = dc_destalpha >> (FRACBITS - 8); - args.light_red = dc_shade_constants.light_red; - args.light_green = dc_shade_constants.light_green; - args.light_blue = dc_shade_constants.light_blue; - args.light_alpha = dc_shade_constants.light_alpha; - args.fade_red = dc_shade_constants.fade_red; - args.fade_green = dc_shade_constants.fade_green; - args.fade_blue = dc_shade_constants.fade_blue; - args.fade_alpha = dc_shade_constants.fade_alpha; - args.desaturate = dc_shade_constants.desaturate; - args.flags = 0; - if (dc_shade_constants.simple_shade) - args.flags |= DrawColumnArgs::simple_shade; - if (args.source2 == nullptr) - args.flags |= DrawColumnArgs::nearest_filter; - - DetectRangeError(args.dest, args.dest_y, args.count); - } - - void DrawColumnRt1LLVMCommand::Execute(DrawerThread *thread) - { - WorkerThreadData d = ThreadData(thread); - Drawers::Instance()->DrawColumnRt1(&args, &d); - } - - FString DrawColumnRt1LLVMCommand::DebugInfo() - { - return "DrawColumnRt\n" + args.ToString(); - } - - ///////////////////////////////////////////////////////////////////////////// - - RtInitColsRGBACommand::RtInitColsRGBACommand(BYTE *buff) - { - this->buff = buff; - } - - void RtInitColsRGBACommand::Execute(DrawerThread *thread) - { - thread->dc_temp_rgba = buff == NULL ? thread->dc_temp_rgbabuff_rgba : (uint32_t*)buff; - } - - FString RtInitColsRGBACommand::DebugInfo() - { - return "RtInitCols"; - } - - ///////////////////////////////////////////////////////////////////////////// - - template - DrawColumnHorizRGBACommand::DrawColumnHorizRGBACommand() - { - using namespace drawerargs; - - _count = dc_count; - _iscale = dc_iscale; - _texturefrac = dc_texturefrac; - _source = (const InputPixelType *)dc_source; - _x = dc_x; - _yl = dc_yl; - _yh = dc_yh; - } - - template - void DrawColumnHorizRGBACommand::Execute(DrawerThread *thread) - { - int count = _count; - uint32_t *dest; - fixed_t fracstep; - fixed_t frac; - - if (count <= 0) - return; - - { - int x = _x & 3; - dest = &thread->dc_temp_rgba[x + 4 * _yl]; - } - fracstep = _iscale; - frac = _texturefrac; - - const InputPixelType *source = _source; - - if (count & 1) { - *dest = source[frac >> FRACBITS]; dest += 4; frac += fracstep; - } - if (count & 2) { - dest[0] = source[frac >> FRACBITS]; frac += fracstep; - dest[4] = source[frac >> FRACBITS]; frac += fracstep; - dest += 8; - } - if (count & 4) { - dest[0] = source[frac >> FRACBITS]; frac += fracstep; - dest[4] = source[frac >> FRACBITS]; frac += fracstep; - dest[8] = source[frac >> FRACBITS]; frac += fracstep; - dest[12] = source[frac >> FRACBITS]; frac += fracstep; - dest += 16; - } - count >>= 3; - if (!count) return; - - do - { - dest[0] = source[frac >> FRACBITS]; frac += fracstep; - dest[4] = source[frac >> FRACBITS]; frac += fracstep; - dest[8] = source[frac >> FRACBITS]; frac += fracstep; - dest[12] = source[frac >> FRACBITS]; frac += fracstep; - dest[16] = source[frac >> FRACBITS]; frac += fracstep; - dest[20] = source[frac >> FRACBITS]; frac += fracstep; - dest[24] = source[frac >> FRACBITS]; frac += fracstep; - dest[28] = source[frac >> FRACBITS]; frac += fracstep; - dest += 32; - } while (--count); - } - - template - FString DrawColumnHorizRGBACommand::DebugInfo() - { - return "DrawColumnHoriz"; - } - - // Generate code for the versions we use: - template class DrawColumnHorizRGBACommand; - template class DrawColumnHorizRGBACommand; - - ///////////////////////////////////////////////////////////////////////////// - - FillColumnHorizRGBACommand::FillColumnHorizRGBACommand() - { - using namespace drawerargs; - - _x = dc_x; - _count = dc_count; - _color = GPalette.BaseColors[dc_color].d | (uint32_t)0xff000000; - _yl = dc_yl; - _yh = dc_yh; - } - - void FillColumnHorizRGBACommand::Execute(DrawerThread *thread) - { - int count = _count; - uint32_t color = _color; - uint32_t *dest; - - if (count <= 0) - return; - - { - int x = _x & 3; - dest = &thread->dc_temp_rgba[x + 4 * _yl]; - } - - if (count & 1) { - *dest = color; - dest += 4; - } - if (!(count >>= 1)) - return; - do { - dest[0] = color; dest[4] = color; - dest += 8; - } while (--count); - } - - FString FillColumnHorizRGBACommand::DebugInfo() - { - return "FillColumnHoriz"; - } - - ///////////////////////////////////////////////////////////////////////////// - - namespace - { - static uint32_t particle_texture[16 * 16] = - { - 1*1, 2*1, 3*1, 4*1, 5*1, 6*1, 7*1, 8*1, 8*1, 7*1, 6*1, 5*1, 4*1, 3*1, 2*1, 1*1, - 1*2, 2*2, 3*2, 4*2, 5*2, 6*2, 7*2, 8*2, 8*2, 7*2, 6*2, 5*2, 4*2, 3*2, 2*2, 1*2, - 1*3, 2*3, 3*3, 4*3, 5*3, 6*3, 7*3, 8*3, 8*3, 7*3, 6*3, 5*3, 4*3, 3*3, 2*3, 1*3, - 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4, 8*4, 8*4, 7*4, 6*4, 5*4, 4*4, 3*4, 2*4, 1*4, - 1*5, 2*5, 3*5, 4*5, 5*5, 6*5, 7*5, 8*5, 8*5, 7*5, 6*5, 5*5, 4*5, 3*5, 2*5, 1*5, - 1*6, 2*6, 3*6, 4*6, 5*6, 6*6, 7*6, 8*6, 8*6, 7*6, 6*6, 5*6, 4*6, 3*6, 2*6, 1*6, - 1*7, 2*7, 3*7, 4*7, 5*7, 6*7, 7*7, 8*7, 8*7, 7*7, 6*7, 5*7, 4*7, 3*7, 2*7, 1*7, - 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 8*8, 7*8, 6*8, 5*8, 4*8, 3*8, 2*8, 1*8, - 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 8*8, 7*8, 6*8, 5*8, 4*8, 3*8, 2*8, 1*8, - 1*7, 2*7, 3*7, 4*7, 5*7, 6*7, 7*7, 8*7, 8*7, 7*7, 6*7, 5*7, 4*7, 3*7, 2*7, 1*7, - 1*6, 2*6, 3*6, 4*6, 5*6, 6*6, 7*6, 8*6, 8*6, 7*6, 6*6, 5*6, 4*6, 3*6, 2*6, 1*6, - 1*5, 2*5, 3*5, 4*5, 5*5, 6*5, 7*5, 8*5, 8*5, 7*5, 6*5, 5*5, 4*5, 3*5, 2*5, 1*5, - 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4, 8*4, 8*4, 7*4, 6*4, 5*4, 4*4, 3*4, 2*4, 1*4, - 1*3, 2*3, 3*3, 4*3, 5*3, 6*3, 7*3, 8*3, 8*3, 7*3, 6*3, 5*3, 4*3, 3*3, 2*3, 1*3, - 1*2, 2*2, 3*2, 4*2, 5*2, 6*2, 7*2, 8*2, 8*2, 7*2, 6*2, 5*2, 4*2, 3*2, 2*2, 1*2, - 1*1, 2*1, 3*1, 4*1, 5*1, 6*1, 7*1, 8*1, 8*1, 7*1, 6*1, 5*1, 4*1, 3*1, 2*1, 1*1 - }; - } - - DrawParticleColumnRGBACommand::DrawParticleColumnRGBACommand(uint32_t *dest, int dest_y, int pitch, int count, uint32_t fg, uint32_t alpha, uint32_t fracposx) - { - _dest = dest; - _pitch = pitch; - _count = count; - _fg = fg; - _alpha = alpha; - _fracposx = fracposx; - _dest_y = dest_y; - } - - void DrawParticleColumnRGBACommand::Execute(DrawerThread *thread) - { - int count = thread->count_for_thread(_dest_y, _count); - if (count <= 0) - return; - - uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, _dest); - int pitch = _pitch * thread->num_cores; - - const uint32_t *source = &particle_texture[(_fracposx >> FRACBITS) * 16]; - uint32_t particle_alpha = _alpha; - - uint32_t fracstep = 16 * FRACUNIT / _count; - uint32_t fracpos = fracstep * thread->skipped_by_thread(_dest_y) + fracstep / 2; - fracstep *= thread->num_cores; - - uint32_t fg_red = (_fg >> 16) & 0xff; - uint32_t fg_green = (_fg >> 8) & 0xff; - uint32_t fg_blue = _fg & 0xff; - - for (int y = 0; y < count; y++) - { - uint32_t alpha = (source[fracpos >> FRACBITS] * particle_alpha) >> 6; - uint32_t inv_alpha = 256 - alpha; - - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 256; - uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 256; - uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 256; - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; - dest += pitch; - fracpos += fracstep; - } - } - - FString DrawParticleColumnRGBACommand::DebugInfo() - { - return "DrawParticle"; - } -} diff --git a/src/r_main.cpp b/src/r_main.cpp index c67b48a1b..a83b2f190 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -169,11 +169,6 @@ void (*fuzzcolfunc) (void); void (*transcolfunc) (void); void (*spanfunc) (void); -void (*hcolfunc_pre) (void); -void (*hcolfunc_post1) (int hx, int sx, int yl, int yh); -void (*hcolfunc_post2) (int hx, int sx, int yl, int yh); -void (*hcolfunc_post4) (int sx, int yl, int yh); - cycle_t WallCycles, PlaneCycles, MaskedCycles, WallScanCycles; // PRIVATE DATA DEFINITIONS ------------------------------------------------ @@ -853,17 +848,11 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) // [RH] Show off segs if r_drawflat is 1 if (r_drawflat) { - hcolfunc_pre = R_FillColumnHoriz; - hcolfunc_post1 = rt_copy1col; - hcolfunc_post4 = rt_copy4cols; colfunc = R_FillColumn; spanfunc = R_FillSpan; } else { - hcolfunc_pre = R_DrawColumnHoriz; - hcolfunc_post1 = rt_map1col; - hcolfunc_post4 = rt_map4cols; colfunc = basecolfunc; spanfunc = R_DrawSpan; } diff --git a/src/r_main.h b/src/r_main.h index 37ead76ce..daf60c16d 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -124,12 +124,6 @@ extern void (*transcolfunc) (void); // No shadow effects on floors. extern void (*spanfunc) (void); -// [RH] Function pointers for the horizontal column drawers. -extern void (*hcolfunc_pre) (void); -extern void (*hcolfunc_post1) (int hx, int sx, int yl, int yh); -extern void (*hcolfunc_post2) (int hx, int sx, int yl, int yh); -extern void (*hcolfunc_post4) (int sx, int yl, int yh); - void R_InitTextureMapping (); diff --git a/src/r_poly_triangle.cpp b/src/r_poly_triangle.cpp index 72851b6b3..5da23297b 100644 --- a/src/r_poly_triangle.cpp +++ b/src/r_poly_triangle.cpp @@ -377,7 +377,6 @@ void DrawPolyTrianglesCommand::Execute(DrawerThread *thread) thread_data.num_cores = thread->num_cores; thread_data.pass_start_y = thread->pass_start_y; thread_data.pass_end_y = thread->pass_end_y; - thread_data.temp = thread->dc_temp_rgba; thread_data.FullSpans = thread->FullSpansBuffer.data(); thread_data.PartialBlocks = thread->PartialBlocksBuffer.data(); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index edad2aecc..a2d02c3f9 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -2323,8 +2323,6 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, } while (needrepeat--); colfunc = basecolfunc; - hcolfunc_post1 = rt_map1col; - hcolfunc_post4 = rt_map4cols; R_FinishSetPatchStyle (); done: diff --git a/src/r_things.cpp b/src/r_things.cpp index 22d6b7ac6..7b945a44c 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -366,18 +366,12 @@ void R_DrawMaskedColumnBgra(FTexture *tex, fixed_t col, bool useRt, bool unmaske double v = ((dc_yl + 0.5 - sprtopscreen) / spryscale) / tex->GetHeight(); dc_texturefrac = (uint32_t)(v * (1 << 30)); - if (useRt) - hcolfunc_pre(); - else - colfunc(); + colfunc(); } span++; } dc_iscale = saved_iscale; - - if (sprflipvert && useRt) - rt_flip_posts(); } void R_DrawMaskedColumn (FTexture *tex, fixed_t col, bool useRt, bool unmasked) @@ -447,16 +441,10 @@ void R_DrawMaskedColumn (FTexture *tex, fixed_t col, bool useRt, bool unmasked) else if (dc_iscale < 0) dc_count = MIN(dc_count, (dc_texturefrac - dc_iscale) / (-dc_iscale)); - if (useRt) - hcolfunc_pre(); - else - colfunc (); + colfunc (); } span++; } - - if (sprflipvert && useRt) - rt_flip_posts(); } // [ZZ] @@ -705,6 +693,7 @@ void R_WallSpriteColumn (bool useRt) void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop, short *clipbot) { +#if 0 int flags = 0; // Do setup for blending. @@ -772,6 +761,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop R_FinishSetPatchStyle(); NetUpdate(); +#endif } // @@ -2857,6 +2847,7 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, fixed_t daxscale, fixed_t dayscale, FVoxel *voxobj, FSWColormap *colormap, int colormapnum, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags) { +#if 0 int i, j, k, x, y, syoff, ggxstart, ggystart, nxoff; fixed_t cosang, sinang, sprcosang, sprsinang; int backx, backy, gxinc, gyinc; @@ -3184,6 +3175,7 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, } } } +#endif } //========================================================================== diff --git a/src/r_thread.h b/src/r_thread.h index ea1ceaa29..c3e818abb 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -45,9 +45,6 @@ class DrawerThread public: DrawerThread() { - dc_temp = dc_temp_buff; - dc_temp_rgba = dc_temp_rgbabuff_rgba; - FullSpansBuffer.resize(MAXWIDTH / 8 * (MAXHEIGHT / 8)); PartialBlocksBuffer.resize(MAXWIDTH / 8 * (MAXHEIGHT / 8)); } @@ -64,14 +61,6 @@ public: int pass_start_y = 0; int pass_end_y = MAXHEIGHT; - // Working buffer used by Rt drawers - uint8_t dc_temp_buff[MAXHEIGHT * 4]; - uint8_t *dc_temp = nullptr; - - // Working buffer used by Rt drawers, true color edition - uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT * 4]; - uint32_t *dc_temp_rgba = nullptr; - // Working buffer used by the tilted (sloped) span drawer const uint8_t *tiltlighting[MAXWIDTH]; diff --git a/tools/drawergen/fixedfunction/drawcolumncodegen.cpp b/tools/drawergen/fixedfunction/drawcolumncodegen.cpp index 177074dad..6e00528ae 100644 --- a/tools/drawergen/fixedfunction/drawcolumncodegen.cpp +++ b/tools/drawergen/fixedfunction/drawcolumncodegen.cpp @@ -32,7 +32,7 @@ #include "ssa/ssa_struct_type.h" #include "ssa/ssa_value.h" -void DrawColumnCodegen::Generate(DrawColumnVariant variant, DrawColumnMethod method, SSAValue args, SSAValue thread_data) +void DrawColumnCodegen::Generate(DrawColumnVariant variant, SSAValue args, SSAValue thread_data) { dest = args[0][0].load(true); source = args[0][1].load(true); @@ -43,12 +43,9 @@ void DrawColumnCodegen::Generate(DrawColumnVariant variant, DrawColumnMethod met pitch = args[0][6].load(true); count = args[0][7].load(true); dest_y = args[0][8].load(true); - if (method == DrawColumnMethod::Normal) - { - iscale = args[0][9].load(true); - texturefracx = args[0][10].load(true); - textureheight = args[0][11].load(true); - } + iscale = args[0][9].load(true); + texturefracx = args[0][10].load(true); + textureheight = args[0][11].load(true); texturefrac = args[0][12].load(true); light = args[0][13].load(true); color = SSAVec4i::unpack(args[0][14].load(true)); @@ -81,49 +78,32 @@ void DrawColumnCodegen::Generate(DrawColumnVariant variant, DrawColumnMethod met count = count_for_thread(dest_y, count, thread); dest = dest_for_thread(dest_y, pitch, dest, thread); pitch = pitch * thread.num_cores; - if (method == DrawColumnMethod::Normal) - { - stack_frac.store(texturefrac + iscale * skipped_by_thread(dest_y, thread)); - iscale = iscale * thread.num_cores; - one = (1 << 30) / textureheight; - SSAIfBlock branch; - branch.if_block(is_simple_shade); - LoopShade(variant, method, true); - branch.else_block(); - LoopShade(variant, method, false); - branch.end_block(); - } - else - { - source = thread.temp[((dest_y + skipped_by_thread(dest_y, thread)) * 4 + texturefrac) * 4]; + stack_frac.store(texturefrac + iscale * skipped_by_thread(dest_y, thread)); + iscale = iscale * thread.num_cores; + one = (1 << 30) / textureheight; - SSAIfBlock branch; - branch.if_block(is_simple_shade); - Loop(variant, method, true, true); - branch.else_block(); - Loop(variant, method, false, true); - branch.end_block(); - } -} - -void DrawColumnCodegen::LoopShade(DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade) -{ SSAIfBlock branch; - branch.if_block(is_nearest_filter); - Loop(variant, method, isSimpleShade, true); + branch.if_block(is_simple_shade); + LoopShade(variant, true); branch.else_block(); - stack_frac.store(stack_frac.load() - (one >> 1)); - Loop(variant, method, isSimpleShade, false); + LoopShade(variant, false); branch.end_block(); } -void DrawColumnCodegen::Loop(DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade, bool isNearestFilter) +void DrawColumnCodegen::LoopShade(DrawColumnVariant variant, bool isSimpleShade) { - SSAInt sincr; - if (method != DrawColumnMethod::Normal) - sincr = thread.num_cores * 4; + SSAIfBlock branch; + branch.if_block(is_nearest_filter); + Loop(variant, isSimpleShade, true); + branch.else_block(); + stack_frac.store(stack_frac.load() - (one >> 1)); + Loop(variant, isSimpleShade, false); + branch.end_block(); +} +void DrawColumnCodegen::Loop(DrawColumnVariant variant, bool isSimpleShade, bool isNearestFilter) +{ stack_index.store(SSAInt(0)); { SSAForBlock loop; @@ -131,56 +111,21 @@ void DrawColumnCodegen::Loop(DrawColumnVariant variant, DrawColumnMethod method, loop.loop_block(index < count); SSAInt sample_index, frac; - if (method == DrawColumnMethod::Normal) - { - frac = stack_frac.load(); - if (IsPaletteInput(variant)) - sample_index = frac >> FRACBITS; - else - sample_index = frac; - } + frac = stack_frac.load(); + if (IsPaletteInput(variant)) + sample_index = frac >> FRACBITS; else - { - sample_index = index * sincr * 4; - } + sample_index = frac; SSAInt offset = index * pitch * 4; - SSAVec4i bgcolor[4]; + SSAVec4i bgcolor = dest[offset].load_vec4ub(false); - int numColumns = (method == DrawColumnMethod::Rt4) ? 4 : 1; + SSAVec4i outcolor = ProcessPixel(sample_index, bgcolor, variant, isSimpleShade, isNearestFilter); - if (numColumns == 4) - { - SSAVec16ub bg = dest[offset].load_unaligned_vec16ub(false); - SSAVec8s bg0 = SSAVec8s::extendlo(bg); - SSAVec8s bg1 = SSAVec8s::extendhi(bg); - bgcolor[0] = SSAVec4i::extendlo(bg0); - bgcolor[1] = SSAVec4i::extendhi(bg0); - bgcolor[2] = SSAVec4i::extendlo(bg1); - bgcolor[3] = SSAVec4i::extendhi(bg1); - } - else - { - bgcolor[0] = dest[offset].load_vec4ub(false); - } - - SSAVec4i outcolor[4]; - for (int i = 0; i < numColumns; i++) - outcolor[i] = ProcessPixel(sample_index + i * 4, bgcolor[i], variant, method, isSimpleShade, isNearestFilter); - - if (numColumns == 4) - { - SSAVec16ub packedcolor(SSAVec8s(outcolor[0], outcolor[1]), SSAVec8s(outcolor[2], outcolor[3])); - dest[offset].store_unaligned_vec16ub(packedcolor); - } - else - { - dest[offset].store_vec4ub(outcolor[0]); - } + dest[offset].store_vec4ub(outcolor); stack_index.store(index.add(SSAInt(1), true, true)); - if (method == DrawColumnMethod::Normal) - stack_frac.store(frac + iscale); + stack_frac.store(frac + iscale); loop.end_block(); } } @@ -212,7 +157,7 @@ bool DrawColumnCodegen::IsPaletteInput(DrawColumnVariant variant) } } -SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade, bool isNearestFilter) +SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade, bool isNearestFilter) { SSAInt alpha, inv_alpha; SSAVec4i fg; @@ -220,22 +165,22 @@ SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, { default: case DrawColumnVariant::DrawCopy: - return blend_copy(Sample(sample_index, method, isNearestFilter)); + return blend_copy(Sample(sample_index, isNearestFilter)); case DrawColumnVariant::Draw: - return blend_copy(Shade(Sample(sample_index, method, isNearestFilter), isSimpleShade)); + return blend_copy(Shade(Sample(sample_index, isNearestFilter), isSimpleShade)); case DrawColumnVariant::DrawAdd: case DrawColumnVariant::DrawAddClamp: - fg = Shade(Sample(sample_index, method, isNearestFilter), isSimpleShade); + fg = Shade(Sample(sample_index, isNearestFilter), isSimpleShade); return blend_add(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha)); case DrawColumnVariant::DrawShaded: alpha = SSAInt::MAX(SSAInt::MIN(ColormapSample(sample_index), SSAInt(64)), SSAInt(0)) * 4; inv_alpha = 256 - alpha; return blend_add(color, bgcolor, alpha, inv_alpha); case DrawColumnVariant::DrawSubClamp: - fg = Shade(Sample(sample_index, method, isNearestFilter), isSimpleShade); + fg = Shade(Sample(sample_index, isNearestFilter), isSimpleShade); return blend_sub(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha)); case DrawColumnVariant::DrawRevSubClamp: - fg = Shade(Sample(sample_index, method, isNearestFilter), isSimpleShade); + fg = Shade(Sample(sample_index, isNearestFilter), isSimpleShade); return blend_revsub(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha)); case DrawColumnVariant::DrawTranslated: return blend_copy(Shade(TranslateSample(sample_index), isSimpleShade)); @@ -311,23 +256,16 @@ SSAVec4i DrawColumnCodegen::ProcessPixelPal(SSAInt sample_index, SSAVec4i bgcolo } } -SSAVec4i DrawColumnCodegen::Sample(SSAInt frac, DrawColumnMethod method, bool isNearestFilter) +SSAVec4i DrawColumnCodegen::Sample(SSAInt frac, bool isNearestFilter) { - if (method == DrawColumnMethod::Normal) + if (isNearestFilter) { - if (isNearestFilter) - { - SSAInt sample_index = (((frac << 2) >> FRACBITS) * textureheight) >> FRACBITS; - return source[sample_index * 4].load_vec4ub(false); - } - else - { - return SampleLinear(source, source2, texturefracx, frac, one, textureheight); - } + SSAInt sample_index = (((frac << 2) >> FRACBITS) * textureheight) >> FRACBITS; + return source[sample_index * 4].load_vec4ub(false); } else { - return source[frac].load_vec4ub(true); + return SampleLinear(source, source2, texturefracx, frac, one, textureheight); } } diff --git a/tools/drawergen/fixedfunction/drawcolumncodegen.h b/tools/drawergen/fixedfunction/drawcolumncodegen.h index 2c44edc5c..905654911 100644 --- a/tools/drawergen/fixedfunction/drawcolumncodegen.h +++ b/tools/drawergen/fixedfunction/drawcolumncodegen.h @@ -45,24 +45,17 @@ enum class DrawColumnVariant DrawRevSubClampTranslated }; -enum class DrawColumnMethod -{ - Normal, - Rt1, - Rt4 -}; - class DrawColumnCodegen : public DrawerCodegen { public: - void Generate(DrawColumnVariant variant, DrawColumnMethod method, SSAValue args, SSAValue thread_data); + void Generate(DrawColumnVariant variant, SSAValue args, SSAValue thread_data); private: - void LoopShade(DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade); - void Loop(DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade, bool isNearestFilter); - SSAVec4i ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, DrawColumnMethod method, bool isSimpleShade, bool isNearestFilter); + void LoopShade(DrawColumnVariant variant, bool isSimpleShade); + void Loop(DrawColumnVariant variant, bool isSimpleShade, bool isNearestFilter); + SSAVec4i ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade, bool isNearestFilter); SSAVec4i ProcessPixelPal(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade); - SSAVec4i Sample(SSAInt frac, DrawColumnMethod method, bool isNearestFilter); + SSAVec4i Sample(SSAInt frac, bool isNearestFilter); SSAVec4i SampleLinear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height); SSAInt ColormapSample(SSAInt frac); SSAVec4i TranslateSample(SSAInt frac); diff --git a/tools/drawergen/llvmdrawers.cpp b/tools/drawergen/llvmdrawers.cpp index 5c3bf05a4..099919997 100644 --- a/tools/drawergen/llvmdrawers.cpp +++ b/tools/drawergen/llvmdrawers.cpp @@ -29,46 +29,22 @@ LLVMDrawers::LLVMDrawers(const std::string &triple, const std::string &cpuName, { mProgram.CreateModule(); - CodegenDrawColumn("FillColumn", DrawColumnVariant::Fill, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnAdd", DrawColumnVariant::FillAdd, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnAddClamp", DrawColumnVariant::FillAddClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnSubClamp", DrawColumnVariant::FillSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("FillColumnRevSubClamp", DrawColumnVariant::FillRevSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumn", DrawColumnVariant::Draw, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnAdd", DrawColumnVariant::DrawAdd, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnShaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnAddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnSubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnRevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnTranslated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnTlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnAddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnSubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnRevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Normal); - CodegenDrawColumn("DrawColumnRt1", DrawColumnVariant::Draw, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt1RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt1); - CodegenDrawColumn("DrawColumnRt4", DrawColumnVariant::Draw, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Copy", DrawColumnVariant::DrawCopy, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Add", DrawColumnVariant::DrawAdd, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Shaded", DrawColumnVariant::DrawShaded, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4AddClamp", DrawColumnVariant::DrawAddClamp, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4SubClamp", DrawColumnVariant::DrawSubClamp, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4RevSubClamp", DrawColumnVariant::DrawRevSubClamp, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4Translated", DrawColumnVariant::DrawTranslated, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4TlatedAdd", DrawColumnVariant::DrawTlatedAdd, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4AddClampTranslated", DrawColumnVariant::DrawAddClampTranslated, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4SubClampTranslated", DrawColumnVariant::DrawSubClampTranslated, DrawColumnMethod::Rt4); - CodegenDrawColumn("DrawColumnRt4RevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated, DrawColumnMethod::Rt4); + CodegenDrawColumn("FillColumn", DrawColumnVariant::Fill); + CodegenDrawColumn("FillColumnAdd", DrawColumnVariant::FillAdd); + CodegenDrawColumn("FillColumnAddClamp", DrawColumnVariant::FillAddClamp); + CodegenDrawColumn("FillColumnSubClamp", DrawColumnVariant::FillSubClamp); + CodegenDrawColumn("FillColumnRevSubClamp", DrawColumnVariant::FillRevSubClamp); + CodegenDrawColumn("DrawColumn", DrawColumnVariant::Draw); + CodegenDrawColumn("DrawColumnAdd", DrawColumnVariant::DrawAdd); + CodegenDrawColumn("DrawColumnShaded", DrawColumnVariant::DrawShaded); + CodegenDrawColumn("DrawColumnAddClamp", DrawColumnVariant::DrawAddClamp); + CodegenDrawColumn("DrawColumnSubClamp", DrawColumnVariant::DrawSubClamp); + CodegenDrawColumn("DrawColumnRevSubClamp", DrawColumnVariant::DrawRevSubClamp); + CodegenDrawColumn("DrawColumnTranslated", DrawColumnVariant::DrawTranslated); + CodegenDrawColumn("DrawColumnTlatedAdd", DrawColumnVariant::DrawTlatedAdd); + CodegenDrawColumn("DrawColumnAddClampTranslated", DrawColumnVariant::DrawAddClampTranslated); + CodegenDrawColumn("DrawColumnSubClampTranslated", DrawColumnVariant::DrawSubClampTranslated); + CodegenDrawColumn("DrawColumnRevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated); CodegenDrawSpan("DrawSpan", DrawSpanVariant::Opaque); CodegenDrawSpan("DrawSpanMasked", DrawSpanVariant::Masked); CodegenDrawSpan("DrawSpanTranslucent", DrawSpanVariant::Translucent); @@ -102,7 +78,7 @@ LLVMDrawers::LLVMDrawers(const std::string &triple, const std::string &cpuName, ObjectFile = mProgram.GenerateObjectFile(triple, cpuName, features); } -void LLVMDrawers::CodegenDrawColumn(const char *name, DrawColumnVariant variant, DrawColumnMethod method) +void LLVMDrawers::CodegenDrawColumn(const char *name, DrawColumnVariant variant) { llvm::IRBuilder<> builder(mProgram.context()); SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder); @@ -113,7 +89,7 @@ void LLVMDrawers::CodegenDrawColumn(const char *name, DrawColumnVariant variant, function.create_public(); DrawColumnCodegen codegen; - codegen.Generate(variant, method, function.parameter(0), function.parameter(1)); + codegen.Generate(variant, function.parameter(0), function.parameter(1)); builder.CreateRetVoid(); diff --git a/tools/drawergen/llvmdrawers.h b/tools/drawergen/llvmdrawers.h index f546d1dff..a7f1c8625 100644 --- a/tools/drawergen/llvmdrawers.h +++ b/tools/drawergen/llvmdrawers.h @@ -47,7 +47,7 @@ public: std::vector ObjectFile; private: - void CodegenDrawColumn(const char *name, DrawColumnVariant variant, DrawColumnMethod method); + void CodegenDrawColumn(const char *name, DrawColumnVariant variant); void CodegenDrawSpan(const char *name, DrawSpanVariant variant); void CodegenDrawWall(const char *name, DrawWallVariant variant, int columns); void CodegenDrawSky(const char *name, DrawSkyVariant variant, int columns); From ea92b9548378fb99848a75cdddf24de5a0af3886 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 25 Dec 2016 06:00:18 +0100 Subject: [PATCH 1486/1509] Change define to if statement --- src/r_walldraw.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/r_walldraw.cpp b/src/r_walldraw.cpp index 4f532a78e..894144300 100644 --- a/src/r_walldraw.cpp +++ b/src/r_walldraw.cpp @@ -805,29 +805,31 @@ static void ProcessWallWorker( double xmagnitude = 1.0; -#if !defined(NO_DYNAMIC_SWLIGHTS) - for (int x = x1; x < x2; x++, light += rw_lightstep) + if (r_dynlights) { - int y1 = uwal[x]; - int y2 = dwal[x]; - if (y2 <= y1) - continue; + for (int x = x1; x < x2; x++, light += rw_lightstep) + { + int y1 = uwal[x]; + int y2 = dwal[x]; + if (y2 <= y1) + continue; - if (!fixed) - R_SetColorMapLight(basecolormap, light, wallshade); + if (!fixed) + R_SetColorMapLight(basecolormap, light, wallshade); - if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); + if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); - WallSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); - Draw1Column(x, y1, y2, sampler, draw1column); + WallSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); + Draw1Column(x, y1, y2, sampler, draw1column); + } + NetUpdate(); + return; } -#else + // Calculate where 4 column alignment begins and ends: int aligned_x1 = clamp((x1 + 3) / 4 * 4, x1, x2); int aligned_x2 = clamp(x2 / 4 * 4, x1, x2); - double xmagnitude = 1.0; - // First unaligned columns: for (int x = x1; x < aligned_x1; x++, light += rw_lightstep) { @@ -956,7 +958,6 @@ static void ProcessWallWorker( WallSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol); Draw1Column(x, y1, y2, sampler, draw1column); } -#endif NetUpdate(); } From d428634c58e2966e55088594ba578d40f40fcb6f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 25 Dec 2016 07:15:17 +0100 Subject: [PATCH 1487/1509] Add dynlights to pal wall drawers --- src/r_draw_pal.cpp | 197 ++++++++++++++++++++++++++++++++++++++------- src/r_draw_pal.h | 6 ++ src/r_walldraw.cpp | 110 ++++++++++++------------- 3 files changed, 229 insertions(+), 84 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 37d38891e..66129fea7 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -103,6 +103,10 @@ namespace swrenderer _pitch = dc_pitch; _srcblend = dc_srcblend; _destblend = dc_destblend; + _dynlights = dc_lights; + _num_dynlights = dc_num_lights; + _viewpos_z = dc_viewpos.Z; + _step_viewpos_z = dc_viewpos_step.Z; } PalWall4Command::PalWall4Command() @@ -124,6 +128,43 @@ namespace swrenderer _destblend = dc_destblend; } + uint8_t PalWall1Command::AddLights(const TriLight *lights, int num_lights, float viewpos_z, uint8_t fg, uint8_t material) + { + uint32_t lit_r = GPalette.BaseColors[fg].r; + uint32_t lit_g = GPalette.BaseColors[fg].g; + uint32_t lit_b = GPalette.BaseColors[fg].b; + + uint32_t material_r = GPalette.BaseColors[material].r; + uint32_t material_g = GPalette.BaseColors[material].g; + uint32_t material_b = GPalette.BaseColors[material].b; + + for (int i = 0; i < num_lights; i++) + { + uint32_t light_color_r = RPART(lights[i].color); + uint32_t light_color_g = GPART(lights[i].color); + uint32_t light_color_b = BPART(lights[i].color); + + // L = light-pos + // dist = sqrt(dot(L, L)) + // attenuation = 1 - MIN(dist * (1/radius), 1) + float Lxy2 = lights[i].x; // L.x*L.x + L.y*L.y + float Lz = lights[i].z - viewpos_z; + float dist2 = Lxy2 + Lz * Lz; + float dist = dist2 * _mm_cvtss_f32(_mm_rsqrt_ss(_mm_load_ss(&dist2))); + uint32_t attenuation = (uint32_t)(256.0f - MIN(dist * lights[i].radius, 256.0f)); + + lit_r += (light_color_r * material_r * attenuation) >> 16; + lit_g += (light_color_g * material_g * attenuation) >> 16; + lit_b += (light_color_b * material_b * attenuation) >> 16; + } + + lit_r = MIN(lit_r, 255); + lit_g = MIN(lit_g, 255); + lit_b = MIN(lit_b, 255); + + return RGB256k.All[((lit_r >> 2) << 12) | ((lit_g >> 2) << 6) | (lit_b >> 2)]; + } + void DrawWall1PalCommand::Execute(DrawerThread *thread) { uint32_t fracstep = _iscale; @@ -134,6 +175,10 @@ namespace swrenderer uint8_t *dest = _dest; int bits = _fracbits; int pitch = _pitch; + TriLight *dynlights = _dynlights; + int num_dynlights = _num_dynlights; + float viewpos_z = _viewpos_z; + float step_viewpos_z = _step_viewpos_z; count = thread->count_for_thread(_dest_y, count); if (count <= 0) @@ -144,12 +189,31 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; - do + if (num_dynlights == 0) { - *dest = colormap[source[frac >> bits]]; - frac += fracstep; - dest += pitch; - } while (--count); + do + { + *dest = colormap[source[frac >> bits]]; + frac += fracstep; + dest += pitch; + } while (--count); + } + else + { + float viewpos_z = _viewpos_z; + float step_viewpos_z = _step_viewpos_z; + + viewpos_z += step_viewpos_z * thread->skipped_by_thread(_dest_y); + step_viewpos_z *= thread->num_cores; + + do + { + *dest = AddLights(dynlights, num_dynlights, viewpos_z, colormap[source[frac >> bits]], source[frac >> bits]); + viewpos_z += step_viewpos_z; + frac += fracstep; + dest += pitch; + } while (--count); + } } void DrawWall4PalCommand::Execute(DrawerThread *thread) @@ -212,6 +276,10 @@ namespace swrenderer uint8_t *dest = _dest; int bits = _fracbits; int pitch = _pitch; + TriLight *dynlights = _dynlights; + int num_dynlights = _num_dynlights; + float viewpos_z = _viewpos_z; + float step_viewpos_z = _step_viewpos_z; count = thread->count_for_thread(_dest_y, count); if (count <= 0) @@ -222,16 +290,39 @@ namespace swrenderer fracstep *= thread->num_cores; pitch *= thread->num_cores; - do + if (num_dynlights == 0) { - uint8_t pix = source[frac >> bits]; - if (pix != 0) + do { - *dest = colormap[pix]; - } - frac += fracstep; - dest += pitch; - } while (--count); + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + *dest = colormap[pix]; + } + frac += fracstep; + dest += pitch; + } while (--count); + } + else + { + float viewpos_z = _viewpos_z; + float step_viewpos_z = _step_viewpos_z; + + viewpos_z += step_viewpos_z * thread->skipped_by_thread(_dest_y); + step_viewpos_z *= thread->num_cores; + + do + { + uint8_t pix = source[frac >> bits]; + if (pix != 0) + { + *dest = AddLights(dynlights, num_dynlights, viewpos_z, colormap[pix], pix); + } + viewpos_z += step_viewpos_z; + frac += fracstep; + dest += pitch; + } while (--count); + } } void DrawWallMasked4PalCommand::Execute(DrawerThread *thread) @@ -296,6 +387,10 @@ namespace swrenderer uint8_t *dest = _dest; int bits = _fracbits; int pitch = _pitch; + TriLight *dynlights = _dynlights; + int num_dynlights = _num_dynlights; + float viewpos_z = _viewpos_z; + float step_viewpos_z = _step_viewpos_z; uint32_t *fg2rgb = _srcblend; uint32_t *bg2rgb = _destblend; @@ -308,6 +403,8 @@ namespace swrenderer frac += fracstep * thread->skipped_by_thread(_dest_y); fracstep *= thread->num_cores; pitch *= thread->num_cores; + viewpos_z += step_viewpos_z * thread->skipped_by_thread(_dest_y); + step_viewpos_z *= thread->num_cores; if (!r_blendmethod) { @@ -316,11 +413,14 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { - uint32_t fg = fg2rgb[colormap[pix]]; + uint8_t lit = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_z, colormap[pix], pix) : colormap[pix]; + + uint32_t fg = fg2rgb[lit]; uint32_t bg = bg2rgb[*dest]; fg = (fg + bg) | 0x1f07c1f; *dest = RGB32k.All[fg & (fg >> 15)]; } + viewpos_z += step_viewpos_z; frac += fracstep; dest += pitch; } while (--count); @@ -333,11 +433,14 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { - uint32_t r = MIN(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 255); - uint32_t g = MIN(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 255); - uint32_t b = MIN(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 255); + uint8_t lit = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_z, colormap[pix], pix) : colormap[pix]; + + uint32_t r = MIN(GPalette.BaseColors[lit].r + GPalette.BaseColors[*dest].r, 255); + uint32_t g = MIN(GPalette.BaseColors[lit].g + GPalette.BaseColors[*dest].g, 255); + uint32_t b = MIN(GPalette.BaseColors[lit].b + GPalette.BaseColors[*dest].b, 255); *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; } + viewpos_z += step_viewpos_z; frac += fracstep; dest += pitch; } while (--count); @@ -420,6 +523,10 @@ namespace swrenderer uint8_t *dest = _dest; int bits = _fracbits; int pitch = _pitch; + TriLight *dynlights = _dynlights; + int num_dynlights = _num_dynlights; + float viewpos_z = _viewpos_z; + float step_viewpos_z = _step_viewpos_z; uint32_t *fg2rgb = _srcblend; uint32_t *bg2rgb = _destblend; @@ -432,6 +539,8 @@ namespace swrenderer frac += fracstep * thread->skipped_by_thread(_dest_y); fracstep *= thread->num_cores; pitch *= thread->num_cores; + viewpos_z += step_viewpos_z * thread->skipped_by_thread(_dest_y); + step_viewpos_z *= thread->num_cores; if (!r_blendmethod) { @@ -440,7 +549,9 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { - uint32_t a = fg2rgb[colormap[pix]] + bg2rgb[*dest]; + uint8_t lit = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_z, colormap[pix], pix) : colormap[pix]; + + uint32_t a = fg2rgb[lit] + bg2rgb[*dest]; uint32_t b = a; a |= 0x01f07c1f; @@ -450,6 +561,7 @@ namespace swrenderer a |= b; *dest = RGB32k.All[a & (a >> 15)]; } + viewpos_z += step_viewpos_z; frac += fracstep; dest += pitch; } while (--count); @@ -461,11 +573,14 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { - uint32_t r = MIN(GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 255); - uint32_t g = MIN(GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 255); - uint32_t b = MIN(GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 255); + uint8_t lit = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_z, colormap[pix], pix) : colormap[pix]; + + uint32_t r = MIN(GPalette.BaseColors[lit].r + GPalette.BaseColors[*dest].r, 255); + uint32_t g = MIN(GPalette.BaseColors[lit].g + GPalette.BaseColors[*dest].g, 255); + uint32_t b = MIN(GPalette.BaseColors[lit].b + GPalette.BaseColors[*dest].b, 255); *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; } + viewpos_z += step_viewpos_z; frac += fracstep; dest += pitch; } while (--count); @@ -526,6 +641,10 @@ namespace swrenderer uint8_t *dest = _dest; int bits = _fracbits; int pitch = _pitch; + TriLight *dynlights = _dynlights; + int num_dynlights = _num_dynlights; + float viewpos_z = _viewpos_z; + float step_viewpos_z = _step_viewpos_z; uint32_t *fg2rgb = _srcblend; uint32_t *bg2rgb = _destblend; @@ -538,6 +657,8 @@ namespace swrenderer frac += fracstep * thread->skipped_by_thread(_dest_y); fracstep *= thread->num_cores; pitch *= thread->num_cores; + viewpos_z += step_viewpos_z * thread->skipped_by_thread(_dest_y); + step_viewpos_z *= thread->num_cores; if (!r_blendmethod) { @@ -546,7 +667,9 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { - uint32_t a = (fg2rgb[colormap[pix]] | 0x40100400) - bg2rgb[*dest]; + uint8_t lit = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_z, colormap[pix], pix) : colormap[pix]; + + uint32_t a = (fg2rgb[lit] | 0x40100400) - bg2rgb[*dest]; uint32_t b = a; b &= 0x40100400; @@ -555,6 +678,7 @@ namespace swrenderer a |= 0x01f07c1f; *dest = RGB32k.All[a & (a >> 15)]; } + viewpos_z += step_viewpos_z; frac += fracstep; dest += pitch; } while (--count); @@ -566,11 +690,14 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { - int r = clamp(-GPalette.BaseColors[colormap[pix]].r + GPalette.BaseColors[*dest].r, 0, 255); - int g = clamp(-GPalette.BaseColors[colormap[pix]].g + GPalette.BaseColors[*dest].g, 0, 255); - int b = clamp(-GPalette.BaseColors[colormap[pix]].b + GPalette.BaseColors[*dest].b, 0, 255); + uint8_t lit = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_z, colormap[pix], pix) : colormap[pix]; + + int r = clamp(-GPalette.BaseColors[lit].r + GPalette.BaseColors[*dest].r, 0, 255); + int g = clamp(-GPalette.BaseColors[lit].g + GPalette.BaseColors[*dest].g, 0, 255); + int b = clamp(-GPalette.BaseColors[lit].b + GPalette.BaseColors[*dest].b, 0, 255); *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; } + viewpos_z += step_viewpos_z; frac += fracstep; dest += pitch; } while (--count); @@ -657,6 +784,10 @@ namespace swrenderer uint8_t *dest = _dest; int bits = _fracbits; int pitch = _pitch; + TriLight *dynlights = _dynlights; + int num_dynlights = _num_dynlights; + float viewpos_z = _viewpos_z; + float step_viewpos_z = _step_viewpos_z; uint32_t *fg2rgb = _srcblend; uint32_t *bg2rgb = _destblend; @@ -669,6 +800,8 @@ namespace swrenderer frac += fracstep * thread->skipped_by_thread(_dest_y); fracstep *= thread->num_cores; pitch *= thread->num_cores; + viewpos_z += step_viewpos_z * thread->skipped_by_thread(_dest_y); + step_viewpos_z *= thread->num_cores; if (!r_blendmethod) { @@ -677,7 +810,9 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { - uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[colormap[pix]]; + uint8_t lit = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_z, colormap[pix], pix) : colormap[pix]; + + uint32_t a = (bg2rgb[*dest] | 0x40100400) - fg2rgb[lit]; uint32_t b = a; b &= 0x40100400; @@ -686,6 +821,7 @@ namespace swrenderer a |= 0x01f07c1f; *dest = RGB32k.All[a & (a >> 15)]; } + viewpos_z += step_viewpos_z; frac += fracstep; dest += pitch; } while (--count); @@ -697,11 +833,14 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { - int r = clamp(GPalette.BaseColors[colormap[pix]].r - GPalette.BaseColors[*dest].r, 0, 255); - int g = clamp(GPalette.BaseColors[colormap[pix]].g - GPalette.BaseColors[*dest].g, 0, 255); - int b = clamp(GPalette.BaseColors[colormap[pix]].b - GPalette.BaseColors[*dest].b, 0, 255); + uint8_t lit = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_z, colormap[pix], pix) : colormap[pix]; + + int r = clamp(GPalette.BaseColors[lit].r - GPalette.BaseColors[*dest].r, 0, 255); + int g = clamp(GPalette.BaseColors[lit].g - GPalette.BaseColors[*dest].g, 0, 255); + int b = clamp(GPalette.BaseColors[lit].b - GPalette.BaseColors[*dest].b, 0, 255); *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; } + viewpos_z += step_viewpos_z; frac += fracstep; dest += pitch; } while (--count); diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index 984849b83..5766d38f4 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -14,6 +14,8 @@ namespace swrenderer FString DebugInfo() override { return "PalWallCommand"; } protected: + inline static uint8_t AddLights(const TriLight *lights, int num_lights, float viewpos_z, uint8_t fg, uint8_t material); + uint32_t _iscale; uint32_t _texturefrac; uint8_t *_colormap; @@ -24,6 +26,10 @@ namespace swrenderer int _pitch; uint32_t *_srcblend; uint32_t *_destblend; + TriLight *_dynlights; + int _num_dynlights; + float _viewpos_z; + float _step_viewpos_z; }; class PalWall4Command : public DrawerCommand diff --git a/src/r_walldraw.cpp b/src/r_walldraw.cpp index 894144300..7e4f3f515 100644 --- a/src/r_walldraw.cpp +++ b/src/r_walldraw.cpp @@ -537,71 +537,71 @@ WallSampler::WallSampler(int y1, float swal, double yrepeat, fixed_t xoffset, do // Draw a column with support for non-power-of-two ranges static void Draw1Column(int x, int y1, int y2, WallSampler &sampler, void(*draw1column)()) { - if (r_swtruecolor) + if (r_dynlights) { - if (r_dynlights) + // Find column position in view space + float w1 = 1.0f / WallC.sz1; + float w2 = 1.0f / WallC.sz2; + float t = (x - WallC.sx1 + 0.5f) / (WallC.sx2 - WallC.sx1); + float wcol = w1 * (1.0f - t) + w2 * t; + float zcol = 1.0f / wcol; + dc_viewpos.X = (float)((x + 0.5 - CenterX) / CenterX * zcol); + dc_viewpos.Y = zcol; + dc_viewpos.Z = (float)((CenterY - y1 - 0.5) / InvZtoScale * zcol); + dc_viewpos_step.Z = (float)(-zcol / InvZtoScale); + + static TriLight lightbuffer[64 * 1024]; + static int nextlightindex = 0; + + // Setup lights for column + dc_num_lights = 0; + dc_lights = lightbuffer + nextlightindex; + FLightNode *cur_node = dc_light_list; + while (cur_node && nextlightindex < 64 * 1024) { - // Find column position in view space - float w1 = 1.0f / WallC.sz1; - float w2 = 1.0f / WallC.sz2; - float t = (x - WallC.sx1 + 0.5f) / (WallC.sx2 - WallC.sx1); - float wcol = w1 * (1.0f - t) + w2 * t; - float zcol = 1.0f / wcol; - dc_viewpos.X = (float)((x + 0.5 - CenterX) / CenterX * zcol); - dc_viewpos.Y = zcol; - dc_viewpos.Z = (float)((CenterY - y1 - 0.5) / InvZtoScale * zcol); - dc_viewpos_step.Z = (float)(-zcol / InvZtoScale); - - static TriLight lightbuffer[64 * 1024]; - static int nextlightindex = 0; - - // Setup lights for column - dc_num_lights = 0; - dc_lights = lightbuffer + nextlightindex; - FLightNode *cur_node = dc_light_list; - while (cur_node && nextlightindex < 64 * 1024) + if (!(cur_node->lightsource->flags2&MF2_DORMANT)) { - if (!(cur_node->lightsource->flags2&MF2_DORMANT)) + double lightX = cur_node->lightsource->X() - ViewPos.X; + double lightY = cur_node->lightsource->Y() - ViewPos.Y; + double lightZ = cur_node->lightsource->Z() - ViewPos.Z; + + float lx = (float)(lightX * ViewSin - lightY * ViewCos) - dc_viewpos.X; + float ly = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; + float lz = (float)lightZ; + + // Precalculate the constant part of the dot here so the drawer doesn't have to. + float lconstant = lx * lx + ly * ly; + + // Include light only if it touches this column + float radius = cur_node->lightsource->GetRadius(); + if (radius * radius >= lconstant) { - double lightX = cur_node->lightsource->X() - ViewPos.X; - double lightY = cur_node->lightsource->Y() - ViewPos.Y; - double lightZ = cur_node->lightsource->Z() - ViewPos.Z; + uint32_t red = cur_node->lightsource->GetRed(); + uint32_t green = cur_node->lightsource->GetGreen(); + uint32_t blue = cur_node->lightsource->GetBlue(); - float lx = (float)(lightX * ViewSin - lightY * ViewCos) - dc_viewpos.X; - float ly = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; - float lz = (float)lightZ; - - // Precalculate the constant part of the dot here so the drawer doesn't have to. - float lconstant = lx * lx + ly * ly; - - // Include light only if it touches this column - float radius = cur_node->lightsource->GetRadius(); - if (radius * radius >= lconstant) - { - uint32_t red = cur_node->lightsource->GetRed(); - uint32_t green = cur_node->lightsource->GetGreen(); - uint32_t blue = cur_node->lightsource->GetBlue(); - - nextlightindex++; - auto &light = dc_lights[dc_num_lights++]; - light.x = lconstant; - light.z = lz; - light.radius = 256.0f / cur_node->lightsource->GetRadius(); - light.color = (red << 16) | (green << 8) | blue; - } + nextlightindex++; + auto &light = dc_lights[dc_num_lights++]; + light.x = lconstant; + light.z = lz; + light.radius = 256.0f / cur_node->lightsource->GetRadius(); + light.color = (red << 16) | (green << 8) | blue; } - - cur_node = cur_node->nextLight; } - if (nextlightindex == 64 * 1024) - nextlightindex = 0; - } - else - { - dc_num_lights = 0; + cur_node = cur_node->nextLight; } + if (nextlightindex == 64 * 1024) + nextlightindex = 0; + } + else + { + dc_num_lights = 0; + } + + if (r_swtruecolor) + { int count = y2 - y1; dc_source = sampler.source; From a76cd3533357962f3211a7d06004dffe24ad5ac4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 25 Dec 2016 07:49:44 +0100 Subject: [PATCH 1488/1509] Dynamic lights to the flats in pal mode --- src/r_draw_pal.cpp | 152 +++++++++++++++++++++++++++++++++++++++------ src/r_draw_pal.h | 6 ++ src/r_plane.cpp | 93 ++++++++++++++------------- 3 files changed, 183 insertions(+), 68 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 66129fea7..630255340 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -2384,6 +2384,47 @@ namespace swrenderer _color = ds_color; _srcalpha = dc_srcalpha; _destalpha = dc_destalpha; + _dynlights = dc_lights; + _num_dynlights = dc_num_lights; + _viewpos_x = dc_viewpos.X; + _step_viewpos_x = dc_viewpos_step.X; + } + + uint8_t PalSpanCommand::AddLights(const TriLight *lights, int num_lights, float viewpos_x, uint8_t fg, uint8_t material) + { + uint32_t lit_r = GPalette.BaseColors[fg].r; + uint32_t lit_g = GPalette.BaseColors[fg].g; + uint32_t lit_b = GPalette.BaseColors[fg].b; + + uint32_t material_r = GPalette.BaseColors[material].r; + uint32_t material_g = GPalette.BaseColors[material].g; + uint32_t material_b = GPalette.BaseColors[material].b; + + for (int i = 0; i < num_lights; i++) + { + uint32_t light_color_r = RPART(lights[i].color); + uint32_t light_color_g = GPART(lights[i].color); + uint32_t light_color_b = BPART(lights[i].color); + + // L = light-pos + // dist = sqrt(dot(L, L)) + // attenuation = 1 - MIN(dist * (1/radius), 1) + float Lyz2 = lights[i].y; // L.y*L.y + L.z*L.z + float Lx = lights[i].x - viewpos_x; + float dist2 = Lyz2 + Lx * Lx; + float dist = dist2 * _mm_cvtss_f32(_mm_rsqrt_ss(_mm_load_ss(&dist2))); + uint32_t attenuation = (uint32_t)(256.0f - MIN(dist * lights[i].radius, 256.0f)); + + lit_r += (light_color_r * material_r * attenuation) >> 16; + lit_g += (light_color_g * material_g * attenuation) >> 16; + lit_b += (light_color_b * material_b * attenuation) >> 16; + } + + lit_r = MIN(lit_r, 255); + lit_g = MIN(lit_g, 255); + lit_b = MIN(lit_b, 255); + + return RGB256k.All[((lit_r >> 2) << 12) | ((lit_g >> 2) << 6) | (lit_b >> 2)]; } void DrawSpanPalCommand::Execute(DrawerThread *thread) @@ -2411,7 +2452,12 @@ namespace swrenderer xstep = _xstep; ystep = _ystep; - if (_xbits == 6 && _ybits == 6) + const TriLight *dynlights = _dynlights; + int num_dynlights = _num_dynlights; + float viewpos_x = _viewpos_x; + float step_viewpos_x = _step_viewpos_x; + + if (_xbits == 6 && _ybits == 6 && num_dynlights == 0) { // 64x64 is the most common case by far, so special case it. do @@ -2428,6 +2474,24 @@ namespace swrenderer yfrac += ystep; } while (--count); } + else if (_xbits == 6 && _ybits == 6) + { + // 64x64 is the most common case by far, so special case it. + do + { + // Current texture index in u,v. + spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); + + // Lookup pixel from flat texture tile, + // re-index using light/colormap. + *dest++ = AddLights(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]); + + // Next step in u,v. + xfrac += xstep; + yfrac += ystep; + viewpos_x += step_viewpos_x; + } while (--count); + } else { uint8_t yshift = 32 - _ybits; @@ -2441,11 +2505,12 @@ namespace swrenderer // Lookup pixel from flat texture tile, // re-index using light/colormap. - *dest++ = colormap[source[spot]]; + *dest++ = AddLights(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]); // Next step in u,v. xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } } @@ -2475,6 +2540,11 @@ namespace swrenderer xstep = _xstep; ystep = _ystep; + const TriLight *dynlights = _dynlights; + int num_dynlights = _num_dynlights; + float viewpos_x = _viewpos_x; + float step_viewpos_x = _step_viewpos_x; + if (_xbits == 6 && _ybits == 6) { // 64x64 is the most common case by far, so special case it. @@ -2486,11 +2556,12 @@ namespace swrenderer texdata = source[spot]; if (texdata != 0) { - *dest = colormap[texdata]; + *dest = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; } dest++; xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } else @@ -2506,11 +2577,12 @@ namespace swrenderer texdata = source[spot]; if (texdata != 0) { - *dest = colormap[texdata]; + *dest = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; } dest++; xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } } @@ -2544,6 +2616,11 @@ namespace swrenderer const PalEntry *palette = GPalette.BaseColors; + const TriLight *dynlights = _dynlights; + int num_dynlights = _num_dynlights; + float viewpos_x = _viewpos_x; + float step_viewpos_x = _step_viewpos_x; + if (!r_blendmethod) { if (_xbits == 6 && _ybits == 6) @@ -2552,7 +2629,7 @@ namespace swrenderer do { spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t fg = colormap[source[spot]]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; uint32_t bg = *dest; fg = fg2rgb[fg]; bg = bg2rgb[bg]; @@ -2560,6 +2637,7 @@ namespace swrenderer *dest++ = RGB32k.All[fg & (fg >> 15)]; xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } else @@ -2570,7 +2648,7 @@ namespace swrenderer do { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t fg = colormap[source[spot]]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; uint32_t bg = *dest; fg = fg2rgb[fg]; bg = bg2rgb[bg]; @@ -2578,6 +2656,7 @@ namespace swrenderer *dest++ = RGB32k.All[fg & (fg >> 15)]; xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } } @@ -2589,7 +2668,7 @@ namespace swrenderer do { spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t fg = colormap[source[spot]]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; uint32_t bg = *dest; int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); @@ -2598,6 +2677,7 @@ namespace swrenderer xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } else @@ -2608,7 +2688,7 @@ namespace swrenderer do { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t fg = colormap[source[spot]]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; uint32_t bg = *dest; int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); @@ -2617,6 +2697,7 @@ namespace swrenderer xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } } @@ -2641,6 +2722,11 @@ namespace swrenderer const PalEntry *palette = GPalette.BaseColors; + const TriLight *dynlights = _dynlights; + int num_dynlights = _num_dynlights; + float viewpos_x = _viewpos_x; + float step_viewpos_x = _step_viewpos_x; + xfrac = _xfrac; yfrac = _yfrac; @@ -2664,7 +2750,7 @@ namespace swrenderer texdata = source[spot]; if (texdata != 0) { - uint32_t fg = colormap[texdata]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; uint32_t bg = *dest; fg = fg2rgb[fg]; bg = bg2rgb[bg]; @@ -2674,6 +2760,7 @@ namespace swrenderer dest++; xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } else @@ -2689,7 +2776,7 @@ namespace swrenderer texdata = source[spot]; if (texdata != 0) { - uint32_t fg = colormap[texdata]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; uint32_t bg = *dest; fg = fg2rgb[fg]; bg = bg2rgb[bg]; @@ -2699,6 +2786,7 @@ namespace swrenderer dest++; xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } } @@ -2715,7 +2803,7 @@ namespace swrenderer texdata = source[spot]; if (texdata != 0) { - uint32_t fg = colormap[texdata]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; uint32_t bg = *dest; int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); @@ -2725,6 +2813,7 @@ namespace swrenderer dest++; xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } else @@ -2740,7 +2829,7 @@ namespace swrenderer texdata = source[spot]; if (texdata != 0) { - uint32_t fg = colormap[texdata]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; uint32_t bg = *dest; int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); @@ -2750,6 +2839,7 @@ namespace swrenderer dest++; xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } } @@ -2773,6 +2863,11 @@ namespace swrenderer uint32_t *bg2rgb = _destblend; const PalEntry *palette = GPalette.BaseColors; + const TriLight *dynlights = _dynlights; + int num_dynlights = _num_dynlights; + float viewpos_x = _viewpos_x; + float step_viewpos_x = _step_viewpos_x; + xfrac = _xfrac; yfrac = _yfrac; @@ -2791,7 +2886,8 @@ namespace swrenderer do { spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; + uint32_t a = fg2rgb[fg] + bg2rgb[*dest]; uint32_t b = a; a |= 0x01f07c1f; @@ -2802,6 +2898,7 @@ namespace swrenderer *dest++ = RGB32k.All[a & (a >> 15)]; xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } else @@ -2812,7 +2909,8 @@ namespace swrenderer do { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t a = fg2rgb[colormap[source[spot]]] + bg2rgb[*dest]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; + uint32_t a = fg2rgb[fg] + bg2rgb[*dest]; uint32_t b = a; a |= 0x01f07c1f; @@ -2823,6 +2921,7 @@ namespace swrenderer *dest++ = RGB32k.All[a & (a >> 15)]; xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } } @@ -2834,7 +2933,7 @@ namespace swrenderer do { spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); - uint32_t fg = colormap[source[spot]]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; uint32_t bg = *dest; int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); @@ -2843,6 +2942,7 @@ namespace swrenderer xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } else @@ -2853,7 +2953,7 @@ namespace swrenderer do { spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); - uint32_t fg = colormap[source[spot]]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; uint32_t bg = *dest; int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); @@ -2862,6 +2962,7 @@ namespace swrenderer xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } } @@ -2885,6 +2986,11 @@ namespace swrenderer uint32_t *bg2rgb = _destblend; const PalEntry *palette = GPalette.BaseColors; + const TriLight *dynlights = _dynlights; + int num_dynlights = _num_dynlights; + float viewpos_x = _viewpos_x; + float step_viewpos_x = _step_viewpos_x; + xfrac = _xfrac; yfrac = _yfrac; @@ -2908,7 +3014,8 @@ namespace swrenderer texdata = source[spot]; if (texdata != 0) { - uint32_t a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; + uint32_t a = fg2rgb[fg] + bg2rgb[*dest]; uint32_t b = a; a |= 0x01f07c1f; @@ -2921,6 +3028,7 @@ namespace swrenderer dest++; xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } else @@ -2936,7 +3044,8 @@ namespace swrenderer texdata = source[spot]; if (texdata != 0) { - uint32_t a = fg2rgb[colormap[texdata]] + bg2rgb[*dest]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; + uint32_t a = fg2rgb[fg] + bg2rgb[*dest]; uint32_t b = a; a |= 0x01f07c1f; @@ -2949,6 +3058,7 @@ namespace swrenderer dest++; xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } } @@ -2965,7 +3075,7 @@ namespace swrenderer texdata = source[spot]; if (texdata != 0) { - uint32_t fg = colormap[texdata]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; uint32_t bg = *dest; int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); @@ -2975,6 +3085,7 @@ namespace swrenderer dest++; xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } else @@ -2990,7 +3101,7 @@ namespace swrenderer texdata = source[spot]; if (texdata != 0) { - uint32_t fg = colormap[texdata]; + uint32_t fg = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; uint32_t bg = *dest; int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); @@ -3000,6 +3111,7 @@ namespace swrenderer dest++; xfrac += xstep; yfrac += ystep; + viewpos_x += step_viewpos_x; } while (--count); } } diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index 5766d38f4..5b901152c 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -153,6 +153,8 @@ namespace swrenderer FString DebugInfo() override { return "PalSpanCommand"; } protected: + inline static uint8_t AddLights(const TriLight *lights, int num_lights, float viewpos_x, uint8_t fg, uint8_t material); + const uint8_t *_source; const uint8_t *_colormap; dsfixed_t _xfrac; @@ -170,6 +172,10 @@ namespace swrenderer int _color; fixed_t _srcalpha; fixed_t _destalpha; + TriLight *_dynlights; + int _num_dynlights; + float _viewpos_x; + float _step_viewpos_x; }; class DrawSpanPalCommand : public PalSpanCommand { public: void Execute(DrawerThread *thread) override; }; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index ddde435b2..fce565922 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -256,63 +256,60 @@ void R_MapPlane (int y, int x1) R_SetDSColorMapLight(basecolormap, GlobVis * fabs(CenterY - y), planeshade); } - if (r_swtruecolor) + if (r_dynlights) { - if (r_dynlights) + // Find row position in view space + float zspan = planeheight / (fabs(y + 0.5 - CenterY) / InvZtoScale); + dc_viewpos.X = (float)((x1 + 0.5 - CenterX) / CenterX * zspan); + dc_viewpos.Y = zspan; + dc_viewpos.Z = (float)((CenterY - y - 0.5) / InvZtoScale * zspan); + dc_viewpos_step.X = (float)(zspan / CenterX); + + static TriLight lightbuffer[64 * 1024]; + static int nextlightindex = 0; + + // Setup lights for column + dc_num_lights = 0; + dc_lights = lightbuffer + nextlightindex; + visplane_light *cur_node = ds_light_list; + while (cur_node && nextlightindex < 64 * 1024) { - // Find row position in view space - float zspan = planeheight / (fabs(y + 0.5 - CenterY) / InvZtoScale); - dc_viewpos.X = (float)((x1 + 0.5 - CenterX) / CenterX * zspan); - dc_viewpos.Y = zspan; - dc_viewpos.Z = (float)((CenterY - y - 0.5) / InvZtoScale * zspan); - dc_viewpos_step.X = (float)(zspan / CenterX); + double lightX = cur_node->lightsource->X() - ViewPos.X; + double lightY = cur_node->lightsource->Y() - ViewPos.Y; + double lightZ = cur_node->lightsource->Z() - ViewPos.Z; - static TriLight lightbuffer[64 * 1024]; - static int nextlightindex = 0; + float lx = (float)(lightX * ViewSin - lightY * ViewCos); + float ly = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; + float lz = (float)lightZ - dc_viewpos.Z; - // Setup lights for column - dc_num_lights = 0; - dc_lights = lightbuffer + nextlightindex; - visplane_light *cur_node = ds_light_list; - while (cur_node && nextlightindex < 64 * 1024) + // Precalculate the constant part of the dot here so the drawer doesn't have to. + float lconstant = ly * ly + lz * lz; + + // Include light only if it touches this row + float radius = cur_node->lightsource->GetRadius(); + if (radius * radius >= lconstant) { - double lightX = cur_node->lightsource->X() - ViewPos.X; - double lightY = cur_node->lightsource->Y() - ViewPos.Y; - double lightZ = cur_node->lightsource->Z() - ViewPos.Z; + uint32_t red = cur_node->lightsource->GetRed(); + uint32_t green = cur_node->lightsource->GetGreen(); + uint32_t blue = cur_node->lightsource->GetBlue(); - float lx = (float)(lightX * ViewSin - lightY * ViewCos); - float ly = (float)(lightX * ViewTanCos + lightY * ViewTanSin) - dc_viewpos.Y; - float lz = (float)lightZ - dc_viewpos.Z; - - // Precalculate the constant part of the dot here so the drawer doesn't have to. - float lconstant = ly * ly + lz * lz; - - // Include light only if it touches this row - float radius = cur_node->lightsource->GetRadius(); - if (radius * radius >= lconstant) - { - uint32_t red = cur_node->lightsource->GetRed(); - uint32_t green = cur_node->lightsource->GetGreen(); - uint32_t blue = cur_node->lightsource->GetBlue(); - - nextlightindex++; - auto &light = dc_lights[dc_num_lights++]; - light.x = lx; - light.y = lconstant; - light.radius = 256.0f / radius; - light.color = (red << 16) | (green << 8) | blue; - } - - cur_node = cur_node->next; + nextlightindex++; + auto &light = dc_lights[dc_num_lights++]; + light.x = lx; + light.y = lconstant; + light.radius = 256.0f / radius; + light.color = (red << 16) | (green << 8) | blue; } - if (nextlightindex == 64 * 1024) - nextlightindex = 0; - } - else - { - dc_num_lights = 0; + cur_node = cur_node->next; } + + if (nextlightindex == 64 * 1024) + nextlightindex = 0; + } + else + { + dc_num_lights = 0; } ds_y = y; From 6f86c11058ba2980aa85a4756d1bd6425ad8c81b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 25 Dec 2016 07:56:09 +0100 Subject: [PATCH 1489/1509] DrawWallAdd1Pal cannot do dynamic lights --- src/r_draw.cpp | 4 +++- src/r_draw_pal.cpp | 12 ++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index f629c027d..ae039d642 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -669,8 +669,10 @@ namespace swrenderer { if (r_swtruecolor) DrawerCommandQueue::QueueCommand(); - else + else if (drawerargs::dc_num_lights == 0) DrawerCommandQueue::QueueCommand(); + else + DrawerCommandQueue::QueueCommand(); } void R_DrawWallAddCol4() diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 630255340..a6b6a7946 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -387,10 +387,6 @@ namespace swrenderer uint8_t *dest = _dest; int bits = _fracbits; int pitch = _pitch; - TriLight *dynlights = _dynlights; - int num_dynlights = _num_dynlights; - float viewpos_z = _viewpos_z; - float step_viewpos_z = _step_viewpos_z; uint32_t *fg2rgb = _srcblend; uint32_t *bg2rgb = _destblend; @@ -403,8 +399,6 @@ namespace swrenderer frac += fracstep * thread->skipped_by_thread(_dest_y); fracstep *= thread->num_cores; pitch *= thread->num_cores; - viewpos_z += step_viewpos_z * thread->skipped_by_thread(_dest_y); - step_viewpos_z *= thread->num_cores; if (!r_blendmethod) { @@ -413,14 +407,13 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { - uint8_t lit = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_z, colormap[pix], pix) : colormap[pix]; + uint8_t lit = colormap[pix]; uint32_t fg = fg2rgb[lit]; uint32_t bg = bg2rgb[*dest]; fg = (fg + bg) | 0x1f07c1f; *dest = RGB32k.All[fg & (fg >> 15)]; } - viewpos_z += step_viewpos_z; frac += fracstep; dest += pitch; } while (--count); @@ -433,14 +426,13 @@ namespace swrenderer uint8_t pix = source[frac >> bits]; if (pix != 0) { - uint8_t lit = num_dynlights != 0 ? AddLights(dynlights, num_dynlights, viewpos_z, colormap[pix], pix) : colormap[pix]; + uint8_t lit = colormap[pix]; uint32_t r = MIN(GPalette.BaseColors[lit].r + GPalette.BaseColors[*dest].r, 255); uint32_t g = MIN(GPalette.BaseColors[lit].g + GPalette.BaseColors[*dest].g, 255); uint32_t b = MIN(GPalette.BaseColors[lit].b + GPalette.BaseColors[*dest].b, 255); *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; } - viewpos_z += step_viewpos_z; frac += fracstep; dest += pitch; } while (--count); From 08fd81802d518e0fbb1eb537ceefcea5d0661465 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 25 Dec 2016 08:01:21 +0100 Subject: [PATCH 1490/1509] Remove useRt --- src/r_segs.cpp | 8 ++++---- src/r_things.cpp | 14 +++++++------- src/r_things.h | 4 ++-- src/v_draw.cpp | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index a2d02c3f9..eff303acb 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -153,7 +153,7 @@ inline bool IsFogBoundary (sector_t *front, sector_t *back) float *MaskedSWall; float MaskedScaleY; -static void BlastMaskedColumn (FTexture *tex, bool useRt) +static void BlastMaskedColumn (FTexture *tex) { // calculate lighting if (fixedcolormap == NULL && fixedlightlev < 0) @@ -176,7 +176,7 @@ static void BlastMaskedColumn (FTexture *tex, bool useRt) // when forming multipatched textures (see r_data.c). // draw the texture - R_DrawMaskedColumn(tex, maskedtexturecol[dc_x], useRt); + R_DrawMaskedColumn(tex, maskedtexturecol[dc_x]); rw_light += rw_lightstep; spryscale += rw_scalestep; } @@ -415,7 +415,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) { for (dc_x = x1; dc_x < x2; ++dc_x) { - BlastMaskedColumn (tex, false); + BlastMaskedColumn (tex); } } } @@ -2309,7 +2309,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { // calculate lighting R_SetColorMapLight(usecolormap, rw_light, wallshade); } - R_WallSpriteColumn (false); + R_WallSpriteColumn (); dc_x++; } } diff --git a/src/r_things.cpp b/src/r_things.cpp index 7b945a44c..0e1fbef56 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -258,7 +258,7 @@ double sprtopscreen; bool sprflipvert; -void R_DrawMaskedColumnBgra(FTexture *tex, fixed_t col, bool useRt, bool unmasked) +void R_DrawMaskedColumnBgra(FTexture *tex, fixed_t col, bool unmasked) { fixed_t saved_iscale = dc_iscale; // Save this because we need to modify it for mipmaps @@ -374,12 +374,12 @@ void R_DrawMaskedColumnBgra(FTexture *tex, fixed_t col, bool useRt, bool unmaske dc_iscale = saved_iscale; } -void R_DrawMaskedColumn (FTexture *tex, fixed_t col, bool useRt, bool unmasked) +void R_DrawMaskedColumn (FTexture *tex, fixed_t col, bool unmasked) { // Handle the linear filtered version in a different function to reduce chances of merge conflicts from zdoom. - if (r_swtruecolor && !drawer_needs_pal_input && !useRt) // To do: add support to R_DrawColumnHoriz_rgba + if (r_swtruecolor && !drawer_needs_pal_input) // To do: add support to R_DrawColumnHoriz_rgba { - R_DrawMaskedColumnBgra(tex, col, useRt, unmasked); + R_DrawMaskedColumnBgra(tex, col, unmasked); return; } @@ -669,14 +669,14 @@ void R_DrawWallSprite(vissprite_t *spr) R_SetColorMapLight(usecolormap, rw_light, shade); } if (!R_ClipSpriteColumnWithPortals(spr)) - R_WallSpriteColumn(false); + R_WallSpriteColumn(); dc_x++; } } R_FinishSetPatchStyle(); } -void R_WallSpriteColumn (bool useRt) +void R_WallSpriteColumn () { float iscale = swall[dc_x] * MaskedScaleY; dc_iscale = FLOAT2FIXED(iscale); @@ -687,7 +687,7 @@ void R_WallSpriteColumn (bool useRt) sprtopscreen = CenterY - dc_texturemid * spryscale; dc_texturefrac = 0; - R_DrawMaskedColumn(WallSpriteTile, lwall[dc_x], useRt); + R_DrawMaskedColumn(WallSpriteTile, lwall[dc_x]); rw_light += rw_lightstep; } diff --git a/src/r_things.h b/src/r_things.h index 657be32c5..ac8345c70 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -129,8 +129,8 @@ extern double pspriteyscale; extern FTexture *WallSpriteTile; -void R_DrawMaskedColumn (FTexture *texture, fixed_t column, bool useRt, bool unmasked = false); -void R_WallSpriteColumn (bool useRt); +void R_DrawMaskedColumn (FTexture *texture, fixed_t column, bool unmasked = false); +void R_WallSpriteColumn (); void R_CacheSprite (spritedef_t *sprite); void R_SortVisSprites (int (*compare)(const void *, const void *), size_t first); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index df5dd5cf0..1b23d5566 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -281,7 +281,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) while (dc_x < x2_i) { - R_DrawMaskedColumn(img, frac, false, !parms.masked); + R_DrawMaskedColumn(img, frac, !parms.masked); dc_x++; frac += xiscale_i; } From 5ec989d563b3baed133d1a84580d82be8dcab965 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 25 Dec 2016 08:08:01 +0100 Subject: [PATCH 1491/1509] Make particles always square --- src/r_things.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 0e1fbef56..4e63372e2 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2567,7 +2567,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, if (x1 >= x2) return; - yscale = YaspectMul * xscale; + yscale = xscale; // YaspectMul is not needed for particles as they should always be square ty = particle->Pos.Z - ViewPos.Z; y1 = xs_RoundToInt(CenterY - (ty + psize) * yscale); y2 = xs_RoundToInt(CenterY - (ty - psize) * yscale); From 66b9e2208d827908fced4cc4810464f48d2a6a34 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 25 Dec 2016 11:07:50 +0100 Subject: [PATCH 1492/1509] Draw a rect where the voxels would be --- src/CMakeLists.txt | 1 + src/r_things.cpp | 9 ++-- src/r_things.h | 5 -- src/r_voxel.cpp | 124 +++++++++++++++++++++++++++++++++++++++++++++ src/r_voxel.h | 31 ++++++++++++ 5 files changed, 161 insertions(+), 9 deletions(-) create mode 100644 src/r_voxel.cpp create mode 100644 src/r_voxel.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ede6c9a52..2fb046924 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -826,6 +826,7 @@ set( FASTMATH_PCH_SOURCES r_segs.cpp r_sky.cpp r_things.cpp + r_voxel.cpp r_walldraw.cpp s_advsound.cpp s_environment.cpp diff --git a/src/r_things.cpp b/src/r_things.cpp index 4e63372e2..472ecc8ea 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -65,6 +65,7 @@ #include "r_data/voxels.h" #include "p_local.h" #include "p_maputl.h" +#include "r_voxel.h" EXTERN_CVAR(Bool, st_scale) EXTERN_CVAR(Bool, r_shadercolormaps) @@ -691,9 +692,9 @@ void R_WallSpriteColumn () rw_light += rw_lightstep; } +#if 0 void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop, short *clipbot) { -#if 0 int flags = 0; // Do setup for blending. @@ -761,8 +762,8 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop R_FinishSetPatchStyle(); NetUpdate(); -#endif } +#endif // // R_ProjectSprite @@ -2842,12 +2843,12 @@ inline int sgn(int v) return v < 0 ? -1 : v > 0 ? 1 : 0; } +#if 0 void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, const FVector3 &dasprpos, DAngle dasprang, fixed_t daxscale, fixed_t dayscale, FVoxel *voxobj, FSWColormap *colormap, int colormapnum, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags) { -#if 0 int i, j, k, x, y, syoff, ggxstart, ggystart, nxoff; fixed_t cosang, sinang, sprcosang, sprsinang; int backx, backy, gxinc, gyinc; @@ -3175,8 +3176,8 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, } } } -#endif } +#endif //========================================================================== // diff --git a/src/r_things.h b/src/r_things.h index ac8345c70..2fa8786a9 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -144,11 +144,6 @@ void R_CheckOffscreenBuffer(int width, int height, bool spansonly); enum { DVF_OFFSCREEN = 1, DVF_SPANSONLY = 2, DVF_MIRRORED = 4 }; -void R_DrawVoxel(const FVector3 &viewpos, FAngle viewangle, - const FVector3 &sprpos, DAngle dasprang, - fixed_t daxscale, fixed_t dayscale, struct FVoxel *voxobj, - FSWColormap *colormap, int colormapnum, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags); - void R_ClipVisSprite (vissprite_t *vis, int xl, int xh); } diff --git a/src/r_voxel.cpp b/src/r_voxel.cpp new file mode 100644 index 000000000..115ff610c --- /dev/null +++ b/src/r_voxel.cpp @@ -0,0 +1,124 @@ +/* +** Voxel rendering +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include +#include "templates.h" +#include "doomdef.h" +#include "sbar.h" +#include "r_data/r_translate.h" +#include "r_data/colormaps.h" +#include "r_data/voxels.h" +#include "r_data/sprites.h" +#include "d_net.h" +#include "po_man.h" +#include "r_things.h" +#include "r_draw.h" +#include "r_thread.h" +#include "r_utility.h" +#include "r_main.h" +#include "r_voxel.h" + +namespace swrenderer +{ + void R_DrawVisVoxel(vissprite_t *sprite, int minZ, int maxZ, short *cliptop, short *clipbottom) + { + R_SetColorMapLight(sprite->Style.BaseColormap, 0, sprite->Style.ColormapNum << FRACBITS); + bool visible = R_SetPatchStyle(sprite->Style.RenderStyle, sprite->Style.Alpha, sprite->Translation, sprite->FillColor); + if (!visible) + return; + + FVector3 view_origin = sprite->pa.vpos; + FAngle view_angle = sprite->pa.vang; + DVector3 sprite_origin = { sprite->gpos.X, sprite->gpos.Y, sprite->gpos.Z }; + DAngle sprite_angle = sprite->Angle; + double sprite_xscale = FIXED2DBL(sprite->xscale); + double sprite_yscale = sprite->yscale; + FVoxel *voxel = sprite->voxel; + + int miplevel = 0;//voxel->NumMips; + const FVoxelMipLevel &mip = voxel->Mips[miplevel]; + if (mip.SlabData == nullptr) + return; + + /* + double spriteSin = sprite_angle.Sin(); + double spriteCos = sprite_angle.Cos(); + double pivotX = (mip.Pivot.X * spriteSin - mip.Pivot.Y * spriteCos); + double pivotY = (mip.Pivot.X * spriteCos + mip.Pivot.Y * spriteSin); + double pivotZ = -mip.Pivot.Z; + */ + + R_FillBox(sprite_origin, 5.0 * sprite_xscale, 5.0 * sprite_yscale, 16, cliptop, clipbottom, false, false); + } + + void R_FillBox(DVector3 origin, double extentX, double extentY, int color, short *cliptop, short *clipbottom, bool viewspace, bool pixelstretch) + { + double viewX, viewY, viewZ; + if (viewspace) + { + viewX = origin.X; + viewY = origin.Y; + viewZ = origin.Z; + } + else // world space + { + double translatedX = origin.X - ViewPos.X; + double translatedY = origin.Y - ViewPos.Y; + double translatedZ = origin.Z - ViewPos.Z; + viewX = translatedX * ViewSin - translatedY * ViewCos; + viewY = translatedZ; + viewZ = translatedX * ViewTanCos + translatedY * ViewTanSin; + } + + if (viewZ < 0.01f) + return; + + double screenX = CenterX + viewX / viewZ * CenterX; + double screenY = CenterY - viewY / viewZ * InvZtoScale; + double screenExtentX = extentX / viewZ * CenterX; + double screenExtentY = pixelstretch ? screenExtentX * YaspectMul : screenExtentX; + + int x1 = MAX((int)(screenX - screenExtentX), 0); + int x2 = MIN((int)(screenX + screenExtentX + 0.5f), viewwidth - 1); + int y1 = MAX((int)(screenY - screenExtentY), 0); + int y2 = MIN((int)(screenY + screenExtentY + 0.5f), viewheight - 1); + + int pixelsize = r_swtruecolor ? 4 : 1; + + if (y1 < y2) + { + for (int x = x1; x < x2; x++) + { + int columnY1 = MAX(y1, (int)cliptop[x]); + int columnY2 = MIN(y2, (int)clipbottom[x]); + if (columnY1 < columnY2) + { + using namespace drawerargs; + dc_dest = dc_destorg + (dc_pitch * columnY1 + x) * pixelsize; + dc_color = color; + dc_count = columnY2 - columnY1; + R_FillColumn(); + } + } + } + } +} diff --git a/src/r_voxel.h b/src/r_voxel.h new file mode 100644 index 000000000..159e26f6e --- /dev/null +++ b/src/r_voxel.h @@ -0,0 +1,31 @@ +/* +** Voxel rendering +** Copyright (c) 2016 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#pragma once + +namespace swrenderer +{ + struct vissprite_t; + + void R_DrawVisVoxel(vissprite_t *sprite, int minZ, int maxZ, short *cliptop, short *clipbottom); + void R_FillBox(DVector3 origin, double extentX, double extentY, int color, short *cliptop, short *clipbottom, bool viewspace, bool pixelstretch); +} From ad2993950a525fd5ef742c77d1deb563b72e9511 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Dec 2016 12:58:29 +0100 Subject: [PATCH 1493/1509] - fixed light level calculation for low light levels. --- src/gl/renderer/gl_lightdata.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 25ad12344..ca2d32c41 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -196,14 +196,30 @@ int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon) if ((glset.lightmode & 2) && lightlevel < 192 && !weapon) { - light = xs_CRoundToInt(192.f - (192-lightlevel)* 1.95f); + if (lightlevel > 100) + { + light = xs_CRoundToInt(192.f - (192 - lightlevel)* 1.87f); + if (light + rellight < 20) + { + light = 20 + (light + rellight - 20) / 5; + } + else + { + light += rellight; + } + } + else + { + light = (lightlevel + rellight) / 5; + } + } else { - light=lightlevel; + light=lightlevel+rellight; } - return clamp(light+rellight, 0, 255); + return clamp(light, 0, 255); } //========================================================================== From 2901e2d8342d8e76a6af641298636536735409a1 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 25 Dec 2016 17:43:13 +0200 Subject: [PATCH 1494/1509] Added missing Intel intrinsics #include --- src/r_draw_pal.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index a6b6a7946..f700be7e2 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -33,6 +33,7 @@ ** */ +#include #include "templates.h" #include "doomtype.h" #include "doomdef.h" From c5d75c18b419b962e3868b8a2dda138909dc9d07 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Dec 2016 22:56:18 +0100 Subject: [PATCH 1495/1509] - make gl_finishbeforeswap more useful by handling the case where it causes stalls on NVidia. --- src/gl/scene/gl_scene.cpp | 2 ++ src/gl/system/gl_framebuffer.cpp | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 5b969d7b9..5cca167d3 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -91,6 +91,7 @@ extern bool r_showviewer; DWORD gl_fixedcolormap; area_t in_area; TArray currentmapsection; +int camtexcount; void gl_ParseDefs(); @@ -1356,6 +1357,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in } tex->SetUpdated(); + camtexcount++; } //========================================================================== diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index f20c9e502..6d4fdcff8 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -207,22 +207,25 @@ void OpenGLFrameBuffer::Update() // //========================================================================== -CVAR(Bool, gl_finishbeforeswap, false, 0); +CVAR(Bool, gl_finishbeforeswap, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +extern int camtexcount; void OpenGLFrameBuffer::Swap() { + bool swapbefore = gl_finishbeforeswap && camtexcount == 0; Finish.Reset(); Finish.Clock(); - if (gl_finishbeforeswap) glFinish(); + if (swapbefore) glFinish(); if (needsetgamma) { //DoSetGamma(); needsetgamma = false; } SwapBuffers(); - if (!gl_finishbeforeswap) glFinish(); + if (!swapbefore) glFinish(); Finish.Unclock(); swapped = true; + camtexcount = 0; FHardwareTexture::UnbindAll(); mDebug->Update(); } From 6f16597668f2335ada5008225b8ad5afdd504cec Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Mon, 26 Dec 2016 00:23:05 +0200 Subject: [PATCH 1496/1509] GL renderer now uses RenderRadius links too --- src/gl/scene/gl_bsp.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index f0ddfd642..85cd35bf5 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -363,20 +363,26 @@ static inline void RenderThings(subsector_t * sub, sector_t * sector) SetupSprite.Clock(); sector_t * sec=sub->sector; // Handle all things in sector. - for (AActor * thing = sec->thinglist; thing; thing = thing->snext) + if (sec->touching_render_things) { - FIntCVar *cvar = thing->GetClass()->distancecheck; - if (cvar != NULL && *cvar >= 0) + for (auto thing : *sec->touching_render_things) { - double dist = (thing->Pos() - ViewPos).LengthSquared(); - double check = (double)**cvar; - if (dist >= check * check) - { - continue; - } - } + if (thing->validcount == validcount) continue; + thing->validcount = validcount; - GLRenderer->ProcessSprite(thing, sector, false); + FIntCVar *cvar = thing->GetClass()->distancecheck; + if (cvar != NULL && *cvar >= 0) + { + double dist = (thing->Pos() - ViewPos).LengthSquared(); + double check = (double)**cvar; + if (dist >= check * check) + { + continue; + } + } + + GLRenderer->ProcessSprite(thing, sector, false); + } } for (msecnode_t *node = sec->render_thinglist; node; node = node->m_snext) { From 100b80143a109f0422bab7912d79d9fa15f74c2b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 26 Dec 2016 05:09:01 +0100 Subject: [PATCH 1497/1509] Add basic voxel drawing showing how to use the input data structures --- src/r_voxel.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++----- src/r_voxel.h | 5 +++++ 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/src/r_voxel.cpp b/src/r_voxel.cpp index 115ff610c..dad4fed16 100644 --- a/src/r_voxel.cpp +++ b/src/r_voxel.cpp @@ -54,20 +54,68 @@ namespace swrenderer double sprite_yscale = sprite->yscale; FVoxel *voxel = sprite->voxel; + // To do: calculate the mipmap level based on distance, sprite scale and voxel extents int miplevel = 0;//voxel->NumMips; + const FVoxelMipLevel &mip = voxel->Mips[miplevel]; if (mip.SlabData == nullptr) return; - /* double spriteSin = sprite_angle.Sin(); double spriteCos = sprite_angle.Cos(); - double pivotX = (mip.Pivot.X * spriteSin - mip.Pivot.Y * spriteCos); - double pivotY = (mip.Pivot.X * spriteCos + mip.Pivot.Y * spriteSin); - double pivotZ = -mip.Pivot.Z; - */ + + DVector2 dirX(spriteSin * sprite_xscale, -spriteCos * sprite_xscale); + DVector2 dirY(spriteCos * sprite_xscale, spriteSin * sprite_xscale); + float dirZ = -sprite_yscale; + + DVector3 voxel_origin = sprite_origin; + voxel_origin.X -= dirX.X * mip.Pivot.X + dirX.Y * mip.Pivot.Y; + voxel_origin.Y -= dirY.X * mip.Pivot.X + dirY.Y * mip.Pivot.Y; + voxel_origin.Z -= dirZ * mip.Pivot.Z; + + // To do: do this loop sorted back to front: + + for (int x = 0; x < mip.SizeX; x++) + { + for (int y = 0; y < mip.SizeY; y++) + { + kvxslab_t *slab_start = R_GetSlabStart(mip, x, y); + kvxslab_t *slab_end = R_GetSlabEnd(mip, x, y); + + for (kvxslab_t *slab = slab_start; slab != slab_end; slab = R_NextSlab(slab)) + { + // To do: check slab->backfacecull + + for (int i = 0; i < slab->zleng; i++) + { + int z = slab->ztop + i; + uint8_t color = slab->col[i]; + + DVector3 voxel_pos = voxel_origin; + voxel_pos.X += dirX.X * x + dirX.Y * y; + voxel_pos.Y += dirY.X * x + dirY.Y * y; + voxel_pos.Z += dirZ * z; + + R_FillBox(voxel_pos, sprite_xscale, sprite_yscale, color, cliptop, clipbottom, false, false); + } + } + } + } + } + + kvxslab_t *R_GetSlabStart(const FVoxelMipLevel &mip, int x, int y) + { + return (kvxslab_t *)&mip.SlabData[mip.OffsetX[x] + (int)mip.OffsetXY[x * (mip.SizeY + 1) + y]]; + } - R_FillBox(sprite_origin, 5.0 * sprite_xscale, 5.0 * sprite_yscale, 16, cliptop, clipbottom, false, false); + kvxslab_t *R_GetSlabEnd(const FVoxelMipLevel &mip, int x, int y) + { + return R_GetSlabStart(mip, x, y + 1); + } + + kvxslab_t *R_NextSlab(kvxslab_t *slab) + { + return (kvxslab_t*)(((uint8_t*)slab) + 3 + slab->zleng); } void R_FillBox(DVector3 origin, double extentX, double extentY, int color, short *cliptop, short *clipbottom, bool viewspace, bool pixelstretch) diff --git a/src/r_voxel.h b/src/r_voxel.h index 159e26f6e..4c1e3f0af 100644 --- a/src/r_voxel.h +++ b/src/r_voxel.h @@ -22,10 +22,15 @@ #pragma once +struct kvxslab_t; + namespace swrenderer { struct vissprite_t; void R_DrawVisVoxel(vissprite_t *sprite, int minZ, int maxZ, short *cliptop, short *clipbottom); void R_FillBox(DVector3 origin, double extentX, double extentY, int color, short *cliptop, short *clipbottom, bool viewspace, bool pixelstretch); + kvxslab_t *R_GetSlabStart(const FVoxelMipLevel &mip, int x, int y); + kvxslab_t *R_GetSlabEnd(const FVoxelMipLevel &mip, int x, int y); + kvxslab_t *R_NextSlab(kvxslab_t *slab); } From f5883d3f86364706bb8649d8718276f1490c9a3e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 26 Dec 2016 12:02:09 +0100 Subject: [PATCH 1498/1509] - fixed: DynamicLight needs a render radius of -1 so that it gets excluded from the touching_renderlist. --- wadsrc/static/zscript/shared/dynlights.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/zscript/shared/dynlights.txt b/wadsrc/static/zscript/shared/dynlights.txt index 578354130..f851d88d0 100644 --- a/wadsrc/static/zscript/shared/dynlights.txt +++ b/wadsrc/static/zscript/shared/dynlights.txt @@ -5,6 +5,7 @@ class DynamicLight : Actor native Height 0; Radius 0.1; FloatBobPhase 0; + RenderRadius -1; +NOBLOCKMAP +NOGRAVITY +FIXMAPTHINGPOS From be508bc6700b559823d21082f8608cc9a33a9c91 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 26 Dec 2016 12:11:55 +0100 Subject: [PATCH 1499/1509] - adjust to using msecnode_t's. --- src/gl/scene/gl_bsp.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index 85cd35bf5..9e5ea258d 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -363,27 +363,26 @@ static inline void RenderThings(subsector_t * sub, sector_t * sector) SetupSprite.Clock(); sector_t * sec=sub->sector; // Handle all things in sector. - if (sec->touching_render_things) + for (auto p = sec->touching_renderthings; p != nullptr; p = p->m_snext) { - for (auto thing : *sec->touching_render_things) + auto thing = p->m_thing; + if (thing->validcount == validcount) continue; + thing->validcount = validcount; + + FIntCVar *cvar = thing->GetClass()->distancecheck; + if (cvar != NULL && *cvar >= 0) { - if (thing->validcount == validcount) continue; - thing->validcount = validcount; - - FIntCVar *cvar = thing->GetClass()->distancecheck; - if (cvar != NULL && *cvar >= 0) + double dist = (thing->Pos() - ViewPos).LengthSquared(); + double check = (double)**cvar; + if (dist >= check * check) { - double dist = (thing->Pos() - ViewPos).LengthSquared(); - double check = (double)**cvar; - if (dist >= check * check) - { - continue; - } + continue; } - - GLRenderer->ProcessSprite(thing, sector, false); } + + GLRenderer->ProcessSprite(thing, sector, false); } + for (msecnode_t *node = sec->render_thinglist; node; node = node->m_snext) { AActor *thing = node->m_thing; From 5d6d75385e7170f4f1a3216be913a04d2328e82d Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 26 Dec 2016 07:41:52 -0500 Subject: [PATCH 1500/1509] - pulled some things out of the loop for the fill drawer --- src/r_draw_pal.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index f700be7e2..15846977d 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -1495,11 +1495,11 @@ namespace swrenderer } else { + int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; + int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; + int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; do { - int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; - int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; - int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; int r = clamp((src_r + pal[*dest].r * _destalpha)>>18, 0, 255); int g = clamp((src_g + pal[*dest].g * _destalpha)>>18, 0, 255); int b = clamp((src_b + pal[*dest].b * _destalpha)>>18, 0, 255); @@ -1551,11 +1551,11 @@ namespace swrenderer } else { + int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; + int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; + int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; do { - int src_r = ((_srccolor >> 16) & 0xff) * _srcalpha; - int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; - int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; int r = clamp((src_r + pal[*dest].r * _destalpha)>>18, 0, 255); int g = clamp((src_g + pal[*dest].g * _destalpha)>>18, 0, 255); int b = clamp((src_b + pal[*dest].b * _destalpha)>>18, 0, 255); From 80228562b346934b201e54e916637182be361bbc Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 26 Dec 2016 08:05:04 -0500 Subject: [PATCH 1501/1509] - Fixed problems with FillSub and FillRevSub drawers. --- src/r_draw_pal.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 15846977d..90dcc9c3b 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -1610,9 +1610,9 @@ namespace swrenderer int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; int bg = *dest; - int r = MAX((src_r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((src_g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((src_b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + int r = MAX((-src_r + palette[bg].r * _destalpha)>>18, 0); + int g = MAX((-src_g + palette[bg].g * _destalpha)>>18, 0); + int b = MAX((-src_b + palette[bg].b * _destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; dest += pitch; @@ -1667,9 +1667,9 @@ namespace swrenderer int src_g = ((_srccolor >> 0) & 0xff) * _srcalpha; int src_b = ((_srccolor >> 8) & 0xff) * _srcalpha; int bg = *dest; - int r = MAX((src_r * _srcalpha - palette[bg].r * _destalpha)>>18, 0); - int g = MAX((src_g * _srcalpha - palette[bg].g * _destalpha)>>18, 0); - int b = MAX((src_b * _srcalpha - palette[bg].b * _destalpha)>>18, 0); + int r = MAX((src_r - palette[bg].r * _destalpha)>>18, 0); + int g = MAX((src_g - palette[bg].g * _destalpha)>>18, 0); + int b = MAX((src_b - palette[bg].b * _destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; dest += pitch; From 470a96d3b21c488abba44b94df1fa14e845a86fd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Dec 2016 19:19:49 +0100 Subject: [PATCH 1502/1509] - fixed: non-damaging attacks should not cause infighting, unless some relevant pain flags are being set. --- src/c_console.cpp | 2 +- src/p_interaction.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c_console.cpp b/src/c_console.cpp index f3b91efde..0e9b94996 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -1577,7 +1577,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer) static TArray command; const size_t length = buffer.Text.Len(); - command.Resize(length + 1); + command.Resize(unsigned(length + 1)); memcpy(&command[0], buffer.Text.GetChars(), length); command[length] = '\0'; diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 9aa178e64..102142d38 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1545,7 +1545,7 @@ dopain: target->SetState (target->SeeState); } } - else if (source != target->target && target->OkayToSwitchTarget (source)) + else if ((damage > 0 || fakedPain) && source != target->target && target->OkayToSwitchTarget (source)) { // Target actor is not intent on another actor, // so make him chase after source From 3fe3abc51e100e804410280be64bf5fe9c132d94 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 26 Dec 2016 15:59:44 +0200 Subject: [PATCH 1503/1509] Fixed endianness issue in script VM See https://forum.zdoom.org/viewtopic.php?t=54549 --- src/scripting/vm/vm.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h index 1869c410b..fdf5f3c9f 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -21,27 +21,35 @@ typedef VM_UBYTE VM_ATAG; #define VM_EPSILON (1/65536.0) +#ifdef __BIG_ENDIAN__ +#define VM_DEFINE_OP2(TYPE, ARG1, ARG2) TYPE ARG2, ARG1 +#define VM_DEFINE_OP4(TYPE, ARG1, ARG2, ARG3, ARG4) TYPE ARG4, ARG3, ARG2, ARG1 +#else // little endian +#define VM_DEFINE_OP2(TYPE, ARG1, ARG2) TYPE ARG1, ARG2 +#define VM_DEFINE_OP4(TYPE, ARG1, ARG2, ARG3, ARG4) TYPE ARG1, ARG2, ARG3, ARG4 +#endif // __BIG_ENDIAN__ + union VMOP { struct { - VM_UBYTE op, a, b, c; + VM_DEFINE_OP4(VM_UBYTE, op, a, b, c); }; struct { - VM_SBYTE pad0, as, bs, cs; + VM_DEFINE_OP4(VM_SBYTE, pad0, as, bs, cs); }; struct { - VM_SWORD pad1:8, i24:24; + VM_DEFINE_OP2(VM_SWORD, pad1:8, i24:24); }; struct { - VM_SWORD pad2:16, i16:16; + VM_DEFINE_OP2(VM_SWORD, pad2:16, i16:16); }; struct { - VM_UHALF pad3, i16u; + VM_DEFINE_OP2(VM_UHALF, pad3, i16u); }; VM_UWORD word; @@ -56,6 +64,9 @@ union VMOP // sar eax,10h }; +#undef VM_DEFINE_OP4 +#undef VM_DEFINE_OP2 + enum { #include "vmops.h" From 3f7c057f9207fed87ffff41123c745cd8846d132 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Mon, 26 Dec 2016 10:39:03 +0100 Subject: [PATCH 1504/1509] - Fixed heap use after free issue with lights. --- src/gl/dynlights/a_dynlight.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 4ba95af87..114633b3f 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -599,7 +599,6 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &opos, subsector_t *subSe for (unsigned i = 0; i < collected_ss.Size(); i++) { subSec = collected_ss[i].sub; - auto &pos = collected_ss[i].pos; touching_subsectors = AddLightNode(&subSec->lighthead, subSec, this, touching_subsectors); if (subSec->sector->validcount != ::validcount) @@ -608,9 +607,10 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &opos, subsector_t *subSe subSec->sector->validcount = ::validcount; } - for (unsigned int i = 0; i < subSec->numlines; i++) + for (unsigned int j = 0; j < subSec->numlines; ++j) { - seg_t * seg = subSec->firstline + i; + auto &pos = collected_ss[i].pos; + seg_t *seg = subSec->firstline + j; // check distance from x/y to seg and if within radius add this seg and, if present the opposing subsector (lather/rinse/repeat) // If out of range we do not need to bother with this seg. From 53270554951a3b97d65b96b12ce444833c6dd614 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 26 Dec 2016 20:37:04 +0100 Subject: [PATCH 1505/1509] - fixed: Source for nailbomb damage in A_Explode should be the caller's target, if defined and the caller is a missile. --- src/p_actionfunctions.cpp | 4 ++-- src/p_local.h | 1 + src/p_map.cpp | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 4136ec331..5bf5bf450 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -1286,9 +1286,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_Explode) { ang = i*360./nails; // Comparing the results of a test wad with Eternity, it seems A_NailBomb does not aim - P_LineAttack (self, ang, MISSILERANGE, 0., + P_LineAttack(self, ang, MISSILERANGE, 0., //P_AimLineAttack (self, ang, MISSILERANGE), - naildamage, NAME_Hitscan, pufftype); + naildamage, NAME_Hitscan, pufftype, (self->flags & MF_MISSILE) ? LAF_TARGETISSOURCE : 0); } } diff --git a/src/p_local.h b/src/p_local.h index 93bbbbf11..41f980d44 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -323,6 +323,7 @@ enum // P_LineAttack flags LAF_NORANDOMPUFFZ = 2, LAF_NOIMPACTDECAL = 4, LAF_NOINTERACT = 8, + LAF_TARGETISSOURCE = 16, }; AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, DAngle pitch, int damage, FName damageType, PClassActor *pufftype, int flags = 0, FTranslatedLineTarget *victim = NULL, int *actualdamage = NULL); diff --git a/src/p_map.cpp b/src/p_map.cpp index 85c3e3da8..560b39de6 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4476,7 +4476,9 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, puff = P_SpawnPuff(t1, pufftype, bleedpos, 0., 0., 2, puffFlags | PF_HITTHING | PF_TEMPORARY); killPuff = true; } - newdam = P_DamageMobj(trace.Actor, puff ? puff : t1, t1, damage, damageType, dmgflags|DMG_USEANGLE, trace.SrcAngleFromTarget); + auto src = t1; + if ((flags & LAF_TARGETISSOURCE) && t1 && t1->target) src = t1->target; + newdam = P_DamageMobj(trace.Actor, puff ? puff : t1, src, damage, damageType, dmgflags|DMG_USEANGLE, trace.SrcAngleFromTarget); if (actualdamage != NULL) { *actualdamage = newdam; From 58316c821d42bd0315230447e611d73e42e8ac6e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 26 Dec 2016 21:07:21 +0100 Subject: [PATCH 1506/1509] - fixed: The pitch shifting info for sounds needs to be taken from the sfxinfo currently being played, not the one it links to. --- src/s_sound.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/s_sound.cpp b/src/s_sound.cpp index fd15b9491..be1b572f1 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -917,6 +917,7 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO // the referenced sound so some additional checks are required int near_limit = sfx->NearLimit; float limit_range = sfx->LimitRange; + auto pitchmask = sfx->PitchMask; rolloff = &sfx->Rolloff; // Resolve player sounds, random sounds, and aliases @@ -1081,9 +1082,9 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO } // Vary the sfx pitches. - if (sfx->PitchMask != 0) + if (pitchmask != 0) { - pitch = NORM_PITCH - (M_Random() & sfx->PitchMask) + (M_Random() & sfx->PitchMask); + pitch = NORM_PITCH - (M_Random() & pitchmask) + (M_Random() & pitchmask); } else { From e9574276a559ff7bf0d0043e3531c3c819ae4c30 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 26 Dec 2016 22:33:07 +0100 Subject: [PATCH 1507/1509] - added CanCollideWith calls to a few more places where they are needed. --- src/p_map.cpp | 111 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 36 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 560b39de6..913840e59 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -82,6 +82,56 @@ static FRandom pr_crunch("DoCrunch"); TArray spechit; TArray portalhit; + +//========================================================================== +// +// CanCollideWith +// +// Checks if an actor can collide with another one, calling virtual script functions to check. +// +//========================================================================== + +DEFINE_ACTION_FUNCTION(AActor, CanCollideWith) +{ + // No need to check the parameters, as they are not even used. + ACTION_RETURN_BOOL(true); +} + +bool P_CanCollideWith(AActor *tmthing, AActor *thing) +{ + static unsigned VIndex = ~0u; + if (VIndex == ~0u) + { + VIndex = GetVirtualIndex(RUNTIME_CLASS(AActor), "CanCollideWith"); + assert(VIndex != ~0u); + } + + VMValue params[3] = { tmthing, thing, false }; + VMReturn ret; + int retval; + ret.IntAt(&retval); + + auto clss = tmthing->GetClass(); + VMFunction *func = clss->Virtuals.Size() > VIndex ? clss->Virtuals[VIndex] : nullptr; + if (func != nullptr) + { + GlobalVMStack.Call(func, params, 3, &ret, 1, nullptr); + if (!retval) return false; + } + std::swap(params[0].a, params[1].a); + params[2].i = true; + + // re-get for the other actor. + clss = thing->GetClass(); + func = clss->Virtuals.Size() > VIndex ? clss->Virtuals[VIndex] : nullptr; + if (func != nullptr) + { + GlobalVMStack.Call(func, params, 3, &ret, 1, nullptr); + if (!retval) return false; + } + return true; +} + //========================================================================== // // FindRefPoint @@ -402,6 +452,9 @@ bool P_TeleportMove(AActor* thing, const DVector3 &pos, bool telefrag, bool modi } } + if (!P_CanCollideWith(tmf.thing, th)) + continue; + // monsters don't stomp things except on boss level // [RH] Some Heretic/Hexen monsters can telestomp // ... and some items can never be telefragged while others will be telefragged by everything that teleports upon them. @@ -1147,12 +1200,6 @@ static bool CanAttackHurt(AActor *victim, AActor *shooter) // //========================================================================== -DEFINE_ACTION_FUNCTION(AActor, CanCollideWith) -{ - // No need to check the parameters, as they are not even used. - ACTION_RETURN_BOOL(true); -} - bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::CheckResult &cres, const FBoundingBox &box, FCheckPosition &tm) { AActor *thing = cres.thing; @@ -1257,36 +1304,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch if (((thing->flags & MF_SOLID) || (thing->flags6 & (MF6_TOUCHY | MF6_BUMPSPECIAL))) && ((tm.thing->flags & (MF_SOLID|MF_MISSILE)) || (tm.thing->flags2 & MF2_BLASTED) || (tm.thing->flags6 & MF6_BLOCKEDBYSOLIDACTORS) || (tm.thing->BounceFlags & BOUNCE_MBF))) { - static unsigned VIndex = ~0u; - if (VIndex == ~0u) - { - VIndex = GetVirtualIndex(RUNTIME_CLASS(AActor), "CanCollideWith"); - assert(VIndex != ~0u); - } - - VMValue params[3] = { tm.thing, thing, false }; - VMReturn ret; - int retval; - ret.IntAt(&retval); - - auto clss = tm.thing->GetClass(); - VMFunction *func = clss->Virtuals.Size() > VIndex ? clss->Virtuals[VIndex] : nullptr; - if (func != nullptr) - { - GlobalVMStack.Call(func, params, 3, &ret, 1, nullptr); - if (!retval) return true; - } - std::swap(params[0].a, params[1].a); - params[2].i = true; - - // re-get for the other actor. - clss = thing->GetClass(); - func = clss->Virtuals.Size() > VIndex ? clss->Virtuals[VIndex] : nullptr; - if (func != nullptr) - { - GlobalVMStack.Call(func, params, 3, &ret, 1, nullptr); - if (!retval) return true; - } + if (!P_CanCollideWith(tm.thing, thing)) return true; } @@ -1959,6 +1977,12 @@ bool P_TestMobjZ(AActor *actor, bool quick, AActor **pOnmobj) { // something higher is in the way continue; } + else if (!P_CanCollideWith(actor, thing)) + { // If they cannot collide, they cannot block each other. + continue; + } + + onmobj = thing; if (quick) break; } @@ -5945,6 +5969,9 @@ int P_PushUp(AActor *thing, FChangePosition *cpos) continue; if ((thing->flags & MF_MISSILE) && (intersect->flags2 & MF2_REFLECTIVE) && (intersect->flags7 & MF7_THRUREFLECT)) continue; + if (!P_CanCollideWith(thing, intersect)) + continue; + if (!(intersect->flags2 & MF2_PASSMOBJ) || (!(intersect->flags3 & MF3_ISMONSTER) && intersect->Mass > mymass) || (intersect->flags4 & MF4_ACTLIKEBRIDGE) @@ -5991,6 +6018,18 @@ int P_PushDown(AActor *thing, FChangePosition *cpos) for (; firstintersect < lastintersect; firstintersect++) { AActor *intersect = intersectors[firstintersect]; + + // [GZ] Skip this iteration for THRUSPECIES things + // Should there be MF2_THRUGHOST / MF3_GHOST checks there too for consistency? + // Or would that risk breaking established behavior? THRUGHOST, like MTHRUSPECIES, + // is normally for projectiles which would have exploded by now anyway... + if (thing->flags6 & MF6_THRUSPECIES && thing->GetSpecies() == intersect->GetSpecies()) + continue; + if ((thing->flags & MF_MISSILE) && (intersect->flags2 & MF2_REFLECTIVE) && (intersect->flags7 & MF7_THRUREFLECT)) + continue; + if (!P_CanCollideWith(thing, intersect)) + continue; + if (!(intersect->flags2 & MF2_PASSMOBJ) || (!(intersect->flags3 & MF3_ISMONSTER) && intersect->Mass > mymass) || (intersect->flags4 & MF4_ACTLIKEBRIDGE) From 66b154a475bd9bf54d62859eed2ca894d712bdc8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 27 Dec 2016 03:07:50 +0100 Subject: [PATCH 1508/1509] Voxel mipmap selection --- src/r_voxel.cpp | 85 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 20 deletions(-) diff --git a/src/r_voxel.cpp b/src/r_voxel.cpp index dad4fed16..0f81124c7 100644 --- a/src/r_voxel.cpp +++ b/src/r_voxel.cpp @@ -46,21 +46,37 @@ namespace swrenderer if (!visible) return; - FVector3 view_origin = sprite->pa.vpos; + DVector3 view_origin = { sprite->pa.vpos.X, sprite->pa.vpos.Y, sprite->pa.vpos.Z }; FAngle view_angle = sprite->pa.vang; DVector3 sprite_origin = { sprite->gpos.X, sprite->gpos.Y, sprite->gpos.Z }; DAngle sprite_angle = sprite->Angle; double sprite_xscale = FIXED2DBL(sprite->xscale); double sprite_yscale = sprite->yscale; FVoxel *voxel = sprite->voxel; - - // To do: calculate the mipmap level based on distance, sprite scale and voxel extents - int miplevel = 0;//voxel->NumMips; + + // Select mipmap level: + + double viewSin = view_angle.Cos(); + double viewCos = view_angle.Sin(); + double logmip = fabs((view_origin.X - sprite_origin.X) * viewCos - (view_origin.Y - sprite_origin.Y) * viewSin); + int miplevel = 0; + while (miplevel < voxel->NumMips - 1 && logmip >= FocalLengthX) + { + logmip *= 0.5; + miplevel++; + } const FVoxelMipLevel &mip = voxel->Mips[miplevel]; if (mip.SlabData == nullptr) return; + minZ >>= miplevel; + maxZ >>= miplevel; + sprite_xscale *= (1 << miplevel); + sprite_yscale *= (1 << miplevel); + + // Find voxel cube eigenvectors and origin in world space: + double spriteSin = sprite_angle.Sin(); double spriteCos = sprite_angle.Cos(); @@ -73,30 +89,59 @@ namespace swrenderer voxel_origin.Y -= dirY.X * mip.Pivot.X + dirY.Y * mip.Pivot.Y; voxel_origin.Z -= dirZ * mip.Pivot.Z; - // To do: do this loop sorted back to front: + // Voxel cube walking directions: - for (int x = 0; x < mip.SizeX; x++) + int startX[4] = { 0, mip.SizeX - 1, 0, mip.SizeX - 1 }; + int startY[4] = { 0, 0, mip.SizeY - 1, mip.SizeY - 1 }; + int stepX[4] = { 1, -1, 1, -1 }; + int stepY[4] = { 1, 1, -1, -1 }; + + // The point in cube mipmap local space where voxel sides change from front to backfacing: + + double dx = (view_origin.X - sprite_origin.X) / sprite_xscale; + double dy = (view_origin.Y - sprite_origin.Y) / sprite_xscale; + int backX = (int)(dx * spriteCos - dy * spriteSin + mip.Pivot.X); + int backY = (int)(dy * spriteCos + dx * spriteSin + mip.Pivot.Y); + int endX = clamp(backX, 0, mip.SizeX - 1); + int endY = clamp(backY, 0, mip.SizeY - 1); + + // Draw the voxel cube: + + for (int index = 0; index < 4; index++) { - for (int y = 0; y < mip.SizeY; y++) + if ((stepX[index] < 0 && endX >= startX[index]) || + (stepX[index] > 0 && endX <= startX[index]) || + (stepY[index] < 0 && endY >= startY[index]) || + (stepY[index] > 0 && endY <= startY[index])) continue; + + for (int x = startX[index]; x != endX; x += stepX[index]) { - kvxslab_t *slab_start = R_GetSlabStart(mip, x, y); - kvxslab_t *slab_end = R_GetSlabEnd(mip, x, y); - - for (kvxslab_t *slab = slab_start; slab != slab_end; slab = R_NextSlab(slab)) + for (int y = startY[index]; y != endY; y += stepY[index]) { - // To do: check slab->backfacecull + kvxslab_t *slab_start = R_GetSlabStart(mip, x, y); + kvxslab_t *slab_end = R_GetSlabEnd(mip, x, y); - for (int i = 0; i < slab->zleng; i++) + for (kvxslab_t *slab = slab_start; slab != slab_end; slab = R_NextSlab(slab)) { - int z = slab->ztop + i; - uint8_t color = slab->col[i]; + // To do: check slab->backfacecull - DVector3 voxel_pos = voxel_origin; - voxel_pos.X += dirX.X * x + dirX.Y * y; - voxel_pos.Y += dirY.X * x + dirY.Y * y; - voxel_pos.Z += dirZ * z; + int ztop = slab->ztop; + int zbottom = ztop + slab->zleng; - R_FillBox(voxel_pos, sprite_xscale, sprite_yscale, color, cliptop, clipbottom, false, false); + //ztop = MAX(ztop, minZ); + //zbottom = MIN(zbottom, maxZ); + + for (int z = ztop; z < zbottom; z++) + { + uint8_t color = slab->col[z - slab->ztop]; + + DVector3 voxel_pos = voxel_origin; + voxel_pos.X += dirX.X * x + dirX.Y * y; + voxel_pos.Y += dirY.X * x + dirY.Y * y; + voxel_pos.Z += dirZ * z; + + R_FillBox(voxel_pos, sprite_xscale, sprite_yscale, color, cliptop, clipbottom, false, false); + } } } } From bafc985282a4d074034c45c3827884f3719fc798 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 27 Dec 2016 03:31:34 +0100 Subject: [PATCH 1509/1509] Fix pal particle performance issue --- src/r_draw_pal.cpp | 81 +++++++++++++++++++++++++++++ src/r_draw_pal.h | 16 ++++++ src/r_things.cpp | 125 ++++++++------------------------------------- src/r_things.h | 1 - 4 files changed, 119 insertions(+), 104 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 90dcc9c3b..fbe372fb8 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -3445,4 +3445,85 @@ namespace swrenderer dest[x] = colormap[dest[x]]; } while (++x <= x2); } + + ///////////////////////////////////////////////////////////////////////////// + + namespace + { + static uint32_t particle_texture[16 * 16] = + { + 1 * 1, 2 * 1, 3 * 1, 4 * 1, 5 * 1, 6 * 1, 7 * 1, 8 * 1, 8 * 1, 7 * 1, 6 * 1, 5 * 1, 4 * 1, 3 * 1, 2 * 1, 1 * 1, + 1 * 2, 2 * 2, 3 * 2, 4 * 2, 5 * 2, 6 * 2, 7 * 2, 8 * 2, 8 * 2, 7 * 2, 6 * 2, 5 * 2, 4 * 2, 3 * 2, 2 * 2, 1 * 2, + 1 * 3, 2 * 3, 3 * 3, 4 * 3, 5 * 3, 6 * 3, 7 * 3, 8 * 3, 8 * 3, 7 * 3, 6 * 3, 5 * 3, 4 * 3, 3 * 3, 2 * 3, 1 * 3, + 1 * 4, 2 * 4, 3 * 4, 4 * 4, 5 * 4, 6 * 4, 7 * 4, 8 * 4, 8 * 4, 7 * 4, 6 * 4, 5 * 4, 4 * 4, 3 * 4, 2 * 4, 1 * 4, + 1 * 5, 2 * 5, 3 * 5, 4 * 5, 5 * 5, 6 * 5, 7 * 5, 8 * 5, 8 * 5, 7 * 5, 6 * 5, 5 * 5, 4 * 5, 3 * 5, 2 * 5, 1 * 5, + 1 * 6, 2 * 6, 3 * 6, 4 * 6, 5 * 6, 6 * 6, 7 * 6, 8 * 6, 8 * 6, 7 * 6, 6 * 6, 5 * 6, 4 * 6, 3 * 6, 2 * 6, 1 * 6, + 1 * 7, 2 * 7, 3 * 7, 4 * 7, 5 * 7, 6 * 7, 7 * 7, 8 * 7, 8 * 7, 7 * 7, 6 * 7, 5 * 7, 4 * 7, 3 * 7, 2 * 7, 1 * 7, + 1 * 8, 2 * 8, 3 * 8, 4 * 8, 5 * 8, 6 * 8, 7 * 8, 8 * 8, 8 * 8, 7 * 8, 6 * 8, 5 * 8, 4 * 8, 3 * 8, 2 * 8, 1 * 8, + 1 * 8, 2 * 8, 3 * 8, 4 * 8, 5 * 8, 6 * 8, 7 * 8, 8 * 8, 8 * 8, 7 * 8, 6 * 8, 5 * 8, 4 * 8, 3 * 8, 2 * 8, 1 * 8, + 1 * 7, 2 * 7, 3 * 7, 4 * 7, 5 * 7, 6 * 7, 7 * 7, 8 * 7, 8 * 7, 7 * 7, 6 * 7, 5 * 7, 4 * 7, 3 * 7, 2 * 7, 1 * 7, + 1 * 6, 2 * 6, 3 * 6, 4 * 6, 5 * 6, 6 * 6, 7 * 6, 8 * 6, 8 * 6, 7 * 6, 6 * 6, 5 * 6, 4 * 6, 3 * 6, 2 * 6, 1 * 6, + 1 * 5, 2 * 5, 3 * 5, 4 * 5, 5 * 5, 6 * 5, 7 * 5, 8 * 5, 8 * 5, 7 * 5, 6 * 5, 5 * 5, 4 * 5, 3 * 5, 2 * 5, 1 * 5, + 1 * 4, 2 * 4, 3 * 4, 4 * 4, 5 * 4, 6 * 4, 7 * 4, 8 * 4, 8 * 4, 7 * 4, 6 * 4, 5 * 4, 4 * 4, 3 * 4, 2 * 4, 1 * 4, + 1 * 3, 2 * 3, 3 * 3, 4 * 3, 5 * 3, 6 * 3, 7 * 3, 8 * 3, 8 * 3, 7 * 3, 6 * 3, 5 * 3, 4 * 3, 3 * 3, 2 * 3, 1 * 3, + 1 * 2, 2 * 2, 3 * 2, 4 * 2, 5 * 2, 6 * 2, 7 * 2, 8 * 2, 8 * 2, 7 * 2, 6 * 2, 5 * 2, 4 * 2, 3 * 2, 2 * 2, 1 * 2, + 1 * 1, 2 * 1, 3 * 1, 4 * 1, 5 * 1, 6 * 1, 7 * 1, 8 * 1, 8 * 1, 7 * 1, 6 * 1, 5 * 1, 4 * 1, 3 * 1, 2 * 1, 1 * 1 + }; + } + + DrawParticleColumnPalCommand::DrawParticleColumnPalCommand(uint8_t *dest, int dest_y, int pitch, int count, uint32_t fg, uint32_t alpha, uint32_t fracposx) + { + _dest = dest; + _pitch = pitch; + _count = count; + _fg = fg; + _alpha = alpha; + _fracposx = fracposx; + _dest_y = dest_y; + } + + void DrawParticleColumnPalCommand::Execute(DrawerThread *thread) + { + int count = thread->count_for_thread(_dest_y, _count); + if (count <= 0) + return; + + uint8_t *dest = thread->dest_for_thread(_dest_y, _pitch, _dest); + int pitch = _pitch * thread->num_cores; + + const uint32_t *source = &particle_texture[(_fracposx >> FRACBITS) * 16]; + uint32_t particle_alpha = _alpha; + + uint32_t fracstep = 16 * FRACUNIT / _count; + uint32_t fracpos = fracstep * thread->skipped_by_thread(_dest_y) + fracstep / 2; + fracstep *= thread->num_cores; + + uint32_t fg_red = (_fg >> 16) & 0xff; + uint32_t fg_green = (_fg >> 8) & 0xff; + uint32_t fg_blue = _fg & 0xff; + + for (int y = 0; y < count; y++) + { + uint32_t alpha = (source[fracpos >> FRACBITS] * particle_alpha) >> 6; + uint32_t inv_alpha = 256 - alpha; + + int bg = *dest; + uint32_t bg_red = GPalette.BaseColors[bg].r; + uint32_t bg_green = GPalette.BaseColors[bg].g; + uint32_t bg_blue = GPalette.BaseColors[bg].b; + + uint32_t red = (fg_red * alpha + bg_red * inv_alpha) / 256; + uint32_t green = (fg_green * alpha + bg_green * inv_alpha) / 256; + uint32_t blue = (fg_blue * alpha + bg_blue * inv_alpha) / 256; + + *dest = RGB256k.All[((red >> 2) << 12) | ((green >> 2) << 6) | (blue >> 2)]; + dest += pitch; + fracpos += fracstep; + } + } + + FString DrawParticleColumnPalCommand::DebugInfo() + { + return "DrawParticle"; + } } diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index 5b901152c..79152665c 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -260,4 +260,20 @@ namespace swrenderer const uint8_t *_colormap; uint8_t *_destorg; }; + + class DrawParticleColumnPalCommand : public DrawerCommand + { + public: + DrawParticleColumnPalCommand(uint8_t *dest, int dest_y, int pitch, int count, uint32_t fg, uint32_t alpha, uint32_t fracposx); + void Execute(DrawerThread *thread) override; + FString DebugInfo() override; + + private: + uint8_t *_dest; + int _pitch; + int _count; + uint32_t _fg; + uint32_t _alpha; + uint32_t _fracposx; + }; } diff --git a/src/r_things.cpp b/src/r_things.cpp index 40fbf782a..b7883a242 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -59,6 +59,7 @@ #include "r_segs.h" #include "r_3dfloors.h" #include "r_draw_rgba.h" +#include "r_draw_pal.h" #include "v_palette.h" #include "r_data/r_translate.h" #include "r_data/colormaps.h" @@ -2712,105 +2713,9 @@ static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) } } -//inline int clamp(int x, int y, int z) { return ((x < y) ? x : (z < y) ? z : y); } - -void R_DrawParticle (vissprite_t *vis) -{ - if (r_swtruecolor) - return R_DrawParticle_rgba(vis); - - DWORD *bg2rgb; - int spacing; - BYTE *dest; - DWORD fg; - BYTE color = vis->Style.BaseColormap->Maps[(vis->Style.ColormapNum << COLORMAPSHIFT) + vis->startfrac]; - int yl = vis->y1; - int ycount = vis->y2 - yl + 1; - int x1 = vis->x1; - int countbase = vis->x2 - x1; - - R_DrawMaskedSegsBehindParticle (vis); - - DrawerCommandQueue::WaitForWorkers(); - - // vis->renderflags holds translucency level (0-255) - fixed_t fglevel, bglevel; - - { - DWORD *fg2rgb; - - fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff; - bglevel = FRACUNIT-fglevel; - fg2rgb = Col2RGB8[fglevel>>10]; - bg2rgb = Col2RGB8[bglevel>>10]; - fg = fg2rgb[color]; - } - - /* - - spacing = RenderTarget->GetPitch() - countbase; - dest = ylookup[yl] + x1 + dc_destorg; - - do - { - int count = countbase; - do - { - DWORD bg = bg2rgb[*dest]; - bg = (fg+bg) | 0x1f07c1f; - *dest++ = RGB32k.All[bg & (bg>>15)]; - } while (--count); - dest += spacing; - } while (--ycount);*/ - - // original was row-wise - // width = countbase - // height = ycount - - spacing = RenderTarget->GetPitch(); - - if (!r_blendmethod) - { - for (int x = x1; x < (x1+countbase); x++) - { - dc_x = x; - if (R_ClipSpriteColumnWithPortals(vis)) - continue; - dest = ylookup[yl] + x + dc_destorg; - for (int y = 0; y < ycount; y++) - { - DWORD bg = bg2rgb[*dest]; - bg = (fg+bg) | 0x1f07c1f; - *dest = RGB32k.All[bg & (bg>>15)]; - dest += spacing; - } - } - } - else - { - for (int x = x1; x < (x1+countbase); x++) - { - dc_x = x; - if (R_ClipSpriteColumnWithPortals(vis)) - continue; - dest = ylookup[yl] + x + dc_destorg; - for (int y = 0; y < ycount; y++) - { - uint32_t dest_r = MIN((GPalette.BaseColors[*dest].r * bglevel + GPalette.BaseColors[color].r * fglevel) >> 18, 63); - uint32_t dest_g = MIN((GPalette.BaseColors[*dest].g * bglevel + GPalette.BaseColors[color].g * fglevel) >> 18, 63); - uint32_t dest_b = MIN((GPalette.BaseColors[*dest].b * bglevel + GPalette.BaseColors[color].b * fglevel) >> 18, 63); - - *dest = RGB256k.RGB[dest_r][dest_g][dest_b]; - dest += spacing; - } - } - } -} - -void R_DrawParticle_rgba(vissprite_t *vis) +void R_DrawParticle(vissprite_t *vis) { int spacing; - uint32_t *dest; BYTE color = vis->Style.BaseColormap->Maps[vis->startfrac]; int yl = vis->y1; int ycount = vis->y2 - yl + 1; @@ -2833,13 +2738,27 @@ void R_DrawParticle_rgba(vissprite_t *vis) uint32_t fracstepx = 16 * FRACUNIT / countbase; uint32_t fracposx = fracstepx / 2; - for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx) + if (r_swtruecolor) { - dc_x = x; - if (R_ClipSpriteColumnWithPortals(vis)) - continue; - dest = ylookup[yl] + x + (uint32_t*)dc_destorg; - DrawerCommandQueue::QueueCommand(dest, yl, spacing, ycount, fg, alpha, fracposx); + for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx) + { + dc_x = x; + if (R_ClipSpriteColumnWithPortals(vis)) + continue; + uint32_t *dest = ylookup[yl] + x + (uint32_t*)dc_destorg; + DrawerCommandQueue::QueueCommand(dest, yl, spacing, ycount, fg, alpha, fracposx); + } + } + else + { + for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx) + { + dc_x = x; + if (R_ClipSpriteColumnWithPortals(vis)) + continue; + uint8_t *dest = ylookup[yl] + x + dc_destorg; + DrawerCommandQueue::QueueCommand(dest, yl, spacing, ycount, fg, alpha, fracposx); + } } } diff --git a/src/r_things.h b/src/r_things.h index 2fa8786a9..7f00ce177 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -101,7 +101,6 @@ struct vissprite_t }; void R_DrawParticle (vissprite_t *); -void R_DrawParticle_rgba (vissprite_t *); void R_ProjectParticle (particle_t *, const sector_t *sector, int shade, int fakeside);